aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/BaseHTTPServer.py603
-rw-r--r--Lib/Bastion.py180
-rw-r--r--Lib/CGIHTTPServer.py378
-rw-r--r--Lib/ConfigParser.py753
-rw-r--r--Lib/DocXMLRPCServer.py279
-rw-r--r--Lib/MimeWriter.py186
-rw-r--r--Lib/SimpleHTTPServer.py220
-rw-r--r--Lib/StringIO.py324
-rw-r--r--Lib/UserDict.py180
-rw-r--r--Lib/UserList.py88
-rwxr-xr-xLib/UserString.py228
-rw-r--r--Lib/_LWPCookieJar.py170
-rw-r--r--Lib/_MozillaCookieJar.py149
-rw-r--r--Lib/__future__.py6
-rw-r--r--Lib/_abcoll.py146
-rw-r--r--Lib/_compat_pickle.py81
-rw-r--r--Lib/_dummy_thread.py (renamed from Lib/dummy_thread.py)40
-rw-r--r--Lib/_markupbase.py (renamed from Lib/markupbase.py)15
-rw-r--r--Lib/_pyio.py258
-rw-r--r--Lib/_strptime.py70
-rw-r--r--Lib/_threading_local.py159
-rw-r--r--Lib/_weakrefset.py6
-rw-r--r--Lib/abc.py88
-rw-r--r--Lib/aifc.py338
-rw-r--r--Lib/antigravity.py13
-rw-r--r--Lib/anydbm.py85
-rw-r--r--Lib/argparse.py77
-rw-r--r--Lib/ast.py31
-rw-r--r--Lib/asynchat.py56
-rw-r--r--Lib/asyncore.py42
-rw-r--r--Lib/atexit.py65
-rw-r--r--Lib/audiodev.py260
-rwxr-xr-xLib/base64.py328
-rw-r--r--Lib/bdb.py204
-rw-r--r--Lib/binhex.py248
-rw-r--r--Lib/bsddb/__init__.py455
-rw-r--r--Lib/bsddb/db.py60
-rw-r--r--Lib/bsddb/dbobj.py269
-rw-r--r--Lib/bsddb/dbrecio.py190
-rw-r--r--Lib/bsddb/dbshelve.py402
-rw-r--r--Lib/bsddb/dbtables.py843
-rw-r--r--Lib/bsddb/dbutils.py83
-rw-r--r--Lib/bsddb/test/test_all.py622
-rw-r--r--Lib/bsddb/test/test_associate.py465
-rw-r--r--Lib/bsddb/test/test_basics.py1192
-rw-r--r--Lib/bsddb/test/test_compare.py273
-rw-r--r--Lib/bsddb/test/test_compat.py184
-rw-r--r--Lib/bsddb/test/test_cursor_pget_bug.py54
-rw-r--r--Lib/bsddb/test/test_db.py142
-rw-r--r--Lib/bsddb/test/test_dbenv.py513
-rw-r--r--Lib/bsddb/test/test_dbobj.py70
-rw-r--r--Lib/bsddb/test/test_dbshelve.py405
-rw-r--r--Lib/bsddb/test/test_dbtables.py409
-rw-r--r--Lib/bsddb/test/test_distributed_transactions.py163
-rw-r--r--Lib/bsddb/test/test_early_close.py216
-rw-r--r--Lib/bsddb/test/test_fileid.py61
-rw-r--r--Lib/bsddb/test/test_get_none.py92
-rw-r--r--Lib/bsddb/test/test_join.py99
-rw-r--r--Lib/bsddb/test/test_lock.py191
-rw-r--r--Lib/bsddb/test/test_misc.py149
-rw-r--r--Lib/bsddb/test/test_pickle.py68
-rw-r--r--Lib/bsddb/test/test_queue.py168
-rw-r--r--Lib/bsddb/test/test_recno.py310
-rw-r--r--Lib/bsddb/test/test_replication.py495
-rw-r--r--Lib/bsddb/test/test_sequence.py142
-rw-r--r--Lib/bsddb/test/test_thread.py521
-rwxr-xr-xLib/cProfile.py12
-rw-r--r--Lib/calendar.py41
-rwxr-xr-xLib/cgi.py524
-rw-r--r--Lib/cgitb.py20
-rw-r--r--Lib/chunk.py14
-rw-r--r--Lib/cmd.py15
-rw-r--r--Lib/code.py47
-rw-r--r--Lib/codecs.py105
-rw-r--r--Lib/codeop.py12
-rw-r--r--Lib/collections.py666
-rw-r--r--Lib/commands.py90
-rw-r--r--Lib/compileall.py245
-rw-r--r--Lib/compiler/__init__.py31
-rw-r--r--Lib/compiler/ast.py1419
-rw-r--r--Lib/compiler/consts.py23
-rw-r--r--Lib/compiler/future.py74
-rw-r--r--Lib/compiler/misc.py73
-rw-r--r--Lib/compiler/pyassem.py763
-rw-r--r--Lib/compiler/pycodegen.py1555
-rw-r--r--Lib/compiler/symbols.py462
-rw-r--r--Lib/compiler/syntax.py46
-rw-r--r--Lib/compiler/transformer.py1535
-rw-r--r--Lib/compiler/visitor.py113
-rw-r--r--Lib/concurrent/__init__.py1
-rw-r--r--Lib/concurrent/futures/__init__.py18
-rw-r--r--Lib/concurrent/futures/_base.py569
-rw-r--r--Lib/concurrent/futures/process.py356
-rw-r--r--Lib/concurrent/futures/thread.py130
-rw-r--r--Lib/configparser.py1247
-rw-r--r--Lib/contextlib.py91
-rw-r--r--Lib/copy.py113
-rw-r--r--Lib/copyreg.py (renamed from Lib/copy_reg.py)19
-rw-r--r--Lib/csv.py67
-rw-r--r--Lib/ctypes/__init__.py72
-rw-r--r--Lib/ctypes/_endian.py11
-rw-r--r--Lib/ctypes/macholib/__init__.py3
-rw-r--r--Lib/ctypes/macholib/dyld.py17
-rw-r--r--Lib/ctypes/macholib/dylib.py3
-rw-r--r--Lib/ctypes/macholib/framework.py3
-rw-r--r--Lib/ctypes/test/__init__.py18
-rw-r--r--Lib/ctypes/test/test_array_in_pointer.py2
-rw-r--r--Lib/ctypes/test/test_arrays.py89
-rw-r--r--Lib/ctypes/test/test_as_parameter.py4
-rw-r--r--Lib/ctypes/test/test_bitfields.py6
-rw-r--r--Lib/ctypes/test/test_buffers.py42
-rw-r--r--Lib/ctypes/test/test_bytes.py50
-rw-r--r--Lib/ctypes/test/test_byteswap.py10
-rw-r--r--Lib/ctypes/test/test_callbacks.py22
-rw-r--r--Lib/ctypes/test/test_cast.py18
-rw-r--r--Lib/ctypes/test/test_cfuncs.py2
-rw-r--r--Lib/ctypes/test/test_errno.py5
-rw-r--r--Lib/ctypes/test/test_find.py4
-rw-r--r--Lib/ctypes/test/test_frombuffer.py10
-rw-r--r--Lib/ctypes/test/test_funcptr.py14
-rw-r--r--Lib/ctypes/test/test_functions.py10
-rw-r--r--Lib/ctypes/test/test_incomplete.py6
-rw-r--r--Lib/ctypes/test/test_init.py2
-rw-r--r--Lib/ctypes/test/test_internals.py6
-rw-r--r--Lib/ctypes/test/test_keeprefs.py28
-rw-r--r--Lib/ctypes/test/test_libc.py10
-rw-r--r--Lib/ctypes/test/test_loading.py8
-rw-r--r--Lib/ctypes/test/test_memfunctions.py28
-rw-r--r--Lib/ctypes/test/test_numbers.py21
-rw-r--r--Lib/ctypes/test/test_objects.py18
-rw-r--r--Lib/ctypes/test/test_parameters.py18
-rw-r--r--Lib/ctypes/test/test_pep3118.py2
-rw-r--r--Lib/ctypes/test/test_pickling.py4
-rw-r--r--Lib/ctypes/test/test_pointers.py22
-rw-r--r--Lib/ctypes/test/test_prototypes.py56
-rw-r--r--Lib/ctypes/test/test_python_api.py38
-rw-r--r--Lib/ctypes/test/test_random_things.py14
-rw-r--r--Lib/ctypes/test/test_repr.py4
-rw-r--r--Lib/ctypes/test/test_returnfuncptrs.py18
-rw-r--r--Lib/ctypes/test/test_simplesubclasses.py8
-rw-r--r--Lib/ctypes/test/test_slicing.py50
-rw-r--r--Lib/ctypes/test/test_stringptr.py26
-rw-r--r--Lib/ctypes/test/test_strings.py110
-rw-r--r--Lib/ctypes/test/test_structures.py56
-rw-r--r--Lib/ctypes/test/test_unicode.py112
-rw-r--r--Lib/ctypes/test/test_values.py6
-rw-r--r--Lib/ctypes/util.py60
-rw-r--r--Lib/ctypes/wintypes.py173
-rw-r--r--Lib/curses/__init__.py4
-rw-r--r--Lib/curses/has_key.py4
-rw-r--r--Lib/curses/panel.py2
-rw-r--r--Lib/curses/textpad.py2
-rw-r--r--Lib/datetime.py2114
-rw-r--r--Lib/dbhash.py18
-rw-r--r--Lib/dbm/__init__.py185
-rw-r--r--Lib/dbm/dumb.py (renamed from Lib/dumbdbm.py)79
-rw-r--r--Lib/dbm/gnu.py3
-rw-r--r--Lib/dbm/ndbm.py3
-rw-r--r--Lib/decimal.py563
-rw-r--r--Lib/difflib.py127
-rw-r--r--Lib/dircache.py41
-rw-r--r--Lib/dis.py229
-rw-r--r--Lib/distutils/__init__.py4
-rw-r--r--Lib/distutils/archive_util.py105
-rw-r--r--Lib/distutils/bcppcompiler.py37
-rw-r--r--Lib/distutils/ccompiler.py281
-rw-r--r--Lib/distutils/cmd.py112
-rw-r--r--Lib/distutils/command/__init__.py4
-rw-r--r--Lib/distutils/command/bdist.py28
-rw-r--r--Lib/distutils/command/bdist_dumb.py38
-rw-r--r--Lib/distutils/command/bdist_msi.py37
-rw-r--r--Lib/distutils/command/bdist_rpm.py103
-rw-r--r--Lib/distutils/command/bdist_wininst.py83
-rw-r--r--Lib/distutils/command/build.py17
-rw-r--r--Lib/distutils/command/build_clib.py48
-rw-r--r--Lib/distutils/command/build_ext.py129
-rw-r--r--Lib/distutils/command/build_py.py44
-rw-r--r--Lib/distutils/command/build_scripts.py88
-rw-r--r--Lib/distutils/command/check.py12
-rw-r--r--Lib/distutils/command/clean.py4
-rw-r--r--Lib/distutils/command/command_template20
-rw-r--r--Lib/distutils/command/config.py40
-rw-r--r--Lib/distutils/command/install.py272
-rw-r--r--Lib/distutils/command/install_data.py2
-rw-r--r--Lib/distutils/command/install_egg_info.py5
-rw-r--r--Lib/distutils/command/install_headers.py4
-rw-r--r--Lib/distutils/command/install_lib.py20
-rw-r--r--Lib/distutils/command/install_scripts.py18
-rw-r--r--Lib/distutils/command/register.py77
-rw-r--r--Lib/distutils/command/sdist.py51
-rw-r--r--Lib/distutils/command/upload.py120
-rw-r--r--Lib/distutils/command/wininst-9.0-amd64.exebin223744 -> 224256 bytes
-rw-r--r--Lib/distutils/command/wininst-9.0.exebin196096 -> 196096 bytes
-rw-r--r--Lib/distutils/config.py9
-rw-r--r--Lib/distutils/core.py71
-rw-r--r--Lib/distutils/cygwinccompiler.py235
-rw-r--r--Lib/distutils/debug.py2
-rw-r--r--Lib/distutils/dep_util.py67
-rw-r--r--Lib/distutils/dir_util.py37
-rw-r--r--Lib/distutils/dist.py242
-rw-r--r--Lib/distutils/emxccompiler.py24
-rw-r--r--Lib/distutils/errors.py49
-rw-r--r--Lib/distutils/extension.py82
-rw-r--r--Lib/distutils/fancy_getopt.py167
-rw-r--r--Lib/distutils/file_util.py95
-rw-r--r--Lib/distutils/filelist.py93
-rw-r--r--Lib/distutils/log.py4
-rw-r--r--Lib/distutils/msvc9compiler.py59
-rw-r--r--Lib/distutils/msvccompiler.py267
-rw-r--r--Lib/distutils/spawn.py67
-rw-r--r--Lib/distutils/sysconfig.py152
-rw-r--r--Lib/distutils/tests/__init__.py2
-rw-r--r--Lib/distutils/tests/setuptools_build_ext.py287
-rw-r--r--Lib/distutils/tests/setuptools_extension.py51
-rw-r--r--Lib/distutils/tests/support.py28
-rw-r--r--Lib/distutils/tests/test_archive_util.py154
-rw-r--r--Lib/distutils/tests/test_bdist.py6
-rw-r--r--Lib/distutils/tests/test_bdist_dumb.py37
-rw-r--r--Lib/distutils/tests/test_bdist_msi.py2
-rw-r--r--Lib/distutils/tests/test_bdist_rpm.py3
-rw-r--r--Lib/distutils/tests/test_bdist_wininst.py3
-rw-r--r--Lib/distutils/tests/test_build.py2
-rw-r--r--Lib/distutils/tests/test_build_clib.py2
-rw-r--r--Lib/distutils/tests/test_build_ext.py185
-rw-r--r--Lib/distutils/tests/test_build_py.py81
-rw-r--r--Lib/distutils/tests/test_build_scripts.py8
-rw-r--r--Lib/distutils/tests/test_ccompiler.py82
-rw-r--r--Lib/distutils/tests/test_check.py17
-rw-r--r--Lib/distutils/tests/test_clean.py2
-rw-r--r--Lib/distutils/tests/test_cmd.py2
-rw-r--r--Lib/distutils/tests/test_config.py9
-rw-r--r--Lib/distutils/tests/test_config_cmd.py2
-rw-r--r--Lib/distutils/tests/test_core.py18
-rw-r--r--Lib/distutils/tests/test_cygwinccompiler.py155
-rw-r--r--Lib/distutils/tests/test_dep_util.py2
-rw-r--r--Lib/distutils/tests/test_dir_util.py13
-rw-r--r--Lib/distutils/tests/test_dist.py183
-rw-r--r--Lib/distutils/tests/test_extension.py69
-rw-r--r--Lib/distutils/tests/test_file_util.py19
-rw-r--r--Lib/distutils/tests/test_filelist.py2
-rw-r--r--Lib/distutils/tests/test_install.py13
-rw-r--r--Lib/distutils/tests/test_install_data.py2
-rw-r--r--Lib/distutils/tests/test_install_headers.py2
-rw-r--r--Lib/distutils/tests/test_install_lib.py70
-rw-r--r--Lib/distutils/tests/test_install_scripts.py2
-rw-r--r--Lib/distutils/tests/test_log.py37
-rw-r--r--Lib/distutils/tests/test_msvc9compiler.py10
-rw-r--r--Lib/distutils/tests/test_register.py82
-rw-r--r--Lib/distutils/tests/test_sdist.py102
-rw-r--r--Lib/distutils/tests/test_spawn.py8
-rw-r--r--Lib/distutils/tests/test_sysconfig.py61
-rw-r--r--Lib/distutils/tests/test_text_file.py2
-rw-r--r--Lib/distutils/tests/test_unixccompiler.py14
-rw-r--r--Lib/distutils/tests/test_upload.py69
-rw-r--r--Lib/distutils/tests/test_util.py264
-rw-r--r--Lib/distutils/tests/test_version.py6
-rw-r--r--Lib/distutils/tests/test_versionpredicate.py2
-rw-r--r--Lib/distutils/text_file.py91
-rw-r--r--Lib/distutils/unixccompiler.py68
-rw-r--r--Lib/distutils/util.py163
-rw-r--r--Lib/distutils/version.py124
-rw-r--r--Lib/distutils/versionpredicate.py8
-rw-r--r--Lib/doctest.py353
-rw-r--r--Lib/dummy_threading.py20
-rw-r--r--Lib/email/__init__.py99
-rw-r--r--Lib/email/_parseaddr.py22
-rw-r--r--Lib/email/base64mime.py116
-rw-r--r--Lib/email/charset.py238
-rw-r--r--Lib/email/encoders.py34
-rw-r--r--Lib/email/feedparser.py19
-rw-r--r--Lib/email/generator.py263
-rw-r--r--Lib/email/header.py662
-rw-r--r--Lib/email/iterators.py10
-rw-r--r--Lib/email/message.py210
-rw-r--r--Lib/email/mime/audio.py6
-rw-r--r--Lib/email/parser.py51
-rw-r--r--Lib/email/quoprimime.py322
-rw-r--r--Lib/email/test/data/msg_15.txt2
-rw-r--r--Lib/email/test/data/msg_26.txt5
-rw-r--r--Lib/email/test/test_email.py2314
-rw-r--r--Lib/email/test/test_email_codecs.py48
-rw-r--r--Lib/email/test/test_email_codecs_renamed.py77
-rw-r--r--Lib/email/test/test_email_renamed.py3297
-rw-r--r--Lib/email/test/test_email_torture.py4
-rw-r--r--Lib/email/utils.py88
-rw-r--r--Lib/encodings/__init__.py53
-rw-r--r--Lib/encodings/aliases.py42
-rw-r--r--Lib/encodings/base64_codec.py66
-rw-r--r--Lib/encodings/bz2_codec.py53
-rw-r--r--Lib/encodings/cp037.py512
-rw-r--r--Lib/encodings/cp1006.py512
-rw-r--r--Lib/encodings/cp1026.py512
-rw-r--r--Lib/encodings/cp1140.py512
-rw-r--r--Lib/encodings/cp1250.py512
-rw-r--r--Lib/encodings/cp1251.py512
-rw-r--r--Lib/encodings/cp1252.py512
-rw-r--r--Lib/encodings/cp1253.py512
-rw-r--r--Lib/encodings/cp1254.py512
-rw-r--r--Lib/encodings/cp1255.py512
-rw-r--r--Lib/encodings/cp1256.py512
-rw-r--r--Lib/encodings/cp1257.py512
-rw-r--r--Lib/encodings/cp1258.py512
-rw-r--r--Lib/encodings/cp424.py512
-rw-r--r--Lib/encodings/cp437.py512
-rw-r--r--Lib/encodings/cp500.py512
-rw-r--r--Lib/encodings/cp720.py512
-rw-r--r--Lib/encodings/cp737.py512
-rw-r--r--Lib/encodings/cp775.py512
-rw-r--r--Lib/encodings/cp850.py512
-rw-r--r--Lib/encodings/cp852.py512
-rw-r--r--Lib/encodings/cp855.py512
-rw-r--r--Lib/encodings/cp856.py512
-rw-r--r--Lib/encodings/cp857.py512
-rw-r--r--Lib/encodings/cp858.py512
-rw-r--r--Lib/encodings/cp860.py512
-rw-r--r--Lib/encodings/cp861.py512
-rw-r--r--Lib/encodings/cp862.py512
-rw-r--r--Lib/encodings/cp863.py512
-rw-r--r--Lib/encodings/cp864.py512
-rw-r--r--Lib/encodings/cp865.py512
-rw-r--r--Lib/encodings/cp866.py512
-rw-r--r--Lib/encodings/cp869.py512
-rw-r--r--Lib/encodings/cp874.py512
-rw-r--r--Lib/encodings/cp875.py512
-rw-r--r--Lib/encodings/hex_codec.py62
-rw-r--r--Lib/encodings/idna.py95
-rw-r--r--Lib/encodings/iso8859_1.py512
-rw-r--r--Lib/encodings/iso8859_10.py512
-rw-r--r--Lib/encodings/iso8859_11.py512
-rw-r--r--Lib/encodings/iso8859_13.py512
-rw-r--r--Lib/encodings/iso8859_14.py512
-rw-r--r--Lib/encodings/iso8859_15.py512
-rw-r--r--Lib/encodings/iso8859_16.py512
-rw-r--r--Lib/encodings/iso8859_2.py512
-rw-r--r--Lib/encodings/iso8859_3.py512
-rw-r--r--Lib/encodings/iso8859_4.py512
-rw-r--r--Lib/encodings/iso8859_5.py512
-rw-r--r--Lib/encodings/iso8859_6.py512
-rw-r--r--Lib/encodings/iso8859_7.py512
-rw-r--r--Lib/encodings/iso8859_8.py512
-rw-r--r--Lib/encodings/iso8859_9.py512
-rw-r--r--Lib/encodings/koi8_r.py512
-rw-r--r--Lib/encodings/koi8_u.py512
-rw-r--r--Lib/encodings/mac_arabic.py512
-rw-r--r--Lib/encodings/mac_centeuro.py512
-rw-r--r--Lib/encodings/mac_croatian.py512
-rw-r--r--Lib/encodings/mac_cyrillic.py512
-rw-r--r--Lib/encodings/mac_farsi.py512
-rw-r--r--Lib/encodings/mac_greek.py512
-rw-r--r--Lib/encodings/mac_iceland.py512
-rw-r--r--Lib/encodings/mac_roman.py512
-rw-r--r--Lib/encodings/mac_romanian.py512
-rw-r--r--Lib/encodings/mac_turkish.py512
-rw-r--r--Lib/encodings/punycode.py57
-rw-r--r--Lib/encodings/quopri_codec.py55
-rwxr-xr-x[-rw-r--r--]Lib/encodings/rot_13.py31
-rw-r--r--Lib/encodings/string_escape.py38
-rw-r--r--Lib/encodings/tis_620.py512
-rw-r--r--Lib/encodings/utf_16.py31
-rw-r--r--Lib/encodings/utf_32.py2
-rw-r--r--Lib/encodings/utf_8_sig.py31
-rw-r--r--Lib/encodings/uu_codec.py100
-rw-r--r--Lib/encodings/zlib_codec.py51
-rw-r--r--Lib/filecmp.py62
-rw-r--r--Lib/fileinput.py74
-rw-r--r--Lib/fnmatch.py45
-rw-r--r--Lib/formatter.py26
-rw-r--r--Lib/fpformat.py145
-rw-r--r--Lib/fractions.py129
-rw-r--r--Lib/ftplib.py256
-rw-r--r--Lib/functools.py122
-rw-r--r--Lib/genericpath.py5
-rw-r--r--Lib/getopt.py4
-rw-r--r--Lib/getpass.py24
-rw-r--r--Lib/gettext.py170
-rw-r--r--Lib/glob.py35
-rw-r--r--Lib/gzip.py285
-rw-r--r--Lib/hashlib.py70
-rw-r--r--Lib/heapq.py46
-rw-r--r--Lib/hmac.py30
-rw-r--r--Lib/hotshot/__init__.py78
-rw-r--r--Lib/hotshot/log.py194
-rw-r--r--Lib/hotshot/stats.py93
-rw-r--r--Lib/hotshot/stones.py30
-rw-r--r--Lib/html/__init__.py21
-rw-r--r--Lib/html/entities.py (renamed from Lib/htmlentitydefs.py)7
-rw-r--r--Lib/html/parser.py (renamed from Lib/HTMLParser.py)108
-rw-r--r--Lib/htmllib.py491
-rw-r--r--Lib/http/__init__.py1
-rw-r--r--Lib/http/client.py (renamed from Lib/httplib.py)778
-rw-r--r--Lib/http/cookiejar.py (renamed from Lib/cookielib.py)381
-rw-r--r--Lib/http/cookies.py (renamed from Lib/Cookie.py)480
-rw-r--r--Lib/http/server.py1192
-rw-r--r--Lib/idlelib/AutoComplete.py13
-rw-r--r--Lib/idlelib/AutoCompleteWindow.py11
-rw-r--r--Lib/idlelib/CallTipWindow.py2
-rw-r--r--Lib/idlelib/CallTips.py297
-rw-r--r--Lib/idlelib/ClassBrowser.py2
-rw-r--r--Lib/idlelib/CodeContext.py10
-rw-r--r--Lib/idlelib/ColorDelegator.py55
-rw-r--r--Lib/idlelib/Debugger.py33
-rw-r--r--Lib/idlelib/Delegator.py6
-rw-r--r--Lib/idlelib/EditorWindow.py147
-rw-r--r--Lib/idlelib/FileList.py17
-rw-r--r--Lib/idlelib/FormatParagraph.py5
-rw-r--r--Lib/idlelib/GrepDialog.py20
-rw-r--r--Lib/idlelib/IOBinding.py308
-rw-r--r--Lib/idlelib/MultiCall.py26
-rw-r--r--Lib/idlelib/MultiStatusBar.py2
-rw-r--r--Lib/idlelib/NEWS.txt125
-rw-r--r--Lib/idlelib/ObjectBrowser.py33
-rw-r--r--Lib/idlelib/OutputWindow.py15
-rw-r--r--Lib/idlelib/Percolator.py13
-rw-r--r--Lib/idlelib/PyParse.py28
-rw-r--r--Lib/idlelib/PyShell.py229
-rw-r--r--Lib/idlelib/README.txt9
-rw-r--r--Lib/idlelib/RemoteDebugger.py33
-rw-r--r--Lib/idlelib/RemoteObjectBrowser.py8
-rw-r--r--Lib/idlelib/ReplaceDialog.py3
-rw-r--r--Lib/idlelib/ScriptBinding.py117
-rw-r--r--Lib/idlelib/ScrolledList.py6
-rw-r--r--Lib/idlelib/SearchDialog.py2
-rw-r--r--Lib/idlelib/SearchDialogBase.py2
-rw-r--r--Lib/idlelib/SearchEngine.py6
-rw-r--r--Lib/idlelib/StackViewer.py19
-rw-r--r--Lib/idlelib/ToolTip.py2
-rw-r--r--Lib/idlelib/TreeWidget.py4
-rw-r--r--Lib/idlelib/UndoDelegator.py10
-rw-r--r--Lib/idlelib/WidgetRedirector.py4
-rw-r--r--Lib/idlelib/WindowList.py12
-rw-r--r--Lib/idlelib/aboutDialog.py2
-rw-r--r--Lib/idlelib/config-main.def4
-rw-r--r--Lib/idlelib/configDialog.py105
-rw-r--r--Lib/idlelib/configHandler.py48
-rw-r--r--Lib/idlelib/configHelpSourceEdit.py8
-rw-r--r--Lib/idlelib/configSectionNameDialog.py6
-rw-r--r--Lib/idlelib/dynOptionMenuWidget.py6
-rw-r--r--Lib/idlelib/help.txt4
-rw-r--r--Lib/idlelib/idle.pyw2
-rw-r--r--Lib/idlelib/idlever.py2
-rw-r--r--Lib/idlelib/keybindingDialog.py13
-rw-r--r--Lib/idlelib/macosxSupport.py12
-rw-r--r--Lib/idlelib/rpc.py108
-rw-r--r--Lib/idlelib/run.py79
-rw-r--r--Lib/idlelib/tabbedpages.py12
-rw-r--r--Lib/idlelib/textView.py15
-rw-r--r--Lib/ihooks.py554
-rw-r--r--Lib/imaplib.py277
-rw-r--r--Lib/imghdr.py49
-rw-r--r--Lib/importlib/__init__.py126
-rw-r--r--Lib/importlib/_bootstrap.py890
-rw-r--r--Lib/importlib/abc.py304
-rw-r--r--Lib/importlib/machinery.py5
-rw-r--r--Lib/importlib/test/__init__.py (renamed from Lib/bsddb/test/__init__.py)0
-rw-r--r--Lib/importlib/test/__main__.py29
-rw-r--r--Lib/importlib/test/abc.py99
-rw-r--r--Lib/importlib/test/benchmark.py172
-rw-r--r--Lib/importlib/test/builtin/__init__.py12
-rw-r--r--Lib/importlib/test/builtin/test_finder.py55
-rw-r--r--Lib/importlib/test/builtin/test_loader.py102
-rw-r--r--Lib/importlib/test/builtin/util.py7
-rw-r--r--Lib/importlib/test/extension/__init__.py13
-rw-r--r--Lib/importlib/test/extension/test_case_sensitivity.py42
-rw-r--r--Lib/importlib/test/extension/test_finder.py47
-rw-r--r--Lib/importlib/test/extension/test_loader.py59
-rw-r--r--Lib/importlib/test/extension/test_path_hook.py31
-rw-r--r--Lib/importlib/test/extension/util.py21
-rw-r--r--Lib/importlib/test/frozen/__init__.py13
-rw-r--r--Lib/importlib/test/frozen/test_finder.py47
-rw-r--r--Lib/importlib/test/frozen/test_loader.py105
-rw-r--r--Lib/importlib/test/import_/__init__.py13
-rw-r--r--Lib/importlib/test/import_/test___package__.py119
-rw-r--r--Lib/importlib/test/import_/test_api.py22
-rw-r--r--Lib/importlib/test/import_/test_caching.py86
-rw-r--r--Lib/importlib/test/import_/test_fromlist.py123
-rw-r--r--Lib/importlib/test/import_/test_meta_path.py97
-rw-r--r--Lib/importlib/test/import_/test_packages.py37
-rw-r--r--Lib/importlib/test/import_/test_path.py131
-rw-r--r--Lib/importlib/test/import_/test_relative_imports.py203
-rw-r--r--Lib/importlib/test/import_/util.py29
-rw-r--r--Lib/importlib/test/regrtest.py35
-rw-r--r--Lib/importlib/test/source/__init__.py13
-rw-r--r--Lib/importlib/test/source/test_abc_loader.py876
-rw-r--r--Lib/importlib/test/source/test_case_sensitivity.py60
-rw-r--r--Lib/importlib/test/source/test_file_loader.py419
-rw-r--r--Lib/importlib/test/source/test_finder.py153
-rw-r--r--Lib/importlib/test/source/test_path_hook.py26
-rw-r--r--Lib/importlib/test/source/test_source_encoding.py123
-rw-r--r--Lib/importlib/test/source/util.py97
-rw-r--r--Lib/importlib/test/test_abc.py89
-rw-r--r--Lib/importlib/test/test_api.py93
-rw-r--r--Lib/importlib/test/test_util.py118
-rw-r--r--Lib/importlib/test/util.py136
-rw-r--r--Lib/importlib/util.py5
-rw-r--r--Lib/imputil.py725
-rw-r--r--Lib/inspect.py534
-rw-r--r--Lib/io.py4
-rw-r--r--Lib/json/__init__.py99
-rw-r--r--Lib/json/decoder.py90
-rw-r--r--Lib/json/encoder.py75
-rw-r--r--Lib/json/scanner.py14
-rw-r--r--Lib/json/tests/test_check_circular.py34
-rw-r--r--Lib/json/tests/test_encode_basestring_ascii.py41
-rw-r--r--Lib/json/tests/test_scanstring.py109
-rw-r--r--Lib/json/tests/test_unicode.py89
-rw-r--r--Lib/json/tool.py8
-rwxr-xr-xLib/keyword.py30
-rw-r--r--Lib/lib-tk/Canvas.py194
-rw-r--r--Lib/lib-tk/SimpleDialog.py112
-rw-r--r--Lib/lib-tk/test/runtktests.py114
-rw-r--r--Lib/lib-tk/test/test_ttk/support.py33
-rw-r--r--Lib/lib-tk/tkFileDialog.py215
-rw-r--r--Lib/lib2to3/__main__.py4
-rw-r--r--Lib/lib2to3/btm_matcher.py2
-rw-r--r--Lib/lib2to3/fixer_base.py6
-rw-r--r--Lib/lib2to3/fixer_util.py74
-rw-r--r--Lib/lib2to3/fixes/fix_apply.py6
-rw-r--r--Lib/lib2to3/fixes/fix_basestring.py2
-rw-r--r--Lib/lib2to3/fixes/fix_buffer.py2
-rw-r--r--Lib/lib2to3/fixes/fix_callable.py8
-rw-r--r--Lib/lib2to3/fixes/fix_dict.py10
-rw-r--r--Lib/lib2to3/fixes/fix_except.py14
-rw-r--r--Lib/lib2to3/fixes/fix_exec.py2
-rw-r--r--Lib/lib2to3/fixes/fix_execfile.py12
-rw-r--r--Lib/lib2to3/fixes/fix_exitfunc.py8
-rw-r--r--Lib/lib2to3/fixes/fix_filter.py10
-rw-r--r--Lib/lib2to3/fixes/fix_funcattrs.py2
-rw-r--r--Lib/lib2to3/fixes/fix_getcwdu.py2
-rw-r--r--Lib/lib2to3/fixes/fix_has_key.py6
-rw-r--r--Lib/lib2to3/fixes/fix_idioms.py26
-rw-r--r--Lib/lib2to3/fixes/fix_import.py8
-rw-r--r--Lib/lib2to3/fixes/fix_imports.py2
-rw-r--r--Lib/lib2to3/fixes/fix_input.py4
-rw-r--r--Lib/lib2to3/fixes/fix_intern.py4
-rw-r--r--Lib/lib2to3/fixes/fix_isinstance.py2
-rw-r--r--Lib/lib2to3/fixes/fix_itertools.py2
-rw-r--r--Lib/lib2to3/fixes/fix_itertools_imports.py8
-rw-r--r--Lib/lib2to3/fixes/fix_long.py2
-rw-r--r--Lib/lib2to3/fixes/fix_map.py8
-rw-r--r--Lib/lib2to3/fixes/fix_metaclass.py26
-rw-r--r--Lib/lib2to3/fixes/fix_methodattrs.py2
-rw-r--r--Lib/lib2to3/fixes/fix_ne.py4
-rw-r--r--Lib/lib2to3/fixes/fix_next.py14
-rw-r--r--Lib/lib2to3/fixes/fix_nonzero.py2
-rw-r--r--Lib/lib2to3/fixes/fix_numliterals.py8
-rw-r--r--Lib/lib2to3/fixes/fix_operator.py32
-rw-r--r--Lib/lib2to3/fixes/fix_paren.py2
-rw-r--r--Lib/lib2to3/fixes/fix_print.py22
-rw-r--r--Lib/lib2to3/fixes/fix_raise.py16
-rw-r--r--Lib/lib2to3/fixes/fix_raw_input.py2
-rw-r--r--Lib/lib2to3/fixes/fix_reduce.py2
-rw-r--r--Lib/lib2to3/fixes/fix_renames.py6
-rw-r--r--Lib/lib2to3/fixes/fix_repr.py2
-rw-r--r--Lib/lib2to3/fixes/fix_set_literal.py4
-rw-r--r--Lib/lib2to3/fixes/fix_standarderror.py2
-rw-r--r--Lib/lib2to3/fixes/fix_sys_exc.py6
-rw-r--r--Lib/lib2to3/fixes/fix_throw.py8
-rw-r--r--Lib/lib2to3/fixes/fix_tuple_params.py18
-rw-r--r--Lib/lib2to3/fixes/fix_types.py2
-rw-r--r--Lib/lib2to3/fixes/fix_unicode.py4
-rw-r--r--Lib/lib2to3/fixes/fix_urllib.py2
-rw-r--r--Lib/lib2to3/fixes/fix_ws_comma.py10
-rw-r--r--Lib/lib2to3/fixes/fix_xrange.py10
-rw-r--r--Lib/lib2to3/fixes/fix_xreadlines.py2
-rw-r--r--Lib/lib2to3/fixes/fix_zip.py4
-rw-r--r--Lib/lib2to3/main.py25
-rw-r--r--Lib/lib2to3/patcomp.py6
-rw-r--r--Lib/lib2to3/pgen2/conv.py66
-rw-r--r--Lib/lib2to3/pgen2/driver.py8
-rw-r--r--Lib/lib2to3/pgen2/grammar.py12
-rw-r--r--Lib/lib2to3/pgen2/literals.py2
-rw-r--r--Lib/lib2to3/pgen2/pgen.py40
-rwxr-xr-xLib/lib2to3/pgen2/token.py4
-rw-r--r--Lib/lib2to3/pgen2/tokenize.py18
-rw-r--r--Lib/lib2to3/pygram.py2
-rw-r--r--Lib/lib2to3/pytree.py20
-rw-r--r--Lib/lib2to3/refactor.py52
-rwxr-xr-xLib/lib2to3/tests/pytree_idempotency.py20
-rw-r--r--Lib/lib2to3/tests/support.py2
-rw-r--r--Lib/lib2to3/tests/test_fixers.py12
-rw-r--r--Lib/lib2to3/tests/test_main.py36
-rw-r--r--Lib/lib2to3/tests/test_parser.py41
-rw-r--r--Lib/lib2to3/tests/test_refactor.py8
-rw-r--r--Lib/lib2to3/tests/test_util.py10
-rw-r--r--Lib/linecache.py7
-rw-r--r--Lib/locale.py169
-rw-r--r--Lib/logging/__init__.py446
-rw-r--r--Lib/logging/config.py200
-rw-r--r--Lib/logging/handlers.py254
-rw-r--r--Lib/macpath.py102
-rw-r--r--Lib/macurl2path.py20
-rw-r--r--Lib/mailbox.py642
-rw-r--r--Lib/mailcap.py34
-rw-r--r--Lib/md5.py14
-rw-r--r--Lib/mhlib.py1005
-rw-r--r--Lib/mimetools.py250
-rw-r--r--Lib/mimetypes.py38
-rwxr-xr-xLib/mimify.py468
-rw-r--r--Lib/modulefinder.py128
-rw-r--r--Lib/msilib/__init__.py17
-rw-r--r--Lib/msilib/schema.py848
-rw-r--r--Lib/msilib/sequence.py220
-rw-r--r--Lib/msilib/text.py240
-rw-r--r--Lib/multifile.py162
-rw-r--r--Lib/multiprocessing/__init__.py1
-rw-r--r--Lib/multiprocessing/connection.py60
-rw-r--r--Lib/multiprocessing/dummy/__init__.py10
-rw-r--r--Lib/multiprocessing/dummy/connection.py2
-rw-r--r--Lib/multiprocessing/forking.py51
-rw-r--r--Lib/multiprocessing/heap.py6
-rw-r--r--Lib/multiprocessing/managers.py53
-rw-r--r--Lib/multiprocessing/pool.py63
-rw-r--r--Lib/multiprocessing/process.py41
-rw-r--r--Lib/multiprocessing/queues.py12
-rw-r--r--Lib/multiprocessing/sharedctypes.py11
-rw-r--r--Lib/multiprocessing/synchronize.py11
-rw-r--r--Lib/multiprocessing/util.py64
-rw-r--r--Lib/mutex.py55
-rw-r--r--Lib/netrc.py12
-rw-r--r--Lib/new.py17
-rw-r--r--Lib/nntplib.py1196
-rw-r--r--Lib/ntpath.py532
-rw-r--r--Lib/nturl2path.py22
-rw-r--r--Lib/numbers.py59
-rw-r--r--Lib/opcode.py46
-rw-r--r--Lib/optparse.py85
-rw-r--r--Lib/os.py535
-rw-r--r--Lib/os2emxpath.py13
-rw-r--r--Lib/pdb.doc202
-rwxr-xr-xLib/pdb.py1375
-rw-r--r--Lib/pickle.py971
-rw-r--r--Lib/pickletools.py565
-rw-r--r--Lib/pipes.py48
-rw-r--r--Lib/pkgutil.py19
-rw-r--r--Lib/plat-aix3/IN.py126
-rwxr-xr-xLib/plat-aix3/regen8
-rw-r--r--Lib/plat-aix4/IN.py12
-rw-r--r--Lib/plat-atheos/IN.py944
-rw-r--r--Lib/plat-atheos/TYPES.py142
-rwxr-xr-xLib/plat-atheos/regen3
-rw-r--r--Lib/plat-beos5/IN.py327
-rwxr-xr-xLib/plat-beos5/regen7
-rw-r--r--Lib/plat-darwin/IN.py405
-rw-r--r--Lib/plat-irix5/AL.py65
-rw-r--r--Lib/plat-irix5/CD.py38
-rw-r--r--Lib/plat-irix5/CL.py28
-rw-r--r--Lib/plat-irix5/CL_old.py240
-rw-r--r--Lib/plat-irix5/DEVICE.py404
-rw-r--r--Lib/plat-irix5/ERRNO.py150
-rw-r--r--Lib/plat-irix5/FILE.py242
-rw-r--r--Lib/plat-irix5/FL.py292
-rw-r--r--Lib/plat-irix5/GET.py62
-rw-r--r--Lib/plat-irix5/GL.py397
-rw-r--r--Lib/plat-irix5/GLWS.py16
-rw-r--r--Lib/plat-irix5/IN.py144
-rw-r--r--Lib/plat-irix5/IOCTL.py236
-rw-r--r--Lib/plat-irix5/SV.py124
-rw-r--r--Lib/plat-irix5/WAIT.py18
-rw-r--r--Lib/plat-irix5/cddb.py207
-rw-r--r--Lib/plat-irix5/cdplayer.py91
-rw-r--r--Lib/plat-irix5/flp.doc117
-rw-r--r--Lib/plat-irix5/flp.py455
-rw-r--r--Lib/plat-irix5/jpeg.py114
-rw-r--r--Lib/plat-irix5/panel.py284
-rw-r--r--Lib/plat-irix5/panelparser.py131
-rw-r--r--Lib/plat-irix5/readcd.doc104
-rw-r--r--Lib/plat-irix5/readcd.py247
-rwxr-xr-xLib/plat-irix5/regen10
-rw-r--r--Lib/plat-irix5/torgb.py102
-rw-r--r--Lib/plat-irix6/AL.py65
-rw-r--r--Lib/plat-irix6/CD.py38
-rw-r--r--Lib/plat-irix6/CL.py28
-rw-r--r--Lib/plat-irix6/DEVICE.py404
-rw-r--r--Lib/plat-irix6/ERRNO.py183
-rw-r--r--Lib/plat-irix6/FILE.py677
-rw-r--r--Lib/plat-irix6/FL.py292
-rw-r--r--Lib/plat-irix6/GET.py62
-rw-r--r--Lib/plat-irix6/GL.py397
-rw-r--r--Lib/plat-irix6/GLWS.py16
-rw-r--r--Lib/plat-irix6/IN.py388
-rw-r--r--Lib/plat-irix6/IOCTL.py236
-rw-r--r--Lib/plat-irix6/SV.py124
-rw-r--r--Lib/plat-irix6/WAIT.py338
-rw-r--r--Lib/plat-irix6/cddb.py207
-rw-r--r--Lib/plat-irix6/cdplayer.py91
-rw-r--r--Lib/plat-irix6/flp.doc117
-rw-r--r--Lib/plat-irix6/flp.py454
-rw-r--r--Lib/plat-irix6/jpeg.py114
-rw-r--r--Lib/plat-irix6/panel.py284
-rw-r--r--Lib/plat-irix6/panelparser.py131
-rw-r--r--Lib/plat-irix6/readcd.doc104
-rw-r--r--Lib/plat-irix6/readcd.py247
-rwxr-xr-xLib/plat-irix6/regen11
-rw-r--r--Lib/plat-irix6/torgb.py102
-rw-r--r--Lib/plat-linux2/DLFCN.py6
-rw-r--r--Lib/plat-linux2/IN.py32
-rw-r--r--Lib/plat-linux2/TYPES.py8
-rw-r--r--Lib/plat-mac/Audio_mac.py124
-rw-r--r--Lib/plat-mac/Carbon/AE.py1
-rw-r--r--Lib/plat-mac/Carbon/AH.py1
-rw-r--r--Lib/plat-mac/Carbon/Alias.py1
-rw-r--r--Lib/plat-mac/Carbon/Aliases.py18
-rw-r--r--Lib/plat-mac/Carbon/App.py1
-rw-r--r--Lib/plat-mac/Carbon/Appearance.py648
-rw-r--r--Lib/plat-mac/Carbon/AppleEvents.py961
-rw-r--r--Lib/plat-mac/Carbon/AppleHelp.py6
-rw-r--r--Lib/plat-mac/Carbon/CF.py1
-rw-r--r--Lib/plat-mac/Carbon/CG.py1
-rw-r--r--Lib/plat-mac/Carbon/CarbonEvents.py451
-rw-r--r--Lib/plat-mac/Carbon/CarbonEvt.py1
-rw-r--r--Lib/plat-mac/Carbon/Cm.py1
-rw-r--r--Lib/plat-mac/Carbon/Components.py62
-rw-r--r--Lib/plat-mac/Carbon/ControlAccessor.py56
-rw-r--r--Lib/plat-mac/Carbon/Controls.py668
-rw-r--r--Lib/plat-mac/Carbon/CoreFoundation.py28
-rw-r--r--Lib/plat-mac/Carbon/CoreGraphics.py28
-rw-r--r--Lib/plat-mac/Carbon/Ctl.py1
-rw-r--r--Lib/plat-mac/Carbon/Dialogs.py79
-rw-r--r--Lib/plat-mac/Carbon/Dlg.py1
-rw-r--r--Lib/plat-mac/Carbon/Drag.py1
-rw-r--r--Lib/plat-mac/Carbon/Dragconst.py86
-rw-r--r--Lib/plat-mac/Carbon/Events.py102
-rw-r--r--Lib/plat-mac/Carbon/Evt.py1
-rw-r--r--Lib/plat-mac/Carbon/File.py1
-rw-r--r--Lib/plat-mac/Carbon/Files.py426
-rw-r--r--Lib/plat-mac/Carbon/Fm.py1
-rw-r--r--Lib/plat-mac/Carbon/Folder.py1
-rw-r--r--Lib/plat-mac/Carbon/Folders.py190
-rw-r--r--Lib/plat-mac/Carbon/Fonts.py59
-rw-r--r--Lib/plat-mac/Carbon/Help.py1
-rw-r--r--Lib/plat-mac/Carbon/IBCarbon.py1
-rw-r--r--Lib/plat-mac/Carbon/IBCarbonRuntime.py5
-rw-r--r--Lib/plat-mac/Carbon/Icn.py1
-rw-r--r--Lib/plat-mac/Carbon/Icons.py381
-rw-r--r--Lib/plat-mac/Carbon/Launch.py1
-rw-r--r--Lib/plat-mac/Carbon/LaunchServices.py74
-rw-r--r--Lib/plat-mac/Carbon/List.py1
-rw-r--r--Lib/plat-mac/Carbon/Lists.py35
-rw-r--r--Lib/plat-mac/Carbon/MacHelp.py58
-rw-r--r--Lib/plat-mac/Carbon/MacTextEditor.py226
-rw-r--r--Lib/plat-mac/Carbon/MediaDescr.py97
-rw-r--r--Lib/plat-mac/Carbon/Menu.py1
-rw-r--r--Lib/plat-mac/Carbon/Menus.py169
-rw-r--r--Lib/plat-mac/Carbon/Mlte.py1
-rw-r--r--Lib/plat-mac/Carbon/OSA.py1
-rw-r--r--Lib/plat-mac/Carbon/OSAconst.py133
-rw-r--r--Lib/plat-mac/Carbon/QDOffscreen.py47
-rw-r--r--Lib/plat-mac/Carbon/Qd.py1
-rw-r--r--Lib/plat-mac/Carbon/Qdoffs.py1
-rw-r--r--Lib/plat-mac/Carbon/Qt.py5
-rw-r--r--Lib/plat-mac/Carbon/QuickDraw.py218
-rw-r--r--Lib/plat-mac/Carbon/QuickTime.py3468
-rw-r--r--Lib/plat-mac/Carbon/Res.py4
-rw-r--r--Lib/plat-mac/Carbon/Resources.py27
-rw-r--r--Lib/plat-mac/Carbon/Scrap.py1
-rw-r--r--Lib/plat-mac/Carbon/Snd.py1
-rw-r--r--Lib/plat-mac/Carbon/Sndihooks.py1
-rw-r--r--Lib/plat-mac/Carbon/Sound.py400
-rw-r--r--Lib/plat-mac/Carbon/TE.py1
-rw-r--r--Lib/plat-mac/Carbon/TextEdit.py57
-rw-r--r--Lib/plat-mac/Carbon/Win.py1
-rw-r--r--Lib/plat-mac/Carbon/Windows.py279
-rw-r--r--Lib/plat-mac/Carbon/__init__.py7
-rw-r--r--Lib/plat-mac/EasyDialogs.py841
-rw-r--r--Lib/plat-mac/FrameWork.py1126
-rw-r--r--Lib/plat-mac/MiniAEFrame.py200
-rw-r--r--Lib/plat-mac/PixMapWrapper.py218
-rw-r--r--Lib/plat-mac/aepack.py369
-rw-r--r--Lib/plat-mac/aetools.py363
-rw-r--r--Lib/plat-mac/aetypes.py571
-rw-r--r--Lib/plat-mac/applesingle.py146
-rw-r--r--Lib/plat-mac/appletrawmain.py67
-rwxr-xr-xLib/plat-mac/appletrunner.py20
-rw-r--r--Lib/plat-mac/argvemulator.py92
-rw-r--r--Lib/plat-mac/bgenlocations.py58
-rw-r--r--Lib/plat-mac/buildtools.py435
-rwxr-xr-xLib/plat-mac/bundlebuilder.py949
-rw-r--r--Lib/plat-mac/cfmfile.py187
-rw-r--r--Lib/plat-mac/dialogs.rsrcbin18133 -> 0 bytes
-rw-r--r--Lib/plat-mac/errors.rsrcbin86868 -> 0 bytes
-rw-r--r--Lib/plat-mac/findertools.py835
-rw-r--r--Lib/plat-mac/gensuitemodule.py1216
-rw-r--r--Lib/plat-mac/ic.py271
-rw-r--r--Lib/plat-mac/icopen.py69
-rw-r--r--Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py682
-rw-r--r--Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py2373
-rw-r--r--Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py62
-rw-r--r--Lib/plat-mac/lib-scriptpackages/CodeWarrior/Standard_Suite.py408
-rw-r--r--Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py193
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/Microsoft_Internet_Explorer.py96
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/Netscape_Suite.py49
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py108
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py72
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/URL_Suite.py54
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py226
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py84
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Containers_and_folders.py279
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py145
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Files.py212
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Finder_Basics.py207
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Finder_items.py355
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Legacy_suite.py224
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Standard_Suite.py335
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Type_Definitions.py346
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/Window_classes.py229
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Finder/__init__.py237
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/Mozilla_suite.py269
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/PowerPlant.py86
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/Required_suite.py108
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/Standard_Suite.py243
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/Standard_URL_suite.py60
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/Text.py122
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/WorldWideWeb_suite.py426
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py109
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py2215
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Macintosh_Connectivity_Clas.py373
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suite.py417
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suppleme.py73
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Required_Suite.py32
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Standard_Suite.py738
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Table_Suite.py104
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Text_Suite.py224
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/Type_Names_Suite.py435
-rw-r--r--Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py475
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Disk_Folder_File_Suite.py381
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Folder_Actions_Suite.py287
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Hidden_Suite.py50
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Login_Items_Suite.py74
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Power_Suite.py149
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py214
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Standard_Suite.py582
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/System_Events_Suite.py109
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/Text_Suite.py195
-rw-r--r--Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py144
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Terminal/Standard_Suite.py582
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Terminal/Terminal_Suite.py254
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Terminal/Text_Suite.py195
-rw-r--r--Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py93
-rw-r--r--Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py31
-rw-r--r--Lib/plat-mac/lib-scriptpackages/_builtinSuites/builtin_Suite.py140
-rw-r--r--Lib/plat-mac/macerrors.py1857
-rw-r--r--Lib/plat-mac/macostools.py138
-rw-r--r--Lib/plat-mac/macresource.py135
-rw-r--r--Lib/plat-mac/pimp.py1182
-rw-r--r--Lib/plat-mac/terminalcommand.py50
-rw-r--r--Lib/plat-mac/videoreader.py294
-rw-r--r--Lib/plat-os2emx/IN.py12
-rw-r--r--Lib/plat-os2emx/_emx_link.py6
-rw-r--r--Lib/plat-os2emx/grp.py14
-rw-r--r--Lib/plat-os2emx/pwd.py16
-rw-r--r--Lib/plat-riscos/riscosenviron.py45
-rw-r--r--Lib/plat-riscos/riscospath.py378
-rw-r--r--Lib/plat-riscos/rourl2path.py70
-rw-r--r--Lib/plat-sunos5/IN.py58
-rw-r--r--Lib/plat-sunos5/STROPTS.py56
-rw-r--r--Lib/plat-sunos5/SUNAUDIODEV.py43
-rw-r--r--Lib/plat-sunos5/TYPES.py12
-rw-r--r--Lib/plat-unixware7/IN.py20
-rw-r--r--Lib/plat-unixware7/STROPTS.py132
-rwxr-xr-xLib/platform.py198
-rw-r--r--Lib/plistlib.py234
-rw-r--r--Lib/popen2.py201
-rw-r--r--Lib/poplib.py140
-rw-r--r--Lib/posixfile.py237
-rw-r--r--Lib/posixpath.py240
-rw-r--r--Lib/pprint.py198
-rwxr-xr-xLib/profile.py28
-rw-r--r--Lib/pstats.py259
-rw-r--r--Lib/pty.py10
-rw-r--r--Lib/py_compile.py83
-rw-r--r--Lib/pyclbr.py29
-rwxr-xr-xLib/pydoc.py1147
-rw-r--r--Lib/pydoc_data/_pydoc.css6
-rw-r--r--Lib/pydoc_data/topics.py121
-rw-r--r--Lib/queue.py (renamed from Lib/Queue.py)29
-rwxr-xr-xLib/quopri.py141
-rw-r--r--Lib/random.py396
-rw-r--r--Lib/re.py145
-rw-r--r--Lib/reprlib.py (renamed from Lib/repr.py)59
-rw-r--r--Lib/rexec.py588
-rw-r--r--Lib/rfc822.py1011
-rw-r--r--Lib/rlcompleter.py14
-rw-r--r--Lib/runpy.py60
-rw-r--r--Lib/sched.py8
-rw-r--r--Lib/sets.py557
-rw-r--r--Lib/sgmllib.py553
-rw-r--r--Lib/sha.py15
-rw-r--r--Lib/shelve.py87
-rw-r--r--Lib/shlex.py62
-rw-r--r--Lib/shutil.py263
-rw-r--r--Lib/site.py142
-rwxr-xr-xLib/smtpd.py324
-rw-r--r--[-rwxr-xr-x]Lib/smtplib.py221
-rw-r--r--Lib/sndhdr.py119
-rw-r--r--Lib/socket.py681
-rw-r--r--Lib/socketserver.py (renamed from Lib/SocketServer.py)22
-rw-r--r--Lib/sqlite3/__init__.py5
-rw-r--r--Lib/sqlite3/dbapi2.py15
-rw-r--r--Lib/sqlite3/test/dbapi.py58
-rw-r--r--Lib/sqlite3/test/dump.py2
-rw-r--r--Lib/sqlite3/test/factory.py60
-rw-r--r--Lib/sqlite3/test/hooks.py27
-rw-r--r--Lib/sqlite3/test/py25tests.py80
-rw-r--r--Lib/sqlite3/test/regression.py51
-rw-r--r--Lib/sqlite3/test/transactions.py3
-rw-r--r--Lib/sqlite3/test/types.py71
-rw-r--r--Lib/sqlite3/test/userfunctions.py55
-rw-r--r--Lib/sre.py13
-rw-r--r--Lib/sre_compile.py37
-rw-r--r--Lib/sre_constants.py5
-rw-r--r--Lib/sre_parse.py160
-rw-r--r--Lib/ssl.py411
-rw-r--r--Lib/stat.py54
-rw-r--r--Lib/statvfs.py18
-rw-r--r--Lib/string.py423
-rw-r--r--Lib/stringold.py432
-rw-r--r--Lib/stringprep.py340
-rw-r--r--Lib/struct.py11
-rw-r--r--Lib/subprocess.py851
-rw-r--r--Lib/sunau.py84
-rw-r--r--Lib/sunaudio.py49
-rwxr-xr-xLib/symbol.py134
-rw-r--r--Lib/symtable.py14
-rw-r--r--Lib/sysconfig.py142
-rwxr-xr-xLib/tabnanny.py51
-rw-r--r--Lib/tarfile.py1044
-rw-r--r--Lib/telnetlib.py228
-rw-r--r--Lib/tempfile.py231
-rw-r--r--Lib/test/__main__.py13
-rw-r--r--Lib/test/bad_coding2.py2
-rw-r--r--Lib/test/badsyntax_3131.py2
-rw-r--r--Lib/test/badsyntax_future8.py2
-rw-r--r--Lib/test/badsyntax_future9.py2
-rw-r--r--Lib/test/badsyntax_nocaret.py2
-rw-r--r--Lib/test/badsyntax_pep3120.py1
-rw-r--r--Lib/test/buffer_tests.py10
-rw-r--r--Lib/test/capath/4e1295a3.014
-rw-r--r--Lib/test/capath/5ed36f99.041
-rw-r--r--Lib/test/capath/6e88d7b8.014
-rw-r--r--Lib/test/capath/99d0fa06.041
-rw-r--r--Lib/test/cfgparser.2537
-rw-r--r--Lib/test/cfgparser.369
-rw-r--r--Lib/test/cmath_testcases.txt31
-rw-r--r--Lib/test/crashers/bogus_code_obj.py6
-rw-r--r--Lib/test/crashers/borrowed_ref_1.py2
-rw-r--r--Lib/test/crashers/borrowed_ref_2.py4
-rw-r--r--Lib/test/crashers/buffer_mutate.py30
-rw-r--r--Lib/test/crashers/decref_before_assignment.py44
-rw-r--r--Lib/test/crashers/gc_has_finalizer.py36
-rw-r--r--Lib/test/crashers/gc_inspection.py4
-rw-r--r--Lib/test/crashers/loosing_mro_ref.py6
-rw-r--r--Lib/test/crashers/nasty_eq_vs_dict.py2
-rw-r--r--Lib/test/crashers/recursive_call.py2
-rw-r--r--Lib/test/crashers/trace_at_recursion_limit.py27
-rw-r--r--Lib/test/crashers/underlying_dict.py20
-rw-r--r--Lib/test/curses_tests.py2
-rw-r--r--Lib/test/data/README2
-rw-r--r--Lib/test/datetimetester.py3685
-rw-r--r--Lib/test/decimaltestdata/and.decTest676
-rw-r--r--Lib/test/decimaltestdata/class.decTest262
-rw-r--r--Lib/test/decimaltestdata/comparetotal.decTest1596
-rw-r--r--Lib/test/decimaltestdata/comparetotmag.decTest1580
-rw-r--r--Lib/test/decimaltestdata/copy.decTest172
-rw-r--r--Lib/test/decimaltestdata/copyabs.decTest172
-rw-r--r--Lib/test/decimaltestdata/copynegate.decTest172
-rw-r--r--Lib/test/decimaltestdata/copysign.decTest354
-rw-r--r--Lib/test/decimaltestdata/ddAbs.decTest252
-rw-r--r--Lib/test/decimaltestdata/ddAdd.decTest2656
-rw-r--r--Lib/test/decimaltestdata/ddAnd.decTest694
-rw-r--r--Lib/test/decimaltestdata/ddBase.decTest2208
-rw-r--r--Lib/test/decimaltestdata/ddCanonical.decTest714
-rw-r--r--Lib/test/decimaltestdata/ddClass.decTest152
-rw-r--r--Lib/test/decimaltestdata/ddCompare.decTest1488
-rw-r--r--Lib/test/decimaltestdata/ddCompareSig.decTest1294
-rw-r--r--Lib/test/decimaltestdata/ddCompareTotal.decTest1412
-rw-r--r--Lib/test/decimaltestdata/ddCompareTotalMag.decTest1412
-rw-r--r--Lib/test/decimaltestdata/ddCopy.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopyAbs.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopyNegate.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddCopySign.decTest350
-rw-r--r--Lib/test/decimaltestdata/ddDivide.decTest1726
-rw-r--r--Lib/test/decimaltestdata/ddDivideInt.decTest898
-rw-r--r--Lib/test/decimaltestdata/ddEncode.decTest990
-rw-r--r--Lib/test/decimaltestdata/ddFMA.decTest3396
-rw-r--r--Lib/test/decimaltestdata/ddInvert.decTest404
-rw-r--r--Lib/test/decimaltestdata/ddLogB.decTest318
-rw-r--r--Lib/test/decimaltestdata/ddMax.decTest644
-rw-r--r--Lib/test/decimaltestdata/ddMaxMag.decTest608
-rw-r--r--Lib/test/decimaltestdata/ddMin.decTest618
-rw-r--r--Lib/test/decimaltestdata/ddMinMag.decTest586
-rw-r--r--Lib/test/decimaltestdata/ddMinus.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddMultiply.decTest1106
-rw-r--r--Lib/test/decimaltestdata/ddNextMinus.decTest252
-rw-r--r--Lib/test/decimaltestdata/ddNextPlus.decTest248
-rw-r--r--Lib/test/decimaltestdata/ddNextToward.decTest748
-rw-r--r--Lib/test/decimaltestdata/ddOr.decTest584
-rw-r--r--Lib/test/decimaltestdata/ddPlus.decTest176
-rw-r--r--Lib/test/decimaltestdata/ddQuantize.decTest1666
-rw-r--r--Lib/test/decimaltestdata/ddReduce.decTest364
-rw-r--r--Lib/test/decimaltestdata/ddRemainder.decTest1200
-rw-r--r--Lib/test/decimaltestdata/ddRemainderNear.decTest1258
-rw-r--r--Lib/test/decimaltestdata/ddRotate.decTest524
-rw-r--r--Lib/test/decimaltestdata/ddSameQuantum.decTest778
-rw-r--r--Lib/test/decimaltestdata/ddScaleB.decTest486
-rw-r--r--Lib/test/decimaltestdata/ddShift.decTest524
-rw-r--r--Lib/test/decimaltestdata/ddSubtract.decTest1258
-rw-r--r--Lib/test/decimaltestdata/ddToIntegral.decTest514
-rw-r--r--Lib/test/decimaltestdata/ddXor.decTest674
-rw-r--r--Lib/test/decimaltestdata/dqAbs.decTest252
-rw-r--r--Lib/test/decimaltestdata/dqAdd.decTest2430
-rw-r--r--Lib/test/decimaltestdata/dqAnd.decTest840
-rw-r--r--Lib/test/decimaltestdata/dqBase.decTest2162
-rw-r--r--Lib/test/decimaltestdata/dqCanonical.decTest744
-rw-r--r--Lib/test/decimaltestdata/dqClass.decTest154
-rw-r--r--Lib/test/decimaltestdata/dqCompare.decTest1506
-rw-r--r--Lib/test/decimaltestdata/dqCompareSig.decTest1294
-rw-r--r--Lib/test/decimaltestdata/dqCompareTotal.decTest1412
-rw-r--r--Lib/test/decimaltestdata/dqCompareTotalMag.decTest1412
-rw-r--r--Lib/test/decimaltestdata/dqCopy.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopyAbs.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopyNegate.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqCopySign.decTest350
-rw-r--r--Lib/test/decimaltestdata/dqDivide.decTest1616
-rw-r--r--Lib/test/decimaltestdata/dqDivideInt.decTest906
-rw-r--r--Lib/test/decimaltestdata/dqEncode.decTest954
-rw-r--r--Lib/test/decimaltestdata/dqFMA.decTest3572
-rw-r--r--Lib/test/decimaltestdata/dqInvert.decTest490
-rw-r--r--Lib/test/decimaltestdata/dqLogB.decTest320
-rw-r--r--Lib/test/decimaltestdata/dqMax.decTest644
-rw-r--r--Lib/test/decimaltestdata/dqMaxMag.decTest608
-rw-r--r--Lib/test/decimaltestdata/dqMin.decTest618
-rw-r--r--Lib/test/decimaltestdata/dqMinMag.decTest586
-rw-r--r--Lib/test/decimaltestdata/dqMinus.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqMultiply.decTest1178
-rw-r--r--Lib/test/decimaltestdata/dqNextMinus.decTest252
-rw-r--r--Lib/test/decimaltestdata/dqNextPlus.decTest248
-rw-r--r--Lib/test/decimaltestdata/dqNextToward.decTest750
-rw-r--r--Lib/test/decimaltestdata/dqOr.decTest802
-rw-r--r--Lib/test/decimaltestdata/dqPlus.decTest176
-rw-r--r--Lib/test/decimaltestdata/dqQuantize.decTest1672
-rw-r--r--Lib/test/decimaltestdata/dqReduce.decTest366
-rw-r--r--Lib/test/decimaltestdata/dqRemainder.decTest1194
-rw-r--r--Lib/test/decimaltestdata/dqRemainderNear.decTest1262
-rw-r--r--Lib/test/decimaltestdata/dqRotate.decTest596
-rw-r--r--Lib/test/decimaltestdata/dqSameQuantum.decTest778
-rw-r--r--Lib/test/decimaltestdata/dqScaleB.decTest520
-rw-r--r--Lib/test/decimaltestdata/dqShift.decTest596
-rw-r--r--Lib/test/decimaltestdata/dqSubtract.decTest1270
-rw-r--r--Lib/test/decimaltestdata/dqToIntegral.decTest514
-rw-r--r--Lib/test/decimaltestdata/dqXor.decTest820
-rw-r--r--Lib/test/decimaltestdata/dsBase.decTest2124
-rw-r--r--Lib/test/decimaltestdata/dsEncode.decTest744
-rw-r--r--Lib/test/decimaltestdata/exp.decTest1348
-rw-r--r--Lib/test/decimaltestdata/extra.decTest13
-rw-r--r--Lib/test/decimaltestdata/fma.decTest6852
-rw-r--r--Lib/test/decimaltestdata/invert.decTest352
-rw-r--r--Lib/test/decimaltestdata/ln.decTest1222
-rw-r--r--Lib/test/decimaltestdata/log10.decTest1102
-rw-r--r--Lib/test/decimaltestdata/logb.decTest376
-rw-r--r--Lib/test/decimaltestdata/maxmag.decTest808
-rw-r--r--Lib/test/decimaltestdata/minmag.decTest780
-rw-r--r--Lib/test/decimaltestdata/nextminus.decTest296
-rw-r--r--Lib/test/decimaltestdata/nextplus.decTest300
-rw-r--r--Lib/test/decimaltestdata/nexttoward.decTest852
-rw-r--r--Lib/test/decimaltestdata/or.decTest668
-rw-r--r--Lib/test/decimaltestdata/powersqrt.decTest5940
-rw-r--r--Lib/test/decimaltestdata/rotate.decTest494
-rw-r--r--Lib/test/decimaltestdata/scaleb.decTest418
-rw-r--r--Lib/test/decimaltestdata/shift.decTest500
-rw-r--r--Lib/test/decimaltestdata/tointegralx.decTest510
-rw-r--r--Lib/test/decimaltestdata/xor.decTest670
-rw-r--r--Lib/test/dis_module.py5
-rw-r--r--Lib/test/doctest_aliases.py2
-rw-r--r--Lib/test/double_const.py2
-rw-r--r--Lib/test/encoded_modules/__init__.py23
-rw-r--r--Lib/test/encoded_modules/module_iso_8859_1.py5
-rw-r--r--Lib/test/encoded_modules/module_koi8_r.py3
-rw-r--r--Lib/test/exception_hierarchy.txt74
-rw-r--r--Lib/test/fork_wait.py14
-rw-r--r--Lib/test/formatfloat_testcases.txt97
-rw-r--r--Lib/test/gdb_sample.py2
-rw-r--r--Lib/test/greyrgb.uue1547
-rw-r--r--Lib/test/infinite_reload.py8
-rw-r--r--Lib/test/inspect_fodder.py4
-rw-r--r--Lib/test/inspect_fodder2.py20
-rw-r--r--Lib/test/json_tests/__init__.py (renamed from Lib/json/tests/__init__.py)8
-rw-r--r--Lib/test/json_tests/test_decode.py (renamed from Lib/json/tests/test_decode.py)47
-rw-r--r--Lib/test/json_tests/test_default.py (renamed from Lib/json/tests/test_default.py)4
-rw-r--r--Lib/test/json_tests/test_dump.py (renamed from Lib/json/tests/test_dump.py)8
-rw-r--r--Lib/test/json_tests/test_encode_basestring_ascii.py44
-rw-r--r--Lib/test/json_tests/test_fail.py (renamed from Lib/json/tests/test_fail.py)6
-rw-r--r--Lib/test/json_tests/test_float.py (renamed from Lib/json/tests/test_float.py)12
-rw-r--r--Lib/test/json_tests/test_indent.py (renamed from Lib/json/tests/test_indent.py)47
-rw-r--r--Lib/test/json_tests/test_pass1.py (renamed from Lib/json/tests/test_pass1.py)4
-rw-r--r--Lib/test/json_tests/test_pass2.py (renamed from Lib/json/tests/test_pass2.py)4
-rw-r--r--Lib/test/json_tests/test_pass3.py (renamed from Lib/json/tests/test_pass3.py)4
-rw-r--r--Lib/test/json_tests/test_recursion.py (renamed from Lib/json/tests/test_recursion.py)14
-rw-r--r--Lib/test/json_tests/test_scanstring.py103
-rw-r--r--Lib/test/json_tests/test_separators.py (renamed from Lib/json/tests/test_separators.py)4
-rw-r--r--Lib/test/json_tests/test_speedups.py (renamed from Lib/json/tests/test_speedups.py)7
-rw-r--r--Lib/test/json_tests/test_tool.py (renamed from Lib/json/tests/test_tool.py)12
-rw-r--r--Lib/test/json_tests/test_unicode.py75
-rw-r--r--Lib/test/keycert.pem59
-rw-r--r--Lib/test/keycert2.pem31
-rw-r--r--Lib/test/leakers/test_dictself.py12
-rw-r--r--Lib/test/leakers/test_gestalt.py2
-rw-r--r--Lib/test/leakers/test_selftype.py4
-rw-r--r--Lib/test/list_tests.py88
-rw-r--r--Lib/test/lock_tests.py358
-rw-r--r--Lib/test/make_ssl_certs.py64
-rw-r--r--Lib/test/mapping_tests.py157
-rw-r--r--Lib/test/math_testcases.txt72
-rw-r--r--Lib/test/mime.types1445
-rw-r--r--Lib/test/mock_socket.py154
-rw-r--r--Lib/test/mp_fork_bomb.py13
-rw-r--r--Lib/test/outstanding_bugs.py74
-rw-r--r--Lib/test/pickletester.py1111
-rw-r--r--Lib/test/pstats.pckbin0 -> 66607 bytes
-rw-r--r--Lib/test/pydoc_mod.py2
-rw-r--r--Lib/test/pydocfodder.py6
-rwxr-xr-xLib/test/pystone.py14
-rwxr-xr-xLib/test/re_tests.py12
-rwxr-xr-xLib/test/regrtest.py888
-rw-r--r--Lib/test/reperf.py4
-rw-r--r--Lib/test/sample_doctest.py6
-rw-r--r--Lib/test/script_helper.py69
-rw-r--r--Lib/test/seq_tests.py64
-rw-r--r--Lib/test/sha256.pem222
-rw-r--r--Lib/test/sndhdrdata/README12
-rw-r--r--Lib/test/sndhdrdata/sndhdr.8svxbin0 -> 110 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.aifcbin0 -> 106 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.aiffbin0 -> 108 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.aubin0 -> 64 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.hcombin0 -> 256 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.sndtbin0 -> 129 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.vocbin0 -> 63 bytes
-rw-r--r--Lib/test/sndhdrdata/sndhdr.wavbin0 -> 64 bytes
-rw-r--r--Lib/test/sortperf.py24
-rw-r--r--Lib/test/ssl_cert.pem25
-rw-r--r--Lib/test/ssl_key.pem25
-rw-r--r--Lib/test/ssl_servers.py189
-rw-r--r--Lib/test/string_tests.py631
-rw-r--r--Lib/test/subprocessdata/fd_status.py24
-rw-r--r--Lib/test/subprocessdata/input_reader.py7
-rw-r--r--Lib/test/subprocessdata/qcat.py7
-rw-r--r--Lib/test/subprocessdata/qgrep.py10
-rw-r--r--Lib/test/support.py (renamed from Lib/test/test_support.py)870
-rw-r--r--Lib/test/symlink_support.py100
-rw-r--r--Lib/test/test_MimeWriter.py292
-rw-r--r--Lib/test/test_SimpleHTTPServer.py41
-rw-r--r--Lib/test/test_StringIO.py179
-rw-r--r--Lib/test/test___all__.py22
-rw-r--r--Lib/test/test___future__.py8
-rw-r--r--Lib/test/test__locale.py15
-rw-r--r--Lib/test/test_abc.py153
-rw-r--r--Lib/test/test_abstract_numbers.py20
-rw-r--r--Lib/test/test_aepack.py90
-rw-r--r--Lib/test/test_aifc.py217
-rwxr-xr-xLib/test/test_al.py25
-rw-r--r--Lib/test/test_anydbm.py97
-rw-r--r--Lib/test/test_applesingle.py71
-rw-r--r--Lib/test/test_argparse.py88
-rwxr-xr-xLib/test/test_array.py453
-rw-r--r--Lib/test/test_ascii_formatd.py58
-rw-r--r--Lib/test/test_ast.py112
-rw-r--r--Lib/test/test_asynchat.py97
-rw-r--r--Lib/test/test_asyncore.py95
-rw-r--r--Lib/test/test_atexit.py139
-rw-r--r--Lib/test/test_audioop.py56
-rw-r--r--Lib/test/test_augassign.py44
-rw-r--r--Lib/test/test_base64.py342
-rw-r--r--Lib/test/test_bastion.py3
-rw-r--r--Lib/test/test_bigaddrspace.py103
-rw-r--r--Lib/test/test_bigmem.py917
-rw-r--r--Lib/test/test_binascii.py130
-rwxr-xr-xLib/test/test_binhex.py34
-rw-r--r--Lib/test/test_binop.py135
-rw-r--r--Lib/test/test_bisect.py44
-rw-r--r--Lib/test/test_bool.py145
-rwxr-xr-xLib/test/test_bsddb.py357
-rw-r--r--Lib/test/test_bsddb185.py43
-rw-r--r--Lib/test/test_bsddb3.py81
-rw-r--r--Lib/test/test_buffer.py31
-rw-r--r--Lib/test/test_bufio.py7
-rw-r--r--Lib/test/test_builtin.py1114
-rw-r--r--Lib/test/test_bytes.py303
-rw-r--r--Lib/test/test_bz2.py139
-rw-r--r--Lib/test/test_calendar.py31
-rw-r--r--Lib/test/test_call.py25
-rw-r--r--Lib/test/test_capi.py172
-rwxr-xr-xLib/test/test_cd.py30
-rw-r--r--Lib/test/test_cfgparser.py1561
-rw-r--r--Lib/test/test_cgi.py194
-rw-r--r--Lib/test/test_charmapcodec.py34
-rwxr-xr-xLib/test/test_cl.py82
-rw-r--r--Lib/test/test_class.py276
-rw-r--r--Lib/test/test_cmath.py84
-rw-r--r--Lib/test/test_cmd.py52
-rw-r--r--Lib/test/test_cmd_line.py364
-rw-r--r--Lib/test/test_cmd_line_script.py193
-rw-r--r--Lib/test/test_code.py54
-rw-r--r--Lib/test/test_codeccallbacks.py445
-rw-r--r--Lib/test/test_codecencodings_cn.py68
-rw-r--r--Lib/test/test_codecencodings_hk.py16
-rw-r--r--Lib/test/test_codecencodings_iso2022.py16
-rw-r--r--Lib/test/test_codecencodings_jp.py92
-rw-r--r--Lib/test/test_codecencodings_kr.py68
-rw-r--r--Lib/test/test_codecencodings_tw.py16
-rw-r--r--Lib/test/test_codecmaps_cn.py6
-rw-r--r--Lib/test/test_codecmaps_hk.py8
-rw-r--r--Lib/test/test_codecmaps_jp.py26
-rw-r--r--Lib/test/test_codecmaps_kr.py14
-rw-r--r--Lib/test/test_codecmaps_tw.py10
-rw-r--r--Lib/test/test_codecs.py1475
-rw-r--r--Lib/test/test_codeop.py14
-rw-r--r--Lib/test/test_coding.py42
-rw-r--r--Lib/test/test_coercion.py348
-rw-r--r--Lib/test/test_collections.py347
-rw-r--r--Lib/test/test_colorsys.py4
-rw-r--r--Lib/test/test_commands.py74
-rw-r--r--Lib/test/test_compare.py47
-rw-r--r--Lib/test/test_compile.py207
-rw-r--r--Lib/test/test_compileall.py304
-rw-r--r--Lib/test/test_compiler.py317
-rw-r--r--Lib/test/test_complex.py327
-rw-r--r--Lib/test/test_complex_args.py118
-rw-r--r--Lib/test/test_concurrent_futures.py639
-rw-r--r--Lib/test/test_contains.py68
-rw-r--r--Lib/test/test_contextlib.py298
-rw-r--r--Lib/test/test_cookie.py99
-rw-r--r--Lib/test/test_copy.py138
-rw-r--r--Lib/test/test_copyreg.py (renamed from Lib/test/test_copy_reg.py)62
-rw-r--r--Lib/test/test_cpickle.py139
-rw-r--r--Lib/test/test_cprofile.py85
-rw-r--r--Lib/test/test_crypt.py10
-rw-r--r--Lib/test/test_csv.py369
-rw-r--r--Lib/test/test_ctypes.py7
-rw-r--r--Lib/test/test_curses.py39
-rw-r--r--Lib/test/test_datetime.py3403
-rw-r--r--Lib/test/test_dbm.py178
-rw-r--r--Lib/test/test_dbm_dumb.py (renamed from Lib/test/test_dumbdbm.py)106
-rwxr-xr-x[-rw-r--r--]Lib/test/test_dbm_gnu.py (renamed from Lib/test/test_gdbm.py)18
-rwxr-xr-xLib/test/test_dbm_ndbm.py43
-rw-r--r--Lib/test/test_decimal.py250
-rw-r--r--Lib/test/test_decorators.py16
-rw-r--r--Lib/test/test_defaultdict.py25
-rw-r--r--Lib/test/test_deque.py193
-rw-r--r--Lib/test/test_descr.py1478
-rw-r--r--Lib/test/test_descrtut.py121
-rw-r--r--Lib/test/test_dict.py223
-rw-r--r--Lib/test/test_dictcomps.py6
-rw-r--r--Lib/test/test_dictviews.py161
-rw-r--r--Lib/test/test_difflib.py23
-rw-r--r--Lib/test/test_dircache.py77
-rw-r--r--Lib/test/test_dis.py304
-rw-r--r--Lib/test/test_distutils.py6
-rwxr-xr-xLib/test/test_dl.py39
-rw-r--r--Lib/test/test_doctest.py692
-rw-r--r--Lib/test/test_doctest.txt6
-rw-r--r--Lib/test/test_doctest2.py37
-rw-r--r--Lib/test/test_doctest3.txt2
-rw-r--r--Lib/test/test_doctest4.txt10
-rw-r--r--Lib/test/test_docxmlrpc.py87
-rw-r--r--Lib/test/test_dummy_thread.py48
-rw-r--r--Lib/test/test_dummy_threading.py29
-rw-r--r--Lib/test/test_dynamic.py143
-rw-r--r--Lib/test/test_email.py8
-rw-r--r--Lib/test/test_email_codecs.py15
-rw-r--r--Lib/test/test_email_renamed.py12
-rw-r--r--Lib/test/test_enumerate.py52
-rw-r--r--Lib/test/test_eof.py14
-rw-r--r--Lib/test/test_epoll.py16
-rwxr-xr-xLib/test/test_errno.py13
-rw-r--r--Lib/test/test_exception_variations.py14
-rw-r--r--Lib/test/test_exceptions.py787
-rw-r--r--Lib/test/test_extcall.py65
-rw-r--r--Lib/test/test_fcntl.py27
-rw-r--r--Lib/test/test_file.py22
-rw-r--r--Lib/test/test_file2k.py832
-rw-r--r--Lib/test/test_file_eintr.py11
-rw-r--r--Lib/test/test_filecmp.py42
-rw-r--r--Lib/test/test_fileinput.py97
-rw-r--r--Lib/test/test_fileio.py58
-rw-r--r--Lib/test/test_float.py380
-rw-r--r--Lib/test/test_flufl.py27
-rw-r--r--Lib/test/test_fnmatch.py47
-rw-r--r--Lib/test/test_fork1.py48
-rw-r--r--Lib/test/test_format.py374
-rw-r--r--Lib/test/test_fpformat.py76
-rw-r--r--Lib/test/test_fractions.py75
-rw-r--r--Lib/test/test_frozen.py40
-rw-r--r--Lib/test/test_ftplib.py255
-rw-r--r--Lib/test/test_funcattrs.py236
-rw-r--r--Lib/test/test_functools.py301
-rw-r--r--Lib/test/test_future.py34
-rw-r--r--Lib/test/test_future2.py2
-rw-r--r--Lib/test/test_future3.py4
-rw-r--r--Lib/test/test_future4.py41
-rw-r--r--Lib/test/test_future5.py8
-rw-r--r--Lib/test/test_future_builtins.py38
-rw-r--r--Lib/test/test_gc.py118
-rw-r--r--Lib/test/test_gdb.py305
-rw-r--r--Lib/test/test_generators.py369
-rw-r--r--Lib/test/test_genericpath.py168
-rw-r--r--Lib/test/test_genexps.py76
-rw-r--r--Lib/test/test_getargs.py31
-rw-r--r--Lib/test/test_getargs2.py214
-rw-r--r--Lib/test/test_getopt.py2
-rw-r--r--Lib/test/test_gettext.py74
-rwxr-xr-xLib/test/test_gl.py155
-rw-r--r--Lib/test/test_glob.py61
-rw-r--r--Lib/test/test_global.py15
-rw-r--r--Lib/test/test_grammar.py338
-rw-r--r--Lib/test/test_grp.py14
-rw-r--r--Lib/test/test_gzip.py146
-rw-r--r--Lib/test/test_hash.py106
-rw-r--r--Lib/test/test_hashlib.py201
-rw-r--r--Lib/test/test_heapq.py70
-rw-r--r--Lib/test/test_hmac.py134
-rw-r--r--Lib/test/test_hotshot.py158
-rw-r--r--Lib/test/test_html.py24
-rw-r--r--Lib/test/test_htmllib.py69
-rw-r--r--Lib/test/test_htmlparser.py520
-rw-r--r--Lib/test/test_http_cookiejar.py (renamed from Lib/test/test_cookielib.py)309
-rw-r--r--Lib/test/test_http_cookies.py187
-rw-r--r--Lib/test/test_httplib.py510
-rw-r--r--Lib/test/test_httpservers.py404
-rwxr-xr-xLib/test/test_imageop.py211
-rw-r--r--Lib/test/test_imaplib.py139
-rwxr-xr-xLib/test/test_imgfile.py119
-rw-r--r--Lib/test/test_imp.py292
-rw-r--r--Lib/test/test_import.py519
-rw-r--r--Lib/test/test_importhooks.py42
-rw-r--r--Lib/test/test_importlib.py173
-rw-r--r--Lib/test/test_index.py119
-rw-r--r--Lib/test/test_inspect.py712
-rw-r--r--Lib/test/test_int.py370
-rw-r--r--Lib/test/test_int_literal.py117
-rw-r--r--Lib/test/test_io.py349
-rw-r--r--Lib/test/test_ioctl.py16
-rw-r--r--Lib/test/test_isinstance.py28
-rw-r--r--Lib/test/test_iter.py212
-rw-r--r--Lib/test/test_iterlen.py66
-rw-r--r--Lib/test/test_itertools.py691
-rw-r--r--Lib/test/test_json.py6
-rw-r--r--Lib/test/test_keywordonlyarg.py183
-rw-r--r--Lib/test/test_kqueue.py29
-rw-r--r--Lib/test/test_largefile.py16
-rw-r--r--Lib/test/test_lib2to3.py9
-rw-r--r--Lib/test/test_linecache.py12
-rw-r--r--Lib/test/test_linuxaudiodev.py99
-rw-r--r--Lib/test/test_list.py37
-rw-r--r--Lib/test/test_listcomps.py148
-rw-r--r--Lib/test/test_locale.py93
-rw-r--r--Lib/test/test_logging.py682
-rw-r--r--Lib/test/test_long.py1278
-rw-r--r--Lib/test/test_long_future.py221
-rw-r--r--Lib/test/test_longexp.py4
-rw-r--r--Lib/test/test_macos.py98
-rw-r--r--Lib/test/test_macostools.py88
-rw-r--r--Lib/test/test_macpath.py82
-rw-r--r--Lib/test/test_mailbox.py590
-rw-r--r--Lib/test/test_marshal.py240
-rw-r--r--Lib/test/test_math.py183
-rw-r--r--Lib/test/test_md5.py61
-rw-r--r--Lib/test/test_memoryio.py84
-rw-r--r--Lib/test/test_memoryview.py161
-rw-r--r--Lib/test/test_metaclass.py257
-rw-r--r--Lib/test/test_mhlib.py348
-rw-r--r--Lib/test/test_mimetools.py53
-rw-r--r--Lib/test/test_mimetypes.py24
-rw-r--r--Lib/test/test_minidom.py75
-rw-r--r--Lib/test/test_mmap.py523
-rw-r--r--Lib/test/test_module.py10
-rw-r--r--Lib/test/test_modulefinder.py29
-rw-r--r--Lib/test/test_msilib.py2
-rw-r--r--Lib/test/test_multibytecodec.py235
-rw-r--r--Lib/test/test_multibytecodec_support.py161
-rw-r--r--Lib/test/test_multifile.py67
-rw-r--r--Lib/test/test_multiprocessing.py327
-rw-r--r--Lib/test/test_mutants.py39
-rw-r--r--Lib/test/test_mutex.py35
-rw-r--r--Lib/test/test_netrc.py6
-rw-r--r--Lib/test/test_new.py163
-rw-r--r--Lib/test/test_nis.py15
-rw-r--r--Lib/test/test_nntplib.py1389
-rw-r--r--Lib/test/test_normalization.py14
-rw-r--r--Lib/test/test_ntpath.py98
-rw-r--r--Lib/test/test_numeric_tower.py206
-rw-r--r--Lib/test/test_old_mailbox.py160
-rw-r--r--Lib/test/test_opcodes.py35
-rw-r--r--Lib/test/test_openpty.py8
-rw-r--r--Lib/test/test_operator.py156
-rw-r--r--Lib/test/test_optparse.py89
-rw-r--r--Lib/test/test_os.py906
-rw-r--r--Lib/test/test_ossaudiodev.py34
-rw-r--r--Lib/test/test_osx_env.py36
-rw-r--r--Lib/test/test_parser.py243
-rw-r--r--Lib/test/test_pdb.py550
-rw-r--r--Lib/test/test_peepholer.py143
-rw-r--r--Lib/test/test_pep247.py62
-rw-r--r--Lib/test/test_pep263.py38
-rw-r--r--Lib/test/test_pep277.py88
-rw-r--r--Lib/test/test_pep292.py55
-rw-r--r--Lib/test/test_pep3120.py47
-rw-r--r--Lib/test/test_pep3131.py40
-rw-r--r--Lib/test/test_pep352.py136
-rw-r--r--Lib/test/test_pickle.py121
-rw-r--r--Lib/test/test_pickletools.py17
-rw-r--r--Lib/test/test_pipes.py15
-rw-r--r--Lib/test/test_pkg.py76
-rw-r--r--Lib/test/test_pkgimport.py41
-rw-r--r--Lib/test/test_pkgutil.py105
-rw-r--r--Lib/test/test_platform.py57
-rw-r--r--Lib/test/test_plistlib.py90
-rw-r--r--Lib/test/test_poll.py12
-rw-r--r--Lib/test/test_popen.py27
-rw-r--r--Lib/test/test_popen2.py130
-rw-r--r--Lib/test/test_poplib.py96
-rw-r--r--Lib/test/test_posix.py207
-rw-r--r--Lib/test/test_posixpath.py592
-rw-r--r--Lib/test/test_pow.py32
-rw-r--r--Lib/test/test_pprint.py423
-rw-r--r--Lib/test/test_print.py49
-rw-r--r--Lib/test/test_profile.py148
-rw-r--r--Lib/test/test_property.py2
-rw-r--r--Lib/test/test_pstats.py23
-rw-r--r--Lib/test/test_pty.py42
-rw-r--r--Lib/test/test_pwd.py22
-rw-r--r--Lib/test/test_py3kwarn.py426
-rw-r--r--Lib/test/test_py_compile.py13
-rw-r--r--Lib/test/test_pyclbr.py71
-rw-r--r--Lib/test/test_pydoc.py290
-rw-r--r--Lib/test/test_pyexpat.py252
-rw-r--r--Lib/test/test_queue.py122
-rw-r--r--Lib/test/test_quopri.py91
-rw-r--r--Lib/test/test_raise.py383
-rw-r--r--Lib/test/test_random.py227
-rw-r--r--Lib/test/test_range.py524
-rw-r--r--Lib/test/test_re.py300
-rw-r--r--Lib/test/test_readline.py2
-rw-r--r--Lib/test/test_reprlib.py (renamed from Lib/test/test_repr.py)91
-rw-r--r--Lib/test/test_resource.py20
-rw-r--r--Lib/test/test_rfc822.py257
-rw-r--r--Lib/test/test_richcmp.py50
-rw-r--r--Lib/test/test_rlcompleter.py6
-rw-r--r--Lib/test/test_robotparser.py34
-rw-r--r--Lib/test/test_runpy.py474
-rw-r--r--Lib/test/test_sax.py197
-rw-r--r--Lib/test/test_sched.py81
-rw-r--r--Lib/test/test_scope.py507
-rw-r--r--Lib/test/test_scriptpackages.py51
-rw-r--r--Lib/test/test_select.py18
-rw-r--r--Lib/test/test_set.py231
-rw-r--r--Lib/test/test_setcomps.py22
-rw-r--r--Lib/test/test_sets.py862
-rw-r--r--Lib/test/test_sgmllib.py439
-rw-r--r--Lib/test/test_sha.py56
-rw-r--r--Lib/test/test_shelve.py118
-rw-r--r--Lib/test/test_shlex.py17
-rw-r--r--Lib/test/test_shutil.py443
-rw-r--r--Lib/test/test_signal.py333
-rw-r--r--Lib/test/test_site.py129
-rw-r--r--Lib/test/test_slice.py31
-rw-r--r--Lib/test/test_smtpd.py291
-rw-r--r--Lib/test/test_smtplib.py375
-rw-r--r--Lib/test/test_smtpnet.py16
-rw-r--r--Lib/test/test_sndhdr.py23
-rw-r--r--Lib/test/test_socket.py1085
-rw-r--r--Lib/test/test_socketserver.py102
-rw-r--r--Lib/test/test_softspace.py23
-rw-r--r--Lib/test/test_sort.py153
-rw-r--r--Lib/test/test_sqlite.py21
-rw-r--r--Lib/test/test_ssl.py1393
-rw-r--r--Lib/test/test_startfile.py30
-rw-r--r--Lib/test/test_str.py461
-rw-r--r--Lib/test/test_strftime.py48
-rw-r--r--Lib/test/test_string.py136
-rw-r--r--Lib/test/test_stringprep.py80
-rw-r--r--Lib/test/test_strlit.py150
-rw-r--r--Lib/test/test_strop.py153
-rw-r--r--Lib/test/test_strptime.py10
-rw-r--r--Lib/test/test_strtod.py34
-rw-r--r--Lib/test/test_struct.py350
-rw-r--r--Lib/test/test_structmembers.py61
-rw-r--r--Lib/test/test_structseq.py27
-rw-r--r--Lib/test/test_subprocess.py1222
-rw-r--r--Lib/test/test_sunau.py70
-rw-r--r--Lib/test/test_sunaudiodev.py33
-rw-r--r--Lib/test/test_sundry.py40
-rw-r--r--Lib/test/test_super.py90
-rw-r--r--Lib/test/test_symtable.py16
-rw-r--r--Lib/test/test_syntax.py201
-rw-r--r--Lib/test/test_sys.py515
-rw-r--r--Lib/test/test_sys_setprofile.py34
-rw-r--r--Lib/test/test_sys_settrace.py61
-rw-r--r--Lib/test/test_sysconfig.py96
-rw-r--r--Lib/test/test_syslog.py39
-rw-r--r--Lib/test/test_tarfile.py1224
-rw-r--r--Lib/test/test_tcl.py28
-rw-r--r--Lib/test/test_telnetlib.py566
-rw-r--r--Lib/test/test_tempfile.py325
-rw-r--r--Lib/test/test_textwrap.py40
-rw-r--r--Lib/test/test_thread.py31
-rw-r--r--Lib/test/test_threaded_import.py256
-rw-r--r--Lib/test/test_threadedtempfile.py8
-rw-r--r--Lib/test/test_threading.py319
-rw-r--r--Lib/test/test_threading_local.py67
-rw-r--r--Lib/test/test_threadsignals.py156
-rw-r--r--Lib/test/test_time.py242
-rw-r--r--Lib/test/test_timeit.py306
-rw-r--r--Lib/test/test_timeout.py244
-rw-r--r--Lib/test/test_tk.py29
-rw-r--r--Lib/test/test_tokenize.py589
-rw-r--r--Lib/test/test_tools.py75
-rw-r--r--Lib/test/test_trace.py23
-rw-r--r--Lib/test/test_traceback.py352
-rw-r--r--Lib/test/test_transformer.py38
-rw-r--r--Lib/test/test_ttk_guionly.py38
-rw-r--r--Lib/test/test_ttk_textonly.py13
-rw-r--r--Lib/test/test_tuple.py46
-rw-r--r--Lib/test/test_typechecks.py29
-rw-r--r--Lib/test/test_types.py312
-rw-r--r--Lib/test/test_ucn.py82
-rw-r--r--Lib/test/test_unary.py35
-rw-r--r--Lib/test/test_undocumented_details.py39
-rw-r--r--Lib/test/test_unicode.py2355
-rw-r--r--Lib/test/test_unicode_file.py95
-rw-r--r--Lib/test/test_unicodedata.py246
-rw-r--r--Lib/test/test_unittest.py10
-rw-r--r--Lib/test/test_univnewlines.py19
-rw-r--r--Lib/test/test_univnewlines2k.py130
-rw-r--r--Lib/test/test_unpack.py14
-rw-r--r--Lib/test/test_unpack_ex.py174
-rw-r--r--Lib/test/test_urllib.py833
-rw-r--r--Lib/test/test_urllib2.py434
-rw-r--r--Lib/test/test_urllib2_localnet.py361
-rw-r--r--Lib/test/test_urllib2net.py179
-rw-r--r--Lib/test/test_urllib_response.py42
-rw-r--r--Lib/test/test_urllibnet.py192
-rwxr-xr-x[-rw-r--r--]Lib/test/test_urlparse.py528
-rw-r--r--Lib/test/test_userdict.py242
-rw-r--r--Lib/test/test_userlist.py16
-rwxr-xr-xLib/test/test_userstring.py108
-rw-r--r--Lib/test/test_uu.py154
-rw-r--r--Lib/test/test_uuid.py173
-rw-r--r--Lib/test/test_wait3.py6
-rw-r--r--Lib/test/test_wait4.py2
-rw-r--r--Lib/test/test_warnings.py112
-rw-r--r--Lib/test/test_wave.py29
-rw-r--r--Lib/test/test_weakref.py299
-rw-r--r--Lib/test/test_weakset.py52
-rw-r--r--Lib/test/test_whichdb.py68
-rw-r--r--Lib/test/test_winreg.py111
-rw-r--r--Lib/test/test_winsound.py30
-rw-r--r--Lib/test/test_with.py48
-rw-r--r--Lib/test/test_wsgiref.py149
-rw-r--r--Lib/test/test_xdrlib.py14
-rw-r--r--Lib/test/test_xml_etree.py304
-rw-r--r--Lib/test/test_xml_etree_c.py32
-rw-r--r--Lib/test/test_xmllib.py48
-rw-r--r--Lib/test/test_xmlrpc.py478
-rw-r--r--Lib/test/test_xmlrpc_net.py61
-rw-r--r--Lib/test/test_xpickle.py264
-rw-r--r--Lib/test/test_xrange.py218
-rw-r--r--Lib/test/test_zipfile.py548
-rw-r--r--Lib/test/test_zipfile64.py36
-rw-r--r--Lib/test/test_zipimport.py100
-rw-r--r--Lib/test/test_zipimport_support.py209
-rw-r--r--Lib/test/test_zlib.py298
-rw-r--r--Lib/test/testall.py10
-rw-r--r--Lib/test/testcodec.py6
-rw-r--r--Lib/test/testimg.uue1170
-rw-r--r--Lib/test/testimgr.uue1170
-rw-r--r--Lib/test/testrgb.uue971
-rw-r--r--Lib/test/testtar.tarbin281600 -> 435200 bytes
-rw-r--r--Lib/test/tf_inherit_check.py4
-rw-r--r--Lib/test/threaded_import_hangers.py2
-rw-r--r--Lib/test/time_hashlib.py52
-rw-r--r--Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt13
-rw-r--r--Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt11
-rw-r--r--Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt13
-rw-r--r--Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt12
-rw-r--r--Lib/test/tokenize_tests.txt57
-rw-r--r--Lib/test/win_console_handler.py4
-rw-r--r--Lib/test/wrongcert.pem32
-rw-r--r--Lib/test/xmltests.py5
-rw-r--r--Lib/test/zip_cp437_header.zipbin0 -> 270 bytes
-rw-r--r--Lib/textwrap.py60
-rw-r--r--Lib/this.py2
-rw-r--r--Lib/threading.py776
-rw-r--r--Lib/timeit.py48
-rw-r--r--Lib/tkinter/__init__.py (renamed from Lib/lib-tk/Tkinter.py)166
-rw-r--r--Lib/tkinter/__main__.py7
-rw-r--r--Lib/tkinter/_fix.py (renamed from Lib/lib-tk/FixTk.py)10
-rw-r--r--Lib/tkinter/colorchooser.py (renamed from Lib/lib-tk/tkColorChooser.py)4
-rw-r--r--Lib/tkinter/commondialog.py (renamed from Lib/lib-tk/tkCommonDialog.py)8
-rw-r--r--Lib/tkinter/constants.py (renamed from Lib/lib-tk/Tkconstants.py)0
-rw-r--r--Lib/tkinter/dialog.py (renamed from Lib/lib-tk/Dialog.py)6
-rw-r--r--Lib/tkinter/dnd.py (renamed from Lib/lib-tk/Tkdnd.py)12
-rw-r--r--Lib/tkinter/filedialog.py (renamed from Lib/lib-tk/FileDialog.py)213
-rw-r--r--Lib/tkinter/font.py (renamed from Lib/lib-tk/tkFont.py)43
-rw-r--r--Lib/tkinter/messagebox.py (renamed from Lib/lib-tk/tkMessageBox.py)18
-rw-r--r--Lib/tkinter/scrolledtext.py (renamed from Lib/lib-tk/ScrolledText.py)13
-rw-r--r--Lib/tkinter/simpledialog.py (renamed from Lib/lib-tk/tkSimpleDialog.py)150
-rw-r--r--Lib/tkinter/test/README (renamed from Lib/lib-tk/test/README)0
-rw-r--r--Lib/tkinter/test/__init__.py (renamed from Lib/lib-tk/test/test_tkinter/__init__.py)0
-rw-r--r--Lib/tkinter/test/runtktests.py72
-rw-r--r--Lib/tkinter/test/support.py79
-rw-r--r--Lib/tkinter/test/test_tkinter/__init__.py (renamed from Lib/lib-tk/test/test_ttk/__init__.py)0
-rw-r--r--Lib/tkinter/test/test_tkinter/test_font.py33
-rw-r--r--Lib/tkinter/test/test_tkinter/test_loadtk.py (renamed from Lib/lib-tk/test/test_tkinter/test_loadtk.py)7
-rw-r--r--Lib/tkinter/test/test_tkinter/test_text.py (renamed from Lib/lib-tk/test/test_tkinter/test_text.py)16
-rw-r--r--Lib/tkinter/test/test_ttk/__init__.py0
-rw-r--r--Lib/tkinter/test/test_ttk/test_extensions.py (renamed from Lib/lib-tk/test/test_ttk/test_extensions.py)38
-rw-r--r--Lib/tkinter/test/test_ttk/test_functions.py (renamed from Lib/lib-tk/test/test_ttk/test_functions.py)67
-rw-r--r--Lib/tkinter/test/test_ttk/test_style.py (renamed from Lib/lib-tk/test/test_ttk/test_style.py)14
-rw-r--r--Lib/tkinter/test/test_ttk/test_widgets.py (renamed from Lib/lib-tk/test/test_ttk/test_widgets.py)187
-rw-r--r--Lib/tkinter/tix.py (renamed from Lib/lib-tk/Tix.py)49
-rw-r--r--Lib/tkinter/ttk.py (renamed from Lib/lib-tk/ttk.py)74
-rw-r--r--Lib/toaiff.py110
-rwxr-xr-xLib/token.py86
-rw-r--r--Lib/tokenize.py383
-rw-r--r--Lib/trace.py276
-rw-r--r--Lib/traceback.py165
-rw-r--r--Lib/turtle.py (renamed from Lib/lib-tk/turtle.py)646
-rw-r--r--Lib/turtledemo/__init__.py0
-rwxr-xr-xLib/turtledemo/__main__.py266
-rw-r--r--Lib/turtledemo/about_turtle.txt76
-rw-r--r--Lib/turtledemo/about_turtledemo.txt13
-rw-r--r--Lib/turtledemo/bytedesign.py162
-rw-r--r--Lib/turtledemo/chaos.py59
-rw-r--r--Lib/turtledemo/clock.py132
-rw-r--r--Lib/turtledemo/colormixer.py60
-rw-r--r--Lib/turtledemo/demohelp.txt70
-rw-r--r--Lib/turtledemo/forest.py109
-rw-r--r--Lib/turtledemo/fractalcurves.py138
-rw-r--r--Lib/turtledemo/lindenmayer.py119
-rw-r--r--Lib/turtledemo/minimal_hanoi.py76
-rw-r--r--Lib/turtledemo/nim.py226
-rw-r--r--Lib/turtledemo/paint.py50
-rw-r--r--Lib/turtledemo/peace.py65
-rw-r--r--Lib/turtledemo/penrose.py181
-rw-r--r--Lib/turtledemo/planet_and_moon.py113
-rw-r--r--Lib/turtledemo/round_dance.py86
-rw-r--r--Lib/turtledemo/tree.py63
-rw-r--r--Lib/turtledemo/turtle.cfg10
-rw-r--r--Lib/turtledemo/two_canvases.py52
-rw-r--r--Lib/turtledemo/wikipedia.py65
-rw-r--r--Lib/turtledemo/yinyang.py49
-rw-r--r--Lib/types.py61
-rw-r--r--Lib/unittest/case.py531
-rw-r--r--Lib/unittest/loader.py57
-rw-r--r--Lib/unittest/main.py119
-rw-r--r--Lib/unittest/result.py7
-rw-r--r--Lib/unittest/runner.py45
-rw-r--r--Lib/unittest/suite.py12
-rw-r--r--Lib/unittest/test/_test_warnings.py74
-rw-r--r--Lib/unittest/test/support.py45
-rw-r--r--Lib/unittest/test/test_assertions.py46
-rw-r--r--Lib/unittest/test/test_break.py12
-rw-r--r--Lib/unittest/test/test_case.py522
-rw-r--r--Lib/unittest/test/test_discovery.py69
-rw-r--r--Lib/unittest/test/test_functiontestcase.py14
-rw-r--r--Lib/unittest/test/test_loader.py58
-rw-r--r--Lib/unittest/test/test_program.py115
-rw-r--r--Lib/unittest/test/test_result.py45
-rw-r--r--Lib/unittest/test/test_runner.py123
-rw-r--r--Lib/unittest/test/test_setups.py7
-rw-r--r--Lib/unittest/test/test_skipping.py21
-rw-r--r--Lib/unittest/test/test_suite.py15
-rw-r--r--Lib/unittest/util.py30
-rw-r--r--Lib/urllib.py1602
-rw-r--r--Lib/urllib/__init__.py0
-rw-r--r--Lib/urllib/error.py69
-rw-r--r--Lib/urllib/parse.py983
-rw-r--r--Lib/urllib/request.py2484
-rw-r--r--Lib/urllib/response.py96
-rw-r--r--Lib/urllib/robotparser.py (renamed from Lib/robotparser.py)66
-rw-r--r--Lib/urllib2.py1470
-rw-r--r--Lib/urlparse.py403
-rw-r--r--Lib/user.py48
-rwxr-xr-xLib/uu.py61
-rw-r--r--Lib/uuid.py225
-rw-r--r--Lib/warnings.py53
-rw-r--r--Lib/wave.py94
-rw-r--r--Lib/weakref.py218
-rw-r--r--Lib/webbrowser.py38
-rw-r--r--Lib/whichdb.py117
-rw-r--r--Lib/wsgiref/handlers.py181
-rw-r--r--Lib/wsgiref/headers.py39
-rw-r--r--Lib/wsgiref/simple_server.py39
-rw-r--r--Lib/wsgiref/util.py12
-rw-r--r--Lib/wsgiref/validate.py59
-rw-r--r--Lib/xdrlib.py41
-rw-r--r--Lib/xml/__init__.py21
-rw-r--r--Lib/xml/dom/NodeFilter.py2
-rw-r--r--Lib/xml/dom/__init__.py2
-rw-r--r--Lib/xml/dom/domreg.py10
-rw-r--r--Lib/xml/dom/expatbuilder.py12
-rw-r--r--Lib/xml/dom/minicompat.py9
-rw-r--r--Lib/xml/dom/minidom.py91
-rw-r--r--Lib/xml/dom/pulldom.py17
-rw-r--r--Lib/xml/dom/xmlbuilder.py14
-rw-r--r--Lib/xml/etree/ElementInclude.py9
-rw-r--r--Lib/xml/etree/ElementPath.py6
-rw-r--r--Lib/xml/etree/ElementTree.py233
-rw-r--r--Lib/xml/parsers/expat.py8
-rw-r--r--Lib/xml/sax/__init__.py15
-rw-r--r--Lib/xml/sax/expatreader.py5
-rw-r--r--Lib/xml/sax/handler.py2
-rw-r--r--Lib/xml/sax/saxutils.py61
-rw-r--r--Lib/xml/sax/xmlreader.py35
-rw-r--r--Lib/xmllib.py930
-rw-r--r--Lib/xmlrpc/__init__.py1
-rw-r--r--Lib/xmlrpc/client.py (renamed from Lib/xmlrpclib.py)572
-rw-r--r--Lib/xmlrpc/server.py (renamed from Lib/SimpleXMLRPCServer.py)421
-rw-r--r--Lib/zipfile.py395
1718 files changed, 167505 insertions, 224162 deletions
diff --git a/Lib/BaseHTTPServer.py b/Lib/BaseHTTPServer.py
deleted file mode 100644
index deaf2f960b8..00000000000
--- a/Lib/BaseHTTPServer.py
+++ /dev/null
@@ -1,603 +0,0 @@
-"""HTTP server base class.
-
-Note: the class in this module doesn't implement any HTTP request; see
-SimpleHTTPServer for simple implementations of GET, HEAD and POST
-(including CGI scripts). It does, however, optionally implement HTTP/1.1
-persistent connections, as of version 0.3.
-
-Contents:
-
-- BaseHTTPRequestHandler: HTTP request handler base class
-- test: test function
-
-XXX To do:
-
-- log requests even later (to capture byte count)
-- log user-agent header and other interesting goodies
-- send error log to separate file
-"""
-
-
-# See also:
-#
-# HTTP Working Group T. Berners-Lee
-# INTERNET-DRAFT R. T. Fielding
-# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen
-# Expires September 8, 1995 March 8, 1995
-#
-# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt
-#
-# and
-#
-# Network Working Group R. Fielding
-# Request for Comments: 2616 et al
-# Obsoletes: 2068 June 1999
-# Category: Standards Track
-#
-# URL: http://www.faqs.org/rfcs/rfc2616.html
-
-# Log files
-# ---------
-#
-# Here's a quote from the NCSA httpd docs about log file format.
-#
-# | The logfile format is as follows. Each line consists of:
-# |
-# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb
-# |
-# | host: Either the DNS name or the IP number of the remote client
-# | rfc931: Any information returned by identd for this person,
-# | - otherwise.
-# | authuser: If user sent a userid for authentication, the user name,
-# | - otherwise.
-# | DD: Day
-# | Mon: Month (calendar name)
-# | YYYY: Year
-# | hh: hour (24-hour format, the machine's timezone)
-# | mm: minutes
-# | ss: seconds
-# | request: The first line of the HTTP request as sent by the client.
-# | ddd: the status code returned by the server, - if not available.
-# | bbbb: the total number of bytes sent,
-# | *not including the HTTP/1.0 header*, - if not available
-# |
-# | You can determine the name of the file accessed through request.
-#
-# (Actually, the latter is only true if you know the server configuration
-# at the time the request was made!)
-
-__version__ = "0.3"
-
-__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
-
-import sys
-import time
-import socket # For gethostbyaddr()
-from warnings import filterwarnings, catch_warnings
-with catch_warnings():
- if sys.py3kwarning:
- filterwarnings("ignore", ".*mimetools has been removed",
- DeprecationWarning)
- import mimetools
-import SocketServer
-
-# Default error message template
-DEFAULT_ERROR_MESSAGE = """\
-<head>
-<title>Error response</title>
-</head>
-<body>
-<h1>Error response</h1>
-<p>Error code %(code)d.
-<p>Message: %(message)s.
-<p>Error code explanation: %(code)s = %(explain)s.
-</body>
-"""
-
-DEFAULT_ERROR_CONTENT_TYPE = "text/html"
-
-def _quote_html(html):
- return html.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
-
-class HTTPServer(SocketServer.TCPServer):
-
- allow_reuse_address = 1 # Seems to make sense in testing environment
-
- def server_bind(self):
- """Override server_bind to store the server name."""
- SocketServer.TCPServer.server_bind(self)
- host, port = self.socket.getsockname()[:2]
- self.server_name = socket.getfqdn(host)
- self.server_port = port
-
-
-class BaseHTTPRequestHandler(SocketServer.StreamRequestHandler):
-
- """HTTP request handler base class.
-
- The following explanation of HTTP serves to guide you through the
- code as well as to expose any misunderstandings I may have about
- HTTP (so you don't need to read the code to figure out I'm wrong
- :-).
-
- HTTP (HyperText Transfer Protocol) is an extensible protocol on
- top of a reliable stream transport (e.g. TCP/IP). The protocol
- recognizes three parts to a request:
-
- 1. One line identifying the request type and path
- 2. An optional set of RFC-822-style headers
- 3. An optional data part
-
- The headers and data are separated by a blank line.
-
- The first line of the request has the form
-
- <command> <path> <version>
-
- where <command> is a (case-sensitive) keyword such as GET or POST,
- <path> is a string containing path information for the request,
- and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
- <path> is encoded using the URL encoding scheme (using %xx to signify
- the ASCII character with hex code xx).
-
- The specification specifies that lines are separated by CRLF but
- for compatibility with the widest range of clients recommends
- servers also handle LF. Similarly, whitespace in the request line
- is treated sensibly (allowing multiple spaces between components
- and allowing trailing whitespace).
-
- Similarly, for output, lines ought to be separated by CRLF pairs
- but most clients grok LF characters just fine.
-
- If the first line of the request has the form
-
- <command> <path>
-
- (i.e. <version> is left out) then this is assumed to be an HTTP
- 0.9 request; this form has no optional headers and data part and
- the reply consists of just the data.
-
- The reply form of the HTTP 1.x protocol again has three parts:
-
- 1. One line giving the response code
- 2. An optional set of RFC-822-style headers
- 3. The data
-
- Again, the headers and data are separated by a blank line.
-
- The response code line has the form
-
- <version> <responsecode> <responsestring>
-
- where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
- <responsecode> is a 3-digit response code indicating success or
- failure of the request, and <responsestring> is an optional
- human-readable string explaining what the response code means.
-
- This server parses the request and the headers, and then calls a
- function specific to the request type (<command>). Specifically,
- a request SPAM will be handled by a method do_SPAM(). If no
- such method exists the server sends an error response to the
- client. If it exists, it is called with no arguments:
-
- do_SPAM()
-
- Note that the request name is case sensitive (i.e. SPAM and spam
- are different requests).
-
- The various request details are stored in instance variables:
-
- - client_address is the client IP address in the form (host,
- port);
-
- - command, path and version are the broken-down request line;
-
- - headers is an instance of mimetools.Message (or a derived
- class) containing the header information;
-
- - rfile is a file object open for reading positioned at the
- start of the optional input data part;
-
- - wfile is a file object open for writing.
-
- IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!
-
- The first thing to be written must be the response line. Then
- follow 0 or more header lines, then a blank line, and then the
- actual data (if any). The meaning of the header lines depends on
- the command executed by the server; in most cases, when data is
- returned, there should be at least one header line of the form
-
- Content-type: <type>/<subtype>
-
- where <type> and <subtype> should be registered MIME types,
- e.g. "text/html" or "text/plain".
-
- """
-
- # The Python system version, truncated to its first component.
- sys_version = "Python/" + sys.version.split()[0]
-
- # The server software version. You may want to override this.
- # The format is multiple whitespace-separated strings,
- # where each string is of the form name[/version].
- server_version = "BaseHTTP/" + __version__
-
- # The default request version. This only affects responses up until
- # the point where the request line is parsed, so it mainly decides what
- # the client gets back when sending a malformed request line.
- # Most web servers default to HTTP 0.9, i.e. don't send a status line.
- default_request_version = "HTTP/0.9"
-
- def parse_request(self):
- """Parse a request (internal).
-
- The request should be stored in self.raw_requestline; the results
- are in self.command, self.path, self.request_version and
- self.headers.
-
- Return True for success, False for failure; on failure, an
- error is sent back.
-
- """
- self.command = None # set in case of error on the first line
- self.request_version = version = self.default_request_version
- self.close_connection = 1
- requestline = self.raw_requestline
- requestline = requestline.rstrip('\r\n')
- self.requestline = requestline
- words = requestline.split()
- if len(words) == 3:
- command, path, version = words
- if version[:5] != 'HTTP/':
- self.send_error(400, "Bad request version (%r)" % version)
- return False
- try:
- base_version_number = version.split('/', 1)[1]
- version_number = base_version_number.split(".")
- # RFC 2145 section 3.1 says there can be only one "." and
- # - major and minor numbers MUST be treated as
- # separate integers;
- # - HTTP/2.4 is a lower version than HTTP/2.13, which in
- # turn is lower than HTTP/12.3;
- # - Leading zeros MUST be ignored by recipients.
- if len(version_number) != 2:
- raise ValueError
- version_number = int(version_number[0]), int(version_number[1])
- except (ValueError, IndexError):
- self.send_error(400, "Bad request version (%r)" % version)
- return False
- if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
- self.close_connection = 0
- if version_number >= (2, 0):
- self.send_error(505,
- "Invalid HTTP Version (%s)" % base_version_number)
- return False
- elif len(words) == 2:
- command, path = words
- self.close_connection = 1
- if command != 'GET':
- self.send_error(400,
- "Bad HTTP/0.9 request type (%r)" % command)
- return False
- elif not words:
- return False
- else:
- self.send_error(400, "Bad request syntax (%r)" % requestline)
- return False
- self.command, self.path, self.request_version = command, path, version
-
- # Examine the headers and look for a Connection directive
- self.headers = self.MessageClass(self.rfile, 0)
-
- conntype = self.headers.get('Connection', "")
- if conntype.lower() == 'close':
- self.close_connection = 1
- elif (conntype.lower() == 'keep-alive' and
- self.protocol_version >= "HTTP/1.1"):
- self.close_connection = 0
- return True
-
- def handle_one_request(self):
- """Handle a single HTTP request.
-
- You normally don't need to override this method; see the class
- __doc__ string for information on how to handle specific HTTP
- commands such as GET and POST.
-
- """
- try:
- self.raw_requestline = self.rfile.readline(65537)
- if len(self.raw_requestline) > 65536:
- self.requestline = ''
- self.request_version = ''
- self.command = ''
- self.send_error(414)
- return
- if not self.raw_requestline:
- self.close_connection = 1
- return
- if not self.parse_request():
- # An error code has been sent, just exit
- return
- mname = 'do_' + self.command
- if not hasattr(self, mname):
- self.send_error(501, "Unsupported method (%r)" % self.command)
- return
- method = getattr(self, mname)
- method()
- self.wfile.flush() #actually send the response if not already done.
- except socket.timeout, e:
- #a read or a write timed out. Discard this connection
- self.log_error("Request timed out: %r", e)
- self.close_connection = 1
- return
-
- def handle(self):
- """Handle multiple requests if necessary."""
- self.close_connection = 1
-
- self.handle_one_request()
- while not self.close_connection:
- self.handle_one_request()
-
- def send_error(self, code, message=None):
- """Send and log an error reply.
-
- Arguments are the error code, and a detailed message.
- The detailed message defaults to the short entry matching the
- response code.
-
- This sends an error response (so it must be called before any
- output has been generated), logs the error, and finally sends
- a piece of HTML explaining the error to the user.
-
- """
-
- try:
- short, long = self.responses[code]
- except KeyError:
- short, long = '???', '???'
- if message is None:
- message = short
- explain = long
- self.log_error("code %d, message %s", code, message)
- # using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201)
- content = (self.error_message_format %
- {'code': code, 'message': _quote_html(message), 'explain': explain})
- self.send_response(code, message)
- self.send_header("Content-Type", self.error_content_type)
- self.send_header('Connection', 'close')
- self.end_headers()
- if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
- self.wfile.write(content)
-
- error_message_format = DEFAULT_ERROR_MESSAGE
- error_content_type = DEFAULT_ERROR_CONTENT_TYPE
-
- def send_response(self, code, message=None):
- """Send the response header and log the response code.
-
- Also send two standard headers with the server software
- version and the current date.
-
- """
- self.log_request(code)
- if message is None:
- if code in self.responses:
- message = self.responses[code][0]
- else:
- message = ''
- if self.request_version != 'HTTP/0.9':
- self.wfile.write("%s %d %s\r\n" %
- (self.protocol_version, code, message))
- # print (self.protocol_version, code, message)
- self.send_header('Server', self.version_string())
- self.send_header('Date', self.date_time_string())
-
- def send_header(self, keyword, value):
- """Send a MIME header."""
- if self.request_version != 'HTTP/0.9':
- self.wfile.write("%s: %s\r\n" % (keyword, value))
-
- if keyword.lower() == 'connection':
- if value.lower() == 'close':
- self.close_connection = 1
- elif value.lower() == 'keep-alive':
- self.close_connection = 0
-
- def end_headers(self):
- """Send the blank line ending the MIME headers."""
- if self.request_version != 'HTTP/0.9':
- self.wfile.write("\r\n")
-
- def log_request(self, code='-', size='-'):
- """Log an accepted request.
-
- This is called by send_response().
-
- """
-
- self.log_message('"%s" %s %s',
- self.requestline, str(code), str(size))
-
- def log_error(self, format, *args):
- """Log an error.
-
- This is called when a request cannot be fulfilled. By
- default it passes the message on to log_message().
-
- Arguments are the same as for log_message().
-
- XXX This should go to the separate error log.
-
- """
-
- self.log_message(format, *args)
-
- def log_message(self, format, *args):
- """Log an arbitrary message.
-
- This is used by all other logging functions. Override
- it if you have specific logging wishes.
-
- The first argument, FORMAT, is a format string for the
- message to be logged. If the format string contains
- any % escapes requiring parameters, they should be
- specified as subsequent arguments (it's just like
- printf!).
-
- The client ip address and current date/time are prefixed to every
- message.
-
- """
-
- sys.stderr.write("%s - - [%s] %s\n" %
- (self.client_address[0],
- self.log_date_time_string(),
- format%args))
-
- def version_string(self):
- """Return the server software version string."""
- return self.server_version + ' ' + self.sys_version
-
- def date_time_string(self, timestamp=None):
- """Return the current date and time formatted for a message header."""
- if timestamp is None:
- timestamp = time.time()
- year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
- s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
- self.weekdayname[wd],
- day, self.monthname[month], year,
- hh, mm, ss)
- return s
-
- def log_date_time_string(self):
- """Return the current time formatted for logging."""
- now = time.time()
- year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
- s = "%02d/%3s/%04d %02d:%02d:%02d" % (
- day, self.monthname[month], year, hh, mm, ss)
- return s
-
- weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
-
- monthname = [None,
- 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
- 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
-
- def address_string(self):
- """Return the client address formatted for logging.
-
- This version looks up the full hostname using gethostbyaddr(),
- and tries to find a name that contains at least one dot.
-
- """
-
- host, port = self.client_address[:2]
- return socket.getfqdn(host)
-
- # Essentially static class variables
-
- # The version of the HTTP protocol we support.
- # Set this to HTTP/1.1 to enable automatic keepalive
- protocol_version = "HTTP/1.0"
-
- # The Message-like class used to parse headers
- MessageClass = mimetools.Message
-
- # Table mapping response codes to messages; entries have the
- # form {code: (shortmessage, longmessage)}.
- # See RFC 2616.
- responses = {
- 100: ('Continue', 'Request received, please continue'),
- 101: ('Switching Protocols',
- 'Switching to new protocol; obey Upgrade header'),
-
- 200: ('OK', 'Request fulfilled, document follows'),
- 201: ('Created', 'Document created, URL follows'),
- 202: ('Accepted',
- 'Request accepted, processing continues off-line'),
- 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
- 204: ('No Content', 'Request fulfilled, nothing follows'),
- 205: ('Reset Content', 'Clear input form for further input.'),
- 206: ('Partial Content', 'Partial content follows.'),
-
- 300: ('Multiple Choices',
- 'Object has several resources -- see URI list'),
- 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
- 302: ('Found', 'Object moved temporarily -- see URI list'),
- 303: ('See Other', 'Object moved -- see Method and URL list'),
- 304: ('Not Modified',
- 'Document has not changed since given time'),
- 305: ('Use Proxy',
- 'You must use proxy specified in Location to access this '
- 'resource.'),
- 307: ('Temporary Redirect',
- 'Object moved temporarily -- see URI list'),
-
- 400: ('Bad Request',
- 'Bad request syntax or unsupported method'),
- 401: ('Unauthorized',
- 'No permission -- see authorization schemes'),
- 402: ('Payment Required',
- 'No payment -- see charging schemes'),
- 403: ('Forbidden',
- 'Request forbidden -- authorization will not help'),
- 404: ('Not Found', 'Nothing matches the given URI'),
- 405: ('Method Not Allowed',
- 'Specified method is invalid for this resource.'),
- 406: ('Not Acceptable', 'URI not available in preferred format.'),
- 407: ('Proxy Authentication Required', 'You must authenticate with '
- 'this proxy before proceeding.'),
- 408: ('Request Timeout', 'Request timed out; try again later.'),
- 409: ('Conflict', 'Request conflict.'),
- 410: ('Gone',
- 'URI no longer exists and has been permanently removed.'),
- 411: ('Length Required', 'Client must specify Content-Length.'),
- 412: ('Precondition Failed', 'Precondition in headers is false.'),
- 413: ('Request Entity Too Large', 'Entity is too large.'),
- 414: ('Request-URI Too Long', 'URI is too long.'),
- 415: ('Unsupported Media Type', 'Entity body in unsupported format.'),
- 416: ('Requested Range Not Satisfiable',
- 'Cannot satisfy request range.'),
- 417: ('Expectation Failed',
- 'Expect condition could not be satisfied.'),
-
- 500: ('Internal Server Error', 'Server got itself in trouble'),
- 501: ('Not Implemented',
- 'Server does not support this operation'),
- 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),
- 503: ('Service Unavailable',
- 'The server cannot process the request due to a high load'),
- 504: ('Gateway Timeout',
- 'The gateway server did not receive a timely response'),
- 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),
- }
-
-
-def test(HandlerClass = BaseHTTPRequestHandler,
- ServerClass = HTTPServer, protocol="HTTP/1.0"):
- """Test the HTTP request handler class.
-
- This runs an HTTP server on port 8000 (or the first command line
- argument).
-
- """
-
- if sys.argv[1:]:
- port = int(sys.argv[1])
- else:
- port = 8000
- server_address = ('', port)
-
- HandlerClass.protocol_version = protocol
- httpd = ServerClass(server_address, HandlerClass)
-
- sa = httpd.socket.getsockname()
- print "Serving HTTP on", sa[0], "port", sa[1], "..."
- httpd.serve_forever()
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/Bastion.py b/Lib/Bastion.py
deleted file mode 100644
index d0dddbfdefc..00000000000
--- a/Lib/Bastion.py
+++ /dev/null
@@ -1,180 +0,0 @@
-"""Bastionification utility.
-
-A bastion (for another object -- the 'original') is an object that has
-the same methods as the original but does not give access to its
-instance variables. Bastions have a number of uses, but the most
-obvious one is to provide code executing in restricted mode with a
-safe interface to an object implemented in unrestricted mode.
-
-The bastionification routine has an optional second argument which is
-a filter function. Only those methods for which the filter method
-(called with the method name as argument) returns true are accessible.
-The default filter method returns true unless the method name begins
-with an underscore.
-
-There are a number of possible implementations of bastions. We use a
-'lazy' approach where the bastion's __getattr__() discipline does all
-the work for a particular method the first time it is used. This is
-usually fastest, especially if the user doesn't call all available
-methods. The retrieved methods are stored as instance variables of
-the bastion, so the overhead is only occurred on the first use of each
-method.
-
-Detail: the bastion class has a __repr__() discipline which includes
-the repr() of the original object. This is precomputed when the
-bastion is created.
-
-"""
-from warnings import warnpy3k
-warnpy3k("the Bastion module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-__all__ = ["BastionClass", "Bastion"]
-
-from types import MethodType
-
-
-class BastionClass:
-
- """Helper class used by the Bastion() function.
-
- You could subclass this and pass the subclass as the bastionclass
- argument to the Bastion() function, as long as the constructor has
- the same signature (a get() function and a name for the object).
-
- """
-
- def __init__(self, get, name):
- """Constructor.
-
- Arguments:
-
- get - a function that gets the attribute value (by name)
- name - a human-readable name for the original object
- (suggestion: use repr(object))
-
- """
- self._get_ = get
- self._name_ = name
-
- def __repr__(self):
- """Return a representation string.
-
- This includes the name passed in to the constructor, so that
- if you print the bastion during debugging, at least you have
- some idea of what it is.
-
- """
- return "<Bastion for %s>" % self._name_
-
- def __getattr__(self, name):
- """Get an as-yet undefined attribute value.
-
- This calls the get() function that was passed to the
- constructor. The result is stored as an instance variable so
- that the next time the same attribute is requested,
- __getattr__() won't be invoked.
-
- If the get() function raises an exception, this is simply
- passed on -- exceptions are not cached.
-
- """
- attribute = self._get_(name)
- self.__dict__[name] = attribute
- return attribute
-
-
-def Bastion(object, filter = lambda name: name[:1] != '_',
- name=None, bastionclass=BastionClass):
- """Create a bastion for an object, using an optional filter.
-
- See the Bastion module's documentation for background.
-
- Arguments:
-
- object - the original object
- filter - a predicate that decides whether a function name is OK;
- by default all names are OK that don't start with '_'
- name - the name of the object; default repr(object)
- bastionclass - class used to create the bastion; default BastionClass
-
- """
-
- raise RuntimeError, "This code is not secure in Python 2.2 and later"
-
- # Note: we define *two* ad-hoc functions here, get1 and get2.
- # Both are intended to be called in the same way: get(name).
- # It is clear that the real work (getting the attribute
- # from the object and calling the filter) is done in get1.
- # Why can't we pass get1 to the bastion? Because the user
- # would be able to override the filter argument! With get2,
- # overriding the default argument is no security loophole:
- # all it does is call it.
- # Also notice that we can't place the object and filter as
- # instance variables on the bastion object itself, since
- # the user has full access to all instance variables!
-
- def get1(name, object=object, filter=filter):
- """Internal function for Bastion(). See source comments."""
- if filter(name):
- attribute = getattr(object, name)
- if type(attribute) == MethodType:
- return attribute
- raise AttributeError, name
-
- def get2(name, get1=get1):
- """Internal function for Bastion(). See source comments."""
- return get1(name)
-
- if name is None:
- name = repr(object)
- return bastionclass(get2, name)
-
-
-def _test():
- """Test the Bastion() function."""
- class Original:
- def __init__(self):
- self.sum = 0
- def add(self, n):
- self._add(n)
- def _add(self, n):
- self.sum = self.sum + n
- def total(self):
- return self.sum
- o = Original()
- b = Bastion(o)
- testcode = """if 1:
- b.add(81)
- b.add(18)
- print "b.total() =", b.total()
- try:
- print "b.sum =", b.sum,
- except:
- print "inaccessible"
- else:
- print "accessible"
- try:
- print "b._add =", b._add,
- except:
- print "inaccessible"
- else:
- print "accessible"
- try:
- print "b._get_.func_defaults =", map(type, b._get_.func_defaults),
- except:
- print "inaccessible"
- else:
- print "accessible"
- \n"""
- exec testcode
- print '='*20, "Using rexec:", '='*20
- import rexec
- r = rexec.RExec()
- m = r.add_module('__main__')
- m.b = b
- r.r_exec(testcode)
-
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/CGIHTTPServer.py b/Lib/CGIHTTPServer.py
deleted file mode 100644
index 47a994cab1f..00000000000
--- a/Lib/CGIHTTPServer.py
+++ /dev/null
@@ -1,378 +0,0 @@
-"""CGI-savvy HTTP Server.
-
-This module builds on SimpleHTTPServer by implementing GET and POST
-requests to cgi-bin scripts.
-
-If the os.fork() function is not present (e.g. on Windows),
-os.popen2() is used as a fallback, with slightly altered semantics; if
-that function is not present either (e.g. on Macintosh), only Python
-scripts are supported, and they are executed by the current process.
-
-In all cases, the implementation is intentionally naive -- all
-requests are executed sychronously.
-
-SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
--- it may execute arbitrary Python code or external programs.
-
-Note that status code 200 is sent prior to execution of a CGI script, so
-scripts cannot send other status codes such as 302 (redirect).
-"""
-
-
-__version__ = "0.4"
-
-__all__ = ["CGIHTTPRequestHandler"]
-
-import os
-import sys
-import urllib
-import BaseHTTPServer
-import SimpleHTTPServer
-import select
-import copy
-
-
-class CGIHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
-
- """Complete HTTP server with GET, HEAD and POST commands.
-
- GET and HEAD also support running CGI scripts.
-
- The POST command is *only* implemented for CGI scripts.
-
- """
-
- # Determine platform specifics
- have_fork = hasattr(os, 'fork')
- have_popen2 = hasattr(os, 'popen2')
- have_popen3 = hasattr(os, 'popen3')
-
- # Make rfile unbuffered -- we need to read one line and then pass
- # the rest to a subprocess, so we can't use buffered input.
- rbufsize = 0
-
- def do_POST(self):
- """Serve a POST request.
-
- This is only implemented for CGI scripts.
-
- """
-
- if self.is_cgi():
- self.run_cgi()
- else:
- self.send_error(501, "Can only POST to CGI scripts")
-
- def send_head(self):
- """Version of send_head that support CGI scripts"""
- if self.is_cgi():
- return self.run_cgi()
- else:
- return SimpleHTTPServer.SimpleHTTPRequestHandler.send_head(self)
-
- def is_cgi(self):
- """Test whether self.path corresponds to a CGI script.
-
- Returns True and updates the cgi_info attribute to the tuple
- (dir, rest) if self.path requires running a CGI script.
- Returns False otherwise.
-
- If any exception is raised, the caller should assume that
- self.path was rejected as invalid and act accordingly.
-
- The default implementation tests whether the normalized url
- path begins with one of the strings in self.cgi_directories
- (and the next character is a '/' or the end of the string).
- """
- collapsed_path = _url_collapse_path(self.path)
- dir_sep = collapsed_path.find('/', 1)
- head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
- if head in self.cgi_directories:
- self.cgi_info = head, tail
- return True
- return False
-
- cgi_directories = ['/cgi-bin', '/htbin']
-
- def is_executable(self, path):
- """Test whether argument path is an executable file."""
- return executable(path)
-
- def is_python(self, path):
- """Test whether argument path is a Python script."""
- head, tail = os.path.splitext(path)
- return tail.lower() in (".py", ".pyw")
-
- def run_cgi(self):
- """Execute a CGI script."""
- path = self.path
- dir, rest = self.cgi_info
-
- i = path.find('/', len(dir) + 1)
- while i >= 0:
- nextdir = path[:i]
- nextrest = path[i+1:]
-
- scriptdir = self.translate_path(nextdir)
- if os.path.isdir(scriptdir):
- dir, rest = nextdir, nextrest
- i = path.find('/', len(dir) + 1)
- else:
- break
-
- # find an explicit query string, if present.
- i = rest.rfind('?')
- if i >= 0:
- rest, query = rest[:i], rest[i+1:]
- else:
- query = ''
-
- # dissect the part after the directory name into a script name &
- # a possible additional path, to be stored in PATH_INFO.
- i = rest.find('/')
- if i >= 0:
- script, rest = rest[:i], rest[i:]
- else:
- script, rest = rest, ''
-
- scriptname = dir + '/' + script
- scriptfile = self.translate_path(scriptname)
- if not os.path.exists(scriptfile):
- self.send_error(404, "No such CGI script (%r)" % scriptname)
- return
- if not os.path.isfile(scriptfile):
- self.send_error(403, "CGI script is not a plain file (%r)" %
- scriptname)
- return
- ispy = self.is_python(scriptname)
- if not ispy:
- if not (self.have_fork or self.have_popen2 or self.have_popen3):
- self.send_error(403, "CGI script is not a Python script (%r)" %
- scriptname)
- return
- if not self.is_executable(scriptfile):
- self.send_error(403, "CGI script is not executable (%r)" %
- scriptname)
- return
-
- # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
- # XXX Much of the following could be prepared ahead of time!
- env = copy.deepcopy(os.environ)
- env['SERVER_SOFTWARE'] = self.version_string()
- env['SERVER_NAME'] = self.server.server_name
- env['GATEWAY_INTERFACE'] = 'CGI/1.1'
- env['SERVER_PROTOCOL'] = self.protocol_version
- env['SERVER_PORT'] = str(self.server.server_port)
- env['REQUEST_METHOD'] = self.command
- uqrest = urllib.unquote(rest)
- env['PATH_INFO'] = uqrest
- env['PATH_TRANSLATED'] = self.translate_path(uqrest)
- env['SCRIPT_NAME'] = scriptname
- if query:
- env['QUERY_STRING'] = query
- host = self.address_string()
- if host != self.client_address[0]:
- env['REMOTE_HOST'] = host
- env['REMOTE_ADDR'] = self.client_address[0]
- authorization = self.headers.getheader("authorization")
- if authorization:
- authorization = authorization.split()
- if len(authorization) == 2:
- import base64, binascii
- env['AUTH_TYPE'] = authorization[0]
- if authorization[0].lower() == "basic":
- try:
- authorization = base64.decodestring(authorization[1])
- except binascii.Error:
- pass
- else:
- authorization = authorization.split(':')
- if len(authorization) == 2:
- env['REMOTE_USER'] = authorization[0]
- # XXX REMOTE_IDENT
- if self.headers.typeheader is None:
- env['CONTENT_TYPE'] = self.headers.type
- else:
- env['CONTENT_TYPE'] = self.headers.typeheader
- length = self.headers.getheader('content-length')
- if length:
- env['CONTENT_LENGTH'] = length
- referer = self.headers.getheader('referer')
- if referer:
- env['HTTP_REFERER'] = referer
- accept = []
- for line in self.headers.getallmatchingheaders('accept'):
- if line[:1] in "\t\n\r ":
- accept.append(line.strip())
- else:
- accept = accept + line[7:].split(',')
- env['HTTP_ACCEPT'] = ','.join(accept)
- ua = self.headers.getheader('user-agent')
- if ua:
- env['HTTP_USER_AGENT'] = ua
- co = filter(None, self.headers.getheaders('cookie'))
- if co:
- env['HTTP_COOKIE'] = ', '.join(co)
- # XXX Other HTTP_* headers
- # Since we're setting the env in the parent, provide empty
- # values to override previously set values
- for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
- 'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'):
- env.setdefault(k, "")
-
- self.send_response(200, "Script output follows")
-
- decoded_query = query.replace('+', ' ')
-
- if self.have_fork:
- # Unix -- fork as we should
- args = [script]
- if '=' not in decoded_query:
- args.append(decoded_query)
- nobody = nobody_uid()
- self.wfile.flush() # Always flush before forking
- pid = os.fork()
- if pid != 0:
- # Parent
- pid, sts = os.waitpid(pid, 0)
- # throw away additional data [see bug #427345]
- while select.select([self.rfile], [], [], 0)[0]:
- if not self.rfile.read(1):
- break
- if sts:
- self.log_error("CGI script exit status %#x", sts)
- return
- # Child
- try:
- try:
- os.setuid(nobody)
- except os.error:
- pass
- os.dup2(self.rfile.fileno(), 0)
- os.dup2(self.wfile.fileno(), 1)
- os.execve(scriptfile, args, env)
- except:
- self.server.handle_error(self.request, self.client_address)
- os._exit(127)
-
- else:
- # Non Unix - use subprocess
- import subprocess
- cmdline = [scriptfile]
- if self.is_python(scriptfile):
- interp = sys.executable
- if interp.lower().endswith("w.exe"):
- # On Windows, use python.exe, not pythonw.exe
- interp = interp[:-5] + interp[-4:]
- cmdline = [interp, '-u'] + cmdline
- if '=' not in query:
- cmdline.append(query)
-
- self.log_message("command: %s", subprocess.list2cmdline(cmdline))
- try:
- nbytes = int(length)
- except (TypeError, ValueError):
- nbytes = 0
- p = subprocess.Popen(cmdline,
- stdin = subprocess.PIPE,
- stdout = subprocess.PIPE,
- stderr = subprocess.PIPE,
- env = env
- )
- if self.command.lower() == "post" and nbytes > 0:
- data = self.rfile.read(nbytes)
- else:
- data = None
- # throw away additional data [see bug #427345]
- while select.select([self.rfile._sock], [], [], 0)[0]:
- if not self.rfile._sock.recv(1):
- break
- stdout, stderr = p.communicate(data)
- self.wfile.write(stdout)
- if stderr:
- self.log_error('%s', stderr)
- p.stderr.close()
- p.stdout.close()
- status = p.returncode
- if status:
- self.log_error("CGI script exit status %#x", status)
- else:
- self.log_message("CGI script exited OK")
-
-
-def _url_collapse_path(path):
- """
- Given a URL path, remove extra '/'s and '.' path elements and collapse
- any '..' references and returns a colllapsed path.
-
- Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
- The utility of this function is limited to is_cgi method and helps
- preventing some security attacks.
-
- Returns: A tuple of (head, tail) where tail is everything after the final /
- and head is everything before it. Head will always start with a '/' and,
- if it contains anything else, never have a trailing '/'.
-
- Raises: IndexError if too many '..' occur within the path.
-
- """
- # Similar to os.path.split(os.path.normpath(path)) but specific to URL
- # path semantics rather than local operating system semantics.
- path_parts = path.split('/')
- head_parts = []
- for part in path_parts[:-1]:
- if part == '..':
- head_parts.pop() # IndexError if more '..' than prior parts
- elif part and part != '.':
- head_parts.append( part )
- if path_parts:
- tail_part = path_parts.pop()
- if tail_part:
- if tail_part == '..':
- head_parts.pop()
- tail_part = ''
- elif tail_part == '.':
- tail_part = ''
- else:
- tail_part = ''
-
- splitpath = ('/' + '/'.join(head_parts), tail_part)
- collapsed_path = "/".join(splitpath)
-
- return collapsed_path
-
-
-nobody = None
-
-def nobody_uid():
- """Internal routine to get nobody's uid"""
- global nobody
- if nobody:
- return nobody
- try:
- import pwd
- except ImportError:
- return -1
- try:
- nobody = pwd.getpwnam('nobody')[2]
- except KeyError:
- nobody = 1 + max(map(lambda x: x[2], pwd.getpwall()))
- return nobody
-
-
-def executable(path):
- """Test for executable file."""
- try:
- st = os.stat(path)
- except os.error:
- return False
- return st.st_mode & 0111 != 0
-
-
-def test(HandlerClass = CGIHTTPRequestHandler,
- ServerClass = BaseHTTPServer.HTTPServer):
- SimpleHTTPServer.test(HandlerClass, ServerClass)
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/ConfigParser.py b/Lib/ConfigParser.py
deleted file mode 100644
index 7e6cdbc30a7..00000000000
--- a/Lib/ConfigParser.py
+++ /dev/null
@@ -1,753 +0,0 @@
-"""Configuration file parser.
-
-A setup file consists of sections, lead by a "[section]" header,
-and followed by "name: value" entries, with continuations and such in
-the style of RFC 822.
-
-The option values can contain format strings which refer to other values in
-the same section, or values in a special [DEFAULT] section.
-
-For example:
-
- something: %(dir)s/whatever
-
-would resolve the "%(dir)s" to the value of dir. All reference
-expansions are done late, on demand.
-
-Intrinsic defaults can be specified by passing them into the
-ConfigParser constructor as a dictionary.
-
-class:
-
-ConfigParser -- responsible for parsing a list of
- configuration files, and managing the parsed database.
-
- methods:
-
- __init__(defaults=None)
- create the parser and specify a dictionary of intrinsic defaults. The
- keys must be strings, the values must be appropriate for %()s string
- interpolation. Note that `__name__' is always an intrinsic default;
- its value is the section's name.
-
- sections()
- return all the configuration section names, sans DEFAULT
-
- has_section(section)
- return whether the given section exists
-
- has_option(section, option)
- return whether the given option exists in the given section
-
- options(section)
- return list of configuration options for the named section
-
- read(filenames)
- read and parse the list of named configuration files, given by
- name. A single filename is also allowed. Non-existing files
- are ignored. Return list of successfully read files.
-
- readfp(fp, filename=None)
- read and parse one configuration file, given as a file object.
- The filename defaults to fp.name; it is only used in error
- messages (if fp has no `name' attribute, the string `<???>' is used).
-
- get(section, option, raw=False, vars=None)
- return a string value for the named option. All % interpolations are
- expanded in the return values, based on the defaults passed into the
- constructor and the DEFAULT section. Additional substitutions may be
- provided using the `vars' argument, which must be a dictionary whose
- contents override any pre-existing defaults.
-
- getint(section, options)
- like get(), but convert value to an integer
-
- getfloat(section, options)
- like get(), but convert value to a float
-
- getboolean(section, options)
- like get(), but convert value to a boolean (currently case
- insensitively defined as 0, false, no, off for False, and 1, true,
- yes, on for True). Returns False or True.
-
- items(section, raw=False, vars=None)
- return a list of tuples with (name, value) for each option
- in the section.
-
- remove_section(section)
- remove the given file section and all its options
-
- remove_option(section, option)
- remove the given option from the given section
-
- set(section, option, value)
- set the given option
-
- write(fp)
- write the configuration state in .ini format
-"""
-
-try:
- from collections import OrderedDict as _default_dict
-except ImportError:
- # fallback for setup.py which hasn't yet built _collections
- _default_dict = dict
-
-import re
-
-__all__ = ["NoSectionError", "DuplicateSectionError", "NoOptionError",
- "InterpolationError", "InterpolationDepthError",
- "InterpolationSyntaxError", "ParsingError",
- "MissingSectionHeaderError",
- "ConfigParser", "SafeConfigParser", "RawConfigParser",
- "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]
-
-DEFAULTSECT = "DEFAULT"
-
-MAX_INTERPOLATION_DEPTH = 10
-
-
-
-# exception classes
-class Error(Exception):
- """Base class for ConfigParser exceptions."""
-
- def _get_message(self):
- """Getter for 'message'; needed only to override deprecation in
- BaseException."""
- return self.__message
-
- def _set_message(self, value):
- """Setter for 'message'; needed only to override deprecation in
- BaseException."""
- self.__message = value
-
- # BaseException.message has been deprecated since Python 2.6. To prevent
- # DeprecationWarning from popping up over this pre-existing attribute, use
- # a new property that takes lookup precedence.
- message = property(_get_message, _set_message)
-
- def __init__(self, msg=''):
- self.message = msg
- Exception.__init__(self, msg)
-
- def __repr__(self):
- return self.message
-
- __str__ = __repr__
-
-class NoSectionError(Error):
- """Raised when no section matches a requested option."""
-
- def __init__(self, section):
- Error.__init__(self, 'No section: %r' % (section,))
- self.section = section
- self.args = (section, )
-
-class DuplicateSectionError(Error):
- """Raised when a section is multiply-created."""
-
- def __init__(self, section):
- Error.__init__(self, "Section %r already exists" % section)
- self.section = section
- self.args = (section, )
-
-class NoOptionError(Error):
- """A requested option was not found."""
-
- def __init__(self, option, section):
- Error.__init__(self, "No option %r in section: %r" %
- (option, section))
- self.option = option
- self.section = section
- self.args = (option, section)
-
-class InterpolationError(Error):
- """Base class for interpolation-related exceptions."""
-
- def __init__(self, option, section, msg):
- Error.__init__(self, msg)
- self.option = option
- self.section = section
- self.args = (option, section, msg)
-
-class InterpolationMissingOptionError(InterpolationError):
- """A string substitution required a setting which was not available."""
-
- def __init__(self, option, section, rawval, reference):
- msg = ("Bad value substitution:\n"
- "\tsection: [%s]\n"
- "\toption : %s\n"
- "\tkey : %s\n"
- "\trawval : %s\n"
- % (section, option, reference, rawval))
- InterpolationError.__init__(self, option, section, msg)
- self.reference = reference
- self.args = (option, section, rawval, reference)
-
-class InterpolationSyntaxError(InterpolationError):
- """Raised when the source text into which substitutions are made
- does not conform to the required syntax."""
-
-class InterpolationDepthError(InterpolationError):
- """Raised when substitutions are nested too deeply."""
-
- def __init__(self, option, section, rawval):
- msg = ("Value interpolation too deeply recursive:\n"
- "\tsection: [%s]\n"
- "\toption : %s\n"
- "\trawval : %s\n"
- % (section, option, rawval))
- InterpolationError.__init__(self, option, section, msg)
- self.args = (option, section, rawval)
-
-class ParsingError(Error):
- """Raised when a configuration file does not follow legal syntax."""
-
- def __init__(self, filename):
- Error.__init__(self, 'File contains parsing errors: %s' % filename)
- self.filename = filename
- self.errors = []
- self.args = (filename, )
-
- def append(self, lineno, line):
- self.errors.append((lineno, line))
- self.message += '\n\t[line %2d]: %s' % (lineno, line)
-
-class MissingSectionHeaderError(ParsingError):
- """Raised when a key-value pair is found before any section header."""
-
- def __init__(self, filename, lineno, line):
- Error.__init__(
- self,
- 'File contains no section headers.\nfile: %s, line: %d\n%r' %
- (filename, lineno, line))
- self.filename = filename
- self.lineno = lineno
- self.line = line
- self.args = (filename, lineno, line)
-
-
-class RawConfigParser:
- def __init__(self, defaults=None, dict_type=_default_dict,
- allow_no_value=False):
- self._dict = dict_type
- self._sections = self._dict()
- self._defaults = self._dict()
- if allow_no_value:
- self._optcre = self.OPTCRE_NV
- else:
- self._optcre = self.OPTCRE
- if defaults:
- for key, value in defaults.items():
- self._defaults[self.optionxform(key)] = value
-
- def defaults(self):
- return self._defaults
-
- def sections(self):
- """Return a list of section names, excluding [DEFAULT]"""
- # self._sections will never have [DEFAULT] in it
- return self._sections.keys()
-
- def add_section(self, section):
- """Create a new section in the configuration.
-
- Raise DuplicateSectionError if a section by the specified name
- already exists. Raise ValueError if name is DEFAULT or any of it's
- case-insensitive variants.
- """
- if section.lower() == "default":
- raise ValueError, 'Invalid section name: %s' % section
-
- if section in self._sections:
- raise DuplicateSectionError(section)
- self._sections[section] = self._dict()
-
- def has_section(self, section):
- """Indicate whether the named section is present in the configuration.
-
- The DEFAULT section is not acknowledged.
- """
- return section in self._sections
-
- def options(self, section):
- """Return a list of option names for the given section name."""
- try:
- opts = self._sections[section].copy()
- except KeyError:
- raise NoSectionError(section)
- opts.update(self._defaults)
- if '__name__' in opts:
- del opts['__name__']
- return opts.keys()
-
- def read(self, filenames):
- """Read and parse a filename or a list of filenames.
-
- Files that cannot be opened are silently ignored; this is
- designed so that you can specify a list of potential
- configuration file locations (e.g. current directory, user's
- home directory, systemwide directory), and all existing
- configuration files in the list will be read. A single
- filename may also be given.
-
- Return list of successfully read files.
- """
- if isinstance(filenames, basestring):
- filenames = [filenames]
- read_ok = []
- for filename in filenames:
- try:
- fp = open(filename)
- except IOError:
- continue
- self._read(fp, filename)
- fp.close()
- read_ok.append(filename)
- return read_ok
-
- def readfp(self, fp, filename=None):
- """Like read() but the argument must be a file-like object.
-
- The `fp' argument must have a `readline' method. Optional
- second argument is the `filename', which if not given, is
- taken from fp.name. If fp has no `name' attribute, `<???>' is
- used.
-
- """
- if filename is None:
- try:
- filename = fp.name
- except AttributeError:
- filename = '<???>'
- self._read(fp, filename)
-
- def get(self, section, option):
- opt = self.optionxform(option)
- if section not in self._sections:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- if opt in self._defaults:
- return self._defaults[opt]
- else:
- raise NoOptionError(option, section)
- elif opt in self._sections[section]:
- return self._sections[section][opt]
- elif opt in self._defaults:
- return self._defaults[opt]
- else:
- raise NoOptionError(option, section)
-
- def items(self, section):
- try:
- d2 = self._sections[section]
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- d2 = self._dict()
- d = self._defaults.copy()
- d.update(d2)
- if "__name__" in d:
- del d["__name__"]
- return d.items()
-
- def _get(self, section, conv, option):
- return conv(self.get(section, option))
-
- def getint(self, section, option):
- return self._get(section, int, option)
-
- def getfloat(self, section, option):
- return self._get(section, float, option)
-
- _boolean_states = {'1': True, 'yes': True, 'true': True, 'on': True,
- '0': False, 'no': False, 'false': False, 'off': False}
-
- def getboolean(self, section, option):
- v = self.get(section, option)
- if v.lower() not in self._boolean_states:
- raise ValueError, 'Not a boolean: %s' % v
- return self._boolean_states[v.lower()]
-
- def optionxform(self, optionstr):
- return optionstr.lower()
-
- def has_option(self, section, option):
- """Check for the existence of a given option in a given section."""
- if not section or section == DEFAULTSECT:
- option = self.optionxform(option)
- return option in self._defaults
- elif section not in self._sections:
- return False
- else:
- option = self.optionxform(option)
- return (option in self._sections[section]
- or option in self._defaults)
-
- def set(self, section, option, value=None):
- """Set an option."""
- if not section or section == DEFAULTSECT:
- sectdict = self._defaults
- else:
- try:
- sectdict = self._sections[section]
- except KeyError:
- raise NoSectionError(section)
- sectdict[self.optionxform(option)] = value
-
- def write(self, fp):
- """Write an .ini-format representation of the configuration state."""
- if self._defaults:
- fp.write("[%s]\n" % DEFAULTSECT)
- for (key, value) in self._defaults.items():
- fp.write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
- fp.write("\n")
- for section in self._sections:
- fp.write("[%s]\n" % section)
- for (key, value) in self._sections[section].items():
- if key == "__name__":
- continue
- if (value is not None) or (self._optcre == self.OPTCRE):
- key = " = ".join((key, str(value).replace('\n', '\n\t')))
- fp.write("%s\n" % (key))
- fp.write("\n")
-
- def remove_option(self, section, option):
- """Remove an option."""
- if not section or section == DEFAULTSECT:
- sectdict = self._defaults
- else:
- try:
- sectdict = self._sections[section]
- except KeyError:
- raise NoSectionError(section)
- option = self.optionxform(option)
- existed = option in sectdict
- if existed:
- del sectdict[option]
- return existed
-
- def remove_section(self, section):
- """Remove a file section."""
- existed = section in self._sections
- if existed:
- del self._sections[section]
- return existed
-
- #
- # Regular expressions for parsing section headers and options.
- #
- SECTCRE = re.compile(
- r'\[' # [
- r'(?P<header>[^]]+)' # very permissive!
- r'\]' # ]
- )
- OPTCRE = re.compile(
- r'(?P<option>[^:=\s][^:=]*)' # very permissive!
- r'\s*(?P<vi>[:=])\s*' # any number of space/tab,
- # followed by separator
- # (either : or =), followed
- # by any # space/tab
- r'(?P<value>.*)$' # everything up to eol
- )
- OPTCRE_NV = re.compile(
- r'(?P<option>[^:=\s][^:=]*)' # very permissive!
- r'\s*(?:' # any number of space/tab,
- r'(?P<vi>[:=])\s*' # optionally followed by
- # separator (either : or
- # =), followed by any #
- # space/tab
- r'(?P<value>.*))?$' # everything up to eol
- )
-
- def _read(self, fp, fpname):
- """Parse a sectioned setup file.
-
- The sections in setup file contains a title line at the top,
- indicated by a name in square brackets (`[]'), plus key/value
- options lines, indicated by `name: value' format lines.
- Continuations are represented by an embedded newline then
- leading whitespace. Blank lines, lines beginning with a '#',
- and just about everything else are ignored.
- """
- cursect = None # None, or a dictionary
- optname = None
- lineno = 0
- e = None # None, or an exception
- while True:
- line = fp.readline()
- if not line:
- break
- lineno = lineno + 1
- # comment or blank line?
- if line.strip() == '' or line[0] in '#;':
- continue
- if line.split(None, 1)[0].lower() == 'rem' and line[0] in "rR":
- # no leading whitespace
- continue
- # continuation line?
- if line[0].isspace() and cursect is not None and optname:
- value = line.strip()
- if value:
- cursect[optname].append(value)
- # a section header or option header?
- else:
- # is it a section header?
- mo = self.SECTCRE.match(line)
- if mo:
- sectname = mo.group('header')
- if sectname in self._sections:
- cursect = self._sections[sectname]
- elif sectname == DEFAULTSECT:
- cursect = self._defaults
- else:
- cursect = self._dict()
- cursect['__name__'] = sectname
- self._sections[sectname] = cursect
- # So sections can't start with a continuation line
- optname = None
- # no section header in the file?
- elif cursect is None:
- raise MissingSectionHeaderError(fpname, lineno, line)
- # an option line?
- else:
- mo = self._optcre.match(line)
- if mo:
- optname, vi, optval = mo.group('option', 'vi', 'value')
- optname = self.optionxform(optname.rstrip())
- # This check is fine because the OPTCRE cannot
- # match if it would set optval to None
- if optval is not None:
- if vi in ('=', ':') and ';' in optval:
- # ';' is a comment delimiter only if it follows
- # a spacing character
- pos = optval.find(';')
- if pos != -1 and optval[pos-1].isspace():
- optval = optval[:pos]
- optval = optval.strip()
- # allow empty values
- if optval == '""':
- optval = ''
- cursect[optname] = [optval]
- else:
- # valueless option handling
- cursect[optname] = optval
- else:
- # a non-fatal parsing error occurred. set up the
- # exception but keep going. the exception will be
- # raised at the end of the file and will contain a
- # list of all bogus lines
- if not e:
- e = ParsingError(fpname)
- e.append(lineno, repr(line))
- # if any parsing errors occurred, raise an exception
- if e:
- raise e
-
- # join the multi-line values collected while reading
- all_sections = [self._defaults]
- all_sections.extend(self._sections.values())
- for options in all_sections:
- for name, val in options.items():
- if isinstance(val, list):
- options[name] = '\n'.join(val)
-
-import UserDict as _UserDict
-
-class _Chainmap(_UserDict.DictMixin):
- """Combine multiple mappings for successive lookups.
-
- For example, to emulate Python's normal lookup sequence:
-
- import __builtin__
- pylookup = _Chainmap(locals(), globals(), vars(__builtin__))
- """
-
- def __init__(self, *maps):
- self._maps = maps
-
- def __getitem__(self, key):
- for mapping in self._maps:
- try:
- return mapping[key]
- except KeyError:
- pass
- raise KeyError(key)
-
- def keys(self):
- result = []
- seen = set()
- for mapping in self._maps:
- for key in mapping:
- if key not in seen:
- result.append(key)
- seen.add(key)
- return result
-
-class ConfigParser(RawConfigParser):
-
- def get(self, section, option, raw=False, vars=None):
- """Get an option value for a given section.
-
- If `vars' is provided, it must be a dictionary. The option is looked up
- in `vars' (if provided), `section', and in `defaults' in that order.
-
- All % interpolations are expanded in the return values, unless the
- optional argument `raw' is true. Values for interpolation keys are
- looked up in the same manner as the option.
-
- The section DEFAULT is special.
- """
- sectiondict = {}
- try:
- sectiondict = self._sections[section]
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- # Update with the entry specific variables
- vardict = {}
- if vars:
- for key, value in vars.items():
- vardict[self.optionxform(key)] = value
- d = _Chainmap(vardict, sectiondict, self._defaults)
- option = self.optionxform(option)
- try:
- value = d[option]
- except KeyError:
- raise NoOptionError(option, section)
-
- if raw or value is None:
- return value
- else:
- return self._interpolate(section, option, value, d)
-
- def items(self, section, raw=False, vars=None):
- """Return a list of tuples with (name, value) for each option
- in the section.
-
- All % interpolations are expanded in the return values, based on the
- defaults passed into the constructor, unless the optional argument
- `raw' is true. Additional substitutions may be provided using the
- `vars' argument, which must be a dictionary whose contents overrides
- any pre-existing defaults.
-
- The section DEFAULT is special.
- """
- d = self._defaults.copy()
- try:
- d.update(self._sections[section])
- except KeyError:
- if section != DEFAULTSECT:
- raise NoSectionError(section)
- # Update with the entry specific variables
- if vars:
- for key, value in vars.items():
- d[self.optionxform(key)] = value
- options = d.keys()
- if "__name__" in options:
- options.remove("__name__")
- if raw:
- return [(option, d[option])
- for option in options]
- else:
- return [(option, self._interpolate(section, option, d[option], d))
- for option in options]
-
- def _interpolate(self, section, option, rawval, vars):
- # do the string interpolation
- value = rawval
- depth = MAX_INTERPOLATION_DEPTH
- while depth: # Loop through this until it's done
- depth -= 1
- if value and "%(" in value:
- value = self._KEYCRE.sub(self._interpolation_replace, value)
- try:
- value = value % vars
- except KeyError, e:
- raise InterpolationMissingOptionError(
- option, section, rawval, e.args[0])
- else:
- break
- if value and "%(" in value:
- raise InterpolationDepthError(option, section, rawval)
- return value
-
- _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
-
- def _interpolation_replace(self, match):
- s = match.group(1)
- if s is None:
- return match.group()
- else:
- return "%%(%s)s" % self.optionxform(s)
-
-
-class SafeConfigParser(ConfigParser):
-
- def _interpolate(self, section, option, rawval, vars):
- # do the string interpolation
- L = []
- self._interpolate_some(option, L, rawval, section, vars, 1)
- return ''.join(L)
-
- _interpvar_re = re.compile(r"%\(([^)]+)\)s")
-
- def _interpolate_some(self, option, accum, rest, section, map, depth):
- if depth > MAX_INTERPOLATION_DEPTH:
- raise InterpolationDepthError(option, section, rest)
- while rest:
- p = rest.find("%")
- if p < 0:
- accum.append(rest)
- return
- if p > 0:
- accum.append(rest[:p])
- rest = rest[p:]
- # p is no longer used
- c = rest[1:2]
- if c == "%":
- accum.append("%")
- rest = rest[2:]
- elif c == "(":
- m = self._interpvar_re.match(rest)
- if m is None:
- raise InterpolationSyntaxError(option, section,
- "bad interpolation variable reference %r" % rest)
- var = self.optionxform(m.group(1))
- rest = rest[m.end():]
- try:
- v = map[var]
- except KeyError:
- raise InterpolationMissingOptionError(
- option, section, rest, var)
- if "%" in v:
- self._interpolate_some(option, accum, v,
- section, map, depth + 1)
- else:
- accum.append(v)
- else:
- raise InterpolationSyntaxError(
- option, section,
- "'%%' must be followed by '%%' or '(', found: %r" % (rest,))
-
- def set(self, section, option, value=None):
- """Set an option. Extend ConfigParser.set: check for string values."""
- # The only legal non-string value if we allow valueless
- # options is None, so we need to check if the value is a
- # string if:
- # - we do not allow valueless options, or
- # - we allow valueless options but the value is not None
- if self._optcre is self.OPTCRE or value:
- if not isinstance(value, basestring):
- raise TypeError("option values must be strings")
- if value is not None:
- # check for bad percent signs:
- # first, replace all "good" interpolations
- tmp_value = value.replace('%%', '')
- tmp_value = self._interpvar_re.sub('', tmp_value)
- # then, check if there's a lone percent sign left
- if '%' in tmp_value:
- raise ValueError("invalid interpolation syntax in %r at "
- "position %d" % (value, tmp_value.find('%')))
- ConfigParser.set(self, section, option, value)
diff --git a/Lib/DocXMLRPCServer.py b/Lib/DocXMLRPCServer.py
deleted file mode 100644
index 4064ec2e48d..00000000000
--- a/Lib/DocXMLRPCServer.py
+++ /dev/null
@@ -1,279 +0,0 @@
-"""Self documenting XML-RPC Server.
-
-This module can be used to create XML-RPC servers that
-serve pydoc-style documentation in response to HTTP
-GET requests. This documentation is dynamically generated
-based on the functions and methods registered with the
-server.
-
-This module is built upon the pydoc and SimpleXMLRPCServer
-modules.
-"""
-
-import pydoc
-import inspect
-import re
-import sys
-
-from SimpleXMLRPCServer import (SimpleXMLRPCServer,
- SimpleXMLRPCRequestHandler,
- CGIXMLRPCRequestHandler,
- resolve_dotted_attribute)
-
-class ServerHTMLDoc(pydoc.HTMLDoc):
- """Class used to generate pydoc HTML document for a server"""
-
- def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
- """Mark up some plain text, given a context of symbols to look for.
- Each context dictionary maps object names to anchor names."""
- escape = escape or self.escape
- results = []
- here = 0
-
- # XXX Note that this regular expression does not allow for the
- # hyperlinking of arbitrary strings being used as method
- # names. Only methods with names consisting of word characters
- # and '.'s are hyperlinked.
- pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
- r'RFC[- ]?(\d+)|'
- r'PEP[- ]?(\d+)|'
- r'(self\.)?((?:\w|\.)+))\b')
- while 1:
- match = pattern.search(text, here)
- if not match: break
- start, end = match.span()
- results.append(escape(text[here:start]))
-
- all, scheme, rfc, pep, selfdot, name = match.groups()
- if scheme:
- url = escape(all).replace('"', '&quot;')
- results.append('<a href="%s">%s</a>' % (url, url))
- elif rfc:
- url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
- results.append('<a href="%s">%s</a>' % (url, escape(all)))
- elif pep:
- url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
- results.append('<a href="%s">%s</a>' % (url, escape(all)))
- elif text[end:end+1] == '(':
- results.append(self.namelink(name, methods, funcs, classes))
- elif selfdot:
- results.append('self.<strong>%s</strong>' % name)
- else:
- results.append(self.namelink(name, classes))
- here = end
- results.append(escape(text[here:]))
- return ''.join(results)
-
- def docroutine(self, object, name, mod=None,
- funcs={}, classes={}, methods={}, cl=None):
- """Produce HTML documentation for a function or method object."""
-
- anchor = (cl and cl.__name__ or '') + '-' + name
- note = ''
-
- title = '<a name="%s"><strong>%s</strong></a>' % (
- self.escape(anchor), self.escape(name))
-
- if inspect.ismethod(object):
- args, varargs, varkw, defaults = inspect.getargspec(object.im_func)
- # exclude the argument bound to the instance, it will be
- # confusing to the non-Python user
- argspec = inspect.formatargspec (
- args[1:],
- varargs,
- varkw,
- defaults,
- formatvalue=self.formatvalue
- )
- elif inspect.isfunction(object):
- args, varargs, varkw, defaults = inspect.getargspec(object)
- argspec = inspect.formatargspec(
- args, varargs, varkw, defaults, formatvalue=self.formatvalue)
- else:
- argspec = '(...)'
-
- if isinstance(object, tuple):
- argspec = object[0] or argspec
- docstring = object[1] or ""
- else:
- docstring = pydoc.getdoc(object)
-
- decl = title + argspec + (note and self.grey(
- '<font face="helvetica, arial">%s</font>' % note))
-
- doc = self.markup(
- docstring, self.preformat, funcs, classes, methods)
- doc = doc and '<dd><tt>%s</tt></dd>' % doc
- return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
-
- def docserver(self, server_name, package_documentation, methods):
- """Produce HTML documentation for an XML-RPC server."""
-
- fdict = {}
- for key, value in methods.items():
- fdict[key] = '#-' + key
- fdict[value] = fdict[key]
-
- server_name = self.escape(server_name)
- head = '<big><big><strong>%s</strong></big></big>' % server_name
- result = self.heading(head, '#ffffff', '#7799ee')
-
- doc = self.markup(package_documentation, self.preformat, fdict)
- doc = doc and '<tt>%s</tt>' % doc
- result = result + '<p>%s</p>\n' % doc
-
- contents = []
- method_items = sorted(methods.items())
- for key, value in method_items:
- contents.append(self.docroutine(value, key, funcs=fdict))
- result = result + self.bigsection(
- 'Methods', '#ffffff', '#eeaa77', pydoc.join(contents))
-
- return result
-
-class XMLRPCDocGenerator:
- """Generates documentation for an XML-RPC server.
-
- This class is designed as mix-in and should not
- be constructed directly.
- """
-
- def __init__(self):
- # setup variables used for HTML documentation
- self.server_name = 'XML-RPC Server Documentation'
- self.server_documentation = \
- "This server exports the following methods through the XML-RPC "\
- "protocol."
- self.server_title = 'XML-RPC Server Documentation'
-
- def set_server_title(self, server_title):
- """Set the HTML title of the generated server documentation"""
-
- self.server_title = server_title
-
- def set_server_name(self, server_name):
- """Set the name of the generated HTML server documentation"""
-
- self.server_name = server_name
-
- def set_server_documentation(self, server_documentation):
- """Set the documentation string for the entire server."""
-
- self.server_documentation = server_documentation
-
- def generate_html_documentation(self):
- """generate_html_documentation() => html documentation for the server
-
- Generates HTML documentation for the server using introspection for
- installed functions and instances that do not implement the
- _dispatch method. Alternatively, instances can choose to implement
- the _get_method_argstring(method_name) method to provide the
- argument string used in the documentation and the
- _methodHelp(method_name) method to provide the help text used
- in the documentation."""
-
- methods = {}
-
- for method_name in self.system_listMethods():
- if method_name in self.funcs:
- method = self.funcs[method_name]
- elif self.instance is not None:
- method_info = [None, None] # argspec, documentation
- if hasattr(self.instance, '_get_method_argstring'):
- method_info[0] = self.instance._get_method_argstring(method_name)
- if hasattr(self.instance, '_methodHelp'):
- method_info[1] = self.instance._methodHelp(method_name)
-
- method_info = tuple(method_info)
- if method_info != (None, None):
- method = method_info
- elif not hasattr(self.instance, '_dispatch'):
- try:
- method = resolve_dotted_attribute(
- self.instance,
- method_name
- )
- except AttributeError:
- method = method_info
- else:
- method = method_info
- else:
- assert 0, "Could not find method in self.functions and no "\
- "instance installed"
-
- methods[method_name] = method
-
- documenter = ServerHTMLDoc()
- documentation = documenter.docserver(
- self.server_name,
- self.server_documentation,
- methods
- )
-
- return documenter.page(self.server_title, documentation)
-
-class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
- """XML-RPC and documentation request handler class.
-
- Handles all HTTP POST requests and attempts to decode them as
- XML-RPC requests.
-
- Handles all HTTP GET requests and interprets them as requests
- for documentation.
- """
-
- def do_GET(self):
- """Handles the HTTP GET request.
-
- Interpret all HTTP GET requests as requests for server
- documentation.
- """
- # Check that the path is legal
- if not self.is_rpc_path_valid():
- self.report_404()
- return
-
- response = self.server.generate_html_documentation()
- self.send_response(200)
- self.send_header("Content-type", "text/html")
- self.send_header("Content-length", str(len(response)))
- self.end_headers()
- self.wfile.write(response)
-
-class DocXMLRPCServer( SimpleXMLRPCServer,
- XMLRPCDocGenerator):
- """XML-RPC and HTML documentation server.
-
- Adds the ability to serve server documentation to the capabilities
- of SimpleXMLRPCServer.
- """
-
- def __init__(self, addr, requestHandler=DocXMLRPCRequestHandler,
- logRequests=1, allow_none=False, encoding=None,
- bind_and_activate=True):
- SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests,
- allow_none, encoding, bind_and_activate)
- XMLRPCDocGenerator.__init__(self)
-
-class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
- XMLRPCDocGenerator):
- """Handler for XML-RPC data and documentation requests passed through
- CGI"""
-
- def handle_get(self):
- """Handles the HTTP GET request.
-
- Interpret all HTTP GET requests as requests for server
- documentation.
- """
-
- response = self.generate_html_documentation()
-
- print 'Content-Type: text/html'
- print 'Content-Length: %d' % len(response)
- print
- sys.stdout.write(response)
-
- def __init__(self):
- CGIXMLRPCRequestHandler.__init__(self)
- XMLRPCDocGenerator.__init__(self)
diff --git a/Lib/MimeWriter.py b/Lib/MimeWriter.py
deleted file mode 100644
index e898f9ff231..00000000000
--- a/Lib/MimeWriter.py
+++ /dev/null
@@ -1,186 +0,0 @@
-"""Generic MIME writer.
-
-This module defines the class MimeWriter. The MimeWriter class implements
-a basic formatter for creating MIME multi-part files. It doesn't seek around
-the output file nor does it use large amounts of buffer space. You must write
-the parts out in the order that they should occur in the final file.
-MimeWriter does buffer the headers you add, allowing you to rearrange their
-order.
-
-"""
-
-
-import mimetools
-
-__all__ = ["MimeWriter"]
-
-import warnings
-
-warnings.warn("the MimeWriter module is deprecated; use the email package instead",
- DeprecationWarning, 2)
-
-class MimeWriter:
-
- """Generic MIME writer.
-
- Methods:
-
- __init__()
- addheader()
- flushheaders()
- startbody()
- startmultipartbody()
- nextpart()
- lastpart()
-
- A MIME writer is much more primitive than a MIME parser. It
- doesn't seek around on the output file, and it doesn't use large
- amounts of buffer space, so you have to write the parts in the
- order they should occur on the output file. It does buffer the
- headers you add, allowing you to rearrange their order.
-
- General usage is:
-
- f = <open the output file>
- w = MimeWriter(f)
- ...call w.addheader(key, value) 0 or more times...
-
- followed by either:
-
- f = w.startbody(content_type)
- ...call f.write(data) for body data...
-
- or:
-
- w.startmultipartbody(subtype)
- for each part:
- subwriter = w.nextpart()
- ...use the subwriter's methods to create the subpart...
- w.lastpart()
-
- The subwriter is another MimeWriter instance, and should be
- treated in the same way as the toplevel MimeWriter. This way,
- writing recursive body parts is easy.
-
- Warning: don't forget to call lastpart()!
-
- XXX There should be more state so calls made in the wrong order
- are detected.
-
- Some special cases:
-
- - startbody() just returns the file passed to the constructor;
- but don't use this knowledge, as it may be changed.
-
- - startmultipartbody() actually returns a file as well;
- this can be used to write the initial 'if you can read this your
- mailer is not MIME-aware' message.
-
- - If you call flushheaders(), the headers accumulated so far are
- written out (and forgotten); this is useful if you don't need a
- body part at all, e.g. for a subpart of type message/rfc822
- that's (mis)used to store some header-like information.
-
- - Passing a keyword argument 'prefix=<flag>' to addheader(),
- start*body() affects where the header is inserted; 0 means
- append at the end, 1 means insert at the start; default is
- append for addheader(), but insert for start*body(), which use
- it to determine where the Content-Type header goes.
-
- """
-
- def __init__(self, fp):
- self._fp = fp
- self._headers = []
-
- def addheader(self, key, value, prefix=0):
- """Add a header line to the MIME message.
-
- The key is the name of the header, where the value obviously provides
- the value of the header. The optional argument prefix determines
- where the header is inserted; 0 means append at the end, 1 means
- insert at the start. The default is to append.
-
- """
- lines = value.split("\n")
- while lines and not lines[-1]: del lines[-1]
- while lines and not lines[0]: del lines[0]
- for i in range(1, len(lines)):
- lines[i] = " " + lines[i].strip()
- value = "\n".join(lines) + "\n"
- line = key + ": " + value
- if prefix:
- self._headers.insert(0, line)
- else:
- self._headers.append(line)
-
- def flushheaders(self):
- """Writes out and forgets all headers accumulated so far.
-
- This is useful if you don't need a body part at all; for example,
- for a subpart of type message/rfc822 that's (mis)used to store some
- header-like information.
-
- """
- self._fp.writelines(self._headers)
- self._headers = []
-
- def startbody(self, ctype, plist=[], prefix=1):
- """Returns a file-like object for writing the body of the message.
-
- The content-type is set to the provided ctype, and the optional
- parameter, plist, provides additional parameters for the
- content-type declaration. The optional argument prefix determines
- where the header is inserted; 0 means append at the end, 1 means
- insert at the start. The default is to insert at the start.
-
- """
- for name, value in plist:
- ctype = ctype + ';\n %s=\"%s\"' % (name, value)
- self.addheader("Content-Type", ctype, prefix=prefix)
- self.flushheaders()
- self._fp.write("\n")
- return self._fp
-
- def startmultipartbody(self, subtype, boundary=None, plist=[], prefix=1):
- """Returns a file-like object for writing the body of the message.
-
- Additionally, this method initializes the multi-part code, where the
- subtype parameter provides the multipart subtype, the boundary
- parameter may provide a user-defined boundary specification, and the
- plist parameter provides optional parameters for the subtype. The
- optional argument, prefix, determines where the header is inserted;
- 0 means append at the end, 1 means insert at the start. The default
- is to insert at the start. Subparts should be created using the
- nextpart() method.
-
- """
- self._boundary = boundary or mimetools.choose_boundary()
- return self.startbody("multipart/" + subtype,
- [("boundary", self._boundary)] + plist,
- prefix=prefix)
-
- def nextpart(self):
- """Returns a new instance of MimeWriter which represents an
- individual part in a multipart message.
-
- This may be used to write the part as well as used for creating
- recursively complex multipart messages. The message must first be
- initialized with the startmultipartbody() method before using the
- nextpart() method.
-
- """
- self._fp.write("\n--" + self._boundary + "\n")
- return self.__class__(self._fp)
-
- def lastpart(self):
- """This is used to designate the last part of a multipart message.
-
- It should always be used when writing multipart messages.
-
- """
- self._fp.write("\n--" + self._boundary + "--\n")
-
-
-if __name__ == '__main__':
- import test.test_MimeWriter
diff --git a/Lib/SimpleHTTPServer.py b/Lib/SimpleHTTPServer.py
deleted file mode 100644
index 3e0334da3b3..00000000000
--- a/Lib/SimpleHTTPServer.py
+++ /dev/null
@@ -1,220 +0,0 @@
-"""Simple HTTP Server.
-
-This module builds on BaseHTTPServer by implementing the standard GET
-and HEAD requests in a fairly straightforward manner.
-
-"""
-
-
-__version__ = "0.6"
-
-__all__ = ["SimpleHTTPRequestHandler"]
-
-import os
-import posixpath
-import BaseHTTPServer
-import urllib
-import cgi
-import sys
-import shutil
-import mimetypes
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-
-class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
-
- """Simple HTTP request handler with GET and HEAD commands.
-
- This serves files from the current directory and any of its
- subdirectories. The MIME type for files is determined by
- calling the .guess_type() method.
-
- The GET and HEAD requests are identical except that the HEAD
- request omits the actual contents of the file.
-
- """
-
- server_version = "SimpleHTTP/" + __version__
-
- def do_GET(self):
- """Serve a GET request."""
- f = self.send_head()
- if f:
- self.copyfile(f, self.wfile)
- f.close()
-
- def do_HEAD(self):
- """Serve a HEAD request."""
- f = self.send_head()
- if f:
- f.close()
-
- def send_head(self):
- """Common code for GET and HEAD commands.
-
- This sends the response code and MIME headers.
-
- Return value is either a file object (which has to be copied
- to the outputfile by the caller unless the command was HEAD,
- and must be closed by the caller under all circumstances), or
- None, in which case the caller has nothing further to do.
-
- """
- path = self.translate_path(self.path)
- f = None
- if os.path.isdir(path):
- if not self.path.endswith('/'):
- # redirect browser - doing basically what apache does
- self.send_response(301)
- self.send_header("Location", self.path + "/")
- self.end_headers()
- return None
- for index in "index.html", "index.htm":
- index = os.path.join(path, index)
- if os.path.exists(index):
- path = index
- break
- else:
- return self.list_directory(path)
- ctype = self.guess_type(path)
- try:
- # Always read in binary mode. Opening files in text mode may cause
- # newline translations, making the actual size of the content
- # transmitted *less* than the content-length!
- f = open(path, 'rb')
- except IOError:
- self.send_error(404, "File not found")
- return None
- self.send_response(200)
- self.send_header("Content-type", ctype)
- fs = os.fstat(f.fileno())
- self.send_header("Content-Length", str(fs[6]))
- self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
- self.end_headers()
- return f
-
- def list_directory(self, path):
- """Helper to produce a directory listing (absent index.html).
-
- Return value is either a file object, or None (indicating an
- error). In either case, the headers are sent, making the
- interface the same as for send_head().
-
- """
- try:
- list = os.listdir(path)
- except os.error:
- self.send_error(404, "No permission to list directory")
- return None
- list.sort(key=lambda a: a.lower())
- f = StringIO()
- displaypath = cgi.escape(urllib.unquote(self.path))
- f.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
- f.write("<html>\n<title>Directory listing for %s</title>\n" % displaypath)
- f.write("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath)
- f.write("<hr>\n<ul>\n")
- for name in list:
- fullname = os.path.join(path, name)
- displayname = linkname = name
- # Append / for directories or @ for symbolic links
- if os.path.isdir(fullname):
- displayname = name + "/"
- linkname = name + "/"
- if os.path.islink(fullname):
- displayname = name + "@"
- # Note: a link to a directory displays with @ and links with /
- f.write('<li><a href="%s">%s</a>\n'
- % (urllib.quote(linkname), cgi.escape(displayname)))
- f.write("</ul>\n<hr>\n</body>\n</html>\n")
- length = f.tell()
- f.seek(0)
- self.send_response(200)
- encoding = sys.getfilesystemencoding()
- self.send_header("Content-type", "text/html; charset=%s" % encoding)
- self.send_header("Content-Length", str(length))
- self.end_headers()
- return f
-
- def translate_path(self, path):
- """Translate a /-separated PATH to the local filename syntax.
-
- Components that mean special things to the local file system
- (e.g. drive or directory names) are ignored. (XXX They should
- probably be diagnosed.)
-
- """
- # abandon query parameters
- path = path.split('?',1)[0]
- path = path.split('#',1)[0]
- path = posixpath.normpath(urllib.unquote(path))
- words = path.split('/')
- words = filter(None, words)
- path = os.getcwd()
- for word in words:
- drive, word = os.path.splitdrive(word)
- head, word = os.path.split(word)
- if word in (os.curdir, os.pardir): continue
- path = os.path.join(path, word)
- return path
-
- def copyfile(self, source, outputfile):
- """Copy all data between two file objects.
-
- The SOURCE argument is a file object open for reading
- (or anything with a read() method) and the DESTINATION
- argument is a file object open for writing (or
- anything with a write() method).
-
- The only reason for overriding this would be to change
- the block size or perhaps to replace newlines by CRLF
- -- note however that this the default server uses this
- to copy binary data as well.
-
- """
- shutil.copyfileobj(source, outputfile)
-
- def guess_type(self, path):
- """Guess the type of a file.
-
- Argument is a PATH (a filename).
-
- Return value is a string of the form type/subtype,
- usable for a MIME Content-type header.
-
- The default implementation looks the file's extension
- up in the table self.extensions_map, using application/octet-stream
- as a default; however it would be permissible (if
- slow) to look inside the data to make a better guess.
-
- """
-
- base, ext = posixpath.splitext(path)
- if ext in self.extensions_map:
- return self.extensions_map[ext]
- ext = ext.lower()
- if ext in self.extensions_map:
- return self.extensions_map[ext]
- else:
- return self.extensions_map['']
-
- if not mimetypes.inited:
- mimetypes.init() # try to read system mime.types
- extensions_map = mimetypes.types_map.copy()
- extensions_map.update({
- '': 'application/octet-stream', # Default
- '.py': 'text/plain',
- '.c': 'text/plain',
- '.h': 'text/plain',
- })
-
-
-def test(HandlerClass = SimpleHTTPRequestHandler,
- ServerClass = BaseHTTPServer.HTTPServer):
- BaseHTTPServer.test(HandlerClass, ServerClass)
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/StringIO.py b/Lib/StringIO.py
deleted file mode 100644
index f74a066773f..00000000000
--- a/Lib/StringIO.py
+++ /dev/null
@@ -1,324 +0,0 @@
-r"""File-like objects that read from or write to a string buffer.
-
-This implements (nearly) all stdio methods.
-
-f = StringIO() # ready for writing
-f = StringIO(buf) # ready for reading
-f.close() # explicitly release resources held
-flag = f.isatty() # always false
-pos = f.tell() # get current position
-f.seek(pos) # set current position
-f.seek(pos, mode) # mode 0: absolute; 1: relative; 2: relative to EOF
-buf = f.read() # read until EOF
-buf = f.read(n) # read up to n bytes
-buf = f.readline() # read until end of line ('\n') or EOF
-list = f.readlines()# list of f.readline() results until EOF
-f.truncate([size]) # truncate file at to at most size (default: current pos)
-f.write(buf) # write at current position
-f.writelines(list) # for line in list: f.write(line)
-f.getvalue() # return whole file's contents as a string
-
-Notes:
-- Using a real file is often faster (but less convenient).
-- There's also a much faster implementation in C, called cStringIO, but
- it's not subclassable.
-- fileno() is left unimplemented so that code which uses it triggers
- an exception early.
-- Seeking far beyond EOF and then writing will insert real null
- bytes that occupy space in the buffer.
-- There's a simple test set (see end of this file).
-"""
-try:
- from errno import EINVAL
-except ImportError:
- EINVAL = 22
-
-__all__ = ["StringIO"]
-
-def _complain_ifclosed(closed):
- if closed:
- raise ValueError, "I/O operation on closed file"
-
-class StringIO:
- """class StringIO([buffer])
-
- When a StringIO object is created, it can be initialized to an existing
- string by passing the string to the constructor. If no string is given,
- the StringIO will start empty.
-
- The StringIO object can accept either Unicode or 8-bit strings, but
- mixing the two may take some care. If both are used, 8-bit strings that
- cannot be interpreted as 7-bit ASCII (that use the 8th bit) will cause
- a UnicodeError to be raised when getvalue() is called.
- """
- def __init__(self, buf = ''):
- # Force self.buf to be a string or unicode
- if not isinstance(buf, basestring):
- buf = str(buf)
- self.buf = buf
- self.len = len(buf)
- self.buflist = []
- self.pos = 0
- self.closed = False
- self.softspace = 0
-
- def __iter__(self):
- return self
-
- def next(self):
- """A file object is its own iterator, for example iter(f) returns f
- (unless f is closed). When a file is used as an iterator, typically
- in a for loop (for example, for line in f: print line), the next()
- method is called repeatedly. This method returns the next input line,
- or raises StopIteration when EOF is hit.
- """
- _complain_ifclosed(self.closed)
- r = self.readline()
- if not r:
- raise StopIteration
- return r
-
- def close(self):
- """Free the memory buffer.
- """
- if not self.closed:
- self.closed = True
- del self.buf, self.pos
-
- def isatty(self):
- """Returns False because StringIO objects are not connected to a
- tty-like device.
- """
- _complain_ifclosed(self.closed)
- return False
-
- def seek(self, pos, mode = 0):
- """Set the file's current position.
-
- The mode argument is optional and defaults to 0 (absolute file
- positioning); other values are 1 (seek relative to the current
- position) and 2 (seek relative to the file's end).
-
- There is no return value.
- """
- _complain_ifclosed(self.closed)
- if self.buflist:
- self.buf += ''.join(self.buflist)
- self.buflist = []
- if mode == 1:
- pos += self.pos
- elif mode == 2:
- pos += self.len
- self.pos = max(0, pos)
-
- def tell(self):
- """Return the file's current position."""
- _complain_ifclosed(self.closed)
- return self.pos
-
- def read(self, n = -1):
- """Read at most size bytes from the file
- (less if the read hits EOF before obtaining size bytes).
-
- If the size argument is negative or omitted, read all data until EOF
- is reached. The bytes are returned as a string object. An empty
- string is returned when EOF is encountered immediately.
- """
- _complain_ifclosed(self.closed)
- if self.buflist:
- self.buf += ''.join(self.buflist)
- self.buflist = []
- if n is None or n < 0:
- newpos = self.len
- else:
- newpos = min(self.pos+n, self.len)
- r = self.buf[self.pos:newpos]
- self.pos = newpos
- return r
-
- def readline(self, length=None):
- r"""Read one entire line from the file.
-
- A trailing newline character is kept in the string (but may be absent
- when a file ends with an incomplete line). If the size argument is
- present and non-negative, it is a maximum byte count (including the
- trailing newline) and an incomplete line may be returned.
-
- An empty string is returned only when EOF is encountered immediately.
-
- Note: Unlike stdio's fgets(), the returned string contains null
- characters ('\0') if they occurred in the input.
- """
- _complain_ifclosed(self.closed)
- if self.buflist:
- self.buf += ''.join(self.buflist)
- self.buflist = []
- i = self.buf.find('\n', self.pos)
- if i < 0:
- newpos = self.len
- else:
- newpos = i+1
- if length is not None and length > 0:
- if self.pos + length < newpos:
- newpos = self.pos + length
- r = self.buf[self.pos:newpos]
- self.pos = newpos
- return r
-
- def readlines(self, sizehint = 0):
- """Read until EOF using readline() and return a list containing the
- lines thus read.
-
- If the optional sizehint argument is present, instead of reading up
- to EOF, whole lines totalling approximately sizehint bytes (or more
- to accommodate a final whole line).
- """
- total = 0
- lines = []
- line = self.readline()
- while line:
- lines.append(line)
- total += len(line)
- if 0 < sizehint <= total:
- break
- line = self.readline()
- return lines
-
- def truncate(self, size=None):
- """Truncate the file's size.
-
- If the optional size argument is present, the file is truncated to
- (at most) that size. The size defaults to the current position.
- The current file position is not changed unless the position
- is beyond the new file size.
-
- If the specified size exceeds the file's current size, the
- file remains unchanged.
- """
- _complain_ifclosed(self.closed)
- if size is None:
- size = self.pos
- elif size < 0:
- raise IOError(EINVAL, "Negative size not allowed")
- elif size < self.pos:
- self.pos = size
- self.buf = self.getvalue()[:size]
- self.len = size
-
- def write(self, s):
- """Write a string to the file.
-
- There is no return value.
- """
- _complain_ifclosed(self.closed)
- if not s: return
- # Force s to be a string or unicode
- if not isinstance(s, basestring):
- s = str(s)
- spos = self.pos
- slen = self.len
- if spos == slen:
- self.buflist.append(s)
- self.len = self.pos = spos + len(s)
- return
- if spos > slen:
- self.buflist.append('\0'*(spos - slen))
- slen = spos
- newpos = spos + len(s)
- if spos < slen:
- if self.buflist:
- self.buf += ''.join(self.buflist)
- self.buflist = [self.buf[:spos], s, self.buf[newpos:]]
- self.buf = ''
- if newpos > slen:
- slen = newpos
- else:
- self.buflist.append(s)
- slen = newpos
- self.len = slen
- self.pos = newpos
-
- def writelines(self, iterable):
- """Write a sequence of strings to the file. The sequence can be any
- iterable object producing strings, typically a list of strings. There
- is no return value.
-
- (The name is intended to match readlines(); writelines() does not add
- line separators.)
- """
- write = self.write
- for line in iterable:
- write(line)
-
- def flush(self):
- """Flush the internal buffer
- """
- _complain_ifclosed(self.closed)
-
- def getvalue(self):
- """
- Retrieve the entire contents of the "file" at any time before
- the StringIO object's close() method is called.
-
- The StringIO object can accept either Unicode or 8-bit strings,
- but mixing the two may take some care. If both are used, 8-bit
- strings that cannot be interpreted as 7-bit ASCII (that use the
- 8th bit) will cause a UnicodeError to be raised when getvalue()
- is called.
- """
- _complain_ifclosed(self.closed)
- if self.buflist:
- self.buf += ''.join(self.buflist)
- self.buflist = []
- return self.buf
-
-
-# A little test suite
-
-def test():
- import sys
- if sys.argv[1:]:
- file = sys.argv[1]
- else:
- file = '/etc/passwd'
- lines = open(file, 'r').readlines()
- text = open(file, 'r').read()
- f = StringIO()
- for line in lines[:-2]:
- f.write(line)
- f.writelines(lines[-2:])
- if f.getvalue() != text:
- raise RuntimeError, 'write failed'
- length = f.tell()
- print 'File length =', length
- f.seek(len(lines[0]))
- f.write(lines[1])
- f.seek(0)
- print 'First line =', repr(f.readline())
- print 'Position =', f.tell()
- line = f.readline()
- print 'Second line =', repr(line)
- f.seek(-len(line), 1)
- line2 = f.read(len(line))
- if line != line2:
- raise RuntimeError, 'bad result after seek back'
- f.seek(len(line2), 1)
- list = f.readlines()
- line = list[-1]
- f.seek(f.tell() - len(line))
- line2 = f.read()
- if line != line2:
- raise RuntimeError, 'bad result after seek back from EOF'
- print 'Read', len(list), 'more lines'
- print 'File length =', f.tell()
- if f.tell() != length:
- raise RuntimeError, 'bad length'
- f.truncate(length/2)
- f.seek(0, 2)
- print 'Truncated length =', f.tell()
- if f.tell() != length/2:
- raise RuntimeError, 'truncate did not adjust length'
- f.close()
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/UserDict.py b/Lib/UserDict.py
deleted file mode 100644
index bb2218ab6ce..00000000000
--- a/Lib/UserDict.py
+++ /dev/null
@@ -1,180 +0,0 @@
-"""A more or less complete user-defined wrapper around dictionary objects."""
-
-class UserDict:
- def __init__(self, dict=None, **kwargs):
- self.data = {}
- if dict is not None:
- self.update(dict)
- if len(kwargs):
- self.update(kwargs)
- def __repr__(self): return repr(self.data)
- def __cmp__(self, dict):
- if isinstance(dict, UserDict):
- return cmp(self.data, dict.data)
- else:
- return cmp(self.data, dict)
- __hash__ = None # Avoid Py3k warning
- def __len__(self): return len(self.data)
- def __getitem__(self, key):
- if key in self.data:
- return self.data[key]
- if hasattr(self.__class__, "__missing__"):
- return self.__class__.__missing__(self, key)
- raise KeyError(key)
- def __setitem__(self, key, item): self.data[key] = item
- def __delitem__(self, key): del self.data[key]
- def clear(self): self.data.clear()
- def copy(self):
- if self.__class__ is UserDict:
- return UserDict(self.data.copy())
- import copy
- data = self.data
- try:
- self.data = {}
- c = copy.copy(self)
- finally:
- self.data = data
- c.update(self)
- return c
- def keys(self): return self.data.keys()
- def items(self): return self.data.items()
- def iteritems(self): return self.data.iteritems()
- def iterkeys(self): return self.data.iterkeys()
- def itervalues(self): return self.data.itervalues()
- def values(self): return self.data.values()
- def has_key(self, key): return key in self.data
- def update(self, dict=None, **kwargs):
- if dict is None:
- pass
- elif isinstance(dict, UserDict):
- self.data.update(dict.data)
- elif isinstance(dict, type({})) or not hasattr(dict, 'items'):
- self.data.update(dict)
- else:
- for k, v in dict.items():
- self[k] = v
- if len(kwargs):
- self.data.update(kwargs)
- def get(self, key, failobj=None):
- if key not in self:
- return failobj
- return self[key]
- def setdefault(self, key, failobj=None):
- if key not in self:
- self[key] = failobj
- return self[key]
- def pop(self, key, *args):
- return self.data.pop(key, *args)
- def popitem(self):
- return self.data.popitem()
- def __contains__(self, key):
- return key in self.data
- @classmethod
- def fromkeys(cls, iterable, value=None):
- d = cls()
- for key in iterable:
- d[key] = value
- return d
-
-class IterableUserDict(UserDict):
- def __iter__(self):
- return iter(self.data)
-
-import _abcoll
-_abcoll.MutableMapping.register(IterableUserDict)
-
-
-class DictMixin:
- # Mixin defining all dictionary methods for classes that already have
- # a minimum dictionary interface including getitem, setitem, delitem,
- # and keys. Without knowledge of the subclass constructor, the mixin
- # does not define __init__() or copy(). In addition to the four base
- # methods, progressively more efficiency comes with defining
- # __contains__(), __iter__(), and iteritems().
-
- # second level definitions support higher levels
- def __iter__(self):
- for k in self.keys():
- yield k
- def has_key(self, key):
- try:
- self[key]
- except KeyError:
- return False
- return True
- def __contains__(self, key):
- return self.has_key(key)
-
- # third level takes advantage of second level definitions
- def iteritems(self):
- for k in self:
- yield (k, self[k])
- def iterkeys(self):
- return self.__iter__()
-
- # fourth level uses definitions from lower levels
- def itervalues(self):
- for _, v in self.iteritems():
- yield v
- def values(self):
- return [v for _, v in self.iteritems()]
- def items(self):
- return list(self.iteritems())
- def clear(self):
- for key in self.keys():
- del self[key]
- def setdefault(self, key, default=None):
- try:
- return self[key]
- except KeyError:
- self[key] = default
- return default
- def pop(self, key, *args):
- if len(args) > 1:
- raise TypeError, "pop expected at most 2 arguments, got "\
- + repr(1 + len(args))
- try:
- value = self[key]
- except KeyError:
- if args:
- return args[0]
- raise
- del self[key]
- return value
- def popitem(self):
- try:
- k, v = self.iteritems().next()
- except StopIteration:
- raise KeyError, 'container is empty'
- del self[k]
- return (k, v)
- def update(self, other=None, **kwargs):
- # Make progressively weaker assumptions about "other"
- if other is None:
- pass
- elif hasattr(other, 'iteritems'): # iteritems saves memory and lookups
- for k, v in other.iteritems():
- self[k] = v
- elif hasattr(other, 'keys'):
- for k in other.keys():
- self[k] = other[k]
- else:
- for k, v in other:
- self[k] = v
- if kwargs:
- self.update(kwargs)
- def get(self, key, default=None):
- try:
- return self[key]
- except KeyError:
- return default
- def __repr__(self):
- return repr(dict(self.iteritems()))
- def __cmp__(self, other):
- if other is None:
- return 1
- if isinstance(other, DictMixin):
- other = dict(other.iteritems())
- return cmp(dict(self.iteritems()), other)
- def __len__(self):
- return len(self.keys())
diff --git a/Lib/UserList.py b/Lib/UserList.py
deleted file mode 100644
index b4459857079..00000000000
--- a/Lib/UserList.py
+++ /dev/null
@@ -1,88 +0,0 @@
-"""A more or less complete user-defined wrapper around list objects."""
-
-import collections
-
-class UserList(collections.MutableSequence):
- def __init__(self, initlist=None):
- self.data = []
- if initlist is not None:
- # XXX should this accept an arbitrary sequence?
- if type(initlist) == type(self.data):
- self.data[:] = initlist
- elif isinstance(initlist, UserList):
- self.data[:] = initlist.data[:]
- else:
- self.data = list(initlist)
- def __repr__(self): return repr(self.data)
- def __lt__(self, other): return self.data < self.__cast(other)
- def __le__(self, other): return self.data <= self.__cast(other)
- def __eq__(self, other): return self.data == self.__cast(other)
- def __ne__(self, other): return self.data != self.__cast(other)
- def __gt__(self, other): return self.data > self.__cast(other)
- def __ge__(self, other): return self.data >= self.__cast(other)
- def __cast(self, other):
- if isinstance(other, UserList): return other.data
- else: return other
- def __cmp__(self, other):
- return cmp(self.data, self.__cast(other))
- __hash__ = None # Mutable sequence, so not hashable
- def __contains__(self, item): return item in self.data
- def __len__(self): return len(self.data)
- def __getitem__(self, i): return self.data[i]
- def __setitem__(self, i, item): self.data[i] = item
- def __delitem__(self, i): del self.data[i]
- def __getslice__(self, i, j):
- i = max(i, 0); j = max(j, 0)
- return self.__class__(self.data[i:j])
- def __setslice__(self, i, j, other):
- i = max(i, 0); j = max(j, 0)
- if isinstance(other, UserList):
- self.data[i:j] = other.data
- elif isinstance(other, type(self.data)):
- self.data[i:j] = other
- else:
- self.data[i:j] = list(other)
- def __delslice__(self, i, j):
- i = max(i, 0); j = max(j, 0)
- del self.data[i:j]
- def __add__(self, other):
- if isinstance(other, UserList):
- return self.__class__(self.data + other.data)
- elif isinstance(other, type(self.data)):
- return self.__class__(self.data + other)
- else:
- return self.__class__(self.data + list(other))
- def __radd__(self, other):
- if isinstance(other, UserList):
- return self.__class__(other.data + self.data)
- elif isinstance(other, type(self.data)):
- return self.__class__(other + self.data)
- else:
- return self.__class__(list(other) + self.data)
- def __iadd__(self, other):
- if isinstance(other, UserList):
- self.data += other.data
- elif isinstance(other, type(self.data)):
- self.data += other
- else:
- self.data += list(other)
- return self
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
- def __imul__(self, n):
- self.data *= n
- return self
- def append(self, item): self.data.append(item)
- def insert(self, i, item): self.data.insert(i, item)
- def pop(self, i=-1): return self.data.pop(i)
- def remove(self, item): self.data.remove(item)
- def count(self, item): return self.data.count(item)
- def index(self, item, *args): return self.data.index(item, *args)
- def reverse(self): self.data.reverse()
- def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
- def extend(self, other):
- if isinstance(other, UserList):
- self.data.extend(other.data)
- else:
- self.data.extend(other)
diff --git a/Lib/UserString.py b/Lib/UserString.py
deleted file mode 100755
index 726b3f7d3c8..00000000000
--- a/Lib/UserString.py
+++ /dev/null
@@ -1,228 +0,0 @@
-#!/usr/bin/env python
-## vim:ts=4:et:nowrap
-"""A user-defined wrapper around string objects
-
-Note: string objects have grown methods in Python 1.6
-This module requires Python 1.6 or later.
-"""
-import sys
-import collections
-
-__all__ = ["UserString","MutableString"]
-
-class UserString(collections.Sequence):
- def __init__(self, seq):
- if isinstance(seq, basestring):
- self.data = seq
- elif isinstance(seq, UserString):
- self.data = seq.data[:]
- else:
- self.data = str(seq)
- def __str__(self): return str(self.data)
- def __repr__(self): return repr(self.data)
- def __int__(self): return int(self.data)
- def __long__(self): return long(self.data)
- def __float__(self): return float(self.data)
- def __complex__(self): return complex(self.data)
- def __hash__(self): return hash(self.data)
-
- def __cmp__(self, string):
- if isinstance(string, UserString):
- return cmp(self.data, string.data)
- else:
- return cmp(self.data, string)
- def __contains__(self, char):
- return char in self.data
-
- def __len__(self): return len(self.data)
- def __getitem__(self, index): return self.__class__(self.data[index])
- def __getslice__(self, start, end):
- start = max(start, 0); end = max(end, 0)
- return self.__class__(self.data[start:end])
-
- def __add__(self, other):
- if isinstance(other, UserString):
- return self.__class__(self.data + other.data)
- elif isinstance(other, basestring):
- return self.__class__(self.data + other)
- else:
- return self.__class__(self.data + str(other))
- def __radd__(self, other):
- if isinstance(other, basestring):
- return self.__class__(other + self.data)
- else:
- return self.__class__(str(other) + self.data)
- def __mul__(self, n):
- return self.__class__(self.data*n)
- __rmul__ = __mul__
- def __mod__(self, args):
- return self.__class__(self.data % args)
-
- # the following methods are defined in alphabetical order:
- def capitalize(self): return self.__class__(self.data.capitalize())
- def center(self, width, *args):
- return self.__class__(self.data.center(width, *args))
- def count(self, sub, start=0, end=sys.maxint):
- return self.data.count(sub, start, end)
- def decode(self, encoding=None, errors=None): # XXX improve this?
- if encoding:
- if errors:
- return self.__class__(self.data.decode(encoding, errors))
- else:
- return self.__class__(self.data.decode(encoding))
- else:
- return self.__class__(self.data.decode())
- def encode(self, encoding=None, errors=None): # XXX improve this?
- if encoding:
- if errors:
- return self.__class__(self.data.encode(encoding, errors))
- else:
- return self.__class__(self.data.encode(encoding))
- else:
- return self.__class__(self.data.encode())
- def endswith(self, suffix, start=0, end=sys.maxint):
- return self.data.endswith(suffix, start, end)
- def expandtabs(self, tabsize=8):
- return self.__class__(self.data.expandtabs(tabsize))
- def find(self, sub, start=0, end=sys.maxint):
- return self.data.find(sub, start, end)
- def index(self, sub, start=0, end=sys.maxint):
- return self.data.index(sub, start, end)
- def isalpha(self): return self.data.isalpha()
- def isalnum(self): return self.data.isalnum()
- def isdecimal(self): return self.data.isdecimal()
- def isdigit(self): return self.data.isdigit()
- def islower(self): return self.data.islower()
- def isnumeric(self): return self.data.isnumeric()
- def isspace(self): return self.data.isspace()
- def istitle(self): return self.data.istitle()
- def isupper(self): return self.data.isupper()
- def join(self, seq): return self.data.join(seq)
- def ljust(self, width, *args):
- return self.__class__(self.data.ljust(width, *args))
- def lower(self): return self.__class__(self.data.lower())
- def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars))
- def partition(self, sep):
- return self.data.partition(sep)
- def replace(self, old, new, maxsplit=-1):
- return self.__class__(self.data.replace(old, new, maxsplit))
- def rfind(self, sub, start=0, end=sys.maxint):
- return self.data.rfind(sub, start, end)
- def rindex(self, sub, start=0, end=sys.maxint):
- return self.data.rindex(sub, start, end)
- def rjust(self, width, *args):
- return self.__class__(self.data.rjust(width, *args))
- def rpartition(self, sep):
- return self.data.rpartition(sep)
- def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars))
- def split(self, sep=None, maxsplit=-1):
- return self.data.split(sep, maxsplit)
- def rsplit(self, sep=None, maxsplit=-1):
- return self.data.rsplit(sep, maxsplit)
- def splitlines(self, keepends=0): return self.data.splitlines(keepends)
- def startswith(self, prefix, start=0, end=sys.maxint):
- return self.data.startswith(prefix, start, end)
- def strip(self, chars=None): return self.__class__(self.data.strip(chars))
- def swapcase(self): return self.__class__(self.data.swapcase())
- def title(self): return self.__class__(self.data.title())
- def translate(self, *args):
- return self.__class__(self.data.translate(*args))
- def upper(self): return self.__class__(self.data.upper())
- def zfill(self, width): return self.__class__(self.data.zfill(width))
-
-class MutableString(UserString, collections.MutableSequence):
- """mutable string objects
-
- Python strings are immutable objects. This has the advantage, that
- strings may be used as dictionary keys. If this property isn't needed
- and you insist on changing string values in place instead, you may cheat
- and use MutableString.
-
- But the purpose of this class is an educational one: to prevent
- people from inventing their own mutable string class derived
- from UserString and than forget thereby to remove (override) the
- __hash__ method inherited from UserString. This would lead to
- errors that would be very hard to track down.
-
- A faster and better solution is to rewrite your program using lists."""
- def __init__(self, string=""):
- from warnings import warnpy3k
- warnpy3k('the class UserString.MutableString has been removed in '
- 'Python 3.0', stacklevel=2)
- self.data = string
-
- # We inherit object.__hash__, so we must deny this explicitly
- __hash__ = None
-
- def __setitem__(self, index, sub):
- if isinstance(index, slice):
- if isinstance(sub, UserString):
- sub = sub.data
- elif not isinstance(sub, basestring):
- sub = str(sub)
- start, stop, step = index.indices(len(self.data))
- if step == -1:
- start, stop = stop+1, start+1
- sub = sub[::-1]
- elif step != 1:
- # XXX(twouters): I guess we should be reimplementing
- # the extended slice assignment/deletion algorithm here...
- raise TypeError, "invalid step in slicing assignment"
- start = min(start, stop)
- self.data = self.data[:start] + sub + self.data[stop:]
- else:
- if index < 0:
- index += len(self.data)
- if index < 0 or index >= len(self.data): raise IndexError
- self.data = self.data[:index] + sub + self.data[index+1:]
- def __delitem__(self, index):
- if isinstance(index, slice):
- start, stop, step = index.indices(len(self.data))
- if step == -1:
- start, stop = stop+1, start+1
- elif step != 1:
- # XXX(twouters): see same block in __setitem__
- raise TypeError, "invalid step in slicing deletion"
- start = min(start, stop)
- self.data = self.data[:start] + self.data[stop:]
- else:
- if index < 0:
- index += len(self.data)
- if index < 0 or index >= len(self.data): raise IndexError
- self.data = self.data[:index] + self.data[index+1:]
- def __setslice__(self, start, end, sub):
- start = max(start, 0); end = max(end, 0)
- if isinstance(sub, UserString):
- self.data = self.data[:start]+sub.data+self.data[end:]
- elif isinstance(sub, basestring):
- self.data = self.data[:start]+sub+self.data[end:]
- else:
- self.data = self.data[:start]+str(sub)+self.data[end:]
- def __delslice__(self, start, end):
- start = max(start, 0); end = max(end, 0)
- self.data = self.data[:start] + self.data[end:]
- def immutable(self):
- return UserString(self.data)
- def __iadd__(self, other):
- if isinstance(other, UserString):
- self.data += other.data
- elif isinstance(other, basestring):
- self.data += other
- else:
- self.data += str(other)
- return self
- def __imul__(self, n):
- self.data *= n
- return self
- def insert(self, index, value):
- self[index:index] = value
-
-if __name__ == "__main__":
- # execute the regression test to stdout, if called as a script:
- import os
- called_in_dir, called_as = os.path.split(sys.argv[0])
- called_as, py = os.path.splitext(called_as)
- if '-q' in sys.argv:
- from test import test_support
- test_support.verbose = 0
- __import__('test.test_' + called_as.lower())
diff --git a/Lib/_LWPCookieJar.py b/Lib/_LWPCookieJar.py
deleted file mode 100644
index 90cc633d531..00000000000
--- a/Lib/_LWPCookieJar.py
+++ /dev/null
@@ -1,170 +0,0 @@
-"""Load / save to libwww-perl (LWP) format files.
-
-Actually, the format is slightly extended from that used by LWP's
-(libwww-perl's) HTTP::Cookies, to avoid losing some RFC 2965 information
-not recorded by LWP.
-
-It uses the version string "2.0", though really there isn't an LWP Cookies
-2.0 format. This indicates that there is extra information in here
-(domain_dot and # port_spec) while still being compatible with
-libwww-perl, I hope.
-
-"""
-
-import time, re
-from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError,
- Cookie, MISSING_FILENAME_TEXT,
- join_header_words, split_header_words,
- iso2time, time2isoz)
-
-def lwp_cookie_str(cookie):
- """Return string representation of Cookie in an the LWP cookie file format.
-
- Actually, the format is extended a bit -- see module docstring.
-
- """
- h = [(cookie.name, cookie.value),
- ("path", cookie.path),
- ("domain", cookie.domain)]
- if cookie.port is not None: h.append(("port", cookie.port))
- if cookie.path_specified: h.append(("path_spec", None))
- if cookie.port_specified: h.append(("port_spec", None))
- if cookie.domain_initial_dot: h.append(("domain_dot", None))
- if cookie.secure: h.append(("secure", None))
- if cookie.expires: h.append(("expires",
- time2isoz(float(cookie.expires))))
- if cookie.discard: h.append(("discard", None))
- if cookie.comment: h.append(("comment", cookie.comment))
- if cookie.comment_url: h.append(("commenturl", cookie.comment_url))
-
- keys = cookie._rest.keys()
- keys.sort()
- for k in keys:
- h.append((k, str(cookie._rest[k])))
-
- h.append(("version", str(cookie.version)))
-
- return join_header_words([h])
-
-class LWPCookieJar(FileCookieJar):
- """
- The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
- "Set-Cookie3" is the format used by the libwww-perl libary, not known
- to be compatible with any browser, but which is easy to read and
- doesn't lose information about RFC 2965 cookies.
-
- Additional methods
-
- as_lwp_str(ignore_discard=True, ignore_expired=True)
-
- """
-
- def as_lwp_str(self, ignore_discard=True, ignore_expires=True):
- """Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
-
- ignore_discard and ignore_expires: see docstring for FileCookieJar.save
-
- """
- now = time.time()
- r = []
- for cookie in self:
- if not ignore_discard and cookie.discard:
- continue
- if not ignore_expires and cookie.is_expired(now):
- continue
- r.append("Set-Cookie3: %s" % lwp_cookie_str(cookie))
- return "\n".join(r+[""])
-
- def save(self, filename=None, ignore_discard=False, ignore_expires=False):
- if filename is None:
- if self.filename is not None: filename = self.filename
- else: raise ValueError(MISSING_FILENAME_TEXT)
-
- f = open(filename, "w")
- try:
- # There really isn't an LWP Cookies 2.0 format, but this indicates
- # that there is extra information in here (domain_dot and
- # port_spec) while still being compatible with libwww-perl, I hope.
- f.write("#LWP-Cookies-2.0\n")
- f.write(self.as_lwp_str(ignore_discard, ignore_expires))
- finally:
- f.close()
-
- def _really_load(self, f, filename, ignore_discard, ignore_expires):
- magic = f.readline()
- if not re.search(self.magic_re, magic):
- msg = ("%r does not look like a Set-Cookie3 (LWP) format "
- "file" % filename)
- raise LoadError(msg)
-
- now = time.time()
-
- header = "Set-Cookie3:"
- boolean_attrs = ("port_spec", "path_spec", "domain_dot",
- "secure", "discard")
- value_attrs = ("version",
- "port", "path", "domain",
- "expires",
- "comment", "commenturl")
-
- try:
- while 1:
- line = f.readline()
- if line == "": break
- if not line.startswith(header):
- continue
- line = line[len(header):].strip()
-
- for data in split_header_words([line]):
- name, value = data[0]
- standard = {}
- rest = {}
- for k in boolean_attrs:
- standard[k] = False
- for k, v in data[1:]:
- if k is not None:
- lc = k.lower()
- else:
- lc = None
- # don't lose case distinction for unknown fields
- if (lc in value_attrs) or (lc in boolean_attrs):
- k = lc
- if k in boolean_attrs:
- if v is None: v = True
- standard[k] = v
- elif k in value_attrs:
- standard[k] = v
- else:
- rest[k] = v
-
- h = standard.get
- expires = h("expires")
- discard = h("discard")
- if expires is not None:
- expires = iso2time(expires)
- if expires is None:
- discard = True
- domain = h("domain")
- domain_specified = domain.startswith(".")
- c = Cookie(h("version"), name, value,
- h("port"), h("port_spec"),
- domain, domain_specified, h("domain_dot"),
- h("path"), h("path_spec"),
- h("secure"),
- expires,
- discard,
- h("comment"),
- h("commenturl"),
- rest)
- if not ignore_discard and c.discard:
- continue
- if not ignore_expires and c.is_expired(now):
- continue
- self.set_cookie(c)
-
- except IOError:
- raise
- except Exception:
- _warn_unhandled_exception()
- raise LoadError("invalid Set-Cookie3 format file %r: %r" %
- (filename, line))
diff --git a/Lib/_MozillaCookieJar.py b/Lib/_MozillaCookieJar.py
deleted file mode 100644
index 00e8bcf9819..00000000000
--- a/Lib/_MozillaCookieJar.py
+++ /dev/null
@@ -1,149 +0,0 @@
-"""Mozilla / Netscape cookie loading / saving."""
-
-import re, time
-
-from cookielib import (_warn_unhandled_exception, FileCookieJar, LoadError,
- Cookie, MISSING_FILENAME_TEXT)
-
-class MozillaCookieJar(FileCookieJar):
- """
-
- WARNING: you may want to backup your browser's cookies file if you use
- this class to save cookies. I *think* it works, but there have been
- bugs in the past!
-
- This class differs from CookieJar only in the format it uses to save and
- load cookies to and from a file. This class uses the Mozilla/Netscape
- `cookies.txt' format. lynx uses this file format, too.
-
- Don't expect cookies saved while the browser is running to be noticed by
- the browser (in fact, Mozilla on unix will overwrite your saved cookies if
- you change them on disk while it's running; on Windows, you probably can't
- save at all while the browser is running).
-
- Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
- Netscape cookies on saving.
-
- In particular, the cookie version and port number information is lost,
- together with information about whether or not Path, Port and Discard were
- specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
- domain as set in the HTTP header started with a dot (yes, I'm aware some
- domains in Netscape files start with a dot and some don't -- trust me, you
- really don't want to know any more about this).
-
- Note that though Mozilla and Netscape use the same format, they use
- slightly different headers. The class saves cookies using the Netscape
- header by default (Mozilla can cope with that).
-
- """
- magic_re = "#( Netscape)? HTTP Cookie File"
- header = """\
-# Netscape HTTP Cookie File
-# http://www.netscape.com/newsref/std/cookie_spec.html
-# This is a generated file! Do not edit.
-
-"""
-
- def _really_load(self, f, filename, ignore_discard, ignore_expires):
- now = time.time()
-
- magic = f.readline()
- if not re.search(self.magic_re, magic):
- f.close()
- raise LoadError(
- "%r does not look like a Netscape format cookies file" %
- filename)
-
- try:
- while 1:
- line = f.readline()
- if line == "": break
-
- # last field may be absent, so keep any trailing tab
- if line.endswith("\n"): line = line[:-1]
-
- # skip comments and blank lines XXX what is $ for?
- if (line.strip().startswith(("#", "$")) or
- line.strip() == ""):
- continue
-
- domain, domain_specified, path, secure, expires, name, value = \
- line.split("\t")
- secure = (secure == "TRUE")
- domain_specified = (domain_specified == "TRUE")
- if name == "":
- # cookies.txt regards 'Set-Cookie: foo' as a cookie
- # with no name, whereas cookielib regards it as a
- # cookie with no value.
- name = value
- value = None
-
- initial_dot = domain.startswith(".")
- assert domain_specified == initial_dot
-
- discard = False
- if expires == "":
- expires = None
- discard = True
-
- # assume path_specified is false
- c = Cookie(0, name, value,
- None, False,
- domain, domain_specified, initial_dot,
- path, False,
- secure,
- expires,
- discard,
- None,
- None,
- {})
- if not ignore_discard and c.discard:
- continue
- if not ignore_expires and c.is_expired(now):
- continue
- self.set_cookie(c)
-
- except IOError:
- raise
- except Exception:
- _warn_unhandled_exception()
- raise LoadError("invalid Netscape format cookies file %r: %r" %
- (filename, line))
-
- def save(self, filename=None, ignore_discard=False, ignore_expires=False):
- if filename is None:
- if self.filename is not None: filename = self.filename
- else: raise ValueError(MISSING_FILENAME_TEXT)
-
- f = open(filename, "w")
- try:
- f.write(self.header)
- now = time.time()
- for cookie in self:
- if not ignore_discard and cookie.discard:
- continue
- if not ignore_expires and cookie.is_expired(now):
- continue
- if cookie.secure: secure = "TRUE"
- else: secure = "FALSE"
- if cookie.domain.startswith("."): initial_dot = "TRUE"
- else: initial_dot = "FALSE"
- if cookie.expires is not None:
- expires = str(cookie.expires)
- else:
- expires = ""
- if cookie.value is None:
- # cookies.txt regards 'Set-Cookie: foo' as a cookie
- # with no name, whereas cookielib regards it as a
- # cookie with no value.
- name = ""
- value = cookie.name
- else:
- name = cookie.name
- value = cookie.value
- f.write(
- "\t".join([cookie.domain, initial_dot, cookie.path,
- secure, expires, name, value])+
- "\n")
- finally:
- f.close()
diff --git a/Lib/__future__.py b/Lib/__future__.py
index e0996eb007b..3b2d5ecb92a 100644
--- a/Lib/__future__.py
+++ b/Lib/__future__.py
@@ -55,6 +55,7 @@ all_feature_names = [
"with_statement",
"print_function",
"unicode_literals",
+ "barry_as_FLUFL",
]
__all__ = ["all_feature_names"] + all_feature_names
@@ -70,6 +71,7 @@ CO_FUTURE_ABSOLUTE_IMPORT = 0x4000 # perform absolute imports by default
CO_FUTURE_WITH_STATEMENT = 0x8000 # with statement
CO_FUTURE_PRINT_FUNCTION = 0x10000 # print function
CO_FUTURE_UNICODE_LITERALS = 0x20000 # unicode string literals
+CO_FUTURE_BARRY_AS_BDFL = 0x40000
class _Feature:
def __init__(self, optionalRelease, mandatoryRelease, compiler_flag):
@@ -126,3 +128,7 @@ print_function = _Feature((2, 6, 0, "alpha", 2),
unicode_literals = _Feature((2, 6, 0, "alpha", 2),
(3, 0, 0, "alpha", 0),
CO_FUTURE_UNICODE_LITERALS)
+
+barry_as_FLUFL = _Feature((3, 1, 0, "alpha", 2),
+ (3, 9, 0, "alpha", 0),
+ CO_FUTURE_BARRY_AS_BDFL)
diff --git a/Lib/_abcoll.py b/Lib/_abcoll.py
index e7376e4a56a..5ddcea3a301 100644
--- a/Lib/_abcoll.py
+++ b/Lib/_abcoll.py
@@ -17,20 +17,36 @@ __all__ = ["Hashable", "Iterable", "Iterator",
"Mapping", "MutableMapping",
"MappingView", "KeysView", "ItemsView", "ValuesView",
"Sequence", "MutableSequence",
+ "ByteString",
]
-### ONE-TRICK PONIES ###
-def _hasattr(C, attr):
- try:
- return any(attr in B.__dict__ for B in C.__mro__)
- except AttributeError:
- # Old-style class
- return hasattr(C, attr)
+### collection related types which are not exposed through builtin ###
+## iterators ##
+bytes_iterator = type(iter(b''))
+bytearray_iterator = type(iter(bytearray()))
+#callable_iterator = ???
+dict_keyiterator = type(iter({}.keys()))
+dict_valueiterator = type(iter({}.values()))
+dict_itemiterator = type(iter({}.items()))
+list_iterator = type(iter([]))
+list_reverseiterator = type(iter(reversed([])))
+range_iterator = type(iter(range(0)))
+set_iterator = type(iter(set()))
+str_iterator = type(iter(""))
+tuple_iterator = type(iter(()))
+zip_iterator = type(iter(zip()))
+## views ##
+dict_keys = type({}.keys())
+dict_values = type({}.values())
+dict_items = type({}.items())
+## misc ##
+dict_proxy = type(type.__dict__)
+
+### ONE-TRICK PONIES ###
-class Hashable:
- __metaclass__ = ABCMeta
+class Hashable(metaclass=ABCMeta):
@abstractmethod
def __hash__(self):
@@ -39,21 +55,15 @@ class Hashable:
@classmethod
def __subclasshook__(cls, C):
if cls is Hashable:
- try:
- for B in C.__mro__:
- if "__hash__" in B.__dict__:
- if B.__dict__["__hash__"]:
- return True
- break
- except AttributeError:
- # Old-style class
- if getattr(C, "__hash__", None):
- return True
+ for B in C.__mro__:
+ if "__hash__" in B.__dict__:
+ if B.__dict__["__hash__"]:
+ return True
+ break
return NotImplemented
-class Iterable:
- __metaclass__ = ABCMeta
+class Iterable(metaclass=ABCMeta):
@abstractmethod
def __iter__(self):
@@ -63,17 +73,15 @@ class Iterable:
@classmethod
def __subclasshook__(cls, C):
if cls is Iterable:
- if _hasattr(C, "__iter__"):
+ if any("__iter__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
-Iterable.register(str)
-
class Iterator(Iterable):
@abstractmethod
- def next(self):
+ def __next__(self):
raise StopIteration
def __iter__(self):
@@ -82,13 +90,26 @@ class Iterator(Iterable):
@classmethod
def __subclasshook__(cls, C):
if cls is Iterator:
- if _hasattr(C, "next") and _hasattr(C, "__iter__"):
+ if (any("__next__" in B.__dict__ for B in C.__mro__) and
+ any("__iter__" in B.__dict__ for B in C.__mro__)):
return True
return NotImplemented
-
-class Sized:
- __metaclass__ = ABCMeta
+Iterator.register(bytes_iterator)
+Iterator.register(bytearray_iterator)
+#Iterator.register(callable_iterator)
+Iterator.register(dict_keyiterator)
+Iterator.register(dict_valueiterator)
+Iterator.register(dict_itemiterator)
+Iterator.register(list_iterator)
+Iterator.register(list_reverseiterator)
+Iterator.register(range_iterator)
+Iterator.register(set_iterator)
+Iterator.register(str_iterator)
+Iterator.register(tuple_iterator)
+Iterator.register(zip_iterator)
+
+class Sized(metaclass=ABCMeta):
@abstractmethod
def __len__(self):
@@ -97,13 +118,12 @@ class Sized:
@classmethod
def __subclasshook__(cls, C):
if cls is Sized:
- if _hasattr(C, "__len__"):
+ if any("__len__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
-class Container:
- __metaclass__ = ABCMeta
+class Container(metaclass=ABCMeta):
@abstractmethod
def __contains__(self, x):
@@ -112,13 +132,12 @@ class Container:
@classmethod
def __subclasshook__(cls, C):
if cls is Container:
- if _hasattr(C, "__contains__"):
+ if any("__contains__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
-class Callable:
- __metaclass__ = ABCMeta
+class Callable(metaclass=ABCMeta):
@abstractmethod
def __call__(self, *args, **kwds):
@@ -127,7 +146,7 @@ class Callable:
@classmethod
def __subclasshook__(cls, C):
if cls is Callable:
- if _hasattr(C, "__call__"):
+ if any("__call__" in B.__dict__ for B in C.__mro__):
return True
return NotImplemented
@@ -136,6 +155,7 @@ class Callable:
class Set(Sized, Iterable, Container):
+
"""A set is a finite, iterable container.
This class provides concrete generic implementations of all
@@ -164,12 +184,12 @@ class Set(Sized, Iterable, Container):
def __gt__(self, other):
if not isinstance(other, Set):
return NotImplemented
- return other < self
+ return other.__lt__(self)
def __ge__(self, other):
if not isinstance(other, Set):
return NotImplemented
- return other <= self
+ return other.__le__(self)
def __eq__(self, other):
if not isinstance(other, Set):
@@ -220,9 +240,6 @@ class Set(Sized, Iterable, Container):
other = self._from_iterable(other)
return (self - other) | (other - self)
- # Sets are not hashable by default, but subclasses can change this
- __hash__ = None
-
def _hash(self):
"""Compute the hash value of a set.
@@ -238,7 +255,7 @@ class Set(Sized, Iterable, Container):
freedom for __eq__ or __hash__. We match the algorithm used
by the built-in frozenset type.
"""
- MAX = sys.maxint
+ MAX = sys.maxsize
MASK = 2 * MAX + 1
n = len(self)
h = 1927868237 * (n + 1)
@@ -351,28 +368,14 @@ class Mapping(Sized, Iterable, Container):
else:
return True
- def iterkeys(self):
- return iter(self)
-
- def itervalues(self):
- for key in self:
- yield self[key]
-
- def iteritems(self):
- for key in self:
- yield (key, self[key])
-
def keys(self):
- return list(self)
+ return KeysView(self)
def items(self):
- return [(key, self[key]) for key in self]
+ return ItemsView(self)
def values(self):
- return [self[key] for key in self]
-
- # Mappings are not hashable by default, but subclasses can change this
- __hash__ = None
+ return ValuesView(self)
def __eq__(self, other):
if not isinstance(other, Mapping):
@@ -382,6 +385,7 @@ class Mapping(Sized, Iterable, Container):
def __ne__(self, other):
return not (self == other)
+
class MappingView(Sized):
def __init__(self, mapping):
@@ -407,6 +411,8 @@ class KeysView(MappingView, Set):
for key in self._mapping:
yield key
+KeysView.register(dict_keys)
+
class ItemsView(MappingView, Set):
@@ -427,6 +433,8 @@ class ItemsView(MappingView, Set):
for key in self._mapping:
yield (key, self._mapping[key])
+ItemsView.register(dict_items)
+
class ValuesView(MappingView):
@@ -440,6 +448,8 @@ class ValuesView(MappingView):
for key in self._mapping:
yield self._mapping[key]
+ValuesView.register(dict_values)
+
class MutableMapping(Mapping):
@@ -515,6 +525,7 @@ MutableMapping.register(dict)
class Sequence(Sized, Iterable, Container):
+
"""All the operations on a read-only sequence.
Concrete subclasses must override __new__ or __init__,
@@ -555,9 +566,19 @@ class Sequence(Sized, Iterable, Container):
return sum(1 for v in self if v == value)
Sequence.register(tuple)
-Sequence.register(basestring)
-Sequence.register(buffer)
-Sequence.register(xrange)
+Sequence.register(str)
+Sequence.register(range)
+
+
+class ByteString(Sequence):
+
+ """This unifies bytes and bytearray.
+
+ XXX Should add all their methods.
+ """
+
+ByteString.register(bytes)
+ByteString.register(bytearray)
class MutableSequence(Sequence):
@@ -599,3 +620,4 @@ class MutableSequence(Sequence):
return self
MutableSequence.register(list)
+MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
diff --git a/Lib/_compat_pickle.py b/Lib/_compat_pickle.py
new file mode 100644
index 00000000000..700c80cd574
--- /dev/null
+++ b/Lib/_compat_pickle.py
@@ -0,0 +1,81 @@
+# This module is used to map the old Python 2 names to the new names used in
+# Python 3 for the pickle module. This needed to make pickle streams
+# generated with Python 2 loadable by Python 3.
+
+# This is a copy of lib2to3.fixes.fix_imports.MAPPING. We cannot import
+# lib2to3 and use the mapping defined there, because lib2to3 uses pickle.
+# Thus, this could cause the module to be imported recursively.
+IMPORT_MAPPING = {
+ 'StringIO': 'io',
+ 'cStringIO': 'io',
+ 'cPickle': 'pickle',
+ '__builtin__' : 'builtins',
+ 'copy_reg': 'copyreg',
+ 'Queue': 'queue',
+ 'SocketServer': 'socketserver',
+ 'ConfigParser': 'configparser',
+ 'repr': 'reprlib',
+ 'FileDialog': 'tkinter.filedialog',
+ 'tkFileDialog': 'tkinter.filedialog',
+ 'SimpleDialog': 'tkinter.simpledialog',
+ 'tkSimpleDialog': 'tkinter.simpledialog',
+ 'tkColorChooser': 'tkinter.colorchooser',
+ 'tkCommonDialog': 'tkinter.commondialog',
+ 'Dialog': 'tkinter.dialog',
+ 'Tkdnd': 'tkinter.dnd',
+ 'tkFont': 'tkinter.font',
+ 'tkMessageBox': 'tkinter.messagebox',
+ 'ScrolledText': 'tkinter.scrolledtext',
+ 'Tkconstants': 'tkinter.constants',
+ 'Tix': 'tkinter.tix',
+ 'ttk': 'tkinter.ttk',
+ 'Tkinter': 'tkinter',
+ 'markupbase': '_markupbase',
+ '_winreg': 'winreg',
+ 'thread': '_thread',
+ 'dummy_thread': '_dummy_thread',
+ 'dbhash': 'dbm.bsd',
+ 'dumbdbm': 'dbm.dumb',
+ 'dbm': 'dbm.ndbm',
+ 'gdbm': 'dbm.gnu',
+ 'xmlrpclib': 'xmlrpc.client',
+ 'DocXMLRPCServer': 'xmlrpc.server',
+ 'SimpleXMLRPCServer': 'xmlrpc.server',
+ 'httplib': 'http.client',
+ 'htmlentitydefs' : 'html.entities',
+ 'HTMLParser' : 'html.parser',
+ 'Cookie': 'http.cookies',
+ 'cookielib': 'http.cookiejar',
+ 'BaseHTTPServer': 'http.server',
+ 'SimpleHTTPServer': 'http.server',
+ 'CGIHTTPServer': 'http.server',
+ 'test.test_support': 'test.support',
+ 'commands': 'subprocess',
+ 'UserString' : 'collections',
+ 'UserList' : 'collections',
+ 'urlparse' : 'urllib.parse',
+ 'robotparser' : 'urllib.robotparser',
+ 'whichdb': 'dbm',
+ 'anydbm': 'dbm'
+}
+
+
+# This contains rename rules that are easy to handle. We ignore the more
+# complex stuff (e.g. mapping the names in the urllib and types modules).
+# These rules should be run before import names are fixed.
+NAME_MAPPING = {
+ ('__builtin__', 'xrange'): ('builtins', 'range'),
+ ('__builtin__', 'reduce'): ('functools', 'reduce'),
+ ('__builtin__', 'intern'): ('sys', 'intern'),
+ ('__builtin__', 'unichr'): ('builtins', 'chr'),
+ ('__builtin__', 'basestring'): ('builtins', 'str'),
+ ('__builtin__', 'long'): ('builtins', 'int'),
+ ('itertools', 'izip'): ('builtins', 'zip'),
+ ('itertools', 'imap'): ('builtins', 'map'),
+ ('itertools', 'ifilter'): ('builtins', 'filter'),
+ ('itertools', 'ifilterfalse'): ('itertools', 'filterfalse'),
+}
+
+# Same, but for 3.x to 2.x
+REVERSE_IMPORT_MAPPING = dict((v, k) for (k, v) in IMPORT_MAPPING.items())
+REVERSE_NAME_MAPPING = dict((v, k) for (k, v) in NAME_MAPPING.items())
diff --git a/Lib/dummy_thread.py b/Lib/_dummy_thread.py
index 198dc49dba3..ed50520ab32 100644
--- a/Lib/dummy_thread.py
+++ b/Lib/_dummy_thread.py
@@ -6,9 +6,9 @@ not need to be rewritten for when the thread module is not present.
Suggested usage is::
try:
- import thread
+ import _thread
except ImportError:
- import dummy_thread as thread
+ import _dummy_thread as _thread
"""
# Exports only things specified by thread documentation;
@@ -16,20 +16,26 @@ Suggested usage is::
__all__ = ['error', 'start_new_thread', 'exit', 'get_ident', 'allocate_lock',
'interrupt_main', 'LockType']
-import traceback as _traceback
+# A dummy value
+TIMEOUT_MAX = 2**31
+
+# NOTE: this module can be imported early in the extension building process,
+# and so top level imports of other modules should be avoided. Instead, all
+# imports are done when needed on a function-by-function basis. Since threads
+# are disabled, the import lock should not be an issue anyway (??).
class error(Exception):
- """Dummy implementation of thread.error."""
+ """Dummy implementation of _thread.error."""
def __init__(self, *args):
self.args = args
def start_new_thread(function, args, kwargs={}):
- """Dummy implementation of thread.start_new_thread().
+ """Dummy implementation of _thread.start_new_thread().
Compatibility is maintained by making sure that ``args`` is a
tuple and ``kwargs`` is a dictionary. If an exception is raised
- and it is SystemExit (which can be done by thread.exit()) it is
+ and it is SystemExit (which can be done by _thread.exit()) it is
caught and nothing is done; all other exceptions are printed out
by using traceback.print_exc().
@@ -48,7 +54,8 @@ def start_new_thread(function, args, kwargs={}):
except SystemExit:
pass
except:
- _traceback.print_exc()
+ import traceback
+ traceback.print_exc()
_main = True
global _interrupt
if _interrupt:
@@ -56,34 +63,34 @@ def start_new_thread(function, args, kwargs={}):
raise KeyboardInterrupt
def exit():
- """Dummy implementation of thread.exit()."""
+ """Dummy implementation of _thread.exit()."""
raise SystemExit
def get_ident():
- """Dummy implementation of thread.get_ident().
+ """Dummy implementation of _thread.get_ident().
- Since this module should only be used when threadmodule is not
+ Since this module should only be used when _threadmodule is not
available, it is safe to assume that the current process is the
only thread. Thus a constant can be safely returned.
"""
return -1
def allocate_lock():
- """Dummy implementation of thread.allocate_lock()."""
+ """Dummy implementation of _thread.allocate_lock()."""
return LockType()
def stack_size(size=None):
- """Dummy implementation of thread.stack_size()."""
+ """Dummy implementation of _thread.stack_size()."""
if size is not None:
raise error("setting thread stack size not supported")
return 0
class LockType(object):
- """Class implementing dummy implementation of thread.LockType.
+ """Class implementing dummy implementation of _thread.LockType.
Compatibility is maintained by maintaining self.locked_status
which is a boolean that stores the state of the lock. Pickling of
- the lock, though, should not be done since if the thread module is
+ the lock, though, should not be done since if the _thread module is
then used with an unpickled ``lock()`` from here problems could
occur from this class not having atomic methods.
@@ -92,7 +99,7 @@ class LockType(object):
def __init__(self):
self.locked_status = False
- def acquire(self, waitflag=None):
+ def acquire(self, waitflag=None, timeout=-1):
"""Dummy implementation of acquire().
For blocking calls, self.locked_status is automatically set to
@@ -111,6 +118,9 @@ class LockType(object):
self.locked_status = True
return True
else:
+ if timeout > 0:
+ import time
+ time.sleep(timeout)
return False
__enter__ = acquire
diff --git a/Lib/markupbase.py b/Lib/_markupbase.py
index ddeb9835b80..2af5f1c23b6 100644
--- a/Lib/markupbase.py
+++ b/Lib/_markupbase.py
@@ -1,8 +1,7 @@
"""Shared support for scanning document type declarations in HTML and XHTML.
-This module is used as a foundation for the HTMLParser and sgmllib
-modules (indirectly, for htmllib as well). It has no documented
-public API and should not be used directly.
+This module is used as a foundation for the html.parser module. It has no
+documented public API and should not be used directly.
"""
@@ -28,7 +27,7 @@ class ParserBase:
def __init__(self):
if self.__class__ is ParserBase:
raise RuntimeError(
- "markupbase.ParserBase must be subclassed")
+ "_markupbase.ParserBase must be subclassed")
def error(self, message):
raise NotImplementedError(
@@ -127,7 +126,7 @@ class ParserBase:
# this could be handled in a separate doctype parser
if decltype == "doctype":
j = self._parse_doctype_subset(j + 1, i)
- elif decltype in ("attlist", "linktype", "link", "element"):
+ elif decltype in {"attlist", "linktype", "link", "element"}:
# must tolerate []'d groups in a content model in an element declaration
# also in data attribute specifications of attlist declaration
# also link type declaration subsets in linktype declarations
@@ -150,10 +149,10 @@ class ParserBase:
sectName, j = self._scan_name( i+3, i )
if j < 0:
return j
- if sectName in ("temp", "cdata", "ignore", "include", "rcdata"):
+ if sectName in {"temp", "cdata", "ignore", "include", "rcdata"}:
# look for standard ]]> ending
match= _markedsectionclose.search(rawdata, i+3)
- elif sectName in ("if", "else", "endif"):
+ elif sectName in {"if", "else", "endif"}:
# look for MS Office ]> ending
match= _msmarkedsectionclose.search(rawdata, i+3)
else:
@@ -208,7 +207,7 @@ class ParserBase:
name, j = self._scan_name(j + 2, declstartpos)
if j == -1:
return -1
- if name not in ("attlist", "element", "entity", "notation"):
+ if name not in {"attlist", "element", "entity", "notation"}:
self.updatepos(declstartpos, j + 2)
self.error(
"unknown declaration %r in internal subset" % name)
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index ac7832e1bda..2d376d83002 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -2,25 +2,21 @@
Python implementation of the io module.
"""
-from __future__ import (print_function, unicode_literals)
-
import os
import abc
import codecs
import warnings
import errno
-# Import thread instead of threading to reduce startup cost
+# Import _thread instead of threading to reduce startup cost
try:
- from thread import allocate_lock as Lock
+ from _thread import allocate_lock as Lock
except ImportError:
- from dummy_thread import allocate_lock as Lock
+ from _dummy_thread import allocate_lock as Lock
import io
from io import (__all__, SEEK_SET, SEEK_CUR, SEEK_END)
from errno import EINTR
-__metaclass__ = type
-
# open() uses st_blksize whenever we can
DEFAULT_BUFFER_SIZE = 8 * 1024 # bytes
@@ -34,14 +30,13 @@ class BlockingIOError(IOError):
"""Exception raised when I/O would block on a non-blocking I/O stream."""
def __init__(self, errno, strerror, characters_written=0):
- super(IOError, self).__init__(errno, strerror)
- if not isinstance(characters_written, (int, long)):
+ super().__init__(errno, strerror)
+ if not isinstance(characters_written, int):
raise TypeError("characters_written must be a integer")
self.characters_written = characters_written
-def open(file, mode="r", buffering=-1,
- encoding=None, errors=None,
+def open(file, mode="r", buffering=-1, encoding=None, errors=None,
newline=None, closefd=True):
r"""Open file and return a stream. Raise IOError upon failure.
@@ -102,7 +97,7 @@ def open(file, mode="r", buffering=-1,
use line buffering. Other text files use the policy described above
for binary files.
- encoding is the name of the encoding used to decode or encode the
+ encoding is the str name of the encoding used to decode or encode the
file. This should only be used in text mode. The default encoding is
platform dependent, but any encoding supported by Python can be
passed. See the codecs module for the list of supported encodings.
@@ -115,9 +110,9 @@ def open(file, mode="r", buffering=-1,
See the documentation for codecs.register for a list of the permitted
encoding error strings.
- newline controls how universal newlines works (it only applies to text
- mode). It can be None, '', '\n', '\r', and '\r\n'. It works as
- follows:
+ newline is a string controlling how universal newlines works (it only
+ applies to text mode). It can be None, '', '\n', '\r', and '\r\n'. It works
+ as follows:
* On input, if newline is None, universal newlines mode is
enabled. Lines in the input can end in '\n', '\r', or '\r\n', and
@@ -133,9 +128,9 @@ def open(file, mode="r", buffering=-1,
other legal values, any '\n' characters written are translated to
the given string.
- If closefd is False, the underlying file descriptor will be kept open
- when the file is closed. This does not work when a file name is given
- and must be True in that case.
+ closedfd is a bool. If closefd is False, the underlying file descriptor will
+ be kept open when the file is closed. This does not work when a file name is
+ given and must be True in that case.
open() returns a file object whose type depends on the mode, and
through which the standard file operations such as reading and writing
@@ -151,15 +146,15 @@ def open(file, mode="r", buffering=-1,
opened in a text mode, and for bytes a BytesIO can be used like a file
opened in a binary mode.
"""
- if not isinstance(file, (basestring, int, long)):
+ if not isinstance(file, (str, bytes, int)):
raise TypeError("invalid file: %r" % file)
- if not isinstance(mode, basestring):
+ if not isinstance(mode, str):
raise TypeError("invalid mode: %r" % mode)
- if not isinstance(buffering, (int, long)):
+ if not isinstance(buffering, int):
raise TypeError("invalid buffering: %r" % buffering)
- if encoding is not None and not isinstance(encoding, basestring):
+ if encoding is not None and not isinstance(encoding, str):
raise TypeError("invalid encoding: %r" % encoding)
- if errors is not None and not isinstance(errors, basestring):
+ if errors is not None and not isinstance(errors, str):
raise TypeError("invalid errors: %r" % errors)
modes = set(mode)
if modes - set("arwb+tU") or len(mode) > len(modes):
@@ -249,12 +244,16 @@ class OpenWrapper:
return open(*args, **kwargs)
-class UnsupportedOperation(ValueError, IOError):
- pass
+# In normal operation, both `UnsupportedOperation`s should be bound to the
+# same object.
+try:
+ UnsupportedOperation = io.UnsupportedOperation
+except AttributeError:
+ class UnsupportedOperation(ValueError, IOError):
+ pass
-class IOBase:
- __metaclass__ = abc.ABCMeta
+class IOBase(metaclass=abc.ABCMeta):
"""The abstract base class for all I/O classes, acting on streams of
bytes. There is no public constructor.
@@ -266,7 +265,8 @@ class IOBase:
Even though IOBase does not declare read, readinto, or write because
their signatures will vary, implementations and clients should
consider those methods part of the interface. Also, implementations
- may raise a IOError when operations they do not support are called.
+ may raise UnsupportedOperation when operations they do not support are
+ called.
The basic type used for binary data read from or written to a file is
bytes. bytearrays are accepted too, and in some cases (such as
@@ -289,7 +289,7 @@ class IOBase:
### Internal ###
def _unsupported(self, name):
- """Internal: raise an exception for unsupported operations."""
+ """Internal: raise an IOError exception for unsupported operations."""
raise UnsupportedOperation("%s.%s() not supported" %
(self.__class__.__name__, name))
@@ -300,18 +300,18 @@ class IOBase:
Change the stream position to byte offset offset. offset is
interpreted relative to the position indicated by whence. Values
- for whence are:
+ for whence are ints:
* 0 -- start of stream (the default); offset should be zero or positive
* 1 -- current stream position; offset may be negative
* 2 -- end of stream; offset is usually negative
- Return the new absolute position.
+ Return an int indicating the new absolute position.
"""
self._unsupported("seek")
def tell(self):
- """Return current stream position."""
+ """Return an int indicating the current stream position."""
return self.seek(0, 1)
def truncate(self, pos=None):
@@ -340,10 +340,8 @@ class IOBase:
This method has no effect if the file is already closed.
"""
if not self.__closed:
- try:
- self.flush()
- finally:
- self.__closed = True
+ self.flush()
+ self.__closed = True
def __del__(self):
"""Destructor. Calls close()."""
@@ -360,48 +358,47 @@ class IOBase:
### Inquiries ###
def seekable(self):
- """Return whether object supports random access.
+ """Return a bool indicating whether object supports random access.
- If False, seek(), tell() and truncate() will raise IOError.
+ If False, seek(), tell() and truncate() will raise UnsupportedOperation.
This method may need to do a test seek().
"""
return False
def _checkSeekable(self, msg=None):
- """Internal: raise an IOError if file is not seekable
+ """Internal: raise UnsupportedOperation if file is not seekable
"""
if not self.seekable():
- raise IOError("File or stream is not seekable."
- if msg is None else msg)
-
+ raise UnsupportedOperation("File or stream is not seekable."
+ if msg is None else msg)
def readable(self):
- """Return whether object was opened for reading.
+ """Return a bool indicating whether object was opened for reading.
- If False, read() will raise IOError.
+ If False, read() will raise UnsupportedOperation.
"""
return False
def _checkReadable(self, msg=None):
- """Internal: raise an IOError if file is not readable
+ """Internal: raise UnsupportedOperation if file is not readable
"""
if not self.readable():
- raise IOError("File or stream is not readable."
- if msg is None else msg)
+ raise UnsupportedOperation("File or stream is not readable."
+ if msg is None else msg)
def writable(self):
- """Return whether object was opened for writing.
+ """Return a bool indicating whether object was opened for writing.
- If False, write() and truncate() will raise IOError.
+ If False, write() and truncate() will raise UnsupportedOperation.
"""
return False
def _checkWritable(self, msg=None):
- """Internal: raise an IOError if file is not writable
+ """Internal: raise UnsupportedOperation if file is not writable
"""
if not self.writable():
- raise IOError("File or stream is not writable."
- if msg is None else msg)
+ raise UnsupportedOperation("File or stream is not writable."
+ if msg is None else msg)
@property
def closed(self):
@@ -420,8 +417,8 @@ class IOBase:
### Context manager ###
- def __enter__(self):
- """Context management protocol. Returns self."""
+ def __enter__(self): # That's a forward reference
+ """Context management protocol. Returns self (an instance of IOBase)."""
self._checkClosed()
return self
@@ -434,14 +431,14 @@ class IOBase:
# XXX Should these be present even if unimplemented?
def fileno(self):
- """Returns underlying file descriptor if one exists.
+ """Returns underlying file descriptor (an int) if one exists.
An IOError is raised if the IO object does not use a file descriptor.
"""
self._unsupported("fileno")
def isatty(self):
- """Return whether this is an 'interactive' stream.
+ """Return a bool indicating whether this is an 'interactive' stream.
Return False if it can't be determined.
"""
@@ -451,9 +448,10 @@ class IOBase:
### Readline[s] and writelines ###
def readline(self, limit=-1):
- r"""Read and return a line from the stream.
+ r"""Read and return a line of bytes from the stream.
If limit is specified, at most limit bytes will be read.
+ Limit should be an int.
The line terminator is always b'\n' for binary files; for text
files, the newlines argument to open can be used to select the line
@@ -474,7 +472,7 @@ class IOBase:
return 1
if limit is None:
limit = -1
- elif not isinstance(limit, (int, long)):
+ elif not isinstance(limit, int):
raise TypeError("limit must be an integer")
res = bytearray()
while limit < 0 or len(res) < limit:
@@ -490,7 +488,7 @@ class IOBase:
self._checkClosed()
return self
- def next(self):
+ def __next__(self):
line = self.readline()
if not line:
raise StopIteration
@@ -503,8 +501,6 @@ class IOBase:
lines will be read if the total size (in bytes/characters) of all
lines so far exceeds hint.
"""
- if hint is not None and not isinstance(hint, (int, long)):
- raise TypeError("integer or None expected")
if hint is None or hint <= 0:
return list(self)
n = 0
@@ -539,7 +535,7 @@ class RawIOBase(IOBase):
# a subclass doesn't implement either.)
def read(self, n=-1):
- """Read and return up to n bytes.
+ """Read and return up to n bytes, where n is an int.
Returns an empty bytes object on EOF, or None if the object is
set not to block and has no data to read.
@@ -570,10 +566,10 @@ class RawIOBase(IOBase):
return data
def readinto(self, b):
- """Read up to len(b) bytes into b.
+ """Read up to len(b) bytes into bytearray b.
- Returns number of bytes read (0 for EOF), or None if the object
- is set not to block and has no data to read.
+ Returns an int representing the number of bytes read (0 for EOF), or
+ None if the object is set not to block and has no data to read.
"""
self._unsupported("readinto")
@@ -607,7 +603,7 @@ class BufferedIOBase(IOBase):
"""
def read(self, n=None):
- """Read and return up to n bytes.
+ """Read and return up to n bytes, where n is an int.
If the argument is omitted, None, or negative, reads and
returns all data until EOF.
@@ -627,16 +623,18 @@ class BufferedIOBase(IOBase):
self._unsupported("read")
def read1(self, n=None):
- """Read up to n bytes with at most one read() system call."""
+ """Read up to n bytes with at most one read() system call,
+ where n is an int.
+ """
self._unsupported("read1")
def readinto(self, b):
- """Read up to len(b) bytes into b.
+ """Read up to len(b) bytes into bytearray b.
Like read(), this may issue multiple reads to the underlying raw
stream, unless the latter is 'interactive'.
- Returns the number of bytes read (0 for EOF).
+ Returns an int representing the number of bytes read (0 for EOF).
Raises BlockingIOError if the underlying raw stream has no
data at the moment.
@@ -650,11 +648,11 @@ class BufferedIOBase(IOBase):
import array
if not isinstance(b, array.array):
raise err
- b[:n] = array.array(b'b', data)
+ b[:n] = array.array('b', data)
return n
def write(self, b):
- """Write the given buffer to the IO stream.
+ """Write the given bytes buffer to the IO stream.
Return the number of bytes written, which is never less than
len(b).
@@ -764,6 +762,10 @@ class _BufferedIOMixin(BufferedIOBase):
def mode(self):
return self.raw.mode
+ def __getstate__(self):
+ raise TypeError("can not serialize a '{0}' object"
+ .format(self.__class__.__name__))
+
def __repr__(self):
clsname = self.__class__.__name__
try:
@@ -789,7 +791,7 @@ class BytesIO(BufferedIOBase):
def __init__(self, initial_bytes=None):
buf = bytearray()
if initial_bytes is not None:
- buf.extend(initial_bytes)
+ buf += initial_bytes
self._buffer = buf
self._pos = 0
@@ -805,14 +807,16 @@ class BytesIO(BufferedIOBase):
raise ValueError("getvalue on closed file")
return bytes(self._buffer)
+ def getbuffer(self):
+ """Return a readable and writable view of the buffer.
+ """
+ return memoryview(self._buffer)
+
def read(self, n=None):
if self.closed:
raise ValueError("read from closed file")
if n is None:
n = -1
- if not isinstance(n, (int, long)):
- raise TypeError("integer argument expected, got {0!r}".format(
- type(n)))
if n < 0:
n = len(self._buffer)
if len(self._buffer) <= self._pos:
@@ -830,8 +834,8 @@ class BytesIO(BufferedIOBase):
def write(self, b):
if self.closed:
raise ValueError("write to closed file")
- if isinstance(b, unicode):
- raise TypeError("can't write unicode to binary stream")
+ if isinstance(b, str):
+ raise TypeError("can't write str to binary stream")
n = len(b)
if n == 0:
return 0
@@ -850,8 +854,8 @@ class BytesIO(BufferedIOBase):
raise ValueError("seek on closed file")
try:
pos.__index__
- except AttributeError:
- raise TypeError("an integer is required")
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
if whence == 0:
if pos < 0:
raise ValueError("negative seek position %r" % (pos,))
@@ -877,8 +881,8 @@ class BytesIO(BufferedIOBase):
else:
try:
pos.__index__
- except AttributeError:
- raise TypeError("an integer is required")
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
if pos < 0:
raise ValueError("negative truncate position %r" % (pos,))
del self._buffer[pos:]
@@ -1080,8 +1084,8 @@ class BufferedWriter(_BufferedIOMixin):
def write(self, b):
if self.closed:
raise ValueError("write to closed file")
- if isinstance(b, unicode):
- raise TypeError("can't write unicode to binary stream")
+ if isinstance(b, str):
+ raise TypeError("can't write str to binary stream")
with self._write_lock:
# XXX we can implement some more tricks to try and avoid
# partial writes
@@ -1303,19 +1307,21 @@ class TextIOBase(IOBase):
"""
def read(self, n=-1):
- """Read at most n characters from stream.
+ """Read at most n characters from stream, where n is an int.
Read from underlying buffer until we have n characters or we hit EOF.
If n is negative or omitted, read until EOF.
+
+ Returns a string.
"""
self._unsupported("read")
def write(self, s):
- """Write string s to stream."""
+ """Write string s to stream and returning an int."""
self._unsupported("write")
def truncate(self, pos=None):
- """Truncate size to pos."""
+ """Truncate size to pos, where pos is an int."""
self._unsupported("truncate")
def readline(self):
@@ -1471,27 +1477,32 @@ class TextIOWrapper(TextIOBase):
_CHUNK_SIZE = 2048
def __init__(self, buffer, encoding=None, errors=None, newline=None,
- line_buffering=False):
- if newline is not None and not isinstance(newline, basestring):
+ line_buffering=False, write_through=False):
+ if newline is not None and not isinstance(newline, str):
raise TypeError("illegal newline type: %r" % (type(newline),))
if newline not in (None, "", "\n", "\r", "\r\n"):
raise ValueError("illegal newline value: %r" % (newline,))
if encoding is None:
try:
- import locale
- except ImportError:
- # Importing locale may fail if Python is being built
- encoding = "ascii"
- else:
- encoding = locale.getpreferredencoding()
+ encoding = os.device_encoding(buffer.fileno())
+ except (AttributeError, UnsupportedOperation):
+ pass
+ if encoding is None:
+ try:
+ import locale
+ except ImportError:
+ # Importing locale may fail if Python is being built
+ encoding = "ascii"
+ else:
+ encoding = locale.getpreferredencoding()
- if not isinstance(encoding, basestring):
+ if not isinstance(encoding, str):
raise ValueError("invalid encoding: %r" % encoding)
if errors is None:
errors = "strict"
else:
- if not isinstance(errors, basestring):
+ if not isinstance(errors, str):
raise ValueError("invalid errors: %r" % errors)
self._buffer = buffer
@@ -1509,6 +1520,7 @@ class TextIOWrapper(TextIOBase):
self._decoded_chars_used = 0 # offset into _decoded_chars for read()
self._snapshot = None # info for reconstructing decoder state
self._seekable = self._telling = self.buffer.seekable()
+ self._has_read1 = hasattr(self.buffer, 'read1')
if self._seekable and self.writable():
position = self.buffer.tell()
@@ -1529,13 +1541,20 @@ class TextIOWrapper(TextIOBase):
# - "chars_..." for integer variables that count decoded characters
def __repr__(self):
+ result = "<_pyio.TextIOWrapper"
try:
name = self.name
except AttributeError:
- return "<_pyio.TextIOWrapper encoding='{0}'>".format(self.encoding)
+ pass
else:
- return "<_pyio.TextIOWrapper name={0!r} encoding='{1}'>".format(
- name, self.encoding)
+ result += " name={0!r}".format(name)
+ try:
+ mode = self.mode
+ except AttributeError:
+ pass
+ else:
+ result += " mode={0!r}".format(mode)
+ return result + " encoding={0!r}>".format(self.encoding)
@property
def encoding(self):
@@ -1570,10 +1589,8 @@ class TextIOWrapper(TextIOBase):
def close(self):
if self.buffer is not None and not self.closed:
- try:
- self.flush()
- finally:
- self.buffer.close()
+ self.flush()
+ self.buffer.close()
@property
def closed(self):
@@ -1590,9 +1607,10 @@ class TextIOWrapper(TextIOBase):
return self.buffer.isatty()
def write(self, s):
+ 'Write data, where s is a str'
if self.closed:
raise ValueError("write to closed file")
- if not isinstance(s, unicode):
+ if not isinstance(s, str):
raise TypeError("can't write %s to text stream" %
s.__class__.__name__)
length = len(s)
@@ -1670,7 +1688,10 @@ class TextIOWrapper(TextIOBase):
# len(dec_buffer) bytes ago with decoder state (b'', dec_flags).
# Read a chunk, decode it, and put the result in self._decoded_chars.
- input_chunk = self.buffer.read1(self._CHUNK_SIZE)
+ if self._has_read1:
+ input_chunk = self.buffer.read1(self._CHUNK_SIZE)
+ else:
+ input_chunk = self.buffer.read(self._CHUNK_SIZE)
eof = not input_chunk
self._set_decoded_chars(self._decoder.decode(input_chunk, eof))
@@ -1700,7 +1721,7 @@ class TextIOWrapper(TextIOBase):
def tell(self):
if not self._seekable:
- raise IOError("underlying stream is not seekable")
+ raise UnsupportedOperation("underlying stream is not seekable")
if not self._telling:
raise IOError("telling position disabled by next() call")
self.flush()
@@ -1736,7 +1757,8 @@ class TextIOWrapper(TextIOBase):
# nearest "safe start point" before the current location
# (a point where the decoder has nothing buffered, so seek()
# can safely start from there and advance to this location).
- for next_byte in next_input:
+ next_byte = bytearray(1)
+ for next_byte[0] in next_input:
bytes_fed += 1
chars_decoded += len(decoder.decode(next_byte))
dec_buffer, dec_flags = decoder.getstate()
@@ -1778,17 +1800,17 @@ class TextIOWrapper(TextIOBase):
if self.closed:
raise ValueError("tell on closed file")
if not self._seekable:
- raise IOError("underlying stream is not seekable")
+ raise UnsupportedOperation("underlying stream is not seekable")
if whence == 1: # seek relative to current position
if cookie != 0:
- raise IOError("can't do nonzero cur-relative seeks")
+ raise UnsupportedOperation("can't do nonzero cur-relative seeks")
# Seeking to the current position should attempt to
# sync the underlying buffer with the current position.
whence = 0
cookie = self.tell()
if whence == 2: # seek relative to end of file
if cookie != 0:
- raise IOError("can't do nonzero end-relative seeks")
+ raise UnsupportedOperation("can't do nonzero end-relative seeks")
self.flush()
position = self.buffer.seek(0, 2)
self._set_decoded_chars('')
@@ -1853,8 +1875,8 @@ class TextIOWrapper(TextIOBase):
decoder = self._decoder or self._get_decoder()
try:
n.__index__
- except AttributeError:
- raise TypeError("an integer is required")
+ except AttributeError as err:
+ raise TypeError("an integer is required") from err
if n < 0:
# Read everything.
result = (self._get_decoded_chars() +
@@ -1871,7 +1893,7 @@ class TextIOWrapper(TextIOBase):
result += self._get_decoded_chars(n - len(result))
return result
- def next(self):
+ def __next__(self):
self._telling = False
line = self.readline()
if not line:
@@ -1885,7 +1907,7 @@ class TextIOWrapper(TextIOBase):
raise ValueError("read from closed file")
if limit is None:
limit = -1
- elif not isinstance(limit, (int, long)):
+ elif not isinstance(limit, int):
raise TypeError("limit must be an integer")
# Grab all the decoded text (we will rewind any extra bits later).
@@ -1989,9 +2011,11 @@ class StringIO(TextIOWrapper):
# C version, even under Windows.
if newline is None:
self._writetranslate = False
- if initial_value:
- if not isinstance(initial_value, unicode):
- initial_value = unicode(initial_value)
+ if initial_value is not None:
+ if not isinstance(initial_value, str):
+ raise TypeError("initial_value must be str or None, not {0}"
+ .format(type(initial_value).__name__))
+ initial_value = str(initial_value)
self.write(initial_value)
self.seek(0)
diff --git a/Lib/_strptime.py b/Lib/_strptime.py
index 2df30a22ea5..fa06376992c 100644
--- a/Lib/_strptime.py
+++ b/Lib/_strptime.py
@@ -14,13 +14,15 @@ import time
import locale
import calendar
from re import compile as re_compile
-from re import IGNORECASE
+from re import IGNORECASE, ASCII
from re import escape as re_escape
-from datetime import date as datetime_date
+from datetime import (date as datetime_date,
+ timedelta as datetime_timedelta,
+ timezone as datetime_timezone)
try:
- from thread import allocate_lock as _thread_allocate_lock
+ from _thread import allocate_lock as _thread_allocate_lock
except:
- from dummy_thread import allocate_lock as _thread_allocate_lock
+ from _dummy_thread import allocate_lock as _thread_allocate_lock
__all__ = []
@@ -107,7 +109,7 @@ class LocaleTime(object):
# magical; just happened to have used it everywhere else where a
# static date was needed.
am_pm = []
- for hour in (01,22):
+ for hour in (1, 22):
time_tuple = time.struct_time((1999,3,17,hour,44,55,2,76,0))
am_pm.append(time.strftime("%p", time_tuple).lower())
self.am_pm = am_pm
@@ -186,7 +188,7 @@ class TimeRE(dict):
self.locale_time = locale_time
else:
self.locale_time = LocaleTime()
- base = super(TimeRE, self)
+ base = super()
base.__init__({
# The " \d" part of the regex is to make %c from ANSI C work
'd': r"(?P<d>3[0-1]|[1-2]\d|0[1-9]|[1-9]| [1-9])",
@@ -204,6 +206,7 @@ class TimeRE(dict):
#XXX: Does 'Y' need to worry about having less or more than
# 4 digits?
'Y': r"(?P<Y>\d\d\d\d)",
+ 'z': r"(?P<z>[+-]\d\d[0-5]\d)",
'A': self.__seqToRE(self.locale_time.f_weekday, 'A'),
'a': self.__seqToRE(self.locale_time.a_weekday, 'a'),
'B': self.__seqToRE(self.locale_time.f_month[1:], 'B'),
@@ -293,9 +296,18 @@ def _calc_julian_from_U_or_W(year, week_of_year, day_of_week, week_starts_Mon):
def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
- """Return a time struct based on the input string and the format string."""
+ """Return a 2-tuple consisting of a time struct and an int containing
+ the number of microseconds based on the input string and the
+ format string."""
+
+ for index, arg in enumerate([data_string, format]):
+ if not isinstance(arg, str):
+ msg = "strptime() argument {} must be str, not {}"
+ raise TypeError(msg.format(index, type(arg)))
+
global _TimeRE_cache, _regex_cache
with _cache_lock:
+
if _getlang() != _TimeRE_cache.locale_time.lang:
_TimeRE_cache = TimeRE()
_regex_cache.clear()
@@ -308,7 +320,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
format_regex = _TimeRE_cache.compile(format)
# KeyError raised when a bad format is found; can be specified as
# \\, in which case it was a stray % but with a space after it
- except KeyError, err:
+ except KeyError as err:
bad_directive = err.args[0]
if bad_directive == "\\":
bad_directive = "%"
@@ -331,6 +343,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
month = day = 1
hour = minute = second = fraction = 0
tz = -1
+ tzoffset = None
# Default to -1 to signify that values not known; not critical to have,
# though
week_of_year = -1
@@ -339,7 +352,7 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
# values
weekday = julian = -1
found_dict = found.groupdict()
- for group_key in found_dict.iterkeys():
+ for group_key in found_dict.keys():
# Directives not explicitly handled below:
# c, x, X
# handled by making out of other directives
@@ -411,6 +424,11 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
else:
# W starts week on Monday.
week_of_year_start = 0
+ elif group_key == 'z':
+ z = found_dict['z']
+ tzoffset = int(z[1:3]) * 60 + int(z[3:5])
+ if z.startswith("-"):
+ tzoffset = -tzoffset
elif group_key == 'Z':
# Since -1 is default value only need to worry about setting tz if
# it can be something other than -1.
@@ -453,15 +471,41 @@ def _strptime(data_string, format="%a %b %d %H:%M:%S %Y"):
day = datetime_result.day
if weekday == -1:
weekday = datetime_date(year, month, day).weekday()
+ # Add timezone info
+ tzname = found_dict.get("Z")
+ if tzoffset is not None:
+ gmtoff = tzoffset * 60
+ else:
+ gmtoff = None
+
if leap_year_fix:
# the caller didn't supply a year but asked for Feb 29th. We couldn't
# use the default of 1900 for computations. We set it back to ensure
# that February 29th is smaller than March 1st.
year = 1900
- return (time.struct_time((year, month, day,
- hour, minute, second,
- weekday, julian, tz)), fraction)
+ return (year, month, day,
+ hour, minute, second,
+ weekday, julian, tz, gmtoff, tzname), fraction
def _strptime_time(data_string, format="%a %b %d %H:%M:%S %Y"):
- return _strptime(data_string, format)[0]
+ """Return a time struct based on the input string and the
+ format string."""
+ tt = _strptime(data_string, format)[0]
+ return time.struct_time(tt[:9])
+
+def _strptime_datetime(cls, data_string, format="%a %b %d %H:%M:%S %Y"):
+ """Return a class cls instance based on the input string and the
+ format string."""
+ tt, fraction = _strptime(data_string, format)
+ gmtoff, tzname = tt[-2:]
+ args = tt[:6] + (fraction,)
+ if gmtoff is not None:
+ tzdelta = datetime_timedelta(seconds=gmtoff)
+ if tzname:
+ tz = datetime_timezone(tzdelta, tzname)
+ else:
+ tz = datetime_timezone(tzdelta)
+ args += (tz,)
+
+ return cls(*args)
diff --git a/Lib/_threading_local.py b/Lib/_threading_local.py
index 09a3515bdb9..4ec4828144b 100644
--- a/Lib/_threading_local.py
+++ b/Lib/_threading_local.py
@@ -28,8 +28,7 @@ local to a thread. If we access the data in a different thread:
>>> log = []
>>> def f():
- ... items = mydata.__dict__.items()
- ... items.sort()
+ ... items = sorted(mydata.__dict__.items())
... log.append(items)
... mydata.number = 11
... log.append(mydata.number)
@@ -133,6 +132,9 @@ affects what we see:
>>> del mydata
"""
+from weakref import ref
+from contextlib import contextmanager
+
__all__ = ["local"]
# We need to use objects from the threading module, but the threading
@@ -140,112 +142,105 @@ __all__ = ["local"]
# isn't compiled in to the `thread` module. This creates potential problems
# with circular imports. For that reason, we don't import `threading`
# until the bottom of this file (a hack sufficient to worm around the
-# potential problems). Note that almost all platforms do have support for
-# locals in the `thread` module, and there is no circular import problem
+# potential problems). Note that all platforms on CPython do have support
+# for locals in the `thread` module, and there is no circular import problem
# then, so problems introduced by fiddling the order of imports here won't
-# manifest on most boxes.
+# manifest.
+
+class _localimpl:
+ """A class managing thread-local dicts"""
+ __slots__ = 'key', 'dicts', 'localargs', 'locallock', '__weakref__'
+
+ def __init__(self):
+ # The key used in the Thread objects' attribute dicts.
+ # We keep it a string for speed but make it unlikely to clash with
+ # a "real" attribute.
+ self.key = '_threading_local._localimpl.' + str(id(self))
+ # { id(Thread) -> (ref(Thread), thread-local dict) }
+ self.dicts = {}
+
+ def get_dict(self):
+ """Return the dict for the current thread. Raises KeyError if none
+ defined."""
+ thread = current_thread()
+ return self.dicts[id(thread)][1]
+
+ def create_dict(self):
+ """Create a new dict for the current thread, and return it."""
+ localdict = {}
+ key = self.key
+ thread = current_thread()
+ idt = id(thread)
+ def local_deleted(_, key=key):
+ # When the localimpl is deleted, remove the thread attribute.
+ thread = wrthread()
+ if thread is not None:
+ del thread.__dict__[key]
+ def thread_deleted(_, idt=idt):
+ # When the thread is deleted, remove the local dict.
+ # Note that this is suboptimal if the thread object gets
+ # caught in a reference loop. We would like to be called
+ # as soon as the OS-level thread ends instead.
+ local = wrlocal()
+ if local is not None:
+ dct = local.dicts.pop(idt)
+ wrlocal = ref(self, local_deleted)
+ wrthread = ref(thread, thread_deleted)
+ thread.__dict__[key] = wrlocal
+ self.dicts[idt] = wrthread, localdict
+ return localdict
+
+
+@contextmanager
+def _patch(self):
+ impl = object.__getattribute__(self, '_local__impl')
+ try:
+ dct = impl.get_dict()
+ except KeyError:
+ dct = impl.create_dict()
+ args, kw = impl.localargs
+ self.__init__(*args, **kw)
+ with impl.locallock:
+ object.__setattr__(self, '__dict__', dct)
+ yield
-class _localbase(object):
- __slots__ = '_local__key', '_local__args', '_local__lock'
- def __new__(cls, *args, **kw):
- self = object.__new__(cls)
- key = '_local__key', 'thread.local.' + str(id(self))
- object.__setattr__(self, '_local__key', key)
- object.__setattr__(self, '_local__args', (args, kw))
- object.__setattr__(self, '_local__lock', RLock())
+class local:
+ __slots__ = '_local__impl', '__dict__'
+ def __new__(cls, *args, **kw):
if (args or kw) and (cls.__init__ is object.__init__):
raise TypeError("Initialization arguments are not supported")
-
+ self = object.__new__(cls)
+ impl = _localimpl()
+ impl.localargs = (args, kw)
+ impl.locallock = RLock()
+ object.__setattr__(self, '_local__impl', impl)
# We need to create the thread dict in anticipation of
# __init__ being called, to make sure we don't call it
# again ourselves.
- dict = object.__getattribute__(self, '__dict__')
- current_thread().__dict__[key] = dict
-
+ impl.create_dict()
return self
-def _patch(self):
- key = object.__getattribute__(self, '_local__key')
- d = current_thread().__dict__.get(key)
- if d is None:
- d = {}
- current_thread().__dict__[key] = d
- object.__setattr__(self, '__dict__', d)
-
- # we have a new instance dict, so call out __init__ if we have
- # one
- cls = type(self)
- if cls.__init__ is not object.__init__:
- args, kw = object.__getattribute__(self, '_local__args')
- cls.__init__(self, *args, **kw)
- else:
- object.__setattr__(self, '__dict__', d)
-
-class local(_localbase):
-
def __getattribute__(self, name):
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__getattribute__(self, name)
- finally:
- lock.release()
def __setattr__(self, name, value):
if name == '__dict__':
raise AttributeError(
"%r object attribute '__dict__' is read-only"
% self.__class__.__name__)
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__setattr__(self, name, value)
- finally:
- lock.release()
def __delattr__(self, name):
if name == '__dict__':
raise AttributeError(
"%r object attribute '__dict__' is read-only"
% self.__class__.__name__)
- lock = object.__getattribute__(self, '_local__lock')
- lock.acquire()
- try:
- _patch(self)
+ with _patch(self):
return object.__delattr__(self, name)
- finally:
- lock.release()
-
- def __del__(self):
- import threading
-
- key = object.__getattribute__(self, '_local__key')
-
- try:
- # We use the non-locking API since we might already hold the lock
- # (__del__ can be called at any point by the cyclic GC).
- threads = threading._enumerate()
- except:
- # If enumerating the current threads fails, as it seems to do
- # during shutdown, we'll skip cleanup under the assumption
- # that there is nothing to clean up.
- return
-
- for thread in threads:
- try:
- __dict__ = thread.__dict__
- except AttributeError:
- # Thread is dying, rest in peace.
- continue
-
- if key in __dict__:
- try:
- del __dict__[key]
- except KeyError:
- pass # didn't have anything in this thread
+
from threading import current_thread, RLock
diff --git a/Lib/_weakrefset.py b/Lib/_weakrefset.py
index 43f9a6e447d..6a98b88e335 100644
--- a/Lib/_weakrefset.py
+++ b/Lib/_weakrefset.py
@@ -7,7 +7,7 @@ from _weakref import ref
__all__ = ['WeakSet']
-class _IterationGuard(object):
+class _IterationGuard:
# This context manager registers itself in the current iterators of the
# weak container, such as to delay all removals until the context manager
# exits.
@@ -32,7 +32,7 @@ class _IterationGuard(object):
w._commit_removals()
-class WeakSet(object):
+class WeakSet:
def __init__(self, data=None):
self.data = set()
def _remove(item, selfref=ref(self)):
@@ -76,8 +76,6 @@ class WeakSet(object):
return (self.__class__, (list(self),),
getattr(self, '__dict__', None))
- __hash__ = None
-
def add(self, item):
if self._pending_removals:
self._commit_removals()
diff --git a/Lib/abc.py b/Lib/abc.py
index 02e48a1bb32..a6c2dc48779 100644
--- a/Lib/abc.py
+++ b/Lib/abc.py
@@ -3,15 +3,8 @@
"""Abstract Base Classes (ABCs) according to PEP 3119."""
-import types
-
from _weakrefset import WeakSet
-# Instance of old-style class
-class _C: pass
-_InstanceType = type(_C())
-
-
def abstractmethod(funcobj):
"""A decorator indicating abstract methods.
@@ -23,8 +16,7 @@ def abstractmethod(funcobj):
Usage:
- class C:
- __metaclass__ = ABCMeta
+ class C(metaclass=ABCMeta):
@abstractmethod
def my_abstract_method(self, ...):
...
@@ -33,6 +25,46 @@ def abstractmethod(funcobj):
return funcobj
+class abstractclassmethod(classmethod):
+ """A decorator indicating abstract classmethods.
+
+ Similar to abstractmethod.
+
+ Usage:
+
+ class C(metaclass=ABCMeta):
+ @abstractclassmethod
+ def my_abstract_classmethod(cls, ...):
+ ...
+ """
+
+ __isabstractmethod__ = True
+
+ def __init__(self, callable):
+ callable.__isabstractmethod__ = True
+ super().__init__(callable)
+
+
+class abstractstaticmethod(staticmethod):
+ """A decorator indicating abstract staticmethods.
+
+ Similar to abstractmethod.
+
+ Usage:
+
+ class C(metaclass=ABCMeta):
+ @abstractstaticmethod
+ def my_abstract_staticmethod(...):
+ ...
+ """
+
+ __isabstractmethod__ = True
+
+ def __init__(self, callable):
+ callable.__isabstractmethod__ = True
+ super().__init__(callable)
+
+
class abstractproperty(property):
"""A decorator indicating abstract properties.
@@ -44,8 +76,7 @@ class abstractproperty(property):
Usage:
- class C:
- __metaclass__ = ABCMeta
+ class C(metaclass=ABCMeta):
@abstractproperty
def my_abstract_property(self):
...
@@ -53,8 +84,7 @@ class abstractproperty(property):
This defines a read-only property; you can also define a read-write
abstract property using the 'long' form of property declaration:
- class C:
- __metaclass__ = ABCMeta
+ class C(metaclass=ABCMeta):
def getx(self): ...
def setx(self, value): ...
x = abstractproperty(getx, setx)
@@ -84,11 +114,11 @@ class ABCMeta(type):
_abc_invalidation_counter = 0
def __new__(mcls, name, bases, namespace):
- cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
+ cls = super().__new__(mcls, name, bases, namespace)
# Compute set of abstract method names
- abstracts = set(name
+ abstracts = {name
for name, value in namespace.items()
- if getattr(value, "__isabstractmethod__", False))
+ if getattr(value, "__isabstractmethod__", False)}
for base in bases:
for name in getattr(base, "__abstractmethods__", set()):
value = getattr(cls, name, None)
@@ -104,7 +134,7 @@ class ABCMeta(type):
def register(cls, subclass):
"""Register a virtual subclass of an ABC."""
- if not isinstance(subclass, (type, types.ClassType)):
+ if not isinstance(subclass, type):
raise TypeError("Can only register classes")
if issubclass(subclass, cls):
return # Already a subclass
@@ -118,32 +148,28 @@ class ABCMeta(type):
def _dump_registry(cls, file=None):
"""Debug helper to print the ABC registry."""
- print >> file, "Class: %s.%s" % (cls.__module__, cls.__name__)
- print >> file, "Inv.counter: %s" % ABCMeta._abc_invalidation_counter
+ print("Class: %s.%s" % (cls.__module__, cls.__name__), file=file)
+ print("Inv.counter: %s" % ABCMeta._abc_invalidation_counter, file=file)
for name in sorted(cls.__dict__.keys()):
if name.startswith("_abc_"):
value = getattr(cls, name)
- print >> file, "%s: %r" % (name, value)
+ print("%s: %r" % (name, value), file=file)
def __instancecheck__(cls, instance):
"""Override for isinstance(instance, cls)."""
- # Inline the cache checking when it's simple.
- subclass = getattr(instance, '__class__', None)
- if subclass is not None and subclass in cls._abc_cache:
+ # Inline the cache checking
+ subclass = instance.__class__
+ if subclass in cls._abc_cache:
return True
subtype = type(instance)
- # Old-style instances
- if subtype is _InstanceType:
- subtype = subclass
- if subtype is subclass or subclass is None:
+ if subtype is subclass:
if (cls._abc_negative_cache_version ==
ABCMeta._abc_invalidation_counter and
- subtype in cls._abc_negative_cache):
+ subclass in cls._abc_negative_cache):
return False
# Fall back to the subclass check.
- return cls.__subclasscheck__(subtype)
- return (cls.__subclasscheck__(subclass) or
- cls.__subclasscheck__(subtype))
+ return cls.__subclasscheck__(subclass)
+ return any(cls.__subclasscheck__(c) for c in {subclass, subtype})
def __subclasscheck__(cls, subclass):
"""Override for issubclass(subclass, cls)."""
diff --git a/Lib/aifc.py b/Lib/aifc.py
index b8adc852ed6..775f39c74fb 100644
--- a/Lib/aifc.py
+++ b/Lib/aifc.py
@@ -135,14 +135,14 @@ writeframesraw.
"""
import struct
-import __builtin__
+import builtins
-__all__ = ["Error","open","openfp"]
+__all__ = ["Error", "open", "openfp"]
class Error(Exception):
pass
-_AIFC_version = 0xA2805140L # Version 1 of AIFF-C
+_AIFC_version = 0xA2805140 # Version 1 of AIFF-C
def _read_long(file):
try:
@@ -171,7 +171,7 @@ def _read_ushort(file):
def _read_string(file):
length = ord(file.read(1))
if length == 0:
- data = ''
+ data = b''
else:
data = file.read(length)
if length & 1 == 0:
@@ -194,7 +194,7 @@ def _read_float(f): # 10 bytes
f = _HUGE_VAL
else:
expon = expon - 16383
- f = (himant * 0x100000000L + lomant) * pow(2.0, expon - 63)
+ f = (himant * 0x100000000 + lomant) * pow(2.0, expon - 63)
return sign * f
def _write_short(f, x):
@@ -215,7 +215,7 @@ def _write_string(f, s):
f.write(struct.pack('B', len(s)))
f.write(s)
if len(s) & 1 == 0:
- f.write(chr(0))
+ f.write(b'\x00')
def _write_float(f, x):
import math
@@ -242,10 +242,10 @@ def _write_float(f, x):
expon = expon | sign
fmant = math.ldexp(fmant, 32)
fsmant = math.floor(fmant)
- himant = long(fsmant)
+ himant = int(fsmant)
fmant = math.ldexp(fmant - fsmant, 32)
fsmant = math.floor(fmant)
- lomant = long(fsmant)
+ lomant = int(fsmant)
_write_ushort(f, expon)
_write_ulong(f, himant)
_write_ulong(f, lomant)
@@ -290,21 +290,20 @@ class Aifc_read:
def initfp(self, file):
self._version = 0
- self._decomp = None
self._convert = None
self._markers = []
self._soundpos = 0
self._file = file
chunk = Chunk(file)
- if chunk.getname() != 'FORM':
- raise Error, 'file does not start with FORM id'
+ if chunk.getname() != b'FORM':
+ raise Error('file does not start with FORM id')
formdata = chunk.read(4)
- if formdata == 'AIFF':
+ if formdata == b'AIFF':
self._aifc = 0
- elif formdata == 'AIFC':
+ elif formdata == b'AIFC':
self._aifc = 1
else:
- raise Error, 'not an AIFF or AIFF-C file'
+ raise Error('not an AIFF or AIFF-C file')
self._comm_chunk_read = 0
while 1:
self._ssnd_seek_needed = 1
@@ -313,36 +312,24 @@ class Aifc_read:
except EOFError:
break
chunkname = chunk.getname()
- if chunkname == 'COMM':
+ if chunkname == b'COMM':
self._read_comm_chunk(chunk)
self._comm_chunk_read = 1
- elif chunkname == 'SSND':
+ elif chunkname == b'SSND':
self._ssnd_chunk = chunk
dummy = chunk.read(8)
self._ssnd_seek_needed = 0
- elif chunkname == 'FVER':
+ elif chunkname == b'FVER':
self._version = _read_ulong(chunk)
- elif chunkname == 'MARK':
+ elif chunkname == b'MARK':
self._readmark(chunk)
chunk.skip()
if not self._comm_chunk_read or not self._ssnd_chunk:
- raise Error, 'COMM chunk and/or SSND chunk missing'
- if self._aifc and self._decomp:
- import cl
- params = [cl.ORIGINAL_FORMAT, 0,
- cl.BITS_PER_COMPONENT, self._sampwidth * 8,
- cl.FRAME_RATE, self._framerate]
- if self._nchannels == 1:
- params[1] = cl.MONO
- elif self._nchannels == 2:
- params[1] = cl.STEREO_INTERLEAVED
- else:
- raise Error, 'cannot compress more than 2 channels'
- self._decomp.SetParams(params)
+ raise Error('COMM chunk and/or SSND chunk missing')
def __init__(self, f):
- if type(f) == type(''):
- f = __builtin__.open(f, 'rb')
+ if isinstance(f, str):
+ f = builtins.open(f, 'rb')
# else, assume it is an open file object already
self.initfp(f)
@@ -357,9 +344,6 @@ class Aifc_read:
self._soundpos = 0
def close(self):
- if self._decomp:
- self._decomp.CloseDecompressor()
- self._decomp = None
self._file.close()
def tell(self):
@@ -400,11 +384,11 @@ class Aifc_read:
for marker in self._markers:
if id == marker[0]:
return marker
- raise Error, 'marker %r does not exist' % (id,)
+ raise Error('marker {0!r} does not exist'.format(id))
def setpos(self, pos):
if pos < 0 or pos > self._nframes:
- raise Error, 'position not in range'
+ raise Error('position not in range')
self._soundpos = pos
self._ssnd_seek_needed = 1
@@ -417,23 +401,21 @@ class Aifc_read:
self._ssnd_chunk.seek(pos + 8)
self._ssnd_seek_needed = 0
if nframes == 0:
- return ''
+ return b''
data = self._ssnd_chunk.read(nframes * self._framesize)
if self._convert and data:
data = self._convert(data)
- self._soundpos = self._soundpos + len(data) // (self._nchannels * self._sampwidth)
+ self._soundpos = self._soundpos + len(data) // (self._nchannels
+ * self._sampwidth)
return data
#
# Internal methods.
#
- def _decomp_data(self, data):
- import cl
- dummy = self._decomp.SetParam(cl.FRAME_BUFFER_SIZE,
- len(data) * 2)
- return self._decomp.Decompress(len(data) // self._nchannels,
- data)
+ def _alaw2lin(self, data):
+ import audioop
+ return audioop.alaw2lin(data, 2)
def _ulaw2lin(self, data):
import audioop
@@ -444,8 +426,7 @@ class Aifc_read:
if not hasattr(self, '_adpcmstate'):
# first time
self._adpcmstate = None
- data, self._adpcmstate = audioop.adpcm2lin(data, 2,
- self._adpcmstate)
+ data, self._adpcmstate = audioop.adpcm2lin(data, 2, self._adpcmstate)
return data
def _read_comm_chunk(self, chunk):
@@ -459,7 +440,7 @@ class Aifc_read:
kludge = 0
if chunk.chunksize == 18:
kludge = 1
- print 'Warning: bad COMM chunk size'
+ print('Warning: bad COMM chunk size')
chunk.chunksize = 23
#DEBUG end
self._comptype = chunk.read(4)
@@ -472,42 +453,21 @@ class Aifc_read:
chunk.file.seek(-1, 1)
#DEBUG end
self._compname = _read_string(chunk)
- if self._comptype != 'NONE':
- if self._comptype == 'G722':
- try:
- import audioop
- except ImportError:
- pass
- else:
- self._convert = self._adpcm2lin
- self._framesize = self._framesize // 4
- return
- # for ULAW and ALAW try Compression Library
- try:
- import cl
- except ImportError:
- if self._comptype == 'ULAW':
- try:
- import audioop
- self._convert = self._ulaw2lin
- self._framesize = self._framesize // 2
- return
- except ImportError:
- pass
- raise Error, 'cannot read compressed AIFF-C files'
- if self._comptype == 'ULAW':
- scheme = cl.G711_ULAW
+ if self._comptype != b'NONE':
+ if self._comptype == b'G722':
+ self._convert = self._adpcm2lin
+ self._framesize = self._framesize // 4
+ elif self._comptype in (b'ulaw', b'ULAW'):
+ self._convert = self._ulaw2lin
self._framesize = self._framesize // 2
- elif self._comptype == 'ALAW':
- scheme = cl.G711_ALAW
+ elif self._comptype in (b'alaw', b'ALAW'):
+ self._convert = self._alaw2lin
self._framesize = self._framesize // 2
else:
- raise Error, 'unsupported compression type'
- self._decomp = cl.OpenDecompressor(scheme)
- self._convert = self._decomp_data
+ raise Error('unsupported compression type')
else:
- self._comptype = 'NONE'
- self._compname = 'not compressed'
+ self._comptype = b'NONE'
+ self._compname = b'not compressed'
def _readmark(self, chunk):
nmarkers = _read_short(chunk)
@@ -524,11 +484,11 @@ class Aifc_read:
# a position 0 and name ''
self._markers.append((id, pos, name))
except EOFError:
- print 'Warning: MARK chunk contains only',
- print len(self._markers),
- if len(self._markers) == 1: print 'marker',
- else: print 'markers',
- print 'instead of', nmarkers
+ print('Warning: MARK chunk contains only', end=' ')
+ print(len(self._markers), end=' ')
+ if len(self._markers) == 1: print('marker', end=' ')
+ else: print('markers', end=' ')
+ print('instead of', nmarkers)
class Aifc_write:
# Variables used in this class:
@@ -561,9 +521,9 @@ class Aifc_write:
# _datawritten -- the size of the audio samples actually written
def __init__(self, f):
- if type(f) == type(''):
+ if isinstance(f, str):
filename = f
- f = __builtin__.open(f, 'wb')
+ f = builtins.open(f, 'wb')
else:
# else, assume it is an open file object already
filename = '???'
@@ -576,9 +536,8 @@ class Aifc_write:
def initfp(self, file):
self._file = file
self._version = _AIFC_version
- self._comptype = 'NONE'
- self._compname = 'not compressed'
- self._comp = None
+ self._comptype = b'NONE'
+ self._compname = b'not compressed'
self._convert = None
self._nchannels = 0
self._sampwidth = 0
@@ -592,61 +551,60 @@ class Aifc_write:
self._aifc = 1 # AIFF-C is default
def __del__(self):
- if self._file:
- self.close()
+ self.close()
#
# User visible methods.
#
def aiff(self):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self._aifc = 0
def aifc(self):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self._aifc = 1
def setnchannels(self, nchannels):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if nchannels < 1:
- raise Error, 'bad # of channels'
+ raise Error('bad # of channels')
self._nchannels = nchannels
def getnchannels(self):
if not self._nchannels:
- raise Error, 'number of channels not set'
+ raise Error('number of channels not set')
return self._nchannels
def setsampwidth(self, sampwidth):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if sampwidth < 1 or sampwidth > 4:
- raise Error, 'bad sample width'
+ raise Error('bad sample width')
self._sampwidth = sampwidth
def getsampwidth(self):
if not self._sampwidth:
- raise Error, 'sample width not set'
+ raise Error('sample width not set')
return self._sampwidth
def setframerate(self, framerate):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if framerate <= 0:
- raise Error, 'bad frame rate'
+ raise Error('bad frame rate')
self._framerate = framerate
def getframerate(self):
if not self._framerate:
- raise Error, 'frame rate not set'
+ raise Error('frame rate not set')
return self._framerate
def setnframes(self, nframes):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self._nframes = nframes
def getnframes(self):
@@ -654,9 +612,10 @@ class Aifc_write:
def setcomptype(self, comptype, compname):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
- if comptype not in ('NONE', 'ULAW', 'ALAW', 'G722'):
- raise Error, 'unsupported compression type'
+ raise Error('cannot change parameters after starting to write')
+ if comptype not in (b'NONE', b'ulaw', b'ULAW',
+ b'alaw', b'ALAW', b'G722'):
+ raise Error('unsupported compression type')
self._comptype = comptype
self._compname = compname
@@ -671,12 +630,13 @@ class Aifc_write:
## raise Error, 'cannot change parameters after starting to write'
## self._version = version
- def setparams(self, info):
- nchannels, sampwidth, framerate, nframes, comptype, compname = info
+ def setparams(self, params):
+ nchannels, sampwidth, framerate, nframes, comptype, compname = params
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
- if comptype not in ('NONE', 'ULAW', 'ALAW', 'G722'):
- raise Error, 'unsupported compression type'
+ raise Error('cannot change parameters after starting to write')
+ if comptype not in (b'NONE', b'ulaw', b'ULAW',
+ b'alaw', b'ALAW', b'G722'):
+ raise Error('unsupported compression type')
self.setnchannels(nchannels)
self.setsampwidth(sampwidth)
self.setframerate(framerate)
@@ -685,17 +645,17 @@ class Aifc_write:
def getparams(self):
if not self._nchannels or not self._sampwidth or not self._framerate:
- raise Error, 'not all parameters set'
+ raise Error('not all parameters set')
return self._nchannels, self._sampwidth, self._framerate, \
self._nframes, self._comptype, self._compname
def setmark(self, id, pos, name):
if id <= 0:
- raise Error, 'marker ID must be > 0'
+ raise Error('marker ID must be > 0')
if pos < 0:
- raise Error, 'marker position must be >= 0'
- if type(name) != type(''):
- raise Error, 'marker name must be a string'
+ raise Error('marker position must be >= 0')
+ if not isinstance(name, bytes):
+ raise Error('marker name must be bytes')
for i in range(len(self._markers)):
if id == self._markers[i][0]:
self._markers[i] = id, pos, name
@@ -706,7 +666,7 @@ class Aifc_write:
for marker in self._markers:
if id == marker[0]:
return marker
- raise Error, 'marker %r does not exist' % (id,)
+ raise Error('marker {0!r} does not exist'.format(id))
def getmarkers(self):
if len(self._markers) == 0:
@@ -732,32 +692,29 @@ class Aifc_write:
self._patchheader()
def close(self):
- self._ensure_header_written(0)
- if self._datawritten & 1:
- # quick pad to even size
- self._file.write(chr(0))
- self._datawritten = self._datawritten + 1
- self._writemarkers()
- if self._nframeswritten != self._nframes or \
- self._datalength != self._datawritten or \
- self._marklength:
- self._patchheader()
- if self._comp:
- self._comp.CloseCompressor()
- self._comp = None
- # Prevent ref cycles
- self._convert = None
- self._file.close()
+ if self._file:
+ self._ensure_header_written(0)
+ if self._datawritten & 1:
+ # quick pad to even size
+ self._file.write(b'\x00')
+ self._datawritten = self._datawritten + 1
+ self._writemarkers()
+ if self._nframeswritten != self._nframes or \
+ self._datalength != self._datawritten or \
+ self._marklength:
+ self._patchheader()
+ # Prevent ref cycles
+ self._convert = None
+ self._file.close()
+ self._file = None
#
# Internal methods.
#
- def _comp_data(self, data):
- import cl
- dummy = self._comp.SetParam(cl.FRAME_BUFFER_SIZE, len(data))
- dummy = self._comp.SetParam(cl.COMPRESSED_BUFFER_SIZE, len(data))
- return self._comp.Compress(self._nframes, data)
+ def _lin2alaw(self, data):
+ import audioop
+ return audioop.lin2alaw(data, 2)
def _lin2ulaw(self, data):
import audioop
@@ -767,96 +724,61 @@ class Aifc_write:
import audioop
if not hasattr(self, '_adpcmstate'):
self._adpcmstate = None
- data, self._adpcmstate = audioop.lin2adpcm(data, 2,
- self._adpcmstate)
+ data, self._adpcmstate = audioop.lin2adpcm(data, 2, self._adpcmstate)
return data
def _ensure_header_written(self, datasize):
if not self._nframeswritten:
- if self._comptype in ('ULAW', 'ALAW'):
- if not self._sampwidth:
- self._sampwidth = 2
- if self._sampwidth != 2:
- raise Error, 'sample width must be 2 when compressing with ULAW or ALAW'
- if self._comptype == 'G722':
+ if self._comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
if not self._sampwidth:
self._sampwidth = 2
if self._sampwidth != 2:
- raise Error, 'sample width must be 2 when compressing with G7.22 (ADPCM)'
+ raise Error('sample width must be 2 when compressing '
+ 'with ulaw/ULAW, alaw/ALAW or G7.22 (ADPCM)')
if not self._nchannels:
- raise Error, '# channels not specified'
+ raise Error('# channels not specified')
if not self._sampwidth:
- raise Error, 'sample width not specified'
+ raise Error('sample width not specified')
if not self._framerate:
- raise Error, 'sampling rate not specified'
+ raise Error('sampling rate not specified')
self._write_header(datasize)
def _init_compression(self):
- if self._comptype == 'G722':
+ if self._comptype == b'G722':
self._convert = self._lin2adpcm
- return
- try:
- import cl
- except ImportError:
- if self._comptype == 'ULAW':
- try:
- import audioop
- self._convert = self._lin2ulaw
- return
- except ImportError:
- pass
- raise Error, 'cannot write compressed AIFF-C files'
- if self._comptype == 'ULAW':
- scheme = cl.G711_ULAW
- elif self._comptype == 'ALAW':
- scheme = cl.G711_ALAW
- else:
- raise Error, 'unsupported compression type'
- self._comp = cl.OpenCompressor(scheme)
- params = [cl.ORIGINAL_FORMAT, 0,
- cl.BITS_PER_COMPONENT, self._sampwidth * 8,
- cl.FRAME_RATE, self._framerate,
- cl.FRAME_BUFFER_SIZE, 100,
- cl.COMPRESSED_BUFFER_SIZE, 100]
- if self._nchannels == 1:
- params[1] = cl.MONO
- elif self._nchannels == 2:
- params[1] = cl.STEREO_INTERLEAVED
- else:
- raise Error, 'cannot compress more than 2 channels'
- self._comp.SetParams(params)
- # the compressor produces a header which we ignore
- dummy = self._comp.Compress(0, '')
- self._convert = self._comp_data
+ elif self._comptype in (b'ulaw', b'ULAW'):
+ self._convert = self._lin2ulaw
+ elif self._comptype in (b'alaw', b'ALAW'):
+ self._convert = self._lin2alaw
def _write_header(self, initlength):
- if self._aifc and self._comptype != 'NONE':
+ if self._aifc and self._comptype != b'NONE':
self._init_compression()
- self._file.write('FORM')
+ self._file.write(b'FORM')
if not self._nframes:
self._nframes = initlength // (self._nchannels * self._sampwidth)
self._datalength = self._nframes * self._nchannels * self._sampwidth
if self._datalength & 1:
self._datalength = self._datalength + 1
if self._aifc:
- if self._comptype in ('ULAW', 'ALAW'):
+ if self._comptype in (b'ulaw', b'ULAW', b'alaw', b'ALAW'):
self._datalength = self._datalength // 2
if self._datalength & 1:
self._datalength = self._datalength + 1
- elif self._comptype == 'G722':
+ elif self._comptype == b'G722':
self._datalength = (self._datalength + 3) // 4
if self._datalength & 1:
self._datalength = self._datalength + 1
self._form_length_pos = self._file.tell()
commlength = self._write_form_length(self._datalength)
if self._aifc:
- self._file.write('AIFC')
- self._file.write('FVER')
+ self._file.write(b'AIFC')
+ self._file.write(b'FVER')
_write_ulong(self._file, 4)
_write_ulong(self._file, self._version)
else:
- self._file.write('AIFF')
- self._file.write('COMM')
+ self._file.write(b'AIFF')
+ self._file.write(b'COMM')
_write_ulong(self._file, commlength)
_write_short(self._file, self._nchannels)
self._nframes_pos = self._file.tell()
@@ -866,7 +788,7 @@ class Aifc_write:
if self._aifc:
self._file.write(self._comptype)
_write_string(self._file, self._compname)
- self._file.write('SSND')
+ self._file.write(b'SSND')
self._ssnd_length_pos = self._file.tell()
_write_ulong(self._file, self._datalength + 8)
_write_ulong(self._file, 0)
@@ -889,7 +811,7 @@ class Aifc_write:
curpos = self._file.tell()
if self._datawritten & 1:
datalength = self._datawritten + 1
- self._file.write(chr(0))
+ self._file.write(b'\x00')
else:
datalength = self._datawritten
if datalength == self._datalength and \
@@ -910,7 +832,7 @@ class Aifc_write:
def _writemarkers(self):
if len(self._markers) == 0:
return
- self._file.write('MARK')
+ self._file.write(b'MARK')
length = 2
for marker in self._markers:
id, pos, name = marker
@@ -937,7 +859,7 @@ def open(f, mode=None):
elif mode in ('w', 'wb'):
return Aifc_write(f)
else:
- raise Error, "mode must be 'r', 'rb', 'w', or 'wb'"
+ raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
openfp = open # B/W compatibility
@@ -947,16 +869,16 @@ if __name__ == '__main__':
sys.argv.append('/usr/demos/data/audio/bach.aiff')
fn = sys.argv[1]
f = open(fn, 'r')
- print "Reading", fn
- print "nchannels =", f.getnchannels()
- print "nframes =", f.getnframes()
- print "sampwidth =", f.getsampwidth()
- print "framerate =", f.getframerate()
- print "comptype =", f.getcomptype()
- print "compname =", f.getcompname()
+ print("Reading", fn)
+ print("nchannels =", f.getnchannels())
+ print("nframes =", f.getnframes())
+ print("sampwidth =", f.getsampwidth())
+ print("framerate =", f.getframerate())
+ print("comptype =", f.getcomptype())
+ print("compname =", f.getcompname())
if sys.argv[2:]:
gn = sys.argv[2]
- print "Writing", gn
+ print("Writing", gn)
g = open(gn, 'w')
g.setparams(f.getparams())
while 1:
@@ -966,4 +888,4 @@ if __name__ == '__main__':
g.writeframes(data)
g.close()
f.close()
- print "Done."
+ print("Done.")
diff --git a/Lib/antigravity.py b/Lib/antigravity.py
index 7fb7d8282a7..7670187f83a 100644
--- a/Lib/antigravity.py
+++ b/Lib/antigravity.py
@@ -1,4 +1,17 @@
import webbrowser
+import hashlib
webbrowser.open("http://xkcd.com/353/")
+
+def geohash(latitude, longitude, datedow):
+ '''Compute geohash() using the Munroe algorithm.
+
+ >>> geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
+ 37.857713 -122.544543
+
+ '''
+ # http://xkcd.com/426/
+ h = hashlib.md5(datedow).hexdigest()
+ p, q = [('%f' % float.fromhex('0.' + x)) for x in (h[:16], h[16:32])]
+ print('%d%s %d%s' % (latitude, p[1:], longitude, q[1:]))
diff --git a/Lib/anydbm.py b/Lib/anydbm.py
deleted file mode 100644
index ba7e90510a0..00000000000
--- a/Lib/anydbm.py
+++ /dev/null
@@ -1,85 +0,0 @@
-"""Generic interface to all dbm clones.
-
-Instead of
-
- import dbm
- d = dbm.open(file, 'w', 0666)
-
-use
-
- import anydbm
- d = anydbm.open(file, 'w')
-
-The returned object is a dbhash, gdbm, dbm or dumbdbm object,
-dependent on the type of database being opened (determined by whichdb
-module) in the case of an existing dbm. If the dbm does not exist and
-the create or new flag ('c' or 'n') was specified, the dbm type will
-be determined by the availability of the modules (tested in the above
-order).
-
-It has the following interface (key and data are strings):
-
- d[key] = data # store data at key (may override data at
- # existing key)
- data = d[key] # retrieve data at key (raise KeyError if no
- # such key)
- del d[key] # delete data stored at key (raises KeyError
- # if no such key)
- flag = key in d # true if the key exists
- list = d.keys() # return a list of all existing keys (slow!)
-
-Future versions may change the order in which implementations are
-tested for existence, and add interfaces to other dbm-like
-implementations.
-"""
-
-class error(Exception):
- pass
-
-_names = ['dbhash', 'gdbm', 'dbm', 'dumbdbm']
-_errors = [error]
-_defaultmod = None
-
-for _name in _names:
- try:
- _mod = __import__(_name)
- except ImportError:
- continue
- if not _defaultmod:
- _defaultmod = _mod
- _errors.append(_mod.error)
-
-if not _defaultmod:
- raise ImportError, "no dbm clone found; tried %s" % _names
-
-error = tuple(_errors)
-
-def open(file, flag='r', mode=0666):
- """Open or create database at path given by *file*.
-
- Optional argument *flag* can be 'r' (default) for read-only access, 'w'
- for read-write access of an existing database, 'c' for read-write access
- to a new or existing database, and 'n' for read-write access to a new
- database.
-
- Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
- only if it doesn't exist; and 'n' always creates a new database.
- """
-
- # guess the type of an existing database
- from whichdb import whichdb
- result=whichdb(file)
- if result is None:
- # db doesn't exist
- if 'c' in flag or 'n' in flag:
- # file doesn't exist and the new
- # flag was used so use default type
- mod = _defaultmod
- else:
- raise error, "need 'c' or 'n' flag to open new db"
- elif result == "":
- # db type cannot be determined
- raise error, "db type could not be determined"
- else:
- mod = __import__(result)
- return mod.open(file, flag, mode)
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 30bae57896c..eb894caebc2 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -89,11 +89,7 @@ import re as _re
import sys as _sys
import textwrap as _textwrap
-from gettext import gettext as _
-
-
-def _callable(obj):
- return hasattr(obj, '__call__') or hasattr(obj, '__bases__')
+from gettext import gettext as _, ngettext
SUPPRESS = '==SUPPRESS=='
@@ -1024,9 +1020,13 @@ class _SubParsersAction(Action):
class _ChoicesPseudoAction(Action):
- def __init__(self, name, help):
+ def __init__(self, name, aliases, help):
+ metavar = dest = name
+ if aliases:
+ metavar += ' (%s)' % ', '.join(aliases)
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
- sup.__init__(option_strings=[], dest=name, help=help)
+ sup.__init__(option_strings=[], dest=dest, help=help,
+ metavar=metavar)
def __init__(self,
option_strings,
@@ -1054,15 +1054,22 @@ class _SubParsersAction(Action):
if kwargs.get('prog') is None:
kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
+ aliases = kwargs.pop('aliases', ())
+
# create a pseudo-action to hold the choice help
if 'help' in kwargs:
help = kwargs.pop('help')
- choice_action = self._ChoicesPseudoAction(name, help)
+ choice_action = self._ChoicesPseudoAction(name, aliases, help)
self._choices_actions.append(choice_action)
# create the parser and add it to the map
parser = self._parser_class(**kwargs)
self._name_parser_map[name] = parser
+
+ # make parser available under aliases also
+ for alias in aliases:
+ self._name_parser_map[alias] = parser
+
return parser
def _get_subactions(self):
@@ -1080,8 +1087,9 @@ class _SubParsersAction(Action):
try:
parser = self._name_parser_map[parser_name]
except KeyError:
- tup = parser_name, ', '.join(self._name_parser_map)
- msg = _('unknown parser %r (choices: %s)') % tup
+ args = {'parser_name': parser_name,
+ 'choices': ', '.join(self._name_parser_map)}
+ msg = _('unknown parser %(parser_name)r (choices: %(choices)s)') % args
raise ArgumentError(self, msg)
# parse all the remaining options into the namespace
@@ -1152,8 +1160,6 @@ class Namespace(_AttributeHolder):
for name in kwargs:
setattr(self, name, kwargs[name])
- __hash__ = None
-
def __eq__(self, other):
return vars(self) == vars(other)
@@ -1276,13 +1282,13 @@ class _ActionsContainer(object):
# create the action object, and add it to the parser
action_class = self._pop_action_class(kwargs)
- if not _callable(action_class):
+ if not callable(action_class):
raise ValueError('unknown action "%s"' % (action_class,))
action = action_class(**kwargs)
# raise an error if the action type is not callable
type_func = self._registry_get('type', action.type, action.type)
- if not _callable(type_func):
+ if not callable(type_func):
raise ValueError('%r is not callable' % (type_func,))
# raise an error if the metavar does not match the type
@@ -1391,10 +1397,11 @@ class _ActionsContainer(object):
for option_string in args:
# error on strings that don't start with an appropriate prefix
if not option_string[0] in self.prefix_chars:
- msg = _('invalid option string %r: '
- 'must start with a character %r')
- tup = option_string, self.prefix_chars
- raise ValueError(msg % tup)
+ args = {'option': option_string,
+ 'prefix_chars': self.prefix_chars}
+ msg = _('invalid option string %(option)r: '
+ 'must start with a character %(prefix_chars)r')
+ raise ValueError(msg % args)
# strings starting with two prefix characters are long options
option_strings.append(option_string)
@@ -1447,7 +1454,9 @@ class _ActionsContainer(object):
conflict_handler(action, confl_optionals)
def _handle_conflict_error(self, action, conflicting_actions):
- message = _('conflicting option string(s): %s')
+ message = ngettext('conflicting option string: %s',
+ 'conflicting option strings: %s',
+ len(conflicting_actions))
conflict_string = ', '.join([option_string
for option_string, action
in conflicting_actions])
@@ -1948,7 +1957,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# twice (which may fail) if the argument was given, but
# only if it was defined already in the namespace
if (action.default is not None and
- isinstance(action.default, basestring) and
+ isinstance(action.default, str) and
hasattr(namespace, action.dest) and
action.default is getattr(namespace, action.dest)):
setattr(namespace, action.dest,
@@ -2016,7 +2025,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
OPTIONAL: _('expected at most one argument'),
ONE_OR_MORE: _('expected at least one argument'),
}
- default = _('expected %s argument(s)') % action.nargs
+ default = ngettext('expected %s argument',
+ 'expected %s arguments',
+ action.nargs) % action.nargs
msg = nargs_errors.get(action.nargs, default)
raise ArgumentError(action, msg)
@@ -2072,8 +2083,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
if len(option_tuples) > 1:
options = ', '.join([option_string
for action, option_string, explicit_arg in option_tuples])
- tup = arg_string, options
- self.error(_('ambiguous option: %s could match %s') % tup)
+ args = {'option': arg_string, 'matches': options}
+ msg = _('ambiguous option: %(option)s could match %(matches)s')
+ self.error(msg % args)
# if exactly one action matched, this segmentation is good,
# so return the parsed action
@@ -2198,7 +2210,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
value = action.const
else:
value = action.default
- if isinstance(value, basestring):
+ if isinstance(value, str):
value = self._get_value(action, value)
self._check_value(action, value)
@@ -2238,7 +2250,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def _get_value(self, action, arg_string):
type_func = self._registry_get('type', action.type, action.type)
- if not _callable(type_func):
+ if not callable(type_func):
msg = _('%r is not callable')
raise ArgumentError(action, msg % type_func)
@@ -2255,8 +2267,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# TypeErrors or ValueErrors also indicate errors
except (TypeError, ValueError):
name = getattr(action.type, '__name__', repr(action.type))
- msg = _('invalid %s value: %r')
- raise ArgumentError(action, msg % (name, arg_string))
+ args = {'type': name, 'value': arg_string}
+ msg = _('invalid %(type)s value: %(value)r')
+ raise ArgumentError(action, msg % args)
# return the converted value
return result
@@ -2264,9 +2277,10 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def _check_value(self, action, value):
# converted value must be one of the choices (if specified)
if action.choices is not None and value not in action.choices:
- tup = value, ', '.join(map(repr, action.choices))
- msg = _('invalid choice: %r (choose from %s)') % tup
- raise ArgumentError(action, msg)
+ args = {'value': value,
+ 'choices': ', '.join(map(repr, action.choices))}
+ msg = _('invalid choice: %(value)r (choose from %(choices)s)')
+ raise ArgumentError(action, msg % args)
# =======================
# Help-formatting methods
@@ -2358,4 +2372,5 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
should either exit or raise an exception.
"""
self.print_usage(_sys.stderr)
- self.exit(2, _('%s: error: %s\n') % (self.prog, message))
+ args = {'prog': self.prog, 'message': message}
+ self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
diff --git a/Lib/ast.py b/Lib/ast.py
index fd5dfdba676..fb5adac8fd9 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -1,4 +1,3 @@
-# -*- coding: utf-8 -*-
"""
ast
~~~
@@ -41,16 +40,16 @@ def literal_eval(node_or_string):
"""
Safely evaluate an expression node or a string containing a Python
expression. The string or node provided may only consist of the following
- Python literal structures: strings, numbers, tuples, lists, dicts, booleans,
- and None.
+ Python literal structures: strings, bytes, numbers, tuples, lists, dicts,
+ sets, booleans, and None.
"""
_safe_names = {'None': None, 'True': True, 'False': False}
- if isinstance(node_or_string, basestring):
+ if isinstance(node_or_string, str):
node_or_string = parse(node_or_string, mode='eval')
if isinstance(node_or_string, Expression):
node_or_string = node_or_string.body
def _convert(node):
- if isinstance(node, Str):
+ if isinstance(node, (Str, Bytes)):
return node.s
elif isinstance(node, Num):
return node.n
@@ -58,25 +57,33 @@ def literal_eval(node_or_string):
return tuple(map(_convert, node.elts))
elif isinstance(node, List):
return list(map(_convert, node.elts))
+ elif isinstance(node, Set):
+ return set(map(_convert, node.elts))
elif isinstance(node, Dict):
return dict((_convert(k), _convert(v)) for k, v
in zip(node.keys, node.values))
elif isinstance(node, Name):
if node.id in _safe_names:
return _safe_names[node.id]
+ elif isinstance(node, UnaryOp) and \
+ isinstance(node.op, (UAdd, USub)) and \
+ isinstance(node.operand, (Num, UnaryOp, BinOp)):
+ operand = _convert(node.operand)
+ if isinstance(node.op, UAdd):
+ return + operand
+ else:
+ return - operand
elif isinstance(node, BinOp) and \
isinstance(node.op, (Add, Sub)) and \
- isinstance(node.right, Num) and \
- isinstance(node.right.n, complex) and \
- isinstance(node.left, Num) and \
- isinstance(node.left.n, (int, long, float)):
- left = node.left.n
- right = node.right.n
+ isinstance(node.right, (Num, UnaryOp, BinOp)) and \
+ isinstance(node.left, (Num, UnaryOp, BinOp)):
+ left = _convert(node.left)
+ right = _convert(node.right)
if isinstance(node.op, Add):
return left + right
else:
return left - right
- raise ValueError('malformed string')
+ raise ValueError('malformed node or string: ' + repr(node))
return _convert(node_or_string)
diff --git a/Lib/asynchat.py b/Lib/asynchat.py
index 911833d58ce..65585129cea 100644
--- a/Lib/asynchat.py
+++ b/Lib/asynchat.py
@@ -45,12 +45,22 @@ command will be accumulated (using your own 'collect_incoming_data'
method) up to the terminator, and then control will be returned to
you - by calling your self.found_terminator() method.
"""
-
import socket
import asyncore
from collections import deque
-from sys import py3kwarning
-from warnings import filterwarnings, catch_warnings
+
+def buffer(obj, start=None, stop=None):
+ # if memoryview objects gain slicing semantics,
+ # this function will change for the better
+ # memoryview used for the TypeError
+ memoryview(obj)
+ if start == None:
+ start = 0
+ if stop == None:
+ stop = len(obj)
+ x = obj[start:stop]
+ ## print("buffer type is: %s"%(type(x),))
+ return x
class async_chat (asyncore.dispatcher):
"""This is an abstract class. You must derive from this class, and add
@@ -61,9 +71,15 @@ class async_chat (asyncore.dispatcher):
ac_in_buffer_size = 4096
ac_out_buffer_size = 4096
+ # we don't want to enable the use of encoding by default, because that is a
+ # sign of an application bug that we don't want to pass silently
+
+ use_encoding = 0
+ encoding = 'latin1'
+
def __init__ (self, sock=None, map=None):
# for string terminator matching
- self.ac_in_buffer = ''
+ self.ac_in_buffer = b''
# we use a list here rather than cStringIO for a few reasons...
# del lst[:] is faster than sio.truncate(0)
@@ -85,7 +101,7 @@ class async_chat (asyncore.dispatcher):
self.incoming.append(data)
def _get_data(self):
- d = ''.join(self.incoming)
+ d = b''.join(self.incoming)
del self.incoming[:]
return d
@@ -94,6 +110,8 @@ class async_chat (asyncore.dispatcher):
def set_terminator (self, term):
"Set the input delimiter. Can be a fixed string of any length, an integer, or None"
+ if isinstance(term, str) and self.use_encoding:
+ term = bytes(term, self.encoding)
self.terminator = term
def get_terminator (self):
@@ -108,10 +126,12 @@ class async_chat (asyncore.dispatcher):
try:
data = self.recv (self.ac_in_buffer_size)
- except socket.error, why:
+ except socket.error as why:
self.handle_error()
return
+ if isinstance(data, str) and self.use_encoding:
+ data = bytes(str, self.encoding)
self.ac_in_buffer = self.ac_in_buffer + data
# Continue to search for self.terminator in self.ac_in_buffer,
@@ -125,13 +145,13 @@ class async_chat (asyncore.dispatcher):
if not terminator:
# no terminator, collect it all
self.collect_incoming_data (self.ac_in_buffer)
- self.ac_in_buffer = ''
- elif isinstance(terminator, int) or isinstance(terminator, long):
+ self.ac_in_buffer = b''
+ elif isinstance(terminator, int):
# numeric terminator
n = terminator
if lb < n:
self.collect_incoming_data (self.ac_in_buffer)
- self.ac_in_buffer = ''
+ self.ac_in_buffer = b''
self.terminator = self.terminator - lb
else:
self.collect_incoming_data (self.ac_in_buffer[:n])
@@ -168,7 +188,7 @@ class async_chat (asyncore.dispatcher):
else:
# no prefix, collect it all
self.collect_incoming_data (self.ac_in_buffer)
- self.ac_in_buffer = ''
+ self.ac_in_buffer = b''
def handle_write (self):
self.initiate_send()
@@ -179,7 +199,7 @@ class async_chat (asyncore.dispatcher):
def push (self, data):
sabs = self.ac_out_buffer_size
if len(data) > sabs:
- for i in xrange(0, len(data), sabs):
+ for i in range(0, len(data), sabs):
self.producer_fifo.append(data[i:i+sabs])
else:
self.producer_fifo.append(data)
@@ -212,16 +232,15 @@ class async_chat (asyncore.dispatcher):
if not first:
del self.producer_fifo[0]
if first is None:
+ ## print("first is None")
self.handle_close()
return
+ ## print("first is not None")
# handle classic producer behavior
obs = self.ac_out_buffer_size
try:
- with catch_warnings():
- if py3kwarning:
- filterwarnings("ignore", ".*buffer", DeprecationWarning)
- data = buffer(first, 0, obs)
+ data = buffer(first, 0, obs)
except TypeError:
data = first.more()
if data:
@@ -230,6 +249,9 @@ class async_chat (asyncore.dispatcher):
del self.producer_fifo[0]
continue
+ if isinstance(data, str) and self.use_encoding:
+ data = bytes(data, self.encoding)
+
# send the data
try:
num_sent = self.send(data)
@@ -247,7 +269,7 @@ class async_chat (asyncore.dispatcher):
def discard_buffers (self):
# Emergencies only!
- self.ac_in_buffer = ''
+ self.ac_in_buffer = b''
del self.incoming[:]
self.producer_fifo.clear()
@@ -264,7 +286,7 @@ class simple_producer:
return result
else:
result = self.data
- self.data = ''
+ self.data = b''
return result
class fifo:
diff --git a/Lib/asyncore.py b/Lib/asyncore.py
index 29099bdf5c0..d379ba820c3 100644
--- a/Lib/asyncore.py
+++ b/Lib/asyncore.py
@@ -112,7 +112,7 @@ def readwrite(obj, flags):
obj.handle_expt_event()
if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
obj.handle_close()
- except socket.error, e:
+ except socket.error as e:
if e.args[0] not in _DISCONNECTED:
obj.handle_error()
else:
@@ -127,7 +127,7 @@ def poll(timeout=0.0, map=None):
map = socket_map
if map:
r = []; w = []; e = []
- for fd, obj in map.items():
+ for fd, obj in list(map.items()):
is_r = obj.readable()
is_w = obj.writable()
if is_r:
@@ -143,7 +143,7 @@ def poll(timeout=0.0, map=None):
try:
r, w, e = select.select(r, w, e, timeout)
- except select.error, err:
+ except select.error as err:
if err.args[0] != EINTR:
raise
else:
@@ -176,7 +176,7 @@ def poll2(timeout=0.0, map=None):
timeout = int(timeout*1000)
pollster = select.poll()
if map:
- for fd, obj in map.items():
+ for fd, obj in list(map.items()):
flags = 0
if obj.readable():
flags |= select.POLLIN | select.POLLPRI
@@ -190,7 +190,7 @@ def poll2(timeout=0.0, map=None):
pollster.register(fd, flags)
try:
r = pollster.poll(timeout)
- except select.error, err:
+ except select.error as err:
if err.args[0] != EINTR:
raise
r = []
@@ -248,7 +248,7 @@ class dispatcher:
# passed be connected.
try:
self.addr = sock.getpeername()
- except socket.error, err:
+ except socket.error as err:
if err.args[0] in (ENOTCONN, EINVAL):
# To handle the case where we got an unconnected
# socket.
@@ -373,7 +373,7 @@ class dispatcher:
try:
result = self.socket.send(data)
return result
- except socket.error, why:
+ except socket.error as why:
if why.args[0] == EWOULDBLOCK:
return 0
elif why.args[0] in _DISCONNECTED:
@@ -389,14 +389,14 @@ class dispatcher:
# a closed connection is indicated by signaling
# a read condition, and having recv() return 0.
self.handle_close()
- return ''
+ return b''
else:
return data
- except socket.error, why:
+ except socket.error as why:
# winsock sometimes raises ENOTCONN
if why.args[0] in _DISCONNECTED:
self.handle_close()
- return ''
+ return b''
else:
raise
@@ -407,7 +407,7 @@ class dispatcher:
self.del_channel()
try:
self.socket.close()
- except socket.error, why:
+ except socket.error as why:
if why.args[0] not in (ENOTCONN, EBADF):
raise
@@ -420,8 +420,8 @@ class dispatcher:
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}
+ 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
@@ -434,7 +434,7 @@ class dispatcher:
def log_info(self, message, type='info'):
if type not in self.ignore_log_types:
- print '%s: %s' % (type, message)
+ print('%s: %s' % (type, message))
def handle_read_event(self):
if self.accepting:
@@ -515,7 +515,13 @@ class dispatcher:
self.log_info('unhandled connect event', 'warning')
def handle_accept(self):
- self.log_info('unhandled accept event', 'warning')
+ pair = self.accept()
+ if pair is not None:
+ self.handle_accepted(*pair)
+
+ def handle_accepted(self, sock, addr):
+ sock.close()
+ self.log_info('unhandled accepted event', 'warning')
def handle_close(self):
self.log_info('unhandled close event', 'warning')
@@ -530,7 +536,7 @@ class dispatcher_with_send(dispatcher):
def __init__(self, sock=None, map=None):
dispatcher.__init__(self, sock, map)
- self.out_buffer = ''
+ self.out_buffer = b''
def initiate_send(self):
num_sent = 0
@@ -576,10 +582,10 @@ def compact_traceback():
def close_all(map=None, ignore_all=False):
if map is None:
map = socket_map
- for x in map.values():
+ for x in list(map.values()):
try:
x.close()
- except OSError, x:
+ except OSError as x:
if x.args[0] == EBADF:
pass
elif not ignore_all:
diff --git a/Lib/atexit.py b/Lib/atexit.py
deleted file mode 100644
index 93fddf7f99a..00000000000
--- a/Lib/atexit.py
+++ /dev/null
@@ -1,65 +0,0 @@
-"""
-atexit.py - allow programmer to define multiple exit functions to be executed
-upon normal program termination.
-
-One public function, register, is defined.
-"""
-
-__all__ = ["register"]
-
-import sys
-
-_exithandlers = []
-def _run_exitfuncs():
- """run any registered exit functions
-
- _exithandlers is traversed in reverse order so functions are executed
- last in, first out.
- """
-
- exc_info = None
- while _exithandlers:
- func, targs, kargs = _exithandlers.pop()
- try:
- func(*targs, **kargs)
- except SystemExit:
- exc_info = sys.exc_info()
- except:
- import traceback
- print >> sys.stderr, "Error in atexit._run_exitfuncs:"
- traceback.print_exc()
- exc_info = sys.exc_info()
-
- if exc_info is not None:
- raise exc_info[0], exc_info[1], exc_info[2]
-
-
-def register(func, *targs, **kargs):
- """register a function to be executed upon normal program termination
-
- func - function to be called at exit
- targs - optional arguments to pass to func
- kargs - optional keyword arguments to pass to func
-
- func is returned to facilitate usage as a decorator.
- """
- _exithandlers.append((func, targs, kargs))
- return func
-
-if hasattr(sys, "exitfunc"):
- # Assume it's another registered exit function - append it to our list
- register(sys.exitfunc)
-sys.exitfunc = _run_exitfuncs
-
-if __name__ == "__main__":
- def x1():
- print "running x1"
- def x2(n):
- print "running x2(%r)" % (n,)
- def x3(n, kwd=None):
- print "running x3(%r, kwd=%r)" % (n, kwd)
-
- register(x1)
- register(x2, 12)
- register(x3, 5, "bar")
- register(x3, "no kwd args")
diff --git a/Lib/audiodev.py b/Lib/audiodev.py
deleted file mode 100644
index b6831a692f5..00000000000
--- a/Lib/audiodev.py
+++ /dev/null
@@ -1,260 +0,0 @@
-"""Classes for manipulating audio devices (currently only for Sun and SGI)"""
-from warnings import warnpy3k
-warnpy3k("the audiodev module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-__all__ = ["error","AudioDev"]
-
-class error(Exception):
- pass
-
-class Play_Audio_sgi:
- # Private instance variables
-## if 0: access frameratelist, nchannelslist, sampwidthlist, oldparams, \
-## params, config, inited_outrate, inited_width, \
-## inited_nchannels, port, converter, classinited: private
-
- classinited = 0
- frameratelist = nchannelslist = sampwidthlist = None
-
- def initclass(self):
- import AL
- self.frameratelist = [
- (48000, AL.RATE_48000),
- (44100, AL.RATE_44100),
- (32000, AL.RATE_32000),
- (22050, AL.RATE_22050),
- (16000, AL.RATE_16000),
- (11025, AL.RATE_11025),
- ( 8000, AL.RATE_8000),
- ]
- self.nchannelslist = [
- (1, AL.MONO),
- (2, AL.STEREO),
- (4, AL.QUADRO),
- ]
- self.sampwidthlist = [
- (1, AL.SAMPLE_8),
- (2, AL.SAMPLE_16),
- (3, AL.SAMPLE_24),
- ]
- self.classinited = 1
-
- def __init__(self):
- import al, AL
- if not self.classinited:
- self.initclass()
- self.oldparams = []
- self.params = [AL.OUTPUT_RATE, 0]
- self.config = al.newconfig()
- self.inited_outrate = 0
- self.inited_width = 0
- self.inited_nchannels = 0
- self.converter = None
- self.port = None
- return
-
- def __del__(self):
- if self.port:
- self.stop()
- if self.oldparams:
- import al, AL
- al.setparams(AL.DEFAULT_DEVICE, self.oldparams)
- self.oldparams = []
-
- def wait(self):
- if not self.port:
- return
- import time
- while self.port.getfilled() > 0:
- time.sleep(0.1)
- self.stop()
-
- def stop(self):
- if self.port:
- self.port.closeport()
- self.port = None
- if self.oldparams:
- import al, AL
- al.setparams(AL.DEFAULT_DEVICE, self.oldparams)
- self.oldparams = []
-
- def setoutrate(self, rate):
- for (raw, cooked) in self.frameratelist:
- if rate == raw:
- self.params[1] = cooked
- self.inited_outrate = 1
- break
- else:
- raise error, 'bad output rate'
-
- def setsampwidth(self, width):
- for (raw, cooked) in self.sampwidthlist:
- if width == raw:
- self.config.setwidth(cooked)
- self.inited_width = 1
- break
- else:
- if width == 0:
- import AL
- self.inited_width = 0
- self.config.setwidth(AL.SAMPLE_16)
- self.converter = self.ulaw2lin
- else:
- raise error, 'bad sample width'
-
- def setnchannels(self, nchannels):
- for (raw, cooked) in self.nchannelslist:
- if nchannels == raw:
- self.config.setchannels(cooked)
- self.inited_nchannels = 1
- break
- else:
- raise error, 'bad # of channels'
-
- def writeframes(self, data):
- if not (self.inited_outrate and self.inited_nchannels):
- raise error, 'params not specified'
- if not self.port:
- import al, AL
- self.port = al.openport('Python', 'w', self.config)
- self.oldparams = self.params[:]
- al.getparams(AL.DEFAULT_DEVICE, self.oldparams)
- al.setparams(AL.DEFAULT_DEVICE, self.params)
- if self.converter:
- data = self.converter(data)
- self.port.writesamps(data)
-
- def getfilled(self):
- if self.port:
- return self.port.getfilled()
- else:
- return 0
-
- def getfillable(self):
- if self.port:
- return self.port.getfillable()
- else:
- return self.config.getqueuesize()
-
- # private methods
-## if 0: access *: private
-
- def ulaw2lin(self, data):
- import audioop
- return audioop.ulaw2lin(data, 2)
-
-class Play_Audio_sun:
-## if 0: access outrate, sampwidth, nchannels, inited_outrate, inited_width, \
-## inited_nchannels, converter: private
-
- def __init__(self):
- self.outrate = 0
- self.sampwidth = 0
- self.nchannels = 0
- self.inited_outrate = 0
- self.inited_width = 0
- self.inited_nchannels = 0
- self.converter = None
- self.port = None
- return
-
- def __del__(self):
- self.stop()
-
- def setoutrate(self, rate):
- self.outrate = rate
- self.inited_outrate = 1
-
- def setsampwidth(self, width):
- self.sampwidth = width
- self.inited_width = 1
-
- def setnchannels(self, nchannels):
- self.nchannels = nchannels
- self.inited_nchannels = 1
-
- def writeframes(self, data):
- if not (self.inited_outrate and self.inited_width and self.inited_nchannels):
- raise error, 'params not specified'
- if not self.port:
- import sunaudiodev, SUNAUDIODEV
- self.port = sunaudiodev.open('w')
- info = self.port.getinfo()
- info.o_sample_rate = self.outrate
- info.o_channels = self.nchannels
- if self.sampwidth == 0:
- info.o_precision = 8
- self.o_encoding = SUNAUDIODEV.ENCODING_ULAW
- # XXX Hack, hack -- leave defaults
- else:
- info.o_precision = 8 * self.sampwidth
- info.o_encoding = SUNAUDIODEV.ENCODING_LINEAR
- self.port.setinfo(info)
- if self.converter:
- data = self.converter(data)
- self.port.write(data)
-
- def wait(self):
- if not self.port:
- return
- self.port.drain()
- self.stop()
-
- def stop(self):
- if self.port:
- self.port.flush()
- self.port.close()
- self.port = None
-
- def getfilled(self):
- if self.port:
- return self.port.obufcount()
- else:
- return 0
-
-## # Nobody remembers what this method does, and it's broken. :-(
-## def getfillable(self):
-## return BUFFERSIZE - self.getfilled()
-
-def AudioDev():
- # Dynamically try to import and use a platform specific module.
- try:
- import al
- except ImportError:
- try:
- import sunaudiodev
- return Play_Audio_sun()
- except ImportError:
- try:
- import Audio_mac
- except ImportError:
- raise error, 'no audio device'
- else:
- return Audio_mac.Play_Audio_mac()
- else:
- return Play_Audio_sgi()
-
-def test(fn = None):
- import sys
- if sys.argv[1:]:
- fn = sys.argv[1]
- else:
- fn = 'f:just samples:just.aif'
- import aifc
- af = aifc.open(fn, 'r')
- print fn, af.getparams()
- p = AudioDev()
- p.setoutrate(af.getframerate())
- p.setsampwidth(af.getsampwidth())
- p.setnchannels(af.getnchannels())
- BUFSIZ = af.getframerate()/af.getsampwidth()/af.getnchannels()
- while 1:
- data = af.readframes(BUFSIZ)
- if not data: break
- print len(data)
- p.writeframes(data)
- p.wait()
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/base64.py b/Lib/base64.py
index 85204dd022a..895d813f7ee 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -1,9 +1,10 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""RFC 3548: Base16, Base32, Base64 Data Encodings"""
# Modified 04-Oct-1995 by Jack Jansen to use binascii module
# Modified 30-Dec-2003 by Barry Warsaw to add full RFC 3548 support
+# Modified 22-May-2007 by Guido van Rossum to use bytes everywhere
import re
import struct
@@ -12,7 +13,7 @@ import binascii
__all__ = [
# Legacy interface exports traditional RFC 1521 Base64 encodings
- 'encode', 'decode', 'encodestring', 'decodestring',
+ 'encode', 'decode', 'encodebytes', 'decodebytes',
# Generalized interface for other encodings
'b64encode', 'b64decode', 'b32encode', 'b32decode',
'b16encode', 'b16decode',
@@ -25,124 +26,142 @@ __all__ = [
'urlsafe_b64encode', 'urlsafe_b64decode',
]
-_translation = [chr(_x) for _x in range(256)]
-EMPTYSTRING = ''
+
+bytes_types = (bytes, bytearray) # Types acceptable as binary data
def _translate(s, altchars):
- translation = _translation[:]
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
+ translation = bytearray(range(256))
for k, v in altchars.items():
- translation[ord(k)] = v
- return s.translate(''.join(translation))
+ translation[ord(k)] = v[0]
+ return s.translate(translation)
+
-
# Base64 encoding/decoding uses binascii
def b64encode(s, altchars=None):
- """Encode a string using Base64.
+ """Encode a byte string using Base64.
- s is the string to encode. Optional altchars must be a string of at least
- length 2 (additional characters are ignored) which specifies an
- alternative alphabet for the '+' and '/' characters. This allows an
- application to e.g. generate url or filesystem safe Base64 strings.
+ s is the byte string to encode. Optional altchars must be a byte
+ string of length 2 which specifies an alternative alphabet for the
+ '+' and '/' characters. This allows an application to
+ e.g. generate url or filesystem safe Base64 strings.
- The encoded string is returned.
+ The encoded byte string is returned.
"""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
# Strip off the trailing newline
encoded = binascii.b2a_base64(s)[:-1]
if altchars is not None:
- return _translate(encoded, {'+': altchars[0], '/': altchars[1]})
+ if not isinstance(altchars, bytes_types):
+ raise TypeError("expected bytes, not %s"
+ % altchars.__class__.__name__)
+ assert len(altchars) == 2, repr(altchars)
+ return _translate(encoded, {'+': altchars[0:1], '/': altchars[1:2]})
return encoded
-def b64decode(s, altchars=None):
- """Decode a Base64 encoded string.
+def b64decode(s, altchars=None, validate=False):
+ """Decode a Base64 encoded byte string.
+
+ s is the byte string to decode. Optional altchars must be a
+ string of length 2 which specifies the alternative alphabet used
+ instead of the '+' and '/' characters.
- s is the string to decode. Optional altchars must be a string of at least
- length 2 (additional characters are ignored) which specifies the
- alternative alphabet used instead of the '+' and '/' characters.
+ The decoded string is returned. A binascii.Error is raised if s is
+ incorrectly padded.
- The decoded string is returned. A TypeError is raised if s were
- incorrectly padded or if there are non-alphabet characters present in the
- string.
+ If validate is False (the default), non-base64-alphabet characters are
+ discarded prior to the padding check. If validate is True,
+ non-base64-alphabet characters in the input result in a binascii.Error.
"""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
if altchars is not None:
- s = _translate(s, {altchars[0]: '+', altchars[1]: '/'})
- try:
- return binascii.a2b_base64(s)
- except binascii.Error, msg:
- # Transform this exception for consistency
- raise TypeError(msg)
+ if not isinstance(altchars, bytes_types):
+ raise TypeError("expected bytes, not %s"
+ % altchars.__class__.__name__)
+ assert len(altchars) == 2, repr(altchars)
+ s = _translate(s, {chr(altchars[0]): b'+', chr(altchars[1]): b'/'})
+ if validate and not re.match(b'^[A-Za-z0-9+/]*={0,2}$', s):
+ raise binascii.Error('Non-base64 digit found')
+ return binascii.a2b_base64(s)
def standard_b64encode(s):
- """Encode a string using the standard Base64 alphabet.
+ """Encode a byte string using the standard Base64 alphabet.
- s is the string to encode. The encoded string is returned.
+ s is the byte string to encode. The encoded byte string is returned.
"""
return b64encode(s)
def standard_b64decode(s):
- """Decode a string encoded with the standard Base64 alphabet.
+ """Decode a byte string encoded with the standard Base64 alphabet.
- s is the string to decode. The decoded string is returned. A TypeError
- is raised if the string is incorrectly padded or if there are non-alphabet
- characters present in the string.
+ s is the byte string to decode. The decoded byte string is
+ returned. binascii.Error is raised if the input is incorrectly
+ padded or if there are non-alphabet characters present in the
+ input.
"""
return b64decode(s)
def urlsafe_b64encode(s):
- """Encode a string using a url-safe Base64 alphabet.
+ """Encode a byte string using a url-safe Base64 alphabet.
- s is the string to encode. The encoded string is returned. The alphabet
- uses '-' instead of '+' and '_' instead of '/'.
+ s is the byte string to encode. The encoded byte string is
+ returned. The alphabet uses '-' instead of '+' and '_' instead of
+ '/'.
"""
- return b64encode(s, '-_')
+ return b64encode(s, b'-_')
def urlsafe_b64decode(s):
- """Decode a string encoded with the standard Base64 alphabet.
+ """Decode a byte string encoded with the standard Base64 alphabet.
- s is the string to decode. The decoded string is returned. A TypeError
- is raised if the string is incorrectly padded or if there are non-alphabet
- characters present in the string.
+ s is the byte string to decode. The decoded byte string is
+ returned. binascii.Error is raised if the input is incorrectly
+ padded or if there are non-alphabet characters present in the
+ input.
The alphabet uses '-' instead of '+' and '_' instead of '/'.
"""
- return b64decode(s, '-_')
+ return b64decode(s, b'-_')
+
-
# Base32 encoding/decoding must be done in Python
_b32alphabet = {
- 0: 'A', 9: 'J', 18: 'S', 27: '3',
- 1: 'B', 10: 'K', 19: 'T', 28: '4',
- 2: 'C', 11: 'L', 20: 'U', 29: '5',
- 3: 'D', 12: 'M', 21: 'V', 30: '6',
- 4: 'E', 13: 'N', 22: 'W', 31: '7',
- 5: 'F', 14: 'O', 23: 'X',
- 6: 'G', 15: 'P', 24: 'Y',
- 7: 'H', 16: 'Q', 25: 'Z',
- 8: 'I', 17: 'R', 26: '2',
+ 0: b'A', 9: b'J', 18: b'S', 27: b'3',
+ 1: b'B', 10: b'K', 19: b'T', 28: b'4',
+ 2: b'C', 11: b'L', 20: b'U', 29: b'5',
+ 3: b'D', 12: b'M', 21: b'V', 30: b'6',
+ 4: b'E', 13: b'N', 22: b'W', 31: b'7',
+ 5: b'F', 14: b'O', 23: b'X',
+ 6: b'G', 15: b'P', 24: b'Y',
+ 7: b'H', 16: b'Q', 25: b'Z',
+ 8: b'I', 17: b'R', 26: b'2',
}
-_b32tab = _b32alphabet.items()
-_b32tab.sort()
-_b32tab = [v for k, v in _b32tab]
-_b32rev = dict([(v, long(k)) for k, v in _b32alphabet.items()])
+_b32tab = [v[0] for k, v in sorted(_b32alphabet.items())]
+_b32rev = dict([(v[0], k) for k, v in _b32alphabet.items()])
def b32encode(s):
- """Encode a string using Base32.
+ """Encode a byte string using Base32.
- s is the string to encode. The encoded string is returned.
+ s is the byte string to encode. The encoded byte string is returned.
"""
- parts = []
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
quanta, leftover = divmod(len(s), 5)
# Pad the last quantum with zero bits if necessary
if leftover:
- s += ('\0' * (5 - leftover))
+ s = s + bytes(5 - leftover) # Don't use += !
quanta += 1
+ encoded = bytes()
for i in range(quanta):
# c1 and c2 are 16 bits wide, c3 is 8 bits wide. The intent of this
# code is to process the 40 bits in units of 5 bits. So we take the 1
@@ -152,62 +171,66 @@ def b32encode(s):
c1, c2, c3 = struct.unpack('!HHB', s[i*5:(i+1)*5])
c2 += (c1 & 1) << 16 # 17 bits wide
c3 += (c2 & 3) << 8 # 10 bits wide
- parts.extend([_b32tab[c1 >> 11], # bits 1 - 5
- _b32tab[(c1 >> 6) & 0x1f], # bits 6 - 10
- _b32tab[(c1 >> 1) & 0x1f], # bits 11 - 15
- _b32tab[c2 >> 12], # bits 16 - 20 (1 - 5)
- _b32tab[(c2 >> 7) & 0x1f], # bits 21 - 25 (6 - 10)
- _b32tab[(c2 >> 2) & 0x1f], # bits 26 - 30 (11 - 15)
- _b32tab[c3 >> 5], # bits 31 - 35 (1 - 5)
- _b32tab[c3 & 0x1f], # bits 36 - 40 (1 - 5)
- ])
- encoded = EMPTYSTRING.join(parts)
+ encoded += bytes([_b32tab[c1 >> 11], # bits 1 - 5
+ _b32tab[(c1 >> 6) & 0x1f], # bits 6 - 10
+ _b32tab[(c1 >> 1) & 0x1f], # bits 11 - 15
+ _b32tab[c2 >> 12], # bits 16 - 20 (1 - 5)
+ _b32tab[(c2 >> 7) & 0x1f], # bits 21 - 25 (6 - 10)
+ _b32tab[(c2 >> 2) & 0x1f], # bits 26 - 30 (11 - 15)
+ _b32tab[c3 >> 5], # bits 31 - 35 (1 - 5)
+ _b32tab[c3 & 0x1f], # bits 36 - 40 (1 - 5)
+ ])
# Adjust for any leftover partial quanta
if leftover == 1:
- return encoded[:-6] + '======'
+ return encoded[:-6] + b'======'
elif leftover == 2:
- return encoded[:-4] + '===='
+ return encoded[:-4] + b'===='
elif leftover == 3:
- return encoded[:-3] + '==='
+ return encoded[:-3] + b'==='
elif leftover == 4:
- return encoded[:-1] + '='
+ return encoded[:-1] + b'='
return encoded
def b32decode(s, casefold=False, map01=None):
- """Decode a Base32 encoded string.
-
- s is the string to decode. Optional casefold is a flag specifying whether
- a lowercase alphabet is acceptable as input. For security purposes, the
- default is False.
-
- RFC 3548 allows for optional mapping of the digit 0 (zero) to the letter O
- (oh), and for optional mapping of the digit 1 (one) to either the letter I
- (eye) or letter L (el). The optional argument map01 when not None,
- specifies which letter the digit 1 should be mapped to (when map01 is not
- None, the digit 0 is always mapped to the letter O). For security
- purposes the default is None, so that 0 and 1 are not allowed in the
- input.
-
- The decoded string is returned. A TypeError is raised if s were
- incorrectly padded or if there are non-alphabet characters present in the
- string.
+ """Decode a Base32 encoded byte string.
+
+ s is the byte string to decode. Optional casefold is a flag
+ specifying whether a lowercase alphabet is acceptable as input.
+ For security purposes, the default is False.
+
+ RFC 3548 allows for optional mapping of the digit 0 (zero) to the
+ letter O (oh), and for optional mapping of the digit 1 (one) to
+ either the letter I (eye) or letter L (el). The optional argument
+ map01 when not None, specifies which letter the digit 1 should be
+ mapped to (when map01 is not None, the digit 0 is always mapped to
+ the letter O). For security purposes the default is None, so that
+ 0 and 1 are not allowed in the input.
+
+ The decoded byte string is returned. binascii.Error is raised if
+ the input is incorrectly padded or if there are non-alphabet
+ characters present in the input.
"""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
quanta, leftover = divmod(len(s), 8)
if leftover:
- raise TypeError('Incorrect padding')
+ raise binascii.Error('Incorrect padding')
# Handle section 2.4 zero and one mapping. The flag map01 will be either
# False, or the character to map the digit 1 (one) to. It should be
# either L (el) or I (eye).
- if map01:
- s = _translate(s, {'0': 'O', '1': map01})
+ if map01 is not None:
+ if not isinstance(map01, bytes_types):
+ raise TypeError("expected bytes, not %s" % map01.__class__.__name__)
+ assert len(map01) == 1, repr(map01)
+ s = _translate(s, {b'0': b'O', b'1': map01})
if casefold:
s = s.upper()
# Strip off pad characters from the right. We need to count the pad
# characters because this will tell us how many null bytes to remove from
# the end of the decoded string.
padchars = 0
- mo = re.search('(?P<pad>[=]*)$', s)
+ mo = re.search(b'(?P<pad>[=]*)$', s)
if mo:
padchars = len(mo.group('pad'))
if padchars > 0:
@@ -223,13 +246,13 @@ def b32decode(s, casefold=False, map01=None):
acc += _b32rev[c] << shift
shift -= 5
if shift < 0:
- parts.append(binascii.unhexlify('%010x' % acc))
+ parts.append(binascii.unhexlify(bytes('%010x' % acc, "ascii")))
acc = 0
shift = 35
# Process the last, partial quanta
- last = binascii.unhexlify('%010x' % acc)
+ last = binascii.unhexlify(bytes('%010x' % acc, "ascii"))
if padchars == 0:
- last = '' # No characters
+ last = b'' # No characters
elif padchars == 1:
last = last[:-1]
elif padchars == 3:
@@ -239,51 +262,55 @@ def b32decode(s, casefold=False, map01=None):
elif padchars == 6:
last = last[:-4]
else:
- raise TypeError('Incorrect padding')
+ raise binascii.Error('Incorrect padding')
parts.append(last)
- return EMPTYSTRING.join(parts)
+ return b''.join(parts)
+
-
# RFC 3548, Base 16 Alphabet specifies uppercase, but hexlify() returns
# lowercase. The RFC also recommends against accepting input case
# insensitively.
def b16encode(s):
- """Encode a string using Base16.
+ """Encode a byte string using Base16.
- s is the string to encode. The encoded string is returned.
+ s is the byte string to encode. The encoded byte string is returned.
"""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
return binascii.hexlify(s).upper()
def b16decode(s, casefold=False):
- """Decode a Base16 encoded string.
+ """Decode a Base16 encoded byte string.
- s is the string to decode. Optional casefold is a flag specifying whether
- a lowercase alphabet is acceptable as input. For security purposes, the
- default is False.
+ s is the byte string to decode. Optional casefold is a flag
+ specifying whether a lowercase alphabet is acceptable as input.
+ For security purposes, the default is False.
- The decoded string is returned. A TypeError is raised if s were
- incorrectly padded or if there are non-alphabet characters present in the
- string.
+ The decoded byte string is returned. binascii.Error is raised if
+ s were incorrectly padded or if there are non-alphabet characters
+ present in the string.
"""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
if casefold:
s = s.upper()
- if re.search('[^0-9A-F]', s):
- raise TypeError('Non-base16 digit found')
+ if re.search(b'[^0-9A-F]', s):
+ raise binascii.Error('Non-base16 digit found')
return binascii.unhexlify(s)
-
+
# Legacy interface. This code could be cleaned up since I don't believe
# binascii has any line length limitations. It just doesn't seem worth it
-# though.
+# though. The files should be opened in binary mode.
MAXLINESIZE = 76 # Excluding the CRLF
MAXBINSIZE = (MAXLINESIZE//4)*3
def encode(input, output):
- """Encode a file."""
+ """Encode a file; input and output are binary files."""
while True:
s = input.read(MAXBINSIZE)
if not s:
@@ -298,7 +325,7 @@ def encode(input, output):
def decode(input, output):
- """Decode a file."""
+ """Decode a file; input and output are binary files."""
while True:
line = input.readline()
if not line:
@@ -307,54 +334,75 @@ def decode(input, output):
output.write(s)
-def encodestring(s):
- """Encode a string into multiple lines of base-64 data."""
+def encodebytes(s):
+ """Encode a bytestring into a bytestring containing multiple lines
+ of base-64 data."""
+ if not isinstance(s, bytes_types):
+ raise TypeError("expected bytes, not %s" % s.__class__.__name__)
pieces = []
for i in range(0, len(s), MAXBINSIZE):
chunk = s[i : i + MAXBINSIZE]
pieces.append(binascii.b2a_base64(chunk))
- return "".join(pieces)
+ 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 decodestring(s):
- """Decode a string."""
+
+def decodebytes(s):
+ """Decode a bytestring of base-64 data into a bytestring."""
+ if not isinstance(s, bytes_types):
+ 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)
-
-# Useable as a script...
-def test():
- """Small test program"""
+
+# Usable as a script...
+def main():
+ """Small main program"""
import sys, getopt
try:
opts, args = getopt.getopt(sys.argv[1:], 'deut')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stdout = sys.stderr
- print msg
- print """usage: %s [-d|-e|-u|-t] [file|-]
+ print(msg)
+ print("""usage: %s [-d|-e|-u|-t] [file|-]
-d, -u: decode
-e: encode (default)
- -t: encode and decode string 'Aladdin:open sesame'"""%sys.argv[0]
+ -t: encode and decode string 'Aladdin:open sesame'"""%sys.argv[0])
sys.exit(2)
func = encode
for o, a in opts:
if o == '-e': func = encode
if o == '-d': func = decode
if o == '-u': func = decode
- if o == '-t': test1(); return
+ if o == '-t': test(); return
if args and args[0] != '-':
with open(args[0], 'rb') as f:
- func(f, sys.stdout)
+ func(f, sys.stdout.buffer)
else:
- func(sys.stdin, sys.stdout)
+ func(sys.stdin.buffer, sys.stdout.buffer)
-def test1():
- s0 = "Aladdin:open sesame"
- s1 = encodestring(s0)
- s2 = decodestring(s1)
- print s0, repr(s1), s2
+def test():
+ s0 = b"Aladdin:open sesame"
+ print(repr(s0))
+ s1 = encodebytes(s0)
+ print(repr(s1))
+ s2 = decodebytes(s1)
+ print(repr(s2))
+ assert s0 == s2
if __name__ == '__main__':
- test()
+ main()
diff --git a/Lib/bdb.py b/Lib/bdb.py
index 59440a99a0f..dd1f4287c1b 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -3,16 +3,14 @@
import fnmatch
import sys
import os
-import types
-__all__ = ["BdbQuit","Bdb","Breakpoint"]
+__all__ = ["BdbQuit", "Bdb", "Breakpoint"]
class BdbQuit(Exception):
- """Exception to give up completely"""
+ """Exception to give up completely."""
class Bdb:
-
"""Generic Python debugger base class.
This class takes care of details of the trace facility;
@@ -59,7 +57,7 @@ class Bdb:
return self.trace_dispatch
if event == 'c_return':
return self.trace_dispatch
- print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
+ print('bdb.Bdb.dispatch: unknown debugging event:', repr(event))
return self.trace_dispatch
def dispatch_line(self, frame):
@@ -125,14 +123,14 @@ class Bdb:
def break_here(self, frame):
filename = self.canonic(frame.f_code.co_filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return False
lineno = frame.f_lineno
- if not lineno in self.breaks[filename]:
+ if lineno not in self.breaks[filename]:
# The line itself has no breakpoint, but maybe the line is the
# first line of a function with breakpoint set by function name.
lineno = frame.f_code.co_firstlineno
- if not lineno in self.breaks[filename]:
+ if lineno not in self.breaks[filename]:
return False
# flag says ok to delete temp. bp
@@ -146,7 +144,7 @@ class Bdb:
return False
def do_clear(self, arg):
- raise NotImplementedError, "subclass of bdb must implement do_clear()"
+ raise NotImplementedError("subclass of bdb must implement do_clear()")
def break_anywhere(self, frame):
return self.canonic(frame.f_code.co_filename) in self.breaks
@@ -168,7 +166,6 @@ class Bdb:
pass
def user_exception(self, frame, exc_info):
- exc_type, exc_value, exc_traceback = exc_info
"""This method is called if an exception occurs,
but only if we are to stop at or just below this level."""
pass
@@ -176,7 +173,7 @@ class Bdb:
def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
self.stopframe = stopframe
self.returnframe = returnframe
- self.quitting = 0
+ self.quitting = False
# stoplineno >= 0 means: stop at line >= the stoplineno
# stoplineno -1 means: don't stop at all
self.stoplineno = stoplineno
@@ -184,10 +181,13 @@ class Bdb:
# Derived classes and clients can call the following methods
# to affect the stepping state.
- def set_until(self, frame): #the name "until" is borrowed from gdb
+ def set_until(self, frame, lineno=None):
"""Stop when the line with the line no greater than the current one is
reached or when returning from current frame"""
- self._set_stopinfo(frame, frame, frame.f_lineno+1)
+ # the name "until" is borrowed from gdb
+ if lineno is None:
+ lineno = frame.f_lineno + 1
+ self._set_stopinfo(frame, frame, lineno)
def set_step(self):
"""Stop after one line of code."""
@@ -238,7 +238,7 @@ class Bdb:
def set_quit(self):
self.stopframe = self.botframe
self.returnframe = None
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
# Derived classes and clients can call the following methods
@@ -248,18 +248,15 @@ class Bdb:
# Call self.get_*break*() to see the breakpoints or better
# for bp in Breakpoint.bpbynumber: if bp: bp.bpprint().
- def set_break(self, filename, lineno, temporary=0, cond = None,
+ def set_break(self, filename, lineno, temporary=False, cond=None,
funcname=None):
filename = self.canonic(filename)
import linecache # Import as late as possible
line = linecache.getline(filename, lineno)
if not line:
- return 'Line %s:%d does not exist' % (filename,
- lineno)
- if not filename in self.breaks:
- self.breaks[filename] = []
- list = self.breaks[filename]
- if not lineno in list:
+ return 'Line %s:%d does not exist' % (filename, lineno)
+ list = self.breaks.setdefault(filename, [])
+ if lineno not in list:
list.append(lineno)
bp = Breakpoint(filename, lineno, temporary, cond, funcname)
@@ -271,11 +268,10 @@ class Bdb:
def clear_break(self, filename, lineno):
filename = self.canonic(filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return 'There are no breakpoints in %s' % filename
if lineno not in self.breaks[filename]:
- return 'There is no breakpoint at %s:%d' % (filename,
- lineno)
+ return 'There is no breakpoint at %s:%d' % (filename, lineno)
# If there's only one bp in the list for that file,line
# pair, then remove the breaks entry
for bp in Breakpoint.bplist[filename, lineno][:]:
@@ -284,21 +280,15 @@ class Bdb:
def clear_bpbynumber(self, arg):
try:
- number = int(arg)
- except:
- return 'Non-numeric breakpoint number (%s)' % arg
- try:
- bp = Breakpoint.bpbynumber[number]
- except IndexError:
- return 'Breakpoint number (%d) out of range' % number
- if not bp:
- return 'Breakpoint (%d) already deleted' % number
+ bp = self.get_bpbynumber(arg)
+ except ValueError as err:
+ return str(err)
bp.deleteMe()
self._prune_breaks(bp.file, bp.line)
def clear_all_file_breaks(self, filename):
filename = self.canonic(filename)
- if not filename in self.breaks:
+ if filename not in self.breaks:
return 'There are no breakpoints in %s' % filename
for line in self.breaks[filename]:
blist = Breakpoint.bplist[filename, line]
@@ -314,6 +304,21 @@ class Bdb:
bp.deleteMe()
self.breaks = {}
+ def get_bpbynumber(self, arg):
+ if not arg:
+ raise ValueError('Breakpoint number expected')
+ try:
+ number = int(arg)
+ except ValueError:
+ raise ValueError('Non-numeric breakpoint number %s' % arg)
+ try:
+ bp = Breakpoint.bpbynumber[number]
+ except IndexError:
+ raise ValueError('Breakpoint number %d out of range' % number)
+ if bp is None:
+ raise ValueError('Breakpoint %d already deleted' % number)
+ return bp
+
def get_break(self, filename, lineno):
filename = self.canonic(filename)
return filename in self.breaks and \
@@ -356,35 +361,35 @@ class Bdb:
i = max(0, len(stack) - 1)
return stack, i
- #
-
def format_stack_entry(self, frame_lineno, lprefix=': '):
- import linecache, repr
+ import linecache, reprlib
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
- s = s + frame.f_code.co_name
+ s += frame.f_code.co_name
else:
- s = s + "<lambda>"
+ s += "<lambda>"
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
- s = s + repr.repr(args)
+ s += reprlib.repr(args)
else:
- s = s + '()'
+ s += '()'
if '__return__' in frame.f_locals:
rv = frame.f_locals['__return__']
- s = s + '->'
- s = s + repr.repr(rv)
+ s += '->'
+ s += reprlib.repr(rv)
line = linecache.getline(filename, lineno, frame.f_globals)
- if line: s = s + lprefix + line.strip()
+ if line:
+ s += lprefix + line.strip()
return s
- # The following two methods can be called by clients to use
- # a debugger to debug a statement, given as a string.
+ # The following methods can be called by clients to use
+ # a debugger to debug a statement or an expression.
+ # Both can be given as a string, or a code object.
def run(self, cmd, globals=None, locals=None):
if globals is None:
@@ -393,15 +398,15 @@ class Bdb:
if locals is None:
locals = globals
self.reset()
+ if isinstance(cmd, str):
+ cmd = compile(cmd, "<string>", "exec")
sys.settrace(self.trace_dispatch)
- if not isinstance(cmd, types.CodeType):
- cmd = cmd+'\n'
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
def runeval(self, expr, globals=None, locals=None):
@@ -412,14 +417,12 @@ class Bdb:
locals = globals
self.reset()
sys.settrace(self.trace_dispatch)
- if not isinstance(expr, types.CodeType):
- expr = expr+'\n'
try:
return eval(expr, globals, locals)
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
def runctx(self, cmd, globals, locals):
@@ -437,7 +440,7 @@ class Bdb:
except BdbQuit:
pass
finally:
- self.quitting = 1
+ self.quitting = True
sys.settrace(None)
return res
@@ -447,8 +450,7 @@ def set_trace():
class Breakpoint:
-
- """Breakpoint class
+ """Breakpoint class.
Implements temporary breakpoints, ignore counts, disabling and
(re)-enabling, and conditionals.
@@ -470,7 +472,7 @@ class Breakpoint:
# index 0 is unused, except for marking an
# effective break .... see effective()
- def __init__(self, file, line, temporary=0, cond=None, funcname=None):
+ def __init__(self, file, line, temporary=False, cond=None, funcname=None):
self.funcname = funcname
# Needed if funcname is not None.
self.func_first_executable_line = None
@@ -478,11 +480,11 @@ class Breakpoint:
self.line = line
self.temporary = temporary
self.cond = cond
- self.enabled = 1
+ self.enabled = True
self.ignore = 0
self.hits = 0
self.number = Breakpoint.next
- Breakpoint.next = Breakpoint.next + 1
+ Breakpoint.next += 1
# Build the two lists
self.bpbynumber.append(self)
if (file, line) in self.bplist:
@@ -490,7 +492,6 @@ class Breakpoint:
else:
self.bplist[file, line] = [self]
-
def deleteMe(self):
index = (self.file, self.line)
self.bpbynumber[self.number] = None # No longer in list
@@ -500,14 +501,17 @@ class Breakpoint:
del self.bplist[index]
def enable(self):
- self.enabled = 1
+ self.enabled = True
def disable(self):
- self.enabled = 0
+ self.enabled = False
def bpprint(self, out=None):
if out is None:
out = sys.stdout
+ print(self.bpformat(), file=out)
+
+ def bpformat(self):
if self.temporary:
disp = 'del '
else:
@@ -516,17 +520,22 @@ class Breakpoint:
disp = disp + 'yes '
else:
disp = disp + 'no '
- print >>out, '%-4dbreakpoint %s at %s:%d' % (self.number, disp,
- self.file, self.line)
+ ret = '%-4dbreakpoint %s at %s:%d' % (self.number, disp,
+ self.file, self.line)
if self.cond:
- print >>out, '\tstop only if %s' % (self.cond,)
+ ret += '\n\tstop only if %s' % (self.cond,)
if self.ignore:
- print >>out, '\tignore next %d hits' % (self.ignore)
- if (self.hits):
- if (self.hits > 1): ss = 's'
- else: ss = ''
- print >>out, ('\tbreakpoint already hit %d time%s' %
- (self.hits, ss))
+ ret += '\n\tignore next %d hits' % (self.ignore,)
+ if self.hits:
+ if self.hits > 1:
+ ss = 's'
+ else:
+ ss = ''
+ ret += '\n\tbreakpoint already hit %d time%s' % (self.hits, ss)
+ return ret
+
+ def __str__(self):
+ return 'breakpoint %s at %s:%s' % (self.number, self.file, self.line)
# -----------end of Breakpoint class----------
@@ -566,80 +575,73 @@ def effective(file, line, frame):
that indicates if it is ok to delete a temporary bp.
"""
- possibles = Breakpoint.bplist[file,line]
- for i in range(0, len(possibles)):
- b = possibles[i]
- if b.enabled == 0:
+ possibles = Breakpoint.bplist[file, line]
+ for b in possibles:
+ if not b.enabled:
continue
if not checkfuncname(b, frame):
continue
# Count every hit when bp is enabled
- b.hits = b.hits + 1
+ b.hits += 1
if not b.cond:
- # If unconditional, and ignoring,
- # go on to next, else break
+ # If unconditional, and ignoring go on to next, else break
if b.ignore > 0:
- b.ignore = b.ignore -1
+ b.ignore -= 1
continue
else:
- # breakpoint and marker that's ok
- # to delete if temporary
- return (b,1)
+ # breakpoint and marker that it's ok to delete if temporary
+ return (b, True)
else:
# Conditional bp.
# Ignore count applies only to those bpt hits where the
# condition evaluates to true.
try:
- val = eval(b.cond, frame.f_globals,
- frame.f_locals)
+ val = eval(b.cond, frame.f_globals, frame.f_locals)
if val:
if b.ignore > 0:
- b.ignore = b.ignore -1
+ b.ignore -= 1
# continue
else:
- return (b,1)
+ return (b, True)
# else:
# continue
except:
- # if eval fails, most conservative
- # thing is to stop on breakpoint
- # regardless of ignore count.
- # Don't delete temporary,
- # as another hint to user.
- return (b,0)
+ # if eval fails, most conservative thing is to stop on
+ # breakpoint regardless of ignore count. Don't delete
+ # temporary, as another hint to user.
+ return (b, False)
return (None, None)
+
# -------------------- testing --------------------
class Tdb(Bdb):
def user_call(self, frame, args):
name = frame.f_code.co_name
if not name: name = '???'
- print '+++ call', name, args
+ print('+++ call', name, args)
def user_line(self, frame):
import linecache
name = frame.f_code.co_name
if not name: name = '???'
fn = self.canonic(frame.f_code.co_filename)
line = linecache.getline(fn, frame.f_lineno, frame.f_globals)
- print '+++', fn, frame.f_lineno, name, ':', line.strip()
+ print('+++', fn, frame.f_lineno, name, ':', line.strip())
def user_return(self, frame, retval):
- print '+++ return', retval
+ print('+++ return', retval)
def user_exception(self, frame, exc_stuff):
- print '+++ exception', exc_stuff
+ print('+++ exception', exc_stuff)
self.set_continue()
def foo(n):
- print 'foo(', n, ')'
+ print('foo(', n, ')')
x = bar(n*10)
- print 'bar returned', x
+ print('bar returned', x)
def bar(a):
- print 'bar(', a, ')'
+ print('bar(', a, ')')
return a/2
def test():
t = Tdb()
t.run('import bdb; bdb.foo(10)')
-
-# end
diff --git a/Lib/binhex.py b/Lib/binhex.py
index 8abc9f3e14c..999a6755133 100644
--- a/Lib/binhex.py
+++ b/Lib/binhex.py
@@ -21,8 +21,9 @@ hexbin(inputfilename, outputfilename)
# input. The resulting code (xx 90 90) would appear to be interpreted as an
# escaped *value* of 0x90. All coders I've seen appear to ignore this nicety...
#
-import sys
+import io
import os
+import sys
import struct
import binascii
@@ -35,92 +36,59 @@ class Error(Exception):
[_DID_HEADER, _DID_DATA, _DID_RSRC] = range(3)
# Various constants
-REASONABLY_LARGE=32768 # Minimal amount we pass the rle-coder
-LINELEN=64
-RUNCHAR=chr(0x90) # run-length introducer
+REASONABLY_LARGE = 32768 # Minimal amount we pass the rle-coder
+LINELEN = 64
+RUNCHAR = b"\x90"
#
# This code is no longer byte-order dependent
-#
-# Workarounds for non-mac machines.
-try:
- from Carbon.File import FSSpec, FInfo
- from MacOS import openrf
-
- def getfileinfo(name):
- finfo = FSSpec(name).FSpGetFInfo()
- dir, file = os.path.split(name)
- # XXX Get resource/data sizes
- fp = open(name, 'rb')
- fp.seek(0, 2)
- dlen = fp.tell()
- fp = openrf(name, '*rb')
- fp.seek(0, 2)
- rlen = fp.tell()
- return file, finfo, dlen, rlen
- def openrsrc(name, *mode):
- if not mode:
- mode = '*rb'
- else:
- mode = '*' + mode[0]
- return openrf(name, mode)
-
-except ImportError:
- #
- # Glue code for non-macintosh usage
- #
-
- class FInfo:
- def __init__(self):
- self.Type = '????'
- self.Creator = '????'
- self.Flags = 0
-
- def getfileinfo(name):
- finfo = FInfo()
+class FInfo:
+ def __init__(self):
+ self.Type = '????'
+ self.Creator = '????'
+ self.Flags = 0
+
+def getfileinfo(name):
+ finfo = FInfo()
+ with io.open(name, 'rb') as fp:
# Quick check for textfile
- fp = open(name)
- data = open(name).read(256)
- for c in data:
- if not c.isspace() and (c<' ' or ord(c) > 0x7f):
- break
- else:
+ data = fp.read(512)
+ if 0 not in data:
finfo.Type = 'TEXT'
fp.seek(0, 2)
dsize = fp.tell()
- fp.close()
- dir, file = os.path.split(name)
- file = file.replace(':', '-', 1)
- return file, finfo, dsize, 0
+ dir, file = os.path.split(name)
+ file = file.replace(':', '-', 1)
+ return file, finfo, dsize, 0
- class openrsrc:
- def __init__(self, *args):
- pass
+class openrsrc:
+ def __init__(self, *args):
+ pass
- def read(self, *args):
- return ''
+ def read(self, *args):
+ return b''
- def write(self, *args):
- pass
+ def write(self, *args):
+ pass
- def close(self):
- pass
+ def close(self):
+ pass
class _Hqxcoderengine:
"""Write data to the coder in 3-byte chunks"""
def __init__(self, ofp):
self.ofp = ofp
- self.data = ''
- self.hqxdata = ''
- self.linelen = LINELEN-1
+ self.data = b''
+ self.hqxdata = b''
+ self.linelen = LINELEN - 1
def write(self, data):
self.data = self.data + data
datalen = len(self.data)
- todo = (datalen//3)*3
+ todo = (datalen // 3) * 3
data = self.data[:todo]
self.data = self.data[todo:]
if not data:
@@ -130,19 +98,18 @@ class _Hqxcoderengine:
def _flush(self, force):
first = 0
- while first <= len(self.hqxdata)-self.linelen:
+ while first <= len(self.hqxdata) - self.linelen:
last = first + self.linelen
- self.ofp.write(self.hqxdata[first:last]+'\n')
+ self.ofp.write(self.hqxdata[first:last] + b'\n')
self.linelen = LINELEN
first = last
self.hqxdata = self.hqxdata[first:]
if force:
- self.ofp.write(self.hqxdata + ':\n')
+ self.ofp.write(self.hqxdata + b':\n')
def close(self):
if self.data:
- self.hqxdata = \
- self.hqxdata + binascii.b2a_hqx(self.data)
+ self.hqxdata = self.hqxdata + binascii.b2a_hqx(self.data)
self._flush(1)
self.ofp.close()
del self.ofp
@@ -152,7 +119,7 @@ class _Rlecoderengine:
def __init__(self, ofp):
self.ofp = ofp
- self.data = ''
+ self.data = b''
def write(self, data):
self.data = self.data + data
@@ -160,7 +127,7 @@ class _Rlecoderengine:
return
rledata = binascii.rlecode_hqx(self.data)
self.ofp.write(rledata)
- self.data = ''
+ self.data = b''
def close(self):
if self.data:
@@ -172,26 +139,38 @@ class _Rlecoderengine:
class BinHex:
def __init__(self, name_finfo_dlen_rlen, ofp):
name, finfo, dlen, rlen = name_finfo_dlen_rlen
- if type(ofp) == type(''):
+ close_on_error = False
+ if isinstance(ofp, str):
ofname = ofp
- ofp = open(ofname, 'w')
- ofp.write('(This file must be converted with BinHex 4.0)\n\n:')
- hqxer = _Hqxcoderengine(ofp)
- self.ofp = _Rlecoderengine(hqxer)
- self.crc = 0
- if finfo is None:
- finfo = FInfo()
- self.dlen = dlen
- self.rlen = rlen
- self._writeinfo(name, finfo)
- self.state = _DID_HEADER
+ ofp = io.open(ofname, 'wb')
+ close_on_error = True
+ try:
+ ofp.write(b'(This file must be converted with BinHex 4.0)\r\r:')
+ hqxer = _Hqxcoderengine(ofp)
+ self.ofp = _Rlecoderengine(hqxer)
+ self.crc = 0
+ if finfo is None:
+ finfo = FInfo()
+ self.dlen = dlen
+ self.rlen = rlen
+ self._writeinfo(name, finfo)
+ self.state = _DID_HEADER
+ except:
+ if close_on_error:
+ ofp.close()
+ raise
def _writeinfo(self, name, finfo):
nl = len(name)
if nl > 63:
- raise Error, 'Filename too long'
- d = chr(nl) + name + '\0'
- d2 = finfo.Type + finfo.Creator
+ raise Error('Filename too long')
+ d = bytes([nl]) + name.encode("latin-1") + b'\0'
+ tp, cr = finfo.Type, finfo.Creator
+ if isinstance(tp, str):
+ tp = tp.encode("latin-1")
+ if isinstance(cr, str):
+ cr = cr.encode("latin-1")
+ d2 = tp + cr
# Force all structs to be packed with big-endian
d3 = struct.pack('>h', finfo.Flags)
@@ -216,13 +195,13 @@ class BinHex:
def write(self, data):
if self.state != _DID_HEADER:
- raise Error, 'Writing data at the wrong time'
+ raise Error('Writing data at the wrong time')
self.dlen = self.dlen - len(data)
self._write(data)
def close_data(self):
if self.dlen != 0:
- raise Error, 'Incorrect data size, diff=%r' % (self.rlen,)
+ raise Error('Incorrect data size, diff=%r' % (self.rlen,))
self._writecrc()
self.state = _DID_DATA
@@ -230,7 +209,7 @@ class BinHex:
if self.state < _DID_DATA:
self.close_data()
if self.state != _DID_DATA:
- raise Error, 'Writing resource data at the wrong time'
+ raise Error('Writing resource data at the wrong time')
self.rlen = self.rlen - len(data)
self._write(data)
@@ -238,23 +217,22 @@ class BinHex:
if self.state < _DID_DATA:
self.close_data()
if self.state != _DID_DATA:
- raise Error, 'Close at the wrong time'
+ raise Error('Close at the wrong time')
if self.rlen != 0:
- raise Error, \
- "Incorrect resource-datasize, diff=%r" % (self.rlen,)
+ raise Error("Incorrect resource-datasize, diff=%r" % (self.rlen,))
self._writecrc()
self.ofp.close()
self.state = None
del self.ofp
def binhex(inp, out):
- """(infilename, outfilename) - Create binhex-encoded copy of a file"""
+ """binhex(infilename, outfilename): create binhex-encoded copy of a file"""
finfo = getfileinfo(inp)
ofp = BinHex(finfo, out)
- ifp = open(inp, 'rb')
+ ifp = io.open(inp, 'rb')
# XXXX Do textfile translation on non-mac systems
- while 1:
+ while True:
d = ifp.read(128000)
if not d: break
ofp.write(d)
@@ -262,7 +240,7 @@ def binhex(inp, out):
ifp.close()
ifp = openrsrc(inp, 'rb')
- while 1:
+ while True:
d = ifp.read(128000)
if not d: break
ofp.write_rsrc(d)
@@ -278,36 +256,34 @@ class _Hqxdecoderengine:
def read(self, totalwtd):
"""Read at least wtd bytes (or until EOF)"""
- decdata = ''
+ decdata = b''
wtd = totalwtd
#
# The loop here is convoluted, since we don't really now how
# much to decode: there may be newlines in the incoming data.
while wtd > 0:
if self.eof: return decdata
- wtd = ((wtd+2)//3)*4
+ wtd = ((wtd + 2) // 3) * 4
data = self.ifp.read(wtd)
#
# Next problem: there may not be a complete number of
# bytes in what we pass to a2b. Solve by yet another
# loop.
#
- while 1:
+ while True:
try:
- decdatacur, self.eof = \
- binascii.a2b_hqx(data)
+ decdatacur, self.eof = binascii.a2b_hqx(data)
break
except binascii.Incomplete:
pass
newdata = self.ifp.read(1)
if not newdata:
- raise Error, \
- 'Premature EOF on binhex file'
+ raise Error('Premature EOF on binhex file')
data = data + newdata
decdata = decdata + decdatacur
wtd = totalwtd - len(decdata)
if not decdata and not self.eof:
- raise Error, 'Premature EOF on binhex file'
+ raise Error('Premature EOF on binhex file')
return decdata
def close(self):
@@ -318,23 +294,23 @@ class _Rledecoderengine:
def __init__(self, ifp):
self.ifp = ifp
- self.pre_buffer = ''
- self.post_buffer = ''
+ self.pre_buffer = b''
+ self.post_buffer = b''
self.eof = 0
def read(self, wtd):
if wtd > len(self.post_buffer):
- self._fill(wtd-len(self.post_buffer))
+ self._fill(wtd - len(self.post_buffer))
rv = self.post_buffer[:wtd]
self.post_buffer = self.post_buffer[wtd:]
return rv
def _fill(self, wtd):
- self.pre_buffer = self.pre_buffer + self.ifp.read(wtd+4)
+ self.pre_buffer = self.pre_buffer + self.ifp.read(wtd + 4)
if self.ifp.eof:
self.post_buffer = self.post_buffer + \
binascii.rledecode_hqx(self.pre_buffer)
- self.pre_buffer = ''
+ self.pre_buffer = b''
return
#
@@ -349,13 +325,13 @@ class _Rledecoderengine:
# otherwise: keep 1 byte.
#
mark = len(self.pre_buffer)
- if self.pre_buffer[-3:] == RUNCHAR + '\0' + RUNCHAR:
+ if self.pre_buffer[-3:] == RUNCHAR + b'\0' + RUNCHAR:
mark = mark - 3
- elif self.pre_buffer[-1] == RUNCHAR:
+ elif self.pre_buffer[-1:] == RUNCHAR:
mark = mark - 2
- elif self.pre_buffer[-2:] == RUNCHAR + '\0':
+ elif self.pre_buffer[-2:] == RUNCHAR + b'\0':
mark = mark - 2
- elif self.pre_buffer[-2] == RUNCHAR:
+ elif self.pre_buffer[-2:-1] == RUNCHAR:
pass # Decode all
else:
mark = mark - 1
@@ -369,23 +345,21 @@ class _Rledecoderengine:
class HexBin:
def __init__(self, ifp):
- if type(ifp) == type(''):
- ifp = open(ifp)
+ if isinstance(ifp, str):
+ ifp = io.open(ifp, 'rb')
#
# Find initial colon.
#
- while 1:
+ while True:
ch = ifp.read(1)
if not ch:
- raise Error, "No binhex data found"
+ raise Error("No binhex data found")
# Cater for \r\n terminated lines (which show up as \n\r, hence
# all lines start with \r)
- if ch == '\r':
+ if ch == b'\r':
continue
- if ch == ':':
+ if ch == b':':
break
- if ch != '\n':
- dummy = ifp.readline()
hqxifp = _Hqxdecoderengine(ifp)
self.ifp = _Rledecoderengine(hqxifp)
@@ -403,14 +377,14 @@ class HexBin:
# XXXX Is this needed??
self.crc = self.crc & 0xffff
if filecrc != self.crc:
- raise Error, 'CRC error, computed %x, read %x' \
- %(self.crc, filecrc)
+ raise Error('CRC error, computed %x, read %x'
+ % (self.crc, filecrc))
self.crc = 0
def _readheader(self):
len = self._read(1)
fname = self._read(ord(len))
- rest = self._read(1+4+4+2+4+4)
+ rest = self._read(1 + 4 + 4 + 2 + 4 + 4)
self._checkcrc()
type = rest[1:5]
@@ -429,13 +403,13 @@ class HexBin:
def read(self, *n):
if self.state != _DID_HEADER:
- raise Error, 'Read data at wrong time'
+ raise Error('Read data at wrong time')
if n:
n = n[0]
n = min(n, self.dlen)
else:
n = self.dlen
- rv = ''
+ rv = b''
while len(rv) < n:
rv = rv + self._read(n-len(rv))
self.dlen = self.dlen - n
@@ -443,7 +417,7 @@ class HexBin:
def close_data(self):
if self.state != _DID_HEADER:
- raise Error, 'close_data at wrong time'
+ raise Error('close_data at wrong time')
if self.dlen:
dummy = self._read(self.dlen)
self._checkcrc()
@@ -453,7 +427,7 @@ class HexBin:
if self.state == _DID_HEADER:
self.close_data()
if self.state != _DID_DATA:
- raise Error, 'Read resource data at wrong time'
+ raise Error('Read resource data at wrong time')
if n:
n = n[0]
n = min(n, self.rlen)
@@ -470,15 +444,15 @@ class HexBin:
self.ifp.close()
def hexbin(inp, out):
- """(infilename, outfilename) - Decode binhexed file"""
+ """hexbin(infilename, outfilename) - Decode binhexed file"""
ifp = HexBin(inp)
finfo = ifp.FInfo
if not out:
out = ifp.FName
- ofp = open(out, 'wb')
+ ofp = io.open(out, 'wb')
# XXXX Do translation on non-mac systems
- while 1:
+ while True:
d = ifp.read(128000)
if not d: break
ofp.write(d)
@@ -489,20 +463,10 @@ def hexbin(inp, out):
if d:
ofp = openrsrc(out, 'wb')
ofp.write(d)
- while 1:
+ while True:
d = ifp.read_rsrc(128000)
if not d: break
ofp.write(d)
ofp.close()
ifp.close()
-
-def _test():
- fname = sys.argv[1]
- binhex(fname, fname+'.hqx')
- hexbin(fname+'.hqx', fname+'.viahqx')
- #hexbin(fname, fname+'.unpacked')
- sys.exit(1)
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
deleted file mode 100644
index ed4deeaeb8c..00000000000
--- a/Lib/bsddb/__init__.py
+++ /dev/null
@@ -1,455 +0,0 @@
-#----------------------------------------------------------------------
-# Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA
-# and Andrew Kuchling. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# o Redistributions of source code must retain the above copyright
-# notice, this list of conditions, and the disclaimer that follows.
-#
-# o Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions, and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#
-# o Neither the name of Digital Creations nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
-# IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
-# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-# DAMAGE.
-#----------------------------------------------------------------------
-
-
-"""Support for Berkeley DB 4.1 through 4.8 with a simple interface.
-
-For the full featured object oriented interface use the bsddb.db module
-instead. It mirrors the Oracle Berkeley DB C API.
-"""
-
-import sys
-absolute_import = (sys.version_info[0] >= 3)
-
-if (sys.version_info >= (2, 6)) and (sys.version_info < (3, 0)) :
- import warnings
- if sys.py3kwarning and (__name__ != 'bsddb3') :
- warnings.warnpy3k("in 3.x, the bsddb module has been removed; "
- "please use the pybsddb project instead",
- DeprecationWarning, 2)
- warnings.filterwarnings("ignore", ".*CObject.*", DeprecationWarning,
- "bsddb.__init__")
-
-try:
- if __name__ == 'bsddb3':
- # import _pybsddb binary as it should be the more recent version from
- # a standalone pybsddb addon package than the version included with
- # python as bsddb._bsddb.
- if absolute_import :
- # Because this syntaxis is not valid before Python 2.5
- exec("from . import _pybsddb")
- else :
- import _pybsddb
- _bsddb = _pybsddb
- from bsddb3.dbutils import DeadlockWrap as _DeadlockWrap
- else:
- import _bsddb
- from bsddb.dbutils import DeadlockWrap as _DeadlockWrap
-except ImportError:
- # Remove ourselves from sys.modules
- import sys
- del sys.modules[__name__]
- raise
-
-# bsddb3 calls it db, but provide _db for backwards compatibility
-db = _db = _bsddb
-__version__ = db.__version__
-
-error = db.DBError # So bsddb.error will mean something...
-
-#----------------------------------------------------------------------
-
-import sys, os
-
-from weakref import ref
-
-if sys.version_info < (2, 6) :
- import UserDict
- MutableMapping = UserDict.DictMixin
-else :
- import collections
- MutableMapping = collections.MutableMapping
-
-class _iter_mixin(MutableMapping):
- def _make_iter_cursor(self):
- cur = _DeadlockWrap(self.db.cursor)
- key = id(cur)
- self._cursor_refs[key] = ref(cur, self._gen_cref_cleaner(key))
- return cur
-
- def _gen_cref_cleaner(self, key):
- # use generate the function for the weakref callback here
- # to ensure that we do not hold a strict reference to cur
- # in the callback.
- return lambda ref: self._cursor_refs.pop(key, None)
-
- def __iter__(self):
- self._kill_iteration = False
- self._in_iter += 1
- try:
- try:
- cur = self._make_iter_cursor()
-
- # FIXME-20031102-greg: race condition. cursor could
- # be closed by another thread before this call.
-
- # since we're only returning keys, we call the cursor
- # methods with flags=0, dlen=0, dofs=0
- key = _DeadlockWrap(cur.first, 0,0,0)[0]
- yield key
-
- next = getattr(cur, "next")
- while 1:
- try:
- key = _DeadlockWrap(next, 0,0,0)[0]
- yield key
- except _bsddb.DBCursorClosedError:
- if self._kill_iteration:
- raise RuntimeError('Database changed size '
- 'during iteration.')
- cur = self._make_iter_cursor()
- # FIXME-20031101-greg: race condition. cursor could
- # be closed by another thread before this call.
- _DeadlockWrap(cur.set, key,0,0,0)
- next = getattr(cur, "next")
- except _bsddb.DBNotFoundError:
- pass
- except _bsddb.DBCursorClosedError:
- # the database was modified during iteration. abort.
- pass
-# When Python 2.3 not supported in bsddb3, we can change this to "finally"
- except :
- self._in_iter -= 1
- raise
-
- self._in_iter -= 1
-
- def iteritems(self):
- if not self.db:
- return
- self._kill_iteration = False
- self._in_iter += 1
- try:
- try:
- cur = self._make_iter_cursor()
-
- # FIXME-20031102-greg: race condition. cursor could
- # be closed by another thread before this call.
-
- kv = _DeadlockWrap(cur.first)
- key = kv[0]
- yield kv
-
- next = getattr(cur, "next")
- while 1:
- try:
- kv = _DeadlockWrap(next)
- key = kv[0]
- yield kv
- except _bsddb.DBCursorClosedError:
- if self._kill_iteration:
- raise RuntimeError('Database changed size '
- 'during iteration.')
- cur = self._make_iter_cursor()
- # FIXME-20031101-greg: race condition. cursor could
- # be closed by another thread before this call.
- _DeadlockWrap(cur.set, key,0,0,0)
- next = getattr(cur, "next")
- except _bsddb.DBNotFoundError:
- pass
- except _bsddb.DBCursorClosedError:
- # the database was modified during iteration. abort.
- pass
-# When Python 2.3 not supported in bsddb3, we can change this to "finally"
- except :
- self._in_iter -= 1
- raise
-
- self._in_iter -= 1
-
-
-class _DBWithCursor(_iter_mixin):
- """
- A simple wrapper around DB that makes it look like the bsddbobject in
- the old module. It uses a cursor as needed to provide DB traversal.
- """
- def __init__(self, db):
- self.db = db
- self.db.set_get_returns_none(0)
-
- # FIXME-20031101-greg: I believe there is still the potential
- # for deadlocks in a multithreaded environment if someone
- # attempts to use the any of the cursor interfaces in one
- # thread while doing a put or delete in another thread. The
- # reason is that _checkCursor and _closeCursors are not atomic
- # operations. Doing our own locking around self.dbc,
- # self.saved_dbc_key and self._cursor_refs could prevent this.
- # TODO: A test case demonstrating the problem needs to be written.
-
- # self.dbc is a DBCursor object used to implement the
- # first/next/previous/last/set_location methods.
- self.dbc = None
- self.saved_dbc_key = None
-
- # a collection of all DBCursor objects currently allocated
- # by the _iter_mixin interface.
- self._cursor_refs = {}
- self._in_iter = 0
- self._kill_iteration = False
-
- def __del__(self):
- self.close()
-
- def _checkCursor(self):
- if self.dbc is None:
- self.dbc = _DeadlockWrap(self.db.cursor)
- if self.saved_dbc_key is not None:
- _DeadlockWrap(self.dbc.set, self.saved_dbc_key)
- self.saved_dbc_key = None
-
- # This method is needed for all non-cursor DB calls to avoid
- # Berkeley DB deadlocks (due to being opened with DB_INIT_LOCK
- # and DB_THREAD to be thread safe) when intermixing database
- # operations that use the cursor internally with those that don't.
- def _closeCursors(self, save=1):
- if self.dbc:
- c = self.dbc
- self.dbc = None
- if save:
- try:
- self.saved_dbc_key = _DeadlockWrap(c.current, 0,0,0)[0]
- except db.DBError:
- pass
- _DeadlockWrap(c.close)
- del c
- for cref in self._cursor_refs.values():
- c = cref()
- if c is not None:
- _DeadlockWrap(c.close)
-
- def _checkOpen(self):
- if self.db is None:
- raise error, "BSDDB object has already been closed"
-
- def isOpen(self):
- return self.db is not None
-
- def __len__(self):
- self._checkOpen()
- return _DeadlockWrap(lambda: len(self.db)) # len(self.db)
-
- if sys.version_info >= (2, 6) :
- def __repr__(self) :
- if self.isOpen() :
- return repr(dict(_DeadlockWrap(self.db.items)))
- return repr(dict())
-
- def __getitem__(self, key):
- self._checkOpen()
- return _DeadlockWrap(lambda: self.db[key]) # self.db[key]
-
- def __setitem__(self, key, value):
- self._checkOpen()
- self._closeCursors()
- if self._in_iter and key not in self:
- self._kill_iteration = True
- def wrapF():
- self.db[key] = value
- _DeadlockWrap(wrapF) # self.db[key] = value
-
- def __delitem__(self, key):
- self._checkOpen()
- self._closeCursors()
- if self._in_iter and key in self:
- self._kill_iteration = True
- def wrapF():
- del self.db[key]
- _DeadlockWrap(wrapF) # del self.db[key]
-
- def close(self):
- self._closeCursors(save=0)
- if self.dbc is not None:
- _DeadlockWrap(self.dbc.close)
- v = 0
- if self.db is not None:
- v = _DeadlockWrap(self.db.close)
- self.dbc = None
- self.db = None
- return v
-
- def keys(self):
- self._checkOpen()
- return _DeadlockWrap(self.db.keys)
-
- def has_key(self, key):
- self._checkOpen()
- return _DeadlockWrap(self.db.has_key, key)
-
- def set_location(self, key):
- self._checkOpen()
- self._checkCursor()
- return _DeadlockWrap(self.dbc.set_range, key)
-
- def next(self): # Renamed by "2to3"
- self._checkOpen()
- self._checkCursor()
- rv = _DeadlockWrap(getattr(self.dbc, "next"))
- return rv
-
- if sys.version_info[0] >= 3 : # For "2to3" conversion
- next = __next__
-
- def previous(self):
- self._checkOpen()
- self._checkCursor()
- rv = _DeadlockWrap(self.dbc.prev)
- return rv
-
- def first(self):
- self._checkOpen()
- # fix 1725856: don't needlessly try to restore our cursor position
- self.saved_dbc_key = None
- self._checkCursor()
- rv = _DeadlockWrap(self.dbc.first)
- return rv
-
- def last(self):
- self._checkOpen()
- # fix 1725856: don't needlessly try to restore our cursor position
- self.saved_dbc_key = None
- self._checkCursor()
- rv = _DeadlockWrap(self.dbc.last)
- return rv
-
- def sync(self):
- self._checkOpen()
- return _DeadlockWrap(self.db.sync)
-
-
-#----------------------------------------------------------------------
-# Compatibility object factory functions
-
-def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
- cachesize=None, lorder=None, hflags=0):
-
- flags = _checkflag(flag, file)
- e = _openDBEnv(cachesize)
- d = db.DB(e)
- d.set_flags(hflags)
- if pgsize is not None: d.set_pagesize(pgsize)
- if lorder is not None: d.set_lorder(lorder)
- if ffactor is not None: d.set_h_ffactor(ffactor)
- if nelem is not None: d.set_h_nelem(nelem)
- d.open(file, db.DB_HASH, flags, mode)
- return _DBWithCursor(d)
-
-#----------------------------------------------------------------------
-
-def btopen(file, flag='c', mode=0666,
- btflags=0, cachesize=None, maxkeypage=None, minkeypage=None,
- pgsize=None, lorder=None):
-
- flags = _checkflag(flag, file)
- e = _openDBEnv(cachesize)
- d = db.DB(e)
- if pgsize is not None: d.set_pagesize(pgsize)
- if lorder is not None: d.set_lorder(lorder)
- d.set_flags(btflags)
- if minkeypage is not None: d.set_bt_minkey(minkeypage)
- if maxkeypage is not None: d.set_bt_maxkey(maxkeypage)
- d.open(file, db.DB_BTREE, flags, mode)
- return _DBWithCursor(d)
-
-#----------------------------------------------------------------------
-
-
-def rnopen(file, flag='c', mode=0666,
- rnflags=0, cachesize=None, pgsize=None, lorder=None,
- rlen=None, delim=None, source=None, pad=None):
-
- flags = _checkflag(flag, file)
- e = _openDBEnv(cachesize)
- d = db.DB(e)
- if pgsize is not None: d.set_pagesize(pgsize)
- if lorder is not None: d.set_lorder(lorder)
- d.set_flags(rnflags)
- if delim is not None: d.set_re_delim(delim)
- if rlen is not None: d.set_re_len(rlen)
- if source is not None: d.set_re_source(source)
- if pad is not None: d.set_re_pad(pad)
- d.open(file, db.DB_RECNO, flags, mode)
- return _DBWithCursor(d)
-
-#----------------------------------------------------------------------
-
-def _openDBEnv(cachesize):
- e = db.DBEnv()
- if cachesize is not None:
- if cachesize >= 20480:
- e.set_cachesize(0, cachesize)
- else:
- raise error, "cachesize must be >= 20480"
- e.set_lk_detect(db.DB_LOCK_DEFAULT)
- e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL)
- return e
-
-def _checkflag(flag, file):
- if flag == 'r':
- flags = db.DB_RDONLY
- elif flag == 'rw':
- flags = 0
- elif flag == 'w':
- flags = db.DB_CREATE
- elif flag == 'c':
- flags = db.DB_CREATE
- elif flag == 'n':
- flags = db.DB_CREATE
- #flags = db.DB_CREATE | db.DB_TRUNCATE
- # we used db.DB_TRUNCATE flag for this before but Berkeley DB
- # 4.2.52 changed to disallowed truncate with txn environments.
- if file is not None and os.path.isfile(file):
- os.unlink(file)
- else:
- raise error, "flags should be one of 'r', 'w', 'c' or 'n'"
- return flags | db.DB_THREAD
-
-#----------------------------------------------------------------------
-
-
-# This is a silly little hack that allows apps to continue to use the
-# DB_THREAD flag even on systems without threads without freaking out
-# Berkeley DB.
-#
-# This assumes that if Python was built with thread support then
-# Berkeley DB was too.
-
-try:
- # 2to3 automatically changes "import thread" to "import _thread"
- import thread as T
- del T
-
-except ImportError:
- db.DB_THREAD = 0
-
-#----------------------------------------------------------------------
diff --git a/Lib/bsddb/db.py b/Lib/bsddb/db.py
deleted file mode 100644
index c3aee307ef0..00000000000
--- a/Lib/bsddb/db.py
+++ /dev/null
@@ -1,60 +0,0 @@
-#----------------------------------------------------------------------
-# Copyright (c) 1999-2001, Digital Creations, Fredericksburg, VA, USA
-# and Andrew Kuchling. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# o Redistributions of source code must retain the above copyright
-# notice, this list of conditions, and the disclaimer that follows.
-#
-# o Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions, and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#
-# o Neither the name of Digital Creations nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS
-# IS* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
-# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
-# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
-# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
-# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
-# DAMAGE.
-#----------------------------------------------------------------------
-
-
-# This module is just a placeholder for possible future expansion, in
-# case we ever want to augment the stuff in _db in any way. For now
-# it just simply imports everything from _db.
-
-import sys
-absolute_import = (sys.version_info[0] >= 3)
-
-if not absolute_import :
- if __name__.startswith('bsddb3.') :
- # import _pybsddb binary as it should be the more recent version from
- # a standalone pybsddb addon package than the version included with
- # python as bsddb._bsddb.
- from _pybsddb import *
- from _pybsddb import __version__
- else:
- from _bsddb import *
- from _bsddb import __version__
-else :
- # Because this syntaxis is not valid before Python 2.5
- if __name__.startswith('bsddb3.') :
- exec("from ._pybsddb import *")
- exec("from ._pybsddb import __version__")
- else :
- exec("from ._bsddb import *")
- exec("from ._bsddb import __version__")
diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py
deleted file mode 100644
index c7c73226443..00000000000
--- a/Lib/bsddb/dbobj.py
+++ /dev/null
@@ -1,269 +0,0 @@
-#-------------------------------------------------------------------------
-# This file contains real Python object wrappers for DB and DBEnv
-# C "objects" that can be usefully subclassed. The previous SWIG
-# based interface allowed this thanks to SWIG's shadow classes.
-# -- Gregory P. Smith
-#-------------------------------------------------------------------------
-#
-# (C) Copyright 2001 Autonomous Zone Industries
-#
-# License: This is free software. You may use this software for any
-# purpose including modification/redistribution, so long as
-# this header remains intact and that you do not claim any
-# rights of ownership or authorship of this software. This
-# software has been tested, but no warranty is expressed or
-# implied.
-#
-
-#
-# TODO it would be *really nice* to have an automatic shadow class populator
-# so that new methods don't need to be added here manually after being
-# added to _bsddb.c.
-#
-
-import sys
-absolute_import = (sys.version_info[0] >= 3)
-if absolute_import :
- # Because this syntaxis is not valid before Python 2.5
- exec("from . import db")
-else :
- import db
-
-if sys.version_info < (2, 6) :
- try:
- from UserDict import DictMixin
- except ImportError:
- # DictMixin is new in Python 2.3
- class DictMixin: pass
- MutableMapping = DictMixin
-else :
- import collections
- MutableMapping = collections.MutableMapping
-
-class DBEnv:
- def __init__(self, *args, **kwargs):
- self._cobj = db.DBEnv(*args, **kwargs)
-
- def close(self, *args, **kwargs):
- return self._cobj.close(*args, **kwargs)
- def open(self, *args, **kwargs):
- return self._cobj.open(*args, **kwargs)
- def remove(self, *args, **kwargs):
- return self._cobj.remove(*args, **kwargs)
- def set_shm_key(self, *args, **kwargs):
- return self._cobj.set_shm_key(*args, **kwargs)
- def set_cachesize(self, *args, **kwargs):
- return self._cobj.set_cachesize(*args, **kwargs)
- def set_data_dir(self, *args, **kwargs):
- return self._cobj.set_data_dir(*args, **kwargs)
- def set_flags(self, *args, **kwargs):
- return self._cobj.set_flags(*args, **kwargs)
- def set_lg_bsize(self, *args, **kwargs):
- return self._cobj.set_lg_bsize(*args, **kwargs)
- def set_lg_dir(self, *args, **kwargs):
- return self._cobj.set_lg_dir(*args, **kwargs)
- def set_lg_max(self, *args, **kwargs):
- return self._cobj.set_lg_max(*args, **kwargs)
- def set_lk_detect(self, *args, **kwargs):
- return self._cobj.set_lk_detect(*args, **kwargs)
- if db.version() < (4,5):
- def set_lk_max(self, *args, **kwargs):
- return self._cobj.set_lk_max(*args, **kwargs)
- def set_lk_max_locks(self, *args, **kwargs):
- return self._cobj.set_lk_max_locks(*args, **kwargs)
- def set_lk_max_lockers(self, *args, **kwargs):
- return self._cobj.set_lk_max_lockers(*args, **kwargs)
- def set_lk_max_objects(self, *args, **kwargs):
- return self._cobj.set_lk_max_objects(*args, **kwargs)
- def set_mp_mmapsize(self, *args, **kwargs):
- return self._cobj.set_mp_mmapsize(*args, **kwargs)
- def set_timeout(self, *args, **kwargs):
- return self._cobj.set_timeout(*args, **kwargs)
- def set_tmp_dir(self, *args, **kwargs):
- return self._cobj.set_tmp_dir(*args, **kwargs)
- def txn_begin(self, *args, **kwargs):
- return self._cobj.txn_begin(*args, **kwargs)
- def txn_checkpoint(self, *args, **kwargs):
- return self._cobj.txn_checkpoint(*args, **kwargs)
- def txn_stat(self, *args, **kwargs):
- return self._cobj.txn_stat(*args, **kwargs)
- def set_tx_max(self, *args, **kwargs):
- return self._cobj.set_tx_max(*args, **kwargs)
- def set_tx_timestamp(self, *args, **kwargs):
- return self._cobj.set_tx_timestamp(*args, **kwargs)
- def lock_detect(self, *args, **kwargs):
- return self._cobj.lock_detect(*args, **kwargs)
- def lock_get(self, *args, **kwargs):
- return self._cobj.lock_get(*args, **kwargs)
- def lock_id(self, *args, **kwargs):
- return self._cobj.lock_id(*args, **kwargs)
- def lock_put(self, *args, **kwargs):
- return self._cobj.lock_put(*args, **kwargs)
- def lock_stat(self, *args, **kwargs):
- return self._cobj.lock_stat(*args, **kwargs)
- def log_archive(self, *args, **kwargs):
- return self._cobj.log_archive(*args, **kwargs)
-
- def set_get_returns_none(self, *args, **kwargs):
- return self._cobj.set_get_returns_none(*args, **kwargs)
-
- def log_stat(self, *args, **kwargs):
- return self._cobj.log_stat(*args, **kwargs)
-
- def dbremove(self, *args, **kwargs):
- return self._cobj.dbremove(*args, **kwargs)
- def dbrename(self, *args, **kwargs):
- return self._cobj.dbrename(*args, **kwargs)
- def set_encrypt(self, *args, **kwargs):
- return self._cobj.set_encrypt(*args, **kwargs)
-
- if db.version() >= (4,4):
- def fileid_reset(self, *args, **kwargs):
- return self._cobj.fileid_reset(*args, **kwargs)
-
- def lsn_reset(self, *args, **kwargs):
- return self._cobj.lsn_reset(*args, **kwargs)
-
-
-class DB(MutableMapping):
- def __init__(self, dbenv, *args, **kwargs):
- # give it the proper DBEnv C object that its expecting
- self._cobj = db.DB(*((dbenv._cobj,) + args), **kwargs)
-
- # TODO are there other dict methods that need to be overridden?
- def __len__(self):
- return len(self._cobj)
- def __getitem__(self, arg):
- return self._cobj[arg]
- def __setitem__(self, key, value):
- self._cobj[key] = value
- def __delitem__(self, arg):
- del self._cobj[arg]
-
- if sys.version_info >= (2, 6) :
- def __iter__(self) :
- return self._cobj.__iter__()
-
- def append(self, *args, **kwargs):
- return self._cobj.append(*args, **kwargs)
- def associate(self, *args, **kwargs):
- return self._cobj.associate(*args, **kwargs)
- def close(self, *args, **kwargs):
- return self._cobj.close(*args, **kwargs)
- def consume(self, *args, **kwargs):
- return self._cobj.consume(*args, **kwargs)
- def consume_wait(self, *args, **kwargs):
- return self._cobj.consume_wait(*args, **kwargs)
- def cursor(self, *args, **kwargs):
- return self._cobj.cursor(*args, **kwargs)
- def delete(self, *args, **kwargs):
- return self._cobj.delete(*args, **kwargs)
- def fd(self, *args, **kwargs):
- return self._cobj.fd(*args, **kwargs)
- def get(self, *args, **kwargs):
- return self._cobj.get(*args, **kwargs)
- def pget(self, *args, **kwargs):
- return self._cobj.pget(*args, **kwargs)
- def get_both(self, *args, **kwargs):
- return self._cobj.get_both(*args, **kwargs)
- def get_byteswapped(self, *args, **kwargs):
- return self._cobj.get_byteswapped(*args, **kwargs)
- def get_size(self, *args, **kwargs):
- return self._cobj.get_size(*args, **kwargs)
- def get_type(self, *args, **kwargs):
- return self._cobj.get_type(*args, **kwargs)
- def join(self, *args, **kwargs):
- return self._cobj.join(*args, **kwargs)
- def key_range(self, *args, **kwargs):
- return self._cobj.key_range(*args, **kwargs)
- def has_key(self, *args, **kwargs):
- return self._cobj.has_key(*args, **kwargs)
- def items(self, *args, **kwargs):
- return self._cobj.items(*args, **kwargs)
- def keys(self, *args, **kwargs):
- return self._cobj.keys(*args, **kwargs)
- def open(self, *args, **kwargs):
- return self._cobj.open(*args, **kwargs)
- def put(self, *args, **kwargs):
- return self._cobj.put(*args, **kwargs)
- def remove(self, *args, **kwargs):
- return self._cobj.remove(*args, **kwargs)
- def rename(self, *args, **kwargs):
- return self._cobj.rename(*args, **kwargs)
- def set_bt_minkey(self, *args, **kwargs):
- return self._cobj.set_bt_minkey(*args, **kwargs)
- def set_bt_compare(self, *args, **kwargs):
- return self._cobj.set_bt_compare(*args, **kwargs)
- def set_cachesize(self, *args, **kwargs):
- return self._cobj.set_cachesize(*args, **kwargs)
- def set_flags(self, *args, **kwargs):
- return self._cobj.set_flags(*args, **kwargs)
- def set_h_ffactor(self, *args, **kwargs):
- return self._cobj.set_h_ffactor(*args, **kwargs)
- def set_h_nelem(self, *args, **kwargs):
- return self._cobj.set_h_nelem(*args, **kwargs)
- def set_lorder(self, *args, **kwargs):
- return self._cobj.set_lorder(*args, **kwargs)
- def set_pagesize(self, *args, **kwargs):
- return self._cobj.set_pagesize(*args, **kwargs)
- def set_re_delim(self, *args, **kwargs):
- return self._cobj.set_re_delim(*args, **kwargs)
- def set_re_len(self, *args, **kwargs):
- return self._cobj.set_re_len(*args, **kwargs)
- def set_re_pad(self, *args, **kwargs):
- return self._cobj.set_re_pad(*args, **kwargs)
- def set_re_source(self, *args, **kwargs):
- return self._cobj.set_re_source(*args, **kwargs)
- def set_q_extentsize(self, *args, **kwargs):
- return self._cobj.set_q_extentsize(*args, **kwargs)
- def stat(self, *args, **kwargs):
- return self._cobj.stat(*args, **kwargs)
- def sync(self, *args, **kwargs):
- return self._cobj.sync(*args, **kwargs)
- def type(self, *args, **kwargs):
- return self._cobj.type(*args, **kwargs)
- def upgrade(self, *args, **kwargs):
- return self._cobj.upgrade(*args, **kwargs)
- def values(self, *args, **kwargs):
- return self._cobj.values(*args, **kwargs)
- def verify(self, *args, **kwargs):
- return self._cobj.verify(*args, **kwargs)
- def set_get_returns_none(self, *args, **kwargs):
- return self._cobj.set_get_returns_none(*args, **kwargs)
-
- def set_encrypt(self, *args, **kwargs):
- return self._cobj.set_encrypt(*args, **kwargs)
-
-
-class DBSequence:
- def __init__(self, *args, **kwargs):
- self._cobj = db.DBSequence(*args, **kwargs)
-
- def close(self, *args, **kwargs):
- return self._cobj.close(*args, **kwargs)
- def get(self, *args, **kwargs):
- return self._cobj.get(*args, **kwargs)
- def get_dbp(self, *args, **kwargs):
- return self._cobj.get_dbp(*args, **kwargs)
- def get_key(self, *args, **kwargs):
- return self._cobj.get_key(*args, **kwargs)
- def init_value(self, *args, **kwargs):
- return self._cobj.init_value(*args, **kwargs)
- def open(self, *args, **kwargs):
- return self._cobj.open(*args, **kwargs)
- def remove(self, *args, **kwargs):
- return self._cobj.remove(*args, **kwargs)
- def stat(self, *args, **kwargs):
- return self._cobj.stat(*args, **kwargs)
- def set_cachesize(self, *args, **kwargs):
- return self._cobj.set_cachesize(*args, **kwargs)
- def set_flags(self, *args, **kwargs):
- return self._cobj.set_flags(*args, **kwargs)
- def set_range(self, *args, **kwargs):
- return self._cobj.set_range(*args, **kwargs)
- def get_cachesize(self, *args, **kwargs):
- return self._cobj.get_cachesize(*args, **kwargs)
- def get_flags(self, *args, **kwargs):
- return self._cobj.get_flags(*args, **kwargs)
- def get_range(self, *args, **kwargs):
- return self._cobj.get_range(*args, **kwargs)
diff --git a/Lib/bsddb/dbrecio.py b/Lib/bsddb/dbrecio.py
deleted file mode 100644
index d439f3255e9..00000000000
--- a/Lib/bsddb/dbrecio.py
+++ /dev/null
@@ -1,190 +0,0 @@
-
-"""
-File-like objects that read from or write to a bsddb record.
-
-This implements (nearly) all stdio methods.
-
-f = DBRecIO(db, key, txn=None)
-f.close() # explicitly release resources held
-flag = f.isatty() # always false
-pos = f.tell() # get current position
-f.seek(pos) # set current position
-f.seek(pos, mode) # mode 0: absolute; 1: relative; 2: relative to EOF
-buf = f.read() # read until EOF
-buf = f.read(n) # read up to n bytes
-f.truncate([size]) # truncate file at to at most size (default: current pos)
-f.write(buf) # write at current position
-f.writelines(list) # for line in list: f.write(line)
-
-Notes:
-- fileno() is left unimplemented so that code which uses it triggers
- an exception early.
-- There's a simple test set (see end of this file) - not yet updated
- for DBRecIO.
-- readline() is not implemented yet.
-
-
-From:
- Itamar Shtull-Trauring <itamar@maxnm.com>
-"""
-
-import errno
-import string
-
-class DBRecIO:
- def __init__(self, db, key, txn=None):
- self.db = db
- self.key = key
- self.txn = txn
- self.len = None
- self.pos = 0
- self.closed = 0
- self.softspace = 0
-
- def close(self):
- if not self.closed:
- self.closed = 1
- del self.db, self.txn
-
- def isatty(self):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- return 0
-
- def seek(self, pos, mode = 0):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- if mode == 1:
- pos = pos + self.pos
- elif mode == 2:
- pos = pos + self.len
- self.pos = max(0, pos)
-
- def tell(self):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- return self.pos
-
- def read(self, n = -1):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- if n < 0:
- newpos = self.len
- else:
- newpos = min(self.pos+n, self.len)
-
- dlen = newpos - self.pos
-
- r = self.db.get(self.key, txn=self.txn, dlen=dlen, doff=self.pos)
- self.pos = newpos
- return r
-
- __fixme = """
- def readline(self, length=None):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- if self.buflist:
- self.buf = self.buf + string.joinfields(self.buflist, '')
- self.buflist = []
- i = string.find(self.buf, '\n', self.pos)
- if i < 0:
- newpos = self.len
- else:
- newpos = i+1
- if length is not None:
- if self.pos + length < newpos:
- newpos = self.pos + length
- r = self.buf[self.pos:newpos]
- self.pos = newpos
- return r
-
- def readlines(self, sizehint = 0):
- total = 0
- lines = []
- line = self.readline()
- while line:
- lines.append(line)
- total += len(line)
- if 0 < sizehint <= total:
- break
- line = self.readline()
- return lines
- """
-
- def truncate(self, size=None):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- if size is None:
- size = self.pos
- elif size < 0:
- raise IOError(errno.EINVAL,
- "Negative size not allowed")
- elif size < self.pos:
- self.pos = size
- self.db.put(self.key, "", txn=self.txn, dlen=self.len-size, doff=size)
-
- def write(self, s):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
- if not s: return
- if self.pos > self.len:
- self.buflist.append('\0'*(self.pos - self.len))
- self.len = self.pos
- newpos = self.pos + len(s)
- self.db.put(self.key, s, txn=self.txn, dlen=len(s), doff=self.pos)
- self.pos = newpos
-
- def writelines(self, list):
- self.write(string.joinfields(list, ''))
-
- def flush(self):
- if self.closed:
- raise ValueError, "I/O operation on closed file"
-
-
-"""
-# A little test suite
-
-def _test():
- import sys
- if sys.argv[1:]:
- file = sys.argv[1]
- else:
- file = '/etc/passwd'
- lines = open(file, 'r').readlines()
- text = open(file, 'r').read()
- f = StringIO()
- for line in lines[:-2]:
- f.write(line)
- f.writelines(lines[-2:])
- if f.getvalue() != text:
- raise RuntimeError, 'write failed'
- length = f.tell()
- print 'File length =', length
- f.seek(len(lines[0]))
- f.write(lines[1])
- f.seek(0)
- print 'First line =', repr(f.readline())
- here = f.tell()
- line = f.readline()
- print 'Second line =', repr(line)
- f.seek(-len(line), 1)
- line2 = f.read(len(line))
- if line != line2:
- raise RuntimeError, 'bad result after seek back'
- f.seek(len(line2), 1)
- list = f.readlines()
- line = list[-1]
- f.seek(f.tell() - len(line))
- line2 = f.read()
- if line != line2:
- raise RuntimeError, 'bad result after seek back from EOF'
- print 'Read', len(list), 'more lines'
- print 'File length =', f.tell()
- if f.tell() != length:
- raise RuntimeError, 'bad length'
- f.close()
-
-if __name__ == '__main__':
- _test()
-"""
diff --git a/Lib/bsddb/dbshelve.py b/Lib/bsddb/dbshelve.py
deleted file mode 100644
index e3f6d4c987d..00000000000
--- a/Lib/bsddb/dbshelve.py
+++ /dev/null
@@ -1,402 +0,0 @@
-#!/usr/bin/env python
-#------------------------------------------------------------------------
-# Copyright (c) 1997-2001 by Total Control Software
-# All Rights Reserved
-#------------------------------------------------------------------------
-#
-# Module Name: dbShelve.py
-#
-# Description: A reimplementation of the standard shelve.py that
-# forces the use of cPickle, and DB.
-#
-# Creation Date: 11/3/97 3:39:04PM
-#
-# License: This is free software. You may use this software for any
-# purpose including modification/redistribution, so long as
-# this header remains intact and that you do not claim any
-# rights of ownership or authorship of this software. This
-# software has been tested, but no warranty is expressed or
-# implied.
-#
-# 13-Dec-2000: Updated to be used with the new bsddb3 package.
-# Added DBShelfCursor class.
-#
-#------------------------------------------------------------------------
-
-"""Manage shelves of pickled objects using bsddb database files for the
-storage.
-"""
-
-#------------------------------------------------------------------------
-
-import sys
-absolute_import = (sys.version_info[0] >= 3)
-if absolute_import :
- # Because this syntaxis is not valid before Python 2.5
- exec("from . import db")
-else :
- import db
-
-if sys.version_info[0] >= 3 :
- import cPickle # Will be converted to "pickle" by "2to3"
-else :
- if sys.version_info < (2, 6) :
- import cPickle
- else :
- # When we drop support for python 2.3 and 2.4
- # we could use: (in 2.5 we need a __future__ statement)
- #
- # with warnings.catch_warnings():
- # warnings.filterwarnings(...)
- # ...
- #
- # We can not use "with" as is, because it would be invalid syntax
- # in python 2.3, 2.4 and (with no __future__) 2.5.
- # Here we simulate "with" following PEP 343 :
- import warnings
- w = warnings.catch_warnings()
- w.__enter__()
- try :
- warnings.filterwarnings('ignore',
- message='the cPickle module has been removed in Python 3.0',
- category=DeprecationWarning)
- import cPickle
- finally :
- w.__exit__()
- del w
-
-#At version 2.3 cPickle switched to using protocol instead of bin
-if sys.version_info >= (2, 3):
- HIGHEST_PROTOCOL = cPickle.HIGHEST_PROTOCOL
-# In python 2.3.*, "cPickle.dumps" accepts no
-# named parameters. "pickle.dumps" accepts them,
-# so this seems a bug.
- if sys.version_info < (2, 4):
- def _dumps(object, protocol):
- return cPickle.dumps(object, protocol)
- else :
- def _dumps(object, protocol):
- return cPickle.dumps(object, protocol=protocol)
-
-else:
- HIGHEST_PROTOCOL = None
- def _dumps(object, protocol):
- return cPickle.dumps(object, bin=protocol)
-
-
-if sys.version_info < (2, 6) :
- try:
- from UserDict import DictMixin
- except ImportError:
- # DictMixin is new in Python 2.3
- class DictMixin: pass
- MutableMapping = DictMixin
-else :
- import collections
- MutableMapping = collections.MutableMapping
-
-#------------------------------------------------------------------------
-
-
-def open(filename, flags=db.DB_CREATE, mode=0660, filetype=db.DB_HASH,
- dbenv=None, dbname=None):
- """
- A simple factory function for compatibility with the standard
- shleve.py module. It can be used like this, where key is a string
- and data is a pickleable object:
-
- from bsddb import dbshelve
- db = dbshelve.open(filename)
-
- db[key] = data
-
- db.close()
- """
- if type(flags) == type(''):
- sflag = flags
- if sflag == 'r':
- flags = db.DB_RDONLY
- elif sflag == 'rw':
- flags = 0
- elif sflag == 'w':
- flags = db.DB_CREATE
- elif sflag == 'c':
- flags = db.DB_CREATE
- elif sflag == 'n':
- flags = db.DB_TRUNCATE | db.DB_CREATE
- else:
- raise db.DBError, "flags should be one of 'r', 'w', 'c' or 'n' or use the bsddb.db.DB_* flags"
-
- d = DBShelf(dbenv)
- d.open(filename, dbname, filetype, flags, mode)
- return d
-
-#---------------------------------------------------------------------------
-
-class DBShelveError(db.DBError): pass
-
-
-class DBShelf(MutableMapping):
- """A shelf to hold pickled objects, built upon a bsddb DB object. It
- automatically pickles/unpickles data objects going to/from the DB.
- """
- def __init__(self, dbenv=None):
- self.db = db.DB(dbenv)
- self._closed = True
- if HIGHEST_PROTOCOL:
- self.protocol = HIGHEST_PROTOCOL
- else:
- self.protocol = 1
-
-
- def __del__(self):
- self.close()
-
-
- def __getattr__(self, name):
- """Many methods we can just pass through to the DB object.
- (See below)
- """
- return getattr(self.db, name)
-
-
- #-----------------------------------
- # Dictionary access methods
-
- def __len__(self):
- return len(self.db)
-
-
- def __getitem__(self, key):
- data = self.db[key]
- return cPickle.loads(data)
-
-
- def __setitem__(self, key, value):
- data = _dumps(value, self.protocol)
- self.db[key] = data
-
-
- def __delitem__(self, key):
- del self.db[key]
-
-
- def keys(self, txn=None):
- if txn is not None:
- return self.db.keys(txn)
- else:
- return self.db.keys()
-
- if sys.version_info >= (2, 6) :
- def __iter__(self) : # XXX: Load all keys in memory :-(
- for k in self.db.keys() :
- yield k
-
- # Do this when "DB" support iteration
- # Or is it enough to pass thru "getattr"?
- #
- # def __iter__(self) :
- # return self.db.__iter__()
-
-
- def open(self, *args, **kwargs):
- self.db.open(*args, **kwargs)
- self._closed = False
-
-
- def close(self, *args, **kwargs):
- self.db.close(*args, **kwargs)
- self._closed = True
-
-
- def __repr__(self):
- if self._closed:
- return '<DBShelf @ 0x%x - closed>' % (id(self))
- else:
- return repr(dict(self.iteritems()))
-
-
- def items(self, txn=None):
- if txn is not None:
- items = self.db.items(txn)
- else:
- items = self.db.items()
- newitems = []
-
- for k, v in items:
- newitems.append( (k, cPickle.loads(v)) )
- return newitems
-
- def values(self, txn=None):
- if txn is not None:
- values = self.db.values(txn)
- else:
- values = self.db.values()
-
- return map(cPickle.loads, values)
-
- #-----------------------------------
- # Other methods
-
- def __append(self, value, txn=None):
- data = _dumps(value, self.protocol)
- return self.db.append(data, txn)
-
- def append(self, value, txn=None):
- if self.get_type() == db.DB_RECNO:
- return self.__append(value, txn=txn)
- raise DBShelveError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
-
-
- def associate(self, secondaryDB, callback, flags=0):
- def _shelf_callback(priKey, priData, realCallback=callback):
- # Safe in Python 2.x because expresion short circuit
- if sys.version_info[0] < 3 or isinstance(priData, bytes) :
- data = cPickle.loads(priData)
- else :
- data = cPickle.loads(bytes(priData, "iso8859-1")) # 8 bits
- return realCallback(priKey, data)
-
- return self.db.associate(secondaryDB, _shelf_callback, flags)
-
-
- #def get(self, key, default=None, txn=None, flags=0):
- def get(self, *args, **kw):
- # We do it with *args and **kw so if the default value wasn't
- # given nothing is passed to the extension module. That way
- # an exception can be raised if set_get_returns_none is turned
- # off.
- data = self.db.get(*args, **kw)
- try:
- return cPickle.loads(data)
- except (EOFError, TypeError, cPickle.UnpicklingError):
- return data # we may be getting the default value, or None,
- # so it doesn't need unpickled.
-
- def get_both(self, key, value, txn=None, flags=0):
- data = _dumps(value, self.protocol)
- data = self.db.get(key, data, txn, flags)
- return cPickle.loads(data)
-
-
- def cursor(self, txn=None, flags=0):
- c = DBShelfCursor(self.db.cursor(txn, flags))
- c.protocol = self.protocol
- return c
-
-
- def put(self, key, value, txn=None, flags=0):
- data = _dumps(value, self.protocol)
- return self.db.put(key, data, txn, flags)
-
-
- def join(self, cursorList, flags=0):
- raise NotImplementedError
-
-
- #----------------------------------------------
- # Methods allowed to pass-through to self.db
- #
- # close, delete, fd, get_byteswapped, get_type, has_key,
- # key_range, open, remove, rename, stat, sync,
- # upgrade, verify, and all set_* methods.
-
-
-#---------------------------------------------------------------------------
-
-class DBShelfCursor:
- """
- """
- def __init__(self, cursor):
- self.dbc = cursor
-
- def __del__(self):
- self.close()
-
-
- def __getattr__(self, name):
- """Some methods we can just pass through to the cursor object. (See below)"""
- return getattr(self.dbc, name)
-
-
- #----------------------------------------------
-
- def dup(self, flags=0):
- c = DBShelfCursor(self.dbc.dup(flags))
- c.protocol = self.protocol
- return c
-
-
- def put(self, key, value, flags=0):
- data = _dumps(value, self.protocol)
- return self.dbc.put(key, data, flags)
-
-
- def get(self, *args):
- count = len(args) # a method overloading hack
- method = getattr(self, 'get_%d' % count)
- method(*args)
-
- def get_1(self, flags):
- rec = self.dbc.get(flags)
- return self._extract(rec)
-
- def get_2(self, key, flags):
- rec = self.dbc.get(key, flags)
- return self._extract(rec)
-
- def get_3(self, key, value, flags):
- data = _dumps(value, self.protocol)
- rec = self.dbc.get(key, flags)
- return self._extract(rec)
-
-
- def current(self, flags=0): return self.get_1(flags|db.DB_CURRENT)
- def first(self, flags=0): return self.get_1(flags|db.DB_FIRST)
- def last(self, flags=0): return self.get_1(flags|db.DB_LAST)
- def next(self, flags=0): return self.get_1(flags|db.DB_NEXT)
- def prev(self, flags=0): return self.get_1(flags|db.DB_PREV)
- def consume(self, flags=0): return self.get_1(flags|db.DB_CONSUME)
- def next_dup(self, flags=0): return self.get_1(flags|db.DB_NEXT_DUP)
- def next_nodup(self, flags=0): return self.get_1(flags|db.DB_NEXT_NODUP)
- def prev_nodup(self, flags=0): return self.get_1(flags|db.DB_PREV_NODUP)
-
-
- def get_both(self, key, value, flags=0):
- data = _dumps(value, self.protocol)
- rec = self.dbc.get_both(key, flags)
- return self._extract(rec)
-
-
- def set(self, key, flags=0):
- rec = self.dbc.set(key, flags)
- return self._extract(rec)
-
- def set_range(self, key, flags=0):
- rec = self.dbc.set_range(key, flags)
- return self._extract(rec)
-
- def set_recno(self, recno, flags=0):
- rec = self.dbc.set_recno(recno, flags)
- return self._extract(rec)
-
- set_both = get_both
-
- def _extract(self, rec):
- if rec is None:
- return None
- else:
- key, data = rec
- # Safe in Python 2.x because expresion short circuit
- if sys.version_info[0] < 3 or isinstance(data, bytes) :
- return key, cPickle.loads(data)
- else :
- return key, cPickle.loads(bytes(data, "iso8859-1")) # 8 bits
-
- #----------------------------------------------
- # Methods allowed to pass-through to self.dbc
- #
- # close, count, delete, get_recno, join_item
-
-
-#---------------------------------------------------------------------------
diff --git a/Lib/bsddb/dbtables.py b/Lib/bsddb/dbtables.py
deleted file mode 100644
index 3ebc68d5b0a..00000000000
--- a/Lib/bsddb/dbtables.py
+++ /dev/null
@@ -1,843 +0,0 @@
-#-----------------------------------------------------------------------
-#
-# Copyright (C) 2000, 2001 by Autonomous Zone Industries
-# Copyright (C) 2002 Gregory P. Smith
-#
-# License: This is free software. You may use this software for any
-# purpose including modification/redistribution, so long as
-# this header remains intact and that you do not claim any
-# rights of ownership or authorship of this software. This
-# software has been tested, but no warranty is expressed or
-# implied.
-#
-# -- Gregory P. Smith <greg@krypto.org>
-
-# This provides a simple database table interface built on top of
-# the Python Berkeley DB 3 interface.
-#
-_cvsid = '$Id$'
-
-import re
-import sys
-import copy
-import random
-import struct
-
-
-if sys.version_info[0] >= 3 :
- import pickle
-else :
- if sys.version_info < (2, 6) :
- import cPickle as pickle
- else :
- # When we drop support for python 2.3 and 2.4
- # we could use: (in 2.5 we need a __future__ statement)
- #
- # with warnings.catch_warnings():
- # warnings.filterwarnings(...)
- # ...
- #
- # We can not use "with" as is, because it would be invalid syntax
- # in python 2.3, 2.4 and (with no __future__) 2.5.
- # Here we simulate "with" following PEP 343 :
- import warnings
- w = warnings.catch_warnings()
- w.__enter__()
- try :
- warnings.filterwarnings('ignore',
- message='the cPickle module has been removed in Python 3.0',
- category=DeprecationWarning)
- import cPickle as pickle
- finally :
- w.__exit__()
- del w
-
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db
-except ImportError:
- # For Python 2.3
- from bsddb import db
-
-class TableDBError(StandardError):
- pass
-class TableAlreadyExists(TableDBError):
- pass
-
-
-class Cond:
- """This condition matches everything"""
- def __call__(self, s):
- return 1
-
-class ExactCond(Cond):
- """Acts as an exact match condition function"""
- def __init__(self, strtomatch):
- self.strtomatch = strtomatch
- def __call__(self, s):
- return s == self.strtomatch
-
-class PrefixCond(Cond):
- """Acts as a condition function for matching a string prefix"""
- def __init__(self, prefix):
- self.prefix = prefix
- def __call__(self, s):
- return s[:len(self.prefix)] == self.prefix
-
-class PostfixCond(Cond):
- """Acts as a condition function for matching a string postfix"""
- def __init__(self, postfix):
- self.postfix = postfix
- def __call__(self, s):
- return s[-len(self.postfix):] == self.postfix
-
-class LikeCond(Cond):
- """
- Acts as a function that will match using an SQL 'LIKE' style
- string. Case insensitive and % signs are wild cards.
- This isn't perfect but it should work for the simple common cases.
- """
- def __init__(self, likestr, re_flags=re.IGNORECASE):
- # escape python re characters
- chars_to_escape = '.*+()[]?'
- for char in chars_to_escape :
- likestr = likestr.replace(char, '\\'+char)
- # convert %s to wildcards
- self.likestr = likestr.replace('%', '.*')
- self.re = re.compile('^'+self.likestr+'$', re_flags)
- def __call__(self, s):
- return self.re.match(s)
-
-#
-# keys used to store database metadata
-#
-_table_names_key = '__TABLE_NAMES__' # list of the tables in this db
-_columns = '._COLUMNS__' # table_name+this key contains a list of columns
-
-def _columns_key(table):
- return table + _columns
-
-#
-# these keys are found within table sub databases
-#
-_data = '._DATA_.' # this+column+this+rowid key contains table data
-_rowid = '._ROWID_.' # this+rowid+this key contains a unique entry for each
- # row in the table. (no data is stored)
-_rowid_str_len = 8 # length in bytes of the unique rowid strings
-
-
-def _data_key(table, col, rowid):
- return table + _data + col + _data + rowid
-
-def _search_col_data_key(table, col):
- return table + _data + col + _data
-
-def _search_all_data_key(table):
- return table + _data
-
-def _rowid_key(table, rowid):
- return table + _rowid + rowid + _rowid
-
-def _search_rowid_key(table):
- return table + _rowid
-
-def contains_metastrings(s) :
- """Verify that the given string does not contain any
- metadata strings that might interfere with dbtables database operation.
- """
- if (s.find(_table_names_key) >= 0 or
- s.find(_columns) >= 0 or
- s.find(_data) >= 0 or
- s.find(_rowid) >= 0):
- # Then
- return 1
- else:
- return 0
-
-
-class bsdTableDB :
- def __init__(self, filename, dbhome, create=0, truncate=0, mode=0600,
- recover=0, dbflags=0):
- """bsdTableDB(filename, dbhome, create=0, truncate=0, mode=0600)
-
- Open database name in the dbhome Berkeley DB directory.
- Use keyword arguments when calling this constructor.
- """
- self.db = None
- myflags = db.DB_THREAD
- if create:
- myflags |= db.DB_CREATE
- flagsforenv = (db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_LOG |
- db.DB_INIT_TXN | dbflags)
- # DB_AUTO_COMMIT isn't a valid flag for env.open()
- try:
- dbflags |= db.DB_AUTO_COMMIT
- except AttributeError:
- pass
- if recover:
- flagsforenv = flagsforenv | db.DB_RECOVER
- self.env = db.DBEnv()
- # enable auto deadlock avoidance
- self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
- self.env.open(dbhome, myflags | flagsforenv)
- if truncate:
- myflags |= db.DB_TRUNCATE
- self.db = db.DB(self.env)
- # this code relies on DBCursor.set* methods to raise exceptions
- # rather than returning None
- self.db.set_get_returns_none(1)
- # allow duplicate entries [warning: be careful w/ metadata]
- self.db.set_flags(db.DB_DUP)
- self.db.open(filename, db.DB_BTREE, dbflags | myflags, mode)
- self.dbfilename = filename
-
- if sys.version_info[0] >= 3 :
- class cursor_py3k(object) :
- def __init__(self, dbcursor) :
- self._dbcursor = dbcursor
-
- def close(self) :
- return self._dbcursor.close()
-
- def set_range(self, search) :
- v = self._dbcursor.set_range(bytes(search, "iso8859-1"))
- if v is not None :
- v = (v[0].decode("iso8859-1"),
- v[1].decode("iso8859-1"))
- return v
-
- def __next__(self) :
- v = getattr(self._dbcursor, "next")()
- if v is not None :
- v = (v[0].decode("iso8859-1"),
- v[1].decode("iso8859-1"))
- return v
-
- class db_py3k(object) :
- def __init__(self, db) :
- self._db = db
-
- def cursor(self, txn=None) :
- return cursor_py3k(self._db.cursor(txn=txn))
-
- def has_key(self, key, txn=None) :
- return getattr(self._db,"has_key")(bytes(key, "iso8859-1"),
- txn=txn)
-
- def put(self, key, value, flags=0, txn=None) :
- key = bytes(key, "iso8859-1")
- if value is not None :
- value = bytes(value, "iso8859-1")
- return self._db.put(key, value, flags=flags, txn=txn)
-
- def put_bytes(self, key, value, txn=None) :
- key = bytes(key, "iso8859-1")
- return self._db.put(key, value, txn=txn)
-
- def get(self, key, txn=None, flags=0) :
- key = bytes(key, "iso8859-1")
- v = self._db.get(key, txn=txn, flags=flags)
- if v is not None :
- v = v.decode("iso8859-1")
- return v
-
- def get_bytes(self, key, txn=None, flags=0) :
- key = bytes(key, "iso8859-1")
- return self._db.get(key, txn=txn, flags=flags)
-
- def delete(self, key, txn=None) :
- key = bytes(key, "iso8859-1")
- return self._db.delete(key, txn=txn)
-
- def close (self) :
- return self._db.close()
-
- self.db = db_py3k(self.db)
- else : # Python 2.x
- pass
-
- # Initialize the table names list if this is a new database
- txn = self.env.txn_begin()
- try:
- if not getattr(self.db, "has_key")(_table_names_key, txn):
- getattr(self.db, "put_bytes", self.db.put) \
- (_table_names_key, pickle.dumps([], 1), txn=txn)
- # Yes, bare except
- except:
- txn.abort()
- raise
- else:
- txn.commit()
- # TODO verify more of the database's metadata?
- self.__tablecolumns = {}
-
- def __del__(self):
- self.close()
-
- def close(self):
- if self.db is not None:
- self.db.close()
- self.db = None
- if self.env is not None:
- self.env.close()
- self.env = None
-
- def checkpoint(self, mins=0):
- self.env.txn_checkpoint(mins)
-
- def sync(self):
- self.db.sync()
-
- def _db_print(self) :
- """Print the database to stdout for debugging"""
- print "******** Printing raw database for debugging ********"
- cur = self.db.cursor()
- try:
- key, data = cur.first()
- while 1:
- print repr({key: data})
- next = cur.next()
- if next:
- key, data = next
- else:
- cur.close()
- return
- except db.DBNotFoundError:
- cur.close()
-
-
- def CreateTable(self, table, columns):
- """CreateTable(table, columns) - Create a new table in the database.
-
- raises TableDBError if it already exists or for other DB errors.
- """
- assert isinstance(columns, list)
-
- txn = None
- try:
- # checking sanity of the table and column names here on
- # table creation will prevent problems elsewhere.
- if contains_metastrings(table):
- raise ValueError(
- "bad table name: contains reserved metastrings")
- for column in columns :
- if contains_metastrings(column):
- raise ValueError(
- "bad column name: contains reserved metastrings")
-
- columnlist_key = _columns_key(table)
- if getattr(self.db, "has_key")(columnlist_key):
- raise TableAlreadyExists, "table already exists"
-
- txn = self.env.txn_begin()
- # store the table's column info
- getattr(self.db, "put_bytes", self.db.put)(columnlist_key,
- pickle.dumps(columns, 1), txn=txn)
-
- # add the table name to the tablelist
- tablelist = pickle.loads(getattr(self.db, "get_bytes",
- self.db.get) (_table_names_key, txn=txn, flags=db.DB_RMW))
- tablelist.append(table)
- # delete 1st, in case we opened with DB_DUP
- self.db.delete(_table_names_key, txn=txn)
- getattr(self.db, "put_bytes", self.db.put)(_table_names_key,
- pickle.dumps(tablelist, 1), txn=txn)
-
- txn.commit()
- txn = None
- except db.DBError, dberror:
- if txn:
- txn.abort()
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1]
- else :
- raise TableDBError, dberror.args[1]
-
-
- def ListTableColumns(self, table):
- """Return a list of columns in the given table.
- [] if the table doesn't exist.
- """
- assert isinstance(table, str)
- if contains_metastrings(table):
- raise ValueError, "bad table name: contains reserved metastrings"
-
- columnlist_key = _columns_key(table)
- if not getattr(self.db, "has_key")(columnlist_key):
- return []
- pickledcolumnlist = getattr(self.db, "get_bytes",
- self.db.get)(columnlist_key)
- if pickledcolumnlist:
- return pickle.loads(pickledcolumnlist)
- else:
- return []
-
- def ListTables(self):
- """Return a list of tables in this database."""
- pickledtablelist = self.db.get_get(_table_names_key)
- if pickledtablelist:
- return pickle.loads(pickledtablelist)
- else:
- return []
-
- def CreateOrExtendTable(self, table, columns):
- """CreateOrExtendTable(table, columns)
-
- Create a new table in the database.
-
- If a table of this name already exists, extend it to have any
- additional columns present in the given list as well as
- all of its current columns.
- """
- assert isinstance(columns, list)
-
- try:
- self.CreateTable(table, columns)
- except TableAlreadyExists:
- # the table already existed, add any new columns
- txn = None
- try:
- columnlist_key = _columns_key(table)
- txn = self.env.txn_begin()
-
- # load the current column list
- oldcolumnlist = pickle.loads(
- getattr(self.db, "get_bytes",
- self.db.get)(columnlist_key, txn=txn, flags=db.DB_RMW))
- # create a hash table for fast lookups of column names in the
- # loop below
- oldcolumnhash = {}
- for c in oldcolumnlist:
- oldcolumnhash[c] = c
-
- # create a new column list containing both the old and new
- # column names
- newcolumnlist = copy.copy(oldcolumnlist)
- for c in columns:
- if not c in oldcolumnhash:
- newcolumnlist.append(c)
-
- # store the table's new extended column list
- if newcolumnlist != oldcolumnlist :
- # delete the old one first since we opened with DB_DUP
- self.db.delete(columnlist_key, txn=txn)
- getattr(self.db, "put_bytes", self.db.put)(columnlist_key,
- pickle.dumps(newcolumnlist, 1),
- txn=txn)
-
- txn.commit()
- txn = None
-
- self.__load_column_info(table)
- except db.DBError, dberror:
- if txn:
- txn.abort()
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1]
- else :
- raise TableDBError, dberror.args[1]
-
-
- def __load_column_info(self, table) :
- """initialize the self.__tablecolumns dict"""
- # check the column names
- try:
- tcolpickles = getattr(self.db, "get_bytes",
- self.db.get)(_columns_key(table))
- except db.DBNotFoundError:
- raise TableDBError, "unknown table: %r" % (table,)
- if not tcolpickles:
- raise TableDBError, "unknown table: %r" % (table,)
- self.__tablecolumns[table] = pickle.loads(tcolpickles)
-
- def __new_rowid(self, table, txn) :
- """Create a new unique row identifier"""
- unique = 0
- while not unique:
- # Generate a random 64-bit row ID string
- # (note: might have <64 bits of true randomness
- # but it's plenty for our database id needs!)
- blist = []
- for x in xrange(_rowid_str_len):
- blist.append(random.randint(0,255))
- newid = struct.pack('B'*_rowid_str_len, *blist)
-
- if sys.version_info[0] >= 3 :
- newid = newid.decode("iso8859-1") # 8 bits
-
- # Guarantee uniqueness by adding this key to the database
- try:
- self.db.put(_rowid_key(table, newid), None, txn=txn,
- flags=db.DB_NOOVERWRITE)
- except db.DBKeyExistError:
- pass
- else:
- unique = 1
-
- return newid
-
-
- def Insert(self, table, rowdict) :
- """Insert(table, datadict) - Insert a new row into the table
- using the keys+values from rowdict as the column values.
- """
-
- txn = None
- try:
- if not getattr(self.db, "has_key")(_columns_key(table)):
- raise TableDBError, "unknown table"
-
- # check the validity of each column name
- if not table in self.__tablecolumns:
- self.__load_column_info(table)
- for column in rowdict.keys() :
- if not self.__tablecolumns[table].count(column):
- raise TableDBError, "unknown column: %r" % (column,)
-
- # get a unique row identifier for this row
- txn = self.env.txn_begin()
- rowid = self.__new_rowid(table, txn=txn)
-
- # insert the row values into the table database
- for column, dataitem in rowdict.items():
- # store the value
- self.db.put(_data_key(table, column, rowid), dataitem, txn=txn)
-
- txn.commit()
- txn = None
-
- except db.DBError, dberror:
- # WIBNI we could just abort the txn and re-raise the exception?
- # But no, because TableDBError is not related to DBError via
- # inheritance, so it would be backwards incompatible. Do the next
- # best thing.
- info = sys.exc_info()
- if txn:
- txn.abort()
- self.db.delete(_rowid_key(table, rowid))
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1], info[2]
- else :
- raise TableDBError, dberror.args[1], info[2]
-
-
- def Modify(self, table, conditions={}, mappings={}):
- """Modify(table, conditions={}, mappings={}) - Modify items in rows matching 'conditions' using mapping functions in 'mappings'
-
- * table - the table name
- * conditions - a dictionary keyed on column names containing
- a condition callable expecting the data string as an
- argument and returning a boolean.
- * mappings - a dictionary keyed on column names containing a
- condition callable expecting the data string as an argument and
- returning the new string for that column.
- """
-
- try:
- matching_rowids = self.__Select(table, [], conditions)
-
- # modify only requested columns
- columns = mappings.keys()
- for rowid in matching_rowids.keys():
- txn = None
- try:
- for column in columns:
- txn = self.env.txn_begin()
- # modify the requested column
- try:
- dataitem = self.db.get(
- _data_key(table, column, rowid),
- txn=txn)
- self.db.delete(
- _data_key(table, column, rowid),
- txn=txn)
- except db.DBNotFoundError:
- # XXXXXXX row key somehow didn't exist, assume no
- # error
- dataitem = None
- dataitem = mappings[column](dataitem)
- if dataitem is not None:
- self.db.put(
- _data_key(table, column, rowid),
- dataitem, txn=txn)
- txn.commit()
- txn = None
-
- # catch all exceptions here since we call unknown callables
- except:
- if txn:
- txn.abort()
- raise
-
- except db.DBError, dberror:
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1]
- else :
- raise TableDBError, dberror.args[1]
-
- def Delete(self, table, conditions={}):
- """Delete(table, conditions) - Delete items matching the given
- conditions from the table.
-
- * conditions - a dictionary keyed on column names containing
- condition functions expecting the data string as an
- argument and returning a boolean.
- """
-
- try:
- matching_rowids = self.__Select(table, [], conditions)
-
- # delete row data from all columns
- columns = self.__tablecolumns[table]
- for rowid in matching_rowids.keys():
- txn = None
- try:
- txn = self.env.txn_begin()
- for column in columns:
- # delete the data key
- try:
- self.db.delete(_data_key(table, column, rowid),
- txn=txn)
- except db.DBNotFoundError:
- # XXXXXXX column may not exist, assume no error
- pass
-
- try:
- self.db.delete(_rowid_key(table, rowid), txn=txn)
- except db.DBNotFoundError:
- # XXXXXXX row key somehow didn't exist, assume no error
- pass
- txn.commit()
- txn = None
- except db.DBError, dberror:
- if txn:
- txn.abort()
- raise
- except db.DBError, dberror:
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1]
- else :
- raise TableDBError, dberror.args[1]
-
-
- def Select(self, table, columns, conditions={}):
- """Select(table, columns, conditions) - retrieve specific row data
- Returns a list of row column->value mapping dictionaries.
-
- * columns - a list of which column data to return. If
- columns is None, all columns will be returned.
- * conditions - a dictionary keyed on column names
- containing callable conditions expecting the data string as an
- argument and returning a boolean.
- """
- try:
- if not table in self.__tablecolumns:
- self.__load_column_info(table)
- if columns is None:
- columns = self.__tablecolumns[table]
- matching_rowids = self.__Select(table, columns, conditions)
- except db.DBError, dberror:
- if sys.version_info < (2, 6) :
- raise TableDBError, dberror[1]
- else :
- raise TableDBError, dberror.args[1]
- # return the matches as a list of dictionaries
- return matching_rowids.values()
-
-
- def __Select(self, table, columns, conditions):
- """__Select() - Used to implement Select and Delete (above)
- Returns a dictionary keyed on rowids containing dicts
- holding the row data for columns listed in the columns param
- that match the given conditions.
- * conditions is a dictionary keyed on column names
- containing callable conditions expecting the data string as an
- argument and returning a boolean.
- """
- # check the validity of each column name
- if not table in self.__tablecolumns:
- self.__load_column_info(table)
- if columns is None:
- columns = self.tablecolumns[table]
- for column in (columns + conditions.keys()):
- if not self.__tablecolumns[table].count(column):
- raise TableDBError, "unknown column: %r" % (column,)
-
- # keyed on rows that match so far, containings dicts keyed on
- # column names containing the data for that row and column.
- matching_rowids = {}
- # keys are rowids that do not match
- rejected_rowids = {}
-
- # attempt to sort the conditions in such a way as to minimize full
- # column lookups
- def cmp_conditions(atuple, btuple):
- a = atuple[1]
- b = btuple[1]
- if type(a) is type(b):
-
- # Needed for python 3. "cmp" vanished in 3.0.1
- def cmp(a, b) :
- if a==b : return 0
- if a<b : return -1
- return 1
-
- if isinstance(a, PrefixCond) and isinstance(b, PrefixCond):
- # longest prefix first
- return cmp(len(b.prefix), len(a.prefix))
- if isinstance(a, LikeCond) and isinstance(b, LikeCond):
- # longest likestr first
- return cmp(len(b.likestr), len(a.likestr))
- return 0
- if isinstance(a, ExactCond):
- return -1
- if isinstance(b, ExactCond):
- return 1
- if isinstance(a, PrefixCond):
- return -1
- if isinstance(b, PrefixCond):
- return 1
- # leave all unknown condition callables alone as equals
- return 0
-
- if sys.version_info < (2, 6) :
- conditionlist = conditions.items()
- conditionlist.sort(cmp_conditions)
- else : # Insertion Sort. Please, improve
- conditionlist = []
- for i in conditions.items() :
- for j, k in enumerate(conditionlist) :
- r = cmp_conditions(k, i)
- if r == 1 :
- conditionlist.insert(j, i)
- break
- else :
- conditionlist.append(i)
-
- # Apply conditions to column data to find what we want
- cur = self.db.cursor()
- column_num = -1
- for column, condition in conditionlist:
- column_num = column_num + 1
- searchkey = _search_col_data_key(table, column)
- # speedup: don't linear search columns within loop
- if column in columns:
- savethiscolumndata = 1 # save the data for return
- else:
- savethiscolumndata = 0 # data only used for selection
-
- try:
- key, data = cur.set_range(searchkey)
- while key[:len(searchkey)] == searchkey:
- # extract the rowid from the key
- rowid = key[-_rowid_str_len:]
-
- if not rowid in rejected_rowids:
- # if no condition was specified or the condition
- # succeeds, add row to our match list.
- if not condition or condition(data):
- if not rowid in matching_rowids:
- matching_rowids[rowid] = {}
- if savethiscolumndata:
- matching_rowids[rowid][column] = data
- else:
- if rowid in matching_rowids:
- del matching_rowids[rowid]
- rejected_rowids[rowid] = rowid
-
- key, data = cur.next()
-
- except db.DBError, dberror:
- if dberror.args[0] != db.DB_NOTFOUND:
- raise
- continue
-
- cur.close()
-
- # we're done selecting rows, garbage collect the reject list
- del rejected_rowids
-
- # extract any remaining desired column data from the
- # database for the matching rows.
- if len(columns) > 0:
- for rowid, rowdata in matching_rowids.items():
- for column in columns:
- if column in rowdata:
- continue
- try:
- rowdata[column] = self.db.get(
- _data_key(table, column, rowid))
- except db.DBError, dberror:
- if sys.version_info < (2, 6) :
- if dberror[0] != db.DB_NOTFOUND:
- raise
- else :
- if dberror.args[0] != db.DB_NOTFOUND:
- raise
- rowdata[column] = None
-
- # return the matches
- return matching_rowids
-
-
- def Drop(self, table):
- """Remove an entire table from the database"""
- txn = None
- try:
- txn = self.env.txn_begin()
-
- # delete the column list
- self.db.delete(_columns_key(table), txn=txn)
-
- cur = self.db.cursor(txn)
-
- # delete all keys containing this tables column and row info
- table_key = _search_all_data_key(table)
- while 1:
- try:
- key, data = cur.set_range(table_key)
- except db.DBNotFoundError:
- break
- # only delete items in this table
- if key[:len(table_key)] != table_key:
- break
- cur.delete()
-
- # delete all rowids used by this table
- table_key = _search_rowid_key(table)
- while 1:
- try:
- key, data = cur.set_range(table_key)
- except db.DBNotFoundError:
- break
- # only delete items in this table
- if key[:len(table_key)] != table_key:
- break
- cur.delete()
-
- cur.close()
-
- # delete the tablename from the table name list
- tablelist = pickle.loads(
- getattr(self.db, "get_bytes", self.db.get)(_table_names_key,
- txn=txn, flags=db.DB_RMW))
- try:
- tablelist.remove(table)
- except ValueError:
- # hmm, it wasn't there, oh well, that's what we want.
- pass
- # delete 1st, incase we opened with DB_DUP
- self.db.delete(_table_names_key, txn=txn)
- getattr(self.db, "put_bytes", self.db.put)(_table_names_key,
- pickle.dumps(tablelist, 1), txn=txn)
-
- txn.commit()
- txn = None
-
- if table in self.__tablecolumns:
- del self.__tablecolumns[table]
-
- except db.DBError, dberror:
- if txn:
- txn.abort()
- raise TableDBError(dberror.args[1])
diff --git a/Lib/bsddb/dbutils.py b/Lib/bsddb/dbutils.py
deleted file mode 100644
index 02a686f5d9a..00000000000
--- a/Lib/bsddb/dbutils.py
+++ /dev/null
@@ -1,83 +0,0 @@
-#------------------------------------------------------------------------
-#
-# Copyright (C) 2000 Autonomous Zone Industries
-#
-# License: This is free software. You may use this software for any
-# purpose including modification/redistribution, so long as
-# this header remains intact and that you do not claim any
-# rights of ownership or authorship of this software. This
-# software has been tested, but no warranty is expressed or
-# implied.
-#
-# Author: Gregory P. Smith <greg@krypto.org>
-#
-# Note: I don't know how useful this is in reality since when a
-# DBLockDeadlockError happens the current transaction is supposed to be
-# aborted. If it doesn't then when the operation is attempted again
-# the deadlock is still happening...
-# --Robin
-#
-#------------------------------------------------------------------------
-
-
-#
-# import the time.sleep function in a namespace safe way to allow
-# "from bsddb.dbutils import *"
-#
-from time import sleep as _sleep
-
-import sys
-absolute_import = (sys.version_info[0] >= 3)
-if absolute_import :
- # Because this syntaxis is not valid before Python 2.5
- exec("from . import db")
-else :
- import db
-
-# always sleep at least N seconds between retrys
-_deadlock_MinSleepTime = 1.0/128
-# never sleep more than N seconds between retrys
-_deadlock_MaxSleepTime = 3.14159
-
-# Assign a file object to this for a "sleeping" message to be written to it
-# each retry
-_deadlock_VerboseFile = None
-
-
-def DeadlockWrap(function, *_args, **_kwargs):
- """DeadlockWrap(function, *_args, **_kwargs) - automatically retries
- function in case of a database deadlock.
-
- This is a function intended to be used to wrap database calls such
- that they perform retrys with exponentially backing off sleeps in
- between when a DBLockDeadlockError exception is raised.
-
- A 'max_retries' parameter may optionally be passed to prevent it
- from retrying forever (in which case the exception will be reraised).
-
- d = DB(...)
- d.open(...)
- DeadlockWrap(d.put, "foo", data="bar") # set key "foo" to "bar"
- """
- sleeptime = _deadlock_MinSleepTime
- max_retries = _kwargs.get('max_retries', -1)
- if 'max_retries' in _kwargs:
- del _kwargs['max_retries']
- while True:
- try:
- return function(*_args, **_kwargs)
- except db.DBLockDeadlockError:
- if _deadlock_VerboseFile:
- _deadlock_VerboseFile.write(
- 'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
- _sleep(sleeptime)
- # exponential backoff in the sleep time
- sleeptime *= 2
- if sleeptime > _deadlock_MaxSleepTime:
- sleeptime = _deadlock_MaxSleepTime
- max_retries -= 1
- if max_retries == -1:
- raise
-
-
-#------------------------------------------------------------------------
diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py
deleted file mode 100644
index e9fe618fdbc..00000000000
--- a/Lib/bsddb/test/test_all.py
+++ /dev/null
@@ -1,622 +0,0 @@
-"""Run all test cases.
-"""
-
-import sys
-import os
-import unittest
-try:
- # For Pythons w/distutils pybsddb
- import bsddb3 as bsddb
-except ImportError:
- # For Python 2.3
- import bsddb
-
-
-if sys.version_info[0] >= 3 :
- charset = "iso8859-1" # Full 8 bit
-
- class logcursor_py3k(object) :
- def __init__(self, env) :
- self._logcursor = env.log_cursor()
-
- def __getattr__(self, v) :
- return getattr(self._logcursor, v)
-
- def __next__(self) :
- v = getattr(self._logcursor, "next")()
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- next = __next__
-
- def first(self) :
- v = self._logcursor.first()
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- def last(self) :
- v = self._logcursor.last()
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- def prev(self) :
- v = self._logcursor.prev()
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- def current(self) :
- v = self._logcursor.current()
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- def set(self, lsn) :
- v = self._logcursor.set(lsn)
- if v is not None :
- v = (v[0], v[1].decode(charset))
- return v
-
- class cursor_py3k(object) :
- def __init__(self, db, *args, **kwargs) :
- self._dbcursor = db.cursor(*args, **kwargs)
-
- def __getattr__(self, v) :
- return getattr(self._dbcursor, v)
-
- def _fix(self, v) :
- if v is None : return None
- key, value = v
- if isinstance(key, bytes) :
- key = key.decode(charset)
- return (key, value.decode(charset))
-
- def __next__(self) :
- v = getattr(self._dbcursor, "next")()
- return self._fix(v)
-
- next = __next__
-
- def previous(self) :
- v = self._dbcursor.previous()
- return self._fix(v)
-
- def last(self) :
- v = self._dbcursor.last()
- return self._fix(v)
-
- def set(self, k) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- v = self._dbcursor.set(k)
- return self._fix(v)
-
- def set_recno(self, num) :
- v = self._dbcursor.set_recno(num)
- return self._fix(v)
-
- def set_range(self, k, dlen=-1, doff=-1) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- v = self._dbcursor.set_range(k, dlen=dlen, doff=doff)
- return self._fix(v)
-
- def dup(self, flags=0) :
- cursor = self._dbcursor.dup(flags)
- return dup_cursor_py3k(cursor)
-
- def next_dup(self) :
- v = self._dbcursor.next_dup()
- return self._fix(v)
-
- def next_nodup(self) :
- v = self._dbcursor.next_nodup()
- return self._fix(v)
-
- def put(self, key, data, flags=0, dlen=-1, doff=-1) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- if isinstance(data, str) :
- value = bytes(data, charset)
- return self._dbcursor.put(key, data, flags=flags, dlen=dlen,
- doff=doff)
-
- def current(self, flags=0, dlen=-1, doff=-1) :
- v = self._dbcursor.current(flags=flags, dlen=dlen, doff=doff)
- return self._fix(v)
-
- def first(self) :
- v = self._dbcursor.first()
- return self._fix(v)
-
- def pget(self, key=None, data=None, flags=0) :
- # Incorrect because key can be a bare number,
- # but enough to pass testsuite
- if isinstance(key, int) and (data is None) and (flags == 0) :
- flags = key
- key = None
- if isinstance(key, str) :
- key = bytes(key, charset)
- if isinstance(data, int) and (flags==0) :
- flags = data
- data = None
- if isinstance(data, str) :
- data = bytes(data, charset)
- v=self._dbcursor.pget(key=key, data=data, flags=flags)
- if v is not None :
- v1, v2, v3 = v
- if isinstance(v1, bytes) :
- v1 = v1.decode(charset)
- if isinstance(v2, bytes) :
- v2 = v2.decode(charset)
-
- v = (v1, v2, v3.decode(charset))
-
- return v
-
- def join_item(self) :
- v = self._dbcursor.join_item()
- if v is not None :
- v = v.decode(charset)
- return v
-
- def get(self, *args, **kwargs) :
- l = len(args)
- if l == 2 :
- k, f = args
- if isinstance(k, str) :
- k = bytes(k, "iso8859-1")
- args = (k, f)
- elif l == 3 :
- k, d, f = args
- if isinstance(k, str) :
- k = bytes(k, charset)
- if isinstance(d, str) :
- d = bytes(d, charset)
- args =(k, d, f)
-
- v = self._dbcursor.get(*args, **kwargs)
- if v is not None :
- k, v = v
- if isinstance(k, bytes) :
- k = k.decode(charset)
- v = (k, v.decode(charset))
- return v
-
- def get_both(self, key, value) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- if isinstance(value, str) :
- value = bytes(value, charset)
- v=self._dbcursor.get_both(key, value)
- return self._fix(v)
-
- class dup_cursor_py3k(cursor_py3k) :
- def __init__(self, dbcursor) :
- self._dbcursor = dbcursor
-
- class DB_py3k(object) :
- def __init__(self, *args, **kwargs) :
- args2=[]
- for i in args :
- if isinstance(i, DBEnv_py3k) :
- i = i._dbenv
- args2.append(i)
- args = tuple(args2)
- for k, v in kwargs.items() :
- if isinstance(v, DBEnv_py3k) :
- kwargs[k] = v._dbenv
-
- self._db = bsddb._db.DB_orig(*args, **kwargs)
-
- def __contains__(self, k) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- return getattr(self._db, "has_key")(k)
-
- def __getitem__(self, k) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- v = self._db[k]
- if v is not None :
- v = v.decode(charset)
- return v
-
- def __setitem__(self, k, v) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- if isinstance(v, str) :
- v = bytes(v, charset)
- self._db[k] = v
-
- def __delitem__(self, k) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- del self._db[k]
-
- def __getattr__(self, v) :
- return getattr(self._db, v)
-
- def __len__(self) :
- return len(self._db)
-
- def has_key(self, k, txn=None) :
- if isinstance(k, str) :
- k = bytes(k, charset)
- return self._db.has_key(k, txn=txn)
-
- def set_re_delim(self, c) :
- if isinstance(c, str) : # We can use a numeric value byte too
- c = bytes(c, charset)
- return self._db.set_re_delim(c)
-
- def set_re_pad(self, c) :
- if isinstance(c, str) : # We can use a numeric value byte too
- c = bytes(c, charset)
- return self._db.set_re_pad(c)
-
- def get_re_source(self) :
- source = self._db.get_re_source()
- return source.decode(charset)
-
- def put(self, key, data, txn=None, flags=0, dlen=-1, doff=-1) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- if isinstance(data, str) :
- value = bytes(data, charset)
- return self._db.put(key, data, flags=flags, txn=txn, dlen=dlen,
- doff=doff)
-
- def append(self, value, txn=None) :
- if isinstance(value, str) :
- value = bytes(value, charset)
- return self._db.append(value, txn=txn)
-
- def get_size(self, key) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- return self._db.get_size(key)
-
- def exists(self, key, *args, **kwargs) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- return self._db.exists(key, *args, **kwargs)
-
- def get(self, key, default="MagicCookie", txn=None, flags=0, dlen=-1, doff=-1) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- if default != "MagicCookie" : # Magic for 'test_get_none.py'
- v=self._db.get(key, default=default, txn=txn, flags=flags,
- dlen=dlen, doff=doff)
- else :
- v=self._db.get(key, txn=txn, flags=flags,
- dlen=dlen, doff=doff)
- if (v is not None) and isinstance(v, bytes) :
- v = v.decode(charset)
- return v
-
- def pget(self, key, txn=None) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- v=self._db.pget(key, txn=txn)
- if v is not None :
- v1, v2 = v
- if isinstance(v1, bytes) :
- v1 = v1.decode(charset)
-
- v = (v1, v2.decode(charset))
- return v
-
- def get_both(self, key, value, txn=None, flags=0) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- if isinstance(value, str) :
- value = bytes(value, charset)
- v=self._db.get_both(key, value, txn=txn, flags=flags)
- if v is not None :
- v = v.decode(charset)
- return v
-
- def delete(self, key, txn=None) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- return self._db.delete(key, txn=txn)
-
- def keys(self) :
- k = self._db.keys()
- if len(k) and isinstance(k[0], bytes) :
- return [i.decode(charset) for i in self._db.keys()]
- else :
- return k
-
- def items(self) :
- data = self._db.items()
- if not len(data) : return data
- data2 = []
- for k, v in data :
- if isinstance(k, bytes) :
- k = k.decode(charset)
- data2.append((k, v.decode(charset)))
- return data2
-
- def associate(self, secondarydb, callback, flags=0, txn=None) :
- class associate_callback(object) :
- def __init__(self, callback) :
- self._callback = callback
-
- def callback(self, key, data) :
- if isinstance(key, str) :
- key = key.decode(charset)
- data = data.decode(charset)
- key = self._callback(key, data)
- if (key != bsddb._db.DB_DONOTINDEX) :
- if isinstance(key, str) :
- key = bytes(key, charset)
- elif isinstance(key, list) :
- key2 = []
- for i in key :
- if isinstance(i, str) :
- i = bytes(i, charset)
- key2.append(i)
- key = key2
- return key
-
- return self._db.associate(secondarydb._db,
- associate_callback(callback).callback, flags=flags,
- txn=txn)
-
- def cursor(self, txn=None, flags=0) :
- return cursor_py3k(self._db, txn=txn, flags=flags)
-
- def join(self, cursor_list) :
- cursor_list = [i._dbcursor for i in cursor_list]
- return dup_cursor_py3k(self._db.join(cursor_list))
-
- class DBEnv_py3k(object) :
- def __init__(self, *args, **kwargs) :
- self._dbenv = bsddb._db.DBEnv_orig(*args, **kwargs)
-
- def __getattr__(self, v) :
- return getattr(self._dbenv, v)
-
- def log_cursor(self, flags=0) :
- return logcursor_py3k(self._dbenv)
-
- def get_lg_dir(self) :
- return self._dbenv.get_lg_dir().decode(charset)
-
- def get_tmp_dir(self) :
- return self._dbenv.get_tmp_dir().decode(charset)
-
- def get_data_dirs(self) :
- # Have to use a list comprehension and not
- # generators, because we are supporting Python 2.3.
- return tuple(
- [i.decode(charset) for i in self._dbenv.get_data_dirs()])
-
- class DBSequence_py3k(object) :
- def __init__(self, db, *args, **kwargs) :
- self._db=db
- self._dbsequence = bsddb._db.DBSequence_orig(db._db, *args, **kwargs)
-
- def __getattr__(self, v) :
- return getattr(self._dbsequence, v)
-
- def open(self, key, *args, **kwargs) :
- return self._dbsequence.open(bytes(key, charset), *args, **kwargs)
-
- def get_key(self) :
- return self._dbsequence.get_key().decode(charset)
-
- def get_dbp(self) :
- return self._db
-
- import string
- string.letters=[chr(i) for i in xrange(65,91)]
-
- bsddb._db.DBEnv_orig = bsddb._db.DBEnv
- bsddb._db.DB_orig = bsddb._db.DB
- if bsddb.db.version() <= (4, 3) :
- bsddb._db.DBSequence_orig = None
- else :
- bsddb._db.DBSequence_orig = bsddb._db.DBSequence
-
- def do_proxy_db_py3k(flag) :
- flag2 = do_proxy_db_py3k.flag
- do_proxy_db_py3k.flag = flag
- if flag :
- bsddb.DBEnv = bsddb.db.DBEnv = bsddb._db.DBEnv = DBEnv_py3k
- bsddb.DB = bsddb.db.DB = bsddb._db.DB = DB_py3k
- bsddb._db.DBSequence = DBSequence_py3k
- else :
- bsddb.DBEnv = bsddb.db.DBEnv = bsddb._db.DBEnv = bsddb._db.DBEnv_orig
- bsddb.DB = bsddb.db.DB = bsddb._db.DB = bsddb._db.DB_orig
- bsddb._db.DBSequence = bsddb._db.DBSequence_orig
- return flag2
-
- do_proxy_db_py3k.flag = False
- do_proxy_db_py3k(True)
-
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db, dbtables, dbutils, dbshelve, \
- hashopen, btopen, rnopen, dbobj
-except ImportError:
- # For Python 2.3
- from bsddb import db, dbtables, dbutils, dbshelve, \
- hashopen, btopen, rnopen, dbobj
-
-try:
- from bsddb3 import test_support
-except ImportError:
- if sys.version_info[0] < 3 :
- from test import test_support
- else :
- from test import support as test_support
-
-
-try:
- if sys.version_info[0] < 3 :
- from threading import Thread, currentThread
- del Thread, currentThread
- else :
- from threading import Thread, current_thread
- del Thread, current_thread
- have_threads = True
-except ImportError:
- have_threads = False
-
-verbose = 0
-if 'verbose' in sys.argv:
- verbose = 1
- sys.argv.remove('verbose')
-
-if 'silent' in sys.argv: # take care of old flag, just in case
- verbose = 0
- sys.argv.remove('silent')
-
-
-def print_versions():
- print
- print '-=' * 38
- print db.DB_VERSION_STRING
- print 'bsddb.db.version(): %s' % (db.version(), )
- print 'bsddb.db.__version__: %s' % db.__version__
- print 'bsddb.db.cvsid: %s' % db.cvsid
-
- # Workaround for allowing generating an EGGs as a ZIP files.
- suffix="__"
- print 'py module: %s' % getattr(bsddb, "__file"+suffix)
- print 'extension module: %s' % getattr(bsddb, "__file"+suffix)
-
- print 'python version: %s' % sys.version
- print 'My pid: %s' % os.getpid()
- print '-=' * 38
-
-
-def get_new_path(name) :
- get_new_path.mutex.acquire()
- try :
- import os
- path=os.path.join(get_new_path.prefix,
- name+"_"+str(os.getpid())+"_"+str(get_new_path.num))
- get_new_path.num+=1
- finally :
- get_new_path.mutex.release()
- return path
-
-def get_new_environment_path() :
- path=get_new_path("environment")
- import os
- try:
- os.makedirs(path,mode=0700)
- except os.error:
- test_support.rmtree(path)
- os.makedirs(path)
- return path
-
-def get_new_database_path() :
- path=get_new_path("database")
- import os
- if os.path.exists(path) :
- os.remove(path)
- return path
-
-
-# This path can be overriden via "set_test_path_prefix()".
-import os, os.path
-get_new_path.prefix=os.path.join(os.sep,"tmp","z-Berkeley_DB")
-get_new_path.num=0
-
-def get_test_path_prefix() :
- return get_new_path.prefix
-
-def set_test_path_prefix(path) :
- get_new_path.prefix=path
-
-def remove_test_path_directory() :
- test_support.rmtree(get_new_path.prefix)
-
-if have_threads :
- import threading
- get_new_path.mutex=threading.Lock()
- del threading
-else :
- class Lock(object) :
- def acquire(self) :
- pass
- def release(self) :
- pass
- get_new_path.mutex=Lock()
- del Lock
-
-
-
-class PrintInfoFakeTest(unittest.TestCase):
- def testPrintVersions(self):
- print_versions()
-
-
-# This little hack is for when this module is run as main and all the
-# other modules import it so they will still be able to get the right
-# verbose setting. It's confusing but it works.
-if sys.version_info[0] < 3 :
- import test_all
- test_all.verbose = verbose
-else :
- import sys
- print >>sys.stderr, "Work to do!"
-
-
-def suite(module_prefix='', timing_check=None):
- test_modules = [
- 'test_associate',
- 'test_basics',
- 'test_dbenv',
- 'test_db',
- 'test_compare',
- 'test_compat',
- 'test_cursor_pget_bug',
- 'test_dbobj',
- 'test_dbshelve',
- 'test_dbtables',
- 'test_distributed_transactions',
- 'test_early_close',
- 'test_fileid',
- 'test_get_none',
- 'test_join',
- 'test_lock',
- 'test_misc',
- 'test_pickle',
- 'test_queue',
- 'test_recno',
- 'test_replication',
- 'test_sequence',
- 'test_thread',
- ]
-
- alltests = unittest.TestSuite()
- for name in test_modules:
- #module = __import__(name)
- # Do it this way so that suite may be called externally via
- # python's Lib/test/test_bsddb3.
- module = __import__(module_prefix+name, globals(), locals(), name)
-
- alltests.addTest(module.test_suite())
- if timing_check:
- alltests.addTest(unittest.makeSuite(timing_check))
- return alltests
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(PrintInfoFakeTest))
- return suite
-
-
-if __name__ == '__main__':
- print_versions()
- unittest.main(defaultTest='suite')
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
deleted file mode 100644
index 7a49e11ef7f..00000000000
--- a/Lib/bsddb/test/test_associate.py
+++ /dev/null
@@ -1,465 +0,0 @@
-"""
-TestCases for DB.associate.
-"""
-
-import sys, os, string
-import time
-from pprint import pprint
-
-import unittest
-from test_all import db, dbshelve, test_support, verbose, have_threads, \
- get_new_environment_path
-
-
-#----------------------------------------------------------------------
-
-
-musicdata = {
-1 : ("Bad English", "The Price Of Love", "Rock"),
-2 : ("DNA featuring Suzanne Vega", "Tom's Diner", "Rock"),
-3 : ("George Michael", "Praying For Time", "Rock"),
-4 : ("Gloria Estefan", "Here We Are", "Rock"),
-5 : ("Linda Ronstadt", "Don't Know Much", "Rock"),
-6 : ("Michael Bolton", "How Am I Supposed To Live Without You", "Blues"),
-7 : ("Paul Young", "Oh Girl", "Rock"),
-8 : ("Paula Abdul", "Opposites Attract", "Rock"),
-9 : ("Richard Marx", "Should've Known Better", "Rock"),
-10: ("Rod Stewart", "Forever Young", "Rock"),
-11: ("Roxette", "Dangerous", "Rock"),
-12: ("Sheena Easton", "The Lover In Me", "Rock"),
-13: ("Sinead O'Connor", "Nothing Compares 2 U", "Rock"),
-14: ("Stevie B.", "Because I Love You", "Rock"),
-15: ("Taylor Dayne", "Love Will Lead You Back", "Rock"),
-16: ("The Bangles", "Eternal Flame", "Rock"),
-17: ("Wilson Phillips", "Release Me", "Rock"),
-18: ("Billy Joel", "Blonde Over Blue", "Rock"),
-19: ("Billy Joel", "Famous Last Words", "Rock"),
-20: ("Billy Joel", "Lullabye (Goodnight, My Angel)", "Rock"),
-21: ("Billy Joel", "The River Of Dreams", "Rock"),
-22: ("Billy Joel", "Two Thousand Years", "Rock"),
-23: ("Janet Jackson", "Alright", "Rock"),
-24: ("Janet Jackson", "Black Cat", "Rock"),
-25: ("Janet Jackson", "Come Back To Me", "Rock"),
-26: ("Janet Jackson", "Escapade", "Rock"),
-27: ("Janet Jackson", "Love Will Never Do (Without You)", "Rock"),
-28: ("Janet Jackson", "Miss You Much", "Rock"),
-29: ("Janet Jackson", "Rhythm Nation", "Rock"),
-30: ("Janet Jackson", "State Of The World", "Rock"),
-31: ("Janet Jackson", "The Knowledge", "Rock"),
-32: ("Spyro Gyra", "End of Romanticism", "Jazz"),
-33: ("Spyro Gyra", "Heliopolis", "Jazz"),
-34: ("Spyro Gyra", "Jubilee", "Jazz"),
-35: ("Spyro Gyra", "Little Linda", "Jazz"),
-36: ("Spyro Gyra", "Morning Dance", "Jazz"),
-37: ("Spyro Gyra", "Song for Lorraine", "Jazz"),
-38: ("Yes", "Owner Of A Lonely Heart", "Rock"),
-39: ("Yes", "Rhythm Of Love", "Rock"),
-40: ("Cusco", "Dream Catcher", "New Age"),
-41: ("Cusco", "Geronimos Laughter", "New Age"),
-42: ("Cusco", "Ghost Dance", "New Age"),
-43: ("Blue Man Group", "Drumbone", "New Age"),
-44: ("Blue Man Group", "Endless Column", "New Age"),
-45: ("Blue Man Group", "Klein Mandelbrot", "New Age"),
-46: ("Kenny G", "Silhouette", "Jazz"),
-47: ("Sade", "Smooth Operator", "Jazz"),
-48: ("David Arkenstone", "Papillon (On The Wings Of The Butterfly)",
- "New Age"),
-49: ("David Arkenstone", "Stepping Stars", "New Age"),
-50: ("David Arkenstone", "Carnation Lily Lily Rose", "New Age"),
-51: ("David Lanz", "Behind The Waterfall", "New Age"),
-52: ("David Lanz", "Cristofori's Dream", "New Age"),
-53: ("David Lanz", "Heartsounds", "New Age"),
-54: ("David Lanz", "Leaves on the Seine", "New Age"),
-99: ("unknown artist", "Unnamed song", "Unknown"),
-}
-
-#----------------------------------------------------------------------
-
-class AssociateErrorTestCase(unittest.TestCase):
- def setUp(self):
- self.filename = self.__class__.__name__ + '.db'
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
-
- def tearDown(self):
- self.env.close()
- self.env = None
- test_support.rmtree(self.homeDir)
-
- def test00_associateDBError(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test00_associateDBError..." % \
- self.__class__.__name__
-
- dupDB = db.DB(self.env)
- dupDB.set_flags(db.DB_DUP)
- dupDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE)
-
- secDB = db.DB(self.env)
- secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
-
- # dupDB has been configured to allow duplicates, it can't
- # associate with a secondary. Berkeley DB will return an error.
- try:
- def f(a,b): return a+b
- dupDB.associate(secDB, f)
- except db.DBError:
- # good
- secDB.close()
- dupDB.close()
- else:
- secDB.close()
- dupDB.close()
- self.fail("DBError exception was expected")
-
-
-
-#----------------------------------------------------------------------
-
-
-class AssociateTestCase(unittest.TestCase):
- keytype = ''
- envFlags = 0
- dbFlags = 0
-
- def setUp(self):
- self.filename = self.__class__.__name__ + '.db'
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
- db.DB_INIT_LOCK | db.DB_THREAD | self.envFlags)
-
- def tearDown(self):
- self.closeDB()
- self.env.close()
- self.env = None
- test_support.rmtree(self.homeDir)
-
- def addDataToDB(self, d, txn=None):
- for key, value in musicdata.items():
- if type(self.keytype) == type(''):
- key = "%02d" % key
- d.put(key, '|'.join(value), txn=txn)
-
- def createDB(self, txn=None):
- self.cur = None
- self.secDB = None
- self.primary = db.DB(self.env)
- self.primary.set_get_returns_none(2)
- self.primary.open(self.filename, "primary", self.dbtype,
- db.DB_CREATE | db.DB_THREAD | self.dbFlags, txn=txn)
-
- def closeDB(self):
- if self.cur:
- self.cur.close()
- self.cur = None
- if self.secDB:
- self.secDB.close()
- self.secDB = None
- self.primary.close()
- self.primary = None
-
- def getDB(self):
- return self.primary
-
-
- def _associateWithDB(self, getGenre):
- self.createDB()
-
- self.secDB = db.DB(self.env)
- self.secDB.set_flags(db.DB_DUP)
- self.secDB.set_get_returns_none(2)
- self.secDB.open(self.filename, "secondary", db.DB_BTREE,
- db.DB_CREATE | db.DB_THREAD | self.dbFlags)
- self.getDB().associate(self.secDB, getGenre)
-
- self.addDataToDB(self.getDB())
-
- self.finish_test(self.secDB)
-
- def test01_associateWithDB(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_associateWithDB..." % \
- self.__class__.__name__
-
- return self._associateWithDB(self.getGenre)
-
- def _associateAfterDB(self, getGenre) :
- self.createDB()
- self.addDataToDB(self.getDB())
-
- self.secDB = db.DB(self.env)
- self.secDB.set_flags(db.DB_DUP)
- self.secDB.open(self.filename, "secondary", db.DB_BTREE,
- db.DB_CREATE | db.DB_THREAD | self.dbFlags)
-
- # adding the DB_CREATE flag will cause it to index existing records
- self.getDB().associate(self.secDB, getGenre, db.DB_CREATE)
-
- self.finish_test(self.secDB)
-
- def test02_associateAfterDB(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_associateAfterDB..." % \
- self.__class__.__name__
-
- return self._associateAfterDB(self.getGenre)
-
- if db.version() >= (4, 6):
- def test03_associateWithDB(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03_associateWithDB..." % \
- self.__class__.__name__
-
- return self._associateWithDB(self.getGenreList)
-
- def test04_associateAfterDB(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test04_associateAfterDB..." % \
- self.__class__.__name__
-
- return self._associateAfterDB(self.getGenreList)
-
-
- def finish_test(self, secDB, txn=None):
- # 'Blues' should not be in the secondary database
- vals = secDB.pget('Blues', txn=txn)
- self.assertEqual(vals, None, vals)
-
- vals = secDB.pget('Unknown', txn=txn)
- self.assertTrue(vals[0] == 99 or vals[0] == '99', vals)
- vals[1].index('Unknown')
- vals[1].index('Unnamed')
- vals[1].index('unknown')
-
- if verbose:
- print "Primary key traversal:"
- self.cur = self.getDB().cursor(txn)
- count = 0
- rec = self.cur.first()
- while rec is not None:
- if type(self.keytype) == type(''):
- self.assertTrue(int(rec[0])) # for primary db, key is a number
- else:
- self.assertTrue(rec[0] and type(rec[0]) == type(0))
- count = count + 1
- if verbose:
- print rec
- rec = getattr(self.cur, "next")()
- self.assertEqual(count, len(musicdata)) # all items accounted for
-
-
- if verbose:
- print "Secondary key traversal:"
- self.cur = secDB.cursor(txn)
- count = 0
-
- # test cursor pget
- vals = self.cur.pget('Unknown', flags=db.DB_LAST)
- self.assertTrue(vals[1] == 99 or vals[1] == '99', vals)
- self.assertEqual(vals[0], 'Unknown')
- vals[2].index('Unknown')
- vals[2].index('Unnamed')
- vals[2].index('unknown')
-
- vals = self.cur.pget('Unknown', data='wrong value', flags=db.DB_GET_BOTH)
- self.assertEqual(vals, None, vals)
-
- rec = self.cur.first()
- self.assertEqual(rec[0], "Jazz")
- while rec is not None:
- count = count + 1
- if verbose:
- print rec
- rec = getattr(self.cur, "next")()
- # all items accounted for EXCEPT for 1 with "Blues" genre
- self.assertEqual(count, len(musicdata)-1)
-
- self.cur = None
-
- def getGenre(self, priKey, priData):
- self.assertEqual(type(priData), type(""))
- genre = priData.split('|')[2]
-
- if verbose:
- print 'getGenre key: %r data: %r' % (priKey, priData)
-
- if genre == 'Blues':
- return db.DB_DONOTINDEX
- else:
- return genre
-
- def getGenreList(self, priKey, PriData) :
- v = self.getGenre(priKey, PriData)
- if type(v) == type("") :
- v = [v]
- return v
-
-
-#----------------------------------------------------------------------
-
-
-class AssociateHashTestCase(AssociateTestCase):
- dbtype = db.DB_HASH
-
-class AssociateBTreeTestCase(AssociateTestCase):
- dbtype = db.DB_BTREE
-
-class AssociateRecnoTestCase(AssociateTestCase):
- dbtype = db.DB_RECNO
- keytype = 0
-
-#----------------------------------------------------------------------
-
-class AssociateBTreeTxnTestCase(AssociateBTreeTestCase):
- envFlags = db.DB_INIT_TXN
- dbFlags = 0
-
- def txn_finish_test(self, sDB, txn):
- try:
- self.finish_test(sDB, txn=txn)
- finally:
- if self.cur:
- self.cur.close()
- self.cur = None
- if txn:
- txn.commit()
-
- def test13_associate_in_transaction(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test13_associateAutoCommit..." % \
- self.__class__.__name__
-
- txn = self.env.txn_begin()
- try:
- self.createDB(txn=txn)
-
- self.secDB = db.DB(self.env)
- self.secDB.set_flags(db.DB_DUP)
- self.secDB.set_get_returns_none(2)
- self.secDB.open(self.filename, "secondary", db.DB_BTREE,
- db.DB_CREATE | db.DB_THREAD, txn=txn)
- self.getDB().associate(self.secDB, self.getGenre, txn=txn)
-
- self.addDataToDB(self.getDB(), txn=txn)
- except:
- txn.abort()
- raise
-
- self.txn_finish_test(self.secDB, txn=txn)
-
-
-#----------------------------------------------------------------------
-
-class ShelveAssociateTestCase(AssociateTestCase):
-
- def createDB(self):
- self.primary = dbshelve.open(self.filename,
- dbname="primary",
- dbenv=self.env,
- filetype=self.dbtype)
-
- def addDataToDB(self, d):
- for key, value in musicdata.items():
- if type(self.keytype) == type(''):
- key = "%02d" % key
- d.put(key, value) # save the value as is this time
-
-
- def getGenre(self, priKey, priData):
- self.assertEqual(type(priData), type(()))
- if verbose:
- print 'getGenre key: %r data: %r' % (priKey, priData)
- genre = priData[2]
- if genre == 'Blues':
- return db.DB_DONOTINDEX
- else:
- return genre
-
-
-class ShelveAssociateHashTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_HASH
-
-class ShelveAssociateBTreeTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_BTREE
-
-class ShelveAssociateRecnoTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_RECNO
- keytype = 0
-
-
-#----------------------------------------------------------------------
-
-class ThreadedAssociateTestCase(AssociateTestCase):
-
- def addDataToDB(self, d):
- t1 = Thread(target = self.writer1,
- args = (d, ))
- t2 = Thread(target = self.writer2,
- args = (d, ))
-
- t1.setDaemon(True)
- t2.setDaemon(True)
- t1.start()
- t2.start()
- t1.join()
- t2.join()
-
- def writer1(self, d):
- for key, value in musicdata.items():
- if type(self.keytype) == type(''):
- key = "%02d" % key
- d.put(key, '|'.join(value))
-
- def writer2(self, d):
- for x in range(100, 600):
- key = 'z%2d' % x
- value = [key] * 4
- d.put(key, '|'.join(value))
-
-
-class ThreadedAssociateHashTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_HASH
-
-class ThreadedAssociateBTreeTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_BTREE
-
-class ThreadedAssociateRecnoTestCase(ShelveAssociateTestCase):
- dbtype = db.DB_RECNO
- keytype = 0
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(AssociateErrorTestCase))
-
- suite.addTest(unittest.makeSuite(AssociateHashTestCase))
- suite.addTest(unittest.makeSuite(AssociateBTreeTestCase))
- suite.addTest(unittest.makeSuite(AssociateRecnoTestCase))
-
- suite.addTest(unittest.makeSuite(AssociateBTreeTxnTestCase))
-
- suite.addTest(unittest.makeSuite(ShelveAssociateHashTestCase))
- suite.addTest(unittest.makeSuite(ShelveAssociateBTreeTestCase))
- suite.addTest(unittest.makeSuite(ShelveAssociateRecnoTestCase))
-
- if have_threads:
- suite.addTest(unittest.makeSuite(ThreadedAssociateHashTestCase))
- suite.addTest(unittest.makeSuite(ThreadedAssociateBTreeTestCase))
- suite.addTest(unittest.makeSuite(ThreadedAssociateRecnoTestCase))
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
deleted file mode 100644
index 4d43390ecbd..00000000000
--- a/Lib/bsddb/test/test_basics.py
+++ /dev/null
@@ -1,1192 +0,0 @@
-"""
-Basic TestCases for BTree and hash DBs, with and without a DBEnv, with
-various DB flags, etc.
-"""
-
-import os
-import errno
-import string
-from pprint import pprint
-import unittest
-import time
-
-from test_all import db, test_support, verbose, get_new_environment_path, \
- get_new_database_path
-
-DASH = '-'
-
-
-#----------------------------------------------------------------------
-
-class VersionTestCase(unittest.TestCase):
- def test00_version(self):
- info = db.version()
- if verbose:
- print '\n', '-=' * 20
- print 'bsddb.db.version(): %s' % (info, )
- print db.DB_VERSION_STRING
- print '-=' * 20
- self.assertEqual(info, (db.DB_VERSION_MAJOR, db.DB_VERSION_MINOR,
- db.DB_VERSION_PATCH))
-
-#----------------------------------------------------------------------
-
-class BasicTestCase(unittest.TestCase):
- dbtype = db.DB_UNKNOWN # must be set in derived class
- cachesize = (0, 1024*1024, 1)
- dbopenflags = 0
- dbsetflags = 0
- dbmode = 0660
- dbname = None
- useEnv = 0
- envflags = 0
- envsetflags = 0
-
- _numKeys = 1002 # PRIVATE. NOTE: must be an even value
-
- import sys
- if sys.version_info < (2, 4):
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
- def assertFalse(self, expr, msg=None):
- self.failIf(expr,msg=msg)
-
- def setUp(self):
- if self.useEnv:
- self.homeDir=get_new_environment_path()
- try:
- self.env = db.DBEnv()
- self.env.set_lg_max(1024*1024)
- self.env.set_tx_max(30)
- self._t = int(time.time())
- self.env.set_tx_timestamp(self._t)
- self.env.set_flags(self.envsetflags, 1)
- self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
- self.filename = "test"
- # Yes, a bare except is intended, since we're re-raising the exc.
- except:
- test_support.rmtree(self.homeDir)
- raise
- else:
- self.env = None
- self.filename = get_new_database_path()
-
- # create and open the DB
- self.d = db.DB(self.env)
- if not self.useEnv :
- if db.version() >= (4, 2) :
- self.d.set_cachesize(*self.cachesize)
- cachesize = self.d.get_cachesize()
- self.assertEqual(cachesize[0], self.cachesize[0])
- self.assertEqual(cachesize[2], self.cachesize[2])
- # Berkeley DB expands the cache 25% accounting overhead,
- # if the cache is small.
- self.assertEqual(125, int(100.0*cachesize[1]/self.cachesize[1]))
- self.d.set_flags(self.dbsetflags)
- if self.dbname:
- self.d.open(self.filename, self.dbname, self.dbtype,
- self.dbopenflags|db.DB_CREATE, self.dbmode)
- else:
- self.d.open(self.filename, # try out keyword args
- mode = self.dbmode,
- dbtype = self.dbtype,
- flags = self.dbopenflags|db.DB_CREATE)
-
- if not self.useEnv:
- self.assertRaises(db.DBInvalidArgError,
- self.d.set_cachesize, *self.cachesize)
-
- self.populateDB()
-
-
- def tearDown(self):
- self.d.close()
- if self.env is not None:
- self.env.close()
- test_support.rmtree(self.homeDir)
- else:
- os.remove(self.filename)
-
-
-
- def populateDB(self, _txn=None):
- d = self.d
-
- for x in range(self._numKeys//2):
- key = '%04d' % (self._numKeys - x) # insert keys in reverse order
- data = self.makeData(key)
- d.put(key, data, _txn)
-
- d.put('empty value', '', _txn)
-
- for x in range(self._numKeys//2-1):
- key = '%04d' % x # and now some in forward order
- data = self.makeData(key)
- d.put(key, data, _txn)
-
- if _txn:
- _txn.commit()
-
- num = len(d)
- if verbose:
- print "created %d records" % num
-
-
- def makeData(self, key):
- return DASH.join([key] * 5)
-
-
-
- #----------------------------------------
-
- def test01_GetsAndPuts(self):
- d = self.d
-
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_GetsAndPuts..." % self.__class__.__name__
-
- for key in ['0001', '0100', '0400', '0700', '0999']:
- data = d.get(key)
- if verbose:
- print data
-
- self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
-
- # By default non-existent keys return None...
- self.assertEqual(d.get('abcd'), None)
-
- # ...but they raise exceptions in other situations. Call
- # set_get_returns_none() to change it.
- try:
- d.delete('abcd')
- except db.DBNotFoundError, val:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_NOTFOUND)
- else :
- self.assertEqual(val.args[0], db.DB_NOTFOUND)
- if verbose: print val
- else:
- self.fail("expected exception")
-
-
- d.put('abcd', 'a new record')
- self.assertEqual(d.get('abcd'), 'a new record')
-
- d.put('abcd', 'same key')
- if self.dbsetflags & db.DB_DUP:
- self.assertEqual(d.get('abcd'), 'a new record')
- else:
- self.assertEqual(d.get('abcd'), 'same key')
-
-
- try:
- d.put('abcd', 'this should fail', flags=db.DB_NOOVERWRITE)
- except db.DBKeyExistError, val:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_KEYEXIST)
- else :
- self.assertEqual(val.args[0], db.DB_KEYEXIST)
- if verbose: print val
- else:
- self.fail("expected exception")
-
- if self.dbsetflags & db.DB_DUP:
- self.assertEqual(d.get('abcd'), 'a new record')
- else:
- self.assertEqual(d.get('abcd'), 'same key')
-
-
- d.sync()
- d.close()
- del d
-
- self.d = db.DB(self.env)
- if self.dbname:
- self.d.open(self.filename, self.dbname)
- else:
- self.d.open(self.filename)
- d = self.d
-
- self.assertEqual(d.get('0321'), '0321-0321-0321-0321-0321')
- if self.dbsetflags & db.DB_DUP:
- self.assertEqual(d.get('abcd'), 'a new record')
- else:
- self.assertEqual(d.get('abcd'), 'same key')
-
- rec = d.get_both('0555', '0555-0555-0555-0555-0555')
- if verbose:
- print rec
-
- self.assertEqual(d.get_both('0555', 'bad data'), None)
-
- # test default value
- data = d.get('bad key', 'bad data')
- self.assertEqual(data, 'bad data')
-
- # any object can pass through
- data = d.get('bad key', self)
- self.assertEqual(data, self)
-
- s = d.stat()
- self.assertEqual(type(s), type({}))
- if verbose:
- print 'd.stat() returned this dictionary:'
- pprint(s)
-
-
- #----------------------------------------
-
- def test02_DictionaryMethods(self):
- d = self.d
-
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_DictionaryMethods..." % \
- self.__class__.__name__
-
- for key in ['0002', '0101', '0401', '0701', '0998']:
- data = d[key]
- self.assertEqual(data, self.makeData(key))
- if verbose:
- print data
-
- self.assertEqual(len(d), self._numKeys)
- keys = d.keys()
- self.assertEqual(len(keys), self._numKeys)
- self.assertEqual(type(keys), type([]))
-
- d['new record'] = 'a new record'
- self.assertEqual(len(d), self._numKeys+1)
- keys = d.keys()
- self.assertEqual(len(keys), self._numKeys+1)
-
- d['new record'] = 'a replacement record'
- self.assertEqual(len(d), self._numKeys+1)
- keys = d.keys()
- self.assertEqual(len(keys), self._numKeys+1)
-
- if verbose:
- print "the first 10 keys are:"
- pprint(keys[:10])
-
- self.assertEqual(d['new record'], 'a replacement record')
-
-# We check also the positional parameter
- self.assertEqual(d.has_key('0001', None), 1)
-# We check also the keyword parameter
- self.assertEqual(d.has_key('spam', txn=None), 0)
-
- items = d.items()
- self.assertEqual(len(items), self._numKeys+1)
- self.assertEqual(type(items), type([]))
- self.assertEqual(type(items[0]), type(()))
- self.assertEqual(len(items[0]), 2)
-
- if verbose:
- print "the first 10 items are:"
- pprint(items[:10])
-
- values = d.values()
- self.assertEqual(len(values), self._numKeys+1)
- self.assertEqual(type(values), type([]))
-
- if verbose:
- print "the first 10 values are:"
- pprint(values[:10])
-
-
- #----------------------------------------
-
- def test02b_SequenceMethods(self):
- d = self.d
-
- for key in ['0002', '0101', '0401', '0701', '0998']:
- data = d[key]
- self.assertEqual(data, self.makeData(key))
- if verbose:
- print data
-
- self.assertTrue(hasattr(d, "__contains__"))
- self.assertTrue("0401" in d)
- self.assertFalse("1234" in d)
-
-
- #----------------------------------------
-
- def test03_SimpleCursorStuff(self, get_raises_error=0, set_raises_error=0):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03_SimpleCursorStuff (get_error %s, set_error %s)..." % \
- (self.__class__.__name__, get_raises_error, set_raises_error)
-
- if self.env and self.dbopenflags & db.DB_AUTO_COMMIT:
- txn = self.env.txn_begin()
- else:
- txn = None
- c = self.d.cursor(txn=txn)
-
- rec = c.first()
- count = 0
- while rec is not None:
- count = count + 1
- if verbose and count % 100 == 0:
- print rec
- try:
- rec = c.next()
- except db.DBNotFoundError, val:
- if get_raises_error:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_NOTFOUND)
- else :
- self.assertEqual(val.args[0], db.DB_NOTFOUND)
- if verbose: print val
- rec = None
- else:
- self.fail("unexpected DBNotFoundError")
- self.assertEqual(c.get_current_size(), len(c.current()[1]),
- "%s != len(%r)" % (c.get_current_size(), c.current()[1]))
-
- self.assertEqual(count, self._numKeys)
-
-
- rec = c.last()
- count = 0
- while rec is not None:
- count = count + 1
- if verbose and count % 100 == 0:
- print rec
- try:
- rec = c.prev()
- except db.DBNotFoundError, val:
- if get_raises_error:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_NOTFOUND)
- else :
- self.assertEqual(val.args[0], db.DB_NOTFOUND)
- if verbose: print val
- rec = None
- else:
- self.fail("unexpected DBNotFoundError")
-
- self.assertEqual(count, self._numKeys)
-
- rec = c.set('0505')
- rec2 = c.current()
- self.assertEqual(rec, rec2)
- self.assertEqual(rec[0], '0505')
- self.assertEqual(rec[1], self.makeData('0505'))
- self.assertEqual(c.get_current_size(), len(rec[1]))
-
- # make sure we get empty values properly
- rec = c.set('empty value')
- self.assertEqual(rec[1], '')
- self.assertEqual(c.get_current_size(), 0)
-
- try:
- n = c.set('bad key')
- except db.DBNotFoundError, val:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_NOTFOUND)
- else :
- self.assertEqual(val.args[0], db.DB_NOTFOUND)
- if verbose: print val
- else:
- if set_raises_error:
- self.fail("expected exception")
- if n is not None:
- self.fail("expected None: %r" % (n,))
-
- rec = c.get_both('0404', self.makeData('0404'))
- self.assertEqual(rec, ('0404', self.makeData('0404')))
-
- try:
- n = c.get_both('0404', 'bad data')
- except db.DBNotFoundError, val:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_NOTFOUND)
- else :
- self.assertEqual(val.args[0], db.DB_NOTFOUND)
- if verbose: print val
- else:
- if get_raises_error:
- self.fail("expected exception")
- if n is not None:
- self.fail("expected None: %r" % (n,))
-
- if self.d.get_type() == db.DB_BTREE:
- rec = c.set_range('011')
- if verbose:
- print "searched for '011', found: ", rec
-
- rec = c.set_range('011',dlen=0,doff=0)
- if verbose:
- print "searched (partial) for '011', found: ", rec
- if rec[1] != '': self.fail('expected empty data portion')
-
- ev = c.set_range('empty value')
- if verbose:
- print "search for 'empty value' returned", ev
- if ev[1] != '': self.fail('empty value lookup failed')
-
- c.set('0499')
- c.delete()
- try:
- rec = c.current()
- except db.DBKeyEmptyError, val:
- if get_raises_error:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_KEYEMPTY)
- else :
- self.assertEqual(val.args[0], db.DB_KEYEMPTY)
- if verbose: print val
- else:
- self.fail("unexpected DBKeyEmptyError")
- else:
- if get_raises_error:
- self.fail('DBKeyEmptyError exception expected')
-
- c.next()
- c2 = c.dup(db.DB_POSITION)
- self.assertEqual(c.current(), c2.current())
-
- c2.put('', 'a new value', db.DB_CURRENT)
- self.assertEqual(c.current(), c2.current())
- self.assertEqual(c.current()[1], 'a new value')
-
- c2.put('', 'er', db.DB_CURRENT, dlen=0, doff=5)
- self.assertEqual(c2.current()[1], 'a newer value')
-
- c.close()
- c2.close()
- if txn:
- txn.commit()
-
- # time to abuse the closed cursors and hope we don't crash
- methods_to_test = {
- 'current': (),
- 'delete': (),
- 'dup': (db.DB_POSITION,),
- 'first': (),
- 'get': (0,),
- 'next': (),
- 'prev': (),
- 'last': (),
- 'put':('', 'spam', db.DB_CURRENT),
- 'set': ("0505",),
- }
- for method, args in methods_to_test.items():
- try:
- if verbose:
- print "attempting to use a closed cursor's %s method" % \
- method
- # a bug may cause a NULL pointer dereference...
- getattr(c, method)(*args)
- except db.DBError, val:
- import sys
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], 0)
- else :
- self.assertEqual(val.args[0], 0)
- if verbose: print val
- else:
- self.fail("no exception raised when using a buggy cursor's"
- "%s method" % method)
-
- #
- # free cursor referencing a closed database, it should not barf:
- #
- oldcursor = self.d.cursor(txn=txn)
- self.d.close()
-
- # this would originally cause a segfault when the cursor for a
- # closed database was cleaned up. it should not anymore.
- # SF pybsddb bug id 667343
- del oldcursor
-
- def test03b_SimpleCursorWithoutGetReturnsNone0(self):
- # same test but raise exceptions instead of returning None
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03b_SimpleCursorStuffWithoutGetReturnsNone..." % \
- self.__class__.__name__
-
- old = self.d.set_get_returns_none(0)
- self.assertEqual(old, 2)
- self.test03_SimpleCursorStuff(get_raises_error=1, set_raises_error=1)
-
- def test03b_SimpleCursorWithGetReturnsNone1(self):
- # same test but raise exceptions instead of returning None
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03b_SimpleCursorStuffWithoutGetReturnsNone..." % \
- self.__class__.__name__
-
- old = self.d.set_get_returns_none(1)
- self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=1)
-
-
- def test03c_SimpleCursorGetReturnsNone2(self):
- # same test but raise exceptions instead of returning None
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03c_SimpleCursorStuffWithoutSetReturnsNone..." % \
- self.__class__.__name__
-
- old = self.d.set_get_returns_none(1)
- self.assertEqual(old, 2)
- old = self.d.set_get_returns_none(2)
- self.assertEqual(old, 1)
- self.test03_SimpleCursorStuff(get_raises_error=0, set_raises_error=0)
-
- if db.version() >= (4, 6):
- def test03d_SimpleCursorPriority(self) :
- c = self.d.cursor()
- c.set_priority(db.DB_PRIORITY_VERY_LOW) # Positional
- self.assertEqual(db.DB_PRIORITY_VERY_LOW, c.get_priority())
- c.set_priority(priority=db.DB_PRIORITY_HIGH) # Keyword
- self.assertEqual(db.DB_PRIORITY_HIGH, c.get_priority())
- c.close()
-
- #----------------------------------------
-
- def test04_PartialGetAndPut(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test04_PartialGetAndPut..." % \
- self.__class__.__name__
-
- key = "partialTest"
- data = "1" * 1000 + "2" * 1000
- d.put(key, data)
- self.assertEqual(d.get(key), data)
- self.assertEqual(d.get(key, dlen=20, doff=990),
- ("1" * 10) + ("2" * 10))
-
- d.put("partialtest2", ("1" * 30000) + "robin" )
- self.assertEqual(d.get("partialtest2", dlen=5, doff=30000), "robin")
-
- # There seems to be a bug in DB here... Commented out the test for
- # now.
- ##self.assertEqual(d.get("partialtest2", dlen=5, doff=30010), "")
-
- if self.dbsetflags != db.DB_DUP:
- # Partial put with duplicate records requires a cursor
- d.put(key, "0000", dlen=2000, doff=0)
- self.assertEqual(d.get(key), "0000")
-
- d.put(key, "1111", dlen=1, doff=2)
- self.assertEqual(d.get(key), "0011110")
-
- #----------------------------------------
-
- def test05_GetSize(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test05_GetSize..." % self.__class__.__name__
-
- for i in range(1, 50000, 500):
- key = "size%s" % i
- #print "before ", i,
- d.put(key, "1" * i)
- #print "after",
- self.assertEqual(d.get_size(key), i)
- #print "done"
-
- #----------------------------------------
-
- def test06_Truncate(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test06_Truncate..." % self.__class__.__name__
-
- d.put("abcde", "ABCDE");
- num = d.truncate()
- self.assertTrue(num >= 1, "truncate returned <= 0 on non-empty database")
- num = d.truncate()
- self.assertEqual(num, 0,
- "truncate on empty DB returned nonzero (%r)" % (num,))
-
- #----------------------------------------
-
- def test07_verify(self):
- # Verify bug solved in 4.7.3pre8
- self.d.close()
- d = db.DB(self.env)
- d.verify(self.filename)
-
-
- #----------------------------------------
-
- if db.version() >= (4, 6):
- def test08_exists(self) :
- self.d.put("abcde", "ABCDE")
- self.assertTrue(self.d.exists("abcde") == True,
- "DB->exists() returns wrong value")
- self.assertTrue(self.d.exists("x") == False,
- "DB->exists() returns wrong value")
-
- #----------------------------------------
-
- if db.version() >= (4, 7):
- def test_compact(self) :
- d = self.d
- self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
- self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
- d.put("abcde", "ABCDE");
- d.put("bcde", "BCDE");
- d.put("abc", "ABC");
- d.put("monty", "python");
- d.delete("abc")
- d.delete("bcde")
- d.compact(start='abcde', stop='monty', txn=None,
- compact_fillpercent=42, compact_pages=1,
- compact_timeout=50000000,
- flags=db.DB_FREELIST_ONLY|db.DB_FREE_SPACE)
-
- #----------------------------------------
-
-#----------------------------------------------------------------------
-
-
-class BasicBTreeTestCase(BasicTestCase):
- dbtype = db.DB_BTREE
-
-
-class BasicHashTestCase(BasicTestCase):
- dbtype = db.DB_HASH
-
-
-class BasicBTreeWithThreadFlagTestCase(BasicTestCase):
- dbtype = db.DB_BTREE
- dbopenflags = db.DB_THREAD
-
-
-class BasicHashWithThreadFlagTestCase(BasicTestCase):
- dbtype = db.DB_HASH
- dbopenflags = db.DB_THREAD
-
-
-class BasicWithEnvTestCase(BasicTestCase):
- dbopenflags = db.DB_THREAD
- useEnv = 1
- envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
-
- #----------------------------------------
-
- def test09_EnvRemoveAndRename(self):
- if not self.env:
- return
-
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test09_EnvRemoveAndRename..." % self.__class__.__name__
-
- # can't rename or remove an open DB
- self.d.close()
-
- newname = self.filename + '.renamed'
- self.env.dbrename(self.filename, None, newname)
- self.env.dbremove(newname)
-
- #----------------------------------------
-
-class BasicBTreeWithEnvTestCase(BasicWithEnvTestCase):
- dbtype = db.DB_BTREE
-
-
-class BasicHashWithEnvTestCase(BasicWithEnvTestCase):
- dbtype = db.DB_HASH
-
-
-#----------------------------------------------------------------------
-
-class BasicTransactionTestCase(BasicTestCase):
- import sys
- if sys.version_info < (2, 4):
- def assertTrue(self, expr, msg=None):
- return self.failUnless(expr,msg=msg)
-
- if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
- (sys.version_info < (3, 2))) :
- def assertIn(self, a, b, msg=None) :
- return self.assertTrue(a in b, msg=msg)
-
- dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT
- useEnv = 1
- envflags = (db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
- db.DB_INIT_TXN)
- envsetflags = db.DB_AUTO_COMMIT
-
-
- def tearDown(self):
- self.txn.commit()
- BasicTestCase.tearDown(self)
-
-
- def populateDB(self):
- txn = self.env.txn_begin()
- BasicTestCase.populateDB(self, _txn=txn)
-
- self.txn = self.env.txn_begin()
-
-
- def test06_Transactions(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test06_Transactions..." % self.__class__.__name__
-
- self.assertEqual(d.get('new rec', txn=self.txn), None)
- d.put('new rec', 'this is a new record', self.txn)
- self.assertEqual(d.get('new rec', txn=self.txn),
- 'this is a new record')
- self.txn.abort()
- self.assertEqual(d.get('new rec'), None)
-
- self.txn = self.env.txn_begin()
-
- self.assertEqual(d.get('new rec', txn=self.txn), None)
- d.put('new rec', 'this is a new record', self.txn)
- self.assertEqual(d.get('new rec', txn=self.txn),
- 'this is a new record')
- self.txn.commit()
- self.assertEqual(d.get('new rec'), 'this is a new record')
-
- self.txn = self.env.txn_begin()
- c = d.cursor(self.txn)
- rec = c.first()
- count = 0
- while rec is not None:
- count = count + 1
- if verbose and count % 100 == 0:
- print rec
- rec = c.next()
- self.assertEqual(count, self._numKeys+1)
-
- c.close() # Cursors *MUST* be closed before commit!
- self.txn.commit()
-
- # flush pending updates
- self.env.txn_checkpoint (0, 0, 0)
-
- statDict = self.env.log_stat(0);
- self.assertIn('magic', statDict)
- self.assertIn('version', statDict)
- self.assertIn('cur_file', statDict)
- self.assertIn('region_nowait', statDict)
-
- # must have at least one log file present:
- logs = self.env.log_archive(db.DB_ARCH_ABS | db.DB_ARCH_LOG)
- self.assertNotEqual(logs, None)
- for log in logs:
- if verbose:
- print 'log file: ' + log
- if db.version() >= (4,2):
- logs = self.env.log_archive(db.DB_ARCH_REMOVE)
- self.assertTrue(not logs)
-
- self.txn = self.env.txn_begin()
-
- #----------------------------------------
-
- if db.version() >= (4, 6):
- def test08_exists(self) :
- txn = self.env.txn_begin()
- self.d.put("abcde", "ABCDE", txn=txn)
- txn.commit()
- txn = self.env.txn_begin()
- self.assertTrue(self.d.exists("abcde", txn=txn) == True,
- "DB->exists() returns wrong value")
- self.assertTrue(self.d.exists("x", txn=txn) == False,
- "DB->exists() returns wrong value")
- txn.abort()
-
- #----------------------------------------
-
- def test09_TxnTruncate(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test09_TxnTruncate..." % self.__class__.__name__
-
- d.put("abcde", "ABCDE");
- txn = self.env.txn_begin()
- num = d.truncate(txn)
- self.assertTrue(num >= 1, "truncate returned <= 0 on non-empty database")
- num = d.truncate(txn)
- self.assertEqual(num, 0,
- "truncate on empty DB returned nonzero (%r)" % (num,))
- txn.commit()
-
- #----------------------------------------
-
- def test10_TxnLateUse(self):
- txn = self.env.txn_begin()
- txn.abort()
- try:
- txn.abort()
- except db.DBError, e:
- pass
- else:
- raise RuntimeError, "DBTxn.abort() called after DB_TXN no longer valid w/o an exception"
-
- txn = self.env.txn_begin()
- txn.commit()
- try:
- txn.commit()
- except db.DBError, e:
- pass
- else:
- raise RuntimeError, "DBTxn.commit() called after DB_TXN no longer valid w/o an exception"
-
-
- #----------------------------------------
-
-
- if db.version() >= (4, 4):
- def test_txn_name(self) :
- txn=self.env.txn_begin()
- self.assertEqual(txn.get_name(), "")
- txn.set_name("XXYY")
- self.assertEqual(txn.get_name(), "XXYY")
- txn.set_name("")
- self.assertEqual(txn.get_name(), "")
- txn.abort()
-
- #----------------------------------------
-
-
- def test_txn_set_timeout(self) :
- txn=self.env.txn_begin()
- txn.set_timeout(1234567, db.DB_SET_LOCK_TIMEOUT)
- txn.set_timeout(2345678, flags=db.DB_SET_TXN_TIMEOUT)
- txn.abort()
-
- #----------------------------------------
-
- if db.version() >= (4, 2) :
- def test_get_tx_max(self) :
- self.assertEqual(self.env.get_tx_max(), 30)
-
- def test_get_tx_timestamp(self) :
- self.assertEqual(self.env.get_tx_timestamp(), self._t)
-
-
-
-class BTreeTransactionTestCase(BasicTransactionTestCase):
- dbtype = db.DB_BTREE
-
-class HashTransactionTestCase(BasicTransactionTestCase):
- dbtype = db.DB_HASH
-
-
-
-#----------------------------------------------------------------------
-
-class BTreeRecnoTestCase(BasicTestCase):
- dbtype = db.DB_BTREE
- dbsetflags = db.DB_RECNUM
-
- def test09_RecnoInBTree(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test09_RecnoInBTree..." % self.__class__.__name__
-
- rec = d.get(200)
- self.assertEqual(type(rec), type(()))
- self.assertEqual(len(rec), 2)
- if verbose:
- print "Record #200 is ", rec
-
- c = d.cursor()
- c.set('0200')
- num = c.get_recno()
- self.assertEqual(type(num), type(1))
- if verbose:
- print "recno of d['0200'] is ", num
-
- rec = c.current()
- self.assertEqual(c.set_recno(num), rec)
-
- c.close()
-
-
-
-class BTreeRecnoWithThreadFlagTestCase(BTreeRecnoTestCase):
- dbopenflags = db.DB_THREAD
-
-#----------------------------------------------------------------------
-
-class BasicDUPTestCase(BasicTestCase):
- dbsetflags = db.DB_DUP
-
- def test10_DuplicateKeys(self):
- d = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test10_DuplicateKeys..." % \
- self.__class__.__name__
-
- d.put("dup0", "before")
- for x in "The quick brown fox jumped over the lazy dog.".split():
- d.put("dup1", x)
- d.put("dup2", "after")
-
- data = d.get("dup1")
- self.assertEqual(data, "The")
- if verbose:
- print data
-
- c = d.cursor()
- rec = c.set("dup1")
- self.assertEqual(rec, ('dup1', 'The'))
-
- next_reg = c.next()
- self.assertEqual(next_reg, ('dup1', 'quick'))
-
- rec = c.set("dup1")
- count = c.count()
- self.assertEqual(count, 9)
-
- next_dup = c.next_dup()
- self.assertEqual(next_dup, ('dup1', 'quick'))
-
- rec = c.set('dup1')
- while rec is not None:
- if verbose:
- print rec
- rec = c.next_dup()
-
- c.set('dup1')
- rec = c.next_nodup()
- self.assertNotEqual(rec[0], 'dup1')
- if verbose:
- print rec
-
- c.close()
-
-
-
-class BTreeDUPTestCase(BasicDUPTestCase):
- dbtype = db.DB_BTREE
-
-class HashDUPTestCase(BasicDUPTestCase):
- dbtype = db.DB_HASH
-
-class BTreeDUPWithThreadTestCase(BasicDUPTestCase):
- dbtype = db.DB_BTREE
- dbopenflags = db.DB_THREAD
-
-class HashDUPWithThreadTestCase(BasicDUPTestCase):
- dbtype = db.DB_HASH
- dbopenflags = db.DB_THREAD
-
-
-#----------------------------------------------------------------------
-
-class BasicMultiDBTestCase(BasicTestCase):
- dbname = 'first'
-
- def otherType(self):
- if self.dbtype == db.DB_BTREE:
- return db.DB_HASH
- else:
- return db.DB_BTREE
-
- def test11_MultiDB(self):
- d1 = self.d
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test11_MultiDB..." % self.__class__.__name__
-
- d2 = db.DB(self.env)
- d2.open(self.filename, "second", self.dbtype,
- self.dbopenflags|db.DB_CREATE)
- d3 = db.DB(self.env)
- d3.open(self.filename, "third", self.otherType(),
- self.dbopenflags|db.DB_CREATE)
-
- for x in "The quick brown fox jumped over the lazy dog".split():
- d2.put(x, self.makeData(x))
-
- for x in string.letters:
- d3.put(x, x*70)
-
- d1.sync()
- d2.sync()
- d3.sync()
- d1.close()
- d2.close()
- d3.close()
-
- self.d = d1 = d2 = d3 = None
-
- self.d = d1 = db.DB(self.env)
- d1.open(self.filename, self.dbname, flags = self.dbopenflags)
- d2 = db.DB(self.env)
- d2.open(self.filename, "second", flags = self.dbopenflags)
- d3 = db.DB(self.env)
- d3.open(self.filename, "third", flags = self.dbopenflags)
-
- c1 = d1.cursor()
- c2 = d2.cursor()
- c3 = d3.cursor()
-
- count = 0
- rec = c1.first()
- while rec is not None:
- count = count + 1
- if verbose and (count % 50) == 0:
- print rec
- rec = c1.next()
- self.assertEqual(count, self._numKeys)
-
- count = 0
- rec = c2.first()
- while rec is not None:
- count = count + 1
- if verbose:
- print rec
- rec = c2.next()
- self.assertEqual(count, 9)
-
- count = 0
- rec = c3.first()
- while rec is not None:
- count = count + 1
- if verbose:
- print rec
- rec = c3.next()
- self.assertEqual(count, len(string.letters))
-
-
- c1.close()
- c2.close()
- c3.close()
-
- d2.close()
- d3.close()
-
-
-
-# Strange things happen if you try to use Multiple DBs per file without a
-# DBEnv with MPOOL and LOCKing...
-
-class BTreeMultiDBTestCase(BasicMultiDBTestCase):
- dbtype = db.DB_BTREE
- dbopenflags = db.DB_THREAD
- useEnv = 1
- envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
-
-class HashMultiDBTestCase(BasicMultiDBTestCase):
- dbtype = db.DB_HASH
- dbopenflags = db.DB_THREAD
- useEnv = 1
- envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
-
-
-class PrivateObject(unittest.TestCase) :
- import sys
- if sys.version_info < (2, 4):
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def tearDown(self) :
- del self.obj
-
- def test01_DefaultIsNone(self) :
- self.assertEqual(self.obj.get_private(), None)
-
- def test02_assignment(self) :
- a = "example of private object"
- self.obj.set_private(a)
- b = self.obj.get_private()
- self.assertTrue(a is b) # Object identity
-
- def test03_leak_assignment(self) :
- import sys
- a = "example of private object"
- refcount = sys.getrefcount(a)
- self.obj.set_private(a)
- self.assertEqual(refcount+1, sys.getrefcount(a))
- self.obj.set_private(None)
- self.assertEqual(refcount, sys.getrefcount(a))
-
- def test04_leak_GC(self) :
- import sys
- a = "example of private object"
- refcount = sys.getrefcount(a)
- self.obj.set_private(a)
- self.obj = None
- self.assertEqual(refcount, sys.getrefcount(a))
-
-class DBEnvPrivateObject(PrivateObject) :
- def setUp(self) :
- self.obj = db.DBEnv()
-
-class DBPrivateObject(PrivateObject) :
- def setUp(self) :
- self.obj = db.DB()
-
-class CrashAndBurn(unittest.TestCase) :
- import sys
- if sys.version_info < (2, 4):
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- #def test01_OpenCrash(self) :
- # # See http://bugs.python.org/issue3307
- # self.assertRaises(db.DBInvalidArgError, db.DB, None, 65535)
-
- if db.version() < (4, 8) :
- def test02_DBEnv_dealloc(self):
- # http://bugs.python.org/issue3885
- import gc
- self.assertRaises(db.DBInvalidArgError, db.DBEnv, ~db.DB_RPCCLIENT)
- gc.collect()
-
-
-#----------------------------------------------------------------------
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(VersionTestCase))
- suite.addTest(unittest.makeSuite(BasicBTreeTestCase))
- suite.addTest(unittest.makeSuite(BasicHashTestCase))
- suite.addTest(unittest.makeSuite(BasicBTreeWithThreadFlagTestCase))
- suite.addTest(unittest.makeSuite(BasicHashWithThreadFlagTestCase))
- suite.addTest(unittest.makeSuite(BasicBTreeWithEnvTestCase))
- suite.addTest(unittest.makeSuite(BasicHashWithEnvTestCase))
- suite.addTest(unittest.makeSuite(BTreeTransactionTestCase))
- suite.addTest(unittest.makeSuite(HashTransactionTestCase))
- suite.addTest(unittest.makeSuite(BTreeRecnoTestCase))
- suite.addTest(unittest.makeSuite(BTreeRecnoWithThreadFlagTestCase))
- suite.addTest(unittest.makeSuite(BTreeDUPTestCase))
- suite.addTest(unittest.makeSuite(HashDUPTestCase))
- suite.addTest(unittest.makeSuite(BTreeDUPWithThreadTestCase))
- suite.addTest(unittest.makeSuite(HashDUPWithThreadTestCase))
- suite.addTest(unittest.makeSuite(BTreeMultiDBTestCase))
- suite.addTest(unittest.makeSuite(HashMultiDBTestCase))
- suite.addTest(unittest.makeSuite(DBEnvPrivateObject))
- suite.addTest(unittest.makeSuite(DBPrivateObject))
- suite.addTest(unittest.makeSuite(CrashAndBurn))
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_compare.py b/Lib/bsddb/test/test_compare.py
deleted file mode 100644
index db9cd748057..00000000000
--- a/Lib/bsddb/test/test_compare.py
+++ /dev/null
@@ -1,273 +0,0 @@
-"""
-TestCases for python DB Btree key comparison function.
-"""
-
-import sys, os, re
-import test_all
-from cStringIO import StringIO
-
-import unittest
-
-from test_all import db, dbshelve, test_support, \
- get_new_environment_path, get_new_database_path
-
-
-# Needed for python 3. "cmp" vanished in 3.0.1
-def cmp(a, b) :
- if a==b : return 0
- if a<b : return -1
- return 1
-
-lexical_cmp = cmp
-
-def lowercase_cmp(left, right):
- return cmp (left.lower(), right.lower())
-
-def make_reverse_comparator (cmp):
- def reverse (left, right, delegate=cmp):
- return - delegate (left, right)
- return reverse
-
-_expected_lexical_test_data = ['', 'CCCP', 'a', 'aaa', 'b', 'c', 'cccce', 'ccccf']
-_expected_lowercase_test_data = ['', 'a', 'aaa', 'b', 'c', 'CC', 'cccce', 'ccccf', 'CCCP']
-
-class ComparatorTests (unittest.TestCase):
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None) :
- return self.failUnless(expr,msg=msg)
-
- def comparator_test_helper (self, comparator, expected_data):
- data = expected_data[:]
-
- import sys
- if sys.version_info < (2, 6) :
- if sys.version_info < (2, 4) :
- data.sort(comparator)
- else :
- data.sort(cmp=comparator)
- else : # Insertion Sort. Please, improve
- data2 = []
- for i in data :
- for j, k in enumerate(data2) :
- r = comparator(k, i)
- if r == 1 :
- data2.insert(j, i)
- break
- else :
- data2.append(i)
- data = data2
-
- self.assertEqual(data, expected_data,
- "comparator `%s' is not right: %s vs. %s"
- % (comparator, expected_data, data))
- def test_lexical_comparator (self):
- self.comparator_test_helper (lexical_cmp, _expected_lexical_test_data)
- def test_reverse_lexical_comparator (self):
- rev = _expected_lexical_test_data[:]
- rev.reverse ()
- self.comparator_test_helper (make_reverse_comparator (lexical_cmp),
- rev)
- def test_lowercase_comparator (self):
- self.comparator_test_helper (lowercase_cmp,
- _expected_lowercase_test_data)
-
-class AbstractBtreeKeyCompareTestCase (unittest.TestCase):
- env = None
- db = None
-
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- if (sys.version_info < (2, 7)) or ((sys.version_info >= (3,0)) and
- (sys.version_info < (3, 2))) :
- def assertLess(self, a, b, msg=None) :
- return self.assertTrue(a<b, msg=msg)
-
- def setUp (self):
- self.filename = self.__class__.__name__ + '.db'
- self.homeDir = get_new_environment_path()
- env = db.DBEnv()
- env.open (self.homeDir,
- db.DB_CREATE | db.DB_INIT_MPOOL
- | db.DB_INIT_LOCK | db.DB_THREAD)
- self.env = env
-
- def tearDown (self):
- self.closeDB()
- if self.env is not None:
- self.env.close()
- self.env = None
- test_support.rmtree(self.homeDir)
-
- def addDataToDB (self, data):
- i = 0
- for item in data:
- self.db.put (item, str (i))
- i = i + 1
-
- def createDB (self, key_comparator):
- self.db = db.DB (self.env)
- self.setupDB (key_comparator)
- self.db.open (self.filename, "test", db.DB_BTREE, db.DB_CREATE)
-
- def setupDB (self, key_comparator):
- self.db.set_bt_compare (key_comparator)
-
- def closeDB (self):
- if self.db is not None:
- self.db.close ()
- self.db = None
-
- def startTest (self):
- pass
-
- def finishTest (self, expected = None):
- if expected is not None:
- self.check_results (expected)
- self.closeDB ()
-
- def check_results (self, expected):
- curs = self.db.cursor ()
- try:
- index = 0
- rec = curs.first ()
- while rec:
- key, ignore = rec
- self.assertLess(index, len (expected),
- "to many values returned from cursor")
- self.assertEqual(expected[index], key,
- "expected value `%s' at %d but got `%s'"
- % (expected[index], index, key))
- index = index + 1
- rec = curs.next ()
- self.assertEqual(index, len (expected),
- "not enough values returned from cursor")
- finally:
- curs.close ()
-
-class BtreeKeyCompareTestCase (AbstractBtreeKeyCompareTestCase):
- def runCompareTest (self, comparator, data):
- self.startTest ()
- self.createDB (comparator)
- self.addDataToDB (data)
- self.finishTest (data)
-
- def test_lexical_ordering (self):
- self.runCompareTest (lexical_cmp, _expected_lexical_test_data)
-
- def test_reverse_lexical_ordering (self):
- expected_rev_data = _expected_lexical_test_data[:]
- expected_rev_data.reverse ()
- self.runCompareTest (make_reverse_comparator (lexical_cmp),
- expected_rev_data)
-
- def test_compare_function_useless (self):
- self.startTest ()
- def socialist_comparator (l, r):
- return 0
- self.createDB (socialist_comparator)
- self.addDataToDB (['b', 'a', 'd'])
- # all things being equal the first key will be the only key
- # in the database... (with the last key's value fwiw)
- self.finishTest (['b'])
-
-
-class BtreeExceptionsTestCase (AbstractBtreeKeyCompareTestCase):
- def test_raises_non_callable (self):
- self.startTest ()
- self.assertRaises (TypeError, self.createDB, 'abc')
- self.assertRaises (TypeError, self.createDB, None)
- self.finishTest ()
-
- def test_set_bt_compare_with_function (self):
- self.startTest ()
- self.createDB (lexical_cmp)
- self.finishTest ()
-
- def check_results (self, results):
- pass
-
- def test_compare_function_incorrect (self):
- self.startTest ()
- def bad_comparator (l, r):
- return 1
- # verify that set_bt_compare checks that comparator('', '') == 0
- self.assertRaises (TypeError, self.createDB, bad_comparator)
- self.finishTest ()
-
- def verifyStderr(self, method, successRe):
- """
- Call method() while capturing sys.stderr output internally and
- call self.fail() if successRe.search() does not match the stderr
- output. This is used to test for uncatchable exceptions.
- """
- stdErr = sys.stderr
- sys.stderr = StringIO()
- try:
- method()
- finally:
- temp = sys.stderr
- sys.stderr = stdErr
- errorOut = temp.getvalue()
- if not successRe.search(errorOut):
- self.fail("unexpected stderr output:\n"+errorOut)
- if sys.version_info < (3, 0) : # XXX: How to do this in Py3k ???
- sys.exc_traceback = sys.last_traceback = None
-
- def _test_compare_function_exception (self):
- self.startTest ()
- def bad_comparator (l, r):
- if l == r:
- # pass the set_bt_compare test
- return 0
- raise RuntimeError, "i'm a naughty comparison function"
- self.createDB (bad_comparator)
- #print "\n*** test should print 2 uncatchable tracebacks ***"
- self.addDataToDB (['a', 'b', 'c']) # this should raise, but...
- self.finishTest ()
-
- def test_compare_function_exception(self):
- self.verifyStderr(
- self._test_compare_function_exception,
- re.compile('(^RuntimeError:.* naughty.*){2}', re.M|re.S)
- )
-
- def _test_compare_function_bad_return (self):
- self.startTest ()
- def bad_comparator (l, r):
- if l == r:
- # pass the set_bt_compare test
- return 0
- return l
- self.createDB (bad_comparator)
- #print "\n*** test should print 2 errors about returning an int ***"
- self.addDataToDB (['a', 'b', 'c']) # this should raise, but...
- self.finishTest ()
-
- def test_compare_function_bad_return(self):
- self.verifyStderr(
- self._test_compare_function_bad_return,
- re.compile('(^TypeError:.* return an int.*){2}', re.M|re.S)
- )
-
-
- def test_cannot_assign_twice (self):
-
- def my_compare (a, b):
- return 0
-
- self.startTest()
- self.createDB(my_compare)
- self.assertRaises (RuntimeError, self.db.set_bt_compare, my_compare)
-
-def test_suite ():
- res = unittest.TestSuite ()
-
- res.addTest (unittest.makeSuite (ComparatorTests))
- res.addTest (unittest.makeSuite (BtreeExceptionsTestCase))
- res.addTest (unittest.makeSuite (BtreeKeyCompareTestCase))
- return res
-
-if __name__ == '__main__':
- unittest.main (defaultTest = 'suite')
diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py
deleted file mode 100644
index 7679f197c61..00000000000
--- a/Lib/bsddb/test/test_compat.py
+++ /dev/null
@@ -1,184 +0,0 @@
-"""
-Test cases adapted from the test_bsddb.py module in Python's
-regression test suite.
-"""
-
-import os, string
-import unittest
-
-from test_all import db, hashopen, btopen, rnopen, verbose, \
- get_new_database_path
-
-
-class CompatibilityTestCase(unittest.TestCase):
- def setUp(self):
- self.filename = get_new_database_path()
-
- def tearDown(self):
- try:
- os.remove(self.filename)
- except os.error:
- pass
-
-
- def test01_btopen(self):
- self.do_bthash_test(btopen, 'btopen')
-
- def test02_hashopen(self):
- self.do_bthash_test(hashopen, 'hashopen')
-
- def test03_rnopen(self):
- data = "The quick brown fox jumped over the lazy dog.".split()
- if verbose:
- print "\nTesting: rnopen"
-
- f = rnopen(self.filename, 'c')
- for x in range(len(data)):
- f[x+1] = data[x]
-
- getTest = (f[1], f[2], f[3])
- if verbose:
- print '%s %s %s' % getTest
-
- self.assertEqual(getTest[1], 'quick', 'data mismatch!')
-
- rv = f.set_location(3)
- if rv != (3, 'brown'):
- self.fail('recno database set_location failed: '+repr(rv))
-
- f[25] = 'twenty-five'
- f.close()
- del f
-
- f = rnopen(self.filename, 'w')
- f[20] = 'twenty'
-
- def noRec(f):
- rec = f[15]
- self.assertRaises(KeyError, noRec, f)
-
- def badKey(f):
- rec = f['a string']
- self.assertRaises(TypeError, badKey, f)
-
- del f[3]
-
- rec = f.first()
- while rec:
- if verbose:
- print rec
- try:
- rec = f.next()
- except KeyError:
- break
-
- f.close()
-
-
- def test04_n_flag(self):
- f = hashopen(self.filename, 'n')
- f.close()
-
-
- def do_bthash_test(self, factory, what):
- if verbose:
- print '\nTesting: ', what
-
- f = factory(self.filename, 'c')
- if verbose:
- print 'creation...'
-
- # truth test
- if f:
- if verbose: print "truth test: true"
- else:
- if verbose: print "truth test: false"
-
- f['0'] = ''
- f['a'] = 'Guido'
- f['b'] = 'van'
- f['c'] = 'Rossum'
- f['d'] = 'invented'
- # 'e' intentionally left out
- f['f'] = 'Python'
- if verbose:
- print '%s %s %s' % (f['a'], f['b'], f['c'])
-
- if verbose:
- print 'key ordering...'
- start = f.set_location(f.first()[0])
- if start != ('0', ''):
- self.fail("incorrect first() result: "+repr(start))
- while 1:
- try:
- rec = f.next()
- except KeyError:
- self.assertEqual(rec, f.last(), 'Error, last <> last!')
- f.previous()
- break
- if verbose:
- print rec
-
- self.assertTrue(f.has_key('f'), 'Error, missing key!')
-
- # test that set_location() returns the next nearest key, value
- # on btree databases and raises KeyError on others.
- if factory == btopen:
- e = f.set_location('e')
- if e != ('f', 'Python'):
- self.fail('wrong key,value returned: '+repr(e))
- else:
- try:
- e = f.set_location('e')
- except KeyError:
- pass
- else:
- self.fail("set_location on non-existent key did not raise KeyError")
-
- f.sync()
- f.close()
- # truth test
- try:
- if f:
- if verbose: print "truth test: true"
- else:
- if verbose: print "truth test: false"
- except db.DBError:
- pass
- else:
- self.fail("Exception expected")
-
- del f
-
- if verbose:
- print 'modification...'
- f = factory(self.filename, 'w')
- f['d'] = 'discovered'
-
- if verbose:
- print 'access...'
- for key in f.keys():
- word = f[key]
- if verbose:
- print word
-
- def noRec(f):
- rec = f['no such key']
- self.assertRaises(KeyError, noRec, f)
-
- def badKey(f):
- rec = f[15]
- self.assertRaises(TypeError, badKey, f)
-
- f.close()
-
-
-#----------------------------------------------------------------------
-
-
-def test_suite():
- return unittest.makeSuite(CompatibilityTestCase)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_cursor_pget_bug.py b/Lib/bsddb/test/test_cursor_pget_bug.py
deleted file mode 100644
index 22d3dc1ce55..00000000000
--- a/Lib/bsddb/test/test_cursor_pget_bug.py
+++ /dev/null
@@ -1,54 +0,0 @@
-import unittest
-import os, glob
-
-from test_all import db, test_support, get_new_environment_path, \
- get_new_database_path
-
-#----------------------------------------------------------------------
-
-class pget_bugTestCase(unittest.TestCase):
- """Verify that cursor.pget works properly"""
- db_name = 'test-cursor_pget.db'
-
- def setUp(self):
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- self.primary_db = db.DB(self.env)
- self.primary_db.open(self.db_name, 'primary', db.DB_BTREE, db.DB_CREATE)
- self.secondary_db = db.DB(self.env)
- self.secondary_db.set_flags(db.DB_DUP)
- self.secondary_db.open(self.db_name, 'secondary', db.DB_BTREE, db.DB_CREATE)
- self.primary_db.associate(self.secondary_db, lambda key, data: data)
- self.primary_db.put('salad', 'eggs')
- self.primary_db.put('spam', 'ham')
- self.primary_db.put('omelet', 'eggs')
-
-
- def tearDown(self):
- self.secondary_db.close()
- self.primary_db.close()
- self.env.close()
- del self.secondary_db
- del self.primary_db
- del self.env
- test_support.rmtree(self.homeDir)
-
- def test_pget(self):
- cursor = self.secondary_db.cursor()
-
- self.assertEqual(('eggs', 'salad', 'eggs'), cursor.pget(key='eggs', flags=db.DB_SET))
- self.assertEqual(('eggs', 'omelet', 'eggs'), cursor.pget(db.DB_NEXT_DUP))
- self.assertEqual(None, cursor.pget(db.DB_NEXT_DUP))
-
- self.assertEqual(('ham', 'spam', 'ham'), cursor.pget('ham', 'spam', flags=db.DB_SET))
- self.assertEqual(None, cursor.pget(db.DB_NEXT_DUP))
-
- cursor.close()
-
-
-def test_suite():
- return unittest.makeSuite(pget_bugTestCase)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_db.py b/Lib/bsddb/test/test_db.py
deleted file mode 100644
index 8d3a32bbeba..00000000000
--- a/Lib/bsddb/test/test_db.py
+++ /dev/null
@@ -1,142 +0,0 @@
-import unittest
-import os, glob
-
-from test_all import db, test_support, get_new_environment_path, \
- get_new_database_path
-
-#----------------------------------------------------------------------
-
-class DB(unittest.TestCase):
- import sys
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def setUp(self):
- self.path = get_new_database_path()
- self.db = db.DB()
-
- def tearDown(self):
- self.db.close()
- del self.db
- test_support.rmtree(self.path)
-
-class DB_general(DB) :
- if db.version() >= (4, 2) :
- def test_bt_minkey(self) :
- for i in [17, 108, 1030] :
- self.db.set_bt_minkey(i)
- self.assertEqual(i, self.db.get_bt_minkey())
-
- def test_lorder(self) :
- self.db.set_lorder(1234)
- self.assertEqual(1234, self.db.get_lorder())
- self.db.set_lorder(4321)
- self.assertEqual(4321, self.db.get_lorder())
- self.assertRaises(db.DBInvalidArgError, self.db.set_lorder, 9182)
-
- if db.version() >= (4, 6) :
- def test_priority(self) :
- flags = [db.DB_PRIORITY_VERY_LOW, db.DB_PRIORITY_LOW,
- db.DB_PRIORITY_DEFAULT, db.DB_PRIORITY_HIGH,
- db.DB_PRIORITY_VERY_HIGH]
- for flag in flags :
- self.db.set_priority(flag)
- self.assertEqual(flag, self.db.get_priority())
-
-class DB_hash(DB) :
- if db.version() >= (4, 2) :
- def test_h_ffactor(self) :
- for ffactor in [4, 16, 256] :
- self.db.set_h_ffactor(ffactor)
- self.assertEqual(ffactor, self.db.get_h_ffactor())
-
- def test_h_nelem(self) :
- for nelem in [1, 2, 4] :
- nelem = nelem*1024*1024 # Millions
- self.db.set_h_nelem(nelem)
- self.assertEqual(nelem, self.db.get_h_nelem())
-
- def test_pagesize(self) :
- for i in xrange(9, 17) : # From 512 to 65536
- i = 1<<i
- self.db.set_pagesize(i)
- self.assertEqual(i, self.db.get_pagesize())
-
- # The valid values goes from 512 to 65536
- # Test 131072 bytes...
- self.assertRaises(db.DBInvalidArgError, self.db.set_pagesize, 1<<17)
- # Test 256 bytes...
- self.assertRaises(db.DBInvalidArgError, self.db.set_pagesize, 1<<8)
-
-class DB_txn(DB) :
- def setUp(self) :
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
- db.DB_INIT_LOG | db.DB_INIT_TXN)
- self.db = db.DB(self.env)
-
- def tearDown(self) :
- self.db.close()
- del self.db
- self.env.close()
- del self.env
- test_support.rmtree(self.homeDir)
-
- if db.version() >= (4, 2) :
- def test_flags(self) :
- self.db.set_flags(db.DB_CHKSUM)
- self.assertEqual(db.DB_CHKSUM, self.db.get_flags())
- self.db.set_flags(db.DB_TXN_NOT_DURABLE)
- self.assertEqual(db.DB_TXN_NOT_DURABLE | db.DB_CHKSUM,
- self.db.get_flags())
-
-class DB_recno(DB) :
- if db.version() >= (4, 2) :
- def test_re_pad(self) :
- for i in [' ', '*'] : # Check chars
- self.db.set_re_pad(i)
- self.assertEqual(ord(i), self.db.get_re_pad())
- for i in [97, 65] : # Check integers
- self.db.set_re_pad(i)
- self.assertEqual(i, self.db.get_re_pad())
-
- def test_re_delim(self) :
- for i in [' ', '*'] : # Check chars
- self.db.set_re_delim(i)
- self.assertEqual(ord(i), self.db.get_re_delim())
- for i in [97, 65] : # Check integers
- self.db.set_re_delim(i)
- self.assertEqual(i, self.db.get_re_delim())
-
- def test_re_source(self) :
- for i in ["test", "test2", "test3"] :
- self.db.set_re_source(i)
- self.assertEqual(i, self.db.get_re_source())
-
-class DB_queue(DB) :
- if db.version() >= (4, 2) :
- def test_re_len(self) :
- for i in [33, 65, 300, 2000] :
- self.db.set_re_len(i)
- self.assertEqual(i, self.db.get_re_len())
-
- def test_q_extentsize(self) :
- for i in [1, 60, 100] :
- self.db.set_q_extentsize(i)
- self.assertEqual(i, self.db.get_q_extentsize())
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(DB_general))
- suite.addTest(unittest.makeSuite(DB_txn))
- suite.addTest(unittest.makeSuite(DB_hash))
- suite.addTest(unittest.makeSuite(DB_recno))
- suite.addTest(unittest.makeSuite(DB_queue))
-
- return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_dbenv.py b/Lib/bsddb/test/test_dbenv.py
deleted file mode 100644
index 37281dfc2f3..00000000000
--- a/Lib/bsddb/test/test_dbenv.py
+++ /dev/null
@@ -1,513 +0,0 @@
-import unittest
-import os, glob
-
-from test_all import db, test_support, get_new_environment_path, \
- get_new_database_path
-
-#----------------------------------------------------------------------
-
-class DBEnv(unittest.TestCase):
- import sys
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def assertFalse(self, expr, msg=None):
- self.failIf(expr,msg=msg)
-
- def setUp(self):
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
-
- def tearDown(self):
- self.env.close()
- del self.env
- test_support.rmtree(self.homeDir)
-
-class DBEnv_general(DBEnv) :
- if db.version() >= (4, 7) :
- def test_lk_partitions(self) :
- for i in [10, 20, 40] :
- self.env.set_lk_partitions(i)
- self.assertEqual(i, self.env.get_lk_partitions())
-
- if db.version() >= (4, 6) :
- def test_thread(self) :
- for i in [16, 100, 1000] :
- self.env.set_thread_count(i)
- self.assertEqual(i, self.env.get_thread_count())
-
- def test_cache_max(self) :
- for size in [64, 128] :
- size = size*1024*1024 # Megabytes
- self.env.set_cache_max(0, size)
- size2 = self.env.get_cache_max()
- self.assertEqual(0, size2[0])
- self.assertTrue(size <= size2[1])
- self.assertTrue(2*size > size2[1])
-
- if db.version() >= (4, 4) :
- def test_mutex_stat(self) :
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
- db.DB_INIT_LOCK)
- stat = self.env.mutex_stat()
- self.assertTrue("mutex_inuse_max" in stat)
-
- def test_lg_filemode(self) :
- for i in [0600, 0660, 0666] :
- self.env.set_lg_filemode(i)
- self.assertEqual(i, self.env.get_lg_filemode())
-
- if db.version() >= (4, 3) :
- def test_mp_max_openfd(self) :
- for i in [17, 31, 42] :
- self.env.set_mp_max_openfd(i)
- self.assertEqual(i, self.env.get_mp_max_openfd())
-
- def test_mp_max_write(self) :
- for i in [100, 200, 300] :
- for j in [1, 2, 3] :
- j *= 1000000
- self.env.set_mp_max_write(i, j)
- v=self.env.get_mp_max_write()
- self.assertEqual((i, j), v)
-
- if db.version() >= (4, 2) :
- def test_invalid_txn(self) :
- # This environment doesn't support transactions
- self.assertRaises(db.DBInvalidArgError, self.env.txn_begin)
-
- def test_mp_mmapsize(self) :
- for i in [16, 32, 64] :
- i *= 1024*1024
- self.env.set_mp_mmapsize(i)
- self.assertEqual(i, self.env.get_mp_mmapsize())
-
- def test_tmp_dir(self) :
- for i in ["a", "bb", "ccc"] :
- self.env.set_tmp_dir(i)
- self.assertEqual(i, self.env.get_tmp_dir())
-
- def test_flags(self) :
- self.env.set_flags(db.DB_AUTO_COMMIT, 1)
- self.assertEqual(db.DB_AUTO_COMMIT, self.env.get_flags())
- self.env.set_flags(db.DB_TXN_NOSYNC, 1)
- self.assertEqual(db.DB_AUTO_COMMIT | db.DB_TXN_NOSYNC,
- self.env.get_flags())
- self.env.set_flags(db.DB_AUTO_COMMIT, 0)
- self.assertEqual(db.DB_TXN_NOSYNC, self.env.get_flags())
- self.env.set_flags(db.DB_TXN_NOSYNC, 0)
- self.assertEqual(0, self.env.get_flags())
-
- def test_lk_max_objects(self) :
- for i in [1000, 2000, 3000] :
- self.env.set_lk_max_objects(i)
- self.assertEqual(i, self.env.get_lk_max_objects())
-
- def test_lk_max_locks(self) :
- for i in [1000, 2000, 3000] :
- self.env.set_lk_max_locks(i)
- self.assertEqual(i, self.env.get_lk_max_locks())
-
- def test_lk_max_lockers(self) :
- for i in [1000, 2000, 3000] :
- self.env.set_lk_max_lockers(i)
- self.assertEqual(i, self.env.get_lk_max_lockers())
-
- def test_lg_regionmax(self) :
- for i in [128, 256, 1024] :
- i = i*1024*1024
- self.env.set_lg_regionmax(i)
- j = self.env.get_lg_regionmax()
- self.assertTrue(i <= j)
- self.assertTrue(2*i > j)
-
- def test_lk_detect(self) :
- flags= [db.DB_LOCK_DEFAULT, db.DB_LOCK_EXPIRE, db.DB_LOCK_MAXLOCKS,
- db.DB_LOCK_MINLOCKS, db.DB_LOCK_MINWRITE,
- db.DB_LOCK_OLDEST, db.DB_LOCK_RANDOM, db.DB_LOCK_YOUNGEST]
-
- if db.version() >= (4, 3) :
- flags.append(db.DB_LOCK_MAXWRITE)
-
- for i in flags :
- self.env.set_lk_detect(i)
- self.assertEqual(i, self.env.get_lk_detect())
-
- def test_lg_dir(self) :
- for i in ["a", "bb", "ccc", "dddd"] :
- self.env.set_lg_dir(i)
- self.assertEqual(i, self.env.get_lg_dir())
-
- def test_lg_bsize(self) :
- log_size = 70*1024
- self.env.set_lg_bsize(log_size)
- self.assertTrue(self.env.get_lg_bsize() >= log_size)
- self.assertTrue(self.env.get_lg_bsize() < 4*log_size)
- self.env.set_lg_bsize(4*log_size)
- self.assertTrue(self.env.get_lg_bsize() >= 4*log_size)
-
- def test_setget_data_dirs(self) :
- dirs = ("a", "b", "c", "d")
- for i in dirs :
- self.env.set_data_dir(i)
- self.assertEqual(dirs, self.env.get_data_dirs())
-
- def test_setget_cachesize(self) :
- cachesize = (0, 512*1024*1024, 3)
- self.env.set_cachesize(*cachesize)
- self.assertEqual(cachesize, self.env.get_cachesize())
-
- cachesize = (0, 1*1024*1024, 5)
- self.env.set_cachesize(*cachesize)
- cachesize2 = self.env.get_cachesize()
- self.assertEqual(cachesize[0], cachesize2[0])
- self.assertEqual(cachesize[2], cachesize2[2])
- # Berkeley DB expands the cache 25% accounting overhead,
- # if the cache is small.
- self.assertEqual(125, int(100.0*cachesize2[1]/cachesize[1]))
-
- # You can not change configuration after opening
- # the environment.
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- cachesize = (0, 2*1024*1024, 1)
- self.assertRaises(db.DBInvalidArgError,
- self.env.set_cachesize, *cachesize)
- self.assertEqual(cachesize2, self.env.get_cachesize())
-
- def test_set_cachesize_dbenv_db(self) :
- # You can not configure the cachesize using
- # the database handle, if you are using an environment.
- d = db.DB(self.env)
- self.assertRaises(db.DBInvalidArgError,
- d.set_cachesize, 0, 1024*1024, 1)
-
- def test_setget_shm_key(self) :
- shm_key=137
- self.env.set_shm_key(shm_key)
- self.assertEqual(shm_key, self.env.get_shm_key())
- self.env.set_shm_key(shm_key+1)
- self.assertEqual(shm_key+1, self.env.get_shm_key())
-
- # You can not change configuration after opening
- # the environment.
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- # If we try to reconfigure cache after opening the
- # environment, core dump.
- self.assertRaises(db.DBInvalidArgError,
- self.env.set_shm_key, shm_key)
- self.assertEqual(shm_key+1, self.env.get_shm_key())
-
- if db.version() >= (4, 4) :
- def test_mutex_setget_max(self) :
- v = self.env.mutex_get_max()
- v2 = v*2+1
-
- self.env.mutex_set_max(v2)
- self.assertEqual(v2, self.env.mutex_get_max())
-
- self.env.mutex_set_max(v)
- self.assertEqual(v, self.env.mutex_get_max())
-
- # You can not change configuration after opening
- # the environment.
- self.env.open(self.homeDir, db.DB_CREATE)
- self.assertRaises(db.DBInvalidArgError,
- self.env.mutex_set_max, v2)
-
- def test_mutex_setget_increment(self) :
- v = self.env.mutex_get_increment()
- v2 = 127
-
- self.env.mutex_set_increment(v2)
- self.assertEqual(v2, self.env.mutex_get_increment())
-
- self.env.mutex_set_increment(v)
- self.assertEqual(v, self.env.mutex_get_increment())
-
- # You can not change configuration after opening
- # the environment.
- self.env.open(self.homeDir, db.DB_CREATE)
- self.assertRaises(db.DBInvalidArgError,
- self.env.mutex_set_increment, v2)
-
- def test_mutex_setget_tas_spins(self) :
- self.env.mutex_set_tas_spins(0) # Default = BDB decides
- v = self.env.mutex_get_tas_spins()
- v2 = v*2+1
-
- self.env.mutex_set_tas_spins(v2)
- self.assertEqual(v2, self.env.mutex_get_tas_spins())
-
- self.env.mutex_set_tas_spins(v)
- self.assertEqual(v, self.env.mutex_get_tas_spins())
-
- # In this case, you can change configuration
- # after opening the environment.
- self.env.open(self.homeDir, db.DB_CREATE)
- self.env.mutex_set_tas_spins(v2)
-
- def test_mutex_setget_align(self) :
- v = self.env.mutex_get_align()
- v2 = 64
- if v == 64 :
- v2 = 128
-
- self.env.mutex_set_align(v2)
- self.assertEqual(v2, self.env.mutex_get_align())
-
- # Requires a nonzero power of two
- self.assertRaises(db.DBInvalidArgError,
- self.env.mutex_set_align, 0)
- self.assertRaises(db.DBInvalidArgError,
- self.env.mutex_set_align, 17)
-
- self.env.mutex_set_align(2*v2)
- self.assertEqual(2*v2, self.env.mutex_get_align())
-
- # You can not change configuration after opening
- # the environment.
- self.env.open(self.homeDir, db.DB_CREATE)
- self.assertRaises(db.DBInvalidArgError,
- self.env.mutex_set_align, v2)
-
-
-class DBEnv_log(DBEnv) :
- def setUp(self):
- DBEnv.setUp(self)
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOG)
-
- def test_log_file(self) :
- log_file = self.env.log_file((1, 1))
- self.assertEqual("log.0000000001", log_file[-14:])
-
- if db.version() >= (4, 4) :
- # The version with transactions is checked in other test object
- def test_log_printf(self) :
- msg = "This is a test..."
- self.env.log_printf(msg)
- logc = self.env.log_cursor()
- self.assertTrue(msg in (logc.last()[1]))
-
- if db.version() >= (4, 7) :
- def test_log_config(self) :
- self.env.log_set_config(db.DB_LOG_DSYNC | db.DB_LOG_ZERO, 1)
- self.assertTrue(self.env.log_get_config(db.DB_LOG_DSYNC))
- self.assertTrue(self.env.log_get_config(db.DB_LOG_ZERO))
- self.env.log_set_config(db.DB_LOG_ZERO, 0)
- self.assertTrue(self.env.log_get_config(db.DB_LOG_DSYNC))
- self.assertFalse(self.env.log_get_config(db.DB_LOG_ZERO))
-
-
-class DBEnv_log_txn(DBEnv) :
- def setUp(self):
- DBEnv.setUp(self)
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
- db.DB_INIT_LOG | db.DB_INIT_TXN)
-
- if db.version() >= (4, 5) :
- def test_tx_max(self) :
- txns=[]
- def tx() :
- for i in xrange(self.env.get_tx_max()) :
- txns.append(self.env.txn_begin())
-
- tx()
- self.assertRaises(MemoryError, tx)
-
- # Abort the transactions before garbage collection,
- # to avoid "warnings".
- for i in txns :
- i.abort()
-
- if db.version() >= (4, 4) :
- # The version without transactions is checked in other test object
- def test_log_printf(self) :
- msg = "This is a test..."
- txn = self.env.txn_begin()
- self.env.log_printf(msg, txn=txn)
- txn.commit()
- logc = self.env.log_cursor()
- logc.last() # Skip the commit
- self.assertTrue(msg in (logc.prev()[1]))
-
- msg = "This is another test..."
- txn = self.env.txn_begin()
- self.env.log_printf(msg, txn=txn)
- txn.abort() # Do not store the new message
- logc.last() # Skip the abort
- self.assertTrue(msg not in (logc.prev()[1]))
-
- msg = "This is a third test..."
- txn = self.env.txn_begin()
- self.env.log_printf(msg, txn=txn)
- txn.commit() # Do not store the new message
- logc.last() # Skip the commit
- self.assertTrue(msg in (logc.prev()[1]))
-
-
-class DBEnv_memp(DBEnv):
- def setUp(self):
- DBEnv.setUp(self)
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOG)
- self.db = db.DB(self.env)
- self.db.open("test", db.DB_HASH, db.DB_CREATE, 0660)
-
- def tearDown(self):
- self.db.close()
- del self.db
- DBEnv.tearDown(self)
-
- def test_memp_1_trickle(self) :
- self.db.put("hi", "bye")
- self.assertTrue(self.env.memp_trickle(100) > 0)
-
-# Preserve the order, do "memp_trickle" test first
- def test_memp_2_sync(self) :
- self.db.put("hi", "bye")
- self.env.memp_sync() # Full flush
- # Nothing to do...
- self.assertTrue(self.env.memp_trickle(100) == 0)
-
- self.db.put("hi", "bye2")
- self.env.memp_sync((1, 0)) # NOP, probably
- # Something to do... or not
- self.assertTrue(self.env.memp_trickle(100) >= 0)
-
- self.db.put("hi", "bye3")
- self.env.memp_sync((123, 99)) # Full flush
- # Nothing to do...
- self.assertTrue(self.env.memp_trickle(100) == 0)
-
- def test_memp_stat_1(self) :
- stats = self.env.memp_stat() # No param
- self.assertTrue(len(stats)==2)
- self.assertTrue("cache_miss" in stats[0])
- stats = self.env.memp_stat(db.DB_STAT_CLEAR) # Positional param
- self.assertTrue("cache_miss" in stats[0])
- stats = self.env.memp_stat(flags=0) # Keyword param
- self.assertTrue("cache_miss" in stats[0])
-
- def test_memp_stat_2(self) :
- stats=self.env.memp_stat()[1]
- self.assertTrue(len(stats))==1
- self.assertTrue("test" in stats)
- self.assertTrue("page_in" in stats["test"])
-
-class DBEnv_logcursor(DBEnv):
- def setUp(self):
- DBEnv.setUp(self)
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL |
- db.DB_INIT_LOG | db.DB_INIT_TXN)
- txn = self.env.txn_begin()
- self.db = db.DB(self.env)
- self.db.open("test", db.DB_HASH, db.DB_CREATE, 0660, txn=txn)
- txn.commit()
- for i in ["2", "8", "20"] :
- txn = self.env.txn_begin()
- self.db.put(key = i, data = i*int(i), txn=txn)
- txn.commit()
-
- def tearDown(self):
- self.db.close()
- del self.db
- DBEnv.tearDown(self)
-
- def _check_return(self, value) :
- self.assertTrue(isinstance(value, tuple))
- self.assertEqual(len(value), 2)
- self.assertTrue(isinstance(value[0], tuple))
- self.assertEqual(len(value[0]), 2)
- self.assertTrue(isinstance(value[0][0], int))
- self.assertTrue(isinstance(value[0][1], int))
- self.assertTrue(isinstance(value[1], str))
-
- # Preserve test order
- def test_1_first(self) :
- logc = self.env.log_cursor()
- v = logc.first()
- self._check_return(v)
- self.assertTrue((1, 1) < v[0])
- self.assertTrue(len(v[1])>0)
-
- def test_2_last(self) :
- logc = self.env.log_cursor()
- lsn_first = logc.first()[0]
- v = logc.last()
- self._check_return(v)
- self.assertTrue(lsn_first < v[0])
-
- def test_3_next(self) :
- logc = self.env.log_cursor()
- lsn_last = logc.last()[0]
- self.assertEqual(logc.next(), None)
- lsn_first = logc.first()[0]
- v = logc.next()
- self._check_return(v)
- self.assertTrue(lsn_first < v[0])
- self.assertTrue(lsn_last > v[0])
-
- v2 = logc.next()
- self.assertTrue(v2[0] > v[0])
- self.assertTrue(lsn_last > v2[0])
-
- v3 = logc.next()
- self.assertTrue(v3[0] > v2[0])
- self.assertTrue(lsn_last > v3[0])
-
- def test_4_prev(self) :
- logc = self.env.log_cursor()
- lsn_first = logc.first()[0]
- self.assertEqual(logc.prev(), None)
- lsn_last = logc.last()[0]
- v = logc.prev()
- self._check_return(v)
- self.assertTrue(lsn_first < v[0])
- self.assertTrue(lsn_last > v[0])
-
- v2 = logc.prev()
- self.assertTrue(v2[0] < v[0])
- self.assertTrue(lsn_first < v2[0])
-
- v3 = logc.prev()
- self.assertTrue(v3[0] < v2[0])
- self.assertTrue(lsn_first < v3[0])
-
- def test_5_current(self) :
- logc = self.env.log_cursor()
- logc.first()
- v = logc.next()
- self.assertEqual(v, logc.current())
-
- def test_6_set(self) :
- logc = self.env.log_cursor()
- logc.first()
- v = logc.next()
- self.assertNotEqual(v, logc.next())
- self.assertNotEqual(v, logc.next())
- self.assertEqual(v, logc.set(v[0]))
-
- def test_explicit_close(self) :
- logc = self.env.log_cursor()
- logc.close()
- self.assertRaises(db.DBCursorClosedError, logc.next)
-
- def test_implicit_close(self) :
- logc = [self.env.log_cursor() for i in xrange(10)]
- self.env.close() # This close should close too all its tree
- for i in logc :
- self.assertRaises(db.DBCursorClosedError, i.next)
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(DBEnv_general))
- suite.addTest(unittest.makeSuite(DBEnv_memp))
- suite.addTest(unittest.makeSuite(DBEnv_logcursor))
- suite.addTest(unittest.makeSuite(DBEnv_log))
- suite.addTest(unittest.makeSuite(DBEnv_log_txn))
-
- return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_dbobj.py b/Lib/bsddb/test/test_dbobj.py
deleted file mode 100644
index e301a5ad070..00000000000
--- a/Lib/bsddb/test/test_dbobj.py
+++ /dev/null
@@ -1,70 +0,0 @@
-
-import os, string
-import unittest
-
-from test_all import db, dbobj, test_support, get_new_environment_path, \
- get_new_database_path
-
-#----------------------------------------------------------------------
-
-class dbobjTestCase(unittest.TestCase):
- """Verify that dbobj.DB and dbobj.DBEnv work properly"""
- db_name = 'test-dbobj.db'
-
- def setUp(self):
- self.homeDir = get_new_environment_path()
-
- def tearDown(self):
- if hasattr(self, 'db'):
- del self.db
- if hasattr(self, 'env'):
- del self.env
- test_support.rmtree(self.homeDir)
-
- def test01_both(self):
- class TestDBEnv(dbobj.DBEnv): pass
- class TestDB(dbobj.DB):
- def put(self, key, *args, **kwargs):
- key = key.upper()
- # call our parent classes put method with an upper case key
- return dbobj.DB.put(self, key, *args, **kwargs)
- self.env = TestDBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- self.db = TestDB(self.env)
- self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
- self.db.put('spam', 'eggs')
- self.assertEqual(self.db.get('spam'), None,
- "overridden dbobj.DB.put() method failed [1]")
- self.assertEqual(self.db.get('SPAM'), 'eggs',
- "overridden dbobj.DB.put() method failed [2]")
- self.db.close()
- self.env.close()
-
- def test02_dbobj_dict_interface(self):
- self.env = dbobj.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- self.db = dbobj.DB(self.env)
- self.db.open(self.db_name+'02', db.DB_HASH, db.DB_CREATE)
- # __setitem__
- self.db['spam'] = 'eggs'
- # __len__
- self.assertEqual(len(self.db), 1)
- # __getitem__
- self.assertEqual(self.db['spam'], 'eggs')
- # __del__
- del self.db['spam']
- self.assertEqual(self.db.get('spam'), None, "dbobj __del__ failed")
- self.db.close()
- self.env.close()
-
- def test03_dbobj_type_before_open(self):
- # Ensure this doesn't cause a segfault.
- self.assertRaises(db.DBInvalidArgError, db.DB().type)
-
-#----------------------------------------------------------------------
-
-def test_suite():
- return unittest.makeSuite(dbobjTestCase)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py
deleted file mode 100644
index c0135febc77..00000000000
--- a/Lib/bsddb/test/test_dbshelve.py
+++ /dev/null
@@ -1,405 +0,0 @@
-"""
-TestCases for checking dbShelve objects.
-"""
-
-import os, string, sys
-import random
-import unittest
-
-
-from test_all import db, dbshelve, test_support, verbose, \
- get_new_environment_path, get_new_database_path
-
-
-
-if sys.version_info < (2, 4) :
- from sets import Set as set
-
-
-
-#----------------------------------------------------------------------
-
-# We want the objects to be comparable so we can test dbshelve.values
-# later on.
-class DataClass:
- def __init__(self):
- self.value = random.random()
-
- def __repr__(self) : # For Python 3.0 comparison
- return "DataClass %f" %self.value
-
- def __cmp__(self, other): # For Python 2.x comparison
- return cmp(self.value, other)
-
-
-class DBShelveTestCase(unittest.TestCase):
- if sys.version_info < (2, 4):
- def assertTrue(self, expr, msg=None):
- return self.failUnless(expr,msg=msg)
-
- if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
- (sys.version_info < (3, 2))) :
- def assertIn(self, a, b, msg=None) :
- return self.assertTrue(a in b, msg=msg)
-
-
- def setUp(self):
- if sys.version_info[0] >= 3 :
- from test_all import do_proxy_db_py3k
- self._flag_proxy_db_py3k = do_proxy_db_py3k(False)
- self.filename = get_new_database_path()
- self.do_open()
-
- def tearDown(self):
- if sys.version_info[0] >= 3 :
- from test_all import do_proxy_db_py3k
- do_proxy_db_py3k(self._flag_proxy_db_py3k)
- self.do_close()
- test_support.unlink(self.filename)
-
- def mk(self, key):
- """Turn key into an appropriate key type for this db"""
- # override in child class for RECNO
- if sys.version_info[0] < 3 :
- return key
- else :
- return bytes(key, "iso8859-1") # 8 bits
-
- def populateDB(self, d):
- for x in string.letters:
- d[self.mk('S' + x)] = 10 * x # add a string
- d[self.mk('I' + x)] = ord(x) # add an integer
- d[self.mk('L' + x)] = [x] * 10 # add a list
-
- inst = DataClass() # add an instance
- inst.S = 10 * x
- inst.I = ord(x)
- inst.L = [x] * 10
- d[self.mk('O' + x)] = inst
-
-
- # overridable in derived classes to affect how the shelf is created/opened
- def do_open(self):
- self.d = dbshelve.open(self.filename)
-
- # and closed...
- def do_close(self):
- self.d.close()
-
-
-
- def test01_basics(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_basics..." % self.__class__.__name__
-
- self.populateDB(self.d)
- self.d.sync()
- self.do_close()
- self.do_open()
- d = self.d
-
- l = len(d)
- k = d.keys()
- s = d.stat()
- f = d.fd()
-
- if verbose:
- print "length:", l
- print "keys:", k
- print "stats:", s
-
- self.assertEqual(0, d.has_key(self.mk('bad key')))
- self.assertEqual(1, d.has_key(self.mk('IA')))
- self.assertEqual(1, d.has_key(self.mk('OA')))
-
- d.delete(self.mk('IA'))
- del d[self.mk('OA')]
- self.assertEqual(0, d.has_key(self.mk('IA')))
- self.assertEqual(0, d.has_key(self.mk('OA')))
- self.assertEqual(len(d), l-2)
-
- values = []
- for key in d.keys():
- value = d[key]
- values.append(value)
- if verbose:
- print "%s: %s" % (key, value)
- self.checkrec(key, value)
-
- dbvalues = d.values()
- self.assertEqual(len(dbvalues), len(d.keys()))
- if sys.version_info < (2, 6) :
- values.sort()
- dbvalues.sort()
- self.assertEqual(values, dbvalues)
- else : # XXX: Convert all to strings. Please, improve
- values.sort(key=lambda x : str(x))
- dbvalues.sort(key=lambda x : str(x))
- self.assertEqual(repr(values), repr(dbvalues))
-
- items = d.items()
- self.assertEqual(len(items), len(values))
-
- for key, value in items:
- self.checkrec(key, value)
-
- self.assertEqual(d.get(self.mk('bad key')), None)
- self.assertEqual(d.get(self.mk('bad key'), None), None)
- self.assertEqual(d.get(self.mk('bad key'), 'a string'), 'a string')
- self.assertEqual(d.get(self.mk('bad key'), [1, 2, 3]), [1, 2, 3])
-
- d.set_get_returns_none(0)
- self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
- d.set_get_returns_none(1)
-
- d.put(self.mk('new key'), 'new data')
- self.assertEqual(d.get(self.mk('new key')), 'new data')
- self.assertEqual(d[self.mk('new key')], 'new data')
-
-
-
- def test02_cursors(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_cursors..." % self.__class__.__name__
-
- self.populateDB(self.d)
- d = self.d
-
- count = 0
- c = d.cursor()
- rec = c.first()
- while rec is not None:
- count = count + 1
- if verbose:
- print rec
- key, value = rec
- self.checkrec(key, value)
- # Hack to avoid conversion by 2to3 tool
- rec = getattr(c, "next")()
- del c
-
- self.assertEqual(count, len(d))
-
- count = 0
- c = d.cursor()
- rec = c.last()
- while rec is not None:
- count = count + 1
- if verbose:
- print rec
- key, value = rec
- self.checkrec(key, value)
- rec = c.prev()
-
- self.assertEqual(count, len(d))
-
- c.set(self.mk('SS'))
- key, value = c.current()
- self.checkrec(key, value)
- del c
-
-
- def test03_append(self):
- # NOTE: this is overridden in RECNO subclass, don't change its name.
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03_append..." % self.__class__.__name__
-
- self.assertRaises(dbshelve.DBShelveError,
- self.d.append, 'unit test was here')
-
-
- def test04_iterable(self) :
- self.populateDB(self.d)
- d = self.d
- keys = d.keys()
- keyset = set(keys)
- self.assertEqual(len(keyset), len(keys))
-
- for key in d :
- self.assertIn(key, keyset)
- keyset.remove(key)
- self.assertEqual(len(keyset), 0)
-
- def checkrec(self, key, value):
- # override this in a subclass if the key type is different
-
- if sys.version_info[0] >= 3 :
- if isinstance(key, bytes) :
- key = key.decode("iso8859-1") # 8 bits
-
- x = key[1]
- if key[0] == 'S':
- self.assertEqual(type(value), str)
- self.assertEqual(value, 10 * x)
-
- elif key[0] == 'I':
- self.assertEqual(type(value), int)
- self.assertEqual(value, ord(x))
-
- elif key[0] == 'L':
- self.assertEqual(type(value), list)
- self.assertEqual(value, [x] * 10)
-
- elif key[0] == 'O':
- if sys.version_info[0] < 3 :
- from types import InstanceType
- self.assertEqual(type(value), InstanceType)
- else :
- self.assertEqual(type(value), DataClass)
-
- self.assertEqual(value.S, 10 * x)
- self.assertEqual(value.I, ord(x))
- self.assertEqual(value.L, [x] * 10)
-
- else:
- self.assertTrue(0, 'Unknown key type, fix the test')
-
-#----------------------------------------------------------------------
-
-class BasicShelveTestCase(DBShelveTestCase):
- def do_open(self):
- self.d = dbshelve.DBShelf()
- self.d.open(self.filename, self.dbtype, self.dbflags)
-
- def do_close(self):
- self.d.close()
-
-
-class BTreeShelveTestCase(BasicShelveTestCase):
- dbtype = db.DB_BTREE
- dbflags = db.DB_CREATE
-
-
-class HashShelveTestCase(BasicShelveTestCase):
- dbtype = db.DB_HASH
- dbflags = db.DB_CREATE
-
-
-class ThreadBTreeShelveTestCase(BasicShelveTestCase):
- dbtype = db.DB_BTREE
- dbflags = db.DB_CREATE | db.DB_THREAD
-
-
-class ThreadHashShelveTestCase(BasicShelveTestCase):
- dbtype = db.DB_HASH
- dbflags = db.DB_CREATE | db.DB_THREAD
-
-
-#----------------------------------------------------------------------
-
-class BasicEnvShelveTestCase(DBShelveTestCase):
- def do_open(self):
- self.env = db.DBEnv()
- self.env.open(self.homeDir,
- self.envflags | db.DB_INIT_MPOOL | db.DB_CREATE)
-
- self.filename = os.path.split(self.filename)[1]
- self.d = dbshelve.DBShelf(self.env)
- self.d.open(self.filename, self.dbtype, self.dbflags)
-
-
- def do_close(self):
- self.d.close()
- self.env.close()
-
-
- def setUp(self) :
- self.homeDir = get_new_environment_path()
- DBShelveTestCase.setUp(self)
-
- def tearDown(self):
- if sys.version_info[0] >= 3 :
- from test_all import do_proxy_db_py3k
- do_proxy_db_py3k(self._flag_proxy_db_py3k)
- self.do_close()
- test_support.rmtree(self.homeDir)
-
-
-class EnvBTreeShelveTestCase(BasicEnvShelveTestCase):
- envflags = 0
- dbtype = db.DB_BTREE
- dbflags = db.DB_CREATE
-
-
-class EnvHashShelveTestCase(BasicEnvShelveTestCase):
- envflags = 0
- dbtype = db.DB_HASH
- dbflags = db.DB_CREATE
-
-
-class EnvThreadBTreeShelveTestCase(BasicEnvShelveTestCase):
- envflags = db.DB_THREAD
- dbtype = db.DB_BTREE
- dbflags = db.DB_CREATE | db.DB_THREAD
-
-
-class EnvThreadHashShelveTestCase(BasicEnvShelveTestCase):
- envflags = db.DB_THREAD
- dbtype = db.DB_HASH
- dbflags = db.DB_CREATE | db.DB_THREAD
-
-
-#----------------------------------------------------------------------
-# test cases for a DBShelf in a RECNO DB.
-
-class RecNoShelveTestCase(BasicShelveTestCase):
- dbtype = db.DB_RECNO
- dbflags = db.DB_CREATE
-
- def setUp(self):
- BasicShelveTestCase.setUp(self)
-
- # pool to assign integer key values out of
- self.key_pool = list(range(1, 5000))
- self.key_map = {} # map string keys to the number we gave them
- self.intkey_map = {} # reverse map of above
-
- def mk(self, key):
- if key not in self.key_map:
- self.key_map[key] = self.key_pool.pop(0)
- self.intkey_map[self.key_map[key]] = key
- return self.key_map[key]
-
- def checkrec(self, intkey, value):
- key = self.intkey_map[intkey]
- BasicShelveTestCase.checkrec(self, key, value)
-
- def test03_append(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03_append..." % self.__class__.__name__
-
- self.d[1] = 'spam'
- self.d[5] = 'eggs'
- self.assertEqual(6, self.d.append('spam'))
- self.assertEqual(7, self.d.append('baked beans'))
- self.assertEqual('spam', self.d.get(6))
- self.assertEqual('spam', self.d.get(1))
- self.assertEqual('baked beans', self.d.get(7))
- self.assertEqual('eggs', self.d.get(5))
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(DBShelveTestCase))
- suite.addTest(unittest.makeSuite(BTreeShelveTestCase))
- suite.addTest(unittest.makeSuite(HashShelveTestCase))
- suite.addTest(unittest.makeSuite(ThreadBTreeShelveTestCase))
- suite.addTest(unittest.makeSuite(ThreadHashShelveTestCase))
- suite.addTest(unittest.makeSuite(EnvBTreeShelveTestCase))
- suite.addTest(unittest.makeSuite(EnvHashShelveTestCase))
- suite.addTest(unittest.makeSuite(EnvThreadBTreeShelveTestCase))
- suite.addTest(unittest.makeSuite(EnvThreadHashShelveTestCase))
- suite.addTest(unittest.makeSuite(RecNoShelveTestCase))
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
deleted file mode 100644
index bb31381e14f..00000000000
--- a/Lib/bsddb/test/test_dbtables.py
+++ /dev/null
@@ -1,409 +0,0 @@
-#!/usr/bin/env python
-#
-#-----------------------------------------------------------------------
-# A test suite for the table interface built on bsddb.db
-#-----------------------------------------------------------------------
-#
-# Copyright (C) 2000, 2001 by Autonomous Zone Industries
-# Copyright (C) 2002 Gregory P. Smith
-#
-# March 20, 2000
-#
-# License: This is free software. You may use this software for any
-# purpose including modification/redistribution, so long as
-# this header remains intact and that you do not claim any
-# rights of ownership or authorship of this software. This
-# software has been tested, but no warranty is expressed or
-# implied.
-#
-# -- Gregory P. Smith <greg@krypto.org>
-#
-# $Id$
-
-import os, re, sys
-
-if sys.version_info[0] < 3 :
- try:
- import cPickle
- pickle = cPickle
- except ImportError:
- import pickle
-else :
- import pickle
-
-import unittest
-from test_all import db, dbtables, test_support, verbose, \
- get_new_environment_path, get_new_database_path
-
-#----------------------------------------------------------------------
-
-class TableDBTestCase(unittest.TestCase):
- db_name = 'test-table.db'
-
- def setUp(self):
- import sys
- if sys.version_info[0] >= 3 :
- from test_all import do_proxy_db_py3k
- self._flag_proxy_db_py3k = do_proxy_db_py3k(False)
-
- self.testHomeDir = get_new_environment_path()
- self.tdb = dbtables.bsdTableDB(
- filename='tabletest.db', dbhome=self.testHomeDir, create=1)
-
- def tearDown(self):
- self.tdb.close()
- import sys
- if sys.version_info[0] >= 3 :
- from test_all import do_proxy_db_py3k
- do_proxy_db_py3k(self._flag_proxy_db_py3k)
- test_support.rmtree(self.testHomeDir)
-
- def test01(self):
- tabname = "test01"
- colname = 'cool numbers'
- try:
- self.tdb.Drop(tabname)
- except dbtables.TableDBError:
- pass
- self.tdb.CreateTable(tabname, [colname])
- import sys
- if sys.version_info[0] < 3 :
- self.tdb.Insert(tabname, {colname: pickle.dumps(3.14159, 1)})
- else :
- self.tdb.Insert(tabname, {colname: pickle.dumps(3.14159,
- 1).decode("iso8859-1")}) # 8 bits
-
- if verbose:
- self.tdb._db_print()
-
- values = self.tdb.Select(
- tabname, [colname], conditions={colname: None})
-
- import sys
- if sys.version_info[0] < 3 :
- colval = pickle.loads(values[0][colname])
- else :
- colval = pickle.loads(bytes(values[0][colname], "iso8859-1"))
- self.assertTrue(colval > 3.141)
- self.assertTrue(colval < 3.142)
-
-
- def test02(self):
- tabname = "test02"
- col0 = 'coolness factor'
- col1 = 'but can it fly?'
- col2 = 'Species'
-
- import sys
- if sys.version_info[0] < 3 :
- testinfo = [
- {col0: pickle.dumps(8, 1), col1: 'no', col2: 'Penguin'},
- {col0: pickle.dumps(-1, 1), col1: 'no', col2: 'Turkey'},
- {col0: pickle.dumps(9, 1), col1: 'yes', col2: 'SR-71A Blackbird'}
- ]
- else :
- testinfo = [
- {col0: pickle.dumps(8, 1).decode("iso8859-1"),
- col1: 'no', col2: 'Penguin'},
- {col0: pickle.dumps(-1, 1).decode("iso8859-1"),
- col1: 'no', col2: 'Turkey'},
- {col0: pickle.dumps(9, 1).decode("iso8859-1"),
- col1: 'yes', col2: 'SR-71A Blackbird'}
- ]
-
- try:
- self.tdb.Drop(tabname)
- except dbtables.TableDBError:
- pass
- self.tdb.CreateTable(tabname, [col0, col1, col2])
- for row in testinfo :
- self.tdb.Insert(tabname, row)
-
- import sys
- if sys.version_info[0] < 3 :
- values = self.tdb.Select(tabname, [col2],
- conditions={col0: lambda x: pickle.loads(x) >= 8})
- else :
- values = self.tdb.Select(tabname, [col2],
- conditions={col0: lambda x:
- pickle.loads(bytes(x, "iso8859-1")) >= 8})
-
- self.assertEqual(len(values), 2)
- if values[0]['Species'] == 'Penguin' :
- self.assertEqual(values[1]['Species'], 'SR-71A Blackbird')
- elif values[0]['Species'] == 'SR-71A Blackbird' :
- self.assertEqual(values[1]['Species'], 'Penguin')
- else :
- if verbose:
- print "values= %r" % (values,)
- raise RuntimeError("Wrong values returned!")
-
- def test03(self):
- tabname = "test03"
- try:
- self.tdb.Drop(tabname)
- except dbtables.TableDBError:
- pass
- if verbose:
- print '...before CreateTable...'
- self.tdb._db_print()
- self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
- if verbose:
- print '...after CreateTable...'
- self.tdb._db_print()
- self.tdb.Drop(tabname)
- if verbose:
- print '...after Drop...'
- self.tdb._db_print()
- self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
-
- try:
- self.tdb.Insert(tabname,
- {'a': "",
- 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
- 'f': "Zero"})
- self.fail('Expected an exception')
- except dbtables.TableDBError:
- pass
-
- try:
- self.tdb.Select(tabname, [], conditions={'foo': '123'})
- self.fail('Expected an exception')
- except dbtables.TableDBError:
- pass
-
- self.tdb.Insert(tabname,
- {'a': '42',
- 'b': "bad",
- 'c': "meep",
- 'e': 'Fuzzy wuzzy was a bear'})
- self.tdb.Insert(tabname,
- {'a': '581750',
- 'b': "good",
- 'd': "bla",
- 'c': "black",
- 'e': 'fuzzy was here'})
- self.tdb.Insert(tabname,
- {'a': '800000',
- 'b': "good",
- 'd': "bla",
- 'c': "black",
- 'e': 'Fuzzy wuzzy is a bear'})
-
- if verbose:
- self.tdb._db_print()
-
- # this should return two rows
- values = self.tdb.Select(tabname, ['b', 'a', 'd'],
- conditions={'e': re.compile('wuzzy').search,
- 'a': re.compile('^[0-9]+$').match})
- self.assertEqual(len(values), 2)
-
- # now lets delete one of them and try again
- self.tdb.Delete(tabname, conditions={'b': dbtables.ExactCond('good')})
- values = self.tdb.Select(
- tabname, ['a', 'd', 'b'],
- conditions={'e': dbtables.PrefixCond('Fuzzy')})
- self.assertEqual(len(values), 1)
- self.assertEqual(values[0]['d'], None)
-
- values = self.tdb.Select(tabname, ['b'],
- conditions={'c': lambda c: c == 'meep'})
- self.assertEqual(len(values), 1)
- self.assertEqual(values[0]['b'], "bad")
-
-
- def test04_MultiCondSelect(self):
- tabname = "test04_MultiCondSelect"
- try:
- self.tdb.Drop(tabname)
- except dbtables.TableDBError:
- pass
- self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e'])
-
- try:
- self.tdb.Insert(tabname,
- {'a': "",
- 'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
- 'f': "Zero"})
- self.fail('Expected an exception')
- except dbtables.TableDBError:
- pass
-
- self.tdb.Insert(tabname, {'a': "A", 'b': "B", 'c': "C", 'd': "D",
- 'e': "E"})
- self.tdb.Insert(tabname, {'a': "-A", 'b': "-B", 'c': "-C", 'd': "-D",
- 'e': "-E"})
- self.tdb.Insert(tabname, {'a': "A-", 'b': "B-", 'c': "C-", 'd': "D-",
- 'e': "E-"})
-
- if verbose:
- self.tdb._db_print()
-
- # This select should return 0 rows. it is designed to test
- # the bug identified and fixed in sourceforge bug # 590449
- # (Big Thanks to "Rob Tillotson (n9mtb)" for tracking this down
- # and supplying a fix!! This one caused many headaches to say
- # the least...)
- values = self.tdb.Select(tabname, ['b', 'a', 'd'],
- conditions={'e': dbtables.ExactCond('E'),
- 'a': dbtables.ExactCond('A'),
- 'd': dbtables.PrefixCond('-')
- } )
- self.assertEqual(len(values), 0, values)
-
-
- def test_CreateOrExtend(self):
- tabname = "test_CreateOrExtend"
-
- self.tdb.CreateOrExtendTable(
- tabname, ['name', 'taste', 'filling', 'alcohol content', 'price'])
- try:
- self.tdb.Insert(tabname,
- {'taste': 'crap',
- 'filling': 'no',
- 'is it Guinness?': 'no'})
- self.fail("Insert should've failed due to bad column name")
- except:
- pass
- self.tdb.CreateOrExtendTable(tabname,
- ['name', 'taste', 'is it Guinness?'])
-
- # these should both succeed as the table should contain the union of both sets of columns.
- self.tdb.Insert(tabname, {'taste': 'crap', 'filling': 'no',
- 'is it Guinness?': 'no'})
- self.tdb.Insert(tabname, {'taste': 'great', 'filling': 'yes',
- 'is it Guinness?': 'yes',
- 'name': 'Guinness'})
-
-
- def test_CondObjs(self):
- tabname = "test_CondObjs"
-
- self.tdb.CreateTable(tabname, ['a', 'b', 'c', 'd', 'e', 'p'])
-
- self.tdb.Insert(tabname, {'a': "the letter A",
- 'b': "the letter B",
- 'c': "is for cookie"})
- self.tdb.Insert(tabname, {'a': "is for aardvark",
- 'e': "the letter E",
- 'c': "is for cookie",
- 'd': "is for dog"})
- self.tdb.Insert(tabname, {'a': "the letter A",
- 'e': "the letter E",
- 'c': "is for cookie",
- 'p': "is for Python"})
-
- values = self.tdb.Select(
- tabname, ['p', 'e'],
- conditions={'e': dbtables.PrefixCond('the l')})
- self.assertEqual(len(values), 2, values)
- self.assertEqual(values[0]['e'], values[1]['e'], values)
- self.assertNotEqual(values[0]['p'], values[1]['p'], values)
-
- values = self.tdb.Select(
- tabname, ['d', 'a'],
- conditions={'a': dbtables.LikeCond('%aardvark%')})
- self.assertEqual(len(values), 1, values)
- self.assertEqual(values[0]['d'], "is for dog", values)
- self.assertEqual(values[0]['a'], "is for aardvark", values)
-
- values = self.tdb.Select(tabname, None,
- {'b': dbtables.Cond(),
- 'e':dbtables.LikeCond('%letter%'),
- 'a':dbtables.PrefixCond('is'),
- 'd':dbtables.ExactCond('is for dog'),
- 'c':dbtables.PrefixCond('is for'),
- 'p':lambda s: not s})
- self.assertEqual(len(values), 1, values)
- self.assertEqual(values[0]['d'], "is for dog", values)
- self.assertEqual(values[0]['a'], "is for aardvark", values)
-
- def test_Delete(self):
- tabname = "test_Delete"
- self.tdb.CreateTable(tabname, ['x', 'y', 'z'])
-
- # prior to 2001-05-09 there was a bug where Delete() would
- # fail if it encountered any rows that did not have values in
- # every column.
- # Hunted and Squashed by <Donwulff> (Jukka Santala - donwulff@nic.fi)
- self.tdb.Insert(tabname, {'x': 'X1', 'y':'Y1'})
- self.tdb.Insert(tabname, {'x': 'X2', 'y':'Y2', 'z': 'Z2'})
-
- self.tdb.Delete(tabname, conditions={'x': dbtables.PrefixCond('X')})
- values = self.tdb.Select(tabname, ['y'],
- conditions={'x': dbtables.PrefixCond('X')})
- self.assertEqual(len(values), 0)
-
- def test_Modify(self):
- tabname = "test_Modify"
- self.tdb.CreateTable(tabname, ['Name', 'Type', 'Access'])
-
- self.tdb.Insert(tabname, {'Name': 'Index to MP3 files.doc',
- 'Type': 'Word', 'Access': '8'})
- self.tdb.Insert(tabname, {'Name': 'Nifty.MP3', 'Access': '1'})
- self.tdb.Insert(tabname, {'Type': 'Unknown', 'Access': '0'})
-
- def set_type(type):
- if type is None:
- return 'MP3'
- return type
-
- def increment_access(count):
- return str(int(count)+1)
-
- def remove_value(value):
- return None
-
- self.tdb.Modify(tabname,
- conditions={'Access': dbtables.ExactCond('0')},
- mappings={'Access': remove_value})
- self.tdb.Modify(tabname,
- conditions={'Name': dbtables.LikeCond('%MP3%')},
- mappings={'Type': set_type})
- self.tdb.Modify(tabname,
- conditions={'Name': dbtables.LikeCond('%')},
- mappings={'Access': increment_access})
-
- try:
- self.tdb.Modify(tabname,
- conditions={'Name': dbtables.LikeCond('%')},
- mappings={'Access': 'What is your quest?'})
- except TypeError:
- # success, the string value in mappings isn't callable
- pass
- else:
- raise RuntimeError, "why was TypeError not raised for bad callable?"
-
- # Delete key in select conditions
- values = self.tdb.Select(
- tabname, None,
- conditions={'Type': dbtables.ExactCond('Unknown')})
- self.assertEqual(len(values), 1, values)
- self.assertEqual(values[0]['Name'], None, values)
- self.assertEqual(values[0]['Access'], None, values)
-
- # Modify value by select conditions
- values = self.tdb.Select(
- tabname, None,
- conditions={'Name': dbtables.ExactCond('Nifty.MP3')})
- self.assertEqual(len(values), 1, values)
- self.assertEqual(values[0]['Type'], "MP3", values)
- self.assertEqual(values[0]['Access'], "2", values)
-
- # Make sure change applied only to select conditions
- values = self.tdb.Select(
- tabname, None, conditions={'Name': dbtables.LikeCond('%doc%')})
- self.assertEqual(len(values), 1, values)
- self.assertEqual(values[0]['Type'], "Word", values)
- self.assertEqual(values[0]['Access'], "9", values)
-
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TableDBTestCase))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_distributed_transactions.py b/Lib/bsddb/test/test_distributed_transactions.py
deleted file mode 100644
index 1711fc59667..00000000000
--- a/Lib/bsddb/test/test_distributed_transactions.py
+++ /dev/null
@@ -1,163 +0,0 @@
-"""TestCases for distributed transactions.
-"""
-
-import os
-import unittest
-
-from test_all import db, test_support, get_new_environment_path, \
- get_new_database_path
-
-try :
- a=set()
-except : # Python 2.3
- from sets import Set as set
-else :
- del a
-
-from test_all import verbose
-
-#----------------------------------------------------------------------
-
-class DBTxn_distributed(unittest.TestCase):
- num_txns=1234
- nosync=True
- must_open_db=False
- def _create_env(self, must_open_db) :
- self.dbenv = db.DBEnv()
- self.dbenv.set_tx_max(self.num_txns)
- self.dbenv.set_lk_max_lockers(self.num_txns*2)
- self.dbenv.set_lk_max_locks(self.num_txns*2)
- self.dbenv.set_lk_max_objects(self.num_txns*2)
- if self.nosync :
- self.dbenv.set_flags(db.DB_TXN_NOSYNC,True)
- self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_THREAD |
- db.DB_RECOVER |
- db.DB_INIT_TXN | db.DB_INIT_LOG | db.DB_INIT_MPOOL |
- db.DB_INIT_LOCK, 0666)
- self.db = db.DB(self.dbenv)
- self.db.set_re_len(db.DB_GID_SIZE)
- if must_open_db :
- if db.version() >= (4,2) :
- txn=self.dbenv.txn_begin()
- self.db.open(self.filename,
- db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666,
- txn=txn)
- txn.commit()
- else :
- self.db.open(self.filename,
- db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- def setUp(self) :
- self.homeDir = get_new_environment_path()
- self.filename = "test"
- return self._create_env(must_open_db=True)
-
- def _destroy_env(self):
- if self.nosync or (db.version()[:2] == (4,6)): # Known bug
- self.dbenv.log_flush()
- self.db.close()
- self.dbenv.close()
-
- def tearDown(self):
- self._destroy_env()
- test_support.rmtree(self.homeDir)
-
- def _recreate_env(self,must_open_db) :
- self._destroy_env()
- self._create_env(must_open_db)
-
- def test01_distributed_transactions(self) :
- txns=set()
- adapt = lambda x : x
- import sys
- if sys.version_info[0] >= 3 :
- adapt = lambda x : bytes(x, "ascii")
- # Create transactions, "prepare" them, and
- # let them be garbage collected.
- for i in xrange(self.num_txns) :
- txn = self.dbenv.txn_begin()
- gid = "%%%dd" %db.DB_GID_SIZE
- gid = adapt(gid %i)
- self.db.put(i, gid, txn=txn, flags=db.DB_APPEND)
- txns.add(gid)
- txn.prepare(gid)
- del txn
-
- self._recreate_env(self.must_open_db)
-
- # Get "to be recovered" transactions but
- # let them be garbage collected.
- recovered_txns=self.dbenv.txn_recover()
- self.assertEqual(self.num_txns,len(recovered_txns))
- for gid,txn in recovered_txns :
- self.assertTrue(gid in txns)
- del txn
- del recovered_txns
-
- self._recreate_env(self.must_open_db)
-
- # Get "to be recovered" transactions. Commit, abort and
- # discard them.
- recovered_txns=self.dbenv.txn_recover()
- self.assertEqual(self.num_txns,len(recovered_txns))
- discard_txns=set()
- committed_txns=set()
- state=0
- for gid,txn in recovered_txns :
- if state==0 or state==1:
- committed_txns.add(gid)
- txn.commit()
- elif state==2 :
- txn.abort()
- elif state==3 :
- txn.discard()
- discard_txns.add(gid)
- state=-1
- state+=1
- del txn
- del recovered_txns
-
- self._recreate_env(self.must_open_db)
-
- # Verify the discarded transactions are still
- # around, and dispose them.
- recovered_txns=self.dbenv.txn_recover()
- self.assertEqual(len(discard_txns),len(recovered_txns))
- for gid,txn in recovered_txns :
- txn.abort()
- del txn
- del recovered_txns
-
- self._recreate_env(must_open_db=True)
-
- # Be sure there are not pending transactions.
- # Check also database size.
- recovered_txns=self.dbenv.txn_recover()
- self.assertTrue(len(recovered_txns)==0)
- self.assertEqual(len(committed_txns),self.db.stat()["nkeys"])
-
-class DBTxn_distributedSYNC(DBTxn_distributed):
- nosync=False
-
-class DBTxn_distributed_must_open_db(DBTxn_distributed):
- must_open_db=True
-
-class DBTxn_distributedSYNC_must_open_db(DBTxn_distributed):
- nosync=False
- must_open_db=True
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
- if db.version() >= (4,5) :
- suite.addTest(unittest.makeSuite(DBTxn_distributed))
- suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC))
- if db.version() >= (4,6) :
- suite.addTest(unittest.makeSuite(DBTxn_distributed_must_open_db))
- suite.addTest(unittest.makeSuite(DBTxn_distributedSYNC_must_open_db))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_early_close.py b/Lib/bsddb/test/test_early_close.py
deleted file mode 100644
index 86b86dcc1af..00000000000
--- a/Lib/bsddb/test/test_early_close.py
+++ /dev/null
@@ -1,216 +0,0 @@
-"""TestCases for checking that it does not segfault when a DBEnv object
-is closed before its DB objects.
-"""
-
-import os, sys
-import unittest
-
-from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path
-
-# We're going to get warnings in this module about trying to close the db when
-# its env is already closed. Let's just ignore those.
-try:
- import warnings
-except ImportError:
- pass
-else:
- warnings.filterwarnings('ignore',
- message='DB could not be closed in',
- category=RuntimeWarning)
-
-
-#----------------------------------------------------------------------
-
-class DBEnvClosedEarlyCrash(unittest.TestCase):
- def setUp(self):
- self.homeDir = get_new_environment_path()
- self.filename = "test"
-
- def tearDown(self):
- test_support.rmtree(self.homeDir)
-
- def test01_close_dbenv_before_db(self):
- dbenv = db.DBEnv()
- dbenv.open(self.homeDir,
- db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
-
- d = db.DB(dbenv)
- d2 = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- self.assertRaises(db.DBNoSuchFileError, d2.open,
- self.filename+"2", db.DB_BTREE, db.DB_THREAD, 0666)
-
- d.put("test","this is a test")
- self.assertEqual(d.get("test"), "this is a test", "put!=get")
- dbenv.close() # This "close" should close the child db handle also
- self.assertRaises(db.DBError, d.get, "test")
-
- def test02_close_dbenv_before_dbcursor(self):
- dbenv = db.DBEnv()
- dbenv.open(self.homeDir,
- db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
-
- d = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- d.put("test","this is a test")
- d.put("test2","another test")
- d.put("test3","another one")
- self.assertEqual(d.get("test"), "this is a test", "put!=get")
- c=d.cursor()
- c.first()
- c.next()
- d.close() # This "close" should close the child db handle also
- # db.close should close the child cursor
- self.assertRaises(db.DBError,c.next)
-
- d = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
- c=d.cursor()
- c.first()
- c.next()
- dbenv.close()
- # The "close" should close the child db handle also, with cursors
- self.assertRaises(db.DBError, c.next)
-
- def test03_close_db_before_dbcursor_without_env(self):
- import os.path
- path=os.path.join(self.homeDir,self.filename)
- d = db.DB()
- d.open(path, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- d.put("test","this is a test")
- d.put("test2","another test")
- d.put("test3","another one")
- self.assertEqual(d.get("test"), "this is a test", "put!=get")
- c=d.cursor()
- c.first()
- c.next()
- d.close()
- # The "close" should close the child db handle also
- self.assertRaises(db.DBError, c.next)
-
- def test04_close_massive(self):
- dbenv = db.DBEnv()
- dbenv.open(self.homeDir,
- db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
-
- dbs=[db.DB(dbenv) for i in xrange(16)]
- cursors=[]
- for i in dbs :
- i.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- dbs[10].put("test","this is a test")
- dbs[10].put("test2","another test")
- dbs[10].put("test3","another one")
- self.assertEqual(dbs[4].get("test"), "this is a test", "put!=get")
-
- for i in dbs :
- cursors.extend([i.cursor() for j in xrange(32)])
-
- for i in dbs[::3] :
- i.close()
- for i in cursors[::3] :
- i.close()
-
- # Check for missing exception in DB! (after DB close)
- self.assertRaises(db.DBError, dbs[9].get, "test")
-
- # Check for missing exception in DBCursor! (after DB close)
- self.assertRaises(db.DBError, cursors[101].first)
-
- cursors[80].first()
- cursors[80].next()
- dbenv.close() # This "close" should close the child db handle also
- # Check for missing exception! (after DBEnv close)
- self.assertRaises(db.DBError, cursors[80].next)
-
- def test05_close_dbenv_delete_db_success(self):
- dbenv = db.DBEnv()
- dbenv.open(self.homeDir,
- db.DB_INIT_CDB| db.DB_CREATE |db.DB_THREAD|db.DB_INIT_MPOOL,
- 0666)
-
- d = db.DB(dbenv)
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
-
- dbenv.close() # This "close" should close the child db handle also
-
- del d
- try:
- import gc
- except ImportError:
- gc = None
- if gc:
- # force d.__del__ [DB_dealloc] to be called
- gc.collect()
-
- def test06_close_txn_before_dup_cursor(self) :
- dbenv = db.DBEnv()
- dbenv.open(self.homeDir,db.DB_INIT_TXN | db.DB_INIT_MPOOL |
- db.DB_INIT_LOG | db.DB_CREATE)
- d = db.DB(dbenv)
- txn = dbenv.txn_begin()
- d.open(self.filename, dbtype = db.DB_HASH, flags = db.DB_CREATE,
- txn=txn)
- d.put("XXX", "yyy", txn=txn)
- txn.commit()
- txn = dbenv.txn_begin()
- c1 = d.cursor(txn)
- c2 = c1.dup()
- self.assertEqual(("XXX", "yyy"), c1.first())
-
- # Not interested in warnings about implicit close.
- import warnings
- if sys.version_info < (2, 6) :
- # Completely resetting the warning state is
- # problematic with python >=2.6 with -3 (py3k warning),
- # because some stdlib modules selectively ignores warnings.
- warnings.simplefilter("ignore")
- txn.commit()
- warnings.resetwarnings()
- else :
- # When we drop support for python 2.3 and 2.4
- # we could use: (in 2.5 we need a __future__ statement)
- #
- # with warnings.catch_warnings():
- # warnings.simplefilter("ignore")
- # txn.commit()
- #
- # We can not use "with" as is, because it would be invalid syntax
- # in python 2.3, 2.4 and (with no __future__) 2.5.
- # Here we simulate "with" following PEP 343 :
- w = warnings.catch_warnings()
- w.__enter__()
- try :
- warnings.simplefilter("ignore")
- txn.commit()
- finally :
- w.__exit__()
-
- self.assertRaises(db.DBCursorClosedError, c2.first)
-
- if db.version() > (4,3,0) :
- def test07_close_db_before_sequence(self):
- import os.path
- path=os.path.join(self.homeDir,self.filename)
- d = db.DB()
- d.open(path, db.DB_BTREE, db.DB_CREATE | db.DB_THREAD, 0666)
- dbs=db.DBSequence(d)
- d.close() # This "close" should close the child DBSequence also
- dbs.close() # If not closed, core dump (in Berkeley DB 4.6.*)
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(DBEnvClosedEarlyCrash))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_fileid.py b/Lib/bsddb/test/test_fileid.py
deleted file mode 100644
index 095ec83d425..00000000000
--- a/Lib/bsddb/test/test_fileid.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""TestCase for reseting File ID.
-"""
-
-import os
-import shutil
-import unittest
-
-from test_all import db, test_support, get_new_environment_path, get_new_database_path
-
-class FileidResetTestCase(unittest.TestCase):
- def setUp(self):
- self.db_path_1 = get_new_database_path()
- self.db_path_2 = get_new_database_path()
- self.db_env_path = get_new_environment_path()
-
- def test_fileid_reset(self):
- # create DB 1
- self.db1 = db.DB()
- self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=(db.DB_CREATE|db.DB_EXCL))
- self.db1.put('spam', 'eggs')
- self.db1.close()
-
- shutil.copy(self.db_path_1, self.db_path_2)
-
- self.db2 = db.DB()
- self.db2.open(self.db_path_2, dbtype=db.DB_HASH)
- self.db2.put('spam', 'spam')
- self.db2.close()
-
- self.db_env = db.DBEnv()
- self.db_env.open(self.db_env_path, db.DB_CREATE|db.DB_INIT_MPOOL)
-
- # use fileid_reset() here
- self.db_env.fileid_reset(self.db_path_2)
-
- self.db1 = db.DB(self.db_env)
- self.db1.open(self.db_path_1, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
- self.assertEqual(self.db1.get('spam'), 'eggs')
-
- self.db2 = db.DB(self.db_env)
- self.db2.open(self.db_path_2, dbtype=db.DB_HASH, flags=db.DB_RDONLY)
- self.assertEqual(self.db2.get('spam'), 'spam')
-
- self.db1.close()
- self.db2.close()
-
- self.db_env.close()
-
- def tearDown(self):
- test_support.unlink(self.db_path_1)
- test_support.unlink(self.db_path_2)
- test_support.rmtree(self.db_env_path)
-
-def test_suite():
- suite = unittest.TestSuite()
- if db.version() >= (4, 4):
- suite.addTest(unittest.makeSuite(FileidResetTestCase))
- return suite
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_get_none.py b/Lib/bsddb/test/test_get_none.py
deleted file mode 100644
index 8763b543ca1..00000000000
--- a/Lib/bsddb/test/test_get_none.py
+++ /dev/null
@@ -1,92 +0,0 @@
-"""
-TestCases for checking set_get_returns_none.
-"""
-
-import os, string
-import unittest
-
-from test_all import db, verbose, get_new_database_path
-
-
-#----------------------------------------------------------------------
-
-class GetReturnsNoneTestCase(unittest.TestCase):
- def setUp(self):
- self.filename = get_new_database_path()
-
- def tearDown(self):
- try:
- os.remove(self.filename)
- except os.error:
- pass
-
-
- def test01_get_returns_none(self):
- d = db.DB()
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
- d.set_get_returns_none(1)
-
- for x in string.letters:
- d.put(x, x * 40)
-
- data = d.get('bad key')
- self.assertEqual(data, None)
-
- data = d.get(string.letters[0])
- self.assertEqual(data, string.letters[0]*40)
-
- count = 0
- c = d.cursor()
- rec = c.first()
- while rec:
- count = count + 1
- rec = c.next()
-
- self.assertEqual(rec, None)
- self.assertEqual(count, len(string.letters))
-
- c.close()
- d.close()
-
-
- def test02_get_raises_exception(self):
- d = db.DB()
- d.open(self.filename, db.DB_BTREE, db.DB_CREATE)
- d.set_get_returns_none(0)
-
- for x in string.letters:
- d.put(x, x * 40)
-
- self.assertRaises(db.DBNotFoundError, d.get, 'bad key')
- self.assertRaises(KeyError, d.get, 'bad key')
-
- data = d.get(string.letters[0])
- self.assertEqual(data, string.letters[0]*40)
-
- count = 0
- exceptionHappened = 0
- c = d.cursor()
- rec = c.first()
- while rec:
- count = count + 1
- try:
- rec = c.next()
- except db.DBNotFoundError: # end of the records
- exceptionHappened = 1
- break
-
- self.assertNotEqual(rec, None)
- self.assertTrue(exceptionHappened)
- self.assertEqual(count, len(string.letters))
-
- c.close()
- d.close()
-
-#----------------------------------------------------------------------
-
-def test_suite():
- return unittest.makeSuite(GetReturnsNoneTestCase)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
deleted file mode 100644
index 1f0dfff8583..00000000000
--- a/Lib/bsddb/test/test_join.py
+++ /dev/null
@@ -1,99 +0,0 @@
-"""TestCases for using the DB.join and DBCursor.join_item methods.
-"""
-
-import os
-
-import unittest
-
-from test_all import db, dbshelve, test_support, verbose, \
- get_new_environment_path, get_new_database_path
-
-#----------------------------------------------------------------------
-
-ProductIndex = [
- ('apple', "Convenience Store"),
- ('blueberry', "Farmer's Market"),
- ('shotgun', "S-Mart"), # Aisle 12
- ('pear', "Farmer's Market"),
- ('chainsaw', "S-Mart"), # "Shop smart. Shop S-Mart!"
- ('strawberry', "Farmer's Market"),
-]
-
-ColorIndex = [
- ('blue', "blueberry"),
- ('red', "apple"),
- ('red', "chainsaw"),
- ('red', "strawberry"),
- ('yellow', "peach"),
- ('yellow', "pear"),
- ('black', "shotgun"),
-]
-
-class JoinTestCase(unittest.TestCase):
- keytype = ''
-
- def setUp(self):
- self.filename = self.__class__.__name__ + '.db'
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL | db.DB_INIT_LOCK )
-
- def tearDown(self):
- self.env.close()
- test_support.rmtree(self.homeDir)
-
- def test01_join(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_join..." % \
- self.__class__.__name__
-
- # create and populate primary index
- priDB = db.DB(self.env)
- priDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE)
- map(lambda t, priDB=priDB: priDB.put(*t), ProductIndex)
-
- # create and populate secondary index
- secDB = db.DB(self.env)
- secDB.set_flags(db.DB_DUP | db.DB_DUPSORT)
- secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
- map(lambda t, secDB=secDB: secDB.put(*t), ColorIndex)
-
- sCursor = None
- jCursor = None
- try:
- # lets look up all of the red Products
- sCursor = secDB.cursor()
- # Don't do the .set() in an assert, or you can get a bogus failure
- # when running python -O
- tmp = sCursor.set('red')
- self.assertTrue(tmp)
-
- # FIXME: jCursor doesn't properly hold a reference to its
- # cursors, if they are closed before jcursor is used it
- # can cause a crash.
- jCursor = priDB.join([sCursor])
-
- if jCursor.get(0) != ('apple', "Convenience Store"):
- self.fail("join cursor positioned wrong")
- if jCursor.join_item() != 'chainsaw':
- self.fail("DBCursor.join_item returned wrong item")
- if jCursor.get(0)[0] != 'strawberry':
- self.fail("join cursor returned wrong thing")
- if jCursor.get(0): # there were only three red items to return
- self.fail("join cursor returned too many items")
- finally:
- if jCursor:
- jCursor.close()
- if sCursor:
- sCursor.close()
- priDB.close()
- secDB.close()
-
-
-def test_suite():
- suite = unittest.TestSuite()
-
- suite.addTest(unittest.makeSuite(JoinTestCase))
-
- return suite
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py
deleted file mode 100644
index 25260fc44cc..00000000000
--- a/Lib/bsddb/test/test_lock.py
+++ /dev/null
@@ -1,191 +0,0 @@
-"""
-TestCases for testing the locking sub-system.
-"""
-
-import time
-
-import unittest
-from test_all import db, test_support, verbose, have_threads, \
- get_new_environment_path, get_new_database_path
-
-if have_threads :
- from threading import Thread
- import sys
- if sys.version_info[0] < 3 :
- from threading import currentThread
- else :
- from threading import current_thread as currentThread
-
-#----------------------------------------------------------------------
-
-class LockingTestCase(unittest.TestCase):
- import sys
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
-
- def setUp(self):
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_THREAD | db.DB_INIT_MPOOL |
- db.DB_INIT_LOCK | db.DB_CREATE)
-
-
- def tearDown(self):
- self.env.close()
- test_support.rmtree(self.homeDir)
-
-
- def test01_simple(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_simple..." % self.__class__.__name__
-
- anID = self.env.lock_id()
- if verbose:
- print "locker ID: %s" % anID
- lock = self.env.lock_get(anID, "some locked thing", db.DB_LOCK_WRITE)
- if verbose:
- print "Aquired lock: %s" % lock
- self.env.lock_put(lock)
- if verbose:
- print "Released lock: %s" % lock
- self.env.lock_id_free(anID)
-
-
- def test02_threaded(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_threaded..." % self.__class__.__name__
-
- threads = []
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_WRITE,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_READ,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_READ,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_WRITE,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_READ,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_READ,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_WRITE,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_WRITE,)))
- threads.append(Thread(target = self.theThread,
- args=(db.DB_LOCK_WRITE,)))
-
- for t in threads:
- import sys
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
- for t in threads:
- t.join()
-
- if db.version() >= (4, 2) :
- def test03_lock_timeout(self):
- self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
- self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 0)
- self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
- self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 0)
- self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
- self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 123456)
- self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
- self.assertEqual(self.env.get_timeout(db.DB_SET_TXN_TIMEOUT), 7890123)
-
- def test04_lock_timeout2(self):
- self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
- self.env.set_timeout(0, db.DB_SET_TXN_TIMEOUT)
- self.env.set_timeout(123456, db.DB_SET_LOCK_TIMEOUT)
- self.env.set_timeout(7890123, db.DB_SET_TXN_TIMEOUT)
-
- def deadlock_detection() :
- while not deadlock_detection.end :
- deadlock_detection.count = \
- self.env.lock_detect(db.DB_LOCK_EXPIRE)
- if deadlock_detection.count :
- while not deadlock_detection.end :
- pass
- break
- time.sleep(0.01)
-
- deadlock_detection.end=False
- deadlock_detection.count=0
- t=Thread(target=deadlock_detection)
- import sys
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
- self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT)
- anID = self.env.lock_id()
- anID2 = self.env.lock_id()
- self.assertNotEqual(anID, anID2)
- lock = self.env.lock_get(anID, "shared lock", db.DB_LOCK_WRITE)
- start_time=time.time()
- self.assertRaises(db.DBLockNotGrantedError,
- self.env.lock_get,anID2, "shared lock", db.DB_LOCK_READ)
- end_time=time.time()
- deadlock_detection.end=True
- # Floating point rounding
- self.assertTrue((end_time-start_time) >= 0.0999)
- self.env.lock_put(lock)
- t.join()
-
- self.env.lock_id_free(anID)
- self.env.lock_id_free(anID2)
-
- if db.version() >= (4,6):
- self.assertTrue(deadlock_detection.count>0)
-
- def theThread(self, lockType):
- import sys
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- if lockType == db.DB_LOCK_WRITE:
- lt = "write"
- else:
- lt = "read"
-
- anID = self.env.lock_id()
- if verbose:
- print "%s: locker ID: %s" % (name, anID)
-
- for i in xrange(1000) :
- lock = self.env.lock_get(anID, "some locked thing", lockType)
- if verbose:
- print "%s: Aquired %s lock: %s" % (name, lt, lock)
-
- self.env.lock_put(lock)
- if verbose:
- print "%s: Released %s lock: %s" % (name, lt, lock)
-
- self.env.lock_id_free(anID)
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
-
- if have_threads:
- suite.addTest(unittest.makeSuite(LockingTestCase))
- else:
- suite.addTest(unittest.makeSuite(LockingTestCase, 'test01'))
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py
deleted file mode 100644
index 8dda2968a68..00000000000
--- a/Lib/bsddb/test/test_misc.py
+++ /dev/null
@@ -1,149 +0,0 @@
-"""Miscellaneous bsddb module test cases
-"""
-
-import os, sys
-import unittest
-
-from test_all import db, dbshelve, hashopen, test_support, get_new_environment_path, get_new_database_path
-
-#----------------------------------------------------------------------
-
-class MiscTestCase(unittest.TestCase):
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr, msg=msg)
-
- def assertFalse(self, expr, msg=None):
- self.failIf(expr, msg=msg)
-
- def setUp(self):
- self.filename = get_new_database_path()
- self.homeDir = get_new_environment_path()
-
- def tearDown(self):
- test_support.unlink(self.filename)
- test_support.rmtree(self.homeDir)
-
- def test01_badpointer(self):
- dbs = dbshelve.open(self.filename)
- dbs.close()
- self.assertRaises(db.DBError, dbs.get, "foo")
-
- def test02_db_home(self):
- env = db.DBEnv()
- # check for crash fixed when db_home is used before open()
- self.assertTrue(env.db_home is None)
- env.open(self.homeDir, db.DB_CREATE)
- if sys.version_info[0] < 3 :
- self.assertEqual(self.homeDir, env.db_home)
- else :
- self.assertEqual(bytes(self.homeDir, "ascii"), env.db_home)
-
- def test03_repr_closed_db(self):
- db = hashopen(self.filename)
- db.close()
- rp = repr(db)
- self.assertEqual(rp, "{}")
-
- def test04_repr_db(self) :
- db = hashopen(self.filename)
- d = {}
- for i in xrange(100) :
- db[repr(i)] = repr(100*i)
- d[repr(i)] = repr(100*i)
- db.close()
- db = hashopen(self.filename)
- rp = repr(db)
- self.assertEqual(rp, repr(d))
- db.close()
-
- # http://sourceforge.net/tracker/index.php?func=detail&aid=1708868&group_id=13900&atid=313900
- #
- # See the bug report for details.
- #
- # The problem was that make_key_dbt() was not allocating a copy of
- # string keys but FREE_DBT() was always being told to free it when the
- # database was opened with DB_THREAD.
- def test05_double_free_make_key_dbt(self):
- try:
- db1 = db.DB()
- db1.open(self.filename, None, db.DB_BTREE,
- db.DB_CREATE | db.DB_THREAD)
-
- curs = db1.cursor()
- t = curs.get("/foo", db.DB_SET)
- # double free happened during exit from DBC_get
- finally:
- db1.close()
- test_support.unlink(self.filename)
-
- def test06_key_with_null_bytes(self):
- try:
- db1 = db.DB()
- db1.open(self.filename, None, db.DB_HASH, db.DB_CREATE)
- db1['a'] = 'eh?'
- db1['a\x00'] = 'eh zed.'
- db1['a\x00a'] = 'eh zed eh?'
- db1['aaa'] = 'eh eh eh!'
- keys = db1.keys()
- keys.sort()
- self.assertEqual(['a', 'a\x00', 'a\x00a', 'aaa'], keys)
- self.assertEqual(db1['a'], 'eh?')
- self.assertEqual(db1['a\x00'], 'eh zed.')
- self.assertEqual(db1['a\x00a'], 'eh zed eh?')
- self.assertEqual(db1['aaa'], 'eh eh eh!')
- finally:
- db1.close()
- test_support.unlink(self.filename)
-
- def test07_DB_set_flags_persists(self):
- if db.version() < (4,2):
- # The get_flags API required for this to work is only available
- # in Berkeley DB >= 4.2
- return
- try:
- db1 = db.DB()
- db1.set_flags(db.DB_DUPSORT)
- db1.open(self.filename, db.DB_HASH, db.DB_CREATE)
- db1['a'] = 'eh'
- db1['a'] = 'A'
- self.assertEqual([('a', 'A')], db1.items())
- db1.put('a', 'Aa')
- self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
- db1.close()
- db1 = db.DB()
- # no set_flags call, we're testing that it reads and obeys
- # the flags on open.
- db1.open(self.filename, db.DB_HASH)
- self.assertEqual([('a', 'A'), ('a', 'Aa')], db1.items())
- # if it read the flags right this will replace all values
- # for key 'a' instead of adding a new one. (as a dict should)
- db1['a'] = 'new A'
- self.assertEqual([('a', 'new A')], db1.items())
- finally:
- db1.close()
- test_support.unlink(self.filename)
-
-
- def test08_ExceptionTypes(self) :
- self.assertTrue(issubclass(db.DBError, Exception))
- for i, j in db.__dict__.items() :
- if i.startswith("DB") and i.endswith("Error") :
- self.assertTrue(issubclass(j, db.DBError), msg=i)
- if i not in ("DBKeyEmptyError", "DBNotFoundError") :
- self.assertFalse(issubclass(j, KeyError), msg=i)
-
- # This two exceptions have two bases
- self.assertTrue(issubclass(db.DBKeyEmptyError, KeyError))
- self.assertTrue(issubclass(db.DBNotFoundError, KeyError))
-
-
-#----------------------------------------------------------------------
-
-
-def test_suite():
- return unittest.makeSuite(MiscTestCase)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_pickle.py b/Lib/bsddb/test/test_pickle.py
deleted file mode 100644
index 6a8478d5094..00000000000
--- a/Lib/bsddb/test/test_pickle.py
+++ /dev/null
@@ -1,68 +0,0 @@
-
-import os
-import pickle
-import sys
-
-if sys.version_info[0] < 3 :
- try:
- import cPickle
- except ImportError:
- cPickle = None
-else :
- cPickle = None
-
-import unittest
-
-from test_all import db, test_support, get_new_environment_path, get_new_database_path
-
-#----------------------------------------------------------------------
-
-class pickleTestCase(unittest.TestCase):
- """Verify that DBError can be pickled and unpickled"""
- db_name = 'test-dbobj.db'
-
- def setUp(self):
- self.homeDir = get_new_environment_path()
-
- def tearDown(self):
- if hasattr(self, 'db'):
- del self.db
- if hasattr(self, 'env'):
- del self.env
- test_support.rmtree(self.homeDir)
-
- def _base_test_pickle_DBError(self, pickle):
- self.env = db.DBEnv()
- self.env.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL)
- self.db = db.DB(self.env)
- self.db.open(self.db_name, db.DB_HASH, db.DB_CREATE)
- self.db.put('spam', 'eggs')
- self.assertEqual(self.db['spam'], 'eggs')
- try:
- self.db.put('spam', 'ham', flags=db.DB_NOOVERWRITE)
- except db.DBError, egg:
- pickledEgg = pickle.dumps(egg)
- #print repr(pickledEgg)
- rottenEgg = pickle.loads(pickledEgg)
- if rottenEgg.args != egg.args or type(rottenEgg) != type(egg):
- raise Exception, (rottenEgg, '!=', egg)
- else:
- raise Exception, "where's my DBError exception?!?"
-
- self.db.close()
- self.env.close()
-
- def test01_pickle_DBError(self):
- self._base_test_pickle_DBError(pickle=pickle)
-
- if cPickle:
- def test02_cPickle_DBError(self):
- self._base_test_pickle_DBError(pickle=cPickle)
-
-#----------------------------------------------------------------------
-
-def test_suite():
- return unittest.makeSuite(pickleTestCase)
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_queue.py b/Lib/bsddb/test/test_queue.py
deleted file mode 100644
index 251a8cfdcc8..00000000000
--- a/Lib/bsddb/test/test_queue.py
+++ /dev/null
@@ -1,168 +0,0 @@
-"""
-TestCases for exercising a Queue DB.
-"""
-
-import os, string
-from pprint import pprint
-import unittest
-
-from test_all import db, verbose, get_new_database_path
-
-#----------------------------------------------------------------------
-
-class SimpleQueueTestCase(unittest.TestCase):
- def setUp(self):
- self.filename = get_new_database_path()
-
- def tearDown(self):
- try:
- os.remove(self.filename)
- except os.error:
- pass
-
-
- def test01_basic(self):
- # Basic Queue tests using the deprecated DBCursor.consume method.
-
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_basic..." % self.__class__.__name__
-
- d = db.DB()
- d.set_re_len(40) # Queues must be fixed length
- d.open(self.filename, db.DB_QUEUE, db.DB_CREATE)
-
- if verbose:
- print "before appends" + '-' * 30
- pprint(d.stat())
-
- for x in string.letters:
- d.append(x * 40)
-
- self.assertEqual(len(d), len(string.letters))
-
- d.put(100, "some more data")
- d.put(101, "and some more ")
- d.put(75, "out of order")
- d.put(1, "replacement data")
-
- self.assertEqual(len(d), len(string.letters)+3)
-
- if verbose:
- print "before close" + '-' * 30
- pprint(d.stat())
-
- d.close()
- del d
- d = db.DB()
- d.open(self.filename)
-
- if verbose:
- print "after open" + '-' * 30
- pprint(d.stat())
-
- # Test "txn" as a positional parameter
- d.append("one more", None)
- # Test "txn" as a keyword parameter
- d.append("another one", txn=None)
-
- c = d.cursor()
-
- if verbose:
- print "after append" + '-' * 30
- pprint(d.stat())
-
- rec = c.consume()
- while rec:
- if verbose:
- print rec
- rec = c.consume()
- c.close()
-
- if verbose:
- print "after consume loop" + '-' * 30
- pprint(d.stat())
-
- self.assertEqual(len(d), 0, \
- "if you see this message then you need to rebuild " \
- "Berkeley DB 3.1.17 with the patch in patches/qam_stat.diff")
-
- d.close()
-
-
-
- def test02_basicPost32(self):
- # Basic Queue tests using the new DB.consume method in DB 3.2+
- # (No cursor needed)
-
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_basicPost32..." % self.__class__.__name__
-
- if db.version() < (3, 2, 0):
- if verbose:
- print "Test not run, DB not new enough..."
- return
-
- d = db.DB()
- d.set_re_len(40) # Queues must be fixed length
- d.open(self.filename, db.DB_QUEUE, db.DB_CREATE)
-
- if verbose:
- print "before appends" + '-' * 30
- pprint(d.stat())
-
- for x in string.letters:
- d.append(x * 40)
-
- self.assertEqual(len(d), len(string.letters))
-
- d.put(100, "some more data")
- d.put(101, "and some more ")
- d.put(75, "out of order")
- d.put(1, "replacement data")
-
- self.assertEqual(len(d), len(string.letters)+3)
-
- if verbose:
- print "before close" + '-' * 30
- pprint(d.stat())
-
- d.close()
- del d
- d = db.DB()
- d.open(self.filename)
- #d.set_get_returns_none(true)
-
- if verbose:
- print "after open" + '-' * 30
- pprint(d.stat())
-
- d.append("one more")
-
- if verbose:
- print "after append" + '-' * 30
- pprint(d.stat())
-
- rec = d.consume()
- while rec:
- if verbose:
- print rec
- rec = d.consume()
-
- if verbose:
- print "after consume loop" + '-' * 30
- pprint(d.stat())
-
- d.close()
-
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
- return unittest.makeSuite(SimpleQueueTestCase)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
deleted file mode 100644
index 3191fdce742..00000000000
--- a/Lib/bsddb/test/test_recno.py
+++ /dev/null
@@ -1,310 +0,0 @@
-"""TestCases for exercising a Recno DB.
-"""
-
-import os, sys
-import errno
-from pprint import pprint
-import unittest
-
-from test_all import db, test_support, verbose, get_new_environment_path, get_new_database_path
-
-letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
-
-
-#----------------------------------------------------------------------
-
-class SimpleRecnoTestCase(unittest.TestCase):
- if sys.version_info < (2, 4) :
- def assertFalse(self, expr, msg=None) :
- return self.failIf(expr,msg=msg)
- def assertTrue(self, expr, msg=None) :
- return self.assertTrue(expr, msg=msg)
-
- if (sys.version_info < (2, 7)) or ((sys.version_info >= (3, 0)) and
- (sys.version_info < (3, 2))) :
- def assertIsInstance(self, obj, datatype, msg=None) :
- return self.assertEqual(type(obj), datatype, msg=msg)
- def assertGreaterEqual(self, a, b, msg=None) :
- return self.assertTrue(a>=b, msg=msg)
-
-
- def setUp(self):
- self.filename = get_new_database_path()
- self.homeDir = None
-
- def tearDown(self):
- test_support.unlink(self.filename)
- if self.homeDir:
- test_support.rmtree(self.homeDir)
-
- def test01_basic(self):
- d = db.DB()
-
- get_returns_none = d.set_get_returns_none(2)
- d.set_get_returns_none(get_returns_none)
-
- d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
-
- for x in letters:
- recno = d.append(x * 60)
- self.assertIsInstance(recno, int)
- self.assertGreaterEqual(recno, 1)
- if verbose:
- print recno,
-
- if verbose: print
-
- stat = d.stat()
- if verbose:
- pprint(stat)
-
- for recno in range(1, len(d)+1):
- data = d[recno]
- if verbose:
- print data
-
- self.assertIsInstance(data, str)
- self.assertEqual(data, d.get(recno))
-
- try:
- data = d[0] # This should raise a KeyError!?!?!
- except db.DBInvalidArgError, val:
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.EINVAL)
- else :
- self.assertEqual(val.args[0], db.EINVAL)
- if verbose: print val
- else:
- self.fail("expected exception")
-
- # test that has_key raises DB exceptions (fixed in pybsddb 4.3.2)
- try:
- d.has_key(0)
- except db.DBError, val:
- pass
- else:
- self.fail("has_key did not raise a proper exception")
-
- try:
- data = d[100]
- except KeyError:
- pass
- else:
- self.fail("expected exception")
-
- try:
- data = d.get(100)
- except db.DBNotFoundError, val:
- if get_returns_none:
- self.fail("unexpected exception")
- else:
- self.assertEqual(data, None)
-
- keys = d.keys()
- if verbose:
- print keys
- self.assertIsInstance(keys, list)
- self.assertIsInstance(keys[0], int)
- self.assertEqual(len(keys), len(d))
-
- items = d.items()
- if verbose:
- pprint(items)
- self.assertIsInstance(items, list)
- self.assertIsInstance(items[0], tuple)
- self.assertEqual(len(items[0]), 2)
- self.assertIsInstance(items[0][0], int)
- self.assertIsInstance(items[0][1], str)
- self.assertEqual(len(items), len(d))
-
- self.assertTrue(d.has_key(25))
-
- del d[25]
- self.assertFalse(d.has_key(25))
-
- d.delete(13)
- self.assertFalse(d.has_key(13))
-
- data = d.get_both(26, "z" * 60)
- self.assertEqual(data, "z" * 60, 'was %r' % data)
- if verbose:
- print data
-
- fd = d.fd()
- if verbose:
- print fd
-
- c = d.cursor()
- rec = c.first()
- while rec:
- if verbose:
- print rec
- rec = c.next()
-
- c.set(50)
- rec = c.current()
- if verbose:
- print rec
-
- c.put(-1, "a replacement record", db.DB_CURRENT)
-
- c.set(50)
- rec = c.current()
- self.assertEqual(rec, (50, "a replacement record"))
- if verbose:
- print rec
-
- rec = c.set_range(30)
- if verbose:
- print rec
-
- # test that non-existent key lookups work (and that
- # DBC_set_range doesn't have a memleak under valgrind)
- rec = c.set_range(999999)
- self.assertEqual(rec, None)
- if verbose:
- print rec
-
- c.close()
- d.close()
-
- d = db.DB()
- d.open(self.filename)
- c = d.cursor()
-
- # put a record beyond the consecutive end of the recno's
- d[100] = "way out there"
- self.assertEqual(d[100], "way out there")
-
- try:
- data = d[99]
- except KeyError:
- pass
- else:
- self.fail("expected exception")
-
- try:
- d.get(99)
- except db.DBKeyEmptyError, val:
- if get_returns_none:
- self.fail("unexpected DBKeyEmptyError exception")
- else:
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.DB_KEYEMPTY)
- else :
- self.assertEqual(val.args[0], db.DB_KEYEMPTY)
- if verbose: print val
- else:
- if not get_returns_none:
- self.fail("expected exception")
-
- rec = c.set(40)
- while rec:
- if verbose:
- print rec
- rec = c.next()
-
- c.close()
- d.close()
-
- def test02_WithSource(self):
- """
- A Recno file that is given a "backing source file" is essentially a
- simple ASCII file. Normally each record is delimited by \n and so is
- just a line in the file, but you can set a different record delimiter
- if needed.
- """
- homeDir = get_new_environment_path()
- self.homeDir = homeDir
- source = os.path.join(homeDir, 'test_recno.txt')
- if not os.path.isdir(homeDir):
- os.mkdir(homeDir)
- f = open(source, 'w') # create the file
- f.close()
-
- d = db.DB()
- # This is the default value, just checking if both int
- d.set_re_delim(0x0A)
- d.set_re_delim('\n') # and char can be used...
- d.set_re_source(source)
- d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
-
- data = "The quick brown fox jumped over the lazy dog".split()
- for datum in data:
- d.append(datum)
- d.sync()
- d.close()
-
- # get the text from the backing source
- text = open(source, 'r').read()
- text = text.strip()
- if verbose:
- print text
- print data
- print text.split('\n')
-
- self.assertEqual(text.split('\n'), data)
-
- # open as a DB again
- d = db.DB()
- d.set_re_source(source)
- d.open(self.filename, db.DB_RECNO)
-
- d[3] = 'reddish-brown'
- d[8] = 'comatose'
-
- d.sync()
- d.close()
-
- text = open(source, 'r').read()
- text = text.strip()
- if verbose:
- print text
- print text.split('\n')
-
- self.assertEqual(text.split('\n'),
- "The quick reddish-brown fox jumped over the comatose dog".split())
-
- def test03_FixedLength(self):
- d = db.DB()
- d.set_re_len(40) # fixed length records, 40 bytes long
- d.set_re_pad('-') # sets the pad character...
- d.set_re_pad(45) # ...test both int and char
- d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
-
- for x in letters:
- d.append(x * 35) # These will be padded
-
- d.append('.' * 40) # this one will be exact
-
- try: # this one will fail
- d.append('bad' * 20)
- except db.DBInvalidArgError, val:
- if sys.version_info < (2, 6) :
- self.assertEqual(val[0], db.EINVAL)
- else :
- self.assertEqual(val.args[0], db.EINVAL)
- if verbose: print val
- else:
- self.fail("expected exception")
-
- c = d.cursor()
- rec = c.first()
- while rec:
- if verbose:
- print rec
- rec = c.next()
-
- c.close()
- d.close()
-
-
-#----------------------------------------------------------------------
-
-
-def test_suite():
- return unittest.makeSuite(SimpleRecnoTestCase)
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_replication.py b/Lib/bsddb/test/test_replication.py
deleted file mode 100644
index f3e974fd9d0..00000000000
--- a/Lib/bsddb/test/test_replication.py
+++ /dev/null
@@ -1,495 +0,0 @@
-"""TestCases for distributed transactions.
-"""
-
-import os
-import time
-import unittest
-
-from test_all import db, test_support, have_threads, verbose, \
- get_new_environment_path, get_new_database_path
-
-
-#----------------------------------------------------------------------
-
-class DBReplication(unittest.TestCase) :
- import sys
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def setUp(self) :
- self.homeDirMaster = get_new_environment_path()
- self.homeDirClient = get_new_environment_path()
-
- self.dbenvMaster = db.DBEnv()
- self.dbenvClient = db.DBEnv()
-
- # Must use "DB_THREAD" because the Replication Manager will
- # be executed in other threads but will use the same environment.
- # http://forums.oracle.com/forums/thread.jspa?threadID=645788&tstart=0
- self.dbenvMaster.open(self.homeDirMaster, db.DB_CREATE | db.DB_INIT_TXN
- | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
- db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666)
- self.dbenvClient.open(self.homeDirClient, db.DB_CREATE | db.DB_INIT_TXN
- | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK |
- db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666)
-
- self.confirmed_master=self.client_startupdone=False
- def confirmed_master(a,b,c) :
- if b==db.DB_EVENT_REP_MASTER :
- self.confirmed_master=True
-
- def client_startupdone(a,b,c) :
- if b==db.DB_EVENT_REP_STARTUPDONE :
- self.client_startupdone=True
-
- self.dbenvMaster.set_event_notify(confirmed_master)
- self.dbenvClient.set_event_notify(client_startupdone)
-
- #self.dbenvMaster.set_verbose(db.DB_VERB_REPLICATION, True)
- #self.dbenvMaster.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
- #self.dbenvClient.set_verbose(db.DB_VERB_REPLICATION, True)
- #self.dbenvClient.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
-
- self.dbMaster = self.dbClient = None
-
-
- def tearDown(self):
- if self.dbClient :
- self.dbClient.close()
- if self.dbMaster :
- self.dbMaster.close()
-
- # Here we assign dummy event handlers to allow GC of the test object.
- # Since the dummy handler doesn't use any outer scope variable, it
- # doesn't keep any reference to the test object.
- def dummy(*args) :
- pass
- self.dbenvMaster.set_event_notify(dummy)
- self.dbenvClient.set_event_notify(dummy)
-
- self.dbenvClient.close()
- self.dbenvMaster.close()
- test_support.rmtree(self.homeDirClient)
- test_support.rmtree(self.homeDirMaster)
-
-class DBReplicationManager(DBReplication) :
- def test01_basic_replication(self) :
- master_port = test_support.find_unused_port()
- self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port)
- client_port = test_support.find_unused_port()
- self.dbenvClient.repmgr_set_local_site("127.0.0.1", client_port)
- self.dbenvMaster.repmgr_add_remote_site("127.0.0.1", client_port)
- self.dbenvClient.repmgr_add_remote_site("127.0.0.1", master_port)
- self.dbenvMaster.rep_set_nsites(2)
- self.dbenvClient.rep_set_nsites(2)
- self.dbenvMaster.rep_set_priority(10)
- self.dbenvClient.rep_set_priority(0)
-
- self.dbenvMaster.rep_set_timeout(db.DB_REP_CONNECTION_RETRY,100123)
- self.dbenvClient.rep_set_timeout(db.DB_REP_CONNECTION_RETRY,100321)
- self.assertEqual(self.dbenvMaster.rep_get_timeout(
- db.DB_REP_CONNECTION_RETRY), 100123)
- self.assertEqual(self.dbenvClient.rep_get_timeout(
- db.DB_REP_CONNECTION_RETRY), 100321)
-
- self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 100234)
- self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 100432)
- self.assertEqual(self.dbenvMaster.rep_get_timeout(
- db.DB_REP_ELECTION_TIMEOUT), 100234)
- self.assertEqual(self.dbenvClient.rep_get_timeout(
- db.DB_REP_ELECTION_TIMEOUT), 100432)
-
- self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_RETRY, 100345)
- self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_RETRY, 100543)
- self.assertEqual(self.dbenvMaster.rep_get_timeout(
- db.DB_REP_ELECTION_RETRY), 100345)
- self.assertEqual(self.dbenvClient.rep_get_timeout(
- db.DB_REP_ELECTION_RETRY), 100543)
-
- self.dbenvMaster.repmgr_set_ack_policy(db.DB_REPMGR_ACKS_ALL)
- self.dbenvClient.repmgr_set_ack_policy(db.DB_REPMGR_ACKS_ALL)
-
- self.dbenvMaster.repmgr_start(1, db.DB_REP_MASTER);
- self.dbenvClient.repmgr_start(1, db.DB_REP_CLIENT);
-
- self.assertEqual(self.dbenvMaster.rep_get_nsites(),2)
- self.assertEqual(self.dbenvClient.rep_get_nsites(),2)
- self.assertEqual(self.dbenvMaster.rep_get_priority(),10)
- self.assertEqual(self.dbenvClient.rep_get_priority(),0)
- self.assertEqual(self.dbenvMaster.repmgr_get_ack_policy(),
- db.DB_REPMGR_ACKS_ALL)
- self.assertEqual(self.dbenvClient.repmgr_get_ack_policy(),
- db.DB_REPMGR_ACKS_ALL)
-
- # The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
- # is not generated if the master has no new transactions.
- # This is solved in BDB 4.6 (#15542).
- import time
- timeout = time.time()+60
- while (time.time()<timeout) and not (self.confirmed_master and self.client_startupdone) :
- time.sleep(0.02)
- # self.client_startupdone does not always get set to True within
- # the timeout. On windows this may be a deep issue, on other
- # platforms it is likely just a timing issue, especially on slow
- # virthost buildbots (see issue 3892 for more). Even though
- # the timeout triggers, the rest of this test method usually passes
- # (but not all of it always, see below). So we just note the
- # timeout on stderr and keep soldering on.
- if time.time()>timeout:
- import sys
- print >> sys.stderr, ("XXX: timeout happened before"
- "startup was confirmed - see issue 3892")
- startup_timeout = True
-
- d = self.dbenvMaster.repmgr_site_list()
- self.assertEqual(len(d), 1)
- self.assertEqual(d[0][0], "127.0.0.1")
- self.assertEqual(d[0][1], client_port)
- self.assertTrue((d[0][2]==db.DB_REPMGR_CONNECTED) or \
- (d[0][2]==db.DB_REPMGR_DISCONNECTED))
-
- d = self.dbenvClient.repmgr_site_list()
- self.assertEqual(len(d), 1)
- self.assertEqual(d[0][0], "127.0.0.1")
- self.assertEqual(d[0][1], master_port)
- self.assertTrue((d[0][2]==db.DB_REPMGR_CONNECTED) or \
- (d[0][2]==db.DB_REPMGR_DISCONNECTED))
-
- if db.version() >= (4,6) :
- d = self.dbenvMaster.repmgr_stat(flags=db.DB_STAT_CLEAR);
- self.assertTrue("msgs_queued" in d)
-
- self.dbMaster=db.DB(self.dbenvMaster)
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.open("test", db.DB_HASH, db.DB_CREATE, 0666, txn=txn)
- txn.commit()
-
- import time,os.path
- timeout=time.time()+10
- while (time.time()<timeout) and \
- not (os.path.exists(os.path.join(self.homeDirClient,"test"))) :
- time.sleep(0.01)
-
- self.dbClient=db.DB(self.dbenvClient)
- while True :
- txn=self.dbenvClient.txn_begin()
- try :
- self.dbClient.open("test", db.DB_HASH, flags=db.DB_RDONLY,
- mode=0666, txn=txn)
- except db.DBRepHandleDeadError :
- txn.abort()
- self.dbClient.close()
- self.dbClient=db.DB(self.dbenvClient)
- continue
-
- txn.commit()
- break
-
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.put("ABC", "123", txn=txn)
- txn.commit()
- import time
- timeout=time.time()+10
- v=None
- while (time.time()<timeout) and (v is None) :
- txn=self.dbenvClient.txn_begin()
- v=self.dbClient.get("ABC", txn=txn)
- txn.commit()
- if v is None :
- time.sleep(0.02)
- # If startup did not happen before the timeout above, then this test
- # sometimes fails. This happens randomly, which causes buildbot
- # instability, but all the other bsddb tests pass. Since bsddb3 in the
- # stdlib is currently not getting active maintenance, and is gone in
- # py3k, we just skip the end of the test in that case.
- if time.time()>=timeout and startup_timeout:
- self.skipTest("replication test skipped due to random failure, "
- "see issue 3892")
- self.assertTrue(time.time()<timeout)
- self.assertEqual("123", v)
-
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.delete("ABC", txn=txn)
- txn.commit()
- timeout=time.time()+10
- while (time.time()<timeout) and (v is not None) :
- txn=self.dbenvClient.txn_begin()
- v=self.dbClient.get("ABC", txn=txn)
- txn.commit()
- if v is None :
- time.sleep(0.02)
- self.assertTrue(time.time()<timeout)
- self.assertEqual(None, v)
-
-class DBBaseReplication(DBReplication) :
- def setUp(self) :
- DBReplication.setUp(self)
- def confirmed_master(a,b,c) :
- if (b == db.DB_EVENT_REP_MASTER) or (b == db.DB_EVENT_REP_ELECTED) :
- self.confirmed_master = True
-
- def client_startupdone(a,b,c) :
- if b == db.DB_EVENT_REP_STARTUPDONE :
- self.client_startupdone = True
-
- self.dbenvMaster.set_event_notify(confirmed_master)
- self.dbenvClient.set_event_notify(client_startupdone)
-
- import Queue
- self.m2c = Queue.Queue()
- self.c2m = Queue.Queue()
-
- # There are only two nodes, so we don't need to
- # do any routing decision
- def m2c(dbenv, control, rec, lsnp, envid, flags) :
- self.m2c.put((control, rec))
-
- def c2m(dbenv, control, rec, lsnp, envid, flags) :
- self.c2m.put((control, rec))
-
- self.dbenvMaster.rep_set_transport(13,m2c)
- self.dbenvMaster.rep_set_priority(10)
- self.dbenvClient.rep_set_transport(3,c2m)
- self.dbenvClient.rep_set_priority(0)
-
- self.assertEqual(self.dbenvMaster.rep_get_priority(),10)
- self.assertEqual(self.dbenvClient.rep_get_priority(),0)
-
- #self.dbenvMaster.set_verbose(db.DB_VERB_REPLICATION, True)
- #self.dbenvMaster.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
- #self.dbenvClient.set_verbose(db.DB_VERB_REPLICATION, True)
- #self.dbenvClient.set_verbose(db.DB_VERB_FILEOPS_ALL, True)
-
- def thread_master() :
- return self.thread_do(self.dbenvMaster, self.c2m, 3,
- self.master_doing_election, True)
-
- def thread_client() :
- return self.thread_do(self.dbenvClient, self.m2c, 13,
- self.client_doing_election, False)
-
- from threading import Thread
- t_m=Thread(target=thread_master)
- t_c=Thread(target=thread_client)
- import sys
- if sys.version_info[0] < 3 :
- t_m.setDaemon(True)
- t_c.setDaemon(True)
- else :
- t_m.daemon = True
- t_c.daemon = True
-
- self.t_m = t_m
- self.t_c = t_c
-
- self.dbMaster = self.dbClient = None
-
- self.master_doing_election=[False]
- self.client_doing_election=[False]
-
-
- def tearDown(self):
- if self.dbClient :
- self.dbClient.close()
- if self.dbMaster :
- self.dbMaster.close()
- self.m2c.put(None)
- self.c2m.put(None)
- self.t_m.join()
- self.t_c.join()
-
- # Here we assign dummy event handlers to allow GC of the test object.
- # Since the dummy handler doesn't use any outer scope variable, it
- # doesn't keep any reference to the test object.
- def dummy(*args) :
- pass
- self.dbenvMaster.set_event_notify(dummy)
- self.dbenvClient.set_event_notify(dummy)
- self.dbenvMaster.rep_set_transport(13,dummy)
- self.dbenvClient.rep_set_transport(3,dummy)
-
- self.dbenvClient.close()
- self.dbenvMaster.close()
- test_support.rmtree(self.homeDirClient)
- test_support.rmtree(self.homeDirMaster)
-
- def basic_rep_threading(self) :
- self.dbenvMaster.rep_start(flags=db.DB_REP_MASTER)
- self.dbenvClient.rep_start(flags=db.DB_REP_CLIENT)
-
- def thread_do(env, q, envid, election_status, must_be_master) :
- while True :
- v=q.get()
- if v is None : return
- env.rep_process_message(v[0], v[1], envid)
-
- self.thread_do = thread_do
-
- self.t_m.start()
- self.t_c.start()
-
- def test01_basic_replication(self) :
- self.basic_rep_threading()
-
- # The timeout is necessary in BDB 4.5, since DB_EVENT_REP_STARTUPDONE
- # is not generated if the master has no new transactions.
- # This is solved in BDB 4.6 (#15542).
- import time
- timeout = time.time()+60
- while (time.time()<timeout) and not (self.confirmed_master and
- self.client_startupdone) :
- time.sleep(0.02)
- self.assertTrue(time.time()<timeout)
-
- self.dbMaster=db.DB(self.dbenvMaster)
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.open("test", db.DB_HASH, db.DB_CREATE, 0666, txn=txn)
- txn.commit()
-
- import time,os.path
- timeout=time.time()+10
- while (time.time()<timeout) and \
- not (os.path.exists(os.path.join(self.homeDirClient,"test"))) :
- time.sleep(0.01)
-
- self.dbClient=db.DB(self.dbenvClient)
- while True :
- txn=self.dbenvClient.txn_begin()
- try :
- self.dbClient.open("test", db.DB_HASH, flags=db.DB_RDONLY,
- mode=0666, txn=txn)
- except db.DBRepHandleDeadError :
- txn.abort()
- self.dbClient.close()
- self.dbClient=db.DB(self.dbenvClient)
- continue
-
- txn.commit()
- break
-
- d = self.dbenvMaster.rep_stat(flags=db.DB_STAT_CLEAR);
- self.assertTrue("master_changes" in d)
-
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.put("ABC", "123", txn=txn)
- txn.commit()
- import time
- timeout=time.time()+10
- v=None
- while (time.time()<timeout) and (v is None) :
- txn=self.dbenvClient.txn_begin()
- v=self.dbClient.get("ABC", txn=txn)
- txn.commit()
- if v is None :
- time.sleep(0.02)
- self.assertTrue(time.time()<timeout)
- self.assertEqual("123", v)
-
- txn=self.dbenvMaster.txn_begin()
- self.dbMaster.delete("ABC", txn=txn)
- txn.commit()
- timeout=time.time()+10
- while (time.time()<timeout) and (v is not None) :
- txn=self.dbenvClient.txn_begin()
- v=self.dbClient.get("ABC", txn=txn)
- txn.commit()
- if v is None :
- time.sleep(0.02)
- self.assertTrue(time.time()<timeout)
- self.assertEqual(None, v)
-
- if db.version() >= (4,7) :
- def test02_test_request(self) :
- self.basic_rep_threading()
- (minimum, maximum) = self.dbenvClient.rep_get_request()
- self.dbenvClient.rep_set_request(minimum-1, maximum+1)
- self.assertEqual(self.dbenvClient.rep_get_request(),
- (minimum-1, maximum+1))
-
- if db.version() >= (4,6) :
- def test03_master_election(self) :
- # Get ready to hold an election
- #self.dbenvMaster.rep_start(flags=db.DB_REP_MASTER)
- self.dbenvMaster.rep_start(flags=db.DB_REP_CLIENT)
- self.dbenvClient.rep_start(flags=db.DB_REP_CLIENT)
-
- def thread_do(env, q, envid, election_status, must_be_master) :
- while True :
- v=q.get()
- if v is None : return
- r = env.rep_process_message(v[0],v[1],envid)
- if must_be_master and self.confirmed_master :
- self.dbenvMaster.rep_start(flags = db.DB_REP_MASTER)
- must_be_master = False
-
- if r[0] == db.DB_REP_HOLDELECTION :
- def elect() :
- while True :
- try :
- env.rep_elect(2, 1)
- election_status[0] = False
- break
- except db.DBRepUnavailError :
- pass
- if not election_status[0] and not self.confirmed_master :
- from threading import Thread
- election_status[0] = True
- t=Thread(target=elect)
- import sys
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
-
- self.thread_do = thread_do
-
- self.t_m.start()
- self.t_c.start()
-
- self.dbenvMaster.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 50000)
- self.dbenvClient.rep_set_timeout(db.DB_REP_ELECTION_TIMEOUT, 50000)
- self.client_doing_election[0] = True
- while True :
- try :
- self.dbenvClient.rep_elect(2, 1)
- self.client_doing_election[0] = False
- break
- except db.DBRepUnavailError :
- pass
-
- self.assertTrue(self.confirmed_master)
-
- if db.version() >= (4,7) :
- def test04_test_clockskew(self) :
- fast, slow = 1234, 1230
- self.dbenvMaster.rep_set_clockskew(fast, slow)
- self.assertEqual((fast, slow),
- self.dbenvMaster.rep_get_clockskew())
- self.basic_rep_threading()
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
- if db.version() >= (4, 6) :
- dbenv = db.DBEnv()
- try :
- dbenv.repmgr_get_ack_policy()
- ReplicationManager_available=True
- except :
- ReplicationManager_available=False
- dbenv.close()
- del dbenv
- if ReplicationManager_available :
- suite.addTest(unittest.makeSuite(DBReplicationManager))
-
- if have_threads :
- suite.addTest(unittest.makeSuite(DBBaseReplication))
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_sequence.py b/Lib/bsddb/test/test_sequence.py
deleted file mode 100644
index 3d3ee29ba46..00000000000
--- a/Lib/bsddb/test/test_sequence.py
+++ /dev/null
@@ -1,142 +0,0 @@
-import unittest
-import os
-
-from test_all import db, test_support, get_new_environment_path, get_new_database_path
-
-
-class DBSequenceTest(unittest.TestCase):
- import sys
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def setUp(self):
- self.int_32_max = 0x100000000
- self.homeDir = get_new_environment_path()
- self.filename = "test"
-
- self.dbenv = db.DBEnv()
- self.dbenv.open(self.homeDir, db.DB_CREATE | db.DB_INIT_MPOOL, 0666)
- self.d = db.DB(self.dbenv)
- self.d.open(self.filename, db.DB_BTREE, db.DB_CREATE, 0666)
-
- def tearDown(self):
- if hasattr(self, 'seq'):
- self.seq.close()
- del self.seq
- if hasattr(self, 'd'):
- self.d.close()
- del self.d
- if hasattr(self, 'dbenv'):
- self.dbenv.close()
- del self.dbenv
-
- test_support.rmtree(self.homeDir)
-
- def test_get(self):
- self.seq = db.DBSequence(self.d, flags=0)
- start_value = 10 * self.int_32_max
- self.assertEqual(0xA00000000, start_value)
- self.assertEqual(None, self.seq.initial_value(start_value))
- self.assertEqual(None, self.seq.open(key='id', txn=None, flags=db.DB_CREATE))
- self.assertEqual(start_value, self.seq.get(5))
- self.assertEqual(start_value + 5, self.seq.get())
-
- def test_remove(self):
- self.seq = db.DBSequence(self.d, flags=0)
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- self.assertEqual(None, self.seq.remove(txn=None, flags=0))
- del self.seq
-
- def test_get_key(self):
- self.seq = db.DBSequence(self.d, flags=0)
- key = 'foo'
- self.assertEqual(None, self.seq.open(key=key, txn=None, flags=db.DB_CREATE))
- self.assertEqual(key, self.seq.get_key())
-
- def test_get_dbp(self):
- self.seq = db.DBSequence(self.d, flags=0)
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- self.assertEqual(self.d, self.seq.get_dbp())
-
- def test_cachesize(self):
- self.seq = db.DBSequence(self.d, flags=0)
- cashe_size = 10
- self.assertEqual(None, self.seq.set_cachesize(cashe_size))
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- self.assertEqual(cashe_size, self.seq.get_cachesize())
-
- def test_flags(self):
- self.seq = db.DBSequence(self.d, flags=0)
- flag = db.DB_SEQ_WRAP;
- self.assertEqual(None, self.seq.set_flags(flag))
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- self.assertEqual(flag, self.seq.get_flags() & flag)
-
- def test_range(self):
- self.seq = db.DBSequence(self.d, flags=0)
- seq_range = (10 * self.int_32_max, 11 * self.int_32_max - 1)
- self.assertEqual(None, self.seq.set_range(seq_range))
- self.seq.initial_value(seq_range[0])
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- self.assertEqual(seq_range, self.seq.get_range())
-
- def test_stat(self):
- self.seq = db.DBSequence(self.d, flags=0)
- self.assertEqual(None, self.seq.open(key='foo', txn=None, flags=db.DB_CREATE))
- stat = self.seq.stat()
- for param in ('nowait', 'min', 'max', 'value', 'current',
- 'flags', 'cache_size', 'last_value', 'wait'):
- self.assertTrue(param in stat, "parameter %s isn't in stat info" % param)
-
- if db.version() >= (4,7) :
- # This code checks a crash solved in Berkeley DB 4.7
- def test_stat_crash(self) :
- d=db.DB()
- d.open(None,dbtype=db.DB_HASH,flags=db.DB_CREATE) # In RAM
- seq = db.DBSequence(d, flags=0)
-
- self.assertRaises(db.DBNotFoundError, seq.open,
- key='id', txn=None, flags=0)
-
- self.assertRaises(db.DBInvalidArgError, seq.stat)
-
- d.close()
-
- def test_64bits(self) :
- # We don't use both extremes because they are problematic
- value_plus=(1L<<63)-2
- self.assertEqual(9223372036854775806L,value_plus)
- value_minus=(-1L<<63)+1 # Two complement
- self.assertEqual(-9223372036854775807L,value_minus)
- self.seq = db.DBSequence(self.d, flags=0)
- self.assertEqual(None, self.seq.initial_value(value_plus-1))
- self.assertEqual(None, self.seq.open(key='id', txn=None,
- flags=db.DB_CREATE))
- self.assertEqual(value_plus-1, self.seq.get(1))
- self.assertEqual(value_plus, self.seq.get(1))
-
- self.seq.remove(txn=None, flags=0)
-
- self.seq = db.DBSequence(self.d, flags=0)
- self.assertEqual(None, self.seq.initial_value(value_minus))
- self.assertEqual(None, self.seq.open(key='id', txn=None,
- flags=db.DB_CREATE))
- self.assertEqual(value_minus, self.seq.get(1))
- self.assertEqual(value_minus+1, self.seq.get(1))
-
- def test_multiple_close(self):
- self.seq = db.DBSequence(self.d)
- self.seq.close() # You can close a Sequence multiple times
- self.seq.close()
- self.seq.close()
-
-def test_suite():
- suite = unittest.TestSuite()
- if db.version() >= (4,3):
- suite.addTest(unittest.makeSuite(DBSequenceTest))
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/bsddb/test/test_thread.py b/Lib/bsddb/test/test_thread.py
deleted file mode 100644
index 91002b8512d..00000000000
--- a/Lib/bsddb/test/test_thread.py
+++ /dev/null
@@ -1,521 +0,0 @@
-"""TestCases for multi-threaded access to a DB.
-"""
-
-import os
-import sys
-import time
-import errno
-from random import random
-
-DASH = '-'
-
-try:
- WindowsError
-except NameError:
- class WindowsError(Exception):
- pass
-
-import unittest
-from test_all import db, dbutils, test_support, verbose, have_threads, \
- get_new_environment_path, get_new_database_path
-
-if have_threads :
- from threading import Thread
- if sys.version_info[0] < 3 :
- from threading import currentThread
- else :
- from threading import current_thread as currentThread
-
-
-#----------------------------------------------------------------------
-
-class BaseThreadedTestCase(unittest.TestCase):
- dbtype = db.DB_UNKNOWN # must be set in derived class
- dbopenflags = 0
- dbsetflags = 0
- envflags = 0
-
- if sys.version_info < (2, 4) :
- def assertTrue(self, expr, msg=None):
- self.failUnless(expr,msg=msg)
-
- def setUp(self):
- if verbose:
- dbutils._deadlock_VerboseFile = sys.stdout
-
- self.homeDir = get_new_environment_path()
- self.env = db.DBEnv()
- self.setEnvOpts()
- self.env.open(self.homeDir, self.envflags | db.DB_CREATE)
-
- self.filename = self.__class__.__name__ + '.db'
- self.d = db.DB(self.env)
- if self.dbsetflags:
- self.d.set_flags(self.dbsetflags)
- self.d.open(self.filename, self.dbtype, self.dbopenflags|db.DB_CREATE)
-
- def tearDown(self):
- self.d.close()
- self.env.close()
- test_support.rmtree(self.homeDir)
-
- def setEnvOpts(self):
- pass
-
- def makeData(self, key):
- return DASH.join([key] * 5)
-
-
-#----------------------------------------------------------------------
-
-
-class ConcurrentDataStoreBase(BaseThreadedTestCase):
- dbopenflags = db.DB_THREAD
- envflags = db.DB_THREAD | db.DB_INIT_CDB | db.DB_INIT_MPOOL
- readers = 0 # derived class should set
- writers = 0
- records = 1000
-
- def test01_1WriterMultiReaders(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test01_1WriterMultiReaders..." % \
- self.__class__.__name__
-
- keys=range(self.records)
- import random
- random.shuffle(keys)
- records_per_writer=self.records//self.writers
- readers_per_writer=self.readers//self.writers
- self.assertEqual(self.records,self.writers*records_per_writer)
- self.assertEqual(self.readers,self.writers*readers_per_writer)
- self.assertTrue((records_per_writer%readers_per_writer)==0)
- readers = []
-
- for x in xrange(self.readers):
- rt = Thread(target = self.readerThread,
- args = (self.d, x),
- name = 'reader %d' % x,
- )#verbose = verbose)
- if sys.version_info[0] < 3 :
- rt.setDaemon(True)
- else :
- rt.daemon = True
- readers.append(rt)
-
- writers=[]
- for x in xrange(self.writers):
- a=keys[records_per_writer*x:records_per_writer*(x+1)]
- a.sort() # Generate conflicts
- b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
- wt = Thread(target = self.writerThread,
- args = (self.d, a, b),
- name = 'writer %d' % x,
- )#verbose = verbose)
- writers.append(wt)
-
- for t in writers:
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
-
- for t in writers:
- t.join()
- for t in readers:
- t.join()
-
- def writerThread(self, d, keys, readers):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- if verbose:
- print "%s: creating records %d - %d" % (name, start, stop)
-
- count=len(keys)//len(readers)
- count2=count
- for x in keys :
- key = '%04d' % x
- dbutils.DeadlockWrap(d.put, key, self.makeData(key),
- max_retries=12)
- if verbose and x % 100 == 0:
- print "%s: records %d - %d finished" % (name, start, x)
-
- count2-=1
- if not count2 :
- readers.pop().start()
- count2=count
-
- if verbose:
- print "%s: finished creating records" % name
-
- if verbose:
- print "%s: thread finished" % name
-
- def readerThread(self, d, readerNum):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- for i in xrange(5) :
- c = d.cursor()
- count = 0
- rec = c.first()
- while rec:
- count += 1
- key, data = rec
- self.assertEqual(self.makeData(key), data)
- rec = c.next()
- if verbose:
- print "%s: found %d records" % (name, count)
- c.close()
-
- if verbose:
- print "%s: thread finished" % name
-
-
-class BTreeConcurrentDataStore(ConcurrentDataStoreBase):
- dbtype = db.DB_BTREE
- writers = 2
- readers = 10
- records = 1000
-
-
-class HashConcurrentDataStore(ConcurrentDataStoreBase):
- dbtype = db.DB_HASH
- writers = 2
- readers = 10
- records = 1000
-
-
-#----------------------------------------------------------------------
-
-class SimpleThreadedBase(BaseThreadedTestCase):
- dbopenflags = db.DB_THREAD
- envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
- readers = 10
- writers = 2
- records = 1000
-
- def setEnvOpts(self):
- self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
-
- def test02_SimpleLocks(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test02_SimpleLocks..." % self.__class__.__name__
-
-
- keys=range(self.records)
- import random
- random.shuffle(keys)
- records_per_writer=self.records//self.writers
- readers_per_writer=self.readers//self.writers
- self.assertEqual(self.records,self.writers*records_per_writer)
- self.assertEqual(self.readers,self.writers*readers_per_writer)
- self.assertTrue((records_per_writer%readers_per_writer)==0)
-
- readers = []
- for x in xrange(self.readers):
- rt = Thread(target = self.readerThread,
- args = (self.d, x),
- name = 'reader %d' % x,
- )#verbose = verbose)
- if sys.version_info[0] < 3 :
- rt.setDaemon(True)
- else :
- rt.daemon = True
- readers.append(rt)
-
- writers = []
- for x in xrange(self.writers):
- a=keys[records_per_writer*x:records_per_writer*(x+1)]
- a.sort() # Generate conflicts
- b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
- wt = Thread(target = self.writerThread,
- args = (self.d, a, b),
- name = 'writer %d' % x,
- )#verbose = verbose)
- writers.append(wt)
-
- for t in writers:
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
-
- for t in writers:
- t.join()
- for t in readers:
- t.join()
-
- def writerThread(self, d, keys, readers):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
- if verbose:
- print "%s: creating records %d - %d" % (name, start, stop)
-
- count=len(keys)//len(readers)
- count2=count
- for x in keys :
- key = '%04d' % x
- dbutils.DeadlockWrap(d.put, key, self.makeData(key),
- max_retries=12)
-
- if verbose and x % 100 == 0:
- print "%s: records %d - %d finished" % (name, start, x)
-
- count2-=1
- if not count2 :
- readers.pop().start()
- count2=count
-
- if verbose:
- print "%s: thread finished" % name
-
- def readerThread(self, d, readerNum):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- c = d.cursor()
- count = 0
- rec = dbutils.DeadlockWrap(c.first, max_retries=10)
- while rec:
- count += 1
- key, data = rec
- self.assertEqual(self.makeData(key), data)
- rec = dbutils.DeadlockWrap(c.next, max_retries=10)
- if verbose:
- print "%s: found %d records" % (name, count)
- c.close()
-
- if verbose:
- print "%s: thread finished" % name
-
-
-class BTreeSimpleThreaded(SimpleThreadedBase):
- dbtype = db.DB_BTREE
-
-
-class HashSimpleThreaded(SimpleThreadedBase):
- dbtype = db.DB_HASH
-
-
-#----------------------------------------------------------------------
-
-
-class ThreadedTransactionsBase(BaseThreadedTestCase):
- dbopenflags = db.DB_THREAD | db.DB_AUTO_COMMIT
- envflags = (db.DB_THREAD |
- db.DB_INIT_MPOOL |
- db.DB_INIT_LOCK |
- db.DB_INIT_LOG |
- db.DB_INIT_TXN
- )
- readers = 0
- writers = 0
- records = 2000
- txnFlag = 0
-
- def setEnvOpts(self):
- #self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
- pass
-
- def test03_ThreadedTransactions(self):
- if verbose:
- print '\n', '-=' * 30
- print "Running %s.test03_ThreadedTransactions..." % \
- self.__class__.__name__
-
- keys=range(self.records)
- import random
- random.shuffle(keys)
- records_per_writer=self.records//self.writers
- readers_per_writer=self.readers//self.writers
- self.assertEqual(self.records,self.writers*records_per_writer)
- self.assertEqual(self.readers,self.writers*readers_per_writer)
- self.assertTrue((records_per_writer%readers_per_writer)==0)
-
- readers=[]
- for x in xrange(self.readers):
- rt = Thread(target = self.readerThread,
- args = (self.d, x),
- name = 'reader %d' % x,
- )#verbose = verbose)
- if sys.version_info[0] < 3 :
- rt.setDaemon(True)
- else :
- rt.daemon = True
- readers.append(rt)
-
- writers = []
- for x in xrange(self.writers):
- a=keys[records_per_writer*x:records_per_writer*(x+1)]
- b=readers[readers_per_writer*x:readers_per_writer*(x+1)]
- wt = Thread(target = self.writerThread,
- args = (self.d, a, b),
- name = 'writer %d' % x,
- )#verbose = verbose)
- writers.append(wt)
-
- dt = Thread(target = self.deadlockThread)
- if sys.version_info[0] < 3 :
- dt.setDaemon(True)
- else :
- dt.daemon = True
- dt.start()
-
- for t in writers:
- if sys.version_info[0] < 3 :
- t.setDaemon(True)
- else :
- t.daemon = True
- t.start()
-
- for t in writers:
- t.join()
- for t in readers:
- t.join()
-
- self.doLockDetect = False
- dt.join()
-
- def writerThread(self, d, keys, readers):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- count=len(keys)//len(readers)
- while len(keys):
- try:
- txn = self.env.txn_begin(None, self.txnFlag)
- keys2=keys[:count]
- for x in keys2 :
- key = '%04d' % x
- d.put(key, self.makeData(key), txn)
- if verbose and x % 100 == 0:
- print "%s: records %d - %d finished" % (name, start, x)
- txn.commit()
- keys=keys[count:]
- readers.pop().start()
- except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
- if verbose:
- if sys.version_info < (2, 6) :
- print "%s: Aborting transaction (%s)" % (name, val[1])
- else :
- print "%s: Aborting transaction (%s)" % (name,
- val.args[1])
- txn.abort()
-
- if verbose:
- print "%s: thread finished" % name
-
- def readerThread(self, d, readerNum):
- if sys.version_info[0] < 3 :
- name = currentThread().getName()
- else :
- name = currentThread().name
-
- finished = False
- while not finished:
- try:
- txn = self.env.txn_begin(None, self.txnFlag)
- c = d.cursor(txn)
- count = 0
- rec = c.first()
- while rec:
- count += 1
- key, data = rec
- self.assertEqual(self.makeData(key), data)
- rec = c.next()
- if verbose: print "%s: found %d records" % (name, count)
- c.close()
- txn.commit()
- finished = True
- except (db.DBLockDeadlockError, db.DBLockNotGrantedError), val:
- if verbose:
- if sys.version_info < (2, 6) :
- print "%s: Aborting transaction (%s)" % (name, val[1])
- else :
- print "%s: Aborting transaction (%s)" % (name,
- val.args[1])
- c.close()
- txn.abort()
-
- if verbose:
- print "%s: thread finished" % name
-
- def deadlockThread(self):
- self.doLockDetect = True
- while self.doLockDetect:
- time.sleep(0.05)
- try:
- aborted = self.env.lock_detect(
- db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT)
- if verbose and aborted:
- print "deadlock: Aborted %d deadlocked transaction(s)" \
- % aborted
- except db.DBError:
- pass
-
-
-class BTreeThreadedTransactions(ThreadedTransactionsBase):
- dbtype = db.DB_BTREE
- writers = 2
- readers = 10
- records = 1000
-
-class HashThreadedTransactions(ThreadedTransactionsBase):
- dbtype = db.DB_HASH
- writers = 2
- readers = 10
- records = 1000
-
-class BTreeThreadedNoWaitTransactions(ThreadedTransactionsBase):
- dbtype = db.DB_BTREE
- writers = 2
- readers = 10
- records = 1000
- txnFlag = db.DB_TXN_NOWAIT
-
-class HashThreadedNoWaitTransactions(ThreadedTransactionsBase):
- dbtype = db.DB_HASH
- writers = 2
- readers = 10
- records = 1000
- txnFlag = db.DB_TXN_NOWAIT
-
-
-#----------------------------------------------------------------------
-
-def test_suite():
- suite = unittest.TestSuite()
-
- if have_threads:
- suite.addTest(unittest.makeSuite(BTreeConcurrentDataStore))
- suite.addTest(unittest.makeSuite(HashConcurrentDataStore))
- suite.addTest(unittest.makeSuite(BTreeSimpleThreaded))
- suite.addTest(unittest.makeSuite(HashSimpleThreaded))
- suite.addTest(unittest.makeSuite(BTreeThreadedTransactions))
- suite.addTest(unittest.makeSuite(HashThreadedTransactions))
- suite.addTest(unittest.makeSuite(BTreeThreadedNoWaitTransactions))
- suite.addTest(unittest.makeSuite(HashThreadedNoWaitTransactions))
-
- else:
- print "Threads not available, skipping thread tests."
-
- return suite
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='test_suite')
diff --git a/Lib/cProfile.py b/Lib/cProfile.py
index b2efd047d39..c24d45bab47 100755
--- a/Lib/cProfile.py
+++ b/Lib/cProfile.py
@@ -1,10 +1,10 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Python interface for the 'lsprof' profiler.
Compatible with the 'profile' module.
"""
-__all__ = ["run", "runctx", "help", "Profile"]
+__all__ = ["run", "runctx", "Profile"]
import _lsprof
@@ -56,11 +56,6 @@ def runctx(statement, globals, locals, filename=None, sort=-1):
result = prof.print_stats(sort)
return result
-# Backwards compatibility.
-def help():
- print "Documentation for the profile/cProfile modules can be found "
- print "in the Python Library Reference, section 'The Python Profiler'."
-
# ____________________________________________________________
class Profile(_lsprof.Profiler):
@@ -137,7 +132,7 @@ class Profile(_lsprof.Profiler):
def runctx(self, cmd, globals, locals):
self.enable()
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
self.disable()
return self
@@ -188,6 +183,7 @@ def main():
'__file__': progname,
'__name__': '__main__',
'__package__': None,
+ '__cached__': None,
}
runctx(code, globs, None, options.outfile, options.sort)
else:
diff --git a/Lib/calendar.py b/Lib/calendar.py
index 232957829f0..3bbf399649f 100644
--- a/Lib/calendar.py
+++ b/Lib/calendar.py
@@ -266,7 +266,7 @@ class TextCalendar(Calendar):
"""
Print a single week (no newline).
"""
- print self.formatweek(theweek, width),
+ print(self.formatweek(theweek, width), end=' ')
def formatday(self, day, weekday, width):
"""
@@ -313,7 +313,7 @@ class TextCalendar(Calendar):
"""
Print a month's calendar.
"""
- print self.formatmonth(theyear, themonth, w, l),
+ print(self.formatmonth(theyear, themonth, w, l), end=' ')
def formatmonth(self, theyear, themonth, w=0, l=0):
"""
@@ -370,7 +370,7 @@ class TextCalendar(Calendar):
def pryear(self, theyear, w=0, l=0, c=6, m=3):
"""Print a year's calendar."""
- print self.formatyear(theyear, w, l, c, m)
+ print(self.formatyear(theyear, w, l, c, m))
class HTMLCalendar(Calendar):
@@ -485,7 +485,7 @@ class HTMLCalendar(Calendar):
return ''.join(v).encode(encoding, "xmlcharrefreplace")
-class TimeEncoding:
+class different_locale:
def __init__(self, locale):
self.locale = locale
@@ -512,21 +512,17 @@ class LocaleTextCalendar(TextCalendar):
self.locale = locale
def formatweekday(self, day, width):
- with TimeEncoding(self.locale) as encoding:
+ with different_locale(self.locale):
if width >= 9:
names = day_name
else:
names = day_abbr
name = names[day]
- if encoding is not None:
- name = name.decode(encoding)
return name[:width].center(width)
def formatmonthname(self, theyear, themonth, width, withyear=True):
- with TimeEncoding(self.locale) as encoding:
+ with different_locale(self.locale):
s = month_name[themonth]
- if encoding is not None:
- s = s.decode(encoding)
if withyear:
s = "%s %r" % (s, theyear)
return s.center(width)
@@ -546,17 +542,13 @@ class LocaleHTMLCalendar(HTMLCalendar):
self.locale = locale
def formatweekday(self, day):
- with TimeEncoding(self.locale) as encoding:
+ with different_locale(self.locale):
s = day_abbr[day]
- if encoding is not None:
- s = s.decode(encoding)
return '<th class="%s">%s</th>' % (self.cssclasses[day], s)
def formatmonthname(self, theyear, themonth, withyear=True):
- with TimeEncoding(self.locale) as encoding:
+ with different_locale(self.locale):
s = month_name[themonth]
- if encoding is not None:
- s = s.decode(encoding)
if withyear:
s = '%s %s' % (s, theyear)
return '<tr><th colspan="7" class="month">%s</th></tr>' % s
@@ -568,10 +560,6 @@ c = TextCalendar()
firstweekday = c.getfirstweekday
def setfirstweekday(firstweekday):
- try:
- firstweekday.__index__
- except AttributeError:
- raise IllegalWeekdayError(firstweekday)
if not MONDAY <= firstweekday <= SUNDAY:
raise IllegalWeekdayError(firstweekday)
c.firstweekday = firstweekday
@@ -593,7 +581,7 @@ _spacing = 6 # Number of spaces between columns
def format(cols, colwidth=_colwidth, spacing=_spacing):
"""Prints multi-column formatting for year calendars"""
- print formatstring(cols, colwidth, spacing)
+ print(formatstring(cols, colwidth, spacing))
def formatstring(cols, colwidth=_colwidth, spacing=_spacing):
@@ -652,7 +640,7 @@ def main(args):
parser.add_option(
"-e", "--encoding",
dest="encoding", default=None,
- help="Encoding to use for output"
+ help="Encoding to use for output."
)
parser.add_option(
"-t", "--type",
@@ -678,10 +666,11 @@ def main(args):
if encoding is None:
encoding = sys.getdefaultencoding()
optdict = dict(encoding=encoding, css=options.css)
+ write = sys.stdout.buffer.write
if len(args) == 1:
- print cal.formatyearpage(datetime.date.today().year, **optdict)
+ write(cal.formatyearpage(datetime.date.today().year, **optdict))
elif len(args) == 2:
- print cal.formatyearpage(int(args[1]), **optdict)
+ write(cal.formatyearpage(int(args[1]), **optdict))
else:
parser.error("incorrect number of arguments")
sys.exit(1)
@@ -703,9 +692,11 @@ def main(args):
else:
parser.error("incorrect number of arguments")
sys.exit(1)
+ write = sys.stdout.write
if options.encoding:
result = result.encode(options.encoding)
- print result
+ write = sys.stdout.buffer.write
+ write(result)
if __name__ == "__main__":
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 67079db0d81..90a33450bc0 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -15,9 +15,6 @@ This module defines a number of utilities for use by CGI scripts
written in Python.
"""
-# XXX Perhaps there should be a slimmed version that doesn't contain
-# all those backwards compatible and debugging classes and functions?
-
# History
# -------
#
@@ -34,29 +31,17 @@ __version__ = "2.6"
# Imports
# =======
-from operator import attrgetter
+from io import StringIO, BytesIO, TextIOWrapper
import sys
import os
-import UserDict
-import urlparse
-
-from warnings import filterwarnings, catch_warnings, warn
-with catch_warnings():
- if sys.py3kwarning:
- filterwarnings("ignore", ".*mimetools has been removed",
- DeprecationWarning)
- filterwarnings("ignore", ".*rfc822 has been removed",
- DeprecationWarning)
- import mimetools
- import rfc822
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-__all__ = ["MiniFieldStorage", "FieldStorage", "FormContentDict",
- "SvFormContentDict", "InterpFormContentDict", "FormContent",
+import urllib.parse
+from email.parser import FeedParser
+from warnings import warn
+import html
+import locale
+import tempfile
+
+__all__ = ["MiniFieldStorage", "FieldStorage",
"parse", "parse_qs", "parse_qsl", "parse_multipart",
"parse_header", "print_exception", "print_environ",
"print_form", "print_directory", "print_arguments",
@@ -126,7 +111,7 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
Arguments, all optional:
- fp : file pointer; default: sys.stdin
+ fp : file pointer; default: sys.stdin.buffer
environ : environment dictionary; default: os.environ
@@ -143,6 +128,18 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
"""
if fp is None:
fp = sys.stdin
+
+ # field keys and values (except for files) are returned as strings
+ # an encoding is required to decode the bytes read from self.fp
+ if hasattr(fp,'encoding'):
+ encoding = fp.encoding
+ else:
+ encoding = 'latin-1'
+
+ # fp.read() must return bytes
+ if isinstance(fp, TextIOWrapper):
+ fp = fp.buffer
+
if not 'REQUEST_METHOD' in environ:
environ['REQUEST_METHOD'] = 'GET' # For testing stand-alone
if environ['REQUEST_METHOD'] == 'POST':
@@ -152,8 +149,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
elif ctype == 'application/x-www-form-urlencoded':
clength = int(environ['CONTENT_LENGTH'])
if maxlen and clength > maxlen:
- raise ValueError, 'Maximum content length exceeded'
- qs = fp.read(clength)
+ raise ValueError('Maximum content length exceeded')
+ qs = fp.read(clength).decode(encoding)
else:
qs = '' # Unknown content-type
if 'QUERY_STRING' in environ:
@@ -171,7 +168,8 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
else:
qs = ""
environ['QUERY_STRING'] = qs # XXX Shouldn't, really
- return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
+ return urllib.parse.parse_qs(qs, keep_blank_values, strict_parsing,
+ encoding=encoding)
# parse query string function called from urlparse,
@@ -179,16 +177,15 @@ def parse(fp=None, environ=os.environ, keep_blank_values=0, strict_parsing=0):
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 urlparse.parse_qs instead",
- PendingDeprecationWarning, 2)
- return urlparse.parse_qs(qs, keep_blank_values, strict_parsing)
-
+ 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 urlparse.parse_qsl instead",
- PendingDeprecationWarning, 2)
- return urlparse.parse_qsl(qs, keep_blank_values, strict_parsing)
+ 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.
@@ -215,11 +212,13 @@ def parse_multipart(fp, pdict):
since it can call parse_multipart().
"""
+ import http.client
+
boundary = ""
if 'boundary' in pdict:
boundary = pdict['boundary']
if not valid_boundary(boundary):
- raise ValueError, ('Invalid boundary in multipart form: %r'
+ raise ValueError('Invalid boundary in multipart form: %r'
% (boundary,))
nextpart = "--" + boundary
@@ -232,8 +231,8 @@ def parse_multipart(fp, pdict):
data = None
if terminator:
# At start of next part. Read headers first.
- headers = mimetools.Message(fp)
- clength = headers.getheader('content-length')
+ headers = http.client.parse_headers(fp)
+ clength = headers.get('content-length')
if clength:
try:
bytes = int(clength)
@@ -241,7 +240,7 @@ def parse_multipart(fp, pdict):
pass
if bytes > 0:
if maxlen and bytes > maxlen:
- raise ValueError, 'Maximum content length exceeded'
+ raise ValueError('Maximum content length exceeded')
data = fp.read(bytes)
else:
data = ""
@@ -252,8 +251,8 @@ def parse_multipart(fp, pdict):
if not line:
terminator = lastpart # End outer loop
break
- if line[:2] == "--":
- terminator = line.strip()
+ if line.startswith("--"):
+ terminator = line.rstrip()
if terminator in (nextpart, lastpart):
break
lines.append(line)
@@ -307,7 +306,7 @@ def parse_header(line):
"""
parts = _parseparam(';' + line)
- key = parts.next()
+ key = parts.__next__()
pdict = {}
for p in parts:
i = p.find('=')
@@ -368,9 +367,10 @@ class FieldStorage:
value: the value as a *string*; for file uploads, this
transparently reads the file every time you request the value
+ and returns *bytes*
- file: the file(-like) object from which you can read the data;
- None if the data is stored a simple string
+ file: the file(-like) object from which you can read the data *as
+ bytes* ; None if the data is stored a simple string
type: the content-type, or None if not specified
@@ -381,7 +381,7 @@ class FieldStorage:
disposition_options: dictionary of corresponding options
- headers: a dictionary(-like) object (sometimes rfc822.Message or a
+ headers: a dictionary(-like) object (sometimes email.message.Message or a
subclass thereof) containing *all* headers
The class is subclassable, mostly for the purpose of overriding
@@ -391,15 +391,18 @@ class FieldStorage:
directory and unlinking them as soon as they have been opened.
"""
-
- def __init__(self, fp=None, headers=None, outerboundary="",
- environ=os.environ, keep_blank_values=0, strict_parsing=0):
+ def __init__(self, fp=None, headers=None, outerboundary=b'',
+ environ=os.environ, keep_blank_values=0, strict_parsing=0,
+ limit=None, encoding='utf-8', errors='replace'):
"""Constructor. Read multipart/* until last part.
Arguments, all optional:
- fp : file pointer; default: sys.stdin
+ fp : file pointer; default: sys.stdin.buffer
(not used when the request method is GET)
+ Can be :
+ 1. a TextIOWrapper object
+ 2. an object whose read() and readline() methods return bytes
headers : header dictionary-like object; default:
taken from environ as per CGI spec
@@ -420,6 +423,16 @@ class FieldStorage:
If false (the default), errors are silently ignored.
If true, errors raise a ValueError exception.
+ limit : used internally to read parts of multipart/form-data forms,
+ to exit from the reading loop when reached. It is the difference
+ between the form content-length and the number of bytes already
+ read
+
+ encoding, errors : the encoding and error handler used to decode the
+ binary stream to strings. Must be the same as the charset defined
+ for the page sending the form (content-type : meta http-equiv or
+ header)
+
"""
method = 'GET'
self.keep_blank_values = keep_blank_values
@@ -434,7 +447,8 @@ class FieldStorage:
qs = sys.argv[1]
else:
qs = ""
- fp = StringIO(qs)
+ qs = qs.encode(locale.getpreferredencoding(), 'surrogateescape')
+ fp = BytesIO(qs)
if headers is None:
headers = {'content-type':
"application/x-www-form-urlencoded"}
@@ -449,10 +463,26 @@ class FieldStorage:
self.qs_on_post = environ['QUERY_STRING']
if 'CONTENT_LENGTH' in environ:
headers['content-length'] = environ['CONTENT_LENGTH']
- self.fp = fp or sys.stdin
+ if fp is None:
+ self.fp = sys.stdin.buffer
+ # self.fp.read() must return bytes
+ elif isinstance(fp, TextIOWrapper):
+ self.fp = fp.buffer
+ else:
+ self.fp = fp
+
+ self.encoding = encoding
+ self.errors = errors
+
self.headers = headers
+ if not isinstance(outerboundary, bytes):
+ raise TypeError('outerboundary must be bytes, not %s'
+ % type(outerboundary).__name__)
self.outerboundary = outerboundary
+ self.bytes_read = 0
+ self.limit = limit
+
# Process content-disposition header
cdisp, pdict = "", {}
if 'content-disposition' in self.headers:
@@ -465,6 +495,7 @@ class FieldStorage:
self.filename = None
if 'filename' in pdict:
self.filename = pdict['filename']
+ self._binary_file = self.filename is not None
# Process content-type header
#
@@ -486,9 +517,11 @@ class FieldStorage:
ctype, pdict = 'application/x-www-form-urlencoded', {}
self.type = ctype
self.type_options = pdict
- self.innerboundary = ""
if 'boundary' in pdict:
- self.innerboundary = pdict['boundary']
+ self.innerboundary = pdict['boundary'].encode(self.encoding)
+ else:
+ self.innerboundary = b""
+
clen = -1
if 'content-length' in self.headers:
try:
@@ -496,8 +529,10 @@ class FieldStorage:
except ValueError:
pass
if maxlen and clen > maxlen:
- raise ValueError, 'Maximum content length exceeded'
+ raise ValueError('Maximum content length exceeded')
self.length = clen
+ if self.limit is None and clen:
+ self.limit = clen
self.list = self.file = None
self.done = 0
@@ -518,7 +553,7 @@ class FieldStorage:
def __getattr__(self, name):
if name != 'value':
- raise AttributeError, name
+ raise AttributeError(name)
if self.file:
self.file.seek(0)
value = self.file.read()
@@ -532,12 +567,12 @@ class FieldStorage:
def __getitem__(self, key):
"""Dictionary style indexing."""
if self.list is None:
- raise TypeError, "not indexable"
+ raise TypeError("not indexable")
found = []
for item in self.list:
if item.name == key: found.append(item)
if not found:
- raise KeyError, key
+ raise KeyError(key)
if len(found) == 1:
return found[0]
else:
@@ -547,8 +582,8 @@ class FieldStorage:
"""Dictionary style get() method, including 'value' lookup."""
if key in self:
value = self[key]
- if type(value) is type([]):
- return map(attrgetter('value'), value)
+ if isinstance(value, list):
+ return [x.value for x in value]
else:
return value.value
else:
@@ -558,7 +593,7 @@ class FieldStorage:
""" Return the first value received."""
if key in self:
value = self[key]
- if type(value) is type([]):
+ if isinstance(value, list):
return value[0].value
else:
return value.value
@@ -569,8 +604,8 @@ class FieldStorage:
""" Return list of received values."""
if key in self:
value = self[key]
- if type(value) is type([]):
- return map(attrgetter('value'), value)
+ if isinstance(value, list):
+ return [x.value for x in value]
else:
return [value.value]
else:
@@ -579,19 +614,13 @@ class FieldStorage:
def keys(self):
"""Dictionary style keys() method."""
if self.list is None:
- raise TypeError, "not indexable"
+ raise TypeError("not indexable")
return list(set(item.name for item in self.list))
- def has_key(self, key):
- """Dictionary style has_key() method."""
- if self.list is None:
- raise TypeError, "not indexable"
- return any(item.name == key for item in self.list)
-
def __contains__(self, key):
"""Dictionary style __contains__ method."""
if self.list is None:
- raise TypeError, "not indexable"
+ raise TypeError("not indexable")
return any(item.name == key for item in self.list)
def __len__(self):
@@ -604,12 +633,18 @@ class FieldStorage:
def read_urlencoded(self):
"""Internal: read data in query string format."""
qs = self.fp.read(self.length)
+ if not isinstance(qs, bytes):
+ raise ValueError("%s should return bytes, got %s" \
+ % (self.fp, type(qs).__name__))
+ qs = qs.decode(self.encoding, self.errors)
if self.qs_on_post:
qs += '&' + self.qs_on_post
- self.list = list = []
- for key, value in urlparse.parse_qsl(qs, self.keep_blank_values,
- self.strict_parsing):
- list.append(MiniFieldStorage(key, value))
+ self.list = []
+ query = urllib.parse.parse_qsl(
+ qs, self.keep_blank_values, self.strict_parsing,
+ encoding=self.encoding, errors=self.errors)
+ for key, value in query:
+ self.list.append(MiniFieldStorage(key, value))
self.skip_lines()
FieldStorageClass = None
@@ -618,23 +653,45 @@ class FieldStorage:
"""Internal: read a part that is itself multipart."""
ib = self.innerboundary
if not valid_boundary(ib):
- raise ValueError, 'Invalid boundary in multipart form: %r' % (ib,)
+ raise ValueError('Invalid boundary in multipart form: %r' % (ib,))
self.list = []
if self.qs_on_post:
- for key, value in urlparse.parse_qsl(self.qs_on_post,
- self.keep_blank_values, self.strict_parsing):
+ query = urllib.parse.parse_qsl(
+ self.qs_on_post, self.keep_blank_values, self.strict_parsing,
+ encoding=self.encoding, errors=self.errors)
+ for key, value in query:
self.list.append(MiniFieldStorage(key, value))
FieldStorageClass = None
klass = self.FieldStorageClass or self.__class__
- part = klass(self.fp, {}, ib,
- environ, keep_blank_values, strict_parsing)
- # Throw first part away
- while not part.done:
- headers = rfc822.Message(self.fp)
- part = klass(self.fp, headers, ib,
- environ, keep_blank_values, strict_parsing)
+ first_line = self.fp.readline() # bytes
+ if not isinstance(first_line, bytes):
+ raise ValueError("%s should return bytes, got %s" \
+ % (self.fp, type(first_line).__name__))
+ self.bytes_read += len(first_line)
+ # first line holds boundary ; ignore it, or check that
+ # b"--" + ib == first_line.strip() ?
+ while True:
+ parser = FeedParser()
+ hdr_text = b""
+ while True:
+ data = self.fp.readline()
+ hdr_text += data
+ if not data.strip():
+ break
+ if not hdr_text:
+ break
+ # parser takes strings, not bytes
+ self.bytes_read += len(hdr_text)
+ parser.feed(hdr_text.decode(self.encoding, self.errors))
+ headers = parser.close()
+ part = klass(self.fp, headers, ib, environ, keep_blank_values,
+ strict_parsing,self.limit-self.bytes_read,
+ self.encoding, self.errors)
+ self.bytes_read += part.bytes_read
self.list.append(part)
+ if self.bytes_read >= self.length:
+ break
self.skip_lines()
def read_single(self):
@@ -650,11 +707,15 @@ class FieldStorage:
def read_binary(self):
"""Internal: read binary data."""
- self.file = self.make_file('b')
+ self.file = self.make_file()
todo = self.length
if todo >= 0:
while todo > 0:
- data = self.fp.read(min(todo, self.bufsize))
+ data = self.fp.read(min(todo, self.bufsize)) # bytes
+ if not isinstance(data, bytes):
+ raise ValueError("%s should return bytes, got %s"
+ % (self.fp, type(data).__name__))
+ self.bytes_read += len(data)
if not data:
self.done = -1
break
@@ -663,58 +724,77 @@ class FieldStorage:
def read_lines(self):
"""Internal: read lines until EOF or outerboundary."""
- self.file = self.__file = StringIO()
+ if self._binary_file:
+ self.file = self.__file = BytesIO() # store data as bytes for files
+ else:
+ self.file = self.__file = StringIO() # as strings for other fields
if self.outerboundary:
self.read_lines_to_outerboundary()
else:
self.read_lines_to_eof()
def __write(self, line):
+ """line is always bytes, not string"""
if self.__file is not None:
if self.__file.tell() + len(line) > 1000:
- self.file = self.make_file('')
- self.file.write(self.__file.getvalue())
+ self.file = self.make_file()
+ data = self.__file.getvalue()
+ self.file.write(data)
self.__file = None
- self.file.write(line)
+ if self._binary_file:
+ # keep bytes
+ self.file.write(line)
+ else:
+ # decode to string
+ self.file.write(line.decode(self.encoding, self.errors))
def read_lines_to_eof(self):
"""Internal: read lines until EOF."""
while 1:
- line = self.fp.readline(1<<16)
+ line = self.fp.readline(1<<16) # bytes
+ self.bytes_read += len(line)
if not line:
self.done = -1
break
self.__write(line)
def read_lines_to_outerboundary(self):
- """Internal: read lines until outerboundary."""
- next = "--" + self.outerboundary
- last = next + "--"
- delim = ""
+ """Internal: read lines until outerboundary.
+ Data is read as bytes: boundaries and line ends must be converted
+ to bytes for comparisons.
+ """
+ next_boundary = b"--" + self.outerboundary
+ last_boundary = next_boundary + b"--"
+ delim = b""
last_line_lfend = True
+ _read = 0
while 1:
- line = self.fp.readline(1<<16)
+ if _read >= self.limit:
+ break
+ line = self.fp.readline(1<<16) # bytes
+ self.bytes_read += len(line)
+ _read += len(line)
if not line:
self.done = -1
break
- if line[:2] == "--" and last_line_lfend:
- strippedline = line.strip()
- if strippedline == next:
+ if line.startswith(b"--") and last_line_lfend:
+ strippedline = line.rstrip()
+ if strippedline == next_boundary:
break
- if strippedline == last:
+ if strippedline == last_boundary:
self.done = 1
break
odelim = delim
- if line[-2:] == "\r\n":
- delim = "\r\n"
+ if line.endswith(b"\r\n"):
+ delim = b"\r\n"
line = line[:-2]
last_line_lfend = True
- elif line[-1] == "\n":
- delim = "\n"
+ elif line.endswith(b"\n"):
+ delim = b"\n"
line = line[:-1]
last_line_lfend = True
else:
- delim = ""
+ delim = b""
last_line_lfend = False
self.__write(odelim + line)
@@ -722,24 +802,25 @@ class FieldStorage:
"""Internal: skip lines until outer boundary if defined."""
if not self.outerboundary or self.done:
return
- next = "--" + self.outerboundary
- last = next + "--"
+ next_boundary = b"--" + self.outerboundary
+ last_boundary = next_boundary + b"--"
last_line_lfend = True
- while 1:
+ while True:
line = self.fp.readline(1<<16)
+ self.bytes_read += len(line)
if not line:
self.done = -1
break
- if line[:2] == "--" and last_line_lfend:
+ if line.endswith(b"--") and last_line_lfend:
strippedline = line.strip()
- if strippedline == next:
+ if strippedline == next_boundary:
break
- if strippedline == last:
+ if strippedline == last_boundary:
self.done = 1
break
- last_line_lfend = line.endswith('\n')
+ last_line_lfend = line.endswith(b'\n')
- def make_file(self, binary=None):
+ def make_file(self):
"""Overridable: return a readable & writable file.
The file will be used as follows:
@@ -747,8 +828,8 @@ class FieldStorage:
- seek(0)
- data is read from it
- The 'binary' argument is unused -- the file is always opened
- in binary mode.
+ The file is opened in binary mode for files, in text mode
+ for other fields
This version opens a temporary file for reading and writing,
and immediately deletes (unlinks) it. The trick (on Unix!) is
@@ -763,117 +844,11 @@ class FieldStorage:
which unlinks the temporary files you have created.
"""
- import tempfile
- return tempfile.TemporaryFile("w+b")
-
-
-
-# Backwards Compatibility Classes
-# ===============================
-
-class FormContentDict(UserDict.UserDict):
- """Form content as dictionary with a list of values per field.
-
- form = FormContentDict()
-
- form[key] -> [value, value, ...]
- key in form -> Boolean
- form.keys() -> [key, key, ...]
- form.values() -> [[val, val, ...], [val, val, ...], ...]
- form.items() -> [(key, [val, val, ...]), (key, [val, val, ...]), ...]
- form.dict == {key: [val, val, ...], ...}
-
- """
- def __init__(self, environ=os.environ, keep_blank_values=0, strict_parsing=0):
- self.dict = self.data = parse(environ=environ,
- keep_blank_values=keep_blank_values,
- strict_parsing=strict_parsing)
- self.query_string = environ['QUERY_STRING']
-
-
-class SvFormContentDict(FormContentDict):
- """Form content as dictionary expecting a single value per field.
-
- If you only expect a single value for each field, then form[key]
- will return that single value. It will raise an IndexError if
- that expectation is not true. If you expect a field to have
- possible multiple values, than you can use form.getlist(key) to
- get all of the values. values() and items() are a compromise:
- they return single strings where there is a single value, and
- lists of strings otherwise.
-
- """
- def __getitem__(self, key):
- if len(self.dict[key]) > 1:
- raise IndexError, 'expecting a single value'
- return self.dict[key][0]
- def getlist(self, key):
- return self.dict[key]
- def values(self):
- result = []
- for value in self.dict.values():
- if len(value) == 1:
- result.append(value[0])
- else: result.append(value)
- return result
- def items(self):
- result = []
- for key, value in self.dict.items():
- if len(value) == 1:
- result.append((key, value[0]))
- else: result.append((key, value))
- return result
-
-
-class InterpFormContentDict(SvFormContentDict):
- """This class is present for backwards compatibility only."""
- def __getitem__(self, key):
- v = SvFormContentDict.__getitem__(self, key)
- if v[0] in '0123456789+-.':
- try: return int(v)
- except ValueError:
- try: return float(v)
- except ValueError: pass
- return v.strip()
- def values(self):
- result = []
- for key in self.keys():
- try:
- result.append(self[key])
- except IndexError:
- result.append(self.dict[key])
- return result
- def items(self):
- result = []
- for key in self.keys():
- try:
- result.append((key, self[key]))
- except IndexError:
- result.append((key, self.dict[key]))
- return result
-
-
-class FormContent(FormContentDict):
- """This class is present for backwards compatibility only."""
- def values(self, key):
- if key in self.dict :return self.dict[key]
- else: return None
- def indexed_value(self, key, location):
- if key in self.dict:
- if len(self.dict[key]) > location:
- return self.dict[key][location]
- else: return None
- else: return None
- def value(self, key):
- if key in self.dict: return self.dict[key][0]
- else: return None
- def length(self, key):
- return len(self.dict[key])
- def stripped(self, key):
- if key in self.dict: return self.dict[key][0].strip()
- else: return None
- def pars(self):
- return self.dict
+ if self._binary_file:
+ return tempfile.TemporaryFile("wb+")
+ else:
+ return tempfile.TemporaryFile("w+",
+ encoding=self.encoding, newline = '\n')
# Test/debug code
@@ -886,8 +861,8 @@ def test(environ=os.environ):
the script in HTML form.
"""
- print "Content-type: text/html"
- print
+ print("Content-type: text/html")
+ print()
sys.stderr = sys.stdout
try:
form = FieldStorage() # Replace with other classes to test those
@@ -897,15 +872,15 @@ def test(environ=os.environ):
print_environ(environ)
print_environ_usage()
def f():
- exec "testing print_exception() -- <I>italics?</I>"
+ exec("testing print_exception() -- <I>italics?</I>")
def g(f=f):
f()
- print "<H3>What follows is a test, not an actual exception:</H3>"
+ print("<H3>What follows is a test, not an actual exception:</H3>")
g()
except:
print_exception()
- print "<H1>Second try with a small maxlen...</H1>"
+ print("<H1>Second try with a small maxlen...</H1>")
global maxlen
maxlen = 50
@@ -922,67 +897,65 @@ def print_exception(type=None, value=None, tb=None, limit=None):
if type is None:
type, value, tb = sys.exc_info()
import traceback
- print
- print "<H3>Traceback (most recent call last):</H3>"
+ print()
+ print("<H3>Traceback (most recent call last):</H3>")
list = traceback.format_tb(tb, limit) + \
traceback.format_exception_only(type, value)
- print "<PRE>%s<B>%s</B></PRE>" % (
- escape("".join(list[:-1])),
- escape(list[-1]),
- )
+ print("<PRE>%s<B>%s</B></PRE>" % (
+ html.escape("".join(list[:-1])),
+ html.escape(list[-1]),
+ ))
del tb
def print_environ(environ=os.environ):
"""Dump the shell environment as HTML."""
- keys = environ.keys()
- keys.sort()
- print
- print "<H3>Shell Environment:</H3>"
- print "<DL>"
+ keys = sorted(environ.keys())
+ print()
+ print("<H3>Shell Environment:</H3>")
+ print("<DL>")
for key in keys:
- print "<DT>", escape(key), "<DD>", escape(environ[key])
- print "</DL>"
- print
+ print("<DT>", html.escape(key), "<DD>", html.escape(environ[key]))
+ print("</DL>")
+ print()
def print_form(form):
"""Dump the contents of a form as HTML."""
- keys = form.keys()
- keys.sort()
- print
- print "<H3>Form Contents:</H3>"
+ keys = sorted(form.keys())
+ print()
+ print("<H3>Form Contents:</H3>")
if not keys:
- print "<P>No form fields."
- print "<DL>"
+ print("<P>No form fields.")
+ print("<DL>")
for key in keys:
- print "<DT>" + escape(key) + ":",
+ print("<DT>" + html.escape(key) + ":", end=' ')
value = form[key]
- print "<i>" + escape(repr(type(value))) + "</i>"
- print "<DD>" + escape(repr(value))
- print "</DL>"
- print
+ print("<i>" + html.escape(repr(type(value))) + "</i>")
+ print("<DD>" + html.escape(repr(value)))
+ print("</DL>")
+ print()
def print_directory():
"""Dump the current directory as HTML."""
- print
- print "<H3>Current Working Directory:</H3>"
+ print()
+ print("<H3>Current Working Directory:</H3>")
try:
pwd = os.getcwd()
- except os.error, msg:
- print "os.error:", escape(str(msg))
+ except os.error as msg:
+ print("os.error:", html.escape(str(msg)))
else:
- print escape(pwd)
- print
+ print(html.escape(pwd))
+ print()
def print_arguments():
- print
- print "<H3>Command Line Arguments:</H3>"
- print
- print sys.argv
- print
+ print()
+ print("<H3>Command Line Arguments:</H3>")
+ print()
+ print(sys.argv)
+ print()
def print_environ_usage():
"""Dump a list of environment variables used by CGI as HTML."""
- print """
+ print("""
<H3>These environment variables could have been set:</H3>
<UL>
<LI>AUTH_TYPE
@@ -1021,16 +994,16 @@ environment as well. Here are some common variable names:
<LI>HTTP_REFERER
<LI>HTTP_USER_AGENT
</UL>
-"""
+""")
# Utilities
# =========
def escape(s, quote=None):
- '''Replace special characters "&", "<" and ">" to HTML-safe sequences.
- If the optional flag quote is true, the quotation mark character (")
- is also translated.'''
+ """Deprecated API."""
+ warn("cgi.escape is deprecated, use html.escape instead",
+ PendingDeprecationWarning, stacklevel=2)
s = s.replace("&", "&amp;") # Must be done first!
s = s.replace("<", "&lt;")
s = s.replace(">", "&gt;")
@@ -1038,8 +1011,13 @@ def escape(s, quote=None):
s = s.replace('"', "&quot;")
return s
-def valid_boundary(s, _vb_pattern="^[ -~]{0,200}[!-~]$"):
+
+def valid_boundary(s, _vb_pattern=None):
import re
+ if isinstance(s, bytes):
+ _vb_pattern = b"^[ -~]{0,200}[!-~]$"
+ else:
+ _vb_pattern = "^[ -~]{0,200}[!-~]$"
return re.match(_vb_pattern, s)
# Invoke mainline
diff --git a/Lib/cgitb.py b/Lib/cgitb.py
index 8acc4b75fe3..6da40e82ece 100644
--- a/Lib/cgitb.py
+++ b/Lib/cgitb.py
@@ -102,7 +102,7 @@ def scanvars(reader, frame, locals):
def html(einfo, context=5):
"""Return a nice HTML document describing a given traceback."""
etype, evalue, etb = einfo
- if type(etype) is types.ClassType:
+ if isinstance(etype, type):
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
@@ -172,11 +172,10 @@ function calls leading up to the error, in the order they occurred.</p>'''
exception = ['<p>%s: %s' % (strong(pydoc.html.escape(str(etype))),
pydoc.html.escape(str(evalue)))]
- if isinstance(evalue, BaseException):
- for name in dir(evalue):
- if name[:1] == '_': continue
- value = pydoc.html.repr(getattr(evalue, name))
- exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
+ for name in dir(evalue):
+ if name[:1] == '_': continue
+ value = pydoc.html.repr(getattr(evalue, name))
+ exception.append('\n<br>%s%s&nbsp;=\n%s' % (indent, name, value))
return head + ''.join(frames) + ''.join(exception) + '''
@@ -193,7 +192,7 @@ function calls leading up to the error, in the order they occurred.</p>'''
def text(einfo, context=5):
"""Return a plain text document describing a given traceback."""
etype, evalue, etb = einfo
- if type(etype) is types.ClassType:
+ if isinstance(etype, type):
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + ': ' + sys.executable
date = time.ctime(time.time())
@@ -243,10 +242,9 @@ function calls leading up to the error, in the order they occurred.
frames.append('\n%s\n' % '\n'.join(rows))
exception = ['%s: %s' % (str(etype), str(evalue))]
- if isinstance(evalue, BaseException):
- for name in dir(evalue):
- value = pydoc.text.repr(getattr(evalue, name))
- exception.append('\n%s%s = %s' % (" "*4, name, value))
+ for name in dir(evalue):
+ value = pydoc.text.repr(getattr(evalue, name))
+ exception.append('\n%s%s = %s' % (" "*4, name, value))
return head + ''.join(frames) + ''.join(exception) + '''
diff --git a/Lib/chunk.py b/Lib/chunk.py
index a8fbc1051f3..5863ed0846b 100644
--- a/Lib/chunk.py
+++ b/Lib/chunk.py
@@ -62,7 +62,7 @@ class Chunk:
if len(self.chunkname) < 4:
raise EOFError
try:
- self.chunksize = struct.unpack(strflag+'L', file.read(4))[0]
+ self.chunksize = struct.unpack_from(strflag+'L', file.read(4))[0]
except struct.error:
raise EOFError
if inclheader:
@@ -90,7 +90,7 @@ class Chunk:
def isatty(self):
if self.closed:
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
return False
def seek(self, pos, whence=0):
@@ -100,9 +100,9 @@ class Chunk:
"""
if self.closed:
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
if not self.seekable:
- raise IOError, "cannot seek"
+ raise IOError("cannot seek")
if whence == 1:
pos = pos + self.size_read
elif whence == 2:
@@ -114,7 +114,7 @@ class Chunk:
def tell(self):
if self.closed:
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
return self.size_read
def read(self, size=-1):
@@ -124,7 +124,7 @@ class Chunk:
"""
if self.closed:
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
if self.size_read >= self.chunksize:
return ''
if size < 0:
@@ -148,7 +148,7 @@ class Chunk:
"""
if self.closed:
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
if self.seekable:
try:
n = self.chunksize - self.size_read
diff --git a/Lib/cmd.py b/Lib/cmd.py
index 05ba7e3bc6b..859e91096d8 100644
--- a/Lib/cmd.py
+++ b/Lib/cmd.py
@@ -40,12 +40,9 @@ The data members `self.doc_header', `self.misc_header', and
`self.undoc_header' set the headers used for the help function's
listings of documented functions, miscellaneous topics, and undocumented
functions respectively.
-
-These interpreters use raw_input; thus, if the readline module is loaded,
-they automatically support Emacs-like command history and editing features.
"""
-import string
+import string, sys
__all__ = ["Cmd"]
@@ -87,7 +84,6 @@ class Cmd:
sys.stdin and sys.stdout are used.
"""
- import sys
if stdin is not None:
self.stdin = stdin
else:
@@ -127,7 +123,7 @@ class Cmd:
else:
if self.use_rawinput:
try:
- line = raw_input(self.prompt)
+ line = input(self.prompt)
except EOFError:
line = 'EOF'
else:
@@ -336,7 +332,7 @@ class Cmd:
cmds_undoc.append(cmd)
self.stdout.write("%s\n"%str(self.doc_leader))
self.print_topics(self.doc_header, cmds_doc, 15,80)
- self.print_topics(self.misc_header, help.keys(),15,80)
+ self.print_topics(self.misc_header, list(help.keys()),15,80)
self.print_topics(self.undoc_header, cmds_undoc, 15,80)
def print_topics(self, header, cmds, cmdlen, maxcol):
@@ -356,11 +352,12 @@ class Cmd:
if not list:
self.stdout.write("<empty>\n")
return
+
nonstrings = [i for i in range(len(list))
if not isinstance(list[i], str)]
if nonstrings:
- raise TypeError, ("list[i] not a string for i in %s" %
- ", ".join(map(str, nonstrings)))
+ raise TypeError("list[i] not a string for i in %s"
+ % ", ".join(map(str, nonstrings)))
size = len(list)
if size == 1:
self.stdout.write('%s\n'%str(list[0]))
diff --git a/Lib/code.py b/Lib/code.py
index 3b39d1b346f..605aede5ef1 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -12,19 +12,6 @@ from codeop import CommandCompiler, compile_command
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
"compile_command"]
-def softspace(file, newvalue):
- oldvalue = 0
- try:
- oldvalue = file.softspace
- except AttributeError:
- pass
- try:
- file.softspace = newvalue
- except (AttributeError, TypeError):
- # "attribute-less object" or "read-only attributes"
- pass
- return oldvalue
-
class InteractiveInterpreter:
"""Base class for InteractiveConsole.
@@ -100,14 +87,11 @@ class InteractiveInterpreter:
"""
try:
- exec code in self.locals
+ exec(code, self.locals)
except SystemExit:
raise
except:
self.showtraceback()
- else:
- if softspace(sys.stdout, 0):
- print
def showsyntaxerror(self, filename=None):
"""Display the syntax error that just occurred.
@@ -127,16 +111,16 @@ class InteractiveInterpreter:
if filename and type is SyntaxError:
# Work hard to stuff the correct filename in the exception
try:
- msg, (dummy_filename, lineno, offset, line) = value
- except:
+ msg, (dummy_filename, lineno, offset, line) = value.args
+ except ValueError:
# Not the format we expect; leave it alone
pass
else:
# Stuff in the right filename
value = SyntaxError(msg, (filename, lineno, offset, line))
sys.last_value = value
- list = traceback.format_exception_only(type, value)
- map(self.write, list)
+ lines = traceback.format_exception_only(type, value)
+ self.write(''.join(lines))
def showtraceback(self):
"""Display the exception that just occurred.
@@ -153,13 +137,13 @@ class InteractiveInterpreter:
sys.last_traceback = tb
tblist = traceback.extract_tb(tb)
del tblist[:1]
- list = traceback.format_list(tblist)
- if list:
- list.insert(0, "Traceback (most recent call last):\n")
- list[len(list):] = traceback.format_exception_only(type, value)
+ lines = traceback.format_list(tblist)
+ if lines:
+ lines.insert(0, "Traceback (most recent call last):\n")
+ lines.extend(traceback.format_exception_only(type, value))
finally:
tblist = tb = None
- map(self.write, list)
+ self.write(''.join(lines))
def write(self, data):
"""Write a string.
@@ -200,7 +184,7 @@ class InteractiveConsole(InteractiveInterpreter):
def interact(self, banner=None):
"""Closely emulate the interactive Python console.
- The optional banner argument specify the banner to print
+ The optional banner argument specifies the banner to print
before the first interaction; by default it prints a banner
similar to the one printed by the real Python interpreter,
followed by the current class name in parentheses (so as not
@@ -232,10 +216,6 @@ class InteractiveConsole(InteractiveInterpreter):
prompt = sys.ps1
try:
line = self.raw_input(prompt)
- # Can be None if sys.stdin was redefined
- encoding = getattr(sys.stdin, "encoding", None)
- if encoding and not isinstance(line, unicode):
- line = line.decode(encoding)
except EOFError:
self.write("\n")
break
@@ -274,11 +254,12 @@ class InteractiveConsole(InteractiveInterpreter):
When the user enters the EOF key sequence, EOFError is raised.
The base implementation uses the built-in function
- raw_input(); a subclass may replace this with a different
+ input(); a subclass may replace this with a different
implementation.
"""
- return raw_input(prompt)
+ return input(prompt)
+
def interact(banner=None, readfunc=None, local=None):
diff --git a/Lib/codecs.py b/Lib/codecs.py
index f4cd60a14f2..b150d64d53c 100644
--- a/Lib/codecs.py
+++ b/Lib/codecs.py
@@ -7,13 +7,13 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""#"
-import __builtin__, sys
+import builtins, sys
### Registry and builtin stateless codec functions
try:
from _codecs import *
-except ImportError, why:
+except ImportError as why:
raise SystemError('Failed to load the builtin codecs: %s' % why)
__all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE",
@@ -33,19 +33,19 @@ __all__ = ["register", "lookup", "open", "EncodedFile", "BOM", "BOM_BE",
#
# UTF-8
-BOM_UTF8 = '\xef\xbb\xbf'
+BOM_UTF8 = b'\xef\xbb\xbf'
# UTF-16, little endian
-BOM_LE = BOM_UTF16_LE = '\xff\xfe'
+BOM_LE = BOM_UTF16_LE = b'\xff\xfe'
# UTF-16, big endian
-BOM_BE = BOM_UTF16_BE = '\xfe\xff'
+BOM_BE = BOM_UTF16_BE = b'\xfe\xff'
# UTF-32, little endian
-BOM_UTF32_LE = '\xff\xfe\x00\x00'
+BOM_UTF32_LE = b'\xff\xfe\x00\x00'
# UTF-32, big endian
-BOM_UTF32_BE = '\x00\x00\xfe\xff'
+BOM_UTF32_BE = b'\x00\x00\xfe\xff'
if sys.byteorder == 'little':
@@ -87,7 +87,9 @@ class CodecInfo(tuple):
return self
def __repr__(self):
- return "<%s.%s object for encoding %s at 0x%x>" % (self.__class__.__module__, self.__class__.__name__, self.name, id(self))
+ return "<%s.%s object for encoding %s at 0x%x>" % \
+ (self.__class__.__module__, self.__class__.__name__,
+ self.name, id(self))
class Codec:
@@ -155,9 +157,9 @@ class Codec:
class IncrementalEncoder(object):
"""
- An IncrementalEncoder encodes an input in multiple steps. The input can be
- passed piece by piece to the encode() method. The IncrementalEncoder remembers
- the state of the Encoding process between calls to encode().
+ An IncrementalEncoder encodes an input in multiple steps. The input can
+ be passed piece by piece to the encode() method. The IncrementalEncoder
+ remembers the state of the encoding process between calls to encode().
"""
def __init__(self, errors='strict'):
"""
@@ -201,7 +203,8 @@ class BufferedIncrementalEncoder(IncrementalEncoder):
"""
def __init__(self, errors='strict'):
IncrementalEncoder.__init__(self, errors)
- self.buffer = "" # unencoded input that is kept between calls to encode()
+ # unencoded input that is kept between calls to encode()
+ self.buffer = ""
def _buffer_encode(self, input, errors, final):
# Overwrite this method in subclasses: It must encode input
@@ -228,13 +231,13 @@ class BufferedIncrementalEncoder(IncrementalEncoder):
class IncrementalDecoder(object):
"""
- An IncrementalDecoder decodes an input in multiple steps. The input can be
- passed piece by piece to the decode() method. The IncrementalDecoder
+ An IncrementalDecoder decodes an input in multiple steps. The input can
+ be passed piece by piece to the decode() method. The IncrementalDecoder
remembers the state of the decoding process between calls to decode().
"""
def __init__(self, errors='strict'):
"""
- Creates a IncrementalDecoder instance.
+ Create a IncrementalDecoder instance.
The IncrementalDecoder may use different error handling schemes by
providing the errors keyword argument. See the module docstring
@@ -244,13 +247,13 @@ class IncrementalDecoder(object):
def decode(self, input, final=False):
"""
- Decodes input and returns the resulting object.
+ Decode input and returns the resulting object.
"""
raise NotImplementedError
def reset(self):
"""
- Resets the decoder to the initial state.
+ Reset the decoder to the initial state.
"""
def getstate(self):
@@ -278,12 +281,13 @@ class IncrementalDecoder(object):
class BufferedIncrementalDecoder(IncrementalDecoder):
"""
This subclass of IncrementalDecoder can be used as the baseclass for an
- incremental decoder if the decoder must be able to handle incomplete byte
- sequences.
+ incremental decoder if the decoder must be able to handle incomplete
+ byte sequences.
"""
def __init__(self, errors='strict'):
IncrementalDecoder.__init__(self, errors)
- self.buffer = "" # undecoded input that is kept between calls to decode()
+ # undecoded input that is kept between calls to decode()
+ self.buffer = b""
def _buffer_decode(self, input, errors, final):
# Overwrite this method in subclasses: It must decode input
@@ -300,7 +304,7 @@ class BufferedIncrementalDecoder(IncrementalDecoder):
def reset(self):
IncrementalDecoder.reset(self)
- self.buffer = ""
+ self.buffer = b""
def getstate(self):
# additional state info is always 0
@@ -392,6 +396,8 @@ class StreamWriter(Codec):
class StreamReader(Codec):
+ charbuffertype = str
+
def __init__(self, stream, errors='strict'):
""" Creates a StreamReader instance.
@@ -412,10 +418,9 @@ class StreamReader(Codec):
"""
self.stream = stream
self.errors = errors
- self.bytebuffer = ""
- # For str->str decoding this will stay a str
- # For str->unicode decoding the first read will promote it to unicode
- self.charbuffer = ""
+ self.bytebuffer = b""
+ self._empty_charbuffer = self.charbuffertype()
+ self.charbuffer = self._empty_charbuffer
self.linebuffer = None
def decode(self, input, errors='strict'):
@@ -451,7 +456,7 @@ class StreamReader(Codec):
"""
# If we have lines cached, first merge them back into characters
if self.linebuffer:
- self.charbuffer = "".join(self.linebuffer)
+ self.charbuffer = self._empty_charbuffer.join(self.linebuffer)
self.linebuffer = None
# read until we get the required number of characters (if available)
@@ -475,9 +480,10 @@ class StreamReader(Codec):
data = self.bytebuffer + newdata
try:
newchars, decodedbytes = self.decode(data, self.errors)
- except UnicodeDecodeError, exc:
+ except UnicodeDecodeError as exc:
if firstline:
- newchars, decodedbytes = self.decode(data[:exc.start], self.errors)
+ newchars, decodedbytes = \
+ self.decode(data[:exc.start], self.errors)
lines = newchars.splitlines(True)
if len(lines)<=1:
raise
@@ -493,7 +499,7 @@ class StreamReader(Codec):
if chars < 0:
# Return everything we've got
result = self.charbuffer
- self.charbuffer = ""
+ self.charbuffer = self._empty_charbuffer
else:
# Return the first chars characters
result = self.charbuffer[:chars]
@@ -524,7 +530,7 @@ class StreamReader(Codec):
return line
readsize = size or 72
- line = ""
+ line = self._empty_charbuffer
# If size is given, we call read() only once
while True:
data = self.read(readsize, firstline=True)
@@ -532,7 +538,8 @@ class StreamReader(Codec):
# If we're at a "\r" read one extra character (which might
# be a "\n") to get a proper line ending. If the stream is
# temporarily exhausted we return the wrong line ending.
- if data.endswith("\r"):
+ if (isinstance(data, str) and data.endswith("\r")) or \
+ (isinstance(data, bytes) and data.endswith(b"\r")):
data += self.read(size=1, chars=1)
line += data
@@ -558,7 +565,8 @@ class StreamReader(Codec):
line0withoutend = lines[0].splitlines(False)[0]
if line0withend != line0withoutend: # We really have a line end
# Put the rest back together and keep it until the next call
- self.charbuffer = "".join(lines[1:]) + self.charbuffer
+ self.charbuffer = self._empty_charbuffer.join(lines[1:]) + \
+ self.charbuffer
if keepends:
line = line0withend
else:
@@ -569,7 +577,7 @@ class StreamReader(Codec):
if line and not keepends:
line = line.splitlines(False)[0]
break
- if readsize<8000:
+ if readsize < 8000:
readsize *= 2
return line
@@ -597,8 +605,8 @@ class StreamReader(Codec):
from decoding errors.
"""
- self.bytebuffer = ""
- self.charbuffer = u""
+ self.bytebuffer = b""
+ self.charbuffer = self._empty_charbuffer
self.linebuffer = None
def seek(self, offset, whence=0):
@@ -609,7 +617,7 @@ class StreamReader(Codec):
self.stream.seek(offset, whence)
self.reset()
- def next(self):
+ def __next__(self):
""" Return the next decoded line from the input stream."""
line = self.readline()
@@ -678,10 +686,10 @@ class StreamReaderWriter:
return self.reader.readlines(sizehint)
- def next(self):
+ def __next__(self):
""" Return the next decoded line from the input stream."""
- return self.reader.next()
+ return next(self.reader)
def __iter__(self):
return self
@@ -797,10 +805,10 @@ class StreamRecoder:
data, bytesencoded = self.encode(data, self.errors)
return data.splitlines(1)
- def next(self):
+ def __next__(self):
""" Return the next decoded line from the input stream."""
- data = self.reader.next()
+ data = next(self.reader)
data, bytesencoded = self.encode(data, self.errors)
return data
@@ -869,16 +877,11 @@ def open(filename, mode='rb', encoding=None, errors='strict', buffering=1):
parameter.
"""
- if encoding is not None:
- if 'U' in mode:
- # No automatic conversion of '\n' is done on reading and writing
- mode = mode.strip().replace('U', '')
- if mode[:1] not in set('rwa'):
- mode = 'r' + mode
- if 'b' not in mode:
- # Force opening of the file in binary mode
- mode = mode + 'b'
- file = __builtin__.open(filename, mode, buffering)
+ if encoding is not None and \
+ 'b' not in mode:
+ # Force opening of the file in binary mode
+ mode = mode + 'b'
+ file = builtins.open(filename, mode, buffering)
if encoding is None:
return file
info = lookup(encoding)
@@ -1025,7 +1028,7 @@ def iterdecode(iterator, encoding, errors='strict', **kwargs):
output = decoder.decode(input)
if output:
yield output
- output = decoder.decode("", True)
+ output = decoder.decode(b"", True)
if output:
yield output
diff --git a/Lib/codeop.py b/Lib/codeop.py
index 5616d92a858..fb759da42ad 100644
--- a/Lib/codeop.py
+++ b/Lib/codeop.py
@@ -80,23 +80,23 @@ def _maybe_compile(compiler, source, filename, symbol):
try:
code = compiler(source, filename, symbol)
- except SyntaxError, err:
+ except SyntaxError as err:
pass
try:
code1 = compiler(source + "\n", filename, symbol)
- except SyntaxError, err1:
- pass
+ except SyntaxError as e:
+ err1 = e
try:
code2 = compiler(source + "\n\n", filename, symbol)
- except SyntaxError, err2:
- pass
+ except SyntaxError as e:
+ err2 = e
if code:
return code
if not code1 and repr(err1) == repr(err2):
- raise SyntaxError, err1
+ raise err1
def _compile(source, filename, symbol):
return compile(source, filename, symbol, PyCF_DONT_IMPLY_DEDENT)
diff --git a/Lib/collections.py b/Lib/collections.py
index a0922412d7f..eb2024352de 100644
--- a/Lib/collections.py
+++ b/Lib/collections.py
@@ -1,4 +1,5 @@
-__all__ = ['Counter', 'deque', 'defaultdict', 'namedtuple', 'OrderedDict']
+__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList',
+ 'UserString', 'Counter', 'OrderedDict']
# For bootstrapping reasons, the collection ABCs are defined in _abcoll.py.
# They should however be considered an integral part of collections.py.
from _abcoll import *
@@ -6,23 +7,21 @@ import _abcoll
__all__ += _abcoll.__all__
from _collections import deque, defaultdict
-from operator import itemgetter as _itemgetter, eq as _eq
+from operator import itemgetter as _itemgetter
from keyword import iskeyword as _iskeyword
import sys as _sys
import heapq as _heapq
+from weakref import proxy as _proxy
from itertools import repeat as _repeat, chain as _chain, starmap as _starmap
-from itertools import imap as _imap
-
-try:
- from thread import get_ident as _get_ident
-except ImportError:
- from dummy_thread import get_ident as _get_ident
-
+from reprlib import recursive_repr as _recursive_repr
################################################################################
### OrderedDict
################################################################################
+class _Link(object):
+ __slots__ = 'prev', 'next', 'key', '__weakref__'
+
class OrderedDict(dict):
'Dictionary that remembers insertion order'
# An inherited dict maps keys to values.
@@ -33,7 +32,10 @@ class OrderedDict(dict):
# The internal self.__map dict maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
- # Each link is stored as a list of length three: [PREV, NEXT, KEY].
+ # The sentinel is in self.__hardroot with a weakref proxy in self.__root.
+ # The prev links are weakref proxies (to prevent circular references).
+ # Individual links are kept alive by the hard reference in self.__map.
+ # Those hard references disappear when a key is deleted from an OrderedDict.
def __init__(self, *args, **kwds):
'''Initialize an ordered dictionary. The signature is the same as
@@ -46,86 +48,123 @@ class OrderedDict(dict):
try:
self.__root
except AttributeError:
- self.__root = root = [] # sentinel node
- root[:] = [root, root, None]
+ self.__hardroot = _Link()
+ self.__root = root = _proxy(self.__hardroot)
+ root.prev = root.next = root
self.__map = {}
self.__update(*args, **kwds)
- def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
+ def __setitem__(self, key, value,
+ dict_setitem=dict.__setitem__, proxy=_proxy, Link=_Link):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link at the end of the linked list,
# and the inherited dictionary is updated with the new key/value pair.
if key not in self:
+ self.__map[key] = link = Link()
root = self.__root
- last = root[0]
- last[1] = root[0] = self.__map[key] = [last, root, key]
- return dict_setitem(self, key, value)
+ last = root.prev
+ link.prev, link.next, link.key = last, root, key
+ last.next = link
+ root.prev = proxy(link)
+ dict_setitem(self, key, value)
def __delitem__(self, key, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which gets
# removed by updating the links in the predecessor and successor nodes.
dict_delitem(self, key)
- link_prev, link_next, key = self.__map.pop(key)
- link_prev[1] = link_next # update link_prev[NEXT]
- link_next[0] = link_prev # update link_next[PREV]
+ link = self.__map.pop(key)
+ link_prev = link.prev
+ link_next = link.next
+ link_prev.next = link_next
+ link_next.prev = link_prev
def __iter__(self):
'od.__iter__() <==> iter(od)'
# Traverse the linked list in order.
root = self.__root
- curr = root[1] # start at the first node
+ curr = root.next
while curr is not root:
- yield curr[2] # yield the curr[KEY]
- curr = curr[1] # move to next node
+ yield curr.key
+ curr = curr.next
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
# Traverse the linked list in reverse order.
root = self.__root
- curr = root[0] # start at the last node
+ curr = root.prev
while curr is not root:
- yield curr[2] # yield the curr[KEY]
- curr = curr[0] # move to previous node
+ yield curr.key
+ curr = curr.prev
def clear(self):
'od.clear() -> None. Remove all items from od.'
root = self.__root
- root[:] = [root, root, None]
+ root.prev = root.next = root
self.__map.clear()
dict.clear(self)
- # -- the following methods do not depend on the internal structure --
-
- def keys(self):
- 'od.keys() -> list of keys in od'
- return list(self)
-
- def values(self):
- 'od.values() -> list of values in od'
- return [self[key] for key in self]
-
- def items(self):
- 'od.items() -> list of (key, value) pairs in od'
- return [(key, self[key]) for key in self]
-
- def iterkeys(self):
- 'od.iterkeys() -> an iterator over the keys in od'
- return iter(self)
+ def popitem(self, last=True):
+ '''od.popitem() -> (k, v), return and remove a (key, value) pair.
+ Pairs are returned in LIFO order if last is true or FIFO order if false.
- def itervalues(self):
- 'od.itervalues -> an iterator over the values in od'
- for k in self:
- yield self[k]
+ '''
+ if not self:
+ raise KeyError('dictionary is empty')
+ root = self.__root
+ if last:
+ link = root.prev
+ link_prev = link.prev
+ link_prev.next = root
+ root.prev = link_prev
+ else:
+ link = root.next
+ link_next = link.next
+ root.next = link_next
+ link_next.prev = root
+ key = link.key
+ del self.__map[key]
+ value = dict.pop(self, key)
+ return key, value
- def iteritems(self):
- 'od.iteritems -> an iterator over the (key, value) pairs in od'
- for k in self:
- yield (k, self[k])
+ def move_to_end(self, key, last=True):
+ '''Move an existing element to the end (or beginning if last==False).
- update = MutableMapping.update
+ Raises KeyError if the element does not exist.
+ When last=True, acts like a fast version of self[key]=self.pop(key).
- __update = update # let subclasses override update without breaking __init__
+ '''
+ link = self.__map[key]
+ link_prev = link.prev
+ link_next = link.next
+ link_prev.next = link_next
+ link_next.prev = link_prev
+ root = self.__root
+ if last:
+ last = root.prev
+ link.prev = last
+ link.next = root
+ last.next = root.prev = link
+ else:
+ first = root.next
+ link.prev = root
+ link.next = first
+ root.next = first.prev = link
+
+ def __sizeof__(self):
+ sizeof = _sys.getsizeof
+ n = len(self) + 1 # number of links including root
+ size = sizeof(self.__dict__) # instance dictionary
+ size += sizeof(self.__map) * 2 # internal dict and inherited dict
+ size += sizeof(self.__hardroot) * n # link objects
+ size += sizeof(self.__root) * n # proxy objects
+ return size
+
+ update = __update = MutableMapping.update
+ keys = MutableMapping.keys
+ values = MutableMapping.values
+ items = MutableMapping.items
+ __ne__ = MutableMapping.__ne__
__marker = object()
@@ -150,29 +189,12 @@ class OrderedDict(dict):
self[key] = default
return default
- def popitem(self, last=True):
- '''od.popitem() -> (k, v), return and remove a (key, value) pair.
- Pairs are returned in LIFO order if last is true or FIFO order if false.
-
- '''
- if not self:
- raise KeyError('dictionary is empty')
- key = next(reversed(self) if last else iter(self))
- value = self.pop(key)
- return key, value
-
- def __repr__(self, _repr_running={}):
+ @_recursive_repr()
+ def __repr__(self):
'od.__repr__() <==> repr(od)'
- call_key = id(self), _get_ident()
- if call_key in _repr_running:
- return '...'
- _repr_running[call_key] = 1
- try:
- if not self:
- return '%s()' % (self.__class__.__name__,)
- return '%s(%r)' % (self.__class__.__name__, self.items())
- finally:
- del _repr_running[call_key]
+ if not self:
+ return '%s()' % (self.__class__.__name__,)
+ return '%s(%r)' % (self.__class__.__name__, list(self.items()))
def __reduce__(self):
'Return state information for pickling'
@@ -205,33 +227,20 @@ class OrderedDict(dict):
'''
if isinstance(other, OrderedDict):
- return dict.__eq__(self, other) and all(_imap(_eq, self, other))
+ return len(self)==len(other) and \
+ all(p==q for p, q in zip(self.items(), other.items()))
return dict.__eq__(self, other)
- def __ne__(self, other):
- 'od.__ne__(y) <==> od!=y'
- return not self == other
-
- # -- the following methods support python 3.x style dictionary views --
-
- def viewkeys(self):
- "od.viewkeys() -> a set-like object providing a view on od's keys"
- return KeysView(self)
-
- def viewvalues(self):
- "od.viewvalues() -> an object providing a view on od's values"
- return ValuesView(self)
-
- def viewitems(self):
- "od.viewitems() -> a set-like object providing a view on od's items"
- return ItemsView(self)
-
################################################################################
### namedtuple
################################################################################
_class_template = '''\
+from builtins import property as _property, tuple as _tuple
+from operator import itemgetter as _itemgetter
+from collections import OrderedDict
+
class {typename}(tuple):
'{typename}({arg_list})'
@@ -253,7 +262,7 @@ class {typename}(tuple):
def __repr__(self):
'Return a nicely formatted representation string'
- return '{typename}({repr_fmt})' % self
+ return self.__class__.__name__ + '({repr_fmt})' % self
def _asdict(self):
'Return a new OrderedDict which maps field names to their values'
@@ -265,7 +274,7 @@ class {typename}(tuple):
'Return a new {typename} object replacing specified fields with new values'
result = _self._make(map(kwds.pop, {field_names!r}, _self))
if kwds:
- raise ValueError('Got unexpected field names: %r' % kwds.keys())
+ raise ValueError('Got unexpected field names: %r' % list(kwds))
return result
def __getnewargs__(self):
@@ -305,11 +314,11 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
"""
- # Validate the field names. At the user's option, either generate an error
- # message or automatically replace the field name with a valid name.
- if isinstance(field_names, basestring):
- field_names = field_names.replace(',', ' ').split()
- field_names = map(str, field_names)
+ # Parse and validate the field names. Validation serves two purposes,
+ # generating informative error messages and preventing template injection attacks.
+ if isinstance(field_names, str):
+ field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas
+ field_names = list(map(str, field_names))
if rename:
seen = set()
for index, name in enumerate(field_names):
@@ -323,19 +332,15 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
seen.add(name)
for name in [typename] + field_names:
if not all(c.isalnum() or c=='_' for c in name):
- raise ValueError('Type names and field names can only contain '
- 'alphanumeric characters and underscores: %r' % name)
+ raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name)
if _iskeyword(name):
- raise ValueError('Type names and field names cannot be a '
- 'keyword: %r' % name)
+ raise ValueError('Type names and field names cannot be a keyword: %r' % name)
if name[0].isdigit():
- raise ValueError('Type names and field names cannot start with '
- 'a number: %r' % name)
+ raise ValueError('Type names and field names cannot start with a number: %r' % name)
seen = set()
for name in field_names:
if name.startswith('_') and not rename:
- raise ValueError('Field names cannot start with an underscore: '
- '%r' % name)
+ raise ValueError('Field names cannot start with an underscore: %r' % name)
if name in seen:
raise ValueError('Encountered duplicate field name: %r' % name)
seen.add(name)
@@ -346,23 +351,21 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
field_names = tuple(field_names),
num_fields = len(field_names),
arg_list = repr(tuple(field_names)).replace("'", "")[1:-1],
- repr_fmt = ', '.join(_repr_template.format(name=name)
- for name in field_names),
+ repr_fmt = ', '.join(_repr_template.format(name=name) for name in field_names),
field_defs = '\n'.join(_field_template.format(index=index, name=name)
for index, name in enumerate(field_names))
)
- if verbose:
- print class_definition
- # Execute the template string in a temporary namespace and support
- # tracing utilities by setting a value for frame.f_globals['__name__']
- namespace = dict(_itemgetter=_itemgetter, __name__='namedtuple_%s' % typename,
- OrderedDict=OrderedDict, _property=property, _tuple=tuple)
+ # Execute the template string in a temporary namespace and
+ # support tracing utilities by setting a value for frame.f_globals['__name__']
+ namespace = dict(__name__='namedtuple_%s' % typename)
try:
- exec class_definition in namespace
+ exec(class_definition, namespace)
except SyntaxError as e:
- raise SyntaxError(e.message + ':\n' + class_definition)
+ raise SyntaxError(e.msg + ':\n\n' + class_definition)
result = namespace[typename]
+ if verbose:
+ print(class_definition)
# For pickling to work, the __module__ variable needs to be set to the frame
# where the named tuple is created. Bypass this step in enviroments where
@@ -380,6 +383,17 @@ def namedtuple(typename, field_names, verbose=False, rename=False):
### Counter
########################################################################
+def _count_elements(mapping, iterable):
+ 'Tally elements from the iterable.'
+ mapping_get = mapping.get
+ for elem in iterable:
+ mapping[elem] = mapping_get(elem, 0) + 1
+
+try: # Load C helper function if available
+ from _collections import _count_elements
+except ImportError:
+ pass
+
class Counter(dict):
'''Dict subclass for counting hashable items. Sometimes called a bag
or multiset. Elements are stored as dictionary keys and their counts
@@ -442,7 +456,7 @@ class Counter(dict):
>>> c = Counter(a=4, b=2) # a new counter from keyword args
'''
- super(Counter, self).__init__()
+ super().__init__()
self.update(iterable, **kwds)
def __missing__(self, key):
@@ -460,8 +474,8 @@ class Counter(dict):
'''
# Emulate Bag.sortedByCount from Smalltalk
if n is None:
- return sorted(self.iteritems(), key=_itemgetter(1), reverse=True)
- return _heapq.nlargest(n, self.iteritems(), key=_itemgetter(1))
+ return sorted(self.items(), key=_itemgetter(1), reverse=True)
+ return _heapq.nlargest(n, self.items(), key=_itemgetter(1))
def elements(self):
'''Iterator over elements repeating each as many times as its count.
@@ -483,7 +497,7 @@ class Counter(dict):
'''
# Emulate Bag.do from Smalltalk and Multiset.begin from C++.
- return _chain.from_iterable(_starmap(_repeat, self.iteritems()))
+ return _chain.from_iterable(_starmap(_repeat, self.items()))
# Override dict methods where necessary
@@ -518,14 +532,12 @@ class Counter(dict):
if isinstance(iterable, Mapping):
if self:
self_get = self.get
- for elem, count in iterable.iteritems():
- self[elem] = self_get(elem, 0) + count
+ for elem, count in iterable.items():
+ self[elem] = count + self_get(elem, 0)
else:
- super(Counter, self).update(iterable) # fast path when counter is empty
+ super().update(iterable) # fast path when counter is empty
else:
- self_get = self.get
- for elem in iterable:
- self[elem] = self_get(elem, 0) + 1
+ _count_elements(self, iterable)
if kwds:
self.update(kwds)
@@ -566,13 +578,17 @@ class Counter(dict):
def __delitem__(self, elem):
'Like dict.__delitem__() but does not raise KeyError for missing values.'
if elem in self:
- super(Counter, self).__delitem__(elem)
+ super().__delitem__(elem)
def __repr__(self):
if not self:
return '%s()' % self.__class__.__name__
- items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
- return '%s({%s})' % (self.__class__.__name__, items)
+ try:
+ items = ', '.join(map('%r: %r'.__mod__, self.most_common()))
+ return '%s({%s})' % (self.__class__.__name__, items)
+ except TypeError:
+ # handle case where values are not orderable
+ return '{0}({1!r})'.format(self.__class__.__name__, dict(self))
# Multiset-style mathematical operations discussed in:
# Knuth TAOCP Volume II section 4.6.3 exercise 19
@@ -659,9 +675,385 @@ class Counter(dict):
return result
+########################################################################
+### ChainMap (helper for configparser)
+########################################################################
+
+class _ChainMap(MutableMapping):
+ ''' A ChainMap groups multiple dicts (or other mappings) together
+ to create a single, updateable view.
+
+ The underlying mappings are stored in a list. That list is public and can
+ accessed or updated using the *maps* attribute. There is no other state.
+
+ Lookups search the underlying mappings successively until a key is found.
+ In contrast, writes, updates, and deletions only operate on the first
+ mapping.
+
+ '''
+
+ def __init__(self, *maps):
+ '''Initialize a ChainMap by setting *maps* to the given mappings.
+ If no mappings are provided, a single empty dictionary is used.
+
+ '''
+ self.maps = list(maps) or [{}] # always at least one map
+
+ def __missing__(self, key):
+ raise KeyError(key)
+
+ def __getitem__(self, key):
+ for mapping in self.maps:
+ try:
+ return mapping[key] # can't use 'key in mapping' with defaultdict
+ except KeyError:
+ pass
+ return self.__missing__(key) # support subclasses that define __missing__
+
+ def get(self, key, default=None):
+ return self[key] if key in self else default
+
+ def __len__(self):
+ return len(set().union(*self.maps)) # reuses stored hash values if possible
+
+ def __iter__(self):
+ return iter(set().union(*self.maps))
+
+ def __contains__(self, key):
+ return any(key in m for m in self.maps)
+
+ def __bool__(self):
+ return any(self.maps)
+
+ @_recursive_repr()
+ def __repr__(self):
+ return '{0.__class__.__name__}({1})'.format(
+ self, ', '.join(map(repr, self.maps)))
+
+ @classmethod
+ def fromkeys(cls, iterable, *args):
+ 'Create a ChainMap with a single dict created from the iterable.'
+ return cls(dict.fromkeys(iterable, *args))
+
+ def copy(self):
+ 'New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]'
+ return self.__class__(self.maps[0].copy(), *self.maps[1:])
+
+ __copy__ = copy
+
+ def new_child(self): # like Django's Context.push()
+ 'New ChainMap with a new dict followed by all previous maps.'
+ return self.__class__({}, *self.maps)
+
+ @property
+ def parents(self): # like Django's Context.pop()
+ 'New ChainMap from maps[1:].'
+ return self.__class__(*self.maps[1:])
+
+ def __setitem__(self, key, value):
+ self.maps[0][key] = value
+
+ def __delitem__(self, key):
+ try:
+ del self.maps[0][key]
+ except KeyError:
+ raise KeyError('Key not found in the first mapping: {!r}'.format(key))
+
+ def popitem(self):
+ 'Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.'
+ try:
+ return self.maps[0].popitem()
+ except KeyError:
+ raise KeyError('No keys found in the first mapping.')
+
+ def pop(self, key, *args):
+ 'Remove *key* from maps[0] and return its value. Raise KeyError if *key* not in maps[0].'
+ try:
+ return self.maps[0].pop(key, *args)
+ except KeyError:
+ raise KeyError('Key not found in the first mapping: {!r}'.format(key))
+
+ def clear(self):
+ 'Clear maps[0], leaving maps[1:] intact.'
+ self.maps[0].clear()
+
+
+################################################################################
+### UserDict
+################################################################################
+
+class UserDict(MutableMapping):
+
+ # Start by filling-out the abstract methods
+ def __init__(self, dict=None, **kwargs):
+ self.data = {}
+ if dict is not None:
+ self.update(dict)
+ if len(kwargs):
+ self.update(kwargs)
+ def __len__(self): return len(self.data)
+ def __getitem__(self, key):
+ if key in self.data:
+ return self.data[key]
+ if hasattr(self.__class__, "__missing__"):
+ return self.__class__.__missing__(self, key)
+ raise KeyError(key)
+ def __setitem__(self, key, item): self.data[key] = item
+ def __delitem__(self, key): del self.data[key]
+ def __iter__(self):
+ return iter(self.data)
+
+ # Modify __contains__ to work correctly when __missing__ is present
+ def __contains__(self, key):
+ return key in self.data
+
+ # Now, add the methods in dicts but not in MutableMapping
+ def __repr__(self): return repr(self.data)
+ def copy(self):
+ if self.__class__ is UserDict:
+ return UserDict(self.data.copy())
+ import copy
+ data = self.data
+ try:
+ self.data = {}
+ c = copy.copy(self)
+ finally:
+ self.data = data
+ c.update(self)
+ return c
+ @classmethod
+ def fromkeys(cls, iterable, value=None):
+ d = cls()
+ for key in iterable:
+ d[key] = value
+ return d
+
+
+
+################################################################################
+### UserList
+################################################################################
+
+class UserList(MutableSequence):
+ """A more or less complete user-defined wrapper around list objects."""
+ def __init__(self, initlist=None):
+ self.data = []
+ if initlist is not None:
+ # XXX should this accept an arbitrary sequence?
+ if type(initlist) == type(self.data):
+ self.data[:] = initlist
+ elif isinstance(initlist, UserList):
+ self.data[:] = initlist.data[:]
+ else:
+ self.data = list(initlist)
+ def __repr__(self): return repr(self.data)
+ def __lt__(self, other): return self.data < self.__cast(other)
+ def __le__(self, other): return self.data <= self.__cast(other)
+ def __eq__(self, other): return self.data == self.__cast(other)
+ def __ne__(self, other): return self.data != self.__cast(other)
+ def __gt__(self, other): return self.data > self.__cast(other)
+ def __ge__(self, other): return self.data >= self.__cast(other)
+ def __cast(self, other):
+ return other.data if isinstance(other, UserList) else other
+ def __contains__(self, item): return item in self.data
+ def __len__(self): return len(self.data)
+ def __getitem__(self, i): return self.data[i]
+ def __setitem__(self, i, item): self.data[i] = item
+ def __delitem__(self, i): del self.data[i]
+ def __add__(self, other):
+ if isinstance(other, UserList):
+ return self.__class__(self.data + other.data)
+ elif isinstance(other, type(self.data)):
+ return self.__class__(self.data + other)
+ return self.__class__(self.data + list(other))
+ def __radd__(self, other):
+ if isinstance(other, UserList):
+ return self.__class__(other.data + self.data)
+ elif isinstance(other, type(self.data)):
+ return self.__class__(other + self.data)
+ return self.__class__(list(other) + self.data)
+ def __iadd__(self, other):
+ if isinstance(other, UserList):
+ self.data += other.data
+ elif isinstance(other, type(self.data)):
+ self.data += other
+ else:
+ self.data += list(other)
+ return self
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__
+ def __imul__(self, n):
+ self.data *= n
+ return self
+ def append(self, item): self.data.append(item)
+ def insert(self, i, item): self.data.insert(i, item)
+ def pop(self, i=-1): return self.data.pop(i)
+ def remove(self, item): self.data.remove(item)
+ def count(self, item): return self.data.count(item)
+ def index(self, item, *args): return self.data.index(item, *args)
+ def reverse(self): self.data.reverse()
+ def sort(self, *args, **kwds): self.data.sort(*args, **kwds)
+ def extend(self, other):
+ if isinstance(other, UserList):
+ self.data.extend(other.data)
+ else:
+ self.data.extend(other)
+
+
+
+################################################################################
+### UserString
+################################################################################
+
+class UserString(Sequence):
+ def __init__(self, seq):
+ if isinstance(seq, str):
+ self.data = seq
+ elif isinstance(seq, UserString):
+ self.data = seq.data[:]
+ else:
+ self.data = str(seq)
+ def __str__(self): return str(self.data)
+ def __repr__(self): return repr(self.data)
+ def __int__(self): return int(self.data)
+ def __float__(self): return float(self.data)
+ def __complex__(self): return complex(self.data)
+ def __hash__(self): return hash(self.data)
+
+ def __eq__(self, string):
+ if isinstance(string, UserString):
+ return self.data == string.data
+ return self.data == string
+ def __ne__(self, string):
+ if isinstance(string, UserString):
+ return self.data != string.data
+ return self.data != string
+ def __lt__(self, string):
+ if isinstance(string, UserString):
+ return self.data < string.data
+ return self.data < string
+ def __le__(self, string):
+ if isinstance(string, UserString):
+ return self.data <= string.data
+ return self.data <= string
+ def __gt__(self, string):
+ if isinstance(string, UserString):
+ return self.data > string.data
+ return self.data > string
+ def __ge__(self, string):
+ if isinstance(string, UserString):
+ return self.data >= string.data
+ return self.data >= string
+
+ def __contains__(self, char):
+ if isinstance(char, UserString):
+ char = char.data
+ return char in self.data
+
+ def __len__(self): return len(self.data)
+ def __getitem__(self, index): return self.__class__(self.data[index])
+ def __add__(self, other):
+ if isinstance(other, UserString):
+ return self.__class__(self.data + other.data)
+ elif isinstance(other, str):
+ return self.__class__(self.data + other)
+ return self.__class__(self.data + str(other))
+ def __radd__(self, other):
+ if isinstance(other, str):
+ return self.__class__(other + self.data)
+ return self.__class__(str(other) + self.data)
+ def __mul__(self, n):
+ return self.__class__(self.data*n)
+ __rmul__ = __mul__
+ def __mod__(self, args):
+ return self.__class__(self.data % args)
+
+ # the following methods are defined in alphabetical order:
+ def capitalize(self): return self.__class__(self.data.capitalize())
+ def center(self, width, *args):
+ return self.__class__(self.data.center(width, *args))
+ def count(self, sub, start=0, end=_sys.maxsize):
+ if isinstance(sub, UserString):
+ sub = sub.data
+ return self.data.count(sub, start, end)
+ def encode(self, encoding=None, errors=None): # XXX improve this?
+ if encoding:
+ if errors:
+ return self.__class__(self.data.encode(encoding, errors))
+ return self.__class__(self.data.encode(encoding))
+ return self.__class__(self.data.encode())
+ def endswith(self, suffix, start=0, end=_sys.maxsize):
+ return self.data.endswith(suffix, start, end)
+ def expandtabs(self, tabsize=8):
+ return self.__class__(self.data.expandtabs(tabsize))
+ def find(self, sub, start=0, end=_sys.maxsize):
+ if isinstance(sub, UserString):
+ sub = sub.data
+ return self.data.find(sub, start, end)
+ def format(self, *args, **kwds):
+ return self.data.format(*args, **kwds)
+ def index(self, sub, start=0, end=_sys.maxsize):
+ return self.data.index(sub, start, end)
+ def isalpha(self): return self.data.isalpha()
+ def isalnum(self): return self.data.isalnum()
+ def isdecimal(self): return self.data.isdecimal()
+ def isdigit(self): return self.data.isdigit()
+ def isidentifier(self): return self.data.isidentifier()
+ def islower(self): return self.data.islower()
+ def isnumeric(self): return self.data.isnumeric()
+ def isspace(self): return self.data.isspace()
+ def istitle(self): return self.data.istitle()
+ def isupper(self): return self.data.isupper()
+ def join(self, seq): return self.data.join(seq)
+ def ljust(self, width, *args):
+ return self.__class__(self.data.ljust(width, *args))
+ def lower(self): return self.__class__(self.data.lower())
+ def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars))
+ def partition(self, sep):
+ return self.data.partition(sep)
+ def replace(self, old, new, maxsplit=-1):
+ if isinstance(old, UserString):
+ old = old.data
+ if isinstance(new, UserString):
+ new = new.data
+ return self.__class__(self.data.replace(old, new, maxsplit))
+ def rfind(self, sub, start=0, end=_sys.maxsize):
+ if isinstance(sub, UserString):
+ sub = sub.data
+ return self.data.rfind(sub, start, end)
+ def rindex(self, sub, start=0, end=_sys.maxsize):
+ return self.data.rindex(sub, start, end)
+ def rjust(self, width, *args):
+ return self.__class__(self.data.rjust(width, *args))
+ def rpartition(self, sep):
+ return self.data.rpartition(sep)
+ def rstrip(self, chars=None):
+ return self.__class__(self.data.rstrip(chars))
+ def split(self, sep=None, maxsplit=-1):
+ return self.data.split(sep, maxsplit)
+ def rsplit(self, sep=None, maxsplit=-1):
+ return self.data.rsplit(sep, maxsplit)
+ def splitlines(self, keepends=0): return self.data.splitlines(keepends)
+ def startswith(self, prefix, start=0, end=_sys.maxsize):
+ return self.data.startswith(prefix, start, end)
+ def strip(self, chars=None): return self.__class__(self.data.strip(chars))
+ def swapcase(self): return self.__class__(self.data.swapcase())
+ def title(self): return self.__class__(self.data.title())
+ def translate(self, *args):
+ return self.__class__(self.data.translate(*args))
+ def upper(self): return self.__class__(self.data.upper())
+ def zfill(self, width): return self.__class__(self.data.zfill(width))
+
+
+
+################################################################################
+### Simple tests
+################################################################################
+
if __name__ == '__main__':
# verify that instances can be pickled
- from cPickle import loads, dumps
+ from pickle import loads, dumps
Point = namedtuple('Point', 'x, y', True)
p = Point(x=10, y=20)
assert p == loads(dumps(p))
@@ -676,7 +1068,7 @@ if __name__ == '__main__':
return 'Point: x=%6.3f y=%6.3f hypot=%6.3f' % (self.x, self.y, self.hypot)
for p in Point(3, 4), Point(14, 5/7.):
- print p
+ print (p)
class Point(namedtuple('Point', 'x y')):
'Point class with optimized _make() and _replace() without error-checking'
@@ -685,11 +1077,11 @@ if __name__ == '__main__':
def _replace(self, _map=map, **kwds):
return self._make(_map(kwds.get, ('x', 'y'), self))
- print Point(11, 22)._replace(x=100)
+ print(Point(11, 22)._replace(x=100))
Point3D = namedtuple('Point3D', Point._fields + ('z',))
- print Point3D.__doc__
+ print(Point3D.__doc__)
import doctest
TestResults = namedtuple('TestResults', 'failed attempted')
- print TestResults(*doctest.testmod())
+ print(TestResults(*doctest.testmod()))
diff --git a/Lib/commands.py b/Lib/commands.py
deleted file mode 100644
index d0e8dd5fe93..00000000000
--- a/Lib/commands.py
+++ /dev/null
@@ -1,90 +0,0 @@
-"""Execute shell commands via os.popen() and return status, output.
-
-Interface summary:
-
- import commands
-
- outtext = commands.getoutput(cmd)
- (exitstatus, outtext) = commands.getstatusoutput(cmd)
- outtext = commands.getstatus(file) # returns output of "ls -ld file"
-
-A trailing newline is removed from the output string.
-
-Encapsulates the basic operation:
-
- pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
- text = pipe.read()
- sts = pipe.close()
-
- [Note: it would be nice to add functions to interpret the exit status.]
-"""
-from warnings import warnpy3k
-warnpy3k("the commands module has been removed in Python 3.0; "
- "use the subprocess module instead", stacklevel=2)
-del warnpy3k
-
-__all__ = ["getstatusoutput","getoutput","getstatus"]
-
-# Module 'commands'
-#
-# Various tools for executing commands and looking at their output and status.
-#
-# NB This only works (and is only relevant) for UNIX.
-
-
-# Get 'ls -l' status for an object into a string
-#
-def getstatus(file):
- """Return output of "ls -ld <file>" in a string."""
- import warnings
- warnings.warn("commands.getstatus() is deprecated", DeprecationWarning, 2)
- return getoutput('ls -ld' + mkarg(file))
-
-
-# Get the output from a shell command into a string.
-# The exit status is ignored; a trailing newline is stripped.
-# Assume the command will work with '{ ... ; } 2>&1' around it..
-#
-def getoutput(cmd):
- """Return output (stdout or stderr) of executing cmd in a shell."""
- return getstatusoutput(cmd)[1]
-
-
-# Ditto but preserving the exit status.
-# Returns a pair (sts, output)
-#
-def getstatusoutput(cmd):
- """Return (status, output) of executing cmd in a shell."""
- import os
- pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
- text = pipe.read()
- sts = pipe.close()
- if sts is None: sts = 0
- if text[-1:] == '\n': text = text[:-1]
- return sts, text
-
-
-# Make command argument from directory and pathname (prefix space, add quotes).
-#
-def mk2arg(head, x):
- import os
- return mkarg(os.path.join(head, x))
-
-
-# Make a shell command argument from a string.
-# Return a string beginning with a space followed by a shell-quoted
-# version of the argument.
-# Two strategies: enclose in single quotes if it contains none;
-# otherwise, enclose in double quotes and prefix quotable characters
-# with backslash.
-#
-def mkarg(x):
- if '\'' not in x:
- return ' \'' + x + '\''
- s = ' "'
- for c in x:
- if c in '\\$"`':
- s = s + '\\'
- s = s + c
- s = s + '"'
- return s
diff --git a/Lib/compileall.py b/Lib/compileall.py
index 5cfa8bed3f9..d3cff6a98ad 100644
--- a/Lib/compileall.py
+++ b/Lib/compileall.py
@@ -12,14 +12,15 @@ See module py_compile for details of the actual byte-compilation.
"""
import os
import sys
+import errno
+import imp
import py_compile
import struct
-import imp
__all__ = ["compile_dir","compile_file","compile_path"]
-def compile_dir(dir, maxlevels=10, ddir=None,
- force=0, rx=None, quiet=0):
+def compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None,
+ quiet=False, legacy=False, optimize=-1):
"""Byte-compile all modules in the given directory tree.
Arguments (only dir is required):
@@ -28,37 +29,41 @@ def compile_dir(dir, maxlevels=10, ddir=None,
maxlevels: maximum recursion level (default 10)
ddir: the directory that will be prepended to the path to the
file as it is compiled into each byte-code file.
- force: if 1, force compilation, even if timestamps are up-to-date
- quiet: if 1, be quiet during compilation
+ force: if True, force compilation, even if timestamps are up-to-date
+ quiet: if True, be quiet during compilation
+ legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
+ optimize: optimization level or -1 for level of the interpreter
"""
if not quiet:
- print 'Listing', dir, '...'
+ print('Listing {!r}...'.format(dir))
try:
names = os.listdir(dir)
except os.error:
- print "Can't list", dir
+ print("Can't list {!r}".format(dir))
names = []
names.sort()
success = 1
for name in names:
+ if name == '__pycache__':
+ continue
fullname = os.path.join(dir, name)
if ddir is not None:
dfile = os.path.join(ddir, name)
else:
dfile = None
if not os.path.isdir(fullname):
- if not compile_file(fullname, ddir, force, rx, quiet):
+ if not compile_file(fullname, ddir, force, rx, quiet,
+ legacy, optimize):
success = 0
- elif maxlevels > 0 and \
- name != os.curdir and name != os.pardir and \
- os.path.isdir(fullname) and \
- not os.path.islink(fullname):
+ elif (maxlevels > 0 and name != os.curdir and name != os.pardir and
+ os.path.isdir(fullname) and not os.path.islink(fullname)):
if not compile_dir(fullname, maxlevels - 1, dfile, force, rx,
- quiet):
+ quiet, legacy, optimize):
success = 0
return success
-def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
+def compile_file(fullname, ddir=None, force=False, rx=None, quiet=False,
+ legacy=False, optimize=-1):
"""Byte-compile one file.
Arguments (only fullname is required):
@@ -66,8 +71,10 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
fullname: the file to byte-compile
ddir: if given, the directory name compiled in to the
byte-code file.
- force: if 1, force compilation, even if timestamps are up-to-date
- quiet: if 1, be quiet during compilation
+ force: if True, force compilation, even if timestamps are up-to-date
+ quiet: if True, be quiet during compilation
+ legacy: if True, produce legacy pyc paths instead of PEP 3147 paths
+ optimize: optimization level or -1 for level of the interpreter
"""
success = 1
name = os.path.basename(fullname)
@@ -80,13 +87,21 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
if mo:
return success
if os.path.isfile(fullname):
+ if legacy:
+ cfile = fullname + ('c' if __debug__ else 'o')
+ else:
+ if optimize >= 0:
+ cfile = imp.cache_from_source(fullname,
+ debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(fullname)
+ cache_dir = os.path.dirname(cfile)
head, tail = name[:-3], name[-3:]
if tail == '.py':
if not force:
try:
mtime = int(os.stat(fullname).st_mtime)
expect = struct.pack('<4sl', imp.get_magic(), mtime)
- cfile = fullname + (__debug__ and 'c' or 'o')
with open(cfile, 'rb') as chandle:
actual = chandle.read(8)
if expect == actual:
@@ -94,133 +109,131 @@ def compile_file(fullname, ddir=None, force=0, rx=None, quiet=0):
except IOError:
pass
if not quiet:
- print 'Compiling', fullname, '...'
+ print('Compiling {!r}...'.format(fullname))
try:
- ok = py_compile.compile(fullname, None, dfile, True)
- except py_compile.PyCompileError,err:
+ ok = py_compile.compile(fullname, cfile, dfile, True,
+ optimize=optimize)
+ except py_compile.PyCompileError as err:
if quiet:
- print 'Compiling', fullname, '...'
- print err.msg
+ print('*** Error compiling {!r}...'.format(fullname))
+ else:
+ print('*** ', end='')
+ # escape non-printable characters in msg
+ msg = err.msg.encode(sys.stdout.encoding,
+ errors='backslashreplace')
+ msg = msg.decode(sys.stdout.encoding)
+ print(msg)
success = 0
- except IOError, e:
- print "Sorry", e
+ except (SyntaxError, UnicodeError, IOError) as e:
+ if quiet:
+ print('*** Error compiling {!r}...'.format(fullname))
+ else:
+ print('*** ', end='')
+ print(e.__class__.__name__ + ':', e)
success = 0
else:
if ok == 0:
success = 0
return success
-def compile_path(skip_curdir=1, maxlevels=0, force=0, quiet=0):
+def compile_path(skip_curdir=1, maxlevels=0, force=False, quiet=False,
+ legacy=False, optimize=-1):
"""Byte-compile all module on sys.path.
Arguments (all optional):
- skip_curdir: if true, skip current directory (default true)
+ skip_curdir: if true, skip current directory (default True)
maxlevels: max recursion level (default 0)
- force: as for compile_dir() (default 0)
- quiet: as for compile_dir() (default 0)
+ force: as for compile_dir() (default False)
+ quiet: as for compile_dir() (default False)
+ legacy: as for compile_dir() (default False)
+ optimize: as for compile_dir() (default -1)
"""
success = 1
for dir in sys.path:
if (not dir or dir == os.curdir) and skip_curdir:
- print 'Skipping current directory'
+ print('Skipping current directory')
else:
success = success and compile_dir(dir, maxlevels, None,
- force, quiet=quiet)
+ force, quiet=quiet,
+ legacy=legacy, optimize=optimize)
return success
-def expand_args(args, flist):
- """read names in flist and append to args"""
- expanded = args[:]
- if flist:
- try:
- if flist == '-':
- fd = sys.stdin
- else:
- fd = open(flist)
- while 1:
- line = fd.readline()
- if not line:
- break
- expanded.append(line[:-1])
- except IOError:
- print "Error reading file list %s" % flist
- raise
- return expanded
def main():
"""Script main program."""
- import getopt
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'lfqd:x:i:')
- except getopt.error, msg:
- print msg
- print "usage: python compileall.py [-l] [-f] [-q] [-d destdir] " \
- "[-x regexp] [-i list] [directory|file ...]"
- print
- print "arguments: zero or more file and directory names to compile; " \
- "if no arguments given, "
- print " defaults to the equivalent of -l sys.path"
- print
- print "options:"
- print "-l: don't recurse into subdirectories"
- print "-f: force rebuild even if timestamps are up-to-date"
- print "-q: output only error messages"
- print "-d destdir: directory to prepend to file paths for use in " \
- "compile-time tracebacks and in"
- print " runtime tracebacks in cases where the source " \
- "file is unavailable"
- print "-x regexp: skip files matching the regular expression regexp; " \
- "the regexp is searched for"
- print " in the full path of each file considered for " \
- "compilation"
- print "-i file: add all the files and directories listed in file to " \
- "the list considered for"
- print ' compilation; if "-", names are read from stdin'
-
- sys.exit(2)
- maxlevels = 10
- ddir = None
- force = 0
- quiet = 0
- rx = None
- flist = None
- for o, a in opts:
- if o == '-l': maxlevels = 0
- if o == '-d': ddir = a
- if o == '-f': force = 1
- if o == '-q': quiet = 1
- if o == '-x':
- import re
- rx = re.compile(a)
- if o == '-i': flist = a
- if ddir:
- if len(args) != 1 and not os.path.isdir(args[0]):
- print "-d destdir require exactly one directory argument"
- sys.exit(2)
- success = 1
+ import argparse
+
+ parser = argparse.ArgumentParser(
+ description='Utilities to support installing Python libraries.')
+ parser.add_argument('-l', action='store_const', const=0,
+ default=10, dest='maxlevels',
+ help="don't recurse into subdirectories")
+ parser.add_argument('-f', action='store_true', dest='force',
+ help='force rebuild even if timestamps are up to date')
+ parser.add_argument('-q', action='store_true', dest='quiet',
+ help='output only error messages')
+ parser.add_argument('-b', action='store_true', dest='legacy',
+ help='use legacy (pre-PEP3147) compiled file locations')
+ parser.add_argument('-d', metavar='DESTDIR', dest='ddir', default=None,
+ help=('directory to prepend to file paths for use in '
+ 'compile-time tracebacks and in runtime '
+ 'tracebacks in cases where the source file is '
+ 'unavailable'))
+ parser.add_argument('-x', metavar='REGEXP', dest='rx', default=None,
+ help=('skip files matching the regular expression; '
+ 'the regexp is searched for in the full path '
+ 'of each file considered for compilation'))
+ parser.add_argument('-i', metavar='FILE', dest='flist',
+ help=('add all the files and directories listed in '
+ 'FILE to the list considered for compilation; '
+ 'if "-", names are read from stdin'))
+ parser.add_argument('compile_dest', metavar='FILE|DIR', nargs='*',
+ help=('zero or more file and directory names '
+ 'to compile; if no arguments given, defaults '
+ 'to the equivalent of -l sys.path'))
+ args = parser.parse_args()
+
+ compile_dests = args.compile_dest
+
+ if (args.ddir and (len(compile_dests) != 1
+ or not os.path.isdir(compile_dests[0]))):
+ parser.exit('-d destdir requires exactly one directory argument')
+ if args.rx:
+ import re
+ args.rx = re.compile(args.rx)
+
+ # if flist is provided then load it
+ if args.flist:
+ try:
+ with (sys.stdin if args.flist=='-' else open(args.flist)) as f:
+ for line in f:
+ compile_dests.append(line.strip())
+ except EnvironmentError:
+ print("Error reading file list {}".format(args.flist))
+ return False
+
+ success = True
try:
- if args or flist:
- try:
- if flist:
- args = expand_args(args, flist)
- except IOError:
- success = 0
- if success:
- for arg in args:
- if os.path.isdir(arg):
- if not compile_dir(arg, maxlevels, ddir,
- force, rx, quiet):
- success = 0
- else:
- if not compile_file(arg, ddir, force, rx, quiet):
- success = 0
+ if compile_dests:
+ for dest in compile_dests:
+ if os.path.isfile(dest):
+ if not compile_file(dest, args.ddir, args.force, args.rx,
+ args.quiet, args.legacy):
+ success = False
+ else:
+ if not compile_dir(dest, args.maxlevels, args.ddir,
+ args.force, args.rx, args.quiet,
+ args.legacy):
+ success = False
+ return success
else:
- success = compile_path()
+ return compile_path(legacy=args.legacy)
except KeyboardInterrupt:
- print "\n[interrupted]"
- success = 0
- return success
+ print("\n[interrupted]")
+ return False
+ return True
+
if __name__ == '__main__':
exit_status = int(not main())
diff --git a/Lib/compiler/__init__.py b/Lib/compiler/__init__.py
deleted file mode 100644
index 2a6f64fa509..00000000000
--- a/Lib/compiler/__init__.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""Package for parsing and compiling Python source code
-
-There are several functions defined at the top level that are imported
-from modules contained in the package.
-
-parse(buf, mode="exec") -> AST
- Converts a string containing Python source code to an abstract
- syntax tree (AST). The AST is defined in compiler.ast.
-
-parseFile(path) -> AST
- The same as parse(open(path))
-
-walk(ast, visitor, verbose=None)
- Does a pre-order walk over the ast using the visitor instance.
- See compiler.visitor for details.
-
-compile(source, filename, mode, flags=None, dont_inherit=None)
- Returns a code object. A replacement for the builtin compile() function.
-
-compileFile(filename)
- Generates a .pyc file by compiling filename.
-"""
-
-import warnings
-
-warnings.warn("The compiler package is deprecated and removed in Python 3.x.",
- DeprecationWarning, stacklevel=2)
-
-from compiler.transformer import parse, parseFile
-from compiler.visitor import walk
-from compiler.pycodegen import compile, compileFile
diff --git a/Lib/compiler/ast.py b/Lib/compiler/ast.py
deleted file mode 100644
index 4c3fc161d39..00000000000
--- a/Lib/compiler/ast.py
+++ /dev/null
@@ -1,1419 +0,0 @@
-"""Python abstract syntax node definitions
-
-This file is automatically generated by Tools/compiler/astgen.py
-"""
-from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
-
-def flatten(seq):
- l = []
- for elt in seq:
- t = type(elt)
- if t is tuple or t is list:
- for elt2 in flatten(elt):
- l.append(elt2)
- else:
- l.append(elt)
- return l
-
-def flatten_nodes(seq):
- return [n for n in flatten(seq) if isinstance(n, Node)]
-
-nodes = {}
-
-class Node:
- """Abstract base class for ast nodes."""
- def getChildren(self):
- pass # implemented by subclasses
- def __iter__(self):
- for n in self.getChildren():
- yield n
- def asList(self): # for backwards compatibility
- return self.getChildren()
- def getChildNodes(self):
- pass # implemented by subclasses
-
-class EmptyNode(Node):
- pass
-
-class Expression(Node):
- # Expression is an artificial node class to support "eval"
- nodes["expression"] = "Expression"
- def __init__(self, node):
- self.node = node
-
- def getChildren(self):
- return self.node,
-
- def getChildNodes(self):
- return self.node,
-
- def __repr__(self):
- return "Expression(%s)" % (repr(self.node))
-
-class Add(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Add((%s, %s))" % (repr(self.left), repr(self.right))
-
-class And(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "And(%s)" % (repr(self.nodes),)
-
-class AssAttr(Node):
- def __init__(self, expr, attrname, flags, lineno=None):
- self.expr = expr
- self.attrname = attrname
- self.flags = flags
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr, self.attrname, self.flags
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "AssAttr(%s, %s, %s)" % (repr(self.expr), repr(self.attrname), repr(self.flags))
-
-class AssList(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "AssList(%s)" % (repr(self.nodes),)
-
-class AssName(Node):
- def __init__(self, name, flags, lineno=None):
- self.name = name
- self.flags = flags
- self.lineno = lineno
-
- def getChildren(self):
- return self.name, self.flags
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "AssName(%s, %s)" % (repr(self.name), repr(self.flags))
-
-class AssTuple(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "AssTuple(%s)" % (repr(self.nodes),)
-
-class Assert(Node):
- def __init__(self, test, fail, lineno=None):
- self.test = test
- self.fail = fail
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.test)
- children.append(self.fail)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.test)
- if self.fail is not None:
- nodelist.append(self.fail)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Assert(%s, %s)" % (repr(self.test), repr(self.fail))
-
-class Assign(Node):
- def __init__(self, nodes, expr, lineno=None):
- self.nodes = nodes
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.nodes))
- children.append(self.expr)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- nodelist.append(self.expr)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Assign(%s, %s)" % (repr(self.nodes), repr(self.expr))
-
-class AugAssign(Node):
- def __init__(self, node, op, expr, lineno=None):
- self.node = node
- self.op = op
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.node, self.op, self.expr
-
- def getChildNodes(self):
- return self.node, self.expr
-
- def __repr__(self):
- return "AugAssign(%s, %s, %s)" % (repr(self.node), repr(self.op), repr(self.expr))
-
-class Backquote(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Backquote(%s)" % (repr(self.expr),)
-
-class Bitand(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Bitand(%s)" % (repr(self.nodes),)
-
-class Bitor(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Bitor(%s)" % (repr(self.nodes),)
-
-class Bitxor(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Bitxor(%s)" % (repr(self.nodes),)
-
-class Break(Node):
- def __init__(self, lineno=None):
- self.lineno = lineno
-
- def getChildren(self):
- return ()
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Break()"
-
-class CallFunc(Node):
- def __init__(self, node, args, star_args = None, dstar_args = None, lineno=None):
- self.node = node
- self.args = args
- self.star_args = star_args
- self.dstar_args = dstar_args
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.node)
- children.extend(flatten(self.args))
- children.append(self.star_args)
- children.append(self.dstar_args)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.node)
- nodelist.extend(flatten_nodes(self.args))
- if self.star_args is not None:
- nodelist.append(self.star_args)
- if self.dstar_args is not None:
- nodelist.append(self.dstar_args)
- return tuple(nodelist)
-
- def __repr__(self):
- return "CallFunc(%s, %s, %s, %s)" % (repr(self.node), repr(self.args), repr(self.star_args), repr(self.dstar_args))
-
-class Class(Node):
- def __init__(self, name, bases, doc, code, decorators = None, lineno=None):
- self.name = name
- self.bases = bases
- self.doc = doc
- self.code = code
- self.decorators = decorators
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.name)
- children.extend(flatten(self.bases))
- children.append(self.doc)
- children.append(self.code)
- children.append(self.decorators)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.bases))
- nodelist.append(self.code)
- if self.decorators is not None:
- nodelist.append(self.decorators)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Class(%s, %s, %s, %s, %s)" % (repr(self.name), repr(self.bases), repr(self.doc), repr(self.code), repr(self.decorators))
-
-class Compare(Node):
- def __init__(self, expr, ops, lineno=None):
- self.expr = expr
- self.ops = ops
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.extend(flatten(self.ops))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- nodelist.extend(flatten_nodes(self.ops))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Compare(%s, %s)" % (repr(self.expr), repr(self.ops))
-
-class Const(Node):
- def __init__(self, value, lineno=None):
- self.value = value
- self.lineno = lineno
-
- def getChildren(self):
- return self.value,
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Const(%s)" % (repr(self.value),)
-
-class Continue(Node):
- def __init__(self, lineno=None):
- self.lineno = lineno
-
- def getChildren(self):
- return ()
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Continue()"
-
-class Decorators(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Decorators(%s)" % (repr(self.nodes),)
-
-class Dict(Node):
- def __init__(self, items, lineno=None):
- self.items = items
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.items))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.items))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Dict(%s)" % (repr(self.items),)
-
-class Discard(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Discard(%s)" % (repr(self.expr),)
-
-class Div(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Div((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Ellipsis(Node):
- def __init__(self, lineno=None):
- self.lineno = lineno
-
- def getChildren(self):
- return ()
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Ellipsis()"
-
-class Exec(Node):
- def __init__(self, expr, locals, globals, lineno=None):
- self.expr = expr
- self.locals = locals
- self.globals = globals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.append(self.locals)
- children.append(self.globals)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- if self.locals is not None:
- nodelist.append(self.locals)
- if self.globals is not None:
- nodelist.append(self.globals)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Exec(%s, %s, %s)" % (repr(self.expr), repr(self.locals), repr(self.globals))
-
-class FloorDiv(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "FloorDiv((%s, %s))" % (repr(self.left), repr(self.right))
-
-class For(Node):
- def __init__(self, assign, list, body, else_, lineno=None):
- self.assign = assign
- self.list = list
- self.body = body
- self.else_ = else_
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.assign)
- children.append(self.list)
- children.append(self.body)
- children.append(self.else_)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.assign)
- nodelist.append(self.list)
- nodelist.append(self.body)
- if self.else_ is not None:
- nodelist.append(self.else_)
- return tuple(nodelist)
-
- def __repr__(self):
- return "For(%s, %s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.body), repr(self.else_))
-
-class From(Node):
- def __init__(self, modname, names, level, lineno=None):
- self.modname = modname
- self.names = names
- self.level = level
- self.lineno = lineno
-
- def getChildren(self):
- return self.modname, self.names, self.level
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "From(%s, %s, %s)" % (repr(self.modname), repr(self.names), repr(self.level))
-
-class Function(Node):
- def __init__(self, decorators, name, argnames, defaults, flags, doc, code, lineno=None):
- self.decorators = decorators
- self.name = name
- self.argnames = argnames
- self.defaults = defaults
- self.flags = flags
- self.doc = doc
- self.code = code
- self.lineno = lineno
- self.varargs = self.kwargs = None
- if flags & CO_VARARGS:
- self.varargs = 1
- if flags & CO_VARKEYWORDS:
- self.kwargs = 1
-
-
- def getChildren(self):
- children = []
- children.append(self.decorators)
- children.append(self.name)
- children.append(self.argnames)
- children.extend(flatten(self.defaults))
- children.append(self.flags)
- children.append(self.doc)
- children.append(self.code)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- if self.decorators is not None:
- nodelist.append(self.decorators)
- nodelist.extend(flatten_nodes(self.defaults))
- nodelist.append(self.code)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Function(%s, %s, %s, %s, %s, %s, %s)" % (repr(self.decorators), repr(self.name), repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.doc), repr(self.code))
-
-class GenExpr(Node):
- def __init__(self, code, lineno=None):
- self.code = code
- self.lineno = lineno
- self.argnames = ['.0']
- self.varargs = self.kwargs = None
-
-
- def getChildren(self):
- return self.code,
-
- def getChildNodes(self):
- return self.code,
-
- def __repr__(self):
- return "GenExpr(%s)" % (repr(self.code),)
-
-class GenExprFor(Node):
- def __init__(self, assign, iter, ifs, lineno=None):
- self.assign = assign
- self.iter = iter
- self.ifs = ifs
- self.lineno = lineno
- self.is_outmost = False
-
- def getChildren(self):
- children = []
- children.append(self.assign)
- children.append(self.iter)
- children.extend(flatten(self.ifs))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.assign)
- nodelist.append(self.iter)
- nodelist.extend(flatten_nodes(self.ifs))
- return tuple(nodelist)
-
- def __repr__(self):
- return "GenExprFor(%s, %s, %s)" % (repr(self.assign), repr(self.iter), repr(self.ifs))
-
-class GenExprIf(Node):
- def __init__(self, test, lineno=None):
- self.test = test
- self.lineno = lineno
-
- def getChildren(self):
- return self.test,
-
- def getChildNodes(self):
- return self.test,
-
- def __repr__(self):
- return "GenExprIf(%s)" % (repr(self.test),)
-
-class GenExprInner(Node):
- def __init__(self, expr, quals, lineno=None):
- self.expr = expr
- self.quals = quals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.extend(flatten(self.quals))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- nodelist.extend(flatten_nodes(self.quals))
- return tuple(nodelist)
-
- def __repr__(self):
- return "GenExprInner(%s, %s)" % (repr(self.expr), repr(self.quals))
-
-class Getattr(Node):
- def __init__(self, expr, attrname, lineno=None):
- self.expr = expr
- self.attrname = attrname
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr, self.attrname
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Getattr(%s, %s)" % (repr(self.expr), repr(self.attrname))
-
-class Global(Node):
- def __init__(self, names, lineno=None):
- self.names = names
- self.lineno = lineno
-
- def getChildren(self):
- return self.names,
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Global(%s)" % (repr(self.names),)
-
-class If(Node):
- def __init__(self, tests, else_, lineno=None):
- self.tests = tests
- self.else_ = else_
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.tests))
- children.append(self.else_)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.tests))
- if self.else_ is not None:
- nodelist.append(self.else_)
- return tuple(nodelist)
-
- def __repr__(self):
- return "If(%s, %s)" % (repr(self.tests), repr(self.else_))
-
-class IfExp(Node):
- def __init__(self, test, then, else_, lineno=None):
- self.test = test
- self.then = then
- self.else_ = else_
- self.lineno = lineno
-
- def getChildren(self):
- return self.test, self.then, self.else_
-
- def getChildNodes(self):
- return self.test, self.then, self.else_
-
- def __repr__(self):
- return "IfExp(%s, %s, %s)" % (repr(self.test), repr(self.then), repr(self.else_))
-
-class Import(Node):
- def __init__(self, names, lineno=None):
- self.names = names
- self.lineno = lineno
-
- def getChildren(self):
- return self.names,
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Import(%s)" % (repr(self.names),)
-
-class Invert(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Invert(%s)" % (repr(self.expr),)
-
-class Keyword(Node):
- def __init__(self, name, expr, lineno=None):
- self.name = name
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.name, self.expr
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Keyword(%s, %s)" % (repr(self.name), repr(self.expr))
-
-class Lambda(Node):
- def __init__(self, argnames, defaults, flags, code, lineno=None):
- self.argnames = argnames
- self.defaults = defaults
- self.flags = flags
- self.code = code
- self.lineno = lineno
- self.varargs = self.kwargs = None
- if flags & CO_VARARGS:
- self.varargs = 1
- if flags & CO_VARKEYWORDS:
- self.kwargs = 1
-
-
- def getChildren(self):
- children = []
- children.append(self.argnames)
- children.extend(flatten(self.defaults))
- children.append(self.flags)
- children.append(self.code)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.defaults))
- nodelist.append(self.code)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Lambda(%s, %s, %s, %s)" % (repr(self.argnames), repr(self.defaults), repr(self.flags), repr(self.code))
-
-class LeftShift(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "LeftShift((%s, %s))" % (repr(self.left), repr(self.right))
-
-class List(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "List(%s)" % (repr(self.nodes),)
-
-class ListComp(Node):
- def __init__(self, expr, quals, lineno=None):
- self.expr = expr
- self.quals = quals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.extend(flatten(self.quals))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- nodelist.extend(flatten_nodes(self.quals))
- return tuple(nodelist)
-
- def __repr__(self):
- return "ListComp(%s, %s)" % (repr(self.expr), repr(self.quals))
-
-class ListCompFor(Node):
- def __init__(self, assign, list, ifs, lineno=None):
- self.assign = assign
- self.list = list
- self.ifs = ifs
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.assign)
- children.append(self.list)
- children.extend(flatten(self.ifs))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.assign)
- nodelist.append(self.list)
- nodelist.extend(flatten_nodes(self.ifs))
- return tuple(nodelist)
-
- def __repr__(self):
- return "ListCompFor(%s, %s, %s)" % (repr(self.assign), repr(self.list), repr(self.ifs))
-
-class ListCompIf(Node):
- def __init__(self, test, lineno=None):
- self.test = test
- self.lineno = lineno
-
- def getChildren(self):
- return self.test,
-
- def getChildNodes(self):
- return self.test,
-
- def __repr__(self):
- return "ListCompIf(%s)" % (repr(self.test),)
-
-class SetComp(Node):
- def __init__(self, expr, quals, lineno=None):
- self.expr = expr
- self.quals = quals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.extend(flatten(self.quals))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- nodelist.extend(flatten_nodes(self.quals))
- return tuple(nodelist)
-
- def __repr__(self):
- return "SetComp(%s, %s)" % (repr(self.expr), repr(self.quals))
-
-class DictComp(Node):
- def __init__(self, key, value, quals, lineno=None):
- self.key = key
- self.value = value
- self.quals = quals
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.key)
- children.append(self.value)
- children.extend(flatten(self.quals))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.key)
- nodelist.append(self.value)
- nodelist.extend(flatten_nodes(self.quals))
- return tuple(nodelist)
-
- def __repr__(self):
- return "DictComp(%s, %s, %s)" % (repr(self.key), repr(self.value), repr(self.quals))
-
-class Mod(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Mod((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Module(Node):
- def __init__(self, doc, node, lineno=None):
- self.doc = doc
- self.node = node
- self.lineno = lineno
-
- def getChildren(self):
- return self.doc, self.node
-
- def getChildNodes(self):
- return self.node,
-
- def __repr__(self):
- return "Module(%s, %s)" % (repr(self.doc), repr(self.node))
-
-class Mul(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Mul((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Name(Node):
- def __init__(self, name, lineno=None):
- self.name = name
- self.lineno = lineno
-
- def getChildren(self):
- return self.name,
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Name(%s)" % (repr(self.name),)
-
-class Not(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "Not(%s)" % (repr(self.expr),)
-
-class Or(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Or(%s)" % (repr(self.nodes),)
-
-class Pass(Node):
- def __init__(self, lineno=None):
- self.lineno = lineno
-
- def getChildren(self):
- return ()
-
- def getChildNodes(self):
- return ()
-
- def __repr__(self):
- return "Pass()"
-
-class Power(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Power((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Print(Node):
- def __init__(self, nodes, dest, lineno=None):
- self.nodes = nodes
- self.dest = dest
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.nodes))
- children.append(self.dest)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- if self.dest is not None:
- nodelist.append(self.dest)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Print(%s, %s)" % (repr(self.nodes), repr(self.dest))
-
-class Printnl(Node):
- def __init__(self, nodes, dest, lineno=None):
- self.nodes = nodes
- self.dest = dest
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.extend(flatten(self.nodes))
- children.append(self.dest)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- if self.dest is not None:
- nodelist.append(self.dest)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Printnl(%s, %s)" % (repr(self.nodes), repr(self.dest))
-
-class Raise(Node):
- def __init__(self, expr1, expr2, expr3, lineno=None):
- self.expr1 = expr1
- self.expr2 = expr2
- self.expr3 = expr3
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr1)
- children.append(self.expr2)
- children.append(self.expr3)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- if self.expr1 is not None:
- nodelist.append(self.expr1)
- if self.expr2 is not None:
- nodelist.append(self.expr2)
- if self.expr3 is not None:
- nodelist.append(self.expr3)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Raise(%s, %s, %s)" % (repr(self.expr1), repr(self.expr2), repr(self.expr3))
-
-class Return(Node):
- def __init__(self, value, lineno=None):
- self.value = value
- self.lineno = lineno
-
- def getChildren(self):
- return self.value,
-
- def getChildNodes(self):
- return self.value,
-
- def __repr__(self):
- return "Return(%s)" % (repr(self.value),)
-
-class RightShift(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "RightShift((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Set(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Set(%s)" % (repr(self.nodes),)
-
-class Slice(Node):
- def __init__(self, expr, flags, lower, upper, lineno=None):
- self.expr = expr
- self.flags = flags
- self.lower = lower
- self.upper = upper
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.append(self.flags)
- children.append(self.lower)
- children.append(self.upper)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- if self.lower is not None:
- nodelist.append(self.lower)
- if self.upper is not None:
- nodelist.append(self.upper)
- return tuple(nodelist)
-
- def __repr__(self):
- return "Slice(%s, %s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.lower), repr(self.upper))
-
-class Sliceobj(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Sliceobj(%s)" % (repr(self.nodes),)
-
-class Stmt(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Stmt(%s)" % (repr(self.nodes),)
-
-class Sub(Node):
- def __init__(self, leftright, lineno=None):
- self.left = leftright[0]
- self.right = leftright[1]
- self.lineno = lineno
-
- def getChildren(self):
- return self.left, self.right
-
- def getChildNodes(self):
- return self.left, self.right
-
- def __repr__(self):
- return "Sub((%s, %s))" % (repr(self.left), repr(self.right))
-
-class Subscript(Node):
- def __init__(self, expr, flags, subs, lineno=None):
- self.expr = expr
- self.flags = flags
- self.subs = subs
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.append(self.flags)
- children.extend(flatten(self.subs))
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- nodelist.extend(flatten_nodes(self.subs))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Subscript(%s, %s, %s)" % (repr(self.expr), repr(self.flags), repr(self.subs))
-
-class TryExcept(Node):
- def __init__(self, body, handlers, else_, lineno=None):
- self.body = body
- self.handlers = handlers
- self.else_ = else_
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.body)
- children.extend(flatten(self.handlers))
- children.append(self.else_)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.body)
- nodelist.extend(flatten_nodes(self.handlers))
- if self.else_ is not None:
- nodelist.append(self.else_)
- return tuple(nodelist)
-
- def __repr__(self):
- return "TryExcept(%s, %s, %s)" % (repr(self.body), repr(self.handlers), repr(self.else_))
-
-class TryFinally(Node):
- def __init__(self, body, final, lineno=None):
- self.body = body
- self.final = final
- self.lineno = lineno
-
- def getChildren(self):
- return self.body, self.final
-
- def getChildNodes(self):
- return self.body, self.final
-
- def __repr__(self):
- return "TryFinally(%s, %s)" % (repr(self.body), repr(self.final))
-
-class Tuple(Node):
- def __init__(self, nodes, lineno=None):
- self.nodes = nodes
- self.lineno = lineno
-
- def getChildren(self):
- return tuple(flatten(self.nodes))
-
- def getChildNodes(self):
- nodelist = []
- nodelist.extend(flatten_nodes(self.nodes))
- return tuple(nodelist)
-
- def __repr__(self):
- return "Tuple(%s)" % (repr(self.nodes),)
-
-class UnaryAdd(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "UnaryAdd(%s)" % (repr(self.expr),)
-
-class UnarySub(Node):
- def __init__(self, expr, lineno=None):
- self.expr = expr
- self.lineno = lineno
-
- def getChildren(self):
- return self.expr,
-
- def getChildNodes(self):
- return self.expr,
-
- def __repr__(self):
- return "UnarySub(%s)" % (repr(self.expr),)
-
-class While(Node):
- def __init__(self, test, body, else_, lineno=None):
- self.test = test
- self.body = body
- self.else_ = else_
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.test)
- children.append(self.body)
- children.append(self.else_)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.test)
- nodelist.append(self.body)
- if self.else_ is not None:
- nodelist.append(self.else_)
- return tuple(nodelist)
-
- def __repr__(self):
- return "While(%s, %s, %s)" % (repr(self.test), repr(self.body), repr(self.else_))
-
-class With(Node):
- def __init__(self, expr, vars, body, lineno=None):
- self.expr = expr
- self.vars = vars
- self.body = body
- self.lineno = lineno
-
- def getChildren(self):
- children = []
- children.append(self.expr)
- children.append(self.vars)
- children.append(self.body)
- return tuple(children)
-
- def getChildNodes(self):
- nodelist = []
- nodelist.append(self.expr)
- if self.vars is not None:
- nodelist.append(self.vars)
- nodelist.append(self.body)
- return tuple(nodelist)
-
- def __repr__(self):
- return "With(%s, %s, %s)" % (repr(self.expr), repr(self.vars), repr(self.body))
-
-class Yield(Node):
- def __init__(self, value, lineno=None):
- self.value = value
- self.lineno = lineno
-
- def getChildren(self):
- return self.value,
-
- def getChildNodes(self):
- return self.value,
-
- def __repr__(self):
- return "Yield(%s)" % (repr(self.value),)
-
-for name, obj in globals().items():
- if isinstance(obj, type) and issubclass(obj, Node):
- nodes[name.lower()] = obj
diff --git a/Lib/compiler/consts.py b/Lib/compiler/consts.py
deleted file mode 100644
index c60b1d0b4f6..00000000000
--- a/Lib/compiler/consts.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# operation flags
-OP_ASSIGN = 'OP_ASSIGN'
-OP_DELETE = 'OP_DELETE'
-OP_APPLY = 'OP_APPLY'
-
-SC_LOCAL = 1
-SC_GLOBAL_IMPLICIT = 2
-SC_GLOBAL_EXPLICIT = 3
-SC_FREE = 4
-SC_CELL = 5
-SC_UNKNOWN = 6
-
-CO_OPTIMIZED = 0x0001
-CO_NEWLOCALS = 0x0002
-CO_VARARGS = 0x0004
-CO_VARKEYWORDS = 0x0008
-CO_NESTED = 0x0010
-CO_GENERATOR = 0x0020
-CO_GENERATOR_ALLOWED = 0
-CO_FUTURE_DIVISION = 0x2000
-CO_FUTURE_ABSIMPORT = 0x4000
-CO_FUTURE_WITH_STATEMENT = 0x8000
-CO_FUTURE_PRINT_FUNCTION = 0x10000
diff --git a/Lib/compiler/future.py b/Lib/compiler/future.py
deleted file mode 100644
index fd5e5dfb374..00000000000
--- a/Lib/compiler/future.py
+++ /dev/null
@@ -1,74 +0,0 @@
-"""Parser for future statements
-
-"""
-
-from compiler import ast, walk
-
-def is_future(stmt):
- """Return true if statement is a well-formed future statement"""
- if not isinstance(stmt, ast.From):
- return 0
- if stmt.modname == "__future__":
- return 1
- else:
- return 0
-
-class FutureParser:
-
- features = ("nested_scopes", "generators", "division",
- "absolute_import", "with_statement", "print_function",
- "unicode_literals")
-
- def __init__(self):
- self.found = {} # set
-
- def visitModule(self, node):
- stmt = node.node
- for s in stmt.nodes:
- if not self.check_stmt(s):
- break
-
- def check_stmt(self, stmt):
- if is_future(stmt):
- for name, asname in stmt.names:
- if name in self.features:
- self.found[name] = 1
- else:
- raise SyntaxError, \
- "future feature %s is not defined" % name
- stmt.valid_future = 1
- return 1
- return 0
-
- def get_features(self):
- """Return list of features enabled by future statements"""
- return self.found.keys()
-
-class BadFutureParser:
- """Check for invalid future statements"""
-
- def visitFrom(self, node):
- if hasattr(node, 'valid_future'):
- return
- if node.modname != "__future__":
- return
- raise SyntaxError, "invalid future statement " + repr(node)
-
-def find_futures(node):
- p1 = FutureParser()
- p2 = BadFutureParser()
- walk(node, p1)
- walk(node, p2)
- return p1.get_features()
-
-if __name__ == "__main__":
- import sys
- from compiler import parseFile, walk
-
- for file in sys.argv[1:]:
- print file
- tree = parseFile(file)
- v = FutureParser()
- walk(tree, v)
- print v.found
- print
diff --git a/Lib/compiler/misc.py b/Lib/compiler/misc.py
deleted file mode 100644
index 588c7fbd5ae..00000000000
--- a/Lib/compiler/misc.py
+++ /dev/null
@@ -1,73 +0,0 @@
-
-def flatten(tup):
- elts = []
- for elt in tup:
- if isinstance(elt, tuple):
- elts = elts + flatten(elt)
- else:
- elts.append(elt)
- return elts
-
-class Set:
- def __init__(self):
- self.elts = {}
- def __len__(self):
- return len(self.elts)
- def __contains__(self, elt):
- return elt in self.elts
- def add(self, elt):
- self.elts[elt] = elt
- def elements(self):
- return self.elts.keys()
- def has_elt(self, elt):
- return elt in self.elts
- def remove(self, elt):
- del self.elts[elt]
- def copy(self):
- c = Set()
- c.elts.update(self.elts)
- return c
-
-class Stack:
- def __init__(self):
- self.stack = []
- self.pop = self.stack.pop
- def __len__(self):
- return len(self.stack)
- def push(self, elt):
- self.stack.append(elt)
- def top(self):
- return self.stack[-1]
- def __getitem__(self, index): # needed by visitContinue()
- return self.stack[index]
-
-MANGLE_LEN = 256 # magic constant from compile.c
-
-def mangle(name, klass):
- if not name.startswith('__'):
- return name
- if len(name) + 2 >= MANGLE_LEN:
- return name
- if name.endswith('__'):
- return name
- try:
- i = 0
- while klass[i] == '_':
- i = i + 1
- except IndexError:
- return name
- klass = klass[i:]
-
- tlen = len(klass) + len(name)
- if tlen > MANGLE_LEN:
- klass = klass[:MANGLE_LEN-tlen]
-
- return "_%s%s" % (klass, name)
-
-def set_filename(filename, tree):
- """Set the filename attribute to filename on every node in tree"""
- worklist = [tree]
- while worklist:
- node = worklist.pop(0)
- node.filename = filename
- worklist.extend(node.getChildNodes())
diff --git a/Lib/compiler/pyassem.py b/Lib/compiler/pyassem.py
deleted file mode 100644
index 286be0c8c7d..00000000000
--- a/Lib/compiler/pyassem.py
+++ /dev/null
@@ -1,763 +0,0 @@
-"""A flow graph representation for Python bytecode"""
-
-import dis
-import types
-import sys
-
-from compiler import misc
-from compiler.consts \
- import CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS
-
-class FlowGraph:
- def __init__(self):
- self.current = self.entry = Block()
- self.exit = Block("exit")
- self.blocks = misc.Set()
- self.blocks.add(self.entry)
- self.blocks.add(self.exit)
-
- def startBlock(self, block):
- if self._debug:
- if self.current:
- print "end", repr(self.current)
- print " next", self.current.next
- print " prev", self.current.prev
- print " ", self.current.get_children()
- print repr(block)
- self.current = block
-
- def nextBlock(self, block=None):
- # XXX think we need to specify when there is implicit transfer
- # from one block to the next. might be better to represent this
- # with explicit JUMP_ABSOLUTE instructions that are optimized
- # out when they are unnecessary.
- #
- # I think this strategy works: each block has a child
- # designated as "next" which is returned as the last of the
- # children. because the nodes in a graph are emitted in
- # reverse post order, the "next" block will always be emitted
- # immediately after its parent.
- # Worry: maintaining this invariant could be tricky
- if block is None:
- block = self.newBlock()
-
- # Note: If the current block ends with an unconditional control
- # transfer, then it is techically incorrect to add an implicit
- # transfer to the block graph. Doing so results in code generation
- # for unreachable blocks. That doesn't appear to be very common
- # with Python code and since the built-in compiler doesn't optimize
- # it out we don't either.
- self.current.addNext(block)
- self.startBlock(block)
-
- def newBlock(self):
- b = Block()
- self.blocks.add(b)
- return b
-
- def startExitBlock(self):
- self.startBlock(self.exit)
-
- _debug = 0
-
- def _enable_debug(self):
- self._debug = 1
-
- def _disable_debug(self):
- self._debug = 0
-
- def emit(self, *inst):
- if self._debug:
- print "\t", inst
- if len(inst) == 2 and isinstance(inst[1], Block):
- self.current.addOutEdge(inst[1])
- self.current.emit(inst)
-
- def getBlocksInOrder(self):
- """Return the blocks in reverse postorder
-
- i.e. each node appears before all of its successors
- """
- order = order_blocks(self.entry, self.exit)
- return order
-
- def getBlocks(self):
- return self.blocks.elements()
-
- def getRoot(self):
- """Return nodes appropriate for use with dominator"""
- return self.entry
-
- def getContainedGraphs(self):
- l = []
- for b in self.getBlocks():
- l.extend(b.getContainedGraphs())
- return l
-
-
-def order_blocks(start_block, exit_block):
- """Order blocks so that they are emitted in the right order"""
- # Rules:
- # - when a block has a next block, the next block must be emitted just after
- # - when a block has followers (relative jumps), it must be emitted before
- # them
- # - all reachable blocks must be emitted
- order = []
-
- # Find all the blocks to be emitted.
- remaining = set()
- todo = [start_block]
- while todo:
- b = todo.pop()
- if b in remaining:
- continue
- remaining.add(b)
- for c in b.get_children():
- if c not in remaining:
- todo.append(c)
-
- # A block is dominated by another block if that block must be emitted
- # before it.
- dominators = {}
- for b in remaining:
- if __debug__ and b.next:
- assert b is b.next[0].prev[0], (b, b.next)
- # Make sure every block appears in dominators, even if no
- # other block must precede it.
- dominators.setdefault(b, set())
- # preceeding blocks dominate following blocks
- for c in b.get_followers():
- while 1:
- dominators.setdefault(c, set()).add(b)
- # Any block that has a next pointer leading to c is also
- # dominated because the whole chain will be emitted at once.
- # Walk backwards and add them all.
- if c.prev and c.prev[0] is not b:
- c = c.prev[0]
- else:
- break
-
- def find_next():
- # Find a block that can be emitted next.
- for b in remaining:
- for c in dominators[b]:
- if c in remaining:
- break # can't emit yet, dominated by a remaining block
- else:
- return b
- assert 0, 'circular dependency, cannot find next block'
-
- b = start_block
- while 1:
- order.append(b)
- remaining.discard(b)
- if b.next:
- b = b.next[0]
- continue
- elif b is not exit_block and not b.has_unconditional_transfer():
- order.append(exit_block)
- if not remaining:
- break
- b = find_next()
- return order
-
-
-class Block:
- _count = 0
-
- def __init__(self, label=''):
- self.insts = []
- self.outEdges = set()
- self.label = label
- self.bid = Block._count
- self.next = []
- self.prev = []
- Block._count = Block._count + 1
-
- def __repr__(self):
- if self.label:
- return "<block %s id=%d>" % (self.label, self.bid)
- else:
- return "<block id=%d>" % (self.bid)
-
- def __str__(self):
- insts = map(str, self.insts)
- return "<block %s %d:\n%s>" % (self.label, self.bid,
- '\n'.join(insts))
-
- def emit(self, inst):
- op = inst[0]
- self.insts.append(inst)
-
- def getInstructions(self):
- return self.insts
-
- def addOutEdge(self, block):
- self.outEdges.add(block)
-
- def addNext(self, block):
- self.next.append(block)
- assert len(self.next) == 1, map(str, self.next)
- block.prev.append(self)
- assert len(block.prev) == 1, map(str, block.prev)
-
- _uncond_transfer = ('RETURN_VALUE', 'RAISE_VARARGS',
- 'JUMP_ABSOLUTE', 'JUMP_FORWARD', 'CONTINUE_LOOP',
- )
-
- def has_unconditional_transfer(self):
- """Returns True if there is an unconditional transfer to an other block
- at the end of this block. This means there is no risk for the bytecode
- executer to go past this block's bytecode."""
- try:
- op, arg = self.insts[-1]
- except (IndexError, ValueError):
- return
- return op in self._uncond_transfer
-
- def get_children(self):
- return list(self.outEdges) + self.next
-
- def get_followers(self):
- """Get the whole list of followers, including the next block."""
- followers = set(self.next)
- # Blocks that must be emitted *after* this one, because of
- # bytecode offsets (e.g. relative jumps) pointing to them.
- for inst in self.insts:
- if inst[0] in PyFlowGraph.hasjrel:
- followers.add(inst[1])
- return followers
-
- def getContainedGraphs(self):
- """Return all graphs contained within this block.
-
- For example, a MAKE_FUNCTION block will contain a reference to
- the graph for the function body.
- """
- contained = []
- for inst in self.insts:
- if len(inst) == 1:
- continue
- op = inst[1]
- if hasattr(op, 'graph'):
- contained.append(op.graph)
- return contained
-
-# flags for code objects
-
-# the FlowGraph is transformed in place; it exists in one of these states
-RAW = "RAW"
-FLAT = "FLAT"
-CONV = "CONV"
-DONE = "DONE"
-
-class PyFlowGraph(FlowGraph):
- super_init = FlowGraph.__init__
-
- def __init__(self, name, filename, args=(), optimized=0, klass=None):
- self.super_init()
- self.name = name
- self.filename = filename
- self.docstring = None
- self.args = args # XXX
- self.argcount = getArgCount(args)
- self.klass = klass
- if optimized:
- self.flags = CO_OPTIMIZED | CO_NEWLOCALS
- else:
- self.flags = 0
- self.consts = []
- self.names = []
- # Free variables found by the symbol table scan, including
- # variables used only in nested scopes, are included here.
- self.freevars = []
- self.cellvars = []
- # The closure list is used to track the order of cell
- # variables and free variables in the resulting code object.
- # The offsets used by LOAD_CLOSURE/LOAD_DEREF refer to both
- # kinds of variables.
- self.closure = []
- self.varnames = list(args) or []
- for i in range(len(self.varnames)):
- var = self.varnames[i]
- if isinstance(var, TupleArg):
- self.varnames[i] = var.getName()
- self.stage = RAW
-
- def setDocstring(self, doc):
- self.docstring = doc
-
- def setFlag(self, flag):
- self.flags = self.flags | flag
- if flag == CO_VARARGS:
- self.argcount = self.argcount - 1
-
- def checkFlag(self, flag):
- if self.flags & flag:
- return 1
-
- def setFreeVars(self, names):
- self.freevars = list(names)
-
- def setCellVars(self, names):
- self.cellvars = names
-
- def getCode(self):
- """Get a Python code object"""
- assert self.stage == RAW
- self.computeStackDepth()
- self.flattenGraph()
- assert self.stage == FLAT
- self.convertArgs()
- assert self.stage == CONV
- self.makeByteCode()
- assert self.stage == DONE
- return self.newCodeObject()
-
- def dump(self, io=None):
- if io:
- save = sys.stdout
- sys.stdout = io
- pc = 0
- for t in self.insts:
- opname = t[0]
- if opname == "SET_LINENO":
- print
- if len(t) == 1:
- print "\t", "%3d" % pc, opname
- pc = pc + 1
- else:
- print "\t", "%3d" % pc, opname, t[1]
- pc = pc + 3
- if io:
- sys.stdout = save
-
- def computeStackDepth(self):
- """Compute the max stack depth.
-
- Approach is to compute the stack effect of each basic block.
- Then find the path through the code with the largest total
- effect.
- """
- depth = {}
- exit = None
- for b in self.getBlocks():
- depth[b] = findDepth(b.getInstructions())
-
- seen = {}
-
- def max_depth(b, d):
- if b in seen:
- return d
- seen[b] = 1
- d = d + depth[b]
- children = b.get_children()
- if children:
- return max([max_depth(c, d) for c in children])
- else:
- if not b.label == "exit":
- return max_depth(self.exit, d)
- else:
- return d
-
- self.stacksize = max_depth(self.entry, 0)
-
- def flattenGraph(self):
- """Arrange the blocks in order and resolve jumps"""
- assert self.stage == RAW
- self.insts = insts = []
- pc = 0
- begin = {}
- end = {}
- for b in self.getBlocksInOrder():
- begin[b] = pc
- for inst in b.getInstructions():
- insts.append(inst)
- if len(inst) == 1:
- pc = pc + 1
- elif inst[0] != "SET_LINENO":
- # arg takes 2 bytes
- pc = pc + 3
- end[b] = pc
- pc = 0
- for i in range(len(insts)):
- inst = insts[i]
- if len(inst) == 1:
- pc = pc + 1
- elif inst[0] != "SET_LINENO":
- pc = pc + 3
- opname = inst[0]
- if opname in self.hasjrel:
- oparg = inst[1]
- offset = begin[oparg] - pc
- insts[i] = opname, offset
- elif opname in self.hasjabs:
- insts[i] = opname, begin[inst[1]]
- self.stage = FLAT
-
- hasjrel = set()
- for i in dis.hasjrel:
- hasjrel.add(dis.opname[i])
- hasjabs = set()
- for i in dis.hasjabs:
- hasjabs.add(dis.opname[i])
-
- def convertArgs(self):
- """Convert arguments from symbolic to concrete form"""
- assert self.stage == FLAT
- self.consts.insert(0, self.docstring)
- self.sort_cellvars()
- for i in range(len(self.insts)):
- t = self.insts[i]
- if len(t) == 2:
- opname, oparg = t
- conv = self._converters.get(opname, None)
- if conv:
- self.insts[i] = opname, conv(self, oparg)
- self.stage = CONV
-
- def sort_cellvars(self):
- """Sort cellvars in the order of varnames and prune from freevars.
- """
- cells = {}
- for name in self.cellvars:
- cells[name] = 1
- self.cellvars = [name for name in self.varnames
- if name in cells]
- for name in self.cellvars:
- del cells[name]
- self.cellvars = self.cellvars + cells.keys()
- self.closure = self.cellvars + self.freevars
-
- def _lookupName(self, name, list):
- """Return index of name in list, appending if necessary
-
- This routine uses a list instead of a dictionary, because a
- dictionary can't store two different keys if the keys have the
- same value but different types, e.g. 2 and 2L. The compiler
- must treat these two separately, so it does an explicit type
- comparison before comparing the values.
- """
- t = type(name)
- for i in range(len(list)):
- if t == type(list[i]) and list[i] == name:
- return i
- end = len(list)
- list.append(name)
- return end
-
- _converters = {}
- def _convert_LOAD_CONST(self, arg):
- if hasattr(arg, 'getCode'):
- arg = arg.getCode()
- return self._lookupName(arg, self.consts)
-
- def _convert_LOAD_FAST(self, arg):
- self._lookupName(arg, self.names)
- return self._lookupName(arg, self.varnames)
- _convert_STORE_FAST = _convert_LOAD_FAST
- _convert_DELETE_FAST = _convert_LOAD_FAST
-
- def _convert_LOAD_NAME(self, arg):
- if self.klass is None:
- self._lookupName(arg, self.varnames)
- return self._lookupName(arg, self.names)
-
- def _convert_NAME(self, arg):
- if self.klass is None:
- self._lookupName(arg, self.varnames)
- return self._lookupName(arg, self.names)
- _convert_STORE_NAME = _convert_NAME
- _convert_DELETE_NAME = _convert_NAME
- _convert_IMPORT_NAME = _convert_NAME
- _convert_IMPORT_FROM = _convert_NAME
- _convert_STORE_ATTR = _convert_NAME
- _convert_LOAD_ATTR = _convert_NAME
- _convert_DELETE_ATTR = _convert_NAME
- _convert_LOAD_GLOBAL = _convert_NAME
- _convert_STORE_GLOBAL = _convert_NAME
- _convert_DELETE_GLOBAL = _convert_NAME
-
- def _convert_DEREF(self, arg):
- self._lookupName(arg, self.names)
- self._lookupName(arg, self.varnames)
- return self._lookupName(arg, self.closure)
- _convert_LOAD_DEREF = _convert_DEREF
- _convert_STORE_DEREF = _convert_DEREF
-
- def _convert_LOAD_CLOSURE(self, arg):
- self._lookupName(arg, self.varnames)
- return self._lookupName(arg, self.closure)
-
- _cmp = list(dis.cmp_op)
- def _convert_COMPARE_OP(self, arg):
- return self._cmp.index(arg)
-
- # similarly for other opcodes...
-
- for name, obj in locals().items():
- if name[:9] == "_convert_":
- opname = name[9:]
- _converters[opname] = obj
- del name, obj, opname
-
- def makeByteCode(self):
- assert self.stage == CONV
- self.lnotab = lnotab = LineAddrTable()
- for t in self.insts:
- opname = t[0]
- if len(t) == 1:
- lnotab.addCode(self.opnum[opname])
- else:
- oparg = t[1]
- if opname == "SET_LINENO":
- lnotab.nextLine(oparg)
- continue
- hi, lo = twobyte(oparg)
- try:
- lnotab.addCode(self.opnum[opname], lo, hi)
- except ValueError:
- print opname, oparg
- print self.opnum[opname], lo, hi
- raise
- self.stage = DONE
-
- opnum = {}
- for num in range(len(dis.opname)):
- opnum[dis.opname[num]] = num
- del num
-
- def newCodeObject(self):
- assert self.stage == DONE
- if (self.flags & CO_NEWLOCALS) == 0:
- nlocals = 0
- else:
- nlocals = len(self.varnames)
- argcount = self.argcount
- if self.flags & CO_VARKEYWORDS:
- argcount = argcount - 1
- return types.CodeType(argcount, nlocals, self.stacksize, self.flags,
- self.lnotab.getCode(), self.getConsts(),
- tuple(self.names), tuple(self.varnames),
- self.filename, self.name, self.lnotab.firstline,
- self.lnotab.getTable(), tuple(self.freevars),
- tuple(self.cellvars))
-
- def getConsts(self):
- """Return a tuple for the const slot of the code object
-
- Must convert references to code (MAKE_FUNCTION) to code
- objects recursively.
- """
- l = []
- for elt in self.consts:
- if isinstance(elt, PyFlowGraph):
- elt = elt.getCode()
- l.append(elt)
- return tuple(l)
-
-def isJump(opname):
- if opname[:4] == 'JUMP':
- return 1
-
-class TupleArg:
- """Helper for marking func defs with nested tuples in arglist"""
- def __init__(self, count, names):
- self.count = count
- self.names = names
- def __repr__(self):
- return "TupleArg(%s, %s)" % (self.count, self.names)
- def getName(self):
- return ".%d" % self.count
-
-def getArgCount(args):
- argcount = len(args)
- if args:
- for arg in args:
- if isinstance(arg, TupleArg):
- numNames = len(misc.flatten(arg.names))
- argcount = argcount - numNames
- return argcount
-
-def twobyte(val):
- """Convert an int argument into high and low bytes"""
- assert isinstance(val, int)
- return divmod(val, 256)
-
-class LineAddrTable:
- """lnotab
-
- This class builds the lnotab, which is documented in compile.c.
- Here's a brief recap:
-
- For each SET_LINENO instruction after the first one, two bytes are
- added to lnotab. (In some cases, multiple two-byte entries are
- added.) The first byte is the distance in bytes between the
- instruction for the last SET_LINENO and the current SET_LINENO.
- The second byte is offset in line numbers. If either offset is
- greater than 255, multiple two-byte entries are added -- see
- compile.c for the delicate details.
- """
-
- def __init__(self):
- self.code = []
- self.codeOffset = 0
- self.firstline = 0
- self.lastline = 0
- self.lastoff = 0
- self.lnotab = []
-
- def addCode(self, *args):
- for arg in args:
- self.code.append(chr(arg))
- self.codeOffset = self.codeOffset + len(args)
-
- def nextLine(self, lineno):
- if self.firstline == 0:
- self.firstline = lineno
- self.lastline = lineno
- else:
- # compute deltas
- addr = self.codeOffset - self.lastoff
- line = lineno - self.lastline
- # Python assumes that lineno always increases with
- # increasing bytecode address (lnotab is unsigned char).
- # Depending on when SET_LINENO instructions are emitted
- # this is not always true. Consider the code:
- # a = (1,
- # b)
- # In the bytecode stream, the assignment to "a" occurs
- # after the loading of "b". This works with the C Python
- # compiler because it only generates a SET_LINENO instruction
- # for the assignment.
- if line >= 0:
- push = self.lnotab.append
- while addr > 255:
- push(255); push(0)
- addr -= 255
- while line > 255:
- push(addr); push(255)
- line -= 255
- addr = 0
- if addr > 0 or line > 0:
- push(addr); push(line)
- self.lastline = lineno
- self.lastoff = self.codeOffset
-
- def getCode(self):
- return ''.join(self.code)
-
- def getTable(self):
- return ''.join(map(chr, self.lnotab))
-
-class StackDepthTracker:
- # XXX 1. need to keep track of stack depth on jumps
- # XXX 2. at least partly as a result, this code is broken
-
- def findDepth(self, insts, debug=0):
- depth = 0
- maxDepth = 0
- for i in insts:
- opname = i[0]
- if debug:
- print i,
- delta = self.effect.get(opname, None)
- if delta is not None:
- depth = depth + delta
- else:
- # now check patterns
- for pat, pat_delta in self.patterns:
- if opname[:len(pat)] == pat:
- delta = pat_delta
- depth = depth + delta
- break
- # if we still haven't found a match
- if delta is None:
- meth = getattr(self, opname, None)
- if meth is not None:
- depth = depth + meth(i[1])
- if depth > maxDepth:
- maxDepth = depth
- if debug:
- print depth, maxDepth
- return maxDepth
-
- effect = {
- 'POP_TOP': -1,
- 'DUP_TOP': 1,
- 'LIST_APPEND': -1,
- 'SET_ADD': -1,
- 'MAP_ADD': -2,
- 'SLICE+1': -1,
- 'SLICE+2': -1,
- 'SLICE+3': -2,
- 'STORE_SLICE+0': -1,
- 'STORE_SLICE+1': -2,
- 'STORE_SLICE+2': -2,
- 'STORE_SLICE+3': -3,
- 'DELETE_SLICE+0': -1,
- 'DELETE_SLICE+1': -2,
- 'DELETE_SLICE+2': -2,
- 'DELETE_SLICE+3': -3,
- 'STORE_SUBSCR': -3,
- 'DELETE_SUBSCR': -2,
- # PRINT_EXPR?
- 'PRINT_ITEM': -1,
- 'RETURN_VALUE': -1,
- 'YIELD_VALUE': -1,
- 'EXEC_STMT': -3,
- 'BUILD_CLASS': -2,
- 'STORE_NAME': -1,
- 'STORE_ATTR': -2,
- 'DELETE_ATTR': -1,
- 'STORE_GLOBAL': -1,
- 'BUILD_MAP': 1,
- 'COMPARE_OP': -1,
- 'STORE_FAST': -1,
- 'IMPORT_STAR': -1,
- 'IMPORT_NAME': -1,
- 'IMPORT_FROM': 1,
- 'LOAD_ATTR': 0, # unlike other loads
- # close enough...
- 'SETUP_EXCEPT': 3,
- 'SETUP_FINALLY': 3,
- 'FOR_ITER': 1,
- 'WITH_CLEANUP': -1,
- }
- # use pattern match
- patterns = [
- ('BINARY_', -1),
- ('LOAD_', 1),
- ]
-
- def UNPACK_SEQUENCE(self, count):
- return count-1
- def BUILD_TUPLE(self, count):
- return -count+1
- def BUILD_LIST(self, count):
- return -count+1
- def BUILD_SET(self, count):
- return -count+1
- def CALL_FUNCTION(self, argc):
- hi, lo = divmod(argc, 256)
- return -(lo + hi * 2)
- def CALL_FUNCTION_VAR(self, argc):
- return self.CALL_FUNCTION(argc)-1
- def CALL_FUNCTION_KW(self, argc):
- return self.CALL_FUNCTION(argc)-1
- def CALL_FUNCTION_VAR_KW(self, argc):
- return self.CALL_FUNCTION(argc)-2
- def MAKE_FUNCTION(self, argc):
- return -argc
- def MAKE_CLOSURE(self, argc):
- # XXX need to account for free variables too!
- return -argc
- def BUILD_SLICE(self, argc):
- if argc == 2:
- return -1
- elif argc == 3:
- return -2
- def DUP_TOPX(self, argc):
- return argc
-
-findDepth = StackDepthTracker().findDepth
diff --git a/Lib/compiler/pycodegen.py b/Lib/compiler/pycodegen.py
deleted file mode 100644
index 6515945f39a..00000000000
--- a/Lib/compiler/pycodegen.py
+++ /dev/null
@@ -1,1555 +0,0 @@
-import imp
-import os
-import marshal
-import struct
-import sys
-from cStringIO import StringIO
-
-from compiler import ast, parse, walk, syntax
-from compiler import pyassem, misc, future, symbols
-from compiler.consts import SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICIT, \
- SC_FREE, SC_CELL
-from compiler.consts import (CO_VARARGS, CO_VARKEYWORDS, CO_NEWLOCALS,
- CO_NESTED, CO_GENERATOR, CO_FUTURE_DIVISION,
- CO_FUTURE_ABSIMPORT, CO_FUTURE_WITH_STATEMENT, CO_FUTURE_PRINT_FUNCTION)
-from compiler.pyassem import TupleArg
-
-# XXX The version-specific code can go, since this code only works with 2.x.
-# Do we have Python 1.x or Python 2.x?
-try:
- VERSION = sys.version_info[0]
-except AttributeError:
- VERSION = 1
-
-callfunc_opcode_info = {
- # (Have *args, Have **args) : opcode
- (0,0) : "CALL_FUNCTION",
- (1,0) : "CALL_FUNCTION_VAR",
- (0,1) : "CALL_FUNCTION_KW",
- (1,1) : "CALL_FUNCTION_VAR_KW",
-}
-
-LOOP = 1
-EXCEPT = 2
-TRY_FINALLY = 3
-END_FINALLY = 4
-
-def compileFile(filename, display=0):
- f = open(filename, 'U')
- buf = f.read()
- f.close()
- mod = Module(buf, filename)
- try:
- mod.compile(display)
- except SyntaxError:
- raise
- else:
- f = open(filename + "c", "wb")
- mod.dump(f)
- f.close()
-
-def compile(source, filename, mode, flags=None, dont_inherit=None):
- """Replacement for builtin compile() function"""
- if flags is not None or dont_inherit is not None:
- raise RuntimeError, "not implemented yet"
-
- if mode == "single":
- gen = Interactive(source, filename)
- elif mode == "exec":
- gen = Module(source, filename)
- elif mode == "eval":
- gen = Expression(source, filename)
- else:
- raise ValueError("compile() 3rd arg must be 'exec' or "
- "'eval' or 'single'")
- gen.compile()
- return gen.code
-
-class AbstractCompileMode:
-
- mode = None # defined by subclass
-
- def __init__(self, source, filename):
- self.source = source
- self.filename = filename
- self.code = None
-
- def _get_tree(self):
- tree = parse(self.source, self.mode)
- misc.set_filename(self.filename, tree)
- syntax.check(tree)
- return tree
-
- def compile(self):
- pass # implemented by subclass
-
- def getCode(self):
- return self.code
-
-class Expression(AbstractCompileMode):
-
- mode = "eval"
-
- def compile(self):
- tree = self._get_tree()
- gen = ExpressionCodeGenerator(tree)
- self.code = gen.getCode()
-
-class Interactive(AbstractCompileMode):
-
- mode = "single"
-
- def compile(self):
- tree = self._get_tree()
- gen = InteractiveCodeGenerator(tree)
- self.code = gen.getCode()
-
-class Module(AbstractCompileMode):
-
- mode = "exec"
-
- def compile(self, display=0):
- tree = self._get_tree()
- gen = ModuleCodeGenerator(tree)
- if display:
- import pprint
- print pprint.pprint(tree)
- self.code = gen.getCode()
-
- def dump(self, f):
- f.write(self.getPycHeader())
- marshal.dump(self.code, f)
-
- MAGIC = imp.get_magic()
-
- def getPycHeader(self):
- # compile.c uses marshal to write a long directly, with
- # calling the interface that would also generate a 1-byte code
- # to indicate the type of the value. simplest way to get the
- # same effect is to call marshal and then skip the code.
- mtime = os.path.getmtime(self.filename)
- mtime = struct.pack('<i', mtime)
- return self.MAGIC + mtime
-
-class LocalNameFinder:
- """Find local names in scope"""
- def __init__(self, names=()):
- self.names = misc.Set()
- self.globals = misc.Set()
- for name in names:
- self.names.add(name)
-
- # XXX list comprehensions and for loops
-
- def getLocals(self):
- for elt in self.globals.elements():
- if self.names.has_elt(elt):
- self.names.remove(elt)
- return self.names
-
- def visitDict(self, node):
- pass
-
- def visitGlobal(self, node):
- for name in node.names:
- self.globals.add(name)
-
- def visitFunction(self, node):
- self.names.add(node.name)
-
- def visitLambda(self, node):
- pass
-
- def visitImport(self, node):
- for name, alias in node.names:
- self.names.add(alias or name)
-
- def visitFrom(self, node):
- for name, alias in node.names:
- self.names.add(alias or name)
-
- def visitClass(self, node):
- self.names.add(node.name)
-
- def visitAssName(self, node):
- self.names.add(node.name)
-
-def is_constant_false(node):
- if isinstance(node, ast.Const):
- if not node.value:
- return 1
- return 0
-
-class CodeGenerator:
- """Defines basic code generator for Python bytecode
-
- This class is an abstract base class. Concrete subclasses must
- define an __init__() that defines self.graph and then calls the
- __init__() defined in this class.
-
- The concrete class must also define the class attributes
- NameFinder, FunctionGen, and ClassGen. These attributes can be
- defined in the initClass() method, which is a hook for
- initializing these methods after all the classes have been
- defined.
- """
-
- optimized = 0 # is namespace access optimized?
- __initialized = None
- class_name = None # provide default for instance variable
-
- def __init__(self):
- if self.__initialized is None:
- self.initClass()
- self.__class__.__initialized = 1
- self.checkClass()
- self.locals = misc.Stack()
- self.setups = misc.Stack()
- self.last_lineno = None
- self._setupGraphDelegation()
- self._div_op = "BINARY_DIVIDE"
-
- # XXX set flags based on future features
- futures = self.get_module().futures
- for feature in futures:
- if feature == "division":
- self.graph.setFlag(CO_FUTURE_DIVISION)
- self._div_op = "BINARY_TRUE_DIVIDE"
- elif feature == "absolute_import":
- self.graph.setFlag(CO_FUTURE_ABSIMPORT)
- elif feature == "with_statement":
- self.graph.setFlag(CO_FUTURE_WITH_STATEMENT)
- elif feature == "print_function":
- self.graph.setFlag(CO_FUTURE_PRINT_FUNCTION)
-
- def initClass(self):
- """This method is called once for each class"""
-
- def checkClass(self):
- """Verify that class is constructed correctly"""
- try:
- assert hasattr(self, 'graph')
- assert getattr(self, 'NameFinder')
- assert getattr(self, 'FunctionGen')
- assert getattr(self, 'ClassGen')
- except AssertionError, msg:
- intro = "Bad class construction for %s" % self.__class__.__name__
- raise AssertionError, intro
-
- def _setupGraphDelegation(self):
- self.emit = self.graph.emit
- self.newBlock = self.graph.newBlock
- self.startBlock = self.graph.startBlock
- self.nextBlock = self.graph.nextBlock
- self.setDocstring = self.graph.setDocstring
-
- def getCode(self):
- """Return a code object"""
- return self.graph.getCode()
-
- def mangle(self, name):
- if self.class_name is not None:
- return misc.mangle(name, self.class_name)
- else:
- return name
-
- def parseSymbols(self, tree):
- s = symbols.SymbolVisitor()
- walk(tree, s)
- return s.scopes
-
- def get_module(self):
- raise RuntimeError, "should be implemented by subclasses"
-
- # Next five methods handle name access
-
- def isLocalName(self, name):
- return self.locals.top().has_elt(name)
-
- def storeName(self, name):
- self._nameOp('STORE', name)
-
- def loadName(self, name):
- self._nameOp('LOAD', name)
-
- def delName(self, name):
- self._nameOp('DELETE', name)
-
- def _nameOp(self, prefix, name):
- name = self.mangle(name)
- scope = self.scope.check_name(name)
- if scope == SC_LOCAL:
- if not self.optimized:
- self.emit(prefix + '_NAME', name)
- else:
- self.emit(prefix + '_FAST', name)
- elif scope == SC_GLOBAL_EXPLICIT:
- self.emit(prefix + '_GLOBAL', name)
- elif scope == SC_GLOBAL_IMPLICIT:
- if not self.optimized:
- self.emit(prefix + '_NAME', name)
- else:
- self.emit(prefix + '_GLOBAL', name)
- elif scope == SC_FREE or scope == SC_CELL:
- self.emit(prefix + '_DEREF', name)
- else:
- raise RuntimeError, "unsupported scope for var %s: %d" % \
- (name, scope)
-
- def _implicitNameOp(self, prefix, name):
- """Emit name ops for names generated implicitly by for loops
-
- The interpreter generates names that start with a period or
- dollar sign. The symbol table ignores these names because
- they aren't present in the program text.
- """
- if self.optimized:
- self.emit(prefix + '_FAST', name)
- else:
- self.emit(prefix + '_NAME', name)
-
- # The set_lineno() function and the explicit emit() calls for
- # SET_LINENO below are only used to generate the line number table.
- # As of Python 2.3, the interpreter does not have a SET_LINENO
- # instruction. pyassem treats SET_LINENO opcodes as a special case.
-
- def set_lineno(self, node, force=False):
- """Emit SET_LINENO if necessary.
-
- The instruction is considered necessary if the node has a
- lineno attribute and it is different than the last lineno
- emitted.
-
- Returns true if SET_LINENO was emitted.
-
- There are no rules for when an AST node should have a lineno
- attribute. The transformer and AST code need to be reviewed
- and a consistent policy implemented and documented. Until
- then, this method works around missing line numbers.
- """
- lineno = getattr(node, 'lineno', None)
- if lineno is not None and (lineno != self.last_lineno
- or force):
- self.emit('SET_LINENO', lineno)
- self.last_lineno = lineno
- return True
- return False
-
- # The first few visitor methods handle nodes that generator new
- # code objects. They use class attributes to determine what
- # specialized code generators to use.
-
- NameFinder = LocalNameFinder
- FunctionGen = None
- ClassGen = None
-
- def visitModule(self, node):
- self.scopes = self.parseSymbols(node)
- self.scope = self.scopes[node]
- self.emit('SET_LINENO', 0)
- if node.doc:
- self.emit('LOAD_CONST', node.doc)
- self.storeName('__doc__')
- lnf = walk(node.node, self.NameFinder(), verbose=0)
- self.locals.push(lnf.getLocals())
- self.visit(node.node)
- self.emit('LOAD_CONST', None)
- self.emit('RETURN_VALUE')
-
- def visitExpression(self, node):
- self.set_lineno(node)
- self.scopes = self.parseSymbols(node)
- self.scope = self.scopes[node]
- self.visit(node.node)
- self.emit('RETURN_VALUE')
-
- def visitFunction(self, node):
- self._visitFuncOrLambda(node, isLambda=0)
- if node.doc:
- self.setDocstring(node.doc)
- self.storeName(node.name)
-
- def visitLambda(self, node):
- self._visitFuncOrLambda(node, isLambda=1)
-
- def _visitFuncOrLambda(self, node, isLambda=0):
- if not isLambda and node.decorators:
- for decorator in node.decorators.nodes:
- self.visit(decorator)
- ndecorators = len(node.decorators.nodes)
- else:
- ndecorators = 0
-
- gen = self.FunctionGen(node, self.scopes, isLambda,
- self.class_name, self.get_module())
- walk(node.code, gen)
- gen.finish()
- self.set_lineno(node)
- for default in node.defaults:
- self.visit(default)
- self._makeClosure(gen, len(node.defaults))
- for i in range(ndecorators):
- self.emit('CALL_FUNCTION', 1)
-
- def visitClass(self, node):
- gen = self.ClassGen(node, self.scopes,
- self.get_module())
- walk(node.code, gen)
- gen.finish()
- self.set_lineno(node)
- self.emit('LOAD_CONST', node.name)
- for base in node.bases:
- self.visit(base)
- self.emit('BUILD_TUPLE', len(node.bases))
- self._makeClosure(gen, 0)
- self.emit('CALL_FUNCTION', 0)
- self.emit('BUILD_CLASS')
- self.storeName(node.name)
-
- # The rest are standard visitor methods
-
- # The next few implement control-flow statements
-
- def visitIf(self, node):
- end = self.newBlock()
- numtests = len(node.tests)
- for i in range(numtests):
- test, suite = node.tests[i]
- if is_constant_false(test):
- # XXX will need to check generator stuff here
- continue
- self.set_lineno(test)
- self.visit(test)
- nextTest = self.newBlock()
- self.emit('POP_JUMP_IF_FALSE', nextTest)
- self.nextBlock()
- self.visit(suite)
- self.emit('JUMP_FORWARD', end)
- self.startBlock(nextTest)
- if node.else_:
- self.visit(node.else_)
- self.nextBlock(end)
-
- def visitWhile(self, node):
- self.set_lineno(node)
-
- loop = self.newBlock()
- else_ = self.newBlock()
-
- after = self.newBlock()
- self.emit('SETUP_LOOP', after)
-
- self.nextBlock(loop)
- self.setups.push((LOOP, loop))
-
- self.set_lineno(node, force=True)
- self.visit(node.test)
- self.emit('POP_JUMP_IF_FALSE', else_ or after)
-
- self.nextBlock()
- self.visit(node.body)
- self.emit('JUMP_ABSOLUTE', loop)
-
- self.startBlock(else_) # or just the POPs if not else clause
- self.emit('POP_BLOCK')
- self.setups.pop()
- if node.else_:
- self.visit(node.else_)
- self.nextBlock(after)
-
- def visitFor(self, node):
- start = self.newBlock()
- anchor = self.newBlock()
- after = self.newBlock()
- self.setups.push((LOOP, start))
-
- self.set_lineno(node)
- self.emit('SETUP_LOOP', after)
- self.visit(node.list)
- self.emit('GET_ITER')
-
- self.nextBlock(start)
- self.set_lineno(node, force=1)
- self.emit('FOR_ITER', anchor)
- self.visit(node.assign)
- self.visit(node.body)
- self.emit('JUMP_ABSOLUTE', start)
- self.nextBlock(anchor)
- self.emit('POP_BLOCK')
- self.setups.pop()
- if node.else_:
- self.visit(node.else_)
- self.nextBlock(after)
-
- def visitBreak(self, node):
- if not self.setups:
- raise SyntaxError, "'break' outside loop (%s, %d)" % \
- (node.filename, node.lineno)
- self.set_lineno(node)
- self.emit('BREAK_LOOP')
-
- def visitContinue(self, node):
- if not self.setups:
- raise SyntaxError, "'continue' outside loop (%s, %d)" % \
- (node.filename, node.lineno)
- kind, block = self.setups.top()
- if kind == LOOP:
- self.set_lineno(node)
- self.emit('JUMP_ABSOLUTE', block)
- self.nextBlock()
- elif kind == EXCEPT or kind == TRY_FINALLY:
- self.set_lineno(node)
- # find the block that starts the loop
- top = len(self.setups)
- while top > 0:
- top = top - 1
- kind, loop_block = self.setups[top]
- if kind == LOOP:
- break
- if kind != LOOP:
- raise SyntaxError, "'continue' outside loop (%s, %d)" % \
- (node.filename, node.lineno)
- self.emit('CONTINUE_LOOP', loop_block)
- self.nextBlock()
- elif kind == END_FINALLY:
- msg = "'continue' not allowed inside 'finally' clause (%s, %d)"
- raise SyntaxError, msg % (node.filename, node.lineno)
-
- def visitTest(self, node, jump):
- end = self.newBlock()
- for child in node.nodes[:-1]:
- self.visit(child)
- self.emit(jump, end)
- self.nextBlock()
- self.visit(node.nodes[-1])
- self.nextBlock(end)
-
- def visitAnd(self, node):
- self.visitTest(node, 'JUMP_IF_FALSE_OR_POP')
-
- def visitOr(self, node):
- self.visitTest(node, 'JUMP_IF_TRUE_OR_POP')
-
- def visitIfExp(self, node):
- endblock = self.newBlock()
- elseblock = self.newBlock()
- self.visit(node.test)
- self.emit('POP_JUMP_IF_FALSE', elseblock)
- self.visit(node.then)
- self.emit('JUMP_FORWARD', endblock)
- self.nextBlock(elseblock)
- self.visit(node.else_)
- self.nextBlock(endblock)
-
- def visitCompare(self, node):
- self.visit(node.expr)
- cleanup = self.newBlock()
- for op, code in node.ops[:-1]:
- self.visit(code)
- self.emit('DUP_TOP')
- self.emit('ROT_THREE')
- self.emit('COMPARE_OP', op)
- self.emit('JUMP_IF_FALSE_OR_POP', cleanup)
- self.nextBlock()
- # now do the last comparison
- if node.ops:
- op, code = node.ops[-1]
- self.visit(code)
- self.emit('COMPARE_OP', op)
- if len(node.ops) > 1:
- end = self.newBlock()
- self.emit('JUMP_FORWARD', end)
- self.startBlock(cleanup)
- self.emit('ROT_TWO')
- self.emit('POP_TOP')
- self.nextBlock(end)
-
- # list comprehensions
- def visitListComp(self, node):
- self.set_lineno(node)
- # setup list
- self.emit('BUILD_LIST', 0)
-
- stack = []
- for i, for_ in zip(range(len(node.quals)), node.quals):
- start, anchor = self.visit(for_)
- cont = None
- for if_ in for_.ifs:
- if cont is None:
- cont = self.newBlock()
- self.visit(if_, cont)
- stack.insert(0, (start, cont, anchor))
-
- self.visit(node.expr)
- self.emit('LIST_APPEND', len(node.quals) + 1)
-
- for start, cont, anchor in stack:
- if cont:
- self.nextBlock(cont)
- self.emit('JUMP_ABSOLUTE', start)
- self.startBlock(anchor)
-
- def visitSetComp(self, node):
- self.set_lineno(node)
- # setup list
- self.emit('BUILD_SET', 0)
-
- stack = []
- for i, for_ in zip(range(len(node.quals)), node.quals):
- start, anchor = self.visit(for_)
- cont = None
- for if_ in for_.ifs:
- if cont is None:
- cont = self.newBlock()
- self.visit(if_, cont)
- stack.insert(0, (start, cont, anchor))
-
- self.visit(node.expr)
- self.emit('SET_ADD', len(node.quals) + 1)
-
- for start, cont, anchor in stack:
- if cont:
- self.nextBlock(cont)
- self.emit('JUMP_ABSOLUTE', start)
- self.startBlock(anchor)
-
- def visitDictComp(self, node):
- self.set_lineno(node)
- # setup list
- self.emit('BUILD_MAP', 0)
-
- stack = []
- for i, for_ in zip(range(len(node.quals)), node.quals):
- start, anchor = self.visit(for_)
- cont = None
- for if_ in for_.ifs:
- if cont is None:
- cont = self.newBlock()
- self.visit(if_, cont)
- stack.insert(0, (start, cont, anchor))
-
- self.visit(node.value)
- self.visit(node.key)
- self.emit('MAP_ADD', len(node.quals) + 1)
-
- for start, cont, anchor in stack:
- if cont:
- self.nextBlock(cont)
- self.emit('JUMP_ABSOLUTE', start)
- self.startBlock(anchor)
-
- def visitListCompFor(self, node):
- start = self.newBlock()
- anchor = self.newBlock()
-
- self.visit(node.list)
- self.emit('GET_ITER')
- self.nextBlock(start)
- self.set_lineno(node, force=True)
- self.emit('FOR_ITER', anchor)
- self.nextBlock()
- self.visit(node.assign)
- return start, anchor
-
- def visitListCompIf(self, node, branch):
- self.set_lineno(node, force=True)
- self.visit(node.test)
- self.emit('POP_JUMP_IF_FALSE', branch)
- self.newBlock()
-
- def _makeClosure(self, gen, args):
- frees = gen.scope.get_free_vars()
- if frees:
- for name in frees:
- self.emit('LOAD_CLOSURE', name)
- self.emit('BUILD_TUPLE', len(frees))
- self.emit('LOAD_CONST', gen)
- self.emit('MAKE_CLOSURE', args)
- else:
- self.emit('LOAD_CONST', gen)
- self.emit('MAKE_FUNCTION', args)
-
- def visitGenExpr(self, node):
- gen = GenExprCodeGenerator(node, self.scopes, self.class_name,
- self.get_module())
- walk(node.code, gen)
- gen.finish()
- self.set_lineno(node)
- self._makeClosure(gen, 0)
- # precomputation of outmost iterable
- self.visit(node.code.quals[0].iter)
- self.emit('GET_ITER')
- self.emit('CALL_FUNCTION', 1)
-
- def visitGenExprInner(self, node):
- self.set_lineno(node)
- # setup list
-
- stack = []
- for i, for_ in zip(range(len(node.quals)), node.quals):
- start, anchor, end = self.visit(for_)
- cont = None
- for if_ in for_.ifs:
- if cont is None:
- cont = self.newBlock()
- self.visit(if_, cont)
- stack.insert(0, (start, cont, anchor, end))
-
- self.visit(node.expr)
- self.emit('YIELD_VALUE')
- self.emit('POP_TOP')
-
- for start, cont, anchor, end in stack:
- if cont:
- self.nextBlock(cont)
- self.emit('JUMP_ABSOLUTE', start)
- self.startBlock(anchor)
- self.emit('POP_BLOCK')
- self.setups.pop()
- self.nextBlock(end)
-
- self.emit('LOAD_CONST', None)
-
- def visitGenExprFor(self, node):
- start = self.newBlock()
- anchor = self.newBlock()
- end = self.newBlock()
-
- self.setups.push((LOOP, start))
- self.emit('SETUP_LOOP', end)
-
- if node.is_outmost:
- self.loadName('.0')
- else:
- self.visit(node.iter)
- self.emit('GET_ITER')
-
- self.nextBlock(start)
- self.set_lineno(node, force=True)
- self.emit('FOR_ITER', anchor)
- self.nextBlock()
- self.visit(node.assign)
- return start, anchor, end
-
- def visitGenExprIf(self, node, branch):
- self.set_lineno(node, force=True)
- self.visit(node.test)
- self.emit('POP_JUMP_IF_FALSE', branch)
- self.newBlock()
-
- # exception related
-
- def visitAssert(self, node):
- # XXX would be interesting to implement this via a
- # transformation of the AST before this stage
- if __debug__:
- end = self.newBlock()
- self.set_lineno(node)
- # XXX AssertionError appears to be special case -- it is always
- # loaded as a global even if there is a local name. I guess this
- # is a sort of renaming op.
- self.nextBlock()
- self.visit(node.test)
- self.emit('POP_JUMP_IF_TRUE', end)
- self.nextBlock()
- self.emit('LOAD_GLOBAL', 'AssertionError')
- if node.fail:
- self.visit(node.fail)
- self.emit('RAISE_VARARGS', 2)
- else:
- self.emit('RAISE_VARARGS', 1)
- self.nextBlock(end)
-
- def visitRaise(self, node):
- self.set_lineno(node)
- n = 0
- if node.expr1:
- self.visit(node.expr1)
- n = n + 1
- if node.expr2:
- self.visit(node.expr2)
- n = n + 1
- if node.expr3:
- self.visit(node.expr3)
- n = n + 1
- self.emit('RAISE_VARARGS', n)
-
- def visitTryExcept(self, node):
- body = self.newBlock()
- handlers = self.newBlock()
- end = self.newBlock()
- if node.else_:
- lElse = self.newBlock()
- else:
- lElse = end
- self.set_lineno(node)
- self.emit('SETUP_EXCEPT', handlers)
- self.nextBlock(body)
- self.setups.push((EXCEPT, body))
- self.visit(node.body)
- self.emit('POP_BLOCK')
- self.setups.pop()
- self.emit('JUMP_FORWARD', lElse)
- self.startBlock(handlers)
-
- last = len(node.handlers) - 1
- for i in range(len(node.handlers)):
- expr, target, body = node.handlers[i]
- self.set_lineno(expr)
- if expr:
- self.emit('DUP_TOP')
- self.visit(expr)
- self.emit('COMPARE_OP', 'exception match')
- next = self.newBlock()
- self.emit('POP_JUMP_IF_FALSE', next)
- self.nextBlock()
- self.emit('POP_TOP')
- if target:
- self.visit(target)
- else:
- self.emit('POP_TOP')
- self.emit('POP_TOP')
- self.visit(body)
- self.emit('JUMP_FORWARD', end)
- if expr:
- self.nextBlock(next)
- else:
- self.nextBlock()
- self.emit('END_FINALLY')
- if node.else_:
- self.nextBlock(lElse)
- self.visit(node.else_)
- self.nextBlock(end)
-
- def visitTryFinally(self, node):
- body = self.newBlock()
- final = self.newBlock()
- self.set_lineno(node)
- self.emit('SETUP_FINALLY', final)
- self.nextBlock(body)
- self.setups.push((TRY_FINALLY, body))
- self.visit(node.body)
- self.emit('POP_BLOCK')
- self.setups.pop()
- self.emit('LOAD_CONST', None)
- self.nextBlock(final)
- self.setups.push((END_FINALLY, final))
- self.visit(node.final)
- self.emit('END_FINALLY')
- self.setups.pop()
-
- __with_count = 0
-
- def visitWith(self, node):
- body = self.newBlock()
- final = self.newBlock()
- self.__with_count += 1
- valuevar = "_[%d]" % self.__with_count
- self.set_lineno(node)
- self.visit(node.expr)
- self.emit('DUP_TOP')
- self.emit('LOAD_ATTR', '__exit__')
- self.emit('ROT_TWO')
- self.emit('LOAD_ATTR', '__enter__')
- self.emit('CALL_FUNCTION', 0)
- if node.vars is None:
- self.emit('POP_TOP')
- else:
- self._implicitNameOp('STORE', valuevar)
- self.emit('SETUP_FINALLY', final)
- self.nextBlock(body)
- self.setups.push((TRY_FINALLY, body))
- if node.vars is not None:
- self._implicitNameOp('LOAD', valuevar)
- self._implicitNameOp('DELETE', valuevar)
- self.visit(node.vars)
- self.visit(node.body)
- self.emit('POP_BLOCK')
- self.setups.pop()
- self.emit('LOAD_CONST', None)
- self.nextBlock(final)
- self.setups.push((END_FINALLY, final))
- self.emit('WITH_CLEANUP')
- self.emit('END_FINALLY')
- self.setups.pop()
- self.__with_count -= 1
-
- # misc
-
- def visitDiscard(self, node):
- self.set_lineno(node)
- self.visit(node.expr)
- self.emit('POP_TOP')
-
- def visitConst(self, node):
- self.emit('LOAD_CONST', node.value)
-
- def visitKeyword(self, node):
- self.emit('LOAD_CONST', node.name)
- self.visit(node.expr)
-
- def visitGlobal(self, node):
- # no code to generate
- pass
-
- def visitName(self, node):
- self.set_lineno(node)
- self.loadName(node.name)
-
- def visitPass(self, node):
- self.set_lineno(node)
-
- def visitImport(self, node):
- self.set_lineno(node)
- level = 0 if self.graph.checkFlag(CO_FUTURE_ABSIMPORT) else -1
- for name, alias in node.names:
- if VERSION > 1:
- self.emit('LOAD_CONST', level)
- self.emit('LOAD_CONST', None)
- self.emit('IMPORT_NAME', name)
- mod = name.split(".")[0]
- if alias:
- self._resolveDots(name)
- self.storeName(alias)
- else:
- self.storeName(mod)
-
- def visitFrom(self, node):
- self.set_lineno(node)
- level = node.level
- if level == 0 and not self.graph.checkFlag(CO_FUTURE_ABSIMPORT):
- level = -1
- fromlist = tuple(name for (name, alias) in node.names)
- if VERSION > 1:
- self.emit('LOAD_CONST', level)
- self.emit('LOAD_CONST', fromlist)
- self.emit('IMPORT_NAME', node.modname)
- for name, alias in node.names:
- if VERSION > 1:
- if name == '*':
- self.namespace = 0
- self.emit('IMPORT_STAR')
- # There can only be one name w/ from ... import *
- assert len(node.names) == 1
- return
- else:
- self.emit('IMPORT_FROM', name)
- self._resolveDots(name)
- self.storeName(alias or name)
- else:
- self.emit('IMPORT_FROM', name)
- self.emit('POP_TOP')
-
- def _resolveDots(self, name):
- elts = name.split(".")
- if len(elts) == 1:
- return
- for elt in elts[1:]:
- self.emit('LOAD_ATTR', elt)
-
- def visitGetattr(self, node):
- self.visit(node.expr)
- self.emit('LOAD_ATTR', self.mangle(node.attrname))
-
- # next five implement assignments
-
- def visitAssign(self, node):
- self.set_lineno(node)
- self.visit(node.expr)
- dups = len(node.nodes) - 1
- for i in range(len(node.nodes)):
- elt = node.nodes[i]
- if i < dups:
- self.emit('DUP_TOP')
- if isinstance(elt, ast.Node):
- self.visit(elt)
-
- def visitAssName(self, node):
- if node.flags == 'OP_ASSIGN':
- self.storeName(node.name)
- elif node.flags == 'OP_DELETE':
- self.set_lineno(node)
- self.delName(node.name)
- else:
- print "oops", node.flags
-
- def visitAssAttr(self, node):
- self.visit(node.expr)
- if node.flags == 'OP_ASSIGN':
- self.emit('STORE_ATTR', self.mangle(node.attrname))
- elif node.flags == 'OP_DELETE':
- self.emit('DELETE_ATTR', self.mangle(node.attrname))
- else:
- print "warning: unexpected flags:", node.flags
- print node
-
- def _visitAssSequence(self, node, op='UNPACK_SEQUENCE'):
- if findOp(node) != 'OP_DELETE':
- self.emit(op, len(node.nodes))
- for child in node.nodes:
- self.visit(child)
-
- if VERSION > 1:
- visitAssTuple = _visitAssSequence
- visitAssList = _visitAssSequence
- else:
- def visitAssTuple(self, node):
- self._visitAssSequence(node, 'UNPACK_TUPLE')
-
- def visitAssList(self, node):
- self._visitAssSequence(node, 'UNPACK_LIST')
-
- # augmented assignment
-
- def visitAugAssign(self, node):
- self.set_lineno(node)
- aug_node = wrap_aug(node.node)
- self.visit(aug_node, "load")
- self.visit(node.expr)
- self.emit(self._augmented_opcode[node.op])
- self.visit(aug_node, "store")
-
- _augmented_opcode = {
- '+=' : 'INPLACE_ADD',
- '-=' : 'INPLACE_SUBTRACT',
- '*=' : 'INPLACE_MULTIPLY',
- '/=' : 'INPLACE_DIVIDE',
- '//=': 'INPLACE_FLOOR_DIVIDE',
- '%=' : 'INPLACE_MODULO',
- '**=': 'INPLACE_POWER',
- '>>=': 'INPLACE_RSHIFT',
- '<<=': 'INPLACE_LSHIFT',
- '&=' : 'INPLACE_AND',
- '^=' : 'INPLACE_XOR',
- '|=' : 'INPLACE_OR',
- }
-
- def visitAugName(self, node, mode):
- if mode == "load":
- self.loadName(node.name)
- elif mode == "store":
- self.storeName(node.name)
-
- def visitAugGetattr(self, node, mode):
- if mode == "load":
- self.visit(node.expr)
- self.emit('DUP_TOP')
- self.emit('LOAD_ATTR', self.mangle(node.attrname))
- elif mode == "store":
- self.emit('ROT_TWO')
- self.emit('STORE_ATTR', self.mangle(node.attrname))
-
- def visitAugSlice(self, node, mode):
- if mode == "load":
- self.visitSlice(node, 1)
- elif mode == "store":
- slice = 0
- if node.lower:
- slice = slice | 1
- if node.upper:
- slice = slice | 2
- if slice == 0:
- self.emit('ROT_TWO')
- elif slice == 3:
- self.emit('ROT_FOUR')
- else:
- self.emit('ROT_THREE')
- self.emit('STORE_SLICE+%d' % slice)
-
- def visitAugSubscript(self, node, mode):
- if mode == "load":
- self.visitSubscript(node, 1)
- elif mode == "store":
- self.emit('ROT_THREE')
- self.emit('STORE_SUBSCR')
-
- def visitExec(self, node):
- self.visit(node.expr)
- if node.locals is None:
- self.emit('LOAD_CONST', None)
- else:
- self.visit(node.locals)
- if node.globals is None:
- self.emit('DUP_TOP')
- else:
- self.visit(node.globals)
- self.emit('EXEC_STMT')
-
- def visitCallFunc(self, node):
- pos = 0
- kw = 0
- self.set_lineno(node)
- self.visit(node.node)
- for arg in node.args:
- self.visit(arg)
- if isinstance(arg, ast.Keyword):
- kw = kw + 1
- else:
- pos = pos + 1
- if node.star_args is not None:
- self.visit(node.star_args)
- if node.dstar_args is not None:
- self.visit(node.dstar_args)
- have_star = node.star_args is not None
- have_dstar = node.dstar_args is not None
- opcode = callfunc_opcode_info[have_star, have_dstar]
- self.emit(opcode, kw << 8 | pos)
-
- def visitPrint(self, node, newline=0):
- self.set_lineno(node)
- if node.dest:
- self.visit(node.dest)
- for child in node.nodes:
- if node.dest:
- self.emit('DUP_TOP')
- self.visit(child)
- if node.dest:
- self.emit('ROT_TWO')
- self.emit('PRINT_ITEM_TO')
- else:
- self.emit('PRINT_ITEM')
- if node.dest and not newline:
- self.emit('POP_TOP')
-
- def visitPrintnl(self, node):
- self.visitPrint(node, newline=1)
- if node.dest:
- self.emit('PRINT_NEWLINE_TO')
- else:
- self.emit('PRINT_NEWLINE')
-
- def visitReturn(self, node):
- self.set_lineno(node)
- self.visit(node.value)
- self.emit('RETURN_VALUE')
-
- def visitYield(self, node):
- self.set_lineno(node)
- self.visit(node.value)
- self.emit('YIELD_VALUE')
-
- # slice and subscript stuff
-
- def visitSlice(self, node, aug_flag=None):
- # aug_flag is used by visitAugSlice
- self.visit(node.expr)
- slice = 0
- if node.lower:
- self.visit(node.lower)
- slice = slice | 1
- if node.upper:
- self.visit(node.upper)
- slice = slice | 2
- if aug_flag:
- if slice == 0:
- self.emit('DUP_TOP')
- elif slice == 3:
- self.emit('DUP_TOPX', 3)
- else:
- self.emit('DUP_TOPX', 2)
- if node.flags == 'OP_APPLY':
- self.emit('SLICE+%d' % slice)
- elif node.flags == 'OP_ASSIGN':
- self.emit('STORE_SLICE+%d' % slice)
- elif node.flags == 'OP_DELETE':
- self.emit('DELETE_SLICE+%d' % slice)
- else:
- print "weird slice", node.flags
- raise
-
- def visitSubscript(self, node, aug_flag=None):
- self.visit(node.expr)
- for sub in node.subs:
- self.visit(sub)
- if len(node.subs) > 1:
- self.emit('BUILD_TUPLE', len(node.subs))
- if aug_flag:
- self.emit('DUP_TOPX', 2)
- if node.flags == 'OP_APPLY':
- self.emit('BINARY_SUBSCR')
- elif node.flags == 'OP_ASSIGN':
- self.emit('STORE_SUBSCR')
- elif node.flags == 'OP_DELETE':
- self.emit('DELETE_SUBSCR')
-
- # binary ops
-
- def binaryOp(self, node, op):
- self.visit(node.left)
- self.visit(node.right)
- self.emit(op)
-
- def visitAdd(self, node):
- return self.binaryOp(node, 'BINARY_ADD')
-
- def visitSub(self, node):
- return self.binaryOp(node, 'BINARY_SUBTRACT')
-
- def visitMul(self, node):
- return self.binaryOp(node, 'BINARY_MULTIPLY')
-
- def visitDiv(self, node):
- return self.binaryOp(node, self._div_op)
-
- def visitFloorDiv(self, node):
- return self.binaryOp(node, 'BINARY_FLOOR_DIVIDE')
-
- def visitMod(self, node):
- return self.binaryOp(node, 'BINARY_MODULO')
-
- def visitPower(self, node):
- return self.binaryOp(node, 'BINARY_POWER')
-
- def visitLeftShift(self, node):
- return self.binaryOp(node, 'BINARY_LSHIFT')
-
- def visitRightShift(self, node):
- return self.binaryOp(node, 'BINARY_RSHIFT')
-
- # unary ops
-
- def unaryOp(self, node, op):
- self.visit(node.expr)
- self.emit(op)
-
- def visitInvert(self, node):
- return self.unaryOp(node, 'UNARY_INVERT')
-
- def visitUnarySub(self, node):
- return self.unaryOp(node, 'UNARY_NEGATIVE')
-
- def visitUnaryAdd(self, node):
- return self.unaryOp(node, 'UNARY_POSITIVE')
-
- def visitUnaryInvert(self, node):
- return self.unaryOp(node, 'UNARY_INVERT')
-
- def visitNot(self, node):
- return self.unaryOp(node, 'UNARY_NOT')
-
- def visitBackquote(self, node):
- return self.unaryOp(node, 'UNARY_CONVERT')
-
- # bit ops
-
- def bitOp(self, nodes, op):
- self.visit(nodes[0])
- for node in nodes[1:]:
- self.visit(node)
- self.emit(op)
-
- def visitBitand(self, node):
- return self.bitOp(node.nodes, 'BINARY_AND')
-
- def visitBitor(self, node):
- return self.bitOp(node.nodes, 'BINARY_OR')
-
- def visitBitxor(self, node):
- return self.bitOp(node.nodes, 'BINARY_XOR')
-
- # object constructors
-
- def visitEllipsis(self, node):
- self.emit('LOAD_CONST', Ellipsis)
-
- def visitTuple(self, node):
- self.set_lineno(node)
- for elt in node.nodes:
- self.visit(elt)
- self.emit('BUILD_TUPLE', len(node.nodes))
-
- def visitList(self, node):
- self.set_lineno(node)
- for elt in node.nodes:
- self.visit(elt)
- self.emit('BUILD_LIST', len(node.nodes))
-
- def visitSet(self, node):
- self.set_lineno(node)
- for elt in node.nodes:
- self.visit(elt)
- self.emit('BUILD_SET', len(node.nodes))
-
- def visitSliceobj(self, node):
- for child in node.nodes:
- self.visit(child)
- self.emit('BUILD_SLICE', len(node.nodes))
-
- def visitDict(self, node):
- self.set_lineno(node)
- self.emit('BUILD_MAP', 0)
- for k, v in node.items:
- self.emit('DUP_TOP')
- self.visit(k)
- self.visit(v)
- self.emit('ROT_THREE')
- self.emit('STORE_SUBSCR')
-
-class NestedScopeMixin:
- """Defines initClass() for nested scoping (Python 2.2-compatible)"""
- def initClass(self):
- self.__class__.NameFinder = LocalNameFinder
- self.__class__.FunctionGen = FunctionCodeGenerator
- self.__class__.ClassGen = ClassCodeGenerator
-
-class ModuleCodeGenerator(NestedScopeMixin, CodeGenerator):
- __super_init = CodeGenerator.__init__
-
- scopes = None
-
- def __init__(self, tree):
- self.graph = pyassem.PyFlowGraph("<module>", tree.filename)
- self.futures = future.find_futures(tree)
- self.__super_init()
- walk(tree, self)
-
- def get_module(self):
- return self
-
-class ExpressionCodeGenerator(NestedScopeMixin, CodeGenerator):
- __super_init = CodeGenerator.__init__
-
- scopes = None
- futures = ()
-
- def __init__(self, tree):
- self.graph = pyassem.PyFlowGraph("<expression>", tree.filename)
- self.__super_init()
- walk(tree, self)
-
- def get_module(self):
- return self
-
-class InteractiveCodeGenerator(NestedScopeMixin, CodeGenerator):
-
- __super_init = CodeGenerator.__init__
-
- scopes = None
- futures = ()
-
- def __init__(self, tree):
- self.graph = pyassem.PyFlowGraph("<interactive>", tree.filename)
- self.__super_init()
- self.set_lineno(tree)
- walk(tree, self)
- self.emit('RETURN_VALUE')
-
- def get_module(self):
- return self
-
- def visitDiscard(self, node):
- # XXX Discard means it's an expression. Perhaps this is a bad
- # name.
- self.visit(node.expr)
- self.emit('PRINT_EXPR')
-
-class AbstractFunctionCode:
- optimized = 1
- lambdaCount = 0
-
- def __init__(self, func, scopes, isLambda, class_name, mod):
- self.class_name = class_name
- self.module = mod
- if isLambda:
- klass = FunctionCodeGenerator
- name = "<lambda.%d>" % klass.lambdaCount
- klass.lambdaCount = klass.lambdaCount + 1
- else:
- name = func.name
-
- args, hasTupleArg = generateArgList(func.argnames)
- self.graph = pyassem.PyFlowGraph(name, func.filename, args,
- optimized=1)
- self.isLambda = isLambda
- self.super_init()
-
- if not isLambda and func.doc:
- self.setDocstring(func.doc)
-
- lnf = walk(func.code, self.NameFinder(args), verbose=0)
- self.locals.push(lnf.getLocals())
- if func.varargs:
- self.graph.setFlag(CO_VARARGS)
- if func.kwargs:
- self.graph.setFlag(CO_VARKEYWORDS)
- self.set_lineno(func)
- if hasTupleArg:
- self.generateArgUnpack(func.argnames)
-
- def get_module(self):
- return self.module
-
- def finish(self):
- self.graph.startExitBlock()
- if not self.isLambda:
- self.emit('LOAD_CONST', None)
- self.emit('RETURN_VALUE')
-
- def generateArgUnpack(self, args):
- for i in range(len(args)):
- arg = args[i]
- if isinstance(arg, tuple):
- self.emit('LOAD_FAST', '.%d' % (i * 2))
- self.unpackSequence(arg)
-
- def unpackSequence(self, tup):
- if VERSION > 1:
- self.emit('UNPACK_SEQUENCE', len(tup))
- else:
- self.emit('UNPACK_TUPLE', len(tup))
- for elt in tup:
- if isinstance(elt, tuple):
- self.unpackSequence(elt)
- else:
- self._nameOp('STORE', elt)
-
- unpackTuple = unpackSequence
-
-class FunctionCodeGenerator(NestedScopeMixin, AbstractFunctionCode,
- CodeGenerator):
- super_init = CodeGenerator.__init__ # call be other init
- scopes = None
-
- __super_init = AbstractFunctionCode.__init__
-
- def __init__(self, func, scopes, isLambda, class_name, mod):
- self.scopes = scopes
- self.scope = scopes[func]
- self.__super_init(func, scopes, isLambda, class_name, mod)
- self.graph.setFreeVars(self.scope.get_free_vars())
- self.graph.setCellVars(self.scope.get_cell_vars())
- if self.scope.generator is not None:
- self.graph.setFlag(CO_GENERATOR)
-
-class GenExprCodeGenerator(NestedScopeMixin, AbstractFunctionCode,
- CodeGenerator):
- super_init = CodeGenerator.__init__ # call be other init
- scopes = None
-
- __super_init = AbstractFunctionCode.__init__
-
- def __init__(self, gexp, scopes, class_name, mod):
- self.scopes = scopes
- self.scope = scopes[gexp]
- self.__super_init(gexp, scopes, 1, class_name, mod)
- self.graph.setFreeVars(self.scope.get_free_vars())
- self.graph.setCellVars(self.scope.get_cell_vars())
- self.graph.setFlag(CO_GENERATOR)
-
-class AbstractClassCode:
-
- def __init__(self, klass, scopes, module):
- self.class_name = klass.name
- self.module = module
- self.graph = pyassem.PyFlowGraph(klass.name, klass.filename,
- optimized=0, klass=1)
- self.super_init()
- lnf = walk(klass.code, self.NameFinder(), verbose=0)
- self.locals.push(lnf.getLocals())
- self.graph.setFlag(CO_NEWLOCALS)
- if klass.doc:
- self.setDocstring(klass.doc)
-
- def get_module(self):
- return self.module
-
- def finish(self):
- self.graph.startExitBlock()
- self.emit('LOAD_LOCALS')
- self.emit('RETURN_VALUE')
-
-class ClassCodeGenerator(NestedScopeMixin, AbstractClassCode, CodeGenerator):
- super_init = CodeGenerator.__init__
- scopes = None
-
- __super_init = AbstractClassCode.__init__
-
- def __init__(self, klass, scopes, module):
- self.scopes = scopes
- self.scope = scopes[klass]
- self.__super_init(klass, scopes, module)
- self.graph.setFreeVars(self.scope.get_free_vars())
- self.graph.setCellVars(self.scope.get_cell_vars())
- self.set_lineno(klass)
- self.emit("LOAD_GLOBAL", "__name__")
- self.storeName("__module__")
- if klass.doc:
- self.emit("LOAD_CONST", klass.doc)
- self.storeName('__doc__')
-
-def generateArgList(arglist):
- """Generate an arg list marking TupleArgs"""
- args = []
- extra = []
- count = 0
- for i in range(len(arglist)):
- elt = arglist[i]
- if isinstance(elt, str):
- args.append(elt)
- elif isinstance(elt, tuple):
- args.append(TupleArg(i * 2, elt))
- extra.extend(misc.flatten(elt))
- count = count + 1
- else:
- raise ValueError, "unexpect argument type:", elt
- return args + extra, count
-
-def findOp(node):
- """Find the op (DELETE, LOAD, STORE) in an AssTuple tree"""
- v = OpFinder()
- walk(node, v, verbose=0)
- return v.op
-
-class OpFinder:
- def __init__(self):
- self.op = None
- def visitAssName(self, node):
- if self.op is None:
- self.op = node.flags
- elif self.op != node.flags:
- raise ValueError, "mixed ops in stmt"
- visitAssAttr = visitAssName
- visitSubscript = visitAssName
-
-class Delegator:
- """Base class to support delegation for augmented assignment nodes
-
- To generator code for augmented assignments, we use the following
- wrapper classes. In visitAugAssign, the left-hand expression node
- is visited twice. The first time the visit uses the normal method
- for that node . The second time the visit uses a different method
- that generates the appropriate code to perform the assignment.
- These delegator classes wrap the original AST nodes in order to
- support the variant visit methods.
- """
- def __init__(self, obj):
- self.obj = obj
-
- def __getattr__(self, attr):
- return getattr(self.obj, attr)
-
-class AugGetattr(Delegator):
- pass
-
-class AugName(Delegator):
- pass
-
-class AugSlice(Delegator):
- pass
-
-class AugSubscript(Delegator):
- pass
-
-wrapper = {
- ast.Getattr: AugGetattr,
- ast.Name: AugName,
- ast.Slice: AugSlice,
- ast.Subscript: AugSubscript,
- }
-
-def wrap_aug(node):
- return wrapper[node.__class__](node)
-
-if __name__ == "__main__":
- for file in sys.argv[1:]:
- compileFile(file)
diff --git a/Lib/compiler/symbols.py b/Lib/compiler/symbols.py
deleted file mode 100644
index afeec501538..00000000000
--- a/Lib/compiler/symbols.py
+++ /dev/null
@@ -1,462 +0,0 @@
-"""Module symbol-table generator"""
-
-from compiler import ast
-from compiler.consts import SC_LOCAL, SC_GLOBAL_IMPLICIT, SC_GLOBAL_EXPLICIT, \
- SC_FREE, SC_CELL, SC_UNKNOWN
-from compiler.misc import mangle
-import types
-
-
-import sys
-
-MANGLE_LEN = 256
-
-class Scope:
- # XXX how much information do I need about each name?
- def __init__(self, name, module, klass=None):
- self.name = name
- self.module = module
- self.defs = {}
- self.uses = {}
- self.globals = {}
- self.params = {}
- self.frees = {}
- self.cells = {}
- self.children = []
- # nested is true if the class could contain free variables,
- # i.e. if it is nested within another function.
- self.nested = None
- self.generator = None
- self.klass = None
- if klass is not None:
- for i in range(len(klass)):
- if klass[i] != '_':
- self.klass = klass[i:]
- break
-
- def __repr__(self):
- return "<%s: %s>" % (self.__class__.__name__, self.name)
-
- def mangle(self, name):
- if self.klass is None:
- return name
- return mangle(name, self.klass)
-
- def add_def(self, name):
- self.defs[self.mangle(name)] = 1
-
- def add_use(self, name):
- self.uses[self.mangle(name)] = 1
-
- def add_global(self, name):
- name = self.mangle(name)
- if name in self.uses or name in self.defs:
- pass # XXX warn about global following def/use
- if name in self.params:
- raise SyntaxError, "%s in %s is global and parameter" % \
- (name, self.name)
- self.globals[name] = 1
- self.module.add_def(name)
-
- def add_param(self, name):
- name = self.mangle(name)
- self.defs[name] = 1
- self.params[name] = 1
-
- def get_names(self):
- d = {}
- d.update(self.defs)
- d.update(self.uses)
- d.update(self.globals)
- return d.keys()
-
- def add_child(self, child):
- self.children.append(child)
-
- def get_children(self):
- return self.children
-
- def DEBUG(self):
- print >> sys.stderr, self.name, self.nested and "nested" or ""
- print >> sys.stderr, "\tglobals: ", self.globals
- print >> sys.stderr, "\tcells: ", self.cells
- print >> sys.stderr, "\tdefs: ", self.defs
- print >> sys.stderr, "\tuses: ", self.uses
- print >> sys.stderr, "\tfrees:", self.frees
-
- def check_name(self, name):
- """Return scope of name.
-
- The scope of a name could be LOCAL, GLOBAL, FREE, or CELL.
- """
- if name in self.globals:
- return SC_GLOBAL_EXPLICIT
- if name in self.cells:
- return SC_CELL
- if name in self.defs:
- return SC_LOCAL
- if self.nested and (name in self.frees or name in self.uses):
- return SC_FREE
- if self.nested:
- return SC_UNKNOWN
- else:
- return SC_GLOBAL_IMPLICIT
-
- def get_free_vars(self):
- if not self.nested:
- return ()
- free = {}
- free.update(self.frees)
- for name in self.uses.keys():
- if name not in self.defs and name not in self.globals:
- free[name] = 1
- return free.keys()
-
- def handle_children(self):
- for child in self.children:
- frees = child.get_free_vars()
- globals = self.add_frees(frees)
- for name in globals:
- child.force_global(name)
-
- def force_global(self, name):
- """Force name to be global in scope.
-
- Some child of the current node had a free reference to name.
- When the child was processed, it was labelled a free
- variable. Now that all its enclosing scope have been
- processed, the name is known to be a global or builtin. So
- walk back down the child chain and set the name to be global
- rather than free.
-
- Be careful to stop if a child does not think the name is
- free.
- """
- self.globals[name] = 1
- if name in self.frees:
- del self.frees[name]
- for child in self.children:
- if child.check_name(name) == SC_FREE:
- child.force_global(name)
-
- def add_frees(self, names):
- """Process list of free vars from nested scope.
-
- Returns a list of names that are either 1) declared global in the
- parent or 2) undefined in a top-level parent. In either case,
- the nested scope should treat them as globals.
- """
- child_globals = []
- for name in names:
- sc = self.check_name(name)
- if self.nested:
- if sc == SC_UNKNOWN or sc == SC_FREE \
- or isinstance(self, ClassScope):
- self.frees[name] = 1
- elif sc == SC_GLOBAL_IMPLICIT:
- child_globals.append(name)
- elif isinstance(self, FunctionScope) and sc == SC_LOCAL:
- self.cells[name] = 1
- elif sc != SC_CELL:
- child_globals.append(name)
- else:
- if sc == SC_LOCAL:
- self.cells[name] = 1
- elif sc != SC_CELL:
- child_globals.append(name)
- return child_globals
-
- def get_cell_vars(self):
- return self.cells.keys()
-
-class ModuleScope(Scope):
- __super_init = Scope.__init__
-
- def __init__(self):
- self.__super_init("global", self)
-
-class FunctionScope(Scope):
- pass
-
-class GenExprScope(Scope):
- __super_init = Scope.__init__
-
- __counter = 1
-
- def __init__(self, module, klass=None):
- i = self.__counter
- self.__counter += 1
- self.__super_init("generator expression<%d>"%i, module, klass)
- self.add_param('.0')
-
- def get_names(self):
- keys = Scope.get_names(self)
- return keys
-
-class LambdaScope(FunctionScope):
- __super_init = Scope.__init__
-
- __counter = 1
-
- def __init__(self, module, klass=None):
- i = self.__counter
- self.__counter += 1
- self.__super_init("lambda.%d" % i, module, klass)
-
-class ClassScope(Scope):
- __super_init = Scope.__init__
-
- def __init__(self, name, module):
- self.__super_init(name, module, name)
-
-class SymbolVisitor:
- def __init__(self):
- self.scopes = {}
- self.klass = None
-
- # node that define new scopes
-
- def visitModule(self, node):
- scope = self.module = self.scopes[node] = ModuleScope()
- self.visit(node.node, scope)
-
- visitExpression = visitModule
-
- def visitFunction(self, node, parent):
- if node.decorators:
- self.visit(node.decorators, parent)
- parent.add_def(node.name)
- for n in node.defaults:
- self.visit(n, parent)
- scope = FunctionScope(node.name, self.module, self.klass)
- if parent.nested or isinstance(parent, FunctionScope):
- scope.nested = 1
- self.scopes[node] = scope
- self._do_args(scope, node.argnames)
- self.visit(node.code, scope)
- self.handle_free_vars(scope, parent)
-
- def visitGenExpr(self, node, parent):
- scope = GenExprScope(self.module, self.klass);
- if parent.nested or isinstance(parent, FunctionScope) \
- or isinstance(parent, GenExprScope):
- scope.nested = 1
-
- self.scopes[node] = scope
- self.visit(node.code, scope)
-
- self.handle_free_vars(scope, parent)
-
- def visitGenExprInner(self, node, scope):
- for genfor in node.quals:
- self.visit(genfor, scope)
-
- self.visit(node.expr, scope)
-
- def visitGenExprFor(self, node, scope):
- self.visit(node.assign, scope, 1)
- self.visit(node.iter, scope)
- for if_ in node.ifs:
- self.visit(if_, scope)
-
- def visitGenExprIf(self, node, scope):
- self.visit(node.test, scope)
-
- def visitLambda(self, node, parent, assign=0):
- # Lambda is an expression, so it could appear in an expression
- # context where assign is passed. The transformer should catch
- # any code that has a lambda on the left-hand side.
- assert not assign
-
- for n in node.defaults:
- self.visit(n, parent)
- scope = LambdaScope(self.module, self.klass)
- if parent.nested or isinstance(parent, FunctionScope):
- scope.nested = 1
- self.scopes[node] = scope
- self._do_args(scope, node.argnames)
- self.visit(node.code, scope)
- self.handle_free_vars(scope, parent)
-
- def _do_args(self, scope, args):
- for name in args:
- if type(name) == types.TupleType:
- self._do_args(scope, name)
- else:
- scope.add_param(name)
-
- def handle_free_vars(self, scope, parent):
- parent.add_child(scope)
- scope.handle_children()
-
- def visitClass(self, node, parent):
- parent.add_def(node.name)
- for n in node.bases:
- self.visit(n, parent)
- scope = ClassScope(node.name, self.module)
- if parent.nested or isinstance(parent, FunctionScope):
- scope.nested = 1
- if node.doc is not None:
- scope.add_def('__doc__')
- scope.add_def('__module__')
- self.scopes[node] = scope
- prev = self.klass
- self.klass = node.name
- self.visit(node.code, scope)
- self.klass = prev
- self.handle_free_vars(scope, parent)
-
- # name can be a def or a use
-
- # XXX a few calls and nodes expect a third "assign" arg that is
- # true if the name is being used as an assignment. only
- # expressions contained within statements may have the assign arg.
-
- def visitName(self, node, scope, assign=0):
- if assign:
- scope.add_def(node.name)
- else:
- scope.add_use(node.name)
-
- # operations that bind new names
-
- def visitFor(self, node, scope):
- self.visit(node.assign, scope, 1)
- self.visit(node.list, scope)
- self.visit(node.body, scope)
- if node.else_:
- self.visit(node.else_, scope)
-
- def visitFrom(self, node, scope):
- for name, asname in node.names:
- if name == "*":
- continue
- scope.add_def(asname or name)
-
- def visitImport(self, node, scope):
- for name, asname in node.names:
- i = name.find(".")
- if i > -1:
- name = name[:i]
- scope.add_def(asname or name)
-
- def visitGlobal(self, node, scope):
- for name in node.names:
- scope.add_global(name)
-
- def visitAssign(self, node, scope):
- """Propagate assignment flag down to child nodes.
-
- The Assign node doesn't itself contains the variables being
- assigned to. Instead, the children in node.nodes are visited
- with the assign flag set to true. When the names occur in
- those nodes, they are marked as defs.
-
- Some names that occur in an assignment target are not bound by
- the assignment, e.g. a name occurring inside a slice. The
- visitor handles these nodes specially; they do not propagate
- the assign flag to their children.
- """
- for n in node.nodes:
- self.visit(n, scope, 1)
- self.visit(node.expr, scope)
-
- def visitAssName(self, node, scope, assign=1):
- scope.add_def(node.name)
-
- def visitAssAttr(self, node, scope, assign=0):
- self.visit(node.expr, scope, 0)
-
- def visitSubscript(self, node, scope, assign=0):
- self.visit(node.expr, scope, 0)
- for n in node.subs:
- self.visit(n, scope, 0)
-
- def visitSlice(self, node, scope, assign=0):
- self.visit(node.expr, scope, 0)
- if node.lower:
- self.visit(node.lower, scope, 0)
- if node.upper:
- self.visit(node.upper, scope, 0)
-
- def visitAugAssign(self, node, scope):
- # If the LHS is a name, then this counts as assignment.
- # Otherwise, it's just use.
- self.visit(node.node, scope)
- if isinstance(node.node, ast.Name):
- self.visit(node.node, scope, 1) # XXX worry about this
- self.visit(node.expr, scope)
-
- # prune if statements if tests are false
-
- _const_types = types.StringType, types.IntType, types.FloatType
-
- def visitIf(self, node, scope):
- for test, body in node.tests:
- if isinstance(test, ast.Const):
- if type(test.value) in self._const_types:
- if not test.value:
- continue
- self.visit(test, scope)
- self.visit(body, scope)
- if node.else_:
- self.visit(node.else_, scope)
-
- # a yield statement signals a generator
-
- def visitYield(self, node, scope):
- scope.generator = 1
- self.visit(node.value, scope)
-
-def list_eq(l1, l2):
- return sorted(l1) == sorted(l2)
-
-if __name__ == "__main__":
- import sys
- from compiler import parseFile, walk
- import symtable
-
- def get_names(syms):
- return [s for s in [s.get_name() for s in syms.get_symbols()]
- if not (s.startswith('_[') or s.startswith('.'))]
-
- for file in sys.argv[1:]:
- print file
- f = open(file)
- buf = f.read()
- f.close()
- syms = symtable.symtable(buf, file, "exec")
- mod_names = get_names(syms)
- tree = parseFile(file)
- s = SymbolVisitor()
- walk(tree, s)
-
- # compare module-level symbols
- names2 = s.scopes[tree].get_names()
-
- if not list_eq(mod_names, names2):
- print
- print "oops", file
- print sorted(mod_names)
- print sorted(names2)
- sys.exit(-1)
-
- d = {}
- d.update(s.scopes)
- del d[tree]
- scopes = d.values()
- del d
-
- for s in syms.get_symbols():
- if s.is_namespace():
- l = [sc for sc in scopes
- if sc.name == s.get_name()]
- if len(l) > 1:
- print "skipping", s.get_name()
- else:
- if not list_eq(get_names(s.get_namespace()),
- l[0].get_names()):
- print s.get_name()
- print sorted(get_names(s.get_namespace()))
- print sorted(l[0].get_names())
- sys.exit(-1)
diff --git a/Lib/compiler/syntax.py b/Lib/compiler/syntax.py
deleted file mode 100644
index a45d9c2cf6f..00000000000
--- a/Lib/compiler/syntax.py
+++ /dev/null
@@ -1,46 +0,0 @@
-"""Check for errs in the AST.
-
-The Python parser does not catch all syntax errors. Others, like
-assignments with invalid targets, are caught in the code generation
-phase.
-
-The compiler package catches some errors in the transformer module.
-But it seems clearer to write checkers that use the AST to detect
-errors.
-"""
-
-from compiler import ast, walk
-
-def check(tree, multi=None):
- v = SyntaxErrorChecker(multi)
- walk(tree, v)
- return v.errors
-
-class SyntaxErrorChecker:
- """A visitor to find syntax errors in the AST."""
-
- def __init__(self, multi=None):
- """Create new visitor object.
-
- If optional argument multi is not None, then print messages
- for each error rather than raising a SyntaxError for the
- first.
- """
- self.multi = multi
- self.errors = 0
-
- def error(self, node, msg):
- self.errors = self.errors + 1
- if self.multi is not None:
- print "%s:%s: %s" % (node.filename, node.lineno, msg)
- else:
- raise SyntaxError, "%s (%s:%s)" % (msg, node.filename, node.lineno)
-
- def visitAssign(self, node):
- # the transformer module handles many of these
- pass
-## for target in node.nodes:
-## if isinstance(target, ast.AssList):
-## if target.lineno is None:
-## target.lineno = node.lineno
-## self.error(target, "can't assign to list comprehension")
diff --git a/Lib/compiler/transformer.py b/Lib/compiler/transformer.py
deleted file mode 100644
index d4f4613f480..00000000000
--- a/Lib/compiler/transformer.py
+++ /dev/null
@@ -1,1535 +0,0 @@
-"""Parse tree transformation module.
-
-Transforms Python source code into an abstract syntax tree (AST)
-defined in the ast module.
-
-The simplest ways to invoke this module are via parse and parseFile.
-parse(buf) -> AST
-parseFile(path) -> AST
-"""
-
-# Original version written by Greg Stein (gstein@lyra.org)
-# and Bill Tutt (rassilon@lima.mudlib.org)
-# February 1997.
-#
-# Modifications and improvements for Python 2.0 by Jeremy Hylton and
-# Mark Hammond
-#
-# Some fixes to try to have correct line number on almost all nodes
-# (except Module, Discard and Stmt) added by Sylvain Thenault
-#
-# Portions of this file are:
-# Copyright (C) 1997-1998 Greg Stein. All Rights Reserved.
-#
-# This module is provided under a BSD-ish license. See
-# http://www.opensource.org/licenses/bsd-license.html
-# and replace OWNER, ORGANIZATION, and YEAR as appropriate.
-
-from compiler.ast import *
-import parser
-import symbol
-import token
-
-class WalkerError(StandardError):
- pass
-
-from compiler.consts import CO_VARARGS, CO_VARKEYWORDS
-from compiler.consts import OP_ASSIGN, OP_DELETE, OP_APPLY
-
-def parseFile(path):
- f = open(path, "U")
- # XXX The parser API tolerates files without a trailing newline,
- # but not strings without a trailing newline. Always add an extra
- # newline to the file contents, since we're going through the string
- # version of the API.
- src = f.read() + "\n"
- f.close()
- return parse(src)
-
-def parse(buf, mode="exec"):
- if mode == "exec" or mode == "single":
- return Transformer().parsesuite(buf)
- elif mode == "eval":
- return Transformer().parseexpr(buf)
- else:
- raise ValueError("compile() arg 3 must be"
- " 'exec' or 'eval' or 'single'")
-
-def asList(nodes):
- l = []
- for item in nodes:
- if hasattr(item, "asList"):
- l.append(item.asList())
- else:
- if type(item) is type( (None, None) ):
- l.append(tuple(asList(item)))
- elif type(item) is type( [] ):
- l.append(asList(item))
- else:
- l.append(item)
- return l
-
-def extractLineNo(ast):
- if not isinstance(ast[1], tuple):
- # get a terminal node
- return ast[2]
- for child in ast[1:]:
- if isinstance(child, tuple):
- lineno = extractLineNo(child)
- if lineno is not None:
- return lineno
-
-def Node(*args):
- kind = args[0]
- if kind in nodes:
- try:
- return nodes[kind](*args[1:])
- except TypeError:
- print nodes[kind], len(args), args
- raise
- else:
- raise WalkerError, "Can't find appropriate Node type: %s" % str(args)
- #return apply(ast.Node, args)
-
-class Transformer:
- """Utility object for transforming Python parse trees.
-
- Exposes the following methods:
- tree = transform(ast_tree)
- tree = parsesuite(text)
- tree = parseexpr(text)
- tree = parsefile(fileob | filename)
- """
-
- def __init__(self):
- self._dispatch = {}
- for value, name in symbol.sym_name.items():
- if hasattr(self, name):
- self._dispatch[value] = getattr(self, name)
- self._dispatch[token.NEWLINE] = self.com_NEWLINE
- self._atom_dispatch = {token.LPAR: self.atom_lpar,
- token.LSQB: self.atom_lsqb,
- token.LBRACE: self.atom_lbrace,
- token.BACKQUOTE: self.atom_backquote,
- token.NUMBER: self.atom_number,
- token.STRING: self.atom_string,
- token.NAME: self.atom_name,
- }
- self.encoding = None
-
- def transform(self, tree):
- """Transform an AST into a modified parse tree."""
- if not (isinstance(tree, tuple) or isinstance(tree, list)):
- tree = parser.st2tuple(tree, line_info=1)
- return self.compile_node(tree)
-
- def parsesuite(self, text):
- """Return a modified parse tree for the given suite text."""
- return self.transform(parser.suite(text))
-
- def parseexpr(self, text):
- """Return a modified parse tree for the given expression text."""
- return self.transform(parser.expr(text))
-
- def parsefile(self, file):
- """Return a modified parse tree for the contents of the given file."""
- if type(file) == type(''):
- file = open(file)
- return self.parsesuite(file.read())
-
- # --------------------------------------------------------------
- #
- # PRIVATE METHODS
- #
-
- def compile_node(self, node):
- ### emit a line-number node?
- n = node[0]
-
- if n == symbol.encoding_decl:
- self.encoding = node[2]
- node = node[1]
- n = node[0]
-
- if n == symbol.single_input:
- return self.single_input(node[1:])
- if n == symbol.file_input:
- return self.file_input(node[1:])
- if n == symbol.eval_input:
- return self.eval_input(node[1:])
- if n == symbol.lambdef:
- return self.lambdef(node[1:])
- if n == symbol.funcdef:
- return self.funcdef(node[1:])
- if n == symbol.classdef:
- return self.classdef(node[1:])
-
- raise WalkerError, ('unexpected node type', n)
-
- def single_input(self, node):
- ### do we want to do anything about being "interactive" ?
-
- # NEWLINE | simple_stmt | compound_stmt NEWLINE
- n = node[0][0]
- if n != token.NEWLINE:
- return self.com_stmt(node[0])
-
- return Pass()
-
- def file_input(self, nodelist):
- doc = self.get_docstring(nodelist, symbol.file_input)
- if doc is not None:
- i = 1
- else:
- i = 0
- stmts = []
- for node in nodelist[i:]:
- if node[0] != token.ENDMARKER and node[0] != token.NEWLINE:
- self.com_append_stmt(stmts, node)
- return Module(doc, Stmt(stmts))
-
- def eval_input(self, nodelist):
- # from the built-in function input()
- ### is this sufficient?
- return Expression(self.com_node(nodelist[0]))
-
- def decorator_name(self, nodelist):
- listlen = len(nodelist)
- assert listlen >= 1 and listlen % 2 == 1
-
- item = self.atom_name(nodelist)
- i = 1
- while i < listlen:
- assert nodelist[i][0] == token.DOT
- assert nodelist[i + 1][0] == token.NAME
- item = Getattr(item, nodelist[i + 1][1])
- i += 2
-
- return item
-
- def decorator(self, nodelist):
- # '@' dotted_name [ '(' [arglist] ')' ]
- assert len(nodelist) in (3, 5, 6)
- assert nodelist[0][0] == token.AT
- assert nodelist[-1][0] == token.NEWLINE
-
- assert nodelist[1][0] == symbol.dotted_name
- funcname = self.decorator_name(nodelist[1][1:])
-
- if len(nodelist) > 3:
- assert nodelist[2][0] == token.LPAR
- expr = self.com_call_function(funcname, nodelist[3])
- else:
- expr = funcname
-
- return expr
-
- def decorators(self, nodelist):
- # decorators: decorator ([NEWLINE] decorator)* NEWLINE
- items = []
- for dec_nodelist in nodelist:
- assert dec_nodelist[0] == symbol.decorator
- items.append(self.decorator(dec_nodelist[1:]))
- return Decorators(items)
-
- def decorated(self, nodelist):
- assert nodelist[0][0] == symbol.decorators
- if nodelist[1][0] == symbol.funcdef:
- n = [nodelist[0]] + list(nodelist[1][1:])
- return self.funcdef(n)
- elif nodelist[1][0] == symbol.classdef:
- decorators = self.decorators(nodelist[0][1:])
- cls = self.classdef(nodelist[1][1:])
- cls.decorators = decorators
- return cls
- raise WalkerError()
-
- def funcdef(self, nodelist):
- # -6 -5 -4 -3 -2 -1
- # funcdef: [decorators] 'def' NAME parameters ':' suite
- # parameters: '(' [varargslist] ')'
-
- if len(nodelist) == 6:
- assert nodelist[0][0] == symbol.decorators
- decorators = self.decorators(nodelist[0][1:])
- else:
- assert len(nodelist) == 5
- decorators = None
-
- lineno = nodelist[-4][2]
- name = nodelist[-4][1]
- args = nodelist[-3][2]
-
- if args[0] == symbol.varargslist:
- names, defaults, flags = self.com_arglist(args[1:])
- else:
- names = defaults = ()
- flags = 0
- doc = self.get_docstring(nodelist[-1])
-
- # code for function
- code = self.com_node(nodelist[-1])
-
- if doc is not None:
- assert isinstance(code, Stmt)
- assert isinstance(code.nodes[0], Discard)
- del code.nodes[0]
- return Function(decorators, name, names, defaults, flags, doc, code,
- lineno=lineno)
-
- def lambdef(self, nodelist):
- # lambdef: 'lambda' [varargslist] ':' test
- if nodelist[2][0] == symbol.varargslist:
- names, defaults, flags = self.com_arglist(nodelist[2][1:])
- else:
- names = defaults = ()
- flags = 0
-
- # code for lambda
- code = self.com_node(nodelist[-1])
-
- return Lambda(names, defaults, flags, code, lineno=nodelist[1][2])
- old_lambdef = lambdef
-
- def classdef(self, nodelist):
- # classdef: 'class' NAME ['(' [testlist] ')'] ':' suite
-
- name = nodelist[1][1]
- doc = self.get_docstring(nodelist[-1])
- if nodelist[2][0] == token.COLON:
- bases = []
- elif nodelist[3][0] == token.RPAR:
- bases = []
- else:
- bases = self.com_bases(nodelist[3])
-
- # code for class
- code = self.com_node(nodelist[-1])
-
- if doc is not None:
- assert isinstance(code, Stmt)
- assert isinstance(code.nodes[0], Discard)
- del code.nodes[0]
-
- return Class(name, bases, doc, code, lineno=nodelist[1][2])
-
- def stmt(self, nodelist):
- return self.com_stmt(nodelist[0])
-
- small_stmt = stmt
- flow_stmt = stmt
- compound_stmt = stmt
-
- def simple_stmt(self, nodelist):
- # small_stmt (';' small_stmt)* [';'] NEWLINE
- stmts = []
- for i in range(0, len(nodelist), 2):
- self.com_append_stmt(stmts, nodelist[i])
- return Stmt(stmts)
-
- def parameters(self, nodelist):
- raise WalkerError
-
- def varargslist(self, nodelist):
- raise WalkerError
-
- def fpdef(self, nodelist):
- raise WalkerError
-
- def fplist(self, nodelist):
- raise WalkerError
-
- def dotted_name(self, nodelist):
- raise WalkerError
-
- def comp_op(self, nodelist):
- raise WalkerError
-
- def trailer(self, nodelist):
- raise WalkerError
-
- def sliceop(self, nodelist):
- raise WalkerError
-
- def argument(self, nodelist):
- raise WalkerError
-
- # --------------------------------------------------------------
- #
- # STATEMENT NODES (invoked by com_node())
- #
-
- def expr_stmt(self, nodelist):
- # augassign testlist | testlist ('=' testlist)*
- en = nodelist[-1]
- exprNode = self.lookup_node(en)(en[1:])
- if len(nodelist) == 1:
- return Discard(exprNode, lineno=exprNode.lineno)
- if nodelist[1][0] == token.EQUAL:
- nodesl = []
- for i in range(0, len(nodelist) - 2, 2):
- nodesl.append(self.com_assign(nodelist[i], OP_ASSIGN))
- return Assign(nodesl, exprNode, lineno=nodelist[1][2])
- else:
- lval = self.com_augassign(nodelist[0])
- op = self.com_augassign_op(nodelist[1])
- return AugAssign(lval, op[1], exprNode, lineno=op[2])
- raise WalkerError, "can't get here"
-
- def print_stmt(self, nodelist):
- # print ([ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ])
- items = []
- if len(nodelist) == 1:
- start = 1
- dest = None
- elif nodelist[1][0] == token.RIGHTSHIFT:
- assert len(nodelist) == 3 \
- or nodelist[3][0] == token.COMMA
- dest = self.com_node(nodelist[2])
- start = 4
- else:
- dest = None
- start = 1
- for i in range(start, len(nodelist), 2):
- items.append(self.com_node(nodelist[i]))
- if nodelist[-1][0] == token.COMMA:
- return Print(items, dest, lineno=nodelist[0][2])
- return Printnl(items, dest, lineno=nodelist[0][2])
-
- def del_stmt(self, nodelist):
- return self.com_assign(nodelist[1], OP_DELETE)
-
- def pass_stmt(self, nodelist):
- return Pass(lineno=nodelist[0][2])
-
- def break_stmt(self, nodelist):
- return Break(lineno=nodelist[0][2])
-
- def continue_stmt(self, nodelist):
- return Continue(lineno=nodelist[0][2])
-
- def return_stmt(self, nodelist):
- # return: [testlist]
- if len(nodelist) < 2:
- return Return(Const(None), lineno=nodelist[0][2])
- return Return(self.com_node(nodelist[1]), lineno=nodelist[0][2])
-
- def yield_stmt(self, nodelist):
- expr = self.com_node(nodelist[0])
- return Discard(expr, lineno=expr.lineno)
-
- def yield_expr(self, nodelist):
- if len(nodelist) > 1:
- value = self.com_node(nodelist[1])
- else:
- value = Const(None)
- return Yield(value, lineno=nodelist[0][2])
-
- def raise_stmt(self, nodelist):
- # raise: [test [',' test [',' test]]]
- if len(nodelist) > 5:
- expr3 = self.com_node(nodelist[5])
- else:
- expr3 = None
- if len(nodelist) > 3:
- expr2 = self.com_node(nodelist[3])
- else:
- expr2 = None
- if len(nodelist) > 1:
- expr1 = self.com_node(nodelist[1])
- else:
- expr1 = None
- return Raise(expr1, expr2, expr3, lineno=nodelist[0][2])
-
- def import_stmt(self, nodelist):
- # import_stmt: import_name | import_from
- assert len(nodelist) == 1
- return self.com_node(nodelist[0])
-
- def import_name(self, nodelist):
- # import_name: 'import' dotted_as_names
- return Import(self.com_dotted_as_names(nodelist[1]),
- lineno=nodelist[0][2])
-
- def import_from(self, nodelist):
- # import_from: 'from' ('.'* dotted_name | '.') 'import' ('*' |
- # '(' import_as_names ')' | import_as_names)
- assert nodelist[0][1] == 'from'
- idx = 1
- while nodelist[idx][1] == '.':
- idx += 1
- level = idx - 1
- if nodelist[idx][0] == symbol.dotted_name:
- fromname = self.com_dotted_name(nodelist[idx])
- idx += 1
- else:
- fromname = ""
- assert nodelist[idx][1] == 'import'
- if nodelist[idx + 1][0] == token.STAR:
- return From(fromname, [('*', None)], level,
- lineno=nodelist[0][2])
- else:
- node = nodelist[idx + 1 + (nodelist[idx + 1][0] == token.LPAR)]
- return From(fromname, self.com_import_as_names(node), level,
- lineno=nodelist[0][2])
-
- def global_stmt(self, nodelist):
- # global: NAME (',' NAME)*
- names = []
- for i in range(1, len(nodelist), 2):
- names.append(nodelist[i][1])
- return Global(names, lineno=nodelist[0][2])
-
- def exec_stmt(self, nodelist):
- # exec_stmt: 'exec' expr ['in' expr [',' expr]]
- expr1 = self.com_node(nodelist[1])
- if len(nodelist) >= 4:
- expr2 = self.com_node(nodelist[3])
- if len(nodelist) >= 6:
- expr3 = self.com_node(nodelist[5])
- else:
- expr3 = None
- else:
- expr2 = expr3 = None
-
- return Exec(expr1, expr2, expr3, lineno=nodelist[0][2])
-
- def assert_stmt(self, nodelist):
- # 'assert': test, [',' test]
- expr1 = self.com_node(nodelist[1])
- if (len(nodelist) == 4):
- expr2 = self.com_node(nodelist[3])
- else:
- expr2 = None
- return Assert(expr1, expr2, lineno=nodelist[0][2])
-
- def if_stmt(self, nodelist):
- # if: test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
- tests = []
- for i in range(0, len(nodelist) - 3, 4):
- testNode = self.com_node(nodelist[i + 1])
- suiteNode = self.com_node(nodelist[i + 3])
- tests.append((testNode, suiteNode))
-
- if len(nodelist) % 4 == 3:
- elseNode = self.com_node(nodelist[-1])
-## elseNode.lineno = nodelist[-1][1][2]
- else:
- elseNode = None
- return If(tests, elseNode, lineno=nodelist[0][2])
-
- def while_stmt(self, nodelist):
- # 'while' test ':' suite ['else' ':' suite]
-
- testNode = self.com_node(nodelist[1])
- bodyNode = self.com_node(nodelist[3])
-
- if len(nodelist) > 4:
- elseNode = self.com_node(nodelist[6])
- else:
- elseNode = None
-
- return While(testNode, bodyNode, elseNode, lineno=nodelist[0][2])
-
- def for_stmt(self, nodelist):
- # 'for' exprlist 'in' exprlist ':' suite ['else' ':' suite]
-
- assignNode = self.com_assign(nodelist[1], OP_ASSIGN)
- listNode = self.com_node(nodelist[3])
- bodyNode = self.com_node(nodelist[5])
-
- if len(nodelist) > 8:
- elseNode = self.com_node(nodelist[8])
- else:
- elseNode = None
-
- return For(assignNode, listNode, bodyNode, elseNode,
- lineno=nodelist[0][2])
-
- def try_stmt(self, nodelist):
- return self.com_try_except_finally(nodelist)
-
- def with_stmt(self, nodelist):
- return self.com_with(nodelist)
-
- def with_var(self, nodelist):
- return self.com_with_var(nodelist)
-
- def suite(self, nodelist):
- # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
- if len(nodelist) == 1:
- return self.com_stmt(nodelist[0])
-
- stmts = []
- for node in nodelist:
- if node[0] == symbol.stmt:
- self.com_append_stmt(stmts, node)
- return Stmt(stmts)
-
- # --------------------------------------------------------------
- #
- # EXPRESSION NODES (invoked by com_node())
- #
-
- def testlist(self, nodelist):
- # testlist: expr (',' expr)* [',']
- # testlist_safe: test [(',' test)+ [',']]
- # exprlist: expr (',' expr)* [',']
- return self.com_binary(Tuple, nodelist)
-
- testlist_safe = testlist # XXX
- testlist1 = testlist
- exprlist = testlist
-
- def testlist_comp(self, nodelist):
- # test ( comp_for | (',' test)* [','] )
- assert nodelist[0][0] == symbol.test
- if len(nodelist) == 2 and nodelist[1][0] == symbol.comp_for:
- test = self.com_node(nodelist[0])
- return self.com_generator_expression(test, nodelist[1])
- return self.testlist(nodelist)
-
- def test(self, nodelist):
- # or_test ['if' or_test 'else' test] | lambdef
- if len(nodelist) == 1 and nodelist[0][0] == symbol.lambdef:
- return self.lambdef(nodelist[0])
- then = self.com_node(nodelist[0])
- if len(nodelist) > 1:
- assert len(nodelist) == 5
- assert nodelist[1][1] == 'if'
- assert nodelist[3][1] == 'else'
- test = self.com_node(nodelist[2])
- else_ = self.com_node(nodelist[4])
- return IfExp(test, then, else_, lineno=nodelist[1][2])
- return then
-
- def or_test(self, nodelist):
- # and_test ('or' and_test)* | lambdef
- if len(nodelist) == 1 and nodelist[0][0] == symbol.lambdef:
- return self.lambdef(nodelist[0])
- return self.com_binary(Or, nodelist)
- old_test = or_test
-
- def and_test(self, nodelist):
- # not_test ('and' not_test)*
- return self.com_binary(And, nodelist)
-
- def not_test(self, nodelist):
- # 'not' not_test | comparison
- result = self.com_node(nodelist[-1])
- if len(nodelist) == 2:
- return Not(result, lineno=nodelist[0][2])
- return result
-
- def comparison(self, nodelist):
- # comparison: expr (comp_op expr)*
- node = self.com_node(nodelist[0])
- if len(nodelist) == 1:
- return node
-
- results = []
- for i in range(2, len(nodelist), 2):
- nl = nodelist[i-1]
-
- # comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '=='
- # | 'in' | 'not' 'in' | 'is' | 'is' 'not'
- n = nl[1]
- if n[0] == token.NAME:
- type = n[1]
- if len(nl) == 3:
- if type == 'not':
- type = 'not in'
- else:
- type = 'is not'
- else:
- type = _cmp_types[n[0]]
-
- lineno = nl[1][2]
- results.append((type, self.com_node(nodelist[i])))
-
- # we need a special "compare" node so that we can distinguish
- # 3 < x < 5 from (3 < x) < 5
- # the two have very different semantics and results (note that the
- # latter form is always true)
-
- return Compare(node, results, lineno=lineno)
-
- def expr(self, nodelist):
- # xor_expr ('|' xor_expr)*
- return self.com_binary(Bitor, nodelist)
-
- def xor_expr(self, nodelist):
- # xor_expr ('^' xor_expr)*
- return self.com_binary(Bitxor, nodelist)
-
- def and_expr(self, nodelist):
- # xor_expr ('&' xor_expr)*
- return self.com_binary(Bitand, nodelist)
-
- def shift_expr(self, nodelist):
- # shift_expr ('<<'|'>>' shift_expr)*
- node = self.com_node(nodelist[0])
- for i in range(2, len(nodelist), 2):
- right = self.com_node(nodelist[i])
- if nodelist[i-1][0] == token.LEFTSHIFT:
- node = LeftShift([node, right], lineno=nodelist[1][2])
- elif nodelist[i-1][0] == token.RIGHTSHIFT:
- node = RightShift([node, right], lineno=nodelist[1][2])
- else:
- raise ValueError, "unexpected token: %s" % nodelist[i-1][0]
- return node
-
- def arith_expr(self, nodelist):
- node = self.com_node(nodelist[0])
- for i in range(2, len(nodelist), 2):
- right = self.com_node(nodelist[i])
- if nodelist[i-1][0] == token.PLUS:
- node = Add([node, right], lineno=nodelist[1][2])
- elif nodelist[i-1][0] == token.MINUS:
- node = Sub([node, right], lineno=nodelist[1][2])
- else:
- raise ValueError, "unexpected token: %s" % nodelist[i-1][0]
- return node
-
- def term(self, nodelist):
- node = self.com_node(nodelist[0])
- for i in range(2, len(nodelist), 2):
- right = self.com_node(nodelist[i])
- t = nodelist[i-1][0]
- if t == token.STAR:
- node = Mul([node, right])
- elif t == token.SLASH:
- node = Div([node, right])
- elif t == token.PERCENT:
- node = Mod([node, right])
- elif t == token.DOUBLESLASH:
- node = FloorDiv([node, right])
- else:
- raise ValueError, "unexpected token: %s" % t
- node.lineno = nodelist[1][2]
- return node
-
- def factor(self, nodelist):
- elt = nodelist[0]
- t = elt[0]
- node = self.lookup_node(nodelist[-1])(nodelist[-1][1:])
- # need to handle (unary op)constant here...
- if t == token.PLUS:
- return UnaryAdd(node, lineno=elt[2])
- elif t == token.MINUS:
- return UnarySub(node, lineno=elt[2])
- elif t == token.TILDE:
- node = Invert(node, lineno=elt[2])
- return node
-
- def power(self, nodelist):
- # power: atom trailer* ('**' factor)*
- node = self.com_node(nodelist[0])
- for i in range(1, len(nodelist)):
- elt = nodelist[i]
- if elt[0] == token.DOUBLESTAR:
- return Power([node, self.com_node(nodelist[i+1])],
- lineno=elt[2])
-
- node = self.com_apply_trailer(node, elt)
-
- return node
-
- def atom(self, nodelist):
- return self._atom_dispatch[nodelist[0][0]](nodelist)
-
- def atom_lpar(self, nodelist):
- if nodelist[1][0] == token.RPAR:
- return Tuple((), lineno=nodelist[0][2])
- return self.com_node(nodelist[1])
-
- def atom_lsqb(self, nodelist):
- if nodelist[1][0] == token.RSQB:
- return List((), lineno=nodelist[0][2])
- return self.com_list_constructor(nodelist[1])
-
- def atom_lbrace(self, nodelist):
- if nodelist[1][0] == token.RBRACE:
- return Dict((), lineno=nodelist[0][2])
- return self.com_dictorsetmaker(nodelist[1])
-
- def atom_backquote(self, nodelist):
- return Backquote(self.com_node(nodelist[1]))
-
- def atom_number(self, nodelist):
- ### need to verify this matches compile.c
- k = eval(nodelist[0][1])
- return Const(k, lineno=nodelist[0][2])
-
- def decode_literal(self, lit):
- if self.encoding:
- # this is particularly fragile & a bit of a
- # hack... changes in compile.c:parsestr and
- # tokenizer.c must be reflected here.
- if self.encoding not in ['utf-8', 'iso-8859-1']:
- lit = unicode(lit, 'utf-8').encode(self.encoding)
- return eval("# coding: %s\n%s" % (self.encoding, lit))
- else:
- return eval(lit)
-
- def atom_string(self, nodelist):
- k = ''
- for node in nodelist:
- k += self.decode_literal(node[1])
- return Const(k, lineno=nodelist[0][2])
-
- def atom_name(self, nodelist):
- return Name(nodelist[0][1], lineno=nodelist[0][2])
-
- # --------------------------------------------------------------
- #
- # INTERNAL PARSING UTILITIES
- #
-
- # The use of com_node() introduces a lot of extra stack frames,
- # enough to cause a stack overflow compiling test.test_parser with
- # the standard interpreter recursionlimit. The com_node() is a
- # convenience function that hides the dispatch details, but comes
- # at a very high cost. It is more efficient to dispatch directly
- # in the callers. In these cases, use lookup_node() and call the
- # dispatched node directly.
-
- def lookup_node(self, node):
- return self._dispatch[node[0]]
-
- def com_node(self, node):
- # Note: compile.c has handling in com_node for del_stmt, pass_stmt,
- # break_stmt, stmt, small_stmt, flow_stmt, simple_stmt,
- # and compound_stmt.
- # We'll just dispatch them.
- return self._dispatch[node[0]](node[1:])
-
- def com_NEWLINE(self, *args):
- # A ';' at the end of a line can make a NEWLINE token appear
- # here, Render it harmless. (genc discards ('discard',
- # ('const', xxxx)) Nodes)
- return Discard(Const(None))
-
- def com_arglist(self, nodelist):
- # varargslist:
- # (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME)
- # | fpdef ['=' test] (',' fpdef ['=' test])* [',']
- # fpdef: NAME | '(' fplist ')'
- # fplist: fpdef (',' fpdef)* [',']
- names = []
- defaults = []
- flags = 0
-
- i = 0
- while i < len(nodelist):
- node = nodelist[i]
- if node[0] == token.STAR or node[0] == token.DOUBLESTAR:
- if node[0] == token.STAR:
- node = nodelist[i+1]
- if node[0] == token.NAME:
- names.append(node[1])
- flags = flags | CO_VARARGS
- i = i + 3
-
- if i < len(nodelist):
- # should be DOUBLESTAR
- t = nodelist[i][0]
- if t == token.DOUBLESTAR:
- node = nodelist[i+1]
- else:
- raise ValueError, "unexpected token: %s" % t
- names.append(node[1])
- flags = flags | CO_VARKEYWORDS
-
- break
-
- # fpdef: NAME | '(' fplist ')'
- names.append(self.com_fpdef(node))
-
- i = i + 1
- if i < len(nodelist) and nodelist[i][0] == token.EQUAL:
- defaults.append(self.com_node(nodelist[i + 1]))
- i = i + 2
- elif len(defaults):
- # we have already seen an argument with default, but here
- # came one without
- raise SyntaxError, "non-default argument follows default argument"
-
- # skip the comma
- i = i + 1
-
- return names, defaults, flags
-
- def com_fpdef(self, node):
- # fpdef: NAME | '(' fplist ')'
- if node[1][0] == token.LPAR:
- return self.com_fplist(node[2])
- return node[1][1]
-
- def com_fplist(self, node):
- # fplist: fpdef (',' fpdef)* [',']
- if len(node) == 2:
- return self.com_fpdef(node[1])
- list = []
- for i in range(1, len(node), 2):
- list.append(self.com_fpdef(node[i]))
- return tuple(list)
-
- def com_dotted_name(self, node):
- # String together the dotted names and return the string
- name = ""
- for n in node:
- if type(n) == type(()) and n[0] == 1:
- name = name + n[1] + '.'
- return name[:-1]
-
- def com_dotted_as_name(self, node):
- assert node[0] == symbol.dotted_as_name
- node = node[1:]
- dot = self.com_dotted_name(node[0][1:])
- if len(node) == 1:
- return dot, None
- assert node[1][1] == 'as'
- assert node[2][0] == token.NAME
- return dot, node[2][1]
-
- def com_dotted_as_names(self, node):
- assert node[0] == symbol.dotted_as_names
- node = node[1:]
- names = [self.com_dotted_as_name(node[0])]
- for i in range(2, len(node), 2):
- names.append(self.com_dotted_as_name(node[i]))
- return names
-
- def com_import_as_name(self, node):
- assert node[0] == symbol.import_as_name
- node = node[1:]
- assert node[0][0] == token.NAME
- if len(node) == 1:
- return node[0][1], None
- assert node[1][1] == 'as', node
- assert node[2][0] == token.NAME
- return node[0][1], node[2][1]
-
- def com_import_as_names(self, node):
- assert node[0] == symbol.import_as_names
- node = node[1:]
- names = [self.com_import_as_name(node[0])]
- for i in range(2, len(node), 2):
- names.append(self.com_import_as_name(node[i]))
- return names
-
- def com_bases(self, node):
- bases = []
- for i in range(1, len(node), 2):
- bases.append(self.com_node(node[i]))
- return bases
-
- def com_try_except_finally(self, nodelist):
- # ('try' ':' suite
- # ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite]
- # | 'finally' ':' suite))
-
- if nodelist[3][0] == token.NAME:
- # first clause is a finally clause: only try-finally
- return TryFinally(self.com_node(nodelist[2]),
- self.com_node(nodelist[5]),
- lineno=nodelist[0][2])
-
- #tryexcept: [TryNode, [except_clauses], elseNode)]
- clauses = []
- elseNode = None
- finallyNode = None
- for i in range(3, len(nodelist), 3):
- node = nodelist[i]
- if node[0] == symbol.except_clause:
- # except_clause: 'except' [expr [(',' | 'as') expr]] */
- if len(node) > 2:
- expr1 = self.com_node(node[2])
- if len(node) > 4:
- expr2 = self.com_assign(node[4], OP_ASSIGN)
- else:
- expr2 = None
- else:
- expr1 = expr2 = None
- clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))
-
- if node[0] == token.NAME:
- if node[1] == 'else':
- elseNode = self.com_node(nodelist[i+2])
- elif node[1] == 'finally':
- finallyNode = self.com_node(nodelist[i+2])
- try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
- lineno=nodelist[0][2])
- if finallyNode:
- return TryFinally(try_except, finallyNode, lineno=nodelist[0][2])
- else:
- return try_except
-
- def com_with(self, nodelist):
- # with_stmt: 'with' with_item (',' with_item)* ':' suite
- body = self.com_node(nodelist[-1])
- for i in range(len(nodelist) - 3, 0, -2):
- ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
- if i == 1:
- return ret
- body = ret
-
- def com_with_item(self, nodelist, body, lineno):
- # with_item: test ['as' expr]
- if len(nodelist) == 4:
- var = self.com_assign(nodelist[3], OP_ASSIGN)
- else:
- var = None
- expr = self.com_node(nodelist[1])
- return With(expr, var, body, lineno=lineno)
-
- def com_augassign_op(self, node):
- assert node[0] == symbol.augassign
- return node[1]
-
- def com_augassign(self, node):
- """Return node suitable for lvalue of augmented assignment
-
- Names, slices, and attributes are the only allowable nodes.
- """
- l = self.com_node(node)
- if l.__class__ in (Name, Slice, Subscript, Getattr):
- return l
- raise SyntaxError, "can't assign to %s" % l.__class__.__name__
-
- def com_assign(self, node, assigning):
- # return a node suitable for use as an "lvalue"
- # loop to avoid trivial recursion
- while 1:
- t = node[0]
- if t in (symbol.exprlist, symbol.testlist, symbol.testlist_safe, symbol.testlist_comp):
- if len(node) > 2:
- return self.com_assign_tuple(node, assigning)
- node = node[1]
- elif t in _assign_types:
- if len(node) > 2:
- raise SyntaxError, "can't assign to operator"
- node = node[1]
- elif t == symbol.power:
- if node[1][0] != symbol.atom:
- raise SyntaxError, "can't assign to operator"
- if len(node) > 2:
- primary = self.com_node(node[1])
- for i in range(2, len(node)-1):
- ch = node[i]
- if ch[0] == token.DOUBLESTAR:
- raise SyntaxError, "can't assign to operator"
- primary = self.com_apply_trailer(primary, ch)
- return self.com_assign_trailer(primary, node[-1],
- assigning)
- node = node[1]
- elif t == symbol.atom:
- t = node[1][0]
- if t == token.LPAR:
- node = node[2]
- if node[0] == token.RPAR:
- raise SyntaxError, "can't assign to ()"
- elif t == token.LSQB:
- node = node[2]
- if node[0] == token.RSQB:
- raise SyntaxError, "can't assign to []"
- return self.com_assign_list(node, assigning)
- elif t == token.NAME:
- return self.com_assign_name(node[1], assigning)
- else:
- raise SyntaxError, "can't assign to literal"
- else:
- raise SyntaxError, "bad assignment (%s)" % t
-
- def com_assign_tuple(self, node, assigning):
- assigns = []
- for i in range(1, len(node), 2):
- assigns.append(self.com_assign(node[i], assigning))
- return AssTuple(assigns, lineno=extractLineNo(node))
-
- def com_assign_list(self, node, assigning):
- assigns = []
- for i in range(1, len(node), 2):
- if i + 1 < len(node):
- if node[i + 1][0] == symbol.list_for:
- raise SyntaxError, "can't assign to list comprehension"
- assert node[i + 1][0] == token.COMMA, node[i + 1]
- assigns.append(self.com_assign(node[i], assigning))
- return AssList(assigns, lineno=extractLineNo(node))
-
- def com_assign_name(self, node, assigning):
- return AssName(node[1], assigning, lineno=node[2])
-
- def com_assign_trailer(self, primary, node, assigning):
- t = node[1][0]
- if t == token.DOT:
- return self.com_assign_attr(primary, node[2], assigning)
- if t == token.LSQB:
- return self.com_subscriptlist(primary, node[2], assigning)
- if t == token.LPAR:
- raise SyntaxError, "can't assign to function call"
- raise SyntaxError, "unknown trailer type: %s" % t
-
- def com_assign_attr(self, primary, node, assigning):
- return AssAttr(primary, node[1], assigning, lineno=node[-1])
-
- def com_binary(self, constructor, nodelist):
- "Compile 'NODE (OP NODE)*' into (type, [ node1, ..., nodeN ])."
- l = len(nodelist)
- if l == 1:
- n = nodelist[0]
- return self.lookup_node(n)(n[1:])
- items = []
- for i in range(0, l, 2):
- n = nodelist[i]
- items.append(self.lookup_node(n)(n[1:]))
- return constructor(items, lineno=extractLineNo(nodelist))
-
- def com_stmt(self, node):
- result = self.lookup_node(node)(node[1:])
- assert result is not None
- if isinstance(result, Stmt):
- return result
- return Stmt([result])
-
- def com_append_stmt(self, stmts, node):
- result = self.lookup_node(node)(node[1:])
- assert result is not None
- if isinstance(result, Stmt):
- stmts.extend(result.nodes)
- else:
- stmts.append(result)
-
- def com_list_constructor(self, nodelist):
- # listmaker: test ( list_for | (',' test)* [','] )
- values = []
- for i in range(1, len(nodelist)):
- if nodelist[i][0] == symbol.list_for:
- assert len(nodelist[i:]) == 1
- return self.com_list_comprehension(values[0],
- nodelist[i])
- elif nodelist[i][0] == token.COMMA:
- continue
- values.append(self.com_node(nodelist[i]))
- return List(values, lineno=values[0].lineno)
-
- def com_list_comprehension(self, expr, node):
- return self.com_comprehension(expr, None, node, 'list')
-
- def com_comprehension(self, expr1, expr2, node, type):
- # list_iter: list_for | list_if
- # list_for: 'for' exprlist 'in' testlist [list_iter]
- # list_if: 'if' test [list_iter]
-
- # XXX should raise SyntaxError for assignment
- # XXX(avassalotti) Set and dict comprehensions should have generator
- # semantics. In other words, they shouldn't leak
- # variables outside of the comprehension's scope.
-
- lineno = node[1][2]
- fors = []
- while node:
- t = node[1][1]
- if t == 'for':
- assignNode = self.com_assign(node[2], OP_ASSIGN)
- compNode = self.com_node(node[4])
- newfor = ListCompFor(assignNode, compNode, [])
- newfor.lineno = node[1][2]
- fors.append(newfor)
- if len(node) == 5:
- node = None
- elif type == 'list':
- node = self.com_list_iter(node[5])
- else:
- node = self.com_comp_iter(node[5])
- elif t == 'if':
- test = self.com_node(node[2])
- newif = ListCompIf(test, lineno=node[1][2])
- newfor.ifs.append(newif)
- if len(node) == 3:
- node = None
- elif type == 'list':
- node = self.com_list_iter(node[3])
- else:
- node = self.com_comp_iter(node[3])
- else:
- raise SyntaxError, \
- ("unexpected comprehension element: %s %d"
- % (node, lineno))
- if type == 'list':
- return ListComp(expr1, fors, lineno=lineno)
- elif type == 'set':
- return SetComp(expr1, fors, lineno=lineno)
- elif type == 'dict':
- return DictComp(expr1, expr2, fors, lineno=lineno)
- else:
- raise ValueError("unexpected comprehension type: " + repr(type))
-
- def com_list_iter(self, node):
- assert node[0] == symbol.list_iter
- return node[1]
-
- def com_comp_iter(self, node):
- assert node[0] == symbol.comp_iter
- return node[1]
-
- def com_generator_expression(self, expr, node):
- # comp_iter: comp_for | comp_if
- # comp_for: 'for' exprlist 'in' test [comp_iter]
- # comp_if: 'if' test [comp_iter]
-
- lineno = node[1][2]
- fors = []
- while node:
- t = node[1][1]
- if t == 'for':
- assignNode = self.com_assign(node[2], OP_ASSIGN)
- genNode = self.com_node(node[4])
- newfor = GenExprFor(assignNode, genNode, [],
- lineno=node[1][2])
- fors.append(newfor)
- if (len(node)) == 5:
- node = None
- else:
- node = self.com_comp_iter(node[5])
- elif t == 'if':
- test = self.com_node(node[2])
- newif = GenExprIf(test, lineno=node[1][2])
- newfor.ifs.append(newif)
- if len(node) == 3:
- node = None
- else:
- node = self.com_comp_iter(node[3])
- else:
- raise SyntaxError, \
- ("unexpected generator expression element: %s %d"
- % (node, lineno))
- fors[0].is_outmost = True
- return GenExpr(GenExprInner(expr, fors), lineno=lineno)
-
- def com_dictorsetmaker(self, nodelist):
- # dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |
- # (test (comp_for | (',' test)* [','])) )
- assert nodelist[0] == symbol.dictorsetmaker
- nodelist = nodelist[1:]
- if len(nodelist) == 1 or nodelist[1][0] == token.COMMA:
- # set literal
- items = []
- for i in range(0, len(nodelist), 2):
- items.append(self.com_node(nodelist[i]))
- return Set(items, lineno=items[0].lineno)
- elif nodelist[1][0] == symbol.comp_for:
- # set comprehension
- expr = self.com_node(nodelist[0])
- return self.com_comprehension(expr, None, nodelist[1], 'set')
- elif len(nodelist) > 3 and nodelist[3][0] == symbol.comp_for:
- # dict comprehension
- assert nodelist[1][0] == token.COLON
- key = self.com_node(nodelist[0])
- value = self.com_node(nodelist[2])
- return self.com_comprehension(key, value, nodelist[3], 'dict')
- else:
- # dict literal
- items = []
- for i in range(0, len(nodelist), 4):
- items.append((self.com_node(nodelist[i]),
- self.com_node(nodelist[i+2])))
- return Dict(items, lineno=items[0][0].lineno)
-
- def com_apply_trailer(self, primaryNode, nodelist):
- t = nodelist[1][0]
- if t == token.LPAR:
- return self.com_call_function(primaryNode, nodelist[2])
- if t == token.DOT:
- return self.com_select_member(primaryNode, nodelist[2])
- if t == token.LSQB:
- return self.com_subscriptlist(primaryNode, nodelist[2], OP_APPLY)
-
- raise SyntaxError, 'unknown node type: %s' % t
-
- def com_select_member(self, primaryNode, nodelist):
- if nodelist[0] != token.NAME:
- raise SyntaxError, "member must be a name"
- return Getattr(primaryNode, nodelist[1], lineno=nodelist[2])
-
- def com_call_function(self, primaryNode, nodelist):
- if nodelist[0] == token.RPAR:
- return CallFunc(primaryNode, [], lineno=extractLineNo(nodelist))
- args = []
- kw = 0
- star_node = dstar_node = None
- len_nodelist = len(nodelist)
- i = 1
- while i < len_nodelist:
- node = nodelist[i]
-
- if node[0]==token.STAR:
- if star_node is not None:
- raise SyntaxError, 'already have the varargs indentifier'
- star_node = self.com_node(nodelist[i+1])
- i = i + 3
- continue
- elif node[0]==token.DOUBLESTAR:
- if dstar_node is not None:
- raise SyntaxError, 'already have the kwargs indentifier'
- dstar_node = self.com_node(nodelist[i+1])
- i = i + 3
- continue
-
- # positional or named parameters
- kw, result = self.com_argument(node, kw, star_node)
-
- if len_nodelist != 2 and isinstance(result, GenExpr) \
- and len(node) == 3 and node[2][0] == symbol.comp_for:
- # allow f(x for x in y), but reject f(x for x in y, 1)
- # should use f((x for x in y), 1) instead of f(x for x in y, 1)
- raise SyntaxError, 'generator expression needs parenthesis'
-
- args.append(result)
- i = i + 2
-
- return CallFunc(primaryNode, args, star_node, dstar_node,
- lineno=extractLineNo(nodelist))
-
- def com_argument(self, nodelist, kw, star_node):
- if len(nodelist) == 3 and nodelist[2][0] == symbol.comp_for:
- test = self.com_node(nodelist[1])
- return 0, self.com_generator_expression(test, nodelist[2])
- if len(nodelist) == 2:
- if kw:
- raise SyntaxError, "non-keyword arg after keyword arg"
- if star_node:
- raise SyntaxError, "only named arguments may follow *expression"
- return 0, self.com_node(nodelist[1])
- result = self.com_node(nodelist[3])
- n = nodelist[1]
- while len(n) == 2 and n[0] != token.NAME:
- n = n[1]
- if n[0] != token.NAME:
- raise SyntaxError, "keyword can't be an expression (%s)"%n[0]
- node = Keyword(n[1], result, lineno=n[2])
- return 1, node
-
- def com_subscriptlist(self, primary, nodelist, assigning):
- # slicing: simple_slicing | extended_slicing
- # simple_slicing: primary "[" short_slice "]"
- # extended_slicing: primary "[" slice_list "]"
- # slice_list: slice_item ("," slice_item)* [","]
-
- # backwards compat slice for '[i:j]'
- if len(nodelist) == 2:
- sub = nodelist[1]
- if (sub[1][0] == token.COLON or \
- (len(sub) > 2 and sub[2][0] == token.COLON)) and \
- sub[-1][0] != symbol.sliceop:
- return self.com_slice(primary, sub, assigning)
-
- subscripts = []
- for i in range(1, len(nodelist), 2):
- subscripts.append(self.com_subscript(nodelist[i]))
- return Subscript(primary, assigning, subscripts,
- lineno=extractLineNo(nodelist))
-
- def com_subscript(self, node):
- # slice_item: expression | proper_slice | ellipsis
- ch = node[1]
- t = ch[0]
- if t == token.DOT and node[2][0] == token.DOT:
- return Ellipsis()
- if t == token.COLON or len(node) > 2:
- return self.com_sliceobj(node)
- return self.com_node(ch)
-
- def com_sliceobj(self, node):
- # proper_slice: short_slice | long_slice
- # short_slice: [lower_bound] ":" [upper_bound]
- # long_slice: short_slice ":" [stride]
- # lower_bound: expression
- # upper_bound: expression
- # stride: expression
- #
- # Note: a stride may be further slicing...
-
- items = []
-
- if node[1][0] == token.COLON:
- items.append(Const(None))
- i = 2
- else:
- items.append(self.com_node(node[1]))
- # i == 2 is a COLON
- i = 3
-
- if i < len(node) and node[i][0] == symbol.test:
- items.append(self.com_node(node[i]))
- i = i + 1
- else:
- items.append(Const(None))
-
- # a short_slice has been built. look for long_slice now by looking
- # for strides...
- for j in range(i, len(node)):
- ch = node[j]
- if len(ch) == 2:
- items.append(Const(None))
- else:
- items.append(self.com_node(ch[2]))
- return Sliceobj(items, lineno=extractLineNo(node))
-
- def com_slice(self, primary, node, assigning):
- # short_slice: [lower_bound] ":" [upper_bound]
- lower = upper = None
- if len(node) == 3:
- if node[1][0] == token.COLON:
- upper = self.com_node(node[2])
- else:
- lower = self.com_node(node[1])
- elif len(node) == 4:
- lower = self.com_node(node[1])
- upper = self.com_node(node[3])
- return Slice(primary, assigning, lower, upper,
- lineno=extractLineNo(node))
-
- def get_docstring(self, node, n=None):
- if n is None:
- n = node[0]
- node = node[1:]
- if n == symbol.suite:
- if len(node) == 1:
- return self.get_docstring(node[0])
- for sub in node:
- if sub[0] == symbol.stmt:
- return self.get_docstring(sub)
- return None
- if n == symbol.file_input:
- for sub in node:
- if sub[0] == symbol.stmt:
- return self.get_docstring(sub)
- return None
- if n == symbol.atom:
- if node[0][0] == token.STRING:
- s = ''
- for t in node:
- s = s + eval(t[1])
- return s
- return None
- if n == symbol.stmt or n == symbol.simple_stmt \
- or n == symbol.small_stmt:
- return self.get_docstring(node[0])
- if n in _doc_nodes and len(node) == 1:
- return self.get_docstring(node[0])
- return None
-
-
-_doc_nodes = [
- symbol.expr_stmt,
- symbol.testlist,
- symbol.testlist_safe,
- symbol.test,
- symbol.or_test,
- symbol.and_test,
- symbol.not_test,
- symbol.comparison,
- symbol.expr,
- symbol.xor_expr,
- symbol.and_expr,
- symbol.shift_expr,
- symbol.arith_expr,
- symbol.term,
- symbol.factor,
- symbol.power,
- ]
-
-# comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '=='
-# | 'in' | 'not' 'in' | 'is' | 'is' 'not'
-_cmp_types = {
- token.LESS : '<',
- token.GREATER : '>',
- token.EQEQUAL : '==',
- token.EQUAL : '==',
- token.LESSEQUAL : '<=',
- token.GREATEREQUAL : '>=',
- token.NOTEQUAL : '!=',
- }
-
-_legal_node_types = [
- symbol.funcdef,
- symbol.classdef,
- symbol.stmt,
- symbol.small_stmt,
- symbol.flow_stmt,
- symbol.simple_stmt,
- symbol.compound_stmt,
- symbol.expr_stmt,
- symbol.print_stmt,
- symbol.del_stmt,
- symbol.pass_stmt,
- symbol.break_stmt,
- symbol.continue_stmt,
- symbol.return_stmt,
- symbol.raise_stmt,
- symbol.import_stmt,
- symbol.global_stmt,
- symbol.exec_stmt,
- symbol.assert_stmt,
- symbol.if_stmt,
- symbol.while_stmt,
- symbol.for_stmt,
- symbol.try_stmt,
- symbol.with_stmt,
- symbol.suite,
- symbol.testlist,
- symbol.testlist_safe,
- symbol.test,
- symbol.and_test,
- symbol.not_test,
- symbol.comparison,
- symbol.exprlist,
- symbol.expr,
- symbol.xor_expr,
- symbol.and_expr,
- symbol.shift_expr,
- symbol.arith_expr,
- symbol.term,
- symbol.factor,
- symbol.power,
- symbol.atom,
- ]
-
-if hasattr(symbol, 'yield_stmt'):
- _legal_node_types.append(symbol.yield_stmt)
-if hasattr(symbol, 'yield_expr'):
- _legal_node_types.append(symbol.yield_expr)
-
-_assign_types = [
- symbol.test,
- symbol.or_test,
- symbol.and_test,
- symbol.not_test,
- symbol.comparison,
- symbol.expr,
- symbol.xor_expr,
- symbol.and_expr,
- symbol.shift_expr,
- symbol.arith_expr,
- symbol.term,
- symbol.factor,
- ]
-
-_names = {}
-for k, v in symbol.sym_name.items():
- _names[k] = v
-for k, v in token.tok_name.items():
- _names[k] = v
-
-def debug_tree(tree):
- l = []
- for elt in tree:
- if isinstance(elt, int):
- l.append(_names.get(elt, elt))
- elif isinstance(elt, str):
- l.append(elt)
- else:
- l.append(debug_tree(elt))
- return l
diff --git a/Lib/compiler/visitor.py b/Lib/compiler/visitor.py
deleted file mode 100644
index f10f56011a3..00000000000
--- a/Lib/compiler/visitor.py
+++ /dev/null
@@ -1,113 +0,0 @@
-from compiler import ast
-
-# XXX should probably rename ASTVisitor to ASTWalker
-# XXX can it be made even more generic?
-
-class ASTVisitor:
- """Performs a depth-first walk of the AST
-
- The ASTVisitor will walk the AST, performing either a preorder or
- postorder traversal depending on which method is called.
-
- methods:
- preorder(tree, visitor)
- postorder(tree, visitor)
- tree: an instance of ast.Node
- visitor: an instance with visitXXX methods
-
- The ASTVisitor is responsible for walking over the tree in the
- correct order. For each node, it checks the visitor argument for
- a method named 'visitNodeType' where NodeType is the name of the
- node's class, e.g. Class. If the method exists, it is called
- with the node as its sole argument.
-
- The visitor method for a particular node type can control how
- child nodes are visited during a preorder walk. (It can't control
- the order during a postorder walk, because it is called _after_
- the walk has occurred.) The ASTVisitor modifies the visitor
- argument by adding a visit method to the visitor; this method can
- be used to visit a child node of arbitrary type.
- """
-
- VERBOSE = 0
-
- def __init__(self):
- self.node = None
- self._cache = {}
-
- def default(self, node, *args):
- for child in node.getChildNodes():
- self.dispatch(child, *args)
-
- def dispatch(self, node, *args):
- self.node = node
- klass = node.__class__
- meth = self._cache.get(klass, None)
- if meth is None:
- className = klass.__name__
- meth = getattr(self.visitor, 'visit' + className, self.default)
- self._cache[klass] = meth
-## if self.VERBOSE > 0:
-## className = klass.__name__
-## if self.VERBOSE == 1:
-## if meth == 0:
-## print "dispatch", className
-## else:
-## print "dispatch", className, (meth and meth.__name__ or '')
- return meth(node, *args)
-
- def preorder(self, tree, visitor, *args):
- """Do preorder walk of tree using visitor"""
- self.visitor = visitor
- visitor.visit = self.dispatch
- self.dispatch(tree, *args) # XXX *args make sense?
-
-class ExampleASTVisitor(ASTVisitor):
- """Prints examples of the nodes that aren't visited
-
- This visitor-driver is only useful for development, when it's
- helpful to develop a visitor incrementally, and get feedback on what
- you still have to do.
- """
- examples = {}
-
- def dispatch(self, node, *args):
- self.node = node
- meth = self._cache.get(node.__class__, None)
- className = node.__class__.__name__
- if meth is None:
- meth = getattr(self.visitor, 'visit' + className, 0)
- self._cache[node.__class__] = meth
- if self.VERBOSE > 1:
- print "dispatch", className, (meth and meth.__name__ or '')
- if meth:
- meth(node, *args)
- elif self.VERBOSE > 0:
- klass = node.__class__
- if klass not in self.examples:
- self.examples[klass] = klass
- print
- print self.visitor
- print klass
- for attr in dir(node):
- if attr[0] != '_':
- print "\t", "%-12.12s" % attr, getattr(node, attr)
- print
- return self.default(node, *args)
-
-# XXX this is an API change
-
-_walker = ASTVisitor
-def walk(tree, visitor, walker=None, verbose=None):
- if walker is None:
- walker = _walker()
- if verbose is not None:
- walker.VERBOSE = verbose
- walker.preorder(tree, visitor)
- return walker.visitor
-
-def dumpNode(node):
- print node.__class__
- for attr in dir(node):
- if attr[0] != '_':
- print "\t", "%-10.10s" % attr, getattr(node, attr)
diff --git a/Lib/concurrent/__init__.py b/Lib/concurrent/__init__.py
new file mode 100644
index 00000000000..196d3788575
--- /dev/null
+++ b/Lib/concurrent/__init__.py
@@ -0,0 +1 @@
+# This directory is a Python package.
diff --git a/Lib/concurrent/futures/__init__.py b/Lib/concurrent/futures/__init__.py
new file mode 100644
index 00000000000..b5231f8aab3
--- /dev/null
+++ b/Lib/concurrent/futures/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Execute computations asynchronously using threads or processes."""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+from concurrent.futures._base import (FIRST_COMPLETED,
+ FIRST_EXCEPTION,
+ ALL_COMPLETED,
+ CancelledError,
+ TimeoutError,
+ Future,
+ Executor,
+ wait,
+ as_completed)
+from concurrent.futures.process import ProcessPoolExecutor
+from concurrent.futures.thread import ThreadPoolExecutor
diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py
new file mode 100644
index 00000000000..9f11f6977f1
--- /dev/null
+++ b/Lib/concurrent/futures/_base.py
@@ -0,0 +1,569 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import collections
+import functools
+import logging
+import threading
+import time
+
+FIRST_COMPLETED = 'FIRST_COMPLETED'
+FIRST_EXCEPTION = 'FIRST_EXCEPTION'
+ALL_COMPLETED = 'ALL_COMPLETED'
+_AS_COMPLETED = '_AS_COMPLETED'
+
+# Possible future states (for internal use by the futures package).
+PENDING = 'PENDING'
+RUNNING = 'RUNNING'
+# The future was cancelled by the user...
+CANCELLED = 'CANCELLED'
+# ...and _Waiter.add_cancelled() was called by a worker.
+CANCELLED_AND_NOTIFIED = 'CANCELLED_AND_NOTIFIED'
+FINISHED = 'FINISHED'
+
+_FUTURE_STATES = [
+ PENDING,
+ RUNNING,
+ CANCELLED,
+ CANCELLED_AND_NOTIFIED,
+ FINISHED
+]
+
+_STATE_TO_DESCRIPTION_MAP = {
+ PENDING: "pending",
+ RUNNING: "running",
+ CANCELLED: "cancelled",
+ CANCELLED_AND_NOTIFIED: "cancelled",
+ FINISHED: "finished"
+}
+
+# Logger for internal use by the futures package.
+LOGGER = logging.getLogger("concurrent.futures")
+
+class Error(Exception):
+ """Base class for all future-related exceptions."""
+ pass
+
+class CancelledError(Error):
+ """The Future was cancelled."""
+ pass
+
+class TimeoutError(Error):
+ """The operation exceeded the given deadline."""
+ pass
+
+class _Waiter(object):
+ """Provides the event that wait() and as_completed() block on."""
+ def __init__(self):
+ self.event = threading.Event()
+ self.finished_futures = []
+
+ def add_result(self, future):
+ self.finished_futures.append(future)
+
+ def add_exception(self, future):
+ self.finished_futures.append(future)
+
+ def add_cancelled(self, future):
+ self.finished_futures.append(future)
+
+class _AsCompletedWaiter(_Waiter):
+ """Used by as_completed()."""
+
+ def __init__(self):
+ super(_AsCompletedWaiter, self).__init__()
+ self.lock = threading.Lock()
+
+ def add_result(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_result(future)
+ self.event.set()
+
+ def add_exception(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_exception(future)
+ self.event.set()
+
+ def add_cancelled(self, future):
+ with self.lock:
+ super(_AsCompletedWaiter, self).add_cancelled(future)
+ self.event.set()
+
+class _FirstCompletedWaiter(_Waiter):
+ """Used by wait(return_when=FIRST_COMPLETED)."""
+
+ def add_result(self, future):
+ super().add_result(future)
+ self.event.set()
+
+ def add_exception(self, future):
+ super().add_exception(future)
+ self.event.set()
+
+ def add_cancelled(self, future):
+ super().add_cancelled(future)
+ self.event.set()
+
+class _AllCompletedWaiter(_Waiter):
+ """Used by wait(return_when=FIRST_EXCEPTION and ALL_COMPLETED)."""
+
+ def __init__(self, num_pending_calls, stop_on_exception):
+ self.num_pending_calls = num_pending_calls
+ self.stop_on_exception = stop_on_exception
+ self.lock = threading.Lock()
+ super().__init__()
+
+ def _decrement_pending_calls(self):
+ with self.lock:
+ self.num_pending_calls -= 1
+ if not self.num_pending_calls:
+ self.event.set()
+
+ def add_result(self, future):
+ super().add_result(future)
+ self._decrement_pending_calls()
+
+ def add_exception(self, future):
+ super().add_exception(future)
+ if self.stop_on_exception:
+ self.event.set()
+ else:
+ self._decrement_pending_calls()
+
+ def add_cancelled(self, future):
+ super().add_cancelled(future)
+ self._decrement_pending_calls()
+
+class _AcquireFutures(object):
+ """A context manager that does an ordered acquire of Future conditions."""
+
+ def __init__(self, futures):
+ self.futures = sorted(futures, key=id)
+
+ def __enter__(self):
+ for future in self.futures:
+ future._condition.acquire()
+
+ def __exit__(self, *args):
+ for future in self.futures:
+ future._condition.release()
+
+def _create_and_install_waiters(fs, return_when):
+ if return_when == _AS_COMPLETED:
+ waiter = _AsCompletedWaiter()
+ elif return_when == FIRST_COMPLETED:
+ waiter = _FirstCompletedWaiter()
+ else:
+ pending_count = sum(
+ f._state not in [CANCELLED_AND_NOTIFIED, FINISHED] for f in fs)
+
+ if return_when == FIRST_EXCEPTION:
+ waiter = _AllCompletedWaiter(pending_count, stop_on_exception=True)
+ elif return_when == ALL_COMPLETED:
+ waiter = _AllCompletedWaiter(pending_count, stop_on_exception=False)
+ else:
+ raise ValueError("Invalid return condition: %r" % return_when)
+
+ for f in fs:
+ f._waiters.append(waiter)
+
+ return waiter
+
+def as_completed(fs, timeout=None):
+ """An iterator over the given futures that yields each as it completes.
+
+ Args:
+ fs: The sequence of Futures (possibly created by different Executors) to
+ iterate over.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+
+ Returns:
+ An iterator that yields the given Futures as they complete (finished or
+ cancelled).
+
+ Raises:
+ TimeoutError: If the entire result iterator could not be generated
+ before the given timeout.
+ """
+ if timeout is not None:
+ end_time = timeout + time.time()
+
+ with _AcquireFutures(fs):
+ finished = set(
+ f for f in fs
+ if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
+ pending = set(fs) - finished
+ waiter = _create_and_install_waiters(fs, _AS_COMPLETED)
+
+ try:
+ for future in finished:
+ yield future
+
+ while pending:
+ if timeout is None:
+ wait_timeout = None
+ else:
+ wait_timeout = end_time - time.time()
+ if wait_timeout < 0:
+ raise TimeoutError(
+ '%d (of %d) futures unfinished' % (
+ len(pending), len(fs)))
+
+ waiter.event.wait(wait_timeout)
+
+ with waiter.lock:
+ finished = waiter.finished_futures
+ waiter.finished_futures = []
+ waiter.event.clear()
+
+ for future in finished:
+ yield future
+ pending.remove(future)
+
+ finally:
+ for f in fs:
+ f._waiters.remove(waiter)
+
+DoneAndNotDoneFutures = collections.namedtuple(
+ 'DoneAndNotDoneFutures', 'done not_done')
+def wait(fs, timeout=None, return_when=ALL_COMPLETED):
+ """Wait for the futures in the given sequence to complete.
+
+ Args:
+ fs: The sequence of Futures (possibly created by different Executors) to
+ wait upon.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+ return_when: Indicates when this function should return. The options
+ are:
+
+ FIRST_COMPLETED - Return when any future finishes or is
+ cancelled.
+ FIRST_EXCEPTION - Return when any future finishes by raising an
+ exception. If no future raises an exception
+ then it is equivalent to ALL_COMPLETED.
+ ALL_COMPLETED - Return when all futures finish or are cancelled.
+
+ Returns:
+ A named 2-tuple of sets. The first set, named 'done', contains the
+ futures that completed (is finished or cancelled) before the wait
+ completed. The second set, named 'not_done', contains uncompleted
+ futures.
+ """
+ with _AcquireFutures(fs):
+ done = set(f for f in fs
+ if f._state in [CANCELLED_AND_NOTIFIED, FINISHED])
+ not_done = set(fs) - done
+
+ if (return_when == FIRST_COMPLETED) and done:
+ return DoneAndNotDoneFutures(done, not_done)
+ elif (return_when == FIRST_EXCEPTION) and done:
+ if any(f for f in done
+ if not f.cancelled() and f.exception() is not None):
+ return DoneAndNotDoneFutures(done, not_done)
+
+ if len(done) == len(fs):
+ return DoneAndNotDoneFutures(done, not_done)
+
+ waiter = _create_and_install_waiters(fs, return_when)
+
+ waiter.event.wait(timeout)
+ for f in fs:
+ f._waiters.remove(waiter)
+
+ done.update(waiter.finished_futures)
+ return DoneAndNotDoneFutures(done, set(fs) - done)
+
+class Future(object):
+ """Represents the result of an asynchronous computation."""
+
+ def __init__(self):
+ """Initializes the future. Should not be called by clients."""
+ self._condition = threading.Condition()
+ self._state = PENDING
+ self._result = None
+ self._exception = None
+ self._waiters = []
+ self._done_callbacks = []
+
+ def _invoke_callbacks(self):
+ for callback in self._done_callbacks:
+ try:
+ callback(self)
+ except Exception:
+ LOGGER.exception('exception calling callback for %r', self)
+
+ def __repr__(self):
+ with self._condition:
+ if self._state == FINISHED:
+ if self._exception:
+ return '<Future at %s state=%s raised %s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state],
+ self._exception.__class__.__name__)
+ else:
+ return '<Future at %s state=%s returned %s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state],
+ self._result.__class__.__name__)
+ return '<Future at %s state=%s>' % (
+ hex(id(self)),
+ _STATE_TO_DESCRIPTION_MAP[self._state])
+
+ def cancel(self):
+ """Cancel the future if possible.
+
+ Returns True if the future was cancelled, False otherwise. A future
+ cannot be cancelled if it is running or has already completed.
+ """
+ with self._condition:
+ if self._state in [RUNNING, FINISHED]:
+ return False
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ return True
+
+ self._state = CANCELLED
+ self._condition.notify_all()
+
+ self._invoke_callbacks()
+ return True
+
+ def cancelled(self):
+ """Return True if the future has cancelled."""
+ with self._condition:
+ return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]
+
+ def running(self):
+ """Return True if the future is currently executing."""
+ with self._condition:
+ return self._state == RUNNING
+
+ def done(self):
+ """Return True of the future was cancelled or finished executing."""
+ with self._condition:
+ return self._state in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]
+
+ def __get_result(self):
+ if self._exception:
+ raise self._exception
+ else:
+ return self._result
+
+ def add_done_callback(self, fn):
+ """Attaches a callable that will be called when the future finishes.
+
+ Args:
+ fn: A callable that will be called with this future as its only
+ argument when the future completes or is cancelled. The callable
+ will always be called by a thread in the same process in which
+ it was added. If the future has already completed or been
+ cancelled then the callable will be called immediately. These
+ callables are called in the order that they were added.
+ """
+ with self._condition:
+ if self._state not in [CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED]:
+ self._done_callbacks.append(fn)
+ return
+ fn(self)
+
+ def result(self, timeout=None):
+ """Return the result of the call that the future represents.
+
+ Args:
+ timeout: The number of seconds to wait for the result if the future
+ isn't done. If None, then there is no limit on the wait time.
+
+ Returns:
+ The result of the call that the future represents.
+
+ Raises:
+ CancelledError: If the future was cancelled.
+ TimeoutError: If the future didn't finish executing before the given
+ timeout.
+ Exception: If the call raised then that exception will be raised.
+ """
+ with self._condition:
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self.__get_result()
+
+ self._condition.wait(timeout)
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self.__get_result()
+ else:
+ raise TimeoutError()
+
+ def exception(self, timeout=None):
+ """Return the exception raised by the call that the future represents.
+
+ Args:
+ timeout: The number of seconds to wait for the exception if the
+ future isn't done. If None, then there is no limit on the wait
+ time.
+
+ Returns:
+ The exception raised by the call that the future represents or None
+ if the call completed without raising.
+
+ Raises:
+ CancelledError: If the future was cancelled.
+ TimeoutError: If the future didn't finish executing before the given
+ timeout.
+ """
+
+ with self._condition:
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self._exception
+
+ self._condition.wait(timeout)
+
+ if self._state in [CANCELLED, CANCELLED_AND_NOTIFIED]:
+ raise CancelledError()
+ elif self._state == FINISHED:
+ return self._exception
+ else:
+ raise TimeoutError()
+
+ # The following methods should only be used by Executors and in tests.
+ def set_running_or_notify_cancel(self):
+ """Mark the future as running or process any cancel notifications.
+
+ Should only be used by Executor implementations and unit tests.
+
+ If the future has been cancelled (cancel() was called and returned
+ True) then any threads waiting on the future completing (though calls
+ to as_completed() or wait()) are notified and False is returned.
+
+ If the future was not cancelled then it is put in the running state
+ (future calls to running() will return True) and True is returned.
+
+ This method should be called by Executor implementations before
+ executing the work associated with this future. If this method returns
+ False then the work should not be executed.
+
+ Returns:
+ False if the Future was cancelled, True otherwise.
+
+ Raises:
+ RuntimeError: if this method was already called or if set_result()
+ or set_exception() was called.
+ """
+ with self._condition:
+ if self._state == CANCELLED:
+ self._state = CANCELLED_AND_NOTIFIED
+ for waiter in self._waiters:
+ waiter.add_cancelled(self)
+ # self._condition.notify_all() is not necessary because
+ # self.cancel() triggers a notification.
+ return False
+ elif self._state == PENDING:
+ self._state = RUNNING
+ return True
+ else:
+ LOGGER.critical('Future %s in unexpected state: %s',
+ id(self.future),
+ self.future._state)
+ raise RuntimeError('Future in unexpected state')
+
+ def set_result(self, result):
+ """Sets the return value of work associated with the future.
+
+ Should only be used by Executor implementations and unit tests.
+ """
+ with self._condition:
+ self._result = result
+ self._state = FINISHED
+ for waiter in self._waiters:
+ waiter.add_result(self)
+ self._condition.notify_all()
+ self._invoke_callbacks()
+
+ def set_exception(self, exception):
+ """Sets the result of the future as being the given exception.
+
+ Should only be used by Executor implementations and unit tests.
+ """
+ with self._condition:
+ self._exception = exception
+ self._state = FINISHED
+ for waiter in self._waiters:
+ waiter.add_exception(self)
+ self._condition.notify_all()
+ self._invoke_callbacks()
+
+class Executor(object):
+ """This is an abstract base class for concrete asynchronous executors."""
+
+ def submit(self, fn, *args, **kwargs):
+ """Submits a callable to be executed with the given arguments.
+
+ Schedules the callable to be executed as fn(*args, **kwargs) and returns
+ a Future instance representing the execution of the callable.
+
+ Returns:
+ A Future representing the given call.
+ """
+ raise NotImplementedError()
+
+ def map(self, fn, *iterables, timeout=None):
+ """Returns a iterator equivalent to map(fn, iter).
+
+ Args:
+ fn: A callable that will take take as many arguments as there are
+ passed iterables.
+ timeout: The maximum number of seconds to wait. If None, then there
+ is no limit on the wait time.
+
+ Returns:
+ An iterator equivalent to: map(func, *iterables) but the calls may
+ be evaluated out-of-order.
+
+ Raises:
+ TimeoutError: If the entire result iterator could not be generated
+ before the given timeout.
+ Exception: If fn(*args) raises for any values.
+ """
+ if timeout is not None:
+ end_time = timeout + time.time()
+
+ fs = [self.submit(fn, *args) for args in zip(*iterables)]
+
+ try:
+ for future in fs:
+ if timeout is None:
+ yield future.result()
+ else:
+ yield future.result(end_time - time.time())
+ finally:
+ for future in fs:
+ future.cancel()
+
+ def shutdown(self, wait=True):
+ """Clean-up the resources associated with the Executor.
+
+ It is safe to call this method several times. Otherwise, no other
+ methods can be called after this one.
+
+ Args:
+ wait: If True then shutdown will not return until all running
+ futures have finished executing and the resources used by the
+ executor have been reclaimed.
+ """
+ pass
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_val, exc_tb):
+ self.shutdown(wait=True)
+ return False
diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py
new file mode 100644
index 00000000000..d3bbe2c5e68
--- /dev/null
+++ b/Lib/concurrent/futures/process.py
@@ -0,0 +1,356 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Implements ProcessPoolExecutor.
+
+The follow diagram and text describe the data-flow through the system:
+
+|======================= In-process =====================|== Out-of-process ==|
+
++----------+ +----------+ +--------+ +-----------+ +---------+
+| | => | Work Ids | => | | => | Call Q | => | |
+| | +----------+ | | +-----------+ | |
+| | | ... | | | | ... | | |
+| | | 6 | | | | 5, call() | | |
+| | | 7 | | | | ... | | |
+| Process | | ... | | Local | +-----------+ | Process |
+| Pool | +----------+ | Worker | | #1..n |
+| Executor | | Thread | | |
+| | +----------- + | | +-----------+ | |
+| | <=> | Work Items | <=> | | <= | Result Q | <= | |
+| | +------------+ | | +-----------+ | |
+| | | 6: call() | | | | ... | | |
+| | | future | | | | 4, result | | |
+| | | ... | | | | 3, except | | |
++----------+ +------------+ +--------+ +-----------+ +---------+
+
+Executor.submit() called:
+- creates a uniquely numbered _WorkItem and adds it to the "Work Items" dict
+- adds the id of the _WorkItem to the "Work Ids" queue
+
+Local worker thread:
+- reads work ids from the "Work Ids" queue and looks up the corresponding
+ WorkItem from the "Work Items" dict: if the work item has been cancelled then
+ it is simply removed from the dict, otherwise it is repackaged as a
+ _CallItem and put in the "Call Q". New _CallItems are put in the "Call Q"
+ until "Call Q" is full. NOTE: the size of the "Call Q" is kept small because
+ calls placed in the "Call Q" can no longer be cancelled with Future.cancel().
+- reads _ResultItems from "Result Q", updates the future stored in the
+ "Work Items" dict and deletes the dict entry
+
+Process #1..n:
+- reads _CallItems from "Call Q", executes the calls, and puts the resulting
+ _ResultItems in "Request Q"
+"""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import atexit
+from concurrent.futures import _base
+import queue
+import multiprocessing
+import threading
+import weakref
+
+# Workers are created as daemon threads and processes. This is done to allow the
+# interpreter to exit when there are still idle processes in a
+# ProcessPoolExecutor's process pool (i.e. shutdown() was not called). However,
+# allowing workers to die with the interpreter has two undesirable properties:
+# - The workers would still be running during interpretor shutdown,
+# meaning that they would fail in unpredictable ways.
+# - The workers could be killed while evaluating a work item, which could
+# be bad if the callable being evaluated has external side-effects e.g.
+# writing to a file.
+#
+# To work around this problem, an exit handler is installed which tells the
+# workers to exit when their work queues are empty and then waits until the
+# threads/processes finish.
+
+_threads_queues = weakref.WeakKeyDictionary()
+_shutdown = False
+
+def _python_exit():
+ global _shutdown
+ _shutdown = True
+ items = list(_threads_queues.items())
+ for t, q in items:
+ q.put(None)
+ for t, q in items:
+ t.join()
+
+# Controls how many more calls than processes will be queued in the call queue.
+# A smaller number will mean that processes spend more time idle waiting for
+# work while a larger number will make Future.cancel() succeed less frequently
+# (Futures in the call queue cannot be cancelled).
+EXTRA_QUEUED_CALLS = 1
+
+class _WorkItem(object):
+ def __init__(self, future, fn, args, kwargs):
+ self.future = future
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+class _ResultItem(object):
+ def __init__(self, work_id, exception=None, result=None):
+ self.work_id = work_id
+ self.exception = exception
+ self.result = result
+
+class _CallItem(object):
+ def __init__(self, work_id, fn, args, kwargs):
+ self.work_id = work_id
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+def _process_worker(call_queue, result_queue):
+ """Evaluates calls from call_queue and places the results in result_queue.
+
+ This worker is run in a separate process.
+
+ Args:
+ call_queue: A multiprocessing.Queue of _CallItems that will be read and
+ evaluated by the worker.
+ result_queue: A multiprocessing.Queue of _ResultItems that will written
+ to by the worker.
+ shutdown: A multiprocessing.Event that will be set as a signal to the
+ worker that it should exit when call_queue is empty.
+ """
+ while True:
+ call_item = call_queue.get(block=True)
+ if call_item is None:
+ # Wake up queue management thread
+ result_queue.put(None)
+ return
+ try:
+ r = call_item.fn(*call_item.args, **call_item.kwargs)
+ except BaseException as e:
+ result_queue.put(_ResultItem(call_item.work_id,
+ exception=e))
+ else:
+ result_queue.put(_ResultItem(call_item.work_id,
+ result=r))
+
+def _add_call_item_to_queue(pending_work_items,
+ work_ids,
+ call_queue):
+ """Fills call_queue with _WorkItems from pending_work_items.
+
+ This function never blocks.
+
+ Args:
+ pending_work_items: A dict mapping work ids to _WorkItems e.g.
+ {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
+ work_ids: A queue.Queue of work ids e.g. Queue([5, 6, ...]). Work ids
+ are consumed and the corresponding _WorkItems from
+ pending_work_items are transformed into _CallItems and put in
+ call_queue.
+ call_queue: A multiprocessing.Queue that will be filled with _CallItems
+ derived from _WorkItems.
+ """
+ while True:
+ if call_queue.full():
+ return
+ try:
+ work_id = work_ids.get(block=False)
+ except queue.Empty:
+ return
+ else:
+ work_item = pending_work_items[work_id]
+
+ if work_item.future.set_running_or_notify_cancel():
+ call_queue.put(_CallItem(work_id,
+ work_item.fn,
+ work_item.args,
+ work_item.kwargs),
+ block=True)
+ else:
+ del pending_work_items[work_id]
+ continue
+
+def _queue_management_worker(executor_reference,
+ processes,
+ pending_work_items,
+ work_ids_queue,
+ call_queue,
+ result_queue):
+ """Manages the communication between this process and the worker processes.
+
+ This function is run in a local thread.
+
+ Args:
+ executor_reference: A weakref.ref to the ProcessPoolExecutor that owns
+ this thread. Used to determine if the ProcessPoolExecutor has been
+ garbage collected and that this function can exit.
+ process: A list of the multiprocessing.Process instances used as
+ workers.
+ pending_work_items: A dict mapping work ids to _WorkItems e.g.
+ {5: <_WorkItem...>, 6: <_WorkItem...>, ...}
+ work_ids_queue: A queue.Queue of work ids e.g. Queue([5, 6, ...]).
+ call_queue: A multiprocessing.Queue that will be filled with _CallItems
+ derived from _WorkItems for processing by the process workers.
+ result_queue: A multiprocessing.Queue of _ResultItems generated by the
+ process workers.
+ """
+ nb_shutdown_processes = 0
+ def shutdown_one_process():
+ """Tell a worker to terminate, which will in turn wake us again"""
+ nonlocal nb_shutdown_processes
+ call_queue.put(None)
+ nb_shutdown_processes += 1
+ while True:
+ _add_call_item_to_queue(pending_work_items,
+ work_ids_queue,
+ call_queue)
+
+ result_item = result_queue.get(block=True)
+ if result_item is not None:
+ work_item = pending_work_items[result_item.work_id]
+ del pending_work_items[result_item.work_id]
+
+ if result_item.exception:
+ work_item.future.set_exception(result_item.exception)
+ else:
+ work_item.future.set_result(result_item.result)
+ # Check whether we should start shutting down.
+ executor = executor_reference()
+ # No more work items can be added if:
+ # - The interpreter is shutting down OR
+ # - The executor that owns this worker has been collected OR
+ # - The executor that owns this worker has been shutdown.
+ if _shutdown or executor is None or executor._shutdown_thread:
+ # Since no new work items can be added, it is safe to shutdown
+ # this thread if there are no pending work items.
+ if not pending_work_items:
+ while nb_shutdown_processes < len(processes):
+ shutdown_one_process()
+ # If .join() is not called on the created processes then
+ # some multiprocessing.Queue methods may deadlock on Mac OS
+ # X.
+ for p in processes:
+ p.join()
+ call_queue.close()
+ return
+ del executor
+
+_system_limits_checked = False
+_system_limited = None
+def _check_system_limits():
+ global _system_limits_checked, _system_limited
+ if _system_limits_checked:
+ if _system_limited:
+ raise NotImplementedError(_system_limited)
+ _system_limits_checked = True
+ try:
+ import os
+ nsems_max = os.sysconf("SC_SEM_NSEMS_MAX")
+ except (AttributeError, ValueError):
+ # sysconf not available or setting not available
+ return
+ if nsems_max == -1:
+ # indetermine limit, assume that limit is determined
+ # by available memory only
+ return
+ if nsems_max >= 256:
+ # minimum number of semaphores available
+ # according to POSIX
+ return
+ _system_limited = "system provides too few semaphores (%d available, 256 necessary)" % nsems_max
+ raise NotImplementedError(_system_limited)
+
+class ProcessPoolExecutor(_base.Executor):
+ def __init__(self, max_workers=None):
+ """Initializes a new ProcessPoolExecutor instance.
+
+ Args:
+ max_workers: The maximum number of processes that can be used to
+ execute the given calls. If None or not given then as many
+ worker processes will be created as the machine has processors.
+ """
+ _check_system_limits()
+
+ if max_workers is None:
+ self._max_workers = multiprocessing.cpu_count()
+ else:
+ self._max_workers = max_workers
+
+ # Make the call queue slightly larger than the number of processes to
+ # prevent the worker processes from idling. But don't make it too big
+ # because futures in the call queue cannot be cancelled.
+ self._call_queue = multiprocessing.Queue(self._max_workers +
+ EXTRA_QUEUED_CALLS)
+ self._result_queue = multiprocessing.Queue()
+ self._work_ids = queue.Queue()
+ self._queue_management_thread = None
+ self._processes = set()
+
+ # Shutdown is a two-step process.
+ self._shutdown_thread = False
+ self._shutdown_lock = threading.Lock()
+ self._queue_count = 0
+ self._pending_work_items = {}
+
+ def _start_queue_management_thread(self):
+ # When the executor gets lost, the weakref callback will wake up
+ # the queue management thread.
+ def weakref_cb(_, q=self._result_queue):
+ q.put(None)
+ if self._queue_management_thread is None:
+ self._queue_management_thread = threading.Thread(
+ target=_queue_management_worker,
+ args=(weakref.ref(self, weakref_cb),
+ self._processes,
+ self._pending_work_items,
+ self._work_ids,
+ self._call_queue,
+ self._result_queue))
+ self._queue_management_thread.daemon = True
+ self._queue_management_thread.start()
+ _threads_queues[self._queue_management_thread] = self._result_queue
+
+ def _adjust_process_count(self):
+ for _ in range(len(self._processes), self._max_workers):
+ p = multiprocessing.Process(
+ target=_process_worker,
+ args=(self._call_queue,
+ self._result_queue))
+ p.start()
+ self._processes.add(p)
+
+ def submit(self, fn, *args, **kwargs):
+ with self._shutdown_lock:
+ if self._shutdown_thread:
+ raise RuntimeError('cannot schedule new futures after shutdown')
+
+ f = _base.Future()
+ w = _WorkItem(f, fn, args, kwargs)
+
+ self._pending_work_items[self._queue_count] = w
+ self._work_ids.put(self._queue_count)
+ self._queue_count += 1
+ # Wake up queue management thread
+ self._result_queue.put(None)
+
+ self._start_queue_management_thread()
+ self._adjust_process_count()
+ return f
+ submit.__doc__ = _base.Executor.submit.__doc__
+
+ def shutdown(self, wait=True):
+ with self._shutdown_lock:
+ self._shutdown_thread = True
+ if self._queue_management_thread:
+ # Wake up queue management thread
+ self._result_queue.put(None)
+ if wait:
+ self._queue_management_thread.join()
+ # To reduce the risk of openning too many files, remove references to
+ # objects that use file descriptors.
+ self._queue_management_thread = None
+ self._call_queue = None
+ self._result_queue = None
+ self._processes = None
+ shutdown.__doc__ = _base.Executor.shutdown.__doc__
+
+atexit.register(_python_exit)
diff --git a/Lib/concurrent/futures/thread.py b/Lib/concurrent/futures/thread.py
new file mode 100644
index 00000000000..fbac0887a59
--- /dev/null
+++ b/Lib/concurrent/futures/thread.py
@@ -0,0 +1,130 @@
+# Copyright 2009 Brian Quinlan. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Implements ThreadPoolExecutor."""
+
+__author__ = 'Brian Quinlan (brian@sweetapp.com)'
+
+import atexit
+from concurrent.futures import _base
+import queue
+import threading
+import weakref
+
+# Workers are created as daemon threads. This is done to allow the interpreter
+# to exit when there are still idle threads in a ThreadPoolExecutor's thread
+# pool (i.e. shutdown() was not called). However, allowing workers to die with
+# the interpreter has two undesirable properties:
+# - The workers would still be running during interpretor shutdown,
+# meaning that they would fail in unpredictable ways.
+# - The workers could be killed while evaluating a work item, which could
+# be bad if the callable being evaluated has external side-effects e.g.
+# writing to a file.
+#
+# To work around this problem, an exit handler is installed which tells the
+# workers to exit when their work queues are empty and then waits until the
+# threads finish.
+
+_threads_queues = weakref.WeakKeyDictionary()
+_shutdown = False
+
+def _python_exit():
+ global _shutdown
+ _shutdown = True
+ items = list(_threads_queues.items())
+ for t, q in items:
+ q.put(None)
+ for t, q in items:
+ t.join()
+
+atexit.register(_python_exit)
+
+class _WorkItem(object):
+ def __init__(self, future, fn, args, kwargs):
+ self.future = future
+ self.fn = fn
+ self.args = args
+ self.kwargs = kwargs
+
+ def run(self):
+ if not self.future.set_running_or_notify_cancel():
+ return
+
+ try:
+ result = self.fn(*self.args, **self.kwargs)
+ except BaseException as e:
+ self.future.set_exception(e)
+ else:
+ self.future.set_result(result)
+
+def _worker(executor_reference, work_queue):
+ try:
+ while True:
+ work_item = work_queue.get(block=True)
+ if work_item is not None:
+ work_item.run()
+ continue
+ executor = executor_reference()
+ # Exit if:
+ # - The interpreter is shutting down OR
+ # - The executor that owns the worker has been collected OR
+ # - The executor that owns the worker has been shutdown.
+ if _shutdown or executor is None or executor._shutdown:
+ # Notice other workers
+ work_queue.put(None)
+ return
+ del executor
+ except BaseException as e:
+ _base.LOGGER.critical('Exception in worker', exc_info=True)
+
+class ThreadPoolExecutor(_base.Executor):
+ def __init__(self, max_workers):
+ """Initializes a new ThreadPoolExecutor instance.
+
+ Args:
+ max_workers: The maximum number of threads that can be used to
+ execute the given calls.
+ """
+ self._max_workers = max_workers
+ self._work_queue = queue.Queue()
+ self._threads = set()
+ self._shutdown = False
+ self._shutdown_lock = threading.Lock()
+
+ def submit(self, fn, *args, **kwargs):
+ with self._shutdown_lock:
+ if self._shutdown:
+ raise RuntimeError('cannot schedule new futures after shutdown')
+
+ f = _base.Future()
+ w = _WorkItem(f, fn, args, kwargs)
+
+ self._work_queue.put(w)
+ self._adjust_thread_count()
+ return f
+ submit.__doc__ = _base.Executor.submit.__doc__
+
+ def _adjust_thread_count(self):
+ # When the executor gets lost, the weakref callback will wake up
+ # the worker threads.
+ def weakref_cb(_, q=self._work_queue):
+ q.put(None)
+ # TODO(bquinlan): Should avoid creating new threads if there are more
+ # idle threads than items in the work queue.
+ if len(self._threads) < self._max_workers:
+ t = threading.Thread(target=_worker,
+ args=(weakref.ref(self, weakref_cb),
+ self._work_queue))
+ t.daemon = True
+ t.start()
+ self._threads.add(t)
+ _threads_queues[t] = self._work_queue
+
+ def shutdown(self, wait=True):
+ with self._shutdown_lock:
+ self._shutdown = True
+ self._work_queue.put(None)
+ if wait:
+ for t in self._threads:
+ t.join()
+ shutdown.__doc__ = _base.Executor.shutdown.__doc__
diff --git a/Lib/configparser.py b/Lib/configparser.py
new file mode 100644
index 00000000000..d148b886a21
--- /dev/null
+++ b/Lib/configparser.py
@@ -0,0 +1,1247 @@
+"""Configuration file parser.
+
+A configuration file consists of sections, lead by a "[section]" header,
+and followed by "name: value" entries, with continuations and such in
+the style of RFC 822.
+
+Intrinsic defaults can be specified by passing them into the
+ConfigParser constructor as a dictionary.
+
+class:
+
+ConfigParser -- responsible for parsing a list of
+ configuration files, and managing the parsed database.
+
+ methods:
+
+ __init__(defaults=None, dict_type=_default_dict, allow_no_value=False,
+ delimiters=('=', ':'), comment_prefixes=('#', ';'),
+ inline_comment_prefixes=None, strict=True,
+ empty_lines_in_values=True):
+ Create the parser. When `defaults' is given, it is initialized into the
+ dictionary or intrinsic defaults. The keys must be strings, the values
+ must be appropriate for %()s string interpolation.
+
+ When `dict_type' is given, it will be used to create the dictionary
+ objects for the list of sections, for the options within a section, and
+ for the default values.
+
+ When `delimiters' is given, it will be used as the set of substrings
+ that divide keys from values.
+
+ When `comment_prefixes' is given, it will be used as the set of
+ substrings that prefix comments in empty lines. Comments can be
+ indented.
+
+ When `inline_comment_prefixes' is given, it will be used as the set of
+ substrings that prefix comments in non-empty lines.
+
+ When `strict` is True, the parser won't allow for any section or option
+ duplicates while reading from a single source (file, string or
+ dictionary). Default is True.
+
+ When `empty_lines_in_values' is False (default: True), each empty line
+ marks the end of an option. Otherwise, internal empty lines of
+ a multiline option are kept as part of the value.
+
+ When `allow_no_value' is True (default: False), options without
+ values are accepted; the value presented for these is None.
+
+ sections()
+ Return all the configuration section names, sans DEFAULT.
+
+ has_section(section)
+ Return whether the given section exists.
+
+ has_option(section, option)
+ Return whether the given option exists in the given section.
+
+ options(section)
+ Return list of configuration options for the named section.
+
+ read(filenames, encoding=None)
+ Read and parse the list of named configuration files, given by
+ name. A single filename is also allowed. Non-existing files
+ are ignored. Return list of successfully read files.
+
+ read_file(f, filename=None)
+ Read and parse one configuration file, given as a file object.
+ The filename defaults to f.name; it is only used in error
+ messages (if f has no `name' attribute, the string `<???>' is used).
+
+ read_string(string)
+ Read configuration from a given string.
+
+ read_dict(dictionary)
+ Read configuration from a dictionary. Keys are section names,
+ values are dictionaries with keys and values that should be present
+ in the section. If the used dictionary type preserves order, sections
+ and their keys will be added in order. Values are automatically
+ converted to strings.
+
+ get(section, option, raw=False, vars=None, fallback=_UNSET)
+ Return a string value for the named option. All % interpolations are
+ expanded in the return values, based on the defaults passed into the
+ constructor and the DEFAULT section. Additional substitutions may be
+ provided using the `vars' argument, which must be a dictionary whose
+ contents override any pre-existing defaults. If `option' is a key in
+ `vars', the value from `vars' is used.
+
+ getint(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to an integer.
+
+ getfloat(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to a float.
+
+ getboolean(section, options, raw=False, vars=None, fallback=_UNSET)
+ Like get(), but convert value to a boolean (currently case
+ insensitively defined as 0, false, no, off for False, and 1, true,
+ yes, on for True). Returns False or True.
+
+ items(section=_UNSET, raw=False, vars=None)
+ If section is given, return a list of tuples with (section_name,
+ section_proxy) for each section, including DEFAULTSECT. Otherwise,
+ return a list of tuples with (name, value) for each option
+ in the section.
+
+ remove_section(section)
+ Remove the given file section and all its options.
+
+ remove_option(section, option)
+ Remove the given option from the given section.
+
+ set(section, option, value)
+ Set the given option.
+
+ write(fp, space_around_delimiters=True)
+ Write the configuration state in .ini format. If
+ `space_around_delimiters' is True (the default), delimiters
+ between keys and values are surrounded by spaces.
+"""
+
+from collections import MutableMapping, OrderedDict as _default_dict, _ChainMap
+import functools
+import io
+import itertools
+import re
+import sys
+import warnings
+
+__all__ = ["NoSectionError", "DuplicateOptionError", "DuplicateSectionError",
+ "NoOptionError", "InterpolationError", "InterpolationDepthError",
+ "InterpolationSyntaxError", "ParsingError",
+ "MissingSectionHeaderError",
+ "ConfigParser", "SafeConfigParser", "RawConfigParser",
+ "DEFAULTSECT", "MAX_INTERPOLATION_DEPTH"]
+
+DEFAULTSECT = "DEFAULT"
+
+MAX_INTERPOLATION_DEPTH = 10
+
+
+
+# exception classes
+class Error(Exception):
+ """Base class for ConfigParser exceptions."""
+
+ def _get_message(self):
+ """Getter for 'message'; needed only to override deprecation in
+ BaseException.
+ """
+ return self.__message
+
+ def _set_message(self, value):
+ """Setter for 'message'; needed only to override deprecation in
+ BaseException.
+ """
+ self.__message = value
+
+ # BaseException.message has been deprecated since Python 2.6. To prevent
+ # DeprecationWarning from popping up over this pre-existing attribute, use
+ # a new property that takes lookup precedence.
+ message = property(_get_message, _set_message)
+
+ def __init__(self, msg=''):
+ self.message = msg
+ Exception.__init__(self, msg)
+
+ def __repr__(self):
+ return self.message
+
+ __str__ = __repr__
+
+
+class NoSectionError(Error):
+ """Raised when no section matches a requested option."""
+
+ def __init__(self, section):
+ Error.__init__(self, 'No section: %r' % (section,))
+ self.section = section
+ self.args = (section, )
+
+
+class DuplicateSectionError(Error):
+ """Raised when a section is repeated in an input source.
+
+ Possible repetitions that raise this exception are: multiple creation
+ using the API or in strict parsers when a section is found more than once
+ in a single input file, string or dictionary.
+ """
+
+ def __init__(self, section, source=None, lineno=None):
+ msg = [repr(section), " already exists"]
+ if source is not None:
+ message = ["While reading from ", source]
+ if lineno is not None:
+ message.append(" [line {0:2d}]".format(lineno))
+ message.append(": section ")
+ message.extend(msg)
+ msg = message
+ else:
+ msg.insert(0, "Section ")
+ Error.__init__(self, "".join(msg))
+ self.section = section
+ self.source = source
+ self.lineno = lineno
+ self.args = (section, source, lineno)
+
+
+class DuplicateOptionError(Error):
+ """Raised by strict parsers when an option is repeated in an input source.
+
+ Current implementation raises this exception only when an option is found
+ more than once in a single file, string or dictionary.
+ """
+
+ def __init__(self, section, option, source=None, lineno=None):
+ msg = [repr(option), " in section ", repr(section),
+ " already exists"]
+ if source is not None:
+ message = ["While reading from ", source]
+ if lineno is not None:
+ message.append(" [line {0:2d}]".format(lineno))
+ message.append(": option ")
+ message.extend(msg)
+ msg = message
+ else:
+ msg.insert(0, "Option ")
+ Error.__init__(self, "".join(msg))
+ self.section = section
+ self.option = option
+ self.source = source
+ self.lineno = lineno
+ self.args = (section, option, source, lineno)
+
+
+class NoOptionError(Error):
+ """A requested option was not found."""
+
+ def __init__(self, option, section):
+ Error.__init__(self, "No option %r in section: %r" %
+ (option, section))
+ self.option = option
+ self.section = section
+ self.args = (option, section)
+
+
+class InterpolationError(Error):
+ """Base class for interpolation-related exceptions."""
+
+ def __init__(self, option, section, msg):
+ Error.__init__(self, msg)
+ self.option = option
+ self.section = section
+ self.args = (option, section, msg)
+
+
+class InterpolationMissingOptionError(InterpolationError):
+ """A string substitution required a setting which was not available."""
+
+ def __init__(self, option, section, rawval, reference):
+ msg = ("Bad value substitution:\n"
+ "\tsection: [%s]\n"
+ "\toption : %s\n"
+ "\tkey : %s\n"
+ "\trawval : %s\n"
+ % (section, option, reference, rawval))
+ InterpolationError.__init__(self, option, section, msg)
+ self.reference = reference
+ self.args = (option, section, rawval, reference)
+
+
+class InterpolationSyntaxError(InterpolationError):
+ """Raised when the source text contains invalid syntax.
+
+ Current implementation raises this exception when the source text into
+ which substitutions are made does not conform to the required syntax.
+ """
+
+
+class InterpolationDepthError(InterpolationError):
+ """Raised when substitutions are nested too deeply."""
+
+ def __init__(self, option, section, rawval):
+ msg = ("Value interpolation too deeply recursive:\n"
+ "\tsection: [%s]\n"
+ "\toption : %s\n"
+ "\trawval : %s\n"
+ % (section, option, rawval))
+ InterpolationError.__init__(self, option, section, msg)
+ self.args = (option, section, rawval)
+
+
+class ParsingError(Error):
+ """Raised when a configuration file does not follow legal syntax."""
+
+ def __init__(self, source=None, filename=None):
+ # Exactly one of `source'/`filename' arguments has to be given.
+ # `filename' kept for compatibility.
+ if filename and source:
+ raise ValueError("Cannot specify both `filename' and `source'. "
+ "Use `source'.")
+ elif not filename and not source:
+ raise ValueError("Required argument `source' not given.")
+ elif filename:
+ source = filename
+ Error.__init__(self, 'Source contains parsing errors: %s' % source)
+ self.source = source
+ self.errors = []
+ self.args = (source, )
+
+ @property
+ def filename(self):
+ """Deprecated, use `source'."""
+ warnings.warn(
+ "The 'filename' attribute will be removed in future versions. "
+ "Use 'source' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ return self.source
+
+ @filename.setter
+ def filename(self, value):
+ """Deprecated, user `source'."""
+ warnings.warn(
+ "The 'filename' attribute will be removed in future versions. "
+ "Use 'source' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ self.source = value
+
+ def append(self, lineno, line):
+ self.errors.append((lineno, line))
+ self.message += '\n\t[line %2d]: %s' % (lineno, line)
+
+
+class MissingSectionHeaderError(ParsingError):
+ """Raised when a key-value pair is found before any section header."""
+
+ def __init__(self, filename, lineno, line):
+ Error.__init__(
+ self,
+ 'File contains no section headers.\nfile: %s, line: %d\n%r' %
+ (filename, lineno, line))
+ self.source = filename
+ self.lineno = lineno
+ self.line = line
+ self.args = (filename, lineno, line)
+
+
+# Used in parser getters to indicate the default behaviour when a specific
+# option is not found it to raise an exception. Created to enable `None' as
+# a valid fallback value.
+_UNSET = object()
+
+
+class Interpolation:
+ """Dummy interpolation that passes the value through with no changes."""
+
+ def before_get(self, parser, section, option, value, defaults):
+ return value
+
+ def before_set(self, parser, section, option, value):
+ return value
+
+ def before_read(self, parser, section, option, value):
+ return value
+
+ def before_write(self, parser, section, option, value):
+ return value
+
+
+class BasicInterpolation(Interpolation):
+ """Interpolation as implemented in the classic ConfigParser.
+
+ The option values can contain format strings which refer to other values in
+ the same section, or values in the special default section.
+
+ For example:
+
+ something: %(dir)s/whatever
+
+ would resolve the "%(dir)s" to the value of dir. All reference
+ expansions are done late, on demand. If a user needs to use a bare % in
+ a configuration file, she can escape it by writing %%. Other % usage
+ is considered a user error and raises `InterpolationSyntaxError'."""
+
+ _KEYCRE = re.compile(r"%\(([^)]+)\)s")
+
+ def before_get(self, parser, section, option, value, defaults):
+ L = []
+ self._interpolate_some(parser, option, L, value, section, defaults, 1)
+ return ''.join(L)
+
+ def before_set(self, parser, section, option, value):
+ tmp_value = value.replace('%%', '') # escaped percent signs
+ tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+ if '%' in tmp_value:
+ raise ValueError("invalid interpolation syntax in %r at "
+ "position %d" % (value, tmp_value.find('%')))
+ return value
+
+ def _interpolate_some(self, parser, option, accum, rest, section, map,
+ depth):
+ if depth > MAX_INTERPOLATION_DEPTH:
+ raise InterpolationDepthError(option, section, rest)
+ while rest:
+ p = rest.find("%")
+ if p < 0:
+ accum.append(rest)
+ return
+ if p > 0:
+ accum.append(rest[:p])
+ rest = rest[p:]
+ # p is no longer used
+ c = rest[1:2]
+ if c == "%":
+ accum.append("%")
+ rest = rest[2:]
+ elif c == "(":
+ m = self._KEYCRE.match(rest)
+ if m is None:
+ raise InterpolationSyntaxError(option, section,
+ "bad interpolation variable reference %r" % rest)
+ var = parser.optionxform(m.group(1))
+ rest = rest[m.end():]
+ try:
+ v = map[var]
+ except KeyError:
+ raise InterpolationMissingOptionError(
+ option, section, rest, var)
+ if "%" in v:
+ self._interpolate_some(parser, option, accum, v,
+ section, map, depth + 1)
+ else:
+ accum.append(v)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "'%%' must be followed by '%%' or '(', "
+ "found: %r" % (rest,))
+
+
+class ExtendedInterpolation(Interpolation):
+ """Advanced variant of interpolation, supports the syntax used by
+ `zc.buildout'. Enables interpolation between sections."""
+
+ _KEYCRE = re.compile(r"\$\{([^}]+)\}")
+
+ def before_get(self, parser, section, option, value, defaults):
+ L = []
+ self._interpolate_some(parser, option, L, value, section, defaults, 1)
+ return ''.join(L)
+
+ def before_set(self, parser, section, option, value):
+ tmp_value = value.replace('$$', '') # escaped dollar signs
+ tmp_value = self._KEYCRE.sub('', tmp_value) # valid syntax
+ if '$' in tmp_value:
+ raise ValueError("invalid interpolation syntax in %r at "
+ "position %d" % (value, tmp_value.find('%')))
+ return value
+
+ def _interpolate_some(self, parser, option, accum, rest, section, map,
+ depth):
+ if depth > MAX_INTERPOLATION_DEPTH:
+ raise InterpolationDepthError(option, section, rest)
+ while rest:
+ p = rest.find("$")
+ if p < 0:
+ accum.append(rest)
+ return
+ if p > 0:
+ accum.append(rest[:p])
+ rest = rest[p:]
+ # p is no longer used
+ c = rest[1:2]
+ if c == "$":
+ accum.append("$")
+ rest = rest[2:]
+ elif c == "{":
+ m = self._KEYCRE.match(rest)
+ if m is None:
+ raise InterpolationSyntaxError(option, section,
+ "bad interpolation variable reference %r" % rest)
+ path = m.group(1).split(':')
+ rest = rest[m.end():]
+ sect = section
+ opt = option
+ try:
+ if len(path) == 1:
+ opt = parser.optionxform(path[0])
+ v = map[opt]
+ elif len(path) == 2:
+ sect = path[0]
+ opt = parser.optionxform(path[1])
+ v = parser.get(sect, opt, raw=True)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "More than one ':' found: %r" % (rest,))
+ except (KeyError, NoSectionError, NoOptionError):
+ raise InterpolationMissingOptionError(
+ option, section, rest, ":".join(path))
+ if "$" in v:
+ self._interpolate_some(parser, opt, accum, v, sect,
+ dict(parser.items(sect, raw=True)),
+ depth + 1)
+ else:
+ accum.append(v)
+ else:
+ raise InterpolationSyntaxError(
+ option, section,
+ "'$' must be followed by '$' or '{', "
+ "found: %r" % (rest,))
+
+
+class LegacyInterpolation(Interpolation):
+ """Deprecated interpolation used in old versions of ConfigParser.
+ Use BasicInterpolation or ExtendedInterpolation instead."""
+
+ _KEYCRE = re.compile(r"%\(([^)]*)\)s|.")
+
+ def before_get(self, parser, section, option, value, vars):
+ rawval = value
+ depth = MAX_INTERPOLATION_DEPTH
+ while depth: # Loop through this until it's done
+ depth -= 1
+ if value and "%(" in value:
+ replace = functools.partial(self._interpolation_replace,
+ parser=parser)
+ value = self._KEYCRE.sub(replace, value)
+ try:
+ value = value % vars
+ except KeyError as e:
+ raise InterpolationMissingOptionError(
+ option, section, rawval, e.args[0])
+ else:
+ break
+ if value and "%(" in value:
+ raise InterpolationDepthError(option, section, rawval)
+ return value
+
+ def before_set(self, parser, section, option, value):
+ return value
+
+ @staticmethod
+ def _interpolation_replace(match, parser):
+ s = match.group(1)
+ if s is None:
+ return match.group()
+ else:
+ return "%%(%s)s" % parser.optionxform(s)
+
+
+class RawConfigParser(MutableMapping):
+ """ConfigParser that does not do interpolation."""
+
+ # Regular expressions for parsing section headers and options
+ _SECT_TMPL = r"""
+ \[ # [
+ (?P<header>[^]]+) # very permissive!
+ \] # ]
+ """
+ _OPT_TMPL = r"""
+ (?P<option>.*?) # very permissive!
+ \s*(?P<vi>{delim})\s* # any number of space/tab,
+ # followed by any of the
+ # allowed delimiters,
+ # followed by any space/tab
+ (?P<value>.*)$ # everything up to eol
+ """
+ _OPT_NV_TMPL = r"""
+ (?P<option>.*?) # very permissive!
+ \s*(?: # any number of space/tab,
+ (?P<vi>{delim})\s* # optionally followed by
+ # any of the allowed
+ # delimiters, followed by any
+ # space/tab
+ (?P<value>.*))?$ # everything up to eol
+ """
+ # Interpolation algorithm to be used if the user does not specify another
+ _DEFAULT_INTERPOLATION = Interpolation()
+ # Compiled regular expression for matching sections
+ SECTCRE = re.compile(_SECT_TMPL, re.VERBOSE)
+ # Compiled regular expression for matching options with typical separators
+ OPTCRE = re.compile(_OPT_TMPL.format(delim="=|:"), re.VERBOSE)
+ # Compiled regular expression for matching options with optional values
+ # delimited using typical separators
+ OPTCRE_NV = re.compile(_OPT_NV_TMPL.format(delim="=|:"), re.VERBOSE)
+ # Compiled regular expression for matching leading whitespace in a line
+ NONSPACECRE = re.compile(r"\S")
+ # Possible boolean values in the configuration.
+ BOOLEAN_STATES = {'1': True, 'yes': True, 'true': True, 'on': True,
+ '0': False, 'no': False, 'false': False, 'off': False}
+
+ def __init__(self, defaults=None, dict_type=_default_dict,
+ allow_no_value=False, *, delimiters=('=', ':'),
+ comment_prefixes=('#', ';'), inline_comment_prefixes=None,
+ strict=True, empty_lines_in_values=True,
+ default_section=DEFAULTSECT,
+ interpolation=_UNSET):
+
+ self._dict = dict_type
+ self._sections = self._dict()
+ self._defaults = self._dict()
+ self._proxies = self._dict()
+ self._proxies[default_section] = SectionProxy(self, default_section)
+ if defaults:
+ for key, value in defaults.items():
+ self._defaults[self.optionxform(key)] = value
+ self._delimiters = tuple(delimiters)
+ if delimiters == ('=', ':'):
+ self._optcre = self.OPTCRE_NV if allow_no_value else self.OPTCRE
+ else:
+ d = "|".join(re.escape(d) for d in delimiters)
+ if allow_no_value:
+ self._optcre = re.compile(self._OPT_NV_TMPL.format(delim=d),
+ re.VERBOSE)
+ else:
+ self._optcre = re.compile(self._OPT_TMPL.format(delim=d),
+ re.VERBOSE)
+ self._comment_prefixes = tuple(comment_prefixes or ())
+ self._inline_comment_prefixes = tuple(inline_comment_prefixes or ())
+ self._strict = strict
+ self._allow_no_value = allow_no_value
+ self._empty_lines_in_values = empty_lines_in_values
+ self.default_section=default_section
+ self._interpolation = interpolation
+ if self._interpolation is _UNSET:
+ self._interpolation = self._DEFAULT_INTERPOLATION
+ if self._interpolation is None:
+ self._interpolation = Interpolation()
+
+ def defaults(self):
+ return self._defaults
+
+ def sections(self):
+ """Return a list of section names, excluding [DEFAULT]"""
+ # self._sections will never have [DEFAULT] in it
+ return list(self._sections.keys())
+
+ def add_section(self, section):
+ """Create a new section in the configuration.
+
+ Raise DuplicateSectionError if a section by the specified name
+ already exists. Raise ValueError if name is DEFAULT.
+ """
+ if section == self.default_section:
+ raise ValueError('Invalid section name: %r' % section)
+
+ if section in self._sections:
+ raise DuplicateSectionError(section)
+ self._sections[section] = self._dict()
+ self._proxies[section] = SectionProxy(self, section)
+
+ def has_section(self, section):
+ """Indicate whether the named section is present in the configuration.
+
+ The DEFAULT section is not acknowledged.
+ """
+ return section in self._sections
+
+ def options(self, section):
+ """Return a list of option names for the given section name."""
+ try:
+ opts = self._sections[section].copy()
+ except KeyError:
+ raise NoSectionError(section)
+ opts.update(self._defaults)
+ return list(opts.keys())
+
+ def read(self, filenames, encoding=None):
+ """Read and parse a filename or a list of filenames.
+
+ Files that cannot be opened are silently ignored; this is
+ designed so that you can specify a list of potential
+ configuration file locations (e.g. current directory, user's
+ home directory, systemwide directory), and all existing
+ configuration files in the list will be read. A single
+ filename may also be given.
+
+ Return list of successfully read files.
+ """
+ if isinstance(filenames, str):
+ filenames = [filenames]
+ read_ok = []
+ for filename in filenames:
+ try:
+ with open(filename, encoding=encoding) as fp:
+ self._read(fp, filename)
+ except IOError:
+ continue
+ read_ok.append(filename)
+ return read_ok
+
+ def read_file(self, f, source=None):
+ """Like read() but the argument must be a file-like object.
+
+ The `f' argument must be iterable, returning one line at a time.
+ Optional second argument is the `source' specifying the name of the
+ file being read. If not given, it is taken from f.name. If `f' has no
+ `name' attribute, `<???>' is used.
+ """
+ if source is None:
+ try:
+ source = f.name
+ except AttributeError:
+ source = '<???>'
+ self._read(f, source)
+
+ def read_string(self, string, source='<string>'):
+ """Read configuration from a given string."""
+ sfile = io.StringIO(string)
+ self.read_file(sfile, source)
+
+ def read_dict(self, dictionary, source='<dict>'):
+ """Read configuration from a dictionary.
+
+ Keys are section names, values are dictionaries with keys and values
+ that should be present in the section. If the used dictionary type
+ preserves order, sections and their keys will be added in order.
+
+ All types held in the dictionary are converted to strings during
+ reading, including section names, option names and keys.
+
+ Optional second argument is the `source' specifying the name of the
+ dictionary being read.
+ """
+ elements_added = set()
+ for section, keys in dictionary.items():
+ section = str(section)
+ try:
+ self.add_section(section)
+ except (DuplicateSectionError, ValueError):
+ if self._strict and section in elements_added:
+ raise
+ elements_added.add(section)
+ for key, value in keys.items():
+ key = self.optionxform(str(key))
+ if value is not None:
+ value = str(value)
+ if self._strict and (section, key) in elements_added:
+ raise DuplicateOptionError(section, key, source)
+ elements_added.add((section, key))
+ self.set(section, key, value)
+
+ def readfp(self, fp, filename=None):
+ """Deprecated, use read_file instead."""
+ warnings.warn(
+ "This method will be removed in future versions. "
+ "Use 'parser.read_file()' instead.",
+ DeprecationWarning, stacklevel=2
+ )
+ self.read_file(fp, source=filename)
+
+ def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
+ """Get an option value for a given section.
+
+ If `vars' is provided, it must be a dictionary. The option is looked up
+ in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
+ If the key is not found and `fallback' is provided, it is used as
+ a fallback value. `None' can be provided as a `fallback' value.
+
+ If interpolation is enabled and the optional argument `raw' is False,
+ all interpolations are expanded in the return values.
+
+ Arguments `raw', `vars', and `fallback' are keyword only.
+
+ The section DEFAULT is special.
+ """
+ try:
+ d = self._unify_values(section, vars)
+ except NoSectionError:
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
+ option = self.optionxform(option)
+ try:
+ value = d[option]
+ except KeyError:
+ if fallback is _UNSET:
+ raise NoOptionError(option, section)
+ else:
+ return fallback
+
+ if raw or value is None:
+ return value
+ else:
+ return self._interpolation.before_get(self, section, option, value,
+ d)
+
+ def _get(self, section, conv, option, **kwargs):
+ return conv(self.get(section, option, **kwargs))
+
+ def getint(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
+ try:
+ return self._get(section, int, option, raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
+
+ def getfloat(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
+ try:
+ return self._get(section, float, option, raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
+
+ def getboolean(self, section, option, *, raw=False, vars=None,
+ fallback=_UNSET):
+ try:
+ return self._get(section, self._convert_to_boolean, option,
+ raw=raw, vars=vars)
+ except (NoSectionError, NoOptionError):
+ if fallback is _UNSET:
+ raise
+ else:
+ return fallback
+
+ def items(self, section=_UNSET, raw=False, vars=None):
+ """Return a list of (name, value) tuples for each option in a section.
+
+ All % interpolations are expanded in the return values, based on the
+ defaults passed into the constructor, unless the optional argument
+ `raw' is true. Additional substitutions may be provided using the
+ `vars' argument, which must be a dictionary whose contents overrides
+ any pre-existing defaults.
+
+ The section DEFAULT is special.
+ """
+ if section is _UNSET:
+ return super().items()
+ d = self._defaults.copy()
+ try:
+ d.update(self._sections[section])
+ except KeyError:
+ if section != self.default_section:
+ raise NoSectionError(section)
+ # Update with the entry specific variables
+ if vars:
+ for key, value in vars.items():
+ d[self.optionxform(key)] = value
+ value_getter = lambda option: self._interpolation.before_get(self,
+ section, option, d[option], d)
+ if raw:
+ value_getter = lambda option: d[option]
+ return [(option, value_getter(option)) for option in d.keys()]
+
+ def optionxform(self, optionstr):
+ return optionstr.lower()
+
+ def has_option(self, section, option):
+ """Check for the existence of a given option in a given section.
+ If the specified `section' is None or an empty string, DEFAULT is
+ assumed. If the specified `section' does not exist, returns False."""
+ if not section or section == self.default_section:
+ option = self.optionxform(option)
+ return option in self._defaults
+ elif section not in self._sections:
+ return False
+ else:
+ option = self.optionxform(option)
+ return (option in self._sections[section]
+ or option in self._defaults)
+
+ def set(self, section, option, value=None):
+ """Set an option."""
+ if value:
+ value = self._interpolation.before_set(self, section, option,
+ value)
+ if not section or section == self.default_section:
+ sectdict = self._defaults
+ else:
+ try:
+ sectdict = self._sections[section]
+ except KeyError:
+ raise NoSectionError(section)
+ sectdict[self.optionxform(option)] = value
+
+ def write(self, fp, space_around_delimiters=True):
+ """Write an .ini-format representation of the configuration state.
+
+ If `space_around_delimiters' is True (the default), delimiters
+ between keys and values are surrounded by spaces.
+ """
+ if space_around_delimiters:
+ d = " {} ".format(self._delimiters[0])
+ else:
+ d = self._delimiters[0]
+ if self._defaults:
+ self._write_section(fp, self.default_section,
+ self._defaults.items(), d)
+ for section in self._sections:
+ self._write_section(fp, section,
+ self._sections[section].items(), d)
+
+ def _write_section(self, fp, section_name, section_items, delimiter):
+ """Write a single section to the specified `fp'."""
+ fp.write("[{}]\n".format(section_name))
+ for key, value in section_items:
+ value = self._interpolation.before_write(self, section_name, key,
+ value)
+ if value is not None or not self._allow_no_value:
+ value = delimiter + str(value).replace('\n', '\n\t')
+ else:
+ value = ""
+ fp.write("{}{}\n".format(key, value))
+ fp.write("\n")
+
+ def remove_option(self, section, option):
+ """Remove an option."""
+ if not section or section == self.default_section:
+ sectdict = self._defaults
+ else:
+ try:
+ sectdict = self._sections[section]
+ except KeyError:
+ raise NoSectionError(section)
+ option = self.optionxform(option)
+ existed = option in sectdict
+ if existed:
+ del sectdict[option]
+ return existed
+
+ def remove_section(self, section):
+ """Remove a file section."""
+ existed = section in self._sections
+ if existed:
+ del self._sections[section]
+ del self._proxies[section]
+ return existed
+
+ def __getitem__(self, key):
+ if key != self.default_section and not self.has_section(key):
+ raise KeyError(key)
+ return self._proxies[key]
+
+ def __setitem__(self, key, value):
+ # To conform with the mapping protocol, overwrites existing values in
+ # the section.
+
+ # XXX this is not atomic if read_dict fails at any point. Then again,
+ # no update method in configparser is atomic in this implementation.
+ self.remove_section(key)
+ self.read_dict({key: value})
+
+ def __delitem__(self, key):
+ if key == self.default_section:
+ raise ValueError("Cannot remove the default section.")
+ if not self.has_section(key):
+ raise KeyError(key)
+ self.remove_section(key)
+
+ def __contains__(self, key):
+ return key == self.default_section or self.has_section(key)
+
+ def __len__(self):
+ return len(self._sections) + 1 # the default section
+
+ def __iter__(self):
+ # XXX does it break when underlying container state changed?
+ return itertools.chain((self.default_section,), self._sections.keys())
+
+ def _read(self, fp, fpname):
+ """Parse a sectioned configuration file.
+
+ Each section in a configuration file contains a header, indicated by
+ a name in square brackets (`[]'), plus key/value options, indicated by
+ `name' and `value' delimited with a specific substring (`=' or `:' by
+ default).
+
+ Values can span multiple lines, as long as they are indented deeper
+ than the first line of the value. Depending on the parser's mode, blank
+ lines may be treated as parts of multiline values or ignored.
+
+ Configuration files may include comments, prefixed by specific
+ characters (`#' and `;' by default). Comments may appear on their own
+ in an otherwise empty line or may be entered in lines holding values or
+ section names.
+ """
+ elements_added = set()
+ cursect = None # None, or a dictionary
+ sectname = None
+ optname = None
+ lineno = 0
+ indent_level = 0
+ e = None # None, or an exception
+ for lineno, line in enumerate(fp, start=1):
+ comment_start = None
+ # strip inline comments
+ for prefix in self._inline_comment_prefixes:
+ index = line.find(prefix)
+ if index == 0 or (index > 0 and line[index-1].isspace()):
+ comment_start = index
+ break
+ # strip full line comments
+ for prefix in self._comment_prefixes:
+ if line.strip().startswith(prefix):
+ comment_start = 0
+ break
+ value = line[:comment_start].strip()
+ if not value:
+ if self._empty_lines_in_values:
+ # add empty line to the value, but only if there was no
+ # comment on the line
+ if (comment_start is None and
+ cursect is not None and
+ optname and
+ cursect[optname] is not None):
+ cursect[optname].append('') # newlines added at join
+ else:
+ # empty line marks end of value
+ indent_level = sys.maxsize
+ continue
+ # continuation line?
+ first_nonspace = self.NONSPACECRE.search(line)
+ cur_indent_level = first_nonspace.start() if first_nonspace else 0
+ if (cursect is not None and optname and
+ cur_indent_level > indent_level):
+ cursect[optname].append(value)
+ # a section header or option header?
+ else:
+ indent_level = cur_indent_level
+ # is it a section header?
+ mo = self.SECTCRE.match(value)
+ if mo:
+ sectname = mo.group('header')
+ if sectname in self._sections:
+ if self._strict and sectname in elements_added:
+ raise DuplicateSectionError(sectname, fpname,
+ lineno)
+ cursect = self._sections[sectname]
+ elements_added.add(sectname)
+ elif sectname == self.default_section:
+ cursect = self._defaults
+ else:
+ cursect = self._dict()
+ self._sections[sectname] = cursect
+ self._proxies[sectname] = SectionProxy(self, sectname)
+ elements_added.add(sectname)
+ # So sections can't start with a continuation line
+ optname = None
+ # no section header in the file?
+ elif cursect is None:
+ raise MissingSectionHeaderError(fpname, lineno, line)
+ # an option line?
+ else:
+ mo = self._optcre.match(value)
+ if mo:
+ optname, vi, optval = mo.group('option', 'vi', 'value')
+ if not optname:
+ e = self._handle_error(e, fpname, lineno, line)
+ optname = self.optionxform(optname.rstrip())
+ if (self._strict and
+ (sectname, optname) in elements_added):
+ raise DuplicateOptionError(sectname, optname,
+ fpname, lineno)
+ elements_added.add((sectname, optname))
+ # This check is fine because the OPTCRE cannot
+ # match if it would set optval to None
+ if optval is not None:
+ optval = optval.strip()
+ cursect[optname] = [optval]
+ else:
+ # valueless option handling
+ cursect[optname] = None
+ else:
+ # a non-fatal parsing error occurred. set up the
+ # exception but keep going. the exception will be
+ # raised at the end of the file and will contain a
+ # list of all bogus lines
+ e = self._handle_error(e, fpname, lineno, line)
+ # if any parsing errors occurred, raise an exception
+ if e:
+ raise e
+ self._join_multiline_values()
+
+ def _join_multiline_values(self):
+ defaults = self.default_section, self._defaults
+ all_sections = itertools.chain((defaults,),
+ self._sections.items())
+ for section, options in all_sections:
+ for name, val in options.items():
+ if isinstance(val, list):
+ val = '\n'.join(val).rstrip()
+ options[name] = self._interpolation.before_read(self,
+ section,
+ name, val)
+
+ def _handle_error(self, exc, fpname, lineno, line):
+ if not exc:
+ exc = ParsingError(fpname)
+ exc.append(lineno, repr(line))
+ return exc
+
+ def _unify_values(self, section, vars):
+ """Create a sequence of lookups with 'vars' taking priority over
+ the 'section' which takes priority over the DEFAULTSECT.
+
+ """
+ sectiondict = {}
+ try:
+ sectiondict = self._sections[section]
+ except KeyError:
+ if section != self.default_section:
+ raise NoSectionError(section)
+ # Update with the entry specific variables
+ vardict = {}
+ if vars:
+ for key, value in vars.items():
+ if value is not None:
+ value = str(value)
+ vardict[self.optionxform(key)] = value
+ return _ChainMap(vardict, sectiondict, self._defaults)
+
+ def _convert_to_boolean(self, value):
+ """Return a boolean value translating from other types if necessary.
+ """
+ if value.lower() not in self.BOOLEAN_STATES:
+ raise ValueError('Not a boolean: %s' % value)
+ return self.BOOLEAN_STATES[value.lower()]
+
+ def _validate_value_types(self, *, section="", option="", value=""):
+ """Raises a TypeError for non-string values.
+
+ The only legal non-string value if we allow valueless
+ options is None, so we need to check if the value is a
+ string if:
+ - we do not allow valueless options, or
+ - we allow valueless options but the value is not None
+
+ For compatibility reasons this method is not used in classic set()
+ for RawConfigParsers. It is invoked in every case for mapping protocol
+ access and in ConfigParser.set().
+ """
+ if not isinstance(section, str):
+ raise TypeError("section names must be strings")
+ if not isinstance(option, str):
+ raise TypeError("option keys must be strings")
+ if not self._allow_no_value or value:
+ if not isinstance(value, str):
+ raise TypeError("option values must be strings")
+
+
+class ConfigParser(RawConfigParser):
+ """ConfigParser implementing interpolation."""
+
+ _DEFAULT_INTERPOLATION = BasicInterpolation()
+
+ def set(self, section, option, value=None):
+ """Set an option. Extends RawConfigParser.set by validating type and
+ interpolation syntax on the value."""
+ self._validate_value_types(option=option, value=value)
+ super().set(section, option, value)
+
+ def add_section(self, section):
+ """Create a new section in the configuration. Extends
+ RawConfigParser.add_section by validating if the section name is
+ a string."""
+ self._validate_value_types(section=section)
+ super().add_section(section)
+
+
+class SafeConfigParser(ConfigParser):
+ """ConfigParser alias for backwards compatibility purposes."""
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ warnings.warn(
+ "The SafeConfigParser class has been renamed to ConfigParser "
+ "in Python 3.2. This alias will be removed in future versions."
+ " Use ConfigParser directly instead.",
+ DeprecationWarning, stacklevel=2
+ )
+
+
+class SectionProxy(MutableMapping):
+ """A proxy for a single section from a parser."""
+
+ def __init__(self, parser, name):
+ """Creates a view on a section of the specified `name` in `parser`."""
+ self._parser = parser
+ self._name = name
+
+ def __repr__(self):
+ return '<Section: {}>'.format(self._name)
+
+ def __getitem__(self, key):
+ if not self._parser.has_option(self._name, key):
+ raise KeyError(key)
+ return self._parser.get(self._name, key)
+
+ def __setitem__(self, key, value):
+ self._parser._validate_value_types(option=key, value=value)
+ return self._parser.set(self._name, key, value)
+
+ def __delitem__(self, key):
+ if not (self._parser.has_option(self._name, key) and
+ self._parser.remove_option(self._name, key)):
+ raise KeyError(key)
+
+ def __contains__(self, key):
+ return self._parser.has_option(self._name, key)
+
+ def __len__(self):
+ return len(self._options())
+
+ def __iter__(self):
+ return self._options().__iter__()
+
+ def _options(self):
+ if self._name != self._parser.default_section:
+ return self._parser.options(self._name)
+ else:
+ return self._parser.defaults()
+
+ def get(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.get(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
+
+ def getint(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getint(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
+
+ def getfloat(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getfloat(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
+
+ def getboolean(self, option, fallback=None, *, raw=False, vars=None):
+ return self._parser.getboolean(self._name, option, raw=raw, vars=vars,
+ fallback=fallback)
+
+ @property
+ def parser(self):
+ # The parser object of the proxy is read-only.
+ return self._parser
+
+ @property
+ def name(self):
+ # The name of the section on a proxy is read-only.
+ return self._name
diff --git a/Lib/contextlib.py b/Lib/contextlib.py
index f05205b01c2..5ebbbc65838 100644
--- a/Lib/contextlib.py
+++ b/Lib/contextlib.py
@@ -4,24 +4,55 @@ import sys
from functools import wraps
from warnings import warn
-__all__ = ["contextmanager", "nested", "closing"]
+__all__ = ["contextmanager", "closing", "ContextDecorator"]
-class GeneratorContextManager(object):
+
+class ContextDecorator(object):
+ "A base class or mixin that enables context managers to work as decorators."
+
+ def _recreate_cm(self):
+ """Return a recreated instance of self.
+
+ Allows otherwise one-shot context managers like
+ _GeneratorContextManager to support use as
+ decorators via implicit recreation.
+
+ Note: this is a private interface just for _GCM in 3.2 but will be
+ renamed and documented for third party use in 3.3
+ """
+ return self
+
+ def __call__(self, func):
+ @wraps(func)
+ def inner(*args, **kwds):
+ with self._recreate_cm():
+ return func(*args, **kwds)
+ return inner
+
+
+class _GeneratorContextManager(ContextDecorator):
"""Helper for @contextmanager decorator."""
- def __init__(self, gen):
- self.gen = gen
+ def __init__(self, func, *args, **kwds):
+ self.gen = func(*args, **kwds)
+ self.func, self.args, self.kwds = func, args, kwds
+
+ def _recreate_cm(self):
+ # _GCM instances are one-shot context managers, so the
+ # CM must be recreated each time a decorated function is
+ # called
+ return self.__class__(self.func, *self.args, **self.kwds)
def __enter__(self):
try:
- return self.gen.next()
+ return next(self.gen)
except StopIteration:
raise RuntimeError("generator didn't yield")
def __exit__(self, type, value, traceback):
if type is None:
try:
- self.gen.next()
+ next(self.gen)
except StopIteration:
return
else:
@@ -34,7 +65,7 @@ class GeneratorContextManager(object):
try:
self.gen.throw(type, value, traceback)
raise RuntimeError("generator didn't stop after throw()")
- except StopIteration, exc:
+ except StopIteration as exc:
# Suppress the exception *unless* it's the same exception that
# was passed to throw(). This prevents a StopIteration
# raised inside the "with" statement from being suppressed
@@ -81,54 +112,10 @@ def contextmanager(func):
"""
@wraps(func)
def helper(*args, **kwds):
- return GeneratorContextManager(func(*args, **kwds))
+ return _GeneratorContextManager(func, *args, **kwds)
return helper
-@contextmanager
-def nested(*managers):
- """Combine multiple context managers into a single nested context manager.
-
- This function has been deprecated in favour of the multiple manager form
- of the with statement.
-
- The one advantage of this function over the multiple manager form of the
- with statement is that argument unpacking allows it to be
- used with a variable number of context managers as follows:
-
- with nested(*managers):
- do_something()
-
- """
- warn("With-statements now directly support multiple context managers",
- DeprecationWarning, 3)
- exits = []
- vars = []
- exc = (None, None, None)
- try:
- for mgr in managers:
- exit = mgr.__exit__
- enter = mgr.__enter__
- vars.append(enter())
- exits.append(exit)
- yield vars
- except:
- exc = sys.exc_info()
- finally:
- while exits:
- exit = exits.pop()
- try:
- if exit(*exc):
- exc = (None, None, None)
- except:
- exc = sys.exc_info()
- if exc != (None, None, None):
- # Don't rely on sys.exc_info() still containing
- # the right information. Another exception may
- # have been raised and caught by an exit method
- raise exc[0], exc[1], exc[2]
-
-
class closing(object):
"""Context to automatically close something at the end of a block.
diff --git a/Lib/copy.py b/Lib/copy.py
index c227a2e5c7c..089d101c7ca 100644
--- a/Lib/copy.py
+++ b/Lib/copy.py
@@ -50,7 +50,8 @@ __getstate__() and __setstate__(). See the documentation for module
import types
import weakref
-from copy_reg import dispatch_table
+from copyreg import dispatch_table
+import builtins
class Error(Exception):
pass
@@ -100,13 +101,16 @@ _copy_dispatch = d = {}
def _copy_immutable(x):
return x
-for t in (type(None), int, long, float, bool, str, tuple,
- frozenset, type, xrange, types.ClassType,
+for t in (type(None), int, float, bool, str, tuple,
+ frozenset, type, range,
types.BuiltinFunctionType, type(Ellipsis),
types.FunctionType, weakref.ref):
d[t] = _copy_immutable
-for name in ("ComplexType", "UnicodeType", "CodeType"):
- t = getattr(types, name, None)
+t = getattr(types, "CodeType", None)
+if t is not None:
+ d[t] = _copy_immutable
+for name in ("complex", "unicode"):
+ t = getattr(builtins, name, None)
if t is not None:
d[t] = _copy_immutable
@@ -120,26 +124,6 @@ def _copy_with_copy_method(x):
if PyStringMap is not None:
d[PyStringMap] = _copy_with_copy_method
-def _copy_inst(x):
- if hasattr(x, '__copy__'):
- return x.__copy__()
- if hasattr(x, '__getinitargs__'):
- args = x.__getinitargs__()
- y = x.__class__(*args)
- else:
- y = _EmptyClass()
- y.__class__ = x.__class__
- if hasattr(x, '__getstate__'):
- state = x.__getstate__()
- else:
- state = x.__dict__
- if hasattr(y, '__setstate__'):
- y.__setstate__(state)
- else:
- y.__dict__.update(state)
- return y
-d[types.InstanceType] = _copy_inst
-
del d
def deepcopy(x, memo=None, _nil=[]):
@@ -200,25 +184,20 @@ def _deepcopy_atomic(x, memo):
d[type(None)] = _deepcopy_atomic
d[type(Ellipsis)] = _deepcopy_atomic
d[int] = _deepcopy_atomic
-d[long] = _deepcopy_atomic
d[float] = _deepcopy_atomic
d[bool] = _deepcopy_atomic
try:
d[complex] = _deepcopy_atomic
except NameError:
pass
+d[bytes] = _deepcopy_atomic
d[str] = _deepcopy_atomic
try:
- d[unicode] = _deepcopy_atomic
-except NameError:
- pass
-try:
d[types.CodeType] = _deepcopy_atomic
except AttributeError:
pass
d[type] = _deepcopy_atomic
-d[xrange] = _deepcopy_atomic
-d[types.ClassType] = _deepcopy_atomic
+d[range] = _deepcopy_atomic
d[types.BuiltinFunctionType] = _deepcopy_atomic
d[types.FunctionType] = _deepcopy_atomic
d[weakref.ref] = _deepcopy_atomic
@@ -253,7 +232,7 @@ d[tuple] = _deepcopy_tuple
def _deepcopy_dict(x, memo):
y = {}
memo[id(x)] = y
- for key, value in x.iteritems():
+ for key, value in x.items():
y[deepcopy(key, memo)] = deepcopy(value, memo)
return y
d[dict] = _deepcopy_dict
@@ -261,7 +240,7 @@ if PyStringMap is not None:
d[PyStringMap] = _deepcopy_dict
def _deepcopy_method(x, memo): # Copy instance methods
- return type(x)(x.im_func, deepcopy(x.im_self, memo), x.im_class)
+ return type(x)(x.__func__, deepcopy(x.__self__, memo))
_deepcopy_dispatch[types.MethodType] = _deepcopy_method
def _keep_alive(x, memo):
@@ -280,29 +259,6 @@ def _keep_alive(x, memo):
# aha, this is the first one :-)
memo[id(memo)]=[x]
-def _deepcopy_inst(x, memo):
- if hasattr(x, '__deepcopy__'):
- return x.__deepcopy__(memo)
- if hasattr(x, '__getinitargs__'):
- args = x.__getinitargs__()
- args = deepcopy(args, memo)
- y = x.__class__(*args)
- else:
- y = _EmptyClass()
- y.__class__ = x.__class__
- memo[id(x)] = y
- if hasattr(x, '__getstate__'):
- state = x.__getstate__()
- else:
- state = x.__dict__
- state = deepcopy(state, memo)
- if hasattr(y, '__setstate__'):
- y.__setstate__(state)
- else:
- y.__dict__.update(state)
- return y
-d[types.InstanceType] = _deepcopy_inst
-
def _reconstruct(x, info, deep, memo=None):
if isinstance(info, str):
return x
@@ -342,7 +298,7 @@ def _reconstruct(x, info, deep, memo=None):
if state is not None:
y.__dict__.update(state)
if slotstate is not None:
- for key, value in slotstate.iteritems():
+ for key, value in slotstate.items():
setattr(y, key, value)
if listiter is not None:
@@ -367,14 +323,14 @@ class _EmptyClass:
pass
def _test():
- l = [None, 1, 2L, 3.14, 'xyzzy', (1, 2L), [3.14, 'abc'],
+ l = [None, 1, 2, 3.14, 'xyzzy', (1, 2), [3.14, 'abc'],
{'abc': 'ABC'}, (), [], {}]
l1 = copy(l)
- print l1==l
+ print(l1==l)
l1 = map(copy, l)
- print l1==l
+ print(l1==l)
l1 = deepcopy(l)
- print l1==l
+ print(l1==l)
class C:
def __init__(self, arg=None):
self.a = 1
@@ -389,7 +345,7 @@ def _test():
def __getstate__(self):
return {'a': self.a, 'arg': self.arg}
def __setstate__(self, state):
- for key, value in state.iteritems():
+ for key, value in state.items():
setattr(self, key, value)
def __deepcopy__(self, memo=None):
new = self.__class__(deepcopy(self.arg, memo))
@@ -398,26 +354,25 @@ def _test():
c = C('argument sketch')
l.append(c)
l2 = copy(l)
- print l == l2
- print l
- print l2
+ print(l == l2)
+ print(l)
+ print(l2)
l2 = deepcopy(l)
- print l == l2
- print l
- print l2
+ print(l == l2)
+ print(l)
+ print(l2)
l.append({l[1]: l, 'xyz': l[2]})
l3 = copy(l)
- import repr
- print map(repr.repr, l)
- print map(repr.repr, l1)
- print map(repr.repr, l2)
- print map(repr.repr, l3)
+ import reprlib
+ print(map(reprlib.repr, l))
+ print(map(reprlib.repr, l1))
+ print(map(reprlib.repr, l2))
+ print(map(reprlib.repr, l3))
l3 = deepcopy(l)
- import repr
- print map(repr.repr, l)
- print map(repr.repr, l1)
- print map(repr.repr, l2)
- print map(repr.repr, l3)
+ print(map(reprlib.repr, l))
+ print(map(reprlib.repr, l1))
+ print(map(reprlib.repr, l2))
+ print(map(reprlib.repr, l3))
class odict(dict):
def __init__(self, d = {}):
self.a = 99
diff --git a/Lib/copy_reg.py b/Lib/copyreg.py
index db1715092c5..66c0f8a64d6 100644
--- a/Lib/copy_reg.py
+++ b/Lib/copyreg.py
@@ -1,21 +1,16 @@
-"""Helper to provide extensibility for pickle/cPickle.
+"""Helper to provide extensibility for pickle.
This is only useful to add pickle support for extension types defined in
C, not for instances of user-defined classes.
"""
-from types import ClassType as _ClassType
-
__all__ = ["pickle", "constructor",
"add_extension", "remove_extension", "clear_extension_cache"]
dispatch_table = {}
def pickle(ob_type, pickle_function, constructor_ob=None):
- if type(ob_type) is _ClassType:
- raise TypeError("copy_reg is not intended for use with classes")
-
- if not hasattr(pickle_function, '__call__'):
+ if not callable(pickle_function):
raise TypeError("reduction functions must be callable")
dispatch_table[ob_type] = pickle_function
@@ -25,7 +20,7 @@ def pickle(ob_type, pickle_function, constructor_ob=None):
constructor(constructor_ob)
def constructor(object):
- if not hasattr(object, '__call__'):
+ if not callable(object):
raise TypeError("constructors must be callable")
# Example: provide pickling support for complex numbers.
@@ -67,7 +62,7 @@ def _reduce_ex(self, proto):
state = None
else:
if base is self.__class__:
- raise TypeError, "can't pickle %s objects" % base.__name__
+ raise TypeError("can't pickle %s objects" % base.__name__)
state = base(self)
args = (self.__class__, base, state)
try:
@@ -119,7 +114,7 @@ def _slotnames(cls):
if "__slots__" in c.__dict__:
slots = c.__dict__['__slots__']
# if class has a single slot, it can be given as a string
- if isinstance(slots, basestring):
+ if isinstance(slots, str):
slots = (slots,)
for name in slots:
# special descriptors
@@ -151,14 +146,14 @@ def _slotnames(cls):
_extension_registry = {} # key -> code
_inverted_registry = {} # code -> key
_extension_cache = {} # code -> object
-# Don't ever rebind those names: cPickle grabs a reference to them when
+# Don't ever rebind those names: pickling grabs a reference to them when
# it's initialized, and won't see a rebinding.
def add_extension(module, name, code):
"""Register an extension code."""
code = int(code)
if not 1 <= code <= 0x7fffffff:
- raise ValueError, "code out of range"
+ raise ValueError("code out of range")
key = (module, name)
if (_extension_registry.get(key) == code and
_inverted_registry.get(code) == key):
diff --git a/Lib/csv.py b/Lib/csv.py
index 984ed7e581b..8dfc77e3108 100644
--- a/Lib/csv.py
+++ b/Lib/csv.py
@@ -4,7 +4,6 @@ csv.py - read/write/investigate CSV files
"""
import re
-from functools import reduce
from _csv import Error, __version__, writer, reader, register_dialect, \
unregister_dialect, get_dialect, list_dialects, \
field_size_limit, \
@@ -12,10 +11,7 @@ from _csv import Error, __version__, writer, reader, register_dialect, \
__doc__
from _csv import Dialect as _Dialect
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+from io import StringIO
__all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
"Error", "Dialect", "__doc__", "excel", "excel_tab",
@@ -24,7 +20,7 @@ __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
"unregister_dialect", "__version__", "DictReader", "DictWriter" ]
class Dialect:
- """Describe an Excel dialect.
+ """Describe a CSV dialect.
This must be subclassed (see csv.excel). Valid attributes are:
delimiter, quotechar, escapechar, doublequote, skipinitialspace,
@@ -50,7 +46,7 @@ class Dialect:
def _validate(self):
try:
_Dialect(self)
- except TypeError, e:
+ except TypeError as e:
# We do this for compatibility with py2.3
raise Error(str(e))
@@ -69,6 +65,16 @@ class excel_tab(excel):
delimiter = '\t'
register_dialect("excel-tab", excel_tab)
+class unix_dialect(Dialect):
+ """Describe the usual properties of Unix-generated CSV files."""
+ delimiter = ','
+ quotechar = '"'
+ doublequote = True
+ skipinitialspace = False
+ lineterminator = '\n'
+ quoting = QUOTE_ALL
+register_dialect("unix", unix_dialect)
+
class DictReader:
def __init__(self, f, fieldnames=None, restkey=None, restval=None,
@@ -87,7 +93,7 @@ class DictReader:
def fieldnames(self):
if self._fieldnames is None:
try:
- self._fieldnames = self.reader.next()
+ self._fieldnames = next(self.reader)
except StopIteration:
pass
self.line_num = self.reader.line_num
@@ -97,18 +103,18 @@ class DictReader:
def fieldnames(self, value):
self._fieldnames = value
- def next(self):
+ def __next__(self):
if self.line_num == 0:
# Used only for its side effect.
self.fieldnames
- row = self.reader.next()
+ row = next(self.reader)
self.line_num = self.reader.line_num
# unlike the basic reader, we prefer not to return blanks,
# because we will typically wind up with a dict full of None
# values
while row == []:
- row = self.reader.next()
+ row = next(self.reader)
d = dict(zip(self.fieldnames, row))
lf = len(self.fieldnames)
lr = len(row)
@@ -126,9 +132,8 @@ class DictWriter:
self.fieldnames = fieldnames # list of keys for the dict
self.restval = restval # for writing short dicts
if extrasaction.lower() not in ("raise", "ignore"):
- raise ValueError, \
- ("extrasaction (%s) must be 'raise' or 'ignore'" %
- extrasaction)
+ raise ValueError("extrasaction (%s) must be 'raise' or 'ignore'"
+ % extrasaction)
self.extrasaction = extrasaction
self.writer = writer(f, dialect, *args, **kwds)
@@ -140,8 +145,8 @@ class DictWriter:
if self.extrasaction == "raise":
wrong_fields = [k for k in rowdict if k not in self.fieldnames]
if wrong_fields:
- raise ValueError("dict contains fields not in fieldnames: " +
- ", ".join(wrong_fields))
+ raise ValueError("dict contains fields not in fieldnames: "
+ + ", ".join(wrong_fields))
return [rowdict.get(key, self.restval) for key in self.fieldnames]
def writerow(self, rowdict):
@@ -181,7 +186,7 @@ class Sniffer:
delimiters)
if not delimiter:
- raise Error, "Could not determine delimiter"
+ raise Error("Could not determine delimiter")
class dialect(Dialect):
_name = "sniffed"
@@ -245,12 +250,10 @@ class Sniffer:
if m[n]:
spaces += 1
- quotechar = reduce(lambda a, b, quotes = quotes:
- (quotes[a] > quotes[b]) and a or b, quotes.keys())
+ quotechar = max(quotes, key=quotes.get)
if delims:
- delim = reduce(lambda a, b, delims = delims:
- (delims[a] > delims[b]) and a or b, delims.keys())
+ delim = max(delims, key=delims.get)
skipinitialspace = delims[delim] == spaces
if delim == '\n': # most likely a file with a single column
delim = ''
@@ -293,7 +296,7 @@ class Sniffer:
additional chunks as necessary.
"""
- data = filter(None, data.split('\n'))
+ data = list(filter(None, data.split('\n')))
ascii = [chr(c) for c in range(127)] # 7-bit ASCII
@@ -316,19 +319,17 @@ class Sniffer:
charFrequency[char] = metaFrequency
for char in charFrequency.keys():
- items = charFrequency[char].items()
+ items = list(charFrequency[char].items())
if len(items) == 1 and items[0][0] == 0:
continue
# get the mode of the frequencies
if len(items) > 1:
- modes[char] = reduce(lambda a, b: a[1] > b[1] and a or b,
- items)
+ modes[char] = max(items, key=lambda x: x[1])
# adjust the mode - subtract the sum of all
# other frequencies
items.remove(modes[char])
modes[char] = (modes[char][0], modes[char][1]
- - reduce(lambda a, b: (0, a[1] + b[1]),
- items)[1])
+ - sum(item[1] for item in items))
else:
modes[char] = items[0]
@@ -348,7 +349,7 @@ class Sniffer:
consistency -= 0.01
if len(delims) == 1:
- delim = delims.keys()[0]
+ delim = list(delims.keys())[0]
skipinitialspace = (data[0].count(delim) ==
data[0].count("%c " % delim))
return (delim, skipinitialspace)
@@ -391,7 +392,7 @@ class Sniffer:
rdr = reader(StringIO(sample), self.sniff(sample))
- header = rdr.next() # assume first row is header
+ header = next(rdr) # assume first row is header
columns = len(header)
columnTypes = {}
@@ -407,9 +408,9 @@ class Sniffer:
if len(row) != columns:
continue # skip rows that have irregular number of columns
- for col in columnTypes.keys():
+ for col in list(columnTypes.keys()):
- for thisType in [int, long, float, complex]:
+ for thisType in [int, float, complex]:
try:
thisType(row[col])
break
@@ -419,10 +420,6 @@ class Sniffer:
# fallback to length of string
thisType = len(row[col])
- # treat longs as ints
- if thisType == long:
- thisType = int
-
if thisType != columnTypes[col]:
if columnTypes[col] is None: # add new column type
columnTypes[col] = thisType
diff --git a/Lib/ctypes/__init__.py b/Lib/ctypes/__init__.py
index 4e97c15208f..111209a9535 100644
--- a/Lib/ctypes/__init__.py
+++ b/Lib/ctypes/__init__.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""create and manipulate C data types in Python"""
import os as _os, sys as _sys
@@ -50,18 +47,18 @@ STDAPICALLTYPE
"""
def create_string_buffer(init, size=None):
- """create_string_buffer(aString) -> character array
+ """create_string_buffer(aBytes) -> character array
create_string_buffer(anInteger) -> character array
create_string_buffer(aString, anInteger) -> character array
"""
- if isinstance(init, (str, unicode)):
+ if isinstance(init, (str, bytes)):
if size is None:
size = len(init)+1
buftype = c_char * size
buf = buftype()
buf.value = init
return buf
- elif isinstance(init, (int, long)):
+ elif isinstance(init, int):
buftype = c_char * init
buf = buftype()
return buf
@@ -160,7 +157,7 @@ class py_object(_SimpleCData):
_type_ = "O"
def __repr__(self):
try:
- return super(py_object, self).__repr__()
+ return super().__repr__()
except ValueError:
return "%s(<NULL>)" % type(self).__name__
_check_size(py_object, "P")
@@ -262,6 +259,12 @@ class c_bool(_SimpleCData):
from _ctypes import POINTER, pointer, _pointer_type_cache
+class c_wchar_p(_SimpleCData):
+ _type_ = "Z"
+
+class c_wchar(_SimpleCData):
+ _type_ = "u"
+
def _reset_cache():
_pointer_type_cache.clear()
_c_functype_cache.clear()
@@ -278,39 +281,24 @@ def _reset_cache():
# compiled with the MS SDK compiler. Or an uninitialized variable?
CFUNCTYPE(c_int)(lambda: None)
-try:
- from _ctypes import set_conversion_mode
-except ImportError:
- pass
-else:
- if _os.name in ("nt", "ce"):
- set_conversion_mode("mbcs", "ignore")
- else:
- set_conversion_mode("ascii", "strict")
-
- class c_wchar_p(_SimpleCData):
- _type_ = "Z"
-
- class c_wchar(_SimpleCData):
- _type_ = "u"
+def create_unicode_buffer(init, size=None):
+ """create_unicode_buffer(aString) -> character array
+ create_unicode_buffer(anInteger) -> character array
+ create_unicode_buffer(aString, anInteger) -> character array
+ """
+ if isinstance(init, (str, bytes)):
+ if size is None:
+ size = len(init)+1
+ buftype = c_wchar * size
+ buf = buftype()
+ buf.value = init
+ return buf
+ elif isinstance(init, int):
+ buftype = c_wchar * init
+ buf = buftype()
+ return buf
+ raise TypeError(init)
- def create_unicode_buffer(init, size=None):
- """create_unicode_buffer(aString) -> character array
- create_unicode_buffer(anInteger) -> character array
- create_unicode_buffer(aString, anInteger) -> character array
- """
- if isinstance(init, (str, unicode)):
- if size is None:
- size = len(init)+1
- buftype = c_wchar * size
- buf = buftype()
- buf.value = init
- return buf
- elif isinstance(init, (int, long)):
- buftype = c_wchar * init
- buf = buftype()
- return buf
- raise TypeError(init)
# XXX Deprecated
def SetPointerType(pointer, cls):
@@ -369,8 +357,8 @@ class CDLL(object):
def __repr__(self):
return "<%s '%s', handle %x at %x>" % \
(self.__class__.__name__, self._name,
- (self._handle & (_sys.maxint*2 + 1)),
- id(self) & (_sys.maxint*2 + 1))
+ (self._handle & (_sys.maxsize*2 + 1)),
+ id(self) & (_sys.maxsize*2 + 1))
def __getattr__(self, name):
if name.startswith('__') and name.endswith('__'):
@@ -381,7 +369,7 @@ class CDLL(object):
def __getitem__(self, name_or_ordinal):
func = self._FuncPtr((name_or_ordinal, self))
- if not isinstance(name_or_ordinal, (int, long)):
+ if not isinstance(name_or_ordinal, int):
func.__name__ = name_or_ordinal
return func
diff --git a/Lib/ctypes/_endian.py b/Lib/ctypes/_endian.py
index f80e675aaf2..dae65fc2152 100644
--- a/Lib/ctypes/_endian.py
+++ b/Lib/ctypes/_endian.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
import sys
from ctypes import *
@@ -33,7 +30,7 @@ class _swapped_meta(type(Structure)):
rest = desc[2:]
fields.append((name, _other_endian(typ)) + rest)
value = fields
- super(_swapped_meta, self).__setattr__(attrname, value)
+ super().__setattr__(attrname, value)
################################################################
@@ -46,18 +43,16 @@ if sys.byteorder == "little":
LittleEndianStructure = Structure
- class BigEndianStructure(Structure):
+ class BigEndianStructure(Structure, metaclass=_swapped_meta):
"""Structure with big endian byte order"""
- __metaclass__ = _swapped_meta
_swappedbytes_ = None
elif sys.byteorder == "big":
_OTHER_ENDIAN = "__ctype_le__"
BigEndianStructure = Structure
- class LittleEndianStructure(Structure):
+ class LittleEndianStructure(Structure, metaclass=_swapped_meta):
"""Structure with little endian byte order"""
- __metaclass__ = _swapped_meta
_swappedbytes_ = None
else:
diff --git a/Lib/ctypes/macholib/__init__.py b/Lib/ctypes/macholib/__init__.py
index 36149d28a15..5621defccd6 100644
--- a/Lib/ctypes/macholib/__init__.py
+++ b/Lib/ctypes/macholib/__init__.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Enough Mach-O to make your head spin.
diff --git a/Lib/ctypes/macholib/dyld.py b/Lib/ctypes/macholib/dyld.py
index 9714ec655f0..dc7052e7470 100644
--- a/Lib/ctypes/macholib/dyld.py
+++ b/Lib/ctypes/macholib/dyld.py
@@ -1,13 +1,10 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
dyld emulation
"""
import os
-from framework import framework_info
-from dylib import dylib_info
+from ctypes.macholib.framework import framework_info
+from ctypes.macholib.dylib import dylib_info
from itertools import *
__all__ = [
@@ -31,12 +28,6 @@ DEFAULT_LIBRARY_FALLBACK = [
"/usr/lib",
]
-def ensure_utf8(s):
- """Not all of PyObjC and Python understand unicode paths very well yet"""
- if isinstance(s, unicode):
- return s.encode('utf8')
- return s
-
def dyld_env(env, var):
if env is None:
env = os.environ
@@ -126,8 +117,6 @@ def dyld_find(name, executable_path=None, env=None):
"""
Find a library or framework using dyld semantics
"""
- name = ensure_utf8(name)
- executable_path = ensure_utf8(executable_path)
for path in dyld_image_suffix_search(chain(
dyld_override_search(name, env),
dyld_executable_path_search(name, executable_path),
@@ -148,7 +137,7 @@ def framework_find(fn, executable_path=None, env=None):
"""
try:
return dyld_find(fn, executable_path=executable_path, env=env)
- except ValueError, e:
+ except ValueError as e:
pass
fmwk_index = fn.rfind('.framework')
if fmwk_index == -1:
diff --git a/Lib/ctypes/macholib/dylib.py b/Lib/ctypes/macholib/dylib.py
index ea3dd38bdfb..aa107507bd4 100644
--- a/Lib/ctypes/macholib/dylib.py
+++ b/Lib/ctypes/macholib/dylib.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic dylib path manipulation
"""
diff --git a/Lib/ctypes/macholib/framework.py b/Lib/ctypes/macholib/framework.py
index dd7fb2f296a..ad6ed554ba0 100644
--- a/Lib/ctypes/macholib/framework.py
+++ b/Lib/ctypes/macholib/framework.py
@@ -1,6 +1,3 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
"""
Generic framework path manipulation
"""
diff --git a/Lib/ctypes/test/__init__.py b/Lib/ctypes/test/__init__.py
index 52230928ba5..82dc9e3e9e7 100644
--- a/Lib/ctypes/test/__init__.py
+++ b/Lib/ctypes/test/__init__.py
@@ -41,7 +41,7 @@ def find_package_modules(package, mask):
hasattr(package.__loader__, '_files')):
path = package.__name__.replace(".", os.path.sep)
mask = os.path.join(path, mask)
- for fnm in package.__loader__._files.iterkeys():
+ for fnm in package.__loader__._files.keys():
if fnmatch.fnmatchcase(fnm, mask):
yield os.path.splitext(fnm)[0].replace(os.path.sep, ".")
else:
@@ -58,14 +58,14 @@ def get_tests(package, mask, verbosity, exclude=()):
if modname.split(".")[-1] in exclude:
skipped.append(modname)
if verbosity > 1:
- print >> sys.stderr, "Skipped %s: excluded" % modname
+ print("Skipped %s: excluded" % modname, file=sys.stderr)
continue
try:
mod = __import__(modname, globals(), locals(), ['*'])
- except ResourceDenied, detail:
+ except ResourceDenied as detail:
skipped.append(modname)
if verbosity > 1:
- print >> sys.stderr, "Skipped %s: %s" % (modname, detail)
+ print("Skipped %s: %s" % (modname, detail), file=sys.stderr)
continue
for name in dir(mod):
if name.startswith("_"):
@@ -76,7 +76,7 @@ def get_tests(package, mask, verbosity, exclude=()):
return skipped, tests
def usage():
- print __doc__
+ print(__doc__)
return 1
def test_with_refcounts(runner, verbosity, testcase):
@@ -108,9 +108,9 @@ def test_with_refcounts(runner, verbosity, testcase):
cleanup()
refcounts[i] = sys.gettotalrefcount() - rc
if filter(None, refcounts):
- print "%s leaks:\n\t" % testcase, refcounts
+ print("%s leaks:\n\t" % testcase, refcounts)
elif verbosity:
- print "%s: ok." % testcase
+ print("%s: ok." % testcase)
class TestRunner(unittest.TextTestRunner):
def run(self, test, skipped):
@@ -126,7 +126,7 @@ class TestRunner(unittest.TextTestRunner):
self.stream.writeln(result.separator2)
run = result.testsRun
if _unavail: #skipped:
- requested = _unavail.keys()
+ requested = list(_unavail.keys())
requested.sort()
self.stream.writeln("Ran %d test%s in %.3fs (%s module%s skipped)" %
(run, run != 1 and "s" or "", timeTaken,
@@ -169,7 +169,7 @@ def main(*packages):
try:
sys.gettotalrefcount
except AttributeError:
- print >> sys.stderr, "-r flag requires Python debug build"
+ print("-r flag requires Python debug build", file=sys.stderr)
return -1
search_leaks = True
elif flag == "-u":
diff --git a/Lib/ctypes/test/test_array_in_pointer.py b/Lib/ctypes/test/test_array_in_pointer.py
index ee7863c594b..ca1edcf6210 100644
--- a/Lib/ctypes/test/test_array_in_pointer.py
+++ b/Lib/ctypes/test/test_array_in_pointer.py
@@ -6,7 +6,7 @@ import re
def dump(obj):
# helper function to dump memory contents in hex, with a hyphen
# between the bytes.
- h = hexlify(memoryview(obj))
+ h = hexlify(memoryview(obj)).decode()
return re.sub(r"(..)", r"\1-", h)[:-1]
diff --git a/Lib/ctypes/test/test_arrays.py b/Lib/ctypes/test/test_arrays.py
index 925f8bfedbf..cfc219e56bb 100644
--- a/Lib/ctypes/test/test_arrays.py
+++ b/Lib/ctypes/test/test_arrays.py
@@ -11,7 +11,7 @@ class ArrayTestCase(unittest.TestCase):
# create classes holding simple numeric types, and check
# various properties.
- init = range(15, 25)
+ init = list(range(15, 25))
for fmt in formats:
alen = len(init)
@@ -27,7 +27,7 @@ class ArrayTestCase(unittest.TestCase):
# change the items
from operator import setitem
- new_values = range(42, 42+alen)
+ new_values = list(range(42, 42+alen))
[setitem(ia, n, new_values[n]) for n in range(alen)]
values = [ia[i] for i in range(len(init))]
self.assertEqual(values, new_values)
@@ -42,26 +42,23 @@ class ArrayTestCase(unittest.TestCase):
CharArray = ARRAY(c_char, 3)
- ca = CharArray("a", "b", "c")
+ ca = CharArray(b"a", b"b", b"c")
# Should this work? It doesn't:
# CharArray("abc")
self.assertRaises(TypeError, CharArray, "abc")
- self.assertEqual(ca[0], "a")
- self.assertEqual(ca[1], "b")
- self.assertEqual(ca[2], "c")
- self.assertEqual(ca[-3], "a")
- self.assertEqual(ca[-2], "b")
- self.assertEqual(ca[-1], "c")
+ self.assertEqual(ca[0], b"a")
+ self.assertEqual(ca[1], b"b")
+ self.assertEqual(ca[2], b"c")
+ self.assertEqual(ca[-3], b"a")
+ self.assertEqual(ca[-2], b"b")
+ self.assertEqual(ca[-1], b"c")
self.assertEqual(len(ca), 3)
- # slicing is now supported, but not extended slicing (3-argument)!
- from operator import getslice, delitem
- self.assertRaises(TypeError, getslice, ca, 0, 1, -1)
-
# cannot delete items
+ from operator import delitem
self.assertRaises(TypeError, delitem, ca, 0)
def test_numeric_arrays(self):
@@ -92,14 +89,14 @@ class ArrayTestCase(unittest.TestCase):
def test_from_address(self):
# Failed with 0.9.8, reported by JUrner
- p = create_string_buffer("foo")
+ p = create_string_buffer(b"foo")
sz = (c_char * 3).from_address(addressof(p))
- self.assertEqual(sz[:], "foo")
- self.assertEqual(sz[::], "foo")
- self.assertEqual(sz[::-1], "oof")
- self.assertEqual(sz[::3], "f")
- self.assertEqual(sz[1:4:2], "o")
- self.assertEqual(sz.value, "foo")
+ self.assertEqual(sz[:], b"foo")
+ self.assertEqual(sz[::], b"foo")
+ self.assertEqual(sz[::-1], b"oof")
+ self.assertEqual(sz[::3], b"f")
+ self.assertEqual(sz[1:4:2], b"o")
+ self.assertEqual(sz.value, b"foo")
try:
create_unicode_buffer
@@ -130,5 +127,57 @@ class ArrayTestCase(unittest.TestCase):
t2 = my_int * 1
self.assertTrue(t1 is t2)
+ def test_subclass(self):
+ class T(Array):
+ _type_ = c_int
+ _length_ = 13
+ class U(T):
+ pass
+ class V(U):
+ pass
+ class W(V):
+ pass
+ class X(T):
+ _type_ = c_short
+ class Y(T):
+ _length_ = 187
+
+ for c in [T, U, V, W]:
+ self.assertEqual(c._type_, c_int)
+ self.assertEqual(c._length_, 13)
+ self.assertEqual(c()._type_, c_int)
+ self.assertEqual(c()._length_, 13)
+
+ self.assertEqual(X._type_, c_short)
+ self.assertEqual(X._length_, 13)
+ self.assertEqual(X()._type_, c_short)
+ self.assertEqual(X()._length_, 13)
+
+ self.assertEqual(Y._type_, c_int)
+ self.assertEqual(Y._length_, 187)
+ self.assertEqual(Y()._type_, c_int)
+ self.assertEqual(Y()._length_, 187)
+
+ def test_bad_subclass(self):
+ import sys
+
+ with self.assertRaises(AttributeError):
+ class T(Array):
+ pass
+ with self.assertRaises(AttributeError):
+ class T(Array):
+ _type_ = c_int
+ with self.assertRaises(AttributeError):
+ class T(Array):
+ _length_ = 13
+ with self.assertRaises(OverflowError):
+ class T(Array):
+ _type_ = c_int
+ _length_ = sys.maxsize * 2
+ with self.assertRaises(AttributeError):
+ class T(Array):
+ _type_ = c_int
+ _length_ = 1.87
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_as_parameter.py b/Lib/ctypes/test/test_as_parameter.py
index a603a64714b..2657a66d112 100644
--- a/Lib/ctypes/test/test_as_parameter.py
+++ b/Lib/ctypes/test/test_as_parameter.py
@@ -24,7 +24,7 @@ class BasicWrapTestCase(unittest.TestCase):
return
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
- result = f(self.wrap(1), self.wrap(u"x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
+ result = f(self.wrap(1), self.wrap("x"), self.wrap(3), self.wrap(4), self.wrap(5.0), self.wrap(6.0))
self.assertEqual(result, 139)
self.assertTrue(type(result), int)
@@ -134,7 +134,7 @@ class BasicWrapTestCase(unittest.TestCase):
f.argtypes = [c_longlong, MyCallback]
def callback(value):
- self.assertTrue(isinstance(value, (int, long)))
+ self.assertTrue(isinstance(value, int))
return value & 0x7FFFFFFF
cb = MyCallback(callback)
diff --git a/Lib/ctypes/test/test_bitfields.py b/Lib/ctypes/test/test_bitfields.py
index 3bcc67fb75e..c89ee345ee8 100644
--- a/Lib/ctypes/test/test_bitfields.py
+++ b/Lib/ctypes/test/test_bitfields.py
@@ -37,14 +37,14 @@ class C_Test(unittest.TestCase):
for name in "ABCDEFGHI":
b = BITS()
setattr(b, name, i)
- self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii')))
def test_shorts(self):
for i in range(256):
for name in "MNOPQRS":
b = BITS()
setattr(b, name, i)
- self.assertEqual((name, i, getattr(b, name)), (name, i, func(byref(b), name)))
+ self.assertEqual(getattr(b, name), func(byref(b), name.encode('ascii')))
signed_int_types = (c_byte, c_short, c_int, c_long, c_longlong)
unsigned_int_types = (c_ubyte, c_ushort, c_uint, c_ulong, c_ulonglong)
@@ -191,7 +191,7 @@ class BitFieldTest(unittest.TestCase):
def get_except(self, func, *args, **kw):
try:
func(*args, **kw)
- except Exception, detail:
+ except Exception as detail:
return detail.__class__, str(detail)
def test_mixed_1(self):
diff --git a/Lib/ctypes/test/test_buffers.py b/Lib/ctypes/test/test_buffers.py
index 12945ed9807..2dc74841c49 100644
--- a/Lib/ctypes/test/test_buffers.py
+++ b/Lib/ctypes/test/test_buffers.py
@@ -7,35 +7,23 @@ class StringBufferTestCase(unittest.TestCase):
b = create_string_buffer(32)
self.assertEqual(len(b), 32)
self.assertEqual(sizeof(b), 32 * sizeof(c_char))
- self.assertTrue(type(b[0]) is str)
+ self.assertTrue(type(b[0]) is bytes)
- b = create_string_buffer("abc")
+ b = create_string_buffer(b"abc")
self.assertEqual(len(b), 4) # trailing nul char
self.assertEqual(sizeof(b), 4 * sizeof(c_char))
- self.assertTrue(type(b[0]) is str)
- self.assertEqual(b[0], "a")
- self.assertEqual(b[:], "abc\0")
- self.assertEqual(b[::], "abc\0")
- self.assertEqual(b[::-1], "\0cba")
- self.assertEqual(b[::2], "ac")
- self.assertEqual(b[::5], "a")
+ self.assertTrue(type(b[0]) is bytes)
+ self.assertEqual(b[0], b"a")
+ self.assertEqual(b[:], b"abc\0")
+ self.assertEqual(b[::], b"abc\0")
+ self.assertEqual(b[::-1], b"\0cba")
+ self.assertEqual(b[::2], b"ac")
+ self.assertEqual(b[::5], b"a")
def test_buffer_interface(self):
self.assertEqual(len(bytearray(create_string_buffer(0))), 0)
self.assertEqual(len(bytearray(create_string_buffer(1))), 1)
- def test_string_conversion(self):
- b = create_string_buffer(u"abc")
- self.assertEqual(len(b), 4) # trailing nul char
- self.assertEqual(sizeof(b), 4 * sizeof(c_char))
- self.assertTrue(type(b[0]) is str)
- self.assertEqual(b[0], "a")
- self.assertEqual(b[:], "abc\0")
- self.assertEqual(b[::], "abc\0")
- self.assertEqual(b[::-1], "\0cba")
- self.assertEqual(b[::2], "ac")
- self.assertEqual(b[::5], "a")
-
try:
c_wchar
except NameError:
@@ -45,13 +33,13 @@ class StringBufferTestCase(unittest.TestCase):
b = create_unicode_buffer(32)
self.assertEqual(len(b), 32)
self.assertEqual(sizeof(b), 32 * sizeof(c_wchar))
- self.assertTrue(type(b[0]) is unicode)
+ self.assertTrue(type(b[0]) is str)
- b = create_unicode_buffer(u"abc")
+ b = create_unicode_buffer("abc")
self.assertEqual(len(b), 4) # trailing nul char
self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.assertTrue(type(b[0]) is unicode)
- self.assertEqual(b[0], u"a")
+ self.assertTrue(type(b[0]) is str)
+ self.assertEqual(b[0], "a")
self.assertEqual(b[:], "abc\0")
self.assertEqual(b[::], "abc\0")
self.assertEqual(b[::-1], "\0cba")
@@ -62,8 +50,8 @@ class StringBufferTestCase(unittest.TestCase):
b = create_unicode_buffer("abc")
self.assertEqual(len(b), 4) # trailing nul char
self.assertEqual(sizeof(b), 4 * sizeof(c_wchar))
- self.assertTrue(type(b[0]) is unicode)
- self.assertEqual(b[0], u"a")
+ self.assertTrue(type(b[0]) is str)
+ self.assertEqual(b[0], "a")
self.assertEqual(b[:], "abc\0")
self.assertEqual(b[::], "abc\0")
self.assertEqual(b[::-1], "\0cba")
diff --git a/Lib/ctypes/test/test_bytes.py b/Lib/ctypes/test/test_bytes.py
new file mode 100644
index 00000000000..ee49c456e8e
--- /dev/null
+++ b/Lib/ctypes/test/test_bytes.py
@@ -0,0 +1,50 @@
+"""Test where byte objects are accepted"""
+import unittest
+import sys
+from ctypes import *
+
+class BytesTest(unittest.TestCase):
+ def test_c_char(self):
+ x = c_char(b"x")
+ x.value = b"y"
+ c_char.from_param(b"x")
+ (c_char * 3)(b"a", b"b", b"c")
+
+ def test_c_wchar(self):
+ x = c_wchar("x")
+ x.value = "y"
+ c_wchar.from_param("x")
+ (c_wchar * 3)("a", "b", "c")
+
+ def test_c_char_p(self):
+ c_char_p(b"foo bar")
+
+ def test_c_wchar_p(self):
+ c_wchar_p("foo bar")
+
+ def test_struct(self):
+ class X(Structure):
+ _fields_ = [("a", c_char * 3)]
+
+ x = X(b"abc")
+ self.assertEqual(x.a, b"abc")
+ self.assertEqual(type(x.a), bytes)
+
+ def test_struct_W(self):
+ class X(Structure):
+ _fields_ = [("a", c_wchar * 3)]
+
+ x = X("abc")
+ self.assertEqual(x.a, "abc")
+ self.assertEqual(type(x.a), str)
+
+ if sys.platform == "win32":
+ def test_BSTR(self):
+ from _ctypes import _SimpleCData
+ class BSTR(_SimpleCData):
+ _type_ = "X"
+
+ BSTR("abc")
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/ctypes/test/test_byteswap.py b/Lib/ctypes/test/test_byteswap.py
index 4bd75cd3193..0d2974fdd96 100644
--- a/Lib/ctypes/test/test_byteswap.py
+++ b/Lib/ctypes/test/test_byteswap.py
@@ -4,7 +4,7 @@ from binascii import hexlify
from ctypes import *
def bin(s):
- return hexlify(memoryview(s)).upper()
+ return hexlify(memoryview(s)).decode().upper()
# Each *simple* type that supports different byte orders has an
# __ctype_be__ attribute that specifies the same type in BIG ENDIAN
@@ -15,7 +15,7 @@ def bin(s):
class Test(unittest.TestCase):
def X_test(self):
- print >> sys.stderr, sys.byteorder
+ print(sys.byteorder, file=sys.stderr)
for i in range(32):
bits = BITS()
setattr(bits, "i%s" % i, 1)
@@ -114,12 +114,12 @@ class Test(unittest.TestCase):
s = c_float(math.pi)
self.assertEqual(bin(struct.pack("f", math.pi)), bin(s))
# Hm, what's the precision of a float compared to a double?
- self.assertAlmostEqual(s.value, math.pi, 6)
+ self.assertAlmostEqual(s.value, math.pi, places=6)
s = c_float.__ctype_le__(math.pi)
- self.assertAlmostEqual(s.value, math.pi, 6)
+ self.assertAlmostEqual(s.value, math.pi, places=6)
self.assertEqual(bin(struct.pack("<f", math.pi)), bin(s))
s = c_float.__ctype_be__(math.pi)
- self.assertAlmostEqual(s.value, math.pi, 6)
+ self.assertAlmostEqual(s.value, math.pi, places=6)
self.assertEqual(bin(struct.pack(">f", math.pi)), bin(s))
def test_endian_double(self):
diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
index be0c17e93c8..c7207eab9d2 100644
--- a/Lib/ctypes/test/test_callbacks.py
+++ b/Lib/ctypes/test/test_callbacks.py
@@ -14,7 +14,7 @@ class Callbacks(unittest.TestCase):
return args[-1]
def check_type(self, typ, arg):
- PROTO = self.functype.im_func(typ, typ)
+ PROTO = self.functype.__func__(typ, typ)
result = PROTO(self.callback)(arg)
if typ == c_float:
self.assertAlmostEqual(result, arg, places=5)
@@ -22,7 +22,7 @@ class Callbacks(unittest.TestCase):
self.assertEqual(self.got_args, (arg,))
self.assertEqual(result, arg)
- PROTO = self.functype.im_func(typ, c_byte, typ)
+ PROTO = self.functype.__func__(typ, c_byte, typ)
result = PROTO(self.callback)(-3, arg)
if typ == c_float:
self.assertAlmostEqual(result, arg, places=5)
@@ -61,16 +61,10 @@ class Callbacks(unittest.TestCase):
self.check_type(c_ulong, 42)
def test_longlong(self):
- # test some 64-bit values, positive and negative
- self.check_type(c_longlong, 5948291757245277467)
- self.check_type(c_longlong, -5229388909784190580)
self.check_type(c_longlong, 42)
self.check_type(c_longlong, -42)
def test_ulonglong(self):
- # test some 64-bit values, with and without msb set.
- self.check_type(c_ulonglong, 10955412242170339782)
- self.check_type(c_ulonglong, 3665885499841167458)
self.check_type(c_ulonglong, 42)
def test_float(self):
@@ -88,8 +82,8 @@ class Callbacks(unittest.TestCase):
self.check_type(c_longdouble, -3.14)
def test_char(self):
- self.check_type(c_char, "x")
- self.check_type(c_char, "a")
+ self.check_type(c_char, b"x")
+ self.check_type(c_char, b"a")
# disabled: would now (correctly) raise a RuntimeWarning about
# a memory leak. A callback function cannot return a non-integral
@@ -116,16 +110,16 @@ class Callbacks(unittest.TestCase):
# functions, the type must have a non-NULL stgdict->setfunc.
# POINTER(c_double), for example, is not supported.
- prototype = self.functype.im_func(POINTER(c_double))
+ prototype = self.functype.__func__(POINTER(c_double))
# The type is checked when the prototype is called
self.assertRaises(TypeError, prototype, lambda: None)
def test_unsupported_restype_2(self):
- prototype = self.functype.im_func(object)
+ prototype = self.functype.__func__(object)
self.assertRaises(TypeError, prototype, lambda: None)
def test_issue_7959(self):
- proto = self.functype.im_func(None)
+ proto = self.functype.__func__(None)
class X(object):
def func(self): pass
@@ -146,7 +140,7 @@ class Callbacks(unittest.TestCase):
def __del__(self):
gc.collect()
CFUNCTYPE(None)(lambda x=Nasty(): None)
-
+
try:
WINFUNCTYPE
diff --git a/Lib/ctypes/test/test_cast.py b/Lib/ctypes/test/test_cast.py
index 906fffc9061..702de3cffa7 100644
--- a/Lib/ctypes/test/test_cast.py
+++ b/Lib/ctypes/test/test_cast.py
@@ -33,18 +33,18 @@ class Test(unittest.TestCase):
def test_p2a_objects(self):
array = (c_char_p * 5)()
self.assertEqual(array._objects, None)
- array[0] = "foo bar"
- self.assertEqual(array._objects, {'0': "foo bar"})
+ array[0] = b"foo bar"
+ self.assertEqual(array._objects, {'0': b"foo bar"})
p = cast(array, POINTER(c_char_p))
# array and p share a common _objects attribute
self.assertTrue(p._objects is array._objects)
- self.assertEqual(array._objects, {'0': "foo bar", id(array): array})
- p[0] = "spam spam"
- self.assertEqual(p._objects, {'0': "spam spam", id(array): array})
+ self.assertEqual(array._objects, {'0': b"foo bar", id(array): array})
+ p[0] = b"spam spam"
+ self.assertEqual(p._objects, {'0': b"spam spam", id(array): array})
self.assertTrue(array._objects is p._objects)
- p[1] = "foo bar"
- self.assertEqual(p._objects, {'1': 'foo bar', '0': "spam spam", id(array): array})
+ p[1] = b"foo bar"
+ self.assertEqual(p._objects, {'1': b'foo bar', '0': b"spam spam", id(array): array})
self.assertTrue(array._objects is p._objects)
def test_other(self):
@@ -71,9 +71,9 @@ class Test(unittest.TestCase):
def test_char_p(self):
# This didn't work: bad argument to internal function
- s = c_char_p("hiho")
+ s = c_char_p(b"hiho")
self.assertEqual(cast(cast(s, c_void_p), c_char_p).value,
- "hiho")
+ b"hiho")
try:
c_wchar_p
diff --git a/Lib/ctypes/test/test_cfuncs.py b/Lib/ctypes/test/test_cfuncs.py
index 493cbe979ce..f4bd3b16c37 100644
--- a/Lib/ctypes/test/test_cfuncs.py
+++ b/Lib/ctypes/test/test_cfuncs.py
@@ -107,7 +107,7 @@ class CFunctions(unittest.TestCase):
def test_ulong_plus(self):
self._dll.tf_bL.restype = c_ulong
self._dll.tf_bL.argtypes = (c_char, c_ulong)
- self.assertEqual(self._dll.tf_bL(' ', 4294967295), 1431655765)
+ self.assertEqual(self._dll.tf_bL(b' ', 4294967295), 1431655765)
self.assertEqual(self.U(), 4294967295)
def test_longlong(self):
diff --git a/Lib/ctypes/test/test_errno.py b/Lib/ctypes/test/test_errno.py
index c7a5bf0d4fa..4690a0d8717 100644
--- a/Lib/ctypes/test/test_errno.py
+++ b/Lib/ctypes/test/test_errno.py
@@ -1,7 +1,6 @@
import unittest, os, errno
from ctypes import *
from ctypes.util import find_library
-from test import test_support
try:
import threading
except ImportError:
@@ -20,7 +19,7 @@ class Test(unittest.TestCase):
libc_open.argtypes = c_char_p, c_int
- self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(libc_open(b"", 0), -1)
self.assertEqual(get_errno(), errno.ENOENT)
self.assertEqual(set_errno(32), errno.ENOENT)
@@ -36,7 +35,7 @@ class Test(unittest.TestCase):
else:
libc_open = libc.open
libc_open.argtypes = c_char_p, c_int
- self.assertEqual(libc_open("", 0), -1)
+ self.assertEqual(libc_open(b"", 0), -1)
self.assertEqual(get_errno(), 0)
t = threading.Thread(target=_worker)
diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
index 77e789fd173..c54b69bbc3f 100644
--- a/Lib/ctypes/test/test_find.py
+++ b/Lib/ctypes/test/test_find.py
@@ -19,11 +19,11 @@ else:
## print, for debugging
if is_resource_enabled("printing"):
if lib_gl or lib_glu or lib_gle:
- print "OpenGL libraries:"
+ print("OpenGL libraries:")
for item in (("GL", lib_gl),
("GLU", lib_glu),
("gle", lib_gle)):
- print "\t", item
+ print("\t", item)
# On some systems, loading the OpenGL libraries needs the RTLD_GLOBAL mode.
diff --git a/Lib/ctypes/test/test_frombuffer.py b/Lib/ctypes/test/test_frombuffer.py
index 624fb70be76..92d61580dd1 100644
--- a/Lib/ctypes/test/test_frombuffer.py
+++ b/Lib/ctypes/test/test_frombuffer.py
@@ -51,10 +51,10 @@ class Test(unittest.TestCase):
self.assertEqual(y.c_int, a[0])
self.assertFalse(y.init_called)
- self.assertEqual(x[:], range(16))
+ self.assertEqual(x[:], list(range(16)))
a[0], a[-1] = 200, -200
- self.assertEqual(x[:], range(16))
+ self.assertEqual(x[:], list(range(16)))
self.assertEqual(x._objects, None)
@@ -62,10 +62,10 @@ class Test(unittest.TestCase):
c_int.from_buffer, a, -1)
del a; gc.collect(); gc.collect(); gc.collect()
- self.assertEqual(x[:], range(16))
+ self.assertEqual(x[:], list(range(16)))
- x = (c_char * 16).from_buffer_copy("a" * 16)
- self.assertEqual(x[:], "a" * 16)
+ x = (c_char * 16).from_buffer_copy(b"a" * 16)
+ self.assertEqual(x[:], b"a" * 16)
def test_fom_buffer_copy_with_offset(self):
a = array.array("i", range(16))
diff --git a/Lib/ctypes/test/test_funcptr.py b/Lib/ctypes/test/test_funcptr.py
index 99af5ed68e5..13bf4088bf2 100644
--- a/Lib/ctypes/test/test_funcptr.py
+++ b/Lib/ctypes/test/test_funcptr.py
@@ -97,8 +97,8 @@ class CFuncPtrTestCase(unittest.TestCase):
strchr = lib.my_strchr
strchr.restype = c_char_p
strchr.argtypes = (c_char_p, c_char)
- self.assertEqual(strchr("abcdefghi", "b"), "bcdefghi")
- self.assertEqual(strchr("abcdefghi", "x"), None)
+ self.assertEqual(strchr(b"abcdefghi", b"b"), b"bcdefghi")
+ self.assertEqual(strchr(b"abcdefghi", b"x"), None)
strtok = lib.my_strtok
@@ -111,17 +111,17 @@ class CFuncPtrTestCase(unittest.TestCase):
size = len(init) + 1
return (c_char*size)(*init)
- s = "a\nb\nc"
+ s = b"a\nb\nc"
b = c_string(s)
## b = (c_char * (len(s)+1))()
## b.value = s
## b = c_string(s)
- self.assertEqual(strtok(b, "\n"), "a")
- self.assertEqual(strtok(None, "\n"), "b")
- self.assertEqual(strtok(None, "\n"), "c")
- self.assertEqual(strtok(None, "\n"), None)
+ self.assertEqual(strtok(b, b"\n"), b"a")
+ self.assertEqual(strtok(None, b"\n"), b"b")
+ self.assertEqual(strtok(None, b"\n"), b"c")
+ self.assertEqual(strtok(None, b"\n"), None)
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_functions.py b/Lib/ctypes/test/test_functions.py
index 8e898a8d2e3..45d74ec9e82 100644
--- a/Lib/ctypes/test/test_functions.py
+++ b/Lib/ctypes/test/test_functions.py
@@ -70,7 +70,7 @@ class FunctionTestCase(unittest.TestCase):
return
f = dll._testfunc_i_bhilfd
f.argtypes = [c_byte, c_wchar, c_int, c_long, c_float, c_double]
- result = f(1, u"x", 3, 4, 5.0, 6.0)
+ result = f(1, "x", 3, 4, 5.0, 6.0)
self.assertEqual(result, 139)
self.assertEqual(type(result), int)
@@ -83,7 +83,7 @@ class FunctionTestCase(unittest.TestCase):
f.argtypes = [c_byte, c_short, c_int, c_long, c_float, c_double]
f.restype = c_wchar
result = f(0, 0, 0, 0, 0, 0)
- self.assertEqual(result, u'\x00')
+ self.assertEqual(result, '\x00')
def test_voidresult(self):
f = dll._testfunc_v
@@ -176,8 +176,8 @@ class FunctionTestCase(unittest.TestCase):
f = dll._testfunc_p_p
f.argtypes = None
f.restype = c_char_p
- result = f("123")
- self.assertEqual(result, "123")
+ result = f(b"123")
+ self.assertEqual(result, b"123")
result = f(None)
self.assertEqual(result, None)
@@ -306,7 +306,7 @@ class FunctionTestCase(unittest.TestCase):
f.argtypes = [c_longlong, MyCallback]
def callback(value):
- self.assertTrue(isinstance(value, (int, long)))
+ self.assertTrue(isinstance(value, int))
return value & 0x7FFFFFFF
cb = MyCallback(callback)
diff --git a/Lib/ctypes/test/test_incomplete.py b/Lib/ctypes/test/test_incomplete.py
index 1e03e9fcd50..00c430ef53c 100644
--- a/Lib/ctypes/test/test_incomplete.py
+++ b/Lib/ctypes/test/test_incomplete.py
@@ -17,9 +17,9 @@ class MyTestCase(unittest.TestCase):
SetPointerType(lpcell, cell)
c1 = cell()
- c1.name = "foo"
+ c1.name = b"foo"
c2 = cell()
- c2.name = "bar"
+ c2.name = b"bar"
c1.next = pointer(c2)
c2.next = pointer(c1)
@@ -30,7 +30,7 @@ class MyTestCase(unittest.TestCase):
for i in range(8):
result.append(p.name)
p = p.next[0]
- self.assertEqual(result, ["foo", "bar"] * 4)
+ self.assertEqual(result, [b"foo", b"bar"] * 4)
# to not leak references, we must clean _pointer_type_cache
from ctypes import _pointer_type_cache
diff --git a/Lib/ctypes/test/test_init.py b/Lib/ctypes/test/test_init.py
index 82bd1f998c8..75fad112a01 100644
--- a/Lib/ctypes/test/test_init.py
+++ b/Lib/ctypes/test/test_init.py
@@ -7,7 +7,7 @@ class X(Structure):
new_was_called = False
def __new__(cls):
- result = super(X, cls).__new__(cls)
+ result = super().__new__(cls)
result.new_was_called = True
return result
diff --git a/Lib/ctypes/test/test_internals.py b/Lib/ctypes/test/test_internals.py
index 2e5b1fed45c..cbf2e0589a2 100644
--- a/Lib/ctypes/test/test_internals.py
+++ b/Lib/ctypes/test/test_internals.py
@@ -29,7 +29,7 @@ class ObjectsTestCase(unittest.TestCase):
self.assertEqual(ci._objects, None)
def test_c_char_p(self):
- s = "Hello, World"
+ s = b"Hello, World"
refcnt = grc(s)
cs = c_char_p(s)
self.assertEqual(refcnt + 1, grc(s))
@@ -70,8 +70,8 @@ class ObjectsTestCase(unittest.TestCase):
class Y(Structure):
_fields_ = [("x", X), ("y", X)]
- s1 = "Hello, World"
- s2 = "Hallo, Welt"
+ s1 = b"Hello, World"
+ s2 = b"Hallo, Welt"
x = X()
x.a = s1
diff --git a/Lib/ctypes/test/test_keeprefs.py b/Lib/ctypes/test/test_keeprefs.py
index b504c0c09b1..db8adfb4cac 100644
--- a/Lib/ctypes/test/test_keeprefs.py
+++ b/Lib/ctypes/test/test_keeprefs.py
@@ -13,10 +13,10 @@ class SimpleTestCase(unittest.TestCase):
def test_ccharp(self):
x = c_char_p()
self.assertEqual(x._objects, None)
- x.value = "abc"
- self.assertEqual(x._objects, "abc")
- x = c_char_p("spam")
- self.assertEqual(x._objects, "spam")
+ x.value = b"abc"
+ self.assertEqual(x._objects, b"abc")
+ x = c_char_p(b"spam")
+ self.assertEqual(x._objects, b"spam")
class StructureTestCase(unittest.TestCase):
def test_cint_struct(self):
@@ -37,9 +37,9 @@ class StructureTestCase(unittest.TestCase):
x = X()
self.assertEqual(x._objects, None)
- x.a = "spam"
- x.b = "foo"
- self.assertEqual(x._objects, {"0": "spam", "1": "foo"})
+ x.a = b"spam"
+ x.b = b"foo"
+ self.assertEqual(x._objects, {"0": b"spam", "1": b"foo"})
def test_struct_struct(self):
class POINT(Structure):
@@ -100,13 +100,13 @@ class DeletePointerTestCase(unittest.TestCase):
x = X()
i = c_char_p("abc def")
from sys import getrefcount as grc
- print "2?", grc(i)
+ print("2?", grc(i))
x.p = pointer(i)
- print "3?", grc(i)
+ print("3?", grc(i))
for i in range(320):
c_int(99)
x.p[0]
- print x.p[0]
+ print(x.p[0])
## del x
## print "2?", grc(i)
## del i
@@ -115,14 +115,14 @@ class DeletePointerTestCase(unittest.TestCase):
for i in range(320):
c_int(99)
x.p[0]
- print x.p[0]
- print x.p.contents
+ print(x.p[0])
+ print(x.p.contents)
## print x._objects
x.p[0] = "spam spam"
## print x.p[0]
- print "+" * 42
- print x._objects
+ print("+" * 42)
+ print(x._objects)
class PointerToStructure(unittest.TestCase):
def test(self):
diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
index 3dc463fcb6a..56285b5ff81 100644
--- a/Lib/ctypes/test/test_libc.py
+++ b/Lib/ctypes/test/test_libc.py
@@ -5,6 +5,10 @@ import _ctypes_test
lib = CDLL(_ctypes_test.__file__)
+def three_way_cmp(x, y):
+ """Return -1 if x < y, 0 if x == y and 1 if x > y"""
+ return (x > y) - (x < y)
+
class LibTest(unittest.TestCase):
def test_sqrt(self):
lib.my_sqrt.argtypes = c_double,
@@ -19,11 +23,11 @@ class LibTest(unittest.TestCase):
lib.my_qsort.restype = None
def sort(a, b):
- return cmp(a[0], b[0])
+ return three_way_cmp(a[0], b[0])
- chars = create_string_buffer("spam, spam, and spam")
+ chars = create_string_buffer(b"spam, spam, and spam")
lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort))
- self.assertEqual(chars.raw, " ,,aaaadmmmnpppsss\x00")
+ self.assertEqual(chars.raw, b" ,,aaaadmmmnpppsss\x00")
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_loading.py b/Lib/ctypes/test/test_loading.py
index 26683d829ea..4029b463bcd 100644
--- a/Lib/ctypes/test/test_loading.py
+++ b/Lib/ctypes/test/test_loading.py
@@ -15,7 +15,7 @@ else:
libc_name = find_library("c")
if is_resource_enabled("printing"):
- print "libc_name is", libc_name
+ print("libc_name is", libc_name)
class LoaderTest(unittest.TestCase):
@@ -45,8 +45,8 @@ class LoaderTest(unittest.TestCase):
def test_load_library(self):
self.assertFalse(libc_name is None)
if is_resource_enabled("printing"):
- print find_library("kernel32")
- print find_library("user32")
+ print(find_library("kernel32"))
+ print(find_library("user32"))
if os.name == "nt":
windll.kernel32.GetModuleHandleW
@@ -97,7 +97,7 @@ class LoaderTest(unittest.TestCase):
self.assertEqual(0, advapi32.CloseEventLog(None))
windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p
windll.kernel32.GetProcAddress.restype = c_void_p
- proc = windll.kernel32.GetProcAddress(advapi32._handle, "CloseEventLog")
+ proc = windll.kernel32.GetProcAddress(advapi32._handle, b"CloseEventLog")
self.assertTrue(proc)
# This is the real test: call the function via 'call_function'
self.assertEqual(0, call_function(proc, (None,)))
diff --git a/Lib/ctypes/test/test_memfunctions.py b/Lib/ctypes/test/test_memfunctions.py
index d0726032856..aa2113b885f 100644
--- a/Lib/ctypes/test/test_memfunctions.py
+++ b/Lib/ctypes/test/test_memfunctions.py
@@ -17,27 +17,27 @@ class MemFunctionsTest(unittest.TestCase):
# large buffers apparently increase the chance that the memory
# is allocated in high address space.
a = create_string_buffer(1000000)
- p = "Hello, World"
+ p = b"Hello, World"
result = memmove(a, p, len(p))
- self.assertEqual(a.value, "Hello, World")
+ self.assertEqual(a.value, b"Hello, World")
- self.assertEqual(string_at(result), "Hello, World")
- self.assertEqual(string_at(result, 5), "Hello")
- self.assertEqual(string_at(result, 16), "Hello, World\0\0\0\0")
- self.assertEqual(string_at(result, 0), "")
+ self.assertEqual(string_at(result), b"Hello, World")
+ self.assertEqual(string_at(result, 5), b"Hello")
+ self.assertEqual(string_at(result, 16), b"Hello, World\0\0\0\0")
+ self.assertEqual(string_at(result, 0), b"")
def test_memset(self):
a = create_string_buffer(1000000)
result = memset(a, ord('x'), 16)
- self.assertEqual(a.value, "xxxxxxxxxxxxxxxx")
+ self.assertEqual(a.value, b"xxxxxxxxxxxxxxxx")
- self.assertEqual(string_at(result), "xxxxxxxxxxxxxxxx")
- self.assertEqual(string_at(a), "xxxxxxxxxxxxxxxx")
- self.assertEqual(string_at(a, 20), "xxxxxxxxxxxxxxxx\0\0\0\0")
+ self.assertEqual(string_at(result), b"xxxxxxxxxxxxxxxx")
+ self.assertEqual(string_at(a), b"xxxxxxxxxxxxxxxx")
+ self.assertEqual(string_at(a, 20), b"xxxxxxxxxxxxxxxx\0\0\0\0")
def test_cast(self):
a = (c_ubyte * 32)(*map(ord, "abcdef"))
- self.assertEqual(cast(a, c_char_p).value, "abcdef")
+ self.assertEqual(cast(a, c_char_p).value, b"abcdef")
self.assertEqual(cast(a, POINTER(c_byte))[:7],
[97, 98, 99, 100, 101, 102, 0])
self.assertEqual(cast(a, POINTER(c_byte))[:7:],
@@ -50,14 +50,14 @@ class MemFunctionsTest(unittest.TestCase):
[97])
def test_string_at(self):
- s = string_at("foo bar")
+ s = string_at(b"foo bar")
# XXX The following may be wrong, depending on how Python
# manages string instances
self.assertEqual(2, sys.getrefcount(s))
self.assertTrue(s, "foo bar")
- self.assertEqual(string_at("foo bar", 8), "foo bar\0")
- self.assertEqual(string_at("foo bar", 3), "foo")
+ self.assertEqual(string_at(b"foo bar", 7), b"foo bar")
+ self.assertEqual(string_at(b"foo bar", 3), b"foo")
try:
create_unicode_buffer
diff --git a/Lib/ctypes/test/test_numbers.py b/Lib/ctypes/test/test_numbers.py
index 79239068306..8753a07c540 100644
--- a/Lib/ctypes/test/test_numbers.py
+++ b/Lib/ctypes/test/test_numbers.py
@@ -12,10 +12,10 @@ def valid_ranges(*types):
for t in types:
fmt = t._type_
size = struct.calcsize(fmt)
- a = struct.unpack(fmt, ("\x00"*32)[:size])[0]
- b = struct.unpack(fmt, ("\xFF"*32)[:size])[0]
- c = struct.unpack(fmt, ("\x7F"+"\x00"*32)[:size])[0]
- d = struct.unpack(fmt, ("\x80"+"\xFF"*32)[:size])[0]
+ a = struct.unpack(fmt, (b"\x00"*32)[:size])[0]
+ b = struct.unpack(fmt, (b"\xFF"*32)[:size])[0]
+ c = struct.unpack(fmt, (b"\x7F"+b"\x00"*32)[:size])[0]
+ d = struct.unpack(fmt, (b"\x80"+b"\xFF"*32)[:size])[0]
result.append((min(a, b, c, d), max(a, b, c, d)))
return result
@@ -112,7 +112,7 @@ class NumberTestCase(unittest.TestCase):
for t in float_types:
self.assertEqual(t(2.0).value, 2.0)
self.assertEqual(t(2).value, 2.0)
- self.assertEqual(t(2L).value, 2.0)
+ self.assertEqual(t(2).value, 2.0)
self.assertEqual(t(f).value, 2.0)
def test_integers(self):
@@ -190,13 +190,14 @@ class NumberTestCase(unittest.TestCase):
from ctypes import c_char
from array import array
- a = array('c', 'x')
+ a = array('b', [0])
+ a[0] = ord('x')
v = c_char.from_address(a.buffer_info()[0])
- self.assertEqual(v.value, a[0])
+ self.assertEqual(v.value, b'x')
self.assertTrue(type(v) is c_char)
- a[0] = '?'
- self.assertEqual(v.value, a[0])
+ a[0] = ord('?')
+ self.assertEqual(v.value, b'?')
# array does not support c_bool / 't'
# def test_bool_from_address(self):
@@ -248,7 +249,7 @@ def run_test(rep, msg, func, arg=None):
for i in items:
func(); func(); func(); func(); func()
stop = clock()
- print "%15s: %.2f us" % (msg, ((stop-start)*1e6/5/rep))
+ print("%15s: %.2f us" % (msg, ((stop-start)*1e6/5/rep)))
def check_perf():
# Construct 5 objects
diff --git a/Lib/ctypes/test/test_objects.py b/Lib/ctypes/test/test_objects.py
index 4d921d2e589..f075c208939 100644
--- a/Lib/ctypes/test/test_objects.py
+++ b/Lib/ctypes/test/test_objects.py
@@ -13,18 +13,18 @@ Here is an array of string pointers:
>>> from ctypes import *
>>> array = (c_char_p * 5)()
->>> print array._objects
+>>> print(array._objects)
None
>>>
The memory block stores pointers to strings, and the strings itself
assigned from Python must be kept.
->>> array[4] = 'foo bar'
+>>> array[4] = b'foo bar'
>>> array._objects
-{'4': 'foo bar'}
+{'4': b'foo bar'}
>>> array[4]
-'foo bar'
+b'foo bar'
>>>
It gets more complicated when the ctypes instance itself is contained
@@ -34,22 +34,22 @@ in a 'base' object.
... _fields_ = [("x", c_int), ("y", c_int), ("array", c_char_p * 5)]
...
>>> x = X()
->>> print x._objects
+>>> print(x._objects)
None
>>>
The'array' attribute of the 'x' object shares part of the memory buffer
of 'x' ('_b_base_' is either None, or the root object owning the memory block):
->>> print x.array._b_base_ # doctest: +ELLIPSIS
+>>> print(x.array._b_base_) # doctest: +ELLIPSIS
<ctypes.test.test_objects.X object at 0x...>
>>>
->>> x.array[0] = 'spam spam spam'
+>>> x.array[0] = b'spam spam spam'
>>> x._objects
-{'0:2': 'spam spam spam'}
+{'0:2': b'spam spam spam'}
>>> x.array._b_base_._objects
-{'0:2': 'spam spam spam'}
+{'0:2': b'spam spam spam'}
>>>
'''
diff --git a/Lib/ctypes/test/test_parameters.py b/Lib/ctypes/test/test_parameters.py
index 82704d5f3a9..e83fd9a6fc4 100644
--- a/Lib/ctypes/test/test_parameters.py
+++ b/Lib/ctypes/test/test_parameters.py
@@ -19,7 +19,6 @@ class SimpleTypesTestCase(unittest.TestCase):
else:
set_conversion_mode(*self.prev_conv_mode)
-
def test_subclasses(self):
from ctypes import c_void_p, c_char_p
# ctypes 0.9.5 and before did overwrite from_param in SimpleType_new
@@ -54,18 +53,17 @@ class SimpleTypesTestCase(unittest.TestCase):
# c_char_p.from_param on a Python String packs the string
# into a cparam object
- s = "123"
+ s = b"123"
self.assertTrue(c_char_p.from_param(s)._obj is s)
# new in 0.9.1: convert (encode) unicode to ascii
- self.assertEqual(c_char_p.from_param(u"123")._obj, "123")
- self.assertRaises(UnicodeEncodeError, c_char_p.from_param, u"123\377")
-
+ self.assertEqual(c_char_p.from_param(b"123")._obj, b"123")
+ self.assertRaises(TypeError, c_char_p.from_param, "123\377")
self.assertRaises(TypeError, c_char_p.from_param, 42)
# calling c_char_p.from_param with a c_char_p instance
# returns the argument itself:
- a = c_char_p("123")
+ a = c_char_p(b"123")
self.assertTrue(c_char_p.from_param(a) is a)
def test_cw_strings(self):
@@ -75,16 +73,16 @@ class SimpleTypesTestCase(unittest.TestCase):
except ImportError:
## print "(No c_wchar_p)"
return
- s = u"123"
+ s = "123"
if sys.platform == "win32":
self.assertTrue(c_wchar_p.from_param(s)._obj is s)
self.assertRaises(TypeError, c_wchar_p.from_param, 42)
# new in 0.9.1: convert (decode) ascii to unicode
- self.assertEqual(c_wchar_p.from_param("123")._obj, u"123")
- self.assertRaises(UnicodeDecodeError, c_wchar_p.from_param, "123\377")
+ self.assertEqual(c_wchar_p.from_param("123")._obj, "123")
+ self.assertRaises(TypeError, c_wchar_p.from_param, b"123\377")
- pa = c_wchar_p.from_param(c_wchar_p(u"123"))
+ pa = c_wchar_p.from_param(c_wchar_p("123"))
self.assertEqual(type(pa), c_wchar_p)
def test_int_pointers(self):
diff --git a/Lib/ctypes/test/test_pep3118.py b/Lib/ctypes/test/test_pep3118.py
index 976473c46fe..fa6461f5460 100644
--- a/Lib/ctypes/test/test_pep3118.py
+++ b/Lib/ctypes/test/test_pep3118.py
@@ -1,6 +1,6 @@
import unittest
from ctypes import *
-import re, sys
+import re, struct, sys
if sys.byteorder == "little":
THIS_ENDIAN = "<"
diff --git a/Lib/ctypes/test/test_pickling.py b/Lib/ctypes/test/test_pickling.py
index 136cbe928e5..8c912226944 100644
--- a/Lib/ctypes/test/test_pickling.py
+++ b/Lib/ctypes/test/test_pickling.py
@@ -67,9 +67,9 @@ class PickleTest(unittest.TestCase):
self.assertRaises(ValueError, lambda: self.dumps(item))
def test_wchar(self):
- pickle.dumps(c_char("x"))
+ pickle.dumps(c_char(b"x"))
# Issue 5049
- pickle.dumps(c_wchar(u"x"))
+ pickle.dumps(c_wchar("x"))
class PickleTest_1(PickleTest):
def dumps(self, item):
diff --git a/Lib/ctypes/test/test_pointers.py b/Lib/ctypes/test/test_pointers.py
index 92b8ce60db9..d29317a3e4a 100644
--- a/Lib/ctypes/test/test_pointers.py
+++ b/Lib/ctypes/test/test_pointers.py
@@ -5,8 +5,8 @@ import _ctypes_test
ctype_types = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint,
c_long, c_ulong, c_longlong, c_ulonglong, c_double, c_float]
-python_types = [int, int, int, int, int, long,
- int, long, long, long, float, float]
+python_types = [int, int, int, int, int, int,
+ int, int, int, int, float, float]
class PointersTestCase(unittest.TestCase):
@@ -140,10 +140,10 @@ class PointersTestCase(unittest.TestCase):
func.restype = c_char_p
argv = (c_char_p * 2)()
argc = c_int( 2 )
- argv[0] = 'hello'
- argv[1] = 'world'
+ argv[0] = b'hello'
+ argv[1] = b'world'
result = func( byref(argc), argv )
- assert result == 'world', result
+ self.assertEqual(result, b'world')
def test_bug_1467852(self):
# http://sourceforge.net/tracker/?func=detail&atid=532154&aid=1467852&group_id=71702
@@ -160,16 +160,16 @@ class PointersTestCase(unittest.TestCase):
def test_c_void_p(self):
# http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=105470
if sizeof(c_void_p) == 4:
- self.assertEqual(c_void_p(0xFFFFFFFFL).value,
+ self.assertEqual(c_void_p(0xFFFFFFFF).value,
c_void_p(-1).value)
- self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
elif sizeof(c_void_p) == 8:
- self.assertEqual(c_void_p(0xFFFFFFFFL).value,
- 0xFFFFFFFFL)
- self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+ self.assertEqual(c_void_p(0xFFFFFFFF).value,
+ 0xFFFFFFFF)
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
- self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFFL).value,
+ self.assertEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFF).value,
c_void_p(-1).value)
self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
diff --git a/Lib/ctypes/test/test_prototypes.py b/Lib/ctypes/test/test_prototypes.py
index 09ba6554a4b..6ef1b1bcaff 100644
--- a/Lib/ctypes/test/test_prototypes.py
+++ b/Lib/ctypes/test/test_prototypes.py
@@ -33,7 +33,7 @@ def positive_address(a):
# View the bits in `a` as unsigned instead.
import struct
num_bits = struct.calcsize("P") * 8 # num bits in native machine address
- a += 1L << num_bits
+ a += 1 << num_bits
assert a >= 0
return a
@@ -57,7 +57,7 @@ class CharPointersTestCase(unittest.TestCase):
try:
func()
- except TypeError, details:
+ except TypeError as details:
self.assertEqual(str(details), "required argument 'input' missing")
else:
self.fail("TypeError not raised")
@@ -92,14 +92,14 @@ class CharPointersTestCase(unittest.TestCase):
func.argtypes = POINTER(c_char),
self.assertEqual(None, func(None))
- self.assertEqual("123", func("123"))
+ self.assertEqual(b"123", func(b"123"))
self.assertEqual(None, func(c_char_p(None)))
- self.assertEqual("123", func(c_char_p("123")))
+ self.assertEqual(b"123", func(c_char_p(b"123")))
- self.assertEqual("123", func(c_buffer("123")))
- ca = c_char("a")
- self.assertEqual("a", func(pointer(ca))[0])
- self.assertEqual("a", func(byref(ca))[0])
+ self.assertEqual(b"123", func(c_buffer(b"123")))
+ ca = c_char(b"a")
+ self.assertEqual(ord(b"a"), func(pointer(ca))[0])
+ self.assertEqual(ord(b"a"), func(byref(ca))[0])
def test_c_char_p_arg(self):
func = testdll._testfunc_p_p
@@ -107,14 +107,14 @@ class CharPointersTestCase(unittest.TestCase):
func.argtypes = c_char_p,
self.assertEqual(None, func(None))
- self.assertEqual("123", func("123"))
+ self.assertEqual(b"123", func(b"123"))
self.assertEqual(None, func(c_char_p(None)))
- self.assertEqual("123", func(c_char_p("123")))
+ self.assertEqual(b"123", func(c_char_p(b"123")))
- self.assertEqual("123", func(c_buffer("123")))
- ca = c_char("a")
- self.assertEqual("a", func(pointer(ca))[0])
- self.assertEqual("a", func(byref(ca))[0])
+ self.assertEqual(b"123", func(c_buffer(b"123")))
+ ca = c_char(b"a")
+ self.assertEqual(ord(b"a"), func(pointer(ca))[0])
+ self.assertEqual(ord(b"a"), func(byref(ca))[0])
def test_c_void_p_arg(self):
func = testdll._testfunc_p_p
@@ -122,14 +122,14 @@ class CharPointersTestCase(unittest.TestCase):
func.argtypes = c_void_p,
self.assertEqual(None, func(None))
- self.assertEqual("123", func("123"))
- self.assertEqual("123", func(c_char_p("123")))
+ self.assertEqual(b"123", func(b"123"))
+ self.assertEqual(b"123", func(c_char_p(b"123")))
self.assertEqual(None, func(c_char_p(None)))
- self.assertEqual("123", func(c_buffer("123")))
- ca = c_char("a")
- self.assertEqual("a", func(pointer(ca))[0])
- self.assertEqual("a", func(byref(ca))[0])
+ self.assertEqual(b"123", func(c_buffer(b"123")))
+ ca = c_char(b"a")
+ self.assertEqual(ord(b"a"), func(pointer(ca))[0])
+ self.assertEqual(ord(b"a"), func(byref(ca))[0])
func(byref(c_int()))
func(pointer(c_int()))
@@ -141,7 +141,7 @@ class CharPointersTestCase(unittest.TestCase):
pass
else:
self.assertEqual(None, func(c_wchar_p(None)))
- self.assertEqual(u"123", func(c_wchar_p(u"123")))
+ self.assertEqual("123", func(c_wchar_p("123")))
def test_instance(self):
func = testdll._testfunc_p_p
@@ -175,24 +175,24 @@ else:
func.argtypes = POINTER(c_wchar),
self.assertEqual(None, func(None))
- self.assertEqual(u"123", func(u"123"))
+ self.assertEqual("123", func("123"))
self.assertEqual(None, func(c_wchar_p(None)))
- self.assertEqual(u"123", func(c_wchar_p(u"123")))
+ self.assertEqual("123", func(c_wchar_p("123")))
- self.assertEqual(u"123", func(c_wbuffer(u"123")))
+ self.assertEqual("123", func(c_wbuffer("123")))
ca = c_wchar("a")
- self.assertEqual(u"a", func(pointer(ca))[0])
- self.assertEqual(u"a", func(byref(ca))[0])
+ self.assertEqual("a", func(pointer(ca))[0])
+ self.assertEqual("a", func(byref(ca))[0])
def test_c_wchar_p_arg(self):
func = testdll._testfunc_p_p
func.restype = c_wchar_p
func.argtypes = c_wchar_p,
- c_wchar_p.from_param(u"123")
+ c_wchar_p.from_param("123")
self.assertEqual(None, func(None))
- self.assertEqual("123", func(u"123"))
+ self.assertEqual("123", func("123"))
self.assertEqual(None, func(c_wchar_p(None)))
self.assertEqual("123", func(c_wchar_p("123")))
diff --git a/Lib/ctypes/test/test_python_api.py b/Lib/ctypes/test/test_python_api.py
index 698170f901d..1f4c6039dcb 100644
--- a/Lib/ctypes/test/test_python_api.py
+++ b/Lib/ctypes/test/test_python_api.py
@@ -17,21 +17,21 @@ else:
class PythonAPITestCase(unittest.TestCase):
- def test_PyString_FromStringAndSize(self):
- PyString_FromStringAndSize = pythonapi.PyString_FromStringAndSize
+ def test_PyBytes_FromStringAndSize(self):
+ PyBytes_FromStringAndSize = pythonapi.PyBytes_FromStringAndSize
- PyString_FromStringAndSize.restype = py_object
- PyString_FromStringAndSize.argtypes = c_char_p, c_py_ssize_t
+ PyBytes_FromStringAndSize.restype = py_object
+ PyBytes_FromStringAndSize.argtypes = c_char_p, c_py_ssize_t
- self.assertEqual(PyString_FromStringAndSize("abcdefghi", 3), "abc")
+ self.assertEqual(PyBytes_FromStringAndSize(b"abcdefghi", 3), b"abc")
def test_PyString_FromString(self):
- pythonapi.PyString_FromString.restype = py_object
- pythonapi.PyString_FromString.argtypes = (c_char_p,)
+ pythonapi.PyBytes_FromString.restype = py_object
+ pythonapi.PyBytes_FromString.argtypes = (c_char_p,)
- s = "abc"
+ s = b"abc"
refcnt = grc(s)
- pyob = pythonapi.PyString_FromString(s)
+ pyob = pythonapi.PyBytes_FromString(s)
self.assertEqual(grc(s), refcnt)
self.assertEqual(s, pyob)
del pyob
@@ -41,17 +41,17 @@ class PythonAPITestCase(unittest.TestCase):
# This test is unreliable, because it is possible that code in
# unittest changes the refcount of the '42' integer. So, it
# is disabled by default.
- def test_PyInt_Long(self):
+ def test_PyLong_Long(self):
ref42 = grc(42)
- pythonapi.PyInt_FromLong.restype = py_object
- self.assertEqual(pythonapi.PyInt_FromLong(42), 42)
+ pythonapi.PyLong_FromLong.restype = py_object
+ self.assertEqual(pythonapi.PyLong_FromLong(42), 42)
self.assertEqual(grc(42), ref42)
- pythonapi.PyInt_AsLong.argtypes = (py_object,)
- pythonapi.PyInt_AsLong.restype = c_long
+ pythonapi.PyLong_AsLong.argtypes = (py_object,)
+ pythonapi.PyLong_AsLong.restype = c_long
- res = pythonapi.PyInt_AsLong(42)
+ res = pythonapi.PyLong_AsLong(42)
self.assertEqual(grc(res), ref42 + 1)
del res
self.assertEqual(grc(42), ref42)
@@ -72,11 +72,11 @@ class PythonAPITestCase(unittest.TestCase):
PyOS_snprintf.argtypes = POINTER(c_char), c_size_t, c_char_p
buf = c_buffer(256)
- PyOS_snprintf(buf, sizeof(buf), "Hello from %s", "ctypes")
- self.assertEqual(buf.value, "Hello from ctypes")
+ PyOS_snprintf(buf, sizeof(buf), b"Hello from %s", b"ctypes")
+ self.assertEqual(buf.value, b"Hello from ctypes")
- PyOS_snprintf(buf, sizeof(buf), "Hello from %s", "ctypes", 1, 2, 3)
- self.assertEqual(buf.value, "Hello from ctypes")
+ PyOS_snprintf(buf, sizeof(buf), b"Hello from %s (%d, %d, %d)", b"ctypes", 1, 2, 3)
+ self.assertEqual(buf.value, b"Hello from ctypes (1, 2, 3)")
# not enough arguments
self.assertRaises(TypeError, PyOS_snprintf, buf)
diff --git a/Lib/ctypes/test/test_random_things.py b/Lib/ctypes/test/test_random_things.py
index 1c217c3ed08..515acf509a6 100644
--- a/Lib/ctypes/test/test_random_things.py
+++ b/Lib/ctypes/test/test_random_things.py
@@ -2,7 +2,7 @@ from ctypes import *
import unittest, sys
def callback_func(arg):
- 42 // arg
+ 42 / arg
raise ValueError(arg)
if sys.platform == "win32":
@@ -17,8 +17,8 @@ if sys.platform == "win32":
windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p
windll.kernel32.GetProcAddress.restype = c_void_p
- hdll = windll.kernel32.LoadLibraryA("kernel32")
- funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA")
+ hdll = windll.kernel32.LoadLibraryA(b"kernel32")
+ funcaddr = windll.kernel32.GetProcAddress(hdll, b"GetModuleHandleA")
self.assertEqual(call_function(funcaddr, (None,)),
windll.kernel32.GetModuleHandleA(None))
@@ -37,9 +37,9 @@ class CallbackTracbackTestCase(unittest.TestCase):
def capture_stderr(self, func, *args, **kw):
# helper - call function 'func', and return the captured stderr
- import StringIO
+ import io
old_stderr = sys.stderr
- logger = sys.stderr = StringIO.StringIO()
+ logger = sys.stderr = io.StringIO()
try:
func(*args, **kw)
finally:
@@ -66,10 +66,10 @@ class CallbackTracbackTestCase(unittest.TestCase):
def test_TypeErrorDivisionError(self):
cb = CFUNCTYPE(c_int, c_char_p)(callback_func)
- out = self.capture_stderr(cb, "spam")
+ out = self.capture_stderr(cb, b"spam")
self.assertEqual(out.splitlines()[-1],
"TypeError: "
- "unsupported operand type(s) for //: 'int' and 'str'")
+ "unsupported operand type(s) for /: 'int' and 'bytes'")
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_repr.py b/Lib/ctypes/test/test_repr.py
index 99cc556417a..60a2c803453 100644
--- a/Lib/ctypes/test/test_repr.py
+++ b/Lib/ctypes/test/test_repr.py
@@ -22,8 +22,8 @@ class ReprTest(unittest.TestCase):
self.assertEqual("<X object at", repr(typ(42))[:12])
def test_char(self):
- self.assertEqual("c_char('x')", repr(c_char('x')))
- self.assertEqual("<X object at", repr(X('x'))[:12])
+ self.assertEqual("c_char(b'x')", repr(c_char(b'x')))
+ self.assertEqual("<X object at", repr(X(b'x'))[:12])
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_returnfuncptrs.py b/Lib/ctypes/test/test_returnfuncptrs.py
index f766189d1eb..af1caddaabf 100644
--- a/Lib/ctypes/test/test_returnfuncptrs.py
+++ b/Lib/ctypes/test/test_returnfuncptrs.py
@@ -12,10 +12,12 @@ class ReturnFuncPtrTestCase(unittest.TestCase):
get_strchr = dll.get_strchr
get_strchr.restype = CFUNCTYPE(c_char_p, c_char_p, c_char)
strchr = get_strchr()
- self.assertEqual(strchr("abcdef", "b"), "bcdef")
- self.assertEqual(strchr("abcdef", "x"), None)
- self.assertRaises(ArgumentError, strchr, "abcdef", 3)
- self.assertRaises(TypeError, strchr, "abcdef")
+ self.assertEqual(strchr(b"abcdef", b"b"), b"bcdef")
+ self.assertEqual(strchr(b"abcdef", b"x"), None)
+ self.assertEqual(strchr(b"abcdef", 98), b"bcdef")
+ self.assertEqual(strchr(b"abcdef", 107), None)
+ self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0)
+ self.assertRaises(TypeError, strchr, b"abcdef")
def test_without_prototype(self):
dll = CDLL(_ctypes_test.__file__)
@@ -26,10 +28,10 @@ class ReturnFuncPtrTestCase(unittest.TestCase):
# _CFuncPtr instances are now callable with an integer argument
# which denotes a function address:
strchr = CFUNCTYPE(c_char_p, c_char_p, c_char)(addr)
- self.assertTrue(strchr("abcdef", "b"), "bcdef")
- self.assertEqual(strchr("abcdef", "x"), None)
- self.assertRaises(ArgumentError, strchr, "abcdef", 3)
- self.assertRaises(TypeError, strchr, "abcdef")
+ self.assertTrue(strchr(b"abcdef", b"b"), "bcdef")
+ self.assertEqual(strchr(b"abcdef", b"x"), None)
+ self.assertRaises(ArgumentError, strchr, b"abcdef", 3.0)
+ self.assertRaises(TypeError, strchr, b"abcdef")
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/ctypes/test/test_simplesubclasses.py b/Lib/ctypes/test/test_simplesubclasses.py
index 1b73fb371cc..3da2794a794 100644
--- a/Lib/ctypes/test/test_simplesubclasses.py
+++ b/Lib/ctypes/test/test_simplesubclasses.py
@@ -2,12 +2,10 @@ import unittest
from ctypes import *
class MyInt(c_int):
- def __cmp__(self, other):
+ def __eq__(self, other):
if type(other) != MyInt:
- return -1
- return cmp(self.value, other.value)
- def __hash__(self): # Silence Py3k warning
- return hash(self.value)
+ return NotImplementedError
+ return self.value == other.value
class Test(unittest.TestCase):
diff --git a/Lib/ctypes/test/test_slicing.py b/Lib/ctypes/test/test_slicing.py
index a5632ec4e20..82fee96823f 100644
--- a/Lib/ctypes/test/test_slicing.py
+++ b/Lib/ctypes/test/test_slicing.py
@@ -5,8 +5,8 @@ import _ctypes_test
class SlicesTestCase(unittest.TestCase):
def test_getslice_cint(self):
- a = (c_int * 100)(*xrange(1100, 1200))
- b = range(1100, 1200)
+ a = (c_int * 100)(*range(1100, 1200))
+ b = list(range(1100, 1200))
self.assertEqual(a[0:2], b[0:2])
self.assertEqual(a[0:2:], b[0:2:])
self.assertEqual(len(a), len(b))
@@ -21,20 +21,20 @@ class SlicesTestCase(unittest.TestCase):
self.assertEqual(a[2:6:4], b[2:6:4])
a[0:5] = range(5, 10)
- self.assertEqual(a[0:5], range(5, 10))
- self.assertEqual(a[0:5:], range(5, 10))
- self.assertEqual(a[4::-1], range(9, 4, -1))
+ self.assertEqual(a[0:5], list(range(5, 10)))
+ self.assertEqual(a[0:5:], list(range(5, 10)))
+ self.assertEqual(a[4::-1], list(range(9, 4, -1)))
def test_setslice_cint(self):
- a = (c_int * 100)(*xrange(1100, 1200))
- b = range(1100, 1200)
+ a = (c_int * 100)(*range(1100, 1200))
+ b = list(range(1100, 1200))
- a[32:47] = range(32, 47)
- self.assertEqual(a[32:47], range(32, 47))
+ a[32:47] = list(range(32, 47))
+ self.assertEqual(a[32:47], list(range(32, 47)))
a[32:47] = range(132, 147)
- self.assertEqual(a[32:47:], range(132, 147))
+ self.assertEqual(a[32:47:], list(range(132, 147)))
a[46:31:-1] = range(232, 247)
- self.assertEqual(a[32:47:1], range(246, 231, -1))
+ self.assertEqual(a[32:47:1], list(range(246, 231, -1)))
a[32:47] = range(1132, 1147)
self.assertEqual(a[:], b)
@@ -45,25 +45,21 @@ class SlicesTestCase(unittest.TestCase):
b[33::-3] = range(12)
self.assertEqual(a[:], b)
- from operator import setslice, setitem
+ from operator import setitem
# TypeError: int expected instead of str instance
- self.assertRaises(TypeError, setslice, a, 0, 5, "abcde")
self.assertRaises(TypeError, setitem, a, slice(0, 5), "abcde")
# TypeError: int expected instead of str instance
- self.assertRaises(TypeError, setslice, a, 0, 5, ["a", "b", "c", "d", "e"])
self.assertRaises(TypeError, setitem, a, slice(0, 5),
["a", "b", "c", "d", "e"])
# TypeError: int expected instead of float instance
- self.assertRaises(TypeError, setslice, a, 0, 5, [1, 2, 3, 4, 3.14])
self.assertRaises(TypeError, setitem, a, slice(0, 5),
[1, 2, 3, 4, 3.14])
# ValueError: Can only assign sequence of same size
- self.assertRaises(ValueError, setslice, a, 0, 5, range(32))
self.assertRaises(ValueError, setitem, a, slice(0, 5), range(32))
def test_char_ptr(self):
- s = "abcdefghijklmnopqrstuvwxyz"
+ s = b"abcdefghijklmnopqrstuvwxyz"
dll = CDLL(_ctypes_test.__file__)
dll.my_strdup.restype = POINTER(c_char)
@@ -86,21 +82,19 @@ class SlicesTestCase(unittest.TestCase):
self.assertRaises(ValueError, operator.getitem,
res, slice(-5, None, None))
- self.assertRaises(TypeError, operator.setslice,
- res, 0, 5, u"abcde")
self.assertRaises(TypeError, operator.setitem,
- res, slice(0, 5), u"abcde")
+ res, slice(0, 5), "abcde")
dll.my_free(res)
dll.my_strdup.restype = POINTER(c_byte)
res = dll.my_strdup(s)
- self.assertEqual(res[:len(s)], range(ord("a"), ord("z")+1))
- self.assertEqual(res[:len(s):], range(ord("a"), ord("z")+1))
+ self.assertEqual(res[:len(s)], list(range(ord("a"), ord("z")+1)))
+ self.assertEqual(res[:len(s):], list(range(ord("a"), ord("z")+1)))
dll.my_free(res)
def test_char_ptr_with_free(self):
dll = CDLL(_ctypes_test.__file__)
- s = "abcdefghijklmnopqrstuvwxyz"
+ s = b"abcdefghijklmnopqrstuvwxyz"
class allocated_c_char_p(c_char_p):
pass
@@ -121,7 +115,7 @@ class SlicesTestCase(unittest.TestCase):
def test_char_array(self):
- s = "abcdefghijklmnopqrstuvwxyz\0"
+ s = b"abcdefghijklmnopqrstuvwxyz\0"
p = (c_char * 27)(*s)
self.assertEqual(p[:], s)
@@ -137,7 +131,7 @@ class SlicesTestCase(unittest.TestCase):
pass
else:
def test_wchar_ptr(self):
- s = u"abcdefghijklmnopqrstuvwxyz\0"
+ s = "abcdefghijklmnopqrstuvwxyz\0"
dll = CDLL(_ctypes_test.__file__)
dll.my_wcsdup.restype = POINTER(c_wchar)
@@ -150,10 +144,8 @@ class SlicesTestCase(unittest.TestCase):
self.assertEqual(res[len(s)-1:5:-7], s[:5:-7])
import operator
- self.assertRaises(TypeError, operator.setslice,
- res, 0, 5, u"abcde")
self.assertRaises(TypeError, operator.setitem,
- res, slice(0, 5), u"abcde")
+ res, slice(0, 5), "abcde")
dll.my_free(res)
if sizeof(c_wchar) == sizeof(c_short):
@@ -165,7 +157,7 @@ class SlicesTestCase(unittest.TestCase):
else:
return
res = dll.my_wcsdup(s)
- tmpl = range(ord("a"), ord("z")+1)
+ tmpl = list(range(ord("a"), ord("z")+1))
self.assertEqual(res[:len(s)-1], tmpl)
self.assertEqual(res[:len(s)-1:], tmpl)
self.assertEqual(res[len(s)-2:-1:-1], tmpl[::-1])
diff --git a/Lib/ctypes/test/test_stringptr.py b/Lib/ctypes/test/test_stringptr.py
index abed58b1591..3d25fa53603 100644
--- a/Lib/ctypes/test/test_stringptr.py
+++ b/Lib/ctypes/test/test_stringptr.py
@@ -14,7 +14,7 @@ class StringPtrTestCase(unittest.TestCase):
# NULL pointer access
self.assertRaises(ValueError, getattr, x.str, "contents")
- b = c_buffer("Hello, World")
+ b = c_buffer(b"Hello, World")
from sys import getrefcount as grc
self.assertEqual(grc(b), 2)
x.str = b
@@ -35,10 +35,10 @@ class StringPtrTestCase(unittest.TestCase):
# c_char_p and Python string is compatible
# c_char_p and c_buffer is NOT compatible
self.assertEqual(x.str, None)
- x.str = "Hello, World"
- self.assertEqual(x.str, "Hello, World")
- b = c_buffer("Hello, World")
- self.assertRaises(TypeError, setattr, x, "str", b)
+ x.str = b"Hello, World"
+ self.assertEqual(x.str, b"Hello, World")
+ b = c_buffer(b"Hello, World")
+ self.assertRaises(TypeError, setattr, x, b"str", b)
def test_functions(self):
@@ -48,25 +48,25 @@ class StringPtrTestCase(unittest.TestCase):
# c_char_p and Python string is compatible
# c_char_p and c_buffer are now compatible
strchr.argtypes = c_char_p, c_char
- self.assertEqual(strchr("abcdef", "c"), "cdef")
- self.assertEqual(strchr(c_buffer("abcdef"), "c"), "cdef")
+ self.assertEqual(strchr(b"abcdef", b"c"), b"cdef")
+ self.assertEqual(strchr(c_buffer(b"abcdef"), b"c"), b"cdef")
# POINTER(c_char) and Python string is NOT compatible
# POINTER(c_char) and c_buffer() is compatible
strchr.argtypes = POINTER(c_char), c_char
- buf = c_buffer("abcdef")
- self.assertEqual(strchr(buf, "c"), "cdef")
- self.assertEqual(strchr("abcdef", "c"), "cdef")
+ buf = c_buffer(b"abcdef")
+ self.assertEqual(strchr(buf, b"c"), b"cdef")
+ self.assertEqual(strchr(b"abcdef", b"c"), b"cdef")
# XXX These calls are dangerous, because the first argument
# to strchr is no longer valid after the function returns!
# So we must keep a reference to buf separately
strchr.restype = POINTER(c_char)
- buf = c_buffer("abcdef")
- r = strchr(buf, "c")
+ buf = c_buffer(b"abcdef")
+ r = strchr(buf, b"c")
x = r[0], r[1], r[2], r[3], r[4]
- self.assertEqual(x, ("c", "d", "e", "f", "\000"))
+ self.assertEqual(x, (b"c", b"d", b"e", b"f", b"\000"))
del buf
# x1 will NOT be the same as x, usually:
x1 = r[0], r[1], r[2], r[3], r[4]
diff --git a/Lib/ctypes/test/test_strings.py b/Lib/ctypes/test/test_strings.py
index 8945d0c482a..1a9bdbc5c0f 100644
--- a/Lib/ctypes/test/test_strings.py
+++ b/Lib/ctypes/test/test_strings.py
@@ -1,53 +1,46 @@
import unittest
from ctypes import *
-from test import test_support
class StringArrayTestCase(unittest.TestCase):
def test(self):
BUF = c_char * 4
- buf = BUF("a", "b", "c")
- self.assertEqual(buf.value, "abc")
- self.assertEqual(buf.raw, "abc\000")
+ buf = BUF(b"a", b"b", b"c")
+ self.assertEqual(buf.value, b"abc")
+ self.assertEqual(buf.raw, b"abc\000")
- buf.value = "ABCD"
- self.assertEqual(buf.value, "ABCD")
- self.assertEqual(buf.raw, "ABCD")
+ buf.value = b"ABCD"
+ self.assertEqual(buf.value, b"ABCD")
+ self.assertEqual(buf.raw, b"ABCD")
- buf.value = "x"
- self.assertEqual(buf.value, "x")
- self.assertEqual(buf.raw, "x\000CD")
+ buf.value = b"x"
+ self.assertEqual(buf.value, b"x")
+ self.assertEqual(buf.raw, b"x\000CD")
- buf[1] = "Z"
- self.assertEqual(buf.value, "xZCD")
- self.assertEqual(buf.raw, "xZCD")
+ buf[1] = b"Z"
+ self.assertEqual(buf.value, b"xZCD")
+ self.assertEqual(buf.raw, b"xZCD")
- self.assertRaises(ValueError, setattr, buf, "value", "aaaaaaaa")
+ self.assertRaises(ValueError, setattr, buf, "value", b"aaaaaaaa")
self.assertRaises(TypeError, setattr, buf, "value", 42)
- def test_c_buffer_value(self, memoryview=memoryview):
+ def test_c_buffer_value(self):
buf = c_buffer(32)
- buf.value = "Hello, World"
- self.assertEqual(buf.value, "Hello, World")
+ buf.value = b"Hello, World"
+ self.assertEqual(buf.value, b"Hello, World")
- self.assertRaises(TypeError, setattr, buf, "value", memoryview("Hello, World"))
- self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
- self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
+ self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"Hello, World"))
+ self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
+ self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))
- def test_c_buffer_raw(self, memoryview=memoryview):
+ def test_c_buffer_raw(self):
buf = c_buffer(32)
- buf.raw = memoryview("Hello, World")
- self.assertEqual(buf.value, "Hello, World")
- self.assertRaises(TypeError, setattr, buf, "value", memoryview("abc"))
- self.assertRaises(ValueError, setattr, buf, "raw", memoryview("x" * 100))
-
- def test_c_buffer_deprecated(self):
- # Compatibility with 2.x
- with test_support.check_py3k_warnings():
- self.test_c_buffer_value(buffer)
- self.test_c_buffer_raw(buffer)
+ buf.raw = memoryview(b"Hello, World")
+ self.assertEqual(buf.value, b"Hello, World")
+ self.assertRaises(TypeError, setattr, buf, "value", memoryview(b"abc"))
+ self.assertRaises(ValueError, setattr, buf, "raw", memoryview(b"x" * 100))
def test_param_1(self):
BUF = c_char * 4
@@ -69,17 +62,24 @@ else:
def test(self):
BUF = c_wchar * 4
- buf = BUF(u"a", u"b", u"c")
- self.assertEqual(buf.value, u"abc")
+ buf = BUF("a", "b", "c")
+ self.assertEqual(buf.value, "abc")
+
+ buf.value = "ABCD"
+ self.assertEqual(buf.value, "ABCD")
- buf.value = u"ABCD"
- self.assertEqual(buf.value, u"ABCD")
+ buf.value = "x"
+ self.assertEqual(buf.value, "x")
- buf.value = u"x"
- self.assertEqual(buf.value, u"x")
+ buf[1] = "Z"
+ self.assertEqual(buf.value, "xZCD")
- buf[1] = u"Z"
- self.assertEqual(buf.value, u"xZCD")
+ @unittest.skipIf(sizeof(c_wchar) < 4,
+ "sizeof(wchar_t) is smaller than 4 bytes")
+ def test_nonbmp(self):
+ u = chr(0x10ffff)
+ w = c_wchar(u)
+ self.assertEqual(w.value, u)
class StringTestCase(unittest.TestCase):
def XX_test_basic_strings(self):
@@ -106,7 +106,7 @@ class StringTestCase(unittest.TestCase):
self.assertEqual(cs.value, "XY")
self.assertEqual(cs.raw, "XY\000\000\000\000\000")
- self.assertRaises(TypeError, c_string, u"123")
+ self.assertRaises(TypeError, c_string, "123")
def XX_test_sized_strings(self):
@@ -152,13 +152,13 @@ except NameError:
else:
class WStringTestCase(unittest.TestCase):
def test_wchar(self):
- c_wchar(u"x")
- repr(byref(c_wchar(u"x")))
+ c_wchar("x")
+ repr(byref(c_wchar("x")))
c_wchar("x")
def X_test_basic_wstrings(self):
- cs = c_wstring(u"abcdef")
+ cs = c_wstring("abcdef")
# XXX This behaviour is about to change:
# len returns the size of the internal buffer in bytes.
@@ -166,30 +166,30 @@ else:
self.assertTrue(sizeof(cs) == 14)
# The value property is the string up to the first terminating NUL.
- self.assertTrue(cs.value == u"abcdef")
- self.assertTrue(c_wstring(u"abc\000def").value == u"abc")
+ self.assertTrue(cs.value == "abcdef")
+ self.assertTrue(c_wstring("abc\000def").value == "abc")
- self.assertTrue(c_wstring(u"abc\000def").value == u"abc")
+ self.assertTrue(c_wstring("abc\000def").value == "abc")
# The raw property is the total buffer contents:
- self.assertTrue(cs.raw == u"abcdef\000")
- self.assertTrue(c_wstring(u"abc\000def").raw == u"abc\000def\000")
+ self.assertTrue(cs.raw == "abcdef\000")
+ self.assertTrue(c_wstring("abc\000def").raw == "abc\000def\000")
# We can change the value:
- cs.value = u"ab"
- self.assertTrue(cs.value == u"ab")
- self.assertTrue(cs.raw == u"ab\000\000\000\000\000")
+ cs.value = "ab"
+ self.assertTrue(cs.value == "ab")
+ self.assertTrue(cs.raw == "ab\000\000\000\000\000")
self.assertRaises(TypeError, c_wstring, "123")
self.assertRaises(ValueError, c_wstring, 0)
def X_test_toolong(self):
- cs = c_wstring(u"abcdef")
+ cs = c_wstring("abcdef")
# Much too long string:
- self.assertRaises(ValueError, setattr, cs, "value", u"123456789012345")
+ self.assertRaises(ValueError, setattr, cs, "value", "123456789012345")
# One char too long values:
- self.assertRaises(ValueError, setattr, cs, "value", u"1234567")
+ self.assertRaises(ValueError, setattr, cs, "value", "1234567")
def run_test(rep, msg, func, arg):
@@ -199,7 +199,7 @@ def run_test(rep, msg, func, arg):
for i in items:
func(arg); func(arg); func(arg); func(arg); func(arg)
stop = clock()
- print "%20s: %.2f us" % (msg, ((stop-start)*1e6/5/rep))
+ print("%20s: %.2f us" % (msg, ((stop-start)*1e6/5/rep)))
def check_perf():
# Construct 5 objects
diff --git a/Lib/ctypes/test/test_structures.py b/Lib/ctypes/test/test_structures.py
index 1bde101d7cf..b6d8b012ff0 100644
--- a/Lib/ctypes/test/test_structures.py
+++ b/Lib/ctypes/test/test_structures.py
@@ -205,15 +205,15 @@ class StructureTestCase(unittest.TestCase):
("age", c_int)]
self.assertRaises(TypeError, Person, 42)
- self.assertRaises(ValueError, Person, "asldkjaslkdjaslkdj")
+ self.assertRaises(ValueError, Person, b"asldkjaslkdjaslkdj")
self.assertRaises(TypeError, Person, "Name", "HI")
# short enough
- self.assertEqual(Person("12345", 5).name, "12345")
+ self.assertEqual(Person(b"12345", 5).name, b"12345")
# exact fit
- self.assertEqual(Person("123456", 5).name, "123456")
+ self.assertEqual(Person(b"123456", 5).name, b"123456")
# too long
- self.assertRaises(ValueError, Person, "1234567", 5)
+ self.assertRaises(ValueError, Person, b"1234567", 5)
def test_conflicting_initializers(self):
class POINT(Structure):
@@ -245,7 +245,7 @@ class StructureTestCase(unittest.TestCase):
class S(Structure):
_fields_ = [(name, c_int)]
- self.assertRaises(TypeError, declare_with_name, u"x\xe9")
+ self.assertRaises(TypeError, declare_with_name, b"x")
def test_intarray_fields(self):
class SomeInts(Structure):
@@ -275,11 +275,11 @@ class StructureTestCase(unittest.TestCase):
("phone", Phone),
("age", c_int)]
- p = Person("Someone", ("1234", "5678"), 5)
+ p = Person(b"Someone", (b"1234", b"5678"), 5)
- self.assertEqual(p.name, "Someone")
- self.assertEqual(p.phone.areacode, "1234")
- self.assertEqual(p.phone.number, "5678")
+ self.assertEqual(p.name, b"Someone")
+ self.assertEqual(p.phone.areacode, b"1234")
+ self.assertEqual(p.phone.number, b"5678")
self.assertEqual(p.age, 5)
def test_structures_with_wchar(self):
@@ -292,15 +292,15 @@ class StructureTestCase(unittest.TestCase):
_fields_ = [("name", c_wchar * 12),
("age", c_int)]
- p = PersonW(u"Someone")
- self.assertEqual(p.name, "Someone")
+ p = PersonW("Someone \xe9")
+ self.assertEqual(p.name, "Someone \xe9")
- self.assertEqual(PersonW(u"1234567890").name, u"1234567890")
- self.assertEqual(PersonW(u"12345678901").name, u"12345678901")
+ self.assertEqual(PersonW("1234567890").name, "1234567890")
+ self.assertEqual(PersonW("12345678901").name, "12345678901")
# exact fit
- self.assertEqual(PersonW(u"123456789012").name, u"123456789012")
+ self.assertEqual(PersonW("123456789012").name, "123456789012")
#too long
- self.assertRaises(ValueError, PersonW, u"1234567890123")
+ self.assertRaises(ValueError, PersonW, "1234567890123")
def test_init_errors(self):
class Phone(Structure):
@@ -312,25 +312,19 @@ class StructureTestCase(unittest.TestCase):
("phone", Phone),
("age", c_int)]
- cls, msg = self.get_except(Person, "Someone", (1, 2))
+ cls, msg = self.get_except(Person, b"Someone", (1, 2))
self.assertEqual(cls, RuntimeError)
- # In Python 2.5, Exception is a new-style class, and the repr changed
- if issubclass(Exception, object):
- self.assertEqual(msg,
- "(Phone) <type 'exceptions.TypeError'>: "
- "expected string or Unicode object, int found")
- else:
- self.assertEqual(msg,
- "(Phone) exceptions.TypeError: "
- "expected string or Unicode object, int found")
+ self.assertEqual(msg,
+ "(Phone) <class 'TypeError'>: "
+ "expected string, int found")
- cls, msg = self.get_except(Person, "Someone", ("a", "b", "c"))
+ cls, msg = self.get_except(Person, b"Someone", (b"a", b"b", b"c"))
self.assertEqual(cls, RuntimeError)
if issubclass(Exception, object):
self.assertEqual(msg,
- "(Phone) <type 'exceptions.TypeError'>: too many initializers")
+ "(Phone) <class 'TypeError'>: too many initializers")
else:
- self.assertEqual(msg, "(Phone) exceptions.TypeError: too many initializers")
+ self.assertEqual(msg, "(Phone) TypeError: too many initializers")
def test_huge_field_name(self):
# issue12881: segfault with large structure field names
@@ -348,7 +342,7 @@ class StructureTestCase(unittest.TestCase):
def get_except(self, func, *args):
try:
func(*args)
- except Exception, detail:
+ except Exception as detail:
return detail.__class__, str(detail)
@@ -442,7 +436,7 @@ class TestRecursiveStructure(unittest.TestCase):
try:
Recursive._fields_ = [("next", Recursive)]
- except AttributeError, details:
+ except AttributeError as details:
self.assertTrue("Structure or union cannot contain itself" in
str(details))
else:
@@ -459,7 +453,7 @@ class TestRecursiveStructure(unittest.TestCase):
try:
Second._fields_ = [("first", First)]
- except AttributeError, details:
+ except AttributeError as details:
self.assertTrue("_fields_ is final" in
str(details))
else:
diff --git a/Lib/ctypes/test/test_unicode.py b/Lib/ctypes/test/test_unicode.py
index 65574790308..c3b2d487712 100644
--- a/Lib/ctypes/test/test_unicode.py
+++ b/Lib/ctypes/test/test_unicode.py
@@ -1,4 +1,3 @@
-# coding: latin-1
import unittest
import ctypes
@@ -8,122 +7,53 @@ except AttributeError:
pass
else:
import _ctypes_test
- dll = ctypes.CDLL(_ctypes_test.__file__)
- wcslen = dll.my_wcslen
- wcslen.argtypes = [ctypes.c_wchar_p]
-
class UnicodeTestCase(unittest.TestCase):
- def setUp(self):
- self.prev_conv_mode = ctypes.set_conversion_mode("ascii", "strict")
-
- def tearDown(self):
- ctypes.set_conversion_mode(*self.prev_conv_mode)
-
- def test_ascii_strict(self):
- ctypes.set_conversion_mode("ascii", "strict")
- # no conversions take place with unicode arguments
- self.assertEqual(wcslen(u"abc"), 3)
- self.assertEqual(wcslen(u"ab\u2070"), 3)
- # string args are converted
- self.assertEqual(wcslen("abc"), 3)
- self.assertRaises(ctypes.ArgumentError, wcslen, "abä")
-
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "replace")
- self.assertEqual(wcslen(u"abc"), 3)
- self.assertEqual(wcslen(u"ab\u2070"), 3)
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("abä"), 3)
+ def test_wcslen(self):
+ dll = ctypes.CDLL(_ctypes_test.__file__)
+ wcslen = dll.my_wcslen
+ wcslen.argtypes = [ctypes.c_wchar_p]
- def test_ascii_ignore(self):
- ctypes.set_conversion_mode("ascii", "ignore")
- self.assertEqual(wcslen(u"abc"), 3)
- self.assertEqual(wcslen(u"ab\u2070"), 3)
- # ignore error mode skips non-ascii characters
self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("äöüß"), 0)
-
- def test_latin1_strict(self):
- ctypes.set_conversion_mode("latin-1", "strict")
- self.assertEqual(wcslen(u"abc"), 3)
- self.assertEqual(wcslen(u"ab\u2070"), 3)
- self.assertEqual(wcslen("abc"), 3)
- self.assertEqual(wcslen("äöüß"), 4)
+ self.assertEqual(wcslen("ab\u2070"), 3)
+ self.assertRaises(ctypes.ArgumentError, wcslen, b"ab\xe4")
def test_buffers(self):
- ctypes.set_conversion_mode("ascii", "strict")
buf = ctypes.create_unicode_buffer("abc")
self.assertEqual(len(buf), 3+1)
- ctypes.set_conversion_mode("ascii", "replace")
- buf = ctypes.create_unicode_buffer("abäöü")
- self.assertEqual(buf[:], u"ab\uFFFD\uFFFD\uFFFD\0")
- self.assertEqual(buf[::], u"ab\uFFFD\uFFFD\uFFFD\0")
- self.assertEqual(buf[::-1], u"\0\uFFFD\uFFFD\uFFFDba")
- self.assertEqual(buf[::2], u"a\uFFFD\uFFFD")
- self.assertEqual(buf[6:5:-1], u"")
-
- ctypes.set_conversion_mode("ascii", "ignore")
- buf = ctypes.create_unicode_buffer("abäöü")
- # is that correct? not sure. But with 'ignore', you get what you pay for..
- self.assertEqual(buf[:], u"ab\0\0\0\0")
- self.assertEqual(buf[::], u"ab\0\0\0\0")
- self.assertEqual(buf[::-1], u"\0\0\0\0ba")
- self.assertEqual(buf[::2], u"a\0\0")
- self.assertEqual(buf[6:5:-1], u"")
+ buf = ctypes.create_unicode_buffer("ab\xe4\xf6\xfc")
+ self.assertEqual(buf[:], "ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::], "ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::-1], '\x00\xfc\xf6\xe4ba')
+ self.assertEqual(buf[::2], 'a\xe4\xfc')
+ self.assertEqual(buf[6:5:-1], "")
- import _ctypes_test
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
class StringTestCase(UnicodeTestCase):
def setUp(self):
- self.prev_conv_mode = ctypes.set_conversion_mode("ascii", "strict")
func.argtypes = [ctypes.c_char_p]
func.restype = ctypes.c_char_p
def tearDown(self):
- ctypes.set_conversion_mode(*self.prev_conv_mode)
func.argtypes = None
func.restype = ctypes.c_int
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "strict")
- self.assertEqual(func("abc"), "abc")
- self.assertEqual(func(u"abc"), "abc")
- self.assertRaises(ctypes.ArgumentError, func, u"abä")
-
- def test_ascii_ignore(self):
- ctypes.set_conversion_mode("ascii", "ignore")
- self.assertEqual(func("abc"), "abc")
- self.assertEqual(func(u"abc"), "abc")
- self.assertEqual(func(u"äöüß"), "")
-
- def test_ascii_replace(self):
- ctypes.set_conversion_mode("ascii", "replace")
- self.assertEqual(func("abc"), "abc")
- self.assertEqual(func(u"abc"), "abc")
- self.assertEqual(func(u"äöüß"), "????")
+ def test_func(self):
+ self.assertEqual(func(b"abc\xe4"), b"abc\xe4")
def test_buffers(self):
- ctypes.set_conversion_mode("ascii", "strict")
- buf = ctypes.create_string_buffer(u"abc")
+ buf = ctypes.create_string_buffer(b"abc")
self.assertEqual(len(buf), 3+1)
- ctypes.set_conversion_mode("ascii", "replace")
- buf = ctypes.create_string_buffer(u"abäöü")
- self.assertEqual(buf[:], "ab???\0")
- self.assertEqual(buf[::], "ab???\0")
- self.assertEqual(buf[::-1], "\0???ba")
- self.assertEqual(buf[::2], "a??")
- self.assertEqual(buf[6:5:-1], "")
+ buf = ctypes.create_string_buffer(b"ab\xe4\xf6\xfc")
+ self.assertEqual(buf[:], b"ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::], b"ab\xe4\xf6\xfc\0")
+ self.assertEqual(buf[::-1], b'\x00\xfc\xf6\xe4ba')
+ self.assertEqual(buf[::2], b'a\xe4\xfc')
+ self.assertEqual(buf[6:5:-1], b"")
- ctypes.set_conversion_mode("ascii", "ignore")
- buf = ctypes.create_string_buffer(u"abäöü")
- # is that correct? not sure. But with 'ignore', you get what you pay for..
- self.assertEqual(buf[:], "ab\0\0\0\0")
- self.assertEqual(buf[::], "ab\0\0\0\0")
- self.assertEqual(buf[::-1], "\0\0\0\0ba")
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/ctypes/test/test_values.py b/Lib/ctypes/test/test_values.py
index 4cbfd4ba4b5..e46410208f7 100644
--- a/Lib/ctypes/test/test_values.py
+++ b/Lib/ctypes/test/test_values.py
@@ -10,12 +10,18 @@ import _ctypes_test
class ValuesTestCase(unittest.TestCase):
def test_an_integer(self):
+ # This test checks and changes an integer stored inside the
+ # _ctypes_test dll/shared lib.
ctdll = CDLL(_ctypes_test.__file__)
an_integer = c_int.in_dll(ctdll, "an_integer")
x = an_integer.value
self.assertEqual(x, ctdll.get_an_integer())
an_integer.value *= 2
self.assertEqual(x*2, ctdll.get_an_integer())
+ # To avoid test failures when this test is repeated several
+ # times the original value must be restored
+ an_integer.value = x
+ self.assertEqual(x, ctdll.get_an_integer())
def test_undefined(self):
ctdll = CDLL(_ctypes_test.__file__)
diff --git a/Lib/ctypes/util.py b/Lib/ctypes/util.py
index 7aee0eff99c..1bb7d1de7ef 100644
--- a/Lib/ctypes/util.py
+++ b/Lib/ctypes/util.py
@@ -1,7 +1,5 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
import sys, os
+import contextlib
# find_library(name) returns the pathname of a library, or None.
if os.name == "nt":
@@ -103,11 +101,11 @@ elif os.name == "posix":
finally:
try:
os.unlink(ccout)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
if rv == 10:
- raise OSError, 'gcc or cc command not found'
+ raise OSError('gcc or cc command not found')
res = re.search(expr, trace)
if not res:
return None
@@ -120,11 +118,8 @@ elif os.name == "posix":
if not f:
return None
cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f
- f = os.popen(cmd)
- try:
+ with contextlib.closing(os.popen(cmd)) as f:
data = f.read()
- finally:
- f.close()
res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data)
if not res:
return None
@@ -140,12 +135,9 @@ elif os.name == "posix":
dump = f.read()
rv = f.close()
if rv == 10:
- raise OSError, 'objdump command not found'
- f = os.popen(cmd)
- try:
+ raise OSError('objdump command not found')
+ with contextlib.closing(os.popen(cmd)) as f:
data = f.read()
- finally:
- f.close()
res = re.search(r'\sSONAME\s+([^\s]+)', data)
if not res:
return None
@@ -164,20 +156,17 @@ elif os.name == "posix":
nums.insert(0, int(parts.pop()))
except ValueError:
pass
- return nums or [ sys.maxint ]
+ return nums or [ sys.maxsize ]
def find_library(name):
ename = re.escape(name)
expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename)
- f = os.popen('/sbin/ldconfig -r 2>/dev/null')
- try:
+ with contextlib.closing(os.popen('/sbin/ldconfig -r 2>/dev/null')) as f:
data = f.read()
- finally:
- f.close()
res = re.findall(expr, data)
if not res:
return _get_soname(_findLib_gcc(name))
- res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y)))
+ res.sort(key=_num_version)
return res[-1]
else:
@@ -199,11 +188,8 @@ elif os.name == "posix":
# XXX assuming GLIBC's ldconfig (with option -p)
expr = r'\s+(lib%s\.[^\s]+)\s+\(%s' % (re.escape(name), abi_type)
- f = os.popen('/sbin/ldconfig -p 2>/dev/null')
- try:
+ with contextlib.closing(os.popen('LC_ALL=C LANG=C /sbin/ldconfig -p 2>/dev/null')) as f:
data = f.read()
- finally:
- f.close()
res = re.search(expr, data)
if not res:
return None
@@ -218,15 +204,15 @@ elif os.name == "posix":
def test():
from ctypes import cdll
if os.name == "nt":
- print cdll.msvcrt
- print cdll.load("msvcrt")
- print find_library("msvcrt")
+ print(cdll.msvcrt)
+ print(cdll.load("msvcrt"))
+ print(find_library("msvcrt"))
if os.name == "posix":
# find and load_version
- print find_library("m")
- print find_library("c")
- print find_library("bz2")
+ print(find_library("m"))
+ print(find_library("c"))
+ print(find_library("bz2"))
# getattr
## print cdll.m
@@ -234,14 +220,14 @@ def test():
# load
if sys.platform == "darwin":
- print cdll.LoadLibrary("libm.dylib")
- print cdll.LoadLibrary("libcrypto.dylib")
- print cdll.LoadLibrary("libSystem.dylib")
- print cdll.LoadLibrary("System.framework/System")
+ print(cdll.LoadLibrary("libm.dylib"))
+ print(cdll.LoadLibrary("libcrypto.dylib"))
+ print(cdll.LoadLibrary("libSystem.dylib"))
+ print(cdll.LoadLibrary("System.framework/System"))
else:
- print cdll.LoadLibrary("libm.so")
- print cdll.LoadLibrary("libcrypt.so")
- print find_library("crypt")
+ print(cdll.LoadLibrary("libm.so"))
+ print(cdll.LoadLibrary("libcrypt.so"))
+ print(find_library("crypt"))
if __name__ == "__main__":
test()
diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py
index dafbb78b781..c619d27596d 100644
--- a/Lib/ctypes/wintypes.py
+++ b/Lib/ctypes/wintypes.py
@@ -1,53 +1,50 @@
-######################################################################
-# This file should be kept compatible with Python 2.3, see PEP 291. #
-######################################################################
-
# The most useful windows datatypes
-from ctypes import *
+import ctypes
-BYTE = c_byte
-WORD = c_ushort
-DWORD = c_ulong
+BYTE = ctypes.c_byte
+WORD = ctypes.c_ushort
+DWORD = ctypes.c_ulong
-WCHAR = c_wchar
-UINT = c_uint
-INT = c_int
+#UCHAR = ctypes.c_uchar
+CHAR = ctypes.c_char
+WCHAR = ctypes.c_wchar
+UINT = ctypes.c_uint
+INT = ctypes.c_int
-DOUBLE = c_double
-FLOAT = c_float
+DOUBLE = ctypes.c_double
+FLOAT = ctypes.c_float
BOOLEAN = BYTE
-BOOL = c_long
+BOOL = ctypes.c_long
-from ctypes import _SimpleCData
-class VARIANT_BOOL(_SimpleCData):
+class VARIANT_BOOL(ctypes._SimpleCData):
_type_ = "v"
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.value)
-ULONG = c_ulong
-LONG = c_long
+ULONG = ctypes.c_ulong
+LONG = ctypes.c_long
-USHORT = c_ushort
-SHORT = c_short
+USHORT = ctypes.c_ushort
+SHORT = ctypes.c_short
# in the windows header files, these are structures.
-_LARGE_INTEGER = LARGE_INTEGER = c_longlong
-_ULARGE_INTEGER = ULARGE_INTEGER = c_ulonglong
+_LARGE_INTEGER = LARGE_INTEGER = ctypes.c_longlong
+_ULARGE_INTEGER = ULARGE_INTEGER = ctypes.c_ulonglong
-LPCOLESTR = LPOLESTR = OLESTR = c_wchar_p
-LPCWSTR = LPWSTR = c_wchar_p
-LPCSTR = LPSTR = c_char_p
-LPCVOID = LPVOID = c_void_p
+LPCOLESTR = LPOLESTR = OLESTR = ctypes.c_wchar_p
+LPCWSTR = LPWSTR = ctypes.c_wchar_p
+LPCSTR = LPSTR = ctypes.c_char_p
+LPCVOID = LPVOID = ctypes.c_void_p
# WPARAM is defined as UINT_PTR (unsigned type)
# LPARAM is defined as LONG_PTR (signed type)
-if sizeof(c_long) == sizeof(c_void_p):
- WPARAM = c_ulong
- LPARAM = c_long
-elif sizeof(c_longlong) == sizeof(c_void_p):
- WPARAM = c_ulonglong
- LPARAM = c_longlong
+if ctypes.sizeof(ctypes.c_long) == ctypes.sizeof(ctypes.c_void_p):
+ WPARAM = ctypes.c_ulong
+ LPARAM = ctypes.c_long
+elif ctypes.sizeof(ctypes.c_longlong) == ctypes.sizeof(ctypes.c_void_p):
+ WPARAM = ctypes.c_ulonglong
+ LPARAM = ctypes.c_longlong
ATOM = WORD
LANGID = WORD
@@ -60,7 +57,7 @@ LCID = DWORD
################################################################
# HANDLE types
-HANDLE = c_void_p # in the header files: void *
+HANDLE = ctypes.c_void_p # in the header files: void *
HACCEL = HANDLE
HBITMAP = HANDLE
@@ -97,45 +94,45 @@ SERVICE_STATUS_HANDLE = HANDLE
################################################################
# Some important structure definitions
-class RECT(Structure):
- _fields_ = [("left", c_long),
- ("top", c_long),
- ("right", c_long),
- ("bottom", c_long)]
+class RECT(ctypes.Structure):
+ _fields_ = [("left", LONG),
+ ("top", LONG),
+ ("right", LONG),
+ ("bottom", LONG)]
tagRECT = _RECTL = RECTL = RECT
-class _SMALL_RECT(Structure):
- _fields_ = [('Left', c_short),
- ('Top', c_short),
- ('Right', c_short),
- ('Bottom', c_short)]
+class _SMALL_RECT(ctypes.Structure):
+ _fields_ = [('Left', SHORT),
+ ('Top', SHORT),
+ ('Right', SHORT),
+ ('Bottom', SHORT)]
SMALL_RECT = _SMALL_RECT
-class _COORD(Structure):
- _fields_ = [('X', c_short),
- ('Y', c_short)]
+class _COORD(ctypes.Structure):
+ _fields_ = [('X', SHORT),
+ ('Y', SHORT)]
-class POINT(Structure):
- _fields_ = [("x", c_long),
- ("y", c_long)]
+class POINT(ctypes.Structure):
+ _fields_ = [("x", LONG),
+ ("y", LONG)]
tagPOINT = _POINTL = POINTL = POINT
-class SIZE(Structure):
- _fields_ = [("cx", c_long),
- ("cy", c_long)]
+class SIZE(ctypes.Structure):
+ _fields_ = [("cx", LONG),
+ ("cy", LONG)]
tagSIZE = SIZEL = SIZE
def RGB(red, green, blue):
return red + (green << 8) + (blue << 16)
-class FILETIME(Structure):
+class FILETIME(ctypes.Structure):
_fields_ = [("dwLowDateTime", DWORD),
("dwHighDateTime", DWORD)]
_FILETIME = FILETIME
-class MSG(Structure):
+class MSG(ctypes.Structure):
_fields_ = [("hWnd", HWND),
- ("message", c_uint),
+ ("message", UINT),
("wParam", WPARAM),
("lParam", LPARAM),
("time", DWORD),
@@ -143,7 +140,7 @@ class MSG(Structure):
tagMSG = MSG
MAX_PATH = 260
-class WIN32_FIND_DATAA(Structure):
+class WIN32_FIND_DATAA(ctypes.Structure):
_fields_ = [("dwFileAttributes", DWORD),
("ftCreationTime", FILETIME),
("ftLastAccessTime", FILETIME),
@@ -152,10 +149,10 @@ class WIN32_FIND_DATAA(Structure):
("nFileSizeLow", DWORD),
("dwReserved0", DWORD),
("dwReserved1", DWORD),
- ("cFileName", c_char * MAX_PATH),
- ("cAlternateFileName", c_char * 14)]
+ ("cFileName", CHAR * MAX_PATH),
+ ("cAlternateFileName", CHAR * 14)]
-class WIN32_FIND_DATAW(Structure):
+class WIN32_FIND_DATAW(ctypes.Structure):
_fields_ = [("dwFileAttributes", DWORD),
("ftCreationTime", FILETIME),
("ftLastAccessTime", FILETIME),
@@ -164,22 +161,42 @@ class WIN32_FIND_DATAW(Structure):
("nFileSizeLow", DWORD),
("dwReserved0", DWORD),
("dwReserved1", DWORD),
- ("cFileName", c_wchar * MAX_PATH),
- ("cAlternateFileName", c_wchar * 14)]
-
-__all__ = ['ATOM', 'BOOL', 'BOOLEAN', 'BYTE', 'COLORREF', 'DOUBLE', 'DWORD',
- 'FILETIME', 'FLOAT', 'HACCEL', 'HANDLE', 'HBITMAP', 'HBRUSH',
- 'HCOLORSPACE', 'HDC', 'HDESK', 'HDWP', 'HENHMETAFILE', 'HFONT',
- 'HGDIOBJ', 'HGLOBAL', 'HHOOK', 'HICON', 'HINSTANCE', 'HKEY',
- 'HKL', 'HLOCAL', 'HMENU', 'HMETAFILE', 'HMODULE', 'HMONITOR',
- 'HPALETTE', 'HPEN', 'HRGN', 'HRSRC', 'HSTR', 'HTASK', 'HWINSTA',
- 'HWND', 'INT', 'LANGID', 'LARGE_INTEGER', 'LCID', 'LCTYPE',
- 'LGRPID', 'LONG', 'LPARAM', 'LPCOLESTR', 'LPCSTR', 'LPCVOID',
- 'LPCWSTR', 'LPOLESTR', 'LPSTR', 'LPVOID', 'LPWSTR', 'MAX_PATH',
- 'MSG', 'OLESTR', 'POINT', 'POINTL', 'RECT', 'RECTL', 'RGB',
- 'SC_HANDLE', 'SERVICE_STATUS_HANDLE', 'SHORT', 'SIZE', 'SIZEL',
- 'SMALL_RECT', 'UINT', 'ULARGE_INTEGER', 'ULONG', 'USHORT',
- 'VARIANT_BOOL', 'WCHAR', 'WIN32_FIND_DATAA', 'WIN32_FIND_DATAW',
- 'WORD', 'WPARAM', '_COORD', '_FILETIME', '_LARGE_INTEGER',
- '_POINTL', '_RECTL', '_SMALL_RECT', '_ULARGE_INTEGER', 'tagMSG',
- 'tagPOINT', 'tagRECT', 'tagSIZE']
+ ("cFileName", WCHAR * MAX_PATH),
+ ("cAlternateFileName", WCHAR * 14)]
+
+################################################################
+# Pointer types
+
+LPBOOL = PBOOL = ctypes.POINTER(BOOL)
+PBOOLEAN = ctypes.POINTER(BOOLEAN)
+LPBYTE = PBYTE = ctypes.POINTER(BYTE)
+PCHAR = ctypes.POINTER(CHAR)
+LPCOLORREF = ctypes.POINTER(COLORREF)
+LPDWORD = PDWORD = ctypes.POINTER(DWORD)
+LPFILETIME = PFILETIME = ctypes.POINTER(FILETIME)
+PFLOAT = ctypes.POINTER(FLOAT)
+LPHANDLE = PHANDLE = ctypes.POINTER(HANDLE)
+PHKEY = ctypes.POINTER(HKEY)
+LPHKL = ctypes.POINTER(HKL)
+LPINT = PINT = ctypes.POINTER(INT)
+PLARGE_INTEGER = ctypes.POINTER(LARGE_INTEGER)
+PLCID = ctypes.POINTER(LCID)
+LPLONG = PLONG = ctypes.POINTER(LONG)
+LPMSG = PMSG = ctypes.POINTER(MSG)
+LPPOINT = PPOINT = ctypes.POINTER(POINT)
+PPOINTL = ctypes.POINTER(POINTL)
+LPRECT = PRECT = ctypes.POINTER(RECT)
+LPRECTL = PRECTL = ctypes.POINTER(RECTL)
+LPSC_HANDLE = ctypes.POINTER(SC_HANDLE)
+PSHORT = ctypes.POINTER(SHORT)
+LPSIZE = PSIZE = ctypes.POINTER(SIZE)
+LPSIZEL = PSIZEL = ctypes.POINTER(SIZEL)
+PSMALL_RECT = ctypes.POINTER(SMALL_RECT)
+LPUINT = PUINT = ctypes.POINTER(UINT)
+PULARGE_INTEGER = ctypes.POINTER(ULARGE_INTEGER)
+PULONG = ctypes.POINTER(ULONG)
+PUSHORT = ctypes.POINTER(USHORT)
+PWCHAR = ctypes.POINTER(WCHAR)
+LPWIN32_FIND_DATAA = PWIN32_FIND_DATAA = ctypes.POINTER(WIN32_FIND_DATAA)
+LPWIN32_FIND_DATAW = PWIN32_FIND_DATAW = ctypes.POINTER(WIN32_FIND_DATAW)
+LPWORD = PWORD = ctypes.POINTER(WORD)
diff --git a/Lib/curses/__init__.py b/Lib/curses/__init__.py
index bd7d5f61cf4..a3e9def72a2 100644
--- a/Lib/curses/__init__.py
+++ b/Lib/curses/__init__.py
@@ -10,8 +10,6 @@ the package, and perhaps a particular module inside it.
"""
-__revision__ = "$Id$"
-
from _curses import *
from curses.wrapper import wrapper
import os as _os
@@ -56,4 +54,4 @@ def start_color():
try:
has_key
except NameError:
- from has_key import has_key
+ from .has_key import has_key
diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py
index 1dd5a3bd4a4..4e37b480f13 100644
--- a/Lib/curses/has_key.py
+++ b/Lib/curses/has_key.py
@@ -182,11 +182,11 @@ if __name__ == '__main__':
L = []
_curses.initscr()
for key in _capability_names.keys():
- system = key in _curses
+ system = _curses.has_key(key)
python = has_key(key)
if system != python:
L.append( 'Mismatch for key %s, system=%i, Python=%i'
% (_curses.keyname( key ), system, python) )
finally:
_curses.endwin()
- for i in L: print i
+ for i in L: print(i)
diff --git a/Lib/curses/panel.py b/Lib/curses/panel.py
index aacca85151c..067afef730a 100644
--- a/Lib/curses/panel.py
+++ b/Lib/curses/panel.py
@@ -3,6 +3,4 @@
Module for using panels with curses.
"""
-__revision__ = "$Id$"
-
from _curses_panel import *
diff --git a/Lib/curses/textpad.py b/Lib/curses/textpad.py
index c45361c7d2e..2b4b4cb669f 100644
--- a/Lib/curses/textpad.py
+++ b/Lib/curses/textpad.py
@@ -185,4 +185,4 @@ if __name__ == '__main__':
return Textbox(win).edit()
str = curses.wrapper(test_editbox)
- print 'Contents of text box:', repr(str)
+ print('Contents of text box:', repr(str))
diff --git a/Lib/datetime.py b/Lib/datetime.py
new file mode 100644
index 00000000000..bf23e5002d9
--- /dev/null
+++ b/Lib/datetime.py
@@ -0,0 +1,2114 @@
+"""Concrete date/time and related types -- prototype implemented in Python.
+
+See http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
+
+See also http://dir.yahoo.com/Reference/calendars/
+
+For a primer on DST, including many current DST rules, see
+http://webexhibits.org/daylightsaving/
+
+For more about DST than you ever wanted to know, see
+ftp://elsie.nci.nih.gov/pub/
+
+Sources for time zone and DST data: http://www.twinsun.com/tz/tz-link.htm
+
+This was originally copied from the sandbox of the CPython CVS repository.
+Thanks to Tim Peters for suggesting using it.
+"""
+
+import time as _time
+import math as _math
+
+def _cmp(x, y):
+ return 0 if x == y else 1 if x > y else -1
+
+MINYEAR = 1
+MAXYEAR = 9999
+_MAXORDINAL = 3652059 # date.max.toordinal()
+
+# Utility functions, adapted from Python's Demo/classes/Dates.py, which
+# also assumes the current Gregorian calendar indefinitely extended in
+# both directions. Difference: Dates.py calls January 1 of year 0 day
+# number 1. The code here calls January 1 of year 1 day number 1. This is
+# to match the definition of the "proleptic Gregorian" calendar in Dershowitz
+# and Reingold's "Calendrical Calculations", where it's the base calendar
+# for all computations. See the book for algorithms for converting between
+# proleptic Gregorian ordinals and many other calendar systems.
+
+_DAYS_IN_MONTH = [None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+
+_DAYS_BEFORE_MONTH = [None]
+dbm = 0
+for dim in _DAYS_IN_MONTH[1:]:
+ _DAYS_BEFORE_MONTH.append(dbm)
+ dbm += dim
+del dbm, dim
+
+def _is_leap(year):
+ "year -> 1 if leap year, else 0."
+ return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)
+
+def _days_before_year(year):
+ "year -> number of days before January 1st of year."
+ y = year - 1
+ return y*365 + y//4 - y//100 + y//400
+
+def _days_in_month(year, month):
+ "year, month -> number of days in that month in that year."
+ assert 1 <= month <= 12, month
+ if month == 2 and _is_leap(year):
+ return 29
+ return _DAYS_IN_MONTH[month]
+
+def _days_before_month(year, month):
+ "year, month -> number of days in year preceeding first day of month."
+ assert 1 <= month <= 12, 'month must be in 1..12'
+ return _DAYS_BEFORE_MONTH[month] + (month > 2 and _is_leap(year))
+
+def _ymd2ord(year, month, day):
+ "year, month, day -> ordinal, considering 01-Jan-0001 as day 1."
+ assert 1 <= month <= 12, 'month must be in 1..12'
+ dim = _days_in_month(year, month)
+ assert 1 <= day <= dim, ('day must be in 1..%d' % dim)
+ return (_days_before_year(year) +
+ _days_before_month(year, month) +
+ day)
+
+_DI400Y = _days_before_year(401) # number of days in 400 years
+_DI100Y = _days_before_year(101) # " " " " 100 "
+_DI4Y = _days_before_year(5) # " " " " 4 "
+
+# A 4-year cycle has an extra leap day over what we'd get from pasting
+# together 4 single years.
+assert _DI4Y == 4 * 365 + 1
+
+# Similarly, a 400-year cycle has an extra leap day over what we'd get from
+# pasting together 4 100-year cycles.
+assert _DI400Y == 4 * _DI100Y + 1
+
+# OTOH, a 100-year cycle has one fewer leap day than we'd get from
+# pasting together 25 4-year cycles.
+assert _DI100Y == 25 * _DI4Y - 1
+
+def _ord2ymd(n):
+ "ordinal -> (year, month, day), considering 01-Jan-0001 as day 1."
+
+ # n is a 1-based index, starting at 1-Jan-1. The pattern of leap years
+ # repeats exactly every 400 years. The basic strategy is to find the
+ # closest 400-year boundary at or before n, then work with the offset
+ # from that boundary to n. Life is much clearer if we subtract 1 from
+ # n first -- then the values of n at 400-year boundaries are exactly
+ # those divisible by _DI400Y:
+ #
+ # D M Y n n-1
+ # -- --- ---- ---------- ----------------
+ # 31 Dec -400 -_DI400Y -_DI400Y -1
+ # 1 Jan -399 -_DI400Y +1 -_DI400Y 400-year boundary
+ # ...
+ # 30 Dec 000 -1 -2
+ # 31 Dec 000 0 -1
+ # 1 Jan 001 1 0 400-year boundary
+ # 2 Jan 001 2 1
+ # 3 Jan 001 3 2
+ # ...
+ # 31 Dec 400 _DI400Y _DI400Y -1
+ # 1 Jan 401 _DI400Y +1 _DI400Y 400-year boundary
+ n -= 1
+ n400, n = divmod(n, _DI400Y)
+ year = n400 * 400 + 1 # ..., -399, 1, 401, ...
+
+ # Now n is the (non-negative) offset, in days, from January 1 of year, to
+ # the desired date. Now compute how many 100-year cycles precede n.
+ # Note that it's possible for n100 to equal 4! In that case 4 full
+ # 100-year cycles precede the desired day, which implies the desired
+ # day is December 31 at the end of a 400-year cycle.
+ n100, n = divmod(n, _DI100Y)
+
+ # Now compute how many 4-year cycles precede it.
+ n4, n = divmod(n, _DI4Y)
+
+ # And now how many single years. Again n1 can be 4, and again meaning
+ # that the desired day is December 31 at the end of the 4-year cycle.
+ n1, n = divmod(n, 365)
+
+ year += n100 * 100 + n4 * 4 + n1
+ if n1 == 4 or n100 == 4:
+ assert n == 0
+ return year-1, 12, 31
+
+ # Now the year is correct, and n is the offset from January 1. We find
+ # the month via an estimate that's either exact or one too large.
+ leapyear = n1 == 3 and (n4 != 24 or n100 == 3)
+ assert leapyear == _is_leap(year)
+ month = (n + 50) >> 5
+ preceding = _DAYS_BEFORE_MONTH[month] + (month > 2 and leapyear)
+ if preceding > n: # estimate is too large
+ month -= 1
+ preceding -= _DAYS_IN_MONTH[month] + (month == 2 and leapyear)
+ n -= preceding
+ assert 0 <= n < _days_in_month(year, month)
+
+ # Now the year and month are correct, and n is the offset from the
+ # start of that month: we're done!
+ return year, month, n+1
+
+# Month and day names. For localized versions, see the calendar module.
+_MONTHNAMES = [None, "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+_DAYNAMES = [None, "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
+
+
+def _build_struct_time(y, m, d, hh, mm, ss, dstflag):
+ wday = (_ymd2ord(y, m, d) + 6) % 7
+ dnum = _days_before_month(y, m) + d
+ return _time.struct_time((y, m, d, hh, mm, ss, wday, dnum, dstflag))
+
+def _format_time(hh, mm, ss, us):
+ # Skip trailing microseconds when us==0.
+ result = "%02d:%02d:%02d" % (hh, mm, ss)
+ if us:
+ result += ".%06d" % us
+ return result
+
+# Correctly substitute for %z and %Z escapes in strftime formats.
+def _wrap_strftime(object, format, timetuple):
+ year = timetuple[0]
+ if year < 1000:
+ raise ValueError("year=%d is before 1000; the datetime strftime() "
+ "methods require year >= 1000" % year)
+ # Don't call utcoffset() or tzname() unless actually needed.
+ freplace = None # the string to use for %f
+ zreplace = None # the string to use for %z
+ Zreplace = None # the string to use for %Z
+
+ # Scan format for %z and %Z escapes, replacing as needed.
+ newformat = []
+ push = newformat.append
+ i, n = 0, len(format)
+ while i < n:
+ ch = format[i]
+ i += 1
+ if ch == '%':
+ if i < n:
+ ch = format[i]
+ i += 1
+ if ch == 'f':
+ if freplace is None:
+ freplace = '%06d' % getattr(object,
+ 'microsecond', 0)
+ newformat.append(freplace)
+ elif ch == 'z':
+ if zreplace is None:
+ zreplace = ""
+ if hasattr(object, "utcoffset"):
+ offset = object.utcoffset()
+ if offset is not None:
+ sign = '+'
+ if offset.days < 0:
+ offset = -offset
+ sign = '-'
+ h, m = divmod(offset, timedelta(hours=1))
+ assert not m % timedelta(minutes=1), "whole minute"
+ m //= timedelta(minutes=1)
+ zreplace = '%c%02d%02d' % (sign, h, m)
+ assert '%' not in zreplace
+ newformat.append(zreplace)
+ elif ch == 'Z':
+ if Zreplace is None:
+ Zreplace = ""
+ if hasattr(object, "tzname"):
+ s = object.tzname()
+ if s is not None:
+ # strftime is going to have at this: escape %
+ Zreplace = s.replace('%', '%%')
+ newformat.append(Zreplace)
+ else:
+ push('%')
+ push(ch)
+ else:
+ push('%')
+ else:
+ push(ch)
+ newformat = "".join(newformat)
+ return _time.strftime(newformat, timetuple)
+
+def _call_tzinfo_method(tzinfo, methname, tzinfoarg):
+ if tzinfo is None:
+ return None
+ return getattr(tzinfo, methname)(tzinfoarg)
+
+# Just raise TypeError if the arg isn't None or a string.
+def _check_tzname(name):
+ if name is not None and not isinstance(name, str):
+ raise TypeError("tzinfo.tzname() must return None or string, "
+ "not '%s'" % type(name))
+
+# name is the offset-producing method, "utcoffset" or "dst".
+# offset is what it returned.
+# If offset isn't None or timedelta, raises TypeError.
+# If offset is None, returns None.
+# Else offset is checked for being in range, and a whole # of minutes.
+# If it is, its integer value is returned. Else ValueError is raised.
+def _check_utc_offset(name, offset):
+ assert name in ("utcoffset", "dst")
+ if offset is None:
+ return
+ if not isinstance(offset, timedelta):
+ raise TypeError("tzinfo.%s() must return None "
+ "or timedelta, not '%s'" % (name, type(offset)))
+ if offset % timedelta(minutes=1) or offset.microseconds:
+ raise ValueError("tzinfo.%s() must return a whole number "
+ "of minutes, got %s" % (name, offset))
+ if not -timedelta(1) < offset < timedelta(1):
+ raise ValueError("%s()=%s, must be must be strictly between"
+ " -timedelta(hours=24) and timedelta(hours=24)"
+ % (name, offset))
+
+def _check_date_fields(year, month, day):
+ if not isinstance(year, int):
+ raise TypeError('int expected')
+ if not MINYEAR <= year <= MAXYEAR:
+ raise ValueError('year must be in %d..%d' % (MINYEAR, MAXYEAR), year)
+ if not 1 <= month <= 12:
+ raise ValueError('month must be in 1..12', month)
+ dim = _days_in_month(year, month)
+ if not 1 <= day <= dim:
+ raise ValueError('day must be in 1..%d' % dim, day)
+
+def _check_time_fields(hour, minute, second, microsecond):
+ if not isinstance(hour, int):
+ raise TypeError('int expected')
+ if not 0 <= hour <= 23:
+ raise ValueError('hour must be in 0..23', hour)
+ if not 0 <= minute <= 59:
+ raise ValueError('minute must be in 0..59', minute)
+ if not 0 <= second <= 59:
+ raise ValueError('second must be in 0..59', second)
+ if not 0 <= microsecond <= 999999:
+ raise ValueError('microsecond must be in 0..999999', microsecond)
+
+def _check_tzinfo_arg(tz):
+ if tz is not None and not isinstance(tz, tzinfo):
+ raise TypeError("tzinfo argument must be None or of a tzinfo subclass")
+
+def _cmperror(x, y):
+ raise TypeError("can't compare '%s' to '%s'" % (
+ type(x).__name__, type(y).__name__))
+
+class timedelta:
+ """Represent the difference between two datetime objects.
+
+ Supported operators:
+
+ - add, subtract timedelta
+ - unary plus, minus, abs
+ - compare to timedelta
+ - multiply, divide by int/long
+
+ In addition, datetime supports subtraction of two datetime objects
+ returning a timedelta, and addition or subtraction of a datetime
+ and a timedelta giving a datetime.
+
+ Representation: (days, seconds, microseconds). Why? Because I
+ felt like it.
+ """
+ __slots__ = '_days', '_seconds', '_microseconds'
+
+ def __new__(cls, days=0, seconds=0, microseconds=0,
+ milliseconds=0, minutes=0, hours=0, weeks=0):
+ # Doing this efficiently and accurately in C is going to be difficult
+ # and error-prone, due to ubiquitous overflow possibilities, and that
+ # C double doesn't have enough bits of precision to represent
+ # microseconds over 10K years faithfully. The code here tries to make
+ # explicit where go-fast assumptions can be relied on, in order to
+ # guide the C implementation; it's way more convoluted than speed-
+ # ignoring auto-overflow-to-long idiomatic Python could be.
+
+ # XXX Check that all inputs are ints or floats.
+
+ # Final values, all integer.
+ # s and us fit in 32-bit signed ints; d isn't bounded.
+ d = s = us = 0
+
+ # Normalize everything to days, seconds, microseconds.
+ days += weeks*7
+ seconds += minutes*60 + hours*3600
+ microseconds += milliseconds*1000
+
+ # Get rid of all fractions, and normalize s and us.
+ # Take a deep breath <wink>.
+ if isinstance(days, float):
+ dayfrac, days = _math.modf(days)
+ daysecondsfrac, daysecondswhole = _math.modf(dayfrac * (24.*3600.))
+ assert daysecondswhole == int(daysecondswhole) # can't overflow
+ s = int(daysecondswhole)
+ assert days == int(days)
+ d = int(days)
+ else:
+ daysecondsfrac = 0.0
+ d = days
+ assert isinstance(daysecondsfrac, float)
+ assert abs(daysecondsfrac) <= 1.0
+ assert isinstance(d, int)
+ assert abs(s) <= 24 * 3600
+ # days isn't referenced again before redefinition
+
+ if isinstance(seconds, float):
+ secondsfrac, seconds = _math.modf(seconds)
+ assert seconds == int(seconds)
+ seconds = int(seconds)
+ secondsfrac += daysecondsfrac
+ assert abs(secondsfrac) <= 2.0
+ else:
+ secondsfrac = daysecondsfrac
+ # daysecondsfrac isn't referenced again
+ assert isinstance(secondsfrac, float)
+ assert abs(secondsfrac) <= 2.0
+
+ assert isinstance(seconds, int)
+ days, seconds = divmod(seconds, 24*3600)
+ d += days
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 2 * 24 * 3600
+ # seconds isn't referenced again before redefinition
+
+ usdouble = secondsfrac * 1e6
+ assert abs(usdouble) < 2.1e6 # exact value not critical
+ # secondsfrac isn't referenced again
+
+ if isinstance(microseconds, float):
+ microseconds += usdouble
+ microseconds = round(microseconds, 0)
+ seconds, microseconds = divmod(microseconds, 1e6)
+ assert microseconds == int(microseconds)
+ assert seconds == int(seconds)
+ days, seconds = divmod(seconds, 24.*3600.)
+ assert days == int(days)
+ assert seconds == int(seconds)
+ d += int(days)
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 3 * 24 * 3600
+ else:
+ seconds, microseconds = divmod(microseconds, 1000000)
+ days, seconds = divmod(seconds, 24*3600)
+ d += days
+ s += int(seconds) # can't overflow
+ assert isinstance(s, int)
+ assert abs(s) <= 3 * 24 * 3600
+ microseconds = float(microseconds)
+ microseconds += usdouble
+ microseconds = round(microseconds, 0)
+ assert abs(s) <= 3 * 24 * 3600
+ assert abs(microseconds) < 3.1e6
+
+ # Just a little bit of carrying possible for microseconds and seconds.
+ assert isinstance(microseconds, float)
+ assert int(microseconds) == microseconds
+ us = int(microseconds)
+ seconds, us = divmod(us, 1000000)
+ s += seconds # cant't overflow
+ assert isinstance(s, int)
+ days, s = divmod(s, 24*3600)
+ d += days
+
+ assert isinstance(d, int)
+ assert isinstance(s, int) and 0 <= s < 24*3600
+ assert isinstance(us, int) and 0 <= us < 1000000
+
+ self = object.__new__(cls)
+
+ self._days = d
+ self._seconds = s
+ self._microseconds = us
+ if abs(d) > 999999999:
+ raise OverflowError("timedelta # of days is too large: %d" % d)
+
+ return self
+
+ def __repr__(self):
+ if self._microseconds:
+ return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._days,
+ self._seconds,
+ self._microseconds)
+ if self._seconds:
+ return "%s(%d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._days,
+ self._seconds)
+ return "%s(%d)" % ('datetime.' + self.__class__.__name__, self._days)
+
+ def __str__(self):
+ mm, ss = divmod(self._seconds, 60)
+ hh, mm = divmod(mm, 60)
+ s = "%d:%02d:%02d" % (hh, mm, ss)
+ if self._days:
+ def plural(n):
+ return n, abs(n) != 1 and "s" or ""
+ s = ("%d day%s, " % plural(self._days)) + s
+ if self._microseconds:
+ s = s + ".%06d" % self._microseconds
+ return s
+
+ def total_seconds(self):
+ """Total seconds in the duration."""
+ return ((self.days * 86400 + self.seconds)*10**6 +
+ self.microseconds) / 10**6
+
+ # Read-only field accessors
+ @property
+ def days(self):
+ """days"""
+ return self._days
+
+ @property
+ def seconds(self):
+ """seconds"""
+ return self._seconds
+
+ @property
+ def microseconds(self):
+ """microseconds"""
+ return self._microseconds
+
+ def __add__(self, other):
+ if isinstance(other, timedelta):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days + other._days,
+ self._seconds + other._seconds,
+ self._microseconds + other._microseconds)
+ return NotImplemented
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ if isinstance(other, timedelta):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days - other._days,
+ self._seconds - other._seconds,
+ self._microseconds - other._microseconds)
+ return NotImplemented
+
+ def __rsub__(self, other):
+ if isinstance(other, timedelta):
+ return -self + other
+ return NotImplemented
+
+ def __neg__(self):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(-self._days,
+ -self._seconds,
+ -self._microseconds)
+
+ def __pos__(self):
+ return self
+
+ def __abs__(self):
+ if self._days < 0:
+ return -self
+ else:
+ return self
+
+ def __mul__(self, other):
+ if isinstance(other, int):
+ # for CPython compatibility, we cannot use
+ # our __class__ here, but need a real timedelta
+ return timedelta(self._days * other,
+ self._seconds * other,
+ self._microseconds * other)
+ if isinstance(other, float):
+ a, b = other.as_integer_ratio()
+ return self * a / b
+ return NotImplemented
+
+ __rmul__ = __mul__
+
+ def _to_microseconds(self):
+ return ((self._days * (24*3600) + self._seconds) * 1000000 +
+ self._microseconds)
+
+ def __floordiv__(self, other):
+ if not isinstance(other, (int, timedelta)):
+ return NotImplemented
+ usec = self._to_microseconds()
+ if isinstance(other, timedelta):
+ return usec // other._to_microseconds()
+ if isinstance(other, int):
+ return timedelta(0, 0, usec // other)
+
+ def __truediv__(self, other):
+ if not isinstance(other, (int, float, timedelta)):
+ return NotImplemented
+ usec = self._to_microseconds()
+ if isinstance(other, timedelta):
+ return usec / other._to_microseconds()
+ if isinstance(other, int):
+ return timedelta(0, 0, usec / other)
+ if isinstance(other, float):
+ a, b = other.as_integer_ratio()
+ return timedelta(0, 0, b * usec / a)
+
+ def __mod__(self, other):
+ if isinstance(other, timedelta):
+ r = self._to_microseconds() % other._to_microseconds()
+ return timedelta(0, 0, r)
+ return NotImplemented
+
+ def __divmod__(self, other):
+ if isinstance(other, timedelta):
+ q, r = divmod(self._to_microseconds(),
+ other._to_microseconds())
+ return q, timedelta(0, 0, r)
+ return NotImplemented
+
+ # Comparisons of timedelta objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) == 0
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) != 0
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) <= 0
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) < 0
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) >= 0
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, timedelta):
+ return self._cmp(other) > 0
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, timedelta)
+ return _cmp(self._getstate(), other._getstate())
+
+ def __hash__(self):
+ return hash(self._getstate())
+
+ def __bool__(self):
+ return (self._days != 0 or
+ self._seconds != 0 or
+ self._microseconds != 0)
+
+ # Pickle support.
+
+ def _getstate(self):
+ return (self._days, self._seconds, self._microseconds)
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+timedelta.min = timedelta(-999999999)
+timedelta.max = timedelta(days=999999999, hours=23, minutes=59, seconds=59,
+ microseconds=999999)
+timedelta.resolution = timedelta(microseconds=1)
+
+class date:
+ """Concrete date type.
+
+ Constructors:
+
+ __new__()
+ fromtimestamp()
+ today()
+ fromordinal()
+
+ Operators:
+
+ __repr__, __str__
+ __cmp__, __hash__
+ __add__, __radd__, __sub__ (add/radd only with timedelta arg)
+
+ Methods:
+
+ timetuple()
+ toordinal()
+ weekday()
+ isoweekday(), isocalendar(), isoformat()
+ ctime()
+ strftime()
+
+ Properties (readonly):
+ year, month, day
+ """
+ __slots__ = '_year', '_month', '_day'
+
+ def __new__(cls, year, month=None, day=None):
+ """Constructor.
+
+ Arguments:
+
+ year, month, day (required, base 1)
+ """
+ if (isinstance(year, bytes) and len(year) == 4 and
+ 1 <= year[2] <= 12 and month is None): # Month is sane
+ # Pickle support
+ self = object.__new__(cls)
+ self.__setstate(year)
+ return self
+ _check_date_fields(year, month, day)
+ self = object.__new__(cls)
+ self._year = year
+ self._month = month
+ self._day = day
+ return self
+
+ # Additional constructors
+
+ @classmethod
+ def fromtimestamp(cls, t):
+ "Construct a date from a POSIX timestamp (like time.time())."
+ y, m, d, hh, mm, ss, weekday, jday, dst = _time.localtime(t)
+ return cls(y, m, d)
+
+ @classmethod
+ def today(cls):
+ "Construct a date from time.time()."
+ t = _time.time()
+ return cls.fromtimestamp(t)
+
+ @classmethod
+ def fromordinal(cls, n):
+ """Contruct a date from a proleptic Gregorian ordinal.
+
+ January 1 of year 1 is day 1. Only the year, month and day are
+ non-zero in the result.
+ """
+ y, m, d = _ord2ymd(n)
+ return cls(y, m, d)
+
+ # Conversions to string
+
+ def __repr__(self):
+ """Convert to formal string, for repr().
+
+ >>> dt = datetime(2010, 1, 1)
+ >>> repr(dt)
+ 'datetime.datetime(2010, 1, 1, 0, 0)'
+
+ >>> dt = datetime(2010, 1, 1, tzinfo=timezone.utc)
+ >>> repr(dt)
+ 'datetime.datetime(2010, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)'
+ """
+ return "%s(%d, %d, %d)" % ('datetime.' + self.__class__.__name__,
+ self._year,
+ self._month,
+ self._day)
+ # XXX These shouldn't depend on time.localtime(), because that
+ # clips the usable dates to [1970 .. 2038). At least ctime() is
+ # easily done without using strftime() -- that's better too because
+ # strftime("%c", ...) is locale specific.
+
+
+ def ctime(self):
+ "Return ctime() style string."
+ weekday = self.toordinal() % 7 or 7
+ return "%s %s %2d 00:00:00 %04d" % (
+ _DAYNAMES[weekday],
+ _MONTHNAMES[self._month],
+ self._day, self._year)
+
+ def strftime(self, fmt):
+ "Format using strftime()."
+ return _wrap_strftime(self, fmt, self.timetuple())
+
+ def __format__(self, fmt):
+ if len(fmt) != 0:
+ return self.strftime(fmt)
+ return str(self)
+
+ def isoformat(self):
+ """Return the date formatted according to ISO.
+
+ This is 'YYYY-MM-DD'.
+
+ References:
+ - http://www.w3.org/TR/NOTE-datetime
+ - http://www.cl.cam.ac.uk/~mgk25/iso-time.html
+ """
+ return "%04d-%02d-%02d" % (self._year, self._month, self._day)
+
+ __str__ = isoformat
+
+ # Read-only field accessors
+ @property
+ def year(self):
+ """year (1-9999)"""
+ return self._year
+
+ @property
+ def month(self):
+ """month (1-12)"""
+ return self._month
+
+ @property
+ def day(self):
+ """day (1-31)"""
+ return self._day
+
+ # Standard conversions, __cmp__, __hash__ (and helpers)
+
+ def timetuple(self):
+ "Return local time tuple compatible with time.localtime()."
+ return _build_struct_time(self._year, self._month, self._day,
+ 0, 0, 0, -1)
+
+ def toordinal(self):
+ """Return proleptic Gregorian ordinal for the year, month and day.
+
+ January 1 of year 1 is day 1. Only the year, month and day values
+ contribute to the result.
+ """
+ return _ymd2ord(self._year, self._month, self._day)
+
+ def replace(self, year=None, month=None, day=None):
+ """Return a new date with new values for the specified fields."""
+ if year is None:
+ year = self._year
+ if month is None:
+ month = self._month
+ if day is None:
+ day = self._day
+ _check_date_fields(year, month, day)
+ return date(year, month, day)
+
+ # Comparisons of date objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) == 0
+ return NotImplemented
+
+ def __ne__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) != 0
+ return NotImplemented
+
+ def __le__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) <= 0
+ return NotImplemented
+
+ def __lt__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) < 0
+ return NotImplemented
+
+ def __ge__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) >= 0
+ return NotImplemented
+
+ def __gt__(self, other):
+ if isinstance(other, date):
+ return self._cmp(other) > 0
+ return NotImplemented
+
+ def _cmp(self, other):
+ assert isinstance(other, date)
+ y, m, d = self._year, self._month, self._day
+ y2, m2, d2 = other._year, other._month, other._day
+ return _cmp((y, m, d), (y2, m2, d2))
+
+ def __hash__(self):
+ "Hash."
+ return hash(self._getstate())
+
+ # Computations
+
+ def __add__(self, other):
+ "Add a date to a timedelta."
+ if isinstance(other, timedelta):
+ o = self.toordinal() + other.days
+ if 0 < o <= _MAXORDINAL:
+ return date.fromordinal(o)
+ raise OverflowError("result out of range")
+ return NotImplemented
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ """Subtract two dates, or a date and a timedelta."""
+ if isinstance(other, timedelta):
+ return self + timedelta(-other.days)
+ if isinstance(other, date):
+ days1 = self.toordinal()
+ days2 = other.toordinal()
+ return timedelta(days1 - days2)
+ return NotImplemented
+
+ def weekday(self):
+ "Return day of the week, where Monday == 0 ... Sunday == 6."
+ return (self.toordinal() + 6) % 7
+
+ # Day-of-the-week and week-of-the-year, according to ISO
+
+ def isoweekday(self):
+ "Return day of the week, where Monday == 1 ... Sunday == 7."
+ # 1-Jan-0001 is a Monday
+ return self.toordinal() % 7 or 7
+
+ def isocalendar(self):
+ """Return a 3-tuple containing ISO year, week number, and weekday.
+
+ The first ISO week of the year is the (Mon-Sun) week
+ containing the year's first Thursday; everything else derives
+ from that.
+
+ The first week is 1; Monday is 1 ... Sunday is 7.
+
+ ISO calendar algorithm taken from
+ http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ """
+ year = self._year
+ week1monday = _isoweek1monday(year)
+ today = _ymd2ord(self._year, self._month, self._day)
+ # Internally, week and day have origin 0
+ week, day = divmod(today - week1monday, 7)
+ if week < 0:
+ year -= 1
+ week1monday = _isoweek1monday(year)
+ week, day = divmod(today - week1monday, 7)
+ elif week >= 52:
+ if today >= _isoweek1monday(year+1):
+ year += 1
+ week = 0
+ return year, week+1, day+1
+
+ # Pickle support.
+
+ def _getstate(self):
+ yhi, ylo = divmod(self._year, 256)
+ return bytes([yhi, ylo, self._month, self._day]),
+
+ def __setstate(self, string):
+ if len(string) != 4 or not (1 <= string[2] <= 12):
+ raise TypeError("not enough arguments")
+ yhi, ylo, self._month, self._day = string
+ self._year = yhi * 256 + ylo
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+_date_class = date # so functions w/ args named "date" can get at the class
+
+date.min = date(1, 1, 1)
+date.max = date(9999, 12, 31)
+date.resolution = timedelta(days=1)
+
+class tzinfo:
+ """Abstract base class for time zone info classes.
+
+ Subclasses must override the name(), utcoffset() and dst() methods.
+ """
+ __slots__ = ()
+ def tzname(self, dt):
+ "datetime -> string name of time zone."
+ raise NotImplementedError("tzinfo subclass must override tzname()")
+
+ def utcoffset(self, dt):
+ "datetime -> minutes east of UTC (negative for west of UTC)"
+ raise NotImplementedError("tzinfo subclass must override utcoffset()")
+
+ def dst(self, dt):
+ """datetime -> DST offset in minutes east of UTC.
+
+ Return 0 if DST not in effect. utcoffset() must include the DST
+ offset.
+ """
+ raise NotImplementedError("tzinfo subclass must override dst()")
+
+ def fromutc(self, dt):
+ "datetime in UTC -> datetime in local time."
+
+ if not isinstance(dt, datetime):
+ raise TypeError("fromutc() requires a datetime argument")
+ if dt.tzinfo is not self:
+ raise ValueError("dt.tzinfo is not self")
+
+ dtoff = dt.utcoffset()
+ if dtoff is None:
+ raise ValueError("fromutc() requires a non-None utcoffset() "
+ "result")
+
+ # See the long comment block at the end of this file for an
+ # explanation of this algorithm.
+ dtdst = dt.dst()
+ if dtdst is None:
+ raise ValueError("fromutc() requires a non-None dst() result")
+ delta = dtoff - dtdst
+ if delta:
+ dt += delta
+ dtdst = dt.dst()
+ if dtdst is None:
+ raise ValueError("fromutc(): dt.dst gave inconsistent "
+ "results; cannot convert")
+ return dt + dtdst
+
+ # Pickle support.
+
+ def __reduce__(self):
+ getinitargs = getattr(self, "__getinitargs__", None)
+ if getinitargs:
+ args = getinitargs()
+ else:
+ args = ()
+ getstate = getattr(self, "__getstate__", None)
+ if getstate:
+ state = getstate()
+ else:
+ state = getattr(self, "__dict__", None) or None
+ if state is None:
+ return (self.__class__, args)
+ else:
+ return (self.__class__, args, state)
+
+_tzinfo_class = tzinfo
+
+class time:
+ """Time with time zone.
+
+ Constructors:
+
+ __new__()
+
+ Operators:
+
+ __repr__, __str__
+ __cmp__, __hash__
+
+ Methods:
+
+ strftime()
+ isoformat()
+ utcoffset()
+ tzname()
+ dst()
+
+ Properties (readonly):
+ hour, minute, second, microsecond, tzinfo
+ """
+
+ def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None):
+ """Constructor.
+
+ Arguments:
+
+ hour, minute (required)
+ second, microsecond (default to zero)
+ tzinfo (default to None)
+ """
+ self = object.__new__(cls)
+ if isinstance(hour, bytes) and len(hour) == 6:
+ # Pickle support
+ self.__setstate(hour, minute or None)
+ return self
+ _check_tzinfo_arg(tzinfo)
+ _check_time_fields(hour, minute, second, microsecond)
+ self._hour = hour
+ self._minute = minute
+ self._second = second
+ self._microsecond = microsecond
+ self._tzinfo = tzinfo
+ return self
+
+ # Read-only field accessors
+ @property
+ def hour(self):
+ """hour (0-23)"""
+ return self._hour
+
+ @property
+ def minute(self):
+ """minute (0-59)"""
+ return self._minute
+
+ @property
+ def second(self):
+ """second (0-59)"""
+ return self._second
+
+ @property
+ def microsecond(self):
+ """microsecond (0-999999)"""
+ return self._microsecond
+
+ @property
+ def tzinfo(self):
+ """timezone info object"""
+ return self._tzinfo
+
+ # Standard conversions, __hash__ (and helpers)
+
+ # Comparisons of time objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) == 0
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) != 0
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) <= 0
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) < 0
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) >= 0
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, time):
+ return self._cmp(other) > 0
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, time)
+ mytz = self._tzinfo
+ ottz = other._tzinfo
+ myoff = otoff = None
+
+ if mytz is ottz:
+ base_compare = True
+ else:
+ myoff = self.utcoffset()
+ otoff = other.utcoffset()
+ base_compare = myoff == otoff
+
+ if base_compare:
+ return _cmp((self._hour, self._minute, self._second,
+ self._microsecond),
+ (other._hour, other._minute, other._second,
+ other._microsecond))
+ if myoff is None or otoff is None:
+ raise TypeError("cannot compare naive and aware times")
+ myhhmm = self._hour * 60 + self._minute - myoff//timedelta(minutes=1)
+ othhmm = other._hour * 60 + other._minute - otoff//timedelta(minutes=1)
+ return _cmp((myhhmm, self._second, self._microsecond),
+ (othhmm, other._second, other._microsecond))
+
+ def __hash__(self):
+ """Hash."""
+ tzoff = self.utcoffset()
+ if not tzoff: # zero or None
+ return hash(self._getstate()[0])
+ h, m = divmod(timedelta(hours=self.hour, minutes=self.minute) - tzoff,
+ timedelta(hours=1))
+ assert not m % timedelta(minutes=1), "whole minute"
+ m //= timedelta(minutes=1)
+ if 0 <= h < 24:
+ return hash(time(h, m, self.second, self.microsecond))
+ return hash((h, m, self.second, self.microsecond))
+
+ # Conversion to string
+
+ def _tzstr(self, sep=":"):
+ """Return formatted timezone offset (+xx:xx) or None."""
+ off = self.utcoffset()
+ if off is not None:
+ if off.days < 0:
+ sign = "-"
+ off = -off
+ else:
+ sign = "+"
+ hh, mm = divmod(off, timedelta(hours=1))
+ assert not mm % timedelta(minutes=1), "whole minute"
+ mm //= timedelta(minutes=1)
+ assert 0 <= hh < 24
+ off = "%s%02d%s%02d" % (sign, hh, sep, mm)
+ return off
+
+ def __repr__(self):
+ """Convert to formal string, for repr()."""
+ if self._microsecond != 0:
+ s = ", %d, %d" % (self._second, self._microsecond)
+ elif self._second != 0:
+ s = ", %d" % self._second
+ else:
+ s = ""
+ s= "%s(%d, %d%s)" % ('datetime.' + self.__class__.__name__,
+ self._hour, self._minute, s)
+ if self._tzinfo is not None:
+ assert s[-1:] == ")"
+ s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
+ return s
+
+ def isoformat(self):
+ """Return the time formatted according to ISO.
+
+ This is 'HH:MM:SS.mmmmmm+zz:zz', or 'HH:MM:SS+zz:zz' if
+ self.microsecond == 0.
+ """
+ s = _format_time(self._hour, self._minute, self._second,
+ self._microsecond)
+ tz = self._tzstr()
+ if tz:
+ s += tz
+ return s
+
+ __str__ = isoformat
+
+ def strftime(self, fmt):
+ """Format using strftime(). The date part of the timestamp passed
+ to underlying strftime should not be used.
+ """
+ # The year must be >= 1000 else Python's strftime implementation
+ # can raise a bogus exception.
+ timetuple = (1900, 1, 1,
+ self._hour, self._minute, self._second,
+ 0, 1, -1)
+ return _wrap_strftime(self, fmt, timetuple)
+
+ def __format__(self, fmt):
+ if len(fmt) != 0:
+ return self.strftime(fmt)
+ return str(self)
+
+ # Timezone functions
+
+ def utcoffset(self):
+ """Return the timezone offset in minutes east of UTC (negative west of
+ UTC)."""
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.utcoffset(None)
+ _check_utc_offset("utcoffset", offset)
+ return offset
+
+ def tzname(self):
+ """Return the timezone name.
+
+ Note that the name is 100% informational -- there's no requirement that
+ it mean anything in particular. For example, "GMT", "UTC", "-500",
+ "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
+ """
+ if self._tzinfo is None:
+ return None
+ name = self._tzinfo.tzname(None)
+ _check_tzname(name)
+ return name
+
+ def dst(self):
+ """Return 0 if DST is not in effect, or the DST offset (in minutes
+ eastward) if DST is in effect.
+
+ This is purely informational; the DST offset has already been added to
+ the UTC offset returned by utcoffset() if applicable, so there's no
+ need to consult dst() unless you're interested in displaying the DST
+ info.
+ """
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.dst(None)
+ _check_utc_offset("dst", offset)
+ return offset
+
+ def replace(self, hour=None, minute=None, second=None, microsecond=None,
+ tzinfo=True):
+ """Return a new time with new values for the specified fields."""
+ if hour is None:
+ hour = self.hour
+ if minute is None:
+ minute = self.minute
+ if second is None:
+ second = self.second
+ if microsecond is None:
+ microsecond = self.microsecond
+ if tzinfo is True:
+ tzinfo = self.tzinfo
+ _check_time_fields(hour, minute, second, microsecond)
+ _check_tzinfo_arg(tzinfo)
+ return time(hour, minute, second, microsecond, tzinfo)
+
+ def __bool__(self):
+ if self.second or self.microsecond:
+ return True
+ offset = self.utcoffset() or timedelta(0)
+ return timedelta(hours=self.hour, minutes=self.minute) != offset
+
+ # Pickle support.
+
+ def _getstate(self):
+ us2, us3 = divmod(self._microsecond, 256)
+ us1, us2 = divmod(us2, 256)
+ basestate = bytes([self._hour, self._minute, self._second,
+ us1, us2, us3])
+ if self._tzinfo is None:
+ return (basestate,)
+ else:
+ return (basestate, self._tzinfo)
+
+ def __setstate(self, string, tzinfo):
+ if len(string) != 6 or string[0] >= 24:
+ raise TypeError("an integer is required")
+ (self._hour, self._minute, self._second,
+ us1, us2, us3) = string
+ self._microsecond = (((us1 << 8) | us2) << 8) | us3
+ if tzinfo is None or isinstance(tzinfo, _tzinfo_class):
+ self._tzinfo = tzinfo
+ else:
+ raise TypeError("bad tzinfo state arg %r" % tzinfo)
+
+ def __reduce__(self):
+ return (time, self._getstate())
+
+_time_class = time # so functions w/ args named "time" can get at the class
+
+time.min = time(0, 0, 0)
+time.max = time(23, 59, 59, 999999)
+time.resolution = timedelta(microseconds=1)
+
+class datetime(date):
+ """datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
+
+ The year, month and day arguments are required. tzinfo may be None, or an
+ instance of a tzinfo subclass. The remaining arguments may be ints or longs.
+ """
+
+ __slots__ = date.__slots__ + (
+ '_hour', '_minute', '_second',
+ '_microsecond', '_tzinfo')
+ def __new__(cls, year, month=None, day=None, hour=0, minute=0, second=0,
+ microsecond=0, tzinfo=None):
+ if isinstance(year, bytes) and len(year) == 10:
+ # Pickle support
+ self = date.__new__(cls, year[:4])
+ self.__setstate(year, month)
+ return self
+ _check_tzinfo_arg(tzinfo)
+ _check_time_fields(hour, minute, second, microsecond)
+ self = date.__new__(cls, year, month, day)
+ self._hour = hour
+ self._minute = minute
+ self._second = second
+ self._microsecond = microsecond
+ self._tzinfo = tzinfo
+ return self
+
+ # Read-only field accessors
+ @property
+ def hour(self):
+ """hour (0-23)"""
+ return self._hour
+
+ @property
+ def minute(self):
+ """minute (0-59)"""
+ return self._minute
+
+ @property
+ def second(self):
+ """second (0-59)"""
+ return self._second
+
+ @property
+ def microsecond(self):
+ """microsecond (0-999999)"""
+ return self._microsecond
+
+ @property
+ def tzinfo(self):
+ """timezone info object"""
+ return self._tzinfo
+
+ @classmethod
+ def fromtimestamp(cls, t, tz=None):
+ """Construct a datetime from a POSIX timestamp (like time.time()).
+
+ A timezone info object may be passed in as well.
+ """
+
+ _check_tzinfo_arg(tz)
+
+ converter = _time.localtime if tz is None else _time.gmtime
+
+ t, frac = divmod(t, 1.0)
+ us = round(frac * 1e6)
+
+ # If timestamp is less than one microsecond smaller than a
+ # full second, us can be rounded up to 1000000. In this case,
+ # roll over to seconds, otherwise, ValueError is raised
+ # by the constructor.
+ if us == 1000000:
+ t += 1
+ us = 0
+ y, m, d, hh, mm, ss, weekday, jday, dst = converter(t)
+ ss = min(ss, 59) # clamp out leap seconds if the platform has them
+ result = cls(y, m, d, hh, mm, ss, us, tz)
+ if tz is not None:
+ result = tz.fromutc(result)
+ return result
+
+ @classmethod
+ def utcfromtimestamp(cls, t):
+ "Construct a UTC datetime from a POSIX timestamp (like time.time())."
+ t, frac = divmod(t, 1.0)
+ us = round(frac * 1e6)
+
+ # If timestamp is less than one microsecond smaller than a
+ # full second, us can be rounded up to 1000000. In this case,
+ # roll over to seconds, otherwise, ValueError is raised
+ # by the constructor.
+ if us == 1000000:
+ t += 1
+ us = 0
+ y, m, d, hh, mm, ss, weekday, jday, dst = _time.gmtime(t)
+ ss = min(ss, 59) # clamp out leap seconds if the platform has them
+ return cls(y, m, d, hh, mm, ss, us)
+
+ # XXX This is supposed to do better than we *can* do by using time.time(),
+ # XXX if the platform supports a more accurate way. The C implementation
+ # XXX uses gettimeofday on platforms that have it, but that isn't
+ # XXX available from Python. So now() may return different results
+ # XXX across the implementations.
+ @classmethod
+ def now(cls, tz=None):
+ "Construct a datetime from time.time() and optional time zone info."
+ t = _time.time()
+ return cls.fromtimestamp(t, tz)
+
+ @classmethod
+ def utcnow(cls):
+ "Construct a UTC datetime from time.time()."
+ t = _time.time()
+ return cls.utcfromtimestamp(t)
+
+ @classmethod
+ def combine(cls, date, time):
+ "Construct a datetime from a given date and a given time."
+ if not isinstance(date, _date_class):
+ raise TypeError("date argument must be a date instance")
+ if not isinstance(time, _time_class):
+ raise TypeError("time argument must be a time instance")
+ return cls(date.year, date.month, date.day,
+ time.hour, time.minute, time.second, time.microsecond,
+ time.tzinfo)
+
+ def timetuple(self):
+ "Return local time tuple compatible with time.localtime()."
+ dst = self.dst()
+ if dst is None:
+ dst = -1
+ elif dst:
+ dst = 1
+ else:
+ dst = 0
+ return _build_struct_time(self.year, self.month, self.day,
+ self.hour, self.minute, self.second,
+ dst)
+
+ def utctimetuple(self):
+ "Return UTC time tuple compatible with time.gmtime()."
+ offset = self.utcoffset()
+ if offset:
+ self -= offset
+ y, m, d = self.year, self.month, self.day
+ hh, mm, ss = self.hour, self.minute, self.second
+ return _build_struct_time(y, m, d, hh, mm, ss, 0)
+
+ def date(self):
+ "Return the date part."
+ return date(self._year, self._month, self._day)
+
+ def time(self):
+ "Return the time part, with tzinfo None."
+ return time(self.hour, self.minute, self.second, self.microsecond)
+
+ def timetz(self):
+ "Return the time part, with same tzinfo."
+ return time(self.hour, self.minute, self.second, self.microsecond,
+ self._tzinfo)
+
+ def replace(self, year=None, month=None, day=None, hour=None,
+ minute=None, second=None, microsecond=None, tzinfo=True):
+ """Return a new datetime with new values for the specified fields."""
+ if year is None:
+ year = self.year
+ if month is None:
+ month = self.month
+ if day is None:
+ day = self.day
+ if hour is None:
+ hour = self.hour
+ if minute is None:
+ minute = self.minute
+ if second is None:
+ second = self.second
+ if microsecond is None:
+ microsecond = self.microsecond
+ if tzinfo is True:
+ tzinfo = self.tzinfo
+ _check_date_fields(year, month, day)
+ _check_time_fields(hour, minute, second, microsecond)
+ _check_tzinfo_arg(tzinfo)
+ return datetime(year, month, day, hour, minute, second,
+ microsecond, tzinfo)
+
+ def astimezone(self, tz):
+ if not isinstance(tz, tzinfo):
+ raise TypeError("tz argument must be an instance of tzinfo")
+
+ mytz = self.tzinfo
+ if mytz is None:
+ raise ValueError("astimezone() requires an aware datetime")
+
+ if tz is mytz:
+ return self
+
+ # Convert self to UTC, and attach the new time zone object.
+ myoffset = self.utcoffset()
+ if myoffset is None:
+ raise ValueError("astimezone() requires an aware datetime")
+ utc = (self - myoffset).replace(tzinfo=tz)
+
+ # Convert from UTC to tz's local time.
+ return tz.fromutc(utc)
+
+ # Ways to produce a string.
+
+ def ctime(self):
+ "Return ctime() style string."
+ weekday = self.toordinal() % 7 or 7
+ return "%s %s %2d %02d:%02d:%02d %04d" % (
+ _DAYNAMES[weekday],
+ _MONTHNAMES[self._month],
+ self._day,
+ self._hour, self._minute, self._second,
+ self._year)
+
+ def isoformat(self, sep='T'):
+ """Return the time formatted according to ISO.
+
+ This is 'YYYY-MM-DD HH:MM:SS.mmmmmm', or 'YYYY-MM-DD HH:MM:SS' if
+ self.microsecond == 0.
+
+ If self.tzinfo is not None, the UTC offset is also attached, giving
+ 'YYYY-MM-DD HH:MM:SS.mmmmmm+HH:MM' or 'YYYY-MM-DD HH:MM:SS+HH:MM'.
+
+ Optional argument sep specifies the separator between date and
+ time, default 'T'.
+ """
+ s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day,
+ sep) +
+ _format_time(self._hour, self._minute, self._second,
+ self._microsecond))
+ off = self.utcoffset()
+ if off is not None:
+ if off.days < 0:
+ sign = "-"
+ off = -off
+ else:
+ sign = "+"
+ hh, mm = divmod(off, timedelta(hours=1))
+ assert not mm % timedelta(minutes=1), "whole minute"
+ mm //= timedelta(minutes=1)
+ s += "%s%02d:%02d" % (sign, hh, mm)
+ return s
+
+ def __repr__(self):
+ """Convert to formal string, for repr()."""
+ L = [self._year, self._month, self._day, # These are never zero
+ self._hour, self._minute, self._second, self._microsecond]
+ if L[-1] == 0:
+ del L[-1]
+ if L[-1] == 0:
+ del L[-1]
+ s = ", ".join(map(str, L))
+ s = "%s(%s)" % ('datetime.' + self.__class__.__name__, s)
+ if self._tzinfo is not None:
+ assert s[-1:] == ")"
+ s = s[:-1] + ", tzinfo=%r" % self._tzinfo + ")"
+ return s
+
+ def __str__(self):
+ "Convert to string, for str()."
+ return self.isoformat(sep=' ')
+
+ @classmethod
+ def strptime(cls, date_string, format):
+ 'string, format -> new datetime parsed from a string (like time.strptime()).'
+ import _strptime
+ return _strptime._strptime_datetime(cls, date_string, format)
+
+ def utcoffset(self):
+ """Return the timezone offset in minutes east of UTC (negative west of
+ UTC)."""
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.utcoffset(self)
+ _check_utc_offset("utcoffset", offset)
+ return offset
+
+ def tzname(self):
+ """Return the timezone name.
+
+ Note that the name is 100% informational -- there's no requirement that
+ it mean anything in particular. For example, "GMT", "UTC", "-500",
+ "-5:00", "EDT", "US/Eastern", "America/New York" are all valid replies.
+ """
+ name = _call_tzinfo_method(self._tzinfo, "tzname", self)
+ _check_tzname(name)
+ return name
+
+ def dst(self):
+ """Return 0 if DST is not in effect, or the DST offset (in minutes
+ eastward) if DST is in effect.
+
+ This is purely informational; the DST offset has already been added to
+ the UTC offset returned by utcoffset() if applicable, so there's no
+ need to consult dst() unless you're interested in displaying the DST
+ info.
+ """
+ if self._tzinfo is None:
+ return None
+ offset = self._tzinfo.dst(self)
+ _check_utc_offset("dst", offset)
+ return offset
+
+ # Comparisons of datetime objects with other.
+
+ def __eq__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) == 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ return False
+
+ def __ne__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) != 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ return True
+
+ def __le__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) <= 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __lt__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) < 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __ge__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) >= 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def __gt__(self, other):
+ if isinstance(other, datetime):
+ return self._cmp(other) > 0
+ elif not isinstance(other, date):
+ return NotImplemented
+ else:
+ _cmperror(self, other)
+
+ def _cmp(self, other):
+ assert isinstance(other, datetime)
+ mytz = self._tzinfo
+ ottz = other._tzinfo
+ myoff = otoff = None
+
+ if mytz is ottz:
+ base_compare = True
+ else:
+ if mytz is not None:
+ myoff = self.utcoffset()
+ if ottz is not None:
+ otoff = other.utcoffset()
+ base_compare = myoff == otoff
+
+ if base_compare:
+ return _cmp((self._year, self._month, self._day,
+ self._hour, self._minute, self._second,
+ self._microsecond),
+ (other._year, other._month, other._day,
+ other._hour, other._minute, other._second,
+ other._microsecond))
+ if myoff is None or otoff is None:
+ raise TypeError("cannot compare naive and aware datetimes")
+ # XXX What follows could be done more efficiently...
+ diff = self - other # this will take offsets into account
+ if diff.days < 0:
+ return -1
+ return diff and 1 or 0
+
+ def __add__(self, other):
+ "Add a datetime and a timedelta."
+ if not isinstance(other, timedelta):
+ return NotImplemented
+ delta = timedelta(self.toordinal(),
+ hours=self._hour,
+ minutes=self._minute,
+ seconds=self._second,
+ microseconds=self._microsecond)
+ delta += other
+ hour, rem = divmod(delta.seconds, 3600)
+ minute, second = divmod(rem, 60)
+ if 0 < delta.days <= _MAXORDINAL:
+ return datetime.combine(date.fromordinal(delta.days),
+ time(hour, minute, second,
+ delta.microseconds,
+ tzinfo=self._tzinfo))
+ raise OverflowError("result out of range")
+
+ __radd__ = __add__
+
+ def __sub__(self, other):
+ "Subtract two datetimes, or a datetime and a timedelta."
+ if not isinstance(other, datetime):
+ if isinstance(other, timedelta):
+ return self + -other
+ return NotImplemented
+
+ days1 = self.toordinal()
+ days2 = other.toordinal()
+ secs1 = self._second + self._minute * 60 + self._hour * 3600
+ secs2 = other._second + other._minute * 60 + other._hour * 3600
+ base = timedelta(days1 - days2,
+ secs1 - secs2,
+ self._microsecond - other._microsecond)
+ if self._tzinfo is other._tzinfo:
+ return base
+ myoff = self.utcoffset()
+ otoff = other.utcoffset()
+ if myoff == otoff:
+ return base
+ if myoff is None or otoff is None:
+ raise TypeError("cannot mix naive and timezone-aware time")
+ return base + otoff - myoff
+
+ def __hash__(self):
+ tzoff = self.utcoffset()
+ if tzoff is None:
+ return hash(self._getstate()[0])
+ days = _ymd2ord(self.year, self.month, self.day)
+ seconds = self.hour * 3600 + self.minute * 60 + self.second
+ return hash(timedelta(days, seconds, self.microsecond) - tzoff)
+
+ # Pickle support.
+
+ def _getstate(self):
+ yhi, ylo = divmod(self._year, 256)
+ us2, us3 = divmod(self._microsecond, 256)
+ us1, us2 = divmod(us2, 256)
+ basestate = bytes([yhi, ylo, self._month, self._day,
+ self._hour, self._minute, self._second,
+ us1, us2, us3])
+ if self._tzinfo is None:
+ return (basestate,)
+ else:
+ return (basestate, self._tzinfo)
+
+ def __setstate(self, string, tzinfo):
+ (yhi, ylo, self._month, self._day, self._hour,
+ self._minute, self._second, us1, us2, us3) = string
+ self._year = yhi * 256 + ylo
+ self._microsecond = (((us1 << 8) | us2) << 8) | us3
+ if tzinfo is None or isinstance(tzinfo, _tzinfo_class):
+ self._tzinfo = tzinfo
+ else:
+ raise TypeError("bad tzinfo state arg %r" % tzinfo)
+
+ def __reduce__(self):
+ return (self.__class__, self._getstate())
+
+
+datetime.min = datetime(1, 1, 1)
+datetime.max = datetime(9999, 12, 31, 23, 59, 59, 999999)
+datetime.resolution = timedelta(microseconds=1)
+
+
+def _isoweek1monday(year):
+ # Helper to calculate the day number of the Monday starting week 1
+ # XXX This could be done more efficiently
+ THURSDAY = 3
+ firstday = _ymd2ord(year, 1, 1)
+ firstweekday = (firstday + 6) % 7 # See weekday() above
+ week1monday = firstday - firstweekday
+ if firstweekday > THURSDAY:
+ week1monday += 7
+ return week1monday
+
+class timezone(tzinfo):
+ __slots__ = '_offset', '_name'
+
+ # Sentinel value to disallow None
+ _Omitted = object()
+ def __new__(cls, offset, name=_Omitted):
+ if not isinstance(offset, timedelta):
+ raise TypeError("offset must be a timedelta")
+ if name is cls._Omitted:
+ if not offset:
+ return cls.utc
+ name = None
+ elif not isinstance(name, str):
+ raise TypeError("name must be a string")
+ if not cls._minoffset <= offset <= cls._maxoffset:
+ raise ValueError("offset must be a timedelta"
+ " strictly between -timedelta(hours=24) and"
+ " timedelta(hours=24).")
+ if (offset.microseconds != 0 or
+ offset.seconds % 60 != 0):
+ raise ValueError("offset must be a timedelta"
+ " representing a whole number of minutes")
+ return cls._create(offset, name)
+
+ @classmethod
+ def _create(cls, offset, name=None):
+ self = tzinfo.__new__(cls)
+ self._offset = offset
+ self._name = name
+ return self
+
+ def __getinitargs__(self):
+ """pickle support"""
+ if self._name is None:
+ return (self._offset,)
+ return (self._offset, self._name)
+
+ def __eq__(self, other):
+ if type(other) != timezone:
+ return False
+ return self._offset == other._offset
+
+ def __hash__(self):
+ return hash(self._offset)
+
+ def __repr__(self):
+ """Convert to formal string, for repr().
+
+ >>> tz = timezone.utc
+ >>> repr(tz)
+ 'datetime.timezone.utc'
+ >>> tz = timezone(timedelta(hours=-5), 'EST')
+ >>> repr(tz)
+ "datetime.timezone(datetime.timedelta(-1, 68400), 'EST')"
+ """
+ if self is self.utc:
+ return 'datetime.timezone.utc'
+ if self._name is None:
+ return "%s(%r)" % ('datetime.' + self.__class__.__name__,
+ self._offset)
+ return "%s(%r, %r)" % ('datetime.' + self.__class__.__name__,
+ self._offset, self._name)
+
+ def __str__(self):
+ return self.tzname(None)
+
+ def utcoffset(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ return self._offset
+ raise TypeError("utcoffset() argument must be a datetime instance"
+ " or None")
+
+ def tzname(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ if self._name is None:
+ return self._name_from_offset(self._offset)
+ return self._name
+ raise TypeError("tzname() argument must be a datetime instance"
+ " or None")
+
+ def dst(self, dt):
+ if isinstance(dt, datetime) or dt is None:
+ return None
+ raise TypeError("dst() argument must be a datetime instance"
+ " or None")
+
+ def fromutc(self, dt):
+ if isinstance(dt, datetime):
+ if dt.tzinfo is not self:
+ raise ValueError("fromutc: dt.tzinfo "
+ "is not self")
+ return dt + self._offset
+ raise TypeError("fromutc() argument must be a datetime instance"
+ " or None")
+
+ _maxoffset = timedelta(hours=23, minutes=59)
+ _minoffset = -_maxoffset
+
+ @staticmethod
+ def _name_from_offset(delta):
+ if delta < timedelta(0):
+ sign = '-'
+ delta = -delta
+ else:
+ sign = '+'
+ hours, rest = divmod(delta, timedelta(hours=1))
+ minutes = rest // timedelta(minutes=1)
+ return 'UTC{}{:02d}:{:02d}'.format(sign, hours, minutes)
+
+timezone.utc = timezone._create(timedelta(0))
+timezone.min = timezone._create(timezone._minoffset)
+timezone.max = timezone._create(timezone._maxoffset)
+
+"""
+Some time zone algebra. For a datetime x, let
+ x.n = x stripped of its timezone -- its naive time.
+ x.o = x.utcoffset(), and assuming that doesn't raise an exception or
+ return None
+ x.d = x.dst(), and assuming that doesn't raise an exception or
+ return None
+ x.s = x's standard offset, x.o - x.d
+
+Now some derived rules, where k is a duration (timedelta).
+
+1. x.o = x.s + x.d
+ This follows from the definition of x.s.
+
+2. If x and y have the same tzinfo member, x.s = y.s.
+ This is actually a requirement, an assumption we need to make about
+ sane tzinfo classes.
+
+3. The naive UTC time corresponding to x is x.n - x.o.
+ This is again a requirement for a sane tzinfo class.
+
+4. (x+k).s = x.s
+ This follows from #2, and that datimetimetz+timedelta preserves tzinfo.
+
+5. (x+k).n = x.n + k
+ Again follows from how arithmetic is defined.
+
+Now we can explain tz.fromutc(x). Let's assume it's an interesting case
+(meaning that the various tzinfo methods exist, and don't blow up or return
+None when called).
+
+The function wants to return a datetime y with timezone tz, equivalent to x.
+x is already in UTC.
+
+By #3, we want
+
+ y.n - y.o = x.n [1]
+
+The algorithm starts by attaching tz to x.n, and calling that y. So
+x.n = y.n at the start. Then it wants to add a duration k to y, so that [1]
+becomes true; in effect, we want to solve [2] for k:
+
+ (y+k).n - (y+k).o = x.n [2]
+
+By #1, this is the same as
+
+ (y+k).n - ((y+k).s + (y+k).d) = x.n [3]
+
+By #5, (y+k).n = y.n + k, which equals x.n + k because x.n=y.n at the start.
+Substituting that into [3],
+
+ x.n + k - (y+k).s - (y+k).d = x.n; the x.n terms cancel, leaving
+ k - (y+k).s - (y+k).d = 0; rearranging,
+ k = (y+k).s - (y+k).d; by #4, (y+k).s == y.s, so
+ k = y.s - (y+k).d
+
+On the RHS, (y+k).d can't be computed directly, but y.s can be, and we
+approximate k by ignoring the (y+k).d term at first. Note that k can't be
+very large, since all offset-returning methods return a duration of magnitude
+less than 24 hours. For that reason, if y is firmly in std time, (y+k).d must
+be 0, so ignoring it has no consequence then.
+
+In any case, the new value is
+
+ z = y + y.s [4]
+
+It's helpful to step back at look at [4] from a higher level: it's simply
+mapping from UTC to tz's standard time.
+
+At this point, if
+
+ z.n - z.o = x.n [5]
+
+we have an equivalent time, and are almost done. The insecurity here is
+at the start of daylight time. Picture US Eastern for concreteness. The wall
+time jumps from 1:59 to 3:00, and wall hours of the form 2:MM don't make good
+sense then. The docs ask that an Eastern tzinfo class consider such a time to
+be EDT (because it's "after 2"), which is a redundant spelling of 1:MM EST
+on the day DST starts. We want to return the 1:MM EST spelling because that's
+the only spelling that makes sense on the local wall clock.
+
+In fact, if [5] holds at this point, we do have the standard-time spelling,
+but that takes a bit of proof. We first prove a stronger result. What's the
+difference between the LHS and RHS of [5]? Let
+
+ diff = x.n - (z.n - z.o) [6]
+
+Now
+ z.n = by [4]
+ (y + y.s).n = by #5
+ y.n + y.s = since y.n = x.n
+ x.n + y.s = since z and y are have the same tzinfo member,
+ y.s = z.s by #2
+ x.n + z.s
+
+Plugging that back into [6] gives
+
+ diff =
+ x.n - ((x.n + z.s) - z.o) = expanding
+ x.n - x.n - z.s + z.o = cancelling
+ - z.s + z.o = by #2
+ z.d
+
+So diff = z.d.
+
+If [5] is true now, diff = 0, so z.d = 0 too, and we have the standard-time
+spelling we wanted in the endcase described above. We're done. Contrarily,
+if z.d = 0, then we have a UTC equivalent, and are also done.
+
+If [5] is not true now, diff = z.d != 0, and z.d is the offset we need to
+add to z (in effect, z is in tz's standard time, and we need to shift the
+local clock into tz's daylight time).
+
+Let
+
+ z' = z + z.d = z + diff [7]
+
+and we can again ask whether
+
+ z'.n - z'.o = x.n [8]
+
+If so, we're done. If not, the tzinfo class is insane, according to the
+assumptions we've made. This also requires a bit of proof. As before, let's
+compute the difference between the LHS and RHS of [8] (and skipping some of
+the justifications for the kinds of substitutions we've done several times
+already):
+
+ diff' = x.n - (z'.n - z'.o) = replacing z'.n via [7]
+ x.n - (z.n + diff - z'.o) = replacing diff via [6]
+ x.n - (z.n + x.n - (z.n - z.o) - z'.o) =
+ x.n - z.n - x.n + z.n - z.o + z'.o = cancel x.n
+ - z.n + z.n - z.o + z'.o = cancel z.n
+ - z.o + z'.o = #1 twice
+ -z.s - z.d + z'.s + z'.d = z and z' have same tzinfo
+ z'.d - z.d
+
+So z' is UTC-equivalent to x iff z'.d = z.d at this point. If they are equal,
+we've found the UTC-equivalent so are done. In fact, we stop with [7] and
+return z', not bothering to compute z'.d.
+
+How could z.d and z'd differ? z' = z + z.d [7], so merely moving z' by
+a dst() offset, and starting *from* a time already in DST (we know z.d != 0),
+would have to change the result dst() returns: we start in DST, and moving
+a little further into it takes us out of DST.
+
+There isn't a sane case where this can happen. The closest it gets is at
+the end of DST, where there's an hour in UTC with no spelling in a hybrid
+tzinfo class. In US Eastern, that's 5:MM UTC = 0:MM EST = 1:MM EDT. During
+that hour, on an Eastern clock 1:MM is taken as being in standard time (6:MM
+UTC) because the docs insist on that, but 0:MM is taken as being in daylight
+time (4:MM UTC). There is no local time mapping to 5:MM UTC. The local
+clock jumps from 1:59 back to 1:00 again, and repeats the 1:MM hour in
+standard time. Since that's what the local clock *does*, we want to map both
+UTC hours 5:MM and 6:MM to 1:MM Eastern. The result is ambiguous
+in local time, but so it goes -- it's the way the local clock works.
+
+When x = 5:MM UTC is the input to this algorithm, x.o=0, y.o=-5 and y.d=0,
+so z=0:MM. z.d=60 (minutes) then, so [5] doesn't hold and we keep going.
+z' = z + z.d = 1:MM then, and z'.d=0, and z'.d - z.d = -60 != 0 so [8]
+(correctly) concludes that z' is not UTC-equivalent to x.
+
+Because we know z.d said z was in daylight time (else [5] would have held and
+we would have stopped then), and we know z.d != z'.d (else [8] would have held
+and we have stopped then), and there are only 2 possible values dst() can
+return in Eastern, it follows that z'.d must be 0 (which it is in the example,
+but the reasoning doesn't depend on the example -- it depends on there being
+two possible dst() outcomes, one zero and the other non-zero). Therefore
+z' must be in standard time, and is the spelling we want in this case.
+
+Note again that z' is not UTC-equivalent as far as the hybrid tzinfo class is
+concerned (because it takes z' as being in standard time rather than the
+daylight time we intend here), but returning it gives the real-life "local
+clock repeats an hour" behavior when mapping the "unspellable" UTC hour into
+tz.
+
+When the input is 6:MM, z=1:MM and z.d=0, and we stop at once, again with
+the 1:MM standard time spelling we want.
+
+So how can this break? One of the assumptions must be violated. Two
+possibilities:
+
+1) [2] effectively says that y.s is invariant across all y belong to a given
+ time zone. This isn't true if, for political reasons or continental drift,
+ a region decides to change its base offset from UTC.
+
+2) There may be versions of "double daylight" time where the tail end of
+ the analysis gives up a step too early. I haven't thought about that
+ enough to say.
+
+In any case, it's clear that the default fromutc() is strong enough to handle
+"almost all" time zones: so long as the standard offset is invariant, it
+doesn't matter if daylight time transition points change from year to year, or
+if daylight time is skipped in some years; it doesn't matter how large or
+small dst() may get within its bounds; and it doesn't even matter if some
+perverse time zone returns a negative dst()). So a breaking case must be
+pretty bizarre, and a tzinfo subclass can override fromutc() if it is.
+"""
+try:
+ from _datetime import *
+except ImportError:
+ pass
+else:
+ # Clean up unused names
+ del (_DAYNAMES, _DAYS_BEFORE_MONTH, _DAYS_IN_MONTH,
+ _DI100Y, _DI400Y, _DI4Y, _MAXORDINAL, _MONTHNAMES,
+ _build_struct_time, _call_tzinfo_method, _check_date_fields,
+ _check_time_fields, _check_tzinfo_arg, _check_tzname,
+ _check_utc_offset, _cmp, _cmperror, _date_class, _days_before_month,
+ _days_before_year, _days_in_month, _format_time, _is_leap,
+ _isoweek1monday, _math, _ord2ymd, _time, _time_class, _tzinfo_class,
+ _wrap_strftime, _ymd2ord)
+ # XXX Since import * above excludes names that start with _,
+ # docstring does not get overwritten. In the future, it may be
+ # appropriate to maintain a single module level docstring and
+ # remove the following line.
+ from _datetime import __doc__
diff --git a/Lib/dbhash.py b/Lib/dbhash.py
deleted file mode 100644
index a5d5375ba94..00000000000
--- a/Lib/dbhash.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""Provide a (g)dbm-compatible interface to bsddb.hashopen."""
-
-import sys
-import warnings
-warnings.warnpy3k("in 3.x, the dbhash module has been removed", stacklevel=2)
-try:
- import bsddb
-except ImportError:
- # prevent a second import of this module from spuriously succeeding
- del sys.modules[__name__]
- raise
-
-__all__ = ["error","open"]
-
-error = bsddb.error # Exported for anydbm
-
-def open(file, flag = 'r', mode=0666):
- return bsddb.hashopen(file, flag, mode)
diff --git a/Lib/dbm/__init__.py b/Lib/dbm/__init__.py
new file mode 100644
index 00000000000..813a29d7092
--- /dev/null
+++ b/Lib/dbm/__init__.py
@@ -0,0 +1,185 @@
+"""Generic interface to all dbm clones.
+
+Use
+
+ import dbm
+ d = dbm.open(file, 'w', 0o666)
+
+The returned object is a dbm.gnu, dbm.ndbm or dbm.dumb object, dependent on the
+type of database being opened (determined by the whichdb function) in the case
+of an existing dbm. If the dbm does not exist and the create or new flag ('c'
+or 'n') was specified, the dbm type will be determined by the availability of
+the modules (tested in the above order).
+
+It has the following interface (key and data are strings):
+
+ d[key] = data # store data at key (may override data at
+ # existing key)
+ data = d[key] # retrieve data at key (raise KeyError if no
+ # such key)
+ del d[key] # delete data stored at key (raises KeyError
+ # if no such key)
+ flag = key in d # true if the key exists
+ list = d.keys() # return a list of all existing keys (slow!)
+
+Future versions may change the order in which implementations are
+tested for existence, and add interfaces to other dbm-like
+implementations.
+"""
+
+__all__ = ['open', 'whichdb', 'error']
+
+import io
+import os
+import struct
+import sys
+
+
+class error(Exception):
+ pass
+
+_names = ['dbm.gnu', 'dbm.ndbm', 'dbm.dumb']
+_defaultmod = None
+_modules = {}
+
+error = (error, IOError)
+
+
+def open(file, flag='r', mode=0o666):
+ """Open or create database at path given by *file*.
+
+ Optional argument *flag* can be 'r' (default) for read-only access, 'w'
+ for read-write access of an existing database, 'c' for read-write access
+ to a new or existing database, and 'n' for read-write access to a new
+ database.
+
+ Note: 'r' and 'w' fail if the database doesn't exist; 'c' creates it
+ only if it doesn't exist; and 'n' always creates a new database.
+ """
+ global _defaultmod
+ if _defaultmod is None:
+ for name in _names:
+ try:
+ mod = __import__(name, fromlist=['open'])
+ except ImportError:
+ continue
+ if not _defaultmod:
+ _defaultmod = mod
+ _modules[name] = mod
+ if not _defaultmod:
+ raise ImportError("no dbm clone found; tried %s" % _names)
+
+ # guess the type of an existing database, if not creating a new one
+ result = whichdb(file) if 'n' not in flag else None
+ if result is None:
+ # db doesn't exist or 'n' flag was specified to create a new db
+ if 'c' in flag or 'n' in flag:
+ # file doesn't exist and the new flag was used so use default type
+ mod = _defaultmod
+ else:
+ raise error[0]("need 'c' or 'n' flag to open new db")
+ elif result == "":
+ # db type cannot be determined
+ raise error[0]("db type could not be determined")
+ elif result not in _modules:
+ raise error[0]("db type is {0}, but the module is not "
+ "available".format(result))
+ else:
+ mod = _modules[result]
+ return mod.open(file, flag, mode)
+
+
+def whichdb(filename):
+ """Guess which db package to use to open a db file.
+
+ Return values:
+
+ - None if the database file can't be read;
+ - empty string if the file can be read but can't be recognized
+ - the name of the dbm submodule (e.g. "ndbm" or "gnu") if recognized.
+
+ Importing the given module may still fail, and opening the
+ database using that module may still fail.
+ """
+
+ # Check for ndbm first -- this has a .pag and a .dir file
+ try:
+ f = io.open(filename + ".pag", "rb")
+ f.close()
+ # dbm linked with gdbm on OS/2 doesn't have .dir file
+ if not (ndbm.library == "GNU gdbm" and sys.platform == "os2emx"):
+ f = io.open(filename + ".dir", "rb")
+ f.close()
+ return "dbm.ndbm"
+ except IOError:
+ # some dbm emulations based on Berkeley DB generate a .db file
+ # some do not, but they should be caught by the bsd checks
+ try:
+ f = io.open(filename + ".db", "rb")
+ f.close()
+ # guarantee we can actually open the file using dbm
+ # kind of overkill, but since we are dealing with emulations
+ # it seems like a prudent step
+ if ndbm is not None:
+ d = ndbm.open(filename)
+ d.close()
+ return "dbm.ndbm"
+ except IOError:
+ pass
+
+ # Check for dumbdbm next -- this has a .dir and a .dat file
+ try:
+ # First check for presence of files
+ os.stat(filename + ".dat")
+ size = os.stat(filename + ".dir").st_size
+ # dumbdbm files with no keys are empty
+ if size == 0:
+ return "dbm.dumb"
+ f = io.open(filename + ".dir", "rb")
+ try:
+ if f.read(1) in (b"'", b'"'):
+ return "dbm.dumb"
+ finally:
+ f.close()
+ except (OSError, IOError):
+ pass
+
+ # See if the file exists, return None if not
+ try:
+ f = io.open(filename, "rb")
+ except IOError:
+ return None
+
+ # Read the start of the file -- the magic number
+ s16 = f.read(16)
+ f.close()
+ s = s16[0:4]
+
+ # Return "" if not at least 4 bytes
+ if len(s) != 4:
+ return ""
+
+ # Convert to 4-byte int in native byte order -- return "" if impossible
+ try:
+ (magic,) = struct.unpack("=l", s)
+ except struct.error:
+ return ""
+
+ # Check for GNU dbm
+ if magic in (0x13579ace, 0x13579acd, 0x13579acf):
+ return "dbm.gnu"
+
+ # Later versions of Berkeley db hash file have a 12-byte pad in
+ # front of the file type
+ try:
+ (magic,) = struct.unpack("=l", s16[-4:])
+ except struct.error:
+ return ""
+
+ # Unknown
+ return ""
+
+
+if __name__ == "__main__":
+ for filename in sys.argv[1:]:
+ print(whichdb(filename) or "UNKNOWN", filename)
diff --git a/Lib/dumbdbm.py b/Lib/dbm/dumb.py
index fb54a93041b..cfb912371c9 100644
--- a/Lib/dumbdbm.py
+++ b/Lib/dbm/dumb.py
@@ -21,17 +21,17 @@ is read when the database is opened, and some updates rewrite the whole index)
"""
+import io as _io
import os as _os
-import __builtin__
-import UserDict
+import collections
-_open = __builtin__.open
+__all__ = ["error", "open"]
_BLOCKSIZE = 512
-error = IOError # For anydbm
+error = IOError
-class _Database(UserDict.DictMixin):
+class _Database(collections.MutableMapping):
# The on-disk directory and data files can remain in mutually
# inconsistent states for an arbitrarily long time (see comments
@@ -42,7 +42,7 @@ class _Database(UserDict.DictMixin):
# _commit() finish successfully, we can't ignore shutdown races
# here, and _commit() must not reference any globals.
_os = _os # for _commit()
- _open = _open # for _commit()
+ _io = _io # for _commit()
def __init__(self, filebasename, mode):
self._mode = mode
@@ -52,23 +52,23 @@ class _Database(UserDict.DictMixin):
# where key is the string key, pos is the offset into the dat
# file of the associated value's first byte, and siz is the number
# of bytes in the associated value.
- self._dirfile = filebasename + _os.extsep + 'dir'
+ self._dirfile = filebasename + '.dir'
# The data file is a binary file pointed into by the directory
# file, and holds the values associated with keys. Each value
# begins at a _BLOCKSIZE-aligned byte offset, and is a raw
# binary 8-bit string value.
- self._datfile = filebasename + _os.extsep + 'dat'
- self._bakfile = filebasename + _os.extsep + 'bak'
+ self._datfile = filebasename + '.dat'
+ self._bakfile = filebasename + '.bak'
# The index is an in-memory dict, mirroring the directory file.
self._index = None # maps keys to (pos, siz) pairs
# Mod by Jack: create data file if needed
try:
- f = _open(self._datfile, 'r')
+ f = _io.open(self._datfile, 'r', encoding="Latin-1")
except IOError:
- f = _open(self._datfile, 'w')
+ f = _io.open(self._datfile, 'w', encoding="Latin-1")
self._chmod(self._datfile)
f.close()
self._update()
@@ -77,13 +77,14 @@ class _Database(UserDict.DictMixin):
def _update(self):
self._index = {}
try:
- f = _open(self._dirfile)
+ f = _io.open(self._dirfile, 'r', encoding="Latin-1")
except IOError:
pass
else:
for line in f:
line = line.rstrip()
key, pos_and_siz_pair = eval(line)
+ key = key.encode('Latin-1')
self._index[key] = pos_and_siz_pair
f.close()
@@ -107,17 +108,21 @@ class _Database(UserDict.DictMixin):
except self._os.error:
pass
- f = self._open(self._dirfile, 'w')
+ f = self._io.open(self._dirfile, 'w', encoding="Latin-1")
self._chmod(self._dirfile)
- for key, pos_and_siz_pair in self._index.iteritems():
- f.write("%r, %r\n" % (key, pos_and_siz_pair))
+ for key, pos_and_siz_pair in self._index.items():
+ # Use Latin-1 since it has no qualms with any value in any
+ # position; UTF-8, though, does care sometimes.
+ f.write("%r, %r\n" % (key.decode('Latin-1'), pos_and_siz_pair))
f.close()
sync = _commit
def __getitem__(self, key):
+ if isinstance(key, str):
+ key = key.encode('utf-8')
pos, siz = self._index[key] # may raise KeyError
- f = _open(self._datfile, 'rb')
+ f = _io.open(self._datfile, 'rb')
f.seek(pos)
dat = f.read(siz)
f.close()
@@ -128,11 +133,11 @@ class _Database(UserDict.DictMixin):
# to get to an aligned offset. Return pair
# (starting offset of val, len(val))
def _addval(self, val):
- f = _open(self._datfile, 'rb+')
+ f = _io.open(self._datfile, 'rb+')
f.seek(0, 2)
pos = int(f.tell())
npos = ((pos + _BLOCKSIZE - 1) // _BLOCKSIZE) * _BLOCKSIZE
- f.write('\0'*(npos-pos))
+ f.write(b'\0'*(npos-pos))
pos = npos
f.write(val)
f.close()
@@ -143,7 +148,7 @@ class _Database(UserDict.DictMixin):
# pos to hold val, without overwriting some other value. Return
# pair (pos, len(val)).
def _setval(self, pos, val):
- f = _open(self._datfile, 'rb+')
+ f = _io.open(self._datfile, 'rb+')
f.seek(pos)
f.write(val)
f.close()
@@ -154,14 +159,20 @@ class _Database(UserDict.DictMixin):
# 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
- f = _open(self._dirfile, 'a')
+ f = _io.open(self._dirfile, 'a', encoding="Latin-1")
self._chmod(self._dirfile)
- f.write("%r, %r\n" % (key, pos_and_siz_pair))
+ f.write("%r, %r\n" % (key.decode("Latin-1"), pos_and_siz_pair))
f.close()
def __setitem__(self, key, val):
- if not type(key) == type('') == type(val):
- raise TypeError, "keys and values must be strings"
+ if isinstance(key, str):
+ key = key.encode('utf-8')
+ elif not isinstance(key, (bytes, bytearray)):
+ raise TypeError("keys must be bytes or strings")
+ if isinstance(val, str):
+ val = val.encode('utf-8')
+ elif not isinstance(val, (bytes, bytearray)):
+ raise TypeError("values must be bytes or strings")
if key not in self._index:
self._addkey(key, self._addval(val))
else:
@@ -187,25 +198,29 @@ class _Database(UserDict.DictMixin):
# (so that _commit() never gets called).
def __delitem__(self, key):
+ if isinstance(key, str):
+ key = key.encode('utf-8')
# The blocks used by the associated value are lost.
del self._index[key]
# XXX It's unclear why we do a _commit() here (the code always
- # XXX has, so I'm not changing it). _setitem__ doesn't try to
+ # XXX has, so I'm not changing it). __setitem__ doesn't try to
# XXX keep the directory file in synch. Why should we? Or
# XXX why shouldn't __setitem__?
self._commit()
def keys(self):
- return self._index.keys()
+ return list(self._index.keys())
- def has_key(self, key):
- return key in self._index
+ def items(self):
+ return [(key, self[key]) for key in self._index.keys()]
def __contains__(self, key):
+ if isinstance(key, str):
+ key = key.encode('utf-8')
return key in self._index
def iterkeys(self):
- return self._index.iterkeys()
+ return iter(self._index.keys())
__iter__ = iterkeys
def __len__(self):
@@ -217,21 +232,21 @@ class _Database(UserDict.DictMixin):
__del__ = close
- def _chmod (self, file):
+ def _chmod(self, file):
if hasattr(self._os, 'chmod'):
self._os.chmod(file, self._mode)
-def open(file, flag=None, mode=0666):
+def open(file, flag=None, mode=0o666):
"""Open the database file, filename, and return corresponding object.
The flag argument, used to control how the database is opened in the
- other DBM implementations, is ignored in the dumbdbm module; the
+ other DBM implementations, is ignored in the dbm.dumb module; the
database is always opened for update, and will be created if it does
not exist.
The optional mode argument is the UNIX mode of the file, used only when
- the database has to be created. It defaults to octal code 0666 (and
+ the database has to be created. It defaults to octal code 0o666 (and
will be modified by the prevailing umask).
"""
diff --git a/Lib/dbm/gnu.py b/Lib/dbm/gnu.py
new file mode 100644
index 00000000000..b07a1defffd
--- /dev/null
+++ b/Lib/dbm/gnu.py
@@ -0,0 +1,3 @@
+"""Provide the _gdbm module as a dbm submodule."""
+
+from _gdbm import *
diff --git a/Lib/dbm/ndbm.py b/Lib/dbm/ndbm.py
new file mode 100644
index 00000000000..23056a29ef2
--- /dev/null
+++ b/Lib/dbm/ndbm.py
@@ -0,0 +1,3 @@
+"""Provide the _dbm module as a dbm submodule."""
+
+from _dbm import *
diff --git a/Lib/decimal.py b/Lib/decimal.py
index 361126f6d0e..49de53592fc 100644
--- a/Lib/decimal.py
+++ b/Lib/decimal.py
@@ -7,18 +7,14 @@
# and Aahz <aahz at pobox.com>
# and Tim Peters
-# This module is currently Py2.3 compatible and should be kept that way
-# unless a major compelling advantage arises. IOW, 2.3 compatibility is
-# strongly preferred, but not guaranteed.
-
-# Also, this module should be kept in sync with the latest updates of
-# the IBM specification as it evolves. Those updates will be treated
+# This module should be kept in sync with the latest updates of the
+# IBM specification as it evolves. Those updates will be treated
# as bug fixes (deviation from the spec is a compatibility, usability
# bug) and will be backported. At this point the spec is stabilizing
# and the updates are becoming fewer, smaller, and less significant.
"""
-This is a Py2.3 implementation of decimal floating point arithmetic based on
+This is an implementation of decimal floating point arithmetic based on
the General Decimal Arithmetic Specification:
http://speleotrove.com/decimal/decarith.html
@@ -35,7 +31,8 @@ issues associated with binary floating point. The package is especially
useful for financial applications or for contexts where users have
expectations that are at odds with binary floating point (for instance,
in binary floating point, 1.00 % 0.1 gives 0.09999999999999995 instead
-of the expected Decimal('0.00') returned by decimal floating point).
+of 0.0; Decimal('1.00') % Decimal('0.1') returns the expected
+Decimal('0.00')).
Here are some examples of using the decimal module:
@@ -56,61 +53,61 @@ Decimal('2.60')
>>> Decimal('12.34') + Decimal('3.87') - Decimal('18.41')
Decimal('-2.20')
>>> dig = Decimal(1)
->>> print dig / Decimal(3)
+>>> print(dig / Decimal(3))
0.333333333
>>> getcontext().prec = 18
->>> print dig / Decimal(3)
+>>> print(dig / Decimal(3))
0.333333333333333333
->>> print dig.sqrt()
+>>> print(dig.sqrt())
1
->>> print Decimal(3).sqrt()
+>>> print(Decimal(3).sqrt())
1.73205080756887729
->>> print Decimal(3) ** 123
+>>> print(Decimal(3) ** 123)
4.85192780976896427E+58
>>> inf = Decimal(1) / Decimal(0)
->>> print inf
+>>> print(inf)
Infinity
>>> neginf = Decimal(-1) / Decimal(0)
->>> print neginf
+>>> print(neginf)
-Infinity
->>> print neginf + inf
+>>> print(neginf + inf)
NaN
->>> print neginf * inf
+>>> print(neginf * inf)
-Infinity
->>> print dig / 0
+>>> print(dig / 0)
Infinity
>>> getcontext().traps[DivisionByZero] = 1
->>> print dig / 0
+>>> print(dig / 0)
Traceback (most recent call last):
...
...
...
-DivisionByZero: x / 0
+decimal.DivisionByZero: x / 0
>>> c = Context()
>>> c.traps[InvalidOperation] = 0
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
0
>>> c.divide(Decimal(0), Decimal(0))
Decimal('NaN')
>>> c.traps[InvalidOperation] = 1
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
0
->>> print c.divide(Decimal(0), Decimal(0))
+>>> print(c.divide(Decimal(0), Decimal(0)))
Traceback (most recent call last):
...
...
...
-InvalidOperation: 0 / 0
->>> print c.flags[InvalidOperation]
+decimal.InvalidOperation: 0 / 0
+>>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
>>> c.traps[InvalidOperation] = 0
->>> print c.divide(Decimal(0), Decimal(0))
+>>> print(c.divide(Decimal(0), Decimal(0)))
NaN
->>> print c.flags[InvalidOperation]
+>>> print(c.flags[InvalidOperation])
1
>>>
"""
@@ -135,6 +132,7 @@ __all__ = [
]
__version__ = '1.70' # Highest version of the spec this complies with
+ # See http://speleotrove.com/decimal/
import copy as _copy
import math as _math
@@ -386,7 +384,7 @@ _condition_map = {ConversionSyntax:InvalidOperation,
# The getcontext() and setcontext() function manage access to a thread-local
# current context. Py2.4 offers direct support for thread locals. If that
-# is not available, use threading.currentThread() which is slower but will
+# is not available, use threading.current_thread() which is slower but will
# work for older Pythons. If threads are not part of the build, create a
# mock threading object with threading.local() returning the module namespace.
@@ -408,15 +406,15 @@ except AttributeError:
# To fix reloading, force it to create a new context
# Old contexts have different exceptions in their dicts, making problems.
- if hasattr(threading.currentThread(), '__decimal_context__'):
- del threading.currentThread().__decimal_context__
+ if hasattr(threading.current_thread(), '__decimal_context__'):
+ del threading.current_thread().__decimal_context__
def setcontext(context):
"""Set this thread's context to context."""
if context in (DefaultContext, BasicContext, ExtendedContext):
context = context.copy()
context.clear_flags()
- threading.currentThread().__decimal_context__ = context
+ threading.current_thread().__decimal_context__ = context
def getcontext():
"""Returns this thread's context.
@@ -426,10 +424,10 @@ except AttributeError:
New contexts are copies of DefaultContext.
"""
try:
- return threading.currentThread().__decimal_context__
+ return threading.current_thread().__decimal_context__
except AttributeError:
context = Context()
- threading.currentThread().__decimal_context__ = context
+ threading.current_thread().__decimal_context__ = context
return context
else:
@@ -482,19 +480,19 @@ def localcontext(ctx=None):
return +s # Convert result to normal context
>>> setcontext(DefaultContext)
- >>> print getcontext().prec
+ >>> print(getcontext().prec)
28
>>> with localcontext():
... ctx = getcontext()
... ctx.prec += 2
- ... print ctx.prec
+ ... print(ctx.prec)
...
30
>>> with localcontext(ExtendedContext):
- ... print getcontext().prec
+ ... print(getcontext().prec)
...
9
- >>> print getcontext().prec
+ >>> print(getcontext().prec)
28
"""
if ctx is None: ctx = getcontext()
@@ -503,6 +501,10 @@ def localcontext(ctx=None):
##### Decimal class #######################################################
+# Do not subclass Decimal from numbers.Real and do not register it as such
+# (because Decimals are not interoperable with floats). See the notes in
+# numbers.py for more detail.
+
class Decimal(object):
"""Floating point class for decimal arithmetic."""
@@ -519,7 +521,7 @@ class Decimal(object):
Decimal('3.14')
>>> Decimal((0, (3, 1, 4), -2)) # tuple (sign, digit_tuple, exponent)
Decimal('3.14')
- >>> Decimal(314) # int or long
+ >>> Decimal(314) # int
Decimal('314')
>>> Decimal(Decimal(314)) # another decimal instance
Decimal('314')
@@ -539,7 +541,7 @@ class Decimal(object):
# From a string
# REs insist on real strings, so we can too.
- if isinstance(value, basestring):
+ if isinstance(value, str):
m = _parser(value.strip())
if m is None:
if context is None:
@@ -576,7 +578,7 @@ class Decimal(object):
return self
# From an integer
- if isinstance(value, (int,long)):
+ if isinstance(value, int):
if value >= 0:
self._sign = 0
else:
@@ -609,7 +611,7 @@ class Decimal(object):
'from list or tuple. The list or tuple '
'should have exactly three elements.')
# process sign. The isinstance test rejects floats
- if not (isinstance(value[0], (int, long)) and value[0] in (0,1)):
+ if not (isinstance(value[0], int) and value[0] in (0,1)):
raise ValueError("Invalid sign. The first value in the tuple "
"should be an integer; either 0 for a "
"positive number or 1 for a negative number.")
@@ -623,7 +625,7 @@ class Decimal(object):
# process and validate the digits in value[1]
digits = []
for digit in value[1]:
- if isinstance(digit, (int, long)) and 0 <= digit <= 9:
+ if isinstance(digit, int) and 0 <= digit <= 9:
# skip leading zeros
if digits or digit != 0:
digits.append(digit)
@@ -636,7 +638,7 @@ class Decimal(object):
self._int = ''.join(map(str, digits))
self._exp = value[2]
self._is_special = True
- elif isinstance(value[2], (int, long)):
+ elif isinstance(value[2], int):
# finite number: digits give the coefficient
self._int = ''.join(map(str, digits or [0]))
self._exp = value[2]
@@ -680,7 +682,7 @@ class Decimal(object):
Decimal('-0')
"""
- if isinstance(f, (int, long)): # handle integer inputs
+ if isinstance(f, int): # handle integer inputs
return cls(f)
if _math.isinf(f) or _math.isnan(f): # raises TypeError if not a float
return cls(repr(f))
@@ -790,7 +792,7 @@ class Decimal(object):
other)
return 0
- def __nonzero__(self):
+ def __bool__(self):
"""Return True if self is nonzero; otherwise return False.
NaNs and infinities are considered nonzero.
@@ -862,7 +864,7 @@ class Decimal(object):
# that specified by IEEE 754.
def __eq__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other, equality_op=True)
if other is NotImplemented:
return other
if self._check_nans(other, context):
@@ -870,15 +872,16 @@ class Decimal(object):
return self._cmp(other) == 0
def __ne__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other, equality_op=True)
if other is NotImplemented:
return other
if self._check_nans(other, context):
return True
return self._cmp(other) != 0
+
def __lt__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -887,7 +890,7 @@ class Decimal(object):
return self._cmp(other) < 0
def __le__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -896,7 +899,7 @@ class Decimal(object):
return self._cmp(other) <= 0
def __gt__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -905,7 +908,7 @@ class Decimal(object):
return self._cmp(other) > 0
def __ge__(self, other, context=None):
- other = _convert_other(other, allow_float=True)
+ self, other = _convert_for_comparison(self, other)
if other is NotImplemented:
return other
ans = self._compare_check_nans(other, context)
@@ -934,55 +937,29 @@ class Decimal(object):
def __hash__(self):
"""x.__hash__() <==> hash(x)"""
- # Decimal integers must hash the same as the ints
- #
- # The hash of a nonspecial noninteger Decimal must depend only
- # on the value of that Decimal, and not on its representation.
- # For example: hash(Decimal('100E-1')) == hash(Decimal('10')).
-
- # Equality comparisons involving signaling nans can raise an
- # exception; since equality checks are implicitly and
- # unpredictably used when checking set and dict membership, we
- # prevent signaling nans from being used as set elements or
- # dict keys by making __hash__ raise an exception.
+
+ # In order to make sure that the hash of a Decimal instance
+ # agrees with the hash of a numerically equal integer, float
+ # or Fraction, we follow the rules for numeric hashes outlined
+ # in the documentation. (See library docs, 'Built-in Types').
if self._is_special:
if self.is_snan():
raise TypeError('Cannot hash a signaling NaN value.')
elif self.is_nan():
- # 0 to match hash(float('nan'))
- return 0
+ return _PyHASH_NAN
else:
- # values chosen to match hash(float('inf')) and
- # hash(float('-inf')).
if self._sign:
- return -271828
+ return -_PyHASH_INF
else:
- return 314159
-
- # In Python 2.7, we're allowing comparisons (but not
- # arithmetic operations) between floats and Decimals; so if
- # a Decimal instance is exactly representable as a float then
- # its hash should match that of the float.
- self_as_float = float(self)
- if Decimal.from_float(self_as_float) == self:
- return hash(self_as_float)
-
- if self._isinteger():
- op = _WorkRep(self.to_integral_value())
- # to make computation feasible for Decimals with large
- # exponent, we use the fact that hash(n) == hash(m) for
- # any two nonzero integers n and m such that (i) n and m
- # have the same sign, and (ii) n is congruent to m modulo
- # 2**64-1. So we can replace hash((-1)**s*c*10**e) with
- # hash((-1)**s*c*pow(10, e, 2**64-1).
- return hash((-1)**op.sign*op.int*pow(10, op.exp, 2**64-1))
- # The value of a nonzero nonspecial Decimal instance is
- # faithfully represented by the triple consisting of its sign,
- # its adjusted exponent, and its coefficient with trailing
- # zeros removed.
- return hash((self._sign,
- self._exp+len(self._int),
- self._int.rstrip('0')))
+ return _PyHASH_INF
+
+ if self._exp >= 0:
+ exp_hash = pow(10, self._exp, _PyHASH_MODULUS)
+ else:
+ exp_hash = pow(_PyHASH_10INV, -self._exp, _PyHASH_MODULUS)
+ hash_ = int(self._int) * exp_hash % _PyHASH_MODULUS
+ ans = hash_ if self >= 0 else -hash_
+ return -2 if ans == -1 else ans
def as_tuple(self):
"""Represents the number as a triple tuple.
@@ -1389,9 +1366,6 @@ class Decimal(object):
return other
return other.__truediv__(self, context=context)
- __div__ = __truediv__
- __rdiv__ = __rtruediv__
-
def __divmod__(self, other, context=None):
"""
Return (self // other, self % other)
@@ -1618,20 +1592,13 @@ class Decimal(object):
def __complex__(self):
return complex(float(self))
- def __long__(self):
- """Converts to a long.
-
- Equivalent to long(int(self))
- """
- return long(self.__int__())
-
def _fix_nan(self, context):
"""Decapitate the payload of a NaN to fit the context"""
payload = self._int
- # maximum length of payload is precision if _clamp=0,
- # precision-1 if _clamp=1.
- max_payload_len = context.prec - context._clamp
+ # maximum length of payload is precision if clamp=0,
+ # precision-1 if clamp=1.
+ max_payload_len = context.prec - context.clamp
if len(payload) > max_payload_len:
payload = payload[len(payload)-max_payload_len:].lstrip('0')
return _dec_from_triple(self._sign, payload, self._exp, True)
@@ -1656,11 +1623,11 @@ class Decimal(object):
return Decimal(self)
# if self is zero then exponent should be between Etiny and
- # Emax if _clamp==0, and between Etiny and Etop if _clamp==1.
+ # Emax if clamp==0, and between Etiny and Etop if clamp==1.
Etiny = context.Etiny()
Etop = context.Etop()
if not self:
- exp_max = [context.Emax, Etop][context._clamp]
+ exp_max = [context.Emax, Etop][context.clamp]
new_exp = min(max(self._exp, Etiny), exp_max)
if new_exp != self._exp:
context._raise_error(Clamped)
@@ -1720,8 +1687,8 @@ class Decimal(object):
if self_is_subnormal:
context._raise_error(Subnormal)
- # fold down if _clamp == 1 and self has too few digits
- if context._clamp == 1 and self._exp > Etop:
+ # fold down if clamp == 1 and self has too few digits
+ if context.clamp == 1 and self._exp > Etop:
context._raise_error(Clamped)
self_padded = self._int + '0'*(self._exp - Etop)
return _dec_from_triple(self._sign, self_padded, Etop)
@@ -1806,6 +1773,98 @@ class Decimal(object):
ROUND_05UP = _round_05up,
)
+ def __round__(self, n=None):
+ """Round self to the nearest integer, or to a given precision.
+
+ If only one argument is supplied, round a finite Decimal
+ instance self to the nearest integer. If self is infinite or
+ a NaN then a Python exception is raised. If self is finite
+ and lies exactly halfway between two integers then it is
+ rounded to the integer with even last digit.
+
+ >>> round(Decimal('123.456'))
+ 123
+ >>> round(Decimal('-456.789'))
+ -457
+ >>> round(Decimal('-3.0'))
+ -3
+ >>> round(Decimal('2.5'))
+ 2
+ >>> round(Decimal('3.5'))
+ 4
+ >>> round(Decimal('Inf'))
+ Traceback (most recent call last):
+ ...
+ OverflowError: cannot round an infinity
+ >>> round(Decimal('NaN'))
+ Traceback (most recent call last):
+ ...
+ ValueError: cannot round a NaN
+
+ If a second argument n is supplied, self is rounded to n
+ decimal places using the rounding mode for the current
+ context.
+
+ For an integer n, round(self, -n) is exactly equivalent to
+ self.quantize(Decimal('1En')).
+
+ >>> round(Decimal('123.456'), 0)
+ Decimal('123')
+ >>> round(Decimal('123.456'), 2)
+ Decimal('123.46')
+ >>> round(Decimal('123.456'), -2)
+ Decimal('1E+2')
+ >>> round(Decimal('-Infinity'), 37)
+ Decimal('NaN')
+ >>> round(Decimal('sNaN123'), 0)
+ Decimal('NaN123')
+
+ """
+ if n is not None:
+ # two-argument form: use the equivalent quantize call
+ if not isinstance(n, int):
+ raise TypeError('Second argument to round should be integral')
+ exp = _dec_from_triple(0, '1', -n)
+ return self.quantize(exp)
+
+ # one-argument form
+ if self._is_special:
+ if self.is_nan():
+ raise ValueError("cannot round a NaN")
+ else:
+ raise OverflowError("cannot round an infinity")
+ return int(self._rescale(0, ROUND_HALF_EVEN))
+
+ def __floor__(self):
+ """Return the floor of self, as an integer.
+
+ For a finite Decimal instance self, return the greatest
+ integer n such that n <= self. If self is infinite or a NaN
+ then a Python exception is raised.
+
+ """
+ if self._is_special:
+ if self.is_nan():
+ raise ValueError("cannot round a NaN")
+ else:
+ raise OverflowError("cannot round an infinity")
+ return int(self._rescale(0, ROUND_FLOOR))
+
+ def __ceil__(self):
+ """Return the ceiling of self, as an integer.
+
+ For a finite Decimal instance self, return the least integer n
+ such that n >= self. If self is infinite or a NaN then a
+ Python exception is raised.
+
+ """
+ if self._is_special:
+ if self.is_nan():
+ raise ValueError("cannot round a NaN")
+ else:
+ raise OverflowError("cannot round an infinity")
+ return int(self._rescale(0, ROUND_CEILING))
+
def fma(self, other, third, context=None):
"""Fused multiply-add.
@@ -1928,7 +1987,7 @@ class Decimal(object):
# compute result using integer pow()
base = (base.int % modulo * pow(10, base.exp, modulo)) % modulo
- for i in xrange(exponent.exp):
+ for i in range(exponent.exp):
base = pow(base, 10, modulo)
base = pow(base, exponent.int, modulo)
@@ -1948,9 +2007,9 @@ class Decimal(object):
nonzero. For efficiency, other._exp should not be too large,
so that 10**abs(other._exp) is a feasible calculation."""
- # In the comments below, we write x for the value of self and y for the
- # value of other. Write x = xc*10**xe and abs(y) = yc*10**ye, with xc
- # and yc positive integers not divisible by 10.
+ # In the comments below, we write x for the value of self and
+ # y for the value of other. Write x = xc*10**xe and y =
+ # yc*10**ye.
# The main purpose of this method is to identify the *failure*
# of x**y to be exactly representable with as little effort as
@@ -1958,12 +2017,13 @@ class Decimal(object):
# eliminate the possibility of x**y being exact. Only if all
# these tests are passed do we go on to actually compute x**y.
- # Here's the main idea. Express y as a rational number m/n, with m and
- # n relatively prime and n>0. Then for x**y to be exactly
- # representable (at *any* precision), xc must be the nth power of a
- # positive integer and xe must be divisible by n. If y is negative
- # then additionally xc must be a power of either 2 or 5, hence a power
- # of 2**n or 5**n.
+ # Here's the main idea. First normalize both x and y. We
+ # express y as a rational m/n, with m and n relatively prime
+ # and n>0. Then for x**y to be exactly representable (at
+ # *any* precision), xc must be the nth power of a positive
+ # integer and xe must be divisible by n. If m is negative
+ # then additionally xc must be a power of either 2 or 5, hence
+ # a power of 2**n or 5**n.
#
# There's a limit to how small |y| can be: if y=m/n as above
# then:
@@ -2035,43 +2095,21 @@ class Decimal(object):
return None
# now xc is a power of 2; e is its exponent
e = _nbits(xc)-1
-
- # We now have:
- #
- # x = 2**e * 10**xe, e > 0, and y < 0.
- #
- # The exact result is:
- #
- # x**y = 5**(-e*y) * 10**(e*y + xe*y)
- #
- # provided that both e*y and xe*y are integers. Note that if
- # 5**(-e*y) >= 10**p, then the result can't be expressed
- # exactly with p digits of precision.
- #
- # Using the above, we can guard against large values of ye.
- # 93/65 is an upper bound for log(10)/log(5), so if
- #
- # ye >= len(str(93*p//65))
- #
- # then
- #
- # -e*y >= -y >= 10**ye > 93*p/65 > p*log(10)/log(5),
- #
- # so 5**(-e*y) >= 10**p, and the coefficient of the result
- # can't be expressed in p digits.
-
- # emax >= largest e such that 5**e < 10**p.
- emax = p*93//65
- if ye >= len(str(emax)):
- return None
-
- # Find -e*y and -xe*y; both must be integers
- e = _decimal_lshift_exact(e * yc, ye)
- xe = _decimal_lshift_exact(xe * yc, ye)
- if e is None or xe is None:
- return None
-
- if e > emax:
+ # find e*y and xe*y; both must be integers
+ if ye >= 0:
+ y_as_int = yc*10**ye
+ e = e*y_as_int
+ xe = xe*y_as_int
+ else:
+ ten_pow = 10**-ye
+ e, remainder = divmod(e*yc, ten_pow)
+ if remainder:
+ return None
+ xe, remainder = divmod(xe*yc, ten_pow)
+ if remainder:
+ return None
+
+ if e*65 >= p*93: # 93/65 > log(10)/log(5)
return None
xc = 5**e
@@ -2085,20 +2123,19 @@ class Decimal(object):
while xc % 5 == 0:
xc //= 5
e -= 1
-
- # Guard against large values of ye, using the same logic as in
- # the 'xc is a power of 2' branch. 10/3 is an upper bound for
- # log(10)/log(2).
- emax = p*10//3
- if ye >= len(str(emax)):
- return None
-
- e = _decimal_lshift_exact(e * yc, ye)
- xe = _decimal_lshift_exact(xe * yc, ye)
- if e is None or xe is None:
- return None
-
- if e > emax:
+ if ye >= 0:
+ y_as_integer = yc*10**ye
+ e = e*y_as_integer
+ xe = xe*y_as_integer
+ else:
+ ten_pow = 10**-ye
+ e, remainder = divmod(e*yc, ten_pow)
+ if remainder:
+ return None
+ xe, remainder = divmod(xe*yc, ten_pow)
+ if remainder:
+ return None
+ if e*3 >= p*10: # 10/3 > log(10)/log(2)
return None
xc = 2**e
else:
@@ -2137,7 +2174,7 @@ class Decimal(object):
return None
# compute nth root of xc using Newton's method
- a = 1L << -(-_nbits(xc)//n) # initial estimate
+ a = 1 << -(-_nbits(xc)//n) # initial estimate
while True:
q, r = divmod(xc, a**(n-1))
if a <= q:
@@ -2411,7 +2448,7 @@ class Decimal(object):
if not dup:
return _dec_from_triple(dup._sign, '0', 0)
- exp_max = [context.Emax, context.Etop()][context._clamp]
+ exp_max = [context.Emax, context.Etop()][context.clamp]
end = len(dup._int)
exp = dup._exp
while dup._int[end-1] == '0' and exp < exp_max:
@@ -3776,13 +3813,13 @@ class Context(object):
Emax - Maximum exponent
capitals - If 1, 1*10^1 is printed as 1E+1.
If 0, printed as 1e1
- _clamp - If 1, change exponents if too high (Default 0)
+ clamp - If 1, change exponents if too high (Default 0)
"""
def __init__(self, prec=None, rounding=None,
traps=None, flags=None,
Emin=None, Emax=None,
- capitals=None, _clamp=0,
+ capitals=None, clamp=None,
_ignored_flags=None):
# Set defaults; for everything except flags and _ignored_flags,
# inherit from DefaultContext.
@@ -3796,7 +3833,7 @@ class Context(object):
self.Emin = Emin if Emin is not None else dc.Emin
self.Emax = Emax if Emax is not None else dc.Emax
self.capitals = capitals if capitals is not None else dc.capitals
- self._clamp = _clamp if _clamp is not None else dc._clamp
+ self.clamp = clamp if clamp is not None else dc.clamp
if _ignored_flags is None:
self._ignored_flags = []
@@ -3821,7 +3858,8 @@ class Context(object):
"""Show the current context."""
s = []
s.append('Context(prec=%(prec)d, rounding=%(rounding)s, '
- 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d'
+ 'Emin=%(Emin)d, Emax=%(Emax)d, capitals=%(capitals)d, '
+ 'clamp=%(clamp)d'
% vars(self))
names = [f.__name__ for f, v in self.flags.items() if v]
s.append('flags=[' + ', '.join(names) + ']')
@@ -3838,17 +3876,39 @@ class Context(object):
"""Returns a shallow copy from self."""
nc = Context(self.prec, self.rounding, self.traps,
self.flags, self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
+ self.capitals, self.clamp, self._ignored_flags)
return nc
def copy(self):
"""Returns a deep copy from self."""
nc = Context(self.prec, self.rounding, self.traps.copy(),
self.flags.copy(), self.Emin, self.Emax,
- self.capitals, self._clamp, self._ignored_flags)
+ self.capitals, self.clamp, self._ignored_flags)
return nc
__copy__ = copy
+ # _clamp is provided for backwards compatibility with third-party
+ # code. May be removed in Python >= 3.3.
+ def _get_clamp(self):
+ "_clamp mirrors the clamp attribute. Its use is deprecated."
+ import warnings
+ warnings.warn('Use of the _clamp attribute is deprecated. '
+ 'Please use clamp instead.',
+ DeprecationWarning)
+ return self.clamp
+
+ def _set_clamp(self, clamp):
+ "_clamp mirrors the clamp attribute. Its use is deprecated."
+ import warnings
+ warnings.warn('Use of the _clamp attribute is deprecated. '
+ 'Please use clamp instead.',
+ DeprecationWarning)
+ self.clamp = clamp
+
+ # don't bother with _del_clamp; no sane 3rd party code should
+ # be deleting the _clamp attribute
+ _clamp = property(_get_clamp, _set_clamp)
+
def _raise_error(self, condition, explanation = None, *args):
"""Handles an error
@@ -3925,13 +3985,13 @@ class Context(object):
This method implements the to-number operation of the
IBM Decimal specification."""
- if isinstance(num, basestring) and num != num.strip():
+ if isinstance(num, str) and num != num.strip():
return self._raise_error(ConversionSyntax,
"no trailing or leading whitespace is "
"permitted.")
d = Decimal(num, context=self)
- if d._isnan() and len(d._int) > self.prec - self._clamp:
+ if d._isnan() and len(d._int) > self.prec - self.clamp:
return self._raise_error(ConversionSyntax,
"diagnostic info too long in NaN")
return d._fix(self)
@@ -3947,7 +4007,7 @@ class Context(object):
>>> context.create_decimal_from_float(3.1415926535897932)
Traceback (most recent call last):
...
- Inexact: None
+ decimal.Inexact: None
"""
d = Decimal.from_float(f) # An exact conversion
@@ -4058,18 +4118,18 @@ class Context(object):
>>> c.compare_signal(Decimal('2.1'), Decimal('2.1'))
Decimal('0')
>>> c.flags[InvalidOperation] = 0
- >>> print c.flags[InvalidOperation]
+ >>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('NaN'), Decimal('2.1'))
Decimal('NaN')
- >>> print c.flags[InvalidOperation]
+ >>> print(c.flags[InvalidOperation])
1
>>> c.flags[InvalidOperation] = 0
- >>> print c.flags[InvalidOperation]
+ >>> print(c.flags[InvalidOperation])
0
>>> c.compare_signal(Decimal('sNaN'), Decimal('2.1'))
Decimal('NaN')
- >>> print c.flags[InvalidOperation]
+ >>> print(c.flags[InvalidOperation])
1
>>> c.compare_signal(-1, 2)
Decimal('-1')
@@ -4212,7 +4272,7 @@ class Context(object):
Decimal('1')
"""
a = _convert_other(a, raiseit=True)
- r = a.__div__(b, context=self)
+ r = a.__truediv__(b, context=self)
if r is NotImplemented:
raise TypeError("Unable to convert %s to Decimal" % b)
else:
@@ -5418,7 +5478,7 @@ class Context(object):
class _WorkRep(object):
__slots__ = ('sign','int','exp')
# sign: 0 or 1
- # int: int or long
+ # int: int
# exp: None, int, or string
def __init__(self, value=None):
@@ -5473,44 +5533,7 @@ def _normalize(op1, op2, prec = 0):
##### Integer arithmetic functions used by ln, log10, exp and __pow__ #####
-# This function from Tim Peters was taken from here:
-# http://mail.python.org/pipermail/python-list/1999-July/007758.html
-# The correction being in the function definition is for speed, and
-# the whole function is not resolved with math.log because of avoiding
-# the use of floats.
-def _nbits(n, correction = {
- '0': 4, '1': 3, '2': 2, '3': 2,
- '4': 1, '5': 1, '6': 1, '7': 1,
- '8': 0, '9': 0, 'a': 0, 'b': 0,
- 'c': 0, 'd': 0, 'e': 0, 'f': 0}):
- """Number of bits in binary representation of the positive integer n,
- or 0 if n == 0.
- """
- if n < 0:
- raise ValueError("The argument to _nbits should be nonnegative.")
- hex_n = "%x" % n
- return 4*len(hex_n) - correction[hex_n[0]]
-
-def _decimal_lshift_exact(n, e):
- """ Given integers n and e, return n * 10**e if it's an integer, else None.
-
- The computation is designed to avoid computing large powers of 10
- unnecessarily.
-
- >>> _decimal_lshift_exact(3, 4)
- 30000
- >>> _decimal_lshift_exact(300, -999999999) # returns None
-
- """
- if n == 0:
- return 0
- elif e >= 0:
- return n * 10**e
- else:
- # val_n = largest power of 10 dividing n.
- str_n = str(abs(n))
- val_n = len(str_n) - len(str_n.rstrip('0'))
- return None if val_n < -e else n // 10**-e
+_nbits = int.bit_length
def _sqrt_nearest(n, a):
"""Closest integer to the square root of the positive integer n. a is
@@ -5532,7 +5555,7 @@ def _rshift_nearest(x, shift):
integer to x / 2**shift; use round-to-even in case of a tie.
"""
- b, q = 1L << shift, x >> shift
+ b, q = 1 << shift, x >> shift
return q + (2*(x & (b-1)) + (q&1) > b)
def _div_nearest(a, b):
@@ -5576,9 +5599,9 @@ def _ilog(x, M, L = 8):
y = x-M
# argument reduction; R = number of reductions performed
R = 0
- while (R <= L and long(abs(y)) << L-R >= M or
+ while (R <= L and abs(y) << L-R >= M or
R > L and abs(y) >> R-L >= M):
- y = _div_nearest(long(M*y) << 1,
+ y = _div_nearest((M*y) << 1,
M + _sqrt_nearest(M*(M+_rshift_nearest(y, R)), M))
R += 1
@@ -5586,7 +5609,7 @@ def _ilog(x, M, L = 8):
T = -int(-10*len(str(M))//(3*L))
yshift = _rshift_nearest(y, R)
w = _div_nearest(M, T)
- for k in xrange(T-1, 0, -1):
+ for k in range(T-1, 0, -1):
w = _div_nearest(M, k) - _div_nearest(yshift*w, M)
return _div_nearest(w*y, M)
@@ -5727,18 +5750,18 @@ def _iexp(x, M, L=8):
# expm1(z/2**(R-1)), ... , exp(z/2), exp(z).
# Find R such that x/2**R/M <= 2**-L
- R = _nbits((long(x)<<L)//M)
+ R = _nbits((x<<L)//M)
# Taylor series. (2**L)**T > M
T = -int(-10*len(str(M))//(3*L))
y = _div_nearest(x, T)
- Mshift = long(M)<<R
- for i in xrange(T-1, 0, -1):
+ Mshift = M<<R
+ for i in range(T-1, 0, -1):
y = _div_nearest(x*(Mshift + y), Mshift * i)
# Expansion
- for k in xrange(R-1, -1, -1):
- Mshift = long(M)<<(k+2)
+ for k in range(R-1, -1, -1):
+ Mshift = M<<(k+2)
y = _div_nearest(y*(y+Mshift), Mshift)
return M+y
@@ -5842,7 +5865,7 @@ def _convert_other(other, raiseit=False, allow_float=False):
"""
if isinstance(other, Decimal):
return other
- if isinstance(other, (int, long)):
+ if isinstance(other, int):
return Decimal(other)
if allow_float and isinstance(other, float):
return Decimal.from_float(other)
@@ -5851,6 +5874,37 @@ def _convert_other(other, raiseit=False, allow_float=False):
raise TypeError("Unable to convert %s to Decimal" % other)
return NotImplemented
+def _convert_for_comparison(self, other, equality_op=False):
+ """Given a Decimal instance self and a Python object other, return
+ a pair (s, o) of Decimal instances such that "s op o" is
+ equivalent to "self op other" for any of the 6 comparison
+ operators "op".
+
+ """
+ if isinstance(other, Decimal):
+ return self, other
+
+ # Comparison with a Rational instance (also includes integers):
+ # self op n/d <=> self*d op n (for n and d integers, d positive).
+ # A NaN or infinity can be left unchanged without affecting the
+ # comparison result.
+ if isinstance(other, _numbers.Rational):
+ if not self._is_special:
+ self = _dec_from_triple(self._sign,
+ str(int(self._int) * other.denominator),
+ self._exp)
+ return self, Decimal(other.numerator)
+
+ # Comparisons with float and complex types. == and != comparisons
+ # with complex numbers should succeed, returning either True or False
+ # as appropriate. Other comparisons return NotImplemented.
+ if equality_op and isinstance(other, _numbers.Complex) and other.imag == 0:
+ other = other.real
+ if isinstance(other, float):
+ return self, Decimal.from_float(other)
+ return NotImplemented, NotImplemented
+
+
##### Setup Specific Contexts ############################################
# The default context prototype used by Context()
@@ -5862,7 +5916,8 @@ DefaultContext = Context(
flags=[],
Emax=999999999,
Emin=-999999999,
- capitals=1
+ capitals=1,
+ clamp=0
)
# Pre-made alternate contexts offered by the specification
@@ -5915,7 +5970,7 @@ _parser = re.compile(r""" # A numeric string consists of:
)
# \s*
\Z
-""", re.VERBOSE | re.IGNORECASE | re.UNICODE).match
+""", re.VERBOSE | re.IGNORECASE).match
_all_zeros = re.compile('0*$').match
_exact_half = re.compile('50*$').match
@@ -5927,7 +5982,7 @@ _exact_half = re.compile('50*$').match
#
# A format specifier for Decimal looks like:
#
-# [[fill]align][sign][0][minimumwidth][,][.precision][type]
+# [[fill]align][sign][#][0][minimumwidth][,][.precision][type]
_parse_format_specifier_regex = re.compile(r"""\A
(?:
@@ -5935,6 +5990,7 @@ _parse_format_specifier_regex = re.compile(r"""\A
(?P<align>[<>=^])
)?
(?P<sign>[-+ ])?
+(?P<alt>\#)?
(?P<zeropad>0)?
(?P<minimumwidth>(?!0)\d+)?
(?P<thousands_sep>,)?
@@ -5970,7 +6026,6 @@ def _parse_format_specifier(format_spec, _localeconv=None):
decimal_point: string to use for decimal point
precision: nonnegative integer giving precision, or None
type: one of the characters 'eEfFgG%', or None
- unicode: boolean (always True for Python 3.x)
"""
m = _parse_format_specifier_regex.match(format_spec)
@@ -6032,9 +6087,6 @@ def _parse_format_specifier(format_spec, _localeconv=None):
format_dict['grouping'] = [3, 0]
format_dict['decimal_point'] = '.'
- # record whether return type should be str or unicode
- format_dict['unicode'] = isinstance(format_spec, unicode)
-
return format_dict
def _format_align(sign, body, spec):
@@ -6043,8 +6095,6 @@ def _format_align(sign, body, spec):
format specifier dictionary 'spec' (as produced by
parse_format_specifier).
- Also converts result to unicode if necessary.
-
"""
# how much extra space do we have to play with?
minimumwidth = spec['minimumwidth']
@@ -6064,10 +6114,6 @@ def _format_align(sign, body, spec):
else:
raise ValueError('Unrecognised alignment field')
- # make sure that result is unicode if necessary
- if spec['unicode']:
- result = unicode(result)
-
return result
def _group_lengths(grouping):
@@ -6160,7 +6206,7 @@ def _format_number(is_negative, intpart, fracpart, exp, spec):
sign = _format_sign(is_negative, spec)
- if fracpart:
+ if fracpart or spec['alt']:
fracpart = spec['decimal_point'] + fracpart
if exp != 0 or spec['type'] in 'eE':
@@ -6191,8 +6237,19 @@ _NegativeOne = Decimal(-1)
# _SignedInfinity[sign] is infinity w/ that sign
_SignedInfinity = (_Infinity, _NegativeInfinity)
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo _PyHASH_MODULUS
+import sys
+_PyHASH_MODULUS = sys.hash_info.modulus
+# hash values to use for positive and negative infinities, and nans
+_PyHASH_INF = sys.hash_info.inf
+_PyHASH_NAN = sys.hash_info.nan
+del sys
+
+# _PyHASH_10INV is the inverse of 10 modulo the prime _PyHASH_MODULUS
+_PyHASH_10INV = pow(10, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
if __name__ == '__main__':
- import doctest, sys
- doctest.testmod(sys.modules[__name__])
+ import doctest, decimal
+ doctest.testmod(decimal)
diff --git a/Lib/difflib.py b/Lib/difflib.py
index 3bbcb76b7ec..e6cc6ee4425 100644
--- a/Lib/difflib.py
+++ b/Lib/difflib.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
Module difflib -- helpers for computing deltas between objects.
@@ -32,9 +32,9 @@ __all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
'unified_diff', 'HtmlDiff', 'Match']
+import warnings
import heapq
from collections import namedtuple as _namedtuple
-from functools import reduce
Match = _namedtuple('Match', 'a b size')
@@ -80,7 +80,7 @@ class SequenceMatcher:
sequences. As a rule of thumb, a .ratio() value over 0.6 means the
sequences are close matches:
- >>> print round(s.ratio(), 3)
+ >>> print(round(s.ratio(), 3))
0.866
>>>
@@ -88,7 +88,7 @@ class SequenceMatcher:
.get_matching_blocks() is handy:
>>> for block in s.get_matching_blocks():
- ... print "a[%d] and b[%d] match for %d elements" % block
+ ... print("a[%d] and b[%d] match for %d elements" % block)
a[0] and b[0] match for 8 elements
a[8] and b[17] match for 21 elements
a[29] and b[38] match for 0 elements
@@ -101,7 +101,7 @@ class SequenceMatcher:
use .get_opcodes():
>>> for opcode in s.get_opcodes():
- ... print "%6s a[%d:%d] b[%d:%d]" % opcode
+ ... print("%6s a[%d:%d] b[%d:%d]" % opcode)
equal a[0:8] b[0:8]
insert a[8:8] b[8:17]
equal a[8:29] b[17:38]
@@ -183,7 +183,7 @@ class SequenceMatcher:
# we need to do to 'a' to change it into 'b'?"
# b2j
# for x in b, b2j[x] is a list of the indices (into b)
- # at which x appears; junk elements do not appear
+ # at which x appears; junk and popular elements do not appear
# fullbcount
# for x in b, fullbcount[x] == the number of times x
# appears in b; only materialized if really needed (used
@@ -205,15 +205,10 @@ class SequenceMatcher:
# subtle but helpful effects on the algorithm, which I'll
# get around to writing up someday <0.9 wink>.
# DON'T USE! Only __chain_b uses this. Use isbjunk.
- # isbjunk
- # for x in b, isbjunk(x) == isjunk(x) but much faster;
- # it's really the __contains__ method of a hidden dict.
- # DOES NOT WORK for x in a!
- # isbpopular
- # for x in b, isbpopular(x) is true iff b is reasonably long
- # (at least 200 elements) and x accounts for more than 1 + 1% of
- # its elements (when autojunk is enabled).
- # DOES NOT WORK for x in a!
+ # bjunk
+ # the items in b for which isjunk is True.
+ # bpopular
+ # nonjunk items in b treated as junk by the heuristic (if used).
self.isjunk = isjunk
self.a = self.b = None
@@ -322,30 +317,39 @@ class SequenceMatcher:
indices.append(i)
# Purge junk elements
- junk = set()
+ self.bjunk = junk = set()
isjunk = self.isjunk
if isjunk:
- for elt in list(b2j.keys()): # using list() since b2j is modified
+ for elt in b2j.keys():
if isjunk(elt):
junk.add(elt)
- del b2j[elt]
+ for elt in junk: # separate loop avoids separate list of keys
+ del b2j[elt]
# Purge popular elements that are not junk
- popular = set()
+ self.bpopular = popular = set()
n = len(b)
if self.autojunk and n >= 200:
ntest = n // 100 + 1
- for elt, idxs in list(b2j.items()):
+ for elt, idxs in b2j.items():
if len(idxs) > ntest:
popular.add(elt)
- del b2j[elt]
-
- # Now for x in b, isjunk(x) == x in junk, but the latter is much faster.
- # Sicne the number of *unique* junk elements is probably small, the
- # memory burden of keeping this set alive is likely trivial compared to
- # the size of b2j.
- self.isbjunk = junk.__contains__
- self.isbpopular = popular.__contains__
+ for elt in popular: # ditto; as fast for 1% deletion
+ del b2j[elt]
+
+ def isbjunk(self, item):
+ "Deprecated; use 'item in SequenceMatcher().bjunk'."
+ warnings.warn("'SequenceMatcher().isbjunk(item)' is deprecated;\n"
+ "use 'item in SMinstance.bjunk' instead.",
+ DeprecationWarning, 2)
+ return item in self.bjunk
+
+ def isbpopular(self, item):
+ "Deprecated; use 'item in SequenceMatcher().bpopular'."
+ warnings.warn("'SequenceMatcher().isbpopular(item)' is deprecated;\n"
+ "use 'item in SMinstance.bpopular' instead.",
+ DeprecationWarning, 2)
+ return item in self.bpopular
def find_longest_match(self, alo, ahi, blo, bhi):
"""Find longest matching block in a[alo:ahi] and b[blo:bhi].
@@ -403,14 +407,14 @@ class SequenceMatcher:
# Windiff ends up at the same place as diff, but by pairing up
# the unique 'b's and then matching the first two 'a's.
- a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.isbjunk
+ a, b, b2j, isbjunk = self.a, self.b, self.b2j, self.bjunk.__contains__
besti, bestj, bestsize = alo, blo, 0
# find longest junk-free match
# during an iteration of the loop, j2len[j] = length of longest
# junk-free match ending with a[i-1] and b[j]
j2len = {}
nothing = []
- for i in xrange(alo, ahi):
+ for i in range(alo, ahi):
# look at all instances of a[i] in b; note that because
# b2j has no junk keys, the loop is skipped if a[i] is junk
j2lenget = j2len.get
@@ -472,7 +476,7 @@ class SequenceMatcher:
triple with n==0.
>>> s = SequenceMatcher(None, "abxcd", "abcd")
- >>> s.get_matching_blocks()
+ >>> list(s.get_matching_blocks())
[Match(a=0, b=0, size=2), Match(a=3, b=2, size=2), Match(a=5, b=4, size=0)]
"""
@@ -548,8 +552,8 @@ class SequenceMatcher:
>>> b = "abycdf"
>>> s = SequenceMatcher(None, a, b)
>>> for tag, i1, i2, j1, j2 in s.get_opcodes():
- ... print ("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
- ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2]))
+ ... print(("%7s a[%d:%d] (%s) b[%d:%d] (%s)" %
+ ... (tag, i1, i2, a[i1:i2], j1, j2, b[j1:j2])))
delete a[0:1] (q) b[0:0] ()
equal a[1:3] (ab) b[0:2] (ab)
replace a[3:4] (x) b[2:3] (y)
@@ -590,7 +594,7 @@ class SequenceMatcher:
Each group is in the same format as returned by get_opcodes().
>>> from pprint import pprint
- >>> a = map(str, range(1,40))
+ >>> a = list(map(str, range(1,40)))
>>> b = a[:]
>>> b[8:8] = ['i'] # Make an insertion
>>> b[20] += 'x' # Make a replacement
@@ -655,8 +659,7 @@ class SequenceMatcher:
1.0
"""
- matches = reduce(lambda sum, triple: sum + triple[-1],
- self.get_matching_blocks(), 0)
+ matches = sum(triple[-1] for triple in self.get_matching_blocks())
return _calculate_ratio(matches, len(self.a) + len(self.b))
def quick_ratio(self):
@@ -723,7 +726,7 @@ def get_close_matches(word, possibilities, n=3, cutoff=0.6):
>>> import keyword as _keyword
>>> get_close_matches("wheel", _keyword.kwlist)
['while']
- >>> get_close_matches("apple", _keyword.kwlist)
+ >>> get_close_matches("Apple", _keyword.kwlist)
[]
>>> get_close_matches("accept", _keyword.kwlist)
['except']
@@ -836,7 +839,7 @@ class Differ:
As a single multi-line string it looks like this:
- >>> print ''.join(result),
+ >>> print(''.join(result), end="")
1. Beautiful is better than ugly.
- 2. Explicit is better than implicit.
- 3. Simple is better than complex.
@@ -893,8 +896,9 @@ class Differ:
Example:
- >>> print ''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1),
+ >>> print(''.join(Differ().compare('one\ntwo\nthree\n'.splitlines(1),
... 'ore\ntree\nemu\n'.splitlines(1))),
+ ... end="")
- one
? ^
+ ore
@@ -917,14 +921,14 @@ class Differ:
elif tag == 'equal':
g = self._dump(' ', a, alo, ahi)
else:
- raise ValueError, 'unknown tag %r' % (tag,)
+ raise ValueError('unknown tag %r' % (tag,))
for line in g:
yield line
def _dump(self, tag, x, lo, hi):
"""Generate comparison results for a same-tagged range."""
- for i in xrange(lo, hi):
+ for i in range(lo, hi):
yield '%s %s' % (tag, x[i])
def _plain_replace(self, a, alo, ahi, b, blo, bhi):
@@ -954,7 +958,7 @@ class Differ:
>>> d = Differ()
>>> results = d._fancy_replace(['abcDefghiJkl\n'], 0, 1,
... ['abcdefGhijkl\n'], 0, 1)
- >>> print ''.join(results),
+ >>> print(''.join(results), end="")
- abcDefghiJkl
? ^ ^ ^
+ abcdefGhijkl
@@ -970,10 +974,10 @@ class Differ:
# search for the pair that matches best without being identical
# (identical lines must be junk lines, & we don't want to synch up
# on junk -- unless we have to)
- for j in xrange(blo, bhi):
+ for j in range(blo, bhi):
bj = b[j]
cruncher.set_seq2(bj)
- for i in xrange(alo, ahi):
+ for i in range(alo, ahi):
ai = a[i]
if ai == bj:
if eqi is None:
@@ -1029,7 +1033,7 @@ class Differ:
atags += ' ' * la
btags += ' ' * lb
else:
- raise ValueError, 'unknown tag %r' % (tag,)
+ raise ValueError('unknown tag %r' % (tag,))
for line in self._qformat(aelt, belt, atags, btags):
yield line
else:
@@ -1062,7 +1066,7 @@ class Differ:
>>> d = Differ()
>>> results = d._qformat('\tabcDefghiJkl\n', '\tabcdefGhijkl\n',
... ' ^ ^ ^ ', ' ^ ^ ^ ')
- >>> for line in results: print repr(line)
+ >>> for line in results: print(repr(line))
...
'- \tabcDefghiJkl\n'
'? \t ^ ^ ^\n'
@@ -1184,7 +1188,7 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
... 'zero one tree four'.split(), 'Original', 'Current',
... '2005-01-26 23:30:50', '2010-04-02 10:20:52',
... lineterm=''):
- ... print line # doctest: +NORMALIZE_WHITESPACE
+ ... print(line) # doctest: +NORMALIZE_WHITESPACE
--- Original 2005-01-26 23:30:50
+++ Current 2010-04-02 10:20:52
@@ -1,4 +1,4 @@
@@ -1215,10 +1219,10 @@ def unified_diff(a, b, fromfile='', tofile='', fromfiledate='',
for line in a[i1:i2]:
yield ' ' + line
continue
- if tag in ('replace', 'delete'):
+ if tag in {'replace', 'delete'}:
for line in a[i1:i2]:
yield '-' + line
- if tag in ('replace', 'insert'):
+ if tag in {'replace', 'insert'}:
for line in b[j1:j2]:
yield '+' + line
@@ -1265,8 +1269,9 @@ def context_diff(a, b, fromfile='', tofile='',
Example:
- >>> print ''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
+ >>> print(''.join(context_diff('one\ntwo\nthree\nfour\n'.splitlines(1),
... 'zero\none\ntree\nfour\n'.splitlines(1), 'Original', 'Current')),
+ ... end="")
*** Original
--- Current
***************
@@ -1298,7 +1303,7 @@ def context_diff(a, b, fromfile='', tofile='',
file1_range = _format_range_context(first[1], last[2])
yield '*** {} ****{}'.format(file1_range, lineterm)
- if any(tag in ('replace', 'delete') for tag, _, _, _, _ in group):
+ if any(tag in {'replace', 'delete'} for tag, _, _, _, _ in group):
for tag, i1, i2, _, _ in group:
if tag != 'insert':
for line in a[i1:i2]:
@@ -1307,7 +1312,7 @@ def context_diff(a, b, fromfile='', tofile='',
file2_range = _format_range_context(first[3], last[4])
yield '--- {} ----{}'.format(file2_range, lineterm)
- if any(tag in ('replace', 'insert') for tag, _, _, _, _ in group):
+ if any(tag in {'replace', 'insert'} for tag, _, _, _, _ in group):
for tag, _, _, j1, j2 in group:
if tag != 'delete':
for line in b[j1:j2]:
@@ -1336,7 +1341,7 @@ def ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK):
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
... 'ore\ntree\nemu\n'.splitlines(1))
- >>> print ''.join(diff),
+ >>> print(''.join(diff), end="")
- one
? ^
+ ore
@@ -1469,7 +1474,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
# so we can do some very readable comparisons.
while len(lines) < 4:
try:
- lines.append(diff_lines_iterator.next())
+ lines.append(next(diff_lines_iterator))
except StopIteration:
lines.append('X')
s = ''.join([line[0] for line in lines])
@@ -1556,7 +1561,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
while True:
# Collecting lines of text until we have a from/to pair
while (len(fromlines)==0 or len(tolines)==0):
- from_line, to_line, found_diff =line_iterator.next()
+ from_line, to_line, found_diff = next(line_iterator)
if from_line is not None:
fromlines.append((from_line,found_diff))
if to_line is not None:
@@ -1571,7 +1576,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
line_pair_iterator = _line_pair_iterator()
if context is None:
while True:
- yield line_pair_iterator.next()
+ yield next(line_pair_iterator)
# Handle case where user wants context differencing. We must do some
# storage of lines until we know for sure that they are to be yielded.
else:
@@ -1584,7 +1589,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
index, contextLines = 0, [None]*(context)
found_diff = False
while(found_diff is False):
- from_line, to_line, found_diff = line_pair_iterator.next()
+ from_line, to_line, found_diff = next(line_pair_iterator)
i = index % context
contextLines[i] = (from_line, to_line, found_diff)
index += 1
@@ -1604,7 +1609,7 @@ def _mdiff(fromlines, tolines, context=None, linejunk=None,
# Now yield the context lines after the change
lines_to_write = context-1
while(lines_to_write):
- from_line, to_line, found_diff = line_pair_iterator.next()
+ from_line, to_line, found_diff = next(line_pair_iterator)
# If another change within the context, extend the context
if found_diff:
lines_to_write = context-1
@@ -2032,11 +2037,11 @@ def restore(delta, which):
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(1),
... 'ore\ntree\nemu\n'.splitlines(1))
>>> diff = list(diff)
- >>> print ''.join(restore(diff, 1)),
+ >>> print(''.join(restore(diff, 1)), end="")
one
two
three
- >>> print ''.join(restore(diff, 2)),
+ >>> print(''.join(restore(diff, 2)), end="")
ore
tree
emu
@@ -2044,7 +2049,7 @@ def restore(delta, which):
try:
tag = {1: "- ", 2: "+ "}[int(which)]
except KeyError:
- raise ValueError, ('unknown delta choice (must be 1 or 2): %r'
+ raise ValueError('unknown delta choice (must be 1 or 2): %r'
% which)
prefixes = (" ", tag)
for line in delta:
diff --git a/Lib/dircache.py b/Lib/dircache.py
deleted file mode 100644
index 7e4f0b508ac..00000000000
--- a/Lib/dircache.py
+++ /dev/null
@@ -1,41 +0,0 @@
-"""Read and cache directory listings.
-
-The listdir() routine returns a sorted list of the files in a directory,
-using a cache to avoid reading the directory more often than necessary.
-The annotate() routine appends slashes to directories."""
-from warnings import warnpy3k
-warnpy3k("the dircache module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-
-__all__ = ["listdir", "opendir", "annotate", "reset"]
-
-cache = {}
-
-def reset():
- """Reset the cache completely."""
- global cache
- cache = {}
-
-def listdir(path):
- """List directory contents, using cache."""
- try:
- cached_mtime, list = cache[path]
- del cache[path]
- except KeyError:
- cached_mtime, list = -1, []
- mtime = os.stat(path).st_mtime
- if mtime != cached_mtime:
- list = os.listdir(path)
- list.sort()
- cache[path] = mtime, list
- return list
-
-opendir = listdir # XXX backward compatibility
-
-def annotate(head, list):
- """Add '/' suffixes to directories."""
- for i in range(len(list)):
- if os.path.isdir(os.path.join(head, list[i])):
- list[i] = list[i] + '/'
diff --git a/Lib/dis.py b/Lib/dis.py
index 5aa09c95b6d..f64bae66fb8 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -6,12 +6,24 @@ import types
from opcode import *
from opcode import __all__ as _opcodes_all
-__all__ = ["dis", "disassemble", "distb", "disco",
- "findlinestarts", "findlabels"] + _opcodes_all
+__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
+ "findlinestarts", "findlabels", "show_code"] + _opcodes_all
del _opcodes_all
-_have_code = (types.MethodType, types.FunctionType, types.CodeType,
- types.ClassType, type)
+_have_code = (types.MethodType, types.FunctionType, types.CodeType, type)
+
+def _try_compile(source, name):
+ """Attempts to compile the given source, first as an expression and
+ then as a statement if the first approach fails.
+
+ Utility function to accept strings in functions that otherwise
+ expect code objects
+ """
+ try:
+ c = compile(source, name, 'eval')
+ except SyntaxError:
+ c = compile(source, name, 'exec')
+ return c
def dis(x=None):
"""Disassemble classes, methods, functions, or code.
@@ -22,31 +34,29 @@ def dis(x=None):
if x is None:
distb()
return
- if isinstance(x, types.InstanceType):
- x = x.__class__
- if hasattr(x, 'im_func'):
- x = x.im_func
- if hasattr(x, 'func_code'):
- x = x.func_code
- if hasattr(x, '__dict__'):
- items = x.__dict__.items()
- items.sort()
+ if hasattr(x, '__func__'): # Method
+ x = x.__func__
+ if hasattr(x, '__code__'): # Function
+ x = x.__code__
+ if hasattr(x, '__dict__'): # Class or module
+ items = sorted(x.__dict__.items())
for name, x1 in items:
if isinstance(x1, _have_code):
- print "Disassembly of %s:" % name
+ print("Disassembly of %s:" % name)
try:
dis(x1)
- except TypeError, msg:
- print "Sorry:", msg
- print
- elif hasattr(x, 'co_code'):
+ except TypeError as msg:
+ print("Sorry:", msg)
+ print()
+ elif hasattr(x, 'co_code'): # Code object
disassemble(x)
- elif isinstance(x, str):
- disassemble_string(x)
+ elif isinstance(x, (bytes, bytearray)): # Raw bytecode
+ _disassemble_bytes(x)
+ elif isinstance(x, str): # Source code
+ _disassemble_str(x)
else:
- raise TypeError, \
- "don't know how to disassemble %s objects" % \
- type(x).__name__
+ raise TypeError("don't know how to disassemble %s objects" %
+ type(x).__name__)
def distb(tb=None):
"""Disassemble a traceback (default: last traceback)."""
@@ -54,10 +64,86 @@ def distb(tb=None):
try:
tb = sys.last_traceback
except AttributeError:
- raise RuntimeError, "no last traceback to disassemble"
+ raise RuntimeError("no last traceback to disassemble")
while tb.tb_next: tb = tb.tb_next
disassemble(tb.tb_frame.f_code, tb.tb_lasti)
+# The inspect module interrogates this dictionary to build its
+# list of CO_* constants. It is also used by pretty_flags to
+# turn the co_flags field into a human readable list.
+COMPILER_FLAG_NAMES = {
+ 1: "OPTIMIZED",
+ 2: "NEWLOCALS",
+ 4: "VARARGS",
+ 8: "VARKEYWORDS",
+ 16: "NESTED",
+ 32: "GENERATOR",
+ 64: "NOFREE",
+}
+
+def pretty_flags(flags):
+ """Return pretty representation of code flags."""
+ names = []
+ for i in range(32):
+ flag = 1<<i
+ if flags & flag:
+ names.append(COMPILER_FLAG_NAMES.get(flag, hex(flag)))
+ flags ^= flag
+ if not flags:
+ break
+ else:
+ names.append(hex(flags))
+ return ", ".join(names)
+
+def code_info(x):
+ """Formatted details of methods, functions, or code."""
+ if hasattr(x, '__func__'): # Method
+ x = x.__func__
+ if hasattr(x, '__code__'): # Function
+ x = x.__code__
+ if isinstance(x, str): # Source code
+ x = _try_compile(x, "<code_info>")
+ if hasattr(x, 'co_code'): # Code object
+ return _format_code_info(x)
+ else:
+ raise TypeError("don't know how to disassemble %s objects" %
+ type(x).__name__)
+
+def _format_code_info(co):
+ lines = []
+ lines.append("Name: %s" % co.co_name)
+ lines.append("Filename: %s" % co.co_filename)
+ lines.append("Argument count: %s" % co.co_argcount)
+ lines.append("Kw-only arguments: %s" % co.co_kwonlyargcount)
+ lines.append("Number of locals: %s" % co.co_nlocals)
+ lines.append("Stack size: %s" % co.co_stacksize)
+ lines.append("Flags: %s" % pretty_flags(co.co_flags))
+ if co.co_consts:
+ lines.append("Constants:")
+ for i_c in enumerate(co.co_consts):
+ lines.append("%4d: %r" % i_c)
+ if co.co_names:
+ lines.append("Names:")
+ for i_n in enumerate(co.co_names):
+ lines.append("%4d: %s" % i_n)
+ if co.co_varnames:
+ lines.append("Variable names:")
+ for i_n in enumerate(co.co_varnames):
+ lines.append("%4d: %s" % i_n)
+ if co.co_freevars:
+ lines.append("Free variables:")
+ for i_n in enumerate(co.co_freevars):
+ lines.append("%4d: %s" % i_n)
+ if co.co_cellvars:
+ lines.append("Cell variables:")
+ for i_n in enumerate(co.co_cellvars):
+ lines.append("%4d: %s" % i_n)
+ return "\n".join(lines)
+
+def show_code(co):
+ """Print details of methods, functions, or code to stdout."""
+ print(code_info(co))
+
def disassemble(co, lasti=-1):
"""Disassemble a code object."""
code = co.co_code
@@ -68,84 +154,86 @@ def disassemble(co, lasti=-1):
extended_arg = 0
free = None
while i < n:
- c = code[i]
- op = ord(c)
+ op = code[i]
if i in linestarts:
if i > 0:
- print
- print "%3d" % linestarts[i],
+ print()
+ print("%3d" % linestarts[i], end=' ')
else:
- print ' ',
-
- if i == lasti: print '-->',
- else: print ' ',
- if i in labels: print '>>',
- else: print ' ',
- print repr(i).rjust(4),
- print opname[op].ljust(20),
+ print(' ', end=' ')
+
+ if i == lasti: print('-->', end=' ')
+ else: print(' ', end=' ')
+ if i in labels: print('>>', end=' ')
+ else: print(' ', end=' ')
+ print(repr(i).rjust(4), end=' ')
+ print(opname[op].ljust(20), end=' ')
i = i+1
if op >= HAVE_ARGUMENT:
- oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg
+ oparg = code[i] + code[i+1]*256 + extended_arg
extended_arg = 0
i = i+2
if op == EXTENDED_ARG:
- extended_arg = oparg*65536L
- print repr(oparg).rjust(5),
+ extended_arg = oparg*65536
+ print(repr(oparg).rjust(5), end=' ')
if op in hasconst:
- print '(' + repr(co.co_consts[oparg]) + ')',
+ print('(' + repr(co.co_consts[oparg]) + ')', end=' ')
elif op in hasname:
- print '(' + co.co_names[oparg] + ')',
+ print('(' + co.co_names[oparg] + ')', end=' ')
elif op in hasjrel:
- print '(to ' + repr(i + oparg) + ')',
+ print('(to ' + repr(i + oparg) + ')', end=' ')
elif op in haslocal:
- print '(' + co.co_varnames[oparg] + ')',
+ print('(' + co.co_varnames[oparg] + ')', end=' ')
elif op in hascompare:
- print '(' + cmp_op[oparg] + ')',
+ print('(' + cmp_op[oparg] + ')', end=' ')
elif op in hasfree:
if free is None:
free = co.co_cellvars + co.co_freevars
- print '(' + free[oparg] + ')',
- print
+ print('(' + free[oparg] + ')', end=' ')
+ print()
-def disassemble_string(code, lasti=-1, varnames=None, names=None,
+def _disassemble_bytes(code, lasti=-1, varnames=None, names=None,
constants=None):
labels = findlabels(code)
n = len(code)
i = 0
while i < n:
- c = code[i]
- op = ord(c)
- if i == lasti: print '-->',
- else: print ' ',
- if i in labels: print '>>',
- else: print ' ',
- print repr(i).rjust(4),
- print opname[op].ljust(15),
+ op = code[i]
+ if i == lasti: print('-->', end=' ')
+ else: print(' ', end=' ')
+ if i in labels: print('>>', end=' ')
+ else: print(' ', end=' ')
+ print(repr(i).rjust(4), end=' ')
+ print(opname[op].ljust(15), end=' ')
i = i+1
if op >= HAVE_ARGUMENT:
- oparg = ord(code[i]) + ord(code[i+1])*256
+ oparg = code[i] + code[i+1]*256
i = i+2
- print repr(oparg).rjust(5),
+ print(repr(oparg).rjust(5), end=' ')
if op in hasconst:
if constants:
- print '(' + repr(constants[oparg]) + ')',
+ print('(' + repr(constants[oparg]) + ')', end=' ')
else:
- print '(%d)'%oparg,
+ print('(%d)'%oparg, end=' ')
elif op in hasname:
if names is not None:
- print '(' + names[oparg] + ')',
+ print('(' + names[oparg] + ')', end=' ')
else:
- print '(%d)'%oparg,
+ print('(%d)'%oparg, end=' ')
elif op in hasjrel:
- print '(to ' + repr(i + oparg) + ')',
+ print('(to ' + repr(i + oparg) + ')', end=' ')
elif op in haslocal:
if varnames:
- print '(' + varnames[oparg] + ')',
+ print('(' + varnames[oparg] + ')', end=' ')
else:
- print '(%d)' % oparg,
+ print('(%d)' % oparg, end=' ')
elif op in hascompare:
- print '(' + cmp_op[oparg] + ')',
- print
+ print('(' + cmp_op[oparg] + ')', end=' ')
+ print()
+
+def _disassemble_str(source):
+ """Compile the source string, then disassemble the code object."""
+ disassemble(_try_compile(source, '<dis>'))
disco = disassemble # XXX For backwards compatibility
@@ -159,11 +247,10 @@ def findlabels(code):
n = len(code)
i = 0
while i < n:
- c = code[i]
- op = ord(c)
+ op = code[i]
i = i+1
if op >= HAVE_ARGUMENT:
- oparg = ord(code[i]) + ord(code[i+1])*256
+ oparg = code[i] + code[i+1]*256
i = i+2
label = -1
if op in hasjrel:
@@ -181,8 +268,8 @@ def findlinestarts(code):
Generate pairs (offset, lineno) as described in Python/compile.c.
"""
- byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
- line_increments = [ord(c) for c in code.co_lnotab[1::2]]
+ byte_increments = list(code.co_lnotab[0::2])
+ line_increments = list(code.co_lnotab[1::2])
lastlineno = None
lineno = code.co_firstlineno
diff --git a/Lib/distutils/__init__.py b/Lib/distutils/__init__.py
index 036062cc337..b52a9fe6c40 100644
--- a/Lib/distutils/__init__.py
+++ b/Lib/distutils/__init__.py
@@ -8,12 +8,10 @@ used from a setup script as
setup (...)
"""
-__revision__ = "$Id$"
-
# Distutils version
#
# Updated automatically by the Python release process.
#
#--start constants--
-__version__ = "2.7.3"
+__version__ = "3.2.3"
#--end constants--
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index 834b722ed3f..fcda08e20a2 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -3,66 +3,30 @@
Utility functions for creating archive files (tarballs, zip files,
that sort of thing)."""
-__revision__ = "$Id$"
-
import os
from warnings import warn
import sys
-from distutils.errors import DistutilsExecError
-from distutils.spawn import spawn
-from distutils.dir_util import mkpath
-from distutils import log
-
try:
- from pwd import getpwnam
+ import zipfile
except ImportError:
- getpwnam = None
+ zipfile = None
-try:
- from grp import getgrnam
-except ImportError:
- getgrnam = None
-def _get_gid(name):
- """Returns a gid, given a group name."""
- if getgrnam is None or name is None:
- return None
- try:
- result = getgrnam(name)
- except KeyError:
- result = None
- if result is not None:
- return result[2]
- return None
-
-def _get_uid(name):
- """Returns an uid, given a user name."""
- if getpwnam is None or name is None:
- return None
- try:
- result = getpwnam(name)
- except KeyError:
- result = None
- if result is not None:
- return result[2]
- return None
+from distutils.errors import DistutilsExecError
+from distutils.spawn import spawn
+from distutils.dir_util import mkpath
+from distutils import log
-def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
- owner=None, group=None):
+def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0):
"""Create a (possibly compressed) tar file from all the files under
'base_dir'.
'compress' must be "gzip" (the default), "compress", "bzip2", or None.
- (compress will be deprecated in Python 3.2)
-
- 'owner' and 'group' can be used to define an owner and a group for the
- archive that is being built. If not provided, the current owner and group
- will be used.
-
+ Both "tar" and the compression utility named by 'compress' must be on
+ the default program search path, so this is probably Unix-specific.
The output tar file will be named 'base_dir' + ".tar", possibly plus
the appropriate compression extension (".gz", ".bz2" or ".Z").
-
Returns the output filename.
"""
tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''}
@@ -70,9 +34,9 @@ def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
# flags for compression program, each element of list will be an argument
if compress is not None and compress not in compress_ext.keys():
- raise ValueError, \
- ("bad value for 'compress': must be None, 'gzip', 'bzip2' "
- "or 'compress'")
+ raise ValueError(
+ "bad value for 'compress': must be None, 'gzip', 'bzip2' "
+ "or 'compress'")
archive_name = base_name + '.tar'
if compress != 'compress':
@@ -84,23 +48,10 @@ def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
import tarfile # late import so Python build itself doesn't break
log.info('Creating tar archive')
-
- uid = _get_uid(owner)
- gid = _get_gid(group)
-
- def _set_uid_gid(tarinfo):
- if gid is not None:
- tarinfo.gid = gid
- tarinfo.gname = group
- if uid is not None:
- tarinfo.uid = uid
- tarinfo.uname = owner
- return tarinfo
-
if not dry_run:
tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
try:
- tar.add(base_dir, filter=_set_uid_gid)
+ tar.add(base_dir)
finally:
tar.close()
@@ -127,11 +78,6 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
available, raises DistutilsExecError. Returns the name of the output zip
file.
"""
- try:
- import zipfile
- except ImportError:
- zipfile = None
-
zip_filename = base_name + ".zip"
mkpath(os.path.dirname(zip_filename), dry_run=dry_run)
@@ -149,18 +95,21 @@ def make_zipfile(base_name, base_dir, verbose=0, dry_run=0):
except DistutilsExecError:
# XXX really should distinguish between "couldn't find
# external 'zip' command" and "zip failed".
- raise DistutilsExecError, \
- ("unable to create zip file '%s': "
+ raise DistutilsExecError(("unable to create zip file '%s': "
"could neither import the 'zipfile' module nor "
- "find a standalone zip utility") % zip_filename
+ "find a standalone zip utility") % zip_filename)
else:
log.info("creating '%s' and adding '%s' to it",
zip_filename, base_dir)
if not dry_run:
- zip = zipfile.ZipFile(zip_filename, "w",
- compression=zipfile.ZIP_DEFLATED)
+ try:
+ zip = zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_DEFLATED)
+ except RuntimeError:
+ zip = zipfile.ZipFile(zip_filename, "w",
+ compression=zipfile.ZIP_STORED)
for dirpath, dirnames, filenames in os.walk(base_dir):
for name in filenames:
@@ -191,7 +140,7 @@ def check_archive_formats(formats):
return None
def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
- dry_run=0, owner=None, group=None):
+ dry_run=0):
"""Create an archive file (eg. zip or tar).
'base_name' is the name of the file to create, minus any format-specific
@@ -204,9 +153,6 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
ie. 'base_dir' will be the common prefix of all files and
directories in the archive. 'root_dir' and 'base_dir' both default
to the current directory. Returns the name of the archive file.
-
- 'owner' and 'group' are used when creating a tar archive. By default,
- uses the current owner and group.
"""
save_cwd = os.getcwd()
if root_dir is not None:
@@ -223,16 +169,11 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
try:
format_info = ARCHIVE_FORMATS[format]
except KeyError:
- raise ValueError, "unknown archive format '%s'" % format
+ raise ValueError("unknown archive format '%s'" % format)
func = format_info[0]
for arg, val in format_info[1]:
kwargs[arg] = val
-
- if format != 'zip':
- kwargs['owner'] = owner
- kwargs['group'] = group
-
try:
filename = func(base_name, base_dir, **kwargs)
finally:
diff --git a/Lib/distutils/bcppcompiler.py b/Lib/distutils/bcppcompiler.py
index f26e7ae4673..9f4c432d90e 100644
--- a/Lib/distutils/bcppcompiler.py
+++ b/Lib/distutils/bcppcompiler.py
@@ -11,13 +11,13 @@ for the Borland C++ compiler.
# someone should sit down and factor out the common code as
# WindowsCCompiler! --GPW
-__revision__ = "$Id$"
import os
-
-from distutils.errors import (DistutilsExecError, CompileError, LibError,
- LinkError, UnknownFileError)
-from distutils.ccompiler import CCompiler, gen_preprocess_options
+from distutils.errors import \
+ DistutilsExecError, DistutilsPlatformError, \
+ CompileError, LibError, LinkError, UnknownFileError
+from distutils.ccompiler import \
+ CCompiler, gen_preprocess_options, gen_lib_options
from distutils.file_util import write_file
from distutils.dep_util import newer
from distutils import log
@@ -111,8 +111,8 @@ class BCPPCompiler(CCompiler) :
# This needs to be compiled to a .res file -- do it now.
try:
self.spawn (["brcc32", "-fo", obj, src])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
continue # the 'for' loop
# The next two are both for the real compiler.
@@ -135,8 +135,8 @@ class BCPPCompiler(CCompiler) :
self.spawn ([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] +
extra_postargs + [src])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
return objects
@@ -160,8 +160,8 @@ class BCPPCompiler(CCompiler) :
pass # XXX what goes here?
try:
self.spawn ([self.lib] + lib_args)
- except DistutilsExecError, msg:
- raise LibError, msg
+ except DistutilsExecError as msg:
+ raise LibError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -294,8 +294,8 @@ class BCPPCompiler(CCompiler) :
self.mkpath (os.path.dirname (output_filename))
try:
self.spawn ([self.linker] + ld_args)
- except DistutilsExecError, msg:
- raise LinkError, msg
+ except DistutilsExecError as msg:
+ raise LinkError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -341,9 +341,8 @@ class BCPPCompiler(CCompiler) :
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
(base, ext) = os.path.splitext (os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc','.res']):
- raise UnknownFileError, \
- "unknown file type '%s' (from '%s')" % \
- (ext, src_name)
+ raise UnknownFileError("unknown file type '%s' (from '%s')" % \
+ (ext, src_name))
if strip_dir:
base = os.path.basename (base)
if ext == '.res':
@@ -387,8 +386,8 @@ class BCPPCompiler(CCompiler) :
self.mkpath(os.path.dirname(output_file))
try:
self.spawn(pp_args)
- except DistutilsExecError, msg:
- print msg
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ print(msg)
+ raise CompileError(msg)
# preprocess()
diff --git a/Lib/distutils/ccompiler.py b/Lib/distutils/ccompiler.py
index 7076b933946..c795c958fec 100644
--- a/Lib/distutils/ccompiler.py
+++ b/Lib/distutils/ccompiler.py
@@ -3,18 +3,12 @@
Contains CCompiler, an abstract base class that defines the interface
for the Distutils compiler abstraction model."""
-__revision__ = "$Id$"
-
-import sys
-import os
-import re
-
-from distutils.errors import (CompileError, LinkError, UnknownFileError,
- DistutilsPlatformError, DistutilsModuleError)
+import sys, os, re
+from distutils.errors import *
from distutils.spawn import spawn
from distutils.file_util import move_file
from distutils.dir_util import mkpath
-from distutils.dep_util import newer_group
+from distutils.dep_util import newer_pairwise, newer_group
from distutils.util import split_quoted, execute
from distutils import log
@@ -88,7 +82,7 @@ class CCompiler:
}
language_order = ["c++", "objc", "c"]
- def __init__ (self, verbose=0, dry_run=0, force=0):
+ def __init__(self, verbose=0, dry_run=0, force=0):
self.dry_run = dry_run
self.force = force
self.verbose = verbose
@@ -124,7 +118,7 @@ class CCompiler:
for key in self.executables.keys():
self.set_executable(key, self.executables[key])
- def set_executables(self, **args):
+ def set_executables(self, **kwargs):
"""Define the executables (and options for them) that will be run
to perform the various stages of compilation. The exact set of
executables that may be specified here depends on the compiler
@@ -150,12 +144,11 @@ class CCompiler:
# discovered at run-time, since there are many different ways to do
# basically the same things with Unix C compilers.
- for key in args.keys():
+ for key in kwargs:
if key not in self.executables:
- raise ValueError, \
- "unknown executable '%s' for class %s" % \
- (key, self.__class__.__name__)
- self.set_executable(key, args[key])
+ raise ValueError("unknown executable '%s' for class %s" %
+ (key, self.__class__.__name__))
+ self.set_executable(key, kwargs[key])
def set_executable(self, key, value):
if isinstance(value, str):
@@ -168,7 +161,7 @@ class CCompiler:
for defn in self.macros:
if defn[0] == name:
return i
- i = i + 1
+ i += 1
return None
def _check_macro_definitions(self, definitions):
@@ -178,14 +171,12 @@ class CCompiler:
"""
for defn in definitions:
if not (isinstance(defn, tuple) and
- (len (defn) == 1 or
- (len (defn) == 2 and
- (isinstance(defn[1], str) or defn[1] is None))) and
- isinstance(defn[0], str)):
- raise TypeError, \
- ("invalid macro definition '%s': " % defn) + \
+ (len(defn) in (1, 2) and
+ (isinstance (defn[1], str) or defn[1] is None)) and
+ isinstance (defn[0], str)):
+ raise TypeError(("invalid macro definition '%s': " % defn) + \
"must be tuple (string,), (string, string), or " + \
- "(string, None)"
+ "(string, None)")
# -- Bookkeeping methods -------------------------------------------
@@ -203,8 +194,7 @@ class CCompiler:
if i is not None:
del self.macros[i]
- defn = (name, value)
- self.macros.append (defn)
+ self.macros.append((name, value))
def undefine_macro(self, name):
"""Undefine a preprocessor macro for all compilations driven by
@@ -222,7 +212,7 @@ class CCompiler:
del self.macros[i]
undefn = (name,)
- self.macros.append (undefn)
+ self.macros.append(undefn)
def add_include_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
@@ -230,7 +220,7 @@ class CCompiler:
the order in which they are supplied by successive calls to
'add_include_dir()'.
"""
- self.include_dirs.append (dir)
+ self.include_dirs.append(dir)
def set_include_dirs(self, dirs):
"""Set the list of directories that will be searched to 'dirs' (a
@@ -256,7 +246,7 @@ class CCompiler:
names; the linker will be instructed to link against libraries as
many times as they are mentioned.
"""
- self.libraries.append (libname)
+ self.libraries.append(libname)
def set_libraries(self, libnames):
"""Set the list of libraries to be included in all links driven by
@@ -266,7 +256,6 @@ class CCompiler:
"""
self.libraries = libnames[:]
-
def add_library_dir(self, dir):
"""Add 'dir' to the list of directories that will be searched for
libraries specified to 'add_library()' and 'set_libraries()'. The
@@ -324,29 +313,28 @@ class CCompiler:
if outdir is None:
outdir = self.output_dir
elif not isinstance(outdir, str):
- raise TypeError, "'output_dir' must be a string or None"
+ raise TypeError("'output_dir' must be a string or None")
if macros is None:
macros = self.macros
elif isinstance(macros, list):
macros = macros + (self.macros or [])
else:
- raise TypeError, "'macros' (if supplied) must be a list of tuples"
+ raise TypeError("'macros' (if supplied) must be a list of tuples")
if incdirs is None:
incdirs = self.include_dirs
elif isinstance(incdirs, (list, tuple)):
incdirs = list(incdirs) + (self.include_dirs or [])
else:
- raise TypeError, \
- "'include_dirs' (if supplied) must be a list of strings"
+ raise TypeError(
+ "'include_dirs' (if supplied) must be a list of strings")
if extra is None:
extra = []
# Get the list of expected output (object) files
- objects = self.object_filenames(sources,
- strip_dir=0,
+ objects = self.object_filenames(sources, strip_dir=0,
output_dir=outdir)
assert len(objects) == len(sources)
@@ -384,25 +372,41 @@ class CCompiler:
if output_dir is None:
output_dir = self.output_dir
elif not isinstance(output_dir, str):
- raise TypeError, "'output_dir' must be a string or None"
+ raise TypeError("'output_dir' must be a string or None")
if macros is None:
macros = self.macros
elif isinstance(macros, list):
macros = macros + (self.macros or [])
else:
- raise TypeError, "'macros' (if supplied) must be a list of tuples"
+ raise TypeError("'macros' (if supplied) must be a list of tuples")
if include_dirs is None:
include_dirs = self.include_dirs
elif isinstance(include_dirs, (list, tuple)):
- include_dirs = list (include_dirs) + (self.include_dirs or [])
+ include_dirs = list(include_dirs) + (self.include_dirs or [])
else:
- raise TypeError, \
- "'include_dirs' (if supplied) must be a list of strings"
+ raise TypeError(
+ "'include_dirs' (if supplied) must be a list of strings")
return output_dir, macros, include_dirs
+ def _prep_compile(self, sources, output_dir, depends=None):
+ """Decide which souce files must be recompiled.
+
+ Determine the list of object files corresponding to 'sources',
+ and figure out which ones really need to be recompiled.
+ Return a list of all object files and a dictionary telling
+ which source files can be skipped.
+ """
+ # Get the list of expected output (object) files
+ objects = self.object_filenames(sources, output_dir=output_dir)
+ assert len(objects) == len(sources)
+
+ # Return an empty dict for the "which source files can be skipped"
+ # return value to preserve API compatibility.
+ return objects, {}
+
def _fix_object_args(self, objects, output_dir):
"""Typecheck and fix up some arguments supplied to various methods.
Specifically: ensure that 'objects' is a list; if output_dir is
@@ -410,14 +414,13 @@ class CCompiler:
'objects' and 'output_dir'.
"""
if not isinstance(objects, (list, tuple)):
- raise TypeError, \
- "'objects' must be a list or tuple of strings"
- objects = list (objects)
+ raise TypeError("'objects' must be a list or tuple of strings")
+ objects = list(objects)
if output_dir is None:
output_dir = self.output_dir
elif not isinstance(output_dir, str):
- raise TypeError, "'output_dir' must be a string or None"
+ raise TypeError("'output_dir' must be a string or None")
return (objects, output_dir)
@@ -433,26 +436,25 @@ class CCompiler:
elif isinstance(libraries, (list, tuple)):
libraries = list (libraries) + (self.libraries or [])
else:
- raise TypeError, \
- "'libraries' (if supplied) must be a list of strings"
+ raise TypeError(
+ "'libraries' (if supplied) must be a list of strings")
if library_dirs is None:
library_dirs = self.library_dirs
elif isinstance(library_dirs, (list, tuple)):
library_dirs = list (library_dirs) + (self.library_dirs or [])
else:
- raise TypeError, \
- "'library_dirs' (if supplied) must be a list of strings"
+ raise TypeError(
+ "'library_dirs' (if supplied) must be a list of strings")
if runtime_library_dirs is None:
runtime_library_dirs = self.runtime_library_dirs
elif isinstance(runtime_library_dirs, (list, tuple)):
- runtime_library_dirs = (list (runtime_library_dirs) +
+ runtime_library_dirs = (list(runtime_library_dirs) +
(self.runtime_library_dirs or []))
else:
- raise TypeError, \
- "'runtime_library_dirs' (if supplied) " + \
- "must be a list of strings"
+ raise TypeError("'runtime_library_dirs' (if supplied) "
+ "must be a list of strings")
return (libraries, library_dirs, runtime_library_dirs)
@@ -461,7 +463,7 @@ class CCompiler:
to recreate 'output_file'.
"""
if self.force:
- return 1
+ return True
else:
if self.dry_run:
newer = newer_group (objects, output_file, missing='newer')
@@ -489,6 +491,7 @@ class CCompiler:
pass
return lang
+
# -- Worker methods ------------------------------------------------
# (must be implemented by subclasses)
@@ -558,7 +561,6 @@ class CCompiler:
"""
# A concrete compiler class can either override this method
# entirely or implement _compile().
-
macros, objects, extra_postargs, pp_opts, build = \
self._setup_compile(output_dir, macros, include_dirs, sources,
depends, extra_postargs)
@@ -576,7 +578,6 @@ class CCompiler:
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
"""Compile 'src' to product 'obj'."""
-
# A concrete compiler class that does not override compile()
# should implement _compile().
pass
@@ -607,15 +608,26 @@ class CCompiler:
"""
pass
+
# values for target_desc parameter in link()
SHARED_OBJECT = "shared_object"
SHARED_LIBRARY = "shared_library"
EXECUTABLE = "executable"
- def link(self, target_desc, objects, output_filename, output_dir=None,
- libraries=None, library_dirs=None, runtime_library_dirs=None,
- export_symbols=None, debug=0, extra_preargs=None,
- extra_postargs=None, build_temp=None, target_lang=None):
+ def link(self,
+ target_desc,
+ objects,
+ output_filename,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ export_symbols=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ build_temp=None,
+ target_lang=None):
"""Link a bunch of stuff together to create an executable or
shared library file.
@@ -664,11 +676,19 @@ class CCompiler:
# Old 'link_*()' methods, rewritten to use the new 'link()' method.
- def link_shared_lib(self, objects, output_libname, output_dir=None,
- libraries=None, library_dirs=None,
- runtime_library_dirs=None, export_symbols=None,
- debug=0, extra_preargs=None, extra_postargs=None,
- build_temp=None, target_lang=None):
+ def link_shared_lib(self,
+ objects,
+ output_libname,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ export_symbols=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ build_temp=None,
+ target_lang=None):
self.link(CCompiler.SHARED_LIBRARY, objects,
self.library_filename(output_libname, lib_type='shared'),
output_dir,
@@ -677,21 +697,37 @@ class CCompiler:
extra_preargs, extra_postargs, build_temp, target_lang)
- def link_shared_object(self, objects, output_filename, output_dir=None,
- libraries=None, library_dirs=None,
- runtime_library_dirs=None, export_symbols=None,
- debug=0, extra_preargs=None, extra_postargs=None,
- build_temp=None, target_lang=None):
+ def link_shared_object(self,
+ objects,
+ output_filename,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ export_symbols=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ build_temp=None,
+ target_lang=None):
self.link(CCompiler.SHARED_OBJECT, objects,
output_filename, output_dir,
libraries, library_dirs, runtime_library_dirs,
export_symbols, debug,
extra_preargs, extra_postargs, build_temp, target_lang)
- def link_executable(self, objects, output_progname, output_dir=None,
- libraries=None, library_dirs=None,
- runtime_library_dirs=None, debug=0, extra_preargs=None,
- extra_postargs=None, target_lang=None):
+
+ def link_executable(self,
+ objects,
+ output_progname,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ target_lang=None):
self.link(CCompiler.EXECUTABLE, objects,
self.executable_filename(output_progname), output_dir,
libraries, library_dirs, runtime_library_dirs, None,
@@ -727,7 +763,6 @@ class CCompiler:
the current platform. The optional arguments can be used to
augment the compilation environment.
"""
-
# this can't be included at module scope because it tries to
# import math which might not be available at that point - maybe
# the necessary logic should just be inlined?
@@ -817,8 +852,8 @@ main (int argc, char **argv) {
base = os.path.splitdrive(base)[1] # Chop off the drive
base = base[os.path.isabs(base):] # If abs, chop off leading /
if ext not in self.src_extensions:
- raise UnknownFileError, \
- "unknown file type '%s' (from '%s')" % (ext, src_name)
+ raise UnknownFileError(
+ "unknown file type '%s' (from '%s')" % (ext, src_name))
if strip_dir:
base = os.path.basename(base)
obj_names.append(os.path.join(output_dir,
@@ -828,24 +863,25 @@ main (int argc, char **argv) {
def shared_object_filename(self, basename, strip_dir=0, output_dir=''):
assert output_dir is not None
if strip_dir:
- basename = os.path.basename (basename)
+ basename = os.path.basename(basename)
return os.path.join(output_dir, basename + self.shared_lib_extension)
def executable_filename(self, basename, strip_dir=0, output_dir=''):
assert output_dir is not None
if strip_dir:
- basename = os.path.basename (basename)
+ basename = os.path.basename(basename)
return os.path.join(output_dir, basename + (self.exe_extension or ''))
def library_filename(self, libname, lib_type='static', # or 'shared'
strip_dir=0, output_dir=''):
assert output_dir is not None
if lib_type not in ("static", "shared", "dylib"):
- raise ValueError, "'lib_type' must be \"static\", \"shared\" or \"dylib\""
+ raise ValueError(
+ "'lib_type' must be \"static\", \"shared\" or \"dylib\"")
fmt = getattr(self, lib_type + "_lib_format")
ext = getattr(self, lib_type + "_lib_extension")
- dir, base = os.path.split (libname)
+ dir, base = os.path.split(libname)
filename = fmt % (base, ext)
if strip_dir:
dir = ''
@@ -861,7 +897,7 @@ main (int argc, char **argv) {
def debug_print(self, msg):
from distutils.debug import DEBUG
if DEBUG:
- print msg
+ print(msg)
def warn(self, msg):
sys.stderr.write("warning: %s\n" % msg)
@@ -875,13 +911,10 @@ main (int argc, char **argv) {
def move_file(self, src, dst):
return move_file(src, dst, dry_run=self.dry_run)
- def mkpath(self, name, mode=0777):
+ def mkpath (self, name, mode=0o777):
mkpath(name, mode, dry_run=self.dry_run)
-# class CCompiler
-
-
# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
# type for that platform. Keys are interpreted as re match
# patterns. Order is important; platform mappings are preferred over
@@ -902,15 +935,14 @@ _default_compilers = (
)
def get_default_compiler(osname=None, platform=None):
- """ Determine the default compiler to use for the given platform.
-
- osname should be one of the standard Python OS names (i.e. the
- ones returned by os.name) and platform the common value
- returned by sys.platform for the platform in question.
+ """Determine the default compiler to use for the given platform.
- The default values are os.name and sys.platform in case the
- parameters are not given.
+ osname should be one of the standard Python OS names (i.e. the
+ ones returned by os.name) and platform the common value
+ returned by sys.platform for the platform in question.
+ The default values are os.name and sys.platform in case the
+ parameters are not given.
"""
if osname is None:
osname = os.name
@@ -980,7 +1012,7 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
msg = "don't know how to compile C/C++ code on platform '%s'" % plat
if compiler is not None:
msg = msg + " with '%s' compiler" % compiler
- raise DistutilsPlatformError, msg
+ raise DistutilsPlatformError(msg)
try:
module_name = "distutils." + module_name
@@ -988,13 +1020,13 @@ def new_compiler(plat=None, compiler=None, verbose=0, dry_run=0, force=0):
module = sys.modules[module_name]
klass = vars(module)[class_name]
except ImportError:
- raise DistutilsModuleError, \
+ raise DistutilsModuleError(
"can't compile C/C++ code: unable to load module '%s'" % \
- module_name
+ module_name)
except KeyError:
- raise DistutilsModuleError, \
- ("can't compile C/C++ code: unable to find class '%s' " +
- "in module '%s'") % (class_name, module_name)
+ raise DistutilsModuleError(
+ "can't compile C/C++ code: unable to find class '%s' "
+ "in module '%s'" % (class_name, module_name))
# XXX The None is necessary to preserve backwards compatibility
# with classes that expect verbose to be the first positional
@@ -1023,42 +1055,36 @@ def gen_preprocess_options(macros, include_dirs):
# redundancies like this should probably be the province of
# CCompiler, since the data structures used are inherited from it
# and therefore common to all CCompiler classes.
-
pp_opts = []
for macro in macros:
-
- if not (isinstance(macro, tuple) and
- 1 <= len (macro) <= 2):
- raise TypeError, \
- ("bad macro definition '%s': " +
- "each element of 'macros' list must be a 1- or 2-tuple") % \
- macro
-
- if len (macro) == 1: # undefine this macro
- pp_opts.append ("-U%s" % macro[0])
- elif len (macro) == 2:
+ if not (isinstance(macro, tuple) and 1 <= len(macro) <= 2):
+ raise TypeError(
+ "bad macro definition '%s': "
+ "each element of 'macros' list must be a 1- or 2-tuple"
+ % macro)
+
+ if len(macro) == 1: # undefine this macro
+ pp_opts.append("-U%s" % macro[0])
+ elif len(macro) == 2:
if macro[1] is None: # define with no explicit value
- pp_opts.append ("-D%s" % macro[0])
+ pp_opts.append("-D%s" % macro[0])
else:
# XXX *don't* need to be clever about quoting the
# macro value here, because we're going to avoid the
# shell at all costs when we spawn the command!
- pp_opts.append ("-D%s=%s" % macro)
+ pp_opts.append("-D%s=%s" % macro)
for dir in include_dirs:
- pp_opts.append ("-I%s" % dir)
-
+ pp_opts.append("-I%s" % dir)
return pp_opts
-def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
+def gen_lib_options (compiler, library_dirs, runtime_library_dirs, libraries):
"""Generate linker options for searching library directories and
- linking with specific libraries.
-
- 'libraries' and 'library_dirs' are, respectively, lists of library names
- (not filenames!) and search directories. Returns a list of command-line
- options suitable for use with some compiler (depending on the two format
- strings passed in).
+ linking with specific libraries. 'libraries' and 'library_dirs' are,
+ respectively, lists of library names (not filenames!) and search
+ directories. Returns a list of command-line options suitable for use
+ with some compiler (depending on the two format strings passed in).
"""
lib_opts = []
@@ -1068,7 +1094,7 @@ def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
for dir in runtime_library_dirs:
opt = compiler.runtime_library_dir_option(dir)
if isinstance(opt, list):
- lib_opts.extend(opt)
+ lib_opts = lib_opts + opt
else:
lib_opts.append(opt)
@@ -1079,15 +1105,14 @@ def gen_lib_options(compiler, library_dirs, runtime_library_dirs, libraries):
# pretty nasty way to arrange your C code.
for lib in libraries:
- lib_dir, lib_name = os.path.split(lib)
- if lib_dir != '':
+ (lib_dir, lib_name) = os.path.split(lib)
+ if lib_dir:
lib_file = compiler.find_library_file([lib_dir], lib_name)
- if lib_file is not None:
+ if lib_file:
lib_opts.append(lib_file)
else:
compiler.warn("no library file corresponding to "
"'%s' found (skipping)" % lib)
else:
- lib_opts.append(compiler.library_option(lib))
-
+ lib_opts.append(compiler.library_option (lib))
return lib_opts
diff --git a/Lib/distutils/cmd.py b/Lib/distutils/cmd.py
index 9ad5657e40a..3ea08101acb 100644
--- a/Lib/distutils/cmd.py
+++ b/Lib/distutils/cmd.py
@@ -4,8 +4,6 @@ Provides the Command class, the base class for the command classes
in the distutils.command package.
"""
-__revision__ = "$Id$"
-
import sys, os, re
from distutils.errors import DistutilsOptionError
from distutils import util, dir_util, file_util, archive_util, dep_util
@@ -56,9 +54,9 @@ class Command:
from distutils.dist import Distribution
if not isinstance(dist, Distribution):
- raise TypeError, "dist must be a Distribution instance"
+ raise TypeError("dist must be a Distribution instance")
if self.__class__ is Command:
- raise RuntimeError, "Command is an abstract class"
+ raise RuntimeError("Command is an abstract class")
self.distribution = dist
self.initialize_options()
@@ -102,7 +100,7 @@ class Command:
else:
return myval
else:
- raise AttributeError, attr
+ raise AttributeError(attr)
def ensure_finalized(self):
if not self.finalized:
@@ -132,8 +130,8 @@ class Command:
This method must be implemented by all command classes.
"""
- raise RuntimeError, \
- "abstract method -- subclass %s must override" % self.__class__
+ raise RuntimeError("abstract method -- subclass %s must override"
+ % self.__class__)
def finalize_options(self):
"""Set final values for all the options that this command supports.
@@ -146,8 +144,8 @@ class Command:
This method must be implemented by all command classes.
"""
- raise RuntimeError, \
- "abstract method -- subclass %s must override" % self.__class__
+ raise RuntimeError("abstract method -- subclass %s must override"
+ % self.__class__)
def dump_options(self, header=None, indent=""):
@@ -174,8 +172,8 @@ class Command:
This method must be implemented by all command classes.
"""
- raise RuntimeError, \
- "abstract method -- subclass %s must override" % self.__class__
+ raise RuntimeError("abstract method -- subclass %s must override"
+ % self.__class__)
def announce(self, msg, level=1):
"""If the current verbosity level is of greater than or equal to
@@ -189,7 +187,7 @@ class Command:
"""
from distutils.debug import DEBUG
if DEBUG:
- print msg
+ print(msg)
sys.stdout.flush()
@@ -212,8 +210,8 @@ class Command:
setattr(self, option, default)
return default
elif not isinstance(val, str):
- raise DistutilsOptionError, \
- "'%s' must be a %s (got `%s`)" % (option, what, val)
+ raise DistutilsOptionError("'%s' must be a %s (got `%s`)"
+ % (option, what, val))
return val
def ensure_string(self, option, default=None):
@@ -235,27 +233,20 @@ class Command:
setattr(self, option, re.split(r',\s*|\s+', val))
else:
if isinstance(val, list):
- # checks if all elements are str
- ok = 1
- for element in val:
- if not isinstance(element, str):
- ok = 0
- break
+ ok = all(isinstance(v, str) for v in val)
else:
- ok = 0
-
+ ok = False
if not ok:
- raise DistutilsOptionError, \
- "'%s' must be a list of strings (got %r)" % \
- (option, val)
+ raise DistutilsOptionError(
+ "'%s' must be a list of strings (got %r)"
+ % (option, val))
-
- def _ensure_tested_string(self, option, tester,
- what, error_fmt, default=None):
+ def _ensure_tested_string(self, option, tester, what, error_fmt,
+ default=None):
val = self._ensure_stringlike(option, what, default)
if val is not None and not tester(val):
- raise DistutilsOptionError, \
- ("error in '%s' option: " + error_fmt) % (option, val)
+ raise DistutilsOptionError(("error in '%s' option: " + error_fmt)
+ % (option, val))
def ensure_filename(self, option):
"""Ensure that 'option' is the name of an existing file."""
@@ -291,16 +282,12 @@ class Command:
'src_option' in the 'src_cmd' command object, and copy it to
'dst_option' in the current command object".
"""
-
# Option_pairs: list of (src_option, dst_option) tuples
-
src_cmd_obj = self.distribution.get_command_obj(src_cmd)
src_cmd_obj.ensure_finalized()
for (src_option, dst_option) in option_pairs:
if getattr(self, dst_option) is None:
- setattr(self, dst_option,
- getattr(src_cmd_obj, src_option))
-
+ setattr(self, dst_option, getattr(src_cmd_obj, src_option))
def get_finalized_command(self, command, create=1):
"""Wrapper around Distribution's 'get_command_obj()' method: find
@@ -315,8 +302,8 @@ class Command:
# XXX rename to 'get_reinitialized_command()'? (should do the
# same in dist.py, if so)
def reinitialize_command(self, command, reinit_subcommands=0):
- return self.distribution.reinitialize_command(
- command, reinit_subcommands)
+ return self.distribution.reinitialize_command(command,
+ reinit_subcommands)
def run_command(self, command):
"""Run some other command: uses the 'run_command()' method of
@@ -348,48 +335,39 @@ class Command:
def execute(self, func, args, msg=None, level=1):
util.execute(func, args, msg, dry_run=self.dry_run)
- def mkpath(self, name, mode=0777):
+ def mkpath(self, name, mode=0o777):
dir_util.mkpath(name, mode, dry_run=self.dry_run)
- def copy_file(self, infile, outfile,
- preserve_mode=1, preserve_times=1, link=None, level=1):
+ def copy_file(self, infile, outfile, preserve_mode=1, preserve_times=1,
+ link=None, level=1):
"""Copy a file respecting verbose, dry-run and force flags. (The
former two default to whatever is in the Distribution object, and
the latter defaults to false for commands that don't define it.)"""
+ return file_util.copy_file(infile, outfile, preserve_mode,
+ preserve_times, not self.force, link,
+ dry_run=self.dry_run)
- return file_util.copy_file(
- infile, outfile,
- preserve_mode, preserve_times,
- not self.force,
- link,
- dry_run=self.dry_run)
-
- def copy_tree(self, infile, outfile,
- preserve_mode=1, preserve_times=1, preserve_symlinks=0,
- level=1):
+ def copy_tree(self, infile, outfile, preserve_mode=1, preserve_times=1,
+ preserve_symlinks=0, level=1):
"""Copy an entire directory tree respecting verbose, dry-run,
and force flags.
"""
- return dir_util.copy_tree(
- infile, outfile,
- preserve_mode,preserve_times,preserve_symlinks,
- not self.force,
- dry_run=self.dry_run)
+ return dir_util.copy_tree(infile, outfile, preserve_mode,
+ preserve_times, preserve_symlinks,
+ not self.force, dry_run=self.dry_run)
def move_file (self, src, dst, level=1):
"""Move a file respecting dry-run flag."""
- return file_util.move_file(src, dst, dry_run = self.dry_run)
+ return file_util.move_file(src, dst, dry_run=self.dry_run)
- def spawn (self, cmd, search_path=1, level=1):
+ def spawn(self, cmd, search_path=1, level=1):
"""Spawn an external command respecting dry-run flag."""
from distutils.spawn import spawn
- spawn(cmd, search_path, dry_run= self.dry_run)
+ spawn(cmd, search_path, dry_run=self.dry_run)
- def make_archive(self, base_name, format, root_dir=None, base_dir=None,
- owner=None, group=None):
- return archive_util.make_archive(base_name, format, root_dir,
- base_dir, dry_run=self.dry_run,
- owner=owner, group=group)
+ def make_archive(self, base_name, format, root_dir=None, base_dir=None):
+ return archive_util.make_archive(base_name, format, root_dir, base_dir,
+ dry_run=self.dry_run)
def make_file(self, infiles, outfile, func, args,
exec_msg=None, skip_msg=None, level=1):
@@ -408,19 +386,17 @@ class Command:
if isinstance(infiles, str):
infiles = (infiles,)
elif not isinstance(infiles, (list, tuple)):
- raise TypeError, \
- "'infiles' must be a string, or a list or tuple of strings"
+ raise TypeError(
+ "'infiles' must be a string, or a list or tuple of strings")
if exec_msg is None:
- exec_msg = "generating %s from %s" % \
- (outfile, ', '.join(infiles))
+ exec_msg = "generating %s from %s" % (outfile, ', '.join(infiles))
# If 'outfile' must be regenerated (either because it doesn't
# exist, is out-of-date, or the 'force' flag is true) then
# perform the action that presumably regenerates it
if self.force or dep_util.newer_group(infiles, outfile):
self.execute(func, args, exec_msg, level)
-
# Otherwise, print the "skip" message
else:
log.debug(skip_msg)
diff --git a/Lib/distutils/command/__init__.py b/Lib/distutils/command/__init__.py
index 20b159f74ec..481eea9fd4b 100644
--- a/Lib/distutils/command/__init__.py
+++ b/Lib/distutils/command/__init__.py
@@ -3,8 +3,6 @@
Package containing implementation of all the standard Distutils
commands."""
-__revision__ = "$Id$"
-
__all__ = ['build',
'build_py',
'build_ext',
@@ -22,8 +20,8 @@ __all__ = ['build',
'bdist_dumb',
'bdist_rpm',
'bdist_wininst',
- 'upload',
'check',
+ 'upload',
# These two are reserved for future use:
#'bdist_sdux',
#'bdist_pkgtool',
diff --git a/Lib/distutils/command/bdist.py b/Lib/distutils/command/bdist.py
index d7910b14d6e..c5188eb3719 100644
--- a/Lib/distutils/command/bdist.py
+++ b/Lib/distutils/command/bdist.py
@@ -3,13 +3,10 @@
Implements the Distutils 'bdist' command (create a built [binary]
distribution)."""
-__revision__ = "$Id$"
-
import os
-
-from distutils.util import get_platform
from distutils.core import Command
-from distutils.errors import DistutilsPlatformError, DistutilsOptionError
+from distutils.errors import *
+from distutils.util import get_platform
def show_formats():
@@ -40,12 +37,6 @@ class bdist(Command):
"[default: dist]"),
('skip-build', None,
"skip rebuilding everything (for testing/debugging)"),
- ('owner=', 'u',
- "Owner name used when creating a tar file"
- " [default: current user]"),
- ('group=', 'g',
- "Group name used when creating a tar file"
- " [default: current group]"),
]
boolean_options = ['skip-build']
@@ -87,8 +78,6 @@ class bdist(Command):
self.formats = None
self.dist_dir = None
self.skip_build = 0
- self.group = None
- self.owner = None
def finalize_options(self):
# have to finalize 'plat_name' before 'bdist_base'
@@ -111,9 +100,9 @@ class bdist(Command):
try:
self.formats = [self.default_format[os.name]]
except KeyError:
- raise DistutilsPlatformError, \
- "don't know how to create built distributions " + \
- "on platform %s" % os.name
+ raise DistutilsPlatformError(
+ "don't know how to create built distributions "
+ "on platform %s" % os.name)
if self.dist_dir is None:
self.dist_dir = "dist"
@@ -125,7 +114,7 @@ class bdist(Command):
try:
commands.append(self.format_command[format][0])
except KeyError:
- raise DistutilsOptionError, "invalid format '%s'" % format
+ raise DistutilsOptionError("invalid format '%s'" % format)
# Reinitialize and run each command.
for i in range(len(self.formats)):
@@ -134,11 +123,6 @@ class bdist(Command):
if cmd_name not in self.no_format_option:
sub_cmd.format = self.formats[i]
- # passing the owner and group names for tar archiving
- if cmd_name == 'bdist_dumb':
- sub_cmd.owner = self.owner
- sub_cmd.group = self.group
-
# If we're going to need to run this command again, tell it to
# keep its temporary files around so subsequent runs go faster.
if cmd_name in commands[i+1:]:
diff --git a/Lib/distutils/command/bdist_dumb.py b/Lib/distutils/command/bdist_dumb.py
index 2f3c66829a1..1ab09d16163 100644
--- a/Lib/distutils/command/bdist_dumb.py
+++ b/Lib/distutils/command/bdist_dumb.py
@@ -4,21 +4,17 @@ Implements the Distutils 'bdist_dumb' command (create a "dumb" built
distribution -- i.e., just an archive to be unpacked under $prefix or
$exec_prefix)."""
-__revision__ = "$Id$"
-
import os
-
-from sysconfig import get_python_version
-
-from distutils.util import get_platform
from distutils.core import Command
+from distutils.util import get_platform
from distutils.dir_util import remove_tree, ensure_relative
-from distutils.errors import DistutilsPlatformError
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
from distutils import log
-class bdist_dumb (Command):
+class bdist_dumb(Command):
- description = 'create a "dumb" built distribution'
+ description = "create a \"dumb\" built distribution"
user_options = [('bdist-dir=', 'd',
"temporary directory for creating the distribution"),
@@ -37,12 +33,6 @@ class bdist_dumb (Command):
('relative', None,
"build the archive using relative paths"
"(default: false)"),
- ('owner=', 'u',
- "Owner name used when creating a tar file"
- " [default: current user]"),
- ('group=', 'g',
- "Group name used when creating a tar file"
- " [default: current group]"),
]
boolean_options = ['keep-temp', 'skip-build', 'relative']
@@ -51,8 +41,7 @@ class bdist_dumb (Command):
'nt': 'zip',
'os2': 'zip' }
-
- def initialize_options (self):
+ def initialize_options(self):
self.bdist_dir = None
self.plat_name = None
self.format = None
@@ -60,8 +49,6 @@ class bdist_dumb (Command):
self.dist_dir = None
self.skip_build = None
self.relative = 0
- self.owner = None
- self.group = None
def finalize_options(self):
if self.bdist_dir is None:
@@ -72,9 +59,9 @@ class bdist_dumb (Command):
try:
self.format = self.default_format[os.name]
except KeyError:
- raise DistutilsPlatformError, \
- ("don't know how to create dumb built distributions " +
- "on platform %s") % os.name
+ raise DistutilsPlatformError(
+ "don't know how to create dumb built distributions "
+ "on platform %s" % os.name)
self.set_undefined_options('bdist',
('dist_dir', 'dist_dir'),
@@ -109,8 +96,8 @@ class bdist_dumb (Command):
else:
if (self.distribution.has_ext_modules() and
(install.install_base != install.install_platbase)):
- raise DistutilsPlatformError, \
- ("can't make a dumb built distribution where "
+ raise DistutilsPlatformError(
+ "can't make a dumb built distribution where "
"base and platbase are different (%s, %s)"
% (repr(install.install_base),
repr(install.install_platbase)))
@@ -120,8 +107,7 @@ class bdist_dumb (Command):
# Make the archive
filename = self.make_archive(pseudoinstall_root,
- self.format, root_dir=archive_root,
- owner=self.owner, group=self.group)
+ self.format, root_dir=archive_root)
if self.distribution.has_ext_modules():
pyversion = get_python_version()
else:
diff --git a/Lib/distutils/command/bdist_msi.py b/Lib/distutils/command/bdist_msi.py
index 703f873b164..b3cfe9ceff7 100644
--- a/Lib/distutils/command/bdist_msi.py
+++ b/Lib/distutils/command/bdist_msi.py
@@ -1,21 +1,19 @@
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2005, 2006 Martin von Löwis
+# Copyright (C) 2005, 2006 Martin von Löwis
# Licensed to PSF under a Contributor Agreement.
# The bdist_wininst command proper
# based on bdist_wininst
"""
Implements the bdist_msi command.
"""
-import sys, os
-from sysconfig import get_python_version
+import sys, os
from distutils.core import Command
from distutils.dir_util import remove_tree
+from distutils.sysconfig import get_python_version
from distutils.version import StrictVersion
from distutils.errors import DistutilsOptionError
-from distutils import log
from distutils.util import get_platform
-
+from distutils import log
import msilib
from msilib import schema, sequence, text
from msilib import Directory, Feature, Dialog, add_data
@@ -29,6 +27,7 @@ class PyDialog(Dialog):
default, cancel, bitmap=true)"""
Dialog.__init__(self, *args)
ruler = self.h - 36
+ bmwidth = 152*ruler/328
#if kw.get("bitmap", True):
# self.bitmap("Bitmap", 0, 0, bmwidth, ruler, "PythonWin")
self.line("BottomLine", 0, ruler, self.w, 0)
@@ -81,7 +80,7 @@ class PyDialog(Dialog):
Return the button, so that events can be associated"""
return self.pushbutton(name, int(self.w*xpos - 28), self.h-27, 56, 17, 3, title, next)
-class bdist_msi (Command):
+class bdist_msi(Command):
description = "create a Microsoft Installer (.msi) binary distribution"
@@ -123,7 +122,7 @@ class bdist_msi (Command):
'3.5', '3.6', '3.7', '3.8', '3.9']
other_version = 'X'
- def initialize_options (self):
+ def initialize_options(self):
self.bdist_dir = None
self.plat_name = None
self.keep_temp = 0
@@ -136,7 +135,7 @@ class bdist_msi (Command):
self.pre_install_script = None
self.versions = None
- def finalize_options (self):
+ def finalize_options(self):
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
if self.bdist_dir is None:
@@ -151,9 +150,9 @@ class bdist_msi (Command):
self.versions = [self.target_version]
if not self.skip_build and self.distribution.has_ext_modules()\
and self.target_version != short_version:
- raise DistutilsOptionError, \
- "target version can only be %s, or the '--skip-build'" \
- " option must be specified" % (short_version,)
+ raise DistutilsOptionError(
+ "target version can only be %s, or the '--skip-build'"
+ " option must be specified" % (short_version,))
else:
self.versions = list(self.all_versions)
@@ -163,21 +162,20 @@ class bdist_msi (Command):
)
if self.pre_install_script:
- raise DistutilsOptionError, "the pre-install-script feature is not yet implemented"
+ raise DistutilsOptionError(
+ "the pre-install-script feature is not yet implemented")
if self.install_script:
for script in self.distribution.scripts:
if self.install_script == os.path.basename(script):
break
else:
- raise DistutilsOptionError, \
- "install_script '%s' not found in scripts" % \
- self.install_script
+ raise DistutilsOptionError(
+ "install_script '%s' not found in scripts"
+ % self.install_script)
self.install_script_key = None
- # finalize_options()
-
- def run (self):
+ def run(self):
if not self.skip_build:
self.run_command('build')
@@ -424,6 +422,7 @@ class bdist_msi (Command):
# see "Dialog Style Bits"
modal = 3 # visible | modal
modeless = 1 # visible
+ track_disk_space = 32
# UI customization properties
add_data(db, "Property",
diff --git a/Lib/distutils/command/bdist_rpm.py b/Lib/distutils/command/bdist_rpm.py
index 595824367e3..ac4621791d5 100644
--- a/Lib/distutils/command/bdist_rpm.py
+++ b/Lib/distutils/command/bdist_rpm.py
@@ -3,20 +3,16 @@
Implements the Distutils 'bdist_rpm' command (create RPM source and binary
distributions)."""
-__revision__ = "$Id$"
-
-import sys
-import os
-import string
-
+import subprocess, sys, os
from distutils.core import Command
from distutils.debug import DEBUG
+from distutils.util import get_platform
from distutils.file_util import write_file
-from distutils.errors import (DistutilsOptionError, DistutilsPlatformError,
- DistutilsFileError, DistutilsExecError)
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
from distutils import log
-class bdist_rpm (Command):
+class bdist_rpm(Command):
description = "create an RPM distribution"
@@ -137,7 +133,7 @@ class bdist_rpm (Command):
'rpm2-mode': 'rpm3-mode'}
- def initialize_options (self):
+ def initialize_options(self):
self.bdist_base = None
self.rpm_base = None
self.dist_dir = None
@@ -182,33 +178,29 @@ class bdist_rpm (Command):
self.force_arch = None
self.quiet = 0
- # initialize_options()
-
-
- def finalize_options (self):
+ def finalize_options(self):
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
if self.rpm_base is None:
if not self.rpm3_mode:
- raise DistutilsOptionError, \
- "you must specify --rpm-base in RPM 2 mode"
+ raise DistutilsOptionError(
+ "you must specify --rpm-base in RPM 2 mode")
self.rpm_base = os.path.join(self.bdist_base, "rpm")
if self.python is None:
if self.fix_python:
self.python = sys.executable
else:
- self.python = "python"
+ self.python = "python3"
elif self.fix_python:
- raise DistutilsOptionError, \
- "--python and --fix-python are mutually exclusive options"
+ raise DistutilsOptionError(
+ "--python and --fix-python are mutually exclusive options")
if os.name != 'posix':
- raise DistutilsPlatformError, \
- ("don't know how to create RPM "
+ raise DistutilsPlatformError("don't know how to create RPM "
"distributions on platform %s" % os.name)
if self.binary_only and self.source_only:
- raise DistutilsOptionError, \
- "cannot supply both '--source-only' and '--binary-only'"
+ raise DistutilsOptionError(
+ "cannot supply both '--source-only' and '--binary-only'")
# don't pass CFLAGS to pure python distributions
if not self.distribution.has_ext_modules():
@@ -217,9 +209,7 @@ class bdist_rpm (Command):
self.set_undefined_options('bdist', ('dist_dir', 'dist_dir'))
self.finalize_package_data()
- # finalize_options()
-
- def finalize_package_data (self):
+ def finalize_package_data(self):
self.ensure_string('group', "Development/Libraries")
self.ensure_string('vendor',
"%s <%s>" % (self.distribution.get_contact(),
@@ -263,17 +253,14 @@ class bdist_rpm (Command):
self.ensure_string_list('obsoletes')
self.ensure_string('force_arch')
- # finalize_package_data ()
-
-
- def run (self):
+ def run(self):
if DEBUG:
- print "before _get_package_data():"
- print "vendor =", self.vendor
- print "packager =", self.packager
- print "doc_files =", self.doc_files
- print "changelog =", self.changelog
+ print("before _get_package_data():")
+ print("vendor =", self.vendor)
+ print("packager =", self.packager)
+ print("doc_files =", self.doc_files)
+ print("changelog =", self.changelog)
# make directories
if self.spec_only:
@@ -317,9 +304,8 @@ class bdist_rpm (Command):
if os.path.exists(self.icon):
self.copy_file(self.icon, source_dir)
else:
- raise DistutilsFileError, \
- "icon file '%s' does not exist" % self.icon
-
+ raise DistutilsFileError(
+ "icon file '%s' does not exist" % self.icon)
# build package
log.info("building RPMs")
@@ -334,6 +320,7 @@ class bdist_rpm (Command):
rpm_cmd.append('-bb')
else:
rpm_cmd.append('-ba')
+ rpm_cmd.extend(['--define', '__python %s' % self.python])
if self.rpm3_mode:
rpm_cmd.extend(['--define',
'_topdir %s' % os.path.abspath(self.rpm_base)])
@@ -358,11 +345,11 @@ class bdist_rpm (Command):
try:
binary_rpms = []
source_rpm = None
- while 1:
+ while True:
line = out.readline()
if not line:
break
- l = string.split(string.strip(line))
+ l = line.strip().split()
assert(len(l) == 2)
binary_rpms.append(l[1])
# The source rpm is named after the first entry in the spec file
@@ -401,7 +388,6 @@ class bdist_rpm (Command):
os.path.basename(rpm))
self.distribution.dist_files.append(
('bdist_rpm', pyversion, filename))
- # run()
def _dist_path(self, path):
return os.path.join(self.dist_dir, os.path.basename(path))
@@ -420,6 +406,21 @@ class bdist_rpm (Command):
'Summary: ' + self.distribution.get_description(),
]
+ # Workaround for #14443 which affects some RPM based systems such as
+ # RHEL6 (and probably derivatives)
+ vendor_hook = subprocess.getoutput('rpm --eval %{__os_install_post}')
+ # Generate a potential replacement value for __os_install_post (whilst
+ # normalizing the whitespace to simplify the test for whether the
+ # invocation of brp-python-bytecompile passes in __python):
+ vendor_hook = '\n'.join([' %s \\' % line.strip()
+ for line in vendor_hook.splitlines()])
+ problem = "brp-python-bytecompile \\\n"
+ fixed = "brp-python-bytecompile %{__python} \\\n"
+ fixed_hook = vendor_hook.replace(problem, fixed)
+ if fixed_hook != vendor_hook:
+ spec_file.append('# Workaround for http://bugs.python.org/issue14443')
+ spec_file.append('%define __os_install_post ' + fixed_hook + '\n')
+
# put locale summaries into spec file
# XXX not supported for now (hard to put a dictionary
# in a config file -- arg!)
@@ -460,9 +461,9 @@ class bdist_rpm (Command):
'Conflicts',
'Obsoletes',
):
- val = getattr(self, string.lower(field))
+ val = getattr(self, field.lower())
if isinstance(val, list):
- spec_file.append('%s: %s' % (field, string.join(val)))
+ spec_file.append('%s: %s' % (field, ' '.join(val)))
elif val is not None:
spec_file.append('%s: %s' % (field, val))
@@ -475,7 +476,7 @@ class bdist_rpm (Command):
if self.build_requires:
spec_file.append('BuildRequires: ' +
- string.join(self.build_requires))
+ ' '.join(self.build_requires))
if self.icon:
spec_file.append('Icon: ' + os.path.basename(self.icon))
@@ -536,7 +537,7 @@ class bdist_rpm (Command):
'',
'%' + rpm_opt,])
if val:
- spec_file.extend(string.split(open(val, 'r').read(), '\n'))
+ spec_file.extend(open(val, 'r').read().split('\n'))
else:
spec_file.append(default)
@@ -549,7 +550,7 @@ class bdist_rpm (Command):
])
if self.doc_files:
- spec_file.append('%doc ' + string.join(self.doc_files))
+ spec_file.append('%doc ' + ' '.join(self.doc_files))
if self.changelog:
spec_file.extend([
@@ -559,16 +560,14 @@ class bdist_rpm (Command):
return spec_file
- # _make_spec_file ()
-
def _format_changelog(self, changelog):
"""Format the changelog correctly and convert it to a list of strings
"""
if not changelog:
return changelog
new_changelog = []
- for line in string.split(string.strip(changelog), '\n'):
- line = string.strip(line)
+ for line in changelog.strip().split('\n'):
+ line = line.strip()
if line[0] == '*':
new_changelog.extend(['', line])
elif line[0] == '-':
@@ -581,7 +580,3 @@ class bdist_rpm (Command):
del new_changelog[0]
return new_changelog
-
- # _format_changelog()
-
-# class bdist_rpm
diff --git a/Lib/distutils/command/bdist_wininst.py b/Lib/distutils/command/bdist_wininst.py
index aa9383af98b..e3ed3ad82c1 100644
--- a/Lib/distutils/command/bdist_wininst.py
+++ b/Lib/distutils/command/bdist_wininst.py
@@ -3,21 +3,15 @@
Implements the Distutils 'bdist_wininst' command: create a windows installer
exe-program."""
-__revision__ = "$Id$"
-
-import sys
-import os
-import string
-
-from sysconfig import get_python_version
-
+import sys, os
from distutils.core import Command
-from distutils.dir_util import remove_tree
-from distutils.errors import DistutilsOptionError, DistutilsPlatformError
-from distutils import log
from distutils.util import get_platform
+from distutils.dir_util import create_tree, remove_tree
+from distutils.errors import *
+from distutils.sysconfig import get_python_version
+from distutils import log
-class bdist_wininst (Command):
+class bdist_wininst(Command):
description = "create an executable installer for MS Windows"
@@ -61,7 +55,7 @@ class bdist_wininst (Command):
boolean_options = ['keep-temp', 'no-target-compile', 'no-target-optimize',
'skip-build']
- def initialize_options (self):
+ def initialize_options(self):
self.bdist_dir = None
self.plat_name = None
self.keep_temp = 0
@@ -76,10 +70,8 @@ class bdist_wininst (Command):
self.pre_install_script = None
self.user_access_control = None
- # initialize_options()
-
- def finalize_options (self):
+ def finalize_options(self):
self.set_undefined_options('bdist', ('skip_build', 'skip_build'))
if self.bdist_dir is None:
@@ -98,9 +90,9 @@ class bdist_wininst (Command):
if not self.skip_build and self.distribution.has_ext_modules():
short_version = get_python_version()
if self.target_version and self.target_version != short_version:
- raise DistutilsOptionError, \
+ raise DistutilsOptionError(
"target version can only be %s, or the '--skip-build'" \
- " option must be specified" % (short_version,)
+ " option must be specified" % (short_version,))
self.target_version = short_version
self.set_undefined_options('bdist',
@@ -113,13 +105,11 @@ class bdist_wininst (Command):
if self.install_script == os.path.basename(script):
break
else:
- raise DistutilsOptionError, \
- "install_script '%s' not found in scripts" % \
- self.install_script
- # finalize_options()
-
+ raise DistutilsOptionError(
+ "install_script '%s' not found in scripts"
+ % self.install_script)
- def run (self):
+ def run(self):
if (sys.platform != "win32" and
(self.distribution.has_ext_modules() or
self.distribution.has_c_libraries())):
@@ -160,7 +150,7 @@ class bdist_wininst (Command):
# Use a custom scheme for the zip-file, because we have to decide
# at installation time which scheme to use.
for key in ('purelib', 'platlib', 'headers', 'scripts', 'data'):
- value = string.upper(key)
+ value = key.upper()
if key == 'headers':
value = value + '/Include/$dist_name'
setattr(install,
@@ -200,11 +190,8 @@ class bdist_wininst (Command):
if not self.keep_temp:
remove_tree(self.bdist_dir, dry_run=self.dry_run)
- # run()
-
- def get_inidata (self):
+ def get_inidata(self):
# Return data describing the installation.
-
lines = []
metadata = self.distribution.metadata
@@ -217,14 +204,14 @@ class bdist_wininst (Command):
# Escape newline characters
def escape(s):
- return string.replace(s, "\n", "\\n")
+ return s.replace("\n", "\\n")
for name in ["author", "author_email", "description", "maintainer",
"maintainer_email", "name", "url", "version"]:
data = getattr(metadata, name, "")
if data:
info = info + ("\n %s: %s" % \
- (string.capitalize(name), escape(data)))
+ (name.capitalize(), escape(data)))
lines.append("%s=%s" % (name, escape(data)))
# The [setup] section contains entries controlling
@@ -247,11 +234,9 @@ class bdist_wininst (Command):
build_info = "Built %s with distutils-%s" % \
(time.ctime(time.time()), distutils.__version__)
lines.append("build_info=%s" % build_info)
- return string.join(lines, "\n")
-
- # get_inidata()
+ return "\n".join(lines)
- def create_exe (self, arcname, fullname, bitmap=None):
+ def create_exe(self, arcname, fullname, bitmap=None):
import struct
self.mkpath(self.dist_dir)
@@ -273,22 +258,22 @@ class bdist_wininst (Command):
file.write(bitmapdata)
# Convert cfgdata from unicode to ascii, mbcs encoded
- try:
- unicode
- except NameError:
- pass
- else:
- if isinstance(cfgdata, unicode):
- cfgdata = cfgdata.encode("mbcs")
+ if isinstance(cfgdata, str):
+ cfgdata = cfgdata.encode("mbcs")
# Append the pre-install script
- cfgdata = cfgdata + "\0"
+ cfgdata = cfgdata + b"\0"
if self.pre_install_script:
- script_data = open(self.pre_install_script, "r").read()
- cfgdata = cfgdata + script_data + "\n\0"
+ # We need to normalize newlines, so we open in text mode and
+ # convert back to bytes. "latin1" simply avoids any possible
+ # failures.
+ with open(self.pre_install_script, "r",
+ encoding="latin1") as script:
+ script_data = script.read().encode("latin1")
+ cfgdata = cfgdata + script_data + b"\n\0"
else:
# empty pre-install script
- cfgdata = cfgdata + "\0"
+ cfgdata = cfgdata + b"\0"
file.write(cfgdata)
# The 'magic number' 0x1234567B is used to make sure that the
@@ -304,8 +289,6 @@ class bdist_wininst (Command):
file.write(header)
file.write(open(arcname, "rb").read())
- # create_exe()
-
def get_installer_filename(self, fullname):
# Factored out to allow overriding in subclasses
if self.target_version:
@@ -318,9 +301,8 @@ class bdist_wininst (Command):
installer_name = os.path.join(self.dist_dir,
"%s.%s.exe" % (fullname, self.plat_name))
return installer_name
- # get_installer_filename()
- def get_exe_bytes (self):
+ def get_exe_bytes(self):
from distutils.msvccompiler import get_build_version
# If a target-version other than the current version has been
# specified, then using the MSVC version from *this* build is no good.
@@ -365,4 +347,3 @@ class bdist_wininst (Command):
return f.read()
finally:
f.close()
-# class bdist_wininst
diff --git a/Lib/distutils/command/build.py b/Lib/distutils/command/build.py
index f84bf359dc6..cfc15cf0ddc 100644
--- a/Lib/distutils/command/build.py
+++ b/Lib/distutils/command/build.py
@@ -2,18 +2,17 @@
Implements the Distutils 'build' command."""
-__revision__ = "$Id$"
-
import sys, os
-
-from distutils.util import get_platform
from distutils.core import Command
from distutils.errors import DistutilsOptionError
+from distutils.util import get_platform
+
def show_compilers():
from distutils.ccompiler import show_compilers
show_compilers()
+
class build(Command):
description = "build everything needed to install"
@@ -126,20 +125,22 @@ class build(Command):
for cmd_name in self.get_sub_commands():
self.run_command(cmd_name)
+
# -- Predicates for the sub-command list ---------------------------
- def has_pure_modules (self):
+ def has_pure_modules(self):
return self.distribution.has_pure_modules()
- def has_c_libraries (self):
+ def has_c_libraries(self):
return self.distribution.has_c_libraries()
- def has_ext_modules (self):
+ def has_ext_modules(self):
return self.distribution.has_ext_modules()
- def has_scripts (self):
+ def has_scripts(self):
return self.distribution.has_scripts()
+
sub_commands = [('build_py', has_pure_modules),
('build_clib', has_c_libraries),
('build_ext', has_ext_modules),
diff --git a/Lib/distutils/command/build_clib.py b/Lib/distutils/command/build_clib.py
index 205587e7fc9..3e20ef23cd8 100644
--- a/Lib/distutils/command/build_clib.py
+++ b/Lib/distutils/command/build_clib.py
@@ -4,8 +4,6 @@ Implements the Distutils 'build_clib' command, to build a C/C++ library
that is included in the module distribution and needed by an extension
module."""
-__revision__ = "$Id$"
-
# XXX this module has *lots* of code ripped-off quite transparently from
# build_ext.py -- not surprisingly really, as the work required to build
@@ -18,7 +16,7 @@ __revision__ = "$Id$"
import os
from distutils.core import Command
-from distutils.errors import DistutilsSetupError
+from distutils.errors import *
from distutils.sysconfig import customize_compiler
from distutils import log
@@ -92,6 +90,7 @@ class build_clib(Command):
# XXX same as for build_ext -- what about 'self.define' and
# 'self.undef' ?
+
def run(self):
if not self.libraries:
return
@@ -127,30 +126,30 @@ class build_clib(Command):
just returns otherwise.
"""
if not isinstance(libraries, list):
- raise DistutilsSetupError, \
- "'libraries' option must be a list of tuples"
+ raise DistutilsSetupError(
+ "'libraries' option must be a list of tuples")
for lib in libraries:
if not isinstance(lib, tuple) and len(lib) != 2:
- raise DistutilsSetupError, \
- "each element of 'libraries' must a 2-tuple"
+ raise DistutilsSetupError(
+ "each element of 'libraries' must a 2-tuple")
name, build_info = lib
if not isinstance(name, str):
- raise DistutilsSetupError, \
- "first element of each tuple in 'libraries' " + \
- "must be a string (the library name)"
+ raise DistutilsSetupError(
+ "first element of each tuple in 'libraries' "
+ "must be a string (the library name)")
+
if '/' in name or (os.sep != '/' and os.sep in name):
- raise DistutilsSetupError, \
- ("bad library name '%s': " +
- "may not contain directory separators") % \
- lib[0]
+ raise DistutilsSetupError("bad library name '%s': "
+ "may not contain directory separators" % lib[0])
if not isinstance(build_info, dict):
- raise DistutilsSetupError, \
- "second element of each tuple in 'libraries' " + \
- "must be a dictionary (build info)"
+ raise DistutilsSetupError(
+ "second element of each tuple in 'libraries' "
+ "must be a dictionary (build info)")
+
def get_library_names(self):
# Assume the library list is valid -- 'check_library_list()' is
@@ -170,22 +169,23 @@ class build_clib(Command):
for (lib_name, build_info) in self.libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
- raise DistutilsSetupError, \
- ("in 'libraries' option (library '%s'), "
+ raise DistutilsSetupError(
+ "in 'libraries' option (library '%s'), "
"'sources' must be present and must be "
- "a list of source filenames") % lib_name
+ "a list of source filenames" % lib_name)
filenames.extend(sources)
return filenames
+
def build_libraries(self, libraries):
for (lib_name, build_info) in libraries:
sources = build_info.get('sources')
if sources is None or not isinstance(sources, (list, tuple)):
- raise DistutilsSetupError, \
- ("in 'libraries' option (library '%s'), " +
- "'sources' must be present and must be " +
- "a list of source filenames") % lib_name
+ raise DistutilsSetupError(
+ "in 'libraries' option (library '%s'), "
+ "'sources' must be present and must be "
+ "a list of source filenames" % lib_name)
sources = list(sources)
log.info("building '%s' library", lib_name)
diff --git a/Lib/distutils/command/build_ext.py b/Lib/distutils/command/build_ext.py
index 923197bac43..34b61bdb828 100644
--- a/Lib/distutils/command/build_ext.py
+++ b/Lib/distutils/command/build_ext.py
@@ -4,13 +4,7 @@ Implements the Distutils 'build_ext' command, for building extension
modules (currently limited to C extensions, should accommodate C++
extensions ASAP)."""
-# This module should be kept compatible with Python 2.1.
-
-__revision__ = "$Id$"
-
-import sys, os, string, re
-from types import *
-from site import USER_BASE, USER_SITE
+import sys, os, re
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
@@ -19,6 +13,14 @@ from distutils.extension import Extension
from distutils.util import get_platform
from distutils import log
+# this keeps compatibility from 2.3 to 2.5
+if sys.version < "2.6":
+ USER_BASE = None
+ HAS_USER_SITE = False
+else:
+ from site import USER_BASE
+ HAS_USER_SITE = True
+
if os.name == 'nt':
from distutils.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -34,7 +36,7 @@ def show_compilers ():
show_compilers()
-class build_ext (Command):
+class build_ext(Command):
description = "build C/C++ extensions (compile/link to build directory)"
@@ -94,18 +96,21 @@ class build_ext (Command):
"list of SWIG command line options"),
('swig=', None,
"path to the SWIG executable"),
- ('user', None,
- "add user include, library and rpath"),
]
- boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
+ boolean_options = ['inplace', 'debug', 'force', 'swig-cpp']
+
+ if HAS_USER_SITE:
+ user_options.append(('user', None,
+ "add user include, library and rpath"))
+ boolean_options.append('user')
help_options = [
('help-compiler', None,
"list available compilers", show_compilers),
]
- def initialize_options (self):
+ def initialize_options(self):
self.extensions = None
self.build_lib = None
self.plat_name = None
@@ -168,13 +173,13 @@ class build_ext (Command):
self.libraries = []
if self.library_dirs is None:
self.library_dirs = []
- elif type(self.library_dirs) is StringType:
- self.library_dirs = string.split(self.library_dirs, os.pathsep)
+ elif isinstance(self.library_dirs, str):
+ self.library_dirs = self.library_dirs.split(os.pathsep)
if self.rpath is None:
self.rpath = []
- elif type(self.rpath) is StringType:
- self.rpath = string.split(self.rpath, os.pathsep)
+ elif isinstance(self.rpath, str):
+ self.rpath = self.rpath.split(os.pathsep)
# for extensions under windows use different directories
# for Release and Debug builds.
@@ -251,7 +256,7 @@ class build_ext (Command):
if self.define:
defines = self.define.split(',')
- self.define = map(lambda symbol: (symbol, '1'), defines)
+ self.define = [(symbol, '1') for symbol in defines]
# The option for macros to undefine is also a string from the
# option parsing, but has to be a list. Multiple symbols can also
@@ -349,8 +354,8 @@ class build_ext (Command):
just returns otherwise.
"""
if not isinstance(extensions, list):
- raise DistutilsSetupError, \
- "'ext_modules' option must be a list of Extension instances"
+ raise DistutilsSetupError(
+ "'ext_modules' option must be a list of Extension instances")
for i, ext in enumerate(extensions):
if isinstance(ext, Extension):
@@ -358,8 +363,8 @@ class build_ext (Command):
# by Extension constructor)
if not isinstance(ext, tuple) or len(ext) != 2:
- raise DistutilsSetupError, \
- ("each element of 'ext_modules' option must be an "
+ raise DistutilsSetupError(
+ "each element of 'ext_modules' option must be an "
"Extension instance or 2-tuple")
ext_name, build_info = ext
@@ -370,13 +375,13 @@ class build_ext (Command):
if not (isinstance(ext_name, str) and
extension_name_re.match(ext_name)):
- raise DistutilsSetupError, \
- ("first element of each tuple in 'ext_modules' "
+ raise DistutilsSetupError(
+ "first element of each tuple in 'ext_modules' "
"must be the extension name (a string)")
if not isinstance(build_info, dict):
- raise DistutilsSetupError, \
- ("second element of each tuple in 'ext_modules' "
+ raise DistutilsSetupError(
+ "second element of each tuple in 'ext_modules' "
"must be a dictionary (build info)")
# OK, the (ext_name, build_info) dict is type-safe: convert it
@@ -406,9 +411,9 @@ class build_ext (Command):
ext.undef_macros = []
for macro in macros:
if not (isinstance(macro, tuple) and len(macro) in (1, 2)):
- raise DistutilsSetupError, \
- ("'macros' element of build info dict "
- "must be 1- or 2-tuple")
+ raise DistutilsSetupError(
+ "'macros' element of build info dict "
+ "must be 1- or 2-tuple")
if len(macro) == 1:
ext.undef_macros.append(macro[0])
elif len(macro) == 2:
@@ -423,7 +428,6 @@ class build_ext (Command):
# Wouldn't it be neat if we knew the names of header files too...
for ext in self.extensions:
filenames.extend(ext.sources)
-
return filenames
def get_outputs(self):
@@ -445,15 +449,21 @@ class build_ext (Command):
self.check_extensions_list(self.extensions)
for ext in self.extensions:
- self.build_extension(ext)
+ try:
+ self.build_extension(ext)
+ except (CCompilerError, DistutilsError, CompileError) as e:
+ if not ext.optional:
+ raise
+ self.warn('building extension "%s" failed: %s' %
+ (ext.name, e))
def build_extension(self, ext):
sources = ext.sources
- if sources is None or type(sources) not in (ListType, TupleType):
- raise DistutilsSetupError, \
- ("in 'ext_modules' option (extension '%s'), " +
- "'sources' must be present and must be " +
- "a list of source filenames") % ext.name
+ if sources is None or not isinstance(sources, (list, tuple)):
+ raise DistutilsSetupError(
+ "in 'ext_modules' option (extension '%s'), "
+ "'sources' must be present and must be "
+ "a list of source filenames" % ext.name)
sources = list(sources)
ext_path = self.get_ext_fullpath(ext.name)
@@ -529,15 +539,12 @@ class build_ext (Command):
build_temp=self.build_temp,
target_lang=language)
-
- def swig_sources (self, sources, extension):
-
+ def swig_sources(self, sources, extension):
"""Walk the list of source files in 'sources', looking for SWIG
interface (.i) files. Run SWIG on all that are found, and
return a modified 'sources' list with SWIG source files replaced
by the generated C (or C++) files.
"""
-
new_sources = []
swig_sources = []
swig_targets = {}
@@ -586,18 +593,14 @@ class build_ext (Command):
return new_sources
- # swig_sources ()
-
- def find_swig (self):
+ def find_swig(self):
"""Return the name of the SWIG executable. On Unix, this is
just "swig" -- it should be in the PATH. Tries a bit harder on
Windows.
"""
-
if os.name == "posix":
return "swig"
elif os.name == "nt":
-
# Look for SWIG in its standard installation directory on
# Windows (or so I presume!). If we find it there, great;
# if not, act like Unix and assume it's in the PATH.
@@ -607,17 +610,13 @@ class build_ext (Command):
return fn
else:
return "swig.exe"
-
elif os.name == "os2":
# assume swig available in the PATH.
return "swig.exe"
-
else:
- raise DistutilsPlatformError, \
- ("I don't know how to find (much less run) SWIG "
- "on platform '%s'") % os.name
-
- # find_swig ()
+ raise DistutilsPlatformError(
+ "I don't know how to find (much less run) SWIG "
+ "on platform '%s'" % os.name)
# -- Name generators -----------------------------------------------
# (extension names, filenames, whatever)
@@ -627,14 +626,9 @@ class build_ext (Command):
The file is located in `build_lib` or directly in the package
(inplace option).
"""
- # makes sure the extension name is only using dots
- all_dots = string.maketrans('/'+os.sep, '..')
- ext_name = ext_name.translate(all_dots)
-
fullname = self.get_ext_fullname(ext_name)
modpath = fullname.split('.')
- filename = self.get_ext_filename(ext_name)
- filename = os.path.split(filename)[-1]
+ filename = self.get_ext_filename(modpath[-1])
if not self.inplace:
# no further work needed
@@ -668,7 +662,7 @@ class build_ext (Command):
"foo\bar.pyd").
"""
from distutils.sysconfig import get_config_var
- ext_path = string.split(ext_name, '.')
+ ext_path = ext_name.split('.')
# OS/2 has an 8 character module (extension) limit :-(
if os.name == "os2":
ext_path[len(ext_path) - 1] = ext_path[len(ext_path) - 1][:8]
@@ -678,18 +672,18 @@ class build_ext (Command):
return os.path.join(*ext_path) + '_d' + so_ext
return os.path.join(*ext_path) + so_ext
- def get_export_symbols (self, ext):
+ def get_export_symbols(self, ext):
"""Return the list of symbols that a shared extension has to
export. This either uses 'ext.export_symbols' or, if it's not
- provided, "init" + module_name. Only relevant on Windows, where
- the .pyd file (DLL) must export the module "init" function.
+ provided, "PyInit_" + module_name. Only relevant on Windows, where
+ the .pyd file (DLL) must export the module "PyInit_" function.
"""
- initfunc_name = "init" + ext.name.split('.')[-1]
+ initfunc_name = "PyInit_" + ext.name.split('.')[-1]
if initfunc_name not in ext.export_symbols:
ext.export_symbols.append(initfunc_name)
return ext.export_symbols
- def get_libraries (self, ext):
+ def get_libraries(self, ext):
"""Return the list of libraries to link against when building a
shared extension. On most platforms, this is just 'ext.libraries';
on Windows and OS/2, we add the Python library (eg. python20.dll).
@@ -748,7 +742,6 @@ class build_ext (Command):
# don't extend ext.libraries, it may be shared with other
# extensions, it is a reference to the original list
return ext.libraries + [pythonlib, "m"] + extra
-
elif sys.platform == 'darwin':
# Don't use the default code below
return ext.libraries
@@ -758,11 +751,9 @@ class build_ext (Command):
else:
from distutils import sysconfig
if sysconfig.get_config_var('Py_ENABLE_SHARED'):
- template = "python%d.%d"
- pythonlib = (template %
- (sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff))
+ pythonlib = 'python{}.{}{}'.format(
+ sys.hexversion >> 24, (sys.hexversion >> 16) & 0xff,
+ sys.abiflags)
return ext.libraries + [pythonlib]
else:
return ext.libraries
-
-# class build_ext
diff --git a/Lib/distutils/command/build_py.py b/Lib/distutils/command/build_py.py
index 04c455f0eb9..1371b3d6ff9 100644
--- a/Lib/distutils/command/build_py.py
+++ b/Lib/distutils/command/build_py.py
@@ -2,18 +2,17 @@
Implements the Distutils 'build_py' command."""
-__revision__ = "$Id$"
-
import os
+import imp
import sys
from glob import glob
from distutils.core import Command
-from distutils.errors import DistutilsOptionError, DistutilsFileError
-from distutils.util import convert_path
+from distutils.errors import *
+from distutils.util import convert_path, Mixin2to3
from distutils import log
-class build_py(Command):
+class build_py (Command):
description = "\"build\" pure Python modules (copy to build directory)"
@@ -133,6 +132,7 @@ class build_py(Command):
def build_package_data(self):
"""Copy data files into build directory"""
+ lastdir = None
for package, src_dir, build_dir, filenames in self.data_files:
for filename in filenames:
target = os.path.join(build_dir, filename)
@@ -144,7 +144,6 @@ class build_py(Command):
"""Return the directory, relative to the top of the source
distribution, where package 'package' should be found
(at least according to the 'package_dir' option, if any)."""
-
path = package.split('.')
if not self.package_dir:
@@ -313,9 +312,11 @@ class build_py(Command):
outputs.append(filename)
if include_bytecode:
if self.compile:
- outputs.append(filename + "c")
+ outputs.append(imp.cache_from_source(filename,
+ debug_override=True))
if self.optimize > 0:
- outputs.append(filename + "o")
+ outputs.append(imp.cache_from_source(filename,
+ debug_override=False))
outputs += [
os.path.join(build_dir, filename)
@@ -343,7 +344,6 @@ class build_py(Command):
def build_modules(self):
modules = self.find_modules()
for (package, module, module_file) in modules:
-
# Now "build" the module -- ie. copy the source file to
# self.build_lib (the build directory for Python source).
# (Actually, it gets copied to the directory for this package
@@ -352,7 +352,6 @@ class build_py(Command):
def build_packages(self):
for package in self.packages:
-
# Get list of (package, module, module_file) tuples based on
# scanning the package directory. 'package' is only included
# in the tuple so that 'find_modules()' and
@@ -384,10 +383,33 @@ class build_py(Command):
# XXX this code is essentially the same as the 'byte_compile()
# method of the "install_lib" command, except for the determination
# of the 'prefix' string. Hmmm.
-
if self.compile:
byte_compile(files, optimize=0,
force=self.force, prefix=prefix, dry_run=self.dry_run)
if self.optimize > 0:
byte_compile(files, optimize=self.optimize,
force=self.force, prefix=prefix, dry_run=self.dry_run)
+
+class build_py_2to3(build_py, Mixin2to3):
+ def run(self):
+ self.updated_files = []
+
+ # Base class code
+ if self.py_modules:
+ self.build_modules()
+ if self.packages:
+ self.build_packages()
+ self.build_package_data()
+
+ # 2to3
+ self.run_2to3(self.updated_files)
+
+ # Remaining base class code
+ self.byte_compile(self.get_outputs(include_bytecode=0))
+
+ def build_module(self, module, module_file, package):
+ res = build_py.build_module(self, module, module_file, package)
+ if res[1]:
+ # file was copied
+ self.updated_files.append(res[0])
+ return res
diff --git a/Lib/distutils/command/build_scripts.py b/Lib/distutils/command/build_scripts.py
index 567df6587ec..ec434770610 100644
--- a/Lib/distutils/command/build_scripts.py
+++ b/Lib/distutils/command/build_scripts.py
@@ -2,19 +2,19 @@
Implements the Distutils 'build_scripts' command."""
-__revision__ = "$Id$"
-
import os, re
from stat import ST_MODE
+from distutils import sysconfig
from distutils.core import Command
from distutils.dep_util import newer
-from distutils.util import convert_path
+from distutils.util import convert_path, Mixin2to3
from distutils import log
+import tokenize
# check if Python is called on the first line with this expression
-first_line_re = re.compile('^#!.*python[0-9.]*([ \t].*)?$')
+first_line_re = re.compile(b'^#!.*python[0-9.]*([ \t].*)?$')
-class build_scripts (Command):
+class build_scripts(Command):
description = "\"build\" scripts (copy and fixup #! line)"
@@ -27,14 +27,14 @@ class build_scripts (Command):
boolean_options = ['force']
- def initialize_options (self):
+ def initialize_options(self):
self.build_dir = None
self.scripts = None
self.force = None
self.executable = None
self.outfiles = None
- def finalize_options (self):
+ def finalize_options(self):
self.set_undefined_options('build',
('build_scripts', 'build_dir'),
('force', 'force'),
@@ -44,23 +44,23 @@ class build_scripts (Command):
def get_source_files(self):
return self.scripts
- def run (self):
+ def run(self):
if not self.scripts:
return
self.copy_scripts()
- def copy_scripts (self):
+ def copy_scripts(self):
"""Copy each script listed in 'self.scripts'; if it's marked as a
Python script in the Unix way (first line matches 'first_line_re',
ie. starts with "\#!" and contains "python"), then adjust the first
line to refer to the current Python interpreter as we copy.
"""
- _sysconfig = __import__('sysconfig')
self.mkpath(self.build_dir)
outfiles = []
+ updated_files = []
for script in self.scripts:
- adjust = 0
+ adjust = False
script = convert_path(script)
outfile = os.path.join(self.build_dir, os.path.basename(script))
outfiles.append(outfile)
@@ -73,12 +73,14 @@ class build_scripts (Command):
# that way, we'll get accurate feedback if we can read the
# script.
try:
- f = open(script, "r")
+ f = open(script, "rb")
except IOError:
if not self.dry_run:
raise
f = None
else:
+ encoding, lines = tokenize.detect_encoding(f.readline)
+ f.seek(0)
first_line = f.readline()
if not first_line:
self.warn("%s is an empty file (skipping)" % script)
@@ -86,25 +88,46 @@ class build_scripts (Command):
match = first_line_re.match(first_line)
if match:
- adjust = 1
- post_interp = match.group(1) or ''
+ adjust = True
+ post_interp = match.group(1) or b''
if adjust:
log.info("copying and adjusting %s -> %s", script,
self.build_dir)
+ updated_files.append(outfile)
if not self.dry_run:
- outf = open(outfile, "w")
- if not _sysconfig.is_python_build():
- outf.write("#!%s%s\n" %
- (self.executable,
- post_interp))
+ if not sysconfig.python_build:
+ executable = self.executable
else:
- outf.write("#!%s%s\n" %
- (os.path.join(
- _sysconfig.get_config_var("BINDIR"),
- "python%s%s" % (_sysconfig.get_config_var("VERSION"),
- _sysconfig.get_config_var("EXE"))),
- post_interp))
+ executable = os.path.join(
+ sysconfig.get_config_var("BINDIR"),
+ "python%s%s" % (sysconfig.get_config_var("VERSION"),
+ sysconfig.get_config_var("EXE")))
+ executable = os.fsencode(executable)
+ shebang = b"#!" + executable + post_interp + b"\n"
+ # Python parser starts to read a script using UTF-8 until
+ # it gets a #coding:xxx cookie. The shebang has to be the
+ # first line of a file, the #coding:xxx cookie cannot be
+ # written before. So the shebang has to be decodable from
+ # UTF-8.
+ try:
+ shebang.decode('utf-8')
+ except UnicodeDecodeError:
+ raise ValueError(
+ "The shebang ({!r}) is not decodable "
+ "from utf-8".format(shebang))
+ # If the script is encoded to a custom encoding (use a
+ # #coding:xxx cookie), the shebang has to be decodable from
+ # the script encoding too.
+ try:
+ shebang.decode(encoding)
+ except UnicodeDecodeError:
+ raise ValueError(
+ "The shebang ({!r}) is not decodable "
+ "from the script encoding ({})"
+ .format(shebang, encoding))
+ outf = open(outfile, "wb")
+ outf.write(shebang)
outf.writelines(f.readlines())
outf.close()
if f:
@@ -112,6 +135,7 @@ class build_scripts (Command):
else:
if f:
f.close()
+ updated_files.append(outfile)
self.copy_file(script, outfile)
if os.name == 'posix':
@@ -119,13 +143,19 @@ class build_scripts (Command):
if self.dry_run:
log.info("changing mode of %s", file)
else:
- oldmode = os.stat(file)[ST_MODE] & 07777
- newmode = (oldmode | 0555) & 07777
+ oldmode = os.stat(file)[ST_MODE] & 0o7777
+ newmode = (oldmode | 0o555) & 0o7777
if newmode != oldmode:
log.info("changing mode of %s from %o to %o",
file, oldmode, newmode)
os.chmod(file, newmode)
+ # XXX should we modify self.outfiles?
+ return outfiles, updated_files
- # copy_scripts ()
+class build_scripts_2to3(build_scripts, Mixin2to3):
-# class build_scripts
+ def copy_scripts(self):
+ outfiles, updated_files = build_scripts.copy_scripts(self)
+ if not self.dry_run:
+ self.run_2to3(updated_files)
+ return outfiles, updated_files
diff --git a/Lib/distutils/command/check.py b/Lib/distutils/command/check.py
index 152bf0de98b..22b9349dd60 100644
--- a/Lib/distutils/command/check.py
+++ b/Lib/distutils/command/check.py
@@ -2,10 +2,7 @@
Implements the Distutils 'check' command.
"""
-__revision__ = "$Id$"
-
from distutils.core import Command
-from distutils.dist import PKG_INFO_ENCODING
from distutils.errors import DistutilsSetupError
try:
@@ -14,7 +11,7 @@ try:
from docutils.parsers.rst import Parser
from docutils import frontend
from docutils import nodes
- from StringIO import StringIO
+ from io import StringIO
class SilentReporter(Reporter):
@@ -31,8 +28,9 @@ try:
*children, **kwargs)
HAS_DOCUTILS = True
-except ImportError:
- # docutils is not installed
+except Exception:
+ # Catch all exceptions because exceptions besides ImportError probably
+ # indicate that docutils is not ported to Py3k.
HAS_DOCUTILS = False
class check(Command):
@@ -112,8 +110,6 @@ class check(Command):
def check_restructuredtext(self):
"""Checks if the long string fields are reST-compliant."""
data = self.distribution.get_long_description()
- if not isinstance(data, unicode):
- data = data.decode(PKG_INFO_ENCODING)
for warning in self._check_rst_data(data):
line = warning[-1].get('line')
if line is None:
diff --git a/Lib/distutils/command/clean.py b/Lib/distutils/command/clean.py
index 90ef35f1ca7..0cb27016621 100644
--- a/Lib/distutils/command/clean.py
+++ b/Lib/distutils/command/clean.py
@@ -4,8 +4,6 @@ Implements the Distutils 'clean' command."""
# contributed by Bastian Kleineidam <calvin@cs.uni-sb.de>, added 2000-03-18
-__revision__ = "$Id$"
-
import os
from distutils.core import Command
from distutils.dir_util import remove_tree
@@ -76,5 +74,3 @@ class clean(Command):
log.info("removing '%s'", self.build_base)
except OSError:
pass
-
-# class clean
diff --git a/Lib/distutils/command/command_template b/Lib/distutils/command/command_template
index 50bbab7b6ec..6106819db84 100644
--- a/Lib/distutils/command/command_template
+++ b/Lib/distutils/command/command_template
@@ -10,7 +10,7 @@ __revision__ = "$Id$"
from distutils.core import Command
-class x (Command):
+class x(Command):
# Brief (40-50 characters) description of the command
description = ""
@@ -21,25 +21,13 @@ class x (Command):
""),
]
-
- def initialize_options (self):
+ def initialize_options(self):
self. = None
self. = None
self. = None
- # initialize_options()
-
-
- def finalize_options (self):
+ def finalize_options(self):
if self.x is None:
self.x =
- # finalize_options()
-
-
- def run (self):
-
-
- # run()
-
-# class x
+ def run(self):
diff --git a/Lib/distutils/command/config.py b/Lib/distutils/command/config.py
index b084913563a..847e8581605 100644
--- a/Lib/distutils/command/config.py
+++ b/Lib/distutils/command/config.py
@@ -9,17 +9,14 @@ configure-like tasks: "try to compile this C code", or "figure out where
this header file lives".
"""
-__revision__ = "$Id$"
-
-import os
-import re
+import sys, os, re
from distutils.core import Command
from distutils.errors import DistutilsExecError
from distutils.sysconfig import customize_compiler
from distutils import log
-LANG_EXT = {'c': '.c', 'c++': '.cxx'}
+LANG_EXT = {"c": ".c", "c++": ".cxx"}
class config(Command):
@@ -85,7 +82,6 @@ class config(Command):
def run(self):
pass
-
# Utility methods for actual "config" commands. The interfaces are
# loosely based on Autoconf macros of similar names. Sub-classes
# may use these freely.
@@ -108,7 +104,6 @@ class config(Command):
if self.library_dirs:
self.compiler.set_library_dirs(self.library_dirs)
-
def _gen_temp_sourcefile(self, body, headers, lang):
filename = "_configtest" + LANG_EXT[lang]
file = open(filename, "w")
@@ -184,11 +179,11 @@ class config(Command):
"""
from distutils.ccompiler import CompileError
self._check_compiler()
- ok = 1
+ ok = True
try:
self._preprocess(body, headers, include_dirs, lang)
except CompileError:
- ok = 0
+ ok = False
self._clean()
return ok
@@ -209,13 +204,13 @@ class config(Command):
pattern = re.compile(pattern)
file = open(out)
- match = 0
- while 1:
+ match = False
+ while True:
line = file.readline()
if line == '':
break
if pattern.search(line):
- match = 1
+ match = True
break
file.close()
@@ -230,9 +225,9 @@ class config(Command):
self._check_compiler()
try:
self._compile(body, headers, include_dirs, lang)
- ok = 1
+ ok = True
except CompileError:
- ok = 0
+ ok = False
log.info(ok and "success!" or "failure.")
self._clean()
@@ -249,9 +244,9 @@ class config(Command):
try:
self._link(body, headers, include_dirs,
libraries, library_dirs, lang)
- ok = 1
+ ok = True
except (CompileError, LinkError):
- ok = 0
+ ok = False
log.info(ok and "success!" or "failure.")
self._clean()
@@ -269,9 +264,9 @@ class config(Command):
src, obj, exe = self._link(body, headers, include_dirs,
libraries, library_dirs, lang)
self.spawn([exe])
- ok = 1
+ ok = True
except (CompileError, LinkError, DistutilsExecError):
- ok = 0
+ ok = False
log.info(ok and "success!" or "failure.")
self._clean()
@@ -284,7 +279,6 @@ class config(Command):
def check_func(self, func, headers=None, include_dirs=None,
libraries=None, library_dirs=None, decl=0, call=0):
-
"""Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.
@@ -298,7 +292,6 @@ class config(Command):
calls it. 'libraries' and 'library_dirs' are used when
linking.
"""
-
self._check_compiler()
body = []
if decl:
@@ -314,8 +307,6 @@ class config(Command):
return self.try_link(body, headers, include_dirs,
libraries, library_dirs)
- # check_func ()
-
def check_lib(self, library, library_dirs=None, headers=None,
include_dirs=None, other_libraries=[]):
"""Determine if 'library' is available to be linked against,
@@ -327,9 +318,8 @@ class config(Command):
has symbols that depend on other libraries.
"""
self._check_compiler()
- return self.try_link("int main (void) { }",
- headers, include_dirs,
- [library]+other_libraries, library_dirs)
+ return self.try_link("int main (void) { }", headers, include_dirs,
+ [library] + other_libraries, library_dirs)
def check_header(self, header, include_dirs=None, library_dirs=None,
lang="c"):
diff --git a/Lib/distutils/command/install.py b/Lib/distutils/command/install.py
index f1f3bd5c6f5..0161898f49a 100644
--- a/Lib/distutils/command/install.py
+++ b/Lib/distutils/command/install.py
@@ -2,14 +2,10 @@
Implements the Distutils 'install' command."""
-from distutils import log
-
-# This module should be kept compatible with Python 2.1.
+import sys
+import os
-__revision__ = "$Id$"
-
-import sys, os, string
-from types import *
+from distutils import log
from distutils.core import Command
from distutils.debug import DEBUG
from distutils.sysconfig import get_config_vars
@@ -18,9 +14,16 @@ from distutils.file_util import write_file
from distutils.util import convert_path, subst_vars, change_root
from distutils.util import get_platform
from distutils.errors import DistutilsOptionError
-from site import USER_BASE
-from site import USER_SITE
+# this keeps compatibility from 2.3 to 2.5
+if sys.version < "2.6":
+ USER_BASE = None
+ USER_SITE = None
+ HAS_USER_SITE = False
+else:
+ from site import USER_BASE
+ from site import USER_SITE
+ HAS_USER_SITE = True
if sys.version < "2.2":
WINDOWS_SCHEME = {
@@ -43,7 +46,7 @@ INSTALL_SCHEMES = {
'unix_prefix': {
'purelib': '$base/lib/python$py_version_short/site-packages',
'platlib': '$platbase/lib/python$py_version_short/site-packages',
- 'headers': '$base/include/python$py_version_short/$dist_name',
+ 'headers': '$base/include/python$py_version_short$abiflags/$dist_name',
'scripts': '$base/bin',
'data' : '$base',
},
@@ -54,21 +57,7 @@ INSTALL_SCHEMES = {
'scripts': '$base/bin',
'data' : '$base',
},
- 'unix_user': {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/include/python$py_version_short/$dist_name',
- 'scripts': '$userbase/bin',
- 'data' : '$userbase',
- },
'nt': WINDOWS_SCHEME,
- 'nt_user': {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
- 'scripts': '$userbase/Scripts',
- 'data' : '$userbase',
- },
'os2': {
'purelib': '$base/Lib/site-packages',
'platlib': '$base/Lib/site-packages',
@@ -76,14 +65,34 @@ INSTALL_SCHEMES = {
'scripts': '$base/Scripts',
'data' : '$base',
},
- 'os2_home': {
+ }
+
+# user site schemes
+if HAS_USER_SITE:
+ INSTALL_SCHEMES['nt_user'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
+ 'scripts': '$userbase/Scripts',
+ 'data' : '$userbase',
+ }
+
+ INSTALL_SCHEMES['unix_user'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers':
+ '$userbase/include/python$py_version_short$abiflags/$dist_name',
+ 'scripts': '$userbase/bin',
+ 'data' : '$userbase',
+ }
+
+ INSTALL_SCHEMES['os2_home'] = {
'purelib': '$usersite',
'platlib': '$usersite',
'headers': '$userbase/include/python$py_version_short/$dist_name',
'scripts': '$userbase/bin',
'data' : '$userbase',
- },
- }
+ }
# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
@@ -91,7 +100,7 @@ INSTALL_SCHEMES = {
SCHEME_KEYS = ('purelib', 'platlib', 'headers', 'scripts', 'data')
-class install (Command):
+class install(Command):
description = "install everything from build directory"
@@ -103,8 +112,6 @@ class install (Command):
"(Unix only) prefix for platform-specific files"),
('home=', None,
"(Unix only) home directory to install under"),
- ('user', None,
- "install in user site-package '%s'" % USER_SITE),
# Or, just set the base director(y|ies)
('install-base=', None,
@@ -156,12 +163,18 @@ class install (Command):
"filename in which to record list of installed files"),
]
- boolean_options = ['compile', 'force', 'skip-build', 'user']
- negative_opt = {'no-compile' : 'compile'}
+ boolean_options = ['compile', 'force', 'skip-build']
+ if HAS_USER_SITE:
+ user_options.append(('user', None,
+ "install in user site-package '%s'" % USER_SITE))
+ boolean_options.append('user')
+
+ negative_opt = {'no-compile' : 'compile'}
- def initialize_options (self):
+ def initialize_options(self):
+ """Initializes options."""
# High-level options: these select both an installation base
# and scheme.
self.prefix = None
@@ -237,8 +250,8 @@ class install (Command):
# party Python modules on various platforms given a wide
# array of user input is decided. Yes, it's quite complex!)
- def finalize_options (self):
-
+ def finalize_options(self):
+ """Finalizes options."""
# This method (and its pliant slaves, like 'finalize_unix()',
# 'finalize_other()', and 'select_scheme()') is where the default
# installation directories for modules, extension modules, and
@@ -255,13 +268,13 @@ class install (Command):
if ((self.prefix or self.exec_prefix or self.home) and
(self.install_base or self.install_platbase)):
- raise DistutilsOptionError, \
- ("must supply either prefix/exec-prefix/home or " +
+ raise DistutilsOptionError(
+ "must supply either prefix/exec-prefix/home or " +
"install-base/install-platbase -- not both")
if self.home and (self.prefix or self.exec_prefix):
- raise DistutilsOptionError, \
- "must supply either home or prefix/exec-prefix -- not both"
+ raise DistutilsOptionError(
+ "must supply either home or prefix/exec-prefix -- not both")
if self.user and (self.prefix or self.exec_prefix or self.home or
self.install_base or self.install_platbase):
@@ -296,8 +309,13 @@ class install (Command):
# $platbase in the other installation directories and not worry
# about needing recursive variable expansion (shudder).
- py_version = (string.split(sys.version))[0]
+ py_version = sys.version.split()[0]
(prefix, exec_prefix) = get_config_vars('prefix', 'exec_prefix')
+ try:
+ abiflags = sys.abiflags
+ except AttributeError:
+ # sys.abiflags may not be defined on all platforms.
+ abiflags = ''
self.config_vars = {'dist_name': self.distribution.get_name(),
'dist_version': self.distribution.get_version(),
'dist_fullname': self.distribution.get_fullname(),
@@ -308,9 +326,13 @@ class install (Command):
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
'exec_prefix': exec_prefix,
- 'userbase': self.install_userbase,
- 'usersite': self.install_usersite,
+ 'abiflags': abiflags,
}
+
+ if HAS_USER_SITE:
+ self.config_vars['userbase'] = self.install_userbase
+ self.config_vars['usersite'] = self.install_usersite
+
self.expand_basedirs()
self.dump_dirs("post-expand_basedirs()")
@@ -322,7 +344,7 @@ class install (Command):
if DEBUG:
from pprint import pprint
- print "config vars:"
+ print("config vars:")
pprint(self.config_vars)
# Expand "~" and configuration variables in the installation
@@ -376,29 +398,27 @@ class install (Command):
# Punt on doc directories for now -- after all, we're punting on
# documentation completely!
- # finalize_options ()
-
-
- def dump_dirs (self, msg):
- if DEBUG:
- from distutils.fancy_getopt import longopt_xlate
- print msg + ":"
- for opt in self.user_options:
- opt_name = opt[0]
- if opt_name[-1] == "=":
- opt_name = opt_name[0:-1]
- if opt_name in self.negative_opt:
- opt_name = string.translate(self.negative_opt[opt_name],
- longopt_xlate)
- val = not getattr(self, opt_name)
- else:
- opt_name = string.translate(opt_name, longopt_xlate)
- val = getattr(self, opt_name)
- print " %s: %s" % (opt_name, val)
-
-
- def finalize_unix (self):
+ def dump_dirs(self, msg):
+ """Dumps the list of user options."""
+ if not DEBUG:
+ return
+ from distutils.fancy_getopt import longopt_xlate
+ log.debug(msg + ":")
+ for opt in self.user_options:
+ opt_name = opt[0]
+ if opt_name[-1] == "=":
+ opt_name = opt_name[0:-1]
+ if opt_name in self.negative_opt:
+ opt_name = self.negative_opt[opt_name]
+ opt_name = opt_name.translate(longopt_xlate)
+ val = not getattr(self, opt_name)
+ else:
+ opt_name = opt_name.translate(longopt_xlate)
+ val = getattr(self, opt_name)
+ log.debug(" %s: %s" % (opt_name, val))
+ def finalize_unix(self):
+ """Finalizes options for posix platforms."""
if self.install_base is not None or self.install_platbase is not None:
if ((self.install_lib is None and
self.install_purelib is None and
@@ -406,8 +426,8 @@ class install (Command):
self.install_headers is None or
self.install_scripts is None or
self.install_data is None):
- raise DistutilsOptionError, \
- ("install-base or install-platbase supplied, but "
+ raise DistutilsOptionError(
+ "install-base or install-platbase supplied, but "
"installation scheme is incomplete")
return
@@ -423,8 +443,8 @@ class install (Command):
else:
if self.prefix is None:
if self.exec_prefix is not None:
- raise DistutilsOptionError, \
- "must not supply exec-prefix without prefix"
+ raise DistutilsOptionError(
+ "must not supply exec-prefix without prefix")
self.prefix = os.path.normpath(sys.prefix)
self.exec_prefix = os.path.normpath(sys.exec_prefix)
@@ -437,11 +457,8 @@ class install (Command):
self.install_platbase = self.exec_prefix
self.select_scheme("unix_prefix")
- # finalize_unix ()
-
-
- def finalize_other (self): # Windows and Mac OS for now
-
+ def finalize_other(self):
+ """Finalizes options for non-posix platforms"""
if self.user:
if self.install_userbase is None:
raise DistutilsPlatformError(
@@ -459,13 +476,11 @@ class install (Command):
try:
self.select_scheme(os.name)
except KeyError:
- raise DistutilsPlatformError, \
- "I don't know how to install stuff on '%s'" % os.name
-
- # finalize_other ()
-
+ raise DistutilsPlatformError(
+ "I don't know how to install stuff on '%s'" % os.name)
- def select_scheme (self, name):
+ def select_scheme(self, name):
+ """Sets the install directories by applying the install schemes."""
# it's the caller's problem if they supply a bad name!
scheme = INSTALL_SCHEMES[name]
for key in SCHEME_KEYS:
@@ -473,8 +488,7 @@ class install (Command):
if getattr(self, attrname) is None:
setattr(self, attrname, scheme[key])
-
- def _expand_attrs (self, attrs):
+ def _expand_attrs(self, attrs):
for attr in attrs:
val = getattr(self, attr)
if val is not None:
@@ -483,49 +497,44 @@ class install (Command):
val = subst_vars(val, self.config_vars)
setattr(self, attr, val)
+ def expand_basedirs(self):
+ """Calls `os.path.expanduser` on install_base, install_platbase and
+ root."""
+ self._expand_attrs(['install_base', 'install_platbase', 'root'])
- def expand_basedirs (self):
- self._expand_attrs(['install_base',
- 'install_platbase',
- 'root'])
-
- def expand_dirs (self):
- self._expand_attrs(['install_purelib',
- 'install_platlib',
- 'install_lib',
- 'install_headers',
- 'install_scripts',
- 'install_data',])
+ def expand_dirs(self):
+ """Calls `os.path.expanduser` on install dirs."""
+ self._expand_attrs(['install_purelib', 'install_platlib',
+ 'install_lib', 'install_headers',
+ 'install_scripts', 'install_data',])
-
- def convert_paths (self, *names):
+ def convert_paths(self, *names):
+ """Call `convert_path` over `names`."""
for name in names:
attr = "install_" + name
setattr(self, attr, convert_path(getattr(self, attr)))
-
- def handle_extra_path (self):
-
+ def handle_extra_path(self):
+ """Set `path_file` and `extra_dirs` using `extra_path`."""
if self.extra_path is None:
self.extra_path = self.distribution.extra_path
if self.extra_path is not None:
- if type(self.extra_path) is StringType:
- self.extra_path = string.split(self.extra_path, ',')
+ if isinstance(self.extra_path, str):
+ self.extra_path = self.extra_path.split(',')
if len(self.extra_path) == 1:
path_file = extra_dirs = self.extra_path[0]
elif len(self.extra_path) == 2:
- (path_file, extra_dirs) = self.extra_path
+ path_file, extra_dirs = self.extra_path
else:
- raise DistutilsOptionError, \
- ("'extra_path' option must be a list, tuple, or "
+ raise DistutilsOptionError(
+ "'extra_path' option must be a list, tuple, or "
"comma-separated string with 1 or 2 elements")
# convert to local form in case Unix notation used (as it
# should be in setup scripts)
extra_dirs = convert_path(extra_dirs)
-
else:
path_file = None
extra_dirs = ''
@@ -535,29 +544,26 @@ class install (Command):
self.path_file = path_file
self.extra_dirs = extra_dirs
- # handle_extra_path ()
-
-
- def change_roots (self, *names):
+ def change_roots(self, *names):
+ """Change the install direcories pointed by name using root."""
for name in names:
attr = "install_" + name
setattr(self, attr, change_root(self.root, getattr(self, attr)))
def create_home_path(self):
- """Create directories under ~
- """
+ """Create directories under ~."""
if not self.user:
return
home = convert_path(os.path.expanduser("~"))
- for name, path in self.config_vars.iteritems():
+ for name, path in self.config_vars.items():
if path.startswith(home) and not os.path.isdir(path):
- self.debug_print("os.makedirs('%s', 0700)" % path)
- os.makedirs(path, 0700)
+ self.debug_print("os.makedirs('%s', 0o700)" % path)
+ os.makedirs(path, 0o700)
# -- Command execution methods -------------------------------------
- def run (self):
-
+ def run(self):
+ """Runs the command."""
# Obviously have to build before we can install
if not self.skip_build:
self.run_command('build')
@@ -582,7 +588,7 @@ class install (Command):
outputs = self.get_outputs()
if self.root: # strip any package prefix
root_len = len(self.root)
- for counter in xrange(len(outputs)):
+ for counter in range(len(outputs)):
outputs[counter] = outputs[counter][root_len:]
self.execute(write_file,
(self.record, outputs),
@@ -600,9 +606,8 @@ class install (Command):
"you'll have to change the search path yourself"),
self.install_lib)
- # run ()
-
- def create_path_file (self):
+ def create_path_file(self):
+ """Creates the .pth file"""
filename = os.path.join(self.install_libbase,
self.path_file + ".pth")
if self.install_path_file:
@@ -615,8 +620,8 @@ class install (Command):
# -- Reporting methods ---------------------------------------------
- def get_outputs (self):
- # Assemble the outputs of all the sub-commands.
+ def get_outputs(self):
+ """Assembles the outputs of all the sub-commands."""
outputs = []
for cmd_name in self.get_sub_commands():
cmd = self.get_finalized_command(cmd_name)
@@ -632,7 +637,8 @@ class install (Command):
return outputs
- def get_inputs (self):
+ def get_inputs(self):
+ """Returns the inputs of all the sub-commands"""
# XXX gee, this looks familiar ;-(
inputs = []
for cmd_name in self.get_sub_commands():
@@ -641,25 +647,29 @@ class install (Command):
return inputs
-
# -- Predicates for sub-command list -------------------------------
- def has_lib (self):
- """Return true if the current distribution has any Python
+ def has_lib(self):
+ """Returns true if the current distribution has any Python
modules to install."""
return (self.distribution.has_pure_modules() or
self.distribution.has_ext_modules())
- def has_headers (self):
+ def has_headers(self):
+ """Returns true if the current distribution has any headers to
+ install."""
return self.distribution.has_headers()
- def has_scripts (self):
+ def has_scripts(self):
+ """Returns true if the current distribution has any scripts to.
+ install."""
return self.distribution.has_scripts()
- def has_data (self):
+ def has_data(self):
+ """Returns true if the current distribution has any data to.
+ install."""
return self.distribution.has_data_files()
-
# 'sub_commands': a list of commands this command might have to run to
# get its work done. See cmd.py for more info.
sub_commands = [('install_lib', has_lib),
@@ -668,5 +678,3 @@ class install (Command):
('install_data', has_data),
('install_egg_info', lambda self:True),
]
-
-# class install
diff --git a/Lib/distutils/command/install_data.py b/Lib/distutils/command/install_data.py
index ab40797b986..947cd76a99e 100644
--- a/Lib/distutils/command/install_data.py
+++ b/Lib/distutils/command/install_data.py
@@ -5,8 +5,6 @@ platform-independent data files."""
# contributed by Bastian Kleineidam
-__revision__ = "$Id$"
-
import os
from distutils.core import Command
from distutils.util import change_root, convert_path
diff --git a/Lib/distutils/command/install_egg_info.py b/Lib/distutils/command/install_egg_info.py
index c8880310dfc..c2a7d649c0c 100644
--- a/Lib/distutils/command/install_egg_info.py
+++ b/Lib/distutils/command/install_egg_info.py
@@ -40,9 +40,8 @@ class install_egg_info(Command):
"Creating "+self.install_dir)
log.info("Writing %s", target)
if not self.dry_run:
- f = open(target, 'w')
- self.distribution.metadata.write_pkg_file(f)
- f.close()
+ with open(target, 'w', encoding='UTF-8') as f:
+ self.distribution.metadata.write_pkg_file(f)
def get_outputs(self):
return self.outputs
diff --git a/Lib/distutils/command/install_headers.py b/Lib/distutils/command/install_headers.py
index d892416a8cc..9bb0b18dc0d 100644
--- a/Lib/distutils/command/install_headers.py
+++ b/Lib/distutils/command/install_headers.py
@@ -3,8 +3,6 @@
Implements the Distutils 'install_headers' command, to install C/C++ header
files to the Python include directory."""
-__revision__ = "$Id$"
-
from distutils.core import Command
@@ -47,5 +45,3 @@ class install_headers(Command):
def get_outputs(self):
return self.outfiles
-
-# class install_headers
diff --git a/Lib/distutils/command/install_lib.py b/Lib/distutils/command/install_lib.py
index 043e8b6e271..15c08f12492 100644
--- a/Lib/distutils/command/install_lib.py
+++ b/Lib/distutils/command/install_lib.py
@@ -3,9 +3,8 @@
Implements the Distutils 'install_lib' command
(install all Python modules)."""
-__revision__ = "$Id$"
-
import os
+import imp
import sys
from distutils.core import Command
@@ -13,10 +12,7 @@ from distutils.errors import DistutilsOptionError
# Extension for Python source files.
-if hasattr(os, 'extsep'):
- PYTHON_SOURCE_EXTENSION = os.extsep + "py"
-else:
- PYTHON_SOURCE_EXTENSION = ".py"
+PYTHON_SOURCE_EXTENSION = ".py"
class install_lib(Command):
@@ -75,9 +71,9 @@ class install_lib(Command):
)
if self.compile is None:
- self.compile = 1
+ self.compile = True
if self.optimize is None:
- self.optimize = 0
+ self.optimize = False
if not isinstance(self.optimize, int):
try:
@@ -85,7 +81,7 @@ class install_lib(Command):
if self.optimize not in (0, 1, 2):
raise AssertionError
except (ValueError, AssertionError):
- raise DistutilsOptionError, "optimize must be 0, 1, or 2"
+ raise DistutilsOptionError("optimize must be 0, 1, or 2")
def run(self):
# Make sure we have built everything we need first
@@ -169,9 +165,11 @@ class install_lib(Command):
if ext != PYTHON_SOURCE_EXTENSION:
continue
if self.compile:
- bytecode_files.append(py_file + "c")
+ bytecode_files.append(imp.cache_from_source(
+ py_file, debug_override=True))
if self.optimize > 0:
- bytecode_files.append(py_file + "o")
+ bytecode_files.append(imp.cache_from_source(
+ py_file, debug_override=False))
return bytecode_files
diff --git a/Lib/distutils/command/install_scripts.py b/Lib/distutils/command/install_scripts.py
index 29cd9e7a0e3..31a1130ee54 100644
--- a/Lib/distutils/command/install_scripts.py
+++ b/Lib/distutils/command/install_scripts.py
@@ -5,14 +5,13 @@ Python scripts."""
# contributed by Bastian Kleineidam
-__revision__ = "$Id$"
-
import os
from distutils.core import Command
from distutils import log
from stat import ST_MODE
-class install_scripts (Command):
+
+class install_scripts(Command):
description = "install scripts (Python or otherwise)"
@@ -25,14 +24,13 @@ class install_scripts (Command):
boolean_options = ['force', 'skip-build']
-
- def initialize_options (self):
+ def initialize_options(self):
self.install_dir = None
self.force = 0
self.build_dir = None
self.skip_build = None
- def finalize_options (self):
+ def finalize_options(self):
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
self.set_undefined_options('install',
('install_scripts', 'install_dir'),
@@ -40,7 +38,7 @@ class install_scripts (Command):
('skip_build', 'skip_build'),
)
- def run (self):
+ def run(self):
if not self.skip_build:
self.run_command('build_scripts')
self.outfiles = self.copy_tree(self.build_dir, self.install_dir)
@@ -51,14 +49,12 @@ class install_scripts (Command):
if self.dry_run:
log.info("changing mode of %s", file)
else:
- mode = ((os.stat(file)[ST_MODE]) | 0555) & 07777
+ mode = ((os.stat(file)[ST_MODE]) | 0o555) & 0o7777
log.info("changing mode of %s to %o", file, mode)
os.chmod(file, mode)
- def get_inputs (self):
+ def get_inputs(self):
return self.distribution.scripts or []
def get_outputs(self):
return self.outfiles or []
-
-# class install_scripts
diff --git a/Lib/distutils/command/register.py b/Lib/distutils/command/register.py
index edb42b955d6..99545affa4a 100644
--- a/Lib/distutils/command/register.py
+++ b/Lib/distutils/command/register.py
@@ -5,14 +5,13 @@ Implements the Distutils 'register' command (register with the repository).
# created 2002/10/21, Richard Jones
-__revision__ = "$Id$"
-
-import urllib2
-import getpass
-import urlparse
+import os, string, getpass
+import io
+import urllib.parse, urllib.request
from warnings import warn
from distutils.core import PyPIRCCommand
+from distutils.errors import *
from distutils import log
class register(PyPIRCCommand):
@@ -86,7 +85,8 @@ class register(PyPIRCCommand):
def classifiers(self):
''' Fetch the list of classifiers from the server.
'''
- response = urllib2.urlopen(self.repository+'?:action=list_classifiers')
+ url = self.repository+'?:action=list_classifiers'
+ response = urllib.request.urlopen(url)
log.info(response.read())
def verify_metadata(self):
@@ -96,7 +96,6 @@ class register(PyPIRCCommand):
(code, result) = self.post_to_server(self.build_post_data('verify'))
log.info('Server response (%s): %s' % (code, result))
-
def send_metadata(self):
''' Send the metadata to the package index server.
@@ -145,23 +144,22 @@ We need to know who you are, so please choose either:
3. have the server generate a new password for you (and email it to you), or
4. quit
Your selection [default 1]: ''', log.INFO)
-
- choice = raw_input()
+ choice = input()
if not choice:
choice = '1'
elif choice not in choices:
- print 'Please choose one of the four options!'
+ print('Please choose one of the four options!')
if choice == '1':
# get the username and password
while not username:
- username = raw_input('Username: ')
+ username = input('Username: ')
while not password:
password = getpass.getpass('Password: ')
# set up the authentication
- auth = urllib2.HTTPPasswordMgr()
- host = urlparse.urlparse(self.repository)[1]
+ auth = urllib.request.HTTPPasswordMgr()
+ host = urllib.parse.urlparse(self.repository)[1]
auth.add_password(self.realm, host, username, password)
# send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'),
@@ -182,7 +180,7 @@ Your selection [default 1]: ''', log.INFO)
self._get_rc_file(), log.INFO)
choice = 'X'
while choice.lower() not in 'yn':
- choice = raw_input('Save your login (y/N)?')
+ choice = input('Save your login (y/N)?')
if not choice:
choice = 'n'
if choice.lower() == 'y':
@@ -193,7 +191,7 @@ Your selection [default 1]: ''', log.INFO)
data['name'] = data['password'] = data['email'] = ''
data['confirm'] = None
while not data['name']:
- data['name'] = raw_input('Username: ')
+ data['name'] = input('Username: ')
while data['password'] != data['confirm']:
while not data['password']:
data['password'] = getpass.getpass('Password: ')
@@ -202,9 +200,9 @@ Your selection [default 1]: ''', log.INFO)
if data['password'] != data['confirm']:
data['password'] = ''
data['confirm'] = None
- print "Password and confirm don't match!"
+ print("Password and confirm don't match!")
while not data['email']:
- data['email'] = raw_input(' EMail: ')
+ data['email'] = input(' EMail: ')
code, result = self.post_to_server(data)
if code != 200:
log.info('Server response (%s): %s' % (code, result))
@@ -216,7 +214,7 @@ Your selection [default 1]: ''', log.INFO)
data = {':action': 'password_reset'}
data['email'] = ''
while not data['email']:
- data['email'] = raw_input('Your email address: ')
+ data['email'] = input('Your email address: ')
code, result = self.post_to_server(data)
log.info('Server response (%s): %s' % (code, result))
@@ -253,56 +251,48 @@ Your selection [default 1]: ''', log.INFO)
'''
if 'name' in data:
self.announce('Registering %s to %s' % (data['name'],
- self.repository),
- log.INFO)
+ self.repository),
+ log.INFO)
# Build up the MIME payload for the urllib2 POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
sep_boundary = '\n--' + boundary
end_boundary = sep_boundary + '--'
- chunks = []
+ body = io.StringIO()
for key, value in data.items():
# handle multiple entries for the same name
if type(value) not in (type([]), type( () )):
value = [value]
for value in value:
- chunks.append(sep_boundary)
- chunks.append('\nContent-Disposition: form-data; name="%s"'%key)
- chunks.append("\n\n")
- chunks.append(value)
+ value = str(value)
+ body.write(sep_boundary)
+ body.write('\nContent-Disposition: form-data; name="%s"'%key)
+ body.write("\n\n")
+ body.write(value)
if value and value[-1] == '\r':
- chunks.append('\n') # write an extra newline (lurve Macs)
- chunks.append(end_boundary)
- chunks.append("\n")
-
- # chunks may be bytes (str) or unicode objects that we need to encode
- body = []
- for chunk in chunks:
- if isinstance(chunk, unicode):
- body.append(chunk.encode('utf-8'))
- else:
- body.append(chunk)
-
- body = ''.join(body)
+ body.write('\n') # write an extra newline (lurve Macs)
+ body.write(end_boundary)
+ body.write("\n")
+ body = body.getvalue().encode("utf-8")
# build the Request
headers = {
'Content-type': 'multipart/form-data; boundary=%s; charset=utf-8'%boundary,
'Content-length': str(len(body))
}
- req = urllib2.Request(self.repository, body, headers)
+ req = urllib.request.Request(self.repository, body, headers)
# handle HTTP and include the Basic Auth handler
- opener = urllib2.build_opener(
- urllib2.HTTPBasicAuthHandler(password_mgr=auth)
+ opener = urllib.request.build_opener(
+ urllib.request.HTTPBasicAuthHandler(password_mgr=auth)
)
data = ''
try:
result = opener.open(req)
- except urllib2.HTTPError, e:
+ except urllib.error.HTTPError as e:
if self.show_response:
data = e.fp.read()
result = e.code, e.msg
- except urllib2.URLError, e:
+ except urllib.error.URLError as e:
result = 500, str(e)
else:
if self.show_response:
@@ -311,5 +301,4 @@ Your selection [default 1]: ''', log.INFO)
if self.show_response:
dashes = '-' * 75
self.announce('%s%s%s' % (dashes, data, dashes))
-
return result
diff --git a/Lib/distutils/command/sdist.py b/Lib/distutils/command/sdist.py
index d30de10673c..a9429a4296a 100644
--- a/Lib/distutils/command/sdist.py
+++ b/Lib/distutils/command/sdist.py
@@ -2,19 +2,17 @@
Implements the Distutils 'sdist' command (create a source distribution)."""
-__revision__ = "$Id$"
-
import os
import string
import sys
+from types import *
from glob import glob
from warnings import warn
from distutils.core import Command
from distutils import dir_util, dep_util, file_util, archive_util
from distutils.text_file import TextFile
-from distutils.errors import (DistutilsPlatformError, DistutilsOptionError,
- DistutilsTemplateError)
+from distutils.errors import *
from distutils.filelist import FileList
from distutils import log
from distutils.util import convert_path
@@ -76,10 +74,6 @@ class sdist(Command):
('metadata-check', None,
"Ensure that all required elements of meta-data "
"are supplied. Warn if any missing. [default]"),
- ('owner=', 'u',
- "Owner name used when creating a tar file [default: current user]"),
- ('group=', 'g',
- "Group name used when creating a tar file [default: current group]"),
]
boolean_options = ['use-defaults', 'prune',
@@ -119,8 +113,6 @@ class sdist(Command):
self.archive_files = None
self.metadata_check = 1
- self.owner = None
- self.group = None
def finalize_options(self):
if self.manifest is None:
@@ -133,14 +125,14 @@ class sdist(Command):
try:
self.formats = [self.default_format[os.name]]
except KeyError:
- raise DistutilsPlatformError, \
- "don't know how to create source distributions " + \
- "on platform %s" % os.name
+ raise DistutilsPlatformError(
+ "don't know how to create source distributions "
+ "on platform %s" % os.name)
bad_format = archive_util.check_archive_formats(self.formats)
if bad_format:
- raise DistutilsOptionError, \
- "unknown archive format '%s'" % bad_format
+ raise DistutilsOptionError(
+ "unknown archive format '%s'" % bad_format)
if self.dist_dir is None:
self.dist_dir = "dist"
@@ -229,21 +221,20 @@ class sdist(Command):
Warns if (README or README.txt) or setup.py are missing; everything
else is optional.
"""
-
standards = [('README', 'README.txt'), self.distribution.script_name]
for fn in standards:
if isinstance(fn, tuple):
alts = fn
- got_it = 0
+ got_it = False
for fn in alts:
if os.path.exists(fn):
- got_it = 1
+ got_it = True
self.filelist.append(fn)
break
if not got_it:
self.warn("standard file not found: should have one of " +
- string.join(alts, ', '))
+ ', '.join(alts))
else:
if os.path.exists(fn):
self.filelist.append(fn)
@@ -253,8 +244,7 @@ class sdist(Command):
optional = ['test/test*.py', 'setup.cfg']
for pattern in optional:
files = filter(os.path.isfile, glob(pattern))
- if files:
- self.filelist.extend(files)
+ self.filelist.extend(files)
# build_py is used to get:
# - python modules
@@ -304,16 +294,12 @@ class sdist(Command):
'self.filelist', which updates itself accordingly.
"""
log.info("reading manifest template '%s'", self.template)
- template = TextFile(self.template,
- strip_comments=1,
- skip_blanks=1,
- join_lines=1,
- lstrip_ws=1,
- rstrip_ws=1,
+ template = TextFile(self.template, strip_comments=1, skip_blanks=1,
+ join_lines=1, lstrip_ws=1, rstrip_ws=1,
collapse_join=1)
try:
- while 1:
+ while True:
line = template.readline()
if line is None: # end of file
break
@@ -344,8 +330,6 @@ class sdist(Command):
self.filelist.exclude_pattern(None, prefix=build.build_base)
self.filelist.exclude_pattern(None, prefix=base_dir)
- # pruning out vcs directories
- # both separators are used under win32
if sys.platform == 'win32':
seps = r'/|\\'
else:
@@ -372,11 +356,11 @@ class sdist(Command):
"writing manifest file '%s'" % self.manifest)
def _manifest_is_not_generated(self):
- # check for special comment used in 2.7.1 and higher
+ # check for special comment used in 3.1.3 and higher
if not os.path.isfile(self.manifest):
return False
- fp = open(self.manifest, 'rU')
+ fp = open(self.manifest)
try:
first_line = fp.readline()
finally:
@@ -460,8 +444,7 @@ class sdist(Command):
self.formats.append(self.formats.pop(self.formats.index('tar')))
for fmt in self.formats:
- file = self.make_archive(base_name, fmt, base_dir=base_dir,
- owner=self.owner, group=self.group)
+ file = self.make_archive(base_name, fmt, base_dir=base_dir)
archive_files.append(file)
self.distribution.dist_files.append(('sdist', '', file))
diff --git a/Lib/distutils/command/upload.py b/Lib/distutils/command/upload.py
index d0133353a63..8b36851d256 100644
--- a/Lib/distutils/command/upload.py
+++ b/Lib/distutils/command/upload.py
@@ -1,19 +1,25 @@
"""distutils.command.upload
Implements the Distutils 'upload' subcommand (upload package to PyPI)."""
-import os
-import socket
-import platform
-from urllib2 import urlopen, Request, HTTPError
-from base64 import standard_b64encode
-import urlparse
-import cStringIO as StringIO
-from hashlib import md5
-from distutils.errors import DistutilsOptionError
+from distutils.errors import *
from distutils.core import PyPIRCCommand
from distutils.spawn import spawn
from distutils import log
+import sys
+import os, io
+import socket
+import platform
+import configparser
+import http.client as httpclient
+from base64 import standard_b64encode
+import urllib.parse
+
+# this keeps compatibility for 2.3 and 2.4
+if sys.version < "2.5":
+ from md5 import md5
+else:
+ from hashlib import md5
class upload(PyPIRCCommand):
@@ -60,15 +66,6 @@ class upload(PyPIRCCommand):
self.upload_file(command, pyversion, filename)
def upload_file(self, command, pyversion, filename):
- # Makes sure the repository URL is compliant
- schema, netloc, url, params, query, fragments = \
- urlparse.urlparse(self.repository)
- if params or query or fragments:
- raise AssertionError("Incompatible url %s" % self.repository)
-
- if schema not in ('http', 'https'):
- raise AssertionError("unsupported schema " + schema)
-
# Sign if requested
if self.sign:
gpg_args = ["gpg", "--detach-sign", "-a", filename]
@@ -128,67 +125,78 @@ class upload(PyPIRCCommand):
if self.sign:
data['gpg_signature'] = (os.path.basename(filename) + ".asc",
- open(filename+".asc").read())
+ open(filename+".asc", "rb").read())
# set up the authentication
- auth = "Basic " + standard_b64encode(self.username + ":" +
- self.password)
+ user_pass = (self.username + ":" + self.password).encode('ascii')
+ # The exact encoding of the authentication string is debated.
+ # Anyway PyPI only accepts ascii for both username or password.
+ auth = "Basic " + standard_b64encode(user_pass).decode('ascii')
# Build up the MIME payload for the POST data
boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
- sep_boundary = '\n--' + boundary
- end_boundary = sep_boundary + '--'
- body = StringIO.StringIO()
+ sep_boundary = b'\n--' + boundary.encode('ascii')
+ end_boundary = sep_boundary + b'--'
+ body = io.BytesIO()
for key, value in data.items():
+ title = '\nContent-Disposition: form-data; name="%s"' % key
# handle multiple entries for the same name
- if not isinstance(value, list):
+ if type(value) != type([]):
value = [value]
for value in value:
- if isinstance(value, tuple):
- fn = ';filename="%s"' % value[0]
+ if type(value) is tuple:
+ title += '; filename="%s"' % value[0]
value = value[1]
else:
- fn = ""
-
+ value = str(value).encode('utf-8')
body.write(sep_boundary)
- body.write('\nContent-Disposition: form-data; name="%s"'%key)
- body.write(fn)
- body.write("\n\n")
+ body.write(title.encode('utf-8'))
+ body.write(b"\n\n")
body.write(value)
- if value and value[-1] == '\r':
- body.write('\n') # write an extra newline (lurve Macs)
+ if value and value[-1:] == b'\r':
+ body.write(b'\n') # write an extra newline (lurve Macs)
body.write(end_boundary)
- body.write("\n")
+ body.write(b"\n")
body = body.getvalue()
self.announce("Submitting %s to %s" % (filename, self.repository), log.INFO)
# build the Request
- headers = {'Content-type':
- 'multipart/form-data; boundary=%s' % boundary,
- 'Content-length': str(len(body)),
- 'Authorization': auth}
-
- request = Request(self.repository, data=body,
- headers=headers)
- # send the data
+ # We can't use urllib since we need to send the Basic
+ # auth right with the first request
+ # TODO(jhylton): Can we fix urllib?
+ schema, netloc, url, params, query, fragments = \
+ urllib.parse.urlparse(self.repository)
+ assert not params and not query and not fragments
+ if schema == 'http':
+ http = httpclient.HTTPConnection(netloc)
+ elif schema == 'https':
+ http = httpclient.HTTPSConnection(netloc)
+ else:
+ raise AssertionError("unsupported schema "+schema)
+
+ data = ''
+ loglevel = log.INFO
try:
- result = urlopen(request)
- status = result.getcode()
- reason = result.msg
- if self.show_response:
- msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
- self.announce(msg, log.INFO)
- except socket.error, e:
+ http.connect()
+ http.putrequest("POST", url)
+ http.putheader('Content-type',
+ 'multipart/form-data; boundary=%s'%boundary)
+ http.putheader('Content-length', str(len(body)))
+ http.putheader('Authorization', auth)
+ http.endheaders()
+ http.send(body)
+ except socket.error as e:
self.announce(str(e), log.ERROR)
return
- except HTTPError, e:
- status = e.code
- reason = e.msg
- if status == 200:
- self.announce('Server response (%s): %s' % (status, reason),
+ r = http.getresponse()
+ if r.status == 200:
+ self.announce('Server response (%s): %s' % (r.status, r.reason),
log.INFO)
else:
- self.announce('Upload failed (%s): %s' % (status, reason),
+ self.announce('Upload failed (%s): %s' % (r.status, r.reason),
log.ERROR)
+ if self.show_response:
+ msg = '\n'.join(('-' * 75, r.read(), '-' * 75))
+ self.announce(msg, log.INFO)
diff --git a/Lib/distutils/command/wininst-9.0-amd64.exe b/Lib/distutils/command/wininst-9.0-amd64.exe
index 11d8011c717..94fbd4341b2 100644
--- a/Lib/distutils/command/wininst-9.0-amd64.exe
+++ b/Lib/distutils/command/wininst-9.0-amd64.exe
Binary files differ
diff --git a/Lib/distutils/command/wininst-9.0.exe b/Lib/distutils/command/wininst-9.0.exe
index dadb31d8938..2ec261f9fdc 100644
--- a/Lib/distutils/command/wininst-9.0.exe
+++ b/Lib/distutils/command/wininst-9.0.exe
Binary files differ
diff --git a/Lib/distutils/config.py b/Lib/distutils/config.py
index 1d327143bea..1fd53346e96 100644
--- a/Lib/distutils/config.py
+++ b/Lib/distutils/config.py
@@ -4,7 +4,7 @@ Provides the PyPIRCCommand class, the base class for the command classes
that uses .pypirc in the distutils.command package.
"""
import os
-from ConfigParser import ConfigParser
+from configparser import ConfigParser
from distutils.cmd import Command
@@ -42,11 +42,8 @@ class PyPIRCCommand(Command):
def _store_pypirc(self, username, password):
"""Creates a default .pypirc file."""
rc = self._get_rc_file()
- f = os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0600), 'w')
- try:
+ with os.fdopen(os.open(rc, os.O_CREAT | os.O_WRONLY, 0o600), 'w') as f:
f.write(DEFAULT_PYPIRC % (username, password))
- finally:
- f.close()
def _read_pypirc(self):
"""Reads the .pypirc file."""
@@ -54,6 +51,8 @@ class PyPIRCCommand(Command):
if os.path.exists(rc):
self.announce('Using PyPI login from %s' % rc)
repository = self.repository or self.DEFAULT_REPOSITORY
+ realm = self.realm or self.DEFAULT_REALM
+
config = ConfigParser()
config.read(rc)
sections = config.sections()
diff --git a/Lib/distutils/core.py b/Lib/distutils/core.py
index b89557d7679..260332a2ac6 100644
--- a/Lib/distutils/core.py
+++ b/Lib/distutils/core.py
@@ -6,14 +6,11 @@ indirectly provides the Distribution and Command classes, although they are
really defined in distutils.dist and distutils.cmd.
"""
-__revision__ = "$Id$"
-
-import sys
import os
+import sys
from distutils.debug import DEBUG
-from distutils.errors import (DistutilsSetupError, DistutilsArgError,
- DistutilsError, CCompilerError)
+from distutils.errors import *
from distutils.util import grok_environment_error
# Mainly import these so setup scripts can "from distutils.core import" them.
@@ -33,9 +30,9 @@ usage: %(script)s [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: %(script)s cmd --help
"""
-def gen_usage(script_name):
+def gen_usage (script_name):
script = os.path.basename(script_name)
- return USAGE % {'script': script}
+ return USAGE % vars()
# Some mild magic to control the behaviour of 'setup()' from 'run_setup()'.
@@ -58,7 +55,7 @@ extension_keywords = ('name', 'sources', 'include_dirs',
'extra_objects', 'extra_compile_args', 'extra_link_args',
'swig_opts', 'export_symbols', 'depends', 'language')
-def setup(**attrs):
+def setup (**attrs):
"""The gateway to the Distutils: do everything your setup script needs
to do, in a highly flexible and user-driven way. Briefly: create a
Distribution instance; find and parse config files; parse the command
@@ -103,19 +100,19 @@ def setup(**attrs):
if 'script_name' not in attrs:
attrs['script_name'] = os.path.basename(sys.argv[0])
- if 'script_args' not in attrs:
+ if 'script_args' not in attrs:
attrs['script_args'] = sys.argv[1:]
# Create the Distribution instance, using the remaining arguments
# (ie. everything except distclass) to initialize it
try:
_setup_distribution = dist = klass(attrs)
- except DistutilsSetupError, msg:
- if 'name' in attrs:
- raise SystemExit, "error in %s setup command: %s" % \
- (attrs['name'], msg)
+ except DistutilsSetupError as msg:
+ if 'name' not in attrs:
+ raise SystemExit("error in setup command: %s" % msg)
else:
- raise SystemExit, "error in setup command: %s" % msg
+ raise SystemExit("error in %s setup command: %s" % \
+ (attrs['name'], msg))
if _setup_stop_after == "init":
return dist
@@ -125,22 +122,21 @@ def setup(**attrs):
dist.parse_config_files()
if DEBUG:
- print "options (after parsing config files):"
+ print("options (after parsing config files):")
dist.dump_option_dicts()
if _setup_stop_after == "config":
return dist
- # Parse the command line and override config files; any
- # command-line errors are the end user's fault, so turn them into
- # SystemExit to suppress tracebacks.
+ # Parse the command line; any command-line errors are the end user's
+ # fault, so turn them into SystemExit to suppress tracebacks.
try:
ok = dist.parse_command_line()
- except DistutilsArgError, msg:
- raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
+ except DistutilsArgError as msg:
+ raise SystemExit(gen_usage(dist.script_name) + "\nerror: %s" % msg)
if DEBUG:
- print "options (after parsing command line):"
+ print("options (after parsing command line):")
dist.dump_option_dicts()
if _setup_stop_after == "commandline":
@@ -151,34 +147,36 @@ def setup(**attrs):
try:
dist.run_commands()
except KeyboardInterrupt:
- raise SystemExit, "interrupted"
- except (IOError, os.error), exc:
+ raise SystemExit("interrupted")
+ except (IOError, os.error) as exc:
error = grok_environment_error(exc)
if DEBUG:
sys.stderr.write(error + "\n")
raise
else:
- raise SystemExit, error
+ raise SystemExit(error)
except (DistutilsError,
- CCompilerError), msg:
+ CCompilerError) as msg:
if DEBUG:
raise
else:
- raise SystemExit, "error: " + str(msg)
+ raise SystemExit("error: " + str(msg))
return dist
+# setup ()
-def run_setup(script_name, script_args=None, stop_after="run"):
+
+def run_setup (script_name, script_args=None, stop_after="run"):
"""Run a setup script in a somewhat controlled environment, and
return the Distribution instance that drives things. This is useful
if you need to find out the distribution meta-data (passed as
keyword args from 'script' to 'setup()', or the contents of the
config files or command-line.
- 'script_name' is a file that will be run with 'execfile()';
+ 'script_name' is a file that will be read and run with 'exec()';
'sys.argv[0]' will be replaced with 'script' for the duration of the
call. 'script_args' is a list of strings; if supplied,
'sys.argv[1:]' will be replaced by 'script_args' for the duration of
@@ -203,7 +201,7 @@ def run_setup(script_name, script_args=None, stop_after="run"):
used to drive the Distutils.
"""
if stop_after not in ('init', 'config', 'commandline', 'run'):
- raise ValueError, "invalid value for 'stop_after': %r" % (stop_after,)
+ raise ValueError("invalid value for 'stop_after': %r" % (stop_after,))
global _setup_stop_after, _setup_distribution
_setup_stop_after = stop_after
@@ -216,11 +214,8 @@ def run_setup(script_name, script_args=None, stop_after="run"):
sys.argv[0] = script_name
if script_args is not None:
sys.argv[1:] = script_args
- f = open(script_name)
- try:
- exec f.read() in g, l
- finally:
- f.close()
+ with open(script_name, 'rb') as f:
+ exec(f.read(), g, l)
finally:
sys.argv = save_argv
_setup_stop_after = None
@@ -232,11 +227,13 @@ def run_setup(script_name, script_args=None, stop_after="run"):
raise
if _setup_distribution is None:
- raise RuntimeError, \
- ("'distutils.core.setup()' was never called -- "
+ raise RuntimeError(("'distutils.core.setup()' was never called -- "
"perhaps '%s' is not a Distutils setup script?") % \
- script_name
+ script_name)
# I wonder if the setup script's namespace -- g and l -- would be of
# any interest to callers?
+ #print "_setup_distribution:", _setup_distribution
return _setup_distribution
+
+# run_setup ()
diff --git a/Lib/distutils/cygwinccompiler.py b/Lib/distutils/cygwinccompiler.py
index a1ee815c6cc..819e1a97be3 100644
--- a/Lib/distutils/cygwinccompiler.py
+++ b/Lib/distutils/cygwinccompiler.py
@@ -45,16 +45,19 @@ cygwin in no-cygwin mode).
# * mingw gcc 3.2/ld 2.13 works
# (ld supports -shared)
-# This module should be kept compatible with Python 2.1.
+import os
+import sys
+import copy
+from subprocess import Popen, PIPE
+import re
-__revision__ = "$Id$"
-
-import os,sys,copy
from distutils.ccompiler import gen_preprocess_options, gen_lib_options
from distutils.unixccompiler import UnixCCompiler
from distutils.file_util import write_file
from distutils.errors import DistutilsExecError, CompileError, UnknownFileError
from distutils import log
+from distutils.version import LooseVersion
+from distutils.spawn import find_executable
def get_msvcr():
"""Include the appropriate MSVC runtime library if Python was built
@@ -79,8 +82,9 @@ def get_msvcr():
raise ValueError("Unknown MS Compiler version %s " % msc_ver)
-class CygwinCCompiler (UnixCCompiler):
-
+class CygwinCCompiler(UnixCCompiler):
+ """ Handles the Cygwin port of the GNU C compiler to Windows.
+ """
compiler_type = 'cygwin'
obj_extension = ".o"
static_lib_extension = ".a"
@@ -89,11 +93,11 @@ class CygwinCCompiler (UnixCCompiler):
shared_lib_format = "%s%s"
exe_extension = ".exe"
- def __init__ (self, verbose=0, dry_run=0, force=0):
+ def __init__(self, verbose=0, dry_run=0, force=0):
- UnixCCompiler.__init__ (self, verbose, dry_run, force)
+ UnixCCompiler.__init__(self, verbose, dry_run, force)
- (status, details) = check_config_h()
+ status, details = check_config_h()
self.debug_print("Python's GCC status: %s (details: %s)" %
(status, details))
if status is not CONFIG_H_OK:
@@ -148,38 +152,26 @@ class CygwinCCompiler (UnixCCompiler):
# with MSVC 7.0 or later.
self.dll_libraries = get_msvcr()
- # __init__ ()
-
-
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
+ """Compiles the source by spawning GCC and windres if needed."""
if ext == '.rc' or ext == '.res':
# gcc needs '.res' and '.rc' compiled to object files !!!
try:
self.spawn(["windres", "-i", src, "-o", obj])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
- raise CompileError, msg
-
- def link (self,
- target_desc,
- objects,
- output_filename,
- output_dir=None,
- libraries=None,
- library_dirs=None,
- runtime_library_dirs=None,
- export_symbols=None,
- debug=0,
- extra_preargs=None,
- extra_postargs=None,
- build_temp=None,
- target_lang=None):
-
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
+
+ def link(self, target_desc, objects, output_filename, output_dir=None,
+ libraries=None, library_dirs=None, runtime_library_dirs=None,
+ export_symbols=None, debug=0, extra_preargs=None,
+ extra_postargs=None, build_temp=None, target_lang=None):
+ """Link the objects."""
# use separate copies, so we can modify the lists
extra_preargs = copy.copy(extra_preargs or [])
libraries = copy.copy(libraries or [])
@@ -244,64 +236,44 @@ class CygwinCCompiler (UnixCCompiler):
if not debug:
extra_preargs.append("-s")
- UnixCCompiler.link(self,
- target_desc,
- objects,
- output_filename,
- output_dir,
- libraries,
- library_dirs,
+ UnixCCompiler.link(self, target_desc, objects, output_filename,
+ output_dir, libraries, library_dirs,
runtime_library_dirs,
None, # export_symbols, we do this in our def-file
- debug,
- extra_preargs,
- extra_postargs,
- build_temp,
+ debug, extra_preargs, extra_postargs, build_temp,
target_lang)
- # link ()
-
# -- Miscellaneous methods -----------------------------------------
- # overwrite the one from CCompiler to support rc and res-files
- def object_filenames (self,
- source_filenames,
- strip_dir=0,
- output_dir=''):
- if output_dir is None: output_dir = ''
+ def object_filenames(self, source_filenames, strip_dir=0, output_dir=''):
+ """Adds supports for rc and res files."""
+ if output_dir is None:
+ output_dir = ''
obj_names = []
for src_name in source_filenames:
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
- (base, ext) = os.path.splitext (os.path.normcase(src_name))
+ base, ext = os.path.splitext(os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc','.res']):
- raise UnknownFileError, \
- "unknown file type '%s' (from '%s')" % \
- (ext, src_name)
+ raise UnknownFileError("unknown file type '%s' (from '%s')" % \
+ (ext, src_name))
if strip_dir:
base = os.path.basename (base)
- if ext == '.res' or ext == '.rc':
+ if ext in ('.res', '.rc'):
# these need to be compiled to object files
- obj_names.append (os.path.join (output_dir,
- base + ext + self.obj_extension))
+ obj_names.append (os.path.join(output_dir,
+ base + ext + self.obj_extension))
else:
- obj_names.append (os.path.join (output_dir,
- base + self.obj_extension))
+ obj_names.append (os.path.join(output_dir,
+ base + self.obj_extension))
return obj_names
- # object_filenames ()
-
-# class CygwinCCompiler
-
-
# the same as cygwin plus some additional parameters
-class Mingw32CCompiler (CygwinCCompiler):
-
+class Mingw32CCompiler(CygwinCCompiler):
+ """ Handles the Mingw32 port of the GNU C compiler to Windows.
+ """
compiler_type = 'mingw32'
- def __init__ (self,
- verbose=0,
- dry_run=0,
- force=0):
+ def __init__(self, verbose=0, dry_run=0, force=0):
CygwinCCompiler.__init__ (self, verbose, dry_run, force)
@@ -337,10 +309,6 @@ class Mingw32CCompiler (CygwinCCompiler):
# with MSVC 7.0 or later.
self.dll_libraries = get_msvcr()
- # __init__ ()
-
-# class Mingw32CCompiler
-
# Because these compilers aren't configured in Python's pyconfig.h file by
# default, we should at least warn the user if he is using a unmodified
# version.
@@ -350,16 +318,16 @@ CONFIG_H_NOTOK = "not ok"
CONFIG_H_UNCERTAIN = "uncertain"
def check_config_h():
+ """Check if the current Python installation appears amenable to building
+ extensions with GCC.
+
+ Returns a tuple (status, details), where 'status' is one of the following
+ constants:
+
+ - CONFIG_H_OK: all is well, go ahead and compile
+ - CONFIG_H_NOTOK: doesn't look good
+ - CONFIG_H_UNCERTAIN: not sure -- unable to read pyconfig.h
- """Check if the current Python installation (specifically, pyconfig.h)
- appears amenable to building extensions with GCC. Returns a tuple
- (status, details), where 'status' is one of the following constants:
- CONFIG_H_OK
- all is well, go ahead and compile
- CONFIG_H_NOTOK
- doesn't look good
- CONFIG_H_UNCERTAIN
- not sure -- unable to read pyconfig.h
'details' is a human-readable string explaining the situation.
Note there are two ways to conclude "OK": either 'sys.version' contains
@@ -371,79 +339,54 @@ def check_config_h():
# "pyconfig.h" check -- should probably be renamed...
from distutils import sysconfig
- import string
- # if sys.version contains GCC then python was compiled with
- # GCC, and the pyconfig.h file should be OK
- if string.find(sys.version,"GCC") >= 0:
- return (CONFIG_H_OK, "sys.version mentions 'GCC'")
+ # if sys.version contains GCC then python was compiled with GCC, and the
+ # pyconfig.h file should be OK
+ if "GCC" in sys.version:
+ return CONFIG_H_OK, "sys.version mentions 'GCC'"
+
+ # let's see if __GNUC__ is mentioned in python.h
fn = sysconfig.get_config_h_filename()
try:
- # It would probably better to read single lines to search.
- # But we do this only once, and it is fast enough
- f = open(fn)
+ config_h = open(fn)
try:
- s = f.read()
+ if "__GNUC__" in config_h.read():
+ return CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn
+ else:
+ return CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn
finally:
- f.close()
-
- except IOError, exc:
- # if we can't read this file, we cannot say it is wrong
- # the compiler will complain later about this file as missing
+ config_h.close()
+ except IOError as exc:
return (CONFIG_H_UNCERTAIN,
"couldn't read '%s': %s" % (fn, exc.strerror))
- else:
- # "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
- if string.find(s,"__GNUC__") >= 0:
- return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
- else:
- return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
+RE_VERSION = re.compile(b'(\d+\.\d+(\.\d+)*)')
+def _find_exe_version(cmd):
+ """Find the version of an executable by running `cmd` in the shell.
+ If the command is not found, or the output does not match
+ `RE_VERSION`, returns None.
+ """
+ executable = cmd.split()[0]
+ if find_executable(executable) is None:
+ return None
+ out = Popen(cmd, shell=True, stdout=PIPE).stdout
+ try:
+ out_string = out.read()
+ finally:
+ out.close()
+ result = RE_VERSION.search(out_string)
+ if result is None:
+ return None
+ # LooseVersion works with strings
+ # so we need to decode our bytes
+ return LooseVersion(result.group(1).decode())
def get_versions():
""" Try to find out the versions of gcc, ld and dllwrap.
- If not possible it returns None for it.
- """
- from distutils.version import LooseVersion
- from distutils.spawn import find_executable
- import re
- gcc_exe = find_executable('gcc')
- if gcc_exe:
- out = os.popen(gcc_exe + ' -dumpversion','r')
- out_string = out.read()
- out.close()
- result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
- if result:
- gcc_version = LooseVersion(result.group(1))
- else:
- gcc_version = None
- else:
- gcc_version = None
- ld_exe = find_executable('ld')
- if ld_exe:
- out = os.popen(ld_exe + ' -v','r')
- out_string = out.read()
- out.close()
- result = re.search('(\d+\.\d+(\.\d+)*)',out_string)
- if result:
- ld_version = LooseVersion(result.group(1))
- else:
- ld_version = None
- else:
- ld_version = None
- dllwrap_exe = find_executable('dllwrap')
- if dllwrap_exe:
- out = os.popen(dllwrap_exe + ' --version','r')
- out_string = out.read()
- out.close()
- result = re.search(' (\d+\.\d+(\.\d+)*)',out_string)
- if result:
- dllwrap_version = LooseVersion(result.group(1))
- else:
- dllwrap_version = None
- else:
- dllwrap_version = None
- return (gcc_version, ld_version, dllwrap_version)
+ If not possible it returns None for it.
+ """
+ commands = ['gcc -dumpversion', 'ld -v', 'dllwrap --version']
+ return tuple([_find_exe_version(cmd) for cmd in commands])
diff --git a/Lib/distutils/debug.py b/Lib/distutils/debug.py
index 2886744402e..daf1660f0d8 100644
--- a/Lib/distutils/debug.py
+++ b/Lib/distutils/debug.py
@@ -1,7 +1,5 @@
import os
-__revision__ = "$Id$"
-
# If DISTUTILS_DEBUG is anything other than the empty string, we run in
# debug mode.
DEBUG = os.environ.get('DISTUTILS_DEBUG')
diff --git a/Lib/distutils/dep_util.py b/Lib/distutils/dep_util.py
index 2b759056ea8..d74f5e4e92f 100644
--- a/Lib/distutils/dep_util.py
+++ b/Lib/distutils/dep_util.py
@@ -4,56 +4,56 @@ Utility functions for simple, timestamp-based dependency of files
and groups of files; also, function based entirely on such
timestamp dependency analysis."""
-__revision__ = "$Id$"
-
import os
-from stat import ST_MTIME
from distutils.errors import DistutilsFileError
-def newer(source, target):
- """Tells if the target is newer than the source.
-
- Return true if 'source' exists and is more recently modified than
- 'target', or if 'source' exists and 'target' doesn't.
-
- Return false if both exist and 'target' is the same age or younger
- than 'source'. Raise DistutilsFileError if 'source' does not exist.
- Note that this test is not very accurate: files created in the same second
- will have the same "age".
+def newer (source, target):
+ """Return true if 'source' exists and is more recently modified than
+ 'target', or if 'source' exists and 'target' doesn't. Return false if
+ both exist and 'target' is the same age or younger than 'source'.
+ Raise DistutilsFileError if 'source' does not exist.
"""
if not os.path.exists(source):
raise DistutilsFileError("file '%s' does not exist" %
os.path.abspath(source))
if not os.path.exists(target):
- return True
+ return 1
+
+ from stat import ST_MTIME
+ mtime1 = os.stat(source)[ST_MTIME]
+ mtime2 = os.stat(target)[ST_MTIME]
+
+ return mtime1 > mtime2
- return os.stat(source)[ST_MTIME] > os.stat(target)[ST_MTIME]
+# newer ()
-def newer_pairwise(sources, targets):
+
+def newer_pairwise (sources, targets):
"""Walk two filename lists in parallel, testing if each source is newer
than its corresponding target. Return a pair of lists (sources,
targets) where source is newer than target, according to the semantics
of 'newer()'.
"""
if len(sources) != len(targets):
- raise ValueError, "'sources' and 'targets' must be same length"
+ raise ValueError("'sources' and 'targets' must be same length")
# build a pair of lists (sources, targets) where source is newer
n_sources = []
n_targets = []
- for source, target in zip(sources, targets):
- if newer(source, target):
- n_sources.append(source)
- n_targets.append(target)
+ for i in range(len(sources)):
+ if newer(sources[i], targets[i]):
+ n_sources.append(sources[i])
+ n_targets.append(targets[i])
- return n_sources, n_targets
+ return (n_sources, n_targets)
+
+# newer_pairwise ()
-def newer_group(sources, target, missing='error'):
- """Return true if 'target' is out-of-date with respect to any file
- listed in 'sources'.
- In other words, if 'target' exists and is newer
+def newer_group (sources, target, missing='error'):
+ """Return true if 'target' is out-of-date with respect to any file
+ listed in 'sources'. In other words, if 'target' exists and is newer
than every file in 'sources', return false; otherwise return true.
'missing' controls what we do when a source file is missing; the
default ("error") is to blow up with an OSError from inside 'stat()';
@@ -66,14 +66,14 @@ def newer_group(sources, target, missing='error'):
"""
# If the target doesn't even exist, then it's definitely out-of-date.
if not os.path.exists(target):
- return True
+ return 1
# Otherwise we have to find out the hard way: if *any* source file
# is more recent than 'target', then 'target' is out-of-date and
# we can immediately return true. If we fall through to the end
# of the loop, then 'target' is up-to-date and we return false.
+ from stat import ST_MTIME
target_mtime = os.stat(target)[ST_MTIME]
-
for source in sources:
if not os.path.exists(source):
if missing == 'error': # blow up when we stat() the file
@@ -81,9 +81,12 @@ def newer_group(sources, target, missing='error'):
elif missing == 'ignore': # missing source dropped from
continue # target's dependency list
elif missing == 'newer': # missing source means target is
- return True # out-of-date
+ return 1 # out-of-date
- if os.stat(source)[ST_MTIME] > target_mtime:
- return True
+ source_mtime = os.stat(source)[ST_MTIME]
+ if source_mtime > target_mtime:
+ return 1
+ else:
+ return 0
- return False
+# newer_group ()
diff --git a/Lib/distutils/dir_util.py b/Lib/distutils/dir_util.py
index 5026e246685..2826ff805d7 100644
--- a/Lib/distutils/dir_util.py
+++ b/Lib/distutils/dir_util.py
@@ -2,9 +2,7 @@
Utility functions for manipulating directories and directory trees."""
-__revision__ = "$Id$"
-
-import os
+import os, sys
import errno
from distutils.errors import DistutilsFileError, DistutilsInternalError
from distutils import log
@@ -16,7 +14,7 @@ _path_created = {}
# I don't use os.makedirs because a) it's new to Python 1.5.2, and
# b) it blows up if the directory already exists (I want to silently
# succeed in that case).
-def mkpath(name, mode=0777, verbose=1, dry_run=0):
+def mkpath(name, mode=0o777, verbose=1, dry_run=0):
"""Create a directory and any missing ancestor directories.
If the directory already exists (or if 'name' is the empty string, which
@@ -30,9 +28,9 @@ def mkpath(name, mode=0777, verbose=1, dry_run=0):
global _path_created
# Detect a common bug -- name is None
- if not isinstance(name, basestring):
- raise DistutilsInternalError, \
- "mkpath: 'name' must be a string (got %r)" % (name,)
+ if not isinstance(name, str):
+ raise DistutilsInternalError(
+ "mkpath: 'name' must be a string (got %r)" % (name,))
# XXX what's the better way to handle verbosity? print as we create
# each directory in the path (the current behaviour), or only announce
@@ -70,7 +68,7 @@ def mkpath(name, mode=0777, verbose=1, dry_run=0):
if not dry_run:
try:
os.mkdir(head, mode)
- except OSError, exc:
+ except OSError as exc:
if not (exc.errno == errno.EEXIST and os.path.isdir(head)):
raise DistutilsFileError(
"could not create '%s': %s" % (head, exc.args[-1]))
@@ -79,7 +77,7 @@ def mkpath(name, mode=0777, verbose=1, dry_run=0):
_path_created[abs_head] = 1
return created_dirs
-def create_tree(base_dir, files, mode=0777, verbose=1, dry_run=0):
+def create_tree(base_dir, files, mode=0o777, verbose=1, dry_run=0):
"""Create all the empty directories under 'base_dir' needed to put 'files'
there.
@@ -90,14 +88,12 @@ def create_tree(base_dir, files, mode=0777, verbose=1, dry_run=0):
'dry_run' flags are as for 'mkpath()'.
"""
# First get the list of directories to create
- need_dir = {}
+ need_dir = set()
for file in files:
- need_dir[os.path.join(base_dir, os.path.dirname(file))] = 1
- need_dirs = need_dir.keys()
- need_dirs.sort()
+ need_dir.add(os.path.join(base_dir, os.path.dirname(file)))
# Now create them
- for dir in need_dirs:
+ for dir in sorted(need_dir):
mkpath(dir, mode, verbose=verbose, dry_run=dry_run)
def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
@@ -124,16 +120,17 @@ def copy_tree(src, dst, preserve_mode=1, preserve_times=1,
from distutils.file_util import copy_file
if not dry_run and not os.path.isdir(src):
- raise DistutilsFileError, \
- "cannot copy tree '%s': not a directory" % src
+ raise DistutilsFileError(
+ "cannot copy tree '%s': not a directory" % src)
try:
names = os.listdir(src)
- except os.error, (errno, errstr):
+ except os.error as e:
+ (errno, errstr) = e
if dry_run:
names = []
else:
- raise DistutilsFileError, \
- "error listing files in '%s': %s" % (src, errstr)
+ raise DistutilsFileError(
+ "error listing files in '%s': %s" % (src, errstr))
if not dry_run:
mkpath(dst, verbose=verbose)
@@ -201,7 +198,7 @@ def remove_tree(directory, verbose=1, dry_run=0):
abspath = os.path.abspath(cmd[1])
if abspath in _path_created:
del _path_created[abspath]
- except (IOError, OSError), exc:
+ except (IOError, OSError) as exc:
log.warn(grok_environment_error(
exc, "error removing %s: " % directory))
diff --git a/Lib/distutils/dist.py b/Lib/distutils/dist.py
index e025313dbd9..a7025682781 100644
--- a/Lib/distutils/dist.py
+++ b/Lib/distutils/dist.py
@@ -4,26 +4,19 @@ Provides the Distribution class, which represents the module distribution
being built/installed/distributed.
"""
-__revision__ = "$Id$"
-
import sys, os, re
-from email import message_from_file
try:
import warnings
except ImportError:
warnings = None
-from distutils.errors import (DistutilsOptionError, DistutilsArgError,
- DistutilsModuleError, DistutilsClassError)
+from distutils.errors import *
from distutils.fancy_getopt import FancyGetopt, translate_longopt
from distutils.util import check_environ, strtobool, rfc822_escape
from distutils import log
from distutils.debug import DEBUG
-# Encoding used for the PKG-INFO files
-PKG_INFO_ENCODING = 'utf-8'
-
# Regex to define acceptable Distutils command names. This is not *quite*
# the same as a Python NAME -- I don't allow leading underscores. The fact
# that they're very similar is no coincidence; the default naming scheme is
@@ -58,9 +51,7 @@ class Distribution:
('quiet', 'q', "run quietly (turns verbosity off)"),
('dry-run', 'n', "don't actually do anything"),
('help', 'h', "show detailed help message"),
- ('no-user-cfg', None,
- 'ignore pydistutils.cfg in your home directory'),
- ]
+ ]
# 'common_usage' is a short (2-3 line) string describing the common
# usage of the setup script.
@@ -116,8 +107,7 @@ Common commands: (see '--help-commands' for more)
('obsoletes', None,
"print the list of packages/modules made obsolete")
]
- display_option_names = map(lambda x: translate_longopt(x[0]),
- display_options)
+ display_option_names = [translate_longopt(x[0]) for x in display_options]
# negative options are options that exclude other options
negative_opt = {'quiet': 'verbose'}
@@ -268,22 +258,6 @@ Common commands: (see '--help-commands' for more)
else:
sys.stderr.write(msg + "\n")
- # no-user-cfg is handled before other command line args
- # because other args override the config files, and this
- # one is needed before we can load the config files.
- # If attrs['script_args'] wasn't passed, assume false.
- #
- # This also make sure we just look at the global options
- self.want_user_cfg = True
-
- if self.script_args is not None:
- for arg in self.script_args:
- if not arg.startswith('-'):
- break
- if arg == '--no-user-cfg':
- self.want_user_cfg = False
- break
-
self.finalize_options()
def get_option_dict(self, command):
@@ -301,8 +275,7 @@ Common commands: (see '--help-commands' for more)
from pprint import pformat
if commands is None: # dump all command option dicts
- commands = self.command_options.keys()
- commands.sort()
+ commands = sorted(self.command_options.keys())
if header is not None:
self.announce(indent + header)
@@ -336,10 +309,7 @@ Common commands: (see '--help-commands' for more)
Distutils installation directory (ie. where the top-level
Distutils __inst__.py file lives), a file in the user's home
directory named .pydistutils.cfg on Unix and pydistutils.cfg
- on Windows/Mac; and setup.cfg in the current directory.
-
- The file in the user's home directory can be disabled with the
- --no-user-cfg option.
+ on Windows/Mac, and setup.cfg in the current directory.
"""
files = []
check_environ()
@@ -359,23 +329,19 @@ Common commands: (see '--help-commands' for more)
user_filename = "pydistutils.cfg"
# And look for the user config file
- if self.want_user_cfg:
- user_file = os.path.join(os.path.expanduser('~'), user_filename)
- if os.path.isfile(user_file):
- files.append(user_file)
+ user_file = os.path.join(os.path.expanduser('~'), user_filename)
+ if os.path.isfile(user_file):
+ files.append(user_file)
# All platforms support local setup.cfg
local_file = "setup.cfg"
if os.path.isfile(local_file):
files.append(local_file)
- if DEBUG:
- self.announce("using config files: %s" % ', '.join(files))
-
return files
def parse_config_files(self, filenames=None):
- from ConfigParser import ConfigParser
+ from configparser import ConfigParser
if filenames is None:
filenames = self.find_config_files()
@@ -415,8 +381,8 @@ Common commands: (see '--help-commands' for more)
setattr(self, opt, strtobool(val))
else:
setattr(self, opt, val)
- except ValueError, msg:
- raise DistutilsOptionError, msg
+ except ValueError as msg:
+ raise DistutilsOptionError(msg)
# -- Command-line parsing methods ----------------------------------
@@ -482,10 +448,10 @@ Common commands: (see '--help-commands' for more)
# Oops, no commands found -- an end-user error
if not self.commands:
- raise DistutilsArgError, "no commands supplied"
+ raise DistutilsArgError("no commands supplied")
# All is well: return true
- return 1
+ return True
def _get_toplevel_options(self):
"""Return the non-display options recognized at the top level.
@@ -513,7 +479,7 @@ Common commands: (see '--help-commands' for more)
# Pull the current command from the head of the command line
command = args[0]
if not command_re.match(command):
- raise SystemExit, "invalid command name '%s'" % command
+ raise SystemExit("invalid command name '%s'" % command)
self.commands.append(command)
# Dig up the command class that implements this command, so we
@@ -521,23 +487,22 @@ Common commands: (see '--help-commands' for more)
# it takes.
try:
cmd_class = self.get_command_class(command)
- except DistutilsModuleError, msg:
- raise DistutilsArgError, msg
+ except DistutilsModuleError as msg:
+ raise DistutilsArgError(msg)
# Require that the command class be derived from Command -- want
# to be sure that the basic "command" interface is implemented.
if not issubclass(cmd_class, Command):
- raise DistutilsClassError, \
- "command class %s must subclass Command" % cmd_class
+ raise DistutilsClassError(
+ "command class %s must subclass Command" % cmd_class)
# Also make sure that the command object provides a list of its
# known options.
if not (hasattr(cmd_class, 'user_options') and
isinstance(cmd_class.user_options, list)):
- raise DistutilsClassError, \
- ("command class %s must provide " +
+ raise DistutilsClassError(("command class %s must provide " +
"'user_options' attribute (a list of tuples)") % \
- cmd_class
+ cmd_class)
# If the command class has a list of negative alias options,
# merge it in with the global negative aliases.
@@ -572,7 +537,7 @@ Common commands: (see '--help-commands' for more)
for (help_option, short, desc, func) in cmd_class.help_options:
if hasattr(opts, parser.get_attr_name(help_option)):
help_option_found=1
- if hasattr(func, '__call__'):
+ if callable(func):
func()
else:
raise DistutilsClassError(
@@ -739,7 +704,7 @@ Common commands: (see '--help-commands' for more)
"Standard commands",
max_length)
if extra_commands:
- print
+ print()
self.print_command_list(extra_commands,
"Extra commands",
max_length)
@@ -753,7 +718,6 @@ Common commands: (see '--help-commands' for more)
"""
# Currently this is only used on Mac OS, for the Mac-only GUI
# Distutils interface (by Jack Jansen)
-
import distutils.command
std_commands = distutils.command.__all__
is_std = {}
@@ -820,16 +784,15 @@ Common commands: (see '--help-commands' for more)
try:
klass = getattr(module, klass_name)
except AttributeError:
- raise DistutilsModuleError, \
- "invalid command '%s' (no class '%s' in module '%s')" \
- % (command, klass_name, module_name)
+ raise DistutilsModuleError(
+ "invalid command '%s' (no class '%s' in module '%s')"
+ % (command, klass_name, module_name))
self.cmdclass[command] = klass
return klass
raise DistutilsModuleError("invalid command '%s'" % command)
-
def get_command_obj(self, command, create=1):
"""Return the command object for 'command'. Normally this object
is cached on a previous call to 'get_command_obj()'; if no command
@@ -877,7 +840,8 @@ Common commands: (see '--help-commands' for more)
self.announce(" %s = %s (from %s)" % (option, value,
source))
try:
- bool_opts = map(translate_longopt, command_obj.boolean_options)
+ bool_opts = [translate_longopt(o)
+ for o in command_obj.boolean_options]
except AttributeError:
bool_opts = []
try:
@@ -894,11 +858,11 @@ Common commands: (see '--help-commands' for more)
elif hasattr(command_obj, option):
setattr(command_obj, option, value)
else:
- raise DistutilsOptionError, \
- ("error in %s: command '%s' has no such option '%s'"
- % (source, command_name, option))
- except ValueError, msg:
- raise DistutilsOptionError, msg
+ raise DistutilsOptionError(
+ "error in %s: command '%s' has no such option '%s'"
+ % (source, command_name, option))
+ except ValueError as msg:
+ raise DistutilsOptionError(msg)
def reinitialize_command(self, command, reinit_subcommands=0):
"""Reinitializes a command to the state it was in when first
@@ -1023,89 +987,32 @@ class DistributionMetadata:
"provides", "requires", "obsoletes",
)
- def __init__(self, path=None):
- if path is not None:
- self.read_pkg_file(open(path))
- else:
- self.name = None
- self.version = None
- self.author = None
- self.author_email = None
- self.maintainer = None
- self.maintainer_email = None
- self.url = None
- self.license = None
- self.description = None
- self.long_description = None
- self.keywords = None
- self.platforms = None
- self.classifiers = None
- self.download_url = None
- # PEP 314
- self.provides = None
- self.requires = None
- self.obsoletes = None
-
- def read_pkg_file(self, file):
- """Reads the metadata values from a file object."""
- msg = message_from_file(file)
-
- def _read_field(name):
- value = msg[name]
- if value == 'UNKNOWN':
- return None
- return value
-
- def _read_list(name):
- values = msg.get_all(name, None)
- if values == []:
- return None
- return values
-
- metadata_version = msg['metadata-version']
- self.name = _read_field('name')
- self.version = _read_field('version')
- self.description = _read_field('summary')
- # we are filling author only.
- self.author = _read_field('author')
+ def __init__ (self):
+ self.name = None
+ self.version = None
+ self.author = None
+ self.author_email = None
self.maintainer = None
- self.author_email = _read_field('author-email')
self.maintainer_email = None
- self.url = _read_field('home-page')
- self.license = _read_field('license')
-
- if 'download-url' in msg:
- self.download_url = _read_field('download-url')
- else:
- self.download_url = None
-
- self.long_description = _read_field('description')
- self.description = _read_field('summary')
-
- if 'keywords' in msg:
- self.keywords = _read_field('keywords').split(',')
-
- self.platforms = _read_list('platform')
- self.classifiers = _read_list('classifier')
-
- # PEP 314 - these fields only exist in 1.1
- if metadata_version == '1.1':
- self.requires = _read_list('requires')
- self.provides = _read_list('provides')
- self.obsoletes = _read_list('obsoletes')
- else:
- self.requires = None
- self.provides = None
- self.obsoletes = None
+ self.url = None
+ self.license = None
+ self.description = None
+ self.long_description = None
+ self.keywords = None
+ self.platforms = None
+ self.classifiers = None
+ self.download_url = None
+ # PEP 314
+ self.provides = None
+ self.requires = None
+ self.obsoletes = None
def write_pkg_info(self, base_dir):
"""Write the PKG-INFO file into the release tree.
"""
- pkg_info = open(os.path.join(base_dir, 'PKG-INFO'), 'w')
- try:
+ with open(os.path.join(base_dir, 'PKG-INFO'), 'w',
+ encoding='UTF-8') as pkg_info:
self.write_pkg_file(pkg_info)
- finally:
- pkg_info.close()
def write_pkg_file(self, file):
"""Write the PKG-INFO format data to a file object.
@@ -1115,23 +1022,23 @@ class DistributionMetadata:
self.classifiers or self.download_url):
version = '1.1'
- self._write_field(file, 'Metadata-Version', version)
- self._write_field(file, 'Name', self.get_name())
- self._write_field(file, 'Version', self.get_version())
- self._write_field(file, 'Summary', self.get_description())
- self._write_field(file, 'Home-page', self.get_url())
- self._write_field(file, 'Author', self.get_contact())
- self._write_field(file, 'Author-email', self.get_contact_email())
- self._write_field(file, 'License', self.get_license())
+ file.write('Metadata-Version: %s\n' % version)
+ file.write('Name: %s\n' % self.get_name() )
+ file.write('Version: %s\n' % self.get_version() )
+ file.write('Summary: %s\n' % self.get_description() )
+ file.write('Home-page: %s\n' % self.get_url() )
+ file.write('Author: %s\n' % self.get_contact() )
+ file.write('Author-email: %s\n' % self.get_contact_email() )
+ file.write('License: %s\n' % self.get_license() )
if self.download_url:
- self._write_field(file, 'Download-URL', self.download_url)
+ file.write('Download-URL: %s\n' % self.download_url)
long_desc = rfc822_escape(self.get_long_description())
- self._write_field(file, 'Description', long_desc)
+ file.write('Description: %s\n' % long_desc)
keywords = ','.join(self.get_keywords())
if keywords:
- self._write_field(file, 'Keywords', keywords)
+ file.write('Keywords: %s\n' % keywords )
self._write_list(file, 'Platform', self.get_platforms())
self._write_list(file, 'Classifier', self.get_classifiers())
@@ -1141,19 +1048,9 @@ class DistributionMetadata:
self._write_list(file, 'Provides', self.get_provides())
self._write_list(file, 'Obsoletes', self.get_obsoletes())
- def _write_field(self, file, name, value):
- file.write('%s: %s\n' % (name, self._encode_field(value)))
-
- def _write_list (self, file, name, values):
+ def _write_list(self, file, name, values):
for value in values:
- self._write_field(file, name, value)
-
- def _encode_field(self, value):
- if value is None:
- return None
- if isinstance(value, unicode):
- return value.encode(PKG_INFO_ENCODING)
- return str(value)
+ file.write('%s: %s\n' % (name, value))
# -- Metadata query methods ----------------------------------------
@@ -1167,20 +1064,19 @@ class DistributionMetadata:
return "%s-%s" % (self.get_name(), self.get_version())
def get_author(self):
- return self._encode_field(self.author) or "UNKNOWN"
+ return self.author or "UNKNOWN"
def get_author_email(self):
return self.author_email or "UNKNOWN"
def get_maintainer(self):
- return self._encode_field(self.maintainer) or "UNKNOWN"
+ return self.maintainer or "UNKNOWN"
def get_maintainer_email(self):
return self.maintainer_email or "UNKNOWN"
def get_contact(self):
- return (self._encode_field(self.maintainer) or
- self._encode_field(self.author) or "UNKNOWN")
+ return self.maintainer or self.author or "UNKNOWN"
def get_contact_email(self):
return self.maintainer_email or self.author_email or "UNKNOWN"
@@ -1193,10 +1089,10 @@ class DistributionMetadata:
get_licence = get_license
def get_description(self):
- return self._encode_field(self.description) or "UNKNOWN"
+ return self.description or "UNKNOWN"
def get_long_description(self):
- return self._encode_field(self.long_description) or "UNKNOWN"
+ return self.long_description or "UNKNOWN"
def get_keywords(self):
return self.keywords or []
diff --git a/Lib/distutils/emxccompiler.py b/Lib/distutils/emxccompiler.py
index a0172058a38..3675f8df9c8 100644
--- a/Lib/distutils/emxccompiler.py
+++ b/Lib/distutils/emxccompiler.py
@@ -19,8 +19,6 @@ handles the EMX port of the GNU C compiler to OS/2.
#
# * EMX gcc 2.81/EMX 0.9d fix03
-__revision__ = "$Id$"
-
import os,sys,copy
from distutils.ccompiler import gen_preprocess_options, gen_lib_options
from distutils.unixccompiler import UnixCCompiler
@@ -79,14 +77,14 @@ class EMXCCompiler (UnixCCompiler):
# gcc requires '.rc' compiled to binary ('.res') files !!!
try:
self.spawn(["rc", "-r", src])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
def link (self,
target_desc,
@@ -189,9 +187,8 @@ class EMXCCompiler (UnixCCompiler):
# use normcase to make sure '.rc' is really '.rc' and not '.RC'
(base, ext) = os.path.splitext (os.path.normcase(src_name))
if ext not in (self.src_extensions + ['.rc']):
- raise UnknownFileError, \
- "unknown file type '%s' (from '%s')" % \
- (ext, src_name)
+ raise UnknownFileError("unknown file type '%s' (from '%s')" % \
+ (ext, src_name))
if strip_dir:
base = os.path.basename (base)
if ext == '.rc':
@@ -261,10 +258,9 @@ def check_config_h():
# "pyconfig.h" check -- should probably be renamed...
from distutils import sysconfig
- import string
# if sys.version contains GCC then python was compiled with
# GCC, and the pyconfig.h file should be OK
- if string.find(sys.version,"GCC") >= 0:
+ if sys.version.find("GCC") >= 0:
return (CONFIG_H_OK, "sys.version mentions 'GCC'")
fn = sysconfig.get_config_h_filename()
@@ -277,7 +273,7 @@ def check_config_h():
finally:
f.close()
- except IOError, exc:
+ except IOError as exc:
# if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing
return (CONFIG_H_UNCERTAIN,
@@ -285,7 +281,7 @@ def check_config_h():
else:
# "pyconfig.h" contains an "#ifdef __GNUC__" or something similar
- if string.find(s,"__GNUC__") >= 0:
+ if s.find("__GNUC__") >= 0:
return (CONFIG_H_OK, "'%s' mentions '__GNUC__'" % fn)
else:
return (CONFIG_H_NOTOK, "'%s' does not mention '__GNUC__'" % fn)
@@ -306,7 +302,7 @@ def get_versions():
out_string = out.read()
finally:
out.close()
- result = re.search('(\d+\.\d+\.\d+)',out_string)
+ result = re.search('(\d+\.\d+\.\d+)', out_string, re.ASCII)
if result:
gcc_version = StrictVersion(result.group(1))
else:
diff --git a/Lib/distutils/errors.py b/Lib/distutils/errors.py
index d9c47c761cb..eb13c983e92 100644
--- a/Lib/distutils/errors.py
+++ b/Lib/distutils/errors.py
@@ -8,81 +8,90 @@ usually raised for errors that are obviously the end-user's fault
This module is safe to use in "from ... import *" mode; it only exports
symbols whose names start with "Distutils" and end with "Error"."""
-__revision__ = "$Id$"
-
-class DistutilsError(Exception):
+class DistutilsError (Exception):
"""The root of all Distutils evil."""
+ pass
-class DistutilsModuleError(DistutilsError):
+class DistutilsModuleError (DistutilsError):
"""Unable to load an expected module, or to find an expected class
within some module (in particular, command modules and classes)."""
+ pass
-class DistutilsClassError(DistutilsError):
+class DistutilsClassError (DistutilsError):
"""Some command class (or possibly distribution class, if anyone
feels a need to subclass Distribution) is found not to be holding
up its end of the bargain, ie. implementing some part of the
"command "interface."""
+ pass
-class DistutilsGetoptError(DistutilsError):
+class DistutilsGetoptError (DistutilsError):
"""The option table provided to 'fancy_getopt()' is bogus."""
+ pass
-class DistutilsArgError(DistutilsError):
+class DistutilsArgError (DistutilsError):
"""Raised by fancy_getopt in response to getopt.error -- ie. an
error in the command line usage."""
+ pass
-class DistutilsFileError(DistutilsError):
+class DistutilsFileError (DistutilsError):
"""Any problems in the filesystem: expected file not found, etc.
Typically this is for problems that we detect before IOError or
OSError could be raised."""
+ pass
-class DistutilsOptionError(DistutilsError):
+class DistutilsOptionError (DistutilsError):
"""Syntactic/semantic errors in command options, such as use of
mutually conflicting options, or inconsistent options,
badly-spelled values, etc. No distinction is made between option
values originating in the setup script, the command line, config
files, or what-have-you -- but if we *know* something originated in
the setup script, we'll raise DistutilsSetupError instead."""
+ pass
-class DistutilsSetupError(DistutilsError):
+class DistutilsSetupError (DistutilsError):
"""For errors that can be definitely blamed on the setup script,
such as invalid keyword arguments to 'setup()'."""
+ pass
-class DistutilsPlatformError(DistutilsError):
+class DistutilsPlatformError (DistutilsError):
"""We don't know how to do something on the current platform (but
we do know how to do it on some platform) -- eg. trying to compile
C files on a platform not supported by a CCompiler subclass."""
+ pass
-class DistutilsExecError(DistutilsError):
+class DistutilsExecError (DistutilsError):
"""Any problems executing an external program (such as the C
compiler, when compiling C files)."""
+ pass
-class DistutilsInternalError(DistutilsError):
+class DistutilsInternalError (DistutilsError):
"""Internal inconsistencies or impossibilities (obviously, this
should never be seen if the code is working!)."""
+ pass
-class DistutilsTemplateError(DistutilsError):
+class DistutilsTemplateError (DistutilsError):
"""Syntax error in a file list template."""
class DistutilsByteCompileError(DistutilsError):
"""Byte compile error."""
# Exception classes used by the CCompiler implementation classes
-class CCompilerError(Exception):
+class CCompilerError (Exception):
"""Some compile/link operation failed."""
-class PreprocessError(CCompilerError):
+class PreprocessError (CCompilerError):
"""Failure to preprocess one or more C/C++ files."""
-class CompileError(CCompilerError):
+class CompileError (CCompilerError):
"""Failure to compile one or more C/C++ source files."""
-class LibError(CCompilerError):
+class LibError (CCompilerError):
"""Failure to create a static library from one or more C/C++ object
files."""
-class LinkError(CCompilerError):
+class LinkError (CCompilerError):
"""Failure to link one or more C/C++ object files into an executable
or shared library file."""
-class UnknownFileError(CCompilerError):
+class UnknownFileError (CCompilerError):
"""Attempt to process an unknown file type."""
diff --git a/Lib/distutils/extension.py b/Lib/distutils/extension.py
index 9a67ca8b3ea..a93655af2cf 100644
--- a/Lib/distutils/extension.py
+++ b/Lib/distutils/extension.py
@@ -3,15 +3,9 @@
Provides the Extension class, used to describe C/C++ extension
modules in setup scripts."""
-__revision__ = "$Id$"
-
-import os, string, sys
-from types import *
-
-try:
- import warnings
-except ImportError:
- warnings = None
+import os
+import sys
+import warnings
# This class is really only used by the "build_ext" command, so it might
# make sense to put it in distutils.command.build_ext. However, that
@@ -83,11 +77,14 @@ class Extension:
language : string
extension language (i.e. "c", "c++", "objc"). Will be detected
from the source extensions if not provided.
+ optional : boolean
+ specifies that a build failure in the extension should not abort the
+ build process, but simply not install the failing extension.
"""
# When adding arguments to this constructor, be sure to update
# setup_keywords in core.py.
- def __init__ (self, name, sources,
+ def __init__(self, name, sources,
include_dirs=None,
define_macros=None,
undef_macros=None,
@@ -101,12 +98,14 @@ class Extension:
swig_opts = None,
depends=None,
language=None,
+ optional=None,
**kw # To catch unknown keywords
):
- assert type(name) is StringType, "'name' must be a string"
- assert (type(sources) is ListType and
- map(type, sources) == [StringType]*len(sources)), \
- "'sources' must be a list of strings"
+ if not isinstance(name, str):
+ raise AssertionError("'name' must be a string")
+ if not (isinstance(sources, list) and
+ all(isinstance(v, str) for v in sources)):
+ raise AssertionError("'sources' must be a list of strings")
self.name = name
self.sources = sources
@@ -123,22 +122,20 @@ class Extension:
self.swig_opts = swig_opts or []
self.depends = depends or []
self.language = language
+ self.optional = optional
# If there are unknown keyword options, warn about them
- if len(kw):
- L = kw.keys() ; L.sort()
- L = map(repr, L)
- msg = "Unknown Extension options: " + string.join(L, ', ')
- if warnings is not None:
- warnings.warn(msg)
- else:
- sys.stderr.write(msg + '\n')
-# class Extension
-
-
-def read_setup_file (filename):
- from distutils.sysconfig import \
- parse_makefile, expand_makefile_vars, _variable_rx
+ if len(kw) > 0:
+ options = [repr(option) for option in kw]
+ options = ', '.join(sorted(options))
+ msg = "Unknown Extension options: %s" % options
+ warnings.warn(msg)
+
+def read_setup_file(filename):
+ """Reads a Setup file and returns Extension instances."""
+ from distutils.sysconfig import (parse_makefile, expand_makefile_vars,
+ _variable_rx)
+
from distutils.text_file import TextFile
from distutils.util import split_quoted
@@ -153,21 +150,19 @@ def read_setup_file (filename):
try:
extensions = []
- while 1:
+ while True:
line = file.readline()
if line is None: # eof
break
if _variable_rx.match(line): # VAR=VALUE, handled in first pass
continue
- if line[0] == line[-1] == "*":
- file.warn("'%s' lines not handled yet" % line)
- continue
+ if line[0] == line[-1] == "*":
+ file.warn("'%s' lines not handled yet" % line)
+ continue
- #print "original line: " + line
line = expand_makefile_vars(line, vars)
words = split_quoted(line)
- #print "expanded line: " + line
# NB. this parses a slightly different syntax than the old
# makesetup script: here, there must be exactly one extension per
@@ -196,7 +191,7 @@ def read_setup_file (filename):
elif switch == "-I":
ext.include_dirs.append(value)
elif switch == "-D":
- equals = string.find(value, "=")
+ equals = value.find("=")
if equals == -1: # bare "-DFOO" -- no value
ext.define_macros.append((value, None))
else: # "-DFOO=blah"
@@ -222,12 +217,6 @@ def read_setup_file (filename):
ext.extra_link_args.append(word)
if not value:
append_next_word = ext.extra_link_args
- elif word == "-Xcompiler":
- append_next_word = ext.extra_compile_args
- elif switch == "-u":
- ext.extra_link_args.append(word)
- if not value:
- append_next_word = ext.extra_link_args
elif suffix in (".a", ".so", ".sl", ".o", ".dylib"):
# NB. a really faithful emulation of makesetup would
# append a .o file to extra_objects only if it
@@ -241,15 +230,4 @@ def read_setup_file (filename):
finally:
file.close()
- #print "module:", module
- #print "source files:", source_files
- #print "cpp args:", cpp_args
- #print "lib args:", library_args
-
- #extensions[module] = { 'sources': source_files,
- # 'cpp_args': cpp_args,
- # 'lib_args': library_args }
-
return extensions
-
-# read_setup_file ()
diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py
index 2dea9480259..7d170dd2773 100644
--- a/Lib/distutils/fancy_getopt.py
+++ b/Lib/distutils/fancy_getopt.py
@@ -8,13 +8,9 @@ additional features:
* options set attributes of a passed-in object
"""
-__revision__ = "$Id$"
-
-import sys
-import string
-import re
+import sys, string, re
import getopt
-from distutils.errors import DistutilsGetoptError, DistutilsArgError
+from distutils.errors import *
# Much like command_re in distutils.core, this is close to but not quite
# the same as a Python NAME -- except, in the spirit of most GNU
@@ -28,7 +24,7 @@ neg_alias_re = re.compile("^(%s)=!(%s)$" % (longopt_pat, longopt_pat))
# This is used to translate long options to legitimate Python identifiers
# (for use as attributes of some object).
-longopt_xlate = string.maketrans('-', '_')
+longopt_xlate = str.maketrans('-', '_')
class FancyGetopt:
"""Wrapper around the standard 'getopt()' module that provides some
@@ -42,8 +38,7 @@ class FancyGetopt:
on the command line sets 'verbose' to false
"""
- def __init__ (self, option_table=None):
-
+ def __init__(self, option_table=None):
# The option table is (currently) a list of tuples. The
# tuples may have 3 or four values:
# (long_option, short_option, help_string [, repeatable])
@@ -83,58 +78,51 @@ class FancyGetopt:
# but expands short options, converts aliases, etc.
self.option_order = []
- # __init__ ()
-
-
- def _build_index (self):
+ def _build_index(self):
self.option_index.clear()
for option in self.option_table:
self.option_index[option[0]] = option
- def set_option_table (self, option_table):
+ def set_option_table(self, option_table):
self.option_table = option_table
self._build_index()
- def add_option (self, long_option, short_option=None, help_string=None):
+ def add_option(self, long_option, short_option=None, help_string=None):
if long_option in self.option_index:
- raise DistutilsGetoptError, \
- "option conflict: already an option '%s'" % long_option
+ raise DistutilsGetoptError(
+ "option conflict: already an option '%s'" % long_option)
else:
option = (long_option, short_option, help_string)
self.option_table.append(option)
self.option_index[long_option] = option
-
- def has_option (self, long_option):
+ def has_option(self, long_option):
"""Return true if the option table for this parser has an
option with long name 'long_option'."""
return long_option in self.option_index
- def get_attr_name (self, long_option):
+ def get_attr_name(self, long_option):
"""Translate long option name 'long_option' to the form it
has as an attribute of some object: ie., translate hyphens
to underscores."""
- return string.translate(long_option, longopt_xlate)
-
+ return long_option.translate(longopt_xlate)
- def _check_alias_dict (self, aliases, what):
+ def _check_alias_dict(self, aliases, what):
assert isinstance(aliases, dict)
for (alias, opt) in aliases.items():
if alias not in self.option_index:
- raise DistutilsGetoptError, \
- ("invalid %s '%s': "
- "option '%s' not defined") % (what, alias, alias)
+ raise DistutilsGetoptError(("invalid %s '%s': "
+ "option '%s' not defined") % (what, alias, alias))
if opt not in self.option_index:
- raise DistutilsGetoptError, \
- ("invalid %s '%s': "
- "aliased option '%s' not defined") % (what, alias, opt)
+ raise DistutilsGetoptError(("invalid %s '%s': "
+ "aliased option '%s' not defined") % (what, alias, opt))
- def set_aliases (self, alias):
+ def set_aliases(self, alias):
"""Set the aliases for this option parser."""
self._check_alias_dict(alias, "alias")
self.alias = alias
- def set_negative_aliases (self, negative_alias):
+ def set_negative_aliases(self, negative_alias):
"""Set the negative aliases for this option parser.
'negative_alias' should be a dictionary mapping option names to
option names, both the key and value must already be defined
@@ -142,8 +130,7 @@ class FancyGetopt:
self._check_alias_dict(negative_alias, "negative alias")
self.negative_alias = negative_alias
-
- def _grok_option_table (self):
+ def _grok_option_table(self):
"""Populate the various data structures that keep tabs on the
option table. Called by 'getopt()' before it can do anything
worthwhile.
@@ -162,19 +149,17 @@ class FancyGetopt:
else:
# the option table is part of the code, so simply
# assert that it is correct
- raise ValueError, "invalid option tuple: %r" % (option,)
+ raise ValueError("invalid option tuple: %r" % (option,))
# Type- and value-check the option names
if not isinstance(long, str) or len(long) < 2:
- raise DistutilsGetoptError, \
- ("invalid long option '%s': "
- "must be a string of length >= 2") % long
+ raise DistutilsGetoptError(("invalid long option '%s': "
+ "must be a string of length >= 2") % long)
if (not ((short is None) or
(isinstance(short, str) and len(short) == 1))):
- raise DistutilsGetoptError, \
- ("invalid short option '%s': "
- "must a single character or None") % short
+ raise DistutilsGetoptError("invalid short option '%s': "
+ "must a single character or None" % short)
self.repeat[long] = repeat
self.long_opts.append(long)
@@ -184,54 +169,45 @@ class FancyGetopt:
long = long[0:-1]
self.takes_arg[long] = 1
else:
-
# Is option is a "negative alias" for some other option (eg.
# "quiet" == "!verbose")?
alias_to = self.negative_alias.get(long)
if alias_to is not None:
if self.takes_arg[alias_to]:
- raise DistutilsGetoptError, \
- ("invalid negative alias '%s': "
- "aliased option '%s' takes a value") % \
- (long, alias_to)
+ raise DistutilsGetoptError(
+ "invalid negative alias '%s': "
+ "aliased option '%s' takes a value"
+ % (long, alias_to))
self.long_opts[-1] = long # XXX redundant?!
- self.takes_arg[long] = 0
-
- else:
- self.takes_arg[long] = 0
+ self.takes_arg[long] = 0
# If this is an alias option, make sure its "takes arg" flag is
# the same as the option it's aliased to.
alias_to = self.alias.get(long)
if alias_to is not None:
if self.takes_arg[long] != self.takes_arg[alias_to]:
- raise DistutilsGetoptError, \
- ("invalid alias '%s': inconsistent with "
- "aliased option '%s' (one of them takes a value, "
- "the other doesn't") % (long, alias_to)
-
+ raise DistutilsGetoptError(
+ "invalid alias '%s': inconsistent with "
+ "aliased option '%s' (one of them takes a value, "
+ "the other doesn't"
+ % (long, alias_to))
# Now enforce some bondage on the long option name, so we can
# later translate it to an attribute name on some object. Have
# to do this a bit late to make sure we've removed any trailing
# '='.
if not longopt_re.match(long):
- raise DistutilsGetoptError, \
- ("invalid long option name '%s' " +
- "(must be letters, numbers, hyphens only") % long
+ raise DistutilsGetoptError(
+ "invalid long option name '%s' "
+ "(must be letters, numbers, hyphens only" % long)
self.attr_name[long] = self.get_attr_name(long)
if short:
self.short_opts.append(short)
self.short2long[short[0]] = long
- # for option_table
-
- # _grok_option_table()
-
-
- def getopt (self, args=None, object=None):
+ def getopt(self, args=None, object=None):
"""Parse command-line options in args. Store as attributes on object.
If 'args' is None or not supplied, uses 'sys.argv[1:]'. If
@@ -246,17 +222,17 @@ class FancyGetopt:
args = sys.argv[1:]
if object is None:
object = OptionDummy()
- created_object = 1
+ created_object = True
else:
- created_object = 0
+ created_object = False
self._grok_option_table()
- short_opts = string.join(self.short_opts)
+ short_opts = ' '.join(self.short_opts)
try:
opts, args = getopt.getopt(args, short_opts, self.long_opts)
- except getopt.error, msg:
- raise DistutilsArgError, msg
+ except getopt.error as msg:
+ raise DistutilsArgError(msg)
for opt, val in opts:
if len(opt) == 2 and opt[0] == '-': # it's a short option
@@ -292,21 +268,17 @@ class FancyGetopt:
else:
return args
- # getopt()
-
-
- def get_option_order (self):
+ def get_option_order(self):
"""Returns the list of (option, value) tuples processed by the
previous run of 'getopt()'. Raises RuntimeError if
'getopt()' hasn't been called yet.
"""
if self.option_order is None:
- raise RuntimeError, "'getopt()' hasn't been called yet"
+ raise RuntimeError("'getopt()' hasn't been called yet")
else:
return self.option_order
-
- def generate_help (self, header=None):
+ def generate_help(self, header=None):
"""Generate help text (a list of strings, one per suggested line of
output) from the option table for this FancyGetopt object.
"""
@@ -383,50 +355,41 @@ class FancyGetopt:
for l in text[1:]:
lines.append(big_indent + l)
-
- # for self.option_table
-
return lines
- # generate_help ()
-
- def print_help (self, header=None, file=None):
+ def print_help(self, header=None, file=None):
if file is None:
file = sys.stdout
for line in self.generate_help(header):
file.write(line + "\n")
-# class FancyGetopt
-
-def fancy_getopt (options, negative_opt, object, args):
+def fancy_getopt(options, negative_opt, object, args):
parser = FancyGetopt(options)
parser.set_negative_aliases(negative_opt)
return parser.getopt(args, object)
-WS_TRANS = string.maketrans(string.whitespace, ' ' * len(string.whitespace))
+WS_TRANS = {ord(_wschar) : ' ' for _wschar in string.whitespace}
-def wrap_text (text, width):
+def wrap_text(text, width):
"""wrap_text(text : string, width : int) -> [string]
Split 'text' into multiple lines of no more than 'width' characters
each, and return the list of strings that results.
"""
-
if text is None:
return []
if len(text) <= width:
return [text]
- text = string.expandtabs(text)
- text = string.translate(text, WS_TRANS)
+ text = text.expandtabs()
+ text = text.translate(WS_TRANS)
chunks = re.split(r'( +|-+)', text)
- chunks = filter(None, chunks) # ' - ' results in empty strings
+ chunks = [ch for ch in chunks if ch] # ' - ' results in empty strings
lines = []
while chunks:
-
cur_line = [] # list of chunks (to-be-joined)
cur_len = 0 # length of current line
@@ -443,7 +406,6 @@ def wrap_text (text, width):
break
if chunks: # any chunks left to process?
-
# if the current line is still empty, then we had a single
# chunk that's too big too fit on a line -- so we break
# down and break it up at the line width
@@ -459,9 +421,7 @@ def wrap_text (text, width):
# and store this line in the list-of-all-lines -- as a single
# string, of course!
- lines.append(string.join(cur_line, ''))
-
- # while chunks
+ lines.append(''.join(cur_line))
return lines
@@ -470,15 +430,28 @@ def translate_longopt(opt):
"""Convert a long option name to a valid Python identifier by
changing "-" to "_".
"""
- return string.translate(opt, longopt_xlate)
+ return opt.translate(longopt_xlate)
class OptionDummy:
"""Dummy class just used as a place to hold command-line option
values as instance attributes."""
- def __init__ (self, options=[]):
+ def __init__(self, options=[]):
"""Create a new OptionDummy instance. The attributes listed in
'options' will be initialized to None."""
for opt in options:
setattr(self, opt, None)
+
+
+if __name__ == "__main__":
+ text = """\
+Tra-la-la, supercalifragilisticexpialidocious.
+How *do* you spell that odd word, anyways?
+(Someone ask Mary -- she'll know [or she'll
+say, "How should I know?"].)"""
+
+ for w in (10, 20, 30, 40):
+ print("width: %d" % w)
+ print("\n".join(wrap_text(text, w)))
+ print()
diff --git a/Lib/distutils/file_util.py b/Lib/distutils/file_util.py
index b9f07861335..9bdd14e42e3 100644
--- a/Lib/distutils/file_util.py
+++ b/Lib/distutils/file_util.py
@@ -3,25 +3,22 @@
Utility functions for operating on single files.
"""
-__revision__ = "$Id$"
-
import os
from distutils.errors import DistutilsFileError
from distutils import log
# for generating verbose output in 'copy_file()'
-_copy_action = {None: 'copying',
- 'hard': 'hard linking',
- 'sym': 'symbolically linking'}
+_copy_action = { None: 'copying',
+ 'hard': 'hard linking',
+ 'sym': 'symbolically linking' }
def _copy_file_contents(src, dst, buffer_size=16*1024):
- """Copy the file 'src' to 'dst'.
-
- Both must be filenames. Any error opening either file, reading from
- 'src', or writing to 'dst', raises DistutilsFileError. Data is
- read/written in chunks of 'buffer_size' bytes (default 16k). No attempt
- is made to handle anything apart from regular files.
+ """Copy the file 'src' to 'dst'; both must be filenames. Any error
+ opening either file, reading from 'src', or writing to 'dst', raises
+ DistutilsFileError. Data is read/written in chunks of 'buffer_size'
+ bytes (default 16k). No attempt is made to handle anything apart from
+ regular files.
"""
# Stolen from shutil module in the standard library, but with
# custom error-handling added.
@@ -30,38 +27,37 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
try:
try:
fsrc = open(src, 'rb')
- except os.error, (errno, errstr):
- raise DistutilsFileError("could not open '%s': %s" % (src, errstr))
+ except os.error as e:
+ raise DistutilsFileError("could not open '%s': %s" % (src, e.strerror))
if os.path.exists(dst):
try:
os.unlink(dst)
- except os.error, (errno, errstr):
+ except os.error as e:
raise DistutilsFileError(
- "could not delete '%s': %s" % (dst, errstr))
+ "could not delete '%s': %s" % (dst, e.strerror))
try:
fdst = open(dst, 'wb')
- except os.error, (errno, errstr):
+ except os.error as e:
raise DistutilsFileError(
- "could not create '%s': %s" % (dst, errstr))
+ "could not create '%s': %s" % (dst, e.strerror))
- while 1:
+ while True:
try:
buf = fsrc.read(buffer_size)
- except os.error, (errno, errstr):
+ except os.error as e:
raise DistutilsFileError(
- "could not read from '%s': %s" % (src, errstr))
+ "could not read from '%s': %s" % (src, e.strerror))
if not buf:
break
try:
fdst.write(buf)
- except os.error, (errno, errstr):
+ except os.error as e:
raise DistutilsFileError(
- "could not write to '%s': %s" % (dst, errstr))
-
+ "could not write to '%s': %s" % (dst, e.strerror))
finally:
if fdst:
fdst.close()
@@ -70,16 +66,15 @@ def _copy_file_contents(src, dst, buffer_size=16*1024):
def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
link=None, verbose=1, dry_run=0):
- """Copy a file 'src' to 'dst'.
-
- If 'dst' is a directory, then 'src' is copied there with the same name;
- otherwise, it must be a filename. (If the file exists, it will be
- ruthlessly clobbered.) If 'preserve_mode' is true (the default),
- the file's mode (type and permission bits, or whatever is analogous on
- the current platform) is copied. If 'preserve_times' is true (the
- default), the last-modified and last-access times are copied as well.
- If 'update' is true, 'src' will only be copied if 'dst' does not exist,
- or if 'dst' does exist but is older than 'src'.
+ """Copy a file 'src' to 'dst'. If 'dst' is a directory, then 'src' is
+ copied there with the same name; otherwise, it must be a filename. (If
+ the file exists, it will be ruthlessly clobbered.) If 'preserve_mode'
+ is true (the default), the file's mode (type and permission bits, or
+ whatever is analogous on the current platform) is copied. If
+ 'preserve_times' is true (the default), the last-modified and
+ last-access times are copied as well. If 'update' is true, 'src' will
+ only be copied if 'dst' does not exist, or if 'dst' does exist but is
+ older than 'src'.
'link' allows you to make hard links (os.link) or symbolic links
(os.symlink) instead of copying: set it to "hard" or "sym"; if it is
@@ -117,7 +112,7 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
if update and not newer(src, dst):
if verbose >= 1:
log.debug("not copying %s (output up-to-date)", src)
- return dst, 0
+ return (dst, 0)
try:
action = _copy_action[link]
@@ -135,7 +130,7 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
# If linking (hard or symbolic), use the appropriate system call
# (Unix only, of course, but that's the caller's responsibility)
- if link == 'hard':
+ elif link == 'hard':
if not (os.path.exists(dst) and os.path.samefile(src, dst)):
os.link(src, dst)
elif link == 'sym':
@@ -158,13 +153,15 @@ def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
return (dst, 1)
+
# XXX I suspect this is Unix-specific -- need porting help!
-def move_file (src, dst, verbose=1, dry_run=0):
- """Move a file 'src' to 'dst'.
+def move_file (src, dst,
+ verbose=1,
+ dry_run=0):
- If 'dst' is a directory, the file will be moved into it with the same
- name; otherwise, 'src' is just renamed to 'dst'. Return the new
- full name of the file.
+ """Move a file 'src' to 'dst'. If 'dst' is a directory, the file will
+ be moved into it with the same name; otherwise, 'src' is just renamed
+ to 'dst'. Return the new full name of the file.
Handles cross-device moves on Unix using 'copy_file()'. What about
other systems???
@@ -190,15 +187,16 @@ def move_file (src, dst, verbose=1, dry_run=0):
if not isdir(dirname(dst)):
raise DistutilsFileError(
- "can't move '%s': destination '%s' not a valid path" % \
+ "can't move '%s': destination '%s' not a valid path" %
(src, dst))
- copy_it = 0
+ copy_it = False
try:
os.rename(src, dst)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
if num == errno.EXDEV:
- copy_it = 1
+ copy_it = True
else:
raise DistutilsFileError(
"couldn't move '%s' to '%s': %s" % (src, dst, msg))
@@ -207,15 +205,16 @@ def move_file (src, dst, verbose=1, dry_run=0):
copy_file(src, dst, verbose=verbose)
try:
os.unlink(src)
- except os.error, (num, msg):
+ except os.error as e:
+ (num, msg) = e
try:
os.unlink(dst)
except os.error:
pass
raise DistutilsFileError(
- ("couldn't move '%s' to '%s' by copy/delete: " +
- "delete '%s' failed: %s") %
- (src, dst, src, msg))
+ "couldn't move '%s' to '%s' by copy/delete: "
+ "delete '%s' failed: %s"
+ % (src, dst, src, msg))
return dst
diff --git a/Lib/distutils/filelist.py b/Lib/distutils/filelist.py
index 2f1c457ea0b..db3f7a96802 100644
--- a/Lib/distutils/filelist.py
+++ b/Lib/distutils/filelist.py
@@ -4,8 +4,6 @@ Provides the FileList class, used for poking about the filesystem
and building lists of files.
"""
-__revision__ = "$Id$"
-
import os, re
import fnmatch
from distutils.util import convert_path
@@ -45,7 +43,7 @@ class FileList:
"""
from distutils.debug import DEBUG
if DEBUG:
- print msg
+ print(msg)
# -- List-like methods ---------------------------------------------
@@ -57,8 +55,7 @@ class FileList:
def sort(self):
# Not a strict lexical sort!
- sortable_files = map(os.path.split, self.files)
- sortable_files.sort()
+ sortable_files = sorted(map(os.path.split, self.files))
self.files = []
for sort_tuple in sortable_files:
self.files.append(os.path.join(*sort_tuple))
@@ -84,28 +81,22 @@ class FileList:
if action in ('include', 'exclude',
'global-include', 'global-exclude'):
if len(words) < 2:
- raise DistutilsTemplateError, \
- "'%s' expects <pattern1> <pattern2> ..." % action
-
- patterns = map(convert_path, words[1:])
-
+ raise DistutilsTemplateError(
+ "'%s' expects <pattern1> <pattern2> ..." % action)
+ patterns = [convert_path(w) for w in words[1:]]
elif action in ('recursive-include', 'recursive-exclude'):
if len(words) < 3:
- raise DistutilsTemplateError, \
- "'%s' expects <dir> <pattern1> <pattern2> ..." % action
-
+ raise DistutilsTemplateError(
+ "'%s' expects <dir> <pattern1> <pattern2> ..." % action)
dir = convert_path(words[1])
- patterns = map(convert_path, words[2:])
-
+ patterns = [convert_path(w) for w in words[2:]]
elif action in ('graft', 'prune'):
if len(words) != 2:
- raise DistutilsTemplateError, \
- "'%s' expects a single <dir_pattern>" % action
-
+ raise DistutilsTemplateError(
+ "'%s' expects a single <dir_pattern>" % action)
dir_pattern = convert_path(words[1])
-
else:
- raise DistutilsTemplateError, "unknown action '%s'" % action
+ raise DistutilsTemplateError("unknown action '%s'" % action)
return (action, patterns, dir, dir_pattern)
@@ -115,7 +106,7 @@ class FileList:
# defined: it's the first word of the line. Which of the other
# three are defined depends on the action; it'll be either
# patterns, (dir and patterns), or (dir_pattern).
- action, patterns, dir, dir_pattern = self._parse_template_line(line)
+ (action, patterns, dir, dir_pattern) = self._parse_template_line(line)
# OK, now we know that the action is valid and we have the
# right number of words on the line for that action -- so we
@@ -138,7 +129,7 @@ class FileList:
self.debug_print("global-include " + ' '.join(patterns))
for pattern in patterns:
if not self.include_pattern(pattern, anchor=0):
- log.warn(("warning: no files found matching '%s' " +
+ log.warn(("warning: no files found matching '%s' "
"anywhere in distribution"), pattern)
elif action == 'global-exclude':
@@ -154,7 +145,7 @@ class FileList:
(dir, ' '.join(patterns)))
for pattern in patterns:
if not self.include_pattern(pattern, prefix=dir):
- log.warn(("warning: no files found matching '%s' " +
+ log.warn(("warning: no files found matching '%s' "
"under directory '%s'"),
pattern, dir)
@@ -176,21 +167,21 @@ class FileList:
elif action == 'prune':
self.debug_print("prune " + dir_pattern)
if not self.exclude_pattern(None, prefix=dir_pattern):
- log.warn(("no previously-included directories found " +
+ log.warn(("no previously-included directories found "
"matching '%s'"), dir_pattern)
else:
- raise DistutilsInternalError, \
- "this cannot happen: invalid action '%s'" % action
+ raise DistutilsInternalError(
+ "this cannot happen: invalid action '%s'" % action)
+
# -- Filtering/selection methods -----------------------------------
def include_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
"""Select strings (presumably filenames) from 'self.files' that
- match 'pattern', a Unix-style wildcard (glob) pattern.
-
- Patterns are not quite the same as implemented by the 'fnmatch'
- module: '*' and '?' match non-special characters, where "special"
- is platform-dependent: slash on Unix; colon, slash, and backslash on
+ match 'pattern', a Unix-style wildcard (glob) pattern. Patterns
+ are not quite the same as implemented by the 'fnmatch' module: '*'
+ and '?' match non-special characters, where "special" is platform-
+ dependent: slash on Unix; colon, slash, and backslash on
DOS/Windows; and colon on Mac OS.
If 'anchor' is true (the default), then the pattern match is more
@@ -208,10 +199,10 @@ class FileList:
Selected strings will be added to self.files.
- Return 1 if files are found.
+ Return True if files are found, False otherwise.
"""
# XXX docstring lying about what the special chars are?
- files_found = 0
+ files_found = False
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
self.debug_print("include_pattern: applying regex r'%s'" %
pattern_re.pattern)
@@ -224,20 +215,19 @@ class FileList:
if pattern_re.search(name):
self.debug_print(" adding " + name)
self.files.append(name)
- files_found = 1
-
+ files_found = True
return files_found
- def exclude_pattern(self, pattern, anchor=1, prefix=None, is_regex=0):
+ def exclude_pattern (self, pattern,
+ anchor=1, prefix=None, is_regex=0):
"""Remove strings (presumably filenames) from 'files' that match
- 'pattern'.
-
- Other parameters are the same as for 'include_pattern()', above.
- The list 'self.files' is modified in place. Return 1 if files are
- found.
+ 'pattern'. Other parameters are the same as for
+ 'include_pattern()', above.
+ The list 'self.files' is modified in place.
+ Return True if files are found, False otherwise.
"""
- files_found = 0
+ files_found = False
pattern_re = translate_pattern(pattern, anchor, prefix, is_regex)
self.debug_print("exclude_pattern: applying regex r'%s'" %
pattern_re.pattern)
@@ -245,15 +235,14 @@ class FileList:
if pattern_re.search(self.files[i]):
self.debug_print(" removing " + self.files[i])
del self.files[i]
- files_found = 1
-
+ files_found = True
return files_found
# ----------------------------------------------------------------------
# Utility functions
-def findall(dir = os.curdir):
+def findall(dir=os.curdir):
"""Find all files under 'dir' and return the list of full filenames
(relative to 'dir').
"""
@@ -281,16 +270,14 @@ def findall(dir = os.curdir):
list.append(fullname)
elif S_ISDIR(mode) and not S_ISLNK(mode):
push(fullname)
-
return list
def glob_to_re(pattern):
- """Translate a shell-like glob pattern to a regular expression.
-
- Return a string containing the regex. Differs from
- 'fnmatch.translate()' in that '*' does not match "special characters"
- (which are platform-specific).
+ """Translate a shell-like glob pattern to a regular expression; return
+ a string containing the regex. Differs from 'fnmatch.translate()' in
+ that '*' does not match "special characters" (which are
+ platform-specific).
"""
pattern_re = fnmatch.translate(pattern)
@@ -311,9 +298,7 @@ def glob_to_re(pattern):
def translate_pattern(pattern, anchor=1, prefix=None, is_regex=0):
"""Translate a shell-like wildcard pattern to a compiled regular
- expression.
-
- Return the compiled regex. If 'is_regex' true,
+ expression. Return the compiled regex. If 'is_regex' true,
then 'pattern' is directly compiled to a regex (if it's a string)
or just returned as-is (assumes it's a regex object).
"""
diff --git a/Lib/distutils/log.py b/Lib/distutils/log.py
index 758857081c8..b301a8338c2 100644
--- a/Lib/distutils/log.py
+++ b/Lib/distutils/log.py
@@ -27,6 +27,10 @@ class Log:
stream = sys.stderr
else:
stream = sys.stdout
+ if stream.errors == 'strict':
+ # emulate backslashreplace error handler
+ encoding = stream.encoding
+ msg = msg.encode(encoding, "backslashreplace").decode(encoding)
stream.write('%s\n' % msg)
stream.flush()
diff --git a/Lib/distutils/msvc9compiler.py b/Lib/distutils/msvc9compiler.py
index 7ec9b92a5dc..b3f6ce10a81 100644
--- a/Lib/distutils/msvc9compiler.py
+++ b/Lib/distutils/msvc9compiler.py
@@ -12,30 +12,29 @@ for older versions of VS in distutils.msvccompiler.
# finding DevStudio (through the registry)
# ported to VS2005 and VS 2008 by Christian Heimes
-__revision__ = "$Id$"
-
import os
import subprocess
import sys
import re
-from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
- CompileError, LibError, LinkError)
-from distutils.ccompiler import CCompiler, gen_lib_options
+from distutils.errors import DistutilsExecError, DistutilsPlatformError, \
+ CompileError, LibError, LinkError
+from distutils.ccompiler import CCompiler, gen_preprocess_options, \
+ gen_lib_options
from distutils import log
from distutils.util import get_platform
-import _winreg
+import winreg
-RegOpenKeyEx = _winreg.OpenKeyEx
-RegEnumKey = _winreg.EnumKey
-RegEnumValue = _winreg.EnumValue
-RegError = _winreg.error
+RegOpenKeyEx = winreg.OpenKeyEx
+RegEnumKey = winreg.EnumKey
+RegEnumValue = winreg.EnumValue
+RegError = winreg.error
-HKEYS = (_winreg.HKEY_USERS,
- _winreg.HKEY_CURRENT_USER,
- _winreg.HKEY_LOCAL_MACHINE,
- _winreg.HKEY_CLASSES_ROOT)
+HKEYS = (winreg.HKEY_USERS,
+ winreg.HKEY_CURRENT_USER,
+ winreg.HKEY_LOCAL_MACHINE,
+ winreg.HKEY_CLASSES_ROOT)
NATIVE_WIN64 = (sys.platform == 'win32' and sys.maxsize > 2**32)
if NATIVE_WIN64:
@@ -43,12 +42,10 @@ if NATIVE_WIN64:
# the corresponding registry branch, if we're running a
# 64-bit Python on Win64
VS_BASE = r"Software\Wow6432Node\Microsoft\VisualStudio\%0.1f"
- VSEXPRESS_BASE = r"Software\Wow6432Node\Microsoft\VCExpress\%0.1f"
WINSDK_BASE = r"Software\Wow6432Node\Microsoft\Microsoft SDKs\Windows"
NET_BASE = r"Software\Wow6432Node\Microsoft\.NETFramework"
else:
VS_BASE = r"Software\Microsoft\VisualStudio\%0.1f"
- VSEXPRESS_BASE = r"Software\Microsoft\VCExpress\%0.1f"
WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows"
NET_BASE = r"Software\Microsoft\.NETFramework"
@@ -227,18 +224,9 @@ def find_vcvarsall(version):
productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
"productdir")
except KeyError:
+ log.debug("Unable to find productdir in registry")
productdir = None
- # trying Express edition
- if productdir is None:
- vsbase = VSEXPRESS_BASE % version
- try:
- productdir = Reg.get_value(r"%s\Setup\VC" % vsbase,
- "productdir")
- except KeyError:
- productdir = None
- log.debug("Unable to find productdir in registry")
-
if not productdir or not os.path.isdir(productdir):
toolskey = "VS%0.f0COMNTOOLS" % version
toolsdir = os.environ.get(toolskey, None)
@@ -382,10 +370,9 @@ class MSVCCompiler(CCompiler) :
vc_env = query_vcvarsall(VERSION, plat_spec)
- # take care to only use strings in the environment.
- self.__paths = vc_env['path'].encode('mbcs').split(os.pathsep)
- os.environ['lib'] = vc_env['lib'].encode('mbcs')
- os.environ['include'] = vc_env['include'].encode('mbcs')
+ self.__paths = vc_env['path'].split(os.pathsep)
+ os.environ['lib'] = vc_env['lib']
+ os.environ['include'] = vc_env['include']
if len(self.__paths) == 0:
raise DistutilsPlatformError("Python was built with %s, "
@@ -504,7 +491,7 @@ class MSVCCompiler(CCompiler) :
try:
self.spawn([self.rc] + pp_opts +
[output_opt] + [input_opt])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError(msg)
continue
elif ext in self._mc_extensions:
@@ -531,7 +518,7 @@ class MSVCCompiler(CCompiler) :
self.spawn([self.rc] +
["/fo" + obj] + [rc_file])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError(msg)
continue
else:
@@ -544,7 +531,7 @@ class MSVCCompiler(CCompiler) :
self.spawn([self.cc] + compile_opts + pp_opts +
[input_opt, output_opt] +
extra_postargs)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise CompileError(msg)
return objects
@@ -569,7 +556,7 @@ class MSVCCompiler(CCompiler) :
pass # XXX what goes here?
try:
self.spawn([self.lib] + lib_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LibError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -650,7 +637,7 @@ class MSVCCompiler(CCompiler) :
self.mkpath(os.path.dirname(output_filename))
try:
self.spawn([self.linker] + ld_args)
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LinkError(msg)
# embed the manifest
@@ -665,7 +652,7 @@ class MSVCCompiler(CCompiler) :
try:
self.spawn(['mt.exe', '-nologo', '-manifest',
mffilename, out_arg])
- except DistutilsExecError, msg:
+ except DistutilsExecError as msg:
raise LinkError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
diff --git a/Lib/distutils/msvccompiler.py b/Lib/distutils/msvccompiler.py
index 0e69fd368ca..81166569619 100644
--- a/Lib/distutils/msvccompiler.py
+++ b/Lib/distutils/msvccompiler.py
@@ -8,45 +8,41 @@ for the Microsoft Visual Studio.
# hacked by Robin Becker and Thomas Heller to do a better job of
# finding DevStudio (through the registry)
-__revision__ = "$Id$"
-
-import sys
-import os
-import string
-
-from distutils.errors import (DistutilsExecError, DistutilsPlatformError,
- CompileError, LibError, LinkError)
-from distutils.ccompiler import CCompiler, gen_lib_options
+import sys, os
+from distutils.errors import \
+ DistutilsExecError, DistutilsPlatformError, \
+ CompileError, LibError, LinkError
+from distutils.ccompiler import \
+ CCompiler, gen_preprocess_options, gen_lib_options
from distutils import log
-_can_read_reg = 0
+_can_read_reg = False
try:
- import _winreg
+ import winreg
- _can_read_reg = 1
- hkey_mod = _winreg
+ _can_read_reg = True
+ hkey_mod = winreg
- RegOpenKeyEx = _winreg.OpenKeyEx
- RegEnumKey = _winreg.EnumKey
- RegEnumValue = _winreg.EnumValue
- RegError = _winreg.error
+ RegOpenKeyEx = winreg.OpenKeyEx
+ RegEnumKey = winreg.EnumKey
+ RegEnumValue = winreg.EnumValue
+ RegError = winreg.error
except ImportError:
try:
import win32api
import win32con
- _can_read_reg = 1
+ _can_read_reg = True
hkey_mod = win32con
RegOpenKeyEx = win32api.RegOpenKeyEx
RegEnumKey = win32api.RegEnumKey
RegEnumValue = win32api.RegEnumValue
RegError = win32api.error
-
except ImportError:
log.info("Warning: Can't read registry to find the "
"necessary compiler setting\n"
- "Make sure that Python modules _winreg, "
+ "Make sure that Python modules winreg, "
"win32api or win32con are installed.")
pass
@@ -58,20 +54,19 @@ if _can_read_reg:
def read_keys(base, key):
"""Return list of registry keys."""
-
try:
handle = RegOpenKeyEx(base, key)
except RegError:
return None
L = []
i = 0
- while 1:
+ while True:
try:
k = RegEnumKey(handle, i)
except RegError:
break
L.append(k)
- i = i + 1
+ i += 1
return L
def read_values(base, key):
@@ -85,27 +80,26 @@ def read_values(base, key):
return None
d = {}
i = 0
- while 1:
+ while True:
try:
name, value, type = RegEnumValue(handle, i)
except RegError:
break
name = name.lower()
d[convert_mbcs(name)] = convert_mbcs(value)
- i = i + 1
+ i += 1
return d
def convert_mbcs(s):
- enc = getattr(s, "encode", None)
- if enc is not None:
+ dec = getattr(s, "decode", None)
+ if dec is not None:
try:
- s = enc("mbcs")
+ s = dec("mbcs")
except UnicodeError:
pass
return s
class MacroExpander:
-
def __init__(self, version):
self.macros = {}
self.load_macros(version)
@@ -128,9 +122,9 @@ class MacroExpander:
self.set_macro("FrameworkSDKDir", net, "sdkinstallrootv1.1")
else:
self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
- except KeyError:
- raise DistutilsPlatformError, \
- ("""Python was built with Visual Studio 2003;
+ except KeyError as exc: #
+ raise DistutilsPlatformError(
+ """Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
@@ -147,7 +141,7 @@ you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
def sub(self, s):
for k, v in self.macros.items():
- s = string.replace(s, k, v)
+ s = s.replace(k, v)
return s
def get_build_version():
@@ -156,9 +150,8 @@ def get_build_version():
For Python 2.3 and up, the version number is included in
sys.version. For earlier versions, assume the compiler is MSVC 6.
"""
-
prefix = "MSC v."
- i = string.find(sys.version, prefix)
+ i = sys.version.find(prefix)
if i == -1:
return 6
i = i + len(prefix)
@@ -180,10 +173,10 @@ def get_build_architecture():
"""
prefix = " bit ("
- i = string.find(sys.version, prefix)
+ i = sys.version.find(prefix)
if i == -1:
return "Intel"
- j = string.find(sys.version, ")", i)
+ j = sys.version.find(")", i)
return sys.version[i+len(prefix):j]
def normalize_and_reduce_paths(paths):
@@ -201,7 +194,7 @@ def normalize_and_reduce_paths(paths):
return reduced_paths
-class MSVCCompiler (CCompiler) :
+class MSVCCompiler(CCompiler) :
"""Concrete class that implements an interface to Microsoft Visual C++,
as defined by the CCompiler abstract class."""
@@ -231,7 +224,7 @@ class MSVCCompiler (CCompiler) :
static_lib_format = shared_lib_format = '%s%s'
exe_extension = '.exe'
- def __init__ (self, verbose=0, dry_run=0, force=0):
+ def __init__(self, verbose=0, dry_run=0, force=0):
CCompiler.__init__ (self, verbose, dry_run, force)
self.__version = get_build_version()
self.__arch = get_build_architecture()
@@ -262,11 +255,11 @@ class MSVCCompiler (CCompiler) :
else:
self.__paths = self.get_msvc_paths("path")
- if len (self.__paths) == 0:
- raise DistutilsPlatformError, \
- ("Python was built with %s, "
+ if len(self.__paths) == 0:
+ raise DistutilsPlatformError("Python was built with %s, "
"and extensions need to be built with the same "
- "version of the compiler, but it isn't installed." % self.__product)
+ "version of the compiler, but it isn't installed."
+ % self.__product)
self.cc = self.find_exe("cl.exe")
self.linker = self.find_exe("link.exe")
@@ -278,12 +271,12 @@ class MSVCCompiler (CCompiler) :
# extend the MSVC path with the current path
try:
- for p in string.split(os.environ['path'], ';'):
+ for p in os.environ['path'].split(';'):
self.__paths.append(p)
except KeyError:
pass
self.__paths = normalize_and_reduce_paths(self.__paths)
- os.environ['path'] = string.join(self.__paths, ';')
+ os.environ['path'] = ";".join(self.__paths)
self.preprocess_options = None
if self.__arch == "Intel":
@@ -313,10 +306,10 @@ class MSVCCompiler (CCompiler) :
# -- Worker methods ------------------------------------------------
- def object_filenames (self,
- source_filenames,
- strip_dir=0,
- output_dir=''):
+ def object_filenames(self,
+ source_filenames,
+ strip_dir=0,
+ output_dir=''):
# Copied from ccompiler.py, extended to return .res as 'object'-file
# for .rc input file
if output_dir is None: output_dir = ''
@@ -343,17 +336,16 @@ class MSVCCompiler (CCompiler) :
base + self.obj_extension))
return obj_names
- # object_filenames ()
-
def compile(self, sources,
output_dir=None, macros=None, include_dirs=None, debug=0,
extra_preargs=None, extra_postargs=None, depends=None):
- if not self.initialized: self.initialize()
- macros, objects, extra_postargs, pp_opts, build = \
- self._setup_compile(output_dir, macros, include_dirs, sources,
- depends, extra_postargs)
+ if not self.initialized:
+ self.initialize()
+ compile_info = self._setup_compile(output_dir, macros, include_dirs,
+ sources, depends, extra_postargs)
+ macros, objects, extra_postargs, pp_opts, build = compile_info
compile_opts = extra_preargs or []
compile_opts.append ('/c')
@@ -382,13 +374,12 @@ class MSVCCompiler (CCompiler) :
input_opt = src
output_opt = "/fo" + obj
try:
- self.spawn ([self.rc] + pp_opts +
- [output_opt] + [input_opt])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ self.spawn([self.rc] + pp_opts +
+ [output_opt] + [input_opt])
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
continue
elif ext in self._mc_extensions:
-
# Compile .MC to .RC file to .RES file.
# * '-h dir' specifies the directory for the
# generated include file
@@ -400,99 +391,95 @@ class MSVCCompiler (CCompiler) :
# we use the source-directory for the include file and
# the build directory for the RC file and message
# resources. This works at least for win32all.
-
- h_dir = os.path.dirname (src)
- rc_dir = os.path.dirname (obj)
+ h_dir = os.path.dirname(src)
+ rc_dir = os.path.dirname(obj)
try:
# first compile .MC to .RC and .H file
- self.spawn ([self.mc] +
- ['-h', h_dir, '-r', rc_dir] + [src])
+ self.spawn([self.mc] +
+ ['-h', h_dir, '-r', rc_dir] + [src])
base, _ = os.path.splitext (os.path.basename (src))
rc_file = os.path.join (rc_dir, base + '.rc')
# then compile .RC to .RES file
- self.spawn ([self.rc] +
- ["/fo" + obj] + [rc_file])
+ self.spawn([self.rc] +
+ ["/fo" + obj] + [rc_file])
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
continue
else:
# how to handle this file?
- raise CompileError (
- "Don't know how to compile %s to %s" % \
- (src, obj))
+ raise CompileError("Don't know how to compile %s to %s"
+ % (src, obj))
output_opt = "/Fo" + obj
try:
- self.spawn ([self.cc] + compile_opts + pp_opts +
- [input_opt, output_opt] +
- extra_postargs)
- except DistutilsExecError, msg:
- raise CompileError, msg
+ self.spawn([self.cc] + compile_opts + pp_opts +
+ [input_opt, output_opt] +
+ extra_postargs)
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
return objects
- # compile ()
-
- def create_static_lib (self,
- objects,
- output_libname,
- output_dir=None,
- debug=0,
- target_lang=None):
+ def create_static_lib(self,
+ objects,
+ output_libname,
+ output_dir=None,
+ debug=0,
+ target_lang=None):
- if not self.initialized: self.initialize()
- (objects, output_dir) = self._fix_object_args (objects, output_dir)
- output_filename = \
- self.library_filename (output_libname, output_dir=output_dir)
+ if not self.initialized:
+ self.initialize()
+ (objects, output_dir) = self._fix_object_args(objects, output_dir)
+ output_filename = self.library_filename(output_libname,
+ output_dir=output_dir)
- if self._need_link (objects, output_filename):
+ if self._need_link(objects, output_filename):
lib_args = objects + ['/OUT:' + output_filename]
if debug:
- pass # XXX what goes here?
+ pass # XXX what goes here?
try:
- self.spawn ([self.lib] + lib_args)
- except DistutilsExecError, msg:
- raise LibError, msg
-
+ self.spawn([self.lib] + lib_args)
+ except DistutilsExecError as msg:
+ raise LibError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
- # create_static_lib ()
-
- def link (self,
- target_desc,
- objects,
- output_filename,
- output_dir=None,
- libraries=None,
- library_dirs=None,
- runtime_library_dirs=None,
- export_symbols=None,
- debug=0,
- extra_preargs=None,
- extra_postargs=None,
- build_temp=None,
- target_lang=None):
-
- if not self.initialized: self.initialize()
- (objects, output_dir) = self._fix_object_args (objects, output_dir)
- (libraries, library_dirs, runtime_library_dirs) = \
- self._fix_lib_args (libraries, library_dirs, runtime_library_dirs)
+
+ def link(self,
+ target_desc,
+ objects,
+ output_filename,
+ output_dir=None,
+ libraries=None,
+ library_dirs=None,
+ runtime_library_dirs=None,
+ export_symbols=None,
+ debug=0,
+ extra_preargs=None,
+ extra_postargs=None,
+ build_temp=None,
+ target_lang=None):
+
+ if not self.initialized:
+ self.initialize()
+ (objects, output_dir) = self._fix_object_args(objects, output_dir)
+ fixed_args = self._fix_lib_args(libraries, library_dirs,
+ runtime_library_dirs)
+ (libraries, library_dirs, runtime_library_dirs) = fixed_args
if runtime_library_dirs:
self.warn ("I don't know what to do with 'runtime_library_dirs': "
+ str (runtime_library_dirs))
- lib_opts = gen_lib_options (self,
- library_dirs, runtime_library_dirs,
- libraries)
+ lib_opts = gen_lib_options(self,
+ library_dirs, runtime_library_dirs,
+ libraries)
if output_dir is not None:
- output_filename = os.path.join (output_dir, output_filename)
-
- if self._need_link (objects, output_filename):
+ output_filename = os.path.join(output_dir, output_filename)
+ if self._need_link(objects, output_filename):
if target_desc == CCompiler.EXECUTABLE:
if debug:
ldflags = self.ldflags_shared_debug[1:]
@@ -529,34 +516,32 @@ class MSVCCompiler (CCompiler) :
if extra_postargs:
ld_args.extend(extra_postargs)
- self.mkpath (os.path.dirname (output_filename))
+ self.mkpath(os.path.dirname(output_filename))
try:
- self.spawn ([self.linker] + ld_args)
- except DistutilsExecError, msg:
- raise LinkError, msg
+ self.spawn([self.linker] + ld_args)
+ except DistutilsExecError as msg:
+ raise LinkError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
- # link ()
-
# -- Miscellaneous methods -----------------------------------------
# These are all used by the 'gen_lib_options() function, in
# ccompiler.py.
- def library_dir_option (self, dir):
+ def library_dir_option(self, dir):
return "/LIBPATH:" + dir
- def runtime_library_dir_option (self, dir):
- raise DistutilsPlatformError, \
- "don't know how to set runtime library search path for MSVC++"
+ def runtime_library_dir_option(self, dir):
+ raise DistutilsPlatformError(
+ "don't know how to set runtime library search path for MSVC++")
- def library_option (self, lib):
- return self.library_filename (lib)
+ def library_option(self, lib):
+ return self.library_filename(lib)
- def find_library_file (self, dirs, lib, debug=0):
+ def find_library_file(self, dirs, lib, debug=0):
# Prefer a debugging library if found (and requested), but deal
# with it if we don't have one.
if debug:
@@ -572,8 +557,6 @@ class MSVCCompiler (CCompiler) :
# Oops, didn't find it in *any* of 'dirs'
return None
- # find_library_file ()
-
# Helper methods for using the MSVC registry settings
def find_exe(self, exe):
@@ -585,14 +568,13 @@ class MSVCCompiler (CCompiler) :
absolute path that is known to exist. If none of them work, just
return the original program name, 'exe'.
"""
-
for p in self.__paths:
fn = os.path.join(os.path.abspath(p), exe)
if os.path.isfile(fn):
return fn
# didn't find it; try existing path
- for p in string.split(os.environ['Path'],';'):
+ for p in os.environ['Path'].split(';'):
fn = os.path.join(os.path.abspath(p),exe)
if os.path.isfile(fn):
return fn
@@ -605,7 +587,6 @@ class MSVCCompiler (CCompiler) :
Return a list of strings. The list will be empty if unable to
access the registry or appropriate registry keys not found.
"""
-
if not _can_read_reg:
return []
@@ -621,9 +602,9 @@ class MSVCCompiler (CCompiler) :
d = read_values(base, key)
if d:
if self.__version >= 7:
- return string.split(self.__macros.sub(d[path]), ";")
+ return self.__macros.sub(d[path]).split(";")
else:
- return string.split(d[path], ";")
+ return d[path].split(";")
# MSVC 6 seems to create the registry entries we need only when
# the GUI is run.
if self.__version == 6:
@@ -648,7 +629,7 @@ class MSVCCompiler (CCompiler) :
else:
p = self.get_msvc_paths(name)
if p:
- os.environ[name] = string.join(p, ';')
+ os.environ[name] = ';'.join(p)
if get_build_version() >= 8.0:
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py
index 7306099f6b6..f58c55f9024 100644
--- a/Lib/distutils/spawn.py
+++ b/Lib/distutils/spawn.py
@@ -6,8 +6,6 @@ Also provides the 'find_executable()' to search the path for a given
executable name.
"""
-__revision__ = "$Id$"
-
import sys
import os
@@ -37,8 +35,8 @@ def spawn(cmd, search_path=1, verbose=0, dry_run=0):
elif os.name == 'os2':
_spawn_os2(cmd, search_path, dry_run=dry_run)
else:
- raise DistutilsPlatformError, \
- "don't know how to spawn programs on platform '%s'" % os.name
+ raise DistutilsPlatformError(
+ "don't know how to spawn programs on platform '%s'" % os.name)
def _nt_quote_args(args):
"""Quote command-line arguments for DOS/Windows conventions.
@@ -67,14 +65,14 @@ def _spawn_nt(cmd, search_path=1, verbose=0, dry_run=0):
# spawn for NT requires a full path to the .exe
try:
rc = os.spawnv(os.P_WAIT, executable, cmd)
- except OSError, exc:
+ except OSError as exc:
# this seems to happen when the command isn't found
- raise DistutilsExecError, \
- "command '%s' failed: %s" % (cmd[0], exc[-1])
+ raise DistutilsExecError(
+ "command '%s' failed: %s" % (cmd[0], exc.args[-1]))
if rc != 0:
# and this reflects the command running but failing
- raise DistutilsExecError, \
- "command '%s' failed with exit status %d" % (cmd[0], rc)
+ raise DistutilsExecError(
+ "command '%s' failed with exit status %d" % (cmd[0], rc))
def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
executable = cmd[0]
@@ -86,15 +84,15 @@ def _spawn_os2(cmd, search_path=1, verbose=0, dry_run=0):
# spawnv for OS/2 EMX requires a full path to the .exe
try:
rc = os.spawnv(os.P_WAIT, executable, cmd)
- except OSError, exc:
+ except OSError as exc:
# this seems to happen when the command isn't found
- raise DistutilsExecError, \
- "command '%s' failed: %s" % (cmd[0], exc[-1])
+ raise DistutilsExecError(
+ "command '%s' failed: %s" % (cmd[0], exc.args[-1]))
if rc != 0:
# and this reflects the command running but failing
log.debug("command '%s' failed with exit status %d" % (cmd[0], rc))
- raise DistutilsExecError, \
- "command '%s' failed with exit status %d" % (cmd[0], rc)
+ raise DistutilsExecError(
+ "command '%s' failed with exit status %d" % (cmd[0], rc))
if sys.platform == 'darwin':
from distutils import sysconfig
@@ -129,50 +127,46 @@ def _spawn_posix(cmd, search_path=1, verbose=0, dry_run=0):
exec_fn = search_path and os.execvpe or os.execve
exec_args.append(env)
pid = os.fork()
-
- if pid == 0: # in the child
+ if pid == 0: # in the child
try:
exec_fn(*exec_args)
- except OSError, e:
- sys.stderr.write("unable to execute %s: %s\n" %
- (cmd[0], e.strerror))
+ except OSError as e:
+ sys.stderr.write("unable to execute %s: %s\n"
+ % (cmd[0], e.strerror))
os._exit(1)
sys.stderr.write("unable to execute %s for unknown reasons" % cmd[0])
os._exit(1)
- else: # in the parent
+ else: # in the parent
# Loop until the child either exits or is terminated by a signal
# (ie. keep waiting if it's merely stopped)
- while 1:
+ while True:
try:
pid, status = os.waitpid(pid, 0)
- except OSError, exc:
+ except OSError as exc:
import errno
if exc.errno == errno.EINTR:
continue
- raise DistutilsExecError, \
- "command '%s' failed: %s" % (cmd[0], exc[-1])
+ raise DistutilsExecError(
+ "command '%s' failed: %s" % (cmd[0], exc.args[-1]))
if os.WIFSIGNALED(status):
- raise DistutilsExecError, \
- "command '%s' terminated by signal %d" % \
- (cmd[0], os.WTERMSIG(status))
-
+ raise DistutilsExecError(
+ "command '%s' terminated by signal %d"
+ % (cmd[0], os.WTERMSIG(status)))
elif os.WIFEXITED(status):
exit_status = os.WEXITSTATUS(status)
if exit_status == 0:
return # hey, it succeeded!
else:
- raise DistutilsExecError, \
- "command '%s' failed with exit status %d" % \
- (cmd[0], exit_status)
-
+ raise DistutilsExecError(
+ "command '%s' failed with exit status %d"
+ % (cmd[0], exit_status))
elif os.WIFSTOPPED(status):
continue
-
else:
- raise DistutilsExecError, \
- "unknown error executing '%s': termination status %d" % \
- (cmd[0], status)
+ raise DistutilsExecError(
+ "unknown error executing '%s': termination status %d"
+ % (cmd[0], status))
def find_executable(executable, path=None):
"""Tries to find 'executable' in the directories listed in 'path'.
@@ -182,6 +176,7 @@ def find_executable(executable, path=None):
"""
if path is None:
path = os.environ['PATH']
+
paths = path.split(os.pathsep)
base, ext = os.path.splitext(executable)
diff --git a/Lib/distutils/sysconfig.py b/Lib/distutils/sysconfig.py
index 4b193b2703c..16902ca920a 100644
--- a/Lib/distutils/sysconfig.py
+++ b/Lib/distutils/sysconfig.py
@@ -9,14 +9,11 @@ Written by: Fred L. Drake, Jr.
Email: <fdrake@acm.org>
"""
-__revision__ = "$Id$"
-
import os
import re
-import string
import sys
-from distutils.errors import DistutilsPlatformError
+from .errors import DistutilsPlatformError
# These are needed in a couple of spots, so just compute them once.
PREFIX = os.path.normpath(sys.prefix)
@@ -49,6 +46,17 @@ def _python_build():
return False
python_build = _python_build()
+# Calculate the build qualifier flags if they are defined. Adding the flags
+# to the include and lib directories only makes sense for an installation, not
+# an in-source build.
+build_flags = ''
+try:
+ if not python_build:
+ build_flags = sys.abiflags
+except AttributeError:
+ # It's not a configure-based build, so the sys module doesn't have
+ # this attribute, which is fine.
+ pass
def get_python_version():
"""Return a string containing the major and minor Python version,
@@ -71,21 +79,21 @@ def get_python_inc(plat_specific=0, prefix=None):
"""
if prefix is None:
prefix = plat_specific and EXEC_PREFIX or PREFIX
-
if os.name == "posix":
if python_build:
- buildir = os.path.dirname(sys.executable)
+ # Assume the executable is in the build directory. The
+ # pyconfig.h file should be in the same directory. Since
+ # the build directory may not be the source directory, we
+ # must use "srcdir" from the makefile to find the "Include"
+ # directory.
+ base = os.path.dirname(os.path.abspath(sys.executable))
if plat_specific:
- # python.h is located in the buildir
- inc_dir = buildir
+ return base
else:
- # the source dir is relative to the buildir
- srcdir = os.path.abspath(os.path.join(buildir,
- get_config_var('srcdir')))
- # Include is located in the srcdir
- inc_dir = os.path.join(srcdir, "Include")
- return inc_dir
- return os.path.join(prefix, "include", "python" + get_python_version())
+ incdir = os.path.join(get_config_var('srcdir'), 'Include')
+ return os.path.normpath(incdir)
+ python_dir = 'python' + get_python_version() + build_flags
+ return os.path.join(prefix, "include", python_dir)
elif os.name == "nt":
return os.path.join(prefix, "include")
elif os.name == "os2":
@@ -120,7 +128,6 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
return libpython
else:
return os.path.join(libpython, "site-packages")
-
elif os.name == "nt":
if standard_lib:
return os.path.join(prefix, "Lib")
@@ -129,13 +136,11 @@ def get_python_lib(plat_specific=0, standard_lib=0, prefix=None):
return prefix
else:
return os.path.join(prefix, "Lib", "site-packages")
-
elif os.name == "os2":
if standard_lib:
return os.path.join(prefix, "Lib")
else:
return os.path.join(prefix, "Lib", "site-packages")
-
else:
raise DistutilsPlatformError(
"I don't know where Python installs its library "
@@ -152,8 +157,7 @@ def customize_compiler(compiler):
if compiler.compiler_type == "unix":
(cc, cxx, opt, cflags, ccshared, ldshared, so_ext, ar, ar_flags) = \
get_config_vars('CC', 'CXX', 'OPT', 'CFLAGS',
- 'CCSHARED', 'LDSHARED', 'SO', 'AR',
- 'ARFLAGS')
+ 'CCSHARED', 'LDSHARED', 'SO', 'AR', 'ARFLAGS')
newcc = None
if 'CC' in os.environ:
@@ -245,8 +249,9 @@ def get_makefile_filename():
"""Return full pathname of installed Makefile from the Python build."""
if python_build:
return os.path.join(os.path.dirname(sys.executable), "Makefile")
- lib_dir = get_python_lib(plat_specific=1, standard_lib=1)
- return os.path.join(lib_dir, "config", "Makefile")
+ lib_dir = get_python_lib(plat_specific=0, standard_lib=1)
+ config_file = 'config-{}{}'.format(get_python_version(), build_flags)
+ return os.path.join(lib_dir, config_file, 'Makefile')
def parse_config_h(fp, g=None):
@@ -261,7 +266,7 @@ def parse_config_h(fp, g=None):
define_rx = re.compile("#define ([A-Z][A-Za-z0-9_]+) (.*)\n")
undef_rx = re.compile("/[*] #undef ([A-Z][A-Za-z0-9_]+) [*]/\n")
#
- while 1:
+ while True:
line = fp.readline()
if not line:
break
@@ -292,16 +297,16 @@ def parse_makefile(fn, g=None):
used instead of a new dictionary.
"""
from distutils.text_file import TextFile
- fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1)
+ fp = TextFile(fn, strip_comments=1, skip_blanks=1, join_lines=1, errors="surrogateescape")
if g is None:
g = {}
done = {}
notdone = {}
- while 1:
+ while True:
line = fp.readline()
- if line is None: # eof
+ if line is None: # eof
break
m = _variable_rx.match(line)
if m:
@@ -321,9 +326,15 @@ def parse_makefile(fn, g=None):
else:
done[n] = v
+ # Variables with a 'PY_' prefix in the makefile. These need to
+ # be made available without that prefix through sysconfig.
+ # Special care is needed to ensure that variable expansion works, even
+ # if the expansion uses the name without a prefix.
+ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
+
# do variable interpolation here
while notdone:
- for name in notdone.keys():
+ for name in list(notdone):
value = notdone[name]
m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
if m:
@@ -337,6 +348,16 @@ def parse_makefile(fn, g=None):
elif n in os.environ:
# do it like make: fall back to environment
item = os.environ[n]
+
+ elif n in renamed_variables:
+ if name.startswith('PY_') and name[3:] in renamed_variables:
+ item = ""
+
+ elif 'PY_' + n in notdone:
+ found = False
+
+ else:
+ item = str(done['PY_' + n])
else:
done[n] = item = ""
if found:
@@ -351,6 +372,13 @@ def parse_makefile(fn, g=None):
else:
done[name] = value
del notdone[name]
+
+ if name.startswith('PY_') \
+ and name[3:] in renamed_variables:
+
+ name = name[3:]
+ if name not in done:
+ done[name] = value
else:
# bogus variable reference; just drop it since we can't deal
del notdone[name]
@@ -382,7 +410,7 @@ def expand_makefile_vars(s, vars):
# 'parse_makefile()', which takes care of such expansions eagerly,
# according to make's variable expansion semantics.
- while 1:
+ while True:
m = _findvar1_rx.search(s) or _findvar2_rx.search(s)
if m:
(beg, end) = m.span()
@@ -401,7 +429,7 @@ def _init_posix():
try:
filename = get_makefile_filename()
parse_makefile(filename, g)
- except IOError, msg:
+ except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror
@@ -411,8 +439,9 @@ def _init_posix():
# load the installed pyconfig.h:
try:
filename = get_config_h_filename()
- parse_config_h(file(filename), g)
- except IOError, msg:
+ with open(filename) as file:
+ parse_config_h(file, g)
+ except IOError as msg:
my_msg = "invalid Python installation: unable to open %s" % filename
if hasattr(msg, "strerror"):
my_msg = my_msg + " (%s)" % msg.strerror
@@ -436,24 +465,6 @@ def _init_posix():
g['LDSHARED'] = "%s %s -bI:%s" % (ld_so_aix, g['CC'], python_exp)
- elif sys.platform == 'beos':
- # Linker script is in the config directory. In the Makefile it is
- # relative to the srcdir, which after installation no longer makes
- # sense.
- python_lib = get_python_lib(standard_lib=1)
- linkerscript_path = string.split(g['LDSHARED'])[0]
- linkerscript_name = os.path.basename(linkerscript_path)
- linkerscript = os.path.join(python_lib, 'config',
- linkerscript_name)
-
- # XXX this isn't the right place to do this: adding the Python
- # library to the link, if needed, should be in the "build_ext"
- # command. (It's also needed for non-MS compilers on Windows, and
- # it's taken care of for them by the 'build_ext.get_libraries()'
- # method.)
- g['LDSHARED'] = ("%s -L%s/lib -lpython%s" %
- (linkerscript, PREFIX, get_python_version()))
-
global _config_vars
_config_vars = g
@@ -518,6 +529,20 @@ def get_config_vars(*args):
_config_vars['prefix'] = PREFIX
_config_vars['exec_prefix'] = EXEC_PREFIX
+ # Convert srcdir into an absolute path if it appears necessary.
+ # Normally it is relative to the build directory. However, during
+ # testing, for example, we might be running a non-installed python
+ # from a different directory.
+ if python_build and os.name == "posix":
+ base = os.path.dirname(os.path.abspath(sys.executable))
+ if (not os.path.isabs(_config_vars['srcdir']) and
+ base != os.getcwd()):
+ # srcdir is relative and we are not in the same directory
+ # as the executable. Assume executable is in the build
+ # directory and make srcdir absolute.
+ srcdir = os.path.join(base, _config_vars['srcdir'])
+ _config_vars['srcdir'] = os.path.normpath(srcdir)
+
if sys.platform == 'darwin':
kernel_version = os.uname()[2] # Kernel version (8.4.3)
major_version = int(kernel_version.split('.')[0])
@@ -527,12 +552,12 @@ def get_config_vars(*args):
# are in CFLAGS or LDFLAGS and remove them if they are.
# This is needed when building extensions on a 10.3 system
# using a universal build of python.
- for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
+ for key in ('LDFLAGS', 'BASECFLAGS',
# a number of derived variables. These need to be
# patched up as well.
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
flags = _config_vars[key]
- flags = re.sub('-arch\s+\w+\s', ' ', flags)
+ flags = re.sub('-arch\s+\w+\s', ' ', flags, re.ASCII)
flags = re.sub('-isysroot [^ \t]*', ' ', flags)
_config_vars[key] = flags
@@ -546,7 +571,7 @@ def get_config_vars(*args):
if 'ARCHFLAGS' in os.environ:
arch = os.environ['ARCHFLAGS']
- for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
+ for key in ('LDFLAGS', 'BASECFLAGS',
# a number of derived variables. These need to be
# patched up as well.
'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
@@ -556,29 +581,6 @@ def get_config_vars(*args):
flags = flags + ' ' + arch
_config_vars[key] = flags
- # If we're on OSX 10.5 or later and the user tries to
- # compiles an extension using an SDK that is not present
- # on the current machine it is better to not use an SDK
- # than to fail.
- #
- # The major usecase for this is users using a Python.org
- # binary installer on OSX 10.6: that installer uses
- # the 10.4u SDK, but that SDK is not installed by default
- # when you install Xcode.
- #
- m = re.search('-isysroot\s+(\S+)', _config_vars['CFLAGS'])
- if m is not None:
- sdk = m.group(1)
- if not os.path.exists(sdk):
- for key in ('LDFLAGS', 'BASECFLAGS', 'LDSHARED',
- # a number of derived variables. These need to be
- # patched up as well.
- 'CFLAGS', 'PY_CFLAGS', 'BLDSHARED'):
-
- flags = _config_vars[key]
- flags = re.sub('-isysroot\s+\S+(\s|$)', ' ', flags)
- _config_vars[key] = flags
-
if args:
vals = []
for name in args:
diff --git a/Lib/distutils/tests/__init__.py b/Lib/distutils/tests/__init__.py
index 697ff840456..1b939cbd5db 100644
--- a/Lib/distutils/tests/__init__.py
+++ b/Lib/distutils/tests/__init__.py
@@ -15,7 +15,7 @@ by import rather than matching pre-defined names.
import os
import sys
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
here = os.path.dirname(__file__) or os.curdir
diff --git a/Lib/distutils/tests/setuptools_build_ext.py b/Lib/distutils/tests/setuptools_build_ext.py
deleted file mode 100644
index 21fa9e8f439..00000000000
--- a/Lib/distutils/tests/setuptools_build_ext.py
+++ /dev/null
@@ -1,287 +0,0 @@
-from distutils.command.build_ext import build_ext as _du_build_ext
-try:
- # Attempt to use Pyrex for building extensions, if available
- from Pyrex.Distutils.build_ext import build_ext as _build_ext
-except ImportError:
- _build_ext = _du_build_ext
-
-import os, sys
-from distutils.file_util import copy_file
-
-from distutils.tests.setuptools_extension import Library
-
-from distutils.ccompiler import new_compiler
-from distutils.sysconfig import customize_compiler, get_config_var
-get_config_var("LDSHARED") # make sure _config_vars is initialized
-from distutils.sysconfig import _config_vars
-from distutils import log
-from distutils.errors import *
-
-have_rtld = False
-use_stubs = False
-libtype = 'shared'
-
-if sys.platform == "darwin":
- use_stubs = True
-elif os.name != 'nt':
- try:
- from dl import RTLD_NOW
- have_rtld = True
- use_stubs = True
- except ImportError:
- pass
-
-def if_dl(s):
- if have_rtld:
- return s
- return ''
-
-
-
-
-
-
-class build_ext(_build_ext):
- def run(self):
- """Build extensions in build directory, then copy if --inplace"""
- old_inplace, self.inplace = self.inplace, 0
- _build_ext.run(self)
- self.inplace = old_inplace
- if old_inplace:
- self.copy_extensions_to_source()
-
- def copy_extensions_to_source(self):
- build_py = self.get_finalized_command('build_py')
- for ext in self.extensions:
- fullname = self.get_ext_fullname(ext.name)
- filename = self.get_ext_filename(fullname)
- modpath = fullname.split('.')
- package = '.'.join(modpath[:-1])
- package_dir = build_py.get_package_dir(package)
- dest_filename = os.path.join(package_dir,os.path.basename(filename))
- src_filename = os.path.join(self.build_lib,filename)
-
- # Always copy, even if source is older than destination, to ensure
- # that the right extensions for the current Python/platform are
- # used.
- copy_file(
- src_filename, dest_filename, verbose=self.verbose,
- dry_run=self.dry_run
- )
- if ext._needs_stub:
- self.write_stub(package_dir or os.curdir, ext, True)
-
-
- if _build_ext is not _du_build_ext and not hasattr(_build_ext,'pyrex_sources'):
- # Workaround for problems using some Pyrex versions w/SWIG and/or 2.4
- def swig_sources(self, sources, *otherargs):
- # first do any Pyrex processing
- sources = _build_ext.swig_sources(self, sources) or sources
- # Then do any actual SWIG stuff on the remainder
- return _du_build_ext.swig_sources(self, sources, *otherargs)
-
-
-
- def get_ext_filename(self, fullname):
- filename = _build_ext.get_ext_filename(self,fullname)
- ext = self.ext_map[fullname]
- if isinstance(ext,Library):
- fn, ext = os.path.splitext(filename)
- return self.shlib_compiler.library_filename(fn,libtype)
- elif use_stubs and ext._links_to_dynamic:
- d,fn = os.path.split(filename)
- return os.path.join(d,'dl-'+fn)
- else:
- return filename
-
- def initialize_options(self):
- _build_ext.initialize_options(self)
- self.shlib_compiler = None
- self.shlibs = []
- self.ext_map = {}
-
- def finalize_options(self):
- _build_ext.finalize_options(self)
- self.extensions = self.extensions or []
- self.check_extensions_list(self.extensions)
- self.shlibs = [ext for ext in self.extensions
- if isinstance(ext,Library)]
- if self.shlibs:
- self.setup_shlib_compiler()
- for ext in self.extensions:
- ext._full_name = self.get_ext_fullname(ext.name)
- for ext in self.extensions:
- fullname = ext._full_name
- self.ext_map[fullname] = ext
- ltd = ext._links_to_dynamic = \
- self.shlibs and self.links_to_dynamic(ext) or False
- ext._needs_stub = ltd and use_stubs and not isinstance(ext,Library)
- filename = ext._file_name = self.get_ext_filename(fullname)
- libdir = os.path.dirname(os.path.join(self.build_lib,filename))
- if ltd and libdir not in ext.library_dirs:
- ext.library_dirs.append(libdir)
- if ltd and use_stubs and os.curdir not in ext.runtime_library_dirs:
- ext.runtime_library_dirs.append(os.curdir)
-
- def setup_shlib_compiler(self):
- compiler = self.shlib_compiler = new_compiler(
- compiler=self.compiler, dry_run=self.dry_run, force=self.force
- )
- if sys.platform == "darwin":
- tmp = _config_vars.copy()
- try:
- # XXX Help! I don't have any idea whether these are right...
- _config_vars['LDSHARED'] = "gcc -Wl,-x -dynamiclib -undefined dynamic_lookup"
- _config_vars['CCSHARED'] = " -dynamiclib"
- _config_vars['SO'] = ".dylib"
- customize_compiler(compiler)
- finally:
- _config_vars.clear()
- _config_vars.update(tmp)
- else:
- customize_compiler(compiler)
-
- if self.include_dirs is not None:
- compiler.set_include_dirs(self.include_dirs)
- if self.define is not None:
- # 'define' option is a list of (name,value) tuples
- for (name,value) in self.define:
- compiler.define_macro(name, value)
- if self.undef is not None:
- for macro in self.undef:
- compiler.undefine_macro(macro)
- if self.libraries is not None:
- compiler.set_libraries(self.libraries)
- if self.library_dirs is not None:
- compiler.set_library_dirs(self.library_dirs)
- if self.rpath is not None:
- compiler.set_runtime_library_dirs(self.rpath)
- if self.link_objects is not None:
- compiler.set_link_objects(self.link_objects)
-
- # hack so distutils' build_extension() builds a library instead
- compiler.link_shared_object = link_shared_object.__get__(compiler)
-
-
-
- def get_export_symbols(self, ext):
- if isinstance(ext,Library):
- return ext.export_symbols
- return _build_ext.get_export_symbols(self,ext)
-
- def build_extension(self, ext):
- _compiler = self.compiler
- try:
- if isinstance(ext,Library):
- self.compiler = self.shlib_compiler
- _build_ext.build_extension(self,ext)
- if ext._needs_stub:
- self.write_stub(
- self.get_finalized_command('build_py').build_lib, ext
- )
- finally:
- self.compiler = _compiler
-
- def links_to_dynamic(self, ext):
- """Return true if 'ext' links to a dynamic lib in the same package"""
- # XXX this should check to ensure the lib is actually being built
- # XXX as dynamic, and not just using a locally-found version or a
- # XXX static-compiled version
- libnames = dict.fromkeys([lib._full_name for lib in self.shlibs])
- pkg = '.'.join(ext._full_name.split('.')[:-1]+[''])
- for libname in ext.libraries:
- if pkg+libname in libnames: return True
- return False
-
- def get_outputs(self):
- outputs = _build_ext.get_outputs(self)
- optimize = self.get_finalized_command('build_py').optimize
- for ext in self.extensions:
- if ext._needs_stub:
- base = os.path.join(self.build_lib, *ext._full_name.split('.'))
- outputs.append(base+'.py')
- outputs.append(base+'.pyc')
- if optimize:
- outputs.append(base+'.pyo')
- return outputs
-
- def write_stub(self, output_dir, ext, compile=False):
- log.info("writing stub loader for %s to %s",ext._full_name, output_dir)
- stub_file = os.path.join(output_dir, *ext._full_name.split('.'))+'.py'
- if compile and os.path.exists(stub_file):
- raise DistutilsError(stub_file+" already exists! Please delete.")
- if not self.dry_run:
- f = open(stub_file,'w')
- f.write('\n'.join([
- "def __bootstrap__():",
- " global __bootstrap__, __file__, __loader__",
- " import sys, os, pkg_resources, imp"+if_dl(", dl"),
- " __file__ = pkg_resources.resource_filename(__name__,%r)"
- % os.path.basename(ext._file_name),
- " del __bootstrap__",
- " if '__loader__' in globals():",
- " del __loader__",
- if_dl(" old_flags = sys.getdlopenflags()"),
- " old_dir = os.getcwd()",
- " try:",
- " os.chdir(os.path.dirname(__file__))",
- if_dl(" sys.setdlopenflags(dl.RTLD_NOW)"),
- " imp.load_dynamic(__name__,__file__)",
- " finally:",
- if_dl(" sys.setdlopenflags(old_flags)"),
- " os.chdir(old_dir)",
- "__bootstrap__()",
- "" # terminal \n
- ]))
- f.close()
- if compile:
- from distutils.util import byte_compile
- byte_compile([stub_file], optimize=0,
- force=True, dry_run=self.dry_run)
- optimize = self.get_finalized_command('install_lib').optimize
- if optimize > 0:
- byte_compile([stub_file], optimize=optimize,
- force=True, dry_run=self.dry_run)
- if os.path.exists(stub_file) and not self.dry_run:
- os.unlink(stub_file)
-
-
-if use_stubs or os.name=='nt':
- # Build shared libraries
- #
- def link_shared_object(self, objects, output_libname, output_dir=None,
- libraries=None, library_dirs=None, runtime_library_dirs=None,
- export_symbols=None, debug=0, extra_preargs=None,
- extra_postargs=None, build_temp=None, target_lang=None
- ): self.link(
- self.SHARED_LIBRARY, objects, output_libname,
- output_dir, libraries, library_dirs, runtime_library_dirs,
- export_symbols, debug, extra_preargs, extra_postargs,
- build_temp, target_lang
- )
-else:
- # Build static libraries everywhere else
- libtype = 'static'
-
- def link_shared_object(self, objects, output_libname, output_dir=None,
- libraries=None, library_dirs=None, runtime_library_dirs=None,
- export_symbols=None, debug=0, extra_preargs=None,
- extra_postargs=None, build_temp=None, target_lang=None
- ):
- # XXX we need to either disallow these attrs on Library instances,
- # or warn/abort here if set, or something...
- #libraries=None, library_dirs=None, runtime_library_dirs=None,
- #export_symbols=None, extra_preargs=None, extra_postargs=None,
- #build_temp=None
-
- assert output_dir is None # distutils build_ext doesn't pass this
- output_dir,filename = os.path.split(output_libname)
- basename, ext = os.path.splitext(filename)
- if self.library_filename("x").startswith('lib'):
- # strip 'lib' prefix; this is kludgy if some platform uses
- # a different prefix
- basename = basename[3:]
-
- self.create_static_lib(
- objects, basename, output_dir, debug, target_lang
- )
diff --git a/Lib/distutils/tests/setuptools_extension.py b/Lib/distutils/tests/setuptools_extension.py
deleted file mode 100644
index ec6b690cdb3..00000000000
--- a/Lib/distutils/tests/setuptools_extension.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from distutils.core import Extension as _Extension
-from distutils.core import Distribution as _Distribution
-
-def _get_unpatched(cls):
- """Protect against re-patching the distutils if reloaded
-
- Also ensures that no other distutils extension monkeypatched the distutils
- first.
- """
- while cls.__module__.startswith('setuptools'):
- cls, = cls.__bases__
- if not cls.__module__.startswith('distutils'):
- raise AssertionError(
- "distutils has already been patched by %r" % cls
- )
- return cls
-
-_Distribution = _get_unpatched(_Distribution)
-_Extension = _get_unpatched(_Extension)
-
-try:
- from Pyrex.Distutils.build_ext import build_ext
-except ImportError:
- have_pyrex = False
-else:
- have_pyrex = True
-
-
-class Extension(_Extension):
- """Extension that uses '.c' files in place of '.pyx' files"""
-
- if not have_pyrex:
- # convert .pyx extensions to .c
- def __init__(self,*args,**kw):
- _Extension.__init__(self,*args,**kw)
- sources = []
- for s in self.sources:
- if s.endswith('.pyx'):
- sources.append(s[:-3]+'c')
- else:
- sources.append(s)
- self.sources = sources
-
-class Library(Extension):
- """Just like a regular Extension, but built as a library instead"""
-
-import sys, distutils.core, distutils.extension
-distutils.core.Extension = Extension
-distutils.extension.Extension = Extension
-if 'distutils.command.build_ext' in sys.modules:
- sys.modules['distutils.command.build_ext'].Extension = Extension
diff --git a/Lib/distutils/tests/support.py b/Lib/distutils/tests/support.py
index 4e6058d0ec0..84d92323284 100644
--- a/Lib/distutils/tests/support.py
+++ b/Lib/distutils/tests/support.py
@@ -6,25 +6,16 @@ import tempfile
import unittest
import sysconfig
from copy import deepcopy
-import warnings
from distutils import log
from distutils.log import DEBUG, INFO, WARN, ERROR, FATAL
from distutils.core import Distribution
-def capture_warnings(func):
- def _capture_warnings(*args, **kw):
- with warnings.catch_warnings():
- warnings.simplefilter("ignore")
- return func(*args, **kw)
- return _capture_warnings
-
-
class LoggingSilencer(object):
def setUp(self):
- super(LoggingSilencer, self).setUp()
+ super().setUp()
self.threshold = log.set_threshold(log.FATAL)
# catching warnings
# when log will be replaced by logging
@@ -36,7 +27,7 @@ class LoggingSilencer(object):
def tearDown(self):
log.set_threshold(self.threshold)
log.Log._log = self._old_log
- super(LoggingSilencer, self).tearDown()
+ super().tearDown()
def _log(self, level, msg, args):
if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
@@ -62,7 +53,7 @@ class TempdirManager(object):
"""
def setUp(self):
- super(TempdirManager, self).setUp()
+ super().setUp()
self.old_cwd = os.getcwd()
self.tempdirs = []
@@ -70,7 +61,7 @@ class TempdirManager(object):
# Restore working dir, for Solaris and derivatives, where rmdir()
# on the current directory fails.
os.chdir(self.old_cwd)
- super(TempdirManager, self).tearDown()
+ super().tearDown()
while self.tempdirs:
d = self.tempdirs.pop()
shutil.rmtree(d, os.name in ('nt', 'cygwin'))
@@ -138,7 +129,7 @@ class EnvironGuard(object):
if os.environ.get(key) != value:
os.environ[key] = value
- for key in os.environ.keys():
+ for key in tuple(os.environ.keys()):
if key not in self.old_environ:
del os.environ[key]
@@ -165,8 +156,6 @@ def copy_xxmodule_c(directory):
def _get_xxmodule_path():
- # FIXME when run from regrtest, srcdir seems to be '.', which does not help
- # us find the xxmodule.c file
srcdir = sysconfig.get_config_var('srcdir')
candidates = [
# use installed copy if available
@@ -186,10 +175,9 @@ def _get_xxmodule_path():
def fixup_build_ext(cmd):
"""Function needed to make build_ext tests pass.
- When Python was build with --enable-shared on Unix, -L. is not good
- enough to find the libpython<blah>.so. This is because regrtest runs
- it under a tempdir, not in the top level where the .so lives. By the
- time we've gotten here, Python's already been chdir'd to the tempdir.
+ When Python was built with --enable-shared on Unix, -L. is not enough to
+ find libpython<blah>.so, because regrtest runs in a tempdir, not in the
+ source directory where the .so lives.
When Python was built with in debug mode on Windows, build_ext commands
need their debug attribute set, and it is not done automatically for
diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
index f01cec32632..8edfab49f87 100644
--- a/Lib/distutils/tests/test_archive_util.py
+++ b/Lib/distutils/tests/test_archive_util.py
@@ -1,27 +1,17 @@
-# -*- coding: utf-8 -*-
"""Tests for distutils.archive_util."""
-__revision__ = "$Id$"
-
import unittest
import os
-import sys
import tarfile
from os.path import splitdrive
import warnings
+from distutils import archive_util
from distutils.archive_util import (check_archive_formats, make_tarball,
make_zipfile, make_archive,
ARCHIVE_FORMATS)
from distutils.spawn import find_executable, spawn
from distutils.tests import support
-from test.test_support import check_warnings, run_unittest
-
-try:
- import grp
- import pwd
- UID_GID_SUPPORT = True
-except ImportError:
- UID_GID_SUPPORT = False
+from test.support import check_warnings, run_unittest, patch
try:
import zipfile
@@ -29,34 +19,19 @@ try:
except ImportError:
ZIP_SUPPORT = find_executable('zip')
-# some tests will fail if zlib is not available
try:
import zlib
+ ZLIB_SUPPORT = True
except ImportError:
- zlib = None
-
-def can_fs_encode(filename):
- """
- Return True if the filename can be saved in the file system.
- """
- if os.path.supports_unicode_filenames:
- return True
- try:
- filename.encode(sys.getfilesystemencoding())
- except UnicodeEncodeError:
- return False
- return True
+ ZLIB_SUPPORT = False
class ArchiveUtilTestCase(support.TempdirManager,
support.LoggingSilencer,
unittest.TestCase):
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_make_tarball(self):
- self._make_tarball('archive')
-
- def _make_tarball(self, target_name):
# creating something to tar
tmpdir = self.mkdtemp()
self.write_file([tmpdir, 'file1'], 'xxx')
@@ -66,9 +41,9 @@ class ArchiveUtilTestCase(support.TempdirManager,
tmpdir2 = self.mkdtemp()
unittest.skipUnless(splitdrive(tmpdir)[0] == splitdrive(tmpdir2)[0],
- "source and target should be on same drive")
+ "Source and target should be on same drive")
- base_name = os.path.join(tmpdir2, target_name)
+ base_name = os.path.join(tmpdir2, 'archive')
# working with relative paths to avoid tar warnings
old_dir = os.getcwd()
@@ -83,7 +58,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
self.assertTrue(os.path.exists(tarball))
# trying an uncompressed one
- base_name = os.path.join(tmpdir2, target_name)
+ base_name = os.path.join(tmpdir2, 'archive')
old_dir = os.getcwd()
os.chdir(tmpdir)
try:
@@ -116,9 +91,9 @@ class ArchiveUtilTestCase(support.TempdirManager,
base_name = os.path.join(tmpdir2, 'archive')
return tmpdir, tmpdir2, base_name
- @unittest.skipUnless(zlib, "Requires zlib")
- @unittest.skipUnless(find_executable('tar') and find_executable('gzip'),
- 'Need the tar command to run')
+ @unittest.skipUnless(find_executable('tar') and find_executable('gzip')
+ and ZLIB_SUPPORT,
+ 'Need the tar, gzip and zlib command to run')
def test_tarfile_vs_tar(self):
tmpdir, tmpdir2, base_name = self._create_files()
old_dir = os.getcwd()
@@ -202,8 +177,8 @@ class ArchiveUtilTestCase(support.TempdirManager,
self.assertTrue(not os.path.exists(tarball))
self.assertEqual(len(w.warnings), 1)
- @unittest.skipUnless(zlib, "Requires zlib")
- @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
+ @unittest.skipUnless(ZIP_SUPPORT and ZLIB_SUPPORT,
+ 'Need zip and zlib support to run')
def test_make_zipfile(self):
# creating something to tar
tmpdir = self.mkdtemp()
@@ -216,6 +191,29 @@ class ArchiveUtilTestCase(support.TempdirManager,
# check if the compressed tarball was created
tarball = base_name + '.zip'
+ self.assertTrue(os.path.exists(tarball))
+
+ @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run')
+ def test_make_zipfile_no_zlib(self):
+ patch(self, archive_util.zipfile, 'zlib', None) # force zlib ImportError
+
+ called = []
+ zipfile_class = zipfile.ZipFile
+ def fake_zipfile(*a, **kw):
+ if kw.get('compression', None) == zipfile.ZIP_STORED:
+ called.append((a, kw))
+ return zipfile_class(*a, **kw)
+
+ patch(self, archive_util.zipfile, 'ZipFile', fake_zipfile)
+
+ # create something to tar and compress
+ tmpdir, tmpdir2, base_name = self._create_files()
+ make_zipfile(base_name, tmpdir)
+
+ tarball = base_name + '.zip'
+ self.assertEqual(called,
+ [((tarball, "w"), {'compression': zipfile.ZIP_STORED})])
+ self.assertTrue(os.path.exists(tarball))
def test_check_archive_formats(self):
self.assertEqual(check_archive_formats(['gztar', 'xxx', 'zip']),
@@ -227,59 +225,6 @@ class ArchiveUtilTestCase(support.TempdirManager,
base_name = os.path.join(tmpdir, 'archive')
self.assertRaises(ValueError, make_archive, base_name, 'xxx')
- @unittest.skipUnless(zlib, "Requires zlib")
- def test_make_archive_owner_group(self):
- # testing make_archive with owner and group, with various combinations
- # this works even if there's not gid/uid support
- if UID_GID_SUPPORT:
- group = grp.getgrgid(0)[0]
- owner = pwd.getpwuid(0)[0]
- else:
- group = owner = 'root'
-
- base_dir, root_dir, base_name = self._create_files()
- base_name = os.path.join(self.mkdtemp() , 'archive')
- res = make_archive(base_name, 'zip', root_dir, base_dir, owner=owner,
- group=group)
- self.assertTrue(os.path.exists(res))
-
- res = make_archive(base_name, 'zip', root_dir, base_dir)
- self.assertTrue(os.path.exists(res))
-
- res = make_archive(base_name, 'tar', root_dir, base_dir,
- owner=owner, group=group)
- self.assertTrue(os.path.exists(res))
-
- res = make_archive(base_name, 'tar', root_dir, base_dir,
- owner='kjhkjhkjg', group='oihohoh')
- self.assertTrue(os.path.exists(res))
-
- @unittest.skipUnless(zlib, "Requires zlib")
- @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
- def test_tarfile_root_owner(self):
- tmpdir, tmpdir2, base_name = self._create_files()
- old_dir = os.getcwd()
- os.chdir(tmpdir)
- group = grp.getgrgid(0)[0]
- owner = pwd.getpwuid(0)[0]
- try:
- archive_name = make_tarball(base_name, 'dist', compress=None,
- owner=owner, group=group)
- finally:
- os.chdir(old_dir)
-
- # check if the compressed tarball was created
- self.assertTrue(os.path.exists(archive_name))
-
- # now checks the rights
- archive = tarfile.open(archive_name)
- try:
- for member in archive.getmembers():
- self.assertEqual(member.uid, 0)
- self.assertEqual(member.gid, 0)
- finally:
- archive.close()
-
def test_make_archive_cwd(self):
current_dir = os.getcwd()
def _breaks(*args, **kw):
@@ -294,33 +239,6 @@ class ArchiveUtilTestCase(support.TempdirManager,
finally:
del ARCHIVE_FORMATS['xxx']
- @unittest.skipUnless(zlib, "requires zlib")
- def test_make_tarball_unicode(self):
- """
- Mirror test_make_tarball, except filename is unicode.
- """
- self._make_tarball(u'archive')
-
- @unittest.skipUnless(zlib, "requires zlib")
- @unittest.skipUnless(can_fs_encode(u'Ã¥rchiv'),
- 'File system cannot handle this filename')
- def test_make_tarball_unicode_latin1(self):
- """
- Mirror test_make_tarball, except filename is unicode and contains
- latin characters.
- """
- self._make_tarball(u'Ã¥rchiv') # note this isn't a real word
-
- @unittest.skipUnless(zlib, "requires zlib")
- @unittest.skipUnless(can_fs_encode(u'ã®ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–'),
- 'File system cannot handle this filename')
- def test_make_tarball_unicode_extended(self):
- """
- Mirror test_make_tarball, except filename is unicode and contains
- characters outside the latin charset.
- """
- self._make_tarball(u'ã®ã‚¢ãƒ¼ã‚«ã‚¤ãƒ–') # japanese for archive
-
def test_suite():
return unittest.makeSuite(ArchiveUtilTestCase)
diff --git a/Lib/distutils/tests/test_bdist.py b/Lib/distutils/tests/test_bdist.py
index 121d0992dba..503a6e857df 100644
--- a/Lib/distutils/tests/test_bdist.py
+++ b/Lib/distutils/tests/test_bdist.py
@@ -1,8 +1,7 @@
"""Tests for distutils.command.bdist."""
import os
import unittest
-
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.bdist import bdist
from distutils.tests import support
@@ -34,8 +33,7 @@ class BuildTestCase(support.TempdirManager,
cmd.ensure_finalized()
dist.command_obj['bdist'] = cmd
- names = ['bdist_dumb', 'bdist_wininst']
- # bdist_rpm does not support --skip-build
+ names = ['bdist_dumb', 'bdist_wininst'] # bdist_rpm does not support --skip-build
if os.name == 'nt':
names.append('bdist_msi')
diff --git a/Lib/distutils/tests/test_bdist_dumb.py b/Lib/distutils/tests/test_bdist_dumb.py
index 3378f49ea09..1037d8216ec 100644
--- a/Lib/distutils/tests/test_bdist_dumb.py
+++ b/Lib/distutils/tests/test_bdist_dumb.py
@@ -1,17 +1,11 @@
"""Tests for distutils.command.bdist_dumb."""
import os
+import imp
import sys
import zipfile
import unittest
-from test.test_support import run_unittest
-
-# zlib is not used here, but if it's not available
-# test_simple_built will fail
-try:
- import zlib
-except ImportError:
- zlib = None
+from test.support import run_unittest
from distutils.core import Distribution
from distutils.command.bdist_dumb import bdist_dumb
@@ -26,6 +20,13 @@ setup(name='foo', version='0.1', py_modules=['foo'],
"""
+try:
+ import zlib
+ ZLIB_SUPPORT = True
+except ImportError:
+ ZLIB_SUPPORT = False
+
+
class BuildDumbTestCase(support.TempdirManager,
support.LoggingSilencer,
support.EnvironGuard,
@@ -42,7 +43,7 @@ class BuildDumbTestCase(support.TempdirManager,
sys.argv[:] = self.old_sys_argv[1]
super(BuildDumbTestCase, self).tearDown()
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_simple_built(self):
# let's create a simple package
@@ -88,24 +89,10 @@ class BuildDumbTestCase(support.TempdirManager,
contents = sorted(os.path.basename(fn) for fn in contents)
wanted = ['foo-0.1-py%s.%s.egg-info' % sys.version_info[:2],
- 'foo.py', 'foo.pyc']
+ 'foo.%s.pyc' % imp.get_tag(),
+ 'foo.py']
self.assertEqual(contents, sorted(wanted))
- def test_finalize_options(self):
- pkg_dir, dist = self.create_dist()
- os.chdir(pkg_dir)
- cmd = bdist_dumb(dist)
- self.assertEqual(cmd.bdist_dir, None)
- cmd.finalize_options()
-
- # bdist_dir is initialized to bdist_base/dumb if not set
- base = cmd.get_finalized_command('bdist').bdist_base
- self.assertEqual(cmd.bdist_dir, os.path.join(base, 'dumb'))
-
- # the format is set to a default value depending on the os.name
- default = cmd.default_format[os.name]
- self.assertEqual(cmd.format, default)
-
def test_suite():
return unittest.makeSuite(BuildDumbTestCase)
diff --git a/Lib/distutils/tests/test_bdist_msi.py b/Lib/distutils/tests/test_bdist_msi.py
index f98b7a2199a..15d8bdff2b4 100644
--- a/Lib/distutils/tests/test_bdist_msi.py
+++ b/Lib/distutils/tests/test_bdist_msi.py
@@ -1,7 +1,7 @@
"""Tests for distutils.command.bdist_msi."""
import sys
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_bdist_rpm.py b/Lib/distutils/tests/test_bdist_rpm.py
index 37d89155c7e..ab7a1bf24e7 100644
--- a/Lib/distutils/tests/test_bdist_rpm.py
+++ b/Lib/distutils/tests/test_bdist_rpm.py
@@ -5,8 +5,7 @@ import sys
import os
import tempfile
import shutil
-
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.core import Distribution
from distutils.command.bdist_rpm import bdist_rpm
diff --git a/Lib/distutils/tests/test_bdist_wininst.py b/Lib/distutils/tests/test_bdist_wininst.py
index c2b13b314dc..f9e8f89e21d 100644
--- a/Lib/distutils/tests/test_bdist_wininst.py
+++ b/Lib/distutils/tests/test_bdist_wininst.py
@@ -1,7 +1,6 @@
"""Tests for distutils.command.bdist_wininst."""
import unittest
-
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.bdist_wininst import bdist_wininst
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_build.py b/Lib/distutils/tests/test_build.py
index eeb8d73e14d..3391f36d4bf 100644
--- a/Lib/distutils/tests/test_build.py
+++ b/Lib/distutils/tests/test_build.py
@@ -2,7 +2,7 @@
import unittest
import os
import sys
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.build import build
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_build_clib.py b/Lib/distutils/tests/test_build_clib.py
index bef1bd99536..69bd2bf6241 100644
--- a/Lib/distutils/tests/test_build_clib.py
+++ b/Lib/distutils/tests/test_build_clib.py
@@ -3,7 +3,7 @@ import unittest
import os
import sys
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.build_clib import build_clib
from distutils.errors import DistutilsSetupError
diff --git a/Lib/distutils/tests/test_build_ext.py b/Lib/distutils/tests/test_build_ext.py
index b71cc983bee..090eacfb2c3 100644
--- a/Lib/distutils/tests/test_build_ext.py
+++ b/Lib/distutils/tests/test_build_ext.py
@@ -1,32 +1,36 @@
import sys
import os
-from StringIO import StringIO
+from io import StringIO
import textwrap
-from distutils.core import Extension, Distribution
+from distutils.core import Distribution
from distutils.command.build_ext import build_ext
from distutils import sysconfig
-from distutils.tests import support
-from distutils.errors import (DistutilsSetupError, CompileError,
- DistutilsPlatformError)
+from distutils.tests.support import (TempdirManager, LoggingSilencer,
+ copy_xxmodule_c, fixup_build_ext)
+from distutils.extension import Extension
+from distutils.errors import (
+ CompileError, DistutilsPlatformError, DistutilsSetupError,
+ UnknownFileError)
import unittest
-from test import test_support
+from test import support
# http://bugs.python.org/issue4373
# Don't load the xx module more than once.
ALREADY_TESTED = False
-class BuildExtTestCase(support.TempdirManager,
- support.LoggingSilencer,
+class BuildExtTestCase(TempdirManager,
+ LoggingSilencer,
unittest.TestCase):
def setUp(self):
+ # Create a simple test environment
+ # Note that we're making changes to sys.path
super(BuildExtTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
- self.xx_created = False
+ self.sys_path = sys.path, sys.path[:]
sys.path.append(self.tmp_dir)
- self.addCleanup(sys.path.remove, self.tmp_dir)
if sys.version > "2.6":
import site
self.old_user_base = site.USER_BASE
@@ -34,28 +38,20 @@ class BuildExtTestCase(support.TempdirManager,
from distutils.command import build_ext
build_ext.USER_BASE = site.USER_BASE
- def tearDown(self):
- if self.xx_created:
- test_support.unload('xx')
- # XXX on Windows the test leaves a directory
- # with xx module in TEMP
- super(BuildExtTestCase, self).tearDown()
-
def test_build_ext(self):
global ALREADY_TESTED
- support.copy_xxmodule_c(self.tmp_dir)
- self.xx_created = True
+ copy_xxmodule_c(self.tmp_dir)
xx_c = os.path.join(self.tmp_dir, 'xxmodule.c')
xx_ext = Extension('xx', [xx_c])
dist = Distribution({'name': 'xx', 'ext_modules': [xx_ext]})
dist.package_dir = self.tmp_dir
cmd = build_ext(dist)
- support.fixup_build_ext(cmd)
+ fixup_build_ext(cmd)
cmd.build_lib = self.tmp_dir
cmd.build_temp = self.tmp_dir
old_stdout = sys.stdout
- if not test_support.verbose:
+ if not support.verbose:
# silence compiler output
sys.stdout = StringIO()
try:
@@ -82,6 +78,18 @@ class BuildExtTestCase(support.TempdirManager,
self.assertTrue(isinstance(xx.Null(), xx.Null))
self.assertTrue(isinstance(xx.Str(), xx.Str))
+ def tearDown(self):
+ # Get everything back to normal
+ support.unload('xx')
+ sys.path = self.sys_path[0]
+ sys.path[:] = self.sys_path[1]
+ if sys.version > "2.6":
+ import site
+ site.USER_BASE = self.old_user_base
+ from distutils.command import build_ext
+ build_ext.USER_BASE = self.old_user_base
+ super(BuildExtTestCase, self).tearDown()
+
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
cmd = build_ext(dist)
@@ -113,9 +121,9 @@ class BuildExtTestCase(support.TempdirManager,
cmd = build_ext(dist)
# making sure the user option is there
- options = [name for name, short, label in
+ options = [name for name, short, lable in
cmd.user_options]
- self.assertIn('user', options)
+ self.assertTrue('user' in options)
# setting a value
cmd.user = 1
@@ -126,21 +134,41 @@ class BuildExtTestCase(support.TempdirManager,
os.mkdir(lib)
os.mkdir(incl)
+ # let's run finalize
cmd.ensure_finalized()
- # see if include_dirs and library_dirs were set
+ # see if include_dirs and library_dirs
+ # were set
self.assertIn(lib, cmd.library_dirs)
self.assertIn(lib, cmd.rpath)
self.assertIn(incl, cmd.include_dirs)
+ def test_optional_extension(self):
+
+ # this extension will fail, but let's ignore this failure
+ # with the optional argument.
+ modules = [Extension('foo', ['xxx'], optional=False)]
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
+ cmd = build_ext(dist)
+ cmd.ensure_finalized()
+ self.assertRaises((UnknownFileError, CompileError),
+ cmd.run) # should raise an error
+
+ modules = [Extension('foo', ['xxx'], optional=True)]
+ dist = Distribution({'name': 'xx', 'ext_modules': modules})
+ cmd = build_ext(dist)
+ cmd.ensure_finalized()
+ cmd.run() # should pass
+
def test_finalize_options(self):
# Make sure Python's include directories (for Python.h, pyconfig.h,
# etc.) are in the include search path.
- modules = [Extension('foo', ['xxx'])]
+ modules = [Extension('foo', ['xxx'], optional=False)]
dist = Distribution({'name': 'xx', 'ext_modules': modules})
cmd = build_ext(dist)
cmd.finalize_options()
+ from distutils import sysconfig
py_include = sysconfig.get_python_inc()
self.assertTrue(py_include in cmd.include_dirs)
@@ -202,7 +230,8 @@ class BuildExtTestCase(support.TempdirManager,
cmd.finalize_options()
#'extensions' option must be a list of Extension instances
- self.assertRaises(DistutilsSetupError, cmd.check_extensions_list, 'foo')
+ self.assertRaises(DistutilsSetupError,
+ cmd.check_extensions_list, 'foo')
# each element of 'ext_modules' option must be an
# Extension instance or 2-tuple
@@ -244,7 +273,7 @@ class BuildExtTestCase(support.TempdirManager,
self.assertEqual(exts[0].define_macros, [('1', '2')])
def test_get_source_files(self):
- modules = [Extension('foo', ['xxx'])]
+ modules = [Extension('foo', ['xxx'], optional=False)]
dist = Distribution({'name': 'xx', 'ext_modules': modules})
cmd = build_ext(dist)
cmd.ensure_finalized()
@@ -264,12 +293,12 @@ class BuildExtTestCase(support.TempdirManager,
def test_get_outputs(self):
tmp_dir = self.mkdtemp()
c_file = os.path.join(tmp_dir, 'foo.c')
- self.write_file(c_file, 'void initfoo(void) {};\n')
- ext = Extension('foo', [c_file])
+ self.write_file(c_file, 'void PyInit_foo(void) {}\n')
+ ext = Extension('foo', [c_file], optional=False)
dist = Distribution({'name': 'xx',
'ext_modules': [ext]})
cmd = build_ext(dist)
- support.fixup_build_ext(cmd)
+ fixup_build_ext(cmd)
cmd.ensure_finalized()
self.assertEqual(len(cmd.get_outputs()), 1)
@@ -288,17 +317,17 @@ class BuildExtTestCase(support.TempdirManager,
finally:
os.chdir(old_wd)
self.assertTrue(os.path.exists(so_file))
- self.assertEqual(os.path.splitext(so_file)[-1],
- sysconfig.get_config_var('SO'))
+ so_ext = sysconfig.get_config_var('SO')
+ self.assertTrue(so_file.endswith(so_ext))
so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, other_tmp_dir)
- cmd.compiler = None
+
cmd.inplace = 0
+ cmd.compiler = None
cmd.run()
so_file = cmd.get_outputs()[0]
self.assertTrue(os.path.exists(so_file))
- self.assertEqual(os.path.splitext(so_file)[-1],
- sysconfig.get_config_var('SO'))
+ self.assertTrue(so_file.endswith(so_ext))
so_dir = os.path.dirname(so_file)
self.assertEqual(so_dir, cmd.build_lib)
@@ -326,6 +355,10 @@ class BuildExtTestCase(support.TempdirManager,
def test_ext_fullpath(self):
ext = sysconfig.get_config_vars()['SO']
+ # building lxml.etree inplace
+ #etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
+ #etree_ext = Extension('lxml.etree', [etree_c])
+ #dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
dist = Distribution()
cmd = build_ext(dist)
cmd.inplace = 1
@@ -358,73 +391,6 @@ class BuildExtTestCase(support.TempdirManager,
wanted = os.path.join(curdir, 'twisted', 'runner', 'portmap' + ext)
self.assertEqual(wanted, path)
- def test_build_ext_inplace(self):
- etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
- etree_ext = Extension('lxml.etree', [etree_c])
- dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
- cmd = build_ext(dist)
- cmd.ensure_finalized()
- cmd.inplace = 1
- cmd.distribution.package_dir = {'': 'src'}
- cmd.distribution.packages = ['lxml', 'lxml.html']
- curdir = os.getcwd()
- ext = sysconfig.get_config_var("SO")
- wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
- path = cmd.get_ext_fullpath('lxml.etree')
- self.assertEqual(wanted, path)
-
- def test_setuptools_compat(self):
- import distutils.core, distutils.extension, distutils.command.build_ext
- saved_ext = distutils.extension.Extension
- try:
- # on some platforms, it loads the deprecated "dl" module
- test_support.import_module('setuptools_build_ext', deprecated=True)
-
- # theses import patch Distutils' Extension class
- from setuptools_build_ext import build_ext as setuptools_build_ext
- from setuptools_extension import Extension
-
- etree_c = os.path.join(self.tmp_dir, 'lxml.etree.c')
- etree_ext = Extension('lxml.etree', [etree_c])
- dist = Distribution({'name': 'lxml', 'ext_modules': [etree_ext]})
- cmd = setuptools_build_ext(dist)
- cmd.ensure_finalized()
- cmd.inplace = 1
- cmd.distribution.package_dir = {'': 'src'}
- cmd.distribution.packages = ['lxml', 'lxml.html']
- curdir = os.getcwd()
- ext = sysconfig.get_config_var("SO")
- wanted = os.path.join(curdir, 'src', 'lxml', 'etree' + ext)
- path = cmd.get_ext_fullpath('lxml.etree')
- self.assertEqual(wanted, path)
- finally:
- # restoring Distutils' Extension class otherwise its broken
- distutils.extension.Extension = saved_ext
- distutils.core.Extension = saved_ext
- distutils.command.build_ext.Extension = saved_ext
-
- def test_build_ext_path_with_os_sep(self):
- dist = Distribution({'name': 'UpdateManager'})
- cmd = build_ext(dist)
- cmd.ensure_finalized()
- ext = sysconfig.get_config_var("SO")
- ext_name = os.path.join('UpdateManager', 'fdsend')
- ext_path = cmd.get_ext_fullpath(ext_name)
- wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext)
- self.assertEqual(ext_path, wanted)
-
- def test_build_ext_path_cross_platform(self):
- if sys.platform != 'win32':
- return
- dist = Distribution({'name': 'UpdateManager'})
- cmd = build_ext(dist)
- cmd.ensure_finalized()
- ext = sysconfig.get_config_var("SO")
- # this needs to work even under win32
- ext_name = 'UpdateManager/fdsend'
- ext_path = cmd.get_ext_fullpath(ext_name)
- wanted = os.path.join(cmd.build_lib, 'UpdateManager', 'fdsend' + ext)
- self.assertEqual(ext_path, wanted)
@unittest.skipUnless(sys.platform == 'darwin', 'test only relevant for MacOSX')
def test_deployment_target_default(self):
@@ -498,13 +464,22 @@ class BuildExtTestCase(support.TempdirManager,
cmd.build_temp = self.tmp_dir
try:
- cmd.ensure_finalized()
- cmd.run()
+ old_stdout = sys.stdout
+ if not support.verbose:
+ # silence compiler output
+ sys.stdout = StringIO()
+ try:
+ cmd.ensure_finalized()
+ cmd.run()
+ finally:
+ sys.stdout = old_stdout
+
except CompileError:
self.fail("Wrong deployment target during compilation")
+
def test_suite():
return unittest.makeSuite(BuildExtTestCase)
if __name__ == '__main__':
- test_support.run_unittest(test_suite())
+ support.run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_build_py.py b/Lib/distutils/tests/test_build_py.py
index 6c6ec208aaa..e416edd4a1e 100644
--- a/Lib/distutils/tests/test_build_py.py
+++ b/Lib/distutils/tests/test_build_py.py
@@ -2,7 +2,7 @@
import os
import sys
-import StringIO
+import imp
import unittest
from distutils.command.build_py import build_py
@@ -10,7 +10,7 @@ from distutils.core import Distribution
from distutils.errors import DistutilsFileError
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class BuildPyTestCase(support.TempdirManager,
@@ -53,23 +53,20 @@ class BuildPyTestCase(support.TempdirManager,
# This makes sure the list of outputs includes byte-compiled
# files for Python modules but not for package data files
# (there shouldn't *be* byte-code files for those!).
- #
self.assertEqual(len(cmd.get_outputs()), 3)
pkgdest = os.path.join(destination, "pkg")
files = os.listdir(pkgdest)
+ pycache_dir = os.path.join(pkgdest, "__pycache__")
self.assertIn("__init__.py", files)
self.assertIn("README.txt", files)
- # XXX even with -O, distutils writes pyc, not pyo; bug?
if sys.dont_write_bytecode:
- self.assertNotIn("__init__.pyc", files)
+ self.assertFalse(os.path.exists(pycache_dir))
else:
- self.assertIn("__init__.pyc", files)
+ pyc_files = os.listdir(pycache_dir)
+ self.assertIn("__init__.%s.pyc" % imp.get_tag(), pyc_files)
def test_empty_package_dir(self):
- # See SF 1668596/1720897.
- cwd = os.getcwd()
-
- # create the distribution files.
+ # See bugs #1668596/#1720897
sources = self.mkdtemp()
open(os.path.join(sources, "__init__.py"), "w").close()
@@ -78,30 +75,55 @@ class BuildPyTestCase(support.TempdirManager,
open(os.path.join(testdir, "testfile"), "w").close()
os.chdir(sources)
- old_stdout = sys.stdout
- sys.stdout = StringIO.StringIO()
+ dist = Distribution({"packages": ["pkg"],
+ "package_dir": {"pkg": ""},
+ "package_data": {"pkg": ["doc/*"]}})
+ # script_name need not exist, it just need to be initialized
+ dist.script_name = os.path.join(sources, "setup.py")
+ dist.script_args = ["build"]
+ dist.parse_command_line()
try:
- dist = Distribution({"packages": ["pkg"],
- "package_dir": {"pkg": ""},
- "package_data": {"pkg": ["doc/*"]}})
- # script_name need not exist, it just need to be initialized
- dist.script_name = os.path.join(sources, "setup.py")
- dist.script_args = ["build"]
- dist.parse_command_line()
-
- try:
- dist.run_commands()
- except DistutilsFileError:
- self.fail("failed package_data test when package_dir is ''")
- finally:
- # Restore state.
- os.chdir(cwd)
- sys.stdout = old_stdout
+ dist.run_commands()
+ except DistutilsFileError:
+ self.fail("failed package_data test when package_dir is ''")
+
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ def test_byte_compile(self):
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
+ os.chdir(project_dir)
+ self.write_file('boiledeggs.py', 'import antigravity')
+ cmd = build_py(dist)
+ cmd.compile = 1
+ cmd.build_lib = 'here'
+ cmd.finalize_options()
+ cmd.run()
+
+ found = os.listdir(cmd.build_lib)
+ self.assertEqual(sorted(found), ['__pycache__', 'boiledeggs.py'])
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
+ self.assertEqual(found, ['boiledeggs.%s.pyc' % imp.get_tag()])
+
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ def test_byte_compile_optimized(self):
+ project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
+ os.chdir(project_dir)
+ self.write_file('boiledeggs.py', 'import antigravity')
+ cmd = build_py(dist)
+ cmd.compile = 0
+ cmd.optimize = 1
+ cmd.build_lib = 'here'
+ cmd.finalize_options()
+ cmd.run()
+
+ found = os.listdir(cmd.build_lib)
+ self.assertEqual(sorted(found), ['__pycache__', 'boiledeggs.py'])
+ found = os.listdir(os.path.join(cmd.build_lib, '__pycache__'))
+ self.assertEqual(sorted(found), ['boiledeggs.%s.pyo' % imp.get_tag()])
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
- pkg_dir, dist = self.create_dist()
+ dist = self.create_dist()[1]
cmd = build_py(dist)
cmd.compile = 1
cmd.optimize = 1
@@ -115,6 +137,7 @@ class BuildPyTestCase(support.TempdirManager,
self.assertIn('byte-compiling is disabled', self.logs[0][1])
+
def test_suite():
return unittest.makeSuite(BuildPyTestCase)
diff --git a/Lib/distutils/tests/test_build_scripts.py b/Lib/distutils/tests/test_build_scripts.py
index 4da93cc1405..e3326b85176 100644
--- a/Lib/distutils/tests/test_build_scripts.py
+++ b/Lib/distutils/tests/test_build_scripts.py
@@ -5,10 +5,10 @@ import unittest
from distutils.command.build_scripts import build_scripts
from distutils.core import Distribution
-import sysconfig
+from distutils import sysconfig
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class BuildScriptsTestCase(support.TempdirManager,
@@ -94,12 +94,12 @@ class BuildScriptsTestCase(support.TempdirManager,
# --with-suffix=3`, python is compiled okay but the build scripts
# failed when writing the name of the executable
old = sysconfig.get_config_vars().get('VERSION')
- sysconfig._CONFIG_VARS['VERSION'] = 4
+ sysconfig._config_vars['VERSION'] = 4
try:
cmd.run()
finally:
if old is not None:
- sysconfig._CONFIG_VARS['VERSION'] = old
+ sysconfig._config_vars['VERSION'] = old
built = os.listdir(target)
for name in expected:
diff --git a/Lib/distutils/tests/test_ccompiler.py b/Lib/distutils/tests/test_ccompiler.py
deleted file mode 100644
index 45e477a429e..00000000000
--- a/Lib/distutils/tests/test_ccompiler.py
+++ /dev/null
@@ -1,82 +0,0 @@
-"""Tests for distutils.ccompiler."""
-import os
-import unittest
-from test.test_support import captured_stdout
-
-from distutils.ccompiler import (gen_lib_options, CCompiler,
- get_default_compiler)
-from distutils.sysconfig import customize_compiler
-from distutils import debug
-from distutils.tests import support
-
-class FakeCompiler(object):
- def library_dir_option(self, dir):
- return "-L" + dir
-
- def runtime_library_dir_option(self, dir):
- return ["-cool", "-R" + dir]
-
- def find_library_file(self, dirs, lib, debug=0):
- return 'found'
-
- def library_option(self, lib):
- return "-l" + lib
-
-class CCompilerTestCase(support.EnvironGuard, unittest.TestCase):
-
- def test_gen_lib_options(self):
- compiler = FakeCompiler()
- libdirs = ['lib1', 'lib2']
- runlibdirs = ['runlib1']
- libs = [os.path.join('dir', 'name'), 'name2']
-
- opts = gen_lib_options(compiler, libdirs, runlibdirs, libs)
- wanted = ['-Llib1', '-Llib2', '-cool', '-Rrunlib1', 'found',
- '-lname2']
- self.assertEqual(opts, wanted)
-
- def test_debug_print(self):
-
- class MyCCompiler(CCompiler):
- executables = {}
-
- compiler = MyCCompiler()
- with captured_stdout() as stdout:
- compiler.debug_print('xxx')
- stdout.seek(0)
- self.assertEqual(stdout.read(), '')
-
- debug.DEBUG = True
- try:
- with captured_stdout() as stdout:
- compiler.debug_print('xxx')
- stdout.seek(0)
- self.assertEqual(stdout.read(), 'xxx\n')
- finally:
- debug.DEBUG = False
-
- def test_customize_compiler(self):
-
- # not testing if default compiler is not unix
- if get_default_compiler() != 'unix':
- return
-
- os.environ['AR'] = 'my_ar'
- os.environ['ARFLAGS'] = '-arflags'
-
- # make sure AR gets caught
- class compiler:
- compiler_type = 'unix'
-
- def set_executables(self, **kw):
- self.exes = kw
-
- comp = compiler()
- customize_compiler(comp)
- self.assertEqual(comp.exes['archiver'], 'my_ar -arflags')
-
-def test_suite():
- return unittest.makeSuite(CCompilerTestCase)
-
-if __name__ == "__main__":
- unittest.main(defaultTest="test_suite")
diff --git a/Lib/distutils/tests/test_check.py b/Lib/distutils/tests/test_check.py
index f73342ade85..4de64734c4c 100644
--- a/Lib/distutils/tests/test_check.py
+++ b/Lib/distutils/tests/test_check.py
@@ -1,7 +1,6 @@
-# -*- encoding: utf8 -*-
"""Tests for distutils.command.check."""
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.check import check, HAS_DOCUTILS
from distutils.tests import support
@@ -47,12 +46,12 @@ class CheckTestCase(support.LoggingSilencer,
cmd = self._run(metadata, strict=1)
self.assertEqual(cmd._warnings, 0)
- # now a test with Unicode entries
- metadata = {'url': u'xxx', 'author': u'\u00c9ric',
- 'author_email': u'xxx', u'name': 'xxx',
- 'version': u'xxx',
- 'description': u'Something about esszet \u00df',
- 'long_description': u'More things about esszet \u00df'}
+ # now a test with non-ASCII characters
+ metadata = {'url': 'xxx', 'author': '\u00c9ric',
+ 'author_email': 'xxx', 'name': 'xxx',
+ 'version': 'xxx',
+ 'description': 'Something about esszet \u00df',
+ 'long_description': 'More things about esszet \u00df'}
cmd = self._run(metadata)
self.assertEqual(cmd._warnings, 0)
@@ -91,7 +90,7 @@ class CheckTestCase(support.LoggingSilencer,
**{'strict': 1, 'restructuredtext': 1})
# and non-broken rest, including a non-ASCII character to test #12114
- metadata['long_description'] = u'title\n=====\n\ntest \u00df'
+ metadata['long_description'] = 'title\n=====\n\ntest \u00df'
cmd = self._run(metadata, strict=1, restructuredtext=1)
self.assertEqual(cmd._warnings, 0)
diff --git a/Lib/distutils/tests/test_clean.py b/Lib/distutils/tests/test_clean.py
index 7b988f7f325..eb8958bff5a 100644
--- a/Lib/distutils/tests/test_clean.py
+++ b/Lib/distutils/tests/test_clean.py
@@ -6,7 +6,7 @@ import getpass
from distutils.command.clean import clean
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class cleanTestCase(support.TempdirManager,
support.LoggingSilencer,
diff --git a/Lib/distutils/tests/test_cmd.py b/Lib/distutils/tests/test_cmd.py
index e074099609a..195045cc7b8 100644
--- a/Lib/distutils/tests/test_cmd.py
+++ b/Lib/distutils/tests/test_cmd.py
@@ -1,7 +1,7 @@
"""Tests for distutils.cmd."""
import unittest
import os
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
from distutils.cmd import Command
from distutils.dist import Distribution
diff --git a/Lib/distutils/tests/test_config.py b/Lib/distutils/tests/test_config.py
index cfd096ebc23..525bee9416a 100644
--- a/Lib/distutils/tests/test_config.py
+++ b/Lib/distutils/tests/test_config.py
@@ -3,7 +3,6 @@ import sys
import os
import unittest
import tempfile
-import shutil
from distutils.core import PyPIRCCommand
from distutils.core import Distribution
@@ -11,7 +10,7 @@ from distutils.log import set_threshold
from distutils.log import WARN
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
PYPIRC = """\
[distutils]
@@ -86,8 +85,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
cmd = self._cmd(self.dist)
config = cmd._read_pypirc()
- config = config.items()
- config.sort()
+ config = list(sorted(config.items()))
waited = [('password', 'secret'), ('realm', 'pypi'),
('repository', 'http://pypi.python.org/pypi'),
('server', 'server1'), ('username', 'me')]
@@ -96,8 +94,7 @@ class PyPIRCCommandTestCase(support.TempdirManager,
# old format
self.write_file(self.rc, PYPIRC_OLD)
config = cmd._read_pypirc()
- config = config.items()
- config.sort()
+ config = list(sorted(config.items()))
waited = [('password', 'secret'), ('realm', 'pypi'),
('repository', 'http://pypi.python.org/pypi'),
('server', 'server-login'), ('username', 'tarek')]
diff --git a/Lib/distutils/tests/test_config_cmd.py b/Lib/distutils/tests/test_config_cmd.py
index 2cf3886cb5b..e2e6e4ebaa2 100644
--- a/Lib/distutils/tests/test_config_cmd.py
+++ b/Lib/distutils/tests/test_config_cmd.py
@@ -2,7 +2,7 @@
import unittest
import os
import sys
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils.command.config import dump_file, config
from distutils.tests import support
diff --git a/Lib/distutils/tests/test_core.py b/Lib/distutils/tests/test_core.py
index 0d979bcde9e..41321f7db4e 100644
--- a/Lib/distutils/tests/test_core.py
+++ b/Lib/distutils/tests/test_core.py
@@ -1,12 +1,12 @@
"""Tests for distutils.core."""
-import StringIO
+import io
import distutils.core
import os
import shutil
import sys
-import test.test_support
-from test.test_support import captured_stdout, run_unittest
+import test.support
+from test.support import captured_stdout, run_unittest
import unittest
from distutils.tests import support
@@ -22,7 +22,7 @@ setup()
setup_prints_cwd = """\
import os
-print os.getcwd()
+print(os.getcwd())
from distutils.core import setup
setup()
@@ -45,13 +45,13 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
super(CoreTestCase, self).tearDown()
def cleanup_testfn(self):
- path = test.test_support.TESTFN
+ path = test.support.TESTFN
if os.path.isfile(path):
os.remove(path)
elif os.path.isdir(path):
shutil.rmtree(path)
- def write_setup(self, text, path=test.test_support.TESTFN):
+ def write_setup(self, text, path=test.support.TESTFN):
f = open(path, "w")
try:
f.write(text)
@@ -69,12 +69,12 @@ class CoreTestCase(support.EnvironGuard, unittest.TestCase):
# This tests that the setup script is run with the current directory
# as its own current directory; this was temporarily broken by a
# previous patch when TESTFN did not use the current directory.
- sys.stdout = StringIO.StringIO()
+ sys.stdout = io.StringIO()
cwd = os.getcwd()
# Create a directory and write the setup.py file there:
- os.mkdir(test.test_support.TESTFN)
- setup_py = os.path.join(test.test_support.TESTFN, "setup.py")
+ os.mkdir(test.support.TESTFN)
+ setup_py = os.path.join(test.support.TESTFN, "setup.py")
distutils.core.run_setup(
self.write_setup(setup_prints_cwd, path=setup_py))
diff --git a/Lib/distutils/tests/test_cygwinccompiler.py b/Lib/distutils/tests/test_cygwinccompiler.py
new file mode 100644
index 00000000000..856921679d6
--- /dev/null
+++ b/Lib/distutils/tests/test_cygwinccompiler.py
@@ -0,0 +1,155 @@
+"""Tests for distutils.cygwinccompiler."""
+import unittest
+import sys
+import os
+from io import BytesIO
+import subprocess
+from test.support import run_unittest
+
+from distutils import cygwinccompiler
+from distutils.cygwinccompiler import (CygwinCCompiler, check_config_h,
+ CONFIG_H_OK, CONFIG_H_NOTOK,
+ CONFIG_H_UNCERTAIN, get_versions,
+ get_msvcr)
+from distutils.tests import support
+
+class FakePopen(object):
+ test_class = None
+
+ def __init__(self, cmd, shell, stdout):
+ self.cmd = cmd.split()[0]
+ exes = self.test_class._exes
+ if self.cmd in exes:
+ # issue #6438 in Python 3.x, Popen returns bytes
+ self.stdout = BytesIO(exes[self.cmd])
+ else:
+ self.stdout = os.popen(cmd, 'r')
+
+
+class CygwinCCompilerTestCase(support.TempdirManager,
+ unittest.TestCase):
+
+ def setUp(self):
+ super(CygwinCCompilerTestCase, self).setUp()
+ self.version = sys.version
+ self.python_h = os.path.join(self.mkdtemp(), 'python.h')
+ from distutils import sysconfig
+ self.old_get_config_h_filename = sysconfig.get_config_h_filename
+ sysconfig.get_config_h_filename = self._get_config_h_filename
+ self.old_find_executable = cygwinccompiler.find_executable
+ cygwinccompiler.find_executable = self._find_executable
+ self._exes = {}
+ self.old_popen = cygwinccompiler.Popen
+ FakePopen.test_class = self
+ cygwinccompiler.Popen = FakePopen
+
+ def tearDown(self):
+ sys.version = self.version
+ from distutils import sysconfig
+ sysconfig.get_config_h_filename = self.old_get_config_h_filename
+ cygwinccompiler.find_executable = self.old_find_executable
+ cygwinccompiler.Popen = self.old_popen
+ super(CygwinCCompilerTestCase, self).tearDown()
+
+ def _get_config_h_filename(self):
+ return self.python_h
+
+ def _find_executable(self, name):
+ if name in self._exes:
+ return name
+ return None
+
+ def test_check_config_h(self):
+
+ # check_config_h looks for "GCC" in sys.version first
+ # returns CONFIG_H_OK if found
+ sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) \n[GCC '
+ '4.0.1 (Apple Computer, Inc. build 5370)]')
+
+ self.assertEqual(check_config_h()[0], CONFIG_H_OK)
+
+ # then it tries to see if it can find "__GNUC__" in pyconfig.h
+ sys.version = 'something without the *CC word'
+
+ # if the file doesn't exist it returns CONFIG_H_UNCERTAIN
+ self.assertEqual(check_config_h()[0], CONFIG_H_UNCERTAIN)
+
+ # if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
+ self.write_file(self.python_h, 'xxx')
+ self.assertEqual(check_config_h()[0], CONFIG_H_NOTOK)
+
+ # and CONFIG_H_OK if __GNUC__ is found
+ self.write_file(self.python_h, 'xxx __GNUC__ xxx')
+ self.assertEqual(check_config_h()[0], CONFIG_H_OK)
+
+ def test_get_versions(self):
+
+ # get_versions calls distutils.spawn.find_executable on
+ # 'gcc', 'ld' and 'dllwrap'
+ self.assertEqual(get_versions(), (None, None, None))
+
+ # Let's fake we have 'gcc' and it returns '3.4.5'
+ self._exes['gcc'] = b'gcc (GCC) 3.4.5 (mingw special)\nFSF'
+ res = get_versions()
+ self.assertEqual(str(res[0]), '3.4.5')
+
+ # and let's see what happens when the version
+ # doesn't match the regular expression
+ # (\d+\.\d+(\.\d+)*)
+ self._exes['gcc'] = b'very strange output'
+ res = get_versions()
+ self.assertEqual(res[0], None)
+
+ # same thing for ld
+ self._exes['ld'] = b'GNU ld version 2.17.50 20060824'
+ res = get_versions()
+ self.assertEqual(str(res[1]), '2.17.50')
+ self._exes['ld'] = b'@(#)PROGRAM:ld PROJECT:ld64-77'
+ res = get_versions()
+ self.assertEqual(res[1], None)
+
+ # and dllwrap
+ self._exes['dllwrap'] = b'GNU dllwrap 2.17.50 20060824\nFSF'
+ res = get_versions()
+ self.assertEqual(str(res[2]), '2.17.50')
+ self._exes['dllwrap'] = b'Cheese Wrap'
+ res = get_versions()
+ self.assertEqual(res[2], None)
+
+ def test_get_msvcr(self):
+
+ # none
+ sys.version = ('2.6.1 (r261:67515, Dec 6 2008, 16:42:21) '
+ '\n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]')
+ self.assertEqual(get_msvcr(), None)
+
+ # MSVC 7.0
+ sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
+ '[MSC v.1300 32 bits (Intel)]')
+ self.assertEqual(get_msvcr(), ['msvcr70'])
+
+ # MSVC 7.1
+ sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
+ '[MSC v.1310 32 bits (Intel)]')
+ self.assertEqual(get_msvcr(), ['msvcr71'])
+
+ # VS2005 / MSVC 8.0
+ sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
+ '[MSC v.1400 32 bits (Intel)]')
+ self.assertEqual(get_msvcr(), ['msvcr80'])
+
+ # VS2008 / MSVC 9.0
+ sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
+ '[MSC v.1500 32 bits (Intel)]')
+ self.assertEqual(get_msvcr(), ['msvcr90'])
+
+ # unknown
+ sys.version = ('2.5.1 (r251:54863, Apr 18 2007, 08:51:08) '
+ '[MSC v.1999 32 bits (Intel)]')
+ self.assertRaises(ValueError, get_msvcr)
+
+def test_suite():
+ return unittest.makeSuite(CygwinCCompilerTestCase)
+
+if __name__ == '__main__':
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_dep_util.py b/Lib/distutils/tests/test_dep_util.py
index 751043432ed..3e1c366892d 100644
--- a/Lib/distutils/tests/test_dep_util.py
+++ b/Lib/distutils/tests/test_dep_util.py
@@ -6,7 +6,7 @@ import time
from distutils.dep_util import newer, newer_pairwise, newer_group
from distutils.errors import DistutilsFileError
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class DepUtilTestCase(support.TempdirManager, unittest.TestCase):
diff --git a/Lib/distutils/tests/test_dir_util.py b/Lib/distutils/tests/test_dir_util.py
index d82d9133d04..1589f1297db 100644
--- a/Lib/distutils/tests/test_dir_util.py
+++ b/Lib/distutils/tests/test_dir_util.py
@@ -10,7 +10,7 @@ from distutils.dir_util import (mkpath, remove_tree, create_tree, copy_tree,
from distutils import log
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -76,7 +76,6 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
remove_tree(self.root_target, verbose=0)
-
def test_copy_tree_verbosity(self):
mkpath(self.target, verbose=0)
@@ -88,11 +87,8 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
mkpath(self.target, verbose=0)
a_file = os.path.join(self.target, 'ok.txt')
- f = open(a_file, 'w')
- try:
+ with open(a_file, 'w') as f:
f.write('some content')
- finally:
- f.close()
wanted = ['copying %s -> %s' % (a_file, self.target2)]
copy_tree(self.target, self.target2, verbose=1)
@@ -107,11 +103,8 @@ class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
a_file = os.path.join(self.target, 'ok.txt')
nfs_file = os.path.join(self.target, '.nfs123abc')
for f in a_file, nfs_file:
- fh = open(f, 'w')
- try:
+ with open(f, 'w') as fh:
fh.write('some content')
- finally:
- fh.close()
copy_tree(self.target, self.target2)
self.assertEqual(os.listdir(self.target2), ['ok.txt'])
diff --git a/Lib/distutils/tests/test_dist.py b/Lib/distutils/tests/test_dist.py
index 4b7bbeb33ec..8aaae88cae5 100644
--- a/Lib/distutils/tests/test_dist.py
+++ b/Lib/distutils/tests/test_dist.py
@@ -1,8 +1,6 @@
-# -*- coding: utf8 -*-
-
"""Tests for distutils.dist."""
import os
-import StringIO
+import io
import sys
import unittest
import warnings
@@ -10,8 +8,8 @@ import textwrap
from distutils.dist import Distribution, fix_help_options
from distutils.cmd import Command
-import distutils.dist
-from test.test_support import TESTFN, captured_stdout, run_unittest
+
+from test.support import TESTFN, captured_stdout, run_unittest
from distutils.tests import support
@@ -38,8 +36,7 @@ class TestDistribution(Distribution):
return self._config_files
-class DistributionTestCase(support.TempdirManager,
- support.LoggingSilencer,
+class DistributionTestCase(support.LoggingSilencer,
support.EnvironGuard,
unittest.TestCase):
@@ -60,27 +57,6 @@ class DistributionTestCase(support.TempdirManager,
d.parse_command_line()
return d
- def test_debug_mode(self):
- with open(TESTFN, "w") as f:
- f.write("[global]\n")
- f.write("command_packages = foo.bar, splat")
-
- files = [TESTFN]
- sys.argv.append("build")
-
- with captured_stdout() as stdout:
- self.create_distribution(files)
- stdout.seek(0)
- self.assertEqual(stdout.read(), '')
- distutils.dist.DEBUG = True
- try:
- with captured_stdout() as stdout:
- self.create_distribution(files)
- stdout.seek(0)
- self.assertEqual(stdout.read(), '')
- finally:
- distutils.dist.DEBUG = False
-
def test_command_packages_unspecified(self):
sys.argv.append("build")
d = self.create_distribution()
@@ -106,8 +82,8 @@ class DistributionTestCase(support.TempdirManager,
self.addCleanup(os.unlink, TESTFN)
f = open(TESTFN, "w")
try:
- print >> f, "[global]"
- print >> f, "command_packages = foo.bar, splat"
+ print("[global]", file=f)
+ print("command_packages = foo.bar, splat", file=f)
finally:
f.close()
@@ -127,33 +103,6 @@ class DistributionTestCase(support.TempdirManager,
d = self.create_distribution([TESTFN])
self.assertEqual(d.get_command_packages(), ["distutils.command"])
- def test_write_pkg_file(self):
- # Check DistributionMetadata handling of Unicode fields
- tmp_dir = self.mkdtemp()
- my_file = os.path.join(tmp_dir, 'f')
- klass = Distribution
-
- dist = klass(attrs={'author': u'Mister Café',
- 'name': 'my.package',
- 'maintainer': u'Café Junior',
- 'description': u'Café torréfié',
- 'long_description': u'Héhéhé'})
-
- # let's make sure the file can be written
- # with Unicode fields. they are encoded with
- # PKG_INFO_ENCODING
- dist.metadata.write_pkg_file(open(my_file, 'w'))
-
- # regular ascii is of course always usable
- dist = klass(attrs={'author': 'Mister Cafe',
- 'name': 'my.package',
- 'maintainer': 'Cafe Junior',
- 'description': 'Cafe torrefie',
- 'long_description': 'Hehehe'})
-
- my_file2 = os.path.join(tmp_dir, 'f2')
- dist.metadata.write_pkg_file(open(my_file2, 'w'))
-
def test_empty_options(self):
# an empty options dictionary should not stay in the
# list of attributes
@@ -203,35 +152,6 @@ class DistributionTestCase(support.TempdirManager,
kwargs = {'level': 'ok2'}
self.assertRaises(ValueError, dist.announce, args, kwargs)
- def test_find_config_files_disable(self):
- # Ticket #1180: Allow user to disable their home config file.
- temp_home = self.mkdtemp()
- if os.name == 'posix':
- user_filename = os.path.join(temp_home, ".pydistutils.cfg")
- else:
- user_filename = os.path.join(temp_home, "pydistutils.cfg")
-
- with open(user_filename, 'w') as f:
- f.write('[distutils]\n')
-
- def _expander(path):
- return temp_home
-
- old_expander = os.path.expanduser
- os.path.expanduser = _expander
- try:
- d = distutils.dist.Distribution()
- all_files = d.find_config_files()
-
- d = distutils.dist.Distribution(attrs={'script_args':
- ['--no-user-cfg']})
- files = d.find_config_files()
- finally:
- os.path.expanduser = old_expander
-
- # make sure --no-user-cfg disables the user cfg file
- self.assertEqual(len(all_files)-1, len(files))
-
class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
unittest.TestCase):
@@ -245,34 +165,10 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
sys.argv[:] = self.argv[1]
super(MetadataTestCase, self).tearDown()
- def test_classifier(self):
- attrs = {'name': 'Boa', 'version': '3.0',
- 'classifiers': ['Programming Language :: Python :: 3']}
- dist = Distribution(attrs)
- meta = self.format_metadata(dist)
- self.assertIn('Metadata-Version: 1.1', meta)
-
- def test_download_url(self):
- attrs = {'name': 'Boa', 'version': '3.0',
- 'download_url': 'http://example.org/boa'}
- dist = Distribution(attrs)
- meta = self.format_metadata(dist)
- self.assertIn('Metadata-Version: 1.1', meta)
-
- def test_long_description(self):
- long_desc = textwrap.dedent("""\
- example::
- We start here
- and continue here
- and end here.""")
- attrs = {"name": "package",
- "version": "1.0",
- "long_description": long_desc}
-
- dist = Distribution(attrs)
- meta = self.format_metadata(dist)
- meta = meta.replace('\n' + 8 * ' ', '\n')
- self.assertIn(long_desc, meta)
+ def format_metadata(self, dist):
+ sio = io.StringIO()
+ dist.metadata.write_pkg_file(sio)
+ return sio.getvalue()
def test_simple_metadata(self):
attrs = {"name": "package",
@@ -348,10 +244,34 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
"version": "1.0",
"obsoletes": ["my.pkg (splat)"]})
- def format_metadata(self, dist):
- sio = StringIO.StringIO()
- dist.metadata.write_pkg_file(sio)
- return sio.getvalue()
+ def test_classifier(self):
+ attrs = {'name': 'Boa', 'version': '3.0',
+ 'classifiers': ['Programming Language :: Python :: 3']}
+ dist = Distribution(attrs)
+ meta = self.format_metadata(dist)
+ self.assertIn('Metadata-Version: 1.1', meta)
+
+ def test_download_url(self):
+ attrs = {'name': 'Boa', 'version': '3.0',
+ 'download_url': 'http://example.org/boa'}
+ dist = Distribution(attrs)
+ meta = self.format_metadata(dist)
+ self.assertIn('Metadata-Version: 1.1', meta)
+
+ def test_long_description(self):
+ long_desc = textwrap.dedent("""\
+ example::
+ We start here
+ and continue here
+ and end here.""")
+ attrs = {"name": "package",
+ "version": "1.0",
+ "long_description": long_desc}
+
+ dist = Distribution(attrs)
+ meta = self.format_metadata(dist)
+ meta = meta.replace('\n' + 8 * ' ', '\n')
+ self.assertIn(long_desc, meta)
def test_custom_pydistutils(self):
# fixes #2166
@@ -407,33 +327,6 @@ class MetadataTestCase(support.TempdirManager, support.EnvironGuard,
if line.strip() != '']
self.assertTrue(output)
- def test_read_metadata(self):
- attrs = {"name": "package",
- "version": "1.0",
- "long_description": "desc",
- "description": "xxx",
- "download_url": "http://example.com",
- "keywords": ['one', 'two'],
- "requires": ['foo']}
-
- dist = Distribution(attrs)
- metadata = dist.metadata
-
- # write it then reloads it
- PKG_INFO = StringIO.StringIO()
- metadata.write_pkg_file(PKG_INFO)
- PKG_INFO.seek(0)
- metadata.read_pkg_file(PKG_INFO)
-
- self.assertEqual(metadata.name, "package")
- self.assertEqual(metadata.version, "1.0")
- self.assertEqual(metadata.description, "xxx")
- self.assertEqual(metadata.download_url, 'http://example.com')
- self.assertEqual(metadata.keywords, ['one', 'two'])
- self.assertEqual(metadata.platforms, ['UNKNOWN'])
- self.assertEqual(metadata.obsoletes, None)
- self.assertEqual(metadata.requires, ['foo'])
-
def test_suite():
suite = unittest.TestSuite()
diff --git a/Lib/distutils/tests/test_extension.py b/Lib/distutils/tests/test_extension.py
new file mode 100644
index 00000000000..e35f2738b6a
--- /dev/null
+++ b/Lib/distutils/tests/test_extension.py
@@ -0,0 +1,69 @@
+"""Tests for distutils.extension."""
+import unittest
+import os
+import warnings
+
+from test.support import check_warnings, run_unittest
+from distutils.extension import read_setup_file, Extension
+
+class ExtensionTestCase(unittest.TestCase):
+
+ def test_read_setup_file(self):
+ # trying to read a Setup file
+ # (sample extracted from the PyGame project)
+ setup = os.path.join(os.path.dirname(__file__), 'Setup.sample')
+
+ exts = read_setup_file(setup)
+ names = [ext.name for ext in exts]
+ names.sort()
+
+ # here are the extensions read_setup_file should have created
+ # out of the file
+ wanted = ['_arraysurfarray', '_camera', '_numericsndarray',
+ '_numericsurfarray', 'base', 'bufferproxy', 'cdrom',
+ 'color', 'constants', 'display', 'draw', 'event',
+ 'fastevent', 'font', 'gfxdraw', 'image', 'imageext',
+ 'joystick', 'key', 'mask', 'mixer', 'mixer_music',
+ 'mouse', 'movie', 'overlay', 'pixelarray', 'pypm',
+ 'rect', 'rwobject', 'scrap', 'surface', 'surflock',
+ 'time', 'transform']
+
+ self.assertEqual(names, wanted)
+
+ def test_extension_init(self):
+ # the first argument, which is the name, must be a string
+ self.assertRaises(AssertionError, Extension, 1, [])
+ ext = Extension('name', [])
+ self.assertEqual(ext.name, 'name')
+
+ # the second argument, which is the list of files, must
+ # be a list of strings
+ self.assertRaises(AssertionError, Extension, 'name', 'file')
+ self.assertRaises(AssertionError, Extension, 'name', ['file', 1])
+ ext = Extension('name', ['file1', 'file2'])
+ self.assertEqual(ext.sources, ['file1', 'file2'])
+
+ # others arguments have defaults
+ for attr in ('include_dirs', 'define_macros', 'undef_macros',
+ 'library_dirs', 'libraries', 'runtime_library_dirs',
+ 'extra_objects', 'extra_compile_args', 'extra_link_args',
+ 'export_symbols', 'swig_opts', 'depends'):
+ self.assertEqual(getattr(ext, attr), [])
+
+ self.assertEqual(ext.language, None)
+ self.assertEqual(ext.optional, None)
+
+ # if there are unknown keyword options, warn about them
+ with check_warnings() as w:
+ warnings.simplefilter('always')
+ ext = Extension('name', ['file1', 'file2'], chic=True)
+
+ self.assertEqual(len(w.warnings), 1)
+ self.assertEqual(str(w.warnings[0].message),
+ "Unknown Extension options: 'chic'")
+
+def test_suite():
+ return unittest.makeSuite(ExtensionTestCase)
+
+if __name__ == "__main__":
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_file_util.py b/Lib/distutils/tests/test_file_util.py
index 7dbcf52c68c..3c3e3dcb3bf 100644
--- a/Lib/distutils/tests/test_file_util.py
+++ b/Lib/distutils/tests/test_file_util.py
@@ -3,10 +3,10 @@ import unittest
import os
import shutil
-from distutils.file_util import move_file, write_file, copy_file
+from distutils.file_util import move_file
from distutils import log
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -58,21 +58,6 @@ class FileUtilTestCase(support.TempdirManager, unittest.TestCase):
wanted = ['moving %s -> %s' % (self.source, self.target_dir)]
self.assertEqual(self._logs, wanted)
- def test_write_file(self):
- lines = ['a', 'b', 'c']
- dir = self.mkdtemp()
- foo = os.path.join(dir, 'foo')
- write_file(foo, lines)
- content = [line.strip() for line in open(foo).readlines()]
- self.assertEqual(content, lines)
-
- def test_copy_file(self):
- src_dir = self.mkdtemp()
- foo = os.path.join(src_dir, 'foo')
- write_file(foo, 'content')
- dst_dir = self.mkdtemp()
- copy_file(foo, dst_dir)
- self.assertTrue(os.path.exists(os.path.join(dst_dir, 'foo')))
def test_suite():
return unittest.makeSuite(FileUtilTestCase)
diff --git a/Lib/distutils/tests/test_filelist.py b/Lib/distutils/tests/test_filelist.py
index 69b88f2df2a..e82bc3d2ed7 100644
--- a/Lib/distutils/tests/test_filelist.py
+++ b/Lib/distutils/tests/test_filelist.py
@@ -7,7 +7,7 @@ from distutils.log import WARN
from distutils.errors import DistutilsTemplateError
from distutils.filelist import glob_to_re, translate_pattern, FileList
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
from distutils.tests import support
MANIFEST_IN = """\
diff --git a/Lib/distutils/tests/test_install.py b/Lib/distutils/tests/test_install.py
index f17baa1e50d..cb2e1f28799 100644
--- a/Lib/distutils/tests/test_install.py
+++ b/Lib/distutils/tests/test_install.py
@@ -1,11 +1,12 @@
"""Tests for distutils.command.install."""
import os
+import imp
import sys
import unittest
import site
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
from distutils import sysconfig
from distutils.command.install import install
@@ -26,6 +27,7 @@ def _make_ext_name(modname):
class InstallTestCase(support.TempdirManager,
+ support.EnvironGuard,
support.LoggingSilencer,
unittest.TestCase):
@@ -66,10 +68,7 @@ class InstallTestCase(support.TempdirManager,
check_path(cmd.install_data, destination)
def test_user_site(self):
- # site.USER_SITE was introduced in 2.6
- if sys.version < '2.6':
- return
-
+ # test install with --user
# preparing the environment for the test
self.old_user_base = site.USER_BASE
self.old_user_site = site.USER_SITE
@@ -177,7 +176,7 @@ class InstallTestCase(support.TempdirManager,
project_dir, dist = self.create_dist(py_modules=['hello'],
scripts=['sayhi'])
os.chdir(project_dir)
- self.write_file('hello.py', "def main(): print 'o hai'")
+ self.write_file('hello.py', "def main(): print('o hai')")
self.write_file('sayhi', 'from hello import main; main()')
cmd = install(dist)
@@ -194,7 +193,7 @@ class InstallTestCase(support.TempdirManager,
f.close()
found = [os.path.basename(line) for line in content.splitlines()]
- expected = ['hello.py', 'hello.pyc', 'sayhi',
+ expected = ['hello.py', 'hello.%s.pyc' % imp.get_tag(), 'sayhi',
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
self.assertEqual(found, expected)
diff --git a/Lib/distutils/tests/test_install_data.py b/Lib/distutils/tests/test_install_data.py
index 477569444fb..4d8c00acb99 100644
--- a/Lib/distutils/tests/test_install_data.py
+++ b/Lib/distutils/tests/test_install_data.py
@@ -6,7 +6,7 @@ import getpass
from distutils.command.install_data import install_data
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class InstallDataTestCase(support.TempdirManager,
support.LoggingSilencer,
diff --git a/Lib/distutils/tests/test_install_headers.py b/Lib/distutils/tests/test_install_headers.py
index b37224b93d2..d953157bb7e 100644
--- a/Lib/distutils/tests/test_install_headers.py
+++ b/Lib/distutils/tests/test_install_headers.py
@@ -6,7 +6,7 @@ import getpass
from distutils.command.install_headers import install_headers
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class InstallHeadersTestCase(support.TempdirManager,
support.LoggingSilencer,
diff --git a/Lib/distutils/tests/test_install_lib.py b/Lib/distutils/tests/test_install_lib.py
index 4d863089c08..2bd4dc6e963 100644
--- a/Lib/distutils/tests/test_install_lib.py
+++ b/Lib/distutils/tests/test_install_lib.py
@@ -1,13 +1,15 @@
"""Tests for distutils.command.install_data."""
-import os
import sys
+import os
+import imp
import unittest
from distutils.command.install_lib import install_lib
from distutils.extension import Extension
from distutils.tests import support
from distutils.errors import DistutilsOptionError
-from test.test_support import run_unittest
+from test.support import run_unittest
+
class InstallLibTestCase(support.TempdirManager,
support.LoggingSilencer,
@@ -15,7 +17,7 @@ class InstallLibTestCase(support.TempdirManager,
unittest.TestCase):
def test_finalize_options(self):
- pkg_dir, dist = self.create_dist()
+ dist = self.create_dist()[1]
cmd = install_lib(dist)
cmd.finalize_options()
@@ -32,61 +34,64 @@ class InstallLibTestCase(support.TempdirManager,
cmd.finalize_options()
self.assertEqual(cmd.optimize, 2)
- def _setup_byte_compile(self):
- pkg_dir, dist = self.create_dist()
+ @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
+ def test_byte_compile(self):
+ project_dir, dist = self.create_dist()
+ os.chdir(project_dir)
cmd = install_lib(dist)
cmd.compile = cmd.optimize = 1
- f = os.path.join(pkg_dir, 'foo.py')
+ f = os.path.join(project_dir, 'foo.py')
self.write_file(f, '# python file')
cmd.byte_compile([f])
- return pkg_dir
-
- @unittest.skipIf(sys.dont_write_bytecode, 'byte-compile not enabled')
- def test_byte_compile(self):
- pkg_dir = self._setup_byte_compile()
- if sys.flags.optimize < 1:
- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyc')))
- else:
- self.assertTrue(os.path.exists(os.path.join(pkg_dir, 'foo.pyo')))
+ pyc_file = imp.cache_from_source('foo.py', debug_override=True)
+ pyo_file = imp.cache_from_source('foo.py', debug_override=False)
+ self.assertTrue(os.path.exists(pyc_file))
+ self.assertTrue(os.path.exists(pyo_file))
def test_get_outputs(self):
- pkg_dir, dist = self.create_dist()
+ project_dir, dist = self.create_dist()
+ os.chdir(project_dir)
+ os.mkdir('spam')
cmd = install_lib(dist)
# setting up a dist environment
cmd.compile = cmd.optimize = 1
- cmd.install_dir = pkg_dir
- f = os.path.join(pkg_dir, 'foo.py')
- self.write_file(f, '# python file')
- cmd.distribution.py_modules = [pkg_dir]
+ cmd.install_dir = self.mkdtemp()
+ f = os.path.join(project_dir, 'spam', '__init__.py')
+ self.write_file(f, '# python package')
cmd.distribution.ext_modules = [Extension('foo', ['xxx'])]
- cmd.distribution.packages = [pkg_dir]
+ cmd.distribution.packages = ['spam']
cmd.distribution.script_name = 'setup.py'
- # get_output should return 4 elements
- self.assertTrue(len(cmd.get_outputs()) >= 2)
+ # get_outputs should return 4 elements: spam/__init__.py, .pyc and
+ # .pyo, foo.import-tag-abiflags.so / foo.pyd
+ outputs = cmd.get_outputs()
+ self.assertEqual(len(outputs), 4, outputs)
def test_get_inputs(self):
- pkg_dir, dist = self.create_dist()
+ project_dir, dist = self.create_dist()
+ os.chdir(project_dir)
+ os.mkdir('spam')
cmd = install_lib(dist)
# setting up a dist environment
cmd.compile = cmd.optimize = 1
- cmd.install_dir = pkg_dir
- f = os.path.join(pkg_dir, 'foo.py')
- self.write_file(f, '# python file')
- cmd.distribution.py_modules = [pkg_dir]
+ cmd.install_dir = self.mkdtemp()
+ f = os.path.join(project_dir, 'spam', '__init__.py')
+ self.write_file(f, '# python package')
cmd.distribution.ext_modules = [Extension('foo', ['xxx'])]
- cmd.distribution.packages = [pkg_dir]
+ cmd.distribution.packages = ['spam']
cmd.distribution.script_name = 'setup.py'
- # get_input should return 2 elements
- self.assertEqual(len(cmd.get_inputs()), 2)
+ # get_inputs should return 2 elements: spam/__init__.py and
+ # foo.import-tag-abiflags.so / foo.pyd
+ inputs = cmd.get_inputs()
+ self.assertEqual(len(inputs), 2, inputs)
def test_dont_write_bytecode(self):
# makes sure byte_compile is not used
- pkg_dir, dist = self.create_dist()
+ dist = self.create_dist()[1]
cmd = install_lib(dist)
cmd.compile = 1
cmd.optimize = 1
@@ -100,6 +105,7 @@ class InstallLibTestCase(support.TempdirManager,
self.assertTrue('byte-compiling is disabled' in self.logs[0][1])
+
def test_suite():
return unittest.makeSuite(InstallLibTestCase)
diff --git a/Lib/distutils/tests/test_install_scripts.py b/Lib/distutils/tests/test_install_scripts.py
index 46085458bf1..8952e744e5d 100644
--- a/Lib/distutils/tests/test_install_scripts.py
+++ b/Lib/distutils/tests/test_install_scripts.py
@@ -7,7 +7,7 @@ from distutils.command.install_scripts import install_scripts
from distutils.core import Distribution
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
class InstallScriptsTestCase(support.TempdirManager,
diff --git a/Lib/distutils/tests/test_log.py b/Lib/distutils/tests/test_log.py
new file mode 100644
index 00000000000..ce66ee51e7c
--- /dev/null
+++ b/Lib/distutils/tests/test_log.py
@@ -0,0 +1,37 @@
+"""Tests for distutils.log"""
+
+import sys
+import unittest
+from tempfile import NamedTemporaryFile
+from test.support import run_unittest
+
+from distutils import log
+
+class TestLog(unittest.TestCase):
+ def test_non_ascii(self):
+ # Issue #8663: test that non-ASCII text is escaped with
+ # backslashreplace error handler (stream use ASCII encoding and strict
+ # error handler)
+ old_stdout = sys.stdout
+ old_stderr = sys.stderr
+ try:
+ log.set_threshold(log.DEBUG)
+ with NamedTemporaryFile(mode="w+", encoding='ascii') as stdout, \
+ NamedTemporaryFile(mode="w+", encoding='ascii') as stderr:
+ sys.stdout = stdout
+ sys.stderr = stderr
+ log.debug("debug:\xe9")
+ log.fatal("fatal:\xe9")
+ stdout.seek(0)
+ self.assertEqual(stdout.read().rstrip(), "debug:\\xe9")
+ stderr.seek(0)
+ self.assertEqual(stderr.read().rstrip(), "fatal:\\xe9")
+ finally:
+ sys.stdout = old_stdout
+ sys.stderr = old_stderr
+
+def test_suite():
+ return unittest.makeSuite(TestLog)
+
+if __name__ == "__main__":
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_msvc9compiler.py b/Lib/distutils/tests/test_msvc9compiler.py
index 2d94a1117e4..301d43d20c0 100644
--- a/Lib/distutils/tests/test_msvc9compiler.py
+++ b/Lib/distutils/tests/test_msvc9compiler.py
@@ -5,7 +5,7 @@ import os
from distutils.errors import DistutilsPlatformError
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
# A manifest with the only assembly reference being the msvcrt assembly, so
# should have the assembly completely stripped. Note that although the
@@ -127,11 +127,11 @@ class msvc9compilerTestCase(support.TempdirManager,
# looking for values that should exist on all
# windows registeries versions.
path = r'Control Panel\Desktop'
- v = Reg.get_value(path, u'dragfullwindows')
- self.assertTrue(v in (u'0', u'1', u'2'))
+ v = Reg.get_value(path, 'dragfullwindows')
+ self.assertTrue(v in ('0', '1', '2'))
- import _winreg
- HKCU = _winreg.HKEY_CURRENT_USER
+ import winreg
+ HKCU = winreg.HKEY_CURRENT_USER
keys = Reg.read_keys(HKCU, 'xxxx')
self.assertEqual(keys, None)
diff --git a/Lib/distutils/tests/test_register.py b/Lib/distutils/tests/test_register.py
index 4f34b18bd8f..a86b8606e4e 100644
--- a/Lib/distutils/tests/test_register.py
+++ b/Lib/distutils/tests/test_register.py
@@ -1,12 +1,11 @@
-# -*- encoding: utf8 -*-
"""Tests for distutils.command.register."""
import os
import unittest
import getpass
-import urllib2
+import urllib
import warnings
-from test.test_support import check_warnings, run_unittest
+from test.support import check_warnings, run_unittest
from distutils.command import register as register_module
from distutils.command.register import register
@@ -39,7 +38,7 @@ username:tarek
password:password
"""
-class RawInputs(object):
+class Inputs(object):
"""Fakes user inputs."""
def __init__(self, *answers):
self.answers = answers
@@ -75,12 +74,12 @@ class RegisterTestCase(PyPIRCCommandTestCase):
def _getpass(prompt):
return 'password'
getpass.getpass = _getpass
- self.old_opener = urllib2.build_opener
- self.conn = urllib2.build_opener = FakeOpener()
+ self.old_opener = urllib.request.build_opener
+ self.conn = urllib.request.build_opener = FakeOpener()
def tearDown(self):
getpass.getpass = self._old_getpass
- urllib2.build_opener = self.old_opener
+ urllib.request.build_opener = self.old_opener
super(RegisterTestCase, self).tearDown()
def _get_cmd(self, metadata=None):
@@ -101,7 +100,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
# we shouldn't have a .pypirc file yet
self.assertTrue(not os.path.exists(self.rc))
- # patching raw_input and getpass.getpass
+ # patching input and getpass.getpass
# so register gets happy
#
# Here's what we are faking :
@@ -109,13 +108,13 @@ class RegisterTestCase(PyPIRCCommandTestCase):
# Username : 'tarek'
# Password : 'password'
# Save your login (y/N)? : 'y'
- inputs = RawInputs('1', 'tarek', 'y')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('1', 'tarek', 'y')
+ register_module.input = inputs.__call__
# let's run the command
try:
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
# we should have a brand new .pypirc file
self.assertTrue(os.path.exists(self.rc))
@@ -133,7 +132,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
# if we run the command again
def _no_way(prompt=''):
raise AssertionError(prompt)
- register_module.raw_input = _no_way
+ register_module.input = _no_way
cmd.show_response = 1
cmd.run()
@@ -143,8 +142,10 @@ class RegisterTestCase(PyPIRCCommandTestCase):
self.assertEqual(len(self.conn.reqs), 2)
req1 = dict(self.conn.reqs[0].headers)
req2 = dict(self.conn.reqs[1].headers)
- self.assertEqual(req2['Content-length'], req1['Content-length'])
- self.assertTrue('xxx' in self.conn.reqs[1].data)
+
+ self.assertEqual(req1['Content-length'], '1374')
+ self.assertEqual(req2['Content-length'], '1374')
+ self.assertTrue((b'xxx') in self.conn.reqs[1].data)
def test_password_not_in_file(self):
@@ -161,38 +162,38 @@ class RegisterTestCase(PyPIRCCommandTestCase):
def test_registering(self):
# this test runs choice 2
cmd = self._get_cmd()
- inputs = RawInputs('2', 'tarek', 'tarek@ziade.org')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('2', 'tarek', 'tarek@ziade.org')
+ register_module.input = inputs.__call__
try:
# let's run the command
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
# we should have send a request
self.assertEqual(len(self.conn.reqs), 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEqual(headers['Content-length'], '608')
- self.assertTrue('tarek' in req.data)
+ self.assertTrue((b'tarek') in req.data)
def test_password_reset(self):
# this test runs choice 3
cmd = self._get_cmd()
- inputs = RawInputs('3', 'tarek@ziade.org')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('3', 'tarek@ziade.org')
+ register_module.input = inputs.__call__
try:
# let's run the command
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
# we should have send a request
self.assertEqual(len(self.conn.reqs), 1)
req = self.conn.reqs[0]
headers = dict(req.headers)
self.assertEqual(headers['Content-length'], '290')
- self.assertTrue('tarek' in req.data)
+ self.assertTrue((b'tarek') in req.data)
@unittest.skipUnless(docutils is not None, 'needs docutils')
def test_strict(self):
@@ -209,7 +210,7 @@ class RegisterTestCase(PyPIRCCommandTestCase):
# metadata are OK but long_description is broken
metadata = {'url': 'xxx', 'author': 'xxx',
- 'author_email': u'éxéxé',
+ 'author_email': 'éxéxé',
'name': 'xxx', 'version': 'xxx',
'long_description': 'title\n==\n\ntext'}
@@ -223,42 +224,42 @@ class RegisterTestCase(PyPIRCCommandTestCase):
cmd = self._get_cmd(metadata)
cmd.ensure_finalized()
cmd.strict = 1
- inputs = RawInputs('1', 'tarek', 'y')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('1', 'tarek', 'y')
+ register_module.input = inputs.__call__
# let's run the command
try:
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
# strict is not by default
cmd = self._get_cmd()
cmd.ensure_finalized()
- inputs = RawInputs('1', 'tarek', 'y')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('1', 'tarek', 'y')
+ register_module.input = inputs.__call__
# let's run the command
try:
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
# and finally a Unicode test (bug #12114)
- metadata = {'url': u'xxx', 'author': u'\u00c9ric',
- 'author_email': u'xxx', u'name': 'xxx',
- 'version': u'xxx',
- 'description': u'Something about esszet \u00df',
- 'long_description': u'More things about esszet \u00df'}
+ metadata = {'url': 'xxx', 'author': '\u00c9ric',
+ 'author_email': 'xxx', 'name': 'xxx',
+ 'version': 'xxx',
+ 'description': 'Something about esszet \u00df',
+ 'long_description': 'More things about esszet \u00df'}
cmd = self._get_cmd(metadata)
cmd.ensure_finalized()
cmd.strict = 1
- inputs = RawInputs('1', 'tarek', 'y')
- register_module.raw_input = inputs.__call__
+ inputs = Inputs('1', 'tarek', 'y')
+ register_module.input = inputs.__call__
# let's run the command
try:
cmd.run()
finally:
- del register_module.raw_input
+ del register_module.input
@unittest.skipUnless(docutils is not None, 'needs docutils')
def test_register_invalid_long_description(self):
@@ -270,9 +271,10 @@ class RegisterTestCase(PyPIRCCommandTestCase):
cmd = self._get_cmd(metadata)
cmd.ensure_finalized()
cmd.strict = True
- inputs = RawInputs('2', 'tarek', 'tarek@ziade.org')
- register_module.raw_input = inputs
- self.addCleanup(delattr, register_module, 'raw_input')
+ inputs = Inputs('2', 'tarek', 'tarek@ziade.org')
+ register_module.input = inputs
+ self.addCleanup(delattr, register_module, 'input')
+
self.assertRaises(DistutilsSetupError, cmd.run)
def test_check_metadata_deprecated(self):
diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
index 7e7d98d096c..e6359d6a8af 100644
--- a/Lib/distutils/tests/test_sdist.py
+++ b/Lib/distutils/tests/test_sdist.py
@@ -6,21 +6,13 @@ import warnings
import zipfile
from os.path import join
from textwrap import dedent
-from test.test_support import captured_stdout, check_warnings, run_unittest
+from test.support import captured_stdout, check_warnings, run_unittest
-# zlib is not used here, but if it's not available
-# the tests that use zipfile may fail
try:
import zlib
+ ZLIB_SUPPORT = True
except ImportError:
- zlib = None
-
-try:
- import grp
- import pwd
- UID_GID_SUPPORT = True
-except ImportError:
- UID_GID_SUPPORT = False
+ ZLIB_SUPPORT = False
from distutils.command.sdist import sdist, show_formats
@@ -89,7 +81,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.dist_dir = 'dist'
return dist, cmd
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_prune_file_list(self):
# this test creates a project with some VCS dirs and an NFS rename
# file, then launches sdist to check they get pruned on all systems
@@ -132,7 +124,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# making sure everything has been pruned correctly
self.assertEqual(len(content), 4)
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_make_distribution(self):
# check if tar and gzip are installed
@@ -167,29 +159,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
result.sort()
self.assertEqual(result, ['fake-1.0.tar', 'fake-1.0.tar.gz'])
- @unittest.skipUnless(zlib, "requires zlib")
- def test_unicode_metadata_tgz(self):
- """
- Unicode name or version should not break building to tar.gz format.
- Reference issue #11638.
- """
-
- # create the sdist command with unicode parameters
- dist, cmd = self.get_cmd({'name': u'fake', 'version': u'1.0'})
-
- # create the sdist as gztar and run the command
- cmd.formats = ['gztar']
- cmd.ensure_finalized()
- cmd.run()
-
- # The command should have created the .tar.gz file
- dist_folder = join(self.tmp_dir, 'dist')
- result = os.listdir(dist_folder)
- self.assertEqual(result, ['fake-1.0.tar.gz'])
-
- os.remove(join(dist_folder, 'fake-1.0.tar.gz'))
-
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_add_defaults(self):
# http://bugs.python.org/issue2279
@@ -262,7 +232,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
f.close()
self.assertEqual(manifest, MANIFEST % {'sep': os.sep})
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_metadata_check_option(self):
# testing the `medata-check` option
dist, cmd = self.get_cmd(metadata={})
@@ -323,56 +293,6 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.formats = 'supazipa'
self.assertRaises(DistutilsOptionError, cmd.finalize_options)
- @unittest.skipUnless(zlib, "requires zlib")
- @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
- def test_make_distribution_owner_group(self):
-
- # check if tar and gzip are installed
- if (find_executable('tar') is None or
- find_executable('gzip') is None):
- return
-
- # now building a sdist
- dist, cmd = self.get_cmd()
-
- # creating a gztar and specifying the owner+group
- cmd.formats = ['gztar']
- cmd.owner = pwd.getpwuid(0)[0]
- cmd.group = grp.getgrgid(0)[0]
- cmd.ensure_finalized()
- cmd.run()
-
- # making sure we have the good rights
- archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
- archive = tarfile.open(archive_name)
- try:
- for member in archive.getmembers():
- self.assertEqual(member.uid, 0)
- self.assertEqual(member.gid, 0)
- finally:
- archive.close()
-
- # building a sdist again
- dist, cmd = self.get_cmd()
-
- # creating a gztar
- cmd.formats = ['gztar']
- cmd.ensure_finalized()
- cmd.run()
-
- # making sure we have the good rights
- archive_name = join(self.tmp_dir, 'dist', 'fake-1.0.tar.gz')
- archive = tarfile.open(archive_name)
-
- # note that we are not testing the group ownership here
- # because, depending on the platforms and the container
- # rights (see #7408)
- try:
- for member in archive.getmembers():
- self.assertEqual(member.uid, os.getuid())
- finally:
- archive.close()
-
# the following tests make sure there is a nice error message instead
# of a traceback when parsing an invalid manifest template
@@ -399,7 +319,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
# this used to crash instead of raising a warning: #8286
self._check_template('include examples/')
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_get_file_list(self):
# make sure MANIFEST is recalculated
dist, cmd = self.get_cmd()
@@ -441,7 +361,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.assertEqual(len(manifest2), 6)
self.assertIn('doc2.txt', manifest2[-1])
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_manifest_marker(self):
# check that autogenerated MANIFESTs have a marker
dist, cmd = self.get_cmd()
@@ -458,7 +378,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
self.assertEqual(manifest[0],
'# file GENERATED by distutils, do NOT edit')
- @unittest.skipUnless(zlib, 'requires zlib')
+ @unittest.skipUnless(ZLIB_SUPPORT, "Need zlib support to run")
def test_manifest_comments(self):
# make sure comments don't cause exceptions or wrong includes
contents = dedent("""\
@@ -475,7 +395,7 @@ class SDistTestCase(PyPIRCCommandTestCase):
cmd.run()
self.assertEqual(cmd.filelist.files, ['good.py'])
- @unittest.skipUnless(zlib, "requires zlib")
+ @unittest.skipUnless(ZLIB_SUPPORT, 'Need zlib support to run')
def test_manual_manifest(self):
# check that a MANIFEST without a marker is left alone
dist, cmd = self.get_cmd()
diff --git a/Lib/distutils/tests/test_spawn.py b/Lib/distutils/tests/test_spawn.py
index defa54d87f1..6c7eb20c471 100644
--- a/Lib/distutils/tests/test_spawn.py
+++ b/Lib/distutils/tests/test_spawn.py
@@ -2,7 +2,7 @@
import unittest
import os
import time
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
from distutils.spawn import _nt_quote_args
from distutils.spawn import spawn, find_executable
@@ -33,24 +33,22 @@ class SpawnTestCase(support.TempdirManager,
if os.name == 'posix':
exe = os.path.join(tmpdir, 'foo.sh')
self.write_file(exe, '#!/bin/sh\nexit 1')
- os.chmod(exe, 0777)
else:
exe = os.path.join(tmpdir, 'foo.bat')
self.write_file(exe, 'exit 1')
- os.chmod(exe, 0777)
+ os.chmod(exe, 0o777)
self.assertRaises(DistutilsExecError, spawn, [exe])
# now something that works
if os.name == 'posix':
exe = os.path.join(tmpdir, 'foo.sh')
self.write_file(exe, '#!/bin/sh\nexit 0')
- os.chmod(exe, 0777)
else:
exe = os.path.join(tmpdir, 'foo.bat')
self.write_file(exe, 'exit 0')
- os.chmod(exe, 0777)
+ os.chmod(exe, 0o777)
spawn([exe]) # should work without any error
def test_suite():
diff --git a/Lib/distutils/tests/test_sysconfig.py b/Lib/distutils/tests/test_sysconfig.py
index 49570c4ce50..fbe26bf65d6 100644
--- a/Lib/distutils/tests/test_sysconfig.py
+++ b/Lib/distutils/tests/test_sysconfig.py
@@ -1,12 +1,13 @@
"""Tests for distutils.sysconfig."""
import os
+import shutil
import test
import unittest
-import shutil
from distutils import sysconfig
+from distutils.ccompiler import get_default_compiler
from distutils.tests import support
-from test.test_support import TESTFN
+from test.support import TESTFN, run_unittest
class SysconfigTestCase(support.EnvironGuard,
unittest.TestCase):
@@ -21,11 +22,14 @@ class SysconfigTestCase(support.EnvironGuard,
super(SysconfigTestCase, self).tearDown()
def cleanup_testfn(self):
- path = test.test_support.TESTFN
- if os.path.isfile(path):
- os.remove(path)
- elif os.path.isdir(path):
- shutil.rmtree(path)
+ if os.path.isfile(TESTFN):
+ os.remove(TESTFN)
+ elif os.path.isdir(TESTFN):
+ shutil.rmtree(TESTFN)
+
+ def test_get_config_h_filename(self):
+ config_h = sysconfig.get_config_h_filename()
+ self.assertTrue(os.path.isfile(config_h), config_h)
def test_get_python_lib(self):
lib_dir = sysconfig.get_python_lib()
@@ -34,9 +38,6 @@ class SysconfigTestCase(support.EnvironGuard,
# test for pythonxx.lib?
self.assertNotEqual(sysconfig.get_python_lib(),
sysconfig.get_python_lib(prefix=TESTFN))
- _sysconfig = __import__('sysconfig')
- res = sysconfig.get_python_lib(True, True)
- self.assertEqual(_sysconfig.get_path('platstdlib'), res)
def test_get_python_inc(self):
inc_dir = sysconfig.get_python_inc()
@@ -47,8 +48,33 @@ class SysconfigTestCase(support.EnvironGuard,
python_h = os.path.join(inc_dir, "Python.h")
self.assertTrue(os.path.isfile(python_h), python_h)
+ def test_get_config_vars(self):
+ cvars = sysconfig.get_config_vars()
+ self.assertTrue(isinstance(cvars, dict))
+ self.assertTrue(cvars)
+
+ def test_customize_compiler(self):
+
+ # not testing if default compiler is not unix
+ if get_default_compiler() != 'unix':
+ return
+
+ os.environ['AR'] = 'my_ar'
+ os.environ['ARFLAGS'] = '-arflags'
+
+ # make sure AR gets caught
+ class compiler:
+ compiler_type = 'unix'
+
+ def set_executables(self, **kw):
+ self.exes = kw
+
+ comp = compiler()
+ sysconfig.customize_compiler(comp)
+ self.assertEqual(comp.exes['archiver'], 'my_ar -arflags')
+
def test_parse_makefile_base(self):
- self.makefile = test.test_support.TESTFN
+ self.makefile = TESTFN
fd = open(self.makefile, 'w')
try:
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=LIB'" '\n')
@@ -60,7 +86,7 @@ class SysconfigTestCase(support.EnvironGuard,
'OTHER': 'foo'})
def test_parse_makefile_literal_dollar(self):
- self.makefile = test.test_support.TESTFN
+ self.makefile = TESTFN
fd = open(self.makefile, 'w')
try:
fd.write(r"CONFIG_ARGS= '--arg1=optarg1' 'ENV=\$$LIB'" '\n')
@@ -72,6 +98,15 @@ class SysconfigTestCase(support.EnvironGuard,
'OTHER': 'foo'})
+ def test_sysconfig_module(self):
+ import sysconfig as global_sysconfig
+ self.assertEqual(global_sysconfig.get_config_var('CFLAGS'), sysconfig.get_config_var('CFLAGS'))
+ self.assertEqual(global_sysconfig.get_config_var('LDFLAGS'), sysconfig.get_config_var('LDFLAGS'))
+ self.assertEqual(global_sysconfig.get_config_var('LDSHARED'),sysconfig.get_config_var('LDSHARED'))
+ self.assertEqual(global_sysconfig.get_config_var('CC'), sysconfig.get_config_var('CC'))
+
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(SysconfigTestCase))
@@ -79,4 +114,4 @@ def test_suite():
if __name__ == '__main__':
- test.test_support.run_unittest(test_suite())
+ run_unittest(test_suite())
diff --git a/Lib/distutils/tests/test_text_file.py b/Lib/distutils/tests/test_text_file.py
index ce19cd4dcde..7e76240a9a3 100644
--- a/Lib/distutils/tests/test_text_file.py
+++ b/Lib/distutils/tests/test_text_file.py
@@ -3,7 +3,7 @@ import os
import unittest
from distutils.text_file import TextFile
from distutils.tests import support
-from test.test_support import run_unittest
+from test.support import run_unittest
TEST_DATA = """# test file
diff --git a/Lib/distutils/tests/test_unixccompiler.py b/Lib/distutils/tests/test_unixccompiler.py
index 40c908a24d0..1bff38e9eef 100644
--- a/Lib/distutils/tests/test_unixccompiler.py
+++ b/Lib/distutils/tests/test_unixccompiler.py
@@ -1,7 +1,7 @@
"""Tests for distutils.unixccompiler."""
import sys
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
from distutils import sysconfig
from distutils.unixccompiler import UnixCCompiler
@@ -71,7 +71,7 @@ class UnixCCompilerTestCase(unittest.TestCase):
elif v == 'GNULD':
return 'yes'
sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-Wl,-R/foo')
+ self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
# GCC non-GNULD
sys.platform = 'bar'
@@ -92,7 +92,7 @@ class UnixCCompilerTestCase(unittest.TestCase):
elif v == 'GNULD':
return 'yes'
sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-Wl,-R/foo')
+ self.assertEqual(self.cc.rpath_foo(), '-Wl,--enable-new-dtags,-R/foo')
# non-GCC GNULD
@@ -115,14 +115,6 @@ class UnixCCompilerTestCase(unittest.TestCase):
sysconfig.get_config_var = gcv
self.assertEqual(self.cc.rpath_foo(), '-R/foo')
- # AIX C/C++ linker
- sys.platform = 'aix'
- def gcv(v):
- return 'xxx'
- sysconfig.get_config_var = gcv
- self.assertEqual(self.cc.rpath_foo(), '-R/foo')
-
-
def test_suite():
return unittest.makeSuite(UnixCCompilerTestCase)
diff --git a/Lib/distutils/tests/test_upload.py b/Lib/distutils/tests/test_upload.py
index 99111999d87..4c6464a32e8 100644
--- a/Lib/distutils/tests/test_upload.py
+++ b/Lib/distutils/tests/test_upload.py
@@ -1,10 +1,9 @@
-# -*- encoding: utf8 -*-
"""Tests for distutils.command.upload."""
import os
import unittest
-from test.test_support import run_unittest
+import http.client as httpclient
+from test.support import run_unittest
-from distutils.command import upload as upload_mod
from distutils.command.upload import upload
from distutils.core import Distribution
@@ -38,37 +37,48 @@ index-servers =
[server1]
username:me
"""
+class Response(object):
+ def __init__(self, status=200, reason='OK'):
+ self.status = status
+ self.reason = reason
-class FakeOpen(object):
+class FakeConnection(object):
- def __init__(self, url):
- self.url = url
- if not isinstance(url, str):
- self.req = url
- else:
- self.req = None
- self.msg = 'OK'
+ def __init__(self):
+ self.requests = []
+ self.headers = []
+ self.body = ''
- def getcode(self):
- return 200
+ def __call__(self, netloc):
+ return self
+ def connect(self):
+ pass
+ endheaders = connect
+
+ def putrequest(self, method, url):
+ self.requests.append((method, url))
+
+ def putheader(self, name, value):
+ self.headers.append((name, value))
+
+ def send(self, body):
+ self.body = body
+
+ def getresponse(self):
+ return Response()
class uploadTestCase(PyPIRCCommandTestCase):
def setUp(self):
super(uploadTestCase, self).setUp()
- self.old_open = upload_mod.urlopen
- upload_mod.urlopen = self._urlopen
- self.last_open = None
+ self.old_class = httpclient.HTTPConnection
+ self.conn = httpclient.HTTPConnection = FakeConnection()
def tearDown(self):
- upload_mod.urlopen = self.old_open
+ httpclient.HTTPConnection = self.old_class
super(uploadTestCase, self).tearDown()
- def _urlopen(self, url):
- self.last_open = FakeOpen(url)
- return self.last_open
-
def test_finalize_options(self):
# new format
@@ -107,22 +117,19 @@ class uploadTestCase(PyPIRCCommandTestCase):
self.write_file(self.rc, PYPIRC_LONG_PASSWORD)
# lets run it
- pkg_dir, dist = self.create_dist(dist_files=dist_files, author=u'dédé')
+ pkg_dir, dist = self.create_dist(dist_files=dist_files)
cmd = upload(dist)
cmd.ensure_finalized()
cmd.run()
# what did we send ?
- self.assertIn('dédé', self.last_open.req.data)
- headers = dict(self.last_open.req.headers)
- self.assertEqual(headers['Content-length'], '2085')
+ headers = dict(self.conn.headers)
+ self.assertEqual(headers['Content-length'], '2087')
self.assertTrue(headers['Content-type'].startswith('multipart/form-data'))
- self.assertEqual(self.last_open.req.get_method(), 'POST')
- self.assertEqual(self.last_open.req.get_full_url(),
- 'http://pypi.python.org/pypi')
- self.assertTrue('xxx' in self.last_open.req.data)
- auth = self.last_open.req.headers['Authorization']
- self.assertFalse('\n' in auth)
+ self.assertFalse('\n' in headers['Authorization'])
+
+ self.assertEqual(self.conn.requests, [('POST', '/pypi')])
+ self.assertTrue((b'xxx') in self.conn.body)
def test_suite():
return unittest.makeSuite(uploadTestCase)
diff --git a/Lib/distutils/tests/test_util.py b/Lib/distutils/tests/test_util.py
index 67cd4cc7e61..1a06d4c4a14 100644
--- a/Lib/distutils/tests/test_util.py
+++ b/Lib/distutils/tests/test_util.py
@@ -1,12 +1,270 @@
"""Tests for distutils.util."""
+import os
import sys
import unittest
-from test.test_support import run_unittest
+from copy import copy
+from test.support import run_unittest
from distutils.errors import DistutilsPlatformError, DistutilsByteCompileError
-from distutils.util import byte_compile
+from distutils.util import (get_platform, convert_path, change_root,
+ check_environ, split_quoted, strtobool,
+ rfc822_escape, byte_compile)
+from distutils import util # used to patch _environ_checked
+from distutils.sysconfig import get_config_vars
+from distutils import sysconfig
+from distutils.tests import support
-class UtilTestCase(unittest.TestCase):
+class UtilTestCase(support.EnvironGuard, unittest.TestCase):
+
+ def setUp(self):
+ super(UtilTestCase, self).setUp()
+ # saving the environment
+ self.name = os.name
+ self.platform = sys.platform
+ self.version = sys.version
+ self.sep = os.sep
+ self.join = os.path.join
+ self.isabs = os.path.isabs
+ self.splitdrive = os.path.splitdrive
+ self._config_vars = copy(sysconfig._config_vars)
+
+ # patching os.uname
+ if hasattr(os, 'uname'):
+ self.uname = os.uname
+ self._uname = os.uname()
+ else:
+ self.uname = None
+ self._uname = None
+
+ os.uname = self._get_uname
+
+ def tearDown(self):
+ # getting back the environment
+ os.name = self.name
+ sys.platform = self.platform
+ sys.version = self.version
+ os.sep = self.sep
+ os.path.join = self.join
+ os.path.isabs = self.isabs
+ os.path.splitdrive = self.splitdrive
+ if self.uname is not None:
+ os.uname = self.uname
+ else:
+ del os.uname
+ sysconfig._config_vars = copy(self._config_vars)
+ super(UtilTestCase, self).tearDown()
+
+ def _set_uname(self, uname):
+ self._uname = uname
+
+ def _get_uname(self):
+ return self._uname
+
+ def test_get_platform(self):
+
+ # windows XP, 32bits
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Intel)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win32')
+
+ # windows XP, amd64
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Amd64)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win-amd64')
+
+ # windows XP, itanium
+ os.name = 'nt'
+ sys.version = ('2.4.4 (#71, Oct 18 2006, 08:34:43) '
+ '[MSC v.1310 32 bit (Itanium)]')
+ sys.platform = 'win32'
+ self.assertEqual(get_platform(), 'win-ia64')
+
+ # macbook
+ os.name = 'posix'
+ sys.version = ('2.5 (r25:51918, Sep 19 2006, 08:49:13) '
+ '\n[GCC 4.0.1 (Apple Computer, Inc. build 5341)]')
+ sys.platform = 'darwin'
+ self._set_uname(('Darwin', 'macziade', '8.11.1',
+ ('Darwin Kernel Version 8.11.1: '
+ 'Wed Oct 10 18:23:28 PDT 2007; '
+ 'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
+ get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+
+ get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
+ '-fwrapv -O3 -Wall -Wstrict-prototypes')
+
+ cursize = sys.maxsize
+ sys.maxsize = (2 ** 31)-1
+ try:
+ self.assertEqual(get_platform(), 'macosx-10.3-i386')
+ finally:
+ sys.maxsize = cursize
+
+ # macbook with fat binaries (fat, universal or fat64)
+ get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
+ get_config_vars()['CFLAGS'] = ('-arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-fat')
+
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.1'
+ self.assertEqual(get_platform(), 'macosx-10.4-fat')
+
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-intel')
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+ self.assertEqual(get_platform(), 'macosx-10.4-fat3')
+
+ get_config_vars()['CFLAGS'] = ('-arch ppc64 -arch x86_64 -arch ppc -arch i386 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+ self.assertEqual(get_platform(), 'macosx-10.4-universal')
+
+ get_config_vars()['CFLAGS'] = ('-arch x86_64 -arch ppc64 -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3')
+
+ self.assertEqual(get_platform(), 'macosx-10.4-fat64')
+
+ for arch in ('ppc', 'i386', 'x86_64', 'ppc64'):
+ get_config_vars()['CFLAGS'] = ('-arch %s -isysroot '
+ '/Developer/SDKs/MacOSX10.4u.sdk '
+ '-fno-strict-aliasing -fno-common '
+ '-dynamic -DNDEBUG -g -O3'%(arch,))
+
+ self.assertEqual(get_platform(), 'macosx-10.4-%s'%(arch,))
+
+
+ # linux debian sarge
+ os.name = 'posix'
+ sys.version = ('2.3.5 (#1, Jul 4 2007, 17:28:59) '
+ '\n[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)]')
+ sys.platform = 'linux2'
+ self._set_uname(('Linux', 'aglae', '2.6.21.1dedibox-r7',
+ '#1 Mon Apr 30 17:25:38 CEST 2007', 'i686'))
+
+ self.assertEqual(get_platform(), 'linux-i686')
+
+ # XXX more platforms to tests here
+
+ def test_convert_path(self):
+ # linux/mac
+ os.sep = '/'
+ def _join(path):
+ return '/'.join(path)
+ os.path.join = _join
+
+ self.assertEqual(convert_path('/home/to/my/stuff'),
+ '/home/to/my/stuff')
+
+ # win
+ os.sep = '\\'
+ def _join(*path):
+ return '\\'.join(path)
+ os.path.join = _join
+
+ self.assertRaises(ValueError, convert_path, '/home/to/my/stuff')
+ self.assertRaises(ValueError, convert_path, 'home/to/my/stuff/')
+
+ self.assertEqual(convert_path('home/to/my/stuff'),
+ 'home\\to\\my\\stuff')
+ self.assertEqual(convert_path('.'),
+ os.curdir)
+
+ def test_change_root(self):
+ # linux/mac
+ os.name = 'posix'
+ def _isabs(path):
+ return path[0] == '/'
+ os.path.isabs = _isabs
+ def _join(*path):
+ return '/'.join(path)
+ os.path.join = _join
+
+ self.assertEqual(change_root('/root', '/old/its/here'),
+ '/root/old/its/here')
+ self.assertEqual(change_root('/root', 'its/here'),
+ '/root/its/here')
+
+ # windows
+ os.name = 'nt'
+ def _isabs(path):
+ return path.startswith('c:\\')
+ os.path.isabs = _isabs
+ def _splitdrive(path):
+ if path.startswith('c:'):
+ return ('', path.replace('c:', ''))
+ return ('', path)
+ os.path.splitdrive = _splitdrive
+ def _join(*path):
+ return '\\'.join(path)
+ os.path.join = _join
+
+ self.assertEqual(change_root('c:\\root', 'c:\\old\\its\\here'),
+ 'c:\\root\\old\\its\\here')
+ self.assertEqual(change_root('c:\\root', 'its\\here'),
+ 'c:\\root\\its\\here')
+
+ # BugsBunny os (it's a great os)
+ os.name = 'BugsBunny'
+ self.assertRaises(DistutilsPlatformError,
+ change_root, 'c:\\root', 'its\\here')
+
+ # XXX platforms to be covered: os2, mac
+
+ def test_check_environ(self):
+ util._environ_checked = 0
+ if 'HOME' in os.environ:
+ del os.environ['HOME']
+
+ # posix without HOME
+ if os.name == 'posix': # this test won't run on windows
+ check_environ()
+ import pwd
+ self.assertEqual(os.environ['HOME'], pwd.getpwuid(os.getuid())[5])
+ else:
+ check_environ()
+
+ self.assertEqual(os.environ['PLAT'], get_platform())
+ self.assertEqual(util._environ_checked, 1)
+
+ def test_split_quoted(self):
+ self.assertEqual(split_quoted('""one"" "two" \'three\' \\four'),
+ ['one', 'two', 'three', 'four'])
+
+ def test_strtobool(self):
+ yes = ('y', 'Y', 'yes', 'True', 't', 'true', 'True', 'On', 'on', '1')
+ no = ('n', 'no', 'f', 'false', 'off', '0', 'Off', 'No', 'N')
+
+ for y in yes:
+ self.assertTrue(strtobool(y))
+
+ for n in no:
+ self.assertTrue(not strtobool(n))
+
+ def test_rfc822_escape(self):
+ header = 'I am a\npoor\nlonesome\nheader\n'
+ res = rfc822_escape(header)
+ wanted = ('I am a%(8s)spoor%(8s)slonesome%(8s)s'
+ 'header%(8s)s') % {'8s': '\n'+8*' '}
+ self.assertEqual(res, wanted)
def test_dont_write_bytecode(self):
# makes sure byte_compile raise a DistutilsError
diff --git a/Lib/distutils/tests/test_version.py b/Lib/distutils/tests/test_version.py
index 2189956429f..15f14c7de3f 100644
--- a/Lib/distutils/tests/test_version.py
+++ b/Lib/distutils/tests/test_version.py
@@ -2,7 +2,7 @@
import unittest
from distutils.version import LooseVersion
from distutils.version import StrictVersion
-from test.test_support import run_unittest
+from test.support import run_unittest
class VersionTestCase(unittest.TestCase):
@@ -34,7 +34,7 @@ class VersionTestCase(unittest.TestCase):
for v1, v2, wanted in versions:
try:
- res = StrictVersion(v1).__cmp__(StrictVersion(v2))
+ res = StrictVersion(v1)._cmp(StrictVersion(v2))
except ValueError:
if wanted is ValueError:
continue
@@ -59,7 +59,7 @@ class VersionTestCase(unittest.TestCase):
for v1, v2, wanted in versions:
- res = LooseVersion(v1).__cmp__(LooseVersion(v2))
+ res = LooseVersion(v1)._cmp(LooseVersion(v2))
self.assertEqual(res, wanted,
'cmp(%s, %s) should be %s, got %s' %
(v1, v2, wanted, res))
diff --git a/Lib/distutils/tests/test_versionpredicate.py b/Lib/distutils/tests/test_versionpredicate.py
index 1d6c8d5a98d..28ae09dc205 100644
--- a/Lib/distutils/tests/test_versionpredicate.py
+++ b/Lib/distutils/tests/test_versionpredicate.py
@@ -4,7 +4,7 @@
import distutils.versionpredicate
import doctest
-from test.test_support import run_unittest
+from test.support import run_unittest
def test_suite():
return doctest.DocTestSuite(distutils.versionpredicate)
diff --git a/Lib/distutils/text_file.py b/Lib/distutils/text_file.py
index 09a798b1902..40b8484a685 100644
--- a/Lib/distutils/text_file.py
+++ b/Lib/distutils/text_file.py
@@ -4,13 +4,10 @@ provides the TextFile class, which gives an interface to text files
that (optionally) takes care of stripping comments, ignoring blank
lines, and joining lines with backslashes."""
-__revision__ = "$Id$"
-
-import sys
+import sys, os, io
class TextFile:
-
"""Provides a file-like object that takes care of all the things you
commonly want to do when processing a text file that has some
line-by-line syntax: strip comments (as long as "#" is your
@@ -33,7 +30,7 @@ class TextFile:
something that provides 'readline()' and 'close()' methods). It is
recommended that you supply at least 'filename', so that TextFile
can include it in warning messages. If 'file' is not supplied,
- TextFile creates its own using the 'open()' builtin.
+ TextFile creates its own using 'io.open()'.
The options are all boolean, and affect the value returned by
'readline()':
@@ -59,6 +56,8 @@ class TextFile:
collapse_join [default: false]
strip leading whitespace from lines that are joined to their
predecessor; only matters if (join_lines and not lstrip_ws)
+ errors [default: 'strict']
+ error handler used to decode the file content
Note that since 'rstrip_ws' can strip the trailing newline, the
semantics of 'readline()' must differ from those of the builtin file
@@ -73,34 +72,32 @@ class TextFile:
'rstrip_ws': 1,
'join_lines': 0,
'collapse_join': 0,
+ 'errors': 'strict',
}
- def __init__ (self, filename=None, file=None, **options):
+ def __init__(self, filename=None, file=None, **options):
"""Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'."""
-
if filename is None and file is None:
- raise RuntimeError, \
- "you must supply either or both of 'filename' and 'file'"
+ raise RuntimeError("you must supply either or both of 'filename' and 'file'")
# set values for all options -- either from client option hash
# or fallback to default_options
for opt in self.default_options.keys():
if opt in options:
- setattr (self, opt, options[opt])
-
+ setattr(self, opt, options[opt])
else:
- setattr (self, opt, self.default_options[opt])
+ setattr(self, opt, self.default_options[opt])
# sanity check client option hash
for opt in options.keys():
if opt not in self.default_options:
- raise KeyError, "invalid TextFile option '%s'" % opt
+ raise KeyError("invalid TextFile option '%s'" % opt)
if file is None:
- self.open (filename)
+ self.open(filename)
else:
self.filename = filename
self.file = file
@@ -111,43 +108,37 @@ class TextFile:
# 'unreadline()' operation
self.linebuf = []
-
- def open (self, filename):
+ def open(self, filename):
"""Open a new file named 'filename'. This overrides both the
'filename' and 'file' arguments to the constructor."""
-
self.filename = filename
- self.file = open (self.filename, 'r')
+ self.file = io.open(self.filename, 'r', errors=self.errors)
self.current_line = 0
-
- def close (self):
+ def close(self):
"""Close the current file and forget everything we know about it
(filename, current line number)."""
-
- self.file.close ()
+ self.file.close()
self.file = None
self.filename = None
self.current_line = None
-
- def gen_error (self, msg, line=None):
+ def gen_error(self, msg, line=None):
outmsg = []
if line is None:
line = self.current_line
outmsg.append(self.filename + ", ")
if isinstance(line, (list, tuple)):
- outmsg.append("lines %d-%d: " % tuple (line))
+ outmsg.append("lines %d-%d: " % tuple(line))
else:
outmsg.append("line %d: " % line)
outmsg.append(str(msg))
- return ''.join(outmsg)
-
+ return "".join(outmsg)
- def error (self, msg, line=None):
- raise ValueError, "error: " + self.gen_error(msg, line)
+ def error(self, msg, line=None):
+ raise ValueError("error: " + self.gen_error(msg, line))
- def warn (self, msg, line=None):
+ def warn(self, msg, line=None):
"""Print (to stderr) a warning message tied to the current logical
line in the current file. If the current logical line in the
file spans multiple physical lines, the warning refers to the
@@ -157,8 +148,7 @@ class TextFile:
line."""
sys.stderr.write("warning: " + self.gen_error(msg, line) + "\n")
-
- def readline (self):
+ def readline(self):
"""Read and return a single logical line from the current file (or
from an internal buffer if lines have previously been "unread"
with 'unreadline()'). If the 'join_lines' option is true, this
@@ -168,7 +158,6 @@ class TextFile:
line(s) just read. Returns None on end-of-file, since the empty
string can occur if 'rstrip_ws' is true but 'strip_blanks' is
not."""
-
# If any "unread" lines waiting in 'linebuf', return the top
# one. (We don't actually buffer read-ahead data -- lines only
# get put in 'linebuf' if the client explicitly does an
@@ -180,10 +169,11 @@ class TextFile:
buildup_line = ''
- while 1:
+ while True:
# read the line, make it None if EOF
line = self.file.readline()
- if line == '': line = None
+ if line == '':
+ line = None
if self.strip_comments and line:
@@ -196,7 +186,7 @@ class TextFile:
# lurking in there) and otherwise leave the line alone.
pos = line.find("#")
- if pos == -1: # no "#" -- no comments
+ if pos == -1: # no "#" -- no comments
pass
# It's definitely a comment -- either "#" is the first
@@ -220,17 +210,15 @@ class TextFile:
# result in "hello there".
if line.strip() == "":
continue
-
- else: # it's an escaped "#"
+ else: # it's an escaped "#"
line = line.replace("\\#", "#")
-
# did previous line end with a backslash? then accumulate
if self.join_lines and buildup_line:
# oops: end of file
if line is None:
- self.warn ("continuation line immediately precedes "
- "end-of-file")
+ self.warn("continuation line immediately precedes "
+ "end-of-file")
return buildup_line
if self.collapse_join:
@@ -242,10 +230,10 @@ class TextFile:
self.current_line[1] = self.current_line[1] + 1
else:
self.current_line = [self.current_line,
- self.current_line+1]
+ self.current_line + 1]
# just an ordinary line, read it as usual
else:
- if line is None: # eof
+ if line is None: # eof
return None
# still have to be careful about incrementing the line number!
@@ -254,7 +242,6 @@ class TextFile:
else:
self.current_line = self.current_line + 1
-
# strip whitespace however the client wants (leading and
# trailing, or one or the other, or neither)
if self.lstrip_ws and self.rstrip_ws:
@@ -281,24 +268,18 @@ class TextFile:
# well, I guess there's some actual content there: return it
return line
- # readline ()
-
-
- def readlines (self):
+ def readlines(self):
"""Read and return the list of all logical lines remaining in the
current file."""
-
lines = []
- while 1:
+ while True:
line = self.readline()
if line is None:
return lines
- lines.append (line)
+ lines.append(line)
-
- def unreadline (self, line):
+ def unreadline(self, line):
"""Push 'line' (a string) onto an internal buffer that will be
checked by future 'readline()' calls. Handy for implementing
a parser with line-at-a-time lookahead."""
-
- self.linebuf.append (line)
+ self.linebuf.append(line)
diff --git a/Lib/distutils/unixccompiler.py b/Lib/distutils/unixccompiler.py
index c49ac9ba918..c70a3cc555c 100644
--- a/Lib/distutils/unixccompiler.py
+++ b/Lib/distutils/unixccompiler.py
@@ -13,10 +13,7 @@ the "typical" Unix-style command-line C compiler:
* link shared library handled by 'cc -shared'
"""
-__revision__ = "$Id$"
-
import os, sys, re
-from types import StringType, NoneType
from distutils import sysconfig
from distutils.dep_util import newer
@@ -50,7 +47,7 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
build, without a way to remove an architecture. Furthermore GCC will
barf if multiple '-isysroot' arguments are present.
"""
- stripArch = stripSysroot = 0
+ stripArch = stripSysroot = False
compiler_so = list(compiler_so)
kernel_version = os.uname()[2] # 8.4.3
@@ -65,7 +62,7 @@ def _darwin_compiler_fixup(compiler_so, cc_args):
stripSysroot = '-isysroot' in cc_args
if stripArch or 'ARCHFLAGS' in os.environ:
- while 1:
+ while True:
try:
index = compiler_so.index('-arch')
# Strip this argument and the next one:
@@ -142,11 +139,10 @@ class UnixCCompiler(CCompiler):
if sys.platform == "cygwin":
exe_extension = ".exe"
- def preprocess(self, source,
- output_file=None, macros=None, include_dirs=None,
- extra_preargs=None, extra_postargs=None):
- ignore, macros, include_dirs = \
- self._fix_compile_args(None, macros, include_dirs)
+ def preprocess(self, source, output_file=None, macros=None,
+ include_dirs=None, extra_preargs=None, extra_postargs=None):
+ fixed_args = self._fix_compile_args(None, macros, include_dirs)
+ ignore, macros, include_dirs = fixed_args
pp_opts = gen_preprocess_options(macros, include_dirs)
pp_args = self.preprocessor + pp_opts
if output_file:
@@ -166,8 +162,8 @@ class UnixCCompiler(CCompiler):
self.mkpath(os.path.dirname(output_file))
try:
self.spawn(pp_args)
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
compiler_so = self.compiler_so
@@ -176,8 +172,8 @@ class UnixCCompiler(CCompiler):
try:
self.spawn(compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
- except DistutilsExecError, msg:
- raise CompileError, msg
+ except DistutilsExecError as msg:
+ raise CompileError(msg)
def create_static_lib(self, objects, output_libname,
output_dir=None, debug=0, target_lang=None):
@@ -200,8 +196,8 @@ class UnixCCompiler(CCompiler):
if self.ranlib:
try:
self.spawn(self.ranlib + [output_filename])
- except DistutilsExecError, msg:
- raise LibError, msg
+ except DistutilsExecError as msg:
+ raise LibError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -211,13 +207,14 @@ class UnixCCompiler(CCompiler):
export_symbols=None, debug=0, extra_preargs=None,
extra_postargs=None, build_temp=None, target_lang=None):
objects, output_dir = self._fix_object_args(objects, output_dir)
- libraries, library_dirs, runtime_library_dirs = \
- self._fix_lib_args(libraries, library_dirs, runtime_library_dirs)
+ fixed_args = self._fix_lib_args(libraries, library_dirs,
+ runtime_library_dirs)
+ libraries, library_dirs, runtime_library_dirs = fixed_args
lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs,
libraries)
- if type(output_dir) not in (StringType, NoneType):
- raise TypeError, "'output_dir' must be a string or None"
+ if not isinstance(output_dir, (str, type(None))):
+ raise TypeError("'output_dir' must be a string or None")
if output_dir is not None:
output_filename = os.path.join(output_dir, output_filename)
@@ -246,16 +243,15 @@ class UnixCCompiler(CCompiler):
if os.path.basename(linker[0]) == "env":
i = 1
while '=' in linker[i]:
- i = i + 1
-
+ i += 1
linker[i] = self.compiler_cxx[i]
if sys.platform == 'darwin':
linker = _darwin_compiler_fixup(linker, ld_args)
self.spawn(linker + ld_args)
- except DistutilsExecError, msg:
- raise LinkError, msg
+ except DistutilsExecError as msg:
+ raise LinkError(msg)
else:
log.debug("skipping %s (up-to-date)", output_filename)
@@ -276,8 +272,9 @@ class UnixCCompiler(CCompiler):
# Linkers on different platforms need different options to
# specify that directories need to be added to the list of
# directories searched for dependencies when a dynamic library
- # is sought. GCC has to be told to pass the -R option through
- # to the linker, whereas other compilers just know this.
+ # is sought. GCC on GNU systems (Linux, FreeBSD, ...) has to
+ # be told to pass the -R option through to the linker, whereas
+ # other compilers and gcc on other systems just know this.
# Other compilers may need something slightly different. At
# this time, there's no way to determine this information from
# the configuration data stored in the Python installation, so
@@ -292,10 +289,23 @@ class UnixCCompiler(CCompiler):
return ["+s", "-L" + dir]
elif sys.platform[:7] == "irix646" or sys.platform[:6] == "osf1V5":
return ["-rpath", dir]
- elif self._is_gcc(compiler):
- return "-Wl,-R" + dir
else:
- return "-R" + dir
+ if self._is_gcc(compiler):
+ # gcc on non-GNU systems does not need -Wl, but can
+ # use it anyway. Since distutils has always passed in
+ # -Wl whenever gcc was used in the past it is probably
+ # safest to keep doing so.
+ if sysconfig.get_config_var("GNULD") == "yes":
+ # GNU ld needs an extra option to get a RUNPATH
+ # instead of just an RPATH.
+ return "-Wl,--enable-new-dtags,-R" + dir
+ else:
+ return "-Wl,-R" + dir
+ else:
+ # No idea how --enable-new-dtags would be passed on to
+ # ld if this system was using GNU ld. Don't know if a
+ # system like this even exists.
+ return "-R" + dir
def library_option(self, lib):
return "-l" + lib
diff --git a/Lib/distutils/util.py b/Lib/distutils/util.py
index 0c24e8ca3e1..bce840274dc 100644
--- a/Lib/distutils/util.py
+++ b/Lib/distutils/util.py
@@ -4,9 +4,11 @@ Miscellaneous utility functions -- anything that doesn't fit into
one of the other *util.py modules.
"""
-__revision__ = "$Id$"
-
-import sys, os, string, re
+import os
+import re
+import imp
+import sys
+import string
from distutils.errors import DistutilsPlatformError
from distutils.dep_util import newer
from distutils.spawn import spawn
@@ -40,14 +42,14 @@ def get_platform ():
if os.name == 'nt':
# sniff sys.version for architecture.
prefix = " bit ("
- i = string.find(sys.version, prefix)
+ i = sys.version.find(prefix)
if i == -1:
return sys.platform
- j = string.find(sys.version, ")", i)
+ j = sys.version.find(")", i)
look = sys.version[i+len(prefix):j].lower()
- if look=='amd64':
+ if look == 'amd64':
return 'win-amd64'
- if look=='itanium':
+ if look == 'itanium':
return 'win-ia64'
return sys.platform
@@ -62,10 +64,9 @@ def get_platform ():
# Convert the OS name to lowercase, remove '/' characters
# (to accommodate BSD/OS), and translate spaces (for "Power Macintosh")
- osname = string.lower(osname)
- osname = string.replace(osname, '/', '')
- machine = string.replace(machine, ' ', '_')
- machine = string.replace(machine, '/', '-')
+ osname = osname.lower().replace('/', '')
+ machine = machine.replace(' ', '_')
+ machine = machine.replace('/', '-')
if osname[:5] == "linux":
# At least on Linux/Intel, 'machine' is the processor --
@@ -80,7 +81,7 @@ def get_platform ():
# bootstrap problem. We use a dict to get an error
# if some suspicious happens.
bitness = {2147483647:"32bit", 9223372036854775807:"64bit"}
- machine += ".%s" % bitness[sys.maxint]
+ machine += ".%s" % bitness[sys.maxsize]
# fall through to standard osname-release-machine representation
elif osname[:4] == "irix": # could be "irix64"!
return "%s-%s" % (osname, release)
@@ -88,7 +89,7 @@ def get_platform ():
return "%s-%s.%s" % (osname, version, release)
elif osname[:6] == "cygwin":
osname = "cygwin"
- rel_re = re.compile (r'[\d.]+')
+ rel_re = re.compile (r'[\d.]+', re.ASCII)
m = rel_re.match(release)
if m:
release = m.group()
@@ -171,7 +172,7 @@ def get_platform ():
# On OSX the machine type returned by uname is always the
# 32-bit variant, even if the executable architecture is
# the 64-bit variant
- if sys.maxint >= 2**32:
+ if sys.maxsize >= 2**32:
machine = 'x86_64'
elif machine in ('PowerPC', 'Power_Macintosh'):
@@ -179,7 +180,7 @@ def get_platform ():
machine = 'ppc'
# See 'i386' case
- if sys.maxint >= 2**32:
+ if sys.maxsize >= 2**32:
machine = 'ppc64'
return "%s-%s-%s" % (osname, release, machine)
@@ -201,11 +202,11 @@ def convert_path (pathname):
if not pathname:
return pathname
if pathname[0] == '/':
- raise ValueError, "path '%s' cannot be absolute" % pathname
+ raise ValueError("path '%s' cannot be absolute" % pathname)
if pathname[-1] == '/':
- raise ValueError, "path '%s' cannot end with '/'" % pathname
+ raise ValueError("path '%s' cannot end with '/'" % pathname)
- paths = string.split(pathname, '/')
+ paths = pathname.split('/')
while '.' in paths:
paths.remove('.')
if not paths:
@@ -240,8 +241,7 @@ def change_root (new_root, pathname):
return os.path.join(new_root, path)
else:
- raise DistutilsPlatformError, \
- "nothing known about platform '%s'" % os.name
+ raise DistutilsPlatformError("nothing known about platform '%s'" % os.name)
_environ_checked = 0
@@ -286,8 +286,8 @@ def subst_vars (s, local_vars):
try:
return re.sub(r'\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
- except KeyError, var:
- raise ValueError, "invalid variable '$%s'" % var
+ except KeyError as var:
+ raise ValueError("invalid variable '$%s'" % var)
# subst_vars ()
@@ -309,7 +309,7 @@ def grok_environment_error (exc, prefix="error: "):
# include the filename in the exception object!
error = prefix + "%s" % exc.strerror
else:
- error = prefix + str(exc[-1])
+ error = prefix + str(exc.args[-1])
return error
@@ -338,7 +338,7 @@ def split_quoted (s):
# bit of a brain-bender to get it working right, though...
if _wordchars_re is None: _init_regex()
- s = string.strip(s)
+ s = s.strip()
words = []
pos = 0
@@ -351,7 +351,7 @@ def split_quoted (s):
if s[end] in string.whitespace: # unescaped, unquoted whitespace: now
words.append(s[:end]) # we definitely have a word delimiter
- s = string.lstrip(s[end:])
+ s = s[end:].lstrip()
pos = 0
elif s[end] == '\\': # preserve whatever is being escaped;
@@ -365,12 +365,10 @@ def split_quoted (s):
elif s[end] == '"': # slurp doubly-quoted string
m = _dquote_re.match(s, end)
else:
- raise RuntimeError, \
- "this can't happen (bad char '%c')" % s[end]
+ raise RuntimeError("this can't happen (bad char '%c')" % s[end])
if m is None:
- raise ValueError, \
- "bad string (mismatched %s quotes?)" % s[end]
+ raise ValueError("bad string (mismatched %s quotes?)" % s[end])
(beg, end) = m.span()
s = s[:beg] + s[beg+1:end-1] + s[end:]
@@ -411,13 +409,13 @@ def strtobool (val):
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
- val = string.lower(val)
+ val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
else:
- raise ValueError, "invalid truth value %r" % (val,)
+ raise ValueError("invalid truth value %r" % (val,))
def byte_compile (py_files,
@@ -426,9 +424,9 @@ def byte_compile (py_files,
verbose=1, dry_run=0,
direct=None):
"""Byte-compile a collection of Python source files to either .pyc
- or .pyo files in the same directory. 'py_files' is a list of files
- to compile; any files that don't end in ".py" are silently skipped.
- 'optimize' must be one of the following:
+ or .pyo files in a __pycache__ subdirectory. 'py_files' is a list
+ of files to compile; any files that don't end in ".py" are silently
+ skipped. 'optimize' must be one of the following:
0 - don't optimize (generate .pyc)
1 - normal optimization (like "python -O")
2 - extra optimization (like "python -OO")
@@ -505,7 +503,7 @@ files = [
#if prefix:
# prefix = os.path.abspath(prefix)
- script.write(string.join(map(repr, py_files), ",\n") + "]\n")
+ script.write(",\n".join(map(repr, py_files)) + "]\n")
script.write("""
byte_compile(files, optimize=%r, force=%r,
prefix=%r, base_dir=%r,
@@ -540,12 +538,14 @@ byte_compile(files, optimize=%r, force=%r,
# Terminology from the py_compile module:
# cfile - byte-compiled file
# dfile - purported source filename (same as 'file' by default)
- cfile = file + (__debug__ and "c" or "o")
+ if optimize >= 0:
+ cfile = imp.cache_from_source(file, debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(file)
dfile = file
if prefix:
if file[:len(prefix)] != prefix:
- raise ValueError, \
- ("invalid prefix: filename %r doesn't start with %r"
+ raise ValueError("invalid prefix: filename %r doesn't start with %r"
% (file, prefix))
dfile = dfile[len(prefix):]
if base_dir:
@@ -567,6 +567,87 @@ def rfc822_escape (header):
"""Return a version of the string escaped for inclusion in an
RFC-822 header, by ensuring there are 8 spaces space after each newline.
"""
- lines = string.split(header, '\n')
- header = string.join(lines, '\n' + 8*' ')
- return header
+ lines = header.split('\n')
+ sep = '\n' + 8 * ' '
+ return sep.join(lines)
+
+# 2to3 support
+
+def run_2to3(files, fixer_names=None, options=None, explicit=None):
+ """Invoke 2to3 on a list of Python files.
+ The files should all come from the build area, as the
+ modification is done in-place. To reduce the build time,
+ only files modified since the last invocation of this
+ function should be passed in the files argument."""
+
+ if not files:
+ return
+
+ # Make this class local, to delay import of 2to3
+ from lib2to3.refactor import RefactoringTool, get_fixers_from_package
+ class DistutilsRefactoringTool(RefactoringTool):
+ def log_error(self, msg, *args, **kw):
+ log.error(msg, *args)
+
+ def log_message(self, msg, *args):
+ log.info(msg, *args)
+
+ def log_debug(self, msg, *args):
+ log.debug(msg, *args)
+
+ if fixer_names is None:
+ fixer_names = get_fixers_from_package('lib2to3.fixes')
+ r = DistutilsRefactoringTool(fixer_names, options=options)
+ r.refactor(files, write=True)
+
+def copydir_run_2to3(src, dest, template=None, fixer_names=None,
+ options=None, explicit=None):
+ """Recursively copy a directory, only copying new and changed files,
+ running run_2to3 over all newly copied Python modules afterward.
+
+ If you give a template string, it's parsed like a MANIFEST.in.
+ """
+ from distutils.dir_util import mkpath
+ from distutils.file_util import copy_file
+ from distutils.filelist import FileList
+ filelist = FileList()
+ curdir = os.getcwd()
+ os.chdir(src)
+ try:
+ filelist.findall()
+ finally:
+ os.chdir(curdir)
+ filelist.files[:] = filelist.allfiles
+ if template:
+ for line in template.splitlines():
+ line = line.strip()
+ if not line: continue
+ filelist.process_template_line(line)
+ copied = []
+ for filename in filelist.files:
+ outname = os.path.join(dest, filename)
+ mkpath(os.path.dirname(outname))
+ res = copy_file(os.path.join(src, filename), outname, update=1)
+ if res[1]: copied.append(outname)
+ run_2to3([fn for fn in copied if fn.lower().endswith('.py')],
+ fixer_names=fixer_names, options=options, explicit=explicit)
+ return copied
+
+class Mixin2to3:
+ '''Mixin class for commands that run 2to3.
+ To configure 2to3, setup scripts may either change
+ the class variables, or inherit from individual commands
+ to override how 2to3 is invoked.'''
+
+ # provide list of fixers to run;
+ # defaults to all from lib2to3.fixers
+ fixer_names = None
+
+ # options dictionary
+ options = None
+
+ # list of fixers to invoke even though they are marked as explicit
+ explicit = None
+
+ def run_2to3(self, files):
+ return run_2to3(files, self.fixer_names, self.options, self.explicit)
diff --git a/Lib/distutils/version.py b/Lib/distutils/version.py
index 0fb5b6e2041..ebcab84e4e2 100644
--- a/Lib/distutils/version.py
+++ b/Lib/distutils/version.py
@@ -21,18 +21,18 @@ Every version number class implements the following interface:
an equivalent string -- ie. one that will generate an equivalent
version number instance)
* __repr__ generates Python code to recreate the version number instance
- * __cmp__ compares the current instance with either another instance
+ * _cmp compares the current instance with either another instance
of the same class or a string (which will be parsed to an instance
of the same class, thus must follow the same rules)
"""
-import string, re
-from types import StringType
+import re
class Version:
"""Abstract base class for version numbering classes. Just provides
constructor (__init__) and reproducer (__repr__), because those
- seem to be the same for all version numbering classes.
+ seem to be the same for all version numbering classes; and route
+ rich comparisons to _cmp.
"""
def __init__ (self, vstring=None):
@@ -42,6 +42,42 @@ class Version:
def __repr__ (self):
return "%s ('%s')" % (self.__class__.__name__, str(self))
+ def __eq__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c == 0
+
+ def __ne__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c != 0
+
+ def __lt__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c < 0
+
+ def __le__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c <= 0
+
+ def __gt__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c > 0
+
+ def __ge__(self, other):
+ c = self._cmp(other)
+ if c is NotImplemented:
+ return c
+ return c >= 0
+
# Interface for version-number classes -- must be implemented
# by the following classes (the concrete ones -- Version should
@@ -55,7 +91,7 @@ class Version:
# (if not identical to) the string supplied to parse
# __repr__ (self) - generate Python code to recreate
# the instance
-# __cmp__ (self, other) - compare two version numbers ('other' may
+# _cmp (self, other) - compare two version numbers ('other' may
# be an unparsed version string, or another
# instance of your version class)
@@ -98,24 +134,24 @@ class StrictVersion (Version):
"""
version_re = re.compile(r'^(\d+) \. (\d+) (\. (\d+))? ([ab](\d+))?$',
- re.VERBOSE)
+ re.VERBOSE | re.ASCII)
def parse (self, vstring):
match = self.version_re.match(vstring)
if not match:
- raise ValueError, "invalid version number '%s'" % vstring
+ raise ValueError("invalid version number '%s'" % vstring)
(major, minor, patch, prerelease, prerelease_num) = \
match.group(1, 2, 4, 5, 6)
if patch:
- self.version = tuple(map(string.atoi, [major, minor, patch]))
+ self.version = tuple(map(int, [major, minor, patch]))
else:
- self.version = tuple(map(string.atoi, [major, minor]) + [0])
+ self.version = tuple(map(int, [major, minor])) + (0,)
if prerelease:
- self.prerelease = (prerelease[0], string.atoi(prerelease_num))
+ self.prerelease = (prerelease[0], int(prerelease_num))
else:
self.prerelease = None
@@ -123,9 +159,9 @@ class StrictVersion (Version):
def __str__ (self):
if self.version[2] == 0:
- vstring = string.join(map(str, self.version[0:2]), '.')
+ vstring = '.'.join(map(str, self.version[0:2]))
else:
- vstring = string.join(map(str, self.version), '.')
+ vstring = '.'.join(map(str, self.version))
if self.prerelease:
vstring = vstring + self.prerelease[0] + str(self.prerelease[1])
@@ -133,30 +169,39 @@ class StrictVersion (Version):
return vstring
- def __cmp__ (self, other):
- if isinstance(other, StringType):
+ def _cmp (self, other):
+ if isinstance(other, str):
other = StrictVersion(other)
- compare = cmp(self.version, other.version)
- if (compare == 0): # have to compare prerelease
-
- # case 1: neither has prerelease; they're equal
- # case 2: self has prerelease, other doesn't; other is greater
- # case 3: self doesn't have prerelease, other does: self is greater
- # case 4: both have prerelease: must compare them!
+ if self.version != other.version:
+ # numeric versions don't match
+ # prerelease stuff doesn't matter
+ if self.version < other.version:
+ return -1
+ else:
+ return 1
- if (not self.prerelease and not other.prerelease):
+ # have to compare prerelease
+ # case 1: neither has prerelease; they're equal
+ # case 2: self has prerelease, other doesn't; other is greater
+ # case 3: self doesn't have prerelease, other does: self is greater
+ # case 4: both have prerelease: must compare them!
+
+ if (not self.prerelease and not other.prerelease):
+ return 0
+ elif (self.prerelease and not other.prerelease):
+ return -1
+ elif (not self.prerelease and other.prerelease):
+ return 1
+ elif (self.prerelease and other.prerelease):
+ if self.prerelease == other.prerelease:
return 0
- elif (self.prerelease and not other.prerelease):
+ elif self.prerelease < other.prerelease:
return -1
- elif (not self.prerelease and other.prerelease):
+ else:
return 1
- elif (self.prerelease and other.prerelease):
- return cmp(self.prerelease, other.prerelease)
-
- else: # numeric versions don't match --
- return compare # prerelease stuff doesn't matter
-
+ else:
+ assert False, "never get here"
# end class StrictVersion
@@ -270,11 +315,11 @@ class LooseVersion (Version):
# from the parsed tuple -- so I just store the string here for
# use by __str__
self.vstring = vstring
- components = filter(lambda x: x and x != '.',
- self.component_re.split(vstring))
- for i in range(len(components)):
+ components = [x for x in self.component_re.split(vstring)
+ if x and x != '.']
+ for i, obj in enumerate(components):
try:
- components[i] = int(components[i])
+ components[i] = int(obj)
except ValueError:
pass
@@ -289,11 +334,16 @@ class LooseVersion (Version):
return "LooseVersion ('%s')" % str(self)
- def __cmp__ (self, other):
- if isinstance(other, StringType):
+ def _cmp (self, other):
+ if isinstance(other, str):
other = LooseVersion(other)
- return cmp(self.version, other.version)
+ if self.version == other.version:
+ return 0
+ if self.version < other.version:
+ return -1
+ if self.version > other.version:
+ return 1
# end class LooseVersion
diff --git a/Lib/distutils/versionpredicate.py b/Lib/distutils/versionpredicate.py
index ba8b6c021b2..b0dd9f45bff 100644
--- a/Lib/distutils/versionpredicate.py
+++ b/Lib/distutils/versionpredicate.py
@@ -5,7 +5,8 @@ import distutils.version
import operator
-re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)")
+re_validPackage = re.compile(r"(?i)^\s*([a-z_]\w*(?:\.[a-z_]\w*)*)(.*)",
+ re.ASCII)
# (package) (rest)
re_paren = re.compile(r"^\s*\((.*)\)\s*$") # (list) inside of parentheses
@@ -40,7 +41,7 @@ class VersionPredicate:
The str() of a `VersionPredicate` provides a normalized
human-readable version of the expression::
- >>> print v
+ >>> print(v)
pyepat.abc (> 1.0, < 3333.3a1, != 1555.1b3)
The `satisfied_by()` method can be used to determine with a given
@@ -153,7 +154,8 @@ def split_provision(value):
global _provision_rx
if _provision_rx is None:
_provision_rx = re.compile(
- "([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$")
+ "([a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)(?:\s*\(\s*([^)\s]+)\s*\))?$",
+ re.ASCII)
value = value.strip()
m = _provision_rx.match(value)
if not m:
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 90bcca1fdbe..e189c8feba3 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -80,13 +80,11 @@ __all__ = [
'testmod',
'testfile',
'run_docstring_examples',
- # 7. Tester
- 'Tester',
- # 8. Unittest Support
+ # 7. Unittest Support
'DocTestSuite',
'DocFileSuite',
'set_unittest_reportflags',
- # 9. Debugging Support
+ # 8. Debugging Support
'script_from_examples',
'testsource',
'debug_src',
@@ -94,11 +92,16 @@ __all__ = [
]
import __future__
-
-import sys, traceback, inspect, linecache, os, re
-import unittest, difflib, pdb, tempfile
-import warnings
-from StringIO import StringIO
+import difflib
+import inspect
+import linecache
+import os
+import pdb
+import re
+import sys
+import traceback
+import unittest
+from io import StringIO
from collections import namedtuple
TestResults = namedtuple('TestResults', 'failed attempted')
@@ -166,10 +169,9 @@ ELLIPSIS_MARKER = '...'
# 4. DocTest Finder -- extracts test cases from objects
# 5. DocTest Runner -- runs test cases
# 6. Test Functions -- convenient wrappers for testing
-# 7. Tester Class -- for backwards compatibility
-# 8. Unittest Support
-# 9. Debugging Support
-# 10. Example Usage
+# 7. Unittest Support
+# 8. Debugging Support
+# 9. Example Usage
######################################################################
## 1. Utility Functions
@@ -199,38 +201,32 @@ def _normalize_module(module, depth=2):
"""
if inspect.ismodule(module):
return module
- elif isinstance(module, (str, unicode)):
+ elif isinstance(module, str):
return __import__(module, globals(), locals(), ["*"])
elif module is None:
return sys.modules[sys._getframe(depth).f_globals['__name__']]
else:
raise TypeError("Expected a module, string, or None")
-def _load_testfile(filename, package, module_relative):
+def _load_testfile(filename, package, module_relative, encoding):
if module_relative:
package = _normalize_module(package, 3)
filename = _module_relative_path(package, filename)
if hasattr(package, '__loader__'):
if hasattr(package.__loader__, 'get_data'):
file_contents = package.__loader__.get_data(filename)
+ file_contents = file_contents.decode(encoding)
# 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
- with open(filename) as f:
+ with open(filename, encoding=encoding) as f:
return f.read(), filename
-# Use sys.stdout encoding for ouput.
-_encoding = getattr(sys.__stdout__, 'encoding', None) or 'utf-8'
-
def _indent(s, indent=4):
"""
Add the given number of space characters to the beginning of
every non-blank line in `s`, and return the result.
- If the string `s` is Unicode, it is encoded using the stdout
- encoding and the `backslashreplace` error handler.
"""
- if isinstance(s, unicode):
- s = s.encode(_encoding, 'backslashreplace')
# This regexp matches the start of non-blank lines:
return re.sub('(?m)^(?!$)', indent*' ', s)
@@ -254,19 +250,11 @@ class _SpoofOut(StringIO):
# that a trailing newline is missing.
if result and not result.endswith("\n"):
result += "\n"
- # Prevent softspace from screwing up the next test case, in
- # case they used print with a trailing comma in an example.
- if hasattr(self, "softspace"):
- del self.softspace
return result
- def truncate(self, size=None):
- StringIO.truncate(self, size)
- if hasattr(self, "softspace"):
- del self.softspace
- if not self.buf:
- # Reset it to an empty string, to make sure it's not unicode.
- self.buf = ''
+ def truncate(self, size=None):
+ self.seek(size)
+ StringIO.truncate(self)
# Worst-case linear-time ellipsis matching.
def _ellipsis_match(want, got):
@@ -335,7 +323,8 @@ class _OutputRedirectingPdb(pdb.Pdb):
def __init__(self, out):
self.__out = out
self.__debugger_used = False
- pdb.Pdb.__init__(self, stdout=out)
+ # do not play signal games in the pdb
+ pdb.Pdb.__init__(self, stdout=out, nosigint=True)
# still use input() to get user input
self.use_rawinput = 1
@@ -364,9 +353,9 @@ class _OutputRedirectingPdb(pdb.Pdb):
# [XX] Normalize with respect to os.path.pardir?
def _module_relative_path(module, path):
if not inspect.ismodule(module):
- raise TypeError, 'Expected a module: %r' % module
+ raise TypeError('Expected a module: %r' % module)
if path.startswith('/'):
- raise ValueError, 'Module-relative files may not have absolute paths'
+ raise ValueError('Module-relative files may not have absolute paths')
# Find the base directory for the path.
if hasattr(module, '__file__'):
@@ -499,7 +488,7 @@ class DocTest:
Create a new DocTest containing the given examples. The
DocTest's globals are initialized with a copy of `globs`.
"""
- assert not isinstance(examples, basestring), \
+ assert not isinstance(examples, str), \
"DocTest no longer accepts str; use DocTestParser instead"
self.examples = examples
self.docstring = docstring
@@ -536,11 +525,12 @@ class DocTest:
return hash((self.docstring, self.name, self.filename, self.lineno))
# This lets us sort tests by name:
- def __cmp__(self, other):
+ def __lt__(self, other):
if not isinstance(other, DocTest):
- return -1
- return cmp((self.name, self.filename, self.lineno, id(self)),
- (other.name, other.filename, other.lineno, id(other)))
+ return NotImplemented
+ return ((self.name, self.filename, self.lineno, id(self))
+ <
+ (other.name, other.filename, other.lineno, id(other)))
######################################################################
## 3. DocTestParser
@@ -867,20 +857,29 @@ class DocTestFinder:
# DocTestFinder._find_lineno to find the line number for a
# given object's docstring.
try:
- file = inspect.getsourcefile(obj) or inspect.getfile(obj)
- if module is not None:
- # Supply the module globals in case the module was
- # originally loaded via a PEP 302 loader and
- # file is not a valid filesystem path
- source_lines = linecache.getlines(file, module.__dict__)
- else:
- # No access to a loader, so assume it's a normal
- # filesystem path
- source_lines = linecache.getlines(file)
- if not source_lines:
- source_lines = None
+ file = inspect.getsourcefile(obj)
except TypeError:
source_lines = None
+ else:
+ if not file:
+ # Check to see if it's one of our special internal "files"
+ # (see __patched_linecache_getlines).
+ file = inspect.getfile(obj)
+ if not file[0]+file[-2:] == '<]>': file = None
+ if file is None:
+ source_lines = None
+ else:
+ if module is not None:
+ # Supply the module globals in case the module was
+ # originally loaded via a PEP 302 loader and
+ # file is not a valid filesystem path
+ source_lines = linecache.getlines(file, module.__dict__)
+ else:
+ # No access to a loader, so assume it's a normal
+ # filesystem path
+ source_lines = linecache.getlines(file)
+ if not source_lines:
+ source_lines = None
# Initialize globals, and merge in extraglobs.
if globs is None:
@@ -915,7 +914,7 @@ class DocTestFinder:
elif inspect.getmodule(object) is not None:
return module is inspect.getmodule(object)
elif inspect.isfunction(object):
- return module.__dict__ is object.func_globals
+ return module.__dict__ is object.__globals__
elif inspect.isclass(object):
return module.__name__ == object.__module__
elif hasattr(object, '__module__'):
@@ -931,7 +930,7 @@ class DocTestFinder:
add them to `tests`.
"""
if self._verbose:
- print 'Finding tests in %s' % name
+ print('Finding tests in %s' % name)
# If we've already processed this object, then ignore it.
if id(obj) in seen:
@@ -956,13 +955,13 @@ class DocTestFinder:
# Look for tests in a module's __test__ dictionary.
if inspect.ismodule(obj) and self._recurse:
for valname, val in getattr(obj, '__test__', {}).items():
- if not isinstance(valname, basestring):
+ if not isinstance(valname, str):
raise ValueError("DocTestFinder.find: __test__ keys "
"must be strings: %r" %
(type(valname),))
if not (inspect.isfunction(val) or inspect.isclass(val) or
inspect.ismethod(val) or inspect.ismodule(val) or
- isinstance(val, basestring)):
+ isinstance(val, str)):
raise ValueError("DocTestFinder.find: __test__ values "
"must be strings, functions, methods, "
"classes, or modules: %r" %
@@ -978,7 +977,7 @@ class DocTestFinder:
if isinstance(val, staticmethod):
val = getattr(obj, valname)
if isinstance(val, classmethod):
- val = getattr(obj, valname).im_func
+ val = getattr(obj, valname).__func__
# Recurse to methods, properties, and nested classes.
if ((inspect.isfunction(val) or inspect.isclass(val) or
@@ -995,7 +994,7 @@ class DocTestFinder:
"""
# Extract the object's docstring. If it doesn't have one,
# then return None (no test for this object).
- if isinstance(obj, basestring):
+ if isinstance(obj, str):
docstring = obj
else:
try:
@@ -1003,7 +1002,7 @@ class DocTestFinder:
docstring = ''
else:
docstring = obj.__doc__
- if not isinstance(docstring, basestring):
+ if not isinstance(docstring, str):
docstring = str(docstring)
except (TypeError, AttributeError):
docstring = ''
@@ -1050,8 +1049,8 @@ class DocTestFinder:
break
# Find the line number for functions & methods.
- if inspect.ismethod(obj): obj = obj.im_func
- if inspect.isfunction(obj): obj = obj.func_code
+ if inspect.ismethod(obj): obj = obj.__func__
+ if inspect.isfunction(obj): obj = obj.__code__
if inspect.istraceback(obj): obj = obj.tb_frame
if inspect.isframe(obj): obj = obj.f_code
if inspect.iscode(obj):
@@ -1088,7 +1087,7 @@ class DocTestRunner:
>>> runner = DocTestRunner(verbose=False)
>>> tests.sort(key = lambda test: test.name)
>>> for test in tests:
- ... print test.name, '->', runner.run(test)
+ ... print(test.name, '->', runner.run(test))
_TestClass -> TestResults(failed=0, attempted=2)
_TestClass.__init__ -> TestResults(failed=0, attempted=2)
_TestClass.get -> TestResults(failed=0, attempted=2)
@@ -1285,8 +1284,8 @@ class DocTestRunner:
# keyboard interrupts.)
try:
# Don't blink! This is where the user's code gets run.
- exec compile(example.source, filename, "single",
- compileflags, 1) in test.globs
+ exec(compile(example.source, filename, "single",
+ compileflags, 1), test.globs)
self.debugger.set_continue() # ==== Example Finished ====
exception = None
except KeyboardInterrupt:
@@ -1307,10 +1306,9 @@ class DocTestRunner:
# The example raised an exception: check if it was expected.
else:
- exc_info = sys.exc_info()
- exc_msg = traceback.format_exception_only(*exc_info[:2])[-1]
+ exc_msg = traceback.format_exception_only(*exception[:2])[-1]
if not quiet:
- got += _exception_traceback(exc_info)
+ got += _exception_traceback(exception)
# If `example.exc_msg` is None, then we weren't expecting
# an exception.
@@ -1340,7 +1338,7 @@ class DocTestRunner:
elif outcome is BOOM:
if not quiet:
self.report_unexpected_exception(out, test, example,
- exc_info)
+ exception)
failures += 1
else:
assert False, ("unknown outcome", outcome)
@@ -1369,10 +1367,7 @@ class DocTestRunner:
m = self.__LINECACHE_FILENAME_RE.match(filename)
if m and m.group('name') == self.test.name:
example = self.test.examples[int(m.group('examplenum'))]
- source = example.source
- if isinstance(source, unicode):
- source = source.encode('ascii', 'backslashreplace')
- return source.splitlines(True)
+ return example.source.splitlines(True)
else:
return self.save_linecache_getlines(filename, module_globals)
@@ -1403,7 +1398,14 @@ class DocTestRunner:
save_stdout = sys.stdout
if out is None:
- out = save_stdout.write
+ encoding = save_stdout.encoding
+ if encoding is None or encoding.lower() == 'utf-8':
+ out = save_stdout.write
+ else:
+ # Use backslashreplace error handling on write
+ def out(s):
+ s = str(s.encode(encoding, 'backslashreplace'), encoding)
+ save_stdout.write(s)
sys.stdout = self._fakeout
# Patch pdb.set_trace to restore sys.stdout during interactive
@@ -1434,6 +1436,8 @@ class DocTestRunner:
sys.displayhook = save_displayhook
if clear_globs:
test.globs.clear()
+ import builtins
+ builtins._ = None
#/////////////////////////////////////////////////////////////////
# Summarization
@@ -1468,28 +1472,28 @@ class DocTestRunner:
failed.append(x)
if verbose:
if notests:
- print len(notests), "items had no tests:"
+ print(len(notests), "items had no tests:")
notests.sort()
for thing in notests:
- print " ", thing
+ print(" ", thing)
if passed:
- print len(passed), "items passed all tests:"
+ print(len(passed), "items passed all tests:")
passed.sort()
for thing, count in passed:
- print " %3d tests in %s" % (count, thing)
+ print(" %3d tests in %s" % (count, thing))
if failed:
- print self.DIVIDER
- print len(failed), "items had failures:"
+ print(self.DIVIDER)
+ print(len(failed), "items had failures:")
failed.sort()
for thing, (f, t) in failed:
- print " %3d of %3d in %s" % (f, t, thing)
+ print(" %3d of %3d in %s" % (f, t, thing))
if verbose:
- print totalt, "tests in", len(self._name2ft), "items."
- print totalt - totalf, "passed and", totalf, "failed."
+ print(totalt, "tests in", len(self._name2ft), "items.")
+ print(totalt - totalf, "passed and", totalf, "failed.")
if totalf:
- print "***Test Failed***", totalf, "failures."
+ print("***Test Failed***", totalf, "failures.")
elif verbose:
- print "Test passed."
+ print("Test passed.")
return TestResults(totalf, totalt)
#/////////////////////////////////////////////////////////////////
@@ -1501,8 +1505,8 @@ class DocTestRunner:
if name in d:
# Don't print here by default, since doing
# so breaks some of the buildbots
- #print "*** DocTestRunner.merge: '" + name + "' in both" \
- # " testers; summing outcomes."
+ #print("*** DocTestRunner.merge: '" + name + "' in both" \
+ # " testers; summing outcomes.")
f2, t2 = d[name]
f = f + f2
t = t + t2
@@ -1516,6 +1520,12 @@ class OutputChecker:
and returns true if they match; and `output_difference`, which
returns a string describing the differences between two outputs.
"""
+ def _toAscii(self, s):
+ """
+ Convert string to hex-escaped ASCII string.
+ """
+ return str(s.encode('ASCII', 'backslashreplace'), "ASCII")
+
def check_output(self, want, got, optionflags):
"""
Return True iff the actual output from an example (`got`)
@@ -1526,6 +1536,15 @@ class OutputChecker:
documentation for `TestRunner` for more information about
option flags.
"""
+
+ # If `want` contains hex-escaped character such as "\u1234",
+ # then `want` is a string of six characters(e.g. [\,u,1,2,3,4]).
+ # On the other hand, `got` could be an another sequence of
+ # characters such as [\u1234], so `want` and `got` should
+ # be folded to hex-escaped ASCII string to compare.
+ got = self._toAscii(got)
+ want = self._toAscii(want)
+
# Handle the common case first, for efficiency:
# if they're string-identical, always return true.
if got == want:
@@ -1690,8 +1709,8 @@ class DebugRunner(DocTestRunner):
... {}, 'foo', 'foo.py', 0)
>>> try:
... runner.run(test)
- ... except UnexpectedException, failure:
- ... pass
+ ... except UnexpectedException as f:
+ ... failure = f
>>> failure.test is test
True
@@ -1700,7 +1719,7 @@ class DebugRunner(DocTestRunner):
'42\n'
>>> exc_info = failure.exc_info
- >>> raise exc_info[0], exc_info[1], exc_info[2]
+ >>> raise exc_info[1] # Already has the traceback
Traceback (most recent call last):
...
KeyError
@@ -1718,8 +1737,8 @@ class DebugRunner(DocTestRunner):
>>> try:
... runner.run(test)
- ... except DocTestFailure, failure:
- ... pass
+ ... except DocTestFailure as f:
+ ... failure = f
DocTestFailure objects provide access to the test:
@@ -1750,7 +1769,7 @@ class DebugRunner(DocTestRunner):
>>> runner.run(test)
Traceback (most recent call last):
...
- UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
+ doctest.UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>
>>> del test.globs['__builtins__']
>>> test.globs
@@ -1982,7 +2001,8 @@ def testfile(filename, module_relative=True, name=None, package=None,
"relative paths.")
# Relativize the path
- text, filename = _load_testfile(filename, package, module_relative)
+ text, filename = _load_testfile(filename, package, module_relative,
+ encoding or "utf-8")
# If no name was given, then use the file's name.
if name is None:
@@ -2003,9 +2023,6 @@ def testfile(filename, module_relative=True, name=None, package=None,
else:
runner = DocTestRunner(verbose=verbose, optionflags=optionflags)
- if encoding is not None:
- text = text.decode(encoding)
-
# Read the file, convert it to a test, and run it.
test = parser.get_doctest(text, globs, name, filename, 0)
runner.run(test)
@@ -2044,72 +2061,7 @@ def run_docstring_examples(f, globs, verbose=False, name="NoName",
runner.run(test, compileflags=compileflags)
######################################################################
-## 7. Tester
-######################################################################
-# This is provided only for backwards compatibility. It's not
-# actually used in any way.
-
-class Tester:
- def __init__(self, mod=None, globs=None, verbose=None, optionflags=0):
-
- warnings.warn("class Tester is deprecated; "
- "use class doctest.DocTestRunner instead",
- DeprecationWarning, stacklevel=2)
- if mod is None and globs is None:
- raise TypeError("Tester.__init__: must specify mod or globs")
- if mod is not None and not inspect.ismodule(mod):
- raise TypeError("Tester.__init__: mod must be a module; %r" %
- (mod,))
- if globs is None:
- globs = mod.__dict__
- self.globs = globs
-
- self.verbose = verbose
- self.optionflags = optionflags
- self.testfinder = DocTestFinder()
- self.testrunner = DocTestRunner(verbose=verbose,
- optionflags=optionflags)
-
- def runstring(self, s, name):
- test = DocTestParser().get_doctest(s, self.globs, name, None, None)
- if self.verbose:
- print "Running string", name
- (f,t) = self.testrunner.run(test)
- if self.verbose:
- print f, "of", t, "examples failed in string", name
- return TestResults(f,t)
-
- def rundoc(self, object, name=None, module=None):
- f = t = 0
- tests = self.testfinder.find(object, name, module=module,
- globs=self.globs)
- for test in tests:
- (f2, t2) = self.testrunner.run(test)
- (f,t) = (f+f2, t+t2)
- return TestResults(f,t)
-
- def rundict(self, d, name, module=None):
- import types
- m = types.ModuleType(name)
- m.__dict__.update(d)
- if module is None:
- module = False
- return self.rundoc(m, name, module)
-
- def run__test__(self, d, name):
- import types
- m = types.ModuleType(name)
- m.__test__ = d
- return self.rundoc(m, name)
-
- def summarize(self, verbose=None):
- return self.testrunner.summarize(verbose)
-
- def merge(self, other):
- self.testrunner.merge(other.testrunner)
-
-######################################################################
-## 8. Unittest Support
+## 7. Unittest Support
######################################################################
_unittest_reportflags = 0
@@ -2229,8 +2181,8 @@ class DocTestCase(unittest.TestCase):
>>> case = DocTestCase(test)
>>> try:
... case.debug()
- ... except UnexpectedException, failure:
- ... pass
+ ... except UnexpectedException as f:
+ ... failure = f
The UnexpectedException contains the test, the example, and
the original exception:
@@ -2242,7 +2194,7 @@ class DocTestCase(unittest.TestCase):
'42\n'
>>> exc_info = failure.exc_info
- >>> raise exc_info[0], exc_info[1], exc_info[2]
+ >>> raise exc_info[1] # Already has the traceback
Traceback (most recent call last):
...
KeyError
@@ -2258,8 +2210,8 @@ class DocTestCase(unittest.TestCase):
>>> try:
... case.debug()
- ... except DocTestFailure, failure:
- ... pass
+ ... except DocTestFailure as f:
+ ... failure = f
DocTestFailure objects provide access to the test:
@@ -2430,7 +2382,8 @@ def DocFileTest(path, module_relative=True, package=None,
"relative paths.")
# Relativize the path.
- doc, path = _load_testfile(path, package, module_relative)
+ doc, path = _load_testfile(path, package, module_relative,
+ encoding or "utf-8")
if "__file__" not in globs:
globs["__file__"] = path
@@ -2438,10 +2391,6 @@ def DocFileTest(path, module_relative=True, package=None,
# Find the file and read it.
name = os.path.basename(path)
- # If an encoding is specified, use it to convert the file to unicode
- if encoding is not None:
- doc = doc.decode(encoding)
-
# Convert it to a test, and wrap it in a DocFileCase.
test = parser.get_doctest(doc, globs, name, path, 0)
return DocFileCase(test, **options)
@@ -2516,7 +2465,7 @@ def DocFileSuite(*paths, **kw):
return suite
######################################################################
-## 9. Debugging Support
+## 8. Debugging Support
######################################################################
def script_from_examples(s):
@@ -2551,7 +2500,7 @@ def script_from_examples(s):
... Ho hum
... '''
- >>> print script_from_examples(text)
+ >>> print(script_from_examples(text))
# Here are examples of simple math.
#
# Python has super accurate integer addition
@@ -2626,33 +2575,21 @@ def debug_script(src, pm=False, globs=None):
"Debug a test script. `src` is the script, as a string."
import pdb
- # Note that tempfile.NameTemporaryFile() cannot be used. As the
- # docs say, a file so created cannot be opened by name a second time
- # on modern Windows boxes, and execfile() needs to open it.
- srcfilename = tempfile.mktemp(".py", "doctestdebug")
- f = open(srcfilename, 'w')
- f.write(src)
- f.close()
-
- try:
- if globs:
- globs = globs.copy()
- else:
- globs = {}
-
- if pm:
- try:
- execfile(srcfilename, globs, globs)
- except:
- print sys.exc_info()[1]
- pdb.post_mortem(sys.exc_info()[2])
- else:
- # Note that %r is vital here. '%s' instead can, e.g., cause
- # backslashes to get treated as metacharacters on Windows.
- pdb.run("execfile(%r)" % srcfilename, globs, globs)
+ if globs:
+ globs = globs.copy()
+ else:
+ globs = {}
- finally:
- os.remove(srcfilename)
+ if pm:
+ try:
+ exec(src, globs, globs)
+ except:
+ print(sys.exc_info()[1])
+ p = pdb.Pdb(nosigint=True)
+ p.reset()
+ p.interaction(None, sys.exc_info()[2])
+ else:
+ pdb.Pdb(nosigint=True).run("exec(%r)" % src, globs, globs)
def debug(module, name, pm=False):
"""Debug a single doctest docstring.
@@ -2666,7 +2603,7 @@ def debug(module, name, pm=False):
debug_script(testsrc, pm, module.__dict__)
######################################################################
-## 10. Example Usage
+## 9. Example Usage
######################################################################
class _TestClass:
"""
@@ -2686,7 +2623,7 @@ class _TestClass:
"""val -> _TestClass object with associated value val.
>>> t = _TestClass(123)
- >>> print t.get()
+ >>> print(t.get())
123
"""
@@ -2706,7 +2643,7 @@ class _TestClass:
"""get() -> return TestClass's associated value.
>>> x = _TestClass(-42)
- >>> print x.get()
+ >>> print(x.get())
-42
"""
@@ -2738,7 +2675,7 @@ __test__ = {"_TestClass": _TestClass,
"blank lines": r"""
Blank lines can be marked with <BLANKLINE>:
- >>> print 'foo\n\nbar\n'
+ >>> print('foo\n\nbar\n')
foo
<BLANKLINE>
bar
@@ -2748,14 +2685,14 @@ __test__ = {"_TestClass": _TestClass,
"ellipsis": r"""
If the ellipsis flag is used, then '...' can be used to
elide substrings in the desired output:
- >>> print range(1000) #doctest: +ELLIPSIS
+ >>> print(list(range(1000))) #doctest: +ELLIPSIS
[0, 1, 2, ..., 999]
""",
"whitespace normalization": r"""
If the whitespace normalization flag is used, then
differences in whitespace are ignored.
- >>> print range(30) #doctest: +NORMALIZE_WHITESPACE
+ >>> print(list(range(30))) #doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29]
diff --git a/Lib/dummy_threading.py b/Lib/dummy_threading.py
index 81028a3d4e8..1bb7eee338a 100644
--- a/Lib/dummy_threading.py
+++ b/Lib/dummy_threading.py
@@ -3,12 +3,12 @@
The module ``_dummy_threading`` is added to ``sys.modules`` in order
to not have ``threading`` considered imported. Had ``threading`` been
directly imported it would have made all subsequent imports succeed
-regardless of whether ``thread`` was available which is not desired.
+regardless of whether ``_thread`` was available which is not desired.
"""
from sys import modules as sys_modules
-import dummy_thread
+import _dummy_thread
# Declaring now so as to not have to nest ``try``s to get proper clean-up.
holding_thread = False
@@ -16,15 +16,15 @@ holding_threading = False
holding__threading_local = False
try:
- # Could have checked if ``thread`` was not in sys.modules and gone
+ # Could have checked if ``_thread`` was not in sys.modules and gone
# a different route, but decided to mirror technique used with
# ``threading`` below.
- if 'thread' in sys_modules:
- held_thread = sys_modules['thread']
+ if '_thread' in sys_modules:
+ held_thread = sys_modules['_thread']
holding_thread = True
- # Must have some module named ``thread`` that implements its API
+ # Must have some module named ``_thread`` that implements its API
# in order to initially import ``threading``.
- sys_modules['thread'] = sys_modules['dummy_thread']
+ sys_modules['_thread'] = sys_modules['_dummy_thread']
if 'threading' in sys_modules:
# If ``threading`` is already imported, might as well prevent
@@ -68,11 +68,11 @@ finally:
# Put back ``thread`` if we overwrote, else del the entry we made
if holding_thread:
- sys_modules['thread'] = held_thread
+ sys_modules['_thread'] = held_thread
del held_thread
else:
- del sys_modules['thread']
+ del sys_modules['_thread']
del holding_thread
- del dummy_thread
+ del _dummy_thread
del sys_modules
diff --git a/Lib/email/__init__.py b/Lib/email/__init__.py
index a780ebe339b..ff16f6af3f3 100644
--- a/Lib/email/__init__.py
+++ b/Lib/email/__init__.py
@@ -1,42 +1,25 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Author: Barry Warsaw
# Contact: email-sig@python.org
"""A package for parsing, handling, and generating email messages."""
-__version__ = '4.0.3'
+__version__ = '5.1.0'
__all__ = [
- # Old names
- 'base64MIME',
- 'Charset',
- 'Encoders',
- 'Errors',
- 'Generator',
- 'Header',
- 'Iterators',
- 'Message',
- 'MIMEAudio',
- 'MIMEBase',
- 'MIMEImage',
- 'MIMEMessage',
- 'MIMEMultipart',
- 'MIMENonMultipart',
- 'MIMEText',
- 'Parser',
- 'quopriMIME',
- 'Utils',
- 'message_from_string',
- 'message_from_file',
- # new names
'base64mime',
'charset',
'encoders',
'errors',
+ 'feedparser',
'generator',
'header',
'iterators',
'message',
+ 'message_from_file',
+ 'message_from_binary_file',
+ 'message_from_string',
+ 'message_from_bytes',
'mime',
'parser',
'quoprimime',
@@ -56,6 +39,13 @@ def message_from_string(s, *args, **kws):
from email.parser import Parser
return Parser(*args, **kws).parsestr(s)
+def message_from_bytes(s, *args, **kws):
+ """Parse a bytes string into a Message object model.
+
+ Optional _class and strict are passed to the Parser constructor.
+ """
+ from email.parser import BytesParser
+ return BytesParser(*args, **kws).parsebytes(s)
def message_from_file(fp, *args, **kws):
"""Read a file and parse its contents into a Message object model.
@@ -65,59 +55,10 @@ def message_from_file(fp, *args, **kws):
from email.parser import Parser
return Parser(*args, **kws).parse(fp)
+def message_from_binary_file(fp, *args, **kws):
+ """Read a binary file and parse its contents into a Message object model.
-
-# Lazy loading to provide name mapping from new-style names (PEP 8 compatible
-# email 4.0 module names), to old-style names (email 3.0 module names).
-import sys
-
-class LazyImporter(object):
- def __init__(self, module_name):
- self.__name__ = 'email.' + module_name
-
- def __getattr__(self, name):
- __import__(self.__name__)
- mod = sys.modules[self.__name__]
- self.__dict__.update(mod.__dict__)
- return getattr(mod, name)
-
-
-_LOWERNAMES = [
- # email.<old name> -> email.<new name is lowercased old name>
- 'Charset',
- 'Encoders',
- 'Errors',
- 'FeedParser',
- 'Generator',
- 'Header',
- 'Iterators',
- 'Message',
- 'Parser',
- 'Utils',
- 'base64MIME',
- 'quopriMIME',
- ]
-
-_MIMENAMES = [
- # email.MIME<old name> -> email.mime.<new name is lowercased old name>
- 'Audio',
- 'Base',
- 'Image',
- 'Message',
- 'Multipart',
- 'NonMultipart',
- 'Text',
- ]
-
-for _name in _LOWERNAMES:
- importer = LazyImporter(_name.lower())
- sys.modules['email.' + _name] = importer
- setattr(sys.modules['email'], _name, importer)
-
-
-import email.mime
-for _name in _MIMENAMES:
- importer = LazyImporter('mime.' + _name.lower())
- sys.modules['email.MIME' + _name] = importer
- setattr(sys.modules['email'], 'MIME' + _name, importer)
- setattr(sys.modules['email.mime'], _name, importer)
+ Optional _class and strict are passed to the Parser constructor.
+ """
+ from email.parser import BytesParser
+ return BytesParser(*args, **kws).parse(fp)
diff --git a/Lib/email/_parseaddr.py b/Lib/email/_parseaddr.py
index 690db2c22d3..79573c61778 100644
--- a/Lib/email/_parseaddr.py
+++ b/Lib/email/_parseaddr.py
@@ -64,8 +64,10 @@ def parsedate_tz(data):
if len(data) == 4:
s = data[3]
i = s.find('+')
+ if i == -1:
+ i = s.find('-')
if i > 0:
- data[3:] = [s[:i], s[i+1:]]
+ data[3:] = [s[:i], s[i:]]
else:
data.append('') # Dummy tz
if len(data) < 5:
@@ -176,7 +178,7 @@ class AddrlistClass:
front of you.
Note: this class interface is deprecated and may be removed in the future.
- Use rfc822.AddressList instead.
+ Use email.utils.AddressList instead.
"""
def __init__(self, field):
@@ -199,14 +201,18 @@ class AddrlistClass:
self.commentlist = []
def gotonext(self):
- """Parse up to the start of the next address."""
+ """Skip white space and extract comments."""
+ wslist = []
while self.pos < len(self.field):
if self.field[self.pos] in self.LWS + '\n\r':
+ if self.field[self.pos] not in '\n\r':
+ wslist.append(self.field[self.pos])
self.pos += 1
elif self.field[self.pos] == '(':
self.commentlist.append(self.getcomment())
else:
break
+ return EMPTYSTRING.join(wslist)
def getaddrlist(self):
"""Parse all addresses.
@@ -319,16 +325,24 @@ class AddrlistClass:
self.gotonext()
while self.pos < len(self.field):
+ preserve_ws = True
if self.field[self.pos] == '.':
+ if aslist and not aslist[-1].strip():
+ aslist.pop()
aslist.append('.')
self.pos += 1
+ preserve_ws = False
elif self.field[self.pos] == '"':
aslist.append('"%s"' % quote(self.getquote()))
elif self.field[self.pos] in self.atomends:
+ if aslist and not aslist[-1].strip():
+ aslist.pop()
break
else:
aslist.append(self.getatom())
- self.gotonext()
+ ws = self.gotonext()
+ if preserve_ws and ws:
+ aslist.append(ws)
if self.pos >= len(self.field) or self.field[self.pos] != '@':
return EMPTYSTRING.join(aslist)
diff --git a/Lib/email/base64mime.py b/Lib/email/base64mime.py
index 4aa800026d6..f3bbac1cafb 100644
--- a/Lib/email/base64mime.py
+++ b/Lib/email/base64mime.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2006 Python Software Foundation
+# Copyright (C) 2002-2007 Python Software Foundation
# Author: Ben Gertzfield
# Contact: email-sig@python.org
@@ -25,19 +25,17 @@ module.
"""
__all__ = [
- 'base64_len',
'body_decode',
'body_encode',
'decode',
'decodestring',
- 'encode',
- 'encodestring',
'header_encode',
+ 'header_length',
]
+from base64 import b64encode
from binascii import b2a_base64, a2b_base64
-from email.utils import fix_eols
CRLF = '\r\n'
NL = '\n'
@@ -49,11 +47,10 @@ MISC_LEN = 7
# Helpers
-def base64_len(s):
+def header_length(bytearray):
"""Return the length of s when it is encoded with base64."""
- groups_of_3, leftover = divmod(len(s), 3)
+ groups_of_3, leftover = divmod(len(bytearray), 3)
# 4 bytes out for each 3 bytes (or nonzero fraction thereof) in.
- # Thanks, Tim!
n = groups_of_3 * 4
if leftover:
n += 4
@@ -61,121 +58,60 @@ def base64_len(s):
-def header_encode(header, charset='iso-8859-1', keep_eols=False,
- maxlinelen=76, eol=NL):
+def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with Base64 encoding in a given charset.
- Defined in RFC 2045, this Base64 encoding is identical to normal Base64
- encoding, except that each line must be intelligently wrapped (respecting
- the Base64 encoding), and subsequent lines must start with a space.
-
charset names the character set to use to encode the header. It defaults
- to iso-8859-1.
-
- End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted
- to the canonical email line separator \\r\\n unless the keep_eols
- parameter is True (the default is False).
-
- Each line of the header will be terminated in the value of eol, which
- defaults to "\\n". Set this to "\\r\\n" if you are using the result of
- this function directly in email.
-
- The resulting string will be in the form:
-
- "=?charset?b?WW/5ciBtYXp66XLrIHf8eiBhIGhhbXBzdGHuciBBIFlv+XIgbWF6euly?=\\n
- =?charset?b?6yB3/HogYSBoYW1wc3Rh7nIgQkMgWW/5ciBtYXp66XLrIHf8eiBhIGhh?="
-
- with each line wrapped at, at most, maxlinelen characters (defaults to 76
- characters).
+ to iso-8859-1. Base64 encoding is defined in RFC 2045.
"""
- # Return empty headers unchanged
- if not header:
- return header
-
- if not keep_eols:
- header = fix_eols(header)
-
- # Base64 encode each line, in encoded chunks no greater than maxlinelen in
- # length, after the RFC chrome is added in.
- base64ed = []
- max_encoded = maxlinelen - len(charset) - MISC_LEN
- max_unencoded = max_encoded * 3 // 4
-
- for i in range(0, len(header), max_unencoded):
- base64ed.append(b2a_base64(header[i:i+max_unencoded]))
-
- # Now add the RFC chrome to each encoded chunk
- lines = []
- for line in base64ed:
- # Ignore the last character of each line if it is a newline
- if line.endswith(NL):
- line = line[:-1]
- # Add the chrome
- lines.append('=?%s?b?%s?=' % (charset, line))
- # Glue the lines together and return it. BAW: should we be able to
- # specify the leading whitespace in the joiner?
- joiner = eol + ' '
- return joiner.join(lines)
+ if not header_bytes:
+ return ""
+ if isinstance(header_bytes, str):
+ header_bytes = header_bytes.encode(charset)
+ encoded = b64encode(header_bytes).decode("ascii")
+ return '=?%s?b?%s?=' % (charset, encoded)
-def encode(s, binary=True, maxlinelen=76, eol=NL):
- """Encode a string with base64.
+def body_encode(s, maxlinelen=76, eol=NL):
+ r"""Encode a string with base64.
Each line will be wrapped at, at most, maxlinelen characters (defaults to
76 characters).
- If binary is False, end-of-line characters will be converted to the
- canonical email end-of-line sequence \\r\\n. Otherwise they will be left
- verbatim (this is the default).
-
- Each line of encoded text will end with eol, which defaults to "\\n". Set
- this to "\\r\\n" if you will be using the result of this function directly
+ Each line of encoded text will end with eol, which defaults to "\n". Set
+ this to "\r\n" if you will be using the result of this function directly
in an email.
"""
if not s:
return s
- if not binary:
- s = fix_eols(s)
-
encvec = []
max_unencoded = maxlinelen * 3 // 4
for i in range(0, len(s), max_unencoded):
# BAW: should encode() inherit b2a_base64()'s dubious behavior in
# adding a newline to the encoded string?
- enc = b2a_base64(s[i:i + max_unencoded])
+ enc = b2a_base64(s[i:i + max_unencoded]).decode("ascii")
if enc.endswith(NL) and eol != NL:
enc = enc[:-1] + eol
encvec.append(enc)
return EMPTYSTRING.join(encvec)
-# For convenience and backwards compatibility w/ standard base64 module
-body_encode = encode
-encodestring = encode
-
-
-def decode(s, convert_eols=None):
- """Decode a raw base64 string.
-
- If convert_eols is set to a string value, all canonical email linefeeds,
- e.g. "\\r\\n", in the decoded text will be converted to the value of
- convert_eols. os.linesep is a good choice for convert_eols if you are
- decoding a text attachment.
+def decode(string):
+ """Decode a raw base64 string, returning a bytes object.
This function does not parse a full MIME header value encoded with
base64 (like =?iso-8895-1?b?bmloISBuaWgh?=) -- please use the high
level email.header class for that functionality.
"""
- if not s:
- return s
-
- dec = a2b_base64(s)
- if convert_eols:
- return dec.replace(CRLF, convert_eols)
- return dec
+ if not string:
+ return bytes()
+ elif isinstance(string, str):
+ return a2b_base64(string.encode('raw-unicode-escape'))
+ else:
+ return a2b_base64(string)
# For convenience and backwards compatibility w/ standard base64 module
diff --git a/Lib/email/charset.py b/Lib/email/charset.py
index dddaa76c55d..f22be2c52c1 100644
--- a/Lib/email/charset.py
+++ b/Lib/email/charset.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Author: Ben Gertzfield, Barry Warsaw
# Contact: email-sig@python.org
@@ -9,7 +9,8 @@ __all__ = [
'add_codec',
]
-import codecs
+from functools import partial
+
import email.base64mime
import email.quoprimime
@@ -24,9 +25,11 @@ BASE64 = 2 # Base64
SHORTEST = 3 # the shorter of QP and base64, but only for headers
# In "=?charset?q?hello_world?=", the =?, ?q?, and ?= add up to 7
-MISC_LEN = 7
+RFC2047_CHROME_LEN = 7
DEFAULT_CHARSET = 'us-ascii'
+UNKNOWN8BIT = 'unknown-8bit'
+EMPTYSTRING = ''
@@ -58,8 +61,6 @@ CHARSETS = {
'iso-2022-jp': (BASE64, None, None),
'koi8-r': (BASE64, BASE64, None),
'utf-8': (SHORTEST, BASE64, 'utf-8'),
- # We're making this one up to represent raw unencoded 8-bit
- '8bit': (None, BASE64, 'utf-8'),
}
# Aliases for other commonly-used names for character sets. Map
@@ -153,6 +154,16 @@ def add_codec(charset, codecname):
+# Convenience function for encoding strings, taking into account
+# that they might be unknown-8bit (ie: have surrogate-escaped bytes)
+def _encode(string, codec):
+ if codec == UNKNOWN8BIT:
+ return string.encode('ascii', 'surrogateescape')
+ else:
+ return string.encode(codec)
+
+
+
class Charset:
"""Map character sets to their email properties.
@@ -203,19 +214,14 @@ class Charset:
# is already a unicode, we leave it at that, but ensure that the
# charset is ASCII, as the standard (RFC XXX) requires.
try:
- if isinstance(input_charset, unicode):
+ if isinstance(input_charset, str):
input_charset.encode('ascii')
else:
- input_charset = unicode(input_charset, 'ascii')
+ input_charset = str(input_charset, 'ascii')
except UnicodeError:
raise errors.CharsetError(input_charset)
- input_charset = input_charset.lower().encode('ascii')
- # Set the input charset after filtering through the aliases and/or codecs
- if not (input_charset in ALIASES or input_charset in CHARSETS):
- try:
- input_charset = codecs.lookup(input_charset).name
- except LookupError:
- pass
+ input_charset = input_charset.lower()
+ # Set the input charset after filtering through the aliases
self.input_charset = ALIASES.get(input_charset, input_charset)
# We can try to guess which encoding and conversion to use by the
# charset_map dictionary. Try that first, but let the user override
@@ -257,7 +263,7 @@ class Charset:
Returns "quoted-printable" if self.body_encoding is QP.
Returns "base64" if self.body_encoding is BASE64.
- Returns "7bit" otherwise.
+ Returns conversion function otherwise.
"""
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
@@ -267,60 +273,6 @@ class Charset:
else:
return encode_7or8bit
- def convert(self, s):
- """Convert a string from the input_codec to the output_codec."""
- if self.input_codec != self.output_codec:
- return unicode(s, self.input_codec).encode(self.output_codec)
- else:
- return s
-
- def to_splittable(self, s):
- """Convert a possibly multibyte string to a safely splittable format.
-
- Uses the input_codec to try and convert the string to Unicode, so it
- can be safely split on character boundaries (even for multibyte
- characters).
-
- Returns the string as-is if it isn't known how to convert it to
- Unicode with the input_charset.
-
- Characters that could not be converted to Unicode will be replaced
- with the Unicode replacement character U+FFFD.
- """
- if isinstance(s, unicode) or self.input_codec is None:
- return s
- try:
- return unicode(s, self.input_codec, 'replace')
- except LookupError:
- # Input codec not installed on system, so return the original
- # string unchanged.
- return s
-
- def from_splittable(self, ustr, to_output=True):
- """Convert a splittable string back into an encoded string.
-
- Uses the proper codec to try and convert the string from Unicode back
- into an encoded format. Return the string as-is if it is not Unicode,
- or if it could not be converted from Unicode.
-
- Characters that could not be converted from Unicode will be replaced
- with an appropriate character (usually '?').
-
- If to_output is True (the default), uses output_codec to convert to an
- encoded format. If to_output is False, uses input_codec.
- """
- if to_output:
- codec = self.output_codec
- else:
- codec = self.input_codec
- if not isinstance(ustr, unicode) or codec is None:
- return ustr
- try:
- return ustr.encode(codec, 'replace')
- except LookupError:
- # Output codec not installed
- return ustr
-
def get_output_charset(self):
"""Return the output character set.
@@ -329,69 +281,119 @@ class Charset:
"""
return self.output_charset or self.input_charset
- def encoded_header_len(self, s):
- """Return the length of the encoded header string."""
- cset = self.get_output_charset()
- # The len(s) of a 7bit encoding is len(s)
- if self.header_encoding == BASE64:
- return email.base64mime.base64_len(s) + len(cset) + MISC_LEN
- elif self.header_encoding == QP:
- return email.quoprimime.header_quopri_len(s) + len(cset) + MISC_LEN
- elif self.header_encoding == SHORTEST:
- lenb64 = email.base64mime.base64_len(s)
- lenqp = email.quoprimime.header_quopri_len(s)
- return min(lenb64, lenqp) + len(cset) + MISC_LEN
- else:
- return len(s)
-
- def header_encode(self, s, convert=False):
- """Header-encode a string, optionally converting it to output_charset.
-
- If convert is True, the string will be converted from the input
- charset to the output charset automatically. This is not useful for
- multibyte character sets, which have line length issues (multibyte
- characters must be split on a character, not a byte boundary); use the
- high-level Header class to deal with these issues. convert defaults
- to False.
+ def header_encode(self, string):
+ """Header-encode a string by converting it first to bytes.
The type of encoding (base64 or quoted-printable) will be based on
- self.header_encoding.
+ this charset's `header_encoding`.
+
+ :param string: A unicode string for the header. It must be possible
+ to encode this string to bytes using the character set's
+ output codec.
+ :return: The encoded string, with RFC 2047 chrome.
"""
- cset = self.get_output_charset()
- if convert:
- s = self.convert(s)
+ codec = self.output_codec or 'us-ascii'
+ header_bytes = _encode(string, codec)
# 7bit/8bit encodings return the string unchanged (modulo conversions)
+ encoder_module = self._get_encoder(header_bytes)
+ if encoder_module is None:
+ return string
+ return encoder_module.header_encode(header_bytes, codec)
+
+ def header_encode_lines(self, string, maxlengths):
+ """Header-encode a string by converting it first to bytes.
+
+ This is similar to `header_encode()` except that the string is fit
+ into maximum line lengths as given by the argument.
+
+ :param string: A unicode string for the header. It must be possible
+ to encode this string to bytes using the character set's
+ output codec.
+ :param maxlengths: Maximum line length iterator. Each element
+ returned from this iterator will provide the next maximum line
+ length. This parameter is used as an argument to built-in next()
+ and should never be exhausted. The maximum line lengths should
+ not count the RFC 2047 chrome. These line lengths are only a
+ hint; the splitter does the best it can.
+ :return: Lines of encoded strings, each with RFC 2047 chrome.
+ """
+ # See which encoding we should use.
+ codec = self.output_codec or 'us-ascii'
+ header_bytes = _encode(string, codec)
+ encoder_module = self._get_encoder(header_bytes)
+ encoder = partial(encoder_module.header_encode, charset=codec)
+ # Calculate the number of characters that the RFC 2047 chrome will
+ # contribute to each line.
+ charset = self.get_output_charset()
+ extra = len(charset) + RFC2047_CHROME_LEN
+ # Now comes the hard part. We must encode bytes but we can't split on
+ # bytes because some character sets are variable length and each
+ # encoded word must stand on its own. So the problem is you have to
+ # encode to bytes to figure out this word's length, but you must split
+ # on characters. This causes two problems: first, we don't know how
+ # many octets a specific substring of unicode characters will get
+ # encoded to, and second, we don't know how many ASCII characters
+ # those octets will get encoded to. Unless we try it. Which seems
+ # inefficient. In the interest of being correct rather than fast (and
+ # in the hope that there will be few encoded headers in any such
+ # message), brute force it. :(
+ lines = []
+ current_line = []
+ maxlen = next(maxlengths) - extra
+ for character in string:
+ current_line.append(character)
+ this_line = EMPTYSTRING.join(current_line)
+ length = encoder_module.header_length(_encode(this_line, charset))
+ if length > maxlen:
+ # This last character doesn't fit so pop it off.
+ current_line.pop()
+ # Does nothing fit on the first line?
+ if not lines and not current_line:
+ lines.append(None)
+ else:
+ separator = (' ' if lines else '')
+ joined_line = EMPTYSTRING.join(current_line)
+ header_bytes = _encode(joined_line, codec)
+ lines.append(encoder(header_bytes))
+ current_line = [character]
+ maxlen = next(maxlengths) - extra
+ joined_line = EMPTYSTRING.join(current_line)
+ header_bytes = _encode(joined_line, codec)
+ lines.append(encoder(header_bytes))
+ return lines
+
+ def _get_encoder(self, header_bytes):
if self.header_encoding == BASE64:
- return email.base64mime.header_encode(s, cset)
+ return email.base64mime
elif self.header_encoding == QP:
- return email.quoprimime.header_encode(s, cset, maxlinelen=None)
+ return email.quoprimime
elif self.header_encoding == SHORTEST:
- lenb64 = email.base64mime.base64_len(s)
- lenqp = email.quoprimime.header_quopri_len(s)
- if lenb64 < lenqp:
- return email.base64mime.header_encode(s, cset)
+ len64 = email.base64mime.header_length(header_bytes)
+ lenqp = email.quoprimime.header_length(header_bytes)
+ if len64 < lenqp:
+ return email.base64mime
else:
- return email.quoprimime.header_encode(s, cset, maxlinelen=None)
+ return email.quoprimime
else:
- return s
-
- def body_encode(self, s, convert=True):
- """Body-encode a string and convert it to output_charset.
+ return None
- If convert is True (the default), the string will be converted from
- the input charset to output charset automatically. Unlike
- header_encode(), there are no issues with byte boundaries and
- multibyte charsets in email bodies, so this is usually pretty safe.
+ def body_encode(self, string):
+ """Body-encode a string by converting it first to bytes.
The type of encoding (base64 or quoted-printable) will be based on
- self.body_encoding.
+ self.body_encoding. If body_encoding is None, we assume the
+ output charset is a 7bit encoding, so re-encoding the decoded
+ string using the ascii codec produces the correct string version
+ of the content.
"""
- if convert:
- s = self.convert(s)
# 7bit/8bit encodings return the string unchanged (module conversions)
if self.body_encoding is BASE64:
- return email.base64mime.body_encode(s)
+ if isinstance(string, str):
+ string = string.encode(self.output_charset)
+ return email.base64mime.body_encode(string)
elif self.body_encoding is QP:
- return email.quoprimime.body_encode(s)
+ return email.quoprimime.body_encode(string)
else:
- return s
+ if isinstance(string, str):
+ string = string.encode(self.output_charset).decode('ascii')
+ return string
diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
index af45e62c333..e5c099f35ad 100644
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -11,8 +11,8 @@ __all__ = [
'encode_quopri',
]
-import base64
+from base64 import encodebytes as _bencode
from quopri import encodestring as _encodestring
@@ -23,26 +23,13 @@ def _qencode(s):
return enc.replace(' ', '=20')
-def _bencode(s):
- # We can't quite use base64.encodestring() since it tacks on a "courtesy
- # newline". Blech!
- if not s:
- return s
- hasnewline = (s[-1] == '\n')
- value = base64.encodestring(s)
- if not hasnewline and value[-1] == '\n':
- return value[:-1]
- return value
-
-
-
def encode_base64(msg):
"""Encode the message's payload in Base64.
Also, add an appropriate Content-Transfer-Encoding header.
"""
orig = msg.get_payload()
- encdata = _bencode(orig)
+ encdata = str(_bencode(orig), 'ascii')
msg.set_payload(encdata)
msg['Content-Transfer-Encoding'] = 'base64'
@@ -67,12 +54,21 @@ def encode_7or8bit(msg):
# There's no payload. For backwards compatibility we use 7bit
msg['Content-Transfer-Encoding'] = '7bit'
return
- # We play a trick to make this go fast. If encoding to ASCII succeeds, we
- # know the data must be 7bit, otherwise treat it as 8bit.
+ # We play a trick to make this go fast. If encoding/decode to ASCII
+ # succeeds, we know the data must be 7bit, otherwise treat it as 8bit.
try:
- orig.encode('ascii')
+ if isinstance(orig, str):
+ orig.encode('ascii')
+ else:
+ orig.decode('ascii')
except UnicodeError:
- msg['Content-Transfer-Encoding'] = '8bit'
+ # iso-2022-* is non-ASCII but still 7-bit
+ charset = msg.get_charset()
+ output_cset = charset and charset.output_charset
+ if output_cset and output_cset.lower().startswith('iso-2022-'):
+ msg['Content-Transfer-Encoding'] = '7bit'
+ else:
+ msg['Content-Transfer-Encoding'] = '8bit'
else:
msg['Content-Transfer-Encoding'] = '7bit'
diff --git a/Lib/email/feedparser.py b/Lib/email/feedparser.py
index 15db26d22a2..16ed2885d71 100644
--- a/Lib/email/feedparser.py
+++ b/Lib/email/feedparser.py
@@ -19,7 +19,7 @@ the current message. Defects are just instances that live on the message
object's .defects attribute.
"""
-__all__ = ['FeedParser']
+__all__ = ['FeedParser', 'BytesFeedParser']
import re
@@ -126,7 +126,7 @@ class BufferedSubFile(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
line = self.readline()
if line == '':
raise StopIteration
@@ -142,7 +142,7 @@ class FeedParser:
self._factory = _factory
self._input = BufferedSubFile()
self._msgstack = []
- self._parse = self._parsegen().next
+ self._parse = self._parsegen().__next__
self._cur = None
self._last = None
self._headersonly = False
@@ -368,12 +368,12 @@ class FeedParser:
end = len(mo.group(0))
self._last.epilogue = epilogue[:-end]
else:
- payload = self._last.get_payload()
- if isinstance(payload, basestring):
+ payload = self._last._payload
+ if isinstance(payload, str):
mo = NLCRE_eol.search(payload)
if mo:
payload = payload[:-len(mo.group(0))]
- self._last.set_payload(payload)
+ self._last._payload = payload
self._input.pop_eof_matcher()
self._pop_message()
# Set the multipart up for newline cleansing, which will
@@ -482,3 +482,10 @@ class FeedParser:
if lastheader:
# XXX reconsider the joining of folded lines
self._cur[lastheader] = EMPTYSTRING.join(lastvalue).rstrip('\r\n')
+
+
+class BytesFeedParser(FeedParser):
+ """Like FeedParser, but feed accepts bytes."""
+
+ def feed(self, data):
+ super().feed(data.decode('ascii', 'surrogateescape'))
diff --git a/Lib/email/generator.py b/Lib/email/generator.py
index 5626ab91eb5..c6bfb704f53 100644
--- a/Lib/email/generator.py
+++ b/Lib/email/generator.py
@@ -1,9 +1,10 @@
# Copyright (C) 2001-2010 Python Software Foundation
+# Author: Barry Warsaw
# Contact: email-sig@python.org
"""Classes to generate plain text from a message object tree."""
-__all__ = ['Generator', 'DecodedGenerator']
+__all__ = ['Generator', 'DecodedGenerator', 'BytesGenerator']
import re
import sys
@@ -11,22 +12,15 @@ import time
import random
import warnings
-from cStringIO import StringIO
+from io import StringIO, BytesIO
from email.header import Header
+from email.message import _has_surrogates
UNDERSCORE = '_'
-NL = '\n'
+NL = '\n' # XXX: no longer used by the code below.
fcre = re.compile(r'^From ', re.MULTILINE)
-def _is8bitstring(s):
- if isinstance(s, str):
- try:
- unicode(s, 'us-ascii')
- except UnicodeError:
- return True
- return False
-
class Generator:
@@ -64,8 +58,8 @@ class Generator:
# Just delegate to the file object
self._fp.write(s)
- def flatten(self, msg, unixfrom=False):
- """Print the message object tree rooted at msg to the output file
+ def flatten(self, msg, unixfrom=False, linesep='\n'):
+ r"""Print the message object tree rooted at msg to the output file
specified when the Generator instance was created.
unixfrom is a flag that forces the printing of a Unix From_ delimiter
@@ -74,12 +68,26 @@ class Generator:
is False to inhibit the printing of any From_ delimiter.
Note that for subobjects, no From_ line is printed.
+
+ linesep specifies the characters used to indicate a new line in
+ the output. The default value is the most useful for typical
+ Python applications, but it can be set to \r\n to produce RFC-compliant
+ line separators when needed.
+
"""
+ # We use the _XXX constants for operating on data that comes directly
+ # from the msg, and _encoded_XXX constants for operating on data that
+ # has already been converted (to bytes in the BytesGenerator) and
+ # inserted into a temporary buffer.
+ self._NL = linesep
+ self._encoded_NL = self._encode(linesep)
+ self._EMPTY = ''
+ self._encoded_EMTPY = self._encode('')
if unixfrom:
ufrom = msg.get_unixfrom()
if not ufrom:
ufrom = 'From nobody ' + time.ctime(time.time())
- print >> self._fp, ufrom
+ self.write(ufrom + self._NL)
self._write(msg)
def clone(self, fp):
@@ -90,6 +98,27 @@ class Generator:
# Protected interface - undocumented ;/
#
+ # Note that we use 'self.write' when what we are writing is coming from
+ # the source, and self._fp.write when what we are writing is coming from a
+ # buffer (because the Bytes subclass has already had a chance to transform
+ # the data in its write method in that case). This is an entirely
+ # pragmatic split determined by experiment; we could be more general by
+ # always using write and having the Bytes subclass write method detect when
+ # it has already transformed the input; but, since this whole thing is a
+ # hack anyway this seems good enough.
+
+ # Similarly, we have _XXX and _encoded_XXX attributes that are used on
+ # source and buffer data, respectively.
+ _encoded_EMPTY = ''
+
+ def _new_buffer(self):
+ # BytesGenerator overrides this to return BytesIO.
+ return StringIO()
+
+ def _encode(self, s):
+ # BytesGenerator overrides this to encode strings to bytes.
+ return s
+
def _write(self, msg):
# We can't write the headers yet because of the following scenario:
# say a multipart message includes the boundary string somewhere in
@@ -98,13 +127,13 @@ class Generator:
# parameter.
#
# The way we do this, so as to make the _handle_*() methods simpler,
- # is to cache any subpart writes into a StringIO. The we write the
- # headers and the StringIO contents. That way, subpart handlers can
+ # is to cache any subpart writes into a buffer. The we write the
+ # headers and the buffer contents. That way, subpart handlers can
# Do The Right Thing, and can still modify the Content-Type: header if
# necessary.
oldfp = self._fp
try:
- self._fp = sfp = StringIO()
+ self._fp = sfp = self._new_buffer()
self._dispatch(msg)
finally:
self._fp = oldfp
@@ -139,31 +168,17 @@ class Generator:
def _write_headers(self, msg):
for h, v in msg.items():
- print >> self._fp, '%s:' % h,
- if self._maxheaderlen == 0:
- # Explicit no-wrapping
- print >> self._fp, v
- elif isinstance(v, Header):
- # Header instances know what to do
- print >> self._fp, v.encode()
- elif _is8bitstring(v):
- # If we have raw 8bit data in a byte string, we have no idea
- # what the encoding is. There is no safe way to split this
- # string. If it's ascii-subset, then we could do a normal
- # ascii split, but if it's multibyte then we could break the
- # string. There's no way to know so the least harm seems to
- # be to not split the string and risk it being too long.
- print >> self._fp, v
+ self.write('%s: ' % h)
+ if isinstance(v, Header):
+ self.write(v.encode(
+ maxlinelen=self._maxheaderlen, linesep=self._NL)+self._NL)
else:
- # Header's got lots of smarts, so use it. Note that this is
- # fundamentally broken though because we lose idempotency when
- # the header string is continued with tabs. It will now be
- # continued with spaces. This was reversedly broken before we
- # fixed bug 1974. Either way, we lose.
- print >> self._fp, Header(
- v, maxlinelen=self._maxheaderlen, header_name=h).encode()
+ # Header's got lots of smarts, so use it.
+ header = Header(v, maxlinelen=self._maxheaderlen,
+ header_name=h)
+ self.write(header.encode(linesep=self._NL)+self._NL)
# A blank line always separates headers from body
- print >> self._fp
+ self.write(self._NL)
#
# Handlers for writing types and subtypes
@@ -173,11 +188,17 @@ class Generator:
payload = msg.get_payload()
if payload is None:
return
- if not isinstance(payload, basestring):
+ if not isinstance(payload, str):
raise TypeError('string payload expected: %s' % type(payload))
+ if _has_surrogates(msg._payload):
+ charset = msg.get_param('charset')
+ if charset is not None:
+ del msg['content-transfer-encoding']
+ msg.set_payload(payload, charset)
+ payload = msg.get_payload()
if self._mangle_from_:
payload = fcre.sub('>From ', payload)
- self._fp.write(payload)
+ self.write(payload)
# Default body handler
_writeBody = _handle_text
@@ -190,25 +211,25 @@ class Generator:
subparts = msg.get_payload()
if subparts is None:
subparts = []
- elif isinstance(subparts, basestring):
+ elif isinstance(subparts, str):
# e.g. a non-strict parse of a message with no starting boundary.
- self._fp.write(subparts)
+ self.write(subparts)
return
elif not isinstance(subparts, list):
# Scalar payload
subparts = [subparts]
for part in subparts:
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
- g.flatten(part, unixfrom=False)
+ g.flatten(part, unixfrom=False, linesep=self._NL)
msgtexts.append(s.getvalue())
# BAW: What about boundaries that are wrapped in double-quotes?
boundary = msg.get_boundary()
if not boundary:
# Create a boundary that doesn't appear in any of the
# message texts.
- alltext = NL.join(msgtexts)
- boundary = _make_boundary(alltext)
+ alltext = self._encoded_NL.join(msgtexts)
+ boundary = self._make_boundary(alltext)
msg.set_boundary(boundary)
# If there's a preamble, write it out, with a trailing CRLF
if msg.preamble is not None:
@@ -216,9 +237,9 @@ class Generator:
preamble = fcre.sub('>From ', msg.preamble)
else:
preamble = msg.preamble
- print >> self._fp, preamble
+ self.write(preamble + self._NL)
# dash-boundary transport-padding CRLF
- print >> self._fp, '--' + boundary
+ self.write('--' + boundary + self._NL)
# body-part
if msgtexts:
self._fp.write(msgtexts.pop(0))
@@ -227,18 +248,18 @@ class Generator:
# --> CRLF body-part
for body_part in msgtexts:
# delimiter transport-padding CRLF
- print >> self._fp, '\n--' + boundary
+ self.write(self._NL + '--' + boundary + self._NL)
# body-part
self._fp.write(body_part)
# close-delimiter transport-padding
- self._fp.write('\n--' + boundary + '--')
+ self.write(self._NL + '--' + boundary + '--')
if msg.epilogue is not None:
- print >> self._fp
+ self.write(self._NL)
if self._mangle_from_:
epilogue = fcre.sub('>From ', msg.epilogue)
else:
epilogue = msg.epilogue
- self._fp.write(epilogue)
+ self.write(epilogue)
def _handle_multipart_signed(self, msg):
# The contents of signed parts has to stay unmodified in order to keep
@@ -257,23 +278,23 @@ class Generator:
# block and the boundary. Sigh.
blocks = []
for part in msg.get_payload():
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
- g.flatten(part, unixfrom=False)
+ g.flatten(part, unixfrom=False, linesep=self._NL)
text = s.getvalue()
- lines = text.split('\n')
+ lines = text.split(self._encoded_NL)
# Strip off the unnecessary trailing empty line
- if lines and lines[-1] == '':
- blocks.append(NL.join(lines[:-1]))
+ if lines and lines[-1] == self._encoded_EMPTY:
+ blocks.append(self._encoded_NL.join(lines[:-1]))
else:
blocks.append(text)
# Now join all the blocks with an empty line. This has the lovely
# effect of separating each block with an empty line, but not adding
# an extra one after the last one.
- self._fp.write(NL.join(blocks))
+ self._fp.write(self._encoded_NL.join(blocks))
def _handle_message(self, msg):
- s = StringIO()
+ s = self._new_buffer()
g = self.clone(s)
# The payload of a message/rfc822 part should be a multipart sequence
# of length 1. The zeroth element of the list should be the Message
@@ -286,10 +307,100 @@ class Generator:
# in that case we just emit the string body.
payload = msg.get_payload()
if isinstance(payload, list):
- g.flatten(msg.get_payload(0), unixfrom=False)
+ g.flatten(msg.get_payload(0), unixfrom=False, linesep=self._NL)
payload = s.getvalue()
self._fp.write(payload)
+ # This used to be a module level function; we use a classmethod for this
+ # and _compile_re so we can continue to provide the module level function
+ # for backward compatibility by doing
+ # _make_boudary = Generator._make_boundary
+ # at the end of the module. It *is* internal, so we could drop that...
+ @classmethod
+ def _make_boundary(cls, text=None):
+ # Craft a random boundary. If text is given, ensure that the chosen
+ # boundary doesn't appear in the text.
+ token = random.randrange(sys.maxsize)
+ boundary = ('=' * 15) + (_fmt % token) + '=='
+ if text is None:
+ return boundary
+ b = boundary
+ counter = 0
+ while True:
+ cre = cls._compile_re('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
+ if not cre.search(text):
+ break
+ b = boundary + '.' + str(counter)
+ counter += 1
+ return b
+
+ @classmethod
+ def _compile_re(cls, s, flags):
+ return re.compile(s, flags)
+
+
+class BytesGenerator(Generator):
+ """Generates a bytes version of a Message object tree.
+
+ Functionally identical to the base Generator except that the output is
+ bytes and not string. When surrogates were used in the input to encode
+ bytes, these are decoded back to bytes for output.
+
+ The outfp object must accept bytes in its write method.
+ """
+
+ # Bytes versions of this constant for use in manipulating data from
+ # the BytesIO buffer.
+ _encoded_EMPTY = b''
+
+ def write(self, s):
+ self._fp.write(s.encode('ascii', 'surrogateescape'))
+
+ def _new_buffer(self):
+ return BytesIO()
+
+ def _encode(self, s):
+ return s.encode('ascii')
+
+ def _write_headers(self, msg):
+ # This is almost the same as the string version, except for handling
+ # strings with 8bit bytes.
+ for h, v in msg._headers:
+ self.write('%s: ' % h)
+ if isinstance(v, Header):
+ self.write(v.encode(maxlinelen=self._maxheaderlen)+self._NL)
+ elif _has_surrogates(v):
+ # If we have raw 8bit data in a byte string, we have no idea
+ # what the encoding is. There is no safe way to split this
+ # string. If it's ascii-subset, then we could do a normal
+ # ascii split, but if it's multibyte then we could break the
+ # string. There's no way to know so the least harm seems to
+ # be to not split the string and risk it being too long.
+ self.write(v+NL)
+ else:
+ # Header's got lots of smarts and this string is safe...
+ header = Header(v, maxlinelen=self._maxheaderlen,
+ header_name=h)
+ self.write(header.encode(linesep=self._NL)+self._NL)
+ # A blank line always separates headers from body
+ self.write(self._NL)
+
+ def _handle_text(self, msg):
+ # If the string has surrogates the original source was bytes, so
+ # just write it back out.
+ if msg._payload is None:
+ return
+ if _has_surrogates(msg._payload):
+ if self._mangle_from_:
+ msg._payload = fcre.sub(">From ", msg._payload)
+ self.write(msg._payload)
+ else:
+ super(BytesGenerator,self)._handle_text(msg)
+
+ @classmethod
+ def _compile_re(cls, s, flags):
+ return re.compile(s.encode('ascii'), flags)
+
_FMT = '[Non-text (%(type)s) part of message omitted, filename %(filename)s]'
@@ -332,12 +443,12 @@ class DecodedGenerator(Generator):
for part in msg.walk():
maintype = part.get_content_maintype()
if maintype == 'text':
- print >> self, part.get_payload(decode=True)
+ print(part.get_payload(decode=False), file=self)
elif maintype == 'multipart':
# Just skip this
pass
else:
- print >> self, self._fmt % {
+ print(self._fmt % {
'type' : part.get_content_type(),
'maintype' : part.get_content_maintype(),
'subtype' : part.get_content_subtype(),
@@ -346,27 +457,13 @@ class DecodedGenerator(Generator):
'[no description]'),
'encoding' : part.get('Content-Transfer-Encoding',
'[no encoding]'),
- }
+ }, file=self)
-# Helper
-_width = len(repr(sys.maxint-1))
+# Helper used by Generator._make_boundary
+_width = len(repr(sys.maxsize-1))
_fmt = '%%0%dd' % _width
-def _make_boundary(text=None):
- # Craft a random boundary. If text is given, ensure that the chosen
- # boundary doesn't appear in the text.
- token = random.randrange(sys.maxint)
- boundary = ('=' * 15) + (_fmt % token) + '=='
- if text is None:
- return boundary
- b = boundary
- counter = 0
- while True:
- cre = re.compile('^--' + re.escape(b) + '(--)?$', re.MULTILINE)
- if not cre.search(text):
- break
- b = boundary + '.' + str(counter)
- counter += 1
- return b
+# Backward compatibility
+_make_boundary = Generator._make_boundary
diff --git a/Lib/email/header.py b/Lib/email/header.py
index 2cf870fd575..e33324ad38e 100644
--- a/Lib/email/header.py
+++ b/Lib/email/header.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2006 Python Software Foundation
+# Copyright (C) 2002-2007 Python Software Foundation
# Author: Ben Gertzfield, Barry Warsaw
# Contact: email-sig@python.org
@@ -17,15 +17,16 @@ import email.quoprimime
import email.base64mime
from email.errors import HeaderParseError
-from email.charset import Charset
+from email import charset as _charset
+Charset = _charset.Charset
NL = '\n'
SPACE = ' '
-USPACE = u' '
+BSPACE = b' '
SPACE8 = ' ' * 8
-UEMPTYSTRING = u''
-
-MAXLINELEN = 76
+EMPTYSTRING = ''
+MAXLINELEN = 78
+FWS = ' \t'
USASCII = Charset('us-ascii')
UTF8 = Charset('utf-8')
@@ -61,60 +62,82 @@ _max_append = email.quoprimime._max_append
def decode_header(header):
"""Decode a message header value without converting charset.
- Returns a list of (decoded_string, charset) pairs containing each of the
- decoded parts of the header. Charset is None for non-encoded parts of the
- header, otherwise a lower-case string containing the name of the character
- set specified in the encoded string.
+ Returns a list of (string, charset) pairs containing each of the decoded
+ parts of the header. Charset is None for non-encoded parts of the header,
+ otherwise a lower-case string containing the name of the character set
+ specified in the encoded string.
+
+ header may be a string that may or may not contain RFC2047 encoded words,
+ or it may be a Header object.
An email.errors.HeaderParseError may be raised when certain decoding error
occurs (e.g. a base64 decoding exception).
"""
- # If no encoding, just return the header
- header = str(header)
+ # If it is a Header object, we can just return the encoded chunks.
+ if hasattr(header, '_chunks'):
+ return [(_charset._encode(string, str(charset)), str(charset))
+ for string, charset in header._chunks]
+ # If no encoding, just return the header with no charset.
if not ecre.search(header):
return [(header, None)]
- decoded = []
- dec = ''
+ # First step is to parse all the encoded parts into triplets of the form
+ # (encoded_string, encoding, charset). For unencoded strings, the last
+ # two parts will be None.
+ words = []
for line in header.splitlines():
- # This line might not have an encoding in it
- if not ecre.search(line):
- decoded.append((line, None))
- continue
parts = ecre.split(line)
while parts:
- unenc = parts.pop(0).strip()
- if unenc:
- # Should we continue a long line?
- if decoded and decoded[-1][1] is None:
- decoded[-1] = (decoded[-1][0] + SPACE + unenc, None)
- else:
- decoded.append((unenc, None))
+ unencoded = parts.pop(0).strip()
+ if unencoded:
+ words.append((unencoded, None, None))
if parts:
- charset, encoding = [s.lower() for s in parts[0:2]]
- encoded = parts[2]
- dec = None
- if encoding == 'q':
- dec = email.quoprimime.header_decode(encoded)
- elif encoding == 'b':
- paderr = len(encoded) % 4 # Postel's law: add missing padding
- if paderr:
- encoded += '==='[:4 - paderr]
- try:
- dec = email.base64mime.decode(encoded)
- except binascii.Error:
- # Turn this into a higher level exception. BAW: Right
- # now we throw the lower level exception away but
- # when/if we get exception chaining, we'll preserve it.
- raise HeaderParseError
- if dec is None:
- dec = encoded
-
- if decoded and decoded[-1][1] == charset:
- decoded[-1] = (decoded[-1][0] + dec, decoded[-1][1])
- else:
- decoded.append((dec, charset))
- del parts[0:3]
- return decoded
+ charset = parts.pop(0).lower()
+ encoding = parts.pop(0).lower()
+ encoded = parts.pop(0)
+ words.append((encoded, encoding, charset))
+ # The next step is to decode each encoded word by applying the reverse
+ # base64 or quopri transformation. decoded_words is now a list of the
+ # form (decoded_word, charset).
+ decoded_words = []
+ for encoded_string, encoding, charset in words:
+ if encoding is None:
+ # This is an unencoded word.
+ decoded_words.append((encoded_string, charset))
+ elif encoding == 'q':
+ word = email.quoprimime.header_decode(encoded_string)
+ decoded_words.append((word, charset))
+ elif encoding == 'b':
+ paderr = len(encoded_string) % 4 # Postel's law: add missing padding
+ if paderr:
+ encoded_string += '==='[:4 - paderr]
+ try:
+ word = email.base64mime.decode(encoded_string)
+ except binascii.Error:
+ raise HeaderParseError('Base64 decoding error')
+ else:
+ decoded_words.append((word, charset))
+ else:
+ raise AssertionError('Unexpected encoding: ' + encoding)
+ # Now convert all words to bytes and collapse consecutive runs of
+ # similarly encoded words.
+ collapsed = []
+ last_word = last_charset = None
+ for word, charset in decoded_words:
+ if isinstance(word, str):
+ word = bytes(word, 'raw-unicode-escape')
+ if last_word is None:
+ last_word = word
+ last_charset = charset
+ elif charset != last_charset:
+ collapsed.append((last_word, last_charset))
+ last_word = word
+ last_charset = charset
+ elif last_charset is None:
+ last_word += BSPACE + word
+ else:
+ last_word += word
+ collapsed.append((last_word, last_charset))
+ return collapsed
@@ -159,10 +182,11 @@ class Header:
charset is used both as s's initial charset and as the default for
subsequent .append() calls.
- The maximum line length can be specified explicit via maxlinelen. For
+ The maximum line length can be specified explicitly via maxlinelen. For
splitting the first line to a shorter value (to account for the field
header which isn't included in s, e.g. `Subject') pass in the name of
- the field in header_name. The default maxlinelen is 76.
+ the field in header_name. The default maxlinelen is 78 as recommended
+ by RFC 2822.
continuation_ws must be RFC 2822 compliant folding whitespace (usually
either a space or a hard tab) which will be prepended to continuation
@@ -172,60 +196,54 @@ class Header:
"""
if charset is None:
charset = USASCII
- if not isinstance(charset, Charset):
+ elif not isinstance(charset, Charset):
charset = Charset(charset)
self._charset = charset
self._continuation_ws = continuation_ws
- cws_expanded_len = len(continuation_ws.replace('\t', SPACE8))
- # BAW: I believe `chunks' and `maxlinelen' should be non-public.
self._chunks = []
if s is not None:
self.append(s, charset, errors)
if maxlinelen is None:
maxlinelen = MAXLINELEN
+ self._maxlinelen = maxlinelen
if header_name is None:
- # We don't know anything about the field header so the first line
- # is the same length as subsequent lines.
- self._firstlinelen = maxlinelen
+ self._headerlen = 0
else:
- # The first line should be shorter to take into account the field
- # header. Also subtract off 2 extra for the colon and space.
- self._firstlinelen = maxlinelen - len(header_name) - 2
- # Second and subsequent lines should subtract off the length in
- # columns of the continuation whitespace prefix.
- self._maxlinelen = maxlinelen - cws_expanded_len
+ # Take the separating colon and space into account.
+ self._headerlen = len(header_name) + 2
def __str__(self):
- """A synonym for self.encode()."""
- return self.encode()
-
- def __unicode__(self):
- """Helper for the built-in unicode function."""
+ """Return the string value of the header."""
+ self._normalize()
uchunks = []
lastcs = None
- for s, charset in self._chunks:
+ for string, charset in self._chunks:
# We must preserve spaces between encoded and non-encoded word
# boundaries, which means for us we need to add a space when we go
# from a charset to None/us-ascii, or from None/us-ascii to a
# charset. Only do this for the second and subsequent chunks.
nextcs = charset
+ if nextcs == _charset.UNKNOWN8BIT:
+ original_bytes = string.encode('ascii', 'surrogateescape')
+ string = original_bytes.decode('ascii', 'replace')
if uchunks:
if lastcs not in (None, 'us-ascii'):
if nextcs in (None, 'us-ascii'):
- uchunks.append(USPACE)
+ uchunks.append(SPACE)
nextcs = None
elif nextcs not in (None, 'us-ascii'):
- uchunks.append(USPACE)
+ uchunks.append(SPACE)
lastcs = nextcs
- uchunks.append(unicode(s, str(charset)))
- return UEMPTYSTRING.join(uchunks)
+ uchunks.append(string)
+ return EMPTYSTRING.join(uchunks)
# Rich comparison operators for equality only. BAW: does it make sense to
# have or explicitly disable <, <=, >, >= operators?
def __eq__(self, other):
# other may be a Header or a string. Both are fine so coerce
- # ourselves to a string, swap the args and do another comparison.
- return other == self.encode()
+ # ourselves to a unicode (of the unencoded header value), swap the
+ # args and do another comparison.
+ return other == str(self)
def __ne__(self, other):
return not self == other
@@ -239,140 +257,42 @@ class Header:
constructor is used.
s may be a byte string or a Unicode string. If it is a byte string
- (i.e. isinstance(s, str) is true), then charset is the encoding of
+ (i.e. isinstance(s, str) is false), then charset is the encoding of
that byte string, and a UnicodeError will be raised if the string
cannot be decoded with that charset. If s is a Unicode string, then
charset is a hint specifying the character set of the characters in
- the string. In this case, when producing an RFC 2822 compliant header
- using RFC 2047 rules, the Unicode string will be encoded using the
- following charsets in order: us-ascii, the charset hint, utf-8. The
- first character set not to provoke a UnicodeError is used.
+ the string. In either case, when producing an RFC 2822 compliant
+ header using RFC 2047 rules, the string will be encoded using the
+ output codec of the charset. If the string cannot be encoded to the
+ output codec, a UnicodeError will be raised.
- Optional `errors' is passed as the third argument to any unicode() or
- ustr.encode() call.
+ Optional `errors' is passed as the errors argument to the decode
+ call if s is a byte string.
"""
if charset is None:
charset = self._charset
elif not isinstance(charset, Charset):
charset = Charset(charset)
- # If the charset is our faux 8bit charset, leave the string unchanged
- if charset != '8bit':
- # We need to test that the string can be converted to unicode and
- # back to a byte string, given the input and output codecs of the
- # charset.
- if isinstance(s, str):
- # Possibly raise UnicodeError if the byte string can't be
- # converted to a unicode with the input codec of the charset.
- incodec = charset.input_codec or 'us-ascii'
- ustr = unicode(s, incodec, errors)
- # Now make sure that the unicode could be converted back to a
- # byte string with the output codec, which may be different
- # than the iput coded. Still, use the original byte string.
- outcodec = charset.output_codec or 'us-ascii'
- ustr.encode(outcodec, errors)
- elif isinstance(s, unicode):
- # Now we have to be sure the unicode string can be converted
- # to a byte string with a reasonable output codec. We want to
- # use the byte string in the chunk.
- for charset in USASCII, charset, UTF8:
- try:
- outcodec = charset.output_codec or 'us-ascii'
- s = s.encode(outcodec, errors)
- break
- except UnicodeError:
- pass
- else:
- assert False, 'utf-8 conversion failed'
- self._chunks.append((s, charset))
-
- def _split(self, s, charset, maxlinelen, splitchars):
- # Split up a header safely for use with encode_chunks.
- splittable = charset.to_splittable(s)
- encoded = charset.from_splittable(splittable, True)
- elen = charset.encoded_header_len(encoded)
- # If the line's encoded length first, just return it
- if elen <= maxlinelen:
- return [(encoded, charset)]
- # If we have undetermined raw 8bit characters sitting in a byte
- # string, we really don't know what the right thing to do is. We
- # can't really split it because it might be multibyte data which we
- # could break if we split it between pairs. The least harm seems to
- # be to not split the header at all, but that means they could go out
- # longer than maxlinelen.
- if charset == '8bit':
- return [(s, charset)]
- # BAW: I'm not sure what the right test here is. What we're trying to
- # do is be faithful to RFC 2822's recommendation that ($2.2.3):
- #
- # "Note: Though structured field bodies are defined in such a way that
- # folding can take place between many of the lexical tokens (and even
- # within some of the lexical tokens), folding SHOULD be limited to
- # placing the CRLF at higher-level syntactic breaks."
- #
- # For now, I can only imagine doing this when the charset is us-ascii,
- # although it's possible that other charsets may also benefit from the
- # higher-level syntactic breaks.
- elif charset == 'us-ascii':
- return self._split_ascii(s, charset, maxlinelen, splitchars)
- # BAW: should we use encoded?
- elif elen == len(s):
- # We can split on _maxlinelen boundaries because we know that the
- # encoding won't change the size of the string
- splitpnt = maxlinelen
- first = charset.from_splittable(splittable[:splitpnt], False)
- last = charset.from_splittable(splittable[splitpnt:], False)
- else:
- # Binary search for split point
- first, last = _binsplit(splittable, charset, maxlinelen)
- # first is of the proper length so just wrap it in the appropriate
- # chrome. last must be recursively split.
- fsplittable = charset.to_splittable(first)
- fencoded = charset.from_splittable(fsplittable, True)
- chunk = [(fencoded, charset)]
- return chunk + self._split(last, charset, self._maxlinelen, splitchars)
-
- def _split_ascii(self, s, charset, firstlen, splitchars):
- chunks = _split_ascii(s, firstlen, self._maxlinelen,
- self._continuation_ws, splitchars)
- return zip(chunks, [charset]*len(chunks))
-
- def _encode_chunks(self, newchunks, maxlinelen):
- # MIME-encode a header with many different charsets and/or encodings.
- #
- # Given a list of pairs (string, charset), return a MIME-encoded
- # string suitable for use in a header field. Each pair may have
- # different charsets and/or encodings, and the resulting header will
- # accurately reflect each setting.
- #
- # Each encoding can be email.utils.QP (quoted-printable, for
- # ASCII-like character sets like iso-8859-1), email.utils.BASE64
- # (Base64, for non-ASCII like character sets like KOI8-R and
- # iso-2022-jp), or None (no encoding).
- #
- # Each pair will be represented on a separate line; the resulting
- # string will be in the format:
- #
- # =?charset1?q?Mar=EDa_Gonz=E1lez_Alonso?=\n
- # =?charset2?b?SvxyZ2VuIEL2aW5n?="
- chunks = []
- for header, charset in newchunks:
- if not header:
- continue
- if charset is None or charset.header_encoding is None:
- s = header
- else:
- s = charset.header_encode(header)
- # Don't add more folding whitespace than necessary
- if chunks and chunks[-1].endswith(' '):
- extra = ''
+ if not isinstance(s, str):
+ input_charset = charset.input_codec or 'us-ascii'
+ if input_charset == _charset.UNKNOWN8BIT:
+ s = s.decode('us-ascii', 'surrogateescape')
else:
- extra = ' '
- _max_append(chunks, s, maxlinelen, extra)
- joiner = NL + self._continuation_ws
- return joiner.join(chunks)
+ s = s.decode(input_charset, errors)
+ # Ensure that the bytes we're storing can be decoded to the output
+ # character set, otherwise an early error is raised.
+ output_charset = charset.output_codec or 'us-ascii'
+ if output_charset != _charset.UNKNOWN8BIT:
+ try:
+ s.encode(output_charset, errors)
+ except UnicodeEncodeError:
+ if output_charset!='us-ascii':
+ raise
+ charset = UTF8
+ self._chunks.append((s, charset))
- def encode(self, splitchars=';, '):
- """Encode a message header into an RFC-compliant format.
+ def encode(self, splitchars=';, \t', maxlinelen=None, linesep='\n'):
+ r"""Encode a message header into an RFC-compliant format.
There are many issues involved in converting a given string for use in
an email header. Only certain character sets are readable in most
@@ -382,133 +302,245 @@ class Header:
75-character length limit on any given encoded header field, so
line-wrapping must be performed, even with double-byte character sets.
- This method will do its best to convert the string to the correct
- character set used in email, and encode and line wrap it safely with
- the appropriate scheme for that character set.
-
- If the given charset is not known or an error occurs during
- conversion, this function will return the header untouched.
-
- Optional splitchars is a string containing characters to split long
- ASCII lines on, in rough support of RFC 2822's `highest level
- syntactic breaks'. This doesn't affect RFC 2047 encoded lines.
+ Optional maxlinelen specifies the maximum length of each generated
+ line, exclusive of the linesep string. Individual lines may be longer
+ than maxlinelen if a folding point cannot be found. The first line
+ will be shorter by the length of the header name plus ": " if a header
+ name was specified at Header construction time. The default value for
+ maxlinelen is determined at header construction time.
+
+ Optional splitchars is a string containing characters which should be
+ given extra weight by the splitting algorithm during normal header
+ wrapping. This is in very rough support of RFC 2822's `higher level
+ syntactic breaks': split points preceded by a splitchar are preferred
+ during line splitting, with the characters preferred in the order in
+ which they appear in the string. Space and tab may be included in the
+ string to indicate whether preference should be given to one over the
+ other as a split point when other split chars do not appear in the line
+ being split. Splitchars does not affect RFC 2047 encoded lines.
+
+ Optional linesep is a string to be used to separate the lines of
+ the value. The default value is the most useful for typical
+ Python applications, but it can be set to \r\n to produce RFC-compliant
+ line separators when needed.
"""
- newchunks = []
- maxlinelen = self._firstlinelen
- lastlen = 0
- for s, charset in self._chunks:
- # The first bit of the next chunk should be just long enough to
- # fill the next line. Don't forget the space separating the
- # encoded words.
- targetlen = maxlinelen - lastlen - 1
- if targetlen < charset.encoded_header_len(''):
- # Stick it on the next line
- targetlen = maxlinelen
- newchunks += self._split(s, charset, targetlen, splitchars)
- lastchunk, lastcharset = newchunks[-1]
- lastlen = lastcharset.encoded_header_len(lastchunk)
- value = self._encode_chunks(newchunks, maxlinelen)
+ self._normalize()
+ if maxlinelen is None:
+ maxlinelen = self._maxlinelen
+ # A maxlinelen of 0 means don't wrap. For all practical purposes,
+ # choosing a huge number here accomplishes that and makes the
+ # _ValueFormatter algorithm much simpler.
+ if maxlinelen == 0:
+ maxlinelen = 1000000
+ formatter = _ValueFormatter(self._headerlen, maxlinelen,
+ self._continuation_ws, splitchars)
+ for string, charset in self._chunks:
+ lines = string.splitlines()
+ if lines:
+ formatter.feed('', lines[0], charset)
+ else:
+ formatter.feed('', '', charset)
+ for line in lines[1:]:
+ formatter.newline()
+ if charset.header_encoding is not None:
+ formatter.feed(self._continuation_ws, ' ' + line.lstrip(),
+ charset)
+ else:
+ sline = line.lstrip()
+ fws = line[:len(line)-len(sline)]
+ formatter.feed(fws, sline, charset)
+ if len(lines) > 1:
+ formatter.newline()
+ formatter.add_transition()
+ value = formatter._str(linesep)
if _embeded_header.search(value):
raise HeaderParseError("header value appears to contain "
"an embedded header: {!r}".format(value))
return value
+ def _normalize(self):
+ # Step 1: Normalize the chunks so that all runs of identical charsets
+ # get collapsed into a single unicode string.
+ chunks = []
+ last_charset = None
+ last_chunk = []
+ for string, charset in self._chunks:
+ if charset == last_charset:
+ last_chunk.append(string)
+ else:
+ if last_charset is not None:
+ chunks.append((SPACE.join(last_chunk), last_charset))
+ last_chunk = [string]
+ last_charset = charset
+ if last_chunk:
+ chunks.append((SPACE.join(last_chunk), last_charset))
+ self._chunks = chunks
+
-def _split_ascii(s, firstlen, restlen, continuation_ws, splitchars):
- lines = []
- maxlen = firstlen
- for line in s.splitlines():
- # Ignore any leading whitespace (i.e. continuation whitespace) already
- # on the line, since we'll be adding our own.
- line = line.lstrip()
- if len(line) < maxlen:
- lines.append(line)
- maxlen = restlen
- continue
- # Attempt to split the line at the highest-level syntactic break
- # possible. Note that we don't have a lot of smarts about field
+class _ValueFormatter:
+ def __init__(self, headerlen, maxlen, continuation_ws, splitchars):
+ self._maxlen = maxlen
+ self._continuation_ws = continuation_ws
+ self._continuation_ws_len = len(continuation_ws)
+ self._splitchars = splitchars
+ self._lines = []
+ self._current_line = _Accumulator(headerlen)
+
+ def _str(self, linesep):
+ self.newline()
+ return linesep.join(self._lines)
+
+ def __str__(self):
+ return self._str(NL)
+
+ def newline(self):
+ end_of_line = self._current_line.pop()
+ if end_of_line != (' ', ''):
+ self._current_line.push(*end_of_line)
+ if len(self._current_line) > 0:
+ if self._current_line.is_onlyws():
+ self._lines[-1] += str(self._current_line)
+ else:
+ self._lines.append(str(self._current_line))
+ self._current_line.reset()
+
+ def add_transition(self):
+ self._current_line.push(' ', '')
+
+ def feed(self, fws, string, charset):
+ # If the charset has no header encoding (i.e. it is an ASCII encoding)
+ # then we must split the header at the "highest level syntactic break"
+ # possible. Note that we don't have a lot of smarts about field
# syntax; we just try to break on semi-colons, then commas, then
- # whitespace.
- for ch in splitchars:
- if ch in line:
- break
- else:
- # There's nothing useful to split the line on, not even spaces, so
- # just append this line unchanged
- lines.append(line)
- maxlen = restlen
- continue
- # Now split the line on the character plus trailing whitespace
- cre = re.compile(r'%s\s*' % ch)
- if ch in ';,':
- eol = ch
+ # whitespace. Eventually, this should be pluggable.
+ if charset.header_encoding is None:
+ self._ascii_split(fws, string, self._splitchars)
+ return
+ # Otherwise, we're doing either a Base64 or a quoted-printable
+ # encoding which means we don't need to split the line on syntactic
+ # breaks. We can basically just find enough characters to fit on the
+ # current line, minus the RFC 2047 chrome. What makes this trickier
+ # though is that we have to split at octet boundaries, not character
+ # boundaries but it's only safe to split at character boundaries so at
+ # best we can only get close.
+ encoded_lines = charset.header_encode_lines(string, self._maxlengths())
+ # The first element extends the current line, but if it's None then
+ # nothing more fit on the current line so start a new line.
+ try:
+ first_line = encoded_lines.pop(0)
+ except IndexError:
+ # There are no encoded lines, so we're done.
+ return
+ if first_line is not None:
+ self._append_chunk(fws, first_line)
+ try:
+ last_line = encoded_lines.pop()
+ except IndexError:
+ # There was only one line.
+ return
+ self.newline()
+ self._current_line.push(self._continuation_ws, last_line)
+ # Everything else are full lines in themselves.
+ for line in encoded_lines:
+ self._lines.append(self._continuation_ws + line)
+
+ def _maxlengths(self):
+ # The first line's length.
+ yield self._maxlen - len(self._current_line)
+ while True:
+ yield self._maxlen - self._continuation_ws_len
+
+ def _ascii_split(self, fws, string, splitchars):
+ # The RFC 2822 header folding algorithm is simple in principle but
+ # complex in practice. Lines may be folded any place where "folding
+ # white space" appears by inserting a linesep character in front of the
+ # FWS. The complication is that not all spaces or tabs qualify as FWS,
+ # and we are also supposed to prefer to break at "higher level
+ # syntactic breaks". We can't do either of these without intimate
+ # knowledge of the structure of structured headers, which we don't have
+ # here. So the best we can do here is prefer to break at the specified
+ # splitchars, and hope that we don't choose any spaces or tabs that
+ # aren't legal FWS. (This is at least better than the old algorithm,
+ # where we would sometimes *introduce* FWS after a splitchar, or the
+ # algorithm before that, where we would turn all white space runs into
+ # single spaces or tabs.)
+ parts = re.split("(["+FWS+"]+)", fws+string)
+ if parts[0]:
+ parts[:0] = ['']
else:
- eol = ''
- joiner = eol + ' '
- joinlen = len(joiner)
- wslen = len(continuation_ws.replace('\t', SPACE8))
- this = []
- linelen = 0
- for part in cre.split(line):
- curlen = linelen + max(0, len(this)-1) * joinlen
- partlen = len(part)
- onfirstline = not lines
- # We don't want to split after the field name, if we're on the
- # first line and the field name is present in the header string.
- if ch == ' ' and onfirstline and \
- len(this) == 1 and fcre.match(this[0]):
- this.append(part)
- linelen += partlen
- elif curlen + partlen > maxlen:
- if this:
- lines.append(joiner.join(this) + eol)
- # If this part is longer than maxlen and we aren't already
- # splitting on whitespace, try to recursively split this line
- # on whitespace.
- if partlen > maxlen and ch != ' ':
- subl = _split_ascii(part, maxlen, restlen,
- continuation_ws, ' ')
- lines.extend(subl[:-1])
- this = [subl[-1]]
+ parts.pop(0)
+ for fws, part in zip(*[iter(parts)]*2):
+ self._append_chunk(fws, part)
+
+ def _append_chunk(self, fws, string):
+ self._current_line.push(fws, string)
+ if len(self._current_line) > self._maxlen:
+ # Find the best split point, working backward from the end.
+ # There might be none, on a long first line.
+ for ch in self._splitchars:
+ for i in range(self._current_line.part_count()-1, 0, -1):
+ if ch.isspace():
+ fws = self._current_line[i][0]
+ if fws and fws[0]==ch:
+ break
+ prevpart = self._current_line[i-1][1]
+ if prevpart and prevpart[-1]==ch:
+ break
else:
- this = [part]
- linelen = wslen + len(this[-1])
- maxlen = restlen
+ continue
+ break
else:
- this.append(part)
- linelen += partlen
- # Put any left over parts on a line by themselves
- if this:
- lines.append(joiner.join(this))
- return lines
+ fws, part = self._current_line.pop()
+ if self._current_line._initial_size > 0:
+ # There will be a header, so leave it on a line by itself.
+ self.newline()
+ if not fws:
+ # We don't use continuation_ws here because the whitespace
+ # after a header should always be a space.
+ fws = ' '
+ self._current_line.push(fws, part)
+ return
+ remainder = self._current_line.pop_from(i)
+ self._lines.append(str(self._current_line))
+ self._current_line.reset(remainder)
+
+
+class _Accumulator(list):
+
+ def __init__(self, initial_size=0):
+ self._initial_size = initial_size
+ super().__init__()
+
+ def push(self, fws, string):
+ self.append((fws, string))
+
+ def pop_from(self, i=0):
+ popped = self[i:]
+ self[i:] = []
+ return popped
+
+ def pop(self):
+ if self.part_count()==0:
+ return ('', '')
+ return super().pop()
+
+ def __len__(self):
+ return sum((len(fws)+len(part) for fws, part in self),
+ self._initial_size)
+ def __str__(self):
+ return EMPTYSTRING.join((EMPTYSTRING.join((fws, part))
+ for fws, part in self))
-
-def _binsplit(splittable, charset, maxlinelen):
- i = 0
- j = len(splittable)
- while i < j:
- # Invariants:
- # 1. splittable[:k] fits for all k <= i (note that we *assume*,
- # at the start, that splittable[:0] fits).
- # 2. splittable[:k] does not fit for any k > j (at the start,
- # this means we shouldn't look at any k > len(splittable)).
- # 3. We don't know about splittable[:k] for k in i+1..j.
- # 4. We want to set i to the largest k that fits, with i <= k <= j.
- #
- m = (i+j+1) >> 1 # ceiling((i+j)/2); i < m <= j
- chunk = charset.from_splittable(splittable[:m], True)
- chunklen = charset.encoded_header_len(chunk)
- if chunklen <= maxlinelen:
- # m is acceptable, so is a new lower bound.
- i = m
- else:
- # m is not acceptable, so final i must be < m.
- j = m - 1
- # i == j. Invariant #1 implies that splittable[:i] fits, and
- # invariant #2 implies that splittable[:i+1] does not fit, so i
- # is what we're looking for.
- first = charset.from_splittable(splittable[:i], False)
- last = charset.from_splittable(splittable[i:], False)
- return first, last
+ def reset(self, startval=None):
+ if startval is None:
+ startval = []
+ self[:] = startval
+ self._initial_size = 0
+
+ def is_onlyws(self):
+ return self._initial_size==0 and (not self or str(self).isspace())
+
+ def part_count(self):
+ return super().__len__()
diff --git a/Lib/email/iterators.py b/Lib/email/iterators.py
index e99f2280da3..3adc4a04ba8 100644
--- a/Lib/email/iterators.py
+++ b/Lib/email/iterators.py
@@ -12,7 +12,7 @@ __all__ = [
]
import sys
-from cStringIO import StringIO
+from io import StringIO
@@ -39,7 +39,7 @@ def body_line_iterator(msg, decode=False):
"""
for subpart in msg.walk():
payload = subpart.get_payload(decode=decode)
- if isinstance(payload, basestring):
+ if isinstance(payload, str):
for line in StringIO(payload):
yield line
@@ -63,11 +63,11 @@ def _structure(msg, fp=None, level=0, include_default=False):
if fp is None:
fp = sys.stdout
tab = ' ' * (level * 4)
- print >> fp, tab + msg.get_content_type(),
+ print(tab + msg.get_content_type(), end='', file=fp)
if include_default:
- print >> fp, '[%s]' % msg.get_default_type()
+ print(' [%s]' % msg.get_default_type(), file=fp)
else:
- print >> fp
+ print(file=fp)
if msg.is_multipart():
for subpart in msg.get_payload():
_structure(subpart, fp, level+1, include_default)
diff --git a/Lib/email/message.py b/Lib/email/message.py
index 7c93370984c..f1ffcdb4de0 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Author: Barry Warsaw
# Contact: email-sig@python.org
@@ -8,14 +8,17 @@ __all__ = ['Message']
import re
import uu
+import base64
import binascii
import warnings
-from cStringIO import StringIO
+from io import BytesIO, StringIO
# Intrapackage imports
-import email.charset
from email import utils
from email import errors
+from email import header
+from email import charset as _charset
+Charset = _charset.Charset
SEMISPACE = '; '
@@ -23,14 +26,31 @@ SEMISPACE = '; '
# existence of which force quoting of the parameter value.
tspecials = re.compile(r'[ \(\)<>@,;:\\"/\[\]\?=]')
+# How to figure out if we are processing strings that come from a byte
+# source with undecodable characters.
+_has_surrogates = re.compile(
+ '([^\ud800-\udbff]|\A)[\udc00-\udfff]([^\udc00-\udfff]|\Z)').search
+
# Helper functions
+def _sanitize_header(name, value):
+ # If the header value contains surrogates, return a Header using
+ # the unknown-8bit charset to encode the bytes as encoded words.
+ if not isinstance(value, str):
+ # Assume it is already a header object
+ return value
+ if _has_surrogates(value):
+ return header.Header(value, charset=_charset.UNKNOWN8BIT,
+ header_name=name)
+ else:
+ return value
+
def _splitparam(param):
# Split header parameters. BAW: this may be too simple. It isn't
# strictly RFC 2045 (section 5.1) compliant, but it catches most headers
- # found in the wild. We may eventually need a full fledged parser
- # eventually.
- a, sep, b = param.partition(';')
+ # found in the wild. We may eventually need a full fledged parser.
+ # RDM: we might have a Header here; for now just stringify it.
+ a, sep, b = str(param).partition(';')
if not sep:
return a.strip(), None
return a.strip(), b.strip()
@@ -40,16 +60,26 @@ def _formatparam(param, value=None, quote=True):
This will quote the value if needed or if quote is true. If value is a
three tuple (charset, language, value), it will be encoded according
- to RFC2231 rules.
+ to RFC2231 rules. If it contains non-ascii characters it will likewise
+ be encoded according to RFC2231 rules, using the utf-8 charset and
+ a null language.
"""
if value is not None and len(value) > 0:
# A tuple is used for RFC 2231 encoded parameter values where items
# are (charset, language, value). charset is a string, not a Charset
- # instance.
+ # instance. RFC 2231 encoded values are never quoted, per RFC.
if isinstance(value, tuple):
# Encode as per RFC 2231
param += '*'
value = utils.encode_rfc2231(value[2], value[0], value[1])
+ return '%s=%s' % (param, value)
+ else:
+ try:
+ value.encode('ascii')
+ except UnicodeEncodeError:
+ param += '*'
+ value = utils.encode_rfc2231(value, 'utf-8', '')
+ return '%s=%s' % (param, value)
# BAW: Please check this. I think that if quote is set it should
# force quoting even if not necessary.
if quote or tspecials.search(value):
@@ -60,6 +90,8 @@ def _formatparam(param, value=None, quote=True):
return param
def _parseparam(s):
+ # RDM This might be a Header, so for now stringify it.
+ s = ';' + str(s)
plist = []
while s[:1] == ';':
s = s[1:]
@@ -119,21 +151,20 @@ class Message:
"""Return the entire formatted message as a string.
This includes the headers, body, and envelope header.
"""
- return self.as_string(unixfrom=True)
+ return self.as_string()
- def as_string(self, unixfrom=False):
+ def as_string(self, unixfrom=False, maxheaderlen=0):
"""Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This is a convenience method and may not generate the message exactly
- as you intend because by default it mangles lines that begin with
- "From ". For more flexibility, use the flatten() method of a
+ as you intend. For more flexibility, use the flatten() method of a
Generator instance.
"""
from email.generator import Generator
fp = StringIO()
- g = Generator(fp)
+ g = Generator(fp, mangle_from_=False, maxheaderlen=maxheaderlen)
g.flatten(self, unixfrom=unixfrom)
return fp.getvalue()
@@ -185,34 +216,73 @@ class Message:
If the message is a multipart and the decode flag is True, then None
is returned.
"""
- if i is None:
- payload = self._payload
- elif not isinstance(self._payload, list):
- raise TypeError('Expected list, got %s' % type(self._payload))
- else:
- payload = self._payload[i]
- if decode:
- if self.is_multipart():
+ # Here is the logic table for this code, based on the email5.0.0 code:
+ # i decode is_multipart result
+ # ------ ------ ------------ ------------------------------
+ # None True True None
+ # i True True None
+ # None False True _payload (a list)
+ # i False True _payload element i (a Message)
+ # i False False error (not a list)
+ # i True False error (not a list)
+ # None False False _payload
+ # None True False _payload decoded (bytes)
+ # Note that Barry planned to factor out the 'decode' case, but that
+ # isn't so easy now that we handle the 8 bit data, which needs to be
+ # converted in both the decode and non-decode path.
+ if self.is_multipart():
+ if decode:
return None
- cte = self.get('content-transfer-encoding', '').lower()
- if cte == 'quoted-printable':
- return utils._qdecode(payload)
- elif cte == 'base64':
- try:
- return utils._bdecode(payload)
- except binascii.Error:
- # Incorrect padding
- return payload
- elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
- sfp = StringIO()
+ if i is None:
+ return self._payload
+ else:
+ return self._payload[i]
+ # For backward compatibility, Use isinstance and this error message
+ # instead of the more logical is_multipart test.
+ if i is not None and not isinstance(self._payload, list):
+ raise TypeError('Expected list, got %s' % type(self._payload))
+ payload = self._payload
+ # cte might be a Header, so for now stringify it.
+ cte = str(self.get('content-transfer-encoding', '')).lower()
+ # payload may be bytes here.
+ if isinstance(payload, str):
+ if _has_surrogates(payload):
+ bpayload = payload.encode('ascii', 'surrogateescape')
+ if not decode:
+ try:
+ payload = bpayload.decode(self.get_param('charset', 'ascii'), 'replace')
+ except LookupError:
+ payload = bpayload.decode('ascii', 'replace')
+ elif decode:
try:
- uu.decode(StringIO(payload+'\n'), sfp, quiet=True)
- payload = sfp.getvalue()
- except uu.Error:
- # Some decoding problem
- return payload
- # Everything else, including encodings with 8bit or 7bit are returned
- # unchanged.
+ bpayload = payload.encode('ascii')
+ except UnicodeError:
+ # This won't happen for RFC compliant messages (messages
+ # containing only ASCII codepoints in the unicode input).
+ # If it does happen, turn the string into bytes in a way
+ # guaranteed not to fail.
+ bpayload = payload.encode('raw-unicode-escape')
+ if not decode:
+ return payload
+ if cte == 'quoted-printable':
+ return utils._qdecode(bpayload)
+ elif cte == 'base64':
+ try:
+ return base64.b64decode(bpayload)
+ except binascii.Error:
+ # Incorrect padding
+ return bpayload
+ elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
+ in_file = BytesIO(bpayload)
+ out_file = BytesIO()
+ try:
+ uu.decode(in_file, out_file, quiet=True)
+ return out_file.getvalue()
+ except uu.Error:
+ # Some decoding problem
+ return bpayload
+ if isinstance(payload, str):
+ return bpayload
return payload
def set_payload(self, payload, charset=None):
@@ -238,18 +308,13 @@ class Message:
and encoded properly, if needed, when generating the plain text
representation of the message. MIME headers (MIME-Version,
Content-Type, Content-Transfer-Encoding) will be added as needed.
-
"""
if charset is None:
self.del_param('charset')
self._charset = None
return
- if isinstance(charset, basestring):
- charset = email.charset.Charset(charset)
- if not isinstance(charset, email.charset.Charset):
- raise TypeError(charset)
- # BAW: should we accept strings that can serve as arguments to the
- # Charset constructor?
+ if not isinstance(charset, Charset):
+ charset = Charset(charset)
self._charset = charset
if 'MIME-Version' not in self:
self.add_header('MIME-Version', '1.0')
@@ -258,9 +323,7 @@ class Message:
charset=charset.get_output_charset())
else:
self.set_param('charset', charset.get_output_charset())
- if isinstance(self._payload, unicode):
- self._payload = self._payload.encode(charset.output_charset)
- if str(charset) != charset.get_output_charset():
+ if charset != charset.get_output_charset():
self._payload = charset.body_encode(self._payload)
if 'Content-Transfer-Encoding' not in self:
cte = charset.get_body_encoding()
@@ -316,10 +379,9 @@ class Message:
def __contains__(self, name):
return name.lower() in [k.lower() for k, v in self._headers]
- def has_key(self, name):
- """Return true if the message contains the header."""
- missing = object()
- return self.get(name, missing) is not missing
+ def __iter__(self):
+ for field, value in self._headers:
+ yield field
def keys(self):
"""Return a list of all the message's header field names.
@@ -339,7 +401,7 @@ class Message:
Any fields deleted and re-inserted are always appended to the header
list.
"""
- return [v for k, v in self._headers]
+ return [_sanitize_header(k, v) for k, v in self._headers]
def items(self):
"""Get all the message's header fields and values.
@@ -349,7 +411,7 @@ class Message:
Any fields deleted and re-inserted are always appended to the header
list.
"""
- return self._headers[:]
+ return [(k, _sanitize_header(k, v)) for k, v in self._headers]
def get(self, name, failobj=None):
"""Get a header value.
@@ -360,7 +422,7 @@ class Message:
name = name.lower()
for k, v in self._headers:
if k.lower() == name:
- return v
+ return _sanitize_header(k, v)
return failobj
#
@@ -380,7 +442,7 @@ class Message:
name = name.lower()
for k, v in self._headers:
if k.lower() == name:
- values.append(v)
+ values.append(_sanitize_header(k, v))
if not values:
return failobj
return values
@@ -392,13 +454,18 @@ class Message:
additional parameters for the header field, with underscores converted
to dashes. Normally the parameter will be added as key="value" unless
value is None, in which case only the key will be added. If a
- parameter value contains non-ASCII characters it must be specified as a
+ parameter value contains non-ASCII characters it can be specified as a
three-tuple of (charset, language, value), in which case it will be
- encoded according to RFC2231 rules.
+ encoded according to RFC2231 rules. Otherwise it will be encoded using
+ the utf-8 charset and a language of ''.
- Example:
+ Examples:
msg.add_header('content-disposition', 'attachment', filename='bud.gif')
+ msg.add_header('content-disposition', 'attachment',
+ filename=('utf-8', '', Fußballer.ppt'))
+ msg.add_header('content-disposition', 'attachment',
+ filename='Fußballer.ppt'))
"""
parts = []
for k, v in _params.items():
@@ -497,7 +564,7 @@ class Message:
if value is missing:
return failobj
params = []
- for p in _parseparam(';' + value):
+ for p in _parseparam(value):
try:
name, val = p.split('=', 1)
name = name.strip()
@@ -546,17 +613,15 @@ class Message:
the form (CHARSET, LANGUAGE, VALUE). Note that both CHARSET and
LANGUAGE can be None, in which case you should consider VALUE to be
encoded in the us-ascii charset. You can usually ignore LANGUAGE.
+ The parameter value (either the returned string, or the VALUE item in
+ the 3-tuple) is always unquoted, unless unquote is set to False.
- Your application should be prepared to deal with 3-tuple return
- values, and can convert the parameter to a Unicode string like so:
+ If your application doesn't care whether the parameter was RFC 2231
+ encoded, it can turn the return value into a string as follows:
param = msg.get_param('foo')
- if isinstance(param, tuple):
- param = unicode(param[2], param[0] or 'us-ascii')
+ param = email.utils.collapse_rfc2231_value(rawparam)
- In any case, the parameter value (either the returned string, or the
- VALUE item in the 3-tuple) is always unquoted, unless unquote is set
- to False.
"""
if header not in self:
return failobj
@@ -762,14 +827,13 @@ class Message:
# LookupError will be raised if the charset isn't known to
# Python. UnicodeError will be raised if the encoded text
# contains a character not in the charset.
- charset = unicode(charset[2], pcharset).encode('us-ascii')
+ as_bytes = charset[2].encode('raw-unicode-escape')
+ charset = str(as_bytes, pcharset)
except (LookupError, UnicodeError):
charset = charset[2]
- # charset character must be in us-ascii range
+ # charset characters must be in us-ascii range
try:
- if isinstance(charset, str):
- charset = unicode(charset, 'us-ascii')
- charset = charset.encode('us-ascii')
+ charset.encode('us-ascii')
except UnicodeError:
return failobj
# RFC 2046, $4.1.2 says charsets are not case sensitive
diff --git a/Lib/email/mime/audio.py b/Lib/email/mime/audio.py
index c7290c4b1c2..fbc118951ae 100644
--- a/Lib/email/mime/audio.py
+++ b/Lib/email/mime/audio.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Author: Anthony Baxter
# Contact: email-sig@python.org
@@ -8,7 +8,7 @@ __all__ = ['MIMEAudio']
import sndhdr
-from cStringIO import StringIO
+from io import BytesIO
from email import encoders
from email.mime.nonmultipart import MIMENonMultipart
@@ -30,7 +30,7 @@ def _whatsnd(data):
command and use the standard 'magic' file, as shipped with a modern Unix.
"""
hdr = data[:512]
- fakefile = StringIO(hdr)
+ fakefile = BytesIO(hdr)
for testfn in sndhdr.tests:
res = testfn(hdr, fakefile)
if res is not None:
diff --git a/Lib/email/parser.py b/Lib/email/parser.py
index 2fcaf254562..1c931ea9dea 100644
--- a/Lib/email/parser.py
+++ b/Lib/email/parser.py
@@ -1,13 +1,13 @@
-# Copyright (C) 2001-2006 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# Author: Barry Warsaw, Thomas Wouters, Anthony Baxter
# Contact: email-sig@python.org
"""A parser of RFC 2822 and MIME email messages."""
-__all__ = ['Parser', 'HeaderParser']
+__all__ = ['Parser', 'HeaderParser', 'BytesParser']
import warnings
-from cStringIO import StringIO
+from io import StringIO, TextIOWrapper
from email.feedparser import FeedParser
from email.message import Message
@@ -89,3 +89,48 @@ class HeaderParser(Parser):
def parsestr(self, text, headersonly=True):
return Parser.parsestr(self, text, True)
+
+
+class BytesParser:
+
+ def __init__(self, *args, **kw):
+ """Parser of binary RFC 2822 and MIME email messages.
+
+ Creates an in-memory object tree representing the email message, which
+ can then be manipulated and turned over to a Generator to return the
+ textual representation of the message.
+
+ The input must be formatted as a block of RFC 2822 headers and header
+ continuation lines, optionally preceeded by a `Unix-from' header. The
+ header block is terminated either by the end of the input or by a
+ blank line.
+
+ _class is the class to instantiate for new message objects when they
+ must be created. This class must have a constructor that can take
+ zero arguments. Default is Message.Message.
+ """
+ self.parser = Parser(*args, **kw)
+
+ def parse(self, fp, headersonly=False):
+ """Create a message structure from the data in a binary file.
+
+ Reads all the data from the file and returns the root of the message
+ structure. Optional headersonly is a flag specifying whether to stop
+ parsing after reading the headers or not. The default is False,
+ meaning it parses the entire contents of the file.
+ """
+ fp = TextIOWrapper(fp, encoding='ascii', errors='surrogateescape')
+ with fp:
+ return self.parser.parse(fp, headersonly)
+
+
+ def parsebytes(self, text, headersonly=False):
+ """Create a message structure from a byte string.
+
+ Returns the root of the message structure. Optional headersonly is a
+ flag specifying whether to stop parsing after reading the headers or
+ not. The default is False, meaning it parses the entire contents of
+ the file.
+ """
+ text = text.decode('ASCII', errors='surrogateescape')
+ return self.parser.parsestr(text, headersonly)
diff --git a/Lib/email/quoprimime.py b/Lib/email/quoprimime.py
index 0c18a9e04ef..78638d5904c 100644
--- a/Lib/email/quoprimime.py
+++ b/Lib/email/quoprimime.py
@@ -29,70 +29,84 @@ wrapping issues, use the email.header module.
__all__ = [
'body_decode',
'body_encode',
- 'body_quopri_check',
- 'body_quopri_len',
+ 'body_length',
'decode',
'decodestring',
- 'encode',
- 'encodestring',
'header_decode',
'header_encode',
- 'header_quopri_check',
- 'header_quopri_len',
+ 'header_length',
'quote',
'unquote',
]
import re
+import io
-from string import hexdigits
-from email.utils import fix_eols
+from string import ascii_letters, digits, hexdigits
CRLF = '\r\n'
NL = '\n'
+EMPTYSTRING = ''
-# See also Charset.py
-MISC_LEN = 7
+# Build a mapping of octets to the expansion of that octet. Since we're only
+# going to have 256 of these things, this isn't terribly inefficient
+# space-wise. Remember that headers and bodies have different sets of safe
+# characters. Initialize both maps with the full expansion, and then override
+# the safe bytes with the more compact form.
+_QUOPRI_HEADER_MAP = dict((c, '=%02X' % c) for c in range(256))
+_QUOPRI_BODY_MAP = _QUOPRI_HEADER_MAP.copy()
+
+# Safe header bytes which need no encoding.
+for c in b'-!*+/' + ascii_letters.encode('ascii') + digits.encode('ascii'):
+ _QUOPRI_HEADER_MAP[c] = chr(c)
+# Headers have one other special encoding; spaces become underscores.
+_QUOPRI_HEADER_MAP[ord(' ')] = '_'
+
+# Safe body bytes which need no encoding.
+for c in (b' !"#$%&\'()*+,-./0123456789:;<>'
+ b'?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`'
+ b'abcdefghijklmnopqrstuvwxyz{|}~\t'):
+ _QUOPRI_BODY_MAP[c] = chr(c)
-hqre = re.compile(r'[^-a-zA-Z0-9!*+/ ]')
-bqre = re.compile(r'[^ !-<>-~\t]')
-
# Helpers
-def header_quopri_check(c):
- """Return True if the character should be escaped with header quopri."""
- return bool(hqre.match(c))
+def header_check(octet):
+ """Return True if the octet should be escaped with header quopri."""
+ return chr(octet) != _QUOPRI_HEADER_MAP[octet]
-def body_quopri_check(c):
- """Return True if the character should be escaped with body quopri."""
- return bool(bqre.match(c))
+def body_check(octet):
+ """Return True if the octet should be escaped with body quopri."""
+ return chr(octet) != _QUOPRI_BODY_MAP[octet]
-def header_quopri_len(s):
- """Return the length of str when it is encoded with header quopri."""
- count = 0
- for c in s:
- if hqre.match(c):
- count += 3
- else:
- count += 1
- return count
+def header_length(bytearray):
+ """Return a header quoted-printable encoding length.
+ Note that this does not include any RFC 2047 chrome added by
+ `header_encode()`.
+
+ :param bytearray: An array of bytes (a.k.a. octets).
+ :return: The length in bytes of the byte array when it is encoded with
+ quoted-printable for headers.
+ """
+ return sum(len(_QUOPRI_HEADER_MAP[octet]) for octet in bytearray)
-def body_quopri_len(str):
- """Return the length of str when it is encoded with body quopri."""
- count = 0
- for c in str:
- if bqre.match(c):
- count += 3
- else:
- count += 1
- return count
+
+def body_length(bytearray):
+ """Return a body quoted-printable encoding length.
+
+ :param bytearray: An array of bytes (a.k.a. octets).
+ :return: The length in bytes of the byte array when it is encoded with
+ quoted-printable for bodies.
+ """
+ return sum(len(_QUOPRI_BODY_MAP[octet]) for octet in bytearray)
def _max_append(L, s, maxlen, extra=''):
+ if not isinstance(s, str):
+ s = chr(s)
if not L:
L.append(s.lstrip())
elif len(L[-1]) + len(s) <= maxlen:
@@ -107,12 +121,11 @@ def unquote(s):
def quote(c):
- return "=%02X" % ord(c)
+ return '=%02X' % ord(c)
+
-
-def header_encode(header, charset="iso-8859-1", keep_eols=False,
- maxlinelen=76, eol=NL):
+def header_encode(header_bytes, charset='iso-8859-1'):
"""Encode a single header line with quoted-printable (like) encoding.
Defined in RFC 2045, this `Q' encoding is similar to quoted-printable, but
@@ -120,149 +133,122 @@ def header_encode(header, charset="iso-8859-1", keep_eols=False,
bit characters (and some 8 bit) to remain more or less readable in non-RFC
2045 aware mail clients.
- charset names the character set to use to encode the header. It defaults
- to iso-8859-1.
-
- The resulting string will be in the form:
-
- "=?charset?q?I_f=E2rt_in_your_g=E8n=E8ral_dire=E7tion?\\n
- =?charset?q?Silly_=C8nglish_Kn=EEghts?="
-
- with each line wrapped safely at, at most, maxlinelen characters (defaults
- to 76 characters). If maxlinelen is None, the entire string is encoded in
- one chunk with no splitting.
-
- End-of-line characters (\\r, \\n, \\r\\n) will be automatically converted
- to the canonical email line separator \\r\\n unless the keep_eols
- parameter is True (the default is False).
-
- Each line of the header will be terminated in the value of eol, which
- defaults to "\\n". Set this to "\\r\\n" if you are using the result of
- this function directly in email.
+ charset names the character set to use in the RFC 2046 header. It
+ defaults to iso-8859-1.
"""
- # Return empty headers unchanged
- if not header:
- return header
-
- if not keep_eols:
- header = fix_eols(header)
-
- # Quopri encode each line, in encoded chunks no greater than maxlinelen in
- # length, after the RFC chrome is added in.
- quoted = []
- if maxlinelen is None:
- # An obnoxiously large number that's good enough
- max_encoded = 100000
- else:
- max_encoded = maxlinelen - len(charset) - MISC_LEN - 1
-
- for c in header:
- # Space may be represented as _ instead of =20 for readability
- if c == ' ':
- _max_append(quoted, '_', max_encoded)
- # These characters can be included verbatim
- elif not hqre.match(c):
- _max_append(quoted, c, max_encoded)
- # Otherwise, replace with hex value like =E2
- else:
- _max_append(quoted, "=%02X" % ord(c), max_encoded)
-
+ # Return empty headers as an empty string.
+ if not header_bytes:
+ return ''
+ # Iterate over every byte, encoding if necessary.
+ encoded = []
+ for octet in header_bytes:
+ encoded.append(_QUOPRI_HEADER_MAP[octet])
# Now add the RFC chrome to each encoded chunk and glue the chunks
- # together. BAW: should we be able to specify the leading whitespace in
- # the joiner?
- joiner = eol + ' '
- return joiner.join(['=?%s?q?%s?=' % (charset, line) for line in quoted])
+ # together.
+ return '=?%s?q?%s?=' % (charset, EMPTYSTRING.join(encoded))
+
+
+class _body_accumulator(io.StringIO):
+
+ def __init__(self, maxlinelen, eol, *args, **kw):
+ super().__init__(*args, **kw)
+ self.eol = eol
+ self.maxlinelen = self.room = maxlinelen
+
+ def write_str(self, s):
+ """Add string s to the accumulated body."""
+ self.write(s)
+ self.room -= len(s)
+
+ def newline(self):
+ """Write eol, then start new line."""
+ self.write_str(self.eol)
+ self.room = self.maxlinelen
+
+ def write_soft_break(self):
+ """Write a soft break, then start a new line."""
+ self.write_str('=')
+ self.newline()
+
+ def write_wrapped(self, s, extra_room=0):
+ """Add a soft line break if needed, then write s."""
+ if self.room < len(s) + extra_room:
+ self.write_soft_break()
+ self.write_str(s)
+
+ def write_char(self, c, is_last_char):
+ if not is_last_char:
+ # Another character follows on this line, so we must leave
+ # extra room, either for it or a soft break, and whitespace
+ # need not be quoted.
+ self.write_wrapped(c, extra_room=1)
+ elif c not in ' \t':
+ # For this and remaining cases, no more characters follow,
+ # so there is no need to reserve extra room (since a hard
+ # break will immediately follow).
+ self.write_wrapped(c)
+ elif self.room >= 3:
+ # It's a whitespace character at end-of-line, and we have room
+ # for the three-character quoted encoding.
+ self.write(quote(c))
+ elif self.room == 2:
+ # There's room for the whitespace character and a soft break.
+ self.write(c)
+ self.write_soft_break()
+ else:
+ # There's room only for a soft break. The quoted whitespace
+ # will be the only content on the subsequent line.
+ self.write_soft_break()
+ self.write(quote(c))
-
-def encode(body, binary=False, maxlinelen=76, eol=NL):
+def body_encode(body, maxlinelen=76, eol=NL):
"""Encode with quoted-printable, wrapping at maxlinelen characters.
- If binary is False (the default), end-of-line characters will be converted
- to the canonical email end-of-line sequence \\r\\n. Otherwise they will
- be left verbatim.
-
Each line of encoded text will end with eol, which defaults to "\\n". Set
this to "\\r\\n" if you will be using the result of this function directly
in an email.
- Each line will be wrapped at, at most, maxlinelen characters (defaults to
- 76 characters). Long lines will have the `soft linefeed' quoted-printable
- character "=" appended to them, so the decoded text will be identical to
- the original text.
+ Each line will be wrapped at, at most, maxlinelen characters before the
+ eol string (maxlinelen defaults to 76 characters, the maximum value
+ permitted by RFC 2045). Long lines will have the 'soft line break'
+ quoted-printable character "=" appended to them, so the decoded text will
+ be identical to the original text.
+
+ The minimum maxlinelen is 4 to have room for a quoted character ("=XX")
+ followed by a soft line break. Smaller values will generate a
+ ValueError.
+
"""
+
+ if maxlinelen < 4:
+ raise ValueError("maxlinelen must be at least 4")
if not body:
return body
- if not binary:
- body = fix_eols(body)
-
- # BAW: We're accumulating the body text by string concatenation. That
- # can't be very efficient, but I don't have time now to rewrite it. It
- # just feels like this algorithm could be more efficient.
- encoded_body = ''
- lineno = -1
- # Preserve line endings here so we can check later to see an eol needs to
- # be added to the output later.
- lines = body.splitlines(1)
- for line in lines:
- # But strip off line-endings for processing this line.
- if line.endswith(CRLF):
- line = line[:-2]
- elif line[-1] in CRLF:
- line = line[:-1]
-
- lineno += 1
- encoded_line = ''
- prev = None
- linelen = len(line)
- # Now we need to examine every character to see if it needs to be
- # quopri encoded. BAW: again, string concatenation is inefficient.
- for j in range(linelen):
- c = line[j]
- prev = c
- if bqre.match(c):
+ # The last line may or may not end in eol, but all other lines do.
+ last_has_eol = (body[-1] in '\r\n')
+
+ # This accumulator will make it easier to build the encoded body.
+ encoded_body = _body_accumulator(maxlinelen, eol)
+
+ lines = body.splitlines()
+ last_line_no = len(lines) - 1
+ for line_no, line in enumerate(lines):
+ last_char_index = len(line) - 1
+ for i, c in enumerate(line):
+ if body_check(ord(c)):
c = quote(c)
- elif j+1 == linelen:
- # Check for whitespace at end of line; special case
- if c not in ' \t':
- encoded_line += c
- prev = c
- continue
- # Check to see to see if the line has reached its maximum length
- if len(encoded_line) + len(c) >= maxlinelen:
- encoded_body += encoded_line + '=' + eol
- encoded_line = ''
- encoded_line += c
- # Now at end of line..
- if prev and prev in ' \t':
- # Special case for whitespace at end of file
- if lineno + 1 == len(lines):
- prev = quote(prev)
- if len(encoded_line) + len(prev) > maxlinelen:
- encoded_body += encoded_line + '=' + eol + prev
- else:
- encoded_body += encoded_line + prev
- # Just normal whitespace at end of line
- else:
- encoded_body += encoded_line + prev + '=' + eol
- encoded_line = ''
- # Now look at the line we just finished and it has a line ending, we
- # need to add eol to the end of the line.
- if lines[lineno].endswith(CRLF) or lines[lineno][-1] in CRLF:
- encoded_body += encoded_line + eol
- else:
- encoded_body += encoded_line
- encoded_line = ''
- return encoded_body
+ encoded_body.write_char(c, i==last_char_index)
+ # Add an eol if input line had eol. All input lines have eol except
+ # possibly the last one.
+ if line_no < last_line_no or last_has_eol:
+ encoded_body.newline()
+ return encoded_body.getvalue()
-# For convenience and backwards compatibility w/ standard base64 module
-body_encode = encode
-encodestring = encode
-
# BAW: I'm not sure if the intent was for the signature of this function to be
# the same as base64MIME.decode() or not...
def decode(encoded, eol=NL):
@@ -307,7 +293,7 @@ def decode(encoded, eol=NL):
if i == n:
decoded += eol
# Special case if original string did not end with eol
- if not encoded.endswith(eol) and decoded.endswith(eol):
+ if encoded[-1] not in '\r\n' and decoded.endswith(eol):
decoded = decoded[:-1]
return decoded
@@ -317,7 +303,7 @@ body_decode = decode
decodestring = decode
-
+
def _unquote_match(match):
"""Turn a match in the form =AB to the ASCII character with value 0xab"""
s = match.group(0)
@@ -333,4 +319,4 @@ def header_decode(s):
the high level email.header class for that functionality.
"""
s = s.replace('_', ' ')
- return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s)
+ return re.sub(r'=[a-fA-F0-9]{2}', _unquote_match, s, re.ASCII)
diff --git a/Lib/email/test/data/msg_15.txt b/Lib/email/test/data/msg_15.txt
index 33b8487aaf5..0025624e750 100644
--- a/Lib/email/test/data/msg_15.txt
+++ b/Lib/email/test/data/msg_15.txt
@@ -9,7 +9,7 @@ Mime-version: 1.0
Content-type: multipart/mixed;
boundary="MS_Mac_OE_3071477847_720252_MIME_Part"
-> Denne meddelelse er i MIME-format. Da dit postl¾sningsprogram ikke forstŒr dette format, kan del af eller hele meddelelsen v¾re ul¾selig.
+> Denne meddelelse er i MIME-format. Da dit postl
--MS_Mac_OE_3071477847_720252_MIME_Part
Content-type: multipart/alternative;
diff --git a/Lib/email/test/data/msg_26.txt b/Lib/email/test/data/msg_26.txt
index e13203a0a96..58efaa9c9a8 100644
--- a/Lib/email/test/data/msg_26.txt
+++ b/Lib/email/test/data/msg_26.txt
@@ -24,7 +24,8 @@ Simple email with attachment.
--1618492860--2051301190--113853680
-Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP; load=&fff69c4b; exec=&355dd4d1; access=&03
+Content-Type: application/riscos; name="clock.bmp,69c"; type=BMP;
+ load=&fff69c4b; exec=&355dd4d1; access=&03
Content-Disposition: attachment; filename="clock.bmp"
Content-Transfer-Encoding: base64
@@ -42,4 +43,4 @@ AAMwgAgAAAAACDAAAAu7t7cwAAgDgAAAAABzcIAAAAAAAAgDMwAAAAAAN7uwgAAAAAgH
MzMAAAAACH97tzAAAAALu3c3gAAAAAAL+7tzDABAu7f7cAAAAAAACA+3MA7EQAv/sIAA
AAAAAAAIAAAAAAAAAIAAAAAA
---1618492860--2051301190--113853680-- \ No newline at end of file
+--1618492860--2051301190--113853680--
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
index b32da9dcbd6..352b9b1d9a0 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -3,6 +3,7 @@
# email package unit tests
import os
+import re
import sys
import time
import base64
@@ -10,29 +11,32 @@ import difflib
import unittest
import warnings
import textwrap
-from cStringIO import StringIO
+
+from io import StringIO, BytesIO
+from itertools import chain
import email
-from email.Charset import Charset
-from email.Header import Header, decode_header, make_header
-from email.Parser import Parser, HeaderParser
-from email.Generator import Generator, DecodedGenerator
-from email.Message import Message
-from email.MIMEAudio import MIMEAudio
-from email.MIMEText import MIMEText
-from email.MIMEImage import MIMEImage
-from email.MIMEBase import MIMEBase
-from email.MIMEMessage import MIMEMessage
-from email.MIMEMultipart import MIMEMultipart
-from email import Utils
-from email import Errors
-from email import Encoders
-from email import Iterators
-from email import base64MIME
-from email import quopriMIME
-
-from test.test_support import findfile, run_unittest
+from email.charset import Charset
+from email.header import Header, decode_header, make_header
+from email.parser import Parser, HeaderParser
+from email.generator import Generator, DecodedGenerator, BytesGenerator
+from email.message import Message
+from email.mime.application import MIMEApplication
+from email.mime.audio import MIMEAudio
+from email.mime.text import MIMEText
+from email.mime.image import MIMEImage
+from email.mime.base import MIMEBase
+from email.mime.message import MIMEMessage
+from email.mime.multipart import MIMEMultipart
+from email import utils
+from email import errors
+from email import encoders
+from email import iterators
+from email import base64mime
+from email import quoprimime
+
+from test.support import findfile, run_unittest, unlink
from email.test import __file__ as landmark
@@ -42,9 +46,9 @@ SPACE = ' '
-def openfile(filename, mode='r'):
+def openfile(filename, *args, **kws):
path = os.path.join(os.path.dirname(landmark), 'data', filename)
- return open(path, mode)
+ return open(path, *args, **kws)
@@ -55,18 +59,14 @@ class TestEmailBase(unittest.TestCase):
if first != second:
sfirst = str(first)
ssecond = str(second)
- diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines())
- fp = StringIO()
- print >> fp, NL, NL.join(diff)
- raise self.failureException, fp.getvalue()
+ rfirst = [repr(line) for line in sfirst.splitlines()]
+ rsecond = [repr(line) for line in ssecond.splitlines()]
+ diff = difflib.ndiff(rfirst, rsecond)
+ raise self.failureException(NL + NL.join(diff))
def _msgobj(self, filename):
- fp = openfile(findfile(filename))
- try:
- msg = email.message_from_file(fp)
- finally:
- fp.close()
- return msg
+ with openfile(findfile(filename)) as fp:
+ return email.message_from_file(fp)
@@ -177,7 +177,7 @@ class TestMessageAPI(TestEmailBase):
eq(value, 'multipart/mixed; boundary="BOUNDARY"')
# And this one has no Content-Type: header at all.
msg = self._msgobj('msg_03.txt')
- self.assertRaises(Errors.HeaderParseError,
+ self.assertRaises(errors.HeaderParseError,
msg.set_boundary, 'BOUNDARY')
def test_make_boundary(self):
@@ -194,12 +194,12 @@ class TestMessageAPI(TestEmailBase):
def test_message_rfc822_only(self):
# Issue 7970: message/rfc822 not in multipart parsed by
# HeaderParser caused an exception when flattened.
- fp = openfile(findfile('msg_46.txt'))
- msgdata = fp.read()
- parser = email.Parser.HeaderParser()
+ with openfile(findfile('msg_46.txt')) as fp:
+ msgdata = fp.read()
+ parser = HeaderParser()
msg = parser.parsestr(msgdata)
out = StringIO()
- gen = email.Generator.Generator(out, True, 0)
+ gen = Generator(out, True, 0)
gen.flatten(msg, False)
self.assertEqual(out.getvalue(), msgdata)
@@ -210,20 +210,20 @@ class TestMessageAPI(TestEmailBase):
eq(msg.get_payload(decode=True), None)
# Subpart 1 is 7bit encoded
eq(msg.get_payload(0).get_payload(decode=True),
- 'This is a 7bit encoded message.\n')
+ b'This is a 7bit encoded message.\n')
# Subpart 2 is quopri
eq(msg.get_payload(1).get_payload(decode=True),
- '\xa1This is a Quoted Printable encoded message!\n')
+ b'\xa1This is a Quoted Printable encoded message!\n')
# Subpart 3 is base64
eq(msg.get_payload(2).get_payload(decode=True),
- 'This is a Base64 encoded message.')
+ b'This is a Base64 encoded message.')
# Subpart 4 is base64 with a trailing newline, which
# used to be stripped (issue 7143).
eq(msg.get_payload(3).get_payload(decode=True),
- 'This is a Base64 encoded message.\n')
+ b'This is a Base64 encoded message.\n')
# Subpart 5 has no Content-Transfer-Encoding: header.
eq(msg.get_payload(4).get_payload(decode=True),
- 'This has no Content-Transfer-Encoding: header.\n')
+ b'This has no Content-Transfer-Encoding: header.\n')
def test_get_decoded_uu_payload(self):
eq = self.assertEqual
@@ -231,32 +231,20 @@ class TestMessageAPI(TestEmailBase):
msg.set_payload('begin 666 -\n+:&5L;&\\@=V]R;&0 \n \nend\n')
for cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
msg['content-transfer-encoding'] = cte
- eq(msg.get_payload(decode=True), 'hello world')
+ eq(msg.get_payload(decode=True), b'hello world')
# Now try some bogus data
msg.set_payload('foo')
- eq(msg.get_payload(decode=True), 'foo')
+ eq(msg.get_payload(decode=True), b'foo')
- def test_decode_bogus_uu_payload_quietly(self):
+ def test_get_payload_n_raises_on_non_multipart(self):
msg = Message()
- msg.set_payload('begin 664 foo.txt\n%<W1F=0000H \n \nend\n')
- msg['Content-Transfer-Encoding'] = 'x-uuencode'
- old_stderr = sys.stderr
- try:
- sys.stderr = sfp = StringIO()
- # We don't care about the payload
- msg.get_payload(decode=True)
- finally:
- sys.stderr = old_stderr
- self.assertEqual(sfp.getvalue(), '')
+ self.assertRaises(TypeError, msg.get_payload, 1)
def test_decoded_generator(self):
eq = self.assertEqual
msg = self._msgobj('msg_07.txt')
- fp = openfile('msg_17.txt')
- try:
+ with openfile('msg_17.txt') as fp:
text = fp.read()
- finally:
- fp.close()
s = StringIO()
g = DecodedGenerator(s)
g.flatten(msg)
@@ -275,24 +263,12 @@ class TestMessageAPI(TestEmailBase):
self.assertTrue('TO' in msg)
def test_as_string(self):
- eq = self.assertEqual
+ eq = self.ndiffAssertEqual
msg = self._msgobj('msg_01.txt')
- fp = openfile('msg_01.txt')
- try:
- # BAW 30-Mar-2009 Evil be here. So, the generator is broken with
- # respect to long line breaking. It's also not idempotent when a
- # header from a parsed message is continued with tabs rather than
- # spaces. Before we fixed bug 1974 it was reversedly broken,
- # i.e. headers that were continued with spaces got continued with
- # tabs. For Python 2.x there's really no good fix and in Python
- # 3.x all this stuff is re-written to be right(er). Chris Withers
- # convinced me that using space as the default continuation
- # character is less bad for more applications.
- text = fp.read().replace('\t', ' ')
- finally:
- fp.close()
- eq(text, msg.as_string())
- fullrepr = str(msg)
+ with openfile('msg_01.txt') as fp:
+ text = fp.read()
+ eq(text, str(msg))
+ fullrepr = msg.as_string(unixfrom=True)
lines = fullrepr.split('\n')
self.assertTrue(lines[0].startswith('From '))
eq(text, NL.join(lines[1:]))
@@ -371,12 +347,13 @@ class TestMessageAPI(TestEmailBase):
"Content-Type: foo; bar*0=\"baz\\\"foobar\"; bar*1=\"\\\"baz\"")
self.assertEqual(msg.get_param('bar'), 'baz"foobar"baz')
- def test_has_key(self):
+ def test_field_containment(self):
+ unless = self.assertTrue
msg = email.message_from_string('Header: exists')
- self.assertTrue(msg.has_key('header'))
- self.assertTrue(msg.has_key('Header'))
- self.assertTrue(msg.has_key('HEADER'))
- self.assertFalse(msg.has_key('headeri'))
+ unless('header' in msg)
+ unless('Header' in msg)
+ unless('HEADER' in msg)
+ self.assertFalse('headerx' in msg)
def test_set_param(self):
eq = self.assertEqual
@@ -418,6 +395,17 @@ class TestMessageAPI(TestEmailBase):
msg.del_param('filename', 'content-disposition')
self.assertEqual(msg['content-disposition'], 'attachment')
+ def test_del_param_on_nonexistent_header(self):
+ msg = Message()
+ msg.del_param('filename', 'content-disposition')
+
+ def test_del_nonexistent_param(self):
+ msg = Message()
+ msg.add_header('Content-Type', 'text/plain', charset='utf-8')
+ existing_header = msg['Content-Type']
+ msg.del_param('foobar', header='Content-Type')
+ self.assertEqual(msg['Content-Type'], 'text/plain; charset="utf-8"')
+
def test_set_type(self):
eq = self.assertEqual
msg = Message()
@@ -545,30 +533,117 @@ class TestMessageAPI(TestEmailBase):
msg['content-type'] = 'audio/x-midi'
msg['content-transfer-encoding'] = 'base64'
msg.set_payload(x)
+ self.assertEqual(msg.get_payload(decode=True),
+ bytes(x, 'raw-unicode-escape'))
+
+ def test_broken_unicode_payload(self):
+ # This test improves coverage but is not a compliance test.
+ # The behavior in this situation is currently undefined by the API.
+ x = 'this is a br\xf6ken thing to do'
+ msg = Message()
+ msg['content-type'] = 'text/plain'
+ msg['content-transfer-encoding'] = '8bit'
+ msg.set_payload(x)
+ self.assertEqual(msg.get_payload(decode=True),
+ bytes(x, 'raw-unicode-escape'))
+
+ def test_questionable_bytes_payload(self):
+ # This test improves coverage but is not a compliance test,
+ # since it involves poking inside the black box.
+ x = 'this is a quéstionable thing to do'.encode('utf-8')
+ msg = Message()
+ msg['content-type'] = 'text/plain; charset="utf-8"'
+ msg['content-transfer-encoding'] = '8bit'
+ msg._payload = x
self.assertEqual(msg.get_payload(decode=True), x)
- def test_get_content_charset(self):
+ # Issue 1078919
+ def test_ascii_add_header(self):
msg = Message()
- msg.set_charset('us-ascii')
- self.assertEqual('us-ascii', msg.get_content_charset())
- msg.set_charset(u'us-ascii')
- self.assertEqual('us-ascii', msg.get_content_charset())
+ msg.add_header('Content-Disposition', 'attachment',
+ filename='bud.gif')
+ self.assertEqual('attachment; filename="bud.gif"',
+ msg['Content-Disposition'])
+
+ def test_noascii_add_header(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="Fußballer.ppt")
+ self.assertEqual(
+ 'attachment; filename*=utf-8\'\'Fu%C3%9Fballer.ppt',
+ msg['Content-Disposition'])
+
+ def test_nonascii_add_header_via_triple(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename=('iso-8859-1', '', 'Fußballer.ppt'))
+ self.assertEqual(
+ 'attachment; filename*=iso-8859-1\'\'Fu%DFballer.ppt',
+ msg['Content-Disposition'])
+
+ def test_ascii_add_header_with_tspecial(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="windows [filename].ppt")
+ self.assertEqual(
+ 'attachment; filename="windows [filename].ppt"',
+ msg['Content-Disposition'])
+
+ def test_nonascii_add_header_with_tspecial(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'attachment',
+ filename="Fußballer [filename].ppt")
+ self.assertEqual(
+ "attachment; filename*=utf-8''Fu%C3%9Fballer%20%5Bfilename%5D.ppt",
+ msg['Content-Disposition'])
+
+ def test_add_header_with_name_only_param(self):
+ msg = Message()
+ msg.add_header('Content-Disposition', 'inline', foo_bar=None)
+ self.assertEqual("inline; foo-bar", msg['Content-Disposition'])
+
+ def test_add_header_with_no_value(self):
+ msg = Message()
+ msg.add_header('X-Status', None)
+ self.assertEqual('', msg['X-Status'])
# Issue 5871: reject an attempt to embed a header inside a header value
# (header injection attack).
def test_embeded_header_via_Header_rejected(self):
msg = Message()
msg['Dummy'] = Header('dummy\nX-Injected-Header: test')
- self.assertRaises(Errors.HeaderParseError, msg.as_string)
+ self.assertRaises(errors.HeaderParseError, msg.as_string)
def test_embeded_header_via_string_rejected(self):
msg = Message()
msg['Dummy'] = 'dummy\nX-Injected-Header: test'
- self.assertRaises(Errors.HeaderParseError, msg.as_string)
-
+ self.assertRaises(errors.HeaderParseError, msg.as_string)
+
+ def test_unicode_header_defaults_to_utf8_encoding(self):
+ # Issue 14291
+ m = MIMEText('abc\n')
+ m['Subject'] = 'É test'
+ self.assertEqual(str(m),textwrap.dedent("""\
+ Content-Type: text/plain; charset="us-ascii"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: 7bit
+ Subject: =?utf-8?q?=C3=89_test?=
+
+ abc
+ """))
-# Test the email.Encoders module
+# Test the email.encoders module
class TestEncoders(unittest.TestCase):
+
+ def test_EncodersEncode_base64(self):
+ with openfile('PyBanner048.gif', 'rb') as fp:
+ bindata = fp.read()
+ mimed = email.mime.image.MIMEImage(bindata)
+ base64ed = mimed.get_payload()
+ # the transfer-encoded body lines should all be <=76 characters
+ lines = base64ed.split('\n')
+ self.assertLessEqual(max([ len(x) for x in lines ]), 76)
+
def test_encode_empty_payload(self):
eq = self.assertEqual
msg = Message()
@@ -592,12 +667,15 @@ class TestEncoders(unittest.TestCase):
# whose output character set is 7bit gets a transfer-encoding
# of 7bit.
eq = self.assertEqual
- msg = email.MIMEText.MIMEText('\xca\xb8', _charset='euc-jp')
+ msg = MIMEText('æ–‡', _charset='euc-jp')
eq(msg['content-transfer-encoding'], '7bit')
# Test long header wrapping
class TestLongHeaders(TestEmailBase):
+
+ maxDiff = None
+
def test_split_long_continuation(self):
eq = self.ndiffAssertEqual
msg = email.message_from_string("""\
@@ -612,8 +690,8 @@ test
g.flatten(msg)
eq(sfp.getvalue(), """\
Subject: bug demonstration
- 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
- more text
+\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
+\tmore text
test
""")
@@ -629,7 +707,7 @@ bug demonstration
bug demonstration
\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
\tmore text""")
- h = Header(hstr)
+ h = Header(hstr.replace('\t', ' '))
eq(h.encode(), """\
bug demonstration
12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
@@ -640,9 +718,20 @@ bug demonstration
g = Charset("iso-8859-1")
cz = Charset("iso-8859-2")
utf8 = Charset("utf-8")
- g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
- cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. "
- utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8")
+ g_head = (b'Die Mieter treten hier ein werden mit einem Foerderband '
+ b'komfortabel den Korridor entlang, an s\xfcdl\xfcndischen '
+ b'Wandgem\xe4lden vorbei, gegen die rotierenden Klingen '
+ b'bef\xf6rdert. ')
+ cz_head = (b'Finan\xe8ni metropole se hroutily pod tlakem jejich '
+ b'd\xf9vtipu.. ')
+ utf8_head = ('\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
+ '\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00'
+ '\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
+ '\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
+ '\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das '
+ 'Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder '
+ 'die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066'
+ '\u3044\u307e\u3059\u3002')
h = Header(g_head, g, header_name='Subject')
h.append(cz_head, cz)
h.append(utf8_head, utf8)
@@ -652,31 +741,31 @@ bug demonstration
g = Generator(sfp)
g.flatten(msg)
eq(sfp.getvalue(), """\
-Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?=
- =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?=
- =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?=
- =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?=
- =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
- =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?=
- =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?=
- =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?=
- =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?=
- =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?=
- =?utf-8?b?44Gm44GE44G+44GZ44CC?=
+Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderb?=
+ =?iso-8859-1?q?and_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen?=
+ =?iso-8859-1?q?_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef?=
+ =?iso-8859-1?q?=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hrouti?=
+ =?iso-8859-2?q?ly_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
+ =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC5LiA?=
+ =?utf-8?b?6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn44Gf44KJ?=
+ =?utf-8?b?44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFzIE51bnN0dWNr?=
+ =?utf-8?b?IGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5kIGRhcyBPZGVyIGRp?=
+ =?utf-8?b?ZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIDjgaPjgabjgYTjgb7jgZk=?=
+ =?utf-8?b?44CC?=
""")
- eq(h.encode(), """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?=
- =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?=
- =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?=
- =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?=
- =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
- =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?=
- =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?=
- =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?=
- =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?=
- =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?=
- =?utf-8?b?44Gm44GE44G+44GZ44CC?=""")
+ eq(h.encode(maxlinelen=76), """\
+=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerde?=
+ =?iso-8859-1?q?rband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndis?=
+ =?iso-8859-1?q?chen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klinge?=
+ =?iso-8859-1?q?n_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se?=
+ =?iso-8859-2?q?_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
+ =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb?=
+ =?utf-8?b?44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go?=
+ =?utf-8?b?44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBp?=
+ =?utf-8?b?c3QgZGFzIE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWlo?=
+ =?utf-8?b?ZXJodW5kIGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI0=?=
+ =?utf-8?b?44Go6KiA44Gj44Gm44GE44G+44GZ44CC?=""")
def test_long_header_encode(self):
eq = self.ndiffAssertEqual
@@ -687,7 +776,7 @@ Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?=
wasnipoop; giraffes="very-long-necked-animals";
spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
- def test_long_header_encode_with_tab_continuation(self):
+ def test_long_header_encode_with_tab_continuation_is_just_a_hint(self):
eq = self.ndiffAssertEqual
h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
@@ -695,8 +784,32 @@ wasnipoop; giraffes="very-long-necked-animals";
continuation_ws='\t')
eq(h.encode(), '''\
wasnipoop; giraffes="very-long-necked-animals";
+ spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
+
+ def test_long_header_encode_with_tab_continuation(self):
+ eq = self.ndiffAssertEqual
+ h = Header('wasnipoop; giraffes="very-long-necked-animals";\t'
+ 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
+ header_name='X-Foobar-Spoink-Defrobnit',
+ continuation_ws='\t')
+ eq(h.encode(), '''\
+wasnipoop; giraffes="very-long-necked-animals";
\tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
+ def test_header_encode_with_different_output_charset(self):
+ h = Header('æ–‡', 'euc-jp')
+ self.assertEqual(h.encode(), "=?iso-2022-jp?b?GyRCSjgbKEI=?=")
+
+ def test_long_header_encode_with_different_output_charset(self):
+ h = Header(b'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4'
+ b'\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4'
+ b'\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4'
+ b'\xa4\xa4\xde\xa4\xb9'.decode('euc-jp'), 'euc-jp')
+ res = """\
+=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKMnE8VCROPjUbKEI=?=
+ =?iso-2022-jp?b?GyRCRyckckJUJEMkRiQkJF4kORsoQg==?="""
+ self.assertEqual(h.encode(), res)
+
def test_header_splitter(self):
eq = self.ndiffAssertEqual
msg = MIMEText('')
@@ -721,7 +834,7 @@ X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
eq = self.ndiffAssertEqual
msg = Message()
msg['From'] = 'test@dom.ain'
- msg['References'] = SPACE.join(['<%d@dom.ain>' % i for i in range(10)])
+ msg['References'] = SPACE.join('<%d@dom.ain>' % i for i in range(10))
msg.set_payload('Test')
sfp = StringIO()
g = Generator(sfp)
@@ -733,12 +846,167 @@ References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
Test""")
+ def test_last_split_chunk_does_not_fit(self):
+ eq = self.ndiffAssertEqual
+ h = Header('Subject: the first part of this is short, but_the_second'
+ '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
+ '_all_by_itself')
+ eq(h.encode(), """\
+Subject: the first part of this is short,
+ but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")
+
+ def test_splittable_leading_char_followed_by_overlong_unsplitable(self):
+ eq = self.ndiffAssertEqual
+ h = Header(', but_the_second'
+ '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
+ '_all_by_itself')
+ eq(h.encode(), """\
+,
+ but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")
+
+ def test_multiple_splittable_leading_char_followed_by_overlong_unsplitable(self):
+ eq = self.ndiffAssertEqual
+ h = Header(', , but_the_second'
+ '_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line'
+ '_all_by_itself')
+ eq(h.encode(), """\
+, ,
+ but_the_second_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself""")
+
+ def test_trailing_splitable_on_overlong_unsplitable(self):
+ eq = self.ndiffAssertEqual
+ h = Header('this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself;')
+ eq(h.encode(), "this_part_does_not_fit_within_maxlinelen_and_thus_should_"
+ "be_on_a_line_all_by_itself;")
+
+ def test_trailing_splitable_on_overlong_unsplitable_with_leading_splitable(self):
+ eq = self.ndiffAssertEqual
+ h = Header('; '
+ 'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself; ')
+ eq(h.encode(), """\
+;
+ this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)
+
+ def test_long_header_with_multiple_sequential_split_chars(self):
+ eq = self.ndiffAssertEqual
+ h = Header('This is a long line that has two whitespaces in a row. '
+ 'This used to cause truncation of the header when folded')
+ eq(h.encode(), """\
+This is a long line that has two whitespaces in a row. This used to cause
+ truncation of the header when folded""")
+
+ def test_splitter_split_on_punctuation_only_if_fws(self):
+ eq = self.ndiffAssertEqual
+ h = Header('thisverylongheaderhas;semicolons;and,commas,but'
+ 'they;arenotlegal;fold,points')
+ eq(h.encode(), "thisverylongheaderhas;semicolons;and,commas,butthey;"
+ "arenotlegal;fold,points")
+
+ def test_leading_splittable_in_the_middle_just_before_overlong_last_part(self):
+ eq = self.ndiffAssertEqual
+ h = Header('this is a test where we need to have more than one line '
+ 'before; our final line that is just too big to fit;; '
+ 'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself;')
+ eq(h.encode(), """\
+this is a test where we need to have more than one line before;
+ our final line that is just too big to fit;;
+ this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself;""")
+
+ def test_overlong_last_part_followed_by_split_point(self):
+ eq = self.ndiffAssertEqual
+ h = Header('this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself ')
+ eq(h.encode(), "this_part_does_not_fit_within_maxlinelen_and_thus_"
+ "should_be_on_a_line_all_by_itself ")
+
+ def test_multiline_with_overlong_parts_separated_by_two_split_points(self):
+ eq = self.ndiffAssertEqual
+ h = Header('this_is_a__test_where_we_need_to_have_more_than_one_line_'
+ 'before_our_final_line_; ; '
+ 'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself; ')
+ eq(h.encode(), """\
+this_is_a__test_where_we_need_to_have_more_than_one_line_before_our_final_line_;
+ ;
+ this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)
+
+ def test_multiline_with_overlong_last_part_followed_by_split_point(self):
+ eq = self.ndiffAssertEqual
+ h = Header('this is a test where we need to have more than one line '
+ 'before our final line; ; '
+ 'this_part_does_not_fit_within_maxlinelen_and_thus_should_'
+ 'be_on_a_line_all_by_itself; ')
+ eq(h.encode(), """\
+this is a test where we need to have more than one line before our final line;
+ ;
+ this_part_does_not_fit_within_maxlinelen_and_thus_should_be_on_a_line_all_by_itself; """)
+
+ def test_long_header_with_whitespace_runs(self):
+ eq = self.ndiffAssertEqual
+ msg = Message()
+ msg['From'] = 'test@dom.ain'
+ msg['References'] = SPACE.join(['<foo@dom.ain> '] * 10)
+ msg.set_payload('Test')
+ sfp = StringIO()
+ g = Generator(sfp)
+ g.flatten(msg)
+ eq(sfp.getvalue(), """\
+From: test@dom.ain
+References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
+ <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
+ <foo@dom.ain> <foo@dom.ain>\x20\x20
+
+Test""")
+
+ def test_long_run_with_semi_header_splitter(self):
+ eq = self.ndiffAssertEqual
+ msg = Message()
+ msg['From'] = 'test@dom.ain'
+ msg['References'] = SPACE.join(['<foo@dom.ain>'] * 10) + '; abc'
+ msg.set_payload('Test')
+ sfp = StringIO()
+ g = Generator(sfp)
+ g.flatten(msg)
+ eq(sfp.getvalue(), """\
+From: test@dom.ain
+References: <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
+ <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain> <foo@dom.ain>
+ <foo@dom.ain>; abc
+
+Test""")
+
+ def test_splitter_split_on_punctuation_only_if_fws(self):
+ eq = self.ndiffAssertEqual
+ msg = Message()
+ msg['From'] = 'test@dom.ain'
+ msg['References'] = ('thisverylongheaderhas;semicolons;and,commas,but'
+ 'they;arenotlegal;fold,points')
+ msg.set_payload('Test')
+ sfp = StringIO()
+ g = Generator(sfp)
+ g.flatten(msg)
+ # XXX the space after the header should not be there.
+ eq(sfp.getvalue(), """\
+From: test@dom.ain
+References:\x20
+ thisverylongheaderhas;semicolons;and,commas,butthey;arenotlegal;fold,points
+
+Test""")
+
def test_no_split_long_header(self):
eq = self.ndiffAssertEqual
hstr = 'References: ' + 'x' * 80
- h = Header(hstr, continuation_ws='\t')
+ h = Header(hstr)
+ # These come on two lines because Headers are really field value
+ # classes and don't really know about their field names.
eq(h.encode(), """\
-References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""")
+References:
+ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""")
+ h = Header('x' * 80)
+ eq(h.encode(), 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')
def test_splitting_multiple_long_lines(self):
eq = self.ndiffAssertEqual
@@ -750,17 +1018,17 @@ from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org
h = Header(hstr, continuation_ws='\t')
eq(h.encode(), """\
from babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
+ by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
+ for <mailman-admin@babylon.socal-raves.org>;
+ Sat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
+ by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
+ for <mailman-admin@babylon.socal-raves.org>;
+ Sat, 2 Feb 2002 17:00:06 -0800 (PST)
\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)""")
+ by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
+ for <mailman-admin@babylon.socal-raves.org>;
+ Sat, 2 Feb 2002 17:00:06 -0800 (PST)""")
def test_splitting_first_line_only_is_long(self):
eq = self.ndiffAssertEqual
@@ -773,7 +1041,7 @@ from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.
continuation_ws='\t')
eq(h.encode(), """\
from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
-\thelo=cthulhu.gerg.ca)
+ helo=cthulhu.gerg.ca)
\tby kronos.mems-exchange.org with esmtp (Exim 4.05)
\tid 17k4h5-00034i-00
\tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""")
@@ -784,29 +1052,52 @@ from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
h = Header('Britische Regierung gibt', 'iso-8859-1',
header_name='Subject')
h.append('gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte')
+ eq(h.encode(maxlinelen=76), """\
+=?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
+ =?iso-8859-1?q?hore-Windkraftprojekte?=""")
msg['Subject'] = h
- eq(msg.as_string(), """\
-Subject: =?iso-8859-1?q?Britische_Regierung_gibt?= =?iso-8859-1?q?gr=FCnes?=
- =?iso-8859-1?q?_Licht_f=FCr_Offshore-Windkraftprojekte?=
+ eq(msg.as_string(maxheaderlen=76), """\
+Subject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offs?=
+ =?iso-8859-1?q?hore-Windkraftprojekte?=
+
+""")
+ eq(msg.as_string(maxheaderlen=0), """\
+Subject: =?iso-8859-1?q?Britische_Regierung_gibt_gr=FCnes_Licht_f=FCr_Offshore-Windkraftprojekte?=
""")
def test_long_8bit_header_no_charset(self):
eq = self.ndiffAssertEqual
msg = Message()
- msg['Reply-To'] = 'Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com>'
- eq(msg.as_string(), """\
-Reply-To: Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com>
+ header_string = ('Britische Regierung gibt gr\xfcnes Licht '
+ 'f\xfcr Offshore-Windkraftprojekte '
+ '<a-very-long-address@example.com>')
+ msg['Reply-To'] = header_string
+ eq(msg.as_string(maxheaderlen=78), """\
+Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
+ =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=
+
+""")
+ msg = Message()
+ msg['Reply-To'] = Header(header_string,
+ header_name='Reply-To')
+ eq(msg.as_string(maxheaderlen=78), """\
+Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?=
+ =?utf-8?q?hore-Windkraftprojekte_=3Ca-very-long-address=40example=2Ecom=3E?=
""")
def test_long_to_header(self):
eq = self.ndiffAssertEqual
- to = '"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,"Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>'
+ to = ('"Someone Test #A" <someone@eecs.umich.edu>,'
+ '<someone@eecs.umich.edu>, '
+ '"Someone Test #B" <someone@umich.edu>, '
+ '"Someone Test #C" <someone@eecs.umich.edu>, '
+ '"Someone Test #D" <someone@eecs.umich.edu>')
msg = Message()
msg['To'] = to
- eq(msg.as_string(0), '''\
-To: "Someone Test #A" <someone@eecs.umich.edu>, <someone@eecs.umich.edu>,
+ eq(msg.as_string(maxheaderlen=78), '''\
+To: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,
"Someone Test #B" <someone@umich.edu>,
"Someone Test #C" <someone@eecs.umich.edu>,
"Someone Test #D" <someone@eecs.umich.edu>
@@ -818,7 +1109,7 @@ To: "Someone Test #A" <someone@eecs.umich.edu>, <someone@eecs.umich.edu>,
s = 'This is an example of string which has almost the limit of header length.'
h = Header(s)
h.append('Add another line.')
- eq(h.encode(), """\
+ eq(h.encode(maxlinelen=76), """\
This is an example of string which has almost the limit of header length.
Add another line.""")
@@ -833,24 +1124,30 @@ This is an example of string which has almost the limit of header length.
def test_long_field_name(self):
eq = self.ndiffAssertEqual
fn = 'X-Very-Very-Very-Long-Header-Name'
- gs = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
+ gs = ('Die Mieter treten hier ein werden mit einem Foerderband '
+ 'komfortabel den Korridor entlang, an s\xfcdl\xfcndischen '
+ 'Wandgem\xe4lden vorbei, gegen die rotierenden Klingen '
+ 'bef\xf6rdert. ')
h = Header(gs, 'iso-8859-1', header_name=fn)
# BAW: this seems broken because the first line is too long
- eq(h.encode(), """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_?=
- =?iso-8859-1?q?ein_werden_mit_einem_Foerderband_komfortabel_den_Korridor_?=
- =?iso-8859-1?q?entlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_g?=
- =?iso-8859-1?q?egen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""")
+ eq(h.encode(maxlinelen=76), """\
+=?iso-8859-1?q?Die_Mieter_treten_hier_e?=
+ =?iso-8859-1?q?in_werden_mit_einem_Foerderband_komfortabel_den_Korridor_e?=
+ =?iso-8859-1?q?ntlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_ge?=
+ =?iso-8859-1?q?gen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""")
def test_long_received_header(self):
- h = 'from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700'
+ h = ('from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) '
+ 'by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; '
+ 'Wed, 05 Mar 2003 18:10:18 -0700')
msg = Message()
msg['Received-1'] = Header(h, continuation_ws='\t')
msg['Received-2'] = h
- self.assertEqual(msg.as_string(), """\
+ # This should be splitting on spaces not semicolons.
+ self.ndiffAssertEqual(msg.as_string(maxheaderlen=78), """\
Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
-\throthgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
-\tWed, 05 Mar 2003 18:10:18 -0700
+ hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
+ Wed, 05 Mar 2003 18:10:18 -0700
Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
Wed, 05 Mar 2003 18:10:18 -0700
@@ -858,16 +1155,21 @@ Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
""")
def test_string_headerinst_eq(self):
- h = '<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner\'s message of "Thu, 6 Mar 2003 13:58:21 +0100")'
+ h = ('<15975.17901.207240.414604@sgigritzmann1.mathematik.'
+ 'tu-muenchen.de> (David Bremner\'s message of '
+ '"Thu, 6 Mar 2003 13:58:21 +0100")')
msg = Message()
- msg['Received'] = Header(h, header_name='Received',
- continuation_ws='\t')
- msg['Received'] = h
- self.ndiffAssertEqual(msg.as_string(), """\
-Received: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de>
-\t(David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
-Received: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de>
- (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
+ msg['Received-1'] = Header(h, header_name='Received-1',
+ continuation_ws='\t')
+ msg['Received-2'] = h
+ # XXX The space after the ':' should not be there.
+ self.ndiffAssertEqual(msg.as_string(maxheaderlen=78), """\
+Received-1:\x20
+ <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
+ Bremner's message of \"Thu, 6 Mar 2003 13:58:21 +0100\")
+Received-2:\x20
+ <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David
+ Bremner's message of \"Thu, 6 Mar 2003 13:58:21 +0100\")
""")
@@ -875,25 +1177,34 @@ Received: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de>
eq = self.ndiffAssertEqual
msg = Message()
t = """\
- iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
+iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp"""
msg['Face-1'] = t
msg['Face-2'] = Header(t, header_name='Face-2')
- eq(msg.as_string(), """\
-Face-1: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
+ msg['Face-3'] = ' ' + t
+ # XXX This splitting is all wrong. It the first value line should be
+ # snug against the field name or the space after the header not there.
+ eq(msg.as_string(maxheaderlen=78), """\
+Face-1:\x20
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
-Face-2: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
+Face-2:\x20
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
+ locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
+Face-3:\x20
+ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
""")
def test_another_long_multiline_header(self):
eq = self.ndiffAssertEqual
- m = '''\
-Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905);
- Wed, 16 Oct 2002 07:41:11 -0700'''
+ m = ('Received: from siimage.com '
+ '([172.25.1.3]) by zima.siliconimage.com with '
+ 'Microsoft SMTPSVC(5.0.2195.4905); '
+ 'Wed, 16 Oct 2002 07:41:11 -0700')
msg = email.message_from_string(m)
- eq(msg.as_string(), '''\
+ eq(msg.as_string(maxheaderlen=78), '''\
Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700
@@ -901,20 +1212,35 @@ Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
def test_long_lines_with_different_header(self):
eq = self.ndiffAssertEqual
- h = """\
-List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>"""
+ h = ('List-Unsubscribe: '
+ '<http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,'
+ ' <mailto:spamassassin-talk-request@lists.sourceforge.net'
+ '?subject=unsubscribe>')
msg = Message()
msg['List'] = h
msg['List'] = Header(h, header_name='List')
- eq(msg.as_string(), """\
-List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
-List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
+ eq(msg.as_string(maxheaderlen=78), """\
+List: List-Unsubscribe:
+ <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
+ <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
+List: List-Unsubscribe:
+ <http://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
+ <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
""")
+ def test_long_rfc2047_header_with_embedded_fws(self):
+ h = Header(textwrap.dedent("""\
+ We're going to pretend this header is in a non-ascii character set
+ \tto see if line wrapping with encoded words and embedded
+ folding white space works"""),
+ charset='utf-8',
+ header_name='Test')
+ self.assertEqual(h.encode()+'\n', textwrap.dedent("""\
+ =?utf-8?q?We=27re_going_to_pretend_this_header_is_in_a_non-ascii_chara?=
+ =?utf-8?q?cter_set?=
+ =?utf-8?q?_to_see_if_line_wrapping_with_encoded_words_and_embedded?=
+ =?utf-8?q?_folding_white_space_works?=""")+'\n')
# Test mangling of "From " lines in the body of a message
@@ -972,6 +1298,20 @@ Blah blah blah
self.assertEqual(len([1 for x in s.getvalue().split('\n')
if x.startswith('>From ')]), 2)
+ def test_mangled_from_with_bad_bytes(self):
+ source = textwrap.dedent("""\
+ Content-Type: text/plain; charset="utf-8"
+ MIME-Version: 1.0
+ Content-Transfer-Encoding: 8bit
+ From: aaa@bbb.org
+
+ """).encode('utf-8')
+ msg = email.message_from_bytes(source + b'From R\xc3\xb6lli\n')
+ b = BytesIO()
+ g = BytesGenerator(b, mangle_from_=True)
+ g.flatten(msg)
+ self.assertEqual(b.getvalue(), source + b'>From R\xc3\xb6lli\n')
+
# Test the basic MIMEAudio class
class TestMIMEAudio(unittest.TestCase):
@@ -982,11 +1322,8 @@ class TestMIMEAudio(unittest.TestCase):
# package. The trailing empty string on the .join() is significant
# since findfile() will do a dirname().
datadir = os.path.join(os.path.dirname(landmark), 'data', '')
- fp = open(findfile('audiotest.au', datadir), 'rb')
- try:
+ with open(findfile('audiotest.au', datadir), 'rb') as fp:
self._audiodata = fp.read()
- finally:
- fp.close()
self._au = MIMEAudio(self._audiodata)
def test_guess_minor_type(self):
@@ -994,7 +1331,8 @@ class TestMIMEAudio(unittest.TestCase):
def test_encoding(self):
payload = self._au.get_payload()
- self.assertEqual(base64.decodestring(payload), self._audiodata)
+ self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+ self._audiodata)
def test_checkSetMinor(self):
au = MIMEAudio(self._audiodata, 'fish')
@@ -1025,11 +1363,8 @@ class TestMIMEAudio(unittest.TestCase):
# Test the basic MIMEImage class
class TestMIMEImage(unittest.TestCase):
def setUp(self):
- fp = openfile('PyBanner048.gif')
- try:
+ with openfile('PyBanner048.gif', 'rb') as fp:
self._imgdata = fp.read()
- finally:
- fp.close()
self._im = MIMEImage(self._imgdata)
def test_guess_minor_type(self):
@@ -1037,7 +1372,8 @@ class TestMIMEImage(unittest.TestCase):
def test_encoding(self):
payload = self._im.get_payload()
- self.assertEqual(base64.decodestring(payload), self._imgdata)
+ self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+ self._imgdata)
def test_checkSetMinor(self):
im = MIMEImage(self._imgdata, 'fish')
@@ -1065,6 +1401,24 @@ class TestMIMEImage(unittest.TestCase):
+# Test the basic MIMEApplication class
+class TestMIMEApplication(unittest.TestCase):
+ def test_headers(self):
+ eq = self.assertEqual
+ msg = MIMEApplication(b'\xfa\xfb\xfc\xfd\xfe\xff')
+ eq(msg.get_content_type(), 'application/octet-stream')
+ eq(msg['content-transfer-encoding'], 'base64')
+
+ def test_body(self):
+ eq = self.assertEqual
+ bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'
+ msg = MIMEApplication(bytesdata)
+ # whitespace in the cte encoded block is RFC-irrelevant.
+ eq(msg.get_payload().strip(), '+vv8/f7/')
+ eq(msg.get_payload(decode=True), bytesdata)
+
+
+
# Test the basic MIMEText class
class TestMIMEText(unittest.TestCase):
def setUp(self):
@@ -1090,29 +1444,31 @@ class TestMIMEText(unittest.TestCase):
eq(msg.get_charset().input_charset, 'us-ascii')
eq(msg['content-type'], 'text/plain; charset="us-ascii"')
- def test_7bit_unicode_input(self):
+ def test_7bit_input(self):
eq = self.assertEqual
- msg = MIMEText(u'hello there', _charset='us-ascii')
+ msg = MIMEText('hello there', _charset='us-ascii')
eq(msg.get_charset().input_charset, 'us-ascii')
eq(msg['content-type'], 'text/plain; charset="us-ascii"')
- def test_7bit_unicode_input_no_charset(self):
+ def test_7bit_input_no_charset(self):
eq = self.assertEqual
- msg = MIMEText(u'hello there')
+ msg = MIMEText('hello there')
eq(msg.get_charset(), 'us-ascii')
eq(msg['content-type'], 'text/plain; charset="us-ascii"')
self.assertTrue('hello there' in msg.as_string())
- def test_8bit_unicode_input(self):
- teststr = u'\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
+ def test_utf8_input(self):
+ teststr = '\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
eq = self.assertEqual
msg = MIMEText(teststr, _charset='utf-8')
eq(msg.get_charset().output_charset, 'utf-8')
eq(msg['content-type'], 'text/plain; charset="utf-8"')
eq(msg.get_payload(decode=True), teststr.encode('utf-8'))
- def test_8bit_unicode_input_no_charset(self):
- teststr = u'\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
+ @unittest.skip("can't fix because of backward compat in email5, "
+ "will fix in email6")
+ def test_utf8_input_no_charset(self):
+ teststr = '\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'
self.assertRaises(UnicodeEncodeError, MIMEText, teststr)
@@ -1120,12 +1476,8 @@ class TestMIMEText(unittest.TestCase):
# Test complicated multipart/* messages
class TestMultipart(TestEmailBase):
def setUp(self):
- fp = openfile('PyBanner048.gif')
- try:
+ with openfile('PyBanner048.gif', 'rb') as fp:
data = fp.read()
- finally:
- fp.close()
-
container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY')
image = MIMEImage(data, name='dingusfish.gif')
image.add_header('content-disposition', 'attachment',
@@ -1151,7 +1503,7 @@ This is the dingus fish.
sign = '-'
else:
sign = '+'
- tzoffset = ' %s%04d' % (sign, tzsecs // 36)
+ tzoffset = ' %s%04d' % (sign, tzsecs / 36)
container['Date'] = time.strftime(
'%a, %d %b %Y %H:%M:%S',
time.localtime(now)) + tzoffset
@@ -1418,7 +1770,7 @@ hello world
# parts.
msg = self._msgobj('msg_38.txt')
sfp = StringIO()
- Iterators._structure(msg, sfp)
+ iterators._structure(msg, sfp)
eq(sfp.getvalue(), """\
multipart/mixed
multipart/mixed
@@ -1436,7 +1788,7 @@ multipart/mixed
# parsed is closest to the spirit of RFC 2046
msg = self._msgobj('msg_39.txt')
sfp = StringIO()
- Iterators._structure(msg, sfp)
+ iterators._structure(msg, sfp)
eq(sfp.getvalue(), """\
multipart/mixed
multipart/mixed
@@ -1513,16 +1865,16 @@ class TestNonConformant(TestEmailBase):
unless(hasattr(inner, 'defects'))
self.assertEqual(len(inner.defects), 1)
unless(isinstance(inner.defects[0],
- Errors.StartBoundaryNotFoundDefect))
+ errors.StartBoundaryNotFoundDefect))
def test_multipart_no_boundary(self):
unless = self.assertTrue
msg = self._msgobj('msg_25.txt')
unless(isinstance(msg.get_payload(), str))
self.assertEqual(len(msg.defects), 2)
- unless(isinstance(msg.defects[0], Errors.NoBoundaryInMultipartDefect))
+ unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
unless(isinstance(msg.defects[1],
- Errors.MultipartInvariantViolationDefect))
+ errors.MultipartInvariantViolationDefect))
def test_invalid_content_type(self):
eq = self.assertEqual
@@ -1578,9 +1930,9 @@ counter to RFC 2822, there's no separating newline here
msg = self._msgobj('msg_41.txt')
unless(hasattr(msg, 'defects'))
self.assertEqual(len(msg.defects), 2)
- unless(isinstance(msg.defects[0], Errors.NoBoundaryInMultipartDefect))
+ unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
unless(isinstance(msg.defects[1],
- Errors.MultipartInvariantViolationDefect))
+ errors.MultipartInvariantViolationDefect))
def test_missing_start_boundary(self):
outer = self._msgobj('msg_42.txt')
@@ -1595,7 +1947,7 @@ counter to RFC 2822, there's no separating newline here
bad = outer.get_payload(1).get_payload(0)
self.assertEqual(len(bad.defects), 1)
self.assertTrue(isinstance(bad.defects[0],
- Errors.StartBoundaryNotFoundDefect))
+ errors.StartBoundaryNotFoundDefect))
def test_first_line_is_continuation_header(self):
eq = self.assertEqual
@@ -1605,46 +1957,49 @@ counter to RFC 2822, there's no separating newline here
eq(msg.get_payload(), 'Line 2\nLine 3')
eq(len(msg.defects), 1)
self.assertTrue(isinstance(msg.defects[0],
- Errors.FirstHeaderLineIsContinuationDefect))
+ errors.FirstHeaderLineIsContinuationDefect))
eq(msg.defects[0].line, ' Line 1\n')
-
# Test RFC 2047 header encoding and decoding
-class TestRFC2047(unittest.TestCase):
+class TestRFC2047(TestEmailBase):
def test_rfc2047_multiline(self):
eq = self.assertEqual
s = """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?="""
dh = decode_header(s)
eq(dh, [
- ('Re:', None),
- ('r\x8aksm\x9arg\x8cs', 'mac-iceland'),
- ('baz foo bar', None),
- ('r\x8aksm\x9arg\x8cs', 'mac-iceland')])
- eq(str(make_header(dh)),
- """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar
- =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=""")
+ (b'Re:', None),
+ (b'r\x8aksm\x9arg\x8cs', 'mac-iceland'),
+ (b'baz foo bar', None),
+ (b'r\x8aksm\x9arg\x8cs', 'mac-iceland')])
+ header = make_header(dh)
+ eq(str(header),
+ 'Re: r\xe4ksm\xf6rg\xe5s baz foo bar r\xe4ksm\xf6rg\xe5s')
+ self.ndiffAssertEqual(header.encode(maxlinelen=76), """\
+Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar =?mac-iceland?q?r=8Aksm?=
+ =?mac-iceland?q?=9Arg=8Cs?=""")
def test_whitespace_eater_unicode(self):
eq = self.assertEqual
s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>'
dh = decode_header(s)
- eq(dh, [('Andr\xe9', 'iso-8859-1'), ('Pirard <pirard@dom.ain>', None)])
- hu = unicode(make_header(dh)).encode('latin-1')
- eq(hu, 'Andr\xe9 Pirard <pirard@dom.ain>')
+ eq(dh, [(b'Andr\xe9', 'iso-8859-1'),
+ (b'Pirard <pirard@dom.ain>', None)])
+ header = str(make_header(dh))
+ eq(header, 'Andr\xe9 Pirard <pirard@dom.ain>')
def test_whitespace_eater_unicode_2(self):
eq = self.assertEqual
s = 'The =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?='
dh = decode_header(s)
- eq(dh, [('The', None), ('quick brown fox', 'iso-8859-1'),
- ('jumped over the', None), ('lazy dog', 'iso-8859-1')])
- hu = make_header(dh).__unicode__()
- eq(hu, u'The quick brown fox jumped over the lazy dog')
+ eq(dh, [(b'The', None), (b'quick brown fox', 'iso-8859-1'),
+ (b'jumped over the', None), (b'lazy dog', 'iso-8859-1')])
+ hu = str(make_header(dh))
+ eq(hu, 'The quick brown fox jumped over the lazy dog')
- def test_rfc2047_without_whitespace(self):
+ def test_rfc2047_missing_whitespace(self):
s = 'Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord'
dh = decode_header(s)
self.assertEqual(dh, [(s, None)])
@@ -1652,15 +2007,15 @@ class TestRFC2047(unittest.TestCase):
def test_rfc2047_with_whitespace(self):
s = 'Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord'
dh = decode_header(s)
- self.assertEqual(dh, [('Sm', None), ('\xf6', 'iso-8859-1'),
- ('rg', None), ('\xe5', 'iso-8859-1'),
- ('sbord', None)])
+ self.assertEqual(dh, [(b'Sm', None), (b'\xf6', 'iso-8859-1'),
+ (b'rg', None), (b'\xe5', 'iso-8859-1'),
+ (b'sbord', None)])
def test_rfc2047_B_bad_padding(self):
s = '=?iso-8859-1?B?%s?='
data = [ # only test complete bytes
- ('dm==', 'v'), ('dm=', 'v'), ('dm', 'v'),
- ('dmk=', 'vi'), ('dmk', 'vi')
+ ('dm==', b'v'), ('dm=', b'v'), ('dm', b'v'),
+ ('dmk=', b'vi'), ('dmk', b'vi')
]
for q, a in data:
dh = decode_header(s % q)
@@ -1676,11 +2031,8 @@ class TestRFC2047(unittest.TestCase):
# Test the MIMEMessage class
class TestMIMEMessage(TestEmailBase):
def setUp(self):
- fp = openfile('msg_11.txt')
- try:
+ with openfile('msg_11.txt') as fp:
self._text = fp.read()
- finally:
- fp.close()
def test_type_error(self):
self.assertRaises(TypeError, MIMEMessage, 'a plain string')
@@ -1707,7 +2059,7 @@ class TestMIMEMessage(TestEmailBase):
msg2 = Message()
msg2['Subject'] = 'subpart 2'
r = MIMEMessage(msg1)
- self.assertRaises(Errors.MultipartConversionError, r.attach, msg2)
+ self.assertRaises(errors.MultipartConversionError, r.attach, msg2)
def test_generate(self):
# First craft the message to be encapsulated
@@ -1802,11 +2154,8 @@ Your message cannot be delivered to the following recipients:
def test_epilogue(self):
eq = self.ndiffAssertEqual
- fp = openfile('msg_21.txt')
- try:
+ with openfile('msg_21.txt') as fp:
text = fp.read()
- finally:
- fp.close()
msg = Message()
msg['From'] = 'aperson@dom.ain'
msg['To'] = 'bperson@dom.ain'
@@ -1860,11 +2209,8 @@ Two
def test_default_type(self):
eq = self.assertEqual
- fp = openfile('msg_30.txt')
- try:
+ with openfile('msg_30.txt') as fp:
msg = email.message_from_file(fp)
- finally:
- fp.close()
container1 = msg.get_payload(0)
eq(container1.get_default_type(), 'message/rfc822')
eq(container1.get_content_type(), 'message/rfc822')
@@ -1880,11 +2226,8 @@ Two
def test_default_type_with_explicit_container_type(self):
eq = self.assertEqual
- fp = openfile('msg_28.txt')
- try:
+ with openfile('msg_28.txt') as fp:
msg = email.message_from_file(fp)
- finally:
- fp.close()
container1 = msg.get_payload(0)
eq(container1.get_default_type(), 'message/rfc822')
eq(container1.get_content_type(), 'message/rfc822')
@@ -1992,20 +2335,20 @@ message 2
# should be identical. Note: that we ignore the Unix-From since that may
# contain a changed date.
class TestIdempotent(TestEmailBase):
+
+ linesep = '\n'
+
def _msgobj(self, filename):
- fp = openfile(filename)
- try:
+ with openfile(filename) as fp:
data = fp.read()
- finally:
- fp.close()
msg = email.message_from_string(data)
return msg, data
- def _idempotent(self, msg, text):
+ def _idempotent(self, msg, text, unixfrom=False):
eq = self.ndiffAssertEqual
s = StringIO()
g = Generator(s, maxheaderlen=0)
- g.flatten(msg)
+ g.flatten(msg, unixfrom=unixfrom)
eq(text, s.getvalue())
def test_parse_text_message(self):
@@ -2092,6 +2435,14 @@ class TestIdempotent(TestEmailBase):
msg, text = self._msgobj('msg_36.txt')
self._idempotent(msg, text)
+ def test_message_delivery_status(self):
+ msg, text = self._msgobj('msg_43.txt')
+ self._idempotent(msg, text, unixfrom=True)
+
+ def test_message_signed_idempotent(self):
+ msg, text = self._msgobj('msg_45.txt')
+ self._idempotent(msg, text)
+
def test_content_type(self):
eq = self.assertEqual
unless = self.assertTrue
@@ -2104,16 +2455,16 @@ class TestIdempotent(TestEmailBase):
params[pk] = pv
eq(params['report-type'], 'delivery-status')
eq(params['boundary'], 'D1690A7AC1.996856090/mail.example.com')
- eq(msg.preamble, 'This is a MIME-encapsulated message.\n')
- eq(msg.epilogue, '\n')
+ eq(msg.preamble, 'This is a MIME-encapsulated message.' + self.linesep)
+ eq(msg.epilogue, self.linesep)
eq(len(msg.get_payload()), 3)
# Make sure the subparts are what we expect
msg1 = msg.get_payload(0)
eq(msg1.get_content_type(), 'text/plain')
- eq(msg1.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg1.get_payload(), 'Yadda yadda yadda' + self.linesep)
msg2 = msg.get_payload(1)
eq(msg2.get_content_type(), 'text/plain')
- eq(msg2.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg2.get_payload(), 'Yadda yadda yadda' + self.linesep)
msg3 = msg.get_payload(2)
eq(msg3.get_content_type(), 'message/rfc822')
self.assertTrue(isinstance(msg3, Message))
@@ -2122,7 +2473,7 @@ class TestIdempotent(TestEmailBase):
eq(len(payload), 1)
msg4 = payload[0]
unless(isinstance(msg4, Message))
- eq(msg4.get_payload(), 'Yadda yadda yadda\n')
+ eq(msg4.get_payload(), 'Yadda yadda yadda' + self.linesep)
def test_parser(self):
eq = self.assertEqual
@@ -2139,18 +2490,15 @@ class TestIdempotent(TestEmailBase):
self.assertTrue(isinstance(msg1, Message))
eq(msg1.get_content_type(), 'text/plain')
self.assertTrue(isinstance(msg1.get_payload(), str))
- eq(msg1.get_payload(), '\n')
+ eq(msg1.get_payload(), self.linesep)
# Test various other bits of the package's functionality
class TestMiscellaneous(TestEmailBase):
def test_message_from_string(self):
- fp = openfile('msg_01.txt')
- try:
+ with openfile('msg_01.txt') as fp:
text = fp.read()
- finally:
- fp.close()
msg = email.message_from_string(text)
s = StringIO()
# Don't wrap/continue long headers since we're trying to test
@@ -2160,8 +2508,7 @@ class TestMiscellaneous(TestEmailBase):
self.assertEqual(text, s.getvalue())
def test_message_from_file(self):
- fp = openfile('msg_01.txt')
- try:
+ with openfile('msg_01.txt') as fp:
text = fp.read()
fp.seek(0)
msg = email.message_from_file(fp)
@@ -2171,16 +2518,12 @@ class TestMiscellaneous(TestEmailBase):
g = Generator(s, maxheaderlen=0)
g.flatten(msg)
self.assertEqual(text, s.getvalue())
- finally:
- fp.close()
def test_message_from_string_with_class(self):
unless = self.assertTrue
- fp = openfile('msg_01.txt')
- try:
+ with openfile('msg_01.txt') as fp:
text = fp.read()
- finally:
- fp.close()
+
# Create a subclass
class MyMessage(Message):
pass
@@ -2188,11 +2531,8 @@ class TestMiscellaneous(TestEmailBase):
msg = email.message_from_string(text, MyMessage)
unless(isinstance(msg, MyMessage))
# Try something more complicated
- fp = openfile('msg_02.txt')
- try:
+ with openfile('msg_02.txt') as fp:
text = fp.read()
- finally:
- fp.close()
msg = email.message_from_string(text, MyMessage)
for subpart in msg.walk():
unless(isinstance(subpart, MyMessage))
@@ -2203,92 +2543,88 @@ class TestMiscellaneous(TestEmailBase):
class MyMessage(Message):
pass
- fp = openfile('msg_01.txt')
- try:
+ with openfile('msg_01.txt') as fp:
msg = email.message_from_file(fp, MyMessage)
- finally:
- fp.close()
unless(isinstance(msg, MyMessage))
# Try something more complicated
- fp = openfile('msg_02.txt')
- try:
+ with openfile('msg_02.txt') as fp:
msg = email.message_from_file(fp, MyMessage)
- finally:
- fp.close()
for subpart in msg.walk():
unless(isinstance(subpart, MyMessage))
def test__all__(self):
module = __import__('email')
- all = module.__all__
- all.sort()
- self.assertEqual(all, [
- # Old names
- 'Charset', 'Encoders', 'Errors', 'Generator',
- 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase',
- 'MIMEImage', 'MIMEMessage', 'MIMEMultipart',
- 'MIMENonMultipart', 'MIMEText', 'Message',
- 'Parser', 'Utils', 'base64MIME',
- # new names
- 'base64mime', 'charset', 'encoders', 'errors', 'generator',
- 'header', 'iterators', 'message', 'message_from_file',
- 'message_from_string', 'mime', 'parser',
- 'quopriMIME', 'quoprimime', 'utils',
+ self.assertEqual(sorted(module.__all__), [
+ 'base64mime', 'charset', 'encoders', 'errors', 'feedparser',
+ 'generator', 'header', 'iterators', 'message',
+ 'message_from_binary_file', 'message_from_bytes',
+ 'message_from_file', 'message_from_string', 'mime', 'parser',
+ 'quoprimime', 'utils',
])
def test_formatdate(self):
now = time.time()
- self.assertEqual(Utils.parsedate(Utils.formatdate(now))[:6],
+ self.assertEqual(utils.parsedate(utils.formatdate(now))[:6],
time.gmtime(now)[:6])
def test_formatdate_localtime(self):
now = time.time()
self.assertEqual(
- Utils.parsedate(Utils.formatdate(now, localtime=True))[:6],
+ utils.parsedate(utils.formatdate(now, localtime=True))[:6],
time.localtime(now)[:6])
def test_formatdate_usegmt(self):
now = time.time()
self.assertEqual(
- Utils.formatdate(now, localtime=False),
+ utils.formatdate(now, localtime=False),
time.strftime('%a, %d %b %Y %H:%M:%S -0000', time.gmtime(now)))
self.assertEqual(
- Utils.formatdate(now, localtime=False, usegmt=True),
+ utils.formatdate(now, localtime=False, usegmt=True),
time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(now)))
def test_parsedate_none(self):
- self.assertEqual(Utils.parsedate(''), None)
+ self.assertEqual(utils.parsedate(''), None)
def test_parsedate_compact(self):
# The FWS after the comma is optional
- self.assertEqual(Utils.parsedate('Wed,3 Apr 2002 14:58:26 +0800'),
- Utils.parsedate('Wed, 3 Apr 2002 14:58:26 +0800'))
+ self.assertEqual(utils.parsedate('Wed,3 Apr 2002 14:58:26 +0800'),
+ utils.parsedate('Wed, 3 Apr 2002 14:58:26 +0800'))
def test_parsedate_no_dayofweek(self):
eq = self.assertEqual
- eq(Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
+ eq(utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
(2003, 2, 25, 13, 47, 26, 0, 1, -1, -28800))
def test_parsedate_compact_no_dayofweek(self):
eq = self.assertEqual
- eq(Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
+ eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
(2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
+ def test_parsedate_no_space_before_positive_offset(self):
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26+0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, 28800))
+
+ def test_parsedate_no_space_before_negative_offset(self):
+ # Issue 1155362: we already handled '+' for this case.
+ self.assertEqual(utils.parsedate_tz('Wed, 3 Apr 2002 14:58:26-0800'),
+ (2002, 4, 3, 14, 58, 26, 0, 1, -1, -28800))
+
+
def test_parsedate_acceptable_to_time_functions(self):
eq = self.assertEqual
- timetup = Utils.parsedate('5 Feb 2003 13:47:26 -0800')
+ timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
t = int(time.mktime(timetup))
eq(time.localtime(t)[:6], timetup[:6])
eq(int(time.strftime('%Y', timetup)), 2003)
- timetup = Utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
+ timetup = utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
t = int(time.mktime(timetup[:9]))
eq(time.localtime(t)[:6], timetup[:6])
eq(int(time.strftime('%Y', timetup[:9])), 2003)
def test_mktime_tz(self):
- self.assertEqual(Utils.mktime_tz((1970, 1, 1, 0, 0, 0,
+ self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0,
-1, -1, -1, 0)), 0)
- self.assertEqual(Utils.mktime_tz((1970, 1, 1, 0, 0, 0,
+ self.assertEqual(utils.mktime_tz((1970, 1, 1, 0, 0, 0,
-1, -1, -1, 1234)), -1234)
def test_parsedate_y2k(self):
@@ -2299,44 +2635,44 @@ class TestMiscellaneous(TestEmailBase):
obsoletes RFC822) requires four-digit years.
"""
- self.assertEqual(Utils.parsedate_tz('25 Feb 03 13:47:26 -0800'),
- Utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'))
- self.assertEqual(Utils.parsedate_tz('25 Feb 71 13:47:26 -0800'),
- Utils.parsedate_tz('25 Feb 1971 13:47:26 -0800'))
+ self.assertEqual(utils.parsedate_tz('25 Feb 03 13:47:26 -0800'),
+ utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'))
+ self.assertEqual(utils.parsedate_tz('25 Feb 71 13:47:26 -0800'),
+ utils.parsedate_tz('25 Feb 1971 13:47:26 -0800'))
def test_parseaddr_empty(self):
- self.assertEqual(Utils.parseaddr('<>'), ('', ''))
- self.assertEqual(Utils.formataddr(Utils.parseaddr('<>')), '')
+ self.assertEqual(utils.parseaddr('<>'), ('', ''))
+ self.assertEqual(utils.formataddr(utils.parseaddr('<>')), '')
def test_noquote_dump(self):
self.assertEqual(
- Utils.formataddr(('A Silly Person', 'person@dom.ain')),
+ utils.formataddr(('A Silly Person', 'person@dom.ain')),
'A Silly Person <person@dom.ain>')
def test_escape_dump(self):
self.assertEqual(
- Utils.formataddr(('A (Very) Silly Person', 'person@dom.ain')),
+ utils.formataddr(('A (Very) Silly Person', 'person@dom.ain')),
r'"A \(Very\) Silly Person" <person@dom.ain>')
a = r'A \(Special\) Person'
b = 'person@dom.ain'
- self.assertEqual(Utils.parseaddr(Utils.formataddr((a, b))), (a, b))
+ self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
def test_escape_backslashes(self):
self.assertEqual(
- Utils.formataddr(('Arthur \Backslash\ Foobar', 'person@dom.ain')),
+ utils.formataddr(('Arthur \Backslash\ Foobar', 'person@dom.ain')),
r'"Arthur \\Backslash\\ Foobar" <person@dom.ain>')
a = r'Arthur \Backslash\ Foobar'
b = 'person@dom.ain'
- self.assertEqual(Utils.parseaddr(Utils.formataddr((a, b))), (a, b))
+ self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
def test_name_with_dot(self):
x = 'John X. Doe <jxd@example.com>'
y = '"John X. Doe" <jxd@example.com>'
a, b = ('John X. Doe', 'jxd@example.com')
- self.assertEqual(Utils.parseaddr(x), (a, b))
- self.assertEqual(Utils.parseaddr(y), (a, b))
+ self.assertEqual(utils.parseaddr(x), (a, b))
+ self.assertEqual(utils.parseaddr(y), (a, b))
# formataddr() quotes the name if there's a dot in it
- self.assertEqual(Utils.formataddr((a, b)), y)
+ self.assertEqual(utils.formataddr((a, b)), y)
def test_parseaddr_preserves_quoted_pairs_in_addresses(self):
# issue 10005. Note that in the third test the second pair of
@@ -2349,32 +2685,42 @@ class TestMiscellaneous(TestEmailBase):
# not appear in an address outside of a quoted string. It is probably
# a sensible Postel interpretation, though.
eq = self.assertEqual
- eq(Utils.parseaddr('""example" example"@example.com'),
+ eq(utils.parseaddr('""example" example"@example.com'),
('', '""example" example"@example.com'))
- eq(Utils.parseaddr('"\\"example\\" example"@example.com'),
+ eq(utils.parseaddr('"\\"example\\" example"@example.com'),
('', '"\\"example\\" example"@example.com'))
- eq(Utils.parseaddr('"\\\\"example\\\\" example"@example.com'),
+ eq(utils.parseaddr('"\\\\"example\\\\" example"@example.com'),
('', '"\\\\"example\\\\" example"@example.com'))
+ def test_parseaddr_preserves_spaces_in_local_part(self):
+ # issue 9286. A normal RFC5322 local part should not contain any
+ # folding white space, but legacy local parts can (they are a sequence
+ # of atoms, not dotatoms). On the other hand we strip whitespace from
+ # before the @ and around dots, on the assumption that the whitespace
+ # around the punctuation is a mistake in what would otherwise be
+ # an RFC5322 local part. Leading whitespace is, usual, stripped as well.
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr("merwok wok@xample.com"))
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr("merwok wok@xample.com"))
+ self.assertEqual(('', "merwok wok@xample.com"),
+ utils.parseaddr(" merwok wok @xample.com"))
+ self.assertEqual(('', 'merwok"wok" wok@xample.com'),
+ utils.parseaddr('merwok"wok" wok@xample.com'))
+ self.assertEqual(('', 'merwok.wok.wok@xample.com'),
+ utils.parseaddr('merwok. wok . wok@xample.com'))
+
def test_multiline_from_comment(self):
x = """\
Foo
\tBar <foo@example.com>"""
- self.assertEqual(Utils.parseaddr(x), ('Foo Bar', 'foo@example.com'))
+ self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo@example.com'))
def test_quote_dump(self):
self.assertEqual(
- Utils.formataddr(('A Silly; Person', 'person@dom.ain')),
+ utils.formataddr(('A Silly; Person', 'person@dom.ain')),
r'"A Silly; Person" <person@dom.ain>')
- def test_fix_eols(self):
- eq = self.assertEqual
- eq(Utils.fix_eols('hello'), 'hello')
- eq(Utils.fix_eols('hello\n'), 'hello\r\n')
- eq(Utils.fix_eols('hello\r'), 'hello\r\n')
- eq(Utils.fix_eols('hello\r\n'), 'hello\r\n')
- eq(Utils.fix_eols('hello\n\r'), 'hello\r\n\r\n')
-
def test_charset_richcomparisons(self):
eq = self.assertEqual
ne = self.assertNotEqual
@@ -2397,25 +2743,25 @@ Foo
def test_getaddresses(self):
eq = self.assertEqual
- eq(Utils.getaddresses(['aperson@dom.ain (Al Person)',
+ eq(utils.getaddresses(['aperson@dom.ain (Al Person)',
'Bud Person <bperson@dom.ain>']),
[('Al Person', 'aperson@dom.ain'),
('Bud Person', 'bperson@dom.ain')])
def test_getaddresses_nasty(self):
eq = self.assertEqual
- eq(Utils.getaddresses(['foo: ;']), [('', '')])
- eq(Utils.getaddresses(
+ eq(utils.getaddresses(['foo: ;']), [('', '')])
+ eq(utils.getaddresses(
['[]*-- =~$']),
[('', ''), ('', ''), ('', '*--')])
- eq(Utils.getaddresses(
+ eq(utils.getaddresses(
['foo: ;', '"Jason R. Mastaler" <jason@dom.ain>']),
[('', ''), ('Jason R. Mastaler', 'jason@dom.ain')])
def test_getaddresses_embedded_comment(self):
"""Test proper handling of a nested comment"""
eq = self.assertEqual
- addrs = Utils.getaddresses(['User ((nested comment)) <foo@bar.com>'])
+ addrs = utils.getaddresses(['User ((nested comment)) <foo@bar.com>'])
eq(addrs[0][1], 'foo@bar.com')
def test_utils_quote_unquote(self):
@@ -2439,9 +2785,9 @@ Foo
eq(charsets[0], 'utf-8')
charset = Charset(charsets[0])
eq(charset.get_body_encoding(), 'base64')
- msg.set_payload('hello world', charset=charset)
+ msg.set_payload(b'hello world', charset=charset)
eq(msg.get_payload(), 'aGVsbG8gd29ybGQ=\n')
- eq(msg.get_payload(decode=True), 'hello world')
+ eq(msg.get_payload(decode=True), b'hello world')
eq(msg['content-transfer-encoding'], 'base64')
# Try another one
msg = Message()
@@ -2450,7 +2796,7 @@ Foo
eq(len(charsets), 1)
eq(charsets[0], 'us-ascii')
charset = Charset(charsets[0])
- eq(charset.get_body_encoding(), Encoders.encode_7or8bit)
+ eq(charset.get_body_encoding(), encoders.encode_7or8bit)
msg.set_payload('hello world', charset=charset)
eq(msg.get_payload(), 'hello world')
eq(msg['content-transfer-encoding'], '7bit')
@@ -2468,7 +2814,7 @@ Foo
# unreadline() of NeedMoreData.
msg = self._msgobj('msg_43.txt')
sfp = StringIO()
- Iterators._structure(msg, sfp)
+ iterators._structure(msg, sfp)
eq(sfp.getvalue(), """\
multipart/report
text/plain
@@ -2502,6 +2848,10 @@ multipart/report
text/rfc822-headers
""")
+ def test_make_msgid_domain(self):
+ self.assertEqual(
+ email.utils.make_msgid(domain='testdomain-string')[-19:],
+ '@testdomain-string>')
# Test the iterator/generators
@@ -2511,25 +2861,22 @@ class TestIterators(TestEmailBase):
neq = self.ndiffAssertEqual
# First a simple non-multipart message
msg = self._msgobj('msg_01.txt')
- it = Iterators.body_line_iterator(msg)
+ it = iterators.body_line_iterator(msg)
lines = list(it)
eq(len(lines), 6)
neq(EMPTYSTRING.join(lines), msg.get_payload())
# Now a more complicated multipart
msg = self._msgobj('msg_02.txt')
- it = Iterators.body_line_iterator(msg)
+ it = iterators.body_line_iterator(msg)
lines = list(it)
eq(len(lines), 43)
- fp = openfile('msg_19.txt')
- try:
+ with openfile('msg_19.txt') as fp:
neq(EMPTYSTRING.join(lines), fp.read())
- finally:
- fp.close()
def test_typed_subpart_iterator(self):
eq = self.assertEqual
msg = self._msgobj('msg_04.txt')
- it = Iterators.typed_subpart_iterator(msg, 'text')
+ it = iterators.typed_subpart_iterator(msg, 'text')
lines = []
subparts = 0
for subpart in it:
@@ -2546,7 +2893,7 @@ to reflect upon our own
def test_typed_subpart_iterator_default_type(self):
eq = self.assertEqual
msg = self._msgobj('msg_03.txt')
- it = Iterators.typed_subpart_iterator(msg, 'text', 'plain')
+ it = iterators.typed_subpart_iterator(msg, 'text', 'plain')
lines = []
subparts = 0
for subpart in it:
@@ -2601,11 +2948,8 @@ class TestParsers(TestEmailBase):
def test_header_parser(self):
eq = self.assertEqual
# Parse only the headers of a complex multipart MIME document
- fp = openfile('msg_02.txt')
- try:
+ with openfile('msg_02.txt') as fp:
msg = HeaderParser().parse(fp)
- finally:
- fp.close()
eq(msg['from'], 'ppp-request@zzz.org')
eq(msg['to'], 'ppp@zzz.org')
eq(msg.get_content_type(), 'multipart/mixed')
@@ -2650,11 +2994,8 @@ Here's the message body
def test_crlf_separation(self):
eq = self.assertEqual
- fp = openfile('msg_26.txt', mode='rb')
- try:
+ with openfile('msg_26.txt', newline='\n') as fp:
msg = Parser().parse(fp)
- finally:
- fp.close()
eq(len(msg.get_payload()), 2)
part1 = msg.get_payload(0)
eq(part1.get_content_type(), 'text/plain')
@@ -2662,14 +3003,23 @@ Here's the message body
part2 = msg.get_payload(1)
eq(part2.get_content_type(), 'application/riscos')
+ def test_crlf_flatten(self):
+ # Using newline='\n' preserves the crlfs in this input file.
+ with openfile('msg_26.txt', newline='\n') as fp:
+ text = fp.read()
+ msg = email.message_from_string(text)
+ s = StringIO()
+ g = Generator(s)
+ g.flatten(msg, linesep='\r\n')
+ self.assertEqual(s.getvalue(), text)
+
+ maxDiff = None
+
def test_multipart_digest_with_extra_mime_headers(self):
eq = self.assertEqual
neq = self.ndiffAssertEqual
- fp = openfile('msg_28.txt')
- try:
+ with openfile('msg_28.txt') as fp:
msg = email.message_from_file(fp)
- finally:
- fp.close()
# Structure is:
# multipart/digest
# message/rfc822
@@ -2719,10 +3069,8 @@ Here's the message body
eq = self.assertEqual
m = '>From: foo\nFrom: bar\n!"#QUX;~: zoo\n\nbody'
msg = email.message_from_string(m)
- eq(len(msg.keys()), 3)
- keys = msg.keys()
- keys.sort()
- eq(keys, ['!"#QUX;~', '>From', 'From'])
+ eq(len(msg), 3)
+ eq(sorted(field for field in msg), ['!"#QUX;~', '>From', 'From'])
eq(msg.get_payload(), 'body')
def test_rfc2822_space_not_allowed_in_header(self):
@@ -2760,11 +3108,446 @@ Here's the message body
self.assertTrue(msg.get_payload(0).get_payload().endswith('\r\n'))
+class Test8BitBytesHandling(unittest.TestCase):
+ # In Python3 all input is string, but that doesn't work if the actual input
+ # uses an 8bit transfer encoding. To hack around that, in email 5.1 we
+ # decode byte streams using the surrogateescape error handler, and
+ # reconvert to binary at appropriate places if we detect surrogates. This
+ # doesn't allow us to transform headers with 8bit bytes (they get munged),
+ # but it does allow us to parse and preserve them, and to decode body
+ # parts that use an 8bit CTE.
+
+ bodytest_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: baz
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset={charset}
+ Content-Transfer-Encoding: {cte}
+
+ {bodyline}
+ """)
+
+ def test_known_8bit_CTE(self):
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='8bit',
+ bodyline='pöstal').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), "pöstal\n")
+ self.assertEqual(msg.get_payload(decode=True),
+ "pöstal\n".encode('utf-8'))
+
+ def test_unknown_8bit_CTE(self):
+ m = self.bodytest_msg.format(charset='notavalidcharset',
+ cte='8bit',
+ bodyline='pöstal').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), "p\uFFFD\uFFFDstal\n")
+ self.assertEqual(msg.get_payload(decode=True),
+ "pöstal\n".encode('utf-8'))
+
+ def test_8bit_in_quopri_body(self):
+ # This is non-RFC compliant data...without 'decode' the library code
+ # decodes the body using the charset from the headers, and because the
+ # source byte really is utf-8 this works. This is likely to fail
+ # against real dirty data (ie: produce mojibake), but the data is
+ # invalid anyway so it is as good a guess as any. But this means that
+ # this test just confirms the current behavior; that behavior is not
+ # necessarily the best possible behavior. With 'decode' it is
+ # returning the raw bytes, so that test should be of correct behavior,
+ # or at least produce the same result that email4 did.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='quoted-printable',
+ bodyline='p=C3=B6stál').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), 'p=C3=B6stál\n')
+ self.assertEqual(msg.get_payload(decode=True),
+ 'pöstál\n'.encode('utf-8'))
+
+ def test_invalid_8bit_in_non_8bit_cte_uses_replace(self):
+ # This is similar to the previous test, but proves that if the 8bit
+ # byte is undecodeable in the specified charset, it gets replaced
+ # by the unicode 'unknown' character. Again, this may or may not
+ # be the ideal behavior. Note that if decode=False none of the
+ # decoders will get involved, so this is the only test we need
+ # for this behavior.
+ m = self.bodytest_msg.format(charset='ascii',
+ cte='quoted-printable',
+ bodyline='p=C3=B6stál').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(), 'p=C3=B6st\uFFFD\uFFFDl\n')
+ self.assertEqual(msg.get_payload(decode=True),
+ 'pöstál\n'.encode('utf-8'))
+
+ def test_8bit_in_base64_body(self):
+ # Sticking an 8bit byte in a base64 block makes it undecodable by
+ # normal means, so the block is returned undecoded, but as bytes.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='base64',
+ bodyline='cMO2c3RhbAá=').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(decode=True),
+ 'cMO2c3RhbAá=\n'.encode('utf-8'))
+
+ def test_8bit_in_uuencode_body(self):
+ # Sticking an 8bit byte in a uuencode block makes it undecodable by
+ # normal means, so the block is returned undecoded, but as bytes.
+ m = self.bodytest_msg.format(charset='utf-8',
+ cte='uuencode',
+ bodyline='<,.V<W1A; á ').encode('utf-8')
+ msg = email.message_from_bytes(m)
+ self.assertEqual(msg.get_payload(decode=True),
+ '<,.V<W1A; á \n'.encode('utf-8'))
+
+
+ headertest_headers = (
+ ('From: foo@bar.com', ('From', 'foo@bar.com')),
+ ('To: báz', ('To', '=?unknown-8bit?q?b=C3=A1z?=')),
+ ('Subject: Maintenant je vous présente mon collègue, le pouf célèbre\n'
+ '\tJean de Baddie',
+ ('Subject', '=?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_'
+ 'coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=\n'
+ ' =?unknown-8bit?q?_Jean_de_Baddie?=')),
+ ('From: göst', ('From', '=?unknown-8bit?b?Z8O2c3Q=?=')),
+ )
+ headertest_msg = ('\n'.join([src for (src, _) in headertest_headers]) +
+ '\nYes, they are flying.\n').encode('utf-8')
+
+ def test_get_8bit_header(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertEqual(str(msg.get('to')), 'b\uFFFD\uFFFDz')
+ self.assertEqual(str(msg['to']), 'b\uFFFD\uFFFDz')
+
+ def test_print_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertEqual(str(msg),
+ textwrap.dedent("""\
+ From: {}
+ To: {}
+ Subject: {}
+ From: {}
+
+ Yes, they are flying.
+ """).format(*[expected[1] for (_, expected) in
+ self.headertest_headers]))
+
+ def test_values_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([str(x) for x in msg.values()],
+ ['foo@bar.com',
+ 'b\uFFFD\uFFFDz',
+ 'Maintenant je vous pr\uFFFD\uFFFDsente mon '
+ 'coll\uFFFD\uFFFDgue, le pouf '
+ 'c\uFFFD\uFFFDl\uFFFD\uFFFDbre\n'
+ '\tJean de Baddie',
+ "g\uFFFD\uFFFDst"])
+
+ def test_items_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([(str(x), str(y)) for (x, y) in msg.items()],
+ [('From', 'foo@bar.com'),
+ ('To', 'b\uFFFD\uFFFDz'),
+ ('Subject', 'Maintenant je vous '
+ 'pr\uFFFD\uFFFDsente '
+ 'mon coll\uFFFD\uFFFDgue, le pouf '
+ 'c\uFFFD\uFFFDl\uFFFD\uFFFDbre\n'
+ '\tJean de Baddie'),
+ ('From', 'g\uFFFD\uFFFDst')])
+
+ def test_get_all_with_8bit_headers(self):
+ msg = email.message_from_bytes(self.headertest_msg)
+ self.assertListEqual([str(x) for x in msg.get_all('from')],
+ ['foo@bar.com',
+ 'g\uFFFD\uFFFDst'])
+
+ def test_get_content_type_with_8bit(self):
+ msg = email.message_from_bytes(textwrap.dedent("""\
+ Content-Type: text/pl\xA7in; charset=utf-8
+ """).encode('latin-1'))
+ self.assertEqual(msg.get_content_type(), "text/pl\uFFFDin")
+ self.assertEqual(msg.get_content_maintype(), "text")
+ self.assertEqual(msg.get_content_subtype(), "pl\uFFFDin")
+
+ def test_get_params_with_8bit(self):
+ msg = email.message_from_bytes(
+ 'X-Header: foo=\xa7ne; b\xa7r=two; baz=three\n'.encode('latin-1'))
+ self.assertEqual(msg.get_params(header='x-header'),
+ [('foo', '\uFFFDne'), ('b\uFFFDr', 'two'), ('baz', 'three')])
+ self.assertEqual(msg.get_param('Foo', header='x-header'), '\uFFFdne')
+ # XXX: someday you might be able to get 'b\xa7r', for now you can't.
+ self.assertEqual(msg.get_param('b\xa7r', header='x-header'), None)
+
+ def test_get_rfc2231_params_with_8bit(self):
+ msg = email.message_from_bytes(textwrap.dedent("""\
+ Content-Type: text/plain; charset=us-ascii;
+ title*=us-ascii'en'This%20is%20not%20f\xa7n"""
+ ).encode('latin-1'))
+ self.assertEqual(msg.get_param('title'),
+ ('us-ascii', 'en', 'This is not f\uFFFDn'))
+
+ def test_set_rfc2231_params_with_8bit(self):
+ msg = email.message_from_bytes(textwrap.dedent("""\
+ Content-Type: text/plain; charset=us-ascii;
+ title*=us-ascii'en'This%20is%20not%20f\xa7n"""
+ ).encode('latin-1'))
+ msg.set_param('title', 'test')
+ self.assertEqual(msg.get_param('title'), 'test')
+
+ def test_del_rfc2231_params_with_8bit(self):
+ msg = email.message_from_bytes(textwrap.dedent("""\
+ Content-Type: text/plain; charset=us-ascii;
+ title*=us-ascii'en'This%20is%20not%20f\xa7n"""
+ ).encode('latin-1'))
+ msg.del_param('title')
+ self.assertEqual(msg.get_param('title'), None)
+ self.assertEqual(msg.get_content_maintype(), 'text')
+
+ def test_get_payload_with_8bit_cte_header(self):
+ msg = email.message_from_bytes(textwrap.dedent("""\
+ Content-Transfer-Encoding: b\xa7se64
+ Content-Type: text/plain; charset=latin-1
+
+ payload
+ """).encode('latin-1'))
+ self.assertEqual(msg.get_payload(), 'payload\n')
+ self.assertEqual(msg.get_payload(decode=True), b'payload\n')
+
+ non_latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: báz
+ Subject: Maintenant je vous présente mon collègue, le pouf célèbre
+ \tJean de Baddie
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ Да, они летÑÑ‚.
+ """).encode('utf-8')
+
+ def test_bytes_generator(self):
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), self.non_latin_bin_msg)
+
+ def test_bytes_generator_handles_None_body(self):
+ #Issue 11019
+ msg = email.message.Message()
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), b"\n")
+
+ non_latin_bin_msg_as7bit_wrapped = textwrap.dedent("""\
+ From: foo@bar.com
+ To: =?unknown-8bit?q?b=C3=A1z?=
+ Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_coll=C3=A8gue?=
+ =?unknown-8bit?q?=2C_le_pouf_c=C3=A9l=C3=A8bre?=
+ =?unknown-8bit?q?_Jean_de_Baddie?=
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: base64
+
+ 0JTQsCwg0L7QvdC4INC70LXRgtGP0YIuCg==
+ """)
+
+ def test_generator_handles_8bit(self):
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = StringIO()
+ email.generator.Generator(out).flatten(msg)
+ self.assertEqual(out.getvalue(), self.non_latin_bin_msg_as7bit_wrapped)
+
+ def test_bytes_generator_with_unix_from(self):
+ # The unixfrom contains a current date, so we can't check it
+ # literally. Just make sure the first word is 'From' and the
+ # rest of the message matches the input.
+ msg = email.message_from_bytes(self.non_latin_bin_msg)
+ out = BytesIO()
+ email.generator.BytesGenerator(out).flatten(msg, unixfrom=True)
+ lines = out.getvalue().split(b'\n')
+ self.assertEqual(lines[0].split()[0], b'From')
+ self.assertEqual(b'\n'.join(lines[1:]), self.non_latin_bin_msg)
+
+ non_latin_bin_msg_as7bit = non_latin_bin_msg_as7bit_wrapped.split('\n')
+ non_latin_bin_msg_as7bit[2:4] = [
+ 'Subject: =?unknown-8bit?q?Maintenant_je_vous_pr=C3=A9sente_mon_'
+ 'coll=C3=A8gue=2C_le_pouf_c=C3=A9l=C3=A8bre?=']
+ non_latin_bin_msg_as7bit = '\n'.join(non_latin_bin_msg_as7bit)
+
+ def test_message_from_binary_file(self):
+ fn = 'test.msg'
+ self.addCleanup(unlink, fn)
+ with open(fn, 'wb') as testfile:
+ testfile.write(self.non_latin_bin_msg)
+ with open(fn, 'rb') as testfile:
+ m = email.parser.BytesParser().parse(testfile)
+ self.assertEqual(str(m), self.non_latin_bin_msg_as7bit)
+
+ latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: Dinsdale
+ Subject: Nudge nudge, wink, wink
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="latin-1"
+ Content-Transfer-Encoding: 8bit
+
+ oh là là, know what I mean, know what I mean?
+ """).encode('latin-1')
+
+ latin_bin_msg_as7bit = textwrap.dedent("""\
+ From: foo@bar.com
+ To: Dinsdale
+ Subject: Nudge nudge, wink, wink
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="iso-8859-1"
+ Content-Transfer-Encoding: quoted-printable
+
+ oh l=E0 l=E0, know what I mean, know what I mean?
+ """)
+
+ def test_string_generator_reencodes_to_quopri_when_appropriate(self):
+ m = email.message_from_bytes(self.latin_bin_msg)
+ self.assertEqual(str(m), self.latin_bin_msg_as7bit)
+
+ def test_decoded_generator_emits_unicode_body(self):
+ m = email.message_from_bytes(self.latin_bin_msg)
+ out = StringIO()
+ email.generator.DecodedGenerator(out).flatten(m)
+ #DecodedHeader output contains an extra blank line compared
+ #to the input message. RDM: not sure if this is a bug or not,
+ #but it is not specific to the 8bit->7bit conversion.
+ self.assertEqual(out.getvalue(),
+ self.latin_bin_msg.decode('latin-1')+'\n')
+
+ def test_bytes_feedparser(self):
+ bfp = email.feedparser.BytesFeedParser()
+ for i in range(0, len(self.latin_bin_msg), 10):
+ bfp.feed(self.latin_bin_msg[i:i+10])
+ m = bfp.close()
+ self.assertEqual(str(m), self.latin_bin_msg_as7bit)
+
+ def test_crlf_flatten(self):
+ with openfile('msg_26.txt', 'rb') as fp:
+ text = fp.read()
+ msg = email.message_from_bytes(text)
+ s = BytesIO()
+ g = email.generator.BytesGenerator(s)
+ g.flatten(msg, linesep='\r\n')
+ self.assertEqual(s.getvalue(), text)
+
+ def test_8bit_multipart(self):
+ # Issue 11605
+ source = textwrap.dedent("""\
+ Date: Fri, 18 Mar 2011 17:15:43 +0100
+ To: foo@example.com
+ From: foodwatch-Newsletter <bar@example.com>
+ Subject: Aktuelles zu Japan, Klonfleisch und Smiley-System
+ Message-ID: <76a486bee62b0d200f33dc2ca08220ad@localhost.localdomain>
+ MIME-Version: 1.0
+ Content-Type: multipart/alternative;
+ boundary="b1_76a486bee62b0d200f33dc2ca08220ad"
+
+ --b1_76a486bee62b0d200f33dc2ca08220ad
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ Guten Tag, ,
+
+ mit großer Betroffenheit verfolgen auch wir im foodwatch-Team die
+ Nachrichten aus Japan.
+
+
+ --b1_76a486bee62b0d200f33dc2ca08220ad
+ Content-Type: text/html; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+ <html lang="de">
+ <head>
+ <title>foodwatch - Newsletter</title>
+ </head>
+ <body>
+ <p>mit gro&szlig;er Betroffenheit verfolgen auch wir im foodwatch-Team
+ die Nachrichten aus Japan.</p>
+ </body>
+ </html>
+ --b1_76a486bee62b0d200f33dc2ca08220ad--
+
+ """).encode('utf-8')
+ msg = email.message_from_bytes(source)
+ s = BytesIO()
+ g = email.generator.BytesGenerator(s)
+ g.flatten(msg)
+ self.assertEqual(s.getvalue(), source)
+
+ def test_bytes_generator_b_encoding_linesep(self):
+ # Issue 14062: b encoding was tacking on an extra \n.
+ m = Message()
+ # This has enough non-ascii that it should always end up b encoded.
+ m['Subject'] = Header('žluÅ¥ouÄký kůň')
+ s = BytesIO()
+ g = email.generator.BytesGenerator(s)
+ g.flatten(m, linesep='\r\n')
+ self.assertEqual(
+ s.getvalue(),
+ b'Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=\r\n\r\n')
+
+ def test_generator_b_encoding_linesep(self):
+ # Since this broke in ByteGenerator, test Generator for completeness.
+ m = Message()
+ # This has enough non-ascii that it should always end up b encoded.
+ m['Subject'] = Header('žluÅ¥ouÄký kůň')
+ s = StringIO()
+ g = email.generator.Generator(s)
+ g.flatten(m, linesep='\r\n')
+ self.assertEqual(
+ s.getvalue(),
+ 'Subject: =?utf-8?b?xb5sdcWlb3XEjWvDvSBrxa/FiA==?=\r\n\r\n')
+
+ maxDiff = None
+
+
+class BaseTestBytesGeneratorIdempotent:
+
+ maxDiff = None
+
+ def _msgobj(self, filename):
+ with openfile(filename, 'rb') as fp:
+ data = fp.read()
+ data = self.normalize_linesep_regex.sub(self.blinesep, data)
+ msg = email.message_from_bytes(data)
+ return msg, data
+
+ def _idempotent(self, msg, data, unixfrom=False):
+ b = BytesIO()
+ g = email.generator.BytesGenerator(b, maxheaderlen=0)
+ g.flatten(msg, unixfrom=unixfrom, linesep=self.linesep)
+ self.assertByteStringsEqual(data, b.getvalue())
+
+ def assertByteStringsEqual(self, str1, str2):
+ # Not using self.blinesep here is intentional. This way the output
+ # is more useful when the failure results in mixed line endings.
+ self.assertListEqual(str1.split(b'\n'), str2.split(b'\n'))
+
+
+class TestBytesGeneratorIdempotentNL(BaseTestBytesGeneratorIdempotent,
+ TestIdempotent):
+ linesep = '\n'
+ blinesep = b'\n'
+ normalize_linesep_regex = re.compile(br'\r\n')
+
+
+class TestBytesGeneratorIdempotentCRLF(BaseTestBytesGeneratorIdempotent,
+ TestIdempotent):
+ linesep = '\r\n'
+ blinesep = b'\r\n'
+ normalize_linesep_regex = re.compile(br'(?<!\r)\n')
+
+
class TestBase64(unittest.TestCase):
def test_len(self):
eq = self.assertEqual
- eq(base64MIME.base64_len('hello'),
- len(base64MIME.encode('hello', eol='')))
+ eq(base64mime.header_length('hello'),
+ len(base64mime.body_encode(b'hello', eol='')))
for size in range(15):
if size == 0 : bsize = 0
elif size <= 3 : bsize = 4
@@ -2772,31 +3555,29 @@ class TestBase64(unittest.TestCase):
elif size <= 9 : bsize = 12
elif size <= 12: bsize = 16
else : bsize = 20
- eq(base64MIME.base64_len('x'*size), bsize)
+ eq(base64mime.header_length('x' * size), bsize)
def test_decode(self):
eq = self.assertEqual
- eq(base64MIME.decode(''), '')
- eq(base64MIME.decode('aGVsbG8='), 'hello')
- eq(base64MIME.decode('aGVsbG8=', 'X'), 'hello')
- eq(base64MIME.decode('aGVsbG8NCndvcmxk\n', 'X'), 'helloXworld')
+ eq(base64mime.decode(''), b'')
+ eq(base64mime.decode('aGVsbG8='), b'hello')
def test_encode(self):
eq = self.assertEqual
- eq(base64MIME.encode(''), '')
- eq(base64MIME.encode('hello'), 'aGVsbG8=\n')
+ eq(base64mime.body_encode(b''), b'')
+ eq(base64mime.body_encode(b'hello'), 'aGVsbG8=\n')
# Test the binary flag
- eq(base64MIME.encode('hello\n'), 'aGVsbG8K\n')
- eq(base64MIME.encode('hello\n', 0), 'aGVsbG8NCg==\n')
+ eq(base64mime.body_encode(b'hello\n'), 'aGVsbG8K\n')
# Test the maxlinelen arg
- eq(base64MIME.encode('xxxx ' * 20, maxlinelen=40), """\
+ eq(base64mime.body_encode(b'xxxx ' * 20, maxlinelen=40), """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
eHh4eCB4eHh4IA==
""")
# Test the eol argument
- eq(base64MIME.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
+ eq(base64mime.body_encode(b'xxxx ' * 20, maxlinelen=40, eol='\r\n'),
+ """\
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
@@ -2805,134 +3586,322 @@ eHh4eCB4eHh4IA==\r
def test_header_encode(self):
eq = self.assertEqual
- he = base64MIME.header_encode
+ he = base64mime.header_encode
eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=')
- eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=')
+ eq(he('hello\r\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=')
+ eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
# Test the charset option
eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=')
- # Test the keep_eols flag
- eq(he('hello\nworld', keep_eols=True),
- '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
- # Test the maxlinelen argument
- eq(he('xxxx ' * 20, maxlinelen=40), """\
-=?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?=
- =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?=
- =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?=
- =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?=
- =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?=
- =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""")
- # Test the eol argument
- eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-=?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?=\r
- =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?=\r
- =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?=\r
- =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?=\r
- =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?=\r
- =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""")
+ eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
class TestQuopri(unittest.TestCase):
def setUp(self):
- self.hlit = [chr(x) for x in range(ord('a'), ord('z')+1)] + \
- [chr(x) for x in range(ord('A'), ord('Z')+1)] + \
- [chr(x) for x in range(ord('0'), ord('9')+1)] + \
- ['!', '*', '+', '-', '/', ' ']
- self.hnon = [chr(x) for x in range(256) if chr(x) not in self.hlit]
+ # Set of characters (as byte integers) that don't need to be encoded
+ # in headers.
+ self.hlit = list(chain(
+ range(ord('a'), ord('z') + 1),
+ range(ord('A'), ord('Z') + 1),
+ range(ord('0'), ord('9') + 1),
+ (c for c in b'!*+-/')))
+ # Set of characters (as byte integers) that do need to be encoded in
+ # headers.
+ self.hnon = [c for c in range(256) if c not in self.hlit]
assert len(self.hlit) + len(self.hnon) == 256
- self.blit = [chr(x) for x in range(ord(' '), ord('~')+1)] + ['\t']
- self.blit.remove('=')
- self.bnon = [chr(x) for x in range(256) if chr(x) not in self.blit]
+ # Set of characters (as byte integers) that don't need to be encoded
+ # in bodies.
+ self.blit = list(range(ord(' '), ord('~') + 1))
+ self.blit.append(ord('\t'))
+ self.blit.remove(ord('='))
+ # Set of characters (as byte integers) that do need to be encoded in
+ # bodies.
+ self.bnon = [c for c in range(256) if c not in self.blit]
assert len(self.blit) + len(self.bnon) == 256
- def test_header_quopri_check(self):
+ def test_quopri_header_check(self):
for c in self.hlit:
- self.assertFalse(quopriMIME.header_quopri_check(c))
+ self.assertFalse(quoprimime.header_check(c),
+ 'Should not be header quopri encoded: %s' % chr(c))
for c in self.hnon:
- self.assertTrue(quopriMIME.header_quopri_check(c))
+ self.assertTrue(quoprimime.header_check(c),
+ 'Should be header quopri encoded: %s' % chr(c))
- def test_body_quopri_check(self):
+ def test_quopri_body_check(self):
for c in self.blit:
- self.assertFalse(quopriMIME.body_quopri_check(c))
+ self.assertFalse(quoprimime.body_check(c),
+ 'Should not be body quopri encoded: %s' % chr(c))
for c in self.bnon:
- self.assertTrue(quopriMIME.body_quopri_check(c))
+ self.assertTrue(quoprimime.body_check(c),
+ 'Should be body quopri encoded: %s' % chr(c))
def test_header_quopri_len(self):
eq = self.assertEqual
- hql = quopriMIME.header_quopri_len
- enc = quopriMIME.header_encode
- for s in ('hello', 'h@e@l@l@o@'):
- # Empty charset and no line-endings. 7 == RFC chrome
- eq(hql(s), len(enc(s, charset='', eol=''))-7)
+ eq(quoprimime.header_length(b'hello'), 5)
+ # RFC 2047 chrome is not included in header_length().
+ eq(len(quoprimime.header_encode(b'hello', charset='xxx')),
+ quoprimime.header_length(b'hello') +
+ # =?xxx?q?...?= means 10 extra characters
+ 10)
+ eq(quoprimime.header_length(b'h@e@l@l@o@'), 20)
+ # RFC 2047 chrome is not included in header_length().
+ eq(len(quoprimime.header_encode(b'h@e@l@l@o@', charset='xxx')),
+ quoprimime.header_length(b'h@e@l@l@o@') +
+ # =?xxx?q?...?= means 10 extra characters
+ 10)
for c in self.hlit:
- eq(hql(c), 1)
+ eq(quoprimime.header_length(bytes([c])), 1,
+ 'expected length 1 for %r' % chr(c))
for c in self.hnon:
- eq(hql(c), 3)
+ # Space is special; it's encoded to _
+ if c == ord(' '):
+ continue
+ eq(quoprimime.header_length(bytes([c])), 3,
+ 'expected length 3 for %r' % chr(c))
+ eq(quoprimime.header_length(b' '), 1)
def test_body_quopri_len(self):
eq = self.assertEqual
- bql = quopriMIME.body_quopri_len
for c in self.blit:
- eq(bql(c), 1)
+ eq(quoprimime.body_length(bytes([c])), 1)
for c in self.bnon:
- eq(bql(c), 3)
+ eq(quoprimime.body_length(bytes([c])), 3)
def test_quote_unquote_idempotent(self):
for x in range(256):
c = chr(x)
- self.assertEqual(quopriMIME.unquote(quopriMIME.quote(c)), c)
+ self.assertEqual(quoprimime.unquote(quoprimime.quote(c)), c)
- def test_header_encode(self):
- eq = self.assertEqual
- he = quopriMIME.header_encode
- eq(he('hello'), '=?iso-8859-1?q?hello?=')
- eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=')
- # Test the charset option
- eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=')
- # Test the keep_eols flag
- eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?q?hello=0Aworld?=')
- # Test a non-ASCII character
- eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=')
- # Test the maxlinelen argument
- eq(he('xxxx ' * 20, maxlinelen=40), """\
-=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
- =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
- =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?=
- =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?=
- =?iso-8859-1?q?x_xxxx_xxxx_?=""")
- # Test the eol argument
- eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=\r
- =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=\r
- =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?=\r
- =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?=\r
- =?iso-8859-1?q?x_xxxx_xxxx_?=""")
+ def _test_header_encode(self, header, expected_encoded_header, charset=None):
+ if charset is None:
+ encoded_header = quoprimime.header_encode(header)
+ else:
+ encoded_header = quoprimime.header_encode(header, charset)
+ self.assertEqual(encoded_header, expected_encoded_header)
- def test_decode(self):
- eq = self.assertEqual
- eq(quopriMIME.decode(''), '')
- eq(quopriMIME.decode('hello'), 'hello')
- eq(quopriMIME.decode('hello', 'X'), 'hello')
- eq(quopriMIME.decode('hello\nworld', 'X'), 'helloXworld')
+ def test_header_encode_null(self):
+ self._test_header_encode(b'', '')
+
+ def test_header_encode_one_word(self):
+ self._test_header_encode(b'hello', '=?iso-8859-1?q?hello?=')
+
+ def test_header_encode_two_lines(self):
+ self._test_header_encode(b'hello\nworld',
+ '=?iso-8859-1?q?hello=0Aworld?=')
+
+ def test_header_encode_non_ascii(self):
+ self._test_header_encode(b'hello\xc7there',
+ '=?iso-8859-1?q?hello=C7there?=')
+
+ def test_header_encode_alt_charset(self):
+ self._test_header_encode(b'hello', '=?iso-8859-2?q?hello?=',
+ charset='iso-8859-2')
+
+ def _test_header_decode(self, encoded_header, expected_decoded_header):
+ decoded_header = quoprimime.header_decode(encoded_header)
+ self.assertEqual(decoded_header, expected_decoded_header)
+
+ def test_header_decode_null(self):
+ self._test_header_decode('', '')
+
+ def test_header_decode_one_word(self):
+ self._test_header_decode('hello', 'hello')
+
+ def test_header_decode_two_lines(self):
+ self._test_header_decode('hello=0Aworld', 'hello\nworld')
+
+ def test_header_decode_non_ascii(self):
+ self._test_header_decode('hello=C7there', 'hello\xc7there')
+
+ def _test_decode(self, encoded, expected_decoded, eol=None):
+ if eol is None:
+ decoded = quoprimime.decode(encoded)
+ else:
+ decoded = quoprimime.decode(encoded, eol=eol)
+ self.assertEqual(decoded, expected_decoded)
+
+ def test_decode_null_word(self):
+ self._test_decode('', '')
+
+ def test_decode_null_line_null_word(self):
+ self._test_decode('\r\n', '\n')
+
+ def test_decode_one_word(self):
+ self._test_decode('hello', 'hello')
+
+ def test_decode_one_word_eol(self):
+ self._test_decode('hello', 'hello', eol='X')
+
+ def test_decode_one_line(self):
+ self._test_decode('hello\r\n', 'hello\n')
+
+ def test_decode_one_line_lf(self):
+ self._test_decode('hello\n', 'hello\n')
+
+ def test_decode_one_line_cr(self):
+ self._test_decode('hello\r', 'hello\n')
+
+ def test_decode_one_line_nl(self):
+ self._test_decode('hello\n', 'helloX', eol='X')
+
+ def test_decode_one_line_crnl(self):
+ self._test_decode('hello\r\n', 'helloX', eol='X')
+
+ def test_decode_one_line_one_word(self):
+ self._test_decode('hello\r\nworld', 'hello\nworld')
+
+ def test_decode_one_line_one_word_eol(self):
+ self._test_decode('hello\r\nworld', 'helloXworld', eol='X')
+
+ def test_decode_two_lines(self):
+ self._test_decode('hello\r\nworld\r\n', 'hello\nworld\n')
+
+ def test_decode_two_lines_eol(self):
+ self._test_decode('hello\r\nworld\r\n', 'helloXworldX', eol='X')
+
+ def test_decode_one_long_line(self):
+ self._test_decode('Spam' * 250, 'Spam' * 250)
+
+ def test_decode_one_space(self):
+ self._test_decode(' ', '')
+
+ def test_decode_multiple_spaces(self):
+ self._test_decode(' ' * 5, '')
+
+ def test_decode_one_line_trailing_spaces(self):
+ self._test_decode('hello \r\n', 'hello\n')
+
+ def test_decode_two_lines_trailing_spaces(self):
+ self._test_decode('hello \r\nworld \r\n', 'hello\nworld\n')
+
+ def test_decode_quoted_word(self):
+ self._test_decode('=22quoted=20words=22', '"quoted words"')
+
+ def test_decode_uppercase_quoting(self):
+ self._test_decode('ab=CD=EF', 'ab\xcd\xef')
+
+ def test_decode_lowercase_quoting(self):
+ self._test_decode('ab=cd=ef', 'ab\xcd\xef')
+
+ def test_decode_soft_line_break(self):
+ self._test_decode('soft line=\r\nbreak', 'soft linebreak')
+
+ def test_decode_false_quoting(self):
+ self._test_decode('A=1,B=A ==> A+B==2', 'A=1,B=A ==> A+B==2')
+
+ def _test_encode(self, body, expected_encoded_body, maxlinelen=None, eol=None):
+ kwargs = {}
+ if maxlinelen is None:
+ # Use body_encode's default.
+ maxlinelen = 76
+ else:
+ kwargs['maxlinelen'] = maxlinelen
+ if eol is None:
+ # Use body_encode's default.
+ eol = '\n'
+ else:
+ kwargs['eol'] = eol
+ encoded_body = quoprimime.body_encode(body, **kwargs)
+ self.assertEqual(encoded_body, expected_encoded_body)
+ if eol == '\n' or eol == '\r\n':
+ # We know how to split the result back into lines, so maxlinelen
+ # can be checked.
+ for line in encoded_body.splitlines():
+ self.assertLessEqual(len(line), maxlinelen)
+
+ def test_encode_null(self):
+ self._test_encode('', '')
+
+ def test_encode_null_lines(self):
+ self._test_encode('\n\n', '\n\n')
+
+ def test_encode_one_line(self):
+ self._test_encode('hello\n', 'hello\n')
+
+ def test_encode_one_line_crlf(self):
+ self._test_encode('hello\r\n', 'hello\n')
+
+ def test_encode_one_line_eol(self):
+ self._test_encode('hello\n', 'hello\r\n', eol='\r\n')
+
+ def test_encode_one_space(self):
+ self._test_encode(' ', '=20')
+
+ def test_encode_one_line_one_space(self):
+ self._test_encode(' \n', '=20\n')
+
+# XXX: body_encode() expect strings, but uses ord(char) from these strings
+# to index into a 256-entry list. For code points above 255, this will fail.
+# Should there be a check for 8-bit only ord() values in body, or at least
+# a comment about the expected input?
+
+ def test_encode_two_lines_one_space(self):
+ self._test_encode(' \n \n', '=20\n=20\n')
+
+ def test_encode_one_word_trailing_spaces(self):
+ self._test_encode('hello ', 'hello =20')
+
+ def test_encode_one_line_trailing_spaces(self):
+ self._test_encode('hello \n', 'hello =20\n')
+
+ def test_encode_one_word_trailing_tab(self):
+ self._test_encode('hello \t', 'hello =09')
+
+ def test_encode_one_line_trailing_tab(self):
+ self._test_encode('hello \t\n', 'hello =09\n')
+
+ def test_encode_trailing_space_before_maxlinelen(self):
+ self._test_encode('abcd \n1234', 'abcd =\n\n1234', maxlinelen=6)
+
+ def test_encode_trailing_space_at_maxlinelen(self):
+ self._test_encode('abcd \n1234', 'abcd=\n=20\n1234', maxlinelen=5)
+
+ def test_encode_trailing_space_beyond_maxlinelen(self):
+ self._test_encode('abcd \n1234', 'abc=\nd=20\n1234', maxlinelen=4)
+
+ def test_encode_whitespace_lines(self):
+ self._test_encode(' \n' * 5, '=20\n' * 5)
+
+ def test_encode_quoted_equals(self):
+ self._test_encode('a = b', 'a =3D b')
+
+ def test_encode_one_long_string(self):
+ self._test_encode('x' * 100, 'x' * 75 + '=\n' + 'x' * 25)
+
+ def test_encode_one_long_line(self):
+ self._test_encode('x' * 100 + '\n', 'x' * 75 + '=\n' + 'x' * 25 + '\n')
+
+ def test_encode_one_very_long_line(self):
+ self._test_encode('x' * 200 + '\n',
+ 2 * ('x' * 75 + '=\n') + 'x' * 50 + '\n')
+
+ def test_encode_one_long_line(self):
+ self._test_encode('x' * 100 + '\n', 'x' * 75 + '=\n' + 'x' * 25 + '\n')
+
+ def test_encode_shortest_maxlinelen(self):
+ self._test_encode('=' * 5, '=3D=\n' * 4 + '=3D', maxlinelen=4)
+
+ def test_encode_maxlinelen_too_small(self):
+ self.assertRaises(ValueError, self._test_encode, '', '', maxlinelen=3)
def test_encode(self):
eq = self.assertEqual
- eq(quopriMIME.encode(''), '')
- eq(quopriMIME.encode('hello'), 'hello')
+ eq(quoprimime.body_encode(''), '')
+ eq(quoprimime.body_encode('hello'), 'hello')
# Test the binary flag
- eq(quopriMIME.encode('hello\r\nworld'), 'hello\nworld')
- eq(quopriMIME.encode('hello\r\nworld', 0), 'hello\nworld')
+ eq(quoprimime.body_encode('hello\r\nworld'), 'hello\nworld')
# Test the maxlinelen arg
- eq(quopriMIME.encode('xxxx ' * 20, maxlinelen=40), """\
+ eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40), """\
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
x xxxx xxxx xxxx xxxx=20""")
# Test the eol argument
- eq(quopriMIME.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
+ eq(quoprimime.body_encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'),
+ """\
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=\r
xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=\r
x xxxx xxxx xxxx xxxx=20""")
- eq(quopriMIME.encode("""\
+ eq(quoprimime.body_encode("""\
one line
two line"""), """\
@@ -2945,23 +3914,22 @@ two line""")
# Test the Charset class
class TestCharset(unittest.TestCase):
def tearDown(self):
- from email import Charset as CharsetModule
+ from email import charset as CharsetModule
try:
del CharsetModule.CHARSETS['fake']
except KeyError:
pass
- def test_idempotent(self):
+ def test_codec_encodeable(self):
eq = self.assertEqual
# Make sure us-ascii = no Unicode conversion
c = Charset('us-ascii')
- s = 'Hello World!'
- sp = c.to_splittable(s)
- eq(s, c.from_splittable(sp))
- # test 8-bit idempotency with us-ascii
+ eq(c.header_encode('Hello World!'), 'Hello World!')
+ # Test 8-bit idempotency with us-ascii
s = '\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa'
- sp = c.to_splittable(s)
- eq(s, c.from_splittable(sp))
+ self.assertRaises(UnicodeError, c.header_encode, s)
+ c = Charset('utf-8')
+ eq(c.header_encode(s), '=?utf-8?b?wqTCosKkwqTCpMKmwqTCqMKkwqo=?=')
def test_body_encode(self):
eq = self.assertEqual
@@ -2970,37 +3938,35 @@ class TestCharset(unittest.TestCase):
eq('hello w=F6rld', c.body_encode('hello w\xf6rld'))
# Try a charset with Base64 body encoding
c = Charset('utf-8')
- eq('aGVsbG8gd29ybGQ=\n', c.body_encode('hello world'))
+ eq('aGVsbG8gd29ybGQ=\n', c.body_encode(b'hello world'))
# Try a charset with None body encoding
c = Charset('us-ascii')
eq('hello world', c.body_encode('hello world'))
# Try the convert argument, where input codec != output codec
c = Charset('euc-jp')
# With apologies to Tokio Kikuchi ;)
- try:
- eq('\x1b$B5FCO;~IW\x1b(B',
- c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
- eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7',
- c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
- except LookupError:
- # We probably don't have the Japanese codecs installed
- pass
+ # XXX FIXME
+## try:
+## eq('\x1b$B5FCO;~IW\x1b(B',
+## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
+## eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7',
+## c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
+## except LookupError:
+## # We probably don't have the Japanese codecs installed
+## pass
# Testing SF bug #625509, which we have to fake, since there are no
# built-in encodings where the header encoding is QP but the body
# encoding is not.
- from email import Charset as CharsetModule
- CharsetModule.add_charset('fake', CharsetModule.QP, None)
+ from email import charset as CharsetModule
+ CharsetModule.add_charset('fake', CharsetModule.QP, None, 'utf-8')
c = Charset('fake')
- eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))
+ eq('hello world', c.body_encode('hello world'))
def test_unicode_charset_name(self):
- charset = Charset(u'us-ascii')
+ charset = Charset('us-ascii')
self.assertEqual(str(charset), 'us-ascii')
- self.assertRaises(Errors.CharsetError, Charset, 'asc\xffii')
+ self.assertRaises(errors.CharsetError, Charset, 'asc\xffii')
- def test_codecs_aliases_accepted(self):
- charset = Charset('utf8')
- self.assertEqual(str(charset), 'utf-8')
# Test multilingual MIME headers.
@@ -3034,70 +4000,216 @@ class TestHeader(TestEmailBase):
g = Charset("iso-8859-1")
cz = Charset("iso-8859-2")
utf8 = Charset("utf-8")
- g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
- cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. "
- utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8")
+ g_head = (b'Die Mieter treten hier ein werden mit einem '
+ b'Foerderband komfortabel den Korridor entlang, '
+ b'an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, '
+ b'gegen die rotierenden Klingen bef\xf6rdert. ')
+ cz_head = (b'Finan\xe8ni metropole se hroutily pod tlakem jejich '
+ b'd\xf9vtipu.. ')
+ utf8_head = ('\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
+ '\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00'
+ '\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
+ '\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
+ '\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das '
+ 'Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder '
+ 'die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066'
+ '\u3044\u307e\u3059\u3002')
h = Header(g_head, g)
h.append(cz_head, cz)
h.append(utf8_head, utf8)
- enc = h.encode()
+ enc = h.encode(maxlinelen=76)
eq(enc, """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_ko?=
- =?iso-8859-1?q?mfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wan?=
- =?iso-8859-1?q?dgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6?=
- =?iso-8859-1?q?rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
+=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_kom?=
+ =?iso-8859-1?q?fortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wand?=
+ =?iso-8859-1?q?gem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6r?=
+ =?iso-8859-1?q?dert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
=?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
=?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?=
=?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?=
=?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?=
- =?utf-8?q?_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das_Oder_die_Fl?=
- =?utf-8?b?aXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBo+OBpuOBhOOBvuOBmQ==?=
- =?utf-8?b?44CC?=""")
- eq(decode_header(enc),
- [(g_head, "iso-8859-1"), (cz_head, "iso-8859-2"),
- (utf8_head, "utf-8")])
- ustr = unicode(h)
- eq(ustr.encode('utf-8'),
- 'Die Mieter treten hier ein werden mit einem Foerderband '
- 'komfortabel den Korridor entlang, an s\xc3\xbcdl\xc3\xbcndischen '
- 'Wandgem\xc3\xa4lden vorbei, gegen die rotierenden Klingen '
- 'bef\xc3\xb6rdert. Finan\xc4\x8dni metropole se hroutily pod '
- 'tlakem jejich d\xc5\xafvtipu.. \xe6\xad\xa3\xe7\xa2\xba\xe3\x81'
- '\xab\xe8\xa8\x80\xe3\x81\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3'
- '\xe3\x81\xaf\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3'
- '\x81\xbe\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83'
- '\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8\xaa\x9e'
- '\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81\xe3\x81\x82\xe3'
- '\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81\x9f\xe3\x82\x89\xe3\x82'
- '\x81\xe3\x81\xa7\xe3\x81\x99\xe3\x80\x82\xe5\xae\x9f\xe9\x9a\x9b'
- '\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x8cWenn ist das Nunstuck git '
- 'und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt '
- 'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81'
- '\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82')
+ =?utf-8?b?IE51bnN0dWNrIGdpdCB1bmQgU2xvdGVybWV5ZXI/IEphISBCZWloZXJodW5k?=
+ =?utf-8?b?IGRhcyBPZGVyIGRpZSBGbGlwcGVyd2FsZHQgZ2Vyc3B1dC7jgI3jgajoqIA=?=
+ =?utf-8?b?44Gj44Gm44GE44G+44GZ44CC?=""")
+ decoded = decode_header(enc)
+ eq(len(decoded), 3)
+ eq(decoded[0], (g_head, 'iso-8859-1'))
+ eq(decoded[1], (cz_head, 'iso-8859-2'))
+ eq(decoded[2], (utf8_head.encode('utf-8'), 'utf-8'))
+ ustr = str(h)
+ eq(ustr,
+ (b'Die Mieter treten hier ein werden mit einem Foerderband '
+ b'komfortabel den Korridor entlang, an s\xc3\xbcdl\xc3\xbcndischen '
+ b'Wandgem\xc3\xa4lden vorbei, gegen die rotierenden Klingen '
+ b'bef\xc3\xb6rdert. Finan\xc4\x8dni metropole se hroutily pod '
+ b'tlakem jejich d\xc5\xafvtipu.. \xe6\xad\xa3\xe7\xa2\xba\xe3\x81'
+ b'\xab\xe8\xa8\x80\xe3\x81\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3'
+ b'\xe3\x81\xaf\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3'
+ b'\x81\xbe\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83'
+ b'\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8\xaa\x9e'
+ b'\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81\xe3\x81\x82\xe3'
+ b'\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81\x9f\xe3\x82\x89\xe3\x82'
+ b'\x81\xe3\x81\xa7\xe3\x81\x99\xe3\x80\x82\xe5\xae\x9f\xe9\x9a\x9b'
+ b'\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x8cWenn ist das Nunstuck git '
+ b'und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt '
+ b'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81'
+ b'\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82'
+ ).decode('utf-8'))
# Test make_header()
newh = make_header(decode_header(enc))
- eq(newh, enc)
+ eq(newh, h)
+
+ def test_empty_header_encode(self):
+ h = Header()
+ self.assertEqual(h.encode(), '')
def test_header_ctor_default_args(self):
eq = self.ndiffAssertEqual
h = Header()
eq(h, '')
h.append('foo', Charset('iso-8859-1'))
- eq(h, '=?iso-8859-1?q?foo?=')
+ eq(h, 'foo')
def test_explicit_maxlinelen(self):
eq = self.ndiffAssertEqual
- hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior'
+ hstr = ('A very long line that must get split to something other '
+ 'than at the 76th character boundary to test the non-default '
+ 'behavior')
h = Header(hstr)
eq(h.encode(), '''\
A very long line that must get split to something other than at the 76th
character boundary to test the non-default behavior''')
+ eq(str(h), hstr)
h = Header(hstr, header_name='Subject')
eq(h.encode(), '''\
A very long line that must get split to something other than at the
76th character boundary to test the non-default behavior''')
+ eq(str(h), hstr)
h = Header(hstr, maxlinelen=1024, header_name='Subject')
eq(h.encode(), hstr)
+ eq(str(h), hstr)
+
+ def test_quopri_splittable(self):
+ eq = self.ndiffAssertEqual
+ h = Header(charset='iso-8859-1', maxlinelen=20)
+ x = 'xxxx ' * 20
+ h.append(x)
+ s = h.encode()
+ eq(s, """\
+=?iso-8859-1?q?xxx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_x?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?x_?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?xx?=
+ =?iso-8859-1?q?_?=""")
+ eq(x, str(make_header(decode_header(s))))
+ h = Header(charset='iso-8859-1', maxlinelen=40)
+ h.append('xxxx ' * 20)
+ s = h.encode()
+ eq(s, """\
+=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xxx?=
+ =?iso-8859-1?q?x_xxxx_xxxx_xxxx_xxxx_?=
+ =?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
+ =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
+ =?iso-8859-1?q?_xxxx_xxxx_?=""")
+ eq(x, str(make_header(decode_header(s))))
+
+ def test_base64_splittable(self):
+ eq = self.ndiffAssertEqual
+ h = Header(charset='koi8-r', maxlinelen=20)
+ x = 'xxxx ' * 20
+ h.append(x)
+ s = h.encode()
+ eq(s, """\
+=?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IHh4?=
+ =?koi8-r?b?eHgg?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?eCB4?=
+ =?koi8-r?b?eHh4?=
+ =?koi8-r?b?IA==?=""")
+ eq(x, str(make_header(decode_header(s))))
+ h = Header(charset='koi8-r', maxlinelen=40)
+ h.append(x)
+ s = h.encode()
+ eq(s, """\
+=?koi8-r?b?eHh4eCB4eHh4IHh4eHggeHh4?=
+ =?koi8-r?b?eCB4eHh4IHh4eHggeHh4eCB4?=
+ =?koi8-r?b?eHh4IHh4eHggeHh4eCB4eHh4?=
+ =?koi8-r?b?IHh4eHggeHh4eCB4eHh4IHh4?=
+ =?koi8-r?b?eHggeHh4eCB4eHh4IHh4eHgg?=
+ =?koi8-r?b?eHh4eCB4eHh4IA==?=""")
+ eq(x, str(make_header(decode_header(s))))
def test_us_ascii_header(self):
eq = self.assertEqual
@@ -3111,7 +4223,7 @@ A very long line that must get split to something other than at the
eq = self.assertEqual
h = Header()
h.append('hello', 'iso-8859-1')
- eq(h, '=?iso-8859-1?q?hello?=')
+ eq(h, 'hello')
## def test_unicode_error(self):
## raises = self.assertRaises
@@ -3124,21 +4236,51 @@ A very long line that must get split to something other than at the
def test_utf8_shortest(self):
eq = self.assertEqual
- h = Header(u'p\xf6stal', 'utf-8')
+ h = Header('p\xf6stal', 'utf-8')
eq(h.encode(), '=?utf-8?q?p=C3=B6stal?=')
- h = Header(u'\u83ca\u5730\u6642\u592b', 'utf-8')
+ h = Header('\u83ca\u5730\u6642\u592b', 'utf-8')
eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=')
def test_bad_8bit_header(self):
raises = self.assertRaises
eq = self.assertEqual
- x = 'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
+ x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
raises(UnicodeError, Header, x)
h = Header()
raises(UnicodeError, h.append, x)
- eq(str(Header(x, errors='replace')), x)
+ e = x.decode('utf-8', 'replace')
+ eq(str(Header(x, errors='replace')), e)
h.append(x, errors='replace')
- eq(str(h), x)
+ eq(str(h), e)
+
+ def test_escaped_8bit_header(self):
+ x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
+ e = x.decode('ascii', 'surrogateescape')
+ h = Header(e, charset=email.charset.UNKNOWN8BIT)
+ self.assertEqual(str(h),
+ 'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
+ self.assertEqual(email.header.decode_header(h), [(x, 'unknown-8bit')])
+
+ def test_header_handles_binary_unknown8bit(self):
+ x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
+ h = Header(x, charset=email.charset.UNKNOWN8BIT)
+ self.assertEqual(str(h),
+ 'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
+ self.assertEqual(email.header.decode_header(h), [(x, 'unknown-8bit')])
+
+ def test_make_header_handles_binary_unknown8bit(self):
+ x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
+ h = Header(x, charset=email.charset.UNKNOWN8BIT)
+ h2 = email.header.make_header(email.header.decode_header(h))
+ self.assertEqual(str(h2),
+ 'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big')
+ self.assertEqual(email.header.decode_header(h2), [(x, 'unknown-8bit')])
+
+ def test_modify_returned_list_does_not_change_header(self):
+ h = Header('test')
+ chunks = email.header.decode_header(h)
+ chunks.append(('ascii', 'test2'))
+ self.assertEqual(str(h), 'test')
def test_encoded_adjacent_nonencoded(self):
eq = self.assertEqual
@@ -3154,7 +4296,7 @@ A very long line that must get split to something other than at the
eq = self.assertEqual
s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.'
parts = decode_header(s)
- eq(parts, [('Subject:', None), ('\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), ('zz.', None)])
+ eq(parts, [(b'Subject:', None), (b'\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), (b'zz.', None)])
hdr = make_header(parts)
eq(hdr.encode(),
'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.')
@@ -3162,30 +4304,24 @@ A very long line that must get split to something other than at the
def test_broken_base64_header(self):
raises = self.assertRaises
s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
- raises(Errors.HeaderParseError, decode_header, s)
+ raises(errors.HeaderParseError, decode_header, s)
- # Issue 1078919
- def test_ascii_add_header(self):
- msg = Message()
- msg.add_header('Content-Disposition', 'attachment',
- filename='bud.gif')
- self.assertEqual('attachment; filename="bud.gif"',
- msg['Content-Disposition'])
+ def test_shift_jis_charset(self):
+ h = Header('æ–‡', charset='shift_jis')
+ self.assertEqual(h.encode(), '=?iso-2022-jp?b?GyRCSjgbKEI=?=')
- def test_nonascii_add_header_via_triple(self):
+ def test_flatten_header_with_no_value(self):
+ # Issue 11401 (regression from email 4.x) Note that the space after
+ # the header doesn't reflect the input, but this is also the way
+ # email 4.x behaved. At some point it would be nice to fix that.
+ msg = email.message_from_string("EmptyHeader:")
+ self.assertEqual(str(msg), "EmptyHeader: \n\n")
+
+ def test_encode_preserves_leading_ws_on_value(self):
msg = Message()
- msg.add_header('Content-Disposition', 'attachment',
- filename=('iso-8859-1', '', 'Fu\xdfballer.ppt'))
- self.assertEqual(
- 'attachment; filename*="iso-8859-1\'\'Fu%DFballer.ppt"',
- msg['Content-Disposition'])
+ msg['SomeHeader'] = ' value with leading ws'
+ self.assertEqual(str(msg), "SomeHeader: value with leading ws\n\n")
- def test_encode_unaliased_charset(self):
- # Issue 1379416: when the charset has no output conversion,
- # output was accidentally getting coerced to unicode.
- res = Header('abc','iso-8859-2').encode()
- self.assertEqual(res, '=?iso-8859-2?q?abc?=')
- self.assertIsInstance(res, str)
# Test RFC 2231 header parameters (en/de)coding
@@ -3199,7 +4335,7 @@ class TestRFC2231(TestEmailBase):
('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"'))
def test_set_param(self):
- eq = self.assertEqual
+ eq = self.ndiffAssertEqual
msg = Message()
msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
charset='us-ascii')
@@ -3212,11 +4348,11 @@ class TestRFC2231(TestEmailBase):
msg = self._msgobj('msg_01.txt')
msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
charset='us-ascii', language='en')
- self.ndiffAssertEqual(msg.as_string(), """\
+ eq(msg.as_string(maxheaderlen=78), """\
Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
- id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
+\tid 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
@@ -3225,7 +4361,7 @@ To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset=us-ascii;
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
Hi,
@@ -3235,6 +4371,16 @@ Do you like this message?
-Me
""")
+ def test_set_param_requote(self):
+ msg = Message()
+ msg.set_param('title', 'foo')
+ self.assertEqual(msg['content-type'], 'text/plain; title="foo"')
+ msg.set_param('title', 'bar', requote=False)
+ self.assertEqual(msg['content-type'], 'text/plain; title=bar')
+ # tspecial is still quoted.
+ msg.set_param('title', "(bar)bell", requote=False)
+ self.assertEqual(msg['content-type'], 'text/plain; title="(bar)bell"')
+
def test_del_param(self):
eq = self.ndiffAssertEqual
msg = self._msgobj('msg_01.txt')
@@ -3242,11 +4388,11 @@ Do you like this message?
msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
charset='us-ascii', language='en')
msg.del_param('foo', header='Content-Type')
- eq(msg.as_string(), """\
+ eq(msg.as_string(maxheaderlen=78), """\
Return-Path: <bbb@zzz.org>
Delivered-To: bbb@zzz.org
Received: by mail.zzz.org (Postfix, from userid 889)
- id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
+\tid 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
@@ -3255,7 +4401,7 @@ To: bbb@zzz.org
Subject: This is a test message
Date: Fri, 4 May 2001 14:05:44 -0400
Content-Type: text/plain; charset="us-ascii";
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
+ title*=us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21
Hi,
@@ -3270,6 +4416,32 @@ Do you like this message?
msg = self._msgobj('msg_32.txt')
eq(msg.get_content_charset(), 'us-ascii')
+ def test_rfc2231_parse_rfc_quoting(self):
+ m = textwrap.dedent('''\
+ Content-Disposition: inline;
+ \tfilename*0*=''This%20is%20even%20more%20;
+ \tfilename*1*=%2A%2A%2Afun%2A%2A%2A%20;
+ \tfilename*2="is it not.pdf"
+
+ ''')
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_filename(),
+ 'This is even more ***fun*** is it not.pdf')
+ self.assertEqual(m, msg.as_string())
+
+ def test_rfc2231_parse_extra_quoting(self):
+ m = textwrap.dedent('''\
+ Content-Disposition: inline;
+ \tfilename*0*="''This%20is%20even%20more%20";
+ \tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+ \tfilename*2="is it not.pdf"
+
+ ''')
+ msg = email.message_from_string(m)
+ self.assertEqual(msg.get_filename(),
+ 'This is even more ***fun*** is it not.pdf')
+ self.assertEqual(m, msg.as_string())
+
def test_rfc2231_no_language_or_charset(self):
m = '''\
Content-Transfer-Encoding: 8bit
@@ -3401,7 +4573,7 @@ Content-Disposition: inline;
'''
msg = email.message_from_string(m)
self.assertEqual(msg.get_filename(),
- u'This is even more ***fun*** is it not.pdf\ufffd')
+ 'This is even more ***fun*** is it not.pdf\ufffd')
def test_rfc2231_unknown_encoding(self):
m = """\
@@ -3506,12 +4678,9 @@ Content-Type: application/x-foo;
class TestSigned(TestEmailBase):
def _msg_and_obj(self, filename):
- fp = openfile(findfile(filename))
- try:
+ with openfile(findfile(filename)) as fp:
original = fp.read()
msg = email.message_from_string(original)
- finally:
- fp.close()
return original, msg
def _signed_parts_eq(self, original, result):
@@ -3527,6 +4696,11 @@ class TestSigned(TestEmailBase):
result = msg.as_string()
self._signed_parts_eq(original, result)
+ def test_long_headers_as_string_maxheaderlen(self):
+ original, msg = self._msg_and_obj('msg_45.txt')
+ result = msg.as_string(maxheaderlen=60)
+ self._signed_parts_eq(original, result)
+
def test_long_headers_flatten(self):
original, msg = self._msg_and_obj('msg_45.txt')
fp = StringIO()
diff --git a/Lib/email/test/test_email_codecs.py b/Lib/email/test/test_email_codecs.py
index 532750a6dc3..ca85f5731e0 100644
--- a/Lib/email/test/test_email_codecs.py
+++ b/Lib/email/test/test_email_codecs.py
@@ -3,7 +3,7 @@
# email package unit tests for (optional) Asian codecs
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
from email.test.test_email import TestEmailBase
from email.charset import Charset
@@ -13,7 +13,7 @@ from email.message import Message
# We're compatible with Python 2.3, but it doesn't have the built-in Asian
# codecs, so we have to skip all these tests.
try:
- unicode('foo', 'euc-jp')
+ str(b'foo', 'euc-jp')
except LookupError:
raise unittest.SkipTest
@@ -22,11 +22,14 @@ except LookupError:
class TestEmailAsianCodecs(TestEmailBase):
def test_japanese_codecs(self):
eq = self.ndiffAssertEqual
- j = Charset("euc-jp")
- g = Charset("iso-8859-1")
+ jcode = "euc-jp"
+ gcode = "iso-8859-1"
+ j = Charset(jcode)
+ g = Charset(gcode)
h = Header("Hello World!")
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
- ghello = 'Gr\xfc\xdf Gott!'
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
+ ghello = str(b'Gr\xfc\xdf Gott!', gcode)
h.append(jhello, j)
h.append(ghello, g)
# BAW: This used to -- and maybe should -- fold the two iso-8859-1
@@ -36,13 +39,17 @@ class TestEmailAsianCodecs(TestEmailBase):
# encoded word.
eq(h.encode(), """\
Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=
- =?iso-8859-1?q?Gr=FC=DF?= =?iso-8859-1?q?_Gott!?=""")
+ =?iso-8859-1?q?Gr=FC=DF_Gott!?=""")
eq(decode_header(h.encode()),
- [('Hello World!', None),
- ('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
- ('Gr\xfc\xdf Gott!', 'iso-8859-1')])
- long = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
- h = Header(long, j, header_name="Subject")
+ [(b'Hello World!', None),
+ (b'\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
+ (b'Gr\xfc\xdf Gott!', gcode)])
+ subject_bytes = (b'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5'
+ b'\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2'
+ b'\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3'
+ b'\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9')
+ subject = str(subject_bytes, jcode)
+ h = Header(subject, j, header_name="Subject")
# test a very long header
enc = h.encode()
# TK: splitting point may differ by codec design and/or Header encoding
@@ -50,15 +57,24 @@ Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=
=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
=?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""")
# TK: full decode comparison
- eq(h.__unicode__().encode('euc-jp'), long)
+ eq(str(h).encode(jcode), subject_bytes)
+
+ def test_payload_encoding_utf8(self):
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', 'euc-jp')
+ msg = Message()
+ msg.set_payload(jhello, 'utf-8')
+ ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
+ self.assertEqual(jhello, ustr)
def test_payload_encoding(self):
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
jcode = 'euc-jp'
+ jhello = str(b'\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc'
+ b'\xa5\xeb\xa5\xc9\xa1\xaa', jcode)
msg = Message()
msg.set_payload(jhello, jcode)
- ustr = unicode(msg.get_payload(), msg.get_content_charset())
- self.assertEqual(jhello, ustr.encode(jcode))
+ ustr = msg.get_payload(decode=True).decode(msg.get_content_charset())
+ self.assertEqual(jhello, ustr)
diff --git a/Lib/email/test/test_email_codecs_renamed.py b/Lib/email/test/test_email_codecs_renamed.py
deleted file mode 100644
index 532750a6dc3..00000000000
--- a/Lib/email/test/test_email_codecs_renamed.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright (C) 2002-2006 Python Software Foundation
-# Contact: email-sig@python.org
-# email package unit tests for (optional) Asian codecs
-
-import unittest
-from test.test_support import run_unittest
-
-from email.test.test_email import TestEmailBase
-from email.charset import Charset
-from email.header import Header, decode_header
-from email.message import Message
-
-# We're compatible with Python 2.3, but it doesn't have the built-in Asian
-# codecs, so we have to skip all these tests.
-try:
- unicode('foo', 'euc-jp')
-except LookupError:
- raise unittest.SkipTest
-
-
-
-class TestEmailAsianCodecs(TestEmailBase):
- def test_japanese_codecs(self):
- eq = self.ndiffAssertEqual
- j = Charset("euc-jp")
- g = Charset("iso-8859-1")
- h = Header("Hello World!")
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
- ghello = 'Gr\xfc\xdf Gott!'
- h.append(jhello, j)
- h.append(ghello, g)
- # BAW: This used to -- and maybe should -- fold the two iso-8859-1
- # chunks into a single encoded word. However it doesn't violate the
- # standard to have them as two encoded chunks and maybe it's
- # reasonable <wink> for each .append() call to result in a separate
- # encoded word.
- eq(h.encode(), """\
-Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=
- =?iso-8859-1?q?Gr=FC=DF?= =?iso-8859-1?q?_Gott!?=""")
- eq(decode_header(h.encode()),
- [('Hello World!', None),
- ('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'),
- ('Gr\xfc\xdf Gott!', 'iso-8859-1')])
- long = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9'
- h = Header(long, j, header_name="Subject")
- # test a very long header
- enc = h.encode()
- # TK: splitting point may differ by codec design and/or Header encoding
- eq(enc , """\
-=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?=
- =?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""")
- # TK: full decode comparison
- eq(h.__unicode__().encode('euc-jp'), long)
-
- def test_payload_encoding(self):
- jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa'
- jcode = 'euc-jp'
- msg = Message()
- msg.set_payload(jhello, jcode)
- ustr = unicode(msg.get_payload(), msg.get_content_charset())
- self.assertEqual(jhello, ustr.encode(jcode))
-
-
-
-def suite():
- suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestEmailAsianCodecs))
- return suite
-
-
-def test_main():
- run_unittest(TestEmailAsianCodecs)
-
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='suite')
diff --git a/Lib/email/test/test_email_renamed.py b/Lib/email/test/test_email_renamed.py
deleted file mode 100644
index 497b66b93eb..00000000000
--- a/Lib/email/test/test_email_renamed.py
+++ /dev/null
@@ -1,3297 +0,0 @@
-# Copyright (C) 2001-2007 Python Software Foundation
-# Contact: email-sig@python.org
-# email package unit tests
-
-import os
-import sys
-import time
-import base64
-import difflib
-import unittest
-import warnings
-from cStringIO import StringIO
-
-import email
-
-from email.charset import Charset
-from email.header import Header, decode_header, make_header
-from email.parser import Parser, HeaderParser
-from email.generator import Generator, DecodedGenerator
-from email.message import Message
-from email.mime.application import MIMEApplication
-from email.mime.audio import MIMEAudio
-from email.mime.text import MIMEText
-from email.mime.image import MIMEImage
-from email.mime.base import MIMEBase
-from email.mime.message import MIMEMessage
-from email.mime.multipart import MIMEMultipart
-from email import utils
-from email import errors
-from email import encoders
-from email import iterators
-from email import base64mime
-from email import quoprimime
-
-from test.test_support import findfile, run_unittest
-from email.test import __file__ as landmark
-
-
-NL = '\n'
-EMPTYSTRING = ''
-SPACE = ' '
-
-
-
-def openfile(filename, mode='r'):
- path = os.path.join(os.path.dirname(landmark), 'data', filename)
- return open(path, mode)
-
-
-
-# Base test class
-class TestEmailBase(unittest.TestCase):
- def ndiffAssertEqual(self, first, second):
- """Like assertEqual except use ndiff for readable output."""
- if first != second:
- sfirst = str(first)
- ssecond = str(second)
- diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines())
- fp = StringIO()
- print >> fp, NL, NL.join(diff)
- raise self.failureException, fp.getvalue()
-
- def _msgobj(self, filename):
- fp = openfile(findfile(filename))
- try:
- msg = email.message_from_file(fp)
- finally:
- fp.close()
- return msg
-
-
-
-# Test various aspects of the Message class's API
-class TestMessageAPI(TestEmailBase):
- def test_get_all(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_20.txt')
- eq(msg.get_all('cc'), ['ccc@zzz.org', 'ddd@zzz.org', 'eee@zzz.org'])
- eq(msg.get_all('xx', 'n/a'), 'n/a')
-
- def test_getset_charset(self):
- eq = self.assertEqual
- msg = Message()
- eq(msg.get_charset(), None)
- charset = Charset('iso-8859-1')
- msg.set_charset(charset)
- eq(msg['mime-version'], '1.0')
- eq(msg.get_content_type(), 'text/plain')
- eq(msg['content-type'], 'text/plain; charset="iso-8859-1"')
- eq(msg.get_param('charset'), 'iso-8859-1')
- eq(msg['content-transfer-encoding'], 'quoted-printable')
- eq(msg.get_charset().input_charset, 'iso-8859-1')
- # Remove the charset
- msg.set_charset(None)
- eq(msg.get_charset(), None)
- eq(msg['content-type'], 'text/plain')
- # Try adding a charset when there's already MIME headers present
- msg = Message()
- msg['MIME-Version'] = '2.0'
- msg['Content-Type'] = 'text/x-weird'
- msg['Content-Transfer-Encoding'] = 'quinted-puntable'
- msg.set_charset(charset)
- eq(msg['mime-version'], '2.0')
- eq(msg['content-type'], 'text/x-weird; charset="iso-8859-1"')
- eq(msg['content-transfer-encoding'], 'quinted-puntable')
-
- def test_set_charset_from_string(self):
- eq = self.assertEqual
- msg = Message()
- msg.set_charset('us-ascii')
- eq(msg.get_charset().input_charset, 'us-ascii')
- eq(msg['content-type'], 'text/plain; charset="us-ascii"')
-
- def test_set_payload_with_charset(self):
- msg = Message()
- charset = Charset('iso-8859-1')
- msg.set_payload('This is a string payload', charset)
- self.assertEqual(msg.get_charset().input_charset, 'iso-8859-1')
-
- def test_get_charsets(self):
- eq = self.assertEqual
-
- msg = self._msgobj('msg_08.txt')
- charsets = msg.get_charsets()
- eq(charsets, [None, 'us-ascii', 'iso-8859-1', 'iso-8859-2', 'koi8-r'])
-
- msg = self._msgobj('msg_09.txt')
- charsets = msg.get_charsets('dingbat')
- eq(charsets, ['dingbat', 'us-ascii', 'iso-8859-1', 'dingbat',
- 'koi8-r'])
-
- msg = self._msgobj('msg_12.txt')
- charsets = msg.get_charsets()
- eq(charsets, [None, 'us-ascii', 'iso-8859-1', None, 'iso-8859-2',
- 'iso-8859-3', 'us-ascii', 'koi8-r'])
-
- def test_get_filename(self):
- eq = self.assertEqual
-
- msg = self._msgobj('msg_04.txt')
- filenames = [p.get_filename() for p in msg.get_payload()]
- eq(filenames, ['msg.txt', 'msg.txt'])
-
- msg = self._msgobj('msg_07.txt')
- subpart = msg.get_payload(1)
- eq(subpart.get_filename(), 'dingusfish.gif')
-
- def test_get_filename_with_name_parameter(self):
- eq = self.assertEqual
-
- msg = self._msgobj('msg_44.txt')
- filenames = [p.get_filename() for p in msg.get_payload()]
- eq(filenames, ['msg.txt', 'msg.txt'])
-
- def test_get_boundary(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_07.txt')
- # No quotes!
- eq(msg.get_boundary(), 'BOUNDARY')
-
- def test_set_boundary(self):
- eq = self.assertEqual
- # This one has no existing boundary parameter, but the Content-Type:
- # header appears fifth.
- msg = self._msgobj('msg_01.txt')
- msg.set_boundary('BOUNDARY')
- header, value = msg.items()[4]
- eq(header.lower(), 'content-type')
- eq(value, 'text/plain; charset="us-ascii"; boundary="BOUNDARY"')
- # This one has a Content-Type: header, with a boundary, stuck in the
- # middle of its headers. Make sure the order is preserved; it should
- # be fifth.
- msg = self._msgobj('msg_04.txt')
- msg.set_boundary('BOUNDARY')
- header, value = msg.items()[4]
- eq(header.lower(), 'content-type')
- eq(value, 'multipart/mixed; boundary="BOUNDARY"')
- # And this one has no Content-Type: header at all.
- msg = self._msgobj('msg_03.txt')
- self.assertRaises(errors.HeaderParseError,
- msg.set_boundary, 'BOUNDARY')
-
- def test_get_decoded_payload(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_10.txt')
- # The outer message is a multipart
- eq(msg.get_payload(decode=True), None)
- # Subpart 1 is 7bit encoded
- eq(msg.get_payload(0).get_payload(decode=True),
- 'This is a 7bit encoded message.\n')
- # Subpart 2 is quopri
- eq(msg.get_payload(1).get_payload(decode=True),
- '\xa1This is a Quoted Printable encoded message!\n')
- # Subpart 3 is base64
- eq(msg.get_payload(2).get_payload(decode=True),
- 'This is a Base64 encoded message.')
- # Subpart 4 is base64 with a trailing newline, which
- # used to be stripped (issue 7143).
- eq(msg.get_payload(3).get_payload(decode=True),
- 'This is a Base64 encoded message.\n')
- # Subpart 5 has no Content-Transfer-Encoding: header.
- eq(msg.get_payload(4).get_payload(decode=True),
- 'This has no Content-Transfer-Encoding: header.\n')
-
- def test_get_decoded_uu_payload(self):
- eq = self.assertEqual
- msg = Message()
- msg.set_payload('begin 666 -\n+:&5L;&\\@=V]R;&0 \n \nend\n')
- for cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
- msg['content-transfer-encoding'] = cte
- eq(msg.get_payload(decode=True), 'hello world')
- # Now try some bogus data
- msg.set_payload('foo')
- eq(msg.get_payload(decode=True), 'foo')
-
- def test_decoded_generator(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_07.txt')
- fp = openfile('msg_17.txt')
- try:
- text = fp.read()
- finally:
- fp.close()
- s = StringIO()
- g = DecodedGenerator(s)
- g.flatten(msg)
- eq(s.getvalue(), text)
-
- def test__contains__(self):
- msg = Message()
- msg['From'] = 'Me'
- msg['to'] = 'You'
- # Check for case insensitivity
- self.assertTrue('from' in msg)
- self.assertTrue('From' in msg)
- self.assertTrue('FROM' in msg)
- self.assertTrue('to' in msg)
- self.assertTrue('To' in msg)
- self.assertTrue('TO' in msg)
-
- def test_as_string(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_01.txt')
- fp = openfile('msg_01.txt')
- try:
- # BAW 30-Mar-2009 Evil be here. So, the generator is broken with
- # respect to long line breaking. It's also not idempotent when a
- # header from a parsed message is continued with tabs rather than
- # spaces. Before we fixed bug 1974 it was reversedly broken,
- # i.e. headers that were continued with spaces got continued with
- # tabs. For Python 2.x there's really no good fix and in Python
- # 3.x all this stuff is re-written to be right(er). Chris Withers
- # convinced me that using space as the default continuation
- # character is less bad for more applications.
- text = fp.read().replace('\t', ' ')
- finally:
- fp.close()
- self.ndiffAssertEqual(text, msg.as_string())
- fullrepr = str(msg)
- lines = fullrepr.split('\n')
- self.assertTrue(lines[0].startswith('From '))
- eq(text, NL.join(lines[1:]))
-
- def test_bad_param(self):
- msg = email.message_from_string("Content-Type: blarg; baz; boo\n")
- self.assertEqual(msg.get_param('baz'), '')
-
- def test_missing_filename(self):
- msg = email.message_from_string("From: foo\n")
- self.assertEqual(msg.get_filename(), None)
-
- def test_bogus_filename(self):
- msg = email.message_from_string(
- "Content-Disposition: blarg; filename\n")
- self.assertEqual(msg.get_filename(), '')
-
- def test_missing_boundary(self):
- msg = email.message_from_string("From: foo\n")
- self.assertEqual(msg.get_boundary(), None)
-
- def test_get_params(self):
- eq = self.assertEqual
- msg = email.message_from_string(
- 'X-Header: foo=one; bar=two; baz=three\n')
- eq(msg.get_params(header='x-header'),
- [('foo', 'one'), ('bar', 'two'), ('baz', 'three')])
- msg = email.message_from_string(
- 'X-Header: foo; bar=one; baz=two\n')
- eq(msg.get_params(header='x-header'),
- [('foo', ''), ('bar', 'one'), ('baz', 'two')])
- eq(msg.get_params(), None)
- msg = email.message_from_string(
- 'X-Header: foo; bar="one"; baz=two\n')
- eq(msg.get_params(header='x-header'),
- [('foo', ''), ('bar', 'one'), ('baz', 'two')])
-
- def test_get_param_liberal(self):
- msg = Message()
- msg['Content-Type'] = 'Content-Type: Multipart/mixed; boundary = "CPIMSSMTPC06p5f3tG"'
- self.assertEqual(msg.get_param('boundary'), 'CPIMSSMTPC06p5f3tG')
-
- def test_get_param(self):
- eq = self.assertEqual
- msg = email.message_from_string(
- "X-Header: foo=one; bar=two; baz=three\n")
- eq(msg.get_param('bar', header='x-header'), 'two')
- eq(msg.get_param('quuz', header='x-header'), None)
- eq(msg.get_param('quuz'), None)
- msg = email.message_from_string(
- 'X-Header: foo; bar="one"; baz=two\n')
- eq(msg.get_param('foo', header='x-header'), '')
- eq(msg.get_param('bar', header='x-header'), 'one')
- eq(msg.get_param('baz', header='x-header'), 'two')
- # XXX: We are not RFC-2045 compliant! We cannot parse:
- # msg["Content-Type"] = 'text/plain; weird="hey; dolly? [you] @ <\\"home\\">?"'
- # msg.get_param("weird")
- # yet.
-
- def test_get_param_funky_continuation_lines(self):
- msg = self._msgobj('msg_22.txt')
- self.assertEqual(msg.get_payload(1).get_param('name'), 'wibble.JPG')
-
- def test_get_param_with_semis_in_quotes(self):
- msg = email.message_from_string(
- 'Content-Type: image/pjpeg; name="Jim&amp;&amp;Jill"\n')
- self.assertEqual(msg.get_param('name'), 'Jim&amp;&amp;Jill')
- self.assertEqual(msg.get_param('name', unquote=False),
- '"Jim&amp;&amp;Jill"')
-
- def test_has_key(self):
- msg = email.message_from_string('Header: exists')
- self.assertTrue(msg.has_key('header'))
- self.assertTrue(msg.has_key('Header'))
- self.assertTrue(msg.has_key('HEADER'))
- self.assertFalse(msg.has_key('headeri'))
-
- def test_set_param(self):
- eq = self.assertEqual
- msg = Message()
- msg.set_param('charset', 'iso-2022-jp')
- eq(msg.get_param('charset'), 'iso-2022-jp')
- msg.set_param('importance', 'high value')
- eq(msg.get_param('importance'), 'high value')
- eq(msg.get_param('importance', unquote=False), '"high value"')
- eq(msg.get_params(), [('text/plain', ''),
- ('charset', 'iso-2022-jp'),
- ('importance', 'high value')])
- eq(msg.get_params(unquote=False), [('text/plain', ''),
- ('charset', '"iso-2022-jp"'),
- ('importance', '"high value"')])
- msg.set_param('charset', 'iso-9999-xx', header='X-Jimmy')
- eq(msg.get_param('charset', header='X-Jimmy'), 'iso-9999-xx')
-
- def test_del_param(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_05.txt')
- eq(msg.get_params(),
- [('multipart/report', ''), ('report-type', 'delivery-status'),
- ('boundary', 'D1690A7AC1.996856090/mail.example.com')])
- old_val = msg.get_param("report-type")
- msg.del_param("report-type")
- eq(msg.get_params(),
- [('multipart/report', ''),
- ('boundary', 'D1690A7AC1.996856090/mail.example.com')])
- msg.set_param("report-type", old_val)
- eq(msg.get_params(),
- [('multipart/report', ''),
- ('boundary', 'D1690A7AC1.996856090/mail.example.com'),
- ('report-type', old_val)])
-
- def test_del_param_on_other_header(self):
- msg = Message()
- msg.add_header('Content-Disposition', 'attachment', filename='bud.gif')
- msg.del_param('filename', 'content-disposition')
- self.assertEqual(msg['content-disposition'], 'attachment')
-
- def test_set_type(self):
- eq = self.assertEqual
- msg = Message()
- self.assertRaises(ValueError, msg.set_type, 'text')
- msg.set_type('text/plain')
- eq(msg['content-type'], 'text/plain')
- msg.set_param('charset', 'us-ascii')
- eq(msg['content-type'], 'text/plain; charset="us-ascii"')
- msg.set_type('text/html')
- eq(msg['content-type'], 'text/html; charset="us-ascii"')
-
- def test_set_type_on_other_header(self):
- msg = Message()
- msg['X-Content-Type'] = 'text/plain'
- msg.set_type('application/octet-stream', 'X-Content-Type')
- self.assertEqual(msg['x-content-type'], 'application/octet-stream')
-
- def test_get_content_type_missing(self):
- msg = Message()
- self.assertEqual(msg.get_content_type(), 'text/plain')
-
- def test_get_content_type_missing_with_default_type(self):
- msg = Message()
- msg.set_default_type('message/rfc822')
- self.assertEqual(msg.get_content_type(), 'message/rfc822')
-
- def test_get_content_type_from_message_implicit(self):
- msg = self._msgobj('msg_30.txt')
- self.assertEqual(msg.get_payload(0).get_content_type(),
- 'message/rfc822')
-
- def test_get_content_type_from_message_explicit(self):
- msg = self._msgobj('msg_28.txt')
- self.assertEqual(msg.get_payload(0).get_content_type(),
- 'message/rfc822')
-
- def test_get_content_type_from_message_text_plain_implicit(self):
- msg = self._msgobj('msg_03.txt')
- self.assertEqual(msg.get_content_type(), 'text/plain')
-
- def test_get_content_type_from_message_text_plain_explicit(self):
- msg = self._msgobj('msg_01.txt')
- self.assertEqual(msg.get_content_type(), 'text/plain')
-
- def test_get_content_maintype_missing(self):
- msg = Message()
- self.assertEqual(msg.get_content_maintype(), 'text')
-
- def test_get_content_maintype_missing_with_default_type(self):
- msg = Message()
- msg.set_default_type('message/rfc822')
- self.assertEqual(msg.get_content_maintype(), 'message')
-
- def test_get_content_maintype_from_message_implicit(self):
- msg = self._msgobj('msg_30.txt')
- self.assertEqual(msg.get_payload(0).get_content_maintype(), 'message')
-
- def test_get_content_maintype_from_message_explicit(self):
- msg = self._msgobj('msg_28.txt')
- self.assertEqual(msg.get_payload(0).get_content_maintype(), 'message')
-
- def test_get_content_maintype_from_message_text_plain_implicit(self):
- msg = self._msgobj('msg_03.txt')
- self.assertEqual(msg.get_content_maintype(), 'text')
-
- def test_get_content_maintype_from_message_text_plain_explicit(self):
- msg = self._msgobj('msg_01.txt')
- self.assertEqual(msg.get_content_maintype(), 'text')
-
- def test_get_content_subtype_missing(self):
- msg = Message()
- self.assertEqual(msg.get_content_subtype(), 'plain')
-
- def test_get_content_subtype_missing_with_default_type(self):
- msg = Message()
- msg.set_default_type('message/rfc822')
- self.assertEqual(msg.get_content_subtype(), 'rfc822')
-
- def test_get_content_subtype_from_message_implicit(self):
- msg = self._msgobj('msg_30.txt')
- self.assertEqual(msg.get_payload(0).get_content_subtype(), 'rfc822')
-
- def test_get_content_subtype_from_message_explicit(self):
- msg = self._msgobj('msg_28.txt')
- self.assertEqual(msg.get_payload(0).get_content_subtype(), 'rfc822')
-
- def test_get_content_subtype_from_message_text_plain_implicit(self):
- msg = self._msgobj('msg_03.txt')
- self.assertEqual(msg.get_content_subtype(), 'plain')
-
- def test_get_content_subtype_from_message_text_plain_explicit(self):
- msg = self._msgobj('msg_01.txt')
- self.assertEqual(msg.get_content_subtype(), 'plain')
-
- def test_get_content_maintype_error(self):
- msg = Message()
- msg['Content-Type'] = 'no-slash-in-this-string'
- self.assertEqual(msg.get_content_maintype(), 'text')
-
- def test_get_content_subtype_error(self):
- msg = Message()
- msg['Content-Type'] = 'no-slash-in-this-string'
- self.assertEqual(msg.get_content_subtype(), 'plain')
-
- def test_replace_header(self):
- eq = self.assertEqual
- msg = Message()
- msg.add_header('First', 'One')
- msg.add_header('Second', 'Two')
- msg.add_header('Third', 'Three')
- eq(msg.keys(), ['First', 'Second', 'Third'])
- eq(msg.values(), ['One', 'Two', 'Three'])
- msg.replace_header('Second', 'Twenty')
- eq(msg.keys(), ['First', 'Second', 'Third'])
- eq(msg.values(), ['One', 'Twenty', 'Three'])
- msg.add_header('First', 'Eleven')
- msg.replace_header('First', 'One Hundred')
- eq(msg.keys(), ['First', 'Second', 'Third', 'First'])
- eq(msg.values(), ['One Hundred', 'Twenty', 'Three', 'Eleven'])
- self.assertRaises(KeyError, msg.replace_header, 'Fourth', 'Missing')
-
- def test_broken_base64_payload(self):
- x = 'AwDp0P7//y6LwKEAcPa/6Q=9'
- msg = Message()
- msg['content-type'] = 'audio/x-midi'
- msg['content-transfer-encoding'] = 'base64'
- msg.set_payload(x)
- self.assertEqual(msg.get_payload(decode=True), x)
-
-
-
-# Test the email.encoders module
-class TestEncoders(unittest.TestCase):
- def test_encode_empty_payload(self):
- eq = self.assertEqual
- msg = Message()
- msg.set_charset('us-ascii')
- eq(msg['content-transfer-encoding'], '7bit')
-
- def test_default_cte(self):
- eq = self.assertEqual
- msg = MIMEText('hello world')
- eq(msg['content-transfer-encoding'], '7bit')
-
- def test_default_cte(self):
- eq = self.assertEqual
- # With no explicit _charset its us-ascii, and all are 7-bit
- msg = MIMEText('hello world')
- eq(msg['content-transfer-encoding'], '7bit')
- # Similar, but with 8-bit data
- msg = MIMEText('hello \xf8 world')
- eq(msg['content-transfer-encoding'], '8bit')
- # And now with a different charset
- msg = MIMEText('hello \xf8 world', _charset='iso-8859-1')
- eq(msg['content-transfer-encoding'], 'quoted-printable')
-
-
-
-# Test long header wrapping
-class TestLongHeaders(TestEmailBase):
- def test_split_long_continuation(self):
- eq = self.ndiffAssertEqual
- msg = email.message_from_string("""\
-Subject: bug demonstration
-\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
-\tmore text
-
-test
-""")
- sfp = StringIO()
- g = Generator(sfp)
- g.flatten(msg)
- eq(sfp.getvalue(), """\
-Subject: bug demonstration
- 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
- more text
-
-test
-""")
-
- def test_another_long_almost_unsplittable_header(self):
- eq = self.ndiffAssertEqual
- hstr = """\
-bug demonstration
-\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
-\tmore text"""
- h = Header(hstr, continuation_ws='\t')
- eq(h.encode(), """\
-bug demonstration
-\t12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
-\tmore text""")
- h = Header(hstr)
- eq(h.encode(), """\
-bug demonstration
- 12345678911234567892123456789312345678941234567895123456789612345678971234567898112345678911234567892123456789112345678911234567892123456789
- more text""")
-
- def test_long_nonstring(self):
- eq = self.ndiffAssertEqual
- g = Charset("iso-8859-1")
- cz = Charset("iso-8859-2")
- utf8 = Charset("utf-8")
- g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
- cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. "
- utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8")
- h = Header(g_head, g, header_name='Subject')
- h.append(cz_head, cz)
- h.append(utf8_head, utf8)
- msg = Message()
- msg['Subject'] = h
- sfp = StringIO()
- g = Generator(sfp)
- g.flatten(msg)
- eq(sfp.getvalue(), """\
-Subject: =?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?=
- =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?=
- =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?=
- =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?=
- =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
- =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?=
- =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?=
- =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?=
- =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?=
- =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?=
- =?utf-8?b?44Gm44GE44G+44GZ44CC?=
-
-""")
- eq(h.encode(), """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerd?=
- =?iso-8859-1?q?erband_komfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndi?=
- =?iso-8859-1?q?schen_Wandgem=E4lden_vorbei=2C_gegen_die_rotierenden_Kling?=
- =?iso-8859-1?q?en_bef=F6rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_met?=
- =?iso-8859-2?q?ropole_se_hroutily_pod_tlakem_jejich_d=F9vtipu=2E=2E_?=
- =?utf-8?b?5q2j56K644Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE?=
- =?utf-8?b?44G+44Gb44KT44CC5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB?=
- =?utf-8?b?44GC44Go44Gv44Gn44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CM?=
- =?utf-8?q?Wenn_ist_das_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das?=
- =?utf-8?b?IE9kZXIgZGllIEZsaXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBow==?=
- =?utf-8?b?44Gm44GE44G+44GZ44CC?=""")
-
- def test_long_header_encode(self):
- eq = self.ndiffAssertEqual
- h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
- 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
- header_name='X-Foobar-Spoink-Defrobnit')
- eq(h.encode(), '''\
-wasnipoop; giraffes="very-long-necked-animals";
- spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
-
- def test_long_header_encode_with_tab_continuation(self):
- eq = self.ndiffAssertEqual
- h = Header('wasnipoop; giraffes="very-long-necked-animals"; '
- 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"',
- header_name='X-Foobar-Spoink-Defrobnit',
- continuation_ws='\t')
- eq(h.encode(), '''\
-wasnipoop; giraffes="very-long-necked-animals";
-\tspooge="yummy"; hippos="gargantuan"; marshmallows="gooey"''')
-
- def test_header_splitter(self):
- eq = self.ndiffAssertEqual
- msg = MIMEText('')
- # It'd be great if we could use add_header() here, but that doesn't
- # guarantee an order of the parameters.
- msg['X-Foobar-Spoink-Defrobnit'] = (
- 'wasnipoop; giraffes="very-long-necked-animals"; '
- 'spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"')
- sfp = StringIO()
- g = Generator(sfp)
- g.flatten(msg)
- eq(sfp.getvalue(), '''\
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
- spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"
-
-''')
-
- def test_no_semis_header_splitter(self):
- eq = self.ndiffAssertEqual
- msg = Message()
- msg['From'] = 'test@dom.ain'
- msg['References'] = SPACE.join(['<%d@dom.ain>' % i for i in range(10)])
- msg.set_payload('Test')
- sfp = StringIO()
- g = Generator(sfp)
- g.flatten(msg)
- eq(sfp.getvalue(), """\
-From: test@dom.ain
-References: <0@dom.ain> <1@dom.ain> <2@dom.ain> <3@dom.ain> <4@dom.ain>
- <5@dom.ain> <6@dom.ain> <7@dom.ain> <8@dom.ain> <9@dom.ain>
-
-Test""")
-
- def test_no_split_long_header(self):
- eq = self.ndiffAssertEqual
- hstr = 'References: ' + 'x' * 80
- h = Header(hstr, continuation_ws='\t')
- eq(h.encode(), """\
-References: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""")
-
- def test_splitting_multiple_long_lines(self):
- eq = self.ndiffAssertEqual
- hstr = """\
-from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
-\tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
-\tfrom babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
-"""
- h = Header(hstr, continuation_ws='\t')
- eq(h.encode(), """\
-from babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
-\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)
-\tfrom babylon.socal-raves.org (localhost [127.0.0.1]);
-\tby babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
-\tfor <mailman-admin@babylon.socal-raves.org>;
-\tSat, 2 Feb 2002 17:00:06 -0800 (PST)""")
-
- def test_splitting_first_line_only_is_long(self):
- eq = self.ndiffAssertEqual
- hstr = """\
-from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93] helo=cthulhu.gerg.ca)
-\tby kronos.mems-exchange.org with esmtp (Exim 4.05)
-\tid 17k4h5-00034i-00
-\tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400"""
- h = Header(hstr, maxlinelen=78, header_name='Received',
- continuation_ws='\t')
- eq(h.encode(), """\
-from modemcable093.139-201-24.que.mc.videotron.ca ([24.201.139.93]
-\thelo=cthulhu.gerg.ca)
-\tby kronos.mems-exchange.org with esmtp (Exim 4.05)
-\tid 17k4h5-00034i-00
-\tfor test@mems-exchange.org; Wed, 28 Aug 2002 11:25:20 -0400""")
-
- def test_long_8bit_header(self):
- eq = self.ndiffAssertEqual
- msg = Message()
- h = Header('Britische Regierung gibt', 'iso-8859-1',
- header_name='Subject')
- h.append('gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte')
- msg['Subject'] = h
- eq(msg.as_string(), """\
-Subject: =?iso-8859-1?q?Britische_Regierung_gibt?= =?iso-8859-1?q?gr=FCnes?=
- =?iso-8859-1?q?_Licht_f=FCr_Offshore-Windkraftprojekte?=
-
-""")
-
- def test_long_8bit_header_no_charset(self):
- eq = self.ndiffAssertEqual
- msg = Message()
- msg['Reply-To'] = 'Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com>'
- eq(msg.as_string(), """\
-Reply-To: Britische Regierung gibt gr\xfcnes Licht f\xfcr Offshore-Windkraftprojekte <a-very-long-address@example.com>
-
-""")
-
- def test_long_to_header(self):
- eq = self.ndiffAssertEqual
- to = '"Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>,"Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu>'
- msg = Message()
- msg['To'] = to
- eq(msg.as_string(0), '''\
-To: "Someone Test #A" <someone@eecs.umich.edu>, <someone@eecs.umich.edu>,
- "Someone Test #B" <someone@umich.edu>,
- "Someone Test #C" <someone@eecs.umich.edu>,
- "Someone Test #D" <someone@eecs.umich.edu>
-
-''')
-
- def test_long_line_after_append(self):
- eq = self.ndiffAssertEqual
- s = 'This is an example of string which has almost the limit of header length.'
- h = Header(s)
- h.append('Add another line.')
- eq(h.encode(), """\
-This is an example of string which has almost the limit of header length.
- Add another line.""")
-
- def test_shorter_line_with_append(self):
- eq = self.ndiffAssertEqual
- s = 'This is a shorter line.'
- h = Header(s)
- h.append('Add another sentence. (Surprise?)')
- eq(h.encode(),
- 'This is a shorter line. Add another sentence. (Surprise?)')
-
- def test_long_field_name(self):
- eq = self.ndiffAssertEqual
- fn = 'X-Very-Very-Very-Long-Header-Name'
- gs = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
- h = Header(gs, 'iso-8859-1', header_name=fn)
- # BAW: this seems broken because the first line is too long
- eq(h.encode(), """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_?=
- =?iso-8859-1?q?ein_werden_mit_einem_Foerderband_komfortabel_den_Korridor_?=
- =?iso-8859-1?q?entlang=2C_an_s=FCdl=FCndischen_Wandgem=E4lden_vorbei=2C_g?=
- =?iso-8859-1?q?egen_die_rotierenden_Klingen_bef=F6rdert=2E_?=""")
-
- def test_long_received_header(self):
- h = 'from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP; Wed, 05 Mar 2003 18:10:18 -0700'
- msg = Message()
- msg['Received-1'] = Header(h, continuation_ws='\t')
- msg['Received-2'] = h
- self.ndiffAssertEqual(msg.as_string(), """\
-Received-1: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
-\throthgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
-\tWed, 05 Mar 2003 18:10:18 -0700
-Received-2: from FOO.TLD (vizworld.acl.foo.tld [123.452.678.9]) by
- hrothgar.la.mastaler.com (tmda-ofmipd) with ESMTP;
- Wed, 05 Mar 2003 18:10:18 -0700
-
-""")
-
- def test_string_headerinst_eq(self):
- h = '<15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de> (David Bremner\'s message of "Thu, 6 Mar 2003 13:58:21 +0100")'
- msg = Message()
- msg['Received'] = Header(h, header_name='Received-1',
- continuation_ws='\t')
- msg['Received'] = h
- self.ndiffAssertEqual(msg.as_string(), """\
-Received: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de>
-\t(David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
-Received: <15975.17901.207240.414604@sgigritzmann1.mathematik.tu-muenchen.de>
- (David Bremner's message of "Thu, 6 Mar 2003 13:58:21 +0100")
-
-""")
-
- def test_long_unbreakable_lines_with_continuation(self):
- eq = self.ndiffAssertEqual
- msg = Message()
- t = """\
- iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
- locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp"""
- msg['Face-1'] = t
- msg['Face-2'] = Header(t, header_name='Face-2')
- eq(msg.as_string(), """\
-Face-1: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
- locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
-Face-2: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9
- locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp
-
-""")
-
- def test_another_long_multiline_header(self):
- eq = self.ndiffAssertEqual
- m = '''\
-Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with Microsoft SMTPSVC(5.0.2195.4905);
- Wed, 16 Oct 2002 07:41:11 -0700'''
- msg = email.message_from_string(m)
- eq(msg.as_string(), '''\
-Received: from siimage.com ([172.25.1.3]) by zima.siliconimage.com with
- Microsoft SMTPSVC(5.0.2195.4905); Wed, 16 Oct 2002 07:41:11 -0700
-
-''')
-
- def test_long_lines_with_different_header(self):
- eq = self.ndiffAssertEqual
- h = """\
-List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>"""
- msg = Message()
- msg['List'] = h
- msg['List'] = Header(h, header_name='List')
- self.ndiffAssertEqual(msg.as_string(), """\
-List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
-List: List-Unsubscribe: <https://lists.sourceforge.net/lists/listinfo/spamassassin-talk>,
- <mailto:spamassassin-talk-request@lists.sourceforge.net?subject=unsubscribe>
-
-""")
-
-
-
-# Test mangling of "From " lines in the body of a message
-class TestFromMangling(unittest.TestCase):
- def setUp(self):
- self.msg = Message()
- self.msg['From'] = 'aaa@bbb.org'
- self.msg.set_payload("""\
-From the desk of A.A.A.:
-Blah blah blah
-""")
-
- def test_mangled_from(self):
- s = StringIO()
- g = Generator(s, mangle_from_=True)
- g.flatten(self.msg)
- self.assertEqual(s.getvalue(), """\
-From: aaa@bbb.org
-
->From the desk of A.A.A.:
-Blah blah blah
-""")
-
- def test_dont_mangle_from(self):
- s = StringIO()
- g = Generator(s, mangle_from_=False)
- g.flatten(self.msg)
- self.assertEqual(s.getvalue(), """\
-From: aaa@bbb.org
-
-From the desk of A.A.A.:
-Blah blah blah
-""")
-
-
-
-# Test the basic MIMEAudio class
-class TestMIMEAudio(unittest.TestCase):
- def setUp(self):
- # Make sure we pick up the audiotest.au that lives in email/test/data.
- # In Python, there's an audiotest.au living in Lib/test but that isn't
- # included in some binary distros that don't include the test
- # package. The trailing empty string on the .join() is significant
- # since findfile() will do a dirname().
- datadir = os.path.join(os.path.dirname(landmark), 'data', '')
- fp = open(findfile('audiotest.au', datadir), 'rb')
- try:
- self._audiodata = fp.read()
- finally:
- fp.close()
- self._au = MIMEAudio(self._audiodata)
-
- def test_guess_minor_type(self):
- self.assertEqual(self._au.get_content_type(), 'audio/basic')
-
- def test_encoding(self):
- payload = self._au.get_payload()
- self.assertEqual(base64.decodestring(payload), self._audiodata)
-
- def test_checkSetMinor(self):
- au = MIMEAudio(self._audiodata, 'fish')
- self.assertEqual(au.get_content_type(), 'audio/fish')
-
- def test_add_header(self):
- eq = self.assertEqual
- unless = self.assertTrue
- self._au.add_header('Content-Disposition', 'attachment',
- filename='audiotest.au')
- eq(self._au['content-disposition'],
- 'attachment; filename="audiotest.au"')
- eq(self._au.get_params(header='content-disposition'),
- [('attachment', ''), ('filename', 'audiotest.au')])
- eq(self._au.get_param('filename', header='content-disposition'),
- 'audiotest.au')
- missing = []
- eq(self._au.get_param('attachment', header='content-disposition'), '')
- unless(self._au.get_param('foo', failobj=missing,
- header='content-disposition') is missing)
- # Try some missing stuff
- unless(self._au.get_param('foobar', missing) is missing)
- unless(self._au.get_param('attachment', missing,
- header='foobar') is missing)
-
-
-
-# Test the basic MIMEImage class
-class TestMIMEImage(unittest.TestCase):
- def setUp(self):
- fp = openfile('PyBanner048.gif')
- try:
- self._imgdata = fp.read()
- finally:
- fp.close()
- self._im = MIMEImage(self._imgdata)
-
- def test_guess_minor_type(self):
- self.assertEqual(self._im.get_content_type(), 'image/gif')
-
- def test_encoding(self):
- payload = self._im.get_payload()
- self.assertEqual(base64.decodestring(payload), self._imgdata)
-
- def test_checkSetMinor(self):
- im = MIMEImage(self._imgdata, 'fish')
- self.assertEqual(im.get_content_type(), 'image/fish')
-
- def test_add_header(self):
- eq = self.assertEqual
- unless = self.assertTrue
- self._im.add_header('Content-Disposition', 'attachment',
- filename='dingusfish.gif')
- eq(self._im['content-disposition'],
- 'attachment; filename="dingusfish.gif"')
- eq(self._im.get_params(header='content-disposition'),
- [('attachment', ''), ('filename', 'dingusfish.gif')])
- eq(self._im.get_param('filename', header='content-disposition'),
- 'dingusfish.gif')
- missing = []
- eq(self._im.get_param('attachment', header='content-disposition'), '')
- unless(self._im.get_param('foo', failobj=missing,
- header='content-disposition') is missing)
- # Try some missing stuff
- unless(self._im.get_param('foobar', missing) is missing)
- unless(self._im.get_param('attachment', missing,
- header='foobar') is missing)
-
-
-
-# Test the basic MIMEApplication class
-class TestMIMEApplication(unittest.TestCase):
- def test_headers(self):
- eq = self.assertEqual
- msg = MIMEApplication('\xfa\xfb\xfc\xfd\xfe\xff')
- eq(msg.get_content_type(), 'application/octet-stream')
- eq(msg['content-transfer-encoding'], 'base64')
-
- def test_body(self):
- eq = self.assertEqual
- bytes = '\xfa\xfb\xfc\xfd\xfe\xff'
- msg = MIMEApplication(bytes)
- eq(msg.get_payload(), '+vv8/f7/')
- eq(msg.get_payload(decode=True), bytes)
-
-
-
-# Test the basic MIMEText class
-class TestMIMEText(unittest.TestCase):
- def setUp(self):
- self._msg = MIMEText('hello there')
-
- def test_types(self):
- eq = self.assertEqual
- unless = self.assertTrue
- eq(self._msg.get_content_type(), 'text/plain')
- eq(self._msg.get_param('charset'), 'us-ascii')
- missing = []
- unless(self._msg.get_param('foobar', missing) is missing)
- unless(self._msg.get_param('charset', missing, header='foobar')
- is missing)
-
- def test_payload(self):
- self.assertEqual(self._msg.get_payload(), 'hello there')
- self.assertTrue(not self._msg.is_multipart())
-
- def test_charset(self):
- eq = self.assertEqual
- msg = MIMEText('hello there', _charset='us-ascii')
- eq(msg.get_charset().input_charset, 'us-ascii')
- eq(msg['content-type'], 'text/plain; charset="us-ascii"')
-
-
-
-# Test complicated multipart/* messages
-class TestMultipart(TestEmailBase):
- def setUp(self):
- fp = openfile('PyBanner048.gif')
- try:
- data = fp.read()
- finally:
- fp.close()
-
- container = MIMEBase('multipart', 'mixed', boundary='BOUNDARY')
- image = MIMEImage(data, name='dingusfish.gif')
- image.add_header('content-disposition', 'attachment',
- filename='dingusfish.gif')
- intro = MIMEText('''\
-Hi there,
-
-This is the dingus fish.
-''')
- container.attach(intro)
- container.attach(image)
- container['From'] = 'Barry <barry@digicool.com>'
- container['To'] = 'Dingus Lovers <cravindogs@cravindogs.com>'
- container['Subject'] = 'Here is your dingus fish'
-
- now = 987809702.54848599
- timetuple = time.localtime(now)
- if timetuple[-1] == 0:
- tzsecs = time.timezone
- else:
- tzsecs = time.altzone
- if tzsecs > 0:
- sign = '-'
- else:
- sign = '+'
- tzoffset = ' %s%04d' % (sign, tzsecs // 36)
- container['Date'] = time.strftime(
- '%a, %d %b %Y %H:%M:%S',
- time.localtime(now)) + tzoffset
- self._msg = container
- self._im = image
- self._txt = intro
-
- def test_hierarchy(self):
- # convenience
- eq = self.assertEqual
- unless = self.assertTrue
- raises = self.assertRaises
- # tests
- m = self._msg
- unless(m.is_multipart())
- eq(m.get_content_type(), 'multipart/mixed')
- eq(len(m.get_payload()), 2)
- raises(IndexError, m.get_payload, 2)
- m0 = m.get_payload(0)
- m1 = m.get_payload(1)
- unless(m0 is self._txt)
- unless(m1 is self._im)
- eq(m.get_payload(), [m0, m1])
- unless(not m0.is_multipart())
- unless(not m1.is_multipart())
-
- def test_empty_multipart_idempotent(self):
- text = """\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
-
---BOUNDARY
-
-
---BOUNDARY--
-"""
- msg = Parser().parsestr(text)
- self.ndiffAssertEqual(text, msg.as_string())
-
- def test_no_parts_in_a_multipart_with_none_epilogue(self):
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.set_boundary('BOUNDARY')
- self.ndiffAssertEqual(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-
---BOUNDARY--''')
-
- def test_no_parts_in_a_multipart_with_empty_epilogue(self):
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.preamble = ''
- outer.epilogue = ''
- outer.set_boundary('BOUNDARY')
- self.ndiffAssertEqual(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
-
---BOUNDARY
-
---BOUNDARY--
-''')
-
- def test_one_part_in_a_multipart(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.set_boundary('BOUNDARY')
- msg = MIMEText('hello world')
- outer.attach(msg)
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--''')
-
- def test_seq_parts_in_a_multipart_with_empty_preamble(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.preamble = ''
- msg = MIMEText('hello world')
- outer.attach(msg)
- outer.set_boundary('BOUNDARY')
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--''')
-
-
- def test_seq_parts_in_a_multipart_with_none_preamble(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.preamble = None
- msg = MIMEText('hello world')
- outer.attach(msg)
- outer.set_boundary('BOUNDARY')
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--''')
-
-
- def test_seq_parts_in_a_multipart_with_none_epilogue(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.epilogue = None
- msg = MIMEText('hello world')
- outer.attach(msg)
- outer.set_boundary('BOUNDARY')
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--''')
-
-
- def test_seq_parts_in_a_multipart_with_empty_epilogue(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.epilogue = ''
- msg = MIMEText('hello world')
- outer.attach(msg)
- outer.set_boundary('BOUNDARY')
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--
-''')
-
-
- def test_seq_parts_in_a_multipart_with_nl_epilogue(self):
- eq = self.ndiffAssertEqual
- outer = MIMEBase('multipart', 'mixed')
- outer['Subject'] = 'A subject'
- outer['To'] = 'aperson@dom.ain'
- outer['From'] = 'bperson@dom.ain'
- outer.epilogue = '\n'
- msg = MIMEText('hello world')
- outer.attach(msg)
- outer.set_boundary('BOUNDARY')
- eq(outer.as_string(), '''\
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-MIME-Version: 1.0
-Subject: A subject
-To: aperson@dom.ain
-From: bperson@dom.ain
-
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-hello world
---BOUNDARY--
-
-''')
-
- def test_message_external_body(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_36.txt')
- eq(len(msg.get_payload()), 2)
- msg1 = msg.get_payload(1)
- eq(msg1.get_content_type(), 'multipart/alternative')
- eq(len(msg1.get_payload()), 2)
- for subpart in msg1.get_payload():
- eq(subpart.get_content_type(), 'message/external-body')
- eq(len(subpart.get_payload()), 1)
- subsubpart = subpart.get_payload(0)
- eq(subsubpart.get_content_type(), 'text/plain')
-
- def test_double_boundary(self):
- # msg_37.txt is a multipart that contains two dash-boundary's in a
- # row. Our interpretation of RFC 2046 calls for ignoring the second
- # and subsequent boundaries.
- msg = self._msgobj('msg_37.txt')
- self.assertEqual(len(msg.get_payload()), 3)
-
- def test_nested_inner_contains_outer_boundary(self):
- eq = self.ndiffAssertEqual
- # msg_38.txt has an inner part that contains outer boundaries. My
- # interpretation of RFC 2046 (based on sections 5.1 and 5.1.2) say
- # these are illegal and should be interpreted as unterminated inner
- # parts.
- msg = self._msgobj('msg_38.txt')
- sfp = StringIO()
- iterators._structure(msg, sfp)
- eq(sfp.getvalue(), """\
-multipart/mixed
- multipart/mixed
- multipart/alternative
- text/plain
- text/plain
- text/plain
- text/plain
-""")
-
- def test_nested_with_same_boundary(self):
- eq = self.ndiffAssertEqual
- # msg 39.txt is similarly evil in that it's got inner parts that use
- # the same boundary as outer parts. Again, I believe the way this is
- # parsed is closest to the spirit of RFC 2046
- msg = self._msgobj('msg_39.txt')
- sfp = StringIO()
- iterators._structure(msg, sfp)
- eq(sfp.getvalue(), """\
-multipart/mixed
- multipart/mixed
- multipart/alternative
- application/octet-stream
- application/octet-stream
- text/plain
-""")
-
- def test_boundary_in_non_multipart(self):
- msg = self._msgobj('msg_40.txt')
- self.assertEqual(msg.as_string(), '''\
-MIME-Version: 1.0
-Content-Type: text/html; boundary="--961284236552522269"
-
-----961284236552522269
-Content-Type: text/html;
-Content-Transfer-Encoding: 7Bit
-
-<html></html>
-
-----961284236552522269--
-''')
-
- def test_boundary_with_leading_space(self):
- eq = self.assertEqual
- msg = email.message_from_string('''\
-MIME-Version: 1.0
-Content-Type: multipart/mixed; boundary=" XXXX"
-
--- XXXX
-Content-Type: text/plain
-
-
--- XXXX
-Content-Type: text/plain
-
--- XXXX--
-''')
- self.assertTrue(msg.is_multipart())
- eq(msg.get_boundary(), ' XXXX')
- eq(len(msg.get_payload()), 2)
-
- def test_boundary_without_trailing_newline(self):
- m = Parser().parsestr("""\
-Content-Type: multipart/mixed; boundary="===============0012394164=="
-MIME-Version: 1.0
-
---===============0012394164==
-Content-Type: image/file1.jpg
-MIME-Version: 1.0
-Content-Transfer-Encoding: base64
-
-YXNkZg==
---===============0012394164==--""")
- self.assertEqual(m.get_payload(0).get_payload(), 'YXNkZg==')
-
-
-
-# Test some badly formatted messages
-class TestNonConformant(TestEmailBase):
- def test_parse_missing_minor_type(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_14.txt')
- eq(msg.get_content_type(), 'text/plain')
- eq(msg.get_content_maintype(), 'text')
- eq(msg.get_content_subtype(), 'plain')
-
- def test_same_boundary_inner_outer(self):
- unless = self.assertTrue
- msg = self._msgobj('msg_15.txt')
- # XXX We can probably eventually do better
- inner = msg.get_payload(0)
- unless(hasattr(inner, 'defects'))
- self.assertEqual(len(inner.defects), 1)
- unless(isinstance(inner.defects[0],
- errors.StartBoundaryNotFoundDefect))
-
- def test_multipart_no_boundary(self):
- unless = self.assertTrue
- msg = self._msgobj('msg_25.txt')
- unless(isinstance(msg.get_payload(), str))
- self.assertEqual(len(msg.defects), 2)
- unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
- unless(isinstance(msg.defects[1],
- errors.MultipartInvariantViolationDefect))
-
- def test_invalid_content_type(self):
- eq = self.assertEqual
- neq = self.ndiffAssertEqual
- msg = Message()
- # RFC 2045, $5.2 says invalid yields text/plain
- msg['Content-Type'] = 'text'
- eq(msg.get_content_maintype(), 'text')
- eq(msg.get_content_subtype(), 'plain')
- eq(msg.get_content_type(), 'text/plain')
- # Clear the old value and try something /really/ invalid
- del msg['content-type']
- msg['Content-Type'] = 'foo'
- eq(msg.get_content_maintype(), 'text')
- eq(msg.get_content_subtype(), 'plain')
- eq(msg.get_content_type(), 'text/plain')
- # Still, make sure that the message is idempotently generated
- s = StringIO()
- g = Generator(s)
- g.flatten(msg)
- neq(s.getvalue(), 'Content-Type: foo\n\n')
-
- def test_no_start_boundary(self):
- eq = self.ndiffAssertEqual
- msg = self._msgobj('msg_31.txt')
- eq(msg.get_payload(), """\
---BOUNDARY
-Content-Type: text/plain
-
-message 1
-
---BOUNDARY
-Content-Type: text/plain
-
-message 2
-
---BOUNDARY--
-""")
-
- def test_no_separating_blank_line(self):
- eq = self.ndiffAssertEqual
- msg = self._msgobj('msg_35.txt')
- eq(msg.as_string(), """\
-From: aperson@dom.ain
-To: bperson@dom.ain
-Subject: here's something interesting
-
-counter to RFC 2822, there's no separating newline here
-""")
-
- def test_lying_multipart(self):
- unless = self.assertTrue
- msg = self._msgobj('msg_41.txt')
- unless(hasattr(msg, 'defects'))
- self.assertEqual(len(msg.defects), 2)
- unless(isinstance(msg.defects[0], errors.NoBoundaryInMultipartDefect))
- unless(isinstance(msg.defects[1],
- errors.MultipartInvariantViolationDefect))
-
- def test_missing_start_boundary(self):
- outer = self._msgobj('msg_42.txt')
- # The message structure is:
- #
- # multipart/mixed
- # text/plain
- # message/rfc822
- # multipart/mixed [*]
- #
- # [*] This message is missing its start boundary
- bad = outer.get_payload(1).get_payload(0)
- self.assertEqual(len(bad.defects), 1)
- self.assertTrue(isinstance(bad.defects[0],
- errors.StartBoundaryNotFoundDefect))
-
- def test_first_line_is_continuation_header(self):
- eq = self.assertEqual
- m = ' Line 1\nLine 2\nLine 3'
- msg = email.message_from_string(m)
- eq(msg.keys(), [])
- eq(msg.get_payload(), 'Line 2\nLine 3')
- eq(len(msg.defects), 1)
- self.assertTrue(isinstance(msg.defects[0],
- errors.FirstHeaderLineIsContinuationDefect))
- eq(msg.defects[0].line, ' Line 1\n')
-
-
-
-# Test RFC 2047 header encoding and decoding
-class TestRFC2047(unittest.TestCase):
- def test_rfc2047_multiline(self):
- eq = self.assertEqual
- s = """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz
- foo bar =?mac-iceland?q?r=8Aksm=9Arg=8Cs?="""
- dh = decode_header(s)
- eq(dh, [
- ('Re:', None),
- ('r\x8aksm\x9arg\x8cs', 'mac-iceland'),
- ('baz foo bar', None),
- ('r\x8aksm\x9arg\x8cs', 'mac-iceland')])
- eq(str(make_header(dh)),
- """Re: =?mac-iceland?q?r=8Aksm=9Arg=8Cs?= baz foo bar
- =?mac-iceland?q?r=8Aksm=9Arg=8Cs?=""")
-
- def test_whitespace_eater_unicode(self):
- eq = self.assertEqual
- s = '=?ISO-8859-1?Q?Andr=E9?= Pirard <pirard@dom.ain>'
- dh = decode_header(s)
- eq(dh, [('Andr\xe9', 'iso-8859-1'), ('Pirard <pirard@dom.ain>', None)])
- hu = unicode(make_header(dh)).encode('latin-1')
- eq(hu, 'Andr\xe9 Pirard <pirard@dom.ain>')
-
- def test_whitespace_eater_unicode_2(self):
- eq = self.assertEqual
- s = 'The =?iso-8859-1?b?cXVpY2sgYnJvd24gZm94?= jumped over the =?iso-8859-1?b?bGF6eSBkb2c=?='
- dh = decode_header(s)
- eq(dh, [('The', None), ('quick brown fox', 'iso-8859-1'),
- ('jumped over the', None), ('lazy dog', 'iso-8859-1')])
- hu = make_header(dh).__unicode__()
- eq(hu, u'The quick brown fox jumped over the lazy dog')
-
- def test_rfc2047_missing_whitespace(self):
- s = 'Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord'
- dh = decode_header(s)
- self.assertEqual(dh, [(s, None)])
-
- def test_rfc2047_with_whitespace(self):
- s = 'Sm =?ISO-8859-1?B?9g==?= rg =?ISO-8859-1?B?5Q==?= sbord'
- dh = decode_header(s)
- self.assertEqual(dh, [('Sm', None), ('\xf6', 'iso-8859-1'),
- ('rg', None), ('\xe5', 'iso-8859-1'),
- ('sbord', None)])
-
-
-
-# Test the MIMEMessage class
-class TestMIMEMessage(TestEmailBase):
- def setUp(self):
- fp = openfile('msg_11.txt')
- try:
- self._text = fp.read()
- finally:
- fp.close()
-
- def test_type_error(self):
- self.assertRaises(TypeError, MIMEMessage, 'a plain string')
-
- def test_valid_argument(self):
- eq = self.assertEqual
- unless = self.assertTrue
- subject = 'A sub-message'
- m = Message()
- m['Subject'] = subject
- r = MIMEMessage(m)
- eq(r.get_content_type(), 'message/rfc822')
- payload = r.get_payload()
- unless(isinstance(payload, list))
- eq(len(payload), 1)
- subpart = payload[0]
- unless(subpart is m)
- eq(subpart['subject'], subject)
-
- def test_bad_multipart(self):
- eq = self.assertEqual
- msg1 = Message()
- msg1['Subject'] = 'subpart 1'
- msg2 = Message()
- msg2['Subject'] = 'subpart 2'
- r = MIMEMessage(msg1)
- self.assertRaises(errors.MultipartConversionError, r.attach, msg2)
-
- def test_generate(self):
- # First craft the message to be encapsulated
- m = Message()
- m['Subject'] = 'An enclosed message'
- m.set_payload('Here is the body of the message.\n')
- r = MIMEMessage(m)
- r['Subject'] = 'The enclosing message'
- s = StringIO()
- g = Generator(s)
- g.flatten(r)
- self.assertEqual(s.getvalue(), """\
-Content-Type: message/rfc822
-MIME-Version: 1.0
-Subject: The enclosing message
-
-Subject: An enclosed message
-
-Here is the body of the message.
-""")
-
- def test_parse_message_rfc822(self):
- eq = self.assertEqual
- unless = self.assertTrue
- msg = self._msgobj('msg_11.txt')
- eq(msg.get_content_type(), 'message/rfc822')
- payload = msg.get_payload()
- unless(isinstance(payload, list))
- eq(len(payload), 1)
- submsg = payload[0]
- self.assertTrue(isinstance(submsg, Message))
- eq(submsg['subject'], 'An enclosed message')
- eq(submsg.get_payload(), 'Here is the body of the message.\n')
-
- def test_dsn(self):
- eq = self.assertEqual
- unless = self.assertTrue
- # msg 16 is a Delivery Status Notification, see RFC 1894
- msg = self._msgobj('msg_16.txt')
- eq(msg.get_content_type(), 'multipart/report')
- unless(msg.is_multipart())
- eq(len(msg.get_payload()), 3)
- # Subpart 1 is a text/plain, human readable section
- subpart = msg.get_payload(0)
- eq(subpart.get_content_type(), 'text/plain')
- eq(subpart.get_payload(), """\
-This report relates to a message you sent with the following header fields:
-
- Message-id: <002001c144a6$8752e060$56104586@oxy.edu>
- Date: Sun, 23 Sep 2001 20:10:55 -0700
- From: "Ian T. Henry" <henryi@oxy.edu>
- To: SoCal Raves <scr@socal-raves.org>
- Subject: [scr] yeah for Ians!!
-
-Your message cannot be delivered to the following recipients:
-
- Recipient address: jangel1@cougar.noc.ucla.edu
- Reason: recipient reached disk quota
-
-""")
- # Subpart 2 contains the machine parsable DSN information. It
- # consists of two blocks of headers, represented by two nested Message
- # objects.
- subpart = msg.get_payload(1)
- eq(subpart.get_content_type(), 'message/delivery-status')
- eq(len(subpart.get_payload()), 2)
- # message/delivery-status should treat each block as a bunch of
- # headers, i.e. a bunch of Message objects.
- dsn1 = subpart.get_payload(0)
- unless(isinstance(dsn1, Message))
- eq(dsn1['original-envelope-id'], '0GK500B4HD0888@cougar.noc.ucla.edu')
- eq(dsn1.get_param('dns', header='reporting-mta'), '')
- # Try a missing one <wink>
- eq(dsn1.get_param('nsd', header='reporting-mta'), None)
- dsn2 = subpart.get_payload(1)
- unless(isinstance(dsn2, Message))
- eq(dsn2['action'], 'failed')
- eq(dsn2.get_params(header='original-recipient'),
- [('rfc822', ''), ('jangel1@cougar.noc.ucla.edu', '')])
- eq(dsn2.get_param('rfc822', header='final-recipient'), '')
- # Subpart 3 is the original message
- subpart = msg.get_payload(2)
- eq(subpart.get_content_type(), 'message/rfc822')
- payload = subpart.get_payload()
- unless(isinstance(payload, list))
- eq(len(payload), 1)
- subsubpart = payload[0]
- unless(isinstance(subsubpart, Message))
- eq(subsubpart.get_content_type(), 'text/plain')
- eq(subsubpart['message-id'],
- '<002001c144a6$8752e060$56104586@oxy.edu>')
-
- def test_epilogue(self):
- eq = self.ndiffAssertEqual
- fp = openfile('msg_21.txt')
- try:
- text = fp.read()
- finally:
- fp.close()
- msg = Message()
- msg['From'] = 'aperson@dom.ain'
- msg['To'] = 'bperson@dom.ain'
- msg['Subject'] = 'Test'
- msg.preamble = 'MIME message'
- msg.epilogue = 'End of MIME message\n'
- msg1 = MIMEText('One')
- msg2 = MIMEText('Two')
- msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY')
- msg.attach(msg1)
- msg.attach(msg2)
- sfp = StringIO()
- g = Generator(sfp)
- g.flatten(msg)
- eq(sfp.getvalue(), text)
-
- def test_no_nl_preamble(self):
- eq = self.ndiffAssertEqual
- msg = Message()
- msg['From'] = 'aperson@dom.ain'
- msg['To'] = 'bperson@dom.ain'
- msg['Subject'] = 'Test'
- msg.preamble = 'MIME message'
- msg.epilogue = ''
- msg1 = MIMEText('One')
- msg2 = MIMEText('Two')
- msg.add_header('Content-Type', 'multipart/mixed', boundary='BOUNDARY')
- msg.attach(msg1)
- msg.attach(msg2)
- eq(msg.as_string(), """\
-From: aperson@dom.ain
-To: bperson@dom.ain
-Subject: Test
-Content-Type: multipart/mixed; boundary="BOUNDARY"
-
-MIME message
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-One
---BOUNDARY
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-Two
---BOUNDARY--
-""")
-
- def test_default_type(self):
- eq = self.assertEqual
- fp = openfile('msg_30.txt')
- try:
- msg = email.message_from_file(fp)
- finally:
- fp.close()
- container1 = msg.get_payload(0)
- eq(container1.get_default_type(), 'message/rfc822')
- eq(container1.get_content_type(), 'message/rfc822')
- container2 = msg.get_payload(1)
- eq(container2.get_default_type(), 'message/rfc822')
- eq(container2.get_content_type(), 'message/rfc822')
- container1a = container1.get_payload(0)
- eq(container1a.get_default_type(), 'text/plain')
- eq(container1a.get_content_type(), 'text/plain')
- container2a = container2.get_payload(0)
- eq(container2a.get_default_type(), 'text/plain')
- eq(container2a.get_content_type(), 'text/plain')
-
- def test_default_type_with_explicit_container_type(self):
- eq = self.assertEqual
- fp = openfile('msg_28.txt')
- try:
- msg = email.message_from_file(fp)
- finally:
- fp.close()
- container1 = msg.get_payload(0)
- eq(container1.get_default_type(), 'message/rfc822')
- eq(container1.get_content_type(), 'message/rfc822')
- container2 = msg.get_payload(1)
- eq(container2.get_default_type(), 'message/rfc822')
- eq(container2.get_content_type(), 'message/rfc822')
- container1a = container1.get_payload(0)
- eq(container1a.get_default_type(), 'text/plain')
- eq(container1a.get_content_type(), 'text/plain')
- container2a = container2.get_payload(0)
- eq(container2a.get_default_type(), 'text/plain')
- eq(container2a.get_content_type(), 'text/plain')
-
- def test_default_type_non_parsed(self):
- eq = self.assertEqual
- neq = self.ndiffAssertEqual
- # Set up container
- container = MIMEMultipart('digest', 'BOUNDARY')
- container.epilogue = ''
- # Set up subparts
- subpart1a = MIMEText('message 1\n')
- subpart2a = MIMEText('message 2\n')
- subpart1 = MIMEMessage(subpart1a)
- subpart2 = MIMEMessage(subpart2a)
- container.attach(subpart1)
- container.attach(subpart2)
- eq(subpart1.get_content_type(), 'message/rfc822')
- eq(subpart1.get_default_type(), 'message/rfc822')
- eq(subpart2.get_content_type(), 'message/rfc822')
- eq(subpart2.get_default_type(), 'message/rfc822')
- neq(container.as_string(0), '''\
-Content-Type: multipart/digest; boundary="BOUNDARY"
-MIME-Version: 1.0
-
---BOUNDARY
-Content-Type: message/rfc822
-MIME-Version: 1.0
-
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-message 1
-
---BOUNDARY
-Content-Type: message/rfc822
-MIME-Version: 1.0
-
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-message 2
-
---BOUNDARY--
-''')
- del subpart1['content-type']
- del subpart1['mime-version']
- del subpart2['content-type']
- del subpart2['mime-version']
- eq(subpart1.get_content_type(), 'message/rfc822')
- eq(subpart1.get_default_type(), 'message/rfc822')
- eq(subpart2.get_content_type(), 'message/rfc822')
- eq(subpart2.get_default_type(), 'message/rfc822')
- neq(container.as_string(0), '''\
-Content-Type: multipart/digest; boundary="BOUNDARY"
-MIME-Version: 1.0
-
---BOUNDARY
-
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-message 1
-
---BOUNDARY
-
-Content-Type: text/plain; charset="us-ascii"
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-
-message 2
-
---BOUNDARY--
-''')
-
- def test_mime_attachments_in_constructor(self):
- eq = self.assertEqual
- text1 = MIMEText('')
- text2 = MIMEText('')
- msg = MIMEMultipart(_subparts=(text1, text2))
- eq(len(msg.get_payload()), 2)
- eq(msg.get_payload(0), text1)
- eq(msg.get_payload(1), text2)
-
-
-
-# A general test of parser->model->generator idempotency. IOW, read a message
-# in, parse it into a message object tree, then without touching the tree,
-# regenerate the plain text. The original text and the transformed text
-# should be identical. Note: that we ignore the Unix-From since that may
-# contain a changed date.
-class TestIdempotent(TestEmailBase):
- def _msgobj(self, filename):
- fp = openfile(filename)
- try:
- data = fp.read()
- finally:
- fp.close()
- msg = email.message_from_string(data)
- return msg, data
-
- def _idempotent(self, msg, text):
- eq = self.ndiffAssertEqual
- s = StringIO()
- g = Generator(s, maxheaderlen=0)
- g.flatten(msg)
- eq(text, s.getvalue())
-
- def test_parse_text_message(self):
- eq = self.assertEqual
- msg, text = self._msgobj('msg_01.txt')
- eq(msg.get_content_type(), 'text/plain')
- eq(msg.get_content_maintype(), 'text')
- eq(msg.get_content_subtype(), 'plain')
- eq(msg.get_params()[1], ('charset', 'us-ascii'))
- eq(msg.get_param('charset'), 'us-ascii')
- eq(msg.preamble, None)
- eq(msg.epilogue, None)
- self._idempotent(msg, text)
-
- def test_parse_untyped_message(self):
- eq = self.assertEqual
- msg, text = self._msgobj('msg_03.txt')
- eq(msg.get_content_type(), 'text/plain')
- eq(msg.get_params(), None)
- eq(msg.get_param('charset'), None)
- self._idempotent(msg, text)
-
- def test_simple_multipart(self):
- msg, text = self._msgobj('msg_04.txt')
- self._idempotent(msg, text)
-
- def test_MIME_digest(self):
- msg, text = self._msgobj('msg_02.txt')
- self._idempotent(msg, text)
-
- def test_long_header(self):
- msg, text = self._msgobj('msg_27.txt')
- self._idempotent(msg, text)
-
- def test_MIME_digest_with_part_headers(self):
- msg, text = self._msgobj('msg_28.txt')
- self._idempotent(msg, text)
-
- def test_mixed_with_image(self):
- msg, text = self._msgobj('msg_06.txt')
- self._idempotent(msg, text)
-
- def test_multipart_report(self):
- msg, text = self._msgobj('msg_05.txt')
- self._idempotent(msg, text)
-
- def test_dsn(self):
- msg, text = self._msgobj('msg_16.txt')
- self._idempotent(msg, text)
-
- def test_preamble_epilogue(self):
- msg, text = self._msgobj('msg_21.txt')
- self._idempotent(msg, text)
-
- def test_multipart_one_part(self):
- msg, text = self._msgobj('msg_23.txt')
- self._idempotent(msg, text)
-
- def test_multipart_no_parts(self):
- msg, text = self._msgobj('msg_24.txt')
- self._idempotent(msg, text)
-
- def test_no_start_boundary(self):
- msg, text = self._msgobj('msg_31.txt')
- self._idempotent(msg, text)
-
- def test_rfc2231_charset(self):
- msg, text = self._msgobj('msg_32.txt')
- self._idempotent(msg, text)
-
- def test_more_rfc2231_parameters(self):
- msg, text = self._msgobj('msg_33.txt')
- self._idempotent(msg, text)
-
- def test_text_plain_in_a_multipart_digest(self):
- msg, text = self._msgobj('msg_34.txt')
- self._idempotent(msg, text)
-
- def test_nested_multipart_mixeds(self):
- msg, text = self._msgobj('msg_12a.txt')
- self._idempotent(msg, text)
-
- def test_message_external_body_idempotent(self):
- msg, text = self._msgobj('msg_36.txt')
- self._idempotent(msg, text)
-
- def test_content_type(self):
- eq = self.assertEqual
- unless = self.assertTrue
- # Get a message object and reset the seek pointer for other tests
- msg, text = self._msgobj('msg_05.txt')
- eq(msg.get_content_type(), 'multipart/report')
- # Test the Content-Type: parameters
- params = {}
- for pk, pv in msg.get_params():
- params[pk] = pv
- eq(params['report-type'], 'delivery-status')
- eq(params['boundary'], 'D1690A7AC1.996856090/mail.example.com')
- eq(msg.preamble, 'This is a MIME-encapsulated message.\n')
- eq(msg.epilogue, '\n')
- eq(len(msg.get_payload()), 3)
- # Make sure the subparts are what we expect
- msg1 = msg.get_payload(0)
- eq(msg1.get_content_type(), 'text/plain')
- eq(msg1.get_payload(), 'Yadda yadda yadda\n')
- msg2 = msg.get_payload(1)
- eq(msg2.get_content_type(), 'text/plain')
- eq(msg2.get_payload(), 'Yadda yadda yadda\n')
- msg3 = msg.get_payload(2)
- eq(msg3.get_content_type(), 'message/rfc822')
- self.assertTrue(isinstance(msg3, Message))
- payload = msg3.get_payload()
- unless(isinstance(payload, list))
- eq(len(payload), 1)
- msg4 = payload[0]
- unless(isinstance(msg4, Message))
- eq(msg4.get_payload(), 'Yadda yadda yadda\n')
-
- def test_parser(self):
- eq = self.assertEqual
- unless = self.assertTrue
- msg, text = self._msgobj('msg_06.txt')
- # Check some of the outer headers
- eq(msg.get_content_type(), 'message/rfc822')
- # Make sure the payload is a list of exactly one sub-Message, and that
- # that submessage has a type of text/plain
- payload = msg.get_payload()
- unless(isinstance(payload, list))
- eq(len(payload), 1)
- msg1 = payload[0]
- self.assertTrue(isinstance(msg1, Message))
- eq(msg1.get_content_type(), 'text/plain')
- self.assertTrue(isinstance(msg1.get_payload(), str))
- eq(msg1.get_payload(), '\n')
-
-
-
-# Test various other bits of the package's functionality
-class TestMiscellaneous(TestEmailBase):
- def test_message_from_string(self):
- fp = openfile('msg_01.txt')
- try:
- text = fp.read()
- finally:
- fp.close()
- msg = email.message_from_string(text)
- s = StringIO()
- # Don't wrap/continue long headers since we're trying to test
- # idempotency.
- g = Generator(s, maxheaderlen=0)
- g.flatten(msg)
- self.assertEqual(text, s.getvalue())
-
- def test_message_from_file(self):
- fp = openfile('msg_01.txt')
- try:
- text = fp.read()
- fp.seek(0)
- msg = email.message_from_file(fp)
- s = StringIO()
- # Don't wrap/continue long headers since we're trying to test
- # idempotency.
- g = Generator(s, maxheaderlen=0)
- g.flatten(msg)
- self.assertEqual(text, s.getvalue())
- finally:
- fp.close()
-
- def test_message_from_string_with_class(self):
- unless = self.assertTrue
- fp = openfile('msg_01.txt')
- try:
- text = fp.read()
- finally:
- fp.close()
- # Create a subclass
- class MyMessage(Message):
- pass
-
- msg = email.message_from_string(text, MyMessage)
- unless(isinstance(msg, MyMessage))
- # Try something more complicated
- fp = openfile('msg_02.txt')
- try:
- text = fp.read()
- finally:
- fp.close()
- msg = email.message_from_string(text, MyMessage)
- for subpart in msg.walk():
- unless(isinstance(subpart, MyMessage))
-
- def test_message_from_file_with_class(self):
- unless = self.assertTrue
- # Create a subclass
- class MyMessage(Message):
- pass
-
- fp = openfile('msg_01.txt')
- try:
- msg = email.message_from_file(fp, MyMessage)
- finally:
- fp.close()
- unless(isinstance(msg, MyMessage))
- # Try something more complicated
- fp = openfile('msg_02.txt')
- try:
- msg = email.message_from_file(fp, MyMessage)
- finally:
- fp.close()
- for subpart in msg.walk():
- unless(isinstance(subpart, MyMessage))
-
- def test__all__(self):
- module = __import__('email')
- # Can't use sorted() here due to Python 2.3 compatibility
- all = module.__all__[:]
- all.sort()
- self.assertEqual(all, [
- # Old names
- 'Charset', 'Encoders', 'Errors', 'Generator',
- 'Header', 'Iterators', 'MIMEAudio', 'MIMEBase',
- 'MIMEImage', 'MIMEMessage', 'MIMEMultipart',
- 'MIMENonMultipart', 'MIMEText', 'Message',
- 'Parser', 'Utils', 'base64MIME',
- # new names
- 'base64mime', 'charset', 'encoders', 'errors', 'generator',
- 'header', 'iterators', 'message', 'message_from_file',
- 'message_from_string', 'mime', 'parser',
- 'quopriMIME', 'quoprimime', 'utils',
- ])
-
- def test_formatdate(self):
- now = time.time()
- self.assertEqual(utils.parsedate(utils.formatdate(now))[:6],
- time.gmtime(now)[:6])
-
- def test_formatdate_localtime(self):
- now = time.time()
- self.assertEqual(
- utils.parsedate(utils.formatdate(now, localtime=True))[:6],
- time.localtime(now)[:6])
-
- def test_formatdate_usegmt(self):
- now = time.time()
- self.assertEqual(
- utils.formatdate(now, localtime=False),
- time.strftime('%a, %d %b %Y %H:%M:%S -0000', time.gmtime(now)))
- self.assertEqual(
- utils.formatdate(now, localtime=False, usegmt=True),
- time.strftime('%a, %d %b %Y %H:%M:%S GMT', time.gmtime(now)))
-
- def test_parsedate_none(self):
- self.assertEqual(utils.parsedate(''), None)
-
- def test_parsedate_compact(self):
- # The FWS after the comma is optional
- self.assertEqual(utils.parsedate('Wed,3 Apr 2002 14:58:26 +0800'),
- utils.parsedate('Wed, 3 Apr 2002 14:58:26 +0800'))
-
- def test_parsedate_no_dayofweek(self):
- eq = self.assertEqual
- eq(utils.parsedate_tz('25 Feb 2003 13:47:26 -0800'),
- (2003, 2, 25, 13, 47, 26, 0, 1, -1, -28800))
-
- def test_parsedate_compact_no_dayofweek(self):
- eq = self.assertEqual
- eq(utils.parsedate_tz('5 Feb 2003 13:47:26 -0800'),
- (2003, 2, 5, 13, 47, 26, 0, 1, -1, -28800))
-
- def test_parsedate_acceptable_to_time_functions(self):
- eq = self.assertEqual
- timetup = utils.parsedate('5 Feb 2003 13:47:26 -0800')
- t = int(time.mktime(timetup))
- eq(time.localtime(t)[:6], timetup[:6])
- eq(int(time.strftime('%Y', timetup)), 2003)
- timetup = utils.parsedate_tz('5 Feb 2003 13:47:26 -0800')
- t = int(time.mktime(timetup[:9]))
- eq(time.localtime(t)[:6], timetup[:6])
- eq(int(time.strftime('%Y', timetup[:9])), 2003)
-
- def test_parseaddr_empty(self):
- self.assertEqual(utils.parseaddr('<>'), ('', ''))
- self.assertEqual(utils.formataddr(utils.parseaddr('<>')), '')
-
- def test_noquote_dump(self):
- self.assertEqual(
- utils.formataddr(('A Silly Person', 'person@dom.ain')),
- 'A Silly Person <person@dom.ain>')
-
- def test_escape_dump(self):
- self.assertEqual(
- utils.formataddr(('A (Very) Silly Person', 'person@dom.ain')),
- r'"A \(Very\) Silly Person" <person@dom.ain>')
- a = r'A \(Special\) Person'
- b = 'person@dom.ain'
- self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
-
- def test_escape_backslashes(self):
- self.assertEqual(
- utils.formataddr(('Arthur \Backslash\ Foobar', 'person@dom.ain')),
- r'"Arthur \\Backslash\\ Foobar" <person@dom.ain>')
- a = r'Arthur \Backslash\ Foobar'
- b = 'person@dom.ain'
- self.assertEqual(utils.parseaddr(utils.formataddr((a, b))), (a, b))
-
- def test_name_with_dot(self):
- x = 'John X. Doe <jxd@example.com>'
- y = '"John X. Doe" <jxd@example.com>'
- a, b = ('John X. Doe', 'jxd@example.com')
- self.assertEqual(utils.parseaddr(x), (a, b))
- self.assertEqual(utils.parseaddr(y), (a, b))
- # formataddr() quotes the name if there's a dot in it
- self.assertEqual(utils.formataddr((a, b)), y)
-
- def test_multiline_from_comment(self):
- x = """\
-Foo
-\tBar <foo@example.com>"""
- self.assertEqual(utils.parseaddr(x), ('Foo Bar', 'foo@example.com'))
-
- def test_quote_dump(self):
- self.assertEqual(
- utils.formataddr(('A Silly; Person', 'person@dom.ain')),
- r'"A Silly; Person" <person@dom.ain>')
-
- def test_fix_eols(self):
- eq = self.assertEqual
- eq(utils.fix_eols('hello'), 'hello')
- eq(utils.fix_eols('hello\n'), 'hello\r\n')
- eq(utils.fix_eols('hello\r'), 'hello\r\n')
- eq(utils.fix_eols('hello\r\n'), 'hello\r\n')
- eq(utils.fix_eols('hello\n\r'), 'hello\r\n\r\n')
-
- def test_charset_richcomparisons(self):
- eq = self.assertEqual
- ne = self.assertNotEqual
- cset1 = Charset()
- cset2 = Charset()
- eq(cset1, 'us-ascii')
- eq(cset1, 'US-ASCII')
- eq(cset1, 'Us-AsCiI')
- eq('us-ascii', cset1)
- eq('US-ASCII', cset1)
- eq('Us-AsCiI', cset1)
- ne(cset1, 'usascii')
- ne(cset1, 'USASCII')
- ne(cset1, 'UsAsCiI')
- ne('usascii', cset1)
- ne('USASCII', cset1)
- ne('UsAsCiI', cset1)
- eq(cset1, cset2)
- eq(cset2, cset1)
-
- def test_getaddresses(self):
- eq = self.assertEqual
- eq(utils.getaddresses(['aperson@dom.ain (Al Person)',
- 'Bud Person <bperson@dom.ain>']),
- [('Al Person', 'aperson@dom.ain'),
- ('Bud Person', 'bperson@dom.ain')])
-
- def test_getaddresses_nasty(self):
- eq = self.assertEqual
- eq(utils.getaddresses(['foo: ;']), [('', '')])
- eq(utils.getaddresses(
- ['[]*-- =~$']),
- [('', ''), ('', ''), ('', '*--')])
- eq(utils.getaddresses(
- ['foo: ;', '"Jason R. Mastaler" <jason@dom.ain>']),
- [('', ''), ('Jason R. Mastaler', 'jason@dom.ain')])
-
- def test_getaddresses_embedded_comment(self):
- """Test proper handling of a nested comment"""
- eq = self.assertEqual
- addrs = utils.getaddresses(['User ((nested comment)) <foo@bar.com>'])
- eq(addrs[0][1], 'foo@bar.com')
-
- def test_utils_quote_unquote(self):
- eq = self.assertEqual
- msg = Message()
- msg.add_header('content-disposition', 'attachment',
- filename='foo\\wacky"name')
- eq(msg.get_filename(), 'foo\\wacky"name')
-
- def test_get_body_encoding_with_bogus_charset(self):
- charset = Charset('not a charset')
- self.assertEqual(charset.get_body_encoding(), 'base64')
-
- def test_get_body_encoding_with_uppercase_charset(self):
- eq = self.assertEqual
- msg = Message()
- msg['Content-Type'] = 'text/plain; charset=UTF-8'
- eq(msg['content-type'], 'text/plain; charset=UTF-8')
- charsets = msg.get_charsets()
- eq(len(charsets), 1)
- eq(charsets[0], 'utf-8')
- charset = Charset(charsets[0])
- eq(charset.get_body_encoding(), 'base64')
- msg.set_payload('hello world', charset=charset)
- eq(msg.get_payload(), 'aGVsbG8gd29ybGQ=\n')
- eq(msg.get_payload(decode=True), 'hello world')
- eq(msg['content-transfer-encoding'], 'base64')
- # Try another one
- msg = Message()
- msg['Content-Type'] = 'text/plain; charset="US-ASCII"'
- charsets = msg.get_charsets()
- eq(len(charsets), 1)
- eq(charsets[0], 'us-ascii')
- charset = Charset(charsets[0])
- eq(charset.get_body_encoding(), encoders.encode_7or8bit)
- msg.set_payload('hello world', charset=charset)
- eq(msg.get_payload(), 'hello world')
- eq(msg['content-transfer-encoding'], '7bit')
-
- def test_charsets_case_insensitive(self):
- lc = Charset('us-ascii')
- uc = Charset('US-ASCII')
- self.assertEqual(lc.get_body_encoding(), uc.get_body_encoding())
-
- def test_partial_falls_inside_message_delivery_status(self):
- eq = self.ndiffAssertEqual
- # The Parser interface provides chunks of data to FeedParser in 8192
- # byte gulps. SF bug #1076485 found one of those chunks inside
- # message/delivery-status header block, which triggered an
- # unreadline() of NeedMoreData.
- msg = self._msgobj('msg_43.txt')
- sfp = StringIO()
- iterators._structure(msg, sfp)
- eq(sfp.getvalue(), """\
-multipart/report
- text/plain
- message/delivery-status
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/plain
- text/rfc822-headers
-""")
-
-
-
-# Test the iterator/generators
-class TestIterators(TestEmailBase):
- def test_body_line_iterator(self):
- eq = self.assertEqual
- neq = self.ndiffAssertEqual
- # First a simple non-multipart message
- msg = self._msgobj('msg_01.txt')
- it = iterators.body_line_iterator(msg)
- lines = list(it)
- eq(len(lines), 6)
- neq(EMPTYSTRING.join(lines), msg.get_payload())
- # Now a more complicated multipart
- msg = self._msgobj('msg_02.txt')
- it = iterators.body_line_iterator(msg)
- lines = list(it)
- eq(len(lines), 43)
- fp = openfile('msg_19.txt')
- try:
- neq(EMPTYSTRING.join(lines), fp.read())
- finally:
- fp.close()
-
- def test_typed_subpart_iterator(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_04.txt')
- it = iterators.typed_subpart_iterator(msg, 'text')
- lines = []
- subparts = 0
- for subpart in it:
- subparts += 1
- lines.append(subpart.get_payload())
- eq(subparts, 2)
- eq(EMPTYSTRING.join(lines), """\
-a simple kind of mirror
-to reflect upon our own
-a simple kind of mirror
-to reflect upon our own
-""")
-
- def test_typed_subpart_iterator_default_type(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_03.txt')
- it = iterators.typed_subpart_iterator(msg, 'text', 'plain')
- lines = []
- subparts = 0
- for subpart in it:
- subparts += 1
- lines.append(subpart.get_payload())
- eq(subparts, 1)
- eq(EMPTYSTRING.join(lines), """\
-
-Hi,
-
-Do you like this message?
-
--Me
-""")
-
-
-
-class TestParsers(TestEmailBase):
- def test_header_parser(self):
- eq = self.assertEqual
- # Parse only the headers of a complex multipart MIME document
- fp = openfile('msg_02.txt')
- try:
- msg = HeaderParser().parse(fp)
- finally:
- fp.close()
- eq(msg['from'], 'ppp-request@zzz.org')
- eq(msg['to'], 'ppp@zzz.org')
- eq(msg.get_content_type(), 'multipart/mixed')
- self.assertFalse(msg.is_multipart())
- self.assertTrue(isinstance(msg.get_payload(), str))
-
- def test_whitespace_continuation(self):
- eq = self.assertEqual
- # This message contains a line after the Subject: header that has only
- # whitespace, but it is not empty!
- msg = email.message_from_string("""\
-From: aperson@dom.ain
-To: bperson@dom.ain
-Subject: the next line has a space on it
-\x20
-Date: Mon, 8 Apr 2002 15:09:19 -0400
-Message-ID: spam
-
-Here's the message body
-""")
- eq(msg['subject'], 'the next line has a space on it\n ')
- eq(msg['message-id'], 'spam')
- eq(msg.get_payload(), "Here's the message body\n")
-
- def test_whitespace_continuation_last_header(self):
- eq = self.assertEqual
- # Like the previous test, but the subject line is the last
- # header.
- msg = email.message_from_string("""\
-From: aperson@dom.ain
-To: bperson@dom.ain
-Date: Mon, 8 Apr 2002 15:09:19 -0400
-Message-ID: spam
-Subject: the next line has a space on it
-\x20
-
-Here's the message body
-""")
- eq(msg['subject'], 'the next line has a space on it\n ')
- eq(msg['message-id'], 'spam')
- eq(msg.get_payload(), "Here's the message body\n")
-
- def test_crlf_separation(self):
- eq = self.assertEqual
- fp = openfile('msg_26.txt', mode='rb')
- try:
- msg = Parser().parse(fp)
- finally:
- fp.close()
- eq(len(msg.get_payload()), 2)
- part1 = msg.get_payload(0)
- eq(part1.get_content_type(), 'text/plain')
- eq(part1.get_payload(), 'Simple email with attachment.\r\n\r\n')
- part2 = msg.get_payload(1)
- eq(part2.get_content_type(), 'application/riscos')
-
- def test_multipart_digest_with_extra_mime_headers(self):
- eq = self.assertEqual
- neq = self.ndiffAssertEqual
- fp = openfile('msg_28.txt')
- try:
- msg = email.message_from_file(fp)
- finally:
- fp.close()
- # Structure is:
- # multipart/digest
- # message/rfc822
- # text/plain
- # message/rfc822
- # text/plain
- eq(msg.is_multipart(), 1)
- eq(len(msg.get_payload()), 2)
- part1 = msg.get_payload(0)
- eq(part1.get_content_type(), 'message/rfc822')
- eq(part1.is_multipart(), 1)
- eq(len(part1.get_payload()), 1)
- part1a = part1.get_payload(0)
- eq(part1a.is_multipart(), 0)
- eq(part1a.get_content_type(), 'text/plain')
- neq(part1a.get_payload(), 'message 1\n')
- # next message/rfc822
- part2 = msg.get_payload(1)
- eq(part2.get_content_type(), 'message/rfc822')
- eq(part2.is_multipart(), 1)
- eq(len(part2.get_payload()), 1)
- part2a = part2.get_payload(0)
- eq(part2a.is_multipart(), 0)
- eq(part2a.get_content_type(), 'text/plain')
- neq(part2a.get_payload(), 'message 2\n')
-
- def test_three_lines(self):
- # A bug report by Andrew McNamara
- lines = ['From: Andrew Person <aperson@dom.ain',
- 'Subject: Test',
- 'Date: Tue, 20 Aug 2002 16:43:45 +1000']
- msg = email.message_from_string(NL.join(lines))
- self.assertEqual(msg['date'], 'Tue, 20 Aug 2002 16:43:45 +1000')
-
- def test_strip_line_feed_and_carriage_return_in_headers(self):
- eq = self.assertEqual
- # For [ 1002475 ] email message parser doesn't handle \r\n correctly
- value1 = 'text'
- value2 = 'more text'
- m = 'Header: %s\r\nNext-Header: %s\r\n\r\nBody\r\n\r\n' % (
- value1, value2)
- msg = email.message_from_string(m)
- eq(msg.get('Header'), value1)
- eq(msg.get('Next-Header'), value2)
-
- def test_rfc2822_header_syntax(self):
- eq = self.assertEqual
- m = '>From: foo\nFrom: bar\n!"#QUX;~: zoo\n\nbody'
- msg = email.message_from_string(m)
- eq(len(msg.keys()), 3)
- keys = msg.keys()
- keys.sort()
- eq(keys, ['!"#QUX;~', '>From', 'From'])
- eq(msg.get_payload(), 'body')
-
- def test_rfc2822_space_not_allowed_in_header(self):
- eq = self.assertEqual
- m = '>From foo@example.com 11:25:53\nFrom: bar\n!"#QUX;~: zoo\n\nbody'
- msg = email.message_from_string(m)
- eq(len(msg.keys()), 0)
-
- def test_rfc2822_one_character_header(self):
- eq = self.assertEqual
- m = 'A: first header\nB: second header\nCC: third header\n\nbody'
- msg = email.message_from_string(m)
- headers = msg.keys()
- headers.sort()
- eq(headers, ['A', 'B', 'CC'])
- eq(msg.get_payload(), 'body')
-
-
-
-class TestBase64(unittest.TestCase):
- def test_len(self):
- eq = self.assertEqual
- eq(base64mime.base64_len('hello'),
- len(base64mime.encode('hello', eol='')))
- for size in range(15):
- if size == 0 : bsize = 0
- elif size <= 3 : bsize = 4
- elif size <= 6 : bsize = 8
- elif size <= 9 : bsize = 12
- elif size <= 12: bsize = 16
- else : bsize = 20
- eq(base64mime.base64_len('x'*size), bsize)
-
- def test_decode(self):
- eq = self.assertEqual
- eq(base64mime.decode(''), '')
- eq(base64mime.decode('aGVsbG8='), 'hello')
- eq(base64mime.decode('aGVsbG8=', 'X'), 'hello')
- eq(base64mime.decode('aGVsbG8NCndvcmxk\n', 'X'), 'helloXworld')
-
- def test_encode(self):
- eq = self.assertEqual
- eq(base64mime.encode(''), '')
- eq(base64mime.encode('hello'), 'aGVsbG8=\n')
- # Test the binary flag
- eq(base64mime.encode('hello\n'), 'aGVsbG8K\n')
- eq(base64mime.encode('hello\n', 0), 'aGVsbG8NCg==\n')
- # Test the maxlinelen arg
- eq(base64mime.encode('xxxx ' * 20, maxlinelen=40), """\
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg
-eHh4eCB4eHh4IA==
-""")
- # Test the eol argument
- eq(base64mime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
-eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
-eHh4eCB4eHh4IA==\r
-""")
-
- def test_header_encode(self):
- eq = self.assertEqual
- he = base64mime.header_encode
- eq(he('hello'), '=?iso-8859-1?b?aGVsbG8=?=')
- eq(he('hello\nworld'), '=?iso-8859-1?b?aGVsbG8NCndvcmxk?=')
- # Test the charset option
- eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?b?aGVsbG8=?=')
- # Test the keep_eols flag
- eq(he('hello\nworld', keep_eols=True),
- '=?iso-8859-1?b?aGVsbG8Kd29ybGQ=?=')
- # Test the maxlinelen argument
- eq(he('xxxx ' * 20, maxlinelen=40), """\
-=?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?=
- =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?=
- =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?=
- =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?=
- =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?=
- =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""")
- # Test the eol argument
- eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-=?iso-8859-1?b?eHh4eCB4eHh4IHh4eHggeHg=?=\r
- =?iso-8859-1?b?eHggeHh4eCB4eHh4IHh4eHg=?=\r
- =?iso-8859-1?b?IHh4eHggeHh4eCB4eHh4IHg=?=\r
- =?iso-8859-1?b?eHh4IHh4eHggeHh4eCB4eHg=?=\r
- =?iso-8859-1?b?eCB4eHh4IHh4eHggeHh4eCA=?=\r
- =?iso-8859-1?b?eHh4eCB4eHh4IHh4eHgg?=""")
-
-
-
-class TestQuopri(unittest.TestCase):
- def setUp(self):
- self.hlit = [chr(x) for x in range(ord('a'), ord('z')+1)] + \
- [chr(x) for x in range(ord('A'), ord('Z')+1)] + \
- [chr(x) for x in range(ord('0'), ord('9')+1)] + \
- ['!', '*', '+', '-', '/', ' ']
- self.hnon = [chr(x) for x in range(256) if chr(x) not in self.hlit]
- assert len(self.hlit) + len(self.hnon) == 256
- self.blit = [chr(x) for x in range(ord(' '), ord('~')+1)] + ['\t']
- self.blit.remove('=')
- self.bnon = [chr(x) for x in range(256) if chr(x) not in self.blit]
- assert len(self.blit) + len(self.bnon) == 256
-
- def test_header_quopri_check(self):
- for c in self.hlit:
- self.assertFalse(quoprimime.header_quopri_check(c))
- for c in self.hnon:
- self.assertTrue(quoprimime.header_quopri_check(c))
-
- def test_body_quopri_check(self):
- for c in self.blit:
- self.assertFalse(quoprimime.body_quopri_check(c))
- for c in self.bnon:
- self.assertTrue(quoprimime.body_quopri_check(c))
-
- def test_header_quopri_len(self):
- eq = self.assertEqual
- hql = quoprimime.header_quopri_len
- enc = quoprimime.header_encode
- for s in ('hello', 'h@e@l@l@o@'):
- # Empty charset and no line-endings. 7 == RFC chrome
- eq(hql(s), len(enc(s, charset='', eol=''))-7)
- for c in self.hlit:
- eq(hql(c), 1)
- for c in self.hnon:
- eq(hql(c), 3)
-
- def test_body_quopri_len(self):
- eq = self.assertEqual
- bql = quoprimime.body_quopri_len
- for c in self.blit:
- eq(bql(c), 1)
- for c in self.bnon:
- eq(bql(c), 3)
-
- def test_quote_unquote_idempotent(self):
- for x in range(256):
- c = chr(x)
- self.assertEqual(quoprimime.unquote(quoprimime.quote(c)), c)
-
- def test_header_encode(self):
- eq = self.assertEqual
- he = quoprimime.header_encode
- eq(he('hello'), '=?iso-8859-1?q?hello?=')
- eq(he('hello\nworld'), '=?iso-8859-1?q?hello=0D=0Aworld?=')
- # Test the charset option
- eq(he('hello', charset='iso-8859-2'), '=?iso-8859-2?q?hello?=')
- # Test the keep_eols flag
- eq(he('hello\nworld', keep_eols=True), '=?iso-8859-1?q?hello=0Aworld?=')
- # Test a non-ASCII character
- eq(he('hello\xc7there'), '=?iso-8859-1?q?hello=C7there?=')
- # Test the maxlinelen argument
- eq(he('xxxx ' * 20, maxlinelen=40), """\
-=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=
- =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=
- =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?=
- =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?=
- =?iso-8859-1?q?x_xxxx_xxxx_?=""")
- # Test the eol argument
- eq(he('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-=?iso-8859-1?q?xxxx_xxxx_xxxx_xxxx_xx?=\r
- =?iso-8859-1?q?xx_xxxx_xxxx_xxxx_xxxx?=\r
- =?iso-8859-1?q?_xxxx_xxxx_xxxx_xxxx_x?=\r
- =?iso-8859-1?q?xxx_xxxx_xxxx_xxxx_xxx?=\r
- =?iso-8859-1?q?x_xxxx_xxxx_?=""")
-
- def test_decode(self):
- eq = self.assertEqual
- eq(quoprimime.decode(''), '')
- eq(quoprimime.decode('hello'), 'hello')
- eq(quoprimime.decode('hello', 'X'), 'hello')
- eq(quoprimime.decode('hello\nworld', 'X'), 'helloXworld')
-
- def test_encode(self):
- eq = self.assertEqual
- eq(quoprimime.encode(''), '')
- eq(quoprimime.encode('hello'), 'hello')
- # Test the binary flag
- eq(quoprimime.encode('hello\r\nworld'), 'hello\nworld')
- eq(quoprimime.encode('hello\r\nworld', 0), 'hello\nworld')
- # Test the maxlinelen arg
- eq(quoprimime.encode('xxxx ' * 20, maxlinelen=40), """\
-xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=
- xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=
-x xxxx xxxx xxxx xxxx=20""")
- # Test the eol argument
- eq(quoprimime.encode('xxxx ' * 20, maxlinelen=40, eol='\r\n'), """\
-xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx=\r
- xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx=\r
-x xxxx xxxx xxxx xxxx=20""")
- eq(quoprimime.encode("""\
-one line
-
-two line"""), """\
-one line
-
-two line""")
-
-
-
-# Test the Charset class
-class TestCharset(unittest.TestCase):
- def tearDown(self):
- from email import charset as CharsetModule
- try:
- del CharsetModule.CHARSETS['fake']
- except KeyError:
- pass
-
- def test_idempotent(self):
- eq = self.assertEqual
- # Make sure us-ascii = no Unicode conversion
- c = Charset('us-ascii')
- s = 'Hello World!'
- sp = c.to_splittable(s)
- eq(s, c.from_splittable(sp))
- # test 8-bit idempotency with us-ascii
- s = '\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa'
- sp = c.to_splittable(s)
- eq(s, c.from_splittable(sp))
-
- def test_body_encode(self):
- eq = self.assertEqual
- # Try a charset with QP body encoding
- c = Charset('iso-8859-1')
- eq('hello w=F6rld', c.body_encode('hello w\xf6rld'))
- # Try a charset with Base64 body encoding
- c = Charset('utf-8')
- eq('aGVsbG8gd29ybGQ=\n', c.body_encode('hello world'))
- # Try a charset with None body encoding
- c = Charset('us-ascii')
- eq('hello world', c.body_encode('hello world'))
- # Try the convert argument, where input codec != output codec
- c = Charset('euc-jp')
- # With apologies to Tokio Kikuchi ;)
- try:
- eq('\x1b$B5FCO;~IW\x1b(B',
- c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7'))
- eq('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7',
- c.body_encode('\xb5\xc6\xc3\xcf\xbb\xfe\xc9\xd7', False))
- except LookupError:
- # We probably don't have the Japanese codecs installed
- pass
- # Testing SF bug #625509, which we have to fake, since there are no
- # built-in encodings where the header encoding is QP but the body
- # encoding is not.
- from email import charset as CharsetModule
- CharsetModule.add_charset('fake', CharsetModule.QP, None)
- c = Charset('fake')
- eq('hello w\xf6rld', c.body_encode('hello w\xf6rld'))
-
- def test_unicode_charset_name(self):
- charset = Charset(u'us-ascii')
- self.assertEqual(str(charset), 'us-ascii')
- self.assertRaises(errors.CharsetError, Charset, 'asc\xffii')
-
-
-
-# Test multilingual MIME headers.
-class TestHeader(TestEmailBase):
- def test_simple(self):
- eq = self.ndiffAssertEqual
- h = Header('Hello World!')
- eq(h.encode(), 'Hello World!')
- h.append(' Goodbye World!')
- eq(h.encode(), 'Hello World! Goodbye World!')
-
- def test_simple_surprise(self):
- eq = self.ndiffAssertEqual
- h = Header('Hello World!')
- eq(h.encode(), 'Hello World!')
- h.append('Goodbye World!')
- eq(h.encode(), 'Hello World! Goodbye World!')
-
- def test_header_needs_no_decoding(self):
- h = 'no decoding needed'
- self.assertEqual(decode_header(h), [(h, None)])
-
- def test_long(self):
- h = Header("I am the very model of a modern Major-General; I've information vegetable, animal, and mineral; I know the kings of England, and I quote the fights historical from Marathon to Waterloo, in order categorical; I'm very well acquainted, too, with matters mathematical; I understand equations, both the simple and quadratical; about binomial theorem I'm teeming with a lot o' news, with many cheerful facts about the square of the hypotenuse.",
- maxlinelen=76)
- for l in h.encode(splitchars=' ').split('\n '):
- self.assertTrue(len(l) <= 76)
-
- def test_multilingual(self):
- eq = self.ndiffAssertEqual
- g = Charset("iso-8859-1")
- cz = Charset("iso-8859-2")
- utf8 = Charset("utf-8")
- g_head = "Die Mieter treten hier ein werden mit einem Foerderband komfortabel den Korridor entlang, an s\xfcdl\xfcndischen Wandgem\xe4lden vorbei, gegen die rotierenden Klingen bef\xf6rdert. "
- cz_head = "Finan\xe8ni metropole se hroutily pod tlakem jejich d\xf9vtipu.. "
- utf8_head = u"\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das Nunstuck git und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt gersput.\u300d\u3068\u8a00\u3063\u3066\u3044\u307e\u3059\u3002".encode("utf-8")
- h = Header(g_head, g)
- h.append(cz_head, cz)
- h.append(utf8_head, utf8)
- enc = h.encode()
- eq(enc, """\
-=?iso-8859-1?q?Die_Mieter_treten_hier_ein_werden_mit_einem_Foerderband_ko?=
- =?iso-8859-1?q?mfortabel_den_Korridor_entlang=2C_an_s=FCdl=FCndischen_Wan?=
- =?iso-8859-1?q?dgem=E4lden_vorbei=2C_gegen_die_rotierenden_Klingen_bef=F6?=
- =?iso-8859-1?q?rdert=2E_?= =?iso-8859-2?q?Finan=E8ni_metropole_se_hroutily?=
- =?iso-8859-2?q?_pod_tlakem_jejich_d=F9vtipu=2E=2E_?= =?utf-8?b?5q2j56K6?=
- =?utf-8?b?44Gr6KiA44GG44Go57+76Kiz44Gv44GV44KM44Gm44GE44G+44Gb44KT44CC?=
- =?utf-8?b?5LiA6YOo44Gv44OJ44Kk44OE6Kqe44Gn44GZ44GM44CB44GC44Go44Gv44Gn?=
- =?utf-8?b?44Gf44KJ44KB44Gn44GZ44CC5a6f6Zqb44Gr44Gv44CMV2VubiBpc3QgZGFz?=
- =?utf-8?q?_Nunstuck_git_und_Slotermeyer=3F_Ja!_Beiherhund_das_Oder_die_Fl?=
- =?utf-8?b?aXBwZXJ3YWxkdCBnZXJzcHV0LuOAjeOBqOiogOOBo+OBpuOBhOOBvuOBmQ==?=
- =?utf-8?b?44CC?=""")
- eq(decode_header(enc),
- [(g_head, "iso-8859-1"), (cz_head, "iso-8859-2"),
- (utf8_head, "utf-8")])
- ustr = unicode(h)
- eq(ustr.encode('utf-8'),
- 'Die Mieter treten hier ein werden mit einem Foerderband '
- 'komfortabel den Korridor entlang, an s\xc3\xbcdl\xc3\xbcndischen '
- 'Wandgem\xc3\xa4lden vorbei, gegen die rotierenden Klingen '
- 'bef\xc3\xb6rdert. Finan\xc4\x8dni metropole se hroutily pod '
- 'tlakem jejich d\xc5\xafvtipu.. \xe6\xad\xa3\xe7\xa2\xba\xe3\x81'
- '\xab\xe8\xa8\x80\xe3\x81\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3'
- '\xe3\x81\xaf\xe3\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3'
- '\x81\xbe\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83'
- '\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8\xaa\x9e'
- '\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81\xe3\x81\x82\xe3'
- '\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81\x9f\xe3\x82\x89\xe3\x82'
- '\x81\xe3\x81\xa7\xe3\x81\x99\xe3\x80\x82\xe5\xae\x9f\xe9\x9a\x9b'
- '\xe3\x81\xab\xe3\x81\xaf\xe3\x80\x8cWenn ist das Nunstuck git '
- 'und Slotermeyer? Ja! Beiherhund das Oder die Flipperwaldt '
- 'gersput.\xe3\x80\x8d\xe3\x81\xa8\xe8\xa8\x80\xe3\x81\xa3\xe3\x81'
- '\xa6\xe3\x81\x84\xe3\x81\xbe\xe3\x81\x99\xe3\x80\x82')
- # Test make_header()
- newh = make_header(decode_header(enc))
- eq(newh, enc)
-
- def test_header_ctor_default_args(self):
- eq = self.ndiffAssertEqual
- h = Header()
- eq(h, '')
- h.append('foo', Charset('iso-8859-1'))
- eq(h, '=?iso-8859-1?q?foo?=')
-
- def test_explicit_maxlinelen(self):
- eq = self.ndiffAssertEqual
- hstr = 'A very long line that must get split to something other than at the 76th character boundary to test the non-default behavior'
- h = Header(hstr)
- eq(h.encode(), '''\
-A very long line that must get split to something other than at the 76th
- character boundary to test the non-default behavior''')
- h = Header(hstr, header_name='Subject')
- eq(h.encode(), '''\
-A very long line that must get split to something other than at the
- 76th character boundary to test the non-default behavior''')
- h = Header(hstr, maxlinelen=1024, header_name='Subject')
- eq(h.encode(), hstr)
-
- def test_us_ascii_header(self):
- eq = self.assertEqual
- s = 'hello'
- x = decode_header(s)
- eq(x, [('hello', None)])
- h = make_header(x)
- eq(s, h.encode())
-
- def test_string_charset(self):
- eq = self.assertEqual
- h = Header()
- h.append('hello', 'iso-8859-1')
- eq(h, '=?iso-8859-1?q?hello?=')
-
-## def test_unicode_error(self):
-## raises = self.assertRaises
-## raises(UnicodeError, Header, u'[P\xf6stal]', 'us-ascii')
-## raises(UnicodeError, Header, '[P\xf6stal]', 'us-ascii')
-## h = Header()
-## raises(UnicodeError, h.append, u'[P\xf6stal]', 'us-ascii')
-## raises(UnicodeError, h.append, '[P\xf6stal]', 'us-ascii')
-## raises(UnicodeError, Header, u'\u83ca\u5730\u6642\u592b', 'iso-8859-1')
-
- def test_utf8_shortest(self):
- eq = self.assertEqual
- h = Header(u'p\xf6stal', 'utf-8')
- eq(h.encode(), '=?utf-8?q?p=C3=B6stal?=')
- h = Header(u'\u83ca\u5730\u6642\u592b', 'utf-8')
- eq(h.encode(), '=?utf-8?b?6I+K5Zyw5pmC5aSr?=')
-
- def test_bad_8bit_header(self):
- raises = self.assertRaises
- eq = self.assertEqual
- x = 'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big'
- raises(UnicodeError, Header, x)
- h = Header()
- raises(UnicodeError, h.append, x)
- eq(str(Header(x, errors='replace')), x)
- h.append(x, errors='replace')
- eq(str(h), x)
-
- def test_encoded_adjacent_nonencoded(self):
- eq = self.assertEqual
- h = Header()
- h.append('hello', 'iso-8859-1')
- h.append('world')
- s = h.encode()
- eq(s, '=?iso-8859-1?q?hello?= world')
- h = make_header(decode_header(s))
- eq(h.encode(), s)
-
- def test_whitespace_eater(self):
- eq = self.assertEqual
- s = 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztk=?= =?koi8-r?q?=CA?= zz.'
- parts = decode_header(s)
- eq(parts, [('Subject:', None), ('\xf0\xd2\xcf\xd7\xc5\xd2\xcb\xc1 \xce\xc1 \xc6\xc9\xce\xc1\xcc\xd8\xce\xd9\xca', 'koi8-r'), ('zz.', None)])
- hdr = make_header(parts)
- eq(hdr.encode(),
- 'Subject: =?koi8-r?b?8NLP18XSy8EgzsEgxsnOwczYztnK?= zz.')
-
- def test_broken_base64_header(self):
- raises = self.assertRaises
- s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?='
- raises(errors.HeaderParseError, decode_header, s)
-
-
-
-# Test RFC 2231 header parameters (en/de)coding
-class TestRFC2231(TestEmailBase):
- def test_get_param(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_29.txt')
- eq(msg.get_param('title'),
- ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!'))
- eq(msg.get_param('title', unquote=False),
- ('us-ascii', 'en', '"This is even more ***fun*** isn\'t it!"'))
-
- def test_set_param(self):
- eq = self.assertEqual
- msg = Message()
- msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
- charset='us-ascii')
- eq(msg.get_param('title'),
- ('us-ascii', '', 'This is even more ***fun*** isn\'t it!'))
- msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
- charset='us-ascii', language='en')
- eq(msg.get_param('title'),
- ('us-ascii', 'en', 'This is even more ***fun*** isn\'t it!'))
- msg = self._msgobj('msg_01.txt')
- msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
- charset='us-ascii', language='en')
- self.ndiffAssertEqual(msg.as_string(), """\
-Return-Path: <bbb@zzz.org>
-Delivered-To: bbb@zzz.org
-Received: by mail.zzz.org (Postfix, from userid 889)
- id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
-From: bbb@ddd.com (John X. Doe)
-To: bbb@zzz.org
-Subject: This is a test message
-Date: Fri, 4 May 2001 14:05:44 -0400
-Content-Type: text/plain; charset=us-ascii;
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
-
-
-Hi,
-
-Do you like this message?
-
--Me
-""")
-
- def test_del_param(self):
- eq = self.ndiffAssertEqual
- msg = self._msgobj('msg_01.txt')
- msg.set_param('foo', 'bar', charset='us-ascii', language='en')
- msg.set_param('title', 'This is even more ***fun*** isn\'t it!',
- charset='us-ascii', language='en')
- msg.del_param('foo', header='Content-Type')
- eq(msg.as_string(), """\
-Return-Path: <bbb@zzz.org>
-Delivered-To: bbb@zzz.org
-Received: by mail.zzz.org (Postfix, from userid 889)
- id 27CEAD38CC; Fri, 4 May 2001 14:05:44 -0400 (EDT)
-MIME-Version: 1.0
-Content-Transfer-Encoding: 7bit
-Message-ID: <15090.61304.110929.45684@aaa.zzz.org>
-From: bbb@ddd.com (John X. Doe)
-To: bbb@zzz.org
-Subject: This is a test message
-Date: Fri, 4 May 2001 14:05:44 -0400
-Content-Type: text/plain; charset="us-ascii";
- title*="us-ascii'en'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20isn%27t%20it%21"
-
-
-Hi,
-
-Do you like this message?
-
--Me
-""")
-
- def test_rfc2231_get_content_charset(self):
- eq = self.assertEqual
- msg = self._msgobj('msg_32.txt')
- eq(msg.get_content_charset(), 'us-ascii')
-
- def test_rfc2231_no_language_or_charset(self):
- m = '''\
-Content-Transfer-Encoding: 8bit
-Content-Disposition: inline; filename="file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm"
-Content-Type: text/html; NAME*0=file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEM; NAME*1=P_nsmail.htm
-
-'''
- msg = email.message_from_string(m)
- param = msg.get_param('NAME')
- self.assertFalse(isinstance(param, tuple))
- self.assertEqual(
- param,
- 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm')
-
- def test_rfc2231_no_language_or_charset_in_filename(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0*="''This%20is%20even%20more%20";
-\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_filename(),
- 'This is even more ***fun*** is it not.pdf')
-
- def test_rfc2231_no_language_or_charset_in_filename_encoded(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0*="''This%20is%20even%20more%20";
-\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_filename(),
- 'This is even more ***fun*** is it not.pdf')
-
- def test_rfc2231_partly_encoded(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0="''This%20is%20even%20more%20";
-\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(
- msg.get_filename(),
- 'This%20is%20even%20more%20***fun*** is it not.pdf')
-
- def test_rfc2231_partly_nonencoded(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0="This%20is%20even%20more%20";
-\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(
- msg.get_filename(),
- 'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdf')
-
- def test_rfc2231_no_language_or_charset_in_boundary(self):
- m = '''\
-Content-Type: multipart/alternative;
-\tboundary*0*="''This%20is%20even%20more%20";
-\tboundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tboundary*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_boundary(),
- 'This is even more ***fun*** is it not.pdf')
-
- def test_rfc2231_no_language_or_charset_in_charset(self):
- # This is a nonsensical charset value, but tests the code anyway
- m = '''\
-Content-Type: text/plain;
-\tcharset*0*="This%20is%20even%20more%20";
-\tcharset*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tcharset*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_content_charset(),
- 'this is even more ***fun*** is it not.pdf')
-
- def test_rfc2231_bad_encoding_in_filename(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0*="bogus'xx'This%20is%20even%20more%20";
-\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2="is it not.pdf"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_filename(),
- 'This is even more ***fun*** is it not.pdf')
-
- def test_rfc2231_bad_encoding_in_charset(self):
- m = """\
-Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D
-
-"""
- msg = email.message_from_string(m)
- # This should return None because non-ascii characters in the charset
- # are not allowed.
- self.assertEqual(msg.get_content_charset(), None)
-
- def test_rfc2231_bad_character_in_charset(self):
- m = """\
-Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D
-
-"""
- msg = email.message_from_string(m)
- # This should return None because non-ascii characters in the charset
- # are not allowed.
- self.assertEqual(msg.get_content_charset(), None)
-
- def test_rfc2231_bad_character_in_filename(self):
- m = '''\
-Content-Disposition: inline;
-\tfilename*0*="ascii'xx'This%20is%20even%20more%20";
-\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
-\tfilename*2*="is it not.pdf%E2"
-
-'''
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_filename(),
- u'This is even more ***fun*** is it not.pdf\ufffd')
-
- def test_rfc2231_unknown_encoding(self):
- m = """\
-Content-Transfer-Encoding: 8bit
-Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt
-
-"""
- msg = email.message_from_string(m)
- self.assertEqual(msg.get_filename(), 'myfile.txt')
-
- def test_rfc2231_single_tick_in_filename_extended(self):
- eq = self.assertEqual
- m = """\
-Content-Type: application/x-foo;
-\tname*0*=\"Frank's\"; name*1*=\" Document\"
-
-"""
- msg = email.message_from_string(m)
- charset, language, s = msg.get_param('name')
- eq(charset, None)
- eq(language, None)
- eq(s, "Frank's Document")
-
- def test_rfc2231_single_tick_in_filename(self):
- m = """\
-Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\"
-
-"""
- msg = email.message_from_string(m)
- param = msg.get_param('name')
- self.assertFalse(isinstance(param, tuple))
- self.assertEqual(param, "Frank's Document")
-
- def test_rfc2231_tick_attack_extended(self):
- eq = self.assertEqual
- m = """\
-Content-Type: application/x-foo;
-\tname*0*=\"us-ascii'en-us'Frank's\"; name*1*=\" Document\"
-
-"""
- msg = email.message_from_string(m)
- charset, language, s = msg.get_param('name')
- eq(charset, 'us-ascii')
- eq(language, 'en-us')
- eq(s, "Frank's Document")
-
- def test_rfc2231_tick_attack(self):
- m = """\
-Content-Type: application/x-foo;
-\tname*0=\"us-ascii'en-us'Frank's\"; name*1=\" Document\"
-
-"""
- msg = email.message_from_string(m)
- param = msg.get_param('name')
- self.assertFalse(isinstance(param, tuple))
- self.assertEqual(param, "us-ascii'en-us'Frank's Document")
-
- def test_rfc2231_no_extended_values(self):
- eq = self.assertEqual
- m = """\
-Content-Type: application/x-foo; name=\"Frank's Document\"
-
-"""
- msg = email.message_from_string(m)
- eq(msg.get_param('name'), "Frank's Document")
-
- def test_rfc2231_encoded_then_unencoded_segments(self):
- eq = self.assertEqual
- m = """\
-Content-Type: application/x-foo;
-\tname*0*=\"us-ascii'en-us'My\";
-\tname*1=\" Document\";
-\tname*2*=\" For You\"
-
-"""
- msg = email.message_from_string(m)
- charset, language, s = msg.get_param('name')
- eq(charset, 'us-ascii')
- eq(language, 'en-us')
- eq(s, 'My Document For You')
-
- def test_rfc2231_unencoded_then_encoded_segments(self):
- eq = self.assertEqual
- m = """\
-Content-Type: application/x-foo;
-\tname*0=\"us-ascii'en-us'My\";
-\tname*1*=\" Document\";
-\tname*2*=\" For You\"
-
-"""
- msg = email.message_from_string(m)
- charset, language, s = msg.get_param('name')
- eq(charset, 'us-ascii')
- eq(language, 'en-us')
- eq(s, 'My Document For You')
-
-
-
-def _testclasses():
- mod = sys.modules[__name__]
- return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
-
-
-def suite():
- suite = unittest.TestSuite()
- for testclass in _testclasses():
- suite.addTest(unittest.makeSuite(testclass))
- return suite
-
-
-def test_main():
- for testclass in _testclasses():
- run_unittest(testclass)
-
-
-
-if __name__ == '__main__':
- unittest.main(defaultTest='suite')
diff --git a/Lib/email/test/test_email_torture.py b/Lib/email/test/test_email_torture.py
index 9dfa6028811..544b1bbb397 100644
--- a/Lib/email/test/test_email_torture.py
+++ b/Lib/email/test/test_email_torture.py
@@ -9,11 +9,11 @@
import sys
import os
import unittest
-from cStringIO import StringIO
+from io import StringIO
from types import ListType
from email.test.test_email import TestEmailBase
-from test.test_support import TestSkipped, run_unittest
+from test.support import TestSkipped, run_unittest
import email
from email import __file__ as testfile
diff --git a/Lib/email/utils.py b/Lib/email/utils.py
index c976021e0e0..ac4da3705f3 100644
--- a/Lib/email/utils.py
+++ b/Lib/email/utils.py
@@ -26,8 +26,9 @@ import time
import base64
import random
import socket
-import urllib
+import urllib.parse
import warnings
+from io import StringIO
from email._parseaddr import quote
from email._parseaddr import AddressList as _AddressList
@@ -44,7 +45,7 @@ from email.encoders import _bencode, _qencode
COMMASPACE = ', '
EMPTYSTRING = ''
-UEMPTYSTRING = u''
+UEMPTYSTRING = ''
CRLF = '\r\n'
TICK = "'"
@@ -52,36 +53,9 @@ specialsre = re.compile(r'[][\\()<>@,:;".]')
escapesre = re.compile(r'[][\\()"]')
-
-# Helpers
-
-def _identity(s):
- return s
-
-
-def _bdecode(s):
- """Decodes a base64 string.
-
- This function is equivalent to base64.decodestring and it's retained only
- for backward compatibility. It used to remove the last \\n of the decoded
- string, if it had any (see issue 7143).
- """
- if not s:
- return s
- return base64.decodestring(s)
-
-
-
-def fix_eols(s):
- """Replace all line-ending characters with \\r\\n."""
- # Fix newlines with no preceding carriage return
- s = re.sub(r'(?<!\r)\n', CRLF, s)
- # Fix carriage returns with no following newline
- s = re.sub(r'\r(?!\n)', CRLF, s)
- return s
+# Helpers
-
def formataddr(pair):
"""The inverse of parseaddr(), this takes a 2-tuple of the form
(realname, email_address) and returns the string value suitable
@@ -100,7 +74,7 @@ def formataddr(pair):
return address
-
+
def getaddresses(fieldvalues):
"""Return a list of (REALNAME, EMAIL) for each fieldvalue."""
all = COMMASPACE.join(fieldvalues)
@@ -108,7 +82,7 @@ def getaddresses(fieldvalues):
return a.addresslist
-
+
ecre = re.compile(r'''
=\? # literal =?
(?P<charset>[^?]*?) # non-greedy up to the next ? is the charset
@@ -120,7 +94,7 @@ ecre = re.compile(r'''
''', re.VERBOSE | re.IGNORECASE)
-
+
def formatdate(timeval=None, localtime=False, usegmt=False):
"""Returns a date string as specified by RFC 2822, e.g.:
@@ -173,14 +147,16 @@ def formatdate(timeval=None, localtime=False, usegmt=False):
zone)
-
-def make_msgid(idstring=None):
+
+def make_msgid(idstring=None, domain=None):
"""Returns a string suitable for RFC 2822 compliant Message-ID, e.g:
<20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
- uniqueness of the message id.
+ uniqueness of the message id. Optional domain if given provides the
+ portion of the message id after the '@'. It defaults to the locally
+ defined hostname.
"""
timeval = time.time()
utcdate = time.strftime('%Y%m%d%H%M%S', time.gmtime(timeval))
@@ -190,12 +166,13 @@ def make_msgid(idstring=None):
idstring = ''
else:
idstring = '.' + idstring
- idhost = socket.getfqdn()
- msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, idhost)
+ if domain is None:
+ domain = socket.getfqdn()
+ msgid = '<%s.%s.%s%s@%s>' % (utcdate, pid, randint, idstring, domain)
return msgid
-
+
# These functions are in the standalone mimelib version only because they've
# subsequently been fixed in the latest Python versions. We use this to worm
# around broken older Pythons.
@@ -229,7 +206,7 @@ def unquote(str):
return str
-
+
# RFC2231-related functions - parameter encoding and decoding
def decode_rfc2231(s):
"""Decode string according to RFC 2231"""
@@ -246,8 +223,7 @@ def encode_rfc2231(s, charset=None, language=None):
charset is given but not language, the string is encoded using the empty
string for language.
"""
- import urllib
- s = urllib.quote(s, safe='')
+ s = urllib.parse.quote(s, safe='', encoding=charset or 'ascii')
if charset is None and language is None:
return s
if language is None:
@@ -255,7 +231,8 @@ def encode_rfc2231(s, charset=None, language=None):
return "%s'%s'%s" % (charset, language, s)
-rfc2231_continuation = re.compile(r'^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$')
+rfc2231_continuation = re.compile(r'^(?P<name>\w+)\*((?P<num>[0-9]+)\*?)?$',
+ re.ASCII)
def decode_params(params):
"""Decode parameters list according to RFC 2231.
@@ -299,7 +276,10 @@ def decode_params(params):
# language specifiers at the beginning of the string.
for num, s, encoded in continuations:
if encoded:
- s = urllib.unquote(s)
+ # Decode as "latin-1", so the characters in s directly
+ # represent the percent-encoded octet values.
+ # collapse_rfc2231_value treats this as an octet sequence.
+ s = urllib.parse.unquote(s, encoding="latin-1")
extended = True
value.append(s)
value = quote(EMPTYSTRING.join(value))
@@ -312,13 +292,15 @@ def decode_params(params):
def collapse_rfc2231_value(value, errors='replace',
fallback_charset='us-ascii'):
- if isinstance(value, tuple):
- rawval = unquote(value[2])
- charset = value[0] or 'us-ascii'
- try:
- return unicode(rawval, charset, errors)
- except LookupError:
- # XXX charset is unknown to Python.
- return unicode(rawval, fallback_charset, errors)
- else:
+ if not isinstance(value, tuple) or len(value) != 3:
return unquote(value)
+ # While value comes to us as a unicode string, we need it to be a bytes
+ # object. We do not want bytes() normal utf-8 decoder, we want a straight
+ # interpretation of the string as character bytes.
+ charset, language, text = value
+ rawbytes = bytes(text, 'raw-unicode-escape')
+ try:
+ return str(rawbytes, charset, errors)
+ except LookupError:
+ # charset is not a known codec.
+ return unquote(text)
diff --git a/Lib/encodings/__init__.py b/Lib/encodings/__init__.py
index b85ca823aec..8dd713056ef 100644
--- a/Lib/encodings/__init__.py
+++ b/Lib/encodings/__init__.py
@@ -10,7 +10,7 @@
Each codec module must export the following interface:
* getregentry() -> codecs.CodecInfo object
- The getregentry() API must a CodecInfo object with encoder, decoder,
+ The getregentry() API must return a CodecInfo object with encoder, decoder,
incrementalencoder, incrementaldecoder, streamwriter and streamreader
atttributes which adhere to the Python Codec Interface Standard.
@@ -29,18 +29,11 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""#"
import codecs
-from encodings import aliases
-import __builtin__
+from . import aliases
_cache = {}
_unknown = '--unknown--'
_import_tail = ['*']
-_norm_encoding_map = (' . '
- '0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ '
- ' abcdefghijklmnopqrstuvwxyz '
- ' '
- ' '
- ' ')
_aliases = aliases.aliases
class CodecRegistryError(LookupError, SystemError):
@@ -59,14 +52,19 @@ def normalize_encoding(encoding):
non-ASCII characters, these must be Latin-1 compatible.
"""
- # Make sure we have an 8-bit string, because .translate() works
- # differently for Unicode strings.
- if hasattr(__builtin__, "unicode") and isinstance(encoding, unicode):
- # Note that .encode('latin-1') does *not* use the codec
- # registry, so this call doesn't recurse. (See unicodeobject.c
- # PyUnicode_AsEncodedString() for details)
- encoding = encoding.encode('latin-1')
- return '_'.join(encoding.translate(_norm_encoding_map).split())
+ if isinstance(encoding, bytes):
+ encoding = str(encoding, "ascii")
+ chars = []
+ punct = False
+ for c in encoding:
+ if c.isalnum() or c == '.':
+ if punct and chars:
+ chars.append('_')
+ chars.append(c)
+ punct = False
+ else:
+ punct = True
+ return ''.join(chars)
def search_function(encoding):
@@ -120,18 +118,15 @@ def search_function(encoding):
entry = getregentry()
if not isinstance(entry, codecs.CodecInfo):
if not 4 <= len(entry) <= 7:
- raise CodecRegistryError,\
- 'module "%s" (%s) failed to register' % \
- (mod.__name__, mod.__file__)
- if not hasattr(entry[0], '__call__') or \
- not hasattr(entry[1], '__call__') or \
- (entry[2] is not None and not hasattr(entry[2], '__call__')) or \
- (entry[3] is not None and not hasattr(entry[3], '__call__')) or \
- (len(entry) > 4 and entry[4] is not None and not hasattr(entry[4], '__call__')) or \
- (len(entry) > 5 and entry[5] is not None and not hasattr(entry[5], '__call__')):
- raise CodecRegistryError,\
- 'incompatible codecs in module "%s" (%s)' % \
- (mod.__name__, mod.__file__)
+ raise CodecRegistryError('module "%s" (%s) failed to register'
+ % (mod.__name__, mod.__file__))
+ if not callable(entry[0]) or not callable(entry[1]) or \
+ (entry[2] is not None and not callable(entry[2])) or \
+ (entry[3] is not None and not callable(entry[3])) or \
+ (len(entry) > 4 and entry[4] is not None and not callable(entry[4])) or \
+ (len(entry) > 5 and entry[5] is not None and not callable(entry[5])):
+ raise CodecRegistryError('incompatible codecs in module "%s" (%s)'
+ % (mod.__name__, mod.__file__))
if len(entry)<7 or entry[6] is None:
entry += (None,)*(6-len(entry)) + (mod.__name__.split(".", 1)[1],)
entry = codecs.CodecInfo(*entry)
diff --git a/Lib/encodings/aliases.py b/Lib/encodings/aliases.py
index a54cf774b7b..235deb5c309 100644
--- a/Lib/encodings/aliases.py
+++ b/Lib/encodings/aliases.py
@@ -33,9 +33,9 @@ aliases = {
'us' : 'ascii',
'us_ascii' : 'ascii',
- # base64_codec codec
- 'base64' : 'base64_codec',
- 'base_64' : 'base64_codec',
+ ## base64_codec codec
+ #'base64' : 'base64_codec',
+ #'base_64' : 'base64_codec',
# big5 codec
'big5_tw' : 'big5',
@@ -45,8 +45,8 @@ aliases = {
'big5_hkscs' : 'big5hkscs',
'hkscs' : 'big5hkscs',
- # bz2_codec codec
- 'bz2' : 'bz2_codec',
+ ## bz2_codec codec
+ #'bz2' : 'bz2_codec',
# cp037 codec
'037' : 'cp037',
@@ -248,8 +248,8 @@ aliases = {
'cp936' : 'gbk',
'ms936' : 'gbk',
- # hex_codec codec
- 'hex' : 'hex_codec',
+ ## hex_codec codec
+ #'hex' : 'hex_codec',
# hp_roman8 codec
'roman8' : 'hp_roman8',
@@ -435,6 +435,7 @@ aliases = {
'maclatin2' : 'mac_latin2',
# mac_roman codec
+ 'macintosh' : 'mac_roman',
'macroman' : 'mac_roman',
# mac_turkish codec
@@ -449,13 +450,13 @@ aliases = {
'cp154' : 'ptcp154',
'cyrillic_asian' : 'ptcp154',
- # quopri_codec codec
- 'quopri' : 'quopri_codec',
- 'quoted_printable' : 'quopri_codec',
- 'quotedprintable' : 'quopri_codec',
+ ## quopri_codec codec
+ #'quopri' : 'quopri_codec',
+ #'quoted_printable' : 'quopri_codec',
+ #'quotedprintable' : 'quopri_codec',
- # rot_13 codec
- 'rot13' : 'rot_13',
+ ## rot_13 codec
+ #'rot13' : 'rot_13',
# shift_jis codec
'csshiftjis' : 'shift_jis',
@@ -517,11 +518,16 @@ aliases = {
'utf8_ucs2' : 'utf_8',
'utf8_ucs4' : 'utf_8',
- # uu_codec codec
- 'uu' : 'uu_codec',
+ ## uu_codec codec
+ #'uu' : 'uu_codec',
- # zlib_codec codec
- 'zip' : 'zlib_codec',
- 'zlib' : 'zlib_codec',
+ ## zlib_codec codec
+ #'zip' : 'zlib_codec',
+ #'zlib' : 'zlib_codec',
+ # temporary mac CJK aliases, will be replaced by proper codecs in 3.1
+ 'x_mac_japanese' : 'shift_jis',
+ 'x_mac_korean' : 'euc_kr',
+ 'x_mac_simp_chinese' : 'gb2312',
+ 'x_mac_trad_chinese' : 'big5',
}
diff --git a/Lib/encodings/base64_codec.py b/Lib/encodings/base64_codec.py
index f84e7808e99..321a961782a 100644
--- a/Lib/encodings/base64_codec.py
+++ b/Lib/encodings/base64_codec.py
@@ -1,69 +1,45 @@
-""" Python 'base64_codec' Codec - base64 content transfer encoding
+"""Python 'base64_codec' Codec - base64 content transfer encoding.
- Unlike most of the other codecs which target Unicode, this codec
- will return Python string objects for both encode and decode.
-
- Written by Marc-Andre Lemburg (mal@lemburg.com).
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+Written by Marc-Andre Lemburg (mal@lemburg.com).
"""
-import codecs, base64
-
-### Codec APIs
-def base64_encode(input,errors='strict'):
+import codecs
+import base64
- """ Encodes the object input and returns a tuple (output
- object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
+### Codec APIs
- """
+def base64_encode(input, errors='strict'):
assert errors == 'strict'
- output = base64.encodestring(input)
- return (output, len(input))
+ return (base64.encodebytes(input), len(input))
-def base64_decode(input,errors='strict'):
-
- """ Decodes the object input and returns a tuple (output
- object, length consumed).
-
- input must be an object which provides the bf_getreadbuf
- buffer slot. Python strings, buffer objects and memory
- mapped files are examples of objects providing this slot.
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def base64_decode(input, errors='strict'):
assert errors == 'strict'
- output = base64.decodestring(input)
- return (output, len(input))
+ return (base64.decodebytes(input), len(input))
class Codec(codecs.Codec):
-
- def encode(self, input,errors='strict'):
- return base64_encode(input,errors)
- def decode(self, input,errors='strict'):
- return base64_decode(input,errors)
+ def encode(self, input, errors='strict'):
+ return base64_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return base64_decode(input, errors)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
assert self.errors == 'strict'
- return base64.encodestring(input)
+ return base64.encodebytes(input)
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
assert self.errors == 'strict'
- return base64.decodestring(input)
+ return base64.decodebytes(input)
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
### encodings module API
diff --git a/Lib/encodings/bz2_codec.py b/Lib/encodings/bz2_codec.py
index 054b36b401a..e65d226bfdf 100644
--- a/Lib/encodings/bz2_codec.py
+++ b/Lib/encodings/bz2_codec.py
@@ -1,51 +1,26 @@
-""" Python 'bz2_codec' Codec - bz2 compression encoding
+"""Python 'bz2_codec' Codec - bz2 compression encoding.
- Unlike most of the other codecs which target Unicode, this codec
- will return Python string objects for both encode and decode.
-
- Adapted by Raymond Hettinger from zlib_codec.py which was written
- by Marc-Andre Lemburg (mal@lemburg.com).
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+Adapted by Raymond Hettinger from zlib_codec.py which was written
+by Marc-Andre Lemburg (mal@lemburg.com).
"""
+
import codecs
import bz2 # this codec needs the optional bz2 module !
### Codec APIs
-def bz2_encode(input,errors='strict'):
-
- """ Encodes the object input and returns a tuple (output
- object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def bz2_encode(input, errors='strict'):
assert errors == 'strict'
- output = bz2.compress(input)
- return (output, len(input))
+ return (bz2.compress(input), len(input))
-def bz2_decode(input,errors='strict'):
-
- """ Decodes the object input and returns a tuple (output
- object, length consumed).
-
- input must be an object which provides the bf_getreadbuf
- buffer slot. Python strings, buffer objects and memory
- mapped files are examples of objects providing this slot.
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def bz2_decode(input, errors='strict'):
assert errors == 'strict'
- output = bz2.decompress(input)
- return (output, len(input))
+ return (bz2.decompress(input), len(input))
class Codec(codecs.Codec):
-
def encode(self, input, errors='strict'):
return bz2_encode(input, errors)
def decode(self, input, errors='strict'):
@@ -82,11 +57,11 @@ class IncrementalDecoder(codecs.IncrementalDecoder):
def reset(self):
self.decompressobj = bz2.BZ2Decompressor()
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
### encodings module API
diff --git a/Lib/encodings/cp037.py b/Lib/encodings/cp037.py
index c802b899af2..4edd708f3d7 100644
--- a/Lib/encodings/cp037.py
+++ b/Lib/encodings/cp037.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> CONTROL
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> CONTROL
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> CONTROL
- u'\x8d' # 0x09 -> CONTROL
- u'\x8e' # 0x0A -> CONTROL
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> CONTROL
- u'\x85' # 0x15 -> CONTROL
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> CONTROL
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> CONTROL
- u'\x8f' # 0x1B -> CONTROL
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> CONTROL
- u'\x81' # 0x21 -> CONTROL
- u'\x82' # 0x22 -> CONTROL
- u'\x83' # 0x23 -> CONTROL
- u'\x84' # 0x24 -> CONTROL
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> CONTROL
- u'\x89' # 0x29 -> CONTROL
- u'\x8a' # 0x2A -> CONTROL
- u'\x8b' # 0x2B -> CONTROL
- u'\x8c' # 0x2C -> CONTROL
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> CONTROL
- u'\x91' # 0x31 -> CONTROL
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> CONTROL
- u'\x94' # 0x34 -> CONTROL
- u'\x95' # 0x35 -> CONTROL
- u'\x96' # 0x36 -> CONTROL
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> CONTROL
- u'\x99' # 0x39 -> CONTROL
- u'\x9a' # 0x3A -> CONTROL
- u'\x9b' # 0x3B -> CONTROL
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> CONTROL
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\xa0' # 0x41 -> NO-BREAK SPACE
- u'\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
- u'\xa2' # 0x4A -> CENT SIGN
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'|' # 0x4F -> VERTICAL LINE
- u'&' # 0x50 -> AMPERSAND
- u'\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u'!' # 0x5A -> EXCLAMATION MARK
- u'$' # 0x5B -> DOLLAR SIGN
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'\xac' # 0x5F -> NOT SIGN
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xa6' # 0x6A -> BROKEN BAR
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
- u'\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
- u'`' # 0x79 -> GRAVE ACCENT
- u':' # 0x7A -> COLON
- u'#' # 0x7B -> NUMBER SIGN
- u'@' # 0x7C -> COMMERCIAL AT
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'"' # 0x7F -> QUOTATION MARK
- u'\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
- u'\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
- u'\xb1' # 0x8F -> PLUS-MINUS SIGN
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
- u'\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
- u'\xb8' # 0x9D -> CEDILLA
- u'\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
- u'\xa4' # 0x9F -> CURRENCY SIGN
- u'\xb5' # 0xA0 -> MICRO SIGN
- u'~' # 0xA1 -> TILDE
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
- u'\xbf' # 0xAB -> INVERTED QUESTION MARK
- u'\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
- u'\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
- u'\xae' # 0xAF -> REGISTERED SIGN
- u'^' # 0xB0 -> CIRCUMFLEX ACCENT
- u'\xa3' # 0xB1 -> POUND SIGN
- u'\xa5' # 0xB2 -> YEN SIGN
- u'\xb7' # 0xB3 -> MIDDLE DOT
- u'\xa9' # 0xB4 -> COPYRIGHT SIGN
- u'\xa7' # 0xB5 -> SECTION SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
- u'[' # 0xBA -> LEFT SQUARE BRACKET
- u']' # 0xBB -> RIGHT SQUARE BRACKET
- u'\xaf' # 0xBC -> MACRON
- u'\xa8' # 0xBD -> DIAERESIS
- u'\xb4' # 0xBE -> ACUTE ACCENT
- u'\xd7' # 0xBF -> MULTIPLICATION SIGN
- u'{' # 0xC0 -> LEFT CURLY BRACKET
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
- u'}' # 0xD0 -> RIGHT CURLY BRACKET
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb9' # 0xDA -> SUPERSCRIPT ONE
- u'\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
- u'\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\\' # 0xE0 -> REVERSE SOLIDUS
- u'\xf7' # 0xE1 -> DIVISION SIGN
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\x9f' # 0xFF -> CONTROL
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> CONTROL
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> CONTROL
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> CONTROL
+ '\x8d' # 0x09 -> CONTROL
+ '\x8e' # 0x0A -> CONTROL
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> CONTROL
+ '\x85' # 0x15 -> CONTROL
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> CONTROL
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> CONTROL
+ '\x8f' # 0x1B -> CONTROL
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> CONTROL
+ '\x81' # 0x21 -> CONTROL
+ '\x82' # 0x22 -> CONTROL
+ '\x83' # 0x23 -> CONTROL
+ '\x84' # 0x24 -> CONTROL
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> CONTROL
+ '\x89' # 0x29 -> CONTROL
+ '\x8a' # 0x2A -> CONTROL
+ '\x8b' # 0x2B -> CONTROL
+ '\x8c' # 0x2C -> CONTROL
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> CONTROL
+ '\x91' # 0x31 -> CONTROL
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> CONTROL
+ '\x94' # 0x34 -> CONTROL
+ '\x95' # 0x35 -> CONTROL
+ '\x96' # 0x36 -> CONTROL
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> CONTROL
+ '\x99' # 0x39 -> CONTROL
+ '\x9a' # 0x3A -> CONTROL
+ '\x9b' # 0x3B -> CONTROL
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> CONTROL
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\xa0' # 0x41 -> NO-BREAK SPACE
+ '\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
+ '\xa2' # 0x4A -> CENT SIGN
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '|' # 0x4F -> VERTICAL LINE
+ '&' # 0x50 -> AMPERSAND
+ '\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ '!' # 0x5A -> EXCLAMATION MARK
+ '$' # 0x5B -> DOLLAR SIGN
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '\xac' # 0x5F -> NOT SIGN
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xa6' # 0x6A -> BROKEN BAR
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
+ '\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
+ '`' # 0x79 -> GRAVE ACCENT
+ ':' # 0x7A -> COLON
+ '#' # 0x7B -> NUMBER SIGN
+ '@' # 0x7C -> COMMERCIAL AT
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '"' # 0x7F -> QUOTATION MARK
+ '\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
+ '\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
+ '\xb1' # 0x8F -> PLUS-MINUS SIGN
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
+ '\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
+ '\xb8' # 0x9D -> CEDILLA
+ '\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
+ '\xa4' # 0x9F -> CURRENCY SIGN
+ '\xb5' # 0xA0 -> MICRO SIGN
+ '~' # 0xA1 -> TILDE
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
+ '\xbf' # 0xAB -> INVERTED QUESTION MARK
+ '\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
+ '\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
+ '\xae' # 0xAF -> REGISTERED SIGN
+ '^' # 0xB0 -> CIRCUMFLEX ACCENT
+ '\xa3' # 0xB1 -> POUND SIGN
+ '\xa5' # 0xB2 -> YEN SIGN
+ '\xb7' # 0xB3 -> MIDDLE DOT
+ '\xa9' # 0xB4 -> COPYRIGHT SIGN
+ '\xa7' # 0xB5 -> SECTION SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
+ '[' # 0xBA -> LEFT SQUARE BRACKET
+ ']' # 0xBB -> RIGHT SQUARE BRACKET
+ '\xaf' # 0xBC -> MACRON
+ '\xa8' # 0xBD -> DIAERESIS
+ '\xb4' # 0xBE -> ACUTE ACCENT
+ '\xd7' # 0xBF -> MULTIPLICATION SIGN
+ '{' # 0xC0 -> LEFT CURLY BRACKET
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
+ '}' # 0xD0 -> RIGHT CURLY BRACKET
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb9' # 0xDA -> SUPERSCRIPT ONE
+ '\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
+ '\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\\' # 0xE0 -> REVERSE SOLIDUS
+ '\xf7' # 0xE1 -> DIVISION SIGN
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\x9f' # 0xFF -> CONTROL
)
### Encoding table
diff --git a/Lib/encodings/cp1006.py b/Lib/encodings/cp1006.py
index e21e804eb9b..a1221c3ef1c 100644
--- a/Lib/encodings/cp1006.py
+++ b/Lib/encodings/cp1006.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u06f0' # 0xA1 -> EXTENDED ARABIC-INDIC DIGIT ZERO
- u'\u06f1' # 0xA2 -> EXTENDED ARABIC-INDIC DIGIT ONE
- u'\u06f2' # 0xA3 -> EXTENDED ARABIC-INDIC DIGIT TWO
- u'\u06f3' # 0xA4 -> EXTENDED ARABIC-INDIC DIGIT THREE
- u'\u06f4' # 0xA5 -> EXTENDED ARABIC-INDIC DIGIT FOUR
- u'\u06f5' # 0xA6 -> EXTENDED ARABIC-INDIC DIGIT FIVE
- u'\u06f6' # 0xA7 -> EXTENDED ARABIC-INDIC DIGIT SIX
- u'\u06f7' # 0xA8 -> EXTENDED ARABIC-INDIC DIGIT SEVEN
- u'\u06f8' # 0xA9 -> EXTENDED ARABIC-INDIC DIGIT EIGHT
- u'\u06f9' # 0xAA -> EXTENDED ARABIC-INDIC DIGIT NINE
- u'\u060c' # 0xAB -> ARABIC COMMA
- u'\u061b' # 0xAC -> ARABIC SEMICOLON
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u061f' # 0xAE -> ARABIC QUESTION MARK
- u'\ufe81' # 0xAF -> ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
- u'\ufe8d' # 0xB0 -> ARABIC LETTER ALEF ISOLATED FORM
- u'\ufe8e' # 0xB1 -> ARABIC LETTER ALEF FINAL FORM
- u'\ufe8e' # 0xB2 -> ARABIC LETTER ALEF FINAL FORM
- u'\ufe8f' # 0xB3 -> ARABIC LETTER BEH ISOLATED FORM
- u'\ufe91' # 0xB4 -> ARABIC LETTER BEH INITIAL FORM
- u'\ufb56' # 0xB5 -> ARABIC LETTER PEH ISOLATED FORM
- u'\ufb58' # 0xB6 -> ARABIC LETTER PEH INITIAL FORM
- u'\ufe93' # 0xB7 -> ARABIC LETTER TEH MARBUTA ISOLATED FORM
- u'\ufe95' # 0xB8 -> ARABIC LETTER TEH ISOLATED FORM
- u'\ufe97' # 0xB9 -> ARABIC LETTER TEH INITIAL FORM
- u'\ufb66' # 0xBA -> ARABIC LETTER TTEH ISOLATED FORM
- u'\ufb68' # 0xBB -> ARABIC LETTER TTEH INITIAL FORM
- u'\ufe99' # 0xBC -> ARABIC LETTER THEH ISOLATED FORM
- u'\ufe9b' # 0xBD -> ARABIC LETTER THEH INITIAL FORM
- u'\ufe9d' # 0xBE -> ARABIC LETTER JEEM ISOLATED FORM
- u'\ufe9f' # 0xBF -> ARABIC LETTER JEEM INITIAL FORM
- u'\ufb7a' # 0xC0 -> ARABIC LETTER TCHEH ISOLATED FORM
- u'\ufb7c' # 0xC1 -> ARABIC LETTER TCHEH INITIAL FORM
- u'\ufea1' # 0xC2 -> ARABIC LETTER HAH ISOLATED FORM
- u'\ufea3' # 0xC3 -> ARABIC LETTER HAH INITIAL FORM
- u'\ufea5' # 0xC4 -> ARABIC LETTER KHAH ISOLATED FORM
- u'\ufea7' # 0xC5 -> ARABIC LETTER KHAH INITIAL FORM
- u'\ufea9' # 0xC6 -> ARABIC LETTER DAL ISOLATED FORM
- u'\ufb84' # 0xC7 -> ARABIC LETTER DAHAL ISOLATED FORMN
- u'\ufeab' # 0xC8 -> ARABIC LETTER THAL ISOLATED FORM
- u'\ufead' # 0xC9 -> ARABIC LETTER REH ISOLATED FORM
- u'\ufb8c' # 0xCA -> ARABIC LETTER RREH ISOLATED FORM
- u'\ufeaf' # 0xCB -> ARABIC LETTER ZAIN ISOLATED FORM
- u'\ufb8a' # 0xCC -> ARABIC LETTER JEH ISOLATED FORM
- u'\ufeb1' # 0xCD -> ARABIC LETTER SEEN ISOLATED FORM
- u'\ufeb3' # 0xCE -> ARABIC LETTER SEEN INITIAL FORM
- u'\ufeb5' # 0xCF -> ARABIC LETTER SHEEN ISOLATED FORM
- u'\ufeb7' # 0xD0 -> ARABIC LETTER SHEEN INITIAL FORM
- u'\ufeb9' # 0xD1 -> ARABIC LETTER SAD ISOLATED FORM
- u'\ufebb' # 0xD2 -> ARABIC LETTER SAD INITIAL FORM
- u'\ufebd' # 0xD3 -> ARABIC LETTER DAD ISOLATED FORM
- u'\ufebf' # 0xD4 -> ARABIC LETTER DAD INITIAL FORM
- u'\ufec1' # 0xD5 -> ARABIC LETTER TAH ISOLATED FORM
- u'\ufec5' # 0xD6 -> ARABIC LETTER ZAH ISOLATED FORM
- u'\ufec9' # 0xD7 -> ARABIC LETTER AIN ISOLATED FORM
- u'\ufeca' # 0xD8 -> ARABIC LETTER AIN FINAL FORM
- u'\ufecb' # 0xD9 -> ARABIC LETTER AIN INITIAL FORM
- u'\ufecc' # 0xDA -> ARABIC LETTER AIN MEDIAL FORM
- u'\ufecd' # 0xDB -> ARABIC LETTER GHAIN ISOLATED FORM
- u'\ufece' # 0xDC -> ARABIC LETTER GHAIN FINAL FORM
- u'\ufecf' # 0xDD -> ARABIC LETTER GHAIN INITIAL FORM
- u'\ufed0' # 0xDE -> ARABIC LETTER GHAIN MEDIAL FORM
- u'\ufed1' # 0xDF -> ARABIC LETTER FEH ISOLATED FORM
- u'\ufed3' # 0xE0 -> ARABIC LETTER FEH INITIAL FORM
- u'\ufed5' # 0xE1 -> ARABIC LETTER QAF ISOLATED FORM
- u'\ufed7' # 0xE2 -> ARABIC LETTER QAF INITIAL FORM
- u'\ufed9' # 0xE3 -> ARABIC LETTER KAF ISOLATED FORM
- u'\ufedb' # 0xE4 -> ARABIC LETTER KAF INITIAL FORM
- u'\ufb92' # 0xE5 -> ARABIC LETTER GAF ISOLATED FORM
- u'\ufb94' # 0xE6 -> ARABIC LETTER GAF INITIAL FORM
- u'\ufedd' # 0xE7 -> ARABIC LETTER LAM ISOLATED FORM
- u'\ufedf' # 0xE8 -> ARABIC LETTER LAM INITIAL FORM
- u'\ufee0' # 0xE9 -> ARABIC LETTER LAM MEDIAL FORM
- u'\ufee1' # 0xEA -> ARABIC LETTER MEEM ISOLATED FORM
- u'\ufee3' # 0xEB -> ARABIC LETTER MEEM INITIAL FORM
- u'\ufb9e' # 0xEC -> ARABIC LETTER NOON GHUNNA ISOLATED FORM
- u'\ufee5' # 0xED -> ARABIC LETTER NOON ISOLATED FORM
- u'\ufee7' # 0xEE -> ARABIC LETTER NOON INITIAL FORM
- u'\ufe85' # 0xEF -> ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
- u'\ufeed' # 0xF0 -> ARABIC LETTER WAW ISOLATED FORM
- u'\ufba6' # 0xF1 -> ARABIC LETTER HEH GOAL ISOLATED FORM
- u'\ufba8' # 0xF2 -> ARABIC LETTER HEH GOAL INITIAL FORM
- u'\ufba9' # 0xF3 -> ARABIC LETTER HEH GOAL MEDIAL FORM
- u'\ufbaa' # 0xF4 -> ARABIC LETTER HEH DOACHASHMEE ISOLATED FORM
- u'\ufe80' # 0xF5 -> ARABIC LETTER HAMZA ISOLATED FORM
- u'\ufe89' # 0xF6 -> ARABIC LETTER YEH WITH HAMZA ABOVE ISOLATED FORM
- u'\ufe8a' # 0xF7 -> ARABIC LETTER YEH WITH HAMZA ABOVE FINAL FORM
- u'\ufe8b' # 0xF8 -> ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
- u'\ufef1' # 0xF9 -> ARABIC LETTER YEH ISOLATED FORM
- u'\ufef2' # 0xFA -> ARABIC LETTER YEH FINAL FORM
- u'\ufef3' # 0xFB -> ARABIC LETTER YEH INITIAL FORM
- u'\ufbb0' # 0xFC -> ARABIC LETTER YEH BARREE WITH HAMZA ABOVE ISOLATED FORM
- u'\ufbae' # 0xFD -> ARABIC LETTER YEH BARREE ISOLATED FORM
- u'\ufe7c' # 0xFE -> ARABIC SHADDA ISOLATED FORM
- u'\ufe7d' # 0xFF -> ARABIC SHADDA MEDIAL FORM
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u06f0' # 0xA1 -> EXTENDED ARABIC-INDIC DIGIT ZERO
+ '\u06f1' # 0xA2 -> EXTENDED ARABIC-INDIC DIGIT ONE
+ '\u06f2' # 0xA3 -> EXTENDED ARABIC-INDIC DIGIT TWO
+ '\u06f3' # 0xA4 -> EXTENDED ARABIC-INDIC DIGIT THREE
+ '\u06f4' # 0xA5 -> EXTENDED ARABIC-INDIC DIGIT FOUR
+ '\u06f5' # 0xA6 -> EXTENDED ARABIC-INDIC DIGIT FIVE
+ '\u06f6' # 0xA7 -> EXTENDED ARABIC-INDIC DIGIT SIX
+ '\u06f7' # 0xA8 -> EXTENDED ARABIC-INDIC DIGIT SEVEN
+ '\u06f8' # 0xA9 -> EXTENDED ARABIC-INDIC DIGIT EIGHT
+ '\u06f9' # 0xAA -> EXTENDED ARABIC-INDIC DIGIT NINE
+ '\u060c' # 0xAB -> ARABIC COMMA
+ '\u061b' # 0xAC -> ARABIC SEMICOLON
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u061f' # 0xAE -> ARABIC QUESTION MARK
+ '\ufe81' # 0xAF -> ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
+ '\ufe8d' # 0xB0 -> ARABIC LETTER ALEF ISOLATED FORM
+ '\ufe8e' # 0xB1 -> ARABIC LETTER ALEF FINAL FORM
+ '\ufe8e' # 0xB2 -> ARABIC LETTER ALEF FINAL FORM
+ '\ufe8f' # 0xB3 -> ARABIC LETTER BEH ISOLATED FORM
+ '\ufe91' # 0xB4 -> ARABIC LETTER BEH INITIAL FORM
+ '\ufb56' # 0xB5 -> ARABIC LETTER PEH ISOLATED FORM
+ '\ufb58' # 0xB6 -> ARABIC LETTER PEH INITIAL FORM
+ '\ufe93' # 0xB7 -> ARABIC LETTER TEH MARBUTA ISOLATED FORM
+ '\ufe95' # 0xB8 -> ARABIC LETTER TEH ISOLATED FORM
+ '\ufe97' # 0xB9 -> ARABIC LETTER TEH INITIAL FORM
+ '\ufb66' # 0xBA -> ARABIC LETTER TTEH ISOLATED FORM
+ '\ufb68' # 0xBB -> ARABIC LETTER TTEH INITIAL FORM
+ '\ufe99' # 0xBC -> ARABIC LETTER THEH ISOLATED FORM
+ '\ufe9b' # 0xBD -> ARABIC LETTER THEH INITIAL FORM
+ '\ufe9d' # 0xBE -> ARABIC LETTER JEEM ISOLATED FORM
+ '\ufe9f' # 0xBF -> ARABIC LETTER JEEM INITIAL FORM
+ '\ufb7a' # 0xC0 -> ARABIC LETTER TCHEH ISOLATED FORM
+ '\ufb7c' # 0xC1 -> ARABIC LETTER TCHEH INITIAL FORM
+ '\ufea1' # 0xC2 -> ARABIC LETTER HAH ISOLATED FORM
+ '\ufea3' # 0xC3 -> ARABIC LETTER HAH INITIAL FORM
+ '\ufea5' # 0xC4 -> ARABIC LETTER KHAH ISOLATED FORM
+ '\ufea7' # 0xC5 -> ARABIC LETTER KHAH INITIAL FORM
+ '\ufea9' # 0xC6 -> ARABIC LETTER DAL ISOLATED FORM
+ '\ufb84' # 0xC7 -> ARABIC LETTER DAHAL ISOLATED FORMN
+ '\ufeab' # 0xC8 -> ARABIC LETTER THAL ISOLATED FORM
+ '\ufead' # 0xC9 -> ARABIC LETTER REH ISOLATED FORM
+ '\ufb8c' # 0xCA -> ARABIC LETTER RREH ISOLATED FORM
+ '\ufeaf' # 0xCB -> ARABIC LETTER ZAIN ISOLATED FORM
+ '\ufb8a' # 0xCC -> ARABIC LETTER JEH ISOLATED FORM
+ '\ufeb1' # 0xCD -> ARABIC LETTER SEEN ISOLATED FORM
+ '\ufeb3' # 0xCE -> ARABIC LETTER SEEN INITIAL FORM
+ '\ufeb5' # 0xCF -> ARABIC LETTER SHEEN ISOLATED FORM
+ '\ufeb7' # 0xD0 -> ARABIC LETTER SHEEN INITIAL FORM
+ '\ufeb9' # 0xD1 -> ARABIC LETTER SAD ISOLATED FORM
+ '\ufebb' # 0xD2 -> ARABIC LETTER SAD INITIAL FORM
+ '\ufebd' # 0xD3 -> ARABIC LETTER DAD ISOLATED FORM
+ '\ufebf' # 0xD4 -> ARABIC LETTER DAD INITIAL FORM
+ '\ufec1' # 0xD5 -> ARABIC LETTER TAH ISOLATED FORM
+ '\ufec5' # 0xD6 -> ARABIC LETTER ZAH ISOLATED FORM
+ '\ufec9' # 0xD7 -> ARABIC LETTER AIN ISOLATED FORM
+ '\ufeca' # 0xD8 -> ARABIC LETTER AIN FINAL FORM
+ '\ufecb' # 0xD9 -> ARABIC LETTER AIN INITIAL FORM
+ '\ufecc' # 0xDA -> ARABIC LETTER AIN MEDIAL FORM
+ '\ufecd' # 0xDB -> ARABIC LETTER GHAIN ISOLATED FORM
+ '\ufece' # 0xDC -> ARABIC LETTER GHAIN FINAL FORM
+ '\ufecf' # 0xDD -> ARABIC LETTER GHAIN INITIAL FORM
+ '\ufed0' # 0xDE -> ARABIC LETTER GHAIN MEDIAL FORM
+ '\ufed1' # 0xDF -> ARABIC LETTER FEH ISOLATED FORM
+ '\ufed3' # 0xE0 -> ARABIC LETTER FEH INITIAL FORM
+ '\ufed5' # 0xE1 -> ARABIC LETTER QAF ISOLATED FORM
+ '\ufed7' # 0xE2 -> ARABIC LETTER QAF INITIAL FORM
+ '\ufed9' # 0xE3 -> ARABIC LETTER KAF ISOLATED FORM
+ '\ufedb' # 0xE4 -> ARABIC LETTER KAF INITIAL FORM
+ '\ufb92' # 0xE5 -> ARABIC LETTER GAF ISOLATED FORM
+ '\ufb94' # 0xE6 -> ARABIC LETTER GAF INITIAL FORM
+ '\ufedd' # 0xE7 -> ARABIC LETTER LAM ISOLATED FORM
+ '\ufedf' # 0xE8 -> ARABIC LETTER LAM INITIAL FORM
+ '\ufee0' # 0xE9 -> ARABIC LETTER LAM MEDIAL FORM
+ '\ufee1' # 0xEA -> ARABIC LETTER MEEM ISOLATED FORM
+ '\ufee3' # 0xEB -> ARABIC LETTER MEEM INITIAL FORM
+ '\ufb9e' # 0xEC -> ARABIC LETTER NOON GHUNNA ISOLATED FORM
+ '\ufee5' # 0xED -> ARABIC LETTER NOON ISOLATED FORM
+ '\ufee7' # 0xEE -> ARABIC LETTER NOON INITIAL FORM
+ '\ufe85' # 0xEF -> ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
+ '\ufeed' # 0xF0 -> ARABIC LETTER WAW ISOLATED FORM
+ '\ufba6' # 0xF1 -> ARABIC LETTER HEH GOAL ISOLATED FORM
+ '\ufba8' # 0xF2 -> ARABIC LETTER HEH GOAL INITIAL FORM
+ '\ufba9' # 0xF3 -> ARABIC LETTER HEH GOAL MEDIAL FORM
+ '\ufbaa' # 0xF4 -> ARABIC LETTER HEH DOACHASHMEE ISOLATED FORM
+ '\ufe80' # 0xF5 -> ARABIC LETTER HAMZA ISOLATED FORM
+ '\ufe89' # 0xF6 -> ARABIC LETTER YEH WITH HAMZA ABOVE ISOLATED FORM
+ '\ufe8a' # 0xF7 -> ARABIC LETTER YEH WITH HAMZA ABOVE FINAL FORM
+ '\ufe8b' # 0xF8 -> ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
+ '\ufef1' # 0xF9 -> ARABIC LETTER YEH ISOLATED FORM
+ '\ufef2' # 0xFA -> ARABIC LETTER YEH FINAL FORM
+ '\ufef3' # 0xFB -> ARABIC LETTER YEH INITIAL FORM
+ '\ufbb0' # 0xFC -> ARABIC LETTER YEH BARREE WITH HAMZA ABOVE ISOLATED FORM
+ '\ufbae' # 0xFD -> ARABIC LETTER YEH BARREE ISOLATED FORM
+ '\ufe7c' # 0xFE -> ARABIC SHADDA ISOLATED FORM
+ '\ufe7d' # 0xFF -> ARABIC SHADDA MEDIAL FORM
)
### Encoding table
diff --git a/Lib/encodings/cp1026.py b/Lib/encodings/cp1026.py
index 45bbe626fdf..46f71f74dae 100644
--- a/Lib/encodings/cp1026.py
+++ b/Lib/encodings/cp1026.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> CONTROL
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> CONTROL
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> CONTROL
- u'\x8d' # 0x09 -> CONTROL
- u'\x8e' # 0x0A -> CONTROL
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> CONTROL
- u'\x85' # 0x15 -> CONTROL
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> CONTROL
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> CONTROL
- u'\x8f' # 0x1B -> CONTROL
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> CONTROL
- u'\x81' # 0x21 -> CONTROL
- u'\x82' # 0x22 -> CONTROL
- u'\x83' # 0x23 -> CONTROL
- u'\x84' # 0x24 -> CONTROL
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> CONTROL
- u'\x89' # 0x29 -> CONTROL
- u'\x8a' # 0x2A -> CONTROL
- u'\x8b' # 0x2B -> CONTROL
- u'\x8c' # 0x2C -> CONTROL
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> CONTROL
- u'\x91' # 0x31 -> CONTROL
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> CONTROL
- u'\x94' # 0x34 -> CONTROL
- u'\x95' # 0x35 -> CONTROL
- u'\x96' # 0x36 -> CONTROL
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> CONTROL
- u'\x99' # 0x39 -> CONTROL
- u'\x9a' # 0x3A -> CONTROL
- u'\x9b' # 0x3B -> CONTROL
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> CONTROL
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\xa0' # 0x41 -> NO-BREAK SPACE
- u'\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'{' # 0x48 -> LEFT CURLY BRACKET
- u'\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
- u'\xc7' # 0x4A -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'!' # 0x4F -> EXCLAMATION MARK
- u'&' # 0x50 -> AMPERSAND
- u'\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u'\u011e' # 0x5A -> LATIN CAPITAL LETTER G WITH BREVE
- u'\u0130' # 0x5B -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'^' # 0x5F -> CIRCUMFLEX ACCENT
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'[' # 0x68 -> LEFT SQUARE BRACKET
- u'\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\u015f' # 0x6A -> LATIN SMALL LETTER S WITH CEDILLA
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
- u'\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\u0131' # 0x79 -> LATIN SMALL LETTER DOTLESS I
- u':' # 0x7A -> COLON
- u'\xd6' # 0x7B -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\u015e' # 0x7C -> LATIN CAPITAL LETTER S WITH CEDILLA
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'\xdc' # 0x7F -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'}' # 0x8C -> RIGHT CURLY BRACKET
- u'`' # 0x8D -> GRAVE ACCENT
- u'\xa6' # 0x8E -> BROKEN BAR
- u'\xb1' # 0x8F -> PLUS-MINUS SIGN
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
- u'\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
- u'\xb8' # 0x9D -> CEDILLA
- u'\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
- u'\xa4' # 0x9F -> CURRENCY SIGN
- u'\xb5' # 0xA0 -> MICRO SIGN
- u'\xf6' # 0xA1 -> LATIN SMALL LETTER O WITH DIAERESIS
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
- u'\xbf' # 0xAB -> INVERTED QUESTION MARK
- u']' # 0xAC -> RIGHT SQUARE BRACKET
- u'$' # 0xAD -> DOLLAR SIGN
- u'@' # 0xAE -> COMMERCIAL AT
- u'\xae' # 0xAF -> REGISTERED SIGN
- u'\xa2' # 0xB0 -> CENT SIGN
- u'\xa3' # 0xB1 -> POUND SIGN
- u'\xa5' # 0xB2 -> YEN SIGN
- u'\xb7' # 0xB3 -> MIDDLE DOT
- u'\xa9' # 0xB4 -> COPYRIGHT SIGN
- u'\xa7' # 0xB5 -> SECTION SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
- u'\xac' # 0xBA -> NOT SIGN
- u'|' # 0xBB -> VERTICAL LINE
- u'\xaf' # 0xBC -> MACRON
- u'\xa8' # 0xBD -> DIAERESIS
- u'\xb4' # 0xBE -> ACUTE ACCENT
- u'\xd7' # 0xBF -> MULTIPLICATION SIGN
- u'\xe7' # 0xC0 -> LATIN SMALL LETTER C WITH CEDILLA
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'~' # 0xCC -> TILDE
- u'\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
- u'\u011f' # 0xD0 -> LATIN SMALL LETTER G WITH BREVE
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb9' # 0xDA -> SUPERSCRIPT ONE
- u'\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\\' # 0xDC -> REVERSE SOLIDUS
- u'\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
- u'\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xfc' # 0xE0 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xf7' # 0xE1 -> DIVISION SIGN
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'#' # 0xEC -> NUMBER SIGN
- u'\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'"' # 0xFC -> QUOTATION MARK
- u'\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\x9f' # 0xFF -> CONTROL
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> CONTROL
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> CONTROL
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> CONTROL
+ '\x8d' # 0x09 -> CONTROL
+ '\x8e' # 0x0A -> CONTROL
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> CONTROL
+ '\x85' # 0x15 -> CONTROL
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> CONTROL
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> CONTROL
+ '\x8f' # 0x1B -> CONTROL
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> CONTROL
+ '\x81' # 0x21 -> CONTROL
+ '\x82' # 0x22 -> CONTROL
+ '\x83' # 0x23 -> CONTROL
+ '\x84' # 0x24 -> CONTROL
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> CONTROL
+ '\x89' # 0x29 -> CONTROL
+ '\x8a' # 0x2A -> CONTROL
+ '\x8b' # 0x2B -> CONTROL
+ '\x8c' # 0x2C -> CONTROL
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> CONTROL
+ '\x91' # 0x31 -> CONTROL
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> CONTROL
+ '\x94' # 0x34 -> CONTROL
+ '\x95' # 0x35 -> CONTROL
+ '\x96' # 0x36 -> CONTROL
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> CONTROL
+ '\x99' # 0x39 -> CONTROL
+ '\x9a' # 0x3A -> CONTROL
+ '\x9b' # 0x3B -> CONTROL
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> CONTROL
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\xa0' # 0x41 -> NO-BREAK SPACE
+ '\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '{' # 0x48 -> LEFT CURLY BRACKET
+ '\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
+ '\xc7' # 0x4A -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '!' # 0x4F -> EXCLAMATION MARK
+ '&' # 0x50 -> AMPERSAND
+ '\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ '\u011e' # 0x5A -> LATIN CAPITAL LETTER G WITH BREVE
+ '\u0130' # 0x5B -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '^' # 0x5F -> CIRCUMFLEX ACCENT
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '[' # 0x68 -> LEFT SQUARE BRACKET
+ '\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\u015f' # 0x6A -> LATIN SMALL LETTER S WITH CEDILLA
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
+ '\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\u0131' # 0x79 -> LATIN SMALL LETTER DOTLESS I
+ ':' # 0x7A -> COLON
+ '\xd6' # 0x7B -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\u015e' # 0x7C -> LATIN CAPITAL LETTER S WITH CEDILLA
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '\xdc' # 0x7F -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '}' # 0x8C -> RIGHT CURLY BRACKET
+ '`' # 0x8D -> GRAVE ACCENT
+ '\xa6' # 0x8E -> BROKEN BAR
+ '\xb1' # 0x8F -> PLUS-MINUS SIGN
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
+ '\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
+ '\xb8' # 0x9D -> CEDILLA
+ '\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
+ '\xa4' # 0x9F -> CURRENCY SIGN
+ '\xb5' # 0xA0 -> MICRO SIGN
+ '\xf6' # 0xA1 -> LATIN SMALL LETTER O WITH DIAERESIS
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
+ '\xbf' # 0xAB -> INVERTED QUESTION MARK
+ ']' # 0xAC -> RIGHT SQUARE BRACKET
+ '$' # 0xAD -> DOLLAR SIGN
+ '@' # 0xAE -> COMMERCIAL AT
+ '\xae' # 0xAF -> REGISTERED SIGN
+ '\xa2' # 0xB0 -> CENT SIGN
+ '\xa3' # 0xB1 -> POUND SIGN
+ '\xa5' # 0xB2 -> YEN SIGN
+ '\xb7' # 0xB3 -> MIDDLE DOT
+ '\xa9' # 0xB4 -> COPYRIGHT SIGN
+ '\xa7' # 0xB5 -> SECTION SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
+ '\xac' # 0xBA -> NOT SIGN
+ '|' # 0xBB -> VERTICAL LINE
+ '\xaf' # 0xBC -> MACRON
+ '\xa8' # 0xBD -> DIAERESIS
+ '\xb4' # 0xBE -> ACUTE ACCENT
+ '\xd7' # 0xBF -> MULTIPLICATION SIGN
+ '\xe7' # 0xC0 -> LATIN SMALL LETTER C WITH CEDILLA
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '~' # 0xCC -> TILDE
+ '\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
+ '\u011f' # 0xD0 -> LATIN SMALL LETTER G WITH BREVE
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb9' # 0xDA -> SUPERSCRIPT ONE
+ '\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\\' # 0xDC -> REVERSE SOLIDUS
+ '\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
+ '\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xfc' # 0xE0 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xf7' # 0xE1 -> DIVISION SIGN
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '#' # 0xEC -> NUMBER SIGN
+ '\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '"' # 0xFC -> QUOTATION MARK
+ '\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\x9f' # 0xFF -> CONTROL
)
### Encoding table
diff --git a/Lib/encodings/cp1140.py b/Lib/encodings/cp1140.py
index 7e507fd8530..0a919d837e1 100644
--- a/Lib/encodings/cp1140.py
+++ b/Lib/encodings/cp1140.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> CONTROL
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> CONTROL
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> CONTROL
- u'\x8d' # 0x09 -> CONTROL
- u'\x8e' # 0x0A -> CONTROL
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> CONTROL
- u'\x85' # 0x15 -> CONTROL
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> CONTROL
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> CONTROL
- u'\x8f' # 0x1B -> CONTROL
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> CONTROL
- u'\x81' # 0x21 -> CONTROL
- u'\x82' # 0x22 -> CONTROL
- u'\x83' # 0x23 -> CONTROL
- u'\x84' # 0x24 -> CONTROL
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> CONTROL
- u'\x89' # 0x29 -> CONTROL
- u'\x8a' # 0x2A -> CONTROL
- u'\x8b' # 0x2B -> CONTROL
- u'\x8c' # 0x2C -> CONTROL
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> CONTROL
- u'\x91' # 0x31 -> CONTROL
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> CONTROL
- u'\x94' # 0x34 -> CONTROL
- u'\x95' # 0x35 -> CONTROL
- u'\x96' # 0x36 -> CONTROL
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> CONTROL
- u'\x99' # 0x39 -> CONTROL
- u'\x9a' # 0x3A -> CONTROL
- u'\x9b' # 0x3B -> CONTROL
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> CONTROL
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\xa0' # 0x41 -> NO-BREAK SPACE
- u'\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
- u'\xa2' # 0x4A -> CENT SIGN
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'|' # 0x4F -> VERTICAL LINE
- u'&' # 0x50 -> AMPERSAND
- u'\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u'!' # 0x5A -> EXCLAMATION MARK
- u'$' # 0x5B -> DOLLAR SIGN
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'\xac' # 0x5F -> NOT SIGN
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xa6' # 0x6A -> BROKEN BAR
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
- u'\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
- u'`' # 0x79 -> GRAVE ACCENT
- u':' # 0x7A -> COLON
- u'#' # 0x7B -> NUMBER SIGN
- u'@' # 0x7C -> COMMERCIAL AT
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'"' # 0x7F -> QUOTATION MARK
- u'\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
- u'\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
- u'\xb1' # 0x8F -> PLUS-MINUS SIGN
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
- u'\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
- u'\xb8' # 0x9D -> CEDILLA
- u'\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
- u'\u20ac' # 0x9F -> EURO SIGN
- u'\xb5' # 0xA0 -> MICRO SIGN
- u'~' # 0xA1 -> TILDE
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
- u'\xbf' # 0xAB -> INVERTED QUESTION MARK
- u'\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
- u'\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
- u'\xae' # 0xAF -> REGISTERED SIGN
- u'^' # 0xB0 -> CIRCUMFLEX ACCENT
- u'\xa3' # 0xB1 -> POUND SIGN
- u'\xa5' # 0xB2 -> YEN SIGN
- u'\xb7' # 0xB3 -> MIDDLE DOT
- u'\xa9' # 0xB4 -> COPYRIGHT SIGN
- u'\xa7' # 0xB5 -> SECTION SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
- u'[' # 0xBA -> LEFT SQUARE BRACKET
- u']' # 0xBB -> RIGHT SQUARE BRACKET
- u'\xaf' # 0xBC -> MACRON
- u'\xa8' # 0xBD -> DIAERESIS
- u'\xb4' # 0xBE -> ACUTE ACCENT
- u'\xd7' # 0xBF -> MULTIPLICATION SIGN
- u'{' # 0xC0 -> LEFT CURLY BRACKET
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
- u'}' # 0xD0 -> RIGHT CURLY BRACKET
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb9' # 0xDA -> SUPERSCRIPT ONE
- u'\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
- u'\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\\' # 0xE0 -> REVERSE SOLIDUS
- u'\xf7' # 0xE1 -> DIVISION SIGN
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\x9f' # 0xFF -> CONTROL
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> CONTROL
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> CONTROL
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> CONTROL
+ '\x8d' # 0x09 -> CONTROL
+ '\x8e' # 0x0A -> CONTROL
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> CONTROL
+ '\x85' # 0x15 -> CONTROL
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> CONTROL
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> CONTROL
+ '\x8f' # 0x1B -> CONTROL
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> CONTROL
+ '\x81' # 0x21 -> CONTROL
+ '\x82' # 0x22 -> CONTROL
+ '\x83' # 0x23 -> CONTROL
+ '\x84' # 0x24 -> CONTROL
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> CONTROL
+ '\x89' # 0x29 -> CONTROL
+ '\x8a' # 0x2A -> CONTROL
+ '\x8b' # 0x2B -> CONTROL
+ '\x8c' # 0x2C -> CONTROL
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> CONTROL
+ '\x91' # 0x31 -> CONTROL
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> CONTROL
+ '\x94' # 0x34 -> CONTROL
+ '\x95' # 0x35 -> CONTROL
+ '\x96' # 0x36 -> CONTROL
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> CONTROL
+ '\x99' # 0x39 -> CONTROL
+ '\x9a' # 0x3A -> CONTROL
+ '\x9b' # 0x3B -> CONTROL
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> CONTROL
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\xa0' # 0x41 -> NO-BREAK SPACE
+ '\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
+ '\xa2' # 0x4A -> CENT SIGN
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '|' # 0x4F -> VERTICAL LINE
+ '&' # 0x50 -> AMPERSAND
+ '\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ '!' # 0x5A -> EXCLAMATION MARK
+ '$' # 0x5B -> DOLLAR SIGN
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '\xac' # 0x5F -> NOT SIGN
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xa6' # 0x6A -> BROKEN BAR
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
+ '\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
+ '`' # 0x79 -> GRAVE ACCENT
+ ':' # 0x7A -> COLON
+ '#' # 0x7B -> NUMBER SIGN
+ '@' # 0x7C -> COMMERCIAL AT
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '"' # 0x7F -> QUOTATION MARK
+ '\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
+ '\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
+ '\xb1' # 0x8F -> PLUS-MINUS SIGN
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
+ '\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
+ '\xb8' # 0x9D -> CEDILLA
+ '\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
+ '\u20ac' # 0x9F -> EURO SIGN
+ '\xb5' # 0xA0 -> MICRO SIGN
+ '~' # 0xA1 -> TILDE
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
+ '\xbf' # 0xAB -> INVERTED QUESTION MARK
+ '\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
+ '\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
+ '\xae' # 0xAF -> REGISTERED SIGN
+ '^' # 0xB0 -> CIRCUMFLEX ACCENT
+ '\xa3' # 0xB1 -> POUND SIGN
+ '\xa5' # 0xB2 -> YEN SIGN
+ '\xb7' # 0xB3 -> MIDDLE DOT
+ '\xa9' # 0xB4 -> COPYRIGHT SIGN
+ '\xa7' # 0xB5 -> SECTION SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
+ '[' # 0xBA -> LEFT SQUARE BRACKET
+ ']' # 0xBB -> RIGHT SQUARE BRACKET
+ '\xaf' # 0xBC -> MACRON
+ '\xa8' # 0xBD -> DIAERESIS
+ '\xb4' # 0xBE -> ACUTE ACCENT
+ '\xd7' # 0xBF -> MULTIPLICATION SIGN
+ '{' # 0xC0 -> LEFT CURLY BRACKET
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
+ '}' # 0xD0 -> RIGHT CURLY BRACKET
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb9' # 0xDA -> SUPERSCRIPT ONE
+ '\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
+ '\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\\' # 0xE0 -> REVERSE SOLIDUS
+ '\xf7' # 0xE1 -> DIVISION SIGN
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\x9f' # 0xFF -> CONTROL
)
### Encoding table
diff --git a/Lib/encodings/cp1250.py b/Lib/encodings/cp1250.py
index d620b893358..c2c83aaf3e8 100644
--- a/Lib/encodings/cp1250.py
+++ b/Lib/encodings/cp1250.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\ufffe' # 0x83 -> UNDEFINED
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\ufffe' # 0x88 -> UNDEFINED
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u015a' # 0x8C -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u0164' # 0x8D -> LATIN CAPITAL LETTER T WITH CARON
- u'\u017d' # 0x8E -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\ufffe' # 0x98 -> UNDEFINED
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u015b' # 0x9C -> LATIN SMALL LETTER S WITH ACUTE
- u'\u0165' # 0x9D -> LATIN SMALL LETTER T WITH CARON
- u'\u017e' # 0x9E -> LATIN SMALL LETTER Z WITH CARON
- u'\u017a' # 0x9F -> LATIN SMALL LETTER Z WITH ACUTE
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u02c7' # 0xA1 -> CARON
- u'\u02d8' # 0xA2 -> BREVE
- u'\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\u0104' # 0xA5 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u02db' # 0xB2 -> OGONEK
- u'\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\u0105' # 0xB9 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u013d' # 0xBC -> LATIN CAPITAL LETTER L WITH CARON
- u'\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT
- u'\u013e' # 0xBE -> LATIN SMALL LETTER L WITH CARON
- u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE
- u'\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON
- u'\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE
- u'\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON
- u'\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA
- u'\u02d9' # 0xFF -> DOT ABOVE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\ufffe' # 0x83 -> UNDEFINED
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\ufffe' # 0x88 -> UNDEFINED
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u015a' # 0x8C -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u0164' # 0x8D -> LATIN CAPITAL LETTER T WITH CARON
+ '\u017d' # 0x8E -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\ufffe' # 0x98 -> UNDEFINED
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u015b' # 0x9C -> LATIN SMALL LETTER S WITH ACUTE
+ '\u0165' # 0x9D -> LATIN SMALL LETTER T WITH CARON
+ '\u017e' # 0x9E -> LATIN SMALL LETTER Z WITH CARON
+ '\u017a' # 0x9F -> LATIN SMALL LETTER Z WITH ACUTE
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u02c7' # 0xA1 -> CARON
+ '\u02d8' # 0xA2 -> BREVE
+ '\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\u0104' # 0xA5 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u02db' # 0xB2 -> OGONEK
+ '\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\u0105' # 0xB9 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u013d' # 0xBC -> LATIN CAPITAL LETTER L WITH CARON
+ '\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT
+ '\u013e' # 0xBE -> LATIN SMALL LETTER L WITH CARON
+ '\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE
+ '\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON
+ '\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE
+ '\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON
+ '\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA
+ '\u02d9' # 0xFF -> DOT ABOVE
)
### Encoding table
diff --git a/Lib/encodings/cp1251.py b/Lib/encodings/cp1251.py
index 216771fa4cc..22bc66002d3 100644
--- a/Lib/encodings/cp1251.py
+++ b/Lib/encodings/cp1251.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u0402' # 0x80 -> CYRILLIC CAPITAL LETTER DJE
- u'\u0403' # 0x81 -> CYRILLIC CAPITAL LETTER GJE
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0453' # 0x83 -> CYRILLIC SMALL LETTER GJE
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u20ac' # 0x88 -> EURO SIGN
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\u0409' # 0x8A -> CYRILLIC CAPITAL LETTER LJE
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u040a' # 0x8C -> CYRILLIC CAPITAL LETTER NJE
- u'\u040c' # 0x8D -> CYRILLIC CAPITAL LETTER KJE
- u'\u040b' # 0x8E -> CYRILLIC CAPITAL LETTER TSHE
- u'\u040f' # 0x8F -> CYRILLIC CAPITAL LETTER DZHE
- u'\u0452' # 0x90 -> CYRILLIC SMALL LETTER DJE
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\ufffe' # 0x98 -> UNDEFINED
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\u0459' # 0x9A -> CYRILLIC SMALL LETTER LJE
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u045a' # 0x9C -> CYRILLIC SMALL LETTER NJE
- u'\u045c' # 0x9D -> CYRILLIC SMALL LETTER KJE
- u'\u045b' # 0x9E -> CYRILLIC SMALL LETTER TSHE
- u'\u045f' # 0x9F -> CYRILLIC SMALL LETTER DZHE
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u040e' # 0xA1 -> CYRILLIC CAPITAL LETTER SHORT U
- u'\u045e' # 0xA2 -> CYRILLIC SMALL LETTER SHORT U
- u'\u0408' # 0xA3 -> CYRILLIC CAPITAL LETTER JE
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\u0490' # 0xA5 -> CYRILLIC CAPITAL LETTER GHE WITH UPTURN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\u0401' # 0xA8 -> CYRILLIC CAPITAL LETTER IO
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u0404' # 0xAA -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\u0407' # 0xAF -> CYRILLIC CAPITAL LETTER YI
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u0406' # 0xB2 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0456' # 0xB3 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0491' # 0xB4 -> CYRILLIC SMALL LETTER GHE WITH UPTURN
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u0451' # 0xB8 -> CYRILLIC SMALL LETTER IO
- u'\u2116' # 0xB9 -> NUMERO SIGN
- u'\u0454' # 0xBA -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u0458' # 0xBC -> CYRILLIC SMALL LETTER JE
- u'\u0405' # 0xBD -> CYRILLIC CAPITAL LETTER DZE
- u'\u0455' # 0xBE -> CYRILLIC SMALL LETTER DZE
- u'\u0457' # 0xBF -> CYRILLIC SMALL LETTER YI
- u'\u0410' # 0xC0 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0xC1 -> CYRILLIC CAPITAL LETTER BE
- u'\u0412' # 0xC2 -> CYRILLIC CAPITAL LETTER VE
- u'\u0413' # 0xC3 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0414' # 0xC4 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0xC5 -> CYRILLIC CAPITAL LETTER IE
- u'\u0416' # 0xC6 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0417' # 0xC7 -> CYRILLIC CAPITAL LETTER ZE
- u'\u0418' # 0xC8 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0xC9 -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0xCA -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0xCB -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0xCC -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0xCD -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0xCE -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0xCF -> CYRILLIC CAPITAL LETTER PE
- u'\u0420' # 0xD0 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0xD1 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0xD2 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0xD3 -> CYRILLIC CAPITAL LETTER U
- u'\u0424' # 0xD4 -> CYRILLIC CAPITAL LETTER EF
- u'\u0425' # 0xD5 -> CYRILLIC CAPITAL LETTER HA
- u'\u0426' # 0xD6 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0427' # 0xD7 -> CYRILLIC CAPITAL LETTER CHE
- u'\u0428' # 0xD8 -> CYRILLIC CAPITAL LETTER SHA
- u'\u0429' # 0xD9 -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u042a' # 0xDA -> CYRILLIC CAPITAL LETTER HARD SIGN
- u'\u042b' # 0xDB -> CYRILLIC CAPITAL LETTER YERU
- u'\u042c' # 0xDC -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042d' # 0xDD -> CYRILLIC CAPITAL LETTER E
- u'\u042e' # 0xDE -> CYRILLIC CAPITAL LETTER YU
- u'\u042f' # 0xDF -> CYRILLIC CAPITAL LETTER YA
- u'\u0430' # 0xE0 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0xE1 -> CYRILLIC SMALL LETTER BE
- u'\u0432' # 0xE2 -> CYRILLIC SMALL LETTER VE
- u'\u0433' # 0xE3 -> CYRILLIC SMALL LETTER GHE
- u'\u0434' # 0xE4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0xE5 -> CYRILLIC SMALL LETTER IE
- u'\u0436' # 0xE6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0437' # 0xE7 -> CYRILLIC SMALL LETTER ZE
- u'\u0438' # 0xE8 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0xE9 -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0xEA -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0xEB -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0xEC -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0xED -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0xEE -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0xEF -> CYRILLIC SMALL LETTER PE
- u'\u0440' # 0xF0 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0xF1 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0xF2 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0xF3 -> CYRILLIC SMALL LETTER U
- u'\u0444' # 0xF4 -> CYRILLIC SMALL LETTER EF
- u'\u0445' # 0xF5 -> CYRILLIC SMALL LETTER HA
- u'\u0446' # 0xF6 -> CYRILLIC SMALL LETTER TSE
- u'\u0447' # 0xF7 -> CYRILLIC SMALL LETTER CHE
- u'\u0448' # 0xF8 -> CYRILLIC SMALL LETTER SHA
- u'\u0449' # 0xF9 -> CYRILLIC SMALL LETTER SHCHA
- u'\u044a' # 0xFA -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u044b' # 0xFB -> CYRILLIC SMALL LETTER YERU
- u'\u044c' # 0xFC -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044d' # 0xFD -> CYRILLIC SMALL LETTER E
- u'\u044e' # 0xFE -> CYRILLIC SMALL LETTER YU
- u'\u044f' # 0xFF -> CYRILLIC SMALL LETTER YA
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u0402' # 0x80 -> CYRILLIC CAPITAL LETTER DJE
+ '\u0403' # 0x81 -> CYRILLIC CAPITAL LETTER GJE
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0453' # 0x83 -> CYRILLIC SMALL LETTER GJE
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u20ac' # 0x88 -> EURO SIGN
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\u0409' # 0x8A -> CYRILLIC CAPITAL LETTER LJE
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u040a' # 0x8C -> CYRILLIC CAPITAL LETTER NJE
+ '\u040c' # 0x8D -> CYRILLIC CAPITAL LETTER KJE
+ '\u040b' # 0x8E -> CYRILLIC CAPITAL LETTER TSHE
+ '\u040f' # 0x8F -> CYRILLIC CAPITAL LETTER DZHE
+ '\u0452' # 0x90 -> CYRILLIC SMALL LETTER DJE
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\ufffe' # 0x98 -> UNDEFINED
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\u0459' # 0x9A -> CYRILLIC SMALL LETTER LJE
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u045a' # 0x9C -> CYRILLIC SMALL LETTER NJE
+ '\u045c' # 0x9D -> CYRILLIC SMALL LETTER KJE
+ '\u045b' # 0x9E -> CYRILLIC SMALL LETTER TSHE
+ '\u045f' # 0x9F -> CYRILLIC SMALL LETTER DZHE
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u040e' # 0xA1 -> CYRILLIC CAPITAL LETTER SHORT U
+ '\u045e' # 0xA2 -> CYRILLIC SMALL LETTER SHORT U
+ '\u0408' # 0xA3 -> CYRILLIC CAPITAL LETTER JE
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\u0490' # 0xA5 -> CYRILLIC CAPITAL LETTER GHE WITH UPTURN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\u0401' # 0xA8 -> CYRILLIC CAPITAL LETTER IO
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u0404' # 0xAA -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\u0407' # 0xAF -> CYRILLIC CAPITAL LETTER YI
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u0406' # 0xB2 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0456' # 0xB3 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0491' # 0xB4 -> CYRILLIC SMALL LETTER GHE WITH UPTURN
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u0451' # 0xB8 -> CYRILLIC SMALL LETTER IO
+ '\u2116' # 0xB9 -> NUMERO SIGN
+ '\u0454' # 0xBA -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u0458' # 0xBC -> CYRILLIC SMALL LETTER JE
+ '\u0405' # 0xBD -> CYRILLIC CAPITAL LETTER DZE
+ '\u0455' # 0xBE -> CYRILLIC SMALL LETTER DZE
+ '\u0457' # 0xBF -> CYRILLIC SMALL LETTER YI
+ '\u0410' # 0xC0 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0xC1 -> CYRILLIC CAPITAL LETTER BE
+ '\u0412' # 0xC2 -> CYRILLIC CAPITAL LETTER VE
+ '\u0413' # 0xC3 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0414' # 0xC4 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0xC5 -> CYRILLIC CAPITAL LETTER IE
+ '\u0416' # 0xC6 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0417' # 0xC7 -> CYRILLIC CAPITAL LETTER ZE
+ '\u0418' # 0xC8 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0xC9 -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0xCA -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0xCB -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0xCC -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0xCD -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0xCE -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0xCF -> CYRILLIC CAPITAL LETTER PE
+ '\u0420' # 0xD0 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0xD1 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0xD2 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0xD3 -> CYRILLIC CAPITAL LETTER U
+ '\u0424' # 0xD4 -> CYRILLIC CAPITAL LETTER EF
+ '\u0425' # 0xD5 -> CYRILLIC CAPITAL LETTER HA
+ '\u0426' # 0xD6 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0427' # 0xD7 -> CYRILLIC CAPITAL LETTER CHE
+ '\u0428' # 0xD8 -> CYRILLIC CAPITAL LETTER SHA
+ '\u0429' # 0xD9 -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u042a' # 0xDA -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\u042b' # 0xDB -> CYRILLIC CAPITAL LETTER YERU
+ '\u042c' # 0xDC -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042d' # 0xDD -> CYRILLIC CAPITAL LETTER E
+ '\u042e' # 0xDE -> CYRILLIC CAPITAL LETTER YU
+ '\u042f' # 0xDF -> CYRILLIC CAPITAL LETTER YA
+ '\u0430' # 0xE0 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0xE1 -> CYRILLIC SMALL LETTER BE
+ '\u0432' # 0xE2 -> CYRILLIC SMALL LETTER VE
+ '\u0433' # 0xE3 -> CYRILLIC SMALL LETTER GHE
+ '\u0434' # 0xE4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0xE5 -> CYRILLIC SMALL LETTER IE
+ '\u0436' # 0xE6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0437' # 0xE7 -> CYRILLIC SMALL LETTER ZE
+ '\u0438' # 0xE8 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0xE9 -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0xEA -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0xEB -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0xEC -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0xED -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0xEE -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0xEF -> CYRILLIC SMALL LETTER PE
+ '\u0440' # 0xF0 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0xF1 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0xF2 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0xF3 -> CYRILLIC SMALL LETTER U
+ '\u0444' # 0xF4 -> CYRILLIC SMALL LETTER EF
+ '\u0445' # 0xF5 -> CYRILLIC SMALL LETTER HA
+ '\u0446' # 0xF6 -> CYRILLIC SMALL LETTER TSE
+ '\u0447' # 0xF7 -> CYRILLIC SMALL LETTER CHE
+ '\u0448' # 0xF8 -> CYRILLIC SMALL LETTER SHA
+ '\u0449' # 0xF9 -> CYRILLIC SMALL LETTER SHCHA
+ '\u044a' # 0xFA -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u044b' # 0xFB -> CYRILLIC SMALL LETTER YERU
+ '\u044c' # 0xFC -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044d' # 0xFD -> CYRILLIC SMALL LETTER E
+ '\u044e' # 0xFE -> CYRILLIC SMALL LETTER YU
+ '\u044f' # 0xFF -> CYRILLIC SMALL LETTER YA
)
### Encoding table
diff --git a/Lib/encodings/cp1252.py b/Lib/encodings/cp1252.py
index e60a328db40..c0e8088ea82 100644
--- a/Lib/encodings/cp1252.py
+++ b/Lib/encodings/cp1252.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\u017d' # 0x8E -> LATIN CAPITAL LETTER Z WITH CARON
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\u02dc' # 0x98 -> SMALL TILDE
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\u017e' # 0x9E -> LATIN SMALL LETTER Z WITH CARON
- u'\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf0' # 0xF0 -> LATIN SMALL LETTER ETH
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0xFE -> LATIN SMALL LETTER THORN
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\u017d' # 0x8E -> LATIN CAPITAL LETTER Z WITH CARON
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\u02dc' # 0x98 -> SMALL TILDE
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\u017e' # 0x9E -> LATIN SMALL LETTER Z WITH CARON
+ '\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf0' # 0xF0 -> LATIN SMALL LETTER ETH
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0xFE -> LATIN SMALL LETTER THORN
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/cp1253.py b/Lib/encodings/cp1253.py
index 49f6cccbd23..ec9c0972d10 100644
--- a/Lib/encodings/cp1253.py
+++ b/Lib/encodings/cp1253.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\ufffe' # 0x88 -> UNDEFINED
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\ufffe' # 0x8A -> UNDEFINED
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x8C -> UNDEFINED
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\ufffe' # 0x98 -> UNDEFINED
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x9C -> UNDEFINED
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\ufffe' # 0x9F -> UNDEFINED
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0385' # 0xA1 -> GREEK DIALYTIKA TONOS
- u'\u0386' # 0xA2 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\ufffe' # 0xAA -> UNDEFINED
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\u2015' # 0xAF -> HORIZONTAL BAR
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\u0384' # 0xB4 -> GREEK TONOS
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u0388' # 0xB8 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u0389' # 0xB9 -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\u038a' # 0xBA -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u038c' # 0xBC -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\u038e' # 0xBE -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u038f' # 0xBF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'\u0390' # 0xC0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
- u'\u0391' # 0xC1 -> GREEK CAPITAL LETTER ALPHA
- u'\u0392' # 0xC2 -> GREEK CAPITAL LETTER BETA
- u'\u0393' # 0xC3 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0xC4 -> GREEK CAPITAL LETTER DELTA
- u'\u0395' # 0xC5 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0xC6 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0xC7 -> GREEK CAPITAL LETTER ETA
- u'\u0398' # 0xC8 -> GREEK CAPITAL LETTER THETA
- u'\u0399' # 0xC9 -> GREEK CAPITAL LETTER IOTA
- u'\u039a' # 0xCA -> GREEK CAPITAL LETTER KAPPA
- u'\u039b' # 0xCB -> GREEK CAPITAL LETTER LAMDA
- u'\u039c' # 0xCC -> GREEK CAPITAL LETTER MU
- u'\u039d' # 0xCD -> GREEK CAPITAL LETTER NU
- u'\u039e' # 0xCE -> GREEK CAPITAL LETTER XI
- u'\u039f' # 0xCF -> GREEK CAPITAL LETTER OMICRON
- u'\u03a0' # 0xD0 -> GREEK CAPITAL LETTER PI
- u'\u03a1' # 0xD1 -> GREEK CAPITAL LETTER RHO
- u'\ufffe' # 0xD2 -> UNDEFINED
- u'\u03a3' # 0xD3 -> GREEK CAPITAL LETTER SIGMA
- u'\u03a4' # 0xD4 -> GREEK CAPITAL LETTER TAU
- u'\u03a5' # 0xD5 -> GREEK CAPITAL LETTER UPSILON
- u'\u03a6' # 0xD6 -> GREEK CAPITAL LETTER PHI
- u'\u03a7' # 0xD7 -> GREEK CAPITAL LETTER CHI
- u'\u03a8' # 0xD8 -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0xD9 -> GREEK CAPITAL LETTER OMEGA
- u'\u03aa' # 0xDA -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\u03ab' # 0xDB -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'\u03ac' # 0xDC -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\u03ad' # 0xDD -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0xDE -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03af' # 0xDF -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03b0' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
- u'\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
- u'\u03b3' # 0xE3 -> GREEK SMALL LETTER GAMMA
- u'\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
- u'\u03b6' # 0xE6 -> GREEK SMALL LETTER ZETA
- u'\u03b7' # 0xE7 -> GREEK SMALL LETTER ETA
- u'\u03b8' # 0xE8 -> GREEK SMALL LETTER THETA
- u'\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
- u'\u03ba' # 0xEA -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0xEB -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0xEC -> GREEK SMALL LETTER MU
- u'\u03bd' # 0xED -> GREEK SMALL LETTER NU
- u'\u03be' # 0xEE -> GREEK SMALL LETTER XI
- u'\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
- u'\u03c1' # 0xF1 -> GREEK SMALL LETTER RHO
- u'\u03c2' # 0xF2 -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
- u'\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
- u'\u03c5' # 0xF5 -> GREEK SMALL LETTER UPSILON
- u'\u03c6' # 0xF6 -> GREEK SMALL LETTER PHI
- u'\u03c7' # 0xF7 -> GREEK SMALL LETTER CHI
- u'\u03c8' # 0xF8 -> GREEK SMALL LETTER PSI
- u'\u03c9' # 0xF9 -> GREEK SMALL LETTER OMEGA
- u'\u03ca' # 0xFA -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u03cb' # 0xFB -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u03cc' # 0xFC -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u03cd' # 0xFD -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u03ce' # 0xFE -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\ufffe' # 0xFF -> UNDEFINED
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\ufffe' # 0x88 -> UNDEFINED
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\ufffe' # 0x8A -> UNDEFINED
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x8C -> UNDEFINED
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\ufffe' # 0x98 -> UNDEFINED
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x9C -> UNDEFINED
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\ufffe' # 0x9F -> UNDEFINED
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0385' # 0xA1 -> GREEK DIALYTIKA TONOS
+ '\u0386' # 0xA2 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\ufffe' # 0xAA -> UNDEFINED
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\u2015' # 0xAF -> HORIZONTAL BAR
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\u0384' # 0xB4 -> GREEK TONOS
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u0388' # 0xB8 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u0389' # 0xB9 -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\u038a' # 0xBA -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u038c' # 0xBC -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\u038e' # 0xBE -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u038f' # 0xBF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '\u0390' # 0xC0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+ '\u0391' # 0xC1 -> GREEK CAPITAL LETTER ALPHA
+ '\u0392' # 0xC2 -> GREEK CAPITAL LETTER BETA
+ '\u0393' # 0xC3 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0xC4 -> GREEK CAPITAL LETTER DELTA
+ '\u0395' # 0xC5 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0xC6 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0xC7 -> GREEK CAPITAL LETTER ETA
+ '\u0398' # 0xC8 -> GREEK CAPITAL LETTER THETA
+ '\u0399' # 0xC9 -> GREEK CAPITAL LETTER IOTA
+ '\u039a' # 0xCA -> GREEK CAPITAL LETTER KAPPA
+ '\u039b' # 0xCB -> GREEK CAPITAL LETTER LAMDA
+ '\u039c' # 0xCC -> GREEK CAPITAL LETTER MU
+ '\u039d' # 0xCD -> GREEK CAPITAL LETTER NU
+ '\u039e' # 0xCE -> GREEK CAPITAL LETTER XI
+ '\u039f' # 0xCF -> GREEK CAPITAL LETTER OMICRON
+ '\u03a0' # 0xD0 -> GREEK CAPITAL LETTER PI
+ '\u03a1' # 0xD1 -> GREEK CAPITAL LETTER RHO
+ '\ufffe' # 0xD2 -> UNDEFINED
+ '\u03a3' # 0xD3 -> GREEK CAPITAL LETTER SIGMA
+ '\u03a4' # 0xD4 -> GREEK CAPITAL LETTER TAU
+ '\u03a5' # 0xD5 -> GREEK CAPITAL LETTER UPSILON
+ '\u03a6' # 0xD6 -> GREEK CAPITAL LETTER PHI
+ '\u03a7' # 0xD7 -> GREEK CAPITAL LETTER CHI
+ '\u03a8' # 0xD8 -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0xD9 -> GREEK CAPITAL LETTER OMEGA
+ '\u03aa' # 0xDA -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\u03ab' # 0xDB -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '\u03ac' # 0xDC -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\u03ad' # 0xDD -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0xDE -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03af' # 0xDF -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03b0' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+ '\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
+ '\u03b3' # 0xE3 -> GREEK SMALL LETTER GAMMA
+ '\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
+ '\u03b6' # 0xE6 -> GREEK SMALL LETTER ZETA
+ '\u03b7' # 0xE7 -> GREEK SMALL LETTER ETA
+ '\u03b8' # 0xE8 -> GREEK SMALL LETTER THETA
+ '\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
+ '\u03ba' # 0xEA -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0xEB -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0xEC -> GREEK SMALL LETTER MU
+ '\u03bd' # 0xED -> GREEK SMALL LETTER NU
+ '\u03be' # 0xEE -> GREEK SMALL LETTER XI
+ '\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
+ '\u03c1' # 0xF1 -> GREEK SMALL LETTER RHO
+ '\u03c2' # 0xF2 -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
+ '\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
+ '\u03c5' # 0xF5 -> GREEK SMALL LETTER UPSILON
+ '\u03c6' # 0xF6 -> GREEK SMALL LETTER PHI
+ '\u03c7' # 0xF7 -> GREEK SMALL LETTER CHI
+ '\u03c8' # 0xF8 -> GREEK SMALL LETTER PSI
+ '\u03c9' # 0xF9 -> GREEK SMALL LETTER OMEGA
+ '\u03ca' # 0xFA -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u03cb' # 0xFB -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u03cc' # 0xFC -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u03cd' # 0xFD -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u03ce' # 0xFE -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\ufffe' # 0xFF -> UNDEFINED
)
### Encoding table
diff --git a/Lib/encodings/cp1254.py b/Lib/encodings/cp1254.py
index 65530ab5461..4912327a5bc 100644
--- a/Lib/encodings/cp1254.py
+++ b/Lib/encodings/cp1254.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\u02dc' # 0x98 -> SMALL TILDE
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I
- u'\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\u0160' # 0x8A -> LATIN CAPITAL LETTER S WITH CARON
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\u02dc' # 0x98 -> SMALL TILDE
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\u0161' # 0x9A -> LATIN SMALL LETTER S WITH CARON
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I
+ '\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/cp1255.py b/Lib/encodings/cp1255.py
index fd1456fab6e..91ce26b9bff 100644
--- a/Lib/encodings/cp1255.py
+++ b/Lib/encodings/cp1255.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\ufffe' # 0x8A -> UNDEFINED
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x8C -> UNDEFINED
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\u02dc' # 0x98 -> SMALL TILDE
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x9C -> UNDEFINED
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\ufffe' # 0x9F -> UNDEFINED
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\u20aa' # 0xA4 -> NEW SHEQEL SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xd7' # 0xAA -> MULTIPLICATION SIGN
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xf7' # 0xBA -> DIVISION SIGN
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\u05b0' # 0xC0 -> HEBREW POINT SHEVA
- u'\u05b1' # 0xC1 -> HEBREW POINT HATAF SEGOL
- u'\u05b2' # 0xC2 -> HEBREW POINT HATAF PATAH
- u'\u05b3' # 0xC3 -> HEBREW POINT HATAF QAMATS
- u'\u05b4' # 0xC4 -> HEBREW POINT HIRIQ
- u'\u05b5' # 0xC5 -> HEBREW POINT TSERE
- u'\u05b6' # 0xC6 -> HEBREW POINT SEGOL
- u'\u05b7' # 0xC7 -> HEBREW POINT PATAH
- u'\u05b8' # 0xC8 -> HEBREW POINT QAMATS
- u'\u05b9' # 0xC9 -> HEBREW POINT HOLAM
- u'\ufffe' # 0xCA -> UNDEFINED
- u'\u05bb' # 0xCB -> HEBREW POINT QUBUTS
- u'\u05bc' # 0xCC -> HEBREW POINT DAGESH OR MAPIQ
- u'\u05bd' # 0xCD -> HEBREW POINT METEG
- u'\u05be' # 0xCE -> HEBREW PUNCTUATION MAQAF
- u'\u05bf' # 0xCF -> HEBREW POINT RAFE
- u'\u05c0' # 0xD0 -> HEBREW PUNCTUATION PASEQ
- u'\u05c1' # 0xD1 -> HEBREW POINT SHIN DOT
- u'\u05c2' # 0xD2 -> HEBREW POINT SIN DOT
- u'\u05c3' # 0xD3 -> HEBREW PUNCTUATION SOF PASUQ
- u'\u05f0' # 0xD4 -> HEBREW LIGATURE YIDDISH DOUBLE VAV
- u'\u05f1' # 0xD5 -> HEBREW LIGATURE YIDDISH VAV YOD
- u'\u05f2' # 0xD6 -> HEBREW LIGATURE YIDDISH DOUBLE YOD
- u'\u05f3' # 0xD7 -> HEBREW PUNCTUATION GERESH
- u'\u05f4' # 0xD8 -> HEBREW PUNCTUATION GERSHAYIM
- u'\ufffe' # 0xD9 -> UNDEFINED
- u'\ufffe' # 0xDA -> UNDEFINED
- u'\ufffe' # 0xDB -> UNDEFINED
- u'\ufffe' # 0xDC -> UNDEFINED
- u'\ufffe' # 0xDD -> UNDEFINED
- u'\ufffe' # 0xDE -> UNDEFINED
- u'\ufffe' # 0xDF -> UNDEFINED
- u'\u05d0' # 0xE0 -> HEBREW LETTER ALEF
- u'\u05d1' # 0xE1 -> HEBREW LETTER BET
- u'\u05d2' # 0xE2 -> HEBREW LETTER GIMEL
- u'\u05d3' # 0xE3 -> HEBREW LETTER DALET
- u'\u05d4' # 0xE4 -> HEBREW LETTER HE
- u'\u05d5' # 0xE5 -> HEBREW LETTER VAV
- u'\u05d6' # 0xE6 -> HEBREW LETTER ZAYIN
- u'\u05d7' # 0xE7 -> HEBREW LETTER HET
- u'\u05d8' # 0xE8 -> HEBREW LETTER TET
- u'\u05d9' # 0xE9 -> HEBREW LETTER YOD
- u'\u05da' # 0xEA -> HEBREW LETTER FINAL KAF
- u'\u05db' # 0xEB -> HEBREW LETTER KAF
- u'\u05dc' # 0xEC -> HEBREW LETTER LAMED
- u'\u05dd' # 0xED -> HEBREW LETTER FINAL MEM
- u'\u05de' # 0xEE -> HEBREW LETTER MEM
- u'\u05df' # 0xEF -> HEBREW LETTER FINAL NUN
- u'\u05e0' # 0xF0 -> HEBREW LETTER NUN
- u'\u05e1' # 0xF1 -> HEBREW LETTER SAMEKH
- u'\u05e2' # 0xF2 -> HEBREW LETTER AYIN
- u'\u05e3' # 0xF3 -> HEBREW LETTER FINAL PE
- u'\u05e4' # 0xF4 -> HEBREW LETTER PE
- u'\u05e5' # 0xF5 -> HEBREW LETTER FINAL TSADI
- u'\u05e6' # 0xF6 -> HEBREW LETTER TSADI
- u'\u05e7' # 0xF7 -> HEBREW LETTER QOF
- u'\u05e8' # 0xF8 -> HEBREW LETTER RESH
- u'\u05e9' # 0xF9 -> HEBREW LETTER SHIN
- u'\u05ea' # 0xFA -> HEBREW LETTER TAV
- u'\ufffe' # 0xFB -> UNDEFINED
- u'\ufffe' # 0xFC -> UNDEFINED
- u'\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
- u'\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
- u'\ufffe' # 0xFF -> UNDEFINED
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\ufffe' # 0x8A -> UNDEFINED
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x8C -> UNDEFINED
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\u02dc' # 0x98 -> SMALL TILDE
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x9C -> UNDEFINED
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\ufffe' # 0x9F -> UNDEFINED
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\u20aa' # 0xA4 -> NEW SHEQEL SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xd7' # 0xAA -> MULTIPLICATION SIGN
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xf7' # 0xBA -> DIVISION SIGN
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\u05b0' # 0xC0 -> HEBREW POINT SHEVA
+ '\u05b1' # 0xC1 -> HEBREW POINT HATAF SEGOL
+ '\u05b2' # 0xC2 -> HEBREW POINT HATAF PATAH
+ '\u05b3' # 0xC3 -> HEBREW POINT HATAF QAMATS
+ '\u05b4' # 0xC4 -> HEBREW POINT HIRIQ
+ '\u05b5' # 0xC5 -> HEBREW POINT TSERE
+ '\u05b6' # 0xC6 -> HEBREW POINT SEGOL
+ '\u05b7' # 0xC7 -> HEBREW POINT PATAH
+ '\u05b8' # 0xC8 -> HEBREW POINT QAMATS
+ '\u05b9' # 0xC9 -> HEBREW POINT HOLAM
+ '\ufffe' # 0xCA -> UNDEFINED
+ '\u05bb' # 0xCB -> HEBREW POINT QUBUTS
+ '\u05bc' # 0xCC -> HEBREW POINT DAGESH OR MAPIQ
+ '\u05bd' # 0xCD -> HEBREW POINT METEG
+ '\u05be' # 0xCE -> HEBREW PUNCTUATION MAQAF
+ '\u05bf' # 0xCF -> HEBREW POINT RAFE
+ '\u05c0' # 0xD0 -> HEBREW PUNCTUATION PASEQ
+ '\u05c1' # 0xD1 -> HEBREW POINT SHIN DOT
+ '\u05c2' # 0xD2 -> HEBREW POINT SIN DOT
+ '\u05c3' # 0xD3 -> HEBREW PUNCTUATION SOF PASUQ
+ '\u05f0' # 0xD4 -> HEBREW LIGATURE YIDDISH DOUBLE VAV
+ '\u05f1' # 0xD5 -> HEBREW LIGATURE YIDDISH VAV YOD
+ '\u05f2' # 0xD6 -> HEBREW LIGATURE YIDDISH DOUBLE YOD
+ '\u05f3' # 0xD7 -> HEBREW PUNCTUATION GERESH
+ '\u05f4' # 0xD8 -> HEBREW PUNCTUATION GERSHAYIM
+ '\ufffe' # 0xD9 -> UNDEFINED
+ '\ufffe' # 0xDA -> UNDEFINED
+ '\ufffe' # 0xDB -> UNDEFINED
+ '\ufffe' # 0xDC -> UNDEFINED
+ '\ufffe' # 0xDD -> UNDEFINED
+ '\ufffe' # 0xDE -> UNDEFINED
+ '\ufffe' # 0xDF -> UNDEFINED
+ '\u05d0' # 0xE0 -> HEBREW LETTER ALEF
+ '\u05d1' # 0xE1 -> HEBREW LETTER BET
+ '\u05d2' # 0xE2 -> HEBREW LETTER GIMEL
+ '\u05d3' # 0xE3 -> HEBREW LETTER DALET
+ '\u05d4' # 0xE4 -> HEBREW LETTER HE
+ '\u05d5' # 0xE5 -> HEBREW LETTER VAV
+ '\u05d6' # 0xE6 -> HEBREW LETTER ZAYIN
+ '\u05d7' # 0xE7 -> HEBREW LETTER HET
+ '\u05d8' # 0xE8 -> HEBREW LETTER TET
+ '\u05d9' # 0xE9 -> HEBREW LETTER YOD
+ '\u05da' # 0xEA -> HEBREW LETTER FINAL KAF
+ '\u05db' # 0xEB -> HEBREW LETTER KAF
+ '\u05dc' # 0xEC -> HEBREW LETTER LAMED
+ '\u05dd' # 0xED -> HEBREW LETTER FINAL MEM
+ '\u05de' # 0xEE -> HEBREW LETTER MEM
+ '\u05df' # 0xEF -> HEBREW LETTER FINAL NUN
+ '\u05e0' # 0xF0 -> HEBREW LETTER NUN
+ '\u05e1' # 0xF1 -> HEBREW LETTER SAMEKH
+ '\u05e2' # 0xF2 -> HEBREW LETTER AYIN
+ '\u05e3' # 0xF3 -> HEBREW LETTER FINAL PE
+ '\u05e4' # 0xF4 -> HEBREW LETTER PE
+ '\u05e5' # 0xF5 -> HEBREW LETTER FINAL TSADI
+ '\u05e6' # 0xF6 -> HEBREW LETTER TSADI
+ '\u05e7' # 0xF7 -> HEBREW LETTER QOF
+ '\u05e8' # 0xF8 -> HEBREW LETTER RESH
+ '\u05e9' # 0xF9 -> HEBREW LETTER SHIN
+ '\u05ea' # 0xFA -> HEBREW LETTER TAV
+ '\ufffe' # 0xFB -> UNDEFINED
+ '\ufffe' # 0xFC -> UNDEFINED
+ '\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
+ '\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
+ '\ufffe' # 0xFF -> UNDEFINED
)
### Encoding table
diff --git a/Lib/encodings/cp1256.py b/Lib/encodings/cp1256.py
index 302b5fa0662..fd6afab52c6 100644
--- a/Lib/encodings/cp1256.py
+++ b/Lib/encodings/cp1256.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\u067e' # 0x81 -> ARABIC LETTER PEH
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\u0679' # 0x8A -> ARABIC LETTER TTEH
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
- u'\u0686' # 0x8D -> ARABIC LETTER TCHEH
- u'\u0698' # 0x8E -> ARABIC LETTER JEH
- u'\u0688' # 0x8F -> ARABIC LETTER DDAL
- u'\u06af' # 0x90 -> ARABIC LETTER GAF
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\u06a9' # 0x98 -> ARABIC LETTER KEHEH
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\u0691' # 0x9A -> ARABIC LETTER RREH
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
- u'\u200c' # 0x9D -> ZERO WIDTH NON-JOINER
- u'\u200d' # 0x9E -> ZERO WIDTH JOINER
- u'\u06ba' # 0x9F -> ARABIC LETTER NOON GHUNNA
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u060c' # 0xA1 -> ARABIC COMMA
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u06be' # 0xAA -> ARABIC LETTER HEH DOACHASHMEE
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\u061b' # 0xBA -> ARABIC SEMICOLON
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\u061f' # 0xBF -> ARABIC QUESTION MARK
- u'\u06c1' # 0xC0 -> ARABIC LETTER HEH GOAL
- u'\u0621' # 0xC1 -> ARABIC LETTER HAMZA
- u'\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
- u'\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
- u'\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
- u'\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
- u'\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
- u'\u0627' # 0xC7 -> ARABIC LETTER ALEF
- u'\u0628' # 0xC8 -> ARABIC LETTER BEH
- u'\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
- u'\u062a' # 0xCA -> ARABIC LETTER TEH
- u'\u062b' # 0xCB -> ARABIC LETTER THEH
- u'\u062c' # 0xCC -> ARABIC LETTER JEEM
- u'\u062d' # 0xCD -> ARABIC LETTER HAH
- u'\u062e' # 0xCE -> ARABIC LETTER KHAH
- u'\u062f' # 0xCF -> ARABIC LETTER DAL
- u'\u0630' # 0xD0 -> ARABIC LETTER THAL
- u'\u0631' # 0xD1 -> ARABIC LETTER REH
- u'\u0632' # 0xD2 -> ARABIC LETTER ZAIN
- u'\u0633' # 0xD3 -> ARABIC LETTER SEEN
- u'\u0634' # 0xD4 -> ARABIC LETTER SHEEN
- u'\u0635' # 0xD5 -> ARABIC LETTER SAD
- u'\u0636' # 0xD6 -> ARABIC LETTER DAD
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u0637' # 0xD8 -> ARABIC LETTER TAH
- u'\u0638' # 0xD9 -> ARABIC LETTER ZAH
- u'\u0639' # 0xDA -> ARABIC LETTER AIN
- u'\u063a' # 0xDB -> ARABIC LETTER GHAIN
- u'\u0640' # 0xDC -> ARABIC TATWEEL
- u'\u0641' # 0xDD -> ARABIC LETTER FEH
- u'\u0642' # 0xDE -> ARABIC LETTER QAF
- u'\u0643' # 0xDF -> ARABIC LETTER KAF
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\u0644' # 0xE1 -> ARABIC LETTER LAM
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\u0645' # 0xE3 -> ARABIC LETTER MEEM
- u'\u0646' # 0xE4 -> ARABIC LETTER NOON
- u'\u0647' # 0xE5 -> ARABIC LETTER HEH
- u'\u0648' # 0xE6 -> ARABIC LETTER WAW
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u0649' # 0xEC -> ARABIC LETTER ALEF MAKSURA
- u'\u064a' # 0xED -> ARABIC LETTER YEH
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u064b' # 0xF0 -> ARABIC FATHATAN
- u'\u064c' # 0xF1 -> ARABIC DAMMATAN
- u'\u064d' # 0xF2 -> ARABIC KASRATAN
- u'\u064e' # 0xF3 -> ARABIC FATHA
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u064f' # 0xF5 -> ARABIC DAMMA
- u'\u0650' # 0xF6 -> ARABIC KASRA
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u0651' # 0xF8 -> ARABIC SHADDA
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\u0652' # 0xFA -> ARABIC SUKUN
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
- u'\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
- u'\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\u067e' # 0x81 -> ARABIC LETTER PEH
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\u0679' # 0x8A -> ARABIC LETTER TTEH
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
+ '\u0686' # 0x8D -> ARABIC LETTER TCHEH
+ '\u0698' # 0x8E -> ARABIC LETTER JEH
+ '\u0688' # 0x8F -> ARABIC LETTER DDAL
+ '\u06af' # 0x90 -> ARABIC LETTER GAF
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\u06a9' # 0x98 -> ARABIC LETTER KEHEH
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\u0691' # 0x9A -> ARABIC LETTER RREH
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
+ '\u200c' # 0x9D -> ZERO WIDTH NON-JOINER
+ '\u200d' # 0x9E -> ZERO WIDTH JOINER
+ '\u06ba' # 0x9F -> ARABIC LETTER NOON GHUNNA
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u060c' # 0xA1 -> ARABIC COMMA
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u06be' # 0xAA -> ARABIC LETTER HEH DOACHASHMEE
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\u061b' # 0xBA -> ARABIC SEMICOLON
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\u061f' # 0xBF -> ARABIC QUESTION MARK
+ '\u06c1' # 0xC0 -> ARABIC LETTER HEH GOAL
+ '\u0621' # 0xC1 -> ARABIC LETTER HAMZA
+ '\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0xC7 -> ARABIC LETTER ALEF
+ '\u0628' # 0xC8 -> ARABIC LETTER BEH
+ '\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0xCA -> ARABIC LETTER TEH
+ '\u062b' # 0xCB -> ARABIC LETTER THEH
+ '\u062c' # 0xCC -> ARABIC LETTER JEEM
+ '\u062d' # 0xCD -> ARABIC LETTER HAH
+ '\u062e' # 0xCE -> ARABIC LETTER KHAH
+ '\u062f' # 0xCF -> ARABIC LETTER DAL
+ '\u0630' # 0xD0 -> ARABIC LETTER THAL
+ '\u0631' # 0xD1 -> ARABIC LETTER REH
+ '\u0632' # 0xD2 -> ARABIC LETTER ZAIN
+ '\u0633' # 0xD3 -> ARABIC LETTER SEEN
+ '\u0634' # 0xD4 -> ARABIC LETTER SHEEN
+ '\u0635' # 0xD5 -> ARABIC LETTER SAD
+ '\u0636' # 0xD6 -> ARABIC LETTER DAD
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u0637' # 0xD8 -> ARABIC LETTER TAH
+ '\u0638' # 0xD9 -> ARABIC LETTER ZAH
+ '\u0639' # 0xDA -> ARABIC LETTER AIN
+ '\u063a' # 0xDB -> ARABIC LETTER GHAIN
+ '\u0640' # 0xDC -> ARABIC TATWEEL
+ '\u0641' # 0xDD -> ARABIC LETTER FEH
+ '\u0642' # 0xDE -> ARABIC LETTER QAF
+ '\u0643' # 0xDF -> ARABIC LETTER KAF
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\u0644' # 0xE1 -> ARABIC LETTER LAM
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\u0645' # 0xE3 -> ARABIC LETTER MEEM
+ '\u0646' # 0xE4 -> ARABIC LETTER NOON
+ '\u0647' # 0xE5 -> ARABIC LETTER HEH
+ '\u0648' # 0xE6 -> ARABIC LETTER WAW
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u0649' # 0xEC -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0xED -> ARABIC LETTER YEH
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u064b' # 0xF0 -> ARABIC FATHATAN
+ '\u064c' # 0xF1 -> ARABIC DAMMATAN
+ '\u064d' # 0xF2 -> ARABIC KASRATAN
+ '\u064e' # 0xF3 -> ARABIC FATHA
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u064f' # 0xF5 -> ARABIC DAMMA
+ '\u0650' # 0xF6 -> ARABIC KASRA
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u0651' # 0xF8 -> ARABIC SHADDA
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\u0652' # 0xFA -> ARABIC SUKUN
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
+ '\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
+ '\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE
)
### Encoding table
diff --git a/Lib/encodings/cp1257.py b/Lib/encodings/cp1257.py
index 53a6b29d5b0..9ebc90d509d 100644
--- a/Lib/encodings/cp1257.py
+++ b/Lib/encodings/cp1257.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\ufffe' # 0x83 -> UNDEFINED
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\ufffe' # 0x88 -> UNDEFINED
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\ufffe' # 0x8A -> UNDEFINED
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x8C -> UNDEFINED
- u'\xa8' # 0x8D -> DIAERESIS
- u'\u02c7' # 0x8E -> CARON
- u'\xb8' # 0x8F -> CEDILLA
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\ufffe' # 0x98 -> UNDEFINED
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\ufffe' # 0x9C -> UNDEFINED
- u'\xaf' # 0x9D -> MACRON
- u'\u02db' # 0x9E -> OGONEK
- u'\ufffe' # 0x9F -> UNDEFINED
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\ufffe' # 0xA1 -> UNDEFINED
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\ufffe' # 0xA5 -> UNDEFINED
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xd8' # 0xA8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u0156' # 0xAA -> LATIN CAPITAL LETTER R WITH CEDILLA
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xc6' # 0xAF -> LATIN CAPITAL LETTER AE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xf8' # 0xB8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\u0157' # 0xBA -> LATIN SMALL LETTER R WITH CEDILLA
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xe6' # 0xBF -> LATIN SMALL LETTER AE
- u'\u0104' # 0xC0 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u012e' # 0xC1 -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u0100' # 0xC2 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\u0106' # 0xC3 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\u0118' # 0xC6 -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\u0112' # 0xC7 -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0179' # 0xCA -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\u0116' # 0xCB -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\u0122' # 0xCC -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\u0136' # 0xCD -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\u012a' # 0xCE -> LATIN CAPITAL LETTER I WITH MACRON
- u'\u013b' # 0xCF -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\u0160' # 0xD0 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\u0145' # 0xD2 -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\u014c' # 0xD4 -> LATIN CAPITAL LETTER O WITH MACRON
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u0172' # 0xD8 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\u0141' # 0xD9 -> LATIN CAPITAL LETTER L WITH STROKE
- u'\u015a' # 0xDA -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u016a' # 0xDB -> LATIN CAPITAL LETTER U WITH MACRON
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u017b' # 0xDD -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\u017d' # 0xDE -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\u0105' # 0xE0 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u012f' # 0xE1 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u0101' # 0xE2 -> LATIN SMALL LETTER A WITH MACRON
- u'\u0107' # 0xE3 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\u0119' # 0xE6 -> LATIN SMALL LETTER E WITH OGONEK
- u'\u0113' # 0xE7 -> LATIN SMALL LETTER E WITH MACRON
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u017a' # 0xEA -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u0117' # 0xEB -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\u0123' # 0xEC -> LATIN SMALL LETTER G WITH CEDILLA
- u'\u0137' # 0xED -> LATIN SMALL LETTER K WITH CEDILLA
- u'\u012b' # 0xEE -> LATIN SMALL LETTER I WITH MACRON
- u'\u013c' # 0xEF -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u0161' # 0xF0 -> LATIN SMALL LETTER S WITH CARON
- u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0146' # 0xF2 -> LATIN SMALL LETTER N WITH CEDILLA
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\u014d' # 0xF4 -> LATIN SMALL LETTER O WITH MACRON
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u0173' # 0xF8 -> LATIN SMALL LETTER U WITH OGONEK
- u'\u0142' # 0xF9 -> LATIN SMALL LETTER L WITH STROKE
- u'\u015b' # 0xFA -> LATIN SMALL LETTER S WITH ACUTE
- u'\u016b' # 0xFB -> LATIN SMALL LETTER U WITH MACRON
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u017e' # 0xFE -> LATIN SMALL LETTER Z WITH CARON
- u'\u02d9' # 0xFF -> DOT ABOVE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\ufffe' # 0x83 -> UNDEFINED
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\ufffe' # 0x88 -> UNDEFINED
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\ufffe' # 0x8A -> UNDEFINED
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x8C -> UNDEFINED
+ '\xa8' # 0x8D -> DIAERESIS
+ '\u02c7' # 0x8E -> CARON
+ '\xb8' # 0x8F -> CEDILLA
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\ufffe' # 0x98 -> UNDEFINED
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\ufffe' # 0x9C -> UNDEFINED
+ '\xaf' # 0x9D -> MACRON
+ '\u02db' # 0x9E -> OGONEK
+ '\ufffe' # 0x9F -> UNDEFINED
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\ufffe' # 0xA1 -> UNDEFINED
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\ufffe' # 0xA5 -> UNDEFINED
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xd8' # 0xA8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u0156' # 0xAA -> LATIN CAPITAL LETTER R WITH CEDILLA
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xc6' # 0xAF -> LATIN CAPITAL LETTER AE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xf8' # 0xB8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\u0157' # 0xBA -> LATIN SMALL LETTER R WITH CEDILLA
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xe6' # 0xBF -> LATIN SMALL LETTER AE
+ '\u0104' # 0xC0 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u012e' # 0xC1 -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u0100' # 0xC2 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\u0106' # 0xC3 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\u0118' # 0xC6 -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\u0112' # 0xC7 -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0179' # 0xCA -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\u0116' # 0xCB -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\u0122' # 0xCC -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\u0136' # 0xCD -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\u012a' # 0xCE -> LATIN CAPITAL LETTER I WITH MACRON
+ '\u013b' # 0xCF -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\u0160' # 0xD0 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\u0145' # 0xD2 -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\u014c' # 0xD4 -> LATIN CAPITAL LETTER O WITH MACRON
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u0172' # 0xD8 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\u0141' # 0xD9 -> LATIN CAPITAL LETTER L WITH STROKE
+ '\u015a' # 0xDA -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u016a' # 0xDB -> LATIN CAPITAL LETTER U WITH MACRON
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u017b' # 0xDD -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\u017d' # 0xDE -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\u0105' # 0xE0 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u012f' # 0xE1 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u0101' # 0xE2 -> LATIN SMALL LETTER A WITH MACRON
+ '\u0107' # 0xE3 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\u0119' # 0xE6 -> LATIN SMALL LETTER E WITH OGONEK
+ '\u0113' # 0xE7 -> LATIN SMALL LETTER E WITH MACRON
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u017a' # 0xEA -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u0117' # 0xEB -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\u0123' # 0xEC -> LATIN SMALL LETTER G WITH CEDILLA
+ '\u0137' # 0xED -> LATIN SMALL LETTER K WITH CEDILLA
+ '\u012b' # 0xEE -> LATIN SMALL LETTER I WITH MACRON
+ '\u013c' # 0xEF -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u0161' # 0xF0 -> LATIN SMALL LETTER S WITH CARON
+ '\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0146' # 0xF2 -> LATIN SMALL LETTER N WITH CEDILLA
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\u014d' # 0xF4 -> LATIN SMALL LETTER O WITH MACRON
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u0173' # 0xF8 -> LATIN SMALL LETTER U WITH OGONEK
+ '\u0142' # 0xF9 -> LATIN SMALL LETTER L WITH STROKE
+ '\u015b' # 0xFA -> LATIN SMALL LETTER S WITH ACUTE
+ '\u016b' # 0xFB -> LATIN SMALL LETTER U WITH MACRON
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u017e' # 0xFE -> LATIN SMALL LETTER Z WITH CARON
+ '\u02d9' # 0xFF -> DOT ABOVE
)
### Encoding table
diff --git a/Lib/encodings/cp1258.py b/Lib/encodings/cp1258.py
index 4b25d8e7e80..784378a8369 100644
--- a/Lib/encodings/cp1258.py
+++ b/Lib/encodings/cp1258.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
- u'\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
- u'\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\u2020' # 0x86 -> DAGGER
- u'\u2021' # 0x87 -> DOUBLE DAGGER
- u'\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u2030' # 0x89 -> PER MILLE SIGN
- u'\ufffe' # 0x8A -> UNDEFINED
- u'\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\u02dc' # 0x98 -> SMALL TILDE
- u'\u2122' # 0x99 -> TRADE MARK SIGN
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u0300' # 0xCC -> COMBINING GRAVE ACCENT
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\u0309' # 0xD2 -> COMBINING HOOK ABOVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u01a0' # 0xD5 -> LATIN CAPITAL LETTER O WITH HORN
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u01af' # 0xDD -> LATIN CAPITAL LETTER U WITH HORN
- u'\u0303' # 0xDE -> COMBINING TILDE
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u0301' # 0xEC -> COMBINING ACUTE ACCENT
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\u0323' # 0xF2 -> COMBINING DOT BELOW
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u01a1' # 0xF5 -> LATIN SMALL LETTER O WITH HORN
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u01b0' # 0xFD -> LATIN SMALL LETTER U WITH HORN
- u'\u20ab' # 0xFE -> DONG SIGN
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\u201a' # 0x82 -> SINGLE LOW-9 QUOTATION MARK
+ '\u0192' # 0x83 -> LATIN SMALL LETTER F WITH HOOK
+ '\u201e' # 0x84 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\u2020' # 0x86 -> DAGGER
+ '\u2021' # 0x87 -> DOUBLE DAGGER
+ '\u02c6' # 0x88 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u2030' # 0x89 -> PER MILLE SIGN
+ '\ufffe' # 0x8A -> UNDEFINED
+ '\u2039' # 0x8B -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u0152' # 0x8C -> LATIN CAPITAL LIGATURE OE
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\u02dc' # 0x98 -> SMALL TILDE
+ '\u2122' # 0x99 -> TRADE MARK SIGN
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\u203a' # 0x9B -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u0153' # 0x9C -> LATIN SMALL LIGATURE OE
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\u0178' # 0x9F -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u0300' # 0xCC -> COMBINING GRAVE ACCENT
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\u0309' # 0xD2 -> COMBINING HOOK ABOVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u01a0' # 0xD5 -> LATIN CAPITAL LETTER O WITH HORN
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u01af' # 0xDD -> LATIN CAPITAL LETTER U WITH HORN
+ '\u0303' # 0xDE -> COMBINING TILDE
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u0301' # 0xEC -> COMBINING ACUTE ACCENT
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\u0323' # 0xF2 -> COMBINING DOT BELOW
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u01a1' # 0xF5 -> LATIN SMALL LETTER O WITH HORN
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u01b0' # 0xFD -> LATIN SMALL LETTER U WITH HORN
+ '\u20ab' # 0xFE -> DONG SIGN
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/cp424.py b/Lib/encodings/cp424.py
index d3ade227768..6753daf122d 100644
--- a/Lib/encodings/cp424.py
+++ b/Lib/encodings/cp424.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> SELECT
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> REQUIRED NEW LINE
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> GRAPHIC ESCAPE
- u'\x8d' # 0x09 -> SUPERSCRIPT
- u'\x8e' # 0x0A -> REPEAT
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> RESTORE/ENABLE PRESENTATION
- u'\x85' # 0x15 -> NEW LINE
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> PROGRAM OPERATOR COMMUNICATION
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> UNIT BACK SPACE
- u'\x8f' # 0x1B -> CUSTOMER USE ONE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> DIGIT SELECT
- u'\x81' # 0x21 -> START OF SIGNIFICANCE
- u'\x82' # 0x22 -> FIELD SEPARATOR
- u'\x83' # 0x23 -> WORD UNDERSCORE
- u'\x84' # 0x24 -> BYPASS OR INHIBIT PRESENTATION
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> SET ATTRIBUTE
- u'\x89' # 0x29 -> START FIELD EXTENDED
- u'\x8a' # 0x2A -> SET MODE OR SWITCH
- u'\x8b' # 0x2B -> CONTROL SEQUENCE PREFIX
- u'\x8c' # 0x2C -> MODIFY FIELD ATTRIBUTE
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> <reserved>
- u'\x91' # 0x31 -> <reserved>
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> INDEX RETURN
- u'\x94' # 0x34 -> PRESENTATION POSITION
- u'\x95' # 0x35 -> TRANSPARENT
- u'\x96' # 0x36 -> NUMERIC BACKSPACE
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> SUBSCRIPT
- u'\x99' # 0x39 -> INDENT TABULATION
- u'\x9a' # 0x3A -> REVERSE FORM FEED
- u'\x9b' # 0x3B -> CUSTOMER USE THREE
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> <reserved>
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\u05d0' # 0x41 -> HEBREW LETTER ALEF
- u'\u05d1' # 0x42 -> HEBREW LETTER BET
- u'\u05d2' # 0x43 -> HEBREW LETTER GIMEL
- u'\u05d3' # 0x44 -> HEBREW LETTER DALET
- u'\u05d4' # 0x45 -> HEBREW LETTER HE
- u'\u05d5' # 0x46 -> HEBREW LETTER VAV
- u'\u05d6' # 0x47 -> HEBREW LETTER ZAYIN
- u'\u05d7' # 0x48 -> HEBREW LETTER HET
- u'\u05d8' # 0x49 -> HEBREW LETTER TET
- u'\xa2' # 0x4A -> CENT SIGN
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'|' # 0x4F -> VERTICAL LINE
- u'&' # 0x50 -> AMPERSAND
- u'\u05d9' # 0x51 -> HEBREW LETTER YOD
- u'\u05da' # 0x52 -> HEBREW LETTER FINAL KAF
- u'\u05db' # 0x53 -> HEBREW LETTER KAF
- u'\u05dc' # 0x54 -> HEBREW LETTER LAMED
- u'\u05dd' # 0x55 -> HEBREW LETTER FINAL MEM
- u'\u05de' # 0x56 -> HEBREW LETTER MEM
- u'\u05df' # 0x57 -> HEBREW LETTER FINAL NUN
- u'\u05e0' # 0x58 -> HEBREW LETTER NUN
- u'\u05e1' # 0x59 -> HEBREW LETTER SAMEKH
- u'!' # 0x5A -> EXCLAMATION MARK
- u'$' # 0x5B -> DOLLAR SIGN
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'\xac' # 0x5F -> NOT SIGN
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\u05e2' # 0x62 -> HEBREW LETTER AYIN
- u'\u05e3' # 0x63 -> HEBREW LETTER FINAL PE
- u'\u05e4' # 0x64 -> HEBREW LETTER PE
- u'\u05e5' # 0x65 -> HEBREW LETTER FINAL TSADI
- u'\u05e6' # 0x66 -> HEBREW LETTER TSADI
- u'\u05e7' # 0x67 -> HEBREW LETTER QOF
- u'\u05e8' # 0x68 -> HEBREW LETTER RESH
- u'\u05e9' # 0x69 -> HEBREW LETTER SHIN
- u'\xa6' # 0x6A -> BROKEN BAR
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\ufffe' # 0x70 -> UNDEFINED
- u'\u05ea' # 0x71 -> HEBREW LETTER TAV
- u'\ufffe' # 0x72 -> UNDEFINED
- u'\ufffe' # 0x73 -> UNDEFINED
- u'\xa0' # 0x74 -> NO-BREAK SPACE
- u'\ufffe' # 0x75 -> UNDEFINED
- u'\ufffe' # 0x76 -> UNDEFINED
- u'\ufffe' # 0x77 -> UNDEFINED
- u'\u2017' # 0x78 -> DOUBLE LOW LINE
- u'`' # 0x79 -> GRAVE ACCENT
- u':' # 0x7A -> COLON
- u'#' # 0x7B -> NUMBER SIGN
- u'@' # 0x7C -> COMMERCIAL AT
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'"' # 0x7F -> QUOTATION MARK
- u'\ufffe' # 0x80 -> UNDEFINED
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\ufffe' # 0x8C -> UNDEFINED
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\xb1' # 0x8F -> PLUS-MINUS SIGN
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\ufffe' # 0x9B -> UNDEFINED
- u'\ufffe' # 0x9C -> UNDEFINED
- u'\xb8' # 0x9D -> CEDILLA
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\xa4' # 0x9F -> CURRENCY SIGN
- u'\xb5' # 0xA0 -> MICRO SIGN
- u'~' # 0xA1 -> TILDE
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\ufffe' # 0xAA -> UNDEFINED
- u'\ufffe' # 0xAB -> UNDEFINED
- u'\ufffe' # 0xAC -> UNDEFINED
- u'\ufffe' # 0xAD -> UNDEFINED
- u'\ufffe' # 0xAE -> UNDEFINED
- u'\xae' # 0xAF -> REGISTERED SIGN
- u'^' # 0xB0 -> CIRCUMFLEX ACCENT
- u'\xa3' # 0xB1 -> POUND SIGN
- u'\xa5' # 0xB2 -> YEN SIGN
- u'\xb7' # 0xB3 -> MIDDLE DOT
- u'\xa9' # 0xB4 -> COPYRIGHT SIGN
- u'\xa7' # 0xB5 -> SECTION SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
- u'[' # 0xBA -> LEFT SQUARE BRACKET
- u']' # 0xBB -> RIGHT SQUARE BRACKET
- u'\xaf' # 0xBC -> MACRON
- u'\xa8' # 0xBD -> DIAERESIS
- u'\xb4' # 0xBE -> ACUTE ACCENT
- u'\xd7' # 0xBF -> MULTIPLICATION SIGN
- u'{' # 0xC0 -> LEFT CURLY BRACKET
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\ufffe' # 0xCB -> UNDEFINED
- u'\ufffe' # 0xCC -> UNDEFINED
- u'\ufffe' # 0xCD -> UNDEFINED
- u'\ufffe' # 0xCE -> UNDEFINED
- u'\ufffe' # 0xCF -> UNDEFINED
- u'}' # 0xD0 -> RIGHT CURLY BRACKET
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb9' # 0xDA -> SUPERSCRIPT ONE
- u'\ufffe' # 0xDB -> UNDEFINED
- u'\ufffe' # 0xDC -> UNDEFINED
- u'\ufffe' # 0xDD -> UNDEFINED
- u'\ufffe' # 0xDE -> UNDEFINED
- u'\ufffe' # 0xDF -> UNDEFINED
- u'\\' # 0xE0 -> REVERSE SOLIDUS
- u'\xf7' # 0xE1 -> DIVISION SIGN
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\ufffe' # 0xEB -> UNDEFINED
- u'\ufffe' # 0xEC -> UNDEFINED
- u'\ufffe' # 0xED -> UNDEFINED
- u'\ufffe' # 0xEE -> UNDEFINED
- u'\ufffe' # 0xEF -> UNDEFINED
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\ufffe' # 0xFB -> UNDEFINED
- u'\ufffe' # 0xFC -> UNDEFINED
- u'\ufffe' # 0xFD -> UNDEFINED
- u'\ufffe' # 0xFE -> UNDEFINED
- u'\x9f' # 0xFF -> EIGHT ONES
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> SELECT
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> REQUIRED NEW LINE
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> GRAPHIC ESCAPE
+ '\x8d' # 0x09 -> SUPERSCRIPT
+ '\x8e' # 0x0A -> REPEAT
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> RESTORE/ENABLE PRESENTATION
+ '\x85' # 0x15 -> NEW LINE
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> PROGRAM OPERATOR COMMUNICATION
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> UNIT BACK SPACE
+ '\x8f' # 0x1B -> CUSTOMER USE ONE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> DIGIT SELECT
+ '\x81' # 0x21 -> START OF SIGNIFICANCE
+ '\x82' # 0x22 -> FIELD SEPARATOR
+ '\x83' # 0x23 -> WORD UNDERSCORE
+ '\x84' # 0x24 -> BYPASS OR INHIBIT PRESENTATION
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> SET ATTRIBUTE
+ '\x89' # 0x29 -> START FIELD EXTENDED
+ '\x8a' # 0x2A -> SET MODE OR SWITCH
+ '\x8b' # 0x2B -> CONTROL SEQUENCE PREFIX
+ '\x8c' # 0x2C -> MODIFY FIELD ATTRIBUTE
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> <reserved>
+ '\x91' # 0x31 -> <reserved>
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> INDEX RETURN
+ '\x94' # 0x34 -> PRESENTATION POSITION
+ '\x95' # 0x35 -> TRANSPARENT
+ '\x96' # 0x36 -> NUMERIC BACKSPACE
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> SUBSCRIPT
+ '\x99' # 0x39 -> INDENT TABULATION
+ '\x9a' # 0x3A -> REVERSE FORM FEED
+ '\x9b' # 0x3B -> CUSTOMER USE THREE
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> <reserved>
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\u05d0' # 0x41 -> HEBREW LETTER ALEF
+ '\u05d1' # 0x42 -> HEBREW LETTER BET
+ '\u05d2' # 0x43 -> HEBREW LETTER GIMEL
+ '\u05d3' # 0x44 -> HEBREW LETTER DALET
+ '\u05d4' # 0x45 -> HEBREW LETTER HE
+ '\u05d5' # 0x46 -> HEBREW LETTER VAV
+ '\u05d6' # 0x47 -> HEBREW LETTER ZAYIN
+ '\u05d7' # 0x48 -> HEBREW LETTER HET
+ '\u05d8' # 0x49 -> HEBREW LETTER TET
+ '\xa2' # 0x4A -> CENT SIGN
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '|' # 0x4F -> VERTICAL LINE
+ '&' # 0x50 -> AMPERSAND
+ '\u05d9' # 0x51 -> HEBREW LETTER YOD
+ '\u05da' # 0x52 -> HEBREW LETTER FINAL KAF
+ '\u05db' # 0x53 -> HEBREW LETTER KAF
+ '\u05dc' # 0x54 -> HEBREW LETTER LAMED
+ '\u05dd' # 0x55 -> HEBREW LETTER FINAL MEM
+ '\u05de' # 0x56 -> HEBREW LETTER MEM
+ '\u05df' # 0x57 -> HEBREW LETTER FINAL NUN
+ '\u05e0' # 0x58 -> HEBREW LETTER NUN
+ '\u05e1' # 0x59 -> HEBREW LETTER SAMEKH
+ '!' # 0x5A -> EXCLAMATION MARK
+ '$' # 0x5B -> DOLLAR SIGN
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '\xac' # 0x5F -> NOT SIGN
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\u05e2' # 0x62 -> HEBREW LETTER AYIN
+ '\u05e3' # 0x63 -> HEBREW LETTER FINAL PE
+ '\u05e4' # 0x64 -> HEBREW LETTER PE
+ '\u05e5' # 0x65 -> HEBREW LETTER FINAL TSADI
+ '\u05e6' # 0x66 -> HEBREW LETTER TSADI
+ '\u05e7' # 0x67 -> HEBREW LETTER QOF
+ '\u05e8' # 0x68 -> HEBREW LETTER RESH
+ '\u05e9' # 0x69 -> HEBREW LETTER SHIN
+ '\xa6' # 0x6A -> BROKEN BAR
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\ufffe' # 0x70 -> UNDEFINED
+ '\u05ea' # 0x71 -> HEBREW LETTER TAV
+ '\ufffe' # 0x72 -> UNDEFINED
+ '\ufffe' # 0x73 -> UNDEFINED
+ '\xa0' # 0x74 -> NO-BREAK SPACE
+ '\ufffe' # 0x75 -> UNDEFINED
+ '\ufffe' # 0x76 -> UNDEFINED
+ '\ufffe' # 0x77 -> UNDEFINED
+ '\u2017' # 0x78 -> DOUBLE LOW LINE
+ '`' # 0x79 -> GRAVE ACCENT
+ ':' # 0x7A -> COLON
+ '#' # 0x7B -> NUMBER SIGN
+ '@' # 0x7C -> COMMERCIAL AT
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '"' # 0x7F -> QUOTATION MARK
+ '\ufffe' # 0x80 -> UNDEFINED
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\ufffe' # 0x8C -> UNDEFINED
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\xb1' # 0x8F -> PLUS-MINUS SIGN
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\ufffe' # 0x9B -> UNDEFINED
+ '\ufffe' # 0x9C -> UNDEFINED
+ '\xb8' # 0x9D -> CEDILLA
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\xa4' # 0x9F -> CURRENCY SIGN
+ '\xb5' # 0xA0 -> MICRO SIGN
+ '~' # 0xA1 -> TILDE
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\ufffe' # 0xAA -> UNDEFINED
+ '\ufffe' # 0xAB -> UNDEFINED
+ '\ufffe' # 0xAC -> UNDEFINED
+ '\ufffe' # 0xAD -> UNDEFINED
+ '\ufffe' # 0xAE -> UNDEFINED
+ '\xae' # 0xAF -> REGISTERED SIGN
+ '^' # 0xB0 -> CIRCUMFLEX ACCENT
+ '\xa3' # 0xB1 -> POUND SIGN
+ '\xa5' # 0xB2 -> YEN SIGN
+ '\xb7' # 0xB3 -> MIDDLE DOT
+ '\xa9' # 0xB4 -> COPYRIGHT SIGN
+ '\xa7' # 0xB5 -> SECTION SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
+ '[' # 0xBA -> LEFT SQUARE BRACKET
+ ']' # 0xBB -> RIGHT SQUARE BRACKET
+ '\xaf' # 0xBC -> MACRON
+ '\xa8' # 0xBD -> DIAERESIS
+ '\xb4' # 0xBE -> ACUTE ACCENT
+ '\xd7' # 0xBF -> MULTIPLICATION SIGN
+ '{' # 0xC0 -> LEFT CURLY BRACKET
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\ufffe' # 0xCB -> UNDEFINED
+ '\ufffe' # 0xCC -> UNDEFINED
+ '\ufffe' # 0xCD -> UNDEFINED
+ '\ufffe' # 0xCE -> UNDEFINED
+ '\ufffe' # 0xCF -> UNDEFINED
+ '}' # 0xD0 -> RIGHT CURLY BRACKET
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb9' # 0xDA -> SUPERSCRIPT ONE
+ '\ufffe' # 0xDB -> UNDEFINED
+ '\ufffe' # 0xDC -> UNDEFINED
+ '\ufffe' # 0xDD -> UNDEFINED
+ '\ufffe' # 0xDE -> UNDEFINED
+ '\ufffe' # 0xDF -> UNDEFINED
+ '\\' # 0xE0 -> REVERSE SOLIDUS
+ '\xf7' # 0xE1 -> DIVISION SIGN
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\ufffe' # 0xEB -> UNDEFINED
+ '\ufffe' # 0xEC -> UNDEFINED
+ '\ufffe' # 0xED -> UNDEFINED
+ '\ufffe' # 0xEE -> UNDEFINED
+ '\ufffe' # 0xEF -> UNDEFINED
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\ufffe' # 0xFB -> UNDEFINED
+ '\ufffe' # 0xFC -> UNDEFINED
+ '\ufffe' # 0xFD -> UNDEFINED
+ '\ufffe' # 0xFE -> UNDEFINED
+ '\x9f' # 0xFF -> EIGHT ONES
)
### Encoding table
diff --git a/Lib/encodings/cp437.py b/Lib/encodings/cp437.py
index 52cd8829428..b6c75e2ca1c 100644
--- a/Lib/encodings/cp437.py
+++ b/Lib/encodings/cp437.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xa2' # 0x009b -> CENT SIGN
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xa5' # 0x009d -> YEN SIGN
- u'\u20a7' # 0x009e -> PESETA SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\u2310' # 0x00a9 -> REVERSED NOT SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xa2' # 0x009b -> CENT SIGN
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xa5' # 0x009d -> YEN SIGN
+ '\u20a7' # 0x009e -> PESETA SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\u2310' # 0x00a9 -> REVERSED NOT SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp500.py b/Lib/encodings/cp500.py
index 60766c0393b..5f61535f82a 100644
--- a/Lib/encodings/cp500.py
+++ b/Lib/encodings/cp500.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> CONTROL
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> CONTROL
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> CONTROL
- u'\x8d' # 0x09 -> CONTROL
- u'\x8e' # 0x0A -> CONTROL
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> CONTROL
- u'\x85' # 0x15 -> CONTROL
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> CONTROL
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> CONTROL
- u'\x8f' # 0x1B -> CONTROL
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> CONTROL
- u'\x81' # 0x21 -> CONTROL
- u'\x82' # 0x22 -> CONTROL
- u'\x83' # 0x23 -> CONTROL
- u'\x84' # 0x24 -> CONTROL
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> CONTROL
- u'\x89' # 0x29 -> CONTROL
- u'\x8a' # 0x2A -> CONTROL
- u'\x8b' # 0x2B -> CONTROL
- u'\x8c' # 0x2C -> CONTROL
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> CONTROL
- u'\x91' # 0x31 -> CONTROL
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> CONTROL
- u'\x94' # 0x34 -> CONTROL
- u'\x95' # 0x35 -> CONTROL
- u'\x96' # 0x36 -> CONTROL
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> CONTROL
- u'\x99' # 0x39 -> CONTROL
- u'\x9a' # 0x3A -> CONTROL
- u'\x9b' # 0x3B -> CONTROL
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> CONTROL
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\xa0' # 0x41 -> NO-BREAK SPACE
- u'\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
- u'[' # 0x4A -> LEFT SQUARE BRACKET
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'!' # 0x4F -> EXCLAMATION MARK
- u'&' # 0x50 -> AMPERSAND
- u'\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u']' # 0x5A -> RIGHT SQUARE BRACKET
- u'$' # 0x5B -> DOLLAR SIGN
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'^' # 0x5F -> CIRCUMFLEX ACCENT
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xa6' # 0x6A -> BROKEN BAR
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
- u'\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
- u'`' # 0x79 -> GRAVE ACCENT
- u':' # 0x7A -> COLON
- u'#' # 0x7B -> NUMBER SIGN
- u'@' # 0x7C -> COMMERCIAL AT
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'"' # 0x7F -> QUOTATION MARK
- u'\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
- u'\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
- u'\xb1' # 0x8F -> PLUS-MINUS SIGN
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
- u'\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
- u'\xb8' # 0x9D -> CEDILLA
- u'\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
- u'\xa4' # 0x9F -> CURRENCY SIGN
- u'\xb5' # 0xA0 -> MICRO SIGN
- u'~' # 0xA1 -> TILDE
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
- u'\xbf' # 0xAB -> INVERTED QUESTION MARK
- u'\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
- u'\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
- u'\xae' # 0xAF -> REGISTERED SIGN
- u'\xa2' # 0xB0 -> CENT SIGN
- u'\xa3' # 0xB1 -> POUND SIGN
- u'\xa5' # 0xB2 -> YEN SIGN
- u'\xb7' # 0xB3 -> MIDDLE DOT
- u'\xa9' # 0xB4 -> COPYRIGHT SIGN
- u'\xa7' # 0xB5 -> SECTION SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
- u'\xac' # 0xBA -> NOT SIGN
- u'|' # 0xBB -> VERTICAL LINE
- u'\xaf' # 0xBC -> MACRON
- u'\xa8' # 0xBD -> DIAERESIS
- u'\xb4' # 0xBE -> ACUTE ACCENT
- u'\xd7' # 0xBF -> MULTIPLICATION SIGN
- u'{' # 0xC0 -> LEFT CURLY BRACKET
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
- u'}' # 0xD0 -> RIGHT CURLY BRACKET
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb9' # 0xDA -> SUPERSCRIPT ONE
- u'\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
- u'\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\\' # 0xE0 -> REVERSE SOLIDUS
- u'\xf7' # 0xE1 -> DIVISION SIGN
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\x9f' # 0xFF -> CONTROL
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> CONTROL
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> CONTROL
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> CONTROL
+ '\x8d' # 0x09 -> CONTROL
+ '\x8e' # 0x0A -> CONTROL
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> CONTROL
+ '\x85' # 0x15 -> CONTROL
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> CONTROL
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> CONTROL
+ '\x8f' # 0x1B -> CONTROL
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> CONTROL
+ '\x81' # 0x21 -> CONTROL
+ '\x82' # 0x22 -> CONTROL
+ '\x83' # 0x23 -> CONTROL
+ '\x84' # 0x24 -> CONTROL
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> CONTROL
+ '\x89' # 0x29 -> CONTROL
+ '\x8a' # 0x2A -> CONTROL
+ '\x8b' # 0x2B -> CONTROL
+ '\x8c' # 0x2C -> CONTROL
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> CONTROL
+ '\x91' # 0x31 -> CONTROL
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> CONTROL
+ '\x94' # 0x34 -> CONTROL
+ '\x95' # 0x35 -> CONTROL
+ '\x96' # 0x36 -> CONTROL
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> CONTROL
+ '\x99' # 0x39 -> CONTROL
+ '\x9a' # 0x3A -> CONTROL
+ '\x9b' # 0x3B -> CONTROL
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> CONTROL
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\xa0' # 0x41 -> NO-BREAK SPACE
+ '\xe2' # 0x42 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x43 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x44 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0x45 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe3' # 0x46 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x47 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x48 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xf1' # 0x49 -> LATIN SMALL LETTER N WITH TILDE
+ '[' # 0x4A -> LEFT SQUARE BRACKET
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '!' # 0x4F -> EXCLAMATION MARK
+ '&' # 0x50 -> AMPERSAND
+ '\xe9' # 0x51 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0x52 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x53 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x54 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xed' # 0x55 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0x56 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x57 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xec' # 0x58 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xdf' # 0x59 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ ']' # 0x5A -> RIGHT SQUARE BRACKET
+ '$' # 0x5B -> DOLLAR SIGN
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '^' # 0x5F -> CIRCUMFLEX ACCENT
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\xc2' # 0x62 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc4' # 0x63 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc0' # 0x64 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0x65 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc3' # 0x66 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc5' # 0x67 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x68 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xd1' # 0x69 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xa6' # 0x6A -> BROKEN BAR
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\xf8' # 0x70 -> LATIN SMALL LETTER O WITH STROKE
+ '\xc9' # 0x71 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0x72 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x73 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x74 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0x75 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x76 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x77 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0x78 -> LATIN CAPITAL LETTER I WITH GRAVE
+ '`' # 0x79 -> GRAVE ACCENT
+ ':' # 0x7A -> COLON
+ '#' # 0x7B -> NUMBER SIGN
+ '@' # 0x7C -> COMMERCIAL AT
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '"' # 0x7F -> QUOTATION MARK
+ '\xd8' # 0x80 -> LATIN CAPITAL LETTER O WITH STROKE
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\xab' # 0x8A -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x8B -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xf0' # 0x8C -> LATIN SMALL LETTER ETH (ICELANDIC)
+ '\xfd' # 0x8D -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0x8E -> LATIN SMALL LETTER THORN (ICELANDIC)
+ '\xb1' # 0x8F -> PLUS-MINUS SIGN
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\xaa' # 0x9A -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x9B -> MASCULINE ORDINAL INDICATOR
+ '\xe6' # 0x9C -> LATIN SMALL LIGATURE AE
+ '\xb8' # 0x9D -> CEDILLA
+ '\xc6' # 0x9E -> LATIN CAPITAL LIGATURE AE
+ '\xa4' # 0x9F -> CURRENCY SIGN
+ '\xb5' # 0xA0 -> MICRO SIGN
+ '~' # 0xA1 -> TILDE
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\xa1' # 0xAA -> INVERTED EXCLAMATION MARK
+ '\xbf' # 0xAB -> INVERTED QUESTION MARK
+ '\xd0' # 0xAC -> LATIN CAPITAL LETTER ETH (ICELANDIC)
+ '\xdd' # 0xAD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xAE -> LATIN CAPITAL LETTER THORN (ICELANDIC)
+ '\xae' # 0xAF -> REGISTERED SIGN
+ '\xa2' # 0xB0 -> CENT SIGN
+ '\xa3' # 0xB1 -> POUND SIGN
+ '\xa5' # 0xB2 -> YEN SIGN
+ '\xb7' # 0xB3 -> MIDDLE DOT
+ '\xa9' # 0xB4 -> COPYRIGHT SIGN
+ '\xa7' # 0xB5 -> SECTION SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xbc' # 0xB7 -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xB8 -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xB9 -> VULGAR FRACTION THREE QUARTERS
+ '\xac' # 0xBA -> NOT SIGN
+ '|' # 0xBB -> VERTICAL LINE
+ '\xaf' # 0xBC -> MACRON
+ '\xa8' # 0xBD -> DIAERESIS
+ '\xb4' # 0xBE -> ACUTE ACCENT
+ '\xd7' # 0xBF -> MULTIPLICATION SIGN
+ '{' # 0xC0 -> LEFT CURLY BRACKET
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\xf4' # 0xCB -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0xCC -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0xCD -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xCE -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf5' # 0xCF -> LATIN SMALL LETTER O WITH TILDE
+ '}' # 0xD0 -> RIGHT CURLY BRACKET
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb9' # 0xDA -> SUPERSCRIPT ONE
+ '\xfb' # 0xDB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xDC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xf9' # 0xDD -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xDE -> LATIN SMALL LETTER U WITH ACUTE
+ '\xff' # 0xDF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\\' # 0xE0 -> REVERSE SOLIDUS
+ '\xf7' # 0xE1 -> DIVISION SIGN
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\xd4' # 0xEB -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd6' # 0xEC -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd2' # 0xED -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd5' # 0xEF -> LATIN CAPITAL LETTER O WITH TILDE
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\xdb' # 0xFB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xFC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xd9' # 0xFD -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xFE -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\x9f' # 0xFF -> CONTROL
)
### Encoding table
diff --git a/Lib/encodings/cp720.py b/Lib/encodings/cp720.py
index 5c96d9813cf..96d609616c4 100644
--- a/Lib/encodings/cp720.py
+++ b/Lib/encodings/cp720.py
@@ -47,262 +47,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\x80'
- u'\x81'
- u'\xe9' # 0x82 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x83 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\x84'
- u'\xe0' # 0x85 -> LATIN SMALL LETTER A WITH GRAVE
- u'\x86'
- u'\xe7' # 0x87 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x88 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x89 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x8A -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x8B -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x8C -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\x8d'
- u'\x8e'
- u'\x8f'
- u'\x90'
- u'\u0651' # 0x91 -> ARABIC SHADDA
- u'\u0652' # 0x92 -> ARABIC SUKUN
- u'\xf4' # 0x93 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xa4' # 0x94 -> CURRENCY SIGN
- u'\u0640' # 0x95 -> ARABIC TATWEEL
- u'\xfb' # 0x96 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x97 -> LATIN SMALL LETTER U WITH GRAVE
- u'\u0621' # 0x98 -> ARABIC LETTER HAMZA
- u'\u0622' # 0x99 -> ARABIC LETTER ALEF WITH MADDA ABOVE
- u'\u0623' # 0x9A -> ARABIC LETTER ALEF WITH HAMZA ABOVE
- u'\u0624' # 0x9B -> ARABIC LETTER WAW WITH HAMZA ABOVE
- u'\xa3' # 0x9C -> POUND SIGN
- u'\u0625' # 0x9D -> ARABIC LETTER ALEF WITH HAMZA BELOW
- u'\u0626' # 0x9E -> ARABIC LETTER YEH WITH HAMZA ABOVE
- u'\u0627' # 0x9F -> ARABIC LETTER ALEF
- u'\u0628' # 0xA0 -> ARABIC LETTER BEH
- u'\u0629' # 0xA1 -> ARABIC LETTER TEH MARBUTA
- u'\u062a' # 0xA2 -> ARABIC LETTER TEH
- u'\u062b' # 0xA3 -> ARABIC LETTER THEH
- u'\u062c' # 0xA4 -> ARABIC LETTER JEEM
- u'\u062d' # 0xA5 -> ARABIC LETTER HAH
- u'\u062e' # 0xA6 -> ARABIC LETTER KHAH
- u'\u062f' # 0xA7 -> ARABIC LETTER DAL
- u'\u0630' # 0xA8 -> ARABIC LETTER THAL
- u'\u0631' # 0xA9 -> ARABIC LETTER REH
- u'\u0632' # 0xAA -> ARABIC LETTER ZAIN
- u'\u0633' # 0xAB -> ARABIC LETTER SEEN
- u'\u0634' # 0xAC -> ARABIC LETTER SHEEN
- u'\u0635' # 0xAD -> ARABIC LETTER SAD
- u'\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0xB0 -> LIGHT SHADE
- u'\u2592' # 0xB1 -> MEDIUM SHADE
- u'\u2593' # 0xB2 -> DARK SHADE
- u'\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0xB5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0xB6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0xB8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0xBD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0xBE -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0xC6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0xC7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0xCF -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0xD0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0xD1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0xD2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0xD3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0xD4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0xD5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0xD6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0xD7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0xD8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0xDB -> FULL BLOCK
- u'\u2584' # 0xDC -> LOWER HALF BLOCK
- u'\u258c' # 0xDD -> LEFT HALF BLOCK
- u'\u2590' # 0xDE -> RIGHT HALF BLOCK
- u'\u2580' # 0xDF -> UPPER HALF BLOCK
- u'\u0636' # 0xE0 -> ARABIC LETTER DAD
- u'\u0637' # 0xE1 -> ARABIC LETTER TAH
- u'\u0638' # 0xE2 -> ARABIC LETTER ZAH
- u'\u0639' # 0xE3 -> ARABIC LETTER AIN
- u'\u063a' # 0xE4 -> ARABIC LETTER GHAIN
- u'\u0641' # 0xE5 -> ARABIC LETTER FEH
- u'\xb5' # 0xE6 -> MICRO SIGN
- u'\u0642' # 0xE7 -> ARABIC LETTER QAF
- u'\u0643' # 0xE8 -> ARABIC LETTER KAF
- u'\u0644' # 0xE9 -> ARABIC LETTER LAM
- u'\u0645' # 0xEA -> ARABIC LETTER MEEM
- u'\u0646' # 0xEB -> ARABIC LETTER NOON
- u'\u0647' # 0xEC -> ARABIC LETTER HEH
- u'\u0648' # 0xED -> ARABIC LETTER WAW
- u'\u0649' # 0xEE -> ARABIC LETTER ALEF MAKSURA
- u'\u064a' # 0xEF -> ARABIC LETTER YEH
- u'\u2261' # 0xF0 -> IDENTICAL TO
- u'\u064b' # 0xF1 -> ARABIC FATHATAN
- u'\u064c' # 0xF2 -> ARABIC DAMMATAN
- u'\u064d' # 0xF3 -> ARABIC KASRATAN
- u'\u064e' # 0xF4 -> ARABIC FATHA
- u'\u064f' # 0xF5 -> ARABIC DAMMA
- u'\u0650' # 0xF6 -> ARABIC KASRA
- u'\u2248' # 0xF7 -> ALMOST EQUAL TO
- u'\xb0' # 0xF8 -> DEGREE SIGN
- u'\u2219' # 0xF9 -> BULLET OPERATOR
- u'\xb7' # 0xFA -> MIDDLE DOT
- u'\u221a' # 0xFB -> SQUARE ROOT
- u'\u207f' # 0xFC -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0xFD -> SUPERSCRIPT TWO
- u'\u25a0' # 0xFE -> BLACK SQUARE
- u'\xa0' # 0xFF -> NO-BREAK SPACE
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\x80'
+ '\x81'
+ '\xe9' # 0x82 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x83 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\x84'
+ '\xe0' # 0x85 -> LATIN SMALL LETTER A WITH GRAVE
+ '\x86'
+ '\xe7' # 0x87 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x88 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x89 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x8A -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x8B -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x8C -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\x8d'
+ '\x8e'
+ '\x8f'
+ '\x90'
+ '\u0651' # 0x91 -> ARABIC SHADDA
+ '\u0652' # 0x92 -> ARABIC SUKUN
+ '\xf4' # 0x93 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xa4' # 0x94 -> CURRENCY SIGN
+ '\u0640' # 0x95 -> ARABIC TATWEEL
+ '\xfb' # 0x96 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x97 -> LATIN SMALL LETTER U WITH GRAVE
+ '\u0621' # 0x98 -> ARABIC LETTER HAMZA
+ '\u0622' # 0x99 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0x9A -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0x9B -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\xa3' # 0x9C -> POUND SIGN
+ '\u0625' # 0x9D -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0x9E -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0x9F -> ARABIC LETTER ALEF
+ '\u0628' # 0xA0 -> ARABIC LETTER BEH
+ '\u0629' # 0xA1 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0xA2 -> ARABIC LETTER TEH
+ '\u062b' # 0xA3 -> ARABIC LETTER THEH
+ '\u062c' # 0xA4 -> ARABIC LETTER JEEM
+ '\u062d' # 0xA5 -> ARABIC LETTER HAH
+ '\u062e' # 0xA6 -> ARABIC LETTER KHAH
+ '\u062f' # 0xA7 -> ARABIC LETTER DAL
+ '\u0630' # 0xA8 -> ARABIC LETTER THAL
+ '\u0631' # 0xA9 -> ARABIC LETTER REH
+ '\u0632' # 0xAA -> ARABIC LETTER ZAIN
+ '\u0633' # 0xAB -> ARABIC LETTER SEEN
+ '\u0634' # 0xAC -> ARABIC LETTER SHEEN
+ '\u0635' # 0xAD -> ARABIC LETTER SAD
+ '\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0xB0 -> LIGHT SHADE
+ '\u2592' # 0xB1 -> MEDIUM SHADE
+ '\u2593' # 0xB2 -> DARK SHADE
+ '\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0xB5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0xB6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0xB8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0xBD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0xBE -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0xC6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0xC7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0xCF -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0xD0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0xD1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0xD2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0xD3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0xD4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0xD5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0xD6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0xD7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0xD8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0xDB -> FULL BLOCK
+ '\u2584' # 0xDC -> LOWER HALF BLOCK
+ '\u258c' # 0xDD -> LEFT HALF BLOCK
+ '\u2590' # 0xDE -> RIGHT HALF BLOCK
+ '\u2580' # 0xDF -> UPPER HALF BLOCK
+ '\u0636' # 0xE0 -> ARABIC LETTER DAD
+ '\u0637' # 0xE1 -> ARABIC LETTER TAH
+ '\u0638' # 0xE2 -> ARABIC LETTER ZAH
+ '\u0639' # 0xE3 -> ARABIC LETTER AIN
+ '\u063a' # 0xE4 -> ARABIC LETTER GHAIN
+ '\u0641' # 0xE5 -> ARABIC LETTER FEH
+ '\xb5' # 0xE6 -> MICRO SIGN
+ '\u0642' # 0xE7 -> ARABIC LETTER QAF
+ '\u0643' # 0xE8 -> ARABIC LETTER KAF
+ '\u0644' # 0xE9 -> ARABIC LETTER LAM
+ '\u0645' # 0xEA -> ARABIC LETTER MEEM
+ '\u0646' # 0xEB -> ARABIC LETTER NOON
+ '\u0647' # 0xEC -> ARABIC LETTER HEH
+ '\u0648' # 0xED -> ARABIC LETTER WAW
+ '\u0649' # 0xEE -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0xEF -> ARABIC LETTER YEH
+ '\u2261' # 0xF0 -> IDENTICAL TO
+ '\u064b' # 0xF1 -> ARABIC FATHATAN
+ '\u064c' # 0xF2 -> ARABIC DAMMATAN
+ '\u064d' # 0xF3 -> ARABIC KASRATAN
+ '\u064e' # 0xF4 -> ARABIC FATHA
+ '\u064f' # 0xF5 -> ARABIC DAMMA
+ '\u0650' # 0xF6 -> ARABIC KASRA
+ '\u2248' # 0xF7 -> ALMOST EQUAL TO
+ '\xb0' # 0xF8 -> DEGREE SIGN
+ '\u2219' # 0xF9 -> BULLET OPERATOR
+ '\xb7' # 0xFA -> MIDDLE DOT
+ '\u221a' # 0xFB -> SQUARE ROOT
+ '\u207f' # 0xFC -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0xFD -> SUPERSCRIPT TWO
+ '\u25a0' # 0xFE -> BLACK SQUARE
+ '\xa0' # 0xFF -> NO-BREAK SPACE
)
### Encoding table
diff --git a/Lib/encodings/cp737.py b/Lib/encodings/cp737.py
index d6544482d2d..9685bae75b3 100644
--- a/Lib/encodings/cp737.py
+++ b/Lib/encodings/cp737.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\u0391' # 0x0080 -> GREEK CAPITAL LETTER ALPHA
- u'\u0392' # 0x0081 -> GREEK CAPITAL LETTER BETA
- u'\u0393' # 0x0082 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0x0083 -> GREEK CAPITAL LETTER DELTA
- u'\u0395' # 0x0084 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0x0085 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0x0086 -> GREEK CAPITAL LETTER ETA
- u'\u0398' # 0x0087 -> GREEK CAPITAL LETTER THETA
- u'\u0399' # 0x0088 -> GREEK CAPITAL LETTER IOTA
- u'\u039a' # 0x0089 -> GREEK CAPITAL LETTER KAPPA
- u'\u039b' # 0x008a -> GREEK CAPITAL LETTER LAMDA
- u'\u039c' # 0x008b -> GREEK CAPITAL LETTER MU
- u'\u039d' # 0x008c -> GREEK CAPITAL LETTER NU
- u'\u039e' # 0x008d -> GREEK CAPITAL LETTER XI
- u'\u039f' # 0x008e -> GREEK CAPITAL LETTER OMICRON
- u'\u03a0' # 0x008f -> GREEK CAPITAL LETTER PI
- u'\u03a1' # 0x0090 -> GREEK CAPITAL LETTER RHO
- u'\u03a3' # 0x0091 -> GREEK CAPITAL LETTER SIGMA
- u'\u03a4' # 0x0092 -> GREEK CAPITAL LETTER TAU
- u'\u03a5' # 0x0093 -> GREEK CAPITAL LETTER UPSILON
- u'\u03a6' # 0x0094 -> GREEK CAPITAL LETTER PHI
- u'\u03a7' # 0x0095 -> GREEK CAPITAL LETTER CHI
- u'\u03a8' # 0x0096 -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0x0097 -> GREEK CAPITAL LETTER OMEGA
- u'\u03b1' # 0x0098 -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0x0099 -> GREEK SMALL LETTER BETA
- u'\u03b3' # 0x009a -> GREEK SMALL LETTER GAMMA
- u'\u03b4' # 0x009b -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0x009c -> GREEK SMALL LETTER EPSILON
- u'\u03b6' # 0x009d -> GREEK SMALL LETTER ZETA
- u'\u03b7' # 0x009e -> GREEK SMALL LETTER ETA
- u'\u03b8' # 0x009f -> GREEK SMALL LETTER THETA
- u'\u03b9' # 0x00a0 -> GREEK SMALL LETTER IOTA
- u'\u03ba' # 0x00a1 -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0x00a2 -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0x00a3 -> GREEK SMALL LETTER MU
- u'\u03bd' # 0x00a4 -> GREEK SMALL LETTER NU
- u'\u03be' # 0x00a5 -> GREEK SMALL LETTER XI
- u'\u03bf' # 0x00a6 -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0x00a7 -> GREEK SMALL LETTER PI
- u'\u03c1' # 0x00a8 -> GREEK SMALL LETTER RHO
- u'\u03c3' # 0x00a9 -> GREEK SMALL LETTER SIGMA
- u'\u03c2' # 0x00aa -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c4' # 0x00ab -> GREEK SMALL LETTER TAU
- u'\u03c5' # 0x00ac -> GREEK SMALL LETTER UPSILON
- u'\u03c6' # 0x00ad -> GREEK SMALL LETTER PHI
- u'\u03c7' # 0x00ae -> GREEK SMALL LETTER CHI
- u'\u03c8' # 0x00af -> GREEK SMALL LETTER PSI
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03c9' # 0x00e0 -> GREEK SMALL LETTER OMEGA
- u'\u03ac' # 0x00e1 -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\u03ad' # 0x00e2 -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0x00e3 -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03ca' # 0x00e4 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u03af' # 0x00e5 -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03cc' # 0x00e6 -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u03cd' # 0x00e7 -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u03cb' # 0x00e8 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u03ce' # 0x00e9 -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\u0386' # 0x00ea -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\u0388' # 0x00eb -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u0389' # 0x00ec -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\u038a' # 0x00ed -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\u038c' # 0x00ee -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\u038e' # 0x00ef -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u038f' # 0x00f0 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u03aa' # 0x00f4 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\u03ab' # 0x00f5 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\u0391' # 0x0080 -> GREEK CAPITAL LETTER ALPHA
+ '\u0392' # 0x0081 -> GREEK CAPITAL LETTER BETA
+ '\u0393' # 0x0082 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0x0083 -> GREEK CAPITAL LETTER DELTA
+ '\u0395' # 0x0084 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0x0085 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0x0086 -> GREEK CAPITAL LETTER ETA
+ '\u0398' # 0x0087 -> GREEK CAPITAL LETTER THETA
+ '\u0399' # 0x0088 -> GREEK CAPITAL LETTER IOTA
+ '\u039a' # 0x0089 -> GREEK CAPITAL LETTER KAPPA
+ '\u039b' # 0x008a -> GREEK CAPITAL LETTER LAMDA
+ '\u039c' # 0x008b -> GREEK CAPITAL LETTER MU
+ '\u039d' # 0x008c -> GREEK CAPITAL LETTER NU
+ '\u039e' # 0x008d -> GREEK CAPITAL LETTER XI
+ '\u039f' # 0x008e -> GREEK CAPITAL LETTER OMICRON
+ '\u03a0' # 0x008f -> GREEK CAPITAL LETTER PI
+ '\u03a1' # 0x0090 -> GREEK CAPITAL LETTER RHO
+ '\u03a3' # 0x0091 -> GREEK CAPITAL LETTER SIGMA
+ '\u03a4' # 0x0092 -> GREEK CAPITAL LETTER TAU
+ '\u03a5' # 0x0093 -> GREEK CAPITAL LETTER UPSILON
+ '\u03a6' # 0x0094 -> GREEK CAPITAL LETTER PHI
+ '\u03a7' # 0x0095 -> GREEK CAPITAL LETTER CHI
+ '\u03a8' # 0x0096 -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0x0097 -> GREEK CAPITAL LETTER OMEGA
+ '\u03b1' # 0x0098 -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0x0099 -> GREEK SMALL LETTER BETA
+ '\u03b3' # 0x009a -> GREEK SMALL LETTER GAMMA
+ '\u03b4' # 0x009b -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0x009c -> GREEK SMALL LETTER EPSILON
+ '\u03b6' # 0x009d -> GREEK SMALL LETTER ZETA
+ '\u03b7' # 0x009e -> GREEK SMALL LETTER ETA
+ '\u03b8' # 0x009f -> GREEK SMALL LETTER THETA
+ '\u03b9' # 0x00a0 -> GREEK SMALL LETTER IOTA
+ '\u03ba' # 0x00a1 -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0x00a2 -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0x00a3 -> GREEK SMALL LETTER MU
+ '\u03bd' # 0x00a4 -> GREEK SMALL LETTER NU
+ '\u03be' # 0x00a5 -> GREEK SMALL LETTER XI
+ '\u03bf' # 0x00a6 -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0x00a7 -> GREEK SMALL LETTER PI
+ '\u03c1' # 0x00a8 -> GREEK SMALL LETTER RHO
+ '\u03c3' # 0x00a9 -> GREEK SMALL LETTER SIGMA
+ '\u03c2' # 0x00aa -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c4' # 0x00ab -> GREEK SMALL LETTER TAU
+ '\u03c5' # 0x00ac -> GREEK SMALL LETTER UPSILON
+ '\u03c6' # 0x00ad -> GREEK SMALL LETTER PHI
+ '\u03c7' # 0x00ae -> GREEK SMALL LETTER CHI
+ '\u03c8' # 0x00af -> GREEK SMALL LETTER PSI
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03c9' # 0x00e0 -> GREEK SMALL LETTER OMEGA
+ '\u03ac' # 0x00e1 -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\u03ad' # 0x00e2 -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0x00e3 -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03ca' # 0x00e4 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u03af' # 0x00e5 -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03cc' # 0x00e6 -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u03cd' # 0x00e7 -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u03cb' # 0x00e8 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u03ce' # 0x00e9 -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\u0386' # 0x00ea -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\u0388' # 0x00eb -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u0389' # 0x00ec -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\u038a' # 0x00ed -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\u038c' # 0x00ee -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\u038e' # 0x00ef -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u038f' # 0x00f0 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u03aa' # 0x00f4 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\u03ab' # 0x00f5 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp775.py b/Lib/encodings/cp775.py
index 6a456a5825e..fe06e7bc3b3 100644
--- a/Lib/encodings/cp775.py
+++ b/Lib/encodings/cp775.py
@@ -177,262 +177,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\u0106' # 0x0080 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0101' # 0x0083 -> LATIN SMALL LETTER A WITH MACRON
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u0123' # 0x0085 -> LATIN SMALL LETTER G WITH CEDILLA
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\u0107' # 0x0087 -> LATIN SMALL LETTER C WITH ACUTE
- u'\u0142' # 0x0088 -> LATIN SMALL LETTER L WITH STROKE
- u'\u0113' # 0x0089 -> LATIN SMALL LETTER E WITH MACRON
- u'\u0156' # 0x008a -> LATIN CAPITAL LETTER R WITH CEDILLA
- u'\u0157' # 0x008b -> LATIN SMALL LETTER R WITH CEDILLA
- u'\u012b' # 0x008c -> LATIN SMALL LETTER I WITH MACRON
- u'\u0179' # 0x008d -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\u014d' # 0x0093 -> LATIN SMALL LETTER O WITH MACRON
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\u0122' # 0x0095 -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\xa2' # 0x0096 -> CENT SIGN
- u'\u015a' # 0x0097 -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u015b' # 0x0098 -> LATIN SMALL LETTER S WITH ACUTE
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd7' # 0x009e -> MULTIPLICATION SIGN
- u'\xa4' # 0x009f -> CURRENCY SIGN
- u'\u0100' # 0x00a0 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\u012a' # 0x00a1 -> LATIN CAPITAL LETTER I WITH MACRON
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\u017b' # 0x00a3 -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\u017c' # 0x00a4 -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u017a' # 0x00a5 -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u201d' # 0x00a6 -> RIGHT DOUBLE QUOTATION MARK
- u'\xa6' # 0x00a7 -> BROKEN BAR
- u'\xa9' # 0x00a8 -> COPYRIGHT SIGN
- u'\xae' # 0x00a9 -> REGISTERED SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\u0141' # 0x00ad -> LATIN CAPITAL LETTER L WITH STROKE
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u0104' # 0x00b5 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u010c' # 0x00b6 -> LATIN CAPITAL LETTER C WITH CARON
- u'\u0118' # 0x00b7 -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\u0116' # 0x00b8 -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u012e' # 0x00bd -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u0160' # 0x00be -> LATIN CAPITAL LETTER S WITH CARON
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u0172' # 0x00c6 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\u016a' # 0x00c7 -> LATIN CAPITAL LETTER U WITH MACRON
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u017d' # 0x00cf -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u0105' # 0x00d0 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u010d' # 0x00d1 -> LATIN SMALL LETTER C WITH CARON
- u'\u0119' # 0x00d2 -> LATIN SMALL LETTER E WITH OGONEK
- u'\u0117' # 0x00d3 -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\u012f' # 0x00d4 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u0161' # 0x00d5 -> LATIN SMALL LETTER S WITH CARON
- u'\u0173' # 0x00d6 -> LATIN SMALL LETTER U WITH OGONEK
- u'\u016b' # 0x00d7 -> LATIN SMALL LETTER U WITH MACRON
- u'\u017e' # 0x00d8 -> LATIN SMALL LETTER Z WITH CARON
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u'\u014c' # 0x00e2 -> LATIN CAPITAL LETTER O WITH MACRON
- u'\u0143' # 0x00e3 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
- u'\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u0144' # 0x00e7 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0136' # 0x00e8 -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\u0137' # 0x00e9 -> LATIN SMALL LETTER K WITH CEDILLA
- u'\u013b' # 0x00ea -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\u013c' # 0x00eb -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u0146' # 0x00ec -> LATIN SMALL LETTER N WITH CEDILLA
- u'\u0112' # 0x00ed -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u0145' # 0x00ee -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\u2019' # 0x00ef -> RIGHT SINGLE QUOTATION MARK
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u201c' # 0x00f2 -> LEFT DOUBLE QUOTATION MARK
- u'\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
- u'\xb6' # 0x00f4 -> PILCROW SIGN
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u201e' # 0x00f7 -> DOUBLE LOW-9 QUOTATION MARK
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\xb9' # 0x00fb -> SUPERSCRIPT ONE
- u'\xb3' # 0x00fc -> SUPERSCRIPT THREE
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\u0106' # 0x0080 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0101' # 0x0083 -> LATIN SMALL LETTER A WITH MACRON
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u0123' # 0x0085 -> LATIN SMALL LETTER G WITH CEDILLA
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\u0107' # 0x0087 -> LATIN SMALL LETTER C WITH ACUTE
+ '\u0142' # 0x0088 -> LATIN SMALL LETTER L WITH STROKE
+ '\u0113' # 0x0089 -> LATIN SMALL LETTER E WITH MACRON
+ '\u0156' # 0x008a -> LATIN CAPITAL LETTER R WITH CEDILLA
+ '\u0157' # 0x008b -> LATIN SMALL LETTER R WITH CEDILLA
+ '\u012b' # 0x008c -> LATIN SMALL LETTER I WITH MACRON
+ '\u0179' # 0x008d -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\u014d' # 0x0093 -> LATIN SMALL LETTER O WITH MACRON
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\u0122' # 0x0095 -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\xa2' # 0x0096 -> CENT SIGN
+ '\u015a' # 0x0097 -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u015b' # 0x0098 -> LATIN SMALL LETTER S WITH ACUTE
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd7' # 0x009e -> MULTIPLICATION SIGN
+ '\xa4' # 0x009f -> CURRENCY SIGN
+ '\u0100' # 0x00a0 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\u012a' # 0x00a1 -> LATIN CAPITAL LETTER I WITH MACRON
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\u017b' # 0x00a3 -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\u017c' # 0x00a4 -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u017a' # 0x00a5 -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u201d' # 0x00a6 -> RIGHT DOUBLE QUOTATION MARK
+ '\xa6' # 0x00a7 -> BROKEN BAR
+ '\xa9' # 0x00a8 -> COPYRIGHT SIGN
+ '\xae' # 0x00a9 -> REGISTERED SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\u0141' # 0x00ad -> LATIN CAPITAL LETTER L WITH STROKE
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u0104' # 0x00b5 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u010c' # 0x00b6 -> LATIN CAPITAL LETTER C WITH CARON
+ '\u0118' # 0x00b7 -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\u0116' # 0x00b8 -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u012e' # 0x00bd -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u0160' # 0x00be -> LATIN CAPITAL LETTER S WITH CARON
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u0172' # 0x00c6 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\u016a' # 0x00c7 -> LATIN CAPITAL LETTER U WITH MACRON
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u017d' # 0x00cf -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u0105' # 0x00d0 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u010d' # 0x00d1 -> LATIN SMALL LETTER C WITH CARON
+ '\u0119' # 0x00d2 -> LATIN SMALL LETTER E WITH OGONEK
+ '\u0117' # 0x00d3 -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\u012f' # 0x00d4 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u0161' # 0x00d5 -> LATIN SMALL LETTER S WITH CARON
+ '\u0173' # 0x00d6 -> LATIN SMALL LETTER U WITH OGONEK
+ '\u016b' # 0x00d7 -> LATIN SMALL LETTER U WITH MACRON
+ '\u017e' # 0x00d8 -> LATIN SMALL LETTER Z WITH CARON
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ '\u014c' # 0x00e2 -> LATIN CAPITAL LETTER O WITH MACRON
+ '\u0143' # 0x00e3 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
+ '\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u0144' # 0x00e7 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0136' # 0x00e8 -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\u0137' # 0x00e9 -> LATIN SMALL LETTER K WITH CEDILLA
+ '\u013b' # 0x00ea -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\u013c' # 0x00eb -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u0146' # 0x00ec -> LATIN SMALL LETTER N WITH CEDILLA
+ '\u0112' # 0x00ed -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u0145' # 0x00ee -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\u2019' # 0x00ef -> RIGHT SINGLE QUOTATION MARK
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u201c' # 0x00f2 -> LEFT DOUBLE QUOTATION MARK
+ '\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0x00f4 -> PILCROW SIGN
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u201e' # 0x00f7 -> DOUBLE LOW-9 QUOTATION MARK
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\xb9' # 0x00fb -> SUPERSCRIPT ONE
+ '\xb3' # 0x00fc -> SUPERSCRIPT THREE
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp850.py b/Lib/encodings/cp850.py
index 0c8478c8b20..f98aef99fb6 100644
--- a/Lib/encodings/cp850.py
+++ b/Lib/encodings/cp850.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd7' # 0x009e -> MULTIPLICATION SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\xae' # 0x00a9 -> REGISTERED SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xa9' # 0x00b8 -> COPYRIGHT SIGN
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\xa2' # 0x00bd -> CENT SIGN
- u'\xa5' # 0x00be -> YEN SIGN
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
- u'\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0x00cf -> CURRENCY SIGN
- u'\xf0' # 0x00d0 -> LATIN SMALL LETTER ETH
- u'\xd0' # 0x00d1 -> LATIN CAPITAL LETTER ETH
- u'\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\u0131' # 0x00d5 -> LATIN SMALL LETTER DOTLESS I
- u'\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\xa6' # 0x00dd -> BROKEN BAR
- u'\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
- u'\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\xfe' # 0x00e7 -> LATIN SMALL LETTER THORN
- u'\xde' # 0x00e8 -> LATIN CAPITAL LETTER THORN
- u'\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xaf' # 0x00ee -> MACRON
- u'\xb4' # 0x00ef -> ACUTE ACCENT
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2017' # 0x00f2 -> DOUBLE LOW LINE
- u'\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
- u'\xb6' # 0x00f4 -> PILCROW SIGN
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\xb8' # 0x00f7 -> CEDILLA
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\xa8' # 0x00f9 -> DIAERESIS
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\xb9' # 0x00fb -> SUPERSCRIPT ONE
- u'\xb3' # 0x00fc -> SUPERSCRIPT THREE
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd7' # 0x009e -> MULTIPLICATION SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\xae' # 0x00a9 -> REGISTERED SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xa9' # 0x00b8 -> COPYRIGHT SIGN
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\xa2' # 0x00bd -> CENT SIGN
+ '\xa5' # 0x00be -> YEN SIGN
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
+ '\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\xf0' # 0x00d0 -> LATIN SMALL LETTER ETH
+ '\xd0' # 0x00d1 -> LATIN CAPITAL LETTER ETH
+ '\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\u0131' # 0x00d5 -> LATIN SMALL LETTER DOTLESS I
+ '\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\xa6' # 0x00dd -> BROKEN BAR
+ '\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
+ '\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\xfe' # 0x00e7 -> LATIN SMALL LETTER THORN
+ '\xde' # 0x00e8 -> LATIN CAPITAL LETTER THORN
+ '\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xaf' # 0x00ee -> MACRON
+ '\xb4' # 0x00ef -> ACUTE ACCENT
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2017' # 0x00f2 -> DOUBLE LOW LINE
+ '\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0x00f4 -> PILCROW SIGN
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\xb8' # 0x00f7 -> CEDILLA
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\xb9' # 0x00fb -> SUPERSCRIPT ONE
+ '\xb3' # 0x00fc -> SUPERSCRIPT THREE
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp852.py b/Lib/encodings/cp852.py
index 069d5473b50..34d8a0ea5ac 100644
--- a/Lib/encodings/cp852.py
+++ b/Lib/encodings/cp852.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u016f' # 0x0085 -> LATIN SMALL LETTER U WITH RING ABOVE
- u'\u0107' # 0x0086 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\u0142' # 0x0088 -> LATIN SMALL LETTER L WITH STROKE
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u0150' # 0x008a -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
- u'\u0151' # 0x008b -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u0179' # 0x008d -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u0106' # 0x008f -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0139' # 0x0091 -> LATIN CAPITAL LETTER L WITH ACUTE
- u'\u013a' # 0x0092 -> LATIN SMALL LETTER L WITH ACUTE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\u013d' # 0x0095 -> LATIN CAPITAL LETTER L WITH CARON
- u'\u013e' # 0x0096 -> LATIN SMALL LETTER L WITH CARON
- u'\u015a' # 0x0097 -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u015b' # 0x0098 -> LATIN SMALL LETTER S WITH ACUTE
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0164' # 0x009b -> LATIN CAPITAL LETTER T WITH CARON
- u'\u0165' # 0x009c -> LATIN SMALL LETTER T WITH CARON
- u'\u0141' # 0x009d -> LATIN CAPITAL LETTER L WITH STROKE
- u'\xd7' # 0x009e -> MULTIPLICATION SIGN
- u'\u010d' # 0x009f -> LATIN SMALL LETTER C WITH CARON
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\u0104' # 0x00a4 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u0105' # 0x00a5 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u017d' # 0x00a6 -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u017e' # 0x00a7 -> LATIN SMALL LETTER Z WITH CARON
- u'\u0118' # 0x00a8 -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\u0119' # 0x00a9 -> LATIN SMALL LETTER E WITH OGONEK
- u'\xac' # 0x00aa -> NOT SIGN
- u'\u017a' # 0x00ab -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u010c' # 0x00ac -> LATIN CAPITAL LETTER C WITH CARON
- u'\u015f' # 0x00ad -> LATIN SMALL LETTER S WITH CEDILLA
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u011a' # 0x00b7 -> LATIN CAPITAL LETTER E WITH CARON
- u'\u015e' # 0x00b8 -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u017b' # 0x00bd -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\u017c' # 0x00be -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u0102' # 0x00c6 -> LATIN CAPITAL LETTER A WITH BREVE
- u'\u0103' # 0x00c7 -> LATIN SMALL LETTER A WITH BREVE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0x00cf -> CURRENCY SIGN
- u'\u0111' # 0x00d0 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0110' # 0x00d1 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u010e' # 0x00d2 -> LATIN CAPITAL LETTER D WITH CARON
- u'\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u010f' # 0x00d4 -> LATIN SMALL LETTER D WITH CARON
- u'\u0147' # 0x00d5 -> LATIN CAPITAL LETTER N WITH CARON
- u'\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\u011b' # 0x00d8 -> LATIN SMALL LETTER E WITH CARON
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u0162' # 0x00dd -> LATIN CAPITAL LETTER T WITH CEDILLA
- u'\u016e' # 0x00de -> LATIN CAPITAL LETTER U WITH RING ABOVE
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0143' # 0x00e3 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\u0144' # 0x00e4 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0148' # 0x00e5 -> LATIN SMALL LETTER N WITH CARON
- u'\u0160' # 0x00e6 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u0161' # 0x00e7 -> LATIN SMALL LETTER S WITH CARON
- u'\u0154' # 0x00e8 -> LATIN CAPITAL LETTER R WITH ACUTE
- u'\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\u0155' # 0x00ea -> LATIN SMALL LETTER R WITH ACUTE
- u'\u0170' # 0x00eb -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
- u'\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\u0163' # 0x00ee -> LATIN SMALL LETTER T WITH CEDILLA
- u'\xb4' # 0x00ef -> ACUTE ACCENT
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\u02dd' # 0x00f1 -> DOUBLE ACUTE ACCENT
- u'\u02db' # 0x00f2 -> OGONEK
- u'\u02c7' # 0x00f3 -> CARON
- u'\u02d8' # 0x00f4 -> BREVE
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\xb8' # 0x00f7 -> CEDILLA
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\xa8' # 0x00f9 -> DIAERESIS
- u'\u02d9' # 0x00fa -> DOT ABOVE
- u'\u0171' # 0x00fb -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
- u'\u0158' # 0x00fc -> LATIN CAPITAL LETTER R WITH CARON
- u'\u0159' # 0x00fd -> LATIN SMALL LETTER R WITH CARON
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u016f' # 0x0085 -> LATIN SMALL LETTER U WITH RING ABOVE
+ '\u0107' # 0x0086 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\u0142' # 0x0088 -> LATIN SMALL LETTER L WITH STROKE
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u0150' # 0x008a -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+ '\u0151' # 0x008b -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u0179' # 0x008d -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u0106' # 0x008f -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0139' # 0x0091 -> LATIN CAPITAL LETTER L WITH ACUTE
+ '\u013a' # 0x0092 -> LATIN SMALL LETTER L WITH ACUTE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\u013d' # 0x0095 -> LATIN CAPITAL LETTER L WITH CARON
+ '\u013e' # 0x0096 -> LATIN SMALL LETTER L WITH CARON
+ '\u015a' # 0x0097 -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u015b' # 0x0098 -> LATIN SMALL LETTER S WITH ACUTE
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0164' # 0x009b -> LATIN CAPITAL LETTER T WITH CARON
+ '\u0165' # 0x009c -> LATIN SMALL LETTER T WITH CARON
+ '\u0141' # 0x009d -> LATIN CAPITAL LETTER L WITH STROKE
+ '\xd7' # 0x009e -> MULTIPLICATION SIGN
+ '\u010d' # 0x009f -> LATIN SMALL LETTER C WITH CARON
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\u0104' # 0x00a4 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u0105' # 0x00a5 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u017d' # 0x00a6 -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u017e' # 0x00a7 -> LATIN SMALL LETTER Z WITH CARON
+ '\u0118' # 0x00a8 -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\u0119' # 0x00a9 -> LATIN SMALL LETTER E WITH OGONEK
+ '\xac' # 0x00aa -> NOT SIGN
+ '\u017a' # 0x00ab -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u010c' # 0x00ac -> LATIN CAPITAL LETTER C WITH CARON
+ '\u015f' # 0x00ad -> LATIN SMALL LETTER S WITH CEDILLA
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u011a' # 0x00b7 -> LATIN CAPITAL LETTER E WITH CARON
+ '\u015e' # 0x00b8 -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u017b' # 0x00bd -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\u017c' # 0x00be -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u0102' # 0x00c6 -> LATIN CAPITAL LETTER A WITH BREVE
+ '\u0103' # 0x00c7 -> LATIN SMALL LETTER A WITH BREVE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\u0111' # 0x00d0 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0110' # 0x00d1 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u010e' # 0x00d2 -> LATIN CAPITAL LETTER D WITH CARON
+ '\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u010f' # 0x00d4 -> LATIN SMALL LETTER D WITH CARON
+ '\u0147' # 0x00d5 -> LATIN CAPITAL LETTER N WITH CARON
+ '\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\u011b' # 0x00d8 -> LATIN SMALL LETTER E WITH CARON
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u0162' # 0x00dd -> LATIN CAPITAL LETTER T WITH CEDILLA
+ '\u016e' # 0x00de -> LATIN CAPITAL LETTER U WITH RING ABOVE
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0143' # 0x00e3 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\u0144' # 0x00e4 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0148' # 0x00e5 -> LATIN SMALL LETTER N WITH CARON
+ '\u0160' # 0x00e6 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u0161' # 0x00e7 -> LATIN SMALL LETTER S WITH CARON
+ '\u0154' # 0x00e8 -> LATIN CAPITAL LETTER R WITH ACUTE
+ '\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\u0155' # 0x00ea -> LATIN SMALL LETTER R WITH ACUTE
+ '\u0170' # 0x00eb -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+ '\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\u0163' # 0x00ee -> LATIN SMALL LETTER T WITH CEDILLA
+ '\xb4' # 0x00ef -> ACUTE ACCENT
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\u02dd' # 0x00f1 -> DOUBLE ACUTE ACCENT
+ '\u02db' # 0x00f2 -> OGONEK
+ '\u02c7' # 0x00f3 -> CARON
+ '\u02d8' # 0x00f4 -> BREVE
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\xb8' # 0x00f7 -> CEDILLA
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\u02d9' # 0x00fa -> DOT ABOVE
+ '\u0171' # 0x00fb -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
+ '\u0158' # 0x00fc -> LATIN CAPITAL LETTER R WITH CARON
+ '\u0159' # 0x00fd -> LATIN SMALL LETTER R WITH CARON
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp855.py b/Lib/encodings/cp855.py
index 241ef9d1e86..4fe9210697c 100644
--- a/Lib/encodings/cp855.py
+++ b/Lib/encodings/cp855.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\u0452' # 0x0080 -> CYRILLIC SMALL LETTER DJE
- u'\u0402' # 0x0081 -> CYRILLIC CAPITAL LETTER DJE
- u'\u0453' # 0x0082 -> CYRILLIC SMALL LETTER GJE
- u'\u0403' # 0x0083 -> CYRILLIC CAPITAL LETTER GJE
- u'\u0451' # 0x0084 -> CYRILLIC SMALL LETTER IO
- u'\u0401' # 0x0085 -> CYRILLIC CAPITAL LETTER IO
- u'\u0454' # 0x0086 -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\u0404' # 0x0087 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\u0455' # 0x0088 -> CYRILLIC SMALL LETTER DZE
- u'\u0405' # 0x0089 -> CYRILLIC CAPITAL LETTER DZE
- u'\u0456' # 0x008a -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0406' # 0x008b -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0457' # 0x008c -> CYRILLIC SMALL LETTER YI
- u'\u0407' # 0x008d -> CYRILLIC CAPITAL LETTER YI
- u'\u0458' # 0x008e -> CYRILLIC SMALL LETTER JE
- u'\u0408' # 0x008f -> CYRILLIC CAPITAL LETTER JE
- u'\u0459' # 0x0090 -> CYRILLIC SMALL LETTER LJE
- u'\u0409' # 0x0091 -> CYRILLIC CAPITAL LETTER LJE
- u'\u045a' # 0x0092 -> CYRILLIC SMALL LETTER NJE
- u'\u040a' # 0x0093 -> CYRILLIC CAPITAL LETTER NJE
- u'\u045b' # 0x0094 -> CYRILLIC SMALL LETTER TSHE
- u'\u040b' # 0x0095 -> CYRILLIC CAPITAL LETTER TSHE
- u'\u045c' # 0x0096 -> CYRILLIC SMALL LETTER KJE
- u'\u040c' # 0x0097 -> CYRILLIC CAPITAL LETTER KJE
- u'\u045e' # 0x0098 -> CYRILLIC SMALL LETTER SHORT U
- u'\u040e' # 0x0099 -> CYRILLIC CAPITAL LETTER SHORT U
- u'\u045f' # 0x009a -> CYRILLIC SMALL LETTER DZHE
- u'\u040f' # 0x009b -> CYRILLIC CAPITAL LETTER DZHE
- u'\u044e' # 0x009c -> CYRILLIC SMALL LETTER YU
- u'\u042e' # 0x009d -> CYRILLIC CAPITAL LETTER YU
- u'\u044a' # 0x009e -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u042a' # 0x009f -> CYRILLIC CAPITAL LETTER HARD SIGN
- u'\u0430' # 0x00a0 -> CYRILLIC SMALL LETTER A
- u'\u0410' # 0x00a1 -> CYRILLIC CAPITAL LETTER A
- u'\u0431' # 0x00a2 -> CYRILLIC SMALL LETTER BE
- u'\u0411' # 0x00a3 -> CYRILLIC CAPITAL LETTER BE
- u'\u0446' # 0x00a4 -> CYRILLIC SMALL LETTER TSE
- u'\u0426' # 0x00a5 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0434' # 0x00a6 -> CYRILLIC SMALL LETTER DE
- u'\u0414' # 0x00a7 -> CYRILLIC CAPITAL LETTER DE
- u'\u0435' # 0x00a8 -> CYRILLIC SMALL LETTER IE
- u'\u0415' # 0x00a9 -> CYRILLIC CAPITAL LETTER IE
- u'\u0444' # 0x00aa -> CYRILLIC SMALL LETTER EF
- u'\u0424' # 0x00ab -> CYRILLIC CAPITAL LETTER EF
- u'\u0433' # 0x00ac -> CYRILLIC SMALL LETTER GHE
- u'\u0413' # 0x00ad -> CYRILLIC CAPITAL LETTER GHE
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u0445' # 0x00b5 -> CYRILLIC SMALL LETTER HA
- u'\u0425' # 0x00b6 -> CYRILLIC CAPITAL LETTER HA
- u'\u0438' # 0x00b7 -> CYRILLIC SMALL LETTER I
- u'\u0418' # 0x00b8 -> CYRILLIC CAPITAL LETTER I
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u0439' # 0x00bd -> CYRILLIC SMALL LETTER SHORT I
- u'\u0419' # 0x00be -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u043a' # 0x00c6 -> CYRILLIC SMALL LETTER KA
- u'\u041a' # 0x00c7 -> CYRILLIC CAPITAL LETTER KA
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0x00cf -> CURRENCY SIGN
- u'\u043b' # 0x00d0 -> CYRILLIC SMALL LETTER EL
- u'\u041b' # 0x00d1 -> CYRILLIC CAPITAL LETTER EL
- u'\u043c' # 0x00d2 -> CYRILLIC SMALL LETTER EM
- u'\u041c' # 0x00d3 -> CYRILLIC CAPITAL LETTER EM
- u'\u043d' # 0x00d4 -> CYRILLIC SMALL LETTER EN
- u'\u041d' # 0x00d5 -> CYRILLIC CAPITAL LETTER EN
- u'\u043e' # 0x00d6 -> CYRILLIC SMALL LETTER O
- u'\u041e' # 0x00d7 -> CYRILLIC CAPITAL LETTER O
- u'\u043f' # 0x00d8 -> CYRILLIC SMALL LETTER PE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u041f' # 0x00dd -> CYRILLIC CAPITAL LETTER PE
- u'\u044f' # 0x00de -> CYRILLIC SMALL LETTER YA
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u042f' # 0x00e0 -> CYRILLIC CAPITAL LETTER YA
- u'\u0440' # 0x00e1 -> CYRILLIC SMALL LETTER ER
- u'\u0420' # 0x00e2 -> CYRILLIC CAPITAL LETTER ER
- u'\u0441' # 0x00e3 -> CYRILLIC SMALL LETTER ES
- u'\u0421' # 0x00e4 -> CYRILLIC CAPITAL LETTER ES
- u'\u0442' # 0x00e5 -> CYRILLIC SMALL LETTER TE
- u'\u0422' # 0x00e6 -> CYRILLIC CAPITAL LETTER TE
- u'\u0443' # 0x00e7 -> CYRILLIC SMALL LETTER U
- u'\u0423' # 0x00e8 -> CYRILLIC CAPITAL LETTER U
- u'\u0436' # 0x00e9 -> CYRILLIC SMALL LETTER ZHE
- u'\u0416' # 0x00ea -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0432' # 0x00eb -> CYRILLIC SMALL LETTER VE
- u'\u0412' # 0x00ec -> CYRILLIC CAPITAL LETTER VE
- u'\u044c' # 0x00ed -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u042c' # 0x00ee -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u2116' # 0x00ef -> NUMERO SIGN
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\u044b' # 0x00f1 -> CYRILLIC SMALL LETTER YERU
- u'\u042b' # 0x00f2 -> CYRILLIC CAPITAL LETTER YERU
- u'\u0437' # 0x00f3 -> CYRILLIC SMALL LETTER ZE
- u'\u0417' # 0x00f4 -> CYRILLIC CAPITAL LETTER ZE
- u'\u0448' # 0x00f5 -> CYRILLIC SMALL LETTER SHA
- u'\u0428' # 0x00f6 -> CYRILLIC CAPITAL LETTER SHA
- u'\u044d' # 0x00f7 -> CYRILLIC SMALL LETTER E
- u'\u042d' # 0x00f8 -> CYRILLIC CAPITAL LETTER E
- u'\u0449' # 0x00f9 -> CYRILLIC SMALL LETTER SHCHA
- u'\u0429' # 0x00fa -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u0447' # 0x00fb -> CYRILLIC SMALL LETTER CHE
- u'\u0427' # 0x00fc -> CYRILLIC CAPITAL LETTER CHE
- u'\xa7' # 0x00fd -> SECTION SIGN
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\u0452' # 0x0080 -> CYRILLIC SMALL LETTER DJE
+ '\u0402' # 0x0081 -> CYRILLIC CAPITAL LETTER DJE
+ '\u0453' # 0x0082 -> CYRILLIC SMALL LETTER GJE
+ '\u0403' # 0x0083 -> CYRILLIC CAPITAL LETTER GJE
+ '\u0451' # 0x0084 -> CYRILLIC SMALL LETTER IO
+ '\u0401' # 0x0085 -> CYRILLIC CAPITAL LETTER IO
+ '\u0454' # 0x0086 -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\u0404' # 0x0087 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\u0455' # 0x0088 -> CYRILLIC SMALL LETTER DZE
+ '\u0405' # 0x0089 -> CYRILLIC CAPITAL LETTER DZE
+ '\u0456' # 0x008a -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0406' # 0x008b -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0457' # 0x008c -> CYRILLIC SMALL LETTER YI
+ '\u0407' # 0x008d -> CYRILLIC CAPITAL LETTER YI
+ '\u0458' # 0x008e -> CYRILLIC SMALL LETTER JE
+ '\u0408' # 0x008f -> CYRILLIC CAPITAL LETTER JE
+ '\u0459' # 0x0090 -> CYRILLIC SMALL LETTER LJE
+ '\u0409' # 0x0091 -> CYRILLIC CAPITAL LETTER LJE
+ '\u045a' # 0x0092 -> CYRILLIC SMALL LETTER NJE
+ '\u040a' # 0x0093 -> CYRILLIC CAPITAL LETTER NJE
+ '\u045b' # 0x0094 -> CYRILLIC SMALL LETTER TSHE
+ '\u040b' # 0x0095 -> CYRILLIC CAPITAL LETTER TSHE
+ '\u045c' # 0x0096 -> CYRILLIC SMALL LETTER KJE
+ '\u040c' # 0x0097 -> CYRILLIC CAPITAL LETTER KJE
+ '\u045e' # 0x0098 -> CYRILLIC SMALL LETTER SHORT U
+ '\u040e' # 0x0099 -> CYRILLIC CAPITAL LETTER SHORT U
+ '\u045f' # 0x009a -> CYRILLIC SMALL LETTER DZHE
+ '\u040f' # 0x009b -> CYRILLIC CAPITAL LETTER DZHE
+ '\u044e' # 0x009c -> CYRILLIC SMALL LETTER YU
+ '\u042e' # 0x009d -> CYRILLIC CAPITAL LETTER YU
+ '\u044a' # 0x009e -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u042a' # 0x009f -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\u0430' # 0x00a0 -> CYRILLIC SMALL LETTER A
+ '\u0410' # 0x00a1 -> CYRILLIC CAPITAL LETTER A
+ '\u0431' # 0x00a2 -> CYRILLIC SMALL LETTER BE
+ '\u0411' # 0x00a3 -> CYRILLIC CAPITAL LETTER BE
+ '\u0446' # 0x00a4 -> CYRILLIC SMALL LETTER TSE
+ '\u0426' # 0x00a5 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0434' # 0x00a6 -> CYRILLIC SMALL LETTER DE
+ '\u0414' # 0x00a7 -> CYRILLIC CAPITAL LETTER DE
+ '\u0435' # 0x00a8 -> CYRILLIC SMALL LETTER IE
+ '\u0415' # 0x00a9 -> CYRILLIC CAPITAL LETTER IE
+ '\u0444' # 0x00aa -> CYRILLIC SMALL LETTER EF
+ '\u0424' # 0x00ab -> CYRILLIC CAPITAL LETTER EF
+ '\u0433' # 0x00ac -> CYRILLIC SMALL LETTER GHE
+ '\u0413' # 0x00ad -> CYRILLIC CAPITAL LETTER GHE
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u0445' # 0x00b5 -> CYRILLIC SMALL LETTER HA
+ '\u0425' # 0x00b6 -> CYRILLIC CAPITAL LETTER HA
+ '\u0438' # 0x00b7 -> CYRILLIC SMALL LETTER I
+ '\u0418' # 0x00b8 -> CYRILLIC CAPITAL LETTER I
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u0439' # 0x00bd -> CYRILLIC SMALL LETTER SHORT I
+ '\u0419' # 0x00be -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u043a' # 0x00c6 -> CYRILLIC SMALL LETTER KA
+ '\u041a' # 0x00c7 -> CYRILLIC CAPITAL LETTER KA
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\u043b' # 0x00d0 -> CYRILLIC SMALL LETTER EL
+ '\u041b' # 0x00d1 -> CYRILLIC CAPITAL LETTER EL
+ '\u043c' # 0x00d2 -> CYRILLIC SMALL LETTER EM
+ '\u041c' # 0x00d3 -> CYRILLIC CAPITAL LETTER EM
+ '\u043d' # 0x00d4 -> CYRILLIC SMALL LETTER EN
+ '\u041d' # 0x00d5 -> CYRILLIC CAPITAL LETTER EN
+ '\u043e' # 0x00d6 -> CYRILLIC SMALL LETTER O
+ '\u041e' # 0x00d7 -> CYRILLIC CAPITAL LETTER O
+ '\u043f' # 0x00d8 -> CYRILLIC SMALL LETTER PE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u041f' # 0x00dd -> CYRILLIC CAPITAL LETTER PE
+ '\u044f' # 0x00de -> CYRILLIC SMALL LETTER YA
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u042f' # 0x00e0 -> CYRILLIC CAPITAL LETTER YA
+ '\u0440' # 0x00e1 -> CYRILLIC SMALL LETTER ER
+ '\u0420' # 0x00e2 -> CYRILLIC CAPITAL LETTER ER
+ '\u0441' # 0x00e3 -> CYRILLIC SMALL LETTER ES
+ '\u0421' # 0x00e4 -> CYRILLIC CAPITAL LETTER ES
+ '\u0442' # 0x00e5 -> CYRILLIC SMALL LETTER TE
+ '\u0422' # 0x00e6 -> CYRILLIC CAPITAL LETTER TE
+ '\u0443' # 0x00e7 -> CYRILLIC SMALL LETTER U
+ '\u0423' # 0x00e8 -> CYRILLIC CAPITAL LETTER U
+ '\u0436' # 0x00e9 -> CYRILLIC SMALL LETTER ZHE
+ '\u0416' # 0x00ea -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0432' # 0x00eb -> CYRILLIC SMALL LETTER VE
+ '\u0412' # 0x00ec -> CYRILLIC CAPITAL LETTER VE
+ '\u044c' # 0x00ed -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u042c' # 0x00ee -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u2116' # 0x00ef -> NUMERO SIGN
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\u044b' # 0x00f1 -> CYRILLIC SMALL LETTER YERU
+ '\u042b' # 0x00f2 -> CYRILLIC CAPITAL LETTER YERU
+ '\u0437' # 0x00f3 -> CYRILLIC SMALL LETTER ZE
+ '\u0417' # 0x00f4 -> CYRILLIC CAPITAL LETTER ZE
+ '\u0448' # 0x00f5 -> CYRILLIC SMALL LETTER SHA
+ '\u0428' # 0x00f6 -> CYRILLIC CAPITAL LETTER SHA
+ '\u044d' # 0x00f7 -> CYRILLIC SMALL LETTER E
+ '\u042d' # 0x00f8 -> CYRILLIC CAPITAL LETTER E
+ '\u0449' # 0x00f9 -> CYRILLIC SMALL LETTER SHCHA
+ '\u0429' # 0x00fa -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u0447' # 0x00fb -> CYRILLIC SMALL LETTER CHE
+ '\u0427' # 0x00fc -> CYRILLIC CAPITAL LETTER CHE
+ '\xa7' # 0x00fd -> SECTION SIGN
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp856.py b/Lib/encodings/cp856.py
index 203c2c4ca0f..cacbfb2f804 100644
--- a/Lib/encodings/cp856.py
+++ b/Lib/encodings/cp856.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u05d0' # 0x80 -> HEBREW LETTER ALEF
- u'\u05d1' # 0x81 -> HEBREW LETTER BET
- u'\u05d2' # 0x82 -> HEBREW LETTER GIMEL
- u'\u05d3' # 0x83 -> HEBREW LETTER DALET
- u'\u05d4' # 0x84 -> HEBREW LETTER HE
- u'\u05d5' # 0x85 -> HEBREW LETTER VAV
- u'\u05d6' # 0x86 -> HEBREW LETTER ZAYIN
- u'\u05d7' # 0x87 -> HEBREW LETTER HET
- u'\u05d8' # 0x88 -> HEBREW LETTER TET
- u'\u05d9' # 0x89 -> HEBREW LETTER YOD
- u'\u05da' # 0x8A -> HEBREW LETTER FINAL KAF
- u'\u05db' # 0x8B -> HEBREW LETTER KAF
- u'\u05dc' # 0x8C -> HEBREW LETTER LAMED
- u'\u05dd' # 0x8D -> HEBREW LETTER FINAL MEM
- u'\u05de' # 0x8E -> HEBREW LETTER MEM
- u'\u05df' # 0x8F -> HEBREW LETTER FINAL NUN
- u'\u05e0' # 0x90 -> HEBREW LETTER NUN
- u'\u05e1' # 0x91 -> HEBREW LETTER SAMEKH
- u'\u05e2' # 0x92 -> HEBREW LETTER AYIN
- u'\u05e3' # 0x93 -> HEBREW LETTER FINAL PE
- u'\u05e4' # 0x94 -> HEBREW LETTER PE
- u'\u05e5' # 0x95 -> HEBREW LETTER FINAL TSADI
- u'\u05e6' # 0x96 -> HEBREW LETTER TSADI
- u'\u05e7' # 0x97 -> HEBREW LETTER QOF
- u'\u05e8' # 0x98 -> HEBREW LETTER RESH
- u'\u05e9' # 0x99 -> HEBREW LETTER SHIN
- u'\u05ea' # 0x9A -> HEBREW LETTER TAV
- u'\ufffe' # 0x9B -> UNDEFINED
- u'\xa3' # 0x9C -> POUND SIGN
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\xd7' # 0x9E -> MULTIPLICATION SIGN
- u'\ufffe' # 0x9F -> UNDEFINED
- u'\ufffe' # 0xA0 -> UNDEFINED
- u'\ufffe' # 0xA1 -> UNDEFINED
- u'\ufffe' # 0xA2 -> UNDEFINED
- u'\ufffe' # 0xA3 -> UNDEFINED
- u'\ufffe' # 0xA4 -> UNDEFINED
- u'\ufffe' # 0xA5 -> UNDEFINED
- u'\ufffe' # 0xA6 -> UNDEFINED
- u'\ufffe' # 0xA7 -> UNDEFINED
- u'\ufffe' # 0xA8 -> UNDEFINED
- u'\xae' # 0xA9 -> REGISTERED SIGN
- u'\xac' # 0xAA -> NOT SIGN
- u'\xbd' # 0xAB -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0xAC -> VULGAR FRACTION ONE QUARTER
- u'\ufffe' # 0xAD -> UNDEFINED
- u'\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0xB0 -> LIGHT SHADE
- u'\u2592' # 0xB1 -> MEDIUM SHADE
- u'\u2593' # 0xB2 -> DARK SHADE
- u'\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\ufffe' # 0xB5 -> UNDEFINED
- u'\ufffe' # 0xB6 -> UNDEFINED
- u'\ufffe' # 0xB7 -> UNDEFINED
- u'\xa9' # 0xB8 -> COPYRIGHT SIGN
- u'\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\xa2' # 0xBD -> CENT SIGN
- u'\xa5' # 0xBE -> YEN SIGN
- u'\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\ufffe' # 0xC6 -> UNDEFINED
- u'\ufffe' # 0xC7 -> UNDEFINED
- u'\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0xCF -> CURRENCY SIGN
- u'\ufffe' # 0xD0 -> UNDEFINED
- u'\ufffe' # 0xD1 -> UNDEFINED
- u'\ufffe' # 0xD2 -> UNDEFINED
- u'\ufffe' # 0xD3 -> UNDEFINEDS
- u'\ufffe' # 0xD4 -> UNDEFINED
- u'\ufffe' # 0xD5 -> UNDEFINED
- u'\ufffe' # 0xD6 -> UNDEFINEDE
- u'\ufffe' # 0xD7 -> UNDEFINED
- u'\ufffe' # 0xD8 -> UNDEFINED
- u'\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0xDB -> FULL BLOCK
- u'\u2584' # 0xDC -> LOWER HALF BLOCK
- u'\xa6' # 0xDD -> BROKEN BAR
- u'\ufffe' # 0xDE -> UNDEFINED
- u'\u2580' # 0xDF -> UPPER HALF BLOCK
- u'\ufffe' # 0xE0 -> UNDEFINED
- u'\ufffe' # 0xE1 -> UNDEFINED
- u'\ufffe' # 0xE2 -> UNDEFINED
- u'\ufffe' # 0xE3 -> UNDEFINED
- u'\ufffe' # 0xE4 -> UNDEFINED
- u'\ufffe' # 0xE5 -> UNDEFINED
- u'\xb5' # 0xE6 -> MICRO SIGN
- u'\ufffe' # 0xE7 -> UNDEFINED
- u'\ufffe' # 0xE8 -> UNDEFINED
- u'\ufffe' # 0xE9 -> UNDEFINED
- u'\ufffe' # 0xEA -> UNDEFINED
- u'\ufffe' # 0xEB -> UNDEFINED
- u'\ufffe' # 0xEC -> UNDEFINED
- u'\ufffe' # 0xED -> UNDEFINED
- u'\xaf' # 0xEE -> MACRON
- u'\xb4' # 0xEF -> ACUTE ACCENT
- u'\xad' # 0xF0 -> SOFT HYPHEN
- u'\xb1' # 0xF1 -> PLUS-MINUS SIGN
- u'\u2017' # 0xF2 -> DOUBLE LOW LINE
- u'\xbe' # 0xF3 -> VULGAR FRACTION THREE QUARTERS
- u'\xb6' # 0xF4 -> PILCROW SIGN
- u'\xa7' # 0xF5 -> SECTION SIGN
- u'\xf7' # 0xF6 -> DIVISION SIGN
- u'\xb8' # 0xF7 -> CEDILLA
- u'\xb0' # 0xF8 -> DEGREE SIGN
- u'\xa8' # 0xF9 -> DIAERESIS
- u'\xb7' # 0xFA -> MIDDLE DOT
- u'\xb9' # 0xFB -> SUPERSCRIPT ONE
- u'\xb3' # 0xFC -> SUPERSCRIPT THREE
- u'\xb2' # 0xFD -> SUPERSCRIPT TWO
- u'\u25a0' # 0xFE -> BLACK SQUARE
- u'\xa0' # 0xFF -> NO-BREAK SPACE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u05d0' # 0x80 -> HEBREW LETTER ALEF
+ '\u05d1' # 0x81 -> HEBREW LETTER BET
+ '\u05d2' # 0x82 -> HEBREW LETTER GIMEL
+ '\u05d3' # 0x83 -> HEBREW LETTER DALET
+ '\u05d4' # 0x84 -> HEBREW LETTER HE
+ '\u05d5' # 0x85 -> HEBREW LETTER VAV
+ '\u05d6' # 0x86 -> HEBREW LETTER ZAYIN
+ '\u05d7' # 0x87 -> HEBREW LETTER HET
+ '\u05d8' # 0x88 -> HEBREW LETTER TET
+ '\u05d9' # 0x89 -> HEBREW LETTER YOD
+ '\u05da' # 0x8A -> HEBREW LETTER FINAL KAF
+ '\u05db' # 0x8B -> HEBREW LETTER KAF
+ '\u05dc' # 0x8C -> HEBREW LETTER LAMED
+ '\u05dd' # 0x8D -> HEBREW LETTER FINAL MEM
+ '\u05de' # 0x8E -> HEBREW LETTER MEM
+ '\u05df' # 0x8F -> HEBREW LETTER FINAL NUN
+ '\u05e0' # 0x90 -> HEBREW LETTER NUN
+ '\u05e1' # 0x91 -> HEBREW LETTER SAMEKH
+ '\u05e2' # 0x92 -> HEBREW LETTER AYIN
+ '\u05e3' # 0x93 -> HEBREW LETTER FINAL PE
+ '\u05e4' # 0x94 -> HEBREW LETTER PE
+ '\u05e5' # 0x95 -> HEBREW LETTER FINAL TSADI
+ '\u05e6' # 0x96 -> HEBREW LETTER TSADI
+ '\u05e7' # 0x97 -> HEBREW LETTER QOF
+ '\u05e8' # 0x98 -> HEBREW LETTER RESH
+ '\u05e9' # 0x99 -> HEBREW LETTER SHIN
+ '\u05ea' # 0x9A -> HEBREW LETTER TAV
+ '\ufffe' # 0x9B -> UNDEFINED
+ '\xa3' # 0x9C -> POUND SIGN
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\xd7' # 0x9E -> MULTIPLICATION SIGN
+ '\ufffe' # 0x9F -> UNDEFINED
+ '\ufffe' # 0xA0 -> UNDEFINED
+ '\ufffe' # 0xA1 -> UNDEFINED
+ '\ufffe' # 0xA2 -> UNDEFINED
+ '\ufffe' # 0xA3 -> UNDEFINED
+ '\ufffe' # 0xA4 -> UNDEFINED
+ '\ufffe' # 0xA5 -> UNDEFINED
+ '\ufffe' # 0xA6 -> UNDEFINED
+ '\ufffe' # 0xA7 -> UNDEFINED
+ '\ufffe' # 0xA8 -> UNDEFINED
+ '\xae' # 0xA9 -> REGISTERED SIGN
+ '\xac' # 0xAA -> NOT SIGN
+ '\xbd' # 0xAB -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0xAC -> VULGAR FRACTION ONE QUARTER
+ '\ufffe' # 0xAD -> UNDEFINED
+ '\xab' # 0xAE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xAF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0xB0 -> LIGHT SHADE
+ '\u2592' # 0xB1 -> MEDIUM SHADE
+ '\u2593' # 0xB2 -> DARK SHADE
+ '\u2502' # 0xB3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0xB4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\ufffe' # 0xB5 -> UNDEFINED
+ '\ufffe' # 0xB6 -> UNDEFINED
+ '\ufffe' # 0xB7 -> UNDEFINED
+ '\xa9' # 0xB8 -> COPYRIGHT SIGN
+ '\u2563' # 0xB9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0xBA -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0xBB -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0xBC -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\xa2' # 0xBD -> CENT SIGN
+ '\xa5' # 0xBE -> YEN SIGN
+ '\u2510' # 0xBF -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0xC0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0xC1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0xC2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0xC3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0xC4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0xC5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\ufffe' # 0xC6 -> UNDEFINED
+ '\ufffe' # 0xC7 -> UNDEFINED
+ '\u255a' # 0xC8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0xC9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0xCA -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0xCB -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0xCC -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0xCD -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0xCE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0xCF -> CURRENCY SIGN
+ '\ufffe' # 0xD0 -> UNDEFINED
+ '\ufffe' # 0xD1 -> UNDEFINED
+ '\ufffe' # 0xD2 -> UNDEFINED
+ '\ufffe' # 0xD3 -> UNDEFINEDS
+ '\ufffe' # 0xD4 -> UNDEFINED
+ '\ufffe' # 0xD5 -> UNDEFINED
+ '\ufffe' # 0xD6 -> UNDEFINEDE
+ '\ufffe' # 0xD7 -> UNDEFINED
+ '\ufffe' # 0xD8 -> UNDEFINED
+ '\u2518' # 0xD9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0xDA -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0xDB -> FULL BLOCK
+ '\u2584' # 0xDC -> LOWER HALF BLOCK
+ '\xa6' # 0xDD -> BROKEN BAR
+ '\ufffe' # 0xDE -> UNDEFINED
+ '\u2580' # 0xDF -> UPPER HALF BLOCK
+ '\ufffe' # 0xE0 -> UNDEFINED
+ '\ufffe' # 0xE1 -> UNDEFINED
+ '\ufffe' # 0xE2 -> UNDEFINED
+ '\ufffe' # 0xE3 -> UNDEFINED
+ '\ufffe' # 0xE4 -> UNDEFINED
+ '\ufffe' # 0xE5 -> UNDEFINED
+ '\xb5' # 0xE6 -> MICRO SIGN
+ '\ufffe' # 0xE7 -> UNDEFINED
+ '\ufffe' # 0xE8 -> UNDEFINED
+ '\ufffe' # 0xE9 -> UNDEFINED
+ '\ufffe' # 0xEA -> UNDEFINED
+ '\ufffe' # 0xEB -> UNDEFINED
+ '\ufffe' # 0xEC -> UNDEFINED
+ '\ufffe' # 0xED -> UNDEFINED
+ '\xaf' # 0xEE -> MACRON
+ '\xb4' # 0xEF -> ACUTE ACCENT
+ '\xad' # 0xF0 -> SOFT HYPHEN
+ '\xb1' # 0xF1 -> PLUS-MINUS SIGN
+ '\u2017' # 0xF2 -> DOUBLE LOW LINE
+ '\xbe' # 0xF3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0xF4 -> PILCROW SIGN
+ '\xa7' # 0xF5 -> SECTION SIGN
+ '\xf7' # 0xF6 -> DIVISION SIGN
+ '\xb8' # 0xF7 -> CEDILLA
+ '\xb0' # 0xF8 -> DEGREE SIGN
+ '\xa8' # 0xF9 -> DIAERESIS
+ '\xb7' # 0xFA -> MIDDLE DOT
+ '\xb9' # 0xFB -> SUPERSCRIPT ONE
+ '\xb3' # 0xFC -> SUPERSCRIPT THREE
+ '\xb2' # 0xFD -> SUPERSCRIPT TWO
+ '\u25a0' # 0xFE -> BLACK SQUARE
+ '\xa0' # 0xFF -> NO-BREAK SPACE
)
### Encoding table
diff --git a/Lib/encodings/cp857.py b/Lib/encodings/cp857.py
index c24191b04dc..741b059b9a2 100644
--- a/Lib/encodings/cp857.py
+++ b/Lib/encodings/cp857.py
@@ -177,262 +177,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u0131' # 0x008d -> LATIN SMALL LETTER DOTLESS I
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\u0130' # 0x0098 -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u015e' # 0x009e -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\u015f' # 0x009f -> LATIN SMALL LETTER S WITH CEDILLA
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\u011e' # 0x00a6 -> LATIN CAPITAL LETTER G WITH BREVE
- u'\u011f' # 0x00a7 -> LATIN SMALL LETTER G WITH BREVE
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\xae' # 0x00a9 -> REGISTERED SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xa9' # 0x00b8 -> COPYRIGHT SIGN
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\xa2' # 0x00bd -> CENT SIGN
- u'\xa5' # 0x00be -> YEN SIGN
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
- u'\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0x00cf -> CURRENCY SIGN
- u'\xba' # 0x00d0 -> MASCULINE ORDINAL INDICATOR
- u'\xaa' # 0x00d1 -> FEMININE ORDINAL INDICATOR
- u'\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\ufffe' # 0x00d5 -> UNDEFINED
- u'\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\xa6' # 0x00dd -> BROKEN BAR
- u'\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
- u'\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\ufffe' # 0x00e7 -> UNDEFINED
- u'\xd7' # 0x00e8 -> MULTIPLICATION SIGN
- u'\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xec' # 0x00ec -> LATIN SMALL LETTER I WITH GRAVE
- u'\xff' # 0x00ed -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xaf' # 0x00ee -> MACRON
- u'\xb4' # 0x00ef -> ACUTE ACCENT
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\ufffe' # 0x00f2 -> UNDEFINED
- u'\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
- u'\xb6' # 0x00f4 -> PILCROW SIGN
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\xb8' # 0x00f7 -> CEDILLA
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\xa8' # 0x00f9 -> DIAERESIS
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\xb9' # 0x00fb -> SUPERSCRIPT ONE
- u'\xb3' # 0x00fc -> SUPERSCRIPT THREE
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u0131' # 0x008d -> LATIN SMALL LETTER DOTLESS I
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\u0130' # 0x0098 -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u015e' # 0x009e -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\u015f' # 0x009f -> LATIN SMALL LETTER S WITH CEDILLA
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\u011e' # 0x00a6 -> LATIN CAPITAL LETTER G WITH BREVE
+ '\u011f' # 0x00a7 -> LATIN SMALL LETTER G WITH BREVE
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\xae' # 0x00a9 -> REGISTERED SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xa9' # 0x00b8 -> COPYRIGHT SIGN
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\xa2' # 0x00bd -> CENT SIGN
+ '\xa5' # 0x00be -> YEN SIGN
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
+ '\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\xba' # 0x00d0 -> MASCULINE ORDINAL INDICATOR
+ '\xaa' # 0x00d1 -> FEMININE ORDINAL INDICATOR
+ '\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\ufffe' # 0x00d5 -> UNDEFINED
+ '\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\xa6' # 0x00dd -> BROKEN BAR
+ '\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
+ '\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\ufffe' # 0x00e7 -> UNDEFINED
+ '\xd7' # 0x00e8 -> MULTIPLICATION SIGN
+ '\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xec' # 0x00ec -> LATIN SMALL LETTER I WITH GRAVE
+ '\xff' # 0x00ed -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xaf' # 0x00ee -> MACRON
+ '\xb4' # 0x00ef -> ACUTE ACCENT
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\ufffe' # 0x00f2 -> UNDEFINED
+ '\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0x00f4 -> PILCROW SIGN
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\xb8' # 0x00f7 -> CEDILLA
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\xb9' # 0x00fb -> SUPERSCRIPT ONE
+ '\xb3' # 0x00fc -> SUPERSCRIPT THREE
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp858.py b/Lib/encodings/cp858.py
index 7ba7621f8fb..7579f525386 100644
--- a/Lib/encodings/cp858.py
+++ b/Lib/encodings/cp858.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd7' # 0x009e -> MULTIPLICATION SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\xae' # 0x00a9 -> REGISTERED SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xa9' # 0x00b8 -> COPYRIGHT SIGN
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\xa2' # 0x00bd -> CENT SIGN
- u'\xa5' # 0x00be -> YEN SIGN
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
- u'\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa4' # 0x00cf -> CURRENCY SIGN
- u'\xf0' # 0x00d0 -> LATIN SMALL LETTER ETH
- u'\xd0' # 0x00d1 -> LATIN CAPITAL LETTER ETH
- u'\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\u20ac' # 0x00d5 -> EURO SIGN
- u'\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\xa6' # 0x00dd -> BROKEN BAR
- u'\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
- u'\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\xfe' # 0x00e7 -> LATIN SMALL LETTER THORN
- u'\xde' # 0x00e8 -> LATIN CAPITAL LETTER THORN
- u'\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xaf' # 0x00ee -> MACRON
- u'\xb4' # 0x00ef -> ACUTE ACCENT
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2017' # 0x00f2 -> DOUBLE LOW LINE
- u'\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
- u'\xb6' # 0x00f4 -> PILCROW SIGN
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\xb8' # 0x00f7 -> CEDILLA
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\xa8' # 0x00f9 -> DIAERESIS
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\xb9' # 0x00fb -> SUPERSCRIPT ONE
- u'\xb3' # 0x00fc -> SUPERSCRIPT THREE
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd7' # 0x009e -> MULTIPLICATION SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\xae' # 0x00a9 -> REGISTERED SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\xc1' # 0x00b5 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0x00b6 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc0' # 0x00b7 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xa9' # 0x00b8 -> COPYRIGHT SIGN
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\xa2' # 0x00bd -> CENT SIGN
+ '\xa5' # 0x00be -> YEN SIGN
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\xe3' # 0x00c6 -> LATIN SMALL LETTER A WITH TILDE
+ '\xc3' # 0x00c7 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa4' # 0x00cf -> CURRENCY SIGN
+ '\xf0' # 0x00d0 -> LATIN SMALL LETTER ETH
+ '\xd0' # 0x00d1 -> LATIN CAPITAL LETTER ETH
+ '\xca' # 0x00d2 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0x00d3 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0x00d4 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\u20ac' # 0x00d5 -> EURO SIGN
+ '\xcd' # 0x00d6 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0x00d7 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0x00d8 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\xa6' # 0x00dd -> BROKEN BAR
+ '\xcc' # 0x00de -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\xd3' # 0x00e0 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\xd4' # 0x00e2 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd2' # 0x00e3 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xf5' # 0x00e4 -> LATIN SMALL LETTER O WITH TILDE
+ '\xd5' # 0x00e5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\xfe' # 0x00e7 -> LATIN SMALL LETTER THORN
+ '\xde' # 0x00e8 -> LATIN CAPITAL LETTER THORN
+ '\xda' # 0x00e9 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0x00ea -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0x00eb -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xfd' # 0x00ec -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xdd' # 0x00ed -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xaf' # 0x00ee -> MACRON
+ '\xb4' # 0x00ef -> ACUTE ACCENT
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2017' # 0x00f2 -> DOUBLE LOW LINE
+ '\xbe' # 0x00f3 -> VULGAR FRACTION THREE QUARTERS
+ '\xb6' # 0x00f4 -> PILCROW SIGN
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\xb8' # 0x00f7 -> CEDILLA
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\xb9' # 0x00fb -> SUPERSCRIPT ONE
+ '\xb3' # 0x00fc -> SUPERSCRIPT THREE
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp860.py b/Lib/encodings/cp860.py
index 4acb0cf3626..65903e74641 100644
--- a/Lib/encodings/cp860.py
+++ b/Lib/encodings/cp860.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0x0084 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xc1' # 0x0086 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xca' # 0x0089 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xcd' # 0x008b -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xd4' # 0x008c -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
- u'\xc3' # 0x008e -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc2' # 0x008f -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xc0' # 0x0091 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc8' # 0x0092 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0x0094 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xda' # 0x0096 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xcc' # 0x0098 -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd5' # 0x0099 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xa2' # 0x009b -> CENT SIGN
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd9' # 0x009d -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\u20a7' # 0x009e -> PESETA SIGN
- u'\xd3' # 0x009f -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\xd2' # 0x00a9 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0x0084 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xc1' # 0x0086 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xca' # 0x0089 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xcd' # 0x008b -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xd4' # 0x008c -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc3' # 0x008e -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc2' # 0x008f -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xc0' # 0x0091 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc8' # 0x0092 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0x0094 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xda' # 0x0096 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xcc' # 0x0098 -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd5' # 0x0099 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xa2' # 0x009b -> CENT SIGN
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd9' # 0x009d -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\u20a7' # 0x009e -> PESETA SIGN
+ '\xd3' # 0x009f -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\xd2' # 0x00a9 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp861.py b/Lib/encodings/cp861.py
index 0939b5b1eef..860a05fa3f4 100644
--- a/Lib/encodings/cp861.py
+++ b/Lib/encodings/cp861.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xd0' # 0x008b -> LATIN CAPITAL LETTER ETH
- u'\xf0' # 0x008c -> LATIN SMALL LETTER ETH
- u'\xde' # 0x008d -> LATIN CAPITAL LETTER THORN
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xfe' # 0x0095 -> LATIN SMALL LETTER THORN
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xdd' # 0x0097 -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xfd' # 0x0098 -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u20a7' # 0x009e -> PESETA SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xc1' # 0x00a4 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xcd' # 0x00a5 -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xd3' # 0x00a6 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xda' # 0x00a7 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\u2310' # 0x00a9 -> REVERSED NOT SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xd0' # 0x008b -> LATIN CAPITAL LETTER ETH
+ '\xf0' # 0x008c -> LATIN SMALL LETTER ETH
+ '\xde' # 0x008d -> LATIN CAPITAL LETTER THORN
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xfe' # 0x0095 -> LATIN SMALL LETTER THORN
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xdd' # 0x0097 -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xfd' # 0x0098 -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u20a7' # 0x009e -> PESETA SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xc1' # 0x00a4 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xcd' # 0x00a5 -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xd3' # 0x00a6 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xda' # 0x00a7 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\u2310' # 0x00a9 -> REVERSED NOT SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp862.py b/Lib/encodings/cp862.py
index ea0405ca1ba..3df22f997b7 100644
--- a/Lib/encodings/cp862.py
+++ b/Lib/encodings/cp862.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\u05d0' # 0x0080 -> HEBREW LETTER ALEF
- u'\u05d1' # 0x0081 -> HEBREW LETTER BET
- u'\u05d2' # 0x0082 -> HEBREW LETTER GIMEL
- u'\u05d3' # 0x0083 -> HEBREW LETTER DALET
- u'\u05d4' # 0x0084 -> HEBREW LETTER HE
- u'\u05d5' # 0x0085 -> HEBREW LETTER VAV
- u'\u05d6' # 0x0086 -> HEBREW LETTER ZAYIN
- u'\u05d7' # 0x0087 -> HEBREW LETTER HET
- u'\u05d8' # 0x0088 -> HEBREW LETTER TET
- u'\u05d9' # 0x0089 -> HEBREW LETTER YOD
- u'\u05da' # 0x008a -> HEBREW LETTER FINAL KAF
- u'\u05db' # 0x008b -> HEBREW LETTER KAF
- u'\u05dc' # 0x008c -> HEBREW LETTER LAMED
- u'\u05dd' # 0x008d -> HEBREW LETTER FINAL MEM
- u'\u05de' # 0x008e -> HEBREW LETTER MEM
- u'\u05df' # 0x008f -> HEBREW LETTER FINAL NUN
- u'\u05e0' # 0x0090 -> HEBREW LETTER NUN
- u'\u05e1' # 0x0091 -> HEBREW LETTER SAMEKH
- u'\u05e2' # 0x0092 -> HEBREW LETTER AYIN
- u'\u05e3' # 0x0093 -> HEBREW LETTER FINAL PE
- u'\u05e4' # 0x0094 -> HEBREW LETTER PE
- u'\u05e5' # 0x0095 -> HEBREW LETTER FINAL TSADI
- u'\u05e6' # 0x0096 -> HEBREW LETTER TSADI
- u'\u05e7' # 0x0097 -> HEBREW LETTER QOF
- u'\u05e8' # 0x0098 -> HEBREW LETTER RESH
- u'\u05e9' # 0x0099 -> HEBREW LETTER SHIN
- u'\u05ea' # 0x009a -> HEBREW LETTER TAV
- u'\xa2' # 0x009b -> CENT SIGN
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xa5' # 0x009d -> YEN SIGN
- u'\u20a7' # 0x009e -> PESETA SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\u2310' # 0x00a9 -> REVERSED NOT SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S (GERMAN)
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\u05d0' # 0x0080 -> HEBREW LETTER ALEF
+ '\u05d1' # 0x0081 -> HEBREW LETTER BET
+ '\u05d2' # 0x0082 -> HEBREW LETTER GIMEL
+ '\u05d3' # 0x0083 -> HEBREW LETTER DALET
+ '\u05d4' # 0x0084 -> HEBREW LETTER HE
+ '\u05d5' # 0x0085 -> HEBREW LETTER VAV
+ '\u05d6' # 0x0086 -> HEBREW LETTER ZAYIN
+ '\u05d7' # 0x0087 -> HEBREW LETTER HET
+ '\u05d8' # 0x0088 -> HEBREW LETTER TET
+ '\u05d9' # 0x0089 -> HEBREW LETTER YOD
+ '\u05da' # 0x008a -> HEBREW LETTER FINAL KAF
+ '\u05db' # 0x008b -> HEBREW LETTER KAF
+ '\u05dc' # 0x008c -> HEBREW LETTER LAMED
+ '\u05dd' # 0x008d -> HEBREW LETTER FINAL MEM
+ '\u05de' # 0x008e -> HEBREW LETTER MEM
+ '\u05df' # 0x008f -> HEBREW LETTER FINAL NUN
+ '\u05e0' # 0x0090 -> HEBREW LETTER NUN
+ '\u05e1' # 0x0091 -> HEBREW LETTER SAMEKH
+ '\u05e2' # 0x0092 -> HEBREW LETTER AYIN
+ '\u05e3' # 0x0093 -> HEBREW LETTER FINAL PE
+ '\u05e4' # 0x0094 -> HEBREW LETTER PE
+ '\u05e5' # 0x0095 -> HEBREW LETTER FINAL TSADI
+ '\u05e6' # 0x0096 -> HEBREW LETTER TSADI
+ '\u05e7' # 0x0097 -> HEBREW LETTER QOF
+ '\u05e8' # 0x0098 -> HEBREW LETTER RESH
+ '\u05e9' # 0x0099 -> HEBREW LETTER SHIN
+ '\u05ea' # 0x009a -> HEBREW LETTER TAV
+ '\xa2' # 0x009b -> CENT SIGN
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xa5' # 0x009d -> YEN SIGN
+ '\u20a7' # 0x009e -> PESETA SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\u2310' # 0x00a9 -> REVERSED NOT SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S (GERMAN)
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp863.py b/Lib/encodings/cp863.py
index 62dfabf66ab..764180b6232 100644
--- a/Lib/encodings/cp863.py
+++ b/Lib/encodings/cp863.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xc2' # 0x0084 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xb6' # 0x0086 -> PILCROW SIGN
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u2017' # 0x008d -> DOUBLE LOW LINE
- u'\xc0' # 0x008e -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xa7' # 0x008f -> SECTION SIGN
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xc8' # 0x0091 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xca' # 0x0092 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xcb' # 0x0094 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcf' # 0x0095 -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xa4' # 0x0098 -> CURRENCY SIGN
- u'\xd4' # 0x0099 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xa2' # 0x009b -> CENT SIGN
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd9' # 0x009d -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xdb' # 0x009e -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xa6' # 0x00a0 -> BROKEN BAR
- u'\xb4' # 0x00a1 -> ACUTE ACCENT
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xa8' # 0x00a4 -> DIAERESIS
- u'\xb8' # 0x00a5 -> CEDILLA
- u'\xb3' # 0x00a6 -> SUPERSCRIPT THREE
- u'\xaf' # 0x00a7 -> MACRON
- u'\xce' # 0x00a8 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\u2310' # 0x00a9 -> REVERSED NOT SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xbe' # 0x00ad -> VULGAR FRACTION THREE QUARTERS
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xc2' # 0x0084 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xb6' # 0x0086 -> PILCROW SIGN
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u2017' # 0x008d -> DOUBLE LOW LINE
+ '\xc0' # 0x008e -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xa7' # 0x008f -> SECTION SIGN
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xc8' # 0x0091 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xca' # 0x0092 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xcb' # 0x0094 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcf' # 0x0095 -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xa4' # 0x0098 -> CURRENCY SIGN
+ '\xd4' # 0x0099 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xa2' # 0x009b -> CENT SIGN
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd9' # 0x009d -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xdb' # 0x009e -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xa6' # 0x00a0 -> BROKEN BAR
+ '\xb4' # 0x00a1 -> ACUTE ACCENT
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xa8' # 0x00a4 -> DIAERESIS
+ '\xb8' # 0x00a5 -> CEDILLA
+ '\xb3' # 0x00a6 -> SUPERSCRIPT THREE
+ '\xaf' # 0x00a7 -> MACRON
+ '\xce' # 0x00a8 -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\u2310' # 0x00a9 -> REVERSED NOT SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xbe' # 0x00ad -> VULGAR FRACTION THREE QUARTERS
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp864.py b/Lib/encodings/cp864.py
index 02a0e733a87..53df482dcd6 100644
--- a/Lib/encodings/cp864.py
+++ b/Lib/encodings/cp864.py
@@ -176,262 +176,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'\u066a' # 0x0025 -> ARABIC PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xb0' # 0x0080 -> DEGREE SIGN
- u'\xb7' # 0x0081 -> MIDDLE DOT
- u'\u2219' # 0x0082 -> BULLET OPERATOR
- u'\u221a' # 0x0083 -> SQUARE ROOT
- u'\u2592' # 0x0084 -> MEDIUM SHADE
- u'\u2500' # 0x0085 -> FORMS LIGHT HORIZONTAL
- u'\u2502' # 0x0086 -> FORMS LIGHT VERTICAL
- u'\u253c' # 0x0087 -> FORMS LIGHT VERTICAL AND HORIZONTAL
- u'\u2524' # 0x0088 -> FORMS LIGHT VERTICAL AND LEFT
- u'\u252c' # 0x0089 -> FORMS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x008a -> FORMS LIGHT VERTICAL AND RIGHT
- u'\u2534' # 0x008b -> FORMS LIGHT UP AND HORIZONTAL
- u'\u2510' # 0x008c -> FORMS LIGHT DOWN AND LEFT
- u'\u250c' # 0x008d -> FORMS LIGHT DOWN AND RIGHT
- u'\u2514' # 0x008e -> FORMS LIGHT UP AND RIGHT
- u'\u2518' # 0x008f -> FORMS LIGHT UP AND LEFT
- u'\u03b2' # 0x0090 -> GREEK SMALL BETA
- u'\u221e' # 0x0091 -> INFINITY
- u'\u03c6' # 0x0092 -> GREEK SMALL PHI
- u'\xb1' # 0x0093 -> PLUS-OR-MINUS SIGN
- u'\xbd' # 0x0094 -> FRACTION 1/2
- u'\xbc' # 0x0095 -> FRACTION 1/4
- u'\u2248' # 0x0096 -> ALMOST EQUAL TO
- u'\xab' # 0x0097 -> LEFT POINTING GUILLEMET
- u'\xbb' # 0x0098 -> RIGHT POINTING GUILLEMET
- u'\ufef7' # 0x0099 -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
- u'\ufef8' # 0x009a -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
- u'\ufffe' # 0x009b -> UNDEFINED
- u'\ufffe' # 0x009c -> UNDEFINED
- u'\ufefb' # 0x009d -> ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
- u'\ufefc' # 0x009e -> ARABIC LIGATURE LAM WITH ALEF FINAL FORM
- u'\ufffe' # 0x009f -> UNDEFINED
- u'\xa0' # 0x00a0 -> NON-BREAKING SPACE
- u'\xad' # 0x00a1 -> SOFT HYPHEN
- u'\ufe82' # 0x00a2 -> ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
- u'\xa3' # 0x00a3 -> POUND SIGN
- u'\xa4' # 0x00a4 -> CURRENCY SIGN
- u'\ufe84' # 0x00a5 -> ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
- u'\ufffe' # 0x00a6 -> UNDEFINED
- u'\ufffe' # 0x00a7 -> UNDEFINED
- u'\ufe8e' # 0x00a8 -> ARABIC LETTER ALEF FINAL FORM
- u'\ufe8f' # 0x00a9 -> ARABIC LETTER BEH ISOLATED FORM
- u'\ufe95' # 0x00aa -> ARABIC LETTER TEH ISOLATED FORM
- u'\ufe99' # 0x00ab -> ARABIC LETTER THEH ISOLATED FORM
- u'\u060c' # 0x00ac -> ARABIC COMMA
- u'\ufe9d' # 0x00ad -> ARABIC LETTER JEEM ISOLATED FORM
- u'\ufea1' # 0x00ae -> ARABIC LETTER HAH ISOLATED FORM
- u'\ufea5' # 0x00af -> ARABIC LETTER KHAH ISOLATED FORM
- u'\u0660' # 0x00b0 -> ARABIC-INDIC DIGIT ZERO
- u'\u0661' # 0x00b1 -> ARABIC-INDIC DIGIT ONE
- u'\u0662' # 0x00b2 -> ARABIC-INDIC DIGIT TWO
- u'\u0663' # 0x00b3 -> ARABIC-INDIC DIGIT THREE
- u'\u0664' # 0x00b4 -> ARABIC-INDIC DIGIT FOUR
- u'\u0665' # 0x00b5 -> ARABIC-INDIC DIGIT FIVE
- u'\u0666' # 0x00b6 -> ARABIC-INDIC DIGIT SIX
- u'\u0667' # 0x00b7 -> ARABIC-INDIC DIGIT SEVEN
- u'\u0668' # 0x00b8 -> ARABIC-INDIC DIGIT EIGHT
- u'\u0669' # 0x00b9 -> ARABIC-INDIC DIGIT NINE
- u'\ufed1' # 0x00ba -> ARABIC LETTER FEH ISOLATED FORM
- u'\u061b' # 0x00bb -> ARABIC SEMICOLON
- u'\ufeb1' # 0x00bc -> ARABIC LETTER SEEN ISOLATED FORM
- u'\ufeb5' # 0x00bd -> ARABIC LETTER SHEEN ISOLATED FORM
- u'\ufeb9' # 0x00be -> ARABIC LETTER SAD ISOLATED FORM
- u'\u061f' # 0x00bf -> ARABIC QUESTION MARK
- u'\xa2' # 0x00c0 -> CENT SIGN
- u'\ufe80' # 0x00c1 -> ARABIC LETTER HAMZA ISOLATED FORM
- u'\ufe81' # 0x00c2 -> ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
- u'\ufe83' # 0x00c3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
- u'\ufe85' # 0x00c4 -> ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
- u'\ufeca' # 0x00c5 -> ARABIC LETTER AIN FINAL FORM
- u'\ufe8b' # 0x00c6 -> ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
- u'\ufe8d' # 0x00c7 -> ARABIC LETTER ALEF ISOLATED FORM
- u'\ufe91' # 0x00c8 -> ARABIC LETTER BEH INITIAL FORM
- u'\ufe93' # 0x00c9 -> ARABIC LETTER TEH MARBUTA ISOLATED FORM
- u'\ufe97' # 0x00ca -> ARABIC LETTER TEH INITIAL FORM
- u'\ufe9b' # 0x00cb -> ARABIC LETTER THEH INITIAL FORM
- u'\ufe9f' # 0x00cc -> ARABIC LETTER JEEM INITIAL FORM
- u'\ufea3' # 0x00cd -> ARABIC LETTER HAH INITIAL FORM
- u'\ufea7' # 0x00ce -> ARABIC LETTER KHAH INITIAL FORM
- u'\ufea9' # 0x00cf -> ARABIC LETTER DAL ISOLATED FORM
- u'\ufeab' # 0x00d0 -> ARABIC LETTER THAL ISOLATED FORM
- u'\ufead' # 0x00d1 -> ARABIC LETTER REH ISOLATED FORM
- u'\ufeaf' # 0x00d2 -> ARABIC LETTER ZAIN ISOLATED FORM
- u'\ufeb3' # 0x00d3 -> ARABIC LETTER SEEN INITIAL FORM
- u'\ufeb7' # 0x00d4 -> ARABIC LETTER SHEEN INITIAL FORM
- u'\ufebb' # 0x00d5 -> ARABIC LETTER SAD INITIAL FORM
- u'\ufebf' # 0x00d6 -> ARABIC LETTER DAD INITIAL FORM
- u'\ufec1' # 0x00d7 -> ARABIC LETTER TAH ISOLATED FORM
- u'\ufec5' # 0x00d8 -> ARABIC LETTER ZAH ISOLATED FORM
- u'\ufecb' # 0x00d9 -> ARABIC LETTER AIN INITIAL FORM
- u'\ufecf' # 0x00da -> ARABIC LETTER GHAIN INITIAL FORM
- u'\xa6' # 0x00db -> BROKEN VERTICAL BAR
- u'\xac' # 0x00dc -> NOT SIGN
- u'\xf7' # 0x00dd -> DIVISION SIGN
- u'\xd7' # 0x00de -> MULTIPLICATION SIGN
- u'\ufec9' # 0x00df -> ARABIC LETTER AIN ISOLATED FORM
- u'\u0640' # 0x00e0 -> ARABIC TATWEEL
- u'\ufed3' # 0x00e1 -> ARABIC LETTER FEH INITIAL FORM
- u'\ufed7' # 0x00e2 -> ARABIC LETTER QAF INITIAL FORM
- u'\ufedb' # 0x00e3 -> ARABIC LETTER KAF INITIAL FORM
- u'\ufedf' # 0x00e4 -> ARABIC LETTER LAM INITIAL FORM
- u'\ufee3' # 0x00e5 -> ARABIC LETTER MEEM INITIAL FORM
- u'\ufee7' # 0x00e6 -> ARABIC LETTER NOON INITIAL FORM
- u'\ufeeb' # 0x00e7 -> ARABIC LETTER HEH INITIAL FORM
- u'\ufeed' # 0x00e8 -> ARABIC LETTER WAW ISOLATED FORM
- u'\ufeef' # 0x00e9 -> ARABIC LETTER ALEF MAKSURA ISOLATED FORM
- u'\ufef3' # 0x00ea -> ARABIC LETTER YEH INITIAL FORM
- u'\ufebd' # 0x00eb -> ARABIC LETTER DAD ISOLATED FORM
- u'\ufecc' # 0x00ec -> ARABIC LETTER AIN MEDIAL FORM
- u'\ufece' # 0x00ed -> ARABIC LETTER GHAIN FINAL FORM
- u'\ufecd' # 0x00ee -> ARABIC LETTER GHAIN ISOLATED FORM
- u'\ufee1' # 0x00ef -> ARABIC LETTER MEEM ISOLATED FORM
- u'\ufe7d' # 0x00f0 -> ARABIC SHADDA MEDIAL FORM
- u'\u0651' # 0x00f1 -> ARABIC SHADDAH
- u'\ufee5' # 0x00f2 -> ARABIC LETTER NOON ISOLATED FORM
- u'\ufee9' # 0x00f3 -> ARABIC LETTER HEH ISOLATED FORM
- u'\ufeec' # 0x00f4 -> ARABIC LETTER HEH MEDIAL FORM
- u'\ufef0' # 0x00f5 -> ARABIC LETTER ALEF MAKSURA FINAL FORM
- u'\ufef2' # 0x00f6 -> ARABIC LETTER YEH FINAL FORM
- u'\ufed0' # 0x00f7 -> ARABIC LETTER GHAIN MEDIAL FORM
- u'\ufed5' # 0x00f8 -> ARABIC LETTER QAF ISOLATED FORM
- u'\ufef5' # 0x00f9 -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
- u'\ufef6' # 0x00fa -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
- u'\ufedd' # 0x00fb -> ARABIC LETTER LAM ISOLATED FORM
- u'\ufed9' # 0x00fc -> ARABIC LETTER KAF ISOLATED FORM
- u'\ufef1' # 0x00fd -> ARABIC LETTER YEH ISOLATED FORM
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\ufffe' # 0x00ff -> UNDEFINED
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '\u066a' # 0x0025 -> ARABIC PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xb0' # 0x0080 -> DEGREE SIGN
+ '\xb7' # 0x0081 -> MIDDLE DOT
+ '\u2219' # 0x0082 -> BULLET OPERATOR
+ '\u221a' # 0x0083 -> SQUARE ROOT
+ '\u2592' # 0x0084 -> MEDIUM SHADE
+ '\u2500' # 0x0085 -> FORMS LIGHT HORIZONTAL
+ '\u2502' # 0x0086 -> FORMS LIGHT VERTICAL
+ '\u253c' # 0x0087 -> FORMS LIGHT VERTICAL AND HORIZONTAL
+ '\u2524' # 0x0088 -> FORMS LIGHT VERTICAL AND LEFT
+ '\u252c' # 0x0089 -> FORMS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x008a -> FORMS LIGHT VERTICAL AND RIGHT
+ '\u2534' # 0x008b -> FORMS LIGHT UP AND HORIZONTAL
+ '\u2510' # 0x008c -> FORMS LIGHT DOWN AND LEFT
+ '\u250c' # 0x008d -> FORMS LIGHT DOWN AND RIGHT
+ '\u2514' # 0x008e -> FORMS LIGHT UP AND RIGHT
+ '\u2518' # 0x008f -> FORMS LIGHT UP AND LEFT
+ '\u03b2' # 0x0090 -> GREEK SMALL BETA
+ '\u221e' # 0x0091 -> INFINITY
+ '\u03c6' # 0x0092 -> GREEK SMALL PHI
+ '\xb1' # 0x0093 -> PLUS-OR-MINUS SIGN
+ '\xbd' # 0x0094 -> FRACTION 1/2
+ '\xbc' # 0x0095 -> FRACTION 1/4
+ '\u2248' # 0x0096 -> ALMOST EQUAL TO
+ '\xab' # 0x0097 -> LEFT POINTING GUILLEMET
+ '\xbb' # 0x0098 -> RIGHT POINTING GUILLEMET
+ '\ufef7' # 0x0099 -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM
+ '\ufef8' # 0x009a -> ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE FINAL FORM
+ '\ufffe' # 0x009b -> UNDEFINED
+ '\ufffe' # 0x009c -> UNDEFINED
+ '\ufefb' # 0x009d -> ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM
+ '\ufefc' # 0x009e -> ARABIC LIGATURE LAM WITH ALEF FINAL FORM
+ '\ufffe' # 0x009f -> UNDEFINED
+ '\xa0' # 0x00a0 -> NON-BREAKING SPACE
+ '\xad' # 0x00a1 -> SOFT HYPHEN
+ '\ufe82' # 0x00a2 -> ARABIC LETTER ALEF WITH MADDA ABOVE FINAL FORM
+ '\xa3' # 0x00a3 -> POUND SIGN
+ '\xa4' # 0x00a4 -> CURRENCY SIGN
+ '\ufe84' # 0x00a5 -> ARABIC LETTER ALEF WITH HAMZA ABOVE FINAL FORM
+ '\ufffe' # 0x00a6 -> UNDEFINED
+ '\ufffe' # 0x00a7 -> UNDEFINED
+ '\ufe8e' # 0x00a8 -> ARABIC LETTER ALEF FINAL FORM
+ '\ufe8f' # 0x00a9 -> ARABIC LETTER BEH ISOLATED FORM
+ '\ufe95' # 0x00aa -> ARABIC LETTER TEH ISOLATED FORM
+ '\ufe99' # 0x00ab -> ARABIC LETTER THEH ISOLATED FORM
+ '\u060c' # 0x00ac -> ARABIC COMMA
+ '\ufe9d' # 0x00ad -> ARABIC LETTER JEEM ISOLATED FORM
+ '\ufea1' # 0x00ae -> ARABIC LETTER HAH ISOLATED FORM
+ '\ufea5' # 0x00af -> ARABIC LETTER KHAH ISOLATED FORM
+ '\u0660' # 0x00b0 -> ARABIC-INDIC DIGIT ZERO
+ '\u0661' # 0x00b1 -> ARABIC-INDIC DIGIT ONE
+ '\u0662' # 0x00b2 -> ARABIC-INDIC DIGIT TWO
+ '\u0663' # 0x00b3 -> ARABIC-INDIC DIGIT THREE
+ '\u0664' # 0x00b4 -> ARABIC-INDIC DIGIT FOUR
+ '\u0665' # 0x00b5 -> ARABIC-INDIC DIGIT FIVE
+ '\u0666' # 0x00b6 -> ARABIC-INDIC DIGIT SIX
+ '\u0667' # 0x00b7 -> ARABIC-INDIC DIGIT SEVEN
+ '\u0668' # 0x00b8 -> ARABIC-INDIC DIGIT EIGHT
+ '\u0669' # 0x00b9 -> ARABIC-INDIC DIGIT NINE
+ '\ufed1' # 0x00ba -> ARABIC LETTER FEH ISOLATED FORM
+ '\u061b' # 0x00bb -> ARABIC SEMICOLON
+ '\ufeb1' # 0x00bc -> ARABIC LETTER SEEN ISOLATED FORM
+ '\ufeb5' # 0x00bd -> ARABIC LETTER SHEEN ISOLATED FORM
+ '\ufeb9' # 0x00be -> ARABIC LETTER SAD ISOLATED FORM
+ '\u061f' # 0x00bf -> ARABIC QUESTION MARK
+ '\xa2' # 0x00c0 -> CENT SIGN
+ '\ufe80' # 0x00c1 -> ARABIC LETTER HAMZA ISOLATED FORM
+ '\ufe81' # 0x00c2 -> ARABIC LETTER ALEF WITH MADDA ABOVE ISOLATED FORM
+ '\ufe83' # 0x00c3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE ISOLATED FORM
+ '\ufe85' # 0x00c4 -> ARABIC LETTER WAW WITH HAMZA ABOVE ISOLATED FORM
+ '\ufeca' # 0x00c5 -> ARABIC LETTER AIN FINAL FORM
+ '\ufe8b' # 0x00c6 -> ARABIC LETTER YEH WITH HAMZA ABOVE INITIAL FORM
+ '\ufe8d' # 0x00c7 -> ARABIC LETTER ALEF ISOLATED FORM
+ '\ufe91' # 0x00c8 -> ARABIC LETTER BEH INITIAL FORM
+ '\ufe93' # 0x00c9 -> ARABIC LETTER TEH MARBUTA ISOLATED FORM
+ '\ufe97' # 0x00ca -> ARABIC LETTER TEH INITIAL FORM
+ '\ufe9b' # 0x00cb -> ARABIC LETTER THEH INITIAL FORM
+ '\ufe9f' # 0x00cc -> ARABIC LETTER JEEM INITIAL FORM
+ '\ufea3' # 0x00cd -> ARABIC LETTER HAH INITIAL FORM
+ '\ufea7' # 0x00ce -> ARABIC LETTER KHAH INITIAL FORM
+ '\ufea9' # 0x00cf -> ARABIC LETTER DAL ISOLATED FORM
+ '\ufeab' # 0x00d0 -> ARABIC LETTER THAL ISOLATED FORM
+ '\ufead' # 0x00d1 -> ARABIC LETTER REH ISOLATED FORM
+ '\ufeaf' # 0x00d2 -> ARABIC LETTER ZAIN ISOLATED FORM
+ '\ufeb3' # 0x00d3 -> ARABIC LETTER SEEN INITIAL FORM
+ '\ufeb7' # 0x00d4 -> ARABIC LETTER SHEEN INITIAL FORM
+ '\ufebb' # 0x00d5 -> ARABIC LETTER SAD INITIAL FORM
+ '\ufebf' # 0x00d6 -> ARABIC LETTER DAD INITIAL FORM
+ '\ufec1' # 0x00d7 -> ARABIC LETTER TAH ISOLATED FORM
+ '\ufec5' # 0x00d8 -> ARABIC LETTER ZAH ISOLATED FORM
+ '\ufecb' # 0x00d9 -> ARABIC LETTER AIN INITIAL FORM
+ '\ufecf' # 0x00da -> ARABIC LETTER GHAIN INITIAL FORM
+ '\xa6' # 0x00db -> BROKEN VERTICAL BAR
+ '\xac' # 0x00dc -> NOT SIGN
+ '\xf7' # 0x00dd -> DIVISION SIGN
+ '\xd7' # 0x00de -> MULTIPLICATION SIGN
+ '\ufec9' # 0x00df -> ARABIC LETTER AIN ISOLATED FORM
+ '\u0640' # 0x00e0 -> ARABIC TATWEEL
+ '\ufed3' # 0x00e1 -> ARABIC LETTER FEH INITIAL FORM
+ '\ufed7' # 0x00e2 -> ARABIC LETTER QAF INITIAL FORM
+ '\ufedb' # 0x00e3 -> ARABIC LETTER KAF INITIAL FORM
+ '\ufedf' # 0x00e4 -> ARABIC LETTER LAM INITIAL FORM
+ '\ufee3' # 0x00e5 -> ARABIC LETTER MEEM INITIAL FORM
+ '\ufee7' # 0x00e6 -> ARABIC LETTER NOON INITIAL FORM
+ '\ufeeb' # 0x00e7 -> ARABIC LETTER HEH INITIAL FORM
+ '\ufeed' # 0x00e8 -> ARABIC LETTER WAW ISOLATED FORM
+ '\ufeef' # 0x00e9 -> ARABIC LETTER ALEF MAKSURA ISOLATED FORM
+ '\ufef3' # 0x00ea -> ARABIC LETTER YEH INITIAL FORM
+ '\ufebd' # 0x00eb -> ARABIC LETTER DAD ISOLATED FORM
+ '\ufecc' # 0x00ec -> ARABIC LETTER AIN MEDIAL FORM
+ '\ufece' # 0x00ed -> ARABIC LETTER GHAIN FINAL FORM
+ '\ufecd' # 0x00ee -> ARABIC LETTER GHAIN ISOLATED FORM
+ '\ufee1' # 0x00ef -> ARABIC LETTER MEEM ISOLATED FORM
+ '\ufe7d' # 0x00f0 -> ARABIC SHADDA MEDIAL FORM
+ '\u0651' # 0x00f1 -> ARABIC SHADDAH
+ '\ufee5' # 0x00f2 -> ARABIC LETTER NOON ISOLATED FORM
+ '\ufee9' # 0x00f3 -> ARABIC LETTER HEH ISOLATED FORM
+ '\ufeec' # 0x00f4 -> ARABIC LETTER HEH MEDIAL FORM
+ '\ufef0' # 0x00f5 -> ARABIC LETTER ALEF MAKSURA FINAL FORM
+ '\ufef2' # 0x00f6 -> ARABIC LETTER YEH FINAL FORM
+ '\ufed0' # 0x00f7 -> ARABIC LETTER GHAIN MEDIAL FORM
+ '\ufed5' # 0x00f8 -> ARABIC LETTER QAF ISOLATED FORM
+ '\ufef5' # 0x00f9 -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM
+ '\ufef6' # 0x00fa -> ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE FINAL FORM
+ '\ufedd' # 0x00fb -> ARABIC LETTER LAM ISOLATED FORM
+ '\ufed9' # 0x00fc -> ARABIC LETTER KAF ISOLATED FORM
+ '\ufef1' # 0x00fd -> ARABIC LETTER YEH ISOLATED FORM
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\ufffe' # 0x00ff -> UNDEFINED
)
### Encoding Map
diff --git a/Lib/encodings/cp865.py b/Lib/encodings/cp865.py
index e9f45f1b508..6726cf3f9ed 100644
--- a/Lib/encodings/cp865.py
+++ b/Lib/encodings/cp865.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
- u'\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
- u'\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
- u'\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
- u'\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
- u'\xa3' # 0x009c -> POUND SIGN
- u'\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u20a7' # 0x009e -> PESETA SIGN
- u'\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
- u'\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
- u'\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
- u'\xbf' # 0x00a8 -> INVERTED QUESTION MARK
- u'\u2310' # 0x00a9 -> REVERSED NOT SIGN
- u'\xac' # 0x00aa -> NOT SIGN
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
- u'\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xa4' # 0x00af -> CURRENCY SIGN
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
- u'\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
- u'\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
- u'\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
- u'\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
- u'\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
- u'\xb5' # 0x00e6 -> MICRO SIGN
- u'\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
- u'\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
- u'\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
- u'\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
- u'\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
- u'\u221e' # 0x00ec -> INFINITY
- u'\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
- u'\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
- u'\u2229' # 0x00ef -> INTERSECTION
- u'\u2261' # 0x00f0 -> IDENTICAL TO
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
- u'\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
- u'\u2320' # 0x00f4 -> TOP HALF INTEGRAL
- u'\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
- u'\xf7' # 0x00f6 -> DIVISION SIGN
- u'\u2248' # 0x00f7 -> ALMOST EQUAL TO
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
- u'\xb2' # 0x00fd -> SUPERSCRIPT TWO
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\xc7' # 0x0080 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xfc' # 0x0081 -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xe9' # 0x0082 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe2' # 0x0083 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x0084 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe0' # 0x0085 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe5' # 0x0086 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x0087 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xea' # 0x0088 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0089 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xe8' # 0x008a -> LATIN SMALL LETTER E WITH GRAVE
+ '\xef' # 0x008b -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xee' # 0x008c -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xec' # 0x008d -> LATIN SMALL LETTER I WITH GRAVE
+ '\xc4' # 0x008e -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x008f -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc9' # 0x0090 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xe6' # 0x0091 -> LATIN SMALL LIGATURE AE
+ '\xc6' # 0x0092 -> LATIN CAPITAL LIGATURE AE
+ '\xf4' # 0x0093 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x0094 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf2' # 0x0095 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xfb' # 0x0096 -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xf9' # 0x0097 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xff' # 0x0098 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\xd6' # 0x0099 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x009a -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xf8' # 0x009b -> LATIN SMALL LETTER O WITH STROKE
+ '\xa3' # 0x009c -> POUND SIGN
+ '\xd8' # 0x009d -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u20a7' # 0x009e -> PESETA SIGN
+ '\u0192' # 0x009f -> LATIN SMALL LETTER F WITH HOOK
+ '\xe1' # 0x00a0 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xed' # 0x00a1 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xf3' # 0x00a2 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xfa' # 0x00a3 -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf1' # 0x00a4 -> LATIN SMALL LETTER N WITH TILDE
+ '\xd1' # 0x00a5 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xaa' # 0x00a6 -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0x00a7 -> MASCULINE ORDINAL INDICATOR
+ '\xbf' # 0x00a8 -> INVERTED QUESTION MARK
+ '\u2310' # 0x00a9 -> REVERSED NOT SIGN
+ '\xac' # 0x00aa -> NOT SIGN
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\xbc' # 0x00ac -> VULGAR FRACTION ONE QUARTER
+ '\xa1' # 0x00ad -> INVERTED EXCLAMATION MARK
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xa4' # 0x00af -> CURRENCY SIGN
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b1' # 0x00e0 -> GREEK SMALL LETTER ALPHA
+ '\xdf' # 0x00e1 -> LATIN SMALL LETTER SHARP S
+ '\u0393' # 0x00e2 -> GREEK CAPITAL LETTER GAMMA
+ '\u03c0' # 0x00e3 -> GREEK SMALL LETTER PI
+ '\u03a3' # 0x00e4 -> GREEK CAPITAL LETTER SIGMA
+ '\u03c3' # 0x00e5 -> GREEK SMALL LETTER SIGMA
+ '\xb5' # 0x00e6 -> MICRO SIGN
+ '\u03c4' # 0x00e7 -> GREEK SMALL LETTER TAU
+ '\u03a6' # 0x00e8 -> GREEK CAPITAL LETTER PHI
+ '\u0398' # 0x00e9 -> GREEK CAPITAL LETTER THETA
+ '\u03a9' # 0x00ea -> GREEK CAPITAL LETTER OMEGA
+ '\u03b4' # 0x00eb -> GREEK SMALL LETTER DELTA
+ '\u221e' # 0x00ec -> INFINITY
+ '\u03c6' # 0x00ed -> GREEK SMALL LETTER PHI
+ '\u03b5' # 0x00ee -> GREEK SMALL LETTER EPSILON
+ '\u2229' # 0x00ef -> INTERSECTION
+ '\u2261' # 0x00f0 -> IDENTICAL TO
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u2265' # 0x00f2 -> GREATER-THAN OR EQUAL TO
+ '\u2264' # 0x00f3 -> LESS-THAN OR EQUAL TO
+ '\u2320' # 0x00f4 -> TOP HALF INTEGRAL
+ '\u2321' # 0x00f5 -> BOTTOM HALF INTEGRAL
+ '\xf7' # 0x00f6 -> DIVISION SIGN
+ '\u2248' # 0x00f7 -> ALMOST EQUAL TO
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u207f' # 0x00fc -> SUPERSCRIPT LATIN SMALL LETTER N
+ '\xb2' # 0x00fd -> SUPERSCRIPT TWO
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp866.py b/Lib/encodings/cp866.py
index 29cd85a3f10..bec7ae39fba 100644
--- a/Lib/encodings/cp866.py
+++ b/Lib/encodings/cp866.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\u0410' # 0x0080 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0x0081 -> CYRILLIC CAPITAL LETTER BE
- u'\u0412' # 0x0082 -> CYRILLIC CAPITAL LETTER VE
- u'\u0413' # 0x0083 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0414' # 0x0084 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0x0085 -> CYRILLIC CAPITAL LETTER IE
- u'\u0416' # 0x0086 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0417' # 0x0087 -> CYRILLIC CAPITAL LETTER ZE
- u'\u0418' # 0x0088 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0x0089 -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0x008a -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0x008b -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0x008c -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0x008d -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0x008e -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0x008f -> CYRILLIC CAPITAL LETTER PE
- u'\u0420' # 0x0090 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0x0091 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0x0092 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0x0093 -> CYRILLIC CAPITAL LETTER U
- u'\u0424' # 0x0094 -> CYRILLIC CAPITAL LETTER EF
- u'\u0425' # 0x0095 -> CYRILLIC CAPITAL LETTER HA
- u'\u0426' # 0x0096 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0427' # 0x0097 -> CYRILLIC CAPITAL LETTER CHE
- u'\u0428' # 0x0098 -> CYRILLIC CAPITAL LETTER SHA
- u'\u0429' # 0x0099 -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u042a' # 0x009a -> CYRILLIC CAPITAL LETTER HARD SIGN
- u'\u042b' # 0x009b -> CYRILLIC CAPITAL LETTER YERU
- u'\u042c' # 0x009c -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042d' # 0x009d -> CYRILLIC CAPITAL LETTER E
- u'\u042e' # 0x009e -> CYRILLIC CAPITAL LETTER YU
- u'\u042f' # 0x009f -> CYRILLIC CAPITAL LETTER YA
- u'\u0430' # 0x00a0 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0x00a1 -> CYRILLIC SMALL LETTER BE
- u'\u0432' # 0x00a2 -> CYRILLIC SMALL LETTER VE
- u'\u0433' # 0x00a3 -> CYRILLIC SMALL LETTER GHE
- u'\u0434' # 0x00a4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0x00a5 -> CYRILLIC SMALL LETTER IE
- u'\u0436' # 0x00a6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0437' # 0x00a7 -> CYRILLIC SMALL LETTER ZE
- u'\u0438' # 0x00a8 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0x00a9 -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0x00aa -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0x00ab -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0x00ac -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0x00ad -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0x00ae -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0x00af -> CYRILLIC SMALL LETTER PE
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u258c' # 0x00dd -> LEFT HALF BLOCK
- u'\u2590' # 0x00de -> RIGHT HALF BLOCK
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u0440' # 0x00e0 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0x00e1 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0x00e2 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0x00e3 -> CYRILLIC SMALL LETTER U
- u'\u0444' # 0x00e4 -> CYRILLIC SMALL LETTER EF
- u'\u0445' # 0x00e5 -> CYRILLIC SMALL LETTER HA
- u'\u0446' # 0x00e6 -> CYRILLIC SMALL LETTER TSE
- u'\u0447' # 0x00e7 -> CYRILLIC SMALL LETTER CHE
- u'\u0448' # 0x00e8 -> CYRILLIC SMALL LETTER SHA
- u'\u0449' # 0x00e9 -> CYRILLIC SMALL LETTER SHCHA
- u'\u044a' # 0x00ea -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u044b' # 0x00eb -> CYRILLIC SMALL LETTER YERU
- u'\u044c' # 0x00ec -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044d' # 0x00ed -> CYRILLIC SMALL LETTER E
- u'\u044e' # 0x00ee -> CYRILLIC SMALL LETTER YU
- u'\u044f' # 0x00ef -> CYRILLIC SMALL LETTER YA
- u'\u0401' # 0x00f0 -> CYRILLIC CAPITAL LETTER IO
- u'\u0451' # 0x00f1 -> CYRILLIC SMALL LETTER IO
- u'\u0404' # 0x00f2 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\u0454' # 0x00f3 -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\u0407' # 0x00f4 -> CYRILLIC CAPITAL LETTER YI
- u'\u0457' # 0x00f5 -> CYRILLIC SMALL LETTER YI
- u'\u040e' # 0x00f6 -> CYRILLIC CAPITAL LETTER SHORT U
- u'\u045e' # 0x00f7 -> CYRILLIC SMALL LETTER SHORT U
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\u2219' # 0x00f9 -> BULLET OPERATOR
- u'\xb7' # 0x00fa -> MIDDLE DOT
- u'\u221a' # 0x00fb -> SQUARE ROOT
- u'\u2116' # 0x00fc -> NUMERO SIGN
- u'\xa4' # 0x00fd -> CURRENCY SIGN
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\u0410' # 0x0080 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0x0081 -> CYRILLIC CAPITAL LETTER BE
+ '\u0412' # 0x0082 -> CYRILLIC CAPITAL LETTER VE
+ '\u0413' # 0x0083 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0414' # 0x0084 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0x0085 -> CYRILLIC CAPITAL LETTER IE
+ '\u0416' # 0x0086 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0417' # 0x0087 -> CYRILLIC CAPITAL LETTER ZE
+ '\u0418' # 0x0088 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0x0089 -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0x008a -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0x008b -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0x008c -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0x008d -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0x008e -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0x008f -> CYRILLIC CAPITAL LETTER PE
+ '\u0420' # 0x0090 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0x0091 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0x0092 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0x0093 -> CYRILLIC CAPITAL LETTER U
+ '\u0424' # 0x0094 -> CYRILLIC CAPITAL LETTER EF
+ '\u0425' # 0x0095 -> CYRILLIC CAPITAL LETTER HA
+ '\u0426' # 0x0096 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0427' # 0x0097 -> CYRILLIC CAPITAL LETTER CHE
+ '\u0428' # 0x0098 -> CYRILLIC CAPITAL LETTER SHA
+ '\u0429' # 0x0099 -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u042a' # 0x009a -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\u042b' # 0x009b -> CYRILLIC CAPITAL LETTER YERU
+ '\u042c' # 0x009c -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042d' # 0x009d -> CYRILLIC CAPITAL LETTER E
+ '\u042e' # 0x009e -> CYRILLIC CAPITAL LETTER YU
+ '\u042f' # 0x009f -> CYRILLIC CAPITAL LETTER YA
+ '\u0430' # 0x00a0 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0x00a1 -> CYRILLIC SMALL LETTER BE
+ '\u0432' # 0x00a2 -> CYRILLIC SMALL LETTER VE
+ '\u0433' # 0x00a3 -> CYRILLIC SMALL LETTER GHE
+ '\u0434' # 0x00a4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0x00a5 -> CYRILLIC SMALL LETTER IE
+ '\u0436' # 0x00a6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0437' # 0x00a7 -> CYRILLIC SMALL LETTER ZE
+ '\u0438' # 0x00a8 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0x00a9 -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0x00aa -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0x00ab -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0x00ac -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0x00ad -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0x00ae -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0x00af -> CYRILLIC SMALL LETTER PE
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u2561' # 0x00b5 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u2562' # 0x00b6 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2556' # 0x00b7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2555' # 0x00b8 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255c' # 0x00bd -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255b' # 0x00be -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u255e' # 0x00c6 -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0x00c7 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u2567' # 0x00cf -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0x00d0 -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2564' # 0x00d1 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0x00d2 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2559' # 0x00d3 -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u2558' # 0x00d4 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2552' # 0x00d5 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u2553' # 0x00d6 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u256b' # 0x00d7 -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256a' # 0x00d8 -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u258c' # 0x00dd -> LEFT HALF BLOCK
+ '\u2590' # 0x00de -> RIGHT HALF BLOCK
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u0440' # 0x00e0 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0x00e1 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0x00e2 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0x00e3 -> CYRILLIC SMALL LETTER U
+ '\u0444' # 0x00e4 -> CYRILLIC SMALL LETTER EF
+ '\u0445' # 0x00e5 -> CYRILLIC SMALL LETTER HA
+ '\u0446' # 0x00e6 -> CYRILLIC SMALL LETTER TSE
+ '\u0447' # 0x00e7 -> CYRILLIC SMALL LETTER CHE
+ '\u0448' # 0x00e8 -> CYRILLIC SMALL LETTER SHA
+ '\u0449' # 0x00e9 -> CYRILLIC SMALL LETTER SHCHA
+ '\u044a' # 0x00ea -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u044b' # 0x00eb -> CYRILLIC SMALL LETTER YERU
+ '\u044c' # 0x00ec -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044d' # 0x00ed -> CYRILLIC SMALL LETTER E
+ '\u044e' # 0x00ee -> CYRILLIC SMALL LETTER YU
+ '\u044f' # 0x00ef -> CYRILLIC SMALL LETTER YA
+ '\u0401' # 0x00f0 -> CYRILLIC CAPITAL LETTER IO
+ '\u0451' # 0x00f1 -> CYRILLIC SMALL LETTER IO
+ '\u0404' # 0x00f2 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\u0454' # 0x00f3 -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\u0407' # 0x00f4 -> CYRILLIC CAPITAL LETTER YI
+ '\u0457' # 0x00f5 -> CYRILLIC SMALL LETTER YI
+ '\u040e' # 0x00f6 -> CYRILLIC CAPITAL LETTER SHORT U
+ '\u045e' # 0x00f7 -> CYRILLIC SMALL LETTER SHORT U
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\u2219' # 0x00f9 -> BULLET OPERATOR
+ '\xb7' # 0x00fa -> MIDDLE DOT
+ '\u221a' # 0x00fb -> SQUARE ROOT
+ '\u2116' # 0x00fc -> NUMERO SIGN
+ '\xa4' # 0x00fd -> CURRENCY SIGN
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp869.py b/Lib/encodings/cp869.py
index b4dc99bf254..8d8a29b175c 100644
--- a/Lib/encodings/cp869.py
+++ b/Lib/encodings/cp869.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> NULL
- u'\x01' # 0x0001 -> START OF HEADING
- u'\x02' # 0x0002 -> START OF TEXT
- u'\x03' # 0x0003 -> END OF TEXT
- u'\x04' # 0x0004 -> END OF TRANSMISSION
- u'\x05' # 0x0005 -> ENQUIRY
- u'\x06' # 0x0006 -> ACKNOWLEDGE
- u'\x07' # 0x0007 -> BELL
- u'\x08' # 0x0008 -> BACKSPACE
- u'\t' # 0x0009 -> HORIZONTAL TABULATION
- u'\n' # 0x000a -> LINE FEED
- u'\x0b' # 0x000b -> VERTICAL TABULATION
- u'\x0c' # 0x000c -> FORM FEED
- u'\r' # 0x000d -> CARRIAGE RETURN
- u'\x0e' # 0x000e -> SHIFT OUT
- u'\x0f' # 0x000f -> SHIFT IN
- u'\x10' # 0x0010 -> DATA LINK ESCAPE
- u'\x11' # 0x0011 -> DEVICE CONTROL ONE
- u'\x12' # 0x0012 -> DEVICE CONTROL TWO
- u'\x13' # 0x0013 -> DEVICE CONTROL THREE
- u'\x14' # 0x0014 -> DEVICE CONTROL FOUR
- u'\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x0016 -> SYNCHRONOUS IDLE
- u'\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x0018 -> CANCEL
- u'\x19' # 0x0019 -> END OF MEDIUM
- u'\x1a' # 0x001a -> SUBSTITUTE
- u'\x1b' # 0x001b -> ESCAPE
- u'\x1c' # 0x001c -> FILE SEPARATOR
- u'\x1d' # 0x001d -> GROUP SEPARATOR
- u'\x1e' # 0x001e -> RECORD SEPARATOR
- u'\x1f' # 0x001f -> UNIT SEPARATOR
- u' ' # 0x0020 -> SPACE
- u'!' # 0x0021 -> EXCLAMATION MARK
- u'"' # 0x0022 -> QUOTATION MARK
- u'#' # 0x0023 -> NUMBER SIGN
- u'$' # 0x0024 -> DOLLAR SIGN
- u'%' # 0x0025 -> PERCENT SIGN
- u'&' # 0x0026 -> AMPERSAND
- u"'" # 0x0027 -> APOSTROPHE
- u'(' # 0x0028 -> LEFT PARENTHESIS
- u')' # 0x0029 -> RIGHT PARENTHESIS
- u'*' # 0x002a -> ASTERISK
- u'+' # 0x002b -> PLUS SIGN
- u',' # 0x002c -> COMMA
- u'-' # 0x002d -> HYPHEN-MINUS
- u'.' # 0x002e -> FULL STOP
- u'/' # 0x002f -> SOLIDUS
- u'0' # 0x0030 -> DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE
- u':' # 0x003a -> COLON
- u';' # 0x003b -> SEMICOLON
- u'<' # 0x003c -> LESS-THAN SIGN
- u'=' # 0x003d -> EQUALS SIGN
- u'>' # 0x003e -> GREATER-THAN SIGN
- u'?' # 0x003f -> QUESTION MARK
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET
- u'\\' # 0x005c -> REVERSE SOLIDUS
- u']' # 0x005d -> RIGHT SQUARE BRACKET
- u'^' # 0x005e -> CIRCUMFLEX ACCENT
- u'_' # 0x005f -> LOW LINE
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET
- u'|' # 0x007c -> VERTICAL LINE
- u'}' # 0x007d -> RIGHT CURLY BRACKET
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> DELETE
- u'\ufffe' # 0x0080 -> UNDEFINED
- u'\ufffe' # 0x0081 -> UNDEFINED
- u'\ufffe' # 0x0082 -> UNDEFINED
- u'\ufffe' # 0x0083 -> UNDEFINED
- u'\ufffe' # 0x0084 -> UNDEFINED
- u'\ufffe' # 0x0085 -> UNDEFINED
- u'\u0386' # 0x0086 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\ufffe' # 0x0087 -> UNDEFINED
- u'\xb7' # 0x0088 -> MIDDLE DOT
- u'\xac' # 0x0089 -> NOT SIGN
- u'\xa6' # 0x008a -> BROKEN BAR
- u'\u2018' # 0x008b -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x008c -> RIGHT SINGLE QUOTATION MARK
- u'\u0388' # 0x008d -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u2015' # 0x008e -> HORIZONTAL BAR
- u'\u0389' # 0x008f -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\u038a' # 0x0090 -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\u03aa' # 0x0091 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\u038c' # 0x0092 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\ufffe' # 0x0093 -> UNDEFINED
- u'\ufffe' # 0x0094 -> UNDEFINED
- u'\u038e' # 0x0095 -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u03ab' # 0x0096 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'\xa9' # 0x0097 -> COPYRIGHT SIGN
- u'\u038f' # 0x0098 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'\xb2' # 0x0099 -> SUPERSCRIPT TWO
- u'\xb3' # 0x009a -> SUPERSCRIPT THREE
- u'\u03ac' # 0x009b -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\xa3' # 0x009c -> POUND SIGN
- u'\u03ad' # 0x009d -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0x009e -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03af' # 0x009f -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03ca' # 0x00a0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u0390' # 0x00a1 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
- u'\u03cc' # 0x00a2 -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u03cd' # 0x00a3 -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u0391' # 0x00a4 -> GREEK CAPITAL LETTER ALPHA
- u'\u0392' # 0x00a5 -> GREEK CAPITAL LETTER BETA
- u'\u0393' # 0x00a6 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0x00a7 -> GREEK CAPITAL LETTER DELTA
- u'\u0395' # 0x00a8 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0x00a9 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0x00aa -> GREEK CAPITAL LETTER ETA
- u'\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
- u'\u0398' # 0x00ac -> GREEK CAPITAL LETTER THETA
- u'\u0399' # 0x00ad -> GREEK CAPITAL LETTER IOTA
- u'\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2591' # 0x00b0 -> LIGHT SHADE
- u'\u2592' # 0x00b1 -> MEDIUM SHADE
- u'\u2593' # 0x00b2 -> DARK SHADE
- u'\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u039a' # 0x00b5 -> GREEK CAPITAL LETTER KAPPA
- u'\u039b' # 0x00b6 -> GREEK CAPITAL LETTER LAMDA
- u'\u039c' # 0x00b7 -> GREEK CAPITAL LETTER MU
- u'\u039d' # 0x00b8 -> GREEK CAPITAL LETTER NU
- u'\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u039e' # 0x00bd -> GREEK CAPITAL LETTER XI
- u'\u039f' # 0x00be -> GREEK CAPITAL LETTER OMICRON
- u'\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u03a0' # 0x00c6 -> GREEK CAPITAL LETTER PI
- u'\u03a1' # 0x00c7 -> GREEK CAPITAL LETTER RHO
- u'\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\u03a3' # 0x00cf -> GREEK CAPITAL LETTER SIGMA
- u'\u03a4' # 0x00d0 -> GREEK CAPITAL LETTER TAU
- u'\u03a5' # 0x00d1 -> GREEK CAPITAL LETTER UPSILON
- u'\u03a6' # 0x00d2 -> GREEK CAPITAL LETTER PHI
- u'\u03a7' # 0x00d3 -> GREEK CAPITAL LETTER CHI
- u'\u03a8' # 0x00d4 -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0x00d5 -> GREEK CAPITAL LETTER OMEGA
- u'\u03b1' # 0x00d6 -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0x00d7 -> GREEK SMALL LETTER BETA
- u'\u03b3' # 0x00d8 -> GREEK SMALL LETTER GAMMA
- u'\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2588' # 0x00db -> FULL BLOCK
- u'\u2584' # 0x00dc -> LOWER HALF BLOCK
- u'\u03b4' # 0x00dd -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0x00de -> GREEK SMALL LETTER EPSILON
- u'\u2580' # 0x00df -> UPPER HALF BLOCK
- u'\u03b6' # 0x00e0 -> GREEK SMALL LETTER ZETA
- u'\u03b7' # 0x00e1 -> GREEK SMALL LETTER ETA
- u'\u03b8' # 0x00e2 -> GREEK SMALL LETTER THETA
- u'\u03b9' # 0x00e3 -> GREEK SMALL LETTER IOTA
- u'\u03ba' # 0x00e4 -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0x00e5 -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0x00e6 -> GREEK SMALL LETTER MU
- u'\u03bd' # 0x00e7 -> GREEK SMALL LETTER NU
- u'\u03be' # 0x00e8 -> GREEK SMALL LETTER XI
- u'\u03bf' # 0x00e9 -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0x00ea -> GREEK SMALL LETTER PI
- u'\u03c1' # 0x00eb -> GREEK SMALL LETTER RHO
- u'\u03c3' # 0x00ec -> GREEK SMALL LETTER SIGMA
- u'\u03c2' # 0x00ed -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c4' # 0x00ee -> GREEK SMALL LETTER TAU
- u'\u0384' # 0x00ef -> GREEK TONOS
- u'\xad' # 0x00f0 -> SOFT HYPHEN
- u'\xb1' # 0x00f1 -> PLUS-MINUS SIGN
- u'\u03c5' # 0x00f2 -> GREEK SMALL LETTER UPSILON
- u'\u03c6' # 0x00f3 -> GREEK SMALL LETTER PHI
- u'\u03c7' # 0x00f4 -> GREEK SMALL LETTER CHI
- u'\xa7' # 0x00f5 -> SECTION SIGN
- u'\u03c8' # 0x00f6 -> GREEK SMALL LETTER PSI
- u'\u0385' # 0x00f7 -> GREEK DIALYTIKA TONOS
- u'\xb0' # 0x00f8 -> DEGREE SIGN
- u'\xa8' # 0x00f9 -> DIAERESIS
- u'\u03c9' # 0x00fa -> GREEK SMALL LETTER OMEGA
- u'\u03cb' # 0x00fb -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u03b0' # 0x00fc -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
- u'\u03ce' # 0x00fd -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\u25a0' # 0x00fe -> BLACK SQUARE
- u'\xa0' # 0x00ff -> NO-BREAK SPACE
+ '\x00' # 0x0000 -> NULL
+ '\x01' # 0x0001 -> START OF HEADING
+ '\x02' # 0x0002 -> START OF TEXT
+ '\x03' # 0x0003 -> END OF TEXT
+ '\x04' # 0x0004 -> END OF TRANSMISSION
+ '\x05' # 0x0005 -> ENQUIRY
+ '\x06' # 0x0006 -> ACKNOWLEDGE
+ '\x07' # 0x0007 -> BELL
+ '\x08' # 0x0008 -> BACKSPACE
+ '\t' # 0x0009 -> HORIZONTAL TABULATION
+ '\n' # 0x000a -> LINE FEED
+ '\x0b' # 0x000b -> VERTICAL TABULATION
+ '\x0c' # 0x000c -> FORM FEED
+ '\r' # 0x000d -> CARRIAGE RETURN
+ '\x0e' # 0x000e -> SHIFT OUT
+ '\x0f' # 0x000f -> SHIFT IN
+ '\x10' # 0x0010 -> DATA LINK ESCAPE
+ '\x11' # 0x0011 -> DEVICE CONTROL ONE
+ '\x12' # 0x0012 -> DEVICE CONTROL TWO
+ '\x13' # 0x0013 -> DEVICE CONTROL THREE
+ '\x14' # 0x0014 -> DEVICE CONTROL FOUR
+ '\x15' # 0x0015 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x0016 -> SYNCHRONOUS IDLE
+ '\x17' # 0x0017 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x0018 -> CANCEL
+ '\x19' # 0x0019 -> END OF MEDIUM
+ '\x1a' # 0x001a -> SUBSTITUTE
+ '\x1b' # 0x001b -> ESCAPE
+ '\x1c' # 0x001c -> FILE SEPARATOR
+ '\x1d' # 0x001d -> GROUP SEPARATOR
+ '\x1e' # 0x001e -> RECORD SEPARATOR
+ '\x1f' # 0x001f -> UNIT SEPARATOR
+ ' ' # 0x0020 -> SPACE
+ '!' # 0x0021 -> EXCLAMATION MARK
+ '"' # 0x0022 -> QUOTATION MARK
+ '#' # 0x0023 -> NUMBER SIGN
+ '$' # 0x0024 -> DOLLAR SIGN
+ '%' # 0x0025 -> PERCENT SIGN
+ '&' # 0x0026 -> AMPERSAND
+ "'" # 0x0027 -> APOSTROPHE
+ '(' # 0x0028 -> LEFT PARENTHESIS
+ ')' # 0x0029 -> RIGHT PARENTHESIS
+ '*' # 0x002a -> ASTERISK
+ '+' # 0x002b -> PLUS SIGN
+ ',' # 0x002c -> COMMA
+ '-' # 0x002d -> HYPHEN-MINUS
+ '.' # 0x002e -> FULL STOP
+ '/' # 0x002f -> SOLIDUS
+ '0' # 0x0030 -> DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE
+ ':' # 0x003a -> COLON
+ ';' # 0x003b -> SEMICOLON
+ '<' # 0x003c -> LESS-THAN SIGN
+ '=' # 0x003d -> EQUALS SIGN
+ '>' # 0x003e -> GREATER-THAN SIGN
+ '?' # 0x003f -> QUESTION MARK
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET
+ '\\' # 0x005c -> REVERSE SOLIDUS
+ ']' # 0x005d -> RIGHT SQUARE BRACKET
+ '^' # 0x005e -> CIRCUMFLEX ACCENT
+ '_' # 0x005f -> LOW LINE
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET
+ '|' # 0x007c -> VERTICAL LINE
+ '}' # 0x007d -> RIGHT CURLY BRACKET
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> DELETE
+ '\ufffe' # 0x0080 -> UNDEFINED
+ '\ufffe' # 0x0081 -> UNDEFINED
+ '\ufffe' # 0x0082 -> UNDEFINED
+ '\ufffe' # 0x0083 -> UNDEFINED
+ '\ufffe' # 0x0084 -> UNDEFINED
+ '\ufffe' # 0x0085 -> UNDEFINED
+ '\u0386' # 0x0086 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\ufffe' # 0x0087 -> UNDEFINED
+ '\xb7' # 0x0088 -> MIDDLE DOT
+ '\xac' # 0x0089 -> NOT SIGN
+ '\xa6' # 0x008a -> BROKEN BAR
+ '\u2018' # 0x008b -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x008c -> RIGHT SINGLE QUOTATION MARK
+ '\u0388' # 0x008d -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u2015' # 0x008e -> HORIZONTAL BAR
+ '\u0389' # 0x008f -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\u038a' # 0x0090 -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\u03aa' # 0x0091 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\u038c' # 0x0092 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\ufffe' # 0x0093 -> UNDEFINED
+ '\ufffe' # 0x0094 -> UNDEFINED
+ '\u038e' # 0x0095 -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u03ab' # 0x0096 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '\xa9' # 0x0097 -> COPYRIGHT SIGN
+ '\u038f' # 0x0098 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '\xb2' # 0x0099 -> SUPERSCRIPT TWO
+ '\xb3' # 0x009a -> SUPERSCRIPT THREE
+ '\u03ac' # 0x009b -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\xa3' # 0x009c -> POUND SIGN
+ '\u03ad' # 0x009d -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0x009e -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03af' # 0x009f -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03ca' # 0x00a0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u0390' # 0x00a1 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+ '\u03cc' # 0x00a2 -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u03cd' # 0x00a3 -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u0391' # 0x00a4 -> GREEK CAPITAL LETTER ALPHA
+ '\u0392' # 0x00a5 -> GREEK CAPITAL LETTER BETA
+ '\u0393' # 0x00a6 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0x00a7 -> GREEK CAPITAL LETTER DELTA
+ '\u0395' # 0x00a8 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0x00a9 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0x00aa -> GREEK CAPITAL LETTER ETA
+ '\xbd' # 0x00ab -> VULGAR FRACTION ONE HALF
+ '\u0398' # 0x00ac -> GREEK CAPITAL LETTER THETA
+ '\u0399' # 0x00ad -> GREEK CAPITAL LETTER IOTA
+ '\xab' # 0x00ae -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0x00af -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2591' # 0x00b0 -> LIGHT SHADE
+ '\u2592' # 0x00b1 -> MEDIUM SHADE
+ '\u2593' # 0x00b2 -> DARK SHADE
+ '\u2502' # 0x00b3 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u2524' # 0x00b4 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u039a' # 0x00b5 -> GREEK CAPITAL LETTER KAPPA
+ '\u039b' # 0x00b6 -> GREEK CAPITAL LETTER LAMDA
+ '\u039c' # 0x00b7 -> GREEK CAPITAL LETTER MU
+ '\u039d' # 0x00b8 -> GREEK CAPITAL LETTER NU
+ '\u2563' # 0x00b9 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2551' # 0x00ba -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2557' # 0x00bb -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u255d' # 0x00bc -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u039e' # 0x00bd -> GREEK CAPITAL LETTER XI
+ '\u039f' # 0x00be -> GREEK CAPITAL LETTER OMICRON
+ '\u2510' # 0x00bf -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x00c0 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2534' # 0x00c1 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u252c' # 0x00c2 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u251c' # 0x00c3 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2500' # 0x00c4 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u253c' # 0x00c5 -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u03a0' # 0x00c6 -> GREEK CAPITAL LETTER PI
+ '\u03a1' # 0x00c7 -> GREEK CAPITAL LETTER RHO
+ '\u255a' # 0x00c8 -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u2554' # 0x00c9 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2569' # 0x00ca -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u2566' # 0x00cb -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2560' # 0x00cc -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2550' # 0x00cd -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u256c' # 0x00ce -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\u03a3' # 0x00cf -> GREEK CAPITAL LETTER SIGMA
+ '\u03a4' # 0x00d0 -> GREEK CAPITAL LETTER TAU
+ '\u03a5' # 0x00d1 -> GREEK CAPITAL LETTER UPSILON
+ '\u03a6' # 0x00d2 -> GREEK CAPITAL LETTER PHI
+ '\u03a7' # 0x00d3 -> GREEK CAPITAL LETTER CHI
+ '\u03a8' # 0x00d4 -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0x00d5 -> GREEK CAPITAL LETTER OMEGA
+ '\u03b1' # 0x00d6 -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0x00d7 -> GREEK SMALL LETTER BETA
+ '\u03b3' # 0x00d8 -> GREEK SMALL LETTER GAMMA
+ '\u2518' # 0x00d9 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u250c' # 0x00da -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2588' # 0x00db -> FULL BLOCK
+ '\u2584' # 0x00dc -> LOWER HALF BLOCK
+ '\u03b4' # 0x00dd -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0x00de -> GREEK SMALL LETTER EPSILON
+ '\u2580' # 0x00df -> UPPER HALF BLOCK
+ '\u03b6' # 0x00e0 -> GREEK SMALL LETTER ZETA
+ '\u03b7' # 0x00e1 -> GREEK SMALL LETTER ETA
+ '\u03b8' # 0x00e2 -> GREEK SMALL LETTER THETA
+ '\u03b9' # 0x00e3 -> GREEK SMALL LETTER IOTA
+ '\u03ba' # 0x00e4 -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0x00e5 -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0x00e6 -> GREEK SMALL LETTER MU
+ '\u03bd' # 0x00e7 -> GREEK SMALL LETTER NU
+ '\u03be' # 0x00e8 -> GREEK SMALL LETTER XI
+ '\u03bf' # 0x00e9 -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0x00ea -> GREEK SMALL LETTER PI
+ '\u03c1' # 0x00eb -> GREEK SMALL LETTER RHO
+ '\u03c3' # 0x00ec -> GREEK SMALL LETTER SIGMA
+ '\u03c2' # 0x00ed -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c4' # 0x00ee -> GREEK SMALL LETTER TAU
+ '\u0384' # 0x00ef -> GREEK TONOS
+ '\xad' # 0x00f0 -> SOFT HYPHEN
+ '\xb1' # 0x00f1 -> PLUS-MINUS SIGN
+ '\u03c5' # 0x00f2 -> GREEK SMALL LETTER UPSILON
+ '\u03c6' # 0x00f3 -> GREEK SMALL LETTER PHI
+ '\u03c7' # 0x00f4 -> GREEK SMALL LETTER CHI
+ '\xa7' # 0x00f5 -> SECTION SIGN
+ '\u03c8' # 0x00f6 -> GREEK SMALL LETTER PSI
+ '\u0385' # 0x00f7 -> GREEK DIALYTIKA TONOS
+ '\xb0' # 0x00f8 -> DEGREE SIGN
+ '\xa8' # 0x00f9 -> DIAERESIS
+ '\u03c9' # 0x00fa -> GREEK SMALL LETTER OMEGA
+ '\u03cb' # 0x00fb -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u03b0' # 0x00fc -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+ '\u03ce' # 0x00fd -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\u25a0' # 0x00fe -> BLACK SQUARE
+ '\xa0' # 0x00ff -> NO-BREAK SPACE
)
### Encoding Map
diff --git a/Lib/encodings/cp874.py b/Lib/encodings/cp874.py
index 6110f46e5b5..59bfcbc98ab 100644
--- a/Lib/encodings/cp874.py
+++ b/Lib/encodings/cp874.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u20ac' # 0x80 -> EURO SIGN
- u'\ufffe' # 0x81 -> UNDEFINED
- u'\ufffe' # 0x82 -> UNDEFINED
- u'\ufffe' # 0x83 -> UNDEFINED
- u'\ufffe' # 0x84 -> UNDEFINED
- u'\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
- u'\ufffe' # 0x86 -> UNDEFINED
- u'\ufffe' # 0x87 -> UNDEFINED
- u'\ufffe' # 0x88 -> UNDEFINED
- u'\ufffe' # 0x89 -> UNDEFINED
- u'\ufffe' # 0x8A -> UNDEFINED
- u'\ufffe' # 0x8B -> UNDEFINED
- u'\ufffe' # 0x8C -> UNDEFINED
- u'\ufffe' # 0x8D -> UNDEFINED
- u'\ufffe' # 0x8E -> UNDEFINED
- u'\ufffe' # 0x8F -> UNDEFINED
- u'\ufffe' # 0x90 -> UNDEFINED
- u'\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
- u'\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2022' # 0x95 -> BULLET
- u'\u2013' # 0x96 -> EN DASH
- u'\u2014' # 0x97 -> EM DASH
- u'\ufffe' # 0x98 -> UNDEFINED
- u'\ufffe' # 0x99 -> UNDEFINED
- u'\ufffe' # 0x9A -> UNDEFINED
- u'\ufffe' # 0x9B -> UNDEFINED
- u'\ufffe' # 0x9C -> UNDEFINED
- u'\ufffe' # 0x9D -> UNDEFINED
- u'\ufffe' # 0x9E -> UNDEFINED
- u'\ufffe' # 0x9F -> UNDEFINED
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
- u'\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
- u'\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
- u'\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
- u'\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
- u'\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
- u'\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
- u'\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
- u'\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
- u'\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
- u'\u0e0b' # 0xAB -> THAI CHARACTER SO SO
- u'\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
- u'\u0e0d' # 0xAD -> THAI CHARACTER YO YING
- u'\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
- u'\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
- u'\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
- u'\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
- u'\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
- u'\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
- u'\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
- u'\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
- u'\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
- u'\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
- u'\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
- u'\u0e19' # 0xB9 -> THAI CHARACTER NO NU
- u'\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
- u'\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
- u'\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
- u'\u0e1d' # 0xBD -> THAI CHARACTER FO FA
- u'\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
- u'\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
- u'\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
- u'\u0e21' # 0xC1 -> THAI CHARACTER MO MA
- u'\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
- u'\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
- u'\u0e24' # 0xC4 -> THAI CHARACTER RU
- u'\u0e25' # 0xC5 -> THAI CHARACTER LO LING
- u'\u0e26' # 0xC6 -> THAI CHARACTER LU
- u'\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
- u'\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
- u'\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
- u'\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
- u'\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
- u'\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
- u'\u0e2d' # 0xCD -> THAI CHARACTER O ANG
- u'\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
- u'\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
- u'\u0e30' # 0xD0 -> THAI CHARACTER SARA A
- u'\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
- u'\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
- u'\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
- u'\u0e34' # 0xD4 -> THAI CHARACTER SARA I
- u'\u0e35' # 0xD5 -> THAI CHARACTER SARA II
- u'\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
- u'\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
- u'\u0e38' # 0xD8 -> THAI CHARACTER SARA U
- u'\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
- u'\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
- u'\ufffe' # 0xDB -> UNDEFINED
- u'\ufffe' # 0xDC -> UNDEFINED
- u'\ufffe' # 0xDD -> UNDEFINED
- u'\ufffe' # 0xDE -> UNDEFINED
- u'\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
- u'\u0e40' # 0xE0 -> THAI CHARACTER SARA E
- u'\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
- u'\u0e42' # 0xE2 -> THAI CHARACTER SARA O
- u'\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
- u'\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
- u'\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
- u'\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
- u'\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
- u'\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
- u'\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
- u'\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
- u'\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
- u'\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
- u'\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
- u'\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
- u'\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
- u'\u0e50' # 0xF0 -> THAI DIGIT ZERO
- u'\u0e51' # 0xF1 -> THAI DIGIT ONE
- u'\u0e52' # 0xF2 -> THAI DIGIT TWO
- u'\u0e53' # 0xF3 -> THAI DIGIT THREE
- u'\u0e54' # 0xF4 -> THAI DIGIT FOUR
- u'\u0e55' # 0xF5 -> THAI DIGIT FIVE
- u'\u0e56' # 0xF6 -> THAI DIGIT SIX
- u'\u0e57' # 0xF7 -> THAI DIGIT SEVEN
- u'\u0e58' # 0xF8 -> THAI DIGIT EIGHT
- u'\u0e59' # 0xF9 -> THAI DIGIT NINE
- u'\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
- u'\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
- u'\ufffe' # 0xFC -> UNDEFINED
- u'\ufffe' # 0xFD -> UNDEFINED
- u'\ufffe' # 0xFE -> UNDEFINED
- u'\ufffe' # 0xFF -> UNDEFINED
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u20ac' # 0x80 -> EURO SIGN
+ '\ufffe' # 0x81 -> UNDEFINED
+ '\ufffe' # 0x82 -> UNDEFINED
+ '\ufffe' # 0x83 -> UNDEFINED
+ '\ufffe' # 0x84 -> UNDEFINED
+ '\u2026' # 0x85 -> HORIZONTAL ELLIPSIS
+ '\ufffe' # 0x86 -> UNDEFINED
+ '\ufffe' # 0x87 -> UNDEFINED
+ '\ufffe' # 0x88 -> UNDEFINED
+ '\ufffe' # 0x89 -> UNDEFINED
+ '\ufffe' # 0x8A -> UNDEFINED
+ '\ufffe' # 0x8B -> UNDEFINED
+ '\ufffe' # 0x8C -> UNDEFINED
+ '\ufffe' # 0x8D -> UNDEFINED
+ '\ufffe' # 0x8E -> UNDEFINED
+ '\ufffe' # 0x8F -> UNDEFINED
+ '\ufffe' # 0x90 -> UNDEFINED
+ '\u2018' # 0x91 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0x92 -> RIGHT SINGLE QUOTATION MARK
+ '\u201c' # 0x93 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0x94 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2022' # 0x95 -> BULLET
+ '\u2013' # 0x96 -> EN DASH
+ '\u2014' # 0x97 -> EM DASH
+ '\ufffe' # 0x98 -> UNDEFINED
+ '\ufffe' # 0x99 -> UNDEFINED
+ '\ufffe' # 0x9A -> UNDEFINED
+ '\ufffe' # 0x9B -> UNDEFINED
+ '\ufffe' # 0x9C -> UNDEFINED
+ '\ufffe' # 0x9D -> UNDEFINED
+ '\ufffe' # 0x9E -> UNDEFINED
+ '\ufffe' # 0x9F -> UNDEFINED
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
+ '\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
+ '\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
+ '\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
+ '\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
+ '\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
+ '\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
+ '\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
+ '\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
+ '\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
+ '\u0e0b' # 0xAB -> THAI CHARACTER SO SO
+ '\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
+ '\u0e0d' # 0xAD -> THAI CHARACTER YO YING
+ '\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
+ '\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
+ '\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
+ '\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
+ '\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
+ '\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
+ '\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
+ '\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
+ '\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
+ '\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
+ '\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
+ '\u0e19' # 0xB9 -> THAI CHARACTER NO NU
+ '\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
+ '\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
+ '\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
+ '\u0e1d' # 0xBD -> THAI CHARACTER FO FA
+ '\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
+ '\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
+ '\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
+ '\u0e21' # 0xC1 -> THAI CHARACTER MO MA
+ '\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
+ '\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
+ '\u0e24' # 0xC4 -> THAI CHARACTER RU
+ '\u0e25' # 0xC5 -> THAI CHARACTER LO LING
+ '\u0e26' # 0xC6 -> THAI CHARACTER LU
+ '\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
+ '\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
+ '\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
+ '\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
+ '\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
+ '\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
+ '\u0e2d' # 0xCD -> THAI CHARACTER O ANG
+ '\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
+ '\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
+ '\u0e30' # 0xD0 -> THAI CHARACTER SARA A
+ '\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
+ '\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
+ '\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
+ '\u0e34' # 0xD4 -> THAI CHARACTER SARA I
+ '\u0e35' # 0xD5 -> THAI CHARACTER SARA II
+ '\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
+ '\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
+ '\u0e38' # 0xD8 -> THAI CHARACTER SARA U
+ '\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
+ '\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
+ '\ufffe' # 0xDB -> UNDEFINED
+ '\ufffe' # 0xDC -> UNDEFINED
+ '\ufffe' # 0xDD -> UNDEFINED
+ '\ufffe' # 0xDE -> UNDEFINED
+ '\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
+ '\u0e40' # 0xE0 -> THAI CHARACTER SARA E
+ '\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
+ '\u0e42' # 0xE2 -> THAI CHARACTER SARA O
+ '\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
+ '\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
+ '\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
+ '\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
+ '\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
+ '\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
+ '\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
+ '\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
+ '\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
+ '\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
+ '\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
+ '\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
+ '\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
+ '\u0e50' # 0xF0 -> THAI DIGIT ZERO
+ '\u0e51' # 0xF1 -> THAI DIGIT ONE
+ '\u0e52' # 0xF2 -> THAI DIGIT TWO
+ '\u0e53' # 0xF3 -> THAI DIGIT THREE
+ '\u0e54' # 0xF4 -> THAI DIGIT FOUR
+ '\u0e55' # 0xF5 -> THAI DIGIT FIVE
+ '\u0e56' # 0xF6 -> THAI DIGIT SIX
+ '\u0e57' # 0xF7 -> THAI DIGIT SEVEN
+ '\u0e58' # 0xF8 -> THAI DIGIT EIGHT
+ '\u0e59' # 0xF9 -> THAI DIGIT NINE
+ '\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
+ '\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
+ '\ufffe' # 0xFC -> UNDEFINED
+ '\ufffe' # 0xFD -> UNDEFINED
+ '\ufffe' # 0xFE -> UNDEFINED
+ '\ufffe' # 0xFF -> UNDEFINED
)
### Encoding table
diff --git a/Lib/encodings/cp875.py b/Lib/encodings/cp875.py
index 72b160b02f7..c25a5a43bc4 100644
--- a/Lib/encodings/cp875.py
+++ b/Lib/encodings/cp875.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x9c' # 0x04 -> CONTROL
- u'\t' # 0x05 -> HORIZONTAL TABULATION
- u'\x86' # 0x06 -> CONTROL
- u'\x7f' # 0x07 -> DELETE
- u'\x97' # 0x08 -> CONTROL
- u'\x8d' # 0x09 -> CONTROL
- u'\x8e' # 0x0A -> CONTROL
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x9d' # 0x14 -> CONTROL
- u'\x85' # 0x15 -> CONTROL
- u'\x08' # 0x16 -> BACKSPACE
- u'\x87' # 0x17 -> CONTROL
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x92' # 0x1A -> CONTROL
- u'\x8f' # 0x1B -> CONTROL
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u'\x80' # 0x20 -> CONTROL
- u'\x81' # 0x21 -> CONTROL
- u'\x82' # 0x22 -> CONTROL
- u'\x83' # 0x23 -> CONTROL
- u'\x84' # 0x24 -> CONTROL
- u'\n' # 0x25 -> LINE FEED
- u'\x17' # 0x26 -> END OF TRANSMISSION BLOCK
- u'\x1b' # 0x27 -> ESCAPE
- u'\x88' # 0x28 -> CONTROL
- u'\x89' # 0x29 -> CONTROL
- u'\x8a' # 0x2A -> CONTROL
- u'\x8b' # 0x2B -> CONTROL
- u'\x8c' # 0x2C -> CONTROL
- u'\x05' # 0x2D -> ENQUIRY
- u'\x06' # 0x2E -> ACKNOWLEDGE
- u'\x07' # 0x2F -> BELL
- u'\x90' # 0x30 -> CONTROL
- u'\x91' # 0x31 -> CONTROL
- u'\x16' # 0x32 -> SYNCHRONOUS IDLE
- u'\x93' # 0x33 -> CONTROL
- u'\x94' # 0x34 -> CONTROL
- u'\x95' # 0x35 -> CONTROL
- u'\x96' # 0x36 -> CONTROL
- u'\x04' # 0x37 -> END OF TRANSMISSION
- u'\x98' # 0x38 -> CONTROL
- u'\x99' # 0x39 -> CONTROL
- u'\x9a' # 0x3A -> CONTROL
- u'\x9b' # 0x3B -> CONTROL
- u'\x14' # 0x3C -> DEVICE CONTROL FOUR
- u'\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
- u'\x9e' # 0x3E -> CONTROL
- u'\x1a' # 0x3F -> SUBSTITUTE
- u' ' # 0x40 -> SPACE
- u'\u0391' # 0x41 -> GREEK CAPITAL LETTER ALPHA
- u'\u0392' # 0x42 -> GREEK CAPITAL LETTER BETA
- u'\u0393' # 0x43 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0x44 -> GREEK CAPITAL LETTER DELTA
- u'\u0395' # 0x45 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0x46 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0x47 -> GREEK CAPITAL LETTER ETA
- u'\u0398' # 0x48 -> GREEK CAPITAL LETTER THETA
- u'\u0399' # 0x49 -> GREEK CAPITAL LETTER IOTA
- u'[' # 0x4A -> LEFT SQUARE BRACKET
- u'.' # 0x4B -> FULL STOP
- u'<' # 0x4C -> LESS-THAN SIGN
- u'(' # 0x4D -> LEFT PARENTHESIS
- u'+' # 0x4E -> PLUS SIGN
- u'!' # 0x4F -> EXCLAMATION MARK
- u'&' # 0x50 -> AMPERSAND
- u'\u039a' # 0x51 -> GREEK CAPITAL LETTER KAPPA
- u'\u039b' # 0x52 -> GREEK CAPITAL LETTER LAMDA
- u'\u039c' # 0x53 -> GREEK CAPITAL LETTER MU
- u'\u039d' # 0x54 -> GREEK CAPITAL LETTER NU
- u'\u039e' # 0x55 -> GREEK CAPITAL LETTER XI
- u'\u039f' # 0x56 -> GREEK CAPITAL LETTER OMICRON
- u'\u03a0' # 0x57 -> GREEK CAPITAL LETTER PI
- u'\u03a1' # 0x58 -> GREEK CAPITAL LETTER RHO
- u'\u03a3' # 0x59 -> GREEK CAPITAL LETTER SIGMA
- u']' # 0x5A -> RIGHT SQUARE BRACKET
- u'$' # 0x5B -> DOLLAR SIGN
- u'*' # 0x5C -> ASTERISK
- u')' # 0x5D -> RIGHT PARENTHESIS
- u';' # 0x5E -> SEMICOLON
- u'^' # 0x5F -> CIRCUMFLEX ACCENT
- u'-' # 0x60 -> HYPHEN-MINUS
- u'/' # 0x61 -> SOLIDUS
- u'\u03a4' # 0x62 -> GREEK CAPITAL LETTER TAU
- u'\u03a5' # 0x63 -> GREEK CAPITAL LETTER UPSILON
- u'\u03a6' # 0x64 -> GREEK CAPITAL LETTER PHI
- u'\u03a7' # 0x65 -> GREEK CAPITAL LETTER CHI
- u'\u03a8' # 0x66 -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0x67 -> GREEK CAPITAL LETTER OMEGA
- u'\u03aa' # 0x68 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\u03ab' # 0x69 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'|' # 0x6A -> VERTICAL LINE
- u',' # 0x6B -> COMMA
- u'%' # 0x6C -> PERCENT SIGN
- u'_' # 0x6D -> LOW LINE
- u'>' # 0x6E -> GREATER-THAN SIGN
- u'?' # 0x6F -> QUESTION MARK
- u'\xa8' # 0x70 -> DIAERESIS
- u'\u0386' # 0x71 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\u0388' # 0x72 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u0389' # 0x73 -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\xa0' # 0x74 -> NO-BREAK SPACE
- u'\u038a' # 0x75 -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\u038c' # 0x76 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\u038e' # 0x77 -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u038f' # 0x78 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'`' # 0x79 -> GRAVE ACCENT
- u':' # 0x7A -> COLON
- u'#' # 0x7B -> NUMBER SIGN
- u'@' # 0x7C -> COMMERCIAL AT
- u"'" # 0x7D -> APOSTROPHE
- u'=' # 0x7E -> EQUALS SIGN
- u'"' # 0x7F -> QUOTATION MARK
- u'\u0385' # 0x80 -> GREEK DIALYTIKA TONOS
- u'a' # 0x81 -> LATIN SMALL LETTER A
- u'b' # 0x82 -> LATIN SMALL LETTER B
- u'c' # 0x83 -> LATIN SMALL LETTER C
- u'd' # 0x84 -> LATIN SMALL LETTER D
- u'e' # 0x85 -> LATIN SMALL LETTER E
- u'f' # 0x86 -> LATIN SMALL LETTER F
- u'g' # 0x87 -> LATIN SMALL LETTER G
- u'h' # 0x88 -> LATIN SMALL LETTER H
- u'i' # 0x89 -> LATIN SMALL LETTER I
- u'\u03b1' # 0x8A -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0x8B -> GREEK SMALL LETTER BETA
- u'\u03b3' # 0x8C -> GREEK SMALL LETTER GAMMA
- u'\u03b4' # 0x8D -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0x8E -> GREEK SMALL LETTER EPSILON
- u'\u03b6' # 0x8F -> GREEK SMALL LETTER ZETA
- u'\xb0' # 0x90 -> DEGREE SIGN
- u'j' # 0x91 -> LATIN SMALL LETTER J
- u'k' # 0x92 -> LATIN SMALL LETTER K
- u'l' # 0x93 -> LATIN SMALL LETTER L
- u'm' # 0x94 -> LATIN SMALL LETTER M
- u'n' # 0x95 -> LATIN SMALL LETTER N
- u'o' # 0x96 -> LATIN SMALL LETTER O
- u'p' # 0x97 -> LATIN SMALL LETTER P
- u'q' # 0x98 -> LATIN SMALL LETTER Q
- u'r' # 0x99 -> LATIN SMALL LETTER R
- u'\u03b7' # 0x9A -> GREEK SMALL LETTER ETA
- u'\u03b8' # 0x9B -> GREEK SMALL LETTER THETA
- u'\u03b9' # 0x9C -> GREEK SMALL LETTER IOTA
- u'\u03ba' # 0x9D -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0x9E -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0x9F -> GREEK SMALL LETTER MU
- u'\xb4' # 0xA0 -> ACUTE ACCENT
- u'~' # 0xA1 -> TILDE
- u's' # 0xA2 -> LATIN SMALL LETTER S
- u't' # 0xA3 -> LATIN SMALL LETTER T
- u'u' # 0xA4 -> LATIN SMALL LETTER U
- u'v' # 0xA5 -> LATIN SMALL LETTER V
- u'w' # 0xA6 -> LATIN SMALL LETTER W
- u'x' # 0xA7 -> LATIN SMALL LETTER X
- u'y' # 0xA8 -> LATIN SMALL LETTER Y
- u'z' # 0xA9 -> LATIN SMALL LETTER Z
- u'\u03bd' # 0xAA -> GREEK SMALL LETTER NU
- u'\u03be' # 0xAB -> GREEK SMALL LETTER XI
- u'\u03bf' # 0xAC -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0xAD -> GREEK SMALL LETTER PI
- u'\u03c1' # 0xAE -> GREEK SMALL LETTER RHO
- u'\u03c3' # 0xAF -> GREEK SMALL LETTER SIGMA
- u'\xa3' # 0xB0 -> POUND SIGN
- u'\u03ac' # 0xB1 -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\u03ad' # 0xB2 -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0xB3 -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03ca' # 0xB4 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u03af' # 0xB5 -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03cc' # 0xB6 -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u03cd' # 0xB7 -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u03cb' # 0xB8 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u03ce' # 0xB9 -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\u03c2' # 0xBA -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c4' # 0xBB -> GREEK SMALL LETTER TAU
- u'\u03c5' # 0xBC -> GREEK SMALL LETTER UPSILON
- u'\u03c6' # 0xBD -> GREEK SMALL LETTER PHI
- u'\u03c7' # 0xBE -> GREEK SMALL LETTER CHI
- u'\u03c8' # 0xBF -> GREEK SMALL LETTER PSI
- u'{' # 0xC0 -> LEFT CURLY BRACKET
- u'A' # 0xC1 -> LATIN CAPITAL LETTER A
- u'B' # 0xC2 -> LATIN CAPITAL LETTER B
- u'C' # 0xC3 -> LATIN CAPITAL LETTER C
- u'D' # 0xC4 -> LATIN CAPITAL LETTER D
- u'E' # 0xC5 -> LATIN CAPITAL LETTER E
- u'F' # 0xC6 -> LATIN CAPITAL LETTER F
- u'G' # 0xC7 -> LATIN CAPITAL LETTER G
- u'H' # 0xC8 -> LATIN CAPITAL LETTER H
- u'I' # 0xC9 -> LATIN CAPITAL LETTER I
- u'\xad' # 0xCA -> SOFT HYPHEN
- u'\u03c9' # 0xCB -> GREEK SMALL LETTER OMEGA
- u'\u0390' # 0xCC -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
- u'\u03b0' # 0xCD -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
- u'\u2018' # 0xCE -> LEFT SINGLE QUOTATION MARK
- u'\u2015' # 0xCF -> HORIZONTAL BAR
- u'}' # 0xD0 -> RIGHT CURLY BRACKET
- u'J' # 0xD1 -> LATIN CAPITAL LETTER J
- u'K' # 0xD2 -> LATIN CAPITAL LETTER K
- u'L' # 0xD3 -> LATIN CAPITAL LETTER L
- u'M' # 0xD4 -> LATIN CAPITAL LETTER M
- u'N' # 0xD5 -> LATIN CAPITAL LETTER N
- u'O' # 0xD6 -> LATIN CAPITAL LETTER O
- u'P' # 0xD7 -> LATIN CAPITAL LETTER P
- u'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
- u'R' # 0xD9 -> LATIN CAPITAL LETTER R
- u'\xb1' # 0xDA -> PLUS-MINUS SIGN
- u'\xbd' # 0xDB -> VULGAR FRACTION ONE HALF
- u'\x1a' # 0xDC -> SUBSTITUTE
- u'\u0387' # 0xDD -> GREEK ANO TELEIA
- u'\u2019' # 0xDE -> RIGHT SINGLE QUOTATION MARK
- u'\xa6' # 0xDF -> BROKEN BAR
- u'\\' # 0xE0 -> REVERSE SOLIDUS
- u'\x1a' # 0xE1 -> SUBSTITUTE
- u'S' # 0xE2 -> LATIN CAPITAL LETTER S
- u'T' # 0xE3 -> LATIN CAPITAL LETTER T
- u'U' # 0xE4 -> LATIN CAPITAL LETTER U
- u'V' # 0xE5 -> LATIN CAPITAL LETTER V
- u'W' # 0xE6 -> LATIN CAPITAL LETTER W
- u'X' # 0xE7 -> LATIN CAPITAL LETTER X
- u'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
- u'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
- u'\xb2' # 0xEA -> SUPERSCRIPT TWO
- u'\xa7' # 0xEB -> SECTION SIGN
- u'\x1a' # 0xEC -> SUBSTITUTE
- u'\x1a' # 0xED -> SUBSTITUTE
- u'\xab' # 0xEE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xEF -> NOT SIGN
- u'0' # 0xF0 -> DIGIT ZERO
- u'1' # 0xF1 -> DIGIT ONE
- u'2' # 0xF2 -> DIGIT TWO
- u'3' # 0xF3 -> DIGIT THREE
- u'4' # 0xF4 -> DIGIT FOUR
- u'5' # 0xF5 -> DIGIT FIVE
- u'6' # 0xF6 -> DIGIT SIX
- u'7' # 0xF7 -> DIGIT SEVEN
- u'8' # 0xF8 -> DIGIT EIGHT
- u'9' # 0xF9 -> DIGIT NINE
- u'\xb3' # 0xFA -> SUPERSCRIPT THREE
- u'\xa9' # 0xFB -> COPYRIGHT SIGN
- u'\x1a' # 0xFC -> SUBSTITUTE
- u'\x1a' # 0xFD -> SUBSTITUTE
- u'\xbb' # 0xFE -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\x9f' # 0xFF -> CONTROL
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x9c' # 0x04 -> CONTROL
+ '\t' # 0x05 -> HORIZONTAL TABULATION
+ '\x86' # 0x06 -> CONTROL
+ '\x7f' # 0x07 -> DELETE
+ '\x97' # 0x08 -> CONTROL
+ '\x8d' # 0x09 -> CONTROL
+ '\x8e' # 0x0A -> CONTROL
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x9d' # 0x14 -> CONTROL
+ '\x85' # 0x15 -> CONTROL
+ '\x08' # 0x16 -> BACKSPACE
+ '\x87' # 0x17 -> CONTROL
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x92' # 0x1A -> CONTROL
+ '\x8f' # 0x1B -> CONTROL
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ '\x80' # 0x20 -> CONTROL
+ '\x81' # 0x21 -> CONTROL
+ '\x82' # 0x22 -> CONTROL
+ '\x83' # 0x23 -> CONTROL
+ '\x84' # 0x24 -> CONTROL
+ '\n' # 0x25 -> LINE FEED
+ '\x17' # 0x26 -> END OF TRANSMISSION BLOCK
+ '\x1b' # 0x27 -> ESCAPE
+ '\x88' # 0x28 -> CONTROL
+ '\x89' # 0x29 -> CONTROL
+ '\x8a' # 0x2A -> CONTROL
+ '\x8b' # 0x2B -> CONTROL
+ '\x8c' # 0x2C -> CONTROL
+ '\x05' # 0x2D -> ENQUIRY
+ '\x06' # 0x2E -> ACKNOWLEDGE
+ '\x07' # 0x2F -> BELL
+ '\x90' # 0x30 -> CONTROL
+ '\x91' # 0x31 -> CONTROL
+ '\x16' # 0x32 -> SYNCHRONOUS IDLE
+ '\x93' # 0x33 -> CONTROL
+ '\x94' # 0x34 -> CONTROL
+ '\x95' # 0x35 -> CONTROL
+ '\x96' # 0x36 -> CONTROL
+ '\x04' # 0x37 -> END OF TRANSMISSION
+ '\x98' # 0x38 -> CONTROL
+ '\x99' # 0x39 -> CONTROL
+ '\x9a' # 0x3A -> CONTROL
+ '\x9b' # 0x3B -> CONTROL
+ '\x14' # 0x3C -> DEVICE CONTROL FOUR
+ '\x15' # 0x3D -> NEGATIVE ACKNOWLEDGE
+ '\x9e' # 0x3E -> CONTROL
+ '\x1a' # 0x3F -> SUBSTITUTE
+ ' ' # 0x40 -> SPACE
+ '\u0391' # 0x41 -> GREEK CAPITAL LETTER ALPHA
+ '\u0392' # 0x42 -> GREEK CAPITAL LETTER BETA
+ '\u0393' # 0x43 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0x44 -> GREEK CAPITAL LETTER DELTA
+ '\u0395' # 0x45 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0x46 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0x47 -> GREEK CAPITAL LETTER ETA
+ '\u0398' # 0x48 -> GREEK CAPITAL LETTER THETA
+ '\u0399' # 0x49 -> GREEK CAPITAL LETTER IOTA
+ '[' # 0x4A -> LEFT SQUARE BRACKET
+ '.' # 0x4B -> FULL STOP
+ '<' # 0x4C -> LESS-THAN SIGN
+ '(' # 0x4D -> LEFT PARENTHESIS
+ '+' # 0x4E -> PLUS SIGN
+ '!' # 0x4F -> EXCLAMATION MARK
+ '&' # 0x50 -> AMPERSAND
+ '\u039a' # 0x51 -> GREEK CAPITAL LETTER KAPPA
+ '\u039b' # 0x52 -> GREEK CAPITAL LETTER LAMDA
+ '\u039c' # 0x53 -> GREEK CAPITAL LETTER MU
+ '\u039d' # 0x54 -> GREEK CAPITAL LETTER NU
+ '\u039e' # 0x55 -> GREEK CAPITAL LETTER XI
+ '\u039f' # 0x56 -> GREEK CAPITAL LETTER OMICRON
+ '\u03a0' # 0x57 -> GREEK CAPITAL LETTER PI
+ '\u03a1' # 0x58 -> GREEK CAPITAL LETTER RHO
+ '\u03a3' # 0x59 -> GREEK CAPITAL LETTER SIGMA
+ ']' # 0x5A -> RIGHT SQUARE BRACKET
+ '$' # 0x5B -> DOLLAR SIGN
+ '*' # 0x5C -> ASTERISK
+ ')' # 0x5D -> RIGHT PARENTHESIS
+ ';' # 0x5E -> SEMICOLON
+ '^' # 0x5F -> CIRCUMFLEX ACCENT
+ '-' # 0x60 -> HYPHEN-MINUS
+ '/' # 0x61 -> SOLIDUS
+ '\u03a4' # 0x62 -> GREEK CAPITAL LETTER TAU
+ '\u03a5' # 0x63 -> GREEK CAPITAL LETTER UPSILON
+ '\u03a6' # 0x64 -> GREEK CAPITAL LETTER PHI
+ '\u03a7' # 0x65 -> GREEK CAPITAL LETTER CHI
+ '\u03a8' # 0x66 -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0x67 -> GREEK CAPITAL LETTER OMEGA
+ '\u03aa' # 0x68 -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\u03ab' # 0x69 -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '|' # 0x6A -> VERTICAL LINE
+ ',' # 0x6B -> COMMA
+ '%' # 0x6C -> PERCENT SIGN
+ '_' # 0x6D -> LOW LINE
+ '>' # 0x6E -> GREATER-THAN SIGN
+ '?' # 0x6F -> QUESTION MARK
+ '\xa8' # 0x70 -> DIAERESIS
+ '\u0386' # 0x71 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\u0388' # 0x72 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u0389' # 0x73 -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\xa0' # 0x74 -> NO-BREAK SPACE
+ '\u038a' # 0x75 -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\u038c' # 0x76 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\u038e' # 0x77 -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u038f' # 0x78 -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '`' # 0x79 -> GRAVE ACCENT
+ ':' # 0x7A -> COLON
+ '#' # 0x7B -> NUMBER SIGN
+ '@' # 0x7C -> COMMERCIAL AT
+ "'" # 0x7D -> APOSTROPHE
+ '=' # 0x7E -> EQUALS SIGN
+ '"' # 0x7F -> QUOTATION MARK
+ '\u0385' # 0x80 -> GREEK DIALYTIKA TONOS
+ 'a' # 0x81 -> LATIN SMALL LETTER A
+ 'b' # 0x82 -> LATIN SMALL LETTER B
+ 'c' # 0x83 -> LATIN SMALL LETTER C
+ 'd' # 0x84 -> LATIN SMALL LETTER D
+ 'e' # 0x85 -> LATIN SMALL LETTER E
+ 'f' # 0x86 -> LATIN SMALL LETTER F
+ 'g' # 0x87 -> LATIN SMALL LETTER G
+ 'h' # 0x88 -> LATIN SMALL LETTER H
+ 'i' # 0x89 -> LATIN SMALL LETTER I
+ '\u03b1' # 0x8A -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0x8B -> GREEK SMALL LETTER BETA
+ '\u03b3' # 0x8C -> GREEK SMALL LETTER GAMMA
+ '\u03b4' # 0x8D -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0x8E -> GREEK SMALL LETTER EPSILON
+ '\u03b6' # 0x8F -> GREEK SMALL LETTER ZETA
+ '\xb0' # 0x90 -> DEGREE SIGN
+ 'j' # 0x91 -> LATIN SMALL LETTER J
+ 'k' # 0x92 -> LATIN SMALL LETTER K
+ 'l' # 0x93 -> LATIN SMALL LETTER L
+ 'm' # 0x94 -> LATIN SMALL LETTER M
+ 'n' # 0x95 -> LATIN SMALL LETTER N
+ 'o' # 0x96 -> LATIN SMALL LETTER O
+ 'p' # 0x97 -> LATIN SMALL LETTER P
+ 'q' # 0x98 -> LATIN SMALL LETTER Q
+ 'r' # 0x99 -> LATIN SMALL LETTER R
+ '\u03b7' # 0x9A -> GREEK SMALL LETTER ETA
+ '\u03b8' # 0x9B -> GREEK SMALL LETTER THETA
+ '\u03b9' # 0x9C -> GREEK SMALL LETTER IOTA
+ '\u03ba' # 0x9D -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0x9E -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0x9F -> GREEK SMALL LETTER MU
+ '\xb4' # 0xA0 -> ACUTE ACCENT
+ '~' # 0xA1 -> TILDE
+ 's' # 0xA2 -> LATIN SMALL LETTER S
+ 't' # 0xA3 -> LATIN SMALL LETTER T
+ 'u' # 0xA4 -> LATIN SMALL LETTER U
+ 'v' # 0xA5 -> LATIN SMALL LETTER V
+ 'w' # 0xA6 -> LATIN SMALL LETTER W
+ 'x' # 0xA7 -> LATIN SMALL LETTER X
+ 'y' # 0xA8 -> LATIN SMALL LETTER Y
+ 'z' # 0xA9 -> LATIN SMALL LETTER Z
+ '\u03bd' # 0xAA -> GREEK SMALL LETTER NU
+ '\u03be' # 0xAB -> GREEK SMALL LETTER XI
+ '\u03bf' # 0xAC -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0xAD -> GREEK SMALL LETTER PI
+ '\u03c1' # 0xAE -> GREEK SMALL LETTER RHO
+ '\u03c3' # 0xAF -> GREEK SMALL LETTER SIGMA
+ '\xa3' # 0xB0 -> POUND SIGN
+ '\u03ac' # 0xB1 -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\u03ad' # 0xB2 -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0xB3 -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03ca' # 0xB4 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u03af' # 0xB5 -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03cc' # 0xB6 -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u03cd' # 0xB7 -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u03cb' # 0xB8 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u03ce' # 0xB9 -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\u03c2' # 0xBA -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c4' # 0xBB -> GREEK SMALL LETTER TAU
+ '\u03c5' # 0xBC -> GREEK SMALL LETTER UPSILON
+ '\u03c6' # 0xBD -> GREEK SMALL LETTER PHI
+ '\u03c7' # 0xBE -> GREEK SMALL LETTER CHI
+ '\u03c8' # 0xBF -> GREEK SMALL LETTER PSI
+ '{' # 0xC0 -> LEFT CURLY BRACKET
+ 'A' # 0xC1 -> LATIN CAPITAL LETTER A
+ 'B' # 0xC2 -> LATIN CAPITAL LETTER B
+ 'C' # 0xC3 -> LATIN CAPITAL LETTER C
+ 'D' # 0xC4 -> LATIN CAPITAL LETTER D
+ 'E' # 0xC5 -> LATIN CAPITAL LETTER E
+ 'F' # 0xC6 -> LATIN CAPITAL LETTER F
+ 'G' # 0xC7 -> LATIN CAPITAL LETTER G
+ 'H' # 0xC8 -> LATIN CAPITAL LETTER H
+ 'I' # 0xC9 -> LATIN CAPITAL LETTER I
+ '\xad' # 0xCA -> SOFT HYPHEN
+ '\u03c9' # 0xCB -> GREEK SMALL LETTER OMEGA
+ '\u0390' # 0xCC -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+ '\u03b0' # 0xCD -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+ '\u2018' # 0xCE -> LEFT SINGLE QUOTATION MARK
+ '\u2015' # 0xCF -> HORIZONTAL BAR
+ '}' # 0xD0 -> RIGHT CURLY BRACKET
+ 'J' # 0xD1 -> LATIN CAPITAL LETTER J
+ 'K' # 0xD2 -> LATIN CAPITAL LETTER K
+ 'L' # 0xD3 -> LATIN CAPITAL LETTER L
+ 'M' # 0xD4 -> LATIN CAPITAL LETTER M
+ 'N' # 0xD5 -> LATIN CAPITAL LETTER N
+ 'O' # 0xD6 -> LATIN CAPITAL LETTER O
+ 'P' # 0xD7 -> LATIN CAPITAL LETTER P
+ 'Q' # 0xD8 -> LATIN CAPITAL LETTER Q
+ 'R' # 0xD9 -> LATIN CAPITAL LETTER R
+ '\xb1' # 0xDA -> PLUS-MINUS SIGN
+ '\xbd' # 0xDB -> VULGAR FRACTION ONE HALF
+ '\x1a' # 0xDC -> SUBSTITUTE
+ '\u0387' # 0xDD -> GREEK ANO TELEIA
+ '\u2019' # 0xDE -> RIGHT SINGLE QUOTATION MARK
+ '\xa6' # 0xDF -> BROKEN BAR
+ '\\' # 0xE0 -> REVERSE SOLIDUS
+ '\x1a' # 0xE1 -> SUBSTITUTE
+ 'S' # 0xE2 -> LATIN CAPITAL LETTER S
+ 'T' # 0xE3 -> LATIN CAPITAL LETTER T
+ 'U' # 0xE4 -> LATIN CAPITAL LETTER U
+ 'V' # 0xE5 -> LATIN CAPITAL LETTER V
+ 'W' # 0xE6 -> LATIN CAPITAL LETTER W
+ 'X' # 0xE7 -> LATIN CAPITAL LETTER X
+ 'Y' # 0xE8 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0xE9 -> LATIN CAPITAL LETTER Z
+ '\xb2' # 0xEA -> SUPERSCRIPT TWO
+ '\xa7' # 0xEB -> SECTION SIGN
+ '\x1a' # 0xEC -> SUBSTITUTE
+ '\x1a' # 0xED -> SUBSTITUTE
+ '\xab' # 0xEE -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xEF -> NOT SIGN
+ '0' # 0xF0 -> DIGIT ZERO
+ '1' # 0xF1 -> DIGIT ONE
+ '2' # 0xF2 -> DIGIT TWO
+ '3' # 0xF3 -> DIGIT THREE
+ '4' # 0xF4 -> DIGIT FOUR
+ '5' # 0xF5 -> DIGIT FIVE
+ '6' # 0xF6 -> DIGIT SIX
+ '7' # 0xF7 -> DIGIT SEVEN
+ '8' # 0xF8 -> DIGIT EIGHT
+ '9' # 0xF9 -> DIGIT NINE
+ '\xb3' # 0xFA -> SUPERSCRIPT THREE
+ '\xa9' # 0xFB -> COPYRIGHT SIGN
+ '\x1a' # 0xFC -> SUBSTITUTE
+ '\x1a' # 0xFD -> SUBSTITUTE
+ '\xbb' # 0xFE -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\x9f' # 0xFF -> CONTROL
)
### Encoding table
diff --git a/Lib/encodings/hex_codec.py b/Lib/encodings/hex_codec.py
index 91b38d952e1..e003fc3ff97 100644
--- a/Lib/encodings/hex_codec.py
+++ b/Lib/encodings/hex_codec.py
@@ -1,53 +1,29 @@
-""" Python 'hex_codec' Codec - 2-digit hex content transfer encoding
+"""Python 'hex_codec' Codec - 2-digit hex content transfer encoding.
- Unlike most of the other codecs which target Unicode, this codec
- will return Python string objects for both encode and decode.
-
- Written by Marc-Andre Lemburg (mal@lemburg.com).
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+Written by Marc-Andre Lemburg (mal@lemburg.com).
"""
-import codecs, binascii
-
-### Codec APIs
-def hex_encode(input,errors='strict'):
+import codecs
+import binascii
- """ Encodes the object input and returns a tuple (output
- object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
+### Codec APIs
- """
+def hex_encode(input, errors='strict'):
assert errors == 'strict'
- output = binascii.b2a_hex(input)
- return (output, len(input))
+ return (binascii.b2a_hex(input), len(input))
-def hex_decode(input,errors='strict'):
-
- """ Decodes the object input and returns a tuple (output
- object, length consumed).
-
- input must be an object which provides the bf_getreadbuf
- buffer slot. Python strings, buffer objects and memory
- mapped files are examples of objects providing this slot.
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def hex_decode(input, errors='strict'):
assert errors == 'strict'
- output = binascii.a2b_hex(input)
- return (output, len(input))
+ return (binascii.a2b_hex(input), len(input))
class Codec(codecs.Codec):
-
- def encode(self, input,errors='strict'):
- return hex_encode(input,errors)
- def decode(self, input,errors='strict'):
- return hex_decode(input,errors)
+ def encode(self, input, errors='strict'):
+ return hex_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return hex_decode(input, errors)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
@@ -59,11 +35,11 @@ class IncrementalDecoder(codecs.IncrementalDecoder):
assert self.errors == 'strict'
return binascii.a2b_hex(input)
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
### encodings module API
diff --git a/Lib/encodings/idna.py b/Lib/encodings/idna.py
index ea90d67142f..583bdf130a5 100644
--- a/Lib/encodings/idna.py
+++ b/Lib/encodings/idna.py
@@ -4,11 +4,11 @@ import stringprep, re, codecs
from unicodedata import ucd_3_2_0 as unicodedata
# IDNA section 3.1
-dots = re.compile(u"[\u002E\u3002\uFF0E\uFF61]")
+dots = re.compile("[\u002E\u3002\uFF0E\uFF61]")
# IDNA section 5
-ace_prefix = "xn--"
-uace_prefix = unicode(ace_prefix, "ascii")
+ace_prefix = b"xn--"
+sace_prefix = "xn--"
# This assumes query strings, so AllowUnassigned is true
def nameprep(label):
@@ -19,7 +19,7 @@ def nameprep(label):
# Map to nothing
continue
newlabel.append(stringprep.map_table_b2(c))
- label = u"".join(newlabel)
+ label = "".join(newlabel)
# Normalize
label = unicodedata.normalize("NFKC", label)
@@ -38,7 +38,7 @@ def nameprep(label):
raise UnicodeError("Invalid character %r" % c)
# Check bidi
- RandAL = map(stringprep.in_table_d1, label)
+ RandAL = [stringprep.in_table_d1(x) for x in label]
for c in RandAL:
if c:
# There is a RandAL char in the string. Must perform further
@@ -47,7 +47,7 @@ def nameprep(label):
# This is table C.8, which was already checked
# 2) If a string contains any RandALCat character, the string
# MUST NOT contain any LCat character.
- if filter(stringprep.in_table_d2, label):
+ if any(stringprep.in_table_d2(x) for x in label):
raise UnicodeError("Violation of BIDI requirement 2")
# 3) If a string contains any RandALCat character, a
@@ -88,7 +88,7 @@ def ToASCII(label):
raise UnicodeError("label empty or too long")
# Step 5: Check ACE prefix
- if label.startswith(uace_prefix):
+ if label.startswith(sace_prefix):
raise UnicodeError("Label starts with ACE prefix")
# Step 6: Encode with PUNYCODE
@@ -104,7 +104,7 @@ def ToASCII(label):
def ToUnicode(label):
# Step 1: Check for ASCII
- if isinstance(label, str):
+ if isinstance(label, bytes):
pure_ascii = True
else:
try:
@@ -122,7 +122,7 @@ def ToUnicode(label):
raise UnicodeError("Invalid character in IDN label")
# Step 3: Check for ACE prefix
if not label.startswith(ace_prefix):
- return unicode(label, "ascii")
+ return str(label, "ascii")
# Step 4: Remove ACE prefix
label1 = label[len(ace_prefix):]
@@ -135,7 +135,7 @@ def ToUnicode(label):
# Step 7: Compare the result of step 6 with the one of step 3
# label2 will already be in lower case.
- if label.lower() != label2:
+ if str(label, "ascii").lower() != str(label2, "ascii"):
raise UnicodeError("IDNA does not round-trip", label, label2)
# Step 8: return the result of step 5
@@ -144,55 +144,54 @@ def ToUnicode(label):
### Codec APIs
class Codec(codecs.Codec):
- def encode(self,input,errors='strict'):
+ def encode(self, input, errors='strict'):
if errors != 'strict':
# IDNA is quite clear that implementations must be strict
raise UnicodeError("unsupported error handling "+errors)
if not input:
- return "", 0
+ return b'', 0
- result = []
+ result = bytearray()
labels = dots.split(input)
- if labels and len(labels[-1])==0:
- trailing_dot = '.'
+ if labels and not labels[-1]:
+ trailing_dot = b'.'
del labels[-1]
else:
- trailing_dot = ''
+ trailing_dot = b''
for label in labels:
- result.append(ToASCII(label))
- # Join with U+002E
- return ".".join(result)+trailing_dot, len(input)
+ if result:
+ # Join with U+002E
+ result.extend(b'.')
+ result.extend(ToASCII(label))
+ return bytes(result+trailing_dot), len(input)
- def decode(self,input,errors='strict'):
+ def decode(self, input, errors='strict'):
if errors != 'strict':
raise UnicodeError("Unsupported error handling "+errors)
if not input:
- return u"", 0
+ return "", 0
# IDNA allows decoding to operate on Unicode strings, too.
- if isinstance(input, unicode):
- labels = dots.split(input)
- else:
- # Must be ASCII string
- input = str(input)
- unicode(input, "ascii")
- labels = input.split(".")
+ if not isinstance(input, bytes):
+ # XXX obviously wrong, see #3232
+ input = bytes(input)
+ labels = input.split(b".")
if labels and len(labels[-1]) == 0:
- trailing_dot = u'.'
+ trailing_dot = '.'
del labels[-1]
else:
- trailing_dot = u''
+ trailing_dot = ''
result = []
for label in labels:
result.append(ToUnicode(label))
- return u".".join(result)+trailing_dot, len(input)
+ return ".".join(result)+trailing_dot, len(input)
class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
def _buffer_encode(self, input, errors, final):
@@ -201,32 +200,33 @@ class IncrementalEncoder(codecs.BufferedIncrementalEncoder):
raise UnicodeError("unsupported error handling "+errors)
if not input:
- return ("", 0)
+ return (b'', 0)
labels = dots.split(input)
- trailing_dot = u''
+ trailing_dot = b''
if labels:
if not labels[-1]:
- trailing_dot = '.'
+ trailing_dot = b'.'
del labels[-1]
elif not final:
# Keep potentially unfinished label until the next call
del labels[-1]
if labels:
- trailing_dot = '.'
+ trailing_dot = b'.'
- result = []
+ result = bytearray()
size = 0
for label in labels:
- result.append(ToASCII(label))
if size:
+ # Join with U+002E
+ result.extend(b'.')
size += 1
+ result.extend(ToASCII(label))
size += len(label)
- # Join with U+002E
- result = ".".join(result) + trailing_dot
+ result += trailing_dot
size += len(trailing_dot)
- return (result, size)
+ return (bytes(result), size)
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
def _buffer_decode(self, input, errors, final):
@@ -234,27 +234,26 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
raise UnicodeError("Unsupported error handling "+errors)
if not input:
- return (u"", 0)
+ return ("", 0)
# IDNA allows decoding to operate on Unicode strings, too.
- if isinstance(input, unicode):
+ if isinstance(input, str):
labels = dots.split(input)
else:
# Must be ASCII string
- input = str(input)
- unicode(input, "ascii")
+ input = str(input, "ascii")
labels = input.split(".")
- trailing_dot = u''
+ trailing_dot = ''
if labels:
if not labels[-1]:
- trailing_dot = u'.'
+ trailing_dot = '.'
del labels[-1]
elif not final:
# Keep potentially unfinished label until the next call
del labels[-1]
if labels:
- trailing_dot = u'.'
+ trailing_dot = '.'
result = []
size = 0
@@ -264,7 +263,7 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
size += 1
size += len(label)
- result = u".".join(result) + trailing_dot
+ result = ".".join(result) + trailing_dot
size += len(trailing_dot)
return (result, size)
diff --git a/Lib/encodings/iso8859_1.py b/Lib/encodings/iso8859_1.py
index 71bc13fcbb3..8cfc01fe14e 100644
--- a/Lib/encodings/iso8859_1.py
+++ b/Lib/encodings/iso8859_1.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH (Icelandic)
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN (Icelandic)
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf0' # 0xF0 -> LATIN SMALL LETTER ETH (Icelandic)
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0xFE -> LATIN SMALL LETTER THORN (Icelandic)
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH (Icelandic)
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN (Icelandic)
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf0' # 0xF0 -> LATIN SMALL LETTER ETH (Icelandic)
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0xFE -> LATIN SMALL LETTER THORN (Icelandic)
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/iso8859_10.py b/Lib/encodings/iso8859_10.py
index 757e5c5eb9a..b4fb0419c42 100644
--- a/Lib/encodings/iso8859_10.py
+++ b/Lib/encodings/iso8859_10.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u0112' # 0xA2 -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u0122' # 0xA3 -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\u012a' # 0xA4 -> LATIN CAPITAL LETTER I WITH MACRON
- u'\u0128' # 0xA5 -> LATIN CAPITAL LETTER I WITH TILDE
- u'\u0136' # 0xA6 -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\u013b' # 0xA8 -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\u0110' # 0xA9 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u0160' # 0xAA -> LATIN CAPITAL LETTER S WITH CARON
- u'\u0166' # 0xAB -> LATIN CAPITAL LETTER T WITH STROKE
- u'\u017d' # 0xAC -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u016a' # 0xAE -> LATIN CAPITAL LETTER U WITH MACRON
- u'\u014a' # 0xAF -> LATIN CAPITAL LETTER ENG
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u0113' # 0xB2 -> LATIN SMALL LETTER E WITH MACRON
- u'\u0123' # 0xB3 -> LATIN SMALL LETTER G WITH CEDILLA
- u'\u012b' # 0xB4 -> LATIN SMALL LETTER I WITH MACRON
- u'\u0129' # 0xB5 -> LATIN SMALL LETTER I WITH TILDE
- u'\u0137' # 0xB6 -> LATIN SMALL LETTER K WITH CEDILLA
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u013c' # 0xB8 -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u0111' # 0xB9 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0161' # 0xBA -> LATIN SMALL LETTER S WITH CARON
- u'\u0167' # 0xBB -> LATIN SMALL LETTER T WITH STROKE
- u'\u017e' # 0xBC -> LATIN SMALL LETTER Z WITH CARON
- u'\u2015' # 0xBD -> HORIZONTAL BAR
- u'\u016b' # 0xBE -> LATIN SMALL LETTER U WITH MACRON
- u'\u014b' # 0xBF -> LATIN SMALL LETTER ENG
- u'\u0100' # 0xC0 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\u012e' # 0xC7 -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u0116' # 0xCC -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH (Icelandic)
- u'\u0145' # 0xD1 -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\u014c' # 0xD2 -> LATIN CAPITAL LETTER O WITH MACRON
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\u0168' # 0xD7 -> LATIN CAPITAL LETTER U WITH TILDE
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u0172' # 0xD9 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN (Icelandic)
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
- u'\u0101' # 0xE0 -> LATIN SMALL LETTER A WITH MACRON
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\u012f' # 0xE7 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u0117' # 0xEC -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf0' # 0xF0 -> LATIN SMALL LETTER ETH (Icelandic)
- u'\u0146' # 0xF1 -> LATIN SMALL LETTER N WITH CEDILLA
- u'\u014d' # 0xF2 -> LATIN SMALL LETTER O WITH MACRON
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\u0169' # 0xF7 -> LATIN SMALL LETTER U WITH TILDE
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\u0173' # 0xF9 -> LATIN SMALL LETTER U WITH OGONEK
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0xFE -> LATIN SMALL LETTER THORN (Icelandic)
- u'\u0138' # 0xFF -> LATIN SMALL LETTER KRA
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u0112' # 0xA2 -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u0122' # 0xA3 -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\u012a' # 0xA4 -> LATIN CAPITAL LETTER I WITH MACRON
+ '\u0128' # 0xA5 -> LATIN CAPITAL LETTER I WITH TILDE
+ '\u0136' # 0xA6 -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\u013b' # 0xA8 -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\u0110' # 0xA9 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u0160' # 0xAA -> LATIN CAPITAL LETTER S WITH CARON
+ '\u0166' # 0xAB -> LATIN CAPITAL LETTER T WITH STROKE
+ '\u017d' # 0xAC -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u016a' # 0xAE -> LATIN CAPITAL LETTER U WITH MACRON
+ '\u014a' # 0xAF -> LATIN CAPITAL LETTER ENG
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u0113' # 0xB2 -> LATIN SMALL LETTER E WITH MACRON
+ '\u0123' # 0xB3 -> LATIN SMALL LETTER G WITH CEDILLA
+ '\u012b' # 0xB4 -> LATIN SMALL LETTER I WITH MACRON
+ '\u0129' # 0xB5 -> LATIN SMALL LETTER I WITH TILDE
+ '\u0137' # 0xB6 -> LATIN SMALL LETTER K WITH CEDILLA
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u013c' # 0xB8 -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u0111' # 0xB9 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0161' # 0xBA -> LATIN SMALL LETTER S WITH CARON
+ '\u0167' # 0xBB -> LATIN SMALL LETTER T WITH STROKE
+ '\u017e' # 0xBC -> LATIN SMALL LETTER Z WITH CARON
+ '\u2015' # 0xBD -> HORIZONTAL BAR
+ '\u016b' # 0xBE -> LATIN SMALL LETTER U WITH MACRON
+ '\u014b' # 0xBF -> LATIN SMALL LETTER ENG
+ '\u0100' # 0xC0 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\u012e' # 0xC7 -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u0116' # 0xCC -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH (Icelandic)
+ '\u0145' # 0xD1 -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\u014c' # 0xD2 -> LATIN CAPITAL LETTER O WITH MACRON
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\u0168' # 0xD7 -> LATIN CAPITAL LETTER U WITH TILDE
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u0172' # 0xD9 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN (Icelandic)
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
+ '\u0101' # 0xE0 -> LATIN SMALL LETTER A WITH MACRON
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\u012f' # 0xE7 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u0117' # 0xEC -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf0' # 0xF0 -> LATIN SMALL LETTER ETH (Icelandic)
+ '\u0146' # 0xF1 -> LATIN SMALL LETTER N WITH CEDILLA
+ '\u014d' # 0xF2 -> LATIN SMALL LETTER O WITH MACRON
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\u0169' # 0xF7 -> LATIN SMALL LETTER U WITH TILDE
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\u0173' # 0xF9 -> LATIN SMALL LETTER U WITH OGONEK
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0xFE -> LATIN SMALL LETTER THORN (Icelandic)
+ '\u0138' # 0xFF -> LATIN SMALL LETTER KRA
)
### Encoding table
diff --git a/Lib/encodings/iso8859_11.py b/Lib/encodings/iso8859_11.py
index 27ece8dc7b7..c7258ecf464 100644
--- a/Lib/encodings/iso8859_11.py
+++ b/Lib/encodings/iso8859_11.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
- u'\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
- u'\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
- u'\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
- u'\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
- u'\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
- u'\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
- u'\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
- u'\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
- u'\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
- u'\u0e0b' # 0xAB -> THAI CHARACTER SO SO
- u'\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
- u'\u0e0d' # 0xAD -> THAI CHARACTER YO YING
- u'\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
- u'\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
- u'\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
- u'\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
- u'\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
- u'\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
- u'\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
- u'\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
- u'\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
- u'\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
- u'\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
- u'\u0e19' # 0xB9 -> THAI CHARACTER NO NU
- u'\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
- u'\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
- u'\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
- u'\u0e1d' # 0xBD -> THAI CHARACTER FO FA
- u'\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
- u'\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
- u'\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
- u'\u0e21' # 0xC1 -> THAI CHARACTER MO MA
- u'\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
- u'\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
- u'\u0e24' # 0xC4 -> THAI CHARACTER RU
- u'\u0e25' # 0xC5 -> THAI CHARACTER LO LING
- u'\u0e26' # 0xC6 -> THAI CHARACTER LU
- u'\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
- u'\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
- u'\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
- u'\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
- u'\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
- u'\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
- u'\u0e2d' # 0xCD -> THAI CHARACTER O ANG
- u'\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
- u'\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
- u'\u0e30' # 0xD0 -> THAI CHARACTER SARA A
- u'\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
- u'\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
- u'\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
- u'\u0e34' # 0xD4 -> THAI CHARACTER SARA I
- u'\u0e35' # 0xD5 -> THAI CHARACTER SARA II
- u'\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
- u'\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
- u'\u0e38' # 0xD8 -> THAI CHARACTER SARA U
- u'\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
- u'\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
- u'\u0e40' # 0xE0 -> THAI CHARACTER SARA E
- u'\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
- u'\u0e42' # 0xE2 -> THAI CHARACTER SARA O
- u'\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
- u'\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
- u'\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
- u'\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
- u'\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
- u'\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
- u'\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
- u'\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
- u'\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
- u'\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
- u'\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
- u'\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
- u'\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
- u'\u0e50' # 0xF0 -> THAI DIGIT ZERO
- u'\u0e51' # 0xF1 -> THAI DIGIT ONE
- u'\u0e52' # 0xF2 -> THAI DIGIT TWO
- u'\u0e53' # 0xF3 -> THAI DIGIT THREE
- u'\u0e54' # 0xF4 -> THAI DIGIT FOUR
- u'\u0e55' # 0xF5 -> THAI DIGIT FIVE
- u'\u0e56' # 0xF6 -> THAI DIGIT SIX
- u'\u0e57' # 0xF7 -> THAI DIGIT SEVEN
- u'\u0e58' # 0xF8 -> THAI DIGIT EIGHT
- u'\u0e59' # 0xF9 -> THAI DIGIT NINE
- u'\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
- u'\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
+ '\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
+ '\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
+ '\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
+ '\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
+ '\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
+ '\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
+ '\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
+ '\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
+ '\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
+ '\u0e0b' # 0xAB -> THAI CHARACTER SO SO
+ '\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
+ '\u0e0d' # 0xAD -> THAI CHARACTER YO YING
+ '\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
+ '\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
+ '\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
+ '\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
+ '\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
+ '\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
+ '\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
+ '\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
+ '\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
+ '\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
+ '\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
+ '\u0e19' # 0xB9 -> THAI CHARACTER NO NU
+ '\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
+ '\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
+ '\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
+ '\u0e1d' # 0xBD -> THAI CHARACTER FO FA
+ '\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
+ '\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
+ '\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
+ '\u0e21' # 0xC1 -> THAI CHARACTER MO MA
+ '\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
+ '\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
+ '\u0e24' # 0xC4 -> THAI CHARACTER RU
+ '\u0e25' # 0xC5 -> THAI CHARACTER LO LING
+ '\u0e26' # 0xC6 -> THAI CHARACTER LU
+ '\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
+ '\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
+ '\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
+ '\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
+ '\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
+ '\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
+ '\u0e2d' # 0xCD -> THAI CHARACTER O ANG
+ '\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
+ '\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
+ '\u0e30' # 0xD0 -> THAI CHARACTER SARA A
+ '\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
+ '\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
+ '\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
+ '\u0e34' # 0xD4 -> THAI CHARACTER SARA I
+ '\u0e35' # 0xD5 -> THAI CHARACTER SARA II
+ '\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
+ '\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
+ '\u0e38' # 0xD8 -> THAI CHARACTER SARA U
+ '\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
+ '\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
+ '\u0e40' # 0xE0 -> THAI CHARACTER SARA E
+ '\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
+ '\u0e42' # 0xE2 -> THAI CHARACTER SARA O
+ '\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
+ '\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
+ '\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
+ '\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
+ '\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
+ '\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
+ '\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
+ '\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
+ '\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
+ '\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
+ '\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
+ '\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
+ '\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
+ '\u0e50' # 0xF0 -> THAI DIGIT ZERO
+ '\u0e51' # 0xF1 -> THAI DIGIT ONE
+ '\u0e52' # 0xF2 -> THAI DIGIT TWO
+ '\u0e53' # 0xF3 -> THAI DIGIT THREE
+ '\u0e54' # 0xF4 -> THAI DIGIT FOUR
+ '\u0e55' # 0xF5 -> THAI DIGIT FIVE
+ '\u0e56' # 0xF6 -> THAI DIGIT SIX
+ '\u0e57' # 0xF7 -> THAI DIGIT SEVEN
+ '\u0e58' # 0xF8 -> THAI DIGIT EIGHT
+ '\u0e59' # 0xF9 -> THAI DIGIT NINE
+ '\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
+ '\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
)
### Encoding table
diff --git a/Lib/encodings/iso8859_13.py b/Lib/encodings/iso8859_13.py
index 71adb5c19a8..6f8eab2b821 100644
--- a/Lib/encodings/iso8859_13.py
+++ b/Lib/encodings/iso8859_13.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u201d' # 0xA1 -> RIGHT DOUBLE QUOTATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\u201e' # 0xA5 -> DOUBLE LOW-9 QUOTATION MARK
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xd8' # 0xA8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u0156' # 0xAA -> LATIN CAPITAL LETTER R WITH CEDILLA
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xc6' # 0xAF -> LATIN CAPITAL LETTER AE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\u201c' # 0xB4 -> LEFT DOUBLE QUOTATION MARK
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xf8' # 0xB8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\u0157' # 0xBA -> LATIN SMALL LETTER R WITH CEDILLA
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xe6' # 0xBF -> LATIN SMALL LETTER AE
- u'\u0104' # 0xC0 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u012e' # 0xC1 -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u0100' # 0xC2 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\u0106' # 0xC3 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\u0118' # 0xC6 -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\u0112' # 0xC7 -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0179' # 0xCA -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\u0116' # 0xCB -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\u0122' # 0xCC -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\u0136' # 0xCD -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\u012a' # 0xCE -> LATIN CAPITAL LETTER I WITH MACRON
- u'\u013b' # 0xCF -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\u0160' # 0xD0 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\u0145' # 0xD2 -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\u014c' # 0xD4 -> LATIN CAPITAL LETTER O WITH MACRON
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u0172' # 0xD8 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\u0141' # 0xD9 -> LATIN CAPITAL LETTER L WITH STROKE
- u'\u015a' # 0xDA -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u016a' # 0xDB -> LATIN CAPITAL LETTER U WITH MACRON
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u017b' # 0xDD -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\u017d' # 0xDE -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
- u'\u0105' # 0xE0 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u012f' # 0xE1 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u0101' # 0xE2 -> LATIN SMALL LETTER A WITH MACRON
- u'\u0107' # 0xE3 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\u0119' # 0xE6 -> LATIN SMALL LETTER E WITH OGONEK
- u'\u0113' # 0xE7 -> LATIN SMALL LETTER E WITH MACRON
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u017a' # 0xEA -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u0117' # 0xEB -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\u0123' # 0xEC -> LATIN SMALL LETTER G WITH CEDILLA
- u'\u0137' # 0xED -> LATIN SMALL LETTER K WITH CEDILLA
- u'\u012b' # 0xEE -> LATIN SMALL LETTER I WITH MACRON
- u'\u013c' # 0xEF -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u0161' # 0xF0 -> LATIN SMALL LETTER S WITH CARON
- u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0146' # 0xF2 -> LATIN SMALL LETTER N WITH CEDILLA
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\u014d' # 0xF4 -> LATIN SMALL LETTER O WITH MACRON
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u0173' # 0xF8 -> LATIN SMALL LETTER U WITH OGONEK
- u'\u0142' # 0xF9 -> LATIN SMALL LETTER L WITH STROKE
- u'\u015b' # 0xFA -> LATIN SMALL LETTER S WITH ACUTE
- u'\u016b' # 0xFB -> LATIN SMALL LETTER U WITH MACRON
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u017e' # 0xFE -> LATIN SMALL LETTER Z WITH CARON
- u'\u2019' # 0xFF -> RIGHT SINGLE QUOTATION MARK
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u201d' # 0xA1 -> RIGHT DOUBLE QUOTATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\u201e' # 0xA5 -> DOUBLE LOW-9 QUOTATION MARK
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xd8' # 0xA8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u0156' # 0xAA -> LATIN CAPITAL LETTER R WITH CEDILLA
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xc6' # 0xAF -> LATIN CAPITAL LETTER AE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\u201c' # 0xB4 -> LEFT DOUBLE QUOTATION MARK
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xf8' # 0xB8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\u0157' # 0xBA -> LATIN SMALL LETTER R WITH CEDILLA
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xe6' # 0xBF -> LATIN SMALL LETTER AE
+ '\u0104' # 0xC0 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u012e' # 0xC1 -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u0100' # 0xC2 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\u0106' # 0xC3 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\u0118' # 0xC6 -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\u0112' # 0xC7 -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0179' # 0xCA -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\u0116' # 0xCB -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\u0122' # 0xCC -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\u0136' # 0xCD -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\u012a' # 0xCE -> LATIN CAPITAL LETTER I WITH MACRON
+ '\u013b' # 0xCF -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\u0160' # 0xD0 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\u0145' # 0xD2 -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\u014c' # 0xD4 -> LATIN CAPITAL LETTER O WITH MACRON
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u0172' # 0xD8 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\u0141' # 0xD9 -> LATIN CAPITAL LETTER L WITH STROKE
+ '\u015a' # 0xDA -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u016a' # 0xDB -> LATIN CAPITAL LETTER U WITH MACRON
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u017b' # 0xDD -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\u017d' # 0xDE -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S (German)
+ '\u0105' # 0xE0 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u012f' # 0xE1 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u0101' # 0xE2 -> LATIN SMALL LETTER A WITH MACRON
+ '\u0107' # 0xE3 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\u0119' # 0xE6 -> LATIN SMALL LETTER E WITH OGONEK
+ '\u0113' # 0xE7 -> LATIN SMALL LETTER E WITH MACRON
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u017a' # 0xEA -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u0117' # 0xEB -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\u0123' # 0xEC -> LATIN SMALL LETTER G WITH CEDILLA
+ '\u0137' # 0xED -> LATIN SMALL LETTER K WITH CEDILLA
+ '\u012b' # 0xEE -> LATIN SMALL LETTER I WITH MACRON
+ '\u013c' # 0xEF -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u0161' # 0xF0 -> LATIN SMALL LETTER S WITH CARON
+ '\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0146' # 0xF2 -> LATIN SMALL LETTER N WITH CEDILLA
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\u014d' # 0xF4 -> LATIN SMALL LETTER O WITH MACRON
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u0173' # 0xF8 -> LATIN SMALL LETTER U WITH OGONEK
+ '\u0142' # 0xF9 -> LATIN SMALL LETTER L WITH STROKE
+ '\u015b' # 0xFA -> LATIN SMALL LETTER S WITH ACUTE
+ '\u016b' # 0xFB -> LATIN SMALL LETTER U WITH MACRON
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u017e' # 0xFE -> LATIN SMALL LETTER Z WITH CARON
+ '\u2019' # 0xFF -> RIGHT SINGLE QUOTATION MARK
)
### Encoding table
diff --git a/Lib/encodings/iso8859_14.py b/Lib/encodings/iso8859_14.py
index 56843d5fd09..7568d4ee1f0 100644
--- a/Lib/encodings/iso8859_14.py
+++ b/Lib/encodings/iso8859_14.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u1e02' # 0xA1 -> LATIN CAPITAL LETTER B WITH DOT ABOVE
- u'\u1e03' # 0xA2 -> LATIN SMALL LETTER B WITH DOT ABOVE
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\u010a' # 0xA4 -> LATIN CAPITAL LETTER C WITH DOT ABOVE
- u'\u010b' # 0xA5 -> LATIN SMALL LETTER C WITH DOT ABOVE
- u'\u1e0a' # 0xA6 -> LATIN CAPITAL LETTER D WITH DOT ABOVE
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\u1e80' # 0xA8 -> LATIN CAPITAL LETTER W WITH GRAVE
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u1e82' # 0xAA -> LATIN CAPITAL LETTER W WITH ACUTE
- u'\u1e0b' # 0xAB -> LATIN SMALL LETTER D WITH DOT ABOVE
- u'\u1ef2' # 0xAC -> LATIN CAPITAL LETTER Y WITH GRAVE
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\u0178' # 0xAF -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u1e1e' # 0xB0 -> LATIN CAPITAL LETTER F WITH DOT ABOVE
- u'\u1e1f' # 0xB1 -> LATIN SMALL LETTER F WITH DOT ABOVE
- u'\u0120' # 0xB2 -> LATIN CAPITAL LETTER G WITH DOT ABOVE
- u'\u0121' # 0xB3 -> LATIN SMALL LETTER G WITH DOT ABOVE
- u'\u1e40' # 0xB4 -> LATIN CAPITAL LETTER M WITH DOT ABOVE
- u'\u1e41' # 0xB5 -> LATIN SMALL LETTER M WITH DOT ABOVE
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\u1e56' # 0xB7 -> LATIN CAPITAL LETTER P WITH DOT ABOVE
- u'\u1e81' # 0xB8 -> LATIN SMALL LETTER W WITH GRAVE
- u'\u1e57' # 0xB9 -> LATIN SMALL LETTER P WITH DOT ABOVE
- u'\u1e83' # 0xBA -> LATIN SMALL LETTER W WITH ACUTE
- u'\u1e60' # 0xBB -> LATIN CAPITAL LETTER S WITH DOT ABOVE
- u'\u1ef3' # 0xBC -> LATIN SMALL LETTER Y WITH GRAVE
- u'\u1e84' # 0xBD -> LATIN CAPITAL LETTER W WITH DIAERESIS
- u'\u1e85' # 0xBE -> LATIN SMALL LETTER W WITH DIAERESIS
- u'\u1e61' # 0xBF -> LATIN SMALL LETTER S WITH DOT ABOVE
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u0174' # 0xD0 -> LATIN CAPITAL LETTER W WITH CIRCUMFLEX
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\u1e6a' # 0xD7 -> LATIN CAPITAL LETTER T WITH DOT ABOVE
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\u0176' # 0xDE -> LATIN CAPITAL LETTER Y WITH CIRCUMFLEX
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u0175' # 0xF0 -> LATIN SMALL LETTER W WITH CIRCUMFLEX
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\u1e6b' # 0xF7 -> LATIN SMALL LETTER T WITH DOT ABOVE
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\u0177' # 0xFE -> LATIN SMALL LETTER Y WITH CIRCUMFLEX
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u1e02' # 0xA1 -> LATIN CAPITAL LETTER B WITH DOT ABOVE
+ '\u1e03' # 0xA2 -> LATIN SMALL LETTER B WITH DOT ABOVE
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\u010a' # 0xA4 -> LATIN CAPITAL LETTER C WITH DOT ABOVE
+ '\u010b' # 0xA5 -> LATIN SMALL LETTER C WITH DOT ABOVE
+ '\u1e0a' # 0xA6 -> LATIN CAPITAL LETTER D WITH DOT ABOVE
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\u1e80' # 0xA8 -> LATIN CAPITAL LETTER W WITH GRAVE
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u1e82' # 0xAA -> LATIN CAPITAL LETTER W WITH ACUTE
+ '\u1e0b' # 0xAB -> LATIN SMALL LETTER D WITH DOT ABOVE
+ '\u1ef2' # 0xAC -> LATIN CAPITAL LETTER Y WITH GRAVE
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\u0178' # 0xAF -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u1e1e' # 0xB0 -> LATIN CAPITAL LETTER F WITH DOT ABOVE
+ '\u1e1f' # 0xB1 -> LATIN SMALL LETTER F WITH DOT ABOVE
+ '\u0120' # 0xB2 -> LATIN CAPITAL LETTER G WITH DOT ABOVE
+ '\u0121' # 0xB3 -> LATIN SMALL LETTER G WITH DOT ABOVE
+ '\u1e40' # 0xB4 -> LATIN CAPITAL LETTER M WITH DOT ABOVE
+ '\u1e41' # 0xB5 -> LATIN SMALL LETTER M WITH DOT ABOVE
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\u1e56' # 0xB7 -> LATIN CAPITAL LETTER P WITH DOT ABOVE
+ '\u1e81' # 0xB8 -> LATIN SMALL LETTER W WITH GRAVE
+ '\u1e57' # 0xB9 -> LATIN SMALL LETTER P WITH DOT ABOVE
+ '\u1e83' # 0xBA -> LATIN SMALL LETTER W WITH ACUTE
+ '\u1e60' # 0xBB -> LATIN CAPITAL LETTER S WITH DOT ABOVE
+ '\u1ef3' # 0xBC -> LATIN SMALL LETTER Y WITH GRAVE
+ '\u1e84' # 0xBD -> LATIN CAPITAL LETTER W WITH DIAERESIS
+ '\u1e85' # 0xBE -> LATIN SMALL LETTER W WITH DIAERESIS
+ '\u1e61' # 0xBF -> LATIN SMALL LETTER S WITH DOT ABOVE
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u0174' # 0xD0 -> LATIN CAPITAL LETTER W WITH CIRCUMFLEX
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\u1e6a' # 0xD7 -> LATIN CAPITAL LETTER T WITH DOT ABOVE
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\u0176' # 0xDE -> LATIN CAPITAL LETTER Y WITH CIRCUMFLEX
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u0175' # 0xF0 -> LATIN SMALL LETTER W WITH CIRCUMFLEX
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\u1e6b' # 0xF7 -> LATIN SMALL LETTER T WITH DOT ABOVE
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\u0177' # 0xFE -> LATIN SMALL LETTER Y WITH CIRCUMFLEX
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/iso8859_15.py b/Lib/encodings/iso8859_15.py
index 13b140ca3bd..43bdecd4468 100644
--- a/Lib/encodings/iso8859_15.py
+++ b/Lib/encodings/iso8859_15.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\u20ac' # 0xA4 -> EURO SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\u0160' # 0xA6 -> LATIN CAPITAL LETTER S WITH CARON
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\u0161' # 0xA8 -> LATIN SMALL LETTER S WITH CARON
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\u017d' # 0xB4 -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u017e' # 0xB8 -> LATIN SMALL LETTER Z WITH CARON
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u0152' # 0xBC -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xBD -> LATIN SMALL LIGATURE OE
- u'\u0178' # 0xBE -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf0' # 0xF0 -> LATIN SMALL LETTER ETH
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xfe' # 0xFE -> LATIN SMALL LETTER THORN
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\u20ac' # 0xA4 -> EURO SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\u0160' # 0xA6 -> LATIN CAPITAL LETTER S WITH CARON
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\u0161' # 0xA8 -> LATIN SMALL LETTER S WITH CARON
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\u017d' # 0xB4 -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u017e' # 0xB8 -> LATIN SMALL LETTER Z WITH CARON
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u0152' # 0xBC -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xBD -> LATIN SMALL LIGATURE OE
+ '\u0178' # 0xBE -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xd0' # 0xD0 -> LATIN CAPITAL LETTER ETH
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf0' # 0xF0 -> LATIN SMALL LETTER ETH
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xfe' # 0xFE -> LATIN SMALL LETTER THORN
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/iso8859_16.py b/Lib/encodings/iso8859_16.py
index 00b9ac80555..e70c96e3335 100644
--- a/Lib/encodings/iso8859_16.py
+++ b/Lib/encodings/iso8859_16.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u0105' # 0xA2 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
- u'\u20ac' # 0xA4 -> EURO SIGN
- u'\u201e' # 0xA5 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u0160' # 0xA6 -> LATIN CAPITAL LETTER S WITH CARON
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\u0161' # 0xA8 -> LATIN SMALL LETTER S WITH CARON
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u0218' # 0xAA -> LATIN CAPITAL LETTER S WITH COMMA BELOW
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u0179' # 0xAC -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u017a' # 0xAE -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u010c' # 0xB2 -> LATIN CAPITAL LETTER C WITH CARON
- u'\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
- u'\u017d' # 0xB4 -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u201d' # 0xB5 -> RIGHT DOUBLE QUOTATION MARK
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u017e' # 0xB8 -> LATIN SMALL LETTER Z WITH CARON
- u'\u010d' # 0xB9 -> LATIN SMALL LETTER C WITH CARON
- u'\u0219' # 0xBA -> LATIN SMALL LETTER S WITH COMMA BELOW
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u0152' # 0xBC -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xBD -> LATIN SMALL LIGATURE OE
- u'\u0178' # 0xBE -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u0106' # 0xC5 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\u015a' # 0xD7 -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u0170' # 0xD8 -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0118' # 0xDD -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\u021a' # 0xDE -> LATIN CAPITAL LETTER T WITH COMMA BELOW
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u0107' # 0xE5 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\u015b' # 0xF7 -> LATIN SMALL LETTER S WITH ACUTE
- u'\u0171' # 0xF8 -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u0119' # 0xFD -> LATIN SMALL LETTER E WITH OGONEK
- u'\u021b' # 0xFE -> LATIN SMALL LETTER T WITH COMMA BELOW
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u0105' # 0xA2 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
+ '\u20ac' # 0xA4 -> EURO SIGN
+ '\u201e' # 0xA5 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u0160' # 0xA6 -> LATIN CAPITAL LETTER S WITH CARON
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\u0161' # 0xA8 -> LATIN SMALL LETTER S WITH CARON
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u0218' # 0xAA -> LATIN CAPITAL LETTER S WITH COMMA BELOW
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u0179' # 0xAC -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u017a' # 0xAE -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u010c' # 0xB2 -> LATIN CAPITAL LETTER C WITH CARON
+ '\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
+ '\u017d' # 0xB4 -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u201d' # 0xB5 -> RIGHT DOUBLE QUOTATION MARK
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u017e' # 0xB8 -> LATIN SMALL LETTER Z WITH CARON
+ '\u010d' # 0xB9 -> LATIN SMALL LETTER C WITH CARON
+ '\u0219' # 0xBA -> LATIN SMALL LETTER S WITH COMMA BELOW
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u0152' # 0xBC -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xBD -> LATIN SMALL LIGATURE OE
+ '\u0178' # 0xBE -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u0106' # 0xC5 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\u015a' # 0xD7 -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u0170' # 0xD8 -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0118' # 0xDD -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\u021a' # 0xDE -> LATIN CAPITAL LETTER T WITH COMMA BELOW
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u0107' # 0xE5 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\u015b' # 0xF7 -> LATIN SMALL LETTER S WITH ACUTE
+ '\u0171' # 0xF8 -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u0119' # 0xFD -> LATIN SMALL LETTER E WITH OGONEK
+ '\u021b' # 0xFE -> LATIN SMALL LETTER T WITH COMMA BELOW
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/iso8859_2.py b/Lib/encodings/iso8859_2.py
index 38e91d8e177..3698747b479 100644
--- a/Lib/encodings/iso8859_2.py
+++ b/Lib/encodings/iso8859_2.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u02d8' # 0xA2 -> BREVE
- u'\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\u013d' # 0xA5 -> LATIN CAPITAL LETTER L WITH CARON
- u'\u015a' # 0xA6 -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\u0164' # 0xAB -> LATIN CAPITAL LETTER T WITH CARON
- u'\u0179' # 0xAC -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u02db' # 0xB2 -> OGONEK
- u'\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\u013e' # 0xB5 -> LATIN SMALL LETTER L WITH CARON
- u'\u015b' # 0xB6 -> LATIN SMALL LETTER S WITH ACUTE
- u'\u02c7' # 0xB7 -> CARON
- u'\xb8' # 0xB8 -> CEDILLA
- u'\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
- u'\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
- u'\u0165' # 0xBB -> LATIN SMALL LETTER T WITH CARON
- u'\u017a' # 0xBC -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT
- u'\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
- u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE
- u'\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON
- u'\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE
- u'\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON
- u'\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
- u'\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA
- u'\u02d9' # 0xFF -> DOT ABOVE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u02d8' # 0xA2 -> BREVE
+ '\u0141' # 0xA3 -> LATIN CAPITAL LETTER L WITH STROKE
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\u013d' # 0xA5 -> LATIN CAPITAL LETTER L WITH CARON
+ '\u015a' # 0xA6 -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\u0164' # 0xAB -> LATIN CAPITAL LETTER T WITH CARON
+ '\u0179' # 0xAC -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u02db' # 0xB2 -> OGONEK
+ '\u0142' # 0xB3 -> LATIN SMALL LETTER L WITH STROKE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\u013e' # 0xB5 -> LATIN SMALL LETTER L WITH CARON
+ '\u015b' # 0xB6 -> LATIN SMALL LETTER S WITH ACUTE
+ '\u02c7' # 0xB7 -> CARON
+ '\xb8' # 0xB8 -> CEDILLA
+ '\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
+ '\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
+ '\u0165' # 0xBB -> LATIN SMALL LETTER T WITH CARON
+ '\u017a' # 0xBC -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u02dd' # 0xBD -> DOUBLE ACUTE ACCENT
+ '\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
+ '\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u0154' # 0xC0 -> LATIN CAPITAL LETTER R WITH ACUTE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u0102' # 0xC3 -> LATIN CAPITAL LETTER A WITH BREVE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u0139' # 0xC5 -> LATIN CAPITAL LETTER L WITH ACUTE
+ '\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u011a' # 0xCC -> LATIN CAPITAL LETTER E WITH CARON
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\u010e' # 0xCF -> LATIN CAPITAL LETTER D WITH CARON
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u0143' # 0xD1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\u0147' # 0xD2 -> LATIN CAPITAL LETTER N WITH CARON
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0150' # 0xD5 -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u0158' # 0xD8 -> LATIN CAPITAL LETTER R WITH CARON
+ '\u016e' # 0xD9 -> LATIN CAPITAL LETTER U WITH RING ABOVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\u0170' # 0xDB -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xdd' # 0xDD -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\u0162' # 0xDE -> LATIN CAPITAL LETTER T WITH CEDILLA
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\u0155' # 0xE0 -> LATIN SMALL LETTER R WITH ACUTE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\u0103' # 0xE3 -> LATIN SMALL LETTER A WITH BREVE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u013a' # 0xE5 -> LATIN SMALL LETTER L WITH ACUTE
+ '\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u011b' # 0xEC -> LATIN SMALL LETTER E WITH CARON
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u010f' # 0xEF -> LATIN SMALL LETTER D WITH CARON
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0144' # 0xF1 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0148' # 0xF2 -> LATIN SMALL LETTER N WITH CARON
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u0151' # 0xF5 -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u0159' # 0xF8 -> LATIN SMALL LETTER R WITH CARON
+ '\u016f' # 0xF9 -> LATIN SMALL LETTER U WITH RING ABOVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\u0171' # 0xFB -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xfd' # 0xFD -> LATIN SMALL LETTER Y WITH ACUTE
+ '\u0163' # 0xFE -> LATIN SMALL LETTER T WITH CEDILLA
+ '\u02d9' # 0xFF -> DOT ABOVE
)
### Encoding table
diff --git a/Lib/encodings/iso8859_3.py b/Lib/encodings/iso8859_3.py
index 23daafdbb17..96d3063ea68 100644
--- a/Lib/encodings/iso8859_3.py
+++ b/Lib/encodings/iso8859_3.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0126' # 0xA1 -> LATIN CAPITAL LETTER H WITH STROKE
- u'\u02d8' # 0xA2 -> BREVE
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\ufffe'
- u'\u0124' # 0xA6 -> LATIN CAPITAL LETTER H WITH CIRCUMFLEX
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\u0130' # 0xA9 -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\u011e' # 0xAB -> LATIN CAPITAL LETTER G WITH BREVE
- u'\u0134' # 0xAC -> LATIN CAPITAL LETTER J WITH CIRCUMFLEX
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\ufffe'
- u'\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\u0127' # 0xB1 -> LATIN SMALL LETTER H WITH STROKE
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u0125' # 0xB6 -> LATIN SMALL LETTER H WITH CIRCUMFLEX
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\u0131' # 0xB9 -> LATIN SMALL LETTER DOTLESS I
- u'\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
- u'\u011f' # 0xBB -> LATIN SMALL LETTER G WITH BREVE
- u'\u0135' # 0xBC -> LATIN SMALL LETTER J WITH CIRCUMFLEX
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\ufffe'
- u'\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\ufffe'
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u010a' # 0xC5 -> LATIN CAPITAL LETTER C WITH DOT ABOVE
- u'\u0108' # 0xC6 -> LATIN CAPITAL LETTER C WITH CIRCUMFLEX
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\ufffe'
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0120' # 0xD5 -> LATIN CAPITAL LETTER G WITH DOT ABOVE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\u011c' # 0xD8 -> LATIN CAPITAL LETTER G WITH CIRCUMFLEX
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u016c' # 0xDD -> LATIN CAPITAL LETTER U WITH BREVE
- u'\u015c' # 0xDE -> LATIN CAPITAL LETTER S WITH CIRCUMFLEX
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\ufffe'
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u010b' # 0xE5 -> LATIN SMALL LETTER C WITH DOT ABOVE
- u'\u0109' # 0xE6 -> LATIN SMALL LETTER C WITH CIRCUMFLEX
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\ufffe'
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\u0121' # 0xF5 -> LATIN SMALL LETTER G WITH DOT ABOVE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\u011d' # 0xF8 -> LATIN SMALL LETTER G WITH CIRCUMFLEX
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u016d' # 0xFD -> LATIN SMALL LETTER U WITH BREVE
- u'\u015d' # 0xFE -> LATIN SMALL LETTER S WITH CIRCUMFLEX
- u'\u02d9' # 0xFF -> DOT ABOVE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0126' # 0xA1 -> LATIN CAPITAL LETTER H WITH STROKE
+ '\u02d8' # 0xA2 -> BREVE
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\ufffe'
+ '\u0124' # 0xA6 -> LATIN CAPITAL LETTER H WITH CIRCUMFLEX
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\u0130' # 0xA9 -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '\u015e' # 0xAA -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\u011e' # 0xAB -> LATIN CAPITAL LETTER G WITH BREVE
+ '\u0134' # 0xAC -> LATIN CAPITAL LETTER J WITH CIRCUMFLEX
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\ufffe'
+ '\u017b' # 0xAF -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\u0127' # 0xB1 -> LATIN SMALL LETTER H WITH STROKE
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u0125' # 0xB6 -> LATIN SMALL LETTER H WITH CIRCUMFLEX
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\u0131' # 0xB9 -> LATIN SMALL LETTER DOTLESS I
+ '\u015f' # 0xBA -> LATIN SMALL LETTER S WITH CEDILLA
+ '\u011f' # 0xBB -> LATIN SMALL LETTER G WITH BREVE
+ '\u0135' # 0xBC -> LATIN SMALL LETTER J WITH CIRCUMFLEX
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\ufffe'
+ '\u017c' # 0xBF -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\ufffe'
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u010a' # 0xC5 -> LATIN CAPITAL LETTER C WITH DOT ABOVE
+ '\u0108' # 0xC6 -> LATIN CAPITAL LETTER C WITH CIRCUMFLEX
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\ufffe'
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0120' # 0xD5 -> LATIN CAPITAL LETTER G WITH DOT ABOVE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\u011c' # 0xD8 -> LATIN CAPITAL LETTER G WITH CIRCUMFLEX
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u016c' # 0xDD -> LATIN CAPITAL LETTER U WITH BREVE
+ '\u015c' # 0xDE -> LATIN CAPITAL LETTER S WITH CIRCUMFLEX
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\ufffe'
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u010b' # 0xE5 -> LATIN SMALL LETTER C WITH DOT ABOVE
+ '\u0109' # 0xE6 -> LATIN SMALL LETTER C WITH CIRCUMFLEX
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\ufffe'
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\u0121' # 0xF5 -> LATIN SMALL LETTER G WITH DOT ABOVE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\u011d' # 0xF8 -> LATIN SMALL LETTER G WITH CIRCUMFLEX
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u016d' # 0xFD -> LATIN SMALL LETTER U WITH BREVE
+ '\u015d' # 0xFE -> LATIN SMALL LETTER S WITH CIRCUMFLEX
+ '\u02d9' # 0xFF -> DOT ABOVE
)
### Encoding table
diff --git a/Lib/encodings/iso8859_4.py b/Lib/encodings/iso8859_4.py
index c8e03b566ae..65c1e00f306 100644
--- a/Lib/encodings/iso8859_4.py
+++ b/Lib/encodings/iso8859_4.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\u0138' # 0xA2 -> LATIN SMALL LETTER KRA
- u'\u0156' # 0xA3 -> LATIN CAPITAL LETTER R WITH CEDILLA
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\u0128' # 0xA5 -> LATIN CAPITAL LETTER I WITH TILDE
- u'\u013b' # 0xA6 -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u0112' # 0xAA -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u0122' # 0xAB -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\u0166' # 0xAC -> LATIN CAPITAL LETTER T WITH STROKE
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u02db' # 0xB2 -> OGONEK
- u'\u0157' # 0xB3 -> LATIN SMALL LETTER R WITH CEDILLA
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\u0129' # 0xB5 -> LATIN SMALL LETTER I WITH TILDE
- u'\u013c' # 0xB6 -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u02c7' # 0xB7 -> CARON
- u'\xb8' # 0xB8 -> CEDILLA
- u'\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
- u'\u0113' # 0xBA -> LATIN SMALL LETTER E WITH MACRON
- u'\u0123' # 0xBB -> LATIN SMALL LETTER G WITH CEDILLA
- u'\u0167' # 0xBC -> LATIN SMALL LETTER T WITH STROKE
- u'\u014a' # 0xBD -> LATIN CAPITAL LETTER ENG
- u'\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
- u'\u014b' # 0xBF -> LATIN SMALL LETTER ENG
- u'\u0100' # 0xC0 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\u012e' # 0xC7 -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u0116' # 0xCC -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\u012a' # 0xCF -> LATIN CAPITAL LETTER I WITH MACRON
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u0145' # 0xD1 -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\u014c' # 0xD2 -> LATIN CAPITAL LETTER O WITH MACRON
- u'\u0136' # 0xD3 -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u0172' # 0xD9 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0168' # 0xDD -> LATIN CAPITAL LETTER U WITH TILDE
- u'\u016a' # 0xDE -> LATIN CAPITAL LETTER U WITH MACRON
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\u0101' # 0xE0 -> LATIN SMALL LETTER A WITH MACRON
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\u012f' # 0xE7 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\u0117' # 0xEC -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\u012b' # 0xEF -> LATIN SMALL LETTER I WITH MACRON
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\u0146' # 0xF1 -> LATIN SMALL LETTER N WITH CEDILLA
- u'\u014d' # 0xF2 -> LATIN SMALL LETTER O WITH MACRON
- u'\u0137' # 0xF3 -> LATIN SMALL LETTER K WITH CEDILLA
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\u0173' # 0xF9 -> LATIN SMALL LETTER U WITH OGONEK
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u0169' # 0xFD -> LATIN SMALL LETTER U WITH TILDE
- u'\u016b' # 0xFE -> LATIN SMALL LETTER U WITH MACRON
- u'\u02d9' # 0xFF -> DOT ABOVE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0104' # 0xA1 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\u0138' # 0xA2 -> LATIN SMALL LETTER KRA
+ '\u0156' # 0xA3 -> LATIN CAPITAL LETTER R WITH CEDILLA
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\u0128' # 0xA5 -> LATIN CAPITAL LETTER I WITH TILDE
+ '\u013b' # 0xA6 -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u0112' # 0xAA -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u0122' # 0xAB -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\u0166' # 0xAC -> LATIN CAPITAL LETTER T WITH STROKE
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\u0105' # 0xB1 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u02db' # 0xB2 -> OGONEK
+ '\u0157' # 0xB3 -> LATIN SMALL LETTER R WITH CEDILLA
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\u0129' # 0xB5 -> LATIN SMALL LETTER I WITH TILDE
+ '\u013c' # 0xB6 -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u02c7' # 0xB7 -> CARON
+ '\xb8' # 0xB8 -> CEDILLA
+ '\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
+ '\u0113' # 0xBA -> LATIN SMALL LETTER E WITH MACRON
+ '\u0123' # 0xBB -> LATIN SMALL LETTER G WITH CEDILLA
+ '\u0167' # 0xBC -> LATIN SMALL LETTER T WITH STROKE
+ '\u014a' # 0xBD -> LATIN CAPITAL LETTER ENG
+ '\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
+ '\u014b' # 0xBF -> LATIN SMALL LETTER ENG
+ '\u0100' # 0xC0 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\u012e' # 0xC7 -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0118' # 0xCA -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u0116' # 0xCC -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\u012a' # 0xCF -> LATIN CAPITAL LETTER I WITH MACRON
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u0145' # 0xD1 -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\u014c' # 0xD2 -> LATIN CAPITAL LETTER O WITH MACRON
+ '\u0136' # 0xD3 -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u0172' # 0xD9 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0168' # 0xDD -> LATIN CAPITAL LETTER U WITH TILDE
+ '\u016a' # 0xDE -> LATIN CAPITAL LETTER U WITH MACRON
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\u0101' # 0xE0 -> LATIN SMALL LETTER A WITH MACRON
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\u012f' # 0xE7 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0119' # 0xEA -> LATIN SMALL LETTER E WITH OGONEK
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\u0117' # 0xEC -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\u012b' # 0xEF -> LATIN SMALL LETTER I WITH MACRON
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\u0146' # 0xF1 -> LATIN SMALL LETTER N WITH CEDILLA
+ '\u014d' # 0xF2 -> LATIN SMALL LETTER O WITH MACRON
+ '\u0137' # 0xF3 -> LATIN SMALL LETTER K WITH CEDILLA
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\u0173' # 0xF9 -> LATIN SMALL LETTER U WITH OGONEK
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u0169' # 0xFD -> LATIN SMALL LETTER U WITH TILDE
+ '\u016b' # 0xFE -> LATIN SMALL LETTER U WITH MACRON
+ '\u02d9' # 0xFF -> DOT ABOVE
)
### Encoding table
diff --git a/Lib/encodings/iso8859_5.py b/Lib/encodings/iso8859_5.py
index c01cd1caab3..a3c868a50c5 100644
--- a/Lib/encodings/iso8859_5.py
+++ b/Lib/encodings/iso8859_5.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u0401' # 0xA1 -> CYRILLIC CAPITAL LETTER IO
- u'\u0402' # 0xA2 -> CYRILLIC CAPITAL LETTER DJE
- u'\u0403' # 0xA3 -> CYRILLIC CAPITAL LETTER GJE
- u'\u0404' # 0xA4 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\u0405' # 0xA5 -> CYRILLIC CAPITAL LETTER DZE
- u'\u0406' # 0xA6 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0407' # 0xA7 -> CYRILLIC CAPITAL LETTER YI
- u'\u0408' # 0xA8 -> CYRILLIC CAPITAL LETTER JE
- u'\u0409' # 0xA9 -> CYRILLIC CAPITAL LETTER LJE
- u'\u040a' # 0xAA -> CYRILLIC CAPITAL LETTER NJE
- u'\u040b' # 0xAB -> CYRILLIC CAPITAL LETTER TSHE
- u'\u040c' # 0xAC -> CYRILLIC CAPITAL LETTER KJE
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\u040e' # 0xAE -> CYRILLIC CAPITAL LETTER SHORT U
- u'\u040f' # 0xAF -> CYRILLIC CAPITAL LETTER DZHE
- u'\u0410' # 0xB0 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0xB1 -> CYRILLIC CAPITAL LETTER BE
- u'\u0412' # 0xB2 -> CYRILLIC CAPITAL LETTER VE
- u'\u0413' # 0xB3 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0414' # 0xB4 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0xB5 -> CYRILLIC CAPITAL LETTER IE
- u'\u0416' # 0xB6 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0417' # 0xB7 -> CYRILLIC CAPITAL LETTER ZE
- u'\u0418' # 0xB8 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0xB9 -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0xBA -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0xBB -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0xBC -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0xBD -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0xBE -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0xBF -> CYRILLIC CAPITAL LETTER PE
- u'\u0420' # 0xC0 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0xC1 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0xC2 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0xC3 -> CYRILLIC CAPITAL LETTER U
- u'\u0424' # 0xC4 -> CYRILLIC CAPITAL LETTER EF
- u'\u0425' # 0xC5 -> CYRILLIC CAPITAL LETTER HA
- u'\u0426' # 0xC6 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0427' # 0xC7 -> CYRILLIC CAPITAL LETTER CHE
- u'\u0428' # 0xC8 -> CYRILLIC CAPITAL LETTER SHA
- u'\u0429' # 0xC9 -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u042a' # 0xCA -> CYRILLIC CAPITAL LETTER HARD SIGN
- u'\u042b' # 0xCB -> CYRILLIC CAPITAL LETTER YERU
- u'\u042c' # 0xCC -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042d' # 0xCD -> CYRILLIC CAPITAL LETTER E
- u'\u042e' # 0xCE -> CYRILLIC CAPITAL LETTER YU
- u'\u042f' # 0xCF -> CYRILLIC CAPITAL LETTER YA
- u'\u0430' # 0xD0 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0xD1 -> CYRILLIC SMALL LETTER BE
- u'\u0432' # 0xD2 -> CYRILLIC SMALL LETTER VE
- u'\u0433' # 0xD3 -> CYRILLIC SMALL LETTER GHE
- u'\u0434' # 0xD4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0xD5 -> CYRILLIC SMALL LETTER IE
- u'\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0437' # 0xD7 -> CYRILLIC SMALL LETTER ZE
- u'\u0438' # 0xD8 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0xD9 -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0xDA -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0xDB -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0xDC -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0xDD -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0xDE -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0xDF -> CYRILLIC SMALL LETTER PE
- u'\u0440' # 0xE0 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0xE1 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0xE2 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0xE3 -> CYRILLIC SMALL LETTER U
- u'\u0444' # 0xE4 -> CYRILLIC SMALL LETTER EF
- u'\u0445' # 0xE5 -> CYRILLIC SMALL LETTER HA
- u'\u0446' # 0xE6 -> CYRILLIC SMALL LETTER TSE
- u'\u0447' # 0xE7 -> CYRILLIC SMALL LETTER CHE
- u'\u0448' # 0xE8 -> CYRILLIC SMALL LETTER SHA
- u'\u0449' # 0xE9 -> CYRILLIC SMALL LETTER SHCHA
- u'\u044a' # 0xEA -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u044b' # 0xEB -> CYRILLIC SMALL LETTER YERU
- u'\u044c' # 0xEC -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044d' # 0xED -> CYRILLIC SMALL LETTER E
- u'\u044e' # 0xEE -> CYRILLIC SMALL LETTER YU
- u'\u044f' # 0xEF -> CYRILLIC SMALL LETTER YA
- u'\u2116' # 0xF0 -> NUMERO SIGN
- u'\u0451' # 0xF1 -> CYRILLIC SMALL LETTER IO
- u'\u0452' # 0xF2 -> CYRILLIC SMALL LETTER DJE
- u'\u0453' # 0xF3 -> CYRILLIC SMALL LETTER GJE
- u'\u0454' # 0xF4 -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\u0455' # 0xF5 -> CYRILLIC SMALL LETTER DZE
- u'\u0456' # 0xF6 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0457' # 0xF7 -> CYRILLIC SMALL LETTER YI
- u'\u0458' # 0xF8 -> CYRILLIC SMALL LETTER JE
- u'\u0459' # 0xF9 -> CYRILLIC SMALL LETTER LJE
- u'\u045a' # 0xFA -> CYRILLIC SMALL LETTER NJE
- u'\u045b' # 0xFB -> CYRILLIC SMALL LETTER TSHE
- u'\u045c' # 0xFC -> CYRILLIC SMALL LETTER KJE
- u'\xa7' # 0xFD -> SECTION SIGN
- u'\u045e' # 0xFE -> CYRILLIC SMALL LETTER SHORT U
- u'\u045f' # 0xFF -> CYRILLIC SMALL LETTER DZHE
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u0401' # 0xA1 -> CYRILLIC CAPITAL LETTER IO
+ '\u0402' # 0xA2 -> CYRILLIC CAPITAL LETTER DJE
+ '\u0403' # 0xA3 -> CYRILLIC CAPITAL LETTER GJE
+ '\u0404' # 0xA4 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\u0405' # 0xA5 -> CYRILLIC CAPITAL LETTER DZE
+ '\u0406' # 0xA6 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0407' # 0xA7 -> CYRILLIC CAPITAL LETTER YI
+ '\u0408' # 0xA8 -> CYRILLIC CAPITAL LETTER JE
+ '\u0409' # 0xA9 -> CYRILLIC CAPITAL LETTER LJE
+ '\u040a' # 0xAA -> CYRILLIC CAPITAL LETTER NJE
+ '\u040b' # 0xAB -> CYRILLIC CAPITAL LETTER TSHE
+ '\u040c' # 0xAC -> CYRILLIC CAPITAL LETTER KJE
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\u040e' # 0xAE -> CYRILLIC CAPITAL LETTER SHORT U
+ '\u040f' # 0xAF -> CYRILLIC CAPITAL LETTER DZHE
+ '\u0410' # 0xB0 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0xB1 -> CYRILLIC CAPITAL LETTER BE
+ '\u0412' # 0xB2 -> CYRILLIC CAPITAL LETTER VE
+ '\u0413' # 0xB3 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0414' # 0xB4 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0xB5 -> CYRILLIC CAPITAL LETTER IE
+ '\u0416' # 0xB6 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0417' # 0xB7 -> CYRILLIC CAPITAL LETTER ZE
+ '\u0418' # 0xB8 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0xB9 -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0xBA -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0xBB -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0xBC -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0xBD -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0xBE -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0xBF -> CYRILLIC CAPITAL LETTER PE
+ '\u0420' # 0xC0 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0xC1 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0xC2 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0xC3 -> CYRILLIC CAPITAL LETTER U
+ '\u0424' # 0xC4 -> CYRILLIC CAPITAL LETTER EF
+ '\u0425' # 0xC5 -> CYRILLIC CAPITAL LETTER HA
+ '\u0426' # 0xC6 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0427' # 0xC7 -> CYRILLIC CAPITAL LETTER CHE
+ '\u0428' # 0xC8 -> CYRILLIC CAPITAL LETTER SHA
+ '\u0429' # 0xC9 -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u042a' # 0xCA -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\u042b' # 0xCB -> CYRILLIC CAPITAL LETTER YERU
+ '\u042c' # 0xCC -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042d' # 0xCD -> CYRILLIC CAPITAL LETTER E
+ '\u042e' # 0xCE -> CYRILLIC CAPITAL LETTER YU
+ '\u042f' # 0xCF -> CYRILLIC CAPITAL LETTER YA
+ '\u0430' # 0xD0 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0xD1 -> CYRILLIC SMALL LETTER BE
+ '\u0432' # 0xD2 -> CYRILLIC SMALL LETTER VE
+ '\u0433' # 0xD3 -> CYRILLIC SMALL LETTER GHE
+ '\u0434' # 0xD4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0xD5 -> CYRILLIC SMALL LETTER IE
+ '\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0437' # 0xD7 -> CYRILLIC SMALL LETTER ZE
+ '\u0438' # 0xD8 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0xD9 -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0xDA -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0xDB -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0xDC -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0xDD -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0xDE -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0xDF -> CYRILLIC SMALL LETTER PE
+ '\u0440' # 0xE0 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0xE1 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0xE2 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0xE3 -> CYRILLIC SMALL LETTER U
+ '\u0444' # 0xE4 -> CYRILLIC SMALL LETTER EF
+ '\u0445' # 0xE5 -> CYRILLIC SMALL LETTER HA
+ '\u0446' # 0xE6 -> CYRILLIC SMALL LETTER TSE
+ '\u0447' # 0xE7 -> CYRILLIC SMALL LETTER CHE
+ '\u0448' # 0xE8 -> CYRILLIC SMALL LETTER SHA
+ '\u0449' # 0xE9 -> CYRILLIC SMALL LETTER SHCHA
+ '\u044a' # 0xEA -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u044b' # 0xEB -> CYRILLIC SMALL LETTER YERU
+ '\u044c' # 0xEC -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044d' # 0xED -> CYRILLIC SMALL LETTER E
+ '\u044e' # 0xEE -> CYRILLIC SMALL LETTER YU
+ '\u044f' # 0xEF -> CYRILLIC SMALL LETTER YA
+ '\u2116' # 0xF0 -> NUMERO SIGN
+ '\u0451' # 0xF1 -> CYRILLIC SMALL LETTER IO
+ '\u0452' # 0xF2 -> CYRILLIC SMALL LETTER DJE
+ '\u0453' # 0xF3 -> CYRILLIC SMALL LETTER GJE
+ '\u0454' # 0xF4 -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\u0455' # 0xF5 -> CYRILLIC SMALL LETTER DZE
+ '\u0456' # 0xF6 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0457' # 0xF7 -> CYRILLIC SMALL LETTER YI
+ '\u0458' # 0xF8 -> CYRILLIC SMALL LETTER JE
+ '\u0459' # 0xF9 -> CYRILLIC SMALL LETTER LJE
+ '\u045a' # 0xFA -> CYRILLIC SMALL LETTER NJE
+ '\u045b' # 0xFB -> CYRILLIC SMALL LETTER TSHE
+ '\u045c' # 0xFC -> CYRILLIC SMALL LETTER KJE
+ '\xa7' # 0xFD -> SECTION SIGN
+ '\u045e' # 0xFE -> CYRILLIC SMALL LETTER SHORT U
+ '\u045f' # 0xFF -> CYRILLIC SMALL LETTER DZHE
)
### Encoding table
diff --git a/Lib/encodings/iso8859_6.py b/Lib/encodings/iso8859_6.py
index 16c34a3f618..b02ade6eaf4 100644
--- a/Lib/encodings/iso8859_6.py
+++ b/Lib/encodings/iso8859_6.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u060c' # 0xAC -> ARABIC COMMA
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u061b' # 0xBB -> ARABIC SEMICOLON
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u061f' # 0xBF -> ARABIC QUESTION MARK
- u'\ufffe'
- u'\u0621' # 0xC1 -> ARABIC LETTER HAMZA
- u'\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
- u'\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
- u'\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
- u'\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
- u'\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
- u'\u0627' # 0xC7 -> ARABIC LETTER ALEF
- u'\u0628' # 0xC8 -> ARABIC LETTER BEH
- u'\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
- u'\u062a' # 0xCA -> ARABIC LETTER TEH
- u'\u062b' # 0xCB -> ARABIC LETTER THEH
- u'\u062c' # 0xCC -> ARABIC LETTER JEEM
- u'\u062d' # 0xCD -> ARABIC LETTER HAH
- u'\u062e' # 0xCE -> ARABIC LETTER KHAH
- u'\u062f' # 0xCF -> ARABIC LETTER DAL
- u'\u0630' # 0xD0 -> ARABIC LETTER THAL
- u'\u0631' # 0xD1 -> ARABIC LETTER REH
- u'\u0632' # 0xD2 -> ARABIC LETTER ZAIN
- u'\u0633' # 0xD3 -> ARABIC LETTER SEEN
- u'\u0634' # 0xD4 -> ARABIC LETTER SHEEN
- u'\u0635' # 0xD5 -> ARABIC LETTER SAD
- u'\u0636' # 0xD6 -> ARABIC LETTER DAD
- u'\u0637' # 0xD7 -> ARABIC LETTER TAH
- u'\u0638' # 0xD8 -> ARABIC LETTER ZAH
- u'\u0639' # 0xD9 -> ARABIC LETTER AIN
- u'\u063a' # 0xDA -> ARABIC LETTER GHAIN
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u0640' # 0xE0 -> ARABIC TATWEEL
- u'\u0641' # 0xE1 -> ARABIC LETTER FEH
- u'\u0642' # 0xE2 -> ARABIC LETTER QAF
- u'\u0643' # 0xE3 -> ARABIC LETTER KAF
- u'\u0644' # 0xE4 -> ARABIC LETTER LAM
- u'\u0645' # 0xE5 -> ARABIC LETTER MEEM
- u'\u0646' # 0xE6 -> ARABIC LETTER NOON
- u'\u0647' # 0xE7 -> ARABIC LETTER HEH
- u'\u0648' # 0xE8 -> ARABIC LETTER WAW
- u'\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA
- u'\u064a' # 0xEA -> ARABIC LETTER YEH
- u'\u064b' # 0xEB -> ARABIC FATHATAN
- u'\u064c' # 0xEC -> ARABIC DAMMATAN
- u'\u064d' # 0xED -> ARABIC KASRATAN
- u'\u064e' # 0xEE -> ARABIC FATHA
- u'\u064f' # 0xEF -> ARABIC DAMMA
- u'\u0650' # 0xF0 -> ARABIC KASRA
- u'\u0651' # 0xF1 -> ARABIC SHADDA
- u'\u0652' # 0xF2 -> ARABIC SUKUN
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u060c' # 0xAC -> ARABIC COMMA
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u061b' # 0xBB -> ARABIC SEMICOLON
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u061f' # 0xBF -> ARABIC QUESTION MARK
+ '\ufffe'
+ '\u0621' # 0xC1 -> ARABIC LETTER HAMZA
+ '\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0xC7 -> ARABIC LETTER ALEF
+ '\u0628' # 0xC8 -> ARABIC LETTER BEH
+ '\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0xCA -> ARABIC LETTER TEH
+ '\u062b' # 0xCB -> ARABIC LETTER THEH
+ '\u062c' # 0xCC -> ARABIC LETTER JEEM
+ '\u062d' # 0xCD -> ARABIC LETTER HAH
+ '\u062e' # 0xCE -> ARABIC LETTER KHAH
+ '\u062f' # 0xCF -> ARABIC LETTER DAL
+ '\u0630' # 0xD0 -> ARABIC LETTER THAL
+ '\u0631' # 0xD1 -> ARABIC LETTER REH
+ '\u0632' # 0xD2 -> ARABIC LETTER ZAIN
+ '\u0633' # 0xD3 -> ARABIC LETTER SEEN
+ '\u0634' # 0xD4 -> ARABIC LETTER SHEEN
+ '\u0635' # 0xD5 -> ARABIC LETTER SAD
+ '\u0636' # 0xD6 -> ARABIC LETTER DAD
+ '\u0637' # 0xD7 -> ARABIC LETTER TAH
+ '\u0638' # 0xD8 -> ARABIC LETTER ZAH
+ '\u0639' # 0xD9 -> ARABIC LETTER AIN
+ '\u063a' # 0xDA -> ARABIC LETTER GHAIN
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u0640' # 0xE0 -> ARABIC TATWEEL
+ '\u0641' # 0xE1 -> ARABIC LETTER FEH
+ '\u0642' # 0xE2 -> ARABIC LETTER QAF
+ '\u0643' # 0xE3 -> ARABIC LETTER KAF
+ '\u0644' # 0xE4 -> ARABIC LETTER LAM
+ '\u0645' # 0xE5 -> ARABIC LETTER MEEM
+ '\u0646' # 0xE6 -> ARABIC LETTER NOON
+ '\u0647' # 0xE7 -> ARABIC LETTER HEH
+ '\u0648' # 0xE8 -> ARABIC LETTER WAW
+ '\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0xEA -> ARABIC LETTER YEH
+ '\u064b' # 0xEB -> ARABIC FATHATAN
+ '\u064c' # 0xEC -> ARABIC DAMMATAN
+ '\u064d' # 0xED -> ARABIC KASRATAN
+ '\u064e' # 0xEE -> ARABIC FATHA
+ '\u064f' # 0xEF -> ARABIC DAMMA
+ '\u0650' # 0xF0 -> ARABIC KASRA
+ '\u0651' # 0xF1 -> ARABIC SHADDA
+ '\u0652' # 0xF2 -> ARABIC SUKUN
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
)
### Encoding table
diff --git a/Lib/encodings/iso8859_7.py b/Lib/encodings/iso8859_7.py
index a560023a08b..d7b39cbc3a7 100644
--- a/Lib/encodings/iso8859_7.py
+++ b/Lib/encodings/iso8859_7.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\u2018' # 0xA1 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xA2 -> RIGHT SINGLE QUOTATION MARK
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\u20ac' # 0xA4 -> EURO SIGN
- u'\u20af' # 0xA5 -> DRACHMA SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u037a' # 0xAA -> GREEK YPOGEGRAMMENI
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\ufffe'
- u'\u2015' # 0xAF -> HORIZONTAL BAR
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\u0384' # 0xB4 -> GREEK TONOS
- u'\u0385' # 0xB5 -> GREEK DIALYTIKA TONOS
- u'\u0386' # 0xB6 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\u0388' # 0xB8 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u0389' # 0xB9 -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\u038a' # 0xBA -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u038c' # 0xBC -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\u038e' # 0xBE -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u038f' # 0xBF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'\u0390' # 0xC0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
- u'\u0391' # 0xC1 -> GREEK CAPITAL LETTER ALPHA
- u'\u0392' # 0xC2 -> GREEK CAPITAL LETTER BETA
- u'\u0393' # 0xC3 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0xC4 -> GREEK CAPITAL LETTER DELTA
- u'\u0395' # 0xC5 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0xC6 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0xC7 -> GREEK CAPITAL LETTER ETA
- u'\u0398' # 0xC8 -> GREEK CAPITAL LETTER THETA
- u'\u0399' # 0xC9 -> GREEK CAPITAL LETTER IOTA
- u'\u039a' # 0xCA -> GREEK CAPITAL LETTER KAPPA
- u'\u039b' # 0xCB -> GREEK CAPITAL LETTER LAMDA
- u'\u039c' # 0xCC -> GREEK CAPITAL LETTER MU
- u'\u039d' # 0xCD -> GREEK CAPITAL LETTER NU
- u'\u039e' # 0xCE -> GREEK CAPITAL LETTER XI
- u'\u039f' # 0xCF -> GREEK CAPITAL LETTER OMICRON
- u'\u03a0' # 0xD0 -> GREEK CAPITAL LETTER PI
- u'\u03a1' # 0xD1 -> GREEK CAPITAL LETTER RHO
- u'\ufffe'
- u'\u03a3' # 0xD3 -> GREEK CAPITAL LETTER SIGMA
- u'\u03a4' # 0xD4 -> GREEK CAPITAL LETTER TAU
- u'\u03a5' # 0xD5 -> GREEK CAPITAL LETTER UPSILON
- u'\u03a6' # 0xD6 -> GREEK CAPITAL LETTER PHI
- u'\u03a7' # 0xD7 -> GREEK CAPITAL LETTER CHI
- u'\u03a8' # 0xD8 -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0xD9 -> GREEK CAPITAL LETTER OMEGA
- u'\u03aa' # 0xDA -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\u03ab' # 0xDB -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'\u03ac' # 0xDC -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\u03ad' # 0xDD -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0xDE -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03af' # 0xDF -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03b0' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
- u'\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
- u'\u03b3' # 0xE3 -> GREEK SMALL LETTER GAMMA
- u'\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
- u'\u03b6' # 0xE6 -> GREEK SMALL LETTER ZETA
- u'\u03b7' # 0xE7 -> GREEK SMALL LETTER ETA
- u'\u03b8' # 0xE8 -> GREEK SMALL LETTER THETA
- u'\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
- u'\u03ba' # 0xEA -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0xEB -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0xEC -> GREEK SMALL LETTER MU
- u'\u03bd' # 0xED -> GREEK SMALL LETTER NU
- u'\u03be' # 0xEE -> GREEK SMALL LETTER XI
- u'\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
- u'\u03c1' # 0xF1 -> GREEK SMALL LETTER RHO
- u'\u03c2' # 0xF2 -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
- u'\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
- u'\u03c5' # 0xF5 -> GREEK SMALL LETTER UPSILON
- u'\u03c6' # 0xF6 -> GREEK SMALL LETTER PHI
- u'\u03c7' # 0xF7 -> GREEK SMALL LETTER CHI
- u'\u03c8' # 0xF8 -> GREEK SMALL LETTER PSI
- u'\u03c9' # 0xF9 -> GREEK SMALL LETTER OMEGA
- u'\u03ca' # 0xFA -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u03cb' # 0xFB -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u03cc' # 0xFC -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u03cd' # 0xFD -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u03ce' # 0xFE -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\ufffe'
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\u2018' # 0xA1 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xA2 -> RIGHT SINGLE QUOTATION MARK
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\u20ac' # 0xA4 -> EURO SIGN
+ '\u20af' # 0xA5 -> DRACHMA SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u037a' # 0xAA -> GREEK YPOGEGRAMMENI
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\ufffe'
+ '\u2015' # 0xAF -> HORIZONTAL BAR
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\u0384' # 0xB4 -> GREEK TONOS
+ '\u0385' # 0xB5 -> GREEK DIALYTIKA TONOS
+ '\u0386' # 0xB6 -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\u0388' # 0xB8 -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u0389' # 0xB9 -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\u038a' # 0xBA -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u038c' # 0xBC -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\u038e' # 0xBE -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u038f' # 0xBF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '\u0390' # 0xC0 -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+ '\u0391' # 0xC1 -> GREEK CAPITAL LETTER ALPHA
+ '\u0392' # 0xC2 -> GREEK CAPITAL LETTER BETA
+ '\u0393' # 0xC3 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0xC4 -> GREEK CAPITAL LETTER DELTA
+ '\u0395' # 0xC5 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0xC6 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0xC7 -> GREEK CAPITAL LETTER ETA
+ '\u0398' # 0xC8 -> GREEK CAPITAL LETTER THETA
+ '\u0399' # 0xC9 -> GREEK CAPITAL LETTER IOTA
+ '\u039a' # 0xCA -> GREEK CAPITAL LETTER KAPPA
+ '\u039b' # 0xCB -> GREEK CAPITAL LETTER LAMDA
+ '\u039c' # 0xCC -> GREEK CAPITAL LETTER MU
+ '\u039d' # 0xCD -> GREEK CAPITAL LETTER NU
+ '\u039e' # 0xCE -> GREEK CAPITAL LETTER XI
+ '\u039f' # 0xCF -> GREEK CAPITAL LETTER OMICRON
+ '\u03a0' # 0xD0 -> GREEK CAPITAL LETTER PI
+ '\u03a1' # 0xD1 -> GREEK CAPITAL LETTER RHO
+ '\ufffe'
+ '\u03a3' # 0xD3 -> GREEK CAPITAL LETTER SIGMA
+ '\u03a4' # 0xD4 -> GREEK CAPITAL LETTER TAU
+ '\u03a5' # 0xD5 -> GREEK CAPITAL LETTER UPSILON
+ '\u03a6' # 0xD6 -> GREEK CAPITAL LETTER PHI
+ '\u03a7' # 0xD7 -> GREEK CAPITAL LETTER CHI
+ '\u03a8' # 0xD8 -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0xD9 -> GREEK CAPITAL LETTER OMEGA
+ '\u03aa' # 0xDA -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\u03ab' # 0xDB -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '\u03ac' # 0xDC -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\u03ad' # 0xDD -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0xDE -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03af' # 0xDF -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03b0' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+ '\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
+ '\u03b3' # 0xE3 -> GREEK SMALL LETTER GAMMA
+ '\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
+ '\u03b6' # 0xE6 -> GREEK SMALL LETTER ZETA
+ '\u03b7' # 0xE7 -> GREEK SMALL LETTER ETA
+ '\u03b8' # 0xE8 -> GREEK SMALL LETTER THETA
+ '\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
+ '\u03ba' # 0xEA -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0xEB -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0xEC -> GREEK SMALL LETTER MU
+ '\u03bd' # 0xED -> GREEK SMALL LETTER NU
+ '\u03be' # 0xEE -> GREEK SMALL LETTER XI
+ '\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
+ '\u03c1' # 0xF1 -> GREEK SMALL LETTER RHO
+ '\u03c2' # 0xF2 -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
+ '\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
+ '\u03c5' # 0xF5 -> GREEK SMALL LETTER UPSILON
+ '\u03c6' # 0xF6 -> GREEK SMALL LETTER PHI
+ '\u03c7' # 0xF7 -> GREEK SMALL LETTER CHI
+ '\u03c8' # 0xF8 -> GREEK SMALL LETTER PSI
+ '\u03c9' # 0xF9 -> GREEK SMALL LETTER OMEGA
+ '\u03ca' # 0xFA -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u03cb' # 0xFB -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u03cc' # 0xFC -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u03cd' # 0xFD -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u03ce' # 0xFE -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\ufffe'
)
### Encoding table
diff --git a/Lib/encodings/iso8859_8.py b/Lib/encodings/iso8859_8.py
index 43cf2138b53..81849027388 100644
--- a/Lib/encodings/iso8859_8.py
+++ b/Lib/encodings/iso8859_8.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\ufffe'
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xd7' # 0xAA -> MULTIPLICATION SIGN
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xf7' # 0xBA -> DIVISION SIGN
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u2017' # 0xDF -> DOUBLE LOW LINE
- u'\u05d0' # 0xE0 -> HEBREW LETTER ALEF
- u'\u05d1' # 0xE1 -> HEBREW LETTER BET
- u'\u05d2' # 0xE2 -> HEBREW LETTER GIMEL
- u'\u05d3' # 0xE3 -> HEBREW LETTER DALET
- u'\u05d4' # 0xE4 -> HEBREW LETTER HE
- u'\u05d5' # 0xE5 -> HEBREW LETTER VAV
- u'\u05d6' # 0xE6 -> HEBREW LETTER ZAYIN
- u'\u05d7' # 0xE7 -> HEBREW LETTER HET
- u'\u05d8' # 0xE8 -> HEBREW LETTER TET
- u'\u05d9' # 0xE9 -> HEBREW LETTER YOD
- u'\u05da' # 0xEA -> HEBREW LETTER FINAL KAF
- u'\u05db' # 0xEB -> HEBREW LETTER KAF
- u'\u05dc' # 0xEC -> HEBREW LETTER LAMED
- u'\u05dd' # 0xED -> HEBREW LETTER FINAL MEM
- u'\u05de' # 0xEE -> HEBREW LETTER MEM
- u'\u05df' # 0xEF -> HEBREW LETTER FINAL NUN
- u'\u05e0' # 0xF0 -> HEBREW LETTER NUN
- u'\u05e1' # 0xF1 -> HEBREW LETTER SAMEKH
- u'\u05e2' # 0xF2 -> HEBREW LETTER AYIN
- u'\u05e3' # 0xF3 -> HEBREW LETTER FINAL PE
- u'\u05e4' # 0xF4 -> HEBREW LETTER PE
- u'\u05e5' # 0xF5 -> HEBREW LETTER FINAL TSADI
- u'\u05e6' # 0xF6 -> HEBREW LETTER TSADI
- u'\u05e7' # 0xF7 -> HEBREW LETTER QOF
- u'\u05e8' # 0xF8 -> HEBREW LETTER RESH
- u'\u05e9' # 0xF9 -> HEBREW LETTER SHIN
- u'\u05ea' # 0xFA -> HEBREW LETTER TAV
- u'\ufffe'
- u'\ufffe'
- u'\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
- u'\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
- u'\ufffe'
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\ufffe'
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xd7' # 0xAA -> MULTIPLICATION SIGN
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xf7' # 0xBA -> DIVISION SIGN
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u2017' # 0xDF -> DOUBLE LOW LINE
+ '\u05d0' # 0xE0 -> HEBREW LETTER ALEF
+ '\u05d1' # 0xE1 -> HEBREW LETTER BET
+ '\u05d2' # 0xE2 -> HEBREW LETTER GIMEL
+ '\u05d3' # 0xE3 -> HEBREW LETTER DALET
+ '\u05d4' # 0xE4 -> HEBREW LETTER HE
+ '\u05d5' # 0xE5 -> HEBREW LETTER VAV
+ '\u05d6' # 0xE6 -> HEBREW LETTER ZAYIN
+ '\u05d7' # 0xE7 -> HEBREW LETTER HET
+ '\u05d8' # 0xE8 -> HEBREW LETTER TET
+ '\u05d9' # 0xE9 -> HEBREW LETTER YOD
+ '\u05da' # 0xEA -> HEBREW LETTER FINAL KAF
+ '\u05db' # 0xEB -> HEBREW LETTER KAF
+ '\u05dc' # 0xEC -> HEBREW LETTER LAMED
+ '\u05dd' # 0xED -> HEBREW LETTER FINAL MEM
+ '\u05de' # 0xEE -> HEBREW LETTER MEM
+ '\u05df' # 0xEF -> HEBREW LETTER FINAL NUN
+ '\u05e0' # 0xF0 -> HEBREW LETTER NUN
+ '\u05e1' # 0xF1 -> HEBREW LETTER SAMEKH
+ '\u05e2' # 0xF2 -> HEBREW LETTER AYIN
+ '\u05e3' # 0xF3 -> HEBREW LETTER FINAL PE
+ '\u05e4' # 0xF4 -> HEBREW LETTER PE
+ '\u05e5' # 0xF5 -> HEBREW LETTER FINAL TSADI
+ '\u05e6' # 0xF6 -> HEBREW LETTER TSADI
+ '\u05e7' # 0xF7 -> HEBREW LETTER QOF
+ '\u05e8' # 0xF8 -> HEBREW LETTER RESH
+ '\u05e9' # 0xF9 -> HEBREW LETTER SHIN
+ '\u05ea' # 0xFA -> HEBREW LETTER TAV
+ '\ufffe'
+ '\ufffe'
+ '\u200e' # 0xFD -> LEFT-TO-RIGHT MARK
+ '\u200f' # 0xFE -> RIGHT-TO-LEFT MARK
+ '\ufffe'
)
### Encoding table
diff --git a/Lib/encodings/iso8859_9.py b/Lib/encodings/iso8859_9.py
index b8029382c0d..e539fddac6c 100644
--- a/Lib/encodings/iso8859_9.py
+++ b/Lib/encodings/iso8859_9.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\xa0' # 0xA0 -> NO-BREAK SPACE
- u'\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa4' # 0xA4 -> CURRENCY SIGN
- u'\xa5' # 0xA5 -> YEN SIGN
- u'\xa6' # 0xA6 -> BROKEN BAR
- u'\xa7' # 0xA7 -> SECTION SIGN
- u'\xa8' # 0xA8 -> DIAERESIS
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
- u'\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xac' # 0xAC -> NOT SIGN
- u'\xad' # 0xAD -> SOFT HYPHEN
- u'\xae' # 0xAE -> REGISTERED SIGN
- u'\xaf' # 0xAF -> MACRON
- u'\xb0' # 0xB0 -> DEGREE SIGN
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\xb2' # 0xB2 -> SUPERSCRIPT TWO
- u'\xb3' # 0xB3 -> SUPERSCRIPT THREE
- u'\xb4' # 0xB4 -> ACUTE ACCENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\xb6' # 0xB6 -> PILCROW SIGN
- u'\xb7' # 0xB7 -> MIDDLE DOT
- u'\xb8' # 0xB8 -> CEDILLA
- u'\xb9' # 0xB9 -> SUPERSCRIPT ONE
- u'\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
- u'\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
- u'\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
- u'\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
- u'\xbf' # 0xBF -> INVERTED QUESTION MARK
- u'\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
- u'\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE
- u'\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
- u'\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xd7' # 0xD7 -> MULTIPLICATION SIGN
- u'\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
- u'\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
- u'\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
- u'\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe6' # 0xE6 -> LATIN SMALL LETTER AE
- u'\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
- u'\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
- u'\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
- u'\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
- u'\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE
- u'\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
- u'\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0xF7 -> DIVISION SIGN
- u'\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
- u'\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
- u'\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I
- u'\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA
- u'\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\xa0' # 0xA0 -> NO-BREAK SPACE
+ '\xa1' # 0xA1 -> INVERTED EXCLAMATION MARK
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa4' # 0xA4 -> CURRENCY SIGN
+ '\xa5' # 0xA5 -> YEN SIGN
+ '\xa6' # 0xA6 -> BROKEN BAR
+ '\xa7' # 0xA7 -> SECTION SIGN
+ '\xa8' # 0xA8 -> DIAERESIS
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\xaa' # 0xAA -> FEMININE ORDINAL INDICATOR
+ '\xab' # 0xAB -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xac' # 0xAC -> NOT SIGN
+ '\xad' # 0xAD -> SOFT HYPHEN
+ '\xae' # 0xAE -> REGISTERED SIGN
+ '\xaf' # 0xAF -> MACRON
+ '\xb0' # 0xB0 -> DEGREE SIGN
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\xb2' # 0xB2 -> SUPERSCRIPT TWO
+ '\xb3' # 0xB3 -> SUPERSCRIPT THREE
+ '\xb4' # 0xB4 -> ACUTE ACCENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\xb6' # 0xB6 -> PILCROW SIGN
+ '\xb7' # 0xB7 -> MIDDLE DOT
+ '\xb8' # 0xB8 -> CEDILLA
+ '\xb9' # 0xB9 -> SUPERSCRIPT ONE
+ '\xba' # 0xBA -> MASCULINE ORDINAL INDICATOR
+ '\xbb' # 0xBB -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbc' # 0xBC -> VULGAR FRACTION ONE QUARTER
+ '\xbd' # 0xBD -> VULGAR FRACTION ONE HALF
+ '\xbe' # 0xBE -> VULGAR FRACTION THREE QUARTERS
+ '\xbf' # 0xBF -> INVERTED QUESTION MARK
+ '\xc0' # 0xC0 -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc1' # 0xC1 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xc2' # 0xC2 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xc3' # 0xC3 -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xc4' # 0xC4 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0xC5 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc6' # 0xC6 -> LATIN CAPITAL LETTER AE
+ '\xc7' # 0xC7 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc8' # 0xC8 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xc9' # 0xC9 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xca' # 0xCA -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xcb' # 0xCB -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xcc' # 0xCC -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xcd' # 0xCD -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xCE -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xCF -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\u011e' # 0xD0 -> LATIN CAPITAL LETTER G WITH BREVE
+ '\xd1' # 0xD1 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd2' # 0xD2 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xd3' # 0xD3 -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xD4 -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\xd5' # 0xD5 -> LATIN CAPITAL LETTER O WITH TILDE
+ '\xd6' # 0xD6 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xd7' # 0xD7 -> MULTIPLICATION SIGN
+ '\xd8' # 0xD8 -> LATIN CAPITAL LETTER O WITH STROKE
+ '\xd9' # 0xD9 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\xda' # 0xDA -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xDB -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xdc' # 0xDC -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0130' # 0xDD -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\xdf' # 0xDF -> LATIN SMALL LETTER SHARP S
+ '\xe0' # 0xE0 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe1' # 0xE1 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe2' # 0xE2 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe3' # 0xE3 -> LATIN SMALL LETTER A WITH TILDE
+ '\xe4' # 0xE4 -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe5' # 0xE5 -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe6' # 0xE6 -> LATIN SMALL LETTER AE
+ '\xe7' # 0xE7 -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe8' # 0xE8 -> LATIN SMALL LETTER E WITH GRAVE
+ '\xe9' # 0xE9 -> LATIN SMALL LETTER E WITH ACUTE
+ '\xea' # 0xEA -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0xEB -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xec' # 0xEC -> LATIN SMALL LETTER I WITH GRAVE
+ '\xed' # 0xED -> LATIN SMALL LETTER I WITH ACUTE
+ '\xee' # 0xEE -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0xEF -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u011f' # 0xF0 -> LATIN SMALL LETTER G WITH BREVE
+ '\xf1' # 0xF1 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf2' # 0xF2 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf3' # 0xF3 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf4' # 0xF4 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf5' # 0xF5 -> LATIN SMALL LETTER O WITH TILDE
+ '\xf6' # 0xF6 -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0xF7 -> DIVISION SIGN
+ '\xf8' # 0xF8 -> LATIN SMALL LETTER O WITH STROKE
+ '\xf9' # 0xF9 -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfa' # 0xFA -> LATIN SMALL LETTER U WITH ACUTE
+ '\xfb' # 0xFB -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0xFC -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u0131' # 0xFD -> LATIN SMALL LETTER DOTLESS I
+ '\u015f' # 0xFE -> LATIN SMALL LETTER S WITH CEDILLA
+ '\xff' # 0xFF -> LATIN SMALL LETTER Y WITH DIAERESIS
)
### Encoding table
diff --git a/Lib/encodings/koi8_r.py b/Lib/encodings/koi8_r.py
index f9eb82c0db4..41ddde856e6 100644
--- a/Lib/encodings/koi8_r.py
+++ b/Lib/encodings/koi8_r.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u2500' # 0x80 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u2502' # 0x81 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u250c' # 0x82 -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2510' # 0x83 -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x84 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2518' # 0x85 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u251c' # 0x86 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2524' # 0x87 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u252c' # 0x88 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u2534' # 0x89 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u253c' # 0x8A -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u2580' # 0x8B -> UPPER HALF BLOCK
- u'\u2584' # 0x8C -> LOWER HALF BLOCK
- u'\u2588' # 0x8D -> FULL BLOCK
- u'\u258c' # 0x8E -> LEFT HALF BLOCK
- u'\u2590' # 0x8F -> RIGHT HALF BLOCK
- u'\u2591' # 0x90 -> LIGHT SHADE
- u'\u2592' # 0x91 -> MEDIUM SHADE
- u'\u2593' # 0x92 -> DARK SHADE
- u'\u2320' # 0x93 -> TOP HALF INTEGRAL
- u'\u25a0' # 0x94 -> BLACK SQUARE
- u'\u2219' # 0x95 -> BULLET OPERATOR
- u'\u221a' # 0x96 -> SQUARE ROOT
- u'\u2248' # 0x97 -> ALMOST EQUAL TO
- u'\u2264' # 0x98 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0x99 -> GREATER-THAN OR EQUAL TO
- u'\xa0' # 0x9A -> NO-BREAK SPACE
- u'\u2321' # 0x9B -> BOTTOM HALF INTEGRAL
- u'\xb0' # 0x9C -> DEGREE SIGN
- u'\xb2' # 0x9D -> SUPERSCRIPT TWO
- u'\xb7' # 0x9E -> MIDDLE DOT
- u'\xf7' # 0x9F -> DIVISION SIGN
- u'\u2550' # 0xA0 -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u2551' # 0xA1 -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2552' # 0xA2 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u0451' # 0xA3 -> CYRILLIC SMALL LETTER IO
- u'\u2553' # 0xA4 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
- u'\u2554' # 0xA5 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u2555' # 0xA6 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
- u'\u2556' # 0xA7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
- u'\u2557' # 0xA8 -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u2558' # 0xA9 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2559' # 0xAA -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0xAB -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u255b' # 0xAC -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u255c' # 0xAD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
- u'\u255d' # 0xAE -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255e' # 0xAF -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0xB0 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u2560' # 0xB1 -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2561' # 0xB2 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u0401' # 0xB3 -> CYRILLIC CAPITAL LETTER IO
- u'\u2562' # 0xB4 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
- u'\u2563' # 0xB5 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u2564' # 0xB6 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
- u'\u2565' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
- u'\u2566' # 0xB8 -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2567' # 0xB9 -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0xBA -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2569' # 0xBB -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u256a' # 0xBC -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u256b' # 0xBD -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
- u'\u256c' # 0xBE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa9' # 0xBF -> COPYRIGHT SIGN
- u'\u044e' # 0xC0 -> CYRILLIC SMALL LETTER YU
- u'\u0430' # 0xC1 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0xC2 -> CYRILLIC SMALL LETTER BE
- u'\u0446' # 0xC3 -> CYRILLIC SMALL LETTER TSE
- u'\u0434' # 0xC4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0xC5 -> CYRILLIC SMALL LETTER IE
- u'\u0444' # 0xC6 -> CYRILLIC SMALL LETTER EF
- u'\u0433' # 0xC7 -> CYRILLIC SMALL LETTER GHE
- u'\u0445' # 0xC8 -> CYRILLIC SMALL LETTER HA
- u'\u0438' # 0xC9 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0xCA -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0xCB -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0xCC -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0xCD -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0xCE -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0xCF -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0xD0 -> CYRILLIC SMALL LETTER PE
- u'\u044f' # 0xD1 -> CYRILLIC SMALL LETTER YA
- u'\u0440' # 0xD2 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0xD3 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0xD4 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0xD5 -> CYRILLIC SMALL LETTER U
- u'\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0432' # 0xD7 -> CYRILLIC SMALL LETTER VE
- u'\u044c' # 0xD8 -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044b' # 0xD9 -> CYRILLIC SMALL LETTER YERU
- u'\u0437' # 0xDA -> CYRILLIC SMALL LETTER ZE
- u'\u0448' # 0xDB -> CYRILLIC SMALL LETTER SHA
- u'\u044d' # 0xDC -> CYRILLIC SMALL LETTER E
- u'\u0449' # 0xDD -> CYRILLIC SMALL LETTER SHCHA
- u'\u0447' # 0xDE -> CYRILLIC SMALL LETTER CHE
- u'\u044a' # 0xDF -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u042e' # 0xE0 -> CYRILLIC CAPITAL LETTER YU
- u'\u0410' # 0xE1 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0xE2 -> CYRILLIC CAPITAL LETTER BE
- u'\u0426' # 0xE3 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0414' # 0xE4 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0xE5 -> CYRILLIC CAPITAL LETTER IE
- u'\u0424' # 0xE6 -> CYRILLIC CAPITAL LETTER EF
- u'\u0413' # 0xE7 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0425' # 0xE8 -> CYRILLIC CAPITAL LETTER HA
- u'\u0418' # 0xE9 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0xEA -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0xEB -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0xEC -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0xED -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0xEE -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0xEF -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0xF0 -> CYRILLIC CAPITAL LETTER PE
- u'\u042f' # 0xF1 -> CYRILLIC CAPITAL LETTER YA
- u'\u0420' # 0xF2 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0xF3 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0xF4 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0xF5 -> CYRILLIC CAPITAL LETTER U
- u'\u0416' # 0xF6 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0412' # 0xF7 -> CYRILLIC CAPITAL LETTER VE
- u'\u042c' # 0xF8 -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042b' # 0xF9 -> CYRILLIC CAPITAL LETTER YERU
- u'\u0417' # 0xFA -> CYRILLIC CAPITAL LETTER ZE
- u'\u0428' # 0xFB -> CYRILLIC CAPITAL LETTER SHA
- u'\u042d' # 0xFC -> CYRILLIC CAPITAL LETTER E
- u'\u0429' # 0xFD -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u0427' # 0xFE -> CYRILLIC CAPITAL LETTER CHE
- u'\u042a' # 0xFF -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u2500' # 0x80 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u2502' # 0x81 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u250c' # 0x82 -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2510' # 0x83 -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x84 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2518' # 0x85 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u251c' # 0x86 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2524' # 0x87 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u252c' # 0x88 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u2534' # 0x89 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u253c' # 0x8A -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u2580' # 0x8B -> UPPER HALF BLOCK
+ '\u2584' # 0x8C -> LOWER HALF BLOCK
+ '\u2588' # 0x8D -> FULL BLOCK
+ '\u258c' # 0x8E -> LEFT HALF BLOCK
+ '\u2590' # 0x8F -> RIGHT HALF BLOCK
+ '\u2591' # 0x90 -> LIGHT SHADE
+ '\u2592' # 0x91 -> MEDIUM SHADE
+ '\u2593' # 0x92 -> DARK SHADE
+ '\u2320' # 0x93 -> TOP HALF INTEGRAL
+ '\u25a0' # 0x94 -> BLACK SQUARE
+ '\u2219' # 0x95 -> BULLET OPERATOR
+ '\u221a' # 0x96 -> SQUARE ROOT
+ '\u2248' # 0x97 -> ALMOST EQUAL TO
+ '\u2264' # 0x98 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0x99 -> GREATER-THAN OR EQUAL TO
+ '\xa0' # 0x9A -> NO-BREAK SPACE
+ '\u2321' # 0x9B -> BOTTOM HALF INTEGRAL
+ '\xb0' # 0x9C -> DEGREE SIGN
+ '\xb2' # 0x9D -> SUPERSCRIPT TWO
+ '\xb7' # 0x9E -> MIDDLE DOT
+ '\xf7' # 0x9F -> DIVISION SIGN
+ '\u2550' # 0xA0 -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u2551' # 0xA1 -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2552' # 0xA2 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u0451' # 0xA3 -> CYRILLIC SMALL LETTER IO
+ '\u2553' # 0xA4 -> BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE
+ '\u2554' # 0xA5 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u2555' # 0xA6 -> BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE
+ '\u2556' # 0xA7 -> BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE
+ '\u2557' # 0xA8 -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u2558' # 0xA9 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2559' # 0xAA -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0xAB -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u255b' # 0xAC -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u255c' # 0xAD -> BOX DRAWINGS UP DOUBLE AND LEFT SINGLE
+ '\u255d' # 0xAE -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255e' # 0xAF -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0xB0 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u2560' # 0xB1 -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2561' # 0xB2 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u0401' # 0xB3 -> CYRILLIC CAPITAL LETTER IO
+ '\u2562' # 0xB4 -> BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE
+ '\u2563' # 0xB5 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u2564' # 0xB6 -> BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE
+ '\u2565' # 0xB7 -> BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE
+ '\u2566' # 0xB8 -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2567' # 0xB9 -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0xBA -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2569' # 0xBB -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u256a' # 0xBC -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u256b' # 0xBD -> BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE
+ '\u256c' # 0xBE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa9' # 0xBF -> COPYRIGHT SIGN
+ '\u044e' # 0xC0 -> CYRILLIC SMALL LETTER YU
+ '\u0430' # 0xC1 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0xC2 -> CYRILLIC SMALL LETTER BE
+ '\u0446' # 0xC3 -> CYRILLIC SMALL LETTER TSE
+ '\u0434' # 0xC4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0xC5 -> CYRILLIC SMALL LETTER IE
+ '\u0444' # 0xC6 -> CYRILLIC SMALL LETTER EF
+ '\u0433' # 0xC7 -> CYRILLIC SMALL LETTER GHE
+ '\u0445' # 0xC8 -> CYRILLIC SMALL LETTER HA
+ '\u0438' # 0xC9 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0xCA -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0xCB -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0xCC -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0xCD -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0xCE -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0xCF -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0xD0 -> CYRILLIC SMALL LETTER PE
+ '\u044f' # 0xD1 -> CYRILLIC SMALL LETTER YA
+ '\u0440' # 0xD2 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0xD3 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0xD4 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0xD5 -> CYRILLIC SMALL LETTER U
+ '\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0432' # 0xD7 -> CYRILLIC SMALL LETTER VE
+ '\u044c' # 0xD8 -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044b' # 0xD9 -> CYRILLIC SMALL LETTER YERU
+ '\u0437' # 0xDA -> CYRILLIC SMALL LETTER ZE
+ '\u0448' # 0xDB -> CYRILLIC SMALL LETTER SHA
+ '\u044d' # 0xDC -> CYRILLIC SMALL LETTER E
+ '\u0449' # 0xDD -> CYRILLIC SMALL LETTER SHCHA
+ '\u0447' # 0xDE -> CYRILLIC SMALL LETTER CHE
+ '\u044a' # 0xDF -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u042e' # 0xE0 -> CYRILLIC CAPITAL LETTER YU
+ '\u0410' # 0xE1 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0xE2 -> CYRILLIC CAPITAL LETTER BE
+ '\u0426' # 0xE3 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0414' # 0xE4 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0xE5 -> CYRILLIC CAPITAL LETTER IE
+ '\u0424' # 0xE6 -> CYRILLIC CAPITAL LETTER EF
+ '\u0413' # 0xE7 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0425' # 0xE8 -> CYRILLIC CAPITAL LETTER HA
+ '\u0418' # 0xE9 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0xEA -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0xEB -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0xEC -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0xED -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0xEE -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0xEF -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0xF0 -> CYRILLIC CAPITAL LETTER PE
+ '\u042f' # 0xF1 -> CYRILLIC CAPITAL LETTER YA
+ '\u0420' # 0xF2 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0xF3 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0xF4 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0xF5 -> CYRILLIC CAPITAL LETTER U
+ '\u0416' # 0xF6 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0412' # 0xF7 -> CYRILLIC CAPITAL LETTER VE
+ '\u042c' # 0xF8 -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042b' # 0xF9 -> CYRILLIC CAPITAL LETTER YERU
+ '\u0417' # 0xFA -> CYRILLIC CAPITAL LETTER ZE
+ '\u0428' # 0xFB -> CYRILLIC CAPITAL LETTER SHA
+ '\u042d' # 0xFC -> CYRILLIC CAPITAL LETTER E
+ '\u0429' # 0xFD -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u0427' # 0xFE -> CYRILLIC CAPITAL LETTER CHE
+ '\u042a' # 0xFF -> CYRILLIC CAPITAL LETTER HARD SIGN
)
### Encoding table
diff --git a/Lib/encodings/koi8_u.py b/Lib/encodings/koi8_u.py
index a9317b12b77..f9e3fae5fa2 100644
--- a/Lib/encodings/koi8_u.py
+++ b/Lib/encodings/koi8_u.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\u2500' # 0x80 -> BOX DRAWINGS LIGHT HORIZONTAL
- u'\u2502' # 0x81 -> BOX DRAWINGS LIGHT VERTICAL
- u'\u250c' # 0x82 -> BOX DRAWINGS LIGHT DOWN AND RIGHT
- u'\u2510' # 0x83 -> BOX DRAWINGS LIGHT DOWN AND LEFT
- u'\u2514' # 0x84 -> BOX DRAWINGS LIGHT UP AND RIGHT
- u'\u2518' # 0x85 -> BOX DRAWINGS LIGHT UP AND LEFT
- u'\u251c' # 0x86 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
- u'\u2524' # 0x87 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
- u'\u252c' # 0x88 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
- u'\u2534' # 0x89 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
- u'\u253c' # 0x8A -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
- u'\u2580' # 0x8B -> UPPER HALF BLOCK
- u'\u2584' # 0x8C -> LOWER HALF BLOCK
- u'\u2588' # 0x8D -> FULL BLOCK
- u'\u258c' # 0x8E -> LEFT HALF BLOCK
- u'\u2590' # 0x8F -> RIGHT HALF BLOCK
- u'\u2591' # 0x90 -> LIGHT SHADE
- u'\u2592' # 0x91 -> MEDIUM SHADE
- u'\u2593' # 0x92 -> DARK SHADE
- u'\u2320' # 0x93 -> TOP HALF INTEGRAL
- u'\u25a0' # 0x94 -> BLACK SQUARE
- u'\u2219' # 0x95 -> BULLET OPERATOR
- u'\u221a' # 0x96 -> SQUARE ROOT
- u'\u2248' # 0x97 -> ALMOST EQUAL TO
- u'\u2264' # 0x98 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0x99 -> GREATER-THAN OR EQUAL TO
- u'\xa0' # 0x9A -> NO-BREAK SPACE
- u'\u2321' # 0x9B -> BOTTOM HALF INTEGRAL
- u'\xb0' # 0x9C -> DEGREE SIGN
- u'\xb2' # 0x9D -> SUPERSCRIPT TWO
- u'\xb7' # 0x9E -> MIDDLE DOT
- u'\xf7' # 0x9F -> DIVISION SIGN
- u'\u2550' # 0xA0 -> BOX DRAWINGS DOUBLE HORIZONTAL
- u'\u2551' # 0xA1 -> BOX DRAWINGS DOUBLE VERTICAL
- u'\u2552' # 0xA2 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
- u'\u0451' # 0xA3 -> CYRILLIC SMALL LETTER IO
- u'\u0454' # 0xA4 -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\u2554' # 0xA5 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
- u'\u0456' # 0xA6 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0457' # 0xA7 -> CYRILLIC SMALL LETTER YI (UKRAINIAN)
- u'\u2557' # 0xA8 -> BOX DRAWINGS DOUBLE DOWN AND LEFT
- u'\u2558' # 0xA9 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
- u'\u2559' # 0xAA -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
- u'\u255a' # 0xAB -> BOX DRAWINGS DOUBLE UP AND RIGHT
- u'\u255b' # 0xAC -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
- u'\u0491' # 0xAD -> CYRILLIC SMALL LETTER UKRAINIAN GHE WITH UPTURN
- u'\u255d' # 0xAE -> BOX DRAWINGS DOUBLE UP AND LEFT
- u'\u255e' # 0xAF -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
- u'\u255f' # 0xB0 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
- u'\u2560' # 0xB1 -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
- u'\u2561' # 0xB2 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
- u'\u0401' # 0xB3 -> CYRILLIC CAPITAL LETTER IO
- u'\u0404' # 0xB4 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\u2563' # 0xB5 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
- u'\u0406' # 0xB6 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\u0407' # 0xB7 -> CYRILLIC CAPITAL LETTER YI (UKRAINIAN)
- u'\u2566' # 0xB8 -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
- u'\u2567' # 0xB9 -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
- u'\u2568' # 0xBA -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
- u'\u2569' # 0xBB -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
- u'\u256a' # 0xBC -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
- u'\u0490' # 0xBD -> CYRILLIC CAPITAL LETTER UKRAINIAN GHE WITH UPTURN
- u'\u256c' # 0xBE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
- u'\xa9' # 0xBF -> COPYRIGHT SIGN
- u'\u044e' # 0xC0 -> CYRILLIC SMALL LETTER YU
- u'\u0430' # 0xC1 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0xC2 -> CYRILLIC SMALL LETTER BE
- u'\u0446' # 0xC3 -> CYRILLIC SMALL LETTER TSE
- u'\u0434' # 0xC4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0xC5 -> CYRILLIC SMALL LETTER IE
- u'\u0444' # 0xC6 -> CYRILLIC SMALL LETTER EF
- u'\u0433' # 0xC7 -> CYRILLIC SMALL LETTER GHE
- u'\u0445' # 0xC8 -> CYRILLIC SMALL LETTER HA
- u'\u0438' # 0xC9 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0xCA -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0xCB -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0xCC -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0xCD -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0xCE -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0xCF -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0xD0 -> CYRILLIC SMALL LETTER PE
- u'\u044f' # 0xD1 -> CYRILLIC SMALL LETTER YA
- u'\u0440' # 0xD2 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0xD3 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0xD4 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0xD5 -> CYRILLIC SMALL LETTER U
- u'\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0432' # 0xD7 -> CYRILLIC SMALL LETTER VE
- u'\u044c' # 0xD8 -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044b' # 0xD9 -> CYRILLIC SMALL LETTER YERU
- u'\u0437' # 0xDA -> CYRILLIC SMALL LETTER ZE
- u'\u0448' # 0xDB -> CYRILLIC SMALL LETTER SHA
- u'\u044d' # 0xDC -> CYRILLIC SMALL LETTER E
- u'\u0449' # 0xDD -> CYRILLIC SMALL LETTER SHCHA
- u'\u0447' # 0xDE -> CYRILLIC SMALL LETTER CHE
- u'\u044a' # 0xDF -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u042e' # 0xE0 -> CYRILLIC CAPITAL LETTER YU
- u'\u0410' # 0xE1 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0xE2 -> CYRILLIC CAPITAL LETTER BE
- u'\u0426' # 0xE3 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0414' # 0xE4 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0xE5 -> CYRILLIC CAPITAL LETTER IE
- u'\u0424' # 0xE6 -> CYRILLIC CAPITAL LETTER EF
- u'\u0413' # 0xE7 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0425' # 0xE8 -> CYRILLIC CAPITAL LETTER HA
- u'\u0418' # 0xE9 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0xEA -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0xEB -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0xEC -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0xED -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0xEE -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0xEF -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0xF0 -> CYRILLIC CAPITAL LETTER PE
- u'\u042f' # 0xF1 -> CYRILLIC CAPITAL LETTER YA
- u'\u0420' # 0xF2 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0xF3 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0xF4 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0xF5 -> CYRILLIC CAPITAL LETTER U
- u'\u0416' # 0xF6 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0412' # 0xF7 -> CYRILLIC CAPITAL LETTER VE
- u'\u042c' # 0xF8 -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042b' # 0xF9 -> CYRILLIC CAPITAL LETTER YERU
- u'\u0417' # 0xFA -> CYRILLIC CAPITAL LETTER ZE
- u'\u0428' # 0xFB -> CYRILLIC CAPITAL LETTER SHA
- u'\u042d' # 0xFC -> CYRILLIC CAPITAL LETTER E
- u'\u0429' # 0xFD -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u0427' # 0xFE -> CYRILLIC CAPITAL LETTER CHE
- u'\u042a' # 0xFF -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\u2500' # 0x80 -> BOX DRAWINGS LIGHT HORIZONTAL
+ '\u2502' # 0x81 -> BOX DRAWINGS LIGHT VERTICAL
+ '\u250c' # 0x82 -> BOX DRAWINGS LIGHT DOWN AND RIGHT
+ '\u2510' # 0x83 -> BOX DRAWINGS LIGHT DOWN AND LEFT
+ '\u2514' # 0x84 -> BOX DRAWINGS LIGHT UP AND RIGHT
+ '\u2518' # 0x85 -> BOX DRAWINGS LIGHT UP AND LEFT
+ '\u251c' # 0x86 -> BOX DRAWINGS LIGHT VERTICAL AND RIGHT
+ '\u2524' # 0x87 -> BOX DRAWINGS LIGHT VERTICAL AND LEFT
+ '\u252c' # 0x88 -> BOX DRAWINGS LIGHT DOWN AND HORIZONTAL
+ '\u2534' # 0x89 -> BOX DRAWINGS LIGHT UP AND HORIZONTAL
+ '\u253c' # 0x8A -> BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL
+ '\u2580' # 0x8B -> UPPER HALF BLOCK
+ '\u2584' # 0x8C -> LOWER HALF BLOCK
+ '\u2588' # 0x8D -> FULL BLOCK
+ '\u258c' # 0x8E -> LEFT HALF BLOCK
+ '\u2590' # 0x8F -> RIGHT HALF BLOCK
+ '\u2591' # 0x90 -> LIGHT SHADE
+ '\u2592' # 0x91 -> MEDIUM SHADE
+ '\u2593' # 0x92 -> DARK SHADE
+ '\u2320' # 0x93 -> TOP HALF INTEGRAL
+ '\u25a0' # 0x94 -> BLACK SQUARE
+ '\u2219' # 0x95 -> BULLET OPERATOR
+ '\u221a' # 0x96 -> SQUARE ROOT
+ '\u2248' # 0x97 -> ALMOST EQUAL TO
+ '\u2264' # 0x98 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0x99 -> GREATER-THAN OR EQUAL TO
+ '\xa0' # 0x9A -> NO-BREAK SPACE
+ '\u2321' # 0x9B -> BOTTOM HALF INTEGRAL
+ '\xb0' # 0x9C -> DEGREE SIGN
+ '\xb2' # 0x9D -> SUPERSCRIPT TWO
+ '\xb7' # 0x9E -> MIDDLE DOT
+ '\xf7' # 0x9F -> DIVISION SIGN
+ '\u2550' # 0xA0 -> BOX DRAWINGS DOUBLE HORIZONTAL
+ '\u2551' # 0xA1 -> BOX DRAWINGS DOUBLE VERTICAL
+ '\u2552' # 0xA2 -> BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE
+ '\u0451' # 0xA3 -> CYRILLIC SMALL LETTER IO
+ '\u0454' # 0xA4 -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\u2554' # 0xA5 -> BOX DRAWINGS DOUBLE DOWN AND RIGHT
+ '\u0456' # 0xA6 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0457' # 0xA7 -> CYRILLIC SMALL LETTER YI (UKRAINIAN)
+ '\u2557' # 0xA8 -> BOX DRAWINGS DOUBLE DOWN AND LEFT
+ '\u2558' # 0xA9 -> BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE
+ '\u2559' # 0xAA -> BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE
+ '\u255a' # 0xAB -> BOX DRAWINGS DOUBLE UP AND RIGHT
+ '\u255b' # 0xAC -> BOX DRAWINGS UP SINGLE AND LEFT DOUBLE
+ '\u0491' # 0xAD -> CYRILLIC SMALL LETTER UKRAINIAN GHE WITH UPTURN
+ '\u255d' # 0xAE -> BOX DRAWINGS DOUBLE UP AND LEFT
+ '\u255e' # 0xAF -> BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE
+ '\u255f' # 0xB0 -> BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE
+ '\u2560' # 0xB1 -> BOX DRAWINGS DOUBLE VERTICAL AND RIGHT
+ '\u2561' # 0xB2 -> BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE
+ '\u0401' # 0xB3 -> CYRILLIC CAPITAL LETTER IO
+ '\u0404' # 0xB4 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\u2563' # 0xB5 -> BOX DRAWINGS DOUBLE VERTICAL AND LEFT
+ '\u0406' # 0xB6 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\u0407' # 0xB7 -> CYRILLIC CAPITAL LETTER YI (UKRAINIAN)
+ '\u2566' # 0xB8 -> BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL
+ '\u2567' # 0xB9 -> BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE
+ '\u2568' # 0xBA -> BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE
+ '\u2569' # 0xBB -> BOX DRAWINGS DOUBLE UP AND HORIZONTAL
+ '\u256a' # 0xBC -> BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE
+ '\u0490' # 0xBD -> CYRILLIC CAPITAL LETTER UKRAINIAN GHE WITH UPTURN
+ '\u256c' # 0xBE -> BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL
+ '\xa9' # 0xBF -> COPYRIGHT SIGN
+ '\u044e' # 0xC0 -> CYRILLIC SMALL LETTER YU
+ '\u0430' # 0xC1 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0xC2 -> CYRILLIC SMALL LETTER BE
+ '\u0446' # 0xC3 -> CYRILLIC SMALL LETTER TSE
+ '\u0434' # 0xC4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0xC5 -> CYRILLIC SMALL LETTER IE
+ '\u0444' # 0xC6 -> CYRILLIC SMALL LETTER EF
+ '\u0433' # 0xC7 -> CYRILLIC SMALL LETTER GHE
+ '\u0445' # 0xC8 -> CYRILLIC SMALL LETTER HA
+ '\u0438' # 0xC9 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0xCA -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0xCB -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0xCC -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0xCD -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0xCE -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0xCF -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0xD0 -> CYRILLIC SMALL LETTER PE
+ '\u044f' # 0xD1 -> CYRILLIC SMALL LETTER YA
+ '\u0440' # 0xD2 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0xD3 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0xD4 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0xD5 -> CYRILLIC SMALL LETTER U
+ '\u0436' # 0xD6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0432' # 0xD7 -> CYRILLIC SMALL LETTER VE
+ '\u044c' # 0xD8 -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044b' # 0xD9 -> CYRILLIC SMALL LETTER YERU
+ '\u0437' # 0xDA -> CYRILLIC SMALL LETTER ZE
+ '\u0448' # 0xDB -> CYRILLIC SMALL LETTER SHA
+ '\u044d' # 0xDC -> CYRILLIC SMALL LETTER E
+ '\u0449' # 0xDD -> CYRILLIC SMALL LETTER SHCHA
+ '\u0447' # 0xDE -> CYRILLIC SMALL LETTER CHE
+ '\u044a' # 0xDF -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u042e' # 0xE0 -> CYRILLIC CAPITAL LETTER YU
+ '\u0410' # 0xE1 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0xE2 -> CYRILLIC CAPITAL LETTER BE
+ '\u0426' # 0xE3 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0414' # 0xE4 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0xE5 -> CYRILLIC CAPITAL LETTER IE
+ '\u0424' # 0xE6 -> CYRILLIC CAPITAL LETTER EF
+ '\u0413' # 0xE7 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0425' # 0xE8 -> CYRILLIC CAPITAL LETTER HA
+ '\u0418' # 0xE9 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0xEA -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0xEB -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0xEC -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0xED -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0xEE -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0xEF -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0xF0 -> CYRILLIC CAPITAL LETTER PE
+ '\u042f' # 0xF1 -> CYRILLIC CAPITAL LETTER YA
+ '\u0420' # 0xF2 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0xF3 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0xF4 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0xF5 -> CYRILLIC CAPITAL LETTER U
+ '\u0416' # 0xF6 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0412' # 0xF7 -> CYRILLIC CAPITAL LETTER VE
+ '\u042c' # 0xF8 -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042b' # 0xF9 -> CYRILLIC CAPITAL LETTER YERU
+ '\u0417' # 0xFA -> CYRILLIC CAPITAL LETTER ZE
+ '\u0428' # 0xFB -> CYRILLIC CAPITAL LETTER SHA
+ '\u042d' # 0xFC -> CYRILLIC CAPITAL LETTER E
+ '\u0429' # 0xFD -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u0427' # 0xFE -> CYRILLIC CAPITAL LETTER CHE
+ '\u042a' # 0xFF -> CYRILLIC CAPITAL LETTER HARD SIGN
)
### Encoding table
diff --git a/Lib/encodings/mac_arabic.py b/Lib/encodings/mac_arabic.py
index 7a7d3c5f7fe..72847e859c4 100644
--- a/Lib/encodings/mac_arabic.py
+++ b/Lib/encodings/mac_arabic.py
@@ -178,262 +178,262 @@ decoding_map.update({
### Decoding Table
decoding_table = (
- u'\x00' # 0x0000 -> CONTROL CHARACTER
- u'\x01' # 0x0001 -> CONTROL CHARACTER
- u'\x02' # 0x0002 -> CONTROL CHARACTER
- u'\x03' # 0x0003 -> CONTROL CHARACTER
- u'\x04' # 0x0004 -> CONTROL CHARACTER
- u'\x05' # 0x0005 -> CONTROL CHARACTER
- u'\x06' # 0x0006 -> CONTROL CHARACTER
- u'\x07' # 0x0007 -> CONTROL CHARACTER
- u'\x08' # 0x0008 -> CONTROL CHARACTER
- u'\t' # 0x0009 -> CONTROL CHARACTER
- u'\n' # 0x000a -> CONTROL CHARACTER
- u'\x0b' # 0x000b -> CONTROL CHARACTER
- u'\x0c' # 0x000c -> CONTROL CHARACTER
- u'\r' # 0x000d -> CONTROL CHARACTER
- u'\x0e' # 0x000e -> CONTROL CHARACTER
- u'\x0f' # 0x000f -> CONTROL CHARACTER
- u'\x10' # 0x0010 -> CONTROL CHARACTER
- u'\x11' # 0x0011 -> CONTROL CHARACTER
- u'\x12' # 0x0012 -> CONTROL CHARACTER
- u'\x13' # 0x0013 -> CONTROL CHARACTER
- u'\x14' # 0x0014 -> CONTROL CHARACTER
- u'\x15' # 0x0015 -> CONTROL CHARACTER
- u'\x16' # 0x0016 -> CONTROL CHARACTER
- u'\x17' # 0x0017 -> CONTROL CHARACTER
- u'\x18' # 0x0018 -> CONTROL CHARACTER
- u'\x19' # 0x0019 -> CONTROL CHARACTER
- u'\x1a' # 0x001a -> CONTROL CHARACTER
- u'\x1b' # 0x001b -> CONTROL CHARACTER
- u'\x1c' # 0x001c -> CONTROL CHARACTER
- u'\x1d' # 0x001d -> CONTROL CHARACTER
- u'\x1e' # 0x001e -> CONTROL CHARACTER
- u'\x1f' # 0x001f -> CONTROL CHARACTER
- u' ' # 0x0020 -> SPACE, left-right
- u'!' # 0x0021 -> EXCLAMATION MARK, left-right
- u'"' # 0x0022 -> QUOTATION MARK, left-right
- u'#' # 0x0023 -> NUMBER SIGN, left-right
- u'$' # 0x0024 -> DOLLAR SIGN, left-right
- u'%' # 0x0025 -> PERCENT SIGN, left-right
- u'&' # 0x0026 -> AMPERSAND, left-right
- u"'" # 0x0027 -> APOSTROPHE, left-right
- u'(' # 0x0028 -> LEFT PARENTHESIS, left-right
- u')' # 0x0029 -> RIGHT PARENTHESIS, left-right
- u'*' # 0x002a -> ASTERISK, left-right
- u'+' # 0x002b -> PLUS SIGN, left-right
- u',' # 0x002c -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR
- u'-' # 0x002d -> HYPHEN-MINUS, left-right
- u'.' # 0x002e -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR
- u'/' # 0x002f -> SOLIDUS, left-right
- u'0' # 0x0030 -> DIGIT ZERO; in Arabic-script context, displayed as 0x0660 ARABIC-INDIC DIGIT ZERO
- u'1' # 0x0031 -> DIGIT ONE; in Arabic-script context, displayed as 0x0661 ARABIC-INDIC DIGIT ONE
- u'2' # 0x0032 -> DIGIT TWO; in Arabic-script context, displayed as 0x0662 ARABIC-INDIC DIGIT TWO
- u'3' # 0x0033 -> DIGIT THREE; in Arabic-script context, displayed as 0x0663 ARABIC-INDIC DIGIT THREE
- u'4' # 0x0034 -> DIGIT FOUR; in Arabic-script context, displayed as 0x0664 ARABIC-INDIC DIGIT FOUR
- u'5' # 0x0035 -> DIGIT FIVE; in Arabic-script context, displayed as 0x0665 ARABIC-INDIC DIGIT FIVE
- u'6' # 0x0036 -> DIGIT SIX; in Arabic-script context, displayed as 0x0666 ARABIC-INDIC DIGIT SIX
- u'7' # 0x0037 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x0667 ARABIC-INDIC DIGIT SEVEN
- u'8' # 0x0038 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x0668 ARABIC-INDIC DIGIT EIGHT
- u'9' # 0x0039 -> DIGIT NINE; in Arabic-script context, displayed as 0x0669 ARABIC-INDIC DIGIT NINE
- u':' # 0x003a -> COLON, left-right
- u';' # 0x003b -> SEMICOLON, left-right
- u'<' # 0x003c -> LESS-THAN SIGN, left-right
- u'=' # 0x003d -> EQUALS SIGN, left-right
- u'>' # 0x003e -> GREATER-THAN SIGN, left-right
- u'?' # 0x003f -> QUESTION MARK, left-right
- u'@' # 0x0040 -> COMMERCIAL AT
- u'A' # 0x0041 -> LATIN CAPITAL LETTER A
- u'B' # 0x0042 -> LATIN CAPITAL LETTER B
- u'C' # 0x0043 -> LATIN CAPITAL LETTER C
- u'D' # 0x0044 -> LATIN CAPITAL LETTER D
- u'E' # 0x0045 -> LATIN CAPITAL LETTER E
- u'F' # 0x0046 -> LATIN CAPITAL LETTER F
- u'G' # 0x0047 -> LATIN CAPITAL LETTER G
- u'H' # 0x0048 -> LATIN CAPITAL LETTER H
- u'I' # 0x0049 -> LATIN CAPITAL LETTER I
- u'J' # 0x004a -> LATIN CAPITAL LETTER J
- u'K' # 0x004b -> LATIN CAPITAL LETTER K
- u'L' # 0x004c -> LATIN CAPITAL LETTER L
- u'M' # 0x004d -> LATIN CAPITAL LETTER M
- u'N' # 0x004e -> LATIN CAPITAL LETTER N
- u'O' # 0x004f -> LATIN CAPITAL LETTER O
- u'P' # 0x0050 -> LATIN CAPITAL LETTER P
- u'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
- u'R' # 0x0052 -> LATIN CAPITAL LETTER R
- u'S' # 0x0053 -> LATIN CAPITAL LETTER S
- u'T' # 0x0054 -> LATIN CAPITAL LETTER T
- u'U' # 0x0055 -> LATIN CAPITAL LETTER U
- u'V' # 0x0056 -> LATIN CAPITAL LETTER V
- u'W' # 0x0057 -> LATIN CAPITAL LETTER W
- u'X' # 0x0058 -> LATIN CAPITAL LETTER X
- u'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x005a -> LATIN CAPITAL LETTER Z
- u'[' # 0x005b -> LEFT SQUARE BRACKET, left-right
- u'\\' # 0x005c -> REVERSE SOLIDUS, left-right
- u']' # 0x005d -> RIGHT SQUARE BRACKET, left-right
- u'^' # 0x005e -> CIRCUMFLEX ACCENT, left-right
- u'_' # 0x005f -> LOW LINE, left-right
- u'`' # 0x0060 -> GRAVE ACCENT
- u'a' # 0x0061 -> LATIN SMALL LETTER A
- u'b' # 0x0062 -> LATIN SMALL LETTER B
- u'c' # 0x0063 -> LATIN SMALL LETTER C
- u'd' # 0x0064 -> LATIN SMALL LETTER D
- u'e' # 0x0065 -> LATIN SMALL LETTER E
- u'f' # 0x0066 -> LATIN SMALL LETTER F
- u'g' # 0x0067 -> LATIN SMALL LETTER G
- u'h' # 0x0068 -> LATIN SMALL LETTER H
- u'i' # 0x0069 -> LATIN SMALL LETTER I
- u'j' # 0x006a -> LATIN SMALL LETTER J
- u'k' # 0x006b -> LATIN SMALL LETTER K
- u'l' # 0x006c -> LATIN SMALL LETTER L
- u'm' # 0x006d -> LATIN SMALL LETTER M
- u'n' # 0x006e -> LATIN SMALL LETTER N
- u'o' # 0x006f -> LATIN SMALL LETTER O
- u'p' # 0x0070 -> LATIN SMALL LETTER P
- u'q' # 0x0071 -> LATIN SMALL LETTER Q
- u'r' # 0x0072 -> LATIN SMALL LETTER R
- u's' # 0x0073 -> LATIN SMALL LETTER S
- u't' # 0x0074 -> LATIN SMALL LETTER T
- u'u' # 0x0075 -> LATIN SMALL LETTER U
- u'v' # 0x0076 -> LATIN SMALL LETTER V
- u'w' # 0x0077 -> LATIN SMALL LETTER W
- u'x' # 0x0078 -> LATIN SMALL LETTER X
- u'y' # 0x0079 -> LATIN SMALL LETTER Y
- u'z' # 0x007a -> LATIN SMALL LETTER Z
- u'{' # 0x007b -> LEFT CURLY BRACKET, left-right
- u'|' # 0x007c -> VERTICAL LINE, left-right
- u'}' # 0x007d -> RIGHT CURLY BRACKET, left-right
- u'~' # 0x007e -> TILDE
- u'\x7f' # 0x007f -> CONTROL CHARACTER
- u'\xc4' # 0x0080 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xa0' # 0x0081 -> NO-BREAK SPACE, right-left
- u'\xc7' # 0x0082 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x0083 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x0084 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x0085 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x0086 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x0087 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x0088 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x0089 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x008a -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u06ba' # 0x008b -> ARABIC LETTER NOON GHUNNA
- u'\xab' # 0x008c -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
- u'\xe7' # 0x008d -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x008e -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x008f -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x0090 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x0091 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x0092 -> LATIN SMALL LETTER I WITH ACUTE
- u'\u2026' # 0x0093 -> HORIZONTAL ELLIPSIS, right-left
- u'\xee' # 0x0094 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x0095 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x0096 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x0097 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xbb' # 0x0098 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
- u'\xf4' # 0x0099 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x009a -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0x009b -> DIVISION SIGN, right-left
- u'\xfa' # 0x009c -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x009d -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x009e -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x009f -> LATIN SMALL LETTER U WITH DIAERESIS
- u' ' # 0x00a0 -> SPACE, right-left
- u'!' # 0x00a1 -> EXCLAMATION MARK, right-left
- u'"' # 0x00a2 -> QUOTATION MARK, right-left
- u'#' # 0x00a3 -> NUMBER SIGN, right-left
- u'$' # 0x00a4 -> DOLLAR SIGN, right-left
- u'\u066a' # 0x00a5 -> ARABIC PERCENT SIGN
- u'&' # 0x00a6 -> AMPERSAND, right-left
- u"'" # 0x00a7 -> APOSTROPHE, right-left
- u'(' # 0x00a8 -> LEFT PARENTHESIS, right-left
- u')' # 0x00a9 -> RIGHT PARENTHESIS, right-left
- u'*' # 0x00aa -> ASTERISK, right-left
- u'+' # 0x00ab -> PLUS SIGN, right-left
- u'\u060c' # 0x00ac -> ARABIC COMMA
- u'-' # 0x00ad -> HYPHEN-MINUS, right-left
- u'.' # 0x00ae -> FULL STOP, right-left
- u'/' # 0x00af -> SOLIDUS, right-left
- u'\u0660' # 0x00b0 -> ARABIC-INDIC DIGIT ZERO, right-left (need override)
- u'\u0661' # 0x00b1 -> ARABIC-INDIC DIGIT ONE, right-left (need override)
- u'\u0662' # 0x00b2 -> ARABIC-INDIC DIGIT TWO, right-left (need override)
- u'\u0663' # 0x00b3 -> ARABIC-INDIC DIGIT THREE, right-left (need override)
- u'\u0664' # 0x00b4 -> ARABIC-INDIC DIGIT FOUR, right-left (need override)
- u'\u0665' # 0x00b5 -> ARABIC-INDIC DIGIT FIVE, right-left (need override)
- u'\u0666' # 0x00b6 -> ARABIC-INDIC DIGIT SIX, right-left (need override)
- u'\u0667' # 0x00b7 -> ARABIC-INDIC DIGIT SEVEN, right-left (need override)
- u'\u0668' # 0x00b8 -> ARABIC-INDIC DIGIT EIGHT, right-left (need override)
- u'\u0669' # 0x00b9 -> ARABIC-INDIC DIGIT NINE, right-left (need override)
- u':' # 0x00ba -> COLON, right-left
- u'\u061b' # 0x00bb -> ARABIC SEMICOLON
- u'<' # 0x00bc -> LESS-THAN SIGN, right-left
- u'=' # 0x00bd -> EQUALS SIGN, right-left
- u'>' # 0x00be -> GREATER-THAN SIGN, right-left
- u'\u061f' # 0x00bf -> ARABIC QUESTION MARK
- u'\u274a' # 0x00c0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
- u'\u0621' # 0x00c1 -> ARABIC LETTER HAMZA
- u'\u0622' # 0x00c2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
- u'\u0623' # 0x00c3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
- u'\u0624' # 0x00c4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
- u'\u0625' # 0x00c5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
- u'\u0626' # 0x00c6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
- u'\u0627' # 0x00c7 -> ARABIC LETTER ALEF
- u'\u0628' # 0x00c8 -> ARABIC LETTER BEH
- u'\u0629' # 0x00c9 -> ARABIC LETTER TEH MARBUTA
- u'\u062a' # 0x00ca -> ARABIC LETTER TEH
- u'\u062b' # 0x00cb -> ARABIC LETTER THEH
- u'\u062c' # 0x00cc -> ARABIC LETTER JEEM
- u'\u062d' # 0x00cd -> ARABIC LETTER HAH
- u'\u062e' # 0x00ce -> ARABIC LETTER KHAH
- u'\u062f' # 0x00cf -> ARABIC LETTER DAL
- u'\u0630' # 0x00d0 -> ARABIC LETTER THAL
- u'\u0631' # 0x00d1 -> ARABIC LETTER REH
- u'\u0632' # 0x00d2 -> ARABIC LETTER ZAIN
- u'\u0633' # 0x00d3 -> ARABIC LETTER SEEN
- u'\u0634' # 0x00d4 -> ARABIC LETTER SHEEN
- u'\u0635' # 0x00d5 -> ARABIC LETTER SAD
- u'\u0636' # 0x00d6 -> ARABIC LETTER DAD
- u'\u0637' # 0x00d7 -> ARABIC LETTER TAH
- u'\u0638' # 0x00d8 -> ARABIC LETTER ZAH
- u'\u0639' # 0x00d9 -> ARABIC LETTER AIN
- u'\u063a' # 0x00da -> ARABIC LETTER GHAIN
- u'[' # 0x00db -> LEFT SQUARE BRACKET, right-left
- u'\\' # 0x00dc -> REVERSE SOLIDUS, right-left
- u']' # 0x00dd -> RIGHT SQUARE BRACKET, right-left
- u'^' # 0x00de -> CIRCUMFLEX ACCENT, right-left
- u'_' # 0x00df -> LOW LINE, right-left
- u'\u0640' # 0x00e0 -> ARABIC TATWEEL
- u'\u0641' # 0x00e1 -> ARABIC LETTER FEH
- u'\u0642' # 0x00e2 -> ARABIC LETTER QAF
- u'\u0643' # 0x00e3 -> ARABIC LETTER KAF
- u'\u0644' # 0x00e4 -> ARABIC LETTER LAM
- u'\u0645' # 0x00e5 -> ARABIC LETTER MEEM
- u'\u0646' # 0x00e6 -> ARABIC LETTER NOON
- u'\u0647' # 0x00e7 -> ARABIC LETTER HEH
- u'\u0648' # 0x00e8 -> ARABIC LETTER WAW
- u'\u0649' # 0x00e9 -> ARABIC LETTER ALEF MAKSURA
- u'\u064a' # 0x00ea -> ARABIC LETTER YEH
- u'\u064b' # 0x00eb -> ARABIC FATHATAN
- u'\u064c' # 0x00ec -> ARABIC DAMMATAN
- u'\u064d' # 0x00ed -> ARABIC KASRATAN
- u'\u064e' # 0x00ee -> ARABIC FATHA
- u'\u064f' # 0x00ef -> ARABIC DAMMA
- u'\u0650' # 0x00f0 -> ARABIC KASRA
- u'\u0651' # 0x00f1 -> ARABIC SHADDA
- u'\u0652' # 0x00f2 -> ARABIC SUKUN
- u'\u067e' # 0x00f3 -> ARABIC LETTER PEH
- u'\u0679' # 0x00f4 -> ARABIC LETTER TTEH
- u'\u0686' # 0x00f5 -> ARABIC LETTER TCHEH
- u'\u06d5' # 0x00f6 -> ARABIC LETTER AE
- u'\u06a4' # 0x00f7 -> ARABIC LETTER VEH
- u'\u06af' # 0x00f8 -> ARABIC LETTER GAF
- u'\u0688' # 0x00f9 -> ARABIC LETTER DDAL
- u'\u0691' # 0x00fa -> ARABIC LETTER RREH
- u'{' # 0x00fb -> LEFT CURLY BRACKET, right-left
- u'|' # 0x00fc -> VERTICAL LINE, right-left
- u'}' # 0x00fd -> RIGHT CURLY BRACKET, right-left
- u'\u0698' # 0x00fe -> ARABIC LETTER JEH
- u'\u06d2' # 0x00ff -> ARABIC LETTER YEH BARREE
+ '\x00' # 0x0000 -> CONTROL CHARACTER
+ '\x01' # 0x0001 -> CONTROL CHARACTER
+ '\x02' # 0x0002 -> CONTROL CHARACTER
+ '\x03' # 0x0003 -> CONTROL CHARACTER
+ '\x04' # 0x0004 -> CONTROL CHARACTER
+ '\x05' # 0x0005 -> CONTROL CHARACTER
+ '\x06' # 0x0006 -> CONTROL CHARACTER
+ '\x07' # 0x0007 -> CONTROL CHARACTER
+ '\x08' # 0x0008 -> CONTROL CHARACTER
+ '\t' # 0x0009 -> CONTROL CHARACTER
+ '\n' # 0x000a -> CONTROL CHARACTER
+ '\x0b' # 0x000b -> CONTROL CHARACTER
+ '\x0c' # 0x000c -> CONTROL CHARACTER
+ '\r' # 0x000d -> CONTROL CHARACTER
+ '\x0e' # 0x000e -> CONTROL CHARACTER
+ '\x0f' # 0x000f -> CONTROL CHARACTER
+ '\x10' # 0x0010 -> CONTROL CHARACTER
+ '\x11' # 0x0011 -> CONTROL CHARACTER
+ '\x12' # 0x0012 -> CONTROL CHARACTER
+ '\x13' # 0x0013 -> CONTROL CHARACTER
+ '\x14' # 0x0014 -> CONTROL CHARACTER
+ '\x15' # 0x0015 -> CONTROL CHARACTER
+ '\x16' # 0x0016 -> CONTROL CHARACTER
+ '\x17' # 0x0017 -> CONTROL CHARACTER
+ '\x18' # 0x0018 -> CONTROL CHARACTER
+ '\x19' # 0x0019 -> CONTROL CHARACTER
+ '\x1a' # 0x001a -> CONTROL CHARACTER
+ '\x1b' # 0x001b -> CONTROL CHARACTER
+ '\x1c' # 0x001c -> CONTROL CHARACTER
+ '\x1d' # 0x001d -> CONTROL CHARACTER
+ '\x1e' # 0x001e -> CONTROL CHARACTER
+ '\x1f' # 0x001f -> CONTROL CHARACTER
+ ' ' # 0x0020 -> SPACE, left-right
+ '!' # 0x0021 -> EXCLAMATION MARK, left-right
+ '"' # 0x0022 -> QUOTATION MARK, left-right
+ '#' # 0x0023 -> NUMBER SIGN, left-right
+ '$' # 0x0024 -> DOLLAR SIGN, left-right
+ '%' # 0x0025 -> PERCENT SIGN, left-right
+ '&' # 0x0026 -> AMPERSAND, left-right
+ "'" # 0x0027 -> APOSTROPHE, left-right
+ '(' # 0x0028 -> LEFT PARENTHESIS, left-right
+ ')' # 0x0029 -> RIGHT PARENTHESIS, left-right
+ '*' # 0x002a -> ASTERISK, left-right
+ '+' # 0x002b -> PLUS SIGN, left-right
+ ',' # 0x002c -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR
+ '-' # 0x002d -> HYPHEN-MINUS, left-right
+ '.' # 0x002e -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR
+ '/' # 0x002f -> SOLIDUS, left-right
+ '0' # 0x0030 -> DIGIT ZERO; in Arabic-script context, displayed as 0x0660 ARABIC-INDIC DIGIT ZERO
+ '1' # 0x0031 -> DIGIT ONE; in Arabic-script context, displayed as 0x0661 ARABIC-INDIC DIGIT ONE
+ '2' # 0x0032 -> DIGIT TWO; in Arabic-script context, displayed as 0x0662 ARABIC-INDIC DIGIT TWO
+ '3' # 0x0033 -> DIGIT THREE; in Arabic-script context, displayed as 0x0663 ARABIC-INDIC DIGIT THREE
+ '4' # 0x0034 -> DIGIT FOUR; in Arabic-script context, displayed as 0x0664 ARABIC-INDIC DIGIT FOUR
+ '5' # 0x0035 -> DIGIT FIVE; in Arabic-script context, displayed as 0x0665 ARABIC-INDIC DIGIT FIVE
+ '6' # 0x0036 -> DIGIT SIX; in Arabic-script context, displayed as 0x0666 ARABIC-INDIC DIGIT SIX
+ '7' # 0x0037 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x0667 ARABIC-INDIC DIGIT SEVEN
+ '8' # 0x0038 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x0668 ARABIC-INDIC DIGIT EIGHT
+ '9' # 0x0039 -> DIGIT NINE; in Arabic-script context, displayed as 0x0669 ARABIC-INDIC DIGIT NINE
+ ':' # 0x003a -> COLON, left-right
+ ';' # 0x003b -> SEMICOLON, left-right
+ '<' # 0x003c -> LESS-THAN SIGN, left-right
+ '=' # 0x003d -> EQUALS SIGN, left-right
+ '>' # 0x003e -> GREATER-THAN SIGN, left-right
+ '?' # 0x003f -> QUESTION MARK, left-right
+ '@' # 0x0040 -> COMMERCIAL AT
+ 'A' # 0x0041 -> LATIN CAPITAL LETTER A
+ 'B' # 0x0042 -> LATIN CAPITAL LETTER B
+ 'C' # 0x0043 -> LATIN CAPITAL LETTER C
+ 'D' # 0x0044 -> LATIN CAPITAL LETTER D
+ 'E' # 0x0045 -> LATIN CAPITAL LETTER E
+ 'F' # 0x0046 -> LATIN CAPITAL LETTER F
+ 'G' # 0x0047 -> LATIN CAPITAL LETTER G
+ 'H' # 0x0048 -> LATIN CAPITAL LETTER H
+ 'I' # 0x0049 -> LATIN CAPITAL LETTER I
+ 'J' # 0x004a -> LATIN CAPITAL LETTER J
+ 'K' # 0x004b -> LATIN CAPITAL LETTER K
+ 'L' # 0x004c -> LATIN CAPITAL LETTER L
+ 'M' # 0x004d -> LATIN CAPITAL LETTER M
+ 'N' # 0x004e -> LATIN CAPITAL LETTER N
+ 'O' # 0x004f -> LATIN CAPITAL LETTER O
+ 'P' # 0x0050 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x0051 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x0052 -> LATIN CAPITAL LETTER R
+ 'S' # 0x0053 -> LATIN CAPITAL LETTER S
+ 'T' # 0x0054 -> LATIN CAPITAL LETTER T
+ 'U' # 0x0055 -> LATIN CAPITAL LETTER U
+ 'V' # 0x0056 -> LATIN CAPITAL LETTER V
+ 'W' # 0x0057 -> LATIN CAPITAL LETTER W
+ 'X' # 0x0058 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x0059 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x005a -> LATIN CAPITAL LETTER Z
+ '[' # 0x005b -> LEFT SQUARE BRACKET, left-right
+ '\\' # 0x005c -> REVERSE SOLIDUS, left-right
+ ']' # 0x005d -> RIGHT SQUARE BRACKET, left-right
+ '^' # 0x005e -> CIRCUMFLEX ACCENT, left-right
+ '_' # 0x005f -> LOW LINE, left-right
+ '`' # 0x0060 -> GRAVE ACCENT
+ 'a' # 0x0061 -> LATIN SMALL LETTER A
+ 'b' # 0x0062 -> LATIN SMALL LETTER B
+ 'c' # 0x0063 -> LATIN SMALL LETTER C
+ 'd' # 0x0064 -> LATIN SMALL LETTER D
+ 'e' # 0x0065 -> LATIN SMALL LETTER E
+ 'f' # 0x0066 -> LATIN SMALL LETTER F
+ 'g' # 0x0067 -> LATIN SMALL LETTER G
+ 'h' # 0x0068 -> LATIN SMALL LETTER H
+ 'i' # 0x0069 -> LATIN SMALL LETTER I
+ 'j' # 0x006a -> LATIN SMALL LETTER J
+ 'k' # 0x006b -> LATIN SMALL LETTER K
+ 'l' # 0x006c -> LATIN SMALL LETTER L
+ 'm' # 0x006d -> LATIN SMALL LETTER M
+ 'n' # 0x006e -> LATIN SMALL LETTER N
+ 'o' # 0x006f -> LATIN SMALL LETTER O
+ 'p' # 0x0070 -> LATIN SMALL LETTER P
+ 'q' # 0x0071 -> LATIN SMALL LETTER Q
+ 'r' # 0x0072 -> LATIN SMALL LETTER R
+ 's' # 0x0073 -> LATIN SMALL LETTER S
+ 't' # 0x0074 -> LATIN SMALL LETTER T
+ 'u' # 0x0075 -> LATIN SMALL LETTER U
+ 'v' # 0x0076 -> LATIN SMALL LETTER V
+ 'w' # 0x0077 -> LATIN SMALL LETTER W
+ 'x' # 0x0078 -> LATIN SMALL LETTER X
+ 'y' # 0x0079 -> LATIN SMALL LETTER Y
+ 'z' # 0x007a -> LATIN SMALL LETTER Z
+ '{' # 0x007b -> LEFT CURLY BRACKET, left-right
+ '|' # 0x007c -> VERTICAL LINE, left-right
+ '}' # 0x007d -> RIGHT CURLY BRACKET, left-right
+ '~' # 0x007e -> TILDE
+ '\x7f' # 0x007f -> CONTROL CHARACTER
+ '\xc4' # 0x0080 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xa0' # 0x0081 -> NO-BREAK SPACE, right-left
+ '\xc7' # 0x0082 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x0083 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x0084 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x0085 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x0086 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x0087 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x0088 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x0089 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x008a -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u06ba' # 0x008b -> ARABIC LETTER NOON GHUNNA
+ '\xab' # 0x008c -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
+ '\xe7' # 0x008d -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x008e -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x008f -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x0090 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x0091 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x0092 -> LATIN SMALL LETTER I WITH ACUTE
+ '\u2026' # 0x0093 -> HORIZONTAL ELLIPSIS, right-left
+ '\xee' # 0x0094 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x0095 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x0096 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x0097 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xbb' # 0x0098 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
+ '\xf4' # 0x0099 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x009a -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0x009b -> DIVISION SIGN, right-left
+ '\xfa' # 0x009c -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x009d -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x009e -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x009f -> LATIN SMALL LETTER U WITH DIAERESIS
+ ' ' # 0x00a0 -> SPACE, right-left
+ '!' # 0x00a1 -> EXCLAMATION MARK, right-left
+ '"' # 0x00a2 -> QUOTATION MARK, right-left
+ '#' # 0x00a3 -> NUMBER SIGN, right-left
+ '$' # 0x00a4 -> DOLLAR SIGN, right-left
+ '\u066a' # 0x00a5 -> ARABIC PERCENT SIGN
+ '&' # 0x00a6 -> AMPERSAND, right-left
+ "'" # 0x00a7 -> APOSTROPHE, right-left
+ '(' # 0x00a8 -> LEFT PARENTHESIS, right-left
+ ')' # 0x00a9 -> RIGHT PARENTHESIS, right-left
+ '*' # 0x00aa -> ASTERISK, right-left
+ '+' # 0x00ab -> PLUS SIGN, right-left
+ '\u060c' # 0x00ac -> ARABIC COMMA
+ '-' # 0x00ad -> HYPHEN-MINUS, right-left
+ '.' # 0x00ae -> FULL STOP, right-left
+ '/' # 0x00af -> SOLIDUS, right-left
+ '\u0660' # 0x00b0 -> ARABIC-INDIC DIGIT ZERO, right-left (need override)
+ '\u0661' # 0x00b1 -> ARABIC-INDIC DIGIT ONE, right-left (need override)
+ '\u0662' # 0x00b2 -> ARABIC-INDIC DIGIT TWO, right-left (need override)
+ '\u0663' # 0x00b3 -> ARABIC-INDIC DIGIT THREE, right-left (need override)
+ '\u0664' # 0x00b4 -> ARABIC-INDIC DIGIT FOUR, right-left (need override)
+ '\u0665' # 0x00b5 -> ARABIC-INDIC DIGIT FIVE, right-left (need override)
+ '\u0666' # 0x00b6 -> ARABIC-INDIC DIGIT SIX, right-left (need override)
+ '\u0667' # 0x00b7 -> ARABIC-INDIC DIGIT SEVEN, right-left (need override)
+ '\u0668' # 0x00b8 -> ARABIC-INDIC DIGIT EIGHT, right-left (need override)
+ '\u0669' # 0x00b9 -> ARABIC-INDIC DIGIT NINE, right-left (need override)
+ ':' # 0x00ba -> COLON, right-left
+ '\u061b' # 0x00bb -> ARABIC SEMICOLON
+ '<' # 0x00bc -> LESS-THAN SIGN, right-left
+ '=' # 0x00bd -> EQUALS SIGN, right-left
+ '>' # 0x00be -> GREATER-THAN SIGN, right-left
+ '\u061f' # 0x00bf -> ARABIC QUESTION MARK
+ '\u274a' # 0x00c0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
+ '\u0621' # 0x00c1 -> ARABIC LETTER HAMZA
+ '\u0622' # 0x00c2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0x00c3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0x00c4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\u0625' # 0x00c5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0x00c6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0x00c7 -> ARABIC LETTER ALEF
+ '\u0628' # 0x00c8 -> ARABIC LETTER BEH
+ '\u0629' # 0x00c9 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0x00ca -> ARABIC LETTER TEH
+ '\u062b' # 0x00cb -> ARABIC LETTER THEH
+ '\u062c' # 0x00cc -> ARABIC LETTER JEEM
+ '\u062d' # 0x00cd -> ARABIC LETTER HAH
+ '\u062e' # 0x00ce -> ARABIC LETTER KHAH
+ '\u062f' # 0x00cf -> ARABIC LETTER DAL
+ '\u0630' # 0x00d0 -> ARABIC LETTER THAL
+ '\u0631' # 0x00d1 -> ARABIC LETTER REH
+ '\u0632' # 0x00d2 -> ARABIC LETTER ZAIN
+ '\u0633' # 0x00d3 -> ARABIC LETTER SEEN
+ '\u0634' # 0x00d4 -> ARABIC LETTER SHEEN
+ '\u0635' # 0x00d5 -> ARABIC LETTER SAD
+ '\u0636' # 0x00d6 -> ARABIC LETTER DAD
+ '\u0637' # 0x00d7 -> ARABIC LETTER TAH
+ '\u0638' # 0x00d8 -> ARABIC LETTER ZAH
+ '\u0639' # 0x00d9 -> ARABIC LETTER AIN
+ '\u063a' # 0x00da -> ARABIC LETTER GHAIN
+ '[' # 0x00db -> LEFT SQUARE BRACKET, right-left
+ '\\' # 0x00dc -> REVERSE SOLIDUS, right-left
+ ']' # 0x00dd -> RIGHT SQUARE BRACKET, right-left
+ '^' # 0x00de -> CIRCUMFLEX ACCENT, right-left
+ '_' # 0x00df -> LOW LINE, right-left
+ '\u0640' # 0x00e0 -> ARABIC TATWEEL
+ '\u0641' # 0x00e1 -> ARABIC LETTER FEH
+ '\u0642' # 0x00e2 -> ARABIC LETTER QAF
+ '\u0643' # 0x00e3 -> ARABIC LETTER KAF
+ '\u0644' # 0x00e4 -> ARABIC LETTER LAM
+ '\u0645' # 0x00e5 -> ARABIC LETTER MEEM
+ '\u0646' # 0x00e6 -> ARABIC LETTER NOON
+ '\u0647' # 0x00e7 -> ARABIC LETTER HEH
+ '\u0648' # 0x00e8 -> ARABIC LETTER WAW
+ '\u0649' # 0x00e9 -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0x00ea -> ARABIC LETTER YEH
+ '\u064b' # 0x00eb -> ARABIC FATHATAN
+ '\u064c' # 0x00ec -> ARABIC DAMMATAN
+ '\u064d' # 0x00ed -> ARABIC KASRATAN
+ '\u064e' # 0x00ee -> ARABIC FATHA
+ '\u064f' # 0x00ef -> ARABIC DAMMA
+ '\u0650' # 0x00f0 -> ARABIC KASRA
+ '\u0651' # 0x00f1 -> ARABIC SHADDA
+ '\u0652' # 0x00f2 -> ARABIC SUKUN
+ '\u067e' # 0x00f3 -> ARABIC LETTER PEH
+ '\u0679' # 0x00f4 -> ARABIC LETTER TTEH
+ '\u0686' # 0x00f5 -> ARABIC LETTER TCHEH
+ '\u06d5' # 0x00f6 -> ARABIC LETTER AE
+ '\u06a4' # 0x00f7 -> ARABIC LETTER VEH
+ '\u06af' # 0x00f8 -> ARABIC LETTER GAF
+ '\u0688' # 0x00f9 -> ARABIC LETTER DDAL
+ '\u0691' # 0x00fa -> ARABIC LETTER RREH
+ '{' # 0x00fb -> LEFT CURLY BRACKET, right-left
+ '|' # 0x00fc -> VERTICAL LINE, right-left
+ '}' # 0x00fd -> RIGHT CURLY BRACKET, right-left
+ '\u0698' # 0x00fe -> ARABIC LETTER JEH
+ '\u06d2' # 0x00ff -> ARABIC LETTER YEH BARREE
)
### Encoding Map
diff --git a/Lib/encodings/mac_centeuro.py b/Lib/encodings/mac_centeuro.py
index 483c8212ace..5785a0ec12d 100644
--- a/Lib/encodings/mac_centeuro.py
+++ b/Lib/encodings/mac_centeuro.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\u0100' # 0x81 -> LATIN CAPITAL LETTER A WITH MACRON
- u'\u0101' # 0x82 -> LATIN SMALL LETTER A WITH MACRON
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\u0104' # 0x84 -> LATIN CAPITAL LETTER A WITH OGONEK
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\u0105' # 0x88 -> LATIN SMALL LETTER A WITH OGONEK
- u'\u010c' # 0x89 -> LATIN CAPITAL LETTER C WITH CARON
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u010d' # 0x8B -> LATIN SMALL LETTER C WITH CARON
- u'\u0106' # 0x8C -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\u0107' # 0x8D -> LATIN SMALL LETTER C WITH ACUTE
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE
- u'\u017a' # 0x90 -> LATIN SMALL LETTER Z WITH ACUTE
- u'\u010e' # 0x91 -> LATIN CAPITAL LETTER D WITH CARON
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\u010f' # 0x93 -> LATIN SMALL LETTER D WITH CARON
- u'\u0112' # 0x94 -> LATIN CAPITAL LETTER E WITH MACRON
- u'\u0113' # 0x95 -> LATIN SMALL LETTER E WITH MACRON
- u'\u0116' # 0x96 -> LATIN CAPITAL LETTER E WITH DOT ABOVE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\u0117' # 0x98 -> LATIN SMALL LETTER E WITH DOT ABOVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\u011a' # 0x9D -> LATIN CAPITAL LETTER E WITH CARON
- u'\u011b' # 0x9E -> LATIN SMALL LETTER E WITH CARON
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\u0118' # 0xA2 -> LATIN CAPITAL LETTER E WITH OGONEK
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\u0119' # 0xAB -> LATIN SMALL LETTER E WITH OGONEK
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\u0123' # 0xAE -> LATIN SMALL LETTER G WITH CEDILLA
- u'\u012e' # 0xAF -> LATIN CAPITAL LETTER I WITH OGONEK
- u'\u012f' # 0xB0 -> LATIN SMALL LETTER I WITH OGONEK
- u'\u012a' # 0xB1 -> LATIN CAPITAL LETTER I WITH MACRON
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\u012b' # 0xB4 -> LATIN SMALL LETTER I WITH MACRON
- u'\u0136' # 0xB5 -> LATIN CAPITAL LETTER K WITH CEDILLA
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u0142' # 0xB8 -> LATIN SMALL LETTER L WITH STROKE
- u'\u013b' # 0xB9 -> LATIN CAPITAL LETTER L WITH CEDILLA
- u'\u013c' # 0xBA -> LATIN SMALL LETTER L WITH CEDILLA
- u'\u013d' # 0xBB -> LATIN CAPITAL LETTER L WITH CARON
- u'\u013e' # 0xBC -> LATIN SMALL LETTER L WITH CARON
- u'\u0139' # 0xBD -> LATIN CAPITAL LETTER L WITH ACUTE
- u'\u013a' # 0xBE -> LATIN SMALL LETTER L WITH ACUTE
- u'\u0145' # 0xBF -> LATIN CAPITAL LETTER N WITH CEDILLA
- u'\u0146' # 0xC0 -> LATIN SMALL LETTER N WITH CEDILLA
- u'\u0143' # 0xC1 -> LATIN CAPITAL LETTER N WITH ACUTE
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0144' # 0xC4 -> LATIN SMALL LETTER N WITH ACUTE
- u'\u0147' # 0xC5 -> LATIN CAPITAL LETTER N WITH CARON
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\u0148' # 0xCB -> LATIN SMALL LETTER N WITH CARON
- u'\u0150' # 0xCC -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0151' # 0xCE -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
- u'\u014c' # 0xCF -> LATIN CAPITAL LETTER O WITH MACRON
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\u014d' # 0xD8 -> LATIN SMALL LETTER O WITH MACRON
- u'\u0154' # 0xD9 -> LATIN CAPITAL LETTER R WITH ACUTE
- u'\u0155' # 0xDA -> LATIN SMALL LETTER R WITH ACUTE
- u'\u0158' # 0xDB -> LATIN CAPITAL LETTER R WITH CARON
- u'\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u0159' # 0xDE -> LATIN SMALL LETTER R WITH CARON
- u'\u0156' # 0xDF -> LATIN CAPITAL LETTER R WITH CEDILLA
- u'\u0157' # 0xE0 -> LATIN SMALL LETTER R WITH CEDILLA
- u'\u0160' # 0xE1 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u0161' # 0xE4 -> LATIN SMALL LETTER S WITH CARON
- u'\u015a' # 0xE5 -> LATIN CAPITAL LETTER S WITH ACUTE
- u'\u015b' # 0xE6 -> LATIN SMALL LETTER S WITH ACUTE
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\u0164' # 0xE8 -> LATIN CAPITAL LETTER T WITH CARON
- u'\u0165' # 0xE9 -> LATIN SMALL LETTER T WITH CARON
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\u017d' # 0xEB -> LATIN CAPITAL LETTER Z WITH CARON
- u'\u017e' # 0xEC -> LATIN SMALL LETTER Z WITH CARON
- u'\u016a' # 0xED -> LATIN CAPITAL LETTER U WITH MACRON
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u016b' # 0xF0 -> LATIN SMALL LETTER U WITH MACRON
- u'\u016e' # 0xF1 -> LATIN CAPITAL LETTER U WITH RING ABOVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\u016f' # 0xF3 -> LATIN SMALL LETTER U WITH RING ABOVE
- u'\u0170' # 0xF4 -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
- u'\u0171' # 0xF5 -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
- u'\u0172' # 0xF6 -> LATIN CAPITAL LETTER U WITH OGONEK
- u'\u0173' # 0xF7 -> LATIN SMALL LETTER U WITH OGONEK
- u'\xdd' # 0xF8 -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xfd' # 0xF9 -> LATIN SMALL LETTER Y WITH ACUTE
- u'\u0137' # 0xFA -> LATIN SMALL LETTER K WITH CEDILLA
- u'\u017b' # 0xFB -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
- u'\u0141' # 0xFC -> LATIN CAPITAL LETTER L WITH STROKE
- u'\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
- u'\u0122' # 0xFE -> LATIN CAPITAL LETTER G WITH CEDILLA
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\u0100' # 0x81 -> LATIN CAPITAL LETTER A WITH MACRON
+ '\u0101' # 0x82 -> LATIN SMALL LETTER A WITH MACRON
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\u0104' # 0x84 -> LATIN CAPITAL LETTER A WITH OGONEK
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\u0105' # 0x88 -> LATIN SMALL LETTER A WITH OGONEK
+ '\u010c' # 0x89 -> LATIN CAPITAL LETTER C WITH CARON
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u010d' # 0x8B -> LATIN SMALL LETTER C WITH CARON
+ '\u0106' # 0x8C -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\u0107' # 0x8D -> LATIN SMALL LETTER C WITH ACUTE
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\u0179' # 0x8F -> LATIN CAPITAL LETTER Z WITH ACUTE
+ '\u017a' # 0x90 -> LATIN SMALL LETTER Z WITH ACUTE
+ '\u010e' # 0x91 -> LATIN CAPITAL LETTER D WITH CARON
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\u010f' # 0x93 -> LATIN SMALL LETTER D WITH CARON
+ '\u0112' # 0x94 -> LATIN CAPITAL LETTER E WITH MACRON
+ '\u0113' # 0x95 -> LATIN SMALL LETTER E WITH MACRON
+ '\u0116' # 0x96 -> LATIN CAPITAL LETTER E WITH DOT ABOVE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\u0117' # 0x98 -> LATIN SMALL LETTER E WITH DOT ABOVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\u011a' # 0x9D -> LATIN CAPITAL LETTER E WITH CARON
+ '\u011b' # 0x9E -> LATIN SMALL LETTER E WITH CARON
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\u0118' # 0xA2 -> LATIN CAPITAL LETTER E WITH OGONEK
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\u0119' # 0xAB -> LATIN SMALL LETTER E WITH OGONEK
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\u0123' # 0xAE -> LATIN SMALL LETTER G WITH CEDILLA
+ '\u012e' # 0xAF -> LATIN CAPITAL LETTER I WITH OGONEK
+ '\u012f' # 0xB0 -> LATIN SMALL LETTER I WITH OGONEK
+ '\u012a' # 0xB1 -> LATIN CAPITAL LETTER I WITH MACRON
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\u012b' # 0xB4 -> LATIN SMALL LETTER I WITH MACRON
+ '\u0136' # 0xB5 -> LATIN CAPITAL LETTER K WITH CEDILLA
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u0142' # 0xB8 -> LATIN SMALL LETTER L WITH STROKE
+ '\u013b' # 0xB9 -> LATIN CAPITAL LETTER L WITH CEDILLA
+ '\u013c' # 0xBA -> LATIN SMALL LETTER L WITH CEDILLA
+ '\u013d' # 0xBB -> LATIN CAPITAL LETTER L WITH CARON
+ '\u013e' # 0xBC -> LATIN SMALL LETTER L WITH CARON
+ '\u0139' # 0xBD -> LATIN CAPITAL LETTER L WITH ACUTE
+ '\u013a' # 0xBE -> LATIN SMALL LETTER L WITH ACUTE
+ '\u0145' # 0xBF -> LATIN CAPITAL LETTER N WITH CEDILLA
+ '\u0146' # 0xC0 -> LATIN SMALL LETTER N WITH CEDILLA
+ '\u0143' # 0xC1 -> LATIN CAPITAL LETTER N WITH ACUTE
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0144' # 0xC4 -> LATIN SMALL LETTER N WITH ACUTE
+ '\u0147' # 0xC5 -> LATIN CAPITAL LETTER N WITH CARON
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\u0148' # 0xCB -> LATIN SMALL LETTER N WITH CARON
+ '\u0150' # 0xCC -> LATIN CAPITAL LETTER O WITH DOUBLE ACUTE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0151' # 0xCE -> LATIN SMALL LETTER O WITH DOUBLE ACUTE
+ '\u014c' # 0xCF -> LATIN CAPITAL LETTER O WITH MACRON
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\u014d' # 0xD8 -> LATIN SMALL LETTER O WITH MACRON
+ '\u0154' # 0xD9 -> LATIN CAPITAL LETTER R WITH ACUTE
+ '\u0155' # 0xDA -> LATIN SMALL LETTER R WITH ACUTE
+ '\u0158' # 0xDB -> LATIN CAPITAL LETTER R WITH CARON
+ '\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u0159' # 0xDE -> LATIN SMALL LETTER R WITH CARON
+ '\u0156' # 0xDF -> LATIN CAPITAL LETTER R WITH CEDILLA
+ '\u0157' # 0xE0 -> LATIN SMALL LETTER R WITH CEDILLA
+ '\u0160' # 0xE1 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u0161' # 0xE4 -> LATIN SMALL LETTER S WITH CARON
+ '\u015a' # 0xE5 -> LATIN CAPITAL LETTER S WITH ACUTE
+ '\u015b' # 0xE6 -> LATIN SMALL LETTER S WITH ACUTE
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\u0164' # 0xE8 -> LATIN CAPITAL LETTER T WITH CARON
+ '\u0165' # 0xE9 -> LATIN SMALL LETTER T WITH CARON
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\u017d' # 0xEB -> LATIN CAPITAL LETTER Z WITH CARON
+ '\u017e' # 0xEC -> LATIN SMALL LETTER Z WITH CARON
+ '\u016a' # 0xED -> LATIN CAPITAL LETTER U WITH MACRON
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u016b' # 0xF0 -> LATIN SMALL LETTER U WITH MACRON
+ '\u016e' # 0xF1 -> LATIN CAPITAL LETTER U WITH RING ABOVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\u016f' # 0xF3 -> LATIN SMALL LETTER U WITH RING ABOVE
+ '\u0170' # 0xF4 -> LATIN CAPITAL LETTER U WITH DOUBLE ACUTE
+ '\u0171' # 0xF5 -> LATIN SMALL LETTER U WITH DOUBLE ACUTE
+ '\u0172' # 0xF6 -> LATIN CAPITAL LETTER U WITH OGONEK
+ '\u0173' # 0xF7 -> LATIN SMALL LETTER U WITH OGONEK
+ '\xdd' # 0xF8 -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xfd' # 0xF9 -> LATIN SMALL LETTER Y WITH ACUTE
+ '\u0137' # 0xFA -> LATIN SMALL LETTER K WITH CEDILLA
+ '\u017b' # 0xFB -> LATIN CAPITAL LETTER Z WITH DOT ABOVE
+ '\u0141' # 0xFC -> LATIN CAPITAL LETTER L WITH STROKE
+ '\u017c' # 0xFD -> LATIN SMALL LETTER Z WITH DOT ABOVE
+ '\u0122' # 0xFE -> LATIN CAPITAL LETTER G WITH CEDILLA
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/mac_croatian.py b/Lib/encodings/mac_croatian.py
index f57f7b4b33f..4a92fe61a4f 100644
--- a/Lib/encodings/mac_croatian.py
+++ b/Lib/encodings/mac_croatian.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\xb4' # 0xAB -> ACUTE ACCENT
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
- u'\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\u2206' # 0xB4 -> INCREMENT
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u220f' # 0xB8 -> N-ARY PRODUCT
- u'\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
- u'\u222b' # 0xBA -> INTEGRAL
- u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
- u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
- u'\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
- u'\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
- u'\xbf' # 0xC0 -> INVERTED QUESTION MARK
- u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\uf8ff' # 0xD8 -> Apple logo
- u'\xa9' # 0xD9 -> COPYRIGHT SIGN
- u'\u2044' # 0xDA -> FRACTION SLASH
- u'\u20ac' # 0xDB -> EURO SIGN
- u'\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\xc6' # 0xDE -> LATIN CAPITAL LETTER AE
- u'\xbb' # 0xDF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2013' # 0xE0 -> EN DASH
- u'\xb7' # 0xE1 -> MIDDLE DOT
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2030' # 0xE4 -> PER MILLE SIGN
- u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
- u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
- u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
- u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u02dc' # 0xF7 -> SMALL TILDE
- u'\xaf' # 0xF8 -> MACRON
- u'\u03c0' # 0xF9 -> GREEK SMALL LETTER PI
- u'\xcb' # 0xFA -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\u02da' # 0xFB -> RING ABOVE
- u'\xb8' # 0xFC -> CEDILLA
- u'\xca' # 0xFD -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xe6' # 0xFE -> LATIN SMALL LETTER AE
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\u0160' # 0xA9 -> LATIN CAPITAL LETTER S WITH CARON
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\xb4' # 0xAB -> ACUTE ACCENT
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\u017d' # 0xAE -> LATIN CAPITAL LETTER Z WITH CARON
+ '\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\u2206' # 0xB4 -> INCREMENT
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u220f' # 0xB8 -> N-ARY PRODUCT
+ '\u0161' # 0xB9 -> LATIN SMALL LETTER S WITH CARON
+ '\u222b' # 0xBA -> INTEGRAL
+ '\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
+ '\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
+ '\u017e' # 0xBE -> LATIN SMALL LETTER Z WITH CARON
+ '\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
+ '\xbf' # 0xC0 -> INVERTED QUESTION MARK
+ '\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u0106' # 0xC6 -> LATIN CAPITAL LETTER C WITH ACUTE
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u010c' # 0xC8 -> LATIN CAPITAL LETTER C WITH CARON
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u0110' # 0xD0 -> LATIN CAPITAL LETTER D WITH STROKE
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\uf8ff' # 0xD8 -> Apple logo
+ '\xa9' # 0xD9 -> COPYRIGHT SIGN
+ '\u2044' # 0xDA -> FRACTION SLASH
+ '\u20ac' # 0xDB -> EURO SIGN
+ '\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\xc6' # 0xDE -> LATIN CAPITAL LETTER AE
+ '\xbb' # 0xDF -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2013' # 0xE0 -> EN DASH
+ '\xb7' # 0xE1 -> MIDDLE DOT
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2030' # 0xE4 -> PER MILLE SIGN
+ '\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\u0107' # 0xE6 -> LATIN SMALL LETTER C WITH ACUTE
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\u010d' # 0xE8 -> LATIN SMALL LETTER C WITH CARON
+ '\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\u0111' # 0xF0 -> LATIN SMALL LETTER D WITH STROKE
+ '\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
+ '\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u02dc' # 0xF7 -> SMALL TILDE
+ '\xaf' # 0xF8 -> MACRON
+ '\u03c0' # 0xF9 -> GREEK SMALL LETTER PI
+ '\xcb' # 0xFA -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\u02da' # 0xFB -> RING ABOVE
+ '\xb8' # 0xFC -> CEDILLA
+ '\xca' # 0xFD -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xe6' # 0xFE -> LATIN SMALL LETTER AE
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/mac_cyrillic.py b/Lib/encodings/mac_cyrillic.py
index 63324a14b86..d20272acfad 100644
--- a/Lib/encodings/mac_cyrillic.py
+++ b/Lib/encodings/mac_cyrillic.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\u0410' # 0x80 -> CYRILLIC CAPITAL LETTER A
- u'\u0411' # 0x81 -> CYRILLIC CAPITAL LETTER BE
- u'\u0412' # 0x82 -> CYRILLIC CAPITAL LETTER VE
- u'\u0413' # 0x83 -> CYRILLIC CAPITAL LETTER GHE
- u'\u0414' # 0x84 -> CYRILLIC CAPITAL LETTER DE
- u'\u0415' # 0x85 -> CYRILLIC CAPITAL LETTER IE
- u'\u0416' # 0x86 -> CYRILLIC CAPITAL LETTER ZHE
- u'\u0417' # 0x87 -> CYRILLIC CAPITAL LETTER ZE
- u'\u0418' # 0x88 -> CYRILLIC CAPITAL LETTER I
- u'\u0419' # 0x89 -> CYRILLIC CAPITAL LETTER SHORT I
- u'\u041a' # 0x8A -> CYRILLIC CAPITAL LETTER KA
- u'\u041b' # 0x8B -> CYRILLIC CAPITAL LETTER EL
- u'\u041c' # 0x8C -> CYRILLIC CAPITAL LETTER EM
- u'\u041d' # 0x8D -> CYRILLIC CAPITAL LETTER EN
- u'\u041e' # 0x8E -> CYRILLIC CAPITAL LETTER O
- u'\u041f' # 0x8F -> CYRILLIC CAPITAL LETTER PE
- u'\u0420' # 0x90 -> CYRILLIC CAPITAL LETTER ER
- u'\u0421' # 0x91 -> CYRILLIC CAPITAL LETTER ES
- u'\u0422' # 0x92 -> CYRILLIC CAPITAL LETTER TE
- u'\u0423' # 0x93 -> CYRILLIC CAPITAL LETTER U
- u'\u0424' # 0x94 -> CYRILLIC CAPITAL LETTER EF
- u'\u0425' # 0x95 -> CYRILLIC CAPITAL LETTER HA
- u'\u0426' # 0x96 -> CYRILLIC CAPITAL LETTER TSE
- u'\u0427' # 0x97 -> CYRILLIC CAPITAL LETTER CHE
- u'\u0428' # 0x98 -> CYRILLIC CAPITAL LETTER SHA
- u'\u0429' # 0x99 -> CYRILLIC CAPITAL LETTER SHCHA
- u'\u042a' # 0x9A -> CYRILLIC CAPITAL LETTER HARD SIGN
- u'\u042b' # 0x9B -> CYRILLIC CAPITAL LETTER YERU
- u'\u042c' # 0x9C -> CYRILLIC CAPITAL LETTER SOFT SIGN
- u'\u042d' # 0x9D -> CYRILLIC CAPITAL LETTER E
- u'\u042e' # 0x9E -> CYRILLIC CAPITAL LETTER YU
- u'\u042f' # 0x9F -> CYRILLIC CAPITAL LETTER YA
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\u0490' # 0xA2 -> CYRILLIC CAPITAL LETTER GHE WITH UPTURN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\u0406' # 0xA7 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\u0402' # 0xAB -> CYRILLIC CAPITAL LETTER DJE
- u'\u0452' # 0xAC -> CYRILLIC SMALL LETTER DJE
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\u0403' # 0xAE -> CYRILLIC CAPITAL LETTER GJE
- u'\u0453' # 0xAF -> CYRILLIC SMALL LETTER GJE
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\u0456' # 0xB4 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u0491' # 0xB6 -> CYRILLIC SMALL LETTER GHE WITH UPTURN
- u'\u0408' # 0xB7 -> CYRILLIC CAPITAL LETTER JE
- u'\u0404' # 0xB8 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
- u'\u0454' # 0xB9 -> CYRILLIC SMALL LETTER UKRAINIAN IE
- u'\u0407' # 0xBA -> CYRILLIC CAPITAL LETTER YI
- u'\u0457' # 0xBB -> CYRILLIC SMALL LETTER YI
- u'\u0409' # 0xBC -> CYRILLIC CAPITAL LETTER LJE
- u'\u0459' # 0xBD -> CYRILLIC SMALL LETTER LJE
- u'\u040a' # 0xBE -> CYRILLIC CAPITAL LETTER NJE
- u'\u045a' # 0xBF -> CYRILLIC SMALL LETTER NJE
- u'\u0458' # 0xC0 -> CYRILLIC SMALL LETTER JE
- u'\u0405' # 0xC1 -> CYRILLIC CAPITAL LETTER DZE
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\u040b' # 0xCB -> CYRILLIC CAPITAL LETTER TSHE
- u'\u045b' # 0xCC -> CYRILLIC SMALL LETTER TSHE
- u'\u040c' # 0xCD -> CYRILLIC CAPITAL LETTER KJE
- u'\u045c' # 0xCE -> CYRILLIC SMALL LETTER KJE
- u'\u0455' # 0xCF -> CYRILLIC SMALL LETTER DZE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u201e' # 0xD7 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u040e' # 0xD8 -> CYRILLIC CAPITAL LETTER SHORT U
- u'\u045e' # 0xD9 -> CYRILLIC SMALL LETTER SHORT U
- u'\u040f' # 0xDA -> CYRILLIC CAPITAL LETTER DZHE
- u'\u045f' # 0xDB -> CYRILLIC SMALL LETTER DZHE
- u'\u2116' # 0xDC -> NUMERO SIGN
- u'\u0401' # 0xDD -> CYRILLIC CAPITAL LETTER IO
- u'\u0451' # 0xDE -> CYRILLIC SMALL LETTER IO
- u'\u044f' # 0xDF -> CYRILLIC SMALL LETTER YA
- u'\u0430' # 0xE0 -> CYRILLIC SMALL LETTER A
- u'\u0431' # 0xE1 -> CYRILLIC SMALL LETTER BE
- u'\u0432' # 0xE2 -> CYRILLIC SMALL LETTER VE
- u'\u0433' # 0xE3 -> CYRILLIC SMALL LETTER GHE
- u'\u0434' # 0xE4 -> CYRILLIC SMALL LETTER DE
- u'\u0435' # 0xE5 -> CYRILLIC SMALL LETTER IE
- u'\u0436' # 0xE6 -> CYRILLIC SMALL LETTER ZHE
- u'\u0437' # 0xE7 -> CYRILLIC SMALL LETTER ZE
- u'\u0438' # 0xE8 -> CYRILLIC SMALL LETTER I
- u'\u0439' # 0xE9 -> CYRILLIC SMALL LETTER SHORT I
- u'\u043a' # 0xEA -> CYRILLIC SMALL LETTER KA
- u'\u043b' # 0xEB -> CYRILLIC SMALL LETTER EL
- u'\u043c' # 0xEC -> CYRILLIC SMALL LETTER EM
- u'\u043d' # 0xED -> CYRILLIC SMALL LETTER EN
- u'\u043e' # 0xEE -> CYRILLIC SMALL LETTER O
- u'\u043f' # 0xEF -> CYRILLIC SMALL LETTER PE
- u'\u0440' # 0xF0 -> CYRILLIC SMALL LETTER ER
- u'\u0441' # 0xF1 -> CYRILLIC SMALL LETTER ES
- u'\u0442' # 0xF2 -> CYRILLIC SMALL LETTER TE
- u'\u0443' # 0xF3 -> CYRILLIC SMALL LETTER U
- u'\u0444' # 0xF4 -> CYRILLIC SMALL LETTER EF
- u'\u0445' # 0xF5 -> CYRILLIC SMALL LETTER HA
- u'\u0446' # 0xF6 -> CYRILLIC SMALL LETTER TSE
- u'\u0447' # 0xF7 -> CYRILLIC SMALL LETTER CHE
- u'\u0448' # 0xF8 -> CYRILLIC SMALL LETTER SHA
- u'\u0449' # 0xF9 -> CYRILLIC SMALL LETTER SHCHA
- u'\u044a' # 0xFA -> CYRILLIC SMALL LETTER HARD SIGN
- u'\u044b' # 0xFB -> CYRILLIC SMALL LETTER YERU
- u'\u044c' # 0xFC -> CYRILLIC SMALL LETTER SOFT SIGN
- u'\u044d' # 0xFD -> CYRILLIC SMALL LETTER E
- u'\u044e' # 0xFE -> CYRILLIC SMALL LETTER YU
- u'\u20ac' # 0xFF -> EURO SIGN
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\u0410' # 0x80 -> CYRILLIC CAPITAL LETTER A
+ '\u0411' # 0x81 -> CYRILLIC CAPITAL LETTER BE
+ '\u0412' # 0x82 -> CYRILLIC CAPITAL LETTER VE
+ '\u0413' # 0x83 -> CYRILLIC CAPITAL LETTER GHE
+ '\u0414' # 0x84 -> CYRILLIC CAPITAL LETTER DE
+ '\u0415' # 0x85 -> CYRILLIC CAPITAL LETTER IE
+ '\u0416' # 0x86 -> CYRILLIC CAPITAL LETTER ZHE
+ '\u0417' # 0x87 -> CYRILLIC CAPITAL LETTER ZE
+ '\u0418' # 0x88 -> CYRILLIC CAPITAL LETTER I
+ '\u0419' # 0x89 -> CYRILLIC CAPITAL LETTER SHORT I
+ '\u041a' # 0x8A -> CYRILLIC CAPITAL LETTER KA
+ '\u041b' # 0x8B -> CYRILLIC CAPITAL LETTER EL
+ '\u041c' # 0x8C -> CYRILLIC CAPITAL LETTER EM
+ '\u041d' # 0x8D -> CYRILLIC CAPITAL LETTER EN
+ '\u041e' # 0x8E -> CYRILLIC CAPITAL LETTER O
+ '\u041f' # 0x8F -> CYRILLIC CAPITAL LETTER PE
+ '\u0420' # 0x90 -> CYRILLIC CAPITAL LETTER ER
+ '\u0421' # 0x91 -> CYRILLIC CAPITAL LETTER ES
+ '\u0422' # 0x92 -> CYRILLIC CAPITAL LETTER TE
+ '\u0423' # 0x93 -> CYRILLIC CAPITAL LETTER U
+ '\u0424' # 0x94 -> CYRILLIC CAPITAL LETTER EF
+ '\u0425' # 0x95 -> CYRILLIC CAPITAL LETTER HA
+ '\u0426' # 0x96 -> CYRILLIC CAPITAL LETTER TSE
+ '\u0427' # 0x97 -> CYRILLIC CAPITAL LETTER CHE
+ '\u0428' # 0x98 -> CYRILLIC CAPITAL LETTER SHA
+ '\u0429' # 0x99 -> CYRILLIC CAPITAL LETTER SHCHA
+ '\u042a' # 0x9A -> CYRILLIC CAPITAL LETTER HARD SIGN
+ '\u042b' # 0x9B -> CYRILLIC CAPITAL LETTER YERU
+ '\u042c' # 0x9C -> CYRILLIC CAPITAL LETTER SOFT SIGN
+ '\u042d' # 0x9D -> CYRILLIC CAPITAL LETTER E
+ '\u042e' # 0x9E -> CYRILLIC CAPITAL LETTER YU
+ '\u042f' # 0x9F -> CYRILLIC CAPITAL LETTER YA
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\u0490' # 0xA2 -> CYRILLIC CAPITAL LETTER GHE WITH UPTURN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\u0406' # 0xA7 -> CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\u0402' # 0xAB -> CYRILLIC CAPITAL LETTER DJE
+ '\u0452' # 0xAC -> CYRILLIC SMALL LETTER DJE
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\u0403' # 0xAE -> CYRILLIC CAPITAL LETTER GJE
+ '\u0453' # 0xAF -> CYRILLIC SMALL LETTER GJE
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\u0456' # 0xB4 -> CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u0491' # 0xB6 -> CYRILLIC SMALL LETTER GHE WITH UPTURN
+ '\u0408' # 0xB7 -> CYRILLIC CAPITAL LETTER JE
+ '\u0404' # 0xB8 -> CYRILLIC CAPITAL LETTER UKRAINIAN IE
+ '\u0454' # 0xB9 -> CYRILLIC SMALL LETTER UKRAINIAN IE
+ '\u0407' # 0xBA -> CYRILLIC CAPITAL LETTER YI
+ '\u0457' # 0xBB -> CYRILLIC SMALL LETTER YI
+ '\u0409' # 0xBC -> CYRILLIC CAPITAL LETTER LJE
+ '\u0459' # 0xBD -> CYRILLIC SMALL LETTER LJE
+ '\u040a' # 0xBE -> CYRILLIC CAPITAL LETTER NJE
+ '\u045a' # 0xBF -> CYRILLIC SMALL LETTER NJE
+ '\u0458' # 0xC0 -> CYRILLIC SMALL LETTER JE
+ '\u0405' # 0xC1 -> CYRILLIC CAPITAL LETTER DZE
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\u040b' # 0xCB -> CYRILLIC CAPITAL LETTER TSHE
+ '\u045b' # 0xCC -> CYRILLIC SMALL LETTER TSHE
+ '\u040c' # 0xCD -> CYRILLIC CAPITAL LETTER KJE
+ '\u045c' # 0xCE -> CYRILLIC SMALL LETTER KJE
+ '\u0455' # 0xCF -> CYRILLIC SMALL LETTER DZE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u201e' # 0xD7 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u040e' # 0xD8 -> CYRILLIC CAPITAL LETTER SHORT U
+ '\u045e' # 0xD9 -> CYRILLIC SMALL LETTER SHORT U
+ '\u040f' # 0xDA -> CYRILLIC CAPITAL LETTER DZHE
+ '\u045f' # 0xDB -> CYRILLIC SMALL LETTER DZHE
+ '\u2116' # 0xDC -> NUMERO SIGN
+ '\u0401' # 0xDD -> CYRILLIC CAPITAL LETTER IO
+ '\u0451' # 0xDE -> CYRILLIC SMALL LETTER IO
+ '\u044f' # 0xDF -> CYRILLIC SMALL LETTER YA
+ '\u0430' # 0xE0 -> CYRILLIC SMALL LETTER A
+ '\u0431' # 0xE1 -> CYRILLIC SMALL LETTER BE
+ '\u0432' # 0xE2 -> CYRILLIC SMALL LETTER VE
+ '\u0433' # 0xE3 -> CYRILLIC SMALL LETTER GHE
+ '\u0434' # 0xE4 -> CYRILLIC SMALL LETTER DE
+ '\u0435' # 0xE5 -> CYRILLIC SMALL LETTER IE
+ '\u0436' # 0xE6 -> CYRILLIC SMALL LETTER ZHE
+ '\u0437' # 0xE7 -> CYRILLIC SMALL LETTER ZE
+ '\u0438' # 0xE8 -> CYRILLIC SMALL LETTER I
+ '\u0439' # 0xE9 -> CYRILLIC SMALL LETTER SHORT I
+ '\u043a' # 0xEA -> CYRILLIC SMALL LETTER KA
+ '\u043b' # 0xEB -> CYRILLIC SMALL LETTER EL
+ '\u043c' # 0xEC -> CYRILLIC SMALL LETTER EM
+ '\u043d' # 0xED -> CYRILLIC SMALL LETTER EN
+ '\u043e' # 0xEE -> CYRILLIC SMALL LETTER O
+ '\u043f' # 0xEF -> CYRILLIC SMALL LETTER PE
+ '\u0440' # 0xF0 -> CYRILLIC SMALL LETTER ER
+ '\u0441' # 0xF1 -> CYRILLIC SMALL LETTER ES
+ '\u0442' # 0xF2 -> CYRILLIC SMALL LETTER TE
+ '\u0443' # 0xF3 -> CYRILLIC SMALL LETTER U
+ '\u0444' # 0xF4 -> CYRILLIC SMALL LETTER EF
+ '\u0445' # 0xF5 -> CYRILLIC SMALL LETTER HA
+ '\u0446' # 0xF6 -> CYRILLIC SMALL LETTER TSE
+ '\u0447' # 0xF7 -> CYRILLIC SMALL LETTER CHE
+ '\u0448' # 0xF8 -> CYRILLIC SMALL LETTER SHA
+ '\u0449' # 0xF9 -> CYRILLIC SMALL LETTER SHCHA
+ '\u044a' # 0xFA -> CYRILLIC SMALL LETTER HARD SIGN
+ '\u044b' # 0xFB -> CYRILLIC SMALL LETTER YERU
+ '\u044c' # 0xFC -> CYRILLIC SMALL LETTER SOFT SIGN
+ '\u044d' # 0xFD -> CYRILLIC SMALL LETTER E
+ '\u044e' # 0xFE -> CYRILLIC SMALL LETTER YU
+ '\u20ac' # 0xFF -> EURO SIGN
)
### Encoding table
diff --git a/Lib/encodings/mac_farsi.py b/Lib/encodings/mac_farsi.py
index 9dbd76a2323..e357d43510b 100644
--- a/Lib/encodings/mac_farsi.py
+++ b/Lib/encodings/mac_farsi.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE, left-right
- u'!' # 0x21 -> EXCLAMATION MARK, left-right
- u'"' # 0x22 -> QUOTATION MARK, left-right
- u'#' # 0x23 -> NUMBER SIGN, left-right
- u'$' # 0x24 -> DOLLAR SIGN, left-right
- u'%' # 0x25 -> PERCENT SIGN, left-right
- u'&' # 0x26 -> AMPERSAND, left-right
- u"'" # 0x27 -> APOSTROPHE, left-right
- u'(' # 0x28 -> LEFT PARENTHESIS, left-right
- u')' # 0x29 -> RIGHT PARENTHESIS, left-right
- u'*' # 0x2A -> ASTERISK, left-right
- u'+' # 0x2B -> PLUS SIGN, left-right
- u',' # 0x2C -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR
- u'-' # 0x2D -> HYPHEN-MINUS, left-right
- u'.' # 0x2E -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR
- u'/' # 0x2F -> SOLIDUS, left-right
- u'0' # 0x30 -> DIGIT ZERO; in Arabic-script context, displayed as 0x06F0 EXTENDED ARABIC-INDIC DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE; in Arabic-script context, displayed as 0x06F1 EXTENDED ARABIC-INDIC DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO; in Arabic-script context, displayed as 0x06F2 EXTENDED ARABIC-INDIC DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE; in Arabic-script context, displayed as 0x06F3 EXTENDED ARABIC-INDIC DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR; in Arabic-script context, displayed as 0x06F4 EXTENDED ARABIC-INDIC DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE; in Arabic-script context, displayed as 0x06F5 EXTENDED ARABIC-INDIC DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX; in Arabic-script context, displayed as 0x06F6 EXTENDED ARABIC-INDIC DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE; in Arabic-script context, displayed as 0x06F9 EXTENDED ARABIC-INDIC DIGIT NINE
- u':' # 0x3A -> COLON, left-right
- u';' # 0x3B -> SEMICOLON, left-right
- u'<' # 0x3C -> LESS-THAN SIGN, left-right
- u'=' # 0x3D -> EQUALS SIGN, left-right
- u'>' # 0x3E -> GREATER-THAN SIGN, left-right
- u'?' # 0x3F -> QUESTION MARK, left-right
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET, left-right
- u'\\' # 0x5C -> REVERSE SOLIDUS, left-right
- u']' # 0x5D -> RIGHT SQUARE BRACKET, left-right
- u'^' # 0x5E -> CIRCUMFLEX ACCENT, left-right
- u'_' # 0x5F -> LOW LINE, left-right
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET, left-right
- u'|' # 0x7C -> VERTICAL LINE, left-right
- u'}' # 0x7D -> RIGHT CURLY BRACKET, left-right
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xa0' # 0x81 -> NO-BREAK SPACE, right-left
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u06ba' # 0x8B -> ARABIC LETTER NOON GHUNNA
- u'\xab' # 0x8C -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\u2026' # 0x93 -> HORIZONTAL ELLIPSIS, right-left
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xbb' # 0x98 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf7' # 0x9B -> DIVISION SIGN, right-left
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u' ' # 0xA0 -> SPACE, right-left
- u'!' # 0xA1 -> EXCLAMATION MARK, right-left
- u'"' # 0xA2 -> QUOTATION MARK, right-left
- u'#' # 0xA3 -> NUMBER SIGN, right-left
- u'$' # 0xA4 -> DOLLAR SIGN, right-left
- u'\u066a' # 0xA5 -> ARABIC PERCENT SIGN
- u'&' # 0xA6 -> AMPERSAND, right-left
- u"'" # 0xA7 -> APOSTROPHE, right-left
- u'(' # 0xA8 -> LEFT PARENTHESIS, right-left
- u')' # 0xA9 -> RIGHT PARENTHESIS, right-left
- u'*' # 0xAA -> ASTERISK, right-left
- u'+' # 0xAB -> PLUS SIGN, right-left
- u'\u060c' # 0xAC -> ARABIC COMMA
- u'-' # 0xAD -> HYPHEN-MINUS, right-left
- u'.' # 0xAE -> FULL STOP, right-left
- u'/' # 0xAF -> SOLIDUS, right-left
- u'\u06f0' # 0xB0 -> EXTENDED ARABIC-INDIC DIGIT ZERO, right-left (need override)
- u'\u06f1' # 0xB1 -> EXTENDED ARABIC-INDIC DIGIT ONE, right-left (need override)
- u'\u06f2' # 0xB2 -> EXTENDED ARABIC-INDIC DIGIT TWO, right-left (need override)
- u'\u06f3' # 0xB3 -> EXTENDED ARABIC-INDIC DIGIT THREE, right-left (need override)
- u'\u06f4' # 0xB4 -> EXTENDED ARABIC-INDIC DIGIT FOUR, right-left (need override)
- u'\u06f5' # 0xB5 -> EXTENDED ARABIC-INDIC DIGIT FIVE, right-left (need override)
- u'\u06f6' # 0xB6 -> EXTENDED ARABIC-INDIC DIGIT SIX, right-left (need override)
- u'\u06f7' # 0xB7 -> EXTENDED ARABIC-INDIC DIGIT SEVEN, right-left (need override)
- u'\u06f8' # 0xB8 -> EXTENDED ARABIC-INDIC DIGIT EIGHT, right-left (need override)
- u'\u06f9' # 0xB9 -> EXTENDED ARABIC-INDIC DIGIT NINE, right-left (need override)
- u':' # 0xBA -> COLON, right-left
- u'\u061b' # 0xBB -> ARABIC SEMICOLON
- u'<' # 0xBC -> LESS-THAN SIGN, right-left
- u'=' # 0xBD -> EQUALS SIGN, right-left
- u'>' # 0xBE -> GREATER-THAN SIGN, right-left
- u'\u061f' # 0xBF -> ARABIC QUESTION MARK
- u'\u274a' # 0xC0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
- u'\u0621' # 0xC1 -> ARABIC LETTER HAMZA
- u'\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
- u'\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
- u'\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
- u'\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
- u'\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
- u'\u0627' # 0xC7 -> ARABIC LETTER ALEF
- u'\u0628' # 0xC8 -> ARABIC LETTER BEH
- u'\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
- u'\u062a' # 0xCA -> ARABIC LETTER TEH
- u'\u062b' # 0xCB -> ARABIC LETTER THEH
- u'\u062c' # 0xCC -> ARABIC LETTER JEEM
- u'\u062d' # 0xCD -> ARABIC LETTER HAH
- u'\u062e' # 0xCE -> ARABIC LETTER KHAH
- u'\u062f' # 0xCF -> ARABIC LETTER DAL
- u'\u0630' # 0xD0 -> ARABIC LETTER THAL
- u'\u0631' # 0xD1 -> ARABIC LETTER REH
- u'\u0632' # 0xD2 -> ARABIC LETTER ZAIN
- u'\u0633' # 0xD3 -> ARABIC LETTER SEEN
- u'\u0634' # 0xD4 -> ARABIC LETTER SHEEN
- u'\u0635' # 0xD5 -> ARABIC LETTER SAD
- u'\u0636' # 0xD6 -> ARABIC LETTER DAD
- u'\u0637' # 0xD7 -> ARABIC LETTER TAH
- u'\u0638' # 0xD8 -> ARABIC LETTER ZAH
- u'\u0639' # 0xD9 -> ARABIC LETTER AIN
- u'\u063a' # 0xDA -> ARABIC LETTER GHAIN
- u'[' # 0xDB -> LEFT SQUARE BRACKET, right-left
- u'\\' # 0xDC -> REVERSE SOLIDUS, right-left
- u']' # 0xDD -> RIGHT SQUARE BRACKET, right-left
- u'^' # 0xDE -> CIRCUMFLEX ACCENT, right-left
- u'_' # 0xDF -> LOW LINE, right-left
- u'\u0640' # 0xE0 -> ARABIC TATWEEL
- u'\u0641' # 0xE1 -> ARABIC LETTER FEH
- u'\u0642' # 0xE2 -> ARABIC LETTER QAF
- u'\u0643' # 0xE3 -> ARABIC LETTER KAF
- u'\u0644' # 0xE4 -> ARABIC LETTER LAM
- u'\u0645' # 0xE5 -> ARABIC LETTER MEEM
- u'\u0646' # 0xE6 -> ARABIC LETTER NOON
- u'\u0647' # 0xE7 -> ARABIC LETTER HEH
- u'\u0648' # 0xE8 -> ARABIC LETTER WAW
- u'\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA
- u'\u064a' # 0xEA -> ARABIC LETTER YEH
- u'\u064b' # 0xEB -> ARABIC FATHATAN
- u'\u064c' # 0xEC -> ARABIC DAMMATAN
- u'\u064d' # 0xED -> ARABIC KASRATAN
- u'\u064e' # 0xEE -> ARABIC FATHA
- u'\u064f' # 0xEF -> ARABIC DAMMA
- u'\u0650' # 0xF0 -> ARABIC KASRA
- u'\u0651' # 0xF1 -> ARABIC SHADDA
- u'\u0652' # 0xF2 -> ARABIC SUKUN
- u'\u067e' # 0xF3 -> ARABIC LETTER PEH
- u'\u0679' # 0xF4 -> ARABIC LETTER TTEH
- u'\u0686' # 0xF5 -> ARABIC LETTER TCHEH
- u'\u06d5' # 0xF6 -> ARABIC LETTER AE
- u'\u06a4' # 0xF7 -> ARABIC LETTER VEH
- u'\u06af' # 0xF8 -> ARABIC LETTER GAF
- u'\u0688' # 0xF9 -> ARABIC LETTER DDAL
- u'\u0691' # 0xFA -> ARABIC LETTER RREH
- u'{' # 0xFB -> LEFT CURLY BRACKET, right-left
- u'|' # 0xFC -> VERTICAL LINE, right-left
- u'}' # 0xFD -> RIGHT CURLY BRACKET, right-left
- u'\u0698' # 0xFE -> ARABIC LETTER JEH
- u'\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE, left-right
+ '!' # 0x21 -> EXCLAMATION MARK, left-right
+ '"' # 0x22 -> QUOTATION MARK, left-right
+ '#' # 0x23 -> NUMBER SIGN, left-right
+ '$' # 0x24 -> DOLLAR SIGN, left-right
+ '%' # 0x25 -> PERCENT SIGN, left-right
+ '&' # 0x26 -> AMPERSAND, left-right
+ "'" # 0x27 -> APOSTROPHE, left-right
+ '(' # 0x28 -> LEFT PARENTHESIS, left-right
+ ')' # 0x29 -> RIGHT PARENTHESIS, left-right
+ '*' # 0x2A -> ASTERISK, left-right
+ '+' # 0x2B -> PLUS SIGN, left-right
+ ',' # 0x2C -> COMMA, left-right; in Arabic-script context, displayed as 0x066C ARABIC THOUSANDS SEPARATOR
+ '-' # 0x2D -> HYPHEN-MINUS, left-right
+ '.' # 0x2E -> FULL STOP, left-right; in Arabic-script context, displayed as 0x066B ARABIC DECIMAL SEPARATOR
+ '/' # 0x2F -> SOLIDUS, left-right
+ '0' # 0x30 -> DIGIT ZERO; in Arabic-script context, displayed as 0x06F0 EXTENDED ARABIC-INDIC DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE; in Arabic-script context, displayed as 0x06F1 EXTENDED ARABIC-INDIC DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO; in Arabic-script context, displayed as 0x06F2 EXTENDED ARABIC-INDIC DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE; in Arabic-script context, displayed as 0x06F3 EXTENDED ARABIC-INDIC DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR; in Arabic-script context, displayed as 0x06F4 EXTENDED ARABIC-INDIC DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE; in Arabic-script context, displayed as 0x06F5 EXTENDED ARABIC-INDIC DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX; in Arabic-script context, displayed as 0x06F6 EXTENDED ARABIC-INDIC DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN; in Arabic-script context, displayed as 0x06F7 EXTENDED ARABIC-INDIC DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT; in Arabic-script context, displayed as 0x06F8 EXTENDED ARABIC-INDIC DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE; in Arabic-script context, displayed as 0x06F9 EXTENDED ARABIC-INDIC DIGIT NINE
+ ':' # 0x3A -> COLON, left-right
+ ';' # 0x3B -> SEMICOLON, left-right
+ '<' # 0x3C -> LESS-THAN SIGN, left-right
+ '=' # 0x3D -> EQUALS SIGN, left-right
+ '>' # 0x3E -> GREATER-THAN SIGN, left-right
+ '?' # 0x3F -> QUESTION MARK, left-right
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET, left-right
+ '\\' # 0x5C -> REVERSE SOLIDUS, left-right
+ ']' # 0x5D -> RIGHT SQUARE BRACKET, left-right
+ '^' # 0x5E -> CIRCUMFLEX ACCENT, left-right
+ '_' # 0x5F -> LOW LINE, left-right
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET, left-right
+ '|' # 0x7C -> VERTICAL LINE, left-right
+ '}' # 0x7D -> RIGHT CURLY BRACKET, left-right
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xa0' # 0x81 -> NO-BREAK SPACE, right-left
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u06ba' # 0x8B -> ARABIC LETTER NOON GHUNNA
+ '\xab' # 0x8C -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\u2026' # 0x93 -> HORIZONTAL ELLIPSIS, right-left
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xbb' # 0x98 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK, right-left
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf7' # 0x9B -> DIVISION SIGN, right-left
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ ' ' # 0xA0 -> SPACE, right-left
+ '!' # 0xA1 -> EXCLAMATION MARK, right-left
+ '"' # 0xA2 -> QUOTATION MARK, right-left
+ '#' # 0xA3 -> NUMBER SIGN, right-left
+ '$' # 0xA4 -> DOLLAR SIGN, right-left
+ '\u066a' # 0xA5 -> ARABIC PERCENT SIGN
+ '&' # 0xA6 -> AMPERSAND, right-left
+ "'" # 0xA7 -> APOSTROPHE, right-left
+ '(' # 0xA8 -> LEFT PARENTHESIS, right-left
+ ')' # 0xA9 -> RIGHT PARENTHESIS, right-left
+ '*' # 0xAA -> ASTERISK, right-left
+ '+' # 0xAB -> PLUS SIGN, right-left
+ '\u060c' # 0xAC -> ARABIC COMMA
+ '-' # 0xAD -> HYPHEN-MINUS, right-left
+ '.' # 0xAE -> FULL STOP, right-left
+ '/' # 0xAF -> SOLIDUS, right-left
+ '\u06f0' # 0xB0 -> EXTENDED ARABIC-INDIC DIGIT ZERO, right-left (need override)
+ '\u06f1' # 0xB1 -> EXTENDED ARABIC-INDIC DIGIT ONE, right-left (need override)
+ '\u06f2' # 0xB2 -> EXTENDED ARABIC-INDIC DIGIT TWO, right-left (need override)
+ '\u06f3' # 0xB3 -> EXTENDED ARABIC-INDIC DIGIT THREE, right-left (need override)
+ '\u06f4' # 0xB4 -> EXTENDED ARABIC-INDIC DIGIT FOUR, right-left (need override)
+ '\u06f5' # 0xB5 -> EXTENDED ARABIC-INDIC DIGIT FIVE, right-left (need override)
+ '\u06f6' # 0xB6 -> EXTENDED ARABIC-INDIC DIGIT SIX, right-left (need override)
+ '\u06f7' # 0xB7 -> EXTENDED ARABIC-INDIC DIGIT SEVEN, right-left (need override)
+ '\u06f8' # 0xB8 -> EXTENDED ARABIC-INDIC DIGIT EIGHT, right-left (need override)
+ '\u06f9' # 0xB9 -> EXTENDED ARABIC-INDIC DIGIT NINE, right-left (need override)
+ ':' # 0xBA -> COLON, right-left
+ '\u061b' # 0xBB -> ARABIC SEMICOLON
+ '<' # 0xBC -> LESS-THAN SIGN, right-left
+ '=' # 0xBD -> EQUALS SIGN, right-left
+ '>' # 0xBE -> GREATER-THAN SIGN, right-left
+ '\u061f' # 0xBF -> ARABIC QUESTION MARK
+ '\u274a' # 0xC0 -> EIGHT TEARDROP-SPOKED PROPELLER ASTERISK, right-left
+ '\u0621' # 0xC1 -> ARABIC LETTER HAMZA
+ '\u0622' # 0xC2 -> ARABIC LETTER ALEF WITH MADDA ABOVE
+ '\u0623' # 0xC3 -> ARABIC LETTER ALEF WITH HAMZA ABOVE
+ '\u0624' # 0xC4 -> ARABIC LETTER WAW WITH HAMZA ABOVE
+ '\u0625' # 0xC5 -> ARABIC LETTER ALEF WITH HAMZA BELOW
+ '\u0626' # 0xC6 -> ARABIC LETTER YEH WITH HAMZA ABOVE
+ '\u0627' # 0xC7 -> ARABIC LETTER ALEF
+ '\u0628' # 0xC8 -> ARABIC LETTER BEH
+ '\u0629' # 0xC9 -> ARABIC LETTER TEH MARBUTA
+ '\u062a' # 0xCA -> ARABIC LETTER TEH
+ '\u062b' # 0xCB -> ARABIC LETTER THEH
+ '\u062c' # 0xCC -> ARABIC LETTER JEEM
+ '\u062d' # 0xCD -> ARABIC LETTER HAH
+ '\u062e' # 0xCE -> ARABIC LETTER KHAH
+ '\u062f' # 0xCF -> ARABIC LETTER DAL
+ '\u0630' # 0xD0 -> ARABIC LETTER THAL
+ '\u0631' # 0xD1 -> ARABIC LETTER REH
+ '\u0632' # 0xD2 -> ARABIC LETTER ZAIN
+ '\u0633' # 0xD3 -> ARABIC LETTER SEEN
+ '\u0634' # 0xD4 -> ARABIC LETTER SHEEN
+ '\u0635' # 0xD5 -> ARABIC LETTER SAD
+ '\u0636' # 0xD6 -> ARABIC LETTER DAD
+ '\u0637' # 0xD7 -> ARABIC LETTER TAH
+ '\u0638' # 0xD8 -> ARABIC LETTER ZAH
+ '\u0639' # 0xD9 -> ARABIC LETTER AIN
+ '\u063a' # 0xDA -> ARABIC LETTER GHAIN
+ '[' # 0xDB -> LEFT SQUARE BRACKET, right-left
+ '\\' # 0xDC -> REVERSE SOLIDUS, right-left
+ ']' # 0xDD -> RIGHT SQUARE BRACKET, right-left
+ '^' # 0xDE -> CIRCUMFLEX ACCENT, right-left
+ '_' # 0xDF -> LOW LINE, right-left
+ '\u0640' # 0xE0 -> ARABIC TATWEEL
+ '\u0641' # 0xE1 -> ARABIC LETTER FEH
+ '\u0642' # 0xE2 -> ARABIC LETTER QAF
+ '\u0643' # 0xE3 -> ARABIC LETTER KAF
+ '\u0644' # 0xE4 -> ARABIC LETTER LAM
+ '\u0645' # 0xE5 -> ARABIC LETTER MEEM
+ '\u0646' # 0xE6 -> ARABIC LETTER NOON
+ '\u0647' # 0xE7 -> ARABIC LETTER HEH
+ '\u0648' # 0xE8 -> ARABIC LETTER WAW
+ '\u0649' # 0xE9 -> ARABIC LETTER ALEF MAKSURA
+ '\u064a' # 0xEA -> ARABIC LETTER YEH
+ '\u064b' # 0xEB -> ARABIC FATHATAN
+ '\u064c' # 0xEC -> ARABIC DAMMATAN
+ '\u064d' # 0xED -> ARABIC KASRATAN
+ '\u064e' # 0xEE -> ARABIC FATHA
+ '\u064f' # 0xEF -> ARABIC DAMMA
+ '\u0650' # 0xF0 -> ARABIC KASRA
+ '\u0651' # 0xF1 -> ARABIC SHADDA
+ '\u0652' # 0xF2 -> ARABIC SUKUN
+ '\u067e' # 0xF3 -> ARABIC LETTER PEH
+ '\u0679' # 0xF4 -> ARABIC LETTER TTEH
+ '\u0686' # 0xF5 -> ARABIC LETTER TCHEH
+ '\u06d5' # 0xF6 -> ARABIC LETTER AE
+ '\u06a4' # 0xF7 -> ARABIC LETTER VEH
+ '\u06af' # 0xF8 -> ARABIC LETTER GAF
+ '\u0688' # 0xF9 -> ARABIC LETTER DDAL
+ '\u0691' # 0xFA -> ARABIC LETTER RREH
+ '{' # 0xFB -> LEFT CURLY BRACKET, right-left
+ '|' # 0xFC -> VERTICAL LINE, right-left
+ '}' # 0xFD -> RIGHT CURLY BRACKET, right-left
+ '\u0698' # 0xFE -> ARABIC LETTER JEH
+ '\u06d2' # 0xFF -> ARABIC LETTER YEH BARREE
)
### Encoding table
diff --git a/Lib/encodings/mac_greek.py b/Lib/encodings/mac_greek.py
index 68f4fff0dba..d3d0c4f0c38 100644
--- a/Lib/encodings/mac_greek.py
+++ b/Lib/encodings/mac_greek.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xb9' # 0x81 -> SUPERSCRIPT ONE
- u'\xb2' # 0x82 -> SUPERSCRIPT TWO
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xb3' # 0x84 -> SUPERSCRIPT THREE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\u0385' # 0x87 -> GREEK DIALYTIKA TONOS
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\u0384' # 0x8B -> GREEK TONOS
- u'\xa8' # 0x8C -> DIAERESIS
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xa3' # 0x92 -> POUND SIGN
- u'\u2122' # 0x93 -> TRADE MARK SIGN
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\u2022' # 0x96 -> BULLET
- u'\xbd' # 0x97 -> VULGAR FRACTION ONE HALF
- u'\u2030' # 0x98 -> PER MILLE SIGN
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xa6' # 0x9B -> BROKEN BAR
- u'\u20ac' # 0x9C -> EURO SIGN # before Mac OS 9.2.2, was SOFT HYPHEN
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\u0393' # 0xA1 -> GREEK CAPITAL LETTER GAMMA
- u'\u0394' # 0xA2 -> GREEK CAPITAL LETTER DELTA
- u'\u0398' # 0xA3 -> GREEK CAPITAL LETTER THETA
- u'\u039b' # 0xA4 -> GREEK CAPITAL LETTER LAMDA
- u'\u039e' # 0xA5 -> GREEK CAPITAL LETTER XI
- u'\u03a0' # 0xA6 -> GREEK CAPITAL LETTER PI
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u03a3' # 0xAA -> GREEK CAPITAL LETTER SIGMA
- u'\u03aa' # 0xAB -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
- u'\xa7' # 0xAC -> SECTION SIGN
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\xb0' # 0xAE -> DEGREE SIGN
- u'\xb7' # 0xAF -> MIDDLE DOT
- u'\u0391' # 0xB0 -> GREEK CAPITAL LETTER ALPHA
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\xa5' # 0xB4 -> YEN SIGN
- u'\u0392' # 0xB5 -> GREEK CAPITAL LETTER BETA
- u'\u0395' # 0xB6 -> GREEK CAPITAL LETTER EPSILON
- u'\u0396' # 0xB7 -> GREEK CAPITAL LETTER ZETA
- u'\u0397' # 0xB8 -> GREEK CAPITAL LETTER ETA
- u'\u0399' # 0xB9 -> GREEK CAPITAL LETTER IOTA
- u'\u039a' # 0xBA -> GREEK CAPITAL LETTER KAPPA
- u'\u039c' # 0xBB -> GREEK CAPITAL LETTER MU
- u'\u03a6' # 0xBC -> GREEK CAPITAL LETTER PHI
- u'\u03ab' # 0xBD -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
- u'\u03a8' # 0xBE -> GREEK CAPITAL LETTER PSI
- u'\u03a9' # 0xBF -> GREEK CAPITAL LETTER OMEGA
- u'\u03ac' # 0xC0 -> GREEK SMALL LETTER ALPHA WITH TONOS
- u'\u039d' # 0xC1 -> GREEK CAPITAL LETTER NU
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u039f' # 0xC3 -> GREEK CAPITAL LETTER OMICRON
- u'\u03a1' # 0xC4 -> GREEK CAPITAL LETTER RHO
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u03a4' # 0xC6 -> GREEK CAPITAL LETTER TAU
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\u03a5' # 0xCB -> GREEK CAPITAL LETTER UPSILON
- u'\u03a7' # 0xCC -> GREEK CAPITAL LETTER CHI
- u'\u0386' # 0xCD -> GREEK CAPITAL LETTER ALPHA WITH TONOS
- u'\u0388' # 0xCE -> GREEK CAPITAL LETTER EPSILON WITH TONOS
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2015' # 0xD1 -> HORIZONTAL BAR
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u0389' # 0xD7 -> GREEK CAPITAL LETTER ETA WITH TONOS
- u'\u038a' # 0xD8 -> GREEK CAPITAL LETTER IOTA WITH TONOS
- u'\u038c' # 0xD9 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
- u'\u038e' # 0xDA -> GREEK CAPITAL LETTER UPSILON WITH TONOS
- u'\u03ad' # 0xDB -> GREEK SMALL LETTER EPSILON WITH TONOS
- u'\u03ae' # 0xDC -> GREEK SMALL LETTER ETA WITH TONOS
- u'\u03af' # 0xDD -> GREEK SMALL LETTER IOTA WITH TONOS
- u'\u03cc' # 0xDE -> GREEK SMALL LETTER OMICRON WITH TONOS
- u'\u038f' # 0xDF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
- u'\u03cd' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH TONOS
- u'\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
- u'\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
- u'\u03c8' # 0xE3 -> GREEK SMALL LETTER PSI
- u'\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
- u'\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
- u'\u03c6' # 0xE6 -> GREEK SMALL LETTER PHI
- u'\u03b3' # 0xE7 -> GREEK SMALL LETTER GAMMA
- u'\u03b7' # 0xE8 -> GREEK SMALL LETTER ETA
- u'\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
- u'\u03be' # 0xEA -> GREEK SMALL LETTER XI
- u'\u03ba' # 0xEB -> GREEK SMALL LETTER KAPPA
- u'\u03bb' # 0xEC -> GREEK SMALL LETTER LAMDA
- u'\u03bc' # 0xED -> GREEK SMALL LETTER MU
- u'\u03bd' # 0xEE -> GREEK SMALL LETTER NU
- u'\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
- u'\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
- u'\u03ce' # 0xF1 -> GREEK SMALL LETTER OMEGA WITH TONOS
- u'\u03c1' # 0xF2 -> GREEK SMALL LETTER RHO
- u'\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
- u'\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
- u'\u03b8' # 0xF5 -> GREEK SMALL LETTER THETA
- u'\u03c9' # 0xF6 -> GREEK SMALL LETTER OMEGA
- u'\u03c2' # 0xF7 -> GREEK SMALL LETTER FINAL SIGMA
- u'\u03c7' # 0xF8 -> GREEK SMALL LETTER CHI
- u'\u03c5' # 0xF9 -> GREEK SMALL LETTER UPSILON
- u'\u03b6' # 0xFA -> GREEK SMALL LETTER ZETA
- u'\u03ca' # 0xFB -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
- u'\u03cb' # 0xFC -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
- u'\u0390' # 0xFD -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
- u'\u03b0' # 0xFE -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
- u'\xad' # 0xFF -> SOFT HYPHEN # before Mac OS 9.2.2, was undefined
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xb9' # 0x81 -> SUPERSCRIPT ONE
+ '\xb2' # 0x82 -> SUPERSCRIPT TWO
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xb3' # 0x84 -> SUPERSCRIPT THREE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\u0385' # 0x87 -> GREEK DIALYTIKA TONOS
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\u0384' # 0x8B -> GREEK TONOS
+ '\xa8' # 0x8C -> DIAERESIS
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xa3' # 0x92 -> POUND SIGN
+ '\u2122' # 0x93 -> TRADE MARK SIGN
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\u2022' # 0x96 -> BULLET
+ '\xbd' # 0x97 -> VULGAR FRACTION ONE HALF
+ '\u2030' # 0x98 -> PER MILLE SIGN
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xa6' # 0x9B -> BROKEN BAR
+ '\u20ac' # 0x9C -> EURO SIGN # before Mac OS 9.2.2, was SOFT HYPHEN
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\u0393' # 0xA1 -> GREEK CAPITAL LETTER GAMMA
+ '\u0394' # 0xA2 -> GREEK CAPITAL LETTER DELTA
+ '\u0398' # 0xA3 -> GREEK CAPITAL LETTER THETA
+ '\u039b' # 0xA4 -> GREEK CAPITAL LETTER LAMDA
+ '\u039e' # 0xA5 -> GREEK CAPITAL LETTER XI
+ '\u03a0' # 0xA6 -> GREEK CAPITAL LETTER PI
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u03a3' # 0xAA -> GREEK CAPITAL LETTER SIGMA
+ '\u03aa' # 0xAB -> GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
+ '\xa7' # 0xAC -> SECTION SIGN
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\xb0' # 0xAE -> DEGREE SIGN
+ '\xb7' # 0xAF -> MIDDLE DOT
+ '\u0391' # 0xB0 -> GREEK CAPITAL LETTER ALPHA
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\xa5' # 0xB4 -> YEN SIGN
+ '\u0392' # 0xB5 -> GREEK CAPITAL LETTER BETA
+ '\u0395' # 0xB6 -> GREEK CAPITAL LETTER EPSILON
+ '\u0396' # 0xB7 -> GREEK CAPITAL LETTER ZETA
+ '\u0397' # 0xB8 -> GREEK CAPITAL LETTER ETA
+ '\u0399' # 0xB9 -> GREEK CAPITAL LETTER IOTA
+ '\u039a' # 0xBA -> GREEK CAPITAL LETTER KAPPA
+ '\u039c' # 0xBB -> GREEK CAPITAL LETTER MU
+ '\u03a6' # 0xBC -> GREEK CAPITAL LETTER PHI
+ '\u03ab' # 0xBD -> GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
+ '\u03a8' # 0xBE -> GREEK CAPITAL LETTER PSI
+ '\u03a9' # 0xBF -> GREEK CAPITAL LETTER OMEGA
+ '\u03ac' # 0xC0 -> GREEK SMALL LETTER ALPHA WITH TONOS
+ '\u039d' # 0xC1 -> GREEK CAPITAL LETTER NU
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u039f' # 0xC3 -> GREEK CAPITAL LETTER OMICRON
+ '\u03a1' # 0xC4 -> GREEK CAPITAL LETTER RHO
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u03a4' # 0xC6 -> GREEK CAPITAL LETTER TAU
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\u03a5' # 0xCB -> GREEK CAPITAL LETTER UPSILON
+ '\u03a7' # 0xCC -> GREEK CAPITAL LETTER CHI
+ '\u0386' # 0xCD -> GREEK CAPITAL LETTER ALPHA WITH TONOS
+ '\u0388' # 0xCE -> GREEK CAPITAL LETTER EPSILON WITH TONOS
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2015' # 0xD1 -> HORIZONTAL BAR
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u0389' # 0xD7 -> GREEK CAPITAL LETTER ETA WITH TONOS
+ '\u038a' # 0xD8 -> GREEK CAPITAL LETTER IOTA WITH TONOS
+ '\u038c' # 0xD9 -> GREEK CAPITAL LETTER OMICRON WITH TONOS
+ '\u038e' # 0xDA -> GREEK CAPITAL LETTER UPSILON WITH TONOS
+ '\u03ad' # 0xDB -> GREEK SMALL LETTER EPSILON WITH TONOS
+ '\u03ae' # 0xDC -> GREEK SMALL LETTER ETA WITH TONOS
+ '\u03af' # 0xDD -> GREEK SMALL LETTER IOTA WITH TONOS
+ '\u03cc' # 0xDE -> GREEK SMALL LETTER OMICRON WITH TONOS
+ '\u038f' # 0xDF -> GREEK CAPITAL LETTER OMEGA WITH TONOS
+ '\u03cd' # 0xE0 -> GREEK SMALL LETTER UPSILON WITH TONOS
+ '\u03b1' # 0xE1 -> GREEK SMALL LETTER ALPHA
+ '\u03b2' # 0xE2 -> GREEK SMALL LETTER BETA
+ '\u03c8' # 0xE3 -> GREEK SMALL LETTER PSI
+ '\u03b4' # 0xE4 -> GREEK SMALL LETTER DELTA
+ '\u03b5' # 0xE5 -> GREEK SMALL LETTER EPSILON
+ '\u03c6' # 0xE6 -> GREEK SMALL LETTER PHI
+ '\u03b3' # 0xE7 -> GREEK SMALL LETTER GAMMA
+ '\u03b7' # 0xE8 -> GREEK SMALL LETTER ETA
+ '\u03b9' # 0xE9 -> GREEK SMALL LETTER IOTA
+ '\u03be' # 0xEA -> GREEK SMALL LETTER XI
+ '\u03ba' # 0xEB -> GREEK SMALL LETTER KAPPA
+ '\u03bb' # 0xEC -> GREEK SMALL LETTER LAMDA
+ '\u03bc' # 0xED -> GREEK SMALL LETTER MU
+ '\u03bd' # 0xEE -> GREEK SMALL LETTER NU
+ '\u03bf' # 0xEF -> GREEK SMALL LETTER OMICRON
+ '\u03c0' # 0xF0 -> GREEK SMALL LETTER PI
+ '\u03ce' # 0xF1 -> GREEK SMALL LETTER OMEGA WITH TONOS
+ '\u03c1' # 0xF2 -> GREEK SMALL LETTER RHO
+ '\u03c3' # 0xF3 -> GREEK SMALL LETTER SIGMA
+ '\u03c4' # 0xF4 -> GREEK SMALL LETTER TAU
+ '\u03b8' # 0xF5 -> GREEK SMALL LETTER THETA
+ '\u03c9' # 0xF6 -> GREEK SMALL LETTER OMEGA
+ '\u03c2' # 0xF7 -> GREEK SMALL LETTER FINAL SIGMA
+ '\u03c7' # 0xF8 -> GREEK SMALL LETTER CHI
+ '\u03c5' # 0xF9 -> GREEK SMALL LETTER UPSILON
+ '\u03b6' # 0xFA -> GREEK SMALL LETTER ZETA
+ '\u03ca' # 0xFB -> GREEK SMALL LETTER IOTA WITH DIALYTIKA
+ '\u03cb' # 0xFC -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA
+ '\u0390' # 0xFD -> GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
+ '\u03b0' # 0xFE -> GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
+ '\xad' # 0xFF -> SOFT HYPHEN # before Mac OS 9.2.2, was undefined
)
### Encoding table
diff --git a/Lib/encodings/mac_iceland.py b/Lib/encodings/mac_iceland.py
index c24add2ad0d..add10f4e555 100644
--- a/Lib/encodings/mac_iceland.py
+++ b/Lib/encodings/mac_iceland.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\xdd' # 0xA0 -> LATIN CAPITAL LETTER Y WITH ACUTE
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\xb4' # 0xAB -> ACUTE ACCENT
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
- u'\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\xa5' # 0xB4 -> YEN SIGN
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u220f' # 0xB8 -> N-ARY PRODUCT
- u'\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
- u'\u222b' # 0xBA -> INTEGRAL
- u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
- u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
- u'\xe6' # 0xBE -> LATIN SMALL LETTER AE
- u'\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
- u'\xbf' # 0xC0 -> INVERTED QUESTION MARK
- u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u2044' # 0xDA -> FRACTION SLASH
- u'\u20ac' # 0xDB -> EURO SIGN
- u'\xd0' # 0xDC -> LATIN CAPITAL LETTER ETH
- u'\xf0' # 0xDD -> LATIN SMALL LETTER ETH
- u'\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
- u'\xfe' # 0xDF -> LATIN SMALL LETTER THORN
- u'\xfd' # 0xE0 -> LATIN SMALL LETTER Y WITH ACUTE
- u'\xb7' # 0xE1 -> MIDDLE DOT
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2030' # 0xE4 -> PER MILLE SIGN
- u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\uf8ff' # 0xF0 -> Apple logo
- u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
- u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u02dc' # 0xF7 -> SMALL TILDE
- u'\xaf' # 0xF8 -> MACRON
- u'\u02d8' # 0xF9 -> BREVE
- u'\u02d9' # 0xFA -> DOT ABOVE
- u'\u02da' # 0xFB -> RING ABOVE
- u'\xb8' # 0xFC -> CEDILLA
- u'\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
- u'\u02db' # 0xFE -> OGONEK
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\xdd' # 0xA0 -> LATIN CAPITAL LETTER Y WITH ACUTE
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\xb4' # 0xAB -> ACUTE ACCENT
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
+ '\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\xa5' # 0xB4 -> YEN SIGN
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u220f' # 0xB8 -> N-ARY PRODUCT
+ '\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
+ '\u222b' # 0xBA -> INTEGRAL
+ '\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
+ '\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
+ '\xe6' # 0xBE -> LATIN SMALL LETTER AE
+ '\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
+ '\xbf' # 0xC0 -> INVERTED QUESTION MARK
+ '\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u2044' # 0xDA -> FRACTION SLASH
+ '\u20ac' # 0xDB -> EURO SIGN
+ '\xd0' # 0xDC -> LATIN CAPITAL LETTER ETH
+ '\xf0' # 0xDD -> LATIN SMALL LETTER ETH
+ '\xde' # 0xDE -> LATIN CAPITAL LETTER THORN
+ '\xfe' # 0xDF -> LATIN SMALL LETTER THORN
+ '\xfd' # 0xE0 -> LATIN SMALL LETTER Y WITH ACUTE
+ '\xb7' # 0xE1 -> MIDDLE DOT
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2030' # 0xE4 -> PER MILLE SIGN
+ '\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\uf8ff' # 0xF0 -> Apple logo
+ '\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
+ '\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u02dc' # 0xF7 -> SMALL TILDE
+ '\xaf' # 0xF8 -> MACRON
+ '\u02d8' # 0xF9 -> BREVE
+ '\u02d9' # 0xFA -> DOT ABOVE
+ '\u02da' # 0xFB -> RING ABOVE
+ '\xb8' # 0xFC -> CEDILLA
+ '\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
+ '\u02db' # 0xFE -> OGONEK
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/mac_roman.py b/Lib/encodings/mac_roman.py
index 62605ec634f..b74b002134f 100644
--- a/Lib/encodings/mac_roman.py
+++ b/Lib/encodings/mac_roman.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\xb4' # 0xAB -> ACUTE ACCENT
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
- u'\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\xa5' # 0xB4 -> YEN SIGN
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u220f' # 0xB8 -> N-ARY PRODUCT
- u'\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
- u'\u222b' # 0xBA -> INTEGRAL
- u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
- u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
- u'\xe6' # 0xBE -> LATIN SMALL LETTER AE
- u'\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
- u'\xbf' # 0xC0 -> INVERTED QUESTION MARK
- u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u2044' # 0xDA -> FRACTION SLASH
- u'\u20ac' # 0xDB -> EURO SIGN
- u'\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\ufb01' # 0xDE -> LATIN SMALL LIGATURE FI
- u'\ufb02' # 0xDF -> LATIN SMALL LIGATURE FL
- u'\u2021' # 0xE0 -> DOUBLE DAGGER
- u'\xb7' # 0xE1 -> MIDDLE DOT
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2030' # 0xE4 -> PER MILLE SIGN
- u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\uf8ff' # 0xF0 -> Apple logo
- u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
- u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u02dc' # 0xF7 -> SMALL TILDE
- u'\xaf' # 0xF8 -> MACRON
- u'\u02d8' # 0xF9 -> BREVE
- u'\u02d9' # 0xFA -> DOT ABOVE
- u'\u02da' # 0xFB -> RING ABOVE
- u'\xb8' # 0xFC -> CEDILLA
- u'\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
- u'\u02db' # 0xFE -> OGONEK
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\xb4' # 0xAB -> ACUTE ACCENT
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
+ '\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\xa5' # 0xB4 -> YEN SIGN
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u220f' # 0xB8 -> N-ARY PRODUCT
+ '\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
+ '\u222b' # 0xBA -> INTEGRAL
+ '\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
+ '\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
+ '\xe6' # 0xBE -> LATIN SMALL LETTER AE
+ '\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
+ '\xbf' # 0xC0 -> INVERTED QUESTION MARK
+ '\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u2044' # 0xDA -> FRACTION SLASH
+ '\u20ac' # 0xDB -> EURO SIGN
+ '\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\ufb01' # 0xDE -> LATIN SMALL LIGATURE FI
+ '\ufb02' # 0xDF -> LATIN SMALL LIGATURE FL
+ '\u2021' # 0xE0 -> DOUBLE DAGGER
+ '\xb7' # 0xE1 -> MIDDLE DOT
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2030' # 0xE4 -> PER MILLE SIGN
+ '\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\uf8ff' # 0xF0 -> Apple logo
+ '\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
+ '\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u02dc' # 0xF7 -> SMALL TILDE
+ '\xaf' # 0xF8 -> MACRON
+ '\u02d8' # 0xF9 -> BREVE
+ '\u02d9' # 0xFA -> DOT ABOVE
+ '\u02da' # 0xFB -> RING ABOVE
+ '\xb8' # 0xFC -> CEDILLA
+ '\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
+ '\u02db' # 0xFE -> OGONEK
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/mac_romanian.py b/Lib/encodings/mac_romanian.py
index 5bd5ae86253..d141b4c5091 100644
--- a/Lib/encodings/mac_romanian.py
+++ b/Lib/encodings/mac_romanian.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\xb4' # 0xAB -> ACUTE ACCENT
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\u0102' # 0xAE -> LATIN CAPITAL LETTER A WITH BREVE
- u'\u0218' # 0xAF -> LATIN CAPITAL LETTER S WITH COMMA BELOW # for Unicode 3.0 and later
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\xa5' # 0xB4 -> YEN SIGN
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u220f' # 0xB8 -> N-ARY PRODUCT
- u'\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
- u'\u222b' # 0xBA -> INTEGRAL
- u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
- u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
- u'\u0103' # 0xBE -> LATIN SMALL LETTER A WITH BREVE
- u'\u0219' # 0xBF -> LATIN SMALL LETTER S WITH COMMA BELOW # for Unicode 3.0 and later
- u'\xbf' # 0xC0 -> INVERTED QUESTION MARK
- u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u2044' # 0xDA -> FRACTION SLASH
- u'\u20ac' # 0xDB -> EURO SIGN
- u'\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
- u'\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
- u'\u021a' # 0xDE -> LATIN CAPITAL LETTER T WITH COMMA BELOW # for Unicode 3.0 and later
- u'\u021b' # 0xDF -> LATIN SMALL LETTER T WITH COMMA BELOW # for Unicode 3.0 and later
- u'\u2021' # 0xE0 -> DOUBLE DAGGER
- u'\xb7' # 0xE1 -> MIDDLE DOT
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2030' # 0xE4 -> PER MILLE SIGN
- u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\uf8ff' # 0xF0 -> Apple logo
- u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
- u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u02dc' # 0xF7 -> SMALL TILDE
- u'\xaf' # 0xF8 -> MACRON
- u'\u02d8' # 0xF9 -> BREVE
- u'\u02d9' # 0xFA -> DOT ABOVE
- u'\u02da' # 0xFB -> RING ABOVE
- u'\xb8' # 0xFC -> CEDILLA
- u'\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
- u'\u02db' # 0xFE -> OGONEK
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\xb4' # 0xAB -> ACUTE ACCENT
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\u0102' # 0xAE -> LATIN CAPITAL LETTER A WITH BREVE
+ '\u0218' # 0xAF -> LATIN CAPITAL LETTER S WITH COMMA BELOW # for Unicode 3.0 and later
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\xa5' # 0xB4 -> YEN SIGN
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u220f' # 0xB8 -> N-ARY PRODUCT
+ '\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
+ '\u222b' # 0xBA -> INTEGRAL
+ '\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
+ '\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
+ '\u0103' # 0xBE -> LATIN SMALL LETTER A WITH BREVE
+ '\u0219' # 0xBF -> LATIN SMALL LETTER S WITH COMMA BELOW # for Unicode 3.0 and later
+ '\xbf' # 0xC0 -> INVERTED QUESTION MARK
+ '\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u2044' # 0xDA -> FRACTION SLASH
+ '\u20ac' # 0xDB -> EURO SIGN
+ '\u2039' # 0xDC -> SINGLE LEFT-POINTING ANGLE QUOTATION MARK
+ '\u203a' # 0xDD -> SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
+ '\u021a' # 0xDE -> LATIN CAPITAL LETTER T WITH COMMA BELOW # for Unicode 3.0 and later
+ '\u021b' # 0xDF -> LATIN SMALL LETTER T WITH COMMA BELOW # for Unicode 3.0 and later
+ '\u2021' # 0xE0 -> DOUBLE DAGGER
+ '\xb7' # 0xE1 -> MIDDLE DOT
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2030' # 0xE4 -> PER MILLE SIGN
+ '\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\uf8ff' # 0xF0 -> Apple logo
+ '\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\u0131' # 0xF5 -> LATIN SMALL LETTER DOTLESS I
+ '\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u02dc' # 0xF7 -> SMALL TILDE
+ '\xaf' # 0xF8 -> MACRON
+ '\u02d8' # 0xF9 -> BREVE
+ '\u02d9' # 0xFA -> DOT ABOVE
+ '\u02da' # 0xFB -> RING ABOVE
+ '\xb8' # 0xFC -> CEDILLA
+ '\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
+ '\u02db' # 0xFE -> OGONEK
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/mac_turkish.py b/Lib/encodings/mac_turkish.py
index 0787f4990b4..044d4cb5ad7 100644
--- a/Lib/encodings/mac_turkish.py
+++ b/Lib/encodings/mac_turkish.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> CONTROL CHARACTER
- u'\x01' # 0x01 -> CONTROL CHARACTER
- u'\x02' # 0x02 -> CONTROL CHARACTER
- u'\x03' # 0x03 -> CONTROL CHARACTER
- u'\x04' # 0x04 -> CONTROL CHARACTER
- u'\x05' # 0x05 -> CONTROL CHARACTER
- u'\x06' # 0x06 -> CONTROL CHARACTER
- u'\x07' # 0x07 -> CONTROL CHARACTER
- u'\x08' # 0x08 -> CONTROL CHARACTER
- u'\t' # 0x09 -> CONTROL CHARACTER
- u'\n' # 0x0A -> CONTROL CHARACTER
- u'\x0b' # 0x0B -> CONTROL CHARACTER
- u'\x0c' # 0x0C -> CONTROL CHARACTER
- u'\r' # 0x0D -> CONTROL CHARACTER
- u'\x0e' # 0x0E -> CONTROL CHARACTER
- u'\x0f' # 0x0F -> CONTROL CHARACTER
- u'\x10' # 0x10 -> CONTROL CHARACTER
- u'\x11' # 0x11 -> CONTROL CHARACTER
- u'\x12' # 0x12 -> CONTROL CHARACTER
- u'\x13' # 0x13 -> CONTROL CHARACTER
- u'\x14' # 0x14 -> CONTROL CHARACTER
- u'\x15' # 0x15 -> CONTROL CHARACTER
- u'\x16' # 0x16 -> CONTROL CHARACTER
- u'\x17' # 0x17 -> CONTROL CHARACTER
- u'\x18' # 0x18 -> CONTROL CHARACTER
- u'\x19' # 0x19 -> CONTROL CHARACTER
- u'\x1a' # 0x1A -> CONTROL CHARACTER
- u'\x1b' # 0x1B -> CONTROL CHARACTER
- u'\x1c' # 0x1C -> CONTROL CHARACTER
- u'\x1d' # 0x1D -> CONTROL CHARACTER
- u'\x1e' # 0x1E -> CONTROL CHARACTER
- u'\x1f' # 0x1F -> CONTROL CHARACTER
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> CONTROL CHARACTER
- u'\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
- u'\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
- u'\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
- u'\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
- u'\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
- u'\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
- u'\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
- u'\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
- u'\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
- u'\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
- u'\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
- u'\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
- u'\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
- u'\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
- u'\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
- u'\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
- u'\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
- u'\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
- u'\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
- u'\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
- u'\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
- u'\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
- u'\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
- u'\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
- u'\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
- u'\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
- u'\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
- u'\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
- u'\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
- u'\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
- u'\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
- u'\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
- u'\u2020' # 0xA0 -> DAGGER
- u'\xb0' # 0xA1 -> DEGREE SIGN
- u'\xa2' # 0xA2 -> CENT SIGN
- u'\xa3' # 0xA3 -> POUND SIGN
- u'\xa7' # 0xA4 -> SECTION SIGN
- u'\u2022' # 0xA5 -> BULLET
- u'\xb6' # 0xA6 -> PILCROW SIGN
- u'\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
- u'\xae' # 0xA8 -> REGISTERED SIGN
- u'\xa9' # 0xA9 -> COPYRIGHT SIGN
- u'\u2122' # 0xAA -> TRADE MARK SIGN
- u'\xb4' # 0xAB -> ACUTE ACCENT
- u'\xa8' # 0xAC -> DIAERESIS
- u'\u2260' # 0xAD -> NOT EQUAL TO
- u'\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
- u'\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
- u'\u221e' # 0xB0 -> INFINITY
- u'\xb1' # 0xB1 -> PLUS-MINUS SIGN
- u'\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
- u'\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
- u'\xa5' # 0xB4 -> YEN SIGN
- u'\xb5' # 0xB5 -> MICRO SIGN
- u'\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
- u'\u2211' # 0xB7 -> N-ARY SUMMATION
- u'\u220f' # 0xB8 -> N-ARY PRODUCT
- u'\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
- u'\u222b' # 0xBA -> INTEGRAL
- u'\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
- u'\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
- u'\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
- u'\xe6' # 0xBE -> LATIN SMALL LETTER AE
- u'\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
- u'\xbf' # 0xC0 -> INVERTED QUESTION MARK
- u'\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
- u'\xac' # 0xC2 -> NOT SIGN
- u'\u221a' # 0xC3 -> SQUARE ROOT
- u'\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
- u'\u2248' # 0xC5 -> ALMOST EQUAL TO
- u'\u2206' # 0xC6 -> INCREMENT
- u'\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- u'\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
- u'\xa0' # 0xCA -> NO-BREAK SPACE
- u'\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
- u'\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
- u'\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
- u'\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
- u'\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
- u'\u2013' # 0xD0 -> EN DASH
- u'\u2014' # 0xD1 -> EM DASH
- u'\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
- u'\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
- u'\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
- u'\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
- u'\xf7' # 0xD6 -> DIVISION SIGN
- u'\u25ca' # 0xD7 -> LOZENGE
- u'\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
- u'\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
- u'\u011e' # 0xDA -> LATIN CAPITAL LETTER G WITH BREVE
- u'\u011f' # 0xDB -> LATIN SMALL LETTER G WITH BREVE
- u'\u0130' # 0xDC -> LATIN CAPITAL LETTER I WITH DOT ABOVE
- u'\u0131' # 0xDD -> LATIN SMALL LETTER DOTLESS I
- u'\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
- u'\u015f' # 0xDF -> LATIN SMALL LETTER S WITH CEDILLA
- u'\u2021' # 0xE0 -> DOUBLE DAGGER
- u'\xb7' # 0xE1 -> MIDDLE DOT
- u'\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
- u'\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
- u'\u2030' # 0xE4 -> PER MILLE SIGN
- u'\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
- u'\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
- u'\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
- u'\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
- u'\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
- u'\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
- u'\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
- u'\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
- u'\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
- u'\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
- u'\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
- u'\uf8ff' # 0xF0 -> Apple logo
- u'\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
- u'\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
- u'\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
- u'\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
- u'\uf8a0' # 0xF5 -> undefined1
- u'\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
- u'\u02dc' # 0xF7 -> SMALL TILDE
- u'\xaf' # 0xF8 -> MACRON
- u'\u02d8' # 0xF9 -> BREVE
- u'\u02d9' # 0xFA -> DOT ABOVE
- u'\u02da' # 0xFB -> RING ABOVE
- u'\xb8' # 0xFC -> CEDILLA
- u'\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
- u'\u02db' # 0xFE -> OGONEK
- u'\u02c7' # 0xFF -> CARON
+ '\x00' # 0x00 -> CONTROL CHARACTER
+ '\x01' # 0x01 -> CONTROL CHARACTER
+ '\x02' # 0x02 -> CONTROL CHARACTER
+ '\x03' # 0x03 -> CONTROL CHARACTER
+ '\x04' # 0x04 -> CONTROL CHARACTER
+ '\x05' # 0x05 -> CONTROL CHARACTER
+ '\x06' # 0x06 -> CONTROL CHARACTER
+ '\x07' # 0x07 -> CONTROL CHARACTER
+ '\x08' # 0x08 -> CONTROL CHARACTER
+ '\t' # 0x09 -> CONTROL CHARACTER
+ '\n' # 0x0A -> CONTROL CHARACTER
+ '\x0b' # 0x0B -> CONTROL CHARACTER
+ '\x0c' # 0x0C -> CONTROL CHARACTER
+ '\r' # 0x0D -> CONTROL CHARACTER
+ '\x0e' # 0x0E -> CONTROL CHARACTER
+ '\x0f' # 0x0F -> CONTROL CHARACTER
+ '\x10' # 0x10 -> CONTROL CHARACTER
+ '\x11' # 0x11 -> CONTROL CHARACTER
+ '\x12' # 0x12 -> CONTROL CHARACTER
+ '\x13' # 0x13 -> CONTROL CHARACTER
+ '\x14' # 0x14 -> CONTROL CHARACTER
+ '\x15' # 0x15 -> CONTROL CHARACTER
+ '\x16' # 0x16 -> CONTROL CHARACTER
+ '\x17' # 0x17 -> CONTROL CHARACTER
+ '\x18' # 0x18 -> CONTROL CHARACTER
+ '\x19' # 0x19 -> CONTROL CHARACTER
+ '\x1a' # 0x1A -> CONTROL CHARACTER
+ '\x1b' # 0x1B -> CONTROL CHARACTER
+ '\x1c' # 0x1C -> CONTROL CHARACTER
+ '\x1d' # 0x1D -> CONTROL CHARACTER
+ '\x1e' # 0x1E -> CONTROL CHARACTER
+ '\x1f' # 0x1F -> CONTROL CHARACTER
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> CONTROL CHARACTER
+ '\xc4' # 0x80 -> LATIN CAPITAL LETTER A WITH DIAERESIS
+ '\xc5' # 0x81 -> LATIN CAPITAL LETTER A WITH RING ABOVE
+ '\xc7' # 0x82 -> LATIN CAPITAL LETTER C WITH CEDILLA
+ '\xc9' # 0x83 -> LATIN CAPITAL LETTER E WITH ACUTE
+ '\xd1' # 0x84 -> LATIN CAPITAL LETTER N WITH TILDE
+ '\xd6' # 0x85 -> LATIN CAPITAL LETTER O WITH DIAERESIS
+ '\xdc' # 0x86 -> LATIN CAPITAL LETTER U WITH DIAERESIS
+ '\xe1' # 0x87 -> LATIN SMALL LETTER A WITH ACUTE
+ '\xe0' # 0x88 -> LATIN SMALL LETTER A WITH GRAVE
+ '\xe2' # 0x89 -> LATIN SMALL LETTER A WITH CIRCUMFLEX
+ '\xe4' # 0x8A -> LATIN SMALL LETTER A WITH DIAERESIS
+ '\xe3' # 0x8B -> LATIN SMALL LETTER A WITH TILDE
+ '\xe5' # 0x8C -> LATIN SMALL LETTER A WITH RING ABOVE
+ '\xe7' # 0x8D -> LATIN SMALL LETTER C WITH CEDILLA
+ '\xe9' # 0x8E -> LATIN SMALL LETTER E WITH ACUTE
+ '\xe8' # 0x8F -> LATIN SMALL LETTER E WITH GRAVE
+ '\xea' # 0x90 -> LATIN SMALL LETTER E WITH CIRCUMFLEX
+ '\xeb' # 0x91 -> LATIN SMALL LETTER E WITH DIAERESIS
+ '\xed' # 0x92 -> LATIN SMALL LETTER I WITH ACUTE
+ '\xec' # 0x93 -> LATIN SMALL LETTER I WITH GRAVE
+ '\xee' # 0x94 -> LATIN SMALL LETTER I WITH CIRCUMFLEX
+ '\xef' # 0x95 -> LATIN SMALL LETTER I WITH DIAERESIS
+ '\xf1' # 0x96 -> LATIN SMALL LETTER N WITH TILDE
+ '\xf3' # 0x97 -> LATIN SMALL LETTER O WITH ACUTE
+ '\xf2' # 0x98 -> LATIN SMALL LETTER O WITH GRAVE
+ '\xf4' # 0x99 -> LATIN SMALL LETTER O WITH CIRCUMFLEX
+ '\xf6' # 0x9A -> LATIN SMALL LETTER O WITH DIAERESIS
+ '\xf5' # 0x9B -> LATIN SMALL LETTER O WITH TILDE
+ '\xfa' # 0x9C -> LATIN SMALL LETTER U WITH ACUTE
+ '\xf9' # 0x9D -> LATIN SMALL LETTER U WITH GRAVE
+ '\xfb' # 0x9E -> LATIN SMALL LETTER U WITH CIRCUMFLEX
+ '\xfc' # 0x9F -> LATIN SMALL LETTER U WITH DIAERESIS
+ '\u2020' # 0xA0 -> DAGGER
+ '\xb0' # 0xA1 -> DEGREE SIGN
+ '\xa2' # 0xA2 -> CENT SIGN
+ '\xa3' # 0xA3 -> POUND SIGN
+ '\xa7' # 0xA4 -> SECTION SIGN
+ '\u2022' # 0xA5 -> BULLET
+ '\xb6' # 0xA6 -> PILCROW SIGN
+ '\xdf' # 0xA7 -> LATIN SMALL LETTER SHARP S
+ '\xae' # 0xA8 -> REGISTERED SIGN
+ '\xa9' # 0xA9 -> COPYRIGHT SIGN
+ '\u2122' # 0xAA -> TRADE MARK SIGN
+ '\xb4' # 0xAB -> ACUTE ACCENT
+ '\xa8' # 0xAC -> DIAERESIS
+ '\u2260' # 0xAD -> NOT EQUAL TO
+ '\xc6' # 0xAE -> LATIN CAPITAL LETTER AE
+ '\xd8' # 0xAF -> LATIN CAPITAL LETTER O WITH STROKE
+ '\u221e' # 0xB0 -> INFINITY
+ '\xb1' # 0xB1 -> PLUS-MINUS SIGN
+ '\u2264' # 0xB2 -> LESS-THAN OR EQUAL TO
+ '\u2265' # 0xB3 -> GREATER-THAN OR EQUAL TO
+ '\xa5' # 0xB4 -> YEN SIGN
+ '\xb5' # 0xB5 -> MICRO SIGN
+ '\u2202' # 0xB6 -> PARTIAL DIFFERENTIAL
+ '\u2211' # 0xB7 -> N-ARY SUMMATION
+ '\u220f' # 0xB8 -> N-ARY PRODUCT
+ '\u03c0' # 0xB9 -> GREEK SMALL LETTER PI
+ '\u222b' # 0xBA -> INTEGRAL
+ '\xaa' # 0xBB -> FEMININE ORDINAL INDICATOR
+ '\xba' # 0xBC -> MASCULINE ORDINAL INDICATOR
+ '\u03a9' # 0xBD -> GREEK CAPITAL LETTER OMEGA
+ '\xe6' # 0xBE -> LATIN SMALL LETTER AE
+ '\xf8' # 0xBF -> LATIN SMALL LETTER O WITH STROKE
+ '\xbf' # 0xC0 -> INVERTED QUESTION MARK
+ '\xa1' # 0xC1 -> INVERTED EXCLAMATION MARK
+ '\xac' # 0xC2 -> NOT SIGN
+ '\u221a' # 0xC3 -> SQUARE ROOT
+ '\u0192' # 0xC4 -> LATIN SMALL LETTER F WITH HOOK
+ '\u2248' # 0xC5 -> ALMOST EQUAL TO
+ '\u2206' # 0xC6 -> INCREMENT
+ '\xab' # 0xC7 -> LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\xbb' # 0xC8 -> RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ '\u2026' # 0xC9 -> HORIZONTAL ELLIPSIS
+ '\xa0' # 0xCA -> NO-BREAK SPACE
+ '\xc0' # 0xCB -> LATIN CAPITAL LETTER A WITH GRAVE
+ '\xc3' # 0xCC -> LATIN CAPITAL LETTER A WITH TILDE
+ '\xd5' # 0xCD -> LATIN CAPITAL LETTER O WITH TILDE
+ '\u0152' # 0xCE -> LATIN CAPITAL LIGATURE OE
+ '\u0153' # 0xCF -> LATIN SMALL LIGATURE OE
+ '\u2013' # 0xD0 -> EN DASH
+ '\u2014' # 0xD1 -> EM DASH
+ '\u201c' # 0xD2 -> LEFT DOUBLE QUOTATION MARK
+ '\u201d' # 0xD3 -> RIGHT DOUBLE QUOTATION MARK
+ '\u2018' # 0xD4 -> LEFT SINGLE QUOTATION MARK
+ '\u2019' # 0xD5 -> RIGHT SINGLE QUOTATION MARK
+ '\xf7' # 0xD6 -> DIVISION SIGN
+ '\u25ca' # 0xD7 -> LOZENGE
+ '\xff' # 0xD8 -> LATIN SMALL LETTER Y WITH DIAERESIS
+ '\u0178' # 0xD9 -> LATIN CAPITAL LETTER Y WITH DIAERESIS
+ '\u011e' # 0xDA -> LATIN CAPITAL LETTER G WITH BREVE
+ '\u011f' # 0xDB -> LATIN SMALL LETTER G WITH BREVE
+ '\u0130' # 0xDC -> LATIN CAPITAL LETTER I WITH DOT ABOVE
+ '\u0131' # 0xDD -> LATIN SMALL LETTER DOTLESS I
+ '\u015e' # 0xDE -> LATIN CAPITAL LETTER S WITH CEDILLA
+ '\u015f' # 0xDF -> LATIN SMALL LETTER S WITH CEDILLA
+ '\u2021' # 0xE0 -> DOUBLE DAGGER
+ '\xb7' # 0xE1 -> MIDDLE DOT
+ '\u201a' # 0xE2 -> SINGLE LOW-9 QUOTATION MARK
+ '\u201e' # 0xE3 -> DOUBLE LOW-9 QUOTATION MARK
+ '\u2030' # 0xE4 -> PER MILLE SIGN
+ '\xc2' # 0xE5 -> LATIN CAPITAL LETTER A WITH CIRCUMFLEX
+ '\xca' # 0xE6 -> LATIN CAPITAL LETTER E WITH CIRCUMFLEX
+ '\xc1' # 0xE7 -> LATIN CAPITAL LETTER A WITH ACUTE
+ '\xcb' # 0xE8 -> LATIN CAPITAL LETTER E WITH DIAERESIS
+ '\xc8' # 0xE9 -> LATIN CAPITAL LETTER E WITH GRAVE
+ '\xcd' # 0xEA -> LATIN CAPITAL LETTER I WITH ACUTE
+ '\xce' # 0xEB -> LATIN CAPITAL LETTER I WITH CIRCUMFLEX
+ '\xcf' # 0xEC -> LATIN CAPITAL LETTER I WITH DIAERESIS
+ '\xcc' # 0xED -> LATIN CAPITAL LETTER I WITH GRAVE
+ '\xd3' # 0xEE -> LATIN CAPITAL LETTER O WITH ACUTE
+ '\xd4' # 0xEF -> LATIN CAPITAL LETTER O WITH CIRCUMFLEX
+ '\uf8ff' # 0xF0 -> Apple logo
+ '\xd2' # 0xF1 -> LATIN CAPITAL LETTER O WITH GRAVE
+ '\xda' # 0xF2 -> LATIN CAPITAL LETTER U WITH ACUTE
+ '\xdb' # 0xF3 -> LATIN CAPITAL LETTER U WITH CIRCUMFLEX
+ '\xd9' # 0xF4 -> LATIN CAPITAL LETTER U WITH GRAVE
+ '\uf8a0' # 0xF5 -> undefined1
+ '\u02c6' # 0xF6 -> MODIFIER LETTER CIRCUMFLEX ACCENT
+ '\u02dc' # 0xF7 -> SMALL TILDE
+ '\xaf' # 0xF8 -> MACRON
+ '\u02d8' # 0xF9 -> BREVE
+ '\u02d9' # 0xFA -> DOT ABOVE
+ '\u02da' # 0xFB -> RING ABOVE
+ '\xb8' # 0xFC -> CEDILLA
+ '\u02dd' # 0xFD -> DOUBLE ACUTE ACCENT
+ '\u02db' # 0xFE -> OGONEK
+ '\u02c7' # 0xFF -> CARON
)
### Encoding table
diff --git a/Lib/encodings/punycode.py b/Lib/encodings/punycode.py
index d97200fd35b..66c51013ea4 100644
--- a/Lib/encodings/punycode.py
+++ b/Lib/encodings/punycode.py
@@ -1,7 +1,6 @@
-# -*- coding: iso-8859-1 -*-
""" Codec for the Punicode encoding, as specified in RFC 3492
-Written by Martin v. Löwis.
+Written by Martin v. Löwis.
"""
import codecs
@@ -10,16 +9,15 @@ import codecs
def segregate(str):
"""3.1 Basic code point segregation"""
- base = []
- extended = {}
+ base = bytearray()
+ extended = set()
for c in str:
if ord(c) < 128:
- base.append(c)
+ base.append(ord(c))
else:
- extended[c] = 1
- extended = extended.keys()
- extended.sort()
- return "".join(base).encode("ascii"),extended
+ extended.add(c)
+ extended = sorted(extended)
+ return bytes(base), extended
def selective_len(str, max):
"""Return the length of str, considering only characters below max."""
@@ -76,16 +74,16 @@ def T(j, bias):
if res > 26: return 26
return res
-digits = "abcdefghijklmnopqrstuvwxyz0123456789"
+digits = b"abcdefghijklmnopqrstuvwxyz0123456789"
def generate_generalized_integer(N, bias):
"""3.3 Generalized variable-length integers"""
- result = []
+ result = bytearray()
j = 0
while 1:
t = T(j, bias)
if N < t:
result.append(digits[N])
- return result
+ return bytes(result)
result.append(digits[t + ((N - t) % (36 - t))])
N = (N - t) // (36 - t)
j += 1
@@ -108,21 +106,20 @@ def adapt(delta, first, numchars):
def generate_integers(baselen, deltas):
"""3.4 Bias adaptation"""
# Punycode parameters: initial bias = 72, damp = 700, skew = 38
- result = []
+ result = bytearray()
bias = 72
for points, delta in enumerate(deltas):
s = generate_generalized_integer(delta, bias)
result.extend(s)
bias = adapt(delta, points==0, baselen+points+1)
- return "".join(result)
+ return bytes(result)
def punycode_encode(text):
base, extended = segregate(text)
- base = base.encode("ascii")
deltas = insertion_unsort(text, extended)
extended = generate_integers(len(base), deltas)
if base:
- return base + "-" + extended
+ return base + b"-" + extended
return extended
##################### Decoding #####################################
@@ -137,7 +134,7 @@ def decode_generalized_number(extended, extpos, bias, errors):
char = ord(extended[extpos])
except IndexError:
if errors == "strict":
- raise UnicodeError, "incomplete punicode string"
+ raise UnicodeError("incomplete punicode string")
return extpos + 1, None
extpos += 1
if 0x41 <= char <= 0x5A: # A-Z
@@ -174,37 +171,39 @@ def insertion_sort(base, extended, errors):
char += pos // (len(base) + 1)
if char > 0x10FFFF:
if errors == "strict":
- raise UnicodeError, ("Invalid character U+%x" % char)
+ raise UnicodeError("Invalid character U+%x" % char)
char = ord('?')
pos = pos % (len(base) + 1)
- base = base[:pos] + unichr(char) + base[pos:]
+ base = base[:pos] + chr(char) + base[pos:]
bias = adapt(delta, (extpos == 0), len(base))
extpos = newpos
return base
def punycode_decode(text, errors):
- pos = text.rfind("-")
+ if isinstance(text, str):
+ text = text.encode("ascii")
+ if isinstance(text, memoryview):
+ text = bytes(text)
+ pos = text.rfind(b"-")
if pos == -1:
base = ""
- extended = text
+ extended = str(text, "ascii").upper()
else:
- base = text[:pos]
- extended = text[pos+1:]
- base = unicode(base, "ascii", errors)
- extended = extended.upper()
+ base = str(text[:pos], "ascii", errors)
+ extended = str(text[pos+1:], "ascii").upper()
return insertion_sort(base, extended, errors)
### Codec APIs
class Codec(codecs.Codec):
- def encode(self,input,errors='strict'):
+ def encode(self, input, errors='strict'):
res = punycode_encode(input)
return res, len(input)
- def decode(self,input,errors='strict'):
+ def decode(self, input, errors='strict'):
if errors not in ('strict', 'replace', 'ignore'):
- raise UnicodeError, "Unsupported error handling "+errors
+ raise UnicodeError("Unsupported error handling "+errors)
res = punycode_decode(input, errors)
return res, len(input)
@@ -215,7 +214,7 @@ class IncrementalEncoder(codecs.IncrementalEncoder):
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
if self.errors not in ('strict', 'replace', 'ignore'):
- raise UnicodeError, "Unsupported error handling "+self.errors
+ raise UnicodeError("Unsupported error handling "+self.errors)
return punycode_decode(input, self.errors)
class StreamWriter(Codec,codecs.StreamWriter):
diff --git a/Lib/encodings/quopri_codec.py b/Lib/encodings/quopri_codec.py
index d8683fd56d3..9243fc443b0 100644
--- a/Lib/encodings/quopri_codec.py
+++ b/Lib/encodings/quopri_codec.py
@@ -1,51 +1,32 @@
"""Codec for quoted-printable encoding.
-Like base64 and rot13, this returns Python strings, not Unicode.
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
"""
-import codecs, quopri
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+import codecs
+import quopri
+from io import BytesIO
def quopri_encode(input, errors='strict'):
- """Encode the input, returning a tuple (output object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
assert errors == 'strict'
- # using str() because of cStringIO's Unicode undesired Unicode behavior.
- f = StringIO(str(input))
- g = StringIO()
+ f = BytesIO(input)
+ g = BytesIO()
quopri.encode(f, g, 1)
- output = g.getvalue()
- return (output, len(input))
+ return (g.getvalue(), len(input))
def quopri_decode(input, errors='strict'):
- """Decode the input, returning a tuple (output object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
assert errors == 'strict'
- f = StringIO(str(input))
- g = StringIO()
+ f = BytesIO(input)
+ g = BytesIO()
quopri.decode(f, g)
- output = g.getvalue()
- return (output, len(input))
+ return (g.getvalue(), len(input))
class Codec(codecs.Codec):
-
- def encode(self, input,errors='strict'):
- return quopri_encode(input,errors)
- def decode(self, input,errors='strict'):
- return quopri_decode(input,errors)
+ def encode(self, input, errors='strict'):
+ return quopri_encode(input, errors)
+ def decode(self, input, errors='strict'):
+ return quopri_decode(input, errors)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
@@ -56,10 +37,10 @@ class IncrementalDecoder(codecs.IncrementalDecoder):
return quopri_decode(input, self.errors)[0]
class StreamWriter(Codec, codecs.StreamWriter):
- pass
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
# encodings module API
diff --git a/Lib/encodings/rot_13.py b/Lib/encodings/rot_13.py
index 52b6431cf30..3140c1432dc 100644..100755
--- a/Lib/encodings/rot_13.py
+++ b/Lib/encodings/rot_13.py
@@ -1,31 +1,30 @@
#!/usr/bin/env python
""" Python Character Mapping Codec for ROT13.
- See http://ucsub.colorado.edu/~kominek/rot13/ for details.
+This codec de/encodes from str to str and is therefore usable with
+str.transform() and str.untransform().
- Written by Marc-Andre Lemburg (mal@lemburg.com).
-
-"""#"
+Written by Marc-Andre Lemburg (mal@lemburg.com).
+"""
import codecs
### Codec APIs
class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return (input.translate(rot13_map), len(input))
- def encode(self,input,errors='strict'):
- return codecs.charmap_encode(input,errors,encoding_map)
-
- def decode(self,input,errors='strict'):
- return codecs.charmap_decode(input,errors,decoding_map)
+ def decode(self, input, errors='strict'):
+ return (input.translate(rot13_map), len(input))
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
- return codecs.charmap_encode(input,self.errors,encoding_map)[0]
+ return input.translate(rot13_map)
class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
- return codecs.charmap_decode(input,self.errors,decoding_map)[0]
+ return input.translate(rot13_map)
class StreamWriter(Codec,codecs.StreamWriter):
pass
@@ -46,10 +45,10 @@ def getregentry():
streamreader=StreamReader,
)
-### Decoding Map
+### Map
-decoding_map = codecs.make_identity_dict(range(256))
-decoding_map.update({
+rot13_map = codecs.make_identity_dict(range(256))
+rot13_map.update({
0x0041: 0x004e,
0x0042: 0x004f,
0x0043: 0x0050,
@@ -104,10 +103,6 @@ decoding_map.update({
0x007a: 0x006d,
})
-### Encoding Map
-
-encoding_map = codecs.make_encoding_map(decoding_map)
-
### Filter API
def rot13(infile, outfile):
diff --git a/Lib/encodings/string_escape.py b/Lib/encodings/string_escape.py
deleted file mode 100644
index e329a2607de..00000000000
--- a/Lib/encodings/string_escape.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# -*- coding: iso-8859-1 -*-
-""" Python 'escape' Codec
-
-
-Written by Martin v. Löwis (martin@v.loewis.de).
-
-"""
-import codecs
-
-class Codec(codecs.Codec):
-
- encode = codecs.escape_encode
- decode = codecs.escape_decode
-
-class IncrementalEncoder(codecs.IncrementalEncoder):
- def encode(self, input, final=False):
- return codecs.escape_encode(input, self.errors)[0]
-
-class IncrementalDecoder(codecs.IncrementalDecoder):
- def decode(self, input, final=False):
- return codecs.escape_decode(input, self.errors)[0]
-
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
-
-class StreamReader(Codec,codecs.StreamReader):
- pass
-
-def getregentry():
- return codecs.CodecInfo(
- name='string-escape',
- encode=Codec.encode,
- decode=Codec.decode,
- incrementalencoder=IncrementalEncoder,
- incrementaldecoder=IncrementalDecoder,
- streamwriter=StreamWriter,
- streamreader=StreamReader,
- )
diff --git a/Lib/encodings/tis_620.py b/Lib/encodings/tis_620.py
index b2cd22b23dc..e288386343d 100644
--- a/Lib/encodings/tis_620.py
+++ b/Lib/encodings/tis_620.py
@@ -45,262 +45,262 @@ def getregentry():
### Decoding Table
decoding_table = (
- u'\x00' # 0x00 -> NULL
- u'\x01' # 0x01 -> START OF HEADING
- u'\x02' # 0x02 -> START OF TEXT
- u'\x03' # 0x03 -> END OF TEXT
- u'\x04' # 0x04 -> END OF TRANSMISSION
- u'\x05' # 0x05 -> ENQUIRY
- u'\x06' # 0x06 -> ACKNOWLEDGE
- u'\x07' # 0x07 -> BELL
- u'\x08' # 0x08 -> BACKSPACE
- u'\t' # 0x09 -> HORIZONTAL TABULATION
- u'\n' # 0x0A -> LINE FEED
- u'\x0b' # 0x0B -> VERTICAL TABULATION
- u'\x0c' # 0x0C -> FORM FEED
- u'\r' # 0x0D -> CARRIAGE RETURN
- u'\x0e' # 0x0E -> SHIFT OUT
- u'\x0f' # 0x0F -> SHIFT IN
- u'\x10' # 0x10 -> DATA LINK ESCAPE
- u'\x11' # 0x11 -> DEVICE CONTROL ONE
- u'\x12' # 0x12 -> DEVICE CONTROL TWO
- u'\x13' # 0x13 -> DEVICE CONTROL THREE
- u'\x14' # 0x14 -> DEVICE CONTROL FOUR
- u'\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
- u'\x16' # 0x16 -> SYNCHRONOUS IDLE
- u'\x17' # 0x17 -> END OF TRANSMISSION BLOCK
- u'\x18' # 0x18 -> CANCEL
- u'\x19' # 0x19 -> END OF MEDIUM
- u'\x1a' # 0x1A -> SUBSTITUTE
- u'\x1b' # 0x1B -> ESCAPE
- u'\x1c' # 0x1C -> FILE SEPARATOR
- u'\x1d' # 0x1D -> GROUP SEPARATOR
- u'\x1e' # 0x1E -> RECORD SEPARATOR
- u'\x1f' # 0x1F -> UNIT SEPARATOR
- u' ' # 0x20 -> SPACE
- u'!' # 0x21 -> EXCLAMATION MARK
- u'"' # 0x22 -> QUOTATION MARK
- u'#' # 0x23 -> NUMBER SIGN
- u'$' # 0x24 -> DOLLAR SIGN
- u'%' # 0x25 -> PERCENT SIGN
- u'&' # 0x26 -> AMPERSAND
- u"'" # 0x27 -> APOSTROPHE
- u'(' # 0x28 -> LEFT PARENTHESIS
- u')' # 0x29 -> RIGHT PARENTHESIS
- u'*' # 0x2A -> ASTERISK
- u'+' # 0x2B -> PLUS SIGN
- u',' # 0x2C -> COMMA
- u'-' # 0x2D -> HYPHEN-MINUS
- u'.' # 0x2E -> FULL STOP
- u'/' # 0x2F -> SOLIDUS
- u'0' # 0x30 -> DIGIT ZERO
- u'1' # 0x31 -> DIGIT ONE
- u'2' # 0x32 -> DIGIT TWO
- u'3' # 0x33 -> DIGIT THREE
- u'4' # 0x34 -> DIGIT FOUR
- u'5' # 0x35 -> DIGIT FIVE
- u'6' # 0x36 -> DIGIT SIX
- u'7' # 0x37 -> DIGIT SEVEN
- u'8' # 0x38 -> DIGIT EIGHT
- u'9' # 0x39 -> DIGIT NINE
- u':' # 0x3A -> COLON
- u';' # 0x3B -> SEMICOLON
- u'<' # 0x3C -> LESS-THAN SIGN
- u'=' # 0x3D -> EQUALS SIGN
- u'>' # 0x3E -> GREATER-THAN SIGN
- u'?' # 0x3F -> QUESTION MARK
- u'@' # 0x40 -> COMMERCIAL AT
- u'A' # 0x41 -> LATIN CAPITAL LETTER A
- u'B' # 0x42 -> LATIN CAPITAL LETTER B
- u'C' # 0x43 -> LATIN CAPITAL LETTER C
- u'D' # 0x44 -> LATIN CAPITAL LETTER D
- u'E' # 0x45 -> LATIN CAPITAL LETTER E
- u'F' # 0x46 -> LATIN CAPITAL LETTER F
- u'G' # 0x47 -> LATIN CAPITAL LETTER G
- u'H' # 0x48 -> LATIN CAPITAL LETTER H
- u'I' # 0x49 -> LATIN CAPITAL LETTER I
- u'J' # 0x4A -> LATIN CAPITAL LETTER J
- u'K' # 0x4B -> LATIN CAPITAL LETTER K
- u'L' # 0x4C -> LATIN CAPITAL LETTER L
- u'M' # 0x4D -> LATIN CAPITAL LETTER M
- u'N' # 0x4E -> LATIN CAPITAL LETTER N
- u'O' # 0x4F -> LATIN CAPITAL LETTER O
- u'P' # 0x50 -> LATIN CAPITAL LETTER P
- u'Q' # 0x51 -> LATIN CAPITAL LETTER Q
- u'R' # 0x52 -> LATIN CAPITAL LETTER R
- u'S' # 0x53 -> LATIN CAPITAL LETTER S
- u'T' # 0x54 -> LATIN CAPITAL LETTER T
- u'U' # 0x55 -> LATIN CAPITAL LETTER U
- u'V' # 0x56 -> LATIN CAPITAL LETTER V
- u'W' # 0x57 -> LATIN CAPITAL LETTER W
- u'X' # 0x58 -> LATIN CAPITAL LETTER X
- u'Y' # 0x59 -> LATIN CAPITAL LETTER Y
- u'Z' # 0x5A -> LATIN CAPITAL LETTER Z
- u'[' # 0x5B -> LEFT SQUARE BRACKET
- u'\\' # 0x5C -> REVERSE SOLIDUS
- u']' # 0x5D -> RIGHT SQUARE BRACKET
- u'^' # 0x5E -> CIRCUMFLEX ACCENT
- u'_' # 0x5F -> LOW LINE
- u'`' # 0x60 -> GRAVE ACCENT
- u'a' # 0x61 -> LATIN SMALL LETTER A
- u'b' # 0x62 -> LATIN SMALL LETTER B
- u'c' # 0x63 -> LATIN SMALL LETTER C
- u'd' # 0x64 -> LATIN SMALL LETTER D
- u'e' # 0x65 -> LATIN SMALL LETTER E
- u'f' # 0x66 -> LATIN SMALL LETTER F
- u'g' # 0x67 -> LATIN SMALL LETTER G
- u'h' # 0x68 -> LATIN SMALL LETTER H
- u'i' # 0x69 -> LATIN SMALL LETTER I
- u'j' # 0x6A -> LATIN SMALL LETTER J
- u'k' # 0x6B -> LATIN SMALL LETTER K
- u'l' # 0x6C -> LATIN SMALL LETTER L
- u'm' # 0x6D -> LATIN SMALL LETTER M
- u'n' # 0x6E -> LATIN SMALL LETTER N
- u'o' # 0x6F -> LATIN SMALL LETTER O
- u'p' # 0x70 -> LATIN SMALL LETTER P
- u'q' # 0x71 -> LATIN SMALL LETTER Q
- u'r' # 0x72 -> LATIN SMALL LETTER R
- u's' # 0x73 -> LATIN SMALL LETTER S
- u't' # 0x74 -> LATIN SMALL LETTER T
- u'u' # 0x75 -> LATIN SMALL LETTER U
- u'v' # 0x76 -> LATIN SMALL LETTER V
- u'w' # 0x77 -> LATIN SMALL LETTER W
- u'x' # 0x78 -> LATIN SMALL LETTER X
- u'y' # 0x79 -> LATIN SMALL LETTER Y
- u'z' # 0x7A -> LATIN SMALL LETTER Z
- u'{' # 0x7B -> LEFT CURLY BRACKET
- u'|' # 0x7C -> VERTICAL LINE
- u'}' # 0x7D -> RIGHT CURLY BRACKET
- u'~' # 0x7E -> TILDE
- u'\x7f' # 0x7F -> DELETE
- u'\x80' # 0x80 -> <control>
- u'\x81' # 0x81 -> <control>
- u'\x82' # 0x82 -> <control>
- u'\x83' # 0x83 -> <control>
- u'\x84' # 0x84 -> <control>
- u'\x85' # 0x85 -> <control>
- u'\x86' # 0x86 -> <control>
- u'\x87' # 0x87 -> <control>
- u'\x88' # 0x88 -> <control>
- u'\x89' # 0x89 -> <control>
- u'\x8a' # 0x8A -> <control>
- u'\x8b' # 0x8B -> <control>
- u'\x8c' # 0x8C -> <control>
- u'\x8d' # 0x8D -> <control>
- u'\x8e' # 0x8E -> <control>
- u'\x8f' # 0x8F -> <control>
- u'\x90' # 0x90 -> <control>
- u'\x91' # 0x91 -> <control>
- u'\x92' # 0x92 -> <control>
- u'\x93' # 0x93 -> <control>
- u'\x94' # 0x94 -> <control>
- u'\x95' # 0x95 -> <control>
- u'\x96' # 0x96 -> <control>
- u'\x97' # 0x97 -> <control>
- u'\x98' # 0x98 -> <control>
- u'\x99' # 0x99 -> <control>
- u'\x9a' # 0x9A -> <control>
- u'\x9b' # 0x9B -> <control>
- u'\x9c' # 0x9C -> <control>
- u'\x9d' # 0x9D -> <control>
- u'\x9e' # 0x9E -> <control>
- u'\x9f' # 0x9F -> <control>
- u'\ufffe'
- u'\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
- u'\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
- u'\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
- u'\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
- u'\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
- u'\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
- u'\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
- u'\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
- u'\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
- u'\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
- u'\u0e0b' # 0xAB -> THAI CHARACTER SO SO
- u'\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
- u'\u0e0d' # 0xAD -> THAI CHARACTER YO YING
- u'\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
- u'\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
- u'\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
- u'\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
- u'\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
- u'\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
- u'\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
- u'\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
- u'\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
- u'\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
- u'\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
- u'\u0e19' # 0xB9 -> THAI CHARACTER NO NU
- u'\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
- u'\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
- u'\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
- u'\u0e1d' # 0xBD -> THAI CHARACTER FO FA
- u'\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
- u'\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
- u'\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
- u'\u0e21' # 0xC1 -> THAI CHARACTER MO MA
- u'\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
- u'\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
- u'\u0e24' # 0xC4 -> THAI CHARACTER RU
- u'\u0e25' # 0xC5 -> THAI CHARACTER LO LING
- u'\u0e26' # 0xC6 -> THAI CHARACTER LU
- u'\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
- u'\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
- u'\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
- u'\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
- u'\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
- u'\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
- u'\u0e2d' # 0xCD -> THAI CHARACTER O ANG
- u'\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
- u'\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
- u'\u0e30' # 0xD0 -> THAI CHARACTER SARA A
- u'\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
- u'\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
- u'\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
- u'\u0e34' # 0xD4 -> THAI CHARACTER SARA I
- u'\u0e35' # 0xD5 -> THAI CHARACTER SARA II
- u'\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
- u'\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
- u'\u0e38' # 0xD8 -> THAI CHARACTER SARA U
- u'\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
- u'\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
- u'\u0e40' # 0xE0 -> THAI CHARACTER SARA E
- u'\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
- u'\u0e42' # 0xE2 -> THAI CHARACTER SARA O
- u'\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
- u'\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
- u'\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
- u'\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
- u'\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
- u'\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
- u'\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
- u'\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
- u'\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
- u'\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
- u'\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
- u'\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
- u'\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
- u'\u0e50' # 0xF0 -> THAI DIGIT ZERO
- u'\u0e51' # 0xF1 -> THAI DIGIT ONE
- u'\u0e52' # 0xF2 -> THAI DIGIT TWO
- u'\u0e53' # 0xF3 -> THAI DIGIT THREE
- u'\u0e54' # 0xF4 -> THAI DIGIT FOUR
- u'\u0e55' # 0xF5 -> THAI DIGIT FIVE
- u'\u0e56' # 0xF6 -> THAI DIGIT SIX
- u'\u0e57' # 0xF7 -> THAI DIGIT SEVEN
- u'\u0e58' # 0xF8 -> THAI DIGIT EIGHT
- u'\u0e59' # 0xF9 -> THAI DIGIT NINE
- u'\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
- u'\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
- u'\ufffe'
+ '\x00' # 0x00 -> NULL
+ '\x01' # 0x01 -> START OF HEADING
+ '\x02' # 0x02 -> START OF TEXT
+ '\x03' # 0x03 -> END OF TEXT
+ '\x04' # 0x04 -> END OF TRANSMISSION
+ '\x05' # 0x05 -> ENQUIRY
+ '\x06' # 0x06 -> ACKNOWLEDGE
+ '\x07' # 0x07 -> BELL
+ '\x08' # 0x08 -> BACKSPACE
+ '\t' # 0x09 -> HORIZONTAL TABULATION
+ '\n' # 0x0A -> LINE FEED
+ '\x0b' # 0x0B -> VERTICAL TABULATION
+ '\x0c' # 0x0C -> FORM FEED
+ '\r' # 0x0D -> CARRIAGE RETURN
+ '\x0e' # 0x0E -> SHIFT OUT
+ '\x0f' # 0x0F -> SHIFT IN
+ '\x10' # 0x10 -> DATA LINK ESCAPE
+ '\x11' # 0x11 -> DEVICE CONTROL ONE
+ '\x12' # 0x12 -> DEVICE CONTROL TWO
+ '\x13' # 0x13 -> DEVICE CONTROL THREE
+ '\x14' # 0x14 -> DEVICE CONTROL FOUR
+ '\x15' # 0x15 -> NEGATIVE ACKNOWLEDGE
+ '\x16' # 0x16 -> SYNCHRONOUS IDLE
+ '\x17' # 0x17 -> END OF TRANSMISSION BLOCK
+ '\x18' # 0x18 -> CANCEL
+ '\x19' # 0x19 -> END OF MEDIUM
+ '\x1a' # 0x1A -> SUBSTITUTE
+ '\x1b' # 0x1B -> ESCAPE
+ '\x1c' # 0x1C -> FILE SEPARATOR
+ '\x1d' # 0x1D -> GROUP SEPARATOR
+ '\x1e' # 0x1E -> RECORD SEPARATOR
+ '\x1f' # 0x1F -> UNIT SEPARATOR
+ ' ' # 0x20 -> SPACE
+ '!' # 0x21 -> EXCLAMATION MARK
+ '"' # 0x22 -> QUOTATION MARK
+ '#' # 0x23 -> NUMBER SIGN
+ '$' # 0x24 -> DOLLAR SIGN
+ '%' # 0x25 -> PERCENT SIGN
+ '&' # 0x26 -> AMPERSAND
+ "'" # 0x27 -> APOSTROPHE
+ '(' # 0x28 -> LEFT PARENTHESIS
+ ')' # 0x29 -> RIGHT PARENTHESIS
+ '*' # 0x2A -> ASTERISK
+ '+' # 0x2B -> PLUS SIGN
+ ',' # 0x2C -> COMMA
+ '-' # 0x2D -> HYPHEN-MINUS
+ '.' # 0x2E -> FULL STOP
+ '/' # 0x2F -> SOLIDUS
+ '0' # 0x30 -> DIGIT ZERO
+ '1' # 0x31 -> DIGIT ONE
+ '2' # 0x32 -> DIGIT TWO
+ '3' # 0x33 -> DIGIT THREE
+ '4' # 0x34 -> DIGIT FOUR
+ '5' # 0x35 -> DIGIT FIVE
+ '6' # 0x36 -> DIGIT SIX
+ '7' # 0x37 -> DIGIT SEVEN
+ '8' # 0x38 -> DIGIT EIGHT
+ '9' # 0x39 -> DIGIT NINE
+ ':' # 0x3A -> COLON
+ ';' # 0x3B -> SEMICOLON
+ '<' # 0x3C -> LESS-THAN SIGN
+ '=' # 0x3D -> EQUALS SIGN
+ '>' # 0x3E -> GREATER-THAN SIGN
+ '?' # 0x3F -> QUESTION MARK
+ '@' # 0x40 -> COMMERCIAL AT
+ 'A' # 0x41 -> LATIN CAPITAL LETTER A
+ 'B' # 0x42 -> LATIN CAPITAL LETTER B
+ 'C' # 0x43 -> LATIN CAPITAL LETTER C
+ 'D' # 0x44 -> LATIN CAPITAL LETTER D
+ 'E' # 0x45 -> LATIN CAPITAL LETTER E
+ 'F' # 0x46 -> LATIN CAPITAL LETTER F
+ 'G' # 0x47 -> LATIN CAPITAL LETTER G
+ 'H' # 0x48 -> LATIN CAPITAL LETTER H
+ 'I' # 0x49 -> LATIN CAPITAL LETTER I
+ 'J' # 0x4A -> LATIN CAPITAL LETTER J
+ 'K' # 0x4B -> LATIN CAPITAL LETTER K
+ 'L' # 0x4C -> LATIN CAPITAL LETTER L
+ 'M' # 0x4D -> LATIN CAPITAL LETTER M
+ 'N' # 0x4E -> LATIN CAPITAL LETTER N
+ 'O' # 0x4F -> LATIN CAPITAL LETTER O
+ 'P' # 0x50 -> LATIN CAPITAL LETTER P
+ 'Q' # 0x51 -> LATIN CAPITAL LETTER Q
+ 'R' # 0x52 -> LATIN CAPITAL LETTER R
+ 'S' # 0x53 -> LATIN CAPITAL LETTER S
+ 'T' # 0x54 -> LATIN CAPITAL LETTER T
+ 'U' # 0x55 -> LATIN CAPITAL LETTER U
+ 'V' # 0x56 -> LATIN CAPITAL LETTER V
+ 'W' # 0x57 -> LATIN CAPITAL LETTER W
+ 'X' # 0x58 -> LATIN CAPITAL LETTER X
+ 'Y' # 0x59 -> LATIN CAPITAL LETTER Y
+ 'Z' # 0x5A -> LATIN CAPITAL LETTER Z
+ '[' # 0x5B -> LEFT SQUARE BRACKET
+ '\\' # 0x5C -> REVERSE SOLIDUS
+ ']' # 0x5D -> RIGHT SQUARE BRACKET
+ '^' # 0x5E -> CIRCUMFLEX ACCENT
+ '_' # 0x5F -> LOW LINE
+ '`' # 0x60 -> GRAVE ACCENT
+ 'a' # 0x61 -> LATIN SMALL LETTER A
+ 'b' # 0x62 -> LATIN SMALL LETTER B
+ 'c' # 0x63 -> LATIN SMALL LETTER C
+ 'd' # 0x64 -> LATIN SMALL LETTER D
+ 'e' # 0x65 -> LATIN SMALL LETTER E
+ 'f' # 0x66 -> LATIN SMALL LETTER F
+ 'g' # 0x67 -> LATIN SMALL LETTER G
+ 'h' # 0x68 -> LATIN SMALL LETTER H
+ 'i' # 0x69 -> LATIN SMALL LETTER I
+ 'j' # 0x6A -> LATIN SMALL LETTER J
+ 'k' # 0x6B -> LATIN SMALL LETTER K
+ 'l' # 0x6C -> LATIN SMALL LETTER L
+ 'm' # 0x6D -> LATIN SMALL LETTER M
+ 'n' # 0x6E -> LATIN SMALL LETTER N
+ 'o' # 0x6F -> LATIN SMALL LETTER O
+ 'p' # 0x70 -> LATIN SMALL LETTER P
+ 'q' # 0x71 -> LATIN SMALL LETTER Q
+ 'r' # 0x72 -> LATIN SMALL LETTER R
+ 's' # 0x73 -> LATIN SMALL LETTER S
+ 't' # 0x74 -> LATIN SMALL LETTER T
+ 'u' # 0x75 -> LATIN SMALL LETTER U
+ 'v' # 0x76 -> LATIN SMALL LETTER V
+ 'w' # 0x77 -> LATIN SMALL LETTER W
+ 'x' # 0x78 -> LATIN SMALL LETTER X
+ 'y' # 0x79 -> LATIN SMALL LETTER Y
+ 'z' # 0x7A -> LATIN SMALL LETTER Z
+ '{' # 0x7B -> LEFT CURLY BRACKET
+ '|' # 0x7C -> VERTICAL LINE
+ '}' # 0x7D -> RIGHT CURLY BRACKET
+ '~' # 0x7E -> TILDE
+ '\x7f' # 0x7F -> DELETE
+ '\x80' # 0x80 -> <control>
+ '\x81' # 0x81 -> <control>
+ '\x82' # 0x82 -> <control>
+ '\x83' # 0x83 -> <control>
+ '\x84' # 0x84 -> <control>
+ '\x85' # 0x85 -> <control>
+ '\x86' # 0x86 -> <control>
+ '\x87' # 0x87 -> <control>
+ '\x88' # 0x88 -> <control>
+ '\x89' # 0x89 -> <control>
+ '\x8a' # 0x8A -> <control>
+ '\x8b' # 0x8B -> <control>
+ '\x8c' # 0x8C -> <control>
+ '\x8d' # 0x8D -> <control>
+ '\x8e' # 0x8E -> <control>
+ '\x8f' # 0x8F -> <control>
+ '\x90' # 0x90 -> <control>
+ '\x91' # 0x91 -> <control>
+ '\x92' # 0x92 -> <control>
+ '\x93' # 0x93 -> <control>
+ '\x94' # 0x94 -> <control>
+ '\x95' # 0x95 -> <control>
+ '\x96' # 0x96 -> <control>
+ '\x97' # 0x97 -> <control>
+ '\x98' # 0x98 -> <control>
+ '\x99' # 0x99 -> <control>
+ '\x9a' # 0x9A -> <control>
+ '\x9b' # 0x9B -> <control>
+ '\x9c' # 0x9C -> <control>
+ '\x9d' # 0x9D -> <control>
+ '\x9e' # 0x9E -> <control>
+ '\x9f' # 0x9F -> <control>
+ '\ufffe'
+ '\u0e01' # 0xA1 -> THAI CHARACTER KO KAI
+ '\u0e02' # 0xA2 -> THAI CHARACTER KHO KHAI
+ '\u0e03' # 0xA3 -> THAI CHARACTER KHO KHUAT
+ '\u0e04' # 0xA4 -> THAI CHARACTER KHO KHWAI
+ '\u0e05' # 0xA5 -> THAI CHARACTER KHO KHON
+ '\u0e06' # 0xA6 -> THAI CHARACTER KHO RAKHANG
+ '\u0e07' # 0xA7 -> THAI CHARACTER NGO NGU
+ '\u0e08' # 0xA8 -> THAI CHARACTER CHO CHAN
+ '\u0e09' # 0xA9 -> THAI CHARACTER CHO CHING
+ '\u0e0a' # 0xAA -> THAI CHARACTER CHO CHANG
+ '\u0e0b' # 0xAB -> THAI CHARACTER SO SO
+ '\u0e0c' # 0xAC -> THAI CHARACTER CHO CHOE
+ '\u0e0d' # 0xAD -> THAI CHARACTER YO YING
+ '\u0e0e' # 0xAE -> THAI CHARACTER DO CHADA
+ '\u0e0f' # 0xAF -> THAI CHARACTER TO PATAK
+ '\u0e10' # 0xB0 -> THAI CHARACTER THO THAN
+ '\u0e11' # 0xB1 -> THAI CHARACTER THO NANGMONTHO
+ '\u0e12' # 0xB2 -> THAI CHARACTER THO PHUTHAO
+ '\u0e13' # 0xB3 -> THAI CHARACTER NO NEN
+ '\u0e14' # 0xB4 -> THAI CHARACTER DO DEK
+ '\u0e15' # 0xB5 -> THAI CHARACTER TO TAO
+ '\u0e16' # 0xB6 -> THAI CHARACTER THO THUNG
+ '\u0e17' # 0xB7 -> THAI CHARACTER THO THAHAN
+ '\u0e18' # 0xB8 -> THAI CHARACTER THO THONG
+ '\u0e19' # 0xB9 -> THAI CHARACTER NO NU
+ '\u0e1a' # 0xBA -> THAI CHARACTER BO BAIMAI
+ '\u0e1b' # 0xBB -> THAI CHARACTER PO PLA
+ '\u0e1c' # 0xBC -> THAI CHARACTER PHO PHUNG
+ '\u0e1d' # 0xBD -> THAI CHARACTER FO FA
+ '\u0e1e' # 0xBE -> THAI CHARACTER PHO PHAN
+ '\u0e1f' # 0xBF -> THAI CHARACTER FO FAN
+ '\u0e20' # 0xC0 -> THAI CHARACTER PHO SAMPHAO
+ '\u0e21' # 0xC1 -> THAI CHARACTER MO MA
+ '\u0e22' # 0xC2 -> THAI CHARACTER YO YAK
+ '\u0e23' # 0xC3 -> THAI CHARACTER RO RUA
+ '\u0e24' # 0xC4 -> THAI CHARACTER RU
+ '\u0e25' # 0xC5 -> THAI CHARACTER LO LING
+ '\u0e26' # 0xC6 -> THAI CHARACTER LU
+ '\u0e27' # 0xC7 -> THAI CHARACTER WO WAEN
+ '\u0e28' # 0xC8 -> THAI CHARACTER SO SALA
+ '\u0e29' # 0xC9 -> THAI CHARACTER SO RUSI
+ '\u0e2a' # 0xCA -> THAI CHARACTER SO SUA
+ '\u0e2b' # 0xCB -> THAI CHARACTER HO HIP
+ '\u0e2c' # 0xCC -> THAI CHARACTER LO CHULA
+ '\u0e2d' # 0xCD -> THAI CHARACTER O ANG
+ '\u0e2e' # 0xCE -> THAI CHARACTER HO NOKHUK
+ '\u0e2f' # 0xCF -> THAI CHARACTER PAIYANNOI
+ '\u0e30' # 0xD0 -> THAI CHARACTER SARA A
+ '\u0e31' # 0xD1 -> THAI CHARACTER MAI HAN-AKAT
+ '\u0e32' # 0xD2 -> THAI CHARACTER SARA AA
+ '\u0e33' # 0xD3 -> THAI CHARACTER SARA AM
+ '\u0e34' # 0xD4 -> THAI CHARACTER SARA I
+ '\u0e35' # 0xD5 -> THAI CHARACTER SARA II
+ '\u0e36' # 0xD6 -> THAI CHARACTER SARA UE
+ '\u0e37' # 0xD7 -> THAI CHARACTER SARA UEE
+ '\u0e38' # 0xD8 -> THAI CHARACTER SARA U
+ '\u0e39' # 0xD9 -> THAI CHARACTER SARA UU
+ '\u0e3a' # 0xDA -> THAI CHARACTER PHINTHU
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\u0e3f' # 0xDF -> THAI CURRENCY SYMBOL BAHT
+ '\u0e40' # 0xE0 -> THAI CHARACTER SARA E
+ '\u0e41' # 0xE1 -> THAI CHARACTER SARA AE
+ '\u0e42' # 0xE2 -> THAI CHARACTER SARA O
+ '\u0e43' # 0xE3 -> THAI CHARACTER SARA AI MAIMUAN
+ '\u0e44' # 0xE4 -> THAI CHARACTER SARA AI MAIMALAI
+ '\u0e45' # 0xE5 -> THAI CHARACTER LAKKHANGYAO
+ '\u0e46' # 0xE6 -> THAI CHARACTER MAIYAMOK
+ '\u0e47' # 0xE7 -> THAI CHARACTER MAITAIKHU
+ '\u0e48' # 0xE8 -> THAI CHARACTER MAI EK
+ '\u0e49' # 0xE9 -> THAI CHARACTER MAI THO
+ '\u0e4a' # 0xEA -> THAI CHARACTER MAI TRI
+ '\u0e4b' # 0xEB -> THAI CHARACTER MAI CHATTAWA
+ '\u0e4c' # 0xEC -> THAI CHARACTER THANTHAKHAT
+ '\u0e4d' # 0xED -> THAI CHARACTER NIKHAHIT
+ '\u0e4e' # 0xEE -> THAI CHARACTER YAMAKKAN
+ '\u0e4f' # 0xEF -> THAI CHARACTER FONGMAN
+ '\u0e50' # 0xF0 -> THAI DIGIT ZERO
+ '\u0e51' # 0xF1 -> THAI DIGIT ONE
+ '\u0e52' # 0xF2 -> THAI DIGIT TWO
+ '\u0e53' # 0xF3 -> THAI DIGIT THREE
+ '\u0e54' # 0xF4 -> THAI DIGIT FOUR
+ '\u0e55' # 0xF5 -> THAI DIGIT FIVE
+ '\u0e56' # 0xF6 -> THAI DIGIT SIX
+ '\u0e57' # 0xF7 -> THAI DIGIT SEVEN
+ '\u0e58' # 0xF8 -> THAI DIGIT EIGHT
+ '\u0e59' # 0xF9 -> THAI DIGIT NINE
+ '\u0e5a' # 0xFA -> THAI CHARACTER ANGKHANKHU
+ '\u0e5b' # 0xFB -> THAI CHARACTER KHOMUT
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
+ '\ufffe'
)
### Encoding table
diff --git a/Lib/encodings/utf_16.py b/Lib/encodings/utf_16.py
index f3fadff6153..809bc9ab368 100644
--- a/Lib/encodings/utf_16.py
+++ b/Lib/encodings/utf_16.py
@@ -72,6 +72,35 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
codecs.BufferedIncrementalDecoder.reset(self)
self.decoder = None
+ def getstate(self):
+ # additonal state info from the base class must be None here,
+ # as it isn't passed along to the caller
+ state = codecs.BufferedIncrementalDecoder.getstate(self)[0]
+ # additional state info we pass to the caller:
+ # 0: stream is in natural order for this platform
+ # 1: stream is in unnatural order
+ # 2: endianness hasn't been determined yet
+ if self.decoder is None:
+ return (state, 2)
+ addstate = int((sys.byteorder == "big") !=
+ (self.decoder is codecs.utf_16_be_decode))
+ return (state, addstate)
+
+ def setstate(self, state):
+ # state[1] will be ignored by BufferedIncrementalDecoder.setstate()
+ codecs.BufferedIncrementalDecoder.setstate(self, state)
+ state = state[1]
+ if state == 0:
+ self.decoder = (codecs.utf_16_be_decode
+ if sys.byteorder == "big"
+ else codecs.utf_16_le_decode)
+ elif state == 1:
+ self.decoder = (codecs.utf_16_le_decode
+ if sys.byteorder == "big"
+ else codecs.utf_16_be_decode)
+ else:
+ self.decoder = None
+
class StreamWriter(codecs.StreamWriter):
def __init__(self, stream, errors='strict'):
codecs.StreamWriter.__init__(self, stream, errors)
@@ -109,7 +138,7 @@ class StreamReader(codecs.StreamReader):
elif byteorder == 1:
self.decode = codecs.utf_16_be_decode
elif consumed>=2:
- raise UnicodeError,"UTF-16 stream does not start with BOM"
+ raise UnicodeError("UTF-16 stream does not start with BOM")
return (object, consumed)
### encodings module API
diff --git a/Lib/encodings/utf_32.py b/Lib/encodings/utf_32.py
index 6c8016fe1b3..c0529285f60 100644
--- a/Lib/encodings/utf_32.py
+++ b/Lib/encodings/utf_32.py
@@ -133,7 +133,7 @@ class StreamReader(codecs.StreamReader):
elif byteorder == 1:
self.decode = codecs.utf_32_be_decode
elif consumed>=4:
- raise UnicodeError,"UTF-32 stream does not start with BOM"
+ raise UnicodeError("UTF-32 stream does not start with BOM")
return (object, consumed)
### encodings module API
diff --git a/Lib/encodings/utf_8_sig.py b/Lib/encodings/utf_8_sig.py
index 8784694f026..1bb479203f3 100644
--- a/Lib/encodings/utf_8_sig.py
+++ b/Lib/encodings/utf_8_sig.py
@@ -12,7 +12,8 @@ import codecs
### Codec APIs
def encode(input, errors='strict'):
- return (codecs.BOM_UTF8 + codecs.utf_8_encode(input, errors)[0], len(input))
+ return (codecs.BOM_UTF8 + codecs.utf_8_encode(input, errors)[0],
+ len(input))
def decode(input, errors='strict'):
prefix = 0
@@ -30,7 +31,8 @@ class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
if self.first:
self.first = 0
- return codecs.BOM_UTF8 + codecs.utf_8_encode(input, self.errors)[0]
+ return codecs.BOM_UTF8 + \
+ codecs.utf_8_encode(input, self.errors)[0]
else:
return codecs.utf_8_encode(input, self.errors)[0]
@@ -47,7 +49,7 @@ class IncrementalEncoder(codecs.IncrementalEncoder):
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
def __init__(self, errors='strict'):
codecs.BufferedIncrementalDecoder.__init__(self, errors)
- self.first = True
+ self.first = 1
def _buffer_decode(self, input, errors, final):
if self.first:
@@ -55,19 +57,30 @@ class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
if codecs.BOM_UTF8.startswith(input):
# not enough data to decide if this really is a BOM
# => try again on the next call
- return (u"", 0)
+ return ("", 0)
else:
- self.first = None
+ self.first = 0
else:
- self.first = None
+ self.first = 0
if input[:3] == codecs.BOM_UTF8:
- (output, consumed) = codecs.utf_8_decode(input[3:], errors, final)
+ (output, consumed) = \
+ codecs.utf_8_decode(input[3:], errors, final)
return (output, consumed+3)
return codecs.utf_8_decode(input, errors, final)
def reset(self):
codecs.BufferedIncrementalDecoder.reset(self)
- self.first = True
+ self.first = 1
+
+ def getstate(self):
+ state = codecs.BufferedIncrementalDecoder.getstate(self)
+ # state[1] must be 0 here, as it isn't passed along to the caller
+ return (state[0], self.first)
+
+ def setstate(self, state):
+ # state[1] will be ignored by BufferedIncrementalDecoder.setstate()
+ codecs.BufferedIncrementalDecoder.setstate(self, state)
+ self.first = state[1]
class StreamWriter(codecs.StreamWriter):
def reset(self):
@@ -94,7 +107,7 @@ class StreamReader(codecs.StreamReader):
if codecs.BOM_UTF8.startswith(input):
# not enough data to decide if this is a BOM
# => try again on the next call
- return (u"", 0)
+ return ("", 0)
elif input[:3] == codecs.BOM_UTF8:
self.decode = codecs.utf_8_decode
(output, consumed) = codecs.utf_8_decode(input[3:],errors)
diff --git a/Lib/encodings/uu_codec.py b/Lib/encodings/uu_codec.py
index fb03758171d..69c6f17c7f3 100644
--- a/Lib/encodings/uu_codec.py
+++ b/Lib/encodings/uu_codec.py
@@ -1,68 +1,40 @@
-""" Python 'uu_codec' Codec - UU content transfer encoding
+"""Python 'uu_codec' Codec - UU content transfer encoding.
- Unlike most of the other codecs which target Unicode, this codec
- will return Python string objects for both encode and decode.
-
- Written by Marc-Andre Lemburg (mal@lemburg.com). Some details were
- adapted from uu.py which was written by Lance Ellinghouse and
- modified by Jack Jansen and Fredrik Lundh.
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+Written by Marc-Andre Lemburg (mal@lemburg.com). Some details were
+adapted from uu.py which was written by Lance Ellinghouse and
+modified by Jack Jansen and Fredrik Lundh.
"""
-import codecs, binascii
-
-### Codec APIs
-def uu_encode(input,errors='strict',filename='<data>',mode=0666):
+import codecs
+import binascii
+from io import BytesIO
- """ Encodes the object input and returns a tuple (output
- object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
+### Codec APIs
- """
+def uu_encode(input, errors='strict', filename='<data>', mode=0o666):
assert errors == 'strict'
- from cStringIO import StringIO
- from binascii import b2a_uu
- # using str() because of cStringIO's Unicode undesired Unicode behavior.
- infile = StringIO(str(input))
- outfile = StringIO()
+ infile = BytesIO(input)
+ outfile = BytesIO()
read = infile.read
write = outfile.write
# Encode
- write('begin %o %s\n' % (mode & 0777, filename))
+ write(('begin %o %s\n' % (mode & 0o777, filename)).encode('ascii'))
chunk = read(45)
while chunk:
- write(b2a_uu(chunk))
+ write(binascii.b2a_uu(chunk))
chunk = read(45)
- write(' \nend\n')
+ write(b' \nend\n')
return (outfile.getvalue(), len(input))
-def uu_decode(input,errors='strict'):
-
- """ Decodes the object input and returns a tuple (output
- object, length consumed).
-
- input must be an object which provides the bf_getreadbuf
- buffer slot. Python strings, buffer objects and memory
- mapped files are examples of objects providing this slot.
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- Note: filename and file mode information in the input data is
- ignored.
-
- """
+def uu_decode(input, errors='strict'):
assert errors == 'strict'
- from cStringIO import StringIO
- from binascii import a2b_uu
- infile = StringIO(str(input))
- outfile = StringIO()
+ infile = BytesIO(input)
+ outfile = BytesIO()
readline = infile.readline
write = outfile.write
@@ -70,36 +42,34 @@ def uu_decode(input,errors='strict'):
while 1:
s = readline()
if not s:
- raise ValueError, 'Missing "begin" line in input data'
- if s[:5] == 'begin':
+ raise ValueError('Missing "begin" line in input data')
+ if s[:5] == b'begin':
break
# Decode
- while 1:
+ while True:
s = readline()
- if not s or \
- s == 'end\n':
+ if not s or s == b'end\n':
break
try:
- data = a2b_uu(s)
- except binascii.Error, v:
+ data = binascii.a2b_uu(s)
+ except binascii.Error as v:
# Workaround for broken uuencoders by /Fredrik Lundh
nbytes = (((ord(s[0])-32) & 63) * 4 + 5) / 3
- data = a2b_uu(s[:nbytes])
+ data = binascii.a2b_uu(s[:nbytes])
#sys.stderr.write("Warning: %s\n" % str(v))
write(data)
if not s:
- raise ValueError, 'Truncated input data'
+ raise ValueError('Truncated input data')
return (outfile.getvalue(), len(input))
class Codec(codecs.Codec):
+ def encode(self, input, errors='strict'):
+ return uu_encode(input, errors)
- def encode(self,input,errors='strict'):
- return uu_encode(input,errors)
-
- def decode(self,input,errors='strict'):
- return uu_decode(input,errors)
+ def decode(self, input, errors='strict'):
+ return uu_decode(input, errors)
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
@@ -109,11 +79,11 @@ class IncrementalDecoder(codecs.IncrementalDecoder):
def decode(self, input, final=False):
return uu_decode(input, self.errors)[0]
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
### encodings module API
diff --git a/Lib/encodings/zlib_codec.py b/Lib/encodings/zlib_codec.py
index 3419f9f48f5..e0b9cdadbcd 100644
--- a/Lib/encodings/zlib_codec.py
+++ b/Lib/encodings/zlib_codec.py
@@ -1,50 +1,25 @@
-""" Python 'zlib_codec' Codec - zlib compression encoding
+"""Python 'zlib_codec' Codec - zlib compression encoding.
- Unlike most of the other codecs which target Unicode, this codec
- will return Python string objects for both encode and decode.
-
- Written by Marc-Andre Lemburg (mal@lemburg.com).
+This codec de/encodes from bytes to bytes and is therefore usable with
+bytes.transform() and bytes.untransform().
+Written by Marc-Andre Lemburg (mal@lemburg.com).
"""
+
import codecs
import zlib # this codec needs the optional zlib module !
### Codec APIs
-def zlib_encode(input,errors='strict'):
-
- """ Encodes the object input and returns a tuple (output
- object, length consumed).
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def zlib_encode(input, errors='strict'):
assert errors == 'strict'
- output = zlib.compress(input)
- return (output, len(input))
+ return (zlib.compress(input), len(input))
-def zlib_decode(input,errors='strict'):
-
- """ Decodes the object input and returns a tuple (output
- object, length consumed).
-
- input must be an object which provides the bf_getreadbuf
- buffer slot. Python strings, buffer objects and memory
- mapped files are examples of objects providing this slot.
-
- errors defines the error handling to apply. It defaults to
- 'strict' handling which is the only currently supported
- error handling for this codec.
-
- """
+def zlib_decode(input, errors='strict'):
assert errors == 'strict'
- output = zlib.decompress(input)
- return (output, len(input))
+ return (zlib.decompress(input), len(input))
class Codec(codecs.Codec):
-
def encode(self, input, errors='strict'):
return zlib_encode(input, errors)
def decode(self, input, errors='strict'):
@@ -82,11 +57,11 @@ class IncrementalDecoder(codecs.IncrementalDecoder):
def reset(self):
self.decompressobj = zlib.decompressobj()
-class StreamWriter(Codec,codecs.StreamWriter):
- pass
+class StreamWriter(Codec, codecs.StreamWriter):
+ charbuffertype = bytes
-class StreamReader(Codec,codecs.StreamReader):
- pass
+class StreamReader(Codec, codecs.StreamReader):
+ charbuffertype = bytes
### encodings module API
diff --git a/Lib/filecmp.py b/Lib/filecmp.py
index 4728317fce9..f5cea1de6ff 100644
--- a/Lib/filecmp.py
+++ b/Lib/filecmp.py
@@ -4,21 +4,21 @@ Classes:
dircmp
Functions:
- cmp(f1, f2, shallow=1) -> int
+ cmp(f1, f2, shallow=True) -> int
cmpfiles(a, b, common) -> ([], [], [])
"""
import os
import stat
-from itertools import ifilter, ifilterfalse, imap, izip
+from itertools import filterfalse
-__all__ = ["cmp","dircmp","cmpfiles"]
+__all__ = ["cmp", "dircmp", "cmpfiles"]
_cache = {}
-BUFSIZE=8*1024
+BUFSIZE = 8*1024
-def cmp(f1, f2, shallow=1):
+def cmp(f1, f2, shallow=True):
"""Compare two files.
Arguments:
@@ -77,7 +77,7 @@ def _do_cmp(f1, f2):
class dircmp:
"""A class that manages the comparison of 2 directories.
- dircmp(a,b,ignore=None,hide=None)
+ dircmp(a, b, ignore=None, hide=None)
A and B are directories.
IGNORE is a list of names to ignore,
defaults to ['RCS', 'CVS', 'tags'].
@@ -129,11 +129,11 @@ class dircmp:
self.right_list.sort()
def phase1(self): # Compute common names
- a = dict(izip(imap(os.path.normcase, self.left_list), self.left_list))
- b = dict(izip(imap(os.path.normcase, self.right_list), self.right_list))
- self.common = map(a.__getitem__, ifilter(b.__contains__, a))
- self.left_only = map(a.__getitem__, ifilterfalse(b.__contains__, a))
- self.right_only = map(b.__getitem__, ifilterfalse(a.__contains__, b))
+ a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))
+ b = dict(zip(map(os.path.normcase, self.right_list), self.right_list))
+ self.common = list(map(a.__getitem__, filter(b.__contains__, a)))
+ self.left_only = list(map(a.__getitem__, filterfalse(b.__contains__, a)))
+ self.right_only = list(map(b.__getitem__, filterfalse(a.__contains__, b)))
def phase2(self): # Distinguish files, directories, funnies
self.common_dirs = []
@@ -147,13 +147,13 @@ class dircmp:
ok = 1
try:
a_stat = os.stat(a_path)
- except os.error, why:
- # print 'Can\'t stat', a_path, ':', why[1]
+ except os.error as why:
+ # print('Can\'t stat', a_path, ':', why.args[1])
ok = 0
try:
b_stat = os.stat(b_path)
- except os.error, why:
- # print 'Can\'t stat', b_path, ':', why[1]
+ except os.error as why:
+ # print('Can\'t stat', b_path, ':', why.args[1])
ok = 0
if ok:
@@ -186,44 +186,44 @@ class dircmp:
def phase4_closure(self): # Recursively call phase4() on subdirectories
self.phase4()
- for sd in self.subdirs.itervalues():
+ for sd in self.subdirs.values():
sd.phase4_closure()
def report(self): # Print a report on the differences between a and b
# Output format is purposely lousy
- print 'diff', self.left, self.right
+ print('diff', self.left, self.right)
if self.left_only:
self.left_only.sort()
- print 'Only in', self.left, ':', self.left_only
+ print('Only in', self.left, ':', self.left_only)
if self.right_only:
self.right_only.sort()
- print 'Only in', self.right, ':', self.right_only
+ print('Only in', self.right, ':', self.right_only)
if self.same_files:
self.same_files.sort()
- print 'Identical files :', self.same_files
+ print('Identical files :', self.same_files)
if self.diff_files:
self.diff_files.sort()
- print 'Differing files :', self.diff_files
+ print('Differing files :', self.diff_files)
if self.funny_files:
self.funny_files.sort()
- print 'Trouble with common files :', self.funny_files
+ print('Trouble with common files :', self.funny_files)
if self.common_dirs:
self.common_dirs.sort()
- print 'Common subdirectories :', self.common_dirs
+ print('Common subdirectories :', self.common_dirs)
if self.common_funny:
self.common_funny.sort()
- print 'Common funny cases :', self.common_funny
+ print('Common funny cases :', self.common_funny)
def report_partial_closure(self): # Print reports on self and on subdirs
self.report()
- for sd in self.subdirs.itervalues():
- print
+ for sd in self.subdirs.values():
+ print()
sd.report()
def report_full_closure(self): # Report on self and subdirs recursively
self.report()
- for sd in self.subdirs.itervalues():
- print
+ for sd in self.subdirs.values():
+ print()
sd.report_full_closure()
methodmap = dict(subdirs=phase4,
@@ -234,11 +234,11 @@ class dircmp:
def __getattr__(self, attr):
if attr not in self.methodmap:
- raise AttributeError, attr
+ raise AttributeError(attr)
self.methodmap[attr](self)
return getattr(self, attr)
-def cmpfiles(a, b, common, shallow=1):
+def cmpfiles(a, b, common, shallow=True):
"""Compare common files in two directories.
a, b -- directory names
@@ -275,7 +275,7 @@ def _cmp(a, b, sh, abs=abs, cmp=cmp):
# Return a copy with items that occur in skip removed.
#
def _filter(flist, skip):
- return list(ifilterfalse(skip.__contains__, flist))
+ return list(filterfalse(skip.__contains__, flist))
# Demonstration and testing.
diff --git a/Lib/fileinput.py b/Lib/fileinput.py
index ba485752092..554beb2448c 100644
--- a/Lib/fileinput.py
+++ b/Lib/fileinput.py
@@ -81,16 +81,17 @@ XXX Possible additions:
import sys, os
-__all__ = ["input","close","nextfile","filename","lineno","filelineno",
- "isfirstline","isstdin","FileInput"]
+__all__ = ["input", "close", "nextfile", "filename", "lineno", "filelineno",
+ "isfirstline", "isstdin", "FileInput"]
_state = None
DEFAULT_BUFSIZE = 8*1024
-def input(files=None, inplace=0, backup="", bufsize=0,
+def input(files=None, inplace=False, backup="", bufsize=0,
mode="r", openhook=None):
- """input([files[, inplace[, backup[, mode[, openhook]]]]])
+ """input(files=None, inplace=False, backup="", bufsize=0, \
+mode="r", openhook=None)
Create an instance of the FileInput class. The instance will be used
as global state for the functions of this module, and is also returned
@@ -99,7 +100,7 @@ def input(files=None, inplace=0, backup="", bufsize=0,
"""
global _state
if _state and _state._file:
- raise RuntimeError, "input() already active"
+ raise RuntimeError("input() already active")
_state = FileInput(files, inplace, backup, bufsize, mode, openhook)
return _state
@@ -122,7 +123,7 @@ def nextfile():
last file has been read, this function has no effect.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.nextfile()
def filename():
@@ -131,7 +132,7 @@ def filename():
Before the first line has been read, returns None.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.filename()
def lineno():
@@ -141,7 +142,7 @@ def lineno():
of the last file has been read, returns the line number of that line.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.lineno()
def filelineno():
@@ -151,7 +152,7 @@ def filelineno():
been read, returns the line number of that line within the file.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.filelineno()
def fileno():
@@ -160,7 +161,7 @@ def fileno():
opened, returns -1.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.fileno()
def isfirstline():
@@ -169,7 +170,7 @@ def isfirstline():
otherwise returns false.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.isfirstline()
def isstdin():
@@ -178,7 +179,7 @@ def isstdin():
otherwise returns false.
"""
if not _state:
- raise RuntimeError, "no active input()"
+ raise RuntimeError("no active input()")
return _state.isstdin()
class FileInput:
@@ -194,9 +195,9 @@ class FileInput:
sequential order; random access and readline() cannot be mixed.
"""
- def __init__(self, files=None, inplace=0, backup="", bufsize=0,
+ def __init__(self, files=None, inplace=False, backup="", bufsize=0,
mode="r", openhook=None):
- if isinstance(files, basestring):
+ if isinstance(files, str):
files = (files,)
else:
if files is None:
@@ -224,10 +225,11 @@ class FileInput:
raise ValueError("FileInput opening mode must be one of "
"'r', 'rU', 'U' and 'rb'")
self._mode = mode
- if inplace and openhook:
- raise ValueError("FileInput cannot use an opening hook in inplace mode")
- elif openhook and not hasattr(openhook, '__call__'):
- raise ValueError("FileInput openhook must be callable")
+ if openhook:
+ if inplace:
+ raise ValueError("FileInput cannot use an opening hook in inplace mode")
+ if not callable(openhook):
+ raise ValueError("FileInput openhook must be callable")
self._openhook = openhook
def __del__(self):
@@ -237,10 +239,16 @@ class FileInput:
self.nextfile()
self._files = ()
+ def __enter__(self):
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
try:
line = self._buffer[self._bufindex]
except IndexError:
@@ -257,11 +265,11 @@ class FileInput:
def __getitem__(self, i):
if i != self._lineno:
- raise RuntimeError, "accessing lines out of order"
+ raise RuntimeError("accessing lines out of order")
try:
- return self.next()
+ return self.__next__()
except StopIteration:
- raise IndexError, "end of input reached"
+ raise IndexError("end of input reached")
def nextfile(self):
savestdout = self._savestdout
@@ -315,7 +323,7 @@ class FileInput:
else:
if self._inplace:
self._backupfilename = (
- self._filename + (self._backup or os.extsep+"bak"))
+ self._filename + (self._backup or ".bak"))
try: os.unlink(self._backupfilename)
except os.error: pass
# The next few lines may raise IOError
@@ -326,9 +334,11 @@ class FileInput:
except OSError:
self._output = open(self._filename, "w")
else:
- fd = os.open(self._filename,
- os.O_CREAT | os.O_WRONLY | os.O_TRUNC,
- perm)
+ mode = os.O_CREAT | os.O_WRONLY | os.O_TRUNC
+ if hasattr(os, 'O_BINARY'):
+ mode |= os.O_BINARY
+
+ fd = os.open(self._filename, mode, perm)
self._output = os.fdopen(fd, "w")
try:
if hasattr(os, 'chmod'):
@@ -396,18 +406,18 @@ def hook_encoded(encoding):
def _test():
import getopt
- inplace = 0
- backup = 0
+ inplace = False
+ backup = False
opts, args = getopt.getopt(sys.argv[1:], "ib:")
for o, a in opts:
- if o == '-i': inplace = 1
+ if o == '-i': inplace = True
if o == '-b': backup = a
for line in input(args, inplace=inplace, backup=backup):
if line[-1:] == '\n': line = line[:-1]
if line[-1:] == '\r': line = line[:-1]
- print "%d: %s[%d]%s %s" % (lineno(), filename(), filelineno(),
- isfirstline() and "*" or "", line)
- print "%d: %s[%d]" % (lineno(), filename(), filelineno())
+ print("%d: %s[%d]%s %s" % (lineno(), filename(), filelineno(),
+ isfirstline() and "*" or "", line))
+ print("%d: %s[%d]" % (lineno(), filename(), filelineno()))
if __name__ == '__main__':
_test()
diff --git a/Lib/fnmatch.py b/Lib/fnmatch.py
index ffe99b5762d..726fbe556e8 100644
--- a/Lib/fnmatch.py
+++ b/Lib/fnmatch.py
@@ -9,18 +9,13 @@ expression. They cache the compiled regular expressions for speed.
The function translate(PATTERN) returns a regular expression
corresponding to PATTERN. (It does not compile it.)
"""
-
+import os
+import posixpath
import re
+import functools
__all__ = ["filter", "fnmatch", "fnmatchcase", "translate"]
-_cache = {}
-_MAXCACHE = 100
-
-def _purge():
- """Clear the pattern cache"""
- _cache.clear()
-
def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
@@ -36,23 +31,25 @@ def fnmatch(name, pat):
if the operating system requires it.
If you don't want this, use fnmatchcase(FILENAME, PATTERN).
"""
-
- import os
name = os.path.normcase(name)
pat = os.path.normcase(pat)
return fnmatchcase(name, pat)
-def filter(names, pat):
- """Return the subset of the list NAMES that match PAT"""
- import os,posixpath
- result=[]
- pat=os.path.normcase(pat)
- if not pat in _cache:
+@functools.lru_cache(maxsize=250)
+def _compile_pattern(pat, is_bytes=False):
+ if is_bytes:
+ pat_str = str(pat, 'ISO-8859-1')
+ res_str = translate(pat_str)
+ res = bytes(res_str, 'ISO-8859-1')
+ else:
res = translate(pat)
- if len(_cache) >= _MAXCACHE:
- _cache.clear()
- _cache[pat] = re.compile(res)
- match=_cache[pat].match
+ return re.compile(res).match
+
+def filter(names, pat):
+ """Return the subset of the list NAMES that match PAT."""
+ result = []
+ pat = os.path.normcase(pat)
+ match = _compile_pattern(pat, isinstance(pat, bytes))
if os.path is posixpath:
# normcase on posix is NOP. Optimize it away from the loop.
for name in names:
@@ -70,13 +67,9 @@ def fnmatchcase(name, pat):
This is a version of fnmatch() which doesn't case-normalize
its arguments.
"""
+ match = _compile_pattern(pat, isinstance(pat, bytes))
+ return match(name) is not None
- if not pat in _cache:
- res = translate(pat)
- if len(_cache) >= _MAXCACHE:
- _cache.clear()
- _cache[pat] = re.compile(res)
- return _cache[pat].match(name) is not None
def translate(pat):
"""Translate a shell PATTERN to a regular expression.
diff --git a/Lib/formatter.py b/Lib/formatter.py
index e0a8fe10b22..60e60f11601 100644
--- a/Lib/formatter.py
+++ b/Lib/formatter.py
@@ -255,7 +255,7 @@ class AbstractFormatter:
def push_margin(self, margin):
self.margin_stack.append(margin)
- fstack = filter(None, self.margin_stack)
+ fstack = [m for m in self.margin_stack if m]
if not margin and fstack:
margin = fstack[-1]
self.writer.new_margin(margin, len(fstack))
@@ -263,7 +263,7 @@ class AbstractFormatter:
def pop_margin(self):
if self.margin_stack:
del self.margin_stack[-1]
- fstack = filter(None, self.margin_stack)
+ fstack = [m for m in self.margin_stack if m]
if fstack:
margin = fstack[-1]
else:
@@ -324,37 +324,37 @@ class AbstractWriter(NullWriter):
"""
def new_alignment(self, align):
- print "new_alignment(%r)" % (align,)
+ print("new_alignment(%r)" % (align,))
def new_font(self, font):
- print "new_font(%r)" % (font,)
+ print("new_font(%r)" % (font,))
def new_margin(self, margin, level):
- print "new_margin(%r, %d)" % (margin, level)
+ print("new_margin(%r, %d)" % (margin, level))
def new_spacing(self, spacing):
- print "new_spacing(%r)" % (spacing,)
+ print("new_spacing(%r)" % (spacing,))
def new_styles(self, styles):
- print "new_styles(%r)" % (styles,)
+ print("new_styles(%r)" % (styles,))
def send_paragraph(self, blankline):
- print "send_paragraph(%r)" % (blankline,)
+ print("send_paragraph(%r)" % (blankline,))
def send_line_break(self):
- print "send_line_break()"
+ print("send_line_break()")
def send_hor_rule(self, *args, **kw):
- print "send_hor_rule()"
+ print("send_hor_rule()")
def send_label_data(self, data):
- print "send_label_data(%r)" % (data,)
+ print("send_label_data(%r)" % (data,))
def send_flowing_data(self, data):
- print "send_flowing_data(%r)" % (data,)
+ print("send_flowing_data(%r)" % (data,))
def send_literal_data(self, data):
- print "send_literal_data(%r)" % (data,)
+ print("send_literal_data(%r)" % (data,))
class DumbWriter(NullWriter):
diff --git a/Lib/fpformat.py b/Lib/fpformat.py
deleted file mode 100644
index 71cbb25f3c8..00000000000
--- a/Lib/fpformat.py
+++ /dev/null
@@ -1,145 +0,0 @@
-"""General floating point formatting functions.
-
-Functions:
-fix(x, digits_behind)
-sci(x, digits_behind)
-
-Each takes a number or a string and a number of digits as arguments.
-
-Parameters:
-x: number to be formatted; or a string resembling a number
-digits_behind: number of digits behind the decimal point
-"""
-from warnings import warnpy3k
-warnpy3k("the fpformat module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import re
-
-__all__ = ["fix","sci","NotANumber"]
-
-# Compiled regular expression to "decode" a number
-decoder = re.compile(r'^([-+]?)0*(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$')
-# \0 the whole thing
-# \1 leading sign or empty
-# \2 digits left of decimal point
-# \3 fraction (empty or begins with point)
-# \4 exponent part (empty or begins with 'e' or 'E')
-
-try:
- class NotANumber(ValueError):
- pass
-except TypeError:
- NotANumber = 'fpformat.NotANumber'
-
-def extract(s):
- """Return (sign, intpart, fraction, expo) or raise an exception:
- sign is '+' or '-'
- intpart is 0 or more digits beginning with a nonzero
- fraction is 0 or more digits
- expo is an integer"""
- res = decoder.match(s)
- if res is None: raise NotANumber, s
- sign, intpart, fraction, exppart = res.group(1,2,3,4)
- if sign == '+': sign = ''
- if fraction: fraction = fraction[1:]
- if exppart: expo = int(exppart[1:])
- else: expo = 0
- return sign, intpart, fraction, expo
-
-def unexpo(intpart, fraction, expo):
- """Remove the exponent by changing intpart and fraction."""
- if expo > 0: # Move the point left
- f = len(fraction)
- intpart, fraction = intpart + fraction[:expo], fraction[expo:]
- if expo > f:
- intpart = intpart + '0'*(expo-f)
- elif expo < 0: # Move the point right
- i = len(intpart)
- intpart, fraction = intpart[:expo], intpart[expo:] + fraction
- if expo < -i:
- fraction = '0'*(-expo-i) + fraction
- return intpart, fraction
-
-def roundfrac(intpart, fraction, digs):
- """Round or extend the fraction to size digs."""
- f = len(fraction)
- if f <= digs:
- return intpart, fraction + '0'*(digs-f)
- i = len(intpart)
- if i+digs < 0:
- return '0'*-digs, ''
- total = intpart + fraction
- nextdigit = total[i+digs]
- if nextdigit >= '5': # Hard case: increment last digit, may have carry!
- n = i + digs - 1
- while n >= 0:
- if total[n] != '9': break
- n = n-1
- else:
- total = '0' + total
- i = i+1
- n = 0
- total = total[:n] + chr(ord(total[n]) + 1) + '0'*(len(total)-n-1)
- intpart, fraction = total[:i], total[i:]
- if digs >= 0:
- return intpart, fraction[:digs]
- else:
- return intpart[:digs] + '0'*-digs, ''
-
-def fix(x, digs):
- """Format x as [-]ddd.ddd with 'digs' digits after the point
- and at least one digit before.
- If digs <= 0, the point is suppressed."""
- if type(x) != type(''): x = repr(x)
- try:
- sign, intpart, fraction, expo = extract(x)
- except NotANumber:
- return x
- intpart, fraction = unexpo(intpart, fraction, expo)
- intpart, fraction = roundfrac(intpart, fraction, digs)
- while intpart and intpart[0] == '0': intpart = intpart[1:]
- if intpart == '': intpart = '0'
- if digs > 0: return sign + intpart + '.' + fraction
- else: return sign + intpart
-
-def sci(x, digs):
- """Format x as [-]d.dddE[+-]ddd with 'digs' digits after the point
- and exactly one digit before.
- If digs is <= 0, one digit is kept and the point is suppressed."""
- if type(x) != type(''): x = repr(x)
- sign, intpart, fraction, expo = extract(x)
- if not intpart:
- while fraction and fraction[0] == '0':
- fraction = fraction[1:]
- expo = expo - 1
- if fraction:
- intpart, fraction = fraction[0], fraction[1:]
- expo = expo - 1
- else:
- intpart = '0'
- else:
- expo = expo + len(intpart) - 1
- intpart, fraction = intpart[0], intpart[1:] + fraction
- digs = max(0, digs)
- intpart, fraction = roundfrac(intpart, fraction, digs)
- if len(intpart) > 1:
- intpart, fraction, expo = \
- intpart[0], intpart[1:] + fraction[:-1], \
- expo + len(intpart) - 1
- s = sign + intpart
- if digs > 0: s = s + '.' + fraction
- e = repr(abs(expo))
- e = '0'*(3-len(e)) + e
- if expo < 0: e = '-' + e
- else: e = '+' + e
- return s + 'e' + e
-
-def test():
- """Interactive test run."""
- try:
- while 1:
- x, digs = input('Enter (x, digs): ')
- print x, fix(x, digs), sci(x, digs)
- except (EOFError, KeyboardInterrupt):
- pass
diff --git a/Lib/fractions.py b/Lib/fractions.py
index a0d86a43936..8be52d2db88 100644
--- a/Lib/fractions.py
+++ b/Lib/fractions.py
@@ -1,18 +1,17 @@
# Originally contributed by Sjoerd Mullender.
# Significantly modified by Jeffrey Yasskin <jyasskin at gmail.com>.
-"""Rational, infinite-precision, real numbers."""
+"""Fraction, infinite-precision, real numbers."""
-from __future__ import division
from decimal import Decimal
import math
import numbers
import operator
import re
+import sys
__all__ = ['Fraction', 'gcd']
-Rational = numbers.Rational
def gcd(a, b):
@@ -25,6 +24,12 @@ def gcd(a, b):
a, b = b, a%b
return a
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+# Value to be used for rationals that reduce to infinity modulo
+# _PyHASH_MODULUS.
+_PyHASH_INF = sys.hash_info.inf
_RATIONAL_FORMAT = re.compile(r"""
\A\s* # optional whitespace at the start, then
@@ -41,7 +46,7 @@ _RATIONAL_FORMAT = re.compile(r"""
""", re.VERBOSE | re.IGNORECASE)
-class Fraction(Rational):
+class Fraction(numbers.Rational):
"""This class implements rational numbers.
In the two-argument form of the constructor, Fraction(8, 6) will
@@ -66,7 +71,7 @@ class Fraction(Rational):
# We're immutable, so use __new__ not __init__
def __new__(cls, numerator=0, denominator=None):
- """Constructs a Fraction.
+ """Constructs a Rational.
Takes a string like '3/2' or '1.5', another Rational instance, a
numerator/denominator pair, or a float.
@@ -99,7 +104,7 @@ class Fraction(Rational):
self = super(Fraction, cls).__new__(cls)
if denominator is None:
- if isinstance(numerator, Rational):
+ if isinstance(numerator, numbers.Rational):
self._numerator = numerator.numerator
self._denominator = numerator.denominator
return self
@@ -117,7 +122,7 @@ class Fraction(Rational):
self._denominator = value._denominator
return self
- elif isinstance(numerator, basestring):
+ elif isinstance(numerator, str):
# Handle construction from strings.
m = _RATIONAL_FORMAT.match(numerator)
if m is None:
@@ -148,8 +153,8 @@ class Fraction(Rational):
raise TypeError("argument should be a string "
"or a Rational instance")
- elif (isinstance(numerator, Rational) and
- isinstance(denominator, Rational)):
+ elif (isinstance(numerator, numbers.Rational) and
+ isinstance(denominator, numbers.Rational)):
numerator, denominator = (
numerator.numerator * denominator.denominator,
denominator.numerator * numerator.denominator
@@ -293,7 +298,7 @@ class Fraction(Rational):
def __add__(self, other):
# Both types have numerators/denominator attributes,
# so do the operation directly
- if isinstance(other, (int, long, Fraction)):
+ if isinstance(other, (int, Fraction)):
return Fraction(self.numerator * other.denominator +
other.numerator * self.denominator,
self.denominator * other.denominator)
@@ -309,7 +314,7 @@ class Fraction(Rational):
def __radd__(self, other):
# radd handles more types than add because there's
# nothing left to fall back to.
- if isinstance(other, Rational):
+ if isinstance(other, numbers.Rational):
return Fraction(self.numerator * other.denominator +
other.numerator * self.denominator,
self.denominator * other.denominator)
@@ -358,7 +363,7 @@ class Fraction(Rational):
"""
def forward(a, b):
- if isinstance(b, (int, long, Fraction)):
+ if isinstance(b, (int, Fraction)):
return monomorphic_operator(a, b)
elif isinstance(b, float):
return fallback_operator(float(a), b)
@@ -370,7 +375,7 @@ class Fraction(Rational):
forward.__doc__ = monomorphic_operator.__doc__
def reverse(b, a):
- if isinstance(a, Rational):
+ if isinstance(a, numbers.Rational):
# Includes ints.
return monomorphic_operator(a, b)
elif isinstance(a, numbers.Real):
@@ -412,31 +417,14 @@ class Fraction(Rational):
a.denominator * b.numerator)
__truediv__, __rtruediv__ = _operator_fallbacks(_div, operator.truediv)
- __div__, __rdiv__ = _operator_fallbacks(_div, operator.div)
def __floordiv__(a, b):
"""a // b"""
- # Will be math.floor(a / b) in 3.0.
- div = a / b
- if isinstance(div, Rational):
- # trunc(math.floor(div)) doesn't work if the rational is
- # more precise than a float because the intermediate
- # rounding may cross an integer boundary.
- return div.numerator // div.denominator
- else:
- return math.floor(div)
+ return math.floor(a / b)
def __rfloordiv__(b, a):
"""a // b"""
- # Will be math.floor(a / b) in 3.0.
- div = a / b
- if isinstance(div, Rational):
- # trunc(math.floor(div)) doesn't work if the rational is
- # more precise than a float because the intermediate
- # rounding may cross an integer boundary.
- return div.numerator // div.denominator
- else:
- return math.floor(div)
+ return math.floor(a / b)
def __mod__(a, b):
"""a % b"""
@@ -456,7 +444,7 @@ class Fraction(Rational):
result will be rational.
"""
- if isinstance(b, Rational):
+ if isinstance(b, numbers.Rational):
if b.denominator == 1:
power = b.numerator
if power >= 0:
@@ -478,7 +466,7 @@ class Fraction(Rational):
# If a is an int, keep it that way if possible.
return a ** b._numerator
- if isinstance(a, Rational):
+ if isinstance(a, numbers.Rational):
return Fraction(a.numerator, a.denominator) ** b
if b._denominator == 1:
@@ -505,28 +493,65 @@ class Fraction(Rational):
else:
return a._numerator // a._denominator
- def __hash__(self):
- """hash(self)
+ def __floor__(a):
+ """Will be math.floor(a) in 3.0."""
+ return a.numerator // a.denominator
- Tricky because values that are exactly representable as a
- float must have the same hash as that float.
+ def __ceil__(a):
+ """Will be math.ceil(a) in 3.0."""
+ # The negations cleverly convince floordiv to return the ceiling.
+ return -(-a.numerator // a.denominator)
+ def __round__(self, ndigits=None):
+ """Will be round(self, ndigits) in 3.0.
+
+ Rounds half toward even.
"""
+ if ndigits is None:
+ floor, remainder = divmod(self.numerator, self.denominator)
+ if remainder * 2 < self.denominator:
+ return floor
+ elif remainder * 2 > self.denominator:
+ return floor + 1
+ # Deal with the half case:
+ elif floor % 2 == 0:
+ return floor
+ else:
+ return floor + 1
+ shift = 10**abs(ndigits)
+ # See _operator_fallbacks.forward to check that the results of
+ # these operations will always be Fraction and therefore have
+ # round().
+ if ndigits > 0:
+ return Fraction(round(self * shift), shift)
+ else:
+ return Fraction(round(self / shift) * shift)
+
+ def __hash__(self):
+ """hash(self)"""
+
# XXX since this method is expensive, consider caching the result
- if self._denominator == 1:
- # Get integers right.
- return hash(self._numerator)
- # Expensive check, but definitely correct.
- if self == float(self):
- return hash(float(self))
+
+ # In order to make sure that the hash of a Fraction agrees
+ # with the hash of a numerically equal integer, float or
+ # Decimal instance, we follow the rules for numeric hashes
+ # outlined in the documentation. (See library docs, 'Built-in
+ # Types').
+
+ # dinv is the inverse of self._denominator modulo the prime
+ # _PyHASH_MODULUS, or 0 if self._denominator is divisible by
+ # _PyHASH_MODULUS.
+ dinv = pow(self._denominator, _PyHASH_MODULUS - 2, _PyHASH_MODULUS)
+ if not dinv:
+ hash_ = _PyHASH_INF
else:
- # Use tuple's hash to avoid a high collision rate on
- # simple fractions.
- return hash((self._numerator, self._denominator))
+ hash_ = abs(self._numerator) * dinv % _PyHASH_MODULUS
+ result = hash_ if self >= 0 else -hash_
+ return -2 if result == -1 else result
def __eq__(a, b):
"""a == b"""
- if isinstance(b, Rational):
+ if isinstance(b, numbers.Rational):
return (a._numerator == b.numerator and
a._denominator == b.denominator)
if isinstance(b, numbers.Complex) and b.imag == 0:
@@ -554,13 +579,9 @@ class Fraction(Rational):
"""
# convert other to a Rational instance where reasonable.
- if isinstance(other, Rational):
+ if isinstance(other, numbers.Rational):
return op(self._numerator * other.denominator,
self._denominator * other.numerator)
- # comparisons with complex should raise a TypeError, for consistency
- # with int<->complex, float<->complex, and complex<->complex comparisons.
- if isinstance(other, complex):
- raise TypeError("no ordering relation is defined for complex numbers")
if isinstance(other, float):
if math.isnan(other) or math.isinf(other):
return op(0.0, other)
@@ -585,7 +606,7 @@ class Fraction(Rational):
"""a >= b"""
return a._richcmp(b, operator.ge)
- def __nonzero__(a):
+ def __bool__(a):
"""a != 0"""
return a._numerator != 0
diff --git a/Lib/ftplib.py b/Lib/ftplib.py
index 53b5f44c52d..a0f0f90fd0e 100644
--- a/Lib/ftplib.py
+++ b/Lib/ftplib.py
@@ -38,13 +38,7 @@ python ftplib.py -d localhost -l -p -l
import os
import sys
-
-# Import SOCKS module if it exists, else standard socket module socket
-try:
- import SOCKS; socket = SOCKS; del SOCKS # import SOCKS as socket
- from socket import getfqdn; socket.getfqdn = getfqdn; del getfqdn
-except ImportError:
- import socket
+import socket
from socket import _GLOBAL_DEFAULT_TIMEOUT
__all__ = ["FTP","Netrc"]
@@ -72,6 +66,7 @@ all_errors = (Error, IOError, EOFError)
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
CRLF = '\r\n'
+B_CRLF = b'\r\n'
# The class itself
class FTP:
@@ -96,7 +91,7 @@ class FTP:
below for details).
The download/upload functions first issue appropriate TYPE
and PORT or PASV commands.
-'''
+ '''
debugging = 0
host = ''
@@ -105,6 +100,7 @@ class FTP:
file = None
welcome = None
passiveserver = 1
+ encoding = "latin1"
# Initialization method (called by class instantiation).
# Initialize host to localhost, port to standard ftp port
@@ -118,6 +114,20 @@ class FTP:
if user:
self.login(user, passwd, acct)
+ def __enter__(self):
+ return self
+
+ # Context management protocol: try to quit() if active
+ def __exit__(self, *args):
+ if self.sock is not None:
+ try:
+ self.quit()
+ except (socket.error, EOFError):
+ pass
+ finally:
+ if self.sock is not None:
+ self.close()
+
def connect(self, host='', port=0, timeout=-999):
'''Connect to host. Arguments are:
- host: hostname to connect to (string, default previous host)
@@ -131,7 +141,7 @@ class FTP:
self.timeout = timeout
self.sock = socket.create_connection((self.host, self.port), self.timeout)
self.af = self.sock.family
- self.file = self.sock.makefile('rb')
+ self.file = self.sock.makefile('r', encoding=self.encoding)
self.welcome = self.getresp()
return self.welcome
@@ -139,7 +149,7 @@ class FTP:
'''Get the welcome message from the server.
(this is read and squirreled away by connect())'''
if self.debugging:
- print '*welcome*', self.sanitize(self.welcome)
+ print('*welcome*', self.sanitize(self.welcome))
return self.welcome
def set_debuglevel(self, level):
@@ -161,7 +171,7 @@ class FTP:
def sanitize(self, s):
if s[:5] == 'pass ' or s[:5] == 'PASS ':
i = len(s)
- while i > 5 and s[i-1] in '\r\n':
+ while i > 5 and s[i-1] in {'\r', '\n'}:
i = i-1
s = s[:5] + '*'*(i-5) + s[i:]
return repr(s)
@@ -169,12 +179,12 @@ class FTP:
# Internal: send one line to the server, appending CRLF
def putline(self, line):
line = line + CRLF
- if self.debugging > 1: print '*put*', self.sanitize(line)
- self.sock.sendall(line)
+ if self.debugging > 1: print('*put*', self.sanitize(line))
+ self.sock.sendall(line.encode(self.encoding))
# Internal: send one command to the server (through putline())
def putcmd(self, line):
- if self.debugging: print '*cmd*', self.sanitize(line)
+ if self.debugging: print('*cmd*', self.sanitize(line))
self.putline(line)
# Internal: return one line from the server, stripping CRLF.
@@ -182,7 +192,7 @@ class FTP:
def getline(self):
line = self.file.readline()
if self.debugging > 1:
- print '*get*', self.sanitize(line)
+ print('*get*', self.sanitize(line))
if not line: raise EOFError
if line[-2:] == CRLF: line = line[:-2]
elif line[-1:] in CRLF: line = line[:-1]
@@ -208,22 +218,22 @@ class FTP:
# Raise various errors if the response indicates an error
def getresp(self):
resp = self.getmultiline()
- if self.debugging: print '*resp*', self.sanitize(resp)
+ if self.debugging: print('*resp*', self.sanitize(resp))
self.lastresp = resp[:3]
c = resp[:1]
- if c in ('1', '2', '3'):
+ if c in {'1', '2', '3'}:
return resp
if c == '4':
- raise error_temp, resp
+ raise error_temp(resp)
if c == '5':
- raise error_perm, resp
- raise error_proto, resp
+ raise error_perm(resp)
+ raise error_proto(resp)
def voidresp(self):
"""Expect a response beginning with '2'."""
resp = self.getresp()
if resp[:1] != '2':
- raise error_reply, resp
+ raise error_reply(resp)
return resp
def abort(self):
@@ -231,12 +241,13 @@ class FTP:
This does not follow the procedure from the RFC to send Telnet
IP and Synch; that doesn't seem to work with the servers I've
tried. Instead, just send the ABOR command as OOB data.'''
- line = 'ABOR' + CRLF
- if self.debugging > 1: print '*put urgent*', self.sanitize(line)
+ line = b'ABOR' + B_CRLF
+ if self.debugging > 1: print('*put urgent*', self.sanitize(line))
self.sock.sendall(line, MSG_OOB)
resp = self.getmultiline()
- if resp[:3] not in ('426', '225', '226'):
- raise error_proto, resp
+ if resp[:3] not in {'426', '225', '226'}:
+ raise error_proto(resp)
+ return resp
def sendcmd(self, cmd):
'''Send a command and return the response.'''
@@ -266,7 +277,7 @@ class FTP:
if self.af == socket.AF_INET6:
af = 2
if af == 0:
- raise error_proto, 'unsupported address family'
+ raise error_proto('unsupported address family')
fields = ['', repr(af), host, repr(port), '']
cmd = 'EPRT ' + '|'.join(fields)
return self.voidcmd(cmd)
@@ -280,7 +291,8 @@ class FTP:
try:
sock = socket.socket(af, socktype, proto)
sock.bind(sa)
- except socket.error, err:
+ except socket.error as _:
+ err = _
if sock:
sock.close()
sock = None
@@ -291,6 +303,7 @@ class FTP:
raise err
else:
raise socket.error("getaddrinfo returns an empty list")
+ raise socket.error(msg)
sock.listen(1)
port = sock.getsockname()[1] # Get proper port
host = self.sock.getsockname()[0] # Get proper host
@@ -341,7 +354,7 @@ class FTP:
if resp[0] == '2':
resp = self.getresp()
if resp[0] != '1':
- raise error_reply, resp
+ raise error_reply(resp)
except:
conn.close()
raise
@@ -355,7 +368,7 @@ class FTP:
if resp[0] == '2':
resp = self.getresp()
if resp[0] != '1':
- raise error_reply, resp
+ raise error_reply(resp)
conn, sockaddr = sock.accept()
if self.timeout is not _GLOBAL_DEFAULT_TIMEOUT:
conn.settimeout(self.timeout)
@@ -375,7 +388,7 @@ class FTP:
if not user: user = 'anonymous'
if not passwd: passwd = ''
if not acct: acct = ''
- if user == 'anonymous' and passwd in ('', '-'):
+ if user == 'anonymous' and passwd in {'', '-'}:
# If there is no anonymous ftp password specified
# then we'll just use anonymous@
# We don't send any other thing because:
@@ -388,7 +401,7 @@ class FTP:
if resp[0] == '3': resp = self.sendcmd('PASS ' + passwd)
if resp[0] == '3': resp = self.sendcmd('ACCT ' + acct)
if resp[0] != '2':
- raise error_reply, resp
+ raise error_reply(resp)
return resp
def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
@@ -406,13 +419,12 @@ class FTP:
The response code.
"""
self.voidcmd('TYPE I')
- conn = self.transfercmd(cmd, rest)
- while 1:
- data = conn.recv(blocksize)
- if not data:
- break
- callback(data)
- conn.close()
+ with self.transfercmd(cmd, rest) as conn:
+ while 1:
+ data = conn.recv(blocksize)
+ if not data:
+ break
+ callback(data)
return self.voidresp()
def retrlines(self, cmd, callback = None):
@@ -429,20 +441,18 @@ class FTP:
"""
if callback is None: callback = print_line
resp = self.sendcmd('TYPE A')
- conn = self.transfercmd(cmd)
- fp = conn.makefile('rb')
- while 1:
- line = fp.readline()
- if self.debugging > 2: print '*retr*', repr(line)
- if not line:
- break
- if line[-2:] == CRLF:
- line = line[:-2]
- elif line[-1:] == '\n':
- line = line[:-1]
- callback(line)
- fp.close()
- conn.close()
+ with self.transfercmd(cmd) as conn, \
+ conn.makefile('r', encoding=self.encoding) as fp:
+ while 1:
+ line = fp.readline()
+ if self.debugging > 2: print('*retr*', repr(line))
+ if not line:
+ break
+ if line[-2:] == CRLF:
+ line = line[:-2]
+ elif line[-1:] == '\n':
+ line = line[:-1]
+ callback(line)
return self.voidresp()
def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
@@ -461,13 +471,12 @@ class FTP:
The response code.
"""
self.voidcmd('TYPE I')
- conn = self.transfercmd(cmd, rest)
- while 1:
- buf = fp.read(blocksize)
- if not buf: break
- conn.sendall(buf)
- if callback: callback(buf)
- conn.close()
+ with self.transfercmd(cmd, rest) as conn:
+ while 1:
+ buf = fp.read(blocksize)
+ if not buf: break
+ conn.sendall(buf)
+ if callback: callback(buf)
return self.voidresp()
def storlines(self, cmd, fp, callback=None):
@@ -483,16 +492,15 @@ class FTP:
The response code.
"""
self.voidcmd('TYPE A')
- conn = self.transfercmd(cmd)
- while 1:
- buf = fp.readline()
- if not buf: break
- if buf[-2:] != CRLF:
- if buf[-1] in CRLF: buf = buf[:-1]
- buf = buf + CRLF
- conn.sendall(buf)
- if callback: callback(buf)
- conn.close()
+ with self.transfercmd(cmd) as conn:
+ while 1:
+ buf = fp.readline()
+ if not buf: break
+ if buf[-2:] != B_CRLF:
+ if buf[-1] in B_CRLF: buf = buf[:-1]
+ buf = buf + B_CRLF
+ conn.sendall(buf)
+ if callback: callback(buf)
return self.voidresp()
def acct(self, password):
@@ -528,23 +536,23 @@ class FTP:
'''Rename a file.'''
resp = self.sendcmd('RNFR ' + fromname)
if resp[0] != '3':
- raise error_reply, resp
+ raise error_reply(resp)
return self.voidcmd('RNTO ' + toname)
def delete(self, filename):
'''Delete a file.'''
resp = self.sendcmd('DELE ' + filename)
- if resp[:3] in ('250', '200'):
+ if resp[:3] in {'250', '200'}:
return resp
else:
- raise error_reply, resp
+ raise error_reply(resp)
def cwd(self, dirname):
'''Change to a directory.'''
if dirname == '..':
try:
return self.voidcmd('CDUP')
- except error_perm, msg:
+ except error_perm as msg:
if msg.args[0][:3] != '500':
raise
elif dirname == '':
@@ -561,11 +569,15 @@ class FTP:
try:
return int(s)
except (OverflowError, ValueError):
- return long(s)
+ return int(s)
def mkd(self, dirname):
'''Make a directory, return its full pathname.'''
- resp = self.sendcmd('MKD ' + dirname)
+ resp = self.voidcmd('MKD ' + dirname)
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def rmd(self, dirname):
@@ -574,7 +586,11 @@ class FTP:
def pwd(self):
'''Return current working directory.'''
- resp = self.sendcmd('PWD')
+ resp = self.voidcmd('PWD')
+ # fix around non-compliant implementations such as IIS shipped
+ # with Windows server 2003
+ if not resp.startswith('257'):
+ return ''
return parse257(resp)
def quit(self):
@@ -585,11 +601,11 @@ class FTP:
def close(self):
'''Close the connection without assuming anything about it.'''
- if self.file is not None:
+ if self.file:
self.file.close()
- if self.sock is not None:
self.sock.close()
- self.file = self.sock = None
+ self.file = self.sock = None
+
try:
import ssl
@@ -632,9 +648,17 @@ else:
ssl_version = ssl.PROTOCOL_TLSv1
def __init__(self, host='', user='', passwd='', acct='', keyfile=None,
- certfile=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ certfile=None, context=None,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ if context is not None and keyfile is not None:
+ raise ValueError("context and keyfile arguments are mutually "
+ "exclusive")
+ if context is not None and certfile is not None:
+ raise ValueError("context and certfile arguments are mutually "
+ "exclusive")
self.keyfile = keyfile
self.certfile = certfile
+ self.context = context
self._prot_p = False
FTP.__init__(self, host, user, passwd, acct, timeout)
@@ -651,9 +675,13 @@ else:
resp = self.voidcmd('AUTH TLS')
else:
resp = self.voidcmd('AUTH SSL')
- self.sock = ssl.wrap_socket(self.sock, self.keyfile, self.certfile,
- ssl_version=self.ssl_version)
- self.file = self.sock.makefile(mode='rb')
+ if self.context is not None:
+ self.sock = self.context.wrap_socket(self.sock)
+ else:
+ self.sock = ssl.wrap_socket(self.sock, self.keyfile,
+ self.certfile,
+ ssl_version=self.ssl_version)
+ self.file = self.sock.makefile(mode='r', encoding=self.encoding)
return resp
def prot_p(self):
@@ -683,8 +711,11 @@ else:
def ntransfercmd(self, cmd, rest=None):
conn, size = FTP.ntransfercmd(self, cmd, rest)
if self._prot_p:
- conn = ssl.wrap_socket(conn, self.keyfile, self.certfile,
- ssl_version=self.ssl_version)
+ if self.context is not None:
+ conn = self.context.wrap_socket(conn)
+ else:
+ conn = ssl.wrap_socket(conn, self.keyfile, self.certfile,
+ ssl_version=self.ssl_version)
return conn, size
def retrbinary(self, cmd, callback, blocksize=8192, rest=None):
@@ -707,11 +738,11 @@ else:
if callback is None: callback = print_line
resp = self.sendcmd('TYPE A')
conn = self.transfercmd(cmd)
- fp = conn.makefile('rb')
+ fp = conn.makefile('r', encoding=self.encoding)
try:
while 1:
line = fp.readline()
- if self.debugging > 2: print '*retr*', repr(line)
+ if self.debugging > 2: print('*retr*', repr(line))
if not line:
break
if line[-2:] == CRLF:
@@ -750,9 +781,9 @@ else:
while 1:
buf = fp.readline()
if not buf: break
- if buf[-2:] != CRLF:
- if buf[-1] in CRLF: buf = buf[:-1]
- buf = buf + CRLF
+ if buf[-2:] != B_CRLF:
+ if buf[-1] in B_CRLF: buf = buf[:-1]
+ buf = buf + B_CRLF
conn.sendall(buf)
if callback: callback(buf)
# shutdown ssl layer
@@ -762,6 +793,15 @@ else:
conn.close()
return self.voidresp()
+ def abort(self):
+ # overridden as we can't pass MSG_OOB flag to sendall()
+ line = b'ABOR' + B_CRLF
+ self.sock.sendall(line)
+ resp = self.getmultiline()
+ if resp[:3] not in {'426', '225', '226'}:
+ raise error_proto(resp)
+ return resp
+
__all__.append('FTP_TLS')
all_errors = (Error, IOError, EOFError, ssl.SSLError)
@@ -774,11 +814,12 @@ def parse150(resp):
be present in the 150 message.
'''
if resp[:3] != '150':
- raise error_reply, resp
+ raise error_reply(resp)
global _150_re
if _150_re is None:
import re
- _150_re = re.compile("150 .* \((\d+) bytes\)", re.IGNORECASE)
+ _150_re = re.compile(
+ "150 .* \((\d+) bytes\)", re.IGNORECASE | re.ASCII)
m = _150_re.match(resp)
if not m:
return None
@@ -786,7 +827,7 @@ def parse150(resp):
try:
return int(s)
except (OverflowError, ValueError):
- return long(s)
+ return int(s)
_227_re = None
@@ -797,14 +838,14 @@ def parse227(resp):
Return ('host.addr.as.numbers', port#) tuple.'''
if resp[:3] != '227':
- raise error_reply, resp
+ raise error_reply(resp)
global _227_re
if _227_re is None:
import re
- _227_re = re.compile(r'(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)')
+ _227_re = re.compile(r'(\d+),(\d+),(\d+),(\d+),(\d+),(\d+)', re.ASCII)
m = _227_re.search(resp)
if not m:
- raise error_proto, resp
+ raise error_proto(resp)
numbers = m.groups()
host = '.'.join(numbers[:4])
port = (int(numbers[4]) << 8) + int(numbers[5])
@@ -817,17 +858,17 @@ def parse229(resp, peer):
Return ('host.addr.as.numbers', port#) tuple.'''
if resp[:3] != '229':
- raise error_reply, resp
+ raise error_reply(resp)
left = resp.find('(')
- if left < 0: raise error_proto, resp
+ if left < 0: raise error_proto(resp)
right = resp.find(')', left + 1)
if right < 0:
- raise error_proto, resp # should contain '(|||port|)'
+ raise error_proto(resp) # should contain '(|||port|)'
if resp[left + 1] != resp[right - 1]:
- raise error_proto, resp
+ raise error_proto(resp)
parts = resp[left + 1:right].split(resp[left+1])
if len(parts) != 5:
- raise error_proto, resp
+ raise error_proto(resp)
host = peer[0]
port = int(parts[3])
return host, port
@@ -839,7 +880,7 @@ def parse257(resp):
Returns the directoryname in the 257 reply.'''
if resp[:3] != '257':
- raise error_reply, resp
+ raise error_reply(resp)
if resp[3:5] != ' "':
return '' # Not compliant to RFC 959, but UNIX ftpd does this
dirname = ''
@@ -858,7 +899,7 @@ def parse257(resp):
def print_line(line):
'''Default retrlines callback to print a line.'''
- print line
+ print(line)
def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
@@ -873,9 +914,9 @@ def ftpcp(source, sourcename, target, targetname = '', type = 'I'):
# transfer request.
# So: STOR before RETR, because here the target is a "user".
treply = target.sendcmd('STOR ' + targetname)
- if treply[:3] not in ('125', '150'): raise error_proto # RFC 959
+ if treply[:3] not in {'125', '150'}: raise error_proto # RFC 959
sreply = source.sendcmd('RETR ' + sourcename)
- if sreply[:3] not in ('125', '150'): raise error_proto # RFC 959
+ if sreply[:3] not in {'125', '150'}: raise error_proto # RFC 959
source.voidresp()
target.voidresp()
@@ -898,8 +939,7 @@ class Netrc:
filename = os.path.join(os.environ["HOME"],
".netrc")
else:
- raise IOError, \
- "specify file to load or set $HOME"
+ raise IOError("specify file to load or set $HOME")
self.__hosts = {}
self.__macros = {}
fp = open(filename, "r")
@@ -997,7 +1037,7 @@ def test():
'''
if len(sys.argv) < 2:
- print test.__doc__
+ print(test.__doc__)
sys.exit(0)
debugging = 0
diff --git a/Lib/functools.py b/Lib/functools.py
index 53680b89466..85ea257abd8 100644
--- a/Lib/functools.py
+++ b/Lib/functools.py
@@ -4,15 +4,24 @@
# to allow utilities written in Python to be added
# to the functools module.
# Written by Nick Coghlan <ncoghlan at gmail.com>
-# Copyright (C) 2006 Python Software Foundation.
+# and Raymond Hettinger <python at rcn.com>
+# Copyright (C) 2006-2010 Python Software Foundation.
# See C source code for _functools credits/copyright
+__all__ = ['update_wrapper', 'wraps', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES',
+ 'total_ordering', 'cmp_to_key', 'lru_cache', 'reduce', 'partial']
+
from _functools import partial, reduce
+from collections import OrderedDict, namedtuple
+try:
+ from _thread import allocate_lock as Lock
+except:
+ from _dummy_thread import allocate_lock as Lock
# update_wrapper() and wraps() are tools to help write
# wrapper functions that can handle naive introspection
-WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__')
+WRAPPER_ASSIGNMENTS = ('__module__', '__name__', '__doc__', '__annotations__')
WRAPPER_UPDATES = ('__dict__',)
def update_wrapper(wrapper,
wrapped,
@@ -29,8 +38,14 @@ def update_wrapper(wrapper,
are updated with the corresponding attribute from the wrapped
function (defaults to functools.WRAPPER_UPDATES)
"""
+ wrapper.__wrapped__ = wrapped
for attr in assigned:
- setattr(wrapper, attr, getattr(wrapped, attr))
+ try:
+ value = getattr(wrapped, attr)
+ except AttributeError:
+ pass
+ else:
+ setattr(wrapper, attr, value)
for attr in updated:
getattr(wrapper, attr).update(getattr(wrapped, attr, {}))
# Return the wrapper so this can be used as a decorator via partial()
@@ -66,7 +81,8 @@ def total_ordering(cls):
('__gt__', lambda self, other: self >= other and not self == other),
('__lt__', lambda self, other: not self >= other)]
}
- roots = set(dir(cls)) & set(convert)
+ # Find user-defined comparisons (not those inherited from object).
+ roots = [op for op in convert if getattr(cls, op, None) is not getattr(object, op, None)]
if not roots:
raise ValueError('must define at least one ordering operation: < > <= >=')
root = max(roots) # prefer __lt__ to __le__ to __gt__ to __ge__
@@ -81,7 +97,7 @@ def cmp_to_key(mycmp):
"""Convert a cmp= function into a key= function"""
class K(object):
__slots__ = ['obj']
- def __init__(self, obj, *args):
+ def __init__(self, obj):
self.obj = obj
def __lt__(self, other):
return mycmp(self.obj, other.obj) < 0
@@ -95,6 +111,98 @@ def cmp_to_key(mycmp):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
- def __hash__(self):
- raise TypeError('hash not implemented')
+ __hash__ = None
return K
+
+_CacheInfo = namedtuple("CacheInfo", "hits misses maxsize currsize")
+
+def lru_cache(maxsize=100):
+ """Least-recently-used cache decorator.
+
+ If *maxsize* is set to None, the LRU features are disabled and the cache
+ can grow without bound.
+
+ Arguments to the cached function must be hashable.
+
+ View the cache statistics named tuple (hits, misses, maxsize, currsize) with
+ f.cache_info(). Clear the cache and statistics with f.cache_clear().
+ Access the underlying function with f.__wrapped__.
+
+ See: http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used
+
+ """
+ # Users should only access the lru_cache through its public API:
+ # cache_info, cache_clear, and f.__wrapped__
+ # The internals of the lru_cache are encapsulated for thread safety and
+ # to allow the implementation to change (including a possible C version).
+
+ def decorating_function(user_function,
+ tuple=tuple, sorted=sorted, len=len, KeyError=KeyError):
+
+ hits = misses = 0
+ kwd_mark = (object(),) # separates positional and keyword args
+ lock = Lock() # needed because OrderedDict isn't threadsafe
+
+ if maxsize is None:
+ cache = dict() # simple cache without ordering or size limit
+
+ @wraps(user_function)
+ def wrapper(*args, **kwds):
+ nonlocal hits, misses
+ key = args
+ if kwds:
+ key += kwd_mark + tuple(sorted(kwds.items()))
+ try:
+ result = cache[key]
+ hits += 1
+ return result
+ except KeyError:
+ pass
+ result = user_function(*args, **kwds)
+ cache[key] = result
+ misses += 1
+ return result
+ else:
+ cache = OrderedDict() # ordered least recent to most recent
+ cache_popitem = cache.popitem
+ cache_renew = cache.move_to_end
+
+ @wraps(user_function)
+ def wrapper(*args, **kwds):
+ nonlocal hits, misses
+ key = args
+ if kwds:
+ key += kwd_mark + tuple(sorted(kwds.items()))
+ with lock:
+ try:
+ result = cache[key]
+ cache_renew(key) # record recent use of this key
+ hits += 1
+ return result
+ except KeyError:
+ pass
+ result = user_function(*args, **kwds)
+ with lock:
+ cache[key] = result # record recent use of this key
+ misses += 1
+ if len(cache) > maxsize:
+ cache_popitem(0) # purge least recently used cache entry
+ return result
+
+ def cache_info():
+ """Report cache statistics"""
+ with lock:
+ return _CacheInfo(hits, misses, maxsize, len(cache))
+
+ def cache_clear():
+ """Clear the cache and cache statistics"""
+ nonlocal hits, misses
+ with lock:
+ cache.clear()
+ hits = misses = 0
+
+ wrapper.cache_info = cache_info
+ wrapper.cache_clear = cache_clear
+ return wrapper
+
+ return decorating_function
diff --git a/Lib/genericpath.py b/Lib/genericpath.py
index a0bf6013e93..2174187a03a 100644
--- a/Lib/genericpath.py
+++ b/Lib/genericpath.py
@@ -87,6 +87,7 @@ def _splitext(p, sep, altsep, extsep):
Extension is everything from the last dot to the end, ignoring
leading dots. Returns "(root, ext)"; ext may be empty."""
+ # NOTE: This code must work for text and bytes strings.
sepIndex = p.rfind(sep)
if altsep:
@@ -98,8 +99,8 @@ def _splitext(p, sep, altsep, extsep):
# skip all leading dots
filenameIndex = sepIndex + 1
while filenameIndex < dotIndex:
- if p[filenameIndex] != extsep:
+ if p[filenameIndex:filenameIndex+1] != extsep:
return p[:dotIndex], p[dotIndex:]
filenameIndex += 1
- return p, ''
+ return p, p[:0]
diff --git a/Lib/getopt.py b/Lib/getopt.py
index 251d89c5cfe..980861d2517 100644
--- a/Lib/getopt.py
+++ b/Lib/getopt.py
@@ -19,7 +19,7 @@ option involved with the exception.
# Gerrit Holl <gerrit@nl.linux.org> moved the string-based exceptions
# to class-based exceptions.
#
-# Peter Astrand <astrand@lysator.liu.se> added gnu_getopt().
+# Peter Åstrand <astrand@lysator.liu.se> added gnu_getopt().
#
# TODO for gnu_getopt():
#
@@ -207,4 +207,4 @@ def short_has_arg(opt, shortopts):
if __name__ == '__main__':
import sys
- print getopt(sys.argv[1:], "a:b", ["alpha=", "beta"])
+ print(getopt(sys.argv[1:], "a:b", ["alpha=", "beta"]))
diff --git a/Lib/getpass.py b/Lib/getpass.py
index 2ac6fd7f38a..dc02bd1eaec 100644
--- a/Lib/getpass.py
+++ b/Lib/getpass.py
@@ -47,7 +47,7 @@ def unix_getpass(prompt='Password: ', stream=None):
input = tty
if not stream:
stream = tty
- except EnvironmentError, e:
+ except EnvironmentError as e:
# If that fails, see if stdin can be controlled.
try:
fd = sys.stdin.fileno()
@@ -72,7 +72,7 @@ def unix_getpass(prompt='Password: ', stream=None):
finally:
termios.tcsetattr(fd, tcsetattr_flags, old)
stream.flush() # issue7208
- except termios.error, e:
+ except termios.error as e:
if passwd is not None:
# _raw_input succeeded. The final tcsetattr failed. Reraise
# instead of leaving the terminal in an unknown state.
@@ -92,10 +92,10 @@ def win_getpass(prompt='Password: ', stream=None):
return fallback_getpass(prompt, stream)
import msvcrt
for c in prompt:
- msvcrt.putch(c)
+ msvcrt.putwch(c)
pw = ""
while 1:
- c = msvcrt.getch()
+ c = msvcrt.getwch()
if c == '\r' or c == '\n':
break
if c == '\003':
@@ -104,8 +104,8 @@ def win_getpass(prompt='Password: ', stream=None):
pw = pw[:-1]
else:
pw = pw + c
- msvcrt.putch('\r')
- msvcrt.putch('\n')
+ msvcrt.putwch('\r')
+ msvcrt.putwch('\n')
return pw
@@ -114,13 +114,12 @@ def fallback_getpass(prompt='Password: ', stream=None):
stacklevel=2)
if not stream:
stream = sys.stderr
- print >>stream, "Warning: Password input may be echoed."
+ print("Warning: Password input may be echoed.", file=stream)
return _raw_input(prompt, stream)
def _raw_input(prompt="", stream=None, input=None):
- # A raw_input() replacement that doesn't save the string in the
- # GNU readline history.
+ # This doesn't save the string in the GNU readline history.
if not stream:
stream = sys.stderr
if not input:
@@ -167,12 +166,7 @@ except (ImportError, AttributeError):
try:
import msvcrt
except ImportError:
- try:
- from EasyDialogs import AskPassword
- except ImportError:
- getpass = fallback_getpass
- else:
- getpass = AskPassword
+ getpass = fallback_getpass
else:
getpass = win_getpass
else:
diff --git a/Lib/gettext.py b/Lib/gettext.py
index 3f4758034c5..256e331eba0 100644
--- a/Lib/gettext.py
+++ b/Lib/gettext.py
@@ -46,7 +46,7 @@ internationalized, to the local language and cultural habits.
# find this format documented anywhere.
-import locale, copy, os, re, struct, sys
+import locale, copy, io, os, re, struct, sys
from errno import ENOENT
@@ -58,39 +58,20 @@ __all__ = ['NullTranslations', 'GNUTranslations', 'Catalog',
_default_localedir = os.path.join(sys.prefix, 'share', 'locale')
-def test(condition, true, false):
- """
- Implements the C expression:
-
- condition ? true : false
-
- Required to correctly interpret plural forms.
- """
- if condition:
- return true
- else:
- return false
-
-
def c2py(plural):
"""Gets a C expression as used in PO files for plural forms and returns a
Python lambda function that implements an equivalent expression.
"""
# Security check, allow only the "n" identifier
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
import token, tokenize
- tokens = tokenize.generate_tokens(StringIO(plural).readline)
+ tokens = tokenize.generate_tokens(io.StringIO(plural).readline)
try:
danger = [x for x in tokens if x[0] == token.NAME and x[1] != 'n']
except tokenize.TokenError:
- raise ValueError, \
- 'plural forms expression error, maybe unbalanced parenthesis'
+ raise ValueError('plural forms expression error, maybe unbalanced parenthesis')
else:
if danger:
- raise ValueError, 'plural forms expression could be dangerous'
+ raise ValueError('plural forms expression could be dangerous')
# Replace some C operators by their Python equivalents
plural = plural.replace('&&', ' and ')
@@ -100,11 +81,11 @@ def c2py(plural):
plural = expr.sub(' not \\1', plural)
# Regular expression and replacement function used to transform
- # "a?b:c" to "test(a,b,c)".
+ # "a?b:c" to "b if a else c".
expr = re.compile(r'(.*?)\?(.*?):(.*)')
def repl(x):
- return "test(%s, %s, %s)" % (x.group(1), x.group(2),
- expr.sub(repl, x.group(3)))
+ return "(%s if %s else %s)" % (x.group(2), x.group(1),
+ expr.sub(repl, x.group(3)))
# Code to transform the plural expression, taking care of parentheses
stack = ['']
@@ -116,7 +97,7 @@ def c2py(plural):
# Actually, we never reach this code, because unbalanced
# parentheses get caught in the security check at the
# beginning.
- raise ValueError, 'unbalanced parenthesis in plural form'
+ raise ValueError('unbalanced parenthesis in plural form')
s = expr.sub(repl, stack.pop())
stack[-1] += '(%s)' % s
else:
@@ -127,36 +108,35 @@ def c2py(plural):
-def _expand_lang(locale):
- from locale import normalize
- locale = normalize(locale)
+def _expand_lang(loc):
+ loc = locale.normalize(loc)
COMPONENT_CODESET = 1 << 0
COMPONENT_TERRITORY = 1 << 1
COMPONENT_MODIFIER = 1 << 2
# split up the locale into its base components
mask = 0
- pos = locale.find('@')
+ pos = loc.find('@')
if pos >= 0:
- modifier = locale[pos:]
- locale = locale[:pos]
+ modifier = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_MODIFIER
else:
modifier = ''
- pos = locale.find('.')
+ pos = loc.find('.')
if pos >= 0:
- codeset = locale[pos:]
- locale = locale[:pos]
+ codeset = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_CODESET
else:
codeset = ''
- pos = locale.find('_')
+ pos = loc.find('_')
if pos >= 0:
- territory = locale[pos:]
- locale = locale[:pos]
+ territory = loc[pos:]
+ loc = loc[:pos]
mask |= COMPONENT_TERRITORY
else:
territory = ''
- language = locale
+ language = loc
ret = []
for i in range(mask+1):
if not (i & ~mask): # if all components for this combo exist ...
@@ -214,19 +194,6 @@ class NullTranslations:
else:
return msgid2
- def ugettext(self, message):
- if self._fallback:
- return self._fallback.ugettext(message)
- return unicode(message)
-
- def ungettext(self, msgid1, msgid2, n):
- if self._fallback:
- return self._fallback.ungettext(msgid1, msgid2, n)
- if n == 1:
- return unicode(msgid1)
- else:
- return unicode(msgid2)
-
def info(self):
return self._info
@@ -239,25 +206,24 @@ class NullTranslations:
def set_output_charset(self, charset):
self._output_charset = charset
- def install(self, unicode=False, names=None):
- import __builtin__
- __builtin__.__dict__['_'] = unicode and self.ugettext or self.gettext
+ def install(self, names=None):
+ import builtins
+ builtins.__dict__['_'] = self.gettext
if hasattr(names, "__contains__"):
if "gettext" in names:
- __builtin__.__dict__['gettext'] = __builtin__.__dict__['_']
+ builtins.__dict__['gettext'] = builtins.__dict__['_']
if "ngettext" in names:
- __builtin__.__dict__['ngettext'] = (unicode and self.ungettext
- or self.ngettext)
+ builtins.__dict__['ngettext'] = self.ngettext
if "lgettext" in names:
- __builtin__.__dict__['lgettext'] = self.lgettext
+ builtins.__dict__['lgettext'] = self.lgettext
if "lngettext" in names:
- __builtin__.__dict__['lngettext'] = self.lngettext
+ builtins.__dict__['lngettext'] = self.lngettext
class GNUTranslations(NullTranslations):
# Magic number of .mo files
- LE_MAGIC = 0x950412deL
- BE_MAGIC = 0xde120495L
+ LE_MAGIC = 0x950412de
+ BE_MAGIC = 0xde120495
def _parse(self, fp):
"""Override this method to support alternative .mo formats."""
@@ -281,7 +247,7 @@ class GNUTranslations(NullTranslations):
raise IOError(0, 'Bad magic number', filename)
# Now put all messages from the .mo file buffer into the catalog
# dictionary.
- for i in xrange(0, msgcount):
+ for i in range(0, msgcount):
mlen, moff = unpack(ii, buf[masteridx:masteridx+8])
mend = moff + mlen
tlen, toff = unpack(ii, buf[transidx:transidx+8])
@@ -295,8 +261,8 @@ class GNUTranslations(NullTranslations):
if mlen == 0:
# Catalog description
lastk = k = None
- for item in tmsg.splitlines():
- item = item.strip()
+ for b_item in tmsg.split('\n'.encode("ascii")):
+ item = b_item.decode().strip()
if not item:
continue
if ':' in item:
@@ -322,38 +288,20 @@ class GNUTranslations(NullTranslations):
# cause no problems since us-ascii should always be a subset of
# the charset encoding. We may want to fall back to 8-bit msgids
# if the Unicode conversion fails.
- if '\x00' in msg:
+ charset = self._charset or 'ascii'
+ if b'\x00' in msg:
# Plural forms
- msgid1, msgid2 = msg.split('\x00')
- tmsg = tmsg.split('\x00')
- if self._charset:
- msgid1 = unicode(msgid1, self._charset)
- tmsg = [unicode(x, self._charset) for x in tmsg]
- for i in range(len(tmsg)):
- catalog[(msgid1, i)] = tmsg[i]
+ msgid1, msgid2 = msg.split(b'\x00')
+ tmsg = tmsg.split(b'\x00')
+ msgid1 = str(msgid1, charset)
+ for i, x in enumerate(tmsg):
+ catalog[(msgid1, i)] = str(x, charset)
else:
- if self._charset:
- msg = unicode(msg, self._charset)
- tmsg = unicode(tmsg, self._charset)
- catalog[msg] = tmsg
+ catalog[str(msg, charset)] = str(tmsg, charset)
# advance to next entry in the seek tables
masteridx += 8
transidx += 8
- def gettext(self, message):
- missing = object()
- tmsg = self._catalog.get(message, missing)
- if tmsg is missing:
- if self._fallback:
- return self._fallback.gettext(message)
- return message
- # Encode the Unicode tmsg back to an 8-bit string, if possible
- if self._output_charset:
- return tmsg.encode(self._output_charset)
- elif self._charset:
- return tmsg.encode(self._charset)
- return tmsg
-
def lgettext(self, message):
missing = object()
tmsg = self._catalog.get(message, missing)
@@ -365,22 +313,6 @@ class GNUTranslations(NullTranslations):
return tmsg.encode(self._output_charset)
return tmsg.encode(locale.getpreferredencoding())
- def ngettext(self, msgid1, msgid2, n):
- try:
- tmsg = self._catalog[(msgid1, self.plural(n))]
- if self._output_charset:
- return tmsg.encode(self._output_charset)
- elif self._charset:
- return tmsg.encode(self._charset)
- return tmsg
- except KeyError:
- if self._fallback:
- return self._fallback.ngettext(msgid1, msgid2, n)
- if n == 1:
- return msgid1
- else:
- return msgid2
-
def lngettext(self, msgid1, msgid2, n):
try:
tmsg = self._catalog[(msgid1, self.plural(n))]
@@ -395,30 +327,30 @@ class GNUTranslations(NullTranslations):
else:
return msgid2
- def ugettext(self, message):
+ def gettext(self, message):
missing = object()
tmsg = self._catalog.get(message, missing)
if tmsg is missing:
if self._fallback:
- return self._fallback.ugettext(message)
- return unicode(message)
+ return self._fallback.gettext(message)
+ return message
return tmsg
- def ungettext(self, msgid1, msgid2, n):
+ def ngettext(self, msgid1, msgid2, n):
try:
tmsg = self._catalog[(msgid1, self.plural(n))]
except KeyError:
if self._fallback:
- return self._fallback.ungettext(msgid1, msgid2, n)
+ return self._fallback.ngettext(msgid1, msgid2, n)
if n == 1:
- tmsg = unicode(msgid1)
+ tmsg = msgid1
else:
- tmsg = unicode(msgid2)
+ tmsg = msgid2
return tmsg
# Locate a .mo file using the gettext strategy
-def find(domain, localedir=None, languages=None, all=0):
+def find(domain, localedir=None, languages=None, all=False):
# Get some reasonable defaults for arguments that were not supplied
if localedir is None:
localedir = _default_localedir
@@ -462,7 +394,7 @@ def translation(domain, localedir=None, languages=None,
class_=None, fallback=False, codeset=None):
if class_ is None:
class_ = GNUTranslations
- mofiles = find(domain, localedir, languages, all=1)
+ mofiles = find(domain, localedir, languages, all=True)
if not mofiles:
if fallback:
return NullTranslations()
@@ -489,9 +421,9 @@ def translation(domain, localedir=None, languages=None,
return result
-def install(domain, localedir=None, unicode=False, codeset=None, names=None):
+def install(domain, localedir=None, codeset=None, names=None):
t = translation(domain, localedir, fallback=True, codeset=codeset)
- t.install(unicode, names)
+ t.install(names)
diff --git a/Lib/glob.py b/Lib/glob.py
index 0aee60561fa..f16e8e16e42 100644
--- a/Lib/glob.py
+++ b/Lib/glob.py
@@ -1,18 +1,9 @@
"""Filename globbing utility."""
-import sys
import os
import re
import fnmatch
-try:
- _unicode = unicode
-except NameError:
- # If Python is built without Unicode support, the unicode type
- # will not exist. Fake one.
- class _unicode(object):
- pass
-
__all__ = ["glob", "iglob"]
def glob(pathname):
@@ -35,7 +26,7 @@ def iglob(pathname):
return
dirname, basename = os.path.split(pathname)
if not dirname:
- for name in glob1(os.curdir, basename):
+ for name in glob1(None, basename):
yield name
return
# `os.path.split()` returns the argument itself as a dirname if it is a
@@ -59,20 +50,20 @@ def iglob(pathname):
def glob1(dirname, pattern):
if not dirname:
- dirname = os.curdir
- if isinstance(pattern, _unicode) and not isinstance(dirname, unicode):
- dirname = unicode(dirname, sys.getfilesystemencoding() or
- sys.getdefaultencoding())
+ if isinstance(pattern, bytes):
+ dirname = bytes(os.curdir, 'ASCII')
+ else:
+ dirname = os.curdir
try:
names = os.listdir(dirname)
except os.error:
return []
- if pattern[0] != '.':
- names = filter(lambda x: x[0] != '.', names)
+ if not _ishidden(pattern):
+ names = [x for x in names if not _ishidden(x)]
return fnmatch.filter(names, pattern)
def glob0(dirname, basename):
- if basename == '':
+ if not basename:
# `os.path.split()` returns an empty basename for paths ending with a
# directory separator. 'q*x/' should match only directories.
if os.path.isdir(dirname):
@@ -84,6 +75,14 @@ def glob0(dirname, basename):
magic_check = re.compile('[*?[]')
+magic_check_bytes = re.compile(b'[*?[]')
def has_magic(s):
- return magic_check.search(s) is not None
+ if isinstance(s, bytes):
+ match = magic_check_bytes.search(s)
+ else:
+ match = magic_check.search(s)
+ return match is not None
+
+def _ishidden(path):
+ return path[0] in ('.', b'.'[0])
diff --git a/Lib/gzip.py b/Lib/gzip.py
index a613bae876d..403040bd9c4 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -7,15 +7,27 @@ but random access is not allowed."""
import struct, sys, time, os
import zlib
+import builtins
import io
-import __builtin__
-__all__ = ["GzipFile","open"]
+__all__ = ["GzipFile", "open", "compress", "decompress"]
FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16
READ, WRITE = 1, 2
+def U32(i):
+ """Return i as an unsigned integer, assuming it fits in 32 bits.
+ If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
+ """
+ if i < 0:
+ i += 1 << 32
+ return i
+
+def LOWU32(i):
+ """Return the low-order 32 bits, as a non-negative int"""
+ return i & 0xFFFFFFFF
+
def write32u(output, value):
# The L format writes the bit pattern correctly whether signed
# or unsigned.
@@ -33,10 +45,69 @@ def open(filename, mode="rb", compresslevel=9):
"""
return GzipFile(filename, mode, compresslevel)
+class _PaddedFile:
+ """Minimal read-only file object that prepends a string to the contents
+ of an actual file. Shouldn't be used outside of gzip.py, as it lacks
+ essential functionality."""
+
+ def __init__(self, f, prepend=b''):
+ self._buffer = prepend
+ self._length = len(prepend)
+ self.file = f
+ self._read = 0
+
+ def read(self, size):
+ if self._read is None:
+ return self.file.read(size)
+ if self._read + size <= self._length:
+ read = self._read
+ self._read += size
+ return self._buffer[read:self._read]
+ else:
+ read = self._read
+ self._read = None
+ return self._buffer[read:] + \
+ self.file.read(size-self._length+read)
+
+ def prepend(self, prepend=b'', readprevious=False):
+ if self._read is None:
+ self._buffer = prepend
+ elif readprevious and len(prepend) <= self._read:
+ self._read -= len(prepend)
+ return
+ else:
+ self._buffer = self._buffer[read:] + prepend
+ self._length = len(self._buffer)
+ self._read = 0
+
+ def unused(self):
+ if self._read is None:
+ return b''
+ return self._buffer[self._read:]
+
+ def seek(self, offset, whence=0):
+ # This is only ever called with offset=whence=0
+ if whence == 1 and self._read is not None:
+ if 0 <= offset + self._read <= self._length:
+ self._read += offset
+ return
+ else:
+ offset += self._length - self._read
+ self._read = None
+ self._buffer = None
+ return self.file.seek(offset, whence)
+
+ def __getattr__(self, name):
+ return getattr(self.file, name)
+
+
class GzipFile(io.BufferedIOBase):
"""The GzipFile class simulates most of the methods of a file object with
the exception of the readinto() and truncate() methods.
+ This class only supports opening files in binary mode. If you need to open a
+ compressed file in text mode, wrap your GzipFile with an io.TextIOWrapper.
+
"""
myfileobj = None
@@ -63,8 +134,8 @@ class GzipFile(io.BufferedIOBase):
The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', or 'wb',
depending on whether the file will be read or written. The default
is the mode of fileobj if discernible; otherwise, the default is 'rb'.
- Be aware that only the 'rb', 'ab', and 'wb' values should be used
- for cross-platform portability.
+ A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
+ 'wb', and 'a' and 'ab'.
The compresslevel argument is an integer from 0 to 9 controlling the
level of compression; 1 is fastest and produces the least compression,
@@ -82,22 +153,15 @@ class GzipFile(io.BufferedIOBase):
"""
- # Make sure we don't inadvertently enable universal newlines on the
- # underlying file object - in read mode, this causes data corruption.
- if mode:
- mode = mode.replace('U', '')
- # guarantee the file is opened in binary mode on platforms
- # that care about that sort of thing
+ if mode and ('t' in mode or 'U' in mode):
+ raise IOError("Mode " + mode + " not supported")
if mode and 'b' not in mode:
mode += 'b'
if fileobj is None:
- fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb')
+ fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')
if filename is None:
- # Issue #13781: os.fdopen() creates a fileobj with a bogus name
- # attribute. Avoid saving this in the gzip header's filename field.
- if hasattr(fileobj, 'name') and fileobj.name != '<fdopen>':
- filename = fileobj.name
- else:
+ filename = getattr(fileobj, 'name', '')
+ if not isinstance(filename, (str, bytes)):
filename = ''
if mode is None:
if hasattr(fileobj, 'mode'): mode = fileobj.mode
@@ -110,12 +174,13 @@ class GzipFile(io.BufferedIOBase):
# Buffer data read from gzip file. extrastart is offset in
# stream where buffer starts. extrasize is number of
# bytes remaining in buffer from current stream position.
- self.extrabuf = ""
+ self.extrabuf = b""
self.extrasize = 0
self.extrastart = 0
self.name = filename
# Starts small, scales exponentially
self.min_readsize = 100
+ fileobj = _PaddedFile(fileobj)
elif mode[0:1] == 'w' or mode[0:1] == 'a':
self.mode = WRITE
@@ -126,7 +191,7 @@ class GzipFile(io.BufferedIOBase):
zlib.DEF_MEM_LEVEL,
0)
else:
- raise IOError, "Mode " + mode + " not supported"
+ raise IOError("Mode " + mode + " not supported")
self.fileobj = fileobj
self.offset = 0
@@ -144,7 +209,10 @@ class GzipFile(io.BufferedIOBase):
return self.name
def __repr__(self):
- s = repr(self.fileobj)
+ fileobj = self.fileobj
+ if isinstance(fileobj, _PaddedFile):
+ fileobj = fileobj.file
+ s = repr(fileobj)
return '<gzip ' + s[1:-1] + ' ' + hex(id(self)) + '>'
def _check_closed(self):
@@ -156,41 +224,51 @@ class GzipFile(io.BufferedIOBase):
def _init_write(self, filename):
self.name = filename
- self.crc = zlib.crc32("") & 0xffffffffL
+ self.crc = zlib.crc32(b"") & 0xffffffff
self.size = 0
self.writebuf = []
self.bufsize = 0
def _write_gzip_header(self):
- self.fileobj.write('\037\213') # magic header
- self.fileobj.write('\010') # compression method
- fname = os.path.basename(self.name)
- if fname.endswith(".gz"):
- fname = fname[:-3]
+ self.fileobj.write(b'\037\213') # magic header
+ self.fileobj.write(b'\010') # compression method
+ try:
+ # RFC 1952 requires the FNAME field to be Latin-1. Do not
+ # include filenames that cannot be represented that way.
+ fname = os.path.basename(self.name)
+ if not isinstance(fname, bytes):
+ fname = fname.encode('latin-1')
+ if fname.endswith(b'.gz'):
+ fname = fname[:-3]
+ except UnicodeEncodeError:
+ fname = b''
flags = 0
if fname:
flags = FNAME
- self.fileobj.write(chr(flags))
+ self.fileobj.write(chr(flags).encode('latin-1'))
mtime = self.mtime
if mtime is None:
mtime = time.time()
- write32u(self.fileobj, long(mtime))
- self.fileobj.write('\002')
- self.fileobj.write('\377')
+ write32u(self.fileobj, int(mtime))
+ self.fileobj.write(b'\002')
+ self.fileobj.write(b'\377')
if fname:
- self.fileobj.write(fname + '\000')
+ self.fileobj.write(fname + b'\000')
def _init_read(self):
- self.crc = zlib.crc32("") & 0xffffffffL
+ self.crc = zlib.crc32(b"") & 0xffffffff
self.size = 0
def _read_gzip_header(self):
magic = self.fileobj.read(2)
- if magic != '\037\213':
- raise IOError, 'Not a gzipped file'
+ if magic == b'':
+ raise EOFError("Reached EOF")
+
+ if magic != b'\037\213':
+ raise IOError('Not a gzipped file')
method = ord( self.fileobj.read(1) )
if method != 8:
- raise IOError, 'Unknown compression method'
+ raise IOError('Unknown compression method')
flag = ord( self.fileobj.read(1) )
self.mtime = read32(self.fileobj)
# extraflag = self.fileobj.read(1)
@@ -206,17 +284,22 @@ class GzipFile(io.BufferedIOBase):
# Read and discard a null-terminated string containing the filename
while True:
s = self.fileobj.read(1)
- if not s or s=='\000':
+ if not s or s==b'\000':
break
if flag & FCOMMENT:
# Read and discard a null-terminated string containing a comment
while True:
s = self.fileobj.read(1)
- if not s or s=='\000':
+ if not s or s==b'\000':
break
if flag & FHCRC:
self.fileobj.read(2) # Read & discard the 16-bit header CRC
+ unused = self.fileobj.unused()
+ if unused:
+ uncompress = self.decompress.decompress(unused)
+ self._add_read_data(uncompress)
+
def write(self,data):
self._check_closed()
if self.mode != WRITE:
@@ -224,7 +307,7 @@ class GzipFile(io.BufferedIOBase):
raise IOError(errno.EBADF, "write() on read-only GzipFile object")
if self.fileobj is None:
- raise ValueError, "write() on closed GzipFile object"
+ raise ValueError("write() on closed GzipFile object")
# Convert data type if called by io.BufferedWriter.
if isinstance(data, memoryview):
@@ -232,7 +315,7 @@ class GzipFile(io.BufferedIOBase):
if len(data) > 0:
self.size = self.size + len(data)
- self.crc = zlib.crc32(data, self.crc) & 0xffffffffL
+ self.crc = zlib.crc32(data, self.crc) & 0xffffffff
self.fileobj.write( self.compress.compress(data) )
self.offset += len(data)
@@ -245,7 +328,7 @@ class GzipFile(io.BufferedIOBase):
raise IOError(errno.EBADF, "read() on write-only GzipFile object")
if self.extrasize <= 0 and self.fileobj is None:
- return ''
+ return b''
readsize = 1024
if size < 0: # get the whole thing
@@ -271,27 +354,39 @@ class GzipFile(io.BufferedIOBase):
self.offset += size
return chunk
+ def peek(self, n):
+ if self.mode != READ:
+ import errno
+ raise IOError(errno.EBADF, "peek() on write-only GzipFile object")
+
+ # Do not return ridiculously small buffers, for one common idiom
+ # is to call peek(1) and expect more bytes in return.
+ if n < 100:
+ n = 100
+ if self.extrasize == 0:
+ if self.fileobj is None:
+ return b''
+ try:
+ # 1024 is the same buffering heuristic used in read()
+ self._read(max(n, 1024))
+ except EOFError:
+ pass
+ offset = self.offset - self.extrastart
+ remaining = self.extrasize
+ assert remaining == len(self.extrabuf) - offset
+ return self.extrabuf[offset:offset + n]
+
def _unread(self, buf):
self.extrasize = len(buf) + self.extrasize
self.offset -= len(buf)
def _read(self, size=1024):
if self.fileobj is None:
- raise EOFError, "Reached EOF"
+ raise EOFError("Reached EOF")
if self._new_member:
# If the _new_member flag is set, we have to
# jump to the next member, if there is one.
- #
- # First, check if we're at the end of the file;
- # if so, it's time to stop; no more members to read.
- pos = self.fileobj.tell() # Save current position
- self.fileobj.seek(0, 2) # Seek to end of file
- if pos == self.fileobj.tell():
- raise EOFError, "Reached EOF"
- else:
- self.fileobj.seek( pos ) # Return to original position
-
self._init_read()
self._read_gzip_header()
self.decompress = zlib.decompressobj(-zlib.MAX_WBITS)
@@ -303,30 +398,32 @@ class GzipFile(io.BufferedIOBase):
# If the EOF has been reached, flush the decompression object
# and mark this object as finished.
- if buf == "":
+ if buf == b"":
uncompress = self.decompress.flush()
+ # Prepend the already read bytes to the fileobj to they can be
+ # seen by _read_eof()
+ self.fileobj.prepend(self.decompress.unused_data, True)
self._read_eof()
self._add_read_data( uncompress )
- raise EOFError, 'Reached EOF'
+ raise EOFError('Reached EOF')
uncompress = self.decompress.decompress(buf)
self._add_read_data( uncompress )
- if self.decompress.unused_data != "":
+ if self.decompress.unused_data != b"":
# Ending case: we've come to the end of a member in the file,
# so seek back to the start of the unused data, finish up
# this member, and read a new gzip header.
- # (The number of bytes to seek back is the length of the unused
- # data, minus 8 because _read_eof() will rewind a further 8 bytes)
- self.fileobj.seek( -len(self.decompress.unused_data)+8, 1)
-
+ # Prepend the already read bytes to the fileobj to they can be
+ # seen by _read_eof() and _read_gzip_header()
+ self.fileobj.prepend(self.decompress.unused_data, True)
# Check the CRC and file size, and set the flag so we read
# a new member on the next call
self._read_eof()
self._new_member = True
def _add_read_data(self, data):
- self.crc = zlib.crc32(data, self.crc) & 0xffffffffL
+ self.crc = zlib.crc32(data, self.crc) & 0xffffffff
offset = self.offset - self.extrastart
self.extrabuf = self.extrabuf[offset:] + data
self.extrasize = self.extrasize + len(data)
@@ -334,28 +431,26 @@ class GzipFile(io.BufferedIOBase):
self.size = self.size + len(data)
def _read_eof(self):
- # We've read to the end of the file, so we have to rewind in order
- # to reread the 8 bytes containing the CRC and the file size.
+ # We've read to the end of the file
# We check the that the computed CRC and size of the
# uncompressed data matches the stored values. Note that the size
# stored is the true file size mod 2**32.
- self.fileobj.seek(-8, 1)
crc32 = read32(self.fileobj)
isize = read32(self.fileobj) # may exceed 2GB
if crc32 != self.crc:
raise IOError("CRC check failed %s != %s" % (hex(crc32),
hex(self.crc)))
- elif isize != (self.size & 0xffffffffL):
- raise IOError, "Incorrect length of data produced"
+ elif isize != (self.size & 0xffffffff):
+ raise IOError("Incorrect length of data produced")
# Gzip files can be padded with zeroes and still have archives.
# Consume all zero bytes and set the file position to the first
# non-zero byte. See http://www.gzip.org/#faq8
- c = "\x00"
- while c == "\x00":
+ c = b"\x00"
+ while c == b"\x00":
c = self.fileobj.read(1)
if c:
- self.fileobj.seek(-1, 1)
+ self.fileobj.prepend(c, True)
@property
def closed(self):
@@ -368,7 +463,7 @@ class GzipFile(io.BufferedIOBase):
self.fileobj.write(self.compress.flush())
write32u(self.fileobj, self.crc)
# self.size may exceed 2GB, or even 4GB
- write32u(self.fileobj, self.size & 0xffffffffL)
+ write32u(self.fileobj, self.size & 0xffffffff)
self.fileobj = None
elif self.mode == READ:
self.fileobj = None
@@ -398,7 +493,7 @@ class GzipFile(io.BufferedIOBase):
raise IOError("Can't rewind in write mode")
self.fileobj.seek(0)
self._new_member = True
- self.extrabuf = ""
+ self.extrabuf = b""
self.extrasize = 0
self.extrastart = 0
self.offset = 0
@@ -422,15 +517,16 @@ class GzipFile(io.BufferedIOBase):
if offset < self.offset:
raise IOError('Negative seek in write mode')
count = offset - self.offset
- for i in xrange(count // 1024):
- self.write(1024 * '\0')
- self.write((count % 1024) * '\0')
+ chunk = bytes(1024)
+ for i in range(count // 1024):
+ self.write(chunk)
+ self.write(bytes(count % 1024))
elif self.mode == READ:
if offset < self.offset:
# for negative seek, rewind and do positive seek
self.rewind()
count = offset - self.offset
- for i in xrange(count // 1024):
+ for i in range(count // 1024):
self.read(1024)
self.read(count % 1024)
@@ -440,20 +536,20 @@ class GzipFile(io.BufferedIOBase):
if size < 0:
# Shortcut common case - newline found in buffer.
offset = self.offset - self.extrastart
- i = self.extrabuf.find('\n', offset) + 1
+ i = self.extrabuf.find(b'\n', offset) + 1
if i > 0:
self.extrasize -= i - offset
self.offset += i - offset
return self.extrabuf[offset: i]
- size = sys.maxint
+ size = sys.maxsize
readsize = self.min_readsize
else:
readsize = size
bufs = []
while size != 0:
c = self.read(readsize)
- i = c.find('\n')
+ i = c.find(b'\n')
# We set i=size to break out of the loop under two
# conditions: 1) there's no newline, and the chunk is
@@ -462,7 +558,7 @@ class GzipFile(io.BufferedIOBase):
if (size <= i) or (i == -1 and len(c) > size):
i = size - 1
- if i >= 0 or c == '':
+ if i >= 0 or c == b'':
bufs.append(c[:i + 1]) # Add portion of last chunk
self._unread(c[i + 1:]) # Push back rest of chunk
break
@@ -473,7 +569,24 @@ class GzipFile(io.BufferedIOBase):
readsize = min(size, readsize * 2)
if readsize > self.min_readsize:
self.min_readsize = min(readsize, self.min_readsize * 2, 512)
- return ''.join(bufs) # Return resulting line
+ return b''.join(bufs) # Return resulting line
+
+
+def compress(data, compresslevel=9):
+ """Compress data in one shot and return the compressed string.
+ Optional argument is the compression level, in range of 0-9.
+ """
+ buf = io.BytesIO()
+ with GzipFile(fileobj=buf, mode='wb', compresslevel=compresslevel) as f:
+ f.write(data)
+ return buf.getvalue()
+
+def decompress(data):
+ """Decompress a gzip compressed string in one shot.
+ Return the decompressed string.
+ """
+ with GzipFile(fileobj=io.BytesIO(data)) as f:
+ return f.read()
def _test():
@@ -489,29 +602,29 @@ def _test():
for arg in args:
if decompress:
if arg == "-":
- f = GzipFile(filename="", mode="rb", fileobj=sys.stdin)
- g = sys.stdout
+ f = GzipFile(filename="", mode="rb", fileobj=sys.stdin.buffer)
+ g = sys.stdout.buffer
else:
if arg[-3:] != ".gz":
- print "filename doesn't end in .gz:", repr(arg)
+ print("filename doesn't end in .gz:", repr(arg))
continue
f = open(arg, "rb")
- g = __builtin__.open(arg[:-3], "wb")
+ g = builtins.open(arg[:-3], "wb")
else:
if arg == "-":
- f = sys.stdin
- g = GzipFile(filename="", mode="wb", fileobj=sys.stdout)
+ f = sys.stdin.buffer
+ g = GzipFile(filename="", mode="wb", fileobj=sys.stdout.buffer)
else:
- f = __builtin__.open(arg, "rb")
+ f = builtins.open(arg, "rb")
g = open(arg + ".gz", "wb")
while True:
chunk = f.read(1024)
if not chunk:
break
g.write(chunk)
- if g is not sys.stdout:
+ if g is not sys.stdout.buffer:
g.close()
- if f is not sys.stdin:
+ if f is not sys.stdin.buffer:
f.close()
if __name__ == '__main__':
diff --git a/Lib/hashlib.py b/Lib/hashlib.py
index d20e1f95a2a..21454c7d306 100644
--- a/Lib/hashlib.py
+++ b/Lib/hashlib.py
@@ -1,22 +1,21 @@
-# $Id$
-#
-# Copyright (C) 2005 Gregory P. Smith (greg@krypto.org)
+# Copyright (C) 2005-2010 Gregory P. Smith (greg@krypto.org)
# Licensed to PSF under a Contributor Agreement.
#
__doc__ = """hashlib module - A common interface to many hash functions.
-new(name, string='') - returns a new hash object implementing the
- given hash function; initializing the hash
- using the given string data.
+new(name, data=b'') - returns a new hash object implementing the
+ given hash function; initializing the hash
+ using the given binary data.
-Named constructor functions are also available, these are much faster
-than using new():
+Named constructor functions are also available, these are faster
+than using new(name):
md5(), sha1(), sha224(), sha256(), sha384(), and sha512()
-More algorithms may be available on your platform but the above are
-guaranteed to exist.
+More algorithms may be available on your platform but the above are guaranteed
+to exist. See the algorithms_guaranteed and algorithms_available attributes
+to find out what algorithm names can be passed to new().
NOTE: If you want the adler32 or crc32 hash functions they are available in
the zlib module.
@@ -25,14 +24,13 @@ Choose your hash function wisely. Some have known collision weaknesses.
sha384 and sha512 will be slow on 32 bit platforms.
Hash objects have these methods:
- - update(arg): Update the hash object with the string arg. Repeated calls
+ - update(arg): Update the hash object with the bytes in arg. Repeated calls
are equivalent to a single call with the concatenation of all
the arguments.
- - digest(): Return the digest of the strings passed to the update() method
- so far. This may contain non-ASCII characters, including
- NUL bytes.
- - hexdigest(): Like digest() except the digest is returned as a string of
- double length, containing only hexadecimal digits.
+ - digest(): Return the digest of the bytes passed to the update() method
+ so far.
+ - hexdigest(): Like digest() except the digest is returned as a unicode
+ object of double length, containing only hexadecimal digits.
- copy(): Return a copy (clone) of the hash object. This can be used to
efficiently compute the digests of strings that share a common
initial substring.
@@ -42,14 +40,14 @@ spammish repetition':
>>> import hashlib
>>> m = hashlib.md5()
- >>> m.update("Nobody inspects")
- >>> m.update(" the spammish repetition")
+ >>> m.update(b"Nobody inspects")
+ >>> m.update(b" the spammish repetition")
>>> m.digest()
- '\\xbbd\\x9c\\x83\\xdd\\x1e\\xa5\\xc9\\xd9\\xde\\xc9\\xa1\\x8d\\xf0\\xff\\xe9'
+ b'\\xbbd\\x9c\\x83\\xdd\\x1e\\xa5\\xc9\\xd9\\xde\\xc9\\xa1\\x8d\\xf0\\xff\\xe9'
More condensed:
- >>> hashlib.sha224("Nobody inspects the spammish repetition").hexdigest()
+ >>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()
'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
"""
@@ -58,19 +56,21 @@ More condensed:
# always available algorithm is added.
__always_supported = ('md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512')
-algorithms = __always_supported
+algorithms_guaranteed = set(__always_supported)
+algorithms_available = set(__always_supported)
-__all__ = __always_supported + ('new', 'algorithms')
+__all__ = __always_supported + ('new', 'algorithms_guaranteed',
+ 'algorithms_available')
def __get_builtin_constructor(name):
try:
if name in ('SHA1', 'sha1'):
- import _sha
- return _sha.new
+ import _sha1
+ return _sha1.sha1
elif name in ('MD5', 'md5'):
import _md5
- return _md5.new
+ return _md5.md5
elif name in ('SHA256', 'sha256', 'SHA224', 'sha224'):
import _sha256
bs = name[3:]
@@ -103,31 +103,33 @@ def __get_openssl_constructor(name):
return __get_builtin_constructor(name)
-def __py_new(name, string=''):
- """new(name, string='') - Return a new hashing object using the named algorithm;
- optionally initialized with a string.
+def __py_new(name, data=b''):
+ """new(name, data=b'') - Return a new hashing object using the named algorithm;
+ optionally initialized with data (which must be bytes).
"""
- return __get_builtin_constructor(name)(string)
+ return __get_builtin_constructor(name)(data)
-def __hash_new(name, string=''):
- """new(name, string='') - Return a new hashing object using the named algorithm;
- optionally initialized with a string.
+def __hash_new(name, data=b''):
+ """new(name, data=b'') - Return a new hashing object using the named algorithm;
+ optionally initialized with data (which must be bytes).
"""
try:
- return _hashlib.new(name, string)
+ return _hashlib.new(name, data)
except ValueError:
# If the _hashlib module (OpenSSL) doesn't support the named
# hash, try using our builtin implementations.
# This allows for SHA224/256 and SHA384/512 support even though
# the OpenSSL library prior to 0.9.8 doesn't provide them.
- return __get_builtin_constructor(name)(string)
+ return __get_builtin_constructor(name)(data)
try:
import _hashlib
new = __hash_new
__get_hash = __get_openssl_constructor
+ algorithms_available = algorithms_available.union(
+ _hashlib.openssl_md_meth_names)
except ImportError:
new = __py_new
__get_hash = __get_builtin_constructor
diff --git a/Lib/heapq.py b/Lib/heapq.py
index 6a4e0f4c31c..dec15aec9ce 100644
--- a/Lib/heapq.py
+++ b/Lib/heapq.py
@@ -1,5 +1,3 @@
-# -*- coding: latin-1 -*-
-
"""Heap queue algorithm (a.k.a. priority queue).
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
@@ -34,7 +32,7 @@ maintains the heap invariant!
__about__ = """Heap queues
-[explanation by François Pinard]
+[explanation by François Pinard]
Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for
all k, counting elements from 0. For the sake of comparison,
@@ -129,15 +127,9 @@ From all times, sorting has always been a Great Art! :-)
__all__ = ['heappush', 'heappop', 'heapify', 'heapreplace', 'merge',
'nlargest', 'nsmallest', 'heappushpop']
-from itertools import islice, repeat, count, imap, izip, tee, chain
-from operator import itemgetter
+from itertools import islice, repeat, count, tee, chain
import bisect
-def cmp_lt(x, y):
- # Use __lt__ if available; otherwise, try __le__.
- # In Py3.x, only __lt__ will be called.
- return (x < y) if hasattr(x, '__lt__') else (not y <= x)
-
def heappush(heap, item):
"""Push item onto heap, maintaining the heap invariant."""
heap.append(item)
@@ -172,7 +164,7 @@ def heapreplace(heap, item):
def heappushpop(heap, item):
"""Fast version of a heappush followed by a heappop."""
- if heap and cmp_lt(heap[0], item):
+ if heap and heap[0] < item:
item, heap[0] = heap[0], item
_siftup(heap, 0)
return item
@@ -185,7 +177,7 @@ def heapify(x):
# or i < (n-1)/2. If n is even = 2*j, this is (2*j-1)/2 = j-1/2 so
# j-1 is the largest, which is n//2 - 1. If n is odd = 2*j+1, this is
# (2*j+1-1)/2 = j so j-1 is the largest, and that's again n//2-1.
- for i in reversed(xrange(n//2)):
+ for i in reversed(range(n//2)):
_siftup(x, i)
def nlargest(n, iterable):
@@ -224,7 +216,7 @@ def nsmallest(n, iterable):
pop = result.pop
los = result[-1] # los --> Largest of the nsmallest
for elem in it:
- if cmp_lt(elem, los):
+ if elem < los:
insort(result, elem)
pop()
los = result[-1]
@@ -236,7 +228,7 @@ def nsmallest(n, iterable):
# O(m) + O(n log m) comparisons.
h = list(iterable)
heapify(h)
- return map(heappop, repeat(h, min(n, len(h))))
+ return list(map(heappop, repeat(h, min(n, len(h)))))
# 'heap' is a heap at all indices >= startpos, except possibly for pos. pos
# is the index of a leaf with a possibly out-of-order value. Restore the
@@ -248,7 +240,7 @@ def _siftdown(heap, startpos, pos):
while pos > startpos:
parentpos = (pos - 1) >> 1
parent = heap[parentpos]
- if cmp_lt(newitem, parent):
+ if newitem < parent:
heap[pos] = parent
pos = parentpos
continue
@@ -270,7 +262,7 @@ def _siftdown(heap, startpos, pos):
#
# Cutting the # of comparisons is important, since these routines have no
# way to extract "the priority" from an array element, so that intelligence
-# is likely to be hiding in custom __cmp__ methods, or in array elements
+# is likely to be hiding in custom comparison methods, or in array elements
# storing (priority, record) tuples. Comparisons are thus potentially
# expensive.
#
@@ -303,7 +295,7 @@ def _siftup(heap, pos):
while childpos < endpos:
# Set childpos to index of smaller child.
rightpos = childpos + 1
- if rightpos < endpos and not cmp_lt(heap[childpos], heap[rightpos]):
+ if rightpos < endpos and not heap[childpos] < heap[rightpos]:
childpos = rightpos
# Move the smaller child up.
heap[pos] = heap[childpos]
@@ -337,7 +329,7 @@ def merge(*iterables):
h_append = h.append
for itnum, it in enumerate(map(iter, iterables)):
try:
- next = it.next
+ next = it.__next__
h_append([next(), itnum, next])
except _StopIteration:
pass
@@ -383,15 +375,15 @@ def nsmallest(n, iterable, key=None):
# When key is none, use simpler decoration
if key is None:
- it = izip(iterable, count()) # decorate
+ it = zip(iterable, count()) # decorate
result = _nsmallest(n, it)
- return map(itemgetter(0), result) # undecorate
+ return [r[0] for r in result] # undecorate
# General case, slowest method
in1, in2 = tee(iterable)
- it = izip(imap(key, in1), count(), in2) # decorate
+ it = zip(map(key, in1), count(), in2) # decorate
result = _nsmallest(n, it)
- return map(itemgetter(2), result) # undecorate
+ return [r[2] for r in result] # undecorate
_nlargest = nlargest
def nlargest(n, iterable, key=None):
@@ -421,15 +413,15 @@ def nlargest(n, iterable, key=None):
# When key is none, use simpler decoration
if key is None:
- it = izip(iterable, count(0,-1)) # decorate
+ it = zip(iterable, count(0,-1)) # decorate
result = _nlargest(n, it)
- return map(itemgetter(0), result) # undecorate
+ return [r[0] for r in result] # undecorate
# General case, slowest method
in1, in2 = tee(iterable)
- it = izip(imap(key, in1), count(0,-1), in2) # decorate
+ it = zip(map(key, in1), count(0,-1), in2) # decorate
result = _nlargest(n, it)
- return map(itemgetter(2), result) # undecorate
+ return [r[2] for r in result] # undecorate
if __name__ == "__main__":
# Simple sanity test
@@ -440,7 +432,7 @@ if __name__ == "__main__":
sort = []
while heap:
sort.append(heappop(heap))
- print sort
+ print(sort)
import doctest
doctest.testmod()
diff --git a/Lib/hmac.py b/Lib/hmac.py
index 538810630cf..956fc65d2c0 100644
--- a/Lib/hmac.py
+++ b/Lib/hmac.py
@@ -5,17 +5,13 @@ Implements the HMAC algorithm as described by RFC 2104.
import warnings as _warnings
-trans_5C = "".join ([chr (x ^ 0x5C) for x in xrange(256)])
-trans_36 = "".join ([chr (x ^ 0x36) for x in xrange(256)])
+trans_5C = bytes((x ^ 0x5C) for x in range(256))
+trans_36 = bytes((x ^ 0x36) for x in range(256))
# The size of the digests returned by HMAC depends on the underlying
# hashing module used. Use digest_size from the instance of HMAC instead.
digest_size = None
-# A unique object passed by HMAC.copy() to the HMAC constructor, in order
-# that the latter return very quickly. HMAC("") in contrast is quite
-# expensive.
-_secret_backdoor_key = []
class HMAC:
"""RFC 2104 HMAC class. Also complies with RFC 4231.
@@ -32,19 +28,21 @@ class HMAC:
digestmod: A module supporting PEP 247. *OR*
A hashlib constructor returning a new hash object.
Defaults to hashlib.md5.
+
+ Note: key and msg must be bytes objects.
"""
- if key is _secret_backdoor_key: # cheap
- return
+ if not isinstance(key, bytes):
+ raise TypeError("expected bytes, but got %r" % type(key).__name__)
if digestmod is None:
import hashlib
digestmod = hashlib.md5
- if hasattr(digestmod, '__call__'):
+ if callable(digestmod):
self.digest_cons = digestmod
else:
- self.digest_cons = lambda d='': digestmod.new(d)
+ self.digest_cons = lambda d=b'': digestmod.new(d)
self.outer = self.digest_cons()
self.inner = self.digest_cons()
@@ -53,8 +51,6 @@ class HMAC:
if hasattr(self.inner, 'block_size'):
blocksize = self.inner.block_size
if blocksize < 16:
- # Very low blocksize, most likely a legacy value like
- # Lib/sha.py and Lib/md5.py have.
_warnings.warn('block_size of %d seems too small; using our '
'default of %d.' % (blocksize, self.blocksize),
RuntimeWarning, 2)
@@ -68,18 +64,17 @@ class HMAC:
if len(key) > blocksize:
key = self.digest_cons(key).digest()
- key = key + chr(0) * (blocksize - len(key))
+ key = key + bytes(blocksize - len(key))
self.outer.update(key.translate(trans_5C))
self.inner.update(key.translate(trans_36))
if msg is not None:
self.update(msg)
-## def clear(self):
-## raise NotImplementedError, "clear() method not available in HMAC."
-
def update(self, msg):
"""Update this hashing object with the string msg.
"""
+ if not isinstance(msg, bytes):
+ raise TypeError("expected bytes, but got %r" % type(msg).__name__)
self.inner.update(msg)
def copy(self):
@@ -87,7 +82,8 @@ class HMAC:
An update to this copy won't affect the original object.
"""
- other = self.__class__(_secret_backdoor_key)
+ # Call __new__ directly to avoid the expensive __init__.
+ other = self.__class__.__new__(self.__class__)
other.digest_cons = self.digest_cons
other.digest_size = self.digest_size
other.inner = self.inner.copy()
diff --git a/Lib/hotshot/__init__.py b/Lib/hotshot/__init__.py
deleted file mode 100644
index 1556ab3f2ba..00000000000
--- a/Lib/hotshot/__init__.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""High-perfomance logging profiler, mostly written in C."""
-
-import _hotshot
-from _hotshot import ProfilerError
-
-from warnings import warnpy3k as _warnpy3k
-_warnpy3k("The 'hotshot' module is not supported in 3.x, "
- "use the 'profile' module instead.", stacklevel=2)
-
-class Profile:
- def __init__(self, logfn, lineevents=0, linetimings=1):
- self.lineevents = lineevents and 1 or 0
- self.linetimings = (linetimings and lineevents) and 1 or 0
- self._prof = p = _hotshot.profiler(
- logfn, self.lineevents, self.linetimings)
-
- # Attempt to avoid confusing results caused by the presence of
- # Python wrappers around these functions, but only if we can
- # be sure the methods have not been overridden or extended.
- if self.__class__ is Profile:
- self.close = p.close
- self.start = p.start
- self.stop = p.stop
- self.addinfo = p.addinfo
-
- def close(self):
- """Close the logfile and terminate the profiler."""
- self._prof.close()
-
- def fileno(self):
- """Return the file descriptor of the profiler's log file."""
- return self._prof.fileno()
-
- def start(self):
- """Start the profiler."""
- self._prof.start()
-
- def stop(self):
- """Stop the profiler."""
- self._prof.stop()
-
- def addinfo(self, key, value):
- """Add an arbitrary labelled value to the profile log."""
- self._prof.addinfo(key, value)
-
- # These methods offer the same interface as the profile.Profile class,
- # but delegate most of the work to the C implementation underneath.
-
- def run(self, cmd):
- """Profile an exec-compatible string in the script
- environment.
-
- The globals from the __main__ module are used as both the
- globals and locals for the script.
- """
- import __main__
- dict = __main__.__dict__
- return self.runctx(cmd, dict, dict)
-
- def runctx(self, cmd, globals, locals):
- """Evaluate an exec-compatible string in a specific
- environment.
-
- The string is compiled before profiling begins.
- """
- code = compile(cmd, "<string>", "exec")
- self._prof.runcode(code, globals, locals)
- return self
-
- def runcall(self, func, *args, **kw):
- """Profile a single call of a callable.
-
- Additional positional and keyword arguments may be passed
- along; the result of the call is returned, and exceptions are
- allowed to propogate cleanly, while ensuring that profiling is
- disabled on the way out.
- """
- return self._prof.runcall(func, args, kw)
diff --git a/Lib/hotshot/log.py b/Lib/hotshot/log.py
deleted file mode 100644
index 17e8b50515a..00000000000
--- a/Lib/hotshot/log.py
+++ /dev/null
@@ -1,194 +0,0 @@
-import _hotshot
-import os.path
-import parser
-import symbol
-
-from _hotshot import \
- WHAT_ENTER, \
- WHAT_EXIT, \
- WHAT_LINENO, \
- WHAT_DEFINE_FILE, \
- WHAT_DEFINE_FUNC, \
- WHAT_ADD_INFO
-
-
-__all__ = ["LogReader", "ENTER", "EXIT", "LINE"]
-
-
-ENTER = WHAT_ENTER
-EXIT = WHAT_EXIT
-LINE = WHAT_LINENO
-
-
-class LogReader:
- def __init__(self, logfn):
- # fileno -> filename
- self._filemap = {}
- # (fileno, lineno) -> filename, funcname
- self._funcmap = {}
-
- self._reader = _hotshot.logreader(logfn)
- self._nextitem = self._reader.next
- self._info = self._reader.info
- if 'current-directory' in self._info:
- self.cwd = self._info['current-directory']
- else:
- self.cwd = None
-
- # This mirrors the call stack of the profiled code as the log
- # is read back in. It contains tuples of the form:
- #
- # (file name, line number of function def, function name)
- #
- self._stack = []
- self._append = self._stack.append
- self._pop = self._stack.pop
-
- def close(self):
- self._reader.close()
-
- def fileno(self):
- """Return the file descriptor of the log reader's log file."""
- return self._reader.fileno()
-
- def addinfo(self, key, value):
- """This method is called for each additional ADD_INFO record.
-
- This can be overridden by applications that want to receive
- these events. The default implementation does not need to be
- called by alternate implementations.
-
- The initial set of ADD_INFO records do not pass through this
- mechanism; this is only needed to receive notification when
- new values are added. Subclasses can inspect self._info after
- calling LogReader.__init__().
- """
- pass
-
- def get_filename(self, fileno):
- try:
- return self._filemap[fileno]
- except KeyError:
- raise ValueError, "unknown fileno"
-
- def get_filenames(self):
- return self._filemap.values()
-
- def get_fileno(self, filename):
- filename = os.path.normcase(os.path.normpath(filename))
- for fileno, name in self._filemap.items():
- if name == filename:
- return fileno
- raise ValueError, "unknown filename"
-
- def get_funcname(self, fileno, lineno):
- try:
- return self._funcmap[(fileno, lineno)]
- except KeyError:
- raise ValueError, "unknown function location"
-
- # Iteration support:
- # This adds an optional (& ignored) parameter to next() so that the
- # same bound method can be used as the __getitem__() method -- this
- # avoids using an additional method call which kills the performance.
-
- def next(self, index=0):
- while 1:
- # This call may raise StopIteration:
- what, tdelta, fileno, lineno = self._nextitem()
-
- # handle the most common cases first
-
- if what == WHAT_ENTER:
- filename, funcname = self._decode_location(fileno, lineno)
- t = (filename, lineno, funcname)
- self._append(t)
- return what, t, tdelta
-
- if what == WHAT_EXIT:
- try:
- return what, self._pop(), tdelta
- except IndexError:
- raise StopIteration
-
- if what == WHAT_LINENO:
- filename, firstlineno, funcname = self._stack[-1]
- return what, (filename, lineno, funcname), tdelta
-
- if what == WHAT_DEFINE_FILE:
- filename = os.path.normcase(os.path.normpath(tdelta))
- self._filemap[fileno] = filename
- elif what == WHAT_DEFINE_FUNC:
- filename = self._filemap[fileno]
- self._funcmap[(fileno, lineno)] = (filename, tdelta)
- elif what == WHAT_ADD_INFO:
- # value already loaded into self.info; call the
- # overridable addinfo() handler so higher-level code
- # can pick up the new value
- if tdelta == 'current-directory':
- self.cwd = lineno
- self.addinfo(tdelta, lineno)
- else:
- raise ValueError, "unknown event type"
-
- def __iter__(self):
- return self
-
- #
- # helpers
- #
-
- def _decode_location(self, fileno, lineno):
- try:
- return self._funcmap[(fileno, lineno)]
- except KeyError:
- #
- # This should only be needed when the log file does not
- # contain all the DEFINE_FUNC records needed to allow the
- # function name to be retrieved from the log file.
- #
- if self._loadfile(fileno):
- filename = funcname = None
- try:
- filename, funcname = self._funcmap[(fileno, lineno)]
- except KeyError:
- filename = self._filemap.get(fileno)
- funcname = None
- self._funcmap[(fileno, lineno)] = (filename, funcname)
- return filename, funcname
-
- def _loadfile(self, fileno):
- try:
- filename = self._filemap[fileno]
- except KeyError:
- print "Could not identify fileId", fileno
- return 1
- if filename is None:
- return 1
- absname = os.path.normcase(os.path.join(self.cwd, filename))
-
- try:
- fp = open(absname)
- except IOError:
- return
- st = parser.suite(fp.read())
- fp.close()
-
- # Scan the tree looking for def and lambda nodes, filling in
- # self._funcmap with all the available information.
- funcdef = symbol.funcdef
- lambdef = symbol.lambdef
-
- stack = [st.totuple(1)]
-
- while stack:
- tree = stack.pop()
- try:
- sym = tree[0]
- except (IndexError, TypeError):
- continue
- if sym == funcdef:
- self._funcmap[(fileno, tree[2][2])] = filename, tree[2][1]
- elif sym == lambdef:
- self._funcmap[(fileno, tree[1][2])] = filename, "<lambda>"
- stack.extend(list(tree[1:]))
diff --git a/Lib/hotshot/stats.py b/Lib/hotshot/stats.py
deleted file mode 100644
index 7ff2277a181..00000000000
--- a/Lib/hotshot/stats.py
+++ /dev/null
@@ -1,93 +0,0 @@
-"""Statistics analyzer for HotShot."""
-
-import profile
-import pstats
-
-import hotshot.log
-
-from hotshot.log import ENTER, EXIT
-
-
-def load(filename):
- return StatsLoader(filename).load()
-
-
-class StatsLoader:
- def __init__(self, logfn):
- self._logfn = logfn
- self._code = {}
- self._stack = []
- self.pop_frame = self._stack.pop
-
- def load(self):
- # The timer selected by the profiler should never be used, so make
- # sure it doesn't work:
- p = Profile()
- p.get_time = _brokentimer
- log = hotshot.log.LogReader(self._logfn)
- taccum = 0
- for event in log:
- what, (filename, lineno, funcname), tdelta = event
- if tdelta > 0:
- taccum += tdelta
-
- # We multiply taccum to convert from the microseconds we
- # have to the seconds that the profile/pstats module work
- # with; this allows the numbers to have some basis in
- # reality (ignoring calibration issues for now).
-
- if what == ENTER:
- frame = self.new_frame(filename, lineno, funcname)
- p.trace_dispatch_call(frame, taccum * .000001)
- taccum = 0
-
- elif what == EXIT:
- frame = self.pop_frame()
- p.trace_dispatch_return(frame, taccum * .000001)
- taccum = 0
-
- # no further work for line events
-
- assert not self._stack
- return pstats.Stats(p)
-
- def new_frame(self, *args):
- # args must be filename, firstlineno, funcname
- # our code objects are cached since we don't need to create
- # new ones every time
- try:
- code = self._code[args]
- except KeyError:
- code = FakeCode(*args)
- self._code[args] = code
- # frame objects are create fresh, since the back pointer will
- # vary considerably
- if self._stack:
- back = self._stack[-1]
- else:
- back = None
- frame = FakeFrame(code, back)
- self._stack.append(frame)
- return frame
-
-
-class Profile(profile.Profile):
- def simulate_cmd_complete(self):
- pass
-
-
-class FakeCode:
- def __init__(self, filename, firstlineno, funcname):
- self.co_filename = filename
- self.co_firstlineno = firstlineno
- self.co_name = self.__name__ = funcname
-
-
-class FakeFrame:
- def __init__(self, code, back):
- self.f_back = back
- self.f_code = code
-
-
-def _brokentimer():
- raise RuntimeError, "this timer should not be called"
diff --git a/Lib/hotshot/stones.py b/Lib/hotshot/stones.py
deleted file mode 100644
index fb88d581d3d..00000000000
--- a/Lib/hotshot/stones.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import errno
-import hotshot
-import hotshot.stats
-import sys
-import test.pystone
-
-def main(logfile):
- p = hotshot.Profile(logfile)
- benchtime, stones = p.runcall(test.pystone.pystones)
- p.close()
-
- print "Pystone(%s) time for %d passes = %g" % \
- (test.pystone.__version__, test.pystone.LOOPS, benchtime)
- print "This machine benchmarks at %g pystones/second" % stones
-
- stats = hotshot.stats.load(logfile)
- stats.strip_dirs()
- stats.sort_stats('time', 'calls')
- try:
- stats.print_stats(20)
- except IOError, e:
- if e.errno != errno.EPIPE:
- raise
-
-if __name__ == '__main__':
- if sys.argv[1:]:
- main(sys.argv[1])
- else:
- import tempfile
- main(tempfile.NamedTemporaryFile().name)
diff --git a/Lib/html/__init__.py b/Lib/html/__init__.py
new file mode 100644
index 00000000000..02652ef73c3
--- /dev/null
+++ b/Lib/html/__init__.py
@@ -0,0 +1,21 @@
+"""
+General functions for HTML manipulation.
+"""
+
+
+_escape_map = {ord('&'): '&amp;', ord('<'): '&lt;', ord('>'): '&gt;'}
+_escape_map_full = {ord('&'): '&amp;', ord('<'): '&lt;', ord('>'): '&gt;',
+ ord('"'): '&quot;', ord('\''): '&#x27;'}
+
+# NB: this is a candidate for a bytes/string polymorphic interface
+
+def escape(s, quote=True):
+ """
+ Replace special characters "&", "<" and ">" to HTML-safe sequences.
+ If the optional flag quote is true (the default), the quotation mark
+ characters, both double quote (") and single quote (') characters are also
+ translated.
+ """
+ if quote:
+ return s.translate(_escape_map_full)
+ return s.translate(_escape_map)
diff --git a/Lib/htmlentitydefs.py b/Lib/html/entities.py
index 3dd14a79fab..e2b7bf1fb88 100644
--- a/Lib/htmlentitydefs.py
+++ b/Lib/html/entities.py
@@ -263,11 +263,8 @@ codepoint2name = {}
# (or a character reference if the character is outside the Latin-1 range)
entitydefs = {}
-for (name, codepoint) in name2codepoint.iteritems():
+for (name, codepoint) in name2codepoint.items():
codepoint2name[codepoint] = name
- if codepoint <= 0xff:
- entitydefs[name] = chr(codepoint)
- else:
- entitydefs[name] = '&#%d;' % codepoint
+ entitydefs[name] = chr(codepoint)
del name, codepoint
diff --git a/Lib/HTMLParser.py b/Lib/html/parser.py
index b336a4c31df..de504ab5440 100644
--- a/Lib/HTMLParser.py
+++ b/Lib/html/parser.py
@@ -8,7 +8,7 @@
# and CDATA (character data -- only end tags are special).
-import markupbase
+import _markupbase
import re
# Regular expressions used for parsing
@@ -26,13 +26,34 @@ tagfind = re.compile('([a-zA-Z][-.a-zA-Z0-9:_]*)(?:\s|/(?!>))*')
# see http://www.w3.org/TR/html5/tokenization.html#tag-open-state
# and http://www.w3.org/TR/html5/tokenization.html#tag-name-state
tagfind_tolerant = re.compile('[a-zA-Z][^\t\n\r\f />\x00]*')
-
+# Note:
+# 1) the strict attrfind isn't really strict, but we can't make it
+# correctly strict without breaking backward compatibility;
+# 2) if you change attrfind remember to update locatestarttagend too;
+# 3) if you change attrfind and/or locatestarttagend the parser will
+# explode, so don't do it.
attrfind = re.compile(
+ r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
+ r'(\'[^\']*\'|"[^"]*"|[^\s"\'=<>`]*))?')
+attrfind_tolerant = re.compile(
r'((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*'
r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*')
-
locatestarttagend = re.compile(r"""
<[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
+ (?:\s+ # whitespace before attribute name
+ (?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name
+ (?:\s*=\s* # value indicator
+ (?:'[^']*' # LITA-enclosed value
+ |\"[^\"]*\" # LIT-enclosed value
+ |[^'\">\s]+ # bare value
+ )
+ )?
+ )
+ )*
+ \s* # trailing whitespace
+""", re.VERBOSE)
+locatestarttagend_tolerant = re.compile(r"""
+ <[a-zA-Z][-.a-zA-Z0-9:_]* # tag name
(?:[\s/]* # optional whitespace before attribute name
(?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name
(?:\s*=+\s* # value indicator
@@ -40,6 +61,7 @@ locatestarttagend = re.compile(r"""
|"[^"]*" # LIT-enclosed value
|(?!['"])[^>\s]* # bare value
)
+ (?:\s*,)* # possibly followed by a comma
)?(?:\s|/(?!>))*
)*
)?
@@ -69,7 +91,7 @@ class HTMLParseError(Exception):
return result
-class HTMLParser(markupbase.ParserBase):
+class HTMLParser(_markupbase.ParserBase):
"""Find tags and other markup and call handler functions.
Usage:
@@ -91,9 +113,15 @@ class HTMLParser(markupbase.ParserBase):
CDATA_CONTENT_ELEMENTS = ("script", "style")
+ def __init__(self, strict=True):
+ """Initialize and reset this instance.
- def __init__(self):
- """Initialize and reset this instance."""
+ If strict is set to True (the default), errors are raised when invalid
+ HTML is encountered. If set to False, an attempt is instead made to
+ continue parsing, making "best guesses" about the intended meaning, in
+ a fashion similar to what browsers typically do.
+ """
+ self.strict = strict
self.reset()
def reset(self):
@@ -102,7 +130,7 @@ class HTMLParser(markupbase.ParserBase):
self.lasttag = '???'
self.interesting = interesting_normal
self.cdata_elem = None
- markupbase.ParserBase.reset(self)
+ _markupbase.ParserBase.reset(self)
def feed(self, data):
r"""Feed data to the parser.
@@ -163,7 +191,10 @@ class HTMLParser(markupbase.ParserBase):
elif startswith("<?", i):
k = self.parse_pi(i)
elif startswith("<!", i):
- k = self.parse_html_declaration(i)
+ if self.strict:
+ k = self.parse_declaration(i)
+ else:
+ k = self.parse_html_declaration(i)
elif (i + 1) < n:
self.handle_data("<")
k = i + 1
@@ -172,6 +203,8 @@ class HTMLParser(markupbase.ParserBase):
if k < 0:
if not end:
break
+ if self.strict:
+ self.error("EOF in middle of construct")
k = rawdata.find('>', i + 1)
if k < 0:
k = rawdata.find('<', i + 1)
@@ -210,7 +243,12 @@ class HTMLParser(markupbase.ParserBase):
if match:
# match.group() will contain at least 2 chars
if end and match.group() == rawdata[i:]:
- self.error("EOF in middle of entity or char ref")
+ if self.strict:
+ self.error("EOF in middle of entity or char ref")
+ else:
+ if k <= i:
+ k = n
+ i = self.updatepos(i, i + 1)
# incomplete
break
elif (i + 1) < n:
@@ -290,9 +328,11 @@ class HTMLParser(markupbase.ParserBase):
assert match, 'unexpected call to parse_starttag()'
k = match.end()
self.lasttag = tag = match.group(1).lower()
-
while k < endpos:
- m = attrfind.match(rawdata, k)
+ if self.strict:
+ m = attrfind.match(rawdata, k)
+ else:
+ m = attrfind_tolerant.match(rawdata, k)
if not m:
break
attrname, rest, attrvalue = m.group(1, 2, 3)
@@ -315,6 +355,9 @@ class HTMLParser(markupbase.ParserBase):
- self.__starttag_text.rfind("\n")
else:
offset = offset + len(self.__starttag_text)
+ if self.strict:
+ self.error("junk characters in start tag: %r"
+ % (rawdata[k:endpos][:20],))
self.handle_data(rawdata[i:endpos])
return endpos
if end.endswith('/>'):
@@ -330,7 +373,10 @@ class HTMLParser(markupbase.ParserBase):
# or -1 if incomplete.
def check_for_whole_start_tag(self, i):
rawdata = self.rawdata
- m = locatestarttagend.match(rawdata, i)
+ if self.strict:
+ m = locatestarttagend.match(rawdata, i)
+ else:
+ m = locatestarttagend_tolerant.match(rawdata, i)
if m:
j = m.end()
next = rawdata[j:j+1]
@@ -343,8 +389,13 @@ class HTMLParser(markupbase.ParserBase):
# buffer boundary
return -1
# else bogus input
- self.updatepos(i, j + 1)
- self.error("malformed empty start tag")
+ if self.strict:
+ self.updatepos(i, j + 1)
+ self.error("malformed empty start tag")
+ if j > i:
+ return j
+ else:
+ return i + 1
if next == "":
# end of input
return -1
@@ -353,6 +404,9 @@ class HTMLParser(markupbase.ParserBase):
# end of input in or before attribute value, or we have the
# '/' from a '/>' ending
return -1
+ if self.strict:
+ self.updatepos(i, j)
+ self.error("malformed start tag")
if j > i:
return j
else:
@@ -372,6 +426,8 @@ class HTMLParser(markupbase.ParserBase):
if self.cdata_elem is not None:
self.handle_data(rawdata[i:gtpos])
return gtpos
+ if self.strict:
+ self.error("bad end tag: %r" % (rawdata[i:gtpos],))
# find the name: w3.org/TR/html5/tokenization.html#tag-name-state
namematch = tagfind_tolerant.match(rawdata, i+2)
if not namematch:
@@ -395,7 +451,7 @@ class HTMLParser(markupbase.ParserBase):
self.handle_data(rawdata[i:gtpos])
return gtpos
- self.handle_endtag(elem)
+ self.handle_endtag(elem.lower())
self.clear_cdata_mode()
return gtpos
@@ -437,7 +493,8 @@ class HTMLParser(markupbase.ParserBase):
pass
def unknown_decl(self, data):
- pass
+ if self.strict:
+ self.error("unknown declaration: %r" % (data,))
# Internal -- helper to remove special character quoting
entitydefs = None
@@ -453,20 +510,21 @@ class HTMLParser(markupbase.ParserBase):
c = int(s[1:], 16)
else:
c = int(s)
- return unichr(c)
+ return chr(c)
except ValueError:
- return '&#'+s+';'
+ return '&#'+ s +';'
else:
- # Cannot use name2codepoint directly, because HTMLParser supports apos,
- # which is not part of HTML 4
- import htmlentitydefs
+ # Cannot use name2codepoint directly, because HTMLParser
+ # supports apos, which is not part of HTML 4
+ import html.entities
if HTMLParser.entitydefs is None:
- entitydefs = HTMLParser.entitydefs = {'apos':u"'"}
- for k, v in htmlentitydefs.name2codepoint.iteritems():
- entitydefs[k] = unichr(v)
+ entitydefs = HTMLParser.entitydefs = {'apos':"'"}
+ for k, v in html.entities.name2codepoint.items():
+ entitydefs[k] = chr(v)
try:
return self.entitydefs[s]
except KeyError:
return '&'+s+';'
- return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));", replaceEntities, s)
+ return re.sub(r"&(#?[xX]?(?:[0-9a-fA-F]+|\w{1,8}));",
+ replaceEntities, s, flags=re.ASCII)
diff --git a/Lib/htmllib.py b/Lib/htmllib.py
deleted file mode 100644
index 44647dbf026..00000000000
--- a/Lib/htmllib.py
+++ /dev/null
@@ -1,491 +0,0 @@
-"""HTML 2.0 parser.
-
-See the HTML 2.0 specification:
-http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
-"""
-
-from warnings import warnpy3k
-warnpy3k("the htmllib module has been removed in Python 3.0",
- stacklevel=2)
-del warnpy3k
-
-import sgmllib
-
-from formatter import AS_IS
-
-__all__ = ["HTMLParser", "HTMLParseError"]
-
-
-class HTMLParseError(sgmllib.SGMLParseError):
- """Error raised when an HTML document can't be parsed."""
-
-
-class HTMLParser(sgmllib.SGMLParser):
- """This is the basic HTML parser class.
-
- It supports all entity names required by the XHTML 1.0 Recommendation.
- It also defines handlers for all HTML 2.0 and many HTML 3.0 and 3.2
- elements.
-
- """
-
- from htmlentitydefs import entitydefs
-
- def __init__(self, formatter, verbose=0):
- """Creates an instance of the HTMLParser class.
-
- The formatter parameter is the formatter instance associated with
- the parser.
-
- """
- sgmllib.SGMLParser.__init__(self, verbose)
- self.formatter = formatter
-
- def error(self, message):
- raise HTMLParseError(message)
-
- def reset(self):
- sgmllib.SGMLParser.reset(self)
- self.savedata = None
- self.isindex = 0
- self.title = None
- self.base = None
- self.anchor = None
- self.anchorlist = []
- self.nofill = 0
- self.list_stack = []
-
- # ------ Methods used internally; some may be overridden
-
- # --- Formatter interface, taking care of 'savedata' mode;
- # shouldn't need to be overridden
-
- def handle_data(self, data):
- if self.savedata is not None:
- self.savedata = self.savedata + data
- else:
- if self.nofill:
- self.formatter.add_literal_data(data)
- else:
- self.formatter.add_flowing_data(data)
-
- # --- Hooks to save data; shouldn't need to be overridden
-
- def save_bgn(self):
- """Begins saving character data in a buffer instead of sending it
- to the formatter object.
-
- Retrieve the stored data via the save_end() method. Use of the
- save_bgn() / save_end() pair may not be nested.
-
- """
- self.savedata = ''
-
- def save_end(self):
- """Ends buffering character data and returns all data saved since
- the preceding call to the save_bgn() method.
-
- If the nofill flag is false, whitespace is collapsed to single
- spaces. A call to this method without a preceding call to the
- save_bgn() method will raise a TypeError exception.
-
- """
- data = self.savedata
- self.savedata = None
- if not self.nofill:
- data = ' '.join(data.split())
- return data
-
- # --- Hooks for anchors; should probably be overridden
-
- def anchor_bgn(self, href, name, type):
- """This method is called at the start of an anchor region.
-
- The arguments correspond to the attributes of the <A> tag with
- the same names. The default implementation maintains a list of
- hyperlinks (defined by the HREF attribute for <A> tags) within
- the document. The list of hyperlinks is available as the data
- attribute anchorlist.
-
- """
- self.anchor = href
- if self.anchor:
- self.anchorlist.append(href)
-
- def anchor_end(self):
- """This method is called at the end of an anchor region.
-
- The default implementation adds a textual footnote marker using an
- index into the list of hyperlinks created by the anchor_bgn()method.
-
- """
- if self.anchor:
- self.handle_data("[%d]" % len(self.anchorlist))
- self.anchor = None
-
- # --- Hook for images; should probably be overridden
-
- def handle_image(self, src, alt, *args):
- """This method is called to handle images.
-
- The default implementation simply passes the alt value to the
- handle_data() method.
-
- """
- self.handle_data(alt)
-
- # --------- Top level elememts
-
- def start_html(self, attrs): pass
- def end_html(self): pass
-
- def start_head(self, attrs): pass
- def end_head(self): pass
-
- def start_body(self, attrs): pass
- def end_body(self): pass
-
- # ------ Head elements
-
- def start_title(self, attrs):
- self.save_bgn()
-
- def end_title(self):
- self.title = self.save_end()
-
- def do_base(self, attrs):
- for a, v in attrs:
- if a == 'href':
- self.base = v
-
- def do_isindex(self, attrs):
- self.isindex = 1
-
- def do_link(self, attrs):
- pass
-
- def do_meta(self, attrs):
- pass
-
- def do_nextid(self, attrs): # Deprecated
- pass
-
- # ------ Body elements
-
- # --- Headings
-
- def start_h1(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h1', 0, 1, 0))
-
- def end_h1(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- def start_h2(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h2', 0, 1, 0))
-
- def end_h2(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- def start_h3(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h3', 0, 1, 0))
-
- def end_h3(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- def start_h4(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h4', 0, 1, 0))
-
- def end_h4(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- def start_h5(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h5', 0, 1, 0))
-
- def end_h5(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- def start_h6(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font(('h6', 0, 1, 0))
-
- def end_h6(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
-
- # --- Block Structuring Elements
-
- def do_p(self, attrs):
- self.formatter.end_paragraph(1)
-
- def start_pre(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_font((AS_IS, AS_IS, AS_IS, 1))
- self.nofill = self.nofill + 1
-
- def end_pre(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_font()
- self.nofill = max(0, self.nofill - 1)
-
- def start_xmp(self, attrs):
- self.start_pre(attrs)
- self.setliteral('xmp') # Tell SGML parser
-
- def end_xmp(self):
- self.end_pre()
-
- def start_listing(self, attrs):
- self.start_pre(attrs)
- self.setliteral('listing') # Tell SGML parser
-
- def end_listing(self):
- self.end_pre()
-
- def start_address(self, attrs):
- self.formatter.end_paragraph(0)
- self.formatter.push_font((AS_IS, 1, AS_IS, AS_IS))
-
- def end_address(self):
- self.formatter.end_paragraph(0)
- self.formatter.pop_font()
-
- def start_blockquote(self, attrs):
- self.formatter.end_paragraph(1)
- self.formatter.push_margin('blockquote')
-
- def end_blockquote(self):
- self.formatter.end_paragraph(1)
- self.formatter.pop_margin()
-
- # --- List Elements
-
- def start_ul(self, attrs):
- self.formatter.end_paragraph(not self.list_stack)
- self.formatter.push_margin('ul')
- self.list_stack.append(['ul', '*', 0])
-
- def end_ul(self):
- if self.list_stack: del self.list_stack[-1]
- self.formatter.end_paragraph(not self.list_stack)
- self.formatter.pop_margin()
-
- def do_li(self, attrs):
- self.formatter.end_paragraph(0)
- if self.list_stack:
- [dummy, label, counter] = top = self.list_stack[-1]
- top[2] = counter = counter+1
- else:
- label, counter = '*', 0
- self.formatter.add_label_data(label, counter)
-
- def start_ol(self, attrs):
- self.formatter.end_paragraph(not self.list_stack)
- self.formatter.push_margin('ol')
- label = '1.'
- for a, v in attrs:
- if a == 'type':
- if len(v) == 1: v = v + '.'
- label = v
- self.list_stack.append(['ol', label, 0])
-
- def end_ol(self):
- if self.list_stack: del self.list_stack[-1]
- self.formatter.end_paragraph(not self.list_stack)
- self.formatter.pop_margin()
-
- def start_menu(self, attrs):
- self.start_ul(attrs)
-
- def end_menu(self):
- self.end_ul()
-
- def start_dir(self, attrs):
- self.start_ul(attrs)
-
- def end_dir(self):
- self.end_ul()
-
- def start_dl(self, attrs):
- self.formatter.end_paragraph(1)
- self.list_stack.append(['dl', '', 0])
-
- def end_dl(self):
- self.ddpop(1)
- if self.list_stack: del self.list_stack[-1]
-
- def do_dt(self, attrs):
- self.ddpop()
-
- def do_dd(self, attrs):
- self.ddpop()
- self.formatter.push_margin('dd')
- self.list_stack.append(['dd', '', 0])
-
- def ddpop(self, bl=0):
- self.formatter.end_paragraph(bl)
- if self.list_stack:
- if self.list_stack[-1][0] == 'dd':
- del self.list_stack[-1]
- self.formatter.pop_margin()
-
- # --- Phrase Markup
-
- # Idiomatic Elements
-
- def start_cite(self, attrs): self.start_i(attrs)
- def end_cite(self): self.end_i()
-
- def start_code(self, attrs): self.start_tt(attrs)
- def end_code(self): self.end_tt()
-
- def start_em(self, attrs): self.start_i(attrs)
- def end_em(self): self.end_i()
-
- def start_kbd(self, attrs): self.start_tt(attrs)
- def end_kbd(self): self.end_tt()
-
- def start_samp(self, attrs): self.start_tt(attrs)
- def end_samp(self): self.end_tt()
-
- def start_strong(self, attrs): self.start_b(attrs)
- def end_strong(self): self.end_b()
-
- def start_var(self, attrs): self.start_i(attrs)
- def end_var(self): self.end_i()
-
- # Typographic Elements
-
- def start_i(self, attrs):
- self.formatter.push_font((AS_IS, 1, AS_IS, AS_IS))
- def end_i(self):
- self.formatter.pop_font()
-
- def start_b(self, attrs):
- self.formatter.push_font((AS_IS, AS_IS, 1, AS_IS))
- def end_b(self):
- self.formatter.pop_font()
-
- def start_tt(self, attrs):
- self.formatter.push_font((AS_IS, AS_IS, AS_IS, 1))
- def end_tt(self):
- self.formatter.pop_font()
-
- def start_a(self, attrs):
- href = ''
- name = ''
- type = ''
- for attrname, value in attrs:
- value = value.strip()
- if attrname == 'href':
- href = value
- if attrname == 'name':
- name = value
- if attrname == 'type':
- type = value.lower()
- self.anchor_bgn(href, name, type)
-
- def end_a(self):
- self.anchor_end()
-
- # --- Line Break
-
- def do_br(self, attrs):
- self.formatter.add_line_break()
-
- # --- Horizontal Rule
-
- def do_hr(self, attrs):
- self.formatter.add_hor_rule()
-
- # --- Image
-
- def do_img(self, attrs):
- align = ''
- alt = '(image)'
- ismap = ''
- src = ''
- width = 0
- height = 0
- for attrname, value in attrs:
- if attrname == 'align':
- align = value
- if attrname == 'alt':
- alt = value
- if attrname == 'ismap':
- ismap = value
- if attrname == 'src':
- src = value
- if attrname == 'width':
- try: width = int(value)
- except ValueError: pass
- if attrname == 'height':
- try: height = int(value)
- except ValueError: pass
- self.handle_image(src, alt, ismap, align, width, height)
-
- # --- Really Old Unofficial Deprecated Stuff
-
- def do_plaintext(self, attrs):
- self.start_pre(attrs)
- self.setnomoretags() # Tell SGML parser
-
- # --- Unhandled tags
-
- def unknown_starttag(self, tag, attrs):
- pass
-
- def unknown_endtag(self, tag):
- pass
-
-
-def test(args = None):
- import sys, formatter
-
- if not args:
- args = sys.argv[1:]
-
- silent = args and args[0] == '-s'
- if silent:
- del args[0]
-
- if args:
- file = args[0]
- else:
- file = 'test.html'
-
- if file == '-':
- f = sys.stdin
- else:
- try:
- f = open(file, 'r')
- except IOError, msg:
- print file, ":", msg
- sys.exit(1)
-
- data = f.read()
-
- if f is not sys.stdin:
- f.close()
-
- if silent:
- f = formatter.NullFormatter()
- else:
- f = formatter.AbstractFormatter(formatter.DumbWriter())
-
- p = HTMLParser(f)
- p.feed(data)
- p.close()
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/http/__init__.py b/Lib/http/__init__.py
new file mode 100644
index 00000000000..196d3788575
--- /dev/null
+++ b/Lib/http/__init__.py
@@ -0,0 +1 @@
+# This directory is a Python package.
diff --git a/Lib/httplib.py b/Lib/http/client.py
index 9d11d040220..4d93b93ff01 100644
--- a/Lib/httplib.py
+++ b/Lib/http/client.py
@@ -1,4 +1,4 @@
-r"""HTTP/1.1 client library
+"""HTTP/1.1 client library
<intro stuff goes here>
<other stuff, too>
@@ -66,24 +66,16 @@ Req-started-unread-response _CS_REQ_STARTED <response_class>
Req-sent-unread-response _CS_REQ_SENT <response_class>
"""
-from array import array
+import email.parser
+import email.message
+import io
import os
import socket
-from sys import py3kwarning
-from urlparse import urlsplit
+import collections
+from urllib.parse import urlsplit
import warnings
-with warnings.catch_warnings():
- if py3kwarning:
- warnings.filterwarnings("ignore", ".*mimetools has been removed",
- DeprecationWarning)
- import mimetools
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-__all__ = ["HTTP", "HTTPResponse", "HTTPConnection",
+__all__ = ["HTTPResponse", "HTTPConnection",
"HTTPException", "NotConnected", "UnknownProtocol",
"UnknownTransferEncoding", "UnimplementedFileMode",
"IncompleteRead", "InvalidURL", "ImproperConnectionState",
@@ -215,140 +207,92 @@ MAXAMOUNT = 1048576
# maximal line length when calling readline().
_MAXLINE = 65536
-class HTTPMessage(mimetools.Message):
+class HTTPMessage(email.message.Message):
+ # XXX The only usage of this method is in
+ # http.server.CGIHTTPRequestHandler. Maybe move the code there so
+ # that it doesn't need to be part of the public API. The API has
+ # never been defined so this could cause backwards compatibility
+ # issues.
+
+ def getallmatchingheaders(self, name):
+ """Find all header lines matching a given header name.
+
+ Look through the list of headers and find all lines matching a given
+ header name (and their continuation lines). A list of the lines is
+ returned, without interpretation. If the header does not occur, an
+ empty list is returned. If the header occurs multiple times, all
+ occurrences are returned. Case is not important in the header name.
- def addheader(self, key, value):
- """Add header for field key handling repeats."""
- prev = self.dict.get(key)
- if prev is None:
- self.dict[key] = value
- else:
- combined = ", ".join((prev, value))
- self.dict[key] = combined
-
- def addcontinue(self, key, more):
- """Add more field data from a continuation line."""
- prev = self.dict[key]
- self.dict[key] = prev + "\n " + more
-
- def readheaders(self):
- """Read header lines.
-
- Read header lines up to the entirely blank line that terminates them.
- The (normally blank) line that ends the headers is skipped, but not
- included in the returned list. If a non-header line ends the headers,
- (which is an error), an attempt is made to backspace over it; it is
- never included in the returned list.
-
- The variable self.status is set to the empty string if all went well,
- otherwise it is an error message. The variable self.headers is a
- completely uninterpreted list of lines contained in the header (so
- printing them will reproduce the header exactly as it appears in the
- file).
-
- If multiple header fields with the same name occur, they are combined
- according to the rules in RFC 2616 sec 4.2:
-
- Appending each subsequent field-value to the first, each separated
- by a comma. The order in which header fields with the same field-name
- are received is significant to the interpretation of the combined
- field value.
"""
- # XXX The implementation overrides the readheaders() method of
- # rfc822.Message. The base class design isn't amenable to
- # customized behavior here so the method here is a copy of the
- # base class code with a few small changes.
-
- self.dict = {}
- self.unixfrom = ''
- self.headers = hlist = []
- self.status = ''
- headerseen = ""
- firstline = 1
- startofline = unread = tell = None
- if hasattr(self.fp, 'unread'):
- unread = self.fp.unread
- elif self.seekable:
- tell = self.fp.tell
- while True:
- if tell:
- try:
- startofline = tell()
- except IOError:
- startofline = tell = None
- self.seekable = 0
- line = self.fp.readline(_MAXLINE + 1)
- if len(line) > _MAXLINE:
- raise LineTooLong("header line")
- if not line:
- self.status = 'EOF in headers'
- break
- # Skip unix From name time lines
- if firstline and line.startswith('From '):
- self.unixfrom = self.unixfrom + line
- continue
- firstline = 0
- if headerseen and line[0] in ' \t':
- # XXX Not sure if continuation lines are handled properly
- # for http and/or for repeating headers
- # It's a continuation line.
- hlist.append(line)
- self.addcontinue(headerseen, line.strip())
- continue
- elif self.iscomment(line):
- # It's a comment. Ignore it.
- continue
- elif self.islast(line):
- # Note! No pushback here! The delimiter line gets eaten.
- break
- headerseen = self.isheader(line)
- if headerseen:
- # It's a legal header line, save it.
- hlist.append(line)
- self.addheader(headerseen, line[len(headerseen)+1:].strip())
- continue
- else:
- # It's not a header line; throw it back and stop here.
- if not self.dict:
- self.status = 'No headers'
- else:
- self.status = 'Non-header line where header expected'
- # Try to undo the read.
- if unread:
- unread(line)
- elif tell:
- self.fp.seek(startofline)
- else:
- self.status = self.status + '; bad seek'
- break
+ name = name.lower() + ':'
+ n = len(name)
+ lst = []
+ hit = 0
+ for line in self.keys():
+ if line[:n].lower() == name:
+ hit = 1
+ elif not line[:1].isspace():
+ hit = 0
+ if hit:
+ lst.append(line)
+ return lst
+
+def parse_headers(fp, _class=HTTPMessage):
+ """Parses only RFC2822 headers from a file pointer.
+
+ email Parser wants to see strings rather than bytes.
+ But a TextIOWrapper around self.rfile would buffer too many bytes
+ from the stream, bytes which we later need to read as bytes.
+ So we read the correct bytes here, as bytes, for email Parser
+ to parse.
+
+ """
+ headers = []
+ while True:
+ line = fp.readline(_MAXLINE + 1)
+ if len(line) > _MAXLINE:
+ raise LineTooLong("header line")
+ headers.append(line)
+ if line in (b'\r\n', b'\n', b''):
+ break
+ hstring = b''.join(headers).decode('iso-8859-1')
+ return email.parser.Parser(_class=_class).parsestr(hstring)
-class HTTPResponse:
- # strict: If true, raise BadStatusLine if the status line can't be
- # parsed as a valid HTTP/1.0 or 1.1 status line. By default it is
- # false because it prevents clients from talking to HTTP/0.9
- # servers. Note that a response with a sufficiently corrupted
- # status line will look like an HTTP/0.9 response.
+_strict_sentinel = object()
+
+class HTTPResponse(io.RawIOBase):
# See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details.
- def __init__(self, sock, debuglevel=0, strict=0, method=None, buffering=False):
- if buffering:
- # The caller won't be using any sock.recv() calls, so buffering
- # is fine and recommended for performance.
- self.fp = sock.makefile('rb')
- else:
- # The buffer size is specified as zero, because the headers of
- # the response are read with readline(). If the reads were
- # buffered the readline() calls could consume some of the
- # response, which make be read via a recv() on the underlying
- # socket.
- self.fp = sock.makefile('rb', 0)
+ # The bytes from the socket object are iso-8859-1 strings.
+ # See RFC 2616 sec 2.2 which notes an exception for MIME-encoded
+ # 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):
+ # 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
+ # the server times out and closes the connection. This will
+ # happen if a self.fp.read() is done (without a size) whether
+ # self.fp is buffered or not. So, no self.fp.read() by
+ # clients unless they know what they are doing.
+ self.fp = sock.makefile("rb")
self.debuglevel = debuglevel
- self.strict = strict
+ 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
- self.msg = None
+ # The HTTPResponse object is returned via urllib. The clients
+ # of http and urllib expect different attributes for the
+ # headers. headers is used here and supports urllib. msg is
+ # provided as a backwards compatibility layer for http
+ # clients.
+
+ self.headers = self.msg = None
# from the Status-Line of the response
self.version = _UNKNOWN # HTTP-Version
@@ -361,34 +305,27 @@ class HTTPResponse:
self.will_close = _UNKNOWN # conn will close at end of response
def _read_status(self):
- # Initialize with Simple-Response defaults
- line = self.fp.readline(_MAXLINE + 1)
+ line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
if len(line) > _MAXLINE:
- raise LineTooLong("header line")
+ raise LineTooLong("status line")
if self.debuglevel > 0:
- print "reply:", repr(line)
+ print("reply:", repr(line))
if not line:
# Presumably, the server closed the connection before
# sending a valid response.
raise BadStatusLine(line)
try:
- [version, status, reason] = line.split(None, 2)
+ version, status, reason = line.split(None, 2)
except ValueError:
try:
- [version, status] = line.split(None, 1)
+ version, status = line.split(None, 1)
reason = ""
except ValueError:
- # empty version will cause next test to fail and status
- # will be treated as 0.9 response.
+ # empty version will cause next test to fail.
version = ""
- if not version.startswith('HTTP/'):
- if self.strict:
- self.close()
- raise BadStatusLine(line)
- else:
- # assume it's a Simple-Response from an 0.9 server
- self.fp = LineAndFileWrapper(line, self.fp)
- return "HTTP/0.9", 200, ""
+ if not version.startswith("HTTP/"):
+ self.close()
+ raise BadStatusLine(line)
# The status code is a three-digit number
try:
@@ -400,7 +337,7 @@ class HTTPResponse:
return version, status, reason
def begin(self):
- if self.msg is not None:
+ if self.headers is not None:
# we've already started reading the response
return
@@ -418,48 +355,42 @@ class HTTPResponse:
if not skip:
break
if self.debuglevel > 0:
- print "header:", skip
+ print("header:", skip)
- self.status = status
+ self.code = self.status = status
self.reason = reason.strip()
- if version == 'HTTP/1.0':
+ if version in ("HTTP/1.0", "HTTP/0.9"):
+ # Some servers might still return "0.9", treat it as 1.0 anyway
self.version = 10
- elif version.startswith('HTTP/1.'):
+ elif version.startswith("HTTP/1."):
self.version = 11 # use HTTP/1.1 code for HTTP/1.x where x>=1
- elif version == 'HTTP/0.9':
- self.version = 9
else:
raise UnknownProtocol(version)
- if self.version == 9:
- self.length = None
- self.chunked = 0
- self.will_close = 1
- self.msg = HTTPMessage(StringIO())
- return
+ self.headers = self.msg = parse_headers(self.fp)
- self.msg = HTTPMessage(self.fp, 0)
if self.debuglevel > 0:
- for hdr in self.msg.headers:
- print "header:", hdr,
-
- # don't let the msg keep an fp
- self.msg.fp = None
+ for hdr in self.headers:
+ print("header:", hdr, end=" ")
# are we using the chunked-style of transfer encoding?
- tr_enc = self.msg.getheader('transfer-encoding')
+ tr_enc = self.headers.get("transfer-encoding")
if tr_enc and tr_enc.lower() == "chunked":
- self.chunked = 1
+ self.chunked = True
self.chunk_left = None
else:
- self.chunked = 0
+ self.chunked = False
# will the connection close at the end of the response?
self.will_close = self._check_close()
# do we have a Content-Length?
# NOTE: RFC 2616, S4.4, #3 says we ignore this if tr_enc is "chunked"
- length = self.msg.getheader('content-length')
+ self.length = None
+ length = self.headers.get("content-length")
+
+ # are we using the chunked-style of transfer encoding?
+ tr_enc = self.headers.get("transfer-encoding")
if length and not self.chunked:
try:
self.length = int(length)
@@ -474,23 +405,23 @@ class HTTPResponse:
# does the body have a fixed length? (of zero)
if (status == NO_CONTENT or status == NOT_MODIFIED or
100 <= status < 200 or # 1xx codes
- self._method == 'HEAD'):
+ self._method == "HEAD"):
self.length = 0
# if the connection remains open, and we aren't using chunked, and
# a content-length was not provided, then assume that the connection
# WILL close.
- if not self.will_close and \
- not self.chunked and \
- self.length is None:
- self.will_close = 1
+ if (not self.will_close and
+ not self.chunked and
+ self.length is None):
+ self.will_close = True
def _check_close(self):
- conn = self.msg.getheader('connection')
+ conn = self.headers.get("connection")
if self.version == 11:
# An HTTP/1.1 proxy is assumed to stay open unless
# explicitly closed.
- conn = self.msg.getheader('connection')
+ conn = self.headers.get("connection")
if conn and "close" in conn.lower():
return True
return False
@@ -499,7 +430,7 @@ class HTTPResponse:
# connections, using rules different than HTTP/1.1.
# For older HTTP, Keep-Alive indicates persistent connection.
- if self.msg.getheader('keep-alive'):
+ if self.headers.get("keep-alive"):
return False
# At least Akamai returns a "Connection: Keep-Alive" header,
@@ -508,7 +439,7 @@ class HTTPResponse:
return False
# Proxy-Connection is a netscape hack.
- pconn = self.msg.getheader('proxy-connection')
+ pconn = self.headers.get("proxy-connection")
if pconn and "keep-alive" in pconn.lower():
return False
@@ -520,6 +451,23 @@ class HTTPResponse:
self.fp.close()
self.fp = None
+ # These implementations are for the benefit of io.BufferedReader.
+
+ # XXX This class should probably be revised to act more like
+ # the "raw stream" that BufferedReader expects.
+
+ @property
+ def closed(self):
+ return self.isclosed()
+
+ def flush(self):
+ self.fp.flush()
+
+ def readable(self):
+ return True
+
+ # End of "raw stream" methods
+
def isclosed(self):
# NOTE: it is possible that we will not ever call self.close(). This
# case occurs when will_close is TRUE, length is None, and we
@@ -529,15 +477,13 @@ class HTTPResponse:
# called, meaning self.isclosed() is meaningful.
return self.fp is None
- # XXX It would be nice to have readline and __iter__ for this, too.
-
def read(self, amt=None):
if self.fp is None:
- return ''
+ return b""
- if self._method == 'HEAD':
+ if self._method == "HEAD":
self.close()
- return ''
+ return b""
if self.chunked:
return self._read_chunked(amt)
@@ -580,7 +526,7 @@ class HTTPResponse:
line = self.fp.readline(_MAXLINE + 1)
if len(line) > _MAXLINE:
raise LineTooLong("chunk size")
- i = line.find(';')
+ i = line.find(b";")
if i >= 0:
line = line[:i] # strip chunk-extensions
try:
@@ -589,7 +535,7 @@ class HTTPResponse:
# close the connection as protocol synchronisation is
# probably lost
self.close()
- raise IncompleteRead(''.join(value))
+ raise IncompleteRead(b''.join(value))
if chunk_left == 0:
break
if amt is None:
@@ -597,12 +543,12 @@ class HTTPResponse:
elif amt < chunk_left:
value.append(self._safe_read(amt))
self.chunk_left = chunk_left - amt
- return ''.join(value)
+ return b''.join(value)
elif amt == chunk_left:
value.append(self._safe_read(amt))
self._safe_read(2) # toss the CRLF at the end of the chunk
self.chunk_left = None
- return ''.join(value)
+ return b''.join(value)
else:
value.append(self._safe_read(chunk_left))
amt -= chunk_left
@@ -621,13 +567,13 @@ class HTTPResponse:
# a vanishingly small number of sites EOF without
# sending the trailer
break
- if line == '\r\n':
+ if line in (b'\r\n', b'\n', b''):
break
# we read everything; close the "file"
self.close()
- return ''.join(value)
+ return b''.join(value)
def _safe_read(self, amt):
"""Read the number of bytes requested, compensating for partial reads.
@@ -643,34 +589,48 @@ class HTTPResponse:
reading. If the bytes are truly not available (due to EOF), then the
IncompleteRead exception can be used to detect the problem.
"""
- # NOTE(gps): As of svn r74426 socket._fileobject.read(x) will never
- # return less than x bytes unless EOF is encountered. It now handles
- # signal interruptions (socket.error EINTR) internally. This code
- # never caught that exception anyways. It seems largely pointless.
- # self.fp.read(amt) will work fine.
s = []
while amt > 0:
chunk = self.fp.read(min(amt, MAXAMOUNT))
if not chunk:
- raise IncompleteRead(''.join(s), amt)
+ raise IncompleteRead(b''.join(s), amt)
s.append(chunk)
amt -= len(chunk)
- return ''.join(s)
+ return b"".join(s)
def fileno(self):
return self.fp.fileno()
def getheader(self, name, default=None):
- if self.msg is None:
+ if self.headers is None:
raise ResponseNotReady()
- return self.msg.getheader(name, default)
+ headers = self.headers.get_all(name) or default
+ if isinstance(headers, str) or not hasattr(headers, '__iter__'):
+ return headers
+ else:
+ return ', '.join(headers)
def getheaders(self):
"""Return list of (header, value) tuples."""
- if self.msg is None:
+ if self.headers is None:
raise ResponseNotReady()
- return self.msg.items()
+ return list(self.headers.items())
+
+ # We override IOBase.__iter__ so that it doesn't check for closed-ness
+
+ def __iter__(self):
+ return self
+
+ # For compatibility with old-style urllib responses.
+
+ def info(self):
+ return self.headers
+
+ def geturl(self):
+ return self.url
+ def getcode(self):
+ return self.status
class HTTPConnection:
@@ -681,10 +641,13 @@ class HTTPConnection:
default_port = HTTP_PORT
auto_open = 1
debuglevel = 0
- strict = 0
- def __init__(self, host, port=None, strict=None,
+ def __init__(self, host, port=None, strict=_strict_sentinel,
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
@@ -697,8 +660,6 @@ class HTTPConnection:
self._tunnel_headers = {}
self._set_hostport(host, port)
- if strict is not None:
- self.strict = strict
def set_tunnel(self, host, port=None, headers=None):
""" Sets up the host and the port for the HTTP CONNECT Tunnelling.
@@ -721,7 +682,7 @@ class HTTPConnection:
try:
port = int(host[i+1:])
except ValueError:
- if host[i+1:] == "": # http://foo.com:/ == http://foo.com/
+ if host[i+1:] == "": # http://foo.com:/ == http://foo.com/
port = self.default_port
else:
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
@@ -738,12 +699,16 @@ class HTTPConnection:
def _tunnel(self):
self._set_hostport(self._tunnel_host, self._tunnel_port)
- self.send("CONNECT %s:%d HTTP/1.0\r\n" % (self.host, self.port))
- for header, value in self._tunnel_headers.iteritems():
- self.send("%s: %s\r\n" % (header, value))
- self.send("\r\n")
- response = self.response_class(self.sock, strict = self.strict,
- method = self._method)
+ connect_str = "CONNECT %s:%d HTTP/1.0\r\n" % (self.host, self.port)
+ connect_bytes = connect_str.encode("ascii")
+ self.send(connect_bytes)
+ for header, value in self._tunnel_headers.items():
+ header_str = "%s: %s\r\n" % (header, value)
+ header_bytes = header_str.encode("latin1")
+ self.send(header_bytes)
+ self.send(b'\r\n')
+
+ response = self.response_class(self.sock, method=self._method)
(version, code, message) = response._read_status()
if code != 200:
@@ -755,17 +720,15 @@ class HTTPConnection:
if len(line) > _MAXLINE:
raise LineTooLong("header line")
if not line:
- # for sites which EOF without sending trailer
+ # for sites which EOF without sending a trailer
break
- if line == '\r\n':
+ if line in (b'\r\n', b'\n', b''):
break
-
def connect(self):
"""Connect to the host and port specified in __init__."""
self.sock = socket.create_connection((self.host,self.port),
self.timeout, self.source_address)
-
if self._tunnel_host:
self._tunnel()
@@ -780,7 +743,11 @@ class HTTPConnection:
self.__state = _CS_IDLE
def send(self, data):
- """Send `data' to the server."""
+ """Send `data' to the server.
+ ``data`` can be a string object, a bytes object, an array object, a
+ file-like object that supports a .read() method, or an iterable object.
+ """
+
if self.sock is None:
if self.auto_open:
self.connect()
@@ -788,16 +755,40 @@ class HTTPConnection:
raise NotConnected()
if self.debuglevel > 0:
- print "send:", repr(data)
+ print("send:", repr(data))
blocksize = 8192
- if hasattr(data,'read') and not isinstance(data, array):
- if self.debuglevel > 0: print "sendIng a read()able"
- datablock = data.read(blocksize)
- while datablock:
- self.sock.sendall(datablock)
+ if hasattr(data, "read") :
+ if self.debuglevel > 0:
+ print("sendIng a read()able")
+ encode = False
+ try:
+ mode = data.mode
+ except AttributeError:
+ # io.BytesIO and other file-like objects don't have a `mode`
+ # attribute.
+ pass
+ else:
+ if "b" not in mode:
+ encode = True
+ if self.debuglevel > 0:
+ print("encoding file using iso-8859-1")
+ while 1:
datablock = data.read(blocksize)
- else:
+ if not datablock:
+ break
+ if encode:
+ datablock = datablock.encode("iso-8859-1")
+ self.sock.sendall(datablock)
+
+ try:
self.sock.sendall(data)
+ except TypeError:
+ if isinstance(data, collections.Iterable):
+ for d in data:
+ self.sock.sendall(d)
+ else:
+ raise TypeError("data should be a bytes-like object "
+ "or an iterable, got %r" % type(data))
def _output(self, s):
"""Add a line of output to the current request buffer.
@@ -812,19 +803,19 @@ class HTTPConnection:
Appends an extra \\r\\n to the buffer.
A message_body may be specified, to be appended to the request.
"""
- self._buffer.extend(("", ""))
- msg = "\r\n".join(self._buffer)
+ self._buffer.extend((b"", b""))
+ msg = b"\r\n".join(self._buffer)
del self._buffer[:]
# If msg and message_body are sent in a single send() call,
# it will avoid performance problems caused by the interaction
# between delayed ack and the Nagle algorithm.
- if isinstance(message_body, str):
+ if isinstance(message_body, bytes):
msg += message_body
message_body = None
self.send(msg)
if message_body is not None:
- #message_body was not a string (i.e. it is a file) and
- #we must run the risk of Nagle
+ # message_body was not a string (i.e. it is a file), and
+ # we must run the risk of Nagle.
self.send(message_body)
def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
@@ -863,15 +854,16 @@ class HTTPConnection:
if self.__state == _CS_IDLE:
self.__state = _CS_REQ_STARTED
else:
- raise CannotSendRequest()
+ raise CannotSendRequest(self.__state)
# Save the method we use, we need it later in the response phase
self._method = method
if not url:
url = '/'
- hdr = '%s %s %s' % (method, url, self._http_vsn_str)
+ request = '%s %s %s' % (method, url, self._http_vsn_str)
- self._output(hdr)
+ # Non-ASCII characters should have been eliminated earlier
+ self._output(request.encode('ascii'))
if self._http_vsn == 11:
# Issue some standard headers for better HTTP/1.1 compliance
@@ -906,12 +898,17 @@ class HTTPConnection:
host_enc = self.host.encode("ascii")
except UnicodeEncodeError:
host_enc = self.host.encode("idna")
- # Wrap the IPv6 Host Header with [] (RFC 2732)
- if host_enc.find(':') >= 0:
- host_enc = "[" + host_enc + "]"
+
+ # As per RFC 273, IPv6 address should be wrapped with []
+ # when used as Host header
+
+ if self.host.find(':') >= 0:
+ host_enc = b'[' + host_enc + b']'
+
if self.port == self.default_port:
self.putheader('Host', host_enc)
else:
+ host_enc = host_enc.decode("ascii")
self.putheader('Host', "%s:%s" % (host_enc, self.port))
# note: we are assuming that clients will not attempt to set these
@@ -945,17 +942,26 @@ class HTTPConnection:
if self.__state != _CS_REQ_STARTED:
raise CannotSendHeader()
- hdr = '%s: %s' % (header, '\r\n\t'.join([str(v) for v in values]))
- self._output(hdr)
+ if hasattr(header, 'encode'):
+ header = header.encode('ascii')
+ values = list(values)
+ for i, one_value in enumerate(values):
+ if hasattr(one_value, 'encode'):
+ values[i] = one_value.encode('latin1')
+ elif isinstance(one_value, int):
+ values[i] = str(one_value).encode('ascii')
+ value = b'\r\n\t'.join(values)
+ header = header + b': ' + value
+ self._output(header)
def endheaders(self, message_body=None):
"""Indicate that the last header line has been sent to the server.
- This method sends the request to the server. The optional
- message_body argument can be used to pass a message body
- associated with the request. The message body will be sent in
- the same packet as the message headers if it is string, otherwise it is
- sent as a separate packet.
+ This method sends the request to the server. The optional message_body
+ argument can be used to pass a message body associated with the
+ request. The message body will be sent in the same packet as the
+ message headers if it is a string, otherwise it is sent as a separate
+ packet.
"""
if self.__state == _CS_REQ_STARTED:
self.__state = _CS_REQ_SENT
@@ -972,14 +978,14 @@ class HTTPConnection:
thelen = None
try:
thelen = str(len(body))
- except TypeError, te:
+ except TypeError as te:
# If this is a file-like object, try to
# fstat its file descriptor
try:
thelen = str(os.fstat(body.fileno()).st_size)
except (AttributeError, OSError):
# Don't send a length if this failed
- if self.debuglevel > 0: print "Cannot stat!!"
+ if self.debuglevel > 0: print("Cannot stat!!")
if thelen is not None:
self.putheader('Content-Length', thelen)
@@ -995,20 +1001,34 @@ class HTTPConnection:
self.putrequest(method, url, **skips)
- if body is not None and 'content-length' not in header_names:
+ if body is not None and ('content-length' not in header_names):
self._set_content_length(body)
- for hdr, value in headers.iteritems():
+ for hdr, value in headers.items():
self.putheader(hdr, value)
+ if isinstance(body, str):
+ # RFC 2616 Section 3.7.1 says that text default has a
+ # default charset of iso-8859-1.
+ body = body.encode('iso-8859-1')
self.endheaders(body)
- def getresponse(self, buffering=False):
- "Get the response from the server."
+ def getresponse(self):
+ """Get the response from the server.
+
+ If the HTTPConnection is in the correct state, returns an
+ instance of HTTPResponse or of whatever object is returned by
+ class the response_class variable.
+
+ If a request has not been sent or if a previous response has
+ not be handled, ResponseNotReady is raised. If the HTTP
+ response indicates that the connection should be closed, then
+ it will be closed before the response is returned. When the
+ connection is closed, the underlying socket is closed.
+ """
# if a prior response has been completed, then forget about it.
if self.__response and self.__response.isclosed():
self.__response = None
- #
# if a prior response exists, then it must be completed (otherwise, we
# cannot read this response's header to determine the connection-close
# behavior)
@@ -1025,17 +1045,13 @@ class HTTPConnection:
# isclosed() status to become true.
#
if self.__state != _CS_REQ_SENT or self.__response:
- raise ResponseNotReady()
+ raise ResponseNotReady(self.__state)
- args = (self.sock,)
- kwds = {"strict":self.strict, "method":self._method}
if self.debuglevel > 0:
- args += (self.debuglevel,)
- if buffering:
- #only add this keyword if non-default, for compatibility with
- #other response_classes.
- kwds["buffering"] = True;
- response = self.response_class(*args, **kwds)
+ response = self.response_class(self.sock, self.debuglevel,
+ method=self._method)
+ else:
+ response = self.response_class(self.sock, method=self._method)
response.begin()
assert response.will_close != _UNKNOWN
@@ -1050,98 +1066,6 @@ class HTTPConnection:
return response
-
-class HTTP:
- "Compatibility class with httplib.py from 1.5."
-
- _http_vsn = 10
- _http_vsn_str = 'HTTP/1.0'
-
- debuglevel = 0
-
- _connection_class = HTTPConnection
-
- def __init__(self, host='', port=None, strict=None):
- "Provide a default host, since the superclass requires one."
-
- # some joker passed 0 explicitly, meaning default port
- if port == 0:
- port = None
-
- # Note that we may pass an empty string as the host; this will raise
- # an error when we attempt to connect. Presumably, the client code
- # will call connect before then, with a proper host.
- self._setup(self._connection_class(host, port, strict))
-
- def _setup(self, conn):
- self._conn = conn
-
- # set up delegation to flesh out interface
- self.send = conn.send
- self.putrequest = conn.putrequest
- self.putheader = conn.putheader
- self.endheaders = conn.endheaders
- self.set_debuglevel = conn.set_debuglevel
-
- conn._http_vsn = self._http_vsn
- conn._http_vsn_str = self._http_vsn_str
-
- self.file = None
-
- def connect(self, host=None, port=None):
- "Accept arguments to set the host/port, since the superclass doesn't."
-
- if host is not None:
- self._conn._set_hostport(host, port)
- self._conn.connect()
-
- def getfile(self):
- "Provide a getfile, since the superclass' does not use this concept."
- return self.file
-
- def getreply(self, buffering=False):
- """Compat definition since superclass does not define it.
-
- Returns a tuple consisting of:
- - server status code (e.g. '200' if all goes well)
- - server "reason" corresponding to status code
- - any RFC822 headers in the response from the server
- """
- try:
- if not buffering:
- response = self._conn.getresponse()
- else:
- #only add this keyword if non-default for compatibility
- #with other connection classes
- response = self._conn.getresponse(buffering)
- except BadStatusLine, e:
- ### hmm. if getresponse() ever closes the socket on a bad request,
- ### then we are going to have problems with self.sock
-
- ### should we keep this behavior? do people use it?
- # keep the socket open (as a file), and return it
- self.file = self._conn.sock.makefile('rb', 0)
-
- # close our socket -- we want to restart after any protocol error
- self.close()
-
- self.headers = None
- return -1, e.line, None
-
- self.headers = response.msg
- self.file = response.fp
- return response.status, response.reason, response.msg
-
- def close(self):
- self._conn.close()
-
- # note that self.file == response.fp, which gets closed by the
- # superclass. just clear the object ref here.
- ### hmm. messy. if status==-1, then self.file is owned by us.
- ### well... we aren't explicitly closing, but losing this ref will
- ### do it
- self.file = None
-
try:
import ssl
except ImportError:
@@ -1152,58 +1076,52 @@ else:
default_port = HTTPS_PORT
+ # 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=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
- source_address=None):
- HTTPConnection.__init__(self, host, port, strict, timeout,
- source_address)
+ strict=_strict_sentinel, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ source_address=None, *, context=None, check_hostname=None):
+ super(HTTPSConnection, self).__init__(host, port, strict, timeout,
+ source_address)
self.key_file = key_file
self.cert_file = cert_file
+ if context is None:
+ # Some reasonable defaults
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.options |= ssl.OP_NO_SSLv2
+ will_verify = context.verify_mode != ssl.CERT_NONE
+ if check_hostname is None:
+ check_hostname = will_verify
+ elif check_hostname and not will_verify:
+ raise ValueError("check_hostname needs a SSL context with "
+ "either CERT_OPTIONAL or CERT_REQUIRED")
+ if key_file or cert_file:
+ context.load_cert_chain(cert_file, key_file)
+ self._context = context
+ self._check_hostname = check_hostname
def connect(self):
"Connect to a host on a given (SSL) port."
sock = socket.create_connection((self.host, self.port),
self.timeout, self.source_address)
+
if self._tunnel_host:
self.sock = sock
self._tunnel()
- self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
-
- __all__.append("HTTPSConnection")
-
- class HTTPS(HTTP):
- """Compatibility with 1.5 httplib interface
-
- Python 1.5.2 did not have an HTTPS class, but it defined an
- interface for sending http requests that is also useful for
- https.
- """
-
- _connection_class = HTTPSConnection
-
- def __init__(self, host='', port=None, key_file=None, cert_file=None,
- strict=None):
- # provide a default host, pass the X509 cert info
-
- # urf. compensate for bad input.
- if port == 0:
- port = None
- self._setup(self._connection_class(host, port, key_file,
- cert_file, strict))
-
- # we never actually use these for anything, but we keep them
- # here for compatibility with post-1.5.2 CVS.
- self.key_file = key_file
- self.cert_file = cert_file
-
- def FakeSocket (sock, sslobj):
- warnings.warn("FakeSocket is deprecated, and won't be in 3.x. " +
- "Use the result of ssl.wrap_socket() directly instead.",
- DeprecationWarning, stacklevel=2)
- return sslobj
+ server_hostname = self.host if ssl.HAS_SNI else None
+ self.sock = self._context.wrap_socket(sock,
+ server_hostname=server_hostname)
+ try:
+ if self._check_hostname:
+ ssl.match_hostname(self.sock.getpeercert(), self.host)
+ except Exception:
+ self.sock.shutdown(socket.SHUT_RDWR)
+ self.sock.close()
+ raise
+ __all__.append("HTTPSConnection")
class HTTPException(Exception):
# Subclasses that define an __init__ must call Exception.__init__
@@ -1267,71 +1185,3 @@ class LineTooLong(HTTPException):
# for backwards compatibility
error = HTTPException
-
-class LineAndFileWrapper:
- """A limited file-like object for HTTP/0.9 responses."""
-
- # The status-line parsing code calls readline(), which normally
- # get the HTTP status line. For a 0.9 response, however, this is
- # actually the first line of the body! Clients need to get a
- # readable file object that contains that line.
-
- def __init__(self, line, file):
- self._line = line
- self._file = file
- self._line_consumed = 0
- self._line_offset = 0
- self._line_left = len(line)
-
- def __getattr__(self, attr):
- return getattr(self._file, attr)
-
- def _done(self):
- # called when the last byte is read from the line. After the
- # call, all read methods are delegated to the underlying file
- # object.
- self._line_consumed = 1
- self.read = self._file.read
- self.readline = self._file.readline
- self.readlines = self._file.readlines
-
- def read(self, amt=None):
- if self._line_consumed:
- return self._file.read(amt)
- assert self._line_left
- if amt is None or amt > self._line_left:
- s = self._line[self._line_offset:]
- self._done()
- if amt is None:
- return s + self._file.read()
- else:
- return s + self._file.read(amt - len(s))
- else:
- assert amt <= self._line_left
- i = self._line_offset
- j = i + amt
- s = self._line[i:j]
- self._line_offset = j
- self._line_left -= amt
- if self._line_left == 0:
- self._done()
- return s
-
- def readline(self):
- if self._line_consumed:
- return self._file.readline()
- assert self._line_left
- s = self._line[self._line_offset:]
- self._done()
- return s
-
- def readlines(self, size=None):
- if self._line_consumed:
- return self._file.readlines(size)
- assert self._line_left
- L = [self._line[self._line_offset:]]
- self._done()
- if size is None:
- return L + self._file.readlines()
- else:
- return L + self._file.readlines(size)
diff --git a/Lib/cookielib.py b/Lib/http/cookiejar.py
index f9c8d2f84bd..b6cfc355c96 100644
--- a/Lib/cookielib.py
+++ b/Lib/http/cookiejar.py
@@ -26,15 +26,18 @@ http://wwwsearch.sf.net/):
"""
__all__ = ['Cookie', 'CookieJar', 'CookiePolicy', 'DefaultCookiePolicy',
- 'FileCookieJar', 'LWPCookieJar', 'lwp_cookie_str', 'LoadError',
- 'MozillaCookieJar']
+ 'FileCookieJar', 'LWPCookieJar', 'LoadError', 'MozillaCookieJar']
-import re, urlparse, copy, time, urllib
+import copy
+import datetime
+import re
+import time
+import urllib.parse, urllib.request
try:
import threading as _threading
except ImportError:
import dummy_threading as _threading
-import httplib # only for the default HTTP port
+import http.client # only for the default HTTP port
from calendar import timegm
debug = False # set to True to enable debugging via the logging module
@@ -46,11 +49,11 @@ def _debug(*args):
global logger
if not logger:
import logging
- logger = logging.getLogger("cookielib")
+ logger = logging.getLogger("http.cookiejar")
return logger.debug(*args)
-DEFAULT_HTTP_PORT = str(httplib.HTTP_PORT)
+DEFAULT_HTTP_PORT = str(http.client.HTTP_PORT)
MISSING_FILENAME_TEXT = ("a filename was not supplied (nor was the CookieJar "
"instance initialised with one)")
@@ -58,11 +61,11 @@ def _warn_unhandled_exception():
# There are a few catch-all except: statements in this module, for
# catching input that's bad in unexpected ways. Warn if any
# exceptions are caught there.
- import warnings, traceback, StringIO
- f = StringIO.StringIO()
+ import io, warnings, traceback
+ f = io.StringIO()
traceback.print_exc(None, f)
msg = f.getvalue()
- warnings.warn("cookielib bug!\n%s" % msg, stacklevel=2)
+ warnings.warn("http.cookiejar bug!\n%s" % msg, stacklevel=2)
# Date/time conversion
@@ -95,10 +98,12 @@ def time2isoz(t=None):
1994-11-24 08:49:37Z
"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec = time.gmtime(t)[:6]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
- year, mon, mday, hour, min, sec)
+ dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
def time2netscape(t=None):
"""Return a string representing time in seconds since epoch, t.
@@ -111,15 +116,18 @@ def time2netscape(t=None):
Wed, DD-Mon-YYYY HH:MM:SS GMT
"""
- if t is None: t = time.time()
- year, mon, mday, hour, min, sec, wday = time.gmtime(t)[:7]
+ if t is None:
+ dt = datetime.datetime.utcnow()
+ else:
+ dt = datetime.datetime.utcfromtimestamp(t)
return "%s %02d-%s-%04d %02d:%02d:%02d GMT" % (
- DAYS[wday], mday, MONTHS[mon-1], year, hour, min, sec)
+ DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
+ dt.year, dt.hour, dt.minute, dt.second)
UTC_ZONES = {"GMT": None, "UTC": None, "UT": None, "Z": None}
-TIMEZONE_RE = re.compile(r"^([-+])?(\d\d?):?(\d\d)?$")
+TIMEZONE_RE = re.compile(r"^([-+])?(\d\d?):?(\d\d)?$", re.ASCII)
def offset_from_tz_string(tz):
offset = None
if tz in UTC_ZONES:
@@ -189,9 +197,9 @@ def _str2time(day, mon, yr, hr, min, sec, tz):
STRICT_DATE_RE = re.compile(
r"^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) "
- "(\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$")
+ "(\d\d\d\d) (\d\d):(\d\d):(\d\d) GMT$", re.ASCII)
WEEKDAY_RE = re.compile(
- r"^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*", re.I)
+ r"^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*", re.I | re.ASCII)
LOOSE_HTTP_DATE_RE = re.compile(
r"""^
(\d\d?) # day
@@ -208,7 +216,7 @@ LOOSE_HTTP_DATE_RE = re.compile(
([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+)? # timezone
\s*
(?:\(\w+\))? # ASCII representation of timezone in parens.
- \s*$""", re.X)
+ \s*$""", re.X | re.ASCII)
def http2time(text):
"""Returns time in seconds since epoch of time represented by a string.
@@ -280,7 +288,7 @@ ISO_DATE_RE = re.compile(
\s*
([-+]?\d\d?:?(:?\d\d)?
|Z|z)? # timezone (Z is "zero meridian", i.e. GMT)
- \s*$""", re.X)
+ \s*$""", re.X | re. ASCII)
def iso2time(text):
"""
As for http2time, but parses the ISO 8601 formats:
@@ -368,7 +376,7 @@ def split_header_words(header_values):
[[('Basic', None), ('realm', '"foobar"')]]
"""
- assert not isinstance(header_values, basestring)
+ assert not isinstance(header_values, str)
result = []
for text in header_values:
orig_text = text
@@ -434,7 +442,7 @@ def join_header_words(lists):
if attr: headers.append("; ".join(attr))
return ", ".join(headers)
-def _strip_quotes(text):
+def strip_quotes(text):
if text.startswith('"'):
text = text[1:]
if text.endswith('"'):
@@ -478,11 +486,11 @@ def parse_ns_headers(ns_headers):
k = lc
if k == "version":
# This is an RFC 2109 cookie.
- v = _strip_quotes(v)
+ v = strip_quotes(v)
version_set = True
if k == "expires":
# convert expires date to seconds since epoch
- v = http2time(_strip_quotes(v)) # None if invalid
+ v = http2time(strip_quotes(v)) # None if invalid
pairs.append((k, v))
if pairs:
@@ -493,7 +501,7 @@ def parse_ns_headers(ns_headers):
return result
-IPV4_RE = re.compile(r"\.\d+$")
+IPV4_RE = re.compile(r"\.\d+$", re.ASCII)
def is_HDN(text):
"""Return True if text is a host domain name."""
# XXX
@@ -578,7 +586,7 @@ def user_domain_match(A, B):
return True
return False
-cut_port_re = re.compile(r":\d+$")
+cut_port_re = re.compile(r":\d+$", re.ASCII)
def request_host(request):
"""Return request-host, as defined by RFC 2965.
@@ -587,7 +595,7 @@ def request_host(request):
"""
url = request.get_full_url()
- host = urlparse.urlparse(url)[1]
+ host = urllib.parse.urlparse(url)[1]
if host == "":
host = request.get_header("Host", "")
@@ -609,7 +617,7 @@ def eff_request_host(request):
def request_path(request):
"""Path component of request-URI, as defined by RFC 2965."""
url = request.get_full_url()
- parts = urlparse.urlsplit(url)
+ parts = urllib.parse.urlsplit(url)
path = escape_path(parts.path)
if not path.startswith("/"):
# fix bad RFC 2396 absoluteURI
@@ -646,9 +654,7 @@ def escape_path(path):
# And here, kind of: draft-fielding-uri-rfc2396bis-03
# (And in draft IRI specification: draft-duerst-iri-05)
# (And here, for new URI schemes: RFC 2718)
- if isinstance(path, unicode):
- path = path.encode("utf-8")
- path = urllib.quote(path, HTTP_PATH_SAFE)
+ path = urllib.parse.quote(path, HTTP_PATH_SAFE)
path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
return path
@@ -1173,8 +1179,7 @@ class DefaultCookiePolicy(CookiePolicy):
def vals_sorted_by_key(adict):
- keys = adict.keys()
- keys.sort()
+ keys = sorted(adict.keys())
return map(adict.get, keys)
def deepvalues(mapping):
@@ -1202,8 +1207,7 @@ class CookieJar:
"""Collection of HTTP cookies.
You may not need to know about this class: try
- urllib2.build_opener(HTTPCookieProcessor).open(url).
-
+ urllib.request.build_opener(HTTPCookieProcessor).open(url).
"""
non_word_re = re.compile(r"\W")
@@ -1212,7 +1216,7 @@ class CookieJar:
domain_re = re.compile(r"[^.]*")
dots_re = re.compile(r"^\.+")
- magic_re = r"^\#LWP-Cookies-(\d+\.\d+)"
+ magic_re = re.compile(r"^\#LWP-Cookies-(\d+\.\d+)", re.ASCII)
def __init__(self, policy=None):
if policy is None:
@@ -1260,7 +1264,7 @@ class CookieJar:
"""
# add cookies in order of most specific (ie. longest) path first
- cookies.sort(key=lambda arg: len(arg.path), reverse=True)
+ cookies.sort(key=lambda a: len(a.path), reverse=True)
version_set = False
@@ -1310,7 +1314,7 @@ class CookieJar:
return attrs
def add_cookie_header(self, request):
- """Add correct Cookie: header to request (urllib2.Request object).
+ """Add correct Cookie: header to request (urllib.request.Request object).
The Cookie2 header is also added unless policy.hide_cookie2 is true.
@@ -1556,8 +1560,8 @@ class CookieJar:
"""Return sequence of Cookie objects extracted from response object."""
# get cookie-attributes for RFC 2965 and Netscape protocols
headers = response.info()
- rfc2965_hdrs = headers.getheaders("Set-Cookie2")
- ns_hdrs = headers.getheaders("Set-Cookie")
+ rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
+ ns_hdrs = headers.get_all("Set-Cookie", [])
rfc2965 = self._policy.rfc2965
netscape = self._policy.netscape
@@ -1790,5 +1794,298 @@ class FileCookieJar(CookieJar):
finally:
self._cookies_lock.release()
-from _LWPCookieJar import LWPCookieJar, lwp_cookie_str
-from _MozillaCookieJar import MozillaCookieJar
+
+def lwp_cookie_str(cookie):
+ """Return string representation of Cookie in an the LWP cookie file format.
+
+ Actually, the format is extended a bit -- see module docstring.
+
+ """
+ h = [(cookie.name, cookie.value),
+ ("path", cookie.path),
+ ("domain", cookie.domain)]
+ if cookie.port is not None: h.append(("port", cookie.port))
+ if cookie.path_specified: h.append(("path_spec", None))
+ if cookie.port_specified: h.append(("port_spec", None))
+ if cookie.domain_initial_dot: h.append(("domain_dot", None))
+ if cookie.secure: h.append(("secure", None))
+ if cookie.expires: h.append(("expires",
+ time2isoz(float(cookie.expires))))
+ if cookie.discard: h.append(("discard", None))
+ if cookie.comment: h.append(("comment", cookie.comment))
+ if cookie.comment_url: h.append(("commenturl", cookie.comment_url))
+
+ keys = sorted(cookie._rest.keys())
+ for k in keys:
+ h.append((k, str(cookie._rest[k])))
+
+ h.append(("version", str(cookie.version)))
+
+ return join_header_words([h])
+
+class LWPCookieJar(FileCookieJar):
+ """
+ The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
+ "Set-Cookie3" is the format used by the libwww-perl libary, not known
+ to be compatible with any browser, but which is easy to read and
+ doesn't lose information about RFC 2965 cookies.
+
+ Additional methods
+
+ as_lwp_str(ignore_discard=True, ignore_expired=True)
+
+ """
+
+ def as_lwp_str(self, ignore_discard=True, ignore_expires=True):
+ """Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
+
+ ignore_discard and ignore_expires: see docstring for FileCookieJar.save
+
+ """
+ now = time.time()
+ r = []
+ for cookie in self:
+ if not ignore_discard and cookie.discard:
+ continue
+ if not ignore_expires and cookie.is_expired(now):
+ continue
+ r.append("Set-Cookie3: %s" % lwp_cookie_str(cookie))
+ return "\n".join(r+[""])
+
+ def save(self, filename=None, ignore_discard=False, ignore_expires=False):
+ if filename is None:
+ if self.filename is not None: filename = self.filename
+ else: raise ValueError(MISSING_FILENAME_TEXT)
+
+ f = open(filename, "w")
+ try:
+ # There really isn't an LWP Cookies 2.0 format, but this indicates
+ # that there is extra information in here (domain_dot and
+ # port_spec) while still being compatible with libwww-perl, I hope.
+ f.write("#LWP-Cookies-2.0\n")
+ f.write(self.as_lwp_str(ignore_discard, ignore_expires))
+ finally:
+ f.close()
+
+ def _really_load(self, f, filename, ignore_discard, ignore_expires):
+ magic = f.readline()
+ if not self.magic_re.search(magic):
+ msg = ("%r does not look like a Set-Cookie3 (LWP) format "
+ "file" % filename)
+ raise LoadError(msg)
+
+ now = time.time()
+
+ header = "Set-Cookie3:"
+ boolean_attrs = ("port_spec", "path_spec", "domain_dot",
+ "secure", "discard")
+ value_attrs = ("version",
+ "port", "path", "domain",
+ "expires",
+ "comment", "commenturl")
+
+ try:
+ while 1:
+ line = f.readline()
+ if line == "": break
+ if not line.startswith(header):
+ continue
+ line = line[len(header):].strip()
+
+ for data in split_header_words([line]):
+ name, value = data[0]
+ standard = {}
+ rest = {}
+ for k in boolean_attrs:
+ standard[k] = False
+ for k, v in data[1:]:
+ if k is not None:
+ lc = k.lower()
+ else:
+ lc = None
+ # don't lose case distinction for unknown fields
+ if (lc in value_attrs) or (lc in boolean_attrs):
+ k = lc
+ if k in boolean_attrs:
+ if v is None: v = True
+ standard[k] = v
+ elif k in value_attrs:
+ standard[k] = v
+ else:
+ rest[k] = v
+
+ h = standard.get
+ expires = h("expires")
+ discard = h("discard")
+ if expires is not None:
+ expires = iso2time(expires)
+ if expires is None:
+ discard = True
+ domain = h("domain")
+ domain_specified = domain.startswith(".")
+ c = Cookie(h("version"), name, value,
+ h("port"), h("port_spec"),
+ domain, domain_specified, h("domain_dot"),
+ h("path"), h("path_spec"),
+ h("secure"),
+ expires,
+ discard,
+ h("comment"),
+ h("commenturl"),
+ rest)
+ if not ignore_discard and c.discard:
+ continue
+ if not ignore_expires and c.is_expired(now):
+ continue
+ self.set_cookie(c)
+
+ except IOError:
+ raise
+ except Exception:
+ _warn_unhandled_exception()
+ raise LoadError("invalid Set-Cookie3 format file %r: %r" %
+ (filename, line))
+
+
+class MozillaCookieJar(FileCookieJar):
+ """
+
+ WARNING: you may want to backup your browser's cookies file if you use
+ this class to save cookies. I *think* it works, but there have been
+ bugs in the past!
+
+ This class differs from CookieJar only in the format it uses to save and
+ load cookies to and from a file. This class uses the Mozilla/Netscape
+ `cookies.txt' format. lynx uses this file format, too.
+
+ Don't expect cookies saved while the browser is running to be noticed by
+ the browser (in fact, Mozilla on unix will overwrite your saved cookies if
+ you change them on disk while it's running; on Windows, you probably can't
+ save at all while the browser is running).
+
+ Note that the Mozilla/Netscape format will downgrade RFC2965 cookies to
+ Netscape cookies on saving.
+
+ In particular, the cookie version and port number information is lost,
+ together with information about whether or not Path, Port and Discard were
+ specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
+ domain as set in the HTTP header started with a dot (yes, I'm aware some
+ domains in Netscape files start with a dot and some don't -- trust me, you
+ really don't want to know any more about this).
+
+ Note that though Mozilla and Netscape use the same format, they use
+ slightly different headers. The class saves cookies using the Netscape
+ header by default (Mozilla can cope with that).
+
+ """
+ magic_re = re.compile("#( Netscape)? HTTP Cookie File")
+ header = """\
+# Netscape HTTP Cookie File
+# http://www.netscape.com/newsref/std/cookie_spec.html
+# This is a generated file! Do not edit.
+
+"""
+
+ def _really_load(self, f, filename, ignore_discard, ignore_expires):
+ now = time.time()
+
+ magic = f.readline()
+ if not self.magic_re.search(magic):
+ f.close()
+ raise LoadError(
+ "%r does not look like a Netscape format cookies file" %
+ filename)
+
+ try:
+ while 1:
+ line = f.readline()
+ if line == "": break
+
+ # last field may be absent, so keep any trailing tab
+ if line.endswith("\n"): line = line[:-1]
+
+ # skip comments and blank lines XXX what is $ for?
+ if (line.strip().startswith(("#", "$")) or
+ line.strip() == ""):
+ continue
+
+ domain, domain_specified, path, secure, expires, name, value = \
+ line.split("\t")
+ secure = (secure == "TRUE")
+ domain_specified = (domain_specified == "TRUE")
+ if name == "":
+ # cookies.txt regards 'Set-Cookie: foo' as a cookie
+ # with no name, whereas http.cookiejar regards it as a
+ # cookie with no value.
+ name = value
+ value = None
+
+ initial_dot = domain.startswith(".")
+ assert domain_specified == initial_dot
+
+ discard = False
+ if expires == "":
+ expires = None
+ discard = True
+
+ # assume path_specified is false
+ c = Cookie(0, name, value,
+ None, False,
+ domain, domain_specified, initial_dot,
+ path, False,
+ secure,
+ expires,
+ discard,
+ None,
+ None,
+ {})
+ if not ignore_discard and c.discard:
+ continue
+ if not ignore_expires and c.is_expired(now):
+ continue
+ self.set_cookie(c)
+
+ except IOError:
+ raise
+ except Exception:
+ _warn_unhandled_exception()
+ raise LoadError("invalid Netscape format cookies file %r: %r" %
+ (filename, line))
+
+ def save(self, filename=None, ignore_discard=False, ignore_expires=False):
+ if filename is None:
+ if self.filename is not None: filename = self.filename
+ else: raise ValueError(MISSING_FILENAME_TEXT)
+
+ f = open(filename, "w")
+ try:
+ f.write(self.header)
+ now = time.time()
+ for cookie in self:
+ if not ignore_discard and cookie.discard:
+ continue
+ if not ignore_expires and cookie.is_expired(now):
+ continue
+ if cookie.secure: secure = "TRUE"
+ else: secure = "FALSE"
+ if cookie.domain.startswith("."): initial_dot = "TRUE"
+ else: initial_dot = "FALSE"
+ if cookie.expires is not None:
+ expires = str(cookie.expires)
+ else:
+ expires = ""
+ if cookie.value is None:
+ # cookies.txt regards 'Set-Cookie: foo' as a cookie
+ # with no name, whereas http.cookiejar regards it as a
+ # cookie with no value.
+ name = ""
+ value = cookie.name
+ else:
+ name = cookie.name
+ value = cookie.value
+ f.write(
+ "\t".join([cookie.domain, initial_dot, cookie.path,
+ secure, expires, name, value])+
+ "\n")
+ finally:
+ f.close()
diff --git a/Lib/Cookie.py b/Lib/http/cookies.py
index 2eda48c0bb1..ddbcbf877bf 100644
--- a/Lib/Cookie.py
+++ b/Lib/http/cookies.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
####
@@ -46,27 +46,18 @@ At the moment, this is the only documentation.
The Basics
----------
-Importing is easy..
+Importing is easy...
- >>> import Cookie
+ >>> from http import cookies
-Most of the time you start by creating a cookie. Cookies come in
-three flavors, each with slightly different encoding semantics, but
-more on that later.
+Most of the time you start by creating a cookie.
- >>> C = Cookie.SimpleCookie()
- >>> C = Cookie.SerialCookie()
- >>> C = Cookie.SmartCookie()
-
-[Note: Long-time users of Cookie.py will remember using
-Cookie.Cookie() to create an Cookie object. Although deprecated, it
-is still supported by the code. See the Backward Compatibility notes
-for more information.]
+ >>> C = cookies.SimpleCookie()
Once you've created your Cookie, you can add values just as if it were
a dictionary.
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C["fig"] = "newton"
>>> C["sugar"] = "wafer"
>>> C.output()
@@ -77,19 +68,19 @@ appropriate format for a Set-Cookie: header. This is the
default behavior. You can change the header and printed
attributes by using the .output() function
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C["rocky"] = "road"
>>> C["rocky"]["path"] = "/cookie"
- >>> print C.output(header="Cookie:")
+ >>> print(C.output(header="Cookie:"))
Cookie: rocky=road; Path=/cookie
- >>> print C.output(attrs=[], header="Cookie:")
+ >>> print(C.output(attrs=[], header="Cookie:"))
Cookie: rocky=road
The load() method of a Cookie extracts cookies from a string. In a
CGI script, you would use this method to extract the cookies from the
HTTP_COOKIE environment variable.
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C.load("chips=ahoy; vienna=finger")
>>> C.output()
'Set-Cookie: chips=ahoy\r\nSet-Cookie: vienna=finger'
@@ -98,44 +89,34 @@ The load() method is darn-tootin smart about identifying cookies
within a string. Escaped quotation marks, nested semicolons, and other
such trickeries do not confuse it.
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C.load('keebler="E=everybody; L=\\"Loves\\"; fudge=\\012;";')
- >>> print C
+ >>> print(C)
Set-Cookie: keebler="E=everybody; L=\"Loves\"; fudge=\012;"
Each element of the Cookie also supports all of the RFC 2109
Cookie attributes. Here's an example which sets the Path
attribute.
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C["oreo"] = "doublestuff"
>>> C["oreo"]["path"] = "/"
- >>> print C
+ >>> print(C)
Set-Cookie: oreo=doublestuff; Path=/
Each dictionary element has a 'value' attribute, which gives you
back the value associated with the key.
- >>> C = Cookie.SmartCookie()
+ >>> C = cookies.SimpleCookie()
>>> C["twix"] = "none for you"
>>> C["twix"].value
'none for you'
-
-A Bit More Advanced
--------------------
-
-As mentioned before, there are three different flavors of Cookie
-objects, each with different encoding/decoding semantics. This
-section briefly discusses the differences.
-
-SimpleCookie
-
The SimpleCookie expects that all values should be standard strings.
Just to be sure, SimpleCookie invokes the str() builtin to convert
the value to a string, when the values are set dictionary-style.
- >>> C = Cookie.SimpleCookie()
+ >>> C = cookies.SimpleCookie()
>>> C["number"] = 7
>>> C["string"] = "seven"
>>> C["number"].value
@@ -145,82 +126,16 @@ the value to a string, when the values are set dictionary-style.
>>> C.output()
'Set-Cookie: number=7\r\nSet-Cookie: string=seven'
-
-SerialCookie
-
-The SerialCookie expects that all values should be serialized using
-cPickle (or pickle, if cPickle isn't available). As a result of
-serializing, SerialCookie can save almost any Python object to a
-value, and recover the exact same object when the cookie has been
-returned. (SerialCookie can yield some strange-looking cookie
-values, however.)
-
- >>> C = Cookie.SerialCookie()
- >>> C["number"] = 7
- >>> C["string"] = "seven"
- >>> C["number"].value
- 7
- >>> C["string"].value
- 'seven'
- >>> C.output()
- 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string="S\'seven\'\\012p1\\012."'
-
-Be warned, however, if SerialCookie cannot de-serialize a value (because
-it isn't a valid pickle'd object), IT WILL RAISE AN EXCEPTION.
-
-
-SmartCookie
-
-The SmartCookie combines aspects of each of the other two flavors.
-When setting a value in a dictionary-fashion, the SmartCookie will
-serialize (ala cPickle) the value *if and only if* it isn't a
-Python string. String objects are *not* serialized. Similarly,
-when the load() method parses out values, it attempts to de-serialize
-the value. If it fails, then it fallsback to treating the value
-as a string.
-
- >>> C = Cookie.SmartCookie()
- >>> C["number"] = 7
- >>> C["string"] = "seven"
- >>> C["number"].value
- 7
- >>> C["string"].value
- 'seven'
- >>> C.output()
- 'Set-Cookie: number="I7\\012."\r\nSet-Cookie: string=seven'
-
-
-Backwards Compatibility
------------------------
-
-In order to keep compatibilty with earlier versions of Cookie.py,
-it is still possible to use Cookie.Cookie() to create a Cookie. In
-fact, this simply returns a SmartCookie.
-
- >>> C = Cookie.Cookie()
- >>> print C.__class__.__name__
- SmartCookie
-
-
Finis.
-""" #"
-# ^
-# |----helps out font-lock
+"""
#
# Import our required modules
#
+import re
import string
-try:
- from cPickle import dumps, loads
-except ImportError:
- from pickle import dumps, loads
-
-import re, warnings
-
-__all__ = ["CookieError","BaseCookie","SimpleCookie","SerialCookie",
- "SmartCookie","Cookie"]
+__all__ = ["CookieError", "BaseCookie", "SimpleCookie"]
_nulljoin = ''.join
_semispacejoin = '; '.join
@@ -310,21 +225,17 @@ _Translator = {
'\375' : '\\375', '\376' : '\\376', '\377' : '\\377'
}
-_idmap = ''.join(chr(x) for x in xrange(256))
+def _quote(str, LegalChars=_LegalChars):
+ r"""Quote a string for use in a cookie header.
-def _quote(str, LegalChars=_LegalChars,
- idmap=_idmap, translate=string.translate):
- #
- # If the string does not need to be double-quoted,
- # then just return the string. Otherwise, surround
- # the string in doublequotes and precede quote (with a \)
- # special characters.
- #
- if "" == translate(str, idmap, LegalChars):
+ If the string does not need to be double-quoted, then just return the
+ string. Otherwise, surround the string in doublequotes and quote
+ (with a \) special characters.
+ """
+ if all(c in LegalChars for c in str):
return str
else:
- return '"' + _nulljoin( map(_Translator.get, str, str) ) + '"'
-# end _quote
+ return '"' + _nulljoin(_Translator.get(s, s) for s in str) + '"'
_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]")
@@ -333,7 +244,7 @@ _QuotePatt = re.compile(r"[\\].")
def _unquote(str):
# If there aren't any doublequotes,
# then there can't be any special characters. See RFC 2109.
- if len(str) < 2:
+ if len(str) < 2:
return str
if str[0] != '"' or str[-1] != '"':
return str
@@ -352,32 +263,32 @@ def _unquote(str):
n = len(str)
res = []
while 0 <= i < n:
- Omatch = _OctalPatt.search(str, i)
- Qmatch = _QuotePatt.search(str, i)
- if not Omatch and not Qmatch: # Neither matched
+ o_match = _OctalPatt.search(str, i)
+ q_match = _QuotePatt.search(str, i)
+ if not o_match and not q_match: # Neither matched
res.append(str[i:])
break
# else:
j = k = -1
- if Omatch: j = Omatch.start(0)
- if Qmatch: k = Qmatch.start(0)
- if Qmatch and ( not Omatch or k < j ): # QuotePatt matched
+ if o_match:
+ j = o_match.start(0)
+ if q_match:
+ k = q_match.start(0)
+ if q_match and (not o_match or k < j): # QuotePatt matched
res.append(str[i:k])
res.append(str[k+1])
- i = k+2
+ i = k + 2
else: # OctalPatt matched
res.append(str[i:j])
- res.append( chr( int(str[j+1:j+4], 8) ) )
- i = j+4
+ res.append(chr(int(str[j+1:j+4], 8)))
+ i = j + 4
return _nulljoin(res)
-# end _unquote
-
-# The _getdate() routine is used to set the expiration time in
-# the cookie's HTTP header. By default, _getdate() returns the
-# current time in the appropriate "expires" format for a
-# Set-Cookie header. The one optional argument is an offset from
-# now, in seconds. For example, an offset of -3600 means "one hour ago".
-# The offset may be a floating point number.
+
+# The _getdate() routine is used to set the expiration time in the cookie's HTTP
+# header. By default, _getdate() returns the current time in the appropriate
+# "expires" format for a Set-Cookie header. The one optional argument is an
+# offset from now, in seconds. For example, an offset of -3600 means "one hour
+# ago". The offset may be a floating point number.
#
_weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
@@ -394,18 +305,15 @@ def _getdate(future=0, weekdayname=_weekdayname, monthname=_monthname):
(weekdayname[wd], day, monthname[month], year, hh, mm, ss)
-#
-# A class to hold ONE key,value pair.
-# In a cookie, each such pair may have several attributes.
-# so this class is used to keep the attributes associated
-# with the appropriate key,value pair.
-# This class also includes a coded_value attribute, which
-# is used to hold the network representation of the
-# value. This is most useful when Python objects are
-# pickled for network transit.
-#
-
class Morsel(dict):
+ """A class to hold ONE (key, value) pair.
+
+ In a cookie, each such pair may have several attributes, so this class is
+ used to keep the attributes associated with the appropriate key,value pair.
+ This class also includes a coded_value attribute, which is used to hold
+ the network representation of the value. This is most useful when Python
+ objects are pickled for network transit.
+ """
# RFC 2109 lists these attributes as reserved:
# path comment domain
# max-age secure version
@@ -419,60 +327,55 @@ class Morsel(dict):
# This dictionary provides a mapping from the lowercase
# variant on the left to the appropriate traditional
# formatting on the right.
- _reserved = { "expires" : "expires",
- "path" : "Path",
- "comment" : "Comment",
- "domain" : "Domain",
- "max-age" : "Max-Age",
- "secure" : "secure",
- "httponly" : "httponly",
- "version" : "Version",
- }
+ _reserved = {
+ "expires" : "expires",
+ "path" : "Path",
+ "comment" : "Comment",
+ "domain" : "Domain",
+ "max-age" : "Max-Age",
+ "secure" : "secure",
+ "httponly" : "httponly",
+ "version" : "Version",
+ }
def __init__(self):
# Set defaults
self.key = self.value = self.coded_value = None
# Set default attributes
- for K in self._reserved:
- dict.__setitem__(self, K, "")
- # end __init__
+ for key in self._reserved:
+ dict.__setitem__(self, key, "")
def __setitem__(self, K, V):
K = K.lower()
if not K in self._reserved:
raise CookieError("Invalid Attribute %s" % K)
dict.__setitem__(self, K, V)
- # end __setitem__
def isReservedKey(self, K):
return K.lower() in self._reserved
- # end isReservedKey
- def set(self, key, val, coded_val,
- LegalChars=_LegalChars,
- idmap=_idmap, translate=string.translate):
+ def set(self, key, val, coded_val, LegalChars=_LegalChars):
# First we verify that the key isn't a reserved word
# Second we make sure it only contains legal characters
if key.lower() in self._reserved:
raise CookieError("Attempt to set a reserved key: %s" % key)
- if "" != translate(key, idmap, LegalChars):
+ if any(c not in LegalChars for c in key):
raise CookieError("Illegal key value: %s" % key)
# It's a good key, so save it.
- self.key = key
- self.value = val
- self.coded_value = coded_val
- # end set
+ self.key = key
+ self.value = val
+ self.coded_value = coded_val
- def output(self, attrs=None, header = "Set-Cookie:"):
- return "%s %s" % ( header, self.OutputString(attrs) )
+ def output(self, attrs=None, header="Set-Cookie:"):
+ return "%s %s" % (header, self.OutputString(attrs))
__str__ = output
def __repr__(self):
return '<%s: %s=%s>' % (self.__class__.__name__,
- self.key, repr(self.value) )
+ self.key, repr(self.value))
def js_output(self, attrs=None):
# Print javascript
@@ -482,42 +385,39 @@ class Morsel(dict):
document.cookie = \"%s\";
// end hiding -->
</script>
- """ % ( self.OutputString(attrs).replace('"',r'\"'), )
- # end js_output()
+ """ % (self.OutputString(attrs).replace('"', r'\"'))
def OutputString(self, attrs=None):
# Build up our result
#
result = []
- RA = result.append
+ append = result.append
# First, the key=value pair
- RA("%s=%s" % (self.key, self.coded_value))
+ append("%s=%s" % (self.key, self.coded_value))
# Now add any defined attributes
if attrs is None:
attrs = self._reserved
- items = self.items()
- items.sort()
- for K,V in items:
- if V == "": continue
- if K not in attrs: continue
- if K == "expires" and type(V) == type(1):
- RA("%s=%s" % (self._reserved[K], _getdate(V)))
- elif K == "max-age" and type(V) == type(1):
- RA("%s=%d" % (self._reserved[K], V))
- elif K == "secure":
- RA(str(self._reserved[K]))
- elif K == "httponly":
- RA(str(self._reserved[K]))
+ items = sorted(self.items())
+ for key, value in items:
+ if value == "":
+ continue
+ if key not in attrs:
+ continue
+ if key == "expires" and isinstance(value, int):
+ append("%s=%s" % (self._reserved[key], _getdate(value)))
+ elif key == "max-age" and isinstance(value, int):
+ append("%s=%d" % (self._reserved[key], value))
+ elif key == "secure":
+ append(str(self._reserved[key]))
+ elif key == "httponly":
+ append(str(self._reserved[key]))
else:
- RA("%s=%s" % (self._reserved[K], V))
+ append("%s=%s" % (self._reserved[key], value))
# Return the result
return _semispacejoin(result)
- # end OutputString
-# end Morsel class
-
#
@@ -530,30 +430,28 @@ class Morsel(dict):
#
_LegalCharsPatt = r"[\w\d!#%&'~_`><@,:/\$\*\+\-\.\^\|\)\(\?\}\{\=]"
-_CookiePattern = re.compile(
- r"(?x)" # This is a Verbose pattern
- r"(?P<key>" # Start of group 'key'
- ""+ _LegalCharsPatt +"+?" # Any word of at least one letter, nongreedy
- r")" # End of group 'key'
- r"\s*=\s*" # Equal Sign
- r"(?P<val>" # Start of group 'val'
- r'"(?:[^\\"]|\\.)*"' # Any doublequoted string
- r"|" # or
- r"\w{3},\s[\s\w\d-]{9,11}\s[\d:]{8}\sGMT" # Special case for "expires" attr
- r"|" # or
- ""+ _LegalCharsPatt +"*" # Any word or empty string
- r")" # End of group 'val'
- r"\s*;?" # Probably ending in a semi-colon
- )
-
-
-# At long last, here is the cookie class.
-# Using this class is almost just like using a dictionary.
-# See this module's docstring for example usage.
+_CookiePattern = re.compile(r"""
+ (?x) # This is a verbose pattern
+ (?P<key> # Start of group 'key'
+ """ + _LegalCharsPatt + r"""+? # Any word of at least one letter
+ ) # End of group 'key'
+ \s*=\s* # Equal Sign
+ (?P<val> # Start of group 'val'
+ "(?:[^\\"]|\\.)*" # Any doublequoted string
+ | # or
+ \w{3},\s[\w\d\s-]{9,11}\s[\d:]{8}\sGMT # Special case for "expires" attr
+ | # or
+ """ + _LegalCharsPatt + r"""* # Any word or empty string
+ ) # End of group 'val'
+ \s*;? # Probably ending in a semi-colon
+ """, re.ASCII) # May be removed if safe.
+
+
+# At long last, here is the cookie class. Using this class is almost just like
+# using a dictionary. See this module's docstring for example usage.
#
class BaseCookie(dict):
- # A container class for a set of Morsels
- #
+ """A container class for a set of Morsels."""
def value_decode(self, val):
"""real_value, coded_value = value_decode(STRING)
@@ -563,7 +461,6 @@ class BaseCookie(dict):
Override this function to modify the behavior of cookies.
"""
return val, val
- # end value_encode
def value_encode(self, val):
"""real_value, coded_value = value_encode(VALUE)
@@ -573,54 +470,46 @@ class BaseCookie(dict):
"""
strval = str(val)
return strval, strval
- # end value_encode
def __init__(self, input=None):
- if input: self.load(input)
- # end __init__
+ if input:
+ self.load(input)
def __set(self, key, real_value, coded_value):
"""Private method for setting a cookie's value"""
M = self.get(key, Morsel())
M.set(key, real_value, coded_value)
dict.__setitem__(self, key, M)
- # end __set
def __setitem__(self, key, value):
"""Dictionary style assignment."""
rval, cval = self.value_encode(value)
self.__set(key, rval, cval)
- # end __setitem__
def output(self, attrs=None, header="Set-Cookie:", sep="\015\012"):
"""Return a string suitable for HTTP."""
result = []
- items = self.items()
- items.sort()
- for K,V in items:
- result.append( V.output(attrs, header) )
+ items = sorted(self.items())
+ for key, value in items:
+ result.append(value.output(attrs, header))
return sep.join(result)
- # end output
__str__ = output
def __repr__(self):
- L = []
- items = self.items()
- items.sort()
- for K,V in items:
- L.append( '%s=%s' % (K,repr(V.value) ) )
- return '<%s: %s>' % (self.__class__.__name__, _spacejoin(L))
+ l = []
+ items = sorted(self.items())
+ for key, value in items:
+ l.append('%s=%s' % (key, repr(value.value)))
+ return '<%s: %s>' % (self.__class__.__name__, _spacejoin(l))
def js_output(self, attrs=None):
"""Return a string suitable for JavaScript."""
result = []
- items = self.items()
- items.sort()
- for K,V in items:
- result.append( V.js_output(attrs) )
+ items = sorted(self.items())
+ for key, value in items:
+ result.append(value.js_output(attrs))
return _nulljoin(result)
- # end js_output
def load(self, rawdata):
"""Load cookies from a string (presumably HTTP_COOKIE) or
@@ -628,16 +517,15 @@ class BaseCookie(dict):
is equivalent to calling:
map(Cookie.__setitem__, d.keys(), d.values())
"""
- if type(rawdata) == type(""):
- self.__ParseString(rawdata)
+ if isinstance(rawdata, str):
+ self.__parse_string(rawdata)
else:
# self.update() wouldn't call our custom __setitem__
- for k, v in rawdata.items():
- self[k] = v
+ for key, value in rawdata.items():
+ self[key] = value
return
- # end load()
- def __ParseString(self, str, patt=_CookiePattern):
+ def __parse_string(self, str, patt=_CookiePattern):
i = 0 # Our starting point
n = len(str) # Length of string
M = None # current morsel
@@ -645,117 +533,39 @@ class BaseCookie(dict):
while 0 <= i < n:
# Start looking for a cookie
match = patt.search(str, i)
- if not match: break # No more cookies
+ if not match:
+ # No more cookies
+ break
- K,V = match.group("key"), match.group("val")
+ key, value = match.group("key"), match.group("val")
i = match.end(0)
# Parse the key, value in case it's metainfo
- if K[0] == "$":
+ if key[0] == "$":
# We ignore attributes which pertain to the cookie
# mechanism as a whole. See RFC 2109.
# (Does anyone care?)
if M:
- M[ K[1:] ] = V
- elif K.lower() in Morsel._reserved:
+ M[key[1:]] = value
+ elif key.lower() in Morsel._reserved:
if M:
- M[ K ] = _unquote(V)
+ M[key] = _unquote(value)
else:
- rval, cval = self.value_decode(V)
- self.__set(K, rval, cval)
- M = self[K]
- # end __ParseString
-# end BaseCookie class
+ rval, cval = self.value_decode(value)
+ self.__set(key, rval, cval)
+ M = self[key]
+
class SimpleCookie(BaseCookie):
- """SimpleCookie
+ """
SimpleCookie supports strings as cookie values. When setting
the value using the dictionary assignment notation, SimpleCookie
calls the builtin str() to convert the value to a string. Values
received from HTTP are kept as strings.
"""
def value_decode(self, val):
- return _unquote( val ), val
- def value_encode(self, val):
- strval = str(val)
- return strval, _quote( strval )
-# end SimpleCookie
-
-class SerialCookie(BaseCookie):
- """SerialCookie
- SerialCookie supports arbitrary objects as cookie values. All
- values are serialized (using cPickle) before being sent to the
- client. All incoming values are assumed to be valid Pickle
- representations. IF AN INCOMING VALUE IS NOT IN A VALID PICKLE
- FORMAT, THEN AN EXCEPTION WILL BE RAISED.
-
- Note: Large cookie values add overhead because they must be
- retransmitted on every HTTP transaction.
-
- Note: HTTP has a 2k limit on the size of a cookie. This class
- does not check for this limit, so be careful!!!
- """
- def __init__(self, input=None):
- warnings.warn("SerialCookie class is insecure; do not use it",
- DeprecationWarning)
- BaseCookie.__init__(self, input)
- # end __init__
- def value_decode(self, val):
- # This could raise an exception!
- return loads( _unquote(val) ), val
- def value_encode(self, val):
- return val, _quote( dumps(val) )
-# end SerialCookie
-
-class SmartCookie(BaseCookie):
- """SmartCookie
- SmartCookie supports arbitrary objects as cookie values. If the
- object is a string, then it is quoted. If the object is not a
- string, however, then SmartCookie will use cPickle to serialize
- the object into a string representation.
-
- Note: Large cookie values add overhead because they must be
- retransmitted on every HTTP transaction.
+ return _unquote(val), val
- Note: HTTP has a 2k limit on the size of a cookie. This class
- does not check for this limit, so be careful!!!
- """
- def __init__(self, input=None):
- warnings.warn("Cookie/SmartCookie class is insecure; do not use it",
- DeprecationWarning)
- BaseCookie.__init__(self, input)
- # end __init__
- def value_decode(self, val):
- strval = _unquote(val)
- try:
- return loads(strval), val
- except:
- return strval, val
def value_encode(self, val):
- if type(val) == type(""):
- return val, _quote(val)
- else:
- return val, _quote( dumps(val) )
-# end SmartCookie
-
-
-###########################################################
-# Backwards Compatibility: Don't break any existing code!
-
-# We provide Cookie() as an alias for SmartCookie()
-Cookie = SmartCookie
-
-#
-###########################################################
-
-def _test():
- import doctest, Cookie
- return doctest.testmod(Cookie)
-
-if __name__ == "__main__":
- _test()
-
-
-#Local Variables:
-#tab-width: 4
-#end:
+ strval = str(val)
+ return strval, _quote(strval)
diff --git a/Lib/http/server.py b/Lib/http/server.py
new file mode 100644
index 00000000000..5569037427d
--- /dev/null
+++ b/Lib/http/server.py
@@ -0,0 +1,1192 @@
+"""HTTP server classes.
+
+Note: BaseHTTPRequestHandler doesn't implement any HTTP request; see
+SimpleHTTPRequestHandler for simple implementations of GET, HEAD and POST,
+and CGIHTTPRequestHandler for CGI scripts.
+
+It does, however, optionally implement HTTP/1.1 persistent connections,
+as of version 0.3.
+
+Notes on CGIHTTPRequestHandler
+------------------------------
+
+This class implements GET and POST requests to cgi-bin scripts.
+
+If the os.fork() function is not present (e.g. on Windows),
+subprocess.Popen() is used as a fallback, with slightly altered semantics.
+
+In all cases, the implementation is intentionally naive -- all
+requests are executed synchronously.
+
+SECURITY WARNING: DON'T USE THIS CODE UNLESS YOU ARE INSIDE A FIREWALL
+-- it may execute arbitrary Python code or external programs.
+
+Note that status code 200 is sent prior to execution of a CGI script, so
+scripts cannot send other status codes such as 302 (redirect).
+
+XXX To do:
+
+- log requests even later (to capture byte count)
+- log user-agent header and other interesting goodies
+- send error log to separate file
+"""
+
+
+# See also:
+#
+# HTTP Working Group T. Berners-Lee
+# INTERNET-DRAFT R. T. Fielding
+# <draft-ietf-http-v10-spec-00.txt> H. Frystyk Nielsen
+# Expires September 8, 1995 March 8, 1995
+#
+# URL: http://www.ics.uci.edu/pub/ietf/http/draft-ietf-http-v10-spec-00.txt
+#
+# and
+#
+# Network Working Group R. Fielding
+# Request for Comments: 2616 et al
+# Obsoletes: 2068 June 1999
+# Category: Standards Track
+#
+# URL: http://www.faqs.org/rfcs/rfc2616.html
+
+# Log files
+# ---------
+#
+# Here's a quote from the NCSA httpd docs about log file format.
+#
+# | The logfile format is as follows. Each line consists of:
+# |
+# | host rfc931 authuser [DD/Mon/YYYY:hh:mm:ss] "request" ddd bbbb
+# |
+# | host: Either the DNS name or the IP number of the remote client
+# | rfc931: Any information returned by identd for this person,
+# | - otherwise.
+# | authuser: If user sent a userid for authentication, the user name,
+# | - otherwise.
+# | DD: Day
+# | Mon: Month (calendar name)
+# | YYYY: Year
+# | hh: hour (24-hour format, the machine's timezone)
+# | mm: minutes
+# | ss: seconds
+# | request: The first line of the HTTP request as sent by the client.
+# | ddd: the status code returned by the server, - if not available.
+# | bbbb: the total number of bytes sent,
+# | *not including the HTTP/1.0 header*, - if not available
+# |
+# | You can determine the name of the file accessed through request.
+#
+# (Actually, the latter is only true if you know the server configuration
+# at the time the request was made!)
+
+__version__ = "0.6"
+
+__all__ = ["HTTPServer", "BaseHTTPRequestHandler"]
+
+import html
+import email.message
+import email.parser
+import http.client
+import io
+import mimetypes
+import os
+import posixpath
+import select
+import shutil
+import socket # For gethostbyaddr()
+import socketserver
+import sys
+import time
+import urllib.parse
+import copy
+
+# Default error message template
+DEFAULT_ERROR_MESSAGE = """\
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+ "http://www.w3.org/TR/html4/strict.dtd">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
+ <title>Error response</title>
+ </head>
+ <body>
+ <h1>Error response</h1>
+ <p>Error code: %(code)d</p>
+ <p>Message: %(message)s.</p>
+ <p>Error code explanation: %(code)s - %(explain)s.</p>
+ </body>
+</html>
+"""
+
+DEFAULT_ERROR_CONTENT_TYPE = "text/html;charset=utf-8"
+
+def _quote_html(html):
+ return html.replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;")
+
+class HTTPServer(socketserver.TCPServer):
+
+ allow_reuse_address = 1 # Seems to make sense in testing environment
+
+ def server_bind(self):
+ """Override server_bind to store the server name."""
+ socketserver.TCPServer.server_bind(self)
+ host, port = self.socket.getsockname()[:2]
+ self.server_name = socket.getfqdn(host)
+ self.server_port = port
+
+
+class BaseHTTPRequestHandler(socketserver.StreamRequestHandler):
+
+ """HTTP request handler base class.
+
+ The following explanation of HTTP serves to guide you through the
+ code as well as to expose any misunderstandings I may have about
+ HTTP (so you don't need to read the code to figure out I'm wrong
+ :-).
+
+ HTTP (HyperText Transfer Protocol) is an extensible protocol on
+ top of a reliable stream transport (e.g. TCP/IP). The protocol
+ recognizes three parts to a request:
+
+ 1. One line identifying the request type and path
+ 2. An optional set of RFC-822-style headers
+ 3. An optional data part
+
+ The headers and data are separated by a blank line.
+
+ The first line of the request has the form
+
+ <command> <path> <version>
+
+ where <command> is a (case-sensitive) keyword such as GET or POST,
+ <path> is a string containing path information for the request,
+ and <version> should be the string "HTTP/1.0" or "HTTP/1.1".
+ <path> is encoded using the URL encoding scheme (using %xx to signify
+ the ASCII character with hex code xx).
+
+ The specification specifies that lines are separated by CRLF but
+ for compatibility with the widest range of clients recommends
+ servers also handle LF. Similarly, whitespace in the request line
+ is treated sensibly (allowing multiple spaces between components
+ and allowing trailing whitespace).
+
+ Similarly, for output, lines ought to be separated by CRLF pairs
+ but most clients grok LF characters just fine.
+
+ If the first line of the request has the form
+
+ <command> <path>
+
+ (i.e. <version> is left out) then this is assumed to be an HTTP
+ 0.9 request; this form has no optional headers and data part and
+ the reply consists of just the data.
+
+ The reply form of the HTTP 1.x protocol again has three parts:
+
+ 1. One line giving the response code
+ 2. An optional set of RFC-822-style headers
+ 3. The data
+
+ Again, the headers and data are separated by a blank line.
+
+ The response code line has the form
+
+ <version> <responsecode> <responsestring>
+
+ where <version> is the protocol version ("HTTP/1.0" or "HTTP/1.1"),
+ <responsecode> is a 3-digit response code indicating success or
+ failure of the request, and <responsestring> is an optional
+ human-readable string explaining what the response code means.
+
+ This server parses the request and the headers, and then calls a
+ function specific to the request type (<command>). Specifically,
+ a request SPAM will be handled by a method do_SPAM(). If no
+ such method exists the server sends an error response to the
+ client. If it exists, it is called with no arguments:
+
+ do_SPAM()
+
+ Note that the request name is case sensitive (i.e. SPAM and spam
+ are different requests).
+
+ The various request details are stored in instance variables:
+
+ - client_address is the client IP address in the form (host,
+ port);
+
+ - command, path and version are the broken-down request line;
+
+ - headers is an instance of email.message.Message (or a derived
+ class) containing the header information;
+
+ - rfile is a file object open for reading positioned at the
+ start of the optional input data part;
+
+ - wfile is a file object open for writing.
+
+ IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!
+
+ The first thing to be written must be the response line. Then
+ follow 0 or more header lines, then a blank line, and then the
+ actual data (if any). The meaning of the header lines depends on
+ the command executed by the server; in most cases, when data is
+ returned, there should be at least one header line of the form
+
+ Content-type: <type>/<subtype>
+
+ where <type> and <subtype> should be registered MIME types,
+ e.g. "text/html" or "text/plain".
+
+ """
+
+ # The Python system version, truncated to its first component.
+ sys_version = "Python/" + sys.version.split()[0]
+
+ # The server software version. You may want to override this.
+ # The format is multiple whitespace-separated strings,
+ # where each string is of the form name[/version].
+ server_version = "BaseHTTP/" + __version__
+
+ error_message_format = DEFAULT_ERROR_MESSAGE
+ error_content_type = DEFAULT_ERROR_CONTENT_TYPE
+
+ # The default request version. This only affects responses up until
+ # the point where the request line is parsed, so it mainly decides what
+ # the client gets back when sending a malformed request line.
+ # Most web servers default to HTTP 0.9, i.e. don't send a status line.
+ default_request_version = "HTTP/0.9"
+
+ def parse_request(self):
+ """Parse a request (internal).
+
+ The request should be stored in self.raw_requestline; the results
+ are in self.command, self.path, self.request_version and
+ self.headers.
+
+ Return True for success, False for failure; on failure, an
+ error is sent back.
+
+ """
+ self.command = None # set in case of error on the first line
+ self.request_version = version = self.default_request_version
+ self.close_connection = 1
+ requestline = str(self.raw_requestline, 'iso-8859-1')
+ requestline = requestline.rstrip('\r\n')
+ self.requestline = requestline
+ words = requestline.split()
+ if len(words) == 3:
+ command, path, version = words
+ if version[:5] != 'HTTP/':
+ self.send_error(400, "Bad request version (%r)" % version)
+ return False
+ try:
+ base_version_number = version.split('/', 1)[1]
+ version_number = base_version_number.split(".")
+ # RFC 2145 section 3.1 says there can be only one "." and
+ # - major and minor numbers MUST be treated as
+ # separate integers;
+ # - HTTP/2.4 is a lower version than HTTP/2.13, which in
+ # turn is lower than HTTP/12.3;
+ # - Leading zeros MUST be ignored by recipients.
+ if len(version_number) != 2:
+ raise ValueError
+ version_number = int(version_number[0]), int(version_number[1])
+ except (ValueError, IndexError):
+ self.send_error(400, "Bad request version (%r)" % version)
+ return False
+ if version_number >= (1, 1) and self.protocol_version >= "HTTP/1.1":
+ self.close_connection = 0
+ if version_number >= (2, 0):
+ self.send_error(505,
+ "Invalid HTTP Version (%s)" % base_version_number)
+ return False
+ elif len(words) == 2:
+ command, path = words
+ self.close_connection = 1
+ if command != 'GET':
+ self.send_error(400,
+ "Bad HTTP/0.9 request type (%r)" % command)
+ return False
+ elif not words:
+ return False
+ else:
+ self.send_error(400, "Bad request syntax (%r)" % requestline)
+ return False
+ self.command, self.path, self.request_version = command, path, version
+
+ # Examine the headers and look for a Connection directive.
+ try:
+ self.headers = http.client.parse_headers(self.rfile,
+ _class=self.MessageClass)
+ except http.client.LineTooLong:
+ self.send_error(400, "Line too long")
+ return False
+
+ conntype = self.headers.get('Connection', "")
+ if conntype.lower() == 'close':
+ self.close_connection = 1
+ elif (conntype.lower() == 'keep-alive' and
+ self.protocol_version >= "HTTP/1.1"):
+ self.close_connection = 0
+ # Examine the headers and look for an Expect directive
+ expect = self.headers.get('Expect', "")
+ if (expect.lower() == "100-continue" and
+ self.protocol_version >= "HTTP/1.1" and
+ self.request_version >= "HTTP/1.1"):
+ if not self.handle_expect_100():
+ return False
+ return True
+
+ def handle_expect_100(self):
+ """Decide what to do with an "Expect: 100-continue" header.
+
+ If the client is expecting a 100 Continue response, we must
+ respond with either a 100 Continue or a final response before
+ waiting for the request body. The default is to always respond
+ with a 100 Continue. You can behave differently (for example,
+ reject unauthorized requests) by overriding this method.
+
+ This method should either return True (possibly after sending
+ a 100 Continue response) or send an error response and return
+ False.
+
+ """
+ self.send_response_only(100)
+ return True
+
+ def handle_one_request(self):
+ """Handle a single HTTP request.
+
+ You normally don't need to override this method; see the class
+ __doc__ string for information on how to handle specific HTTP
+ commands such as GET and POST.
+
+ """
+ try:
+ self.raw_requestline = self.rfile.readline(65537)
+ if len(self.raw_requestline) > 65536:
+ self.requestline = ''
+ self.request_version = ''
+ self.command = ''
+ self.send_error(414)
+ return
+ if not self.raw_requestline:
+ self.close_connection = 1
+ return
+ if not self.parse_request():
+ # An error code has been sent, just exit
+ return
+ mname = 'do_' + self.command
+ if not hasattr(self, mname):
+ self.send_error(501, "Unsupported method (%r)" % self.command)
+ return
+ method = getattr(self, mname)
+ method()
+ self.wfile.flush() #actually send the response if not already done.
+ except socket.timeout as e:
+ #a read or a write timed out. Discard this connection
+ self.log_error("Request timed out: %r", e)
+ self.close_connection = 1
+ return
+
+ def handle(self):
+ """Handle multiple requests if necessary."""
+ self.close_connection = 1
+
+ self.handle_one_request()
+ while not self.close_connection:
+ self.handle_one_request()
+
+ def send_error(self, code, message=None):
+ """Send and log an error reply.
+
+ Arguments are the error code, and a detailed message.
+ The detailed message defaults to the short entry matching the
+ response code.
+
+ This sends an error response (so it must be called before any
+ output has been generated), logs the error, and finally sends
+ a piece of HTML explaining the error to the user.
+
+ """
+
+ try:
+ shortmsg, longmsg = self.responses[code]
+ except KeyError:
+ shortmsg, longmsg = '???', '???'
+ if message is None:
+ message = shortmsg
+ explain = longmsg
+ self.log_error("code %d, message %s", code, message)
+ # using _quote_html to prevent Cross Site Scripting attacks (see bug #1100201)
+ content = (self.error_message_format %
+ {'code': code, 'message': _quote_html(message), 'explain': explain})
+ self.send_response(code, message)
+ self.send_header("Content-Type", self.error_content_type)
+ self.send_header('Connection', 'close')
+ self.end_headers()
+ if self.command != 'HEAD' and code >= 200 and code not in (204, 304):
+ self.wfile.write(content.encode('UTF-8', 'replace'))
+
+ def send_response(self, code, message=None):
+ """Send the response header and log the response code.
+
+ Also send two standard headers with the server software
+ version and the current date.
+
+ """
+ self.log_request(code)
+ self.send_response_only(code, message)
+ self.send_header('Server', self.version_string())
+ self.send_header('Date', self.date_time_string())
+
+ def send_response_only(self, code, message=None):
+ """Send the response header only."""
+ if message is None:
+ if code in self.responses:
+ message = self.responses[code][0]
+ else:
+ message = ''
+ if self.request_version != 'HTTP/0.9':
+ self.wfile.write(("%s %d %s\r\n" %
+ (self.protocol_version, code, message)).encode('latin1', 'strict'))
+
+ def send_header(self, keyword, value):
+ """Send a MIME header."""
+ if self.request_version != 'HTTP/0.9':
+ if not hasattr(self, '_headers_buffer'):
+ self._headers_buffer = []
+ self._headers_buffer.append(
+ ("%s: %s\r\n" % (keyword, value)).encode('latin1', 'strict'))
+
+ if keyword.lower() == 'connection':
+ if value.lower() == 'close':
+ self.close_connection = 1
+ elif value.lower() == 'keep-alive':
+ self.close_connection = 0
+
+ def end_headers(self):
+ """Send the blank line ending the MIME headers."""
+ if self.request_version != 'HTTP/0.9':
+ self._headers_buffer.append(b"\r\n")
+ self.wfile.write(b"".join(self._headers_buffer))
+ self._headers_buffer = []
+
+ def log_request(self, code='-', size='-'):
+ """Log an accepted request.
+
+ This is called by send_response().
+
+ """
+
+ self.log_message('"%s" %s %s',
+ self.requestline, str(code), str(size))
+
+ def log_error(self, format, *args):
+ """Log an error.
+
+ This is called when a request cannot be fulfilled. By
+ default it passes the message on to log_message().
+
+ Arguments are the same as for log_message().
+
+ XXX This should go to the separate error log.
+
+ """
+
+ self.log_message(format, *args)
+
+ def log_message(self, format, *args):
+ """Log an arbitrary message.
+
+ This is used by all other logging functions. Override
+ it if you have specific logging wishes.
+
+ The first argument, FORMAT, is a format string for the
+ message to be logged. If the format string contains
+ any % escapes requiring parameters, they should be
+ specified as subsequent arguments (it's just like
+ printf!).
+
+ The client ip and current date/time are prefixed to
+ every message.
+
+ """
+
+ sys.stderr.write("%s - - [%s] %s\n" %
+ (self.client_address[0],
+ self.log_date_time_string(),
+ format%args))
+
+ def version_string(self):
+ """Return the server software version string."""
+ return self.server_version + ' ' + self.sys_version
+
+ def date_time_string(self, timestamp=None):
+ """Return the current date and time formatted for a message header."""
+ if timestamp is None:
+ timestamp = time.time()
+ year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp)
+ s = "%s, %02d %3s %4d %02d:%02d:%02d GMT" % (
+ self.weekdayname[wd],
+ day, self.monthname[month], year,
+ hh, mm, ss)
+ return s
+
+ def log_date_time_string(self):
+ """Return the current time formatted for logging."""
+ now = time.time()
+ year, month, day, hh, mm, ss, x, y, z = time.localtime(now)
+ s = "%02d/%3s/%04d %02d:%02d:%02d" % (
+ day, self.monthname[month], year, hh, mm, ss)
+ return s
+
+ weekdayname = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+
+ monthname = [None,
+ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
+ 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
+
+ def address_string(self):
+ """Return the client address formatted for logging.
+
+ This version looks up the full hostname using gethostbyaddr(),
+ and tries to find a name that contains at least one dot.
+
+ """
+
+ host, port = self.client_address[:2]
+ return socket.getfqdn(host)
+
+ # Essentially static class variables
+
+ # The version of the HTTP protocol we support.
+ # Set this to HTTP/1.1 to enable automatic keepalive
+ protocol_version = "HTTP/1.0"
+
+ # MessageClass used to parse headers
+ MessageClass = http.client.HTTPMessage
+
+ # Table mapping response codes to messages; entries have the
+ # form {code: (shortmessage, longmessage)}.
+ # See RFC 2616.
+ responses = {
+ 100: ('Continue', 'Request received, please continue'),
+ 101: ('Switching Protocols',
+ 'Switching to new protocol; obey Upgrade header'),
+
+ 200: ('OK', 'Request fulfilled, document follows'),
+ 201: ('Created', 'Document created, URL follows'),
+ 202: ('Accepted',
+ 'Request accepted, processing continues off-line'),
+ 203: ('Non-Authoritative Information', 'Request fulfilled from cache'),
+ 204: ('No Content', 'Request fulfilled, nothing follows'),
+ 205: ('Reset Content', 'Clear input form for further input.'),
+ 206: ('Partial Content', 'Partial content follows.'),
+
+ 300: ('Multiple Choices',
+ 'Object has several resources -- see URI list'),
+ 301: ('Moved Permanently', 'Object moved permanently -- see URI list'),
+ 302: ('Found', 'Object moved temporarily -- see URI list'),
+ 303: ('See Other', 'Object moved -- see Method and URL list'),
+ 304: ('Not Modified',
+ 'Document has not changed since given time'),
+ 305: ('Use Proxy',
+ 'You must use proxy specified in Location to access this '
+ 'resource.'),
+ 307: ('Temporary Redirect',
+ 'Object moved temporarily -- see URI list'),
+
+ 400: ('Bad Request',
+ 'Bad request syntax or unsupported method'),
+ 401: ('Unauthorized',
+ 'No permission -- see authorization schemes'),
+ 402: ('Payment Required',
+ 'No payment -- see charging schemes'),
+ 403: ('Forbidden',
+ 'Request forbidden -- authorization will not help'),
+ 404: ('Not Found', 'Nothing matches the given URI'),
+ 405: ('Method Not Allowed',
+ 'Specified method is invalid for this resource.'),
+ 406: ('Not Acceptable', 'URI not available in preferred format.'),
+ 407: ('Proxy Authentication Required', 'You must authenticate with '
+ 'this proxy before proceeding.'),
+ 408: ('Request Timeout', 'Request timed out; try again later.'),
+ 409: ('Conflict', 'Request conflict.'),
+ 410: ('Gone',
+ 'URI no longer exists and has been permanently removed.'),
+ 411: ('Length Required', 'Client must specify Content-Length.'),
+ 412: ('Precondition Failed', 'Precondition in headers is false.'),
+ 413: ('Request Entity Too Large', 'Entity is too large.'),
+ 414: ('Request-URI Too Long', 'URI is too long.'),
+ 415: ('Unsupported Media Type', 'Entity body in unsupported format.'),
+ 416: ('Requested Range Not Satisfiable',
+ 'Cannot satisfy request range.'),
+ 417: ('Expectation Failed',
+ 'Expect condition could not be satisfied.'),
+
+ 500: ('Internal Server Error', 'Server got itself in trouble'),
+ 501: ('Not Implemented',
+ 'Server does not support this operation'),
+ 502: ('Bad Gateway', 'Invalid responses from another server/proxy.'),
+ 503: ('Service Unavailable',
+ 'The server cannot process the request due to a high load'),
+ 504: ('Gateway Timeout',
+ 'The gateway server did not receive a timely response'),
+ 505: ('HTTP Version Not Supported', 'Cannot fulfill request.'),
+ }
+
+
+class SimpleHTTPRequestHandler(BaseHTTPRequestHandler):
+
+ """Simple HTTP request handler with GET and HEAD commands.
+
+ This serves files from the current directory and any of its
+ subdirectories. The MIME type for files is determined by
+ calling the .guess_type() method.
+
+ The GET and HEAD requests are identical except that the HEAD
+ request omits the actual contents of the file.
+
+ """
+
+ server_version = "SimpleHTTP/" + __version__
+
+ def do_GET(self):
+ """Serve a GET request."""
+ f = self.send_head()
+ if f:
+ self.copyfile(f, self.wfile)
+ f.close()
+
+ def do_HEAD(self):
+ """Serve a HEAD request."""
+ f = self.send_head()
+ if f:
+ f.close()
+
+ def send_head(self):
+ """Common code for GET and HEAD commands.
+
+ This sends the response code and MIME headers.
+
+ Return value is either a file object (which has to be copied
+ to the outputfile by the caller unless the command was HEAD,
+ and must be closed by the caller under all circumstances), or
+ None, in which case the caller has nothing further to do.
+
+ """
+ path = self.translate_path(self.path)
+ f = None
+ if os.path.isdir(path):
+ if not self.path.endswith('/'):
+ # redirect browser - doing basically what apache does
+ self.send_response(301)
+ self.send_header("Location", self.path + "/")
+ self.end_headers()
+ return None
+ for index in "index.html", "index.htm":
+ index = os.path.join(path, index)
+ if os.path.exists(index):
+ path = index
+ break
+ else:
+ return self.list_directory(path)
+ ctype = self.guess_type(path)
+ try:
+ f = open(path, 'rb')
+ except IOError:
+ self.send_error(404, "File not found")
+ return None
+ self.send_response(200)
+ self.send_header("Content-type", ctype)
+ fs = os.fstat(f.fileno())
+ self.send_header("Content-Length", str(fs[6]))
+ self.send_header("Last-Modified", self.date_time_string(fs.st_mtime))
+ self.end_headers()
+ return f
+
+ def list_directory(self, path):
+ """Helper to produce a directory listing (absent index.html).
+
+ Return value is either a file object, or None (indicating an
+ error). In either case, the headers are sent, making the
+ interface the same as for send_head().
+
+ """
+ try:
+ list = os.listdir(path)
+ except os.error:
+ self.send_error(404, "No permission to list directory")
+ return None
+ list.sort(key=lambda a: a.lower())
+ r = []
+ displaypath = html.escape(urllib.parse.unquote(self.path))
+ r.append('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">')
+ r.append("<html>\n<title>Directory listing for %s</title>\n" % displaypath)
+ r.append("<body>\n<h2>Directory listing for %s</h2>\n" % displaypath)
+ r.append("<hr>\n<ul>\n")
+ for name in list:
+ fullname = os.path.join(path, name)
+ displayname = linkname = name
+ # Append / for directories or @ for symbolic links
+ if os.path.isdir(fullname):
+ displayname = name + "/"
+ linkname = name + "/"
+ if os.path.islink(fullname):
+ displayname = name + "@"
+ # Note: a link to a directory displays with @ and links with /
+ r.append('<li><a href="%s">%s</a>\n'
+ % (urllib.parse.quote(linkname), html.escape(displayname)))
+ r.append("</ul>\n<hr>\n</body>\n</html>\n")
+ enc = sys.getfilesystemencoding()
+ encoded = ''.join(r).encode(enc)
+ f = io.BytesIO()
+ f.write(encoded)
+ f.seek(0)
+ self.send_response(200)
+ self.send_header("Content-type", "text/html; charset=%s" % enc)
+ self.send_header("Content-Length", str(len(encoded)))
+ self.end_headers()
+ return f
+
+ def translate_path(self, path):
+ """Translate a /-separated PATH to the local filename syntax.
+
+ Components that mean special things to the local file system
+ (e.g. drive or directory names) are ignored. (XXX They should
+ probably be diagnosed.)
+
+ """
+ # abandon query parameters
+ path = path.split('?',1)[0]
+ path = path.split('#',1)[0]
+ path = posixpath.normpath(urllib.parse.unquote(path))
+ words = path.split('/')
+ words = filter(None, words)
+ path = os.getcwd()
+ for word in words:
+ drive, word = os.path.splitdrive(word)
+ head, word = os.path.split(word)
+ if word in (os.curdir, os.pardir): continue
+ path = os.path.join(path, word)
+ return path
+
+ def copyfile(self, source, outputfile):
+ """Copy all data between two file objects.
+
+ The SOURCE argument is a file object open for reading
+ (or anything with a read() method) and the DESTINATION
+ argument is a file object open for writing (or
+ anything with a write() method).
+
+ The only reason for overriding this would be to change
+ the block size or perhaps to replace newlines by CRLF
+ -- note however that this the default server uses this
+ to copy binary data as well.
+
+ """
+ shutil.copyfileobj(source, outputfile)
+
+ def guess_type(self, path):
+ """Guess the type of a file.
+
+ Argument is a PATH (a filename).
+
+ Return value is a string of the form type/subtype,
+ usable for a MIME Content-type header.
+
+ The default implementation looks the file's extension
+ up in the table self.extensions_map, using application/octet-stream
+ as a default; however it would be permissible (if
+ slow) to look inside the data to make a better guess.
+
+ """
+
+ base, ext = posixpath.splitext(path)
+ if ext in self.extensions_map:
+ return self.extensions_map[ext]
+ ext = ext.lower()
+ if ext in self.extensions_map:
+ return self.extensions_map[ext]
+ else:
+ return self.extensions_map['']
+
+ if not mimetypes.inited:
+ mimetypes.init() # try to read system mime.types
+ extensions_map = mimetypes.types_map.copy()
+ extensions_map.update({
+ '': 'application/octet-stream', # Default
+ '.py': 'text/plain',
+ '.c': 'text/plain',
+ '.h': 'text/plain',
+ })
+
+
+# Utilities for CGIHTTPRequestHandler
+
+def _url_collapse_path(path):
+ """
+ Given a URL path, remove extra '/'s and '.' path elements and collapse
+ any '..' references and returns a colllapsed path.
+
+ Implements something akin to RFC-2396 5.2 step 6 to parse relative paths.
+ The utility of this function is limited to is_cgi method and helps
+ preventing some security attacks.
+
+ Returns: A tuple of (head, tail) where tail is everything after the final /
+ and head is everything before it. Head will always start with a '/' and,
+ if it contains anything else, never have a trailing '/'.
+
+ Raises: IndexError if too many '..' occur within the path.
+
+ """
+ # Similar to os.path.split(os.path.normpath(path)) but specific to URL
+ # path semantics rather than local operating system semantics.
+ path_parts = path.split('/')
+ head_parts = []
+ for part in path_parts[:-1]:
+ if part == '..':
+ head_parts.pop() # IndexError if more '..' than prior parts
+ elif part and part != '.':
+ head_parts.append( part )
+ if path_parts:
+ tail_part = path_parts.pop()
+ if tail_part:
+ if tail_part == '..':
+ head_parts.pop()
+ tail_part = ''
+ elif tail_part == '.':
+ tail_part = ''
+ else:
+ tail_part = ''
+
+ splitpath = ('/' + '/'.join(head_parts), tail_part)
+ collapsed_path = "/".join(splitpath)
+
+ return collapsed_path
+
+
+
+nobody = None
+
+def nobody_uid():
+ """Internal routine to get nobody's uid"""
+ global nobody
+ if nobody:
+ return nobody
+ try:
+ import pwd
+ except ImportError:
+ return -1
+ try:
+ nobody = pwd.getpwnam('nobody')[2]
+ except KeyError:
+ nobody = 1 + max(x[2] for x in pwd.getpwall())
+ return nobody
+
+
+def executable(path):
+ """Test for executable file."""
+ try:
+ st = os.stat(path)
+ except os.error:
+ return False
+ return st.st_mode & 0o111 != 0
+
+
+class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
+
+ """Complete HTTP server with GET, HEAD and POST commands.
+
+ GET and HEAD also support running CGI scripts.
+
+ The POST command is *only* implemented for CGI scripts.
+
+ """
+
+ # Determine platform specifics
+ have_fork = hasattr(os, 'fork')
+
+ # Make rfile unbuffered -- we need to read one line and then pass
+ # the rest to a subprocess, so we can't use buffered input.
+ rbufsize = 0
+
+ def do_POST(self):
+ """Serve a POST request.
+
+ This is only implemented for CGI scripts.
+
+ """
+
+ if self.is_cgi():
+ self.run_cgi()
+ else:
+ self.send_error(501, "Can only POST to CGI scripts")
+
+ def send_head(self):
+ """Version of send_head that support CGI scripts"""
+ if self.is_cgi():
+ return self.run_cgi()
+ else:
+ return SimpleHTTPRequestHandler.send_head(self)
+
+ def is_cgi(self):
+ """Test whether self.path corresponds to a CGI script.
+
+ Returns True and updates the cgi_info attribute to the tuple
+ (dir, rest) if self.path requires running a CGI script.
+ Returns False otherwise.
+
+ If any exception is raised, the caller should assume that
+ self.path was rejected as invalid and act accordingly.
+
+ The default implementation tests whether the normalized url
+ path begins with one of the strings in self.cgi_directories
+ (and the next character is a '/' or the end of the string).
+
+ """
+ collapsed_path = _url_collapse_path(self.path)
+ dir_sep = collapsed_path.find('/', 1)
+ head, tail = collapsed_path[:dir_sep], collapsed_path[dir_sep+1:]
+ if head in self.cgi_directories:
+ self.cgi_info = head, tail
+ return True
+ return False
+
+
+ cgi_directories = ['/cgi-bin', '/htbin']
+
+ def is_executable(self, path):
+ """Test whether argument path is an executable file."""
+ return executable(path)
+
+ def is_python(self, path):
+ """Test whether argument path is a Python script."""
+ head, tail = os.path.splitext(path)
+ return tail.lower() in (".py", ".pyw")
+
+ def run_cgi(self):
+ """Execute a CGI script."""
+ path = self.path
+ dir, rest = self.cgi_info
+
+ i = path.find('/', len(dir) + 1)
+ while i >= 0:
+ nextdir = path[:i]
+ nextrest = path[i+1:]
+
+ scriptdir = self.translate_path(nextdir)
+ if os.path.isdir(scriptdir):
+ dir, rest = nextdir, nextrest
+ i = path.find('/', len(dir) + 1)
+ else:
+ break
+
+ # find an explicit query string, if present.
+ i = rest.rfind('?')
+ if i >= 0:
+ rest, query = rest[:i], rest[i+1:]
+ else:
+ query = ''
+
+ # dissect the part after the directory name into a script name &
+ # a possible additional path, to be stored in PATH_INFO.
+ i = rest.find('/')
+ if i >= 0:
+ script, rest = rest[:i], rest[i:]
+ else:
+ script, rest = rest, ''
+
+ scriptname = dir + '/' + script
+ scriptfile = self.translate_path(scriptname)
+ if not os.path.exists(scriptfile):
+ self.send_error(404, "No such CGI script (%r)" % scriptname)
+ return
+ if not os.path.isfile(scriptfile):
+ self.send_error(403, "CGI script is not a plain file (%r)" %
+ scriptname)
+ return
+ ispy = self.is_python(scriptname)
+ if not ispy:
+ if not self.is_executable(scriptfile):
+ self.send_error(403, "CGI script is not executable (%r)" %
+ scriptname)
+ return
+
+ # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html
+ # XXX Much of the following could be prepared ahead of time!
+ env = copy.deepcopy(os.environ)
+ env['SERVER_SOFTWARE'] = self.version_string()
+ env['SERVER_NAME'] = self.server.server_name
+ env['GATEWAY_INTERFACE'] = 'CGI/1.1'
+ env['SERVER_PROTOCOL'] = self.protocol_version
+ env['SERVER_PORT'] = str(self.server.server_port)
+ env['REQUEST_METHOD'] = self.command
+ uqrest = urllib.parse.unquote(rest)
+ env['PATH_INFO'] = uqrest
+ env['PATH_TRANSLATED'] = self.translate_path(uqrest)
+ env['SCRIPT_NAME'] = scriptname
+ if query:
+ env['QUERY_STRING'] = query
+ host = self.address_string()
+ if host != self.client_address[0]:
+ env['REMOTE_HOST'] = host
+ env['REMOTE_ADDR'] = self.client_address[0]
+ authorization = self.headers.get("authorization")
+ if authorization:
+ authorization = authorization.split()
+ if len(authorization) == 2:
+ import base64, binascii
+ env['AUTH_TYPE'] = authorization[0]
+ if authorization[0].lower() == "basic":
+ try:
+ authorization = authorization[1].encode('ascii')
+ authorization = base64.decodebytes(authorization).\
+ decode('ascii')
+ except (binascii.Error, UnicodeError):
+ pass
+ else:
+ authorization = authorization.split(':')
+ if len(authorization) == 2:
+ env['REMOTE_USER'] = authorization[0]
+ # XXX REMOTE_IDENT
+ if self.headers.get('content-type') is None:
+ env['CONTENT_TYPE'] = self.headers.get_content_type()
+ else:
+ env['CONTENT_TYPE'] = self.headers['content-type']
+ length = self.headers.get('content-length')
+ if length:
+ env['CONTENT_LENGTH'] = length
+ referer = self.headers.get('referer')
+ if referer:
+ env['HTTP_REFERER'] = referer
+ accept = []
+ for line in self.headers.getallmatchingheaders('accept'):
+ if line[:1] in "\t\n\r ":
+ accept.append(line.strip())
+ else:
+ accept = accept + line[7:].split(',')
+ env['HTTP_ACCEPT'] = ','.join(accept)
+ ua = self.headers.get('user-agent')
+ if ua:
+ env['HTTP_USER_AGENT'] = ua
+ co = filter(None, self.headers.get_all('cookie', []))
+ cookie_str = ', '.join(co)
+ if cookie_str:
+ env['HTTP_COOKIE'] = cookie_str
+ # XXX Other HTTP_* headers
+ # Since we're setting the env in the parent, provide empty
+ # values to override previously set values
+ for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH',
+ 'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'):
+ env.setdefault(k, "")
+
+ self.send_response(200, "Script output follows")
+
+ decoded_query = query.replace('+', ' ')
+
+ if self.have_fork:
+ # Unix -- fork as we should
+ args = [script]
+ if '=' not in decoded_query:
+ args.append(decoded_query)
+ nobody = nobody_uid()
+ self.wfile.flush() # Always flush before forking
+ pid = os.fork()
+ if pid != 0:
+ # Parent
+ pid, sts = os.waitpid(pid, 0)
+ # throw away additional data [see bug #427345]
+ while select.select([self.rfile], [], [], 0)[0]:
+ if not self.rfile.read(1):
+ break
+ if sts:
+ self.log_error("CGI script exit status %#x", sts)
+ return
+ # Child
+ try:
+ try:
+ os.setuid(nobody)
+ except os.error:
+ pass
+ os.dup2(self.rfile.fileno(), 0)
+ os.dup2(self.wfile.fileno(), 1)
+ os.execve(scriptfile, args, env)
+ except:
+ self.server.handle_error(self.request, self.client_address)
+ os._exit(127)
+
+ else:
+ # Non-Unix -- use subprocess
+ import subprocess
+ cmdline = [scriptfile]
+ if self.is_python(scriptfile):
+ interp = sys.executable
+ if interp.lower().endswith("w.exe"):
+ # On Windows, use python.exe, not pythonw.exe
+ interp = interp[:-5] + interp[-4:]
+ cmdline = [interp, '-u'] + cmdline
+ if '=' not in query:
+ cmdline.append(query)
+ self.log_message("command: %s", subprocess.list2cmdline(cmdline))
+ try:
+ nbytes = int(length)
+ except (TypeError, ValueError):
+ nbytes = 0
+ p = subprocess.Popen(cmdline,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env = env
+ )
+ if self.command.lower() == "post" and nbytes > 0:
+ data = self.rfile.read(nbytes)
+ else:
+ data = None
+ # throw away additional data [see bug #427345]
+ while select.select([self.rfile._sock], [], [], 0)[0]:
+ if not self.rfile._sock.recv(1):
+ break
+ stdout, stderr = p.communicate(data)
+ self.wfile.write(stdout)
+ if stderr:
+ self.log_error('%s', stderr)
+ p.stderr.close()
+ p.stdout.close()
+ status = p.returncode
+ if status:
+ self.log_error("CGI script exit status %#x", status)
+ else:
+ self.log_message("CGI script exited OK")
+
+
+def test(HandlerClass = BaseHTTPRequestHandler,
+ ServerClass = HTTPServer, protocol="HTTP/1.0"):
+ """Test the HTTP request handler class.
+
+ This runs an HTTP server on port 8000 (or the first command line
+ argument).
+
+ """
+
+ if sys.argv[1:]:
+ port = int(sys.argv[1])
+ else:
+ port = 8000
+ server_address = ('', port)
+
+ HandlerClass.protocol_version = protocol
+ httpd = ServerClass(server_address, HandlerClass)
+
+ sa = httpd.socket.getsockname()
+ print("Serving HTTP on", sa[0], "port", sa[1], "...")
+ try:
+ httpd.serve_forever()
+ except KeyboardInterrupt:
+ print("\nKeyboard interrupt received, exiting.")
+ httpd.server_close()
+ sys.exit(0)
+
+if __name__ == '__main__':
+ test(HandlerClass=SimpleHTTPRequestHandler)
diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py
index 4e173252d61..e4c1aff3dc9 100644
--- a/Lib/idlelib/AutoComplete.py
+++ b/Lib/idlelib/AutoComplete.py
@@ -124,19 +124,26 @@ class AutoComplete:
curline = self.text.get("insert linestart", "insert")
i = j = len(curline)
if hp.is_in_string() and (not mode or mode==COMPLETE_FILES):
+ # Find the beginning of the string
+ # fetch_completions will look at the file system to determine whether the
+ # string value constitutes an actual file name
+ # XXX could consider raw strings here and unescape the string value if it's
+ # not raw.
self._remove_autocomplete_window()
mode = COMPLETE_FILES
- while i and curline[i-1] in FILENAME_CHARS:
+ # Find last separator or string start
+ while i and curline[i-1] not in "'\"" + SEPS:
i -= 1
comp_start = curline[i:j]
j = i
- while i and curline[i-1] in FILENAME_CHARS + SEPS:
+ # Find string start
+ while i and curline[i-1] not in "'\"":
i -= 1
comp_what = curline[i:j]
elif hp.is_in_code() and (not mode or mode==COMPLETE_ATTRIBUTES):
self._remove_autocomplete_window()
mode = COMPLETE_ATTRIBUTES
- while i and curline[i-1] in ID_CHARS:
+ while i and (curline[i-1] in ID_CHARS or ord(curline[i-1]) > 127):
i -= 1
comp_start = curline[i:j]
if i and curline[i-1] == '.':
diff --git a/Lib/idlelib/AutoCompleteWindow.py b/Lib/idlelib/AutoCompleteWindow.py
index 298177fc847..7787e7034c1 100644
--- a/Lib/idlelib/AutoCompleteWindow.py
+++ b/Lib/idlelib/AutoCompleteWindow.py
@@ -1,7 +1,7 @@
"""
An auto-completion window for IDLE, used by the AutoComplete extension
"""
-from Tkinter import *
+from tkinter import *
from idlelib.MultiCall import MC_SHIFT
from idlelib.AutoComplete import COMPLETE_FILES, COMPLETE_ATTRIBUTES
@@ -354,6 +354,15 @@ class AutoCompleteWindow:
# A modifier key, so ignore
return
+ elif event.char and event.char >= ' ':
+ # Regular character with a non-length-1 keycode
+ self._change_start(self.start + event.char)
+ self.lasttypedstart = self.start
+ self.listbox.select_clear(0, int(self.listbox.curselection()[0]))
+ self.listbox.select_set(self._binary_search(self.start))
+ self._selection_changed()
+ return "break"
+
else:
# Unknown event, close the window and let it through.
self.hide_window()
diff --git a/Lib/idlelib/CallTipWindow.py b/Lib/idlelib/CallTipWindow.py
index 7bb62b4e0b5..a2431f8eff3 100644
--- a/Lib/idlelib/CallTipWindow.py
+++ b/Lib/idlelib/CallTipWindow.py
@@ -4,7 +4,7 @@ After ToolTip.py, which uses ideas gleaned from PySol
Used by the CallTips IDLE extension.
"""
-from Tkinter import *
+from tkinter import *
HIDE_VIRTUAL_EVENT_NAME = "<<calltipwindow-hide>>"
HIDE_SEQUENCES = ("<Key-Escape>", "<FocusOut>")
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py
index d533ce13b95..3c8c096d23c 100644
--- a/Lib/idlelib/CallTips.py
+++ b/Lib/idlelib/CallTips.py
@@ -8,6 +8,7 @@ which disappear when you type a closing parenthesis.
import re
import sys
import types
+import inspect
from idlelib import CallTipWindow
from idlelib.HyperParser import HyperParser
@@ -25,28 +26,26 @@ class CallTips:
def __init__(self, editwin=None):
if editwin is None: # subprocess and test
self.editwin = None
- return
- self.editwin = editwin
- self.text = editwin.text
- self.calltip = None
- self._make_calltip_window = self._make_tk_calltip_window
+ else:
+ self.editwin = editwin
+ self.text = editwin.text
+ self.active_calltip = None
+ self._calltip_window = self._make_tk_calltip_window
def close(self):
- self._make_calltip_window = None
+ self._calltip_window = None
def _make_tk_calltip_window(self):
# See __init__ for usage
return CallTipWindow.CallTip(self.text)
def _remove_calltip_window(self, event=None):
- if self.calltip:
- self.calltip.hidetip()
- self.calltip = None
+ if self.active_calltip:
+ self.active_calltip.hidetip()
+ self.active_calltip = None
def force_open_calltip_event(self, event):
- """Happens when the user really wants to open a CallTip, even if a
- function call is needed.
- """
+ "The user selected the menu entry or hotkey, open the tip."
self.open_calltip(True)
def try_open_calltip_event(self, event):
@@ -57,10 +56,7 @@ class CallTips:
self.open_calltip(False)
def refresh_calltip_event(self, event):
- """If there is already a calltip window, check if it is still needed,
- and if so, reload it.
- """
- if self.calltip and self.calltip.is_active():
+ if self.active_calltip and self.active_calltip.is_active():
self.open_calltip(False)
def open_calltip(self, evalfuncs):
@@ -71,21 +67,23 @@ class CallTips:
if not sur_paren:
return
hp.set_index(sur_paren[0])
- expression = hp.get_expression()
- if not expression or (not evalfuncs and expression.find('(') != -1):
+ expression = hp.get_expression()
+ if not expression:
+ return
+ if not evalfuncs and (expression.find('(') != -1):
return
- arg_text = self.fetch_tip(expression)
- if not arg_text:
+ argspec = self.fetch_tip(expression)
+ if not argspec:
return
- self.calltip = self._make_calltip_window()
- self.calltip.showtip(arg_text, sur_paren[0], sur_paren[1])
+ self.active_calltip = self._calltip_window()
+ self.active_calltip.showtip(argspec, sur_paren[0], sur_paren[1])
def fetch_tip(self, expression):
- """Return the argument list and docstring of a function or class
+ """Return the argument list and docstring of a function or class.
If there is a Python subprocess, get the calltip there. Otherwise,
- either fetch_tip() is running in the subprocess itself or it was called
- in an IDLE EditorWindow before any script had been run.
+ either this fetch_tip() is running in the subprocess or it was
+ called in an IDLE running without the subprocess.
The subprocess environment is that of the most recently run script. If
two unrelated modules are being edited some calltips in the current
@@ -102,125 +100,168 @@ class CallTips:
return rpcclt.remotecall("exec", "get_the_calltip",
(expression,), {})
else:
- entity = self.get_entity(expression)
- return get_arg_text(entity)
+ return get_argspec(get_entity(expression))
- def get_entity(self, expression):
- """Return the object corresponding to expression evaluated
- in a namespace spanning sys.modules and __main.dict__.
- """
- if expression:
- namespace = sys.modules.copy()
- namespace.update(__main__.__dict__)
- try:
- return eval(expression, namespace)
- except BaseException:
- # An uncaught exception closes idle, and eval can raise any
- # exception, especially if user classes are involved.
- return None
-
-def _find_constructor(class_ob):
- # Given a class object, return a function object used for the
- # constructor (ie, __init__() ) or None if we can't find one.
- try:
- return class_ob.__init__.im_func
- except AttributeError:
- for base in class_ob.__bases__:
- rc = _find_constructor(base)
- if rc is not None: return rc
- return None
-
-def get_arg_text(ob):
- """Get a string describing the arguments for the given object,
- only if it is callable."""
- arg_text = ""
- if ob is not None and hasattr(ob, '__call__'):
- arg_offset = 0
- if type(ob) in (types.ClassType, types.TypeType):
- # Look for the highest __init__ in the class chain.
- fob = _find_constructor(ob)
- if fob is None:
- fob = lambda: None
- else:
- arg_offset = 1
- elif type(ob)==types.MethodType:
- # bit of a hack for methods - turn it into a function
- # but we drop the "self" param.
- fob = ob.im_func
- arg_offset = 1
+def get_entity(expression):
+ """Return the object corresponding to expression evaluated
+ in a namespace spanning sys.modules and __main.dict__.
+ """
+ if expression:
+ namespace = sys.modules.copy()
+ namespace.update(__main__.__dict__)
+ try:
+ return eval(expression, namespace)
+ except BaseException:
+ # An uncaught exception closes idle, and eval can raise any
+ # exception, especially if user classes are involved.
+ return None
+
+# The following are used in both get_argspec and tests
+_first_param = re.compile('(?<=\()\w*\,?\s*')
+_default_callable_argspec = "No docstring, see docs."
+
+def get_argspec(ob):
+ '''Return a string describing the arguments and return of a callable object.
+
+ For Python-coded functions and methods, the first line is introspected.
+ Delete 'self' parameter for classes (.__init__) and bound methods.
+ The last line is the first line of the doc string. For builtins, this typically
+ includes the arguments in addition to the return value.
+
+ '''
+ argspec = ""
+ if hasattr(ob, '__call__'):
+ if isinstance(ob, type):
+ fob = getattr(ob, '__init__', None)
+ elif isinstance(ob.__call__, types.MethodType):
+ fob = ob.__call__
else:
fob = ob
- # Try to build one for Python defined functions
- if type(fob) in [types.FunctionType, types.LambdaType]:
- argcount = fob.func_code.co_argcount
- real_args = fob.func_code.co_varnames[arg_offset:argcount]
- defaults = fob.func_defaults or []
- defaults = list(map(lambda name: "=%s" % repr(name), defaults))
- defaults = [""] * (len(real_args) - len(defaults)) + defaults
- items = map(lambda arg, dflt: arg + dflt, real_args, defaults)
- if fob.func_code.co_flags & 0x4:
- items.append("...")
- if fob.func_code.co_flags & 0x8:
- items.append("***")
- arg_text = ", ".join(items)
- arg_text = "(%s)" % re.sub("\.\d+", "<tuple>", arg_text)
- # See if we can use the docstring
- doc = getattr(ob, "__doc__", "")
+ if isinstance(fob, (types.FunctionType, types.MethodType)):
+ argspec = inspect.formatargspec(*inspect.getfullargspec(fob))
+ if (isinstance(ob, (type, types.MethodType)) or
+ isinstance(ob.__call__, types.MethodType)):
+ argspec = _first_param.sub("", argspec)
+
+ if isinstance(ob.__call__, types.MethodType):
+ doc = ob.__call__.__doc__
+ else:
+ doc = getattr(ob, "__doc__", "")
if doc:
doc = doc.lstrip()
pos = doc.find("\n")
if pos < 0 or pos > 70:
pos = 70
- if arg_text:
- arg_text += "\n"
- arg_text += doc[:pos]
- return arg_text
+ if argspec:
+ argspec += "\n"
+ argspec += doc[:pos]
+ if not argspec:
+ argspec = _default_callable_argspec
+ return argspec
#################################################
#
-# Test code
-#
-if __name__=='__main__':
+# Test code tests CallTips.fetch_tip, get_entity, and get_argspec
+def main():
+ # Putting expected in docstrings results in doubled tips for test
def t1(): "()"
def t2(a, b=None): "(a, b=None)"
- def t3(a, *args): "(a, ...)"
- def t4(*args): "(...)"
- def t5(a, *args): "(a, ...)"
- def t6(a, b=None, *args, **kw): "(a, b=None, ..., ***)"
- def t7((a, b), c, (d, e)): "(<tuple>, c, <tuple>)"
+ def t3(a, *args): "(a, *args)"
+ def t4(*args): "(*args)"
+ def t5(a, b=None, *args, **kw): "(a, b=None, *args, **kw)"
class TC(object):
- "(ai=None, ...)"
- def __init__(self, ai=None, *b): "(ai=None, ...)"
- def t1(self): "()"
- def t2(self, ai, b=None): "(ai, b=None)"
- def t3(self, ai, *args): "(ai, ...)"
- def t4(self, *args): "(...)"
- def t5(self, ai, *args): "(ai, ...)"
- def t6(self, ai, b=None, *args, **kw): "(ai, b=None, ..., ***)"
- def t7(self, (ai, b), c, (d, e)): "(<tuple>, c, <tuple>)"
-
- def test(tests):
- ct = CallTips()
- failed=[]
- for t in tests:
- expected = t.__doc__ + "\n" + t.__doc__
- name = t.__name__
- # exercise fetch_tip(), not just get_arg_text()
- try:
- qualified_name = "%s.%s" % (t.im_class.__name__, name)
- except AttributeError:
- qualified_name = name
- arg_text = ct.fetch_tip(qualified_name)
- if arg_text != expected:
- failed.append(t)
- fmt = "%s - expected %s, but got %s"
- print fmt % (t.__name__, expected, get_arg_text(t))
- print "%d of %d tests failed" % (len(failed), len(tests))
+ "(ai=None, *b)"
+ def __init__(self, ai=None, *b): "(self, ai=None, *b)"
+ def t1(self): "(self)"
+ def t2(self, ai, b=None): "(self, ai, b=None)"
+ def t3(self, ai, *args): "(self, ai, *args)"
+ def t4(self, *args): "(self, *args)"
+ def t5(self, ai, b=None, *args, **kw): "(self, ai, b=None, *args, **kw)"
+ def t6(no, self): "(no, self)"
+ @classmethod
+ def cm(cls, a): "(cls, a)"
+ @staticmethod
+ def sm(b): "(b)"
+ def __call__(self, ci): "(self, ci)"
tc = TC()
- tests = (t1, t2, t3, t4, t5, t6, t7,
- TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6, tc.t7)
- test(tests)
+ # Python classes that inherit builtin methods
+ class Int(int): "Int(x[, base]) -> integer"
+ class List(list): "List() -> new empty list"
+ # Simulate builtin with no docstring for default argspec test
+ class SB: __call__ = None
+
+ __main__.__dict__.update(locals()) # required for get_entity eval()
+
+ num_tests = num_fail = 0
+ tip = CallTips().fetch_tip
+
+ def test(expression, expected):
+ nonlocal num_tests, num_fail
+ num_tests += 1
+ argspec = tip(expression)
+ if argspec != expected:
+ num_fail += 1
+ fmt = "%s - expected\n%r\n - but got\n%r"
+ print(fmt % (expression, expected, argspec))
+
+ def test_builtins():
+ # if first line of a possibly multiline compiled docstring changes,
+ # must change corresponding test string
+ test('int', "int(x=0) -> integer")
+ test('Int', Int.__doc__)
+ test('types.MethodType', "method(function, instance)")
+ test('list', "list() -> new empty list")
+ test('List', List.__doc__)
+ test('list.__new__',
+ 'T.__new__(S, ...) -> a new object with type S, a subtype of T')
+ test('list.__init__',
+ 'x.__init__(...) initializes x; see help(type(x)) for signature')
+ append_doc = "L.append(object) -> None -- append object to end"
+ test('list.append', append_doc)
+ test('[].append', append_doc)
+ test('List.append', append_doc)
+ test('SB()', _default_callable_argspec)
+
+ def test_funcs():
+ for func in (t1, t2, t3, t4, t5, TC,):
+ fdoc = func.__doc__
+ test(func.__name__, fdoc + "\n" + fdoc)
+ for func in (TC.t1, TC.t2, TC.t3, TC.t4, TC.t5, TC.t6, TC.sm,
+ TC.__call__):
+ fdoc = func.__doc__
+ test('TC.'+func.__name__, fdoc + "\n" + fdoc)
+ fdoc = TC.cm.__func__.__doc__
+ test('TC.cm.__func__', fdoc + "\n" + fdoc)
+
+ def test_methods():
+ # test that first parameter is correctly removed from argspec
+ # using _first_param re to calculate expected masks re errors
+ for meth, mdoc in ((tc.t1, "()"), (tc.t4, "(*args)"), (tc.t6, "(self)"),
+ (TC.cm, "(a)"),):
+ test('tc.'+meth.__name__, mdoc + "\n" + meth.__doc__)
+ test('tc', "(ci)" + "\n" + tc.__call__.__doc__)
+ # directly test that re works to delete unicode parameter name
+ uni = "(A\u0391\u0410\u05d0\u0627\u0905\u1e00\u3042, a)" # various As
+ assert _first_param.sub('', uni) == '(a)'
+
+ def test_non_callables():
+ # expression evaluates, but not to a callable
+ for expr in ('0', '0.0' 'num_tests', b'num_tests', '[]', '{}'):
+ test(expr, '')
+ # expression does not evaluate, but raises an exception
+ for expr in ('1a', 'xyx', 'num_tests.xyz', '[int][1]', '{0:int}[1]'):
+ test(expr, '')
+
+ test_builtins()
+ test_funcs()
+ test_non_callables()
+ test_methods()
+
+ print("%d of %d tests failed" % (num_fail, num_tests))
+
+if __name__ == '__main__':
+ main()
diff --git a/Lib/idlelib/ClassBrowser.py b/Lib/idlelib/ClassBrowser.py
index 095b30dad8f..71176cd7015 100644
--- a/Lib/idlelib/ClassBrowser.py
+++ b/Lib/idlelib/ClassBrowser.py
@@ -94,7 +94,7 @@ class ModuleBrowserTreeItem(TreeItem):
return []
try:
dict = pyclbr.readmodule_ex(name, [dir] + sys.path)
- except ImportError, msg:
+ except ImportError as msg:
return []
items = []
self.classes = {}
diff --git a/Lib/idlelib/CodeContext.py b/Lib/idlelib/CodeContext.py
index 2f6f737b670..84491d5a9d1 100644
--- a/Lib/idlelib/CodeContext.py
+++ b/Lib/idlelib/CodeContext.py
@@ -9,10 +9,10 @@ variable in the CodeContext section of config-extensions.def. Lines which do
not open blocks are not shown in the context hints pane.
"""
-import Tkinter
-from Tkconstants import TOP, LEFT, X, W, SUNKEN
+import tkinter
+from tkinter.constants import TOP, LEFT, X, W, SUNKEN
import re
-from sys import maxint as INFINITY
+from sys import maxsize as INFINITY
from idlelib.configHandler import idleConf
BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for",
@@ -69,7 +69,7 @@ class CodeContext:
border = 0
for widget in widgets:
border += int(str( widget.cget('border') ))
- self.label = Tkinter.Label(self.editwin.top,
+ self.label = tkinter.Label(self.editwin.top,
text="\n" * (self.context_depth - 1),
anchor=W, justify=LEFT,
font=self.textfont,
@@ -117,7 +117,7 @@ class CodeContext:
lastindent = INFINITY
# For a line to be interesting, it must begin with a block opening
# keyword, and have less indentation than lastindent.
- for linenum in xrange(new_topvisible, stopline-1, -1):
+ for linenum in range(new_topvisible, stopline-1, -1):
indent, text, opener = self.get_line_info(linenum)
if indent < lastindent:
lastindent = indent
diff --git a/Lib/idlelib/ColorDelegator.py b/Lib/idlelib/ColorDelegator.py
index 7f4d740ffac..e1881929941 100644
--- a/Lib/idlelib/ColorDelegator.py
+++ b/Lib/idlelib/ColorDelegator.py
@@ -1,8 +1,8 @@
import time
import re
import keyword
-import __builtin__
-from Tkinter import *
+import builtins
+from tkinter import *
from idlelib.Delegator import Delegator
from idlelib.configHandler import idleConf
@@ -14,16 +14,17 @@ def any(name, alternates):
def make_pat():
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
- builtinlist = [str(name) for name in dir(__builtin__)
- if not name.startswith('_')]
- # self.file = file("file") :
+ builtinlist = [str(name) for name in dir(builtins)
+ if not name.startswith('_') and \
+ name not in keyword.kwlist]
+ # self.file = open("file") :
# 1st 'file' colorized normal, 2nd as builtin, 3rd as string
builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
comment = any("COMMENT", [r"#[^\n]*"])
- sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
- dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
- sq3string = r"(\b[rRuU])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
- dq3string = r'(\b[rRuU])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
+ sqstring = r"(\b[rRbB])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
+ dqstring = r'(\b[rRbB])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
+ sq3string = r"(\b[rRbB])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
+ dq3string = r'(\b[rRbB])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
return kw + "|" + builtin + "|" + comment + "|" + string +\
"|" + any("SYNC", [r"\n"])
@@ -72,7 +73,7 @@ class ColorDelegator(Delegator):
"hit": idleConf.GetHighlight(theme, "hit"),
}
- if DEBUG: print 'tagdefs',self.tagdefs
+ if DEBUG: print('tagdefs',self.tagdefs)
def insert(self, index, chars, tags=None):
index = self.index(index)
@@ -91,13 +92,13 @@ class ColorDelegator(Delegator):
def notify_range(self, index1, index2=None):
self.tag_add("TODO", index1, index2)
if self.after_id:
- if DEBUG: print "colorizing already scheduled"
+ if DEBUG: print("colorizing already scheduled")
return
if self.colorizing:
self.stop_colorizing = True
- if DEBUG: print "stop colorizing"
+ if DEBUG: print("stop colorizing")
if self.allow_colorizing:
- if DEBUG: print "schedule colorizing"
+ if DEBUG: print("schedule colorizing")
self.after_id = self.after(1, self.recolorize)
close_when_done = None # Window to be closed when done colorizing
@@ -106,7 +107,7 @@ class ColorDelegator(Delegator):
if self.after_id:
after_id = self.after_id
self.after_id = None
- if DEBUG: print "cancel scheduled recolorizer"
+ if DEBUG: print("cancel scheduled recolorizer")
self.after_cancel(after_id)
self.allow_colorizing = False
self.stop_colorizing = True
@@ -120,42 +121,42 @@ class ColorDelegator(Delegator):
if self.after_id:
after_id = self.after_id
self.after_id = None
- if DEBUG: print "cancel scheduled recolorizer"
+ if DEBUG: print("cancel scheduled recolorizer")
self.after_cancel(after_id)
if self.allow_colorizing and self.colorizing:
- if DEBUG: print "stop colorizing"
+ if DEBUG: print("stop colorizing")
self.stop_colorizing = True
self.allow_colorizing = not self.allow_colorizing
if self.allow_colorizing and not self.colorizing:
self.after_id = self.after(1, self.recolorize)
if DEBUG:
- print "auto colorizing turned",\
- self.allow_colorizing and "on" or "off"
+ print("auto colorizing turned",\
+ self.allow_colorizing and "on" or "off")
return "break"
def recolorize(self):
self.after_id = None
if not self.delegate:
- if DEBUG: print "no delegate"
+ if DEBUG: print("no delegate")
return
if not self.allow_colorizing:
- if DEBUG: print "auto colorizing is off"
+ if DEBUG: print("auto colorizing is off")
return
if self.colorizing:
- if DEBUG: print "already colorizing"
+ if DEBUG: print("already colorizing")
return
try:
self.stop_colorizing = False
self.colorizing = True
- if DEBUG: print "colorizing..."
+ if DEBUG: print("colorizing...")
t0 = time.clock()
self.recolorize_main()
t1 = time.clock()
- if DEBUG: print "%.3f seconds" % (t1-t0)
+ if DEBUG: print("%.3f seconds" % (t1-t0))
finally:
self.colorizing = False
if self.allow_colorizing and self.tag_nextrange("TODO", "1.0"):
- if DEBUG: print "reschedule colorizing"
+ if DEBUG: print("reschedule colorizing")
self.after_id = self.after(1, self.recolorize)
if self.close_when_done:
top = self.close_when_done
@@ -190,7 +191,7 @@ class ColorDelegator(Delegator):
##print head, "get", mark, next, "->", repr(line)
if not line:
return
- for tag in self.tagdefs.keys():
+ for tag in self.tagdefs:
self.tag_remove(tag, mark, next)
chars = chars + line
m = self.prog.search(chars)
@@ -240,11 +241,11 @@ class ColorDelegator(Delegator):
self.tag_add("TODO", next)
self.update()
if self.stop_colorizing:
- if DEBUG: print "colorizing stopped"
+ if DEBUG: print("colorizing stopped")
return
def removecolors(self):
- for tag in self.tagdefs.keys():
+ for tag in self.tagdefs:
self.tag_remove(tag, "1.0", "end")
def main():
diff --git a/Lib/idlelib/Debugger.py b/Lib/idlelib/Debugger.py
index 04eea3235b6..ed66084e91c 100644
--- a/Lib/idlelib/Debugger.py
+++ b/Lib/idlelib/Debugger.py
@@ -1,7 +1,7 @@
import os
import bdb
import types
-from Tkinter import *
+from tkinter import *
from idlelib.WindowList import ListedToplevel
from idlelib.ScrolledList import ScrolledList
from idlelib import macosxSupport
@@ -253,7 +253,8 @@ class Debugger:
if self.vsource.get():
self.sync_source_line()
- def show_frame(self, (frame, lineno)):
+ def show_frame(self, stackitem):
+ frame, lineno = stackitem
self.frame = frame
self.show_variables()
@@ -311,8 +312,7 @@ class Debugger:
def load_breakpoints(self):
"Load PyShellEditorWindow breakpoints into subprocess debugger"
- pyshell_edit_windows = self.pyshell.flist.inversedict.keys()
- for editwin in pyshell_edit_windows:
+ for editwin in self.pyshell.flist.inversedict:
filename = editwin.io.filename
try:
for lineno in editwin.breakpoints:
@@ -348,8 +348,7 @@ class StackViewer(ScrolledList):
funcname = code.co_name
import linecache
sourceline = linecache.getline(filename, lineno)
- import string
- sourceline = string.strip(sourceline)
+ sourceline = sourceline.strip()
if funcname in ("?", "", None):
item = "%s, line %d: %s" % (modname, lineno, sourceline)
else:
@@ -413,8 +412,8 @@ class NamespaceViewer:
height = 20*len(dict) # XXX 20 == observed height of Entry widget
self.master = master
self.title = title
- import repr
- self.repr = repr.Repr()
+ import reprlib
+ self.repr = reprlib.Repr()
self.repr.maxstring = 60
self.repr.maxother = 60
self.frame = frame = Frame(master)
@@ -440,15 +439,27 @@ class NamespaceViewer:
return
subframe = self.subframe
frame = self.frame
- for c in subframe.children.values():
+ for c in list(subframe.children.values()):
c.destroy()
self.dict = None
if not dict:
l = Label(subframe, text="None")
l.grid(row=0, column=0)
else:
- names = dict.keys()
- names.sort()
+ #names = sorted(dict)
+ ###
+ # Because of (temporary) limitations on the dict_keys type (not yet
+ # public or pickleable), have the subprocess to send a list of
+ # keys, not a dict_keys object. sorted() will take a dict_keys
+ # (no subprocess) or a list.
+ #
+ # There is also an obscure bug in sorted(dict) where the
+ # interpreter gets into a loop requesting non-existing dict[0],
+ # dict[1], dict[2], etc from the RemoteDebugger.DictProxy.
+ ###
+ keys_list = dict.keys()
+ names = sorted(keys_list)
+ ###
row = 0
for name in names:
value = dict[name]
diff --git a/Lib/idlelib/Delegator.py b/Lib/idlelib/Delegator.py
index 6125591fe0d..93253b9fbc2 100644
--- a/Lib/idlelib/Delegator.py
+++ b/Lib/idlelib/Delegator.py
@@ -13,7 +13,7 @@ class Delegator:
return attr
def resetcache(self):
- for key in self.__cache.keys():
+ for key in self.__cache:
try:
delattr(self, key)
except AttributeError:
@@ -21,9 +21,9 @@ class Delegator:
self.__cache.clear()
def cachereport(self):
- keys = self.__cache.keys()
+ keys = list(self.__cache.keys())
keys.sort()
- print keys
+ print(keys)
def setdelegate(self, delegate):
self.resetcache()
diff --git a/Lib/idlelib/EditorWindow.py b/Lib/idlelib/EditorWindow.py
index 0a01c9ec305..16f63c52a40 100644
--- a/Lib/idlelib/EditorWindow.py
+++ b/Lib/idlelib/EditorWindow.py
@@ -1,10 +1,12 @@
import sys
import os
import re
+import string
import imp
-from Tkinter import *
-import tkSimpleDialog
-import tkMessageBox
+from tkinter import *
+import tkinter.simpledialog as tkSimpleDialog
+import tkinter.messagebox as tkMessageBox
+import traceback
import webbrowser
from idlelib.MultiCall import MultiCallCreator
@@ -47,7 +49,7 @@ def _find_module(fullname, path=None):
try:
path = module.__path__
except AttributeError:
- raise ImportError, 'No source for module ' + module.__name__
+ raise ImportError('No source for module ' + module.__name__)
if descr[2] != imp.PY_SOURCE:
# If all of the above fails and didn't raise an exception,fallback
# to a straight import which can find __init__.py in a package.
@@ -58,11 +60,7 @@ def _find_module(fullname, path=None):
pass
else:
file = None
- base, ext = os.path.splitext(filename)
- if ext == '.pyc':
- ext = '.py'
- filename = base + ext
- descr = filename, None, imp.PY_SOURCE
+ descr = os.path.splitext(filename)[1], None, imp.PY_SOURCE
return file, filename, descr
@@ -115,7 +113,7 @@ class EditorWindow(object):
from idlelib.UndoDelegator import UndoDelegator
from idlelib.IOBinding import IOBinding, filesystemencoding, encoding
from idlelib import Bindings
- from Tkinter import Toplevel
+ from tkinter import Toplevel
from idlelib.MultiStatusBar import MultiStatusBar
help_url = None
@@ -172,13 +170,15 @@ class EditorWindow(object):
'recent-files.lst')
self.text_frame = text_frame = Frame(top)
self.vbar = vbar = Scrollbar(text_frame, name='vbar')
- self.width = idleConf.GetOption('main','EditorWindow','width', type='int')
+ self.width = idleConf.GetOption('main', 'EditorWindow',
+ 'width', type='int')
text_options = {
'name': 'text',
'padx': 5,
'wrap': 'none',
'width': self.width,
- 'height': idleConf.GetOption('main', 'EditorWindow', 'height', type='int')}
+ 'height': idleConf.GetOption('main', 'EditorWindow',
+ 'height', type='int')}
if TkVersion >= 8.5:
# Starting with tk 8.5 we have to set the new tabstyle option
# to 'wordprocessor' to achieve the same display of tabs as in
@@ -271,7 +271,8 @@ class EditorWindow(object):
# Although use-spaces=0 can be configured manually in config-main.def,
# configuration of tabs v. spaces is not supported in the configuration
# dialog. IDLE promotes the preferred Python indentation: use spaces!
- usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool')
+ usespaces = idleConf.GetOption('main', 'Indent',
+ 'use-spaces', type='bool')
self.usetabs = not usespaces
# tabwidth is the display width of a literal tab character.
@@ -297,39 +298,33 @@ class EditorWindow(object):
# conceivable file).
# Making the initial values larger slows things down more often.
self.num_context_lines = 50, 500, 5000000
-
self.per = per = self.Percolator(text)
-
self.undo = undo = self.UndoDelegator()
per.insertfilter(undo)
text.undo_block_start = undo.undo_block_start
text.undo_block_stop = undo.undo_block_stop
undo.set_saved_change_hook(self.saved_change_hook)
-
# IOBinding implements file I/O and printing functionality
self.io = io = self.IOBinding(self)
io.set_filename_change_hook(self.filename_change_hook)
-
- # Create the recent files submenu
- self.recent_files_menu = Menu(self.menubar)
- self.menudict['file'].insert_cascade(3, label='Recent Files',
- underline=0,
- menu=self.recent_files_menu)
- self.update_recent_files_list()
-
+ self.good_load = False
+ self.set_indentation_params(False)
self.color = None # initialized below in self.ResetColorizer
if filename:
if os.path.exists(filename) and not os.path.isdir(filename):
- io.loadfile(filename)
+ if io.loadfile(filename):
+ self.good_load = True
+ is_py_src = self.ispythonsource(filename)
+ self.set_indentation_params(is_py_src)
+ if is_py_src:
+ self.color = color = self.ColorDelegator()
+ per.insertfilter(color)
else:
io.set_filename(filename)
self.ResetColorizer()
self.saved_change_hook()
-
- self.set_indentation_params(self.ispythonsource(filename))
-
+ self.update_recent_files_list()
self.load_extensions()
-
menu = self.menudict.get('windows')
if menu:
end = menu.index("end")
@@ -348,7 +343,7 @@ class EditorWindow(object):
def _filename_to_unicode(self, filename):
"""convert filename to unicode in order to display it in Tk"""
- if isinstance(filename, unicode) or not filename:
+ if isinstance(filename, str) or not filename:
return filename
else:
try:
@@ -377,7 +372,7 @@ class EditorWindow(object):
insertpt = int(self.text.index("iomark").split(".")[1])
else:
line = self.text.get("insert linestart", "insert lineend")
- for insertpt in xrange(len(line)):
+ for insertpt in range(len(line)):
if line[insertpt] not in (' ','\t'):
break
else:
@@ -391,9 +386,11 @@ class EditorWindow(object):
self.text.tag_remove("sel", "1.0", "end")
else:
if not self.text.index("sel.first"):
- self.text.mark_set("my_anchor", "insert") # there was no previous selection
+ # there was no previous selection
+ self.text.mark_set("my_anchor", "insert")
else:
- if self.text.compare(self.text.index("sel.first"), "<", self.text.index("insert")):
+ if self.text.compare(self.text.index("sel.first"), "<",
+ self.text.index("insert")):
self.text.mark_set("my_anchor", "sel.first") # extend back
else:
self.text.mark_set("my_anchor", "sel.last") # extend forward
@@ -448,13 +445,15 @@ class EditorWindow(object):
underline, label = prepstr(label)
menudict[name] = menu = Menu(mbar, name=name)
mbar.add_cascade(label=label, menu=menu, underline=underline)
-
if macosxSupport.isCarbonAquaTk(self.root):
# Insert the application menu
menudict['application'] = menu = Menu(mbar, name='apple')
mbar.add_cascade(label='IDLE', menu=menu)
-
self.fill_menus()
+ self.recent_files_menu = Menu(self.menubar)
+ self.menudict['file'].insert_cascade(3, label='Recent Files',
+ underline=0,
+ menu=self.recent_files_menu)
self.base_helpmenu_length = self.menudict['help'].index(END)
self.reset_help_menu_entries()
@@ -486,6 +485,7 @@ class EditorWindow(object):
state = getattr(self, verify_state)()
rmenu.entryconfigure(label, state=state)
+
rmenu.tk_popup(event.x_root, event.y_root)
if iswin:
self.text.config(cursor="ibeam")
@@ -636,7 +636,7 @@ class EditorWindow(object):
text.see("insert")
def open_module(self, event=None):
- # XXX Shouldn't this be in IOBinding or in FileList?
+ # XXX Shouldn't this be in IOBinding?
try:
name = self.text.get("sel.first", "sel.last")
except TclError:
@@ -654,7 +654,7 @@ class EditorWindow(object):
# XXX Ought to insert current file's directory in front of path
try:
(f, file, (suffix, mode, type)) = _find_module(name)
- except (NameError, ImportError), msg:
+ except (NameError, ImportError) as msg:
tkMessageBox.showerror("Import error", str(msg), parent=self.text)
return
if type != imp.PY_SOURCE:
@@ -699,13 +699,8 @@ class EditorWindow(object):
base, ext = os.path.splitext(os.path.basename(filename))
if os.path.normcase(ext) in (".py", ".pyw"):
return True
- try:
- f = open(filename)
- line = f.readline()
- f.close()
- except IOError:
- return False
- return line.startswith('#!') and line.find('python') >= 0
+ line = self.text.get('1.0', '1.0 lineend')
+ return line.startswith('#!') and 'python' in line
def close_hook(self):
if self.flist:
@@ -757,6 +752,19 @@ class EditorWindow(object):
selectbackground=select_colors['background'],
)
+ IDENTCHARS = string.ascii_letters + string.digits + "_"
+
+ def colorize_syntax_error(self, text, pos):
+ text.tag_add("ERROR", pos)
+ char = text.get(pos)
+ if char and char in self.IDENTCHARS:
+ text.tag_add("ERROR", pos + " wordstart", pos)
+ if '\n' == text.get(pos): # error at line end
+ text.mark_set("insert", pos)
+ else:
+ text.mark_set("insert", pos + "+1c")
+ text.see(pos)
+
def ResetFont(self):
"Update the text widgets' font if it is changed"
# Called from configDialog.py
@@ -796,7 +804,7 @@ class EditorWindow(object):
for item in menu[1]:
if item:
menuEventDict[menu[0]][prepstr(item[0])[1]] = item[1]
- for menubarItem in self.menudict.keys():
+ for menubarItem in self.menudict:
menu = self.menudict[menubarItem]
end = menu.index(END) + 1
for index in range(0, end):
@@ -855,7 +863,8 @@ class EditorWindow(object):
"Load and update the recent files list and menus"
rf_list = []
if os.path.exists(self.recent_files_path):
- rf_list_file = open(self.recent_files_path,'r')
+ rf_list_file = open(self.recent_files_path,'r',
+ encoding='utf_8', errors='replace')
try:
rf_list = rf_list_file.readlines()
finally:
@@ -874,7 +883,8 @@ class EditorWindow(object):
ulchars = "1234567890ABCDEFGHIJK"
rf_list = rf_list[0:len(ulchars)]
try:
- with open(self.recent_files_path, 'w') as rf_file:
+ with open(self.recent_files_path, 'w',
+ encoding='utf_8', errors='replace') as rf_file:
rf_file.writelines(rf_list)
except IOError as err:
if not getattr(self.root, "recentfilelist_error_displayed", False):
@@ -884,7 +894,7 @@ class EditorWindow(object):
% str(err),
parent=self.text)
# for each edit window instance, construct the recent files menu
- for instance in self.top.instance_dict.keys():
+ for instance in self.top.instance_dict:
menu = instance.recent_files_menu
menu.delete(0, END) # clear, and rebuild:
for i, file_name in enumerate(rf_list):
@@ -968,8 +978,7 @@ class EditorWindow(object):
"Return (width, height, x, y)"
geom = self.top.wm_geometry()
m = re.match(r"(\d+)x(\d+)\+(-?\d+)\+(-?\d+)", geom)
- tuple = (map(int, m.groups()))
- return tuple
+ return list(map(int, m.groups()))
def close_event(self, event):
self.close()
@@ -1014,7 +1023,7 @@ class EditorWindow(object):
self.load_standard_extensions()
def unload_extensions(self):
- for ins in self.extensions.values():
+ for ins in list(self.extensions.values()):
if hasattr(ins, "close"):
ins.close()
self.extensions = {}
@@ -1024,8 +1033,7 @@ class EditorWindow(object):
try:
self.load_extension(name)
except:
- print "Failed to load extension", repr(name)
- import traceback
+ print("Failed to load extension", repr(name))
traceback.print_exc()
def get_standard_extension_names(self):
@@ -1035,8 +1043,8 @@ class EditorWindow(object):
try:
mod = __import__(name, globals(), locals(), [])
except ImportError:
- print "\nFailed to import extension: ", name
- return
+ print("\nFailed to import extension: ", name)
+ raise
cls = getattr(mod, name)
keydefs = idleConf.GetExtensionBindings(name)
if hasattr(cls, "menudefs"):
@@ -1045,7 +1053,7 @@ class EditorWindow(object):
self.extensions[name] = ins
if keydefs:
self.apply_bindings(keydefs)
- for vevent in keydefs.keys():
+ for vevent in keydefs:
methodname = vevent.replace("-", "_")
while methodname[:1] == '<':
methodname = methodname[1:]
@@ -1107,14 +1115,14 @@ class EditorWindow(object):
value = var.get()
return value
else:
- raise NameError, name
+ raise NameError(name)
def setvar(self, name, value, vartype=None):
var = self.get_var_obj(name, vartype)
if var:
var.set(value)
else:
- raise NameError, name
+ raise NameError(name)
def get_var_obj(self, name, vartype=None):
var = self.tkinter_vars.get(name)
@@ -1155,34 +1163,31 @@ class EditorWindow(object):
# Return the text widget's current view of what a tab stop means
# (equivalent width in spaces).
- def get_tabwidth(self):
+ def get_tk_tabwidth(self):
current = self.text['tabs'] or TK_TABWIDTH_DEFAULT
return int(current)
# Set the text widget's current view of what a tab stop means.
- def set_tabwidth(self, newtabwidth):
+ def set_tk_tabwidth(self, newtabwidth):
text = self.text
- if self.get_tabwidth() != newtabwidth:
+ if self.get_tk_tabwidth() != newtabwidth:
+ # Set text widget tab width
pixels = text.tk.call("font", "measure", text["font"],
"-displayof", text.master,
"n" * newtabwidth)
text.configure(tabs=pixels)
- # If ispythonsource and guess are true, guess a good value for
- # indentwidth based on file content (if possible), and if
- # indentwidth != tabwidth set usetabs false.
- # In any case, adjust the Text widget's view of what a tab
- # character means.
+### begin autoindent code ### (configuration was moved to beginning of class)
- def set_indentation_params(self, ispythonsource, guess=True):
- if guess and ispythonsource:
+ def set_indentation_params(self, is_py_src, guess=True):
+ if is_py_src and guess:
i = self.guess_indent()
if 2 <= i <= 8:
self.indentwidth = i
if self.indentwidth != self.tabwidth:
self.usetabs = False
- self.set_tabwidth(self.tabwidth)
+ self.set_tk_tabwidth(self.tabwidth)
def smart_backspace_event(self, event):
text = self.text
@@ -1610,7 +1615,9 @@ class IndentSearcher(object):
_tokenize.tabsize = self.tabwidth
try:
try:
- _tokenize.tokenize(self.readline, self.tokeneater)
+ tokens = _tokenize.generate_tokens(self.readline)
+ for token in tokens:
+ self.tokeneater(*token)
except (_tokenize.TokenError, SyntaxError):
# since we cut off the tokenizer early, we can trigger
# spurious errors
diff --git a/Lib/idlelib/FileList.py b/Lib/idlelib/FileList.py
index 8318ff17b2d..37a337ed9a6 100644
--- a/Lib/idlelib/FileList.py
+++ b/Lib/idlelib/FileList.py
@@ -1,6 +1,6 @@
import os
-from Tkinter import *
-import tkMessageBox
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
class FileList:
@@ -33,7 +33,12 @@ class FileList:
# Don't create window, perform 'action', e.g. open in same window
return action(filename)
else:
- return self.EditorWindow(self, filename, key)
+ edit = self.EditorWindow(self, filename, key)
+ if edit.good_load:
+ return edit
+ else:
+ edit._close()
+ return None
def gotofileline(self, filename, lineno=None):
edit = self.open(filename)
@@ -44,7 +49,7 @@ class FileList:
return self.EditorWindow(self, filename)
def close_all_callback(self, *args, **kwds):
- for edit in self.inversedict.keys():
+ for edit in list(self.inversedict):
reply = edit.close()
if reply == "cancel":
break
@@ -54,7 +59,7 @@ class FileList:
try:
key = self.inversedict[edit]
except KeyError:
- print "Don't know this EditorWindow object. (close)"
+ print("Don't know this EditorWindow object. (close)")
return
if key:
del self.dict[key]
@@ -67,7 +72,7 @@ class FileList:
try:
key = self.inversedict[edit]
except KeyError:
- print "Don't know this EditorWindow object. (rename)"
+ print("Don't know this EditorWindow object. (rename)")
return
filename = edit.io.filename
if not filename:
diff --git a/Lib/idlelib/FormatParagraph.py b/Lib/idlelib/FormatParagraph.py
index 557d8a9e0d7..e3ca7b9b3d4 100644
--- a/Lib/idlelib/FormatParagraph.py
+++ b/Lib/idlelib/FormatParagraph.py
@@ -32,7 +32,7 @@ class FormatParagraph:
self.editwin = None
def format_paragraph_event(self, event):
- maxformatwidth = int(idleConf.GetOption('main','FormatParagraph',
+ maxformatwidth = int(idleConf.GetOption('main', 'FormatParagraph',
'paragraph', type='int'))
text = self.editwin.text
first, last = self.editwin.get_selection_indices()
@@ -47,7 +47,8 @@ class FormatParagraph:
lines = data.split("\n")
lines = map(lambda st, l=len(comment_header): st[l:], lines)
data = "\n".join(lines)
- # Reformat to maxformatwidth chars or a 20 char width, whichever is greater.
+ # Reformat to maxformatwidth chars or a 20 char width,
+ # whichever is greater.
format_width = max(maxformatwidth - len(comment_header), 20)
newdata = reformat_paragraph(data, format_width)
# re-split and re-insert the comment header.
diff --git a/Lib/idlelib/GrepDialog.py b/Lib/idlelib/GrepDialog.py
index e40e5468c0f..27fcc33c329 100644
--- a/Lib/idlelib/GrepDialog.py
+++ b/Lib/idlelib/GrepDialog.py
@@ -1,7 +1,7 @@
import os
import fnmatch
import sys
-from Tkinter import *
+from tkinter import *
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
@@ -77,13 +77,13 @@ class GrepDialog(SearchDialogBase):
list.sort()
self.close()
pat = self.engine.getpat()
- print "Searching %r in %s ..." % (pat, path)
+ print("Searching %r in %s ..." % (pat, path))
hits = 0
for fn in list:
try:
- f = open(fn)
- except IOError, msg:
- print msg
+ f = open(fn, errors='replace')
+ except IOError as msg:
+ print(msg)
continue
lineno = 0
while 1:
@@ -102,16 +102,16 @@ class GrepDialog(SearchDialogBase):
s = ""
else:
s = "s"
- print "Found", hits, "hit%s." % s
- print "(Hint: right-click to open locations.)"
+ print("Found", hits, "hit%s." % s)
+ print("(Hint: right-click to open locations.)")
else:
- print "No hits."
+ print("No hits.")
def findfiles(self, dir, base, rec):
try:
names = os.listdir(dir or os.curdir)
- except os.error, msg:
- print msg
+ except os.error as msg:
+ print(msg)
return []
list = []
subdirs = []
diff --git a/Lib/idlelib/IOBinding.py b/Lib/idlelib/IOBinding.py
index e429c100ba3..9528c9acaa0 100644
--- a/Lib/idlelib/IOBinding.py
+++ b/Lib/idlelib/IOBinding.py
@@ -1,28 +1,17 @@
-# changes by dscherer@cmu.edu
-# - IOBinding.open() replaces the current window with the opened file,
-# if the current window is both unmodified and unnamed
-# - IOBinding.loadfile() interprets Windows, UNIX, and Macintosh
-# end-of-line conventions, instead of relying on the standard library,
-# which will only understand the local convention.
-
import os
import types
import sys
import codecs
import tempfile
-import tkFileDialog
-import tkMessageBox
+import tkinter.filedialog as tkFileDialog
+import tkinter.messagebox as tkMessageBox
import re
-from Tkinter import *
-from SimpleDialog import SimpleDialog
+from tkinter import *
+from tkinter.simpledialog import askstring
from idlelib.configHandler import idleConf
-try:
- from codecs import BOM_UTF8
-except ImportError:
- # only available since Python 2.3
- BOM_UTF8 = '\xef\xbb\xbf'
+from codecs import BOM_UTF8
# Try setting the locale, so that we can find out
# what encoding to use
@@ -33,15 +22,15 @@ except (ImportError, locale.Error):
pass
# Encoding for file names
-filesystemencoding = sys.getfilesystemencoding()
+filesystemencoding = sys.getfilesystemencoding() ### currently unused
-encoding = "ascii"
+locale_encoding = 'ascii'
if sys.platform == 'win32':
# On Windows, we could use "mbcs". However, to give the user
# a portable encoding name, we need to find the code page
try:
- encoding = locale.getdefaultlocale()[1]
- codecs.lookup(encoding)
+ locale_encoding = locale.getdefaultlocale()[1]
+ codecs.lookup(locale_encoding)
except LookupError:
pass
else:
@@ -50,94 +39,65 @@ else:
# loaded, it may not offer nl_langinfo, or CODESET, or the
# resulting codeset may be unknown to Python. We ignore all
# these problems, falling back to ASCII
- encoding = locale.nl_langinfo(locale.CODESET)
- if encoding is None or encoding is '':
+ locale_encoding = locale.nl_langinfo(locale.CODESET)
+ if locale_encoding is None or locale_encoding is '':
# situation occurs on Mac OS X
- encoding = 'ascii'
- codecs.lookup(encoding)
+ locale_encoding = 'ascii'
+ codecs.lookup(locale_encoding)
except (NameError, AttributeError, LookupError):
- # Try getdefaultlocale well: it parses environment variables,
+ # Try getdefaultlocale: it parses environment variables,
# which may give a clue. Unfortunately, getdefaultlocale has
# bugs that can cause ValueError.
try:
- encoding = locale.getdefaultlocale()[1]
- if encoding is None or encoding is '':
+ locale_encoding = locale.getdefaultlocale()[1]
+ if locale_encoding is None or locale_encoding is '':
# situation occurs on Mac OS X
- encoding = 'ascii'
- codecs.lookup(encoding)
+ locale_encoding = 'ascii'
+ codecs.lookup(locale_encoding)
except (ValueError, LookupError):
pass
-encoding = encoding.lower()
+locale_encoding = locale_encoding.lower()
+
+encoding = locale_encoding ### KBK 07Sep07 This is used all over IDLE, check!
+ ### 'encoding' is used below in encode(), check!
coding_re = re.compile("coding[:=]\s*([-\w_.]+)")
-class EncodingMessage(SimpleDialog):
- "Inform user that an encoding declaration is needed."
- def __init__(self, master, enc):
- self.should_edit = False
-
- self.root = top = Toplevel(master)
- top.bind("<Return>", self.return_event)
- top.bind("<Escape>", self.do_ok)
- top.protocol("WM_DELETE_WINDOW", self.wm_delete_window)
- top.wm_title("I/O Warning")
- top.wm_iconname("I/O Warning")
- self.top = top
-
- l1 = Label(top,
- text="Non-ASCII found, yet no encoding declared. Add a line like")
- l1.pack(side=TOP, anchor=W)
- l2 = Entry(top, font="courier")
- l2.insert(0, "# -*- coding: %s -*-" % enc)
- # For some reason, the text is not selectable anymore if the
- # widget is disabled.
- # l2['state'] = DISABLED
- l2.pack(side=TOP, anchor = W, fill=X)
- l3 = Label(top, text="to your file\n"
- "Choose OK to save this file as %s\n"
- "Edit your general options to silence this warning" % enc)
- l3.pack(side=TOP, anchor = W)
-
- buttons = Frame(top)
- buttons.pack(side=TOP, fill=X)
- # Both return and cancel mean the same thing: do nothing
- self.default = self.cancel = 0
- b1 = Button(buttons, text="Ok", default="active",
- command=self.do_ok)
- b1.pack(side=LEFT, fill=BOTH, expand=1)
- b2 = Button(buttons, text="Edit my file",
- command=self.do_edit)
- b2.pack(side=LEFT, fill=BOTH, expand=1)
-
- self._set_transient(master)
-
- def do_ok(self):
- self.done(0)
-
- def do_edit(self):
- self.done(1)
-
-def coding_spec(str):
+def coding_spec(data):
"""Return the encoding declaration according to PEP 263.
- Raise LookupError if the encoding is declared but unknown.
- """
- # Only consider the first two lines
- str = str.split("\n")[:2]
- str = "\n".join(str)
+ When checking encoded data, only the first two lines should be passed
+ in to avoid a UnicodeDecodeError if the rest of the data is not unicode.
+ The first two lines would contain the encoding specification.
+ Raise a LookupError if the encoding is declared but unknown.
+ """
+ if isinstance(data, bytes):
+ # This encoding might be wrong. However, the coding
+ # spec must be ASCII-only, so any non-ASCII characters
+ # around here will be ignored. Decoding to Latin-1 should
+ # never fail (except for memory outage)
+ lines = data.decode('iso-8859-1')
+ else:
+ lines = data
+ # consider only the first two lines
+ if '\n' in lines:
+ lst = lines.split('\n')[:2]
+ elif '\r' in lines:
+ lst = lines.split('\r')[:2]
+ else:
+ lst = list(lines)
+ str = '\n'.join(lst)
match = coding_re.search(str)
if not match:
return None
name = match.group(1)
- # Check whether the encoding is known
- import codecs
try:
codecs.lookup(name)
except LookupError:
# The standard encoding error does not indicate the encoding
- raise LookupError, "Unknown encoding "+name
+ raise LookupError("Unknown encoding: "+name)
return name
@@ -241,83 +201,112 @@ class IOBinding:
eol = r"(\r\n)|\n|\r" # \r\n (Windows), \n (UNIX), or \r (Mac)
eol_re = re.compile(eol)
- eol_convention = os.linesep # Default
+ eol_convention = os.linesep # default
def loadfile(self, filename):
try:
# open the file in binary mode so that we can handle
- # end-of-line convention ourselves.
+ # end-of-line convention ourselves.
f = open(filename,'rb')
- chars = f.read()
+ two_lines = f.readline() + f.readline()
+ f.seek(0)
+ bytes = f.read()
f.close()
- except IOError, msg:
+ except IOError as msg:
tkMessageBox.showerror("I/O Error", str(msg), master=self.text)
return False
-
- chars = self.decode(chars)
+ chars, converted = self._decode(two_lines, bytes)
+ if chars is None:
+ tkMessageBox.showerror("Decoding Error",
+ "File %s\nFailed to Decode" % filename,
+ parent=self.text)
+ return False
# We now convert all end-of-lines to '\n's
firsteol = self.eol_re.search(chars)
if firsteol:
self.eol_convention = firsteol.group(0)
- if isinstance(self.eol_convention, unicode):
- # Make sure it is an ASCII string
- self.eol_convention = self.eol_convention.encode("ascii")
chars = self.eol_re.sub(r"\n", chars)
-
self.text.delete("1.0", "end")
self.set_filename(None)
self.text.insert("1.0", chars)
self.reset_undo()
self.set_filename(filename)
+ if converted:
+ # We need to save the conversion results first
+ # before being able to execute the code
+ self.set_saved(False)
self.text.mark_set("insert", "1.0")
self.text.yview("insert")
self.updaterecentfileslist(filename)
return True
- def decode(self, chars):
- """Create a Unicode string
-
- If that fails, let Tcl try its best
- """
+ def _decode(self, two_lines, bytes):
+ "Create a Unicode string."
+ chars = None
# Check presence of a UTF-8 signature first
- if chars.startswith(BOM_UTF8):
+ if bytes.startswith(BOM_UTF8):
try:
- chars = chars[3:].decode("utf-8")
- except UnicodeError:
+ chars = bytes[3:].decode("utf-8")
+ except UnicodeDecodeError:
# has UTF-8 signature, but fails to decode...
- return chars
+ return None, False
else:
# Indicates that this file originally had a BOM
- self.fileencoding = BOM_UTF8
- return chars
+ self.fileencoding = 'BOM'
+ return chars, False
# Next look for coding specification
try:
- enc = coding_spec(chars)
- except LookupError, name:
+ enc = coding_spec(two_lines)
+ except LookupError as name:
tkMessageBox.showerror(
title="Error loading the file",
message="The encoding '%s' is not known to this Python "\
"installation. The file may not display correctly" % name,
master = self.text)
enc = None
+ except UnicodeDecodeError:
+ return None, False
if enc:
try:
- return unicode(chars, enc)
- except UnicodeError:
+ chars = str(bytes, enc)
+ self.fileencoding = enc
+ return chars, False
+ except UnicodeDecodeError:
pass
- # If it is ASCII, we need not to record anything
+ # Try ascii:
try:
- return unicode(chars, 'ascii')
- except UnicodeError:
+ chars = str(bytes, 'ascii')
+ self.fileencoding = None
+ return chars, False
+ except UnicodeDecodeError:
+ pass
+ # Try utf-8:
+ try:
+ chars = str(bytes, 'utf-8')
+ self.fileencoding = 'utf-8'
+ return chars, False
+ except UnicodeDecodeError:
pass
# Finally, try the locale's encoding. This is deprecated;
# the user should declare a non-ASCII encoding
try:
- chars = unicode(chars, encoding)
- self.fileencoding = encoding
- except UnicodeError:
+ # Wait for the editor window to appear
+ self.editwin.text.update()
+ enc = askstring(
+ "Specify file encoding",
+ "The file's encoding is invalid for Python 3.x.\n"
+ "IDLE will convert it to UTF-8.\n"
+ "What is the current encoding of the file?",
+ initialvalue = locale_encoding,
+ parent = self.editwin.text)
+
+ if enc:
+ chars = str(bytes, enc)
+ self.fileencoding = None
+ return chars, True
+ except (UnicodeDecodeError, LookupError):
pass
- return chars
+ return None, False # None on failure
def maybesave(self):
if self.get_saved():
@@ -378,93 +367,59 @@ class IOBinding:
def writefile(self, filename):
self.fixlastline()
- chars = self.encode(self.text.get("1.0", "end-1c"))
+ text = self.text.get("1.0", "end-1c")
if self.eol_convention != "\n":
- chars = chars.replace("\n", self.eol_convention)
+ text = text.replace("\n", self.eol_convention)
+ chars = self.encode(text)
try:
f = open(filename, "wb")
f.write(chars)
f.flush()
f.close()
return True
- except IOError, msg:
+ except IOError as msg:
tkMessageBox.showerror("I/O Error", str(msg),
master=self.text)
return False
def encode(self, chars):
- if isinstance(chars, types.StringType):
+ if isinstance(chars, bytes):
# This is either plain ASCII, or Tk was returning mixed-encoding
# text to us. Don't try to guess further.
return chars
+ # Preserve a BOM that might have been present on opening
+ if self.fileencoding == 'BOM':
+ return BOM_UTF8 + chars.encode("utf-8")
# See whether there is anything non-ASCII in it.
# If not, no need to figure out the encoding.
try:
return chars.encode('ascii')
except UnicodeError:
pass
- # If there is an encoding declared, try this first.
+ # Check if there is an encoding declared
try:
+ # a string, let coding_spec slice it to the first two lines
enc = coding_spec(chars)
failed = None
- except LookupError, msg:
+ except LookupError as msg:
failed = msg
enc = None
+ else:
+ if not enc:
+ # PEP 3120: default source encoding is UTF-8
+ enc = 'utf-8'
if enc:
try:
return chars.encode(enc)
except UnicodeError:
failed = "Invalid encoding '%s'" % enc
- if failed:
- tkMessageBox.showerror(
- "I/O Error",
- "%s. Saving as UTF-8" % failed,
- master = self.text)
- # If there was a UTF-8 signature, use that. This should not fail
- if self.fileencoding == BOM_UTF8 or failed:
- return BOM_UTF8 + chars.encode("utf-8")
- # Try the original file encoding next, if any
- if self.fileencoding:
- try:
- return chars.encode(self.fileencoding)
- except UnicodeError:
- tkMessageBox.showerror(
- "I/O Error",
- "Cannot save this as '%s' anymore. Saving as UTF-8" \
- % self.fileencoding,
- master = self.text)
- return BOM_UTF8 + chars.encode("utf-8")
- # Nothing was declared, and we had not determined an encoding
- # on loading. Recommend an encoding line.
- config_encoding = idleConf.GetOption("main","EditorWindow",
- "encoding")
- if config_encoding == 'utf-8':
- # User has requested that we save files as UTF-8
- return BOM_UTF8 + chars.encode("utf-8")
- ask_user = True
- try:
- chars = chars.encode(encoding)
- enc = encoding
- if config_encoding == 'locale':
- ask_user = False
- except UnicodeError:
- chars = BOM_UTF8 + chars.encode("utf-8")
- enc = "utf-8"
- if not ask_user:
- return chars
- dialog = EncodingMessage(self.editwin.top, enc)
- dialog.go()
- if dialog.num == 1:
- # User asked us to edit the file
- encline = "# -*- coding: %s -*-\n" % enc
- firstline = self.text.get("1.0", "2.0")
- if firstline.startswith("#!"):
- # Insert encoding after #! line
- self.text.insert("2.0", encline)
- else:
- self.text.insert("1.0", encline)
- return self.encode(self.text.get("1.0", "end-1c"))
- return chars
+ tkMessageBox.showerror(
+ "I/O Error",
+ "%s.\nSaving as UTF-8" % failed,
+ master = self.text)
+ # Fallback: save as UTF-8, with BOM - ignoring the incorrect
+ # declared encoding
+ return BOM_UTF8 + chars.encode("utf-8")
def fixlastline(self):
c = self.text.get("end-2c")
@@ -536,8 +491,6 @@ class IOBinding:
self.opendialog = tkFileDialog.Open(master=self.text,
filetypes=self.filetypes)
filename = self.opendialog.show(initialdir=dir, initialfile=base)
- if isinstance(filename, unicode):
- filename = filename.encode(filesystemencoding)
return filename
def defaultfilename(self, mode="open"):
@@ -558,13 +511,12 @@ class IOBinding:
self.savedialog = tkFileDialog.SaveAs(master=self.text,
filetypes=self.filetypes)
filename = self.savedialog.show(initialdir=dir, initialfile=base)
- if isinstance(filename, unicode):
- filename = filename.encode(filesystemencoding)
return filename
def updaterecentfileslist(self,filename):
"Update recent file list on all editor windows"
- self.editwin.update_recent_files_list(filename)
+ if self.editwin.flist:
+ self.editwin.update_recent_files_list(filename)
def test():
root = Tk()
diff --git a/Lib/idlelib/MultiCall.py b/Lib/idlelib/MultiCall.py
index b81c5ed7d04..47f402d3261 100644
--- a/Lib/idlelib/MultiCall.py
+++ b/Lib/idlelib/MultiCall.py
@@ -30,9 +30,8 @@ Each function will be called at most once for each event.
"""
import sys
-import string
import re
-import Tkinter
+import tkinter
from idlelib import macosxSupport
# the event type constants, which define the meaning of mc_type
@@ -258,19 +257,16 @@ def _parse_sequence(sequence):
"""
if not sequence or sequence[0] != '<' or sequence[-1] != '>':
return None
- words = string.split(sequence[1:-1], '-')
-
+ words = sequence[1:-1].split('-')
modifiers = 0
while words and words[0] in _modifier_names:
modifiers |= 1 << _modifier_names[words[0]]
del words[0]
-
if words and words[0] in _type_names:
type = _type_names[words[0]]
del words[0]
else:
return None
-
if _binder_classes[type] is _SimpleBinder:
if modifiers or words:
return None
@@ -309,7 +305,7 @@ def MultiCallCreator(widget):
return _multicall_dict[widget]
class MultiCall (widget):
- assert issubclass(widget, Tkinter.Misc)
+ assert issubclass(widget, tkinter.Misc)
def __init__(self, *args, **kwargs):
widget.__init__(self, *args, **kwargs)
@@ -321,7 +317,8 @@ def MultiCallCreator(widget):
for i in range(len(_types))]
def bind(self, sequence=None, func=None, add=None):
- #print "bind(%s, %s, %s) called." % (sequence, func, add)
+ #print("bind(%s, %s, %s)" % (sequence, func, add),
+ # file=sys.__stderr__)
if type(sequence) is str and len(sequence) > 2 and \
sequence[:2] == "<<" and sequence[-2:] == ">>":
if sequence in self.__eventinfo:
@@ -349,7 +346,8 @@ def MultiCallCreator(widget):
return widget.unbind(self, sequence, funcid)
def event_add(self, virtual, *sequences):
- #print "event_add(%s,%s) was called"%(repr(virtual),repr(sequences))
+ #print("event_add(%s, %s)" % (repr(virtual), repr(sequences)),
+ # file=sys.__stderr__)
if virtual not in self.__eventinfo:
self.__eventinfo[virtual] = [None, []]
@@ -357,7 +355,7 @@ def MultiCallCreator(widget):
for seq in sequences:
triplet = _parse_sequence(seq)
if triplet is None:
- #print >> sys.stderr, "Seq. %s was added by Tkinter."%seq
+ #print("Tkinter event_add(%s)" % seq, file=sys.__stderr__)
widget.event_add(self, virtual, seq)
else:
if func is not None:
@@ -371,7 +369,7 @@ def MultiCallCreator(widget):
for seq in sequences:
triplet = _parse_sequence(seq)
if triplet is None:
- #print >> sys.stderr, "Seq. %s was deleted by Tkinter."%seq
+ #print("Tkinter event_delete: %s" % seq, file=sys.__stderr__)
widget.event_delete(self, virtual, seq)
else:
if func is not None:
@@ -399,12 +397,12 @@ def MultiCallCreator(widget):
if __name__ == "__main__":
# Test
- root = Tkinter.Tk()
- text = MultiCallCreator(Tkinter.Text)(root)
+ root = tkinter.Tk()
+ text = MultiCallCreator(tkinter.Text)(root)
text.pack()
def bindseq(seq, n=[0]):
def handler(event):
- print seq
+ print(seq)
text.bind("<<handler%d>>"%n[0], handler)
text.event_add("<<handler%d>>"%n[0], seq)
n[0] += 1
diff --git a/Lib/idlelib/MultiStatusBar.py b/Lib/idlelib/MultiStatusBar.py
index 8ee2d03d045..4fc8dcf94ba 100644
--- a/Lib/idlelib/MultiStatusBar.py
+++ b/Lib/idlelib/MultiStatusBar.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
class MultiStatusBar(Frame):
diff --git a/Lib/idlelib/NEWS.txt b/Lib/idlelib/NEWS.txt
index 080f98e0f3b..f234b64b853 100644
--- a/Lib/idlelib/NEWS.txt
+++ b/Lib/idlelib/NEWS.txt
@@ -1,17 +1,23 @@
-What's New in IDLE 2.7.4?
+What's New in IDLE 3.2.4?
=========================
+- Issue #7163: Propagate return value of sys.stdout.write.
+
- Issue #15318: Prevent writing to sys.stdin.
- Issue #13532, #15319: Check that arguments to sys.stdout.write are strings.
- Issue # 12510: Attempt to get certain tool tips no longer crashes IDLE.
+ Erroneous tool tips have been corrected. Default added for callables.
- Issue10365: File open dialog now works instead of crashing even when
parent window is closed while dialog is open.
- Issue 14876: use user-selected font for highlight configuration.
+- Issue #14937: Perform auto-completion of filenames in strings even for
+ non-ASCII filenames. Likewise for identifiers.
+
- Issue #14018: Update checks for unstable system Tcl/Tk versions on OS X
to include versions shipped with OS X 10.7 and 10.8 in addition to 10.6.
@@ -19,7 +25,7 @@ What's New in IDLE 2.7.4?
with certain versions of Tk 8.5. Initial patch by Kevin Walzer.
-What's New in IDLE 2.7.3?
+What's New in IDLE 3.2.3?
=========================
- Issue #14409: IDLE now properly executes commands in the Shell window
@@ -31,25 +37,55 @@ What's New in IDLE 2.7.3?
(directory(ies) instead of file(s)).
-What's New in IDLE 2.7.2?
+What's New in IDLE 3.2.1?
=========================
-*Release date: 29-May-2011*
+*Release date: 15-May-11*
- Issue #6378: Further adjust idle.bat to start associated Python
- Issue #11896: Save on Close failed despite selecting "Yes" in dialog.
+- Issue #1028: Ctrl-space binding to show completions was causing IDLE to exit.
+ Tk < 8.5 was sending invalid Unicode null; replaced with valid null.
+
- <Home> toggle failing on Tk 8.5, causing IDLE exits and strange selection
behavior. Issue 4676. Improve selection extension behaviour.
- <Home> toggle non-functional when NumLock set on Windows. Issue 3851.
-What's New in IDLE 2.7?
+What's New in IDLE 3.1b1?
+=========================
+
+*Release date: 06-May-09*
+
+- Use of 'filter' in keybindingDialog.py was causing custom key assignment to
+ fail. Patch 5707 amaury.forgeotdarc.
+
+
+What's New in IDLE 3.1a1?
+=========================
+
+*Release date: 07-Mar-09*
+
+- Issue #4815: Offer conversion to UTF-8 if source files have
+ no encoding declaration and are not encoded in UTF-8.
+
+- Issue #4008: Fix problems with non-ASCII source files.
+
+- Issue #4323: Always encode source as UTF-8 without asking
+ the user (unless a different encoding is declared); remove
+ user configuration of source encoding; all according to
+ PEP 3120.
+
+- Issue #2665: On Windows, an IDLE installation upgraded from an old version
+ would not start if a custom theme was defined.
+
+What's New in IDLE 2.7? (UNRELEASED, but merged into 3.1 releases above.)
=======================
-*Release date: 07-03-2010*
+*Release date: XX-XXX-2010*
- idle.py modified and simplified to better support developing experimental
versions of IDLE which are not installed in the standard location.
@@ -72,33 +108,86 @@ What's New in IDLE 2.7?
- Issue #3549: On MacOS the preferences menu was not present
+What's New in IDLE 3.0 final?
+=============================
-What's New in IDLE 2.6?
-=======================
+*Release date: 03-Dec-2008*
+
+- IDLE would print a "Unhandled server exception!" message when internal
+ debugging is enabled.
+
+- Issue #4455: IDLE failed to display the windows list when two windows have
+ the same title.
+
+- Issue #4383: When IDLE cannot make the connection to its subprocess, it would
+ fail to properly display the error message.
+
+
+What's New in IDLE 3.0a3?
+=========================
+
+*Release date: 29-Feb-2008*
-*Release date: 01-Oct-2008*
+- help() was not paging to the shell. Issue1650.
+
+- CodeContext was not importing.
+
+- Corrected two 3.0 compatibility errors reported by Mark Summerfield:
+ http://mail.python.org/pipermail/python-3000/2007-December/011491.html
+
+- Shell was not colorizing due to bug introduced at r57998, Bug 1586.
+
+- Issue #1585: IDLE uses non-existent xrange() function.
+
+
+What's New in IDLE 3.0a2?
+=========================
+
+*Release date: 06-Dec-2007*
+
+- Windows EOL sequence not converted correctly, encoding error.
+ Caused file save to fail. Bug 1130.
+
+
+What's New in IDLE 3.0a1?
+=========================
+
+*Release date: 31-Aug-2007*
+
+- IDLE converted to Python 3000 syntax.
+
+- Strings became Unicode.
+
+- CallTips module now uses the inspect module to produce the argspec.
+
+- IDLE modules now use absolute import instead of implied relative import.
+
+- atexit call replaces sys.exitfunc. The functionality of delete-exitfunc flag
+ in config-main.cfg remains unchanged: if set, registered exit functions will
+ be cleared before IDLE exits.
+
+
+What's New in IDLE 2.6 final?
+=============================
+
+*Release date: 01-Oct-2008*, merged into 3.0 releases detailed above (3.0rc2)
- Issue #2665: On Windows, an IDLE installation upgraded from an old version
would not start if a custom theme was defined.
- Home / Control-A toggles between left margin and end of leading white
- space. Patch 1196903 Jeff Shute.
+ space. issue1196903, patch by Jeff Shute.
-- Improved AutoCompleteWindow logic. Patch 2062 Tal Einat.
+- Improved AutoCompleteWindow logic. issue2062, patch by Tal Einat.
- Autocompletion of filenames now support alternate separators, e.g. the
- '/' char on Windows. Patch 2061 Tal Einat.
-
-What's New in IDLE 2.6a1?
-=========================
-
-*Release date: 29-Feb-2008*
+ '/' char on Windows. issue2061 Patch by Tal Einat.
- Configured selection highlighting colors were ignored; updating highlighting
in the config dialog would cause non-Python files to be colored as if they
were Python source; improve use of ColorDelagator. Patch 1334. Tal Einat.
-- ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat.
+- ScriptBinding event handlers weren't returning 'break'. Patch 2050, Tal Einat
- There was an error on exit if no sys.exitfunc was defined. Issue 1647.
diff --git a/Lib/idlelib/ObjectBrowser.py b/Lib/idlelib/ObjectBrowser.py
index 7de698816f4..b359efc1b4e 100644
--- a/Lib/idlelib/ObjectBrowser.py
+++ b/Lib/idlelib/ObjectBrowser.py
@@ -11,7 +11,7 @@
from idlelib.TreeWidget import TreeItem, TreeNode, ScrolledCanvas
-from repr import Repr
+from reprlib import Repr
myrepr = Repr()
myrepr.maxstring = 100
@@ -57,15 +57,6 @@ class ObjectTreeItem(TreeItem):
sublist.append(item)
return sublist
-class InstanceTreeItem(ObjectTreeItem):
- def IsExpandable(self):
- return True
- def GetSubList(self):
- sublist = ObjectTreeItem.GetSubList(self)
- sublist.insert(0,
- make_objecttreeitem("__class__ =", self.object.__class__))
- return sublist
-
class ClassTreeItem(ObjectTreeItem):
def IsExpandable(self):
return True
@@ -103,25 +94,21 @@ class SequenceTreeItem(ObjectTreeItem):
class DictTreeItem(SequenceTreeItem):
def keys(self):
- keys = self.object.keys()
+ keys = list(self.object.keys())
try:
keys.sort()
except:
pass
return keys
-from types import *
-
dispatch = {
- IntType: AtomicObjectTreeItem,
- LongType: AtomicObjectTreeItem,
- FloatType: AtomicObjectTreeItem,
- StringType: AtomicObjectTreeItem,
- TupleType: SequenceTreeItem,
- ListType: SequenceTreeItem,
- DictType: DictTreeItem,
- InstanceType: InstanceTreeItem,
- ClassType: ClassTreeItem,
+ int: AtomicObjectTreeItem,
+ float: AtomicObjectTreeItem,
+ str: AtomicObjectTreeItem,
+ tuple: SequenceTreeItem,
+ list: SequenceTreeItem,
+ dict: DictTreeItem,
+ type: ClassTreeItem,
}
def make_objecttreeitem(labeltext, object, setfunction=None):
@@ -136,7 +123,7 @@ def make_objecttreeitem(labeltext, object, setfunction=None):
def _test():
import sys
- from Tkinter import Tk
+ from tkinter import Tk
root = Tk()
root.configure(bd=0, bg="yellow")
root.focus_set()
diff --git a/Lib/idlelib/OutputWindow.py b/Lib/idlelib/OutputWindow.py
index e18d846d8de..745ccd26135 100644
--- a/Lib/idlelib/OutputWindow.py
+++ b/Lib/idlelib/OutputWindow.py
@@ -1,7 +1,7 @@
-from Tkinter import *
+from tkinter import *
from idlelib.EditorWindow import EditorWindow
import re
-import tkMessageBox
+import tkinter.messagebox as tkMessageBox
from idlelib import IOBinding
class OutputWindow(EditorWindow):
@@ -35,17 +35,12 @@ class OutputWindow(EditorWindow):
# Act as output file
def write(self, s, tags=(), mark="insert"):
- # Tk assumes that byte strings are Latin-1;
- # we assume that they are in the locale's encoding
- if isinstance(s, str):
- try:
- s = unicode(s, IOBinding.encoding)
- except UnicodeError:
- # some other encoding; let Tcl deal with it
- pass
+ if isinstance(s, (bytes, bytes)):
+ s = s.decode(IOBinding.encoding, "replace")
self.text.insert(mark, s, tags)
self.text.see(mark)
self.text.update()
+ return len(s)
def writelines(self, lines):
for line in lines:
diff --git a/Lib/idlelib/Percolator.py b/Lib/idlelib/Percolator.py
index e24689b207e..c91de381296 100644
--- a/Lib/idlelib/Percolator.py
+++ b/Lib/idlelib/Percolator.py
@@ -51,21 +51,21 @@ class Percolator:
f.setdelegate(filter.delegate)
filter.setdelegate(None)
-
def main():
+ import tkinter as Tk
class Tracer(Delegator):
def __init__(self, name):
self.name = name
Delegator.__init__(self, None)
def insert(self, *args):
- print self.name, ": insert", args
+ print(self.name, ": insert", args)
self.delegate.insert(*args)
def delete(self, *args):
- print self.name, ": delete", args
+ print(self.name, ": delete", args)
self.delegate.delete(*args)
- root = Tk()
+ root = Tk.Tk()
root.wm_protocol("WM_DELETE_WINDOW", root.quit)
- text = Text()
+ text = Tk.Text()
text.pack()
text.focus_set()
p = Percolator(text)
@@ -73,7 +73,7 @@ def main():
t2 = Tracer("t2")
p.insertfilter(t1)
p.insertfilter(t2)
- root.mainloop()
+ root.mainloop() # click close widget to continue...
p.removefilter(t2)
root.mainloop()
p.insertfilter(t2)
@@ -81,5 +81,4 @@ def main():
root.mainloop()
if __name__ == "__main__":
- from Tkinter import *
main()
diff --git a/Lib/idlelib/PyParse.py b/Lib/idlelib/PyParse.py
index 1a9db6743ce..61a0003ce5a 100644
--- a/Lib/idlelib/PyParse.py
+++ b/Lib/idlelib/PyParse.py
@@ -94,20 +94,16 @@ _chew_ordinaryre = re.compile(r"""
# Build translation table to map uninteresting chars to "x", open
# brackets to "(", and close brackets to ")".
-_tran = ['x'] * 256
+_tran = {}
+for i in range(256):
+ _tran[i] = 'x'
for ch in "({[":
_tran[ord(ch)] = '('
for ch in ")}]":
_tran[ord(ch)] = ')'
for ch in "\"'\\\n#":
_tran[ord(ch)] = ch
-_tran = ''.join(_tran)
-del ch
-
-try:
- UnicodeType = type(unicode(""))
-except NameError:
- UnicodeType = None
+del i, ch
class Parser:
@@ -115,22 +111,22 @@ class Parser:
self.indentwidth = indentwidth
self.tabwidth = tabwidth
- def set_str(self, str):
- assert len(str) == 0 or str[-1] == '\n'
- if type(str) is UnicodeType:
+ def set_str(self, s):
+ assert len(s) == 0 or s[-1] == '\n'
+ if isinstance(s, str):
# The parse functions have no idea what to do with Unicode, so
# replace all Unicode characters with "x". This is "safe"
# so long as the only characters germane to parsing the structure
# of Python are 7-bit ASCII. It's *necessary* because Unicode
# strings don't have a .translate() method that supports
# deletechars.
- uniphooey = str
- str = []
- push = str.append
+ uniphooey = s
+ s = []
+ push = s.append
for raw in map(ord, uniphooey):
push(raw < 127 and chr(raw) or "x")
- str = "".join(str)
- self.str = str
+ s = "".join(s)
+ self.str = s
self.study_level = 0
# Return index of a good place to begin parsing, as close to the
diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
index 15ca392ca24..fb47b994d1f 100644
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -1,14 +1,15 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
+import getopt
import os
import os.path
-import sys
-import string
-import getopt
import re
import socket
-import time
+import subprocess
+import sys
import threading
+import time
+import tokenize
import traceback
import types
import io
@@ -17,12 +18,12 @@ import linecache
from code import InteractiveInterpreter
try:
- from Tkinter import *
+ from tkinter import *
except ImportError:
- print>>sys.__stderr__, "** IDLE can't import Tkinter. " \
- "Your Python may not be configured for Tk. **"
+ print("** IDLE can't import Tkinter. " \
+ "Your Python may not be configured for Tk. **", file=sys.__stderr__)
sys.exit(1)
-import tkMessageBox
+import tkinter.messagebox as tkMessageBox
from idlelib.EditorWindow import EditorWindow, fixwordbreaks
from idlelib.FileList import FileList
@@ -36,15 +37,9 @@ from idlelib import Debugger
from idlelib import RemoteDebugger
from idlelib import macosxSupport
-IDENTCHARS = string.ascii_letters + string.digits + "_"
HOST = '127.0.0.1' # python execution server on localhost loopback
PORT = 0 # someday pass in host, port for remote debug capability
-try:
- from signal import SIGTERM
-except ImportError:
- SIGTERM = 15
-
# Override warnings module to write to warning_stream. Initialize to send IDLE
# internal warnings to the console. ScriptBinding.check_syntax() will
# temporarily redirect the stream to the shell window to display warnings when
@@ -126,6 +121,7 @@ class PyShellEditorWindow(EditorWindow):
("Cut", "<<cut>>", "rmenu_check_cut"),
("Copy", "<<copy>>", "rmenu_check_copy"),
("Paste", "<<paste>>", "rmenu_check_paste"),
+ (None, None, None),
("Set Breakpoint", "<<set-breakpoint-here>>", None),
("Clear Breakpoint", "<<clear-breakpoint-here>>", None)
]
@@ -213,12 +209,12 @@ class PyShellEditorWindow(EditorWindow):
breaks = self.breakpoints
filename = self.io.filename
try:
- with open(self.breakpointPath,"r") as old_file:
- lines = old_file.readlines()
+ with open(self.breakpointPath, "r") as fp:
+ lines = fp.readlines()
except IOError:
lines = []
try:
- with open(self.breakpointPath,"w") as new_file:
+ with open(self.breakpointPath, "w") as new_file:
for line in lines:
if not line.startswith(filename + '='):
new_file.write(line)
@@ -240,7 +236,8 @@ class PyShellEditorWindow(EditorWindow):
if filename is None:
return
if os.path.isfile(self.breakpointPath):
- lines = open(self.breakpointPath,"r").readlines()
+ with open(self.breakpointPath, "r") as fp:
+ lines = fp.readlines()
for line in lines:
if line.startswith(filename + '='):
breakpoint_linenumbers = eval(line[len(filename)+1:])
@@ -366,20 +363,17 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.original_compiler_flags = self.compile.compiler.flags
rpcclt = None
- rpcpid = None
+ rpcsubproc = None
def spawn_subprocess(self):
if self.subprocess_arglist is None:
self.subprocess_arglist = self.build_subprocess_arglist()
- args = self.subprocess_arglist
- self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args)
+ self.rpcsubproc = subprocess.Popen(self.subprocess_arglist)
def build_subprocess_arglist(self):
assert (self.port!=0), (
"Socket should have been assigned a port number.")
w = ['-W' + s for s in sys.warnoptions]
- if 1/2 > 0: # account for new division
- w.append('-Qnew')
# Maybe IDLE is installed and is being accessed via sys.path,
# or maybe it's not installed and the idle.py script is being
# run from the IDLE source directory.
@@ -389,12 +383,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
command = "__import__('idlelib.run').run.main(%r)" % (del_exitf,)
else:
command = "__import__('run').main(%r)" % (del_exitf,)
- if sys.platform[:3] == 'win' and ' ' in sys.executable:
- # handle embedded space in path by quoting the argument
- decorated_exec = '"%s"' % sys.executable
- else:
- decorated_exec = sys.executable
- return [decorated_exec] + w + ["-c", command, str(self.port)]
+ return [sys.executable] + w + ["-c", command, str(self.port)]
def start_subprocess(self):
addr = (HOST, self.port)
@@ -404,7 +393,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
try:
self.rpcclt = MyRPCClient(addr)
break
- except socket.error, err:
+ except socket.error as err:
pass
else:
self.display_port_binding_error()
@@ -425,7 +414,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.rpcclt.listening_sock.settimeout(10)
try:
self.rpcclt.accept()
- except socket.timeout, err:
+ except socket.timeout as err:
self.display_no_subprocess_error()
return None
# Can't regiter self.tkconsole.stdin, since run.py wants to
@@ -455,14 +444,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
pass
# Kill subprocess, spawn a new one, accept connection.
self.rpcclt.close()
- self.unix_terminate()
+ self.terminate_subprocess()
console = self.tkconsole
was_executing = console.executing
console.executing = False
self.spawn_subprocess()
try:
self.rpcclt.accept()
- except socket.timeout, err:
+ except socket.timeout as err:
self.display_no_subprocess_error()
return None
self.transfer_path(with_cwd=with_cwd)
@@ -497,23 +486,22 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.rpcclt.close()
except AttributeError: # no socket
pass
- self.unix_terminate()
+ self.terminate_subprocess()
self.tkconsole.executing = False
self.rpcclt = None
- def unix_terminate(self):
- "UNIX: make sure subprocess is terminated and collect status"
- if hasattr(os, 'kill'):
+ def terminate_subprocess(self):
+ "Make sure subprocess is terminated"
+ try:
+ self.rpcsubproc.kill()
+ except OSError:
+ # process already terminated
+ return
+ else:
try:
- os.kill(self.rpcpid, SIGTERM)
+ self.rpcsubproc.wait()
except OSError:
- # process already terminated:
return
- else:
- try:
- os.waitpid(self.rpcpid, 0)
- except OSError:
- return
def transfer_path(self, with_cwd=False):
if with_cwd: # Issue 13506
@@ -550,14 +538,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
console = self.tkconsole.console
if how == "OK":
if what is not None:
- print >>console, repr(what)
+ print(repr(what), file=console)
elif how == "EXCEPTION":
if self.tkconsole.getvar("<<toggle-jit-stack-viewer>>"):
self.remote_stack_viewer()
elif how == "ERROR":
errmsg = "PyShell.ModifiedInterpreter: Subprocess ERROR:\n"
- print >>sys.__stderr__, errmsg, what
- print >>console, errmsg, what
+ print(errmsg, what, file=sys.__stderr__)
+ print(errmsg, what, file=console)
# we received a response to the currently active seq number:
try:
self.tkconsole.endexecuting()
@@ -616,14 +604,15 @@ class ModifiedInterpreter(InteractiveInterpreter):
def execfile(self, filename, source=None):
"Execute an existing file"
if source is None:
- source = open(filename, "r").read()
+ with tokenize.open(filename) as fp:
+ source = fp.read()
try:
code = compile(source, filename, "exec")
except (OverflowError, SyntaxError):
self.tkconsole.resetoutput()
tkerr = self.tkconsole.stderr
- print>>tkerr, '*** Error in script or command!\n'
- print>>tkerr, 'Traceback (most recent call last):'
+ print('*** Error in script or command!\n', file=tkerr)
+ print('Traceback (most recent call last):', file=tkerr)
InteractiveInterpreter.showsyntaxerror(self, filename)
self.tkconsole.showprompt()
else:
@@ -635,14 +624,16 @@ class ModifiedInterpreter(InteractiveInterpreter):
self.more = 0
self.save_warnings_filters = warnings.filters[:]
warnings.filterwarnings(action="error", category=SyntaxWarning)
- if isinstance(source, types.UnicodeType):
- from idlelib import IOBinding
- try:
- source = source.encode(IOBinding.encoding)
- except UnicodeError:
- self.tkconsole.resetoutput()
- self.write("Unsupported characters in input\n")
- return
+ # at the moment, InteractiveInterpreter expects str
+ assert isinstance(source, str)
+ #if isinstance(source, str):
+ # from idlelib import IOBinding
+ # try:
+ # source = source.encode(IOBinding.encoding)
+ # except UnicodeError:
+ # self.tkconsole.resetoutput()
+ # self.write("Unsupported characters in input\n")
+ # return
try:
# InteractiveInterpreter.runsource() calls its runcode() method,
# which is overridden (see below)
@@ -673,47 +664,30 @@ class ModifiedInterpreter(InteractiveInterpreter):
\n""" % (filename,))
def showsyntaxerror(self, filename=None):
- """Extend base class method: Add Colorizing
+ """Override Interactive Interpreter method: Use Colorizing
Color the offending position instead of printing it and pointing at it
with a caret.
"""
- text = self.tkconsole.text
- stuff = self.unpackerror()
- if stuff:
- msg, lineno, offset, line = stuff
- if lineno == 1:
- pos = "iomark + %d chars" % (offset-1)
- else:
- pos = "iomark linestart + %d lines + %d chars" % \
- (lineno-1, offset-1)
- text.tag_add("ERROR", pos)
- text.see(pos)
- char = text.get(pos)
- if char and char in IDENTCHARS:
- text.tag_add("ERROR", pos + " wordstart", pos)
- self.tkconsole.resetoutput()
- self.write("SyntaxError: %s\n" % str(msg))
- else:
- self.tkconsole.resetoutput()
- InteractiveInterpreter.showsyntaxerror(self, filename)
- self.tkconsole.showprompt()
-
- def unpackerror(self):
+ tkconsole = self.tkconsole
+ text = tkconsole.text
+ text.tag_remove("ERROR", "1.0", "end")
type, value, tb = sys.exc_info()
- ok = type is SyntaxError
- if ok:
- try:
- msg, (dummy_filename, lineno, offset, line) = value
- if not offset:
- offset = 0
- except:
- ok = 0
- if ok:
- return msg, lineno, offset, line
+ msg = getattr(value, 'msg', '') or value or "<no detail available>"
+ lineno = getattr(value, 'lineno', '') or 1
+ offset = getattr(value, 'offset', '') or 0
+ if offset == 0:
+ lineno += 1 #mark end of offending line
+ if lineno == 1:
+ pos = "iomark + %d chars" % (offset-1)
else:
- return None
+ pos = "iomark linestart + %d lines + %d chars" % \
+ (lineno-1, offset-1)
+ tkconsole.colorize_syntax_error(text, pos)
+ tkconsole.resetoutput()
+ self.write("SyntaxError: %s\n" % msg)
+ tkconsole.showprompt()
def showtraceback(self):
"Extend base class method to reset output properly"
@@ -725,7 +699,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
def checklinecache(self):
c = linecache.cache
- for key in c.keys():
+ for key in list(c.keys()):
if key[:1] + key[-1:] != "<>":
del c[key]
@@ -738,7 +712,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
if self.rpcclt:
self.rpcclt.remotequeue("exec", "runcode", (code,), {})
else:
- exec code in self.locals
+ exec(code, self.locals)
return 1
def runcode(self, code):
@@ -758,7 +732,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
elif debugger:
debugger.run(code, self.locals)
else:
- exec code in self.locals
+ exec(code, self.locals)
except SystemExit:
if not self.tkconsole.closing:
if tkMessageBox.askyesno(
@@ -773,14 +747,14 @@ class ModifiedInterpreter(InteractiveInterpreter):
raise
except:
if use_subprocess:
- print >>self.tkconsole.stderr, \
- "IDLE internal error in runcode()"
+ print("IDLE internal error in runcode()",
+ file=self.tkconsole.stderr)
self.showtraceback()
self.tkconsole.endexecuting()
else:
if self.tkconsole.canceled:
self.tkconsole.canceled = False
- print >>self.tkconsole.stderr, "KeyboardInterrupt"
+ print("KeyboardInterrupt", file=self.tkconsole.stderr)
else:
self.showtraceback()
finally:
@@ -792,7 +766,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
def write(self, s):
"Override base class method"
- self.tkconsole.stderr.write(s)
+ return self.tkconsole.stderr.write(s)
def display_port_binding_error(self):
tkMessageBox.showerror(
@@ -876,6 +850,8 @@ class PyShell(OutputWindow):
text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
text.bind("<<toggle-debugger>>", self.toggle_debugger)
text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
+ self.color = color = self.ColorDelegator()
+ self.per.insertfilter(color)
if use_subprocess:
text.bind("<<view-restart>>", self.view_restart_mark)
text.bind("<<restart-shell>>", self.restart_shell)
@@ -892,6 +868,14 @@ class PyShell(OutputWindow):
sys.stdout = self.stdout
sys.stderr = self.stderr
sys.stdin = self.stdin
+ try:
+ # page help() text to shell.
+ import pydoc # import must be done here to capture i/o rebinding.
+ # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc
+ pydoc.pager = pydoc.plainpager
+ except:
+ sys.stderr = sys.__stderr__
+ raise
#
self.history = self.History(self.text)
#
@@ -1017,6 +1001,7 @@ class PyShell(OutputWindow):
'Type "copyright", "credits" or "license()" for more information.'
def begin(self):
+ self.text.mark_set("iomark", "insert")
self.resetoutput()
if use_subprocess:
nosub = ''
@@ -1029,8 +1014,8 @@ class PyShell(OutputWindow):
self.write("Python %s on %s\n%s\n%s" %
(sys.version, sys.platform, self.COPYRIGHT, nosub))
self.showprompt()
- import Tkinter
- Tkinter._default_root = None # 03Jan04 KBK What's this?
+ import tkinter
+ tkinter._default_root = None # 03Jan04 KBK What's this?
return True
def readline(self):
@@ -1043,12 +1028,6 @@ class PyShell(OutputWindow):
line = self.text.get("iomark", "end-1c")
if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C
line = "\n"
- if isinstance(line, unicode):
- from idlelib import IOBinding
- try:
- line = line.encode(IOBinding.encoding)
- except UnicodeError:
- pass
self.resetoutput()
if self.canceled:
self.canceled = 0
@@ -1166,7 +1145,7 @@ class PyShell(OutputWindow):
self.text.tag_add("stdin", "iomark", "end-1c")
self.text.update_idletasks()
if self.reading:
- self.top.quit() # Break out of recursive mainloop() in raw_input()
+ self.top.quit() # Break out of recursive mainloop()
else:
self.runit()
return "break"
@@ -1252,19 +1231,20 @@ class PyShell(OutputWindow):
self.text.insert("end-1c", "\n")
self.text.mark_set("iomark", "end-1c")
self.set_line_and_column()
- sys.stdout.softspace = 0
def write(self, s, tags=()):
try:
self.text.mark_gravity("iomark", "right")
- OutputWindow.write(self, s, tags, "iomark")
+ count = OutputWindow.write(self, s, tags, "iomark")
self.text.mark_gravity("iomark", "left")
except:
- pass
+ raise ###pass # ### 11Aug07 KBK if we are expecting exceptions
+ # let's find out what they are and be specific.
if self.canceled:
self.canceled = 0
if not use_subprocess:
raise KeyboardInterrupt
+ return count
def rmenu_check_cut(self):
try:
@@ -1272,25 +1252,24 @@ class PyShell(OutputWindow):
return 'disabled'
except TclError: # no selection, so the index 'sel.first' doesn't exist
return 'disabled'
- return super(PyShell, self).rmenu_check_cut()
+ return super().rmenu_check_cut()
def rmenu_check_paste(self):
- if self.text.compare('insert', '<', 'iomark'):
+ if self.text.compare('insert','<','iomark'):
return 'disabled'
- return super(PyShell, self).rmenu_check_paste()
+ return super().rmenu_check_paste()
class PseudoFile(object):
def __init__(self, shell, tags, encoding=None):
self.shell = shell
self.tags = tags
- self.softspace = 0
self.encoding = encoding
def write(self, s):
- if not isinstance(s, (basestring, bytearray)):
- raise TypeError('must be string, not ' + type(s).__name__)
- self.shell.write(s, self.tags)
+ if not isinstance(s, str):
+ raise TypeError('must be str, not ' + type(s).__name__)
+ return self.shell.write(s, self.tags)
def writelines(self, lines):
for line in lines:
@@ -1351,7 +1330,7 @@ idle -est "Baz" foo.py
Run $IDLESTARTUP or $PYTHONSTARTUP, edit foo.py, and open a shell
window with the title "Baz".
-idle -c "import sys; print sys.argv" "foo"
+idle -c "import sys; print(sys.argv)" "foo"
Open a shell window and run the command, passing "-c" in sys.argv[0]
and "foo" in sys.argv[1].
@@ -1360,7 +1339,7 @@ idle -d -s -r foo.py "Hello World"
run foo.py, passing "foo.py" in sys.argv[0] and "Hello World" in
sys.argv[1].
-echo "import sys; print sys.argv" | idle - "foobar"
+echo "import sys; print(sys.argv)" | idle - "foobar"
Open a shell window, run the script piped in, passing '' in sys.argv[0]
and "foobar" in sys.argv[1].
"""
@@ -1377,7 +1356,7 @@ def main():
startup = False
try:
opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:")
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stderr.write("Error: %s\n" % str(msg))
sys.stderr.write(usage_msg)
sys.exit(2)
@@ -1403,7 +1382,7 @@ def main():
if os.path.isfile(script):
pass
else:
- print "No script file: ", script
+ print("No script file: ", script)
sys.exit()
enable_shell = True
if o == '-s':
@@ -1431,11 +1410,11 @@ def main():
pathx.append(os.path.dirname(filename))
for dir in pathx:
dir = os.path.abspath(dir)
- if dir not in sys.path:
+ if not dir in sys.path:
sys.path.insert(0, dir)
else:
dir = os.getcwd()
- if not dir in sys.path:
+ if dir not in sys.path:
sys.path.insert(0, dir)
# check the IDLE settings configuration (but command line overrides)
edit_start = idleConf.GetOption('main', 'General',
diff --git a/Lib/idlelib/README.txt b/Lib/idlelib/README.txt
index 101f7eba167..b2bb73b0651 100644
--- a/Lib/idlelib/README.txt
+++ b/Lib/idlelib/README.txt
@@ -45,13 +45,10 @@ and is cross-platform, working on Unix, Mac, and Windows.
IDLE accepts command line arguments. Try idle -h to see the options.
-If you find bugs or have suggestions, let us know about them by using the
-Python Bug Tracker:
+If you find bugs or have suggestions or patches, let us know about
+them by using the Python issue tracker:
-http://sourceforge.net/projects/python
-
-Patches are always appreciated at the Python Patch Tracker, and change
-requests should be posted to the RFE Tracker.
+http://bugs.python.org
For further details and links, read the Help files and check the IDLE home
page at
diff --git a/Lib/idlelib/RemoteDebugger.py b/Lib/idlelib/RemoteDebugger.py
index 647285fe4e5..d8662bbd96e 100644
--- a/Lib/idlelib/RemoteDebugger.py
+++ b/Lib/idlelib/RemoteDebugger.py
@@ -93,16 +93,13 @@ class IdbAdapter:
self.idb.set_return(frame)
def get_stack(self, fid, tbid):
- ##print >>sys.__stderr__, "get_stack(%r, %r)" % (fid, tbid)
frame = frametable[fid]
if tbid is None:
tb = None
else:
tb = tracebacktable[tbid]
stack, i = self.idb.get_stack(frame, tb)
- ##print >>sys.__stderr__, "get_stack() ->", stack
stack = [(wrap_frame(frame), k) for frame, k in stack]
- ##print >>sys.__stderr__, "get_stack() ->", stack
return stack, i
def run(self, cmd):
@@ -161,13 +158,20 @@ class IdbAdapter:
#----------called by a DictProxy----------
def dict_keys(self, did):
+ raise NotImplemented("dict_keys not public or pickleable")
+## dict = dicttable[did]
+## return dict.keys()
+
+ ### Needed until dict_keys is type is finished and pickealable.
+ ### Will probably need to extend rpc.py:SocketIO._proxify at that time.
+ def dict_keys_list(self, did):
dict = dicttable[did]
- return dict.keys()
+ return list(dict.keys())
def dict_item(self, did, key):
dict = dicttable[did]
value = dict[key]
- value = repr(value)
+ value = repr(value) ### can't pickle module 'builtins'
return value
#----------end class IdbAdapter----------
@@ -205,7 +209,7 @@ class FrameProxy:
def __getattr__(self, name):
if name[:1] == "_":
- raise AttributeError, name
+ raise AttributeError(name)
if name == "f_code":
return self._get_f_code()
if name == "f_globals":
@@ -260,16 +264,21 @@ class DictProxy:
self._oid = oid
self._did = did
+## def keys(self):
+## return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {})
+
+ # 'temporary' until dict_keys is a pickleable built-in type
def keys(self):
- return self._conn.remotecall(self._oid, "dict_keys", (self._did,), {})
+ return self._conn.remotecall(self._oid,
+ "dict_keys_list", (self._did,), {})
def __getitem__(self, key):
return self._conn.remotecall(self._oid, "dict_item",
(self._did, key), {})
def __getattr__(self, name):
- ##print >>sys.__stderr__, "failed DictProxy.__getattr__:", name
- raise AttributeError, name
+ ##print("*** Failed DictProxy.__getattr__:", name)
+ raise AttributeError(name)
class GUIAdapter:
@@ -279,7 +288,7 @@ class GUIAdapter:
self.gui = gui
def interaction(self, message, fid, modified_info):
- ##print "interaction: (%s, %s, %s)" % (message, fid, modified_info)
+ ##print("*** Interaction: (%s, %s, %s)" % (message, fid, modified_info))
frame = FrameProxy(self.conn, fid)
self.gui.interaction(message, frame, modified_info)
@@ -292,9 +301,9 @@ class IdbProxy:
self.shell = shell
def call(self, methodname, *args, **kwargs):
- ##print "**IdbProxy.call %s %s %s" % (methodname, args, kwargs)
+ ##print("*** IdbProxy.call %s %s %s" % (methodname, args, kwargs))
value = self.conn.remotecall(self.oid, methodname, args, kwargs)
- ##print "**IdbProxy.call %s returns %r" % (methodname, value)
+ ##print("*** IdbProxy.call %s returns %r" % (methodname, value))
return value
def run(self, cmd, locals):
diff --git a/Lib/idlelib/RemoteObjectBrowser.py b/Lib/idlelib/RemoteObjectBrowser.py
index 43e2c68f30c..8031aaeaf1f 100644
--- a/Lib/idlelib/RemoteObjectBrowser.py
+++ b/Lib/idlelib/RemoteObjectBrowser.py
@@ -17,8 +17,8 @@ class WrappedObjectTreeItem:
return value
def _GetSubList(self):
- list = self.__item._GetSubList()
- return map(remote_object_tree_item, list)
+ sub_list = self.__item._GetSubList()
+ return list(map(remote_object_tree_item, sub_list))
class StubObjectTreeItem:
# Lives in IDLE process
@@ -32,5 +32,5 @@ class StubObjectTreeItem:
return value
def _GetSubList(self):
- list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
- return [StubObjectTreeItem(self.sockio, oid) for oid in list]
+ sub_list = self.sockio.remotecall(self.oid, "_GetSubList", (), {})
+ return [StubObjectTreeItem(self.sockio, oid) for oid in sub_list]
diff --git a/Lib/idlelib/ReplaceDialog.py b/Lib/idlelib/ReplaceDialog.py
index ae440353f7b..e5a13713882 100644
--- a/Lib/idlelib/ReplaceDialog.py
+++ b/Lib/idlelib/ReplaceDialog.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
@@ -73,6 +73,7 @@ class ReplaceDialog(SearchDialogBase):
new = None
else:
new = repl
+
return new
def replace_all(self, event=None):
diff --git a/Lib/idlelib/ScriptBinding.py b/Lib/idlelib/ScriptBinding.py
index 01ac4746589..18ce9650aed 100644
--- a/Lib/idlelib/ScriptBinding.py
+++ b/Lib/idlelib/ScriptBinding.py
@@ -22,14 +22,13 @@ import re
import string
import tabnanny
import tokenize
-import tkMessageBox
-from idlelib import PyShell
+import tkinter.messagebox as tkMessageBox
+from idlelib.EditorWindow import EditorWindow
+from idlelib import PyShell, IOBinding
from idlelib.configHandler import idleConf
from idlelib import macosxSupport
-IDENTCHARS = string.ascii_letters + string.digits + "_"
-
indent_message = """Error: Inconsistent indentation detected!
1) Your indentation is outright incorrect (easy to fix), OR
@@ -67,77 +66,76 @@ class ScriptBinding:
return 'break'
def tabnanny(self, filename):
- f = open(filename, 'r')
- try:
- tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
- except tokenize.TokenError, msg:
- msgtxt, (lineno, start) = msg
- self.editwin.gotoline(lineno)
- self.errorbox("Tabnanny Tokenizing Error",
- "Token Error: %s" % msgtxt)
- return False
- except tabnanny.NannyNag, nag:
- # The error messages from tabnanny are too confusing...
- self.editwin.gotoline(nag.get_lineno())
- self.errorbox("Tab/space error", indent_message)
- return False
+ # XXX: tabnanny should work on binary files as well
+ with tokenize.open(filename) as f:
+ try:
+ tabnanny.process_tokens(tokenize.generate_tokens(f.readline))
+ except tokenize.TokenError as msg:
+ msgtxt, (lineno, start) = msg
+ self.editwin.gotoline(lineno)
+ self.errorbox("Tabnanny Tokenizing Error",
+ "Token Error: %s" % msgtxt)
+ return False
+ except tabnanny.NannyNag as nag:
+ # The error messages from tabnanny are too confusing...
+ self.editwin.gotoline(nag.get_lineno())
+ self.errorbox("Tab/space error", indent_message)
+ return False
return True
def checksyntax(self, filename):
self.shell = shell = self.flist.open_shell()
saved_stream = shell.get_warning_stream()
shell.set_warning_stream(shell.stderr)
- f = open(filename, 'r')
+ f = open(filename, 'rb')
source = f.read()
f.close()
- if '\r' in source:
- source = re.sub(r"\r\n", "\n", source)
- source = re.sub(r"\r", "\n", source)
- if source and source[-1] != '\n':
- source = source + '\n'
- text = self.editwin.text
+ if b'\r' in source:
+ source = source.replace(b'\r\n', b'\n')
+ source = source.replace(b'\r', b'\n')
+ if source and source[-1] != ord(b'\n'):
+ source = source + b'\n'
+ editwin = self.editwin
+ text = editwin.text
text.tag_remove("ERROR", "1.0", "end")
try:
- try:
- # If successful, return the compiled code
- return compile(source, filename, "exec")
- except (SyntaxError, OverflowError, ValueError), err:
- try:
- msg, (errorfilename, lineno, offset, line) = err
- if not errorfilename:
- err.args = msg, (filename, lineno, offset, line)
- err.filename = filename
- self.colorize_syntax_error(msg, lineno, offset)
- except:
- msg = "*** " + str(err)
- self.errorbox("Syntax error",
- "There's an error in your program:\n" + msg)
- return False
+ # If successful, return the compiled code
+ return compile(source, filename, "exec")
+ except (SyntaxError, OverflowError, ValueError) as value:
+ msg = getattr(value, 'msg', '') or value or "<no detail available>"
+ lineno = getattr(value, 'lineno', '') or 1
+ offset = getattr(value, 'offset', '') or 0
+ if offset == 0:
+ lineno += 1 #mark end of offending line
+ pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)
+ editwin.colorize_syntax_error(text, pos)
+ self.errorbox("SyntaxError", "%-20s" % msg)
+ return False
finally:
shell.set_warning_stream(saved_stream)
- def colorize_syntax_error(self, msg, lineno, offset):
- text = self.editwin.text
- pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)
- text.tag_add("ERROR", pos)
- char = text.get(pos)
- if char and char in IDENTCHARS:
- text.tag_add("ERROR", pos + " wordstart", pos)
- if '\n' == text.get(pos): # error at line end
- text.mark_set("insert", pos)
+ def run_module_event(self, event):
+ if macosxSupport.runningAsOSXApp():
+ # Tk-Cocoa in MacOSX is broken until at least
+ # Tk 8.5.9, and without this rather
+ # crude workaround IDLE would hang when a user
+ # tries to run a module using the keyboard shortcut
+ # (the menu item works fine).
+ self.editwin.text_frame.after(200,
+ lambda: self.editwin.text_frame.event_generate('<<run-module-event-2>>'))
+ return 'break'
else:
- text.mark_set("insert", pos + "+1c")
- text.see(pos)
+ return self._run_module_event(event)
- def run_module_event(self, event):
+ def _run_module_event(self, event):
"""Run the module after setting up the environment.
First check the syntax. If OK, make sure the shell is active and
then transfer the arguments, set the run environment's working
directory to the directory of the module being executed and also
add that directory to its sys.path if not already included.
-
"""
+
filename = self.getfilename()
if not filename:
return 'break'
@@ -169,19 +167,6 @@ class ScriptBinding:
interp.runcode(code)
return 'break'
- if macosxSupport.runningAsOSXApp():
- # Tk-Cocoa in MacOSX is broken until at least
- # Tk 8.5.9, and without this rather
- # crude workaround IDLE would hang when a user
- # tries to run a module using the keyboard shortcut
- # (the menu item works fine).
- _run_module_event = run_module_event
-
- def run_module_event(self, event):
- self.editwin.text_frame.after(200,
- lambda: self.editwin.text_frame.event_generate('<<run-module-event-2>>'))
- return 'break'
-
def getfilename(self):
"""Get source filename. If not saved, offer to save (or create) file
diff --git a/Lib/idlelib/ScrolledList.py b/Lib/idlelib/ScrolledList.py
index 92119365770..0255a0a23f9 100644
--- a/Lib/idlelib/ScrolledList.py
+++ b/Lib/idlelib/ScrolledList.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
class ScrolledList:
@@ -124,8 +124,8 @@ def test():
root.protocol("WM_DELETE_WINDOW", root.destroy)
class MyScrolledList(ScrolledList):
def fill_menu(self): self.menu.add_command(label="pass")
- def on_select(self, index): print "select", self.get(index)
- def on_double(self, index): print "double", self.get(index)
+ def on_select(self, index): print("select", self.get(index))
+ def on_double(self, index): print("double", self.get(index))
s = MyScrolledList(root)
for i in range(30):
s.append("item %02d" % i)
diff --git a/Lib/idlelib/SearchDialog.py b/Lib/idlelib/SearchDialog.py
index 7c70b84ee46..76c444c6c14 100644
--- a/Lib/idlelib/SearchDialog.py
+++ b/Lib/idlelib/SearchDialog.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
from idlelib import SearchEngine
from idlelib.SearchDialogBase import SearchDialogBase
diff --git a/Lib/idlelib/SearchDialogBase.py b/Lib/idlelib/SearchDialogBase.py
index f63e7ae37c7..65914ac24ec 100644
--- a/Lib/idlelib/SearchDialogBase.py
+++ b/Lib/idlelib/SearchDialogBase.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
class SearchDialogBase:
diff --git a/Lib/idlelib/SearchEngine.py b/Lib/idlelib/SearchEngine.py
index cc40a00c50f..13a6a6b287d 100644
--- a/Lib/idlelib/SearchEngine.py
+++ b/Lib/idlelib/SearchEngine.py
@@ -1,6 +1,6 @@
import re
-from Tkinter import *
-import tkMessageBox
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
def get(root):
if not hasattr(root, "_searchengine"):
@@ -66,7 +66,7 @@ class SearchEngine:
flags = flags | re.IGNORECASE
try:
prog = re.compile(pat, flags)
- except re.error, what:
+ except re.error as what:
try:
msg, col = what
except:
diff --git a/Lib/idlelib/StackViewer.py b/Lib/idlelib/StackViewer.py
index 732773f3332..4ef2d31699e 100644
--- a/Lib/idlelib/StackViewer.py
+++ b/Lib/idlelib/StackViewer.py
@@ -7,7 +7,7 @@ from idlelib.ObjectBrowser import ObjectTreeItem, make_objecttreeitem
def StackBrowser(root, flist=None, tb=None, top=None):
if top is None:
- from Tkinter import Toplevel
+ from tkinter import Toplevel
top = Toplevel(root)
sc = ScrolledCanvas(top, bg="white", highlightthickness=0)
sc.frame.pack(expand=1, fill="both")
@@ -106,7 +106,7 @@ class VariablesTreeItem(ObjectTreeItem):
return len(self.object) > 0
def keys(self):
- return self.object.keys()
+ return list(self.object.keys())
def GetSubList(self):
sublist = []
@@ -120,18 +120,3 @@ class VariablesTreeItem(ObjectTreeItem):
item = make_objecttreeitem(key + " =", value, setfunction)
sublist.append(item)
return sublist
-
-
-def _test():
- try:
- import testcode
- reload(testcode)
- except:
- sys.last_type, sys.last_value, sys.last_traceback = sys.exc_info()
- from Tkinter import Tk
- root = Tk()
- StackBrowser(None, top=root)
- root.mainloop()
-
-if __name__ == "__main__":
- _test()
diff --git a/Lib/idlelib/ToolTip.py b/Lib/idlelib/ToolTip.py
index ce7a3d3ee52..b178803b02f 100644
--- a/Lib/idlelib/ToolTip.py
+++ b/Lib/idlelib/ToolTip.py
@@ -3,7 +3,7 @@
# may be useful for some purposes in (or almost in ;) the current project scope
# Ideas gleaned from PySol
-from Tkinter import *
+from tkinter import *
class ToolTipBase:
diff --git a/Lib/idlelib/TreeWidget.py b/Lib/idlelib/TreeWidget.py
index 0feca0196d7..d4e524bb65f 100644
--- a/Lib/idlelib/TreeWidget.py
+++ b/Lib/idlelib/TreeWidget.py
@@ -15,7 +15,7 @@
# - optimize tree redraw after expand of subnode
import os
-from Tkinter import *
+from tkinter import *
import imp
from idlelib import ZoomHeight
@@ -31,7 +31,7 @@ except NameError:
if os.path.isdir(_icondir):
ICONDIR = _icondir
elif not os.path.isdir(ICONDIR):
- raise RuntimeError, "can't find icon directory (%r)" % (ICONDIR,)
+ raise RuntimeError("can't find icon directory (%r)" % (ICONDIR,))
def listicons(icondir=ICONDIR):
"""Utility to display the available icons."""
diff --git a/Lib/idlelib/UndoDelegator.py b/Lib/idlelib/UndoDelegator.py
index 16d3ae198f8..d2ef638ad24 100644
--- a/Lib/idlelib/UndoDelegator.py
+++ b/Lib/idlelib/UndoDelegator.py
@@ -1,5 +1,5 @@
import string
-from Tkinter import *
+from tkinter import *
from idlelib.Delegator import Delegator
@@ -38,10 +38,10 @@ class UndoDelegator(Delegator):
def dump_event(self, event):
from pprint import pprint
pprint(self.undolist[:self.pointer])
- print "pointer:", self.pointer,
- print "saved:", self.saved,
- print "can_merge:", self.can_merge,
- print "get_saved():", self.get_saved()
+ print("pointer:", self.pointer, end=' ')
+ print("saved:", self.saved, end=' ')
+ print("can_merge:", self.can_merge, end=' ')
+ print("get_saved():", self.get_saved())
pprint(self.undolist[self.pointer:])
return "break"
diff --git a/Lib/idlelib/WidgetRedirector.py b/Lib/idlelib/WidgetRedirector.py
index 7c341f2f1e4..ba5251ff71f 100644
--- a/Lib/idlelib/WidgetRedirector.py
+++ b/Lib/idlelib/WidgetRedirector.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
class WidgetRedirector:
@@ -113,7 +113,7 @@ def main():
redir = WidgetRedirector(text)
global previous_tcl_fcn
def my_insert(*args):
- print "insert", args
+ print("insert", args)
previous_tcl_fcn(*args)
previous_tcl_fcn = redir.register("insert", my_insert)
root.mainloop()
diff --git a/Lib/idlelib/WindowList.py b/Lib/idlelib/WindowList.py
index 658502b20b0..bc74348f569 100644
--- a/Lib/idlelib/WindowList.py
+++ b/Lib/idlelib/WindowList.py
@@ -1,4 +1,4 @@
-from Tkinter import *
+from tkinter import *
class WindowList:
@@ -20,15 +20,15 @@ class WindowList:
def add_windows_to_menu(self, menu):
list = []
- for key in self.dict.keys():
+ for key in self.dict:
window = self.dict[key]
try:
title = window.get_title()
except TclError:
continue
- list.append((title, window))
+ list.append((title, key, window))
list.sort()
- for title, window in list:
+ for title, key, window in list:
menu.add_command(label=title, command=window.wakeup)
def register_callback(self, callback):
@@ -45,8 +45,8 @@ class WindowList:
try:
callback()
except:
- print "warning: callback failed in WindowList", \
- sys.exc_type, ":", sys.exc_value
+ t, v, tb = sys.exc_info()
+ print("warning: callback failed in WindowList", t, ":", v)
registry = WindowList()
diff --git a/Lib/idlelib/aboutDialog.py b/Lib/idlelib/aboutDialog.py
index 43a13135aee..cfccc0ffd76 100644
--- a/Lib/idlelib/aboutDialog.py
+++ b/Lib/idlelib/aboutDialog.py
@@ -2,7 +2,7 @@
"""
-from Tkinter import *
+from tkinter import *
import os
from idlelib import textView
diff --git a/Lib/idlelib/config-main.def b/Lib/idlelib/config-main.def
index 5ddd098de1e..9546e2bf128 100644
--- a/Lib/idlelib/config-main.def
+++ b/Lib/idlelib/config-main.def
@@ -46,8 +46,8 @@
[General]
editor-on-startup= 0
autosave= 0
-print-command-posix=lpr %s
-print-command-win=start /min notepad /p %s
+print-command-posix=lpr %%s
+print-command-win=start /min notepad /p %%s
delete-exitfunc= 1
[EditorWindow]
diff --git a/Lib/idlelib/configDialog.py b/Lib/idlelib/configDialog.py
index b707fc3ddb4..1f4a3a57689 100644
--- a/Lib/idlelib/configDialog.py
+++ b/Lib/idlelib/configDialog.py
@@ -9,9 +9,11 @@ Note that tab width in IDLE is currently fixed at eight due to Tk issues.
Refer to comments in EditorWindow autoindent code for details.
"""
-from Tkinter import *
-import tkMessageBox, tkColorChooser, tkFont
-import string
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
+import tkinter.colorchooser as tkColorChooser
+import tkinter.font as tkFont
+import copy
from idlelib.configHandler import idleConf
from idlelib.dynOptionMenuWidget import DynOptionMenu
@@ -71,25 +73,27 @@ class ConfigDialog(Toplevel):
page_names=['Fonts/Tabs','Highlighting','Keys','General'])
frameActionButtons = Frame(self,pady=2)
#action buttons
+
if macosxSupport.runningAsOSXApp():
- # Changing the default padding on OSX results in unreadable
- # text in the buttons
- paddingArgs={}
+ # Surpress the padx and pady arguments when
+ # running as IDLE.app, otherwise the text
+ # on these buttons will not be readable.
+ extraKwds={}
else:
- paddingArgs={'padx':6, 'pady':3}
+ extraKwds=dict(padx=6, pady=3)
self.buttonHelp = Button(frameActionButtons,text='Help',
command=self.Help,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonOk = Button(frameActionButtons,text='Ok',
command=self.Ok,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonApply = Button(frameActionButtons,text='Apply',
command=self.Apply,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.buttonCancel = Button(frameActionButtons,text='Cancel',
command=self.Cancel,takefocus=FALSE,
- **paddingArgs)
+ **extraKwds)
self.CreatePageFontTab()
self.CreatePageHighlight()
self.CreatePageKeys()
@@ -195,13 +199,13 @@ class ConfigDialog(Toplevel):
("'string'",'string'),('\n var1 = ','normal'),("'selected'",'hilite'),
('\n var2 = ','normal'),("'found'",'hit'),
('\n var3 = ','normal'),('list', 'builtin'), ('(','normal'),
- ('None', 'builtin'),(')\n\n','normal'),
+ ('None', 'keyword'),(')\n\n','normal'),
(' error ','error'),(' ','normal'),('cursor |','cursor'),
('\n ','normal'),('shell','console'),(' ','normal'),('stdout','stdout'),
(' ','normal'),('stderr','stderr'),('\n','normal'))
for txTa in textAndTags:
text.insert(END,txTa[0],txTa[1])
- for element in self.themeElements.keys():
+ for element in self.themeElements:
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
lambda event,elem=element: event.widget.winfo_toplevel()
.highlightTarget.set(elem))
@@ -343,7 +347,6 @@ class ConfigDialog(Toplevel):
text=' Autosave Preferences ')
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
- frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Additional Help Sources ')
#frameRun
@@ -372,14 +375,6 @@ class ConfigDialog(Toplevel):
' width (in characters)')
entryParaWidth=Entry(frameParaSize,textvariable=self.paraWidth,
width=3)
- #frameEncoding
- labelEncodingTitle=Label(frameEncoding,text="Default Source Encoding")
- radioEncLocale=Radiobutton(frameEncoding,variable=self.encoding,
- value="locale",text="Locale-defined")
- radioEncUTF8=Radiobutton(frameEncoding,variable=self.encoding,
- value="utf-8",text="UTF-8")
- radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
- value="none",text="None")
#frameHelp
frameHelpList=Frame(frameHelp)
frameHelpListButtons=Frame(frameHelpList)
@@ -401,7 +396,6 @@ class ConfigDialog(Toplevel):
frameSave.pack(side=TOP,padx=5,pady=5,fill=X)
frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X)
frameParaSize.pack(side=TOP,padx=5,pady=5,fill=X)
- frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frameRun
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
@@ -420,11 +414,6 @@ class ConfigDialog(Toplevel):
#paragraphFormatWidth
labelParaWidthTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
entryParaWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5)
- #frameEncoding
- labelEncodingTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
- radioEncNone.pack(side=RIGHT,anchor=E,pady=5)
- radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
- radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
#frameHelp
frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
@@ -568,7 +557,7 @@ class ConfigDialog(Toplevel):
def GetDefaultItems(self):
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
- for configType in dItems.keys():
+ for configType in dItems:
sections=idleConf.GetSectionList('default',configType)
for section in sections:
dItems[configType][section]={}
@@ -609,11 +598,11 @@ class ConfigDialog(Toplevel):
else:
currentKeySetName=self.customKeys.get()
currentBindings=idleConf.GetCurrentKeySet()
- if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
+ if currentKeySetName in self.changedItems['keys']: #unsaved changes
keySetChanges=self.changedItems['keys'][currentKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
currentBindings[event]=keySetChanges[event].split()
- currentKeySequences=currentBindings.values()
+ currentKeySequences = list(currentBindings.values())
newKeys=GetKeysDialog(self,'Get New Keys',bindName,
currentKeySequences).result
if newKeys: #new keys were specified
@@ -660,14 +649,14 @@ class ConfigDialog(Toplevel):
prevKeySetName=self.customKeys.get()
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
newKeys={}
- for event in prevKeys.keys(): #add key set to changed items
+ for event in prevKeys: #add key set to changed items
eventName=event[2:-2] #trim off the angle brackets
- binding=string.join(prevKeys[event])
+ binding=' '.join(prevKeys[event])
newKeys[eventName]=binding
#handle any unsaved changes to prev key set
- if prevKeySetName in self.changedItems['keys'].keys():
+ if prevKeySetName in self.changedItems['keys']:
keySetChanges=self.changedItems['keys'][prevKeySetName]
- for event in keySetChanges.keys():
+ for event in keySetChanges:
newKeys[event]=keySetChanges[event]
#save the new theme
self.SaveNewKeySet(newKeySetName,newKeys)
@@ -685,15 +674,15 @@ class ConfigDialog(Toplevel):
reselect=1
listIndex=self.listBindings.index(ANCHOR)
keySet=idleConf.GetKeySet(keySetName)
- bindNames=keySet.keys()
+ bindNames = list(keySet.keys())
bindNames.sort()
self.listBindings.delete(0,END)
for bindName in bindNames:
- key=string.join(keySet[bindName]) #make key(s) into a string
+ key=' '.join(keySet[bindName]) #make key(s) into a string
bindName=bindName[2:-2] #trim off the angle brackets
- if keySetName in self.changedItems['keys'].keys():
+ if keySetName in self.changedItems['keys']:
#handle any unsaved changes to this key set
- if bindName in self.changedItems['keys'][keySetName].keys():
+ if bindName in self.changedItems['keys'][keySetName]:
key=self.changedItems['keys'][keySetName][bindName]
self.listBindings.insert(END, bindName+' - '+key)
if reselect:
@@ -808,9 +797,9 @@ class ConfigDialog(Toplevel):
themeName=self.customTheme.get()
newTheme=idleConf.GetThemeDict(themeType,themeName)
#apply any of the old theme's unsaved changes to the new theme
- if themeName in self.changedItems['highlight'].keys():
+ if themeName in self.changedItems['highlight']:
themeChanges=self.changedItems['highlight'][themeName]
- for element in themeChanges.keys():
+ for element in themeChanges:
newTheme[element]=themeChanges[element]
#save the new theme
self.SaveNewTheme(newThemeName,newTheme)
@@ -863,14 +852,14 @@ class ConfigDialog(Toplevel):
theme=self.builtinTheme.get()
else: #a user theme
theme=self.customTheme.get()
- for elementTitle in self.themeElements.keys():
+ for elementTitle in self.themeElements:
element=self.themeElements[elementTitle][0]
colours=idleConf.GetHighlight(theme,element)
if element=='cursor': #cursor sample needs special painting
colours['background']=idleConf.GetHighlight(theme,
'normal', fgBg='bg')
#handle any unsaved changes to this theme
- if theme in self.changedItems['highlight'].keys():
+ if theme in self.changedItems['highlight']:
themeDict=self.changedItems['highlight'][theme]
if element+'-foreground' in themeDict:
colours['foreground']=themeDict[element+'-foreground']
@@ -927,7 +916,7 @@ class ConfigDialog(Toplevel):
self.changedItems['main']['HelpFiles'] = {}
for num in range(1,len(self.userHelpList)+1):
self.AddChangedItem('main','HelpFiles',str(num),
- string.join(self.userHelpList[num-1][:2],';'))
+ ';'.join(self.userHelpList[num-1][:2]))
def LoadFontCfg(self):
##base editor font selection list
@@ -936,7 +925,7 @@ class ConfigDialog(Toplevel):
for font in fonts:
self.listFontName.insert(END,font)
configuredFont=idleConf.GetOption('main','EditorWindow','font',
- default='courier')
+ default='courier')
lc_configuredFont = configuredFont.lower()
self.fontName.set(lc_configuredFont)
lc_fonts = [s.lower() for s in fonts]
@@ -946,13 +935,13 @@ class ConfigDialog(Toplevel):
self.listFontName.select_set(currentFontIndex)
self.listFontName.select_anchor(currentFontIndex)
##font size dropdown
- fontSize=idleConf.GetOption('main','EditorWindow','font-size',
- type='int', default='10')
+ fontSize=idleConf.GetOption('main', 'EditorWindow', 'font-size',
+ type='int', default='10')
self.optMenuFontSize.SetMenu(('7','8','9','10','11','12','13','14',
- '16','18','20','22'),fontSize )
+ '16','18','20','22'), fontSize )
##fontWeight
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
- 'font-bold',default=0,type='bool'))
+ 'font-bold',default=0,type='bool'))
##font sample
self.SetFontSample()
@@ -989,7 +978,7 @@ class ConfigDialog(Toplevel):
self.optMenuThemeBuiltin.SetMenu(itemList,itemList[0])
self.SetThemeType()
##load theme element option menu
- themeNames=self.themeElements.keys()
+ themeNames = list(self.themeElements.keys())
themeNames.sort(key=lambda x: self.themeElements[x][1])
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
self.PaintThemeSample()
@@ -1072,7 +1061,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['keys'].has_section(keySetName):
idleConf.userCfg['keys'].add_section(keySetName)
- for event in keySet.keys():
+ for event in keySet:
value=keySet[event]
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
@@ -1084,7 +1073,7 @@ class ConfigDialog(Toplevel):
"""
if not idleConf.userCfg['highlight'].has_section(themeName):
idleConf.userCfg['highlight'].add_section(themeName)
- for element in theme.keys():
+ for element in theme:
value=theme[element]
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
@@ -1099,14 +1088,14 @@ class ConfigDialog(Toplevel):
def SaveAllChangedConfigs(self):
"Save configuration changes to the user config file."
idleConf.userCfg['main'].Save()
- for configType in self.changedItems.keys():
+ for configType in self.changedItems:
cfgTypeHasChanges = False
- for section in self.changedItems[configType].keys():
+ for section in self.changedItems[configType]:
if section == 'HelpFiles':
#this section gets completely replaced
idleConf.userCfg['main'].remove_section('HelpFiles')
cfgTypeHasChanges = True
- for item in self.changedItems[configType][section].keys():
+ for item in self.changedItems[configType][section]:
value = self.changedItems[configType][section][item]
if self.SetUserValue(configType,section,item,value):
cfgTypeHasChanges = True
@@ -1120,13 +1109,13 @@ class ConfigDialog(Toplevel):
def DeactivateCurrentConfig(self):
#Before a config is saved, some cleanup of current
#config must be done - remove the previous keybindings
- winInstances=self.parent.instance_dict.keys()
+ winInstances = self.parent.instance_dict.keys()
for instance in winInstances:
instance.RemoveKeybindings()
def ActivateConfigChanges(self):
"Dynamically apply configuration changes"
- winInstances=self.parent.instance_dict.keys()
+ winInstances = self.parent.instance_dict.keys()
for instance in winInstances:
instance.ResetColorizer()
instance.ResetFont()
diff --git a/Lib/idlelib/configHandler.py b/Lib/idlelib/configHandler.py
index ce28d0836d6..e22ceb00cb7 100644
--- a/Lib/idlelib/configHandler.py
+++ b/Lib/idlelib/configHandler.py
@@ -19,9 +19,9 @@ configuration problem notification and resolution.
"""
import os
import sys
-import string
+
from idlelib import macosxSupport
-from ConfigParser import ConfigParser, NoOptionError, NoSectionError
+from configparser import ConfigParser, NoOptionError, NoSectionError
class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
@@ -285,13 +285,13 @@ class IdleConf:
configType must be one of ('main','extensions','highlight','keys')
"""
if not (configType in ('main','extensions','highlight','keys')):
- raise InvalidConfigType, 'Invalid configType specified'
+ raise InvalidConfigType('Invalid configType specified')
if configSet == 'user':
cfgParser=self.userCfg[configType]
elif configSet == 'default':
cfgParser=self.defaultCfg[configType]
else:
- raise InvalidConfigSet, 'Invalid configSet specified'
+ raise InvalidConfigSet('Invalid configSet specified')
return cfgParser.sections()
def GetHighlight(self, theme, element, fgBg=None):
@@ -319,7 +319,7 @@ class IdleConf:
if fgBg == 'bg':
return highlight["background"]
else:
- raise InvalidFgBg, 'Invalid fgBg specified'
+ raise InvalidFgBg('Invalid fgBg specified')
def GetThemeDict(self,type,themeName):
"""
@@ -335,7 +335,7 @@ class IdleConf:
elif type == 'default':
cfgParser=self.defaultCfg['highlight']
else:
- raise InvalidTheme, 'Invalid theme type specified'
+ raise InvalidTheme('Invalid theme type specified')
#foreground and background values are provded for each theme element
#(apart from cursor) even though all these values are not yet used
#by idle, to allow for their use in the future. Default values are
@@ -369,7 +369,7 @@ class IdleConf:
'stderr-background':'#ffffff',
'console-foreground':'#000000',
'console-background':'#ffffff' }
- for element in theme.keys():
+ for element in theme:
if not cfgParser.has_option(themeName,element):
#we are going to return a default, print warning
warning=('\n Warning: configHandler.py - IdleConf.GetThemeDict'
@@ -453,7 +453,7 @@ class IdleConf:
extName=None
vEvent='<<'+virtualEvent+'>>'
for extn in self.GetExtensions(active_only=0):
- for event in self.GetExtensionKeys(extn).keys():
+ for event in self.GetExtensionKeys(extn):
if event == vEvent:
extName=extn
return extName
@@ -548,7 +548,7 @@ class IdleConf:
for extn in activeExtns:
extKeys=self.__GetRawExtensionKeys(extn)
if extKeys: #the extension defines keybindings
- for event in extKeys.keys():
+ for event in extKeys:
if extKeys[event] in keySet.values():
#the binding is already in use
extKeys[event]='' #disable this binding
@@ -561,7 +561,7 @@ class IdleConf:
virtualEvent - string, name of the virtual event to test for, without
the enclosing '<< >>'
"""
- return ('<<'+virtualEvent+'>>') in self.GetCoreKeys().keys()
+ return ('<<'+virtualEvent+'>>') in self.GetCoreKeys()
def GetCoreKeys(self, keySetName=None):
"""
@@ -624,7 +624,7 @@ class IdleConf:
'<<del-word-right>>': ['<Control-Key-Delete>']
}
if keySetName:
- for event in keyBindings.keys():
+ for event in keyBindings:
binding=self.GetKeyBinding(keySetName,event)
if binding:
keyBindings[event]=binding
@@ -656,7 +656,7 @@ class IdleConf:
elif configSet=='default':
cfgParser=self.defaultCfg['main']
else:
- raise InvalidConfigSet, 'Invalid configSet specified'
+ raise InvalidConfigSet('Invalid configSet specified')
options=cfgParser.GetOptionList('HelpFiles')
for option in options:
value=cfgParser.Get('HelpFiles',option,default=';')
@@ -664,12 +664,12 @@ class IdleConf:
menuItem='' #make these empty
helpPath='' #so value won't be added to list
else: #config entry contains ';' as expected
- value=string.split(value,';')
+ value=value.split(';')
menuItem=value[0].strip()
helpPath=value[1].strip()
if menuItem and helpPath: #neither are empty strings
helpSources.append( (menuItem,helpPath,option) )
- helpSources.sort(key=lambda x: int(x[2]))
+ helpSources.sort(key=lambda x: x[2])
return helpSources
def GetAllExtraHelpSourcesList(self):
@@ -686,7 +686,7 @@ class IdleConf:
"""
load all configuration files.
"""
- for key in self.defaultCfg.keys():
+ for key in self.defaultCfg:
self.defaultCfg[key].Load()
self.userCfg[key].Load() #same keys
@@ -694,7 +694,7 @@ class IdleConf:
"""
write all loaded user configuration files back to disk
"""
- for key in self.userCfg.keys():
+ for key in self.userCfg:
self.userCfg[key].Save()
idleConf=IdleConf()
@@ -702,18 +702,18 @@ idleConf=IdleConf()
### module test
if __name__ == '__main__':
def dumpCfg(cfg):
- print '\n',cfg,'\n'
- for key in cfg.keys():
+ print('\n',cfg,'\n')
+ for key in cfg:
sections=cfg[key].sections()
- print key
- print sections
+ print(key)
+ print(sections)
for section in sections:
options=cfg[key].options(section)
- print section
- print options
+ print(section)
+ print(options)
for option in options:
- print option, '=', cfg[key].Get(section,option)
+ print(option, '=', cfg[key].Get(section,option))
dumpCfg(idleConf.defaultCfg)
dumpCfg(idleConf.userCfg)
- print idleConf.userCfg['main'].Get('Theme','name')
+ print(idleConf.userCfg['main'].Get('Theme','name'))
#print idleConf.userCfg['highlight'].GetDefHighlight('Foo','normal')
diff --git a/Lib/idlelib/configHelpSourceEdit.py b/Lib/idlelib/configHelpSourceEdit.py
index 661162196c7..2ccb4005750 100644
--- a/Lib/idlelib/configHelpSourceEdit.py
+++ b/Lib/idlelib/configHelpSourceEdit.py
@@ -3,9 +3,9 @@
import os
import sys
-from Tkinter import *
-import tkMessageBox
-import tkFileDialog
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
+import tkinter.filedialog as tkFileDialog
class GetHelpSourceDialog(Toplevel):
def __init__(self, parent, title, menuItem='', filePath=''):
@@ -164,6 +164,6 @@ if __name__ == '__main__':
def run():
keySeq = ''
dlg = GetHelpSourceDialog(root, 'Get Help Source')
- print dlg.result
+ print(dlg.result)
Button(root,text='Dialog', command=run).pack()
root.mainloop()
diff --git a/Lib/idlelib/configSectionNameDialog.py b/Lib/idlelib/configSectionNameDialog.py
index 4f1b002afca..4378d6f6827 100644
--- a/Lib/idlelib/configSectionNameDialog.py
+++ b/Lib/idlelib/configSectionNameDialog.py
@@ -2,8 +2,8 @@
Dialog that allows user to specify a new config file section name.
Used to get new highlight theme and keybinding set names.
"""
-from Tkinter import *
-import tkMessageBox
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
class GetCfgSectionNameDialog(Toplevel):
def __init__(self,parent,title,message,usedNames):
@@ -92,6 +92,6 @@ if __name__ == '__main__':
keySeq=''
dlg=GetCfgSectionNameDialog(root,'Get Name',
'The information here should need to be word wrapped. Test.')
- print dlg.result
+ print(dlg.result)
Button(root,text='Dialog',command=run).pack()
root.mainloop()
diff --git a/Lib/idlelib/dynOptionMenuWidget.py b/Lib/idlelib/dynOptionMenuWidget.py
index e81f7babe05..922de96ceac 100644
--- a/Lib/idlelib/dynOptionMenuWidget.py
+++ b/Lib/idlelib/dynOptionMenuWidget.py
@@ -2,8 +2,8 @@
OptionMenu widget modified to allow dynamic menu reconfiguration
and setting of highlightthickness
"""
-from Tkinter import OptionMenu
-from Tkinter import _setit
+from tkinter import OptionMenu
+from tkinter import _setit
import copy
class DynOptionMenu(OptionMenu):
@@ -13,7 +13,7 @@ class DynOptionMenu(OptionMenu):
def __init__(self, master, variable, value, *values, **kwargs):
#get a copy of kwargs before OptionMenu.__init__ munges them
kwargsCopy=copy.copy(kwargs)
- if 'highlightthickness' in kwargs.keys():
+ if 'highlightthickness' in list(kwargs.keys()):
del(kwargs['highlightthickness'])
OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
diff --git a/Lib/idlelib/help.txt b/Lib/idlelib/help.txt
index 2ebf8bf02a5..815ee403da0 100644
--- a/Lib/idlelib/help.txt
+++ b/Lib/idlelib/help.txt
@@ -122,7 +122,7 @@ Help Menu:
Edit context menu (Right-click / Control-click on OS X in Edit window):
- Cut -- Copy a selection into system-wide clipboard,
+ Cut -- Copy a selection into system-wide clipboard,
then delete the selection
Copy -- Copy selection into system-wide clipboard
Paste -- Insert system-wide clipboard into window
@@ -135,7 +135,7 @@ Shell context menu (Right-click / Control-click on OS X in Shell window):
then delete the selection
Copy -- Copy selection into system-wide clipboard
Paste -- Insert system-wide clipboard into window
- ---
+ ---
Go to file/line -- Same as in Debug menu
diff --git a/Lib/idlelib/idle.pyw b/Lib/idlelib/idle.pyw
index 537dd5a9a75..0db5fd426e7 100644
--- a/Lib/idlelib/idle.pyw
+++ b/Lib/idlelib/idle.pyw
@@ -3,7 +3,7 @@ try:
except ImportError:
# IDLE is not installed, but maybe PyShell is on sys.path:
try:
- import PyShell
+ from . import PyShell
except ImportError:
raise
else:
diff --git a/Lib/idlelib/idlever.py b/Lib/idlelib/idlever.py
index 72666cb7f26..17455dbeee0 100644
--- a/Lib/idlelib/idlever.py
+++ b/Lib/idlelib/idlever.py
@@ -1 +1 @@
-IDLE_VERSION = "2.7.3"
+IDLE_VERSION = "3.2.3"
diff --git a/Lib/idlelib/keybindingDialog.py b/Lib/idlelib/keybindingDialog.py
index 5339f88f61c..0f0da8c7e93 100644
--- a/Lib/idlelib/keybindingDialog.py
+++ b/Lib/idlelib/keybindingDialog.py
@@ -1,9 +1,10 @@
"""
Dialog for building Tkinter accelerator key bindings
"""
-from Tkinter import *
-import tkMessageBox
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
import string
+from idlelib import macosxSupport
class GetKeysDialog(Toplevel):
def __init__(self,parent,title,action,currentKeySequences):
@@ -132,7 +133,7 @@ class GetKeysDialog(Toplevel):
order is also important: key binding equality depends on it, so
config-keys.def must use the same ordering.
"""
- from idlelib import macosxSupport
+ import sys
if macosxSupport.runningAsOSXApp():
self.modifiers = ['Shift', 'Control', 'Option', 'Command']
else:
@@ -163,7 +164,7 @@ class GetKeysDialog(Toplevel):
if finalKey:
finalKey = self.TranslateKey(finalKey, modifiers)
keyList.append(finalKey)
- self.keyString.set('<' + string.join(keyList,'-') + '>')
+ self.keyString.set('<' + '-'.join(keyList) + '>')
def GetModifiers(self):
modList = [variable.get() for variable in self.modifier_vars]
@@ -203,7 +204,7 @@ class GetKeysDialog(Toplevel):
'/':'slash','?':'question','Page Up':'Prior','Page Down':'Next',
'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up',
'Down Arrow': 'Down', 'Tab':'Tab'}
- if key in translateDict.keys():
+ if key in translateDict:
key = translateDict[key]
if 'Shift' in modifiers and key in string.ascii_lowercase:
key = key.upper()
@@ -263,6 +264,6 @@ if __name__ == '__main__':
def run():
keySeq=''
dlg=GetKeysDialog(root,'Get Keys','find-again',[])
- print dlg.result
+ print(dlg.result)
Button(root,text='Dialog',command=run).pack()
root.mainloop()
diff --git a/Lib/idlelib/macosxSupport.py b/Lib/idlelib/macosxSupport.py
index af6652fb6f2..96904429af8 100644
--- a/Lib/idlelib/macosxSupport.py
+++ b/Lib/idlelib/macosxSupport.py
@@ -3,7 +3,7 @@ A number of function that enhance IDLE on MacOSX when it used as a normal
GUI application (as opposed to an X11 application).
"""
import sys
-import Tkinter
+import tkinter
from os import path
@@ -72,7 +72,7 @@ def addOpenEventSupport(root, flist):
def hideTkConsole(root):
try:
root.tk.call('console', 'hide')
- except Tkinter.TclError:
+ except tkinter.TclError:
# Some versions of the Tk framework don't have a console object
pass
@@ -92,7 +92,7 @@ def overrideRootMenu(root, flist):
#
# Due to a (mis-)feature of TkAqua the user will also see an empty Help
# menu.
- from Tkinter import Menu, Text, Text
+ from tkinter import Menu, Text, Text
from idlelib.EditorWindow import prepstr, get_accelerator
from idlelib import Bindings
from idlelib import WindowList
@@ -121,6 +121,12 @@ def overrideRootMenu(root, flist):
def config_dialog(event=None):
from idlelib import configDialog
+
+ # Ensure that the root object has an instance_dict attribute,
+ # mirrors code in EditorWindow (although that sets the attribute
+ # on an EditorWindow instance that is then passed as the first
+ # argument to ConfigDialog)
+ root.instance_dict = flist.inversedict
root.instance_dict = flist.inversedict
configDialog.ConfigDialog(root, 'Settings')
diff --git a/Lib/idlelib/rpc.py b/Lib/idlelib/rpc.py
index 13950589a04..def43945aee 100644
--- a/Lib/idlelib/rpc.py
+++ b/Lib/idlelib/rpc.py
@@ -5,7 +5,7 @@ connect to the Idle process, which listens for the connection. Since Idle has
has only one client per server, this was not a limitation.
+---------------------------------+ +-------------+
- | SocketServer.BaseRequestHandler | | SocketIO |
+ | socketserver.BaseRequestHandler | | SocketIO |
+---------------------------------+ +-------------+
^ | register() |
| | unregister()|
@@ -31,13 +31,13 @@ import sys
import os
import socket
import select
-import SocketServer
+import socketserver
import struct
-import cPickle as pickle
+import pickle
import threading
-import Queue
+import queue
import traceback
-import copy_reg
+import copyreg
import types
import marshal
@@ -60,18 +60,18 @@ def pickle_code(co):
# assert isinstance(fn, type.FunctionType)
# return repr(fn)
-copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
-# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
+copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
+# copyreg.pickle(types.FunctionType, pickle_function, unpickle_function)
BUFSIZE = 8*1024
LOCALHOST = '127.0.0.1'
-class RPCServer(SocketServer.TCPServer):
+class RPCServer(socketserver.TCPServer):
def __init__(self, addr, handlerclass=None):
if handlerclass is None:
handlerclass = RPCHandler
- SocketServer.TCPServer.__init__(self, addr, handlerclass)
+ socketserver.TCPServer.__init__(self, addr, handlerclass)
def server_bind(self):
"Override TCPServer method, no bind() phase for connecting entity"
@@ -104,21 +104,21 @@ class RPCServer(SocketServer.TCPServer):
raise
except:
erf = sys.__stderr__
- print>>erf, '\n' + '-'*40
- print>>erf, 'Unhandled server exception!'
- print>>erf, 'Thread: %s' % threading.currentThread().getName()
- print>>erf, 'Client Address: ', client_address
- print>>erf, 'Request: ', repr(request)
+ print('\n' + '-'*40, file=erf)
+ print('Unhandled server exception!', file=erf)
+ print('Thread: %s' % threading.current_thread().name, file=erf)
+ print('Client Address: ', client_address, file=erf)
+ print('Request: ', repr(request), file=erf)
traceback.print_exc(file=erf)
- print>>erf, '\n*** Unrecoverable, server exiting!'
- print>>erf, '-'*40
+ print('\n*** Unrecoverable, server exiting!', file=erf)
+ print('-'*40, file=erf)
os._exit(0)
#----------------- end class RPCServer --------------------
objecttable = {}
-request_queue = Queue.Queue(0)
-response_queue = Queue.Queue(0)
+request_queue = queue.Queue(0)
+response_queue = queue.Queue(0)
class SocketIO(object):
@@ -126,7 +126,7 @@ class SocketIO(object):
nextseq = 0
def __init__(self, sock, objtable=None, debugging=None):
- self.sockthread = threading.currentThread()
+ self.sockthread = threading.current_thread()
if debugging is not None:
self.debugging = debugging
self.sock = sock
@@ -149,10 +149,10 @@ class SocketIO(object):
def debug(self, *args):
if not self.debugging:
return
- s = self.location + " " + str(threading.currentThread().getName())
+ s = self.location + " " + str(threading.current_thread().name)
for a in args:
s = s + " " + str(a)
- print>>sys.__stderr__, s
+ print(s, file=sys.__stderr__)
def register(self, oid, object):
self.objtable[oid] = object
@@ -201,7 +201,7 @@ class SocketIO(object):
except:
msg = "*** Internal Error: rpc.py:SocketIO.localcall()\n\n"\
" Object: %s \n Method: %s \n Args: %s\n"
- print>>sys.__stderr__, msg % (oid, method, args)
+ print(msg % (oid, method, args), file=sys.__stderr__)
traceback.print_exc(file=sys.__stderr__)
return ("EXCEPTION", None)
@@ -218,7 +218,7 @@ class SocketIO(object):
def asynccall(self, oid, methodname, args, kwargs):
request = ("CALL", (oid, methodname, args, kwargs))
seq = self.newseq()
- if threading.currentThread() != self.sockthread:
+ if threading.current_thread() != self.sockthread:
cvar = threading.Condition()
self.cvars[seq] = cvar
self.debug(("asynccall:%d:" % seq), oid, methodname, args, kwargs)
@@ -228,7 +228,7 @@ class SocketIO(object):
def asyncqueue(self, oid, methodname, args, kwargs):
request = ("QUEUE", (oid, methodname, args, kwargs))
seq = self.newseq()
- if threading.currentThread() != self.sockthread:
+ if threading.current_thread() != self.sockthread:
cvar = threading.Condition()
self.cvars[seq] = cvar
self.debug(("asyncqueue:%d:" % seq), oid, methodname, args, kwargs)
@@ -256,8 +256,8 @@ class SocketIO(object):
return None
if how == "ERROR":
self.debug("decoderesponse: Internal ERROR:", what)
- raise RuntimeError, what
- raise SystemError, (how, what)
+ raise RuntimeError(what)
+ raise SystemError(how, what)
def decode_interrupthook(self):
""
@@ -287,14 +287,14 @@ class SocketIO(object):
def _proxify(self, obj):
if isinstance(obj, RemoteProxy):
return RPCProxy(self, obj.oid)
- if isinstance(obj, types.ListType):
- return map(self._proxify, obj)
+ if isinstance(obj, list):
+ return list(map(self._proxify, obj))
# XXX Check for other types -- not currently needed
return obj
def _getresponse(self, myseq, wait):
self.debug("_getresponse:myseq:", myseq)
- if threading.currentThread() is self.sockthread:
+ if threading.current_thread() is self.sockthread:
# this thread does all reading of requests or responses
while 1:
response = self.pollresponse(myseq, wait)
@@ -323,7 +323,7 @@ class SocketIO(object):
try:
s = pickle.dumps(message)
except pickle.PicklingError:
- print >>sys.__stderr__, "Cannot pickle:", repr(message)
+ print("Cannot pickle:", repr(message), file=sys.__stderr__)
raise
s = struct.pack("<i", len(s)) + s
while len(s) > 0:
@@ -331,19 +331,19 @@ class SocketIO(object):
r, w, x = select.select([], [self.sock], [])
n = self.sock.send(s[:BUFSIZE])
except (AttributeError, TypeError):
- raise IOError, "socket no longer exists"
+ raise IOError("socket no longer exists")
except socket.error:
raise
else:
s = s[n:]
- buffer = ""
+ buff = b''
bufneed = 4
bufstate = 0 # meaning: 0 => reading count; 1 => reading data
def pollpacket(self, wait):
self._stage0()
- if len(self.buffer) < self.bufneed:
+ if len(self.buff) < self.bufneed:
r, w, x = select.select([self.sock.fileno()], [], [], wait)
if len(r) == 0:
return None
@@ -353,21 +353,21 @@ class SocketIO(object):
raise EOFError
if len(s) == 0:
raise EOFError
- self.buffer += s
+ self.buff += s
self._stage0()
return self._stage1()
def _stage0(self):
- if self.bufstate == 0 and len(self.buffer) >= 4:
- s = self.buffer[:4]
- self.buffer = self.buffer[4:]
+ if self.bufstate == 0 and len(self.buff) >= 4:
+ s = self.buff[:4]
+ self.buff = self.buff[4:]
self.bufneed = struct.unpack("<i", s)[0]
self.bufstate = 1
def _stage1(self):
- if self.bufstate == 1 and len(self.buffer) >= self.bufneed:
- packet = self.buffer[:self.bufneed]
- self.buffer = self.buffer[self.bufneed:]
+ if self.bufstate == 1 and len(self.buff) >= self.bufneed:
+ packet = self.buff[:self.bufneed]
+ self.buff = self.buff[self.bufneed:]
self.bufneed = 4
self.bufstate = 0
return packet
@@ -379,10 +379,10 @@ class SocketIO(object):
try:
message = pickle.loads(packet)
except pickle.UnpicklingError:
- print >>sys.__stderr__, "-----------------------"
- print >>sys.__stderr__, "cannot unpickle packet:", repr(packet)
+ print("-----------------------", file=sys.__stderr__)
+ print("cannot unpickle packet:", repr(packet), file=sys.__stderr__)
traceback.print_stack(file=sys.__stderr__)
- print >>sys.__stderr__, "-----------------------"
+ print("-----------------------", file=sys.__stderr__)
raise
return message
@@ -413,7 +413,7 @@ class SocketIO(object):
# send queued response if there is one available
try:
qmsg = response_queue.get(0)
- except Queue.Empty:
+ except queue.Empty:
pass
else:
seq, response = qmsg
@@ -492,7 +492,7 @@ class RemoteProxy(object):
def __init__(self, oid):
self.oid = oid
-class RPCHandler(SocketServer.BaseRequestHandler, SocketIO):
+class RPCHandler(socketserver.BaseRequestHandler, SocketIO):
debugging = False
location = "#S" # Server
@@ -500,10 +500,10 @@ class RPCHandler(SocketServer.BaseRequestHandler, SocketIO):
def __init__(self, sock, addr, svr):
svr.current_handler = self ## cgt xxx
SocketIO.__init__(self, sock)
- SocketServer.BaseRequestHandler.__init__(self, sock, addr, svr)
+ socketserver.BaseRequestHandler.__init__(self, sock, addr, svr)
def handle(self):
- "handle() method required by SocketServer"
+ "handle() method required by socketserver"
self.mainloop()
def get_remote_proxy(self, oid):
@@ -524,11 +524,11 @@ class RPCClient(SocketIO):
def accept(self):
working_sock, address = self.listening_sock.accept()
if self.debugging:
- print>>sys.__stderr__, "****** Connection request from ", address
+ print("****** Connection request from ", address, file=sys.__stderr__)
if address[0] == LOCALHOST:
SocketIO.__init__(self, working_sock)
else:
- print>>sys.__stderr__, "** Invalid host: ", address
+ print("** Invalid host: ", address, file=sys.__stderr__)
raise socket.error
def get_remote_proxy(self, oid):
@@ -555,7 +555,7 @@ class RPCProxy(object):
(name,), {})
return value
else:
- raise AttributeError, name
+ raise AttributeError(name)
def __getattributes(self):
self.__attributes = self.sockio.remotecall(self.oid,
@@ -570,18 +570,16 @@ def _getmethods(obj, methods):
# Adds names to dictionary argument 'methods'
for name in dir(obj):
attr = getattr(obj, name)
- if hasattr(attr, '__call__'):
+ if callable(attr):
methods[name] = 1
- if type(obj) == types.InstanceType:
- _getmethods(obj.__class__, methods)
- if type(obj) == types.ClassType:
+ if isinstance(obj, type):
for super in obj.__bases__:
_getmethods(super, methods)
def _getattributes(obj, attributes):
for name in dir(obj):
attr = getattr(obj, name)
- if not hasattr(attr, '__call__'):
+ if not callable(attr):
attributes[name] = 1
class MethodProxy(object):
diff --git a/Lib/idlelib/run.py b/Lib/idlelib/run.py
index 8e9037044fa..53656806d6d 100644
--- a/Lib/idlelib/run.py
+++ b/Lib/idlelib/run.py
@@ -4,9 +4,9 @@ import linecache
import time
import socket
import traceback
-import thread
+import _thread as thread
import threading
-import Queue
+import queue
from idlelib import CallTips
from idlelib import AutoComplete
@@ -74,13 +74,14 @@ def main(del_exitfunc=False):
assert(len(sys.argv) > 1)
port = int(sys.argv[-1])
except:
- print>>sys.stderr, "IDLE Subprocess: no IP port passed in sys.argv."
+ print("IDLE Subprocess: no IP port passed in sys.argv.",
+ file=sys.__stderr__)
return
sys.argv[:] = [""]
sockthread = threading.Thread(target=manage_socket,
name='SockThread',
args=((LOCALHOST, port),))
- sockthread.setDaemon(True)
+ sockthread.daemon = True
sockthread.start()
while 1:
try:
@@ -92,7 +93,7 @@ def main(del_exitfunc=False):
continue
try:
seq, request = rpc.request_queue.get(block=True, timeout=0.05)
- except Queue.Empty:
+ except queue.Empty:
continue
method, args, kwargs = request
ret = method(*args, **kwargs)
@@ -121,22 +122,23 @@ def manage_socket(address):
try:
server = MyRPCServer(address, MyHandler)
break
- except socket.error, err:
- print>>sys.__stderr__,"IDLE Subprocess: socket error: "\
- + err.args[1] + ", retrying...."
+ except socket.error as err:
+ print("IDLE Subprocess: socket error: " + err.args[1] +
+ ", retrying....", file=sys.__stderr__)
+ socket_error = err
else:
- print>>sys.__stderr__, "IDLE Subprocess: Connection to "\
- "IDLE GUI failed, exiting."
- show_socket_error(err, address)
+ print("IDLE Subprocess: Connection to "
+ "IDLE GUI failed, exiting.", file=sys.__stderr__)
+ show_socket_error(socket_error, address)
global exit_now
exit_now = True
return
server.handle_request() # A single request only
def show_socket_error(err, address):
- import Tkinter
- import tkMessageBox
- root = Tkinter.Tk()
+ import tkinter
+ import tkinter.messagebox as tkMessageBox
+ root = tkinter.Tk()
root.withdraw()
if err.args[0] == 61: # connection refused
msg = "IDLE's subprocess can't connect to %s:%d. This may be due "\
@@ -157,14 +159,14 @@ def print_exception():
typ, val, tb = excinfo = sys.exc_info()
sys.last_type, sys.last_value, sys.last_traceback = excinfo
tbe = traceback.extract_tb(tb)
- print>>efile, '\nTraceback (most recent call last):'
- exclude = ("run.py", "rpc.py", "threading.py", "Queue.py",
+ print('Traceback (most recent call last):', file=efile)
+ exclude = ("run.py", "rpc.py", "threading.py", "queue.py",
"RemoteDebugger.py", "bdb.py")
cleanup_traceback(tbe, exclude)
traceback.print_list(tbe, file=efile)
lines = traceback.format_exception_only(typ, val)
for line in lines:
- print>>efile, line,
+ print(line, end='', file=efile)
def cleanup_traceback(tb, exclude):
"Remove excluded traces from beginning/end of tb; get cached lines"
@@ -186,7 +188,7 @@ def cleanup_traceback(tb, exclude):
if len(tb) == 0:
# exception was in IDLE internals, don't prune!
tb[:] = orig_tb[:]
- print>>sys.stderr, "** IDLE Internal Exception: "
+ print("** IDLE Internal Exception: ", file=sys.stderr)
rpchandler = rpc.objecttable['exec'].rpchandler
for i in range(len(tb)):
fn, ln, nm, line = tb[i]
@@ -198,25 +200,19 @@ def cleanup_traceback(tb, exclude):
tb[i] = fn, ln, nm, line
def flush_stdout():
- try:
- if sys.stdout.softspace:
- sys.stdout.softspace = 0
- sys.stdout.write("\n")
- except (AttributeError, EOFError):
- pass
+ """XXX How to do this now?"""
def exit():
- """Exit subprocess, possibly after first deleting sys.exitfunc
+ """Exit subprocess, possibly after first clearing exit functions.
If config-main.cfg/.def 'General' 'delete-exitfunc' is True, then any
- sys.exitfunc will be removed before exiting. (VPython support)
+ functions registered with atexit will be removed before exiting.
+ (VPython support)
"""
if no_exitfunc:
- try:
- del sys.exitfunc
- except AttributeError:
- pass
+ import atexit
+ atexit._clear()
sys.exit(0)
class MyRPCServer(rpc.RPCServer):
@@ -238,14 +234,14 @@ class MyRPCServer(rpc.RPCServer):
thread.interrupt_main()
except:
erf = sys.__stderr__
- print>>erf, '\n' + '-'*40
- print>>erf, 'Unhandled server exception!'
- print>>erf, 'Thread: %s' % threading.currentThread().getName()
- print>>erf, 'Client Address: ', client_address
- print>>erf, 'Request: ', repr(request)
+ print('\n' + '-'*40, file=erf)
+ print('Unhandled server exception!', file=erf)
+ print('Thread: %s' % threading.current_thread().name, file=erf)
+ print('Client Address: ', client_address, file=erf)
+ print('Request: ', repr(request), file=erf)
traceback.print_exc(file=erf)
- print>>erf, '\n*** Unrecoverable, server exiting!'
- print>>erf, '-'*40
+ print('\n*** Unrecoverable, server exiting!', file=erf)
+ print('-'*40, file=erf)
quitting = True
thread.interrupt_main()
@@ -271,7 +267,7 @@ class _RPCFile(io.TextIOBase):
@staticmethod
def _ensure_string(func):
def f(self, s):
- if not isinstance(s, basestring):
+ if not isinstance(s, str):
raise TypeError('must be str, not ' + type(s).__name__)
return func(self, s)
return f
@@ -279,6 +275,8 @@ class _RPCFile(io.TextIOBase):
class _RPCOutputFile(_RPCFile):
@_RPCFile._ensure_string
def write(self, s):
+ if not isinstance(s, str):
+ raise TypeError('must be str, not ' + type(s).__name__)
return self.rpc.write(s)
class _RPCInputFile(_RPCFile):
@@ -297,6 +295,9 @@ class MyHandler(rpc.RPCHandler):
sys.stdin = _RPCInputFile(self.console)
sys.stdout = _RPCOutputFile(self.get_remote_proxy("stdout"))
sys.stderr = _RPCOutputFile(self.get_remote_proxy("stderr"))
+ # page help() text to shell.
+ import pydoc # import must be done here to capture i/o binding
+ pydoc.pager = pydoc.plainpager
from idlelib import IOBinding
sys.stdin.encoding = sys.stdout.encoding = \
sys.stderr.encoding = IOBinding.encoding
@@ -334,7 +335,7 @@ class Executive(object):
self.usr_exc_info = None
interruptable = True
try:
- exec code in self.locals
+ exec(code, self.locals)
finally:
interruptable = False
except:
diff --git a/Lib/idlelib/tabbedpages.py b/Lib/idlelib/tabbedpages.py
index 8d7113dfa93..25577327558 100644
--- a/Lib/idlelib/tabbedpages.py
+++ b/Lib/idlelib/tabbedpages.py
@@ -7,7 +7,7 @@ TabbedPageSet -- A Tkinter implementation of a tabbed-page widget.
TabSet -- A widget containing tabs (buttons) in one or more rows.
"""
-from Tkinter import *
+from tkinter import *
class InvalidNameError(Exception): pass
class AlreadyExistsError(Exception): pass
@@ -78,7 +78,7 @@ class TabSet(Frame):
def remove_tab(self, tab_name):
"""Remove the tab named <tab_name>"""
if not tab_name in self._tab_names:
- raise KeyError("No such Tab: '%s" % page_name)
+ raise KeyError("No such Tab: '%s" % tab_name)
self._tab_names.remove(tab_name)
self._arrange_tabs()
@@ -88,7 +88,7 @@ class TabSet(Frame):
if tab_name == self._selected_tab:
return
if tab_name is not None and tab_name not in self._tabs:
- raise KeyError("No such Tab: '%s" % page_name)
+ raise KeyError("No such Tab: '%s" % tab_name)
# deselect the current selected tab
if self._selected_tab is not None:
@@ -143,8 +143,8 @@ class TabSet(Frame):
"""
# remove all tabs and rows
- for tab_name in self._tabs.keys():
- self._tabs.pop(tab_name).destroy()
+ while self._tabs:
+ self._tabs.popitem()[1].destroy()
self._reset_tab_rows()
if not self._tab_names:
@@ -159,7 +159,7 @@ class TabSet(Frame):
# not expanding the tabs with more than one row is very ugly
expand_tabs = self.expand_tabs or n_rows > 1
i = 0 # index in self._tab_names
- for row_index in xrange(n_rows):
+ for row_index in range(n_rows):
# calculate required number of tabs in this row
n_tabs = (len(self._tab_names) - i - 1) // (n_rows - row_index) + 1
tab_names = self._tab_names[i:i + n_tabs]
diff --git a/Lib/idlelib/textView.py b/Lib/idlelib/textView.py
index 8937c17b6c4..1eaa4649edf 100644
--- a/Lib/idlelib/textView.py
+++ b/Lib/idlelib/textView.py
@@ -2,8 +2,8 @@
"""
-from Tkinter import *
-import tkMessageBox
+from tkinter import *
+import tkinter.messagebox as tkMessageBox
class TextViewer(Toplevel):
"""A simple text viewer dialog for IDLE
@@ -64,18 +64,15 @@ def view_text(parent, title, text, modal=True):
def view_file(parent, title, filename, encoding=None, modal=True):
try:
- if encoding:
- import codecs
- textFile = codecs.open(filename, 'r')
- else:
- textFile = open(filename, 'r')
+ with open(filename, 'r', encoding=encoding) as file:
+ contents = file.read()
except IOError:
- import tkMessageBox
+ import tkinter.messagebox as tkMessageBox
tkMessageBox.showerror(title='File Load Error',
message='Unable to load file %r .' % filename,
parent=parent)
else:
- return view_text(parent, title, textFile.read(), modal)
+ return view_text(parent, title, contents, modal)
if __name__ == '__main__':
diff --git a/Lib/ihooks.py b/Lib/ihooks.py
deleted file mode 100644
index 8761dac7cd0..00000000000
--- a/Lib/ihooks.py
+++ /dev/null
@@ -1,554 +0,0 @@
-"""Import hook support.
-
-Consistent use of this module will make it possible to change the
-different mechanisms involved in loading modules independently.
-
-While the built-in module imp exports interfaces to the built-in
-module searching and loading algorithm, and it is possible to replace
-the built-in function __import__ in order to change the semantics of
-the import statement, until now it has been difficult to combine the
-effect of different __import__ hacks, like loading modules from URLs
-by rimport.py, or restricted execution by rexec.py.
-
-This module defines three new concepts:
-
-1) A "file system hooks" class provides an interface to a filesystem.
-
-One hooks class is defined (Hooks), which uses the interface provided
-by standard modules os and os.path. It should be used as the base
-class for other hooks classes.
-
-2) A "module loader" class provides an interface to search for a
-module in a search path and to load it. It defines a method which
-searches for a module in a single directory; by overriding this method
-one can redefine the details of the search. If the directory is None,
-built-in and frozen modules are searched instead.
-
-Two module loader class are defined, both implementing the search
-strategy used by the built-in __import__ function: ModuleLoader uses
-the imp module's find_module interface, while HookableModuleLoader
-uses a file system hooks class to interact with the file system. Both
-use the imp module's load_* interfaces to actually load the module.
-
-3) A "module importer" class provides an interface to import a
-module, as well as interfaces to reload and unload a module. It also
-provides interfaces to install and uninstall itself instead of the
-default __import__ and reload (and unload) functions.
-
-One module importer class is defined (ModuleImporter), which uses a
-module loader instance passed in (by default HookableModuleLoader is
-instantiated).
-
-The classes defined here should be used as base classes for extended
-functionality along those lines.
-
-If a module importer class supports dotted names, its import_module()
-must return a different value depending on whether it is called on
-behalf of a "from ... import ..." statement or not. (This is caused
-by the way the __import__ hook is used by the Python interpreter.) It
-would also do wise to install a different version of reload().
-
-"""
-from warnings import warnpy3k, warn
-warnpy3k("the ihooks module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import __builtin__
-import imp
-import os
-import sys
-
-__all__ = ["BasicModuleLoader","Hooks","ModuleLoader","FancyModuleLoader",
- "BasicModuleImporter","ModuleImporter","install","uninstall"]
-
-VERBOSE = 0
-
-
-from imp import C_EXTENSION, PY_SOURCE, PY_COMPILED
-from imp import C_BUILTIN, PY_FROZEN, PKG_DIRECTORY
-BUILTIN_MODULE = C_BUILTIN
-FROZEN_MODULE = PY_FROZEN
-
-
-class _Verbose:
-
- def __init__(self, verbose = VERBOSE):
- self.verbose = verbose
-
- def get_verbose(self):
- return self.verbose
-
- def set_verbose(self, verbose):
- self.verbose = verbose
-
- # XXX The following is an experimental interface
-
- def note(self, *args):
- if self.verbose:
- self.message(*args)
-
- def message(self, format, *args):
- if args:
- print format%args
- else:
- print format
-
-
-class BasicModuleLoader(_Verbose):
-
- """Basic module loader.
-
- This provides the same functionality as built-in import. It
- doesn't deal with checking sys.modules -- all it provides is
- find_module() and a load_module(), as well as find_module_in_dir()
- which searches just one directory, and can be overridden by a
- derived class to change the module search algorithm when the basic
- dependency on sys.path is unchanged.
-
- The interface is a little more convenient than imp's:
- find_module(name, [path]) returns None or 'stuff', and
- load_module(name, stuff) loads the module.
-
- """
-
- def find_module(self, name, path = None):
- if path is None:
- path = [None] + self.default_path()
- for dir in path:
- stuff = self.find_module_in_dir(name, dir)
- if stuff: return stuff
- return None
-
- def default_path(self):
- return sys.path
-
- def find_module_in_dir(self, name, dir):
- if dir is None:
- return self.find_builtin_module(name)
- else:
- try:
- return imp.find_module(name, [dir])
- except ImportError:
- return None
-
- def find_builtin_module(self, name):
- # XXX frozen packages?
- if imp.is_builtin(name):
- return None, '', ('', '', BUILTIN_MODULE)
- if imp.is_frozen(name):
- return None, '', ('', '', FROZEN_MODULE)
- return None
-
- def load_module(self, name, stuff):
- file, filename, info = stuff
- try:
- return imp.load_module(name, file, filename, info)
- finally:
- if file: file.close()
-
-
-class Hooks(_Verbose):
-
- """Hooks into the filesystem and interpreter.
-
- By deriving a subclass you can redefine your filesystem interface,
- e.g. to merge it with the URL space.
-
- This base class behaves just like the native filesystem.
-
- """
-
- # imp interface
- def get_suffixes(self): return imp.get_suffixes()
- def new_module(self, name): return imp.new_module(name)
- def is_builtin(self, name): return imp.is_builtin(name)
- def init_builtin(self, name): return imp.init_builtin(name)
- def is_frozen(self, name): return imp.is_frozen(name)
- def init_frozen(self, name): return imp.init_frozen(name)
- def get_frozen_object(self, name): return imp.get_frozen_object(name)
- def load_source(self, name, filename, file=None):
- return imp.load_source(name, filename, file)
- def load_compiled(self, name, filename, file=None):
- return imp.load_compiled(name, filename, file)
- def load_dynamic(self, name, filename, file=None):
- return imp.load_dynamic(name, filename, file)
- def load_package(self, name, filename, file=None):
- return imp.load_module(name, file, filename, ("", "", PKG_DIRECTORY))
-
- def add_module(self, name):
- d = self.modules_dict()
- if name in d: return d[name]
- d[name] = m = self.new_module(name)
- return m
-
- # sys interface
- def modules_dict(self): return sys.modules
- def default_path(self): return sys.path
-
- def path_split(self, x): return os.path.split(x)
- def path_join(self, x, y): return os.path.join(x, y)
- def path_isabs(self, x): return os.path.isabs(x)
- # etc.
-
- def path_exists(self, x): return os.path.exists(x)
- def path_isdir(self, x): return os.path.isdir(x)
- def path_isfile(self, x): return os.path.isfile(x)
- def path_islink(self, x): return os.path.islink(x)
- # etc.
-
- def openfile(self, *x): return open(*x)
- openfile_error = IOError
- def listdir(self, x): return os.listdir(x)
- listdir_error = os.error
- # etc.
-
-
-class ModuleLoader(BasicModuleLoader):
-
- """Default module loader; uses file system hooks.
-
- By defining suitable hooks, you might be able to load modules from
- other sources than the file system, e.g. from compressed or
- encrypted files, tar files or (if you're brave!) URLs.
-
- """
-
- def __init__(self, hooks = None, verbose = VERBOSE):
- BasicModuleLoader.__init__(self, verbose)
- self.hooks = hooks or Hooks(verbose)
-
- def default_path(self):
- return self.hooks.default_path()
-
- def modules_dict(self):
- return self.hooks.modules_dict()
-
- def get_hooks(self):
- return self.hooks
-
- def set_hooks(self, hooks):
- self.hooks = hooks
-
- def find_builtin_module(self, name):
- # XXX frozen packages?
- if self.hooks.is_builtin(name):
- return None, '', ('', '', BUILTIN_MODULE)
- if self.hooks.is_frozen(name):
- return None, '', ('', '', FROZEN_MODULE)
- return None
-
- def find_module_in_dir(self, name, dir, allow_packages=1):
- if dir is None:
- return self.find_builtin_module(name)
- if allow_packages:
- fullname = self.hooks.path_join(dir, name)
- if self.hooks.path_isdir(fullname):
- stuff = self.find_module_in_dir("__init__", fullname, 0)
- if stuff:
- file = stuff[0]
- if file: file.close()
- return None, fullname, ('', '', PKG_DIRECTORY)
- for info in self.hooks.get_suffixes():
- suff, mode, type = info
- fullname = self.hooks.path_join(dir, name+suff)
- try:
- fp = self.hooks.openfile(fullname, mode)
- return fp, fullname, info
- except self.hooks.openfile_error:
- pass
- return None
-
- def load_module(self, name, stuff):
- file, filename, info = stuff
- (suff, mode, type) = info
- try:
- if type == BUILTIN_MODULE:
- return self.hooks.init_builtin(name)
- if type == FROZEN_MODULE:
- return self.hooks.init_frozen(name)
- if type == C_EXTENSION:
- m = self.hooks.load_dynamic(name, filename, file)
- elif type == PY_SOURCE:
- m = self.hooks.load_source(name, filename, file)
- elif type == PY_COMPILED:
- m = self.hooks.load_compiled(name, filename, file)
- elif type == PKG_DIRECTORY:
- m = self.hooks.load_package(name, filename, file)
- else:
- raise ImportError, "Unrecognized module type (%r) for %s" % \
- (type, name)
- finally:
- if file: file.close()
- m.__file__ = filename
- return m
-
-
-class FancyModuleLoader(ModuleLoader):
-
- """Fancy module loader -- parses and execs the code itself."""
-
- def load_module(self, name, stuff):
- file, filename, (suff, mode, type) = stuff
- realfilename = filename
- path = None
-
- if type == PKG_DIRECTORY:
- initstuff = self.find_module_in_dir("__init__", filename, 0)
- if not initstuff:
- raise ImportError, "No __init__ module in package %s" % name
- initfile, initfilename, initinfo = initstuff
- initsuff, initmode, inittype = initinfo
- if inittype not in (PY_COMPILED, PY_SOURCE):
- if initfile: initfile.close()
- raise ImportError, \
- "Bad type (%r) for __init__ module in package %s" % (
- inittype, name)
- path = [filename]
- file = initfile
- realfilename = initfilename
- type = inittype
-
- if type == FROZEN_MODULE:
- code = self.hooks.get_frozen_object(name)
- elif type == PY_COMPILED:
- import marshal
- file.seek(8)
- code = marshal.load(file)
- elif type == PY_SOURCE:
- data = file.read()
- code = compile(data, realfilename, 'exec')
- else:
- return ModuleLoader.load_module(self, name, stuff)
-
- m = self.hooks.add_module(name)
- if path:
- m.__path__ = path
- m.__file__ = filename
- try:
- exec code in m.__dict__
- except:
- d = self.hooks.modules_dict()
- if name in d:
- del d[name]
- raise
- return m
-
-
-class BasicModuleImporter(_Verbose):
-
- """Basic module importer; uses module loader.
-
- This provides basic import facilities but no package imports.
-
- """
-
- def __init__(self, loader = None, verbose = VERBOSE):
- _Verbose.__init__(self, verbose)
- self.loader = loader or ModuleLoader(None, verbose)
- self.modules = self.loader.modules_dict()
-
- def get_loader(self):
- return self.loader
-
- def set_loader(self, loader):
- self.loader = loader
-
- def get_hooks(self):
- return self.loader.get_hooks()
-
- def set_hooks(self, hooks):
- return self.loader.set_hooks(hooks)
-
- def import_module(self, name, globals={}, locals={}, fromlist=[]):
- name = str(name)
- if name in self.modules:
- return self.modules[name] # Fast path
- stuff = self.loader.find_module(name)
- if not stuff:
- raise ImportError, "No module named %s" % name
- return self.loader.load_module(name, stuff)
-
- def reload(self, module, path = None):
- name = str(module.__name__)
- stuff = self.loader.find_module(name, path)
- if not stuff:
- raise ImportError, "Module %s not found for reload" % name
- return self.loader.load_module(name, stuff)
-
- def unload(self, module):
- del self.modules[str(module.__name__)]
- # XXX Should this try to clear the module's namespace?
-
- def install(self):
- self.save_import_module = __builtin__.__import__
- self.save_reload = __builtin__.reload
- if not hasattr(__builtin__, 'unload'):
- __builtin__.unload = None
- self.save_unload = __builtin__.unload
- __builtin__.__import__ = self.import_module
- __builtin__.reload = self.reload
- __builtin__.unload = self.unload
-
- def uninstall(self):
- __builtin__.__import__ = self.save_import_module
- __builtin__.reload = self.save_reload
- __builtin__.unload = self.save_unload
- if not __builtin__.unload:
- del __builtin__.unload
-
-
-class ModuleImporter(BasicModuleImporter):
-
- """A module importer that supports packages."""
-
- def import_module(self, name, globals=None, locals=None, fromlist=None,
- level=-1):
- parent = self.determine_parent(globals, level)
- q, tail = self.find_head_package(parent, str(name))
- m = self.load_tail(q, tail)
- if not fromlist:
- return q
- if hasattr(m, "__path__"):
- self.ensure_fromlist(m, fromlist)
- return m
-
- def determine_parent(self, globals, level=-1):
- if not globals or not level:
- return None
- pkgname = globals.get('__package__')
- if pkgname is not None:
- if not pkgname and level > 0:
- raise ValueError, 'Attempted relative import in non-package'
- else:
- # __package__ not set, figure it out and set it
- modname = globals.get('__name__')
- if modname is None:
- return None
- if "__path__" in globals:
- # __path__ is set so modname is already the package name
- pkgname = modname
- else:
- # normal module, work out package name if any
- if '.' not in modname:
- if level > 0:
- raise ValueError, ('Attempted relative import in '
- 'non-package')
- globals['__package__'] = None
- return None
- pkgname = modname.rpartition('.')[0]
- globals['__package__'] = pkgname
- if level > 0:
- dot = len(pkgname)
- for x in range(level, 1, -1):
- try:
- dot = pkgname.rindex('.', 0, dot)
- except ValueError:
- raise ValueError('attempted relative import beyond '
- 'top-level package')
- pkgname = pkgname[:dot]
- try:
- return sys.modules[pkgname]
- except KeyError:
- if level < 1:
- warn("Parent module '%s' not found while handling "
- "absolute import" % pkgname, RuntimeWarning, 1)
- return None
- else:
- raise SystemError, ("Parent module '%s' not loaded, cannot "
- "perform relative import" % pkgname)
-
- def find_head_package(self, parent, name):
- if '.' in name:
- i = name.find('.')
- head = name[:i]
- tail = name[i+1:]
- else:
- head = name
- tail = ""
- if parent:
- qname = "%s.%s" % (parent.__name__, head)
- else:
- qname = head
- q = self.import_it(head, qname, parent)
- if q: return q, tail
- if parent:
- qname = head
- parent = None
- q = self.import_it(head, qname, parent)
- if q: return q, tail
- raise ImportError, "No module named '%s'" % qname
-
- def load_tail(self, q, tail):
- m = q
- while tail:
- i = tail.find('.')
- if i < 0: i = len(tail)
- head, tail = tail[:i], tail[i+1:]
- mname = "%s.%s" % (m.__name__, head)
- m = self.import_it(head, mname, m)
- if not m:
- raise ImportError, "No module named '%s'" % mname
- return m
-
- def ensure_fromlist(self, m, fromlist, recursive=0):
- for sub in fromlist:
- if sub == "*":
- if not recursive:
- try:
- all = m.__all__
- except AttributeError:
- pass
- else:
- self.ensure_fromlist(m, all, 1)
- continue
- if sub != "*" and not hasattr(m, sub):
- subname = "%s.%s" % (m.__name__, sub)
- submod = self.import_it(sub, subname, m)
- if not submod:
- raise ImportError, "No module named '%s'" % subname
-
- def import_it(self, partname, fqname, parent, force_load=0):
- if not partname:
- # completely empty module name should only happen in
- # 'from . import' or __import__("")
- return parent
- if not force_load:
- try:
- return self.modules[fqname]
- except KeyError:
- pass
- try:
- path = parent and parent.__path__
- except AttributeError:
- return None
- partname = str(partname)
- stuff = self.loader.find_module(partname, path)
- if not stuff:
- return None
- fqname = str(fqname)
- m = self.loader.load_module(fqname, stuff)
- if parent:
- setattr(parent, partname, m)
- return m
-
- def reload(self, module):
- name = str(module.__name__)
- if '.' not in name:
- return self.import_it(name, name, None, force_load=1)
- i = name.rfind('.')
- pname = name[:i]
- parent = self.modules[pname]
- return self.import_it(name[i+1:], name, parent, force_load=1)
-
-
-default_importer = None
-current_importer = None
-
-def install(importer = None):
- global current_importer
- current_importer = importer or default_importer or ModuleImporter()
- current_importer.install()
-
-def uninstall():
- global current_importer
- current_importer.uninstall()
diff --git a/Lib/imaplib.py b/Lib/imaplib.py
index c576927a8b0..c0334d88c3d 100644
--- a/Lib/imaplib.py
+++ b/Lib/imaplib.py
@@ -22,14 +22,20 @@ Public functions: Internaldate2tuple
__version__ = "2.58"
-import binascii, errno, random, re, socket, subprocess, sys, time
+import binascii, errno, random, re, socket, subprocess, sys, time, calendar
+
+try:
+ import ssl
+ HAVE_SSL = True
+except ImportError:
+ HAVE_SSL = False
__all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
"Int2AP", "ParseFlags", "Time2Internaldate"]
# Globals
-CRLF = '\r\n'
+CRLF = b'\r\n'
Debug = 0
IMAP4_PORT = 143
IMAP4_SSL_PORT = 993
@@ -71,6 +77,7 @@ Commands = {
'SETANNOTATION':('AUTH', 'SELECTED'),
'SETQUOTA': ('AUTH', 'SELECTED'),
'SORT': ('SELECTED',),
+ 'STARTTLS': ('NONAUTH',),
'STATUS': ('AUTH', 'SELECTED'),
'STORE': ('SELECTED',),
'SUBSCRIBE': ('AUTH', 'SELECTED'),
@@ -81,18 +88,19 @@ Commands = {
# Patterns to match server responses
-Continuation = re.compile(r'\+( (?P<data>.*))?')
-Flags = re.compile(r'.*FLAGS \((?P<flags>[^\)]*)\)')
-InternalDate = re.compile(r'.*INTERNALDATE "'
- r'(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9])'
- r' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
- r' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
- r'"')
-Literal = re.compile(r'.*{(?P<size>\d+)}$')
-MapCRLF = re.compile(r'\r\n|\r|\n')
-Response_code = re.compile(r'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
-Untagged_response = re.compile(r'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
-Untagged_status = re.compile(r'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?')
+Continuation = re.compile(br'\+( (?P<data>.*))?')
+Flags = re.compile(br'.*FLAGS \((?P<flags>[^\)]*)\)')
+InternalDate = re.compile(br'.*INTERNALDATE "'
+ br'(?P<day>[ 0123][0-9])-(?P<mon>[A-Z][a-z][a-z])-(?P<year>[0-9][0-9][0-9][0-9])'
+ br' (?P<hour>[0-9][0-9]):(?P<min>[0-9][0-9]):(?P<sec>[0-9][0-9])'
+ br' (?P<zonen>[-+])(?P<zoneh>[0-9][0-9])(?P<zonem>[0-9][0-9])'
+ br'"')
+Literal = re.compile(br'.*{(?P<size>\d+)}$', re.ASCII)
+MapCRLF = re.compile(br'\r\n|\r|\n')
+Response_code = re.compile(br'\[(?P<type>[A-Z-]+)( (?P<data>[^\]]*))?\]')
+Untagged_response = re.compile(br'\* (?P<type>[A-Z-]+)( (?P<data>.*))?')
+Untagged_status = re.compile(
+ br'\* (?P<data>\d+) (?P<type>[A-Z-]+)( (?P<data2>.*))?', re.ASCII)
@@ -146,8 +154,6 @@ class IMAP4:
class abort(error): pass # Service errors - close and retry
class readonly(abort): pass # Mailbox status changed to READ-ONLY
- mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]")
-
def __init__(self, host = '', port = IMAP4_PORT):
self.debug = Debug
self.state = 'LOGOUT'
@@ -157,18 +163,30 @@ class IMAP4:
self.continuation_response = '' # Last continuation response
self.is_readonly = False # READ-ONLY desired state
self.tagnum = 0
+ self._tls_established = False
# Open socket to server.
self.open(host, port)
+ try:
+ self._connect()
+ except Exception:
+ try:
+ self.shutdown()
+ except socket.error:
+ pass
+ raise
+
+
+ def _connect(self):
# Create unique tag for this session,
# and compile tagged response matcher.
self.tagpre = Int2AP(random.randint(4096, 65535))
- self.tagre = re.compile(r'(?P<tag>'
+ self.tagre = re.compile(br'(?P<tag>'
+ self.tagpre
- + r'\d+) (?P<type>[A-Z]+) (?P<data>.*)')
+ + br'\d+) (?P<type>[A-Z]+) (?P<data>.*)', re.ASCII)
# Get server welcome message,
# request and store CAPABILITY response.
@@ -189,11 +207,7 @@ class IMAP4:
else:
raise self.error(self.welcome)
- typ, dat = self.capability()
- if dat == [None]:
- raise self.error('no CAPABILITY response from server')
- self.capabilities = tuple(dat[-1].upper().split())
-
+ self._get_capabilities()
if __debug__:
if self.debug >= 3:
self._mesg('CAPABILITIES: %r' % (self.capabilities,))
@@ -218,6 +232,9 @@ class IMAP4:
# Overridable methods
+ def _create_socket(self):
+ return socket.create_connection((self.host, self.port))
+
def open(self, host = '', port = IMAP4_PORT):
"""Setup connection to remote server on "host:port"
(default: localhost:standard IMAP4 port).
@@ -226,13 +243,21 @@ class IMAP4:
"""
self.host = host
self.port = port
- self.sock = socket.create_connection((host, port))
+ self.sock = self._create_socket()
self.file = self.sock.makefile('rb')
def read(self, size):
"""Read 'size' bytes from remote."""
- return self.file.read(size)
+ chunks = []
+ read = 0
+ while read < size:
+ data = self.file.read(min(size-read, 4096))
+ if not data:
+ break
+ read += len(data)
+ chunks.append(data)
+ return b''.join(chunks)
def readline(self):
@@ -699,6 +724,30 @@ class IMAP4:
return self._untagged_response(typ, dat, name)
+ def starttls(self, ssl_context=None):
+ name = 'STARTTLS'
+ if not HAVE_SSL:
+ raise self.error('SSL support missing')
+ if self._tls_established:
+ raise self.abort('TLS session already established')
+ if name not in self.capabilities:
+ raise self.abort('TLS not supported by server')
+ # Generate a default SSL context if none was passed.
+ if ssl_context is None:
+ ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ # SSLv2 considered harmful.
+ ssl_context.options |= ssl.OP_NO_SSLv2
+ typ, dat = self._simple_command(name)
+ if typ == 'OK':
+ self.sock = ssl_context.wrap_socket(self.sock)
+ self.file = self.sock.makefile('rb')
+ self._tls_established = True
+ self._get_capabilities()
+ else:
+ raise self.error("Couldn't establish TLS session")
+ return self._untagged_response(typ, dat, name)
+
+
def status(self, mailbox, names):
"""Request named status conditions for mailbox.
@@ -796,12 +845,12 @@ class IMAP4:
def _append_untagged(self, typ, dat):
-
- if dat is None: dat = ''
+ if dat is None:
+ dat = b''
ur = self.untagged_responses
if __debug__:
if self.debug >= 5:
- self._mesg('untagged_responses[%s] %s += ["%s"]' %
+ self._mesg('untagged_responses[%s] %s += ["%r"]' %
(typ, len(ur.get(typ,'')), dat))
if typ in ur:
ur[typ].append(dat)
@@ -812,7 +861,7 @@ class IMAP4:
def _check_bye(self):
bye = self.untagged_responses.get('BYE')
if bye:
- raise self.abort(bye[-1])
+ raise self.abort(bye[-1].decode('ascii', 'replace'))
def _command(self, name, *args):
@@ -833,10 +882,13 @@ class IMAP4:
raise self.readonly('mailbox status changed to READ-ONLY')
tag = self._new_tag()
- data = '%s %s' % (tag, name)
+ name = bytes(name, 'ASCII')
+ data = tag + b' ' + name
for arg in args:
if arg is None: continue
- data = '%s %s' % (data, self._checkquote(arg))
+ if isinstance(arg, str):
+ arg = bytes(arg, "ASCII")
+ data = data + b' ' + arg
literal = self.literal
if literal is not None:
@@ -845,17 +897,17 @@ class IMAP4:
literator = literal
else:
literator = None
- data = '%s {%s}' % (data, len(literal))
+ data = data + bytes(' {%s}' % len(literal), 'ASCII')
if __debug__:
if self.debug >= 4:
- self._mesg('> %s' % data)
+ self._mesg('> %r' % data)
else:
- self._log('> %s' % data)
+ self._log('> %r' % data)
try:
- self.send('%s%s' % (data, CRLF))
- except (socket.error, OSError), val:
+ self.send(data + CRLF)
+ except (socket.error, OSError) as val:
raise self.abort('socket error: %s' % val)
if literal is None:
@@ -880,7 +932,7 @@ class IMAP4:
try:
self.send(literal)
self.send(CRLF)
- except (socket.error, OSError), val:
+ except (socket.error, OSError) as val:
raise self.abort('socket error: %s' % val)
if not literator:
@@ -895,9 +947,9 @@ class IMAP4:
self._check_bye()
try:
typ, data = self._get_tagged_response(tag)
- except self.abort, val:
+ except self.abort as val:
raise self.abort('command: %s => %s' % (name, val))
- except self.error, val:
+ except self.error as val:
raise self.error('command: %s => %s' % (name, val))
if name != 'LOGOUT':
self._check_bye()
@@ -906,6 +958,15 @@ class IMAP4:
return typ, data
+ def _get_capabilities(self):
+ typ, dat = self.capability()
+ if dat == [None]:
+ raise self.error('no CAPABILITY response from server')
+ dat = str(dat[-1], "ASCII")
+ dat = dat.upper()
+ self.capabilities = tuple(dat.split())
+
+
def _get_response(self):
# Read response and store.
@@ -923,6 +984,7 @@ class IMAP4:
raise self.abort('unexpected tagged response: %s' % resp)
typ = self.mo.group('type')
+ typ = str(typ, 'ASCII')
dat = self.mo.group('data')
self.tagged_commands[tag] = (typ, [dat])
else:
@@ -944,9 +1006,10 @@ class IMAP4:
raise self.abort("unexpected response: '%s'" % resp)
typ = self.mo.group('type')
+ typ = str(typ, 'ascii')
dat = self.mo.group('data')
- if dat is None: dat = '' # Null untagged response
- if dat2: dat = dat + ' ' + dat2
+ if dat is None: dat = b'' # Null untagged response
+ if dat2: dat = dat + b' ' + dat2
# Is there a literal to come?
@@ -973,11 +1036,13 @@ class IMAP4:
# Bracketed response information?
if typ in ('OK', 'NO', 'BAD') and self._match(Response_code, dat):
- self._append_untagged(self.mo.group('type'), self.mo.group('data'))
+ typ = self.mo.group('type')
+ typ = str(typ, "ASCII")
+ self._append_untagged(typ, self.mo.group('data'))
if __debug__:
if self.debug >= 1 and typ in ('NO', 'BAD', 'BYE'):
- self._mesg('%s response: %s' % (typ, dat))
+ self._mesg('%s response: %r' % (typ, dat))
return resp
@@ -997,7 +1062,7 @@ class IMAP4:
try:
self._get_response()
- except self.abort, val:
+ except self.abort as val:
if __debug__:
if self.debug >= 1:
self.print_log()
@@ -1011,15 +1076,15 @@ class IMAP4:
raise self.abort('socket error: EOF')
# Protocol mandates all lines terminated by CRLF
- if not line.endswith('\r\n'):
+ if not line.endswith(b'\r\n'):
raise self.abort('socket error: unterminated line')
line = line[:-2]
if __debug__:
if self.debug >= 4:
- self._mesg('< %s' % line)
+ self._mesg('< %r' % line)
else:
- self._log('< %s' % line)
+ self._log('< %r' % line)
return line
@@ -1031,38 +1096,24 @@ class IMAP4:
self.mo = cre.match(s)
if __debug__:
if self.mo is not None and self.debug >= 5:
- self._mesg("\tmatched r'%s' => %r" % (cre.pattern, self.mo.groups()))
+ self._mesg("\tmatched r'%r' => %r" % (cre.pattern, self.mo.groups()))
return self.mo is not None
def _new_tag(self):
- tag = '%s%s' % (self.tagpre, self.tagnum)
+ tag = self.tagpre + bytes(str(self.tagnum), 'ASCII')
self.tagnum = self.tagnum + 1
self.tagged_commands[tag] = None
return tag
- def _checkquote(self, arg):
-
- # Must quote command args if non-alphanumeric chars present,
- # and not already quoted.
-
- if type(arg) is not type(''):
- return arg
- if len(arg) >= 2 and (arg[0],arg[-1]) in (('(',')'),('"','"')):
- return arg
- if arg and self.mustquote.search(arg) is None:
- return arg
- return self._quote(arg)
-
-
def _quote(self, arg):
arg = arg.replace('\\', '\\\\')
arg = arg.replace('"', '\\"')
- return '"%s"' % arg
+ return '"' + arg + '"'
def _simple_command(self, name, *args):
@@ -1071,7 +1122,6 @@ class IMAP4:
def _untagged_response(self, typ, dat, name):
-
if typ == 'NO':
return typ, dat
if not name in self.untagged_responses:
@@ -1121,12 +1171,8 @@ class IMAP4:
n -= 1
+if HAVE_SSL:
-try:
- import ssl
-except ImportError:
- pass
-else:
class IMAP4_SSL(IMAP4):
"""IMAP4 client class over SSL connection
@@ -1147,61 +1193,17 @@ else:
self.certfile = certfile
IMAP4.__init__(self, host, port)
+ def _create_socket(self):
+ sock = IMAP4._create_socket(self)
+ return ssl.wrap_socket(sock, self.keyfile, self.certfile)
- def open(self, host = '', port = IMAP4_SSL_PORT):
+ def open(self, host='', port=IMAP4_SSL_PORT):
"""Setup connection to remote server on "host:port".
(default: localhost:standard IMAP4 SSL port).
This connection will be used by the routines:
read, readline, send, shutdown.
"""
- self.host = host
- self.port = port
- self.sock = socket.create_connection((host, port))
- self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
- self.file = self.sslobj.makefile('rb')
-
-
- def read(self, size):
- """Read 'size' bytes from remote."""
- return self.file.read(size)
-
-
- def readline(self):
- """Read line from remote."""
- return self.file.readline()
-
-
- def send(self, data):
- """Send data to remote."""
- bytes = len(data)
- while bytes > 0:
- sent = self.sslobj.write(data)
- if sent == bytes:
- break # avoid copy
- data = data[sent:]
- bytes = bytes - sent
-
-
- def shutdown(self):
- """Close I/O established in "open"."""
- self.file.close()
- self.sock.close()
-
-
- def socket(self):
- """Return socket instance used to connect to IMAP4 server.
-
- socket = <instance>.socket()
- """
- return self.sock
-
-
- def ssl(self):
- """Return SSLObject instance used to communicate with the IMAP4 server.
-
- ssl = ssl.wrap_socket(<instance>.socket)
- """
- return self.sslobj
+ IMAP4.open(self, host, port)
__all__.append("IMAP4_SSL")
@@ -1238,7 +1240,6 @@ class IMAP4_stream(IMAP4):
self.writefile = self.process.stdin
self.readfile = self.process.stdout
-
def read(self, size):
"""Read 'size' bytes from remote."""
return self.readfile.read(size)
@@ -1307,14 +1308,14 @@ class _Authenticator:
-Mon2num = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6,
- 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}
+Mon2num = {b'Jan': 1, b'Feb': 2, b'Mar': 3, b'Apr': 4, b'May': 5, b'Jun': 6,
+ b'Jul': 7, b'Aug': 8, b'Sep': 9, b'Oct': 10, b'Nov': 11, b'Dec': 12}
def Internaldate2tuple(resp):
"""Parse an IMAP4 INTERNALDATE string.
Return corresponding local time. The return value is a
- time.struct_time instance or None if the string has wrong format.
+ time.struct_time tuple or None if the string has wrong format.
"""
mo = InternalDate.match(resp)
@@ -1335,23 +1336,13 @@ def Internaldate2tuple(resp):
# INTERNALDATE timezone must be subtracted to get UT
zone = (zoneh*60 + zonem)*60
- if zonen == '-':
+ if zonen == b'-':
zone = -zone
tt = (year, mon, day, hour, min, sec, -1, -1, -1)
+ utc = calendar.timegm(tt) - zone
- utc = time.mktime(tt)
-
- # Following is necessary because the time module has no 'mkgmtime'.
- # 'mktime' assumes arg in local timezone, so adds timezone/altzone.
-
- lt = time.localtime(utc)
- if time.daylight and lt[-1]:
- zone = zone + time.altzone
- else:
- zone = zone + time.timezone
-
- return time.localtime(utc - zone)
+ return time.localtime(utc)
@@ -1359,11 +1350,11 @@ def Int2AP(num):
"""Convert integer to A-P string representation."""
- val = ''; AP = 'ABCDEFGHIJKLMNOP'
+ val = b''; AP = b'ABCDEFGHIJKLMNOP'
num = int(abs(num))
while num:
num, mod = divmod(num, 16)
- val = AP[mod] + val
+ val = AP[mod:mod+1] + val
return val
@@ -1421,7 +1412,7 @@ if __name__ == '__main__':
try:
optlist, args = getopt.getopt(sys.argv[1:], 'd:s:')
- except getopt.error, val:
+ except getopt.error as val:
optlist, args = (), ()
stream_command = None
@@ -1504,15 +1495,15 @@ if __name__ == '__main__':
run('uid', ('FETCH', '%s' % uid[-1],
'(FLAGS INTERNALDATE RFC822.SIZE RFC822.HEADER RFC822.TEXT)'))
- print '\nAll tests OK.'
+ print('\nAll tests OK.')
except:
- print '\nTests failed.'
+ print('\nTests failed.')
if not Debug:
- print '''
+ print('''
If you would like to see debugging output,
try: %s -d5
-''' % sys.argv[0]
+''' % sys.argv[0])
raise
diff --git a/Lib/imghdr.py b/Lib/imghdr.py
index 1683024cb72..6ee45daab8b 100644
--- a/Lib/imghdr.py
+++ b/Lib/imghdr.py
@@ -8,7 +8,7 @@ __all__ = ["what"]
def what(file, h=None):
if h is None:
- if isinstance(file, basestring):
+ if isinstance(file, str):
f = open(file, 'rb')
h = f.read(32)
else:
@@ -35,42 +35,35 @@ def what(file, h=None):
tests = []
def test_jpeg(h, f):
- """JPEG data in JFIF format"""
- if h[6:10] == 'JFIF':
+ """JPEG data in JFIF or Exif format"""
+ if h[6:10] in (b'JFIF', b'Exif'):
return 'jpeg'
tests.append(test_jpeg)
-def test_exif(h, f):
- """JPEG data in Exif format"""
- if h[6:10] == 'Exif':
- return 'jpeg'
-
-tests.append(test_exif)
-
def test_png(h, f):
- if h[:8] == "\211PNG\r\n\032\n":
+ if h.startswith(b'\211PNG\r\n\032\n'):
return 'png'
tests.append(test_png)
def test_gif(h, f):
"""GIF ('87 and '89 variants)"""
- if h[:6] in ('GIF87a', 'GIF89a'):
+ if h[:6] in (b'GIF87a', b'GIF89a'):
return 'gif'
tests.append(test_gif)
def test_tiff(h, f):
"""TIFF (can be in Motorola or Intel byte order)"""
- if h[:2] in ('MM', 'II'):
+ if h[:2] in (b'MM', b'II'):
return 'tiff'
tests.append(test_tiff)
def test_rgb(h, f):
"""SGI image library"""
- if h[:2] == '\001\332':
+ if h.startswith(b'\001\332'):
return 'rgb'
tests.append(test_rgb)
@@ -78,7 +71,7 @@ tests.append(test_rgb)
def test_pbm(h, f):
"""PBM (portable bitmap)"""
if len(h) >= 3 and \
- h[0] == 'P' and h[1] in '14' and h[2] in ' \t\n\r':
+ h[0] == ord(b'P') and h[1] in b'14' and h[2] in b' \t\n\r':
return 'pbm'
tests.append(test_pbm)
@@ -86,7 +79,7 @@ tests.append(test_pbm)
def test_pgm(h, f):
"""PGM (portable graymap)"""
if len(h) >= 3 and \
- h[0] == 'P' and h[1] in '25' and h[2] in ' \t\n\r':
+ h[0] == ord(b'P') and h[1] in b'25' and h[2] in b' \t\n\r':
return 'pgm'
tests.append(test_pgm)
@@ -94,28 +87,27 @@ tests.append(test_pgm)
def test_ppm(h, f):
"""PPM (portable pixmap)"""
if len(h) >= 3 and \
- h[0] == 'P' and h[1] in '36' and h[2] in ' \t\n\r':
+ h[0] == ord(b'P') and h[1] in b'36' and h[2] in b' \t\n\r':
return 'ppm'
tests.append(test_ppm)
def test_rast(h, f):
"""Sun raster file"""
- if h[:4] == '\x59\xA6\x6A\x95':
+ if h.startswith(b'\x59\xA6\x6A\x95'):
return 'rast'
tests.append(test_rast)
def test_xbm(h, f):
"""X bitmap (X10 or X11)"""
- s = '#define '
- if h[:len(s)] == s:
+ if h.startswith(b'#define '):
return 'xbm'
tests.append(test_xbm)
def test_bmp(h, f):
- if h[:2] == 'BM':
+ if h.startswith(b'BM'):
return 'bmp'
tests.append(test_bmp)
@@ -144,18 +136,21 @@ def testall(list, recursive, toplevel):
import os
for filename in list:
if os.path.isdir(filename):
- print filename + '/:',
+ print(filename + '/:', end=' ')
if recursive or toplevel:
- print 'recursing down:'
+ print('recursing down:')
import glob
names = glob.glob(os.path.join(filename, '*'))
testall(names, recursive, 0)
else:
- print '*** directory (use -r) ***'
+ print('*** directory (use -r) ***')
else:
- print filename + ':',
+ print(filename + ':', end=' ')
sys.stdout.flush()
try:
- print what(filename)
+ print(what(filename))
except IOError:
- print '*** not found ***'
+ print('*** not found ***')
+
+if __name__ == '__main__':
+ test()
diff --git a/Lib/importlib/__init__.py b/Lib/importlib/__init__.py
index ad31a1ac477..2baaf937329 100644
--- a/Lib/importlib/__init__.py
+++ b/Lib/importlib/__init__.py
@@ -1,20 +1,108 @@
-"""Backport of importlib.import_module from 3.x."""
-# While not critical (and in no way guaranteed!), it would be nice to keep this
-# code compatible with Python 2.3.
-import sys
-
-def _resolve_name(name, package, level):
- """Return the absolute name of the module to be imported."""
- if not hasattr(package, 'rindex'):
- raise ValueError("'package' not set to a string")
- dot = len(package)
- for x in xrange(level, 1, -1):
+"""A pure Python implementation of import.
+
+References on import:
+
+ * Language reference
+ http://docs.python.org/ref/import.html
+ * __import__ function
+ http://docs.python.org/lib/built-in-funcs.html
+ * Packages
+ http://www.python.org/doc/essays/packages.html
+ * PEP 235: Import on Case-Insensitive Platforms
+ http://www.python.org/dev/peps/pep-0235
+ * PEP 275: Import Modules from Zip Archives
+ http://www.python.org/dev/peps/pep-0273
+ * PEP 302: New Import Hooks
+ http://www.python.org/dev/peps/pep-0302/
+ * PEP 328: Imports: Multi-line and Absolute/Relative
+ http://www.python.org/dev/peps/pep-0328
+
+"""
+__all__ = ['__import__', 'import_module']
+
+from . import _bootstrap
+
+import os
+import re
+import tokenize
+
+# Bootstrap help #####################################################
+
+def _case_ok(directory, check):
+ """Check if the directory contains something matching 'check'.
+
+ No check is done if the file/directory exists or not.
+
+ """
+ if 'PYTHONCASEOK' in os.environ:
+ return True
+ elif check in os.listdir(directory if directory else os.getcwd()):
+ return True
+ return False
+
+
+def _w_long(x):
+ """Convert a 32-bit integer to little-endian.
+
+ XXX Temporary until marshal's long functions are exposed.
+
+ """
+ x = int(x)
+ int_bytes = []
+ int_bytes.append(x & 0xFF)
+ int_bytes.append((x >> 8) & 0xFF)
+ int_bytes.append((x >> 16) & 0xFF)
+ int_bytes.append((x >> 24) & 0xFF)
+ return bytearray(int_bytes)
+
+
+def _r_long(int_bytes):
+ """Convert 4 bytes in little-endian to an integer.
+
+ XXX Temporary until marshal's long function are exposed.
+
+ """
+ x = int_bytes[0]
+ x |= int_bytes[1] << 8
+ x |= int_bytes[2] << 16
+ x |= int_bytes[3] << 24
+ return x
+
+
+# Required built-in modules.
+try:
+ import posix as _os
+except ImportError:
+ try:
+ import nt as _os
+ except ImportError:
try:
- dot = package.rindex('.', 0, dot)
- except ValueError:
- raise ValueError("attempted relative import beyond top-level "
- "package")
- return "%s.%s" % (package[:dot], name)
+ import os2 as _os
+ except ImportError:
+ raise ImportError('posix, nt, or os2 module required for importlib')
+_bootstrap._os = _os
+import imp, sys, marshal, errno, _io
+_bootstrap.imp = imp
+_bootstrap.sys = sys
+_bootstrap.marshal = marshal
+_bootstrap.errno = errno
+_bootstrap._io = _io
+import _warnings
+_bootstrap._warnings = _warnings
+
+
+from os import sep
+# For os.path.join replacement; pull from Include/osdefs.h:SEP .
+_bootstrap.path_sep = sep
+
+_bootstrap._case_ok = _case_ok
+marshal._w_long = _w_long
+marshal._r_long = _r_long
+
+
+# Public API #########################################################
+
+from ._bootstrap import __import__
def import_module(name, package=None):
@@ -25,14 +113,12 @@ def import_module(name, package=None):
relative import to an absolute import.
"""
+ level = 0
if name.startswith('.'):
if not package:
raise TypeError("relative imports require the 'package' argument")
- level = 0
for character in name:
if character != '.':
break
level += 1
- name = _resolve_name(name[level:], package, level)
- __import__(name)
- return sys.modules[name]
+ return _bootstrap._gcd_import(name[level:], package, level)
diff --git a/Lib/importlib/_bootstrap.py b/Lib/importlib/_bootstrap.py
new file mode 100644
index 00000000000..aa4032c0ff5
--- /dev/null
+++ b/Lib/importlib/_bootstrap.py
@@ -0,0 +1,890 @@
+"""Core implementation of import.
+
+This module is NOT meant to be directly imported! It has been designed such
+that it can be bootstrapped into Python as the implementation of import. As
+such it requires the injection of specific modules and attributes in order to
+work. One should use importlib as the public-facing version of this module.
+
+"""
+
+# Injected modules are '_warnings', 'imp', 'sys', 'marshal', 'errno', '_io',
+# and '_os' (a.k.a. 'posix', 'nt' or 'os2').
+# Injected attribute is path_sep.
+#
+# When editing this code be aware that code executed at import time CANNOT
+# reference any injected objects! This includes not only global code but also
+# anything specified at the class level.
+
+
+# Bootstrap-related code ######################################################
+
+# XXX Could also expose Modules/getpath.c:joinpath()
+def _path_join(*args):
+ """Replacement for os.path.join."""
+ return path_sep.join(x[:-len(path_sep)] if x.endswith(path_sep) else x
+ for x in args if x)
+
+
+def _path_exists(path):
+ """Replacement for os.path.exists."""
+ try:
+ _os.stat(path)
+ except OSError:
+ return False
+ else:
+ return True
+
+
+def _path_is_mode_type(path, mode):
+ """Test whether the path is the specified mode type."""
+ try:
+ stat_info = _os.stat(path)
+ except OSError:
+ return False
+ return (stat_info.st_mode & 0o170000) == mode
+
+
+# XXX Could also expose Modules/getpath.c:isfile()
+def _path_isfile(path):
+ """Replacement for os.path.isfile."""
+ return _path_is_mode_type(path, 0o100000)
+
+
+# XXX Could also expose Modules/getpath.c:isdir()
+def _path_isdir(path):
+ """Replacement for os.path.isdir."""
+ if not path:
+ path = _os.getcwd()
+ return _path_is_mode_type(path, 0o040000)
+
+
+def _path_without_ext(path, ext_type):
+ """Replacement for os.path.splitext()[0]."""
+ for suffix in _suffix_list(ext_type):
+ if path.endswith(suffix):
+ return path[:-len(suffix)]
+ else:
+ raise ValueError("path is not of the specified type")
+
+
+def _path_absolute(path):
+ """Replacement for os.path.abspath."""
+ if not path:
+ path = _os.getcwd()
+ try:
+ return _os._getfullpathname(path)
+ except AttributeError:
+ if path.startswith('/'):
+ return path
+ else:
+ return _path_join(_os.getcwd(), path)
+
+
+def _wrap(new, old):
+ """Simple substitute for functools.wraps."""
+ for replace in ['__module__', '__name__', '__doc__']:
+ setattr(new, replace, getattr(old, replace))
+ new.__dict__.update(old.__dict__)
+
+
+code_type = type(_wrap.__code__)
+
+# Finder/loader utility code ##################################################
+
+def set_package(fxn):
+ """Set __package__ on the returned module."""
+ def wrapper(*args, **kwargs):
+ module = fxn(*args, **kwargs)
+ if not hasattr(module, '__package__') or module.__package__ is None:
+ module.__package__ = module.__name__
+ if not hasattr(module, '__path__'):
+ module.__package__ = module.__package__.rpartition('.')[0]
+ return module
+ _wrap(wrapper, fxn)
+ return wrapper
+
+
+def set_loader(fxn):
+ """Set __loader__ on the returned module."""
+ def wrapper(self, *args, **kwargs):
+ module = fxn(self, *args, **kwargs)
+ if not hasattr(module, '__loader__'):
+ module.__loader__ = self
+ return module
+ _wrap(wrapper, fxn)
+ return wrapper
+
+
+def module_for_loader(fxn):
+ """Decorator to handle selecting the proper module for loaders.
+
+ The decorated function is passed the module to use instead of the module
+ name. The module passed in to the function is either from sys.modules if
+ it already exists or is a new module which has __name__ set and is inserted
+ into sys.modules. If an exception is raised and the decorator created the
+ module it is subsequently removed from sys.modules.
+
+ The decorator assumes that the decorated function takes the module name as
+ the second argument.
+
+ """
+ def decorated(self, fullname, *args, **kwargs):
+ module = sys.modules.get(fullname)
+ is_reload = bool(module)
+ if not is_reload:
+ # This must be done before open() is called as the 'io' module
+ # implicitly imports 'locale' and would otherwise trigger an
+ # infinite loop.
+ module = imp.new_module(fullname)
+ sys.modules[fullname] = module
+ try:
+ return fxn(self, module, *args, **kwargs)
+ except:
+ if not is_reload:
+ del sys.modules[fullname]
+ raise
+ _wrap(decorated, fxn)
+ return decorated
+
+
+def _check_name(method):
+ """Decorator to verify that the module being requested matches the one the
+ loader can handle.
+
+ The first argument (self) must define _name which the second argument is
+ compared against. If the comparison fails then ImportError is raised.
+
+ """
+ def inner(self, name, *args, **kwargs):
+ if self._name != name:
+ raise ImportError("loader cannot handle %s" % name)
+ return method(self, name, *args, **kwargs)
+ _wrap(inner, method)
+ return inner
+
+
+def _requires_builtin(fxn):
+ """Decorator to verify the named module is built-in."""
+ def wrapper(self, fullname):
+ if fullname not in sys.builtin_module_names:
+ raise ImportError("{0} is not a built-in module".format(fullname))
+ return fxn(self, fullname)
+ _wrap(wrapper, fxn)
+ return wrapper
+
+
+def _requires_frozen(fxn):
+ """Decorator to verify the named module is frozen."""
+ def wrapper(self, fullname):
+ if not imp.is_frozen(fullname):
+ raise ImportError("{0} is not a frozen module".format(fullname))
+ return fxn(self, fullname)
+ _wrap(wrapper, fxn)
+ return wrapper
+
+
+def _suffix_list(suffix_type):
+ """Return a list of file suffixes based on the imp file type."""
+ return [suffix[0] for suffix in imp.get_suffixes()
+ if suffix[2] == suffix_type]
+
+
+# Loaders #####################################################################
+
+class BuiltinImporter:
+
+ """Meta path import for built-in modules.
+
+ All methods are either class or static methods to avoid the need to
+ instantiate the class.
+
+ """
+
+ @classmethod
+ def find_module(cls, fullname, path=None):
+ """Find the built-in module.
+
+ If 'path' is ever specified then the search is considered a failure.
+
+ """
+ if path is not None:
+ return None
+ return cls if imp.is_builtin(fullname) else None
+
+ @classmethod
+ @set_package
+ @set_loader
+ @_requires_builtin
+ def load_module(cls, fullname):
+ """Load a built-in module."""
+ is_reload = fullname in sys.modules
+ try:
+ return imp.init_builtin(fullname)
+ except:
+ if not is_reload and fullname in sys.modules:
+ del sys.modules[fullname]
+ raise
+
+ @classmethod
+ @_requires_builtin
+ def get_code(cls, fullname):
+ """Return None as built-in modules do not have code objects."""
+ return None
+
+ @classmethod
+ @_requires_builtin
+ def get_source(cls, fullname):
+ """Return None as built-in modules do not have source code."""
+ return None
+
+ @classmethod
+ @_requires_builtin
+ def is_package(cls, fullname):
+ """Return None as built-in module are never packages."""
+ return False
+
+
+class FrozenImporter:
+
+ """Meta path import for frozen modules.
+
+ All methods are either class or static methods to avoid the need to
+ instantiate the class.
+
+ """
+
+ @classmethod
+ def find_module(cls, fullname, path=None):
+ """Find a frozen module."""
+ return cls if imp.is_frozen(fullname) else None
+
+ @classmethod
+ @set_package
+ @set_loader
+ @_requires_frozen
+ def load_module(cls, fullname):
+ """Load a frozen module."""
+ is_reload = fullname in sys.modules
+ try:
+ return imp.init_frozen(fullname)
+ except:
+ if not is_reload and fullname in sys.modules:
+ del sys.modules[fullname]
+ raise
+
+ @classmethod
+ @_requires_frozen
+ def get_code(cls, fullname):
+ """Return the code object for the frozen module."""
+ return imp.get_frozen_object(fullname)
+
+ @classmethod
+ @_requires_frozen
+ def get_source(cls, fullname):
+ """Return None as frozen modules do not have source code."""
+ return None
+
+ @classmethod
+ @_requires_frozen
+ def is_package(cls, fullname):
+ """Return if the frozen module is a package."""
+ return imp.is_frozen_package(fullname)
+
+
+class _LoaderBasics:
+
+ """Base class of common code needed by both SourceLoader and
+ _SourcelessFileLoader."""
+
+ def is_package(self, fullname):
+ """Concrete implementation of InspectLoader.is_package by checking if
+ the path returned by get_filename has a filename of '__init__.py'."""
+ filename = self.get_filename(fullname).rpartition(path_sep)[2]
+ return filename.rsplit('.', 1)[0] == '__init__'
+
+ def _bytes_from_bytecode(self, fullname, data, source_mtime):
+ """Return the marshalled bytes from bytecode, verifying the magic
+ number and timestamp along the way.
+
+ If source_mtime is None then skip the timestamp check.
+
+ """
+ magic = data[:4]
+ raw_timestamp = data[4:8]
+ if len(magic) != 4 or magic != imp.get_magic():
+ raise ImportError("bad magic number in {}".format(fullname))
+ elif len(raw_timestamp) != 4:
+ raise EOFError("bad timestamp in {}".format(fullname))
+ elif source_mtime is not None:
+ if marshal._r_long(raw_timestamp) != source_mtime:
+ raise ImportError("bytecode is stale for {}".format(fullname))
+ # Can't return the code object as errors from marshal loading need to
+ # propagate even when source is available.
+ return data[8:]
+
+ @module_for_loader
+ def _load_module(self, module, *, sourceless=False):
+ """Helper for load_module able to handle either source or sourceless
+ loading."""
+ name = module.__name__
+ code_object = self.get_code(name)
+ module.__file__ = self.get_filename(name)
+ if not sourceless:
+ module.__cached__ = imp.cache_from_source(module.__file__)
+ else:
+ module.__cached__ = module.__file__
+ module.__package__ = name
+ if self.is_package(name):
+ module.__path__ = [module.__file__.rsplit(path_sep, 1)[0]]
+ else:
+ module.__package__ = module.__package__.rpartition('.')[0]
+ module.__loader__ = self
+ exec(code_object, module.__dict__)
+ return module
+
+
+class SourceLoader(_LoaderBasics):
+
+ def path_mtime(self, path):
+ """Optional method that returns the modification time (an int) for the
+ specified path, where path is a str.
+
+ Implementing this method allows the loader to read bytecode files.
+
+ """
+ raise NotImplementedError
+
+ def set_data(self, path, data):
+ """Optional method which writes data (bytes) to a file path (a str).
+
+ Implementing this method allows for the writing of bytecode files.
+
+ """
+ raise NotImplementedError
+
+
+ def get_source(self, fullname):
+ """Concrete implementation of InspectLoader.get_source."""
+ import tokenize
+ path = self.get_filename(fullname)
+ try:
+ source_bytes = self.get_data(path)
+ except IOError:
+ raise ImportError("source not available through get_data()")
+ encoding = tokenize.detect_encoding(_io.BytesIO(source_bytes).readline)
+ newline_decoder = _io.IncrementalNewlineDecoder(None, True)
+ return newline_decoder.decode(source_bytes.decode(encoding[0]))
+
+ def get_code(self, fullname):
+ """Concrete implementation of InspectLoader.get_code.
+
+ Reading of bytecode requires path_mtime to be implemented. To write
+ bytecode, set_data must also be implemented.
+
+ """
+ source_path = self.get_filename(fullname)
+ bytecode_path = imp.cache_from_source(source_path)
+ source_mtime = None
+ if bytecode_path is not None:
+ try:
+ source_mtime = self.path_mtime(source_path)
+ except NotImplementedError:
+ pass
+ else:
+ try:
+ data = self.get_data(bytecode_path)
+ except IOError:
+ pass
+ else:
+ try:
+ bytes_data = self._bytes_from_bytecode(fullname, data,
+ source_mtime)
+ except (ImportError, EOFError):
+ pass
+ else:
+ found = marshal.loads(bytes_data)
+ if isinstance(found, code_type):
+ return found
+ else:
+ msg = "Non-code object in {}"
+ raise ImportError(msg.format(bytecode_path))
+ source_bytes = self.get_data(source_path)
+ code_object = compile(source_bytes, source_path, 'exec',
+ dont_inherit=True)
+ if (not sys.dont_write_bytecode and bytecode_path is not None and
+ source_mtime is not None):
+ # If e.g. Jython ever implements imp.cache_from_source to have
+ # their own cached file format, this block of code will most likely
+ # raise an exception.
+ data = bytearray(imp.get_magic())
+ data.extend(marshal._w_long(source_mtime))
+ data.extend(marshal.dumps(code_object))
+ try:
+ self.set_data(bytecode_path, data)
+ except NotImplementedError:
+ pass
+ return code_object
+
+ def load_module(self, fullname):
+ """Concrete implementation of Loader.load_module.
+
+ Requires ExecutionLoader.get_filename and ResourceLoader.get_data to be
+ implemented to load source code. Use of bytecode is dictated by whether
+ get_code uses/writes bytecode.
+
+ """
+ return self._load_module(fullname)
+
+
+class _FileLoader:
+
+ """Base file loader class which implements the loader protocol methods that
+ require file system usage."""
+
+ def __init__(self, fullname, path):
+ """Cache the module name and the path to the file found by the
+ finder."""
+ self._name = fullname
+ self._path = path
+
+ @_check_name
+ def get_filename(self, fullname):
+ """Return the path to the source file as found by the finder."""
+ return self._path
+
+ def get_data(self, path):
+ """Return the data from path as raw bytes."""
+ with _io.FileIO(path, 'r') as file:
+ return file.read()
+
+
+class _SourceFileLoader(_FileLoader, SourceLoader):
+
+ """Concrete implementation of SourceLoader using the file system."""
+
+ def path_mtime(self, path):
+ """Return the modification time for the path."""
+ return int(_os.stat(path).st_mtime)
+
+ def set_data(self, path, data):
+ """Write bytes data to a file."""
+ parent, _, filename = path.rpartition(path_sep)
+ path_parts = []
+ # Figure out what directories are missing.
+ while parent and not _path_isdir(parent):
+ parent, _, part = parent.rpartition(path_sep)
+ path_parts.append(part)
+ # Create needed directories.
+ for part in reversed(path_parts):
+ parent = _path_join(parent, part)
+ try:
+ _os.mkdir(parent)
+ except OSError as exc:
+ # Probably another Python process already created the dir.
+ if exc.errno == errno.EEXIST:
+ continue
+ else:
+ raise
+ except IOError as exc:
+ # If can't get proper access, then just forget about writing
+ # the data.
+ if exc.errno == errno.EACCES:
+ return
+ else:
+ raise
+ try:
+ with _io.FileIO(path, 'wb') as file:
+ file.write(data)
+ except IOError as exc:
+ # Don't worry if you can't write bytecode.
+ if exc.errno == errno.EACCES:
+ return
+ else:
+ raise
+
+
+class _SourcelessFileLoader(_FileLoader, _LoaderBasics):
+
+ """Loader which handles sourceless file imports."""
+
+ def load_module(self, fullname):
+ return self._load_module(fullname, sourceless=True)
+
+ def get_code(self, fullname):
+ path = self.get_filename(fullname)
+ data = self.get_data(path)
+ bytes_data = self._bytes_from_bytecode(fullname, data, None)
+ found = marshal.loads(bytes_data)
+ if isinstance(found, code_type):
+ return found
+ else:
+ raise ImportError("Non-code object in {}".format(path))
+
+ def get_source(self, fullname):
+ """Return None as there is no source code."""
+ return None
+
+
+class _ExtensionFileLoader:
+
+ """Loader for extension modules.
+
+ The constructor is designed to work with FileFinder.
+
+ """
+
+ def __init__(self, name, path):
+ """Initialize the loader.
+
+ If is_pkg is True then an exception is raised as extension modules
+ cannot be the __init__ module for an extension module.
+
+ """
+ self._name = name
+ self._path = path
+
+ @_check_name
+ @set_package
+ @set_loader
+ def load_module(self, fullname):
+ """Load an extension module."""
+ is_reload = fullname in sys.modules
+ try:
+ return imp.load_dynamic(fullname, self._path)
+ except:
+ if not is_reload and fullname in sys.modules:
+ del sys.modules[fullname]
+ raise
+
+ @_check_name
+ def is_package(self, fullname):
+ """Return False as an extension module can never be a package."""
+ return False
+
+ @_check_name
+ def get_code(self, fullname):
+ """Return None as an extension module cannot create a code object."""
+ return None
+
+ @_check_name
+ def get_source(self, fullname):
+ """Return None as extension modules have no source code."""
+ return None
+
+
+# Finders #####################################################################
+
+class PathFinder:
+
+ """Meta path finder for sys.(path|path_hooks|path_importer_cache)."""
+
+ @classmethod
+ def _path_hooks(cls, path, hooks=None):
+ """Search sequence of hooks for a finder for 'path'.
+
+ If 'hooks' is false then use sys.path_hooks.
+
+ """
+ if not hooks:
+ hooks = sys.path_hooks
+ for hook in hooks:
+ try:
+ return hook(path)
+ except ImportError:
+ continue
+ else:
+ raise ImportError("no path hook found for {0}".format(path))
+
+ @classmethod
+ def _path_importer_cache(cls, path, default=None):
+ """Get the finder for the path from sys.path_importer_cache.
+
+ If the path is not in the cache, find the appropriate finder and cache
+ it. If None is cached, get the default finder and cache that
+ (if applicable).
+
+ Because of NullImporter, some finder should be returned. The only
+ explicit fail case is if None is cached but the path cannot be used for
+ the default hook, for which ImportError is raised.
+
+ """
+ try:
+ finder = sys.path_importer_cache[path]
+ except KeyError:
+ finder = cls._path_hooks(path)
+ sys.path_importer_cache[path] = finder
+ else:
+ if finder is None and default:
+ # Raises ImportError on failure.
+ finder = default(path)
+ sys.path_importer_cache[path] = finder
+ return finder
+
+ @classmethod
+ def find_module(cls, fullname, path=None):
+ """Find the module on sys.path or 'path' based on sys.path_hooks and
+ sys.path_importer_cache."""
+ if not path:
+ path = sys.path
+ for entry in path:
+ try:
+ finder = cls._path_importer_cache(entry)
+ except ImportError:
+ continue
+ if finder:
+ loader = finder.find_module(fullname)
+ if loader:
+ return loader
+ else:
+ return None
+
+
+class _FileFinder:
+
+ """File-based finder.
+
+ Constructor takes a list of objects detailing what file extensions their
+ loader supports along with whether it can be used for a package.
+
+ """
+
+ def __init__(self, path, *details):
+ """Initialize with finder details."""
+ packages = []
+ modules = []
+ for detail in details:
+ modules.extend((suffix, detail.loader) for suffix in detail.suffixes)
+ if detail.supports_packages:
+ packages.extend((suffix, detail.loader)
+ for suffix in detail.suffixes)
+ self.packages = packages
+ self.modules = modules
+ self.path = path
+
+ def find_module(self, fullname):
+ """Try to find a loader for the specified module."""
+ tail_module = fullname.rpartition('.')[2]
+ base_path = _path_join(self.path, tail_module)
+ if _path_isdir(base_path) and _case_ok(self.path, tail_module):
+ for suffix, loader in self.packages:
+ init_filename = '__init__' + suffix
+ full_path = _path_join(base_path, init_filename)
+ if (_path_isfile(full_path) and
+ _case_ok(base_path, init_filename)):
+ return loader(fullname, full_path)
+ else:
+ msg = "Not importing directory {}: missing __init__"
+ _warnings.warn(msg.format(base_path), ImportWarning)
+ for suffix, loader in self.modules:
+ mod_filename = tail_module + suffix
+ full_path = _path_join(self.path, mod_filename)
+ if _path_isfile(full_path) and _case_ok(self.path, mod_filename):
+ return loader(fullname, full_path)
+ return None
+
+class _SourceFinderDetails:
+
+ loader = _SourceFileLoader
+ supports_packages = True
+
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.PY_SOURCE)
+
+class _SourcelessFinderDetails:
+
+ loader = _SourcelessFileLoader
+ supports_packages = True
+
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.PY_COMPILED)
+
+
+class _ExtensionFinderDetails:
+
+ loader = _ExtensionFileLoader
+ supports_packages = False
+
+ def __init__(self):
+ self.suffixes = _suffix_list(imp.C_EXTENSION)
+
+
+# Import itself ###############################################################
+
+def _file_path_hook(path):
+ """If the path is a directory, return a file-based finder."""
+ if _path_isdir(path):
+ return _FileFinder(path, _ExtensionFinderDetails(),
+ _SourceFinderDetails(),
+ _SourcelessFinderDetails())
+ else:
+ raise ImportError("only directories are supported")
+
+
+_DEFAULT_PATH_HOOK = _file_path_hook
+
+class _DefaultPathFinder(PathFinder):
+
+ """Subclass of PathFinder that implements implicit semantics for
+ __import__."""
+
+ @classmethod
+ def _path_hooks(cls, path):
+ """Search sys.path_hooks as well as implicit path hooks."""
+ try:
+ return super()._path_hooks(path)
+ except ImportError:
+ implicit_hooks = [_DEFAULT_PATH_HOOK, imp.NullImporter]
+ return super()._path_hooks(path, implicit_hooks)
+
+ @classmethod
+ def _path_importer_cache(cls, path):
+ """Use the default path hook when None is stored in
+ sys.path_importer_cache."""
+ return super()._path_importer_cache(path, _DEFAULT_PATH_HOOK)
+
+
+class _ImportLockContext:
+
+ """Context manager for the import lock."""
+
+ def __enter__(self):
+ """Acquire the import lock."""
+ imp.acquire_lock()
+
+ def __exit__(self, exc_type, exc_value, exc_traceback):
+ """Release the import lock regardless of any raised exceptions."""
+ imp.release_lock()
+
+
+_IMPLICIT_META_PATH = [BuiltinImporter, FrozenImporter, _DefaultPathFinder]
+
+_ERR_MSG = 'No module named {}'
+
+def _gcd_import(name, package=None, level=0):
+ """Import and return the module based on its name, the package the call is
+ being made from, and the level adjustment.
+
+ This function represents the greatest common denominator of functionality
+ between import_module and __import__. This includes settting __package__ if
+ the loader did not.
+
+ """
+ if package:
+ if not hasattr(package, 'rindex'):
+ raise ValueError("__package__ not set to a string")
+ elif package not in sys.modules:
+ msg = ("Parent module {0!r} not loaded, cannot perform relative "
+ "import")
+ raise SystemError(msg.format(package))
+ if not name and level == 0:
+ raise ValueError("Empty module name")
+ if level > 0:
+ dot = len(package)
+ for x in range(level, 1, -1):
+ try:
+ dot = package.rindex('.', 0, dot)
+ except ValueError:
+ raise ValueError("attempted relative import beyond "
+ "top-level package")
+ if name:
+ name = "{0}.{1}".format(package[:dot], name)
+ else:
+ name = package[:dot]
+ with _ImportLockContext():
+ try:
+ module = sys.modules[name]
+ if module is None:
+ message = ("import of {} halted; "
+ "None in sys.modules".format(name))
+ raise ImportError(message)
+ return module
+ except KeyError:
+ pass
+ parent = name.rpartition('.')[0]
+ path = None
+ if parent:
+ if parent not in sys.modules:
+ _gcd_import(parent)
+ # Backwards-compatibility; be nicer to skip the dict lookup.
+ parent_module = sys.modules[parent]
+ try:
+ path = parent_module.__path__
+ except AttributeError:
+ msg = (_ERR_MSG + '; {} is not a package').format(name, parent)
+ raise ImportError(msg)
+ meta_path = sys.meta_path + _IMPLICIT_META_PATH
+ for finder in meta_path:
+ loader = finder.find_module(name, path)
+ if loader is not None:
+ # The parent import may have already imported this module.
+ if name not in sys.modules:
+ loader.load_module(name)
+ break
+ else:
+ raise ImportError(_ERR_MSG.format(name))
+ # Backwards-compatibility; be nicer to skip the dict lookup.
+ module = sys.modules[name]
+ if parent:
+ # Set the module as an attribute on its parent.
+ setattr(parent_module, name.rpartition('.')[2], module)
+ # Set __package__ if the loader did not.
+ if not hasattr(module, '__package__') or module.__package__ is None:
+ # Watch out for what comes out of sys.modules to not be a module,
+ # e.g. an int.
+ try:
+ module.__package__ = module.__name__
+ if not hasattr(module, '__path__'):
+ module.__package__ = module.__package__.rpartition('.')[0]
+ except AttributeError:
+ pass
+ return module
+
+
+def __import__(name, globals={}, locals={}, fromlist=[], level=0):
+ """Import a module.
+
+ The 'globals' argument is used to infer where the import is occuring from
+ to handle relative imports. The 'locals' argument is ignored. The
+ 'fromlist' argument specifies what should exist as attributes on the module
+ being imported (e.g. ``from module import <fromlist>``). The 'level'
+ argument represents the package location to import from in a relative
+ import (e.g. ``from ..pkg import mod`` would have a 'level' of 2).
+
+ """
+ if not hasattr(name, 'rpartition'):
+ raise TypeError("module name must be str, not {}".format(type(name)))
+ if level == 0:
+ module = _gcd_import(name)
+ else:
+ # __package__ is not guaranteed to be defined or could be set to None
+ # to represent that it's proper value is unknown
+ package = globals.get('__package__')
+ if package is None:
+ package = globals['__name__']
+ if '__path__' not in globals:
+ package = package.rpartition('.')[0]
+ module = _gcd_import(name, package, level)
+ # The hell that is fromlist ...
+ if not fromlist:
+ # Return up to the first dot in 'name'. This is complicated by the fact
+ # that 'name' may be relative.
+ if level == 0:
+ return sys.modules[name.partition('.')[0]]
+ elif not name:
+ return module
+ else:
+ cut_off = len(name) - len(name.partition('.')[0])
+ return sys.modules[module.__name__[:-cut_off]]
+ else:
+ # If a package was imported, try to import stuff from fromlist.
+ if hasattr(module, '__path__'):
+ if '*' in fromlist and hasattr(module, '__all__'):
+ fromlist = list(fromlist)
+ fromlist.remove('*')
+ fromlist.extend(module.__all__)
+ for x in (y for y in fromlist if not hasattr(module,y)):
+ try:
+ _gcd_import('{0}.{1}'.format(module.__name__, x))
+ except ImportError:
+ pass
+ return module
diff --git a/Lib/importlib/abc.py b/Lib/importlib/abc.py
new file mode 100644
index 00000000000..fa343f85a47
--- /dev/null
+++ b/Lib/importlib/abc.py
@@ -0,0 +1,304 @@
+"""Abstract base classes related to import."""
+from . import _bootstrap
+from . import machinery
+from . import util
+import abc
+import imp
+import io
+import marshal
+import os.path
+import sys
+import tokenize
+import types
+import warnings
+
+
+class Loader(metaclass=abc.ABCMeta):
+
+ """Abstract base class for import loaders."""
+
+ @abc.abstractmethod
+ def load_module(self, fullname):
+ """Abstract method which when implemented should load a module.
+ The fullname is a str."""
+ raise NotImplementedError
+
+
+class Finder(metaclass=abc.ABCMeta):
+
+ """Abstract base class for import finders."""
+
+ @abc.abstractmethod
+ def find_module(self, fullname, path=None):
+ """Abstract method which when implemented should find a module.
+ The fullname is a str and the optional path is a str or None.
+ Returns a Loader object.
+ """
+ raise NotImplementedError
+
+Finder.register(machinery.BuiltinImporter)
+Finder.register(machinery.FrozenImporter)
+Finder.register(machinery.PathFinder)
+
+
+class ResourceLoader(Loader):
+
+ """Abstract base class for loaders which can return data from their
+ back-end storage.
+
+ This ABC represents one of the optional protocols specified by PEP 302.
+
+ """
+
+ @abc.abstractmethod
+ def get_data(self, path):
+ """Abstract method which when implemented should return the bytes for
+ the specified path. The path must be a str."""
+ raise NotImplementedError
+
+
+class InspectLoader(Loader):
+
+ """Abstract base class for loaders which support inspection about the
+ modules they can load.
+
+ This ABC represents one of the optional protocols specified by PEP 302.
+
+ """
+
+ @abc.abstractmethod
+ def is_package(self, fullname):
+ """Abstract method which when implemented should return whether the
+ module is a package. The fullname is a str. Returns a bool."""
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def get_code(self, fullname):
+ """Abstract method which when implemented should return the code object
+ for the module. The fullname is a str. Returns a types.CodeType."""
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def get_source(self, fullname):
+ """Abstract method which should return the source code for the
+ module. The fullname is a str. Returns a str."""
+ raise NotImplementedError
+
+InspectLoader.register(machinery.BuiltinImporter)
+InspectLoader.register(machinery.FrozenImporter)
+
+
+class ExecutionLoader(InspectLoader):
+
+ """Abstract base class for loaders that wish to support the execution of
+ modules as scripts.
+
+ This ABC represents one of the optional protocols specified in PEP 302.
+
+ """
+
+ @abc.abstractmethod
+ def get_filename(self, fullname):
+ """Abstract method which should return the value that __file__ is to be
+ set to."""
+ raise NotImplementedError
+
+
+class SourceLoader(_bootstrap.SourceLoader, ResourceLoader, ExecutionLoader):
+
+ """Abstract base class for loading source code (and optionally any
+ corresponding bytecode).
+
+ To support loading from source code, the abstractmethods inherited from
+ ResourceLoader and ExecutionLoader need to be implemented. To also support
+ loading from bytecode, the optional methods specified directly by this ABC
+ is required.
+
+ Inherited abstractmethods not implemented in this ABC:
+
+ * ResourceLoader.get_data
+ * ExecutionLoader.get_filename
+
+ """
+
+ def path_mtime(self, path):
+ """Return the (int) modification time for the path (str)."""
+ raise NotImplementedError
+
+ def set_data(self, path, data):
+ """Write the bytes to the path (if possible).
+
+ Accepts a str path and data as bytes.
+
+ Any needed intermediary directories are to be created. If for some
+ reason the file cannot be written because of permissions, fail
+ silently.
+
+ """
+ raise NotImplementedError
+
+
+class PyLoader(SourceLoader):
+
+ """Implement the deprecated PyLoader ABC in terms of SourceLoader.
+
+ This class has been deprecated! It is slated for removal in Python 3.4.
+ If compatibility with Python 3.1 is not needed then implement the
+ SourceLoader ABC instead of this class. If Python 3.1 compatibility is
+ needed, then use the following idiom to have a single class that is
+ compatible with Python 3.1 onwards::
+
+ try:
+ from importlib.abc import SourceLoader
+ except ImportError:
+ from importlib.abc import PyLoader as SourceLoader
+
+
+ class CustomLoader(SourceLoader):
+ def get_filename(self, fullname):
+ # Implement ...
+
+ def source_path(self, fullname):
+ '''Implement source_path in terms of get_filename.'''
+ try:
+ return self.get_filename(fullname)
+ except ImportError:
+ return None
+
+ def is_package(self, fullname):
+ filename = os.path.basename(self.get_filename(fullname))
+ return os.path.splitext(filename)[0] == '__init__'
+
+ """
+
+ @abc.abstractmethod
+ def is_package(self, fullname):
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def source_path(self, fullname):
+ """Abstract method. Accepts a str module name and returns the path to
+ the source code for the module."""
+ raise NotImplementedError
+
+ def get_filename(self, fullname):
+ """Implement get_filename in terms of source_path.
+
+ As get_filename should only return a source file path there is no
+ chance of the path not existing but loading still being possible, so
+ ImportError should propagate instead of being turned into returning
+ None.
+
+ """
+ warnings.warn("importlib.abc.PyLoader is deprecated and is "
+ "slated for removal in Python 3.4; "
+ "use SourceLoader instead. "
+ "See the importlib documentation on how to be "
+ "compatible with Python 3.1 onwards.",
+ PendingDeprecationWarning)
+ path = self.source_path(fullname)
+ if path is None:
+ raise ImportError
+ else:
+ return path
+
+
+class PyPycLoader(PyLoader):
+
+ """Abstract base class to assist in loading source and bytecode by
+ requiring only back-end storage methods to be implemented.
+
+ This class has been deprecated! Removal is slated for Python 3.4. Implement
+ the SourceLoader ABC instead. If Python 3.1 compatibility is needed, see
+ PyLoader.
+
+ The methods get_code, get_source, and load_module are implemented for the
+ user.
+
+ """
+
+ def get_filename(self, fullname):
+ """Return the source or bytecode file path."""
+ path = self.source_path(fullname)
+ if path is not None:
+ return path
+ path = self.bytecode_path(fullname)
+ if path is not None:
+ return path
+ raise ImportError("no source or bytecode path available for "
+ "{0!r}".format(fullname))
+
+ def get_code(self, fullname):
+ """Get a code object from source or bytecode."""
+ warnings.warn("importlib.abc.PyPycLoader is deprecated and slated for "
+ "removal in Python 3.4; use SourceLoader instead. "
+ "If Python 3.1 compatibility is required, see the "
+ "latest documentation for PyLoader.",
+ PendingDeprecationWarning)
+ source_timestamp = self.source_mtime(fullname)
+ # Try to use bytecode if it is available.
+ bytecode_path = self.bytecode_path(fullname)
+ if bytecode_path:
+ data = self.get_data(bytecode_path)
+ try:
+ magic = data[:4]
+ if len(magic) < 4:
+ raise ImportError("bad magic number in {}".format(fullname))
+ raw_timestamp = data[4:8]
+ if len(raw_timestamp) < 4:
+ raise EOFError("bad timestamp in {}".format(fullname))
+ pyc_timestamp = marshal._r_long(raw_timestamp)
+ bytecode = data[8:]
+ # Verify that the magic number is valid.
+ if imp.get_magic() != magic:
+ raise ImportError("bad magic number in {}".format(fullname))
+ # Verify that the bytecode is not stale (only matters when
+ # there is source to fall back on.
+ if source_timestamp:
+ if pyc_timestamp < source_timestamp:
+ raise ImportError("bytecode is stale")
+ except (ImportError, EOFError):
+ # If source is available give it a shot.
+ if source_timestamp is not None:
+ pass
+ else:
+ raise
+ else:
+ # Bytecode seems fine, so try to use it.
+ return marshal.loads(bytecode)
+ elif source_timestamp is None:
+ raise ImportError("no source or bytecode available to create code "
+ "object for {0!r}".format(fullname))
+ # Use the source.
+ source_path = self.source_path(fullname)
+ if source_path is None:
+ message = "a source path must exist to load {0}".format(fullname)
+ raise ImportError(message)
+ source = self.get_data(source_path)
+ code_object = compile(source, source_path, 'exec', dont_inherit=True)
+ # Generate bytecode and write it out.
+ if not sys.dont_write_bytecode:
+ data = bytearray(imp.get_magic())
+ data.extend(marshal._w_long(source_timestamp))
+ data.extend(marshal.dumps(code_object))
+ self.write_bytecode(fullname, data)
+ return code_object
+
+ @abc.abstractmethod
+ def source_mtime(self, fullname):
+ """Abstract method. Accepts a str filename and returns an int
+ modification time for the source of the module."""
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def bytecode_path(self, fullname):
+ """Abstract method. Accepts a str filename and returns the str pathname
+ to the bytecode for the module."""
+ raise NotImplementedError
+
+ @abc.abstractmethod
+ def write_bytecode(self, fullname, bytecode):
+ """Abstract method. Accepts a str filename and bytes object
+ representing the bytecode for the module. Returns a boolean
+ representing whether the bytecode was written or not."""
+ raise NotImplementedError
diff --git a/Lib/importlib/machinery.py b/Lib/importlib/machinery.py
new file mode 100644
index 00000000000..519774440f1
--- /dev/null
+++ b/Lib/importlib/machinery.py
@@ -0,0 +1,5 @@
+"""The machinery of importlib: finders, loaders, hooks, etc."""
+
+from ._bootstrap import BuiltinImporter
+from ._bootstrap import FrozenImporter
+from ._bootstrap import PathFinder
diff --git a/Lib/bsddb/test/__init__.py b/Lib/importlib/test/__init__.py
index e69de29bb2d..e69de29bb2d 100644
--- a/Lib/bsddb/test/__init__.py
+++ b/Lib/importlib/test/__init__.py
diff --git a/Lib/importlib/test/__main__.py b/Lib/importlib/test/__main__.py
new file mode 100644
index 00000000000..decc53d8c5a
--- /dev/null
+++ b/Lib/importlib/test/__main__.py
@@ -0,0 +1,29 @@
+"""Run importlib's test suite.
+
+Specifying the ``--builtin`` flag will run tests, where applicable, with
+builtins.__import__ instead of importlib.__import__.
+
+"""
+import importlib
+from importlib.test.import_ import util
+import os.path
+from test.support import run_unittest
+import sys
+import unittest
+
+
+def test_main():
+ if '__pycache__' in __file__:
+ parts = __file__.split(os.path.sep)
+ start_dir = sep.join(parts[:-2])
+ else:
+ start_dir = os.path.dirname(__file__)
+ top_dir = os.path.dirname(os.path.dirname(start_dir))
+ test_loader = unittest.TestLoader()
+ if '--builtin' in sys.argv:
+ util.using___import__ = True
+ run_unittest(test_loader.discover(start_dir, top_level_dir=top_dir))
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/abc.py b/Lib/importlib/test/abc.py
new file mode 100644
index 00000000000..2c17ac329bc
--- /dev/null
+++ b/Lib/importlib/test/abc.py
@@ -0,0 +1,99 @@
+import abc
+import unittest
+
+
+class FinderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+
+ """Basic tests for a finder to pass."""
+
+ @abc.abstractmethod
+ def test_module(self):
+ # Test importing a top-level module.
+ pass
+
+ @abc.abstractmethod
+ def test_package(self):
+ # Test importing a package.
+ pass
+
+ @abc.abstractmethod
+ def test_module_in_package(self):
+ # Test importing a module contained within a package.
+ # A value for 'path' should be used if for a meta_path finder.
+ pass
+
+ @abc.abstractmethod
+ def test_package_in_package(self):
+ # Test importing a subpackage.
+ # A value for 'path' should be used if for a meta_path finder.
+ pass
+
+ @abc.abstractmethod
+ def test_package_over_module(self):
+ # Test that packages are chosen over modules.
+ pass
+
+ @abc.abstractmethod
+ def test_failure(self):
+ # Test trying to find a module that cannot be handled.
+ pass
+
+
+class LoaderTests(unittest.TestCase, metaclass=abc.ABCMeta):
+
+ @abc.abstractmethod
+ def test_module(self):
+ """A module should load without issue.
+
+ After the loader returns the module should be in sys.modules.
+
+ Attributes to verify:
+
+ * __file__
+ * __loader__
+ * __name__
+ * No __path__
+
+ """
+ pass
+
+ @abc.abstractmethod
+ def test_package(self):
+ """Loading a package should work.
+
+ After the loader returns the module should be in sys.modules.
+
+ Attributes to verify:
+
+ * __name__
+ * __file__
+ * __package__
+ * __path__
+ * __loader__
+
+ """
+ pass
+
+ @abc.abstractmethod
+ def test_lacking_parent(self):
+ """A loader should not be dependent on it's parent package being
+ imported."""
+ pass
+
+ @abc.abstractmethod
+ def test_module_reuse(self):
+ """If a module is already in sys.modules, it should be reused."""
+ pass
+
+ @abc.abstractmethod
+ def test_state_after_failure(self):
+ """If a module is already in sys.modules and a reload fails
+ (e.g. a SyntaxError), the module should be in the state it was before
+ the reload began."""
+ pass
+
+ @abc.abstractmethod
+ def test_unloadable(self):
+ """Test ImportError is raised when the loader is asked to load a module
+ it can't."""
+ pass
diff --git a/Lib/importlib/test/benchmark.py b/Lib/importlib/test/benchmark.py
new file mode 100644
index 00000000000..b5de6c6b010
--- /dev/null
+++ b/Lib/importlib/test/benchmark.py
@@ -0,0 +1,172 @@
+"""Benchmark some basic import use-cases.
+
+The assumption is made that this benchmark is run in a fresh interpreter and
+thus has no external changes made to import-related attributes in sys.
+
+"""
+from . import util
+from .source import util as source_util
+import decimal
+import imp
+import importlib
+import os
+import py_compile
+import sys
+import timeit
+
+
+def bench(name, cleanup=lambda: None, *, seconds=1, repeat=3):
+ """Bench the given statement as many times as necessary until total
+ executions take one second."""
+ stmt = "__import__({!r})".format(name)
+ timer = timeit.Timer(stmt)
+ for x in range(repeat):
+ total_time = 0
+ count = 0
+ while total_time < seconds:
+ try:
+ total_time += timer.timeit(1)
+ finally:
+ cleanup()
+ count += 1
+ else:
+ # One execution too far
+ if total_time > seconds:
+ count -= 1
+ yield count // seconds
+
+def from_cache(seconds, repeat):
+ """sys.modules"""
+ name = '<benchmark import>'
+ module = imp.new_module(name)
+ module.__file__ = '<test>'
+ module.__package__ = ''
+ with util.uncache(name):
+ sys.modules[name] = module
+ for result in bench(name, repeat=repeat, seconds=seconds):
+ yield result
+
+
+def builtin_mod(seconds, repeat):
+ """Built-in module"""
+ name = 'errno'
+ if name in sys.modules:
+ del sys.modules[name]
+ # Relying on built-in importer being implicit.
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+
+
+def source_wo_bytecode(seconds, repeat):
+ """Source w/o bytecode: simple"""
+ sys.dont_write_bytecode = True
+ try:
+ name = '__importlib_test_benchmark__'
+ # Clears out sys.modules and puts an entry at the front of sys.path.
+ with source_util.create_modules(name) as mapping:
+ assert not os.path.exists(imp.cache_from_source(mapping[name]))
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+ finally:
+ sys.dont_write_bytecode = False
+
+
+def decimal_wo_bytecode(seconds, repeat):
+ """Source w/o bytecode: decimal"""
+ name = 'decimal'
+ decimal_bytecode = imp.cache_from_source(decimal.__file__)
+ if os.path.exists(decimal_bytecode):
+ os.unlink(decimal_bytecode)
+ sys.dont_write_bytecode = True
+ try:
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+ finally:
+ sys.dont_write_bytecode = False
+
+
+def source_writing_bytecode(seconds, repeat):
+ """Source writing bytecode: simple"""
+ assert not sys.dont_write_bytecode
+ name = '__importlib_test_benchmark__'
+ with source_util.create_modules(name) as mapping:
+ def cleanup():
+ sys.modules.pop(name)
+ os.unlink(imp.cache_from_source(mapping[name]))
+ for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
+ assert not os.path.exists(imp.cache_from_source(mapping[name]))
+ yield result
+
+
+def decimal_writing_bytecode(seconds, repeat):
+ """Source writing bytecode: decimal"""
+ assert not sys.dont_write_bytecode
+ name = 'decimal'
+ def cleanup():
+ sys.modules.pop(name)
+ os.unlink(imp.cache_from_source(decimal.__file__))
+ for result in bench(name, cleanup, repeat=repeat, seconds=seconds):
+ yield result
+
+
+def source_using_bytecode(seconds, repeat):
+ """Bytecode w/ source: simple"""
+ name = '__importlib_test_benchmark__'
+ with source_util.create_modules(name) as mapping:
+ py_compile.compile(mapping[name])
+ assert os.path.exists(imp.cache_from_source(mapping[name]))
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+
+
+def decimal_using_bytecode(seconds, repeat):
+ """Bytecode w/ source: decimal"""
+ name = 'decimal'
+ py_compile.compile(decimal.__file__)
+ for result in bench(name, lambda: sys.modules.pop(name), repeat=repeat,
+ seconds=seconds):
+ yield result
+
+
+def main(import_):
+ __builtins__.__import__ = import_
+ benchmarks = (from_cache, builtin_mod,
+ source_using_bytecode, source_wo_bytecode,
+ source_writing_bytecode,
+ decimal_using_bytecode, decimal_writing_bytecode,
+ decimal_wo_bytecode,)
+ seconds = 1
+ seconds_plural = 's' if seconds > 1 else ''
+ repeat = 3
+ header = "Measuring imports/second over {} second{}, best out of {}\n"
+ print(header.format(seconds, seconds_plural, repeat))
+ for benchmark in benchmarks:
+ print(benchmark.__doc__, "[", end=' ')
+ sys.stdout.flush()
+ results = []
+ for result in benchmark(seconds=seconds, repeat=repeat):
+ results.append(result)
+ print(result, end=' ')
+ sys.stdout.flush()
+ assert not sys.dont_write_bytecode
+ print("]", "best is", format(max(results), ',d'))
+
+
+if __name__ == '__main__':
+ import optparse
+
+ parser = optparse.OptionParser()
+ parser.add_option('-b', '--builtin', dest='builtin', action='store_true',
+ default=False, help="use the built-in __import__")
+ options, args = parser.parse_args()
+ if args:
+ raise RuntimeError("unrecognized args: {}".format(args))
+ import_ = __import__
+ if not options.builtin:
+ import_ = importlib.__import__
+
+ main(import_)
diff --git a/Lib/importlib/test/builtin/__init__.py b/Lib/importlib/test/builtin/__init__.py
new file mode 100644
index 00000000000..31a3b5f7d46
--- /dev/null
+++ b/Lib/importlib/test/builtin/__init__.py
@@ -0,0 +1,12 @@
+import importlib.test
+import os
+
+
+def test_suite():
+ directory = os.path.dirname(__file__)
+ return importlib.test.test_suite('importlib.test.builtin', directory)
+
+
+if __name__ == '__main__':
+ from test.support import run_unittest
+ run_unittest(test_suite())
diff --git a/Lib/importlib/test/builtin/test_finder.py b/Lib/importlib/test/builtin/test_finder.py
new file mode 100644
index 00000000000..40f690e4aff
--- /dev/null
+++ b/Lib/importlib/test/builtin/test_finder.py
@@ -0,0 +1,55 @@
+from importlib import machinery
+from .. import abc
+from .. import util
+from . import util as builtin_util
+
+import sys
+import unittest
+
+class FinderTests(abc.FinderTests):
+
+ """Test find_module() for built-in modules."""
+
+ def test_module(self):
+ # Common case.
+ with util.uncache(builtin_util.NAME):
+ found = machinery.BuiltinImporter.find_module(builtin_util.NAME)
+ self.assertTrue(found)
+
+ def test_package(self):
+ # Built-in modules cannot be a package.
+ pass
+
+ def test_module_in_package(self):
+ # Built-in modules cannobt be in a package.
+ pass
+
+ def test_package_in_package(self):
+ # Built-in modules cannot be a package.
+ pass
+
+ def test_package_over_module(self):
+ # Built-in modules cannot be a package.
+ pass
+
+ def test_failure(self):
+ assert 'importlib' not in sys.builtin_module_names
+ loader = machinery.BuiltinImporter.find_module('importlib')
+ self.assertTrue(loader is None)
+
+ def test_ignore_path(self):
+ # The value for 'path' should always trigger a failed import.
+ with util.uncache(builtin_util.NAME):
+ loader = machinery.BuiltinImporter.find_module(builtin_util.NAME,
+ ['pkg'])
+ self.assertTrue(loader is None)
+
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FinderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/builtin/test_loader.py b/Lib/importlib/test/builtin/test_loader.py
new file mode 100644
index 00000000000..1a8539b1e80
--- /dev/null
+++ b/Lib/importlib/test/builtin/test_loader.py
@@ -0,0 +1,102 @@
+import importlib
+from importlib import machinery
+from .. import abc
+from .. import util
+from . import util as builtin_util
+
+import sys
+import types
+import unittest
+
+
+class LoaderTests(abc.LoaderTests):
+
+ """Test load_module() for built-in modules."""
+
+ verification = {'__name__': 'errno', '__package__': '',
+ '__loader__': machinery.BuiltinImporter}
+
+ def verify(self, module):
+ """Verify that the module matches against what it should have."""
+ self.assertTrue(isinstance(module, types.ModuleType))
+ for attr, value in self.verification.items():
+ self.assertEqual(getattr(module, attr), value)
+ self.assertTrue(module.__name__ in sys.modules)
+
+ load_module = staticmethod(lambda name:
+ machinery.BuiltinImporter.load_module(name))
+
+ def test_module(self):
+ # Common case.
+ with util.uncache(builtin_util.NAME):
+ module = self.load_module(builtin_util.NAME)
+ self.verify(module)
+
+ def test_package(self):
+ # Built-in modules cannot be a package.
+ pass
+
+ def test_lacking_parent(self):
+ # Built-in modules cannot be a package.
+ pass
+
+ def test_state_after_failure(self):
+ # Not way to force an imoprt failure.
+ pass
+
+ def test_module_reuse(self):
+ # Test that the same module is used in a reload.
+ with util.uncache(builtin_util.NAME):
+ module1 = self.load_module(builtin_util.NAME)
+ module2 = self.load_module(builtin_util.NAME)
+ self.assertTrue(module1 is module2)
+
+ def test_unloadable(self):
+ name = 'dssdsdfff'
+ assert name not in sys.builtin_module_names
+ with self.assertRaises(ImportError):
+ self.load_module(name)
+
+ def test_already_imported(self):
+ # Using the name of a module already imported but not a built-in should
+ # still fail.
+ assert hasattr(importlib, '__file__') # Not a built-in.
+ with self.assertRaises(ImportError):
+ self.load_module('importlib')
+
+
+class InspectLoaderTests(unittest.TestCase):
+
+ """Tests for InspectLoader methods for BuiltinImporter."""
+
+ def test_get_code(self):
+ # There is no code object.
+ result = machinery.BuiltinImporter.get_code(builtin_util.NAME)
+ self.assertTrue(result is None)
+
+ def test_get_source(self):
+ # There is no source.
+ result = machinery.BuiltinImporter.get_source(builtin_util.NAME)
+ self.assertTrue(result is None)
+
+ def test_is_package(self):
+ # Cannot be a package.
+ result = machinery.BuiltinImporter.is_package(builtin_util.NAME)
+ self.assertTrue(not result)
+
+ def test_not_builtin(self):
+ # Modules not built-in should raise ImportError.
+ for meth_name in ('get_code', 'get_source', 'is_package'):
+ method = getattr(machinery.BuiltinImporter, meth_name)
+ with self.assertRaises(ImportError):
+ method(builtin_util.BAD_NAME)
+
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(LoaderTests, InspectLoaderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/builtin/util.py b/Lib/importlib/test/builtin/util.py
new file mode 100644
index 00000000000..5704699ee23
--- /dev/null
+++ b/Lib/importlib/test/builtin/util.py
@@ -0,0 +1,7 @@
+import sys
+
+assert 'errno' in sys.builtin_module_names
+NAME = 'errno'
+
+assert 'importlib' not in sys.builtin_module_names
+BAD_NAME = 'importlib'
diff --git a/Lib/importlib/test/extension/__init__.py b/Lib/importlib/test/extension/__init__.py
new file mode 100644
index 00000000000..2ec584072d0
--- /dev/null
+++ b/Lib/importlib/test/extension/__init__.py
@@ -0,0 +1,13 @@
+import importlib.test
+import os.path
+import unittest
+
+
+def test_suite():
+ directory = os.path.dirname(__file__)
+ return importlib.test.test_suite('importlib.test.extension', directory)
+
+
+if __name__ == '__main__':
+ from test.support import run_unittest
+ run_unittest(test_suite())
diff --git a/Lib/importlib/test/extension/test_case_sensitivity.py b/Lib/importlib/test/extension/test_case_sensitivity.py
new file mode 100644
index 00000000000..e062fb6597d
--- /dev/null
+++ b/Lib/importlib/test/extension/test_case_sensitivity.py
@@ -0,0 +1,42 @@
+import sys
+from test import support
+import unittest
+from importlib import _bootstrap
+from .. import util
+from . import util as ext_util
+
+
+@util.case_insensitive_tests
+class ExtensionModuleCaseSensitivityTest(unittest.TestCase):
+
+ def find_module(self):
+ good_name = ext_util.NAME
+ bad_name = good_name.upper()
+ assert good_name != bad_name
+ finder = _bootstrap._FileFinder(ext_util.PATH,
+ _bootstrap._ExtensionFinderDetails())
+ return finder.find_module(bad_name)
+
+ def test_case_sensitive(self):
+ with support.EnvironmentVarGuard() as env:
+ env.unset('PYTHONCASEOK')
+ loader = self.find_module()
+ self.assertIsNone(loader)
+
+ def test_case_insensitivity(self):
+ with support.EnvironmentVarGuard() as env:
+ env.set('PYTHONCASEOK', '1')
+ loader = self.find_module()
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+
+
+
+def test_main():
+ if ext_util.FILENAME is None:
+ return
+ support.run_unittest(ExtensionModuleCaseSensitivityTest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/extension/test_finder.py b/Lib/importlib/test/extension/test_finder.py
new file mode 100644
index 00000000000..ea97483317c
--- /dev/null
+++ b/Lib/importlib/test/extension/test_finder.py
@@ -0,0 +1,47 @@
+from importlib import _bootstrap
+from .. import abc
+from . import util
+
+import unittest
+
+class FinderTests(abc.FinderTests):
+
+ """Test the finder for extension modules."""
+
+ def find_module(self, fullname):
+ importer = _bootstrap._FileFinder(util.PATH,
+ _bootstrap._ExtensionFinderDetails())
+ return importer.find_module(fullname)
+
+ def test_module(self):
+ self.assertTrue(self.find_module(util.NAME))
+
+ def test_package(self):
+ # Extension modules cannot be an __init__ for a package.
+ pass
+
+ def test_module_in_package(self):
+ # No extension module in a package available for testing.
+ pass
+
+ def test_package_in_package(self):
+ # Extension modules cannot be an __init__ for a package.
+ pass
+
+ def test_package_over_module(self):
+ # Extension modules cannot be an __init__ for a package.
+ pass
+
+ def test_failure(self):
+ self.assertTrue(self.find_module('asdfjkl;') is None)
+
+ # XXX Raise an exception if someone tries to use the 'path' argument?
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FinderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/extension/test_loader.py b/Lib/importlib/test/extension/test_loader.py
new file mode 100644
index 00000000000..4a783db8a5a
--- /dev/null
+++ b/Lib/importlib/test/extension/test_loader.py
@@ -0,0 +1,59 @@
+from importlib import _bootstrap
+from . import util as ext_util
+from .. import abc
+from .. import util
+
+import sys
+import unittest
+
+
+class LoaderTests(abc.LoaderTests):
+
+ """Test load_module() for extension modules."""
+
+ def load_module(self, fullname):
+ loader = _bootstrap._ExtensionFileLoader(ext_util.NAME,
+ ext_util.FILEPATH)
+ return loader.load_module(fullname)
+
+ def test_module(self):
+ with util.uncache(ext_util.NAME):
+ module = self.load_module(ext_util.NAME)
+ for attr, value in [('__name__', ext_util.NAME),
+ ('__file__', ext_util.FILEPATH),
+ ('__package__', '')]:
+ self.assertEqual(getattr(module, attr), value)
+ self.assertTrue(ext_util.NAME in sys.modules)
+ self.assertTrue(isinstance(module.__loader__,
+ _bootstrap._ExtensionFileLoader))
+
+ def test_package(self):
+ # Extensions are not found in packages.
+ pass
+
+ def test_lacking_parent(self):
+ # Extensions are not found in packages.
+ pass
+
+ def test_module_reuse(self):
+ with util.uncache(ext_util.NAME):
+ module1 = self.load_module(ext_util.NAME)
+ module2 = self.load_module(ext_util.NAME)
+ self.assertTrue(module1 is module2)
+
+ def test_state_after_failure(self):
+ # No easy way to trigger a failure after a successful import.
+ pass
+
+ def test_unloadable(self):
+ with self.assertRaises(ImportError):
+ self.load_module('asdfjkl;')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(LoaderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/extension/test_path_hook.py b/Lib/importlib/test/extension/test_path_hook.py
new file mode 100644
index 00000000000..4610420d293
--- /dev/null
+++ b/Lib/importlib/test/extension/test_path_hook.py
@@ -0,0 +1,31 @@
+from importlib import _bootstrap
+from . import util
+
+import collections
+import imp
+import sys
+import unittest
+
+
+class PathHookTests(unittest.TestCase):
+
+ """Test the path hook for extension modules."""
+ # XXX Should it only succeed for pre-existing directories?
+ # XXX Should it only work for directories containing an extension module?
+
+ def hook(self, entry):
+ return _bootstrap._file_path_hook(entry)
+
+ def test_success(self):
+ # Path hook should handle a directory where a known extension module
+ # exists.
+ self.assertTrue(hasattr(self.hook(util.PATH), 'find_module'))
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(PathHookTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/extension/util.py b/Lib/importlib/test/extension/util.py
new file mode 100644
index 00000000000..d1491697483
--- /dev/null
+++ b/Lib/importlib/test/extension/util.py
@@ -0,0 +1,21 @@
+import imp
+import os
+import sys
+
+PATH = None
+EXT = None
+FILENAME = None
+NAME = '_testcapi'
+_file_exts = [x[0] for x in imp.get_suffixes() if x[2] == imp.C_EXTENSION]
+try:
+ for PATH in sys.path:
+ for EXT in _file_exts:
+ FILENAME = NAME + EXT
+ FILEPATH = os.path.join(PATH, FILENAME)
+ if os.path.exists(os.path.join(PATH, FILENAME)):
+ raise StopIteration
+ else:
+ PATH = EXT = FILENAME = FILEPATH = None
+except StopIteration:
+ pass
+del _file_exts
diff --git a/Lib/importlib/test/frozen/__init__.py b/Lib/importlib/test/frozen/__init__.py
new file mode 100644
index 00000000000..2945eeb0bc1
--- /dev/null
+++ b/Lib/importlib/test/frozen/__init__.py
@@ -0,0 +1,13 @@
+import importlib.test
+import os.path
+import unittest
+
+
+def test_suite():
+ directory = os.path.dirname(__file__)
+ return importlib.test.test_suite('importlib.test.frozen', directory)
+
+
+if __name__ == '__main__':
+ from test.support import run_unittest
+ run_unittest(test_suite())
diff --git a/Lib/importlib/test/frozen/test_finder.py b/Lib/importlib/test/frozen/test_finder.py
new file mode 100644
index 00000000000..db88379d125
--- /dev/null
+++ b/Lib/importlib/test/frozen/test_finder.py
@@ -0,0 +1,47 @@
+from ... import machinery
+from .. import abc
+
+import unittest
+
+
+class FinderTests(abc.FinderTests):
+
+ """Test finding frozen modules."""
+
+ def find(self, name, path=None):
+ finder = machinery.FrozenImporter
+ return finder.find_module(name, path)
+
+ def test_module(self):
+ name = '__hello__'
+ loader = self.find(name)
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+ def test_package(self):
+ loader = self.find('__phello__')
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+ def test_module_in_package(self):
+ loader = self.find('__phello__.spam', ['__phello__'])
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+ def test_package_in_package(self):
+ # No frozen package within another package to test with.
+ pass
+
+ def test_package_over_module(self):
+ # No easy way to test.
+ pass
+
+ def test_failure(self):
+ loader = self.find('<not real>')
+ self.assertTrue(loader is None)
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FinderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/frozen/test_loader.py b/Lib/importlib/test/frozen/test_loader.py
new file mode 100644
index 00000000000..b685ef57084
--- /dev/null
+++ b/Lib/importlib/test/frozen/test_loader.py
@@ -0,0 +1,105 @@
+from importlib import machinery
+import imp
+import unittest
+from .. import abc
+from .. import util
+from test.support import captured_stdout
+
+class LoaderTests(abc.LoaderTests):
+
+ def test_module(self):
+ with util.uncache('__hello__'), captured_stdout() as stdout:
+ module = machinery.FrozenImporter.load_module('__hello__')
+ check = {'__name__': '__hello__', '__file__': '<frozen>',
+ '__package__': '', '__loader__': machinery.FrozenImporter}
+ for attr, value in check.items():
+ self.assertEqual(getattr(module, attr), value)
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+
+ def test_package(self):
+ with util.uncache('__phello__'), captured_stdout() as stdout:
+ module = machinery.FrozenImporter.load_module('__phello__')
+ check = {'__name__': '__phello__', '__file__': '<frozen>',
+ '__package__': '__phello__', '__path__': ['__phello__'],
+ '__loader__': machinery.FrozenImporter}
+ for attr, value in check.items():
+ attr_value = getattr(module, attr)
+ self.assertEqual(attr_value, value,
+ "for __phello__.%s, %r != %r" %
+ (attr, attr_value, value))
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+
+ def test_lacking_parent(self):
+ with util.uncache('__phello__', '__phello__.spam'), \
+ captured_stdout() as stdout:
+ module = machinery.FrozenImporter.load_module('__phello__.spam')
+ check = {'__name__': '__phello__.spam', '__file__': '<frozen>',
+ '__package__': '__phello__',
+ '__loader__': machinery.FrozenImporter}
+ for attr, value in check.items():
+ attr_value = getattr(module, attr)
+ self.assertEqual(attr_value, value,
+ "for __phello__.spam.%s, %r != %r" %
+ (attr, attr_value, value))
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+
+ def test_module_reuse(self):
+ with util.uncache('__hello__'), captured_stdout() as stdout:
+ module1 = machinery.FrozenImporter.load_module('__hello__')
+ module2 = machinery.FrozenImporter.load_module('__hello__')
+ self.assertTrue(module1 is module2)
+ self.assertEqual(stdout.getvalue(),
+ 'Hello world!\nHello world!\n')
+
+ def test_state_after_failure(self):
+ # No way to trigger an error in a frozen module.
+ pass
+
+ def test_unloadable(self):
+ assert machinery.FrozenImporter.find_module('_not_real') is None
+ with self.assertRaises(ImportError):
+ machinery.FrozenImporter.load_module('_not_real')
+
+
+class InspectLoaderTests(unittest.TestCase):
+
+ """Tests for the InspectLoader methods for FrozenImporter."""
+
+ def test_get_code(self):
+ # Make sure that the code object is good.
+ name = '__hello__'
+ with captured_stdout() as stdout:
+ code = machinery.FrozenImporter.get_code(name)
+ mod = imp.new_module(name)
+ exec(code, mod.__dict__)
+ self.assertTrue(hasattr(mod, 'initialized'))
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+
+ def test_get_source(self):
+ # Should always return None.
+ result = machinery.FrozenImporter.get_source('__hello__')
+ self.assertTrue(result is None)
+
+ def test_is_package(self):
+ # Should be able to tell what is a package.
+ test_for = (('__hello__', False), ('__phello__', True),
+ ('__phello__.spam', False))
+ for name, is_package in test_for:
+ result = machinery.FrozenImporter.is_package(name)
+ self.assertTrue(bool(result) == is_package)
+
+ def test_failure(self):
+ # Raise ImportError for modules that are not frozen.
+ for meth_name in ('get_code', 'get_source', 'is_package'):
+ method = getattr(machinery.FrozenImporter, meth_name)
+ with self.assertRaises(ImportError):
+ method('importlib')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(LoaderTests, InspectLoaderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/__init__.py b/Lib/importlib/test/import_/__init__.py
new file mode 100644
index 00000000000..fdf7661dc0b
--- /dev/null
+++ b/Lib/importlib/test/import_/__init__.py
@@ -0,0 +1,13 @@
+import importlib.test
+import os.path
+import unittest
+
+
+def test_suite():
+ directory = os.path.dirname(__file__)
+ return importlib.test.test_suite('importlib.test.import_', directory)
+
+
+if __name__ == '__main__':
+ from test.support import run_unittest
+ run_unittest(test_suite())
diff --git a/Lib/importlib/test/import_/test___package__.py b/Lib/importlib/test/import_/test___package__.py
new file mode 100644
index 00000000000..5056ae59cca
--- /dev/null
+++ b/Lib/importlib/test/import_/test___package__.py
@@ -0,0 +1,119 @@
+"""PEP 366 ("Main module explicit relative imports") specifies the
+semantics for the __package__ attribute on modules. This attribute is
+used, when available, to detect which package a module belongs to (instead
+of using the typical __path__/__name__ test).
+
+"""
+import unittest
+from .. import util
+from . import util as import_util
+
+
+class Using__package__(unittest.TestCase):
+
+ """Use of __package__ supercedes the use of __name__/__path__ to calculate
+ what package a module belongs to. The basic algorithm is [__package__]::
+
+ def resolve_name(name, package, level):
+ level -= 1
+ base = package.rsplit('.', level)[0]
+ return '{0}.{1}'.format(base, name)
+
+ But since there is no guarantee that __package__ has been set (or not been
+ set to None [None]), there has to be a way to calculate the attribute's value
+ [__name__]::
+
+ def calc_package(caller_name, has___path__):
+ if has__path__:
+ return caller_name
+ else:
+ return caller_name.rsplit('.', 1)[0]
+
+ Then the normal algorithm for relative name imports can proceed as if
+ __package__ had been set.
+
+ """
+
+ def test_using___package__(self):
+ # [__package__]
+ with util.mock_modules('pkg.__init__', 'pkg.fake') as importer:
+ with util.import_state(meta_path=[importer]):
+ import_util.import_('pkg.fake')
+ module = import_util.import_('',
+ globals={'__package__': 'pkg.fake'},
+ fromlist=['attr'], level=2)
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_using___name__(self, package_as_None=False):
+ # [__name__]
+ globals_ = {'__name__': 'pkg.fake', '__path__': []}
+ if package_as_None:
+ globals_['__package__'] = None
+ with util.mock_modules('pkg.__init__', 'pkg.fake') as importer:
+ with util.import_state(meta_path=[importer]):
+ import_util.import_('pkg.fake')
+ module = import_util.import_('', globals= globals_,
+ fromlist=['attr'], level=2)
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_None_as___package__(self):
+ # [None]
+ self.test_using___name__(package_as_None=True)
+
+ def test_bad__package__(self):
+ globals = {'__package__': '<not real>'}
+ with self.assertRaises(SystemError):
+ import_util.import_('', globals, {}, ['relimport'], 1)
+
+ def test_bunk__package__(self):
+ globals = {'__package__': 42}
+ with self.assertRaises(ValueError):
+ import_util.import_('', globals, {}, ['relimport'], 1)
+
+
+@import_util.importlib_only
+class Setting__package__(unittest.TestCase):
+
+ """Because __package__ is a new feature, it is not always set by a loader.
+ Import will set it as needed to help with the transition to relying on
+ __package__.
+
+ For a top-level module, __package__ is set to None [top-level]. For a
+ package __name__ is used for __package__ [package]. For submodules the
+ value is __name__.rsplit('.', 1)[0] [submodule].
+
+ """
+
+ # [top-level]
+ def test_top_level(self):
+ with util.mock_modules('top_level') as mock:
+ with util.import_state(meta_path=[mock]):
+ del mock['top_level'].__package__
+ module = import_util.import_('top_level')
+ self.assertEqual(module.__package__, '')
+
+ # [package]
+ def test_package(self):
+ with util.mock_modules('pkg.__init__') as mock:
+ with util.import_state(meta_path=[mock]):
+ del mock['pkg'].__package__
+ module = import_util.import_('pkg')
+ self.assertEqual(module.__package__, 'pkg')
+
+ # [submodule]
+ def test_submodule(self):
+ with util.mock_modules('pkg.__init__', 'pkg.mod') as mock:
+ with util.import_state(meta_path=[mock]):
+ del mock['pkg.mod'].__package__
+ pkg = import_util.import_('pkg.mod')
+ module = getattr(pkg, 'mod')
+ self.assertEqual(module.__package__, 'pkg')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(Using__package__, Setting__package__)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_api.py b/Lib/importlib/test/import_/test_api.py
new file mode 100644
index 00000000000..9075d427597
--- /dev/null
+++ b/Lib/importlib/test/import_/test_api.py
@@ -0,0 +1,22 @@
+from . import util
+import unittest
+
+
+class APITest(unittest.TestCase):
+
+ """Test API-specific details for __import__ (e.g. raising the right
+ exception when passing in an int for the module name)."""
+
+ def test_name_requires_rparition(self):
+ # Raise TypeError if a non-string is passed in for the module name.
+ with self.assertRaises(TypeError):
+ util.import_(42)
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(APITest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_caching.py b/Lib/importlib/test/import_/test_caching.py
new file mode 100644
index 00000000000..48dc64311af
--- /dev/null
+++ b/Lib/importlib/test/import_/test_caching.py
@@ -0,0 +1,86 @@
+"""Test that sys.modules is used properly by import."""
+from .. import util
+from . import util as import_util
+import sys
+from types import MethodType
+import unittest
+
+
+class UseCache(unittest.TestCase):
+
+ """When it comes to sys.modules, import prefers it over anything else.
+
+ Once a name has been resolved, sys.modules is checked to see if it contains
+ the module desired. If so, then it is returned [use cache]. If it is not
+ found, then the proper steps are taken to perform the import, but
+ sys.modules is still used to return the imported module (e.g., not what a
+ loader returns) [from cache on return]. This also applies to imports of
+ things contained within a package and thus get assigned as an attribute
+ [from cache to attribute] or pulled in thanks to a fromlist import
+ [from cache for fromlist]. But if sys.modules contains None then
+ ImportError is raised [None in cache].
+
+ """
+ def test_using_cache(self):
+ # [use cache]
+ module_to_use = "some module found!"
+ with util.uncache(module_to_use):
+ sys.modules['some_module'] = module_to_use
+ module = import_util.import_('some_module')
+ self.assertEqual(id(module_to_use), id(module))
+
+ def test_None_in_cache(self):
+ #[None in cache]
+ name = 'using_None'
+ with util.uncache(name):
+ sys.modules[name] = None
+ with self.assertRaises(ImportError):
+ import_util.import_(name)
+
+ def create_mock(self, *names, return_=None):
+ mock = util.mock_modules(*names)
+ original_load = mock.load_module
+ def load_module(self, fullname):
+ original_load(fullname)
+ return return_
+ mock.load_module = MethodType(load_module, mock)
+ return mock
+
+ # __import__ inconsistent between loaders and built-in import when it comes
+ # to when to use the module in sys.modules and when not to.
+ @import_util.importlib_only
+ def test_using_cache_after_loader(self):
+ # [from cache on return]
+ with self.create_mock('module') as mock:
+ with util.import_state(meta_path=[mock]):
+ module = import_util.import_('module')
+ self.assertEqual(id(module), id(sys.modules['module']))
+
+ # See test_using_cache_after_loader() for reasoning.
+ @import_util.importlib_only
+ def test_using_cache_for_assigning_to_attribute(self):
+ # [from cache to attribute]
+ with self.create_mock('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg.module')
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertTrue(id(module.module), id(sys.modules['pkg.module']))
+
+ # See test_using_cache_after_loader() for reasoning.
+ @import_util.importlib_only
+ def test_using_cache_for_fromlist(self):
+ # [from cache for fromlist]
+ with self.create_mock('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg', fromlist=['module'])
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(id(module.module),
+ id(sys.modules['pkg.module']))
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(UseCache)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_fromlist.py b/Lib/importlib/test/import_/test_fromlist.py
new file mode 100644
index 00000000000..7ecde037aee
--- /dev/null
+++ b/Lib/importlib/test/import_/test_fromlist.py
@@ -0,0 +1,123 @@
+"""Test that the semantics relating to the 'fromlist' argument are correct."""
+from .. import util
+from . import util as import_util
+import unittest
+
+class ReturnValue(unittest.TestCase):
+
+ """The use of fromlist influences what import returns.
+
+ If direct ``import ...`` statement is used, the root module or package is
+ returned [import return]. But if fromlist is set, then the specified module
+ is actually returned (whether it is a relative import or not)
+ [from return].
+
+ """
+
+ def test_return_from_import(self):
+ # [import return]
+ with util.mock_modules('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg.module')
+ self.assertEqual(module.__name__, 'pkg')
+
+ def test_return_from_from_import(self):
+ # [from return]
+ with util.mock_modules('pkg.__init__', 'pkg.module')as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg.module', fromlist=['attr'])
+ self.assertEqual(module.__name__, 'pkg.module')
+
+
+class HandlingFromlist(unittest.TestCase):
+
+ """Using fromlist triggers different actions based on what is being asked
+ of it.
+
+ If fromlist specifies an object on a module, nothing special happens
+ [object case]. This is even true if the object does not exist [bad object].
+
+ If a package is being imported, then what is listed in fromlist may be
+ treated as a module to be imported [module]. But once again, even if
+ something in fromlist does not exist as a module, no error is raised
+ [no module]. And this extends to what is contained in __all__ when '*' is
+ imported [using *]. And '*' does not need to be the only name in the
+ fromlist [using * with others].
+
+ """
+
+ def test_object(self):
+ # [object case]
+ with util.mock_modules('module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('module', fromlist=['attr'])
+ self.assertEqual(module.__name__, 'module')
+
+ def test_unexistent_object(self):
+ # [bad object]
+ with util.mock_modules('module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('module', fromlist=['non_existent'])
+ self.assertEqual(module.__name__, 'module')
+ self.assertTrue(not hasattr(module, 'non_existent'))
+
+ def test_module_from_package(self):
+ # [module]
+ with util.mock_modules('pkg.__init__', 'pkg.module') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg', fromlist=['module'])
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(module.module.__name__, 'pkg.module')
+
+ def test_no_module_from_package(self):
+ # [no module]
+ with util.mock_modules('pkg.__init__') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg', fromlist='non_existent')
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(not hasattr(module, 'non_existent'))
+
+ def test_empty_string(self):
+ with util.mock_modules('pkg.__init__', 'pkg.mod') as importer:
+ with util.import_state(meta_path=[importer]):
+ module = import_util.import_('pkg.mod', fromlist=[''])
+ self.assertEqual(module.__name__, 'pkg.mod')
+
+ def basic_star_test(self, fromlist=['*']):
+ # [using *]
+ with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
+ with util.import_state(meta_path=[mock]):
+ mock['pkg'].__all__ = ['module']
+ module = import_util.import_('pkg', fromlist=fromlist)
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(module.module.__name__, 'pkg.module')
+
+ def test_using_star(self):
+ # [using *]
+ self.basic_star_test()
+
+ def test_fromlist_as_tuple(self):
+ self.basic_star_test(('*',))
+
+ def test_star_with_others(self):
+ # [using * with others]
+ context = util.mock_modules('pkg.__init__', 'pkg.module1', 'pkg.module2')
+ with context as mock:
+ with util.import_state(meta_path=[mock]):
+ mock['pkg'].__all__ = ['module1']
+ module = import_util.import_('pkg', fromlist=['module2', '*'])
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'module1'))
+ self.assertTrue(hasattr(module, 'module2'))
+ self.assertEqual(module.module1.__name__, 'pkg.module1')
+ self.assertEqual(module.module2.__name__, 'pkg.module2')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(ReturnValue, HandlingFromlist)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_meta_path.py b/Lib/importlib/test/import_/test_meta_path.py
new file mode 100644
index 00000000000..3b130c9a13c
--- /dev/null
+++ b/Lib/importlib/test/import_/test_meta_path.py
@@ -0,0 +1,97 @@
+from .. import util
+from . import util as import_util
+from types import MethodType
+import unittest
+
+
+class CallingOrder(unittest.TestCase):
+
+ """Calls to the importers on sys.meta_path happen in order that they are
+ specified in the sequence, starting with the first importer
+ [first called], and then continuing on down until one is found that doesn't
+ return None [continuing]."""
+
+
+ def test_first_called(self):
+ # [first called]
+ mod = 'top_level'
+ first = util.mock_modules(mod)
+ second = util.mock_modules(mod)
+ with util.mock_modules(mod) as first, util.mock_modules(mod) as second:
+ first.modules[mod] = 42
+ second.modules[mod] = -13
+ with util.import_state(meta_path=[first, second]):
+ self.assertEqual(import_util.import_(mod), 42)
+
+ def test_continuing(self):
+ # [continuing]
+ mod_name = 'for_real'
+ with util.mock_modules('nonexistent') as first, \
+ util.mock_modules(mod_name) as second:
+ first.find_module = lambda self, fullname, path=None: None
+ second.modules[mod_name] = 42
+ with util.import_state(meta_path=[first, second]):
+ self.assertEqual(import_util.import_(mod_name), 42)
+
+
+class CallSignature(unittest.TestCase):
+
+ """If there is no __path__ entry on the parent module, then 'path' is None
+ [no path]. Otherwise, the value for __path__ is passed in for the 'path'
+ argument [path set]."""
+
+ def log(self, fxn):
+ log = []
+ def wrapper(self, *args, **kwargs):
+ log.append([args, kwargs])
+ return fxn(*args, **kwargs)
+ return log, wrapper
+
+
+ def test_no_path(self):
+ # [no path]
+ mod_name = 'top_level'
+ assert '.' not in mod_name
+ with util.mock_modules(mod_name) as importer:
+ log, wrapped_call = self.log(importer.find_module)
+ importer.find_module = MethodType(wrapped_call, importer)
+ with util.import_state(meta_path=[importer]):
+ import_util.import_(mod_name)
+ assert len(log) == 1
+ args = log[0][0]
+ kwargs = log[0][1]
+ # Assuming all arguments are positional.
+ self.assertEqual(len(args), 2)
+ self.assertEqual(len(kwargs), 0)
+ self.assertEqual(args[0], mod_name)
+ self.assertTrue(args[1] is None)
+
+ def test_with_path(self):
+ # [path set]
+ pkg_name = 'pkg'
+ mod_name = pkg_name + '.module'
+ path = [42]
+ assert '.' in mod_name
+ with util.mock_modules(pkg_name+'.__init__', mod_name) as importer:
+ importer.modules[pkg_name].__path__ = path
+ log, wrapped_call = self.log(importer.find_module)
+ importer.find_module = MethodType(wrapped_call, importer)
+ with util.import_state(meta_path=[importer]):
+ import_util.import_(mod_name)
+ assert len(log) == 2
+ args = log[1][0]
+ kwargs = log[1][1]
+ # Assuming all arguments are positional.
+ self.assertTrue(not kwargs)
+ self.assertEqual(args[0], mod_name)
+ self.assertTrue(args[1] is path)
+
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(CallingOrder, CallSignature)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_packages.py b/Lib/importlib/test/import_/test_packages.py
new file mode 100644
index 00000000000..faadc32172b
--- /dev/null
+++ b/Lib/importlib/test/import_/test_packages.py
@@ -0,0 +1,37 @@
+from .. import util
+from . import util as import_util
+import sys
+import unittest
+import importlib
+
+
+class ParentModuleTests(unittest.TestCase):
+
+ """Importing a submodule should import the parent modules."""
+
+ def test_import_parent(self):
+ with util.mock_modules('pkg.__init__', 'pkg.module') as mock:
+ with util.import_state(meta_path=[mock]):
+ module = import_util.import_('pkg.module')
+ self.assertTrue('pkg' in sys.modules)
+
+ def test_bad_parent(self):
+ with util.mock_modules('pkg.module') as mock:
+ with util.import_state(meta_path=[mock]):
+ with self.assertRaises(ImportError):
+ import_util.import_('pkg.module')
+
+ def test_module_not_package(self):
+ # Try to import a submodule from a non-package should raise ImportError.
+ assert not hasattr(sys, '__path__')
+ with self.assertRaises(ImportError):
+ import_util.import_('sys.no_submodules_here')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(ParentModuleTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_path.py b/Lib/importlib/test/import_/test_path.py
new file mode 100644
index 00000000000..2faa23174b3
--- /dev/null
+++ b/Lib/importlib/test/import_/test_path.py
@@ -0,0 +1,131 @@
+from importlib import _bootstrap
+from importlib import machinery
+from .. import util
+from . import util as import_util
+import imp
+import os
+import sys
+import tempfile
+from test import support
+from types import MethodType
+import unittest
+
+
+class FinderTests(unittest.TestCase):
+
+ """Tests for PathFinder."""
+
+ def test_failure(self):
+ # Test None returned upon not finding a suitable finder.
+ module = '<test module>'
+ with util.import_state():
+ self.assertTrue(machinery.PathFinder.find_module(module) is None)
+
+ def test_sys_path(self):
+ # Test that sys.path is used when 'path' is None.
+ # Implicitly tests that sys.path_importer_cache is used.
+ module = '<test module>'
+ path = '<test path>'
+ importer = util.mock_modules(module)
+ with util.import_state(path_importer_cache={path: importer},
+ path=[path]):
+ loader = machinery.PathFinder.find_module(module)
+ self.assertTrue(loader is importer)
+
+ def test_path(self):
+ # Test that 'path' is used when set.
+ # Implicitly tests that sys.path_importer_cache is used.
+ module = '<test module>'
+ path = '<test path>'
+ importer = util.mock_modules(module)
+ with util.import_state(path_importer_cache={path: importer}):
+ loader = machinery.PathFinder.find_module(module, [path])
+ self.assertTrue(loader is importer)
+
+ def test_path_hooks(self):
+ # Test that sys.path_hooks is used.
+ # Test that sys.path_importer_cache is set.
+ module = '<test module>'
+ path = '<test path>'
+ importer = util.mock_modules(module)
+ hook = import_util.mock_path_hook(path, importer=importer)
+ with util.import_state(path_hooks=[hook]):
+ loader = machinery.PathFinder.find_module(module, [path])
+ self.assertTrue(loader is importer)
+ self.assertTrue(path in sys.path_importer_cache)
+ self.assertTrue(sys.path_importer_cache[path] is importer)
+
+ def test_path_importer_cache_has_None(self):
+ # Test that if sys.path_importer_cache has None that None is returned.
+ clear_cache = {path: None for path in sys.path}
+ with util.import_state(path_importer_cache=clear_cache):
+ for name in ('asynchat', 'sys', '<test module>'):
+ self.assertTrue(machinery.PathFinder.find_module(name) is None)
+
+ def test_path_importer_cache_has_None_continues(self):
+ # Test that having None in sys.path_importer_cache causes the search to
+ # continue.
+ path = '<test path>'
+ module = '<test module>'
+ importer = util.mock_modules(module)
+ with util.import_state(path=['1', '2'],
+ path_importer_cache={'1': None, '2': importer}):
+ loader = machinery.PathFinder.find_module(module)
+ self.assertTrue(loader is importer)
+
+
+
+class DefaultPathFinderTests(unittest.TestCase):
+
+ """Test importlib._bootstrap._DefaultPathFinder."""
+
+ def test_implicit_hooks(self):
+ # Test that the implicit path hooks are used.
+ bad_path = '<path>'
+ module = '<module>'
+ assert not os.path.exists(bad_path)
+ existing_path = tempfile.mkdtemp()
+ try:
+ with util.import_state():
+ nothing = _bootstrap._DefaultPathFinder.find_module(module,
+ path=[existing_path])
+ self.assertTrue(nothing is None)
+ self.assertTrue(existing_path in sys.path_importer_cache)
+ result = isinstance(sys.path_importer_cache[existing_path],
+ imp.NullImporter)
+ self.assertFalse(result)
+ nothing = _bootstrap._DefaultPathFinder.find_module(module,
+ path=[bad_path])
+ self.assertTrue(nothing is None)
+ self.assertTrue(bad_path in sys.path_importer_cache)
+ self.assertTrue(isinstance(sys.path_importer_cache[bad_path],
+ imp.NullImporter))
+ finally:
+ os.rmdir(existing_path)
+
+
+ def test_path_importer_cache_has_None(self):
+ # Test that the default hook is used when sys.path_importer_cache
+ # contains None for a path.
+ module = '<test module>'
+ importer = util.mock_modules(module)
+ path = '<test path>'
+ # XXX Not blackbox.
+ original_hook = _bootstrap._DEFAULT_PATH_HOOK
+ mock_hook = import_util.mock_path_hook(path, importer=importer)
+ _bootstrap._DEFAULT_PATH_HOOK = mock_hook
+ try:
+ with util.import_state(path_importer_cache={path: None}):
+ loader = _bootstrap._DefaultPathFinder.find_module(module,
+ path=[path])
+ self.assertTrue(loader is importer)
+ finally:
+ _bootstrap._DEFAULT_PATH_HOOK = original_hook
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FinderTests, DefaultPathFinderTests)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/test_relative_imports.py b/Lib/importlib/test/import_/test_relative_imports.py
new file mode 100644
index 00000000000..a0f6b2d827d
--- /dev/null
+++ b/Lib/importlib/test/import_/test_relative_imports.py
@@ -0,0 +1,203 @@
+"""Test relative imports (PEP 328)."""
+from .. import util
+from . import util as import_util
+import sys
+import unittest
+
+class RelativeImports(unittest.TestCase):
+
+ """PEP 328 introduced relative imports. This allows for imports to occur
+ from within a package without having to specify the actual package name.
+
+ A simple example is to import another module within the same package
+ [module from module]::
+
+ # From pkg.mod1 with pkg.mod2 being a module.
+ from . import mod2
+
+ This also works for getting an attribute from a module that is specified
+ in a relative fashion [attr from module]::
+
+ # From pkg.mod1.
+ from .mod2 import attr
+
+ But this is in no way restricted to working between modules; it works
+ from [package to module],::
+
+ # From pkg, importing pkg.module which is a module.
+ from . import module
+
+ [module to package],::
+
+ # Pull attr from pkg, called from pkg.module which is a module.
+ from . import attr
+
+ and [package to package]::
+
+ # From pkg.subpkg1 (both pkg.subpkg[1,2] are packages).
+ from .. import subpkg2
+
+ The number of dots used is in no way restricted [deep import]::
+
+ # Import pkg.attr from pkg.pkg1.pkg2.pkg3.pkg4.pkg5.
+ from ...... import attr
+
+ To prevent someone from accessing code that is outside of a package, one
+ cannot reach the location containing the root package itself::
+
+ # From pkg.__init__ [too high from package]
+ from .. import top_level
+
+ # From pkg.module [too high from module]
+ from .. import top_level
+
+ Relative imports are the only type of import that allow for an empty
+ module name for an import [empty name].
+
+ """
+
+ def relative_import_test(self, create, globals_, callback):
+ """Abstract out boilerplace for setting up for an import test."""
+ uncache_names = []
+ for name in create:
+ if not name.endswith('.__init__'):
+ uncache_names.append(name)
+ else:
+ uncache_names.append(name[:-len('.__init__')])
+ with util.mock_modules(*create) as importer:
+ with util.import_state(meta_path=[importer]):
+ for global_ in globals_:
+ with util.uncache(*uncache_names):
+ callback(global_)
+
+
+ def test_module_from_module(self):
+ # [module from module]
+ create = 'pkg.__init__', 'pkg.mod2'
+ globals_ = {'__package__': 'pkg'}, {'__name__': 'pkg.mod1'}
+ def callback(global_):
+ import_util.import_('pkg') # For __import__().
+ module = import_util.import_('', global_, fromlist=['mod2'], level=1)
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'mod2'))
+ self.assertEqual(module.mod2.attr, 'pkg.mod2')
+ self.relative_import_test(create, globals_, callback)
+
+ def test_attr_from_module(self):
+ # [attr from module]
+ create = 'pkg.__init__', 'pkg.mod2'
+ globals_ = {'__package__': 'pkg'}, {'__name__': 'pkg.mod1'}
+ def callback(global_):
+ import_util.import_('pkg') # For __import__().
+ module = import_util.import_('mod2', global_, fromlist=['attr'],
+ level=1)
+ self.assertEqual(module.__name__, 'pkg.mod2')
+ self.assertEqual(module.attr, 'pkg.mod2')
+ self.relative_import_test(create, globals_, callback)
+
+ def test_package_to_module(self):
+ # [package to module]
+ create = 'pkg.__init__', 'pkg.module'
+ globals_ = ({'__package__': 'pkg'},
+ {'__name__': 'pkg', '__path__': ['blah']})
+ def callback(global_):
+ import_util.import_('pkg') # For __import__().
+ module = import_util.import_('', global_, fromlist=['module'],
+ level=1)
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'module'))
+ self.assertEqual(module.module.attr, 'pkg.module')
+ self.relative_import_test(create, globals_, callback)
+
+ def test_module_to_package(self):
+ # [module to package]
+ create = 'pkg.__init__', 'pkg.module'
+ globals_ = {'__package__': 'pkg'}, {'__name__': 'pkg.module'}
+ def callback(global_):
+ import_util.import_('pkg') # For __import__().
+ module = import_util.import_('', global_, fromlist=['attr'], level=1)
+ self.assertEqual(module.__name__, 'pkg')
+ self.relative_import_test(create, globals_, callback)
+
+ def test_package_to_package(self):
+ # [package to package]
+ create = ('pkg.__init__', 'pkg.subpkg1.__init__',
+ 'pkg.subpkg2.__init__')
+ globals_ = ({'__package__': 'pkg.subpkg1'},
+ {'__name__': 'pkg.subpkg1', '__path__': ['blah']})
+ def callback(global_):
+ module = import_util.import_('', global_, fromlist=['subpkg2'],
+ level=2)
+ self.assertEqual(module.__name__, 'pkg')
+ self.assertTrue(hasattr(module, 'subpkg2'))
+ self.assertEqual(module.subpkg2.attr, 'pkg.subpkg2.__init__')
+
+ def test_deep_import(self):
+ # [deep import]
+ create = ['pkg.__init__']
+ for count in range(1,6):
+ create.append('{0}.pkg{1}.__init__'.format(
+ create[-1][:-len('.__init__')], count))
+ globals_ = ({'__package__': 'pkg.pkg1.pkg2.pkg3.pkg4.pkg5'},
+ {'__name__': 'pkg.pkg1.pkg2.pkg3.pkg4.pkg5',
+ '__path__': ['blah']})
+ def callback(global_):
+ import_util.import_(globals_[0]['__package__'])
+ module = import_util.import_('', global_, fromlist=['attr'], level=6)
+ self.assertEqual(module.__name__, 'pkg')
+ self.relative_import_test(create, globals_, callback)
+
+ def test_too_high_from_package(self):
+ # [too high from package]
+ create = ['top_level', 'pkg.__init__']
+ globals_ = ({'__package__': 'pkg'},
+ {'__name__': 'pkg', '__path__': ['blah']})
+ def callback(global_):
+ import_util.import_('pkg')
+ with self.assertRaises(ValueError):
+ import_util.import_('', global_, fromlist=['top_level'],
+ level=2)
+ self.relative_import_test(create, globals_, callback)
+
+ def test_too_high_from_module(self):
+ # [too high from module]
+ create = ['top_level', 'pkg.__init__', 'pkg.module']
+ globals_ = {'__package__': 'pkg'}, {'__name__': 'pkg.module'}
+ def callback(global_):
+ import_util.import_('pkg')
+ with self.assertRaises(ValueError):
+ import_util.import_('', global_, fromlist=['top_level'],
+ level=2)
+ self.relative_import_test(create, globals_, callback)
+
+ def test_empty_name_w_level_0(self):
+ # [empty name]
+ with self.assertRaises(ValueError):
+ import_util.import_('')
+
+ def test_import_from_different_package(self):
+ # Test importing from a different package than the caller.
+ # in pkg.subpkg1.mod
+ # from ..subpkg2 import mod
+ create = ['__runpy_pkg__.__init__',
+ '__runpy_pkg__.__runpy_pkg__.__init__',
+ '__runpy_pkg__.uncle.__init__',
+ '__runpy_pkg__.uncle.cousin.__init__',
+ '__runpy_pkg__.uncle.cousin.nephew']
+ globals_ = {'__package__': '__runpy_pkg__.__runpy_pkg__'}
+ def callback(global_):
+ import_util.import_('__runpy_pkg__.__runpy_pkg__')
+ module = import_util.import_('uncle.cousin', globals_, {},
+ fromlist=['nephew'],
+ level=2)
+ self.assertEqual(module.__name__, '__runpy_pkg__.uncle.cousin')
+ self.relative_import_test(create, globals_, callback)
+
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(RelativeImports)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/import_/util.py b/Lib/importlib/test/import_/util.py
new file mode 100644
index 00000000000..649c5ed27c3
--- /dev/null
+++ b/Lib/importlib/test/import_/util.py
@@ -0,0 +1,29 @@
+import functools
+import importlib
+import importlib._bootstrap
+import unittest
+
+
+using___import__ = False
+
+
+def import_(*args, **kwargs):
+ """Delegate to allow for injecting different implementations of import."""
+ if using___import__:
+ return __import__(*args, **kwargs)
+ else:
+ return importlib.__import__(*args, **kwargs)
+
+
+def importlib_only(fxn):
+ """Decorator to skip a test if using __builtins__.__import__."""
+ return unittest.skipIf(using___import__, "importlib-specific test")(fxn)
+
+
+def mock_path_hook(*entries, importer):
+ """A mock sys.path_hooks entry."""
+ def hook(entry):
+ if entry not in entries:
+ raise ImportError
+ return importer
+ return hook
diff --git a/Lib/importlib/test/regrtest.py b/Lib/importlib/test/regrtest.py
new file mode 100644
index 00000000000..b103ae7d0e9
--- /dev/null
+++ b/Lib/importlib/test/regrtest.py
@@ -0,0 +1,35 @@
+"""Run Python's standard test suite using importlib.__import__.
+
+Tests known to fail because of assumptions that importlib (properly)
+invalidates are automatically skipped if the entire test suite is run.
+Otherwise all command-line options valid for test.regrtest are also valid for
+this script.
+
+XXX FAILING
+ * test_import
+ - test_incorrect_code_name
+ file name differing between __file__ and co_filename (r68360 on trunk)
+ - test_import_by_filename
+ exception for trying to import by file name does not match
+
+"""
+import importlib
+import sys
+from test import regrtest
+
+if __name__ == '__main__':
+ __builtins__.__import__ = importlib.__import__
+
+ exclude = ['--exclude',
+ 'test_frozen', # Does not expect __loader__ attribute
+ 'test_pkg', # Does not expect __loader__ attribute
+ 'test_pydoc', # Does not expect __loader__ attribute
+ ]
+
+ # Switching on --exclude implies running all test but the ones listed, so
+ # only use it when one is not running an explicit test
+ if len(sys.argv) == 1:
+ # No programmatic way to specify tests to exclude
+ sys.argv.extend(exclude)
+
+ regrtest.main(quiet=True, verbose2=True)
diff --git a/Lib/importlib/test/source/__init__.py b/Lib/importlib/test/source/__init__.py
new file mode 100644
index 00000000000..8d7c49dc9c5
--- /dev/null
+++ b/Lib/importlib/test/source/__init__.py
@@ -0,0 +1,13 @@
+import importlib.test
+import os.path
+import unittest
+
+
+def test_suite():
+ directory = os.path.dirname(__file__)
+ return importlib.test.test_suite('importlib.test.source', directory)
+
+
+if __name__ == '__main__':
+ from test.support import run_unittest
+ run_unittest(test_suite())
diff --git a/Lib/importlib/test/source/test_abc_loader.py b/Lib/importlib/test/source/test_abc_loader.py
new file mode 100644
index 00000000000..32459074a07
--- /dev/null
+++ b/Lib/importlib/test/source/test_abc_loader.py
@@ -0,0 +1,876 @@
+import importlib
+from importlib import abc
+
+from .. import abc as testing_abc
+from .. import util
+from . import util as source_util
+
+import imp
+import inspect
+import io
+import marshal
+import os
+import sys
+import types
+import unittest
+import warnings
+
+
+class SourceOnlyLoaderMock(abc.SourceLoader):
+
+ # Globals that should be defined for all modules.
+ source = (b"_ = '::'.join([__name__, __file__, __cached__, __package__, "
+ b"repr(__loader__)])")
+
+ def __init__(self, path):
+ self.path = path
+
+ def get_data(self, path):
+ assert self.path == path
+ return self.source
+
+ def get_filename(self, fullname):
+ return self.path
+
+
+class SourceLoaderMock(SourceOnlyLoaderMock):
+
+ source_mtime = 1
+
+ def __init__(self, path, magic=imp.get_magic()):
+ super().__init__(path)
+ self.bytecode_path = imp.cache_from_source(self.path)
+ data = bytearray(magic)
+ data.extend(marshal._w_long(self.source_mtime))
+ code_object = compile(self.source, self.path, 'exec',
+ dont_inherit=True)
+ data.extend(marshal.dumps(code_object))
+ self.bytecode = bytes(data)
+ self.written = {}
+
+ def get_data(self, path):
+ if path == self.path:
+ return super().get_data(path)
+ elif path == self.bytecode_path:
+ return self.bytecode
+ else:
+ raise IOError
+
+ def path_mtime(self, path):
+ assert path == self.path
+ return self.source_mtime
+
+ def set_data(self, path, data):
+ self.written[path] = bytes(data)
+ return path == self.bytecode_path
+
+
+class PyLoaderMock(abc.PyLoader):
+
+ # Globals that should be defined for all modules.
+ source = (b"_ = '::'.join([__name__, __file__, __package__, "
+ b"repr(__loader__)])")
+
+ def __init__(self, data):
+ """Take a dict of 'module_name: path' pairings.
+
+ Paths should have no file extension, allowing packages to be denoted by
+ ending in '__init__'.
+
+ """
+ self.module_paths = data
+ self.path_to_module = {val:key for key,val in data.items()}
+
+ def get_data(self, path):
+ if path not in self.path_to_module:
+ raise IOError
+ return self.source
+
+ def is_package(self, name):
+ filename = os.path.basename(self.get_filename(name))
+ return os.path.splitext(filename)[0] == '__init__'
+
+ def source_path(self, name):
+ try:
+ return self.module_paths[name]
+ except KeyError:
+ raise ImportError
+
+ def get_filename(self, name):
+ """Silence deprecation warning."""
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ path = super().get_filename(name)
+ assert len(w) == 1
+ assert issubclass(w[0].category, PendingDeprecationWarning)
+ return path
+
+
+class PyLoaderCompatMock(PyLoaderMock):
+
+ """Mock that matches what is suggested to have a loader that is compatible
+ from Python 3.1 onwards."""
+
+ def get_filename(self, fullname):
+ try:
+ return self.module_paths[fullname]
+ except KeyError:
+ raise ImportError
+
+ def source_path(self, fullname):
+ try:
+ return self.get_filename(fullname)
+ except ImportError:
+ return None
+
+
+class PyPycLoaderMock(abc.PyPycLoader, PyLoaderMock):
+
+ default_mtime = 1
+
+ def __init__(self, source, bc={}):
+ """Initialize mock.
+
+ 'bc' is a dict keyed on a module's name. The value is dict with
+ possible keys of 'path', 'mtime', 'magic', and 'bc'. Except for 'path',
+ each of those keys control if any part of created bytecode is to
+ deviate from default values.
+
+ """
+ super().__init__(source)
+ self.module_bytecode = {}
+ self.path_to_bytecode = {}
+ self.bytecode_to_path = {}
+ for name, data in bc.items():
+ self.path_to_bytecode[data['path']] = name
+ self.bytecode_to_path[name] = data['path']
+ magic = data.get('magic', imp.get_magic())
+ mtime = importlib._w_long(data.get('mtime', self.default_mtime))
+ if 'bc' in data:
+ bc = data['bc']
+ else:
+ bc = self.compile_bc(name)
+ self.module_bytecode[name] = magic + mtime + bc
+
+ def compile_bc(self, name):
+ source_path = self.module_paths.get(name, '<test>') or '<test>'
+ code = compile(self.source, source_path, 'exec')
+ return marshal.dumps(code)
+
+ def source_mtime(self, name):
+ if name in self.module_paths:
+ return self.default_mtime
+ elif name in self.module_bytecode:
+ return None
+ else:
+ raise ImportError
+
+ def bytecode_path(self, name):
+ try:
+ return self.bytecode_to_path[name]
+ except KeyError:
+ if name in self.module_paths:
+ return None
+ else:
+ raise ImportError
+
+ def write_bytecode(self, name, bytecode):
+ self.module_bytecode[name] = bytecode
+ return True
+
+ def get_data(self, path):
+ if path in self.path_to_module:
+ return super().get_data(path)
+ elif path in self.path_to_bytecode:
+ name = self.path_to_bytecode[path]
+ return self.module_bytecode[name]
+ else:
+ raise IOError
+
+ def is_package(self, name):
+ try:
+ return super().is_package(name)
+ except TypeError:
+ return '__init__' in self.bytecode_to_path[name]
+
+ def get_code(self, name):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always")
+ code_object = super().get_code(name)
+ assert len(w) == 1
+ assert issubclass(w[0].category, PendingDeprecationWarning)
+ return code_object
+
+class PyLoaderTests(testing_abc.LoaderTests):
+
+ """Tests for importlib.abc.PyLoader."""
+
+ mocker = PyLoaderMock
+
+ def eq_attrs(self, ob, **kwargs):
+ for attr, val in kwargs.items():
+ found = getattr(ob, attr)
+ self.assertEqual(found, val,
+ "{} attribute: {} != {}".format(attr, found, val))
+
+ def test_module(self):
+ name = '<module>'
+ path = os.path.join('', 'path', 'to', 'module')
+ mock = self.mocker({name: path})
+ with util.uncache(name):
+ module = mock.load_module(name)
+ self.assertTrue(name in sys.modules)
+ self.eq_attrs(module, __name__=name, __file__=path, __package__='',
+ __loader__=mock)
+ self.assertTrue(not hasattr(module, '__path__'))
+ return mock, name
+
+ def test_package(self):
+ name = '<pkg>'
+ path = os.path.join('path', 'to', name, '__init__')
+ mock = self.mocker({name: path})
+ with util.uncache(name):
+ module = mock.load_module(name)
+ self.assertTrue(name in sys.modules)
+ self.eq_attrs(module, __name__=name, __file__=path,
+ __path__=[os.path.dirname(path)], __package__=name,
+ __loader__=mock)
+ return mock, name
+
+ def test_lacking_parent(self):
+ name = 'pkg.mod'
+ path = os.path.join('path', 'to', 'pkg', 'mod')
+ mock = self.mocker({name: path})
+ with util.uncache(name):
+ module = mock.load_module(name)
+ self.assertIn(name, sys.modules)
+ self.eq_attrs(module, __name__=name, __file__=path, __package__='pkg',
+ __loader__=mock)
+ self.assertFalse(hasattr(module, '__path__'))
+ return mock, name
+
+ def test_module_reuse(self):
+ name = 'mod'
+ path = os.path.join('path', 'to', 'mod')
+ module = imp.new_module(name)
+ mock = self.mocker({name: path})
+ with util.uncache(name):
+ sys.modules[name] = module
+ loaded_module = mock.load_module(name)
+ self.assertTrue(loaded_module is module)
+ self.assertTrue(sys.modules[name] is module)
+ return mock, name
+
+ def test_state_after_failure(self):
+ name = "mod"
+ module = imp.new_module(name)
+ module.blah = None
+ mock = self.mocker({name: os.path.join('path', 'to', 'mod')})
+ mock.source = b"1/0"
+ with util.uncache(name):
+ sys.modules[name] = module
+ with self.assertRaises(ZeroDivisionError):
+ mock.load_module(name)
+ self.assertTrue(sys.modules[name] is module)
+ self.assertTrue(hasattr(module, 'blah'))
+ return mock
+
+ def test_unloadable(self):
+ name = "mod"
+ mock = self.mocker({name: os.path.join('path', 'to', 'mod')})
+ mock.source = b"1/0"
+ with util.uncache(name):
+ with self.assertRaises(ZeroDivisionError):
+ mock.load_module(name)
+ self.assertTrue(name not in sys.modules)
+ return mock
+
+
+class PyLoaderCompatTests(PyLoaderTests):
+
+ """Test that the suggested code to make a loader that is compatible from
+ Python 3.1 forward works."""
+
+ mocker = PyLoaderCompatMock
+
+
+class PyLoaderInterfaceTests(unittest.TestCase):
+
+ """Tests for importlib.abc.PyLoader to make sure that when source_path()
+ doesn't return a path everything works as expected."""
+
+ def test_no_source_path(self):
+ # No source path should lead to ImportError.
+ name = 'mod'
+ mock = PyLoaderMock({})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_source_path_is_None(self):
+ name = 'mod'
+ mock = PyLoaderMock({name: None})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_get_filename_with_source_path(self):
+ # get_filename() should return what source_path() returns.
+ name = 'mod'
+ path = os.path.join('path', 'to', 'source')
+ mock = PyLoaderMock({name: path})
+ with util.uncache(name):
+ self.assertEqual(mock.get_filename(name), path)
+
+ def test_get_filename_no_source_path(self):
+ # get_filename() should raise ImportError if source_path returns None.
+ name = 'mod'
+ mock = PyLoaderMock({name: None})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.get_filename(name)
+
+
+class PyPycLoaderTests(PyLoaderTests):
+
+ """Tests for importlib.abc.PyPycLoader."""
+
+ mocker = PyPycLoaderMock
+
+ @source_util.writes_bytecode_files
+ def verify_bytecode(self, mock, name):
+ assert name in mock.module_paths
+ self.assertIn(name, mock.module_bytecode)
+ magic = mock.module_bytecode[name][:4]
+ self.assertEqual(magic, imp.get_magic())
+ mtime = importlib._r_long(mock.module_bytecode[name][4:8])
+ self.assertEqual(mtime, 1)
+ bc = mock.module_bytecode[name][8:]
+ self.assertEqual(bc, mock.compile_bc(name))
+
+ def test_module(self):
+ mock, name = super().test_module()
+ self.verify_bytecode(mock, name)
+
+ def test_package(self):
+ mock, name = super().test_package()
+ self.verify_bytecode(mock, name)
+
+ def test_lacking_parent(self):
+ mock, name = super().test_lacking_parent()
+ self.verify_bytecode(mock, name)
+
+ def test_module_reuse(self):
+ mock, name = super().test_module_reuse()
+ self.verify_bytecode(mock, name)
+
+ def test_state_after_failure(self):
+ super().test_state_after_failure()
+
+ def test_unloadable(self):
+ super().test_unloadable()
+
+
+class PyPycLoaderInterfaceTests(unittest.TestCase):
+
+ """Test for the interface of importlib.abc.PyPycLoader."""
+
+ def get_filename_check(self, src_path, bc_path, expect):
+ name = 'mod'
+ mock = PyPycLoaderMock({name: src_path}, {name: {'path': bc_path}})
+ with util.uncache(name):
+ assert mock.source_path(name) == src_path
+ assert mock.bytecode_path(name) == bc_path
+ self.assertEqual(mock.get_filename(name), expect)
+
+ def test_filename_with_source_bc(self):
+ # When source and bytecode paths present, return the source path.
+ self.get_filename_check('source_path', 'bc_path', 'source_path')
+
+ def test_filename_with_source_no_bc(self):
+ # With source but no bc, return source path.
+ self.get_filename_check('source_path', None, 'source_path')
+
+ def test_filename_with_no_source_bc(self):
+ # With not source but bc, return the bc path.
+ self.get_filename_check(None, 'bc_path', 'bc_path')
+
+ def test_filename_with_no_source_or_bc(self):
+ # With no source or bc, raise ImportError.
+ name = 'mod'
+ mock = PyPycLoaderMock({name: None}, {name: {'path': None}})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.get_filename(name)
+
+
+class SkipWritingBytecodeTests(unittest.TestCase):
+
+ """Test that bytecode is properly handled based on
+ sys.dont_write_bytecode."""
+
+ @source_util.writes_bytecode_files
+ def run_test(self, dont_write_bytecode):
+ name = 'mod'
+ mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')})
+ sys.dont_write_bytecode = dont_write_bytecode
+ with util.uncache(name):
+ mock.load_module(name)
+ self.assertTrue((name in mock.module_bytecode) is not
+ dont_write_bytecode)
+
+ def test_no_bytecode_written(self):
+ self.run_test(True)
+
+ def test_bytecode_written(self):
+ self.run_test(False)
+
+
+class RegeneratedBytecodeTests(unittest.TestCase):
+
+ """Test that bytecode is regenerated as expected."""
+
+ @source_util.writes_bytecode_files
+ def test_different_magic(self):
+ # A different magic number should lead to new bytecode.
+ name = 'mod'
+ bad_magic = b'\x00\x00\x00\x00'
+ assert bad_magic != imp.get_magic()
+ mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')},
+ {name: {'path': os.path.join('path', 'to',
+ 'mod.bytecode'),
+ 'magic': bad_magic}})
+ with util.uncache(name):
+ mock.load_module(name)
+ self.assertTrue(name in mock.module_bytecode)
+ magic = mock.module_bytecode[name][:4]
+ self.assertEqual(magic, imp.get_magic())
+
+ @source_util.writes_bytecode_files
+ def test_old_mtime(self):
+ # Bytecode with an older mtime should be regenerated.
+ name = 'mod'
+ old_mtime = PyPycLoaderMock.default_mtime - 1
+ mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')},
+ {name: {'path': 'path/to/mod.bytecode', 'mtime': old_mtime}})
+ with util.uncache(name):
+ mock.load_module(name)
+ self.assertTrue(name in mock.module_bytecode)
+ mtime = importlib._r_long(mock.module_bytecode[name][4:8])
+ self.assertEqual(mtime, PyPycLoaderMock.default_mtime)
+
+
+class BadBytecodeFailureTests(unittest.TestCase):
+
+ """Test import failures when there is no source and parts of the bytecode
+ is bad."""
+
+ def test_bad_magic(self):
+ # A bad magic number should lead to an ImportError.
+ name = 'mod'
+ bad_magic = b'\x00\x00\x00\x00'
+ bc = {name:
+ {'path': os.path.join('path', 'to', 'mod'),
+ 'magic': bad_magic}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_no_bytecode(self):
+ # Missing code object bytecode should lead to an EOFError.
+ name = 'mod'
+ bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b''}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(EOFError):
+ mock.load_module(name)
+
+ def test_bad_bytecode(self):
+ # Malformed code object bytecode should lead to a ValueError.
+ name = 'mod'
+ bc = {name: {'path': os.path.join('path', 'to', 'mod'), 'bc': b'1234'}}
+ mock = PyPycLoaderMock({name: None}, bc)
+ with util.uncache(name), self.assertRaises(ValueError):
+ mock.load_module(name)
+
+
+def raise_ImportError(*args, **kwargs):
+ raise ImportError
+
+class MissingPathsTests(unittest.TestCase):
+
+ """Test what happens when a source or bytecode path does not exist (either
+ from *_path returning None or raising ImportError)."""
+
+ def test_source_path_None(self):
+ # Bytecode should be used when source_path returns None, along with
+ # __file__ being set to the bytecode path.
+ name = 'mod'
+ bytecode_path = 'path/to/mod'
+ mock = PyPycLoaderMock({name: None}, {name: {'path': bytecode_path}})
+ with util.uncache(name):
+ module = mock.load_module(name)
+ self.assertEqual(module.__file__, bytecode_path)
+
+ # Testing for bytecode_path returning None handled by all tests where no
+ # bytecode initially exists.
+
+ def test_all_paths_None(self):
+ # If all *_path methods return None, raise ImportError.
+ name = 'mod'
+ mock = PyPycLoaderMock({name: None})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_source_path_ImportError(self):
+ # An ImportError from source_path should trigger an ImportError.
+ name = 'mod'
+ mock = PyPycLoaderMock({}, {name: {'path': os.path.join('path', 'to',
+ 'mod')}})
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+ def test_bytecode_path_ImportError(self):
+ # An ImportError from bytecode_path should trigger an ImportError.
+ name = 'mod'
+ mock = PyPycLoaderMock({name: os.path.join('path', 'to', 'mod')})
+ bad_meth = types.MethodType(raise_ImportError, mock)
+ mock.bytecode_path = bad_meth
+ with util.uncache(name), self.assertRaises(ImportError):
+ mock.load_module(name)
+
+
+class SourceLoaderTestHarness(unittest.TestCase):
+
+ def setUp(self, *, is_package=True, **kwargs):
+ self.package = 'pkg'
+ if is_package:
+ self.path = os.path.join(self.package, '__init__.py')
+ self.name = self.package
+ else:
+ module_name = 'mod'
+ self.path = os.path.join(self.package, '.'.join(['mod', 'py']))
+ self.name = '.'.join([self.package, module_name])
+ self.cached = imp.cache_from_source(self.path)
+ self.loader = self.loader_mock(self.path, **kwargs)
+
+ def verify_module(self, module):
+ self.assertEqual(module.__name__, self.name)
+ self.assertEqual(module.__file__, self.path)
+ self.assertEqual(module.__cached__, self.cached)
+ self.assertEqual(module.__package__, self.package)
+ self.assertEqual(module.__loader__, self.loader)
+ values = module._.split('::')
+ self.assertEqual(values[0], self.name)
+ self.assertEqual(values[1], self.path)
+ self.assertEqual(values[2], self.cached)
+ self.assertEqual(values[3], self.package)
+ self.assertEqual(values[4], repr(self.loader))
+
+ def verify_code(self, code_object):
+ module = imp.new_module(self.name)
+ module.__file__ = self.path
+ module.__cached__ = self.cached
+ module.__package__ = self.package
+ module.__loader__ = self.loader
+ module.__path__ = []
+ exec(code_object, module.__dict__)
+ self.verify_module(module)
+
+
+class SourceOnlyLoaderTests(SourceLoaderTestHarness):
+
+ """Test importlib.abc.SourceLoader for source-only loading.
+
+ Reload testing is subsumed by the tests for
+ importlib.util.module_for_loader.
+
+ """
+
+ loader_mock = SourceOnlyLoaderMock
+
+ def test_get_source(self):
+ # Verify the source code is returned as a string.
+ # If an IOError is raised by get_data then raise ImportError.
+ expected_source = self.loader.source.decode('utf-8')
+ self.assertEqual(self.loader.get_source(self.name), expected_source)
+ def raise_IOError(path):
+ raise IOError
+ self.loader.get_data = raise_IOError
+ with self.assertRaises(ImportError):
+ self.loader.get_source(self.name)
+
+ def test_is_package(self):
+ # Properly detect when loading a package.
+ self.setUp(is_package=True)
+ self.assertTrue(self.loader.is_package(self.name))
+ self.setUp(is_package=False)
+ self.assertFalse(self.loader.is_package(self.name))
+
+ def test_get_code(self):
+ # Verify the code object is created.
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+ def test_load_module(self):
+ # Loading a module should set __name__, __loader__, __package__,
+ # __path__ (for packages), __file__, and __cached__.
+ # The module should also be put into sys.modules.
+ with util.uncache(self.name):
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertEqual(module.__path__, [os.path.dirname(self.path)])
+ self.assertTrue(self.name in sys.modules)
+
+ def test_package_settings(self):
+ # __package__ needs to be set, while __path__ is set on if the module
+ # is a package.
+ # Testing the values for a package are covered by test_load_module.
+ self.setUp(is_package=False)
+ with util.uncache(self.name):
+ module = self.loader.load_module(self.name)
+ self.verify_module(module)
+ self.assertTrue(not hasattr(module, '__path__'))
+
+ def test_get_source_encoding(self):
+ # Source is considered encoded in UTF-8 by default unless otherwise
+ # specified by an encoding line.
+ source = "_ = 'ü'"
+ self.loader.source = source.encode('utf-8')
+ returned_source = self.loader.get_source(self.name)
+ self.assertEqual(returned_source, source)
+ source = "# coding: latin-1\n_ = ü"
+ self.loader.source = source.encode('latin-1')
+ returned_source = self.loader.get_source(self.name)
+ self.assertEqual(returned_source, source)
+
+
+@unittest.skipIf(sys.dont_write_bytecode, "sys.dont_write_bytecode is true")
+class SourceLoaderBytecodeTests(SourceLoaderTestHarness):
+
+ """Test importlib.abc.SourceLoader's use of bytecode.
+
+ Source-only testing handled by SourceOnlyLoaderTests.
+
+ """
+
+ loader_mock = SourceLoaderMock
+
+ def verify_code(self, code_object, *, bytecode_written=False):
+ super().verify_code(code_object)
+ if bytecode_written:
+ self.assertIn(self.cached, self.loader.written)
+ data = bytearray(imp.get_magic())
+ data.extend(marshal._w_long(self.loader.source_mtime))
+ data.extend(marshal.dumps(code_object))
+ self.assertEqual(self.loader.written[self.cached], bytes(data))
+
+ def test_code_with_everything(self):
+ # When everything should work.
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+ def test_no_bytecode(self):
+ # If no bytecode exists then move on to the source.
+ self.loader.bytecode_path = "<does not exist>"
+ # Sanity check
+ with self.assertRaises(IOError):
+ bytecode_path = imp.cache_from_source(self.path)
+ self.loader.get_data(bytecode_path)
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+
+ def test_code_bad_timestamp(self):
+ # Bytecode is only used when the timestamp matches the source EXACTLY.
+ for source_mtime in (0, 2):
+ assert source_mtime != self.loader.source_mtime
+ original = self.loader.source_mtime
+ self.loader.source_mtime = source_mtime
+ # If bytecode is used then EOFError would be raised by marshal.
+ self.loader.bytecode = self.loader.bytecode[8:]
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+ self.loader.source_mtime = original
+
+ def test_code_bad_magic(self):
+ # Skip over bytecode with a bad magic number.
+ self.setUp(magic=b'0000')
+ # If bytecode is used then EOFError would be raised by marshal.
+ self.loader.bytecode = self.loader.bytecode[8:]
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object, bytecode_written=True)
+
+ def test_dont_write_bytecode(self):
+ # Bytecode is not written if sys.dont_write_bytecode is true.
+ # Can assume it is false already thanks to the skipIf class decorator.
+ try:
+ sys.dont_write_bytecode = True
+ self.loader.bytecode_path = "<does not exist>"
+ code_object = self.loader.get_code(self.name)
+ self.assertNotIn(self.cached, self.loader.written)
+ finally:
+ sys.dont_write_bytecode = False
+
+ def test_no_set_data(self):
+ # If set_data is not defined, one can still read bytecode.
+ self.setUp(magic=b'0000')
+ original_set_data = self.loader.__class__.set_data
+ try:
+ del self.loader.__class__.set_data
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+ finally:
+ self.loader.__class__.set_data = original_set_data
+
+ def test_set_data_raises_exceptions(self):
+ # Raising NotImplementedError or IOError is okay for set_data.
+ def raise_exception(exc):
+ def closure(*args, **kwargs):
+ raise exc
+ return closure
+
+ self.setUp(magic=b'0000')
+ self.loader.set_data = raise_exception(NotImplementedError)
+ code_object = self.loader.get_code(self.name)
+ self.verify_code(code_object)
+
+
+class SourceLoaderGetSourceTests(unittest.TestCase):
+
+ """Tests for importlib.abc.SourceLoader.get_source()."""
+
+ def test_default_encoding(self):
+ # Should have no problems with UTF-8 text.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock('mod.file')
+ source = 'x = "ü"'
+ mock.source = source.encode('utf-8')
+ returned_source = mock.get_source(name)
+ self.assertEqual(returned_source, source)
+
+ def test_decoded_source(self):
+ # Decoding should work.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock("mod.file")
+ source = "# coding: Latin-1\nx='ü'"
+ assert source.encode('latin-1') != source.encode('utf-8')
+ mock.source = source.encode('latin-1')
+ returned_source = mock.get_source(name)
+ self.assertEqual(returned_source, source)
+
+ def test_universal_newlines(self):
+ # PEP 302 says universal newlines should be used.
+ name = 'mod'
+ mock = SourceOnlyLoaderMock('mod.file')
+ source = "x = 42\r\ny = -13\r\n"
+ mock.source = source.encode('utf-8')
+ expect = io.IncrementalNewlineDecoder(None, True).decode(source)
+ self.assertEqual(mock.get_source(name), expect)
+
+class AbstractMethodImplTests(unittest.TestCase):
+
+ """Test the concrete abstractmethod implementations."""
+
+ class Loader(abc.Loader):
+ def load_module(self, fullname):
+ super().load_module(fullname)
+
+ class Finder(abc.Finder):
+ def find_module(self, _):
+ super().find_module(_)
+
+ class ResourceLoader(Loader, abc.ResourceLoader):
+ def get_data(self, _):
+ super().get_data(_)
+
+ class InspectLoader(Loader, abc.InspectLoader):
+ def is_package(self, _):
+ super().is_package(_)
+
+ def get_code(self, _):
+ super().get_code(_)
+
+ def get_source(self, _):
+ super().get_source(_)
+
+ class ExecutionLoader(InspectLoader, abc.ExecutionLoader):
+ def get_filename(self, _):
+ super().get_filename(_)
+
+ class SourceLoader(ResourceLoader, ExecutionLoader, abc.SourceLoader):
+ pass
+
+ class PyLoader(ResourceLoader, InspectLoader, abc.PyLoader):
+ def source_path(self, _):
+ super().source_path(_)
+
+ class PyPycLoader(PyLoader, abc.PyPycLoader):
+ def bytecode_path(self, _):
+ super().bytecode_path(_)
+
+ def source_mtime(self, _):
+ super().source_mtime(_)
+
+ def write_bytecode(self, _, _2):
+ super().write_bytecode(_, _2)
+
+ def raises_NotImplementedError(self, ins, *args):
+ for method_name in args:
+ method = getattr(ins, method_name)
+ arg_count = len(inspect.getfullargspec(method)[0]) - 1
+ args = [''] * arg_count
+ try:
+ method(*args)
+ except NotImplementedError:
+ pass
+ else:
+ msg = "{}.{} did not raise NotImplementedError"
+ self.fail(msg.format(ins.__class__.__name__, method_name))
+
+ def test_Loader(self):
+ self.raises_NotImplementedError(self.Loader(), 'load_module')
+
+ # XXX misplaced; should be somewhere else
+ def test_Finder(self):
+ self.raises_NotImplementedError(self.Finder(), 'find_module')
+
+ def test_ResourceLoader(self):
+ self.raises_NotImplementedError(self.ResourceLoader(), 'load_module',
+ 'get_data')
+
+ def test_InspectLoader(self):
+ self.raises_NotImplementedError(self.InspectLoader(), 'load_module',
+ 'is_package', 'get_code', 'get_source')
+
+ def test_ExecutionLoader(self):
+ self.raises_NotImplementedError(self.ExecutionLoader(), 'load_module',
+ 'is_package', 'get_code', 'get_source',
+ 'get_filename')
+
+ def test_SourceLoader(self):
+ ins = self.SourceLoader()
+ # Required abstractmethods.
+ self.raises_NotImplementedError(ins, 'get_filename', 'get_data')
+ # Optional abstractmethods.
+ self.raises_NotImplementedError(ins,'path_mtime', 'set_data')
+
+ def test_PyLoader(self):
+ self.raises_NotImplementedError(self.PyLoader(), 'source_path',
+ 'get_data', 'is_package')
+
+ def test_PyPycLoader(self):
+ self.raises_NotImplementedError(self.PyPycLoader(), 'source_path',
+ 'source_mtime', 'bytecode_path',
+ 'write_bytecode')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(PyLoaderTests, PyLoaderCompatTests,
+ PyLoaderInterfaceTests,
+ PyPycLoaderTests, PyPycLoaderInterfaceTests,
+ SkipWritingBytecodeTests, RegeneratedBytecodeTests,
+ BadBytecodeFailureTests, MissingPathsTests,
+ SourceOnlyLoaderTests,
+ SourceLoaderBytecodeTests,
+ SourceLoaderGetSourceTests,
+ AbstractMethodImplTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/test_case_sensitivity.py b/Lib/importlib/test/source/test_case_sensitivity.py
new file mode 100644
index 00000000000..73777de4ba4
--- /dev/null
+++ b/Lib/importlib/test/source/test_case_sensitivity.py
@@ -0,0 +1,60 @@
+"""Test case-sensitivity (PEP 235)."""
+from importlib import _bootstrap
+from .. import util
+from . import util as source_util
+import os
+import sys
+from test import support as test_support
+import unittest
+
+
+@util.case_insensitive_tests
+class CaseSensitivityTest(unittest.TestCase):
+
+ """PEP 235 dictates that on case-preserving, case-insensitive file systems
+ that imports are case-sensitive unless the PYTHONCASEOK environment
+ variable is set."""
+
+ name = 'MoDuLe'
+ assert name != name.lower()
+
+ def find(self, path):
+ finder = _bootstrap._FileFinder(path,
+ _bootstrap._SourceFinderDetails(),
+ _bootstrap._SourcelessFinderDetails())
+ return finder.find_module(self.name)
+
+ def sensitivity_test(self):
+ """Look for a module with matching and non-matching sensitivity."""
+ sensitive_pkg = 'sensitive.{0}'.format(self.name)
+ insensitive_pkg = 'insensitive.{0}'.format(self.name.lower())
+ context = source_util.create_modules(insensitive_pkg, sensitive_pkg)
+ with context as mapping:
+ sensitive_path = os.path.join(mapping['.root'], 'sensitive')
+ insensitive_path = os.path.join(mapping['.root'], 'insensitive')
+ return self.find(sensitive_path), self.find(insensitive_path)
+
+ def test_sensitive(self):
+ with test_support.EnvironmentVarGuard() as env:
+ env.unset('PYTHONCASEOK')
+ sensitive, insensitive = self.sensitivity_test()
+ self.assertTrue(hasattr(sensitive, 'load_module'))
+ self.assertIn(self.name, sensitive.get_filename(self.name))
+ self.assertIsNone(insensitive)
+
+ def test_insensitive(self):
+ with test_support.EnvironmentVarGuard() as env:
+ env.set('PYTHONCASEOK', '1')
+ sensitive, insensitive = self.sensitivity_test()
+ self.assertTrue(hasattr(sensitive, 'load_module'))
+ self.assertIn(self.name, sensitive.get_filename(self.name))
+ self.assertTrue(hasattr(insensitive, 'load_module'))
+ self.assertIn(self.name, insensitive.get_filename(self.name))
+
+
+def test_main():
+ test_support.run_unittest(CaseSensitivityTest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/test_file_loader.py b/Lib/importlib/test/source/test_file_loader.py
new file mode 100644
index 00000000000..c7a7d8fbcae
--- /dev/null
+++ b/Lib/importlib/test/source/test_file_loader.py
@@ -0,0 +1,419 @@
+import importlib
+from importlib import _bootstrap
+from .. import abc
+from .. import util
+from . import util as source_util
+
+import errno
+import imp
+import marshal
+import os
+import py_compile
+import shutil
+import stat
+import sys
+import unittest
+
+from test.support import make_legacy_pyc
+
+
+class SimpleTest(unittest.TestCase):
+
+ """Should have no issue importing a source module [basic]. And if there is
+ a syntax error, it should raise a SyntaxError [syntax error].
+
+ """
+
+ # [basic]
+ def test_module(self):
+ with source_util.create_modules('_temp') as mapping:
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ module = loader.load_module('_temp')
+ self.assertTrue('_temp' in sys.modules)
+ check = {'__name__': '_temp', '__file__': mapping['_temp'],
+ '__package__': ''}
+ for attr, value in check.items():
+ self.assertEqual(getattr(module, attr), value)
+
+ def test_package(self):
+ with source_util.create_modules('_pkg.__init__') as mapping:
+ loader = _bootstrap._SourceFileLoader('_pkg',
+ mapping['_pkg.__init__'])
+ module = loader.load_module('_pkg')
+ self.assertTrue('_pkg' in sys.modules)
+ check = {'__name__': '_pkg', '__file__': mapping['_pkg.__init__'],
+ '__path__': [os.path.dirname(mapping['_pkg.__init__'])],
+ '__package__': '_pkg'}
+ for attr, value in check.items():
+ self.assertEqual(getattr(module, attr), value)
+
+
+ def test_lacking_parent(self):
+ with source_util.create_modules('_pkg.__init__', '_pkg.mod')as mapping:
+ loader = _bootstrap._SourceFileLoader('_pkg.mod',
+ mapping['_pkg.mod'])
+ module = loader.load_module('_pkg.mod')
+ self.assertTrue('_pkg.mod' in sys.modules)
+ check = {'__name__': '_pkg.mod', '__file__': mapping['_pkg.mod'],
+ '__package__': '_pkg'}
+ for attr, value in check.items():
+ self.assertEqual(getattr(module, attr), value)
+
+ def fake_mtime(self, fxn):
+ """Fake mtime to always be higher than expected."""
+ return lambda name: fxn(name) + 1
+
+ def test_module_reuse(self):
+ with source_util.create_modules('_temp') as mapping:
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ module = loader.load_module('_temp')
+ module_id = id(module)
+ module_dict_id = id(module.__dict__)
+ with open(mapping['_temp'], 'w') as file:
+ file.write("testing_var = 42\n")
+ # For filesystems where the mtime is only to a second granularity,
+ # everything that has happened above can be too fast;
+ # force an mtime on the source that is guaranteed to be different
+ # than the original mtime.
+ loader.path_mtime = self.fake_mtime(loader.path_mtime)
+ module = loader.load_module('_temp')
+ self.assertTrue('testing_var' in module.__dict__,
+ "'testing_var' not in "
+ "{0}".format(list(module.__dict__.keys())))
+ self.assertEqual(module, sys.modules['_temp'])
+ self.assertEqual(id(module), module_id)
+ self.assertEqual(id(module.__dict__), module_dict_id)
+
+ def test_state_after_failure(self):
+ # A failed reload should leave the original module intact.
+ attributes = ('__file__', '__path__', '__package__')
+ value = '<test>'
+ name = '_temp'
+ with source_util.create_modules(name) as mapping:
+ orig_module = imp.new_module(name)
+ for attr in attributes:
+ setattr(orig_module, attr, value)
+ with open(mapping[name], 'w') as file:
+ file.write('+++ bad syntax +++')
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ with self.assertRaises(SyntaxError):
+ loader.load_module(name)
+ for attr in attributes:
+ self.assertEqual(getattr(orig_module, attr), value)
+
+ # [syntax error]
+ def test_bad_syntax(self):
+ with source_util.create_modules('_temp') as mapping:
+ with open(mapping['_temp'], 'w') as file:
+ file.write('=')
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ with self.assertRaises(SyntaxError):
+ loader.load_module('_temp')
+ self.assertTrue('_temp' not in sys.modules)
+
+ def test_file_from_empty_string_dir(self):
+ # Loading a module found from an empty string entry on sys.path should
+ # not only work, but keep all attributes relative.
+ file_path = '_temp.py'
+ with open(file_path, 'w') as file:
+ file.write("# test file for importlib")
+ try:
+ with util.uncache('_temp'):
+ loader = _bootstrap._SourceFileLoader('_temp', file_path)
+ mod = loader.load_module('_temp')
+ self.assertEqual(file_path, mod.__file__)
+ self.assertEqual(imp.cache_from_source(file_path),
+ mod.__cached__)
+ finally:
+ os.unlink(file_path)
+ pycache = os.path.dirname(imp.cache_from_source(file_path))
+ shutil.rmtree(pycache)
+
+ def test_timestamp_overflow(self):
+ # When a modification timestamp is larger than 2**32, it should be
+ # truncated rather than raise an OverflowError.
+ with source_util.create_modules('_temp') as mapping:
+ source = mapping['_temp']
+ compiled = imp.cache_from_source(source)
+ with open(source, 'w') as f:
+ f.write("x = 5")
+ try:
+ os.utime(source, (2 ** 33 - 5, 2 ** 33 - 5))
+ except OverflowError:
+ self.skipTest("cannot set modification time to large integer")
+ except OSError as e:
+ if e.errno != getattr(errno, 'EOVERFLOW', None):
+ raise
+ self.skipTest("cannot set modification time to large integer ({})".format(e))
+ loader = _bootstrap._SourceFileLoader('_temp', mapping['_temp'])
+ mod = loader.load_module('_temp')
+ # Sanity checks.
+ self.assertEqual(mod.__cached__, compiled)
+ self.assertEqual(mod.x, 5)
+ # The pyc file was created.
+ os.stat(compiled)
+
+
+class BadBytecodeTest(unittest.TestCase):
+
+ def import_(self, file, module_name):
+ loader = self.loader(module_name, file)
+ module = loader.load_module(module_name)
+ self.assertTrue(module_name in sys.modules)
+
+ def manipulate_bytecode(self, name, mapping, manipulator, *,
+ del_source=False):
+ """Manipulate the bytecode of a module by passing it into a callable
+ that returns what to use as the new bytecode."""
+ try:
+ del sys.modules['_temp']
+ except KeyError:
+ pass
+ py_compile.compile(mapping[name])
+ if not del_source:
+ bytecode_path = imp.cache_from_source(mapping[name])
+ else:
+ os.unlink(mapping[name])
+ bytecode_path = make_legacy_pyc(mapping[name])
+ if manipulator:
+ with open(bytecode_path, 'rb') as file:
+ bc = file.read()
+ new_bc = manipulator(bc)
+ with open(bytecode_path, 'wb') as file:
+ if new_bc is not None:
+ file.write(new_bc)
+ return bytecode_path
+
+ def _test_empty_file(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: b'',
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ @source_util.writes_bytecode_files
+ def _test_partial_magic(self, test, *, del_source=False):
+ # When their are less than 4 bytes to a .pyc, regenerate it if
+ # possible, else raise ImportError.
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:3],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_magic_only(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:4],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_partial_timestamp(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:7],
+ del_source=del_source)
+ test('_temp', mapping, bc_path)
+
+ def _test_no_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8],
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bc_path
+ with self.assertRaises(EOFError):
+ self.import_(file_path, '_temp')
+
+ def _test_non_code_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bytecode_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8] + marshal.dumps(b'abcd'),
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bytecode_path
+ with self.assertRaises(ImportError):
+ self.import_(file_path, '_temp')
+
+ def _test_bad_marshal(self, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bytecode_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: bc[:8] + b'<test>',
+ del_source=del_source)
+ file_path = mapping['_temp'] if not del_source else bytecode_path
+ with self.assertRaises(EOFError):
+ self.import_(file_path, '_temp')
+
+ def _test_bad_magic(self, test, *, del_source=False):
+ with source_util.create_modules('_temp') as mapping:
+ bc_path = self.manipulate_bytecode('_temp', mapping,
+ lambda bc: b'\x00\x00\x00\x00' + bc[4:])
+ test('_temp', mapping, bc_path)
+
+
+class SourceLoaderBadBytecodeTest(BadBytecodeTest):
+
+ loader = _bootstrap._SourceFileLoader
+
+ @source_util.writes_bytecode_files
+ def test_empty_file(self):
+ # When a .pyc is empty, regenerate it if possible, else raise
+ # ImportError.
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_empty_file(test)
+
+ def test_partial_magic(self):
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_partial_magic(test)
+
+ @source_util.writes_bytecode_files
+ def test_magic_only(self):
+ # When there is only the magic number, regenerate the .pyc if possible,
+ # else raise EOFError.
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_magic_only(test)
+
+ @source_util.writes_bytecode_files
+ def test_bad_magic(self):
+ # When the magic number is different, the bytecode should be
+ # regenerated.
+ def test(name, mapping, bytecode_path):
+ self.import_(mapping[name], name)
+ with open(bytecode_path, 'rb') as bytecode_file:
+ self.assertEqual(bytecode_file.read(4), imp.get_magic())
+
+ self._test_bad_magic(test)
+
+ @source_util.writes_bytecode_files
+ def test_partial_timestamp(self):
+ # When the timestamp is partial, regenerate the .pyc, else
+ # raise EOFError.
+ def test(name, mapping, bc_path):
+ self.import_(mapping[name], name)
+ with open(bc_path, 'rb') as file:
+ self.assertGreater(len(file.read()), 8)
+
+ self._test_partial_timestamp(test)
+
+ @source_util.writes_bytecode_files
+ def test_no_marshal(self):
+ # When there is only the magic number and timestamp, raise EOFError.
+ self._test_no_marshal()
+
+ @source_util.writes_bytecode_files
+ def test_non_code_marshal(self):
+ self._test_non_code_marshal()
+ # XXX ImportError when sourceless
+
+ # [bad marshal]
+ @source_util.writes_bytecode_files
+ def test_bad_marshal(self):
+ # Bad marshal data should raise a ValueError.
+ self._test_bad_marshal()
+
+ # [bad timestamp]
+ @source_util.writes_bytecode_files
+ def test_old_timestamp(self):
+ # When the timestamp is older than the source, bytecode should be
+ # regenerated.
+ zeros = b'\x00\x00\x00\x00'
+ with source_util.create_modules('_temp') as mapping:
+ py_compile.compile(mapping['_temp'])
+ bytecode_path = imp.cache_from_source(mapping['_temp'])
+ with open(bytecode_path, 'r+b') as bytecode_file:
+ bytecode_file.seek(4)
+ bytecode_file.write(zeros)
+ self.import_(mapping['_temp'], '_temp')
+ source_mtime = os.path.getmtime(mapping['_temp'])
+ source_timestamp = importlib._w_long(source_mtime)
+ with open(bytecode_path, 'rb') as bytecode_file:
+ bytecode_file.seek(4)
+ self.assertEqual(bytecode_file.read(4), source_timestamp)
+
+ # [bytecode read-only]
+ @source_util.writes_bytecode_files
+ def test_read_only_bytecode(self):
+ # When bytecode is read-only but should be rewritten, fail silently.
+ with source_util.create_modules('_temp') as mapping:
+ # Create bytecode that will need to be re-created.
+ py_compile.compile(mapping['_temp'])
+ bytecode_path = imp.cache_from_source(mapping['_temp'])
+ with open(bytecode_path, 'r+b') as bytecode_file:
+ bytecode_file.seek(0)
+ bytecode_file.write(b'\x00\x00\x00\x00')
+ # Make the bytecode read-only.
+ os.chmod(bytecode_path,
+ stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
+ try:
+ # Should not raise IOError!
+ self.import_(mapping['_temp'], '_temp')
+ finally:
+ # Make writable for eventual clean-up.
+ os.chmod(bytecode_path, stat.S_IWUSR)
+
+
+class SourcelessLoaderBadBytecodeTest(BadBytecodeTest):
+
+ loader = _bootstrap._SourcelessFileLoader
+
+ def test_empty_file(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+
+ self._test_empty_file(test, del_source=True)
+
+ def test_partial_magic(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+ self._test_partial_magic(test, del_source=True)
+
+ def test_magic_only(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(EOFError):
+ self.import_(bytecode_path, name)
+
+ self._test_magic_only(test, del_source=True)
+
+ def test_bad_magic(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(ImportError):
+ self.import_(bytecode_path, name)
+
+ self._test_bad_magic(test, del_source=True)
+
+ def test_partial_timestamp(self):
+ def test(name, mapping, bytecode_path):
+ with self.assertRaises(EOFError):
+ self.import_(bytecode_path, name)
+
+ self._test_partial_timestamp(test, del_source=True)
+
+ def test_no_marshal(self):
+ self._test_no_marshal(del_source=True)
+
+ def test_non_code_marshal(self):
+ self._test_non_code_marshal(del_source=True)
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(SimpleTest,
+ SourceLoaderBadBytecodeTest,
+ SourcelessLoaderBadBytecodeTest
+ )
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/test_finder.py b/Lib/importlib/test/source/test_finder.py
new file mode 100644
index 00000000000..7b9088da0ce
--- /dev/null
+++ b/Lib/importlib/test/source/test_finder.py
@@ -0,0 +1,153 @@
+from importlib import _bootstrap
+from .. import abc
+from . import util as source_util
+from test.support import make_legacy_pyc
+import os
+import errno
+import py_compile
+import unittest
+import warnings
+
+
+class FinderTests(abc.FinderTests):
+
+ """For a top-level module, it should just be found directly in the
+ directory being searched. This is true for a directory with source
+ [top-level source], bytecode [top-level bc], or both [top-level both].
+ There is also the possibility that it is a package [top-level package], in
+ which case there will be a directory with the module name and an
+ __init__.py file. If there is a directory without an __init__.py an
+ ImportWarning is returned [empty dir].
+
+ For sub-modules and sub-packages, the same happens as above but only use
+ the tail end of the name [sub module] [sub package] [sub empty].
+
+ When there is a conflict between a package and module having the same name
+ in the same directory, the package wins out [package over module]. This is
+ so that imports of modules within the package can occur rather than trigger
+ an import error.
+
+ When there is a package and module with the same name, always pick the
+ package over the module [package over module]. This is so that imports from
+ the package have the possibility of succeeding.
+
+ """
+
+ def import_(self, root, module):
+ finder = _bootstrap._FileFinder(root,
+ _bootstrap._SourceFinderDetails(),
+ _bootstrap._SourcelessFinderDetails())
+ return finder.find_module(module)
+
+ def run_test(self, test, create=None, *, compile_=None, unlink=None):
+ """Test the finding of 'test' with the creation of modules listed in
+ 'create'.
+
+ Any names listed in 'compile_' are byte-compiled. Modules
+ listed in 'unlink' have their source files deleted.
+
+ """
+ if create is None:
+ create = {test}
+ with source_util.create_modules(*create) as mapping:
+ if compile_:
+ for name in compile_:
+ py_compile.compile(mapping[name])
+ if unlink:
+ for name in unlink:
+ os.unlink(mapping[name])
+ try:
+ make_legacy_pyc(mapping[name])
+ except OSError as error:
+ # Some tests do not set compile_=True so the source
+ # module will not get compiled and there will be no
+ # PEP 3147 pyc file to rename.
+ if error.errno != errno.ENOENT:
+ raise
+ loader = self.import_(mapping['.root'], test)
+ self.assertTrue(hasattr(loader, 'load_module'))
+ return loader
+
+ def test_module(self):
+ # [top-level source]
+ self.run_test('top_level')
+ # [top-level bc]
+ self.run_test('top_level', compile_={'top_level'},
+ unlink={'top_level'})
+ # [top-level both]
+ self.run_test('top_level', compile_={'top_level'})
+
+ # [top-level package]
+ def test_package(self):
+ # Source.
+ self.run_test('pkg', {'pkg.__init__'})
+ # Bytecode.
+ self.run_test('pkg', {'pkg.__init__'}, compile_={'pkg.__init__'},
+ unlink={'pkg.__init__'})
+ # Both.
+ self.run_test('pkg', {'pkg.__init__'}, compile_={'pkg.__init__'})
+
+ # [sub module]
+ def test_module_in_package(self):
+ with source_util.create_modules('pkg.__init__', 'pkg.sub') as mapping:
+ pkg_dir = os.path.dirname(mapping['pkg.__init__'])
+ loader = self.import_(pkg_dir, 'pkg.sub')
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+ # [sub package]
+ def test_package_in_package(self):
+ context = source_util.create_modules('pkg.__init__', 'pkg.sub.__init__')
+ with context as mapping:
+ pkg_dir = os.path.dirname(mapping['pkg.__init__'])
+ loader = self.import_(pkg_dir, 'pkg.sub')
+ self.assertTrue(hasattr(loader, 'load_module'))
+
+ # [sub empty]
+ def test_empty_sub_directory(self):
+ context = source_util.create_modules('pkg.__init__', 'pkg.sub.__init__')
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", ImportWarning)
+ with context as mapping:
+ os.unlink(mapping['pkg.sub.__init__'])
+ pkg_dir = os.path.dirname(mapping['pkg.__init__'])
+ with self.assertRaises(ImportWarning):
+ self.import_(pkg_dir, 'pkg.sub')
+
+ # [package over modules]
+ def test_package_over_module(self):
+ name = '_temp'
+ loader = self.run_test(name, {'{0}.__init__'.format(name), name})
+ self.assertTrue('__init__' in loader.get_filename(name))
+
+
+ def test_failure(self):
+ with source_util.create_modules('blah') as mapping:
+ nothing = self.import_(mapping['.root'], 'sdfsadsadf')
+ self.assertTrue(nothing is None)
+
+ # [empty dir]
+ def test_empty_dir(self):
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", ImportWarning)
+ with self.assertRaises(ImportWarning):
+ self.run_test('pkg', {'pkg.__init__'}, unlink={'pkg.__init__'})
+
+ def test_empty_string_for_dir(self):
+ # The empty string from sys.path means to search in the cwd.
+ finder = _bootstrap._FileFinder('', _bootstrap._SourceFinderDetails())
+ with open('mod.py', 'w') as file:
+ file.write("# test file for importlib")
+ try:
+ loader = finder.find_module('mod')
+ self.assertTrue(hasattr(loader, 'load_module'))
+ finally:
+ os.unlink('mod.py')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FinderTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/test_path_hook.py b/Lib/importlib/test/source/test_path_hook.py
new file mode 100644
index 00000000000..374f7b6ad3e
--- /dev/null
+++ b/Lib/importlib/test/source/test_path_hook.py
@@ -0,0 +1,26 @@
+from importlib import _bootstrap
+from . import util as source_util
+import unittest
+
+
+class PathHookTest(unittest.TestCase):
+
+ """Test the path hook for source."""
+
+ def test_success(self):
+ with source_util.create_modules('dummy') as mapping:
+ self.assertTrue(hasattr(_bootstrap._file_path_hook(mapping['.root']),
+ 'find_module'))
+
+ def test_empty_string(self):
+ # The empty string represents the cwd.
+ self.assertTrue(hasattr(_bootstrap._file_path_hook(''), 'find_module'))
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(PathHookTest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/test_source_encoding.py b/Lib/importlib/test/source/test_source_encoding.py
new file mode 100644
index 00000000000..794a3df2463
--- /dev/null
+++ b/Lib/importlib/test/source/test_source_encoding.py
@@ -0,0 +1,123 @@
+from importlib import _bootstrap
+from . import util as source_util
+
+import codecs
+import re
+import sys
+# Because sys.path gets essentially blanked, need to have unicodedata already
+# imported for the parser to use.
+import unicodedata
+import unittest
+
+
+CODING_RE = re.compile(r'coding[:=]\s*([-\w.]+)')
+
+
+class EncodingTest(unittest.TestCase):
+
+ """PEP 3120 makes UTF-8 the default encoding for source code
+ [default encoding].
+
+ PEP 263 specifies how that can change on a per-file basis. Either the first
+ or second line can contain the encoding line [encoding first line]
+ encoding second line]. If the file has the BOM marker it is considered UTF-8
+ implicitly [BOM]. If any encoding is specified it must be UTF-8, else it is
+ an error [BOM and utf-8][BOM conflict].
+
+ """
+
+ variable = '\u00fc'
+ character = '\u00c9'
+ source_line = "{0} = '{1}'\n".format(variable, character)
+ module_name = '_temp'
+
+ def run_test(self, source):
+ with source_util.create_modules(self.module_name) as mapping:
+ with open(mapping[self.module_name], 'wb') as file:
+ file.write(source)
+ loader = _bootstrap._SourceFileLoader(self.module_name,
+ mapping[self.module_name])
+ return loader.load_module(self.module_name)
+
+ def create_source(self, encoding):
+ encoding_line = "# coding={0}".format(encoding)
+ assert CODING_RE.search(encoding_line)
+ source_lines = [encoding_line.encode('utf-8')]
+ source_lines.append(self.source_line.encode(encoding))
+ return b'\n'.join(source_lines)
+
+ def test_non_obvious_encoding(self):
+ # Make sure that an encoding that has never been a standard one for
+ # Python works.
+ encoding_line = "# coding=koi8-r"
+ assert CODING_RE.search(encoding_line)
+ source = "{0}\na=42\n".format(encoding_line).encode("koi8-r")
+ self.run_test(source)
+
+ # [default encoding]
+ def test_default_encoding(self):
+ self.run_test(self.source_line.encode('utf-8'))
+
+ # [encoding first line]
+ def test_encoding_on_first_line(self):
+ encoding = 'Latin-1'
+ source = self.create_source(encoding)
+ self.run_test(source)
+
+ # [encoding second line]
+ def test_encoding_on_second_line(self):
+ source = b"#/usr/bin/python\n" + self.create_source('Latin-1')
+ self.run_test(source)
+
+ # [BOM]
+ def test_bom(self):
+ self.run_test(codecs.BOM_UTF8 + self.source_line.encode('utf-8'))
+
+ # [BOM and utf-8]
+ def test_bom_and_utf_8(self):
+ source = codecs.BOM_UTF8 + self.create_source('utf-8')
+ self.run_test(source)
+
+ # [BOM conflict]
+ def test_bom_conflict(self):
+ source = codecs.BOM_UTF8 + self.create_source('latin-1')
+ with self.assertRaises(SyntaxError):
+ self.run_test(source)
+
+
+class LineEndingTest(unittest.TestCase):
+
+ r"""Source written with the three types of line endings (\n, \r\n, \r)
+ need to be readable [cr][crlf][lf]."""
+
+ def run_test(self, line_ending):
+ module_name = '_temp'
+ source_lines = [b"a = 42", b"b = -13", b'']
+ source = line_ending.join(source_lines)
+ with source_util.create_modules(module_name) as mapping:
+ with open(mapping[module_name], 'wb') as file:
+ file.write(source)
+ loader = _bootstrap._SourceFileLoader(module_name,
+ mapping[module_name])
+ return loader.load_module(module_name)
+
+ # [cr]
+ def test_cr(self):
+ self.run_test(b'\r')
+
+ # [crlf]
+ def test_crlf(self):
+ self.run_test(b'\r\n')
+
+ # [lf]
+ def test_lf(self):
+ self.run_test(b'\n')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(EncodingTest, LineEndingTest)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/source/util.py b/Lib/importlib/test/source/util.py
new file mode 100644
index 00000000000..ae65663a670
--- /dev/null
+++ b/Lib/importlib/test/source/util.py
@@ -0,0 +1,97 @@
+from .. import util
+import contextlib
+import errno
+import functools
+import imp
+import os
+import os.path
+import sys
+import tempfile
+from test import support
+
+
+def writes_bytecode_files(fxn):
+ """Decorator to protect sys.dont_write_bytecode from mutation and to skip
+ tests that require it to be set to False."""
+ if sys.dont_write_bytecode:
+ return lambda *args, **kwargs: None
+ @functools.wraps(fxn)
+ def wrapper(*args, **kwargs):
+ original = sys.dont_write_bytecode
+ sys.dont_write_bytecode = False
+ try:
+ to_return = fxn(*args, **kwargs)
+ finally:
+ sys.dont_write_bytecode = original
+ return to_return
+ return wrapper
+
+
+def ensure_bytecode_path(bytecode_path):
+ """Ensure that the __pycache__ directory for PEP 3147 pyc file exists.
+
+ :param bytecode_path: File system path to PEP 3147 pyc file.
+ """
+ try:
+ os.mkdir(os.path.dirname(bytecode_path))
+ except OSError as error:
+ if error.errno != errno.EEXIST:
+ raise
+
+
+@contextlib.contextmanager
+def create_modules(*names):
+ """Temporarily create each named module with an attribute (named 'attr')
+ that contains the name passed into the context manager that caused the
+ creation of the module.
+
+ All files are created in a temporary directory returned by
+ tempfile.mkdtemp(). This directory is inserted at the beginning of
+ sys.path. When the context manager exits all created files (source and
+ bytecode) are explicitly deleted.
+
+ No magic is performed when creating packages! This means that if you create
+ a module within a package you must also create the package's __init__ as
+ well.
+
+ """
+ source = 'attr = {0!r}'
+ created_paths = []
+ mapping = {}
+ state_manager = None
+ uncache_manager = None
+ try:
+ temp_dir = tempfile.mkdtemp()
+ mapping['.root'] = temp_dir
+ import_names = set()
+ for name in names:
+ if not name.endswith('__init__'):
+ import_name = name
+ else:
+ import_name = name[:-len('.__init__')]
+ import_names.add(import_name)
+ if import_name in sys.modules:
+ del sys.modules[import_name]
+ name_parts = name.split('.')
+ file_path = temp_dir
+ for directory in name_parts[:-1]:
+ file_path = os.path.join(file_path, directory)
+ if not os.path.exists(file_path):
+ os.mkdir(file_path)
+ created_paths.append(file_path)
+ file_path = os.path.join(file_path, name_parts[-1] + '.py')
+ with open(file_path, 'w') as file:
+ file.write(source.format(name))
+ created_paths.append(file_path)
+ mapping[name] = file_path
+ uncache_manager = util.uncache(*import_names)
+ uncache_manager.__enter__()
+ state_manager = util.import_state(path=[temp_dir])
+ state_manager.__enter__()
+ yield mapping
+ finally:
+ if state_manager is not None:
+ state_manager.__exit__(None, None, None)
+ if uncache_manager is not None:
+ uncache_manager.__exit__(None, None, None)
+ support.rmtree(temp_dir)
diff --git a/Lib/importlib/test/test_abc.py b/Lib/importlib/test/test_abc.py
new file mode 100644
index 00000000000..0ecbe390ad6
--- /dev/null
+++ b/Lib/importlib/test/test_abc.py
@@ -0,0 +1,89 @@
+from importlib import abc
+from importlib import machinery
+import inspect
+import unittest
+
+
+class InheritanceTests:
+
+ """Test that the specified class is a subclass/superclass of the expected
+ classes."""
+
+ subclasses = []
+ superclasses = []
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ assert self.subclasses or self.superclasses, self.__class__
+ self.__test = getattr(abc, self.__class__.__name__)
+
+ def test_subclasses(self):
+ # Test that the expected subclasses inherit.
+ for subclass in self.subclasses:
+ self.assertTrue(issubclass(subclass, self.__test),
+ "{0} is not a subclass of {1}".format(subclass, self.__test))
+
+ def test_superclasses(self):
+ # Test that the class inherits from the expected superclasses.
+ for superclass in self.superclasses:
+ self.assertTrue(issubclass(self.__test, superclass),
+ "{0} is not a superclass of {1}".format(superclass, self.__test))
+
+
+class Finder(InheritanceTests, unittest.TestCase):
+
+ subclasses = [machinery.BuiltinImporter, machinery.FrozenImporter,
+ machinery.PathFinder]
+
+
+class Loader(InheritanceTests, unittest.TestCase):
+
+ subclasses = [abc.PyLoader]
+
+
+class ResourceLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.Loader]
+
+
+class InspectLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.Loader]
+ subclasses = [abc.PyLoader, machinery.BuiltinImporter,
+ machinery.FrozenImporter]
+
+
+class ExecutionLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.InspectLoader]
+ subclasses = [abc.PyLoader]
+
+
+class SourceLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.ResourceLoader, abc.ExecutionLoader]
+
+
+class PyLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.Loader, abc.ResourceLoader, abc.ExecutionLoader]
+
+
+class PyPycLoader(InheritanceTests, unittest.TestCase):
+
+ superclasses = [abc.PyLoader]
+
+
+def test_main():
+ from test.support import run_unittest
+ classes = []
+ for class_ in globals().values():
+ if (inspect.isclass(class_) and
+ issubclass(class_, unittest.TestCase) and
+ issubclass(class_, InheritanceTests)):
+ classes.append(class_)
+ run_unittest(*classes)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/test_api.py b/Lib/importlib/test/test_api.py
new file mode 100644
index 00000000000..a151626de7d
--- /dev/null
+++ b/Lib/importlib/test/test_api.py
@@ -0,0 +1,93 @@
+from . import util
+import imp
+import importlib
+import sys
+import unittest
+
+
+class ImportModuleTests(unittest.TestCase):
+
+ """Test importlib.import_module."""
+
+ def test_module_import(self):
+ # Test importing a top-level module.
+ with util.mock_modules('top_level') as mock:
+ with util.import_state(meta_path=[mock]):
+ module = importlib.import_module('top_level')
+ self.assertEqual(module.__name__, 'top_level')
+
+ def test_absolute_package_import(self):
+ # Test importing a module from a package with an absolute name.
+ pkg_name = 'pkg'
+ pkg_long_name = '{0}.__init__'.format(pkg_name)
+ name = '{0}.mod'.format(pkg_name)
+ with util.mock_modules(pkg_long_name, name) as mock:
+ with util.import_state(meta_path=[mock]):
+ module = importlib.import_module(name)
+ self.assertEqual(module.__name__, name)
+
+ def test_shallow_relative_package_import(self):
+ # Test importing a module from a package through a relative import.
+ pkg_name = 'pkg'
+ pkg_long_name = '{0}.__init__'.format(pkg_name)
+ module_name = 'mod'
+ absolute_name = '{0}.{1}'.format(pkg_name, module_name)
+ relative_name = '.{0}'.format(module_name)
+ with util.mock_modules(pkg_long_name, absolute_name) as mock:
+ with util.import_state(meta_path=[mock]):
+ importlib.import_module(pkg_name)
+ module = importlib.import_module(relative_name, pkg_name)
+ self.assertEqual(module.__name__, absolute_name)
+
+ def test_deep_relative_package_import(self):
+ modules = ['a.__init__', 'a.b.__init__', 'a.c']
+ with util.mock_modules(*modules) as mock:
+ with util.import_state(meta_path=[mock]):
+ importlib.import_module('a')
+ importlib.import_module('a.b')
+ module = importlib.import_module('..c', 'a.b')
+ self.assertEqual(module.__name__, 'a.c')
+
+ def test_absolute_import_with_package(self):
+ # Test importing a module from a package with an absolute name with
+ # the 'package' argument given.
+ pkg_name = 'pkg'
+ pkg_long_name = '{0}.__init__'.format(pkg_name)
+ name = '{0}.mod'.format(pkg_name)
+ with util.mock_modules(pkg_long_name, name) as mock:
+ with util.import_state(meta_path=[mock]):
+ importlib.import_module(pkg_name)
+ module = importlib.import_module(name, pkg_name)
+ self.assertEqual(module.__name__, name)
+
+ def test_relative_import_wo_package(self):
+ # Relative imports cannot happen without the 'package' argument being
+ # set.
+ with self.assertRaises(TypeError):
+ importlib.import_module('.support')
+
+
+ def test_loaded_once(self):
+ # Issue #13591: Modules should only be loaded once when
+ # initializing the parent package attempts to import the
+ # module currently being imported.
+ b_load_count = 0
+ def load_a():
+ importlib.import_module('a.b')
+ def load_b():
+ nonlocal b_load_count
+ b_load_count += 1
+ code = {'a': load_a, 'a.b': load_b}
+ modules = ['a.__init__', 'a.b']
+ with util.mock_modules(*modules, module_code=code) as mock:
+ with util.import_state(meta_path=[mock]):
+ importlib.import_module('a.b')
+ self.assertEqual(b_load_count, 1)
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(ImportModuleTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/test_util.py b/Lib/importlib/test/test_util.py
new file mode 100644
index 00000000000..602447f09e4
--- /dev/null
+++ b/Lib/importlib/test/test_util.py
@@ -0,0 +1,118 @@
+from importlib import util
+from . import util as test_util
+import imp
+import sys
+import types
+import unittest
+
+
+class ModuleForLoaderTests(unittest.TestCase):
+
+ """Tests for importlib.util.module_for_loader."""
+
+ def return_module(self, name):
+ fxn = util.module_for_loader(lambda self, module: module)
+ return fxn(self, name)
+
+ def raise_exception(self, name):
+ def to_wrap(self, module):
+ raise ImportError
+ fxn = util.module_for_loader(to_wrap)
+ try:
+ fxn(self, name)
+ except ImportError:
+ pass
+
+ def test_new_module(self):
+ # Test that when no module exists in sys.modules a new module is
+ # created.
+ module_name = 'a.b.c'
+ with test_util.uncache(module_name):
+ module = self.return_module(module_name)
+ self.assertTrue(module_name in sys.modules)
+ self.assertTrue(isinstance(module, types.ModuleType))
+ self.assertEqual(module.__name__, module_name)
+
+ def test_reload(self):
+ # Test that a module is reused if already in sys.modules.
+ name = 'a.b.c'
+ module = imp.new_module('a.b.c')
+ with test_util.uncache(name):
+ sys.modules[name] = module
+ returned_module = self.return_module(name)
+ self.assertIs(returned_module, sys.modules[name])
+
+ def test_new_module_failure(self):
+ # Test that a module is removed from sys.modules if added but an
+ # exception is raised.
+ name = 'a.b.c'
+ with test_util.uncache(name):
+ self.raise_exception(name)
+ self.assertTrue(name not in sys.modules)
+
+ def test_reload_failure(self):
+ # Test that a failure on reload leaves the module in-place.
+ name = 'a.b.c'
+ module = imp.new_module(name)
+ with test_util.uncache(name):
+ sys.modules[name] = module
+ self.raise_exception(name)
+ self.assertIs(module, sys.modules[name])
+
+
+class SetPackageTests(unittest.TestCase):
+
+
+ """Tests for importlib.util.set_package."""
+
+ def verify(self, module, expect):
+ """Verify the module has the expected value for __package__ after
+ passing through set_package."""
+ fxn = lambda: module
+ wrapped = util.set_package(fxn)
+ wrapped()
+ self.assertTrue(hasattr(module, '__package__'))
+ self.assertEqual(expect, module.__package__)
+
+ def test_top_level(self):
+ # __package__ should be set to the empty string if a top-level module.
+ # Implicitly tests when package is set to None.
+ module = imp.new_module('module')
+ module.__package__ = None
+ self.verify(module, '')
+
+ def test_package(self):
+ # Test setting __package__ for a package.
+ module = imp.new_module('pkg')
+ module.__path__ = ['<path>']
+ module.__package__ = None
+ self.verify(module, 'pkg')
+
+ def test_submodule(self):
+ # Test __package__ for a module in a package.
+ module = imp.new_module('pkg.mod')
+ module.__package__ = None
+ self.verify(module, 'pkg')
+
+ def test_setting_if_missing(self):
+ # __package__ should be set if it is missing.
+ module = imp.new_module('mod')
+ if hasattr(module, '__package__'):
+ delattr(module, '__package__')
+ self.verify(module, '')
+
+ def test_leaving_alone(self):
+ # If __package__ is set and not None then leave it alone.
+ for value in (True, False):
+ module = imp.new_module('mod')
+ module.__package__ = value
+ self.verify(module, value)
+
+
+def test_main():
+ from test import support
+ support.run_unittest(ModuleForLoaderTests, SetPackageTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/importlib/test/util.py b/Lib/importlib/test/util.py
new file mode 100644
index 00000000000..93b7cd2861b
--- /dev/null
+++ b/Lib/importlib/test/util.py
@@ -0,0 +1,136 @@
+from contextlib import contextmanager
+import imp
+import os.path
+from test import support
+import unittest
+import sys
+
+
+CASE_INSENSITIVE_FS = True
+# Windows is the only OS that is *always* case-insensitive
+# (OS X *can* be case-sensitive).
+if sys.platform not in ('win32', 'cygwin'):
+ changed_name = __file__.upper()
+ if changed_name == __file__:
+ changed_name = __file__.lower()
+ if not os.path.exists(changed_name):
+ CASE_INSENSITIVE_FS = False
+
+
+def case_insensitive_tests(test):
+ """Class decorator that nullifies tests requiring a case-insensitive
+ file system."""
+ return unittest.skipIf(not CASE_INSENSITIVE_FS,
+ "requires a case-insensitive filesystem")(test)
+
+
+@contextmanager
+def uncache(*names):
+ """Uncache a module from sys.modules.
+
+ A basic sanity check is performed to prevent uncaching modules that either
+ cannot/shouldn't be uncached.
+
+ """
+ for name in names:
+ if name in ('sys', 'marshal', 'imp'):
+ raise ValueError(
+ "cannot uncache {0} as it will break _importlib".format(name))
+ try:
+ del sys.modules[name]
+ except KeyError:
+ pass
+ try:
+ yield
+ finally:
+ for name in names:
+ try:
+ del sys.modules[name]
+ except KeyError:
+ pass
+
+@contextmanager
+def import_state(**kwargs):
+ """Context manager to manage the various importers and stored state in the
+ sys module.
+
+ The 'modules' attribute is not supported as the interpreter state stores a
+ pointer to the dict that the interpreter uses internally;
+ reassigning to sys.modules does not have the desired effect.
+
+ """
+ originals = {}
+ try:
+ for attr, default in (('meta_path', []), ('path', []),
+ ('path_hooks', []),
+ ('path_importer_cache', {})):
+ originals[attr] = getattr(sys, attr)
+ if attr in kwargs:
+ new_value = kwargs[attr]
+ del kwargs[attr]
+ else:
+ new_value = default
+ setattr(sys, attr, new_value)
+ if len(kwargs):
+ raise ValueError(
+ 'unrecognized arguments: {0}'.format(kwargs.keys()))
+ yield
+ finally:
+ for attr, value in originals.items():
+ setattr(sys, attr, value)
+
+
+class mock_modules:
+
+ """A mock importer/loader."""
+
+ def __init__(self, *names, module_code={}):
+ self.modules = {}
+ self.module_code = {}
+ for name in names:
+ if not name.endswith('.__init__'):
+ import_name = name
+ else:
+ import_name = name[:-len('.__init__')]
+ if '.' not in name:
+ package = None
+ elif import_name == name:
+ package = name.rsplit('.', 1)[0]
+ else:
+ package = import_name
+ module = imp.new_module(import_name)
+ module.__loader__ = self
+ module.__file__ = '<mock __file__>'
+ module.__package__ = package
+ module.attr = name
+ if import_name != name:
+ module.__path__ = ['<mock __path__>']
+ self.modules[import_name] = module
+ if import_name in module_code:
+ self.module_code[import_name] = module_code[import_name]
+
+ def __getitem__(self, name):
+ return self.modules[name]
+
+ def find_module(self, fullname, path=None):
+ if fullname not in self.modules:
+ return None
+ else:
+ return self
+
+ def load_module(self, fullname):
+ if fullname not in self.modules:
+ raise ImportError
+ else:
+ sys.modules[fullname] = self.modules[fullname]
+ if fullname in self.module_code:
+ self.module_code[fullname]()
+ return self.modules[fullname]
+
+ def __enter__(self):
+ self._uncache = uncache(*self.modules.keys())
+ self._uncache.__enter__()
+ return self
+
+ def __exit__(self, *exc_info):
+ self._uncache.__exit__(None, None, None)
diff --git a/Lib/importlib/util.py b/Lib/importlib/util.py
new file mode 100644
index 00000000000..7b44fa1344c
--- /dev/null
+++ b/Lib/importlib/util.py
@@ -0,0 +1,5 @@
+"""Utility code for constructing importers, etc."""
+
+from ._bootstrap import module_for_loader
+from ._bootstrap import set_loader
+from ._bootstrap import set_package
diff --git a/Lib/imputil.py b/Lib/imputil.py
deleted file mode 100644
index a5fa6ea4f76..00000000000
--- a/Lib/imputil.py
+++ /dev/null
@@ -1,725 +0,0 @@
-"""
-Import utilities
-
-Exported classes:
- ImportManager Manage the import process
-
- Importer Base class for replacing standard import functions
- BuiltinImporter Emulate the import mechanism for builtin and frozen modules
-
- DynLoadSuffixImporter
-"""
-from warnings import warnpy3k
-warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# note: avoid importing non-builtin modules
-import imp ### not available in Jython?
-import sys
-import __builtin__
-
-# for the DirectoryImporter
-import struct
-import marshal
-
-__all__ = ["ImportManager","Importer","BuiltinImporter"]
-
-_StringType = type('')
-_ModuleType = type(sys) ### doesn't work in Jython...
-
-class ImportManager:
- "Manage the import process."
-
- def install(self, namespace=vars(__builtin__)):
- "Install this ImportManager into the specified namespace."
-
- if isinstance(namespace, _ModuleType):
- namespace = vars(namespace)
-
- # Note: we have no notion of "chaining"
-
- # Record the previous import hook, then install our own.
- self.previous_importer = namespace['__import__']
- self.namespace = namespace
- namespace['__import__'] = self._import_hook
-
- ### fix this
- #namespace['reload'] = self._reload_hook
-
- def uninstall(self):
- "Restore the previous import mechanism."
- self.namespace['__import__'] = self.previous_importer
-
- def add_suffix(self, suffix, importFunc):
- assert hasattr(importFunc, '__call__')
- self.fs_imp.add_suffix(suffix, importFunc)
-
- ######################################################################
- #
- # PRIVATE METHODS
- #
-
- clsFilesystemImporter = None
-
- def __init__(self, fs_imp=None):
- # we're definitely going to be importing something in the future,
- # so let's just load the OS-related facilities.
- if not _os_stat:
- _os_bootstrap()
-
- # This is the Importer that we use for grabbing stuff from the
- # filesystem. It defines one more method (import_from_dir) for our use.
- if fs_imp is None:
- cls = self.clsFilesystemImporter or _FilesystemImporter
- fs_imp = cls()
- self.fs_imp = fs_imp
-
- # Initialize the set of suffixes that we recognize and import.
- # The default will import dynamic-load modules first, followed by
- # .py files (or a .py file's cached bytecode)
- for desc in imp.get_suffixes():
- if desc[2] == imp.C_EXTENSION:
- self.add_suffix(desc[0],
- DynLoadSuffixImporter(desc).import_file)
- self.add_suffix('.py', py_suffix_importer)
-
- def _import_hook(self, fqname, globals=None, locals=None, fromlist=None):
- """Python calls this hook to locate and import a module."""
-
- parts = fqname.split('.')
-
- # determine the context of this import
- parent = self._determine_import_context(globals)
-
- # if there is a parent, then its importer should manage this import
- if parent:
- module = parent.__importer__._do_import(parent, parts, fromlist)
- if module:
- return module
-
- # has the top module already been imported?
- try:
- top_module = sys.modules[parts[0]]
- except KeyError:
-
- # look for the topmost module
- top_module = self._import_top_module(parts[0])
- if not top_module:
- # the topmost module wasn't found at all.
- raise ImportError, 'No module named ' + fqname
-
- # fast-path simple imports
- if len(parts) == 1:
- if not fromlist:
- return top_module
-
- if not top_module.__dict__.get('__ispkg__'):
- # __ispkg__ isn't defined (the module was not imported by us),
- # or it is zero.
- #
- # In the former case, there is no way that we could import
- # sub-modules that occur in the fromlist (but we can't raise an
- # error because it may just be names) because we don't know how
- # to deal with packages that were imported by other systems.
- #
- # In the latter case (__ispkg__ == 0), there can't be any sub-
- # modules present, so we can just return.
- #
- # In both cases, since len(parts) == 1, the top_module is also
- # the "bottom" which is the defined return when a fromlist
- # exists.
- return top_module
-
- importer = top_module.__dict__.get('__importer__')
- if importer:
- return importer._finish_import(top_module, parts[1:], fromlist)
-
- # Grrr, some people "import os.path" or do "from os.path import ..."
- if len(parts) == 2 and hasattr(top_module, parts[1]):
- if fromlist:
- return getattr(top_module, parts[1])
- else:
- return top_module
-
- # If the importer does not exist, then we have to bail. A missing
- # importer means that something else imported the module, and we have
- # no knowledge of how to get sub-modules out of the thing.
- raise ImportError, 'No module named ' + fqname
-
- def _determine_import_context(self, globals):
- """Returns the context in which a module should be imported.
-
- The context could be a loaded (package) module and the imported module
- will be looked for within that package. The context could also be None,
- meaning there is no context -- the module should be looked for as a
- "top-level" module.
- """
-
- if not globals or not globals.get('__importer__'):
- # globals does not refer to one of our modules or packages. That
- # implies there is no relative import context (as far as we are
- # concerned), and it should just pick it off the standard path.
- return None
-
- # The globals refer to a module or package of ours. It will define
- # the context of the new import. Get the module/package fqname.
- parent_fqname = globals['__name__']
-
- # if a package is performing the import, then return itself (imports
- # refer to pkg contents)
- if globals['__ispkg__']:
- parent = sys.modules[parent_fqname]
- assert globals is parent.__dict__
- return parent
-
- i = parent_fqname.rfind('.')
-
- # a module outside of a package has no particular import context
- if i == -1:
- return None
-
- # if a module in a package is performing the import, then return the
- # package (imports refer to siblings)
- parent_fqname = parent_fqname[:i]
- parent = sys.modules[parent_fqname]
- assert parent.__name__ == parent_fqname
- return parent
-
- def _import_top_module(self, name):
- # scan sys.path looking for a location in the filesystem that contains
- # the module, or an Importer object that can import the module.
- for item in sys.path:
- if isinstance(item, _StringType):
- module = self.fs_imp.import_from_dir(item, name)
- else:
- module = item.import_top(name)
- if module:
- return module
- return None
-
- def _reload_hook(self, module):
- "Python calls this hook to reload a module."
-
- # reloading of a module may or may not be possible (depending on the
- # importer), but at least we can validate that it's ours to reload
- importer = module.__dict__.get('__importer__')
- if not importer:
- ### oops. now what...
- pass
-
- # okay. it is using the imputil system, and we must delegate it, but
- # we don't know what to do (yet)
- ### we should blast the module dict and do another get_code(). need to
- ### flesh this out and add proper docco...
- raise SystemError, "reload not yet implemented"
-
-
-class Importer:
- "Base class for replacing standard import functions."
-
- def import_top(self, name):
- "Import a top-level module."
- return self._import_one(None, name, name)
-
- ######################################################################
- #
- # PRIVATE METHODS
- #
- def _finish_import(self, top, parts, fromlist):
- # if "a.b.c" was provided, then load the ".b.c" portion down from
- # below the top-level module.
- bottom = self._load_tail(top, parts)
-
- # if the form is "import a.b.c", then return "a"
- if not fromlist:
- # no fromlist: return the top of the import tree
- return top
-
- # the top module was imported by self.
- #
- # this means that the bottom module was also imported by self (just
- # now, or in the past and we fetched it from sys.modules).
- #
- # since we imported/handled the bottom module, this means that we can
- # also handle its fromlist (and reliably use __ispkg__).
-
- # if the bottom node is a package, then (potentially) import some
- # modules.
- #
- # note: if it is not a package, then "fromlist" refers to names in
- # the bottom module rather than modules.
- # note: for a mix of names and modules in the fromlist, we will
- # import all modules and insert those into the namespace of
- # the package module. Python will pick up all fromlist names
- # from the bottom (package) module; some will be modules that
- # we imported and stored in the namespace, others are expected
- # to be present already.
- if bottom.__ispkg__:
- self._import_fromlist(bottom, fromlist)
-
- # if the form is "from a.b import c, d" then return "b"
- return bottom
-
- def _import_one(self, parent, modname, fqname):
- "Import a single module."
-
- # has the module already been imported?
- try:
- return sys.modules[fqname]
- except KeyError:
- pass
-
- # load the module's code, or fetch the module itself
- result = self.get_code(parent, modname, fqname)
- if result is None:
- return None
-
- module = self._process_result(result, fqname)
-
- # insert the module into its parent
- if parent:
- setattr(parent, modname, module)
- return module
-
- def _process_result(self, result, fqname):
- ispkg, code, values = result
- # did get_code() return an actual module? (rather than a code object)
- is_module = isinstance(code, _ModuleType)
-
- # use the returned module, or create a new one to exec code into
- if is_module:
- module = code
- else:
- module = imp.new_module(fqname)
-
- ### record packages a bit differently??
- module.__importer__ = self
- module.__ispkg__ = ispkg
-
- # insert additional values into the module (before executing the code)
- module.__dict__.update(values)
-
- # the module is almost ready... make it visible
- sys.modules[fqname] = module
-
- # execute the code within the module's namespace
- if not is_module:
- try:
- exec code in module.__dict__
- except:
- if fqname in sys.modules:
- del sys.modules[fqname]
- raise
-
- # fetch from sys.modules instead of returning module directly.
- # also make module's __name__ agree with fqname, in case
- # the "exec code in module.__dict__" played games on us.
- module = sys.modules[fqname]
- module.__name__ = fqname
- return module
-
- def _load_tail(self, m, parts):
- """Import the rest of the modules, down from the top-level module.
-
- Returns the last module in the dotted list of modules.
- """
- for part in parts:
- fqname = "%s.%s" % (m.__name__, part)
- m = self._import_one(m, part, fqname)
- if not m:
- raise ImportError, "No module named " + fqname
- return m
-
- def _import_fromlist(self, package, fromlist):
- 'Import any sub-modules in the "from" list.'
-
- # if '*' is present in the fromlist, then look for the '__all__'
- # variable to find additional items (modules) to import.
- if '*' in fromlist:
- fromlist = list(fromlist) + \
- list(package.__dict__.get('__all__', []))
-
- for sub in fromlist:
- # if the name is already present, then don't try to import it (it
- # might not be a module!).
- if sub != '*' and not hasattr(package, sub):
- subname = "%s.%s" % (package.__name__, sub)
- submod = self._import_one(package, sub, subname)
- if not submod:
- raise ImportError, "cannot import name " + subname
-
- def _do_import(self, parent, parts, fromlist):
- """Attempt to import the module relative to parent.
-
- This method is used when the import context specifies that <self>
- imported the parent module.
- """
- top_name = parts[0]
- top_fqname = parent.__name__ + '.' + top_name
- top_module = self._import_one(parent, top_name, top_fqname)
- if not top_module:
- # this importer and parent could not find the module (relatively)
- return None
-
- return self._finish_import(top_module, parts[1:], fromlist)
-
- ######################################################################
- #
- # METHODS TO OVERRIDE
- #
- def get_code(self, parent, modname, fqname):
- """Find and retrieve the code for the given module.
-
- parent specifies a parent module to define a context for importing. It
- may be None, indicating no particular context for the search.
-
- modname specifies a single module (not dotted) within the parent.
-
- fqname specifies the fully-qualified module name. This is a
- (potentially) dotted name from the "root" of the module namespace
- down to the modname.
- If there is no parent, then modname==fqname.
-
- This method should return None, or a 3-tuple.
-
- * If the module was not found, then None should be returned.
-
- * The first item of the 2- or 3-tuple should be the integer 0 or 1,
- specifying whether the module that was found is a package or not.
-
- * The second item is the code object for the module (it will be
- executed within the new module's namespace). This item can also
- be a fully-loaded module object (e.g. loaded from a shared lib).
-
- * The third item is a dictionary of name/value pairs that will be
- inserted into new module before the code object is executed. This
- is provided in case the module's code expects certain values (such
- as where the module was found). When the second item is a module
- object, then these names/values will be inserted *after* the module
- has been loaded/initialized.
- """
- raise RuntimeError, "get_code not implemented"
-
-
-######################################################################
-#
-# Some handy stuff for the Importers
-#
-
-# byte-compiled file suffix character
-_suffix_char = __debug__ and 'c' or 'o'
-
-# byte-compiled file suffix
-_suffix = '.py' + _suffix_char
-
-def _compile(pathname, timestamp):
- """Compile (and cache) a Python source file.
-
- The file specified by <pathname> is compiled to a code object and
- returned.
-
- Presuming the appropriate privileges exist, the bytecodes will be
- saved back to the filesystem for future imports. The source file's
- modification timestamp must be provided as a Long value.
- """
- codestring = open(pathname, 'rU').read()
- if codestring and codestring[-1] != '\n':
- codestring = codestring + '\n'
- code = __builtin__.compile(codestring, pathname, 'exec')
-
- # try to cache the compiled code
- try:
- f = open(pathname + _suffix_char, 'wb')
- except IOError:
- pass
- else:
- f.write('\0\0\0\0')
- f.write(struct.pack('<I', timestamp))
- marshal.dump(code, f)
- f.flush()
- f.seek(0, 0)
- f.write(imp.get_magic())
- f.close()
-
- return code
-
-_os_stat = _os_path_join = None
-def _os_bootstrap():
- "Set up 'os' module replacement functions for use during import bootstrap."
-
- names = sys.builtin_module_names
-
- join = None
- if 'posix' in names:
- sep = '/'
- from posix import stat
- elif 'nt' in names:
- sep = '\\'
- from nt import stat
- elif 'dos' in names:
- sep = '\\'
- from dos import stat
- elif 'os2' in names:
- sep = '\\'
- from os2 import stat
- else:
- raise ImportError, 'no os specific module found'
-
- if join is None:
- def join(a, b, sep=sep):
- if a == '':
- return b
- lastchar = a[-1:]
- if lastchar == '/' or lastchar == sep:
- return a + b
- return a + sep + b
-
- global _os_stat
- _os_stat = stat
-
- global _os_path_join
- _os_path_join = join
-
-def _os_path_isdir(pathname):
- "Local replacement for os.path.isdir()."
- try:
- s = _os_stat(pathname)
- except OSError:
- return None
- return (s.st_mode & 0170000) == 0040000
-
-def _timestamp(pathname):
- "Return the file modification time as a Long."
- try:
- s = _os_stat(pathname)
- except OSError:
- return None
- return long(s.st_mtime)
-
-
-######################################################################
-#
-# Emulate the import mechanism for builtin and frozen modules
-#
-class BuiltinImporter(Importer):
- def get_code(self, parent, modname, fqname):
- if parent:
- # these modules definitely do not occur within a package context
- return None
-
- # look for the module
- if imp.is_builtin(modname):
- type = imp.C_BUILTIN
- elif imp.is_frozen(modname):
- type = imp.PY_FROZEN
- else:
- # not found
- return None
-
- # got it. now load and return it.
- module = imp.load_module(modname, None, modname, ('', '', type))
- return 0, module, { }
-
-
-######################################################################
-#
-# Internal importer used for importing from the filesystem
-#
-class _FilesystemImporter(Importer):
- def __init__(self):
- self.suffixes = [ ]
-
- def add_suffix(self, suffix, importFunc):
- assert hasattr(importFunc, '__call__')
- self.suffixes.append((suffix, importFunc))
-
- def import_from_dir(self, dir, fqname):
- result = self._import_pathname(_os_path_join(dir, fqname), fqname)
- if result:
- return self._process_result(result, fqname)
- return None
-
- def get_code(self, parent, modname, fqname):
- # This importer is never used with an empty parent. Its existence is
- # private to the ImportManager. The ImportManager uses the
- # import_from_dir() method to import top-level modules/packages.
- # This method is only used when we look for a module within a package.
- assert parent
-
- for submodule_path in parent.__path__:
- code = self._import_pathname(_os_path_join(submodule_path, modname), fqname)
- if code is not None:
- return code
- return self._import_pathname(_os_path_join(parent.__pkgdir__, modname),
- fqname)
-
- def _import_pathname(self, pathname, fqname):
- if _os_path_isdir(pathname):
- result = self._import_pathname(_os_path_join(pathname, '__init__'),
- fqname)
- if result:
- values = result[2]
- values['__pkgdir__'] = pathname
- values['__path__'] = [ pathname ]
- return 1, result[1], values
- return None
-
- for suffix, importFunc in self.suffixes:
- filename = pathname + suffix
- try:
- finfo = _os_stat(filename)
- except OSError:
- pass
- else:
- return importFunc(filename, finfo, fqname)
- return None
-
-######################################################################
-#
-# SUFFIX-BASED IMPORTERS
-#
-
-def py_suffix_importer(filename, finfo, fqname):
- file = filename[:-3] + _suffix
- t_py = long(finfo[8])
- t_pyc = _timestamp(file)
-
- code = None
- if t_pyc is not None and t_pyc >= t_py:
- f = open(file, 'rb')
- if f.read(4) == imp.get_magic():
- t = struct.unpack('<I', f.read(4))[0]
- if t == t_py:
- code = marshal.load(f)
- f.close()
- if code is None:
- file = filename
- code = _compile(file, t_py)
-
- return 0, code, { '__file__' : file }
-
-class DynLoadSuffixImporter:
- def __init__(self, desc):
- self.desc = desc
-
- def import_file(self, filename, finfo, fqname):
- fp = open(filename, self.desc[1])
- module = imp.load_module(fqname, fp, filename, self.desc)
- module.__file__ = filename
- return 0, module, { }
-
-
-######################################################################
-
-def _print_importers():
- items = sys.modules.items()
- items.sort()
- for name, module in items:
- if module:
- print name, module.__dict__.get('__importer__', '-- no importer')
- else:
- print name, '-- non-existent module'
-
-def _test_revamp():
- ImportManager().install()
- sys.path.insert(0, BuiltinImporter())
-
-######################################################################
-
-#
-# TODO
-#
-# from Finn Bock:
-# type(sys) is not a module in Jython. what to use instead?
-# imp.C_EXTENSION is not in Jython. same for get_suffixes and new_module
-#
-# given foo.py of:
-# import sys
-# sys.modules['foo'] = sys
-#
-# ---- standard import mechanism
-# >>> import foo
-# >>> foo
-# <module 'sys' (built-in)>
-#
-# ---- revamped import mechanism
-# >>> import imputil
-# >>> imputil._test_revamp()
-# >>> import foo
-# >>> foo
-# <module 'foo' from 'foo.py'>
-#
-#
-# from MAL:
-# should BuiltinImporter exist in sys.path or hard-wired in ImportManager?
-# need __path__ processing
-# performance
-# move chaining to a subclass [gjs: it's been nuked]
-# deinstall should be possible
-# query mechanism needed: is a specific Importer installed?
-# py/pyc/pyo piping hooks to filter/process these files
-# wish list:
-# distutils importer hooked to list of standard Internet repositories
-# module->file location mapper to speed FS-based imports
-# relative imports
-# keep chaining so that it can play nice with other import hooks
-#
-# from Gordon:
-# push MAL's mapper into sys.path[0] as a cache (hard-coded for apps)
-#
-# from Guido:
-# need to change sys.* references for rexec environs
-# need hook for MAL's walk-me-up import strategy, or Tim's absolute strategy
-# watch out for sys.modules[...] is None
-# flag to force absolute imports? (speeds _determine_import_context and
-# checking for a relative module)
-# insert names of archives into sys.path (see quote below)
-# note: reload does NOT blast module dict
-# shift import mechanisms and policies around; provide for hooks, overrides
-# (see quote below)
-# add get_source stuff
-# get_topcode and get_subcode
-# CRLF handling in _compile
-# race condition in _compile
-# refactoring of os.py to deal with _os_bootstrap problem
-# any special handling to do for importing a module with a SyntaxError?
-# (e.g. clean up the traceback)
-# implement "domain" for path-type functionality using pkg namespace
-# (rather than FS-names like __path__)
-# don't use the word "private"... maybe "internal"
-#
-#
-# Guido's comments on sys.path caching:
-#
-# We could cache this in a dictionary: the ImportManager can have a
-# cache dict mapping pathnames to importer objects, and a separate
-# method for coming up with an importer given a pathname that's not yet
-# in the cache. The method should do a stat and/or look at the
-# extension to decide which importer class to use; you can register new
-# importer classes by registering a suffix or a Boolean function, plus a
-# class. If you register a new importer class, the cache is zapped.
-# The cache is independent from sys.path (but maintained per
-# ImportManager instance) so that rearrangements of sys.path do the
-# right thing. If a path is dropped from sys.path the corresponding
-# cache entry is simply no longer used.
-#
-# My/Guido's comments on factoring ImportManager and Importer:
-#
-# > However, we still have a tension occurring here:
-# >
-# > 1) implementing policy in ImportManager assists in single-point policy
-# > changes for app/rexec situations
-# > 2) implementing policy in Importer assists in package-private policy
-# > changes for normal, operating conditions
-# >
-# > I'll see if I can sort out a way to do this. Maybe the Importer class will
-# > implement the methods (which can be overridden to change policy) by
-# > delegating to ImportManager.
-#
-# Maybe also think about what kind of policies an Importer would be
-# likely to want to change. I have a feeling that a lot of the code
-# there is actually not so much policy but a *necessity* to get things
-# working given the calling conventions for the __import__ hook: whether
-# to return the head or tail of a dotted name, or when to do the "finish
-# fromlist" stuff.
-#
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 66d51865734..203175568b9 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -1,8 +1,7 @@
-# -*- coding: iso-8859-1 -*-
"""Get useful information from live Python objects.
This module encapsulates the interface provided by the internal special
-attributes (func_*, co_*, im_*, tb_*, etc.) in a friendlier fashion.
+attributes (co_*, im_*, tb_*, etc.) in a friendlier fashion.
It also provides some help for examining source code and class layout.
Here are some of the useful functions provided by this module:
@@ -18,6 +17,7 @@ Here are some of the useful functions provided by this module:
getclasstree() - arrange classes so as to represent their hierarchy
getargspec(), getargvalues(), getcallargs() - get info about function arguments
+ getfullargspec() - same, with support for Python-3000 features
formatargspec(), formatargvalues() - format an argument spec
getouterframes(), getinnerframes() - get info about frames
currentframe() - get the current stack frame
@@ -32,18 +32,29 @@ __date__ = '1 Jan 2001'
import sys
import os
import types
+import itertools
import string
import re
-import dis
import imp
import tokenize
import linecache
from operator import attrgetter
from collections import namedtuple
-# These constants are from Include/code.h.
-CO_OPTIMIZED, CO_NEWLOCALS, CO_VARARGS, CO_VARKEYWORDS = 0x1, 0x2, 0x4, 0x8
-CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40
+# Create constants for the compiler flags in Include/code.h
+# We try to get them from dis to avoid duplication, but fall
+# back to hardcording so the dependency is optional
+try:
+ from dis import COMPILER_FLAG_NAMES as _flag_names
+except ImportError:
+ CO_OPTIMIZED, CO_NEWLOCALS = 0x1, 0x2
+ CO_VARARGS, CO_VARKEYWORDS = 0x4, 0x8
+ CO_NESTED, CO_GENERATOR, CO_NOFREE = 0x10, 0x20, 0x40
+else:
+ mod_dict = globals()
+ for k, v in _flag_names.items():
+ mod_dict["CO_" + v] = k
+
# See Include/object.h
TPFLAGS_IS_ABSTRACT = 1 << 20
@@ -52,6 +63,7 @@ def ismodule(object):
"""Return true if the object is a module.
Module objects provide these attributes:
+ __cached__ pathname to byte compiled file
__doc__ documentation string
__file__ filename (missing for built-in modules)"""
return isinstance(object, types.ModuleType)
@@ -62,7 +74,7 @@ def isclass(object):
Class objects provide these attributes:
__doc__ documentation string
__module__ name of module in which this class was defined"""
- return isinstance(object, (type, types.ClassType))
+ return isinstance(object, type)
def ismethod(object):
"""Return true if the object is an instance method.
@@ -70,9 +82,8 @@ def ismethod(object):
Instance method objects provide these attributes:
__doc__ documentation string
__name__ name with which this method was defined
- im_class class object in which this method belongs
- im_func function object containing implementation of method
- im_self instance to which this method is bound, or None"""
+ __func__ function object containing implementation of method
+ __self__ instance to which this method is bound"""
return isinstance(object, types.MethodType)
def ismethoddescriptor(object):
@@ -88,12 +99,12 @@ def ismethoddescriptor(object):
Methods implemented via descriptors that also pass one of the other
tests return false from the ismethoddescriptor() test, simply because
the other tests promise more -- you can, e.g., count on having the
- im_func attribute (etc) when an object passes ismethod()."""
- return (hasattr(object, "__get__")
- and not hasattr(object, "__set__") # else it's a data descriptor
- and not ismethod(object) # mutual exclusion
- and not isfunction(object)
- and not isclass(object))
+ __func__ attribute (etc) when an object passes ismethod()."""
+ if isclass(object) or ismethod(object) or isfunction(object):
+ # mutual exclusion
+ return False
+ tp = type(object)
+ return hasattr(tp, "__get__") and not hasattr(tp, "__set__")
def isdatadescriptor(object):
"""Return true if the object is a data descriptor.
@@ -103,7 +114,11 @@ def isdatadescriptor(object):
Typically, data descriptors will also have __name__ and __doc__ attributes
(properties, getsets, and members have both of these attributes), but this
is not guaranteed."""
- return (hasattr(object, "__set__") and hasattr(object, "__get__"))
+ if isclass(object) or ismethod(object) or isfunction(object):
+ # mutual exclusion
+ return False
+ tp = type(object)
+ return hasattr(tp, "__set__") and hasattr(tp, "__get__")
if hasattr(types, 'MemberDescriptorType'):
# CPython and equivalent
@@ -145,11 +160,11 @@ def isfunction(object):
Function objects provide these attributes:
__doc__ documentation string
__name__ name with which this function was defined
- func_code code object containing compiled function bytecode
- func_defaults tuple of any default values for arguments
- func_doc (same as __doc__)
- func_globals global namespace in which this function was defined
- func_name (same as __name__)"""
+ __code__ code object containing compiled function bytecode
+ __defaults__ tuple of any default values for arguments
+ __globals__ global namespace in which this function was defined
+ __annotations__ dict of parameter annotations
+ __kwdefaults__ dict of keyword only parameters with defaults"""
return isinstance(object, types.FunctionType)
def isgeneratorfunction(object):
@@ -159,7 +174,7 @@ def isgeneratorfunction(object):
See help(isfunction) for attributes listing."""
return bool((isfunction(object) or ismethod(object)) and
- object.func_code.co_flags & CO_GENERATOR)
+ object.__code__.co_flags & CO_GENERATOR)
def isgenerator(object):
"""Return true if the object is a generator.
@@ -195,14 +210,10 @@ def isframe(object):
f_back next outer frame object (this frame's caller)
f_builtins built-in namespace seen by this frame
f_code code object being executed in this frame
- f_exc_traceback traceback if raised in this frame, or None
- f_exc_type exception type if raised in this frame, or None
- f_exc_value exception value if raised in this frame, or None
f_globals global namespace seen by this frame
f_lasti index of last attempted instruction in bytecode
f_lineno current line number in Python source code
f_locals local namespace seen by this frame
- f_restricted 0 or 1 if frame is in restricted execution mode
f_trace tracing function for this frame, or None"""
return isinstance(object, types.FrameType)
@@ -247,12 +258,23 @@ def isabstract(object):
def getmembers(object, predicate=None):
"""Return all members of an object as (name, value) pairs sorted by name.
Optionally, only return members that satisfy a given predicate."""
+ if isclass(object):
+ mro = (object,) + getmro(object)
+ else:
+ mro = ()
results = []
for key in dir(object):
- try:
- value = getattr(object, key)
- except AttributeError:
- continue
+ # First try to get the value via __dict__. Some descriptors don't
+ # like calling their __get__ (see bug #1785).
+ for base in mro:
+ if key in base.__dict__:
+ value = base.__dict__[key]
+ break
+ else:
+ try:
+ value = getattr(object, key)
+ except AttributeError:
+ continue
if not predicate or predicate(value):
results.append((key, value))
results.sort()
@@ -317,7 +339,7 @@ def classify_class_attrs(cls):
kind = "data"
else:
obj_via_getattr = getattr(cls, name)
- if (ismethod(obj_via_getattr) or
+ if (isfunction(obj_via_getattr) or
ismethoddescriptor(obj_via_getattr)):
kind = "method"
else:
@@ -329,28 +351,16 @@ def classify_class_attrs(cls):
return result
# ----------------------------------------------------------- class helpers
-def _searchbases(cls, accum):
- # Simulate the "classic class" search order.
- if cls in accum:
- return
- accum.append(cls)
- for base in cls.__bases__:
- _searchbases(base, accum)
def getmro(cls):
"Return tuple of base classes (including cls) in method resolution order."
- if hasattr(cls, "__mro__"):
- return cls.__mro__
- else:
- result = []
- _searchbases(cls, result)
- return tuple(result)
+ return cls.__mro__
# -------------------------------------------------- source code extraction
def indentsize(line):
"""Return the indent size, in spaces, at the start of a line of text."""
- expline = string.expandtabs(line)
- return len(expline) - len(string.lstrip(expline))
+ expline = line.expandtabs()
+ return len(expline) - len(expline.lstrip())
def getdoc(object):
"""Get the documentation string for an object.
@@ -362,7 +372,7 @@ def getdoc(object):
doc = object.__doc__
except AttributeError:
return None
- if not isinstance(doc, types.StringTypes):
+ if not isinstance(doc, str):
return None
return cleandoc(doc)
@@ -372,28 +382,28 @@ def cleandoc(doc):
Any whitespace that can be uniformly removed from the second line
onwards is removed."""
try:
- lines = string.split(string.expandtabs(doc), '\n')
+ lines = doc.expandtabs().split('\n')
except UnicodeError:
return None
else:
# Find minimum indentation of any non-blank lines after first line.
- margin = sys.maxint
+ margin = sys.maxsize
for line in lines[1:]:
- content = len(string.lstrip(line))
+ content = len(line.lstrip())
if content:
indent = len(line) - content
margin = min(margin, indent)
# Remove indentation.
if lines:
lines[0] = lines[0].lstrip()
- if margin < sys.maxint:
+ if margin < sys.maxsize:
for i in range(1, len(lines)): lines[i] = lines[i][margin:]
# Remove any trailing or leading blank lines.
while lines and not lines[-1]:
lines.pop()
while lines and not lines[0]:
lines.pop(0)
- return string.join(lines, '\n')
+ return '\n'.join(lines)
def getfile(object):
"""Work out which source or compiled file an object was defined in."""
@@ -407,9 +417,9 @@ def getfile(object):
return object.__file__
raise TypeError('{!r} is a built-in class'.format(object))
if ismethod(object):
- object = object.im_func
+ object = object.__func__
if isfunction(object):
- object = object.func_code
+ object = object.__code__
if istraceback(object):
object = object.tb_frame
if isframe(object):
@@ -424,9 +434,8 @@ ModuleInfo = namedtuple('ModuleInfo', 'name suffix mode module_type')
def getmoduleinfo(path):
"""Get the module name, suffix, mode, and module type for a given file."""
filename = os.path.basename(path)
- suffixes = map(lambda info:
- (-len(info[0]), info[0], info[1], info[2]),
- imp.get_suffixes())
+ suffixes = [(-len(suffix), suffix, mode, mtype)
+ for suffix, mode, mtype in imp.get_suffixes()]
suffixes.sort() # try longest suffixes first, in case they overlap
for neglen, suffix, mode, mtype in suffixes:
if filename[neglen:] == suffix:
@@ -442,10 +451,10 @@ def getsourcefile(object):
Return None if no way can be identified to get the source.
"""
filename = getfile(object)
- if string.lower(filename[-4:]) in ('.pyc', '.pyo'):
+ if filename[-4:].lower() in ('.pyc', '.pyo'):
filename = filename[:-4] + '.py'
for suffix, mode, kind in imp.get_suffixes():
- if 'b' in mode and string.lower(filename[-len(suffix):]) == suffix:
+ if 'b' in mode and filename[-len(suffix):].lower() == suffix:
# Looks like a binary file. We want to only return a text file.
return None
if os.path.exists(filename):
@@ -487,7 +496,7 @@ def getmodule(object, _filename=None):
return sys.modules.get(modulesbyfile[file])
# Update the filename to module name cache and check yet again
# Copy sys.modules in order to cope with changes while iterating
- for modname, module in sys.modules.items():
+ for modname, module in list(sys.modules.items()):
if ismodule(module) and hasattr(module, '__file__'):
f = module.__file__
if f == _filesbymodname.get(modname, None):
@@ -509,7 +518,7 @@ def getmodule(object, _filename=None):
if mainobject is object:
return main
# Check builtins
- builtin = sys.modules['__builtin__']
+ builtin = sys.modules['builtins']
if hasattr(builtin, object.__name__):
builtinobject = getattr(builtin, object.__name__)
if builtinobject is object:
@@ -564,9 +573,9 @@ def findsource(object):
raise IOError('could not find class definition')
if ismethod(object):
- object = object.im_func
+ object = object.__func__
if isfunction(object):
- object = object.func_code
+ object = object.__code__
if istraceback(object):
object = object.tb_frame
if isframe(object):
@@ -596,36 +605,36 @@ def getcomments(object):
# Look for a comment block at the top of the file.
start = 0
if lines and lines[0][:2] == '#!': start = 1
- while start < len(lines) and string.strip(lines[start]) in ('', '#'):
+ while start < len(lines) and lines[start].strip() in ('', '#'):
start = start + 1
if start < len(lines) and lines[start][:1] == '#':
comments = []
end = start
while end < len(lines) and lines[end][:1] == '#':
- comments.append(string.expandtabs(lines[end]))
+ comments.append(lines[end].expandtabs())
end = end + 1
- return string.join(comments, '')
+ return ''.join(comments)
# Look for a preceding block of comments at the same indentation.
elif lnum > 0:
indent = indentsize(lines[lnum])
end = lnum - 1
- if end >= 0 and string.lstrip(lines[end])[:1] == '#' and \
+ if end >= 0 and lines[end].lstrip()[:1] == '#' and \
indentsize(lines[end]) == indent:
- comments = [string.lstrip(string.expandtabs(lines[end]))]
+ comments = [lines[end].expandtabs().lstrip()]
if end > 0:
end = end - 1
- comment = string.lstrip(string.expandtabs(lines[end]))
+ comment = lines[end].expandtabs().lstrip()
while comment[:1] == '#' and indentsize(lines[end]) == indent:
comments[:0] = [comment]
end = end - 1
if end < 0: break
- comment = string.lstrip(string.expandtabs(lines[end]))
- while comments and string.strip(comments[0]) == '#':
+ comment = lines[end].expandtabs().lstrip()
+ while comments and comments[0].strip() == '#':
comments[:1] = []
- while comments and string.strip(comments[-1]) == '#':
+ while comments and comments[-1].strip() == '#':
comments[-1:] = []
- return string.join(comments, '')
+ return ''.join(comments)
class EndOfBlock(Exception): pass
@@ -638,9 +647,7 @@ class BlockFinder:
self.passline = False
self.last = 1
- def tokeneater(self, type, token, srow_scol, erow_ecol, line):
- srow, scol = srow_scol
- erow, ecol = erow_ecol
+ def tokeneater(self, type, token, srowcol, erowcol, line):
if not self.started:
# look for the first "def", "class" or "lambda"
if token in ("def", "class", "lambda"):
@@ -650,7 +657,7 @@ class BlockFinder:
self.passline = True # skip to the end of the line
elif type == tokenize.NEWLINE:
self.passline = False # stop skipping when a NEWLINE is seen
- self.last = srow
+ self.last = srowcol[0]
if self.islambda: # lambdas always end at the first NEWLINE
raise EndOfBlock
elif self.passline:
@@ -674,7 +681,9 @@ def getblock(lines):
"""Extract the block of code at the top of the given list of lines."""
blockfinder = BlockFinder()
try:
- tokenize.tokenize(iter(lines).next, blockfinder.tokeneater)
+ tokens = tokenize.generate_tokens(iter(lines).__next__)
+ for _token in tokens:
+ blockfinder.tokeneater(*_token)
except (EndOfBlock, IndentationError):
pass
return lines[:blockfinder.last]
@@ -699,7 +708,7 @@ def getsource(object):
or code object. The source code is returned as a single string. An
IOError is raised if the source code cannot be retrieved."""
lines, lnum = getsourcelines(object)
- return string.join(lines, '')
+ return ''.join(lines)
# --------------------------------------------------- class tree extraction
def walktree(classes, children, parent):
@@ -712,7 +721,7 @@ def walktree(classes, children, parent):
results.append(walktree(children[c], children, c))
return results
-def getclasstree(classes, unique=0):
+def getclasstree(classes, unique=False):
"""Arrange the given list of classes into a hierarchy of nested lists.
Where a nested list appears, it contains classes derived from the class
@@ -738,57 +747,36 @@ def getclasstree(classes, unique=0):
return walktree(roots, children, None)
# ------------------------------------------------ argument list extraction
-Arguments = namedtuple('Arguments', 'args varargs keywords')
+Arguments = namedtuple('Arguments', 'args, varargs, varkw')
def getargs(co):
"""Get information about the arguments accepted by a code object.
- Three things are returned: (args, varargs, varkw), where 'args' is
- a list of argument names (possibly containing nested lists), and
- 'varargs' and 'varkw' are the names of the * and ** arguments or None."""
+ Three things are returned: (args, varargs, varkw), where
+ 'args' is the list of argument names. Keyword-only arguments are
+ appended. 'varargs' and 'varkw' are the names of the * and **
+ arguments or None."""
+ args, varargs, kwonlyargs, varkw = _getfullargs(co)
+ return Arguments(args + kwonlyargs, varargs, varkw)
+
+def _getfullargs(co):
+ """Get information about the arguments accepted by a code object.
+
+ Four things are returned: (args, varargs, kwonlyargs, varkw), where
+ 'args' and 'kwonlyargs' are lists of argument names, and 'varargs'
+ and 'varkw' are the names of the * and ** arguments or None."""
if not iscode(co):
raise TypeError('{!r} is not a code object'.format(co))
nargs = co.co_argcount
names = co.co_varnames
+ nkwargs = co.co_kwonlyargcount
args = list(names[:nargs])
+ kwonlyargs = list(names[nargs:nargs+nkwargs])
step = 0
- # The following acrobatics are for anonymous (tuple) arguments.
- for i in range(nargs):
- if args[i][:1] in ('', '.'):
- stack, remain, count = [], [], []
- while step < len(co.co_code):
- op = ord(co.co_code[step])
- step = step + 1
- if op >= dis.HAVE_ARGUMENT:
- opname = dis.opname[op]
- value = ord(co.co_code[step]) + ord(co.co_code[step+1])*256
- step = step + 2
- if opname in ('UNPACK_TUPLE', 'UNPACK_SEQUENCE'):
- remain.append(value)
- count.append(value)
- elif opname == 'STORE_FAST':
- stack.append(names[value])
-
- # Special case for sublists of length 1: def foo((bar))
- # doesn't generate the UNPACK_TUPLE bytecode, so if
- # `remain` is empty here, we have such a sublist.
- if not remain:
- stack[0] = [stack[0]]
- break
- else:
- remain[-1] = remain[-1] - 1
- while remain[-1] == 0:
- remain.pop()
- size = count.pop()
- stack[-size:] = [stack[-size:]]
- if not remain: break
- remain[-1] = remain[-1] - 1
- if not remain: break
- args[i] = stack[0]
-
+ nargs += nkwargs
varargs = None
if co.co_flags & CO_VARARGS:
varargs = co.co_varnames[nargs]
@@ -796,7 +784,8 @@ def getargs(co):
varkw = None
if co.co_flags & CO_VARKEYWORDS:
varkw = co.co_varnames[nargs]
- return Arguments(args, varargs, varkw)
+ return args, varargs, kwonlyargs, varkw
+
ArgSpec = namedtuple('ArgSpec', 'args varargs keywords defaults')
@@ -804,17 +793,48 @@ def getargspec(func):
"""Get the names and default values of a function's arguments.
A tuple of four things is returned: (args, varargs, varkw, defaults).
- 'args' is a list of the argument names (it may contain nested lists).
+ 'args' is a list of the argument names.
+ 'args' will include keyword-only argument names.
+ 'varargs' and 'varkw' are the names of the * and ** arguments or None.
+ 'defaults' is an n-tuple of the default values of the last n arguments.
+
+ Use the getfullargspec() API for Python-3000 code, as annotations
+ and keyword arguments are supported. getargspec() will raise ValueError
+ if the func has either annotations or keyword arguments.
+ """
+
+ args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
+ getfullargspec(func)
+ if kwonlyargs or ann:
+ raise ValueError("Function has keyword-only arguments or annotations"
+ ", use getfullargspec() API which can support them")
+ return ArgSpec(args, varargs, varkw, defaults)
+
+FullArgSpec = namedtuple('FullArgSpec',
+ 'args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, annotations')
+
+def getfullargspec(func):
+ """Get the names and default values of a function's arguments.
+
+ A tuple of seven things is returned:
+ (args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults annotations).
+ 'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'defaults' is an n-tuple of the default values of the last n arguments.
+ 'kwonlyargs' is a list of keyword-only argument names.
+ 'kwonlydefaults' is a dictionary mapping names from kwonlyargs to defaults.
+ 'annotations' is a dictionary mapping argument names to annotations.
+
+ The first four items in the tuple correspond to getargspec().
"""
if ismethod(func):
- func = func.im_func
+ func = func.__func__
if not isfunction(func):
raise TypeError('{!r} is not a Python function'.format(func))
- args, varargs, varkw = getargs(func.func_code)
- return ArgSpec(args, varargs, varkw, func.func_defaults)
+ args, varargs, kwonlyargs, varkw = _getfullargs(func.__code__)
+ return FullArgSpec(args, varargs, varkw, func.__defaults__,
+ kwonlyargs, func.__kwdefaults__, func.__annotations__)
ArgInfo = namedtuple('ArgInfo', 'args varargs keywords locals')
@@ -822,57 +842,77 @@ def getargvalues(frame):
"""Get information about arguments passed into a particular frame.
A tuple of four things is returned: (args, varargs, varkw, locals).
- 'args' is a list of the argument names (it may contain nested lists).
+ 'args' is a list of the argument names.
'varargs' and 'varkw' are the names of the * and ** arguments or None.
'locals' is the locals dictionary of the given frame."""
args, varargs, varkw = getargs(frame.f_code)
return ArgInfo(args, varargs, varkw, frame.f_locals)
-def joinseq(seq):
- if len(seq) == 1:
- return '(' + seq[0] + ',)'
- else:
- return '(' + string.join(seq, ', ') + ')'
+def formatannotation(annotation, base_module=None):
+ if isinstance(annotation, type):
+ if annotation.__module__ in ('builtins', base_module):
+ return annotation.__name__
+ return annotation.__module__+'.'+annotation.__name__
+ return repr(annotation)
-def strseq(object, convert, join=joinseq):
- """Recursively walk a sequence, stringifying each element."""
- if type(object) in (list, tuple):
- return join(map(lambda o, c=convert, j=join: strseq(o, c, j), object))
- else:
- return convert(object)
+def formatannotationrelativeto(object):
+ module = getattr(object, '__module__', None)
+ def _formatannotation(annotation):
+ return formatannotation(annotation, module)
+ return _formatannotation
def formatargspec(args, varargs=None, varkw=None, defaults=None,
+ kwonlyargs=(), kwonlydefaults={}, annotations={},
formatarg=str,
formatvarargs=lambda name: '*' + name,
formatvarkw=lambda name: '**' + name,
formatvalue=lambda value: '=' + repr(value),
- join=joinseq):
- """Format an argument spec from the 4 values returned by getargspec.
-
- The first four arguments are (args, varargs, varkw, defaults). The
- other four arguments are the corresponding optional formatting functions
- that are called to turn names and values into strings. The ninth
- argument is an optional function to format the sequence of arguments."""
+ formatreturns=lambda text: ' -> ' + text,
+ formatannotation=formatannotation):
+ """Format an argument spec from the values returned by getargspec
+ or getfullargspec.
+
+ The first seven arguments are (args, varargs, varkw, defaults,
+ kwonlyargs, kwonlydefaults, annotations). The other five arguments
+ are the corresponding optional formatting functions that are called to
+ turn names and values into strings. The last argument is an optional
+ function to format the sequence of arguments."""
+ def formatargandannotation(arg):
+ result = formatarg(arg)
+ if arg in annotations:
+ result += ': ' + formatannotation(annotations[arg])
+ return result
specs = []
if defaults:
firstdefault = len(args) - len(defaults)
for i, arg in enumerate(args):
- spec = strseq(arg, formatarg, join)
+ spec = formatargandannotation(arg)
if defaults and i >= firstdefault:
spec = spec + formatvalue(defaults[i - firstdefault])
specs.append(spec)
if varargs is not None:
- specs.append(formatvarargs(varargs))
+ specs.append(formatvarargs(formatargandannotation(varargs)))
+ else:
+ if kwonlyargs:
+ specs.append('*')
+ if kwonlyargs:
+ for kwonlyarg in kwonlyargs:
+ spec = formatargandannotation(kwonlyarg)
+ if kwonlydefaults and kwonlyarg in kwonlydefaults:
+ spec += formatvalue(kwonlydefaults[kwonlyarg])
+ specs.append(spec)
if varkw is not None:
- specs.append(formatvarkw(varkw))
- return '(' + string.join(specs, ', ') + ')'
+ specs.append(formatvarkw(formatargandannotation(varkw)))
+ result = '(' + ', '.join(specs) + ')'
+ if 'return' in annotations:
+ result += formatreturns(formatannotation(annotations['return']))
+ return result
def formatargvalues(args, varargs, varkw, locals,
formatarg=str,
formatvarargs=lambda name: '*' + name,
formatvarkw=lambda name: '**' + name,
- formatvalue=lambda value: '=' + repr(value),
- join=joinseq):
+ formatvalue=lambda value: '=' + repr(value)):
"""Format an argument spec from the 4 values returned by getargvalues.
The first four arguments are (args, varargs, varkw, locals). The
@@ -884,12 +924,12 @@ def formatargvalues(args, varargs, varkw, locals,
return formatarg(name) + formatvalue(locals[name])
specs = []
for i in range(len(args)):
- specs.append(strseq(args[i], convert, join))
+ specs.append(convert(args[i]))
if varargs:
specs.append(formatvarargs(varargs) + formatvalue(locals[varargs]))
if varkw:
specs.append(formatvarkw(varkw) + formatvalue(locals[varkw]))
- return '(' + string.join(specs, ', ') + ')'
+ return '(' + ', '.join(specs) + ')'
def getcallargs(func, *positional, **named):
"""Get the mapping of arguments to values.
@@ -897,82 +937,64 @@ def getcallargs(func, *positional, **named):
A dict is returned, with keys the function argument names (including the
names of the * and ** arguments, if any), and values the respective bound
values from 'positional' and 'named'."""
- args, varargs, varkw, defaults = getargspec(func)
+ spec = getfullargspec(func)
+ args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = spec
f_name = func.__name__
arg2value = {}
- # The following closures are basically because of tuple parameter unpacking.
- assigned_tuple_params = []
- def assign(arg, value):
- if isinstance(arg, str):
- arg2value[arg] = value
- else:
- assigned_tuple_params.append(arg)
- value = iter(value)
- for i, subarg in enumerate(arg):
- try:
- subvalue = next(value)
- except StopIteration:
- raise ValueError('need more than %d %s to unpack' %
- (i, 'values' if i > 1 else 'value'))
- assign(subarg,subvalue)
- try:
- next(value)
- except StopIteration:
- pass
- else:
- raise ValueError('too many values to unpack')
- def is_assigned(arg):
- if isinstance(arg,str):
- return arg in arg2value
- return arg in assigned_tuple_params
- if ismethod(func) and func.im_self is not None:
+ if ismethod(func) and func.__self__ is not None:
# implicit 'self' (or 'cls' for classmethods) argument
- positional = (func.im_self,) + positional
+ positional = (func.__self__,) + positional
num_pos = len(positional)
num_total = num_pos + len(named)
num_args = len(args)
num_defaults = len(defaults) if defaults else 0
for arg, value in zip(args, positional):
- assign(arg, value)
+ arg2value[arg] = value
if varargs:
if num_pos > num_args:
- assign(varargs, positional[-(num_pos-num_args):])
+ arg2value[varargs] = positional[-(num_pos-num_args):]
else:
- assign(varargs, ())
+ arg2value[varargs] = ()
elif 0 < num_args < num_pos:
- raise TypeError('%s() takes %s %d %s (%d given)' % (
+ raise TypeError('%s() takes %s %d positional %s (%d given)' % (
f_name, 'at most' if defaults else 'exactly', num_args,
'arguments' if num_args > 1 else 'argument', num_total))
elif num_args == 0 and num_total:
- if varkw:
+ if varkw or kwonlyargs:
if num_pos:
# XXX: We should use num_pos, but Python also uses num_total:
- raise TypeError('%s() takes exactly 0 arguments '
+ raise TypeError('%s() takes exactly 0 positional arguments '
'(%d given)' % (f_name, num_total))
else:
raise TypeError('%s() takes no arguments (%d given)' %
(f_name, num_total))
- for arg in args:
- if isinstance(arg, str) and arg in named:
- if is_assigned(arg):
+
+ for arg in itertools.chain(args, kwonlyargs):
+ if arg in named:
+ if arg in arg2value:
raise TypeError("%s() got multiple values for keyword "
"argument '%s'" % (f_name, arg))
else:
- assign(arg, named.pop(arg))
+ arg2value[arg] = named.pop(arg)
+ for kwonlyarg in kwonlyargs:
+ if kwonlyarg not in arg2value:
+ try:
+ arg2value[kwonlyarg] = kwonlydefaults[kwonlyarg]
+ except KeyError:
+ raise TypeError("%s() needs keyword-only argument %s" %
+ (f_name, kwonlyarg))
if defaults: # fill in any missing values with the defaults
for arg, value in zip(args[-num_defaults:], defaults):
- if not is_assigned(arg):
- assign(arg, value)
+ if arg not in arg2value:
+ arg2value[arg] = value
if varkw:
- assign(varkw, named)
+ arg2value[varkw] = named
elif named:
unexpected = next(iter(named))
- if isinstance(unexpected, unicode):
- unexpected = unexpected.encode(sys.getdefaultencoding(), 'replace')
raise TypeError("%s() got an unexpected keyword argument '%s'" %
(f_name, unexpected))
- unassigned = num_args - len([arg for arg in args if is_assigned(arg)])
+ unassigned = num_args - len([arg for arg in args if arg in arg2value])
if unassigned:
num_required = num_args - num_defaults
raise TypeError('%s() takes %s %d %s (%d given)' % (
@@ -1044,10 +1066,9 @@ def getinnerframes(tb, context=1):
tb = tb.tb_next
return framelist
-if hasattr(sys, '_getframe'):
- currentframe = sys._getframe
-else:
- currentframe = lambda _=None: None
+def currentframe():
+ """Return the frame of the caller or None if this is not possible."""
+ return sys._getframe(1) if hasattr(sys, "_getframe") else None
def stack(context=1):
"""Return a list of records for the stack above the caller's frame."""
@@ -1056,3 +1077,118 @@ def stack(context=1):
def trace(context=1):
"""Return a list of records for the stack below the current exception."""
return getinnerframes(sys.exc_info()[2], context)
+
+
+# ------------------------------------------------ static version of getattr
+
+_sentinel = object()
+
+def _static_getmro(klass):
+ return type.__dict__['__mro__'].__get__(klass)
+
+def _check_instance(obj, attr):
+ instance_dict = {}
+ try:
+ instance_dict = object.__getattribute__(obj, "__dict__")
+ except AttributeError:
+ pass
+ return dict.get(instance_dict, attr, _sentinel)
+
+
+def _check_class(klass, attr):
+ for entry in _static_getmro(klass):
+ if _shadowed_dict(type(entry)) is _sentinel:
+ try:
+ return entry.__dict__[attr]
+ except KeyError:
+ pass
+ return _sentinel
+
+def _is_type(obj):
+ try:
+ _static_getmro(obj)
+ except TypeError:
+ return False
+ return True
+
+def _shadowed_dict(klass):
+ dict_attr = type.__dict__["__dict__"]
+ for entry in _static_getmro(klass):
+ try:
+ class_dict = dict_attr.__get__(entry)["__dict__"]
+ except KeyError:
+ pass
+ else:
+ if not (type(class_dict) is types.GetSetDescriptorType and
+ class_dict.__name__ == "__dict__" and
+ class_dict.__objclass__ is entry):
+ return class_dict
+ return _sentinel
+
+def getattr_static(obj, attr, default=_sentinel):
+ """Retrieve attributes without triggering dynamic lookup via the
+ descriptor protocol, __getattr__ or __getattribute__.
+
+ Note: this function may not be able to retrieve all attributes
+ that getattr can fetch (like dynamically created attributes)
+ and may find attributes that getattr can't (like descriptors
+ that raise AttributeError). It can also return descriptor objects
+ instead of instance members in some cases. See the
+ documentation for details.
+ """
+ instance_result = _sentinel
+ if not _is_type(obj):
+ klass = type(obj)
+ dict_attr = _shadowed_dict(klass)
+ if (dict_attr is _sentinel or
+ type(dict_attr) is types.MemberDescriptorType):
+ instance_result = _check_instance(obj, attr)
+ else:
+ klass = obj
+
+ klass_result = _check_class(klass, attr)
+
+ if instance_result is not _sentinel and klass_result is not _sentinel:
+ if (_check_class(type(klass_result), '__get__') is not _sentinel and
+ _check_class(type(klass_result), '__set__') is not _sentinel):
+ return klass_result
+
+ if instance_result is not _sentinel:
+ return instance_result
+ if klass_result is not _sentinel:
+ return klass_result
+
+ if obj is klass:
+ # for types we check the metaclass too
+ for entry in _static_getmro(type(klass)):
+ if _shadowed_dict(type(entry)) is _sentinel:
+ try:
+ return entry.__dict__[attr]
+ except KeyError:
+ pass
+ if default is not _sentinel:
+ return default
+ raise AttributeError(attr)
+
+
+GEN_CREATED = 'GEN_CREATED'
+GEN_RUNNING = 'GEN_RUNNING'
+GEN_SUSPENDED = 'GEN_SUSPENDED'
+GEN_CLOSED = 'GEN_CLOSED'
+
+def getgeneratorstate(generator):
+ """Get current state of a generator-iterator.
+
+ Possible states are:
+ GEN_CREATED: Waiting to start execution.
+ GEN_RUNNING: Currently being executed by the interpreter.
+ GEN_SUSPENDED: Currently suspended at a yield expression.
+ GEN_CLOSED: Execution has completed.
+ """
+ if generator.gi_running:
+ return GEN_RUNNING
+ if generator.gi_frame is None:
+ return GEN_CLOSED
+ if generator.gi_frame.f_lasti == -1:
+ return GEN_CREATED
+ return GEN_SUSPENDED
diff --git a/Lib/io.py b/Lib/io.py
index 22832766c4c..63d2b33838f 100644
--- a/Lib/io.py
+++ b/Lib/io.py
@@ -66,8 +66,8 @@ SEEK_END = 2
# Declaring ABCs in C is tricky so we do it here.
# Method descriptions and default implementations are inherited from the C
# version however.
-class IOBase(_io._IOBase):
- __metaclass__ = abc.ABCMeta
+class IOBase(_io._IOBase, metaclass=abc.ABCMeta):
+ pass
class RawIOBase(_io._RawIOBase, IOBase):
pass
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index d6a45d3b425..44f49c4247f 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -14,15 +14,15 @@ Encoding basic Python object hierarchies::
>>> import json
>>> json.dumps(['foo', {'bar': ('baz', None, 1.0, 2)}])
'["foo", {"bar": ["baz", null, 1.0, 2]}]'
- >>> print json.dumps("\"foo\bar")
+ >>> print(json.dumps("\"foo\bar"))
"\"foo\bar"
- >>> print json.dumps(u'\u1234')
+ >>> print(json.dumps('\u1234'))
"\u1234"
- >>> print json.dumps('\\')
+ >>> print(json.dumps('\\'))
"\\"
- >>> print json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True)
+ >>> print(json.dumps({"c": 0, "b": 0, "a": 0}, sort_keys=True))
{"a": 0, "b": 0, "c": 0}
- >>> from StringIO import StringIO
+ >>> from io import StringIO
>>> io = StringIO()
>>> json.dump(['streaming API'], io)
>>> io.getvalue()
@@ -31,14 +31,16 @@ Encoding basic Python object hierarchies::
Compact encoding::
>>> import json
- >>> json.dumps([1,2,3,{'4': 5, '6': 7}], sort_keys=True, separators=(',',':'))
+ >>> from collections import OrderedDict
+ >>> mydict = OrderedDict([('4', 5), ('6', 7)])
+ >>> json.dumps([1,2,3,mydict], separators=(',', ':'))
'[1,2,3,{"4":5,"6":7}]'
Pretty printing::
>>> import json
- >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True,
- ... indent=4, separators=(',', ': '))
+ >>> print(json.dumps({'4': 5, '6': 7}, sort_keys=True,
+ ... indent=4, separators=(',', ': ')))
{
"4": 5,
"6": 7
@@ -47,12 +49,12 @@ Pretty printing::
Decoding JSON::
>>> import json
- >>> obj = [u'foo', {u'bar': [u'baz', None, 1.0, 2]}]
+ >>> obj = ['foo', {'bar': ['baz', None, 1.0, 2]}]
>>> json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]') == obj
True
- >>> json.loads('"\\"foo\\bar"') == u'"foo\x08ar'
+ >>> json.loads('"\\"foo\\bar"') == '"foo\x08ar'
True
- >>> from StringIO import StringIO
+ >>> from io import StringIO
>>> io = StringIO('["streaming API"]')
>>> json.load(io)[0] == 'streaming API'
True
@@ -115,28 +117,22 @@ _default_encoder = JSONEncoder(
allow_nan=True,
indent=None,
separators=None,
- encoding='utf-8',
default=None,
)
def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
- encoding='utf-8', default=None, sort_keys=False, **kw):
+ default=None, sort_keys=False, **kw):
"""Serialize ``obj`` as a JSON formatted stream to ``fp`` (a
``.write()``-supporting file-like object).
If ``skipkeys`` is true then ``dict`` keys that are not basic types
- (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
- will be skipped instead of raising a ``TypeError``.
-
- If ``ensure_ascii`` is true (the default), all non-ASCII characters in the
- output are escaped with ``\uXXXX`` sequences, and the result is a ``str``
- instance consisting of ASCII characters only. If ``ensure_ascii`` is
- ``False``, some chunks written to ``fp`` may be ``unicode`` instances.
- This usually happens because the input contains unicode strings or the
- ``encoding`` parameter is used. Unless ``fp.write()`` explicitly
- understands ``unicode`` (as in ``codecs.getwriter``) this is likely to
- cause an error.
+ (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
+ instead of raising a ``TypeError``.
+
+ If ``ensure_ascii`` is false, then the strings written to ``fp`` can
+ contain non-ASCII characters if they appear in strings contained in
+ ``obj``. Otherwise, all such characters are escaped in JSON strings.
If ``check_circular`` is false, then the circular reference check
for container types will be skipped and a circular reference will
@@ -158,8 +154,6 @@ def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
then it will be used instead of the default ``(', ', ': ')`` separators.
``(',', ':')`` is the most compact JSON representation.
- ``encoding`` is the character encoding for str instances, default is UTF-8.
-
``default(obj)`` is a function that should return a serializable version
of obj or raise TypeError. The default simply raises TypeError.
@@ -175,14 +169,14 @@ def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
if (not skipkeys and ensure_ascii and
check_circular and allow_nan and
cls is None and indent is None and separators is None and
- encoding == 'utf-8' and default is None and not sort_keys and not kw):
+ default is None and not sort_keys and not kw):
iterable = _default_encoder.iterencode(obj)
else:
if cls is None:
cls = JSONEncoder
iterable = cls(skipkeys=skipkeys, ensure_ascii=ensure_ascii,
check_circular=check_circular, allow_nan=allow_nan, indent=indent,
- separators=separators, encoding=encoding,
+ separators=separators,
default=default, sort_keys=sort_keys, **kw).iterencode(obj)
# could accelerate with writelines in some versions of Python, at
# a debuggability cost
@@ -192,15 +186,16 @@ def dump(obj, fp, skipkeys=False, ensure_ascii=True, check_circular=True,
def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
allow_nan=True, cls=None, indent=None, separators=None,
- encoding='utf-8', default=None, sort_keys=False, **kw):
+ default=None, sort_keys=False, **kw):
"""Serialize ``obj`` to a JSON formatted ``str``.
If ``skipkeys`` is false then ``dict`` keys that are not basic types
- (``str``, ``unicode``, ``int``, ``long``, ``float``, ``bool``, ``None``)
- will be skipped instead of raising a ``TypeError``.
+ (``str``, ``int``, ``float``, ``bool``, ``None``) will be skipped
+ instead of raising a ``TypeError``.
- If ``ensure_ascii`` is false, all non-ASCII characters are not escaped, and
- the return value may be a ``unicode`` instance. See ``dump`` for details.
+ If ``ensure_ascii`` is false, then the return value can contain non-ASCII
+ characters if they appear in strings contained in ``obj``. Otherwise, all
+ such characters are escaped in JSON strings.
If ``check_circular`` is false, then the circular reference check
for container types will be skipped and a circular reference will
@@ -222,8 +217,6 @@ def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
then it will be used instead of the default ``(', ', ': ')`` separators.
``(',', ':')`` is the most compact JSON representation.
- ``encoding`` is the character encoding for str instances, default is UTF-8.
-
``default(obj)`` is a function that should return a serializable version
of obj or raise TypeError. The default simply raises TypeError.
@@ -239,33 +232,25 @@ def dumps(obj, skipkeys=False, ensure_ascii=True, check_circular=True,
if (not skipkeys and ensure_ascii and
check_circular and allow_nan and
cls is None and indent is None and separators is None and
- encoding == 'utf-8' and default is None and not sort_keys and not kw):
+ default is None and not sort_keys and not kw):
return _default_encoder.encode(obj)
if cls is None:
cls = JSONEncoder
return cls(
skipkeys=skipkeys, ensure_ascii=ensure_ascii,
check_circular=check_circular, allow_nan=allow_nan, indent=indent,
- separators=separators, encoding=encoding, default=default,
- sort_keys=sort_keys, **kw).encode(obj)
+ separators=separators, default=default, sort_keys=sort_keys,
+ **kw).encode(obj)
-_default_decoder = JSONDecoder(encoding=None, object_hook=None,
- object_pairs_hook=None)
+_default_decoder = JSONDecoder(object_hook=None, object_pairs_hook=None)
-def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
+def load(fp, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
a JSON document) to a Python object.
- If the contents of ``fp`` is encoded with an ASCII based encoding other
- than utf-8 (e.g. latin-1), then an appropriate ``encoding`` name must
- be specified. Encodings that are not ASCII based (such as UCS-2) are
- not allowed, and should be wrapped with
- ``codecs.getreader(fp)(encoding)``, or simply decoded to a ``unicode``
- object and passed to ``loads()``
-
``object_hook`` is an optional function that will be called with the
result of any object literal decode (a ``dict``). The return value of
``object_hook`` will be used instead of the ``dict``. This feature
@@ -284,22 +269,16 @@ def load(fp, encoding=None, cls=None, object_hook=None, parse_float=None,
"""
return loads(fp.read(),
- encoding=encoding, cls=cls, object_hook=object_hook,
+ cls=cls, object_hook=object_hook,
parse_float=parse_float, parse_int=parse_int,
- parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
- **kw)
+ parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, object_pairs_hook=None, **kw):
- """Deserialize ``s`` (a ``str`` or ``unicode`` instance containing a JSON
+ """Deserialize ``s`` (a ``str`` instance containing a JSON
document) to a Python object.
- If ``s`` is a ``str`` instance and is encoded with an ASCII based encoding
- other than utf-8 (e.g. latin-1) then an appropriate ``encoding`` name
- must be specified. Encodings that are not ASCII based (such as UCS-2)
- are not allowed and should be decoded to ``unicode`` first.
-
``object_hook`` is an optional function that will be called with the
result of any object literal decode (a ``dict``). The return value of
``object_hook`` will be used instead of the ``dict``. This feature
@@ -331,8 +310,10 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
kwarg; otherwise ``JSONDecoder`` is used.
+ The ``encoding`` argument is ignored and deprecated.
+
"""
- if (cls is None and encoding is None and object_hook is None and
+ if (cls is None and object_hook is None and
parse_int is None and parse_float is None and
parse_constant is None and object_pairs_hook is None and not kw):
return _default_decoder.decode(s)
@@ -348,4 +329,4 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
kw['parse_int'] = parse_int
if parse_constant is not None:
kw['parse_constant'] = parse_constant
- return cls(encoding=encoding, **kw).decode(s)
+ return cls(**kw).decode(s)
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index 7e2c68c8c46..dc1155b1cc7 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -1,5 +1,6 @@
"""Implementation of JSONDecoder
"""
+import binascii
import re
import sys
import struct
@@ -15,7 +16,7 @@ __all__ = ['JSONDecoder']
FLAGS = re.VERBOSE | re.MULTILINE | re.DOTALL
def _floatconstants():
- _BYTES = '7FF80000000000007FF0000000000000'.decode('hex')
+ _BYTES = binascii.unhexlify(b'7FF80000000000007FF0000000000000')
if sys.byteorder != 'big':
_BYTES = _BYTES[:8][::-1] + _BYTES[8:][::-1]
nan, inf = struct.unpack('dd', _BYTES)
@@ -25,11 +26,15 @@ NaN, PosInf, NegInf = _floatconstants()
def linecol(doc, pos):
- lineno = doc.count('\n', 0, pos) + 1
+ if isinstance(doc, bytes):
+ newline = b'\n'
+ else:
+ newline = '\n'
+ lineno = doc.count(newline, 0, pos) + 1
if lineno == 1:
colno = pos
else:
- colno = pos - doc.rindex('\n', 0, pos)
+ colno = pos - doc.rindex(newline, 0, pos)
return lineno, colno
@@ -54,15 +59,14 @@ _CONSTANTS = {
'NaN': NaN,
}
+
STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
BACKSLASH = {
- '"': u'"', '\\': u'\\', '/': u'/',
- 'b': u'\b', 'f': u'\f', 'n': u'\n', 'r': u'\r', 't': u'\t',
+ '"': '"', '\\': '\\', '/': '/',
+ 'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t',
}
-DEFAULT_ENCODING = "utf-8"
-
-def py_scanstring(s, end, encoding=None, strict=True,
+def py_scanstring(s, end, strict=True,
_b=BACKSLASH, _m=STRINGCHUNK.match):
"""Scan the string s for a JSON string. End is the index of the
character in s after the quote that started the JSON string.
@@ -72,8 +76,6 @@ def py_scanstring(s, end, encoding=None, strict=True,
Returns a tuple of the decoded string and the index of the character in s
after the end quote."""
- if encoding is None:
- encoding = DEFAULT_ENCODING
chunks = []
_append = chunks.append
begin = end - 1
@@ -86,8 +88,6 @@ def py_scanstring(s, end, encoding=None, strict=True,
content, terminator = chunk.groups()
# Content is contains zero or more unescaped string characters
if content:
- if not isinstance(content, unicode):
- content = unicode(content, encoding)
_append(content)
# Terminator is the end of string, a literal control character,
# or a backslash denoting that an escape sequence follows
@@ -111,11 +111,10 @@ def py_scanstring(s, end, encoding=None, strict=True,
try:
char = _b[esc]
except KeyError:
- msg = "Invalid \\escape: " + repr(esc)
+ msg = "Invalid \\escape: {0!r}".format(esc)
raise ValueError(errmsg(msg, s, end))
end += 1
else:
- # Unicode escape sequence
esc = s[end + 1:end + 5]
next_end = end + 5
if len(esc) != 4:
@@ -133,11 +132,11 @@ def py_scanstring(s, end, encoding=None, strict=True,
uni2 = int(esc2, 16)
uni = 0x10000 + (((uni - 0xd800) << 10) | (uni2 - 0xdc00))
next_end += 6
- char = unichr(uni)
+ char = chr(uni)
+
end = next_end
- # Append the unescaped character
_append(char)
- return u''.join(chunks), end
+ return ''.join(chunks), end
# Use speedup if available
@@ -146,11 +145,16 @@ scanstring = c_scanstring or py_scanstring
WHITESPACE = re.compile(r'[ \t\n\r]*', FLAGS)
WHITESPACE_STR = ' \t\n\r'
-def JSONObject(s_and_end, encoding, strict, scan_once, object_hook,
- object_pairs_hook, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
+
+def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
+ memo=None, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
s, end = s_and_end
pairs = []
pairs_append = pairs.append
+ # Backwards compatibility
+ if memo is None:
+ memo = {}
+ memo_get = memo.setdefault
# Use a slice to prevent IndexError from being raised, the following
# check will raise a more specific ValueError if the string is empty
nextchar = s[end:end + 1]
@@ -173,8 +177,8 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook,
"Expecting property name enclosed in double quotes", s, end))
end += 1
while True:
- key, end = scanstring(s, end, encoding, strict)
-
+ key, end = scanstring(s, end, strict)
+ key = memo_get(key, key)
# To skip some function call overhead we optimize the fast paths where
# the JSON key separator is ": " or just ":".
if s[end:end + 1] != ':':
@@ -196,7 +200,6 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook,
except StopIteration:
raise ValueError(errmsg("Expecting object", s, end))
pairs_append((key, value))
-
try:
nextchar = s[end]
if nextchar in _ws:
@@ -210,18 +213,8 @@ def JSONObject(s_and_end, encoding, strict, scan_once, object_hook,
break
elif nextchar != ',':
raise ValueError(errmsg("Expecting ',' delimiter", s, end - 1))
-
- try:
- nextchar = s[end]
- if nextchar in _ws:
- end += 1
- nextchar = s[end]
- if nextchar in _ws:
- end = _w(s, end + 1).end()
- nextchar = s[end]
- except IndexError:
- nextchar = ''
-
+ end = _w(s, end).end()
+ nextchar = s[end:end + 1]
end += 1
if nextchar != '"':
raise ValueError(errmsg(
@@ -270,6 +263,7 @@ def JSONArray(s_and_end, scan_once, _w=WHITESPACE.match, _ws=WHITESPACE_STR):
return values, end
+
class JSONDecoder(object):
"""Simple JSON <http://json.org> decoder
@@ -282,9 +276,9 @@ class JSONDecoder(object):
+---------------+-------------------+
| array | list |
+---------------+-------------------+
- | string | unicode |
+ | string | str |
+---------------+-------------------+
- | number (int) | int, long |
+ | number (int) | int |
+---------------+-------------------+
| number (real) | float |
+---------------+-------------------+
@@ -300,17 +294,10 @@ class JSONDecoder(object):
"""
- def __init__(self, encoding=None, object_hook=None, parse_float=None,
+ def __init__(self, object_hook=None, parse_float=None,
parse_int=None, parse_constant=None, strict=True,
object_pairs_hook=None):
- """``encoding`` determines the encoding used to interpret any ``str``
- objects decoded by this instance (utf-8 by default). It has no
- effect when decoding ``unicode`` objects.
-
- Note that currently only encodings that are a superset of ASCII work,
- strings of other encodings should be passed in as ``unicode``.
-
- ``object_hook``, if specified, will be called with the result
+ """``object_hook``, if specified, will be called with the result
of every JSON object decoded and its return value will be used in
place of the given ``dict``. This can be used to provide custom
deserializations (e.g. to support JSON-RPC class hinting).
@@ -345,21 +332,22 @@ class JSONDecoder(object):
including ``'\\t'`` (tab), ``'\\n'``, ``'\\r'`` and ``'\\0'``.
"""
- self.encoding = encoding
self.object_hook = object_hook
- self.object_pairs_hook = object_pairs_hook
self.parse_float = parse_float or float
self.parse_int = parse_int or int
self.parse_constant = parse_constant or _CONSTANTS.__getitem__
self.strict = strict
+ self.object_pairs_hook = object_pairs_hook
self.parse_object = JSONObject
self.parse_array = JSONArray
self.parse_string = scanstring
+ self.memo = {}
self.scan_once = scanner.make_scanner(self)
+
def decode(self, s, _w=WHITESPACE.match):
- """Return the Python representation of ``s`` (a ``str`` or ``unicode``
- instance containing a JSON document)
+ """Return the Python representation of ``s`` (a ``str`` instance
+ containing a JSON document).
"""
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
@@ -369,8 +357,8 @@ class JSONDecoder(object):
return obj
def raw_decode(self, s, idx=0):
- """Decode a JSON document from ``s`` (a ``str`` or ``unicode``
- beginning with a JSON document) and return a 2-tuple of the Python
+ """Decode a JSON document from ``s`` (a ``str`` beginning with
+ a JSON document) and return a 2-tuple of the Python
representation and the index in ``s`` where the document ended.
This can be used to decode a JSON document from a string that may
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index 4d1aaa8eedf..e1ed21f6e70 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -13,7 +13,7 @@ except ImportError:
ESCAPE = re.compile(r'[\x00-\x1f\\"\b\f\n\r\t]')
ESCAPE_ASCII = re.compile(r'([\\"]|[^\ -~])')
-HAS_UTF8 = re.compile(r'[\x80-\xff]')
+HAS_UTF8 = re.compile(b'[\x80-\xff]')
ESCAPE_DCT = {
'\\': '\\\\',
'"': '\\"',
@@ -43,8 +43,6 @@ def py_encode_basestring_ascii(s):
"""Return an ASCII-only JSON representation of a Python string
"""
- if isinstance(s, str) and HAS_UTF8.search(s) is not None:
- s = s.decode('utf-8')
def replace(match):
s = match.group(0)
try:
@@ -60,8 +58,7 @@ def py_encode_basestring_ascii(s):
s1 = 0xd800 | ((n >> 10) & 0x3ff)
s2 = 0xdc00 | (n & 0x3ff)
return '\\u{0:04x}\\u{1:04x}'.format(s1, s2)
- #return '\\u%04x\\u%04x' % (s1, s2)
- return '"' + str(ESCAPE_ASCII.sub(replace, s)) + '"'
+ return '"' + ESCAPE_ASCII.sub(replace, s) + '"'
encode_basestring_ascii = (
@@ -79,9 +76,9 @@ class JSONEncoder(object):
+-------------------+---------------+
| list, tuple | array |
+-------------------+---------------+
- | str, unicode | string |
+ | str | string |
+-------------------+---------------+
- | int, long, float | number |
+ | int, float | number |
+-------------------+---------------+
| True | true |
+-------------------+---------------+
@@ -100,19 +97,16 @@ class JSONEncoder(object):
key_separator = ': '
def __init__(self, skipkeys=False, ensure_ascii=True,
check_circular=True, allow_nan=True, sort_keys=False,
- indent=None, separators=None, encoding='utf-8', default=None):
+ indent=None, separators=None, default=None):
"""Constructor for JSONEncoder, with sensible defaults.
If skipkeys is false, then it is a TypeError to attempt
- encoding of keys that are not str, int, long, float or None. If
+ encoding of keys that are not str, int, float or None. If
skipkeys is True, such items are simply skipped.
- If *ensure_ascii* is true (the default), all non-ASCII
- characters in the output are escaped with \uXXXX sequences,
- and the results are str instances consisting of ASCII
- characters only. If ensure_ascii is False, a result may be a
- unicode instance. This usually happens if the input contains
- unicode strings or the *encoding* parameter is used.
+ If ensure_ascii is true, the output is guaranteed to be str
+ objects with all incoming non-ASCII characters escaped. If
+ ensure_ascii is false, the output can contain non-ASCII characters.
If check_circular is true, then lists, dicts, and custom encoded
objects will be checked for circular references during encoding to
@@ -144,10 +138,6 @@ class JSONEncoder(object):
that can't otherwise be serialized. It should return a JSON encodable
version of the object or raise a ``TypeError``.
- If encoding is not None, then all input strings will be
- transformed into unicode using that encoding prior to JSON-encoding.
- The default is UTF-8.
-
"""
self.skipkeys = skipkeys
@@ -160,7 +150,6 @@ class JSONEncoder(object):
self.item_separator, self.key_separator = separators
if default is not None:
self.default = default
- self.encoding = encoding
def default(self, o):
"""Implement this method in a subclass such that it returns
@@ -190,12 +179,7 @@ class JSONEncoder(object):
"""
# This is for extremely simple cases and benchmarks.
- if isinstance(o, basestring):
- if isinstance(o, str):
- _encoding = self.encoding
- if (_encoding is not None
- and not (_encoding == 'utf-8')):
- o = o.decode(_encoding)
+ if isinstance(o, str):
if self.ensure_ascii:
return encode_basestring_ascii(o)
else:
@@ -226,11 +210,6 @@ class JSONEncoder(object):
_encoder = encode_basestring_ascii
else:
_encoder = encode_basestring
- if self.encoding != 'utf-8':
- def _encoder(o, _orig_encoder=_encoder, _encoding=self.encoding):
- if isinstance(o, str):
- o = o.decode(_encoding)
- return _orig_encoder(o)
def floatstr(o, allow_nan=self.allow_nan,
_repr=FLOAT_REPR, _inf=INFINITY, _neginf=-INFINITY):
@@ -256,7 +235,7 @@ class JSONEncoder(object):
if (_one_shot and c_make_encoder is not None
- and self.indent is None and not self.sort_keys):
+ and self.indent is None):
_iterencode = c_make_encoder(
markers, self.default, _encoder, self.indent,
self.key_separator, self.item_separator, self.sort_keys,
@@ -272,18 +251,19 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
_key_separator, _item_separator, _sort_keys, _skipkeys, _one_shot,
## HACK: hand-optimized bytecode; turn globals into locals
ValueError=ValueError,
- basestring=basestring,
dict=dict,
float=float,
id=id,
int=int,
isinstance=isinstance,
list=list,
- long=long,
str=str,
tuple=tuple,
):
+ if _indent is not None and not isinstance(_indent, str):
+ _indent = ' ' * _indent
+
def _iterencode_list(lst, _current_indent_level):
if not lst:
yield '[]'
@@ -296,7 +276,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
buf = '['
if _indent is not None:
_current_indent_level += 1
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
+ newline_indent = '\n' + _indent * _current_indent_level
separator = _item_separator + newline_indent
buf += newline_indent
else:
@@ -308,7 +288,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
first = False
else:
buf = separator
- if isinstance(value, basestring):
+ if isinstance(value, str):
yield buf + _encoder(value)
elif value is None:
yield buf + 'null'
@@ -316,7 +296,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield buf + 'true'
elif value is False:
yield buf + 'false'
- elif isinstance(value, (int, long)):
+ elif isinstance(value, int):
yield buf + str(value)
elif isinstance(value, float):
yield buf + _floatstr(value)
@@ -332,7 +312,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield chunk
if newline_indent is not None:
_current_indent_level -= 1
- yield '\n' + (' ' * (_indent * _current_indent_level))
+ yield '\n' + _indent * _current_indent_level
yield ']'
if markers is not None:
del markers[markerid]
@@ -349,7 +329,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield '{'
if _indent is not None:
_current_indent_level += 1
- newline_indent = '\n' + (' ' * (_indent * _current_indent_level))
+ newline_indent = '\n' + _indent * _current_indent_level
item_separator = _item_separator + newline_indent
yield newline_indent
else:
@@ -359,9 +339,9 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
if _sort_keys:
items = sorted(dct.items(), key=lambda kv: kv[0])
else:
- items = dct.iteritems()
+ items = dct.items()
for key, value in items:
- if isinstance(key, basestring):
+ if isinstance(key, str):
pass
# JavaScript is weakly typed for these, so it makes sense to
# also allow them. Many encoders seem to do something like this.
@@ -373,7 +353,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
key = 'false'
elif key is None:
key = 'null'
- elif isinstance(key, (int, long)):
+ elif isinstance(key, int):
key = str(key)
elif _skipkeys:
continue
@@ -385,7 +365,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield item_separator
yield _encoder(key)
yield _key_separator
- if isinstance(value, basestring):
+ if isinstance(value, str):
yield _encoder(value)
elif value is None:
yield 'null'
@@ -393,7 +373,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield 'true'
elif value is False:
yield 'false'
- elif isinstance(value, (int, long)):
+ elif isinstance(value, int):
yield str(value)
elif isinstance(value, float):
yield _floatstr(value)
@@ -408,13 +388,13 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield chunk
if newline_indent is not None:
_current_indent_level -= 1
- yield '\n' + (' ' * (_indent * _current_indent_level))
+ yield '\n' + _indent * _current_indent_level
yield '}'
if markers is not None:
del markers[markerid]
def _iterencode(o, _current_indent_level):
- if isinstance(o, basestring):
+ if isinstance(o, str):
yield _encoder(o)
elif o is None:
yield 'null'
@@ -422,7 +402,7 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield 'true'
elif o is False:
yield 'false'
- elif isinstance(o, (int, long)):
+ elif isinstance(o, int):
yield str(o)
elif isinstance(o, float):
yield _floatstr(o)
@@ -443,5 +423,4 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
yield chunk
if markers is not None:
del markers[markerid]
-
return _iterencode
diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py
index 74e6805155d..23eef61b94b 100644
--- a/Lib/json/scanner.py
+++ b/Lib/json/scanner.py
@@ -17,13 +17,13 @@ def py_make_scanner(context):
parse_array = context.parse_array
parse_string = context.parse_string
match_number = NUMBER_RE.match
- encoding = context.encoding
strict = context.strict
parse_float = context.parse_float
parse_int = context.parse_int
parse_constant = context.parse_constant
object_hook = context.object_hook
object_pairs_hook = context.object_pairs_hook
+ memo = context.memo
def _scan_once(string, idx):
try:
@@ -32,10 +32,10 @@ def py_make_scanner(context):
raise StopIteration
if nextchar == '"':
- return parse_string(string, idx + 1, encoding, strict)
+ return parse_string(string, idx + 1, strict)
elif nextchar == '{':
- return parse_object((string, idx + 1), encoding, strict,
- _scan_once, object_hook, object_pairs_hook)
+ return parse_object((string, idx + 1), strict,
+ _scan_once, object_hook, object_pairs_hook, memo)
elif nextchar == '[':
return parse_array((string, idx + 1), _scan_once)
elif nextchar == 'n' and string[idx:idx + 4] == 'null':
@@ -62,6 +62,12 @@ def py_make_scanner(context):
else:
raise StopIteration
+ def scan_once(string, idx):
+ try:
+ return _scan_once(string, idx)
+ finally:
+ memo.clear()
+
return _scan_once
make_scanner = c_make_scanner or py_make_scanner
diff --git a/Lib/json/tests/test_check_circular.py b/Lib/json/tests/test_check_circular.py
deleted file mode 100644
index 3ad3d241969..00000000000
--- a/Lib/json/tests/test_check_circular.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from json.tests import PyTest, CTest
-
-
-def default_iterable(obj):
- return list(obj)
-
-class TestCheckCircular(object):
- def test_circular_dict(self):
- dct = {}
- dct['a'] = dct
- self.assertRaises(ValueError, self.dumps, dct)
-
- def test_circular_list(self):
- lst = []
- lst.append(lst)
- self.assertRaises(ValueError, self.dumps, lst)
-
- def test_circular_composite(self):
- dct2 = {}
- dct2['a'] = []
- dct2['a'].append(dct2)
- self.assertRaises(ValueError, self.dumps, dct2)
-
- def test_circular_default(self):
- self.dumps([set()], default=default_iterable)
- self.assertRaises(TypeError, self.dumps, [set()])
-
- def test_circular_off_default(self):
- self.dumps([set()], default=default_iterable, check_circular=False)
- self.assertRaises(TypeError, self.dumps, [set()], check_circular=False)
-
-
-class TestPyCheckCircular(TestCheckCircular, PyTest): pass
-class TestCCheckCircular(TestCheckCircular, CTest): pass
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/json/tests/test_encode_basestring_ascii.py
deleted file mode 100644
index 9f9d5a5deb4..00000000000
--- a/Lib/json/tests/test_encode_basestring_ascii.py
+++ /dev/null
@@ -1,41 +0,0 @@
-from collections import OrderedDict
-from json.tests import PyTest, CTest
-
-
-CASES = [
- (u'/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'),
- (u'\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
- (u'controls', '"controls"'),
- (u'\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
- (u'{"object with 1 member":["array with 1 element"]}', '"{\\"object with 1 member\\":[\\"array with 1 element\\"]}"'),
- (u' s p a c e d ', '" s p a c e d "'),
- (u'\U0001d120', '"\\ud834\\udd20"'),
- (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
- ('\xce\xb1\xce\xa9', '"\\u03b1\\u03a9"'),
- (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
- ('\xce\xb1\xce\xa9', '"\\u03b1\\u03a9"'),
- (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
- (u'\u03b1\u03a9', '"\\u03b1\\u03a9"'),
- (u"`1~!@#$%^&*()_+-={':[,]}|;.</>?", '"`1~!@#$%^&*()_+-={\':[,]}|;.</>?"'),
- (u'\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
- (u'\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
-]
-
-class TestEncodeBasestringAscii(object):
- def test_encode_basestring_ascii(self):
- fname = self.json.encoder.encode_basestring_ascii.__name__
- for input_string, expect in CASES:
- result = self.json.encoder.encode_basestring_ascii(input_string)
- self.assertEqual(result, expect,
- '{0!r} != {1!r} for {2}({3!r})'.format(
- result, expect, fname, input_string))
-
- def test_ordered_dict(self):
- # See issue 6105
- items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
- s = self.dumps(OrderedDict(items))
- self.assertEqual(s, '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}')
-
-
-class TestPyEncodeBasestringAscii(TestEncodeBasestringAscii, PyTest): pass
-class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest): pass
diff --git a/Lib/json/tests/test_scanstring.py b/Lib/json/tests/test_scanstring.py
deleted file mode 100644
index 4fef8cbabf9..00000000000
--- a/Lib/json/tests/test_scanstring.py
+++ /dev/null
@@ -1,109 +0,0 @@
-import sys
-from json.tests import PyTest, CTest
-
-
-class TestScanstring(object):
- def test_scanstring(self):
- scanstring = self.json.decoder.scanstring
- self.assertEqual(
- scanstring('"z\\ud834\\udd20x"', 1, None, True),
- (u'z\U0001d120x', 16))
-
- if sys.maxunicode == 65535:
- self.assertEqual(
- scanstring(u'"z\U0001d120x"', 1, None, True),
- (u'z\U0001d120x', 6))
- else:
- self.assertEqual(
- scanstring(u'"z\U0001d120x"', 1, None, True),
- (u'z\U0001d120x', 5))
-
- self.assertEqual(
- scanstring('"\\u007b"', 1, None, True),
- (u'{', 8))
-
- self.assertEqual(
- scanstring('"A JSON payload should be an object or array, not a string."', 1, None, True),
- (u'A JSON payload should be an object or array, not a string.', 60))
-
- self.assertEqual(
- scanstring('["Unclosed array"', 2, None, True),
- (u'Unclosed array', 17))
-
- self.assertEqual(
- scanstring('["extra comma",]', 2, None, True),
- (u'extra comma', 14))
-
- self.assertEqual(
- scanstring('["double extra comma",,]', 2, None, True),
- (u'double extra comma', 21))
-
- self.assertEqual(
- scanstring('["Comma after the close"],', 2, None, True),
- (u'Comma after the close', 24))
-
- self.assertEqual(
- scanstring('["Extra close"]]', 2, None, True),
- (u'Extra close', 14))
-
- self.assertEqual(
- scanstring('{"Extra comma": true,}', 2, None, True),
- (u'Extra comma', 14))
-
- self.assertEqual(
- scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, None, True),
- (u'Extra value after close', 26))
-
- self.assertEqual(
- scanstring('{"Illegal expression": 1 + 2}', 2, None, True),
- (u'Illegal expression', 21))
-
- self.assertEqual(
- scanstring('{"Illegal invocation": alert()}', 2, None, True),
- (u'Illegal invocation', 21))
-
- self.assertEqual(
- scanstring('{"Numbers cannot have leading zeroes": 013}', 2, None, True),
- (u'Numbers cannot have leading zeroes', 37))
-
- self.assertEqual(
- scanstring('{"Numbers cannot be hex": 0x14}', 2, None, True),
- (u'Numbers cannot be hex', 24))
-
- self.assertEqual(
- scanstring('[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', 21, None, True),
- (u'Too deep', 30))
-
- self.assertEqual(
- scanstring('{"Missing colon" null}', 2, None, True),
- (u'Missing colon', 16))
-
- self.assertEqual(
- scanstring('{"Double colon":: null}', 2, None, True),
- (u'Double colon', 15))
-
- self.assertEqual(
- scanstring('{"Comma instead of colon", null}', 2, None, True),
- (u'Comma instead of colon', 25))
-
- self.assertEqual(
- scanstring('["Colon instead of comma": false]', 2, None, True),
- (u'Colon instead of comma', 25))
-
- self.assertEqual(
- scanstring('["Bad value", truth]', 2, None, True),
- (u'Bad value', 12))
-
- def test_issue3623(self):
- self.assertRaises(ValueError, self.json.decoder.scanstring, b"xxx", 1,
- "xxx")
- self.assertRaises(UnicodeDecodeError,
- self.json.encoder.encode_basestring_ascii, b"xx\xff")
-
- def test_overflow(self):
- with self.assertRaises(OverflowError):
- self.json.decoder.scanstring(b"xxx", sys.maxsize+1)
-
-
-class TestPyScanstring(TestScanstring, PyTest): pass
-class TestCScanstring(TestScanstring, CTest): pass
diff --git a/Lib/json/tests/test_unicode.py b/Lib/json/tests/test_unicode.py
deleted file mode 100644
index e90f1586063..00000000000
--- a/Lib/json/tests/test_unicode.py
+++ /dev/null
@@ -1,89 +0,0 @@
-from collections import OrderedDict
-from json.tests import PyTest, CTest
-
-
-class TestUnicode(object):
- def test_encoding1(self):
- encoder = self.json.JSONEncoder(encoding='utf-8')
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- s = u.encode('utf-8')
- ju = encoder.encode(u)
- js = encoder.encode(s)
- self.assertEqual(ju, js)
-
- def test_encoding2(self):
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- s = u.encode('utf-8')
- ju = self.dumps(u, encoding='utf-8')
- js = self.dumps(s, encoding='utf-8')
- self.assertEqual(ju, js)
-
- def test_encoding3(self):
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- j = self.dumps(u)
- self.assertEqual(j, '"\\u03b1\\u03a9"')
-
- def test_encoding4(self):
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- j = self.dumps([u])
- self.assertEqual(j, '["\\u03b1\\u03a9"]')
-
- def test_encoding5(self):
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- j = self.dumps(u, ensure_ascii=False)
- self.assertEqual(j, u'"{0}"'.format(u))
-
- def test_encoding6(self):
- u = u'\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
- j = self.dumps([u], ensure_ascii=False)
- self.assertEqual(j, u'["{0}"]'.format(u))
-
- def test_big_unicode_encode(self):
- u = u'\U0001d120'
- self.assertEqual(self.dumps(u), '"\\ud834\\udd20"')
- self.assertEqual(self.dumps(u, ensure_ascii=False), u'"\U0001d120"')
-
- def test_big_unicode_decode(self):
- u = u'z\U0001d120x'
- self.assertEqual(self.loads('"' + u + '"'), u)
- self.assertEqual(self.loads('"z\\ud834\\udd20x"'), u)
-
- def test_unicode_decode(self):
- for i in range(0, 0xd7ff):
- u = unichr(i)
- s = '"\\u{0:04x}"'.format(i)
- self.assertEqual(self.loads(s), u)
-
- def test_object_pairs_hook_with_unicode(self):
- s = u'{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
- p = [(u"xkd", 1), (u"kcw", 2), (u"art", 3), (u"hxm", 4),
- (u"qrt", 5), (u"pad", 6), (u"hoy", 7)]
- self.assertEqual(self.loads(s), eval(s))
- self.assertEqual(self.loads(s, object_pairs_hook = lambda x: x), p)
- od = self.loads(s, object_pairs_hook = OrderedDict)
- self.assertEqual(od, OrderedDict(p))
- self.assertEqual(type(od), OrderedDict)
- # the object_pairs_hook takes priority over the object_hook
- self.assertEqual(self.loads(s,
- object_pairs_hook = OrderedDict,
- object_hook = lambda x: None),
- OrderedDict(p))
-
- def test_default_encoding(self):
- self.assertEqual(self.loads(u'{"a": "\xe9"}'.encode('utf-8')),
- {'a': u'\xe9'})
-
- def test_unicode_preservation(self):
- self.assertEqual(type(self.loads(u'""')), unicode)
- self.assertEqual(type(self.loads(u'"a"')), unicode)
- self.assertEqual(type(self.loads(u'["a"]')[0]), unicode)
- # Issue 10038.
- self.assertEqual(type(self.loads('"foo"')), unicode)
-
- def test_bad_encoding(self):
- self.assertRaises(UnicodeEncodeError, self.loads, '"a"', u"rat\xe9")
- self.assertRaises(TypeError, self.loads, '"a"', 1)
-
-
-class TestPyUnicode(TestUnicode, PyTest): pass
-class TestCUnicode(TestUnicode, CTest): pass
diff --git a/Lib/json/tool.py b/Lib/json/tool.py
index fe47c52d416..0f108c6dae4 100644
--- a/Lib/json/tool.py
+++ b/Lib/json/tool.py
@@ -18,17 +18,17 @@ def main():
infile = sys.stdin
outfile = sys.stdout
elif len(sys.argv) == 2:
- infile = open(sys.argv[1], 'rb')
+ infile = open(sys.argv[1], 'r')
outfile = sys.stdout
elif len(sys.argv) == 3:
- infile = open(sys.argv[1], 'rb')
- outfile = open(sys.argv[2], 'wb')
+ infile = open(sys.argv[1], 'r')
+ outfile = open(sys.argv[2], 'w')
else:
raise SystemExit(sys.argv[0] + " [infile [outfile]]")
with infile:
try:
obj = json.load(infile)
- except ValueError, e:
+ except ValueError as e:
raise SystemExit(e)
with outfile:
json.dump(obj, outfile, sort_keys=True,
diff --git a/Lib/keyword.py b/Lib/keyword.py
index 69794bda8c8..dad39cc3779 100755
--- a/Lib/keyword.py
+++ b/Lib/keyword.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Keywords (from "graminit.c")
@@ -14,6 +14,9 @@ __all__ = ["iskeyword", "kwlist"]
kwlist = [
#--start keywords--
+ 'False',
+ 'None',
+ 'True',
'and',
'as',
'assert',
@@ -25,7 +28,6 @@ kwlist = [
'elif',
'else',
'except',
- 'exec',
'finally',
'for',
'from',
@@ -35,10 +37,10 @@ kwlist = [
'in',
'is',
'lambda',
+ 'nonlocal',
'not',
'or',
'pass',
- 'print',
'raise',
'return',
'try',
@@ -59,21 +61,19 @@ def main():
else: optfile = "Lib/keyword.py"
# scan the source file for keywords
- fp = open(iptfile)
- strprog = re.compile('"([^"]+)"')
- lines = []
- for line in fp:
- if '{1, "' in line:
- match = strprog.search(line)
- if match:
- lines.append(" '" + match.group(1) + "',\n")
- fp.close()
+ with open(iptfile) as fp:
+ strprog = re.compile('"([^"]+)"')
+ lines = []
+ for line in fp:
+ if '{1, "' in line:
+ match = strprog.search(line)
+ if match:
+ lines.append(" '" + match.group(1) + "',\n")
lines.sort()
# load the output skeleton from the target
- fp = open(optfile)
- format = fp.readlines()
- fp.close()
+ with open(optfile) as fp:
+ format = fp.readlines()
# insert the lines of keywords
try:
diff --git a/Lib/lib-tk/Canvas.py b/Lib/lib-tk/Canvas.py
deleted file mode 100644
index 34464ab979f..00000000000
--- a/Lib/lib-tk/Canvas.py
+++ /dev/null
@@ -1,194 +0,0 @@
-# This module exports classes for the various canvas item types
-
-# NOTE: This module was an experiment and is now obsolete.
-# It's best to use the Tkinter.Canvas class directly.
-
-from warnings import warnpy3k
-warnpy3k("the Canvas module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-from Tkinter import Canvas, _cnfmerge, _flatten
-
-
-class CanvasItem:
- def __init__(self, canvas, itemType, *args, **kw):
- self.canvas = canvas
- self.id = canvas._create(itemType, args, kw)
- if not hasattr(canvas, 'items'):
- canvas.items = {}
- canvas.items[self.id] = self
- def __str__(self):
- return str(self.id)
- def __repr__(self):
- return '<%s, id=%d>' % (self.__class__.__name__, self.id)
- def delete(self):
- del self.canvas.items[self.id]
- self.canvas.delete(self.id)
- def __getitem__(self, key):
- v = self.canvas.tk.split(self.canvas.tk.call(
- self.canvas._w, 'itemconfigure',
- self.id, '-' + key))
- return v[4]
- cget = __getitem__
- def __setitem__(self, key, value):
- self.canvas.itemconfig(self.id, {key: value})
- def keys(self):
- if not hasattr(self, '_keys'):
- self._keys = map(lambda x, tk=self.canvas.tk:
- tk.splitlist(x)[0][1:],
- self.canvas.tk.splitlist(
- self.canvas._do(
- 'itemconfigure',
- (self.id,))))
- return self._keys
- def has_key(self, key):
- return key in self.keys()
- def __contains__(self, key):
- return key in self.keys()
- def addtag(self, tag, option='withtag'):
- self.canvas.addtag(tag, option, self.id)
- def bbox(self):
- x1, y1, x2, y2 = self.canvas.bbox(self.id)
- return (x1, y1), (x2, y2)
- def bind(self, sequence=None, command=None, add=None):
- return self.canvas.tag_bind(self.id, sequence, command, add)
- def unbind(self, sequence, funcid=None):
- self.canvas.tag_unbind(self.id, sequence, funcid)
- def config(self, cnf={}, **kw):
- return self.canvas.itemconfig(self.id, _cnfmerge((cnf, kw)))
- def coords(self, pts = ()):
- flat = ()
- for x, y in pts: flat = flat + (x, y)
- return self.canvas.coords(self.id, *flat)
- def dchars(self, first, last=None):
- self.canvas.dchars(self.id, first, last)
- def dtag(self, ttd):
- self.canvas.dtag(self.id, ttd)
- def focus(self):
- self.canvas.focus(self.id)
- def gettags(self):
- return self.canvas.gettags(self.id)
- def icursor(self, index):
- self.canvas.icursor(self.id, index)
- def index(self, index):
- return self.canvas.index(self.id, index)
- def insert(self, beforethis, string):
- self.canvas.insert(self.id, beforethis, string)
- def lower(self, belowthis=None):
- self.canvas.tag_lower(self.id, belowthis)
- def move(self, xamount, yamount):
- self.canvas.move(self.id, xamount, yamount)
- def tkraise(self, abovethis=None):
- self.canvas.tag_raise(self.id, abovethis)
- raise_ = tkraise # BW compat
- def scale(self, xorigin, yorigin, xscale, yscale):
- self.canvas.scale(self.id, xorigin, yorigin, xscale, yscale)
- def type(self):
- return self.canvas.type(self.id)
-
-class Arc(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'arc', *args, **kw)
-
-class Bitmap(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'bitmap', *args, **kw)
-
-class ImageItem(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'image', *args, **kw)
-
-class Line(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'line', *args, **kw)
-
-class Oval(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'oval', *args, **kw)
-
-class Polygon(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'polygon', *args, **kw)
-
-class Rectangle(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'rectangle', *args, **kw)
-
-# XXX "Text" is taken by the Text widget...
-class CanvasText(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'text', *args, **kw)
-
-class Window(CanvasItem):
- def __init__(self, canvas, *args, **kw):
- CanvasItem.__init__(self, canvas, 'window', *args, **kw)
-
-class Group:
- def __init__(self, canvas, tag=None):
- if not tag:
- tag = 'Group%d' % id(self)
- self.tag = self.id = tag
- self.canvas = canvas
- self.canvas.dtag(self.tag)
- def str(self):
- return self.tag
- __str__ = str
- def _do(self, cmd, *args):
- return self.canvas._do(cmd, (self.tag,) + _flatten(args))
- def addtag_above(self, tagOrId):
- self._do('addtag', 'above', tagOrId)
- def addtag_all(self):
- self._do('addtag', 'all')
- def addtag_below(self, tagOrId):
- self._do('addtag', 'below', tagOrId)
- def addtag_closest(self, x, y, halo=None, start=None):
- self._do('addtag', 'closest', x, y, halo, start)
- def addtag_enclosed(self, x1, y1, x2, y2):
- self._do('addtag', 'enclosed', x1, y1, x2, y2)
- def addtag_overlapping(self, x1, y1, x2, y2):
- self._do('addtag', 'overlapping', x1, y1, x2, y2)
- def addtag_withtag(self, tagOrId):
- self._do('addtag', 'withtag', tagOrId)
- def bbox(self):
- return self.canvas._getints(self._do('bbox'))
- def bind(self, sequence=None, command=None, add=None):
- return self.canvas.tag_bind(self.id, sequence, command, add)
- def unbind(self, sequence, funcid=None):
- self.canvas.tag_unbind(self.id, sequence, funcid)
- def coords(self, *pts):
- return self._do('coords', pts)
- def dchars(self, first, last=None):
- self._do('dchars', first, last)
- def delete(self):
- self._do('delete')
- def dtag(self, tagToDelete=None):
- self._do('dtag', tagToDelete)
- def focus(self):
- self._do('focus')
- def gettags(self):
- return self.canvas.tk.splitlist(self._do('gettags', self.tag))
- def icursor(self, index):
- return self._do('icursor', index)
- def index(self, index):
- return self.canvas.tk.getint(self._do('index', index))
- def insert(self, beforeThis, string):
- self._do('insert', beforeThis, string)
- def config(self, cnf={}, **kw):
- return self.canvas.itemconfigure(self.tag, _cnfmerge((cnf,kw)))
- def lower(self, belowThis=None):
- self._do('lower', belowThis)
- def move(self, xAmount, yAmount):
- self._do('move', xAmount, yAmount)
- def tkraise(self, aboveThis=None):
- self._do('raise', aboveThis)
- lift = tkraise
- def scale(self, xOrigin, yOrigin, xScale, yScale):
- self._do('scale', xOrigin, yOrigin, xScale, yScale)
- def select_adjust(self, index):
- self.canvas._do('select', ('adjust', self.tag, index))
- def select_from(self, index):
- self.canvas._do('select', ('from', self.tag, index))
- def select_to(self, index):
- self.canvas._do('select', ('to', self.tag, index))
- def type(self):
- return self._do('type')
diff --git a/Lib/lib-tk/SimpleDialog.py b/Lib/lib-tk/SimpleDialog.py
deleted file mode 100644
index cb08318dbdd..00000000000
--- a/Lib/lib-tk/SimpleDialog.py
+++ /dev/null
@@ -1,112 +0,0 @@
-"""A simple but flexible modal dialog box."""
-
-
-from Tkinter import *
-
-
-class SimpleDialog:
-
- def __init__(self, master,
- text='', buttons=[], default=None, cancel=None,
- title=None, class_=None):
- if class_:
- self.root = Toplevel(master, class_=class_)
- else:
- self.root = Toplevel(master)
- if title:
- self.root.title(title)
- self.root.iconname(title)
- self.message = Message(self.root, text=text, aspect=400)
- self.message.pack(expand=1, fill=BOTH)
- self.frame = Frame(self.root)
- self.frame.pack()
- self.num = default
- self.cancel = cancel
- self.default = default
- self.root.bind('<Return>', self.return_event)
- for num in range(len(buttons)):
- s = buttons[num]
- b = Button(self.frame, text=s,
- command=(lambda self=self, num=num: self.done(num)))
- if num == default:
- b.config(relief=RIDGE, borderwidth=8)
- b.pack(side=LEFT, fill=BOTH, expand=1)
- self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
- self._set_transient(master)
-
- def _set_transient(self, master, relx=0.5, rely=0.3):
- widget = self.root
- widget.withdraw() # Remain invisible while we figure out the geometry
- widget.transient(master)
- widget.update_idletasks() # Actualize geometry information
- if master.winfo_ismapped():
- m_width = master.winfo_width()
- m_height = master.winfo_height()
- m_x = master.winfo_rootx()
- m_y = master.winfo_rooty()
- else:
- m_width = master.winfo_screenwidth()
- m_height = master.winfo_screenheight()
- m_x = m_y = 0
- w_width = widget.winfo_reqwidth()
- w_height = widget.winfo_reqheight()
- x = m_x + (m_width - w_width) * relx
- y = m_y + (m_height - w_height) * rely
- if x+w_width > master.winfo_screenwidth():
- x = master.winfo_screenwidth() - w_width
- elif x < 0:
- x = 0
- if y+w_height > master.winfo_screenheight():
- y = master.winfo_screenheight() - w_height
- elif y < 0:
- y = 0
- widget.geometry("+%d+%d" % (x, y))
- widget.deiconify() # Become visible at the desired location
-
- def go(self):
- self.root.wait_visibility()
- self.root.grab_set()
- self.root.mainloop()
- self.root.destroy()
- return self.num
-
- def return_event(self, event):
- if self.default is None:
- self.root.bell()
- else:
- self.done(self.default)
-
- def wm_delete_window(self):
- if self.cancel is None:
- self.root.bell()
- else:
- self.done(self.cancel)
-
- def done(self, num):
- self.num = num
- self.root.quit()
-
-
-if __name__ == '__main__':
-
- def test():
- root = Tk()
- def doit(root=root):
- d = SimpleDialog(root,
- text="This is a test dialog. "
- "Would this have been an actual dialog, "
- "the buttons below would have been glowing "
- "in soft pink light.\n"
- "Do you believe this?",
- buttons=["Yes", "No", "Cancel"],
- default=0,
- cancel=2,
- title="Test Dialog")
- print d.go()
- t = Button(root, text='Test', command=doit)
- t.pack()
- q = Button(root, text='Quit', command=t.quit)
- q.pack()
- t.mainloop()
-
- test()
diff --git a/Lib/lib-tk/test/runtktests.py b/Lib/lib-tk/test/runtktests.py
deleted file mode 100644
index 95e17288619..00000000000
--- a/Lib/lib-tk/test/runtktests.py
+++ /dev/null
@@ -1,114 +0,0 @@
-"""
-Use this module to get and run all tk tests.
-
-Tkinter tests should live in a package inside the directory where this file
-lives, like test_tkinter.
-Extensions also should live in packages following the same rule as above.
-"""
-
-import os
-import sys
-import unittest
-import importlib
-import test.test_support
-
-this_dir_path = os.path.abspath(os.path.dirname(__file__))
-
-_tk_unavailable = None
-
-def check_tk_availability():
- """Check that Tk is installed and available."""
- global _tk_unavailable
-
- if _tk_unavailable is None:
- _tk_unavailable = False
- if sys.platform == 'darwin':
- # The Aqua Tk implementations on OS X can abort the process if
- # being called in an environment where a window server connection
- # cannot be made, for instance when invoked by a buildbot or ssh
- # process not running under the same user id as the current console
- # user. To avoid that, raise an exception if the window manager
- # connection is not available.
- from ctypes import cdll, c_int, pointer, Structure
- from ctypes.util import find_library
-
- app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
-
- if app_services.CGMainDisplayID() == 0:
- _tk_unavailable = "cannot run without OS X window manager"
- else:
- class ProcessSerialNumber(Structure):
- _fields_ = [("highLongOfPSN", c_int),
- ("lowLongOfPSN", c_int)]
- psn = ProcessSerialNumber()
- psn_p = pointer(psn)
- if ( (app_services.GetCurrentProcess(psn_p) < 0) or
- (app_services.SetFrontProcess(psn_p) < 0) ):
- _tk_unavailable = "cannot run without OS X gui process"
- else: # not OS X
- import Tkinter
- try:
- Tkinter.Button()
- except Tkinter.TclError as msg:
- # assuming tk is not available
- _tk_unavailable = "tk not available: %s" % msg
-
- if _tk_unavailable:
- raise unittest.SkipTest(_tk_unavailable)
- return
-
-def is_package(path):
- for name in os.listdir(path):
- if name in ('__init__.py', '__init__.pyc', '__init.pyo'):
- return True
- return False
-
-def get_tests_modules(basepath=this_dir_path, gui=True, packages=None):
- """This will import and yield modules whose names start with test_
- and are inside packages found in the path starting at basepath.
-
- If packages is specified it should contain package names that want
- their tests colleted.
- """
- py_ext = '.py'
-
- for dirpath, dirnames, filenames in os.walk(basepath):
- for dirname in list(dirnames):
- if dirname[0] == '.':
- dirnames.remove(dirname)
-
- if is_package(dirpath) and filenames:
- pkg_name = dirpath[len(basepath) + len(os.sep):].replace('/', '.')
- if packages and pkg_name not in packages:
- continue
-
- filenames = filter(
- lambda x: x.startswith('test_') and x.endswith(py_ext),
- filenames)
-
- for name in filenames:
- try:
- yield importlib.import_module(
- ".%s" % name[:-len(py_ext)], pkg_name)
- except test.test_support.ResourceDenied:
- if gui:
- raise
-
-def get_tests(text=True, gui=True, packages=None):
- """Yield all the tests in the modules found by get_tests_modules.
-
- If nogui is True, only tests that do not require a GUI will be
- returned."""
- attrs = []
- if text:
- attrs.append('tests_nogui')
- if gui:
- attrs.append('tests_gui')
- for module in get_tests_modules(gui=gui, packages=packages):
- for attr in attrs:
- for test in getattr(module, attr, ()):
- yield test
-
-if __name__ == "__main__":
- test.test_support.use_resources = ['gui']
- test.test_support.run_unittest(*get_tests())
diff --git a/Lib/lib-tk/test/test_ttk/support.py b/Lib/lib-tk/test/test_ttk/support.py
deleted file mode 100644
index 57e7803ec32..00000000000
--- a/Lib/lib-tk/test/test_ttk/support.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import Tkinter
-
-def get_tk_root():
- try:
- root = Tkinter._default_root
- except AttributeError:
- # it is possible to disable default root in Tkinter, although
- # I haven't seen people doing it (but apparently someone did it
- # here).
- root = None
-
- if root is None:
- # create a new master only if there isn't one already
- root = Tkinter.Tk()
-
- return root
-
-def root_deiconify():
- root = get_tk_root()
- root.deiconify()
-
-def root_withdraw():
- root = get_tk_root()
- root.withdraw()
-
-
-def simulate_mouse_click(widget, x, y):
- """Generate proper events to click at the x, y position (tries to act
- like an X server)."""
- widget.event_generate('<Enter>', x=0, y=0)
- widget.event_generate('<Motion>', x=x, y=y)
- widget.event_generate('<ButtonPress-1>', x=x, y=y)
- widget.event_generate('<ButtonRelease-1>', x=x, y=y)
diff --git a/Lib/lib-tk/tkFileDialog.py b/Lib/lib-tk/tkFileDialog.py
deleted file mode 100644
index 15c7d5f606d..00000000000
--- a/Lib/lib-tk/tkFileDialog.py
+++ /dev/null
@@ -1,215 +0,0 @@
-#
-# Instant Python
-# $Id: tkFileDialog.py 36560 2004-07-18 06:16:08Z tim_one $
-#
-# tk common file dialogues
-#
-# this module provides interfaces to the native file dialogues
-# available in Tk 4.2 and newer, and the directory dialogue available
-# in Tk 8.3 and newer.
-#
-# written by Fredrik Lundh, May 1997.
-#
-
-#
-# options (all have default values):
-#
-# - defaultextension: added to filename if not explicitly given
-#
-# - filetypes: sequence of (label, pattern) tuples. the same pattern
-# may occur with several patterns. use "*" as pattern to indicate
-# all files.
-#
-# - initialdir: initial directory. preserved by dialog instance.
-#
-# - initialfile: initial file (ignored by the open dialog). preserved
-# by dialog instance.
-#
-# - parent: which window to place the dialog on top of
-#
-# - title: dialog title
-#
-# - multiple: if true user may select more than one file
-#
-# options for the directory chooser:
-#
-# - initialdir, parent, title: see above
-#
-# - mustexist: if true, user must pick an existing directory
-#
-#
-
-
-from tkCommonDialog import Dialog
-
-class _Dialog(Dialog):
-
- def _fixoptions(self):
- try:
- # make sure "filetypes" is a tuple
- self.options["filetypes"] = tuple(self.options["filetypes"])
- except KeyError:
- pass
-
- def _fixresult(self, widget, result):
- if result:
- # keep directory and filename until next time
- import os
- # convert Tcl path objects to strings
- try:
- result = result.string
- except AttributeError:
- # it already is a string
- pass
- path, file = os.path.split(result)
- self.options["initialdir"] = path
- self.options["initialfile"] = file
- self.filename = result # compatibility
- return result
-
-
-#
-# file dialogs
-
-class Open(_Dialog):
- "Ask for a filename to open"
-
- command = "tk_getOpenFile"
-
- def _fixresult(self, widget, result):
- if isinstance(result, tuple):
- # multiple results:
- result = tuple([getattr(r, "string", r) for r in result])
- if result:
- import os
- path, file = os.path.split(result[0])
- self.options["initialdir"] = path
- # don't set initialfile or filename, as we have multiple of these
- return result
- if not widget.tk.wantobjects() and "multiple" in self.options:
- # Need to split result explicitly
- return self._fixresult(widget, widget.tk.splitlist(result))
- return _Dialog._fixresult(self, widget, result)
-
-class SaveAs(_Dialog):
- "Ask for a filename to save as"
-
- command = "tk_getSaveFile"
-
-
-# the directory dialog has its own _fix routines.
-class Directory(Dialog):
- "Ask for a directory"
-
- command = "tk_chooseDirectory"
-
- def _fixresult(self, widget, result):
- if result:
- # convert Tcl path objects to strings
- try:
- result = result.string
- except AttributeError:
- # it already is a string
- pass
- # keep directory until next time
- self.options["initialdir"] = result
- self.directory = result # compatibility
- return result
-
-#
-# convenience stuff
-
-def askopenfilename(**options):
- "Ask for a filename to open"
-
- return Open(**options).show()
-
-def asksaveasfilename(**options):
- "Ask for a filename to save as"
-
- return SaveAs(**options).show()
-
-def askopenfilenames(**options):
- """Ask for multiple filenames to open
-
- Returns a list of filenames or empty list if
- cancel button selected
- """
- options["multiple"]=1
- return Open(**options).show()
-
-# FIXME: are the following perhaps a bit too convenient?
-
-def askopenfile(mode = "r", **options):
- "Ask for a filename to open, and returned the opened file"
-
- filename = Open(**options).show()
- if filename:
- return open(filename, mode)
- return None
-
-def askopenfiles(mode = "r", **options):
- """Ask for multiple filenames and return the open file
- objects
-
- returns a list of open file objects or an empty list if
- cancel selected
- """
-
- files = askopenfilenames(**options)
- if files:
- ofiles=[]
- for filename in files:
- ofiles.append(open(filename, mode))
- files=ofiles
- return files
-
-
-def asksaveasfile(mode = "w", **options):
- "Ask for a filename to save as, and returned the opened file"
-
- filename = SaveAs(**options).show()
- if filename:
- return open(filename, mode)
- return None
-
-def askdirectory (**options):
- "Ask for a directory, and return the file name"
- return Directory(**options).show()
-
-# --------------------------------------------------------------------
-# test stuff
-
-if __name__ == "__main__":
- # Since the file name may contain non-ASCII characters, we need
- # to find an encoding that likely supports the file name, and
- # displays correctly on the terminal.
-
- # Start off with UTF-8
- enc = "utf-8"
- import sys
-
- # See whether CODESET is defined
- try:
- import locale
- locale.setlocale(locale.LC_ALL,'')
- enc = locale.nl_langinfo(locale.CODESET)
- except (ImportError, AttributeError):
- pass
-
- # dialog for openening files
-
- openfilename=askopenfilename(filetypes=[("all files", "*")])
- try:
- fp=open(openfilename,"r")
- fp.close()
- except:
- print "Could not open File: "
- print sys.exc_info()[1]
-
- print "open", openfilename.encode(enc)
-
- # dialog for saving files
-
- saveasfilename=asksaveasfilename()
- print "saveas", saveasfilename.encode(enc)
diff --git a/Lib/lib2to3/__main__.py b/Lib/lib2to3/__main__.py
deleted file mode 100644
index 80688baf27a..00000000000
--- a/Lib/lib2to3/__main__.py
+++ /dev/null
@@ -1,4 +0,0 @@
-import sys
-from .main import main
-
-sys.exit(main("lib2to3.fixes"))
diff --git a/Lib/lib2to3/btm_matcher.py b/Lib/lib2to3/btm_matcher.py
index 736ba2b9d83..eabe1a71a65 100644
--- a/Lib/lib2to3/btm_matcher.py
+++ b/Lib/lib2to3/btm_matcher.py
@@ -104,7 +104,7 @@ class BottomMatcher(object):
current_ast_node.was_checked = True
for child in current_ast_node.children:
# multiple statements, recheck
- if isinstance(child, pytree.Leaf) and child.value == u";":
+ if isinstance(child, pytree.Leaf) and child.value == ";":
current_ast_node.was_checked = False
break
if current_ast_node.type == 1:
diff --git a/Lib/lib2to3/fixer_base.py b/Lib/lib2to3/fixer_base.py
index f6421ba3f74..afc04670003 100644
--- a/Lib/lib2to3/fixer_base.py
+++ b/Lib/lib2to3/fixer_base.py
@@ -105,14 +105,14 @@ class BaseFix(object):
"""
raise NotImplementedError()
- def new_name(self, template=u"xxx_todo_changeme"):
+ def new_name(self, template="xxx_todo_changeme"):
"""Return a string suitable for use as an identifier
The new name is guaranteed not to conflict with other identifiers.
"""
name = template
while name in self.used_names:
- name = template + unicode(self.numbers.next())
+ name = template + str(next(self.numbers))
self.used_names.add(name)
return name
@@ -131,7 +131,7 @@ class BaseFix(object):
"""
lineno = node.get_lineno()
for_output = node.clone()
- for_output.prefix = u""
+ for_output.prefix = ""
msg = "Line %d: could not convert: %s"
self.log_message(msg % (lineno, for_output))
if reason:
diff --git a/Lib/lib2to3/fixer_util.py b/Lib/lib2to3/fixer_util.py
index 78fdf26dce4..60d219f5770 100644
--- a/Lib/lib2to3/fixer_util.py
+++ b/Lib/lib2to3/fixer_util.py
@@ -16,24 +16,24 @@ from . import patcomp
def KeywordArg(keyword, value):
return Node(syms.argument,
- [keyword, Leaf(token.EQUAL, u"="), value])
+ [keyword, Leaf(token.EQUAL, "="), value])
def LParen():
- return Leaf(token.LPAR, u"(")
+ return Leaf(token.LPAR, "(")
def RParen():
- return Leaf(token.RPAR, u")")
+ return Leaf(token.RPAR, ")")
def Assign(target, source):
"""Build an assignment statement"""
if not isinstance(target, list):
target = [target]
if not isinstance(source, list):
- source.prefix = u" "
+ source.prefix = " "
source = [source]
return Node(syms.atom,
- target + [Leaf(token.EQUAL, u"=", prefix=u" ")] + source)
+ target + [Leaf(token.EQUAL, "=", prefix=" ")] + source)
def Name(name, prefix=None):
"""Return a NAME leaf"""
@@ -45,11 +45,11 @@ def Attr(obj, attr):
def Comma():
"""A comma leaf"""
- return Leaf(token.COMMA, u",")
+ return Leaf(token.COMMA, ",")
def Dot():
"""A period (.) leaf"""
- return Leaf(token.DOT, u".")
+ return Leaf(token.DOT, ".")
def ArgList(args, lparen=LParen(), rparen=RParen()):
"""A parenthesised argument list, used by Call()"""
@@ -67,20 +67,20 @@ def Call(func_name, args=None, prefix=None):
def Newline():
"""A newline literal"""
- return Leaf(token.NEWLINE, u"\n")
+ return Leaf(token.NEWLINE, "\n")
def BlankLine():
"""A blank line"""
- return Leaf(token.NEWLINE, u"")
+ return Leaf(token.NEWLINE, "")
def Number(n, prefix=None):
return Leaf(token.NUMBER, n, prefix=prefix)
def Subscript(index_node):
"""A numeric or string subscript"""
- return Node(syms.trailer, [Leaf(token.LBRACE, u"["),
+ return Node(syms.trailer, [Leaf(token.LBRACE, "["),
index_node,
- Leaf(token.RBRACE, u"]")])
+ Leaf(token.RBRACE, "]")])
def String(string, prefix=None):
"""A string leaf"""
@@ -91,24 +91,24 @@ def ListComp(xp, fp, it, test=None):
If test is None, the "if test" part is omitted.
"""
- xp.prefix = u""
- fp.prefix = u" "
- it.prefix = u" "
- for_leaf = Leaf(token.NAME, u"for")
- for_leaf.prefix = u" "
- in_leaf = Leaf(token.NAME, u"in")
- in_leaf.prefix = u" "
+ xp.prefix = ""
+ fp.prefix = " "
+ it.prefix = " "
+ for_leaf = Leaf(token.NAME, "for")
+ for_leaf.prefix = " "
+ in_leaf = Leaf(token.NAME, "in")
+ in_leaf.prefix = " "
inner_args = [for_leaf, fp, in_leaf, it]
if test:
- test.prefix = u" "
- if_leaf = Leaf(token.NAME, u"if")
- if_leaf.prefix = u" "
+ test.prefix = " "
+ if_leaf = Leaf(token.NAME, "if")
+ if_leaf.prefix = " "
inner_args.append(Node(syms.comp_if, [if_leaf, test]))
inner = Node(syms.listmaker, [xp, Node(syms.comp_for, inner_args)])
return Node(syms.atom,
- [Leaf(token.LBRACE, u"["),
+ [Leaf(token.LBRACE, "["),
inner,
- Leaf(token.RBRACE, u"]")])
+ Leaf(token.RBRACE, "]")])
def FromImport(package_name, name_leafs):
""" Return an import statement in the form:
@@ -122,9 +122,9 @@ def FromImport(package_name, name_leafs):
# Pull the leaves out of their old tree
leaf.remove()
- children = [Leaf(token.NAME, u"from"),
- Leaf(token.NAME, package_name, prefix=u" "),
- Leaf(token.NAME, u"import", prefix=u" "),
+ children = [Leaf(token.NAME, "from"),
+ Leaf(token.NAME, package_name, prefix=" "),
+ Leaf(token.NAME, "import", prefix=" "),
Node(syms.import_as_names, name_leafs)]
imp = Node(syms.import_from, children)
return imp
@@ -143,8 +143,8 @@ def is_tuple(node):
and isinstance(node.children[0], Leaf)
and isinstance(node.children[1], Node)
and isinstance(node.children[2], Leaf)
- and node.children[0].value == u"("
- and node.children[2].value == u")")
+ and node.children[0].value == "("
+ and node.children[2].value == ")")
def is_list(node):
"""Does the node represent a list literal?"""
@@ -152,8 +152,8 @@ def is_list(node):
and len(node.children) > 1
and isinstance(node.children[0], Leaf)
and isinstance(node.children[-1], Leaf)
- and node.children[0].value == u"["
- and node.children[-1].value == u"]")
+ and node.children[0].value == "["
+ and node.children[-1].value == "]")
###########################################################
@@ -255,7 +255,7 @@ def find_indentation(node):
if indent.type == token.INDENT:
return indent.value
node = node.parent
- return u""
+ return ""
###########################################################
### The following functions are to find bindings in a suite
@@ -326,11 +326,11 @@ def touch_import(package, name, node):
if package is None:
import_ = Node(syms.import_name, [
- Leaf(token.NAME, u"import"),
- Leaf(token.NAME, name, prefix=u" ")
+ Leaf(token.NAME, "import"),
+ Leaf(token.NAME, name, prefix=" ")
])
else:
- import_ = FromImport(package, [Leaf(token.NAME, name, prefix=u" ")])
+ import_ = FromImport(package, [Leaf(token.NAME, name, prefix=" ")])
children = [import_, Newline()]
root.insert_child(insert_pos, Node(syms.simple_stmt, children))
@@ -411,12 +411,12 @@ def _is_import_binding(node, name, package=None):
elif imp.type == token.NAME and imp.value == name:
return node
elif node.type == syms.import_from:
- # unicode(...) is used to make life easier here, because
+ # str(...) is used to make life easier here, because
# from a.b import parses to ['import', ['a', '.', 'b'], ...]
- if package and unicode(node.children[1]).strip() != package:
+ if package and str(node.children[1]).strip() != package:
return None
n = node.children[3]
- if package and _find(u"as", n):
+ if package and _find("as", n):
# See test_from_import_as for explanation
return None
elif n.type == syms.import_as_names and _find(name, n):
diff --git a/Lib/lib2to3/fixes/fix_apply.py b/Lib/lib2to3/fixes/fix_apply.py
index a7dc3a046d8..81a46dc43fa 100644
--- a/Lib/lib2to3/fixes/fix_apply.py
+++ b/Lib/lib2to3/fixes/fix_apply.py
@@ -47,12 +47,12 @@ class FixApply(fixer_base.BaseFix):
if kwds is not None:
kwds = kwds.clone()
kwds.prefix = ""
- l_newargs = [pytree.Leaf(token.STAR, u"*"), args]
+ l_newargs = [pytree.Leaf(token.STAR, "*"), args]
if kwds is not None:
l_newargs.extend([Comma(),
- pytree.Leaf(token.DOUBLESTAR, u"**"),
+ pytree.Leaf(token.DOUBLESTAR, "**"),
kwds])
- l_newargs[-2].prefix = u" " # that's the ** token
+ l_newargs[-2].prefix = " " # that's the ** token
# XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t)
# can be translated into f(x, y, *t) instead of f(*(x, y) + t)
#new = pytree.Node(syms.power, (func, ArgList(l_newargs)))
diff --git a/Lib/lib2to3/fixes/fix_basestring.py b/Lib/lib2to3/fixes/fix_basestring.py
index a3c9a436492..5fe69a0f03b 100644
--- a/Lib/lib2to3/fixes/fix_basestring.py
+++ b/Lib/lib2to3/fixes/fix_basestring.py
@@ -11,4 +11,4 @@ class FixBasestring(fixer_base.BaseFix):
PATTERN = "'basestring'"
def transform(self, node, results):
- return Name(u"str", prefix=node.prefix)
+ return Name("str", prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_buffer.py b/Lib/lib2to3/fixes/fix_buffer.py
index c6b09280248..f9a1958ad3b 100644
--- a/Lib/lib2to3/fixes/fix_buffer.py
+++ b/Lib/lib2to3/fixes/fix_buffer.py
@@ -19,4 +19,4 @@ class FixBuffer(fixer_base.BaseFix):
def transform(self, node, results):
name = results["name"]
- name.replace(Name(u"memoryview", prefix=name.prefix))
+ name.replace(Name("memoryview", prefix=name.prefix))
diff --git a/Lib/lib2to3/fixes/fix_callable.py b/Lib/lib2to3/fixes/fix_callable.py
index df33d614ba1..4c92b9c6503 100644
--- a/Lib/lib2to3/fixes/fix_callable.py
+++ b/Lib/lib2to3/fixes/fix_callable.py
@@ -30,8 +30,8 @@ class FixCallable(fixer_base.BaseFix):
def transform(self, node, results):
func = results['func']
- touch_import(None, u'collections', node=node)
+ touch_import(None, 'collections', node=node)
- args = [func.clone(), String(u', ')]
- args.extend(Attr(Name(u'collections'), Name(u'Callable')))
- return Call(Name(u'isinstance'), args, prefix=node.prefix)
+ args = [func.clone(), String(', ')]
+ args.extend(Attr(Name('collections'), Name('Callable')))
+ return Call(Name('isinstance'), args, prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_dict.py b/Lib/lib2to3/fixes/fix_dict.py
index f681e4d7132..4cc37174cb7 100644
--- a/Lib/lib2to3/fixes/fix_dict.py
+++ b/Lib/lib2to3/fixes/fix_dict.py
@@ -58,11 +58,11 @@ class FixDict(fixer_base.BaseFix):
tail = results["tail"]
syms = self.syms
method_name = method.value
- isiter = method_name.startswith(u"iter")
- isview = method_name.startswith(u"view")
+ isiter = method_name.startswith("iter")
+ isview = method_name.startswith("view")
if isiter or isview:
method_name = method_name[4:]
- assert method_name in (u"keys", u"items", u"values"), repr(method)
+ assert method_name in ("keys", "items", "values"), repr(method)
head = [n.clone() for n in head]
tail = [n.clone() for n in tail]
special = not tail and self.in_special_context(node, isiter)
@@ -73,8 +73,8 @@ class FixDict(fixer_base.BaseFix):
results["parens"].clone()]
new = pytree.Node(syms.power, args)
if not (special or isview):
- new.prefix = u""
- new = Call(Name(u"iter" if isiter else u"list"), [new])
+ new.prefix = ""
+ new = Call(Name("iter" if isiter else "list"), [new])
if tail:
new = pytree.Node(syms.power, [new] + tail)
new.prefix = node.prefix
diff --git a/Lib/lib2to3/fixes/fix_except.py b/Lib/lib2to3/fixes/fix_except.py
index e324718f649..49bd3d5ab7d 100644
--- a/Lib/lib2to3/fixes/fix_except.py
+++ b/Lib/lib2to3/fixes/fix_except.py
@@ -30,7 +30,7 @@ from ..fixer_util import Assign, Attr, Name, is_tuple, is_list, syms
def find_excepts(nodes):
for i, n in enumerate(nodes):
if n.type == syms.except_clause:
- if n.children[0].value == u'except':
+ if n.children[0].value == 'except':
yield (n, nodes[i+2])
class FixExcept(fixer_base.BaseFix):
@@ -53,13 +53,13 @@ class FixExcept(fixer_base.BaseFix):
for except_clause, e_suite in find_excepts(try_cleanup):
if len(except_clause.children) == 4:
(E, comma, N) = except_clause.children[1:4]
- comma.replace(Name(u"as", prefix=u" "))
+ comma.replace(Name("as", prefix=" "))
if N.type != token.NAME:
# Generate a new N for the except clause
- new_N = Name(self.new_name(), prefix=u" ")
+ new_N = Name(self.new_name(), prefix=" ")
target = N.clone()
- target.prefix = u""
+ target.prefix = ""
N.replace(new_N)
new_N = new_N.clone()
@@ -75,7 +75,7 @@ class FixExcept(fixer_base.BaseFix):
# The assignment is different if old_N is a tuple or list
# In that case, the assignment is old_N = new_N.args
if is_tuple(N) or is_list(N):
- assign = Assign(target, Attr(new_N, Name(u'args')))
+ assign = Assign(target, Attr(new_N, Name('args')))
else:
assign = Assign(target, new_N)
@@ -83,10 +83,10 @@ class FixExcept(fixer_base.BaseFix):
for child in reversed(suite_stmts[:i]):
e_suite.insert_child(0, child)
e_suite.insert_child(i, assign)
- elif N.prefix == u"":
+ elif N.prefix == "":
# No space after a comma is legal; no space after "as",
# not so much.
- N.prefix = u" "
+ N.prefix = " "
#TODO(cwinter) fix this when children becomes a smart list
children = [c.clone() for c in node.children[:3]] + try_cleanup + tail
diff --git a/Lib/lib2to3/fixes/fix_exec.py b/Lib/lib2to3/fixes/fix_exec.py
index 50e18544545..2c9b72d5425 100644
--- a/Lib/lib2to3/fixes/fix_exec.py
+++ b/Lib/lib2to3/fixes/fix_exec.py
@@ -37,4 +37,4 @@ class FixExec(fixer_base.BaseFix):
if c is not None:
args.extend([Comma(), c.clone()])
- return Call(Name(u"exec"), args, prefix=node.prefix)
+ return Call(Name("exec"), args, prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_execfile.py b/Lib/lib2to3/fixes/fix_execfile.py
index 2f29d3b281a..09cb6f6661c 100644
--- a/Lib/lib2to3/fixes/fix_execfile.py
+++ b/Lib/lib2to3/fixes/fix_execfile.py
@@ -32,21 +32,21 @@ class FixExecfile(fixer_base.BaseFix):
execfile_paren = node.children[-1].children[-1].clone()
# Construct open().read().
open_args = ArgList([filename.clone()], rparen=execfile_paren)
- open_call = Node(syms.power, [Name(u"open"), open_args])
- read = [Node(syms.trailer, [Dot(), Name(u'read')]),
+ open_call = Node(syms.power, [Name("open"), open_args])
+ read = [Node(syms.trailer, [Dot(), Name('read')]),
Node(syms.trailer, [LParen(), RParen()])]
open_expr = [open_call] + read
# Wrap the open call in a compile call. This is so the filename will be
# preserved in the execed code.
filename_arg = filename.clone()
- filename_arg.prefix = u" "
- exec_str = String(u"'exec'", u" ")
+ filename_arg.prefix = " "
+ exec_str = String("'exec'", " ")
compile_args = open_expr + [Comma(), filename_arg, Comma(), exec_str]
- compile_call = Call(Name(u"compile"), compile_args, u"")
+ compile_call = Call(Name("compile"), compile_args, "")
# Finally, replace the execfile call with an exec call.
args = [compile_call]
if globals is not None:
args.extend([Comma(), globals.clone()])
if locals is not None:
args.extend([Comma(), locals.clone()])
- return Call(Name(u"exec"), args, prefix=node.prefix)
+ return Call(Name("exec"), args, prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_exitfunc.py b/Lib/lib2to3/fixes/fix_exitfunc.py
index 89fb3db5336..9afc2fac18a 100644
--- a/Lib/lib2to3/fixes/fix_exitfunc.py
+++ b/Lib/lib2to3/fixes/fix_exitfunc.py
@@ -42,9 +42,9 @@ class FixExitfunc(fixer_base.BaseFix):
return
func = results["func"].clone()
- func.prefix = u""
+ func.prefix = ""
register = pytree.Node(syms.power,
- Attr(Name(u"atexit"), Name(u"register"))
+ Attr(Name("atexit"), Name("register"))
)
call = Call(register, [func], node.prefix)
node.replace(call)
@@ -59,13 +59,13 @@ class FixExitfunc(fixer_base.BaseFix):
names = self.sys_import.children[1]
if names.type == syms.dotted_as_names:
names.append_child(Comma())
- names.append_child(Name(u"atexit", u" "))
+ names.append_child(Name("atexit", " "))
else:
containing_stmt = self.sys_import.parent
position = containing_stmt.children.index(self.sys_import)
stmt_container = containing_stmt.parent
new_import = pytree.Node(syms.import_name,
- [Name(u"import"), Name(u"atexit", u" ")]
+ [Name("import"), Name("atexit", " ")]
)
new = pytree.Node(syms.simple_stmt, [new_import])
containing_stmt.insert_child(position + 1, Newline())
diff --git a/Lib/lib2to3/fixes/fix_filter.py b/Lib/lib2to3/fixes/fix_filter.py
index 18ee2ffc062..391889f9132 100644
--- a/Lib/lib2to3/fixes/fix_filter.py
+++ b/Lib/lib2to3/fixes/fix_filter.py
@@ -61,16 +61,16 @@ class FixFilter(fixer_base.ConditionalFix):
results.get("xp").clone())
elif "none" in results:
- new = ListComp(Name(u"_f"),
- Name(u"_f"),
+ new = ListComp(Name("_f"),
+ Name("_f"),
results["seq"].clone(),
- Name(u"_f"))
+ Name("_f"))
else:
if in_special_context(node):
return None
new = node.clone()
- new.prefix = u""
- new = Call(Name(u"list"), [new])
+ new.prefix = ""
+ new = Call(Name("list"), [new])
new.prefix = node.prefix
return new
diff --git a/Lib/lib2to3/fixes/fix_funcattrs.py b/Lib/lib2to3/fixes/fix_funcattrs.py
index 9e45c028574..67f3e18e061 100644
--- a/Lib/lib2to3/fixes/fix_funcattrs.py
+++ b/Lib/lib2to3/fixes/fix_funcattrs.py
@@ -17,5 +17,5 @@ class FixFuncattrs(fixer_base.BaseFix):
def transform(self, node, results):
attr = results["attr"][0]
- attr.replace(Name((u"__%s__" % attr.value[5:]),
+ attr.replace(Name(("__%s__" % attr.value[5:]),
prefix=attr.prefix))
diff --git a/Lib/lib2to3/fixes/fix_getcwdu.py b/Lib/lib2to3/fixes/fix_getcwdu.py
index 82233c8993b..087eaedcb26 100644
--- a/Lib/lib2to3/fixes/fix_getcwdu.py
+++ b/Lib/lib2to3/fixes/fix_getcwdu.py
@@ -16,4 +16,4 @@ class FixGetcwdu(fixer_base.BaseFix):
def transform(self, node, results):
name = results["name"]
- name.replace(Name(u"getcwd", prefix=name.prefix))
+ name.replace(Name("getcwd", prefix=name.prefix))
diff --git a/Lib/lib2to3/fixes/fix_has_key.py b/Lib/lib2to3/fixes/fix_has_key.py
index bead4cb51cd..18c560fd850 100644
--- a/Lib/lib2to3/fixes/fix_has_key.py
+++ b/Lib/lib2to3/fixes/fix_has_key.py
@@ -92,10 +92,10 @@ class FixHasKey(fixer_base.BaseFix):
before = before[0]
else:
before = pytree.Node(syms.power, before)
- before.prefix = u" "
- n_op = Name(u"in", prefix=u" ")
+ before.prefix = " "
+ n_op = Name("in", prefix=" ")
if negation:
- n_not = Name(u"not", prefix=u" ")
+ n_not = Name("not", prefix=" ")
n_op = pytree.Node(syms.comp_op, (n_not, n_op))
new = pytree.Node(syms.comparison, (arg, n_op, before))
if after:
diff --git a/Lib/lib2to3/fixes/fix_idioms.py b/Lib/lib2to3/fixes/fix_idioms.py
index 37b6eefa513..6905913d7cb 100644
--- a/Lib/lib2to3/fixes/fix_idioms.py
+++ b/Lib/lib2to3/fixes/fix_idioms.py
@@ -100,18 +100,18 @@ class FixIdioms(fixer_base.BaseFix):
def transform_isinstance(self, node, results):
x = results["x"].clone() # The thing inside of type()
T = results["T"].clone() # The type being compared against
- x.prefix = u""
- T.prefix = u" "
- test = Call(Name(u"isinstance"), [x, Comma(), T])
+ x.prefix = ""
+ T.prefix = " "
+ test = Call(Name("isinstance"), [x, Comma(), T])
if "n" in results:
- test.prefix = u" "
- test = Node(syms.not_test, [Name(u"not"), test])
+ test.prefix = " "
+ test = Node(syms.not_test, [Name("not"), test])
test.prefix = node.prefix
return test
def transform_while(self, node, results):
one = results["while"]
- one.replace(Name(u"True", prefix=one.prefix))
+ one.replace(Name("True", prefix=one.prefix))
def transform_sort(self, node, results):
sort_stmt = results["sort"]
@@ -120,11 +120,11 @@ class FixIdioms(fixer_base.BaseFix):
simple_expr = results.get("expr")
if list_call:
- list_call.replace(Name(u"sorted", prefix=list_call.prefix))
+ list_call.replace(Name("sorted", prefix=list_call.prefix))
elif simple_expr:
new = simple_expr.clone()
- new.prefix = u""
- simple_expr.replace(Call(Name(u"sorted"), [new],
+ new.prefix = ""
+ simple_expr.replace(Call(Name("sorted"), [new],
prefix=simple_expr.prefix))
else:
raise RuntimeError("should not have reached here")
@@ -133,13 +133,13 @@ class FixIdioms(fixer_base.BaseFix):
btwn = sort_stmt.prefix
# Keep any prefix lines between the sort_stmt and the list_call and
# shove them right after the sorted() call.
- if u"\n" in btwn:
+ if "\n" in btwn:
if next_stmt:
# The new prefix should be everything from the sort_stmt's
# prefix up to the last newline, then the old prefix after a new
# line.
- prefix_lines = (btwn.rpartition(u"\n")[0], next_stmt[0].prefix)
- next_stmt[0].prefix = u"\n".join(prefix_lines)
+ prefix_lines = (btwn.rpartition("\n")[0], next_stmt[0].prefix)
+ next_stmt[0].prefix = "\n".join(prefix_lines)
else:
assert list_call.parent
assert list_call.next_sibling is None
@@ -149,4 +149,4 @@ class FixIdioms(fixer_base.BaseFix):
assert list_call.next_sibling is end_line
# The new prefix should be everything up to the first new line
# of sort_stmt's prefix.
- end_line.prefix = btwn.rpartition(u"\n")[0]
+ end_line.prefix = btwn.rpartition("\n")[0]
diff --git a/Lib/lib2to3/fixes/fix_import.py b/Lib/lib2to3/fixes/fix_import.py
index 201e811e619..e978fce43fc 100644
--- a/Lib/lib2to3/fixes/fix_import.py
+++ b/Lib/lib2to3/fixes/fix_import.py
@@ -61,7 +61,7 @@ class FixImport(fixer_base.BaseFix):
while not hasattr(imp, 'value'):
imp = imp.children[0]
if self.probably_a_local_import(imp.value):
- imp.value = u"." + imp.value
+ imp.value = "." + imp.value
imp.changed()
else:
have_local = False
@@ -78,15 +78,15 @@ class FixImport(fixer_base.BaseFix):
self.warning(node, "absolute and local imports together")
return
- new = FromImport(u".", [imp])
+ new = FromImport(".", [imp])
new.prefix = node.prefix
return new
def probably_a_local_import(self, imp_name):
- if imp_name.startswith(u"."):
+ if imp_name.startswith("."):
# Relative imports are certainly not local imports.
return False
- imp_name = imp_name.split(u".", 1)[0]
+ imp_name = imp_name.split(".", 1)[0]
base_path = dirname(self.filename)
base_path = join(base_path, imp_name)
# If there is no __init__.py next to the file its not in a package
diff --git a/Lib/lib2to3/fixes/fix_imports.py b/Lib/lib2to3/fixes/fix_imports.py
index 93c9e6787b1..aaf4f2f642e 100644
--- a/Lib/lib2to3/fixes/fix_imports.py
+++ b/Lib/lib2to3/fixes/fix_imports.py
@@ -123,7 +123,7 @@ class FixImports(fixer_base.BaseFix):
import_mod = results.get("module_name")
if import_mod:
mod_name = import_mod.value
- new_name = unicode(self.mapping[mod_name])
+ new_name = self.mapping[mod_name]
import_mod.replace(Name(new_name, prefix=import_mod.prefix))
if "name_import" in results:
# If it's not a "from x import x, y" or "import x as y" import,
diff --git a/Lib/lib2to3/fixes/fix_input.py b/Lib/lib2to3/fixes/fix_input.py
index fbf4c72f5c9..126da1b945b 100644
--- a/Lib/lib2to3/fixes/fix_input.py
+++ b/Lib/lib2to3/fixes/fix_input.py
@@ -22,5 +22,5 @@ class FixInput(fixer_base.BaseFix):
return
new = node.clone()
- new.prefix = u""
- return Call(Name(u"eval"), [new], prefix=node.prefix)
+ new.prefix = ""
+ return Call(Name("eval"), [new], prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_intern.py b/Lib/lib2to3/fixes/fix_intern.py
index e7bb5052b4b..6be11cd39dc 100644
--- a/Lib/lib2to3/fixes/fix_intern.py
+++ b/Lib/lib2to3/fixes/fix_intern.py
@@ -36,11 +36,11 @@ class FixIntern(fixer_base.BaseFix):
if after:
after = [n.clone() for n in after]
new = pytree.Node(syms.power,
- Attr(Name(u"sys"), Name(u"intern")) +
+ Attr(Name("sys"), Name("intern")) +
[pytree.Node(syms.trailer,
[results["lpar"].clone(),
newarglist,
results["rpar"].clone()])] + after)
new.prefix = node.prefix
- touch_import(None, u'sys', node)
+ touch_import(None, 'sys', node)
return new
diff --git a/Lib/lib2to3/fixes/fix_isinstance.py b/Lib/lib2to3/fixes/fix_isinstance.py
index 4b04c8fd0c6..bebb1de1204 100644
--- a/Lib/lib2to3/fixes/fix_isinstance.py
+++ b/Lib/lib2to3/fixes/fix_isinstance.py
@@ -35,7 +35,7 @@ class FixIsinstance(fixer_base.BaseFix):
for idx, arg in iterator:
if arg.type == token.NAME and arg.value in names_inserted:
if idx < len(args) - 1 and args[idx + 1].type == token.COMMA:
- iterator.next()
+ next(iterator)
continue
else:
new_args.append(arg)
diff --git a/Lib/lib2to3/fixes/fix_itertools.py b/Lib/lib2to3/fixes/fix_itertools.py
index 27f8a49ec60..63346b92202 100644
--- a/Lib/lib2to3/fixes/fix_itertools.py
+++ b/Lib/lib2to3/fixes/fix_itertools.py
@@ -29,7 +29,7 @@ class FixItertools(fixer_base.BaseFix):
prefix = None
func = results['func'][0]
if ('it' in results and
- func.value not in (u'ifilterfalse', u'izip_longest')):
+ func.value not in ('ifilterfalse', 'izip_longest')):
dot, it = (results['dot'], results['it'])
# Remove the 'itertools'
prefix = it.prefix
diff --git a/Lib/lib2to3/fixes/fix_itertools_imports.py b/Lib/lib2to3/fixes/fix_itertools_imports.py
index 28610cfcb95..0ddbc7b8422 100644
--- a/Lib/lib2to3/fixes/fix_itertools_imports.py
+++ b/Lib/lib2to3/fixes/fix_itertools_imports.py
@@ -28,13 +28,13 @@ class FixItertoolsImports(fixer_base.BaseFix):
assert child.type == syms.import_as_name
name_node = child.children[0]
member_name = name_node.value
- if member_name in (u'imap', u'izip', u'ifilter'):
+ if member_name in ('imap', 'izip', 'ifilter'):
child.value = None
child.remove()
- elif member_name in (u'ifilterfalse', u'izip_longest'):
+ elif member_name in ('ifilterfalse', 'izip_longest'):
node.changed()
- name_node.value = (u'filterfalse' if member_name[1] == u'f'
- else u'zip_longest')
+ name_node.value = ('filterfalse' if member_name[1] == 'f'
+ else 'zip_longest')
# Make sure the import statement is still sane
children = imports.children[:] or [imports]
diff --git a/Lib/lib2to3/fixes/fix_long.py b/Lib/lib2to3/fixes/fix_long.py
index 5dddde0d08d..f227c9f4981 100644
--- a/Lib/lib2to3/fixes/fix_long.py
+++ b/Lib/lib2to3/fixes/fix_long.py
@@ -15,5 +15,5 @@ class FixLong(fixer_base.BaseFix):
def transform(self, node, results):
if is_probably_builtin(node):
- node.value = u"int"
+ node.value = "int"
node.changed()
diff --git a/Lib/lib2to3/fixes/fix_map.py b/Lib/lib2to3/fixes/fix_map.py
index 7a7d0dbc66c..9f966feedea 100644
--- a/Lib/lib2to3/fixes/fix_map.py
+++ b/Lib/lib2to3/fixes/fix_map.py
@@ -63,8 +63,8 @@ class FixMap(fixer_base.ConditionalFix):
if node.parent.type == syms.simple_stmt:
self.warning(node, "You should use a for loop here")
new = node.clone()
- new.prefix = u""
- new = Call(Name(u"list"), [new])
+ new.prefix = ""
+ new = Call(Name("list"), [new])
elif "map_lambda" in results:
new = ListComp(results["xp"].clone(),
results["fp"].clone(),
@@ -85,7 +85,7 @@ class FixMap(fixer_base.ConditionalFix):
if in_special_context(node):
return None
new = node.clone()
- new.prefix = u""
- new = Call(Name(u"list"), [new])
+ new.prefix = ""
+ new = Call(Name("list"), [new])
new.prefix = node.prefix
return new
diff --git a/Lib/lib2to3/fixes/fix_metaclass.py b/Lib/lib2to3/fixes/fix_metaclass.py
index c86fbeaab2c..7d4d002f976 100644
--- a/Lib/lib2to3/fixes/fix_metaclass.py
+++ b/Lib/lib2to3/fixes/fix_metaclass.py
@@ -113,7 +113,7 @@ def find_metas(cls_node):
# Check if the expr_node is a simple assignment.
left_node = expr_node.children[0]
if isinstance(left_node, Leaf) and \
- left_node.value == u'__metaclass__':
+ left_node.value == '__metaclass__':
# We found a assignment to __metaclass__.
fixup_simple_stmt(node, i, simple_node)
remove_trailing_newline(simple_node)
@@ -136,7 +136,7 @@ def fixup_indent(suite):
node = kids.pop()
if isinstance(node, Leaf) and node.type != token.DEDENT:
if node.prefix:
- node.prefix = u''
+ node.prefix = ''
return
else:
kids.extend(node.children[::-1])
@@ -183,9 +183,9 @@ class FixMetaclass(fixer_base.BaseFix):
# Node(classdef, ['class', 'name', ':', suite])
# 0 1 2 3
arglist = Node(syms.arglist, [])
- node.insert_child(2, Leaf(token.RPAR, u')'))
+ node.insert_child(2, Leaf(token.RPAR, ')'))
node.insert_child(2, arglist)
- node.insert_child(2, Leaf(token.LPAR, u'('))
+ node.insert_child(2, Leaf(token.LPAR, '('))
else:
raise ValueError("Unexpected class definition")
@@ -195,16 +195,16 @@ class FixMetaclass(fixer_base.BaseFix):
orig_meta_prefix = meta_txt.prefix
if arglist.children:
- arglist.append_child(Leaf(token.COMMA, u','))
- meta_txt.prefix = u' '
+ arglist.append_child(Leaf(token.COMMA, ','))
+ meta_txt.prefix = ' '
else:
- meta_txt.prefix = u''
+ meta_txt.prefix = ''
# compact the expression "metaclass = Meta" -> "metaclass=Meta"
expr_stmt = last_metaclass.children[0]
assert expr_stmt.type == syms.expr_stmt
- expr_stmt.children[1].prefix = u''
- expr_stmt.children[2].prefix = u''
+ expr_stmt.children[1].prefix = ''
+ expr_stmt.children[2].prefix = ''
arglist.append_child(last_metaclass)
@@ -214,15 +214,15 @@ class FixMetaclass(fixer_base.BaseFix):
if not suite.children:
# one-liner that was just __metaclass_
suite.remove()
- pass_leaf = Leaf(text_type, u'pass')
+ pass_leaf = Leaf(text_type, 'pass')
pass_leaf.prefix = orig_meta_prefix
node.append_child(pass_leaf)
- node.append_child(Leaf(token.NEWLINE, u'\n'))
+ node.append_child(Leaf(token.NEWLINE, '\n'))
elif len(suite.children) > 1 and \
(suite.children[-2].type == token.INDENT and
suite.children[-1].type == token.DEDENT):
# there was only one line in the class body and it was __metaclass__
- pass_leaf = Leaf(text_type, u'pass')
+ pass_leaf = Leaf(text_type, 'pass')
suite.insert_child(-1, pass_leaf)
- suite.insert_child(-1, Leaf(token.NEWLINE, u'\n'))
+ suite.insert_child(-1, Leaf(token.NEWLINE, '\n'))
diff --git a/Lib/lib2to3/fixes/fix_methodattrs.py b/Lib/lib2to3/fixes/fix_methodattrs.py
index f3c1ecfec15..7f9004f00e6 100644
--- a/Lib/lib2to3/fixes/fix_methodattrs.py
+++ b/Lib/lib2to3/fixes/fix_methodattrs.py
@@ -20,5 +20,5 @@ class FixMethodattrs(fixer_base.BaseFix):
def transform(self, node, results):
attr = results["attr"][0]
- new = unicode(MAP[attr.value])
+ new = MAP[attr.value]
attr.replace(Name(new, prefix=attr.prefix))
diff --git a/Lib/lib2to3/fixes/fix_ne.py b/Lib/lib2to3/fixes/fix_ne.py
index 7025980b48e..e3ee10f4a63 100644
--- a/Lib/lib2to3/fixes/fix_ne.py
+++ b/Lib/lib2to3/fixes/fix_ne.py
@@ -16,8 +16,8 @@ class FixNe(fixer_base.BaseFix):
def match(self, node):
# Override
- return node.value == u"<>"
+ return node.value == "<>"
def transform(self, node, results):
- new = pytree.Leaf(token.NOTEQUAL, u"!=", prefix=node.prefix)
+ new = pytree.Leaf(token.NOTEQUAL, "!=", prefix=node.prefix)
return new
diff --git a/Lib/lib2to3/fixes/fix_next.py b/Lib/lib2to3/fixes/fix_next.py
index f021a9bd70a..9f6305e1d49 100644
--- a/Lib/lib2to3/fixes/fix_next.py
+++ b/Lib/lib2to3/fixes/fix_next.py
@@ -36,7 +36,7 @@ class FixNext(fixer_base.BaseFix):
def start_tree(self, tree, filename):
super(FixNext, self).start_tree(tree, filename)
- n = find_binding(u'next', tree)
+ n = find_binding('next', tree)
if n:
self.warning(n, bind_warning)
self.shadowed_next = True
@@ -52,13 +52,13 @@ class FixNext(fixer_base.BaseFix):
if base:
if self.shadowed_next:
- attr.replace(Name(u"__next__", prefix=attr.prefix))
+ attr.replace(Name("__next__", prefix=attr.prefix))
else:
base = [n.clone() for n in base]
- base[0].prefix = u""
- node.replace(Call(Name(u"next", prefix=node.prefix), base))
+ base[0].prefix = ""
+ node.replace(Call(Name("next", prefix=node.prefix), base))
elif name:
- n = Name(u"__next__", prefix=name.prefix)
+ n = Name("__next__", prefix=name.prefix)
name.replace(n)
elif attr:
# We don't do this transformation if we're assigning to "x.next".
@@ -66,10 +66,10 @@ class FixNext(fixer_base.BaseFix):
# so it's being done here.
if is_assign_target(node):
head = results["head"]
- if "".join([str(n) for n in head]).strip() == u'__builtin__':
+ if "".join([str(n) for n in head]).strip() == '__builtin__':
self.warning(node, bind_warning)
return
- attr.replace(Name(u"__next__"))
+ attr.replace(Name("__next__"))
elif "global" in results:
self.warning(node, bind_warning)
self.shadowed_next = True
diff --git a/Lib/lib2to3/fixes/fix_nonzero.py b/Lib/lib2to3/fixes/fix_nonzero.py
index ba83478f818..ad91a29e43c 100644
--- a/Lib/lib2to3/fixes/fix_nonzero.py
+++ b/Lib/lib2to3/fixes/fix_nonzero.py
@@ -17,5 +17,5 @@ class FixNonzero(fixer_base.BaseFix):
def transform(self, node, results):
name = results["name"]
- new = Name(u"__bool__", prefix=name.prefix)
+ new = Name("__bool__", prefix=name.prefix)
name.replace(new)
diff --git a/Lib/lib2to3/fixes/fix_numliterals.py b/Lib/lib2to3/fixes/fix_numliterals.py
index b0c23f8041a..79207d4aa36 100644
--- a/Lib/lib2to3/fixes/fix_numliterals.py
+++ b/Lib/lib2to3/fixes/fix_numliterals.py
@@ -16,13 +16,13 @@ class FixNumliterals(fixer_base.BaseFix):
def match(self, node):
# Override
- return (node.value.startswith(u"0") or node.value[-1] in u"Ll")
+ return (node.value.startswith("0") or node.value[-1] in "Ll")
def transform(self, node, results):
val = node.value
- if val[-1] in u'Ll':
+ if val[-1] in 'Ll':
val = val[:-1]
- elif val.startswith(u'0') and val.isdigit() and len(set(val)) > 1:
- val = u"0o" + val[1:]
+ elif val.startswith('0') and val.isdigit() and len(set(val)) > 1:
+ val = "0o" + val[1:]
return Number(val, prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_operator.py b/Lib/lib2to3/fixes/fix_operator.py
index 7bf2c0dd22c..1aa17bae58d 100644
--- a/Lib/lib2to3/fixes/fix_operator.py
+++ b/Lib/lib2to3/fixes/fix_operator.py
@@ -9,6 +9,8 @@ operator.repeat(obj, n) -> operator.mul(obj, n)
operator.irepeat(obj, n) -> operator.imul(obj, n)
"""
+import collections
+
# Local imports
from lib2to3 import fixer_base
from lib2to3.fixer_util import Call, Name, String, touch_import
@@ -45,33 +47,33 @@ class FixOperator(fixer_base.BaseFix):
@invocation("operator.contains(%s)")
def _sequenceIncludes(self, node, results):
- return self._handle_rename(node, results, u"contains")
+ return self._handle_rename(node, results, "contains")
@invocation("hasattr(%s, '__call__')")
def _isCallable(self, node, results):
obj = results["obj"]
- args = [obj.clone(), String(u", "), String(u"'__call__'")]
- return Call(Name(u"hasattr"), args, prefix=node.prefix)
+ args = [obj.clone(), String(", "), String("'__call__'")]
+ return Call(Name("hasattr"), args, prefix=node.prefix)
@invocation("operator.mul(%s)")
def _repeat(self, node, results):
- return self._handle_rename(node, results, u"mul")
+ return self._handle_rename(node, results, "mul")
@invocation("operator.imul(%s)")
def _irepeat(self, node, results):
- return self._handle_rename(node, results, u"imul")
+ return self._handle_rename(node, results, "imul")
@invocation("isinstance(%s, collections.Sequence)")
def _isSequenceType(self, node, results):
- return self._handle_type2abc(node, results, u"collections", u"Sequence")
+ return self._handle_type2abc(node, results, "collections", "Sequence")
@invocation("isinstance(%s, collections.Mapping)")
def _isMappingType(self, node, results):
- return self._handle_type2abc(node, results, u"collections", u"Mapping")
+ return self._handle_type2abc(node, results, "collections", "Mapping")
@invocation("isinstance(%s, numbers.Number)")
def _isNumberType(self, node, results):
- return self._handle_type2abc(node, results, u"numbers", u"Number")
+ return self._handle_type2abc(node, results, "numbers", "Number")
def _handle_rename(self, node, results, name):
method = results["method"][0]
@@ -81,16 +83,16 @@ class FixOperator(fixer_base.BaseFix):
def _handle_type2abc(self, node, results, module, abc):
touch_import(None, module, node)
obj = results["obj"]
- args = [obj.clone(), String(u", " + u".".join([module, abc]))]
- return Call(Name(u"isinstance"), args, prefix=node.prefix)
+ args = [obj.clone(), String(", " + ".".join([module, abc]))]
+ return Call(Name("isinstance"), args, prefix=node.prefix)
def _check_method(self, node, results):
- method = getattr(self, "_" + results["method"][0].value.encode("ascii"))
- if callable(method):
+ method = getattr(self, "_" + results["method"][0].value)
+ if isinstance(method, collections.Callable):
if "module" in results:
return method
else:
- sub = (unicode(results["obj"]),)
- invocation_str = unicode(method.invocation) % sub
- self.warning(node, u"You should use '%s' here." % invocation_str)
+ sub = (str(results["obj"]),)
+ invocation_str = method.invocation % sub
+ self.warning(node, "You should use '%s' here." % invocation_str)
return None
diff --git a/Lib/lib2to3/fixes/fix_paren.py b/Lib/lib2to3/fixes/fix_paren.py
index 8650cd9078a..b205aa7e1e9 100644
--- a/Lib/lib2to3/fixes/fix_paren.py
+++ b/Lib/lib2to3/fixes/fix_paren.py
@@ -39,6 +39,6 @@ class FixParen(fixer_base.BaseFix):
lparen = LParen()
lparen.prefix = target.prefix
- target.prefix = u"" # Make it hug the parentheses
+ target.prefix = "" # Make it hug the parentheses
target.insert_child(0, lparen)
target.append_child(RParen())
diff --git a/Lib/lib2to3/fixes/fix_print.py b/Lib/lib2to3/fixes/fix_print.py
index 98786b3ecdc..a1fe2f5c782 100644
--- a/Lib/lib2to3/fixes/fix_print.py
+++ b/Lib/lib2to3/fixes/fix_print.py
@@ -41,10 +41,10 @@ class FixPrint(fixer_base.BaseFix):
if bare_print:
# Special-case print all by itself
- bare_print.replace(Call(Name(u"print"), [],
+ bare_print.replace(Call(Name("print"), [],
prefix=bare_print.prefix))
return
- assert node.children[0] == Name(u"print")
+ assert node.children[0] == Name("print")
args = node.children[1:]
if len(args) == 1 and parend_expr.match(args[0]):
# We don't want to keep sticking parens around an
@@ -55,33 +55,33 @@ class FixPrint(fixer_base.BaseFix):
if args and args[-1] == Comma():
args = args[:-1]
end = " "
- if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, u">>"):
+ if args and args[0] == pytree.Leaf(token.RIGHTSHIFT, ">>"):
assert len(args) >= 2
file = args[1].clone()
args = args[3:] # Strip a possible comma after the file expression
# Now synthesize a print(args, sep=..., end=..., file=...) node.
l_args = [arg.clone() for arg in args]
if l_args:
- l_args[0].prefix = u""
+ l_args[0].prefix = ""
if sep is not None or end is not None or file is not None:
if sep is not None:
- self.add_kwarg(l_args, u"sep", String(repr(sep)))
+ self.add_kwarg(l_args, "sep", String(repr(sep)))
if end is not None:
- self.add_kwarg(l_args, u"end", String(repr(end)))
+ self.add_kwarg(l_args, "end", String(repr(end)))
if file is not None:
- self.add_kwarg(l_args, u"file", file)
- n_stmt = Call(Name(u"print"), l_args)
+ self.add_kwarg(l_args, "file", file)
+ n_stmt = Call(Name("print"), l_args)
n_stmt.prefix = node.prefix
return n_stmt
def add_kwarg(self, l_nodes, s_kwd, n_expr):
# XXX All this prefix-setting may lose comments (though rarely)
- n_expr.prefix = u""
+ n_expr.prefix = ""
n_argument = pytree.Node(self.syms.argument,
(Name(s_kwd),
- pytree.Leaf(token.EQUAL, u"="),
+ pytree.Leaf(token.EQUAL, "="),
n_expr))
if l_nodes:
l_nodes.append(Comma())
- n_argument.prefix = u" "
+ n_argument.prefix = " "
l_nodes.append(n_argument)
diff --git a/Lib/lib2to3/fixes/fix_raise.py b/Lib/lib2to3/fixes/fix_raise.py
index b958ba0129d..05aa21e74a3 100644
--- a/Lib/lib2to3/fixes/fix_raise.py
+++ b/Lib/lib2to3/fixes/fix_raise.py
@@ -55,11 +55,11 @@ class FixRaise(fixer_base.BaseFix):
# exc.children[1:-1] is the unparenthesized tuple
# exc.children[1].children[0] is the first element of the tuple
exc = exc.children[1].children[0].clone()
- exc.prefix = u" "
+ exc.prefix = " "
if "val" not in results:
# One-argument raise
- new = pytree.Node(syms.raise_stmt, [Name(u"raise"), exc])
+ new = pytree.Node(syms.raise_stmt, [Name("raise"), exc])
new.prefix = node.prefix
return new
@@ -67,24 +67,24 @@ class FixRaise(fixer_base.BaseFix):
if is_tuple(val):
args = [c.clone() for c in val.children[1:-1]]
else:
- val.prefix = u""
+ val.prefix = ""
args = [val]
if "tb" in results:
tb = results["tb"].clone()
- tb.prefix = u""
+ tb.prefix = ""
e = exc
# If there's a traceback and None is passed as the value, then don't
# add a call, since the user probably just wants to add a
# traceback. See issue #9661.
- if val.type != token.NAME or val.value != u"None":
+ if val.type != token.NAME or val.value != "None":
e = Call(exc, args)
- with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])]
- new = pytree.Node(syms.simple_stmt, [Name(u"raise")] + with_tb)
+ with_tb = Attr(e, Name('with_traceback')) + [ArgList([tb])]
+ new = pytree.Node(syms.simple_stmt, [Name("raise")] + with_tb)
new.prefix = node.prefix
return new
else:
return pytree.Node(syms.raise_stmt,
- [Name(u"raise"), Call(exc, args)],
+ [Name("raise"), Call(exc, args)],
prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_raw_input.py b/Lib/lib2to3/fixes/fix_raw_input.py
index 3a73b81864e..a51bb694b9e 100644
--- a/Lib/lib2to3/fixes/fix_raw_input.py
+++ b/Lib/lib2to3/fixes/fix_raw_input.py
@@ -14,4 +14,4 @@ class FixRawInput(fixer_base.BaseFix):
def transform(self, node, results):
name = results["name"]
- name.replace(Name(u"input", prefix=name.prefix))
+ name.replace(Name("input", prefix=name.prefix))
diff --git a/Lib/lib2to3/fixes/fix_reduce.py b/Lib/lib2to3/fixes/fix_reduce.py
index 6bd785c1cd9..00e5aa1c33d 100644
--- a/Lib/lib2to3/fixes/fix_reduce.py
+++ b/Lib/lib2to3/fixes/fix_reduce.py
@@ -32,4 +32,4 @@ class FixReduce(fixer_base.BaseFix):
"""
def transform(self, node, results):
- touch_import(u'functools', u'reduce', node)
+ touch_import('functools', 'reduce', node)
diff --git a/Lib/lib2to3/fixes/fix_renames.py b/Lib/lib2to3/fixes/fix_renames.py
index 4bcce8c4ebd..c0e3705ab7b 100644
--- a/Lib/lib2to3/fixes/fix_renames.py
+++ b/Lib/lib2to3/fixes/fix_renames.py
@@ -20,8 +20,8 @@ def alternates(members):
def build_pattern():
#bare = set()
- for module, replace in MAPPING.items():
- for old_attr, new_attr in replace.items():
+ for module, replace in list(MAPPING.items()):
+ for old_attr, new_attr in list(replace.items()):
LOOKUP[(module, old_attr)] = new_attr
#bare.add(module)
#bare.add(old_attr)
@@ -66,5 +66,5 @@ class FixRenames(fixer_base.BaseFix):
#import_mod = results.get("module")
if mod_name and attr_name:
- new_attr = unicode(LOOKUP[(mod_name.value, attr_name.value)])
+ new_attr = LOOKUP[(mod_name.value, attr_name.value)]
attr_name.replace(Name(new_attr, prefix=attr_name.prefix))
diff --git a/Lib/lib2to3/fixes/fix_repr.py b/Lib/lib2to3/fixes/fix_repr.py
index f34365647f0..1150bb8b9db 100644
--- a/Lib/lib2to3/fixes/fix_repr.py
+++ b/Lib/lib2to3/fixes/fix_repr.py
@@ -20,4 +20,4 @@ class FixRepr(fixer_base.BaseFix):
if expr.type == self.syms.testlist1:
expr = parenthesize(expr)
- return Call(Name(u"repr"), [expr], prefix=node.prefix)
+ return Call(Name("repr"), [expr], prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_set_literal.py b/Lib/lib2to3/fixes/fix_set_literal.py
index d3d38ec4e0a..762550cf73d 100644
--- a/Lib/lib2to3/fixes/fix_set_literal.py
+++ b/Lib/lib2to3/fixes/fix_set_literal.py
@@ -35,9 +35,9 @@ class FixSetLiteral(fixer_base.BaseFix):
items = results["items"]
# Build the contents of the literal
- literal = [pytree.Leaf(token.LBRACE, u"{")]
+ literal = [pytree.Leaf(token.LBRACE, "{")]
literal.extend(n.clone() for n in items.children)
- literal.append(pytree.Leaf(token.RBRACE, u"}"))
+ literal.append(pytree.Leaf(token.RBRACE, "}"))
# Set the prefix of the right brace to that of the ')' or ']'
literal[-1].prefix = items.next_sibling.prefix
maker = pytree.Node(syms.dictsetmaker, literal)
diff --git a/Lib/lib2to3/fixes/fix_standarderror.py b/Lib/lib2to3/fixes/fix_standarderror.py
index 6cad51116d0..dc742167e6e 100644
--- a/Lib/lib2to3/fixes/fix_standarderror.py
+++ b/Lib/lib2to3/fixes/fix_standarderror.py
@@ -15,4 +15,4 @@ class FixStandarderror(fixer_base.BaseFix):
"""
def transform(self, node, results):
- return Name(u"Exception", prefix=node.prefix)
+ return Name("Exception", prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_sys_exc.py b/Lib/lib2to3/fixes/fix_sys_exc.py
index 2ecca2b5354..f6039690374 100644
--- a/Lib/lib2to3/fixes/fix_sys_exc.py
+++ b/Lib/lib2to3/fixes/fix_sys_exc.py
@@ -13,7 +13,7 @@ from ..fixer_util import Attr, Call, Name, Number, Subscript, Node, syms
class FixSysExc(fixer_base.BaseFix):
# This order matches the ordering of sys.exc_info().
- exc_info = [u"exc_type", u"exc_value", u"exc_traceback"]
+ exc_info = ["exc_type", "exc_value", "exc_traceback"]
BM_compatible = True
PATTERN = """
power< 'sys' trailer< dot='.' attribute=(%s) > >
@@ -23,8 +23,8 @@ class FixSysExc(fixer_base.BaseFix):
sys_attr = results["attribute"][0]
index = Number(self.exc_info.index(sys_attr.value))
- call = Call(Name(u"exc_info"), prefix=sys_attr.prefix)
- attr = Attr(Name(u"sys"), call)
+ call = Call(Name("exc_info"), prefix=sys_attr.prefix)
+ attr = Attr(Name("sys"), call)
attr[1].children[0].prefix = results["dot"].prefix
attr.append(Subscript(index))
return Node(syms.power, attr, prefix=node.prefix)
diff --git a/Lib/lib2to3/fixes/fix_throw.py b/Lib/lib2to3/fixes/fix_throw.py
index 1468d89a450..aac29169b4e 100644
--- a/Lib/lib2to3/fixes/fix_throw.py
+++ b/Lib/lib2to3/fixes/fix_throw.py
@@ -32,7 +32,7 @@ class FixThrow(fixer_base.BaseFix):
return
# Leave "g.throw(E)" alone
- val = results.get(u"val")
+ val = results.get("val")
if val is None:
return
@@ -40,17 +40,17 @@ class FixThrow(fixer_base.BaseFix):
if is_tuple(val):
args = [c.clone() for c in val.children[1:-1]]
else:
- val.prefix = u""
+ val.prefix = ""
args = [val]
throw_args = results["args"]
if "tb" in results:
tb = results["tb"].clone()
- tb.prefix = u""
+ tb.prefix = ""
e = Call(exc, args)
- with_tb = Attr(e, Name(u'with_traceback')) + [ArgList([tb])]
+ with_tb = Attr(e, Name('with_traceback')) + [ArgList([tb])]
throw_args.replace(pytree.Node(syms.power, with_tb))
else:
throw_args.replace(Call(exc, args))
diff --git a/Lib/lib2to3/fixes/fix_tuple_params.py b/Lib/lib2to3/fixes/fix_tuple_params.py
index 6361717dc54..cad755ffdbe 100644
--- a/Lib/lib2to3/fixes/fix_tuple_params.py
+++ b/Lib/lib2to3/fixes/fix_tuple_params.py
@@ -58,8 +58,8 @@ class FixTupleParams(fixer_base.BaseFix):
end = Newline()
else:
start = 0
- indent = u"; "
- end = pytree.Leaf(token.INDENT, u"")
+ indent = "; "
+ end = pytree.Leaf(token.INDENT, "")
# We need access to self for new_name(), and making this a method
# doesn't feel right. Closing over self and new_lines makes the
@@ -67,10 +67,10 @@ class FixTupleParams(fixer_base.BaseFix):
def handle_tuple(tuple_arg, add_prefix=False):
n = Name(self.new_name())
arg = tuple_arg.clone()
- arg.prefix = u""
+ arg.prefix = ""
stmt = Assign(arg, n.clone())
if add_prefix:
- n.prefix = u" "
+ n.prefix = " "
tuple_arg.replace(n)
new_lines.append(pytree.Node(syms.simple_stmt,
[stmt, end.clone()]))
@@ -95,7 +95,7 @@ class FixTupleParams(fixer_base.BaseFix):
# TODO(cwinter) suite-cleanup
after = start
if start == 0:
- new_lines[0].prefix = u" "
+ new_lines[0].prefix = " "
elif is_docstring(suite[0].children[start]):
new_lines[0].prefix = indent
after = start + 1
@@ -115,7 +115,7 @@ class FixTupleParams(fixer_base.BaseFix):
# Replace lambda ((((x)))): x with lambda x: x
if inner.type == token.NAME:
inner = inner.clone()
- inner.prefix = u" "
+ inner.prefix = " "
args.replace(inner)
return
@@ -123,7 +123,7 @@ class FixTupleParams(fixer_base.BaseFix):
to_index = map_to_index(params)
tup_name = self.new_name(tuple_name(params))
- new_param = Name(tup_name, prefix=u" ")
+ new_param = Name(tup_name, prefix=" ")
args.replace(new_param.clone())
for n in body.post_order():
if n.type == token.NAME and n.value in to_index:
@@ -158,7 +158,7 @@ def map_to_index(param_list, prefix=[], d=None):
if d is None:
d = {}
for i, obj in enumerate(param_list):
- trailer = [Subscript(Number(unicode(i)))]
+ trailer = [Subscript(Number(str(i)))]
if isinstance(obj, list):
map_to_index(obj, trailer, d=d)
else:
@@ -172,4 +172,4 @@ def tuple_name(param_list):
l.append(tuple_name(obj))
else:
l.append(obj)
- return u"_".join(l)
+ return "_".join(l)
diff --git a/Lib/lib2to3/fixes/fix_types.py b/Lib/lib2to3/fixes/fix_types.py
index fc9d4959276..db341047855 100644
--- a/Lib/lib2to3/fixes/fix_types.py
+++ b/Lib/lib2to3/fixes/fix_types.py
@@ -56,7 +56,7 @@ class FixTypes(fixer_base.BaseFix):
PATTERN = '|'.join(_pats)
def transform(self, node, results):
- new_value = unicode(_TYPE_MAPPING.get(results["name"].value))
+ new_value = _TYPE_MAPPING.get(results["name"].value)
if new_value:
return Name(new_value, prefix=node.prefix)
return None
diff --git a/Lib/lib2to3/fixes/fix_unicode.py b/Lib/lib2to3/fixes/fix_unicode.py
index 6c89576540c..d2b3ceeb910 100644
--- a/Lib/lib2to3/fixes/fix_unicode.py
+++ b/Lib/lib2to3/fixes/fix_unicode.py
@@ -6,8 +6,8 @@ import re
from ..pgen2 import token
from .. import fixer_base
-_mapping = {u"unichr" : u"chr", u"unicode" : u"str"}
-_literal_re = re.compile(ur"[uU][rR]?[\'\"]")
+_mapping = {"unichr" : "chr", "unicode" : "str"}
+_literal_re = re.compile(r"[uU][rR]?[\'\"]")
class FixUnicode(fixer_base.BaseFix):
BM_compatible = True
diff --git a/Lib/lib2to3/fixes/fix_urllib.py b/Lib/lib2to3/fixes/fix_urllib.py
index 34e1b2702ba..1481cd91e3c 100644
--- a/Lib/lib2to3/fixes/fix_urllib.py
+++ b/Lib/lib2to3/fixes/fix_urllib.py
@@ -128,7 +128,7 @@ class FixUrllib(FixImports):
else:
member_name = member.value
as_name = None
- if member_name != u",":
+ if member_name != ",":
for change in MAPPING[mod_member.value]:
if member_name in change[1]:
if change[0] not in mod_dict:
diff --git a/Lib/lib2to3/fixes/fix_ws_comma.py b/Lib/lib2to3/fixes/fix_ws_comma.py
index 37ff6244a93..a54a376c472 100644
--- a/Lib/lib2to3/fixes/fix_ws_comma.py
+++ b/Lib/lib2to3/fixes/fix_ws_comma.py
@@ -17,8 +17,8 @@ class FixWsComma(fixer_base.BaseFix):
any<(not(',') any)+ ',' ((not(',') any)+ ',')* [not(',') any]>
"""
- COMMA = pytree.Leaf(token.COMMA, u",")
- COLON = pytree.Leaf(token.COLON, u":")
+ COMMA = pytree.Leaf(token.COMMA, ",")
+ COLON = pytree.Leaf(token.COLON, ":")
SEPS = (COMMA, COLON)
def transform(self, node, results):
@@ -27,13 +27,13 @@ class FixWsComma(fixer_base.BaseFix):
for child in new.children:
if child in self.SEPS:
prefix = child.prefix
- if prefix.isspace() and u"\n" not in prefix:
- child.prefix = u""
+ if prefix.isspace() and "\n" not in prefix:
+ child.prefix = ""
comma = True
else:
if comma:
prefix = child.prefix
if not prefix:
- child.prefix = u" "
+ child.prefix = " "
comma = False
return new
diff --git a/Lib/lib2to3/fixes/fix_xrange.py b/Lib/lib2to3/fixes/fix_xrange.py
index f1436724b45..1e491e166a3 100644
--- a/Lib/lib2to3/fixes/fix_xrange.py
+++ b/Lib/lib2to3/fixes/fix_xrange.py
@@ -26,25 +26,25 @@ class FixXrange(fixer_base.BaseFix):
def transform(self, node, results):
name = results["name"]
- if name.value == u"xrange":
+ if name.value == "xrange":
return self.transform_xrange(node, results)
- elif name.value == u"range":
+ elif name.value == "range":
return self.transform_range(node, results)
else:
raise ValueError(repr(name))
def transform_xrange(self, node, results):
name = results["name"]
- name.replace(Name(u"range", prefix=name.prefix))
+ name.replace(Name("range", prefix=name.prefix))
# This prevents the new range call from being wrapped in a list later.
self.transformed_xranges.add(id(node))
def transform_range(self, node, results):
if (id(node) not in self.transformed_xranges and
not self.in_special_context(node)):
- range_call = Call(Name(u"range"), [results["args"].clone()])
+ range_call = Call(Name("range"), [results["args"].clone()])
# Encase the range call in list().
- list_call = Call(Name(u"list"), [range_call],
+ list_call = Call(Name("list"), [range_call],
prefix=node.prefix)
# Put things that were after the range() call after the list call.
for n in results["rest"]:
diff --git a/Lib/lib2to3/fixes/fix_xreadlines.py b/Lib/lib2to3/fixes/fix_xreadlines.py
index f50b9a27558..3e3f71ab045 100644
--- a/Lib/lib2to3/fixes/fix_xreadlines.py
+++ b/Lib/lib2to3/fixes/fix_xreadlines.py
@@ -20,6 +20,6 @@ class FixXreadlines(fixer_base.BaseFix):
no_call = results.get("no_call")
if no_call:
- no_call.replace(Name(u"__iter__", prefix=no_call.prefix))
+ no_call.replace(Name("__iter__", prefix=no_call.prefix))
else:
node.replace([x.clone() for x in results["call"]])
diff --git a/Lib/lib2to3/fixes/fix_zip.py b/Lib/lib2to3/fixes/fix_zip.py
index c5d7b66d673..8f36a94fb4f 100644
--- a/Lib/lib2to3/fixes/fix_zip.py
+++ b/Lib/lib2to3/fixes/fix_zip.py
@@ -29,7 +29,7 @@ class FixZip(fixer_base.ConditionalFix):
return None
new = node.clone()
- new.prefix = u""
- new = Call(Name(u"list"), [new])
+ new.prefix = ""
+ new = Call(Name("list"), [new])
new.prefix = node.prefix
return new
diff --git a/Lib/lib2to3/main.py b/Lib/lib2to3/main.py
index ad0625e5273..f9cc18b5d3f 100644
--- a/Lib/lib2to3/main.py
+++ b/Lib/lib2to3/main.py
@@ -90,11 +90,11 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
if os.path.lexists(backup):
try:
os.remove(backup)
- except os.error, err:
+ except os.error as err:
self.log_message("Can't remove backup %s", backup)
try:
os.rename(filename, backup)
- except os.error, err:
+ except os.error as err:
self.log_message("Can't rename %s to %s", filename, backup)
# Actually write the new file
write = super(StdoutRefactoringTool, self).write_file
@@ -116,19 +116,18 @@ class StdoutRefactoringTool(refactor.MultiprocessRefactoringTool):
if self.output_lock is not None:
with self.output_lock:
for line in diff_lines:
- print line
+ print(line)
sys.stdout.flush()
else:
for line in diff_lines:
- print line
+ print(line)
except UnicodeEncodeError:
warn("couldn't encode %s's diff for your terminal" %
(filename,))
return
-
def warn(msg):
- print >> sys.stderr, "WARNING: %s" % (msg,)
+ print("WARNING: %s" % (msg,), file=sys.stderr)
def main(fixer_pkg, args=None):
@@ -195,19 +194,19 @@ def main(fixer_pkg, args=None):
if not options.write and options.nobackups:
parser.error("Can't use -n without -w")
if options.list_fixes:
- print "Available transformations for the -f/--fix option:"
+ print("Available transformations for the -f/--fix option:")
for fixname in refactor.get_all_fix_names(fixer_pkg):
- print fixname
+ print(fixname)
if not args:
return 0
if not args:
- print >> sys.stderr, "At least one file or directory argument required."
- print >> sys.stderr, "Use --help to show usage."
+ print("At least one file or directory argument required.", file=sys.stderr)
+ print("Use --help to show usage.", file=sys.stderr)
return 2
if "-" in args:
refactor_stdin = True
if options.write:
- print >> sys.stderr, "Can't write to stdin."
+ print("Can't write to stdin.", file=sys.stderr)
return 2
if options.print_function:
flags["print_function"] = True
@@ -260,8 +259,8 @@ def main(fixer_pkg, args=None):
options.processes)
except refactor.MultiprocessingUnsupported:
assert options.processes > 1
- print >> sys.stderr, "Sorry, -j isn't " \
- "supported on this platform."
+ print("Sorry, -j isn't supported on this platform.",
+ file=sys.stderr)
return 1
rt.summarize()
diff --git a/Lib/lib2to3/patcomp.py b/Lib/lib2to3/patcomp.py
index 093e5f9f8df..0a259e90afd 100644
--- a/Lib/lib2to3/patcomp.py
+++ b/Lib/lib2to3/patcomp.py
@@ -11,8 +11,8 @@ The compiler compiles a pattern to a pytree.*Pattern instance.
__author__ = "Guido van Rossum <guido@python.org>"
# Python imports
+import io
import os
-import StringIO
# Fairly local imports
from .pgen2 import driver, literals, token, tokenize, parse, grammar
@@ -33,7 +33,7 @@ class PatternSyntaxError(Exception):
def tokenize_wrapper(input):
"""Tokenizes a string suppressing significant whitespace."""
skip = set((token.NEWLINE, token.INDENT, token.DEDENT))
- tokens = tokenize.generate_tokens(StringIO.StringIO(input).readline)
+ tokens = tokenize.generate_tokens(io.StringIO(input).readline)
for quintuple in tokens:
type, value, start, end, line_text = quintuple
if type not in skip:
@@ -141,7 +141,7 @@ class PatternCompiler(object):
assert len(nodes) >= 1
node = nodes[0]
if node.type == token.STRING:
- value = unicode(literals.evalString(node.value))
+ value = str(literals.evalString(node.value))
return pytree.LeafPattern(_type_of_literal(value), value)
elif node.type == token.NAME:
value = node.value
diff --git a/Lib/lib2to3/pgen2/conv.py b/Lib/lib2to3/pgen2/conv.py
index 28fbb0b95f0..bf49762ae48 100644
--- a/Lib/lib2to3/pgen2/conv.py
+++ b/Lib/lib2to3/pgen2/conv.py
@@ -60,8 +60,8 @@ class Converter(grammar.Grammar):
"""
try:
f = open(filename)
- except IOError, err:
- print "Can't open %s: %s" % (filename, err)
+ except IOError as err:
+ print("Can't open %s: %s" % (filename, err))
return False
self.symbol2number = {}
self.number2symbol = {}
@@ -70,8 +70,8 @@ class Converter(grammar.Grammar):
lineno += 1
mo = re.match(r"^#define\s+(\w+)\s+(\d+)$", line)
if not mo and line.strip():
- print "%s(%s): can't parse %s" % (filename, lineno,
- line.strip())
+ print("%s(%s): can't parse %s" % (filename, lineno,
+ line.strip()))
else:
symbol, number = mo.groups()
number = int(number)
@@ -111,20 +111,20 @@ class Converter(grammar.Grammar):
"""
try:
f = open(filename)
- except IOError, err:
- print "Can't open %s: %s" % (filename, err)
+ except IOError as err:
+ print("Can't open %s: %s" % (filename, err))
return False
# The code below essentially uses f's iterator-ness!
lineno = 0
# Expect the two #include lines
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == '#include "pgenheaders.h"\n', (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == '#include "grammar.h"\n', (lineno, line)
# Parse the state definitions
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
allarcs = {}
states = []
while line.startswith("static arc "):
@@ -132,35 +132,35 @@ class Converter(grammar.Grammar):
mo = re.match(r"static arc arcs_(\d+)_(\d+)\[(\d+)\] = {$",
line)
assert mo, (lineno, line)
- n, m, k = map(int, mo.groups())
+ n, m, k = list(map(int, mo.groups()))
arcs = []
for _ in range(k):
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"\s+{(\d+), (\d+)},$", line)
assert mo, (lineno, line)
- i, j = map(int, mo.groups())
+ i, j = list(map(int, mo.groups()))
arcs.append((i, j))
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "};\n", (lineno, line)
allarcs[(n, m)] = arcs
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"static state states_(\d+)\[(\d+)\] = {$", line)
assert mo, (lineno, line)
- s, t = map(int, mo.groups())
+ s, t = list(map(int, mo.groups()))
assert s == len(states), (lineno, line)
state = []
for _ in range(t):
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"\s+{(\d+), arcs_(\d+)_(\d+)},$", line)
assert mo, (lineno, line)
- k, n, m = map(int, mo.groups())
+ k, n, m = list(map(int, mo.groups()))
arcs = allarcs[n, m]
assert k == len(arcs), (lineno, line)
state.append(arcs)
states.append(state)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "};\n", (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
self.states = states
# Parse the dfas
@@ -169,18 +169,18 @@ class Converter(grammar.Grammar):
assert mo, (lineno, line)
ndfas = int(mo.group(1))
for i in range(ndfas):
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r'\s+{(\d+), "(\w+)", (\d+), (\d+), states_(\d+),$',
line)
assert mo, (lineno, line)
symbol = mo.group(2)
- number, x, y, z = map(int, mo.group(1, 3, 4, 5))
+ number, x, y, z = list(map(int, mo.group(1, 3, 4, 5)))
assert self.symbol2number[symbol] == number, (lineno, line)
assert self.number2symbol[number] == symbol, (lineno, line)
assert x == 0, (lineno, line)
state = states[z]
assert y == len(state), (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r'\s+("(?:\\\d\d\d)*")},$', line)
assert mo, (lineno, line)
first = {}
@@ -191,18 +191,18 @@ class Converter(grammar.Grammar):
if byte & (1<<j):
first[i*8 + j] = 1
dfas[number] = (state, first)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "};\n", (lineno, line)
self.dfas = dfas
# Parse the labels
labels = []
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"static label labels\[(\d+)\] = {$", line)
assert mo, (lineno, line)
nlabels = int(mo.group(1))
for i in range(nlabels):
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r'\s+{(\d+), (0|"\w+")},$', line)
assert mo, (lineno, line)
x, y = mo.groups()
@@ -212,35 +212,35 @@ class Converter(grammar.Grammar):
else:
y = eval(y)
labels.append((x, y))
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "};\n", (lineno, line)
self.labels = labels
# Parse the grammar struct
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "grammar _PyParser_Grammar = {\n", (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"\s+(\d+),$", line)
assert mo, (lineno, line)
ndfas = int(mo.group(1))
assert ndfas == len(self.dfas)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "\tdfas,\n", (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"\s+{(\d+), labels},$", line)
assert mo, (lineno, line)
nlabels = int(mo.group(1))
assert nlabels == len(self.labels), (lineno, line)
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
mo = re.match(r"\s+(\d+)$", line)
assert mo, (lineno, line)
start = int(mo.group(1))
assert start in self.number2symbol, (lineno, line)
self.start = start
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
assert line == "};\n", (lineno, line)
try:
- lineno, line = lineno+1, f.next()
+ lineno, line = lineno+1, next(f)
except StopIteration:
pass
else:
diff --git a/Lib/lib2to3/pgen2/driver.py b/Lib/lib2to3/pgen2/driver.py
index 39dafb92acc..4c611c66401 100644
--- a/Lib/lib2to3/pgen2/driver.py
+++ b/Lib/lib2to3/pgen2/driver.py
@@ -17,9 +17,9 @@ __all__ = ["Driver", "load_grammar"]
# Python imports
import codecs
+import io
import os
import logging
-import StringIO
import sys
# Pgen imports
@@ -43,7 +43,7 @@ class Driver(object):
lineno = 1
column = 0
type = value = start = end = line_text = None
- prefix = u""
+ prefix = ""
for quintuple in tokens:
type, value, start, end, line_text = quintuple
if start != (lineno, column):
@@ -102,7 +102,7 @@ class Driver(object):
def parse_string(self, text, debug=False):
"""Parse a string and return the syntax tree."""
- tokens = tokenize.generate_tokens(StringIO.StringIO(text).readline)
+ tokens = tokenize.generate_tokens(io.StringIO(text).readline)
return self.parse_tokens(tokens, debug)
@@ -123,7 +123,7 @@ def load_grammar(gt="Grammar.txt", gp=None,
logger.info("Writing grammar tables to %s", gp)
try:
g.dump(gp)
- except IOError, e:
+ except IOError as e:
logger.info("Writing failed:"+str(e))
else:
g = grammar.Grammar()
diff --git a/Lib/lib2to3/pgen2/grammar.py b/Lib/lib2to3/pgen2/grammar.py
index 0483424dc42..26caeb4ba5a 100644
--- a/Lib/lib2to3/pgen2/grammar.py
+++ b/Lib/lib2to3/pgen2/grammar.py
@@ -113,17 +113,17 @@ class Grammar(object):
def report(self):
"""Dump the grammar tables to standard output, for debugging."""
from pprint import pprint
- print "s2n"
+ print("s2n")
pprint(self.symbol2number)
- print "n2s"
+ print("n2s")
pprint(self.number2symbol)
- print "states"
+ print("states")
pprint(self.states)
- print "dfas"
+ print("dfas")
pprint(self.dfas)
- print "labels"
+ print("labels")
pprint(self.labels)
- print "start", self.start
+ print("start", self.start)
# Map from operator to number (since tokenize doesn't do this)
diff --git a/Lib/lib2to3/pgen2/literals.py b/Lib/lib2to3/pgen2/literals.py
index 0b3948a54ea..4f50d31e6ba 100644
--- a/Lib/lib2to3/pgen2/literals.py
+++ b/Lib/lib2to3/pgen2/literals.py
@@ -53,7 +53,7 @@ def test():
s = repr(c)
e = evalString(s)
if e != c:
- print i, c, s, e
+ print(i, c, s, e)
if __name__ == "__main__":
diff --git a/Lib/lib2to3/pgen2/pgen.py b/Lib/lib2to3/pgen2/pgen.py
index 63084a4cd5b..2c51eef9131 100644
--- a/Lib/lib2to3/pgen2/pgen.py
+++ b/Lib/lib2to3/pgen2/pgen.py
@@ -26,7 +26,7 @@ class ParserGenerator(object):
def make_grammar(self):
c = PgenGrammar()
- names = self.dfas.keys()
+ names = list(self.dfas.keys())
names.sort()
names.remove(self.startsymbol)
names.insert(0, self.startsymbol)
@@ -39,7 +39,7 @@ class ParserGenerator(object):
states = []
for state in dfa:
arcs = []
- for label, next in state.arcs.iteritems():
+ for label, next in state.arcs.items():
arcs.append((self.make_label(c, label), dfa.index(next)))
if state.isfinal:
arcs.append((0, dfa.index(state)))
@@ -105,7 +105,7 @@ class ParserGenerator(object):
return ilabel
def addfirstsets(self):
- names = self.dfas.keys()
+ names = list(self.dfas.keys())
names.sort()
for name in names:
if name not in self.first:
@@ -118,7 +118,7 @@ class ParserGenerator(object):
state = dfa[0]
totalset = {}
overlapcheck = {}
- for label, next in state.arcs.iteritems():
+ for label, next in state.arcs.items():
if label in self.dfas:
if label in self.first:
fset = self.first[label]
@@ -133,7 +133,7 @@ class ParserGenerator(object):
totalset[label] = 1
overlapcheck[label] = {label: 1}
inverse = {}
- for label, itsfirst in overlapcheck.iteritems():
+ for label, itsfirst in overlapcheck.items():
for symbol in itsfirst:
if symbol in inverse:
raise ValueError("rule %s is ambiguous; %s is in the"
@@ -192,7 +192,7 @@ class ParserGenerator(object):
for label, next in nfastate.arcs:
if label is not None:
addclosure(next, arcs.setdefault(label, {}))
- for label, nfaset in arcs.iteritems():
+ for label, nfaset in arcs.items():
for st in states:
if st.nfaset == nfaset:
break
@@ -203,10 +203,10 @@ class ParserGenerator(object):
return states # List of DFAState instances; first one is start
def dump_nfa(self, name, start, finish):
- print "Dump of NFA for", name
+ print("Dump of NFA for", name)
todo = [start]
for i, state in enumerate(todo):
- print " State", i, state is finish and "(final)" or ""
+ print(" State", i, state is finish and "(final)" or "")
for label, next in state.arcs:
if next in todo:
j = todo.index(next)
@@ -214,16 +214,16 @@ class ParserGenerator(object):
j = len(todo)
todo.append(next)
if label is None:
- print " -> %d" % j
+ print(" -> %d" % j)
else:
- print " %s -> %d" % (label, j)
+ print(" %s -> %d" % (label, j))
def dump_dfa(self, name, dfa):
- print "Dump of DFA for", name
+ print("Dump of DFA for", name)
for i, state in enumerate(dfa):
- print " State", i, state.isfinal and "(final)" or ""
- for label, next in state.arcs.iteritems():
- print " %s -> %d" % (label, dfa.index(next))
+ print(" State", i, state.isfinal and "(final)" or "")
+ for label, next in state.arcs.items():
+ print(" %s -> %d" % (label, dfa.index(next)))
def simplify_dfa(self, dfa):
# This is not theoretically optimal, but works well enough.
@@ -319,9 +319,9 @@ class ParserGenerator(object):
return value
def gettoken(self):
- tup = self.generator.next()
+ tup = next(self.generator)
while tup[0] in (tokenize.COMMENT, tokenize.NL):
- tup = self.generator.next()
+ tup = next(self.generator)
self.type, self.value, self.begin, self.end, self.line = tup
#print token.tok_name[self.type], repr(self.value)
@@ -330,7 +330,7 @@ class ParserGenerator(object):
try:
msg = msg % args
except:
- msg = " ".join([msg] + map(str, args))
+ msg = " ".join([msg] + list(map(str, args)))
raise SyntaxError(msg, (self.filename, self.end[0],
self.end[1], self.line))
@@ -348,7 +348,7 @@ class DFAState(object):
def __init__(self, nfaset, final):
assert isinstance(nfaset, dict)
- assert isinstance(iter(nfaset).next(), NFAState)
+ assert isinstance(next(iter(nfaset)), NFAState)
assert isinstance(final, NFAState)
self.nfaset = nfaset
self.isfinal = final in nfaset
@@ -361,7 +361,7 @@ class DFAState(object):
self.arcs[label] = next
def unifystate(self, old, new):
- for label, next in self.arcs.iteritems():
+ for label, next in self.arcs.items():
if next is old:
self.arcs[label] = new
@@ -374,7 +374,7 @@ class DFAState(object):
# would invoke this method recursively, with cycles...
if len(self.arcs) != len(other.arcs):
return False
- for label, next in self.arcs.iteritems():
+ for label, next in self.arcs.items():
if next is not other.arcs.get(label):
return False
return True
diff --git a/Lib/lib2to3/pgen2/token.py b/Lib/lib2to3/pgen2/token.py
index 61468b313e7..6a6d0b6b650 100755
--- a/Lib/lib2to3/pgen2/token.py
+++ b/Lib/lib2to3/pgen2/token.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Token constants (from "token.h")."""
@@ -67,7 +67,7 @@ NT_OFFSET = 256
#--end constants--
tok_name = {}
-for _name, _value in globals().items():
+for _name, _value in list(globals().items()):
if type(_value) is type(0):
tok_name[_value] = _name
diff --git a/Lib/lib2to3/pgen2/tokenize.py b/Lib/lib2to3/pgen2/tokenize.py
index e090aa98ddb..31e29698e62 100644
--- a/Lib/lib2to3/pgen2/tokenize.py
+++ b/Lib/lib2to3/pgen2/tokenize.py
@@ -102,8 +102,8 @@ ContStr = group(r"[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" +
PseudoExtras = group(r'\\\r?\n', Comment, Triple)
PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name)
-tokenprog, pseudoprog, single3prog, double3prog = map(
- re.compile, (Token, PseudoToken, Single3, Double3))
+tokenprog, pseudoprog, single3prog, double3prog = list(map(
+ re.compile, (Token, PseudoToken, Single3, Double3)))
endprogs = {"'": re.compile(Single), '"': re.compile(Double),
"'''": single3prog, '"""': double3prog,
"r'''": single3prog, 'r"""': double3prog,
@@ -151,11 +151,11 @@ class TokenError(Exception): pass
class StopTokenizing(Exception): pass
-def printtoken(type, token, start, end, line): # for testing
- (srow, scol) = start
- (erow, ecol) = end
- print "%d,%d-%d,%d:\t%s\t%s" % \
- (srow, scol, erow, ecol, tok_name[type], repr(token))
+def printtoken(type, token, xxx_todo_changeme, xxx_todo_changeme1, line): # for testing
+ (srow, scol) = xxx_todo_changeme
+ (erow, ecol) = xxx_todo_changeme1
+ print("%d,%d-%d,%d:\t%s\t%s" % \
+ (srow, scol, erow, ecol, tok_name[type], repr(token)))
def tokenize(readline, tokeneater=printtoken):
"""
@@ -374,7 +374,7 @@ def generate_tokens(readline):
if contstr: # continued string
if not line:
- raise TokenError, ("EOF in multi-line string", strstart)
+ raise TokenError("EOF in multi-line string", strstart)
endmatch = endprog.match(line)
if endmatch:
pos = end = endmatch.end(0)
@@ -430,7 +430,7 @@ def generate_tokens(readline):
else: # continued statement
if not line:
- raise TokenError, ("EOF in multi-line statement", (lnum, 0))
+ raise TokenError("EOF in multi-line statement", (lnum, 0))
continued = 0
while pos < max:
diff --git a/Lib/lib2to3/pygram.py b/Lib/lib2to3/pygram.py
index 621ff24c954..01fa1087115 100644
--- a/Lib/lib2to3/pygram.py
+++ b/Lib/lib2to3/pygram.py
@@ -25,7 +25,7 @@ class Symbols(object):
Creates an attribute for each grammar symbol (nonterminal),
whose value is the symbol's type (an int >= 256).
"""
- for name, symbol in grammar.symbol2number.iteritems():
+ for name, symbol in grammar.symbol2number.items():
setattr(self, name, symbol)
diff --git a/Lib/lib2to3/pytree.py b/Lib/lib2to3/pytree.py
index 179caca51f2..fa4942f3921 100644
--- a/Lib/lib2to3/pytree.py
+++ b/Lib/lib2to3/pytree.py
@@ -14,7 +14,7 @@ __author__ = "Guido van Rossum <guido@python.org>"
import sys
import warnings
-from StringIO import StringIO
+from io import StringIO
HUGE = 0x7FFFFFFF # maximum repeat count, default max
@@ -229,12 +229,12 @@ class Base(object):
"""
next_sib = self.next_sibling
if next_sib is None:
- return u""
+ return ""
return next_sib.prefix
if sys.version_info < (3, 0):
def __str__(self):
- return unicode(self).encode("ascii")
+ return str(self).encode("ascii")
class Node(Base):
@@ -277,7 +277,7 @@ class Node(Base):
This reproduces the input source exactly.
"""
- return u"".join(map(unicode, self.children))
+ return "".join(map(str, self.children))
if sys.version_info > (3, 0):
__str__ = __unicode__
@@ -388,7 +388,7 @@ class Leaf(Base):
This reproduces the input source exactly.
"""
- return self.prefix + unicode(self.value)
+ return self.prefix + str(self.value)
if sys.version_info > (3, 0):
__str__ = __unicode__
@@ -548,7 +548,7 @@ class LeafPattern(BasePattern):
if type is not None:
assert 0 <= type < 256, type
if content is not None:
- assert isinstance(content, basestring), repr(content)
+ assert isinstance(content, str), repr(content)
self.type = type
self.content = content
self.name = name
@@ -598,7 +598,7 @@ class NodePattern(BasePattern):
if type is not None:
assert type >= 256, type
if content is not None:
- assert not isinstance(content, basestring), repr(content)
+ assert not isinstance(content, str), repr(content)
content = list(content)
for i, item in enumerate(content):
assert isinstance(item, BasePattern), (i, item)
@@ -733,7 +733,7 @@ class WildcardPattern(BasePattern):
"""
if self.content is None:
# Shortcut for special case (see __init__.__doc__)
- for count in xrange(self.min, 1 + min(len(nodes), self.max)):
+ for count in range(self.min, 1 + min(len(nodes), self.max)):
r = {}
if self.name:
r[self.name] = nodes[:count]
@@ -743,8 +743,8 @@ class WildcardPattern(BasePattern):
else:
# The reason for this is that hitting the recursion limit usually
# results in some ugly messages about how RuntimeErrors are being
- # ignored. We don't do this on non-CPython implementation because
- # they don't have this problem.
+ # ignored. We only have to do this on CPython, though, because other
+ # implementations don't have this nasty bug in the first place.
if hasattr(sys, "getrefcount"):
save_stderr = sys.stderr
sys.stderr = StringIO()
diff --git a/Lib/lib2to3/refactor.py b/Lib/lib2to3/refactor.py
index a4c168df9e0..38fb8ed9e22 100644
--- a/Lib/lib2to3/refactor.py
+++ b/Lib/lib2to3/refactor.py
@@ -19,7 +19,7 @@ import sys
import logging
import operator
import collections
-import StringIO
+import io
from itertools import chain
# Local imports
@@ -94,7 +94,7 @@ def _get_headnode_dict(fixer_list):
head_nodes[fixer._accept_type].append(fixer)
else:
every.append(fixer)
- for node_type in chain(pygram.python_grammar.symbol2number.itervalues(),
+ for node_type in chain(pygram.python_grammar.symbol2number.values(),
pygram.python_grammar.tokens):
head_nodes[node_type].extend(every)
return dict(head_nodes)
@@ -115,10 +115,10 @@ if sys.version_info < (3, 0):
_open_with_encoding = codecs.open
# codecs.open doesn't translate newlines sadly.
def _from_system_newlines(input):
- return input.replace(u"\r\n", u"\n")
+ return input.replace("\r\n", "\n")
def _to_system_newlines(input):
if os.linesep != "\n":
- return input.replace(u"\n", os.linesep)
+ return input.replace("\n", os.linesep)
else:
return input
else:
@@ -129,9 +129,9 @@ else:
def _detect_future_features(source):
have_docstring = False
- gen = tokenize.generate_tokens(StringIO.StringIO(source).readline)
+ gen = tokenize.generate_tokens(io.StringIO(source).readline)
def advance():
- tok = gen.next()
+ tok = next(gen)
return tok[0], tok[1]
ignore = frozenset((token.NEWLINE, tokenize.NL, token.COMMENT))
features = set()
@@ -144,20 +144,20 @@ def _detect_future_features(source):
if have_docstring:
break
have_docstring = True
- elif tp == token.NAME and value == u"from":
+ elif tp == token.NAME and value == "from":
tp, value = advance()
- if tp != token.NAME or value != u"__future__":
+ if tp != token.NAME or value != "__future__":
break
tp, value = advance()
- if tp != token.NAME or value != u"import":
+ if tp != token.NAME or value != "import":
break
tp, value = advance()
- if tp == token.OP and value == u"(":
+ if tp == token.OP and value == "(":
tp, value = advance()
while tp == token.NAME:
features.add(value)
tp, value = advance()
- if tp != token.OP or value != u",":
+ if tp != token.OP or value != ",":
break
tp, value = advance()
else:
@@ -342,7 +342,7 @@ class RefactoringTool(object):
if input is None:
# Reading the file failed.
return
- input += u"\n" # Silence certain parse errors
+ input += "\n" # Silence certain parse errors
if doctests_only:
self.log_debug("Refactoring doctests in %s", filename)
output = self.refactor_docstring(input, filename)
@@ -354,7 +354,7 @@ class RefactoringTool(object):
tree = self.refactor_string(input, filename)
if self.write_unchanged_files or (tree and tree.was_changed):
# The [:-1] is to take off the \n we added earlier
- self.processed_file(unicode(tree)[:-1], filename,
+ self.processed_file(str(tree)[:-1], filename,
write=write, encoding=encoding)
else:
self.log_debug("No changes in %s", filename)
@@ -398,7 +398,7 @@ class RefactoringTool(object):
else:
tree = self.refactor_string(input, "<stdin>")
if self.write_unchanged_files or (tree and tree.was_changed):
- self.processed_file(unicode(tree), "<stdin>", input)
+ self.processed_file(str(tree), "<stdin>", input)
else:
self.log_debug("No changes in stdin")
@@ -578,7 +578,7 @@ class RefactoringTool(object):
indent = line[:i]
elif (indent is not None and
(line.startswith(indent + self.PS2) or
- line == indent + self.PS2.rstrip() + u"\n")):
+ line == indent + self.PS2.rstrip() + "\n")):
block.append(line)
else:
if block is not None:
@@ -590,7 +590,7 @@ class RefactoringTool(object):
if block is not None:
result.extend(self.refactor_doctest(block, block_lineno,
indent, filename))
- return u"".join(result)
+ return "".join(result)
def refactor_doctest(self, block, lineno, indent, filename):
"""Refactors one doctest.
@@ -605,17 +605,17 @@ class RefactoringTool(object):
except Exception as err:
if self.logger.isEnabledFor(logging.DEBUG):
for line in block:
- self.log_debug("Source: %s", line.rstrip(u"\n"))
+ self.log_debug("Source: %s", line.rstrip("\n"))
self.log_error("Can't parse docstring in %s line %s: %s: %s",
filename, lineno, err.__class__.__name__, err)
return block
if self.refactor_tree(tree, filename):
- new = unicode(tree).splitlines(True)
+ new = str(tree).splitlines(True)
# Undo the adjustment of the line numbers in wrap_toks() below.
clipped, new = new[:lineno-1], new[lineno-1:]
- assert clipped == [u"\n"] * (lineno-1), clipped
- if not new[-1].endswith(u"\n"):
- new[-1] += u"\n"
+ assert clipped == ["\n"] * (lineno-1), clipped
+ if not new[-1].endswith("\n"):
+ new[-1] += "\n"
block = [indent + self.PS1 + new.pop(0)]
if new:
block += [indent + self.PS2 + line for line in new]
@@ -656,7 +656,7 @@ class RefactoringTool(object):
def wrap_toks(self, block, lineno, indent):
"""Wraps a tokenize stream to systematically modify start/end."""
- tokens = tokenize.generate_tokens(self.gen_lines(block, indent).next)
+ tokens = tokenize.generate_tokens(self.gen_lines(block, indent).__next__)
for type, value, (line0, col0), (line1, col1), line_text in tokens:
line0 += lineno - 1
line1 += lineno - 1
@@ -679,8 +679,8 @@ class RefactoringTool(object):
for line in block:
if line.startswith(prefix):
yield line[len(prefix):]
- elif line == prefix.rstrip() + u"\n":
- yield u"\n"
+ elif line == prefix.rstrip() + "\n":
+ yield "\n"
else:
raise AssertionError("line=%r, prefix=%r" % (line, prefix))
prefix = prefix2
@@ -713,7 +713,7 @@ class MultiprocessRefactoringTool(RefactoringTool):
self.queue = multiprocessing.JoinableQueue()
self.output_lock = multiprocessing.Lock()
processes = [multiprocessing.Process(target=self._child)
- for i in xrange(num_processes)]
+ for i in range(num_processes)]
try:
for p in processes:
p.start()
@@ -721,7 +721,7 @@ class MultiprocessRefactoringTool(RefactoringTool):
doctests_only)
finally:
self.queue.join()
- for i in xrange(num_processes):
+ for i in range(num_processes):
self.queue.put(None)
for p in processes:
if p.is_alive():
diff --git a/Lib/lib2to3/tests/pytree_idempotency.py b/Lib/lib2to3/tests/pytree_idempotency.py
index 243f7e8e282..a02bbfe2018 100755
--- a/Lib/lib2to3/tests/pytree_idempotency.py
+++ b/Lib/lib2to3/tests/pytree_idempotency.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# Copyright 2006 Google, Inc. All Rights Reserved.
# Licensed to PSF under a Contributor Agreement.
@@ -28,7 +28,7 @@ def main():
fn = "example.py"
tree = dr.parse_file(fn, debug=True)
if not diff(fn, tree):
- print "No diffs."
+ print("No diffs.")
if not sys.argv[1:]:
return # Pass a dummy argument to run the complete test suite below
@@ -44,7 +44,7 @@ def main():
fn = fn[:-1]
if not fn.endswith(".py"):
continue
- print >>sys.stderr, "Parsing", fn
+ print("Parsing", fn, file=sys.stderr)
tree = dr.parse_file(fn, debug=True)
if diff(fn, tree):
problems.append(fn)
@@ -55,27 +55,27 @@ def main():
names = os.listdir(dir)
except os.error:
continue
- print >>sys.stderr, "Scanning", dir, "..."
+ print("Scanning", dir, "...", file=sys.stderr)
for name in names:
if not name.endswith(".py"):
continue
- print >>sys.stderr, "Parsing", name
+ print("Parsing", name, file=sys.stderr)
fn = os.path.join(dir, name)
try:
tree = dr.parse_file(fn, debug=True)
- except pgen2.parse.ParseError, err:
- print "ParseError:", err
+ except pgen2.parse.ParseError as err:
+ print("ParseError:", err)
else:
if diff(fn, tree):
problems.append(fn)
# Show summary of problem files
if not problems:
- print "No problems. Congratulations!"
+ print("No problems. Congratulations!")
else:
- print "Problems in following files:"
+ print("Problems in following files:")
for fn in problems:
- print "***", fn
+ print("***", fn)
def diff(fn, tree):
f = open("@", "w")
diff --git a/Lib/lib2to3/tests/support.py b/Lib/lib2to3/tests/support.py
index 364693519bb..6f2d214bd43 100644
--- a/Lib/lib2to3/tests/support.py
+++ b/Lib/lib2to3/tests/support.py
@@ -28,7 +28,7 @@ def run_all_tests(test_mod=None, tests=None):
unittest.TextTestRunner(verbosity=2).run(tests)
def reformat(string):
- return dedent(string) + u"\n\n"
+ return dedent(string) + "\n\n"
def get_refactorer(fixer_pkg="lib2to3", fixers=None, options=None):
"""
diff --git a/Lib/lib2to3/tests/test_fixers.py b/Lib/lib2to3/tests/test_fixers.py
index 15482812201..914b3bf9287 100644
--- a/Lib/lib2to3/tests/test_fixers.py
+++ b/Lib/lib2to3/tests/test_fixers.py
@@ -20,7 +20,7 @@ class FixerTestCase(support.TestCase):
fix_list = [self.fixer]
self.refactor = support.get_refactorer(fixer_pkg, fix_list, options)
self.fixer_log = []
- self.filename = u"<string>"
+ self.filename = "<string>"
for fixer in chain(self.refactor.pre_order,
self.refactor.post_order):
@@ -30,7 +30,7 @@ class FixerTestCase(support.TestCase):
before = support.reformat(before)
after = support.reformat(after)
tree = self.refactor.refactor_string(before, self.filename)
- self.assertEqual(after, unicode(tree))
+ self.assertEqual(after, str(tree))
return tree
def check(self, before, after, ignore_warnings=False):
@@ -2744,7 +2744,7 @@ class Test_renames(FixerTestCase):
}
def test_import_from(self):
- for mod, (old, new) in self.modules.items():
+ for mod, (old, new) in list(self.modules.items()):
b = "from %s import %s" % (mod, old)
a = "from %s import %s" % (mod, new)
self.check(b, a)
@@ -2753,13 +2753,13 @@ class Test_renames(FixerTestCase):
self.unchanged(s)
def test_import_from_as(self):
- for mod, (old, new) in self.modules.items():
+ for mod, (old, new) in list(self.modules.items()):
b = "from %s import %s as foo_bar" % (mod, old)
a = "from %s import %s as foo_bar" % (mod, new)
self.check(b, a)
def test_import_module_usage(self):
- for mod, (old, new) in self.modules.items():
+ for mod, (old, new) in list(self.modules.items()):
b = """
import %s
foo(%s, %s.%s)
@@ -2772,7 +2772,7 @@ class Test_renames(FixerTestCase):
def XXX_test_from_import_usage(self):
# not implemented yet
- for mod, (old, new) in self.modules.items():
+ for mod, (old, new) in list(self.modules.items()):
b = """
from %s import %s
foo(%s, %s)
diff --git a/Lib/lib2to3/tests/test_main.py b/Lib/lib2to3/tests/test_main.py
index 7f8b25ca70e..a498c5a0d1d 100644
--- a/Lib/lib2to3/tests/test_main.py
+++ b/Lib/lib2to3/tests/test_main.py
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
-import sys
import codecs
+import io
import logging
import os
import re
import shutil
-import StringIO
import sys
import tempfile
import unittest
@@ -19,15 +18,6 @@ PY2_TEST_MODULE = os.path.join(TEST_DATA_DIR, "py2_test_grammar.py")
class TestMain(unittest.TestCase):
- if not hasattr(unittest.TestCase, 'assertNotRegex'):
- # This method was only introduced in 3.2.
- def assertNotRegex(self, text, regexp, msg=None):
- import re
- if not hasattr(regexp, 'search'):
- regexp = re.compile(regexp)
- if regexp.search(text):
- self.fail("regexp %s MATCHED text %r" % (regexp.pattern, text))
-
def setUp(self):
self.temp_dir = None # tearDown() will rmtree this directory if set.
@@ -52,13 +42,13 @@ class TestMain(unittest.TestCase):
sys.stderr = save_stderr
def test_unencodable_diff(self):
- input_stream = StringIO.StringIO(u"print 'nothing'\nprint u'über'\n")
- out = StringIO.StringIO()
+ input_stream = io.StringIO("print 'nothing'\nprint u'über'\n")
+ out = io.BytesIO()
out_enc = codecs.getwriter("ascii")(out)
- err = StringIO.StringIO()
+ err = io.StringIO()
ret = self.run_2to3_capture(["-"], input_stream, out_enc, err)
self.assertEqual(ret, 0)
- output = out.getvalue()
+ output = out.getvalue().decode("ascii")
self.assertTrue("-print 'nothing'" in output)
self.assertTrue("WARNING: couldn't encode <stdin>'s diff for "
"your terminal" in err.getvalue())
@@ -85,14 +75,14 @@ class TestMain(unittest.TestCase):
def test_filename_changing_on_output_single_dir(self):
"""2to3 a single directory with a new output dir and suffix."""
self.setup_test_source_trees()
- out = StringIO.StringIO()
- err = StringIO.StringIO()
+ out = io.StringIO()
+ err = io.StringIO()
suffix = "TEST"
ret = self.run_2to3_capture(
["-n", "--add-suffix", suffix, "--write-unchanged-files",
"--no-diffs", "--output-dir",
self.py3_dest_dir, self.py2_src_dir],
- StringIO.StringIO(""), out, err)
+ io.StringIO(""), out, err)
self.assertEqual(ret, 0)
stderr = err.getvalue()
self.assertIn(" implies -w.", stderr)
@@ -106,7 +96,7 @@ class TestMain(unittest.TestCase):
os.path.join(self.py2_src_dir, name),
os.path.join(self.py3_dest_dir, name+suffix)), stderr)
sep = re.escape(os.sep)
- self.assertRegexpMatches(
+ self.assertRegex(
stderr, r"No changes to .*/__init__\.py".replace("/", sep))
self.assertNotRegex(
stderr, r"No changes to .*/trivial\.py".replace("/", sep))
@@ -114,13 +104,13 @@ class TestMain(unittest.TestCase):
def test_filename_changing_on_output_two_files(self):
"""2to3 two files in one directory with a new output dir."""
self.setup_test_source_trees()
- err = StringIO.StringIO()
+ err = io.StringIO()
py2_files = [self.trivial_py2_file, self.init_py2_file]
expected_files = set(os.path.basename(name) for name in py2_files)
ret = self.run_2to3_capture(
["-n", "-w", "--write-unchanged-files",
"--no-diffs", "--output-dir", self.py3_dest_dir] + py2_files,
- StringIO.StringIO(""), StringIO.StringIO(), err)
+ io.StringIO(""), io.StringIO(), err)
self.assertEqual(ret, 0)
stderr = err.getvalue()
self.assertIn(
@@ -131,11 +121,11 @@ class TestMain(unittest.TestCase):
def test_filename_changing_on_output_single_file(self):
"""2to3 a single file with a new output dir."""
self.setup_test_source_trees()
- err = StringIO.StringIO()
+ err = io.StringIO()
ret = self.run_2to3_capture(
["-n", "-w", "--no-diffs", "--output-dir", self.py3_dest_dir,
self.trivial_py2_file],
- StringIO.StringIO(""), StringIO.StringIO(), err)
+ io.StringIO(""), io.StringIO(), err)
self.assertEqual(ret, 0)
stderr = err.getvalue()
self.assertIn(
diff --git a/Lib/lib2to3/tests/test_parser.py b/Lib/lib2to3/tests/test_parser.py
index 26023813516..3968e6a41a6 100644
--- a/Lib/lib2to3/tests/test_parser.py
+++ b/Lib/lib2to3/tests/test_parser.py
@@ -11,10 +11,14 @@ from __future__ import with_statement
# Testing imports
from . import support
from .support import driver, test_dir
+from test.support import verbose
# Python imports
import os
import sys
+import unittest
+import warnings
+import subprocess
# Local imports
from lib2to3.pgen2 import tokenize
@@ -158,21 +162,25 @@ class TestParserIdempotency(support.TestCase):
"""A cut-down version of pytree_idempotency.py."""
+ # Issue 13125
+ @unittest.expectedFailure
def test_all_project_files(self):
- if sys.platform.startswith("win"):
- # XXX something with newlines goes wrong on Windows.
- return
for filepath in support.all_project_files():
with open(filepath, "rb") as fp:
encoding = tokenize.detect_encoding(fp.readline)[0]
self.assertTrue(encoding is not None,
"can't detect encoding for %s" % filepath)
- with open(filepath, "r") as fp:
+ with open(filepath, "r", encoding=encoding) as fp:
source = fp.read()
- source = source.decode(encoding)
- tree = driver.parse_string(source)
- new = unicode(tree)
- if diff(filepath, new, encoding):
+ try:
+ tree = driver.parse_string(source)
+ except ParseError as err:
+ if verbose > 0:
+ warnings.warn('ParseError on file %s (%s)' % (filepath, err))
+ continue
+ new = str(tree)
+ x = diff(filepath, new)
+ if x:
self.fail("Idempotency failed: %s" % filepath)
def test_extended_unpacking(self):
@@ -181,6 +189,7 @@ class TestParserIdempotency(support.TestCase):
driver.parse_string("(z, *y, w) = m\n")
driver.parse_string("for *z, m in d: pass\n")
+
class TestLiterals(GrammarTest):
def validate(self, s):
@@ -214,14 +223,14 @@ class TestLiterals(GrammarTest):
self.validate(s)
-def diff(fn, result, encoding):
- f = open("@", "w")
- try:
- f.write(result.encode(encoding))
- finally:
- f.close()
+def diff(fn, result):
try:
+ with open('@', 'w') as f:
+ f.write(str(result))
fn = fn.replace('"', '\\"')
- return os.system('diff -u "%s" @' % fn)
+ return subprocess.call(['diff', '-u', fn, '@'], stdout=(subprocess.DEVNULL if verbose < 1 else None))
finally:
- os.remove("@")
+ try:
+ os.remove("@")
+ except OSError:
+ pass
diff --git a/Lib/lib2to3/tests/test_refactor.py b/Lib/lib2to3/tests/test_refactor.py
index 6020d1ff18b..8bdebc1f3da 100644
--- a/Lib/lib2to3/tests/test_refactor.py
+++ b/Lib/lib2to3/tests/test_refactor.py
@@ -8,7 +8,7 @@ import sys
import os
import codecs
import operator
-import StringIO
+import io
import tempfile
import shutil
import unittest
@@ -132,7 +132,7 @@ from __future__ import print_function"""
self.assertEqual(top_fixes, [with_head, no_head])
name_fixes = d.pop(token.NAME)
self.assertEqual(name_fixes, [simple, no_head])
- for fixes in d.itervalues():
+ for fixes in d.values():
self.assertEqual(fixes, [no_head])
def test_fixer_loading(self):
@@ -172,7 +172,7 @@ from __future__ import print_function"""
results = []
rt = MyRT(_DEFAULT_FIXERS)
save = sys.stdin
- sys.stdin = StringIO.StringIO("def parrot(): pass\n\n")
+ sys.stdin = io.StringIO("def parrot(): pass\n\n")
try:
rt.refactor_stdin()
finally:
@@ -230,7 +230,7 @@ from __future__ import print_function"""
os.sep, os.path.basename(test_file))
for message in debug_messages:
if "Not writing changes" in message:
- self.assertRegexpMatches(message, message_regex)
+ self.assertRegex(message, message_regex)
break
else:
self.fail("%r not matched in %r" % (message_regex, debug_messages))
diff --git a/Lib/lib2to3/tests/test_util.py b/Lib/lib2to3/tests/test_util.py
index 2fab8b9ad58..d2be82c4a26 100644
--- a/Lib/lib2to3/tests/test_util.py
+++ b/Lib/lib2to3/tests/test_util.py
@@ -581,14 +581,14 @@ class Test_find_indentation(support.TestCase):
def test_nothing(self):
fi = fixer_util.find_indentation
node = parse("node()")
- self.assertEqual(fi(node), u"")
+ self.assertEqual(fi(node), "")
node = parse("")
- self.assertEqual(fi(node), u"")
+ self.assertEqual(fi(node), "")
def test_simple(self):
fi = fixer_util.find_indentation
node = parse("def f():\n x()")
- self.assertEqual(fi(node), u"")
- self.assertEqual(fi(node.children[0].children[4].children[2]), u" ")
+ self.assertEqual(fi(node), "")
+ self.assertEqual(fi(node.children[0].children[4].children[2]), " ")
node = parse("def f():\n x()\n y()")
- self.assertEqual(fi(node.children[0].children[4].children[4]), u" ")
+ self.assertEqual(fi(node.children[0].children[4].children[4]), " ")
diff --git a/Lib/linecache.py b/Lib/linecache.py
index 811f27fe365..c3f2c3fdca4 100644
--- a/Lib/linecache.py
+++ b/Lib/linecache.py
@@ -7,6 +7,7 @@ that name.
import sys
import os
+import tokenize
__all__ = ["getline", "clearcache", "checkcache"]
@@ -45,7 +46,7 @@ def checkcache(filename=None):
(This is not checked upon each call!)"""
if filename is None:
- filenames = cache.keys()
+ filenames = list(cache.keys())
else:
if filename in cache:
filenames = [filename]
@@ -109,8 +110,6 @@ def updatecache(filename, module_globals=None):
return []
for dirname in sys.path:
- # When using imputil, sys.path may contain things other than
- # strings; ignore them when it happens.
try:
fullname = os.path.join(dirname, basename)
except (TypeError, AttributeError):
@@ -124,7 +123,7 @@ def updatecache(filename, module_globals=None):
else:
return []
try:
- with open(fullname, 'rU') as fp:
+ with tokenize.open(fullname) as fp:
lines = fp.readlines()
except IOError:
return []
diff --git a/Lib/locale.py b/Lib/locale.py
index 7ddfdb782c0..d2a885d519f 100644
--- a/Lib/locale.py
+++ b/Lib/locale.py
@@ -15,17 +15,10 @@ import sys
import encodings
import encodings.aliases
import re
-import operator
+import collections
+from builtins import str as _builtin_str
import functools
-try:
- _unicode = unicode
-except NameError:
- # If Python is built without Unicode support, the unicode type
- # will not exist. Fake one.
- class _unicode(object):
- pass
-
# Try importing the _locale module.
#
# If this fails, fall back on a basic 'C' locale emulation.
@@ -38,6 +31,18 @@ __all__ = ["getlocale", "getdefaultlocale", "getpreferredencoding", "Error",
"normalize", "LC_CTYPE", "LC_COLLATE", "LC_TIME", "LC_MONETARY",
"LC_NUMERIC", "LC_ALL", "CHAR_MAX"]
+def _strcoll(a,b):
+ """ strcoll(string,string) -> int.
+ Compares two strings according to the locale.
+ """
+ return (a > b) - (a < b)
+
+def _strxfrm(s):
+ """ strxfrm(string) -> string.
+ Returns a string that behaves for cmp locale-aware.
+ """
+ return s
+
try:
from _locale import *
@@ -85,20 +90,14 @@ except ImportError:
Activates/queries locale processing.
"""
if value not in (None, '', 'C'):
- raise Error, '_locale emulation only supports "C" locale'
+ raise Error('_locale emulation only supports "C" locale')
return 'C'
- def strcoll(a,b):
- """ strcoll(string,string) -> int.
- Compares two strings according to the locale.
- """
- return cmp(a,b)
-
- def strxfrm(s):
- """ strxfrm(string) -> string.
- Returns a string that behaves for cmp locale-aware.
- """
- return s
+# These may or may not exist in _locale, so be sure to set them.
+if 'strxfrm' not in globals():
+ strxfrm = _strxfrm
+if 'strcoll' not in globals():
+ strcoll = _strcoll
_localeconv = localeconv
@@ -226,7 +225,7 @@ def format_string(f, val, grouping=False):
percents = list(_percent_re.finditer(f))
new_f = _percent_re.sub('%s', f)
- if operator.isMappingType(val):
+ if isinstance(val, collections.Mapping):
new_val = []
for perc in percents:
if perc.group()[-1]=='%':
@@ -323,10 +322,10 @@ def _test():
setlocale(LC_ALL, "")
#do grouping
s1 = format("%d", 123456789,1)
- print s1, "is", atoi(s1)
+ print(s1, "is", atoi(s1))
#standard formatting
s1 = str(3.14)
- print s1, "is", atof(s1)
+ print(s1, "is", atof(s1))
### Locale name aliasing engine
@@ -337,13 +336,6 @@ def _test():
# overridden below)
_setlocale = setlocale
-# Avoid relying on the locale-dependent .lower() method
-# (see issue #1813).
-_ascii_lower_map = ''.join(
- chr(x + 32 if x >= ord('A') and x <= ord('Z') else x)
- for x in range(256)
-)
-
def normalize(localename):
""" Returns a normalized locale code for the given locale
@@ -361,9 +353,7 @@ def normalize(localename):
"""
# Normalize the locale name and extract the encoding
- if isinstance(localename, _unicode):
- localename = localename.encode('ascii')
- fullname = localename.translate(_ascii_lower_map)
+ fullname = localename.lower()
if ':' in fullname:
# ':' is sometimes used as encoding delimiter.
fullname = fullname.replace(':', '.')
@@ -440,7 +430,7 @@ def _parse_localename(localename):
return tuple(code.split('.')[:2])
elif code == 'C':
return None, None
- raise ValueError, 'unknown locale: %s' % localename
+ raise ValueError('unknown locale: %s' % localename)
def _build_localename(localetuple):
@@ -450,13 +440,17 @@ def _build_localename(localetuple):
No aliasing or normalizing takes place.
"""
- language, encoding = localetuple
- if language is None:
- language = 'C'
- if encoding is None:
- return language
- else:
- return language + '.' + encoding
+ try:
+ language, encoding = localetuple
+
+ if language is None:
+ language = 'C'
+ if encoding is None:
+ return language
+ else:
+ return language + '.' + encoding
+ except (TypeError, ValueError):
+ raise TypeError('Locale must be None, a string, or an iterable of two strings -- language code, encoding.')
def getdefaultlocale(envvars=('LC_ALL', 'LC_CTYPE', 'LANG', 'LANGUAGE')):
@@ -526,7 +520,7 @@ def getlocale(category=LC_CTYPE):
"""
localename = _setlocale(category)
if category == LC_ALL and ';' in localename:
- raise TypeError, 'category LC_ALL is not supported'
+ raise TypeError('category LC_ALL is not supported')
return _parse_localename(localename)
def setlocale(category, locale=None):
@@ -541,7 +535,7 @@ def setlocale(category, locale=None):
category may be given as one of the LC_* values.
"""
- if locale and type(locale) is not type(""):
+ if locale and not isinstance(locale, _builtin_str):
# convert to string
locale = normalize(_build_localename(locale))
return _setlocale(category, locale)
@@ -571,7 +565,11 @@ else:
def getpreferredencoding(do_setlocale = True):
"""Return the charset that the user is likely using,
by looking at environment variables."""
- return getdefaultlocale()[1]
+ res = getdefaultlocale()[1]
+ if res is None:
+ # LANG not set, default conservatively to ASCII
+ res = 'ascii'
+ return res
else:
def getpreferredencoding(do_setlocale = True):
"""Return the charset that the user is likely using,
@@ -583,10 +581,21 @@ else:
except Error:
pass
result = nl_langinfo(CODESET)
+ if not result and sys.platform == 'darwin':
+ # nl_langinfo can return an empty string
+ # when the setting has an invalid value.
+ # Default to UTF-8 in that case because
+ # UTF-8 is the default charset on OSX and
+ # returning nothing will crash the
+ # interpreter.
+ result = 'UTF-8'
setlocale(LC_CTYPE, oldloc)
- return result
else:
- return nl_langinfo(CODESET)
+ result = nl_langinfo(CODESET)
+ if not result and sys.platform == 'darwin':
+ # See above for explanation
+ result = 'UTF-8'
+ return result
### Database
@@ -1819,49 +1828,49 @@ def _print_locale():
_init_categories()
del categories['LC_ALL']
- print 'Locale defaults as determined by getdefaultlocale():'
- print '-'*72
+ print('Locale defaults as determined by getdefaultlocale():')
+ print('-'*72)
lang, enc = getdefaultlocale()
- print 'Language: ', lang or '(undefined)'
- print 'Encoding: ', enc or '(undefined)'
- print
+ print('Language: ', lang or '(undefined)')
+ print('Encoding: ', enc or '(undefined)')
+ print()
- print 'Locale settings on startup:'
- print '-'*72
+ print('Locale settings on startup:')
+ print('-'*72)
for name,category in categories.items():
- print name, '...'
+ print(name, '...')
lang, enc = getlocale(category)
- print ' Language: ', lang or '(undefined)'
- print ' Encoding: ', enc or '(undefined)'
- print
+ print(' Language: ', lang or '(undefined)')
+ print(' Encoding: ', enc or '(undefined)')
+ print()
- print
- print 'Locale settings after calling resetlocale():'
- print '-'*72
+ print()
+ print('Locale settings after calling resetlocale():')
+ print('-'*72)
resetlocale()
for name,category in categories.items():
- print name, '...'
+ print(name, '...')
lang, enc = getlocale(category)
- print ' Language: ', lang or '(undefined)'
- print ' Encoding: ', enc or '(undefined)'
- print
+ print(' Language: ', lang or '(undefined)')
+ print(' Encoding: ', enc or '(undefined)')
+ print()
try:
setlocale(LC_ALL, "")
except:
- print 'NOTE:'
- print 'setlocale(LC_ALL, "") does not support the default locale'
- print 'given in the OS environment variables.'
+ print('NOTE:')
+ print('setlocale(LC_ALL, "") does not support the default locale')
+ print('given in the OS environment variables.')
else:
- print
- print 'Locale settings after calling setlocale(LC_ALL, ""):'
- print '-'*72
+ print()
+ print('Locale settings after calling setlocale(LC_ALL, ""):')
+ print('-'*72)
for name,category in categories.items():
- print name, '...'
+ print(name, '...')
lang, enc = getlocale(category)
- print ' Language: ', lang or '(undefined)'
- print ' Encoding: ', enc or '(undefined)'
- print
+ print(' Language: ', lang or '(undefined)')
+ print(' Encoding: ', enc or '(undefined)')
+ print()
###
@@ -1873,10 +1882,10 @@ else:
__all__.append("LC_MESSAGES")
if __name__=='__main__':
- print 'Locale aliasing:'
- print
+ print('Locale aliasing:')
+ print()
_print_locale()
- print
- print 'Number formatting:'
- print
+ print()
+ print('Number formatting:')
+ print()
_test()
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index e53718d7457..4da07f1d8ba 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -23,7 +23,8 @@ Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
-import sys, os, time, cStringIO, traceback, warnings, weakref
+import sys, os, time, io, traceback, warnings, weakref
+from string import Template
__all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO',
@@ -31,7 +32,8 @@ __all__ = ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR',
'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig',
'captureWarnings', 'critical', 'debug', 'disable', 'error',
'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass',
- 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning']
+ 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'warn', 'warning',
+ 'getLogRecordFactory', 'setLogRecordFactory', 'lastResort']
try:
import codecs
@@ -39,7 +41,7 @@ except ImportError:
codecs = None
try:
- import thread
+ import _thread as thread
import threading
except ImportError:
thread = None
@@ -52,11 +54,6 @@ __date__ = "07 February 2010"
#---------------------------------------------------------------------------
# Miscellaneous module data
#---------------------------------------------------------------------------
-try:
- unicode
- _unicode = True
-except NameError:
- _unicode = False
#
# _srcfile is used when walking the stack to check when we've got the first
@@ -64,8 +61,6 @@ except NameError:
#
if hasattr(sys, 'frozen'): #support for py2exe
_srcfile = "logging%s__init__%s" % (os.sep, __file__[-4:])
-elif __file__[-4:].lower() in ['.pyc', '.pyo']:
- _srcfile = __file__[:-4] + '.py'
else:
_srcfile = __file__
_srcfile = os.path.normcase(_srcfile)
@@ -180,7 +175,7 @@ def addLevelName(level, levelName):
_releaseLock()
def _checkLevel(level):
- if isinstance(level, (int, long)):
+ if isinstance(level, int):
rv = level
elif str(level) == level:
if level not in _levelNames:
@@ -207,6 +202,7 @@ if thread:
else:
_lock = None
+
def _acquireLock():
"""
Acquire the module-level lock for serializing access to shared data.
@@ -240,7 +236,7 @@ class LogRecord(object):
information to be logged.
"""
def __init__(self, name, level, pathname, lineno,
- msg, args, exc_info, func=None):
+ msg, args, exc_info, func=None, sinfo=None, **kwargs):
"""
Initialize a logging record with interesting information.
"""
@@ -274,10 +270,11 @@ class LogRecord(object):
self.module = "Unknown module"
self.exc_info = exc_info
self.exc_text = None # used to cache the traceback text
+ self.stack_info = sinfo
self.lineno = lineno
self.funcName = func
self.created = ct
- self.msecs = (ct - long(ct)) * 1000
+ self.msecs = (ct - int(ct)) * 1000
self.relativeCreated = (self.created - _startTime) * 1000
if logThreads and thread:
self.thread = thread.get_ident()
@@ -297,7 +294,7 @@ class LogRecord(object):
# for an example
try:
self.processName = mp.current_process().name
- except StandardError:
+ except Exception:
pass
if logProcesses and hasattr(os, 'getpid'):
self.process = os.getpid()
@@ -315,19 +312,33 @@ class LogRecord(object):
Return the message for this LogRecord after merging any user-supplied
arguments with the message.
"""
- if not _unicode: #if no unicode support...
- msg = str(self.msg)
- else:
- msg = self.msg
- if not isinstance(msg, basestring):
- try:
- msg = str(self.msg)
- except UnicodeError:
- msg = self.msg #Defer encoding till later
+ msg = str(self.msg)
if self.args:
msg = msg % self.args
return msg
+#
+# Determine which class to use when instantiating log records.
+#
+_logRecordFactory = LogRecord
+
+def setLogRecordFactory(factory):
+ """
+ Set the factory to be used when instantiating a log record.
+
+ :param factory: A callable which will be called to instantiate
+ a log record.
+ """
+ global _logRecordFactory
+ _logRecordFactory = factory
+
+def getLogRecordFactory():
+ """
+ Return the factory to be used when instantiating a log record.
+ """
+
+ return _logRecordFactory
+
def makeLogRecord(dict):
"""
Make a LogRecord whose attributes are defined by the specified dictionary,
@@ -335,7 +346,7 @@ def makeLogRecord(dict):
a socket connection (which is sent as a dictionary) into a LogRecord
instance.
"""
- rv = LogRecord(None, None, "", 0, "", (), None, None)
+ rv = _logRecordFactory(None, None, "", 0, "", (), None, None)
rv.__dict__.update(dict)
return rv
@@ -343,6 +354,52 @@ def makeLogRecord(dict):
# Formatter classes and functions
#---------------------------------------------------------------------------
+class PercentStyle(object):
+
+ default_format = '%(message)s'
+ asctime_format = '%(asctime)s'
+ asctime_search = '%(asctime)'
+
+ def __init__(self, fmt):
+ self._fmt = fmt or self.default_format
+
+ def usesTime(self):
+ return self._fmt.find(self.asctime_search) >= 0
+
+ def format(self, record):
+ return self._fmt % record.__dict__
+
+class StrFormatStyle(PercentStyle):
+ default_format = '{message}'
+ asctime_format = '{asctime}'
+ asctime_search = '{asctime'
+
+ def format(self, record):
+ return self._fmt.format(**record.__dict__)
+
+
+class StringTemplateStyle(PercentStyle):
+ default_format = '${message}'
+ asctime_format = '${asctime}'
+ asctime_search = '${asctime}'
+
+ def __init__(self, fmt):
+ self._fmt = fmt or self.default_format
+ self._tpl = Template(self._fmt)
+
+ def usesTime(self):
+ fmt = self._fmt
+ return fmt.find('$asctime') >= 0 or fmt.find(self.asctime_format) >= 0
+
+ def format(self, record):
+ return self._tpl.substitute(**record.__dict__)
+
+_STYLES = {
+ '%': PercentStyle,
+ '{': StrFormatStyle,
+ '$': StringTemplateStyle
+}
+
class Formatter(object):
"""
Formatter instances are used to convert a LogRecord to text.
@@ -351,7 +408,7 @@ class Formatter(object):
responsible for converting a LogRecord to (usually) a string which can
be interpreted by either a human or an external system. The base Formatter
allows a formatting string to be specified. If none is supplied, the
- default value of "%s(message)\\n" is used.
+ default value of "%s(message)" is used.
The Formatter can be initialized with a format string which makes use of
knowledge of the LogRecord attributes - e.g. the default value mentioned
@@ -387,18 +444,26 @@ class Formatter(object):
converter = time.localtime
- def __init__(self, fmt=None, datefmt=None):
+ def __init__(self, fmt=None, datefmt=None, style='%'):
"""
Initialize the formatter with specified format strings.
Initialize the formatter either with the specified format string, or a
default as described above. Allow for specialized date formatting with
the optional datefmt argument (if omitted, you get the ISO8601 format).
+
+ Use a style parameter of '%', '{' or '$' to specify that you want to
+ use one of %-formatting, :meth:`str.format` (``{}``) formatting or
+ :class:`string.Template` formatting in your format string.
+
+ .. versionchanged: 3.2
+ Added the ``style`` parameter.
"""
- if fmt:
- self._fmt = fmt
- else:
- self._fmt = "%(message)s"
+ if style not in _STYLES:
+ raise ValueError('Style must be one of: %s' % ','.join(
+ _STYLES.keys()))
+ self._style = _STYLES[style](fmt)
+ self._fmt = self._style._fmt
self.datefmt = datefmt
def formatTime(self, record, datefmt=None):
@@ -424,7 +489,7 @@ class Formatter(object):
s = time.strftime(datefmt, ct)
else:
t = time.strftime("%Y-%m-%d %H:%M:%S", ct)
- s = "%s,%03d" % (t, record.msecs)
+ s = "%s,%03d" % (t, record.msecs) # the use of % here is internal
return s
def formatException(self, ei):
@@ -434,8 +499,12 @@ class Formatter(object):
This default implementation just uses
traceback.print_exception()
"""
- sio = cStringIO.StringIO()
- traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
+ sio = io.StringIO()
+ tb = ei[2]
+ # See issues #9427, #1553375. Commented out for now.
+ #if getattr(self, 'fullstack', False):
+ # traceback.print_stack(tb.tb_frame.f_back, file=sio)
+ traceback.print_exception(ei[0], ei[1], tb, None, sio)
s = sio.getvalue()
sio.close()
if s[-1:] == "\n":
@@ -446,7 +515,23 @@ class Formatter(object):
"""
Check if the format uses the creation time of the record.
"""
- return self._fmt.find("%(asctime)") >= 0
+ return self._style.usesTime()
+
+ def formatMessage(self, record):
+ return self._style.format(record)
+
+ def formatStack(self, stack_info):
+ """
+ This method is provided as an extension point for specialized
+ formatting of stack information.
+
+ The input data is a string as returned from a call to
+ :func:`traceback.print_stack`, but with the last trailing newline
+ removed.
+
+ The base implementation just returns the value passed in.
+ """
+ return stack_info
def format(self, record):
"""
@@ -464,7 +549,7 @@ class Formatter(object):
record.message = record.getMessage()
if self.usesTime():
record.asctime = self.formatTime(record, self.datefmt)
- s = self._fmt % record.__dict__
+ s = self.formatMessage(record)
if record.exc_info:
# Cache the traceback text to avoid converting it multiple times
# (it's constant anyway)
@@ -473,17 +558,11 @@ class Formatter(object):
if record.exc_text:
if s[-1:] != "\n":
s = s + "\n"
- try:
- s = s + record.exc_text
- except UnicodeError:
- # Sometimes filenames have non-ASCII chars, which can lead
- # to errors when s is Unicode and record.exc_text is str
- # See issue 8924.
- # We also use replace for when there are multiple
- # encodings, e.g. UTF-8 for the filesystem and latin-1
- # for a script. See issue 13232.
- s = s + record.exc_text.decode(sys.getfilesystemencoding(),
- 'replace')
+ s = s + record.exc_text
+ if record.stack_info:
+ if s[-1:] != "\n":
+ s = s + "\n"
+ s = s + self.formatStack(record.stack_info)
return s
#
@@ -602,10 +681,18 @@ class Filterer(object):
The default is to allow the record to be logged; any filter can veto
this and the record is then dropped. Returns a zero value if a record
is to be dropped, else non-zero.
+
+ .. versionchanged: 3.2
+
+ Allow filters to be just callables.
"""
rv = 1
for f in self.filters:
- if not f.filter(record):
+ if hasattr(f, 'filter'):
+ result = f.filter(record)
+ else:
+ result = f(record) # assume callable - will raise if not
+ if not result:
rv = 0
break
return rv
@@ -813,6 +900,8 @@ class StreamHandler(Handler):
sys.stdout or sys.stderr may be used.
"""
+ terminator = '\n'
+
def __init__(self, stream=None):
"""
Initialize the handler.
@@ -849,28 +938,8 @@ class StreamHandler(Handler):
try:
msg = self.format(record)
stream = self.stream
- fs = "%s\n"
- if not _unicode: #if no unicode support...
- stream.write(fs % msg)
- else:
- try:
- if (isinstance(msg, unicode) and
- getattr(stream, 'encoding', None)):
- ufs = fs.decode(stream.encoding)
- try:
- stream.write(ufs % msg)
- except UnicodeEncodeError:
- #Printing to terminals sometimes fails. For example,
- #with an encoding of 'cp1251', the above write will
- #work if written to a stream opened or wrapped by
- #the codecs module, but fail when writing to a
- #terminal even when the codepage is set to cp1251.
- #An extra encoding step seems to be needed.
- stream.write((ufs % msg).encode(stream.encoding))
- else:
- stream.write(fs % msg)
- except UnicodeError:
- stream.write(fs % msg.encode("UTF-8"))
+ stream.write(msg)
+ stream.write(self.terminator)
self.flush()
except (KeyboardInterrupt, SystemExit):
raise
@@ -937,6 +1006,26 @@ class FileHandler(StreamHandler):
self.stream = self._open()
StreamHandler.emit(self, record)
+class _StderrHandler(StreamHandler):
+ """
+ This class is like a StreamHandler using sys.stderr, but always uses
+ whatever sys.stderr is currently set to rather than the value of
+ sys.stderr at handler construction time.
+ """
+ def __init__(self, level=NOTSET):
+ """
+ Initialize the handler.
+ """
+ Handler.__init__(self, level)
+
+ @property
+ def stream(self):
+ return sys.stderr
+
+
+_defaultLastResort = _StderrHandler(WARNING)
+lastResort = _defaultLastResort
+
#---------------------------------------------------------------------------
# Manager classes and functions
#---------------------------------------------------------------------------
@@ -951,16 +1040,13 @@ class PlaceHolder(object):
"""
Initialize with the specified logger being a child of this placeholder.
"""
- #self.loggers = [alogger]
self.loggerMap = { alogger : None }
def append(self, alogger):
"""
Add the specified logger as a child of this placeholder.
"""
- #if alogger not in self.loggers:
if alogger not in self.loggerMap:
- #self.loggers.append(alogger)
self.loggerMap[alogger] = None
#
@@ -999,9 +1085,10 @@ class Manager(object):
"""
self.root = rootnode
self.disable = 0
- self.emittedNoHandlerWarning = 0
+ self.emittedNoHandlerWarning = False
self.loggerDict = {}
self.loggerClass = None
+ self.logRecordFactory = None
def getLogger(self, name):
"""
@@ -1015,10 +1102,8 @@ class Manager(object):
placeholder to now point to the logger.
"""
rv = None
- if not isinstance(name, basestring):
- raise TypeError('A logger name must be string or Unicode')
- if isinstance(name, unicode):
- name = name.encode('utf-8')
+ if not isinstance(name, str):
+ raise TypeError('A logger name must be a string')
_acquireLock()
try:
if name in self.loggerDict:
@@ -1049,6 +1134,13 @@ class Manager(object):
+ klass.__name__)
self.loggerClass = klass
+ def setLogRecordFactory(self, factory):
+ """
+ Set the factory to be used when instantiating a log record with this
+ Manager.
+ """
+ self.logRecordFactory = factory
+
def _fixupParents(self, alogger):
"""
Ensure that there are either loggers or placeholders all the way
@@ -1177,7 +1269,7 @@ class Logger(Filterer):
"""
Convenience method for logging an ERROR with exception information.
"""
- kwargs['exc_info'] = 1
+ kwargs['exc_info'] = True
self.error(msg, *args, **kwargs)
def critical(self, msg, *args, **kwargs):
@@ -1211,7 +1303,7 @@ class Logger(Filterer):
if self.isEnabledFor(level):
self._log(level, msg, args, **kwargs)
- def findCaller(self):
+ def findCaller(self, stack_info=False):
"""
Find the stack frame of the caller so that we can note the source
file name, line number and function name.
@@ -1221,23 +1313,34 @@ class Logger(Filterer):
#IronPython isn't run with -X:Frames.
if f is not None:
f = f.f_back
- rv = "(unknown file)", 0, "(unknown function)"
+ rv = "(unknown file)", 0, "(unknown function)", None
while hasattr(f, "f_code"):
co = f.f_code
filename = os.path.normcase(co.co_filename)
if filename == _srcfile:
f = f.f_back
continue
- rv = (co.co_filename, f.f_lineno, co.co_name)
+ sinfo = None
+ if stack_info:
+ sio = io.StringIO()
+ sio.write('Stack (most recent call last):\n')
+ traceback.print_stack(f, file=sio)
+ sinfo = sio.getvalue()
+ if sinfo[-1] == '\n':
+ sinfo = sinfo[:-1]
+ sio.close()
+ rv = (co.co_filename, f.f_lineno, co.co_name, sinfo)
break
return rv
- def makeRecord(self, name, level, fn, lno, msg, args, exc_info, func=None, extra=None):
+ def makeRecord(self, name, level, fn, lno, msg, args, exc_info,
+ func=None, extra=None, sinfo=None):
"""
A factory method which can be overridden in subclasses to create
specialized LogRecords.
"""
- rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
+ rv = _logRecordFactory(name, level, fn, lno, msg, args, exc_info, func,
+ sinfo)
if extra is not None:
for key in extra:
if (key in ["message", "asctime"]) or (key in rv.__dict__):
@@ -1245,17 +1348,18 @@ class Logger(Filterer):
rv.__dict__[key] = extra[key]
return rv
- def _log(self, level, msg, args, exc_info=None, extra=None):
+ def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False):
"""
Low-level logging routine which creates a LogRecord and then calls
all the handlers of this logger to handle the record.
"""
+ sinfo = None
if _srcfile:
#IronPython doesn't track Python frames, so findCaller raises an
#exception on some versions of IronPython. We trap it here so that
#IronPython can use logging.
try:
- fn, lno, func = self.findCaller()
+ fn, lno, func, sinfo = self.findCaller(stack_info)
except ValueError:
fn, lno, func = "(unknown file)", 0, "(unknown function)"
else:
@@ -1263,7 +1367,8 @@ class Logger(Filterer):
if exc_info:
if not isinstance(exc_info, tuple):
exc_info = sys.exc_info()
- record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
+ record = self.makeRecord(self.name, level, fn, lno, msg, args,
+ exc_info, func, extra, sinfo)
self.handle(record)
def handle(self, record):
@@ -1298,6 +1403,28 @@ class Logger(Filterer):
finally:
_releaseLock()
+ def hasHandlers(self):
+ """
+ See if this logger has any handlers configured.
+
+ Loop through all handlers for this logger and its parents in the
+ logger hierarchy. Return True if a handler was found, else False.
+ Stop searching up the hierarchy whenever a logger with the "propagate"
+ attribute set to zero is found - that will be the last logger which
+ is checked for the existence of handlers.
+ """
+ c = self
+ rv = False
+ while c:
+ if c.handlers:
+ rv = True
+ break
+ if not c.propagate:
+ break
+ else:
+ c = c.parent
+ return rv
+
def callHandlers(self, record):
"""
Pass a record to all relevant handlers.
@@ -1319,10 +1446,14 @@ class Logger(Filterer):
c = None #break out
else:
c = c.parent
- if (found == 0) and raiseExceptions and not self.manager.emittedNoHandlerWarning:
- sys.stderr.write("No handlers could be found for logger"
- " \"%s\"\n" % self.name)
- self.manager.emittedNoHandlerWarning = 1
+ if (found == 0):
+ if lastResort:
+ if record.levelno >= lastResort.level:
+ lastResort.handle(record)
+ elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
+ sys.stderr.write("No handlers could be found for logger"
+ " \"%s\"\n" % self.name)
+ self.manager.emittedNoHandlerWarning = True
def getEffectiveLevel(self):
"""
@@ -1412,68 +1543,82 @@ class LoggerAdapter(object):
kwargs["extra"] = self.extra
return msg, kwargs
+ #
+ # Boilerplate convenience methods
+ #
def debug(self, msg, *args, **kwargs):
"""
- Delegate a debug call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a debug call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.debug(msg, *args, **kwargs)
+ self.log(DEBUG, msg, *args, **kwargs)
def info(self, msg, *args, **kwargs):
"""
- Delegate an info call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an info call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.info(msg, *args, **kwargs)
+ self.log(INFO, msg, *args, **kwargs)
def warning(self, msg, *args, **kwargs):
"""
- Delegate a warning call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a warning call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.warning(msg, *args, **kwargs)
+ self.log(WARNING, msg, *args, **kwargs)
+
+ warn = warning
def error(self, msg, *args, **kwargs):
"""
- Delegate an error call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an error call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.error(msg, *args, **kwargs)
+ self.log(ERROR, msg, *args, **kwargs)
def exception(self, msg, *args, **kwargs):
"""
- Delegate an exception call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate an exception call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
kwargs["exc_info"] = 1
- self.logger.error(msg, *args, **kwargs)
+ self.log(ERROR, msg, *args, **kwargs)
def critical(self, msg, *args, **kwargs):
"""
- Delegate a critical call to the underlying logger, after adding
- contextual information from this adapter instance.
+ Delegate a critical call to the underlying logger.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.critical(msg, *args, **kwargs)
+ self.log(CRITICAL, msg, *args, **kwargs)
def log(self, level, msg, *args, **kwargs):
"""
Delegate a log call to the underlying logger, after adding
contextual information from this adapter instance.
"""
- msg, kwargs = self.process(msg, kwargs)
- self.logger.log(level, msg, *args, **kwargs)
+ if self.isEnabledFor(level):
+ msg, kwargs = self.process(msg, kwargs)
+ self.logger._log(level, msg, args, **kwargs)
def isEnabledFor(self, level):
"""
- See if the underlying logger is enabled for the specified level.
+ Is this logger enabled for level 'level'?
"""
- return self.logger.isEnabledFor(level)
+ if self.logger.manager.disable >= level:
+ return False
+ return level >= self.getEffectiveLevel()
+
+ def setLevel(self, level):
+ """
+ Set the specified level on the underlying logger.
+ """
+ self.logger.setLevel(level)
+
+ def getEffectiveLevel(self):
+ """
+ Get the effective level for the underlying logger.
+ """
+ return self.logger.getEffectiveLevel()
+
+ def hasHandlers(self):
+ """
+ See if the underlying logger has any handlers.
+ """
+ return self.logger.hasHandlers()
root = RootLogger(WARNING)
Logger.root = root
@@ -1506,6 +1651,10 @@ def basicConfig(**kwargs):
(if filemode is unspecified, it defaults to 'a').
format Use the specified format string for the handler.
datefmt Use the specified date/time format.
+ style If a format string is specified, use this to specify the
+ type of format string (possible values '%', '{', '$', for
+ %-formatting, :meth:`str.format` and :class:`string.Template`
+ - defaults to '%').
level Set the root logger level to the specified level.
stream Use the specified stream to initialize the StreamHandler. Note
that this argument is incompatible with 'filename' - if both
@@ -1516,27 +1665,34 @@ def basicConfig(**kwargs):
remembered that StreamHandler does not close its stream (since it may be
using sys.stdout or sys.stderr), whereas FileHandler closes its stream
when the handler is closed.
+
+ .. versionchanged: 3.2
+ Added the ``style`` parameter.
"""
# Add thread safety in case someone mistakenly calls
# basicConfig() from multiple threads
_acquireLock()
try:
if len(root.handlers) == 0:
- filename = kwargs.get("filename")
+ filename = kwargs.pop("filename", None)
if filename:
- mode = kwargs.get("filemode", 'a')
+ mode = kwargs.pop("filemode", 'a')
hdlr = FileHandler(filename, mode)
else:
- stream = kwargs.get("stream")
+ stream = kwargs.pop("stream", None)
hdlr = StreamHandler(stream)
- fs = kwargs.get("format", BASIC_FORMAT)
- dfs = kwargs.get("datefmt", None)
- fmt = Formatter(fs, dfs)
+ fs = kwargs.pop("format", BASIC_FORMAT)
+ dfs = kwargs.pop("datefmt", None)
+ style = kwargs.pop("style", '%')
+ fmt = Formatter(fs, dfs, style)
hdlr.setFormatter(fmt)
root.addHandler(hdlr)
- level = kwargs.get("level")
+ level = kwargs.pop("level", None)
if level is not None:
root.setLevel(level)
+ if kwargs:
+ s = ', '.join(kwargs.keys())
+ raise ValueError('Unexpected in keyword arguments: %s' % s)
finally:
_releaseLock()
@@ -1556,18 +1712,11 @@ def getLogger(name=None):
else:
return root
-#def getRootLogger():
-# """
-# Return the root logger.
-#
-# Note that getLogger('') now does the same thing, so this function is
-# deprecated and may disappear in the future.
-# """
-# return root
-
def critical(msg, *args, **kwargs):
"""
- Log a message with severity 'CRITICAL' on the root logger.
+ Log a message with severity 'CRITICAL' on the root logger. If the logger
+ has no handlers, call basicConfig() to add a console handler with a
+ pre-defined format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1577,7 +1726,9 @@ fatal = critical
def error(msg, *args, **kwargs):
"""
- Log a message with severity 'ERROR' on the root logger.
+ Log a message with severity 'ERROR' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1585,15 +1736,18 @@ def error(msg, *args, **kwargs):
def exception(msg, *args, **kwargs):
"""
- Log a message with severity 'ERROR' on the root logger,
- with exception information.
+ Log a message with severity 'ERROR' on the root logger, with exception
+ information. If the logger has no handlers, basicConfig() is called to add
+ a console handler with a pre-defined format.
"""
- kwargs['exc_info'] = 1
+ kwargs['exc_info'] = True
error(msg, *args, **kwargs)
def warning(msg, *args, **kwargs):
"""
- Log a message with severity 'WARNING' on the root logger.
+ Log a message with severity 'WARNING' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1603,7 +1757,9 @@ warn = warning
def info(msg, *args, **kwargs):
"""
- Log a message with severity 'INFO' on the root logger.
+ Log a message with severity 'INFO' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1611,7 +1767,9 @@ def info(msg, *args, **kwargs):
def debug(msg, *args, **kwargs):
"""
- Log a message with severity 'DEBUG' on the root logger.
+ Log a message with severity 'DEBUG' on the root logger. If the logger has
+ no handlers, call basicConfig() to add a console handler with a pre-defined
+ format.
"""
if len(root.handlers) == 0:
basicConfig()
@@ -1619,7 +1777,9 @@ def debug(msg, *args, **kwargs):
def log(level, msg, *args, **kwargs):
"""
- Log 'msg % args' with the integer severity 'level' on the root logger.
+ Log 'msg % args' with the integer severity 'level' on the root logger. If
+ the logger has no handlers, call basicConfig() to add a console handler
+ with a pre-defined format.
"""
if len(root.handlers) == 0:
basicConfig()
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index 8e01a564028..373da2b0764 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -25,15 +25,15 @@ To use, simply 'import logging' and log away!
"""
import sys, logging, logging.handlers, socket, struct, os, traceback, re
-import types, cStringIO
+import types, io
try:
- import thread
+ import _thread as thread
import threading
except ImportError:
thread = None
-from SocketServer import ThreadingTCPServer, StreamRequestHandler
+from socketserver import ThreadingTCPServer, StreamRequestHandler
DEFAULT_LOGGING_CONFIG_PORT = 9030
@@ -59,11 +59,11 @@ def fileConfig(fname, defaults=None, disable_existing_loggers=True):
developer provides a mechanism to present the choices and load the chosen
configuration).
"""
- import ConfigParser
+ import configparser
- cp = ConfigParser.ConfigParser(defaults)
+ cp = configparser.ConfigParser(defaults)
if hasattr(fname, 'readline'):
- cp.readfp(fname)
+ cp.read_file(fname)
else:
cp.read(fname)
@@ -103,7 +103,7 @@ def _encoded(s):
def _create_formatters(cp):
"""Create and return formatters"""
- flist = cp.get("formatters", "keys")
+ flist = cp["formatters"]["keys"]
if not len(flist):
return {}
flist = flist.split(",")
@@ -111,20 +111,12 @@ def _create_formatters(cp):
formatters = {}
for form in flist:
sectname = "formatter_%s" % form
- opts = cp.options(sectname)
- if "format" in opts:
- fs = cp.get(sectname, "format", 1)
- else:
- fs = None
- if "datefmt" in opts:
- dfs = cp.get(sectname, "datefmt", 1)
- else:
- dfs = None
+ fs = cp.get(sectname, "format", raw=True, fallback=None)
+ dfs = cp.get(sectname, "datefmt", raw=True, fallback=None)
c = logging.Formatter
- if "class" in opts:
- class_name = cp.get(sectname, "class")
- if class_name:
- c = _resolve(class_name)
+ class_name = cp[sectname].get("class")
+ if class_name:
+ c = _resolve(class_name)
f = c(fs, dfs)
formatters[form] = f
return formatters
@@ -132,7 +124,7 @@ def _create_formatters(cp):
def _install_handlers(cp, formatters):
"""Install and return handlers"""
- hlist = cp.get("handlers", "keys")
+ hlist = cp["handlers"]["keys"]
if not len(hlist):
return {}
hlist = hlist.split(",")
@@ -140,30 +132,23 @@ def _install_handlers(cp, formatters):
handlers = {}
fixups = [] #for inter-handler references
for hand in hlist:
- sectname = "handler_%s" % hand
- klass = cp.get(sectname, "class")
- opts = cp.options(sectname)
- if "formatter" in opts:
- fmt = cp.get(sectname, "formatter")
- else:
- fmt = ""
+ section = cp["handler_%s" % hand]
+ klass = section["class"]
+ fmt = section.get("formatter", "")
try:
klass = eval(klass, vars(logging))
except (AttributeError, NameError):
klass = _resolve(klass)
- args = cp.get(sectname, "args")
+ args = section["args"]
args = eval(args, vars(logging))
h = klass(*args)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
h.setLevel(logging._levelNames[level])
if len(fmt):
h.setFormatter(formatters[fmt])
if issubclass(klass, logging.handlers.MemoryHandler):
- if "target" in opts:
- target = cp.get(sectname,"target")
- else:
- target = ""
+ target = section.get("target", "")
if len(target): #the target handler may not be loaded yet, so keep for later...
fixups.append((h, target))
handlers[hand] = h
@@ -172,25 +157,44 @@ def _install_handlers(cp, formatters):
h.setTarget(handlers[t])
return handlers
+def _handle_existing_loggers(existing, child_loggers, disable_existing):
+ """
+ When (re)configuring logging, handle loggers which were in the previous
+ configuration but are not in the new configuration. There's no point
+ deleting them as other threads may continue to hold references to them;
+ and by disabling them, you stop them doing any logging.
+
+ However, don't disable children of named loggers, as that's probably not
+ what was intended by the user. Also, allow existing loggers to NOT be
+ disabled if disable_existing is false.
+ """
+ root = logging.root
+ for log in existing:
+ logger = root.manager.loggerDict[log]
+ if log in child_loggers:
+ logger.level = logging.NOTSET
+ logger.handlers = []
+ logger.propagate = True
+ elif disable_existing:
+ logger.disabled = True
-def _install_loggers(cp, handlers, disable_existing_loggers):
+def _install_loggers(cp, handlers, disable_existing):
"""Create and install loggers"""
# configure the root first
- llist = cp.get("loggers", "keys")
+ llist = cp["loggers"]["keys"]
llist = llist.split(",")
llist = list(map(lambda x: x.strip(), llist))
llist.remove("root")
- sectname = "logger_root"
+ section = cp["logger_root"]
root = logging.root
log = root
- opts = cp.options(sectname)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
log.setLevel(logging._levelNames[level])
for h in root.handlers[:]:
root.removeHandler(h)
- hlist = cp.get(sectname, "handlers")
+ hlist = section["handlers"]
if len(hlist):
hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
@@ -211,19 +215,15 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
#avoid disabling child loggers of explicitly
#named loggers. With a sorted list it is easier
#to find the child loggers.
- existing.sort()
+ existing.sort(key=_encoded)
#We'll keep the list of existing loggers
#which are children of named loggers here...
child_loggers = []
#now set up the new ones...
for log in llist:
- sectname = "logger_%s" % log
- qn = cp.get(sectname, "qualname")
- opts = cp.options(sectname)
- if "propagate" in opts:
- propagate = cp.getint(sectname, "propagate")
- else:
- propagate = 1
+ section = cp["logger_%s" % log]
+ qn = section["qualname"]
+ propagate = section.getint("propagate", fallback=1)
logger = logging.getLogger(qn)
if qn in existing:
i = existing.index(qn) + 1 # start with the entry after qn
@@ -235,14 +235,14 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
child_loggers.append(existing[i])
i += 1
existing.remove(qn)
- if "level" in opts:
- level = cp.get(sectname, "level")
+ if "level" in section:
+ level = section["level"]
logger.setLevel(logging._levelNames[level])
for h in logger.handlers[:]:
logger.removeHandler(h)
logger.propagate = propagate
logger.disabled = 0
- hlist = cp.get(sectname, "handlers")
+ hlist = section["handlers"]
if len(hlist):
hlist = hlist.split(",")
hlist = _strip_spaces(hlist)
@@ -254,16 +254,15 @@ def _install_loggers(cp, handlers, disable_existing_loggers):
#and by disabling them, you stop them doing any logging.
#However, don't disable children of named loggers, as that's
#probably not what was intended by the user.
- for log in existing:
- logger = root.manager.loggerDict[log]
- if log in child_loggers:
- logger.level = logging.NOTSET
- logger.handlers = []
- logger.propagate = 1
- elif disable_existing_loggers:
- logger.disabled = 1
-
-
+ #for log in existing:
+ # logger = root.manager.loggerDict[log]
+ # if log in child_loggers:
+ # logger.level = logging.NOTSET
+ # logger.handlers = []
+ # logger.propagate = 1
+ # elif disable_existing_loggers:
+ # logger.disabled = 1
+ _handle_existing_loggers(existing, child_loggers, disable_existing)
IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I)
@@ -374,7 +373,7 @@ class BaseConfigurator(object):
}
# We might want to use a different one, e.g. importlib
- importer = __import__
+ importer = staticmethod(__import__)
def __init__(self, config):
self.config = ConvertingDict(config)
@@ -457,7 +456,7 @@ class BaseConfigurator(object):
isinstance(value, tuple):
value = ConvertingTuple(value)
value.configurator = self
- elif isinstance(value, basestring): # str for py3k
+ elif isinstance(value, str): # str for py3k
m = self.CONVERT_PATTERN.match(value)
if m:
d = m.groupdict()
@@ -472,7 +471,7 @@ class BaseConfigurator(object):
def configure_custom(self, config):
"""Configure an object with a user-supplied factory."""
c = config.pop('()')
- if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
+ if not callable(c):
c = self.resolve(c)
props = config.pop('.', None)
# Check for valid identifiers
@@ -520,21 +519,21 @@ class DictConfigurator(BaseConfigurator):
level = handler_config.get('level', None)
if level:
handler.setLevel(logging._checkLevel(level))
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure handler '
'%r: %s' % (name, e))
loggers = config.get('loggers', EMPTY_DICT)
for name in loggers:
try:
self.configure_logger(name, loggers[name], True)
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure logger '
'%r: %s' % (name, e))
root = config.get('root', None)
if root:
try:
self.configure_root(root, True)
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure root '
'logger: %s' % e)
else:
@@ -549,7 +548,7 @@ class DictConfigurator(BaseConfigurator):
try:
formatters[name] = self.configure_formatter(
formatters[name])
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure '
'formatter %r: %s' % (name, e))
# Next, do filters - they don't refer to anything else, either
@@ -557,7 +556,7 @@ class DictConfigurator(BaseConfigurator):
for name in filters:
try:
filters[name] = self.configure_filter(filters[name])
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure '
'filter %r: %s' % (name, e))
@@ -570,7 +569,7 @@ class DictConfigurator(BaseConfigurator):
handler = self.configure_handler(handlers[name])
handler.name = name
handlers[name] = handler
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure handler '
'%r: %s' % (name, e))
# Next, do loggers - they refer to handlers and filters
@@ -584,33 +583,31 @@ class DictConfigurator(BaseConfigurator):
#which were in the previous configuration but
#which are not in the new configuration.
root = logging.root
- existing = root.manager.loggerDict.keys()
+ existing = list(root.manager.loggerDict.keys())
#The list needs to be sorted so that we can
#avoid disabling child loggers of explicitly
#named loggers. With a sorted list it is easier
#to find the child loggers.
- existing.sort()
+ existing.sort(key=_encoded)
#We'll keep the list of existing loggers
#which are children of named loggers here...
child_loggers = []
#now set up the new ones...
loggers = config.get('loggers', EMPTY_DICT)
for name in loggers:
- name = _encoded(name)
if name in existing:
- i = existing.index(name)
+ i = existing.index(name) + 1 # look after name
prefixed = name + "."
pflen = len(prefixed)
num_existing = len(existing)
- i = i + 1 # look at the entry after name
- while (i < num_existing) and\
- (existing[i][:pflen] == prefixed):
- child_loggers.append(existing[i])
- i = i + 1
+ while i < num_existing:
+ if existing[i][:pflen] == prefixed:
+ child_loggers.append(existing[i])
+ i += 1
existing.remove(name)
try:
self.configure_logger(name, loggers[name])
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure logger '
'%r: %s' % (name, e))
@@ -619,21 +616,23 @@ class DictConfigurator(BaseConfigurator):
#and by disabling them, you stop them doing any logging.
#However, don't disable children of named loggers, as that's
#probably not what was intended by the user.
- for log in existing:
- logger = root.manager.loggerDict[log]
- if log in child_loggers:
- logger.level = logging.NOTSET
- logger.handlers = []
- logger.propagate = True
- elif disable_existing:
- logger.disabled = True
+ #for log in existing:
+ # logger = root.manager.loggerDict[log]
+ # if log in child_loggers:
+ # logger.level = logging.NOTSET
+ # logger.handlers = []
+ # logger.propagate = True
+ # elif disable_existing:
+ # logger.disabled = True
+ _handle_existing_loggers(existing, child_loggers,
+ disable_existing)
# And finally, do the root logger
root = config.get('root', None)
if root:
try:
self.configure_root(root)
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to configure root '
'logger: %s' % e)
finally:
@@ -645,7 +644,7 @@ class DictConfigurator(BaseConfigurator):
factory = config['()'] # for use in exception handler
try:
result = self.configure_custom(config)
- except TypeError, te:
+ except TypeError as te:
if "'format'" not in str(te):
raise
#Name of parameter changed from fmt to format.
@@ -675,7 +674,7 @@ class DictConfigurator(BaseConfigurator):
for f in filters:
try:
filterer.addFilter(self.config['filters'][f])
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to add filter %r: %s' % (f, e))
def configure_handler(self, config):
@@ -684,14 +683,14 @@ class DictConfigurator(BaseConfigurator):
if formatter:
try:
formatter = self.config['formatters'][formatter]
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to set formatter '
'%r: %s' % (formatter, e))
level = config.pop('level', None)
filters = config.pop('filters', None)
if '()' in config:
c = config.pop('()')
- if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
+ if not callable(c):
c = self.resolve(c)
factory = c
else:
@@ -701,7 +700,7 @@ class DictConfigurator(BaseConfigurator):
'target' in config:
try:
config['target'] = self.config['handlers'][config['target']]
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to set target handler '
'%r: %s' % (config['target'], e))
elif issubclass(klass, logging.handlers.SMTPHandler) and\
@@ -714,7 +713,7 @@ class DictConfigurator(BaseConfigurator):
kwargs = dict([(k, config[k]) for k in config if valid_ident(k)])
try:
result = factory(**kwargs)
- except TypeError, te:
+ except TypeError as te:
if "'stream'" not in str(te):
raise
#The argument name changed from strm to stream
@@ -736,7 +735,7 @@ class DictConfigurator(BaseConfigurator):
for h in handlers:
try:
logger.addHandler(self.config['handlers'][h])
- except StandardError, e:
+ except Exception as e:
raise ValueError('Unable to add handler %r: %s' % (h, e))
def common_logger_config(self, logger, config, incremental=False):
@@ -814,6 +813,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
chunk = self.connection.recv(slen)
while len(chunk) < slen:
chunk = chunk + conn.recv(slen - len(chunk))
+ chunk = chunk.decode("utf-8")
try:
import json
d =json.loads(chunk)
@@ -822,7 +822,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
except:
#Apply new configuration.
- file = cStringIO.StringIO(chunk)
+ file = io.StringIO(chunk)
try:
fileConfig(file)
except (KeyboardInterrupt, SystemExit):
@@ -831,7 +831,7 @@ def listen(port=DEFAULT_LOGGING_CONFIG_PORT):
traceback.print_exc()
if self.server.ready:
self.server.ready.set()
- except socket.error, e:
+ except socket.error as e:
if not isinstance(e.args, tuple):
raise
else:
diff --git a/Lib/logging/handlers.py b/Lib/logging/handlers.py
index 26dfe4a1d18..8349d3a7fb9 100644
--- a/Lib/logging/handlers.py
+++ b/Lib/logging/handlers.py
@@ -23,18 +23,18 @@ Copyright (C) 2001-2012 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging.handlers' and log away!
"""
-import errno, logging, socket, os, cPickle, struct, time, re
+import errno, logging, socket, os, pickle, struct, time, re
from stat import ST_DEV, ST_INO, ST_MTIME
+import queue
+try:
+ import threading
+except ImportError:
+ threading = None
try:
import codecs
except ImportError:
codecs = None
-try:
- unicode
- _unicode = True
-except NameError:
- _unicode = False
#
# Some constants...
@@ -130,7 +130,6 @@ class RotatingFileHandler(BaseRotatingHandler):
sfn = "%s.%d" % (self.baseFilename, i)
dfn = "%s.%d" % (self.baseFilename, i + 1)
if os.path.exists(sfn):
- #print "%s -> %s" % (sfn, dfn)
if os.path.exists(dfn):
os.remove(dfn)
os.rename(sfn, dfn)
@@ -138,7 +137,6 @@ class RotatingFileHandler(BaseRotatingHandler):
if os.path.exists(dfn):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
- #print "%s -> %s" % (self.baseFilename, dfn)
self.stream = self._open()
def shouldRollover(self, record):
@@ -210,7 +208,7 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
else:
raise ValueError("Invalid rollover interval specified: %s" % self.when)
- self.extMatch = re.compile(self.extMatch)
+ self.extMatch = re.compile(self.extMatch, re.ASCII)
self.interval = self.interval * interval # multiply by units requested
if os.path.exists(filename):
t = os.stat(filename)[ST_MTIME]
@@ -288,7 +286,6 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
t = int(time.time())
if t >= self.rolloverAt:
return 1
- #print "No need to rollover: %d, %d" % (t, self.rolloverAt)
return 0
def getFilesToDelete(self):
@@ -345,14 +342,8 @@ class TimedRotatingFileHandler(BaseRotatingHandler):
os.remove(dfn)
os.rename(self.baseFilename, dfn)
if self.backupCount > 0:
- # find the oldest log file and delete it
- #s = glob.glob(self.baseFilename + ".20*")
- #if len(s) > self.backupCount:
- # s.sort()
- # os.remove(s[0])
for s in self.getFilesToDelete():
os.remove(s)
- #print "%s -> %s" % (self.baseFilename, dfn)
self.stream = self._open()
newRolloverAt = self.computeRollover(currentTime)
while newRolloverAt <= currentTime:
@@ -429,6 +420,7 @@ class WatchedFileHandler(logging.FileHandler):
self._statstream()
logging.FileHandler.emit(self, record)
+
class SocketHandler(logging.Handler):
"""
A handler class which writes logging records, in pickle format, to
@@ -538,16 +530,14 @@ class SocketHandler(logging.Handler):
if ei:
# just to get traceback text into record.exc_text ...
dummy = self.format(record)
- record.exc_info = None # to avoid Unpickleable error
# See issue #14436: If msg or args are objects, they may not be
# available on the receiving end. So we convert the msg % args
# to a string, save it as msg and zap the args.
d = dict(record.__dict__)
d['msg'] = record.getMessage()
d['args'] = None
- s = cPickle.dumps(d, 1)
- if ei:
- record.exc_info = ei # for next handler
+ d['exc_info'] = None
+ s = pickle.dumps(d, 1)
slen = struct.pack(">L", len(s))
return slen + s
@@ -591,9 +581,9 @@ class SocketHandler(logging.Handler):
if self.sock:
self.sock.close()
self.sock = None
+ logging.Handler.close(self)
finally:
self.release()
- logging.Handler.close(self)
class DatagramHandler(SocketHandler):
"""
@@ -751,7 +741,7 @@ class SysLogHandler(logging.Handler):
self.facility = facility
self.socktype = socktype
- if isinstance(address, basestring):
+ if isinstance(address, str):
self.unixsocket = 1
self._connect_unixsocket(address)
else:
@@ -769,12 +759,6 @@ class SysLogHandler(logging.Handler):
self.socket.close()
raise
- # curious: when talking to the unix-domain '/dev/log' socket, a
- # zero-terminator seems to be required. this string is placed
- # into a class variable so that it can be overridden if
- # necessary.
- log_format_string = '<%d>%s\000'
-
def encodePriority(self, facility, priority):
"""
Encode the facility and priority. You can pass in strings or
@@ -782,9 +766,9 @@ class SysLogHandler(logging.Handler):
priority_names mapping dictionaries are used to convert them to
integers.
"""
- if isinstance(facility, basestring):
+ if isinstance(facility, str):
facility = self.facility_names[facility]
- if isinstance(priority, basestring):
+ if isinstance(priority, str):
priority = self.priority_names[priority]
return (facility << 3) | priority
@@ -796,9 +780,9 @@ class SysLogHandler(logging.Handler):
try:
if self.unixsocket:
self.socket.close()
+ logging.Handler.close(self)
finally:
self.release()
- logging.Handler.close(self)
def mapPriority(self, levelName):
"""
@@ -810,6 +794,8 @@ class SysLogHandler(logging.Handler):
"""
return self.priority_map.get(levelName, "warning")
+ append_nul = True # some old syslog daemons expect a NUL terminator
+
def emit(self, record):
"""
Emit a record.
@@ -817,16 +803,18 @@ class SysLogHandler(logging.Handler):
The record is formatted, and then sent to the syslog server. If
exception information is present, it is NOT sent to the server.
"""
- msg = self.format(record) + '\000'
+ msg = self.format(record)
+ if self.append_nul:
+ msg += '\000'
"""
We need to convert record level to lowercase, maybe this will
change in the future.
"""
prio = '<%d>' % self.encodePriority(self.facility,
self.mapPriority(record.levelname))
+ prio = prio.encode('utf-8')
# Message is a string. Convert to bytes as required by RFC 5424
- if type(msg) is unicode:
- msg = msg.encode('utf-8')
+ msg = msg.encode('utf-8')
msg = prio + msg
try:
if self.unixsocket:
@@ -874,7 +862,7 @@ class SMTPHandler(logging.Handler):
else:
self.username = None
self.fromaddr = fromaddr
- if isinstance(toaddrs, basestring):
+ if isinstance(toaddrs, str):
toaddrs = [toaddrs]
self.toaddrs = toaddrs
self.subject = subject
@@ -1027,7 +1015,7 @@ class HTTPHandler(logging.Handler):
A class which sends records to a Web server, using either GET or
POST semantics.
"""
- def __init__(self, host, url, method="GET"):
+ def __init__(self, host, url, method="GET", secure=False, credentials=None):
"""
Initialize the instance with the host, the request URL, and the method
("GET" or "POST")
@@ -1039,12 +1027,14 @@ class HTTPHandler(logging.Handler):
self.host = host
self.url = url
self.method = method
+ self.secure = secure
+ self.credentials = credentials
def mapLogRecord(self, record):
"""
Default implementation of mapping the log record into a dict
that is sent as the CGI data. Overwrite in your class.
- Contributed by Franz Glasner.
+ Contributed by Franz Glasner.
"""
return record.__dict__
@@ -1055,11 +1045,14 @@ class HTTPHandler(logging.Handler):
Send the record to the Web server as a percent-encoded dictionary
"""
try:
- import httplib, urllib
+ import http.client, urllib.parse
host = self.host
- h = httplib.HTTP(host)
+ if self.secure:
+ h = http.client.HTTPSConnection(host)
+ else:
+ h = http.client.HTTPConnection(host)
url = self.url
- data = urllib.urlencode(self.mapLogRecord(record))
+ data = urllib.parse.urlencode(self.mapLogRecord(record))
if self.method == "GET":
if (url.find('?') >= 0):
sep = '&'
@@ -1077,8 +1070,13 @@ class HTTPHandler(logging.Handler):
h.putheader("Content-type",
"application/x-www-form-urlencoded")
h.putheader("Content-length", str(len(data)))
+ if self.credentials:
+ import base64
+ s = ('u%s:%s' % self.credentials).encode('utf-8')
+ s = 'Basic ' + base64.b64encode(s).strip()
+ h.putheader('Authorization', s)
h.endheaders(data if self.method == "POST" else None)
- h.getreply() #can't do anything with the result
+ h.getresponse() #can't do anything with the result
except (KeyboardInterrupt, SystemExit):
raise
except:
@@ -1175,6 +1173,8 @@ class MemoryHandler(BufferingHandler):
For a MemoryHandler, flushing means just sending the buffered
records to the target, if there is one. Override if you want
different behaviour.
+
+ The record buffer is also cleared by this operation.
"""
self.acquire()
try:
@@ -1196,3 +1196,175 @@ class MemoryHandler(BufferingHandler):
BufferingHandler.close(self)
finally:
self.release()
+
+
+class QueueHandler(logging.Handler):
+ """
+ This handler sends events to a queue. Typically, it would be used together
+ with a multiprocessing Queue to centralise logging to file in one process
+ (in a multi-process application), so as to avoid file write contention
+ between processes.
+
+ This code is new in Python 3.2, but this class can be copy pasted into
+ user code for use with earlier Python versions.
+ """
+
+ def __init__(self, queue):
+ """
+ Initialise an instance, using the passed queue.
+ """
+ logging.Handler.__init__(self)
+ self.queue = queue
+
+ def enqueue(self, record):
+ """
+ Enqueue a record.
+
+ The base implementation uses put_nowait. You may want to override
+ this method if you want to use blocking, timeouts or custom queue
+ implementations.
+ """
+ self.queue.put_nowait(record)
+
+ def prepare(self, record):
+ """
+ Prepares a record for queuing. The object returned by this method is
+ enqueued.
+
+ The base implementation formats the record to merge the message
+ and arguments, and removes unpickleable items from the record
+ in-place.
+
+ You might want to override this method if you want to convert
+ the record to a dict or JSON string, or send a modified copy
+ of the record while leaving the original intact.
+ """
+ # The format operation gets traceback text into record.exc_text
+ # (if there's exception data), and also puts the message into
+ # record.message. We can then use this to replace the original
+ # msg + args, as these might be unpickleable. We also zap the
+ # exc_info attribute, as it's no longer needed and, if not None,
+ # will typically not be pickleable.
+ self.format(record)
+ record.msg = record.message
+ record.args = None
+ record.exc_info = None
+ return record
+
+ def emit(self, record):
+ """
+ Emit a record.
+
+ Writes the LogRecord to the queue, preparing it for pickling first.
+ """
+ try:
+ self.enqueue(self.prepare(record))
+ except (KeyboardInterrupt, SystemExit):
+ raise
+ except:
+ self.handleError(record)
+
+if threading:
+ class QueueListener(object):
+ """
+ This class implements an internal threaded listener which watches for
+ LogRecords being added to a queue, removes them and passes them to a
+ list of handlers for processing.
+ """
+ _sentinel = None
+
+ def __init__(self, queue, *handlers):
+ """
+ Initialise an instance with the specified queue and
+ handlers.
+ """
+ self.queue = queue
+ self.handlers = handlers
+ self._stop = threading.Event()
+ self._thread = None
+
+ def dequeue(self, block):
+ """
+ Dequeue a record and return it, optionally blocking.
+
+ The base implementation uses get. You may want to override this method
+ if you want to use timeouts or work with custom queue implementations.
+ """
+ return self.queue.get(block)
+
+ def start(self):
+ """
+ Start the listener.
+
+ This starts up a background thread to monitor the queue for
+ LogRecords to process.
+ """
+ self._thread = t = threading.Thread(target=self._monitor)
+ t.setDaemon(True)
+ t.start()
+
+ def prepare(self , record):
+ """
+ Prepare a record for handling.
+
+ This method just returns the passed-in record. You may want to
+ override this method if you need to do any custom marshalling or
+ manipulation of the record before passing it to the handlers.
+ """
+ return record
+
+ def handle(self, record):
+ """
+ Handle a record.
+
+ This just loops through the handlers offering them the record
+ to handle.
+ """
+ record = self.prepare(record)
+ for handler in self.handlers:
+ handler.handle(record)
+
+ def _monitor(self):
+ """
+ Monitor the queue for records, and ask the handler
+ to deal with them.
+
+ This method runs on a separate, internal thread.
+ The thread will terminate if it sees a sentinel object in the queue.
+ """
+ q = self.queue
+ has_task_done = hasattr(q, 'task_done')
+ while not self._stop.isSet():
+ try:
+ record = self.dequeue(True)
+ if record is self._sentinel:
+ break
+ self.handle(record)
+ if has_task_done:
+ q.task_done()
+ except queue.Empty:
+ pass
+ # There might still be records in the queue.
+ while True:
+ try:
+ record = self.dequeue(False)
+ if record is self._sentinel:
+ break
+ self.handle(record)
+ if has_task_done:
+ q.task_done()
+ except queue.Empty:
+ break
+
+ def stop(self):
+ """
+ Stop the listener.
+
+ This asks the thread to terminate, and then waits for it to do so.
+ Note that if you don't call this before your application exits, there
+ may be some records still left on the queue, which won't be processed.
+ """
+ self._stop.set()
+ self.queue.put_nowait(self._sentinel)
+ self._thread.join()
+ self._thread = None
diff --git a/Lib/macpath.py b/Lib/macpath.py
index cd4cb8581af..1615d9122a1 100644
--- a/Lib/macpath.py
+++ b/Lib/macpath.py
@@ -1,7 +1,6 @@
"""Pathname and path-related operations for the Macintosh."""
import os
-import warnings
from stat import *
import genericpath
from genericpath import *
@@ -9,11 +8,12 @@ from genericpath import *
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
- "walk","expanduser","expandvars","normpath","abspath",
+ "expanduser","expandvars","normpath","abspath",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"devnull","realpath","supports_unicode_filenames"]
# strings representing various path-related bits and pieces
+# These are primarily for export; internally, they are hardcoded.
curdir = ':'
pardir = '::'
extsep = '.'
@@ -23,9 +23,18 @@ defpath = ':'
altsep = None
devnull = 'Dev:Null'
+def _get_colon(path):
+ if isinstance(path, bytes):
+ return b':'
+ else:
+ return ':'
+
# Normalize the case of a pathname. Dummy in Posix, but <s>.lower() here.
def normcase(path):
+ if not isinstance(path, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(path.__class__.__name__))
return path.lower()
@@ -36,21 +45,23 @@ def isabs(s):
Anything else is absolute (the string up to the first colon is the
volume name)."""
- return ':' in s and s[0] != ':'
+ colon = _get_colon(s)
+ return colon in s and s[:1] != colon
def join(s, *p):
+ colon = _get_colon(s)
path = s
for t in p:
if (not s) or isabs(t):
path = t
continue
- if t[:1] == ':':
+ if t[:1] == colon:
t = t[1:]
- if ':' not in path:
- path = ':' + path
- if path[-1:] != ':':
- path = path + ':'
+ if colon not in path:
+ path = colon + path
+ if path[-1:] != colon:
+ path = path + colon
path = path + t
return path
@@ -60,18 +71,22 @@ def split(s):
bit, and the basename (the filename, without colons, in that directory).
The result (s, t) is such that join(s, t) yields the original argument."""
- if ':' not in s: return '', s
- colon = 0
+ colon = _get_colon(s)
+ if colon not in s: return s[:0], s
+ col = 0
for i in range(len(s)):
- if s[i] == ':': colon = i + 1
- path, file = s[:colon-1], s[colon:]
- if path and not ':' in path:
- path = path + ':'
+ if s[i:i+1] == colon: col = i + 1
+ path, file = s[:col-1], s[col:]
+ if path and not colon in path:
+ path = path + colon
return path, file
def splitext(p):
- return genericpath._splitext(p, sep, altsep, extsep)
+ if isinstance(p, bytes):
+ return genericpath._splitext(p, b':', altsep, b'.')
+ else:
+ return genericpath._splitext(p, sep, altsep, extsep)
splitext.__doc__ = genericpath._splitext.__doc__
def splitdrive(p):
@@ -81,7 +96,7 @@ def splitdrive(p):
syntactic and semantic oddities as DOS drive letters, such as there
being a separate current directory per drive)."""
- return '', p
+ return p[:0], p
# Short interfaces to split()
@@ -93,7 +108,7 @@ def ismount(s):
if not isabs(s):
return False
components = split(s)
- return len(components) == 2 and components[1] == ''
+ return len(components) == 2 and not components[1]
def islink(s):
"""Return true if the pathname refers to a symbolic link."""
@@ -132,62 +147,36 @@ def normpath(s):
"""Normalize a pathname. Will return the same result for
equivalent paths."""
- if ":" not in s:
- return ":"+s
+ colon = _get_colon(s)
+
+ if colon not in s:
+ return colon + s
- comps = s.split(":")
+ comps = s.split(colon)
i = 1
while i < len(comps)-1:
- if comps[i] == "" and comps[i-1] != "":
+ if not comps[i] and comps[i-1]:
if i > 1:
del comps[i-1:i+1]
i = i - 1
else:
# best way to handle this is to raise an exception
- raise norm_error, 'Cannot use :: immediately after volume name'
+ raise norm_error('Cannot use :: immediately after volume name')
else:
i = i + 1
- s = ":".join(comps)
+ s = colon.join(comps)
# remove trailing ":" except for ":" and "Volume:"
- if s[-1] == ":" and len(comps) > 2 and s != ":"*len(s):
+ if s[-1:] == colon and len(comps) > 2 and s != colon*len(s):
s = s[:-1]
return s
-
-def walk(top, func, arg):
- """Directory tree walk with callback function.
-
- For each directory in the directory tree rooted at top (including top
- itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
- dirname is the name of the directory, and fnames a list of the names of
- the files and subdirectories in dirname (excluding '.' and '..'). func
- may modify the fnames list in-place (e.g. via del or slice assignment),
- and walk will only recurse into the subdirectories whose names remain in
- fnames; this can be used to implement a filter, or to impose a specific
- order of visiting. No semantics are defined for, or required of, arg,
- beyond that arg is always passed to func. It can be used, e.g., to pass
- a filename pattern, or a mutable object designed to accumulate
- statistics. Passing None for arg is common."""
- warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
- stacklevel=2)
- try:
- names = os.listdir(top)
- except os.error:
- return
- func(arg, top, names)
- for name in names:
- name = join(top, name)
- if isdir(name) and not islink(name):
- walk(name, func, arg)
-
-
def abspath(path):
"""Return an absolute path."""
if not isabs(path):
- if isinstance(path, unicode):
- cwd = os.getcwdu()
+ if isinstance(path, bytes):
+ cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
@@ -202,8 +191,9 @@ def realpath(path):
return path
if not path:
return path
- components = path.split(':')
- path = components[0] + ':'
+ colon = _get_colon(path)
+ components = path.split(colon)
+ path = components[0] + colon
for c in components[1:]:
path = join(path, c)
try:
diff --git a/Lib/macurl2path.py b/Lib/macurl2path.py
index 4c5ae64572e..f22fb207b84 100644
--- a/Lib/macurl2path.py
+++ b/Lib/macurl2path.py
@@ -2,7 +2,7 @@
Do not import directly; use urllib instead."""
-import urllib
+import urllib.parse
import os
__all__ = ["url2pathname","pathname2url"]
@@ -13,14 +13,14 @@ def url2pathname(pathname):
#
# XXXX The .. handling should be fixed...
#
- tp = urllib.splittype(pathname)[0]
+ tp = urllib.parse.splittype(pathname)[0]
if tp and tp != 'file':
- raise RuntimeError, 'Cannot convert non-local URL to pathname'
+ raise RuntimeError('Cannot convert non-local URL to pathname')
# Turn starting /// into /, an empty hostname means current host
if pathname[:3] == '///':
pathname = pathname[2:]
elif pathname[:2] == '//':
- raise RuntimeError, 'Cannot convert non-local URL to pathname'
+ raise RuntimeError('Cannot convert non-local URL to pathname')
components = pathname.split('/')
# Remove . and embedded ..
i = 0
@@ -47,13 +47,13 @@ def url2pathname(pathname):
i = i + 1
rv = ':' + ':'.join(components)
# and finally unquote slashes and other funny characters
- return urllib.unquote(rv)
+ return urllib.parse.unquote(rv)
def pathname2url(pathname):
"""OS-specific conversion from a file system path to a relative URL
of the 'file' scheme; not recommended for general use."""
if '/' in pathname:
- raise RuntimeError, "Cannot convert pathname containing slashes"
+ raise RuntimeError("Cannot convert pathname containing slashes")
components = pathname.split(':')
# Remove empty first and/or last component
if components[0] == '':
@@ -73,8 +73,8 @@ def pathname2url(pathname):
return '/'.join(components)
def _pncomp2url(component):
- component = urllib.quote(component[:31], safe='') # We want to quote slashes
- return component
+ # We want to quote slashes
+ return urllib.parse.quote(component[:31], safe='')
def test():
for url in ["index.html",
@@ -82,7 +82,7 @@ def test():
"/foo/bar/index.html",
"/foo/bar/",
"/"]:
- print '%r -> %r' % (url, url2pathname(url))
+ print('%r -> %r' % (url, url2pathname(url)))
for path in ["drive:",
"drive:dir:",
"drive:dir:file",
@@ -91,7 +91,7 @@ def test():
":file",
":dir:",
":dir:file"]:
- print '%r -> %r' % (path, pathname2url(path))
+ print('%r -> %r' % (path, pathname2url(path)))
if __name__ == '__main__':
test()
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index 530d3c5a66e..c73fb95fe21 100644
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Read/write support for Maildir, mbox, MH, Babyl, and MMDF mailboxes."""
@@ -15,10 +15,12 @@ import calendar
import socket
import errno
import copy
+import warnings
import email
import email.message
import email.generator
-import StringIO
+import io
+import contextlib
try:
if sys.platform == 'os2emx':
# OS/2 EMX fcntl() not adequate
@@ -27,17 +29,11 @@ try:
except ImportError:
fcntl = None
-import warnings
-with warnings.catch_warnings():
- if sys.py3kwarning:
- warnings.filterwarnings("ignore", ".*rfc822 has been removed",
- DeprecationWarning)
- import rfc822
-
__all__ = [ 'Mailbox', 'Maildir', 'mbox', 'MH', 'Babyl', 'MMDF',
'Message', 'MaildirMessage', 'mboxMessage', 'MHMessage',
- 'BabylMessage', 'MMDFMessage', 'UnixMailbox',
- 'PortableUnixMailbox', 'MmdfMailbox', 'MHMailbox', 'BabylMailbox' ]
+ 'BabylMessage', 'MMDFMessage']
+
+linesep = os.linesep.encode('ascii')
class Mailbox:
"""A group of messages in a particular place."""
@@ -81,14 +77,22 @@ class Mailbox:
if not self._factory:
return self.get_message(key)
else:
- return self._factory(self.get_file(key))
+ with contextlib.closing(self.get_file(key)) as file:
+ return self._factory(file)
def get_message(self, key):
"""Return a Message representation or raise a KeyError."""
raise NotImplementedError('Method must be implemented by subclass')
def get_string(self, key):
- """Return a string representation or raise a KeyError."""
+ """Return a string representation or raise a KeyError.
+
+ Uses email.message.Message to create a 7bit clean string
+ representation of the message."""
+ return email.message_from_bytes(self.get_bytes(key)).as_string()
+
+ def get_bytes(self, key):
+ """Return a byte string representation or raise a KeyError."""
raise NotImplementedError('Method must be implemented by subclass')
def get_file(self, key):
@@ -105,7 +109,7 @@ class Mailbox:
def itervalues(self):
"""Return an iterator over all messages."""
- for key in self.iterkeys():
+ for key in self.keys():
try:
value = self[key]
except KeyError:
@@ -121,7 +125,7 @@ class Mailbox:
def iteritems(self):
"""Return an iterator over (key, message) tuples."""
- for key in self.iterkeys():
+ for key in self.keys():
try:
value = self[key]
except KeyError:
@@ -132,20 +136,17 @@ class Mailbox:
"""Return a list of (key, message) tuples. Memory intensive."""
return list(self.iteritems())
- def has_key(self, key):
+ def __contains__(self, key):
"""Return True if the keyed message exists, False otherwise."""
raise NotImplementedError('Method must be implemented by subclass')
- def __contains__(self, key):
- return self.has_key(key)
-
def __len__(self):
"""Return a count of messages in the mailbox."""
raise NotImplementedError('Method must be implemented by subclass')
def clear(self):
"""Delete all messages."""
- for key in self.iterkeys():
+ for key in self.keys():
self.discard(key)
def pop(self, key, default=None):
@@ -159,7 +160,7 @@ class Mailbox:
def popitem(self):
"""Delete an arbitrary (key, message) pair and return it."""
- for key in self.iterkeys():
+ for key in self.keys():
return (key, self.pop(key)) # This is only run once.
else:
raise KeyError('No messages in mailbox')
@@ -167,7 +168,7 @@ class Mailbox:
def update(self, arg=None):
"""Change the messages that correspond to certain keys."""
if hasattr(arg, 'iteritems'):
- source = arg.iteritems()
+ source = arg.items()
elif hasattr(arg, 'items'):
source = arg.items()
else:
@@ -197,46 +198,70 @@ class Mailbox:
"""Flush and close the mailbox."""
raise NotImplementedError('Method must be implemented by subclass')
+ def _string_to_bytes(self, message):
+ # If a message is not 7bit clean, we refuse to handle it since it
+ # likely came from reading invalid messages in text mode, and that way
+ # lies mojibake.
+ try:
+ return message.encode('ascii')
+ except UnicodeError:
+ raise ValueError("String input must be ASCII-only; "
+ "use bytes or a Message instead")
+
# Whether each message must end in a newline
_append_newline = False
def _dump_message(self, message, target, mangle_from_=False):
- # Most files are opened in binary mode to allow predictable seeking.
- # To get native line endings on disk, the user-friendly \n line endings
- # used in strings and by email.Message are translated here.
+ # This assumes the target file is open in binary mode.
"""Dump message contents to target file."""
if isinstance(message, email.message.Message):
- buffer = StringIO.StringIO()
- gen = email.generator.Generator(buffer, mangle_from_, 0)
+ buffer = io.BytesIO()
+ gen = email.generator.BytesGenerator(buffer, mangle_from_, 0)
gen.flatten(message)
buffer.seek(0)
- data = buffer.read().replace('\n', os.linesep)
+ data = buffer.read()
+ data = data.replace(b'\n', linesep)
target.write(data)
- if self._append_newline and not data.endswith(os.linesep):
+ if self._append_newline and not data.endswith(linesep):
# Make sure the message ends with a newline
- target.write(os.linesep)
- elif isinstance(message, str):
+ target.write(linesep)
+ 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()
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
if mangle_from_:
- message = message.replace('\nFrom ', '\n>From ')
- message = message.replace('\n', os.linesep)
+ message = message.replace(b'\nFrom ', b'\n>From ')
+ message = message.replace(b'\n', linesep)
target.write(message)
- if self._append_newline and not message.endswith(os.linesep):
+ if self._append_newline and not message.endswith(linesep):
# Make sure the message ends with a newline
- target.write(os.linesep)
+ target.write(linesep)
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
lastline = None
while True:
line = message.readline()
- if line == '':
+ # Universal newline support.
+ if line.endswith(b'\r\n'):
+ line = line[:-2] + b'\n'
+ elif line.endswith(b'\r'):
+ line = line[:-1] + b'\n'
+ if not line:
break
- if mangle_from_ and line.startswith('From '):
- line = '>From ' + line[5:]
- line = line.replace('\n', os.linesep)
+ if mangle_from_ and line.startswith(b'From '):
+ line = b'>From ' + line[5:]
+ line = line.replace(b'\n', linesep)
target.write(line)
lastline = line
- if self._append_newline and lastline and not lastline.endswith(os.linesep):
+ if self._append_newline and lastline and not lastline.endswith(linesep):
# Make sure the message ends with a newline
- target.write(os.linesep)
+ target.write(linesep)
else:
raise TypeError('Invalid message type: %s' % type(message))
@@ -246,7 +271,7 @@ class Maildir(Mailbox):
colon = ':'
- def __init__(self, dirname, factory=rfc822.Message, create=True):
+ def __init__(self, dirname, factory=None, create=True):
"""Initialize a Maildir instance."""
Mailbox.__init__(self, dirname, factory, create)
self._paths = {
@@ -256,7 +281,7 @@ class Maildir(Mailbox):
}
if not os.path.exists(self._path):
if create:
- os.mkdir(self._path, 0700)
+ os.mkdir(self._path, 0o700)
for path in self._paths.values():
os.mkdir(path, 0o700)
else:
@@ -292,7 +317,7 @@ class Maildir(Mailbox):
os.remove(tmp_file.name)
else:
os.rename(tmp_file.name, dest)
- except OSError, e:
+ except OSError as e:
os.remove(tmp_file.name)
if e.errno == errno.EEXIST:
raise ExternalClashError('Name clash with existing message: %s'
@@ -314,7 +339,7 @@ class Maildir(Mailbox):
self.remove(key)
except KeyError:
pass
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT:
raise
@@ -344,7 +369,7 @@ class Maildir(Mailbox):
def get_message(self, key):
"""Return a Message representation or raise a KeyError."""
subpath = self._lookup(key)
- f = open(os.path.join(self._path, subpath), 'r')
+ f = open(os.path.join(self._path, subpath), 'rb')
try:
if self._factory:
msg = self._factory(f)
@@ -359,11 +384,11 @@ class Maildir(Mailbox):
msg.set_date(os.path.getmtime(os.path.join(self._path, subpath)))
return msg
- def get_string(self, key):
- """Return a string representation or raise a KeyError."""
- f = open(os.path.join(self._path, self._lookup(key)), 'r')
+ def get_bytes(self, key):
+ """Return a bytes representation or raise a KeyError."""
+ f = open(os.path.join(self._path, self._lookup(key)), 'rb')
try:
- return f.read()
+ return f.read().replace(linesep, b'\n')
finally:
f.close()
@@ -382,7 +407,7 @@ class Maildir(Mailbox):
continue
yield key
- def has_key(self, key):
+ def __contains__(self, key):
"""Return True if the keyed message exists, False otherwise."""
self._refresh()
return key in self._toc
@@ -432,7 +457,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,
- 0666))
+ 0o666))
return result
def remove_folder(self, folder):
@@ -477,12 +502,12 @@ class Maildir(Mailbox):
path = os.path.join(self._path, 'tmp', uniq)
try:
os.stat(path)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.ENOENT:
Maildir._count += 1
try:
return _create_carefully(path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST:
raise
else:
@@ -545,10 +570,10 @@ class Maildir(Mailbox):
def next(self):
"""Return the next message in a one-time iteration."""
if not hasattr(self, '_onetime_keys'):
- self._onetime_keys = self.iterkeys()
+ self._onetime_keys = iter(self.keys())
while True:
try:
- return self[self._onetime_keys.next()]
+ return self[next(self._onetime_keys)]
except StopIteration:
return None
except KeyError:
@@ -563,7 +588,7 @@ class _singlefileMailbox(Mailbox):
Mailbox.__init__(self, path, factory, create)
try:
f = open(self._path, 'rb+')
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ENOENT:
if create:
f = open(self._path, 'wb+')
@@ -609,7 +634,7 @@ class _singlefileMailbox(Mailbox):
for key in self._toc.keys():
yield key
- def has_key(self, key):
+ def __contains__(self, key):
"""Return True if the keyed message exists, False otherwise."""
self._lookup()
return key in self._toc
@@ -667,7 +692,7 @@ class _singlefileMailbox(Mailbox):
while True:
buffer = self._file.read(min(4096,
stop - self._file.tell()))
- if buffer == '':
+ if not buffer:
break
new_file.write(buffer)
new_toc[key] = (new_start, new_file.tell())
@@ -685,7 +710,7 @@ class _singlefileMailbox(Mailbox):
os.chmod(new_file.name, mode)
try:
os.rename(new_file.name, self._path)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.EEXIST or \
(os.name == 'os2' and e.errno == errno.EACCES):
os.remove(self._path)
@@ -760,20 +785,25 @@ class _mboxMMDF(_singlefileMailbox):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- from_line = self._file.readline().replace(os.linesep, '')
+ from_line = self._file.readline().replace(linesep, b'')
string = self._file.read(stop - self._file.tell())
- msg = self._message_factory(string.replace(os.linesep, '\n'))
- msg.set_from(from_line[5:])
+ msg = self._message_factory(string.replace(linesep, b'\n'))
+ msg.set_from(from_line[5:].decode('ascii'))
return msg
def get_string(self, key, from_=False):
"""Return a string representation or raise a KeyError."""
+ return email.message_from_bytes(
+ self.get_bytes(key)).as_string(unixfrom=from_)
+
+ def get_bytes(self, key, from_=False):
+ """Return a string representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
if not from_:
self._file.readline()
string = self._file.read(stop - self._file.tell())
- return string.replace(os.linesep, '\n')
+ return string.replace(linesep, b'\n')
def get_file(self, key, from_=False):
"""Return a file-like representation or raise a KeyError."""
@@ -786,22 +816,27 @@ class _mboxMMDF(_singlefileMailbox):
def _install_message(self, message):
"""Format a message and blindly write to self._file."""
from_line = None
- if isinstance(message, str) and message.startswith('From '):
- newline = message.find('\n')
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
+ if isinstance(message, bytes) and message.startswith(b'From '):
+ newline = message.find(b'\n')
if newline != -1:
from_line = message[:newline]
message = message[newline + 1:]
else:
from_line = message
- message = ''
+ message = b''
elif isinstance(message, _mboxMMDFMessage):
- from_line = 'From ' + message.get_from()
+ author = message.get_from().encode('ascii')
+ from_line = b'From ' + author
elif isinstance(message, email.message.Message):
from_line = message.get_unixfrom() # May be None.
+ if from_line is not None:
+ from_line = from_line.encode('ascii')
if from_line is None:
- from_line = 'From MAILER-DAEMON %s' % time.asctime(time.gmtime())
+ from_line = b'From MAILER-DAEMON ' + time.asctime(time.gmtime()).encode()
start = self._file.tell()
- self._file.write(from_line + os.linesep)
+ self._file.write(from_line + linesep)
self._dump_message(message, self._file, self._mangle_from_)
stop = self._file.tell()
return (start, stop)
@@ -823,7 +858,7 @@ class mbox(_mboxMMDF):
def _post_message_hook(self, f):
"""Called after writing each message to file f."""
- f.write(os.linesep)
+ f.write(linesep)
def _generate_toc(self):
"""Generate key-to-(start, stop) table of contents."""
@@ -833,10 +868,10 @@ class mbox(_mboxMMDF):
while True:
line_pos = self._file.tell()
line = self._file.readline()
- if line.startswith('From '):
+ if line.startswith(b'From '):
if len(stops) < len(starts):
if last_was_empty:
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
else:
# The last line before the "From " line wasn't
# blank, but we consider it a start of a
@@ -846,11 +881,11 @@ class mbox(_mboxMMDF):
last_was_empty = False
elif not line:
if last_was_empty:
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
else:
stops.append(line_pos)
break
- elif line == os.linesep:
+ elif line == linesep:
last_was_empty = True
else:
last_was_empty = False
@@ -869,11 +904,11 @@ class MMDF(_mboxMMDF):
def _pre_message_hook(self, f):
"""Called before writing each message to file f."""
- f.write('\001\001\001\001' + os.linesep)
+ f.write(b'\001\001\001\001' + linesep)
def _post_message_hook(self, f):
"""Called after writing each message to file f."""
- f.write(os.linesep + '\001\001\001\001' + os.linesep)
+ f.write(linesep + b'\001\001\001\001' + linesep)
def _generate_toc(self):
"""Generate key-to-(start, stop) table of contents."""
@@ -884,19 +919,19 @@ class MMDF(_mboxMMDF):
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line.startswith('\001\001\001\001' + os.linesep):
+ if line.startswith(b'\001\001\001\001' + linesep):
starts.append(next_pos)
while True:
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line == '\001\001\001\001' + os.linesep:
- stops.append(line_pos - len(os.linesep))
+ if line == b'\001\001\001\001' + linesep:
+ stops.append(line_pos - len(linesep))
break
- elif line == '':
+ elif not line:
stops.append(line_pos)
break
- elif line == '':
+ elif not line:
break
self._toc = dict(enumerate(zip(starts, stops)))
self._next_key = len(self._toc)
@@ -912,9 +947,9 @@ class MH(Mailbox):
Mailbox.__init__(self, path, factory, create)
if not os.path.exists(self._path):
if create:
- os.mkdir(self._path, 0700)
+ os.mkdir(self._path, 0o700)
os.close(os.open(os.path.join(self._path, '.mh_sequences'),
- os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0600))
+ os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o600))
else:
raise NoSuchMailboxError(self._path)
self._locked = False
@@ -958,7 +993,7 @@ class MH(Mailbox):
path = os.path.join(self._path, str(key))
try:
f = open(path, 'rb+')
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
else:
@@ -972,7 +1007,7 @@ class MH(Mailbox):
path = os.path.join(self._path, str(key))
try:
f = open(path, 'rb+')
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
else:
@@ -995,10 +1030,10 @@ class MH(Mailbox):
"""Return a Message representation or raise a KeyError."""
try:
if self._locked:
- f = open(os.path.join(self._path, str(key)), 'r+')
+ f = open(os.path.join(self._path, str(key)), 'rb+')
else:
- f = open(os.path.join(self._path, str(key)), 'r')
- except IOError, e:
+ f = open(os.path.join(self._path, str(key)), 'rb')
+ except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
else:
@@ -1013,19 +1048,19 @@ class MH(Mailbox):
_unlock_file(f)
finally:
f.close()
- for name, key_list in self.get_sequences().iteritems():
+ for name, key_list in self.get_sequences().items():
if key in key_list:
msg.add_sequence(name)
return msg
- def get_string(self, key):
- """Return a string representation or raise a KeyError."""
+ def get_bytes(self, key):
+ """Return a bytes representation or raise a KeyError."""
try:
if self._locked:
- f = open(os.path.join(self._path, str(key)), 'r+')
+ f = open(os.path.join(self._path, str(key)), 'rb+')
else:
- f = open(os.path.join(self._path, str(key)), 'r')
- except IOError, e:
+ f = open(os.path.join(self._path, str(key)), 'rb')
+ except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
else:
@@ -1034,7 +1069,7 @@ class MH(Mailbox):
if self._locked:
_lock_file(f)
try:
- return f.read()
+ return f.read().replace(linesep, b'\n')
finally:
if self._locked:
_unlock_file(f)
@@ -1045,7 +1080,7 @@ class MH(Mailbox):
"""Return a file-like representation or raise a KeyError."""
try:
f = open(os.path.join(self._path, str(key)), 'rb')
- except IOError, e:
+ except IOError as e:
if e.errno == errno.ENOENT:
raise KeyError('No message with key: %s' % key)
else:
@@ -1057,13 +1092,13 @@ class MH(Mailbox):
return iter(sorted(int(entry) for entry in os.listdir(self._path)
if entry.isdigit()))
- def has_key(self, key):
+ def __contains__(self, key):
"""Return True if the keyed message exists, False otherwise."""
return os.path.exists(os.path.join(self._path, str(key)))
def __len__(self):
"""Return a count of messages in the mailbox."""
- return len(list(self.iterkeys()))
+ return len(list(self.keys()))
def lock(self):
"""Lock the mailbox."""
@@ -1151,10 +1186,10 @@ class MH(Mailbox):
f = open(os.path.join(self._path, '.mh_sequences'), 'r+')
try:
os.close(os.open(f.name, os.O_WRONLY | os.O_TRUNC))
- for name, keys in sequences.iteritems():
+ for name, keys in sequences.items():
if len(keys) == 0:
continue
- f.write('%s:' % name)
+ f.write(name + ':')
prev = None
completing = False
for key in sorted(set(keys)):
@@ -1180,7 +1215,7 @@ class MH(Mailbox):
sequences = self.get_sequences()
prev = 0
changes = []
- for key in self.iterkeys():
+ for key in self.keys():
if key - 1 != prev:
changes.append((key, prev + 1))
if hasattr(os, 'link'):
@@ -1204,7 +1239,7 @@ class MH(Mailbox):
"""Inspect a new MHMessage and update sequences appropriately."""
pending_sequences = message.get_sequences()
all_sequences = self.get_sequences()
- for name, key_list in all_sequences.iteritems():
+ for name, key_list in all_sequences.items():
if name in pending_sequences:
key_list.append(key)
elif key in key_list:
@@ -1249,50 +1284,55 @@ class Babyl(_singlefileMailbox):
"""Return a Message representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- self._file.readline() # Skip '1,' line specifying labels.
- original_headers = StringIO.StringIO()
+ self._file.readline() # Skip b'1,' line specifying labels.
+ original_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == '*** EOOH ***' + os.linesep or line == '':
+ if line == b'*** EOOH ***' + linesep or not line:
break
- original_headers.write(line.replace(os.linesep, '\n'))
- visible_headers = StringIO.StringIO()
+ original_headers.write(line.replace(linesep, b'\n'))
+ visible_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == os.linesep or line == '':
+ if line == linesep or not line:
break
- visible_headers.write(line.replace(os.linesep, '\n'))
- body = self._file.read(stop - self._file.tell()).replace(os.linesep,
- '\n')
+ visible_headers.write(line.replace(linesep, b'\n'))
+ # Read up to the stop, or to the end
+ n = stop - self._file.tell()
+ assert n >= 0
+ body = self._file.read(n)
+ body = body.replace(linesep, b'\n')
msg = BabylMessage(original_headers.getvalue() + body)
msg.set_visible(visible_headers.getvalue())
if key in self._labels:
msg.set_labels(self._labels[key])
return msg
- def get_string(self, key):
+ def get_bytes(self, key):
"""Return a string representation or raise a KeyError."""
start, stop = self._lookup(key)
self._file.seek(start)
- self._file.readline() # Skip '1,' line specifying labels.
- original_headers = StringIO.StringIO()
+ self._file.readline() # Skip b'1,' line specifying labels.
+ original_headers = io.BytesIO()
while True:
line = self._file.readline()
- if line == '*** EOOH ***' + os.linesep or line == '':
+ if line == b'*** EOOH ***' + linesep or not line:
break
- original_headers.write(line.replace(os.linesep, '\n'))
+ original_headers.write(line.replace(linesep, b'\n'))
while True:
line = self._file.readline()
- if line == os.linesep or line == '':
+ if line == linesep or not line:
break
- return original_headers.getvalue() + \
- self._file.read(stop - self._file.tell()).replace(os.linesep,
- '\n')
+ headers = original_headers.getvalue()
+ n = stop - self._file.tell()
+ assert n >= 0
+ data = self._file.read(n)
+ data = data.replace(linesep, b'\n')
+ return headers + data
def get_file(self, key):
"""Return a file-like representation or raise a KeyError."""
- return StringIO.StringIO(self.get_string(key).replace('\n',
- os.linesep))
+ return io.BytesIO(self.get_bytes(key).replace(b'\n', linesep))
def get_labels(self):
"""Return a list of user-defined labels in the mailbox."""
@@ -1313,19 +1353,19 @@ class Babyl(_singlefileMailbox):
line_pos = next_pos
line = self._file.readline()
next_pos = self._file.tell()
- if line == '\037\014' + os.linesep:
+ if line == b'\037\014' + linesep:
if len(stops) < len(starts):
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
starts.append(next_pos)
labels = [label.strip() for label
- in self._file.readline()[1:].split(',')
- if label.strip() != '']
+ in self._file.readline()[1:].split(b',')
+ if label.strip()]
label_lists.append(labels)
- elif line == '\037' or line == '\037' + os.linesep:
+ elif line == b'\037' or line == b'\037' + linesep:
if len(stops) < len(starts):
- stops.append(line_pos - len(os.linesep))
- elif line == '':
- stops.append(line_pos - len(os.linesep))
+ stops.append(line_pos - len(linesep))
+ elif not line:
+ stops.append(line_pos - len(linesep))
break
self._toc = dict(enumerate(zip(starts, stops)))
self._labels = dict(enumerate(label_lists))
@@ -1335,17 +1375,21 @@ class Babyl(_singlefileMailbox):
def _pre_mailbox_hook(self, f):
"""Called before writing the mailbox to file f."""
- f.write('BABYL OPTIONS:%sVersion: 5%sLabels:%s%s\037' %
- (os.linesep, os.linesep, ','.join(self.get_labels()),
- os.linesep))
+ babyl = b'BABYL OPTIONS:' + linesep
+ babyl += b'Version: 5' + linesep
+ labels = self.get_labels()
+ labels = (label.encode() for label in labels)
+ babyl += b'Labels:' + b','.join(labels) + linesep
+ babyl += b'\037'
+ f.write(babyl)
def _pre_message_hook(self, f):
"""Called before writing each message to file f."""
- f.write('\014' + os.linesep)
+ f.write(b'\014' + linesep)
def _post_message_hook(self, f):
"""Called after writing each message to file f."""
- f.write(os.linesep + '\037')
+ f.write(linesep + b'\037')
def _install_message(self, message):
"""Write message contents and return (start, stop)."""
@@ -1358,78 +1402,97 @@ class Babyl(_singlefileMailbox):
special_labels.append(label)
else:
labels.append(label)
- self._file.write('1')
+ self._file.write(b'1')
for label in special_labels:
- self._file.write(', ' + label)
- self._file.write(',,')
+ self._file.write(b', ' + label.encode())
+ self._file.write(b',,')
for label in labels:
- self._file.write(' ' + label + ',')
- self._file.write(os.linesep)
+ self._file.write(b' ' + label.encode() + b',')
+ self._file.write(linesep)
else:
- self._file.write('1,,' + os.linesep)
+ self._file.write(b'1,,' + linesep)
if isinstance(message, email.message.Message):
- orig_buffer = StringIO.StringIO()
- orig_generator = email.generator.Generator(orig_buffer, False, 0)
+ orig_buffer = io.BytesIO()
+ orig_generator = email.generator.BytesGenerator(orig_buffer, False, 0)
orig_generator.flatten(message)
orig_buffer.seek(0)
while True:
line = orig_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or line == '':
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
- self._file.write('*** EOOH ***' + os.linesep)
+ self._file.write(b'*** EOOH ***' + linesep)
if isinstance(message, BabylMessage):
- vis_buffer = StringIO.StringIO()
- vis_generator = email.generator.Generator(vis_buffer, False, 0)
+ vis_buffer = io.BytesIO()
+ vis_generator = email.generator.BytesGenerator(vis_buffer, False, 0)
vis_generator.flatten(message.get_visible())
while True:
line = vis_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or line == '':
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
else:
orig_buffer.seek(0)
while True:
line = orig_buffer.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or line == '':
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
break
while True:
buffer = orig_buffer.read(4096) # Buffer size is arbitrary.
- if buffer == '':
+ if not buffer:
break
- self._file.write(buffer.replace('\n', os.linesep))
- elif isinstance(message, str):
- body_start = message.find('\n\n') + 2
+ 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()
+ if isinstance(message, str):
+ message = self._string_to_bytes(message)
+ body_start = message.find(b'\n\n') + 2
if body_start - 2 != -1:
- self._file.write(message[:body_start].replace('\n',
- os.linesep))
- self._file.write('*** EOOH ***' + os.linesep)
- self._file.write(message[:body_start].replace('\n',
- os.linesep))
- self._file.write(message[body_start:].replace('\n',
- os.linesep))
+ self._file.write(message[:body_start].replace(b'\n', linesep))
+ self._file.write(b'*** EOOH ***' + linesep)
+ self._file.write(message[:body_start].replace(b'\n', linesep))
+ self._file.write(message[body_start:].replace(b'\n', linesep))
else:
- self._file.write('*** EOOH ***' + os.linesep + os.linesep)
- self._file.write(message.replace('\n', os.linesep))
+ self._file.write(b'*** EOOH ***' + linesep + linesep)
+ 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
original_pos = message.tell()
first_pass = True
while True:
line = message.readline()
- self._file.write(line.replace('\n', os.linesep))
- if line == '\n' or line == '':
+ # Universal newline support.
+ if line.endswith(b'\r\n'):
+ line = line[:-2] + b'\n'
+ elif line.endswith(b'\r'):
+ line = line[:-1] + b'\n'
+ self._file.write(line.replace(b'\n', linesep))
+ if line == b'\n' or not line:
if first_pass:
first_pass = False
- self._file.write('*** EOOH ***' + os.linesep)
+ self._file.write(b'*** EOOH ***' + linesep)
message.seek(original_pos)
else:
break
while True:
- buffer = message.read(4096) # Buffer size is arbitrary.
- if buffer == '':
+ line = message.readline()
+ if not line:
break
- self._file.write(buffer.replace('\n', os.linesep))
+ # Universal newline support.
+ if line.endswith(b'\r\n'):
+ line = line[:-2] + linesep
+ elif line.endswith(b'\r'):
+ line = line[:-1] + linesep
+ elif line.endswith(b'\n'):
+ line = line[:-1] + linesep
+ self._file.write(line)
else:
raise TypeError('Invalid message type: %s' % type(message))
stop = self._file.tell()
@@ -1445,10 +1508,14 @@ class Message(email.message.Message):
self._become_message(copy.deepcopy(message))
if isinstance(message, Message):
message._explain_to(self)
+ elif isinstance(message, bytes):
+ self._become_message(email.message_from_bytes(message))
elif isinstance(message, str):
self._become_message(email.message_from_string(message))
- elif hasattr(message, "read"):
+ elif isinstance(message, io.TextIOWrapper):
self._become_message(email.message_from_file(message))
+ elif hasattr(message, "read"):
+ self._become_message(email.message_from_binary_file(message))
elif message is None:
email.message.Message.__init__(self)
else:
@@ -1506,7 +1573,7 @@ class MaildirMessage(Message):
def remove_flag(self, flag):
"""Unset the given string flag(s) without changing others."""
- if self.get_flags() != '':
+ if self.get_flags():
self.set_flags(''.join(set(self.get_flags()) - set(flag)))
def get_date(self):
@@ -1712,7 +1779,7 @@ class MHMessage(Message):
if not sequence in self._sequences:
self._sequences.append(sequence)
else:
- raise TypeError('sequence must be a string: %s' % type(sequence))
+ raise TypeError('sequence type must be str: %s' % type(sequence))
def remove_sequence(self, sequence):
"""Remove sequence from the list of sequences including the message."""
@@ -1872,6 +1939,10 @@ class _ProxyFile:
"""Read bytes."""
return self._read(size, self._file.read)
+ def read1(self, size=None):
+ """Read bytes."""
+ return self._read(size, self._file.read1)
+
def readline(self, size=None):
"""Read a line."""
return self._read(size, self._file.readline)
@@ -1889,7 +1960,11 @@ class _ProxyFile:
def __iter__(self):
"""Iterate over lines."""
- return iter(self.readline, "")
+ while True:
+ line = self.readline()
+ if not line:
+ raise StopIteration
+ yield line
def tell(self):
"""Return the position."""
@@ -1918,6 +1993,33 @@ class _ProxyFile:
self._pos = self._file.tell()
return result
+ def __enter__(self):
+ """Context manager protocol support."""
+ return self
+
+ def __exit__(self, *exc):
+ self.close()
+
+ def readable(self):
+ return self._file.readable()
+
+ def writable(self):
+ return self._file.writable()
+
+ def seekable(self):
+ return self._file.seekable()
+
+ def flush(self):
+ return self._file.flush()
+
+ @property
+ def closed(self):
+ if not hasattr(self, '_file'):
+ return True
+ if not hasattr(self._file, 'closed'):
+ return False
+ return self._file.closed
+
class _PartialFile(_ProxyFile):
"""A read-only wrapper of part of a file."""
@@ -1946,7 +2048,7 @@ class _PartialFile(_ProxyFile):
"""Read size bytes using read_method, honoring start and stop."""
remaining = self._stop - self._pos
if remaining <= 0:
- return ''
+ return b''
if size is None or size < 0 or size > remaining:
size = remaining
return _ProxyFile._read(self, size, read_method)
@@ -1965,7 +2067,7 @@ def _lock_file(f, dotlock=True):
if fcntl:
try:
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
- except IOError, e:
+ except IOError as e:
if e.errno in (errno.EAGAIN, errno.EACCES, errno.EROFS):
raise ExternalClashError('lockf: lock unavailable: %s' %
f.name)
@@ -1975,7 +2077,7 @@ def _lock_file(f, dotlock=True):
try:
pre_lock = _create_temporary(f.name + '.lock')
pre_lock.close()
- except IOError, e:
+ except IOError as e:
if e.errno in (errno.EACCES, errno.EROFS):
return # Without write access, just skip dotlocking.
else:
@@ -1988,7 +2090,7 @@ def _lock_file(f, dotlock=True):
else:
os.rename(pre_lock.name, f.name + '.lock')
dotlock_done = True
- except OSError, e:
+ except OSError as e:
if e.errno == errno.EEXIST or \
(os.name == 'os2' and e.errno == errno.EACCES):
os.remove(pre_lock.name)
@@ -2012,7 +2114,7 @@ def _unlock_file(f):
def _create_carefully(path):
"""Create a file if it doesn't exist and open for reading and writing."""
- fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0666)
+ fd = os.open(path, os.O_CREAT | os.O_EXCL | os.O_RDWR, 0o666)
try:
return open(path, 'rb+')
finally:
@@ -2035,184 +2137,6 @@ def _sync_close(f):
_sync_flush(f)
f.close()
-## Start: classes from the original module (for backward compatibility).
-
-# Note that the Maildir class, whose name is unchanged, itself offers a next()
-# method for backward compatibility.
-
-class _Mailbox:
-
- def __init__(self, fp, factory=rfc822.Message):
- self.fp = fp
- self.seekp = 0
- self.factory = factory
-
- def __iter__(self):
- return iter(self.next, None)
-
- def next(self):
- while 1:
- self.fp.seek(self.seekp)
- try:
- self._search_start()
- except EOFError:
- self.seekp = self.fp.tell()
- return None
- start = self.fp.tell()
- self._search_end()
- self.seekp = stop = self.fp.tell()
- if start != stop:
- break
- return self.factory(_PartialFile(self.fp, start, stop))
-
-# Recommended to use PortableUnixMailbox instead!
-class UnixMailbox(_Mailbox):
-
- def _search_start(self):
- while 1:
- pos = self.fp.tell()
- line = self.fp.readline()
- if not line:
- raise EOFError
- if line[:5] == 'From ' and self._isrealfromline(line):
- self.fp.seek(pos)
- return
-
- def _search_end(self):
- self.fp.readline() # Throw away header line
- while 1:
- pos = self.fp.tell()
- line = self.fp.readline()
- if not line:
- return
- if line[:5] == 'From ' and self._isrealfromline(line):
- self.fp.seek(pos)
- return
-
- # An overridable mechanism to test for From-line-ness. You can either
- # specify a different regular expression or define a whole new
- # _isrealfromline() method. Note that this only gets called for lines
- # starting with the 5 characters "From ".
- #
- # BAW: According to
- #http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html
- # the only portable, reliable way to find message delimiters in a BSD (i.e
- # Unix mailbox) style folder is to search for "\n\nFrom .*\n", or at the
- # beginning of the file, "^From .*\n". While _fromlinepattern below seems
- # like a good idea, in practice, there are too many variations for more
- # strict parsing of the line to be completely accurate.
- #
- # _strict_isrealfromline() is the old version which tries to do stricter
- # parsing of the From_ line. _portable_isrealfromline() simply returns
- # true, since it's never called if the line doesn't already start with
- # "From ".
- #
- # This algorithm, and the way it interacts with _search_start() and
- # _search_end() may not be completely correct, because it doesn't check
- # that the two characters preceding "From " are \n\n or the beginning of
- # the file. Fixing this would require a more extensive rewrite than is
- # necessary. For convenience, we've added a PortableUnixMailbox class
- # which does no checking of the format of the 'From' line.
-
- _fromlinepattern = (r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+"
- r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*"
- r"[^\s]*\s*"
- "$")
- _regexp = None
-
- def _strict_isrealfromline(self, line):
- if not self._regexp:
- import re
- self._regexp = re.compile(self._fromlinepattern)
- return self._regexp.match(line)
-
- def _portable_isrealfromline(self, line):
- return True
-
- _isrealfromline = _strict_isrealfromline
-
-
-class PortableUnixMailbox(UnixMailbox):
- _isrealfromline = UnixMailbox._portable_isrealfromline
-
-
-class MmdfMailbox(_Mailbox):
-
- def _search_start(self):
- while 1:
- line = self.fp.readline()
- if not line:
- raise EOFError
- if line[:5] == '\001\001\001\001\n':
- return
-
- def _search_end(self):
- while 1:
- pos = self.fp.tell()
- line = self.fp.readline()
- if not line:
- return
- if line == '\001\001\001\001\n':
- self.fp.seek(pos)
- return
-
-
-class MHMailbox:
-
- def __init__(self, dirname, factory=rfc822.Message):
- import re
- pat = re.compile('^[1-9][0-9]*$')
- self.dirname = dirname
- # the three following lines could be combined into:
- # list = map(long, filter(pat.match, os.listdir(self.dirname)))
- list = os.listdir(self.dirname)
- list = filter(pat.match, list)
- list = map(long, list)
- list.sort()
- # This only works in Python 1.6 or later;
- # before that str() added 'L':
- self.boxes = map(str, list)
- self.boxes.reverse()
- self.factory = factory
-
- def __iter__(self):
- return iter(self.next, None)
-
- def next(self):
- if not self.boxes:
- return None
- fn = self.boxes.pop()
- fp = open(os.path.join(self.dirname, fn))
- msg = self.factory(fp)
- try:
- msg._mh_msgno = fn
- except (AttributeError, TypeError):
- pass
- return msg
-
-
-class BabylMailbox(_Mailbox):
-
- def _search_start(self):
- while 1:
- line = self.fp.readline()
- if not line:
- raise EOFError
- if line == '*** EOOH ***\n':
- return
-
- def _search_end(self):
- while 1:
- pos = self.fp.tell()
- line = self.fp.readline()
- if not line:
- return
- if line == '\037\014\n' or line == '\037':
- self.fp.seek(pos)
- return
-
-## End: classes from the original module (for backward compatibility).
-
class Error(Exception):
"""Raised for module-specific errors."""
diff --git a/Lib/mailcap.py b/Lib/mailcap.py
index b2ddacd046d..4ae13d7ed7f 100644
--- a/Lib/mailcap.py
+++ b/Lib/mailcap.py
@@ -24,7 +24,7 @@ def getcaps():
continue
morecaps = readmailcapfile(fp)
fp.close()
- for key, value in morecaps.iteritems():
+ for key, value in morecaps.items():
if not key in caps:
caps[key] = value
else:
@@ -164,7 +164,7 @@ def lookup(caps, MIMEtype, key=None):
if MIMEtype in caps:
entries = entries + caps[MIMEtype]
if key is not None:
- entries = filter(lambda e, key=key: key in e, entries)
+ entries = [e for e in entries if key in e]
return entries
def subst(field, MIMEtype, filename, plist=[]):
@@ -219,37 +219,35 @@ def test():
for i in range(1, len(sys.argv), 2):
args = sys.argv[i:i+2]
if len(args) < 2:
- print "usage: mailcap [MIMEtype file] ..."
+ print("usage: mailcap [MIMEtype file] ...")
return
MIMEtype = args[0]
file = args[1]
command, e = findmatch(caps, MIMEtype, 'view', file)
if not command:
- print "No viewer found for", type
+ print("No viewer found for", type)
else:
- print "Executing:", command
+ print("Executing:", command)
sts = os.system(command)
if sts:
- print "Exit status:", sts
+ print("Exit status:", sts)
def show(caps):
- print "Mailcap files:"
- for fn in listmailcapfiles(): print "\t" + fn
- print
+ print("Mailcap files:")
+ for fn in listmailcapfiles(): print("\t" + fn)
+ print()
if not caps: caps = getcaps()
- print "Mailcap entries:"
- print
- ckeys = caps.keys()
- ckeys.sort()
+ print("Mailcap entries:")
+ print()
+ ckeys = sorted(caps)
for type in ckeys:
- print type
+ print(type)
entries = caps[type]
for e in entries:
- keys = e.keys()
- keys.sort()
+ keys = sorted(e)
for k in keys:
- print " %-15s" % k, e[k]
- print
+ print(" %-15s" % k, e[k])
+ print()
if __name__ == '__main__':
test()
diff --git a/Lib/md5.py b/Lib/md5.py
deleted file mode 100644
index a44ca3b4934..00000000000
--- a/Lib/md5.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# $Id$
-#
-# Copyright (C) 2005 Gregory P. Smith (greg@krypto.org)
-# Licensed to PSF under a Contributor Agreement.
-
-import warnings
-warnings.warn("the md5 module is deprecated; use hashlib instead",
- DeprecationWarning, 2)
-
-from hashlib import md5
-new = md5
-
-blocksize = 1 # legacy value (wrong in any useful sense)
-digest_size = 16
diff --git a/Lib/mhlib.py b/Lib/mhlib.py
deleted file mode 100644
index 856e87804cd..00000000000
--- a/Lib/mhlib.py
+++ /dev/null
@@ -1,1005 +0,0 @@
-"""MH interface -- purely object-oriented (well, almost)
-
-Executive summary:
-
-import mhlib
-
-mh = mhlib.MH() # use default mailbox directory and profile
-mh = mhlib.MH(mailbox) # override mailbox location (default from profile)
-mh = mhlib.MH(mailbox, profile) # override mailbox and profile
-
-mh.error(format, ...) # print error message -- can be overridden
-s = mh.getprofile(key) # profile entry (None if not set)
-path = mh.getpath() # mailbox pathname
-name = mh.getcontext() # name of current folder
-mh.setcontext(name) # set name of current folder
-
-list = mh.listfolders() # names of top-level folders
-list = mh.listallfolders() # names of all folders, including subfolders
-list = mh.listsubfolders(name) # direct subfolders of given folder
-list = mh.listallsubfolders(name) # all subfolders of given folder
-
-mh.makefolder(name) # create new folder
-mh.deletefolder(name) # delete folder -- must have no subfolders
-
-f = mh.openfolder(name) # new open folder object
-
-f.error(format, ...) # same as mh.error(format, ...)
-path = f.getfullname() # folder's full pathname
-path = f.getsequencesfilename() # full pathname of folder's sequences file
-path = f.getmessagefilename(n) # full pathname of message n in folder
-
-list = f.listmessages() # list of messages in folder (as numbers)
-n = f.getcurrent() # get current message
-f.setcurrent(n) # set current message
-list = f.parsesequence(seq) # parse msgs syntax into list of messages
-n = f.getlast() # get last message (0 if no messagse)
-f.setlast(n) # set last message (internal use only)
-
-dict = f.getsequences() # dictionary of sequences in folder {name: list}
-f.putsequences(dict) # write sequences back to folder
-
-f.createmessage(n, fp) # add message from file f as number n
-f.removemessages(list) # remove messages in list from folder
-f.refilemessages(list, tofolder) # move messages in list to other folder
-f.movemessage(n, tofolder, ton) # move one message to a given destination
-f.copymessage(n, tofolder, ton) # copy one message to a given destination
-
-m = f.openmessage(n) # new open message object (costs a file descriptor)
-m is a derived class of mimetools.Message(rfc822.Message), with:
-s = m.getheadertext() # text of message's headers
-s = m.getheadertext(pred) # text of message's headers, filtered by pred
-s = m.getbodytext() # text of message's body, decoded
-s = m.getbodytext(0) # text of message's body, not decoded
-"""
-from warnings import warnpy3k
-warnpy3k("the mhlib module has been removed in Python 3.0; use the mailbox "
- "module instead", stacklevel=2)
-del warnpy3k
-
-# XXX To do, functionality:
-# - annotate messages
-# - send messages
-#
-# XXX To do, organization:
-# - move IntSet to separate file
-# - move most Message functionality to module mimetools
-
-
-# Customizable defaults
-
-MH_PROFILE = '~/.mh_profile'
-PATH = '~/Mail'
-MH_SEQUENCES = '.mh_sequences'
-FOLDER_PROTECT = 0700
-
-
-# Imported modules
-
-import os
-import sys
-import re
-import mimetools
-import multifile
-import shutil
-from bisect import bisect
-
-__all__ = ["MH","Error","Folder","Message"]
-
-# Exported constants
-
-class Error(Exception):
- pass
-
-
-class MH:
- """Class representing a particular collection of folders.
- Optional constructor arguments are the pathname for the directory
- containing the collection, and the MH profile to use.
- If either is omitted or empty a default is used; the default
- directory is taken from the MH profile if it is specified there."""
-
- def __init__(self, path = None, profile = None):
- """Constructor."""
- if profile is None: profile = MH_PROFILE
- self.profile = os.path.expanduser(profile)
- if path is None: path = self.getprofile('Path')
- if not path: path = PATH
- if not os.path.isabs(path) and path[0] != '~':
- path = os.path.join('~', path)
- path = os.path.expanduser(path)
- if not os.path.isdir(path): raise Error, 'MH() path not found'
- self.path = path
-
- def __repr__(self):
- """String representation."""
- return 'MH(%r, %r)' % (self.path, self.profile)
-
- def error(self, msg, *args):
- """Routine to print an error. May be overridden by a derived class."""
- sys.stderr.write('MH error: %s\n' % (msg % args))
-
- def getprofile(self, key):
- """Return a profile entry, None if not found."""
- return pickline(self.profile, key)
-
- def getpath(self):
- """Return the path (the name of the collection's directory)."""
- return self.path
-
- def getcontext(self):
- """Return the name of the current folder."""
- context = pickline(os.path.join(self.getpath(), 'context'),
- 'Current-Folder')
- if not context: context = 'inbox'
- return context
-
- def setcontext(self, context):
- """Set the name of the current folder."""
- fn = os.path.join(self.getpath(), 'context')
- f = open(fn, "w")
- f.write("Current-Folder: %s\n" % context)
- f.close()
-
- def listfolders(self):
- """Return the names of the top-level folders."""
- folders = []
- path = self.getpath()
- for name in os.listdir(path):
- fullname = os.path.join(path, name)
- if os.path.isdir(fullname):
- folders.append(name)
- folders.sort()
- return folders
-
- def listsubfolders(self, name):
- """Return the names of the subfolders in a given folder
- (prefixed with the given folder name)."""
- fullname = os.path.join(self.path, name)
- # Get the link count so we can avoid listing folders
- # that have no subfolders.
- nlinks = os.stat(fullname).st_nlink
- if nlinks <= 2:
- return []
- subfolders = []
- subnames = os.listdir(fullname)
- for subname in subnames:
- fullsubname = os.path.join(fullname, subname)
- if os.path.isdir(fullsubname):
- name_subname = os.path.join(name, subname)
- subfolders.append(name_subname)
- # Stop looking for subfolders when
- # we've seen them all
- nlinks = nlinks - 1
- if nlinks <= 2:
- break
- subfolders.sort()
- return subfolders
-
- def listallfolders(self):
- """Return the names of all folders and subfolders, recursively."""
- return self.listallsubfolders('')
-
- def listallsubfolders(self, name):
- """Return the names of subfolders in a given folder, recursively."""
- fullname = os.path.join(self.path, name)
- # Get the link count so we can avoid listing folders
- # that have no subfolders.
- nlinks = os.stat(fullname).st_nlink
- if nlinks <= 2:
- return []
- subfolders = []
- subnames = os.listdir(fullname)
- for subname in subnames:
- if subname[0] == ',' or isnumeric(subname): continue
- fullsubname = os.path.join(fullname, subname)
- if os.path.isdir(fullsubname):
- name_subname = os.path.join(name, subname)
- subfolders.append(name_subname)
- if not os.path.islink(fullsubname):
- subsubfolders = self.listallsubfolders(
- name_subname)
- subfolders = subfolders + subsubfolders
- # Stop looking for subfolders when
- # we've seen them all
- nlinks = nlinks - 1
- if nlinks <= 2:
- break
- subfolders.sort()
- return subfolders
-
- def openfolder(self, name):
- """Return a new Folder object for the named folder."""
- return Folder(self, name)
-
- def makefolder(self, name):
- """Create a new folder (or raise os.error if it cannot be created)."""
- protect = pickline(self.profile, 'Folder-Protect')
- if protect and isnumeric(protect):
- mode = int(protect, 8)
- else:
- mode = FOLDER_PROTECT
- os.mkdir(os.path.join(self.getpath(), name), mode)
-
- def deletefolder(self, name):
- """Delete a folder. This removes files in the folder but not
- subdirectories. Raise os.error if deleting the folder itself fails."""
- fullname = os.path.join(self.getpath(), name)
- for subname in os.listdir(fullname):
- fullsubname = os.path.join(fullname, subname)
- try:
- os.unlink(fullsubname)
- except os.error:
- self.error('%s not deleted, continuing...' %
- fullsubname)
- os.rmdir(fullname)
-
-
-numericprog = re.compile('^[1-9][0-9]*$')
-def isnumeric(str):
- return numericprog.match(str) is not None
-
-class Folder:
- """Class representing a particular folder."""
-
- def __init__(self, mh, name):
- """Constructor."""
- self.mh = mh
- self.name = name
- if not os.path.isdir(self.getfullname()):
- raise Error, 'no folder %s' % name
-
- def __repr__(self):
- """String representation."""
- return 'Folder(%r, %r)' % (self.mh, self.name)
-
- def error(self, *args):
- """Error message handler."""
- self.mh.error(*args)
-
- def getfullname(self):
- """Return the full pathname of the folder."""
- return os.path.join(self.mh.path, self.name)
-
- def getsequencesfilename(self):
- """Return the full pathname of the folder's sequences file."""
- return os.path.join(self.getfullname(), MH_SEQUENCES)
-
- def getmessagefilename(self, n):
- """Return the full pathname of a message in the folder."""
- return os.path.join(self.getfullname(), str(n))
-
- def listsubfolders(self):
- """Return list of direct subfolders."""
- return self.mh.listsubfolders(self.name)
-
- def listallsubfolders(self):
- """Return list of all subfolders."""
- return self.mh.listallsubfolders(self.name)
-
- def listmessages(self):
- """Return the list of messages currently present in the folder.
- As a side effect, set self.last to the last message (or 0)."""
- messages = []
- match = numericprog.match
- append = messages.append
- for name in os.listdir(self.getfullname()):
- if match(name):
- append(name)
- messages = map(int, messages)
- messages.sort()
- if messages:
- self.last = messages[-1]
- else:
- self.last = 0
- return messages
-
- def getsequences(self):
- """Return the set of sequences for the folder."""
- sequences = {}
- fullname = self.getsequencesfilename()
- try:
- f = open(fullname, 'r')
- except IOError:
- return sequences
- while 1:
- line = f.readline()
- if not line: break
- fields = line.split(':')
- if len(fields) != 2:
- self.error('bad sequence in %s: %s' %
- (fullname, line.strip()))
- key = fields[0].strip()
- value = IntSet(fields[1].strip(), ' ').tolist()
- sequences[key] = value
- return sequences
-
- def putsequences(self, sequences):
- """Write the set of sequences back to the folder."""
- fullname = self.getsequencesfilename()
- f = None
- for key, seq in sequences.iteritems():
- s = IntSet('', ' ')
- s.fromlist(seq)
- if not f: f = open(fullname, 'w')
- f.write('%s: %s\n' % (key, s.tostring()))
- if not f:
- try:
- os.unlink(fullname)
- except os.error:
- pass
- else:
- f.close()
-
- def getcurrent(self):
- """Return the current message. Raise Error when there is none."""
- seqs = self.getsequences()
- try:
- return max(seqs['cur'])
- except (ValueError, KeyError):
- raise Error, "no cur message"
-
- def setcurrent(self, n):
- """Set the current message."""
- updateline(self.getsequencesfilename(), 'cur', str(n), 0)
-
- def parsesequence(self, seq):
- """Parse an MH sequence specification into a message list.
- Attempt to mimic mh-sequence(5) as close as possible.
- Also attempt to mimic observed behavior regarding which
- conditions cause which error messages."""
- # XXX Still not complete (see mh-format(5)).
- # Missing are:
- # - 'prev', 'next' as count
- # - Sequence-Negation option
- all = self.listmessages()
- # Observed behavior: test for empty folder is done first
- if not all:
- raise Error, "no messages in %s" % self.name
- # Common case first: all is frequently the default
- if seq == 'all':
- return all
- # Test for X:Y before X-Y because 'seq:-n' matches both
- i = seq.find(':')
- if i >= 0:
- head, dir, tail = seq[:i], '', seq[i+1:]
- if tail[:1] in '-+':
- dir, tail = tail[:1], tail[1:]
- if not isnumeric(tail):
- raise Error, "bad message list %s" % seq
- try:
- count = int(tail)
- except (ValueError, OverflowError):
- # Can't use sys.maxint because of i+count below
- count = len(all)
- try:
- anchor = self._parseindex(head, all)
- except Error, msg:
- seqs = self.getsequences()
- if not head in seqs:
- if not msg:
- msg = "bad message list %s" % seq
- raise Error, msg, sys.exc_info()[2]
- msgs = seqs[head]
- if not msgs:
- raise Error, "sequence %s empty" % head
- if dir == '-':
- return msgs[-count:]
- else:
- return msgs[:count]
- else:
- if not dir:
- if head in ('prev', 'last'):
- dir = '-'
- if dir == '-':
- i = bisect(all, anchor)
- return all[max(0, i-count):i]
- else:
- i = bisect(all, anchor-1)
- return all[i:i+count]
- # Test for X-Y next
- i = seq.find('-')
- if i >= 0:
- begin = self._parseindex(seq[:i], all)
- end = self._parseindex(seq[i+1:], all)
- i = bisect(all, begin-1)
- j = bisect(all, end)
- r = all[i:j]
- if not r:
- raise Error, "bad message list %s" % seq
- return r
- # Neither X:Y nor X-Y; must be a number or a (pseudo-)sequence
- try:
- n = self._parseindex(seq, all)
- except Error, msg:
- seqs = self.getsequences()
- if not seq in seqs:
- if not msg:
- msg = "bad message list %s" % seq
- raise Error, msg
- return seqs[seq]
- else:
- if n not in all:
- if isnumeric(seq):
- raise Error, "message %d doesn't exist" % n
- else:
- raise Error, "no %s message" % seq
- else:
- return [n]
-
- def _parseindex(self, seq, all):
- """Internal: parse a message number (or cur, first, etc.)."""
- if isnumeric(seq):
- try:
- return int(seq)
- except (OverflowError, ValueError):
- return sys.maxint
- if seq in ('cur', '.'):
- return self.getcurrent()
- if seq == 'first':
- return all[0]
- if seq == 'last':
- return all[-1]
- if seq == 'next':
- n = self.getcurrent()
- i = bisect(all, n)
- try:
- return all[i]
- except IndexError:
- raise Error, "no next message"
- if seq == 'prev':
- n = self.getcurrent()
- i = bisect(all, n-1)
- if i == 0:
- raise Error, "no prev message"
- try:
- return all[i-1]
- except IndexError:
- raise Error, "no prev message"
- raise Error, None
-
- def openmessage(self, n):
- """Open a message -- returns a Message object."""
- return Message(self, n)
-
- def removemessages(self, list):
- """Remove one or more messages -- may raise os.error."""
- errors = []
- deleted = []
- for n in list:
- path = self.getmessagefilename(n)
- commapath = self.getmessagefilename(',' + str(n))
- try:
- os.unlink(commapath)
- except os.error:
- pass
- try:
- os.rename(path, commapath)
- except os.error, msg:
- errors.append(msg)
- else:
- deleted.append(n)
- if deleted:
- self.removefromallsequences(deleted)
- if errors:
- if len(errors) == 1:
- raise os.error, errors[0]
- else:
- raise os.error, ('multiple errors:', errors)
-
- def refilemessages(self, list, tofolder, keepsequences=0):
- """Refile one or more messages -- may raise os.error.
- 'tofolder' is an open folder object."""
- errors = []
- refiled = {}
- for n in list:
- ton = tofolder.getlast() + 1
- path = self.getmessagefilename(n)
- topath = tofolder.getmessagefilename(ton)
- try:
- os.rename(path, topath)
- except os.error:
- # Try copying
- try:
- shutil.copy2(path, topath)
- os.unlink(path)
- except (IOError, os.error), msg:
- errors.append(msg)
- try:
- os.unlink(topath)
- except os.error:
- pass
- continue
- tofolder.setlast(ton)
- refiled[n] = ton
- if refiled:
- if keepsequences:
- tofolder._copysequences(self, refiled.items())
- self.removefromallsequences(refiled.keys())
- if errors:
- if len(errors) == 1:
- raise os.error, errors[0]
- else:
- raise os.error, ('multiple errors:', errors)
-
- def _copysequences(self, fromfolder, refileditems):
- """Helper for refilemessages() to copy sequences."""
- fromsequences = fromfolder.getsequences()
- tosequences = self.getsequences()
- changed = 0
- for name, seq in fromsequences.items():
- try:
- toseq = tosequences[name]
- new = 0
- except KeyError:
- toseq = []
- new = 1
- for fromn, ton in refileditems:
- if fromn in seq:
- toseq.append(ton)
- changed = 1
- if new and toseq:
- tosequences[name] = toseq
- if changed:
- self.putsequences(tosequences)
-
- def movemessage(self, n, tofolder, ton):
- """Move one message over a specific destination message,
- which may or may not already exist."""
- path = self.getmessagefilename(n)
- # Open it to check that it exists
- f = open(path)
- f.close()
- del f
- topath = tofolder.getmessagefilename(ton)
- backuptopath = tofolder.getmessagefilename(',%d' % ton)
- try:
- os.rename(topath, backuptopath)
- except os.error:
- pass
- try:
- os.rename(path, topath)
- except os.error:
- # Try copying
- ok = 0
- try:
- tofolder.setlast(None)
- shutil.copy2(path, topath)
- ok = 1
- finally:
- if not ok:
- try:
- os.unlink(topath)
- except os.error:
- pass
- os.unlink(path)
- self.removefromallsequences([n])
-
- def copymessage(self, n, tofolder, ton):
- """Copy one message over a specific destination message,
- which may or may not already exist."""
- path = self.getmessagefilename(n)
- # Open it to check that it exists
- f = open(path)
- f.close()
- del f
- topath = tofolder.getmessagefilename(ton)
- backuptopath = tofolder.getmessagefilename(',%d' % ton)
- try:
- os.rename(topath, backuptopath)
- except os.error:
- pass
- ok = 0
- try:
- tofolder.setlast(None)
- shutil.copy2(path, topath)
- ok = 1
- finally:
- if not ok:
- try:
- os.unlink(topath)
- except os.error:
- pass
-
- def createmessage(self, n, txt):
- """Create a message, with text from the open file txt."""
- path = self.getmessagefilename(n)
- backuppath = self.getmessagefilename(',%d' % n)
- try:
- os.rename(path, backuppath)
- except os.error:
- pass
- ok = 0
- BUFSIZE = 16*1024
- try:
- f = open(path, "w")
- while 1:
- buf = txt.read(BUFSIZE)
- if not buf:
- break
- f.write(buf)
- f.close()
- ok = 1
- finally:
- if not ok:
- try:
- os.unlink(path)
- except os.error:
- pass
-
- def removefromallsequences(self, list):
- """Remove one or more messages from all sequences (including last)
- -- but not from 'cur'!!!"""
- if hasattr(self, 'last') and self.last in list:
- del self.last
- sequences = self.getsequences()
- changed = 0
- for name, seq in sequences.items():
- if name == 'cur':
- continue
- for n in list:
- if n in seq:
- seq.remove(n)
- changed = 1
- if not seq:
- del sequences[name]
- if changed:
- self.putsequences(sequences)
-
- def getlast(self):
- """Return the last message number."""
- if not hasattr(self, 'last'):
- self.listmessages() # Set self.last
- return self.last
-
- def setlast(self, last):
- """Set the last message number."""
- if last is None:
- if hasattr(self, 'last'):
- del self.last
- else:
- self.last = last
-
-class Message(mimetools.Message):
-
- def __init__(self, f, n, fp = None):
- """Constructor."""
- self.folder = f
- self.number = n
- if fp is None:
- path = f.getmessagefilename(n)
- fp = open(path, 'r')
- mimetools.Message.__init__(self, fp)
-
- def __repr__(self):
- """String representation."""
- return 'Message(%s, %s)' % (repr(self.folder), self.number)
-
- def getheadertext(self, pred = None):
- """Return the message's header text as a string. If an
- argument is specified, it is used as a filter predicate to
- decide which headers to return (its argument is the header
- name converted to lower case)."""
- if pred is None:
- return ''.join(self.headers)
- headers = []
- hit = 0
- for line in self.headers:
- if not line[0].isspace():
- i = line.find(':')
- if i > 0:
- hit = pred(line[:i].lower())
- if hit: headers.append(line)
- return ''.join(headers)
-
- def getbodytext(self, decode = 1):
- """Return the message's body text as string. This undoes a
- Content-Transfer-Encoding, but does not interpret other MIME
- features (e.g. multipart messages). To suppress decoding,
- pass 0 as an argument."""
- self.fp.seek(self.startofbody)
- encoding = self.getencoding()
- if not decode or encoding in ('', '7bit', '8bit', 'binary'):
- return self.fp.read()
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- output = StringIO()
- mimetools.decode(self.fp, output, encoding)
- return output.getvalue()
-
- def getbodyparts(self):
- """Only for multipart messages: return the message's body as a
- list of SubMessage objects. Each submessage object behaves
- (almost) as a Message object."""
- if self.getmaintype() != 'multipart':
- raise Error, 'Content-Type is not multipart/*'
- bdry = self.getparam('boundary')
- if not bdry:
- raise Error, 'multipart/* without boundary param'
- self.fp.seek(self.startofbody)
- mf = multifile.MultiFile(self.fp)
- mf.push(bdry)
- parts = []
- while mf.next():
- n = "%s.%r" % (self.number, 1 + len(parts))
- part = SubMessage(self.folder, n, mf)
- parts.append(part)
- mf.pop()
- return parts
-
- def getbody(self):
- """Return body, either a string or a list of messages."""
- if self.getmaintype() == 'multipart':
- return self.getbodyparts()
- else:
- return self.getbodytext()
-
-
-class SubMessage(Message):
-
- def __init__(self, f, n, fp):
- """Constructor."""
- Message.__init__(self, f, n, fp)
- if self.getmaintype() == 'multipart':
- self.body = Message.getbodyparts(self)
- else:
- self.body = Message.getbodytext(self)
- self.bodyencoded = Message.getbodytext(self, decode=0)
- # XXX If this is big, should remember file pointers
-
- def __repr__(self):
- """String representation."""
- f, n, fp = self.folder, self.number, self.fp
- return 'SubMessage(%s, %s, %s)' % (f, n, fp)
-
- def getbodytext(self, decode = 1):
- if not decode:
- return self.bodyencoded
- if type(self.body) == type(''):
- return self.body
-
- def getbodyparts(self):
- if type(self.body) == type([]):
- return self.body
-
- def getbody(self):
- return self.body
-
-
-class IntSet:
- """Class implementing sets of integers.
-
- This is an efficient representation for sets consisting of several
- continuous ranges, e.g. 1-100,200-400,402-1000 is represented
- internally as a list of three pairs: [(1,100), (200,400),
- (402,1000)]. The internal representation is always kept normalized.
-
- The constructor has up to three arguments:
- - the string used to initialize the set (default ''),
- - the separator between ranges (default ',')
- - the separator between begin and end of a range (default '-')
- The separators must be strings (not regexprs) and should be different.
-
- The tostring() function yields a string that can be passed to another
- IntSet constructor; __repr__() is a valid IntSet constructor itself.
- """
-
- # XXX The default begin/end separator means that negative numbers are
- # not supported very well.
- #
- # XXX There are currently no operations to remove set elements.
-
- def __init__(self, data = None, sep = ',', rng = '-'):
- self.pairs = []
- self.sep = sep
- self.rng = rng
- if data: self.fromstring(data)
-
- def reset(self):
- self.pairs = []
-
- def __cmp__(self, other):
- return cmp(self.pairs, other.pairs)
-
- def __hash__(self):
- return hash(self.pairs)
-
- def __repr__(self):
- return 'IntSet(%r, %r, %r)' % (self.tostring(), self.sep, self.rng)
-
- def normalize(self):
- self.pairs.sort()
- i = 1
- while i < len(self.pairs):
- alo, ahi = self.pairs[i-1]
- blo, bhi = self.pairs[i]
- if ahi >= blo-1:
- self.pairs[i-1:i+1] = [(alo, max(ahi, bhi))]
- else:
- i = i+1
-
- def tostring(self):
- s = ''
- for lo, hi in self.pairs:
- if lo == hi: t = repr(lo)
- else: t = repr(lo) + self.rng + repr(hi)
- if s: s = s + (self.sep + t)
- else: s = t
- return s
-
- def tolist(self):
- l = []
- for lo, hi in self.pairs:
- m = range(lo, hi+1)
- l = l + m
- return l
-
- def fromlist(self, list):
- for i in list:
- self.append(i)
-
- def clone(self):
- new = IntSet()
- new.pairs = self.pairs[:]
- return new
-
- def min(self):
- return self.pairs[0][0]
-
- def max(self):
- return self.pairs[-1][-1]
-
- def contains(self, x):
- for lo, hi in self.pairs:
- if lo <= x <= hi: return True
- return False
-
- def append(self, x):
- for i in range(len(self.pairs)):
- lo, hi = self.pairs[i]
- if x < lo: # Need to insert before
- if x+1 == lo:
- self.pairs[i] = (x, hi)
- else:
- self.pairs.insert(i, (x, x))
- if i > 0 and x-1 == self.pairs[i-1][1]:
- # Merge with previous
- self.pairs[i-1:i+1] = [
- (self.pairs[i-1][0],
- self.pairs[i][1])
- ]
- return
- if x <= hi: # Already in set
- return
- i = len(self.pairs) - 1
- if i >= 0:
- lo, hi = self.pairs[i]
- if x-1 == hi:
- self.pairs[i] = lo, x
- return
- self.pairs.append((x, x))
-
- def addpair(self, xlo, xhi):
- if xlo > xhi: return
- self.pairs.append((xlo, xhi))
- self.normalize()
-
- def fromstring(self, data):
- new = []
- for part in data.split(self.sep):
- list = []
- for subp in part.split(self.rng):
- s = subp.strip()
- list.append(int(s))
- if len(list) == 1:
- new.append((list[0], list[0]))
- elif len(list) == 2 and list[0] <= list[1]:
- new.append((list[0], list[1]))
- else:
- raise ValueError, 'bad data passed to IntSet'
- self.pairs = self.pairs + new
- self.normalize()
-
-
-# Subroutines to read/write entries in .mh_profile and .mh_sequences
-
-def pickline(file, key, casefold = 1):
- try:
- f = open(file, 'r')
- except IOError:
- return None
- pat = re.escape(key) + ':'
- prog = re.compile(pat, casefold and re.IGNORECASE)
- while 1:
- line = f.readline()
- if not line: break
- if prog.match(line):
- text = line[len(key)+1:]
- while 1:
- line = f.readline()
- if not line or not line[0].isspace():
- break
- text = text + line
- return text.strip()
- return None
-
-def updateline(file, key, value, casefold = 1):
- try:
- f = open(file, 'r')
- lines = f.readlines()
- f.close()
- except IOError:
- lines = []
- pat = re.escape(key) + ':(.*)\n'
- prog = re.compile(pat, casefold and re.IGNORECASE)
- if value is None:
- newline = None
- else:
- newline = '%s: %s\n' % (key, value)
- for i in range(len(lines)):
- line = lines[i]
- if prog.match(line):
- if newline is None:
- del lines[i]
- else:
- lines[i] = newline
- break
- else:
- if newline is not None:
- lines.append(newline)
- tempfile = file + "~"
- f = open(tempfile, 'w')
- for line in lines:
- f.write(line)
- f.close()
- os.rename(tempfile, file)
-
-
-# Test program
-
-def test():
- global mh, f
- os.system('rm -rf $HOME/Mail/@test')
- mh = MH()
- def do(s): print s; print eval(s)
- do('mh.listfolders()')
- do('mh.listallfolders()')
- testfolders = ['@test', '@test/test1', '@test/test2',
- '@test/test1/test11', '@test/test1/test12',
- '@test/test1/test11/test111']
- for t in testfolders: do('mh.makefolder(%r)' % (t,))
- do('mh.listsubfolders(\'@test\')')
- do('mh.listallsubfolders(\'@test\')')
- f = mh.openfolder('@test')
- do('f.listsubfolders()')
- do('f.listallsubfolders()')
- do('f.getsequences()')
- seqs = f.getsequences()
- seqs['foo'] = IntSet('1-10 12-20', ' ').tolist()
- print seqs
- f.putsequences(seqs)
- do('f.getsequences()')
- for t in reversed(testfolders): do('mh.deletefolder(%r)' % (t,))
- do('mh.getcontext()')
- context = mh.getcontext()
- f = mh.openfolder(context)
- do('f.getcurrent()')
- for seq in ('first', 'last', 'cur', '.', 'prev', 'next',
- 'first:3', 'last:3', 'cur:3', 'cur:-3',
- 'prev:3', 'next:3',
- '1:3', '1:-3', '100:3', '100:-3', '10000:3', '10000:-3',
- 'all'):
- try:
- do('f.parsesequence(%r)' % (seq,))
- except Error, msg:
- print "Error:", msg
- stuff = os.popen("pick %r 2>/dev/null" % (seq,)).read()
- list = map(int, stuff.split())
- print list, "<-- pick"
- do('f.listmessages()')
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/mimetools.py b/Lib/mimetools.py
deleted file mode 100644
index 71ca8f8593f..00000000000
--- a/Lib/mimetools.py
+++ /dev/null
@@ -1,250 +0,0 @@
-"""Various tools used by MIME-reading or MIME-writing programs."""
-
-
-import os
-import sys
-import tempfile
-from warnings import filterwarnings, catch_warnings
-with catch_warnings():
- if sys.py3kwarning:
- filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning)
- import rfc822
-
-from warnings import warnpy3k
-warnpy3k("in 3.x, mimetools has been removed in favor of the email package",
- stacklevel=2)
-
-__all__ = ["Message","choose_boundary","encode","decode","copyliteral",
- "copybinary"]
-
-class Message(rfc822.Message):
- """A derived class of rfc822.Message that knows about MIME headers and
- contains some hooks for decoding encoded and multipart messages."""
-
- def __init__(self, fp, seekable = 1):
- rfc822.Message.__init__(self, fp, seekable)
- self.encodingheader = \
- self.getheader('content-transfer-encoding')
- self.typeheader = \
- self.getheader('content-type')
- self.parsetype()
- self.parseplist()
-
- def parsetype(self):
- str = self.typeheader
- if str is None:
- str = 'text/plain'
- if ';' in str:
- i = str.index(';')
- self.plisttext = str[i:]
- str = str[:i]
- else:
- self.plisttext = ''
- fields = str.split('/')
- for i in range(len(fields)):
- fields[i] = fields[i].strip().lower()
- self.type = '/'.join(fields)
- self.maintype = fields[0]
- self.subtype = '/'.join(fields[1:])
-
- def parseplist(self):
- str = self.plisttext
- self.plist = []
- while str[:1] == ';':
- str = str[1:]
- if ';' in str:
- # XXX Should parse quotes!
- end = str.index(';')
- else:
- end = len(str)
- f = str[:end]
- if '=' in f:
- i = f.index('=')
- f = f[:i].strip().lower() + \
- '=' + f[i+1:].strip()
- self.plist.append(f.strip())
- str = str[end:]
-
- def getplist(self):
- return self.plist
-
- def getparam(self, name):
- name = name.lower() + '='
- n = len(name)
- for p in self.plist:
- if p[:n] == name:
- return rfc822.unquote(p[n:])
- return None
-
- def getparamnames(self):
- result = []
- for p in self.plist:
- i = p.find('=')
- if i >= 0:
- result.append(p[:i].lower())
- return result
-
- def getencoding(self):
- if self.encodingheader is None:
- return '7bit'
- return self.encodingheader.lower()
-
- def gettype(self):
- return self.type
-
- def getmaintype(self):
- return self.maintype
-
- def getsubtype(self):
- return self.subtype
-
-
-
-
-# Utility functions
-# -----------------
-
-try:
- import thread
-except ImportError:
- import dummy_thread as thread
-_counter_lock = thread.allocate_lock()
-del thread
-
-_counter = 0
-def _get_next_counter():
- global _counter
- _counter_lock.acquire()
- _counter += 1
- result = _counter
- _counter_lock.release()
- return result
-
-_prefix = None
-
-def choose_boundary():
- """Return a string usable as a multipart boundary.
-
- The string chosen is unique within a single program run, and
- incorporates the user id (if available), process id (if available),
- and current time. So it's very unlikely the returned string appears
- in message text, but there's no guarantee.
-
- The boundary contains dots so you have to quote it in the header."""
-
- global _prefix
- import time
- if _prefix is None:
- import socket
- try:
- hostid = socket.gethostbyname(socket.gethostname())
- except socket.gaierror:
- hostid = '127.0.0.1'
- try:
- uid = repr(os.getuid())
- except AttributeError:
- uid = '1'
- try:
- pid = repr(os.getpid())
- except AttributeError:
- pid = '1'
- _prefix = hostid + '.' + uid + '.' + pid
- return "%s.%.3f.%d" % (_prefix, time.time(), _get_next_counter())
-
-
-# Subroutines for decoding some common content-transfer-types
-
-def decode(input, output, encoding):
- """Decode common content-transfer-encodings (base64, quopri, uuencode)."""
- if encoding == 'base64':
- import base64
- return base64.decode(input, output)
- if encoding == 'quoted-printable':
- import quopri
- return quopri.decode(input, output)
- if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'):
- import uu
- return uu.decode(input, output)
- if encoding in ('7bit', '8bit'):
- return output.write(input.read())
- if encoding in decodetab:
- pipethrough(input, decodetab[encoding], output)
- else:
- raise ValueError, \
- 'unknown Content-Transfer-Encoding: %s' % encoding
-
-def encode(input, output, encoding):
- """Encode common content-transfer-encodings (base64, quopri, uuencode)."""
- if encoding == 'base64':
- import base64
- return base64.encode(input, output)
- if encoding == 'quoted-printable':
- import quopri
- return quopri.encode(input, output, 0)
- if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'):
- import uu
- return uu.encode(input, output)
- if encoding in ('7bit', '8bit'):
- return output.write(input.read())
- if encoding in encodetab:
- pipethrough(input, encodetab[encoding], output)
- else:
- raise ValueError, \
- 'unknown Content-Transfer-Encoding: %s' % encoding
-
-# The following is no longer used for standard encodings
-
-# XXX This requires that uudecode and mmencode are in $PATH
-
-uudecode_pipe = '''(
-TEMP=/tmp/@uu.$$
-sed "s%^begin [0-7][0-7]* .*%begin 600 $TEMP%" | uudecode
-cat $TEMP
-rm $TEMP
-)'''
-
-decodetab = {
- 'uuencode': uudecode_pipe,
- 'x-uuencode': uudecode_pipe,
- 'uue': uudecode_pipe,
- 'x-uue': uudecode_pipe,
- 'quoted-printable': 'mmencode -u -q',
- 'base64': 'mmencode -u -b',
-}
-
-encodetab = {
- 'x-uuencode': 'uuencode tempfile',
- 'uuencode': 'uuencode tempfile',
- 'x-uue': 'uuencode tempfile',
- 'uue': 'uuencode tempfile',
- 'quoted-printable': 'mmencode -q',
- 'base64': 'mmencode -b',
-}
-
-def pipeto(input, command):
- pipe = os.popen(command, 'w')
- copyliteral(input, pipe)
- pipe.close()
-
-def pipethrough(input, command, output):
- (fd, tempname) = tempfile.mkstemp()
- temp = os.fdopen(fd, 'w')
- copyliteral(input, temp)
- temp.close()
- pipe = os.popen(command + ' <' + tempname, 'r')
- copybinary(pipe, output)
- pipe.close()
- os.unlink(tempname)
-
-def copyliteral(input, output):
- while 1:
- line = input.readline()
- if not line: break
- output.write(line)
-
-def copybinary(input, output):
- BUFSIZE = 8192
- while 1:
- line = input.read(BUFSIZE)
- if not line: break
- output.write(line)
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index ba4ea8257b6..8ce02f9200b 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -2,9 +2,9 @@
This module defines two useful functions:
-guess_type(url, strict=1) -- guess the MIME type and encoding of a URL.
+guess_type(url, strict=True) -- guess the MIME type and encoding of a URL.
-guess_extension(type, strict=1) -- guess the extension for a given MIME type.
+guess_extension(type, strict=True) -- guess the extension for a given MIME type.
It also contains the following, for tuning the behavior:
@@ -26,9 +26,9 @@ read_mime_types(file) -- parse one file, return a dictionary or None
import os
import sys
import posixpath
-import urllib
+import urllib.parse
try:
- import _winreg
+ import winreg as _winreg
except ImportError:
_winreg = None
@@ -111,7 +111,7 @@ class MimeTypes:
Optional `strict' argument when False adds a bunch of commonly found,
but non-standard types.
"""
- scheme, url = urllib.splittype(url)
+ scheme, url = urllib.parse.splittype(url)
if scheme == 'data':
# syntax of data URLs:
# dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
@@ -199,7 +199,7 @@ class MimeTypes:
list of standard types, else to the list of non-standard
types.
"""
- with open(filename) as fp:
+ with open(filename, encoding='utf-8') as fp:
self.readfp(fp, strict)
def readfp(self, fp, strict=True):
@@ -245,10 +245,6 @@ class MimeTypes:
ctype = _winreg.EnumKey(mimedb, i)
except EnvironmentError:
break
- try:
- ctype = ctype.encode(default_encoding) # omit in 3.x!
- except UnicodeEncodeError:
- pass
else:
yield ctype
i += 1
@@ -265,10 +261,6 @@ class MimeTypes:
continue
if datatype != _winreg.REG_SZ:
continue
- try:
- suffix = suffix.encode(default_encoding) # omit in 3.x!
- except UnicodeEncodeError:
- continue
self.add_type(ctype, suffix, strict)
@@ -382,6 +374,7 @@ def _default_mime_types():
global common_types
suffix_map = {
+ '.svgz': '.svg.gz',
'.tgz': '.tar.gz',
'.taz': '.tar.gz',
'.tz': '.tar.gz',
@@ -395,7 +388,7 @@ def _default_mime_types():
}
# Before adding new types, make sure they are either registered with IANA,
- # at http://www.isi.edu/in-notes/iana/assignments/media-types
+ # at http://www.iana.org/assignments/media-types
# or extensions, i.e. using the x- prefix
# If you add to these, please keep them sorted!
@@ -497,6 +490,7 @@ def _default_mime_types():
'.src' : 'application/x-wais-source',
'.sv4cpio': 'application/x-sv4cpio',
'.sv4crc' : 'application/x-sv4crc',
+ '.svg' : 'image/svg+xml',
'.swf' : 'application/x-shockwave-flash',
'.t' : 'application/x-troff',
'.tar' : 'application/x-tar',
@@ -562,14 +556,14 @@ More than one type argument may be given.
"""
def usage(code, msg=''):
- print USAGE
- if msg: print msg
+ print(USAGE)
+ if msg: print(msg)
sys.exit(code)
try:
opts, args = getopt.getopt(sys.argv[1:], 'hle',
['help', 'lenient', 'extension'])
- except getopt.error, msg:
+ except getopt.error as msg:
usage(1, msg)
strict = 1
@@ -584,9 +578,9 @@ More than one type argument may be given.
for gtype in args:
if extension:
guess = guess_extension(gtype, strict)
- if not guess: print "I don't know anything about type", gtype
- else: print guess
+ if not guess: print("I don't know anything about type", gtype)
+ else: print(guess)
else:
guess, encoding = guess_type(gtype, strict)
- if not guess: print "I don't know anything about type", gtype
- else: print 'type:', guess, 'encoding:', encoding
+ if not guess: print("I don't know anything about type", gtype)
+ else: print('type:', guess, 'encoding:', encoding)
diff --git a/Lib/mimify.py b/Lib/mimify.py
deleted file mode 100755
index 1c15983d1e2..00000000000
--- a/Lib/mimify.py
+++ /dev/null
@@ -1,468 +0,0 @@
-#! /usr/bin/env python
-
-"""Mimification and unmimification of mail messages.
-
-Decode quoted-printable parts of a mail message or encode using
-quoted-printable.
-
-Usage:
- mimify(input, output)
- unmimify(input, output, decode_base64 = 0)
-to encode and decode respectively. Input and output may be the name
-of a file or an open file object. Only a readline() method is used
-on the input file, only a write() method is used on the output file.
-When using file names, the input and output file names may be the
-same.
-
-Interactive usage:
- mimify.py -e [infile [outfile]]
- mimify.py -d [infile [outfile]]
-to encode and decode respectively. Infile defaults to standard
-input and outfile to standard output.
-"""
-
-# Configure
-MAXLEN = 200 # if lines longer than this, encode as quoted-printable
-CHARSET = 'ISO-8859-1' # default charset for non-US-ASCII mail
-QUOTE = '> ' # string replies are quoted with
-# End configure
-
-import re
-
-import warnings
-warnings.warn("the mimify module is deprecated; use the email package instead",
- DeprecationWarning, 2)
-
-__all__ = ["mimify","unmimify","mime_encode_header","mime_decode_header"]
-
-qp = re.compile('^content-transfer-encoding:\\s*quoted-printable', re.I)
-base64_re = re.compile('^content-transfer-encoding:\\s*base64', re.I)
-mp = re.compile('^content-type:.*multipart/.*boundary="?([^;"\n]*)', re.I|re.S)
-chrset = re.compile('^(content-type:.*charset=")(us-ascii|iso-8859-[0-9]+)(".*)', re.I|re.S)
-he = re.compile('^-*\n')
-mime_code = re.compile('=([0-9a-f][0-9a-f])', re.I)
-mime_head = re.compile('=\\?iso-8859-1\\?q\\?([^? \t\n]+)\\?=', re.I)
-repl = re.compile('^subject:\\s+re: ', re.I)
-
-class File:
- """A simple fake file object that knows about limited read-ahead and
- boundaries. The only supported method is readline()."""
-
- def __init__(self, file, boundary):
- self.file = file
- self.boundary = boundary
- self.peek = None
-
- def readline(self):
- if self.peek is not None:
- return ''
- line = self.file.readline()
- if not line:
- return line
- if self.boundary:
- if line == self.boundary + '\n':
- self.peek = line
- return ''
- if line == self.boundary + '--\n':
- self.peek = line
- return ''
- return line
-
-class HeaderFile:
- def __init__(self, file):
- self.file = file
- self.peek = None
-
- def readline(self):
- if self.peek is not None:
- line = self.peek
- self.peek = None
- else:
- line = self.file.readline()
- if not line:
- return line
- if he.match(line):
- return line
- while 1:
- self.peek = self.file.readline()
- if len(self.peek) == 0 or \
- (self.peek[0] != ' ' and self.peek[0] != '\t'):
- return line
- line = line + self.peek
- self.peek = None
-
-def mime_decode(line):
- """Decode a single line of quoted-printable text to 8bit."""
- newline = ''
- pos = 0
- while 1:
- res = mime_code.search(line, pos)
- if res is None:
- break
- newline = newline + line[pos:res.start(0)] + \
- chr(int(res.group(1), 16))
- pos = res.end(0)
- return newline + line[pos:]
-
-def mime_decode_header(line):
- """Decode a header line to 8bit."""
- newline = ''
- pos = 0
- while 1:
- res = mime_head.search(line, pos)
- if res is None:
- break
- match = res.group(1)
- # convert underscores to spaces (before =XX conversion!)
- match = ' '.join(match.split('_'))
- newline = newline + line[pos:res.start(0)] + mime_decode(match)
- pos = res.end(0)
- return newline + line[pos:]
-
-def unmimify_part(ifile, ofile, decode_base64 = 0):
- """Convert a quoted-printable part of a MIME mail message to 8bit."""
- multipart = None
- quoted_printable = 0
- is_base64 = 0
- is_repl = 0
- if ifile.boundary and ifile.boundary[:2] == QUOTE:
- prefix = QUOTE
- else:
- prefix = ''
-
- # read header
- hfile = HeaderFile(ifile)
- while 1:
- line = hfile.readline()
- if not line:
- return
- if prefix and line[:len(prefix)] == prefix:
- line = line[len(prefix):]
- pref = prefix
- else:
- pref = ''
- line = mime_decode_header(line)
- if qp.match(line):
- quoted_printable = 1
- continue # skip this header
- if decode_base64 and base64_re.match(line):
- is_base64 = 1
- continue
- ofile.write(pref + line)
- if not prefix and repl.match(line):
- # we're dealing with a reply message
- is_repl = 1
- mp_res = mp.match(line)
- if mp_res:
- multipart = '--' + mp_res.group(1)
- if he.match(line):
- break
- if is_repl and (quoted_printable or multipart):
- is_repl = 0
-
- # read body
- while 1:
- line = ifile.readline()
- if not line:
- return
- line = re.sub(mime_head, '\\1', line)
- if prefix and line[:len(prefix)] == prefix:
- line = line[len(prefix):]
- pref = prefix
- else:
- pref = ''
-## if is_repl and len(line) >= 4 and line[:4] == QUOTE+'--' and line[-3:] != '--\n':
-## multipart = line[:-1]
- while multipart:
- if line == multipart + '--\n':
- ofile.write(pref + line)
- multipart = None
- line = None
- break
- if line == multipart + '\n':
- ofile.write(pref + line)
- nifile = File(ifile, multipart)
- unmimify_part(nifile, ofile, decode_base64)
- line = nifile.peek
- if not line:
- # premature end of file
- break
- continue
- # not a boundary between parts
- break
- if line and quoted_printable:
- while line[-2:] == '=\n':
- line = line[:-2]
- newline = ifile.readline()
- if newline[:len(QUOTE)] == QUOTE:
- newline = newline[len(QUOTE):]
- line = line + newline
- line = mime_decode(line)
- if line and is_base64 and not pref:
- import base64
- line = base64.decodestring(line)
- if line:
- ofile.write(pref + line)
-
-def unmimify(infile, outfile, decode_base64 = 0):
- """Convert quoted-printable parts of a MIME mail message to 8bit."""
- if type(infile) == type(''):
- ifile = open(infile)
- if type(outfile) == type('') and infile == outfile:
- import os
- d, f = os.path.split(infile)
- os.rename(infile, os.path.join(d, ',' + f))
- else:
- ifile = infile
- if type(outfile) == type(''):
- ofile = open(outfile, 'w')
- else:
- ofile = outfile
- nifile = File(ifile, None)
- unmimify_part(nifile, ofile, decode_base64)
- ofile.flush()
-
-mime_char = re.compile('[=\177-\377]') # quote these chars in body
-mime_header_char = re.compile('[=?\177-\377]') # quote these in header
-
-def mime_encode(line, header):
- """Code a single line as quoted-printable.
- If header is set, quote some extra characters."""
- if header:
- reg = mime_header_char
- else:
- reg = mime_char
- newline = ''
- pos = 0
- if len(line) >= 5 and line[:5] == 'From ':
- # quote 'From ' at the start of a line for stupid mailers
- newline = ('=%02x' % ord('F')).upper()
- pos = 1
- while 1:
- res = reg.search(line, pos)
- if res is None:
- break
- newline = newline + line[pos:res.start(0)] + \
- ('=%02x' % ord(res.group(0))).upper()
- pos = res.end(0)
- line = newline + line[pos:]
-
- newline = ''
- while len(line) >= 75:
- i = 73
- while line[i] == '=' or line[i-1] == '=':
- i = i - 1
- i = i + 1
- newline = newline + line[:i] + '=\n'
- line = line[i:]
- return newline + line
-
-mime_header = re.compile('([ \t(]|^)([-a-zA-Z0-9_+]*[\177-\377][-a-zA-Z0-9_+\177-\377]*)(?=[ \t)]|\n)')
-
-def mime_encode_header(line):
- """Code a single header line as quoted-printable."""
- newline = ''
- pos = 0
- while 1:
- res = mime_header.search(line, pos)
- if res is None:
- break
- newline = '%s%s%s=?%s?Q?%s?=' % \
- (newline, line[pos:res.start(0)], res.group(1),
- CHARSET, mime_encode(res.group(2), 1))
- pos = res.end(0)
- return newline + line[pos:]
-
-mv = re.compile('^mime-version:', re.I)
-cte = re.compile('^content-transfer-encoding:', re.I)
-iso_char = re.compile('[\177-\377]')
-
-def mimify_part(ifile, ofile, is_mime):
- """Convert an 8bit part of a MIME mail message to quoted-printable."""
- has_cte = is_qp = is_base64 = 0
- multipart = None
- must_quote_body = must_quote_header = has_iso_chars = 0
-
- header = []
- header_end = ''
- message = []
- message_end = ''
- # read header
- hfile = HeaderFile(ifile)
- while 1:
- line = hfile.readline()
- if not line:
- break
- if not must_quote_header and iso_char.search(line):
- must_quote_header = 1
- if mv.match(line):
- is_mime = 1
- if cte.match(line):
- has_cte = 1
- if qp.match(line):
- is_qp = 1
- elif base64_re.match(line):
- is_base64 = 1
- mp_res = mp.match(line)
- if mp_res:
- multipart = '--' + mp_res.group(1)
- if he.match(line):
- header_end = line
- break
- header.append(line)
-
- # read body
- while 1:
- line = ifile.readline()
- if not line:
- break
- if multipart:
- if line == multipart + '--\n':
- message_end = line
- break
- if line == multipart + '\n':
- message_end = line
- break
- if is_base64:
- message.append(line)
- continue
- if is_qp:
- while line[-2:] == '=\n':
- line = line[:-2]
- newline = ifile.readline()
- if newline[:len(QUOTE)] == QUOTE:
- newline = newline[len(QUOTE):]
- line = line + newline
- line = mime_decode(line)
- message.append(line)
- if not has_iso_chars:
- if iso_char.search(line):
- has_iso_chars = must_quote_body = 1
- if not must_quote_body:
- if len(line) > MAXLEN:
- must_quote_body = 1
-
- # convert and output header and body
- for line in header:
- if must_quote_header:
- line = mime_encode_header(line)
- chrset_res = chrset.match(line)
- if chrset_res:
- if has_iso_chars:
- # change us-ascii into iso-8859-1
- if chrset_res.group(2).lower() == 'us-ascii':
- line = '%s%s%s' % (chrset_res.group(1),
- CHARSET,
- chrset_res.group(3))
- else:
- # change iso-8859-* into us-ascii
- line = '%sus-ascii%s' % chrset_res.group(1, 3)
- if has_cte and cte.match(line):
- line = 'Content-Transfer-Encoding: '
- if is_base64:
- line = line + 'base64\n'
- elif must_quote_body:
- line = line + 'quoted-printable\n'
- else:
- line = line + '7bit\n'
- ofile.write(line)
- if (must_quote_header or must_quote_body) and not is_mime:
- ofile.write('Mime-Version: 1.0\n')
- ofile.write('Content-Type: text/plain; ')
- if has_iso_chars:
- ofile.write('charset="%s"\n' % CHARSET)
- else:
- ofile.write('charset="us-ascii"\n')
- if must_quote_body and not has_cte:
- ofile.write('Content-Transfer-Encoding: quoted-printable\n')
- ofile.write(header_end)
-
- for line in message:
- if must_quote_body:
- line = mime_encode(line, 0)
- ofile.write(line)
- ofile.write(message_end)
-
- line = message_end
- while multipart:
- if line == multipart + '--\n':
- # read bit after the end of the last part
- while 1:
- line = ifile.readline()
- if not line:
- return
- if must_quote_body:
- line = mime_encode(line, 0)
- ofile.write(line)
- if line == multipart + '\n':
- nifile = File(ifile, multipart)
- mimify_part(nifile, ofile, 1)
- line = nifile.peek
- if not line:
- # premature end of file
- break
- ofile.write(line)
- continue
- # unexpectedly no multipart separator--copy rest of file
- while 1:
- line = ifile.readline()
- if not line:
- return
- if must_quote_body:
- line = mime_encode(line, 0)
- ofile.write(line)
-
-def mimify(infile, outfile):
- """Convert 8bit parts of a MIME mail message to quoted-printable."""
- if type(infile) == type(''):
- ifile = open(infile)
- if type(outfile) == type('') and infile == outfile:
- import os
- d, f = os.path.split(infile)
- os.rename(infile, os.path.join(d, ',' + f))
- else:
- ifile = infile
- if type(outfile) == type(''):
- ofile = open(outfile, 'w')
- else:
- ofile = outfile
- nifile = File(ifile, None)
- mimify_part(nifile, ofile, 0)
- ofile.flush()
-
-import sys
-if __name__ == '__main__' or (len(sys.argv) > 0 and sys.argv[0] == 'mimify'):
- import getopt
- usage = 'Usage: mimify [-l len] -[ed] [infile [outfile]]'
-
- decode_base64 = 0
- opts, args = getopt.getopt(sys.argv[1:], 'l:edb')
- if len(args) not in (0, 1, 2):
- print usage
- sys.exit(1)
- if (('-e', '') in opts) == (('-d', '') in opts) or \
- ((('-b', '') in opts) and (('-d', '') not in opts)):
- print usage
- sys.exit(1)
- for o, a in opts:
- if o == '-e':
- encode = mimify
- elif o == '-d':
- encode = unmimify
- elif o == '-l':
- try:
- MAXLEN = int(a)
- except (ValueError, OverflowError):
- print usage
- sys.exit(1)
- elif o == '-b':
- decode_base64 = 1
- if len(args) == 0:
- encode_args = (sys.stdin, sys.stdout)
- elif len(args) == 1:
- encode_args = (args[0], sys.stdout)
- else:
- encode_args = (args[0], args[1])
- if decode_base64:
- encode_args = encode_args + (decode_base64,)
- encode(*encode_args)
diff --git a/Lib/modulefinder.py b/Lib/modulefinder.py
index 7f2bf8b1588..f033ba98efb 100644
--- a/Lib/modulefinder.py
+++ b/Lib/modulefinder.py
@@ -1,5 +1,4 @@
"""Find modules used by a script, using introspection."""
-# This module should be kept compatible with Python 2.2, see PEP 291.
from __future__ import generators
import dis
@@ -10,18 +9,15 @@ import sys
import types
import struct
-if hasattr(sys.__stdout__, "newlines"):
- READ_MODE = "U" # universal line endings
-else:
- # remain compatible with Python < 2.3
- READ_MODE = "r"
+READ_MODE = "rU"
-LOAD_CONST = chr(dis.opname.index('LOAD_CONST'))
-IMPORT_NAME = chr(dis.opname.index('IMPORT_NAME'))
-STORE_NAME = chr(dis.opname.index('STORE_NAME'))
-STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL'))
+# XXX Clean up once str8's cstor matches bytes.
+LOAD_CONST = bytes([dis.opname.index('LOAD_CONST')])
+IMPORT_NAME = bytes([dis.opname.index('IMPORT_NAME')])
+STORE_NAME = bytes([dis.opname.index('STORE_NAME')])
+STORE_GLOBAL = bytes([dis.opname.index('STORE_GLOBAL')])
STORE_OPS = [STORE_NAME, STORE_GLOBAL]
-HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT)
+HAVE_ARGUMENT = bytes([dis.HAVE_ARGUMENT])
# Modulefinder does a good job at simulating Python's, but it can not
# handle __path__ modifications packages make at runtime. Therefore there
@@ -39,9 +35,10 @@ def AddPackagePath(packagename, path):
replacePackageMap = {}
-# This ReplacePackage mechanism allows modulefinder to work around the
-# way the _xmlplus package injects itself under the name "xml" into
-# sys.modules at runtime by calling ReplacePackage("_xmlplus", "xml")
+# This ReplacePackage mechanism allows modulefinder to work around
+# situations in which a package injects itself under the name
+# of another package into sys.modules at runtime by calling
+# ReplacePackage("real_package_name", "faked_package_name")
# before running ModuleFinder.
def ReplacePackage(oldname, newname):
@@ -89,11 +86,11 @@ class ModuleFinder:
def msg(self, level, str, *args):
if level <= self.debug:
for i in range(self.indent):
- print " ",
- print str,
+ print(" ", end=' ')
+ print(str, end=' ')
for arg in args:
- print repr(arg),
- print
+ print(repr(arg), end=' ')
+ print()
def msgin(self, *args):
level = args[0]
@@ -109,16 +106,16 @@ class ModuleFinder:
def run_script(self, pathname):
self.msg(2, "run_script", pathname)
- fp = open(pathname, READ_MODE)
- stuff = ("", "r", imp.PY_SOURCE)
- self.load_module('__main__', fp, pathname, stuff)
+ with open(pathname, READ_MODE) as fp:
+ stuff = ("", "r", imp.PY_SOURCE)
+ self.load_module('__main__', fp, pathname, stuff)
def load_file(self, pathname):
dir, name = os.path.split(pathname)
name, ext = os.path.splitext(name)
- fp = open(pathname, READ_MODE)
- stuff = (ext, "r", imp.PY_SOURCE)
- self.load_module(name, fp, pathname, stuff)
+ with open(pathname, READ_MODE) as fp:
+ stuff = (ext, "r", imp.PY_SOURCE)
+ self.load_module(name, fp, pathname, stuff)
def import_hook(self, name, caller=None, fromlist=None, level=-1):
self.msg(3, "import_hook", name, caller, fromlist, level)
@@ -146,7 +143,7 @@ class ModuleFinder:
self.msgout(4, "determine_parent ->", parent)
return parent
if pname.count(".") < level:
- raise ImportError, "relative importpath too deep"
+ raise ImportError("relative importpath too deep")
pname = ".".join(pname.split(".")[:-level])
parent = self.modules[pname]
self.msgout(4, "determine_parent ->", parent)
@@ -191,7 +188,7 @@ class ModuleFinder:
self.msgout(4, "find_head_package ->", (q, tail))
return q, tail
self.msgout(4, "raise ImportError: No module named", qname)
- raise ImportError, "No module named " + qname
+ raise ImportError("No module named " + qname)
def load_tail(self, q, tail):
self.msgin(4, "load_tail", q, tail)
@@ -204,7 +201,7 @@ class ModuleFinder:
m = self.import_module(head, mname, m)
if not m:
self.msgout(4, "raise ImportError: No module named", mname)
- raise ImportError, "No module named " + mname
+ raise ImportError("No module named " + mname)
self.msgout(4, "load_tail ->", m)
return m
@@ -220,7 +217,7 @@ class ModuleFinder:
subname = "%s.%s" % (m.__name__, sub)
submod = self.import_module(sub, subname, m)
if not submod:
- raise ImportError, "No module named " + subname
+ raise ImportError("No module named " + subname)
def find_all_submodules(self, m):
if not m.__path__:
@@ -291,7 +288,7 @@ class ModuleFinder:
elif type == imp.PY_COMPILED:
if fp.read(4) != imp.get_magic():
self.msgout(2, "raise ImportError: Bad magic number", pathname)
- raise ImportError, "Bad magic number in %s" % pathname
+ raise ImportError("Bad magic number in %s" % pathname)
fp.read(4)
co = marshal.load(fp)
else:
@@ -321,7 +318,7 @@ class ModuleFinder:
return
try:
self.import_hook(name, caller, level=level)
- except ImportError, msg:
+ except ImportError as msg:
self.msg(2, "ImportError:", str(msg))
self._add_badmodule(name, caller)
else:
@@ -332,7 +329,7 @@ class ModuleFinder:
continue
try:
self.import_hook(name, caller, [sub], level=level)
- except ImportError, msg:
+ except ImportError as msg:
self.msg(2, "ImportError:", str(msg))
fullname = name + "." + sub
self._add_badmodule(fullname, caller)
@@ -370,7 +367,7 @@ class ModuleFinder:
consts = co.co_consts
LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME
while code:
- c = code[0]
+ c = bytes([code[0]])
if c in STORE_OPS:
oparg, = unpack('<H', code[1:3])
yield "store", (names[oparg],)
@@ -379,9 +376,7 @@ class ModuleFinder:
if code[:9:3] == LOAD_LOAD_AND_IMPORT:
oparg_1, oparg_2, oparg_3 = unpack('<xHxHxH', code[:9])
level = consts[oparg_1]
- if level == -1: # normal import
- yield "import", (consts[oparg_2], names[oparg_3])
- elif level == 0: # absolute import
+ if level == 0: # absolute import
yield "absolute_import", (consts[oparg_2], names[oparg_3])
else: # relative import
yield "relative_import", (level, consts[oparg_2], names[oparg_3])
@@ -402,16 +397,14 @@ class ModuleFinder:
if what == "store":
name, = args
m.globalnames[name] = 1
- elif what in ("import", "absolute_import"):
+ elif what == "absolute_import":
fromlist, name = args
have_star = 0
if fromlist is not None:
if "*" in fromlist:
have_star = 1
fromlist = [f for f in fromlist if f != "*"]
- if what == "absolute_import": level = 0
- else: level = -1
- self._safe_import_hook(name, m, fromlist, level=level)
+ self._safe_import_hook(name, m, fromlist, level=0)
if have_star:
# We've encountered an "import *". If it is a Python module,
# the code has already been parsed and we can suck out the
@@ -459,9 +452,13 @@ class ModuleFinder:
m.__path__ = m.__path__ + packagePathMap.get(fqname, [])
fp, buf, stuff = self.find_module("__init__", m.__path__)
- self.load_module(fqname, fp, buf, stuff)
- self.msgout(2, "load_package ->", m)
- return m
+ try:
+ self.load_module(fqname, fp, buf, stuff)
+ self.msgout(2, "load_package ->", m)
+ return m
+ finally:
+ if fp:
+ fp.close()
def add_module(self, fqname):
if fqname in self.modules:
@@ -477,7 +474,7 @@ class ModuleFinder:
fullname = name
if fullname in self.excludes:
self.msgout(3, "find_module -> Excluded", fullname)
- raise ImportError, name
+ raise ImportError(name)
if path is None:
if name in sys.builtin_module_names:
@@ -490,38 +487,35 @@ class ModuleFinder:
"""Print a report to stdout, listing the found modules with their
paths, as well as modules that are missing, or seem to be missing.
"""
- print
- print " %-25s %s" % ("Name", "File")
- print " %-25s %s" % ("----", "----")
+ print()
+ print(" %-25s %s" % ("Name", "File"))
+ print(" %-25s %s" % ("----", "----"))
# Print modules found
- keys = self.modules.keys()
- keys.sort()
+ keys = sorted(self.modules.keys())
for key in keys:
m = self.modules[key]
if m.__path__:
- print "P",
+ print("P", end=' ')
else:
- print "m",
- print "%-25s" % key, m.__file__ or ""
+ print("m", end=' ')
+ print("%-25s" % key, m.__file__ or "")
# Print missing modules
missing, maybe = self.any_missing_maybe()
if missing:
- print
- print "Missing modules:"
+ print()
+ print("Missing modules:")
for name in missing:
- mods = self.badmodules[name].keys()
- mods.sort()
- print "?", name, "imported from", ', '.join(mods)
+ mods = sorted(self.badmodules[name].keys())
+ print("?", name, "imported from", ', '.join(mods))
# Print modules that may be missing, but then again, maybe not...
if maybe:
- print
- print "Submodules thay appear to be missing, but could also be",
- print "global names in the parent package:"
+ print()
+ print("Submodules thay appear to be missing, but could also be", end=' ')
+ print("global names in the parent package:")
for name in maybe:
- mods = self.badmodules[name].keys()
- mods.sort()
- print "?", name, "imported from", ', '.join(mods)
+ mods = sorted(self.badmodules[name].keys())
+ print("?", name, "imported from", ', '.join(mods))
def any_missing(self):
"""Return a list of modules that appear to be missing. Use
@@ -610,8 +604,8 @@ def test():
import getopt
try:
opts, args = getopt.getopt(sys.argv[1:], "dmp:qx:")
- except getopt.error, msg:
- print msg
+ except getopt.error as msg:
+ print(msg)
return
# Process options
@@ -642,9 +636,9 @@ def test():
path[0] = os.path.dirname(script)
path = addpath + path
if debug > 1:
- print "path:"
+ print("path:")
for item in path:
- print " ", repr(item)
+ print(" ", repr(item))
# Create the module finder and turn its crank
mf = ModuleFinder(path, debug, exclude)
@@ -668,4 +662,4 @@ if __name__ == '__main__':
try:
mf = test()
except KeyboardInterrupt:
- print "\n[interrupt]"
+ print("\n[interrupt]")
diff --git a/Lib/msilib/__init__.py b/Lib/msilib/__init__.py
index 63f392359b8..6eff89c54b1 100644
--- a/Lib/msilib/__init__.py
+++ b/Lib/msilib/__init__.py
@@ -1,5 +1,4 @@
-# -*- coding: iso-8859-1 -*-
-# Copyright (C) 2005 Martin v. Löwis
+# Copyright (C) 2005 Martin v. Löwis
# Licensed to PSF under a Contributor Agreement.
from _msi import *
import os, string, re, sys
@@ -42,7 +41,7 @@ class Table:
index -= 1
unk = type & ~knownbits
if unk:
- print "%s.%s unknown bits %x" % (self.name, name, unk)
+ print("%s.%s unknown bits %x" % (self.name, name, unk))
size = type & datasizemask
dtype = type & typemask
if dtype == type_string:
@@ -61,7 +60,7 @@ class Table:
tname="OBJECT"
else:
tname="unknown"
- print "%s.%sunknown integer type %d" % (self.name, name, size)
+ print("%s.%sunknown integer type %d" % (self.name, name, size))
if type & type_nullable:
flags = ""
else:
@@ -91,7 +90,7 @@ def change_sequence(seq, action, seqno=_Unspecified, cond = _Unspecified):
seqno = seq[i][2]
seq[i] = (action, cond, seqno)
return
- raise ValueError, "Action not found in sequence"
+ raise ValueError("Action not found in sequence")
def add_data(db, table, values):
v = db.OpenView("SELECT * FROM `%s`" % table)
@@ -101,19 +100,19 @@ def add_data(db, table, values):
assert len(value) == count, value
for i in range(count):
field = value[i]
- if isinstance(field, (int, long)):
+ if isinstance(field, int):
r.SetInteger(i+1,field)
- elif isinstance(field, basestring):
+ elif isinstance(field, str):
r.SetString(i+1,field)
elif field is None:
pass
elif isinstance(field, Binary):
r.SetStream(i+1, field.name)
else:
- raise TypeError, "Unsupported type %s" % field.__class__.__name__
+ raise TypeError("Unsupported type %s" % field.__class__.__name__)
try:
v.Modify(MSIMODIFY_INSERT, r)
- except Exception, e:
+ except Exception as e:
raise MSIError("Could not insert "+repr(values)+" into "+table)
r.ClearData()
diff --git a/Lib/msilib/schema.py b/Lib/msilib/schema.py
index 003f04071c5..a9e167918a0 100644
--- a/Lib/msilib/schema.py
+++ b/Lib/msilib/schema.py
@@ -580,428 +580,428 @@ Verb.add_field(5,'Argument',8191)
tables=[_Validation, ActionText, AdminExecuteSequence, Condition, AdminUISequence, AdvtExecuteSequence, AdvtUISequence, AppId, AppSearch, Property, BBControl, Billboard, Feature, Binary, BindImage, File, CCPSearch, CheckBox, Class, Component, Icon, ProgId, ComboBox, CompLocator, Complus, Directory, Control, Dialog, ControlCondition, ControlEvent, CreateFolder, CustomAction, DrLocator, DuplicateFile, Environment, Error, EventMapping, Extension, MIME, FeatureComponents, FileSFPCatalog, SFPCatalog, Font, IniFile, IniLocator, InstallExecuteSequence, InstallUISequence, IsolatedComponent, LaunchCondition, ListBox, ListView, LockPermissions, Media, MoveFile, MsiAssembly, MsiAssemblyName, MsiDigitalCertificate, MsiDigitalSignature, MsiFileHash, MsiPatchHeaders, ODBCAttribute, ODBCDriver, ODBCDataSource, ODBCSourceAttribute, ODBCTranslator, Patch, PatchPackage, PublishComponent, RadioButton, Registry, RegLocator, RemoveFile, RemoveIniFile, RemoveRegistry, ReserveCost, SelfReg, ServiceControl, ServiceInstall, Shortcut, Signature, TextStyle, TypeLib, UIText, Upgrade, Verb]
_Validation_records = [
-(u'_Validation',u'Table',u'N',None, None, None, None, u'Identifier',None, u'Name of table',),
-(u'_Validation',u'Column',u'N',None, None, None, None, u'Identifier',None, u'Name of column',),
-(u'_Validation',u'Description',u'Y',None, None, None, None, u'Text',None, u'Description of column',),
-(u'_Validation',u'Set',u'Y',None, None, None, None, u'Text',None, u'Set of values that are permitted',),
-(u'_Validation',u'Category',u'Y',None, None, None, None, None, u'Text;Formatted;Template;Condition;Guid;Path;Version;Language;Identifier;Binary;UpperCase;LowerCase;Filename;Paths;AnyPath;WildCardFilename;RegPath;KeyFormatted;CustomSource;Property;Cabinet;Shortcut;URL',u'String category',),
-(u'_Validation',u'KeyColumn',u'Y',1,32,None, None, None, None, u'Column to which foreign key connects',),
-(u'_Validation',u'KeyTable',u'Y',None, None, None, None, u'Identifier',None, u'For foreign key, Name of table to which data must link',),
-(u'_Validation',u'MaxValue',u'Y',-2147483647,2147483647,None, None, None, None, u'Maximum value allowed',),
-(u'_Validation',u'MinValue',u'Y',-2147483647,2147483647,None, None, None, None, u'Minimum value allowed',),
-(u'_Validation',u'Nullable',u'N',None, None, None, None, None, u'Y;N;@',u'Whether the column is nullable',),
-(u'ActionText',u'Description',u'Y',None, None, None, None, u'Text',None, u'Localized description displayed in progress dialog and log when action is executing.',),
-(u'ActionText',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to be described.',),
-(u'ActionText',u'Template',u'Y',None, None, None, None, u'Template',None, u'Optional localized format template used to format action data records for display during action execution.',),
-(u'AdminExecuteSequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'AdminExecuteSequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'AdminExecuteSequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'Condition',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Expression evaluated to determine if Level in the Feature table is to change.',),
-(u'Condition',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Reference to a Feature entry in Feature table.',),
-(u'Condition',u'Level',u'N',0,32767,None, None, None, None, u'New selection Level to set in Feature table if Condition evaluates to TRUE.',),
-(u'AdminUISequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'AdminUISequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'AdminUISequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'AdvtExecuteSequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'AdvtExecuteSequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'AdvtExecuteSequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'AdvtUISequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'AdvtUISequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'AdvtUISequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'AppId',u'AppId',u'N',None, None, None, None, u'Guid',None, None, ),
-(u'AppId',u'ActivateAtStorage',u'Y',0,1,None, None, None, None, None, ),
-(u'AppId',u'DllSurrogate',u'Y',None, None, None, None, u'Text',None, None, ),
-(u'AppId',u'LocalService',u'Y',None, None, None, None, u'Text',None, None, ),
-(u'AppId',u'RemoteServerName',u'Y',None, None, None, None, u'Formatted',None, None, ),
-(u'AppId',u'RunAsInteractiveUser',u'Y',0,1,None, None, None, None, None, ),
-(u'AppId',u'ServiceParameters',u'Y',None, None, None, None, u'Text',None, None, ),
-(u'AppSearch',u'Property',u'N',None, None, None, None, u'Identifier',None, u'The property associated with a Signature',),
-(u'AppSearch',u'Signature_',u'N',None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator',1,u'Identifier',None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.',),
-(u'Property',u'Property',u'N',None, None, None, None, u'Identifier',None, u'Name of property, uppercase if settable by launcher or loader.',),
-(u'Property',u'Value',u'N',None, None, None, None, u'Text',None, u'String value for property. Never null or empty.',),
-(u'BBControl',u'Type',u'N',None, None, None, None, u'Identifier',None, u'The type of the control.',),
-(u'BBControl',u'Y',u'N',0,32767,None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.',),
-(u'BBControl',u'Text',u'Y',None, None, None, None, u'Text',None, u'A string used to set the initial text contained within a control (if appropriate).',),
-(u'BBControl',u'BBControl',u'N',None, None, None, None, u'Identifier',None, u'Name of the control. This name must be unique within a billboard, but can repeat on different billboard.',),
-(u'BBControl',u'Attributes',u'Y',0,2147483647,None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.',),
-(u'BBControl',u'Billboard_',u'N',None, None, u'Billboard',1,u'Identifier',None, u'External key to the Billboard table, name of the billboard.',),
-(u'BBControl',u'Height',u'N',0,32767,None, None, None, None, u'Height of the bounding rectangle of the control.',),
-(u'BBControl',u'Width',u'N',0,32767,None, None, None, None, u'Width of the bounding rectangle of the control.',),
-(u'BBControl',u'X',u'N',0,32767,None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.',),
-(u'Billboard',u'Action',u'Y',None, None, None, None, u'Identifier',None, u'The name of an action. The billboard is displayed during the progress messages received from this action.',),
-(u'Billboard',u'Billboard',u'N',None, None, None, None, u'Identifier',None, u'Name of the billboard.',),
-(u'Billboard',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'An external key to the Feature Table. The billboard is shown only if this feature is being installed.',),
-(u'Billboard',u'Ordering',u'Y',0,32767,None, None, None, None, u'A positive integer. If there is more than one billboard corresponding to an action they will be shown in the order defined by this column.',),
-(u'Feature',u'Description',u'Y',None, None, None, None, u'Text',None, u'Longer descriptive text describing a visible feature item.',),
-(u'Feature',u'Attributes',u'N',None, None, None, None, None, u'0;1;2;4;5;6;8;9;10;16;17;18;20;21;22;24;25;26;32;33;34;36;37;38;48;49;50;52;53;54',u'Feature attributes',),
-(u'Feature',u'Feature',u'N',None, None, None, None, u'Identifier',None, u'Primary key used to identify a particular feature record.',),
-(u'Feature',u'Directory_',u'Y',None, None, u'Directory',1,u'UpperCase',None, u'The name of the Directory that can be configured by the UI. A non-null value will enable the browse button.',),
-(u'Feature',u'Level',u'N',0,32767,None, None, None, None, u'The install level at which record will be initially selected. An install level of 0 will disable an item and prevent its display.',),
-(u'Feature',u'Title',u'Y',None, None, None, None, u'Text',None, u'Short text identifying a visible feature item.',),
-(u'Feature',u'Display',u'Y',0,32767,None, None, None, None, u'Numeric sort order, used to force a specific display ordering.',),
-(u'Feature',u'Feature_Parent',u'Y',None, None, u'Feature',1,u'Identifier',None, u'Optional key of a parent record in the same table. If the parent is not selected, then the record will not be installed. Null indicates a root item.',),
-(u'Binary',u'Name',u'N',None, None, None, None, u'Identifier',None, u'Unique key identifying the binary data.',),
-(u'Binary',u'Data',u'N',None, None, None, None, u'Binary',None, u'The unformatted binary data.',),
-(u'BindImage',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'The index into the File table. This must be an executable file.',),
-(u'BindImage',u'Path',u'Y',None, None, None, None, u'Paths',None, u'A list of ; delimited paths that represent the paths to be searched for the import DLLS. The list is usually a list of properties each enclosed within square brackets [] .',),
-(u'File',u'Sequence',u'N',1,32767,None, None, None, None, u'Sequence with respect to the media images; order must track cabinet order.',),
-(u'File',u'Attributes',u'Y',0,32767,None, None, None, None, u'Integer containing bit flags representing file attributes (with the decimal value of each bit position in parentheses)',),
-(u'File',u'File',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token, must match identifier in cabinet. For uncompressed files, this field is ignored.',),
-(u'File',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key referencing Component that controls the file.',),
-(u'File',u'FileName',u'N',None, None, None, None, u'Filename',None, u'File name used for installation, may be localized. This may contain a "short name|long name" pair.',),
-(u'File',u'FileSize',u'N',0,2147483647,None, None, None, None, u'Size of file in bytes (long integer).',),
-(u'File',u'Language',u'Y',None, None, None, None, u'Language',None, u'List of decimal language Ids, comma-separated if more than one.',),
-(u'File',u'Version',u'Y',None, None, u'File',1,u'Version',None, u'Version string for versioned files; Blank for unversioned files.',),
-(u'CCPSearch',u'Signature_',u'N',None, None, u'Signature;RegLocator;IniLocator;DrLocator;CompLocator',1,u'Identifier',None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.',),
-(u'CheckBox',u'Property',u'N',None, None, None, None, u'Identifier',None, u'A named property to be tied to the item.',),
-(u'CheckBox',u'Value',u'Y',None, None, None, None, u'Formatted',None, u'The value string associated with the item.',),
-(u'Class',u'Description',u'Y',None, None, None, None, u'Text',None, u'Localized description for the Class.',),
-(u'Class',u'Attributes',u'Y',None, 32767,None, None, None, None, u'Class registration attributes.',),
-(u'Class',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.',),
-(u'Class',u'AppId_',u'Y',None, None, u'AppId',1,u'Guid',None, u'Optional AppID containing DCOM information for associated application (string GUID).',),
-(u'Class',u'Argument',u'Y',None, None, None, None, u'Formatted',None, u'optional argument for LocalServers.',),
-(u'Class',u'CLSID',u'N',None, None, None, None, u'Guid',None, u'The CLSID of an OLE factory.',),
-(u'Class',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
-(u'Class',u'Context',u'N',None, None, None, None, u'Identifier',None, u'The numeric server context for this server. CLSCTX_xxxx',),
-(u'Class',u'DefInprocHandler',u'Y',None, None, None, None, u'Filename',u'1;2;3',u'Optional default inproc handler. Only optionally provided if Context=CLSCTX_LOCAL_SERVER. Typically "ole32.dll" or "mapi32.dll"',),
-(u'Class',u'FileTypeMask',u'Y',None, None, None, None, u'Text',None, u'Optional string containing information for the HKCRthis CLSID) key. If multiple patterns exist, they must be delimited by a semicolon, and numeric subkeys will be generated: 0,1,2...',),
-(u'Class',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this CLSID. Will be written under the DefaultIcon key.',),
-(u'Class',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'Optional icon index.',),
-(u'Class',u'ProgId_Default',u'Y',None, None, u'ProgId',1,u'Text',None, u'Optional ProgId associated with this CLSID.',),
-(u'Component',u'Condition',u'Y',None, None, None, None, u'Condition',None, u"A conditional statement that will disable this component if the specified condition evaluates to the 'True' state. If a component is disabled, it will not be installed, regardless of the 'Action' state associated with the component.",),
-(u'Component',u'Attributes',u'N',None, None, None, None, None, None, u'Remote execution option, one of irsEnum',),
-(u'Component',u'Component',u'N',None, None, None, None, u'Identifier',None, u'Primary key used to identify a particular component record.',),
-(u'Component',u'ComponentId',u'Y',None, None, None, None, u'Guid',None, u'A string GUID unique to this component, version, and language.',),
-(u'Component',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Required key of a Directory table record. This is actually a property name whose value contains the actual path, set either by the AppSearch action or with the default setting obtained from the Directory table.',),
-(u'Component',u'KeyPath',u'Y',None, None, u'File;Registry;ODBCDataSource',1,u'Identifier',None, u'Either the primary key into the File table, Registry table, or ODBCDataSource table. This extract path is stored when the component is installed, and is used to detect the presence of the component and to return the path to it.',),
-(u'Icon',u'Name',u'N',None, None, None, None, u'Identifier',None, u'Primary key. Name of the icon file.',),
-(u'Icon',u'Data',u'N',None, None, None, None, u'Binary',None, u'Binary stream. The binary icon data in PE (.DLL or .EXE) or icon (.ICO) format.',),
-(u'ProgId',u'Description',u'Y',None, None, None, None, u'Text',None, u'Localized description for the Program identifier.',),
-(u'ProgId',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Optional foreign key into the Icon Table, specifying the icon file associated with this ProgId. Will be written under the DefaultIcon key.',),
-(u'ProgId',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'Optional icon index.',),
-(u'ProgId',u'ProgId',u'N',None, None, None, None, u'Text',None, u'The Program Identifier. Primary key.',),
-(u'ProgId',u'Class_',u'Y',None, None, u'Class',1,u'Guid',None, u'The CLSID of an OLE factory corresponding to the ProgId.',),
-(u'ProgId',u'ProgId_Parent',u'Y',None, None, u'ProgId',1,u'Text',None, u'The Parent Program Identifier. If specified, the ProgId column becomes a version independent prog id.',),
-(u'ComboBox',u'Text',u'Y',None, None, None, None, u'Formatted',None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
-(u'ComboBox',u'Property',u'N',None, None, None, None, u'Identifier',None, u'A named property to be tied to this item. All the items tied to the same property become part of the same combobox.',),
-(u'ComboBox',u'Value',u'N',None, None, None, None, u'Formatted',None, u'The value string associated with this item. Selecting the line will set the associated property to this value.',),
-(u'ComboBox',u'Order',u'N',1,32767,None, None, None, None, u'A positive integer used to determine the ordering of the items within one list.\tThe integers do not have to be consecutive.',),
-(u'CompLocator',u'Type',u'Y',0,1,None, None, None, None, u'A boolean value that determines if the registry value is a filename or a directory location.',),
-(u'CompLocator',u'Signature_',u'N',None, None, None, None, u'Identifier',None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
-(u'CompLocator',u'ComponentId',u'N',None, None, None, None, u'Guid',None, u'A string GUID unique to this component, version, and language.',),
-(u'Complus',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key referencing Component that controls the ComPlus component.',),
-(u'Complus',u'ExpType',u'Y',0,32767,None, None, None, None, u'ComPlus component attributes.',),
-(u'Directory',u'Directory',u'N',None, None, None, None, u'Identifier',None, u'Unique identifier for directory entry, primary key. If a property by this name is defined, it contains the full path to the directory.',),
-(u'Directory',u'DefaultDir',u'N',None, None, None, None, u'DefaultDir',None, u"The default sub-path under parent's path.",),
-(u'Directory',u'Directory_Parent',u'Y',None, None, u'Directory',1,u'Identifier',None, u'Reference to the entry in this table specifying the default parent directory. A record parented to itself or with a Null parent represents a root of the install tree.',),
-(u'Control',u'Type',u'N',None, None, None, None, u'Identifier',None, u'The type of the control.',),
-(u'Control',u'Y',u'N',0,32767,None, None, None, None, u'Vertical coordinate of the upper left corner of the bounding rectangle of the control.',),
-(u'Control',u'Text',u'Y',None, None, None, None, u'Formatted',None, u'A string used to set the initial text contained within a control (if appropriate).',),
-(u'Control',u'Property',u'Y',None, None, None, None, u'Identifier',None, u'The name of a defined property to be linked to this control. ',),
-(u'Control',u'Attributes',u'Y',0,2147483647,None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this control.',),
-(u'Control',u'Height',u'N',0,32767,None, None, None, None, u'Height of the bounding rectangle of the control.',),
-(u'Control',u'Width',u'N',0,32767,None, None, None, None, u'Width of the bounding rectangle of the control.',),
-(u'Control',u'X',u'N',0,32767,None, None, None, None, u'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.',),
-(u'Control',u'Control',u'N',None, None, None, None, u'Identifier',None, u'Name of the control. This name must be unique within a dialog, but can repeat on different dialogs. ',),
-(u'Control',u'Control_Next',u'Y',None, None, u'Control',2,u'Identifier',None, u'The name of an other control on the same dialog. This link defines the tab order of the controls. The links have to form one or more cycles!',),
-(u'Control',u'Dialog_',u'N',None, None, u'Dialog',1,u'Identifier',None, u'External key to the Dialog table, name of the dialog.',),
-(u'Control',u'Help',u'Y',None, None, None, None, u'Text',None, u'The help strings used with the button. The text is optional. ',),
-(u'Dialog',u'Attributes',u'Y',0,2147483647,None, None, None, None, u'A 32-bit word that specifies the attribute flags to be applied to this dialog.',),
-(u'Dialog',u'Height',u'N',0,32767,None, None, None, None, u'Height of the bounding rectangle of the dialog.',),
-(u'Dialog',u'Width',u'N',0,32767,None, None, None, None, u'Width of the bounding rectangle of the dialog.',),
-(u'Dialog',u'Dialog',u'N',None, None, None, None, u'Identifier',None, u'Name of the dialog.',),
-(u'Dialog',u'Control_Cancel',u'Y',None, None, u'Control',2,u'Identifier',None, u'Defines the cancel control. Hitting escape or clicking on the close icon on the dialog is equivalent to pushing this button.',),
-(u'Dialog',u'Control_Default',u'Y',None, None, u'Control',2,u'Identifier',None, u'Defines the default control. Hitting return is equivalent to pushing this button.',),
-(u'Dialog',u'Control_First',u'N',None, None, u'Control',2,u'Identifier',None, u'Defines the control that has the focus when the dialog is created.',),
-(u'Dialog',u'HCentering',u'N',0,100,None, None, None, None, u'Horizontal position of the dialog on a 0-100 scale. 0 means left end, 100 means right end of the screen, 50 center.',),
-(u'Dialog',u'Title',u'Y',None, None, None, None, u'Formatted',None, u"A text string specifying the title to be displayed in the title bar of the dialog's window.",),
-(u'Dialog',u'VCentering',u'N',0,100,None, None, None, None, u'Vertical position of the dialog on a 0-100 scale. 0 means top end, 100 means bottom end of the screen, 50 center.',),
-(u'ControlCondition',u'Action',u'N',None, None, None, None, None, u'Default;Disable;Enable;Hide;Show',u'The desired action to be taken on the specified control.',),
-(u'ControlCondition',u'Condition',u'N',None, None, None, None, u'Condition',None, u'A standard conditional statement that specifies under which conditions the action should be triggered.',),
-(u'ControlCondition',u'Dialog_',u'N',None, None, u'Dialog',1,u'Identifier',None, u'A foreign key to the Dialog table, name of the dialog.',),
-(u'ControlCondition',u'Control_',u'N',None, None, u'Control',2,u'Identifier',None, u'A foreign key to the Control table, name of the control.',),
-(u'ControlEvent',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'A standard conditional statement that specifies under which conditions an event should be triggered.',),
-(u'ControlEvent',u'Ordering',u'Y',0,2147483647,None, None, None, None, u'An integer used to order several events tied to the same control. Can be left blank.',),
-(u'ControlEvent',u'Argument',u'N',None, None, None, None, u'Formatted',None, u'A value to be used as a modifier when triggering a particular event.',),
-(u'ControlEvent',u'Dialog_',u'N',None, None, u'Dialog',1,u'Identifier',None, u'A foreign key to the Dialog table, name of the dialog.',),
-(u'ControlEvent',u'Control_',u'N',None, None, u'Control',2,u'Identifier',None, u'A foreign key to the Control table, name of the control',),
-(u'ControlEvent',u'Event',u'N',None, None, None, None, u'Formatted',None, u'An identifier that specifies the type of the event that should take place when the user interacts with control specified by the first two entries.',),
-(u'CreateFolder',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table.',),
-(u'CreateFolder',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Primary key, could be foreign key into the Directory table.',),
-(u'CustomAction',u'Type',u'N',1,16383,None, None, None, None, u'The numeric custom action type, consisting of source location, code type, entry, option flags.',),
-(u'CustomAction',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Primary key, name of action, normally appears in sequence table unless private use.',),
-(u'CustomAction',u'Source',u'Y',None, None, None, None, u'CustomSource',None, u'The table reference of the source of the code.',),
-(u'CustomAction',u'Target',u'Y',None, None, None, None, u'Formatted',None, u'Excecution parameter, depends on the type of custom action',),
-(u'DrLocator',u'Signature_',u'N',None, None, None, None, u'Identifier',None, u'The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
-(u'DrLocator',u'Path',u'Y',None, None, None, None, u'AnyPath',None, u'The path on the user system. This is a either a subpath below the value of the Parent or a full path. The path may contain properties enclosed within [ ] that will be expanded.',),
-(u'DrLocator',u'Depth',u'Y',0,32767,None, None, None, None, u'The depth below the path to which the Signature_ is recursively searched. If absent, the depth is assumed to be 0.',),
-(u'DrLocator',u'Parent',u'Y',None, None, None, None, u'Identifier',None, u'The parent file signature. It is also a foreign key in the Signature table. If null and the Path column does not expand to a full path, then all the fixed drives of the user system are searched using the Path.',),
-(u'DuplicateFile',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Foreign key referencing the source file to be duplicated.',),
-(u'DuplicateFile',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key referencing Component that controls the duplicate file.',),
-(u'DuplicateFile',u'DestFolder',u'Y',None, None, None, None, u'Identifier',None, u'Name of a property whose value is assumed to resolve to the full pathname to a destination folder.',),
-(u'DuplicateFile',u'DestName',u'Y',None, None, None, None, u'Filename',None, u'Filename to be given to the duplicate file.',),
-(u'DuplicateFile',u'FileKey',u'N',None, None, None, None, u'Identifier',None, u'Primary key used to identify a particular file entry',),
-(u'Environment',u'Name',u'N',None, None, None, None, u'Text',None, u'The name of the environmental value.',),
-(u'Environment',u'Value',u'Y',None, None, None, None, u'Formatted',None, u'The value to set in the environmental settings.',),
-(u'Environment',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table referencing component that controls the installing of the environmental value.',),
-(u'Environment',u'Environment',u'N',None, None, None, None, u'Identifier',None, u'Unique identifier for the environmental variable setting',),
-(u'Error',u'Error',u'N',0,32767,None, None, None, None, u'Integer error number, obtained from header file IError(...) macros.',),
-(u'Error',u'Message',u'Y',None, None, None, None, u'Template',None, u'Error formatting template, obtained from user ed. or localizers.',),
-(u'EventMapping',u'Dialog_',u'N',None, None, u'Dialog',1,u'Identifier',None, u'A foreign key to the Dialog table, name of the Dialog.',),
-(u'EventMapping',u'Control_',u'N',None, None, u'Control',2,u'Identifier',None, u'A foreign key to the Control table, name of the control.',),
-(u'EventMapping',u'Event',u'N',None, None, None, None, u'Identifier',None, u'An identifier that specifies the type of the event that the control subscribes to.',),
-(u'EventMapping',u'Attribute',u'N',None, None, None, None, u'Identifier',None, u'The name of the control attribute, that is set when this event is received.',),
-(u'Extension',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.',),
-(u'Extension',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
-(u'Extension',u'Extension',u'N',None, None, None, None, u'Text',None, u'The extension associated with the table row.',),
-(u'Extension',u'MIME_',u'Y',None, None, u'MIME',1,u'Text',None, u'Optional Context identifier, typically "type/format" associated with the extension',),
-(u'Extension',u'ProgId_',u'Y',None, None, u'ProgId',1,u'Text',None, u'Optional ProgId associated with this extension.',),
-(u'MIME',u'CLSID',u'Y',None, None, None, None, u'Guid',None, u'Optional associated CLSID.',),
-(u'MIME',u'ContentType',u'N',None, None, None, None, u'Text',None, u'Primary key. Context identifier, typically "type/format".',),
-(u'MIME',u'Extension_',u'N',None, None, u'Extension',1,u'Text',None, u'Optional associated extension (without dot)',),
-(u'FeatureComponents',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Foreign key into Feature table.',),
-(u'FeatureComponents',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into Component table.',),
-(u'FileSFPCatalog',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'File associated with the catalog',),
-(u'FileSFPCatalog',u'SFPCatalog_',u'N',None, None, u'SFPCatalog',1,u'Filename',None, u'Catalog associated with the file',),
-(u'SFPCatalog',u'SFPCatalog',u'N',None, None, None, None, u'Filename',None, u'File name for the catalog.',),
-(u'SFPCatalog',u'Catalog',u'N',None, None, None, None, u'Binary',None, u'SFP Catalog',),
-(u'SFPCatalog',u'Dependency',u'Y',None, None, None, None, u'Formatted',None, u'Parent catalog - only used by SFP',),
-(u'Font',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Primary key, foreign key into File table referencing font file.',),
-(u'Font',u'FontTitle',u'Y',None, None, None, None, u'Text',None, u'Font name.',),
-(u'IniFile',u'Action',u'N',None, None, None, None, None, u'0;1;3',u'The type of modification to be made, one of iifEnum',),
-(u'IniFile',u'Value',u'N',None, None, None, None, u'Formatted',None, u'The value to be written.',),
-(u'IniFile',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table referencing component that controls the installing of the .INI value.',),
-(u'IniFile',u'FileName',u'N',None, None, None, None, u'Filename',None, u'The .INI file name in which to write the information',),
-(u'IniFile',u'IniFile',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'IniFile',u'DirProperty',u'Y',None, None, None, None, u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the .INI file is.',),
-(u'IniFile',u'Key',u'N',None, None, None, None, u'Formatted',None, u'The .INI file key below Section.',),
-(u'IniFile',u'Section',u'N',None, None, None, None, u'Formatted',None, u'The .INI file Section.',),
-(u'IniLocator',u'Type',u'Y',0,2,None, None, None, None, u'An integer value that determines if the .INI value read is a filename or a directory location or to be used as is w/o interpretation.',),
-(u'IniLocator',u'Signature_',u'N',None, None, None, None, u'Identifier',None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
-(u'IniLocator',u'FileName',u'N',None, None, None, None, u'Filename',None, u'The .INI file name.',),
-(u'IniLocator',u'Key',u'N',None, None, None, None, u'Text',None, u'Key value (followed by an equals sign in INI file).',),
-(u'IniLocator',u'Section',u'N',None, None, None, None, u'Text',None, u'Section name within in file (within square brackets in INI file).',),
-(u'IniLocator',u'Field',u'Y',0,32767,None, None, None, None, u'The field in the .INI line. If Field is null or 0 the entire line is read.',),
-(u'InstallExecuteSequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'InstallExecuteSequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'InstallExecuteSequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'InstallUISequence',u'Action',u'N',None, None, None, None, u'Identifier',None, u'Name of action to invoke, either in the engine or the handler DLL.',),
-(u'InstallUISequence',u'Condition',u'Y',None, None, None, None, u'Condition',None, u'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
-(u'InstallUISequence',u'Sequence',u'Y',-4,32767,None, None, None, None, u'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
-(u'IsolatedComponent',u'Component_Application',u'N',None, None, u'Component',1,u'Identifier',None, u'Key to Component table item for application',),
-(u'IsolatedComponent',u'Component_Shared',u'N',None, None, u'Component',1,u'Identifier',None, u'Key to Component table item to be isolated',),
-(u'LaunchCondition',u'Description',u'N',None, None, None, None, u'Formatted',None, u'Localizable text to display when condition fails and install must abort.',),
-(u'LaunchCondition',u'Condition',u'N',None, None, None, None, u'Condition',None, u'Expression which must evaluate to TRUE in order for install to commence.',),
-(u'ListBox',u'Text',u'Y',None, None, None, None, u'Text',None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
-(u'ListBox',u'Property',u'N',None, None, None, None, u'Identifier',None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listbox.',),
-(u'ListBox',u'Value',u'N',None, None, None, None, u'Formatted',None, u'The value string associated with this item. Selecting the line will set the associated property to this value.',),
-(u'ListBox',u'Order',u'N',1,32767,None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
-(u'ListView',u'Text',u'Y',None, None, None, None, u'Text',None, u'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
-(u'ListView',u'Property',u'N',None, None, None, None, u'Identifier',None, u'A named property to be tied to this item. All the items tied to the same property become part of the same listview.',),
-(u'ListView',u'Value',u'N',None, None, None, None, u'Identifier',None, u'The value string associated with this item. Selecting the line will set the associated property to this value.',),
-(u'ListView',u'Order',u'N',1,32767,None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
-(u'ListView',u'Binary_',u'Y',None, None, u'Binary',1,u'Identifier',None, u'The name of the icon to be displayed with the icon. The binary information is looked up from the Binary Table.',),
-(u'LockPermissions',u'Table',u'N',None, None, None, None, u'Identifier',u'Directory;File;Registry',u'Reference to another table name',),
-(u'LockPermissions',u'Domain',u'Y',None, None, None, None, u'Formatted',None, u'Domain name for user whose permissions are being set. (usually a property)',),
-(u'LockPermissions',u'LockObject',u'N',None, None, None, None, u'Identifier',None, u'Foreign key into Registry or File table',),
-(u'LockPermissions',u'Permission',u'Y',-2147483647,2147483647,None, None, None, None, u'Permission Access mask. Full Control = 268435456 (GENERIC_ALL = 0x10000000)',),
-(u'LockPermissions',u'User',u'N',None, None, None, None, u'Formatted',None, u'User for permissions to be set. (usually a property)',),
-(u'Media',u'Source',u'Y',None, None, None, None, u'Property',None, u'The property defining the location of the cabinet file.',),
-(u'Media',u'Cabinet',u'Y',None, None, None, None, u'Cabinet',None, u'If some or all of the files stored on the media are compressed in a cabinet, the name of that cabinet.',),
-(u'Media',u'DiskId',u'N',1,32767,None, None, None, None, u'Primary key, integer to determine sort order for table.',),
-(u'Media',u'DiskPrompt',u'Y',None, None, None, None, u'Text',None, u'Disk name: the visible text actually printed on the disk. This will be used to prompt the user when this disk needs to be inserted.',),
-(u'Media',u'LastSequence',u'N',0,32767,None, None, None, None, u'File sequence number for the last file for this media.',),
-(u'Media',u'VolumeLabel',u'Y',None, None, None, None, u'Text',None, u'The label attributed to the volume.',),
-(u'ModuleComponents',u'Component',u'N',None, None, u'Component',1,u'Identifier',None, u'Component contained in the module.',),
-(u'ModuleComponents',u'Language',u'N',None, None, u'ModuleSignature',2,None, None, u'Default language ID for module (may be changed by transform).',),
-(u'ModuleComponents',u'ModuleID',u'N',None, None, u'ModuleSignature',1,u'Identifier',None, u'Module containing the component.',),
-(u'ModuleSignature',u'Language',u'N',None, None, None, None, None, None, u'Default decimal language of module.',),
-(u'ModuleSignature',u'Version',u'N',None, None, None, None, u'Version',None, u'Version of the module.',),
-(u'ModuleSignature',u'ModuleID',u'N',None, None, None, None, u'Identifier',None, u'Module identifier (String.GUID).',),
-(u'ModuleDependency',u'ModuleID',u'N',None, None, u'ModuleSignature',1,u'Identifier',None, u'Module requiring the dependency.',),
-(u'ModuleDependency',u'ModuleLanguage',u'N',None, None, u'ModuleSignature',2,None, None, u'Language of module requiring the dependency.',),
-(u'ModuleDependency',u'RequiredID',u'N',None, None, None, None, None, None, u'String.GUID of required module.',),
-(u'ModuleDependency',u'RequiredLanguage',u'N',None, None, None, None, None, None, u'LanguageID of the required module.',),
-(u'ModuleDependency',u'RequiredVersion',u'Y',None, None, None, None, u'Version',None, u'Version of the required version.',),
-(u'ModuleExclusion',u'ModuleID',u'N',None, None, u'ModuleSignature',1,u'Identifier',None, u'String.GUID of module with exclusion requirement.',),
-(u'ModuleExclusion',u'ModuleLanguage',u'N',None, None, u'ModuleSignature',2,None, None, u'LanguageID of module with exclusion requirement.',),
-(u'ModuleExclusion',u'ExcludedID',u'N',None, None, None, None, None, None, u'String.GUID of excluded module.',),
-(u'ModuleExclusion',u'ExcludedLanguage',u'N',None, None, None, None, None, None, u'Language of excluded module.',),
-(u'ModuleExclusion',u'ExcludedMaxVersion',u'Y',None, None, None, None, u'Version',None, u'Maximum version of excluded module.',),
-(u'ModuleExclusion',u'ExcludedMinVersion',u'Y',None, None, None, None, u'Version',None, u'Minimum version of excluded module.',),
-(u'MoveFile',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'If this component is not "selected" for installation or removal, no action will be taken on the associated MoveFile entry',),
-(u'MoveFile',u'DestFolder',u'N',None, None, None, None, u'Identifier',None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory',),
-(u'MoveFile',u'DestName',u'Y',None, None, None, None, u'Filename',None, u'Name to be given to the original file after it is moved or copied. If blank, the destination file will be given the same name as the source file',),
-(u'MoveFile',u'FileKey',u'N',None, None, None, None, u'Identifier',None, u'Primary key that uniquely identifies a particular MoveFile record',),
-(u'MoveFile',u'Options',u'N',0,1,None, None, None, None, u'Integer value specifying the MoveFile operating mode, one of imfoEnum',),
-(u'MoveFile',u'SourceFolder',u'Y',None, None, None, None, u'Identifier',None, u'Name of a property whose value is assumed to resolve to the full path to the source directory',),
-(u'MoveFile',u'SourceName',u'Y',None, None, None, None, u'Text',None, u"Name of the source file(s) to be moved or copied. Can contain the '*' or '?' wildcards.",),
-(u'MsiAssembly',u'Attributes',u'Y',None, None, None, None, None, None, u'Assembly attributes',),
-(u'MsiAssembly',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Foreign key into Feature table.',),
-(u'MsiAssembly',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into Component table.',),
-(u'MsiAssembly',u'File_Application',u'Y',None, None, u'File',1,u'Identifier',None, u'Foreign key into File table, denoting the application context for private assemblies. Null for global assemblies.',),
-(u'MsiAssembly',u'File_Manifest',u'Y',None, None, u'File',1,u'Identifier',None, u'Foreign key into the File table denoting the manifest file for the assembly.',),
-(u'MsiAssemblyName',u'Name',u'N',None, None, None, None, u'Text',None, u'The name part of the name-value pairs for the assembly name.',),
-(u'MsiAssemblyName',u'Value',u'N',None, None, None, None, u'Text',None, u'The value part of the name-value pairs for the assembly name.',),
-(u'MsiAssemblyName',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into Component table.',),
-(u'MsiDigitalCertificate',u'CertData',u'N',None, None, None, None, u'Binary',None, u'A certificate context blob for a signer certificate',),
-(u'MsiDigitalCertificate',u'DigitalCertificate',u'N',None, None, None, None, u'Identifier',None, u'A unique identifier for the row',),
-(u'MsiDigitalSignature',u'Table',u'N',None, None, None, None, None, u'Media',u'Reference to another table name (only Media table is supported)',),
-(u'MsiDigitalSignature',u'DigitalCertificate_',u'N',None, None, u'MsiDigitalCertificate',1,u'Identifier',None, u'Foreign key to MsiDigitalCertificate table identifying the signer certificate',),
-(u'MsiDigitalSignature',u'Hash',u'Y',None, None, None, None, u'Binary',None, u'The encoded hash blob from the digital signature',),
-(u'MsiDigitalSignature',u'SignObject',u'N',None, None, None, None, u'Text',None, u'Foreign key to Media table',),
-(u'MsiFileHash',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Primary key, foreign key into File table referencing file with this hash',),
-(u'MsiFileHash',u'Options',u'N',0,32767,None, None, None, None, u'Various options and attributes for this hash.',),
-(u'MsiFileHash',u'HashPart1',u'N',None, None, None, None, None, None, u'Size of file in bytes (long integer).',),
-(u'MsiFileHash',u'HashPart2',u'N',None, None, None, None, None, None, u'Size of file in bytes (long integer).',),
-(u'MsiFileHash',u'HashPart3',u'N',None, None, None, None, None, None, u'Size of file in bytes (long integer).',),
-(u'MsiFileHash',u'HashPart4',u'N',None, None, None, None, None, None, u'Size of file in bytes (long integer).',),
-(u'MsiPatchHeaders',u'StreamRef',u'N',None, None, None, None, u'Identifier',None, u'Primary key. A unique identifier for the row.',),
-(u'MsiPatchHeaders',u'Header',u'N',None, None, None, None, u'Binary',None, u'Binary stream. The patch header, used for patch validation.',),
-(u'ODBCAttribute',u'Value',u'Y',None, None, None, None, u'Text',None, u'Value for ODBC driver attribute',),
-(u'ODBCAttribute',u'Attribute',u'N',None, None, None, None, u'Text',None, u'Name of ODBC driver attribute',),
-(u'ODBCAttribute',u'Driver_',u'N',None, None, u'ODBCDriver',1,u'Identifier',None, u'Reference to ODBC driver in ODBCDriver table',),
-(u'ODBCDriver',u'Description',u'N',None, None, None, None, u'Text',None, u'Text used as registered name for driver, non-localized',),
-(u'ODBCDriver',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Reference to key driver file',),
-(u'ODBCDriver',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Reference to associated component',),
-(u'ODBCDriver',u'Driver',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized.internal token for driver',),
-(u'ODBCDriver',u'File_Setup',u'Y',None, None, u'File',1,u'Identifier',None, u'Optional reference to key driver setup DLL',),
-(u'ODBCDataSource',u'Description',u'N',None, None, None, None, u'Text',None, u'Text used as registered name for data source',),
-(u'ODBCDataSource',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Reference to associated component',),
-(u'ODBCDataSource',u'DataSource',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized.internal token for data source',),
-(u'ODBCDataSource',u'DriverDescription',u'N',None, None, None, None, u'Text',None, u'Reference to driver description, may be existing driver',),
-(u'ODBCDataSource',u'Registration',u'N',0,1,None, None, None, None, u'Registration option: 0=machine, 1=user, others t.b.d.',),
-(u'ODBCSourceAttribute',u'Value',u'Y',None, None, None, None, u'Text',None, u'Value for ODBC data source attribute',),
-(u'ODBCSourceAttribute',u'Attribute',u'N',None, None, None, None, u'Text',None, u'Name of ODBC data source attribute',),
-(u'ODBCSourceAttribute',u'DataSource_',u'N',None, None, u'ODBCDataSource',1,u'Identifier',None, u'Reference to ODBC data source in ODBCDataSource table',),
-(u'ODBCTranslator',u'Description',u'N',None, None, None, None, u'Text',None, u'Text used as registered name for translator',),
-(u'ODBCTranslator',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Reference to key translator file',),
-(u'ODBCTranslator',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Reference to associated component',),
-(u'ODBCTranslator',u'File_Setup',u'Y',None, None, u'File',1,u'Identifier',None, u'Optional reference to key translator setup DLL',),
-(u'ODBCTranslator',u'Translator',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized.internal token for translator',),
-(u'Patch',u'Sequence',u'N',0,32767,None, None, None, None, u'Primary key, sequence with respect to the media images; order must track cabinet order.',),
-(u'Patch',u'Attributes',u'N',0,32767,None, None, None, None, u'Integer containing bit flags representing patch attributes',),
-(u'Patch',u'File_',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token, foreign key to File table, must match identifier in cabinet.',),
-(u'Patch',u'Header',u'Y',None, None, None, None, u'Binary',None, u'Binary stream. The patch header, used for patch validation.',),
-(u'Patch',u'PatchSize',u'N',0,2147483647,None, None, None, None, u'Size of patch in bytes (long integer).',),
-(u'Patch',u'StreamRef_',u'Y',None, None, None, None, u'Identifier',None, u'Identifier. Foreign key to the StreamRef column of the MsiPatchHeaders table.',),
-(u'PatchPackage',u'Media_',u'N',0,32767,None, None, None, None, u'Foreign key to DiskId column of Media table. Indicates the disk containing the patch package.',),
-(u'PatchPackage',u'PatchId',u'N',None, None, None, None, u'Guid',None, u'A unique string GUID representing this patch.',),
-(u'PublishComponent',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Foreign key into the Feature table.',),
-(u'PublishComponent',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table.',),
-(u'PublishComponent',u'ComponentId',u'N',None, None, None, None, u'Guid',None, u'A string GUID that represents the component id that will be requested by the alien product.',),
-(u'PublishComponent',u'AppData',u'Y',None, None, None, None, u'Text',None, u'This is localisable Application specific data that can be associated with a Qualified Component.',),
-(u'PublishComponent',u'Qualifier',u'N',None, None, None, None, u'Text',None, u'This is defined only when the ComponentId column is an Qualified Component Id. This is the Qualifier for ProvideComponentIndirect.',),
-(u'RadioButton',u'Y',u'N',0,32767,None, None, None, None, u'The vertical coordinate of the upper left corner of the bounding rectangle of the radio button.',),
-(u'RadioButton',u'Text',u'Y',None, None, None, None, u'Text',None, u'The visible title to be assigned to the radio button.',),
-(u'RadioButton',u'Property',u'N',None, None, None, None, u'Identifier',None, u'A named property to be tied to this radio button. All the buttons tied to the same property become part of the same group.',),
-(u'RadioButton',u'Height',u'N',0,32767,None, None, None, None, u'The height of the button.',),
-(u'RadioButton',u'Width',u'N',0,32767,None, None, None, None, u'The width of the button.',),
-(u'RadioButton',u'X',u'N',0,32767,None, None, None, None, u'The horizontal coordinate of the upper left corner of the bounding rectangle of the radio button.',),
-(u'RadioButton',u'Value',u'N',None, None, None, None, u'Formatted',None, u'The value string associated with this button. Selecting the button will set the associated property to this value.',),
-(u'RadioButton',u'Order',u'N',1,32767,None, None, None, None, u'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
-(u'RadioButton',u'Help',u'Y',None, None, None, None, u'Text',None, u'The help strings used with the button. The text is optional.',),
-(u'Registry',u'Name',u'Y',None, None, None, None, u'Formatted',None, u'The registry value name.',),
-(u'Registry',u'Value',u'Y',None, None, None, None, u'Formatted',None, u'The registry value.',),
-(u'Registry',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table referencing component that controls the installing of the registry value.',),
-(u'Registry',u'Key',u'N',None, None, None, None, u'RegPath',None, u'The key for the registry value.',),
-(u'Registry',u'Registry',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'Registry',u'Root',u'N',-1,3,None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.',),
-(u'RegLocator',u'Name',u'Y',None, None, None, None, u'Formatted',None, u'The registry value name.',),
-(u'RegLocator',u'Type',u'Y',0,18,None, None, None, None, u'An integer value that determines if the registry value is a filename or a directory location or to be used as is w/o interpretation.',),
-(u'RegLocator',u'Signature_',u'N',None, None, None, None, u'Identifier',None, u'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table. If the type is 0, the registry values refers a directory, and _Signature is not a foreign key.',),
-(u'RegLocator',u'Key',u'N',None, None, None, None, u'RegPath',None, u'The key for the registry value.',),
-(u'RegLocator',u'Root',u'N',0,3,None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum.',),
-(u'RemoveFile',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key referencing Component that controls the file to be removed.',),
-(u'RemoveFile',u'FileKey',u'N',None, None, None, None, u'Identifier',None, u'Primary key used to identify a particular file entry',),
-(u'RemoveFile',u'FileName',u'Y',None, None, None, None, u'WildCardFilename',None, u'Name of the file to be removed.',),
-(u'RemoveFile',u'DirProperty',u'N',None, None, None, None, u'Identifier',None, u'Name of a property whose value is assumed to resolve to the full pathname to the folder of the file to be removed.',),
-(u'RemoveFile',u'InstallMode',u'N',None, None, None, None, None, u'1;2;3',u'Installation option, one of iimEnum.',),
-(u'RemoveIniFile',u'Action',u'N',None, None, None, None, None, u'2;4',u'The type of modification to be made, one of iifEnum.',),
-(u'RemoveIniFile',u'Value',u'Y',None, None, None, None, u'Formatted',None, u'The value to be deleted. The value is required when Action is iifIniRemoveTag',),
-(u'RemoveIniFile',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table referencing component that controls the deletion of the .INI value.',),
-(u'RemoveIniFile',u'FileName',u'N',None, None, None, None, u'Filename',None, u'The .INI file name in which to delete the information',),
-(u'RemoveIniFile',u'DirProperty',u'Y',None, None, None, None, u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the .INI file is.',),
-(u'RemoveIniFile',u'Key',u'N',None, None, None, None, u'Formatted',None, u'The .INI file key below Section.',),
-(u'RemoveIniFile',u'Section',u'N',None, None, None, None, u'Formatted',None, u'The .INI file Section.',),
-(u'RemoveIniFile',u'RemoveIniFile',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'RemoveRegistry',u'Name',u'Y',None, None, None, None, u'Formatted',None, u'The registry value name.',),
-(u'RemoveRegistry',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table referencing component that controls the deletion of the registry value.',),
-(u'RemoveRegistry',u'Key',u'N',None, None, None, None, u'RegPath',None, u'The key for the registry value.',),
-(u'RemoveRegistry',u'Root',u'N',-1,3,None, None, None, None, u'The predefined root key for the registry value, one of rrkEnum',),
-(u'RemoveRegistry',u'RemoveRegistry',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'ReserveCost',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Reserve a specified amount of space if this component is to be installed.',),
-(u'ReserveCost',u'ReserveFolder',u'Y',None, None, None, None, u'Identifier',None, u'Name of a property whose value is assumed to resolve to the full path to the destination directory',),
-(u'ReserveCost',u'ReserveKey',u'N',None, None, None, None, u'Identifier',None, u'Primary key that uniquely identifies a particular ReserveCost record',),
-(u'ReserveCost',u'ReserveLocal',u'N',0,2147483647,None, None, None, None, u'Disk space to reserve if linked component is installed locally.',),
-(u'ReserveCost',u'ReserveSource',u'N',0,2147483647,None, None, None, None, u'Disk space to reserve if linked component is installed to run from the source location.',),
-(u'SelfReg',u'File_',u'N',None, None, u'File',1,u'Identifier',None, u'Foreign key into the File table denoting the module that needs to be registered.',),
-(u'SelfReg',u'Cost',u'Y',0,32767,None, None, None, None, u'The cost of registering the module.',),
-(u'ServiceControl',u'Name',u'N',None, None, None, None, u'Formatted',None, u'Name of a service. /, \\, comma and space are invalid',),
-(u'ServiceControl',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Required foreign key into the Component Table that controls the startup of the service',),
-(u'ServiceControl',u'Event',u'N',0,187,None, None, None, None, u'Bit field: Install: 0x1 = Start, 0x2 = Stop, 0x8 = Delete, Uninstall: 0x10 = Start, 0x20 = Stop, 0x80 = Delete',),
-(u'ServiceControl',u'ServiceControl',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'ServiceControl',u'Arguments',u'Y',None, None, None, None, u'Formatted',None, u'Arguments for the service. Separate by [~].',),
-(u'ServiceControl',u'Wait',u'Y',0,1,None, None, None, None, u'Boolean for whether to wait for the service to fully start',),
-(u'ServiceInstall',u'Name',u'N',None, None, None, None, u'Formatted',None, u'Internal Name of the Service',),
-(u'ServiceInstall',u'Description',u'Y',None, None, None, None, u'Text',None, u'Description of service.',),
-(u'ServiceInstall',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Required foreign key into the Component Table that controls the startup of the service',),
-(u'ServiceInstall',u'Arguments',u'Y',None, None, None, None, u'Formatted',None, u'Arguments to include in every start of the service, passed to WinMain',),
-(u'ServiceInstall',u'ServiceInstall',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'ServiceInstall',u'Dependencies',u'Y',None, None, None, None, u'Formatted',None, u'Other services this depends on to start. Separate by [~], and end with [~][~]',),
-(u'ServiceInstall',u'DisplayName',u'Y',None, None, None, None, u'Formatted',None, u'External Name of the Service',),
-(u'ServiceInstall',u'ErrorControl',u'N',-2147483647,2147483647,None, None, None, None, u'Severity of error if service fails to start',),
-(u'ServiceInstall',u'LoadOrderGroup',u'Y',None, None, None, None, u'Formatted',None, u'LoadOrderGroup',),
-(u'ServiceInstall',u'Password',u'Y',None, None, None, None, u'Formatted',None, u'password to run service with. (with StartName)',),
-(u'ServiceInstall',u'ServiceType',u'N',-2147483647,2147483647,None, None, None, None, u'Type of the service',),
-(u'ServiceInstall',u'StartName',u'Y',None, None, None, None, u'Formatted',None, u'User or object name to run service as',),
-(u'ServiceInstall',u'StartType',u'N',0,4,None, None, None, None, u'Type of the service',),
-(u'Shortcut',u'Name',u'N',None, None, None, None, u'Filename',None, u'The name of the shortcut to be created.',),
-(u'Shortcut',u'Description',u'Y',None, None, None, None, u'Text',None, u'The description for the shortcut.',),
-(u'Shortcut',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.',),
-(u'Shortcut',u'Icon_',u'Y',None, None, u'Icon',1,u'Identifier',None, u'Foreign key into the File table denoting the external icon file for the shortcut.',),
-(u'Shortcut',u'IconIndex',u'Y',-32767,32767,None, None, None, None, u'The icon index for the shortcut.',),
-(u'Shortcut',u'Directory_',u'N',None, None, u'Directory',1,u'Identifier',None, u'Foreign key into the Directory table denoting the directory where the shortcut file is created.',),
-(u'Shortcut',u'Target',u'N',None, None, None, None, u'Shortcut',None, u'The shortcut target. This is usually a property that is expanded to a file or a folder that the shortcut points to.',),
-(u'Shortcut',u'Arguments',u'Y',None, None, None, None, u'Formatted',None, u'The command-line arguments for the shortcut.',),
-(u'Shortcut',u'Shortcut',u'N',None, None, None, None, u'Identifier',None, u'Primary key, non-localized token.',),
-(u'Shortcut',u'Hotkey',u'Y',0,32767,None, None, None, None, u'The hotkey for the shortcut. It has the virtual-key code for the key in the low-order byte, and the modifier flags in the high-order byte. ',),
-(u'Shortcut',u'ShowCmd',u'Y',None, None, None, None, None, u'1;3;7',u'The show command for the application window.The following values may be used.',),
-(u'Shortcut',u'WkDir',u'Y',None, None, None, None, u'Identifier',None, u'Name of property defining location of working directory.',),
-(u'Signature',u'FileName',u'N',None, None, None, None, u'Filename',None, u'The name of the file. This may contain a "short name|long name" pair.',),
-(u'Signature',u'Signature',u'N',None, None, None, None, u'Identifier',None, u'The table key. The Signature represents a unique file signature.',),
-(u'Signature',u'Languages',u'Y',None, None, None, None, u'Language',None, u'The languages supported by the file.',),
-(u'Signature',u'MaxDate',u'Y',0,2147483647,None, None, None, None, u'The maximum creation date of the file.',),
-(u'Signature',u'MaxSize',u'Y',0,2147483647,None, None, None, None, u'The maximum size of the file. ',),
-(u'Signature',u'MaxVersion',u'Y',None, None, None, None, u'Text',None, u'The maximum version of the file.',),
-(u'Signature',u'MinDate',u'Y',0,2147483647,None, None, None, None, u'The minimum creation date of the file.',),
-(u'Signature',u'MinSize',u'Y',0,2147483647,None, None, None, None, u'The minimum size of the file.',),
-(u'Signature',u'MinVersion',u'Y',None, None, None, None, u'Text',None, u'The minimum version of the file.',),
-(u'TextStyle',u'TextStyle',u'N',None, None, None, None, u'Identifier',None, u'Name of the style. The primary key of this table. This name is embedded in the texts to indicate a style change.',),
-(u'TextStyle',u'Color',u'Y',0,16777215,None, None, None, None, u'A long integer indicating the color of the string in the RGB format (Red, Green, Blue each 0-255, RGB = R + 256*G + 256^2*B).',),
-(u'TextStyle',u'FaceName',u'N',None, None, None, None, u'Text',None, u'A string indicating the name of the font used. Required. The string must be at most 31 characters long.',),
-(u'TextStyle',u'Size',u'N',0,32767,None, None, None, None, u'The size of the font used. This size is given in our units (1/12 of the system font height). Assuming that the system font is set to 12 point size, this is equivalent to the point size.',),
-(u'TextStyle',u'StyleBits',u'Y',0,15,None, None, None, None, u'A combination of style bits.',),
-(u'TypeLib',u'Description',u'Y',None, None, None, None, u'Text',None, None, ),
-(u'TypeLib',u'Feature_',u'N',None, None, u'Feature',1,u'Identifier',None, u'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the type library to be operational.',),
-(u'TypeLib',u'Component_',u'N',None, None, u'Component',1,u'Identifier',None, u'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
-(u'TypeLib',u'Directory_',u'Y',None, None, u'Directory',1,u'Identifier',None, u'Optional. The foreign key into the Directory table denoting the path to the help file for the type library.',),
-(u'TypeLib',u'Language',u'N',0,32767,None, None, None, None, u'The language of the library.',),
-(u'TypeLib',u'Version',u'Y',0,16777215,None, None, None, None, u'The version of the library. The minor version is in the lower 8 bits of the integer. The major version is in the next 16 bits. ',),
-(u'TypeLib',u'Cost',u'Y',0,2147483647,None, None, None, None, u'The cost associated with the registration of the typelib. This column is currently optional.',),
-(u'TypeLib',u'LibID',u'N',None, None, None, None, u'Guid',None, u'The GUID that represents the library.',),
-(u'UIText',u'Text',u'Y',None, None, None, None, u'Text',None, u'The localized version of the string.',),
-(u'UIText',u'Key',u'N',None, None, None, None, u'Identifier',None, u'A unique key that identifies the particular string.',),
-(u'Upgrade',u'Attributes',u'N',0,2147483647,None, None, None, None, u'The attributes of this product set.',),
-(u'Upgrade',u'Language',u'Y',None, None, None, None, u'Language',None, u'A comma-separated list of languages for either products in this set or products not in this set.',),
-(u'Upgrade',u'ActionProperty',u'N',None, None, None, None, u'UpperCase',None, u'The property to set when a product in this set is found.',),
-(u'Upgrade',u'Remove',u'Y',None, None, None, None, u'Formatted',None, u'The list of features to remove when uninstalling a product from this set. The default is "ALL".',),
-(u'Upgrade',u'UpgradeCode',u'N',None, None, None, None, u'Guid',None, u'The UpgradeCode GUID belonging to the products in this set.',),
-(u'Upgrade',u'VersionMax',u'Y',None, None, None, None, u'Text',None, u'The maximum ProductVersion of the products in this set. The set may or may not include products with this particular version.',),
-(u'Upgrade',u'VersionMin',u'Y',None, None, None, None, u'Text',None, u'The minimum ProductVersion of the products in this set. The set may or may not include products with this particular version.',),
-(u'Verb',u'Sequence',u'Y',0,32767,None, None, None, None, u'Order within the verbs for a particular extension. Also used simply to specify the default verb.',),
-(u'Verb',u'Argument',u'Y',None, None, None, None, u'Formatted',None, u'Optional value for the command arguments.',),
-(u'Verb',u'Extension_',u'N',None, None, u'Extension',1,u'Text',None, u'The extension associated with the table row.',),
-(u'Verb',u'Verb',u'N',None, None, None, None, u'Text',None, u'The verb for the command.',),
-(u'Verb',u'Command',u'Y',None, None, None, None, u'Formatted',None, u'The command text.',),
+('_Validation','Table','N',None, None, None, None, 'Identifier',None, 'Name of table',),
+('_Validation','Column','N',None, None, None, None, 'Identifier',None, 'Name of column',),
+('_Validation','Description','Y',None, None, None, None, 'Text',None, 'Description of column',),
+('_Validation','Set','Y',None, None, None, None, 'Text',None, 'Set of values that are permitted',),
+('_Validation','Category','Y',None, None, None, None, None, 'Text;Formatted;Template;Condition;Guid;Path;Version;Language;Identifier;Binary;UpperCase;LowerCase;Filename;Paths;AnyPath;WildCardFilename;RegPath;KeyFormatted;CustomSource;Property;Cabinet;Shortcut;URL','String category',),
+('_Validation','KeyColumn','Y',1,32,None, None, None, None, 'Column to which foreign key connects',),
+('_Validation','KeyTable','Y',None, None, None, None, 'Identifier',None, 'For foreign key, Name of table to which data must link',),
+('_Validation','MaxValue','Y',-2147483647,2147483647,None, None, None, None, 'Maximum value allowed',),
+('_Validation','MinValue','Y',-2147483647,2147483647,None, None, None, None, 'Minimum value allowed',),
+('_Validation','Nullable','N',None, None, None, None, None, 'Y;N;@','Whether the column is nullable',),
+('ActionText','Description','Y',None, None, None, None, 'Text',None, 'Localized description displayed in progress dialog and log when action is executing.',),
+('ActionText','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to be described.',),
+('ActionText','Template','Y',None, None, None, None, 'Template',None, 'Optional localized format template used to format action data records for display during action execution.',),
+('AdminExecuteSequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('AdminExecuteSequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('AdminExecuteSequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('Condition','Condition','Y',None, None, None, None, 'Condition',None, 'Expression evaluated to determine if Level in the Feature table is to change.',),
+('Condition','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Reference to a Feature entry in Feature table.',),
+('Condition','Level','N',0,32767,None, None, None, None, 'New selection Level to set in Feature table if Condition evaluates to TRUE.',),
+('AdminUISequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('AdminUISequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('AdminUISequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('AdvtExecuteSequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('AdvtExecuteSequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('AdvtExecuteSequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('AdvtUISequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('AdvtUISequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('AdvtUISequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('AppId','AppId','N',None, None, None, None, 'Guid',None, None, ),
+('AppId','ActivateAtStorage','Y',0,1,None, None, None, None, None, ),
+('AppId','DllSurrogate','Y',None, None, None, None, 'Text',None, None, ),
+('AppId','LocalService','Y',None, None, None, None, 'Text',None, None, ),
+('AppId','RemoteServerName','Y',None, None, None, None, 'Formatted',None, None, ),
+('AppId','RunAsInteractiveUser','Y',0,1,None, None, None, None, None, ),
+('AppId','ServiceParameters','Y',None, None, None, None, 'Text',None, None, ),
+('AppSearch','Property','N',None, None, None, None, 'Identifier',None, 'The property associated with a Signature',),
+('AppSearch','Signature_','N',None, None, 'Signature;RegLocator;IniLocator;DrLocator;CompLocator',1,'Identifier',None, 'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.',),
+('Property','Property','N',None, None, None, None, 'Identifier',None, 'Name of property, uppercase if settable by launcher or loader.',),
+('Property','Value','N',None, None, None, None, 'Text',None, 'String value for property. Never null or empty.',),
+('BBControl','Type','N',None, None, None, None, 'Identifier',None, 'The type of the control.',),
+('BBControl','Y','N',0,32767,None, None, None, None, 'Vertical coordinate of the upper left corner of the bounding rectangle of the control.',),
+('BBControl','Text','Y',None, None, None, None, 'Text',None, 'A string used to set the initial text contained within a control (if appropriate).',),
+('BBControl','BBControl','N',None, None, None, None, 'Identifier',None, 'Name of the control. This name must be unique within a billboard, but can repeat on different billboard.',),
+('BBControl','Attributes','Y',0,2147483647,None, None, None, None, 'A 32-bit word that specifies the attribute flags to be applied to this control.',),
+('BBControl','Billboard_','N',None, None, 'Billboard',1,'Identifier',None, 'External key to the Billboard table, name of the billboard.',),
+('BBControl','Height','N',0,32767,None, None, None, None, 'Height of the bounding rectangle of the control.',),
+('BBControl','Width','N',0,32767,None, None, None, None, 'Width of the bounding rectangle of the control.',),
+('BBControl','X','N',0,32767,None, None, None, None, 'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.',),
+('Billboard','Action','Y',None, None, None, None, 'Identifier',None, 'The name of an action. The billboard is displayed during the progress messages received from this action.',),
+('Billboard','Billboard','N',None, None, None, None, 'Identifier',None, 'Name of the billboard.',),
+('Billboard','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'An external key to the Feature Table. The billboard is shown only if this feature is being installed.',),
+('Billboard','Ordering','Y',0,32767,None, None, None, None, 'A positive integer. If there is more than one billboard corresponding to an action they will be shown in the order defined by this column.',),
+('Feature','Description','Y',None, None, None, None, 'Text',None, 'Longer descriptive text describing a visible feature item.',),
+('Feature','Attributes','N',None, None, None, None, None, '0;1;2;4;5;6;8;9;10;16;17;18;20;21;22;24;25;26;32;33;34;36;37;38;48;49;50;52;53;54','Feature attributes',),
+('Feature','Feature','N',None, None, None, None, 'Identifier',None, 'Primary key used to identify a particular feature record.',),
+('Feature','Directory_','Y',None, None, 'Directory',1,'UpperCase',None, 'The name of the Directory that can be configured by the UI. A non-null value will enable the browse button.',),
+('Feature','Level','N',0,32767,None, None, None, None, 'The install level at which record will be initially selected. An install level of 0 will disable an item and prevent its display.',),
+('Feature','Title','Y',None, None, None, None, 'Text',None, 'Short text identifying a visible feature item.',),
+('Feature','Display','Y',0,32767,None, None, None, None, 'Numeric sort order, used to force a specific display ordering.',),
+('Feature','Feature_Parent','Y',None, None, 'Feature',1,'Identifier',None, 'Optional key of a parent record in the same table. If the parent is not selected, then the record will not be installed. Null indicates a root item.',),
+('Binary','Name','N',None, None, None, None, 'Identifier',None, 'Unique key identifying the binary data.',),
+('Binary','Data','N',None, None, None, None, 'Binary',None, 'The unformatted binary data.',),
+('BindImage','File_','N',None, None, 'File',1,'Identifier',None, 'The index into the File table. This must be an executable file.',),
+('BindImage','Path','Y',None, None, None, None, 'Paths',None, 'A list of ; delimited paths that represent the paths to be searched for the import DLLS. The list is usually a list of properties each enclosed within square brackets [] .',),
+('File','Sequence','N',1,32767,None, None, None, None, 'Sequence with respect to the media images; order must track cabinet order.',),
+('File','Attributes','Y',0,32767,None, None, None, None, 'Integer containing bit flags representing file attributes (with the decimal value of each bit position in parentheses)',),
+('File','File','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token, must match identifier in cabinet. For uncompressed files, this field is ignored.',),
+('File','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key referencing Component that controls the file.',),
+('File','FileName','N',None, None, None, None, 'Filename',None, 'File name used for installation, may be localized. This may contain a "short name|long name" pair.',),
+('File','FileSize','N',0,2147483647,None, None, None, None, 'Size of file in bytes (integer).',),
+('File','Language','Y',None, None, None, None, 'Language',None, 'List of decimal language Ids, comma-separated if more than one.',),
+('File','Version','Y',None, None, 'File',1,'Version',None, 'Version string for versioned files; Blank for unversioned files.',),
+('CCPSearch','Signature_','N',None, None, 'Signature;RegLocator;IniLocator;DrLocator;CompLocator',1,'Identifier',None, 'The Signature_ represents a unique file signature and is also the foreign key in the Signature, RegLocator, IniLocator, CompLocator and the DrLocator tables.',),
+('CheckBox','Property','N',None, None, None, None, 'Identifier',None, 'A named property to be tied to the item.',),
+('CheckBox','Value','Y',None, None, None, None, 'Formatted',None, 'The value string associated with the item.',),
+('Class','Description','Y',None, None, None, None, 'Text',None, 'Localized description for the Class.',),
+('Class','Attributes','Y',None, 32767,None, None, None, None, 'Class registration attributes.',),
+('Class','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.',),
+('Class','AppId_','Y',None, None, 'AppId',1,'Guid',None, 'Optional AppID containing DCOM information for associated application (string GUID).',),
+('Class','Argument','Y',None, None, None, None, 'Formatted',None, 'optional argument for LocalServers.',),
+('Class','CLSID','N',None, None, None, None, 'Guid',None, 'The CLSID of an OLE factory.',),
+('Class','Component_','N',None, None, 'Component',1,'Identifier',None, 'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
+('Class','Context','N',None, None, None, None, 'Identifier',None, 'The numeric server context for this server. CLSCTX_xxxx',),
+('Class','DefInprocHandler','Y',None, None, None, None, 'Filename','1;2;3','Optional default inproc handler. Only optionally provided if Context=CLSCTX_LOCAL_SERVER. Typically "ole32.dll" or "mapi32.dll"',),
+('Class','FileTypeMask','Y',None, None, None, None, 'Text',None, 'Optional string containing information for the HKCRthis CLSID) key. If multiple patterns exist, they must be delimited by a semicolon, and numeric subkeys will be generated: 0,1,2...',),
+('Class','Icon_','Y',None, None, 'Icon',1,'Identifier',None, 'Optional foreign key into the Icon Table, specifying the icon file associated with this CLSID. Will be written under the DefaultIcon key.',),
+('Class','IconIndex','Y',-32767,32767,None, None, None, None, 'Optional icon index.',),
+('Class','ProgId_Default','Y',None, None, 'ProgId',1,'Text',None, 'Optional ProgId associated with this CLSID.',),
+('Component','Condition','Y',None, None, None, None, 'Condition',None, "A conditional statement that will disable this component if the specified condition evaluates to the 'True' state. If a component is disabled, it will not be installed, regardless of the 'Action' state associated with the component.",),
+('Component','Attributes','N',None, None, None, None, None, None, 'Remote execution option, one of irsEnum',),
+('Component','Component','N',None, None, None, None, 'Identifier',None, 'Primary key used to identify a particular component record.',),
+('Component','ComponentId','Y',None, None, None, None, 'Guid',None, 'A string GUID unique to this component, version, and language.',),
+('Component','Directory_','N',None, None, 'Directory',1,'Identifier',None, 'Required key of a Directory table record. This is actually a property name whose value contains the actual path, set either by the AppSearch action or with the default setting obtained from the Directory table.',),
+('Component','KeyPath','Y',None, None, 'File;Registry;ODBCDataSource',1,'Identifier',None, 'Either the primary key into the File table, Registry table, or ODBCDataSource table. This extract path is stored when the component is installed, and is used to detect the presence of the component and to return the path to it.',),
+('Icon','Name','N',None, None, None, None, 'Identifier',None, 'Primary key. Name of the icon file.',),
+('Icon','Data','N',None, None, None, None, 'Binary',None, 'Binary stream. The binary icon data in PE (.DLL or .EXE) or icon (.ICO) format.',),
+('ProgId','Description','Y',None, None, None, None, 'Text',None, 'Localized description for the Program identifier.',),
+('ProgId','Icon_','Y',None, None, 'Icon',1,'Identifier',None, 'Optional foreign key into the Icon Table, specifying the icon file associated with this ProgId. Will be written under the DefaultIcon key.',),
+('ProgId','IconIndex','Y',-32767,32767,None, None, None, None, 'Optional icon index.',),
+('ProgId','ProgId','N',None, None, None, None, 'Text',None, 'The Program Identifier. Primary key.',),
+('ProgId','Class_','Y',None, None, 'Class',1,'Guid',None, 'The CLSID of an OLE factory corresponding to the ProgId.',),
+('ProgId','ProgId_Parent','Y',None, None, 'ProgId',1,'Text',None, 'The Parent Program Identifier. If specified, the ProgId column becomes a version independent prog id.',),
+('ComboBox','Text','Y',None, None, None, None, 'Formatted',None, 'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
+('ComboBox','Property','N',None, None, None, None, 'Identifier',None, 'A named property to be tied to this item. All the items tied to the same property become part of the same combobox.',),
+('ComboBox','Value','N',None, None, None, None, 'Formatted',None, 'The value string associated with this item. Selecting the line will set the associated property to this value.',),
+('ComboBox','Order','N',1,32767,None, None, None, None, 'A positive integer used to determine the ordering of the items within one list.\tThe integers do not have to be consecutive.',),
+('CompLocator','Type','Y',0,1,None, None, None, None, 'A boolean value that determines if the registry value is a filename or a directory location.',),
+('CompLocator','Signature_','N',None, None, None, None, 'Identifier',None, 'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
+('CompLocator','ComponentId','N',None, None, None, None, 'Guid',None, 'A string GUID unique to this component, version, and language.',),
+('Complus','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key referencing Component that controls the ComPlus component.',),
+('Complus','ExpType','Y',0,32767,None, None, None, None, 'ComPlus component attributes.',),
+('Directory','Directory','N',None, None, None, None, 'Identifier',None, 'Unique identifier for directory entry, primary key. If a property by this name is defined, it contains the full path to the directory.',),
+('Directory','DefaultDir','N',None, None, None, None, 'DefaultDir',None, "The default sub-path under parent's path.",),
+('Directory','Directory_Parent','Y',None, None, 'Directory',1,'Identifier',None, 'Reference to the entry in this table specifying the default parent directory. A record parented to itself or with a Null parent represents a root of the install tree.',),
+('Control','Type','N',None, None, None, None, 'Identifier',None, 'The type of the control.',),
+('Control','Y','N',0,32767,None, None, None, None, 'Vertical coordinate of the upper left corner of the bounding rectangle of the control.',),
+('Control','Text','Y',None, None, None, None, 'Formatted',None, 'A string used to set the initial text contained within a control (if appropriate).',),
+('Control','Property','Y',None, None, None, None, 'Identifier',None, 'The name of a defined property to be linked to this control. ',),
+('Control','Attributes','Y',0,2147483647,None, None, None, None, 'A 32-bit word that specifies the attribute flags to be applied to this control.',),
+('Control','Height','N',0,32767,None, None, None, None, 'Height of the bounding rectangle of the control.',),
+('Control','Width','N',0,32767,None, None, None, None, 'Width of the bounding rectangle of the control.',),
+('Control','X','N',0,32767,None, None, None, None, 'Horizontal coordinate of the upper left corner of the bounding rectangle of the control.',),
+('Control','Control','N',None, None, None, None, 'Identifier',None, 'Name of the control. This name must be unique within a dialog, but can repeat on different dialogs. ',),
+('Control','Control_Next','Y',None, None, 'Control',2,'Identifier',None, 'The name of an other control on the same dialog. This link defines the tab order of the controls. The links have to form one or more cycles!',),
+('Control','Dialog_','N',None, None, 'Dialog',1,'Identifier',None, 'External key to the Dialog table, name of the dialog.',),
+('Control','Help','Y',None, None, None, None, 'Text',None, 'The help strings used with the button. The text is optional. ',),
+('Dialog','Attributes','Y',0,2147483647,None, None, None, None, 'A 32-bit word that specifies the attribute flags to be applied to this dialog.',),
+('Dialog','Height','N',0,32767,None, None, None, None, 'Height of the bounding rectangle of the dialog.',),
+('Dialog','Width','N',0,32767,None, None, None, None, 'Width of the bounding rectangle of the dialog.',),
+('Dialog','Dialog','N',None, None, None, None, 'Identifier',None, 'Name of the dialog.',),
+('Dialog','Control_Cancel','Y',None, None, 'Control',2,'Identifier',None, 'Defines the cancel control. Hitting escape or clicking on the close icon on the dialog is equivalent to pushing this button.',),
+('Dialog','Control_Default','Y',None, None, 'Control',2,'Identifier',None, 'Defines the default control. Hitting return is equivalent to pushing this button.',),
+('Dialog','Control_First','N',None, None, 'Control',2,'Identifier',None, 'Defines the control that has the focus when the dialog is created.',),
+('Dialog','HCentering','N',0,100,None, None, None, None, 'Horizontal position of the dialog on a 0-100 scale. 0 means left end, 100 means right end of the screen, 50 center.',),
+('Dialog','Title','Y',None, None, None, None, 'Formatted',None, "A text string specifying the title to be displayed in the title bar of the dialog's window.",),
+('Dialog','VCentering','N',0,100,None, None, None, None, 'Vertical position of the dialog on a 0-100 scale. 0 means top end, 100 means bottom end of the screen, 50 center.',),
+('ControlCondition','Action','N',None, None, None, None, None, 'Default;Disable;Enable;Hide;Show','The desired action to be taken on the specified control.',),
+('ControlCondition','Condition','N',None, None, None, None, 'Condition',None, 'A standard conditional statement that specifies under which conditions the action should be triggered.',),
+('ControlCondition','Dialog_','N',None, None, 'Dialog',1,'Identifier',None, 'A foreign key to the Dialog table, name of the dialog.',),
+('ControlCondition','Control_','N',None, None, 'Control',2,'Identifier',None, 'A foreign key to the Control table, name of the control.',),
+('ControlEvent','Condition','Y',None, None, None, None, 'Condition',None, 'A standard conditional statement that specifies under which conditions an event should be triggered.',),
+('ControlEvent','Ordering','Y',0,2147483647,None, None, None, None, 'An integer used to order several events tied to the same control. Can be left blank.',),
+('ControlEvent','Argument','N',None, None, None, None, 'Formatted',None, 'A value to be used as a modifier when triggering a particular event.',),
+('ControlEvent','Dialog_','N',None, None, 'Dialog',1,'Identifier',None, 'A foreign key to the Dialog table, name of the dialog.',),
+('ControlEvent','Control_','N',None, None, 'Control',2,'Identifier',None, 'A foreign key to the Control table, name of the control',),
+('ControlEvent','Event','N',None, None, None, None, 'Formatted',None, 'An identifier that specifies the type of the event that should take place when the user interacts with control specified by the first two entries.',),
+('CreateFolder','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table.',),
+('CreateFolder','Directory_','N',None, None, 'Directory',1,'Identifier',None, 'Primary key, could be foreign key into the Directory table.',),
+('CustomAction','Type','N',1,16383,None, None, None, None, 'The numeric custom action type, consisting of source location, code type, entry, option flags.',),
+('CustomAction','Action','N',None, None, None, None, 'Identifier',None, 'Primary key, name of action, normally appears in sequence table unless private use.',),
+('CustomAction','Source','Y',None, None, None, None, 'CustomSource',None, 'The table reference of the source of the code.',),
+('CustomAction','Target','Y',None, None, None, None, 'Formatted',None, 'Excecution parameter, depends on the type of custom action',),
+('DrLocator','Signature_','N',None, None, None, None, 'Identifier',None, 'The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
+('DrLocator','Path','Y',None, None, None, None, 'AnyPath',None, 'The path on the user system. This is a either a subpath below the value of the Parent or a full path. The path may contain properties enclosed within [ ] that will be expanded.',),
+('DrLocator','Depth','Y',0,32767,None, None, None, None, 'The depth below the path to which the Signature_ is recursively searched. If absent, the depth is assumed to be 0.',),
+('DrLocator','Parent','Y',None, None, None, None, 'Identifier',None, 'The parent file signature. It is also a foreign key in the Signature table. If null and the Path column does not expand to a full path, then all the fixed drives of the user system are searched using the Path.',),
+('DuplicateFile','File_','N',None, None, 'File',1,'Identifier',None, 'Foreign key referencing the source file to be duplicated.',),
+('DuplicateFile','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key referencing Component that controls the duplicate file.',),
+('DuplicateFile','DestFolder','Y',None, None, None, None, 'Identifier',None, 'Name of a property whose value is assumed to resolve to the full pathname to a destination folder.',),
+('DuplicateFile','DestName','Y',None, None, None, None, 'Filename',None, 'Filename to be given to the duplicate file.',),
+('DuplicateFile','FileKey','N',None, None, None, None, 'Identifier',None, 'Primary key used to identify a particular file entry',),
+('Environment','Name','N',None, None, None, None, 'Text',None, 'The name of the environmental value.',),
+('Environment','Value','Y',None, None, None, None, 'Formatted',None, 'The value to set in the environmental settings.',),
+('Environment','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table referencing component that controls the installing of the environmental value.',),
+('Environment','Environment','N',None, None, None, None, 'Identifier',None, 'Unique identifier for the environmental variable setting',),
+('Error','Error','N',0,32767,None, None, None, None, 'Integer error number, obtained from header file IError(...) macros.',),
+('Error','Message','Y',None, None, None, None, 'Template',None, 'Error formatting template, obtained from user ed. or localizers.',),
+('EventMapping','Dialog_','N',None, None, 'Dialog',1,'Identifier',None, 'A foreign key to the Dialog table, name of the Dialog.',),
+('EventMapping','Control_','N',None, None, 'Control',2,'Identifier',None, 'A foreign key to the Control table, name of the control.',),
+('EventMapping','Event','N',None, None, None, None, 'Identifier',None, 'An identifier that specifies the type of the event that the control subscribes to.',),
+('EventMapping','Attribute','N',None, None, None, None, 'Identifier',None, 'The name of the control attribute, that is set when this event is received.',),
+('Extension','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the CLSID factory to be operational.',),
+('Extension','Component_','N',None, None, 'Component',1,'Identifier',None, 'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
+('Extension','Extension','N',None, None, None, None, 'Text',None, 'The extension associated with the table row.',),
+('Extension','MIME_','Y',None, None, 'MIME',1,'Text',None, 'Optional Context identifier, typically "type/format" associated with the extension',),
+('Extension','ProgId_','Y',None, None, 'ProgId',1,'Text',None, 'Optional ProgId associated with this extension.',),
+('MIME','CLSID','Y',None, None, None, None, 'Guid',None, 'Optional associated CLSID.',),
+('MIME','ContentType','N',None, None, None, None, 'Text',None, 'Primary key. Context identifier, typically "type/format".',),
+('MIME','Extension_','N',None, None, 'Extension',1,'Text',None, 'Optional associated extension (without dot)',),
+('FeatureComponents','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Foreign key into Feature table.',),
+('FeatureComponents','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into Component table.',),
+('FileSFPCatalog','File_','N',None, None, 'File',1,'Identifier',None, 'File associated with the catalog',),
+('FileSFPCatalog','SFPCatalog_','N',None, None, 'SFPCatalog',1,'Filename',None, 'Catalog associated with the file',),
+('SFPCatalog','SFPCatalog','N',None, None, None, None, 'Filename',None, 'File name for the catalog.',),
+('SFPCatalog','Catalog','N',None, None, None, None, 'Binary',None, 'SFP Catalog',),
+('SFPCatalog','Dependency','Y',None, None, None, None, 'Formatted',None, 'Parent catalog - only used by SFP',),
+('Font','File_','N',None, None, 'File',1,'Identifier',None, 'Primary key, foreign key into File table referencing font file.',),
+('Font','FontTitle','Y',None, None, None, None, 'Text',None, 'Font name.',),
+('IniFile','Action','N',None, None, None, None, None, '0;1;3','The type of modification to be made, one of iifEnum',),
+('IniFile','Value','N',None, None, None, None, 'Formatted',None, 'The value to be written.',),
+('IniFile','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table referencing component that controls the installing of the .INI value.',),
+('IniFile','FileName','N',None, None, None, None, 'Filename',None, 'The .INI file name in which to write the information',),
+('IniFile','IniFile','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('IniFile','DirProperty','Y',None, None, None, None, 'Identifier',None, 'Foreign key into the Directory table denoting the directory where the .INI file is.',),
+('IniFile','Key','N',None, None, None, None, 'Formatted',None, 'The .INI file key below Section.',),
+('IniFile','Section','N',None, None, None, None, 'Formatted',None, 'The .INI file Section.',),
+('IniLocator','Type','Y',0,2,None, None, None, None, 'An integer value that determines if the .INI value read is a filename or a directory location or to be used as is w/o interpretation.',),
+('IniLocator','Signature_','N',None, None, None, None, 'Identifier',None, 'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table.',),
+('IniLocator','FileName','N',None, None, None, None, 'Filename',None, 'The .INI file name.',),
+('IniLocator','Key','N',None, None, None, None, 'Text',None, 'Key value (followed by an equals sign in INI file).',),
+('IniLocator','Section','N',None, None, None, None, 'Text',None, 'Section name within in file (within square brackets in INI file).',),
+('IniLocator','Field','Y',0,32767,None, None, None, None, 'The field in the .INI line. If Field is null or 0 the entire line is read.',),
+('InstallExecuteSequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('InstallExecuteSequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('InstallExecuteSequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('InstallUISequence','Action','N',None, None, None, None, 'Identifier',None, 'Name of action to invoke, either in the engine or the handler DLL.',),
+('InstallUISequence','Condition','Y',None, None, None, None, 'Condition',None, 'Optional expression which skips the action if evaluates to expFalse.If the expression syntax is invalid, the engine will terminate, returning iesBadActionData.',),
+('InstallUISequence','Sequence','Y',-4,32767,None, None, None, None, 'Number that determines the sort order in which the actions are to be executed. Leave blank to suppress action.',),
+('IsolatedComponent','Component_Application','N',None, None, 'Component',1,'Identifier',None, 'Key to Component table item for application',),
+('IsolatedComponent','Component_Shared','N',None, None, 'Component',1,'Identifier',None, 'Key to Component table item to be isolated',),
+('LaunchCondition','Description','N',None, None, None, None, 'Formatted',None, 'Localizable text to display when condition fails and install must abort.',),
+('LaunchCondition','Condition','N',None, None, None, None, 'Condition',None, 'Expression which must evaluate to TRUE in order for install to commence.',),
+('ListBox','Text','Y',None, None, None, None, 'Text',None, 'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
+('ListBox','Property','N',None, None, None, None, 'Identifier',None, 'A named property to be tied to this item. All the items tied to the same property become part of the same listbox.',),
+('ListBox','Value','N',None, None, None, None, 'Formatted',None, 'The value string associated with this item. Selecting the line will set the associated property to this value.',),
+('ListBox','Order','N',1,32767,None, None, None, None, 'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
+('ListView','Text','Y',None, None, None, None, 'Text',None, 'The visible text to be assigned to the item. Optional. If this entry or the entire column is missing, the text is the same as the value.',),
+('ListView','Property','N',None, None, None, None, 'Identifier',None, 'A named property to be tied to this item. All the items tied to the same property become part of the same listview.',),
+('ListView','Value','N',None, None, None, None, 'Identifier',None, 'The value string associated with this item. Selecting the line will set the associated property to this value.',),
+('ListView','Order','N',1,32767,None, None, None, None, 'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
+('ListView','Binary_','Y',None, None, 'Binary',1,'Identifier',None, 'The name of the icon to be displayed with the icon. The binary information is looked up from the Binary Table.',),
+('LockPermissions','Table','N',None, None, None, None, 'Identifier','Directory;File;Registry','Reference to another table name',),
+('LockPermissions','Domain','Y',None, None, None, None, 'Formatted',None, 'Domain name for user whose permissions are being set. (usually a property)',),
+('LockPermissions','LockObject','N',None, None, None, None, 'Identifier',None, 'Foreign key into Registry or File table',),
+('LockPermissions','Permission','Y',-2147483647,2147483647,None, None, None, None, 'Permission Access mask. Full Control = 268435456 (GENERIC_ALL = 0x10000000)',),
+('LockPermissions','User','N',None, None, None, None, 'Formatted',None, 'User for permissions to be set. (usually a property)',),
+('Media','Source','Y',None, None, None, None, 'Property',None, 'The property defining the location of the cabinet file.',),
+('Media','Cabinet','Y',None, None, None, None, 'Cabinet',None, 'If some or all of the files stored on the media are compressed in a cabinet, the name of that cabinet.',),
+('Media','DiskId','N',1,32767,None, None, None, None, 'Primary key, integer to determine sort order for table.',),
+('Media','DiskPrompt','Y',None, None, None, None, 'Text',None, 'Disk name: the visible text actually printed on the disk. This will be used to prompt the user when this disk needs to be inserted.',),
+('Media','LastSequence','N',0,32767,None, None, None, None, 'File sequence number for the last file for this media.',),
+('Media','VolumeLabel','Y',None, None, None, None, 'Text',None, 'The label attributed to the volume.',),
+('ModuleComponents','Component','N',None, None, 'Component',1,'Identifier',None, 'Component contained in the module.',),
+('ModuleComponents','Language','N',None, None, 'ModuleSignature',2,None, None, 'Default language ID for module (may be changed by transform).',),
+('ModuleComponents','ModuleID','N',None, None, 'ModuleSignature',1,'Identifier',None, 'Module containing the component.',),
+('ModuleSignature','Language','N',None, None, None, None, None, None, 'Default decimal language of module.',),
+('ModuleSignature','Version','N',None, None, None, None, 'Version',None, 'Version of the module.',),
+('ModuleSignature','ModuleID','N',None, None, None, None, 'Identifier',None, 'Module identifier (String.GUID).',),
+('ModuleDependency','ModuleID','N',None, None, 'ModuleSignature',1,'Identifier',None, 'Module requiring the dependency.',),
+('ModuleDependency','ModuleLanguage','N',None, None, 'ModuleSignature',2,None, None, 'Language of module requiring the dependency.',),
+('ModuleDependency','RequiredID','N',None, None, None, None, None, None, 'String.GUID of required module.',),
+('ModuleDependency','RequiredLanguage','N',None, None, None, None, None, None, 'LanguageID of the required module.',),
+('ModuleDependency','RequiredVersion','Y',None, None, None, None, 'Version',None, 'Version of the required version.',),
+('ModuleExclusion','ModuleID','N',None, None, 'ModuleSignature',1,'Identifier',None, 'String.GUID of module with exclusion requirement.',),
+('ModuleExclusion','ModuleLanguage','N',None, None, 'ModuleSignature',2,None, None, 'LanguageID of module with exclusion requirement.',),
+('ModuleExclusion','ExcludedID','N',None, None, None, None, None, None, 'String.GUID of excluded module.',),
+('ModuleExclusion','ExcludedLanguage','N',None, None, None, None, None, None, 'Language of excluded module.',),
+('ModuleExclusion','ExcludedMaxVersion','Y',None, None, None, None, 'Version',None, 'Maximum version of excluded module.',),
+('ModuleExclusion','ExcludedMinVersion','Y',None, None, None, None, 'Version',None, 'Minimum version of excluded module.',),
+('MoveFile','Component_','N',None, None, 'Component',1,'Identifier',None, 'If this component is not "selected" for installation or removal, no action will be taken on the associated MoveFile entry',),
+('MoveFile','DestFolder','N',None, None, None, None, 'Identifier',None, 'Name of a property whose value is assumed to resolve to the full path to the destination directory',),
+('MoveFile','DestName','Y',None, None, None, None, 'Filename',None, 'Name to be given to the original file after it is moved or copied. If blank, the destination file will be given the same name as the source file',),
+('MoveFile','FileKey','N',None, None, None, None, 'Identifier',None, 'Primary key that uniquely identifies a particular MoveFile record',),
+('MoveFile','Options','N',0,1,None, None, None, None, 'Integer value specifying the MoveFile operating mode, one of imfoEnum',),
+('MoveFile','SourceFolder','Y',None, None, None, None, 'Identifier',None, 'Name of a property whose value is assumed to resolve to the full path to the source directory',),
+('MoveFile','SourceName','Y',None, None, None, None, 'Text',None, "Name of the source file(s) to be moved or copied. Can contain the '*' or '?' wildcards.",),
+('MsiAssembly','Attributes','Y',None, None, None, None, None, None, 'Assembly attributes',),
+('MsiAssembly','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Foreign key into Feature table.',),
+('MsiAssembly','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into Component table.',),
+('MsiAssembly','File_Application','Y',None, None, 'File',1,'Identifier',None, 'Foreign key into File table, denoting the application context for private assemblies. Null for global assemblies.',),
+('MsiAssembly','File_Manifest','Y',None, None, 'File',1,'Identifier',None, 'Foreign key into the File table denoting the manifest file for the assembly.',),
+('MsiAssemblyName','Name','N',None, None, None, None, 'Text',None, 'The name part of the name-value pairs for the assembly name.',),
+('MsiAssemblyName','Value','N',None, None, None, None, 'Text',None, 'The value part of the name-value pairs for the assembly name.',),
+('MsiAssemblyName','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into Component table.',),
+('MsiDigitalCertificate','CertData','N',None, None, None, None, 'Binary',None, 'A certificate context blob for a signer certificate',),
+('MsiDigitalCertificate','DigitalCertificate','N',None, None, None, None, 'Identifier',None, 'A unique identifier for the row',),
+('MsiDigitalSignature','Table','N',None, None, None, None, None, 'Media','Reference to another table name (only Media table is supported)',),
+('MsiDigitalSignature','DigitalCertificate_','N',None, None, 'MsiDigitalCertificate',1,'Identifier',None, 'Foreign key to MsiDigitalCertificate table identifying the signer certificate',),
+('MsiDigitalSignature','Hash','Y',None, None, None, None, 'Binary',None, 'The encoded hash blob from the digital signature',),
+('MsiDigitalSignature','SignObject','N',None, None, None, None, 'Text',None, 'Foreign key to Media table',),
+('MsiFileHash','File_','N',None, None, 'File',1,'Identifier',None, 'Primary key, foreign key into File table referencing file with this hash',),
+('MsiFileHash','Options','N',0,32767,None, None, None, None, 'Various options and attributes for this hash.',),
+('MsiFileHash','HashPart1','N',None, None, None, None, None, None, 'Size of file in bytes (integer).',),
+('MsiFileHash','HashPart2','N',None, None, None, None, None, None, 'Size of file in bytes (integer).',),
+('MsiFileHash','HashPart3','N',None, None, None, None, None, None, 'Size of file in bytes (integer).',),
+('MsiFileHash','HashPart4','N',None, None, None, None, None, None, 'Size of file in bytes (integer).',),
+('MsiPatchHeaders','StreamRef','N',None, None, None, None, 'Identifier',None, 'Primary key. A unique identifier for the row.',),
+('MsiPatchHeaders','Header','N',None, None, None, None, 'Binary',None, 'Binary stream. The patch header, used for patch validation.',),
+('ODBCAttribute','Value','Y',None, None, None, None, 'Text',None, 'Value for ODBC driver attribute',),
+('ODBCAttribute','Attribute','N',None, None, None, None, 'Text',None, 'Name of ODBC driver attribute',),
+('ODBCAttribute','Driver_','N',None, None, 'ODBCDriver',1,'Identifier',None, 'Reference to ODBC driver in ODBCDriver table',),
+('ODBCDriver','Description','N',None, None, None, None, 'Text',None, 'Text used as registered name for driver, non-localized',),
+('ODBCDriver','File_','N',None, None, 'File',1,'Identifier',None, 'Reference to key driver file',),
+('ODBCDriver','Component_','N',None, None, 'Component',1,'Identifier',None, 'Reference to associated component',),
+('ODBCDriver','Driver','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized.internal token for driver',),
+('ODBCDriver','File_Setup','Y',None, None, 'File',1,'Identifier',None, 'Optional reference to key driver setup DLL',),
+('ODBCDataSource','Description','N',None, None, None, None, 'Text',None, 'Text used as registered name for data source',),
+('ODBCDataSource','Component_','N',None, None, 'Component',1,'Identifier',None, 'Reference to associated component',),
+('ODBCDataSource','DataSource','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized.internal token for data source',),
+('ODBCDataSource','DriverDescription','N',None, None, None, None, 'Text',None, 'Reference to driver description, may be existing driver',),
+('ODBCDataSource','Registration','N',0,1,None, None, None, None, 'Registration option: 0=machine, 1=user, others t.b.d.',),
+('ODBCSourceAttribute','Value','Y',None, None, None, None, 'Text',None, 'Value for ODBC data source attribute',),
+('ODBCSourceAttribute','Attribute','N',None, None, None, None, 'Text',None, 'Name of ODBC data source attribute',),
+('ODBCSourceAttribute','DataSource_','N',None, None, 'ODBCDataSource',1,'Identifier',None, 'Reference to ODBC data source in ODBCDataSource table',),
+('ODBCTranslator','Description','N',None, None, None, None, 'Text',None, 'Text used as registered name for translator',),
+('ODBCTranslator','File_','N',None, None, 'File',1,'Identifier',None, 'Reference to key translator file',),
+('ODBCTranslator','Component_','N',None, None, 'Component',1,'Identifier',None, 'Reference to associated component',),
+('ODBCTranslator','File_Setup','Y',None, None, 'File',1,'Identifier',None, 'Optional reference to key translator setup DLL',),
+('ODBCTranslator','Translator','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized.internal token for translator',),
+('Patch','Sequence','N',0,32767,None, None, None, None, 'Primary key, sequence with respect to the media images; order must track cabinet order.',),
+('Patch','Attributes','N',0,32767,None, None, None, None, 'Integer containing bit flags representing patch attributes',),
+('Patch','File_','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token, foreign key to File table, must match identifier in cabinet.',),
+('Patch','Header','Y',None, None, None, None, 'Binary',None, 'Binary stream. The patch header, used for patch validation.',),
+('Patch','PatchSize','N',0,2147483647,None, None, None, None, 'Size of patch in bytes (integer).',),
+('Patch','StreamRef_','Y',None, None, None, None, 'Identifier',None, 'Identifier. Foreign key to the StreamRef column of the MsiPatchHeaders table.',),
+('PatchPackage','Media_','N',0,32767,None, None, None, None, 'Foreign key to DiskId column of Media table. Indicates the disk containing the patch package.',),
+('PatchPackage','PatchId','N',None, None, None, None, 'Guid',None, 'A unique string GUID representing this patch.',),
+('PublishComponent','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Foreign key into the Feature table.',),
+('PublishComponent','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table.',),
+('PublishComponent','ComponentId','N',None, None, None, None, 'Guid',None, 'A string GUID that represents the component id that will be requested by the alien product.',),
+('PublishComponent','AppData','Y',None, None, None, None, 'Text',None, 'This is localisable Application specific data that can be associated with a Qualified Component.',),
+('PublishComponent','Qualifier','N',None, None, None, None, 'Text',None, 'This is defined only when the ComponentId column is an Qualified Component Id. This is the Qualifier for ProvideComponentIndirect.',),
+('RadioButton','Y','N',0,32767,None, None, None, None, 'The vertical coordinate of the upper left corner of the bounding rectangle of the radio button.',),
+('RadioButton','Text','Y',None, None, None, None, 'Text',None, 'The visible title to be assigned to the radio button.',),
+('RadioButton','Property','N',None, None, None, None, 'Identifier',None, 'A named property to be tied to this radio button. All the buttons tied to the same property become part of the same group.',),
+('RadioButton','Height','N',0,32767,None, None, None, None, 'The height of the button.',),
+('RadioButton','Width','N',0,32767,None, None, None, None, 'The width of the button.',),
+('RadioButton','X','N',0,32767,None, None, None, None, 'The horizontal coordinate of the upper left corner of the bounding rectangle of the radio button.',),
+('RadioButton','Value','N',None, None, None, None, 'Formatted',None, 'The value string associated with this button. Selecting the button will set the associated property to this value.',),
+('RadioButton','Order','N',1,32767,None, None, None, None, 'A positive integer used to determine the ordering of the items within one list..The integers do not have to be consecutive.',),
+('RadioButton','Help','Y',None, None, None, None, 'Text',None, 'The help strings used with the button. The text is optional.',),
+('Registry','Name','Y',None, None, None, None, 'Formatted',None, 'The registry value name.',),
+('Registry','Value','Y',None, None, None, None, 'Formatted',None, 'The registry value.',),
+('Registry','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table referencing component that controls the installing of the registry value.',),
+('Registry','Key','N',None, None, None, None, 'RegPath',None, 'The key for the registry value.',),
+('Registry','Registry','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('Registry','Root','N',-1,3,None, None, None, None, 'The predefined root key for the registry value, one of rrkEnum.',),
+('RegLocator','Name','Y',None, None, None, None, 'Formatted',None, 'The registry value name.',),
+('RegLocator','Type','Y',0,18,None, None, None, None, 'An integer value that determines if the registry value is a filename or a directory location or to be used as is w/o interpretation.',),
+('RegLocator','Signature_','N',None, None, None, None, 'Identifier',None, 'The table key. The Signature_ represents a unique file signature and is also the foreign key in the Signature table. If the type is 0, the registry values refers a directory, and _Signature is not a foreign key.',),
+('RegLocator','Key','N',None, None, None, None, 'RegPath',None, 'The key for the registry value.',),
+('RegLocator','Root','N',0,3,None, None, None, None, 'The predefined root key for the registry value, one of rrkEnum.',),
+('RemoveFile','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key referencing Component that controls the file to be removed.',),
+('RemoveFile','FileKey','N',None, None, None, None, 'Identifier',None, 'Primary key used to identify a particular file entry',),
+('RemoveFile','FileName','Y',None, None, None, None, 'WildCardFilename',None, 'Name of the file to be removed.',),
+('RemoveFile','DirProperty','N',None, None, None, None, 'Identifier',None, 'Name of a property whose value is assumed to resolve to the full pathname to the folder of the file to be removed.',),
+('RemoveFile','InstallMode','N',None, None, None, None, None, '1;2;3','Installation option, one of iimEnum.',),
+('RemoveIniFile','Action','N',None, None, None, None, None, '2;4','The type of modification to be made, one of iifEnum.',),
+('RemoveIniFile','Value','Y',None, None, None, None, 'Formatted',None, 'The value to be deleted. The value is required when Action is iifIniRemoveTag',),
+('RemoveIniFile','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table referencing component that controls the deletion of the .INI value.',),
+('RemoveIniFile','FileName','N',None, None, None, None, 'Filename',None, 'The .INI file name in which to delete the information',),
+('RemoveIniFile','DirProperty','Y',None, None, None, None, 'Identifier',None, 'Foreign key into the Directory table denoting the directory where the .INI file is.',),
+('RemoveIniFile','Key','N',None, None, None, None, 'Formatted',None, 'The .INI file key below Section.',),
+('RemoveIniFile','Section','N',None, None, None, None, 'Formatted',None, 'The .INI file Section.',),
+('RemoveIniFile','RemoveIniFile','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('RemoveRegistry','Name','Y',None, None, None, None, 'Formatted',None, 'The registry value name.',),
+('RemoveRegistry','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table referencing component that controls the deletion of the registry value.',),
+('RemoveRegistry','Key','N',None, None, None, None, 'RegPath',None, 'The key for the registry value.',),
+('RemoveRegistry','Root','N',-1,3,None, None, None, None, 'The predefined root key for the registry value, one of rrkEnum',),
+('RemoveRegistry','RemoveRegistry','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('ReserveCost','Component_','N',None, None, 'Component',1,'Identifier',None, 'Reserve a specified amount of space if this component is to be installed.',),
+('ReserveCost','ReserveFolder','Y',None, None, None, None, 'Identifier',None, 'Name of a property whose value is assumed to resolve to the full path to the destination directory',),
+('ReserveCost','ReserveKey','N',None, None, None, None, 'Identifier',None, 'Primary key that uniquely identifies a particular ReserveCost record',),
+('ReserveCost','ReserveLocal','N',0,2147483647,None, None, None, None, 'Disk space to reserve if linked component is installed locally.',),
+('ReserveCost','ReserveSource','N',0,2147483647,None, None, None, None, 'Disk space to reserve if linked component is installed to run from the source location.',),
+('SelfReg','File_','N',None, None, 'File',1,'Identifier',None, 'Foreign key into the File table denoting the module that needs to be registered.',),
+('SelfReg','Cost','Y',0,32767,None, None, None, None, 'The cost of registering the module.',),
+('ServiceControl','Name','N',None, None, None, None, 'Formatted',None, 'Name of a service. /, \\, comma and space are invalid',),
+('ServiceControl','Component_','N',None, None, 'Component',1,'Identifier',None, 'Required foreign key into the Component Table that controls the startup of the service',),
+('ServiceControl','Event','N',0,187,None, None, None, None, 'Bit field: Install: 0x1 = Start, 0x2 = Stop, 0x8 = Delete, Uninstall: 0x10 = Start, 0x20 = Stop, 0x80 = Delete',),
+('ServiceControl','ServiceControl','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('ServiceControl','Arguments','Y',None, None, None, None, 'Formatted',None, 'Arguments for the service. Separate by [~].',),
+('ServiceControl','Wait','Y',0,1,None, None, None, None, 'Boolean for whether to wait for the service to fully start',),
+('ServiceInstall','Name','N',None, None, None, None, 'Formatted',None, 'Internal Name of the Service',),
+('ServiceInstall','Description','Y',None, None, None, None, 'Text',None, 'Description of service.',),
+('ServiceInstall','Component_','N',None, None, 'Component',1,'Identifier',None, 'Required foreign key into the Component Table that controls the startup of the service',),
+('ServiceInstall','Arguments','Y',None, None, None, None, 'Formatted',None, 'Arguments to include in every start of the service, passed to WinMain',),
+('ServiceInstall','ServiceInstall','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('ServiceInstall','Dependencies','Y',None, None, None, None, 'Formatted',None, 'Other services this depends on to start. Separate by [~], and end with [~][~]',),
+('ServiceInstall','DisplayName','Y',None, None, None, None, 'Formatted',None, 'External Name of the Service',),
+('ServiceInstall','ErrorControl','N',-2147483647,2147483647,None, None, None, None, 'Severity of error if service fails to start',),
+('ServiceInstall','LoadOrderGroup','Y',None, None, None, None, 'Formatted',None, 'LoadOrderGroup',),
+('ServiceInstall','Password','Y',None, None, None, None, 'Formatted',None, 'password to run service with. (with StartName)',),
+('ServiceInstall','ServiceType','N',-2147483647,2147483647,None, None, None, None, 'Type of the service',),
+('ServiceInstall','StartName','Y',None, None, None, None, 'Formatted',None, 'User or object name to run service as',),
+('ServiceInstall','StartType','N',0,4,None, None, None, None, 'Type of the service',),
+('Shortcut','Name','N',None, None, None, None, 'Filename',None, 'The name of the shortcut to be created.',),
+('Shortcut','Description','Y',None, None, None, None, 'Text',None, 'The description for the shortcut.',),
+('Shortcut','Component_','N',None, None, 'Component',1,'Identifier',None, 'Foreign key into the Component table denoting the component whose selection gates the shortcut creation/deletion.',),
+('Shortcut','Icon_','Y',None, None, 'Icon',1,'Identifier',None, 'Foreign key into the File table denoting the external icon file for the shortcut.',),
+('Shortcut','IconIndex','Y',-32767,32767,None, None, None, None, 'The icon index for the shortcut.',),
+('Shortcut','Directory_','N',None, None, 'Directory',1,'Identifier',None, 'Foreign key into the Directory table denoting the directory where the shortcut file is created.',),
+('Shortcut','Target','N',None, None, None, None, 'Shortcut',None, 'The shortcut target. This is usually a property that is expanded to a file or a folder that the shortcut points to.',),
+('Shortcut','Arguments','Y',None, None, None, None, 'Formatted',None, 'The command-line arguments for the shortcut.',),
+('Shortcut','Shortcut','N',None, None, None, None, 'Identifier',None, 'Primary key, non-localized token.',),
+('Shortcut','Hotkey','Y',0,32767,None, None, None, None, 'The hotkey for the shortcut. It has the virtual-key code for the key in the low-order byte, and the modifier flags in the high-order byte. ',),
+('Shortcut','ShowCmd','Y',None, None, None, None, None, '1;3;7','The show command for the application window.The following values may be used.',),
+('Shortcut','WkDir','Y',None, None, None, None, 'Identifier',None, 'Name of property defining location of working directory.',),
+('Signature','FileName','N',None, None, None, None, 'Filename',None, 'The name of the file. This may contain a "short name|long name" pair.',),
+('Signature','Signature','N',None, None, None, None, 'Identifier',None, 'The table key. The Signature represents a unique file signature.',),
+('Signature','Languages','Y',None, None, None, None, 'Language',None, 'The languages supported by the file.',),
+('Signature','MaxDate','Y',0,2147483647,None, None, None, None, 'The maximum creation date of the file.',),
+('Signature','MaxSize','Y',0,2147483647,None, None, None, None, 'The maximum size of the file. ',),
+('Signature','MaxVersion','Y',None, None, None, None, 'Text',None, 'The maximum version of the file.',),
+('Signature','MinDate','Y',0,2147483647,None, None, None, None, 'The minimum creation date of the file.',),
+('Signature','MinSize','Y',0,2147483647,None, None, None, None, 'The minimum size of the file.',),
+('Signature','MinVersion','Y',None, None, None, None, 'Text',None, 'The minimum version of the file.',),
+('TextStyle','TextStyle','N',None, None, None, None, 'Identifier',None, 'Name of the style. The primary key of this table. This name is embedded in the texts to indicate a style change.',),
+('TextStyle','Color','Y',0,16777215,None, None, None, None, 'An integer indicating the color of the string in the RGB format (Red, Green, Blue each 0-255, RGB = R + 256*G + 256^2*B).',),
+('TextStyle','FaceName','N',None, None, None, None, 'Text',None, 'A string indicating the name of the font used. Required. The string must be at most 31 characters long.',),
+('TextStyle','Size','N',0,32767,None, None, None, None, 'The size of the font used. This size is given in our units (1/12 of the system font height). Assuming that the system font is set to 12 point size, this is equivalent to the point size.',),
+('TextStyle','StyleBits','Y',0,15,None, None, None, None, 'A combination of style bits.',),
+('TypeLib','Description','Y',None, None, None, None, 'Text',None, None, ),
+('TypeLib','Feature_','N',None, None, 'Feature',1,'Identifier',None, 'Required foreign key into the Feature Table, specifying the feature to validate or install in order for the type library to be operational.',),
+('TypeLib','Component_','N',None, None, 'Component',1,'Identifier',None, 'Required foreign key into the Component Table, specifying the component for which to return a path when called through LocateComponent.',),
+('TypeLib','Directory_','Y',None, None, 'Directory',1,'Identifier',None, 'Optional. The foreign key into the Directory table denoting the path to the help file for the type library.',),
+('TypeLib','Language','N',0,32767,None, None, None, None, 'The language of the library.',),
+('TypeLib','Version','Y',0,16777215,None, None, None, None, 'The version of the library. The minor version is in the lower 8 bits of the integer. The major version is in the next 16 bits. ',),
+('TypeLib','Cost','Y',0,2147483647,None, None, None, None, 'The cost associated with the registration of the typelib. This column is currently optional.',),
+('TypeLib','LibID','N',None, None, None, None, 'Guid',None, 'The GUID that represents the library.',),
+('UIText','Text','Y',None, None, None, None, 'Text',None, 'The localized version of the string.',),
+('UIText','Key','N',None, None, None, None, 'Identifier',None, 'A unique key that identifies the particular string.',),
+('Upgrade','Attributes','N',0,2147483647,None, None, None, None, 'The attributes of this product set.',),
+('Upgrade','Language','Y',None, None, None, None, 'Language',None, 'A comma-separated list of languages for either products in this set or products not in this set.',),
+('Upgrade','ActionProperty','N',None, None, None, None, 'UpperCase',None, 'The property to set when a product in this set is found.',),
+('Upgrade','Remove','Y',None, None, None, None, 'Formatted',None, 'The list of features to remove when uninstalling a product from this set. The default is "ALL".',),
+('Upgrade','UpgradeCode','N',None, None, None, None, 'Guid',None, 'The UpgradeCode GUID belonging to the products in this set.',),
+('Upgrade','VersionMax','Y',None, None, None, None, 'Text',None, 'The maximum ProductVersion of the products in this set. The set may or may not include products with this particular version.',),
+('Upgrade','VersionMin','Y',None, None, None, None, 'Text',None, 'The minimum ProductVersion of the products in this set. The set may or may not include products with this particular version.',),
+('Verb','Sequence','Y',0,32767,None, None, None, None, 'Order within the verbs for a particular extension. Also used simply to specify the default verb.',),
+('Verb','Argument','Y',None, None, None, None, 'Formatted',None, 'Optional value for the command arguments.',),
+('Verb','Extension_','N',None, None, 'Extension',1,'Text',None, 'The extension associated with the table row.',),
+('Verb','Verb','N',None, None, None, None, 'Text',None, 'The verb for the command.',),
+('Verb','Command','Y',None, None, None, None, 'Formatted',None, 'The command text.',),
]
diff --git a/Lib/msilib/sequence.py b/Lib/msilib/sequence.py
index 1138f7a2345..7012a21f857 100644
--- a/Lib/msilib/sequence.py
+++ b/Lib/msilib/sequence.py
@@ -1,126 +1,126 @@
AdminExecuteSequence = [
-(u'InstallInitialize', None, 1500),
-(u'InstallFinalize', None, 6600),
-(u'InstallFiles', None, 4000),
-(u'InstallAdminPackage', None, 3900),
-(u'FileCost', None, 900),
-(u'CostInitialize', None, 800),
-(u'CostFinalize', None, 1000),
-(u'InstallValidate', None, 1400),
+('InstallInitialize', None, 1500),
+('InstallFinalize', None, 6600),
+('InstallFiles', None, 4000),
+('InstallAdminPackage', None, 3900),
+('FileCost', None, 900),
+('CostInitialize', None, 800),
+('CostFinalize', None, 1000),
+('InstallValidate', None, 1400),
]
AdminUISequence = [
-(u'FileCost', None, 900),
-(u'CostInitialize', None, 800),
-(u'CostFinalize', None, 1000),
-(u'ExecuteAction', None, 1300),
-(u'ExitDialog', None, -1),
-(u'FatalError', None, -3),
-(u'UserExit', None, -2),
+('FileCost', None, 900),
+('CostInitialize', None, 800),
+('CostFinalize', None, 1000),
+('ExecuteAction', None, 1300),
+('ExitDialog', None, -1),
+('FatalError', None, -3),
+('UserExit', None, -2),
]
AdvtExecuteSequence = [
-(u'InstallInitialize', None, 1500),
-(u'InstallFinalize', None, 6600),
-(u'CostInitialize', None, 800),
-(u'CostFinalize', None, 1000),
-(u'InstallValidate', None, 1400),
-(u'CreateShortcuts', None, 4500),
-(u'MsiPublishAssemblies', None, 6250),
-(u'PublishComponents', None, 6200),
-(u'PublishFeatures', None, 6300),
-(u'PublishProduct', None, 6400),
-(u'RegisterClassInfo', None, 4600),
-(u'RegisterExtensionInfo', None, 4700),
-(u'RegisterMIMEInfo', None, 4900),
-(u'RegisterProgIdInfo', None, 4800),
+('InstallInitialize', None, 1500),
+('InstallFinalize', None, 6600),
+('CostInitialize', None, 800),
+('CostFinalize', None, 1000),
+('InstallValidate', None, 1400),
+('CreateShortcuts', None, 4500),
+('MsiPublishAssemblies', None, 6250),
+('PublishComponents', None, 6200),
+('PublishFeatures', None, 6300),
+('PublishProduct', None, 6400),
+('RegisterClassInfo', None, 4600),
+('RegisterExtensionInfo', None, 4700),
+('RegisterMIMEInfo', None, 4900),
+('RegisterProgIdInfo', None, 4800),
]
InstallExecuteSequence = [
-(u'InstallInitialize', None, 1500),
-(u'InstallFinalize', None, 6600),
-(u'InstallFiles', None, 4000),
-(u'FileCost', None, 900),
-(u'CostInitialize', None, 800),
-(u'CostFinalize', None, 1000),
-(u'InstallValidate', None, 1400),
-(u'CreateShortcuts', None, 4500),
-(u'MsiPublishAssemblies', None, 6250),
-(u'PublishComponents', None, 6200),
-(u'PublishFeatures', None, 6300),
-(u'PublishProduct', None, 6400),
-(u'RegisterClassInfo', None, 4600),
-(u'RegisterExtensionInfo', None, 4700),
-(u'RegisterMIMEInfo', None, 4900),
-(u'RegisterProgIdInfo', None, 4800),
-(u'AllocateRegistrySpace', u'NOT Installed', 1550),
-(u'AppSearch', None, 400),
-(u'BindImage', None, 4300),
-(u'CCPSearch', u'NOT Installed', 500),
-(u'CreateFolders', None, 3700),
-(u'DeleteServices', u'VersionNT', 2000),
-(u'DuplicateFiles', None, 4210),
-(u'FindRelatedProducts', None, 200),
-(u'InstallODBC', None, 5400),
-(u'InstallServices', u'VersionNT', 5800),
-(u'IsolateComponents', None, 950),
-(u'LaunchConditions', None, 100),
-(u'MigrateFeatureStates', None, 1200),
-(u'MoveFiles', None, 3800),
-(u'PatchFiles', None, 4090),
-(u'ProcessComponents', None, 1600),
-(u'RegisterComPlus', None, 5700),
-(u'RegisterFonts', None, 5300),
-(u'RegisterProduct', None, 6100),
-(u'RegisterTypeLibraries', None, 5500),
-(u'RegisterUser', None, 6000),
-(u'RemoveDuplicateFiles', None, 3400),
-(u'RemoveEnvironmentStrings', None, 3300),
-(u'RemoveExistingProducts', None, 6700),
-(u'RemoveFiles', None, 3500),
-(u'RemoveFolders', None, 3600),
-(u'RemoveIniValues', None, 3100),
-(u'RemoveODBC', None, 2400),
-(u'RemoveRegistryValues', None, 2600),
-(u'RemoveShortcuts', None, 3200),
-(u'RMCCPSearch', u'NOT Installed', 600),
-(u'SelfRegModules', None, 5600),
-(u'SelfUnregModules', None, 2200),
-(u'SetODBCFolders', None, 1100),
-(u'StartServices', u'VersionNT', 5900),
-(u'StopServices', u'VersionNT', 1900),
-(u'MsiUnpublishAssemblies', None, 1750),
-(u'UnpublishComponents', None, 1700),
-(u'UnpublishFeatures', None, 1800),
-(u'UnregisterClassInfo', None, 2700),
-(u'UnregisterComPlus', None, 2100),
-(u'UnregisterExtensionInfo', None, 2800),
-(u'UnregisterFonts', None, 2500),
-(u'UnregisterMIMEInfo', None, 3000),
-(u'UnregisterProgIdInfo', None, 2900),
-(u'UnregisterTypeLibraries', None, 2300),
-(u'ValidateProductID', None, 700),
-(u'WriteEnvironmentStrings', None, 5200),
-(u'WriteIniValues', None, 5100),
-(u'WriteRegistryValues', None, 5000),
+('InstallInitialize', None, 1500),
+('InstallFinalize', None, 6600),
+('InstallFiles', None, 4000),
+('FileCost', None, 900),
+('CostInitialize', None, 800),
+('CostFinalize', None, 1000),
+('InstallValidate', None, 1400),
+('CreateShortcuts', None, 4500),
+('MsiPublishAssemblies', None, 6250),
+('PublishComponents', None, 6200),
+('PublishFeatures', None, 6300),
+('PublishProduct', None, 6400),
+('RegisterClassInfo', None, 4600),
+('RegisterExtensionInfo', None, 4700),
+('RegisterMIMEInfo', None, 4900),
+('RegisterProgIdInfo', None, 4800),
+('AllocateRegistrySpace', 'NOT Installed', 1550),
+('AppSearch', None, 400),
+('BindImage', None, 4300),
+('CCPSearch', 'NOT Installed', 500),
+('CreateFolders', None, 3700),
+('DeleteServices', 'VersionNT', 2000),
+('DuplicateFiles', None, 4210),
+('FindRelatedProducts', None, 200),
+('InstallODBC', None, 5400),
+('InstallServices', 'VersionNT', 5800),
+('IsolateComponents', None, 950),
+('LaunchConditions', None, 100),
+('MigrateFeatureStates', None, 1200),
+('MoveFiles', None, 3800),
+('PatchFiles', None, 4090),
+('ProcessComponents', None, 1600),
+('RegisterComPlus', None, 5700),
+('RegisterFonts', None, 5300),
+('RegisterProduct', None, 6100),
+('RegisterTypeLibraries', None, 5500),
+('RegisterUser', None, 6000),
+('RemoveDuplicateFiles', None, 3400),
+('RemoveEnvironmentStrings', None, 3300),
+('RemoveExistingProducts', None, 6700),
+('RemoveFiles', None, 3500),
+('RemoveFolders', None, 3600),
+('RemoveIniValues', None, 3100),
+('RemoveODBC', None, 2400),
+('RemoveRegistryValues', None, 2600),
+('RemoveShortcuts', None, 3200),
+('RMCCPSearch', 'NOT Installed', 600),
+('SelfRegModules', None, 5600),
+('SelfUnregModules', None, 2200),
+('SetODBCFolders', None, 1100),
+('StartServices', 'VersionNT', 5900),
+('StopServices', 'VersionNT', 1900),
+('MsiUnpublishAssemblies', None, 1750),
+('UnpublishComponents', None, 1700),
+('UnpublishFeatures', None, 1800),
+('UnregisterClassInfo', None, 2700),
+('UnregisterComPlus', None, 2100),
+('UnregisterExtensionInfo', None, 2800),
+('UnregisterFonts', None, 2500),
+('UnregisterMIMEInfo', None, 3000),
+('UnregisterProgIdInfo', None, 2900),
+('UnregisterTypeLibraries', None, 2300),
+('ValidateProductID', None, 700),
+('WriteEnvironmentStrings', None, 5200),
+('WriteIniValues', None, 5100),
+('WriteRegistryValues', None, 5000),
]
InstallUISequence = [
-(u'FileCost', None, 900),
-(u'CostInitialize', None, 800),
-(u'CostFinalize', None, 1000),
-(u'ExecuteAction', None, 1300),
-(u'ExitDialog', None, -1),
-(u'FatalError', None, -3),
-(u'UserExit', None, -2),
-(u'AppSearch', None, 400),
-(u'CCPSearch', u'NOT Installed', 500),
-(u'FindRelatedProducts', None, 200),
-(u'IsolateComponents', None, 950),
-(u'LaunchConditions', None, 100),
-(u'MigrateFeatureStates', None, 1200),
-(u'RMCCPSearch', u'NOT Installed', 600),
-(u'ValidateProductID', None, 700),
+('FileCost', None, 900),
+('CostInitialize', None, 800),
+('CostFinalize', None, 1000),
+('ExecuteAction', None, 1300),
+('ExitDialog', None, -1),
+('FatalError', None, -3),
+('UserExit', None, -2),
+('AppSearch', None, 400),
+('CCPSearch', 'NOT Installed', 500),
+('FindRelatedProducts', None, 200),
+('IsolateComponents', None, 950),
+('LaunchConditions', None, 100),
+('MigrateFeatureStates', None, 1200),
+('RMCCPSearch', 'NOT Installed', 600),
+('ValidateProductID', None, 700),
]
tables=['AdminExecuteSequence', 'AdminUISequence', 'AdvtExecuteSequence', 'InstallExecuteSequence', 'InstallUISequence']
diff --git a/Lib/msilib/text.py b/Lib/msilib/text.py
index 12fd2d7c6c3..c4b9e8697d7 100644
--- a/Lib/msilib/text.py
+++ b/Lib/msilib/text.py
@@ -1,129 +1,129 @@
import msilib,os;dirname=os.path.dirname(__file__)
ActionText = [
-(u'InstallValidate', u'Validating install', None),
-(u'InstallFiles', u'Copying new files', u'File: [1], Directory: [9], Size: [6]'),
-(u'InstallAdminPackage', u'Copying network install files', u'File: [1], Directory: [9], Size: [6]'),
-(u'FileCost', u'Computing space requirements', None),
-(u'CostInitialize', u'Computing space requirements', None),
-(u'CostFinalize', u'Computing space requirements', None),
-(u'CreateShortcuts', u'Creating shortcuts', u'Shortcut: [1]'),
-(u'PublishComponents', u'Publishing Qualified Components', u'Component ID: [1], Qualifier: [2]'),
-(u'PublishFeatures', u'Publishing Product Features', u'Feature: [1]'),
-(u'PublishProduct', u'Publishing product information', None),
-(u'RegisterClassInfo', u'Registering Class servers', u'Class Id: [1]'),
-(u'RegisterExtensionInfo', u'Registering extension servers', u'Extension: [1]'),
-(u'RegisterMIMEInfo', u'Registering MIME info', u'MIME Content Type: [1], Extension: [2]'),
-(u'RegisterProgIdInfo', u'Registering program identifiers', u'ProgId: [1]'),
-(u'AllocateRegistrySpace', u'Allocating registry space', u'Free space: [1]'),
-(u'AppSearch', u'Searching for installed applications', u'Property: [1], Signature: [2]'),
-(u'BindImage', u'Binding executables', u'File: [1]'),
-(u'CCPSearch', u'Searching for qualifying products', None),
-(u'CreateFolders', u'Creating folders', u'Folder: [1]'),
-(u'DeleteServices', u'Deleting services', u'Service: [1]'),
-(u'DuplicateFiles', u'Creating duplicate files', u'File: [1], Directory: [9], Size: [6]'),
-(u'FindRelatedProducts', u'Searching for related applications', u'Found application: [1]'),
-(u'InstallODBC', u'Installing ODBC components', None),
-(u'InstallServices', u'Installing new services', u'Service: [2]'),
-(u'LaunchConditions', u'Evaluating launch conditions', None),
-(u'MigrateFeatureStates', u'Migrating feature states from related applications', u'Application: [1]'),
-(u'MoveFiles', u'Moving files', u'File: [1], Directory: [9], Size: [6]'),
-(u'PatchFiles', u'Patching files', u'File: [1], Directory: [2], Size: [3]'),
-(u'ProcessComponents', u'Updating component registration', None),
-(u'RegisterComPlus', u'Registering COM+ Applications and Components', u'AppId: [1]{{, AppType: [2], Users: [3], RSN: [4]}}'),
-(u'RegisterFonts', u'Registering fonts', u'Font: [1]'),
-(u'RegisterProduct', u'Registering product', u'[1]'),
-(u'RegisterTypeLibraries', u'Registering type libraries', u'LibID: [1]'),
-(u'RegisterUser', u'Registering user', u'[1]'),
-(u'RemoveDuplicateFiles', u'Removing duplicated files', u'File: [1], Directory: [9]'),
-(u'RemoveEnvironmentStrings', u'Updating environment strings', u'Name: [1], Value: [2], Action [3]'),
-(u'RemoveExistingProducts', u'Removing applications', u'Application: [1], Command line: [2]'),
-(u'RemoveFiles', u'Removing files', u'File: [1], Directory: [9]'),
-(u'RemoveFolders', u'Removing folders', u'Folder: [1]'),
-(u'RemoveIniValues', u'Removing INI files entries', u'File: [1], Section: [2], Key: [3], Value: [4]'),
-(u'RemoveODBC', u'Removing ODBC components', None),
-(u'RemoveRegistryValues', u'Removing system registry values', u'Key: [1], Name: [2]'),
-(u'RemoveShortcuts', u'Removing shortcuts', u'Shortcut: [1]'),
-(u'RMCCPSearch', u'Searching for qualifying products', None),
-(u'SelfRegModules', u'Registering modules', u'File: [1], Folder: [2]'),
-(u'SelfUnregModules', u'Unregistering modules', u'File: [1], Folder: [2]'),
-(u'SetODBCFolders', u'Initializing ODBC directories', None),
-(u'StartServices', u'Starting services', u'Service: [1]'),
-(u'StopServices', u'Stopping services', u'Service: [1]'),
-(u'UnpublishComponents', u'Unpublishing Qualified Components', u'Component ID: [1], Qualifier: [2]'),
-(u'UnpublishFeatures', u'Unpublishing Product Features', u'Feature: [1]'),
-(u'UnregisterClassInfo', u'Unregister Class servers', u'Class Id: [1]'),
-(u'UnregisterComPlus', u'Unregistering COM+ Applications and Components', u'AppId: [1]{{, AppType: [2]}}'),
-(u'UnregisterExtensionInfo', u'Unregistering extension servers', u'Extension: [1]'),
-(u'UnregisterFonts', u'Unregistering fonts', u'Font: [1]'),
-(u'UnregisterMIMEInfo', u'Unregistering MIME info', u'MIME Content Type: [1], Extension: [2]'),
-(u'UnregisterProgIdInfo', u'Unregistering program identifiers', u'ProgId: [1]'),
-(u'UnregisterTypeLibraries', u'Unregistering type libraries', u'LibID: [1]'),
-(u'WriteEnvironmentStrings', u'Updating environment strings', u'Name: [1], Value: [2], Action [3]'),
-(u'WriteIniValues', u'Writing INI files values', u'File: [1], Section: [2], Key: [3], Value: [4]'),
-(u'WriteRegistryValues', u'Writing system registry values', u'Key: [1], Name: [2], Value: [3]'),
-(u'Advertise', u'Advertising application', None),
-(u'GenerateScript', u'Generating script operations for action:', u'[1]'),
-(u'InstallSFPCatalogFile', u'Installing system catalog', u'File: [1], Dependencies: [2]'),
-(u'MsiPublishAssemblies', u'Publishing assembly information', u'Application Context:[1], Assembly Name:[2]'),
-(u'MsiUnpublishAssemblies', u'Unpublishing assembly information', u'Application Context:[1], Assembly Name:[2]'),
-(u'Rollback', u'Rolling back action:', u'[1]'),
-(u'RollbackCleanup', u'Removing backup files', u'File: [1]'),
-(u'UnmoveFiles', u'Removing moved files', u'File: [1], Directory: [9]'),
-(u'UnpublishProduct', u'Unpublishing product information', None),
+('InstallValidate', 'Validating install', None),
+('InstallFiles', 'Copying new files', 'File: [1], Directory: [9], Size: [6]'),
+('InstallAdminPackage', 'Copying network install files', 'File: [1], Directory: [9], Size: [6]'),
+('FileCost', 'Computing space requirements', None),
+('CostInitialize', 'Computing space requirements', None),
+('CostFinalize', 'Computing space requirements', None),
+('CreateShortcuts', 'Creating shortcuts', 'Shortcut: [1]'),
+('PublishComponents', 'Publishing Qualified Components', 'Component ID: [1], Qualifier: [2]'),
+('PublishFeatures', 'Publishing Product Features', 'Feature: [1]'),
+('PublishProduct', 'Publishing product information', None),
+('RegisterClassInfo', 'Registering Class servers', 'Class Id: [1]'),
+('RegisterExtensionInfo', 'Registering extension servers', 'Extension: [1]'),
+('RegisterMIMEInfo', 'Registering MIME info', 'MIME Content Type: [1], Extension: [2]'),
+('RegisterProgIdInfo', 'Registering program identifiers', 'ProgId: [1]'),
+('AllocateRegistrySpace', 'Allocating registry space', 'Free space: [1]'),
+('AppSearch', 'Searching for installed applications', 'Property: [1], Signature: [2]'),
+('BindImage', 'Binding executables', 'File: [1]'),
+('CCPSearch', 'Searching for qualifying products', None),
+('CreateFolders', 'Creating folders', 'Folder: [1]'),
+('DeleteServices', 'Deleting services', 'Service: [1]'),
+('DuplicateFiles', 'Creating duplicate files', 'File: [1], Directory: [9], Size: [6]'),
+('FindRelatedProducts', 'Searching for related applications', 'Found application: [1]'),
+('InstallODBC', 'Installing ODBC components', None),
+('InstallServices', 'Installing new services', 'Service: [2]'),
+('LaunchConditions', 'Evaluating launch conditions', None),
+('MigrateFeatureStates', 'Migrating feature states from related applications', 'Application: [1]'),
+('MoveFiles', 'Moving files', 'File: [1], Directory: [9], Size: [6]'),
+('PatchFiles', 'Patching files', 'File: [1], Directory: [2], Size: [3]'),
+('ProcessComponents', 'Updating component registration', None),
+('RegisterComPlus', 'Registering COM+ Applications and Components', 'AppId: [1]{{, AppType: [2], Users: [3], RSN: [4]}}'),
+('RegisterFonts', 'Registering fonts', 'Font: [1]'),
+('RegisterProduct', 'Registering product', '[1]'),
+('RegisterTypeLibraries', 'Registering type libraries', 'LibID: [1]'),
+('RegisterUser', 'Registering user', '[1]'),
+('RemoveDuplicateFiles', 'Removing duplicated files', 'File: [1], Directory: [9]'),
+('RemoveEnvironmentStrings', 'Updating environment strings', 'Name: [1], Value: [2], Action [3]'),
+('RemoveExistingProducts', 'Removing applications', 'Application: [1], Command line: [2]'),
+('RemoveFiles', 'Removing files', 'File: [1], Directory: [9]'),
+('RemoveFolders', 'Removing folders', 'Folder: [1]'),
+('RemoveIniValues', 'Removing INI files entries', 'File: [1], Section: [2], Key: [3], Value: [4]'),
+('RemoveODBC', 'Removing ODBC components', None),
+('RemoveRegistryValues', 'Removing system registry values', 'Key: [1], Name: [2]'),
+('RemoveShortcuts', 'Removing shortcuts', 'Shortcut: [1]'),
+('RMCCPSearch', 'Searching for qualifying products', None),
+('SelfRegModules', 'Registering modules', 'File: [1], Folder: [2]'),
+('SelfUnregModules', 'Unregistering modules', 'File: [1], Folder: [2]'),
+('SetODBCFolders', 'Initializing ODBC directories', None),
+('StartServices', 'Starting services', 'Service: [1]'),
+('StopServices', 'Stopping services', 'Service: [1]'),
+('UnpublishComponents', 'Unpublishing Qualified Components', 'Component ID: [1], Qualifier: [2]'),
+('UnpublishFeatures', 'Unpublishing Product Features', 'Feature: [1]'),
+('UnregisterClassInfo', 'Unregister Class servers', 'Class Id: [1]'),
+('UnregisterComPlus', 'Unregistering COM+ Applications and Components', 'AppId: [1]{{, AppType: [2]}}'),
+('UnregisterExtensionInfo', 'Unregistering extension servers', 'Extension: [1]'),
+('UnregisterFonts', 'Unregistering fonts', 'Font: [1]'),
+('UnregisterMIMEInfo', 'Unregistering MIME info', 'MIME Content Type: [1], Extension: [2]'),
+('UnregisterProgIdInfo', 'Unregistering program identifiers', 'ProgId: [1]'),
+('UnregisterTypeLibraries', 'Unregistering type libraries', 'LibID: [1]'),
+('WriteEnvironmentStrings', 'Updating environment strings', 'Name: [1], Value: [2], Action [3]'),
+('WriteIniValues', 'Writing INI files values', 'File: [1], Section: [2], Key: [3], Value: [4]'),
+('WriteRegistryValues', 'Writing system registry values', 'Key: [1], Name: [2], Value: [3]'),
+('Advertise', 'Advertising application', None),
+('GenerateScript', 'Generating script operations for action:', '[1]'),
+('InstallSFPCatalogFile', 'Installing system catalog', 'File: [1], Dependencies: [2]'),
+('MsiPublishAssemblies', 'Publishing assembly information', 'Application Context:[1], Assembly Name:[2]'),
+('MsiUnpublishAssemblies', 'Unpublishing assembly information', 'Application Context:[1], Assembly Name:[2]'),
+('Rollback', 'Rolling back action:', '[1]'),
+('RollbackCleanup', 'Removing backup files', 'File: [1]'),
+('UnmoveFiles', 'Removing moved files', 'File: [1], Directory: [9]'),
+('UnpublishProduct', 'Unpublishing product information', None),
]
UIText = [
-(u'AbsentPath', None),
-(u'bytes', u'bytes'),
-(u'GB', u'GB'),
-(u'KB', u'KB'),
-(u'MB', u'MB'),
-(u'MenuAbsent', u'Entire feature will be unavailable'),
-(u'MenuAdvertise', u'Feature will be installed when required'),
-(u'MenuAllCD', u'Entire feature will be installed to run from CD'),
-(u'MenuAllLocal', u'Entire feature will be installed on local hard drive'),
-(u'MenuAllNetwork', u'Entire feature will be installed to run from network'),
-(u'MenuCD', u'Will be installed to run from CD'),
-(u'MenuLocal', u'Will be installed on local hard drive'),
-(u'MenuNetwork', u'Will be installed to run from network'),
-(u'ScriptInProgress', u'Gathering required information...'),
-(u'SelAbsentAbsent', u'This feature will remain uninstalled'),
-(u'SelAbsentAdvertise', u'This feature will be set to be installed when required'),
-(u'SelAbsentCD', u'This feature will be installed to run from CD'),
-(u'SelAbsentLocal', u'This feature will be installed on the local hard drive'),
-(u'SelAbsentNetwork', u'This feature will be installed to run from the network'),
-(u'SelAdvertiseAbsent', u'This feature will become unavailable'),
-(u'SelAdvertiseAdvertise', u'Will be installed when required'),
-(u'SelAdvertiseCD', u'This feature will be available to run from CD'),
-(u'SelAdvertiseLocal', u'This feature will be installed on your local hard drive'),
-(u'SelAdvertiseNetwork', u'This feature will be available to run from the network'),
-(u'SelCDAbsent', u"This feature will be uninstalled completely, you won't be able to run it from CD"),
-(u'SelCDAdvertise', u'This feature will change from run from CD state to set to be installed when required'),
-(u'SelCDCD', u'This feature will remain to be run from CD'),
-(u'SelCDLocal', u'This feature will change from run from CD state to be installed on the local hard drive'),
-(u'SelChildCostNeg', u'This feature frees up [1] on your hard drive.'),
-(u'SelChildCostPos', u'This feature requires [1] on your hard drive.'),
-(u'SelCostPending', u'Compiling cost for this feature...'),
-(u'SelLocalAbsent', u'This feature will be completely removed'),
-(u'SelLocalAdvertise', u'This feature will be removed from your local hard drive, but will be set to be installed when required'),
-(u'SelLocalCD', u'This feature will be removed from your local hard drive, but will be still available to run from CD'),
-(u'SelLocalLocal', u'This feature will remain on you local hard drive'),
-(u'SelLocalNetwork', u'This feature will be removed from your local hard drive, but will be still available to run from the network'),
-(u'SelNetworkAbsent', u"This feature will be uninstalled completely, you won't be able to run it from the network"),
-(u'SelNetworkAdvertise', u'This feature will change from run from network state to set to be installed when required'),
-(u'SelNetworkLocal', u'This feature will change from run from network state to be installed on the local hard drive'),
-(u'SelNetworkNetwork', u'This feature will remain to be run from the network'),
-(u'SelParentCostNegNeg', u'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'),
-(u'SelParentCostNegPos', u'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'),
-(u'SelParentCostPosNeg', u'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'),
-(u'SelParentCostPosPos', u'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'),
-(u'TimeRemaining', u'Time remaining: {[1] minutes }{[2] seconds}'),
-(u'VolumeCostAvailable', u'Available'),
-(u'VolumeCostDifference', u'Difference'),
-(u'VolumeCostRequired', u'Required'),
-(u'VolumeCostSize', u'Disk Size'),
-(u'VolumeCostVolume', u'Volume'),
+('AbsentPath', None),
+('bytes', 'bytes'),
+('GB', 'GB'),
+('KB', 'KB'),
+('MB', 'MB'),
+('MenuAbsent', 'Entire feature will be unavailable'),
+('MenuAdvertise', 'Feature will be installed when required'),
+('MenuAllCD', 'Entire feature will be installed to run from CD'),
+('MenuAllLocal', 'Entire feature will be installed on local hard drive'),
+('MenuAllNetwork', 'Entire feature will be installed to run from network'),
+('MenuCD', 'Will be installed to run from CD'),
+('MenuLocal', 'Will be installed on local hard drive'),
+('MenuNetwork', 'Will be installed to run from network'),
+('ScriptInProgress', 'Gathering required information...'),
+('SelAbsentAbsent', 'This feature will remain uninstalled'),
+('SelAbsentAdvertise', 'This feature will be set to be installed when required'),
+('SelAbsentCD', 'This feature will be installed to run from CD'),
+('SelAbsentLocal', 'This feature will be installed on the local hard drive'),
+('SelAbsentNetwork', 'This feature will be installed to run from the network'),
+('SelAdvertiseAbsent', 'This feature will become unavailable'),
+('SelAdvertiseAdvertise', 'Will be installed when required'),
+('SelAdvertiseCD', 'This feature will be available to run from CD'),
+('SelAdvertiseLocal', 'This feature will be installed on your local hard drive'),
+('SelAdvertiseNetwork', 'This feature will be available to run from the network'),
+('SelCDAbsent', "This feature will be uninstalled completely, you won't be able to run it from CD"),
+('SelCDAdvertise', 'This feature will change from run from CD state to set to be installed when required'),
+('SelCDCD', 'This feature will remain to be run from CD'),
+('SelCDLocal', 'This feature will change from run from CD state to be installed on the local hard drive'),
+('SelChildCostNeg', 'This feature frees up [1] on your hard drive.'),
+('SelChildCostPos', 'This feature requires [1] on your hard drive.'),
+('SelCostPending', 'Compiling cost for this feature...'),
+('SelLocalAbsent', 'This feature will be completely removed'),
+('SelLocalAdvertise', 'This feature will be removed from your local hard drive, but will be set to be installed when required'),
+('SelLocalCD', 'This feature will be removed from your local hard drive, but will be still available to run from CD'),
+('SelLocalLocal', 'This feature will remain on you local hard drive'),
+('SelLocalNetwork', 'This feature will be removed from your local hard drive, but will be still available to run from the network'),
+('SelNetworkAbsent', "This feature will be uninstalled completely, you won't be able to run it from the network"),
+('SelNetworkAdvertise', 'This feature will change from run from network state to set to be installed when required'),
+('SelNetworkLocal', 'This feature will change from run from network state to be installed on the local hard drive'),
+('SelNetworkNetwork', 'This feature will remain to be run from the network'),
+('SelParentCostNegNeg', 'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'),
+('SelParentCostNegPos', 'This feature frees up [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'),
+('SelParentCostPosNeg', 'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures free up [4] on your hard drive.'),
+('SelParentCostPosPos', 'This feature requires [1] on your hard drive. It has [2] of [3] subfeatures selected. The subfeatures require [4] on your hard drive.'),
+('TimeRemaining', 'Time remaining: {[1] minutes }{[2] seconds}'),
+('VolumeCostAvailable', 'Available'),
+('VolumeCostDifference', 'Difference'),
+('VolumeCostRequired', 'Required'),
+('VolumeCostSize', 'Disk Size'),
+('VolumeCostVolume', 'Volume'),
]
tables=['ActionText', 'UIText']
diff --git a/Lib/multifile.py b/Lib/multifile.py
deleted file mode 100644
index 35b0200c248..00000000000
--- a/Lib/multifile.py
+++ /dev/null
@@ -1,162 +0,0 @@
-"""A readline()-style interface to the parts of a multipart message.
-
-The MultiFile class makes each part of a multipart message "feel" like
-an ordinary file, as long as you use fp.readline(). Allows recursive
-use, for nested multipart messages. Probably best used together
-with module mimetools.
-
-Suggested use:
-
-real_fp = open(...)
-fp = MultiFile(real_fp)
-
-"read some lines from fp"
-fp.push(separator)
-while 1:
- "read lines from fp until it returns an empty string" (A)
- if not fp.next(): break
-fp.pop()
-"read remaining lines from fp until it returns an empty string"
-
-The latter sequence may be used recursively at (A).
-It is also allowed to use multiple push()...pop() sequences.
-
-If seekable is given as 0, the class code will not do the bookkeeping
-it normally attempts in order to make seeks relative to the beginning of the
-current file part. This may be useful when using MultiFile with a non-
-seekable stream object.
-"""
-from warnings import warn
-warn("the multifile module has been deprecated since Python 2.5",
- DeprecationWarning, stacklevel=2)
-del warn
-
-__all__ = ["MultiFile","Error"]
-
-class Error(Exception):
- pass
-
-class MultiFile:
-
- seekable = 0
-
- def __init__(self, fp, seekable=1):
- self.fp = fp
- self.stack = []
- self.level = 0
- self.last = 0
- if seekable:
- self.seekable = 1
- self.start = self.fp.tell()
- self.posstack = []
-
- def tell(self):
- if self.level > 0:
- return self.lastpos
- return self.fp.tell() - self.start
-
- def seek(self, pos, whence=0):
- here = self.tell()
- if whence:
- if whence == 1:
- pos = pos + here
- elif whence == 2:
- if self.level > 0:
- pos = pos + self.lastpos
- else:
- raise Error, "can't use whence=2 yet"
- if not 0 <= pos <= here or \
- self.level > 0 and pos > self.lastpos:
- raise Error, 'bad MultiFile.seek() call'
- self.fp.seek(pos + self.start)
- self.level = 0
- self.last = 0
-
- def readline(self):
- if self.level > 0:
- return ''
- line = self.fp.readline()
- # Real EOF?
- if not line:
- self.level = len(self.stack)
- self.last = (self.level > 0)
- if self.last:
- raise Error, 'sudden EOF in MultiFile.readline()'
- return ''
- assert self.level == 0
- # Fast check to see if this is just data
- if self.is_data(line):
- return line
- else:
- # Ignore trailing whitespace on marker lines
- marker = line.rstrip()
- # No? OK, try to match a boundary.
- # Return the line (unstripped) if we don't.
- for i, sep in enumerate(reversed(self.stack)):
- if marker == self.section_divider(sep):
- self.last = 0
- break
- elif marker == self.end_marker(sep):
- self.last = 1
- break
- else:
- return line
- # We only get here if we see a section divider or EOM line
- if self.seekable:
- self.lastpos = self.tell() - len(line)
- self.level = i+1
- if self.level > 1:
- raise Error,'Missing endmarker in MultiFile.readline()'
- return ''
-
- def readlines(self):
- list = []
- while 1:
- line = self.readline()
- if not line: break
- list.append(line)
- return list
-
- def read(self): # Note: no size argument -- read until EOF only!
- return ''.join(self.readlines())
-
- def next(self):
- while self.readline(): pass
- if self.level > 1 or self.last:
- return 0
- self.level = 0
- self.last = 0
- if self.seekable:
- self.start = self.fp.tell()
- return 1
-
- def push(self, sep):
- if self.level > 0:
- raise Error, 'bad MultiFile.push() call'
- self.stack.append(sep)
- if self.seekable:
- self.posstack.append(self.start)
- self.start = self.fp.tell()
-
- def pop(self):
- if self.stack == []:
- raise Error, 'bad MultiFile.pop() call'
- if self.level <= 1:
- self.last = 0
- else:
- abslastpos = self.lastpos + self.start
- self.level = max(0, self.level - 1)
- self.stack.pop()
- if self.seekable:
- self.start = self.posstack.pop()
- if self.level > 0:
- self.lastpos = abslastpos - self.start
-
- def is_data(self, line):
- return line[:2] != '--'
-
- def section_divider(self, str):
- return "--" + str
-
- def end_marker(self, str):
- return "--" + str + "--"
diff --git a/Lib/multiprocessing/__init__.py b/Lib/multiprocessing/__init__.py
index 2e91e8eb6eb..e6e16c83224 100644
--- a/Lib/multiprocessing/__init__.py
+++ b/Lib/multiprocessing/__init__.py
@@ -80,7 +80,6 @@ class TimeoutError(ProcessError):
class AuthenticationError(ProcessError):
pass
-# This is down here because _multiprocessing uses BufferTooShort
import _multiprocessing
#
diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py
index 4421ac5cfd7..4fa6f70bf3f 100644
--- a/Lib/multiprocessing/connection.py
+++ b/Lib/multiprocessing/connection.py
@@ -90,10 +90,21 @@ def arbitrary_address(family):
return tempfile.mktemp(prefix='listener-', dir=get_temp_dir())
elif family == 'AF_PIPE':
return tempfile.mktemp(prefix=r'\\.\pipe\pyc-%d-%d-' %
- (os.getpid(), _mmap_counter.next()))
+ (os.getpid(), next(_mmap_counter)))
else:
raise ValueError('unrecognized family')
+def _validate_family(family):
+ '''
+ Checks if the family is valid for the current environment.
+ '''
+ if sys.platform != 'win32' and family == 'AF_PIPE':
+ raise ValueError('Family %s is not recognized.' % family)
+
+ if sys.platform == 'win32' and family == 'AF_UNIX':
+ # double check
+ if not hasattr(socket, family):
+ raise ValueError('Family %s is not recognized.' % family)
def address_type(address):
'''
@@ -126,13 +137,14 @@ class Listener(object):
or default_family
address = address or arbitrary_address(family)
+ _validate_family(family)
if family == 'AF_PIPE':
self._listener = PipeListener(address, backlog)
else:
self._listener = SocketListener(address, family, backlog)
if authkey is not None and not isinstance(authkey, bytes):
- raise TypeError, 'authkey should be a byte string'
+ raise TypeError('authkey should be a byte string')
self._authkey = authkey
@@ -163,13 +175,14 @@ def Client(address, family=None, authkey=None):
Returns a connection to the address of a `Listener`
'''
family = family or address_type(address)
+ _validate_family(family)
if family == 'AF_PIPE':
c = PipeClient(address)
else:
c = SocketClient(address)
if authkey is not None and not isinstance(authkey, bytes):
- raise TypeError, 'authkey should be a byte string'
+ raise TypeError('authkey should be a byte string')
if authkey is not None:
answer_challenge(c, authkey)
@@ -232,7 +245,7 @@ else:
try:
win32.ConnectNamedPipe(h1, win32.NULL)
- except WindowsError, e:
+ except WindowsError as e:
if e.args[0] != win32.ERROR_PIPE_CONNECTED:
raise
@@ -289,26 +302,25 @@ def SocketClient(address):
Return a connection object connected to the socket given by `address`
'''
family = address_type(address)
- s = socket.socket( getattr(socket, family) )
- s.setblocking(True)
- t = _init_timeout()
+ with socket.socket( getattr(socket, family) ) as s:
+ s.setblocking(True)
+ t = _init_timeout()
- while 1:
- try:
- s.connect(address)
- except socket.error, e:
- if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
- debug('failed to connect to address %s', address)
- raise
- time.sleep(0.01)
+ while 1:
+ try:
+ s.connect(address)
+ except socket.error as e:
+ if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
+ debug('failed to connect to address %s', address)
+ raise
+ time.sleep(0.01)
+ else:
+ break
else:
- break
- else:
- raise
+ raise
- fd = duplicate(s.fileno())
+ fd = duplicate(s.fileno())
conn = _multiprocessing.Connection(fd)
- s.close()
return conn
#
@@ -352,7 +364,7 @@ if sys.platform == 'win32':
handle = self._handle_queue.pop(0)
try:
win32.ConnectNamedPipe(handle, win32.NULL)
- except WindowsError, e:
+ except WindowsError as e:
# ERROR_NO_DATA can occur if a client has already connected,
# written data and then disconnected -- see Issue 14725.
if e.args[0] not in (win32.ERROR_PIPE_CONNECTED,
@@ -378,7 +390,7 @@ if sys.platform == 'win32':
address, win32.GENERIC_READ | win32.GENERIC_WRITE,
0, win32.NULL, win32.OPEN_EXISTING, 0, win32.NULL
)
- except WindowsError, e:
+ except WindowsError as e:
if e.args[0] not in (win32.ERROR_SEM_TIMEOUT,
win32.ERROR_PIPE_BUSY) or _check_timeout(t):
raise
@@ -456,11 +468,11 @@ def _xml_loads(s):
class XmlListener(Listener):
def accept(self):
global xmlrpclib
- import xmlrpclib
+ import xmlrpc.client as xmlrpclib
obj = Listener.accept(self)
return ConnectionWrapper(obj, _xml_dumps, _xml_loads)
def XmlClient(*args, **kwds):
global xmlrpclib
- import xmlrpclib
+ import xmlrpc.client as xmlrpclib
return ConnectionWrapper(Client(*args, **kwds), _xml_dumps, _xml_loads)
diff --git a/Lib/multiprocessing/dummy/__init__.py b/Lib/multiprocessing/dummy/__init__.py
index e3b126e9796..101c3cba4d7 100644
--- a/Lib/multiprocessing/dummy/__init__.py
+++ b/Lib/multiprocessing/dummy/__init__.py
@@ -52,7 +52,7 @@ from multiprocessing import TimeoutError, cpu_count
from multiprocessing.dummy.connection import Pipe
from threading import Lock, RLock, Semaphore, BoundedSemaphore
from threading import Event
-from Queue import Queue
+from queue import Queue
#
#
@@ -86,7 +86,11 @@ class DummyProcess(threading.Thread):
#
class Condition(threading._Condition):
- notify_all = threading._Condition.notify_all.im_func
+ # XXX
+ if sys.version_info < (3, 0):
+ notify_all = threading._Condition.notify_all.__func__
+ else:
+ notify_all = threading._Condition.notify_all
#
#
@@ -114,7 +118,7 @@ class Namespace(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)
def __repr__(self):
- items = self.__dict__.items()
+ items = list(self.__dict__.items())
temp = []
for name, value in items:
if not name.startswith('_'):
diff --git a/Lib/multiprocessing/dummy/connection.py b/Lib/multiprocessing/dummy/connection.py
index 50dc9ffe736..af105794f15 100644
--- a/Lib/multiprocessing/dummy/connection.py
+++ b/Lib/multiprocessing/dummy/connection.py
@@ -34,7 +34,7 @@
__all__ = [ 'Client', 'Listener', 'Pipe' ]
-from Queue import Queue
+from queue import Queue
families = [None]
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py
index 55980ffdcad..bc8ac44c22e 100644
--- a/Lib/multiprocessing/forking.py
+++ b/Lib/multiprocessing/forking.py
@@ -55,34 +55,35 @@ def assert_spawning(self):
# Try making some callable types picklable
#
-from pickle import Pickler
+from pickle import _Pickler as Pickler
class ForkingPickler(Pickler):
dispatch = Pickler.dispatch.copy()
-
@classmethod
def register(cls, type, reduce):
def dispatcher(self, obj):
rv = reduce(obj)
- self.save_reduce(obj=obj, *rv)
+ if isinstance(rv, str):
+ self.save_global(obj, rv)
+ else:
+ self.save_reduce(obj=obj, *rv)
cls.dispatch[type] = dispatcher
def _reduce_method(m):
- if m.im_self is None:
- return getattr, (m.im_class, m.im_func.func_name)
+ if m.__self__ is None:
+ return getattr, (m.__class__, m.__func__.__name__)
else:
- return getattr, (m.im_self, m.im_func.func_name)
-ForkingPickler.register(type(ForkingPickler.save), _reduce_method)
+ return getattr, (m.__self__, m.__func__.__name__)
+class _C:
+ def f(self):
+ pass
+ForkingPickler.register(type(_C().f), _reduce_method)
+
def _reduce_method_descriptor(m):
return getattr, (m.__objclass__, m.__name__)
ForkingPickler.register(type(list.append), _reduce_method_descriptor)
ForkingPickler.register(type(int.__add__), _reduce_method_descriptor)
-#def _reduce_builtin_function_or_method(m):
-# return getattr, (m.__self__, m.__name__)
-#ForkingPickler.register(type(list().append), _reduce_builtin_function_or_method)
-#ForkingPickler.register(type(int().__add__), _reduce_builtin_function_or_method)
-
try:
from functools import partial
except ImportError:
@@ -123,8 +124,6 @@ if sys.platform != 'win32':
import random
random.seed()
code = process_obj._bootstrap()
- sys.stdout.flush()
- sys.stderr.flush()
os._exit(code)
def poll(self, flag=os.WNOHANG):
@@ -163,7 +162,7 @@ if sys.platform != 'win32':
if self.returncode is None:
try:
os.kill(self.pid, signal.SIGTERM)
- except OSError, e:
+ except OSError as e:
if self.wait(timeout=0.1) is None:
raise
@@ -176,19 +175,15 @@ if sys.platform != 'win32':
#
else:
- import thread
+ import _thread
import msvcrt
import _subprocess
import time
+ from pickle import dump, load, HIGHEST_PROTOCOL
from _multiprocessing import win32, Connection, PipeConnection
from .util import Finalize
- #try:
- # from cPickle import dump, load, HIGHEST_PROTOCOL
- #except ImportError:
- from pickle import load, HIGHEST_PROTOCOL
-
def dump(obj, file, protocol=None):
ForkingPickler(file, protocol).dump(obj)
@@ -238,7 +233,7 @@ else:
'''
Start a subprocess to run the code of a process object
'''
- _tls = thread._local()
+ _tls = _thread._local()
def __init__(self, process_obj):
# create pipe for communication with child
@@ -463,12 +458,20 @@ def prepare(data):
process.ORIGINAL_DIR = data['orig_dir']
if 'main_path' in data:
+ # XXX (ncoghlan): The following code makes several bogus
+ # assumptions regarding the relationship between __file__
+ # and a module's real name. See PEP 302 and issue #10845
main_path = data['main_path']
main_name = os.path.splitext(os.path.basename(main_path))[0]
if main_name == '__init__':
main_name = os.path.basename(os.path.dirname(main_path))
- if main_name != 'ipython':
+ if main_name == '__main__':
+ main_module = sys.modules['__main__']
+ main_module.__file__ = main_path
+ elif main_name != 'ipython':
+ # Main modules not actually called __main__.py may
+ # contain additional code that should still be executed
import imp
if main_path is None:
@@ -497,7 +500,7 @@ def prepare(data):
# Try to make the potentially picklable objects in
# sys.modules['__main__'] realize they are in the main
# module -- somewhat ugly.
- for obj in main_module.__dict__.values():
+ for obj in list(main_module.__dict__.values()):
try:
if obj.__module__ == '__parents_main__':
obj.__module__ = '__main__'
diff --git a/Lib/multiprocessing/heap.py b/Lib/multiprocessing/heap.py
index a1f37118d5a..0a25ef05c7f 100644
--- a/Lib/multiprocessing/heap.py
+++ b/Lib/multiprocessing/heap.py
@@ -60,7 +60,7 @@ if sys.platform == 'win32':
def __init__(self, size):
self.size = size
- self.name = 'pym-%d-%d' % (os.getpid(), Arena._counter.next())
+ self.name = 'pym-%d-%d' % (os.getpid(), next(Arena._counter))
self.buffer = mmap.mmap(-1, self.size, tagname=self.name)
assert win32.GetLastError() == 0, 'tagname already in use'
self._state = (self.size, self.name)
@@ -213,7 +213,7 @@ class Heap(object):
def malloc(self, size):
# return a block of right size (possibly rounded up)
- assert 0 <= size < sys.maxint
+ assert 0 <= size < sys.maxsize
if os.getpid() != self._lastpid:
self.__init__() # reinitialize after fork
self._lock.acquire()
@@ -239,7 +239,7 @@ class BufferWrapper(object):
_heap = Heap()
def __init__(self, size):
- assert 0 <= size < sys.maxint
+ assert 0 <= size < sys.maxsize
block = BufferWrapper._heap.malloc(size)
self._state = (block, size)
Finalize(self, BufferWrapper._heap.free, args=(block,))
diff --git a/Lib/multiprocessing/managers.py b/Lib/multiprocessing/managers.py
index ffe5812b89d..5588ead1169 100644
--- a/Lib/multiprocessing/managers.py
+++ b/Lib/multiprocessing/managers.py
@@ -44,28 +44,31 @@ import sys
import weakref
import threading
import array
-import Queue
+import queue
from traceback import format_exc
+from pickle import PicklingError
from multiprocessing import Process, current_process, active_children, Pool, util, connection
from multiprocessing.process import AuthenticationString
from multiprocessing.forking import exit, Popen, assert_spawning, ForkingPickler
from multiprocessing.util import Finalize, info
-try:
- from cPickle import PicklingError
-except ImportError:
- from pickle import PicklingError
-
#
# Register some things for pickling
#
def reduce_array(a):
- return array.array, (a.typecode, a.tostring())
+ return array.array, (a.typecode, a.tobytes())
ForkingPickler.register(array.array, reduce_array)
view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]
+if view_types[0] is not list: # only needed in Py3.0
+ def rebuild_as_list(obj):
+ return list, (list(obj),)
+ for view_type in view_types:
+ ForkingPickler.register(view_type, rebuild_as_list)
+ import copyreg
+ copyreg.pickle(view_type, rebuild_as_list)
#
# Type for identifying shared objects
@@ -131,7 +134,7 @@ def all_methods(obj):
temp = []
for name in dir(obj):
func = getattr(obj, name)
- if hasattr(func, '__call__'):
+ if callable(func):
temp.append(name)
return temp
@@ -211,7 +214,7 @@ class Server(object):
msg = ('#RETURN', result)
try:
c.send(msg)
- except Exception, e:
+ except Exception as e:
try:
c.send(('#TRACEBACK', format_exc()))
except Exception:
@@ -251,7 +254,7 @@ class Server(object):
try:
res = function(*args, **kwds)
- except Exception, e:
+ except Exception as e:
msg = ('#ERROR', e)
else:
typeid = gettypeid and gettypeid.get(methodname, None)
@@ -286,9 +289,9 @@ class Server(object):
try:
try:
send(msg)
- except Exception, e:
+ except Exception as e:
send(('#UNSERIALIZABLE', repr(msg)))
- except Exception, e:
+ except Exception as e:
util.info('exception in thread serving %r',
threading.current_thread().name)
util.info(' ... message was %r', msg)
@@ -321,7 +324,7 @@ class Server(object):
self.mutex.acquire()
try:
result = []
- keys = self.id_to_obj.keys()
+ keys = list(self.id_to_obj.keys())
keys.sort()
for ident in keys:
if ident != '0':
@@ -507,7 +510,7 @@ class BaseManager(object):
'''
assert self._state.value == State.INITIAL
- if initializer is not None and not hasattr(initializer, '__call__'):
+ if initializer is not None and not callable(initializer):
raise TypeError('initializer must be a callable')
# pipe over which we will retrieve address of server
@@ -653,7 +656,7 @@ class BaseManager(object):
getattr(proxytype, '_method_to_typeid_', None)
if method_to_typeid:
- for key, value in method_to_typeid.items():
+ for key, value in list(method_to_typeid.items()):
assert type(key) is str, '%r is not a string' % key
assert type(value) is str, '%r is not a string' % value
@@ -805,7 +808,7 @@ class BaseProxy(object):
util.debug('DECREF %r', token.id)
conn = _Client(token.address, authkey=authkey)
dispatch(conn, None, 'decref', (token.id,))
- except Exception, e:
+ except Exception as e:
util.debug('... decref failed %s', e)
else:
@@ -823,7 +826,7 @@ class BaseProxy(object):
self._manager = None
try:
self._incref()
- except Exception, e:
+ except Exception as e:
# the proxy may just be for a manager which has shutdown
util.info('incref failed: %s' % e)
@@ -894,8 +897,8 @@ def MakeProxyType(name, exposed, _cache={}):
dic = {}
for meth in exposed:
- exec '''def %s(self, *args, **kwds):
- return self._callmethod(%r, args, kwds)''' % (meth, meth) in dic
+ exec('''def %s(self, *args, **kwds):
+ return self._callmethod(%r, args, kwds)''' % (meth, meth), dic)
ProxyType = type(name, (BaseProxy,), dic)
ProxyType._exposed_ = exposed
@@ -936,7 +939,7 @@ class Namespace(object):
def __init__(self, **kwds):
self.__dict__.update(kwds)
def __repr__(self):
- items = self.__dict__.items()
+ items = list(self.__dict__.items())
temp = []
for name, value in items:
if not name.startswith('_'):
@@ -964,14 +967,11 @@ def Array(typecode, sequence, lock=True):
#
class IteratorProxy(BaseProxy):
- # XXX remove methods for Py3.0 and Py2.6
- _exposed_ = ('__next__', 'next', 'send', 'throw', 'close')
+ _exposed_ = ('__next__', 'send', 'throw', 'close')
def __iter__(self):
return self
def __next__(self, *args):
return self._callmethod('__next__', args)
- def next(self, *args):
- return self._callmethod('next', args)
def send(self, *args):
return self._callmethod('send', args)
def throw(self, *args):
@@ -993,7 +993,6 @@ class AcquirerProxy(BaseProxy):
class ConditionProxy(AcquirerProxy):
- # XXX will Condition.notfyAll() name be available in Py3.0?
_exposed_ = ('acquire', 'release', 'wait', 'notify', 'notify_all')
def wait(self, timeout=None):
return self._callmethod('wait', (timeout,))
@@ -1095,8 +1094,8 @@ class SyncManager(BaseManager):
this class.
'''
-SyncManager.register('Queue', Queue.Queue)
-SyncManager.register('JoinableQueue', Queue.Queue)
+SyncManager.register('Queue', queue.Queue)
+SyncManager.register('JoinableQueue', queue.Queue)
SyncManager.register('Event', threading.Event, EventProxy)
SyncManager.register('Lock', threading.Lock, AcquirerProxy)
SyncManager.register('RLock', threading.RLock, AcquirerProxy)
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 00c904a8a73..7502ff89f43 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -39,7 +39,7 @@ __all__ = ['Pool']
#
import threading
-import Queue
+import queue
import itertools
import collections
import time
@@ -62,7 +62,7 @@ TERMINATE = 2
job_counter = itertools.count()
def mapstar(args):
- return map(*args)
+ return list(map(*args))
#
# Code run by worker processes
@@ -111,7 +111,7 @@ def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
job, i, func, args, kwds = task
try:
result = (True, func(*args, **kwds))
- except Exception, e:
+ except Exception as e:
result = (False, e)
try:
put((job, i, result))
@@ -129,14 +129,14 @@ def worker(inqueue, outqueue, initializer=None, initargs=(), maxtasks=None):
class Pool(object):
'''
- Class which supports an async version of the `apply()` builtin
+ Class which supports an async version of applying functions to arguments.
'''
Process = Process
def __init__(self, processes=None, initializer=None, initargs=(),
maxtasksperchild=None):
self._setup_queues()
- self._taskqueue = Queue.Queue()
+ self._taskqueue = queue.Queue()
self._cache = {}
self._state = RUN
self._maxtasksperchild = maxtasksperchild
@@ -151,7 +151,7 @@ class Pool(object):
if processes < 1:
raise ValueError("Number of processes must be at least 1")
- if initializer is not None and not hasattr(initializer, '__call__'):
+ if initializer is not None and not callable(initializer):
raise TypeError('initializer must be a callable')
self._processes = processes
@@ -237,21 +237,22 @@ class Pool(object):
def apply(self, func, args=(), kwds={}):
'''
- Equivalent of `apply()` builtin
+ Equivalent of `func(*args, **kwds)`.
'''
assert self._state == RUN
return self.apply_async(func, args, kwds).get()
def map(self, func, iterable, chunksize=None):
'''
- Equivalent of `map()` builtin
+ Apply `func` to each element in `iterable`, collecting the results
+ in a list that is returned.
'''
assert self._state == RUN
return self.map_async(func, iterable, chunksize).get()
def imap(self, func, iterable, chunksize=1):
'''
- Equivalent of `itertools.imap()` -- can be MUCH slower than `Pool.map()`
+ Equivalent of `map()` -- can be MUCH slower than `Pool.map()`.
'''
assert self._state == RUN
if chunksize == 1:
@@ -269,7 +270,7 @@ class Pool(object):
def imap_unordered(self, func, iterable, chunksize=1):
'''
- Like `imap()` method but ordering of results is arbitrary
+ Like `imap()` method but ordering of results is arbitrary.
'''
assert self._state == RUN
if chunksize == 1:
@@ -285,18 +286,20 @@ class Pool(object):
for i, x in enumerate(task_batches)), result._set_length))
return (item for chunk in result for item in chunk)
- def apply_async(self, func, args=(), kwds={}, callback=None):
+ def apply_async(self, func, args=(), kwds={}, callback=None,
+ error_callback=None):
'''
- Asynchronous equivalent of `apply()` builtin
+ Asynchronous version of `apply()` method.
'''
assert self._state == RUN
- result = ApplyResult(self._cache, callback)
+ result = ApplyResult(self._cache, callback, error_callback)
self._taskqueue.put(([(result._job, None, func, args, kwds)], None))
return result
- def map_async(self, func, iterable, chunksize=None, callback=None):
+ def map_async(self, func, iterable, chunksize=None, callback=None,
+ error_callback=None):
'''
- Asynchronous equivalent of `map()` builtin
+ Asynchronous version of `map()` method.
'''
assert self._state == RUN
if not hasattr(iterable, '__len__'):
@@ -310,7 +313,8 @@ class Pool(object):
chunksize = 0
task_batches = Pool._get_tasks(func, iterable, chunksize)
- result = MapResult(self._cache, chunksize, len(iterable), callback)
+ result = MapResult(self._cache, chunksize, len(iterable), callback,
+ error_callback=error_callback)
self._taskqueue.put((((result._job, i, mapstar, (x,), {})
for i, x in enumerate(task_batches)), None))
return result
@@ -490,7 +494,7 @@ class Pool(object):
# workers because we don't want workers to be restarted behind our back.
debug('joining worker handler')
if threading.current_thread() is not worker_handler:
- worker_handler.join(1e100)
+ worker_handler.join()
# Terminate workers which haven't already finished.
if pool and hasattr(pool[0], 'terminate'):
@@ -501,11 +505,11 @@ class Pool(object):
debug('joining task handler')
if threading.current_thread() is not task_handler:
- task_handler.join(1e100)
+ task_handler.join()
debug('joining result handler')
if threading.current_thread() is not result_handler:
- result_handler.join(1e100)
+ result_handler.join()
if pool and hasattr(pool[0], 'terminate'):
debug('joining pool workers')
@@ -521,12 +525,13 @@ class Pool(object):
class ApplyResult(object):
- def __init__(self, cache, callback):
+ def __init__(self, cache, callback, error_callback):
self._cond = threading.Condition(threading.Lock())
- self._job = job_counter.next()
+ self._job = next(job_counter)
self._cache = cache
self._ready = False
self._callback = callback
+ self._error_callback = error_callback
cache[self._job] = self
def ready(self):
@@ -557,6 +562,8 @@ class ApplyResult(object):
self._success, self._value = obj
if self._callback and self._success:
self._callback(self._value)
+ if self._error_callback and not self._success:
+ self._error_callback(self._value)
self._cond.acquire()
try:
self._ready = True
@@ -571,8 +578,9 @@ class ApplyResult(object):
class MapResult(ApplyResult):
- def __init__(self, cache, chunksize, length, callback):
- ApplyResult.__init__(self, cache, callback)
+ def __init__(self, cache, chunksize, length, callback, error_callback):
+ ApplyResult.__init__(self, cache, callback,
+ error_callback=error_callback)
self._success = True
self._value = [None] * length
self._chunksize = chunksize
@@ -598,10 +606,11 @@ class MapResult(ApplyResult):
self._cond.notify()
finally:
self._cond.release()
-
else:
self._success = False
self._value = result
+ if self._error_callback:
+ self._error_callback(self._value)
del self._cache[self._job]
self._cond.acquire()
try:
@@ -618,7 +627,7 @@ class IMapIterator(object):
def __init__(self, cache):
self._cond = threading.Condition(threading.Lock())
- self._job = job_counter.next()
+ self._job = next(job_counter)
self._cache = cache
self._items = collections.deque()
self._index = 0
@@ -712,8 +721,8 @@ class ThreadPool(Pool):
Pool.__init__(self, processes, initializer, initargs)
def _setup_queues(self):
- self._inqueue = Queue.Queue()
- self._outqueue = Queue.Queue()
+ self._inqueue = queue.Queue()
+ self._outqueue = queue.Queue()
self._quick_put = self._inqueue.put
self._quick_get = self._outqueue.get
diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py
index 482ea0a37a8..3262b50f50b 100644
--- a/Lib/multiprocessing/process.py
+++ b/Lib/multiprocessing/process.py
@@ -42,6 +42,7 @@ import os
import sys
import signal
import itertools
+from _weakrefset import WeakSet
#
#
@@ -93,7 +94,7 @@ class Process(object):
def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
assert group is None, 'group argument must be None for now'
- count = _current_process._counter.next()
+ count = next(_current_process._counter)
self._identity = _current_process._identity + (count,)
self._authkey = _current_process._authkey
self._daemonic = _current_process._daemonic
@@ -105,6 +106,7 @@ class Process(object):
self._kwargs = dict(kwargs)
self._name = name or type(self).__name__ + '-' + \
':'.join(str(i) for i in self._identity)
+ _dangling.add(self)
def run(self):
'''
@@ -164,7 +166,7 @@ class Process(object):
@name.setter
def name(self, name):
- assert isinstance(name, basestring), 'name must be a string'
+ assert isinstance(name, str), 'name must be a string'
self._name = name
@property
@@ -245,37 +247,45 @@ class Process(object):
try:
self._children = set()
self._counter = itertools.count(1)
- try:
- sys.stdin.close()
- sys.stdin = open(os.devnull)
- except (OSError, ValueError):
- pass
+ if sys.stdin is not None:
+ try:
+ sys.stdin.close()
+ sys.stdin = open(os.devnull)
+ except (OSError, ValueError):
+ pass
+ old_process = _current_process
_current_process = self
- util._finalizer_registry.clear()
- util._run_after_forkers()
+ try:
+ util._finalizer_registry.clear()
+ util._run_after_forkers()
+ finally:
+ # delay finalization of the old process object until after
+ # _run_after_forkers() is executed
+ del old_process
util.info('child process calling self.run()')
try:
self.run()
exitcode = 0
finally:
util._exit_function()
- except SystemExit, e:
+ except SystemExit as e:
if not e.args:
exitcode = 1
elif isinstance(e.args[0], int):
exitcode = e.args[0]
else:
sys.stderr.write(str(e.args[0]) + '\n')
- sys.stderr.flush()
exitcode = 0 if isinstance(e.args[0], str) else 1
except:
exitcode = 1
import traceback
sys.stderr.write('Process %s:\n' % self.name)
- sys.stderr.flush()
traceback.print_exc()
+ finally:
+ util.info('process exiting with exitcode %d' % exitcode)
+ sys.stdout.flush()
+ sys.stderr.flush()
- util.info('process exiting with exitcode %d' % exitcode)
return exitcode
#
@@ -318,6 +328,9 @@ del _MainProcess
_exitcode_to_name = {}
-for name, signum in signal.__dict__.items():
+for name, signum in list(signal.__dict__.items()):
if name[:3]=='SIG' and '_' not in name:
_exitcode_to_name[-signum] = name
+
+# For debug and leak testing
+_dangling = WeakSet()
diff --git a/Lib/multiprocessing/queues.py b/Lib/multiprocessing/queues.py
index 433c7e29dee..51d991245c1 100644
--- a/Lib/multiprocessing/queues.py
+++ b/Lib/multiprocessing/queues.py
@@ -42,7 +42,7 @@ import time
import atexit
import weakref
-from Queue import Empty, Full
+from queue import Empty, Full
import _multiprocessing
from multiprocessing import Pipe
from multiprocessing.synchronize import Lock, BoundedSemaphore, Semaphore, Condition
@@ -192,7 +192,13 @@ class Queue(object):
debug('... done self._thread.start()')
# On process exit we will wait for data to be flushed to pipe.
- if not self._joincancelled:
+ #
+ # However, if this process created the queue then all
+ # processes which use the queue will be descendants of this
+ # process. Therefore waiting for the queue to be flushed
+ # is pointless once all the child processes have been joined.
+ created_by_this_process = (self._opid == os.getpid())
+ if not self._joincancelled and not created_by_this_process:
self._jointhread = Finalize(
self._thread, Queue._finalize_join,
[weakref.ref(self._thread)],
@@ -268,7 +274,7 @@ class Queue(object):
wrelease()
except IndexError:
pass
- except Exception, e:
+ except Exception as e:
# Since this runs in a daemon thread the resources it uses
# may be become unusable while the process is cleaning up.
# We ignore errors which happen after the process has
diff --git a/Lib/multiprocessing/sharedctypes.py b/Lib/multiprocessing/sharedctypes.py
index 1eb044dd54f..1e694da49d9 100644
--- a/Lib/multiprocessing/sharedctypes.py
+++ b/Lib/multiprocessing/sharedctypes.py
@@ -78,7 +78,7 @@ def RawArray(typecode_or_type, size_or_initializer):
Returns a ctypes array allocated from shared memory
'''
type_ = typecode_to_type.get(typecode_or_type, typecode_or_type)
- if isinstance(size_or_initializer, (int, long)):
+ if isinstance(size_or_initializer, int):
type_ = type_ * size_or_initializer
obj = _new_value(type_)
ctypes.memset(ctypes.addressof(obj), 0, ctypes.sizeof(obj))
@@ -89,13 +89,10 @@ def RawArray(typecode_or_type, size_or_initializer):
result.__init__(*size_or_initializer)
return result
-def Value(typecode_or_type, *args, **kwds):
+def Value(typecode_or_type, *args, lock=None):
'''
Return a synchronization wrapper for a Value
'''
- lock = kwds.pop('lock', None)
- if kwds:
- raise ValueError('unrecognized keyword argument(s): %s' % kwds.keys())
obj = RawValue(typecode_or_type, *args)
if lock is False:
return obj
@@ -111,7 +108,7 @@ def Array(typecode_or_type, size_or_initializer, **kwds):
'''
lock = kwds.pop('lock', None)
if kwds:
- raise ValueError('unrecognized keyword argument(s): %s' % kwds.keys())
+ raise ValueError('unrecognized keyword argument(s): %s' % list(kwds.keys()))
obj = RawArray(typecode_or_type, size_or_initializer)
if lock is False:
return obj
@@ -174,7 +171,7 @@ def make_property(name):
return prop_cache[name]
except KeyError:
d = {}
- exec template % ((name,)*7) in d
+ exec(template % ((name,)*7), d)
prop_cache[name] = d[name]
return d[name]
diff --git a/Lib/multiprocessing/synchronize.py b/Lib/multiprocessing/synchronize.py
index 4b077e53aed..70ae82569cc 100644
--- a/Lib/multiprocessing/synchronize.py
+++ b/Lib/multiprocessing/synchronize.py
@@ -62,7 +62,7 @@ except (ImportError):
# Constants
#
-RECURSIVE_MUTEX, SEMAPHORE = range(2)
+RECURSIVE_MUTEX, SEMAPHORE = list(range(2))
SEM_VALUE_MAX = _multiprocessing.SemLock.SEM_VALUE_MAX
#
@@ -238,19 +238,20 @@ class Condition(object):
# release lock
count = self._lock._semlock._count()
- for i in xrange(count):
+ for i in range(count):
self._lock.release()
try:
# wait for notification or timeout
- self._wait_semaphore.acquire(True, timeout)
+ ret = self._wait_semaphore.acquire(True, timeout)
finally:
# indicate that this thread has woken
self._woken_count.release()
# reacquire lock
- for i in xrange(count):
+ for i in range(count):
self._lock.acquire()
+ return ret
def notify(self):
assert self._lock._semlock._is_mine(), 'lock is not owned'
@@ -285,7 +286,7 @@ class Condition(object):
sleepers += 1
if sleepers:
- for i in xrange(sleepers):
+ for i in range(sleepers):
self._woken_count.acquire() # wait for a sleeper to wake
# rezero wait_semaphore in case some timeouts just happened
diff --git a/Lib/multiprocessing/util.py b/Lib/multiprocessing/util.py
index c65dd9904ed..61b05335ac6 100644
--- a/Lib/multiprocessing/util.py
+++ b/Lib/multiprocessing/util.py
@@ -153,11 +153,11 @@ def _run_after_forkers():
for (index, ident, func), obj in items:
try:
func(obj)
- except Exception, e:
+ except Exception as e:
info('after forker raised exception %s', e)
def register_after_fork(obj, func):
- _afterfork_registry[(_afterfork_counter.next(), id(obj), func)] = obj
+ _afterfork_registry[(next(_afterfork_counter), id(obj), func)] = obj
#
# Finalization using weakrefs
@@ -182,7 +182,7 @@ class Finalize(object):
self._callback = callback
self._args = args
self._kwargs = kwargs or {}
- self._key = (exitpriority, _finalizer_counter.next())
+ self._key = (exitpriority, next(_finalizer_counter))
_finalizer_registry[self._key] = self
@@ -247,12 +247,18 @@ def _run_finalizers(minpriority=None):
Finalizers with highest priority are called first; finalizers with
the same priority will be called in reverse order of creation.
'''
+ if _finalizer_registry is None:
+ # This function may be called after this module's globals are
+ # destroyed. See the _exit_function function in this module for more
+ # notes.
+ return
+
if minpriority is None:
f = lambda p : p[0][0] is not None
else:
f = lambda p : p[0][0] is not None and p[0][0] >= minpriority
- items = [x for x in _finalizer_registry.items() if f(x)]
+ items = [x for x in list(_finalizer_registry.items()) if f(x)]
items.sort(reverse=True)
for key, finalizer in items:
@@ -278,24 +284,42 @@ def is_exiting():
_exiting = False
-def _exit_function():
- global _exiting
-
- info('process shutting down')
- debug('running all "atexit" finalizers with priority >= 0')
- _run_finalizers(0)
+def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
+ active_children=active_children,
+ current_process=current_process):
+ # We hold on to references to functions in the arglist due to the
+ # situation described below, where this function is called after this
+ # module's globals are destroyed.
- for p in active_children():
- if p._daemonic:
- info('calling terminate() for daemon %s', p.name)
- p._popen.terminate()
-
- for p in active_children():
- info('calling join() for process %s', p.name)
- p.join()
+ global _exiting
- debug('running the remaining "atexit" finalizers')
- _run_finalizers()
+ if not _exiting:
+ _exiting = True
+
+ info('process shutting down')
+ debug('running all "atexit" finalizers with priority >= 0')
+ _run_finalizers(0)
+ if current_process() is not None:
+ # We check if the current process is None here because if
+ # it's None, any call to ``active_children()`` will raise an
+ # AttributeError (active_children winds up trying to get
+ # attributes from util._current_process). This happens in a
+ # variety of shutdown circumstances that are not well-understood
+ # because module-scope variables are not apparently supposed to
+ # be destroyed until after this function is called. However,
+ # they are indeed destroyed before this function is called. See
+ # issues #9775 and #15881. Also related: #4106, #9205, and #9207.
+ for p in active_children():
+ if p._daemonic:
+ info('calling terminate() for daemon %s', p.name)
+ p._popen.terminate()
+
+ for p in active_children():
+ info('calling join() for process %s', p.name)
+ p.join()
+
+ debug('running the remaining "atexit" finalizers')
+ _run_finalizers()
atexit.register(_exit_function)
diff --git a/Lib/mutex.py b/Lib/mutex.py
deleted file mode 100644
index f8acba4a35f..00000000000
--- a/Lib/mutex.py
+++ /dev/null
@@ -1,55 +0,0 @@
-"""Mutual exclusion -- for use with module sched
-
-A mutex has two pieces of state -- a 'locked' bit and a queue.
-When the mutex is not locked, the queue is empty.
-Otherwise, the queue contains 0 or more (function, argument) pairs
-representing functions (or methods) waiting to acquire the lock.
-When the mutex is unlocked while the queue is not empty,
-the first queue entry is removed and its function(argument) pair called,
-implying it now has the lock.
-
-Of course, no multi-threading is implied -- hence the funny interface
-for lock, where a function is called once the lock is aquired.
-"""
-from warnings import warnpy3k
-warnpy3k("the mutex module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-from collections import deque
-
-class mutex:
- def __init__(self):
- """Create a new mutex -- initially unlocked."""
- self.locked = False
- self.queue = deque()
-
- def test(self):
- """Test the locked bit of the mutex."""
- return self.locked
-
- def testandset(self):
- """Atomic test-and-set -- grab the lock if it is not set,
- return True if it succeeded."""
- if not self.locked:
- self.locked = True
- return True
- else:
- return False
-
- def lock(self, function, argument):
- """Lock a mutex, call the function with supplied argument
- when it is acquired. If the mutex is already locked, place
- function and argument in the queue."""
- if self.testandset():
- function(argument)
- else:
- self.queue.append((function, argument))
-
- def unlock(self):
- """Unlock a mutex. If the queue is not empty, call the next
- function with its argument."""
- if self.queue:
- function, argument = self.queue.popleft()
- function(argument)
- else:
- self.locked = False
diff --git a/Lib/netrc.py b/Lib/netrc.py
index 0fd37e304f5..c96db6f96a6 100644
--- a/Lib/netrc.py
+++ b/Lib/netrc.py
@@ -2,7 +2,7 @@
# Module and documentation by Eric S. Raymond, 21 Dec 1998
-import os, shlex
+import io, os, shlex
__all__ = ["netrc", "NetrcParseError"]
@@ -37,15 +37,13 @@ class netrc:
lexer.commenters = lexer.commenters.replace('#', '')
while 1:
# Look for a machine, default, or macdef top-level keyword
+ saved_lineno = lexer.lineno
toplevel = tt = lexer.get_token()
if not tt:
break
elif tt[0] == '#':
- # seek to beginning of comment, in case reading the token put
- # us on a new line, and then skip the rest of the line.
- pos = len(tt) + 1
- lexer.instream.seek(-pos, 1)
- lexer.instream.readline()
+ if lexer.lineno == saved_lineno and len(tt) == 1:
+ lexer.instream.readline()
continue
elif tt == 'machine':
entryname = lexer.get_token()
@@ -119,4 +117,4 @@ class netrc:
return rep
if __name__ == '__main__':
- print netrc()
+ print(netrc())
diff --git a/Lib/new.py b/Lib/new.py
deleted file mode 100644
index 2a6e6315529..00000000000
--- a/Lib/new.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""Create new objects of various types. Deprecated.
-
-This module is no longer required except for backward compatibility.
-Objects of most types can now be created by calling the type object.
-"""
-from warnings import warnpy3k
-warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' "
- "module instead.", stacklevel=2)
-del warnpy3k
-
-from types import ClassType as classobj
-from types import FunctionType as function
-from types import InstanceType as instance
-from types import MethodType as instancemethod
-from types import ModuleType as module
-
-from types import CodeType as code
diff --git a/Lib/nntplib.py b/Lib/nntplib.py
index 2dc82a90ae1..32bffd8e27c 100644
--- a/Lib/nntplib.py
+++ b/Lib/nntplib.py
@@ -1,13 +1,16 @@
-"""An NNTP client class based on RFC 977: Network News Transfer Protocol.
+"""An NNTP client class based on:
+- RFC 977: Network News Transfer Protocol
+- RFC 2980: Common NNTP Extensions
+- RFC 3977: Network News Transfer Protocol (version 2)
Example:
>>> from nntplib import NNTP
>>> s = NNTP('news')
>>> resp, count, first, last, name = s.group('comp.lang.python')
->>> print 'Group', name, 'has', count, 'articles, range', first, 'to', last
+>>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
Group comp.lang.python has 51 articles, range 5770 to 5821
->>> resp, subs = s.xhdr('subject', first + '-' + last)
+>>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
>>> resp = s.quit()
>>>
@@ -15,7 +18,7 @@ Here 'resp' is the server response line.
Error responses are turned into exceptions.
To post an article from a file:
->>> f = open(filename, 'r') # file containing article, including header
+>>> f = open(filename, 'rb') # file containing article, including header
>>> resp = s.post(f)
>>>
@@ -27,15 +30,60 @@ are strings, not numbers, since they are rarely used for calculations.
# RFC 977 by Brian Kantor and Phil Lapsley.
# xover, xgtitle, xpath, date methods by Kevan Heydon
+# Incompatible changes from the 2.x nntplib:
+# - all commands are encoded as UTF-8 data (using the "surrogateescape"
+# error handler), except for raw message data (POST, IHAVE)
+# - all responses are decoded as UTF-8 data (using the "surrogateescape"
+# error handler), except for raw message data (ARTICLE, HEAD, BODY)
+# - the `file` argument to various methods is keyword-only
+#
+# - NNTP.date() returns a datetime object
+# - NNTP.newgroups() and NNTP.newnews() take a datetime (or date) object,
+# rather than a pair of (date, time) strings.
+# - NNTP.newgroups() and NNTP.list() return a list of GroupInfo named tuples
+# - NNTP.descriptions() returns a dict mapping group names to descriptions
+# - NNTP.xover() returns a list of dicts mapping field names (header or metadata)
+# to field values; each dict representing a message overview.
+# - NNTP.article(), NNTP.head() and NNTP.body() return a (response, ArticleInfo)
+# tuple.
+# - the "internal" methods have been marked private (they now start with
+# an underscore)
+
+# Other changes from the 2.x/3.1 nntplib:
+# - automatic querying of capabilities at connect
+# - New method NNTP.getcapabilities()
+# - New method NNTP.over()
+# - New helper function decode_header()
+# - NNTP.post() and NNTP.ihave() accept file objects, bytes-like objects and
+# arbitrary iterables yielding lines.
+# - An extensive test suite :-)
+
+# TODO:
+# - return structured data (GroupInfo etc.) everywhere
+# - support HDR
# Imports
import re
import socket
-
-__all__ = ["NNTP","NNTPReplyError","NNTPTemporaryError",
- "NNTPPermanentError","NNTPProtocolError","NNTPDataError",
- "error_reply","error_temp","error_perm","error_proto",
- "error_data",]
+import collections
+import datetime
+import warnings
+
+try:
+ import ssl
+except ImportError:
+ _have_ssl = False
+else:
+ _have_ssl = True
+
+from email.header import decode_header as _email_decode_header
+from socket import _GLOBAL_DEFAULT_TIMEOUT
+
+__all__ = ["NNTP",
+ "NNTPReplyError", "NNTPTemporaryError", "NNTPPermanentError",
+ "NNTPProtocolError", "NNTPDataError",
+ "decode_header",
+ ]
# Exceptions raised when an error or invalid response is received
class NNTPError(Exception):
@@ -67,39 +115,203 @@ class NNTPDataError(NNTPError):
"""Error in response data"""
pass
-# for backwards compatibility
-error_reply = NNTPReplyError
-error_temp = NNTPTemporaryError
-error_perm = NNTPPermanentError
-error_proto = NNTPProtocolError
-error_data = NNTPDataError
-
-
# Standard port used by NNTP servers
NNTP_PORT = 119
-
+NNTP_SSL_PORT = 563
# Response numbers that are followed by additional text (e.g. article)
-LONGRESP = ['100', '215', '220', '221', '222', '224', '230', '231', '282']
-
+_LONGRESP = {
+ '100', # HELP
+ '101', # CAPABILITIES
+ '211', # LISTGROUP (also not multi-line with GROUP)
+ '215', # LIST
+ '220', # ARTICLE
+ '221', # HEAD, XHDR
+ '222', # BODY
+ '224', # OVER, XOVER
+ '225', # HDR
+ '230', # NEWNEWS
+ '231', # NEWGROUPS
+ '282', # XGTITLE
+}
+
+# Default decoded value for LIST OVERVIEW.FMT if not supported
+_DEFAULT_OVERVIEW_FMT = [
+ "subject", "from", "date", "message-id", "references", ":bytes", ":lines"]
+
+# Alternative names allowed in LIST OVERVIEW.FMT response
+_OVERVIEW_FMT_ALTERNATIVES = {
+ 'bytes': ':bytes',
+ 'lines': ':lines',
+}
# Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
-CRLF = '\r\n'
+_CRLF = b'\r\n'
+GroupInfo = collections.namedtuple('GroupInfo',
+ ['group', 'last', 'first', 'flag'])
+ArticleInfo = collections.namedtuple('ArticleInfo',
+ ['number', 'message_id', 'lines'])
-# The class itself
-class NNTP:
- def __init__(self, host, port=NNTP_PORT, user=None, password=None,
- readermode=None, usenetrc=True):
+
+# Helper function(s)
+def decode_header(header_str):
+ """Takes an unicode string representing a munged header value
+ and decodes it as a (possibly non-ASCII) readable value."""
+ parts = []
+ for v, enc in _email_decode_header(header_str):
+ if isinstance(v, bytes):
+ parts.append(v.decode(enc or 'ascii'))
+ else:
+ parts.append(v)
+ return ' '.join(parts)
+
+def _parse_overview_fmt(lines):
+ """Parse a list of string representing the response to LIST OVERVIEW.FMT
+ and return a list of header/metadata names.
+ Raises NNTPDataError if the response is not compliant
+ (cf. RFC 3977, section 8.4)."""
+ fmt = []
+ for line in lines:
+ if line[0] == ':':
+ # Metadata name (e.g. ":bytes")
+ name, _, suffix = line[1:].partition(':')
+ name = ':' + name
+ else:
+ # Header name (e.g. "Subject:" or "Xref:full")
+ name, _, suffix = line.partition(':')
+ name = name.lower()
+ name = _OVERVIEW_FMT_ALTERNATIVES.get(name, name)
+ # Should we do something with the suffix?
+ fmt.append(name)
+ defaults = _DEFAULT_OVERVIEW_FMT
+ if len(fmt) < len(defaults):
+ raise NNTPDataError("LIST OVERVIEW.FMT response too short")
+ if fmt[:len(defaults)] != defaults:
+ raise NNTPDataError("LIST OVERVIEW.FMT redefines default fields")
+ return fmt
+
+def _parse_overview(lines, fmt, data_process_func=None):
+ """Parse the response to a OVER or XOVER command according to the
+ overview format `fmt`."""
+ n_defaults = len(_DEFAULT_OVERVIEW_FMT)
+ overview = []
+ for line in lines:
+ fields = {}
+ article_number, *tokens = line.split('\t')
+ article_number = int(article_number)
+ for i, token in enumerate(tokens):
+ if i >= len(fmt):
+ # XXX should we raise an error? Some servers might not
+ # support LIST OVERVIEW.FMT and still return additional
+ # headers.
+ continue
+ field_name = fmt[i]
+ is_metadata = field_name.startswith(':')
+ if i >= n_defaults and not is_metadata:
+ # Non-default header names are included in full in the response
+ # (unless the field is totally empty)
+ h = field_name + ": "
+ if token and token[:len(h)].lower() != h:
+ raise NNTPDataError("OVER/XOVER response doesn't include "
+ "names of additional headers")
+ token = token[len(h):] if token else None
+ fields[fmt[i]] = token
+ overview.append((article_number, fields))
+ return overview
+
+def _parse_datetime(date_str, time_str=None):
+ """Parse a pair of (date, time) strings, and return a datetime object.
+ If only the date is given, it is assumed to be date and time
+ concatenated together (e.g. response to the DATE command).
+ """
+ if time_str is None:
+ time_str = date_str[-6:]
+ date_str = date_str[:-6]
+ hours = int(time_str[:2])
+ minutes = int(time_str[2:4])
+ seconds = int(time_str[4:])
+ year = int(date_str[:-4])
+ month = int(date_str[-4:-2])
+ day = int(date_str[-2:])
+ # RFC 3977 doesn't say how to interpret 2-char years. Assume that
+ # there are no dates before 1970 on Usenet.
+ if year < 70:
+ year += 2000
+ elif year < 100:
+ year += 1900
+ return datetime.datetime(year, month, day, hours, minutes, seconds)
+
+def _unparse_datetime(dt, legacy=False):
+ """Format a date or datetime object as a pair of (date, time) strings
+ in the format required by the NEWNEWS and NEWGROUPS commands. If a
+ date object is passed, the time is assumed to be midnight (00h00).
+
+ The returned representation depends on the legacy flag:
+ * if legacy is False (the default):
+ date has the YYYYMMDD format and time the HHMMSS format
+ * if legacy is True:
+ date has the YYMMDD format and time the HHMMSS format.
+ RFC 3977 compliant servers should understand both formats; therefore,
+ legacy is only needed when talking to old servers.
+ """
+ if not isinstance(dt, datetime.datetime):
+ time_str = "000000"
+ else:
+ time_str = "{0.hour:02d}{0.minute:02d}{0.second:02d}".format(dt)
+ y = dt.year
+ if legacy:
+ y = y % 100
+ date_str = "{0:02d}{1.month:02d}{1.day:02d}".format(y, dt)
+ else:
+ date_str = "{0:04d}{1.month:02d}{1.day:02d}".format(y, dt)
+ return date_str, time_str
+
+
+if _have_ssl:
+
+ def _encrypt_on(sock, context):
+ """Wrap a socket in SSL/TLS. Arguments:
+ - sock: Socket to wrap
+ - context: SSL context to use for the encrypted connection
+ Returns:
+ - sock: New, encrypted socket.
+ """
+ # Generate a default SSL context if none was passed.
+ if context is None:
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ # SSLv2 considered harmful.
+ context.options |= ssl.OP_NO_SSLv2
+ return context.wrap_socket(sock)
+
+
+# The classes themselves
+class _NNTPBase:
+ # UTF-8 is the character set for all NNTP commands and responses: they
+ # are automatically encoded (when sending) and decoded (and receiving)
+ # by this class.
+ # However, some multi-line data blocks can contain arbitrary bytes (for
+ # example, latin-1 or utf-16 data in the body of a message). Commands
+ # taking (POST, IHAVE) or returning (HEAD, BODY, ARTICLE) raw message
+ # data will therefore only accept and produce bytes objects.
+ # Furthermore, since there could be non-compliant servers out there,
+ # we use 'surrogateescape' as the error handler for fault tolerance
+ # and easy round-tripping. This could be useful for some applications
+ # (e.g. NNTP gateways).
+
+ encoding = 'utf-8'
+ errors = 'surrogateescape'
+
+ def __init__(self, file, host,
+ readermode=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):
"""Initialize an instance. Arguments:
- - host: hostname to connect to
- - port: port to connect to (default the standard NNTP port)
- - user: username to authenticate with
- - password: password to use with username
+ - file: file-like object (open for read/write in binary mode)
+ - host: hostname of the server
- readermode: if true, send 'mode reader' command after
connecting.
+ - timeout: timeout (in seconds) used for socket connections
readermode is sometimes necessary if you are connecting to an
NNTP server on the local machine and intend to call
@@ -108,65 +320,36 @@ class NNTP:
readermode.
"""
self.host = host
- self.port = port
- self.sock = socket.create_connection((host, port))
- self.file = self.sock.makefile('rb')
+ self.file = file
self.debugging = 0
- self.welcome = self.getresp()
-
- # 'mode reader' is sometimes necessary to enable 'reader' mode.
- # However, the order in which 'mode reader' and 'authinfo' need to
- # arrive differs between some NNTP servers. Try to send
- # 'mode reader', and if it fails with an authorization failed
- # error, try again after sending authinfo.
- readermode_afterauth = 0
- if readermode:
- try:
- self.welcome = self.shortcmd('mode reader')
- except NNTPPermanentError:
- # error 500, probably 'not implemented'
- pass
- except NNTPTemporaryError, e:
- if user and e.response[:3] == '480':
- # Need authorization before 'mode reader'
- readermode_afterauth = 1
- else:
- raise
- # If no login/password was specified, try to get them from ~/.netrc
- # Presume that if .netc has an entry, NNRP authentication is required.
- try:
- if usenetrc and not user:
- import netrc
- credentials = netrc.netrc()
- auth = credentials.authenticators(host)
- if auth:
- user = auth[0]
- password = auth[2]
- except IOError:
- pass
- # Perform NNRP authentication if needed.
- if user:
- resp = self.shortcmd('authinfo user '+user)
- if resp[:3] == '381':
- if not password:
- raise NNTPReplyError(resp)
- else:
- resp = self.shortcmd(
- 'authinfo pass '+password)
- if resp[:3] != '281':
- raise NNTPPermanentError(resp)
- if readermode_afterauth:
- try:
- self.welcome = self.shortcmd('mode reader')
- except NNTPPermanentError:
- # error 500, probably 'not implemented'
- pass
-
-
- # Get the welcome message from the server
- # (this is read and squirreled away by __init__()).
- # If the response code is 200, posting is allowed;
- # if it 201, posting is not allowed
+ self.welcome = self._getresp()
+
+ # Inquire about capabilities (RFC 3977).
+ self._caps = None
+ self.getcapabilities()
+
+ # 'MODE READER' is sometimes necessary to enable 'reader' mode.
+ # However, the order in which 'MODE READER' and 'AUTHINFO' need to
+ # arrive differs between some NNTP servers. If _setreadermode() fails
+ # with an authorization failed error, it will set this to True;
+ # the login() routine will interpret that as a request to try again
+ # after performing its normal function.
+ # Enable only if we're not already in READER mode anyway.
+ self.readermode_afterauth = False
+ if readermode and 'READER' not in self._caps:
+ self._setreadermode()
+ if not self.readermode_afterauth:
+ # Capabilities might have changed after MODE READER
+ self._caps = None
+ self.getcapabilities()
+
+ # RFC 4642 2.2.2: Both the client and the server MUST know if there is
+ # a TLS session active. A client MUST NOT attempt to start a TLS
+ # session if a TLS session is already active.
+ self.tls_on = False
+
+ # Log in and encryption setup order is left to subclasses.
+ self.authenticated = False
def getwelcome(self):
"""Get the welcome message from the server
@@ -174,9 +357,31 @@ class NNTP:
If the response code is 200, posting is allowed;
if it 201, posting is not allowed."""
- if self.debugging: print '*welcome*', repr(self.welcome)
+ if self.debugging: print('*welcome*', repr(self.welcome))
return self.welcome
+ def getcapabilities(self):
+ """Get the server capabilities, as read by __init__().
+ If the CAPABILITIES command is not supported, an empty dict is
+ returned."""
+ if self._caps is None:
+ self.nntp_version = 1
+ self.nntp_implementation = None
+ try:
+ resp, caps = self.capabilities()
+ except (NNTPPermanentError, NNTPTemporaryError):
+ # Server doesn't support capabilities
+ self._caps = {}
+ else:
+ self._caps = caps
+ if 'VERSION' in caps:
+ # The server can advertise several supported versions,
+ # choose the highest.
+ self.nntp_version = max(map(int, caps['VERSION']))
+ if 'IMPLEMENTATION' in caps:
+ self.nntp_implementation = ' '.join(caps['IMPLEMENTATION'])
+ return self._caps
+
def set_debuglevel(self, level):
"""Set the debugging level. Argument 'level' means:
0: no debugging output (default)
@@ -186,33 +391,43 @@ class NNTP:
self.debugging = level
debug = set_debuglevel
- def putline(self, line):
- """Internal: send one line to the server, appending CRLF."""
- line = line + CRLF
- if self.debugging > 1: print '*put*', repr(line)
- self.sock.sendall(line)
-
- def putcmd(self, line):
- """Internal: send one command to the server (through putline())."""
- if self.debugging: print '*cmd*', repr(line)
- self.putline(line)
-
- def getline(self):
- """Internal: return one line from the server, stripping CRLF.
- Raise EOFError if the connection is closed."""
+ def _putline(self, line):
+ """Internal: send one line to the server, appending CRLF.
+ The `line` must be a bytes-like object."""
+ line = line + _CRLF
+ if self.debugging > 1: print('*put*', repr(line))
+ self.file.write(line)
+ self.file.flush()
+
+ def _putcmd(self, line):
+ """Internal: send one command to the server (through _putline()).
+ The `line` must be an unicode string."""
+ if self.debugging: print('*cmd*', repr(line))
+ line = line.encode(self.encoding, self.errors)
+ self._putline(line)
+
+ def _getline(self, strip_crlf=True):
+ """Internal: return one line from the server, stripping _CRLF.
+ Raise EOFError if the connection is closed.
+ Returns a bytes object."""
line = self.file.readline()
if self.debugging > 1:
- print '*get*', repr(line)
+ print('*get*', repr(line))
if not line: raise EOFError
- if line[-2:] == CRLF: line = line[:-2]
- elif line[-1:] in CRLF: line = line[:-1]
+ if strip_crlf:
+ if line[-2:] == _CRLF:
+ line = line[:-2]
+ elif line[-1:] in _CRLF:
+ line = line[:-1]
return line
- def getresp(self):
+ def _getresp(self):
"""Internal: get a response from the server.
- Raise various errors if the response indicates an error."""
- resp = self.getline()
- if self.debugging: print '*resp*', repr(resp)
+ Raise various errors if the response indicates an error.
+ Returns an unicode string."""
+ resp = self._getline()
+ if self.debugging: print('*resp*', repr(resp))
+ resp = resp.decode(self.encoding, self.errors)
c = resp[:1]
if c == '4':
raise NNTPTemporaryError(resp)
@@ -222,82 +437,180 @@ class NNTP:
raise NNTPProtocolError(resp)
return resp
- def getlongresp(self, file=None):
+ def _getlongresp(self, file=None):
"""Internal: get a response plus following text from the server.
- Raise various errors if the response indicates an error."""
+ Raise various errors if the response indicates an error.
+
+ Returns a (response, lines) tuple where `response` is an unicode
+ string and `lines` is a list of bytes objects.
+ If `file` is a file-like object, it must be open in binary mode.
+ """
openedFile = None
try:
# If a string was passed then open a file with that name
- if isinstance(file, str):
- openedFile = file = open(file, "w")
+ if isinstance(file, (str, bytes)):
+ openedFile = file = open(file, "wb")
- resp = self.getresp()
- if resp[:3] not in LONGRESP:
+ resp = self._getresp()
+ if resp[:3] not in _LONGRESP:
raise NNTPReplyError(resp)
- list = []
- while 1:
- line = self.getline()
- if line == '.':
- break
- if line[:2] == '..':
- line = line[1:]
- if file:
- file.write(line + "\n")
- else:
- list.append(line)
+
+ lines = []
+ if file is not None:
+ # XXX lines = None instead?
+ terminators = (b'.' + _CRLF, b'.\n')
+ while 1:
+ line = self._getline(False)
+ if line in terminators:
+ break
+ if line.startswith(b'..'):
+ line = line[1:]
+ file.write(line)
+ else:
+ terminator = b'.'
+ while 1:
+ line = self._getline()
+ if line == terminator:
+ break
+ if line.startswith(b'..'):
+ line = line[1:]
+ lines.append(line)
finally:
# If this method created the file, then it must close it
if openedFile:
openedFile.close()
- return resp, list
+ return resp, lines
- def shortcmd(self, line):
- """Internal: send a command and get the response."""
- self.putcmd(line)
- return self.getresp()
+ def _shortcmd(self, line):
+ """Internal: send a command and get the response.
+ Same return value as _getresp()."""
+ self._putcmd(line)
+ return self._getresp()
+
+ def _longcmd(self, line, file=None):
+ """Internal: send a command and get the response plus following text.
+ Same return value as _getlongresp()."""
+ self._putcmd(line)
+ return self._getlongresp(file)
+
+ def _longcmdstring(self, line, file=None):
+ """Internal: send a command and get the response plus following text.
+ Same as _longcmd() and _getlongresp(), except that the returned `lines`
+ are unicode strings rather than bytes objects.
+ """
+ self._putcmd(line)
+ resp, list = self._getlongresp(file)
+ return resp, [line.decode(self.encoding, self.errors)
+ for line in list]
+
+ def _getoverviewfmt(self):
+ """Internal: get the overview format. Queries the server if not
+ already done, else returns the cached value."""
+ try:
+ return self._cachedoverviewfmt
+ except AttributeError:
+ pass
+ try:
+ resp, lines = self._longcmdstring("LIST OVERVIEW.FMT")
+ except NNTPPermanentError:
+ # Not supported by server?
+ fmt = _DEFAULT_OVERVIEW_FMT[:]
+ else:
+ fmt = _parse_overview_fmt(lines)
+ self._cachedoverviewfmt = fmt
+ return fmt
- def longcmd(self, line, file=None):
- """Internal: send a command and get the response plus following text."""
- self.putcmd(line)
- return self.getlongresp(file)
+ def _grouplist(self, lines):
+ # Parse lines into "group last first flag"
+ return [GroupInfo(*line.split()) for line in lines]
- def newgroups(self, date, time, file=None):
- """Process a NEWGROUPS command. Arguments:
- - date: string 'yymmdd' indicating the date
- - time: string 'hhmmss' indicating the time
+ def capabilities(self):
+ """Process a CAPABILITIES command. Not supported by all servers.
Return:
- resp: server response if successful
- - list: list of newsgroup names"""
-
- return self.longcmd('NEWGROUPS ' + date + ' ' + time, file)
+ - caps: a dictionary mapping capability names to lists of tokens
+ (for example {'VERSION': ['2'], 'OVER': [], LIST: ['ACTIVE', 'HEADERS'] })
+ """
+ caps = {}
+ resp, lines = self._longcmdstring("CAPABILITIES")
+ for line in lines:
+ name, *tokens = line.split()
+ caps[name] = tokens
+ return resp, caps
- def newnews(self, group, date, time, file=None):
+ def newgroups(self, date, *, file=None):
+ """Process a NEWGROUPS command. Arguments:
+ - date: a date or datetime object
+ Return:
+ - resp: server response if successful
+ - list: list of newsgroup names
+ """
+ if not isinstance(date, (datetime.date, datetime.date)):
+ raise TypeError(
+ "the date parameter must be a date or datetime object, "
+ "not '{:40}'".format(date.__class__.__name__))
+ date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
+ cmd = 'NEWGROUPS {0} {1}'.format(date_str, time_str)
+ resp, lines = self._longcmdstring(cmd, file)
+ return resp, self._grouplist(lines)
+
+ def newnews(self, group, date, *, file=None):
"""Process a NEWNEWS command. Arguments:
- group: group name or '*'
- - date: string 'yymmdd' indicating the date
- - time: string 'hhmmss' indicating the time
+ - date: a date or datetime object
Return:
- resp: server response if successful
- - list: list of message ids"""
-
- cmd = 'NEWNEWS ' + group + ' ' + date + ' ' + time
- return self.longcmd(cmd, file)
-
- def list(self, file=None):
- """Process a LIST command. Return:
+ - list: list of message ids
+ """
+ if not isinstance(date, (datetime.date, datetime.date)):
+ raise TypeError(
+ "the date parameter must be a date or datetime object, "
+ "not '{:40}'".format(date.__class__.__name__))
+ date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
+ cmd = 'NEWNEWS {0} {1} {2}'.format(group, date_str, time_str)
+ return self._longcmdstring(cmd, file)
+
+ def list(self, group_pattern=None, *, file=None):
+ """Process a LIST or LIST ACTIVE command. Arguments:
+ - group_pattern: a pattern indicating which groups to query
+ - file: Filename string or file object to store the result in
+ Returns:
- resp: server response if successful
- - list: list of (group, last, first, flag) (strings)"""
+ - list: list of (group, last, first, flag) (strings)
+ """
+ if group_pattern is not None:
+ command = 'LIST ACTIVE ' + group_pattern
+ else:
+ command = 'LIST'
+ resp, lines = self._longcmdstring(command, file)
+ return resp, self._grouplist(lines)
- resp, list = self.longcmd('LIST', file)
- for i in range(len(list)):
- # Parse lines into "group last first flag"
- list[i] = tuple(list[i].split())
- return resp, list
+ def _getdescriptions(self, group_pattern, return_all):
+ line_pat = re.compile('^(?P<group>[^ \t]+)[ \t]+(.*)$')
+ # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
+ resp, lines = self._longcmdstring('LIST NEWSGROUPS ' + group_pattern)
+ if not resp.startswith('215'):
+ # Now the deprecated XGTITLE. This either raises an error
+ # or succeeds with the same output structure as LIST
+ # NEWSGROUPS.
+ resp, lines = self._longcmdstring('XGTITLE ' + group_pattern)
+ groups = {}
+ for raw_line in lines:
+ match = line_pat.search(raw_line.strip())
+ if match:
+ name, desc = match.group(1, 2)
+ if not return_all:
+ return desc
+ groups[name] = desc
+ if return_all:
+ return resp, groups
+ else:
+ # Nothing found
+ return ''
def description(self, group):
-
"""Get a description for a single group. If more than one
group matches ('group' is a pattern), return the first. If no
group matches, return an empty string.
@@ -308,42 +621,24 @@ class NNTP:
NOTE: This neither checks for a wildcard in 'group' nor does
it check whether the group actually exists."""
-
- resp, lines = self.descriptions(group)
- if len(lines) == 0:
- return ""
- else:
- return lines[0][1]
+ return self._getdescriptions(group, False)
def descriptions(self, group_pattern):
"""Get descriptions for a range of groups."""
- line_pat = re.compile("^(?P<group>[^ \t]+)[ \t]+(.*)$")
- # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
- resp, raw_lines = self.longcmd('LIST NEWSGROUPS ' + group_pattern)
- if resp[:3] != "215":
- # Now the deprecated XGTITLE. This either raises an error
- # or succeeds with the same output structure as LIST
- # NEWSGROUPS.
- resp, raw_lines = self.longcmd('XGTITLE ' + group_pattern)
- lines = []
- for raw_line in raw_lines:
- match = line_pat.search(raw_line.strip())
- if match:
- lines.append(match.group(1, 2))
- return resp, lines
+ return self._getdescriptions(group_pattern, True)
def group(self, name):
"""Process a GROUP command. Argument:
- group: the group name
Returns:
- resp: server response if successful
- - count: number of articles (string)
- - first: first article number (string)
- - last: last article number (string)
- - name: the group name"""
-
- resp = self.shortcmd('GROUP ' + name)
- if resp[:3] != '211':
+ - count: number of articles
+ - first: first article number
+ - last: last article number
+ - name: the group name
+ """
+ resp = self._shortcmd('GROUP ' + name)
+ if not resp.startswith('211'):
raise NNTPReplyError(resp)
words = resp.split()
count = first = last = 0
@@ -356,151 +651,177 @@ class NNTP:
last = words[3]
if n > 4:
name = words[4].lower()
- return resp, count, first, last, name
+ return resp, int(count), int(first), int(last), name
- def help(self, file=None):
- """Process a HELP command. Returns:
+ def help(self, *, file=None):
+ """Process a HELP command. Argument:
+ - file: Filename string or file object to store the result in
+ Returns:
- resp: server response if successful
- - list: list of strings"""
-
- return self.longcmd('HELP',file)
+ - list: list of strings returned by the server in response to the
+ HELP command
+ """
+ return self._longcmdstring('HELP', file)
- def statparse(self, resp):
- """Internal: parse the response of a STAT, NEXT or LAST command."""
- if resp[:2] != '22':
+ def _statparse(self, resp):
+ """Internal: parse the response line of a STAT, NEXT, LAST,
+ ARTICLE, HEAD or BODY command."""
+ if not resp.startswith('22'):
raise NNTPReplyError(resp)
words = resp.split()
- nr = 0
- id = ''
- n = len(words)
- if n > 1:
- nr = words[1]
- if n > 2:
- id = words[2]
- return resp, nr, id
+ art_num = int(words[1])
+ message_id = words[2]
+ return resp, art_num, message_id
- def statcmd(self, line):
+ def _statcmd(self, line):
"""Internal: process a STAT, NEXT or LAST command."""
- resp = self.shortcmd(line)
- return self.statparse(resp)
+ resp = self._shortcmd(line)
+ return self._statparse(resp)
- def stat(self, id):
+ def stat(self, message_spec=None):
"""Process a STAT command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id (if not specified,
+ the current article is selected)
Returns:
- resp: server response if successful
- - nr: the article number
- - id: the message id"""
-
- return self.statcmd('STAT ' + id)
+ - art_num: the article number
+ - message_id: the message id
+ """
+ if message_spec:
+ return self._statcmd('STAT {0}'.format(message_spec))
+ else:
+ return self._statcmd('STAT')
def next(self):
"""Process a NEXT command. No arguments. Return as for STAT."""
- return self.statcmd('NEXT')
+ return self._statcmd('NEXT')
def last(self):
"""Process a LAST command. No arguments. Return as for STAT."""
- return self.statcmd('LAST')
+ return self._statcmd('LAST')
- def artcmd(self, line, file=None):
+ def _artcmd(self, line, file=None):
"""Internal: process a HEAD, BODY or ARTICLE command."""
- resp, list = self.longcmd(line, file)
- resp, nr, id = self.statparse(resp)
- return resp, nr, id, list
+ resp, lines = self._longcmd(line, file)
+ resp, art_num, message_id = self._statparse(resp)
+ return resp, ArticleInfo(art_num, message_id, lines)
- def head(self, id):
+ def head(self, message_spec=None, *, file=None):
"""Process a HEAD command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id
+ - file: filename string or file object to store the headers in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article's header"""
-
- return self.artcmd('HEAD ' + id)
+ - ArticleInfo: (article number, message id, list of header lines)
+ """
+ if message_spec is not None:
+ cmd = 'HEAD {0}'.format(message_spec)
+ else:
+ cmd = 'HEAD'
+ return self._artcmd(cmd, file)
- def body(self, id, file=None):
+ def body(self, message_spec=None, *, file=None):
"""Process a BODY command. Argument:
- - id: article number or message id
- - file: Filename string or file object to store the article in
+ - message_spec: article number or message id
+ - file: filename string or file object to store the body in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article's body or an empty list
- if file was used"""
-
- return self.artcmd('BODY ' + id, file)
+ - ArticleInfo: (article number, message id, list of body lines)
+ """
+ if message_spec is not None:
+ cmd = 'BODY {0}'.format(message_spec)
+ else:
+ cmd = 'BODY'
+ return self._artcmd(cmd, file)
- def article(self, id):
+ def article(self, message_spec=None, *, file=None):
"""Process an ARTICLE command. Argument:
- - id: article number or message id
+ - message_spec: article number or message id
+ - file: filename string or file object to store the article in
Returns:
- resp: server response if successful
- - nr: article number
- - id: message id
- - list: the lines of the article"""
-
- return self.artcmd('ARTICLE ' + id)
+ - ArticleInfo: (article number, message id, list of article lines)
+ """
+ if message_spec is not None:
+ cmd = 'ARTICLE {0}'.format(message_spec)
+ else:
+ cmd = 'ARTICLE'
+ return self._artcmd(cmd, file)
def slave(self):
"""Process a SLAVE command. Returns:
- - resp: server response if successful"""
-
- return self.shortcmd('SLAVE')
+ - resp: server response if successful
+ """
+ return self._shortcmd('SLAVE')
- def xhdr(self, hdr, str, file=None):
+ def xhdr(self, hdr, str, *, file=None):
"""Process an XHDR command (optional server extension). Arguments:
- hdr: the header type (e.g. 'subject')
- str: an article nr, a message id, or a range nr1-nr2
+ - file: Filename string or file object to store the result in
Returns:
- resp: server response if successful
- - list: list of (nr, value) strings"""
-
+ - list: list of (nr, value) strings
+ """
pat = re.compile('^([0-9]+) ?(.*)\n?')
- resp, lines = self.longcmd('XHDR ' + hdr + ' ' + str, file)
- for i in range(len(lines)):
- line = lines[i]
+ resp, lines = self._longcmdstring('XHDR {0} {1}'.format(hdr, str), file)
+ def remove_number(line):
m = pat.match(line)
- if m:
- lines[i] = m.group(1, 2)
- return resp, lines
+ return m.group(1, 2) if m else line
+ return resp, [remove_number(line) for line in lines]
- def xover(self, start, end, file=None):
+ def xover(self, start, end, *, file=None):
"""Process an XOVER command (optional server extension) Arguments:
- start: start of range
- end: end of range
+ - file: Filename string or file object to store the result in
+ Returns:
+ - resp: server response if successful
+ - list: list of dicts containing the response fields
+ """
+ resp, lines = self._longcmdstring('XOVER {0}-{1}'.format(start, end),
+ file)
+ fmt = self._getoverviewfmt()
+ return resp, _parse_overview(lines, fmt)
+
+ def over(self, message_spec, *, file=None):
+ """Process an OVER command. If the command isn't supported, fall
+ back to XOVER. Arguments:
+ - message_spec:
+ - either a message id, indicating the article to fetch
+ information about
+ - or a (start, end) tuple, indicating a range of article numbers;
+ if end is None, information up to the newest message will be
+ retrieved
+ - or None, indicating the current article number must be used
+ - file: Filename string or file object to store the result in
Returns:
- resp: server response if successful
- - list: list of (art-nr, subject, poster, date,
- id, references, size, lines)"""
+ - list: list of dicts containing the response fields
- resp, lines = self.longcmd('XOVER ' + start + '-' + end, file)
- xover_lines = []
- for line in lines:
- elem = line.split("\t")
- try:
- xover_lines.append((elem[0],
- elem[1],
- elem[2],
- elem[3],
- elem[4],
- elem[5].split(),
- elem[6],
- elem[7]))
- except IndexError:
- raise NNTPDataError(line)
- return resp,xover_lines
-
- def xgtitle(self, group, file=None):
+ NOTE: the "message id" form isn't supported by XOVER
+ """
+ cmd = 'OVER' if 'OVER' in self._caps else 'XOVER'
+ if isinstance(message_spec, (tuple, list)):
+ start, end = message_spec
+ cmd += ' {0}-{1}'.format(start, end or '')
+ elif message_spec is not None:
+ cmd = cmd + ' ' + message_spec
+ resp, lines = self._longcmdstring(cmd, file)
+ fmt = self._getoverviewfmt()
+ return resp, _parse_overview(lines, fmt)
+
+ def xgtitle(self, group, *, file=None):
"""Process an XGTITLE command (optional server extension) Arguments:
- group: group name wildcard (i.e. news.*)
Returns:
- resp: server response if successful
- list: list of (name,title) strings"""
-
- line_pat = re.compile("^([^ \t]+)[ \t]+(.*)$")
- resp, raw_lines = self.longcmd('XGTITLE ' + group, file)
+ warnings.warn("The XGTITLE extension is not actively used, "
+ "use descriptions() instead",
+ PendingDeprecationWarning, 2)
+ line_pat = re.compile('^([^ \t]+)[ \t]+(.*)$')
+ resp, raw_lines = self._longcmdstring('XGTITLE ' + group, file)
lines = []
for raw_line in raw_lines:
match = line_pat.search(raw_line.strip())
@@ -508,15 +829,18 @@ class NNTP:
lines.append(match.group(1, 2))
return resp, lines
- def xpath(self,id):
+ def xpath(self, id):
"""Process an XPATH command (optional server extension) Arguments:
- id: Message id of article
Returns:
resp: server response if successful
- path: directory path to article"""
+ path: directory path to article
+ """
+ warnings.warn("The XPATH extension is not actively used",
+ PendingDeprecationWarning, 2)
- resp = self.shortcmd("XPATH " + id)
- if resp[:3] != '223':
+ resp = self._shortcmd('XPATH {0}'.format(id))
+ if not resp.startswith('223'):
raise NNTPReplyError(resp)
try:
[resp_num, path] = resp.split()
@@ -525,103 +849,265 @@ class NNTP:
else:
return resp, path
- def date (self):
- """Process the DATE command. Arguments:
- None
+ def date(self):
+ """Process the DATE command.
Returns:
- resp: server response if successful
- date: Date suitable for newnews/newgroups commands etc.
- time: Time suitable for newnews/newgroups commands etc."""
-
- resp = self.shortcmd("DATE")
- if resp[:3] != '111':
+ - resp: server response if successful
+ - date: datetime object
+ """
+ resp = self._shortcmd("DATE")
+ if not resp.startswith('111'):
raise NNTPReplyError(resp)
elem = resp.split()
if len(elem) != 2:
raise NNTPDataError(resp)
- date = elem[1][2:8]
- time = elem[1][-6:]
- if len(date) != 6 or len(time) != 6:
+ date = elem[1]
+ if len(date) != 14:
raise NNTPDataError(resp)
- return resp, date, time
-
+ return resp, _parse_datetime(date, None)
- def post(self, f):
+ def _post(self, command, f):
+ resp = self._shortcmd(command)
+ # Raises a specific exception if posting is not allowed
+ if not resp.startswith('3'):
+ raise NNTPReplyError(resp)
+ if isinstance(f, (bytes, bytearray)):
+ f = f.splitlines()
+ # We don't use _putline() because:
+ # - we don't want additional CRLF if the file or iterable is already
+ # in the right format
+ # - we don't want a spurious flush() after each line is written
+ for line in f:
+ if not line.endswith(_CRLF):
+ line = line.rstrip(b"\r\n") + _CRLF
+ if line.startswith(b'.'):
+ line = b'.' + line
+ self.file.write(line)
+ self.file.write(b".\r\n")
+ self.file.flush()
+ return self._getresp()
+
+ def post(self, data):
"""Process a POST command. Arguments:
- - f: file containing the article
+ - data: bytes object, iterable or file containing the article
Returns:
- resp: server response if successful"""
+ return self._post('POST', data)
- resp = self.shortcmd('POST')
- # Raises error_??? if posting is not allowed
- if resp[0] != '3':
- raise NNTPReplyError(resp)
- while 1:
- line = f.readline()
- if not line:
- break
- if line[-1] == '\n':
- line = line[:-1]
- if line[:1] == '.':
- line = '.' + line
- self.putline(line)
- self.putline('.')
- return self.getresp()
-
- def ihave(self, id, f):
+ def ihave(self, message_id, data):
"""Process an IHAVE command. Arguments:
- - id: message-id of the article
- - f: file containing the article
+ - message_id: message-id of the article
+ - data: file containing the article
Returns:
- resp: server response if successful
Note that if the server refuses the article an exception is raised."""
+ return self._post('IHAVE {0}'.format(message_id), data)
- resp = self.shortcmd('IHAVE ' + id)
- # Raises error_??? if the server already has it
- if resp[0] != '3':
- raise NNTPReplyError(resp)
- while 1:
- line = f.readline()
- if not line:
- break
- if line[-1] == '\n':
- line = line[:-1]
- if line[:1] == '.':
- line = '.' + line
- self.putline(line)
- self.putline('.')
- return self.getresp()
+ def _close(self):
+ self.file.close()
+ del self.file
def quit(self):
"""Process a QUIT command and close the socket. Returns:
- resp: server response if successful"""
-
- resp = self.shortcmd('QUIT')
- self.file.close()
- self.sock.close()
- del self.file, self.sock
+ try:
+ resp = self._shortcmd('QUIT')
+ finally:
+ self._close()
return resp
+ def login(self, user=None, password=None, usenetrc=True):
+ if self.authenticated:
+ raise ValueError("Already logged in.")
+ if not user and not usenetrc:
+ raise ValueError(
+ "At least one of `user` and `usenetrc` must be specified")
+ # If no login/password was specified but netrc was requested,
+ # try to get them from ~/.netrc
+ # Presume that if .netrc has an entry, NNRP authentication is required.
+ try:
+ if usenetrc and not user:
+ import netrc
+ credentials = netrc.netrc()
+ auth = credentials.authenticators(self.host)
+ if auth:
+ user = auth[0]
+ password = auth[2]
+ except IOError:
+ pass
+ # Perform NNTP authentication if needed.
+ if not user:
+ return
+ resp = self._shortcmd('authinfo user ' + user)
+ if resp.startswith('381'):
+ if not password:
+ raise NNTPReplyError(resp)
+ else:
+ resp = self._shortcmd('authinfo pass ' + password)
+ if not resp.startswith('281'):
+ raise NNTPPermanentError(resp)
+ # Capabilities might have changed after login
+ self._caps = None
+ self.getcapabilities()
+ # Attempt to send mode reader if it was requested after login.
+ # Only do so if we're not in reader mode already.
+ if self.readermode_afterauth and 'READER' not in self._caps:
+ self._setreadermode()
+ # Capabilities might have changed after MODE READER
+ self._caps = None
+ self.getcapabilities()
+
+ def _setreadermode(self):
+ try:
+ self.welcome = self._shortcmd('mode reader')
+ except NNTPPermanentError:
+ # Error 5xx, probably 'not implemented'
+ pass
+ except NNTPTemporaryError as e:
+ if e.response.startswith('480'):
+ # Need authorization before 'mode reader'
+ self.readermode_afterauth = True
+ else:
+ raise
+
+ if _have_ssl:
+ def starttls(self, context=None):
+ """Process a STARTTLS command. Arguments:
+ - context: SSL context to use for the encrypted connection
+ """
+ # Per RFC 4642, STARTTLS MUST NOT be sent after authentication or if
+ # a TLS session already exists.
+ if self.tls_on:
+ raise ValueError("TLS is already enabled.")
+ if self.authenticated:
+ raise ValueError("TLS cannot be started after authentication.")
+ resp = self._shortcmd('STARTTLS')
+ if resp.startswith('382'):
+ self.file.close()
+ self.sock = _encrypt_on(self.sock, context)
+ self.file = self.sock.makefile("rwb")
+ self.tls_on = True
+ # Capabilities may change after TLS starts up, so ask for them
+ # again.
+ self._caps = None
+ self.getcapabilities()
+ else:
+ raise NNTPError("TLS failed to start.")
+
+
+class NNTP(_NNTPBase):
+
+ def __init__(self, host, port=NNTP_PORT, user=None, password=None,
+ readermode=None, usenetrc=False,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ """Initialize an instance. Arguments:
+ - host: hostname to connect to
+ - port: port to connect to (default the standard NNTP port)
+ - user: username to authenticate with
+ - password: password to use with username
+ - readermode: if true, send 'mode reader' command after
+ connecting.
+ - usenetrc: allow loading username and password from ~/.netrc file
+ if not specified explicitly
+ - timeout: timeout (in seconds) used for socket connections
+
+ readermode is sometimes necessary if you are connecting to an
+ NNTP server on the local machine and intend to call
+ reader-specific commands, such as `group'. If you get
+ unexpected NNTPPermanentErrors, you might need to set
+ readermode.
+ """
+ self.host = host
+ self.port = port
+ self.sock = socket.create_connection((host, port), timeout)
+ file = self.sock.makefile("rwb")
+ _NNTPBase.__init__(self, file, host,
+ readermode, timeout)
+ if user or usenetrc:
+ self.login(user, password, usenetrc)
+
+ def _close(self):
+ try:
+ _NNTPBase._close(self)
+ finally:
+ self.sock.close()
+
+
+if _have_ssl:
+ class NNTP_SSL(_NNTPBase):
+
+ def __init__(self, host, port=NNTP_SSL_PORT,
+ user=None, password=None, ssl_context=None,
+ readermode=None, usenetrc=False,
+ timeout=_GLOBAL_DEFAULT_TIMEOUT):
+ """This works identically to NNTP.__init__, except for the change
+ in default port and the `ssl_context` argument for SSL connections.
+ """
+ self.sock = socket.create_connection((host, port), timeout)
+ self.sock = _encrypt_on(self.sock, ssl_context)
+ file = self.sock.makefile("rwb")
+ _NNTPBase.__init__(self, file, host,
+ readermode=readermode, timeout=timeout)
+ if user or usenetrc:
+ self.login(user, password, usenetrc)
+
+ def _close(self):
+ try:
+ _NNTPBase._close(self)
+ finally:
+ self.sock.close()
+
+ __all__.append("NNTP_SSL")
+
# Test retrieval when run as a script.
-# Assumption: if there's a local news server, it's called 'news'.
-# Assumption: if user queries a remote news server, it's named
-# in the environment variable NNTPSERVER (used by slrn and kin)
-# and we want readermode off.
if __name__ == '__main__':
- import os
- newshost = 'news' and os.environ["NNTPSERVER"]
- if newshost.find('.') == -1:
- mode = 'readermode'
+ import argparse
+ from email.utils import parsedate
+
+ parser = argparse.ArgumentParser(description="""\
+ nntplib built-in demo - display the latest articles in a newsgroup""")
+ parser.add_argument('-g', '--group', default='gmane.comp.python.general',
+ help='group to fetch messages from (default: %(default)s)')
+ parser.add_argument('-s', '--server', default='news.gmane.org',
+ help='NNTP server hostname (default: %(default)s)')
+ parser.add_argument('-p', '--port', default=-1, type=int,
+ help='NNTP port number (default: %s / %s)' % (NNTP_PORT, NNTP_SSL_PORT))
+ parser.add_argument('-n', '--nb-articles', default=10, type=int,
+ help='number of articles to fetch (default: %(default)s)')
+ parser.add_argument('-S', '--ssl', action='store_true', default=False,
+ help='use NNTP over SSL')
+ args = parser.parse_args()
+
+ port = args.port
+ if not args.ssl:
+ if port == -1:
+ port = NNTP_PORT
+ s = NNTP(host=args.server, port=port)
else:
- mode = None
- s = NNTP(newshost, readermode=mode)
- resp, count, first, last, name = s.group('comp.lang.python')
- print resp
- print 'Group', name, 'has', count, 'articles, range', first, 'to', last
- resp, subs = s.xhdr('subject', first + '-' + last)
- print resp
- for item in subs:
- print "%7s %s" % item
- resp = s.quit()
- print resp
+ if port == -1:
+ port = NNTP_SSL_PORT
+ s = NNTP_SSL(host=args.server, port=port)
+
+ caps = s.getcapabilities()
+ if 'STARTTLS' in caps:
+ s.starttls()
+ resp, count, first, last, name = s.group(args.group)
+ print('Group', name, 'has', count, 'articles, range', first, 'to', last)
+
+ def cut(s, lim):
+ if len(s) > lim:
+ s = s[:lim - 4] + "..."
+ return s
+
+ first = str(int(last) - args.nb_articles + 1)
+ resp, overviews = s.xover(first, last)
+ for artnum, over in overviews:
+ author = decode_header(over['from']).split('<', 1)[0]
+ subject = decode_header(over['subject'])
+ lines = int(over[':lines'])
+ print("{:7} {:20} {:42} ({})".format(
+ artnum, cut(author, 20), cut(subject, 42), lines)
+ )
+
+ s.quit()
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 4f8f423c083..826be87d3c7 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -9,18 +9,18 @@ import os
import sys
import stat
import genericpath
-import warnings
-
from genericpath import *
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
- "ismount","walk","expanduser","expandvars","normpath","abspath",
+ "ismount", "expanduser","expandvars","normpath","abspath",
"splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
- "extsep","devnull","realpath","supports_unicode_filenames","relpath"]
+ "extsep","devnull","realpath","supports_unicode_filenames","relpath",
+ "samefile", "sameopenfile",]
# strings representing various path-related bits and pieces
+# These are primarily for export; internally, they are hardcoded.
curdir = '.'
pardir = '..'
extsep = '.'
@@ -35,6 +35,48 @@ elif 'os2' in sys.builtin_module_names:
altsep = '/'
devnull = 'nul'
+def _get_empty(path):
+ if isinstance(path, bytes):
+ return b''
+ else:
+ return ''
+
+def _get_sep(path):
+ if isinstance(path, bytes):
+ return b'\\'
+ else:
+ return '\\'
+
+def _get_altsep(path):
+ if isinstance(path, bytes):
+ return b'/'
+ else:
+ return '/'
+
+def _get_bothseps(path):
+ if isinstance(path, bytes):
+ return b'\\/'
+ else:
+ return '\\/'
+
+def _get_dot(path):
+ if isinstance(path, bytes):
+ return b'.'
+ else:
+ return '.'
+
+def _get_colon(path):
+ if isinstance(path, bytes):
+ return b':'
+ else:
+ return ':'
+
+def _get_special(path):
+ if isinstance(path, bytes):
+ return (b'\\\\.\\', b'\\\\?\\')
+ else:
+ return ('\\\\.\\', '\\\\?\\')
+
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# (this is done by normpath).
@@ -43,19 +85,22 @@ def normcase(s):
"""Normalize case of pathname.
Makes all characters lowercase and all slashes into backslashes."""
- return s.replace("/", "\\").lower()
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
+ return s.replace(_get_altsep(s), _get_sep(s)).lower()
# Return whether a path is absolute.
-# Trivial in Posix, harder on the Mac or MS-DOS.
-# For DOS it is absolute if it starts with a slash or backslash (current
-# volume), or if a pathname after the volume letter and colon / UNC resource
+# Trivial in Posix, harder on Windows.
+# For Windows it is absolute if it starts with a slash or backslash (current
+# volume), or if a pathname after the volume-letter-and-colon or UNC-resource
# starts with a slash or backslash.
def isabs(s):
"""Test whether a path is absolute"""
s = splitdrive(s)[1]
- return s != '' and s[:1] in '/\\'
+ return len(s) > 0 and s[:1] in _get_bothseps(s)
# Join two (or more) paths.
@@ -64,54 +109,75 @@ def join(a, *p):
"""Join two or more pathname components, inserting "\\" as needed.
If any component is an absolute path, all previous path components
will be discarded."""
+ sep = _get_sep(a)
+ seps = _get_bothseps(a)
+ colon = _get_colon(a)
path = a
for b in p:
b_wins = 0 # set to 1 iff b makes path irrelevant
- if path == "":
+ if not path:
b_wins = 1
elif isabs(b):
# This probably wipes out path so far. However, it's more
- # complicated if path begins with a drive letter:
+ # complicated if path begins with a drive letter. You get a+b
+ # (minus redundant slashes) in these four cases:
# 1. join('c:', '/a') == 'c:/a'
- # 2. join('c:/', '/a') == 'c:/a'
- # But
- # 3. join('c:/a', '/b') == '/b'
- # 4. join('c:', 'd:/') = 'd:/'
- # 5. join('c:/', 'd:/') = 'd:/'
- if path[1:2] != ":" or b[1:2] == ":":
- # Path doesn't start with a drive letter, or cases 4 and 5.
- b_wins = 1
-
- # Else path has a drive letter, and b doesn't but is absolute.
- elif len(path) > 3 or (len(path) == 3 and
- path[-1] not in "/\\"):
- # case 3
+ # 2. join('//computer/share', '/a') == '//computer/share/a'
+ # 3. join('c:/', '/a') == 'c:/a'
+ # 4. join('//computer/share/', '/a') == '//computer/share/a'
+ # But b wins in all of these cases:
+ # 5. join('c:/a', '/b') == '/b'
+ # 6. join('//computer/share/a', '/b') == '/b'
+ # 7. join('c:', 'd:/') == 'd:/'
+ # 8. join('c:', '//computer/share/') == '//computer/share/'
+ # 9. join('//computer/share', 'd:/') == 'd:/'
+ # 10. join('//computer/share', '//computer/share/') == '//computer/share/'
+ # 11. join('c:/', 'd:/') == 'd:/'
+ # 12. join('c:/', '//computer/share/') == '//computer/share/'
+ # 13. join('//computer/share/', 'd:/') == 'd:/'
+ # 14. join('//computer/share/', '//computer/share/') == '//computer/share/'
+ b_prefix, b_rest = splitdrive(b)
+
+ # if b has a prefix, it always wins.
+ if b_prefix:
b_wins = 1
+ else:
+ # b doesn't have a prefix.
+ # but isabs(b) returned true.
+ # and therefore b_rest[0] must be a slash.
+ # (but let's check that.)
+ assert(b_rest and b_rest[0] in seps)
+
+ # so, b still wins if path has a rest that's more than a sep.
+ # you get a+b if path_rest is empty or only has a sep.
+ # (see cases 1-4 for times when b loses.)
+ path_rest = splitdrive(path)[1]
+ b_wins = path_rest and path_rest not in seps
if b_wins:
path = b
else:
# Join, and ensure there's a separator.
assert len(path) > 0
- if path[-1] in "/\\":
- if b and b[0] in "/\\":
+ if path[-1:] in seps:
+ if b and b[:1] in seps:
path += b[1:]
else:
path += b
- elif path[-1] == ":":
+ elif path[-1:] == colon:
path += b
elif b:
- if b[0] in "/\\":
+ if b[:1] in seps:
path += b
else:
- path += "\\" + b
+ path += sep + b
else:
# path is not empty and does not end with a backslash,
# but b is empty; since, e.g., split('a/') produces
# ('a', ''), it's best if join() adds a backslash in
# this case.
- path += '\\'
+ path += sep
return path
@@ -120,40 +186,83 @@ def join(a, *p):
# colon) and the path specification.
# It is always true that drivespec + pathspec == p
def splitdrive(p):
- """Split a pathname into drive and path specifiers. Returns a 2-tuple
-"(drive,path)"; either part may be empty"""
- if p[1:2] == ':':
- return p[0:2], p[2:]
- return '', p
+ """Split a pathname into drive/UNC sharepoint and relative path specifiers.
+ Returns a 2-tuple (drive_or_unc, path); either part may be empty.
+
+ If you assign
+ result = splitdrive(p)
+ It is always true that:
+ result[0] + result[1] == p
+
+ If the path contained a drive letter, drive_or_unc will contain everything
+ up to and including the colon. e.g. splitdrive("c:/dir") returns ("c:", "/dir")
+
+ If the path contained a UNC path, the drive_or_unc will contain the host name
+ and share up to but not including the fourth directory separator character.
+ e.g. splitdrive("//host/computer/dir") returns ("//host/computer", "/dir")
+
+ Paths cannot contain both a drive letter and a UNC path.
+
+ """
+ empty = _get_empty(p)
+ if len(p) > 1:
+ sep = _get_sep(p)
+ normp = normcase(p)
+ if (normp[0:2] == sep*2) and (normp[2:3] != sep):
+ # is a UNC path:
+ # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path
+ # \\machine\mountpoint\directory\etc\...
+ # directory ^^^^^^^^^^^^^^^
+ index = normp.find(sep, 2)
+ if index == -1:
+ return empty, p
+ index2 = normp.find(sep, index + 1)
+ # a UNC path can't have two slashes in a row
+ # (after the initial two)
+ if index2 == index + 1:
+ return empty, p
+ if index2 == -1:
+ index2 = len(p)
+ return p[:index2], p[index2:]
+ if normp[1:2] == _get_colon(p):
+ return p[:2], p[2:]
+ return empty, p
# Parse UNC paths
def splitunc(p):
- """Split a pathname into UNC mount point and relative path specifiers.
+ """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.
"""
- if p[1:2] == ':':
- return '', p # Drive letter present
+ 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 firstTwo == '//' or firstTwo == '\\\\':
+ if normcase(firstTwo) == sep + sep:
# is a UNC path:
# vvvvvvvvvvvvvvvvvvvv equivalent to drive letter
# \\machine\mountpoint\directories...
# directory ^^^^^^^^^^^^^^^
normp = normcase(p)
- index = normp.find('\\', 2)
+ index = normp.find(sep, 2)
if index == -1:
##raise RuntimeError, 'illegal UNC path: "' + p + '"'
- return ("", p)
- index = normp.find('\\', index + 1)
+ return (p[:0], p)
+ index = normp.find(sep, index + 1)
if index == -1:
index = len(p)
return p[:index], p[index:]
- return '', p
+ return p[:0], p
# Split a path in head (everything up to the last '/') and tail (the
@@ -167,15 +276,16 @@ def split(p):
Return tuple (head, tail) where tail is everything after the final slash.
Either part may be empty."""
+ seps = _get_bothseps(p)
d, p = splitdrive(p)
# set i to index beyond p's last slash
i = len(p)
- while i and p[i-1] not in '/\\':
- i = i - 1
+ while i and p[i-1] not in seps:
+ i -= 1
head, tail = p[:i], p[i:] # now tail has no slashes
# remove trailing slashes from head, unless it's all slashes
head2 = head
- while head2 and head2[-1] in '/\\':
+ while head2 and head2[-1:] in seps:
head2 = head2[:-1]
head = head2 or head
return d + head, tail
@@ -187,7 +297,8 @@ def split(p):
# It is always true that root + ext == p.
def splitext(p):
- return genericpath._splitext(p, sep, altsep, extsep)
+ return genericpath._splitext(p, _get_sep(p), _get_altsep(p),
+ _get_dot(p))
splitext.__doc__ = genericpath._splitext.__doc__
@@ -205,62 +316,39 @@ def dirname(p):
return split(p)[0]
# Is a path a symbolic link?
-# This will always return false on systems where posix.lstat doesn't exist.
+# This will always return false on systems where os.lstat doesn't exist.
def islink(path):
- """Test for symbolic link.
- On WindowsNT/95 and OS/2 always returns false
+ """Test whether a path is a symbolic link.
+ This will always return false for Windows prior to 6.0
+ and for OS/2.
"""
- return False
+ try:
+ st = os.lstat(path)
+ except (os.error, AttributeError):
+ return False
+ return stat.S_ISLNK(st.st_mode)
+
+# Being true for dangling symbolic links is also useful.
-# alias exists to lexists
-lexists = exists
+def lexists(path):
+ """Test whether a path exists. Returns True for broken symbolic links"""
+ try:
+ st = os.lstat(path)
+ except (os.error, WindowsError):
+ return False
+ return True
# Is a path a mount point? Either a root (with or without drive letter)
# or an UNC path with at most a / or \ after the mount point.
def ismount(path):
"""Test whether a path is a mount point (defined as root of drive)"""
- unc, rest = splitunc(path)
- if unc:
- return rest in ("", "/", "\\")
- p = splitdrive(path)[1]
- return len(p) == 1 and p[0] in '/\\'
-
-
-# Directory tree walk.
-# For each directory under top (including top itself, but excluding
-# '.' and '..'), func(arg, dirname, filenames) is called, where
-# dirname is the name of the directory and filenames is the list
-# of files (and subdirectories etc.) in the directory.
-# The func may modify the filenames list, to implement a filter,
-# or to impose a different order of visiting.
-
-def walk(top, func, arg):
- """Directory tree walk with callback function.
-
- For each directory in the directory tree rooted at top (including top
- itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
- dirname is the name of the directory, and fnames a list of the names of
- the files and subdirectories in dirname (excluding '.' and '..'). func
- may modify the fnames list in-place (e.g. via del or slice assignment),
- and walk will only recurse into the subdirectories whose names remain in
- fnames; this can be used to implement a filter, or to impose a specific
- order of visiting. No semantics are defined for, or required of, arg,
- beyond that arg is always passed to func. It can be used, e.g., to pass
- a filename pattern, or a mutable object designed to accumulate
- statistics. Passing None for arg is common."""
- warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
- stacklevel=2)
- try:
- names = os.listdir(top)
- except os.error:
- return
- func(arg, top, names)
- for name in names:
- name = join(top, name)
- if isdir(name):
- walk(name, func, arg)
+ seps = _get_bothseps(path)
+ root, rest = splitdrive(path)
+ if root and root[0] in seps:
+ return (not rest) or (rest in seps)
+ return rest in seps
# Expand paths beginning with '~' or '~user'.
@@ -276,11 +364,15 @@ def expanduser(path):
"""Expand ~ and ~user constructs.
If user or $HOME is unknown, do nothing."""
- if path[:1] != '~':
+ if isinstance(path, bytes):
+ tilde = b'~'
+ else:
+ tilde = '~'
+ if not path.startswith(tilde):
return path
i, n = 1, len(path)
- while i < n and path[i] not in '/\\':
- i = i + 1
+ while i < n and path[i] not in _get_bothseps(path):
+ i += 1
if 'HOME' in os.environ:
userhome = os.environ['HOME']
@@ -295,6 +387,9 @@ def expanduser(path):
drive = ''
userhome = join(drive, os.environ['HOMEPATH'])
+ if isinstance(path, bytes):
+ userhome = userhome.encode(sys.getfilesystemencoding())
+
if i != 1: #~user
userhome = join(dirname(userhome), path[1:i])
@@ -318,76 +413,112 @@ def expandvars(path):
"""Expand shell variables of the forms $var, ${var} and %var%.
Unknown variables are left unchanged."""
- if '$' not in path and '%' not in path:
- return path
- import string
- varchars = string.ascii_letters + string.digits + '_-'
- res = ''
+ if isinstance(path, bytes):
+ if ord('$') not in path and ord('%') not in path:
+ return path
+ import string
+ varchars = bytes(string.ascii_letters + string.digits + '_-', 'ascii')
+ quote = b'\''
+ percent = b'%'
+ brace = b'{'
+ dollar = b'$'
+ else:
+ if '$' not in path and '%' not in path:
+ return path
+ import string
+ varchars = string.ascii_letters + string.digits + '_-'
+ quote = '\''
+ percent = '%'
+ brace = '{'
+ dollar = '$'
+ res = path[:0]
index = 0
pathlen = len(path)
while index < pathlen:
- c = path[index]
- if c == '\'': # no expansion within single quotes
+ c = path[index:index+1]
+ if c == quote: # no expansion within single quotes
path = path[index + 1:]
pathlen = len(path)
try:
- index = path.index('\'')
- res = res + '\'' + path[:index + 1]
+ index = path.index(c)
+ res += c + path[:index + 1]
except ValueError:
- res = res + path
+ res += path
index = pathlen - 1
- elif c == '%': # variable or '%'
- if path[index + 1:index + 2] == '%':
- res = res + c
- index = index + 1
+ elif c == percent: # variable or '%'
+ if path[index + 1:index + 2] == percent:
+ res += c
+ index += 1
else:
path = path[index+1:]
pathlen = len(path)
try:
- index = path.index('%')
+ index = path.index(percent)
except ValueError:
- res = res + '%' + path
+ res += percent + path
index = pathlen - 1
else:
var = path[:index]
+ if isinstance(path, bytes):
+ var = var.decode('ascii')
if var in os.environ:
- res = res + os.environ[var]
+ value = os.environ[var]
else:
- res = res + '%' + var + '%'
- elif c == '$': # variable or '$$'
- if path[index + 1:index + 2] == '$':
- res = res + c
- index = index + 1
- elif path[index + 1:index + 2] == '{':
+ value = '%' + var + '%'
+ if isinstance(path, bytes):
+ value = value.encode('ascii')
+ res += value
+ elif c == dollar: # variable or '$$'
+ if path[index + 1:index + 2] == dollar:
+ res += c
+ index += 1
+ elif path[index + 1:index + 2] == brace:
path = path[index+2:]
pathlen = len(path)
try:
- index = path.index('}')
+ if isinstance(path, bytes):
+ index = path.index(b'}')
+ else:
+ index = path.index('}')
var = path[:index]
+ if isinstance(path, bytes):
+ var = var.decode('ascii')
if var in os.environ:
- res = res + os.environ[var]
+ value = os.environ[var]
else:
- res = res + '${' + var + '}'
+ value = '${' + var + '}'
+ if isinstance(path, bytes):
+ value = value.encode('ascii')
+ res += value
except ValueError:
- res = res + '${' + path
+ if isinstance(path, bytes):
+ res += b'${' + path
+ else:
+ res += '${' + path
index = pathlen - 1
else:
var = ''
- index = index + 1
+ index += 1
c = path[index:index + 1]
- while c != '' and c in varchars:
- var = var + c
- index = index + 1
+ while c and c in varchars:
+ if isinstance(path, bytes):
+ var += c.decode('ascii')
+ else:
+ var += c
+ index += 1
c = path[index:index + 1]
if var in os.environ:
- res = res + os.environ[var]
+ value = os.environ[var]
else:
- res = res + '$' + var
- if c != '':
- index = index - 1
+ value = '$' + var
+ if isinstance(path, bytes):
+ value = value.encode('ascii')
+ res += value
+ if c:
+ index -= 1
else:
- res = res + c
- index = index + 1
+ res += c
+ index += 1
return res
@@ -397,45 +528,33 @@ def expandvars(path):
def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
- # Preserve unicode (if path is unicode)
- backslash, dot = (u'\\', u'.') if isinstance(path, unicode) else ('\\', '.')
- if path.startswith(('\\\\.\\', '\\\\?\\')):
+ sep = _get_sep(path)
+ dotdot = _get_dot(path) * 2
+ special_prefixes = _get_special(path)
+ if path.startswith(special_prefixes):
# in the case of paths with these prefixes:
# \\.\ -> device names
# \\?\ -> literal paths
# do not do any normalization, but return the path unchanged
return path
- path = path.replace("/", "\\")
+ path = path.replace(_get_altsep(path), sep)
prefix, path = splitdrive(path)
- # We need to be careful here. If the prefix is empty, and the path starts
- # with a backslash, it could either be an absolute path on the current
- # drive (\dir1\dir2\file) or a UNC filename (\\server\mount\dir1\file). It
- # is therefore imperative NOT to collapse multiple backslashes blindly in
- # that case.
- # The code below preserves multiple backslashes when there is no drive
- # letter. This means that the invalid filename \\\a\b is preserved
- # unchanged, where a\\\b is normalised to a\b. It's not clear that there
- # is any better behaviour for such edge cases.
- if prefix == '':
- # No drive letter - preserve initial backslashes
- while path[:1] == "\\":
- prefix = prefix + backslash
- path = path[1:]
- else:
- # We have a drive letter - collapse initial backslashes
- if path.startswith("\\"):
- prefix = prefix + backslash
- path = path.lstrip("\\")
- comps = path.split("\\")
+
+ # collapse initial backslashes
+ if path.startswith(sep):
+ prefix += sep
+ path = path.lstrip(sep)
+
+ comps = path.split(sep)
i = 0
while i < len(comps):
- if comps[i] in ('.', ''):
+ if not comps[i] or comps[i] == _get_dot(path):
del comps[i]
- elif comps[i] == '..':
- if i > 0 and comps[i-1] != '..':
+ elif comps[i] == dotdot:
+ if i > 0 and comps[i-1] != dotdot:
del comps[i-1:i+1]
i -= 1
- elif i == 0 and prefix.endswith("\\"):
+ elif i == 0 and prefix.endswith(_get_sep(path)):
del comps[i]
else:
i += 1
@@ -443,8 +562,8 @@ def normpath(path):
i += 1
# If the path is now empty, substitute '.'
if not prefix and not comps:
- comps.append(dot)
- return prefix + backslash.join(comps)
+ comps.append(_get_dot(path))
+ return prefix + sep.join(comps)
# Return an absolute path.
@@ -455,8 +574,8 @@ except ImportError: # not running on Windows - mock up something sensible
def abspath(path):
"""Return the absolute version of a path."""
if not isabs(path):
- if isinstance(path, unicode):
- cwd = os.getcwdu()
+ if isinstance(path, bytes):
+ cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
@@ -471,8 +590,8 @@ else: # use native Windows method on Windows
path = _getfullpathname(path)
except WindowsError:
pass # Bad path - return unchanged.
- elif isinstance(path, unicode):
- path = os.getcwdu()
+ elif isinstance(path, bytes):
+ path = os.getcwdb()
else:
path = os.getcwd()
return normpath(path)
@@ -483,45 +602,78 @@ realpath = abspath
supports_unicode_filenames = (hasattr(sys, "getwindowsversion") and
sys.getwindowsversion()[3] >= 2)
-def _abspath_split(path):
- abs = abspath(normpath(path))
- prefix, rest = splitunc(abs)
- is_unc = bool(prefix)
- if not is_unc:
- prefix, rest = splitdrive(abs)
- return is_unc, prefix, [x for x in rest.split(sep) if x]
-
def relpath(path, start=curdir):
"""Return a relative version of a path"""
+ sep = _get_sep(path)
+
+ if start is curdir:
+ start = _get_dot(path)
if not path:
raise ValueError("no path specified")
- start_is_unc, start_prefix, start_list = _abspath_split(start)
- path_is_unc, path_prefix, path_list = _abspath_split(path)
-
- if path_is_unc ^ start_is_unc:
- raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)"
- % (path, start))
- if path_prefix.lower() != start_prefix.lower():
- if path_is_unc:
- raise ValueError("path is on UNC root %s, start on UNC root %s"
- % (path_prefix, start_prefix))
- else:
- raise ValueError("path is on drive %s, start on drive %s"
- % (path_prefix, start_prefix))
+ start_abs = abspath(normpath(start))
+ path_abs = abspath(normpath(path))
+ start_drive, start_rest = splitdrive(start_abs)
+ path_drive, path_rest = splitdrive(path_abs)
+ if normcase(start_drive) != normcase(path_drive):
+ error = "path is on mount '{0}', start on mount '{1}'".format(
+ path_drive, start_drive)
+ raise ValueError(error)
+
+ start_list = [x for x in start_rest.split(sep) if x]
+ path_list = [x for x in path_rest.split(sep) if x]
# Work out how much of the filepath is shared by start and path.
i = 0
for e1, e2 in zip(start_list, path_list):
- if e1.lower() != e2.lower():
+ if normcase(e1) != normcase(e2):
break
i += 1
+ if isinstance(path, bytes):
+ pardir = b'..'
+ else:
+ pardir = '..'
rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
if not rel_list:
- return curdir
+ return _get_dot(path)
return join(*rel_list)
+
+# determine if two files are in fact the same file
+try:
+ # GetFinalPathNameByHandle is available starting with Windows 6.0.
+ # Windows XP and non-Windows OS'es will mock _getfinalpathname.
+ if sys.getwindowsversion()[:2] >= (6, 0):
+ from nt import _getfinalpathname
+ else:
+ raise ImportError
+except (AttributeError, ImportError):
+ # On Windows XP and earlier, two files are the same if their absolute
+ # pathnames are the same.
+ # Non-Windows operating systems fake this method with an XP
+ # approximation.
+ def _getfinalpathname(f):
+ return normcase(abspath(f))
+
+def samefile(f1, f2):
+ "Test whether two pathnames reference the same actual file"
+ return _getfinalpathname(f1) == _getfinalpathname(f2)
+
+
+try:
+ from nt import _getfileinformation
+except ImportError:
+ # On other operating systems, just return the fd and see that
+ # it compares equal in sameopenfile.
+ def _getfileinformation(fd):
+ return fd
+
+def sameopenfile(f1, f2):
+ """Test whether two file objects reference the same file"""
+ return _getfileinformation(f1) == _getfileinformation(f2)
+
+
try:
# The genericpath.isdir implementation uses os.stat and checks the mode
# attribute to tell whether or not the path is a directory.
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py
index 10ea2728078..511dcec5d66 100644
--- a/Lib/nturl2path.py
+++ b/Lib/nturl2path.py
@@ -7,7 +7,7 @@ def url2pathname(url):
# ///C|/foo/bar/spam.foo
# becomes
# C:\foo\bar\spam.foo
- import string, urllib
+ import string, urllib.parse
# Windows itself uses ":" even in URLs.
url = url.replace(':', '|')
if not '|' in url:
@@ -19,18 +19,18 @@ def url2pathname(url):
url = url[2:]
components = url.split('/')
# make sure not to convert quoted slashes :-)
- return urllib.unquote('\\'.join(components))
+ return urllib.parse.unquote('\\'.join(components))
comp = url.split('|')
if len(comp) != 2 or comp[0][-1] not in string.ascii_letters:
error = 'Bad URL: ' + url
- raise IOError, error
+ raise IOError(error)
drive = comp[0][-1].upper()
- path = drive + ':'
components = comp[1].split('/')
+ path = drive + ':'
for comp in components:
if comp:
- path = path + '\\' + urllib.unquote(comp)
- # Issue #11474: url like '/C|/' should convert into 'C:\\'
+ path = path + '\\' + urllib.parse.unquote(comp)
+ # Issue #11474 - handing url such as |c/|
if path.endswith(':') and url.endswith('/'):
path += '\\'
return path
@@ -42,7 +42,7 @@ def pathname2url(p):
# C:\foo\bar\spam.foo
# becomes
# ///C|/foo/bar/spam.foo
- import urllib
+ import urllib.parse
if not ':' in p:
# No drive specifier, just convert slashes and quote the name
if p[:2] == '\\\\':
@@ -51,16 +51,16 @@ def pathname2url(p):
# (notice doubling of slashes at the start of the path)
p = '\\\\' + p
components = p.split('\\')
- return urllib.quote('/'.join(components))
+ return urllib.parse.quote('/'.join(components))
comp = p.split(':')
if len(comp) != 2 or len(comp[0]) > 1:
error = 'Bad path: ' + p
- raise IOError, error
+ raise IOError(error)
- drive = urllib.quote(comp[0].upper())
+ drive = urllib.parse.quote(comp[0].upper())
components = comp[1].split('\\')
path = '///' + drive + ':'
for comp in components:
if comp:
- path = path + '/' + urllib.quote(comp)
+ path = path + '/' + urllib.parse.quote(comp)
return path
diff --git a/Lib/numbers.py b/Lib/numbers.py
index bdc6dd65213..ecfad7cef8b 100644
--- a/Lib/numbers.py
+++ b/Lib/numbers.py
@@ -5,18 +5,16 @@
TODO: Fill out more detailed documentation on the operators."""
-from __future__ import division
from abc import ABCMeta, abstractmethod, abstractproperty
__all__ = ["Number", "Complex", "Real", "Rational", "Integral"]
-class Number(object):
+class Number(metaclass=ABCMeta):
"""All numbers inherit from this class.
If you just want to check if an argument x is a number, without
caring what kind, use isinstance(x, Number).
"""
- __metaclass__ = ABCMeta
__slots__ = ()
# Concrete numeric types must provide their own hash implementation
@@ -48,8 +46,7 @@ class Complex(Number):
def __complex__(self):
"""Return a builtin complex instance. Called for complex(self)."""
- # Will be __bool__ in 3.0.
- def __nonzero__(self):
+ def __bool__(self):
"""True if self != 0. Called for bool(self)."""
return self != 0
@@ -108,29 +105,13 @@ class Complex(Number):
raise NotImplementedError
@abstractmethod
- def __div__(self, other):
- """self / other without __future__ division
-
- May promote to float.
- """
- raise NotImplementedError
-
- @abstractmethod
- def __rdiv__(self, other):
- """other / self without __future__ division"""
- raise NotImplementedError
-
- @abstractmethod
def __truediv__(self, other):
- """self / other with __future__ division.
-
- Should promote to float when necessary.
- """
+ """self / other: Should promote to float when necessary."""
raise NotImplementedError
@abstractmethod
def __rtruediv__(self, other):
- """other / self with __future__ division"""
+ """other / self"""
raise NotImplementedError
@abstractmethod
@@ -197,6 +178,25 @@ class Real(Complex):
"""
raise NotImplementedError
+ @abstractmethod
+ def __floor__(self):
+ """Finds the greatest Integral <= self."""
+ raise NotImplementedError
+
+ @abstractmethod
+ def __ceil__(self):
+ """Finds the least Integral >= self."""
+ raise NotImplementedError
+
+ @abstractmethod
+ def __round__(self, ndigits=None):
+ """Rounds self to ndigits decimal places, defaulting to 0.
+
+ If ndigits is omitted or None, returns an Integral, otherwise
+ returns a Real. Rounds half toward even.
+ """
+ raise NotImplementedError
+
def __divmod__(self, other):
"""divmod(self, other): The pair (self // other, self % other).
@@ -293,18 +293,18 @@ class Rational(Real):
class Integral(Rational):
- """Integral adds a conversion to long and the bit-string operations."""
+ """Integral adds a conversion to int and the bit-string operations."""
__slots__ = ()
@abstractmethod
- def __long__(self):
- """long(self)"""
+ def __int__(self):
+ """int(self)"""
raise NotImplementedError
def __index__(self):
"""Called whenever an index is needed, such as in slicing"""
- return long(self)
+ return int(self)
@abstractmethod
def __pow__(self, exponent, modulus=None):
@@ -374,8 +374,8 @@ class Integral(Rational):
# Concrete implementations of Rational and Real abstract methods.
def __float__(self):
- """float(self) == float(long(self))"""
- return float(long(self))
+ """float(self) == float(int(self))"""
+ return float(int(self))
@property
def numerator(self):
@@ -388,4 +388,3 @@ class Integral(Rational):
return 1
Integral.register(int)
-Integral.register(long)
diff --git a/Lib/opcode.py b/Lib/opcode.py
index e403365b6a2..8e15d13e983 100644
--- a/Lib/opcode.py
+++ b/Lib/opcode.py
@@ -48,19 +48,18 @@ def_op('POP_TOP', 1)
def_op('ROT_TWO', 2)
def_op('ROT_THREE', 3)
def_op('DUP_TOP', 4)
-def_op('ROT_FOUR', 5)
+def_op('DUP_TOP_TWO', 5)
def_op('NOP', 9)
def_op('UNARY_POSITIVE', 10)
def_op('UNARY_NEGATIVE', 11)
def_op('UNARY_NOT', 12)
-def_op('UNARY_CONVERT', 13)
def_op('UNARY_INVERT', 15)
def_op('BINARY_POWER', 19)
def_op('BINARY_MULTIPLY', 20)
-def_op('BINARY_DIVIDE', 21)
+
def_op('BINARY_MODULO', 22)
def_op('BINARY_ADD', 23)
def_op('BINARY_SUBTRACT', 24)
@@ -69,26 +68,12 @@ def_op('BINARY_FLOOR_DIVIDE', 26)
def_op('BINARY_TRUE_DIVIDE', 27)
def_op('INPLACE_FLOOR_DIVIDE', 28)
def_op('INPLACE_TRUE_DIVIDE', 29)
-def_op('SLICE+0', 30)
-def_op('SLICE+1', 31)
-def_op('SLICE+2', 32)
-def_op('SLICE+3', 33)
-
-def_op('STORE_SLICE+0', 40)
-def_op('STORE_SLICE+1', 41)
-def_op('STORE_SLICE+2', 42)
-def_op('STORE_SLICE+3', 43)
-
-def_op('DELETE_SLICE+0', 50)
-def_op('DELETE_SLICE+1', 51)
-def_op('DELETE_SLICE+2', 52)
-def_op('DELETE_SLICE+3', 53)
def_op('STORE_MAP', 54)
def_op('INPLACE_ADD', 55)
def_op('INPLACE_SUBTRACT', 56)
def_op('INPLACE_MULTIPLY', 57)
-def_op('INPLACE_DIVIDE', 58)
+
def_op('INPLACE_MODULO', 59)
def_op('STORE_SUBSCR', 60)
def_op('DELETE_SUBSCR', 61)
@@ -99,12 +84,11 @@ def_op('BINARY_XOR', 65)
def_op('BINARY_OR', 66)
def_op('INPLACE_POWER', 67)
def_op('GET_ITER', 68)
+def_op('STORE_LOCALS', 69)
def_op('PRINT_EXPR', 70)
-def_op('PRINT_ITEM', 71)
-def_op('PRINT_NEWLINE', 72)
-def_op('PRINT_ITEM_TO', 73)
-def_op('PRINT_NEWLINE_TO', 74)
+def_op('LOAD_BUILD_CLASS', 71)
+
def_op('INPLACE_LSHIFT', 75)
def_op('INPLACE_RSHIFT', 76)
def_op('INPLACE_AND', 77)
@@ -112,14 +96,14 @@ def_op('INPLACE_XOR', 78)
def_op('INPLACE_OR', 79)
def_op('BREAK_LOOP', 80)
def_op('WITH_CLEANUP', 81)
-def_op('LOAD_LOCALS', 82)
+
def_op('RETURN_VALUE', 83)
def_op('IMPORT_STAR', 84)
-def_op('EXEC_STMT', 85)
+
def_op('YIELD_VALUE', 86)
def_op('POP_BLOCK', 87)
def_op('END_FINALLY', 88)
-def_op('BUILD_CLASS', 89)
+def_op('POP_EXCEPT', 89)
HAVE_ARGUMENT = 90 # Opcodes from here have an argument:
@@ -127,12 +111,11 @@ name_op('STORE_NAME', 90) # Index in name list
name_op('DELETE_NAME', 91) # ""
def_op('UNPACK_SEQUENCE', 92) # Number of tuple items
jrel_op('FOR_ITER', 93)
-def_op('LIST_APPEND', 94)
+def_op('UNPACK_EX', 94)
name_op('STORE_ATTR', 95) # Index in name list
name_op('DELETE_ATTR', 96) # ""
name_op('STORE_GLOBAL', 97) # ""
name_op('DELETE_GLOBAL', 98) # ""
-def_op('DUP_TOPX', 99) # number of items to duplicate
def_op('LOAD_CONST', 100) # Index in const list
hasconst.append(100)
name_op('LOAD_NAME', 101) # Index in name list
@@ -145,6 +128,7 @@ def_op('COMPARE_OP', 107) # Comparison operator
hascompare.append(107)
name_op('IMPORT_NAME', 108) # Index in name list
name_op('IMPORT_FROM', 109) # Index in name list
+
jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip
jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code
jabs_op('JUMP_IF_TRUE_OR_POP', 112) # ""
@@ -177,6 +161,8 @@ def_op('LOAD_DEREF', 136)
hasfree.append(136)
def_op('STORE_DEREF', 137)
hasfree.append(137)
+def_op('DELETE_DEREF', 138)
+hasfree.append(138)
def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
@@ -184,9 +170,11 @@ def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
jrel_op('SETUP_WITH', 143)
-def_op('EXTENDED_ARG', 145)
-EXTENDED_ARG = 145
+def_op('LIST_APPEND', 145)
def_op('SET_ADD', 146)
def_op('MAP_ADD', 147)
+def_op('EXTENDED_ARG', 144)
+EXTENDED_ARG = 144
+
del def_op, name_op, jrel_op, jabs_op
diff --git a/Lib/optparse.py b/Lib/optparse.py
index 731a2bb5edf..d97a1f7aca3 100644
--- a/Lib/optparse.py
+++ b/Lib/optparse.py
@@ -73,7 +73,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import sys, os
-import types
import textwrap
def _repr(self):
@@ -246,10 +245,10 @@ class HelpFormatter:
self.level -= 1
def format_usage(self, usage):
- raise NotImplementedError, "subclasses must implement"
+ raise NotImplementedError("subclasses must implement")
def format_heading(self, heading):
- raise NotImplementedError, "subclasses must implement"
+ raise NotImplementedError("subclasses must implement")
def _format_text(self, text):
"""
@@ -413,7 +412,7 @@ def _parse_int(val):
return _parse_num(val, int)
def _parse_long(val):
- return _parse_num(val, long)
+ return _parse_num(val, int)
_builtin_cvt = { "int" : (_parse_int, _("integer")),
"long" : (_parse_long, _("long integer")),
@@ -580,7 +579,7 @@ class Option:
# Filter out None because early versions of Optik had exactly
# one short option and one long option, either of which
# could be None.
- opts = filter(None, opts)
+ opts = [opt for opt in opts if opt]
if not opts:
raise TypeError("at least one option string must be supplied")
return opts
@@ -617,8 +616,7 @@ class Option:
else:
setattr(self, attr, None)
if attrs:
- attrs = attrs.keys()
- attrs.sort()
+ attrs = sorted(attrs.keys())
raise OptionError(
"invalid keyword arguments: %s" % ", ".join(attrs),
self)
@@ -644,13 +642,13 @@ class Option:
else:
# Allow type objects or builtin type conversion functions
# (int, str, etc.) as an alternative to their names. (The
- # complicated check of __builtin__ is only necessary for
+ # complicated check of builtins is only necessary for
# Python 2.1 and earlier, and is short-circuited by the
# first check on modern Pythons.)
- import __builtin__
- if ( type(self.type) is types.TypeType or
+ import builtins
+ if ( isinstance(self.type, type) or
(hasattr(self.type, "__name__") and
- getattr(__builtin__, self.type.__name__, None) is self.type) ):
+ getattr(builtins, self.type.__name__, None) is self.type) ):
self.type = self.type.__name__
if self.type == "str":
@@ -667,7 +665,7 @@ class Option:
if self.choices is None:
raise OptionError(
"must supply a list of choices for type 'choice'", self)
- elif type(self.choices) not in (types.TupleType, types.ListType):
+ elif not isinstance(self.choices, (tuple, list)):
raise OptionError(
"choices must be a list of strings ('%s' supplied)"
% str(type(self.choices)).split("'")[1], self)
@@ -707,16 +705,16 @@ class Option:
def _check_callback(self):
if self.action == "callback":
- if not hasattr(self.callback, '__call__'):
+ if not callable(self.callback):
raise OptionError(
"callback not callable: %r" % self.callback, self)
if (self.callback_args is not None and
- type(self.callback_args) is not types.TupleType):
+ not isinstance(self.callback_args, tuple)):
raise OptionError(
"callback_args, if supplied, must be a tuple: not %r"
% self.callback_args, self)
if (self.callback_kwargs is not None and
- type(self.callback_kwargs) is not types.DictType):
+ not isinstance(self.callback_kwargs, dict)):
raise OptionError(
"callback_kwargs, if supplied, must be a dict: not %r"
% self.callback_kwargs, self)
@@ -823,15 +821,6 @@ class Option:
SUPPRESS_HELP = "SUPPRESS"+"HELP"
SUPPRESS_USAGE = "SUPPRESS"+"USAGE"
-try:
- basestring
-except NameError:
- def isbasestring(x):
- return isinstance(x, (types.StringType, types.UnicodeType))
-else:
- def isbasestring(x):
- return isinstance(x, basestring)
-
class Values:
def __init__(self, defaults=None):
@@ -844,13 +833,13 @@ class Values:
__repr__ = _repr
- def __cmp__(self, other):
+ def __eq__(self, other):
if isinstance(other, Values):
- return cmp(self.__dict__, other.__dict__)
- elif isinstance(other, types.DictType):
- return cmp(self.__dict__, other)
+ return self.__dict__ == other.__dict__
+ elif isinstance(other, dict):
+ return self.__dict__ == other
else:
- return -1
+ return NotImplemented
def _update_careful(self, dict):
"""
@@ -879,7 +868,7 @@ class Values:
elif mode == "loose":
self._update_loose(dict)
else:
- raise ValueError, "invalid update mode: %r" % mode
+ raise ValueError("invalid update mode: %r" % mode)
def read_module(self, modname, mode="careful"):
__import__(modname)
@@ -888,7 +877,7 @@ class Values:
def read_file(self, filename, mode="careful"):
vars = {}
- execfile(filename, vars)
+ exec(open(filename).read(), vars)
self._update(vars, mode)
def ensure_value(self, attr, value):
@@ -958,7 +947,7 @@ class OptionContainer:
def set_conflict_handler(self, handler):
if handler not in ("error", "resolve"):
- raise ValueError, "invalid conflict_resolution value %r" % handler
+ raise ValueError("invalid conflict_resolution value %r" % handler)
self.conflict_handler = handler
def set_description(self, description):
@@ -1008,14 +997,14 @@ class OptionContainer:
"""add_option(Option)
add_option(opt_str, ..., kwarg=val, ...)
"""
- if type(args[0]) in types.StringTypes:
+ if isinstance(args[0], str):
option = self.option_class(*args, **kwargs)
elif len(args) == 1 and not kwargs:
option = args[0]
if not isinstance(option, Option):
- raise TypeError, "not an Option instance: %r" % option
+ raise TypeError("not an Option instance: %r" % option)
else:
- raise TypeError, "invalid arguments"
+ raise TypeError("invalid arguments")
self._check_conflict(option)
@@ -1323,7 +1312,7 @@ class OptionParser (OptionContainer):
defaults = self.defaults.copy()
for option in self._get_all_options():
default = defaults.get(option.dest)
- if isbasestring(default):
+ if isinstance(default, str):
opt_str = option.get_opt_string()
defaults[option.dest] = option.check_value(opt_str, default)
@@ -1334,16 +1323,16 @@ class OptionParser (OptionContainer):
def add_option_group(self, *args, **kwargs):
# XXX lots of overlap with OptionContainer.add_option()
- if type(args[0]) is types.StringType:
+ if isinstance(args[0], str):
group = OptionGroup(self, *args, **kwargs)
elif len(args) == 1 and not kwargs:
group = args[0]
if not isinstance(group, OptionGroup):
- raise TypeError, "not an OptionGroup instance: %r" % group
+ raise TypeError("not an OptionGroup instance: %r" % group)
if group.parser is not self:
- raise ValueError, "invalid OptionGroup (wrong parser)"
+ raise ValueError("invalid OptionGroup (wrong parser)")
else:
- raise TypeError, "invalid arguments"
+ raise TypeError("invalid arguments")
self.option_groups.append(group)
return group
@@ -1397,7 +1386,7 @@ class OptionParser (OptionContainer):
try:
stop = self._process_args(largs, rargs, values)
- except (BadOptionError, OptionValueError), err:
+ except (BadOptionError, OptionValueError) as err:
self.error(str(err))
args = largs + rargs
@@ -1599,7 +1588,7 @@ class OptionParser (OptionContainer):
or not defined.
"""
if self.usage:
- print >>file, self.get_usage()
+ print(self.get_usage(), file=file)
def get_version(self):
if self.version:
@@ -1616,7 +1605,7 @@ class OptionParser (OptionContainer):
name. Does nothing if self.version is empty or undefined.
"""
if self.version:
- print >>file, self.get_version()
+ print(self.get_version(), file=file)
def format_option_help(self, formatter=None):
if formatter is None:
@@ -1650,13 +1639,6 @@ class OptionParser (OptionContainer):
result.append(self.format_epilog(formatter))
return "".join(result)
- # used by test suite
- def _get_encoding(self, file):
- encoding = getattr(file, "encoding", None)
- if not encoding:
- encoding = sys.getdefaultencoding()
- return encoding
-
def print_help(self, file=None):
"""print_help(file : file = stdout)
@@ -1665,8 +1647,7 @@ class OptionParser (OptionContainer):
"""
if file is None:
file = sys.stdout
- encoding = self._get_encoding(file)
- file.write(self.format_help().encode(encoding, "replace"))
+ file.write(self.format_help())
# class OptionParser
diff --git a/Lib/os.py b/Lib/os.py
index 6d598f3e915..d1101a26a0d 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -2,12 +2,12 @@ r"""OS routines for Mac, NT, or Posix depending on what system we're on.
This exports:
- all functions from posix, nt, os2, or ce, e.g. unlink, stat, etc.
- - os.path is one of the modules posixpath, or ntpath
- - os.name is 'posix', 'nt', 'os2', 'ce' or 'riscos'
+ - os.path is either posixpath or ntpath
+ - os.name is either 'posix', 'nt', 'os2' or 'ce'.
- os.curdir is a string representing the current directory ('.' or ':')
- os.pardir is a string representing the parent directory ('..' or '::')
- os.sep is the (or a most common) pathname separator ('/' or ':' or '\\')
- - os.extsep is the extension separator ('.' or '/')
+ - os.extsep is the extension separator (always '.')
- os.altsep is the alternate pathname separator (None or '/')
- os.pathsep is the component separator used in $PATH etc
- os.linesep is the line separator in text files ('\r' or '\n' or '\r\n')
@@ -28,7 +28,7 @@ import sys, errno
_names = sys.builtin_module_names
# Note: more names are added to __all__ later.
-__all__ = ["altsep", "curdir", "pardir", "sep", "extsep", "pathsep", "linesep",
+__all__ = ["altsep", "curdir", "pardir", "sep", "pathsep", "linesep",
"defpath", "name", "path", "devnull",
"SEEK_SET", "SEEK_CUR", "SEEK_END"]
@@ -99,22 +99,8 @@ elif 'ce' in _names:
__all__.extend(_get_exports_list(ce))
del ce
-elif 'riscos' in _names:
- name = 'riscos'
- linesep = '\n'
- from riscos import *
- try:
- from riscos import _exit
- except ImportError:
- pass
- import riscospath as path
-
- import riscos
- __all__.extend(_get_exports_list(riscos))
- del riscos
-
else:
- raise ImportError, 'no os specific module found'
+ raise ImportError('no os specific module found')
sys.modules['os.path'] = path
from os.path import (curdir, pardir, sep, pathsep, defpath, extsep, altsep,
@@ -128,18 +114,26 @@ SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
+
+def _get_masked_mode(mode):
+ mask = umask(0)
+ umask(mask)
+ return mode & ~mask
+
#'
# Super directory utilities.
# (Inspired by Eric Raymond; the doc strings are mostly his)
-def makedirs(name, mode=0777):
- """makedirs(path [, mode=0777])
+def makedirs(name, mode=0o777, exist_ok=False):
+ """makedirs(path [, mode=0o777][, exist_ok=False])
Super-mkdir; create a leaf directory and all intermediate ones.
Works like mkdir, except that any intermediate path segment (not
- just the rightmost) will be created if it does not exist. This is
- recursive.
+ just the rightmost) will be created if it does not exist. If the
+ target directory with the same mode as we specified already exists,
+ raises an OSError if exist_ok is False, otherwise no exception is
+ raised. This is recursive.
"""
head, tail = path.split(name)
@@ -147,14 +141,29 @@ def makedirs(name, mode=0777):
head, tail = path.split(head)
if head and tail and not path.exists(head):
try:
- makedirs(head, mode)
- except OSError, e:
+ makedirs(head, mode, exist_ok)
+ except OSError as e:
# be happy if someone already created the path
if e.errno != errno.EEXIST:
raise
if tail == curdir: # xxx/newdir/. exists if xxx/newdir exists
return
- mkdir(name, mode)
+ try:
+ mkdir(name, mode)
+ except OSError as e:
+ import stat as st
+ dir_exists = path.isdir(name)
+ expected_mode = _get_masked_mode(mode)
+ if dir_exists:
+ # S_ISGID is automatically copied by the OS from parent to child
+ # directories on mkdir. Don't consider it being set to be a mode
+ # mismatch as mkdir does not unset it when not specified in mode.
+ actual_mode = st.S_IMODE(lstat(name).st_mode) & ~st.S_ISGID
+ else:
+ actual_mode = -1
+ if not (e.errno == errno.EEXIST and exist_ok and dir_exists and
+ actual_mode == expected_mode):
+ raise
def removedirs(name):
"""removedirs(path)
@@ -256,9 +265,9 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
- print root, "consumes",
- print sum([getsize(join(root, name)) for name in files]),
- print "bytes in", len(files), "non-directory files"
+ print(root, "consumes", end="")
+ print(sum([getsize(join(root, name)) for name in files]), end="")
+ print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
"""
@@ -266,7 +275,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
islink, join, isdir = path.islink, path.join, path.isdir
# We may not have read permission for top, in which case we can't
- # get a list of the files the directory contains. os.path.walk
+ # get a list of the files the directory contains. os.walk
# always suppressed the exception then, rather than blow up for a
# minor reason when (say) a thousand readable directories are still
# left to visit. That logic is copied here.
@@ -274,7 +283,7 @@ def walk(top, topdown=True, onerror=None, followlinks=False):
# Note that listdir and error are globals in this module due
# to earlier import-*.
names = listdir(top)
- except error, err:
+ except error as err:
if onerror is not None:
onerror(err)
return
@@ -356,162 +365,247 @@ __all__.extend(["execl","execle","execlp","execlpe","execvp","execvpe"])
def _execvpe(file, args, env=None):
if env is not None:
- func = execve
+ exec_func = execve
argrest = (args, env)
else:
- func = execv
+ exec_func = execv
argrest = (args,)
env = environ
head, tail = path.split(file)
if head:
- func(file, *argrest)
+ exec_func(file, *argrest)
return
- if 'PATH' in env:
- envpath = env['PATH']
- else:
- envpath = defpath
- PATH = envpath.split(pathsep)
- saved_exc = None
+ last_exc = saved_exc = None
saved_tb = None
- for dir in PATH:
+ path_list = get_exec_path(env)
+ if name != 'nt':
+ file = fsencode(file)
+ path_list = map(fsencode, path_list)
+ for dir in path_list:
fullname = path.join(dir, file)
try:
- func(fullname, *argrest)
- except error, e:
+ exec_func(fullname, *argrest)
+ except error as e:
+ last_exc = e
tb = sys.exc_info()[2]
if (e.errno != errno.ENOENT and e.errno != errno.ENOTDIR
and saved_exc is None):
saved_exc = e
saved_tb = tb
if saved_exc:
- raise error, saved_exc, saved_tb
- raise error, e, tb
+ raise saved_exc.with_traceback(saved_tb)
+ raise last_exc.with_traceback(tb)
+
+
+def get_exec_path(env=None):
+ """Returns the sequence of directories that will be searched for the
+ named executable (similar to a shell) when launching a process.
+
+ *env* must be an environment variable dict or None. If *env* is None,
+ os.environ will be used.
+ """
+ # Use a local import instead of a global import to limit the number of
+ # modules loaded at startup: the os module is always loaded at startup by
+ # Python. It may also avoid a bootstrap issue.
+ import warnings
+
+ if env is None:
+ env = environ
+
+ # {b'PATH': ...}.get('PATH') and {'PATH': ...}.get(b'PATH') emit a
+ # BytesWarning when using python -b or python -bb: ignore the warning
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", BytesWarning)
+
+ try:
+ path_list = env.get('PATH')
+ except TypeError:
+ path_list = None
+
+ if supports_bytes_environ:
+ try:
+ path_listb = env[b'PATH']
+ except (KeyError, TypeError):
+ pass
+ else:
+ if path_list is not None:
+ raise ValueError(
+ "env cannot contain 'PATH' and b'PATH' keys")
+ path_list = path_listb
+
+ if path_list is not None and isinstance(path_list, bytes):
+ path_list = fsdecode(path_list)
+
+ if path_list is None:
+ path_list = defpath
+ return path_list.split(pathsep)
+
+
+# Change environ to automatically call putenv(), unsetenv if they exist.
+from _abcoll import MutableMapping # Can't use collections (bootstrap)
+
+class _Environ(MutableMapping):
+ def __init__(self, data, encodekey, decodekey, encodevalue, decodevalue, putenv, unsetenv):
+ self.encodekey = encodekey
+ self.decodekey = decodekey
+ self.encodevalue = encodevalue
+ self.decodevalue = decodevalue
+ self.putenv = putenv
+ self.unsetenv = unsetenv
+ self._data = data
+
+ def __getitem__(self, key):
+ value = self._data[self.encodekey(key)]
+ return self.decodevalue(value)
+
+ def __setitem__(self, key, value):
+ key = self.encodekey(key)
+ value = self.encodevalue(value)
+ self.putenv(key, value)
+ self._data[key] = value
+
+ def __delitem__(self, key):
+ key = self.encodekey(key)
+ self.unsetenv(key)
+ del self._data[key]
+
+ def __iter__(self):
+ for key in self._data:
+ yield self.decodekey(key)
+
+ def __len__(self):
+ return len(self._data)
+
+ def __repr__(self):
+ return 'environ({{{}}})'.format(', '.join(
+ ('{!r}: {!r}'.format(self.decodekey(key), self.decodevalue(value))
+ for key, value in self._data.items())))
+
+ def copy(self):
+ return dict(self)
+
+ def setdefault(self, key, value):
+ if key not in self:
+ self[key] = value
+ return self[key]
-# Change environ to automatically call putenv() if it exists
try:
- # This will fail if there's no putenv
- putenv
+ _putenv = putenv
except NameError:
- pass
+ _putenv = lambda key, value: None
else:
- import UserDict
+ __all__.append("putenv")
- # Fake unsetenv() for Windows
- # not sure about os2 here but
- # I'm guessing they are the same.
+try:
+ _unsetenv = unsetenv
+except NameError:
+ _unsetenv = lambda key: _putenv(key, "")
+else:
+ __all__.append("unsetenv")
+def _createenviron():
if name in ('os2', 'nt'):
- def unsetenv(key):
- putenv(key, "")
-
- if name == "riscos":
- # On RISC OS, all env access goes through getenv and putenv
- from riscosenviron import _Environ
- elif name in ('os2', 'nt'): # Where Env Var Names Must Be UPPERCASE
- # But we store them as upper case
- class _Environ(UserDict.IterableUserDict):
- def __init__(self, environ):
- UserDict.UserDict.__init__(self)
- data = self.data
- for k, v in environ.items():
- data[k.upper()] = v
- def __setitem__(self, key, item):
- putenv(key, item)
- self.data[key.upper()] = item
- def __getitem__(self, key):
- return self.data[key.upper()]
- try:
- unsetenv
- except NameError:
- def __delitem__(self, key):
- del self.data[key.upper()]
- else:
- def __delitem__(self, key):
- unsetenv(key)
- del self.data[key.upper()]
- def clear(self):
- for key in self.data.keys():
- unsetenv(key)
- del self.data[key]
- def pop(self, key, *args):
- unsetenv(key)
- return self.data.pop(key.upper(), *args)
- def has_key(self, key):
- return key.upper() in self.data
- def __contains__(self, key):
- return key.upper() in self.data
- def get(self, key, failobj=None):
- return self.data.get(key.upper(), failobj)
- def update(self, dict=None, **kwargs):
- if dict:
- try:
- keys = dict.keys()
- except AttributeError:
- # List of (key, value)
- for k, v in dict:
- self[k] = v
- else:
- # got keys
- # cannot use items(), since mappings
- # may not have them.
- for k in keys:
- self[k] = dict[k]
- if kwargs:
- self.update(kwargs)
- def copy(self):
- return dict(self)
-
- else: # Where Env Var Names Can Be Mixed Case
- class _Environ(UserDict.IterableUserDict):
- def __init__(self, environ):
- UserDict.UserDict.__init__(self)
- self.data = environ
- def __setitem__(self, key, item):
- putenv(key, item)
- self.data[key] = item
- def update(self, dict=None, **kwargs):
- if dict:
- try:
- keys = dict.keys()
- except AttributeError:
- # List of (key, value)
- for k, v in dict:
- self[k] = v
- else:
- # got keys
- # cannot use items(), since mappings
- # may not have them.
- for k in keys:
- self[k] = dict[k]
- if kwargs:
- self.update(kwargs)
- try:
- unsetenv
- except NameError:
- pass
- else:
- def __delitem__(self, key):
- unsetenv(key)
- del self.data[key]
- def clear(self):
- for key in self.data.keys():
- unsetenv(key)
- del self.data[key]
- def pop(self, key, *args):
- unsetenv(key)
- return self.data.pop(key, *args)
- def copy(self):
- return dict(self)
-
-
- environ = _Environ(environ)
+ # Where Env Var Names Must Be UPPERCASE
+ def check_str(value):
+ if not isinstance(value, str):
+ raise TypeError("str expected, not %s" % type(value).__name__)
+ return value
+ encode = check_str
+ decode = str
+ def encodekey(key):
+ return encode(key).upper()
+ data = {}
+ for key, value in environ.items():
+ data[encodekey(key)] = value
+ else:
+ # Where Env Var Names Can Be Mixed Case
+ encoding = sys.getfilesystemencoding()
+ def encode(value):
+ if not isinstance(value, str):
+ raise TypeError("str expected, not %s" % type(value).__name__)
+ return value.encode(encoding, 'surrogateescape')
+ def decode(value):
+ return value.decode(encoding, 'surrogateescape')
+ encodekey = encode
+ data = environ
+ return _Environ(data,
+ encodekey, decode,
+ encode, decode,
+ _putenv, _unsetenv)
+
+# unicode environ
+environ = _createenviron()
+del _createenviron
+
def getenv(key, default=None):
"""Get an environment variable, return None if it doesn't exist.
- The optional second argument can specify an alternate default."""
+ The optional second argument can specify an alternate default.
+ key, default and the result are str."""
return environ.get(key, default)
-__all__.append("getenv")
+
+supports_bytes_environ = name not in ('os2', 'nt')
+__all__.extend(("getenv", "supports_bytes_environ"))
+
+if supports_bytes_environ:
+ def _check_bytes(value):
+ if not isinstance(value, bytes):
+ raise TypeError("bytes expected, not %s" % type(value).__name__)
+ return value
+
+ # bytes environ
+ environb = _Environ(environ._data,
+ _check_bytes, bytes,
+ _check_bytes, bytes,
+ _putenv, _unsetenv)
+ del _check_bytes
+
+ def getenvb(key, default=None):
+ """Get an environment variable, return None if it doesn't exist.
+ The optional second argument can specify an alternate default.
+ key, default and the result are bytes."""
+ return environb.get(key, default)
+
+ __all__.extend(("environb", "getenvb"))
+
+def _fscodec():
+ encoding = sys.getfilesystemencoding()
+ if encoding == 'mbcs':
+ errors = 'strict'
+ else:
+ errors = 'surrogateescape'
+
+ def fsencode(filename):
+ """
+ Encode filename to the filesystem encoding with 'surrogateescape' error
+ handler, return bytes unchanged. On Windows, use 'strict' error handler if
+ the file system encoding is 'mbcs' (which is the default encoding).
+ """
+ if isinstance(filename, bytes):
+ return filename
+ elif isinstance(filename, str):
+ return filename.encode(encoding, errors)
+ else:
+ raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+
+ def fsdecode(filename):
+ """
+ Decode filename from the filesystem encoding with 'surrogateescape' error
+ handler, return str unchanged. On Windows, use 'strict' error handler if
+ the file system encoding is 'mbcs' (which is the default encoding).
+ """
+ if isinstance(filename, str):
+ return filename
+ elif isinstance(filename, bytes):
+ return filename.decode(encoding, errors)
+ else:
+ raise TypeError("expect bytes or str, not %s" % type(filename).__name__)
+
+ return fsencode, fsdecode
+
+fsencode, fsdecode = _fscodec()
+del _fscodec
def _exists(name):
return name in globals()
@@ -551,7 +645,7 @@ if _exists("fork") and not _exists("spawnv") and _exists("execv"):
elif WIFEXITED(sts):
return WEXITSTATUS(sts)
else:
- raise error, "Not stopped, signaled or exited???"
+ raise error("Not stopped, signaled or exited???")
def spawnv(mode, file, args):
"""spawnv(mode, file, args) -> integer
@@ -649,70 +743,7 @@ otherwise return -SIG, where SIG is the signal that killed it. """
__all__.extend(["spawnvp", "spawnvpe", "spawnlp", "spawnlpe",])
-
-# Supply popen2 etc. (for Unix)
-if _exists("fork"):
- if not _exists("popen2"):
- def popen2(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout) are returned."""
- import warnings
- msg = "os.popen2 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring),
- bufsize=bufsize, stdin=PIPE, stdout=PIPE,
- close_fds=True)
- return p.stdin, p.stdout
- __all__.append("popen2")
-
- if not _exists("popen3"):
- def popen3(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout, child_stderr) are returned."""
- import warnings
- msg = "os.popen3 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring),
- bufsize=bufsize, stdin=PIPE, stdout=PIPE,
- stderr=PIPE, close_fds=True)
- return p.stdin, p.stdout, p.stderr
- __all__.append("popen3")
-
- if not _exists("popen4"):
- def popen4(cmd, mode="t", bufsize=-1):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd'
- may be a sequence, in which case arguments will be passed directly to
- the program without shell intervention (as with os.spawnv()). If 'cmd'
- is a string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdin, child_stdout_stderr) are returned."""
- import warnings
- msg = "os.popen4 is deprecated. Use the subprocess module."
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- import subprocess
- PIPE = subprocess.PIPE
- p = subprocess.Popen(cmd, shell=isinstance(cmd, basestring),
- bufsize=bufsize, stdin=PIPE, stdout=PIPE,
- stderr=subprocess.STDOUT, close_fds=True)
- return p.stdin, p.stdout
- __all__.append("popen4")
-
-import copy_reg as _copy_reg
+import copyreg as _copyreg
def _make_stat_result(tup, dict):
return stat_result(tup, dict)
@@ -722,7 +753,7 @@ def _pickle_stat_result(sr):
return (_make_stat_result, args)
try:
- _copy_reg.pickle(stat_result, _pickle_stat_result, _make_stat_result)
+ _copyreg.pickle(stat_result, _pickle_stat_result, _make_stat_result)
except NameError: # stat_result may not exist
pass
@@ -734,7 +765,59 @@ def _pickle_statvfs_result(sr):
return (_make_statvfs_result, args)
try:
- _copy_reg.pickle(statvfs_result, _pickle_statvfs_result,
+ _copyreg.pickle(statvfs_result, _pickle_statvfs_result,
_make_statvfs_result)
except NameError: # statvfs_result may not exist
pass
+
+# Supply os.popen()
+def popen(cmd, mode="r", buffering=-1):
+ if not isinstance(cmd, str):
+ raise TypeError("invalid cmd type (%s, expected string)" % type(cmd))
+ if mode not in ("r", "w"):
+ raise ValueError("invalid mode %r" % mode)
+ if buffering == 0 or buffering == None:
+ raise ValueError("popen() does not support unbuffered streams")
+ import subprocess, io
+ if mode == "r":
+ proc = subprocess.Popen(cmd,
+ shell=True,
+ stdout=subprocess.PIPE,
+ bufsize=buffering)
+ return _wrap_close(io.TextIOWrapper(proc.stdout), proc)
+ else:
+ proc = subprocess.Popen(cmd,
+ shell=True,
+ stdin=subprocess.PIPE,
+ bufsize=buffering)
+ return _wrap_close(io.TextIOWrapper(proc.stdin), proc)
+
+# Helper for popen() -- a proxy for a file whose close waits for the process
+class _wrap_close:
+ def __init__(self, stream, proc):
+ self._stream = stream
+ self._proc = proc
+ def close(self):
+ self._stream.close()
+ returncode = self._proc.wait()
+ if returncode == 0:
+ return None
+ if name == 'nt':
+ return returncode
+ else:
+ return returncode << 8 # Shift left to match old behavior
+ def __enter__(self):
+ return self
+ def __exit__(self, *args):
+ self.close()
+ def __getattr__(self, name):
+ return getattr(self._stream, name)
+ def __iter__(self):
+ return iter(self._stream)
+
+# Supply os.fdopen()
+def fdopen(fd, *args, **kwargs):
+ if not isinstance(fd, int):
+ raise TypeError("invalid fd type (%s, expected integer)" % type(fd))
+ import io
+ return io.open(fd, *args, **kwargs)
diff --git a/Lib/os2emxpath.py b/Lib/os2emxpath.py
index 1bed51d4fab..0ccbf8ae7b8 100644
--- a/Lib/os2emxpath.py
+++ b/Lib/os2emxpath.py
@@ -9,12 +9,12 @@ import os
import stat
from genericpath import *
from ntpath import (expanduser, expandvars, isabs, islink, splitdrive,
- splitext, split, walk)
+ splitext, split)
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
- "ismount","walk","expanduser","expandvars","normpath","abspath",
+ "ismount","expanduser","expandvars","normpath","abspath",
"splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
"extsep","devnull","realpath","supports_unicode_filenames"]
@@ -36,6 +36,9 @@ def normcase(s):
"""Normalize case of pathname.
Makes all characters lowercase and all altseps into seps."""
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
return s.replace('\\', '/').lower()
@@ -146,11 +149,7 @@ def normpath(path):
def abspath(path):
"""Return the absolute version of a path"""
if not isabs(path):
- if isinstance(path, unicode):
- cwd = os.getcwdu()
- else:
- cwd = os.getcwd()
- path = join(cwd, path)
+ path = join(os.getcwd(), path)
return normpath(path)
# realpath is a no-op on systems without islink support
diff --git a/Lib/pdb.doc b/Lib/pdb.doc
deleted file mode 100644
index 375be2f8be2..00000000000
--- a/Lib/pdb.doc
+++ /dev/null
@@ -1,202 +0,0 @@
-The Python Debugger Pdb
-=======================
-
-To use the debugger in its simplest form:
-
- >>> import pdb
- >>> pdb.run('<a statement>')
-
-The debugger's prompt is '(Pdb) '. This will stop in the first
-function call in <a statement>.
-
-Alternatively, if a statement terminated with an unhandled exception,
-you can use pdb's post-mortem facility to inspect the contents of the
-traceback:
-
- >>> <a statement>
- <exception traceback>
- >>> import pdb
- >>> pdb.pm()
-
-The commands recognized by the debugger are listed in the next
-section. Most can be abbreviated as indicated; e.g., h(elp) means
-that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel',
-nor as 'H' or 'Help' or 'HELP'). Optional arguments are enclosed in
-square brackets.
-
-A blank line repeats the previous command literally, except for
-'list', where it lists the next 11 lines.
-
-Commands that the debugger doesn't recognize are assumed to be Python
-statements and are executed in the context of the program being
-debugged. Python statements can also be prefixed with an exclamation
-point ('!'). This is a powerful way to inspect the program being
-debugged; it is even possible to change variables. When an exception
-occurs in such a statement, the exception name is printed but the
-debugger's state is not changed.
-
-The debugger supports aliases, which can save typing. And aliases can
-have parameters (see the alias help entry) which allows one a certain
-level of adaptability to the context under examination.
-
-Multiple commands may be entered on a single line, separated by the
-pair ';;'. No intelligence is applied to separating the commands; the
-input is split at the first ';;', even if it is in the middle of a
-quoted string.
-
-If a file ".pdbrc" exists in your home directory or in the current
-directory, it is read in and executed as if it had been typed at the
-debugger prompt. This is particularly useful for aliases. If both
-files exist, the one in the home directory is read first and aliases
-defined there can be overriden by the local file.
-
-Aside from aliases, the debugger is not directly programmable; but it
-is implemented as a class from which you can derive your own debugger
-class, which you can make as fancy as you like.
-
-
-Debugger commands
-=================
-
-h(elp)
- Without argument, print the list of available commands. With
- a command name as argument, print help about that command
- (this is currently not implemented).
-
-w(here)
- Print a stack trace, with the most recent frame at the bottom.
- An arrow indicates the "current frame", which determines the
- context of most commands.
-
-d(own)
- Move the current frame one level down in the stack trace
- (to a newer frame).
-
-u(p)
- Move the current frame one level up in the stack trace
- (to an older frame).
-
-b(reak) [ ([filename:]lineno | function) [, condition] ]
- With a filename:line number argument, set a break there. If
- filename is omitted, use the current file. With a function
- name, set a break at the first executable line of that
- function. Without argument, list all breaks. Each breakpoint
- is assigned a number to which all the other breakpoint
- commands refer.
-
- The condition argument, if present, is a string which must
- evaluate to true in order for the breakpoint to be honored.
-
-tbreak [ ([filename:]lineno | function) [, condition] ]
- Temporary breakpoint, which is removed automatically when it
- is first hit. The arguments are the same as break.
-
-cl(ear) [bpnumber [bpnumber ...] ]
- With a space separated list of breakpoint numbers, clear those
- breakpoints. Without argument, clear all breaks (but first
- ask confirmation).
-
-disable bpnumber [bpnumber ...]
- Disables the breakpoints given as a space separated list of
- breakpoint numbers. Disabling a breakpoint means it cannot
- cause the program to stop execution, but unlike clearing a
- breakpoint, it remains in the list of breakpoints and can be
- (re-)enabled.
-
-enable bpnumber [bpnumber ...]
- Enables the breakpoints specified.
-
-ignore bpnumber count
- Sets the ignore count for the given breakpoint number. If
- count is omitted, the ignore count is set to 0. A breakpoint
- becomes active when the ignore count is zero. When non-zero,
- the count is decremented each time the breakpoint is reached
- and the breakpoint is not disabled and any associated
- condition evaluates to true.
-
-condition bpnumber condition
- condition is an expression which must evaluate to true before
- the breakpoint is honored. If condition is absent, any
- existing condition is removed; i.e., the breakpoint is made
- unconditional.
-
-s(tep)
- Execute the current line, stop at the first possible occasion
- (either in a function that is called or in the current function).
-
-n(ext)
- Continue execution until the next line in the current function
- is reached or it returns.
-
-unt(il)
- Continue execution until the line with a number greater than the
- current one is reached or until the current frame returns.
-
-r(eturn)
- Continue execution until the current function returns.
-
-run [args...]
- Restart the debugged python program. If a string is supplied it is
- splitted with "shlex", and the result is used as the new sys.argv.
- History, breakpoints, actions and debugger options are preserved.
- "restart" is an alias for "run".
-
-c(ont(inue))
- Continue execution, only stop when a breakpoint is encountered.
-
-l(ist) [first [,last]]
- List source code for the current file.
- Without arguments, list 11 lines around the current line
- or continue the previous listing.
- With one argument, list 11 lines starting at that line.
- With two arguments, list the given range;
- if the second argument is less than the first, it is a count.
-
-a(rgs)
- Print the argument list of the current function.
-
-p expression
- Print the value of the expression.
-
-(!) statement
- Execute the (one-line) statement in the context of the current
- stack frame. The exclamation point can be omitted unless the
- first word of the statement resembles a debugger command. To
- assign to a global variable you must always prefix the command
- with a 'global' command, e.g.:
- (Pdb) global list_options; list_options = ['-l']
- (Pdb)
-
-
-whatis arg
- Prints the type of the argument.
-
-alias [name [command]]
- Creates an alias called 'name' that executes 'command'. The
- command must *not* be enclosed in quotes. Replaceable
- parameters can be indicated by %1, %2, and so on, while %* is
- replaced by all the parameters. If no command is given, the
- current alias for name is shown. If no name is given, all
- aliases are listed.
-
- Aliases may be nested and can contain anything that can be
- legally typed at the pdb prompt. Note! You *can* override
- internal pdb commands with aliases! Those internal commands
- are then hidden until the alias is removed. Aliasing is
- recursively applied to the first word of the command line; all
- other words in the line are left alone.
-
- As an example, here are two useful aliases (especially when
- placed in the .pdbrc file):
-
- #Print instance variables (usage "pi classInst")
- alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
- #Print instance variables in self
- alias ps pi self
-
-unalias name
- Deletes the specified alias.
-
-q(uit)
- Quit from the debugger.
- The program being executed is aborted.
diff --git a/Lib/pdb.py b/Lib/pdb.py
index 5468d3fcaff..8c7c12b92cb 100755
--- a/Lib/pdb.py
+++ b/Lib/pdb.py
@@ -1,30 +1,89 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
-"""A Python debugger."""
+"""
+The Python Debugger Pdb
+=======================
+
+To use the debugger in its simplest form:
+
+ >>> import pdb
+ >>> pdb.run('<a statement>')
+
+The debugger's prompt is '(Pdb) '. This will stop in the first
+function call in <a statement>.
+
+Alternatively, if a statement terminated with an unhandled exception,
+you can use pdb's post-mortem facility to inspect the contents of the
+traceback:
+
+ >>> <a statement>
+ <exception traceback>
+ >>> import pdb
+ >>> pdb.pm()
+
+The commands recognized by the debugger are listed in the next
+section. Most can be abbreviated as indicated; e.g., h(elp) means
+that 'help' can be typed as 'h' or 'help' (but not as 'he' or 'hel',
+nor as 'H' or 'Help' or 'HELP'). Optional arguments are enclosed in
+square brackets. Alternatives in the command syntax are separated
+by a vertical bar (|).
+
+A blank line repeats the previous command literally, except for
+'list', where it lists the next 11 lines.
+
+Commands that the debugger doesn't recognize are assumed to be Python
+statements and are executed in the context of the program being
+debugged. Python statements can also be prefixed with an exclamation
+point ('!'). This is a powerful way to inspect the program being
+debugged; it is even possible to change variables or call functions.
+When an exception occurs in such a statement, the exception name is
+printed but the debugger's state is not changed.
+
+The debugger supports aliases, which can save typing. And aliases can
+have parameters (see the alias help entry) which allows one a certain
+level of adaptability to the context under examination.
+
+Multiple commands may be entered on a single line, separated by the
+pair ';;'. No intelligence is applied to separating the commands; the
+input is split at the first ';;', even if it is in the middle of a
+quoted string.
+
+If a file ".pdbrc" exists in your home directory or in the current
+directory, it is read in and executed as if it had been typed at the
+debugger prompt. This is particularly useful for aliases. If both
+files exist, the one in the home directory is read first and aliases
+defined there can be overriden by the local file.
+
+Aside from aliases, the debugger is not directly programmable; but it
+is implemented as a class from which you can derive your own debugger
+class, which you can make as fancy as you like.
-# (See pdb.doc for documentation.)
+Debugger commands
+=================
+
+"""
+# NOTE: the actual command documentation is collected from docstrings of the
+# commands and is appended to __doc__ after the class has been defined.
+
+import os
+import re
import sys
-import linecache
import cmd
import bdb
-from repr import Repr
-import os
-import re
+import dis
+import code
import pprint
+import signal
+import inspect
import traceback
+import linecache
class Restart(Exception):
"""Causes a debugger to be restarted for the debugged python program."""
pass
-# Create a custom safe Repr instance and increase its maxstring.
-# The default of 30 truncates error messages too easily.
-_repr = Repr()
-_repr.maxstring = 200
-_saferepr = _repr.repr
-
__all__ = ["run", "pm", "Pdb", "runeval", "runctx", "runcall", "set_trace",
"post_mortem", "help"]
@@ -37,17 +96,40 @@ def find_function(funcname, filename):
# consumer of this info expects the first line to be 1
lineno = 1
answer = None
- while 1:
+ while True:
line = fp.readline()
if line == '':
break
if cre.match(line):
answer = funcname, filename, lineno
break
- lineno = lineno + 1
+ lineno += 1
fp.close()
return answer
+def getsourcelines(obj):
+ lines, lineno = inspect.findsource(obj)
+ if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
+ # must be a module frame: do not try to cut a block out of it
+ return lines, 1
+ elif inspect.ismodule(obj):
+ return lines, 1
+ return inspect.getblock(lines[lineno:]), lineno+1
+
+def lasti2lineno(code, lasti):
+ linestarts = list(dis.findlinestarts(code))
+ linestarts.reverse()
+ for i, lineno in linestarts:
+ if lasti >= i:
+ return lineno
+ return 0
+
+
+class _rstr(str):
+ """String that doesn't quote its repr."""
+ def __repr__(self):
+ return self
+
# Interaction prompt line will separate file and call info from code
# text using value of line_prefix string. A newline and arrow may
@@ -58,41 +140,40 @@ line_prefix = '\n-> ' # Probably a better default
class Pdb(bdb.Bdb, cmd.Cmd):
- def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None):
+ def __init__(self, completekey='tab', stdin=None, stdout=None, skip=None,
+ nosigint=False):
bdb.Bdb.__init__(self, skip=skip)
cmd.Cmd.__init__(self, completekey, stdin, stdout)
if stdout:
self.use_rawinput = 0
self.prompt = '(Pdb) '
self.aliases = {}
+ self.displaying = {}
self.mainpyfile = ''
- self._wait_for_mainpyfile = 0
+ self._wait_for_mainpyfile = False
+ self.tb_lineno = {}
# Try to load readline if it exists
try:
import readline
except ImportError:
pass
+ self.allow_kbdint = False
+ self.nosigint = nosigint
# Read $HOME/.pdbrc and ./.pdbrc
self.rcLines = []
if 'HOME' in os.environ:
envHome = os.environ['HOME']
try:
- rcFile = open(os.path.join(envHome, ".pdbrc"))
+ with open(os.path.join(envHome, ".pdbrc")) as rcFile:
+ self.rcLines.extend(rcFile)
except IOError:
pass
- else:
- for line in rcFile.readlines():
- self.rcLines.append(line)
- rcFile.close()
try:
- rcFile = open(".pdbrc")
+ with open(".pdbrc") as rcFile:
+ self.rcLines.extend(rcFile)
except IOError:
pass
- else:
- for line in rcFile.readlines():
- self.rcLines.append(line)
- rcFile.close()
self.commands = {} # associates a command list to breakpoint numbers
self.commands_doprompt = {} # for each bp num, tells if the prompt
@@ -104,6 +185,15 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.commands_bnum = None # The breakpoint number for which we are
# defining a list
+ def sigint_handler(self, signum, frame):
+ if self.allow_kbdint:
+ raise KeyboardInterrupt
+ self.message("\nProgram interrupted. (Use 'cont' to resume).")
+ self.set_step()
+ self.set_trace(frame)
+ # restore previous signal handler
+ signal.signal(signal.SIGINT, self._previous_sigint_handler)
+
def reset(self):
bdb.Bdb.reset(self)
self.forget()
@@ -113,28 +203,43 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.stack = []
self.curindex = 0
self.curframe = None
+ self.tb_lineno.clear()
- def setup(self, f, t):
+ def setup(self, f, tb):
self.forget()
- self.stack, self.curindex = self.get_stack(f, t)
+ self.stack, self.curindex = self.get_stack(f, tb)
+ while tb:
+ # when setting up post-mortem debugging with a traceback, save all
+ # the original line numbers to be displayed along the current line
+ # numbers (which can be different, e.g. due to finally clauses)
+ lineno = lasti2lineno(tb.tb_frame.f_code, tb.tb_lasti)
+ self.tb_lineno[tb.tb_frame] = lineno
+ tb = tb.tb_next
self.curframe = self.stack[self.curindex][0]
# The f_locals dictionary is updated from the actual frame
# locals whenever the .f_locals accessor is called, so we
# cache it here to ensure that modifications are not overwritten.
self.curframe_locals = self.curframe.f_locals
- self.execRcLines()
+ return self.execRcLines()
# Can be executed earlier than 'setup' if desired
def execRcLines(self):
- if self.rcLines:
- # Make local copy because of recursion
- rcLines = self.rcLines
- # executed only once
- self.rcLines = []
- for line in rcLines:
- line = line[:-1]
- if len(line) > 0 and line[0] != '#':
- self.onecmd(line)
+ if not self.rcLines:
+ return
+ # local copy because of recursion
+ rcLines = self.rcLines
+ rcLines.reverse()
+ # execute every line only once
+ self.rcLines = []
+ while rcLines:
+ line = rcLines.pop().strip()
+ if line and line[0] != '#':
+ if self.onecmd(line):
+ # if onecmd returns True, the command wants to exit
+ # from the interaction, save leftover rc lines
+ # to execute before next interaction
+ self.rcLines += reversed(rcLines)
+ return True
# Override Bdb methods
@@ -144,20 +249,20 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if self._wait_for_mainpyfile:
return
if self.stop_here(frame):
- print >>self.stdout, '--Call--'
+ self.message('--Call--')
self.interaction(frame, None)
def user_line(self, frame):
"""This function is called when we stop or break at this line."""
if self._wait_for_mainpyfile:
if (self.mainpyfile != self.canonic(frame.f_code.co_filename)
- or frame.f_lineno<= 0):
+ or frame.f_lineno <= 0):
return
- self._wait_for_mainpyfile = 0
+ self._wait_for_mainpyfile = False
if self.bp_commands(frame):
self.interaction(frame, None)
- def bp_commands(self,frame):
+ def bp_commands(self, frame):
"""Call every command that was set for the current active breakpoint
(if there is one).
@@ -176,7 +281,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if not self.commands_silent[currentbp]:
self.print_stack_entry(self.stack[self.curindex])
if self.commands_doprompt[currentbp]:
- self.cmdloop()
+ self._cmdloop()
self.forget()
return
return 1
@@ -186,7 +291,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if self._wait_for_mainpyfile:
return
frame.f_locals['__return__'] = return_value
- print >>self.stdout, '--Return--'
+ self.message('--Return--')
self.interaction(frame, None)
def user_exception(self, frame, exc_info):
@@ -196,18 +301,45 @@ class Pdb(bdb.Bdb, cmd.Cmd):
return
exc_type, exc_value, exc_traceback = exc_info
frame.f_locals['__exception__'] = exc_type, exc_value
- if type(exc_type) == type(''):
- exc_type_name = exc_type
- else: exc_type_name = exc_type.__name__
- print >>self.stdout, exc_type_name + ':', _saferepr(exc_value)
+ self.message(traceback.format_exception_only(exc_type,
+ exc_value)[-1].strip())
self.interaction(frame, exc_traceback)
# General interaction function
+ def _cmdloop(self):
+ while True:
+ try:
+ # keyboard interrupts allow for an easy way to cancel
+ # the current command, so allow them during interactive input
+ self.allow_kbdint = True
+ self.cmdloop()
+ self.allow_kbdint = False
+ break
+ except KeyboardInterrupt:
+ self.message('--KeyboardInterrupt--')
+
+ # Called before loop, handles display expressions
+ def preloop(self):
+ displaying = self.displaying.get(self.curframe)
+ if displaying:
+ for expr, oldvalue in displaying.items():
+ newvalue = self._getval_except(expr)
+ # check for identity first; this prevents custom __eq__ to
+ # be called at every loop, and also prevents instances whose
+ # fields are changed to be displayed
+ if newvalue is not oldvalue and newvalue != oldvalue:
+ displaying[expr] = newvalue
+ self.message('display %s: %r [old: %r]' %
+ (expr, newvalue, oldvalue))
def interaction(self, frame, traceback):
- self.setup(frame, traceback)
+ if self.setup(frame, traceback):
+ # no interaction desired at this time (happens if .pdbrc contains
+ # a command like "continue")
+ self.forget()
+ return
self.print_stack_entry(self.stack[self.curindex])
- self.cmdloop()
+ self._cmdloop()
self.forget()
def displayhook(self, obj):
@@ -216,7 +348,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
"""
# reproduce the behavior of the standard displayhook, not printing None
if obj is not None:
- print repr(obj)
+ self.message(repr(obj))
def default(self, line):
if line[:1] == '!': line = line[1:]
@@ -231,17 +363,14 @@ class Pdb(bdb.Bdb, cmd.Cmd):
sys.stdin = self.stdin
sys.stdout = self.stdout
sys.displayhook = self.displayhook
- exec code in globals, locals
+ exec(code, globals, locals)
finally:
sys.stdout = save_stdout
sys.stdin = save_stdin
sys.displayhook = save_displayhook
except:
- t, v = sys.exc_info()[:2]
- if type(t) == type(''):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print >>self.stdout, '***', exc_type_name + ':', v
+ exc_info = sys.exc_info()[:2]
+ self.error(traceback.format_exception_only(*exc_info)[-1].strip())
def precmd(self, line):
"""Handle alias expansion and ';;' separator."""
@@ -254,7 +383,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
for tmpArg in args[1:]:
line = line.replace("%" + str(ii),
tmpArg)
- ii = ii + 1
+ ii += 1
line = line.replace("%*", ' '.join(args[1:]))
args = line.split()
# split into ';;' separated commands
@@ -280,7 +409,7 @@ class Pdb(bdb.Bdb, cmd.Cmd):
else:
return self.handle_command_def(line)
- def handle_command_def(self,line):
+ def handle_command_def(self, line):
"""Handles one command line during command list definition."""
cmd, arg, line = self.parseline(line)
if not cmd:
@@ -302,53 +431,122 @@ class Pdb(bdb.Bdb, cmd.Cmd):
except AttributeError:
func = self.default
# one of the resuming commands
- if func.func_name in self.commands_resuming:
+ if func.__name__ in self.commands_resuming:
self.commands_doprompt[self.commands_bnum] = False
self.cmdqueue = []
return 1
return
+ # interface abstraction functions
+
+ def message(self, msg):
+ print(msg, file=self.stdout)
+
+ def error(self, msg):
+ print('***', msg, file=self.stdout)
+
# Command definitions, called by cmdloop()
# The argument is the remaining string on the command line
# Return true to exit from the command loop
- do_h = cmd.Cmd.do_help
-
def do_commands(self, arg):
- """Defines a list of commands associated to a breakpoint.
-
- Those commands will be executed whenever the breakpoint causes
- the program to stop execution."""
+ """commands [bpnumber]
+ (com) ...
+ (com) end
+ (Pdb)
+
+ Specify a list of commands for breakpoint number bpnumber.
+ The commands themselves are entered on the following lines.
+ Type a line containing just 'end' to terminate the commands.
+ The commands are executed when the breakpoint is hit.
+
+ To remove all commands from a breakpoint, type commands and
+ follow it immediately with end; that is, give no commands.
+
+ With no bpnumber argument, commands refers to the last
+ breakpoint set.
+
+ You can use breakpoint commands to start your program up
+ again. Simply use the continue command, or step, or any other
+ command that resumes execution.
+
+ Specifying any command resuming execution (currently continue,
+ step, next, return, jump, quit and their abbreviations)
+ terminates the command list (as if that command was
+ immediately followed by end). This is because any time you
+ resume execution (even with a simple next or step), you may
+ encounter another breakpoint -- which could have its own
+ command list, leading to ambiguities about which list to
+ execute.
+
+ If you use the 'silent' command in the command list, the usual
+ message about stopping at a breakpoint is not printed. This
+ may be desirable for breakpoints that are to print a specific
+ message and then continue. If none of the other commands
+ print anything, you will see no sign that the breakpoint was
+ reached.
+ """
if not arg:
- bnum = len(bdb.Breakpoint.bpbynumber)-1
+ bnum = len(bdb.Breakpoint.bpbynumber) - 1
else:
try:
bnum = int(arg)
except:
- print >>self.stdout, "Usage : commands [bnum]\n ..." \
- "\n end"
+ self.error("Usage: commands [bnum]\n ...\n end")
return
self.commands_bnum = bnum
+ # Save old definitions for the case of a keyboard interrupt.
+ if bnum in self.commands:
+ old_command_defs = (self.commands[bnum],
+ self.commands_doprompt[bnum],
+ self.commands_silent[bnum])
+ else:
+ old_command_defs = None
self.commands[bnum] = []
self.commands_doprompt[bnum] = True
self.commands_silent[bnum] = False
+
prompt_back = self.prompt
self.prompt = '(com) '
self.commands_defining = True
try:
self.cmdloop()
+ except KeyboardInterrupt:
+ # Restore old definitions.
+ if old_command_defs:
+ self.commands[bnum] = old_command_defs[0]
+ self.commands_doprompt[bnum] = old_command_defs[1]
+ self.commands_silent[bnum] = old_command_defs[2]
+ else:
+ del self.commands[bnum]
+ del self.commands_doprompt[bnum]
+ del self.commands_silent[bnum]
+ self.error('command definition aborted, old commands restored')
finally:
self.commands_defining = False
self.prompt = prompt_back
def do_break(self, arg, temporary = 0):
- # break [ ([filename:]lineno | function) [, "condition"] ]
+ """b(reak) [ ([filename:]lineno | function) [, condition] ]
+ Without argument, list all breaks.
+
+ With a line number argument, set a break at this line in the
+ current file. With a function name, set a break at the first
+ executable line of that function. If a second argument is
+ present, it is a string specifying an expression which must
+ evaluate to true before the breakpoint is honored.
+
+ The line number may be prefixed with a filename and a colon,
+ to specify a breakpoint in another file (probably one that
+ hasn't been loaded yet). The file is searched for on
+ sys.path; the .py suffix may be omitted.
+ """
if not arg:
if self.breaks: # There's at least one
- print >>self.stdout, "Num Type Disp Enb Where"
+ self.message("Num Type Disp Enb Where")
for bp in bdb.Breakpoint.bpbynumber:
if bp:
- bp.bpprint(self.stdout)
+ self.message(bp.bpformat())
return
# parse arguments; comma has lowest precedence
# and cannot occur in filename
@@ -367,16 +565,15 @@ class Pdb(bdb.Bdb, cmd.Cmd):
filename = arg[:colon].rstrip()
f = self.lookupmodule(filename)
if not f:
- print >>self.stdout, '*** ', repr(filename),
- print >>self.stdout, 'not found from sys.path'
+ self.error('%r not found from sys.path' % filename)
return
else:
filename = f
arg = arg[colon+1:].lstrip()
try:
lineno = int(arg)
- except ValueError, msg:
- print >>self.stdout, '*** Bad lineno:', arg
+ except ValueError:
+ self.error('Bad lineno: %s' % arg)
return
else:
# no colon; can be lineno or function
@@ -390,9 +587,9 @@ class Pdb(bdb.Bdb, cmd.Cmd):
except:
func = arg
try:
- if hasattr(func, 'im_func'):
- func = func.im_func
- code = func.func_code
+ if hasattr(func, '__func__'):
+ func = func.__func__
+ code = func.__code__
#use co_name to identify the bkpt (function names
#could be aliased, but co_name is invariant)
funcname = code.co_name
@@ -402,10 +599,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
# last thing to try
(ok, filename, ln) = self.lineinfo(arg)
if not ok:
- print >>self.stdout, '*** The specified object',
- print >>self.stdout, repr(arg),
- print >>self.stdout, 'is not a function'
- print >>self.stdout, 'or was not found along sys.path.'
+ self.error('The specified object %r is not a function '
+ 'or was not found along sys.path.' % arg)
return
funcname = ok # ok contains a function name
lineno = int(ln)
@@ -416,12 +611,12 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if line:
# now set the break point
err = self.set_break(filename, line, temporary, cond, funcname)
- if err: print >>self.stdout, '***', err
+ if err:
+ self.error(err, file=self.stdout)
else:
bp = self.get_breaks(filename, line)[-1]
- print >>self.stdout, "Breakpoint %d at %s:%d" % (bp.number,
- bp.file,
- bp.line)
+ self.message("Breakpoint %d at %s:%d" %
+ (bp.number, bp.file, bp.line))
# To be overridden in derived debuggers
def defaultFile(self):
@@ -434,6 +629,10 @@ class Pdb(bdb.Bdb, cmd.Cmd):
do_b = do_break
def do_tbreak(self, arg):
+ """tbreak [ ([filename:]lineno | function) [, condition] ]
+ Same arguments as break, but sets a temporary breakpoint: it
+ is automatically deleted when first hit.
+ """
self.do_break(arg, 1)
def lineinfo(self, identifier):
@@ -480,120 +679,121 @@ class Pdb(bdb.Bdb, cmd.Cmd):
globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
line = linecache.getline(filename, lineno, globs)
if not line:
- print >>self.stdout, 'End of file'
+ self.message('End of file')
return 0
line = line.strip()
# Don't allow setting breakpoint at a blank line
if (not line or (line[0] == '#') or
(line[:3] == '"""') or line[:3] == "'''"):
- print >>self.stdout, '*** Blank or comment'
+ self.error('Blank or comment')
return 0
return lineno
def do_enable(self, arg):
+ """enable bpnumber [bpnumber ...]
+ Enables the breakpoints given as a space separated list of
+ breakpoint numbers.
+ """
args = arg.split()
for i in args:
try:
- i = int(i)
- except ValueError:
- print >>self.stdout, 'Breakpoint index %r is not a number' % i
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print >>self.stdout, 'No breakpoint numbered', i
- continue
-
- bp = bdb.Breakpoint.bpbynumber[i]
- if bp:
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
+ else:
bp.enable()
+ self.message('Enabled %s' % bp)
def do_disable(self, arg):
+ """disable bpnumber [bpnumber ...]
+ Disables the breakpoints given as a space separated list of
+ breakpoint numbers. Disabling a breakpoint means it cannot
+ cause the program to stop execution, but unlike clearing a
+ breakpoint, it remains in the list of breakpoints and can be
+ (re-)enabled.
+ """
args = arg.split()
for i in args:
try:
- i = int(i)
- except ValueError:
- print >>self.stdout, 'Breakpoint index %r is not a number' % i
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print >>self.stdout, 'No breakpoint numbered', i
- continue
-
- bp = bdb.Breakpoint.bpbynumber[i]
- if bp:
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
+ else:
bp.disable()
+ self.message('Disabled %s' % bp)
def do_condition(self, arg):
- # arg is breakpoint number and condition
+ """condition bpnumber [condition]
+ Set a new condition for the breakpoint, an expression which
+ must evaluate to true before the breakpoint is honored. If
+ condition is absent, any existing condition is removed; i.e.,
+ the breakpoint is made unconditional.
+ """
args = arg.split(' ', 1)
try:
- bpnum = int(args[0].strip())
- except ValueError:
- # something went wrong
- print >>self.stdout, \
- 'Breakpoint index %r is not a number' % args[0]
- return
- try:
cond = args[1]
- except:
+ except IndexError:
cond = None
try:
- bp = bdb.Breakpoint.bpbynumber[bpnum]
- except IndexError:
- print >>self.stdout, 'Breakpoint index %r is not valid' % args[0]
- return
- if bp:
+ bp = self.get_bpbynumber(args[0].strip())
+ except ValueError as err:
+ self.error(err)
+ else:
bp.cond = cond
if not cond:
- print >>self.stdout, 'Breakpoint', bpnum,
- print >>self.stdout, 'is now unconditional.'
-
- def do_ignore(self,arg):
- """arg is bp number followed by ignore count."""
+ self.message('Breakpoint %d is now unconditional.' % bp.number)
+ else:
+ self.message('New condition set for breakpoint %d.' % bp.number)
+
+ def do_ignore(self, arg):
+ """ignore bpnumber [count]
+ Set the ignore count for the given breakpoint number. If
+ count is omitted, the ignore count is set to 0. A breakpoint
+ becomes active when the ignore count is zero. When non-zero,
+ the count is decremented each time the breakpoint is reached
+ and the breakpoint is not disabled and any associated
+ condition evaluates to true.
+ """
args = arg.split()
try:
- bpnum = int(args[0].strip())
- except ValueError:
- # something went wrong
- print >>self.stdout, \
- 'Breakpoint index %r is not a number' % args[0]
- return
- try:
count = int(args[1].strip())
except:
count = 0
try:
- bp = bdb.Breakpoint.bpbynumber[bpnum]
- except IndexError:
- print >>self.stdout, 'Breakpoint index %r is not valid' % args[0]
- return
- if bp:
+ bp = self.get_bpbynumber(args[0].strip())
+ except ValueError as err:
+ self.error(err)
+ else:
bp.ignore = count
if count > 0:
- reply = 'Will ignore next '
if count > 1:
- reply = reply + '%d crossings' % count
+ countstr = '%d crossings' % count
else:
- reply = reply + '1 crossing'
- print >>self.stdout, reply + ' of breakpoint %d.' % bpnum
+ countstr = '1 crossing'
+ self.message('Will ignore next %s of breakpoint %d.' %
+ (countstr, bp.number))
else:
- print >>self.stdout, 'Will stop next time breakpoint',
- print >>self.stdout, bpnum, 'is reached.'
+ self.message('Will stop next time breakpoint %d is reached.'
+ % bp.number)
def do_clear(self, arg):
- """Three possibilities, tried in this order:
- clear -> clear all breaks, ask for confirmation
- clear file:lineno -> clear all breaks at file:lineno
- clear bpno bpno ... -> clear breakpoints by number"""
+ """cl(ear) filename:lineno\ncl(ear) [bpnumber [bpnumber...]]
+ With a space separated list of breakpoint numbers, clear
+ those breakpoints. Without argument, clear all breaks (but
+ first ask confirmation). With a filename:lineno argument,
+ clear all breaks at that line in that file.
+ """
if not arg:
try:
- reply = raw_input('Clear all breaks? ')
+ reply = input('Clear all breaks? ')
except EOFError:
reply = 'no'
reply = reply.strip().lower()
if reply in ('y', 'yes'):
+ bplist = [bp for bp in bdb.Breakpoint.bpbynumber if bp]
self.clear_all_breaks()
+ for bp in bplist:
+ self.message('Deleted %s' % bp)
return
if ':' in arg:
# Make sure it works for "clear C:\foo\bar.py:12"
@@ -605,99 +805,187 @@ class Pdb(bdb.Bdb, cmd.Cmd):
except ValueError:
err = "Invalid line number (%s)" % arg
else:
+ bplist = self.get_breaks(filename, lineno)
err = self.clear_break(filename, lineno)
- if err: print >>self.stdout, '***', err
+ if err:
+ self.error(err)
+ else:
+ for bp in bplist:
+ self.message('Deleted %s' % bp)
return
numberlist = arg.split()
for i in numberlist:
try:
- i = int(i)
- except ValueError:
- print >>self.stdout, 'Breakpoint index %r is not a number' % i
- continue
-
- if not (0 <= i < len(bdb.Breakpoint.bpbynumber)):
- print >>self.stdout, 'No breakpoint numbered', i
- continue
- err = self.clear_bpbynumber(i)
- if err:
- print >>self.stdout, '***', err
+ bp = self.get_bpbynumber(i)
+ except ValueError as err:
+ self.error(err)
else:
- print >>self.stdout, 'Deleted breakpoint', i
+ self.clear_bpbynumber(i)
+ self.message('Deleted %s' % bp)
do_cl = do_clear # 'c' is already an abbreviation for 'continue'
def do_where(self, arg):
+ """w(here)
+ Print a stack trace, with the most recent frame at the bottom.
+ An arrow indicates the "current frame", which determines the
+ context of most commands. 'bt' is an alias for this command.
+ """
self.print_stack_trace()
do_w = do_where
do_bt = do_where
+ def _select_frame(self, number):
+ assert 0 <= number < len(self.stack)
+ self.curindex = number
+ self.curframe = self.stack[self.curindex][0]
+ self.curframe_locals = self.curframe.f_locals
+ self.print_stack_entry(self.stack[self.curindex])
+ self.lineno = None
+
def do_up(self, arg):
+ """u(p) [count]
+ Move the current frame count (default one) levels up in the
+ stack trace (to an older frame).
+ """
if self.curindex == 0:
- print >>self.stdout, '*** Oldest frame'
+ self.error('Oldest frame')
+ return
+ try:
+ count = int(arg or 1)
+ except ValueError:
+ self.error('Invalid frame count (%s)' % arg)
+ return
+ if count < 0:
+ newframe = 0
else:
- self.curindex = self.curindex - 1
- self.curframe = self.stack[self.curindex][0]
- self.curframe_locals = self.curframe.f_locals
- self.print_stack_entry(self.stack[self.curindex])
- self.lineno = None
+ newframe = max(0, self.curindex - count)
+ self._select_frame(newframe)
do_u = do_up
def do_down(self, arg):
+ """d(own) [count]
+ Move the current frame count (default one) levels down in the
+ stack trace (to a newer frame).
+ """
if self.curindex + 1 == len(self.stack):
- print >>self.stdout, '*** Newest frame'
+ self.error('Newest frame')
+ return
+ try:
+ count = int(arg or 1)
+ except ValueError:
+ self.error('Invalid frame count (%s)' % arg)
+ return
+ if count < 0:
+ newframe = len(self.stack) - 1
else:
- self.curindex = self.curindex + 1
- self.curframe = self.stack[self.curindex][0]
- self.curframe_locals = self.curframe.f_locals
- self.print_stack_entry(self.stack[self.curindex])
- self.lineno = None
+ newframe = min(len(self.stack) - 1, self.curindex + count)
+ self._select_frame(newframe)
do_d = do_down
def do_until(self, arg):
- self.set_until(self.curframe)
+ """unt(il) [lineno]
+ Without argument, continue execution until the line with a
+ number greater than the current one is reached. With a line
+ number, continue execution until a line with a number greater
+ or equal to that is reached. In both cases, also stop when
+ the current frame returns.
+ """
+ if arg:
+ try:
+ lineno = int(arg)
+ except ValueError:
+ self.error('Error in argument: %r' % arg)
+ return
+ if lineno <= self.curframe.f_lineno:
+ self.error('"until" line number is smaller than current '
+ 'line number')
+ return
+ else:
+ lineno = None
+ self.set_until(self.curframe, lineno)
return 1
do_unt = do_until
def do_step(self, arg):
+ """s(tep)
+ Execute the current line, stop at the first possible occasion
+ (either in a function that is called or in the current
+ function).
+ """
self.set_step()
return 1
do_s = do_step
def do_next(self, arg):
+ """n(ext)
+ Continue execution until the next line in the current function
+ is reached or it returns.
+ """
self.set_next(self.curframe)
return 1
do_n = do_next
def do_run(self, arg):
- """Restart program by raising an exception to be caught in the main
- debugger loop. If arguments were given, set them in sys.argv."""
+ """run [args...]
+ Restart the debugged python program. If a string is supplied
+ it is splitted with "shlex", and the result is used as the new
+ sys.argv. History, breakpoints, actions and debugger options
+ are preserved. "restart" is an alias for "run".
+ """
if arg:
import shlex
argv0 = sys.argv[0:1]
sys.argv = shlex.split(arg)
sys.argv[:0] = argv0
+ # this is caught in the main debugger loop
raise Restart
do_restart = do_run
def do_return(self, arg):
+ """r(eturn)
+ Continue execution until the current function returns.
+ """
self.set_return(self.curframe)
return 1
do_r = do_return
def do_continue(self, arg):
+ """c(ont(inue))
+ Continue execution, only stop when a breakpoint is encountered.
+ """
+ if not self.nosigint:
+ try:
+ self._previous_sigint_handler = \
+ signal.signal(signal.SIGINT, self.sigint_handler)
+ except ValueError:
+ # ValueError happens when do_continue() is invoked from
+ # a non-main thread in which case we just continue without
+ # SIGINT set. Would printing a message here (once) make
+ # sense?
+ pass
self.set_continue()
return 1
do_c = do_cont = do_continue
def do_jump(self, arg):
+ """j(ump) lineno
+ Set the next line that will be executed. Only available in
+ the bottom-most frame. This lets you jump back and execute
+ code again, or jump forward to skip code that you don't want
+ to run.
+
+ It should be noted that not all jumps are allowed -- for
+ instance it is not possible to jump into the middle of a
+ for loop or out of a finally clause.
+ """
if self.curindex + 1 != len(self.stack):
- print >>self.stdout, "*** You can only jump within the bottom frame"
+ self.error('You can only jump within the bottom frame')
return
try:
arg = int(arg)
except ValueError:
- print >>self.stdout, "*** The 'jump' command requires a line number."
+ self.error("The 'jump' command requires a line number")
else:
try:
# Do the jump, fix up our copy of the stack, and display the
@@ -705,24 +993,32 @@ class Pdb(bdb.Bdb, cmd.Cmd):
self.curframe.f_lineno = arg
self.stack[self.curindex] = self.stack[self.curindex][0], arg
self.print_stack_entry(self.stack[self.curindex])
- except ValueError, e:
- print >>self.stdout, '*** Jump failed:', e
+ except ValueError as e:
+ self.error('Jump failed: %s' % e)
do_j = do_jump
def do_debug(self, arg):
+ """debug code
+ Enter a recursive debugger that steps through the code
+ argument (which is an arbitrary expression or statement to be
+ executed in the current environment).
+ """
sys.settrace(None)
globals = self.curframe.f_globals
locals = self.curframe_locals
p = Pdb(self.completekey, self.stdin, self.stdout)
p.prompt = "(%s) " % self.prompt.strip()
- print >>self.stdout, "ENTERING RECURSIVE DEBUGGER"
+ self.message("ENTERING RECURSIVE DEBUGGER")
sys.call_tracing(p.run, (arg, globals, locals))
- print >>self.stdout, "LEAVING RECURSIVE DEBUGGER"
+ self.message("LEAVING RECURSIVE DEBUGGER")
sys.settrace(self.trace_dispatch)
self.lastcmd = p.lastcmd
def do_quit(self, arg):
- self._user_requested_quit = 1
+ """q(uit)\nexit
+ Quit from the debugger. The program being executed is aborted.
+ """
+ self._user_requested_quit = True
self.set_quit()
return 1
@@ -730,12 +1026,18 @@ class Pdb(bdb.Bdb, cmd.Cmd):
do_exit = do_quit
def do_EOF(self, arg):
- print >>self.stdout
- self._user_requested_quit = 1
+ """EOF
+ Handles the receipt of EOF as a command.
+ """
+ self.message('')
+ self._user_requested_quit = True
self.set_quit()
return 1
def do_args(self, arg):
+ """a(rgs)
+ Print the argument list of the current function.
+ """
co = self.curframe.f_code
dict = self.curframe_locals
n = co.co_argcount
@@ -743,61 +1045,94 @@ class Pdb(bdb.Bdb, cmd.Cmd):
if co.co_flags & 8: n = n+1
for i in range(n):
name = co.co_varnames[i]
- print >>self.stdout, name, '=',
- if name in dict: print >>self.stdout, dict[name]
- else: print >>self.stdout, "*** undefined ***"
+ if name in dict:
+ self.message('%s = %r' % (name, dict[name]))
+ else:
+ self.message('%s = *** undefined ***' % (name,))
do_a = do_args
def do_retval(self, arg):
+ """retval
+ Print the return value for the last return of a function.
+ """
if '__return__' in self.curframe_locals:
- print >>self.stdout, self.curframe_locals['__return__']
+ self.message(repr(self.curframe_locals['__return__']))
else:
- print >>self.stdout, '*** Not yet returned!'
+ self.error('Not yet returned!')
do_rv = do_retval
def _getval(self, arg):
try:
- return eval(arg, self.curframe.f_globals,
- self.curframe_locals)
+ return eval(arg, self.curframe.f_globals, self.curframe_locals)
except:
- t, v = sys.exc_info()[:2]
- if isinstance(t, str):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print >>self.stdout, '***', exc_type_name + ':', repr(v)
+ exc_info = sys.exc_info()[:2]
+ self.error(traceback.format_exception_only(*exc_info)[-1].strip())
raise
+ def _getval_except(self, arg, frame=None):
+ try:
+ if frame is None:
+ return eval(arg, self.curframe.f_globals, self.curframe_locals)
+ else:
+ return eval(arg, frame.f_globals, frame.f_locals)
+ except:
+ exc_info = sys.exc_info()[:2]
+ err = traceback.format_exception_only(*exc_info)[-1].strip()
+ return _rstr('** raised %s **' % err)
+
def do_p(self, arg):
+ """p(rint) expression
+ Print the value of the expression.
+ """
try:
- print >>self.stdout, repr(self._getval(arg))
+ self.message(repr(self._getval(arg)))
except:
pass
+ # make "print" an alias of "p" since print isn't a Python statement anymore
+ do_print = do_p
def do_pp(self, arg):
+ """pp expression
+ Pretty-print the value of the expression.
+ """
try:
- pprint.pprint(self._getval(arg), self.stdout)
+ self.message(pprint.pformat(self._getval(arg)))
except:
pass
def do_list(self, arg):
+ """l(ist) [first [,last] | .]
+
+ List source code for the current file. Without arguments,
+ list 11 lines around the current line or continue the previous
+ listing. With . as argument, list 11 lines around the current
+ line. With one argument, list 11 lines starting at that line.
+ With two arguments, list the given range; if the second
+ argument is less than the first, it is a count.
+
+ The current line in the current frame is indicated by "->".
+ If an exception is being debugged, the line where the
+ exception was originally raised or propagated is indicated by
+ ">>", if it differs from the current line.
+ """
self.lastcmd = 'list'
last = None
- if arg:
+ if arg and arg != '.':
try:
- x = eval(arg, {}, {})
- if type(x) == type(()):
- first, last = x
- first = int(first)
- last = int(last)
+ if ',' in arg:
+ first, last = arg.split(',')
+ first = int(first.strip())
+ last = int(last.strip())
if last < first:
- # Assume it's a count
+ # assume it's a count
last = first + last
else:
- first = max(1, int(x) - 5)
- except:
- print >>self.stdout, '*** Error in argument:', repr(arg)
+ first = int(arg.strip())
+ first = max(1, first - 5)
+ except ValueError:
+ self.error('Error in argument: %r' % arg)
return
- elif self.lineno is None:
+ elif self.lineno is None or arg == '.':
first = max(1, self.curframe.f_lineno - 5)
else:
first = self.lineno + 1
@@ -806,72 +1141,186 @@ class Pdb(bdb.Bdb, cmd.Cmd):
filename = self.curframe.f_code.co_filename
breaklist = self.get_file_breaks(filename)
try:
- for lineno in range(first, last+1):
- line = linecache.getline(filename, lineno,
- self.curframe.f_globals)
- if not line:
- print >>self.stdout, '[EOF]'
- break
- else:
- s = repr(lineno).rjust(3)
- if len(s) < 4: s = s + ' '
- if lineno in breaklist: s = s + 'B'
- else: s = s + ' '
- if lineno == self.curframe.f_lineno:
- s = s + '->'
- print >>self.stdout, s + '\t' + line,
- self.lineno = lineno
+ lines = linecache.getlines(filename, self.curframe.f_globals)
+ self._print_lines(lines[first-1:last], first, breaklist,
+ self.curframe)
+ self.lineno = min(last, len(lines))
+ if len(lines) < last:
+ self.message('[EOF]')
except KeyboardInterrupt:
pass
do_l = do_list
+ def do_longlist(self, arg):
+ """longlist | ll
+ List the whole source code for the current function or frame.
+ """
+ filename = self.curframe.f_code.co_filename
+ breaklist = self.get_file_breaks(filename)
+ try:
+ lines, lineno = getsourcelines(self.curframe)
+ except IOError as err:
+ self.error(err)
+ return
+ self._print_lines(lines, lineno, breaklist, self.curframe)
+ do_ll = do_longlist
+
+ def do_source(self, arg):
+ """source expression
+ Try to get source code for the given object and display it.
+ """
+ try:
+ obj = self._getval(arg)
+ except:
+ return
+ try:
+ lines, lineno = getsourcelines(obj)
+ except (IOError, TypeError) as err:
+ self.error(err)
+ return
+ self._print_lines(lines, lineno)
+
+ def _print_lines(self, lines, start, breaks=(), frame=None):
+ """Print a range of lines."""
+ if frame:
+ current_lineno = frame.f_lineno
+ exc_lineno = self.tb_lineno.get(frame, -1)
+ else:
+ current_lineno = exc_lineno = -1
+ for lineno, line in enumerate(lines, start):
+ s = str(lineno).rjust(3)
+ if len(s) < 4:
+ s += ' '
+ if lineno in breaks:
+ s += 'B'
+ else:
+ s += ' '
+ if lineno == current_lineno:
+ s += '->'
+ elif lineno == exc_lineno:
+ s += '>>'
+ self.message(s + '\t' + line.rstrip())
+
def do_whatis(self, arg):
+ """whatis arg
+ Print the type of the argument.
+ """
try:
- value = eval(arg, self.curframe.f_globals,
- self.curframe_locals)
+ value = self._getval(arg)
except:
- t, v = sys.exc_info()[:2]
- if type(t) == type(''):
- exc_type_name = t
- else: exc_type_name = t.__name__
- print >>self.stdout, '***', exc_type_name + ':', repr(v)
+ # _getval() already printed the error
return
code = None
# Is it a function?
- try: code = value.func_code
- except: pass
+ try:
+ code = value.__code__
+ except Exception:
+ pass
if code:
- print >>self.stdout, 'Function', code.co_name
+ self.message('Function %s' % code.co_name)
return
# Is it an instance method?
- try: code = value.im_func.func_code
- except: pass
+ try:
+ code = value.__func__.__code__
+ except Exception:
+ pass
if code:
- print >>self.stdout, 'Method', code.co_name
+ self.message('Method %s' % code.co_name)
+ return
+ # Is it a class?
+ if value.__class__ is type:
+ self.message('Class %s.%s' % (value.__module__, value.__name__))
return
# None of the above...
- print >>self.stdout, type(value)
+ self.message(type(value))
+
+ def do_display(self, arg):
+ """display [expression]
+
+ Display the value of the expression if it changed, each time execution
+ stops in the current frame.
+
+ Without expression, list all display expressions for the current frame.
+ """
+ if not arg:
+ self.message('Currently displaying:')
+ for item in self.displaying.get(self.curframe, {}).items():
+ self.message('%s: %r' % item)
+ else:
+ val = self._getval_except(arg)
+ self.displaying.setdefault(self.curframe, {})[arg] = val
+ self.message('display %s: %r' % (arg, val))
+
+ def do_undisplay(self, arg):
+ """undisplay [expression]
+
+ Do not display the expression any more in the current frame.
+
+ Without expression, clear all display expressions for the current frame.
+ """
+ if arg:
+ try:
+ del self.displaying.get(self.curframe, {})[arg]
+ except KeyError:
+ self.error('not displaying %s' % arg)
+ else:
+ self.displaying.pop(self.curframe, None)
+
+ def do_interact(self, arg):
+ """interact
+
+ Start an interative interpreter whose global namespace
+ contains all the (global and local) names found in the current scope.
+ """
+ ns = self.curframe.f_globals.copy()
+ ns.update(self.curframe_locals)
+ code.interact("*interactive*", local=ns)
def do_alias(self, arg):
+ """alias [name [command [parameter parameter ...] ]]
+ Create an alias called 'name' that executes 'command'. The
+ command must *not* be enclosed in quotes. Replaceable
+ parameters can be indicated by %1, %2, and so on, while %* is
+ replaced by all the parameters. If no command is given, the
+ current alias for name is shown. If no name is given, all
+ aliases are listed.
+
+ Aliases may be nested and can contain anything that can be
+ legally typed at the pdb prompt. Note! You *can* override
+ internal pdb commands with aliases! Those internal commands
+ are then hidden until the alias is removed. Aliasing is
+ recursively applied to the first word of the command line; all
+ other words in the line are left alone.
+
+ As an example, here are two useful aliases (especially when
+ placed in the .pdbrc file):
+
+ # Print instance variables (usage "pi classInst")
+ alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
+ # Print instance variables in self
+ alias ps pi self
+ """
args = arg.split()
if len(args) == 0:
- keys = self.aliases.keys()
- keys.sort()
+ keys = sorted(self.aliases.keys())
for alias in keys:
- print >>self.stdout, "%s = %s" % (alias, self.aliases[alias])
+ self.message("%s = %s" % (alias, self.aliases[alias]))
return
if args[0] in self.aliases and len(args) == 1:
- print >>self.stdout, "%s = %s" % (args[0], self.aliases[args[0]])
+ self.message("%s = %s" % (args[0], self.aliases[args[0]]))
else:
self.aliases[args[0]] = ' '.join(args[1:])
def do_unalias(self, arg):
+ """unalias name
+ Delete the specified alias.
+ """
args = arg.split()
if len(args) == 0: return
if args[0] in self.aliases:
del self.aliases[args[0]]
- #list of all the commands making the program resume execution.
+ # List of all the commands making the program resume execution.
commands_resuming = ['do_continue', 'do_step', 'do_next', 'do_return',
'do_quit', 'do_jump']
@@ -893,297 +1342,57 @@ class Pdb(bdb.Bdb, cmd.Cmd):
def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
frame, lineno = frame_lineno
if frame is self.curframe:
- print >>self.stdout, '>',
+ prefix = '> '
else:
- print >>self.stdout, ' ',
- print >>self.stdout, self.format_stack_entry(frame_lineno,
- prompt_prefix)
-
-
- # Help methods (derived from pdb.doc)
-
- def help_help(self):
- self.help_h()
-
- def help_h(self):
- print >>self.stdout, """h(elp)
-Without argument, print the list of available commands.
-With a command name as argument, print help about that command
-"help pdb" pipes the full documentation file to the $PAGER
-"help exec" gives help on the ! command"""
-
- def help_where(self):
- self.help_w()
-
- def help_w(self):
- print >>self.stdout, """w(here)
-Print a stack trace, with the most recent frame at the bottom.
-An arrow indicates the "current frame", which determines the
-context of most commands. 'bt' is an alias for this command."""
-
- help_bt = help_w
-
- def help_down(self):
- self.help_d()
-
- def help_d(self):
- print >>self.stdout, """d(own)
-Move the current frame one level down in the stack trace
-(to a newer frame)."""
-
- def help_up(self):
- self.help_u()
-
- def help_u(self):
- print >>self.stdout, """u(p)
-Move the current frame one level up in the stack trace
-(to an older frame)."""
-
- def help_break(self):
- self.help_b()
-
- def help_b(self):
- print >>self.stdout, """b(reak) ([file:]lineno | function) [, condition]
-With a line number argument, set a break there in the current
-file. With a function name, set a break at first executable line
-of that function. Without argument, list all breaks. If a second
-argument is present, it is a string specifying an expression
-which must evaluate to true before the breakpoint is honored.
-
-The line number may be prefixed with a filename and a colon,
-to specify a breakpoint in another file (probably one that
-hasn't been loaded yet). The file is searched for on sys.path;
-the .py suffix may be omitted."""
-
- def help_clear(self):
- self.help_cl()
-
- def help_cl(self):
- print >>self.stdout, "cl(ear) filename:lineno"
- print >>self.stdout, """cl(ear) [bpnumber [bpnumber...]]
-With a space separated list of breakpoint numbers, clear
-those breakpoints. Without argument, clear all breaks (but
-first ask confirmation). With a filename:lineno argument,
-clear all breaks at that line in that file.
-
-Note that the argument is different from previous versions of
-the debugger (in python distributions 1.5.1 and before) where
-a linenumber was used instead of either filename:lineno or
-breakpoint numbers."""
-
- def help_tbreak(self):
- print >>self.stdout, """tbreak same arguments as break, but breakpoint
-is removed when first hit."""
-
- def help_enable(self):
- print >>self.stdout, """enable bpnumber [bpnumber ...]
-Enables the breakpoints given as a space separated list of
-bp numbers."""
-
- def help_disable(self):
- print >>self.stdout, """disable bpnumber [bpnumber ...]
-Disables the breakpoints given as a space separated list of
-bp numbers."""
-
- def help_ignore(self):
- print >>self.stdout, """ignore bpnumber count
-Sets the ignore count for the given breakpoint number. A breakpoint
-becomes active when the ignore count is zero. When non-zero, the
-count is decremented each time the breakpoint is reached and the
-breakpoint is not disabled and any associated condition evaluates
-to true."""
-
- def help_condition(self):
- print >>self.stdout, """condition bpnumber str_condition
-str_condition is a string specifying an expression which
-must evaluate to true before the breakpoint is honored.
-If str_condition is absent, any existing condition is removed;
-i.e., the breakpoint is made unconditional."""
-
- def help_step(self):
- self.help_s()
-
- def help_s(self):
- print >>self.stdout, """s(tep)
-Execute the current line, stop at the first possible occasion
-(either in a function that is called or in the current function)."""
-
- def help_until(self):
- self.help_unt()
-
- def help_unt(self):
- print """unt(il)
-Continue execution until the line with a number greater than the current
-one is reached or until the current frame returns"""
-
- def help_next(self):
- self.help_n()
-
- def help_n(self):
- print >>self.stdout, """n(ext)
-Continue execution until the next line in the current function
-is reached or it returns."""
-
- def help_return(self):
- self.help_r()
-
- def help_r(self):
- print >>self.stdout, """r(eturn)
-Continue execution until the current function returns."""
-
- def help_continue(self):
- self.help_c()
-
- def help_cont(self):
- self.help_c()
-
- def help_c(self):
- print >>self.stdout, """c(ont(inue))
-Continue execution, only stop when a breakpoint is encountered."""
-
- def help_jump(self):
- self.help_j()
-
- def help_j(self):
- print >>self.stdout, """j(ump) lineno
-Set the next line that will be executed."""
-
- def help_debug(self):
- print >>self.stdout, """debug code
-Enter a recursive debugger that steps through the code argument
-(which is an arbitrary expression or statement to be executed
-in the current environment)."""
-
- def help_list(self):
- self.help_l()
-
- def help_l(self):
- print >>self.stdout, """l(ist) [first [,last]]
-List source code for the current file.
-Without arguments, list 11 lines around the current line
-or continue the previous listing.
-With one argument, list 11 lines starting at that line.
-With two arguments, list the given range;
-if the second argument is less than the first, it is a count."""
-
- def help_args(self):
- self.help_a()
-
- def help_a(self):
- print >>self.stdout, """a(rgs)
-Print the arguments of the current function."""
-
- def help_p(self):
- print >>self.stdout, """p expression
-Print the value of the expression."""
-
- def help_pp(self):
- print >>self.stdout, """pp expression
-Pretty-print the value of the expression."""
+ prefix = ' '
+ self.message(prefix +
+ self.format_stack_entry(frame_lineno, prompt_prefix))
+
+ # Provide help
+
+ def do_help(self, arg):
+ """h(elp)
+ Without argument, print the list of available commands.
+ With a command name as argument, print help about that command.
+ "help pdb" shows the full pdb documentation.
+ "help exec" gives help on the ! command.
+ """
+ if not arg:
+ return cmd.Cmd.do_help(self, arg)
+ try:
+ try:
+ topic = getattr(self, 'help_' + arg)
+ return topic()
+ except AttributeError:
+ command = getattr(self, 'do_' + arg)
+ except AttributeError:
+ self.error('No help for %r' % arg)
+ else:
+ if sys.flags.optimize >= 2:
+ self.error('No help for %r; please do not run Python with -OO '
+ 'if you need command help' % arg)
+ return
+ self.message(command.__doc__.rstrip())
- def help_exec(self):
- print >>self.stdout, """(!) statement
-Execute the (one-line) statement in the context of
-the current stack frame.
-The exclamation point can be omitted unless the first word
-of the statement resembles a debugger command.
-To assign to a global variable you must always prefix the
-command with a 'global' command, e.g.:
-(Pdb) global list_options; list_options = ['-l']
-(Pdb)"""
-
- def help_run(self):
- print """run [args...]
-Restart the debugged python program. If a string is supplied, it is
-splitted with "shlex" and the result is used as the new sys.argv.
-History, breakpoints, actions and debugger options are preserved.
-"restart" is an alias for "run"."""
-
- help_restart = help_run
-
- def help_quit(self):
- self.help_q()
-
- def help_q(self):
- print >>self.stdout, """q(uit) or exit - Quit from the debugger.
-The program being executed is aborted."""
-
- help_exit = help_q
-
- def help_whatis(self):
- print >>self.stdout, """whatis arg
-Prints the type of the argument."""
-
- def help_EOF(self):
- print >>self.stdout, """EOF
-Handles the receipt of EOF as a command."""
-
- def help_alias(self):
- print >>self.stdout, """alias [name [command [parameter parameter ...]]]
-Creates an alias called 'name' the executes 'command'. The command
-must *not* be enclosed in quotes. Replaceable parameters are
-indicated by %1, %2, and so on, while %* is replaced by all the
-parameters. If no command is given, the current alias for name
-is shown. If no name is given, all aliases are listed.
-
-Aliases may be nested and can contain anything that can be
-legally typed at the pdb prompt. Note! You *can* override
-internal pdb commands with aliases! Those internal commands
-are then hidden until the alias is removed. Aliasing is recursively
-applied to the first word of the command line; all other words
-in the line are left alone.
-
-Some useful aliases (especially when placed in the .pdbrc file) are:
-
-#Print instance variables (usage "pi classInst")
-alias pi for k in %1.__dict__.keys(): print "%1.",k,"=",%1.__dict__[k]
-
-#Print instance variables in self
-alias ps pi self
-"""
+ do_h = do_help
- def help_unalias(self):
- print >>self.stdout, """unalias name
-Deletes the specified alias."""
-
- def help_commands(self):
- print >>self.stdout, """commands [bpnumber]
-(com) ...
-(com) end
-(Pdb)
-
-Specify a list of commands for breakpoint number bpnumber. The
-commands themselves appear on the following lines. Type a line
-containing just 'end' to terminate the commands.
-
-To remove all commands from a breakpoint, type commands and
-follow it immediately with end; that is, give no commands.
-
-With no bpnumber argument, commands refers to the last
-breakpoint set.
-
-You can use breakpoint commands to start your program up again.
-Simply use the continue command, or step, or any other
-command that resumes execution.
-
-Specifying any command resuming execution (currently continue,
-step, next, return, jump, quit and their abbreviations) terminates
-the command list (as if that command was immediately followed by end).
-This is because any time you resume execution
-(even with a simple next or step), you may encounter
-another breakpoint--which could have its own command list, leading to
-ambiguities about which list to execute.
-
- If you use the 'silent' command in the command list, the
-usual message about stopping at a breakpoint is not printed. This may
-be desirable for breakpoints that are to print a specific message and
-then continue. If none of the other commands print anything, you
-see no sign that the breakpoint was reached.
-"""
+ def help_exec(self):
+ """(!) statement
+ Execute the (one-line) statement in the context of the current
+ stack frame. The exclamation point can be omitted unless the
+ first word of the statement resembles a debugger command. To
+ assign to a global variable you must always prefix the command
+ with a 'global' command, e.g.:
+ (Pdb) global list_options; list_options = ['-l']
+ (Pdb)
+ """
+ self.message((self.help_exec.__doc__ or '').strip())
def help_pdb(self):
help()
+ # other helper functions
+
def lookupmodule(self, filename):
"""Helper function for break/clear parsing -- may be overridden.
@@ -1226,12 +1435,33 @@ see no sign that the breakpoint was reached.
# events depends on python version). So we take special measures to
# avoid stopping before we reach the main script (see user_line and
# user_call for details).
- self._wait_for_mainpyfile = 1
+ self._wait_for_mainpyfile = True
self.mainpyfile = self.canonic(filename)
- self._user_requested_quit = 0
- statement = 'execfile(%r)' % filename
+ self._user_requested_quit = False
+ with open(filename, "rb") as fp:
+ statement = "exec(compile(%r, %r, 'exec'))" % \
+ (fp.read(), self.mainpyfile)
self.run(statement)
+# Collect all command help into docstring, if not run with -OO
+
+if __doc__ is not None:
+ # unfortunately we can't guess this order from the class definition
+ _help_order = [
+ 'help', 'where', 'down', 'up', 'break', 'tbreak', 'clear', 'disable',
+ 'enable', 'ignore', 'condition', 'commands', 'step', 'next', 'until',
+ 'jump', 'return', 'retval', 'run', 'continue', 'list', 'longlist',
+ 'args', 'print', 'pp', 'whatis', 'source', 'display', 'undisplay',
+ 'interact', 'alias', 'unalias', 'debug', 'quit',
+ ]
+
+ for _command in _help_order:
+ __doc__ += getattr(Pdb, 'do_' + _command).__doc__.strip() + '\n\n'
+ __doc__ += Pdb.help_exec.__doc__
+
+ del _help_order, _command
+
+
# Simplified interface
def run(statement, globals=None, locals=None):
@@ -1258,9 +1488,9 @@ def post_mortem(t=None):
# sys.exc_info() returns (type, value, traceback) if an exception is
# being handled, otherwise it returns None
t = sys.exc_info()[2]
- if t is None:
- raise ValueError("A valid traceback must be passed if no "
- "exception is being handled")
+ if t is None:
+ raise ValueError("A valid traceback must be passed if no "
+ "exception is being handled")
p = Pdb()
p.reset()
@@ -1279,27 +1509,45 @@ def test():
# print help
def help():
- for dirname in sys.path:
- fullname = os.path.join(dirname, 'pdb.doc')
- if os.path.exists(fullname):
- sts = os.system('${PAGER-more} '+fullname)
- if sts: print '*** Pager exit status:', sts
- break
- else:
- print 'Sorry, can\'t find the help file "pdb.doc"',
- print 'along the Python search path'
+ import pydoc
+ pydoc.pager(__doc__)
+
+_usage = """\
+usage: pdb.py [-c command] ... pyfile [arg] ...
+
+Debug the Python program given by pyfile.
+
+Initial commands are read from .pdbrc files in your home directory
+and in the current directory, if they exist. Commands supplied with
+-c are executed after commands from .pdbrc files.
+
+To let the script run until an exception occurs, use "-c continue".
+To let the script run up to a given line X in the debugged file, use
+"-c 'until X'"."""
def main():
- if not sys.argv[1:] or sys.argv[1] in ("--help", "-h"):
- print "usage: pdb.py scriptfile [arg] ..."
+ import getopt
+
+ opts, args = getopt.getopt(sys.argv[1:], 'hc:', ['--help', '--command='])
+
+ if not args:
+ print(_usage)
sys.exit(2)
- mainpyfile = sys.argv[1] # Get script filename
+ commands = []
+ for opt, optarg in opts:
+ if opt in ['-h', '--help']:
+ print(_usage)
+ sys.exit()
+ elif opt in ['-c', '--command']:
+ commands.append(optarg)
+
+ mainpyfile = args[0] # Get script filename
if not os.path.exists(mainpyfile):
- print 'Error:', mainpyfile, 'does not exist'
+ print('Error:', mainpyfile, 'does not exist')
sys.exit(1)
- del sys.argv[0] # Hide "pdb.py" from argument list
+ sys.argv[:] = args # Hide "pdb.py" and pdb options from argument list
# Replace pdb's dir with script's dir in front of module search path.
sys.path[0] = os.path.dirname(mainpyfile)
@@ -1309,27 +1557,28 @@ def main():
# changed by the user from the command line. There is a "restart" command
# which allows explicit specification of command line arguments.
pdb = Pdb()
+ pdb.rcLines.extend(commands)
while True:
try:
pdb._runscript(mainpyfile)
if pdb._user_requested_quit:
break
- print "The program finished and will be restarted"
+ print("The program finished and will be restarted")
except Restart:
- print "Restarting", mainpyfile, "with arguments:"
- print "\t" + " ".join(sys.argv[1:])
+ print("Restarting", mainpyfile, "with arguments:")
+ print("\t" + " ".join(args))
except SystemExit:
# In most cases SystemExit does not warrant a post-mortem session.
- print "The program exited via sys.exit(). Exit status: ",
- print sys.exc_info()[1]
+ print("The program exited via sys.exit(). Exit status:", end=' ')
+ print(sys.exc_info()[1])
except:
traceback.print_exc()
- print "Uncaught exception. Entering post mortem debugging"
- print "Running 'cont' or 'step' will restart the program"
+ print("Uncaught exception. Entering post mortem debugging")
+ print("Running 'cont' or 'step' will restart the program")
t = sys.exc_info()[2]
pdb.interaction(None, t)
- print "Post mortem debugger finished. The " + mainpyfile + \
- " will be restarted"
+ print("Post mortem debugger finished. The " + mainpyfile +
+ " will be restarted")
# When invoked as main program, invoke the debugger on a script
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 5b95cbaca76..a690ccd8bc5 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -1,7 +1,6 @@
"""Create portable serialized representations of Python objects.
-See module cPickle for a (much) faster implementation.
-See module copy_reg for a mechanism for registering custom picklers.
+See module copyreg for a mechanism for registering custom picklers.
See module pickletools source for extensive comments.
Classes:
@@ -24,31 +23,42 @@ Misc variables:
"""
-__version__ = "$Revision: 72223 $" # Code version
+__version__ = "$Revision$" # Code version
-from types import *
-from copy_reg import dispatch_table
-from copy_reg import _extension_registry, _inverted_registry, _extension_cache
+from types import FunctionType, BuiltinFunctionType
+from copyreg import dispatch_table
+from copyreg import _extension_registry, _inverted_registry, _extension_cache
import marshal
import sys
import struct
import re
+import io
+import codecs
+import _compat_pickle
__all__ = ["PickleError", "PicklingError", "UnpicklingError", "Pickler",
"Unpickler", "dump", "dumps", "load", "loads"]
+# Shortcut for use in isinstance testing
+bytes_types = (bytes, bytearray)
+
# These are purely informational; no code uses these.
-format_version = "2.0" # File format version we write
+format_version = "3.0" # File format version we write
compatible_formats = ["1.0", # Original protocol 0
"1.1", # Protocol 0 with INST added
"1.2", # Original protocol 1
"1.3", # Protocol 1 with BINFLOAT added
"2.0", # Protocol 2
+ "3.0", # Protocol 3
] # Old format versions we can read
-# Keep in synch with cPickle. This is the highest protocol number we
-# know how to read.
-HIGHEST_PROTOCOL = 2
+# This is the highest protocol number we know how to read.
+HIGHEST_PROTOCOL = 3
+
+# The protocol we write by default. May be less than HIGHEST_PROTOCOL.
+# We intentionally write a protocol that Python 2.x cannot read;
+# there are too many issues with that.
+DEFAULT_PROTOCOL = 3
# Why use struct.pack() for pickling but marshal.loads() for
# unpickling? struct.pack() is 40% faster than marshal.dumps(), but
@@ -89,122 +99,120 @@ try:
except ImportError:
PyStringMap = None
-# UnicodeType may or may not be exported (normally imported from types)
-try:
- UnicodeType
-except NameError:
- UnicodeType = None
-
# Pickle opcodes. See pickletools.py for extensive docs. The listing
# here is in kind-of alphabetical order of 1-character pickle code.
# pickletools groups them by purpose.
-MARK = '(' # push special markobject on stack
-STOP = '.' # every pickle ends with STOP
-POP = '0' # discard topmost stack item
-POP_MARK = '1' # discard stack top through topmost markobject
-DUP = '2' # duplicate top stack item
-FLOAT = 'F' # push float object; decimal string argument
-INT = 'I' # push integer or bool; decimal string argument
-BININT = 'J' # push four-byte signed int
-BININT1 = 'K' # push 1-byte unsigned int
-LONG = 'L' # push long; decimal string argument
-BININT2 = 'M' # push 2-byte unsigned int
-NONE = 'N' # push None
-PERSID = 'P' # push persistent object; id is taken from string arg
-BINPERSID = 'Q' # " " " ; " " " " stack
-REDUCE = 'R' # apply callable to argtuple, both on stack
-STRING = 'S' # push string; NL-terminated string argument
-BINSTRING = 'T' # push string; counted binary string argument
-SHORT_BINSTRING = 'U' # " " ; " " " " < 256 bytes
-UNICODE = 'V' # push Unicode string; raw-unicode-escaped'd argument
-BINUNICODE = 'X' # " " " ; counted UTF-8 string argument
-APPEND = 'a' # append stack top to list below it
-BUILD = 'b' # call __setstate__ or __dict__.update()
-GLOBAL = 'c' # push self.find_class(modname, name); 2 string args
-DICT = 'd' # build a dict from stack items
-EMPTY_DICT = '}' # push empty dict
-APPENDS = 'e' # extend list on stack by topmost stack slice
-GET = 'g' # push item from memo on stack; index is string arg
-BINGET = 'h' # " " " " " " ; " " 1-byte arg
-INST = 'i' # build & push class instance
-LONG_BINGET = 'j' # push item from memo on stack; index is 4-byte arg
-LIST = 'l' # build list from topmost stack items
-EMPTY_LIST = ']' # push empty list
-OBJ = 'o' # build & push class instance
-PUT = 'p' # store stack top in memo; index is string arg
-BINPUT = 'q' # " " " " " ; " " 1-byte arg
-LONG_BINPUT = 'r' # " " " " " ; " " 4-byte arg
-SETITEM = 's' # add key+value pair to dict
-TUPLE = 't' # build tuple from topmost stack items
-EMPTY_TUPLE = ')' # push empty tuple
-SETITEMS = 'u' # modify dict by adding topmost key+value pairs
-BINFLOAT = 'G' # push float; arg is 8-byte float encoding
-
-TRUE = 'I01\n' # not an opcode; see INT docs in pickletools.py
-FALSE = 'I00\n' # not an opcode; see INT docs in pickletools.py
+MARK = b'(' # push special markobject on stack
+STOP = b'.' # every pickle ends with STOP
+POP = b'0' # discard topmost stack item
+POP_MARK = b'1' # discard stack top through topmost markobject
+DUP = b'2' # duplicate top stack item
+FLOAT = b'F' # push float object; decimal string argument
+INT = b'I' # push integer or bool; decimal string argument
+BININT = b'J' # push four-byte signed int
+BININT1 = b'K' # push 1-byte unsigned int
+LONG = b'L' # push long; decimal string argument
+BININT2 = b'M' # push 2-byte unsigned int
+NONE = b'N' # push None
+PERSID = b'P' # push persistent object; id is taken from string arg
+BINPERSID = b'Q' # " " " ; " " " " stack
+REDUCE = b'R' # apply callable to argtuple, both on stack
+STRING = b'S' # push string; NL-terminated string argument
+BINSTRING = b'T' # push string; counted binary string argument
+SHORT_BINSTRING= b'U' # " " ; " " " " < 256 bytes
+UNICODE = b'V' # push Unicode string; raw-unicode-escaped'd argument
+BINUNICODE = b'X' # " " " ; counted UTF-8 string argument
+APPEND = b'a' # append stack top to list below it
+BUILD = b'b' # call __setstate__ or __dict__.update()
+GLOBAL = b'c' # push self.find_class(modname, name); 2 string args
+DICT = b'd' # build a dict from stack items
+EMPTY_DICT = b'}' # push empty dict
+APPENDS = b'e' # extend list on stack by topmost stack slice
+GET = b'g' # push item from memo on stack; index is string arg
+BINGET = b'h' # " " " " " " ; " " 1-byte arg
+INST = b'i' # build & push class instance
+LONG_BINGET = b'j' # push item from memo on stack; index is 4-byte arg
+LIST = b'l' # build list from topmost stack items
+EMPTY_LIST = b']' # push empty list
+OBJ = b'o' # build & push class instance
+PUT = b'p' # store stack top in memo; index is string arg
+BINPUT = b'q' # " " " " " ; " " 1-byte arg
+LONG_BINPUT = b'r' # " " " " " ; " " 4-byte arg
+SETITEM = b's' # add key+value pair to dict
+TUPLE = b't' # build tuple from topmost stack items
+EMPTY_TUPLE = b')' # push empty tuple
+SETITEMS = b'u' # modify dict by adding topmost key+value pairs
+BINFLOAT = b'G' # push float; arg is 8-byte float encoding
+
+TRUE = b'I01\n' # not an opcode; see INT docs in pickletools.py
+FALSE = b'I00\n' # not an opcode; see INT docs in pickletools.py
# Protocol 2
-PROTO = '\x80' # identify pickle protocol
-NEWOBJ = '\x81' # build object by applying cls.__new__ to argtuple
-EXT1 = '\x82' # push object from extension registry; 1-byte index
-EXT2 = '\x83' # ditto, but 2-byte index
-EXT4 = '\x84' # ditto, but 4-byte index
-TUPLE1 = '\x85' # build 1-tuple from stack top
-TUPLE2 = '\x86' # build 2-tuple from two topmost stack items
-TUPLE3 = '\x87' # build 3-tuple from three topmost stack items
-NEWTRUE = '\x88' # push True
-NEWFALSE = '\x89' # push False
-LONG1 = '\x8a' # push long from < 256 bytes
-LONG4 = '\x8b' # push really big long
+PROTO = b'\x80' # identify pickle protocol
+NEWOBJ = b'\x81' # build object by applying cls.__new__ to argtuple
+EXT1 = b'\x82' # push object from extension registry; 1-byte index
+EXT2 = b'\x83' # ditto, but 2-byte index
+EXT4 = b'\x84' # ditto, but 4-byte index
+TUPLE1 = b'\x85' # build 1-tuple from stack top
+TUPLE2 = b'\x86' # build 2-tuple from two topmost stack items
+TUPLE3 = b'\x87' # build 3-tuple from three topmost stack items
+NEWTRUE = b'\x88' # push True
+NEWFALSE = b'\x89' # push False
+LONG1 = b'\x8a' # push long from < 256 bytes
+LONG4 = b'\x8b' # push really big long
_tuplesize2code = [EMPTY_TUPLE, TUPLE1, TUPLE2, TUPLE3]
+# Protocol 3 (Python 3.x)
-__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)])
-del x
+BINBYTES = b'B' # push bytes; counted binary string argument
+SHORT_BINBYTES = b'C' # " " ; " " " " < 256 bytes
+__all__.extend([x for x in dir() if re.match("[A-Z][A-Z0-9_]+$",x)])
# Pickling machinery
-class Pickler:
+class _Pickler:
- def __init__(self, file, protocol=None):
- """This takes a file-like object for writing a pickle data stream.
+ def __init__(self, file, protocol=None, *, fix_imports=True):
+ """This takes a binary file for writing a pickle data stream.
The optional protocol argument tells the pickler to use the
- given protocol; supported protocols are 0, 1, 2. The default
- protocol is 0, to be backwards compatible. (Protocol 0 is the
- only protocol that can be written to a file opened in text
- mode and read back successfully. When using a protocol higher
- than 0, make sure the file is opened in binary mode, both when
- pickling and unpickling.)
-
- Protocol 1 is more efficient than protocol 0; protocol 2 is
- more efficient than protocol 1.
+ given protocol; supported protocols are 0, 1, 2, 3. The default
+ protocol is 3; a backward-incompatible protocol designed for
+ Python 3.0.
Specifying a negative protocol version selects the highest
protocol version supported. The higher the protocol used, the
more recent the version of Python needed to read the pickle
produced.
- The file parameter must have a write() method that accepts a single
- string argument. It can thus be an open file object, a StringIO
- object, or any other custom object that meets this interface.
+ The file argument must have a write() method that accepts a single
+ bytes argument. It can thus be a file object opened for binary
+ writing, a io.BytesIO instance, or any other custom object that
+ meets this interface.
+ If fix_imports is True and protocol is less than 3, pickle will try to
+ map the new Python 3.x names to the old module names used in Python
+ 2.x, so that the pickle data stream is readable with Python 2.x.
"""
if protocol is None:
- protocol = 0
+ protocol = DEFAULT_PROTOCOL
if protocol < 0:
protocol = HIGHEST_PROTOCOL
elif not 0 <= protocol <= HIGHEST_PROTOCOL:
raise ValueError("pickle protocol must be <= %d" % HIGHEST_PROTOCOL)
- self.write = file.write
+ try:
+ self.write = file.write
+ except AttributeError:
+ raise TypeError("file must have a 'write' attribute")
self.memo = {}
self.proto = int(protocol)
self.bin = protocol >= 1
self.fast = 0
+ self.fix_imports = fix_imports and protocol < 3
def clear_memo(self):
"""Clears the pickler's "memo".
@@ -219,8 +227,13 @@ class Pickler:
def dump(self, obj):
"""Write a pickled representation of obj to the open file."""
+ # Check whether Pickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Pickler.dump().
+ if not hasattr(self, "write"):
+ raise PicklingError("Pickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
if self.proto >= 2:
- self.write(PROTO + chr(self.proto))
+ self.write(PROTO + bytes([self.proto]))
self.save(obj)
self.write(STOP)
@@ -250,26 +263,26 @@ class Pickler:
def put(self, i, pack=struct.pack):
if self.bin:
if i < 256:
- return BINPUT + chr(i)
+ return BINPUT + bytes([i])
else:
- return LONG_BINPUT + pack("<i", i)
+ return LONG_BINPUT + pack("<I", i)
- return PUT + repr(i) + '\n'
+ return PUT + repr(i).encode("ascii") + b'\n'
# Return a GET (BINGET, LONG_BINGET) opcode string, with argument i.
def get(self, i, pack=struct.pack):
if self.bin:
if i < 256:
- return BINGET + chr(i)
+ return BINGET + bytes([i])
else:
- return LONG_BINGET + pack("<i", i)
+ return LONG_BINGET + pack("<I", i)
- return GET + repr(i) + '\n'
+ return GET + repr(i).encode("ascii") + b'\n'
- def save(self, obj):
+ def save(self, obj, save_persistent_id=True):
# Check for persistent id (defined by a subclass)
pid = self.persistent_id(obj)
- if pid:
+ if pid is not None and save_persistent_id:
self.save_pers(pid)
return
@@ -286,16 +299,16 @@ class Pickler:
f(self, obj) # Call unbound method with explicit self
return
- # Check copy_reg.dispatch_table
+ # Check copyreg.dispatch_table
reduce = dispatch_table.get(t)
if reduce:
rv = reduce(obj)
else:
# Check for a class with a custom metaclass; treat as regular class
try:
- issc = issubclass(t, TypeType)
+ issc = issubclass(t, type)
except TypeError: # t is not a class (old Boost; see SF #502085)
- issc = 0
+ issc = False
if issc:
self.save_global(obj)
return
@@ -313,12 +326,12 @@ class Pickler:
(t.__name__, obj))
# Check for string returned by reduce(), meaning "save as global"
- if type(rv) is StringType:
+ if isinstance(rv, str):
self.save_global(obj, rv)
return
# Assert that reduce() returned a tuple
- if type(rv) is not TupleType:
+ if not isinstance(rv, tuple):
raise PicklingError("%s must return string or tuple" % reduce)
# Assert that it returned an appropriately sized tuple
@@ -337,22 +350,22 @@ class Pickler:
def save_pers(self, pid):
# Save a persistent id reference
if self.bin:
- self.save(pid)
+ self.save(pid, save_persistent_id=False)
self.write(BINPERSID)
else:
- self.write(PERSID + str(pid) + '\n')
+ self.write(PERSID + str(pid).encode("ascii") + b'\n')
def save_reduce(self, func, args, state=None,
listitems=None, dictitems=None, obj=None):
# This API is called by some subclasses
- # Assert that args is a tuple or None
- if not isinstance(args, TupleType):
- raise PicklingError("args from reduce() should be a tuple")
+ # Assert that args is a tuple
+ if not isinstance(args, tuple):
+ raise PicklingError("args from save_reduce() should be a tuple")
# Assert that func is callable
- if not hasattr(func, '__call__'):
- raise PicklingError("func from reduce should be callable")
+ if not callable(func):
+ raise PicklingError("func from save_reduce() should be callable")
save = self.save
write = self.write
@@ -425,7 +438,7 @@ class Pickler:
def save_none(self, obj):
self.write(NONE)
- dispatch[NoneType] = save_none
+ dispatch[type(None)] = save_none
def save_bool(self, obj):
if self.proto >= 2:
@@ -434,7 +447,7 @@ class Pickler:
self.write(obj and TRUE or FALSE)
dispatch[bool] = save_bool
- def save_int(self, obj, pack=struct.pack):
+ def save_long(self, obj, pack=struct.pack):
if self.bin:
# If the int is small enough to fit in a signed 4-byte 2's-comp
# format, we can store it more efficiently than the general
@@ -442,10 +455,10 @@ class Pickler:
# First one- and two-byte unsigned ints:
if obj >= 0:
if obj <= 0xff:
- self.write(BININT1 + chr(obj))
+ self.write(BININT1 + bytes([obj]))
return
if obj <= 0xffff:
- self.write("%c%c%c" % (BININT2, obj&0xff, obj>>8))
+ self.write(BININT2 + bytes([obj&0xff, obj>>8]))
return
# Next check for 4-byte signed ints:
high_bits = obj >> 31 # note that Python shift sign-extends
@@ -454,80 +467,52 @@ class Pickler:
# fits in a 4-byte signed int.
self.write(BININT + pack("<i", obj))
return
- # Text pickle, or int too big to fit in signed 4-byte format.
- self.write(INT + repr(obj) + '\n')
- dispatch[IntType] = save_int
-
- def save_long(self, obj, pack=struct.pack):
if self.proto >= 2:
- bytes = encode_long(obj)
- n = len(bytes)
+ encoded = encode_long(obj)
+ n = len(encoded)
if n < 256:
- self.write(LONG1 + chr(n) + bytes)
+ self.write(LONG1 + bytes([n]) + encoded)
else:
- self.write(LONG4 + pack("<i", n) + bytes)
+ self.write(LONG4 + pack("<i", n) + encoded)
return
- self.write(LONG + repr(obj) + '\n')
- dispatch[LongType] = save_long
+ self.write(LONG + repr(obj).encode("ascii") + b'L\n')
+ dispatch[int] = save_long
def save_float(self, obj, pack=struct.pack):
if self.bin:
self.write(BINFLOAT + pack('>d', obj))
else:
- self.write(FLOAT + repr(obj) + '\n')
- dispatch[FloatType] = save_float
+ self.write(FLOAT + repr(obj).encode("ascii") + b'\n')
+ dispatch[float] = save_float
- def save_string(self, obj, pack=struct.pack):
- if self.bin:
- n = len(obj)
- if n < 256:
- self.write(SHORT_BINSTRING + chr(n) + obj)
+ def save_bytes(self, obj, pack=struct.pack):
+ if self.proto < 3:
+ if len(obj) == 0:
+ self.save_reduce(bytes, (), obj=obj)
else:
- self.write(BINSTRING + pack("<i", n) + obj)
+ self.save_reduce(codecs.encode,
+ (str(obj, 'latin1'), 'latin1'), obj=obj)
+ return
+ n = len(obj)
+ if n < 256:
+ self.write(SHORT_BINBYTES + bytes([n]) + bytes(obj))
else:
- self.write(STRING + repr(obj) + '\n')
+ self.write(BINBYTES + pack("<I", n) + bytes(obj))
self.memoize(obj)
- dispatch[StringType] = save_string
+ dispatch[bytes] = save_bytes
- def save_unicode(self, obj, pack=struct.pack):
+ def save_str(self, obj, pack=struct.pack):
if self.bin:
- encoding = obj.encode('utf-8')
- n = len(encoding)
- self.write(BINUNICODE + pack("<i", n) + encoding)
+ encoded = obj.encode('utf-8', 'surrogatepass')
+ n = len(encoded)
+ self.write(BINUNICODE + pack("<I", n) + encoded)
else:
obj = obj.replace("\\", "\\u005c")
obj = obj.replace("\n", "\\u000a")
- self.write(UNICODE + obj.encode('raw-unicode-escape') + '\n')
+ self.write(UNICODE + bytes(obj.encode('raw-unicode-escape')) +
+ b'\n')
self.memoize(obj)
- dispatch[UnicodeType] = save_unicode
-
- if StringType is UnicodeType:
- # This is true for Jython
- def save_string(self, obj, pack=struct.pack):
- unicode = obj.isunicode()
-
- if self.bin:
- if unicode:
- obj = obj.encode("utf-8")
- l = len(obj)
- if l < 256 and not unicode:
- self.write(SHORT_BINSTRING + chr(l) + obj)
- else:
- s = pack("<i", l)
- if unicode:
- self.write(BINUNICODE + s + obj)
- else:
- self.write(BINSTRING + s + obj)
- else:
- if unicode:
- obj = obj.replace("\\", "\\u005c")
- obj = obj.replace("\n", "\\u000a")
- obj = obj.encode('raw-unicode-escape')
- self.write(UNICODE + obj + '\n')
- else:
- self.write(STRING + repr(obj) + '\n')
- self.memoize(obj)
- dispatch[StringType] = save_string
+ dispatch[str] = save_str
def save_tuple(self, obj):
write = self.write
@@ -580,13 +565,7 @@ class Pickler:
self.write(TUPLE)
self.memoize(obj)
- dispatch[TupleType] = save_tuple
-
- # save_empty_tuple() isn't used by anything in Python 2.3. However, I
- # found a Pickler subclass in Zope3 that calls it, so it's not harmless
- # to remove it.
- def save_empty_tuple(self, obj):
- self.write(EMPTY_TUPLE)
+ dispatch[tuple] = save_tuple
def save_list(self, obj):
write = self.write
@@ -597,12 +576,10 @@ class Pickler:
write(MARK + LIST)
self.memoize(obj)
- self._batch_appends(iter(obj))
+ self._batch_appends(obj)
- dispatch[ListType] = save_list
+ dispatch[list] = save_list
- # Keep in synch with cPickle's BATCHSIZE. Nothing will break if it gets
- # out of synch, though.
_BATCHSIZE = 1000
def _batch_appends(self, items):
@@ -616,12 +593,13 @@ class Pickler:
write(APPEND)
return
- r = xrange(self._BATCHSIZE)
+ items = iter(items)
+ r = range(self._BATCHSIZE)
while items is not None:
tmp = []
for i in r:
try:
- x = items.next()
+ x = next(items)
tmp.append(x)
except StopIteration:
items = None
@@ -646,10 +624,10 @@ class Pickler:
write(MARK + DICT)
self.memoize(obj)
- self._batch_setitems(obj.iteritems())
+ self._batch_setitems(obj.items())
- dispatch[DictionaryType] = save_dict
- if not PyStringMap is None:
+ dispatch[dict] = save_dict
+ if PyStringMap is not None:
dispatch[PyStringMap] = save_dict
def _batch_setitems(self, items):
@@ -664,12 +642,13 @@ class Pickler:
write(SETITEM)
return
- r = xrange(self._BATCHSIZE)
+ items = iter(items)
+ r = range(self._BATCHSIZE)
while items is not None:
tmp = []
for i in r:
try:
- tmp.append(items.next())
+ tmp.append(next(items))
except StopIteration:
items = None
break
@@ -687,46 +666,6 @@ class Pickler:
write(SETITEM)
# else tmp is empty, and we're done
- def save_inst(self, obj):
- cls = obj.__class__
-
- memo = self.memo
- write = self.write
- save = self.save
-
- if hasattr(obj, '__getinitargs__'):
- args = obj.__getinitargs__()
- len(args) # XXX Assert it's a sequence
- _keep_alive(args, memo)
- else:
- args = ()
-
- write(MARK)
-
- if self.bin:
- save(cls)
- for arg in args:
- save(arg)
- write(OBJ)
- else:
- for arg in args:
- save(arg)
- write(INST + cls.__module__ + '\n' + cls.__name__ + '\n')
-
- self.memoize(obj)
-
- try:
- getstate = obj.__getstate__
- except AttributeError:
- stuff = obj.__dict__
- else:
- stuff = getstate()
- _keep_alive(stuff, memo)
- save(stuff)
- write(BUILD)
-
- dispatch[InstanceType] = save_inst
-
def save_global(self, obj, name=None, pack=struct.pack):
write = self.write
memo = self.memo
@@ -739,7 +678,7 @@ class Pickler:
module = whichmodule(obj, name)
try:
- __import__(module)
+ __import__(module, level=0)
mod = sys.modules[module]
klass = getattr(mod, name)
except (ImportError, KeyError, AttributeError):
@@ -757,20 +696,35 @@ class Pickler:
if code:
assert code > 0
if code <= 0xff:
- write(EXT1 + chr(code))
+ write(EXT1 + bytes([code]))
elif code <= 0xffff:
- write("%c%c%c" % (EXT2, code&0xff, code>>8))
+ write(EXT2 + bytes([code&0xff, code>>8]))
else:
write(EXT4 + pack("<i", code))
return
+ # Non-ASCII identifiers are supported only with protocols >= 3.
+ if self.proto >= 3:
+ write(GLOBAL + bytes(module, "utf-8") + b'\n' +
+ bytes(name, "utf-8") + b'\n')
+ else:
+ if self.fix_imports:
+ if (module, name) in _compat_pickle.REVERSE_NAME_MAPPING:
+ module, name = _compat_pickle.REVERSE_NAME_MAPPING[(module, name)]
+ if module in _compat_pickle.REVERSE_IMPORT_MAPPING:
+ module = _compat_pickle.REVERSE_IMPORT_MAPPING[module]
+ try:
+ write(GLOBAL + bytes(module, "ascii") + b'\n' +
+ bytes(name, "ascii") + b'\n')
+ except UnicodeEncodeError:
+ raise PicklingError(
+ "can't pickle global identifier '%s.%s' using "
+ "pickle protocol %i" % (module, name, self.proto))
- write(GLOBAL + module + '\n' + name + '\n')
self.memoize(obj)
- dispatch[ClassType] = save_global
dispatch[FunctionType] = save_global
dispatch[BuiltinFunctionType] = save_global
- dispatch[TypeType] = save_global
+ dispatch[type] = save_global
# Pickling helpers
@@ -811,7 +765,7 @@ def whichmodule(func, funcname):
if func in classmap:
return classmap[func]
- for name, module in sys.modules.items():
+ for name, module in list(sys.modules.items()):
if module is None:
continue # skip dummy package entries
if name != '__main__' and getattr(module, funcname, None) is func:
@@ -824,29 +778,48 @@ def whichmodule(func, funcname):
# Unpickling machinery
-class Unpickler:
+class _Unpickler:
- def __init__(self, file):
- """This takes a file-like object for reading a pickle data stream.
+ def __init__(self, file, *, fix_imports=True,
+ encoding="ASCII", errors="strict"):
+ """This takes a binary file for reading a pickle data stream.
The protocol version of the pickle is detected automatically, so no
proto argument is needed.
- The file-like object must have two methods, a read() method that
- takes an integer argument, and a readline() method that requires no
- arguments. Both methods should return a string. Thus file-like
- object can be a file object opened for reading, a StringIO object,
- or any other custom object that meets this interface.
+ The file-like object must have two methods, a read() method
+ that takes an integer argument, and a readline() method that
+ requires no arguments. Both methods should return bytes.
+ Thus file-like object can be a binary file object opened for
+ reading, a BytesIO object, or any other custom object that
+ meets this interface.
+
+ Optional keyword arguments are *fix_imports*, *encoding* and *errors*,
+ which are used to control compatiblity support for pickle stream
+ generated by Python 2.x. If *fix_imports* is True, pickle will try to
+ map the old Python 2.x names to the new names used in Python 3.x. The
+ *encoding* and *errors* tell pickle how to decode 8-bit string
+ instances pickled by Python 2.x; these default to 'ASCII' and
+ 'strict', respectively.
"""
self.readline = file.readline
self.read = file.read
self.memo = {}
+ self.encoding = encoding
+ self.errors = errors
+ self.proto = 0
+ self.fix_imports = fix_imports
def load(self):
"""Read a pickled object representation from the open file.
Return the reconstituted object hierarchy specified in the file.
"""
+ # Check whether Unpickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Unpickler.dump().
+ if not hasattr(self, "read"):
+ raise UnpicklingError("Unpickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
self.mark = object() # any new unique object
self.stack = []
self.append = self.stack.append
@@ -855,8 +828,11 @@ class Unpickler:
try:
while 1:
key = read(1)
- dispatch[key](self)
- except _Stop, stopinst:
+ if not key:
+ raise EOFError
+ assert isinstance(key, bytes_types)
+ dispatch[key[0]](self)
+ except _Stop as stopinst:
return stopinst.value
# Return largest index k such that self.stack[k] is self.mark.
@@ -874,39 +850,39 @@ class Unpickler:
while stack[k] is not mark: k = k-1
return k
- dispatch = {}
+ def persistent_load(self, pid):
+ raise UnpicklingError("unsupported persistent id encountered")
- def load_eof(self):
- raise EOFError
- dispatch[''] = load_eof
+ dispatch = {}
def load_proto(self):
proto = ord(self.read(1))
- if not 0 <= proto <= 2:
- raise ValueError, "unsupported pickle protocol: %d" % proto
- dispatch[PROTO] = load_proto
+ if not 0 <= proto <= HIGHEST_PROTOCOL:
+ raise ValueError("unsupported pickle protocol: %d" % proto)
+ self.proto = proto
+ dispatch[PROTO[0]] = load_proto
def load_persid(self):
- pid = self.readline()[:-1]
+ pid = self.readline()[:-1].decode("ascii")
self.append(self.persistent_load(pid))
- dispatch[PERSID] = load_persid
+ dispatch[PERSID[0]] = load_persid
def load_binpersid(self):
pid = self.stack.pop()
self.append(self.persistent_load(pid))
- dispatch[BINPERSID] = load_binpersid
+ dispatch[BINPERSID[0]] = load_binpersid
def load_none(self):
self.append(None)
- dispatch[NONE] = load_none
+ dispatch[NONE[0]] = load_none
def load_false(self):
self.append(False)
- dispatch[NEWFALSE] = load_false
+ dispatch[NEWFALSE[0]] = load_false
def load_true(self):
self.append(True)
- dispatch[NEWTRUE] = load_true
+ dispatch[NEWTRUE[0]] = load_true
def load_int(self):
data = self.readline()
@@ -916,113 +892,142 @@ class Unpickler:
val = True
else:
try:
- val = int(data)
+ val = int(data, 0)
except ValueError:
- val = long(data)
+ val = int(data, 0)
self.append(val)
- dispatch[INT] = load_int
+ dispatch[INT[0]] = load_int
def load_binint(self):
- self.append(mloads('i' + self.read(4)))
- dispatch[BININT] = load_binint
+ self.append(mloads(b'i' + self.read(4)))
+ dispatch[BININT[0]] = load_binint
def load_binint1(self):
self.append(ord(self.read(1)))
- dispatch[BININT1] = load_binint1
+ dispatch[BININT1[0]] = load_binint1
def load_binint2(self):
- self.append(mloads('i' + self.read(2) + '\000\000'))
- dispatch[BININT2] = load_binint2
+ self.append(mloads(b'i' + self.read(2) + b'\000\000'))
+ dispatch[BININT2[0]] = load_binint2
def load_long(self):
- self.append(long(self.readline()[:-1], 0))
- dispatch[LONG] = load_long
+ val = self.readline()[:-1].decode("ascii")
+ if val and val[-1] == 'L':
+ val = val[:-1]
+ self.append(int(val, 0))
+ dispatch[LONG[0]] = load_long
def load_long1(self):
n = ord(self.read(1))
- bytes = self.read(n)
- self.append(decode_long(bytes))
- dispatch[LONG1] = load_long1
+ data = self.read(n)
+ self.append(decode_long(data))
+ dispatch[LONG1[0]] = load_long1
def load_long4(self):
- n = mloads('i' + self.read(4))
- bytes = self.read(n)
- self.append(decode_long(bytes))
- dispatch[LONG4] = load_long4
+ n = mloads(b'i' + self.read(4))
+ if n < 0:
+ # Corrupt or hostile pickle -- we never write one like this
+ raise UnpicklingError("LONG pickle has negative byte count");
+ data = self.read(n)
+ self.append(decode_long(data))
+ dispatch[LONG4[0]] = load_long4
def load_float(self):
self.append(float(self.readline()[:-1]))
- dispatch[FLOAT] = load_float
+ dispatch[FLOAT[0]] = load_float
def load_binfloat(self, unpack=struct.unpack):
self.append(unpack('>d', self.read(8))[0])
- dispatch[BINFLOAT] = load_binfloat
+ dispatch[BINFLOAT[0]] = load_binfloat
def load_string(self):
- rep = self.readline()[:-1]
- for q in "\"'": # double or single quote
+ orig = self.readline()
+ rep = orig[:-1]
+ for q in (b'"', b"'"): # double or single quote
if rep.startswith(q):
if not rep.endswith(q):
- raise ValueError, "insecure string pickle"
+ raise ValueError("insecure string pickle")
rep = rep[len(q):-len(q)]
break
else:
- raise ValueError, "insecure string pickle"
- self.append(rep.decode("string-escape"))
- dispatch[STRING] = load_string
+ raise ValueError("insecure string pickle: %r" % orig)
+ self.append(codecs.escape_decode(rep)[0]
+ .decode(self.encoding, self.errors))
+ dispatch[STRING[0]] = load_string
def load_binstring(self):
- len = mloads('i' + self.read(4))
+ # Deprecated BINSTRING uses signed 32-bit length
+ len = mloads(b'i' + self.read(4))
+ if len < 0:
+ raise UnpicklingError("BINSTRING pickle has negative byte count");
+ data = self.read(len)
+ value = str(data, self.encoding, self.errors)
+ self.append(value)
+ dispatch[BINSTRING[0]] = load_binstring
+
+ def load_binbytes(self, unpack=struct.unpack, maxsize=sys.maxsize):
+ len, = unpack('<I', self.read(4))
+ if len > maxsize:
+ raise UnpicklingError("BINBYTES exceeds system's maximum size of %d bytes" % maxsize);
self.append(self.read(len))
- dispatch[BINSTRING] = load_binstring
+ dispatch[BINBYTES[0]] = load_binbytes
def load_unicode(self):
- self.append(unicode(self.readline()[:-1],'raw-unicode-escape'))
- dispatch[UNICODE] = load_unicode
+ self.append(str(self.readline()[:-1], 'raw-unicode-escape'))
+ dispatch[UNICODE[0]] = load_unicode
- def load_binunicode(self):
- len = mloads('i' + self.read(4))
- self.append(unicode(self.read(len),'utf-8'))
- dispatch[BINUNICODE] = load_binunicode
+ def load_binunicode(self, unpack=struct.unpack, maxsize=sys.maxsize):
+ len, = unpack('<I', self.read(4))
+ if len > maxsize:
+ raise UnpicklingError("BINUNICODE exceeds system's maximum size of %d bytes" % maxsize);
+ self.append(str(self.read(len), 'utf-8', 'surrogatepass'))
+ dispatch[BINUNICODE[0]] = load_binunicode
def load_short_binstring(self):
len = ord(self.read(1))
- self.append(self.read(len))
- dispatch[SHORT_BINSTRING] = load_short_binstring
+ data = bytes(self.read(len))
+ value = str(data, self.encoding, self.errors)
+ self.append(value)
+ dispatch[SHORT_BINSTRING[0]] = load_short_binstring
+
+ def load_short_binbytes(self):
+ len = ord(self.read(1))
+ self.append(bytes(self.read(len)))
+ dispatch[SHORT_BINBYTES[0]] = load_short_binbytes
def load_tuple(self):
k = self.marker()
self.stack[k:] = [tuple(self.stack[k+1:])]
- dispatch[TUPLE] = load_tuple
+ dispatch[TUPLE[0]] = load_tuple
def load_empty_tuple(self):
- self.stack.append(())
- dispatch[EMPTY_TUPLE] = load_empty_tuple
+ self.append(())
+ dispatch[EMPTY_TUPLE[0]] = load_empty_tuple
def load_tuple1(self):
self.stack[-1] = (self.stack[-1],)
- dispatch[TUPLE1] = load_tuple1
+ dispatch[TUPLE1[0]] = load_tuple1
def load_tuple2(self):
self.stack[-2:] = [(self.stack[-2], self.stack[-1])]
- dispatch[TUPLE2] = load_tuple2
+ dispatch[TUPLE2[0]] = load_tuple2
def load_tuple3(self):
self.stack[-3:] = [(self.stack[-3], self.stack[-2], self.stack[-1])]
- dispatch[TUPLE3] = load_tuple3
+ dispatch[TUPLE3[0]] = load_tuple3
def load_empty_list(self):
- self.stack.append([])
- dispatch[EMPTY_LIST] = load_empty_list
+ self.append([])
+ dispatch[EMPTY_LIST[0]] = load_empty_list
def load_empty_dictionary(self):
- self.stack.append({})
- dispatch[EMPTY_DICT] = load_empty_dictionary
+ self.append({})
+ dispatch[EMPTY_DICT[0]] = load_empty_dictionary
def load_list(self):
k = self.marker()
self.stack[k:] = [self.stack[k+1:]]
- dispatch[LIST] = load_list
+ dispatch[LIST[0]] = load_list
def load_dict(self):
k = self.marker()
@@ -1033,7 +1038,7 @@ class Unpickler:
value = items[i+1]
d[key] = value
self.stack[k:] = [d]
- dispatch[DICT] = load_dict
+ dispatch[DICT[0]] = load_dict
# INST and OBJ differ only in how they get a class object. It's not
# only sensible to do the rest in a common routine, the two routines
@@ -1043,68 +1048,59 @@ class Unpickler:
def _instantiate(self, klass, k):
args = tuple(self.stack[k+1:])
del self.stack[k:]
- instantiated = 0
- if (not args and
- type(klass) is ClassType and
- not hasattr(klass, "__getinitargs__")):
- try:
- value = _EmptyClass()
- value.__class__ = klass
- instantiated = 1
- except RuntimeError:
- # In restricted execution, assignment to inst.__class__ is
- # prohibited
- pass
- if not instantiated:
+ if (args or not isinstance(klass, type) or
+ hasattr(klass, "__getinitargs__")):
try:
value = klass(*args)
- except TypeError, err:
- raise TypeError, "in constructor for %s: %s" % (
- klass.__name__, str(err)), sys.exc_info()[2]
+ except TypeError as err:
+ raise TypeError("in constructor for %s: %s" %
+ (klass.__name__, str(err)), sys.exc_info()[2])
+ else:
+ value = klass.__new__(klass)
self.append(value)
def load_inst(self):
- module = self.readline()[:-1]
- name = self.readline()[:-1]
+ module = self.readline()[:-1].decode("ascii")
+ name = self.readline()[:-1].decode("ascii")
klass = self.find_class(module, name)
self._instantiate(klass, self.marker())
- dispatch[INST] = load_inst
+ dispatch[INST[0]] = load_inst
def load_obj(self):
# Stack is ... markobject classobject arg1 arg2 ...
k = self.marker()
klass = self.stack.pop(k+1)
self._instantiate(klass, k)
- dispatch[OBJ] = load_obj
+ dispatch[OBJ[0]] = load_obj
def load_newobj(self):
args = self.stack.pop()
cls = self.stack[-1]
obj = cls.__new__(cls, *args)
self.stack[-1] = obj
- dispatch[NEWOBJ] = load_newobj
+ dispatch[NEWOBJ[0]] = load_newobj
def load_global(self):
- module = self.readline()[:-1]
- name = self.readline()[:-1]
+ module = self.readline()[:-1].decode("utf-8")
+ name = self.readline()[:-1].decode("utf-8")
klass = self.find_class(module, name)
self.append(klass)
- dispatch[GLOBAL] = load_global
+ dispatch[GLOBAL[0]] = load_global
def load_ext1(self):
code = ord(self.read(1))
self.get_extension(code)
- dispatch[EXT1] = load_ext1
+ dispatch[EXT1[0]] = load_ext1
def load_ext2(self):
- code = mloads('i' + self.read(2) + '\000\000')
+ code = mloads(b'i' + self.read(2) + b'\000\000')
self.get_extension(code)
- dispatch[EXT2] = load_ext2
+ dispatch[EXT2[0]] = load_ext2
def load_ext4(self):
- code = mloads('i' + self.read(4))
+ code = mloads(b'i' + self.read(4))
self.get_extension(code)
- dispatch[EXT4] = load_ext4
+ dispatch[EXT4[0]] = load_ext4
def get_extension(self, code):
nil = []
@@ -1114,14 +1110,22 @@ class Unpickler:
return
key = _inverted_registry.get(code)
if not key:
+ if code <= 0: # note that 0 is forbidden
+ # Corrupt or hostile pickle.
+ raise UnpicklingError("EXT specifies code <= 0");
raise ValueError("unregistered extension code %d" % code)
obj = self.find_class(*key)
_extension_cache[code] = obj
self.append(obj)
def find_class(self, module, name):
- # Subclasses may override this
- __import__(module)
+ # Subclasses may override this.
+ if self.proto < 3 and self.fix_imports:
+ if (module, name) in _compat_pickle.NAME_MAPPING:
+ module, name = _compat_pickle.NAME_MAPPING[(module, name)]
+ if module in _compat_pickle.IMPORT_MAPPING:
+ module = _compat_pickle.IMPORT_MAPPING[module]
+ __import__(module, level=0)
mod = sys.modules[module]
klass = getattr(mod, name)
return klass
@@ -1130,57 +1134,70 @@ class Unpickler:
stack = self.stack
args = stack.pop()
func = stack[-1]
- value = func(*args)
+ try:
+ value = func(*args)
+ except:
+ print(sys.exc_info())
+ print(func, args)
+ raise
stack[-1] = value
- dispatch[REDUCE] = load_reduce
+ dispatch[REDUCE[0]] = load_reduce
def load_pop(self):
del self.stack[-1]
- dispatch[POP] = load_pop
+ dispatch[POP[0]] = load_pop
def load_pop_mark(self):
k = self.marker()
del self.stack[k:]
- dispatch[POP_MARK] = load_pop_mark
+ dispatch[POP_MARK[0]] = load_pop_mark
def load_dup(self):
self.append(self.stack[-1])
- dispatch[DUP] = load_dup
+ dispatch[DUP[0]] = load_dup
def load_get(self):
- self.append(self.memo[self.readline()[:-1]])
- dispatch[GET] = load_get
+ i = int(self.readline()[:-1])
+ self.append(self.memo[i])
+ dispatch[GET[0]] = load_get
def load_binget(self):
- i = ord(self.read(1))
- self.append(self.memo[repr(i)])
- dispatch[BINGET] = load_binget
+ i = self.read(1)[0]
+ self.append(self.memo[i])
+ dispatch[BINGET[0]] = load_binget
- def load_long_binget(self):
- i = mloads('i' + self.read(4))
- self.append(self.memo[repr(i)])
- dispatch[LONG_BINGET] = load_long_binget
+ def load_long_binget(self, unpack=struct.unpack):
+ i, = unpack('<I', self.read(4))
+ self.append(self.memo[i])
+ dispatch[LONG_BINGET[0]] = load_long_binget
def load_put(self):
- self.memo[self.readline()[:-1]] = self.stack[-1]
- dispatch[PUT] = load_put
+ i = int(self.readline()[:-1])
+ if i < 0:
+ raise ValueError("negative PUT argument")
+ self.memo[i] = self.stack[-1]
+ dispatch[PUT[0]] = load_put
def load_binput(self):
- i = ord(self.read(1))
- self.memo[repr(i)] = self.stack[-1]
- dispatch[BINPUT] = load_binput
-
- def load_long_binput(self):
- i = mloads('i' + self.read(4))
- self.memo[repr(i)] = self.stack[-1]
- dispatch[LONG_BINPUT] = load_long_binput
+ i = self.read(1)[0]
+ if i < 0:
+ raise ValueError("negative BINPUT argument")
+ self.memo[i] = self.stack[-1]
+ dispatch[BINPUT[0]] = load_binput
+
+ def load_long_binput(self, unpack=struct.unpack, maxsize=sys.maxsize):
+ i, = unpack('<I', self.read(4))
+ if i > maxsize:
+ raise ValueError("negative LONG_BINPUT argument")
+ self.memo[i] = self.stack[-1]
+ dispatch[LONG_BINPUT[0]] = load_long_binput
def load_append(self):
stack = self.stack
value = stack.pop()
list = stack[-1]
list.append(value)
- dispatch[APPEND] = load_append
+ dispatch[APPEND[0]] = load_append
def load_appends(self):
stack = self.stack
@@ -1188,7 +1205,7 @@ class Unpickler:
list = stack[mark - 1]
list.extend(stack[mark + 1:])
del stack[mark:]
- dispatch[APPENDS] = load_appends
+ dispatch[APPENDS[0]] = load_appends
def load_setitem(self):
stack = self.stack
@@ -1196,7 +1213,7 @@ class Unpickler:
key = stack.pop()
dict = stack[-1]
dict[key] = value
- dispatch[SETITEM] = load_setitem
+ dispatch[SETITEM[0]] = load_setitem
def load_setitems(self):
stack = self.stack
@@ -1206,7 +1223,7 @@ class Unpickler:
dict[stack[i]] = stack[i + 1]
del stack[mark:]
- dispatch[SETITEMS] = load_setitems
+ dispatch[SETITEMS[0]] = load_setitems
def load_build(self):
stack = self.stack
@@ -1220,172 +1237,134 @@ class Unpickler:
if isinstance(state, tuple) and len(state) == 2:
state, slotstate = state
if state:
- try:
- d = inst.__dict__
- try:
- for k, v in state.iteritems():
- d[intern(k)] = v
- # keys in state don't have to be strings
- # don't blow up, but don't go out of our way
- except TypeError:
- d.update(state)
-
- except RuntimeError:
- # XXX In restricted execution, the instance's __dict__
- # is not accessible. Use the old way of unpickling
- # the instance variables. This is a semantic
- # difference when unpickling in restricted
- # vs. unrestricted modes.
- # Note, however, that cPickle has never tried to do the
- # .update() business, and always uses
- # PyObject_SetItem(inst.__dict__, key, value) in a
- # loop over state.items().
- for k, v in state.items():
- setattr(inst, k, v)
+ inst_dict = inst.__dict__
+ intern = sys.intern
+ for k, v in state.items():
+ if type(k) is str:
+ inst_dict[intern(k)] = v
+ else:
+ inst_dict[k] = v
if slotstate:
for k, v in slotstate.items():
setattr(inst, k, v)
- dispatch[BUILD] = load_build
+ dispatch[BUILD[0]] = load_build
def load_mark(self):
self.append(self.mark)
- dispatch[MARK] = load_mark
+ dispatch[MARK[0]] = load_mark
def load_stop(self):
value = self.stack.pop()
raise _Stop(value)
- dispatch[STOP] = load_stop
+ dispatch[STOP[0]] = load_stop
-# Helper class for load_inst/load_obj
-
-class _EmptyClass:
- pass
-
-# Encode/decode longs in linear time.
-
-import binascii as _binascii
+# Encode/decode longs.
def encode_long(x):
r"""Encode a long to a two's complement little-endian binary string.
- Note that 0L is a special case, returning an empty string, to save a
+ Note that 0 is a special case, returning an empty string, to save a
byte in the LONG1 pickling context.
- >>> encode_long(0L)
- ''
- >>> encode_long(255L)
- '\xff\x00'
- >>> encode_long(32767L)
- '\xff\x7f'
- >>> encode_long(-256L)
- '\x00\xff'
- >>> encode_long(-32768L)
- '\x00\x80'
- >>> encode_long(-128L)
- '\x80'
- >>> encode_long(127L)
- '\x7f'
+ >>> encode_long(0)
+ b''
+ >>> encode_long(255)
+ b'\xff\x00'
+ >>> encode_long(32767)
+ b'\xff\x7f'
+ >>> encode_long(-256)
+ b'\x00\xff'
+ >>> encode_long(-32768)
+ b'\x00\x80'
+ >>> encode_long(-128)
+ b'\x80'
+ >>> encode_long(127)
+ b'\x7f'
>>>
"""
-
if x == 0:
- return ''
- if x > 0:
- ashex = hex(x)
- assert ashex.startswith("0x")
- njunkchars = 2 + ashex.endswith('L')
- nibbles = len(ashex) - njunkchars
- if nibbles & 1:
- # need an even # of nibbles for unhexlify
- ashex = "0x0" + ashex[2:]
- elif int(ashex[2], 16) >= 8:
- # "looks negative", so need a byte of sign bits
- ashex = "0x00" + ashex[2:]
- else:
- # Build the 256's-complement: (1L << nbytes) + x. The trick is
- # to find the number of bytes in linear time (although that should
- # really be a constant-time task).
- ashex = hex(-x)
- assert ashex.startswith("0x")
- njunkchars = 2 + ashex.endswith('L')
- nibbles = len(ashex) - njunkchars
- if nibbles & 1:
- # Extend to a full byte.
- nibbles += 1
- nbits = nibbles * 4
- x += 1L << nbits
- assert x > 0
- ashex = hex(x)
- njunkchars = 2 + ashex.endswith('L')
- newnibbles = len(ashex) - njunkchars
- if newnibbles < nibbles:
- ashex = "0x" + "0" * (nibbles - newnibbles) + ashex[2:]
- if int(ashex[2], 16) < 8:
- # "looks positive", so need a byte of sign bits
- ashex = "0xff" + ashex[2:]
-
- if ashex.endswith('L'):
- ashex = ashex[2:-1]
- else:
- ashex = ashex[2:]
- assert len(ashex) & 1 == 0, (x, ashex)
- binary = _binascii.unhexlify(ashex)
- return binary[::-1]
+ return b''
+ nbytes = (x.bit_length() >> 3) + 1
+ result = x.to_bytes(nbytes, byteorder='little', signed=True)
+ if x < 0 and nbytes > 1:
+ if result[-1] == 0xff and (result[-2] & 0x80) != 0:
+ result = result[:-1]
+ return result
def decode_long(data):
r"""Decode a long from a two's complement little-endian binary string.
- >>> decode_long('')
- 0L
- >>> decode_long("\xff\x00")
- 255L
- >>> decode_long("\xff\x7f")
- 32767L
- >>> decode_long("\x00\xff")
- -256L
- >>> decode_long("\x00\x80")
- -32768L
- >>> decode_long("\x80")
- -128L
- >>> decode_long("\x7f")
- 127L
+ >>> decode_long(b'')
+ 0
+ >>> decode_long(b"\xff\x00")
+ 255
+ >>> decode_long(b"\xff\x7f")
+ 32767
+ >>> decode_long(b"\x00\xff")
+ -256
+ >>> decode_long(b"\x00\x80")
+ -32768
+ >>> decode_long(b"\x80")
+ -128
+ >>> decode_long(b"\x7f")
+ 127
"""
-
- nbytes = len(data)
- if nbytes == 0:
- return 0L
- ashex = _binascii.hexlify(data[::-1])
- n = long(ashex, 16) # quadratic time before Python 2.3; linear now
- if data[-1] >= '\x80':
- n -= 1L << (nbytes * 8)
- return n
+ return int.from_bytes(data, byteorder='little', signed=True)
# Shorthands
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+def dump(obj, file, protocol=None, *, fix_imports=True):
+ Pickler(file, protocol, fix_imports=fix_imports).dump(obj)
-def dump(obj, file, protocol=None):
- Pickler(file, protocol).dump(obj)
+def dumps(obj, protocol=None, *, fix_imports=True):
+ f = io.BytesIO()
+ Pickler(f, protocol, fix_imports=fix_imports).dump(obj)
+ res = f.getvalue()
+ assert isinstance(res, bytes_types)
+ return res
-def dumps(obj, protocol=None):
- file = StringIO()
- Pickler(file, protocol).dump(obj)
- return file.getvalue()
+def load(file, *, fix_imports=True, encoding="ASCII", errors="strict"):
+ return Unpickler(file, fix_imports=fix_imports,
+ encoding=encoding, errors=errors).load()
-def load(file):
- return Unpickler(file).load()
+def loads(s, *, fix_imports=True, encoding="ASCII", errors="strict"):
+ if isinstance(s, str):
+ raise TypeError("Can't load pickle from unicode string")
+ file = io.BytesIO(s)
+ return Unpickler(file, fix_imports=fix_imports,
+ encoding=encoding, errors=errors).load()
-def loads(str):
- file = StringIO(str)
- return Unpickler(file).load()
+# Use the faster _pickle if possible
+try:
+ from _pickle import *
+except ImportError:
+ Pickler, Unpickler = _Pickler, _Unpickler
# Doctest
-
def _test():
import doctest
return doctest.testmod()
if __name__ == "__main__":
- _test()
+ import sys, argparse
+ parser = argparse.ArgumentParser(
+ description='display contents of the pickle files')
+ parser.add_argument(
+ 'pickle_file', type=argparse.FileType('br'),
+ nargs='*', help='the pickle file')
+ parser.add_argument(
+ '-t', '--test', action='store_true',
+ help='run self-test suite')
+ parser.add_argument(
+ '-v', action='store_true',
+ help='run verbosely; only affects self-test run')
+ args = parser.parse_args()
+ if args.test:
+ _test()
+ else:
+ if not args.pickle_file:
+ parser.print_help()
+ else:
+ import pprint
+ for f in args.pickle_file:
+ obj = load(f)
+ pprint.pprint(obj)
diff --git a/Lib/pickletools.py b/Lib/pickletools.py
index d717728d417..ec6cc53ae31 100644
--- a/Lib/pickletools.py
+++ b/Lib/pickletools.py
@@ -10,8 +10,14 @@ dis(pickle, out=None, memo=None, indentlevel=4)
Print a symbolic disassembly of a pickle.
'''
+import codecs
+import pickle
+import re
+
__all__ = ['dis', 'genops', 'optimize']
+bytes_types = pickle.bytes_types
+
# Other ideas:
#
# - A pickle verifier: read a pickle and check it exhaustively for
@@ -136,7 +142,7 @@ this and there isn't a use case that warrants the expense of such an
analysis.
To this end, all tests for __safe_for_unpickling__ or for
-copy_reg.safe_constructors are removed from the unpickling code.
+copyreg.safe_constructors are removed from the unpickling code.
References to these variables in the descriptions below are to be seen
as describing unpickling in Python 2.2 and before.
"""
@@ -200,14 +206,14 @@ from struct import unpack as _unpack
def read_uint1(f):
r"""
- >>> import StringIO
- >>> read_uint1(StringIO.StringIO('\xff'))
+ >>> import io
+ >>> read_uint1(io.BytesIO(b'\xff'))
255
"""
data = f.read(1)
if data:
- return ord(data)
+ return data[0]
raise ValueError("not enough data in stream to read uint1")
uint1 = ArgumentDescriptor(
@@ -219,10 +225,10 @@ uint1 = ArgumentDescriptor(
def read_uint2(f):
r"""
- >>> import StringIO
- >>> read_uint2(StringIO.StringIO('\xff\x00'))
+ >>> import io
+ >>> read_uint2(io.BytesIO(b'\xff\x00'))
255
- >>> read_uint2(StringIO.StringIO('\xff\xff'))
+ >>> read_uint2(io.BytesIO(b'\xff\xff'))
65535
"""
@@ -240,10 +246,10 @@ uint2 = ArgumentDescriptor(
def read_int4(f):
r"""
- >>> import StringIO
- >>> read_int4(StringIO.StringIO('\xff\x00\x00\x00'))
+ >>> import io
+ >>> read_int4(io.BytesIO(b'\xff\x00\x00\x00'))
255
- >>> read_int4(StringIO.StringIO('\x00\x00\x00\x80')) == -(2**31)
+ >>> read_int4(io.BytesIO(b'\x00\x00\x00\x80')) == -(2**31)
True
"""
@@ -261,38 +267,38 @@ int4 = ArgumentDescriptor(
def read_stringnl(f, decode=True, stripquotes=True):
r"""
- >>> import StringIO
- >>> read_stringnl(StringIO.StringIO("'abcd'\nefg\n"))
+ >>> import io
+ >>> read_stringnl(io.BytesIO(b"'abcd'\nefg\n"))
'abcd'
- >>> read_stringnl(StringIO.StringIO("\n"))
+ >>> read_stringnl(io.BytesIO(b"\n"))
Traceback (most recent call last):
...
- ValueError: no string quotes around ''
+ ValueError: no string quotes around b''
- >>> read_stringnl(StringIO.StringIO("\n"), stripquotes=False)
+ >>> read_stringnl(io.BytesIO(b"\n"), stripquotes=False)
''
- >>> read_stringnl(StringIO.StringIO("''\n"))
+ >>> read_stringnl(io.BytesIO(b"''\n"))
''
- >>> read_stringnl(StringIO.StringIO('"abcd"'))
+ >>> read_stringnl(io.BytesIO(b'"abcd"'))
Traceback (most recent call last):
...
ValueError: no newline found when trying to read stringnl
Embedded escapes are undone in the result.
- >>> read_stringnl(StringIO.StringIO(r"'a\n\\b\x00c\td'" + "\n'e'"))
+ >>> read_stringnl(io.BytesIO(br"'a\n\\b\x00c\td'" + b"\n'e'"))
'a\n\\b\x00c\td'
"""
data = f.readline()
- if not data.endswith('\n'):
+ if not data.endswith(b'\n'):
raise ValueError("no newline found when trying to read stringnl")
data = data[:-1] # lose the newline
if stripquotes:
- for q in "'\"":
+ for q in (b'"', b"'"):
if data.startswith(q):
if not data.endswith(q):
raise ValueError("strinq quote %r not found at both "
@@ -302,10 +308,8 @@ def read_stringnl(f, decode=True, stripquotes=True):
else:
raise ValueError("no string quotes around %r" % data)
- # I'm not sure when 'string_escape' was added to the std codecs; it's
- # crazy not to use it if it's there.
if decode:
- data = data.decode('string_escape')
+ data = codecs.escape_decode(data)[0].decode("ascii")
return data
stringnl = ArgumentDescriptor(
@@ -319,7 +323,7 @@ stringnl = ArgumentDescriptor(
""")
def read_stringnl_noescape(f):
- return read_stringnl(f, decode=False, stripquotes=False)
+ return read_stringnl(f, stripquotes=False)
stringnl_noescape = ArgumentDescriptor(
name='stringnl_noescape',
@@ -334,8 +338,8 @@ stringnl_noescape = ArgumentDescriptor(
def read_stringnl_noescape_pair(f):
r"""
- >>> import StringIO
- >>> read_stringnl_noescape_pair(StringIO.StringIO("Queue\nEmpty\njunk"))
+ >>> import io
+ >>> read_stringnl_noescape_pair(io.BytesIO(b"Queue\nEmpty\njunk"))
'Queue Empty'
"""
@@ -356,12 +360,12 @@ stringnl_noescape_pair = ArgumentDescriptor(
def read_string4(f):
r"""
- >>> import StringIO
- >>> read_string4(StringIO.StringIO("\x00\x00\x00\x00abc"))
+ >>> import io
+ >>> read_string4(io.BytesIO(b"\x00\x00\x00\x00abc"))
''
- >>> read_string4(StringIO.StringIO("\x03\x00\x00\x00abcdef"))
+ >>> read_string4(io.BytesIO(b"\x03\x00\x00\x00abcdef"))
'abc'
- >>> read_string4(StringIO.StringIO("\x00\x00\x00\x03abcdef"))
+ >>> read_string4(io.BytesIO(b"\x00\x00\x00\x03abcdef"))
Traceback (most recent call last):
...
ValueError: expected 50331648 bytes in a string4, but only 6 remain
@@ -372,7 +376,7 @@ def read_string4(f):
raise ValueError("string4 byte count < 0: %d" % n)
data = f.read(n)
if len(data) == n:
- return data
+ return data.decode("latin-1")
raise ValueError("expected %d bytes in a string4, but only %d remain" %
(n, len(data)))
@@ -390,10 +394,10 @@ string4 = ArgumentDescriptor(
def read_string1(f):
r"""
- >>> import StringIO
- >>> read_string1(StringIO.StringIO("\x00"))
+ >>> import io
+ >>> read_string1(io.BytesIO(b"\x00"))
''
- >>> read_string1(StringIO.StringIO("\x03abcdef"))
+ >>> read_string1(io.BytesIO(b"\x03abcdef"))
'abc'
"""
@@ -401,7 +405,7 @@ def read_string1(f):
assert n >= 0
data = f.read(n)
if len(data) == n:
- return data
+ return data.decode("latin-1")
raise ValueError("expected %d bytes in a string1, but only %d remain" %
(n, len(data)))
@@ -419,17 +423,17 @@ string1 = ArgumentDescriptor(
def read_unicodestringnl(f):
r"""
- >>> import StringIO
- >>> read_unicodestringnl(StringIO.StringIO("abc\uabcd\njunk"))
- u'abc\uabcd'
+ >>> import io
+ >>> read_unicodestringnl(io.BytesIO(b"abc\\uabcd\njunk")) == 'abc\uabcd'
+ True
"""
data = f.readline()
- if not data.endswith('\n'):
+ if not data.endswith(b'\n'):
raise ValueError("no newline found when trying to read "
"unicodestringnl")
data = data[:-1] # lose the newline
- return unicode(data, 'raw-unicode-escape')
+ return str(data, 'raw-unicode-escape')
unicodestringnl = ArgumentDescriptor(
name='unicodestringnl',
@@ -444,17 +448,17 @@ unicodestringnl = ArgumentDescriptor(
def read_unicodestring4(f):
r"""
- >>> import StringIO
- >>> s = u'abcd\uabcd'
+ >>> import io
+ >>> s = 'abcd\uabcd'
>>> enc = s.encode('utf-8')
>>> enc
- 'abcd\xea\xaf\x8d'
- >>> n = chr(len(enc)) + chr(0) * 3 # little-endian 4-byte length
- >>> t = read_unicodestring4(StringIO.StringIO(n + enc + 'junk'))
+ b'abcd\xea\xaf\x8d'
+ >>> n = bytes([len(enc), 0, 0, 0]) # little-endian 4-byte length
+ >>> t = read_unicodestring4(io.BytesIO(n + enc + b'junk'))
>>> s == t
True
- >>> read_unicodestring4(StringIO.StringIO(n + enc[:-1]))
+ >>> read_unicodestring4(io.BytesIO(n + enc[:-1]))
Traceback (most recent call last):
...
ValueError: expected 7 bytes in a unicodestring4, but only 6 remain
@@ -465,7 +469,7 @@ def read_unicodestring4(f):
raise ValueError("unicodestring4 byte count < 0: %d" % n)
data = f.read(n)
if len(data) == n:
- return unicode(data, 'utf-8')
+ return str(data, 'utf-8', 'surrogatepass')
raise ValueError("expected %d bytes in a unicodestring4, but only %d "
"remain" % (n, len(data)))
@@ -484,55 +488,48 @@ unicodestring4 = ArgumentDescriptor(
def read_decimalnl_short(f):
r"""
- >>> import StringIO
- >>> read_decimalnl_short(StringIO.StringIO("1234\n56"))
+ >>> import io
+ >>> read_decimalnl_short(io.BytesIO(b"1234\n56"))
1234
- >>> read_decimalnl_short(StringIO.StringIO("1234L\n56"))
+ >>> read_decimalnl_short(io.BytesIO(b"1234L\n56"))
Traceback (most recent call last):
...
- ValueError: trailing 'L' not allowed in '1234L'
+ ValueError: trailing 'L' not allowed in b'1234L'
"""
s = read_stringnl(f, decode=False, stripquotes=False)
- if s.endswith("L"):
+ if s.endswith(b"L"):
raise ValueError("trailing 'L' not allowed in %r" % s)
# It's not necessarily true that the result fits in a Python short int:
# the pickle may have been written on a 64-bit box. There's also a hack
# for True and False here.
- if s == "00":
+ if s == b"00":
return False
- elif s == "01":
+ elif s == b"01":
return True
try:
return int(s)
except OverflowError:
- return long(s)
+ return int(s)
def read_decimalnl_long(f):
r"""
- >>> import StringIO
+ >>> import io
- >>> read_decimalnl_long(StringIO.StringIO("1234\n56"))
- Traceback (most recent call last):
- ...
- ValueError: trailing 'L' required in '1234'
-
- Someday the trailing 'L' will probably go away from this output.
-
- >>> read_decimalnl_long(StringIO.StringIO("1234L\n56"))
- 1234L
+ >>> read_decimalnl_long(io.BytesIO(b"1234L\n56"))
+ 1234
- >>> read_decimalnl_long(StringIO.StringIO("123456789012345678901234L\n6"))
- 123456789012345678901234L
+ >>> read_decimalnl_long(io.BytesIO(b"123456789012345678901234L\n6"))
+ 123456789012345678901234
"""
s = read_stringnl(f, decode=False, stripquotes=False)
- if not s.endswith("L"):
- raise ValueError("trailing 'L' required in %r" % s)
- return long(s)
+ if s[-1:] == b'L':
+ s = s[:-1]
+ return int(s)
decimalnl_short = ArgumentDescriptor(
@@ -561,8 +558,8 @@ decimalnl_long = ArgumentDescriptor(
def read_floatnl(f):
r"""
- >>> import StringIO
- >>> read_floatnl(StringIO.StringIO("-1.25\n6"))
+ >>> import io
+ >>> read_floatnl(io.BytesIO(b"-1.25\n6"))
-1.25
"""
s = read_stringnl(f, decode=False, stripquotes=False)
@@ -583,11 +580,11 @@ floatnl = ArgumentDescriptor(
def read_float8(f):
r"""
- >>> import StringIO, struct
+ >>> import io, struct
>>> raw = struct.pack(">d", -1.25)
>>> raw
- '\xbf\xf4\x00\x00\x00\x00\x00\x00'
- >>> read_float8(StringIO.StringIO(raw + "\n"))
+ b'\xbf\xf4\x00\x00\x00\x00\x00\x00'
+ >>> read_float8(io.BytesIO(raw + b"\n"))
-1.25
"""
@@ -604,7 +601,7 @@ float8 = ArgumentDescriptor(
doc="""An 8-byte binary representation of a float, big-endian.
The format is unique to Python, and shared with the struct
- module (format string '>d') "in theory" (the struct and cPickle
+ module (format string '>d') "in theory" (the struct and pickle
implementations don't share the code -- they should). It's
strongly related to the IEEE-754 double format, and, in normal
cases, is in fact identical to the big-endian 754 double format.
@@ -621,17 +618,17 @@ from pickle import decode_long
def read_long1(f):
r"""
- >>> import StringIO
- >>> read_long1(StringIO.StringIO("\x00"))
- 0L
- >>> read_long1(StringIO.StringIO("\x02\xff\x00"))
- 255L
- >>> read_long1(StringIO.StringIO("\x02\xff\x7f"))
- 32767L
- >>> read_long1(StringIO.StringIO("\x02\x00\xff"))
- -256L
- >>> read_long1(StringIO.StringIO("\x02\x00\x80"))
- -32768L
+ >>> import io
+ >>> read_long1(io.BytesIO(b"\x00"))
+ 0
+ >>> read_long1(io.BytesIO(b"\x02\xff\x00"))
+ 255
+ >>> read_long1(io.BytesIO(b"\x02\xff\x7f"))
+ 32767
+ >>> read_long1(io.BytesIO(b"\x02\x00\xff"))
+ -256
+ >>> read_long1(io.BytesIO(b"\x02\x00\x80"))
+ -32768
"""
n = read_uint1(f)
@@ -653,17 +650,17 @@ long1 = ArgumentDescriptor(
def read_long4(f):
r"""
- >>> import StringIO
- >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x00"))
- 255L
- >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\xff\x7f"))
- 32767L
- >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\xff"))
- -256L
- >>> read_long4(StringIO.StringIO("\x02\x00\x00\x00\x00\x80"))
- -32768L
- >>> read_long1(StringIO.StringIO("\x00\x00\x00\x00"))
- 0L
+ >>> import io
+ >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x00"))
+ 255
+ >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\xff\x7f"))
+ 32767
+ >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\xff"))
+ -256
+ >>> read_long4(io.BytesIO(b"\x02\x00\x00\x00\x00\x80"))
+ -32768
+ >>> read_long1(io.BytesIO(b"\x00\x00\x00\x00"))
+ 0
"""
n = read_int4(f)
@@ -683,7 +680,7 @@ long4 = ArgumentDescriptor(
This first reads four bytes as a signed size (but requires the
size to be >= 0), then reads that many bytes and interprets them
as a little-endian 2's-complement long. If the size is 0, that's taken
- as a shortcut for the long 0L, although LONG1 should really be used
+ as a shortcut for the int 0, although LONG1 should really be used
then instead (and in any case where # of bytes < 256).
""")
@@ -731,12 +728,12 @@ pyint = StackObject(
pylong = StackObject(
name='long',
- obtype=long,
+ obtype=int,
doc="A long (as opposed to short) Python integer object.")
pyinteger_or_bool = StackObject(
name='int_or_bool',
- obtype=(int, long, bool),
+ obtype=(int, bool),
doc="A Python integer object (short or long), or "
"a Python bool.")
@@ -751,14 +748,19 @@ pyfloat = StackObject(
doc="A Python float object.")
pystring = StackObject(
- name='str',
- obtype=str,
- doc="A Python string object.")
+ name='string',
+ obtype=bytes,
+ doc="A Python (8-bit) string object.")
+
+pybytes = StackObject(
+ name='bytes',
+ obtype=bytes,
+ doc="A Python bytes object.")
pyunicode = StackObject(
- name='unicode',
- obtype=unicode,
- doc="A Python Unicode string object.")
+ name='str',
+ obtype=str,
+ doc="A Python (Unicode) string object.")
pynone = StackObject(
name="None",
@@ -873,7 +875,7 @@ class OpcodeInfo(object):
assert isinstance(x, StackObject)
self.stack_after = stack_after
- assert isinstance(proto, int) and 0 <= proto <= 2
+ assert isinstance(proto, int) and 0 <= proto <= 3
self.proto = proto
assert isinstance(doc, str)
@@ -1000,7 +1002,9 @@ opcodes = [
The argument is a repr-style string, with bracketing quote characters,
and perhaps embedded escapes. The argument extends until the next
- newline character.
+ newline character. (Actually, they are decoded into a str instance
+ using the encoding given to the Unpickler constructor. or the default,
+ 'ASCII'.)
"""),
I(name='BINSTRING',
@@ -1013,7 +1017,9 @@ opcodes = [
There are two arguments: the first is a 4-byte little-endian signed int
giving the number of bytes in the string, and the second is that many
- bytes, which are taken literally as the string content.
+ bytes, which are taken literally as the string content. (Actually,
+ they are decoded into a str instance using the encoding given to the
+ Unpickler constructor. or the default, 'ASCII'.)
"""),
I(name='SHORT_BINSTRING',
@@ -1026,6 +1032,36 @@ opcodes = [
There are two arguments: the first is a 1-byte unsigned int giving
the number of bytes in the string, and the second is that many bytes,
+ which are taken literally as the string content. (Actually, they
+ are decoded into a str instance using the encoding given to the
+ Unpickler constructor. or the default, 'ASCII'.)
+ """),
+
+ # Bytes (protocol 3 only; older protocols don't support bytes at all)
+
+ I(name='BINBYTES',
+ code='B',
+ arg=string4,
+ stack_before=[],
+ stack_after=[pybytes],
+ proto=3,
+ doc="""Push a Python bytes object.
+
+ There are two arguments: the first is a 4-byte little-endian signed int
+ giving the number of bytes in the string, and the second is that many
+ bytes, which are taken literally as the bytes content.
+ """),
+
+ I(name='SHORT_BINBYTES',
+ code='C',
+ arg=string1,
+ stack_before=[],
+ stack_after=[pybytes],
+ proto=3,
+ doc="""Push a Python string object.
+
+ There are two arguments: the first is a 1-byte unsigned int giving
+ the number of bytes in the string, and the second is that many bytes,
which are taken literally as the string content.
"""),
@@ -1527,8 +1563,8 @@ opcodes = [
opcode is followed by code to create setstate's argument, and then a
BUILD opcode to apply __setstate__ to that argument.
- If type(callable) is not ClassType, REDUCE complains unless the
- callable has been registered with the copy_reg module's
+ If not isinstance(callable, type), REDUCE complains unless the
+ callable has been registered with the copyreg module's
safe_constructors dict, or the callable has a magic
'__safe_for_unpickling__' attribute with a true value. I'm not sure
why it does this, but I've sure seen this complaint often enough when
@@ -1558,13 +1594,6 @@ opcodes = [
the object is updated via
anyobject.__dict__.update(argument)
-
- This may raise RuntimeError in restricted execution mode (which
- disallows access to __dict__ directly); in that case, the object
- is updated instead via
-
- for k, v in argument.items():
- anyobject[k] = v
"""),
I(name='INST',
@@ -1590,9 +1619,6 @@ opcodes = [
+ The argtuple is empty (markobject was at the top of the stack
at the start).
- + It's an old-style class object (the type of the class object is
- ClassType).
-
+ The class object does not have a __getinitargs__ attribute.
then we want to create an old-style class instance without invoking
@@ -1600,20 +1626,15 @@ opcodes = [
calling __init__() is current wisdom). In this case, an instance of
an old-style dummy class is created, and then we try to rebind its
__class__ attribute to the desired class object. If this succeeds,
- the new instance object is pushed on the stack, and we're done. In
- restricted execution mode it can fail (assignment to __class__ is
- disallowed), and I'm not really sure what happens then -- it looks
- like the code ends up calling the class object's __init__ anyway,
- via falling into the next case.
+ the new instance object is pushed on the stack, and we're done.
Else (the argtuple is not empty, it's not an old-style class object,
or the class object does have a __getinitargs__ attribute), the code
first insists that the class object have a __safe_for_unpickling__
attribute. Unlike as for the __safe_for_unpickling__ check in REDUCE,
it doesn't matter whether this attribute has a true or false value, it
- only matters whether it exists (XXX this is a bug; cPickle
- requires the attribute to be true). If __safe_for_unpickling__
- doesn't exist, UnpicklingError is raised.
+ only matters whether it exists (XXX this is a bug). If
+ __safe_for_unpickling__ doesn't exist, UnpicklingError is raised.
Else (the class object does have a __safe_for_unpickling__ attr),
the class object obtained from INST's arguments is applied to the
@@ -1648,8 +1669,7 @@ opcodes = [
As for INST, the remainder of the stack above the markobject is
gathered into an argument tuple, and then the logic seems identical,
except that no __safe_for_unpickling__ check is done (XXX this is
- a bug; cPickle does test __safe_for_unpickling__). See INST for
- the gory details.
+ a bug). See INST for the gory details.
NOTE: In Python 2.3, INST and OBJ are identical except for how they
get the class object. That was always the intent; the implementations
@@ -1761,24 +1781,24 @@ for d in opcodes:
del d
def assure_pickle_consistency(verbose=False):
- import pickle, re
copy = code2op.copy()
for name in pickle.__all__:
if not re.match("[A-Z][A-Z0-9_]+$", name):
if verbose:
- print "skipping %r: it doesn't look like an opcode name" % name
+ print("skipping %r: it doesn't look like an opcode name" % name)
continue
picklecode = getattr(pickle, name)
- if not isinstance(picklecode, str) or len(picklecode) != 1:
+ if not isinstance(picklecode, bytes) or len(picklecode) != 1:
if verbose:
- print ("skipping %r: value %r doesn't look like a pickle "
- "code" % (name, picklecode))
+ print(("skipping %r: value %r doesn't look like a pickle "
+ "code" % (name, picklecode)))
continue
+ picklecode = picklecode.decode("latin-1")
if picklecode in copy:
if verbose:
- print "checking name %r w/ code %r for consistency" % (
- name, picklecode)
+ print("checking name %r w/ code %r for consistency" % (
+ name, picklecode))
d = copy[picklecode]
if d.name != name:
raise ValueError("for pickle code %r, pickle.py uses name %r "
@@ -1822,16 +1842,15 @@ def genops(pickle):
is None.
If the pickle has a tell() method, pos was the value of pickle.tell()
- before reading the current opcode. If the pickle is a string object,
- it's wrapped in a StringIO object, and the latter's tell() result is
+ before reading the current opcode. If the pickle is a bytes object,
+ it's wrapped in a BytesIO object, and the latter's tell() result is
used. Else (the pickle doesn't have a tell(), and it's not obvious how
to query its current position) pos is None.
"""
- import cStringIO as StringIO
-
- if isinstance(pickle, str):
- pickle = StringIO.StringIO(pickle)
+ if isinstance(pickle, bytes_types):
+ import io
+ pickle = io.BytesIO(pickle)
if hasattr(pickle, "tell"):
getpos = pickle.tell
@@ -1841,9 +1860,9 @@ def genops(pickle):
while True:
pos = getpos()
code = pickle.read(1)
- opcode = code2op.get(code)
+ opcode = code2op.get(code.decode("latin-1"))
if opcode is None:
- if code == "":
+ if code == b"":
raise ValueError("pickle exhausted before seeing STOP")
else:
raise ValueError("at position %s, opcode %r unknown" % (
@@ -1854,7 +1873,7 @@ def genops(pickle):
else:
arg = opcode.arg.reader(pickle)
yield opcode, arg, pos
- if code == '.':
+ if code == b'.':
assert opcode.name == 'STOP'
break
@@ -1883,12 +1902,12 @@ def optimize(p):
s.append(p[i:j])
i = stop
s.append(p[i:])
- return ''.join(s)
+ return b''.join(s)
##############################################################################
# A symbolic pickle disassembler.
-def dis(pickle, out=None, memo=None, indentlevel=4):
+def dis(pickle, out=None, memo=None, indentlevel=4, annotate=0):
"""Produce a symbolic disassembly of a pickle.
'pickle' is a file-like object, or string, containing a (at least one)
@@ -1904,9 +1923,15 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
to proceed across multiple pickles that were all created by the same
pickler with the same memo. Ordinarily you don't need to worry about this.
- Optional arg indentlevel is the number of blanks by which to indent
+ Optional arg 'indentlevel' is the number of blanks by which to indent
a new MARK level. It defaults to 4.
+ Optional arg 'annotate' if nonzero instructs dis() to add short
+ description of the opcode on each line of disassembled output.
+ The value given to 'annotate' must be an integer and is used as a
+ hint for the column where annotation should start. The default
+ value is 0, meaning no annotations.
+
In addition to printing the disassembly, some sanity checks are made:
+ All embedded opcode arguments "make sense".
@@ -1934,9 +1959,10 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
markstack = [] # bytecode positions of MARK opcodes
indentchunk = ' ' * indentlevel
errormsg = None
+ annocol = annotate # columnt hint for annotations
for opcode, arg, pos in genops(pickle):
if pos is not None:
- print >> out, "%5d:" % pos,
+ print("%5d:" % pos, end=' ', file=out)
line = "%-4s %s%s" % (repr(opcode.code)[1:-1],
indentchunk * len(markstack),
@@ -2001,7 +2027,14 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
line += ' ' + repr(arg)
if markmsg:
line += ' ' + markmsg
- print >> out, line
+ if annotate:
+ line += ' ' * (annocol - len(line))
+ # make a mild effort to align annotations
+ annocol = len(line)
+ if annocol > 50:
+ annocol = annotate
+ line += ' ' + opcode.doc.split('\n', 1)[0]
+ print(line, file=out)
if errormsg:
# Note that we delayed complaining until the offending opcode
@@ -2020,7 +2053,7 @@ def dis(pickle, out=None, memo=None, indentlevel=4):
stack.extend(after)
- print >> out, "highest protocol among opcodes =", maxproto
+ print("highest protocol among opcodes =", maxproto, file=out)
if stack:
raise ValueError("stack not empty after STOP: %r" % stack)
@@ -2031,38 +2064,47 @@ class _Example:
_dis_test = r"""
>>> import pickle
->>> x = [1, 2, (3, 4), {'abc': u"def"}]
->>> pkl = pickle.dumps(x, 0)
->>> dis(pkl)
+>>> x = [1, 2, (3, 4), {b'abc': "def"}]
+>>> pkl0 = pickle.dumps(x, 0)
+>>> dis(pkl0)
0: ( MARK
1: l LIST (MARK at 0)
2: p PUT 0
- 5: I INT 1
- 8: a APPEND
- 9: I INT 2
- 12: a APPEND
- 13: ( MARK
- 14: I INT 3
- 17: I INT 4
- 20: t TUPLE (MARK at 13)
- 21: p PUT 1
- 24: a APPEND
- 25: ( MARK
- 26: d DICT (MARK at 25)
- 27: p PUT 2
- 30: S STRING 'abc'
- 37: p PUT 3
- 40: V UNICODE u'def'
- 45: p PUT 4
- 48: s SETITEM
- 49: a APPEND
- 50: . STOP
+ 5: L LONG 1
+ 9: a APPEND
+ 10: L LONG 2
+ 14: a APPEND
+ 15: ( MARK
+ 16: L LONG 3
+ 20: L LONG 4
+ 24: t TUPLE (MARK at 15)
+ 25: p PUT 1
+ 28: a APPEND
+ 29: ( MARK
+ 30: d DICT (MARK at 29)
+ 31: p PUT 2
+ 34: c GLOBAL '_codecs encode'
+ 50: p PUT 3
+ 53: ( MARK
+ 54: V UNICODE 'abc'
+ 59: p PUT 4
+ 62: V UNICODE 'latin1'
+ 70: p PUT 5
+ 73: t TUPLE (MARK at 53)
+ 74: p PUT 6
+ 77: R REDUCE
+ 78: p PUT 7
+ 81: V UNICODE 'def'
+ 86: p PUT 8
+ 89: s SETITEM
+ 90: a APPEND
+ 91: . STOP
highest protocol among opcodes = 0
Try again with a "binary" pickle.
->>> pkl = pickle.dumps(x, 1)
->>> dis(pkl)
+>>> pkl1 = pickle.dumps(x, 1)
+>>> dis(pkl1)
0: ] EMPTY_LIST
1: q BINPUT 0
3: ( MARK
@@ -2075,13 +2117,22 @@ Try again with a "binary" pickle.
14: q BINPUT 1
16: } EMPTY_DICT
17: q BINPUT 2
- 19: U SHORT_BINSTRING 'abc'
- 24: q BINPUT 3
- 26: X BINUNICODE u'def'
- 34: q BINPUT 4
- 36: s SETITEM
- 37: e APPENDS (MARK at 3)
- 38: . STOP
+ 19: c GLOBAL '_codecs encode'
+ 35: q BINPUT 3
+ 37: ( MARK
+ 38: X BINUNICODE 'abc'
+ 46: q BINPUT 4
+ 48: X BINUNICODE 'latin1'
+ 59: q BINPUT 5
+ 61: t TUPLE (MARK at 37)
+ 62: q BINPUT 6
+ 64: R REDUCE
+ 65: q BINPUT 7
+ 67: X BINUNICODE 'def'
+ 75: q BINPUT 8
+ 77: s SETITEM
+ 78: e APPENDS (MARK at 3)
+ 79: . STOP
highest protocol among opcodes = 1
Exercise the INST/OBJ/BUILD family.
@@ -2099,42 +2150,58 @@ highest protocol among opcodes = 0
0: ( MARK
1: l LIST (MARK at 0)
2: p PUT 0
- 5: ( MARK
- 6: i INST 'pickletools _Example' (MARK at 5)
- 28: p PUT 1
- 31: ( MARK
- 32: d DICT (MARK at 31)
- 33: p PUT 2
- 36: S STRING 'value'
- 45: p PUT 3
- 48: I INT 42
- 52: s SETITEM
- 53: b BUILD
- 54: a APPEND
- 55: g GET 1
- 58: a APPEND
- 59: . STOP
+ 5: c GLOBAL 'copy_reg _reconstructor'
+ 30: p PUT 1
+ 33: ( MARK
+ 34: c GLOBAL 'pickletools _Example'
+ 56: p PUT 2
+ 59: c GLOBAL '__builtin__ object'
+ 79: p PUT 3
+ 82: N NONE
+ 83: t TUPLE (MARK at 33)
+ 84: p PUT 4
+ 87: R REDUCE
+ 88: p PUT 5
+ 91: ( MARK
+ 92: d DICT (MARK at 91)
+ 93: p PUT 6
+ 96: V UNICODE 'value'
+ 103: p PUT 7
+ 106: L LONG 42
+ 111: s SETITEM
+ 112: b BUILD
+ 113: a APPEND
+ 114: g GET 5
+ 117: a APPEND
+ 118: . STOP
highest protocol among opcodes = 0
>>> dis(pickle.dumps(x, 1))
0: ] EMPTY_LIST
1: q BINPUT 0
3: ( MARK
- 4: ( MARK
- 5: c GLOBAL 'pickletools _Example'
- 27: q BINPUT 1
- 29: o OBJ (MARK at 4)
- 30: q BINPUT 2
- 32: } EMPTY_DICT
- 33: q BINPUT 3
- 35: U SHORT_BINSTRING 'value'
- 42: q BINPUT 4
- 44: K BININT1 42
- 46: s SETITEM
- 47: b BUILD
- 48: h BINGET 2
- 50: e APPENDS (MARK at 3)
- 51: . STOP
+ 4: c GLOBAL 'copy_reg _reconstructor'
+ 29: q BINPUT 1
+ 31: ( MARK
+ 32: c GLOBAL 'pickletools _Example'
+ 54: q BINPUT 2
+ 56: c GLOBAL '__builtin__ object'
+ 76: q BINPUT 3
+ 78: N NONE
+ 79: t TUPLE (MARK at 31)
+ 80: q BINPUT 4
+ 82: R REDUCE
+ 83: q BINPUT 5
+ 85: } EMPTY_DICT
+ 86: q BINPUT 6
+ 88: X BINUNICODE 'value'
+ 98: q BINPUT 7
+ 100: K BININT1 42
+ 102: s SETITEM
+ 103: b BUILD
+ 104: h BINGET 5
+ 106: e APPENDS (MARK at 3)
+ 107: . STOP
highest protocol among opcodes = 1
Try "the canonical" recursive-object test.
@@ -2232,17 +2299,34 @@ highest protocol among opcodes = 2
12: h BINGET 1
14: . STOP
highest protocol among opcodes = 2
+
+Try protocol 3 with annotations:
+
+>>> dis(pickle.dumps(T, 3), annotate=1)
+ 0: \x80 PROTO 3 Protocol version indicator.
+ 2: ] EMPTY_LIST Push an empty list.
+ 3: q BINPUT 0 Store the stack top into the memo. The stack is not popped.
+ 5: h BINGET 0 Read an object from the memo and push it on the stack.
+ 7: \x85 TUPLE1 Build a one-tuple out of the topmost item on the stack.
+ 8: q BINPUT 1 Store the stack top into the memo. The stack is not popped.
+ 10: a APPEND Append an object to a list.
+ 11: 0 POP Discard the top stack item, shrinking the stack by one item.
+ 12: h BINGET 1 Read an object from the memo and push it on the stack.
+ 14: . STOP Stop the unpickling machine.
+highest protocol among opcodes = 2
+
"""
_memo_test = r"""
>>> import pickle
->>> from StringIO import StringIO
->>> f = StringIO()
+>>> import io
+>>> f = io.BytesIO()
>>> p = pickle.Pickler(f, 2)
>>> x = [1, 2, 3]
>>> p.dump(x)
>>> p.dump(x)
>>> f.seek(0)
+0
>>> memo = {}
>>> dis(f, memo=memo)
0: \x80 PROTO 2
@@ -2271,4 +2355,47 @@ def _test():
return doctest.testmod()
if __name__ == "__main__":
- _test()
+ import sys, argparse
+ parser = argparse.ArgumentParser(
+ description='disassemble one or more pickle files')
+ parser.add_argument(
+ 'pickle_file', type=argparse.FileType('br'),
+ nargs='*', help='the pickle file')
+ parser.add_argument(
+ '-o', '--output', default=sys.stdout, type=argparse.FileType('w'),
+ help='the file where the output should be written')
+ parser.add_argument(
+ '-m', '--memo', action='store_true',
+ help='preserve memo between disassemblies')
+ parser.add_argument(
+ '-l', '--indentlevel', default=4, type=int,
+ help='the number of blanks by which to indent a new MARK level')
+ parser.add_argument(
+ '-a', '--annotate', action='store_true',
+ help='annotate each line with a short opcode description')
+ parser.add_argument(
+ '-p', '--preamble', default="==> {name} <==",
+ help='if more than one pickle file is specified, print this before'
+ ' each disassembly')
+ parser.add_argument(
+ '-t', '--test', action='store_true',
+ help='run self-test suite')
+ parser.add_argument(
+ '-v', action='store_true',
+ help='run verbosely; only affects self-test run')
+ args = parser.parse_args()
+ if args.test:
+ _test()
+ else:
+ annotate = 30 if args.annotate else 0
+ if not args.pickle_file:
+ parser.print_help()
+ elif len(args.pickle_file) == 1:
+ dis(args.pickle_file[0], args.output, None,
+ args.indentlevel, annotate)
+ else:
+ memo = {} if args.memo else None
+ for f in args.pickle_file:
+ preamble = args.preamble.format(name=f.name)
+ args.output.write(preamble + '\n')
+ dis(f, args.output, memo, args.indentlevel, annotate)
diff --git a/Lib/pipes.py b/Lib/pipes.py
index 26750f6ab88..42970538168 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -108,45 +108,33 @@ class Template:
def append(self, cmd, kind):
"""t.append(cmd, kind) adds a new step at the end."""
if type(cmd) is not type(''):
- raise TypeError, \
- 'Template.append: cmd must be a string'
+ raise TypeError('Template.append: cmd must be a string')
if kind not in stepkinds:
- raise ValueError, \
- 'Template.append: bad kind %r' % (kind,)
+ raise ValueError('Template.append: bad kind %r' % (kind,))
if kind == SOURCE:
- raise ValueError, \
- 'Template.append: SOURCE can only be prepended'
+ raise ValueError('Template.append: SOURCE can only be prepended')
if self.steps and self.steps[-1][1] == SINK:
- raise ValueError, \
- 'Template.append: already ends with SINK'
+ raise ValueError('Template.append: already ends with SINK')
if kind[0] == 'f' and not re.search(r'\$IN\b', cmd):
- raise ValueError, \
- 'Template.append: missing $IN in cmd'
+ raise ValueError('Template.append: missing $IN in cmd')
if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd):
- raise ValueError, \
- 'Template.append: missing $OUT in cmd'
+ raise ValueError('Template.append: missing $OUT in cmd')
self.steps.append((cmd, kind))
def prepend(self, cmd, kind):
"""t.prepend(cmd, kind) adds a new step at the front."""
if type(cmd) is not type(''):
- raise TypeError, \
- 'Template.prepend: cmd must be a string'
+ raise TypeError('Template.prepend: cmd must be a string')
if kind not in stepkinds:
- raise ValueError, \
- 'Template.prepend: bad kind %r' % (kind,)
+ raise ValueError('Template.prepend: bad kind %r' % (kind,))
if kind == SINK:
- raise ValueError, \
- 'Template.prepend: SINK can only be appended'
+ raise ValueError('Template.prepend: SINK can only be appended')
if self.steps and self.steps[0][1] == SOURCE:
- raise ValueError, \
- 'Template.prepend: already begins with SOURCE'
+ raise ValueError('Template.prepend: already begins with SOURCE')
if kind[0] == 'f' and not re.search(r'\$IN\b', cmd):
- raise ValueError, \
- 'Template.prepend: missing $IN in cmd'
+ raise ValueError('Template.prepend: missing $IN in cmd')
if kind[1] == 'f' and not re.search(r'\$OUT\b', cmd):
- raise ValueError, \
- 'Template.prepend: missing $OUT in cmd'
+ raise ValueError('Template.prepend: missing $OUT in cmd')
self.steps.insert(0, (cmd, kind))
def open(self, file, rw):
@@ -156,8 +144,8 @@ class Template:
return self.open_r(file)
if rw == 'w':
return self.open_w(file)
- raise ValueError, \
- 'Template.open: rw must be \'r\' or \'w\', not %r' % (rw,)
+ raise ValueError('Template.open: rw must be \'r\' or \'w\', not %r'
+ % (rw,))
def open_r(self, file):
"""t.open_r(file) and t.open_w(file) implement
@@ -165,8 +153,7 @@ class Template:
if not self.steps:
return open(file, 'r')
if self.steps[-1][1] == SINK:
- raise ValueError, \
- 'Template.open_r: pipeline ends width SINK'
+ raise ValueError('Template.open_r: pipeline ends width SINK')
cmd = self.makepipeline(file, '')
return os.popen(cmd, 'r')
@@ -174,8 +161,7 @@ class Template:
if not self.steps:
return open(file, 'w')
if self.steps[0][1] == SOURCE:
- raise ValueError, \
- 'Template.open_w: pipeline begins with SOURCE'
+ raise ValueError('Template.open_w: pipeline begins with SOURCE')
cmd = self.makepipeline('', file)
return os.popen(cmd, 'w')
@@ -185,7 +171,7 @@ class Template:
def makepipeline(self, infile, outfile):
cmd = makepipeline(infile, self.steps, outfile)
if self.debugging:
- print cmd
+ print(cmd)
cmd = 'set -x; ' + cmd
return cmd
diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py
index ce072ec9ef7..51da0b1bb52 100644
--- a/Lib/pkgutil.py
+++ b/Lib/pkgutil.py
@@ -1,8 +1,5 @@
"""Utilities to support packages."""
-# NOTE: This module must remain compatible with Python 2.3, as it is shared
-# by setuptools for distribution with Python 2.3 and up.
-
import os
import sys
import imp
@@ -252,7 +249,8 @@ class ImpLoader:
return mod
def get_data(self, pathname):
- return open(pathname, "rb").read()
+ with open(pathname, "rb") as file:
+ return file.read()
def _reopen(self):
if self.file and self.file.closed:
@@ -329,8 +327,7 @@ try:
from zipimport import zipimporter
def iter_zipimport_modules(importer, prefix=''):
- dirlist = zipimport._zip_directory_cache[importer.archive].keys()
- dirlist.sort()
+ dirlist = sorted(zipimport._zip_directory_cache[importer.archive])
_prefix = importer.prefix
plen = len(_prefix)
yielded = {}
@@ -518,15 +515,13 @@ def extend_path(path, name):
return path
pname = os.path.join(*name.split('.')) # Reconstitute as relative path
- # Just in case os.extsep != '.'
- sname = os.extsep.join(name.split('.'))
- sname_pkg = sname + os.extsep + "pkg"
- init_py = "__init__" + os.extsep + "py"
+ sname_pkg = name + ".pkg"
+ init_py = "__init__.py"
path = path[:] # Start with a copy of the existing path
for dir in sys.path:
- if not isinstance(dir, basestring) or not os.path.isdir(dir):
+ if not isinstance(dir, str) or not os.path.isdir(dir):
continue
subdir = os.path.join(dir, pname)
# XXX This may still add duplicate entries to path on
@@ -540,7 +535,7 @@ def extend_path(path, name):
if os.path.isfile(pkgfile):
try:
f = open(pkgfile)
- except IOError, msg:
+ except IOError as msg:
sys.stderr.write("Can't open %s: %s\n" %
(pkgfile, msg))
else:
diff --git a/Lib/plat-aix3/IN.py b/Lib/plat-aix3/IN.py
deleted file mode 100644
index 2c57362fc8d..00000000000
--- a/Lib/plat-aix3/IN.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# Generated by h2py from /usr/include/netinet/in.h
-
-# Included from net/nh.h
-
-# Included from sys/machine.h
-LITTLE_ENDIAN = 1234
-BIG_ENDIAN = 4321
-PDP_ENDIAN = 3412
-BYTE_ORDER = BIG_ENDIAN
-DEFAULT_GPR = 0xDEADBEEF
-MSR_EE = 0x8000
-MSR_PR = 0x4000
-MSR_FP = 0x2000
-MSR_ME = 0x1000
-MSR_FE = 0x0800
-MSR_FE0 = 0x0800
-MSR_SE = 0x0400
-MSR_BE = 0x0200
-MSR_IE = 0x0100
-MSR_FE1 = 0x0100
-MSR_AL = 0x0080
-MSR_IP = 0x0040
-MSR_IR = 0x0020
-MSR_DR = 0x0010
-MSR_PM = 0x0004
-DEFAULT_MSR = (MSR_EE | MSR_ME | MSR_AL | MSR_IR | MSR_DR)
-DEFAULT_USER_MSR = (DEFAULT_MSR | MSR_PR)
-CR_LT = 0x80000000
-CR_GT = 0x40000000
-CR_EQ = 0x20000000
-CR_SO = 0x10000000
-CR_FX = 0x08000000
-CR_FEX = 0x04000000
-CR_VX = 0x02000000
-CR_OX = 0x01000000
-XER_SO = 0x80000000
-XER_OV = 0x40000000
-XER_CA = 0x20000000
-def XER_COMP_BYTE(xer): return ((xer >> 8) & 0x000000FF)
-
-def XER_LENGTH(xer): return (xer & 0x0000007F)
-
-DSISR_IO = 0x80000000
-DSISR_PFT = 0x40000000
-DSISR_LOCK = 0x20000000
-DSISR_FPIO = 0x10000000
-DSISR_PROT = 0x08000000
-DSISR_LOOP = 0x04000000
-DSISR_DRST = 0x04000000
-DSISR_ST = 0x02000000
-DSISR_SEGB = 0x01000000
-DSISR_DABR = 0x00400000
-DSISR_EAR = 0x00100000
-SRR_IS_PFT = 0x40000000
-SRR_IS_ISPEC = 0x20000000
-SRR_IS_IIO = 0x10000000
-SRR_IS_PROT = 0x08000000
-SRR_IS_LOOP = 0x04000000
-SRR_PR_FPEN = 0x00100000
-SRR_PR_INVAL = 0x00080000
-SRR_PR_PRIV = 0x00040000
-SRR_PR_TRAP = 0x00020000
-SRR_PR_IMPRE = 0x00010000
-def ntohl(x): return (x)
-
-def ntohs(x): return (x)
-
-def htonl(x): return (x)
-
-def htons(x): return (x)
-
-IPPROTO_IP = 0
-IPPROTO_ICMP = 1
-IPPROTO_GGP = 3
-IPPROTO_TCP = 6
-IPPROTO_EGP = 8
-IPPROTO_PUP = 12
-IPPROTO_UDP = 17
-IPPROTO_IDP = 22
-IPPROTO_TP = 29
-IPPROTO_LOCAL = 63
-IPPROTO_EON = 80
-IPPROTO_BIP = 0x53
-IPPROTO_RAW = 255
-IPPROTO_MAX = 256
-IPPORT_RESERVED = 1024
-IPPORT_USERRESERVED = 5000
-IPPORT_TIMESERVER = 37
-def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
-
-IN_CLASSA_NET = 0xff000000
-IN_CLASSA_NSHIFT = 24
-IN_CLASSA_HOST = 0x00ffffff
-IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
-
-IN_CLASSB_NET = 0xffff0000
-IN_CLASSB_NSHIFT = 16
-IN_CLASSB_HOST = 0x0000ffff
-IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
-
-IN_CLASSC_NET = 0xffffff00
-IN_CLASSC_NSHIFT = 8
-IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
-
-def IN_MULTICAST(i): return IN_CLASSD(i)
-
-def IN_EXPERIMENTAL(i): return (((long)(i) & 0xe0000000) == 0xe0000000)
-
-def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
-
-INADDR_ANY = 0x00000000
-INADDR_LOOPBACK = 0x7f000001
-INADDR_BROADCAST = 0xffffffff
-INADDR_NONE = 0xffffffff
-IN_LOOPBACKNET = 127
-IP_OPTIONS = 1
-IP_HDRINCL = 2
-IP_TOS = 3
-IP_TTL = 4
-IP_RECVOPTS = 5
-IP_RECVRETOPTS = 6
-IP_RECVDSTADDR = 7
-IP_RETOPTS = 8
diff --git a/Lib/plat-aix3/regen b/Lib/plat-aix3/regen
deleted file mode 100755
index 58deb202a30..00000000000
--- a/Lib/plat-aix3/regen
+++ /dev/null
@@ -1,8 +0,0 @@
-#! /bin/sh
-case `uname -sv` in
-'AIX 3'*) ;;
-*) echo Probably not on an AIX 3 system 1>&2
- exit 1;;
-esac
-set -v
-h2py.py -i '(u_long)' /usr/include/netinet/in.h
diff --git a/Lib/plat-aix4/IN.py b/Lib/plat-aix4/IN.py
index 00f0e1f8788..43f8f231aea 100644
--- a/Lib/plat-aix4/IN.py
+++ b/Lib/plat-aix4/IN.py
@@ -111,24 +111,24 @@ IPPROTO_MAX = 256
IPPORT_RESERVED = 1024
IPPORT_USERRESERVED = 5000
IPPORT_TIMESERVER = 37
-def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
+def IN_CLASSA(i): return (((int)(i) & 0x80000000) == 0)
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 24
IN_CLASSA_HOST = 0x00ffffff
IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
+def IN_CLASSB(i): return (((int)(i) & 0xc0000000) == 0x80000000)
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 16
IN_CLASSB_HOST = 0x0000ffff
IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
+def IN_CLASSC(i): return (((int)(i) & 0xe0000000) == 0xc0000000)
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 8
IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
+def IN_CLASSD(i): return (((int)(i) & 0xf0000000) == 0xe0000000)
def IN_MULTICAST(i): return IN_CLASSD(i)
@@ -138,9 +138,9 @@ IN_CLASSD_HOST = 0x0fffffff
INADDR_UNSPEC_GROUP = 0xe0000000
INADDR_ALLHOSTS_GROUP = 0xe0000001
INADDR_MAX_LOCAL_GROUP = 0xe00000ff
-def IN_EXPERIMENTAL(i): return (((long)(i) & 0xe0000000) == 0xe0000000)
+def IN_EXPERIMENTAL(i): return (((int)(i) & 0xe0000000) == 0xe0000000)
-def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
+def IN_BADCLASS(i): return (((int)(i) & 0xf0000000) == 0xf0000000)
INADDR_ANY = 0x00000000
INADDR_BROADCAST = 0xffffffff
diff --git a/Lib/plat-atheos/IN.py b/Lib/plat-atheos/IN.py
deleted file mode 100644
index 6588d651120..00000000000
--- a/Lib/plat-atheos/IN.py
+++ /dev/null
@@ -1,944 +0,0 @@
-# Generated by h2py from /include/netinet/in.h
-_NETINET_IN_H = 1
-
-# Included from features.h
-_FEATURES_H = 1
-__USE_ANSI = 1
-__FAVOR_BSD = 1
-_ISOC9X_SOURCE = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506L
-_XOPEN_SOURCE = 500
-_XOPEN_SOURCE_EXTENDED = 1
-_LARGEFILE64_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-__USE_ISOC9X = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506L
-__USE_POSIX = 1
-__USE_POSIX2 = 1
-__USE_POSIX199309 = 1
-__USE_POSIX199506 = 1
-__USE_XOPEN = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_UNIX98 = 1
-_LARGEFILE_SOURCE = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_LARGEFILE = 1
-__USE_LARGEFILE64 = 1
-__USE_FILE_OFFSET64 = 1
-__USE_MISC = 1
-__USE_BSD = 1
-__USE_SVID = 1
-__USE_GNU = 1
-__USE_REENTRANT = 1
-__STDC_IEC_559__ = 1
-__STDC_IEC_559_COMPLEX__ = 1
-__GNU_LIBRARY__ = 6
-__GLIBC__ = 2
-__GLIBC_MINOR__ = 1
-
-# Included from sys/cdefs.h
-_SYS_CDEFS_H = 1
-def __PMT(args): return args
-
-def __P(args): return args
-
-def __PMT(args): return args
-
-def __P(args): return ()
-
-def __PMT(args): return ()
-
-def __STRING(x): return #x
-
-def __STRING(x): return "x"
-
-def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
-
-def __attribute__(xyz): return
-
-__USE_EXTERN_INLINES = 1
-
-# Included from gnu/stubs.h
-
-# Included from limits.h
-_LIBC_LIMITS_H_ = 1
-
-# Included from bits/posix1_lim.h
-_BITS_POSIX1_LIM_H = 1
-_POSIX_AIO_LISTIO_MAX = 2
-_POSIX_AIO_MAX = 1
-_POSIX_ARG_MAX = 4096
-_POSIX_CHILD_MAX = 6
-_POSIX_DELAYTIMER_MAX = 32
-_POSIX_LINK_MAX = 8
-_POSIX_MAX_CANON = 255
-_POSIX_MAX_INPUT = 255
-_POSIX_MQ_OPEN_MAX = 8
-_POSIX_MQ_PRIO_MAX = 32
-_POSIX_NGROUPS_MAX = 0
-_POSIX_OPEN_MAX = 16
-_POSIX_FD_SETSIZE = _POSIX_OPEN_MAX
-_POSIX_NAME_MAX = 14
-_POSIX_PATH_MAX = 255
-_POSIX_PIPE_BUF = 512
-_POSIX_RTSIG_MAX = 8
-_POSIX_SEM_NSEMS_MAX = 256
-_POSIX_SEM_VALUE_MAX = 32767
-_POSIX_SIGQUEUE_MAX = 32
-_POSIX_SSIZE_MAX = 32767
-_POSIX_STREAM_MAX = 8
-_POSIX_TZNAME_MAX = 3
-_POSIX_QLIMIT = 1
-_POSIX_HIWAT = _POSIX_PIPE_BUF
-_POSIX_UIO_MAXIOV = 16
-_POSIX_TTY_NAME_MAX = 9
-_POSIX_TIMER_MAX = 32
-_POSIX_LOGIN_NAME_MAX = 9
-_POSIX_CLOCKRES_MIN = 20000000
-
-# Included from bits/local_lim.h
-
-# Included from posix/limits.h
-CHAR_BIT = 8
-CHAR_MAX = 127
-CHAR_MIN = (-128)
-INT_MAX = 2147483647
-INT_MIN = (-2147483647-1)
-LONG_MAX = 2147483647L
-LONG_MIN = (-2147483647L-1L)
-SCHAR_MAX = 127
-SCHAR_MIN = (-128)
-SHRT_MAX = 32767
-SHRT_MIN = (-32768)
-UCHAR_MAX = 255
-USHRT_MAX = 65535
-_POSIX_ARG_MAX = 131072
-_POSIX_CHILD_MAX = 4096
-_POSIX_LINK_MAX = 1
-_POSIX_MAX_CANON = 126
-_POSIX_MAX_INPUT = 126
-_POSIX_NAME_MAX = 256
-_POSIX_NGROUPS_MAX = 32
-_POSIX_OPEN_MAX = 256
-_POSIX_PATH_MAX = 255
-_POSIX_PIPE_BUF = 512
-_POSIX_SSIZE_MAX = 2147483647
-_POSIX_STREAM_MAX = 256
-_POSIX_TZNAME_MAX = 5
-NGROUPS_MAX = 32
-ARG_MAX = 131072
-CHILD_MAX = 4096
-OPEN_MAX = 256
-LINK_MAX = 1
-MAX_CANON = 126
-MAX_INPUT = 126
-NAME_MAX = 255
-PATH_MAX = 4096
-PIPE_BUF = 4096
-SSIZE_MAX = 2147483647
-MAXSYMLINKS = 16
-AIO_PRIO_DELTA_MAX = 20
-SSIZE_MAX = INT_MAX
-NGROUPS_MAX = _POSIX_NGROUPS_MAX
-
-# Included from bits/posix2_lim.h
-_BITS_POSIX2_LIM_H = 1
-_POSIX2_BC_BASE_MAX = 99
-_POSIX2_BC_DIM_MAX = 2048
-_POSIX2_BC_SCALE_MAX = 99
-_POSIX2_BC_STRING_MAX = 1000
-_POSIX2_COLL_WEIGHTS_MAX = 255
-_POSIX2_EQUIV_CLASS_MAX = 255
-_POSIX2_EXPR_NEST_MAX = 32
-_POSIX2_LINE_MAX = 2048
-_POSIX2_RE_DUP_MAX = 255
-_POSIX2_CHARCLASS_NAME_MAX = 2048
-BC_BASE_MAX = _POSIX2_BC_BASE_MAX
-BC_DIM_MAX = _POSIX2_BC_DIM_MAX
-BC_SCALE_MAX = _POSIX2_BC_SCALE_MAX
-BC_STRING_MAX = _POSIX2_BC_STRING_MAX
-COLL_WEIGHTS_MAX = _POSIX2_COLL_WEIGHTS_MAX
-EQUIV_CLASS_MAX = _POSIX2_EQUIV_CLASS_MAX
-EXPR_NEST_MAX = _POSIX2_EXPR_NEST_MAX
-LINE_MAX = _POSIX2_LINE_MAX
-RE_DUP_MAX = _POSIX2_RE_DUP_MAX
-CHARCLASS_NAME_MAX = _POSIX2_CHARCLASS_NAME_MAX
-
-# Included from bits/xopen_lim.h
-_XOPEN_LIM_H = 1
-
-# Included from bits/stdio_lim.h
-L_tmpnam = 20
-TMP_MAX = 238328
-FILENAME_MAX = 4096
-L_ctermid = 9
-L_cuserid = 9
-FOPEN_MAX = 256
-STREAM_MAX = FOPEN_MAX
-TZNAME_MAX = _POSIX_TZNAME_MAX
-_XOPEN_IOV_MAX = _POSIX_UIO_MAXIOV
-NL_ARGMAX = _POSIX_ARG_MAX
-NL_LANGMAX = _POSIX2_LINE_MAX
-NL_MSGMAX = INT_MAX
-NL_NMAX = INT_MAX
-NL_SETMAX = INT_MAX
-NL_TEXTMAX = INT_MAX
-NZERO = 20
-MB_LEN_MAX = 6
-_LIMITS_H = 1
-CHAR_BIT = 8
-SCHAR_MIN = (-128)
-SCHAR_MAX = 127
-UCHAR_MAX = 255
-CHAR_MIN = 0
-CHAR_MAX = UCHAR_MAX
-CHAR_MIN = SCHAR_MIN
-CHAR_MAX = SCHAR_MAX
-SHRT_MIN = (-32768)
-SHRT_MAX = 32767
-USHRT_MAX = 65535
-INT_MIN = (-INT_MAX - 1)
-INT_MAX = 2147483647
-UINT_MAX = 4294967295
-LONG_MAX = 9223372036854775807L
-LONG_MAX = 2147483647L
-LONG_MIN = (-LONG_MAX - 1L)
-ULONG_MAX = 4294967295L
-
-# Included from stdint.h
-_STDINT_H = 1
-
-# Included from bits/wordsize.h
-__WORDSIZE = 32
-def __INT64_C(c): return c ## L
-
-def __UINT64_C(c): return c ## UL
-
-def __INT64_C(c): return c ## LL
-
-def __UINT64_C(c): return c ## ULL
-
-INT8_MIN = (-128)
-INT16_MIN = (-32767-1)
-INT32_MIN = (-2147483647-1)
-INT64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT8_MAX = (127)
-INT16_MAX = (32767)
-INT32_MAX = (2147483647)
-INT64_MAX = (__INT64_C(9223372036854775807))
-UINT64_MAX = (__UINT64_C(18446744073709551615))
-INT_LEAST8_MIN = (-128)
-INT_LEAST16_MIN = (-32767-1)
-INT_LEAST32_MIN = (-2147483647-1)
-INT_LEAST64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT_LEAST8_MAX = (127)
-INT_LEAST16_MAX = (32767)
-INT_LEAST32_MAX = (2147483647)
-INT_LEAST64_MAX = (__INT64_C(9223372036854775807))
-UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615))
-INT_FAST8_MIN = (-128)
-INT_FAST16_MIN = (-9223372036854775807L-1)
-INT_FAST32_MIN = (-9223372036854775807L-1)
-INT_FAST16_MIN = (-2147483647-1)
-INT_FAST32_MIN = (-2147483647-1)
-INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1)
-INT_FAST8_MAX = (127)
-INT_FAST16_MAX = (9223372036854775807L)
-INT_FAST32_MAX = (9223372036854775807L)
-INT_FAST16_MAX = (2147483647)
-INT_FAST32_MAX = (2147483647)
-INT_FAST64_MAX = (__INT64_C(9223372036854775807))
-UINT_FAST64_MAX = (__UINT64_C(18446744073709551615))
-INTPTR_MIN = (-9223372036854775807L-1)
-INTPTR_MAX = (9223372036854775807L)
-INTPTR_MIN = (-2147483647-1)
-INTPTR_MAX = (2147483647)
-INTMAX_MIN = (-__INT64_C(9223372036854775807)-1)
-INTMAX_MAX = (__INT64_C(9223372036854775807))
-UINTMAX_MAX = (__UINT64_C(18446744073709551615))
-PTRDIFF_MIN = (-9223372036854775807L-1)
-PTRDIFF_MAX = (9223372036854775807L)
-PTRDIFF_MIN = (-2147483647-1)
-PTRDIFF_MAX = (2147483647)
-SIG_ATOMIC_MIN = (-2147483647-1)
-SIG_ATOMIC_MAX = (2147483647)
-WCHAR_MIN = (-2147483647-1)
-WCHAR_MAX = (2147483647)
-WINT_MIN = (0)
-def INT8_C(c): return c
-
-def INT16_C(c): return c
-
-def INT32_C(c): return c
-
-def INT64_C(c): return c ## L
-
-def INT64_C(c): return c ## LL
-
-def UINT8_C(c): return c ## U
-
-def UINT16_C(c): return c ## U
-
-def UINT32_C(c): return c ## U
-
-def UINT64_C(c): return c ## UL
-
-def UINT64_C(c): return c ## ULL
-
-def INTMAX_C(c): return c ## L
-
-def UINTMAX_C(c): return c ## UL
-
-def INTMAX_C(c): return c ## LL
-
-def UINTMAX_C(c): return c ## ULL
-
-
-# Included from sys/types.h
-_SYS_TYPES_H = 1
-
-# Included from bits/types.h
-_BITS_TYPES_H = 1
-__FD_SETSIZE = 1024
-def __FDELT(d): return ((d) / __NFDBITS)
-
-
-# Included from bits/pthreadtypes.h
-
-# Included from time.h
-_TIME_H = 1
-
-# Included from bits/time.h
-
-# Included from posix/time.h
-
-# Included from posix/types.h
-MAXHOSTNAMELEN = 64
-FD_SETSIZE = 1024
-CLOCKS_PER_SEC = 1000000
-_BITS_TIME_H = 1
-CLOCKS_PER_SEC = 1000000
-CLK_TCK = 100
-_STRUCT_TIMEVAL = 1
-CLK_TCK = CLOCKS_PER_SEC
-__clock_t_defined = 1
-__time_t_defined = 1
-__timespec_defined = 1
-def __isleap(year): return \
-
-__BIT_TYPES_DEFINED__ = 1
-
-# Included from endian.h
-_ENDIAN_H = 1
-__LITTLE_ENDIAN = 1234
-__BIG_ENDIAN = 4321
-__PDP_ENDIAN = 3412
-
-# Included from bits/endian.h
-__BYTE_ORDER = __LITTLE_ENDIAN
-__FLOAT_WORD_ORDER = __BYTE_ORDER
-LITTLE_ENDIAN = __LITTLE_ENDIAN
-BIG_ENDIAN = __BIG_ENDIAN
-PDP_ENDIAN = __PDP_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-
-# Included from sys/select.h
-_SYS_SELECT_H = 1
-
-# Included from bits/select.h
-def __FD_ZERO(fdsp): return \
-
-def __FD_ZERO(set): return \
-
-
-# Included from bits/sigset.h
-_SIGSET_H_types = 1
-_SIGSET_H_fns = 1
-def __sigmask(sig): return \
-
-def __sigemptyset(set): return \
-
-def __sigfillset(set): return \
-
-def __sigisemptyset(set): return \
-
-FD_SETSIZE = __FD_SETSIZE
-def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp)
-
-
-# Included from sys/sysmacros.h
-_SYS_SYSMACROS_H = 1
-def major(dev): return ( (( (dev) >> 8) & 0xff))
-
-def minor(dev): return ( ((dev) & 0xff))
-
-
-# Included from bits/socket.h
-PF_UNSPEC = 0
-PF_LOCAL = 1
-PF_UNIX = PF_LOCAL
-PF_FILE = PF_LOCAL
-PF_INET = 2
-PF_AX25 = 3
-PF_IPX = 4
-PF_APPLETALK = 5
-PF_NETROM = 6
-PF_BRIDGE = 7
-PF_ATMPVC = 8
-PF_X25 = 9
-PF_INET6 = 10
-PF_ROSE = 11
-PF_DECnet = 12
-PF_NETBEUI = 13
-PF_SECURITY = 14
-PF_KEY = 15
-PF_NETLINK = 16
-PF_ROUTE = PF_NETLINK
-PF_PACKET = 17
-PF_ASH = 18
-PF_ECONET = 19
-PF_ATMSVC = 20
-PF_SNA = 22
-PF_IRDA = 23
-PF_MAX = 32
-AF_UNSPEC = PF_UNSPEC
-AF_LOCAL = PF_LOCAL
-AF_UNIX = PF_UNIX
-AF_FILE = PF_FILE
-AF_INET = PF_INET
-AF_AX25 = PF_AX25
-AF_IPX = PF_IPX
-AF_APPLETALK = PF_APPLETALK
-AF_NETROM = PF_NETROM
-AF_BRIDGE = PF_BRIDGE
-AF_ATMPVC = PF_ATMPVC
-AF_X25 = PF_X25
-AF_INET6 = PF_INET6
-AF_ROSE = PF_ROSE
-AF_DECnet = PF_DECnet
-AF_NETBEUI = PF_NETBEUI
-AF_SECURITY = PF_SECURITY
-AF_KEY = PF_KEY
-AF_NETLINK = PF_NETLINK
-AF_ROUTE = PF_ROUTE
-AF_PACKET = PF_PACKET
-AF_ASH = PF_ASH
-AF_ECONET = PF_ECONET
-AF_ATMSVC = PF_ATMSVC
-AF_SNA = PF_SNA
-AF_IRDA = PF_IRDA
-AF_MAX = PF_MAX
-SOL_RAW = 255
-SOL_DECNET = 261
-SOL_X25 = 262
-SOL_PACKET = 263
-SOL_ATM = 264
-SOL_AAL = 265
-SOL_IRDA = 266
-SOMAXCONN = 128
-
-# Included from bits/sockaddr.h
-_BITS_SOCKADDR_H = 1
-def __SOCKADDR_COMMON(sa_prefix): return \
-
-_SS_SIZE = 128
-def CMSG_FIRSTHDR(mhdr): return \
-
-
-# Included from atheos/socket.h
-
-# Included from atheos/types.h
-OS_NAME_LENGTH = 64
-TRUE = 1
-FALSE = 0
-
-# Included from atheos/filesystem.h
-
-# Included from atheos/atomic.h
-
-# Included from atheos/typedefs.h
-
-# Included from atheos/fs_attribs.h
-
-# Included from atheos/kernel.h
-
-# Included from atheos/kdebug.h
-
-# Included from atheos/threads.h
-TF_DEADLOCK = 0x0001
-DB_PACKET_SIZE = 128
-DB_PORT_COUNT = 16
-DBP_PRINTK = 0
-DBP_DEBUGGER = 2
-
-# Included from atheos/stdlib.h
-
-# Included from atheos/string.h
-def COMMON(x): return \
-
-def COMMON(x): return \
-
-
-# Included from atheos/schedule.h
-
-# Included from atheos/timer.h
-
-# Included from posix/resource.h
-RUSAGE_SELF = 0
-RUSAGE_CHILDREN = -1
-RLIMIT_CPU = 0
-RLIMIT_FSIZE = 1
-RLIMIT_DATA = 2
-RLIMIT_STACK = 3
-RLIMIT_CORE = 4
-RLIMIT_RSS = 5
-RLIMIT_MEMLOCK = 6
-RLIMIT_NPROC = 7
-RLIMIT_NOFILE = 8
-RLIMIT_AS = 9
-RLIM_NLIMITS = 10
-
-# Included from atheos/v86.h
-
-# Included from atheos/areas.h
-MEMF_REAL = 0x00000002
-MEMF_USER = 0x00000004
-MEMF_BUFFER = 0x00000008
-MEMF_KERNEL = 0x00000010
-MEMF_OKTOFAILHACK = 0x00000020
-MEMF_PRI_MASK = 0x000000ff
-MEMF_NOBLOCK = 0x00000100
-MEMF_CLEAR = 0x00010000
-MEMF_LOCKED = 0x10000000
-PAGE_SHIFT = 12
-PGDIR_SHIFT = 22
-def PAGE_ALIGN(addr): return (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
-AREA_NO_LOCK = 0
-AREA_LAZY_LOCK = 1
-AREA_FULL_LOCK = 2
-AREA_CONTIGUOUS = 3
-AREA_READ = 0x00000001
-AREA_WRITE = 0x00000002
-AREA_EXEC = 0x00000004
-AREA_FULL_ACCESS = (AREA_READ | AREA_WRITE | AREA_EXEC)
-AREA_KERNEL = 0x00000008
-AREA_UNMAP_PHYS = 0x00000010
-AREA_ANY_ADDRESS = 0x00000000
-AREA_EXACT_ADDRESS = 0x00000100
-AREA_BASE_ADDRESS = 0x00000200
-AREA_CLONE_ADDRESS = 0x00000300
-AREA_ADDR_SPEC_MASK = 0x00000f00
-AREA_TOP_DOWN = 0x00001000
-AREA_REMAPPED = 0x0020
-AREA_SHARED = 0x0040
-AREA_GROWSDOWN = 0x0080
-AREA_FIRST_KERNEL_ADDRESS = 0x00100000
-AREA_LAST_KERNEL_ADDRESS = 0x7fffffff
-AREA_FIRST_USER_ADDRESS = 0x80000000
-AREA_LAST_USER_ADDRESS = 0xffffffff
-MAX_CPU_COUNT = 16
-def kfree(p): return kassertw( __kfree(p) == 0 )
-
-
-# Included from posix/dirent.h
-MAXNAMLEN = NAME_MAX
-MAXNAMLEN = 255
-
-# Included from dirent.h
-_DIRENT_H = 1
-
-# Included from bits/dirent.h
-def _D_ALLOC_NAMLEN(d): return (_D_EXACT_NAMLEN (d) + 1)
-
-def IFTODT(mode): return (((mode) & 0170000) >> 12)
-
-def DTTOIF(dirtype): return ((dirtype) << 12)
-
-def dirfd(dirp): return _DIR_dirfd (dirp)
-
-MAXNAMLEN = NAME_MAX
-MAXNAMLEN = 255
-
-# Included from posix/stat.h
-S_IFMT = 00170000
-S_IFSOCK = 0140000
-S_IFLNK = 0120000
-S_IFREG = 0100000
-S_IFBLK = 0060000
-S_IFDIR = 0040000
-S_IFCHR = 0020000
-S_IFIFO = 0010000
-S_ISUID = 0004000
-S_ISGID = 0002000
-S_ISVTX = 0001000
-def S_ISLNK(m): return (((m) & S_IFMT) == S_IFLNK)
-
-def S_ISREG(m): return (((m) & S_IFMT) == S_IFREG)
-
-def S_ISDIR(m): return (((m) & S_IFMT) == S_IFDIR)
-
-def S_ISCHR(m): return (((m) & S_IFMT) == S_IFCHR)
-
-def S_ISBLK(m): return (((m) & S_IFMT) == S_IFBLK)
-
-def S_ISFIFO(m): return (((m) & S_IFMT) == S_IFIFO)
-
-def S_ISSOCK(m): return (((m) & S_IFMT) == S_IFSOCK)
-
-S_IRWXU = 00700
-S_IRUSR = 00400
-S_IWUSR = 00200
-S_IXUSR = 00100
-S_IRWXG = 00070
-S_IRGRP = 00040
-S_IWGRP = 00020
-S_IXGRP = 00010
-S_IRWXO = 00007
-S_IROTH = 00004
-S_IWOTH = 00002
-S_IXOTH = 00001
-S_IRWXUGO = (S_IRWXU|S_IRWXG|S_IRWXO)
-S_IALLUGO = (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
-S_IRUGO = (S_IRUSR|S_IRGRP|S_IROTH)
-S_IWUGO = (S_IWUSR|S_IWGRP|S_IWOTH)
-S_IXUGO = (S_IXUSR|S_IXGRP|S_IXOTH)
-_STAT_VER_KERNEL = 0
-
-# Included from posix/fcntl.h
-O_ACCMODE = 0003
-O_RWMASK = O_ACCMODE
-O_RDONLY = 00
-O_WRONLY = 01
-O_RDWR = 02
-O_CREAT = 0100
-O_EXCL = 0200
-O_NOCTTY = 0400
-O_TRUNC = 01000
-O_APPEND = 02000
-O_NONBLOCK = 04000
-O_NDELAY = O_NONBLOCK
-O_SYNC = 010000
-O_FSYNC = O_SYNC
-O_ASYNC = 020000
-FASYNC = O_ASYNC
-O_DIRECTORY = 040000
-O_NOTRAVERSE = 0100000
-O_NOFOLLOW = O_NOTRAVERSE
-F_DUPFD = 0
-F_GETFD = 1
-F_SETFD = 2
-F_GETFL = 3
-F_SETFL = 4
-F_GETLK = 5
-F_SETLK = 6
-F_SETLKW = 7
-F_SETOWN = 8
-F_GETOWN = 9
-F_SETSIG = 10
-F_GETSIG = 11
-F_COPYFD = 12
-FD_CLOEXEC = 1
-F_RDLCK = 0
-F_WRLCK = 1
-F_UNLCK = 2
-F_EXLCK = 4
-F_SHLCK = 8
-LOCK_SH = 1
-LOCK_EX = 2
-LOCK_NB = 4
-LOCK_UN = 8
-
-# Included from posix/uio.h
-UIO_FASTIOV = 8
-UIO_MAXIOV = 1024
-MNTF_READONLY = 0x0001
-FS_IS_READONLY = 0x00000001
-FS_IS_REMOVABLE = 0x00000002
-FS_IS_PERSISTENT = 0x00000004
-FS_IS_SHARED = 0x00000008
-FS_IS_BLOCKBASED = 0x00000010
-FS_CAN_MOUNT = 0x00000020
-FS_HAS_MIME = 0x00010000
-FS_HAS_ATTR = 0x00020000
-FS_HAS_QUERY = 0x00040000
-FSINFO_VERSION = 1
-WSTAT_MODE = 0x0001
-WSTAT_UID = 0x0002
-WSTAT_GID = 0x0004
-WSTAT_SIZE = 0x0008
-WSTAT_ATIME = 0x0010
-WSTAT_MTIME = 0x0020
-WSTAT_CTIME = 0x0040
-WFSSTAT_NAME = 0x0001
-FSDRIVER_API_VERSION = 1
-
-# Included from net/nettypes.h
-IP_ADR_LEN = 4
-INADDR_ANY = 0x00000000
-INADDR_BROADCAST = 0xffffffff
-INADDR_LOOPBACK = 0x7f000001
-def CMSG_ALIGN(len): return ( ((len)+sizeof(long)-1) & ~(sizeof(long)-1) )
-
-PROT_SOCK = 1024
-SHUTDOWN_MASK = 3
-RCV_SHUTDOWN = 1
-SEND_SHUTDOWN = 2
-SOCK_STREAM = 1
-SOCK_DGRAM = 2
-SOCK_RAW = 3
-SOCK_RDM = 4
-SOCK_SEQPACKET = 5
-SOCK_PACKET = 10
-PF_UNSPEC = 0
-PF_LOCAL = 1
-PF_UNIX = PF_LOCAL
-PF_FILE = PF_LOCAL
-PF_INET = 2
-PF_AX25 = 3
-PF_IPX = 4
-PF_APPLETALK = 5
-PF_NETROM = 6
-PF_BRIDGE = 7
-PF_ATMPVC = 8
-PF_X25 = 9
-PF_INET6 = 10
-PF_ROSE = 11
-PF_DECnet = 12
-PF_NETBEUI = 13
-PF_SECURITY = 14
-PF_KEY = 15
-PF_NETLINK = 16
-PF_ROUTE = PF_NETLINK
-PF_PACKET = 17
-PF_ASH = 18
-PF_ECONET = 19
-PF_ATMSVC = 20
-PF_SNA = 22
-PF_IRDA = 23
-PF_MAX = 32
-AF_UNSPEC = PF_UNSPEC
-AF_LOCAL = PF_LOCAL
-AF_UNIX = PF_UNIX
-AF_FILE = PF_FILE
-AF_INET = PF_INET
-AF_AX25 = PF_AX25
-AF_IPX = PF_IPX
-AF_APPLETALK = PF_APPLETALK
-AF_NETROM = PF_NETROM
-AF_BRIDGE = PF_BRIDGE
-AF_ATMPVC = PF_ATMPVC
-AF_X25 = PF_X25
-AF_INET6 = PF_INET6
-AF_ROSE = PF_ROSE
-AF_DECnet = PF_DECnet
-AF_NETBEUI = PF_NETBEUI
-AF_SECURITY = PF_SECURITY
-AF_KEY = PF_KEY
-AF_NETLINK = PF_NETLINK
-AF_ROUTE = PF_ROUTE
-AF_PACKET = PF_PACKET
-AF_ASH = PF_ASH
-AF_ECONET = PF_ECONET
-AF_ATMSVC = PF_ATMSVC
-AF_SNA = PF_SNA
-AF_IRDA = PF_IRDA
-AF_MAX = PF_MAX
-PF_UNIX = 1
-AF_UNIX = PF_UNIX
-PF_INET = 2
-AF_INET = PF_INET
-SOMAXCONN = 128
-MSG_OOB = 1
-MSG_PEEK = 2
-MSG_DONTROUTE = 4
-MSG_PROXY = 16
-SOL_SOCKET = 1
-SO_DEBUG = 1
-SO_REUSEADDR = 2
-SO_TYPE = 3
-SO_ERROR = 4
-SO_DONTROUTE = 5
-SO_BROADCAST = 6
-SO_SNDBUF = 7
-SO_RCVBUF = 8
-SO_KEEPALIVE = 9
-SO_OOBINLINE = 10
-SO_NO_CHECK = 11
-SO_PRIORITY = 12
-SO_LINGER = 13
-SO_BSDCOMPAT = 14
-SOL_IP = 0
-SOL_IPX = 256
-SOL_AX25 = 257
-SOL_ATALK = 258
-SOL_NETROM = 259
-SOL_TCP = 6
-SOL_UDP = 17
-IP_TOS = 1
-IPTOS_LOWDELAY = 0x10
-IPTOS_THROUGHPUT = 0x08
-IPTOS_RELIABILITY = 0x04
-IPTOS_MINCOST = 0x02
-IP_TTL = 2
-IP_HDRINCL = 3
-IP_OPTIONS = 4
-IP_MULTICAST_IF = 32
-IP_MULTICAST_TTL = 33
-IP_MULTICAST_LOOP = 34
-IP_ADD_MEMBERSHIP = 35
-IP_DROP_MEMBERSHIP = 36
-TCP_NODELAY = 0x01
-TCP_MAXSEG = 0x02
-def IN_CLASSA(a): return ((( (a)) & 0x80000000) == 0)
-
-IN_CLASSA_NET = 0xff000000
-IN_CLASSA_NSHIFT = 24
-IN_CLASSA_HOST = (0xffffffff & ~IN_CLASSA_NET)
-IN_CLASSA_MAX = 128
-def IN_CLASSB(a): return ((( (a)) & 0xc0000000) == 0x80000000)
-
-IN_CLASSB_NET = 0xffff0000
-IN_CLASSB_NSHIFT = 16
-IN_CLASSB_HOST = (0xffffffff & ~IN_CLASSB_NET)
-IN_CLASSB_MAX = 65536
-def IN_CLASSC(a): return ((( (a)) & 0xe0000000) == 0xc0000000)
-
-IN_CLASSC_NET = 0xffffff00
-IN_CLASSC_NSHIFT = 8
-IN_CLASSC_HOST = (0xffffffff & ~IN_CLASSC_NET)
-def IN_CLASSD(a): return ((( (a)) & 0xf0000000) == 0xe0000000)
-
-def IN_MULTICAST(a): return IN_CLASSD(a)
-
-def IN_EXPERIMENTAL(a): return ((( (a)) & 0xe0000000) == 0xe0000000)
-
-def IN_BADCLASS(a): return ((( (a)) & 0xf0000000) == 0xf0000000)
-
-INADDR_ANY = ( 0x00000000)
-INADDR_BROADCAST = ( 0xffffffff)
-INADDR_NONE = ( 0xffffffff)
-IN_LOOPBACKNET = 127
-INADDR_LOOPBACK = ( 0x7f000001)
-INADDR_UNSPEC_GROUP = ( 0xe0000000)
-INADDR_ALLHOSTS_GROUP = ( 0xe0000001)
-INADDR_ALLRTRS_GROUP = ( 0xe0000002)
-INADDR_MAX_LOCAL_GROUP = ( 0xe00000ff)
-INET_ADDRSTRLEN = 16
-INET6_ADDRSTRLEN = 46
-
-# Included from bits/in.h
-IP_TOS = 1
-IP_TTL = 2
-IP_HDRINCL = 3
-IP_OPTIONS = 4
-IP_ROUTER_ALERT = 5
-IP_RECVOPTS = 6
-IP_RETOPTS = 7
-IP_PKTINFO = 8
-IP_PKTOPTIONS = 9
-IP_PMTUDISC = 10
-IP_MTU_DISCOVER = 10
-IP_RECVERR = 11
-IP_RECVTTL = 12
-IP_RECVTOS = 13
-IP_MULTICAST_IF = 32
-IP_MULTICAST_TTL = 33
-IP_MULTICAST_LOOP = 34
-IP_ADD_MEMBERSHIP = 35
-IP_DROP_MEMBERSHIP = 36
-IP_RECVRETOPTS = IP_RETOPTS
-IP_PMTUDISC_DONT = 0
-IP_PMTUDISC_WANT = 1
-IP_PMTUDISC_DO = 2
-SOL_IP = 0
-SOL_SOCKET = 1
-IP_DEFAULT_MULTICAST_TTL = 1
-IP_DEFAULT_MULTICAST_LOOP = 1
-IP_MAX_MEMBERSHIPS = 20
-IPV6_ADDRFORM = 1
-IPV6_PKTINFO = 2
-IPV6_HOPOPTS = 3
-IPV6_DSTOPTS = 4
-IPV6_RXSRCRT = 5
-IPV6_PKTOPTIONS = 6
-IPV6_CHECKSUM = 7
-IPV6_HOPLIMIT = 8
-IPV6_NEXTHOP = 9
-IPV6_AUTHHDR = 10
-IPV6_UNICAST_HOPS = 16
-IPV6_MULTICAST_IF = 17
-IPV6_MULTICAST_HOPS = 18
-IPV6_MULTICAST_LOOP = 19
-IPV6_ADD_MEMBERSHIP = 20
-IPV6_DROP_MEMBERSHIP = 21
-IPV6_ROUTER_ALERT = 22
-SCM_SRCRT = IPV6_RXSRCRT
-IPV6_RXHOPOPTS = IPV6_HOPOPTS
-IPV6_RXDSTOPTS = IPV6_DSTOPTS
-IPV6_PMTUDISC_DONT = 0
-IPV6_PMTUDISC_WANT = 1
-IPV6_PMTUDISC_DO = 2
-SOL_IPV6 = 41
-SOL_ICMPV6 = 58
-
-# Included from bits/byteswap.h
-def __bswap_constant_16(x): return \
-
-def __bswap_16(x): return \
-
-def __bswap_16(x): return __bswap_constant_16 (x)
-
-def __bswap_constant_32(x): return \
-
-def __bswap_32(x): return \
-
-def __bswap_32(x): return \
-
-def __bswap_32(x): return __bswap_constant_32 (x)
-
-def __bswap_64(x): return \
-
-def ntohl(x): return (x)
-
-def ntohs(x): return (x)
-
-def htonl(x): return (x)
-
-def htons(x): return (x)
-
-def ntohl(x): return __bswap_32 (x)
-
-def ntohs(x): return __bswap_16 (x)
-
-def htonl(x): return __bswap_32 (x)
-
-def htons(x): return __bswap_16 (x)
-
-def IN6_IS_ADDR_UNSPECIFIED(a): return \
-
-def IN6_IS_ADDR_LOOPBACK(a): return \
-
-def IN6_IS_ADDR_LINKLOCAL(a): return \
-
-def IN6_IS_ADDR_SITELOCAL(a): return \
-
-def IN6_IS_ADDR_V4MAPPED(a): return \
-
-def IN6_IS_ADDR_V4COMPAT(a): return \
-
-def IN6_IS_ADDR_MC_NODELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_LINKLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_SITELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_ORGLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_GLOBAL(a): return
diff --git a/Lib/plat-atheos/TYPES.py b/Lib/plat-atheos/TYPES.py
deleted file mode 100644
index 314ca736a8d..00000000000
--- a/Lib/plat-atheos/TYPES.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# Generated by h2py from /include/sys/types.h
-_SYS_TYPES_H = 1
-
-# Included from features.h
-_FEATURES_H = 1
-__USE_ANSI = 1
-__FAVOR_BSD = 1
-_ISOC9X_SOURCE = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506L
-_XOPEN_SOURCE = 500
-_XOPEN_SOURCE_EXTENDED = 1
-_LARGEFILE64_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-_BSD_SOURCE = 1
-_SVID_SOURCE = 1
-__USE_ISOC9X = 1
-_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506L
-__USE_POSIX = 1
-__USE_POSIX2 = 1
-__USE_POSIX199309 = 1
-__USE_POSIX199506 = 1
-__USE_XOPEN = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_UNIX98 = 1
-_LARGEFILE_SOURCE = 1
-__USE_XOPEN_EXTENDED = 1
-__USE_LARGEFILE = 1
-__USE_LARGEFILE64 = 1
-__USE_FILE_OFFSET64 = 1
-__USE_MISC = 1
-__USE_BSD = 1
-__USE_SVID = 1
-__USE_GNU = 1
-__USE_REENTRANT = 1
-__STDC_IEC_559__ = 1
-__STDC_IEC_559_COMPLEX__ = 1
-__GNU_LIBRARY__ = 6
-__GLIBC__ = 2
-__GLIBC_MINOR__ = 1
-
-# Included from sys/cdefs.h
-_SYS_CDEFS_H = 1
-def __PMT(args): return args
-
-def __P(args): return args
-
-def __PMT(args): return args
-
-def __P(args): return ()
-
-def __PMT(args): return ()
-
-def __STRING(x): return #x
-
-def __STRING(x): return "x"
-
-def __ASMNAME(cname): return __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
-
-def __attribute__(xyz): return
-
-__USE_EXTERN_INLINES = 1
-
-# Included from gnu/stubs.h
-
-# Included from bits/types.h
-_BITS_TYPES_H = 1
-__FD_SETSIZE = 1024
-def __FDELT(d): return ((d) / __NFDBITS)
-
-
-# Included from bits/pthreadtypes.h
-
-# Included from time.h
-_TIME_H = 1
-
-# Included from bits/time.h
-
-# Included from posix/time.h
-
-# Included from posix/types.h
-MAXHOSTNAMELEN = 64
-FD_SETSIZE = 1024
-CLOCKS_PER_SEC = 1000000
-_BITS_TIME_H = 1
-CLOCKS_PER_SEC = 1000000
-CLK_TCK = 100
-_STRUCT_TIMEVAL = 1
-CLK_TCK = CLOCKS_PER_SEC
-__clock_t_defined = 1
-__time_t_defined = 1
-__timespec_defined = 1
-def __isleap(year): return \
-
-__BIT_TYPES_DEFINED__ = 1
-
-# Included from endian.h
-_ENDIAN_H = 1
-__LITTLE_ENDIAN = 1234
-__BIG_ENDIAN = 4321
-__PDP_ENDIAN = 3412
-
-# Included from bits/endian.h
-__BYTE_ORDER = __LITTLE_ENDIAN
-__FLOAT_WORD_ORDER = __BYTE_ORDER
-LITTLE_ENDIAN = __LITTLE_ENDIAN
-BIG_ENDIAN = __BIG_ENDIAN
-PDP_ENDIAN = __PDP_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-
-# Included from sys/select.h
-_SYS_SELECT_H = 1
-
-# Included from bits/select.h
-def __FD_ZERO(fdsp): return \
-
-def __FD_ZERO(set): return \
-
-
-# Included from bits/sigset.h
-_SIGSET_H_types = 1
-_SIGSET_H_fns = 1
-def __sigmask(sig): return \
-
-def __sigemptyset(set): return \
-
-def __sigfillset(set): return \
-
-def __sigisemptyset(set): return \
-
-FD_SETSIZE = __FD_SETSIZE
-def FD_ZERO(fdsetp): return __FD_ZERO (fdsetp)
-
-
-# Included from sys/sysmacros.h
-_SYS_SYSMACROS_H = 1
-def major(dev): return ( (( (dev) >> 8) & 0xff))
-
-def minor(dev): return ( ((dev) & 0xff))
diff --git a/Lib/plat-atheos/regen b/Lib/plat-atheos/regen
deleted file mode 100755
index 7c002c36740..00000000000
--- a/Lib/plat-atheos/regen
+++ /dev/null
@@ -1,3 +0,0 @@
-#! /bin/sh
-set -v
-python$EXE ../../Tools/scripts/h2py.py -i '\(u_long\)' -i '\(uint32_t\)' -i '\(int\)' -i '\(unsigned int\)' /include/netinet/in.h /include/sys/types.h
diff --git a/Lib/plat-beos5/IN.py b/Lib/plat-beos5/IN.py
deleted file mode 100644
index 362cb41fa75..00000000000
--- a/Lib/plat-beos5/IN.py
+++ /dev/null
@@ -1,327 +0,0 @@
-# Generated by h2py from /boot/develop/headers/be/net/netinet/in.h
-
-# Included from socket.h
-
-# Included from BeBuild.h
-B_BEOS_VERSION_4 = 0x0400
-B_BEOS_VERSION_4_5 = 0x0450
-B_BEOS_VERSION_5 = 0x0500
-B_BEOS_VERSION = B_BEOS_VERSION_5
-B_BEOS_VERSION_MAUI = B_BEOS_VERSION_5
-_PR2_COMPATIBLE_ = 1
-_PR3_COMPATIBLE_ = 1
-_R4_COMPATIBLE_ = 1
-_R4_5_COMPATIBLE_ = 1
-_PR2_COMPATIBLE_ = 0
-_PR3_COMPATIBLE_ = 0
-_R4_COMPATIBLE_ = 1
-_R4_5_COMPATIBLE_ = 1
-def _UNUSED(x): return x
-
-
-# Included from sys/types.h
-
-# Included from time.h
-
-# Included from be_setup.h
-def __std(ref): return ref
-
-__be_os = 2
-__dest_os = __be_os
-__MSL__ = 0x4011
-__GLIBC__ = -2
-__GLIBC_MINOR__ = 1
-
-# Included from null.h
-NULL = (0)
-NULL = 0L
-
-# Included from size_t.h
-
-# Included from stddef.h
-
-# Included from wchar_t.h
-CLOCKS_PER_SEC = 1000
-CLK_TCK = CLOCKS_PER_SEC
-MAX_TIMESTR = 70
-
-# Included from sys/time.h
-
-# Included from ByteOrder.h
-
-# Included from endian.h
-__LITTLE_ENDIAN = 1234
-LITTLE_ENDIAN = __LITTLE_ENDIAN
-__BYTE_ORDER = __LITTLE_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-__BIG_ENDIAN = 0
-BIG_ENDIAN = 0
-__BIG_ENDIAN = 4321
-BIG_ENDIAN = __BIG_ENDIAN
-__BYTE_ORDER = __BIG_ENDIAN
-BYTE_ORDER = __BYTE_ORDER
-__LITTLE_ENDIAN = 0
-LITTLE_ENDIAN = 0
-__PDP_ENDIAN = 3412
-PDP_ENDIAN = __PDP_ENDIAN
-
-# Included from SupportDefs.h
-
-# Included from Errors.h
-
-# Included from limits.h
-
-# Included from float.h
-FLT_ROUNDS = 1
-FLT_RADIX = 2
-FLT_MANT_DIG = 24
-FLT_DIG = 6
-FLT_MIN_EXP = (-125)
-FLT_MIN_10_EXP = (-37)
-FLT_MAX_EXP = 128
-FLT_MAX_10_EXP = 38
-DBL_MANT_DIG = 53
-DBL_DIG = 15
-DBL_MIN_EXP = (-1021)
-DBL_MIN_10_EXP = (-308)
-DBL_MAX_EXP = 1024
-DBL_MAX_10_EXP = 308
-LDBL_MANT_DIG = DBL_MANT_DIG
-LDBL_DIG = DBL_DIG
-LDBL_MIN_EXP = DBL_MIN_EXP
-LDBL_MIN_10_EXP = DBL_MIN_10_EXP
-LDBL_MAX_EXP = DBL_MAX_EXP
-LDBL_MAX_10_EXP = DBL_MAX_10_EXP
-CHAR_BIT = (8)
-SCHAR_MIN = (-127-1)
-SCHAR_MAX = (127)
-CHAR_MIN = SCHAR_MIN
-CHAR_MAX = SCHAR_MAX
-MB_LEN_MAX = (1)
-SHRT_MIN = (-32767-1)
-SHRT_MAX = (32767)
-LONG_MIN = (-2147483647L-1)
-LONG_MAX = (2147483647L)
-INT_MIN = LONG_MIN
-INT_MAX = LONG_MAX
-ARG_MAX = (32768)
-ATEXIT_MAX = (32)
-CHILD_MAX = (1024)
-IOV_MAX = (256)
-FILESIZEBITS = (64)
-LINK_MAX = (1)
-LOGIN_NAME_MAX = (32)
-MAX_CANON = (255)
-MAX_INPUT = (255)
-NAME_MAX = (256)
-NGROUPS_MAX = (32)
-OPEN_MAX = (128)
-PATH_MAX = (1024)
-PIPE_MAX = (512)
-SSIZE_MAX = (2147483647L)
-TTY_NAME_MAX = (256)
-TZNAME_MAX = (32)
-SYMLINKS_MAX = (16)
-_POSIX_ARG_MAX = (32768)
-_POSIX_CHILD_MAX = (1024)
-_POSIX_LINK_MAX = (1)
-_POSIX_LOGIN_NAME_MAX = (9)
-_POSIX_MAX_CANON = (255)
-_POSIX_MAX_INPUT = (255)
-_POSIX_NAME_MAX = (255)
-_POSIX_NGROUPS_MAX = (0)
-_POSIX_OPEN_MAX = (128)
-_POSIX_PATH_MAX = (1024)
-_POSIX_PIPE_BUF = (512)
-_POSIX_SSIZE_MAX = (2147483647L)
-_POSIX_STREAM_MAX = (8)
-_POSIX_TTY_NAME_MAX = (256)
-_POSIX_TZNAME_MAX = (3)
-B_GENERAL_ERROR_BASE = LONG_MIN
-B_OS_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x1000
-B_APP_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x2000
-B_INTERFACE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x3000
-B_MEDIA_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x4000
-B_TRANSLATION_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x4800
-B_MIDI_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x5000
-B_STORAGE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x6000
-B_POSIX_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x7000
-B_MAIL_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x8000
-B_PRINT_ERROR_BASE = B_GENERAL_ERROR_BASE + 0x9000
-B_DEVICE_ERROR_BASE = B_GENERAL_ERROR_BASE + 0xa000
-B_ERRORS_END = (B_GENERAL_ERROR_BASE + 0xffff)
-E2BIG = (B_POSIX_ERROR_BASE + 1)
-ECHILD = (B_POSIX_ERROR_BASE + 2)
-EDEADLK = (B_POSIX_ERROR_BASE + 3)
-EFBIG = (B_POSIX_ERROR_BASE + 4)
-EMLINK = (B_POSIX_ERROR_BASE + 5)
-ENFILE = (B_POSIX_ERROR_BASE + 6)
-ENODEV = (B_POSIX_ERROR_BASE + 7)
-ENOLCK = (B_POSIX_ERROR_BASE + 8)
-ENOSYS = (B_POSIX_ERROR_BASE + 9)
-ENOTTY = (B_POSIX_ERROR_BASE + 10)
-ENXIO = (B_POSIX_ERROR_BASE + 11)
-ESPIPE = (B_POSIX_ERROR_BASE + 12)
-ESRCH = (B_POSIX_ERROR_BASE + 13)
-EFPOS = (B_POSIX_ERROR_BASE + 14)
-ESIGPARM = (B_POSIX_ERROR_BASE + 15)
-EDOM = (B_POSIX_ERROR_BASE + 16)
-ERANGE = (B_POSIX_ERROR_BASE + 17)
-EPROTOTYPE = (B_POSIX_ERROR_BASE + 18)
-EPROTONOSUPPORT = (B_POSIX_ERROR_BASE + 19)
-EPFNOSUPPORT = (B_POSIX_ERROR_BASE + 20)
-EAFNOSUPPORT = (B_POSIX_ERROR_BASE + 21)
-EADDRINUSE = (B_POSIX_ERROR_BASE + 22)
-EADDRNOTAVAIL = (B_POSIX_ERROR_BASE + 23)
-ENETDOWN = (B_POSIX_ERROR_BASE + 24)
-ENETUNREACH = (B_POSIX_ERROR_BASE + 25)
-ENETRESET = (B_POSIX_ERROR_BASE + 26)
-ECONNABORTED = (B_POSIX_ERROR_BASE + 27)
-ECONNRESET = (B_POSIX_ERROR_BASE + 28)
-EISCONN = (B_POSIX_ERROR_BASE + 29)
-ENOTCONN = (B_POSIX_ERROR_BASE + 30)
-ESHUTDOWN = (B_POSIX_ERROR_BASE + 31)
-ECONNREFUSED = (B_POSIX_ERROR_BASE + 32)
-EHOSTUNREACH = (B_POSIX_ERROR_BASE + 33)
-ENOPROTOOPT = (B_POSIX_ERROR_BASE + 34)
-ENOBUFS = (B_POSIX_ERROR_BASE + 35)
-EINPROGRESS = (B_POSIX_ERROR_BASE + 36)
-EALREADY = (B_POSIX_ERROR_BASE + 37)
-EILSEQ = (B_POSIX_ERROR_BASE + 38)
-ENOMSG = (B_POSIX_ERROR_BASE + 39)
-ESTALE = (B_POSIX_ERROR_BASE + 40)
-EOVERFLOW = (B_POSIX_ERROR_BASE + 41)
-EMSGSIZE = (B_POSIX_ERROR_BASE + 42)
-EOPNOTSUPP = (B_POSIX_ERROR_BASE + 43)
-ENOTSOCK = (B_POSIX_ERROR_BASE + 44)
-false = 0
-true = 1
-NULL = (0)
-FALSE = 0
-TRUE = 1
-
-# Included from TypeConstants.h
-B_HOST_IS_LENDIAN = 1
-B_HOST_IS_BENDIAN = 0
-def B_HOST_TO_LENDIAN_DOUBLE(arg): return (double)(arg)
-
-def B_HOST_TO_LENDIAN_FLOAT(arg): return (float)(arg)
-
-def B_HOST_TO_LENDIAN_INT64(arg): return (uint64)(arg)
-
-def B_HOST_TO_LENDIAN_INT32(arg): return (uint32)(arg)
-
-def B_HOST_TO_LENDIAN_INT16(arg): return (uint16)(arg)
-
-def B_HOST_TO_BENDIAN_DOUBLE(arg): return __swap_double(arg)
-
-def B_HOST_TO_BENDIAN_FLOAT(arg): return __swap_float(arg)
-
-def B_HOST_TO_BENDIAN_INT64(arg): return __swap_int64(arg)
-
-def B_HOST_TO_BENDIAN_INT32(arg): return __swap_int32(arg)
-
-def B_HOST_TO_BENDIAN_INT16(arg): return __swap_int16(arg)
-
-def B_LENDIAN_TO_HOST_DOUBLE(arg): return (double)(arg)
-
-def B_LENDIAN_TO_HOST_FLOAT(arg): return (float)(arg)
-
-def B_LENDIAN_TO_HOST_INT64(arg): return (uint64)(arg)
-
-def B_LENDIAN_TO_HOST_INT32(arg): return (uint32)(arg)
-
-def B_LENDIAN_TO_HOST_INT16(arg): return (uint16)(arg)
-
-def B_BENDIAN_TO_HOST_DOUBLE(arg): return __swap_double(arg)
-
-def B_BENDIAN_TO_HOST_FLOAT(arg): return __swap_float(arg)
-
-def B_BENDIAN_TO_HOST_INT64(arg): return __swap_int64(arg)
-
-def B_BENDIAN_TO_HOST_INT32(arg): return __swap_int32(arg)
-
-def B_BENDIAN_TO_HOST_INT16(arg): return __swap_int16(arg)
-
-B_HOST_IS_LENDIAN = 0
-B_HOST_IS_BENDIAN = 1
-def B_HOST_TO_LENDIAN_DOUBLE(arg): return __swap_double(arg)
-
-def B_HOST_TO_LENDIAN_FLOAT(arg): return __swap_float(arg)
-
-def B_HOST_TO_LENDIAN_INT64(arg): return __swap_int64(arg)
-
-def B_HOST_TO_LENDIAN_INT32(arg): return __swap_int32(arg)
-
-def B_HOST_TO_LENDIAN_INT16(arg): return __swap_int16(arg)
-
-def B_HOST_TO_BENDIAN_DOUBLE(arg): return (double)(arg)
-
-def B_HOST_TO_BENDIAN_FLOAT(arg): return (float)(arg)
-
-def B_HOST_TO_BENDIAN_INT64(arg): return (uint64)(arg)
-
-def B_HOST_TO_BENDIAN_INT32(arg): return (uint32)(arg)
-
-def B_HOST_TO_BENDIAN_INT16(arg): return (uint16)(arg)
-
-def B_LENDIAN_TO_HOST_DOUBLE(arg): return __swap_double(arg)
-
-def B_LENDIAN_TO_HOST_FLOAT(arg): return __swap_float(arg)
-
-def B_LENDIAN_TO_HOST_INT64(arg): return __swap_int64(arg)
-
-def B_LENDIAN_TO_HOST_INT32(arg): return __swap_int32(arg)
-
-def B_LENDIAN_TO_HOST_INT16(arg): return __swap_int16(arg)
-
-def B_BENDIAN_TO_HOST_DOUBLE(arg): return (double)(arg)
-
-def B_BENDIAN_TO_HOST_FLOAT(arg): return (float)(arg)
-
-def B_BENDIAN_TO_HOST_INT64(arg): return (uint64)(arg)
-
-def B_BENDIAN_TO_HOST_INT32(arg): return (uint32)(arg)
-
-def B_BENDIAN_TO_HOST_INT16(arg): return (uint16)(arg)
-
-def B_SWAP_DOUBLE(arg): return __swap_double(arg)
-
-def B_SWAP_FLOAT(arg): return __swap_float(arg)
-
-def B_SWAP_INT64(arg): return __swap_int64(arg)
-
-def B_SWAP_INT32(arg): return __swap_int32(arg)
-
-def B_SWAP_INT16(arg): return __swap_int16(arg)
-
-def htonl(x): return B_HOST_TO_BENDIAN_INT32(x)
-
-def ntohl(x): return B_BENDIAN_TO_HOST_INT32(x)
-
-def htons(x): return B_HOST_TO_BENDIAN_INT16(x)
-
-def ntohs(x): return B_BENDIAN_TO_HOST_INT16(x)
-
-AF_INET = 1
-INADDR_ANY = 0x00000000
-INADDR_BROADCAST = 0xffffffff
-INADDR_LOOPBACK = 0x7f000001
-SOL_SOCKET = 1
-SO_DEBUG = 1
-SO_REUSEADDR = 2
-SO_NONBLOCK = 3
-SO_REUSEPORT = 4
-MSG_OOB = 0x1
-SOCK_DGRAM = 1
-SOCK_STREAM = 2
-IPPROTO_UDP = 1
-IPPROTO_TCP = 2
-IPPROTO_ICMP = 3
-B_UDP_MAX_SIZE = (65536 - 1024)
-FD_SETSIZE = 256
-FDSETSIZE = FD_SETSIZE
-NFDBITS = 32
-def _FDMSKNO(fd): return ((fd) / NFDBITS)
-
-def _FDBITNO(fd): return ((fd) % NFDBITS)
diff --git a/Lib/plat-beos5/regen b/Lib/plat-beos5/regen
deleted file mode 100755
index c2d2f78b1d2..00000000000
--- a/Lib/plat-beos5/regen
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /bin/sh
-
-H2PY=../../Tools/scripts/h2py.py
-HEADERS=/boot/develop/headers
-
-set -v
-python $H2PY -i '(u_long)' $HEADERS/be/net/netinet/in.h
diff --git a/Lib/plat-darwin/IN.py b/Lib/plat-darwin/IN.py
index 9d7408654f1..6b6be33a5ad 100644
--- a/Lib/plat-darwin/IN.py
+++ b/Lib/plat-darwin/IN.py
@@ -1,6 +1,341 @@
# Generated by h2py from /usr/include/netinet/in.h
# Included from sys/appleapiopts.h
+
+# Included from sys/_types.h
+
+# Included from sys/cdefs.h
+def __P(protos): return protos
+
+def __STRING(x): return #x
+
+def __P(protos): return ()
+
+def __STRING(x): return "x"
+
+def __attribute__(x): return
+
+def __COPYRIGHT(s): return __IDSTRING(copyright,s)
+
+def __RCSID(s): return __IDSTRING(rcsid,s)
+
+def __SCCSID(s): return __IDSTRING(sccsid,s)
+
+def __PROJECT_VERSION(s): return __IDSTRING(project_version,s)
+
+__DARWIN_UNIX03 = 1
+__DARWIN_UNIX03 = 0
+__DARWIN_UNIX03 = 0
+__DARWIN_UNIX03 = 1
+__DARWIN_64_BIT_INO_T = 1
+__DARWIN_64_BIT_INO_T = 0
+__DARWIN_64_BIT_INO_T = 0
+__DARWIN_NON_CANCELABLE = 0
+__DARWIN_VERS_1050 = 1
+__DARWIN_VERS_1050 = 0
+__DARWIN_SUF_UNIX03 = "$UNIX2003"
+__DARWIN_SUF_UNIX03_SET = 1
+__DARWIN_SUF_UNIX03_SET = 0
+__DARWIN_SUF_64_BIT_INO_T = "$INODE64"
+__DARWIN_SUF_NON_CANCELABLE = "$NOCANCEL"
+__DARWIN_SUF_1050 = "$1050"
+__DARWIN_SUF_UNIX03_SET = 0
+__DARWIN_SUF_EXTSN = "$DARWIN_EXTSN"
+__DARWIN_LONG_DOUBLE_IS_DOUBLE = 0
+def __DARWIN_LDBL_COMPAT(x): return
+
+def __DARWIN_LDBL_COMPAT2(x): return
+
+__DARWIN_LONG_DOUBLE_IS_DOUBLE = 1
+def __DARWIN_LDBL_COMPAT(x): return
+
+def __DARWIN_LDBL_COMPAT2(x): return
+
+__DARWIN_LONG_DOUBLE_IS_DOUBLE = 0
+_DARWIN_FEATURE_LONG_DOUBLE_IS_DOUBLE = 1
+_DARWIN_FEATURE_UNIX_CONFORMANCE = 3
+_DARWIN_FEATURE_64_BIT_INODE = 1
+
+# Included from machine/_types.h
+__PTHREAD_SIZE__ = 1168
+__PTHREAD_ATTR_SIZE__ = 56
+__PTHREAD_MUTEXATTR_SIZE__ = 8
+__PTHREAD_MUTEX_SIZE__ = 56
+__PTHREAD_CONDATTR_SIZE__ = 8
+__PTHREAD_COND_SIZE__ = 40
+__PTHREAD_ONCE_SIZE__ = 8
+__PTHREAD_RWLOCK_SIZE__ = 192
+__PTHREAD_RWLOCKATTR_SIZE__ = 16
+__PTHREAD_SIZE__ = 596
+__PTHREAD_ATTR_SIZE__ = 36
+__PTHREAD_MUTEXATTR_SIZE__ = 8
+__PTHREAD_MUTEX_SIZE__ = 40
+__PTHREAD_CONDATTR_SIZE__ = 4
+__PTHREAD_COND_SIZE__ = 24
+__PTHREAD_ONCE_SIZE__ = 4
+__PTHREAD_RWLOCK_SIZE__ = 124
+__PTHREAD_RWLOCKATTR_SIZE__ = 12
+__DARWIN_NULL = 0
+
+# Included from stdint.h
+__WORDSIZE = 64
+__WORDSIZE = 32
+INT8_MAX = 127
+INT16_MAX = 32767
+INT32_MAX = 2147483647
+INT8_MIN = -128
+INT16_MIN = -32768
+INT32_MIN = (-INT32_MAX-1)
+UINT8_MAX = 255
+UINT16_MAX = 65535
+INT_LEAST8_MIN = INT8_MIN
+INT_LEAST16_MIN = INT16_MIN
+INT_LEAST32_MIN = INT32_MIN
+INT_LEAST8_MAX = INT8_MAX
+INT_LEAST16_MAX = INT16_MAX
+INT_LEAST32_MAX = INT32_MAX
+UINT_LEAST8_MAX = UINT8_MAX
+UINT_LEAST16_MAX = UINT16_MAX
+INT_FAST8_MIN = INT8_MIN
+INT_FAST16_MIN = INT16_MIN
+INT_FAST32_MIN = INT32_MIN
+INT_FAST8_MAX = INT8_MAX
+INT_FAST16_MAX = INT16_MAX
+INT_FAST32_MAX = INT32_MAX
+UINT_FAST8_MAX = UINT8_MAX
+UINT_FAST16_MAX = UINT16_MAX
+INTPTR_MIN = INT32_MIN
+INTPTR_MAX = INT32_MAX
+PTRDIFF_MIN = INT32_MIN
+PTRDIFF_MAX = INT32_MAX
+WCHAR_MAX = 0x7fffffff
+WCHAR_MIN = 0
+WCHAR_MIN = (-WCHAR_MAX-1)
+WINT_MIN = INT32_MIN
+WINT_MAX = INT32_MAX
+SIG_ATOMIC_MIN = INT32_MIN
+SIG_ATOMIC_MAX = INT32_MAX
+def INT8_C(v): return (v)
+
+def INT16_C(v): return (v)
+
+def INT32_C(v): return (v)
+
+
+# Included from sys/socket.h
+
+# Included from machine/_param.h
+SOCK_STREAM = 1
+SOCK_DGRAM = 2
+SOCK_RAW = 3
+SOCK_RDM = 4
+SOCK_SEQPACKET = 5
+SO_DEBUG = 0x0001
+SO_ACCEPTCONN = 0x0002
+SO_REUSEADDR = 0x0004
+SO_KEEPALIVE = 0x0008
+SO_DONTROUTE = 0x0010
+SO_BROADCAST = 0x0020
+SO_USELOOPBACK = 0x0040
+SO_LINGER = 0x0080
+SO_LINGER = 0x1080
+SO_OOBINLINE = 0x0100
+SO_REUSEPORT = 0x0200
+SO_TIMESTAMP = 0x0400
+SO_ACCEPTFILTER = 0x1000
+SO_DONTTRUNC = 0x2000
+SO_WANTMORE = 0x4000
+SO_WANTOOBFLAG = 0x8000
+SO_SNDBUF = 0x1001
+SO_RCVBUF = 0x1002
+SO_SNDLOWAT = 0x1003
+SO_RCVLOWAT = 0x1004
+SO_SNDTIMEO = 0x1005
+SO_RCVTIMEO = 0x1006
+SO_ERROR = 0x1007
+SO_TYPE = 0x1008
+SO_NREAD = 0x1020
+SO_NKE = 0x1021
+SO_NOSIGPIPE = 0x1022
+SO_NOADDRERR = 0x1023
+SO_NWRITE = 0x1024
+SO_REUSESHAREUID = 0x1025
+SO_NOTIFYCONFLICT = 0x1026
+SO_LINGER_SEC = 0x1080
+SO_RESTRICTIONS = 0x1081
+SO_RESTRICT_DENYIN = 0x00000001
+SO_RESTRICT_DENYOUT = 0x00000002
+SO_RESTRICT_DENYSET = (-2147483648)
+SO_LABEL = 0x1010
+SO_PEERLABEL = 0x1011
+SOL_SOCKET = 0xffff
+AF_UNSPEC = 0
+AF_UNIX = 1
+AF_LOCAL = AF_UNIX
+AF_INET = 2
+AF_IMPLINK = 3
+AF_PUP = 4
+AF_CHAOS = 5
+AF_NS = 6
+AF_ISO = 7
+AF_OSI = AF_ISO
+AF_ECMA = 8
+AF_DATAKIT = 9
+AF_CCITT = 10
+AF_SNA = 11
+AF_DECnet = 12
+AF_DLI = 13
+AF_LAT = 14
+AF_HYLINK = 15
+AF_APPLETALK = 16
+AF_ROUTE = 17
+AF_LINK = 18
+pseudo_AF_XTP = 19
+AF_COIP = 20
+AF_CNT = 21
+pseudo_AF_RTIP = 22
+AF_IPX = 23
+AF_SIP = 24
+pseudo_AF_PIP = 25
+AF_NDRV = 27
+AF_ISDN = 28
+AF_E164 = AF_ISDN
+pseudo_AF_KEY = 29
+AF_INET6 = 30
+AF_NATM = 31
+AF_SYSTEM = 32
+AF_NETBIOS = 33
+AF_PPP = 34
+AF_ATM = 30
+pseudo_AF_HDRCMPLT = 35
+AF_RESERVED_36 = 36
+AF_NETGRAPH = 32
+AF_MAX = 37
+SOCK_MAXADDRLEN = 255
+_SS_MAXSIZE = 128
+PF_UNSPEC = AF_UNSPEC
+PF_LOCAL = AF_LOCAL
+PF_UNIX = PF_LOCAL
+PF_INET = AF_INET
+PF_IMPLINK = AF_IMPLINK
+PF_PUP = AF_PUP
+PF_CHAOS = AF_CHAOS
+PF_NS = AF_NS
+PF_ISO = AF_ISO
+PF_OSI = AF_ISO
+PF_ECMA = AF_ECMA
+PF_DATAKIT = AF_DATAKIT
+PF_CCITT = AF_CCITT
+PF_SNA = AF_SNA
+PF_DECnet = AF_DECnet
+PF_DLI = AF_DLI
+PF_LAT = AF_LAT
+PF_HYLINK = AF_HYLINK
+PF_APPLETALK = AF_APPLETALK
+PF_ROUTE = AF_ROUTE
+PF_LINK = AF_LINK
+PF_XTP = pseudo_AF_XTP
+PF_COIP = AF_COIP
+PF_CNT = AF_CNT
+PF_SIP = AF_SIP
+PF_IPX = AF_IPX
+PF_RTIP = pseudo_AF_RTIP
+PF_PIP = pseudo_AF_PIP
+PF_NDRV = AF_NDRV
+PF_ISDN = AF_ISDN
+PF_KEY = pseudo_AF_KEY
+PF_INET6 = AF_INET6
+PF_NATM = AF_NATM
+PF_SYSTEM = AF_SYSTEM
+PF_NETBIOS = AF_NETBIOS
+PF_PPP = AF_PPP
+PF_RESERVED_36 = AF_RESERVED_36
+PF_ATM = AF_ATM
+PF_NETGRAPH = AF_NETGRAPH
+PF_MAX = AF_MAX
+NET_MAXID = AF_MAX
+NET_RT_DUMP = 1
+NET_RT_FLAGS = 2
+NET_RT_IFLIST = 3
+NET_RT_STAT = 4
+NET_RT_TRASH = 5
+NET_RT_IFLIST2 = 6
+NET_RT_DUMP2 = 7
+NET_RT_MAXID = 8
+SOMAXCONN = 128
+MSG_OOB = 0x1
+MSG_PEEK = 0x2
+MSG_DONTROUTE = 0x4
+MSG_EOR = 0x8
+MSG_TRUNC = 0x10
+MSG_CTRUNC = 0x20
+MSG_WAITALL = 0x40
+MSG_DONTWAIT = 0x80
+MSG_EOF = 0x100
+MSG_WAITSTREAM = 0x200
+MSG_FLUSH = 0x400
+MSG_HOLD = 0x800
+MSG_SEND = 0x1000
+MSG_HAVEMORE = 0x2000
+MSG_RCVMORE = 0x4000
+MSG_NEEDSA = 0x10000
+CMGROUP_MAX = 16
+SCM_RIGHTS = 0x01
+SCM_TIMESTAMP = 0x02
+SCM_CREDS = 0x03
+SHUT_RD = 0
+SHUT_WR = 1
+SHUT_RDWR = 2
+
+# Included from machine/endian.h
+
+# Included from sys/_endian.h
+def ntohl(x): return (x)
+
+def ntohs(x): return (x)
+
+def htonl(x): return (x)
+
+def htons(x): return (x)
+
+def NTOHL(x): return (x)
+
+def NTOHS(x): return (x)
+
+def HTONL(x): return (x)
+
+def HTONS(x): return (x)
+
+
+# Included from libkern/_OSByteOrder.h
+def __DARWIN_OSSwapConstInt16(x): return \
+
+def __DARWIN_OSSwapConstInt32(x): return \
+
+def __DARWIN_OSSwapConstInt64(x): return \
+
+
+# Included from libkern/i386/_OSByteOrder.h
+def __DARWIN_OSSwapInt16(x): return \
+
+def __DARWIN_OSSwapInt32(x): return \
+
+def __DARWIN_OSSwapInt64(x): return \
+
+def __DARWIN_OSSwapInt16(x): return _OSSwapInt16(x)
+
+def __DARWIN_OSSwapInt32(x): return _OSSwapInt32(x)
+
+def __DARWIN_OSSwapInt64(x): return _OSSwapInt64(x)
+
+def ntohs(x): return __DARWIN_OSSwapInt16(x)
+
+def htons(x): return __DARWIN_OSSwapInt16(x)
+
+def ntohl(x): return __DARWIN_OSSwapInt32(x)
+
+def htonl(x): return __DARWIN_OSSwapInt32(x)
+
IPPROTO_IP = 0
IPPROTO_HOPOPTS = 0
IPPROTO_ICMP = 1
@@ -107,40 +442,41 @@ IPPROTO_DIVERT = 254
IPPROTO_RAW = 255
IPPROTO_MAX = 256
IPPROTO_DONE = 257
-IPPORT_RESERVED = 1024
+__DARWIN_IPPORT_RESERVED = 1024
+IPPORT_RESERVED = __DARWIN_IPPORT_RESERVED
IPPORT_USERRESERVED = 5000
IPPORT_HIFIRSTAUTO = 49152
IPPORT_HILASTAUTO = 65535
IPPORT_RESERVEDSTART = 600
-def IN_CLASSA(i): return (((u_int32_t)(i) & 0x80000000) == 0)
+def IN_CLASSA(i): return (((u_int32_t)(i) & (-2147483648)) == 0)
-IN_CLASSA_NET = 0xff000000
+IN_CLASSA_NET = (-16777216)
IN_CLASSA_NSHIFT = 24
IN_CLASSA_HOST = 0x00ffffff
IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((u_int32_t)(i) & 0xc0000000) == 0x80000000)
+def IN_CLASSB(i): return (((u_int32_t)(i) & (-1073741824)) == (-2147483648))
-IN_CLASSB_NET = 0xffff0000
+IN_CLASSB_NET = (-65536)
IN_CLASSB_NSHIFT = 16
IN_CLASSB_HOST = 0x0000ffff
IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((u_int32_t)(i) & 0xe0000000) == 0xc0000000)
+def IN_CLASSC(i): return (((u_int32_t)(i) & (-536870912)) == (-1073741824))
-IN_CLASSC_NET = 0xffffff00
+IN_CLASSC_NET = (-256)
IN_CLASSC_NSHIFT = 8
IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((u_int32_t)(i) & 0xf0000000) == 0xe0000000)
+def IN_CLASSD(i): return (((u_int32_t)(i) & (-268435456)) == (-536870912))
-IN_CLASSD_NET = 0xf0000000
+IN_CLASSD_NET = (-268435456)
IN_CLASSD_NSHIFT = 28
IN_CLASSD_HOST = 0x0fffffff
def IN_MULTICAST(i): return IN_CLASSD(i)
-def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
+def IN_EXPERIMENTAL(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456))
-def IN_BADCLASS(i): return (((u_int32_t)(i) & 0xf0000000) == 0xf0000000)
+def IN_BADCLASS(i): return (((u_int32_t)(i) & (-268435456)) == (-268435456))
-INADDR_NONE = 0xffffffff
+INADDR_NONE = (-1)
def IN_LINKLOCAL(i): return (((u_int32_t)(i) & IN_CLASSB_NET) == IN_LINKLOCALNETNUM)
IN_LOOPBACKNET = 127
@@ -168,6 +504,7 @@ IP_RECVIF = 20
IP_IPSEC_POLICY = 21
IP_FAITH = 22
IP_STRIPHDR = 23
+IP_RECVTTL = 24
IP_FW_ADD = 40
IP_FW_DEL = 41
IP_FW_FLUSH = 42
@@ -185,6 +522,10 @@ IP_DUMMYNET_CONFIGURE = 60
IP_DUMMYNET_DEL = 61
IP_DUMMYNET_FLUSH = 62
IP_DUMMYNET_GET = 64
+IP_TRAFFIC_MGT_BACKGROUND = 65
+IP_FORCE_OUT_IFP = 69
+TRAFFIC_MGT_SO_BACKGROUND = 0x0001
+TRAFFIC_MGT_SO_BG_SUPPRESSED = 0x0002
IP_DEFAULT_MULTICAST_TTL = 1
IP_DEFAULT_MULTICAST_LOOP = 1
IP_MAX_MEMBERSHIPS = 20
@@ -218,22 +559,6 @@ IPV6PORT_ANONMAX = 65535
IPV6PORT_RESERVEDMIN = 600
IPV6PORT_RESERVEDMAX = (IPV6PORT_RESERVED-1)
INET6_ADDRSTRLEN = 46
-IPV6_ADDR_INT32_ONE = 1
-IPV6_ADDR_INT32_TWO = 2
-IPV6_ADDR_INT32_MNL = 0xff010000
-IPV6_ADDR_INT32_MLL = 0xff020000
-IPV6_ADDR_INT32_SMP = 0x0000ffff
-IPV6_ADDR_INT16_ULL = 0xfe80
-IPV6_ADDR_INT16_USL = 0xfec0
-IPV6_ADDR_INT16_MLL = 0xff02
-IPV6_ADDR_INT32_ONE = 0x01000000
-IPV6_ADDR_INT32_TWO = 0x02000000
-IPV6_ADDR_INT32_MNL = 0x000001ff
-IPV6_ADDR_INT32_MLL = 0x000002ff
-IPV6_ADDR_INT32_SMP = 0xffff0000
-IPV6_ADDR_INT16_ULL = 0x80fe
-IPV6_ADDR_INT16_USL = 0xc0fe
-IPV6_ADDR_INT16_MLL = 0x02ff
def IN6_IS_ADDR_UNSPECIFIED(a): return \
def IN6_IS_ADDR_LOOPBACK(a): return \
@@ -242,11 +567,6 @@ def IN6_IS_ADDR_V4COMPAT(a): return \
def IN6_IS_ADDR_V4MAPPED(a): return \
-IPV6_ADDR_SCOPE_NODELOCAL = 0x01
-IPV6_ADDR_SCOPE_LINKLOCAL = 0x02
-IPV6_ADDR_SCOPE_SITELOCAL = 0x05
-IPV6_ADDR_SCOPE_ORGLOCAL = 0x08
-IPV6_ADDR_SCOPE_GLOBAL = 0x0e
__IPV6_ADDR_SCOPE_NODELOCAL = 0x01
__IPV6_ADDR_SCOPE_LINKLOCAL = 0x02
__IPV6_ADDR_SCOPE_SITELOCAL = 0x05
@@ -266,22 +586,6 @@ def IN6_IS_ADDR_MC_ORGLOCAL(a): return \
def IN6_IS_ADDR_MC_GLOBAL(a): return \
-def IN6_IS_ADDR_MC_NODELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_LINKLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_SITELOCAL(a): return \
-
-def IN6_IS_ADDR_MC_ORGLOCAL(a): return \
-
-def IN6_IS_ADDR_MC_GLOBAL(a): return \
-
-def IN6_IS_SCOPE_LINKLOCAL(a): return \
-
-def IFA6_IS_DEPRECATED(a): return \
-
-def IFA6_IS_INVALID(a): return \
-
IPV6_OPTIONS = 1
IPV6_RECVOPTS = 5
IPV6_RECVRETOPTS = 6
@@ -354,4 +658,5 @@ IPV6CTL_TEMPPLTIME = 33
IPV6CTL_TEMPVLTIME = 34
IPV6CTL_AUTO_LINKLOCAL = 35
IPV6CTL_RIP6STATS = 36
-IPV6CTL_MAXID = 37
+IPV6CTL_MAXFRAGS = 41
+IPV6CTL_MAXID = 42
diff --git a/Lib/plat-irix5/AL.py b/Lib/plat-irix5/AL.py
deleted file mode 100644
index 3b43d2c8bc6..00000000000
--- a/Lib/plat-irix5/AL.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the AL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-RATE_48000 = 48000
-RATE_44100 = 44100
-RATE_32000 = 32000
-RATE_22050 = 22050
-RATE_16000 = 16000
-RATE_11025 = 11025
-RATE_8000 = 8000
-
-SAMPFMT_TWOSCOMP= 1
-SAMPFMT_FLOAT = 32
-SAMPFMT_DOUBLE = 64
-
-SAMPLE_8 = 1
-SAMPLE_16 = 2
- # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
-SAMPLE_24 = 4
-
-MONO = 1
-STEREO = 2
-QUADRO = 4 # 4CHANNEL is not a legal Python name
-
-INPUT_LINE = 0
-INPUT_MIC = 1
-INPUT_DIGITAL = 2
-
-MONITOR_OFF = 0
-MONITOR_ON = 1
-
-ERROR_NUMBER = 0
-ERROR_TYPE = 1
-ERROR_LOCATION_LSP = 2
-ERROR_LOCATION_MSP = 3
-ERROR_LENGTH = 4
-
-ERROR_INPUT_UNDERFLOW = 0
-ERROR_OUTPUT_OVERFLOW = 1
-
-# These seem to be not supported anymore:
-##HOLD, RELEASE = 0, 1
-##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
-
-DEFAULT_DEVICE = 1
-
-INPUT_SOURCE = 0
-LEFT_INPUT_ATTEN = 1
-RIGHT_INPUT_ATTEN = 2
-INPUT_RATE = 3
-OUTPUT_RATE = 4
-LEFT_SPEAKER_GAIN = 5
-RIGHT_SPEAKER_GAIN = 6
-INPUT_COUNT = 7
-OUTPUT_COUNT = 8
-UNUSED_COUNT = 9
-SYNC_INPUT_TO_AES = 10
-SYNC_OUTPUT_TO_AES = 11
-MONITOR_CTL = 12
-LEFT_MONITOR_ATTEN = 13
-RIGHT_MONITOR_ATTEN = 14
-
-ENUM_VALUE = 0 # only certain values are valid
-RANGE_VALUE = 1 # any value in range is valid
diff --git a/Lib/plat-irix5/CD.py b/Lib/plat-irix5/CD.py
deleted file mode 100644
index 5398f4656cd..00000000000
--- a/Lib/plat-irix5/CD.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the CD module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-ERROR = 0
-NODISC = 1
-READY = 2
-PLAYING = 3
-PAUSED = 4
-STILL = 5
-
-AUDIO = 0
-PNUM = 1
-INDEX = 2
-PTIME = 3
-ATIME = 4
-CATALOG = 5
-IDENT = 6
-CONTROL = 7
-
-CDDA_DATASIZE = 2352
-
-##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ))
-##CDDA_BLOCKSIZE = (sizeof(struct cdframe))
-##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2)
-##
-##CDQ_PREEMP_MASK = 0xd
-##CDQ_COPY_MASK = 0xb
-##CDQ_DDATA_MASK = 0xd
-##CDQ_BROADCAST_MASK = 0x8
-##CDQ_PREEMPHASIS = 0x1
-##CDQ_COPY_PERMITTED = 0x2
-##CDQ_DIGITAL_DATA = 0x4
-##CDQ_BROADCAST_USE = 0x8
-##
-##CDQ_MODE1 = 0x1
-##CDQ_MODE2 = 0x2
-##CDQ_MODE3 = 0x3
diff --git a/Lib/plat-irix5/CL.py b/Lib/plat-irix5/CL.py
deleted file mode 100644
index 15130e4306e..00000000000
--- a/Lib/plat-irix5/CL.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Backward compatible module CL.
-# All relevant symbols are now defined in the module cl.
-from warnings import warnpy3k
-warnpy3k("the CL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-try:
- from cl import *
-except ImportError:
- from CL_old import *
-else:
- del CompressImage
- del DecompressImage
- del GetAlgorithmName
- del OpenCompressor
- del OpenDecompressor
- del QueryAlgorithms
- del QueryMaxHeaderSize
- del QueryScheme
- del QuerySchemeFromName
- del SetDefault
- del SetMax
- del SetMin
- try:
- del cvt_type
- except NameError:
- pass
- del error
diff --git a/Lib/plat-irix5/CL_old.py b/Lib/plat-irix5/CL_old.py
deleted file mode 100644
index 892f86c0114..00000000000
--- a/Lib/plat-irix5/CL_old.py
+++ /dev/null
@@ -1,240 +0,0 @@
-#
-# cl.h - Compression Library typedefs and prototypes
-#
-# 01/07/92 Cleanup by Brian Knittel
-# 02/18/92 Original Version by Brian Knittel
-#
-
-#
-# originalFormat parameter values
-#
-from warnings import warnpy3k
-warnpy3k("the CL_old module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-MAX_NUMBER_OF_ORIGINAL_FORMATS = 32
-
-# Audio
-MONO = 0
-STEREO_INTERLEAVED = 1
-
-# Video
-# YUV is defined to be the same thing as YCrCb (luma and two chroma components).
-# 422 is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
-# horizontally, packed as U Y1 V Y2 (byte order).
-# 422HC is appended to YUV (or YCrCb) if the chroma is sub-sampled by 2
-# vertically in addition to horizontally, and is packed the same as
-# 422 except that U & V are not valid on the second line.
-#
-RGB = 0
-RGBX = 1
-RGBA = 2
-RGB332 = 3
-
-GRAYSCALE = 4
-Y = 4
-YUV = 5
-YCbCr = 5
-YUV422 = 6 # 4:2:2 sampling
-YCbCr422 = 6 # 4:2:2 sampling
-YUV422HC = 7 # 4:1:1 sampling
-YCbCr422HC = 7 # 4:1:1 sampling
-YUV422DC = 7 # 4:1:1 sampling
-YCbCr422DC = 7 # 4:1:1 sampling
-
-BEST_FIT = -1
-
-def BytesPerSample(s):
- if s in (MONO, YUV):
- return 2
- elif s == STEREO_INTERLEAVED:
- return 4
- else:
- return 0
-
-def BytesPerPixel(f):
- if f in (RGB, YUV):
- return 3
- elif f in (RGBX, RGBA):
- return 4
- elif f in (RGB332, GRAYSCALE):
- return 1
- else:
- return 2
-
-def AudioFormatName(f):
- if f == MONO:
- return 'MONO'
- elif f == STEREO_INTERLEAVED:
- return 'STEREO_INTERLEAVED'
- else:
- return 'Not a valid format'
-
-def VideoFormatName(f):
- if f == RGB:
- return 'RGB'
- elif f == RGBX:
- return 'RGBX'
- elif f == RGBA:
- return 'RGBA'
- elif f == RGB332:
- return 'RGB332'
- elif f == GRAYSCALE:
- return 'GRAYSCALE'
- elif f == YUV:
- return 'YUV'
- elif f == YUV422:
- return 'YUV422'
- elif f == YUV422DC:
- return 'YUV422DC'
- else:
- return 'Not a valid format'
-
-MAX_NUMBER_OF_AUDIO_ALGORITHMS = 32
-MAX_NUMBER_OF_VIDEO_ALGORITHMS = 32
-
-#
-# Algorithm types
-#
-AUDIO = 0
-VIDEO = 1
-
-def AlgorithmNumber(scheme):
- return scheme & 0x7fff
-def AlgorithmType(scheme):
- return (scheme >> 15) & 1
-def Algorithm(type, n):
- return n | ((type & 1) << 15)
-
-#
-# "compressionScheme" argument values
-#
-UNKNOWN_SCHEME = -1
-
-UNCOMPRESSED_AUDIO = Algorithm(AUDIO, 0)
-G711_ULAW = Algorithm(AUDIO, 1)
-ULAW = Algorithm(AUDIO, 1)
-G711_ALAW = Algorithm(AUDIO, 2)
-ALAW = Algorithm(AUDIO, 2)
-AWARE_MPEG_AUDIO = Algorithm(AUDIO, 3)
-AWARE_MULTIRATE = Algorithm(AUDIO, 4)
-
-UNCOMPRESSED = Algorithm(VIDEO, 0)
-UNCOMPRESSED_VIDEO = Algorithm(VIDEO, 0)
-RLE = Algorithm(VIDEO, 1)
-JPEG = Algorithm(VIDEO, 2)
-MPEG_VIDEO = Algorithm(VIDEO, 3)
-MVC1 = Algorithm(VIDEO, 4)
-RTR = Algorithm(VIDEO, 5)
-RTR1 = Algorithm(VIDEO, 5)
-
-#
-# Parameters
-#
-MAX_NUMBER_OF_PARAMS = 256
-# Default Parameters
-IMAGE_WIDTH = 0
-IMAGE_HEIGHT = 1
-ORIGINAL_FORMAT = 2
-INTERNAL_FORMAT = 3
-COMPONENTS = 4
-BITS_PER_COMPONENT = 5
-FRAME_RATE = 6
-COMPRESSION_RATIO = 7
-EXACT_COMPRESSION_RATIO = 8
-FRAME_BUFFER_SIZE = 9
-COMPRESSED_BUFFER_SIZE = 10
-BLOCK_SIZE = 11
-PREROLL = 12
-FRAME_TYPE = 13
-ALGORITHM_ID = 14
-ALGORITHM_VERSION = 15
-ORIENTATION = 16
-NUMBER_OF_FRAMES = 17
-SPEED = 18
-LAST_FRAME_INDEX = 19
-NUMBER_OF_PARAMS = 20
-
-# JPEG Specific Parameters
-QUALITY_FACTOR = NUMBER_OF_PARAMS + 0
-
-# MPEG Specific Parameters
-END_OF_SEQUENCE = NUMBER_OF_PARAMS + 0
-
-# RTR Specific Parameters
-QUALITY_LEVEL = NUMBER_OF_PARAMS + 0
-ZOOM_X = NUMBER_OF_PARAMS + 1
-ZOOM_Y = NUMBER_OF_PARAMS + 2
-
-#
-# Parameter value types
-#
-ENUM_VALUE = 0 # only certain constant values are valid
-RANGE_VALUE = 1 # any value in a given range is valid
-FLOATING_ENUM_VALUE = 2 # only certain constant floating point values are valid
-FLOATING_RANGE_VALUE = 3 # any value in a given floating point range is valid
-
-#
-# Algorithm Functionality
-#
-DECOMPRESSOR = 1
-COMPRESSOR = 2
-CODEC = 3
-
-#
-# Buffer types
-#
-NONE = 0
-FRAME = 1
-DATA = 2
-
-#
-# Frame types
-#
-NONE = 0
-KEYFRAME = 1
-INTRA = 1
-PREDICTED = 2
-BIDIRECTIONAL = 3
-
-#
-# Orientations
-#
-TOP_DOWN = 0
-BOTTOM_UP = 1
-
-#
-# SGI Proprietary Algorithm Header Start Code
-#
-HEADER_START_CODE = 0xc1C0DEC
-
-#
-# error codes
-#
-
-BAD_NO_BUFFERSPACE = -2 # no space for internal buffers
-BAD_PVBUFFER = -3 # param/val buffer doesn't make sense
-BAD_BUFFERLENGTH_NEG = -4 # negative buffer length
-BAD_BUFFERLENGTH_ODD = -5 # odd length parameter/value buffer
-BAD_PARAM = -6 # invalid parameter
-BAD_COMPRESSION_SCHEME = -7 # compression scheme parameter invalid
-BAD_COMPRESSOR_HANDLE = -8 # compression handle parameter invalid
-BAD_COMPRESSOR_HANDLE_POINTER = -9 # compression handle pointer invalid
-BAD_BUFFER_HANDLE = -10 # buffer handle invalid
-BAD_BUFFER_QUERY_SIZE = -11 # buffer query size too large
-JPEG_ERROR = -12 # error from libjpeg
-BAD_FRAME_SIZE = -13 # frame size invalid
-PARAM_OUT_OF_RANGE = -14 # parameter out of range
-ADDED_ALGORITHM_ERROR = -15 # added algorithm had a unique error
-BAD_ALGORITHM_TYPE = -16 # bad algorithm type
-BAD_ALGORITHM_NAME = -17 # bad algorithm name
-BAD_BUFFERING = -18 # bad buffering calls
-BUFFER_NOT_CREATED = -19 # buffer not created
-BAD_BUFFER_EXISTS = -20 # buffer already created
-BAD_INTERNAL_FORMAT = -21 # invalid internal format
-BAD_BUFFER_POINTER = -22 # invalid buffer pointer
-FRAME_BUFFER_SIZE_ZERO = -23 # frame buffer has zero size
-BAD_STREAM_HEADER = -24 # invalid stream header
-
-BAD_LICENSE = -25 # netls license not valid
-AWARE_ERROR = -26 # error from libawcmp
diff --git a/Lib/plat-irix5/DEVICE.py b/Lib/plat-irix5/DEVICE.py
deleted file mode 100644
index 14fd5347b96..00000000000
--- a/Lib/plat-irix5/DEVICE.py
+++ /dev/null
@@ -1,404 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the DEVICE module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NULLDEV = 0
-BUTOFFSET = 1
-VALOFFSET = 256
-PSEUDOFFSET = 512
-BUT2OFFSET = 3840
-TIMOFFSET = 515
-XKBDOFFSET = 143
-BUTCOUNT = 255
-VALCOUNT = 256
-TIMCOUNT = 4
-XKBDCOUNT = 28
-USERBUTOFFSET = 4096
-USERVALOFFSET = 12288
-USERPSEUDOFFSET = 16384
-BUT0 = 1
-BUT1 = 2
-BUT2 = 3
-BUT3 = 4
-BUT4 = 5
-BUT5 = 6
-BUT6 = 7
-BUT7 = 8
-BUT8 = 9
-BUT9 = 10
-BUT10 = 11
-BUT11 = 12
-BUT12 = 13
-BUT13 = 14
-BUT14 = 15
-BUT15 = 16
-BUT16 = 17
-BUT17 = 18
-BUT18 = 19
-BUT19 = 20
-BUT20 = 21
-BUT21 = 22
-BUT22 = 23
-BUT23 = 24
-BUT24 = 25
-BUT25 = 26
-BUT26 = 27
-BUT27 = 28
-BUT28 = 29
-BUT29 = 30
-BUT30 = 31
-BUT31 = 32
-BUT32 = 33
-BUT33 = 34
-BUT34 = 35
-BUT35 = 36
-BUT36 = 37
-BUT37 = 38
-BUT38 = 39
-BUT39 = 40
-BUT40 = 41
-BUT41 = 42
-BUT42 = 43
-BUT43 = 44
-BUT44 = 45
-BUT45 = 46
-BUT46 = 47
-BUT47 = 48
-BUT48 = 49
-BUT49 = 50
-BUT50 = 51
-BUT51 = 52
-BUT52 = 53
-BUT53 = 54
-BUT54 = 55
-BUT55 = 56
-BUT56 = 57
-BUT57 = 58
-BUT58 = 59
-BUT59 = 60
-BUT60 = 61
-BUT61 = 62
-BUT62 = 63
-BUT63 = 64
-BUT64 = 65
-BUT65 = 66
-BUT66 = 67
-BUT67 = 68
-BUT68 = 69
-BUT69 = 70
-BUT70 = 71
-BUT71 = 72
-BUT72 = 73
-BUT73 = 74
-BUT74 = 75
-BUT75 = 76
-BUT76 = 77
-BUT77 = 78
-BUT78 = 79
-BUT79 = 80
-BUT80 = 81
-BUT81 = 82
-BUT82 = 83
-MAXKBDBUT = 83
-BUT100 = 101
-BUT101 = 102
-BUT102 = 103
-BUT103 = 104
-BUT104 = 105
-BUT105 = 106
-BUT106 = 107
-BUT107 = 108
-BUT108 = 109
-BUT109 = 110
-BUT110 = 111
-BUT111 = 112
-BUT112 = 113
-BUT113 = 114
-BUT114 = 115
-BUT115 = 116
-BUT116 = 117
-BUT117 = 118
-BUT118 = 119
-BUT119 = 120
-BUT120 = 121
-BUT121 = 122
-BUT122 = 123
-BUT123 = 124
-BUT124 = 125
-BUT125 = 126
-BUT126 = 127
-BUT127 = 128
-BUT128 = 129
-BUT129 = 130
-BUT130 = 131
-BUT131 = 132
-BUT132 = 133
-BUT133 = 134
-BUT134 = 135
-BUT135 = 136
-BUT136 = 137
-BUT137 = 138
-BUT138 = 139
-BUT139 = 140
-BUT140 = 141
-BUT141 = 142
-BUT142 = 143
-BUT143 = 144
-BUT144 = 145
-BUT145 = 146
-BUT146 = 147
-BUT147 = 148
-BUT148 = 149
-BUT149 = 150
-BUT150 = 151
-BUT151 = 152
-BUT152 = 153
-BUT153 = 154
-BUT154 = 155
-BUT155 = 156
-BUT156 = 157
-BUT157 = 158
-BUT158 = 159
-BUT159 = 160
-BUT160 = 161
-BUT161 = 162
-BUT162 = 163
-BUT163 = 164
-BUT164 = 165
-BUT165 = 166
-BUT166 = 167
-BUT167 = 168
-BUT168 = 169
-BUT181 = 182
-BUT182 = 183
-BUT183 = 184
-BUT184 = 185
-BUT185 = 186
-BUT186 = 187
-BUT187 = 188
-BUT188 = 189
-BUT189 = 190
-MOUSE1 = 101
-MOUSE2 = 102
-MOUSE3 = 103
-LEFTMOUSE = 103
-MIDDLEMOUSE = 102
-RIGHTMOUSE = 101
-LPENBUT = 104
-BPAD0 = 105
-BPAD1 = 106
-BPAD2 = 107
-BPAD3 = 108
-LPENVALID = 109
-SWBASE = 111
-SW0 = 111
-SW1 = 112
-SW2 = 113
-SW3 = 114
-SW4 = 115
-SW5 = 116
-SW6 = 117
-SW7 = 118
-SW8 = 119
-SW9 = 120
-SW10 = 121
-SW11 = 122
-SW12 = 123
-SW13 = 124
-SW14 = 125
-SW15 = 126
-SW16 = 127
-SW17 = 128
-SW18 = 129
-SW19 = 130
-SW20 = 131
-SW21 = 132
-SW22 = 133
-SW23 = 134
-SW24 = 135
-SW25 = 136
-SW26 = 137
-SW27 = 138
-SW28 = 139
-SW29 = 140
-SW30 = 141
-SW31 = 142
-SBBASE = 182
-SBPICK = 182
-SBBUT1 = 183
-SBBUT2 = 184
-SBBUT3 = 185
-SBBUT4 = 186
-SBBUT5 = 187
-SBBUT6 = 188
-SBBUT7 = 189
-SBBUT8 = 190
-AKEY = 11
-BKEY = 36
-CKEY = 28
-DKEY = 18
-EKEY = 17
-FKEY = 19
-GKEY = 26
-HKEY = 27
-IKEY = 40
-JKEY = 34
-KKEY = 35
-LKEY = 42
-MKEY = 44
-NKEY = 37
-OKEY = 41
-PKEY = 48
-QKEY = 10
-RKEY = 24
-SKEY = 12
-TKEY = 25
-UKEY = 33
-VKEY = 29
-WKEY = 16
-XKEY = 21
-YKEY = 32
-ZKEY = 20
-ZEROKEY = 46
-ONEKEY = 8
-TWOKEY = 14
-THREEKEY = 15
-FOURKEY = 22
-FIVEKEY = 23
-SIXKEY = 30
-SEVENKEY = 31
-EIGHTKEY = 38
-NINEKEY = 39
-BREAKKEY = 1
-SETUPKEY = 2
-CTRLKEY = 3
-LEFTCTRLKEY = CTRLKEY
-CAPSLOCKKEY = 4
-RIGHTSHIFTKEY = 5
-LEFTSHIFTKEY = 6
-NOSCRLKEY = 13
-ESCKEY = 7
-TABKEY = 9
-RETKEY = 51
-SPACEKEY = 83
-LINEFEEDKEY = 60
-BACKSPACEKEY = 61
-DELKEY = 62
-SEMICOLONKEY = 43
-PERIODKEY = 52
-COMMAKEY = 45
-QUOTEKEY = 50
-ACCENTGRAVEKEY = 55
-MINUSKEY = 47
-VIRGULEKEY = 53
-BACKSLASHKEY = 57
-EQUALKEY = 54
-LEFTBRACKETKEY = 49
-RIGHTBRACKETKEY = 56
-LEFTARROWKEY = 73
-DOWNARROWKEY = 74
-RIGHTARROWKEY = 80
-UPARROWKEY = 81
-PAD0 = 59
-PAD1 = 58
-PAD2 = 64
-PAD3 = 65
-PAD4 = 63
-PAD5 = 69
-PAD6 = 70
-PAD7 = 67
-PAD8 = 68
-PAD9 = 75
-PADPF1 = 72
-PADPF2 = 71
-PADPF3 = 79
-PADPF4 = 78
-PADPERIOD = 66
-PADMINUS = 76
-PADCOMMA = 77
-PADENTER = 82
-LEFTALTKEY = 143
-RIGHTALTKEY = 144
-RIGHTCTRLKEY = 145
-F1KEY = 146
-F2KEY = 147
-F3KEY = 148
-F4KEY = 149
-F5KEY = 150
-F6KEY = 151
-F7KEY = 152
-F8KEY = 153
-F9KEY = 154
-F10KEY = 155
-F11KEY = 156
-F12KEY = 157
-PRINTSCREENKEY = 158
-SCROLLLOCKKEY = 159
-PAUSEKEY = 160
-INSERTKEY = 161
-HOMEKEY = 162
-PAGEUPKEY = 163
-ENDKEY = 164
-PAGEDOWNKEY = 165
-NUMLOCKKEY = 166
-PADVIRGULEKEY = 167
-PADASTERKEY = 168
-PADPLUSKEY = 169
-SGIRESERVED = 256
-DIAL0 = 257
-DIAL1 = 258
-DIAL2 = 259
-DIAL3 = 260
-DIAL4 = 261
-DIAL5 = 262
-DIAL6 = 263
-DIAL7 = 264
-DIAL8 = 265
-MOUSEX = 266
-MOUSEY = 267
-LPENX = 268
-LPENY = 269
-BPADX = 270
-BPADY = 271
-CURSORX = 272
-CURSORY = 273
-GHOSTX = 274
-GHOSTY = 275
-SBTX = 276
-SBTY = 277
-SBTZ = 278
-SBRX = 279
-SBRY = 280
-SBRZ = 281
-SBPERIOD = 282
-TIMER0 = 515
-TIMER1 = 516
-TIMER2 = 517
-TIMER3 = 518
-KEYBD = 513
-RAWKEYBD = 514
-VALMARK = 523
-REDRAW = 528
-INPUTCHANGE = 534
-QFULL = 535
-QREADERROR = 538
-WINFREEZE = 539
-WINTHAW = 540
-REDRAWICONIC = 541
-WINQUIT = 542
-DEPTHCHANGE = 543
-WINSHUT = 546
-DRAWOVERLAY = 547
-VIDEO = 548
-MENUBUTTON = RIGHTMOUSE
-WINCLOSE = 537
-KEYBDFNAMES = 544
-KEYBDFSTRINGS = 545
-MAXSGIDEVICE = 20000
-GERROR = 524
-WMSEND = 529
-WMREPLY = 530
-WMGFCLOSE = 531
-WMTXCLOSE = 532
-MODECHANGE = 533
-PIECECHANGE = 536
diff --git a/Lib/plat-irix5/ERRNO.py b/Lib/plat-irix5/ERRNO.py
deleted file mode 100644
index d9ab7a4a967..00000000000
--- a/Lib/plat-irix5/ERRNO.py
+++ /dev/null
@@ -1,150 +0,0 @@
-# Generated by h2py from /usr/include/errno.h
-from warnings import warnpy3k
-warnpy3k("the ERRNO module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from sys/errno.h
-__KBASE = 1000
-__IRIXBASE = 1000
-EPERM = 1
-ENOENT = 2
-ESRCH = 3
-EINTR = 4
-EIO = 5
-ENXIO = 6
-E2BIG = 7
-ENOEXEC = 8
-EBADF = 9
-ECHILD = 10
-EAGAIN = 11
-ENOMEM = 12
-EACCES = 13
-EFAULT = 14
-ENOTBLK = 15
-EBUSY = 16
-EEXIST = 17
-EXDEV = 18
-ENODEV = 19
-ENOTDIR = 20
-EISDIR = 21
-EINVAL = 22
-ENFILE = 23
-EMFILE = 24
-ENOTTY = 25
-ETXTBSY = 26
-EFBIG = 27
-ENOSPC = 28
-ESPIPE = 29
-EROFS = 30
-EMLINK = 31
-EPIPE = 32
-EDOM = 33
-ERANGE = 34
-ENOMSG = 35
-EIDRM = 36
-ECHRNG = 37
-EL2NSYNC = 38
-EL3HLT = 39
-EL3RST = 40
-ELNRNG = 41
-EUNATCH = 42
-ENOCSI = 43
-EL2HLT = 44
-EDEADLK = 45
-ENOLCK = 46
-EBADE = 50
-EBADR = 51
-EXFULL = 52
-ENOANO = 53
-EBADRQC = 54
-EBADSLT = 55
-EDEADLOCK = 56
-EBFONT = 57
-ENOSTR = 60
-ENODATA = 61
-ETIME = 62
-ENOSR = 63
-ENONET = 64
-ENOPKG = 65
-EREMOTE = 66
-ENOLINK = 67
-EADV = 68
-ESRMNT = 69
-ECOMM = 70
-EPROTO = 71
-EMULTIHOP = 74
-EBADMSG = 77
-ENAMETOOLONG = 78
-EOVERFLOW = 79
-ENOTUNIQ = 80
-EBADFD = 81
-EREMCHG = 82
-ELIBACC = 83
-ELIBBAD = 84
-ELIBSCN = 85
-ELIBMAX = 86
-ELIBEXEC = 87
-EILSEQ = 88
-ENOSYS = 89
-ELOOP = 90
-ERESTART = 91
-ESTRPIPE = 92
-ENOTEMPTY = 93
-EUSERS = 94
-ENOTSOCK = 95
-EDESTADDRREQ = 96
-EMSGSIZE = 97
-EPROTOTYPE = 98
-ENOPROTOOPT = 99
-EPROTONOSUPPORT = 120
-ESOCKTNOSUPPORT = 121
-EOPNOTSUPP = 122
-EPFNOSUPPORT = 123
-EAFNOSUPPORT = 124
-EADDRINUSE = 125
-EADDRNOTAVAIL = 126
-ENETDOWN = 127
-ENETUNREACH = 128
-ENETRESET = 129
-ECONNABORTED = 130
-ECONNRESET = 131
-ENOBUFS = 132
-EISCONN = 133
-ENOTCONN = 134
-ESHUTDOWN = 143
-ETOOMANYREFS = 144
-ETIMEDOUT = 145
-ECONNREFUSED = 146
-EHOSTDOWN = 147
-EHOSTUNREACH = 148
-EWOULDBLOCK = __KBASE+101
-EWOULDBLOCK = EAGAIN
-EALREADY = 149
-EINPROGRESS = 150
-ESTALE = 151
-EIORESID = 500
-EUCLEAN = 135
-ENOTNAM = 137
-ENAVAIL = 138
-EISNAM = 139
-EREMOTEIO = 140
-EINIT = 141
-EREMDEV = 142
-ECANCELED = 158
-ECANCELED = 1000
-EDQUOT = 1133
-ENFSREMOTE = 1135
-ETCP_EBASE = 100
-ETCP_ELIMIT = 129
-ENAMI_EBASE = 129
-ENAMI_ELIMIT = 131
-ENFS_EBASE = 131
-ENFS_ELIMIT = 135
-ELASTERRNO = 135
-TCP_EBASE = ETCP_EBASE
-TCP_ELIMIT = ETCP_ELIMIT
-NAMI_EBASE = ENAMI_EBASE
-NAMI_ELIMIT = ENAMI_ELIMIT
-NFS_EBASE = ENFS_EBASE
-NFS_ELIMIT = ENFS_ELIMIT
-LASTERRNO = ELASTERRNO
diff --git a/Lib/plat-irix5/FILE.py b/Lib/plat-irix5/FILE.py
deleted file mode 100644
index adf0da3523e..00000000000
--- a/Lib/plat-irix5/FILE.py
+++ /dev/null
@@ -1,242 +0,0 @@
-# Generated by h2py from /usr/include/sys/file.h
-from warnings import warnpy3k
-warnpy3k("the FILE module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from sys/types.h
-
-# Included from sgidefs.h
-_MIPS_ISA_MIPS1 = 1
-_MIPS_ISA_MIPS2 = 2
-_MIPS_ISA_MIPS3 = 3
-_MIPS_ISA_MIPS4 = 4
-_MIPS_SIM_ABI32 = 1
-_MIPS_SIM_NABI32 = 2
-_MIPS_SIM_ABI64 = 3
-P_MYID = (-1)
-P_MYHOSTID = (-1)
-
-# Included from sys/bsd_types.h
-
-# Included from sys/mkdev.h
-ONBITSMAJOR = 7
-ONBITSMINOR = 8
-OMAXMAJ = 0x7f
-OMAXMIN = 0xff
-NBITSMAJOR = 14
-NBITSMINOR = 18
-MAXMAJ = 0x1ff
-MAXMIN = 0x3ffff
-OLDDEV = 0
-NEWDEV = 1
-MKDEV_VER = NEWDEV
-def major(dev): return __major(MKDEV_VER, dev)
-
-def minor(dev): return __minor(MKDEV_VER, dev)
-
-
-# Included from sys/select.h
-FD_SETSIZE = 1024
-NBBY = 8
-
-# Included from sys/sema.h
-HP_NOPOLICY = 0
-HP_ADDOFF = 1
-HP_MULOFF = 2
-SEMA_NAMSZ = 8
-SEMA_NOHIST = 0x1
-SEMA_LIFO = 0x2
-SEMA_MUTEX = 0x4
-SEMA_METER = 0x8
-SEMAOP_PSEMA = 1
-SEMAOP_VSEMA = 2
-SEMAOP_CPSEMA = 3
-SEMAOP_CVSEMA = 4
-SEMAOP_WSEMA = 5
-SEMAOP_UNSEMA = 6
-SEMAOP_INIT = 7
-SEMAOP_FREE = 8
-SSOP_PHIT = 1
-SSOP_PSLP = 2
-SSOP_PWAKE = 6
-SSOP_PRESIG = 7
-SSOP_POSTSIG = 8
-SSOP_VNOWAKE = 3
-SSOP_VWAKE = 4
-SSOP_CPHIT = 1
-SSOP_CPMISS = 5
-SSOP_CVNOWAKE = 3
-SSOP_CVWAKE = 4
-SSOP_WMISS = 5
-SSOP_WWAKE = 4
-SSOP_RMV = 9
-TZERO = 10
-SEMA_NOP = 0
-SEMA_WAKE = 1
-SEMA_VSEMA = 2
-SEMA_SPINOP = 3
-MR_ACCESS = 0x1
-MR_UPDATE = 0x2
-def cv_signal(cv): return cvsema(cv);
-
-def cv_destroy(cv): return freesema(cv)
-
-def mutex_enter(m): return psema(m, PZERO | PNOSTOP)
-
-def mutex_exit(m): return vsema(m)
-
-def mutex_destroy(m): return freesema(m)
-
-def MUTEX_HELD(m): return (ownsema(m))
-
-def MUTEX_HELD(m): return (1)
-
-RW_READER = MR_ACCESS
-RW_WRITER = MR_UPDATE
-def rw_exit(r): return mrunlock(r)
-
-def rw_tryupgrade(r): return cmrpromote(r)
-
-def rw_downgrade(r): return mrdemote(r)
-
-def rw_destroy(r): return mrfree(r)
-
-def RW_WRITE_HELD(r): return ismrlocked(r, MR_UPDATE)
-
-def RW_READ_HELD(r): return ismrlocked(r, MR_ACCESS)
-
-
-# Included from sys/splock.h
-SPLOCKNAMSIZ = 8
-SPLOCK_NONE = 0
-SPLOCK_SOFT = 1
-SPLOCK_HARD = 2
-OWNER_NONE = -1
-MAP_LOCKID = 0
-SPLOCK_MAX = (96*1024)
-SPLOCK_MAX = 32768
-MIN_POOL_SIZE = 256
-MAX_POOL_SIZE = 16384
-DEF_SEMA_POOL = 8192
-DEF_VNODE_POOL = 1024
-DEF_FILE_POOL = 1024
-def ownlock(x): return 1
-
-def splock(x): return 1
-
-def io_splock(x): return 1
-
-def apvsema(x): return vsema(x)
-
-def apcpsema(x): return cpsema(x)
-
-def apcvsema(x): return cvsema(x)
-
-def mp_mrunlock(a): return mrunlock(a)
-
-def apvsema(x): return 0
-
-def apcpsema(x): return 1
-
-def apcvsema(x): return 0
-
-def mp_mrunlock(a): return 0
-
-
-# Included from sys/fcntl.h
-FNDELAY = 0x04
-FAPPEND = 0x08
-FSYNC = 0x10
-FNONBLOCK = 0x80
-FASYNC = 0x1000
-FNONBLK = FNONBLOCK
-FDIRECT = 0x8000
-FCREAT = 0x0100
-FTRUNC = 0x0200
-FEXCL = 0x0400
-FNOCTTY = 0x0800
-O_RDONLY = 0
-O_WRONLY = 1
-O_RDWR = 2
-O_NDELAY = 0x04
-O_APPEND = 0x08
-O_SYNC = 0x10
-O_NONBLOCK = 0x80
-O_DIRECT = 0x8000
-O_CREAT = 0x100
-O_TRUNC = 0x200
-O_EXCL = 0x400
-O_NOCTTY = 0x800
-F_DUPFD = 0
-F_GETFD = 1
-F_SETFD = 2
-F_GETFL = 3
-F_SETFL = 4
-F_GETLK = 14
-F_SETLK = 6
-F_SETLKW = 7
-F_CHKFL = 8
-F_ALLOCSP = 10
-F_FREESP = 11
-F_SETBSDLK = 12
-F_SETBSDLKW = 13
-F_DIOINFO = 30
-F_FSGETXATTR = 31
-F_FSSETXATTR = 32
-F_GETLK64 = 33
-F_SETLK64 = 34
-F_SETLKW64 = 35
-F_ALLOCSP64 = 36
-F_FREESP64 = 37
-F_GETBMAP = 38
-F_FSSETDM = 39
-F_RSETLK = 20
-F_RGETLK = 21
-F_RSETLKW = 22
-F_GETOWN = 23
-F_SETOWN = 24
-F_O_GETLK = 5
-F_O_GETOWN = 10
-F_O_SETOWN = 11
-F_RDLCK = 01
-F_WRLCK = 02
-F_UNLCK = 03
-O_ACCMODE = 3
-FD_CLOEXEC = 1
-FD_NODUP_FORK = 4
-FMASK = 0x90FF
-FOPEN = 0xFFFFFFFF
-FREAD = 0x01
-FWRITE = 0x02
-FNDELAY = 0x04
-FAPPEND = 0x08
-FSYNC = 0x10
-FNONBLOCK = 0x80
-FASYNC = 0x1000
-FNONBLK = FNONBLOCK
-FDIRECT = 0x8000
-FCREAT = 0x0100
-FTRUNC = 0x0200
-FEXCL = 0x0400
-FNOCTTY = 0x0800
-IRIX4_FASYNC = 0x40
-FMARK = 0x4000
-FDEFER = 0x2000
-FINPROGRESS = 0x0400
-FINVIS = 0x0100
-FNMFS = 0x2000
-FCLOSEXEC = 001
-FDSHD = 0x0001
-FDNOMARK = 0x0002
-FDIGNPROGRESS = 0x0004
-LOCK_SH = 1
-LOCK_EX = 2
-LOCK_NB = 4
-LOCK_UN = 8
-F_OK = 0
-X_OK = 1
-W_OK = 2
-R_OK = 4
-L_SET = 0
-L_INCR = 1
-L_XTND = 2
diff --git a/Lib/plat-irix5/FL.py b/Lib/plat-irix5/FL.py
deleted file mode 100644
index d1b3be1ef37..00000000000
--- a/Lib/plat-irix5/FL.py
+++ /dev/null
@@ -1,292 +0,0 @@
-# Constants used by the FORMS library (module fl).
-# This corresponds to "forms.h".
-# Recommended use: import FL; ... FL.NORMAL_BOX ... etc.
-# Alternate use: from FL import *; ... NORMAL_BOX ... etc.
-from warnings import warnpy3k
-warnpy3k("the FL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-_v20 = 1
-_v21 = 1
-##import fl
-##try:
-## _v20 = (fl.get_rgbmode is not None)
-##except:
-## _v20 = 0
-##del fl
-
-NULL = 0
-FALSE = 0
-TRUE = 1
-
-EVENT = -1
-
-LABEL_SIZE = 64
-if _v20:
- SHORTCUT_SIZE = 32
-PLACE_FREE = 0
-PLACE_SIZE = 1
-PLACE_ASPECT = 2
-PLACE_MOUSE = 3
-PLACE_CENTER = 4
-PLACE_POSITION = 5
-FL_PLACE_FULLSCREEN = 6
-FIND_INPUT = 0
-FIND_AUTOMATIC = 1
-FIND_MOUSE = 2
-BEGIN_GROUP = 10000
-END_GROUP = 20000
-ALIGN_TOP = 0
-ALIGN_BOTTOM = 1
-ALIGN_LEFT = 2
-ALIGN_RIGHT = 3
-ALIGN_CENTER = 4
-NO_BOX = 0
-UP_BOX = 1
-DOWN_BOX = 2
-FLAT_BOX = 3
-BORDER_BOX = 4
-SHADOW_BOX = 5
-FRAME_BOX = 6
-ROUNDED_BOX = 7
-RFLAT_BOX = 8
-RSHADOW_BOX = 9
-TOP_BOUND_COL = 51
-LEFT_BOUND_COL = 55
-BOT_BOUND_COL = 40
-RIGHT_BOUND_COL = 35
-COL1 = 47
-MCOL = 49
-LCOL = 0
-BOUND_WIDTH = 3.0
-DRAW = 0
-PUSH = 1
-RELEASE = 2
-ENTER = 3
-LEAVE = 4
-MOUSE = 5
-FOCUS = 6
-UNFOCUS = 7
-KEYBOARD = 8
-STEP = 9
-MOVE = 10
-FONT_NAME = 'Helvetica'
-FONT_BOLDNAME = 'Helvetica-Bold'
-FONT_ITALICNAME = 'Helvetica-Oblique'
-FONT_FIXEDNAME = 'Courier'
-FONT_ICONNAME = 'Icon'
-SMALL_FONT = 8.0
-NORMAL_FONT = 11.0
-LARGE_FONT = 20.0
-NORMAL_STYLE = 0
-BOLD_STYLE = 1
-ITALIC_STYLE = 2
-FIXED_STYLE = 3
-ENGRAVED_STYLE = 4
-ICON_STYLE = 5
-BITMAP = 3
-NORMAL_BITMAP = 0
-BITMAP_BOXTYPE = NO_BOX
-BITMAP_COL1 = 0
-BITMAP_COL2 = COL1
-BITMAP_LCOL = LCOL
-BITMAP_ALIGN = ALIGN_BOTTOM
-BITMAP_MAXSIZE = 128*128
-BITMAP_BW = BOUND_WIDTH
-BOX = 1
-BOX_BOXTYPE = UP_BOX
-BOX_COL1 = COL1
-BOX_LCOL = LCOL
-BOX_ALIGN = ALIGN_CENTER
-BOX_BW = BOUND_WIDTH
-BROWSER = 71
-NORMAL_BROWSER = 0
-SELECT_BROWSER = 1
-HOLD_BROWSER = 2
-MULTI_BROWSER = 3
-BROWSER_BOXTYPE = DOWN_BOX
-BROWSER_COL1 = COL1
-BROWSER_COL2 = 3
-BROWSER_LCOL = LCOL
-BROWSER_ALIGN = ALIGN_BOTTOM
-BROWSER_SLCOL = COL1
-BROWSER_BW = BOUND_WIDTH
-BROWSER_LINELENGTH = 128
-BROWSER_MAXLINE = 512
-BUTTON = 11
-NORMAL_BUTTON = 0
-PUSH_BUTTON = 1
-RADIO_BUTTON = 2
-HIDDEN_BUTTON = 3
-TOUCH_BUTTON = 4
-INOUT_BUTTON = 5
-RETURN_BUTTON = 6
-if _v20:
- HIDDEN_RET_BUTTON = 7
-BUTTON_BOXTYPE = UP_BOX
-BUTTON_COL1 = COL1
-BUTTON_COL2 = COL1
-BUTTON_LCOL = LCOL
-BUTTON_ALIGN = ALIGN_CENTER
-BUTTON_MCOL1 = MCOL
-BUTTON_MCOL2 = MCOL
-BUTTON_BW = BOUND_WIDTH
-if _v20:
- CHART = 4
- BAR_CHART = 0
- HORBAR_CHART = 1
- LINE_CHART = 2
- FILLED_CHART = 3
- SPIKE_CHART = 4
- PIE_CHART = 5
- SPECIALPIE_CHART = 6
- CHART_BOXTYPE = BORDER_BOX
- CHART_COL1 = COL1
- CHART_LCOL = LCOL
- CHART_ALIGN = ALIGN_BOTTOM
- CHART_BW = BOUND_WIDTH
- CHART_MAX = 128
-CHOICE = 42
-NORMAL_CHOICE = 0
-CHOICE_BOXTYPE = DOWN_BOX
-CHOICE_COL1 = COL1
-CHOICE_COL2 = LCOL
-CHOICE_LCOL = LCOL
-CHOICE_ALIGN = ALIGN_LEFT
-CHOICE_BW = BOUND_WIDTH
-CHOICE_MCOL = MCOL
-CHOICE_MAXITEMS = 128
-CHOICE_MAXSTR = 64
-CLOCK = 61
-SQUARE_CLOCK = 0
-ROUND_CLOCK = 1
-CLOCK_BOXTYPE = UP_BOX
-CLOCK_COL1 = 37
-CLOCK_COL2 = 42
-CLOCK_LCOL = LCOL
-CLOCK_ALIGN = ALIGN_BOTTOM
-CLOCK_TOPCOL = COL1
-CLOCK_BW = BOUND_WIDTH
-COUNTER = 25
-NORMAL_COUNTER = 0
-SIMPLE_COUNTER = 1
-COUNTER_BOXTYPE = UP_BOX
-COUNTER_COL1 = COL1
-COUNTER_COL2 = 4
-COUNTER_LCOL = LCOL
-COUNTER_ALIGN = ALIGN_BOTTOM
-if _v20:
- COUNTER_BW = BOUND_WIDTH
-else:
- DEFAULT = 51
- RETURN_DEFAULT = 0
- ALWAYS_DEFAULT = 1
-DIAL = 22
-NORMAL_DIAL = 0
-LINE_DIAL = 1
-DIAL_BOXTYPE = NO_BOX
-DIAL_COL1 = COL1
-DIAL_COL2 = 37
-DIAL_LCOL = LCOL
-DIAL_ALIGN = ALIGN_BOTTOM
-DIAL_TOPCOL = COL1
-DIAL_BW = BOUND_WIDTH
-FREE = 101
-NORMAL_FREE = 1
-SLEEPING_FREE = 2
-INPUT_FREE = 3
-CONTINUOUS_FREE = 4
-ALL_FREE = 5
-INPUT = 31
-NORMAL_INPUT = 0
-if _v20:
- FLOAT_INPUT = 1
- INT_INPUT = 2
- HIDDEN_INPUT = 3
- if _v21:
- MULTILINE_INPUT = 4
- SECRET_INPUT = 5
-else:
- ALWAYS_INPUT = 1
-INPUT_BOXTYPE = DOWN_BOX
-INPUT_COL1 = 13
-INPUT_COL2 = 5
-INPUT_LCOL = LCOL
-INPUT_ALIGN = ALIGN_LEFT
-INPUT_TCOL = LCOL
-INPUT_CCOL = 4
-INPUT_BW = BOUND_WIDTH
-INPUT_MAX = 128
-LIGHTBUTTON = 12
-LIGHTBUTTON_BOXTYPE = UP_BOX
-LIGHTBUTTON_COL1 = 39
-LIGHTBUTTON_COL2 = 3
-LIGHTBUTTON_LCOL = LCOL
-LIGHTBUTTON_ALIGN = ALIGN_CENTER
-LIGHTBUTTON_TOPCOL = COL1
-LIGHTBUTTON_MCOL = MCOL
-LIGHTBUTTON_BW1 = BOUND_WIDTH
-LIGHTBUTTON_BW2 = BOUND_WIDTH/2.0
-LIGHTBUTTON_MINSIZE = 12.0
-MENU = 41
-TOUCH_MENU = 0
-PUSH_MENU = 1
-MENU_BOXTYPE = BORDER_BOX
-MENU_COL1 = 55
-MENU_COL2 = 37
-MENU_LCOL = LCOL
-MENU_ALIGN = ALIGN_CENTER
-MENU_BW = BOUND_WIDTH
-MENU_MAX = 300
-POSITIONER = 23
-NORMAL_POSITIONER = 0
-POSITIONER_BOXTYPE = DOWN_BOX
-POSITIONER_COL1 = COL1
-POSITIONER_COL2 = 1
-POSITIONER_LCOL = LCOL
-POSITIONER_ALIGN = ALIGN_BOTTOM
-POSITIONER_BW = BOUND_WIDTH
-ROUNDBUTTON = 13
-ROUNDBUTTON_BOXTYPE = NO_BOX
-ROUNDBUTTON_COL1 = 7
-ROUNDBUTTON_COL2 = 3
-ROUNDBUTTON_LCOL = LCOL
-ROUNDBUTTON_ALIGN = ALIGN_CENTER
-ROUNDBUTTON_TOPCOL = COL1
-ROUNDBUTTON_MCOL = MCOL
-ROUNDBUTTON_BW = BOUND_WIDTH
-SLIDER = 21
-VALSLIDER = 24
-VERT_SLIDER = 0
-HOR_SLIDER = 1
-VERT_FILL_SLIDER = 2
-HOR_FILL_SLIDER = 3
-VERT_NICE_SLIDER = 4
-HOR_NICE_SLIDER = 5
-SLIDER_BOXTYPE = DOWN_BOX
-SLIDER_COL1 = COL1
-SLIDER_COL2 = COL1
-SLIDER_LCOL = LCOL
-SLIDER_ALIGN = ALIGN_BOTTOM
-SLIDER_BW1 = BOUND_WIDTH
-SLIDER_BW2 = BOUND_WIDTH*0.75
-SLIDER_FINE = 0.05
-SLIDER_WIDTH = 0.08
-TEXT = 2
-NORMAL_TEXT = 0
-TEXT_BOXTYPE = NO_BOX
-TEXT_COL1 = COL1
-TEXT_LCOL = LCOL
-TEXT_ALIGN = ALIGN_LEFT
-TEXT_BW = BOUND_WIDTH
-TIMER = 62
-NORMAL_TIMER = 0
-VALUE_TIMER = 1
-HIDDEN_TIMER = 2
-TIMER_BOXTYPE = DOWN_BOX
-TIMER_COL1 = COL1
-TIMER_COL2 = 1
-TIMER_LCOL = LCOL
-TIMER_ALIGN = ALIGN_CENTER
-TIMER_BW = BOUND_WIDTH
-TIMER_BLINKRATE = 0.2
diff --git a/Lib/plat-irix5/GET.py b/Lib/plat-irix5/GET.py
deleted file mode 100644
index 842a3aa9a14..00000000000
--- a/Lib/plat-irix5/GET.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Symbols from <gl/get.h>
-from warnings import warnpy3k
-warnpy3k("the GET module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-BCKBUFFER = 0x1
-FRNTBUFFER = 0x2
-DRAWZBUFFER = 0x4
-DMRGB = 0
-DMSINGLE = 1
-DMDOUBLE = 2
-DMRGBDOUBLE = 5
-HZ30 = 0
-HZ60 = 1
-NTSC = 2
-HDTV = 3
-VGA = 4
-IRIS3K = 5
-PR60 = 6
-PAL = 9
-HZ30_SG = 11
-A343 = 14
-STR_RECT = 15
-VOF0 = 16
-VOF1 = 17
-VOF2 = 18
-VOF3 = 19
-SGI0 = 20
-SGI1 = 21
-SGI2 = 22
-HZ72 = 23
-GL_VIDEO_REG = 0x00800000
-GLV_GENLOCK = 0x00000001
-GLV_UNBLANK = 0x00000002
-GLV_SRED = 0x00000004
-GLV_SGREEN = 0x00000008
-GLV_SBLUE = 0x00000010
-GLV_SALPHA = 0x00000020
-GLV_TTLGENLOCK = 0x00000080
-GLV_TTLSYNC = GLV_TTLGENLOCK
-GLV_GREENGENLOCK = 0x0000100
-LEFTPLANE = 0x0001
-RIGHTPLANE = 0x0002
-BOTTOMPLANE = 0x0004
-TOPPLANE = 0x0008
-NEARPLANE = 0x0010
-FARPLANE = 0x0020
-## GETDEF = __GL_GET_H__
-NOBUFFER = 0x0
-BOTHBUFFERS = 0x3
-DMINTENSITYSINGLE = 3
-DMINTENSITYDOUBLE = 4
-MONSPECIAL = 0x20
-HZ50 = 3
-MONA = 5
-MONB = 6
-MONC = 7
-MOND = 8
-MON_ALL = 12
-MON_GEN_ALL = 13
-CMAPMULTI = 0
-CMAPONE = 1
diff --git a/Lib/plat-irix5/GL.py b/Lib/plat-irix5/GL.py
deleted file mode 100644
index d0e0074755b..00000000000
--- a/Lib/plat-irix5/GL.py
+++ /dev/null
@@ -1,397 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the GL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NULL = 0
-FALSE = 0
-TRUE = 1
-ATTRIBSTACKDEPTH = 10
-VPSTACKDEPTH = 8
-MATRIXSTACKDEPTH = 32
-NAMESTACKDEPTH = 1025
-STARTTAG = -2
-ENDTAG = -3
-BLACK = 0
-RED = 1
-GREEN = 2
-YELLOW = 3
-BLUE = 4
-MAGENTA = 5
-CYAN = 6
-WHITE = 7
-PUP_CLEAR = 0
-PUP_COLOR = 1
-PUP_BLACK = 2
-PUP_WHITE = 3
-NORMALDRAW = 0x010
-PUPDRAW = 0x020
-OVERDRAW = 0x040
-UNDERDRAW = 0x080
-CURSORDRAW = 0x100
-DUALDRAW = 0x200
-PATTERN_16 = 16
-PATTERN_32 = 32
-PATTERN_64 = 64
-PATTERN_16_SIZE = 16
-PATTERN_32_SIZE = 64
-PATTERN_64_SIZE = 256
-SRC_AUTO = 0
-SRC_FRONT = 1
-SRC_BACK = 2
-SRC_ZBUFFER = 3
-SRC_PUP = 4
-SRC_OVER = 5
-SRC_UNDER = 6
-SRC_FRAMEGRABBER = 7
-BF_ZERO = 0
-BF_ONE = 1
-BF_DC = 2
-BF_SC = 2
-BF_MDC = 3
-BF_MSC = 3
-BF_SA = 4
-BF_MSA = 5
-BF_DA = 6
-BF_MDA = 7
-BF_MIN_SA_MDA = 8
-AF_NEVER = 0
-AF_LESS = 1
-AF_EQUAL = 2
-AF_LEQUAL = 3
-AF_GREATER = 4
-AF_NOTEQUAL = 5
-AF_GEQUAL = 6
-AF_ALWAYS = 7
-ZF_NEVER = 0
-ZF_LESS = 1
-ZF_EQUAL = 2
-ZF_LEQUAL = 3
-ZF_GREATER = 4
-ZF_NOTEQUAL = 5
-ZF_GEQUAL = 6
-ZF_ALWAYS = 7
-ZSRC_DEPTH = 0
-ZSRC_COLOR = 1
-SMP_OFF = 0x0
-SMP_ON = 0x1
-SMP_SMOOTHER = 0x2
-SML_OFF = 0x0
-SML_ON = 0x1
-SML_SMOOTHER = 0x2
-SML_END_CORRECT = 0x4
-PYSM_OFF = 0
-PYSM_ON = 1
-PYSM_SHRINK = 2
-DT_OFF = 0
-DT_ON = 1
-PUP_NONE = 0
-PUP_GREY = 0x1
-PUP_BOX = 0x2
-PUP_CHECK = 0x4
-GLC_OLDPOLYGON = 0
-GLC_ZRANGEMAP = 1
-GLC_MQUEUERATE = 2
-GLC_SOFTATTACH = 3
-GLC_MANAGEBG = 4
-GLC_SLOWMAPCOLORS = 5
-GLC_INPUTCHANGEBUG = 6
-GLC_NOBORDERBUG = 7
-GLC_SET_VSYNC = 8
-GLC_GET_VSYNC = 9
-GLC_VSYNC_SLEEP = 10
-GLC_COMPATRATE = 15
-C16X1 = 0
-C16X2 = 1
-C32X1 = 2
-C32X2 = 3
-CCROSS = 4
-FLAT = 0
-GOURAUD = 1
-LO_ZERO = 0x0
-LO_AND = 0x1
-LO_ANDR = 0x2
-LO_SRC = 0x3
-LO_ANDI = 0x4
-LO_DST = 0x5
-LO_XOR = 0x6
-LO_OR = 0x7
-LO_NOR = 0x8
-LO_XNOR = 0x9
-LO_NDST = 0xa
-LO_ORR = 0xb
-LO_NSRC = 0xc
-LO_ORI = 0xd
-LO_NAND = 0xe
-LO_ONE = 0xf
-INFOCUSSCRN = -2
-ST_KEEP = 0
-ST_ZERO = 1
-ST_REPLACE = 2
-ST_INCR = 3
-ST_DECR = 4
-ST_INVERT = 5
-SF_NEVER = 0
-SF_LESS = 1
-SF_EQUAL = 2
-SF_LEQUAL = 3
-SF_GREATER = 4
-SF_NOTEQUAL = 5
-SF_GEQUAL = 6
-SF_ALWAYS = 7
-SS_OFF = 0
-SS_DEPTH = 1
-PYM_FILL = 1
-PYM_POINT = 2
-PYM_LINE = 3
-PYM_HOLLOW = 4
-PYM_LINE_FAST = 5
-FG_OFF = 0
-FG_ON = 1
-FG_DEFINE = 2
-FG_VTX_EXP = 2
-FG_VTX_LIN = 3
-FG_PIX_EXP = 4
-FG_PIX_LIN = 5
-FG_VTX_EXP2 = 6
-FG_PIX_EXP2 = 7
-PM_SHIFT = 0
-PM_EXPAND = 1
-PM_C0 = 2
-PM_C1 = 3
-PM_ADD24 = 4
-PM_SIZE = 5
-PM_OFFSET = 6
-PM_STRIDE = 7
-PM_TTOB = 8
-PM_RTOL = 9
-PM_ZDATA = 10
-PM_WARP = 11
-PM_RDX = 12
-PM_RDY = 13
-PM_CDX = 14
-PM_CDY = 15
-PM_XSTART = 16
-PM_YSTART = 17
-PM_VO1 = 1000
-NAUTO = 0
-NNORMALIZE = 1
-AC_CLEAR = 0
-AC_ACCUMULATE = 1
-AC_CLEAR_ACCUMULATE = 2
-AC_RETURN = 3
-AC_MULT = 4
-AC_ADD = 5
-CP_OFF = 0
-CP_ON = 1
-CP_DEFINE = 2
-SB_RESET = 0
-SB_TRACK = 1
-SB_HOLD = 2
-RD_FREEZE = 0x00000001
-RD_ALPHAONE = 0x00000002
-RD_IGNORE_UNDERLAY = 0x00000004
-RD_IGNORE_OVERLAY = 0x00000008
-RD_IGNORE_PUP = 0x00000010
-RD_OFFSCREEN = 0x00000020
-GD_XPMAX = 0
-GD_YPMAX = 1
-GD_XMMAX = 2
-GD_YMMAX = 3
-GD_ZMIN = 4
-GD_ZMAX = 5
-GD_BITS_NORM_SNG_RED = 6
-GD_BITS_NORM_SNG_GREEN = 7
-GD_BITS_NORM_SNG_BLUE = 8
-GD_BITS_NORM_DBL_RED = 9
-GD_BITS_NORM_DBL_GREEN = 10
-GD_BITS_NORM_DBL_BLUE = 11
-GD_BITS_NORM_SNG_CMODE = 12
-GD_BITS_NORM_DBL_CMODE = 13
-GD_BITS_NORM_SNG_MMAP = 14
-GD_BITS_NORM_DBL_MMAP = 15
-GD_BITS_NORM_ZBUFFER = 16
-GD_BITS_OVER_SNG_CMODE = 17
-GD_BITS_UNDR_SNG_CMODE = 18
-GD_BITS_PUP_SNG_CMODE = 19
-GD_BITS_NORM_SNG_ALPHA = 21
-GD_BITS_NORM_DBL_ALPHA = 22
-GD_BITS_CURSOR = 23
-GD_OVERUNDER_SHARED = 24
-GD_BLEND = 25
-GD_CIFRACT = 26
-GD_CROSSHAIR_CINDEX = 27
-GD_DITHER = 28
-GD_LINESMOOTH_CMODE = 30
-GD_LINESMOOTH_RGB = 31
-GD_LOGICOP = 33
-GD_NSCRNS = 35
-GD_NURBS_ORDER = 36
-GD_NBLINKS = 37
-GD_NVERTEX_POLY = 39
-GD_PATSIZE_64 = 40
-GD_PNTSMOOTH_CMODE = 41
-GD_PNTSMOOTH_RGB = 42
-GD_PUP_TO_OVERUNDER = 43
-GD_READSOURCE = 44
-GD_READSOURCE_ZBUFFER = 48
-GD_STEREO = 50
-GD_SUBPIXEL_LINE = 51
-GD_SUBPIXEL_PNT = 52
-GD_SUBPIXEL_POLY = 53
-GD_TRIMCURVE_ORDER = 54
-GD_WSYS = 55
-GD_ZDRAW_GEOM = 57
-GD_ZDRAW_PIXELS = 58
-GD_SCRNTYPE = 61
-GD_TEXTPORT = 62
-GD_NMMAPS = 63
-GD_FRAMEGRABBER = 64
-GD_TIMERHZ = 66
-GD_DBBOX = 67
-GD_AFUNCTION = 68
-GD_ALPHA_OVERUNDER = 69
-GD_BITS_ACBUF = 70
-GD_BITS_ACBUF_HW = 71
-GD_BITS_STENCIL = 72
-GD_CLIPPLANES = 73
-GD_FOGVERTEX = 74
-GD_LIGHTING_TWOSIDE = 76
-GD_POLYMODE = 77
-GD_POLYSMOOTH = 78
-GD_SCRBOX = 79
-GD_TEXTURE = 80
-GD_FOGPIXEL = 81
-GD_TEXTURE_PERSP = 82
-GD_MUXPIPES = 83
-GD_NOLIMIT = -2
-GD_WSYS_NONE = 0
-GD_WSYS_4S = 1
-GD_SCRNTYPE_WM = 0
-GD_SCRNTYPE_NOWM = 1
-N_PIXEL_TOLERANCE = 1
-N_CULLING = 2
-N_DISPLAY = 3
-N_ERRORCHECKING = 4
-N_SUBDIVISIONS = 5
-N_S_STEPS = 6
-N_T_STEPS = 7
-N_TILES = 8
-N_TMP1 = 9
-N_TMP2 = 10
-N_TMP3 = 11
-N_TMP4 = 12
-N_TMP5 = 13
-N_TMP6 = 14
-N_FILL = 1.0
-N_OUTLINE_POLY = 2.0
-N_OUTLINE_PATCH = 5.0
-N_ISOLINE_S = 12.0
-N_ST = 0x8
-N_STW = 0xd
-N_XYZ = 0x4c
-N_XYZW = 0x51
-N_TEX = 0x88
-N_TEXW = 0x8d
-N_RGBA = 0xd0
-N_RGBAW = 0xd5
-N_P2D = 0x8
-N_P2DR = 0xd
-N_V3D = 0x4c
-N_V3DR = 0x51
-N_T2D = 0x88
-N_T2DR = 0x8d
-N_C4D = 0xd0
-N_C4DR = 0xd5
-LMNULL = 0.0
-MSINGLE = 0
-MPROJECTION = 1
-MVIEWING = 2
-MTEXTURE = 3
-MAXLIGHTS = 8
-MAXRESTRICTIONS = 4
-DEFMATERIAL = 0
-EMISSION = 1
-AMBIENT = 2
-DIFFUSE = 3
-SPECULAR = 4
-SHININESS = 5
-COLORINDEXES = 6
-ALPHA = 7
-DEFLIGHT = 100
-LCOLOR = 101
-POSITION = 102
-SPOTDIRECTION = 103
-SPOTLIGHT = 104
-DEFLMODEL = 200
-LOCALVIEWER = 201
-ATTENUATION = 202
-ATTENUATION2 = 203
-TWOSIDE = 204
-MATERIAL = 1000
-BACKMATERIAL = 1001
-LIGHT0 = 1100
-LIGHT1 = 1101
-LIGHT2 = 1102
-LIGHT3 = 1103
-LIGHT4 = 1104
-LIGHT5 = 1105
-LIGHT6 = 1106
-LIGHT7 = 1107
-LMODEL = 1200
-LMC_COLOR = 0
-LMC_EMISSION = 1
-LMC_AMBIENT = 2
-LMC_DIFFUSE = 3
-LMC_SPECULAR = 4
-LMC_AD = 5
-LMC_NULL = 6
-TX_MINFILTER = 0x100
-TX_MAGFILTER = 0x200
-TX_WRAP = 0x300
-TX_WRAP_S = 0x310
-TX_WRAP_T = 0x320
-TX_TILE = 0x400
-TX_BORDER = 0x500
-TX_NULL = 0x000
-TX_POINT = 0x110
-TX_BILINEAR = 0x220
-TX_MIPMAP = 0x120
-TX_MIPMAP_POINT = 0x121
-TX_MIPMAP_LINEAR = 0x122
-TX_MIPMAP_BILINEAR = 0x123
-TX_MIPMAP_TRILINEAR = 0x124
-TX_REPEAT = 0x301
-TX_CLAMP = 0x302
-TX_SELECT = 0x303
-TX_TEXTURE_0 = 0
-TV_MODULATE = 0x101
-TV_BLEND = 0x102
-TV_DECAL = 0x103
-TV_COLOR = 0x200
-TV_NULL = 0x000
-TV_ENV0 = 0
-TX_S = 0
-TX_T = 1
-TG_OFF = 0
-TG_ON = 1
-TG_CONTOUR = 2
-TG_LINEAR = 3
-TG_SPHEREMAP = 4
-TG_REFRACTMAP = 5
-DGLSINK = 0
-DGLLOCAL = 1
-DGLTSOCKET = 2
-DGL4DDN = 3
-PUP_CURSOR = PUP_COLOR
-FATAL = 1
-WARNING = 2
-ASK_CONT = 3
-ASK_RESTART = 4
-XMAXSCREEN = 1279
-YMAXSCREEN = 1023
-XMAXMEDIUM = 1023
-YMAXMEDIUM = 767
-XMAX170 = 645
-YMAX170 = 484
-XMAXPAL = 779
-YMAXPAL = 574
diff --git a/Lib/plat-irix5/GLWS.py b/Lib/plat-irix5/GLWS.py
deleted file mode 100644
index c1338c73e02..00000000000
--- a/Lib/plat-irix5/GLWS.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the GLWS module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NOERROR = 0
-NOCONTEXT = -1
-NODISPLAY = -2
-NOWINDOW = -3
-NOGRAPHICS = -4
-NOTTOP = -5
-NOVISUAL = -6
-BUFSIZE = -7
-BADWINDOW = -8
-ALREADYBOUND = -100
-BINDFAILED = -101
-SETFAILED = -102
diff --git a/Lib/plat-irix5/IN.py b/Lib/plat-irix5/IN.py
deleted file mode 100644
index 8f5817676fc..00000000000
--- a/Lib/plat-irix5/IN.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# Generated by h2py from /usr/include/netinet/in.h
-from warnings import warnpy3k
-warnpy3k("the IN module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from sys/endian.h
-LITTLE_ENDIAN = 1234
-BIG_ENDIAN = 4321
-PDP_ENDIAN = 3412
-BYTE_ORDER = BIG_ENDIAN
-BYTE_ORDER = LITTLE_ENDIAN
-def ntohl(x): return (x)
-
-def ntohs(x): return (x)
-
-def htonl(x): return (x)
-
-def htons(x): return (x)
-
-def htonl(x): return ntohl(x)
-
-def htons(x): return ntohs(x)
-
-
-# Included from sys/bsd_types.h
-
-# Included from sys/mkdev.h
-ONBITSMAJOR = 7
-ONBITSMINOR = 8
-OMAXMAJ = 0x7f
-OMAXMIN = 0xff
-NBITSMAJOR = 14
-NBITSMINOR = 18
-MAXMAJ = 0x1ff
-MAXMIN = 0x3ffff
-OLDDEV = 0
-NEWDEV = 1
-MKDEV_VER = NEWDEV
-def major(dev): return __major(MKDEV_VER, dev)
-
-def minor(dev): return __minor(MKDEV_VER, dev)
-
-
-# Included from sys/select.h
-FD_SETSIZE = 1024
-NBBY = 8
-IPPROTO_IP = 0
-IPPROTO_ICMP = 1
-IPPROTO_IGMP = 2
-IPPROTO_GGP = 3
-IPPROTO_ENCAP = 4
-IPPROTO_TCP = 6
-IPPROTO_EGP = 8
-IPPROTO_PUP = 12
-IPPROTO_UDP = 17
-IPPROTO_IDP = 22
-IPPROTO_TP = 29
-IPPROTO_XTP = 36
-IPPROTO_HELLO = 63
-IPPROTO_ND = 77
-IPPROTO_EON = 80
-IPPROTO_RAW = 255
-IPPROTO_MAX = 256
-IPPORT_RESERVED = 1024
-IPPORT_USERRESERVED = 5000
-IPPORT_MAXPORT = 65535
-def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
-
-IN_CLASSA_NET = 0xff000000
-IN_CLASSA_NSHIFT = 24
-IN_CLASSA_HOST = 0x00ffffff
-IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
-
-IN_CLASSB_NET = 0xffff0000
-IN_CLASSB_NSHIFT = 16
-IN_CLASSB_HOST = 0x0000ffff
-IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
-
-IN_CLASSC_NET = 0xffffff00
-IN_CLASSC_NSHIFT = 8
-IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
-
-IN_CLASSD_NET = 0xf0000000
-IN_CLASSD_NSHIFT = 28
-IN_CLASSD_HOST = 0x0fffffff
-def IN_MULTICAST(i): return IN_CLASSD(i)
-
-def IN_EXPERIMENTAL(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
-
-def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
-
-INADDR_ANY = 0x00000000
-INADDR_BROADCAST = 0xffffffff
-INADDR_LOOPBACK = 0x7F000001
-INADDR_UNSPEC_GROUP = 0xe0000000
-INADDR_ALLHOSTS_GROUP = 0xe0000001
-INADDR_MAX_LOCAL_GROUP = 0xe00000ff
-INADDR_NONE = 0xffffffff
-IN_LOOPBACKNET = 127
-IP_OPTIONS = 1
-IP_MULTICAST_IF = 2
-IP_MULTICAST_TTL = 3
-IP_MULTICAST_LOOP = 4
-IP_ADD_MEMBERSHIP = 5
-IP_DROP_MEMBERSHIP = 6
-IP_HDRINCL = 7
-IP_TOS = 8
-IP_TTL = 9
-IP_RECVOPTS = 10
-IP_RECVRETOPTS = 11
-IP_RECVDSTADDR = 12
-IP_RETOPTS = 13
-IP_OPTIONS = 1
-IP_HDRINCL = 2
-IP_TOS = 3
-IP_TTL = 4
-IP_RECVOPTS = 5
-IP_RECVRETOPTS = 6
-IP_RECVDSTADDR = 7
-IP_RETOPTS = 8
-IP_MULTICAST_IF = 20
-IP_MULTICAST_TTL = 21
-IP_MULTICAST_LOOP = 22
-IP_ADD_MEMBERSHIP = 23
-IP_DROP_MEMBERSHIP = 24
-IRIX4_IP_OPTIONS = 1
-IRIX4_IP_MULTICAST_IF = 2
-IRIX4_IP_MULTICAST_TTL = 3
-IRIX4_IP_MULTICAST_LOOP = 4
-IRIX4_IP_ADD_MEMBERSHIP = 5
-IRIX4_IP_DROP_MEMBERSHIP = 6
-IRIX4_IP_HDRINCL = 7
-IRIX4_IP_TOS = 8
-IRIX4_IP_TTL = 9
-IRIX4_IP_RECVOPTS = 10
-IRIX4_IP_RECVRETOPTS = 11
-IRIX4_IP_RECVDSTADDR = 12
-IRIX4_IP_RETOPTS = 13
-IP_DEFAULT_MULTICAST_TTL = 1
-IP_DEFAULT_MULTICAST_LOOP = 1
-IP_MAX_MEMBERSHIPS = 20
diff --git a/Lib/plat-irix5/IOCTL.py b/Lib/plat-irix5/IOCTL.py
deleted file mode 100644
index ffe0f932d0e..00000000000
--- a/Lib/plat-irix5/IOCTL.py
+++ /dev/null
@@ -1,236 +0,0 @@
-# These lines were mostly generated by h2py.py (see demo/scripts)
-# from <sys/ioctl.h>, <sys/termio.h> and <termios.h> on Irix 4.0.2
-# with some manual changes to cope with imperfections in h2py.py.
-# The applicability on other systems is not clear; especially non-SYSV
-# systems may have a totally different set of ioctls.
-from warnings import warnpy3k
-warnpy3k("the IOCTL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-IOCTYPE = 0xff00
-LIOC = (ord('l')<<8)
-LIOCGETP = (LIOC|1)
-LIOCSETP = (LIOC|2)
-LIOCGETS = (LIOC|5)
-LIOCSETS = (LIOC|6)
-DIOC = (ord('d')<<8)
-DIOCGETC = (DIOC|1)
-DIOCGETB = (DIOC|2)
-DIOCSETE = (DIOC|3)
-IOCPARM_MASK = 0x7f
-IOC_VOID = 0x20000000
-IOC_OUT = 0x40000000
-IOC_IN = 0x80000000
-IOC_INOUT = (IOC_IN|IOC_OUT)
-int = 'i'
-short = 'h'
-long = 'l'
-def sizeof(t): import struct; return struct.calcsize(t)
-def _IO(x,y): return (IOC_VOID|((x)<<8)|y)
-def _IOR(x,y,t): return (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-def _IOW(x,y,t): return (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-# this should be _IORW, but stdio got there first
-def _IOWR(x,y,t): return (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-FIONREAD = _IOR(ord('f'), 127, int)
-FIONBIO = _IOW(ord('f'), 126, int)
-FIOASYNC = _IOW(ord('f'), 125, int)
-FIOSETOWN = _IOW(ord('f'), 124, int)
-FIOGETOWN = _IOR(ord('f'), 123, int)
-NCC = 8
-NCC_PAD = 7
-NCC_EXT = 16
-NCCS = (NCC+NCC_PAD+NCC_EXT)
-VINTR = 0
-VQUIT = 1
-VERASE = 2
-VKILL = 3
-VEOF = 4
-VEOL = 5
-VEOL2 = 6
-VMIN = VEOF
-VTIME = VEOL
-VSWTCH = 7
-VLNEXT = (NCC+NCC_PAD+0)
-VWERASE = (NCC+NCC_PAD+1)
-VRPRNT = (NCC+NCC_PAD+2)
-VFLUSHO = (NCC+NCC_PAD+3)
-VSTOP = (NCC+NCC_PAD+4)
-VSTART = (NCC+NCC_PAD+5)
-CNUL = '\0'
-CDEL = '\377'
-CESC = '\\'
-CINTR = '\177'
-CQUIT = '\34'
-CBRK = '\377'
-def CTRL(c): return ord(c) & 0x0f
-CERASE = CTRL('H')
-CKILL = CTRL('U')
-CEOF = CTRL('d')
-CEOT = CEOF
-CSTART = CTRL('q')
-CSTOP = CTRL('s')
-CSWTCH = CTRL('z')
-CSUSP = CSWTCH
-CNSWTCH = 0
-CLNEXT = CTRL('v')
-CWERASE = CTRL('w')
-CFLUSHO = CTRL('o')
-CFLUSH = CFLUSHO
-CRPRNT = CTRL('r')
-CDSUSP = CTRL('y')
-IGNBRK = 0000001
-BRKINT = 0000002
-IGNPAR = 0000004
-PARMRK = 0000010
-INPCK = 0000020
-ISTRIP = 0000040
-INLCR = 0000100
-IGNCR = 0000200
-ICRNL = 0000400
-IUCLC = 0001000
-IXON = 0002000
-IXANY = 0004000
-IXOFF = 0010000
-IBLKMD = 0020000
-OPOST = 0000001
-OLCUC = 0000002
-ONLCR = 0000004
-OCRNL = 0000010
-ONOCR = 0000020
-ONLRET = 0000040
-OFILL = 0000100
-OFDEL = 0000200
-NLDLY = 0000400
-NL0 = 0
-NL1 = 0000400
-CRDLY = 0003000
-CR0 = 0
-CR1 = 0001000
-CR2 = 0002000
-CR3 = 0003000
-TABDLY = 0014000
-TAB0 = 0
-TAB1 = 0004000
-TAB2 = 0010000
-TAB3 = 0014000
-BSDLY = 0020000
-BS0 = 0
-BS1 = 0020000
-VTDLY = 0040000
-VT0 = 0
-VT1 = 0040000
-FFDLY = 0100000
-FF0 = 0
-FF1 = 0100000
-CBAUD = 0000017
-B0 = 0
-B50 = 0000001
-B75 = 0000002
-B110 = 0000003
-B134 = 0000004
-B150 = 0000005
-B200 = 0000006
-B300 = 0000007
-B600 = 0000010
-B1200 = 0000011
-B1800 = 0000012
-B2400 = 0000013
-B4800 = 0000014
-B9600 = 0000015
-B19200 = 0000016
-EXTA = 0000016
-B38400 = 0000017
-EXTB = 0000017
-CSIZE = 0000060
-CS5 = 0
-CS6 = 0000020
-CS7 = 0000040
-CS8 = 0000060
-CSTOPB = 0000100
-CREAD = 0000200
-PARENB = 0000400
-PARODD = 0001000
-HUPCL = 0002000
-CLOCAL = 0004000
-LOBLK = 0040000
-ISIG = 0000001
-ICANON = 0000002
-XCASE = 0000004
-ECHO = 0000010
-ECHOE = 0000020
-ECHOK = 0000040
-ECHONL = 0000100
-NOFLSH = 0000200
-IIEXTEN = 0000400
-ITOSTOP = 0001000
-SSPEED = B9600
-IOCTYPE = 0xff00
-TIOC = (ord('T')<<8)
-oTCGETA = (TIOC|1)
-oTCSETA = (TIOC|2)
-oTCSETAW = (TIOC|3)
-oTCSETAF = (TIOC|4)
-TCSBRK = (TIOC|5)
-TCXONC = (TIOC|6)
-TCFLSH = (TIOC|7)
-TCGETA = (TIOC|8)
-TCSETA = (TIOC|9)
-TCSETAW = (TIOC|10)
-TCSETAF = (TIOC|11)
-TIOCFLUSH = (TIOC|12)
-TCDSET = (TIOC|32)
-TCBLKMD = (TIOC|33)
-TIOCPKT = (TIOC|112)
-TIOCPKT_DATA = 0x00
-TIOCPKT_FLUSHREAD = 0x01
-TIOCPKT_FLUSHWRITE = 0x02
-TIOCPKT_NOSTOP = 0x10
-TIOCPKT_DOSTOP = 0x20
-TIOCNOTTY = (TIOC|113)
-TIOCSTI = (TIOC|114)
-TIOCSPGRP = _IOW(ord('t'), 118, int)
-TIOCGPGRP = _IOR(ord('t'), 119, int)
-TIOCCONS = _IOW(ord('t'), 120, int)
-struct_winsize = 'hhhh'
-TIOCGWINSZ = _IOR(ord('t'), 104, struct_winsize)
-TIOCSWINSZ = _IOW(ord('t'), 103, struct_winsize)
-TFIOC = (ord('F')<<8)
-oFIONREAD = (TFIOC|127)
-LDIOC = (ord('D')<<8)
-LDOPEN = (LDIOC|0)
-LDCLOSE = (LDIOC|1)
-LDCHG = (LDIOC|2)
-LDGETT = (LDIOC|8)
-LDSETT = (LDIOC|9)
-TERM_NONE = 0
-TERM_TEC = 1
-TERM_V61 = 2
-TERM_V10 = 3
-TERM_TEX = 4
-TERM_D40 = 5
-TERM_H45 = 6
-TERM_D42 = 7
-TM_NONE = 0000
-TM_SNL = 0001
-TM_ANL = 0002
-TM_LCF = 0004
-TM_CECHO = 0010
-TM_CINVIS = 0020
-TM_SET = 0200
-LDISC0 = 0
-LDISC1 = 1
-NTTYDISC = LDISC1
-VSUSP = VSWTCH
-TCSANOW = 0
-TCSADRAIN = 1
-TCSAFLUSH = 2
-TCIFLUSH = 0
-TCOFLUSH = 1
-TCIOFLUSH = 2
-TCOOFF = 0
-TCOON = 1
-TCIOFF = 2
-TCION = 3
-TO_STOP = LOBLK
-IEXTEN = IIEXTEN
-TOSTOP = ITOSTOP
diff --git a/Lib/plat-irix5/SV.py b/Lib/plat-irix5/SV.py
deleted file mode 100644
index e9e14f8dafa..00000000000
--- a/Lib/plat-irix5/SV.py
+++ /dev/null
@@ -1,124 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the SV module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NTSC_XMAX = 640
-NTSC_YMAX = 480
-PAL_XMAX = 768
-PAL_YMAX = 576
-BLANKING_BUFFER_SIZE = 2
-
-MAX_SOURCES = 2
-
-# mode parameter for Bind calls
-IN_OFF = 0 # No Video
-IN_OVER = 1 # Video over graphics
-IN_UNDER = 2 # Video under graphics
-IN_REPLACE = 3 # Video replaces entire win
-
-# mode parameters for LoadMap calls. Specifies buffer, always 256 entries
-INPUT_COLORMAP = 0 # tuples of 8-bit RGB
-CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB
-COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB
-GAMMA_MAP = 3 # tuples of 24-bit red values
-
-# mode parameters for UseExclusive calls
-INPUT = 0
-OUTPUT = 1
-IN_OUT = 2
-
-# Format constants for the capture routines
-RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields
-RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames
-YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format
-YUV411_FRAMES_AND_BLANKING_BUFFER = 3
-
-#
-# sv.SetParam is passed variable length argument lists,
-# consisting of <name, value> pairs. The following
-# constants identify argument names.
-#
-_NAME_BASE = 1000
-SOURCE = (_NAME_BASE + 0)
-SOURCE1 = 0
-SOURCE2 = 1
-SOURCE3 = 2
-COLOR = (_NAME_BASE + 1)
-DEFAULT_COLOR = 0
-USER_COLOR = 1
-MONO = 2
-OUTPUTMODE = (_NAME_BASE + 2)
-LIVE_OUTPUT = 0
-STILL24_OUT = 1
-FREEZE = (_NAME_BASE + 3)
-DITHER = (_NAME_BASE + 4)
-OUTPUT_FILTER = (_NAME_BASE + 5)
-HUE = (_NAME_BASE + 6)
-GENLOCK = (_NAME_BASE + 7)
-GENLOCK_OFF = 0
-GENLOCK_ON = 1
-GENLOCK_HOUSE = 2
-BROADCAST = (_NAME_BASE + 8)
-NTSC = 0
-PAL = 1
-VIDEO_MODE = (_NAME_BASE + 9)
-COMP = 0
-SVIDEO = 1
-INPUT_BYPASS = (_NAME_BASE + 10)
-FIELDDROP = (_NAME_BASE + 11)
-SLAVE = (_NAME_BASE + 12)
-APERTURE_FACTOR = (_NAME_BASE + 13)
-AFACTOR_0 = 0
-AFACTOR_QTR = 1
-AFACTOR_HLF = 2
-AFACTOR_ONE = 3
-CORING = (_NAME_BASE + 14)
-COR_OFF = 0
-COR_1LSB = 1
-COR_2LSB = 2
-COR_3LSB = 3
-APERTURE_BANDPASS = (_NAME_BASE + 15)
-ABAND_F0 = 0
-ABAND_F1 = 1
-ABAND_F2 = 2
-ABAND_F3 = 3
-PREFILTER = (_NAME_BASE + 16)
-CHROMA_TRAP = (_NAME_BASE + 17)
-CK_THRESHOLD = (_NAME_BASE + 18)
-PAL_SENSITIVITY = (_NAME_BASE + 19)
-GAIN_CONTROL = (_NAME_BASE + 20)
-GAIN_SLOW = 0
-GAIN_MEDIUM = 1
-GAIN_FAST = 2
-GAIN_FROZEN = 3
-AUTO_CKILL = (_NAME_BASE + 21)
-VTR_MODE = (_NAME_BASE + 22)
-VTR_INPUT = 0
-CAMERA_INPUT = 1
-LUMA_DELAY = (_NAME_BASE + 23)
-VNOISE = (_NAME_BASE + 24)
-VNOISE_NORMAL = 0
-VNOISE_SEARCH = 1
-VNOISE_AUTO = 2
-VNOISE_BYPASS = 3
-CHCV_PAL = (_NAME_BASE + 25)
-CHCV_NTSC = (_NAME_BASE + 26)
-CCIR_LEVELS = (_NAME_BASE + 27)
-STD_CHROMA = (_NAME_BASE + 28)
-DENC_VTBYPASS = (_NAME_BASE + 29)
-FAST_TIMECONSTANT = (_NAME_BASE + 30)
-GENLOCK_DELAY = (_NAME_BASE + 31)
-PHASE_SYNC = (_NAME_BASE + 32)
-VIDEO_OUTPUT = (_NAME_BASE + 33)
-CHROMA_PHASEOUT = (_NAME_BASE + 34)
-CHROMA_CENTER = (_NAME_BASE + 35)
-YUV_TO_RGB_INVERT = (_NAME_BASE + 36)
-SOURCE1_BROADCAST = (_NAME_BASE + 37)
-SOURCE1_MODE = (_NAME_BASE + 38)
-SOURCE2_BROADCAST = (_NAME_BASE + 39)
-SOURCE2_MODE = (_NAME_BASE + 40)
-SOURCE3_BROADCAST = (_NAME_BASE + 41)
-SOURCE3_MODE = (_NAME_BASE + 42)
-SIGNAL_STD = (_NAME_BASE + 43)
-NOSIGNAL = 2
-SIGNAL_COLOR = (_NAME_BASE + 44)
diff --git a/Lib/plat-irix5/WAIT.py b/Lib/plat-irix5/WAIT.py
deleted file mode 100644
index 913a147d35b..00000000000
--- a/Lib/plat-irix5/WAIT.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated by h2py from /usr/include/sys/wait.h
-from warnings import warnpy3k
-warnpy3k("the WAIT module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-_WSTOPPED = 0177
-WNOHANG = 0100
-WEXITED = 0001
-WTRAPPED = 0002
-WSTOPPED = 0004
-WCONTINUED = 0010
-WNOWAIT = 0200
-WOPTMASK = (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
-WSTOPFLG = 0177
-WCONTFLG = 0177777
-WCOREFLAG = 0200
-WSIGMASK = 0177
-WUNTRACED = 0004
diff --git a/Lib/plat-irix5/cddb.py b/Lib/plat-irix5/cddb.py
deleted file mode 100644
index ea5e9fd465a..00000000000
--- a/Lib/plat-irix5/cddb.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# This file implements a class which forms an interface to the .cddb
-# directory that is maintained by SGI's cdman program.
-#
-# Usage is as follows:
-#
-# import readcd
-# r = readcd.Readcd()
-# c = Cddb(r.gettrackinfo())
-#
-# Now you can use c.artist, c.title and c.track[trackno] (where trackno
-# starts at 1). When the CD is not recognized, all values will be the empty
-# string.
-# It is also possible to set the above mentioned variables to new values.
-# You can then use c.write() to write out the changed values to the
-# .cdplayerrc file.
-from warnings import warnpy3k
-warnpy3k("the cddb module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import string, posix, os
-
-_cddbrc = '.cddb'
-_DB_ID_NTRACKS = 5
-_dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz'
-def _dbid(v):
- if v >= len(_dbid_map):
- return string.zfill(v, 2)
- else:
- return _dbid_map[v]
-
-def tochash(toc):
- if type(toc) == type(''):
- tracklist = []
- for i in range(2, len(toc), 4):
- tracklist.append((None,
- (int(toc[i:i+2]),
- int(toc[i+2:i+4]))))
- else:
- tracklist = toc
- ntracks = len(tracklist)
- hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- hash = hash + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- hash = hash + _dbid(length[0]) + _dbid(length[1])
- return hash
-
-class Cddb:
- def __init__(self, tracklist):
- if os.environ.has_key('CDDB_PATH'):
- path = os.environ['CDDB_PATH']
- cddb_path = path.split(',')
- else:
- home = os.environ['HOME']
- cddb_path = [home + '/' + _cddbrc]
-
- self._get_id(tracklist)
-
- for dir in cddb_path:
- file = dir + '/' + self.id + '.rdb'
- try:
- f = open(file, 'r')
- self.file = file
- break
- except IOError:
- pass
- ntracks = int(self.id[:2], 16)
- self.artist = ''
- self.title = ''
- self.track = [None] + [''] * ntracks
- self.trackartist = [None] + [''] * ntracks
- self.notes = []
- if not hasattr(self, 'file'):
- return
- import re
- reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)')
- while 1:
- line = f.readline()
- if not line:
- break
- match = reg.match(line)
- if not match:
- print 'syntax error in ' + file
- continue
- name1, name2, value = match.group(1, 2, 3)
- if name1 == 'album':
- if name2 == 'artist':
- self.artist = value
- elif name2 == 'title':
- self.title = value
- elif name2 == 'toc':
- if not self.toc:
- self.toc = value
- if self.toc != value:
- print 'toc\'s don\'t match'
- elif name2 == 'notes':
- self.notes.append(value)
- elif name1[:5] == 'track':
- try:
- trackno = int(name1[5:])
- except strings.atoi_error:
- print 'syntax error in ' + file
- continue
- if trackno > ntracks:
- print 'track number %r in file %r out of range' % (trackno, file)
- continue
- if name2 == 'title':
- self.track[trackno] = value
- elif name2 == 'artist':
- self.trackartist[trackno] = value
- f.close()
- for i in range(2, len(self.track)):
- track = self.track[i]
- # if track title starts with `,', use initial part
- # of previous track's title
- if track and track[0] == ',':
- try:
- off = self.track[i - 1].index(',')
- except ValueError:
- pass
- else:
- self.track[i] = self.track[i-1][:off] \
- + track
-
- def _get_id(self, tracklist):
- # fill in self.id and self.toc.
- # if the argument is a string ending in .rdb, the part
- # upto the suffix is taken as the id.
- if type(tracklist) == type(''):
- if tracklist[-4:] == '.rdb':
- self.id = tracklist[:-4]
- self.toc = ''
- return
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (int(tracklist[i:i+2]), \
- int(tracklist[i+2:i+4]))))
- tracklist = t
- ntracks = len(tracklist)
- self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- self.id = self.id + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- self.id = self.id + _dbid(length[0]) + _dbid(length[1])
- self.toc = string.zfill(ntracks, 2)
- for track in tracklist:
- start, length = track
- self.toc = self.toc + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
-
- def write(self):
- import posixpath
- if os.environ.has_key('CDDB_WRITE_DIR'):
- dir = os.environ['CDDB_WRITE_DIR']
- else:
- dir = os.environ['HOME'] + '/' + _cddbrc
- file = dir + '/' + self.id + '.rdb'
- if posixpath.exists(file):
- # make backup copy
- posix.rename(file, file + '~')
- f = open(file, 'w')
- f.write('album.title:\t' + self.title + '\n')
- f.write('album.artist:\t' + self.artist + '\n')
- f.write('album.toc:\t' + self.toc + '\n')
- for note in self.notes:
- f.write('album.notes:\t' + note + '\n')
- prevpref = None
- for i in range(1, len(self.track)):
- if self.trackartist[i]:
- f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
- track = self.track[i]
- try:
- off = track.index(',')
- except ValuError:
- prevpref = None
- else:
- if prevpref and track[:off] == prevpref:
- track = track[off:]
- else:
- prevpref = track[:off]
- f.write('track%r.title:\t%s\n' % (i, track))
- f.close()
diff --git a/Lib/plat-irix5/cdplayer.py b/Lib/plat-irix5/cdplayer.py
deleted file mode 100644
index 9e4ba9c3187..00000000000
--- a/Lib/plat-irix5/cdplayer.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# This file implements a class which forms an interface to the .cdplayerrc
-# file that is maintained by SGI's cdplayer program.
-#
-# Usage is as follows:
-#
-# import readcd
-# r = readcd.Readcd()
-# c = Cdplayer(r.gettrackinfo())
-#
-# Now you can use c.artist, c.title and c.track[trackno] (where trackno
-# starts at 1). When the CD is not recognized, all values will be the empty
-# string.
-# It is also possible to set the above mentioned variables to new values.
-# You can then use c.write() to write out the changed values to the
-# .cdplayerrc file.
-from warnings import warnpy3k
-warnpy3k("the cdplayer module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-cdplayerrc = '.cdplayerrc'
-
-class Cdplayer:
- def __init__(self, tracklist):
- import string
- self.artist = ''
- self.title = ''
- if type(tracklist) == type(''):
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (string.atoi(tracklist[i:i+2]), \
- string.atoi(tracklist[i+2:i+4]))))
- tracklist = t
- self.track = [None] + [''] * len(tracklist)
- self.id = 'd' + string.zfill(len(tracklist), 2)
- for track in tracklist:
- start, length = track
- self.id = self.id + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
- try:
- import posix
- f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
- except IOError:
- return
- import re
- reg = re.compile(r'^([^:]*):\t(.*)')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = f.readline()
- if line == '':
- break
- if line[:l] == s:
- line = line[l:]
- match = reg.match(line)
- if not match:
- print 'syntax error in ~/' + cdplayerrc
- continue
- name, value = match.group(1, 2)
- if name == 'title':
- self.title = value
- elif name == 'artist':
- self.artist = value
- elif name[:5] == 'track':
- trackno = string.atoi(name[6:])
- self.track[trackno] = value
- f.close()
-
- def write(self):
- import posix
- filename = posix.environ['HOME'] + '/' + cdplayerrc
- try:
- old = open(filename, 'r')
- except IOError:
- old = open('/dev/null', 'r')
- new = open(filename + '.new', 'w')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = old.readline()
- if line == '':
- break
- if line[:l] != s:
- new.write(line)
- new.write(self.id + '.title:\t' + self.title + '\n')
- new.write(self.id + '.artist:\t' + self.artist + '\n')
- for i in range(1, len(self.track)):
- new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i]))
- old.close()
- new.close()
- posix.rename(filename + '.new', filename)
diff --git a/Lib/plat-irix5/flp.doc b/Lib/plat-irix5/flp.doc
deleted file mode 100644
index 1a2f374ae7a..00000000000
--- a/Lib/plat-irix5/flp.doc
+++ /dev/null
@@ -1,117 +0,0 @@
-.SH
-Module flp
-.LP
-The flp module loads fl-forms from fd files, as generated
-by fdesign. The module is designed to be flexible enough to allow
-almost anything to be done with the loaded form.
-.LP
-Loadform defines
-two types of functions: functions to parse fd files and functions to
-create the forms from the templates returned by the parse functions.
-There are fairly low-level create functions that create single objects,
-and convenience routines that create complete forms, including callbacks,
-etc.
-.LP
-The exception flp.error is raised whenever an error occurs while parsing a forms
-definition file or creating a form.
-.SH 2
-Parsing functions
-.LP
-There are two parsing functions, parse_form() and parse_forms(). They
-take the following form:
-.LP
-.ft C
-ftuple = parse_form(filename, formname)
-.br
-ftdict = parse_forms(filename)
-.IP
-Parse_form parses a single form, and returns a tuple (ftmp, otmplist).
-Ftmp is a template for a form, otmplist is a list of templates for
-objects. See below for a description of these templates.
-.IP
-Parse_forms parses all forms in an fd file. It returns a dictionary of
-(ftmp, otmplist) tuples, indexed by formname.
-.IP
-Filename is the name of the forms definition file to inspect. The functions
-appends '.fd' if needed, and use 'sys.path' to locate the file.
-.IP
-formname is the name of the form to load. This argument is mandatory,
-even if the file only contains one form.
-.LP
-The form template and object template are structures that contain all
-the information read from the fd file, in 'natural' form. A form
-template record contains the following fields:
-.IP
-.nf
-"Name", the name of the form;
-"Width", the width of the form;
-"Height", the height of the form; and
-"Numberofobjects", the number of objects in the form.
-.LP
-An object template contains the following fields:
-.IP
-.nf
-"Class", the class of object (eg. FL.BUTTON);
-"Type", the sub-class (eg. FL.NORMALBUTTON);
-"Box", a list with four members: [x, y, width, height];
-"Boxtype", the type of box (eg. FL.DOWNBOX);
-"Colors", a list with the two object colors;
-"Alignment", the label alignment (eg. FL.ALIGNLEFT);
-"Style", the label style (eg. FL.BOLDSTYLE);
-"Lcol", the label color;
-"Label", a string containing the label;
-"Name", a string containing the name of the object;
-"Callback", a string containing the callback routine name; and
-"Argument", a string containing the callback routine extra argument.
-.SH
-Low-level create routines.
-.LP
-The three low-level creation routines are called as follows:
-.LP
-.ft C
-form = create_form(form_template)
-.IP
-Create an fl form from a form template. Returns the form created.
-.LP
-.ft C
-obj = create_object(form, obj_template)
-.IP
-Create an object in an fl form. Return the new object.
-An error is raised if the object has a callback routine.
-.SH
-High-level create routines.
-.LP
-The 'standard' way to handle forms in python is to define a class
-that contains the form and all the objects (insofar as they are named),
-and that defines all the callback functions, and use an instance of
-this class to handle the form interaction.
-Flp contains three routines that simplify handling this paradigm:
-.LP
-.ft C
-create_full_form(instance, ftuple)
-.IP
-This routine takes an instance of your form-handling class and an
-ftuple (as returned by the parsing routines) as parameters. It inserts
-the form into the instance, defines all object names and arranges that
-the callback methods are called. All the names inserted into the
-instance are the same as the names used for the objects, etc. in the
-fd file.
-.LP
-.ft C
-merge_full_form(instance, form, ftuple)
-.IP
-This function does the same as create_full_form, only it does not create
-the form itself nor the 'background box' that fdesign automatically
-adds to each form. This is useful if your class inherits a superclass
-that already defines a skeleton form (with 'OK' and 'Cancel' buttons,
-for instance), and you want to merge the new form into that existing
-form. The 'form' parameter is the form to which the new objects are
-added.
-.LP
-If you use the paradigm sketched here but need slightly more control
-over object creation there is a routine that creates a single object
-and inserts its name (and arranges for the callback routine to be
-called):
-.LP
-.ft C
-create_object_instance(instance, form, obj_template)
diff --git a/Lib/plat-irix5/flp.py b/Lib/plat-irix5/flp.py
deleted file mode 100644
index 13c926f3ad7..00000000000
--- a/Lib/plat-irix5/flp.py
+++ /dev/null
@@ -1,455 +0,0 @@
-#
-# flp - Module to load fl forms from fd files
-#
-# Jack Jansen, December 1991
-#
-from warnings import warnpy3k
-warnpy3k("the flp module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import string
-import os
-import sys
-import FL
-
-SPLITLINE = '--------------------'
-FORMLINE = '=============== FORM ==============='
-ENDLINE = '=============================='
-
-class error(Exception):
- pass
-
-##################################################################
-# Part 1 - The parsing routines #
-##################################################################
-
-#
-# Externally visible function. Load form.
-#
-def parse_form(filename, formname):
- forms = checkcache(filename)
- if forms is None:
- forms = parse_forms(filename)
- if forms.has_key(formname):
- return forms[formname]
- else:
- raise error, 'No such form in fd file'
-
-#
-# Externally visible function. Load all forms.
-#
-def parse_forms(filename):
- forms = checkcache(filename)
- if forms is not None: return forms
- fp = _open_formfile(filename)
- nforms = _parse_fd_header(fp)
- forms = {}
- for i in range(nforms):
- form = _parse_fd_form(fp, None)
- forms[form[0].Name] = form
- writecache(filename, forms)
- return forms
-
-#
-# Internal: see if a cached version of the file exists
-#
-MAGIC = '.fdc'
-_internal_cache = {} # Used by frozen scripts only
-def checkcache(filename):
- if _internal_cache.has_key(filename):
- altforms = _internal_cache[filename]
- return _unpack_cache(altforms)
- import marshal
- fp, filename = _open_formfile2(filename)
- fp.close()
- cachename = filename + 'c'
- try:
- fp = open(cachename, 'r')
- except IOError:
- #print 'flp: no cache file', cachename
- return None
- try:
- if fp.read(4) != MAGIC:
- print 'flp: bad magic word in cache file', cachename
- return None
- cache_mtime = rdlong(fp)
- file_mtime = getmtime(filename)
- if cache_mtime != file_mtime:
- #print 'flp: outdated cache file', cachename
- return None
- #print 'flp: valid cache file', cachename
- altforms = marshal.load(fp)
- return _unpack_cache(altforms)
- finally:
- fp.close()
-
-def _unpack_cache(altforms):
- forms = {}
- for name in altforms.keys():
- altobj, altlist = altforms[name]
- obj = _newobj()
- obj.make(altobj)
- list = []
- for altobj in altlist:
- nobj = _newobj()
- nobj.make(altobj)
- list.append(nobj)
- forms[name] = obj, list
- return forms
-
-def rdlong(fp):
- s = fp.read(4)
- if len(s) != 4: return None
- a, b, c, d = s[0], s[1], s[2], s[3]
- return ord(a)<<24 | ord(b)<<16 | ord(c)<<8 | ord(d)
-
-def wrlong(fp, x):
- a, b, c, d = (x>>24)&0xff, (x>>16)&0xff, (x>>8)&0xff, x&0xff
- fp.write(chr(a) + chr(b) + chr(c) + chr(d))
-
-def getmtime(filename):
- import os
- from stat import ST_MTIME
- try:
- return os.stat(filename)[ST_MTIME]
- except os.error:
- return None
-
-#
-# Internal: write cached version of the form (parsing is too slow!)
-#
-def writecache(filename, forms):
- import marshal
- fp, filename = _open_formfile2(filename)
- fp.close()
- cachename = filename + 'c'
- try:
- fp = open(cachename, 'w')
- except IOError:
- print 'flp: can\'t create cache file', cachename
- return # Never mind
- fp.write('\0\0\0\0') # Seek back and write MAGIC when done
- wrlong(fp, getmtime(filename))
- altforms = _pack_cache(forms)
- marshal.dump(altforms, fp)
- fp.seek(0)
- fp.write(MAGIC)
- fp.close()
- #print 'flp: wrote cache file', cachename
-
-#
-# External: print some statements that set up the internal cache.
-# This is for use with the "freeze" script. You should call
-# flp.freeze(filename) for all forms used by the script, and collect
-# the output on a file in a module file named "frozenforms.py". Then
-# in the main program of the script import frozenforms.
-# (Don't forget to take this out when using the unfrozen version of
-# the script!)
-#
-def freeze(filename):
- forms = parse_forms(filename)
- altforms = _pack_cache(forms)
- print 'import flp'
- print 'flp._internal_cache[', repr(filename), '] =', altforms
-
-#
-# Internal: create the data structure to be placed in the cache
-#
-def _pack_cache(forms):
- altforms = {}
- for name in forms.keys():
- obj, list = forms[name]
- altobj = obj.__dict__
- altlist = []
- for obj in list: altlist.append(obj.__dict__)
- altforms[name] = altobj, altlist
- return altforms
-
-#
-# Internal: Locate form file (using PYTHONPATH) and open file
-#
-def _open_formfile(filename):
- return _open_formfile2(filename)[0]
-
-def _open_formfile2(filename):
- if filename[-3:] != '.fd':
- filename = filename + '.fd'
- if filename[0] == '/':
- try:
- fp = open(filename,'r')
- except IOError:
- fp = None
- else:
- for pc in sys.path:
- pn = os.path.join(pc, filename)
- try:
- fp = open(pn, 'r')
- filename = pn
- break
- except IOError:
- fp = None
- if fp is None:
- raise error, 'Cannot find forms file ' + filename
- return fp, filename
-
-#
-# Internal: parse the fd file header, return number of forms
-#
-def _parse_fd_header(file):
- # First read the magic header line
- datum = _parse_1_line(file)
- if datum != ('Magic', 12321):
- raise error, 'Not a forms definition file'
- # Now skip until we know number of forms
- while 1:
- datum = _parse_1_line(file)
- if type(datum) == type(()) and datum[0] == 'Numberofforms':
- break
- return datum[1]
-#
-# Internal: parse fd form, or skip if name doesn't match.
-# the special value None means 'always parse it'.
-#
-def _parse_fd_form(file, name):
- datum = _parse_1_line(file)
- if datum != FORMLINE:
- raise error, 'Missing === FORM === line'
- form = _parse_object(file)
- if form.Name == name or name is None:
- objs = []
- for j in range(form.Numberofobjects):
- obj = _parse_object(file)
- objs.append(obj)
- return (form, objs)
- else:
- for j in range(form.Numberofobjects):
- _skip_object(file)
- return None
-
-#
-# Internal class: a convenient place to store object info fields
-#
-class _newobj:
- def add(self, name, value):
- self.__dict__[name] = value
- def make(self, dict):
- for name in dict.keys():
- self.add(name, dict[name])
-
-#
-# Internal parsing routines.
-#
-def _parse_string(str):
- if '\\' in str:
- s = '\'' + str + '\''
- try:
- return eval(s)
- except:
- pass
- return str
-
-def _parse_num(str):
- return eval(str)
-
-def _parse_numlist(str):
- slist = string.split(str)
- nlist = []
- for i in slist:
- nlist.append(_parse_num(i))
- return nlist
-
-# This dictionary maps item names to parsing routines.
-# If no routine is given '_parse_num' is default.
-_parse_func = { \
- 'Name': _parse_string, \
- 'Box': _parse_numlist, \
- 'Colors': _parse_numlist, \
- 'Label': _parse_string, \
- 'Name': _parse_string, \
- 'Callback': _parse_string, \
- 'Argument': _parse_string }
-
-# This function parses a line, and returns either
-# a string or a tuple (name,value)
-
-import re
-prog = re.compile('^([^:]*): *(.*)')
-
-def _parse_line(line):
- match = prog.match(line)
- if not match:
- return line
- name, value = match.group(1, 2)
- if name[0] == 'N':
- name = string.join(string.split(name),'')
- name = string.lower(name)
- name = string.capitalize(name)
- try:
- pf = _parse_func[name]
- except KeyError:
- pf = _parse_num
- value = pf(value)
- return (name, value)
-
-def _readline(file):
- line = file.readline()
- if not line:
- raise EOFError
- return line[:-1]
-
-def _parse_1_line(file):
- line = _readline(file)
- while line == '':
- line = _readline(file)
- return _parse_line(line)
-
-def _skip_object(file):
- line = ''
- while not line in (SPLITLINE, FORMLINE, ENDLINE):
- pos = file.tell()
- line = _readline(file)
- if line == FORMLINE:
- file.seek(pos)
-
-def _parse_object(file):
- obj = _newobj()
- while 1:
- pos = file.tell()
- datum = _parse_1_line(file)
- if datum in (SPLITLINE, FORMLINE, ENDLINE):
- if datum == FORMLINE:
- file.seek(pos)
- return obj
- if type(datum) is not type(()) or len(datum) != 2:
- raise error, 'Parse error, illegal line in object: '+datum
- obj.add(datum[0], datum[1])
-
-#################################################################
-# Part 2 - High-level object/form creation routines #
-#################################################################
-
-#
-# External - Create a form an link to an instance variable.
-#
-def create_full_form(inst, (fdata, odatalist)):
- form = create_form(fdata)
- exec 'inst.'+fdata.Name+' = form\n'
- for odata in odatalist:
- create_object_instance(inst, form, odata)
-
-#
-# External - Merge a form into an existing form in an instance
-# variable.
-#
-def merge_full_form(inst, form, (fdata, odatalist)):
- exec 'inst.'+fdata.Name+' = form\n'
- if odatalist[0].Class != FL.BOX:
- raise error, 'merge_full_form() expects FL.BOX as first obj'
- for odata in odatalist[1:]:
- create_object_instance(inst, form, odata)
-
-
-#################################################################
-# Part 3 - Low-level object/form creation routines #
-#################################################################
-
-#
-# External Create_form - Create form from parameters
-#
-def create_form(fdata):
- import fl
- return fl.make_form(FL.NO_BOX, fdata.Width, fdata.Height)
-
-#
-# External create_object - Create an object. Make sure there are
-# no callbacks. Returns the object created.
-#
-def create_object(form, odata):
- obj = _create_object(form, odata)
- if odata.Callback:
- raise error, 'Creating free object with callback'
- return obj
-#
-# External create_object_instance - Create object in an instance.
-#
-def create_object_instance(inst, form, odata):
- obj = _create_object(form, odata)
- if odata.Callback:
- cbfunc = eval('inst.'+odata.Callback)
- obj.set_call_back(cbfunc, odata.Argument)
- if odata.Name:
- exec 'inst.' + odata.Name + ' = obj\n'
-#
-# Internal _create_object: Create the object and fill options
-#
-def _create_object(form, odata):
- crfunc = _select_crfunc(form, odata.Class)
- obj = crfunc(odata.Type, odata.Box[0], odata.Box[1], odata.Box[2], \
- odata.Box[3], odata.Label)
- if not odata.Class in (FL.BEGIN_GROUP, FL.END_GROUP):
- obj.boxtype = odata.Boxtype
- obj.col1 = odata.Colors[0]
- obj.col2 = odata.Colors[1]
- obj.align = odata.Alignment
- obj.lstyle = odata.Style
- obj.lsize = odata.Size
- obj.lcol = odata.Lcol
- return obj
-#
-# Internal crfunc: helper function that returns correct create function
-#
-def _select_crfunc(fm, cl):
- if cl == FL.BEGIN_GROUP: return fm.bgn_group
- elif cl == FL.END_GROUP: return fm.end_group
- elif cl == FL.BITMAP: return fm.add_bitmap
- elif cl == FL.BOX: return fm.add_box
- elif cl == FL.BROWSER: return fm.add_browser
- elif cl == FL.BUTTON: return fm.add_button
- elif cl == FL.CHART: return fm.add_chart
- elif cl == FL.CHOICE: return fm.add_choice
- elif cl == FL.CLOCK: return fm.add_clock
- elif cl == FL.COUNTER: return fm.add_counter
- elif cl == FL.DIAL: return fm.add_dial
- elif cl == FL.FREE: return fm.add_free
- elif cl == FL.INPUT: return fm.add_input
- elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
- elif cl == FL.MENU: return fm.add_menu
- elif cl == FL.POSITIONER: return fm.add_positioner
- elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
- elif cl == FL.SLIDER: return fm.add_slider
- elif cl == FL.VALSLIDER: return fm.add_valslider
- elif cl == FL.TEXT: return fm.add_text
- elif cl == FL.TIMER: return fm.add_timer
- else:
- raise error, 'Unknown object type: %r' % (cl,)
-
-
-def test():
- import time
- t0 = time.time()
- if len(sys.argv) == 2:
- forms = parse_forms(sys.argv[1])
- t1 = time.time()
- print 'parse time:', 0.001*(t1-t0), 'sec.'
- keys = forms.keys()
- keys.sort()
- for i in keys:
- _printform(forms[i])
- elif len(sys.argv) == 3:
- form = parse_form(sys.argv[1], sys.argv[2])
- t1 = time.time()
- print 'parse time:', round(t1-t0, 3), 'sec.'
- _printform(form)
- else:
- print 'Usage: test fdfile [form]'
-
-def _printform(form):
- f = form[0]
- objs = form[1]
- print 'Form ', f.Name, ', size: ', f.Width, f.Height, ' Nobj ', f.Numberofobjects
- for i in objs:
- print ' Obj ', i.Name, ' type ', i.Class, i.Type
- print ' Box ', i.Box, ' btype ', i.Boxtype
- print ' Label ', i.Label, ' size/style/col/align ', i.Size,i.Style, i.Lcol, i.Alignment
- print ' cols ', i.Colors
- print ' cback ', i.Callback, i.Argument
diff --git a/Lib/plat-irix5/jpeg.py b/Lib/plat-irix5/jpeg.py
deleted file mode 100644
index 944ce930e1e..00000000000
--- a/Lib/plat-irix5/jpeg.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Implement 'jpeg' interface using SGI's compression library
-
-# XXX Options 'smooth' and 'optimize' are ignored.
-
-# XXX It appears that compressing grayscale images doesn't work right;
-# XXX the resulting file causes weirdness.
-from warnings import warnpy3k
-warnpy3k("the jpeg module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-class error(Exception):
- pass
-
-options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
-
-comp = None
-decomp = None
-
-def compress(imgdata, width, height, bytesperpixel):
- global comp
- import cl
- if comp is None: comp = cl.OpenCompressor(cl.JPEG)
- if bytesperpixel == 1:
- format = cl.GRAYSCALE
- elif bytesperpixel == 4:
- format = cl.RGBX
- if options['forcegray']:
- iformat = cl.GRAYSCALE
- else:
- iformat = cl.YUV
- # XXX How to support 'optimize'?
- params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height, \
- cl.ORIGINAL_FORMAT, format, \
- cl.ORIENTATION, cl.BOTTOM_UP, \
- cl.QUALITY_FACTOR, options['quality'], \
- cl.INTERNAL_FORMAT, iformat, \
- ]
- comp.SetParams(params)
- jpegdata = comp.Compress(1, imgdata)
- return jpegdata
-
-def decompress(jpegdata):
- global decomp
- import cl
- if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
- headersize = decomp.ReadHeader(jpegdata)
- params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
- decomp.GetParams(params)
- width, height, format = params[1], params[3], params[5]
- if format == cl.GRAYSCALE or options['forcegray']:
- format = cl.GRAYSCALE
- bytesperpixel = 1
- else:
- format = cl.RGBX
- bytesperpixel = 4
- # XXX How to support 'smooth'?
- params = [cl.ORIGINAL_FORMAT, format, \
- cl.ORIENTATION, cl.BOTTOM_UP, \
- cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
- decomp.SetParams(params)
- imgdata = decomp.Decompress(1, jpegdata)
- return imgdata, width, height, bytesperpixel
-
-def setoption(name, value):
- if type(value) is not type(0):
- raise TypeError, 'jpeg.setoption: numeric options only'
- if name == 'forcegrey':
- name = 'forcegray'
- if not options.has_key(name):
- raise KeyError, 'jpeg.setoption: unknown option name'
- options[name] = int(value)
-
-def test():
- import sys
- if sys.argv[1:2] == ['-g']:
- del sys.argv[1]
- setoption('forcegray', 1)
- if not sys.argv[1:]:
- sys.argv.append('/usr/local/images/data/jpg/asterix.jpg')
- for file in sys.argv[1:]:
- show(file)
-
-def show(file):
- import gl, GL, DEVICE
- jpegdata = open(file, 'r').read()
- imgdata, width, height, bytesperpixel = decompress(jpegdata)
- gl.foreground()
- gl.prefsize(width, height)
- win = gl.winopen(file)
- if bytesperpixel == 1:
- gl.cmode()
- gl.pixmode(GL.PM_SIZE, 8)
- gl.gconfig()
- for i in range(256):
- gl.mapcolor(i, i, i, i)
- else:
- gl.RGBmode()
- gl.pixmode(GL.PM_SIZE, 32)
- gl.gconfig()
- gl.qdevice(DEVICE.REDRAW)
- gl.qdevice(DEVICE.ESCKEY)
- gl.qdevice(DEVICE.WINQUIT)
- gl.qdevice(DEVICE.WINSHUT)
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- while 1:
- dev, val = gl.qread()
- if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
- break
- if dev == DEVICE.REDRAW:
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- gl.winclose(win)
- # Now test the compression and write the result to a fixed filename
- newjpegdata = compress(imgdata, width, height, bytesperpixel)
- open('/tmp/j.jpg', 'w').write(newjpegdata)
diff --git a/Lib/plat-irix5/panel.py b/Lib/plat-irix5/panel.py
deleted file mode 100644
index fcfa56b54d9..00000000000
--- a/Lib/plat-irix5/panel.py
+++ /dev/null
@@ -1,284 +0,0 @@
-# Module 'panel'
-#
-# Support for the Panel library.
-# Uses built-in module 'pnl'.
-# Applications should use 'panel.function' instead of 'pnl.function';
-# most 'pnl' functions are transparently exported by 'panel',
-# but dopanel() is overridden and you have to use this version
-# if you want to use callbacks.
-from warnings import warnpy3k
-warnpy3k("the panel module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-
-import pnl
-
-
-debug = 0
-
-
-# Test if an object is a list.
-#
-def is_list(x):
- return type(x) == type([])
-
-
-# Reverse a list.
-#
-def reverse(list):
- res = []
- for item in list:
- res.insert(0, item)
- return res
-
-
-# Get an attribute of a list, which may itself be another list.
-# Don't use 'prop' for name.
-#
-def getattrlist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == name:
- return item[1:]
- return []
-
-
-# Get a property of a list, which may itself be another list.
-#
-def getproplist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == 'prop':
- if len(item) > 1 and item[1] == name:
- return item[2:]
- return []
-
-
-# Test if an actuator description contains the property 'end-of-group'
-#
-def is_endgroup(list):
- x = getproplist(list, 'end-of-group')
- return (x and x[0] == '#t')
-
-
-# Neatly display an actuator definition given as S-expression
-# the prefix string is printed before each line.
-#
-def show_actuator(prefix, a):
- for item in a:
- if not is_list(item):
- print prefix, item
- elif item and item[0] == 'al':
- print prefix, 'Subactuator list:'
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print prefix, item[0], '=>', item[1]
- elif len(item) == 3 and item[0] == 'prop':
- print prefix, 'Prop', item[1], '=>',
- print item[2]
- else:
- print prefix, '?', item
-
-
-# Neatly display a panel.
-#
-def show_panel(prefix, p):
- for item in p:
- if not is_list(item):
- print prefix, item
- elif item and item[0] == 'al':
- print prefix, 'Actuator list:'
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print prefix, item[0], '=>', item[1]
- elif len(item) == 3 and item[0] == 'prop':
- print prefix, 'Prop', item[1], '=>',
- print item[2]
- else:
- print prefix, '?', item
-
-
-# Exception raised by build_actuator or build_panel.
-#
-panel_error = 'panel error'
-
-
-# Dummy callback used to initialize the callbacks.
-#
-def dummy_callback(arg):
- pass
-
-
-# Assign attributes to members of the target.
-# Attribute names in exclist are ignored.
-# The member name is the attribute name prefixed with the prefix.
-#
-def assign_members(target, attrlist, exclist, prefix):
- for item in attrlist:
- if is_list(item) and len(item) == 2 and item[0] not in exclist:
- name, value = item[0], item[1]
- ok = 1
- if value[0] in '-0123456789':
- value = eval(value)
- elif value[0] == '"':
- value = value[1:-1]
- elif value == 'move-then-resize':
- # Strange default set by Panel Editor...
- ok = 0
- else:
- print 'unknown value', value, 'for', name
- ok = 0
- if ok:
- lhs = 'target.' + prefix + name
- stmt = lhs + '=' + repr(value)
- if debug: print 'exec', stmt
- try:
- exec stmt + '\n'
- except KeyboardInterrupt: # Don't catch this!
- raise KeyboardInterrupt
- except:
- print 'assign failed:', stmt
-
-
-# Build a real actuator from an actuator description.
-# Return a pair (actuator, name).
-#
-def build_actuator(descr):
- namelist = getattrlist(descr, 'name')
- if namelist:
- # Assume it is a string
- actuatorname = namelist[0][1:-1]
- else:
- actuatorname = ''
- type = descr[0]
- if type[:4] == 'pnl_': type = type[4:]
- act = pnl.mkact(type)
- act.downfunc = act.activefunc = act.upfunc = dummy_callback
- #
- assign_members(act, descr[1:], ['al', 'data', 'name'], '')
- #
- # Treat actuator-specific data
- #
- datalist = getattrlist(descr, 'data')
- prefix = ''
- if type[-4:] == 'puck':
- prefix = 'puck_'
- elif type == 'mouse':
- prefix = 'mouse_'
- assign_members(act, datalist, [], prefix)
- #
- return act, actuatorname
-
-
-# Build all sub-actuators and add them to the super-actuator.
-# The super-actuator must already have been added to the panel.
-# Sub-actuators with defined names are added as members to the panel
-# so they can be referenced as p.name.
-#
-# Note: I have no idea how panel.endgroup() works when applied
-# to a sub-actuator.
-#
-def build_subactuators(panel, super_act, al):
- #
- # This is nearly the same loop as below in build_panel(),
- # except a call is made to addsubact() instead of addact().
- #
- for a in al:
- act, name = build_actuator(a)
- act.addsubact(super_act)
- if name:
- stmt = 'panel.' + name + ' = act'
- if debug: print 'exec', stmt
- exec stmt + '\n'
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- # Fix the actuator to which whe just added subactuators.
- # This can't hurt (I hope) and is needed for the scroll actuator.
- #
- super_act.fixact()
-
-
-# Build a real panel from a panel definition.
-# Return a panel object p, where for each named actuator a, p.name is a
-# reference to a.
-#
-def build_panel(descr):
- #
- # Sanity check
- #
- if (not descr) or descr[0] != 'panel':
- raise panel_error, 'panel description must start with "panel"'
- #
- if debug: show_panel('', descr)
- #
- # Create an empty panel
- #
- panel = pnl.mkpanel()
- #
- # Assign panel attributes
- #
- assign_members(panel, descr[1:], ['al'], '')
- #
- # Look for actuator list
- #
- al = getattrlist(descr, 'al')
- #
- # The order in which actuators are created is important
- # because of the endgroup() operator.
- # Unfortunately the Panel Editor outputs the actuator list
- # in reverse order, so we reverse it here.
- #
- al = reverse(al)
- #
- for a in al:
- act, name = build_actuator(a)
- act.addact(panel)
- if name:
- stmt = 'panel.' + name + ' = act'
- exec stmt + '\n'
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- return panel
-
-
-# Wrapper around pnl.dopanel() which calls call-back functions.
-#
-def my_dopanel():
- # Extract only the first 4 elements to allow for future expansion
- a, down, active, up = pnl.dopanel()[:4]
- if down:
- down.downfunc(down)
- if active:
- active.activefunc(active)
- if up:
- up.upfunc(up)
- return a
-
-
-# Create one or more panels from a description file (S-expressions)
-# generated by the Panel Editor.
-#
-def defpanellist(file):
- import panelparser
- descrlist = panelparser.parse_file(open(file, 'r'))
- panellist = []
- for descr in descrlist:
- panellist.append(build_panel(descr))
- return panellist
-
-
-# Import everything from built-in method pnl, so the user can always
-# use panel.foo() instead of pnl.foo().
-# This gives *no* performance penalty once this module is imported.
-#
-from pnl import * # for export
-
-dopanel = my_dopanel # override pnl.dopanel
diff --git a/Lib/plat-irix5/panelparser.py b/Lib/plat-irix5/panelparser.py
deleted file mode 100644
index 362156d4c19..00000000000
--- a/Lib/plat-irix5/panelparser.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Module 'parser'
-#
-# Parse S-expressions output by the Panel Editor
-# (which is written in Scheme so it can't help writing S-expressions).
-#
-# See notes at end of file.
-from warnings import warnpy3k
-warnpy3k("the panelparser module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-
-whitespace = ' \t\n'
-operators = '()\''
-separators = operators + whitespace + ';' + '"'
-
-
-# Tokenize a string.
-# Return a list of tokens (strings).
-#
-def tokenize_string(s):
- tokens = []
- while s:
- c = s[:1]
- if c in whitespace:
- s = s[1:]
- elif c == ';':
- s = ''
- elif c == '"':
- n = len(s)
- i = 1
- while i < n:
- c = s[i]
- i = i+1
- if c == '"': break
- if c == '\\': i = i+1
- tokens.append(s[:i])
- s = s[i:]
- elif c in operators:
- tokens.append(c)
- s = s[1:]
- else:
- n = len(s)
- i = 1
- while i < n:
- if s[i] in separators: break
- i = i+1
- tokens.append(s[:i])
- s = s[i:]
- return tokens
-
-
-# Tokenize a whole file (given as file object, not as file name).
-# Return a list of tokens (strings).
-#
-def tokenize_file(fp):
- tokens = []
- while 1:
- line = fp.readline()
- if not line: break
- tokens = tokens + tokenize_string(line)
- return tokens
-
-
-# Exception raised by parse_exr.
-#
-syntax_error = 'syntax error'
-
-
-# Parse an S-expression.
-# Input is a list of tokens as returned by tokenize_*().
-# Return a pair (expr, tokens)
-# where expr is a list representing the s-expression,
-# and tokens contains the remaining tokens.
-# May raise syntax_error.
-#
-def parse_expr(tokens):
- if (not tokens) or tokens[0] != '(':
- raise syntax_error, 'expected "("'
- tokens = tokens[1:]
- expr = []
- while 1:
- if not tokens:
- raise syntax_error, 'missing ")"'
- if tokens[0] == ')':
- return expr, tokens[1:]
- elif tokens[0] == '(':
- subexpr, tokens = parse_expr(tokens)
- expr.append(subexpr)
- else:
- expr.append(tokens[0])
- tokens = tokens[1:]
-
-
-# Parse a file (given as file object, not as file name).
-# Return a list of parsed S-expressions found at the top level.
-#
-def parse_file(fp):
- tokens = tokenize_file(fp)
- exprlist = []
- while tokens:
- expr, tokens = parse_expr(tokens)
- exprlist.append(expr)
- return exprlist
-
-
-# EXAMPLE:
-#
-# The input
-# '(hip (hop hur-ray))'
-#
-# passed to tokenize_string() returns the token list
-# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
-#
-# When this is passed to parse_expr() it returns the expression
-# ['hip', ['hop', 'hur-ray']]
-# plus an empty token list (because there are no tokens left.
-#
-# When a file containing the example is passed to parse_file() it returns
-# a list whose only element is the output of parse_expr() above:
-# [['hip', ['hop', 'hur-ray']]]
-
-
-# TOKENIZING:
-#
-# Comments start with semicolon (;) and continue till the end of the line.
-#
-# Tokens are separated by whitespace, except the following characters
-# always form a separate token (outside strings):
-# ( ) '
-# Strings are enclosed in double quotes (") and backslash (\) is used
-# as escape character in strings.
diff --git a/Lib/plat-irix5/readcd.doc b/Lib/plat-irix5/readcd.doc
deleted file mode 100644
index 1be549c7904..00000000000
--- a/Lib/plat-irix5/readcd.doc
+++ /dev/null
@@ -1,104 +0,0 @@
-Interface to CD-ROM player.
-
-This module implements an interface to the built-in cd module. The
-intention is to provide a more user-friendly interface than the
-built-in module.
-
-The module defines a class Readcd with several methods. The
-initialization of the class will try to open the CD player. This
-means that initialization will fail if the CD player is already in
-use. A RuntimeError will be raised by the cd module in that case.
-
-The way to work with this module is as follows. The user specifies
-the parts of the CD that are to be read and he specifies callback
-functions which are to be called by the system. At some point he can
-tell the system to play. The specified parts of the CD will then be
-read and the callbacks will be called.
-
-Initialization.
-===============
-
-r = readcd.Readcd([cd-player [, mode]])
-
-The optional arguments are the name of the CD device and the mode.
-When "mode" is not specified, it defaults to 'r' (which is the only
-possible value); when "cd-player" also isn't specified, it defaults
-to "None" which indicates the default CD player.
-
-Methods.
-========
-
-eject() -- Eject the CD from the player.
-
-reset() -- Reset the list of data stretches to be played.
-
-appendtrack(track) -- Append the specified track to the list of music
-stretches.
-
-appendstretch(first, last) -- Append the stretch from "first" to "last"
-to the list of music stretches. Both "first" and "last" can be in one
-of four forms. "None": for "first", the beginning of the CD, for
-"last" the end of the CD; a single integer: a track number--playing
-starts at the beginning of the track or ends at the end of the
-specified track; a three-tuple: the absolute time from the start of
-the CD in minutes, seconds, frames; a four-tuple: track number and
-relative time within the track in minutes, seconds, frames.
-
-settracks(tracklist) -- The argument is a list of integers. The list
-of stretches is set to argument list. The old list is discarded.
-
-setcallback(type, func, arg) -- Set a callback function for "type".
-The function will be called as func(arg, type, data) where "arg" is
-the third argument of setcallback, "type" is the type of callback,
-"data" is type-dependent data. See the CDsetcallback(3) manual page
-for more information. The possible "type" arguments are defined in
-the CD module.
-
-removecallback(type) -- Remove the callback for "type".
-
-gettrackinfo([tracklist]) -- Return a list of tuples. Each tuple
-consists of start and length information of a track. The start and
-length information consist of three-tuples with minutes, seconds and
-frames. The optional tracklist argument gives a list of interesting
-track numbers. If no tracklist is specified, information about all
-tracks is returned.
-
-getstatus() -- Return the status information of the CD.
-
-play() -- Play the preprogrammed stretches of music from the CD. When
-nothing was programmed, the whole CD is played.
-
-Specifying stretches.
-=====================
-
-There are three methods available to specify a stretch of music to be
-played. The easiest way is to use "settracklist(tracklist)" with which
-a list of tracks can be specified. "settracklist(tracklist)" is
-equivalent to the sequence
- reset()
- for track in tracklist:
- appendtrack(track)
-
-The next method is "appendtrack(track)" with which a whole track can be
-added to the list of music to be played. "appendtrack(track)" is
-equivalent to "appendstretch(track, track)".
-
-The most complete method is "appendstretch(first, last)". Using this
-method, it is possible to specify any stretch of music.
-
-When two consecutive tracks are played, it is possible to choose
-whether the pause that may be between the tracks is played as well or
-whether the pause should be skipped. When the end of a stretch is
-specified using a track number and the next stretch starts at the
-beginning of the following track and that was also specified using the
-track number (that is, both were specified as integers, not as tuples),
-the pause is played. When either value was specified using absolute
-time or track-relative time (that is, as three-tuple or as
-four-tuple), the pause will not be played.
-
-Errors.
-=======
-
-When an error occurs, an exception will be raised. Depending on where
-the error occurs, the exception may either be "readcd.Error" or
-"RuntimeError".
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
deleted file mode 100644
index 54549e792cb..00000000000
--- a/Lib/plat-irix5/readcd.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# Class interface to the CD module.
-from warnings import warnpy3k
-warnpy3k("the readcd module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import cd, CD
-
-class Error(Exception):
- pass
-class _Stop(Exception):
- pass
-
-def _doatime(self, cb_type, data):
- if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
-
-def _dopnum(self, cb_type, data):
- if data > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
-
-class Readcd:
- def __init__(self, *arg):
- if len(arg) == 0:
- self.player = cd.open()
- elif len(arg) == 1:
- self.player = cd.open(arg[0])
- elif len(arg) == 2:
- self.player = cd.open(arg[0], arg[1])
- else:
- raise Error, 'bad __init__ call'
- self.list = []
- self.callbacks = [(None, None)] * 8
- self.parser = cd.createparser()
- self.playing = 0
- self.end = 0
- self.status = None
- self.trackinfo = None
-
- def eject(self):
- self.player.eject()
- self.list = []
- self.end = 0
- self.listindex = 0
- self.status = None
- self.trackinfo = None
- if self.playing:
-## print 'stop playing from eject'
- raise _Stop
-
- def pmsf2msf(self, track, min, sec, frame):
- if not self.status:
- self.cachestatus()
- if track < self.status[5] or track > self.status[6]:
- raise Error, 'track number out of range'
- if not self.trackinfo:
- self.cacheinfo()
- start, total = self.trackinfo[track]
- start = ((start[0] * 60) + start[1]) * 75 + start[2]
- total = ((total[0] * 60) + total[1]) * 75 + total[2]
- block = ((min * 60) + sec) * 75 + frame
- if block > total:
- raise Error, 'out of range'
- block = start + block
- min, block = divmod(block, 75*60)
- sec, frame = divmod(block, 75)
- return min, sec, frame
-
- def reset(self):
- self.list = []
-
- def appendtrack(self, track):
- self.appendstretch(track, track)
-
- def appendstretch(self, start, end):
- if not self.status:
- self.cachestatus()
- if not start:
- start = 1
- if not end:
- end = self.status[6]
- if type(end) == type(0):
- if end < self.status[5] or end > self.status[6]:
- raise Error, 'range error'
- else:
- l = len(end)
- if l == 4:
- prog, min, sec, frame = end
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- end = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- if type(start) == type(0):
- if start < self.status[5] or start > self.status[6]:
- raise Error, 'range error'
- if len(self.list) > 0:
- s, e = self.list[-1]
- if type(e) == type(0):
- if start == e+1:
- start = s
- del self.list[-1]
- else:
- l = len(start)
- if l == 4:
- prog, min, sec, frame = start
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- start = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- self.list.append((start, end))
-
- def settracks(self, list):
- self.list = []
- for track in list:
- self.appendtrack(track)
-
- def setcallback(self, cb_type, func, arg):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (func, arg)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.setcallback(cb_type, func, arg)
- else:
- if cb_type != CD.ATIME:
- self.parser.setcallback(cb_type, func, arg)
-
- def removecallback(self, cb_type):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (None, None)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.removecallback(cb_type)
- else:
- if cb_type != CD.ATIME:
- self.parser.removecallback(cb_type)
-
- def gettrackinfo(self, *arg):
- if not self.status:
- self.cachestatus()
- if not self.trackinfo:
- self.cacheinfo()
- if len(arg) == 0:
- return self.trackinfo[self.status[5]:self.status[6]+1]
- result = []
- for i in arg:
- if i < self.status[5] or i > self.status[6]:
- raise Error, 'range error'
- result.append(self.trackinfo[i])
- return result
-
- def cacheinfo(self):
- if not self.status:
- self.cachestatus()
- self.trackinfo = []
- for i in range(self.status[5]):
- self.trackinfo.append(None)
- for i in range(self.status[5], self.status[6]+1):
- self.trackinfo.append(self.player.gettrackinfo(i))
-
- def cachestatus(self):
- self.status = self.player.getstatus()
- if self.status[0] == CD.NODISC:
- self.status = None
- raise Error, 'no disc in player'
-
- def getstatus(self):
- return self.player.getstatus()
-
- def play(self):
- if not self.status:
- self.cachestatus()
- size = self.player.bestreadsize()
- self.listindex = 0
- self.playing = 0
- for i in range(8):
- func, arg = self.callbacks[i]
- if func:
- self.parser.setcallback(i, func, arg)
- else:
- self.parser.removecallback(i)
- if len(self.list) == 0:
- for i in range(self.status[5], self.status[6]+1):
- self.appendtrack(i)
- try:
- while 1:
- if not self.playing:
- if self.listindex >= len(self.list):
- return
- start, end = self.list[self.listindex]
- if type(start) == type(0):
- dummy = self.player.seektrack(
- start)
- else:
- min, sec, frame = start
- dummy = self.player.seek(
- min, sec, frame)
- if type(end) == type(0):
- self.parser.setcallback(
- CD.PNUM, _dopnum, self)
- self.end = end
- func, arg = \
- self.callbacks[CD.ATIME]
- if func:
- self.parser.setcallback(CD.ATIME, func, arg)
- else:
- self.parser.removecallback(CD.ATIME)
- else:
- min, sec, frame = end
- self.parser.setcallback(
- CD.ATIME, _doatime,
- self)
- self.end = (min * 60 + sec) * \
- 75 + frame
- func, arg = \
- self.callbacks[CD.PNUM]
- if func:
- self.parser.setcallback(CD.PNUM, func, arg)
- else:
- self.parser.removecallback(CD.PNUM)
- self.playing = 1
- data = self.player.readda(size)
- if data == '':
- self.playing = 0
- self.listindex = self.listindex + 1
- continue
- try:
- self.parser.parseframe(data)
- except _Stop:
- self.playing = 0
- self.listindex = self.listindex + 1
- finally:
- self.playing = 0
diff --git a/Lib/plat-irix5/regen b/Lib/plat-irix5/regen
deleted file mode 100755
index c950a475ca6..00000000000
--- a/Lib/plat-irix5/regen
+++ /dev/null
@@ -1,10 +0,0 @@
-#! /bin/sh
-case `uname -sr` in
-'IRIX '[45].*) ;;
-*) echo Probably not on an IRIX system 1>&2
- exit 1;;
-esac
-set -v
-h2py /usr/include/sys/file.h
-h2py -i '(u_long)' /usr/include/netinet/in.h
-h2py /usr/include/errno.h
diff --git a/Lib/plat-irix5/torgb.py b/Lib/plat-irix5/torgb.py
deleted file mode 100644
index 024d1ea4889..00000000000
--- a/Lib/plat-irix5/torgb.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# Convert "arbitrary" image files to rgb files (SGI's image format).
-# Input may be compressed.
-# The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster.
-# An exception is raised if the file is not of a recognized type.
-# Returned filename is either the input filename or a temporary filename;
-# in the latter case the caller must ensure that it is removed.
-# Other temporary files used are removed by the function.
-from warnings import warnpy3k
-warnpy3k("the torgb module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-import tempfile
-import pipes
-import imghdr
-
-table = {}
-
-t = pipes.Template()
-t.append('fromppm $IN $OUT', 'ff')
-table['ppm'] = t
-
-t = pipes.Template()
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['pnm'] = t
-table['pgm'] = t
-table['pbm'] = t
-
-t = pipes.Template()
-t.append('fromgif $IN $OUT', 'ff')
-table['gif'] = t
-
-t = pipes.Template()
-t.append('tifftopnm', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['tiff'] = t
-
-t = pipes.Template()
-t.append('rasttopnm', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['rast'] = t
-
-t = pipes.Template()
-t.append('djpeg', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['jpeg'] = t
-
-uncompress = pipes.Template()
-uncompress.append('uncompress', '--')
-
-
-class error(Exception):
- pass
-
-def torgb(filename):
- temps = []
- ret = None
- try:
- ret = _torgb(filename, temps)
- finally:
- for temp in temps[:]:
- if temp != ret:
- try:
- os.unlink(temp)
- except os.error:
- pass
- temps.remove(temp)
- return ret
-
-def _torgb(filename, temps):
- if filename[-2:] == '.Z':
- (fd, fname) = tempfile.mkstemp()
- os.close(fd)
- temps.append(fname)
- sts = uncompress.copy(filename, fname)
- if sts:
- raise error, filename + ': uncompress failed'
- else:
- fname = filename
- try:
- ftype = imghdr.what(fname)
- except IOError, msg:
- if type(msg) == type(()) and len(msg) == 2 and \
- type(msg[0]) == type(0) and type(msg[1]) == type(''):
- msg = msg[1]
- if type(msg) is not type(''):
- msg = repr(msg)
- raise error, filename + ': ' + msg
- if ftype == 'rgb':
- return fname
- if ftype is None or not table.has_key(ftype):
- raise error, '%s: unsupported image file type %r' % (filename, ftype)
- (fd, temp) = tempfile.mkstemp()
- os.close(fd)
- sts = table[ftype].copy(fname, temp)
- if sts:
- raise error, filename + ': conversion to rgb failed'
- return temp
diff --git a/Lib/plat-irix6/AL.py b/Lib/plat-irix6/AL.py
deleted file mode 100644
index 3b43d2c8bc6..00000000000
--- a/Lib/plat-irix6/AL.py
+++ /dev/null
@@ -1,65 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the AL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-RATE_48000 = 48000
-RATE_44100 = 44100
-RATE_32000 = 32000
-RATE_22050 = 22050
-RATE_16000 = 16000
-RATE_11025 = 11025
-RATE_8000 = 8000
-
-SAMPFMT_TWOSCOMP= 1
-SAMPFMT_FLOAT = 32
-SAMPFMT_DOUBLE = 64
-
-SAMPLE_8 = 1
-SAMPLE_16 = 2
- # SAMPLE_24 is the low 24 bits of a long, sign extended to 32 bits
-SAMPLE_24 = 4
-
-MONO = 1
-STEREO = 2
-QUADRO = 4 # 4CHANNEL is not a legal Python name
-
-INPUT_LINE = 0
-INPUT_MIC = 1
-INPUT_DIGITAL = 2
-
-MONITOR_OFF = 0
-MONITOR_ON = 1
-
-ERROR_NUMBER = 0
-ERROR_TYPE = 1
-ERROR_LOCATION_LSP = 2
-ERROR_LOCATION_MSP = 3
-ERROR_LENGTH = 4
-
-ERROR_INPUT_UNDERFLOW = 0
-ERROR_OUTPUT_OVERFLOW = 1
-
-# These seem to be not supported anymore:
-##HOLD, RELEASE = 0, 1
-##ATTAIL, ATHEAD, ATMARK, ATTIME = 0, 1, 2, 3
-
-DEFAULT_DEVICE = 1
-
-INPUT_SOURCE = 0
-LEFT_INPUT_ATTEN = 1
-RIGHT_INPUT_ATTEN = 2
-INPUT_RATE = 3
-OUTPUT_RATE = 4
-LEFT_SPEAKER_GAIN = 5
-RIGHT_SPEAKER_GAIN = 6
-INPUT_COUNT = 7
-OUTPUT_COUNT = 8
-UNUSED_COUNT = 9
-SYNC_INPUT_TO_AES = 10
-SYNC_OUTPUT_TO_AES = 11
-MONITOR_CTL = 12
-LEFT_MONITOR_ATTEN = 13
-RIGHT_MONITOR_ATTEN = 14
-
-ENUM_VALUE = 0 # only certain values are valid
-RANGE_VALUE = 1 # any value in range is valid
diff --git a/Lib/plat-irix6/CD.py b/Lib/plat-irix6/CD.py
deleted file mode 100644
index 5398f4656cd..00000000000
--- a/Lib/plat-irix6/CD.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the CD module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-ERROR = 0
-NODISC = 1
-READY = 2
-PLAYING = 3
-PAUSED = 4
-STILL = 5
-
-AUDIO = 0
-PNUM = 1
-INDEX = 2
-PTIME = 3
-ATIME = 4
-CATALOG = 5
-IDENT = 6
-CONTROL = 7
-
-CDDA_DATASIZE = 2352
-
-##CDDA_SUBCODESIZE = (sizeof(struct subcodeQ))
-##CDDA_BLOCKSIZE = (sizeof(struct cdframe))
-##CDDA_NUMSAMPLES = (CDDA_DATASIZE/2)
-##
-##CDQ_PREEMP_MASK = 0xd
-##CDQ_COPY_MASK = 0xb
-##CDQ_DDATA_MASK = 0xd
-##CDQ_BROADCAST_MASK = 0x8
-##CDQ_PREEMPHASIS = 0x1
-##CDQ_COPY_PERMITTED = 0x2
-##CDQ_DIGITAL_DATA = 0x4
-##CDQ_BROADCAST_USE = 0x8
-##
-##CDQ_MODE1 = 0x1
-##CDQ_MODE2 = 0x2
-##CDQ_MODE3 = 0x3
diff --git a/Lib/plat-irix6/CL.py b/Lib/plat-irix6/CL.py
deleted file mode 100644
index 15130e4306e..00000000000
--- a/Lib/plat-irix6/CL.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Backward compatible module CL.
-# All relevant symbols are now defined in the module cl.
-from warnings import warnpy3k
-warnpy3k("the CL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-try:
- from cl import *
-except ImportError:
- from CL_old import *
-else:
- del CompressImage
- del DecompressImage
- del GetAlgorithmName
- del OpenCompressor
- del OpenDecompressor
- del QueryAlgorithms
- del QueryMaxHeaderSize
- del QueryScheme
- del QuerySchemeFromName
- del SetDefault
- del SetMax
- del SetMin
- try:
- del cvt_type
- except NameError:
- pass
- del error
diff --git a/Lib/plat-irix6/DEVICE.py b/Lib/plat-irix6/DEVICE.py
deleted file mode 100644
index 14fd5347b96..00000000000
--- a/Lib/plat-irix6/DEVICE.py
+++ /dev/null
@@ -1,404 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the DEVICE module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NULLDEV = 0
-BUTOFFSET = 1
-VALOFFSET = 256
-PSEUDOFFSET = 512
-BUT2OFFSET = 3840
-TIMOFFSET = 515
-XKBDOFFSET = 143
-BUTCOUNT = 255
-VALCOUNT = 256
-TIMCOUNT = 4
-XKBDCOUNT = 28
-USERBUTOFFSET = 4096
-USERVALOFFSET = 12288
-USERPSEUDOFFSET = 16384
-BUT0 = 1
-BUT1 = 2
-BUT2 = 3
-BUT3 = 4
-BUT4 = 5
-BUT5 = 6
-BUT6 = 7
-BUT7 = 8
-BUT8 = 9
-BUT9 = 10
-BUT10 = 11
-BUT11 = 12
-BUT12 = 13
-BUT13 = 14
-BUT14 = 15
-BUT15 = 16
-BUT16 = 17
-BUT17 = 18
-BUT18 = 19
-BUT19 = 20
-BUT20 = 21
-BUT21 = 22
-BUT22 = 23
-BUT23 = 24
-BUT24 = 25
-BUT25 = 26
-BUT26 = 27
-BUT27 = 28
-BUT28 = 29
-BUT29 = 30
-BUT30 = 31
-BUT31 = 32
-BUT32 = 33
-BUT33 = 34
-BUT34 = 35
-BUT35 = 36
-BUT36 = 37
-BUT37 = 38
-BUT38 = 39
-BUT39 = 40
-BUT40 = 41
-BUT41 = 42
-BUT42 = 43
-BUT43 = 44
-BUT44 = 45
-BUT45 = 46
-BUT46 = 47
-BUT47 = 48
-BUT48 = 49
-BUT49 = 50
-BUT50 = 51
-BUT51 = 52
-BUT52 = 53
-BUT53 = 54
-BUT54 = 55
-BUT55 = 56
-BUT56 = 57
-BUT57 = 58
-BUT58 = 59
-BUT59 = 60
-BUT60 = 61
-BUT61 = 62
-BUT62 = 63
-BUT63 = 64
-BUT64 = 65
-BUT65 = 66
-BUT66 = 67
-BUT67 = 68
-BUT68 = 69
-BUT69 = 70
-BUT70 = 71
-BUT71 = 72
-BUT72 = 73
-BUT73 = 74
-BUT74 = 75
-BUT75 = 76
-BUT76 = 77
-BUT77 = 78
-BUT78 = 79
-BUT79 = 80
-BUT80 = 81
-BUT81 = 82
-BUT82 = 83
-MAXKBDBUT = 83
-BUT100 = 101
-BUT101 = 102
-BUT102 = 103
-BUT103 = 104
-BUT104 = 105
-BUT105 = 106
-BUT106 = 107
-BUT107 = 108
-BUT108 = 109
-BUT109 = 110
-BUT110 = 111
-BUT111 = 112
-BUT112 = 113
-BUT113 = 114
-BUT114 = 115
-BUT115 = 116
-BUT116 = 117
-BUT117 = 118
-BUT118 = 119
-BUT119 = 120
-BUT120 = 121
-BUT121 = 122
-BUT122 = 123
-BUT123 = 124
-BUT124 = 125
-BUT125 = 126
-BUT126 = 127
-BUT127 = 128
-BUT128 = 129
-BUT129 = 130
-BUT130 = 131
-BUT131 = 132
-BUT132 = 133
-BUT133 = 134
-BUT134 = 135
-BUT135 = 136
-BUT136 = 137
-BUT137 = 138
-BUT138 = 139
-BUT139 = 140
-BUT140 = 141
-BUT141 = 142
-BUT142 = 143
-BUT143 = 144
-BUT144 = 145
-BUT145 = 146
-BUT146 = 147
-BUT147 = 148
-BUT148 = 149
-BUT149 = 150
-BUT150 = 151
-BUT151 = 152
-BUT152 = 153
-BUT153 = 154
-BUT154 = 155
-BUT155 = 156
-BUT156 = 157
-BUT157 = 158
-BUT158 = 159
-BUT159 = 160
-BUT160 = 161
-BUT161 = 162
-BUT162 = 163
-BUT163 = 164
-BUT164 = 165
-BUT165 = 166
-BUT166 = 167
-BUT167 = 168
-BUT168 = 169
-BUT181 = 182
-BUT182 = 183
-BUT183 = 184
-BUT184 = 185
-BUT185 = 186
-BUT186 = 187
-BUT187 = 188
-BUT188 = 189
-BUT189 = 190
-MOUSE1 = 101
-MOUSE2 = 102
-MOUSE3 = 103
-LEFTMOUSE = 103
-MIDDLEMOUSE = 102
-RIGHTMOUSE = 101
-LPENBUT = 104
-BPAD0 = 105
-BPAD1 = 106
-BPAD2 = 107
-BPAD3 = 108
-LPENVALID = 109
-SWBASE = 111
-SW0 = 111
-SW1 = 112
-SW2 = 113
-SW3 = 114
-SW4 = 115
-SW5 = 116
-SW6 = 117
-SW7 = 118
-SW8 = 119
-SW9 = 120
-SW10 = 121
-SW11 = 122
-SW12 = 123
-SW13 = 124
-SW14 = 125
-SW15 = 126
-SW16 = 127
-SW17 = 128
-SW18 = 129
-SW19 = 130
-SW20 = 131
-SW21 = 132
-SW22 = 133
-SW23 = 134
-SW24 = 135
-SW25 = 136
-SW26 = 137
-SW27 = 138
-SW28 = 139
-SW29 = 140
-SW30 = 141
-SW31 = 142
-SBBASE = 182
-SBPICK = 182
-SBBUT1 = 183
-SBBUT2 = 184
-SBBUT3 = 185
-SBBUT4 = 186
-SBBUT5 = 187
-SBBUT6 = 188
-SBBUT7 = 189
-SBBUT8 = 190
-AKEY = 11
-BKEY = 36
-CKEY = 28
-DKEY = 18
-EKEY = 17
-FKEY = 19
-GKEY = 26
-HKEY = 27
-IKEY = 40
-JKEY = 34
-KKEY = 35
-LKEY = 42
-MKEY = 44
-NKEY = 37
-OKEY = 41
-PKEY = 48
-QKEY = 10
-RKEY = 24
-SKEY = 12
-TKEY = 25
-UKEY = 33
-VKEY = 29
-WKEY = 16
-XKEY = 21
-YKEY = 32
-ZKEY = 20
-ZEROKEY = 46
-ONEKEY = 8
-TWOKEY = 14
-THREEKEY = 15
-FOURKEY = 22
-FIVEKEY = 23
-SIXKEY = 30
-SEVENKEY = 31
-EIGHTKEY = 38
-NINEKEY = 39
-BREAKKEY = 1
-SETUPKEY = 2
-CTRLKEY = 3
-LEFTCTRLKEY = CTRLKEY
-CAPSLOCKKEY = 4
-RIGHTSHIFTKEY = 5
-LEFTSHIFTKEY = 6
-NOSCRLKEY = 13
-ESCKEY = 7
-TABKEY = 9
-RETKEY = 51
-SPACEKEY = 83
-LINEFEEDKEY = 60
-BACKSPACEKEY = 61
-DELKEY = 62
-SEMICOLONKEY = 43
-PERIODKEY = 52
-COMMAKEY = 45
-QUOTEKEY = 50
-ACCENTGRAVEKEY = 55
-MINUSKEY = 47
-VIRGULEKEY = 53
-BACKSLASHKEY = 57
-EQUALKEY = 54
-LEFTBRACKETKEY = 49
-RIGHTBRACKETKEY = 56
-LEFTARROWKEY = 73
-DOWNARROWKEY = 74
-RIGHTARROWKEY = 80
-UPARROWKEY = 81
-PAD0 = 59
-PAD1 = 58
-PAD2 = 64
-PAD3 = 65
-PAD4 = 63
-PAD5 = 69
-PAD6 = 70
-PAD7 = 67
-PAD8 = 68
-PAD9 = 75
-PADPF1 = 72
-PADPF2 = 71
-PADPF3 = 79
-PADPF4 = 78
-PADPERIOD = 66
-PADMINUS = 76
-PADCOMMA = 77
-PADENTER = 82
-LEFTALTKEY = 143
-RIGHTALTKEY = 144
-RIGHTCTRLKEY = 145
-F1KEY = 146
-F2KEY = 147
-F3KEY = 148
-F4KEY = 149
-F5KEY = 150
-F6KEY = 151
-F7KEY = 152
-F8KEY = 153
-F9KEY = 154
-F10KEY = 155
-F11KEY = 156
-F12KEY = 157
-PRINTSCREENKEY = 158
-SCROLLLOCKKEY = 159
-PAUSEKEY = 160
-INSERTKEY = 161
-HOMEKEY = 162
-PAGEUPKEY = 163
-ENDKEY = 164
-PAGEDOWNKEY = 165
-NUMLOCKKEY = 166
-PADVIRGULEKEY = 167
-PADASTERKEY = 168
-PADPLUSKEY = 169
-SGIRESERVED = 256
-DIAL0 = 257
-DIAL1 = 258
-DIAL2 = 259
-DIAL3 = 260
-DIAL4 = 261
-DIAL5 = 262
-DIAL6 = 263
-DIAL7 = 264
-DIAL8 = 265
-MOUSEX = 266
-MOUSEY = 267
-LPENX = 268
-LPENY = 269
-BPADX = 270
-BPADY = 271
-CURSORX = 272
-CURSORY = 273
-GHOSTX = 274
-GHOSTY = 275
-SBTX = 276
-SBTY = 277
-SBTZ = 278
-SBRX = 279
-SBRY = 280
-SBRZ = 281
-SBPERIOD = 282
-TIMER0 = 515
-TIMER1 = 516
-TIMER2 = 517
-TIMER3 = 518
-KEYBD = 513
-RAWKEYBD = 514
-VALMARK = 523
-REDRAW = 528
-INPUTCHANGE = 534
-QFULL = 535
-QREADERROR = 538
-WINFREEZE = 539
-WINTHAW = 540
-REDRAWICONIC = 541
-WINQUIT = 542
-DEPTHCHANGE = 543
-WINSHUT = 546
-DRAWOVERLAY = 547
-VIDEO = 548
-MENUBUTTON = RIGHTMOUSE
-WINCLOSE = 537
-KEYBDFNAMES = 544
-KEYBDFSTRINGS = 545
-MAXSGIDEVICE = 20000
-GERROR = 524
-WMSEND = 529
-WMREPLY = 530
-WMGFCLOSE = 531
-WMTXCLOSE = 532
-MODECHANGE = 533
-PIECECHANGE = 536
diff --git a/Lib/plat-irix6/ERRNO.py b/Lib/plat-irix6/ERRNO.py
deleted file mode 100644
index ec8720a5335..00000000000
--- a/Lib/plat-irix6/ERRNO.py
+++ /dev/null
@@ -1,183 +0,0 @@
-# Generated by h2py from /usr/include/errno.h
-from warnings import warnpy3k
-warnpy3k("the ERRNO module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from sys/errno.h
-
-# Included from standards.h
-__KBASE = 1000
-__IRIXBASE = 1000
-__FTNBASE = 4000
-__FTNLAST = 5999
-EPERM = 1
-ENOENT = 2
-ESRCH = 3
-EINTR = 4
-EIO = 5
-ENXIO = 6
-E2BIG = 7
-ENOEXEC = 8
-EBADF = 9
-ECHILD = 10
-EAGAIN = 11
-ENOMEM = 12
-EACCES = 13
-EFAULT = 14
-ENOTBLK = 15
-EBUSY = 16
-EEXIST = 17
-EXDEV = 18
-ENODEV = 19
-ENOTDIR = 20
-EISDIR = 21
-EINVAL = 22
-ENFILE = 23
-EMFILE = 24
-ENOTTY = 25
-ETXTBSY = 26
-EFBIG = 27
-ENOSPC = 28
-ESPIPE = 29
-EROFS = 30
-EMLINK = 31
-EPIPE = 32
-EDOM = 33
-ERANGE = 34
-ENOMSG = 35
-EIDRM = 36
-ECHRNG = 37
-EL2NSYNC = 38
-EL3HLT = 39
-EL3RST = 40
-ELNRNG = 41
-EUNATCH = 42
-ENOCSI = 43
-EL2HLT = 44
-EDEADLK = 45
-ENOLCK = 46
-ECKPT = 47
-EBADE = 50
-EBADR = 51
-EXFULL = 52
-ENOANO = 53
-EBADRQC = 54
-EBADSLT = 55
-EDEADLOCK = 56
-EBFONT = 57
-ENOSTR = 60
-ENODATA = 61
-ETIME = 62
-ENOSR = 63
-ENONET = 64
-ENOPKG = 65
-EREMOTE = 66
-ENOLINK = 67
-EADV = 68
-ESRMNT = 69
-ECOMM = 70
-EPROTO = 71
-EMULTIHOP = 74
-EBADMSG = 77
-ENAMETOOLONG = 78
-EOVERFLOW = 79
-ENOTUNIQ = 80
-EBADFD = 81
-EREMCHG = 82
-ELIBACC = 83
-ELIBBAD = 84
-ELIBSCN = 85
-ELIBMAX = 86
-ELIBEXEC = 87
-EILSEQ = 88
-ENOSYS = 89
-ELOOP = 90
-ERESTART = 91
-ESTRPIPE = 92
-ENOTEMPTY = 93
-EUSERS = 94
-ENOTSOCK = 95
-EDESTADDRREQ = 96
-EMSGSIZE = 97
-EPROTOTYPE = 98
-ENOPROTOOPT = 99
-EPROTONOSUPPORT = 120
-ESOCKTNOSUPPORT = 121
-EOPNOTSUPP = 122
-EPFNOSUPPORT = 123
-EAFNOSUPPORT = 124
-EADDRINUSE = 125
-EADDRNOTAVAIL = 126
-ENETDOWN = 127
-ENETUNREACH = 128
-ENETRESET = 129
-ECONNABORTED = 130
-ECONNRESET = 131
-ENOBUFS = 132
-EISCONN = 133
-ENOTCONN = 134
-ESHUTDOWN = 143
-ETOOMANYREFS = 144
-ETIMEDOUT = 145
-ECONNREFUSED = 146
-EHOSTDOWN = 147
-EHOSTUNREACH = 148
-LASTERRNO = ENOTCONN
-EWOULDBLOCK = __KBASE+101
-EWOULDBLOCK = EAGAIN
-EALREADY = 149
-EINPROGRESS = 150
-ESTALE = 151
-EIORESID = 500
-EUCLEAN = 135
-ENOTNAM = 137
-ENAVAIL = 138
-EISNAM = 139
-EREMOTEIO = 140
-EINIT = 141
-EREMDEV = 142
-ECANCELED = 158
-ENOLIMFILE = 1001
-EPROCLIM = 1002
-EDISJOINT = 1003
-ENOLOGIN = 1004
-ELOGINLIM = 1005
-EGROUPLOOP = 1006
-ENOATTACH = 1007
-ENOTSUP = 1008
-ENOATTR = 1009
-EFSCORRUPTED = 1010
-EDIRCORRUPTED = 1010
-EWRONGFS = 1011
-EDQUOT = 1133
-ENFSREMOTE = 1135
-ECONTROLLER = 1300
-ENOTCONTROLLER = 1301
-EENQUEUED = 1302
-ENOTENQUEUED = 1303
-EJOINED = 1304
-ENOTJOINED = 1305
-ENOPROC = 1306
-EMUSTRUN = 1307
-ENOTSTOPPED = 1308
-ECLOCKCPU = 1309
-EINVALSTATE = 1310
-ENOEXIST = 1311
-EENDOFMINOR = 1312
-EBUFSIZE = 1313
-EEMPTY = 1314
-ENOINTRGROUP = 1315
-EINVALMODE = 1316
-ECANTEXTENT = 1317
-EINVALTIME = 1318
-EDESTROYED = 1319
-EBDHDL = 1400
-EDELAY = 1401
-ENOBWD = 1402
-EBADRSPEC = 1403
-EBADTSPEC = 1404
-EBADFILT = 1405
-EMIGRATED = 1500
-EMIGRATING = 1501
-ECELLDOWN = 1502
-EMEMRETRY = 1600
diff --git a/Lib/plat-irix6/FILE.py b/Lib/plat-irix6/FILE.py
deleted file mode 100644
index 3376c7103ed..00000000000
--- a/Lib/plat-irix6/FILE.py
+++ /dev/null
@@ -1,677 +0,0 @@
-# Generated by h2py from /usr/include/sys/file.h
-from warnings import warnpy3k
-warnpy3k("the FILE module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from standards.h
-
-# Included from sys/types.h
-
-# Included from sgidefs.h
-_MIPS_ISA_MIPS1 = 1
-_MIPS_ISA_MIPS2 = 2
-_MIPS_ISA_MIPS3 = 3
-_MIPS_ISA_MIPS4 = 4
-_MIPS_SIM_ABI32 = 1
-_MIPS_SIM_NABI32 = 2
-_MIPS_SIM_ABI64 = 3
-
-# Included from sys/pthread.h
-P_MYID = (-1)
-P_MYHOSTID = (-1)
-
-# Included from sys/bsd_types.h
-
-# Included from sys/mkdev.h
-ONBITSMAJOR = 7
-ONBITSMINOR = 8
-OMAXMAJ = 0x7f
-OMAXMIN = 0xff
-NBITSMAJOR = 14
-NBITSMINOR = 18
-MAXMAJ = 0x1ff
-MAXMIN = 0x3ffff
-OLDDEV = 0
-NEWDEV = 1
-MKDEV_VER = NEWDEV
-def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0))
-
-def major(dev): return __major(MKDEV_VER, dev)
-
-def minor(dev): return __minor(MKDEV_VER, dev)
-
-
-# Included from sys/select.h
-FD_SETSIZE = 1024
-__NBBY = 8
-
-# Included from string.h
-NULL = 0L
-NBBY = 8
-
-# Included from sys/cpumask.h
-MAXCPU = 128
-def CPUMASK_INDEX(bit): return ((bit) >> 6)
-
-def CPUMASK_SHFT(bit): return ((bit) & 0x3f)
-
-def CPUMASK_IS_ZERO(p): return ((p) == 0)
-
-def CPUMASK_IS_NONZERO(p): return ((p) != 0)
-
-
-# Included from sys/nodemask.h
-def CNODEMASK_IS_ZERO(p): return ((p) == 0)
-
-def CNODEMASK_IS_NONZERO(p): return ((p) != 0)
-
-
-# Included from sys/sema.h
-
-# Included from sys/timespec.h
-
-# Included from sys/param.h
-
-# Included from sys/signal.h
-SIGHUP = 1
-SIGINT = 2
-SIGQUIT = 3
-SIGILL = 4
-SIGTRAP = 5
-SIGIOT = 6
-SIGABRT = 6
-SIGEMT = 7
-SIGFPE = 8
-SIGKILL = 9
-SIGBUS = 10
-SIGSEGV = 11
-SIGSYS = 12
-SIGPIPE = 13
-SIGALRM = 14
-SIGTERM = 15
-SIGUSR1 = 16
-SIGUSR2 = 17
-SIGCLD = 18
-SIGCHLD = 18
-SIGPWR = 19
-SIGWINCH = 20
-SIGURG = 21
-SIGPOLL = 22
-SIGIO = 22
-SIGSTOP = 23
-SIGTSTP = 24
-SIGCONT = 25
-SIGTTIN = 26
-SIGTTOU = 27
-SIGVTALRM = 28
-SIGPROF = 29
-SIGXCPU = 30
-SIGXFSZ = 31
-SIGK32 = 32
-SIGCKPT = 33
-SIGRESTART = 34
-SIGUME = 35
-SIGPTINTR = 47
-SIGPTRESCHED = 48
-SIGRTMIN = 49
-SIGRTMAX = 64
-__sigargs = int
-
-# Included from sys/sigevent.h
-SIGEV_NONE = 128
-SIGEV_SIGNAL = 129
-SIGEV_CALLBACK = 130
-SIGEV_THREAD = 131
-
-# Included from sys/siginfo.h
-SI_MAXSZ = 128
-SI_USER = 0
-SI_KILL = SI_USER
-SI_QUEUE = -1
-SI_ASYNCIO = -2
-SI_TIMER = -3
-SI_MESGQ = -4
-ILL_ILLOPC = 1
-ILL_ILLOPN = 2
-ILL_ILLADR = 3
-ILL_ILLTRP = 4
-ILL_PRVOPC = 5
-ILL_PRVREG = 6
-ILL_COPROC = 7
-ILL_BADSTK = 8
-NSIGILL = 8
-FPE_INTDIV = 1
-FPE_INTOVF = 2
-FPE_FLTDIV = 3
-FPE_FLTOVF = 4
-FPE_FLTUND = 5
-FPE_FLTRES = 6
-FPE_FLTINV = 7
-FPE_FLTSUB = 8
-NSIGFPE = 8
-SEGV_MAPERR = 1
-SEGV_ACCERR = 2
-NSIGSEGV = 2
-BUS_ADRALN = 1
-BUS_ADRERR = 2
-BUS_OBJERR = 3
-NSIGBUS = 3
-TRAP_BRKPT = 1
-TRAP_TRACE = 2
-NSIGTRAP = 2
-CLD_EXITED = 1
-CLD_KILLED = 2
-CLD_DUMPED = 3
-CLD_TRAPPED = 4
-CLD_STOPPED = 5
-CLD_CONTINUED = 6
-NSIGCLD = 6
-POLL_IN = 1
-POLL_OUT = 2
-POLL_MSG = 3
-POLL_ERR = 4
-POLL_PRI = 5
-POLL_HUP = 6
-NSIGPOLL = 6
-UME_ECCERR = 1
-NSIGUME = 1
-SIG_NOP = 0
-SIG_BLOCK = 1
-SIG_UNBLOCK = 2
-SIG_SETMASK = 3
-SIG_SETMASK32 = 256
-SA_ONSTACK = 0x00000001
-SA_RESETHAND = 0x00000002
-SA_RESTART = 0x00000004
-SA_SIGINFO = 0x00000008
-SA_NODEFER = 0x00000010
-SA_NOCLDWAIT = 0x00010000
-SA_NOCLDSTOP = 0x00020000
-_SA_BSDCALL = 0x10000000
-MINSIGSTKSZ = 512
-SIGSTKSZ = 8192
-SS_ONSTACK = 0x00000001
-SS_DISABLE = 0x00000002
-
-# Included from sys/ucontext.h
-NGREG = 36
-NGREG = 37
-GETCONTEXT = 0
-SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
-UC_MCONTEXT = (UC_CPU|UC_MAU)
-UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
-CTX_R0 = 0
-CTX_AT = 1
-CTX_V0 = 2
-CTX_V1 = 3
-CTX_A0 = 4
-CTX_A1 = 5
-CTX_A2 = 6
-CTX_A3 = 7
-CTX_T0 = 8
-CTX_T1 = 9
-CTX_T2 = 10
-CTX_T3 = 11
-CTX_T4 = 12
-CTX_T5 = 13
-CTX_T6 = 14
-CTX_T7 = 15
-CTX_A4 = 8
-CTX_A5 = 9
-CTX_A6 = 10
-CTX_A7 = 11
-CTX_T0 = 12
-CTX_T1 = 13
-CTX_T2 = 14
-CTX_T3 = 15
-CTX_S0 = 16
-CTX_S1 = 17
-CTX_S2 = 18
-CTX_S3 = 19
-CTX_S4 = 20
-CTX_S5 = 21
-CTX_S6 = 22
-CTX_S7 = 23
-CTX_T8 = 24
-CTX_T9 = 25
-CTX_K0 = 26
-CTX_K1 = 27
-CTX_GP = 28
-CTX_SP = 29
-CTX_S8 = 30
-CTX_RA = 31
-CTX_MDLO = 32
-CTX_MDHI = 33
-CTX_CAUSE = 34
-CTX_EPC = 35
-CTX_SR = 36
-CXT_R0 = CTX_R0
-CXT_AT = CTX_AT
-CXT_V0 = CTX_V0
-CXT_V1 = CTX_V1
-CXT_A0 = CTX_A0
-CXT_A1 = CTX_A1
-CXT_A2 = CTX_A2
-CXT_A3 = CTX_A3
-CXT_T0 = CTX_T0
-CXT_T1 = CTX_T1
-CXT_T2 = CTX_T2
-CXT_T3 = CTX_T3
-CXT_T4 = CTX_T4
-CXT_T5 = CTX_T5
-CXT_T6 = CTX_T6
-CXT_T7 = CTX_T7
-CXT_S0 = CTX_S0
-CXT_S1 = CTX_S1
-CXT_S2 = CTX_S2
-CXT_S3 = CTX_S3
-CXT_S4 = CTX_S4
-CXT_S5 = CTX_S5
-CXT_S6 = CTX_S6
-CXT_S7 = CTX_S7
-CXT_T8 = CTX_T8
-CXT_T9 = CTX_T9
-CXT_K0 = CTX_K0
-CXT_K1 = CTX_K1
-CXT_GP = CTX_GP
-CXT_SP = CTX_SP
-CXT_S8 = CTX_S8
-CXT_RA = CTX_RA
-CXT_MDLO = CTX_MDLO
-CXT_MDHI = CTX_MDHI
-CXT_CAUSE = CTX_CAUSE
-CXT_EPC = CTX_EPC
-CXT_SR = CTX_SR
-CTX_FV0 = 0
-CTX_FV1 = 2
-CTX_FA0 = 12
-CTX_FA1 = 13
-CTX_FA2 = 14
-CTX_FA3 = 15
-CTX_FA4 = 16
-CTX_FA5 = 17
-CTX_FA6 = 18
-CTX_FA7 = 19
-CTX_FT0 = 4
-CTX_FT1 = 5
-CTX_FT2 = 6
-CTX_FT3 = 7
-CTX_FT4 = 8
-CTX_FT5 = 9
-CTX_FT6 = 10
-CTX_FT7 = 11
-CTX_FT8 = 20
-CTX_FT9 = 21
-CTX_FT10 = 22
-CTX_FT11 = 23
-CTX_FT12 = 1
-CTX_FT13 = 3
-CTX_FS0 = 24
-CTX_FS1 = 25
-CTX_FS2 = 26
-CTX_FS3 = 27
-CTX_FS4 = 28
-CTX_FS5 = 29
-CTX_FS6 = 30
-CTX_FS7 = 31
-CTX_FT8 = 21
-CTX_FT9 = 23
-CTX_FT10 = 25
-CTX_FT11 = 27
-CTX_FT12 = 29
-CTX_FT13 = 31
-CTX_FT14 = 1
-CTX_FT15 = 3
-CTX_FS0 = 20
-CTX_FS1 = 22
-CTX_FS2 = 24
-CTX_FS3 = 26
-CTX_FS4 = 28
-CTX_FS5 = 30
-SV_ONSTACK = 0x0001
-SV_INTERRUPT = 0x0002
-NUMBSDSIGS = (32)
-def sigmask(sig): return (1L << ((sig)-1))
-
-def sigmask(sig): return (1L << ((sig)-1))
-
-SIG_ERR = (-1)
-SIG_IGN = (1)
-SIG_HOLD = (2)
-SIG_DFL = (0)
-NSIG = 65
-MAXSIG = (NSIG-1)
-NUMSIGS = (NSIG-1)
-BRK_USERBP = 0
-BRK_KERNELBP = 1
-BRK_ABORT = 2
-BRK_BD_TAKEN = 3
-BRK_BD_NOTTAKEN = 4
-BRK_SSTEPBP = 5
-BRK_OVERFLOW = 6
-BRK_DIVZERO = 7
-BRK_RANGE = 8
-BRK_PSEUDO_OP_BIT = 0x80
-BRK_PSEUDO_OP_MAX = 0x3
-BRK_CACHE_SYNC = 0x80
-BRK_MULOVF = 1023
-_POSIX_VERSION = 199506L
-_POSIX_VERSION = 199506
-_POSIX_VDISABLE = 0
-MAX_INPUT = 512
-MAX_CANON = 256
-UID_NOBODY = 60001
-GID_NOBODY = UID_NOBODY
-UID_NOACCESS = 60002
-MAXPID = 0x7ffffff0
-MAXUID = 0x7fffffff
-MAXLINK = 30000
-SSIZE = 1
-SINCR = 1
-KSTKSIZE = 1
-EXTKSTKSIZE = 1
-KSTKIDX = 0
-KSTEIDX = 1
-EXTKSTKSIZE = 0
-KSTKIDX = 0
-CANBSIZ = 256
-HZ = 100
-TICK = 10000000
-NOFILE = 20
-NGROUPS_UMIN = 0
-NGROUPS_UMAX = 32
-NGROUPS = 16
-PMASK = 0177
-PCATCH = 0400
-PLTWAIT = 01000
-PRECALC = 01000
-PSWP = 0
-PINOD = 10
-PSNDD = PINOD
-PRIBIO = 20
-PZERO = 25
-PMEM = 0
-NZERO = 20
-PPIPE = 26
-PVFS = 27
-PWAIT = 30
-PSLEP = 39
-PUSER = 60
-PBATCH_CRITICAL = -1
-PTIME_SHARE = -2
-PTIME_SHARE_OVER = -3
-PBATCH = -4
-PWEIGHTLESS = -5
-IO_NBPC = 4096
-IO_BPCSHIFT = 12
-MIN_NBPC = 4096
-MIN_BPCSHIFT = 12
-MIN_CPSSHIFT = 10
-BPCSHIFT = 12
-CPSSHIFT = 10
-BPCSHIFT = 14
-CPSSHIFT = 12
-CPSSHIFT = 11
-BPSSHIFT = (BPCSHIFT+CPSSHIFT)
-NULL = 0L
-CMASK = 022
-NODEV = (-1)
-NOPAGE = (-1)
-NBPSCTR = 512
-SCTRSHFT = 9
-def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK0)
-
-def BASEPRI(psw): return (((psw) & SR_IMASK) == SR_IMASK)
-
-def USERMODE(psw): return (((psw) & SR_KSU_MSK) == SR_KSU_USR)
-
-MAXPATHLEN = 1024
-MAXSYMLINKS = 30
-MAXNAMELEN = 256
-PIPE_BUF = 10240
-PIPE_MAX = 10240
-NBBY = 8
-BBSHIFT = 9
-BBSIZE = (1<<BBSHIFT)
-BBMASK = (BBSIZE-1)
-def BBTOB(bbs): return ((bbs) << BBSHIFT)
-
-def OFFTOBB(bytes): return (((__uint64_t)(bytes) + BBSIZE - 1) >> BBSHIFT)
-
-def OFFTOBBT(bytes): return ((off_t)(bytes) >> BBSHIFT)
-
-def BBTOOFF(bbs): return ((off_t)(bbs) << BBSHIFT)
-
-SEEKLIMIT32 = 0x7fffffff
-MAXBSIZE = 8192
-DEV_BSIZE = BBSIZE
-DEV_BSHIFT = BBSHIFT
-def btodb(bytes): return \
-
-def dbtob(db): return \
-
-BLKDEV_IOSHIFT = BPCSHIFT
-BLKDEV_IOSIZE = (1<<BLKDEV_IOSHIFT)
-def BLKDEV_OFF(off): return ((off) & (BLKDEV_IOSIZE - 1))
-
-def BLKDEV_LBN(off): return ((off) >> BLKDEV_IOSHIFT)
-
-def BLKDEV_LTOP(bn): return ((bn) * BLKDEV_BB)
-
-MAXHOSTNAMELEN = 256
-def DELAY(n): return us_delay(n)
-
-def DELAYBUS(n): return us_delaybus(n)
-
-TIMEPOKE_NOW = -100L
-MUTEX_DEFAULT = 0x0
-METER_NAMSZ = 16
-METER_NO_SEQ = -1
-def mutex_spinlock(l): return splhi()
-
-def mutex_spintrylock(l): return splhi()
-
-def spinlock_initialized(l): return 1
-
-SV_FIFO = 0x0
-SV_LIFO = 0x2
-SV_PRIO = 0x4
-SV_KEYED = 0x6
-SV_DEFAULT = SV_FIFO
-SEMA_NOHIST = 0x0001
-SEMA_LOCK = 0x0004
-NSCHEDCLASS = (-(PWEIGHTLESS)+1)
-MR_ACCESS = 1
-MR_UPDATE = 2
-MRLOCK_BARRIER = 0x1
-MRLOCK_BEHAVIOR = 0x2
-MRLOCK_DBLTRIPPABLE = 0x4
-MRLOCK_ALLOW_EQUAL_PRI = 0x8
-MRLOCK_DEFAULT = MRLOCK_BARRIER
-def mraccess(mrp): return mraccessf(mrp, 0)
-
-def mrupdate(mrp): return mrupdatef(mrp, 0)
-
-def mp_mutex_unlock(m): return mutex_unlock(m)
-
-def mp_mutex_trylock(m): return mutex_trylock(m)
-
-def mp_mutex_spinlock(m): return mutex_spinlock(m)
-
-
-# Included from sys/mon.h
-MON_LOCKED = 0x01
-MON_WAITING = 0x02
-MON_TIMEOUT = 0x04
-MON_DOSRV = 0x08
-MON_RUN = 0x10
-MR_READER_BUCKETS = 13
-def initlock(l): return spinlock_init(l,0)
-
-def ownlock(x): return 1
-
-def mutex_enter(m): return mutex_lock(m, PZERO)
-
-def mutex_tryenter(m): return mutex_trylock(m)
-
-def mutex_exit(m): return mutex_unlock(m)
-
-def cv_signal(cv): return sv_signal(cv)
-
-def cv_broadcast(cv): return sv_broadcast(cv)
-
-def cv_destroy(cv): return sv_destroy(cv)
-
-RW_READER = MR_ACCESS
-RW_WRITER = MR_UPDATE
-def rw_exit(r): return mrunlock(r)
-
-def rw_tryupgrade(r): return mrtrypromote(r)
-
-def rw_downgrade(r): return mrdemote(r)
-
-def rw_destroy(r): return mrfree(r)
-
-def RW_WRITE_HELD(r): return ismrlocked(r, MR_UPDATE)
-
-def RW_READ_HELD(r): return ismrlocked(r, MR_ACCESS)
-
-MS_FREE = 0
-MS_UPD = 1
-MS_ACC = 2
-MS_WAITERS = 4
-
-# Included from sys/fcntl.h
-FNDELAY = 0x04
-FAPPEND = 0x08
-FSYNC = 0x10
-FDSYNC = 0x20
-FRSYNC = 0x40
-FNONBLOCK = 0x80
-FASYNC = 0x1000
-FLARGEFILE = 0x2000
-FNONBLK = FNONBLOCK
-FDIRECT = 0x8000
-FBULK = 0x10000
-FDIRENT64 = 0x8000
-FCREAT = 0x0100
-FTRUNC = 0x0200
-FEXCL = 0x0400
-FNOCTTY = 0x0800
-O_RDONLY = 0
-O_WRONLY = 1
-O_RDWR = 2
-O_NDELAY = 0x04
-O_APPEND = 0x08
-O_SYNC = 0x10
-O_DSYNC = 0x20
-O_RSYNC = 0x40
-O_NONBLOCK = 0x80
-O_LARGEFILE = 0x2000
-O_DIRECT = 0x8000
-O_BULK = 0x10000
-O_CREAT = 0x100
-O_TRUNC = 0x200
-O_EXCL = 0x400
-O_NOCTTY = 0x800
-F_DUPFD = 0
-F_GETFD = 1
-F_SETFD = 2
-F_GETFL = 3
-F_SETFL = 4
-F_SETLK = 6
-F_SETLKW = 7
-F_CHKFL = 8
-F_ALLOCSP = 10
-F_FREESP = 11
-F_SETBSDLK = 12
-F_SETBSDLKW = 13
-F_GETLK = 14
-F_CHKLK = 15
-F_CHKLKW = 16
-F_CLNLK = 17
-F_RSETLK = 20
-F_RGETLK = 21
-F_RSETLKW = 22
-F_GETOWN = 23
-F_SETOWN = 24
-F_DIOINFO = 30
-F_FSGETXATTR = 31
-F_FSSETXATTR = 32
-F_GETLK64 = 33
-F_SETLK64 = 34
-F_SETLKW64 = 35
-F_ALLOCSP64 = 36
-F_FREESP64 = 37
-F_GETBMAP = 38
-F_FSSETDM = 39
-F_RESVSP = 40
-F_UNRESVSP = 41
-F_RESVSP64 = 42
-F_UNRESVSP64 = 43
-F_GETBMAPA = 44
-F_FSGETXATTRA = 45
-F_SETBIOSIZE = 46
-F_GETBIOSIZE = 47
-F_GETOPS = 50
-F_DMAPI = 51
-F_FSYNC = 52
-F_FSYNC64 = 53
-F_GETBDSATTR = 54
-F_SETBDSATTR = 55
-F_GETBMAPX = 56
-F_SETPRIO = 57
-F_GETPRIO = 58
-F_RDLCK = 01
-F_WRLCK = 02
-F_UNLCK = 03
-O_ACCMODE = 3
-FD_CLOEXEC = 1
-FD_NODUP_FORK = 4
-BMV_IF_ATTRFORK = 0x1
-BMV_IF_NO_DMAPI_READ = 0x2
-BMV_IF_PREALLOC = 0x4
-BMV_IF_VALID = (BMV_IF_ATTRFORK|BMV_IF_NO_DMAPI_READ|BMV_IF_PREALLOC)
-BMV_OF_PREALLOC = 0x1
-BMV_IF_EXTENDED = 0x40000000
-FMASK = 0x190FF
-FOPEN = 0xFFFFFFFF
-FREAD = 0x01
-FWRITE = 0x02
-FNDELAY = 0x04
-FAPPEND = 0x08
-FSYNC = 0x10
-FDSYNC = 0x20
-FRSYNC = 0x40
-FNONBLOCK = 0x80
-FASYNC = 0x1000
-FNONBLK = FNONBLOCK
-FLARGEFILE = 0x2000
-FDIRECT = 0x8000
-FBULK = 0x10000
-FCREAT = 0x0100
-FTRUNC = 0x0200
-FEXCL = 0x0400
-FNOCTTY = 0x0800
-FINVIS = 0x0100
-FSOCKET = 0x0200
-FINPROGRESS = 0x0400
-FPRIORITY = 0x0800
-FPRIO = 0x4000
-FDIRENT64 = 0x8000
-FCLOSEXEC = 0x01
-LOCK_SH = 1
-LOCK_EX = 2
-LOCK_NB = 4
-LOCK_UN = 8
-L_SET = 0
-L_INCR = 1
-L_XTND = 2
-F_OK = 0
-X_OK = 1
-W_OK = 2
-R_OK = 4
diff --git a/Lib/plat-irix6/FL.py b/Lib/plat-irix6/FL.py
deleted file mode 100644
index d1b3be1ef37..00000000000
--- a/Lib/plat-irix6/FL.py
+++ /dev/null
@@ -1,292 +0,0 @@
-# Constants used by the FORMS library (module fl).
-# This corresponds to "forms.h".
-# Recommended use: import FL; ... FL.NORMAL_BOX ... etc.
-# Alternate use: from FL import *; ... NORMAL_BOX ... etc.
-from warnings import warnpy3k
-warnpy3k("the FL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-_v20 = 1
-_v21 = 1
-##import fl
-##try:
-## _v20 = (fl.get_rgbmode is not None)
-##except:
-## _v20 = 0
-##del fl
-
-NULL = 0
-FALSE = 0
-TRUE = 1
-
-EVENT = -1
-
-LABEL_SIZE = 64
-if _v20:
- SHORTCUT_SIZE = 32
-PLACE_FREE = 0
-PLACE_SIZE = 1
-PLACE_ASPECT = 2
-PLACE_MOUSE = 3
-PLACE_CENTER = 4
-PLACE_POSITION = 5
-FL_PLACE_FULLSCREEN = 6
-FIND_INPUT = 0
-FIND_AUTOMATIC = 1
-FIND_MOUSE = 2
-BEGIN_GROUP = 10000
-END_GROUP = 20000
-ALIGN_TOP = 0
-ALIGN_BOTTOM = 1
-ALIGN_LEFT = 2
-ALIGN_RIGHT = 3
-ALIGN_CENTER = 4
-NO_BOX = 0
-UP_BOX = 1
-DOWN_BOX = 2
-FLAT_BOX = 3
-BORDER_BOX = 4
-SHADOW_BOX = 5
-FRAME_BOX = 6
-ROUNDED_BOX = 7
-RFLAT_BOX = 8
-RSHADOW_BOX = 9
-TOP_BOUND_COL = 51
-LEFT_BOUND_COL = 55
-BOT_BOUND_COL = 40
-RIGHT_BOUND_COL = 35
-COL1 = 47
-MCOL = 49
-LCOL = 0
-BOUND_WIDTH = 3.0
-DRAW = 0
-PUSH = 1
-RELEASE = 2
-ENTER = 3
-LEAVE = 4
-MOUSE = 5
-FOCUS = 6
-UNFOCUS = 7
-KEYBOARD = 8
-STEP = 9
-MOVE = 10
-FONT_NAME = 'Helvetica'
-FONT_BOLDNAME = 'Helvetica-Bold'
-FONT_ITALICNAME = 'Helvetica-Oblique'
-FONT_FIXEDNAME = 'Courier'
-FONT_ICONNAME = 'Icon'
-SMALL_FONT = 8.0
-NORMAL_FONT = 11.0
-LARGE_FONT = 20.0
-NORMAL_STYLE = 0
-BOLD_STYLE = 1
-ITALIC_STYLE = 2
-FIXED_STYLE = 3
-ENGRAVED_STYLE = 4
-ICON_STYLE = 5
-BITMAP = 3
-NORMAL_BITMAP = 0
-BITMAP_BOXTYPE = NO_BOX
-BITMAP_COL1 = 0
-BITMAP_COL2 = COL1
-BITMAP_LCOL = LCOL
-BITMAP_ALIGN = ALIGN_BOTTOM
-BITMAP_MAXSIZE = 128*128
-BITMAP_BW = BOUND_WIDTH
-BOX = 1
-BOX_BOXTYPE = UP_BOX
-BOX_COL1 = COL1
-BOX_LCOL = LCOL
-BOX_ALIGN = ALIGN_CENTER
-BOX_BW = BOUND_WIDTH
-BROWSER = 71
-NORMAL_BROWSER = 0
-SELECT_BROWSER = 1
-HOLD_BROWSER = 2
-MULTI_BROWSER = 3
-BROWSER_BOXTYPE = DOWN_BOX
-BROWSER_COL1 = COL1
-BROWSER_COL2 = 3
-BROWSER_LCOL = LCOL
-BROWSER_ALIGN = ALIGN_BOTTOM
-BROWSER_SLCOL = COL1
-BROWSER_BW = BOUND_WIDTH
-BROWSER_LINELENGTH = 128
-BROWSER_MAXLINE = 512
-BUTTON = 11
-NORMAL_BUTTON = 0
-PUSH_BUTTON = 1
-RADIO_BUTTON = 2
-HIDDEN_BUTTON = 3
-TOUCH_BUTTON = 4
-INOUT_BUTTON = 5
-RETURN_BUTTON = 6
-if _v20:
- HIDDEN_RET_BUTTON = 7
-BUTTON_BOXTYPE = UP_BOX
-BUTTON_COL1 = COL1
-BUTTON_COL2 = COL1
-BUTTON_LCOL = LCOL
-BUTTON_ALIGN = ALIGN_CENTER
-BUTTON_MCOL1 = MCOL
-BUTTON_MCOL2 = MCOL
-BUTTON_BW = BOUND_WIDTH
-if _v20:
- CHART = 4
- BAR_CHART = 0
- HORBAR_CHART = 1
- LINE_CHART = 2
- FILLED_CHART = 3
- SPIKE_CHART = 4
- PIE_CHART = 5
- SPECIALPIE_CHART = 6
- CHART_BOXTYPE = BORDER_BOX
- CHART_COL1 = COL1
- CHART_LCOL = LCOL
- CHART_ALIGN = ALIGN_BOTTOM
- CHART_BW = BOUND_WIDTH
- CHART_MAX = 128
-CHOICE = 42
-NORMAL_CHOICE = 0
-CHOICE_BOXTYPE = DOWN_BOX
-CHOICE_COL1 = COL1
-CHOICE_COL2 = LCOL
-CHOICE_LCOL = LCOL
-CHOICE_ALIGN = ALIGN_LEFT
-CHOICE_BW = BOUND_WIDTH
-CHOICE_MCOL = MCOL
-CHOICE_MAXITEMS = 128
-CHOICE_MAXSTR = 64
-CLOCK = 61
-SQUARE_CLOCK = 0
-ROUND_CLOCK = 1
-CLOCK_BOXTYPE = UP_BOX
-CLOCK_COL1 = 37
-CLOCK_COL2 = 42
-CLOCK_LCOL = LCOL
-CLOCK_ALIGN = ALIGN_BOTTOM
-CLOCK_TOPCOL = COL1
-CLOCK_BW = BOUND_WIDTH
-COUNTER = 25
-NORMAL_COUNTER = 0
-SIMPLE_COUNTER = 1
-COUNTER_BOXTYPE = UP_BOX
-COUNTER_COL1 = COL1
-COUNTER_COL2 = 4
-COUNTER_LCOL = LCOL
-COUNTER_ALIGN = ALIGN_BOTTOM
-if _v20:
- COUNTER_BW = BOUND_WIDTH
-else:
- DEFAULT = 51
- RETURN_DEFAULT = 0
- ALWAYS_DEFAULT = 1
-DIAL = 22
-NORMAL_DIAL = 0
-LINE_DIAL = 1
-DIAL_BOXTYPE = NO_BOX
-DIAL_COL1 = COL1
-DIAL_COL2 = 37
-DIAL_LCOL = LCOL
-DIAL_ALIGN = ALIGN_BOTTOM
-DIAL_TOPCOL = COL1
-DIAL_BW = BOUND_WIDTH
-FREE = 101
-NORMAL_FREE = 1
-SLEEPING_FREE = 2
-INPUT_FREE = 3
-CONTINUOUS_FREE = 4
-ALL_FREE = 5
-INPUT = 31
-NORMAL_INPUT = 0
-if _v20:
- FLOAT_INPUT = 1
- INT_INPUT = 2
- HIDDEN_INPUT = 3
- if _v21:
- MULTILINE_INPUT = 4
- SECRET_INPUT = 5
-else:
- ALWAYS_INPUT = 1
-INPUT_BOXTYPE = DOWN_BOX
-INPUT_COL1 = 13
-INPUT_COL2 = 5
-INPUT_LCOL = LCOL
-INPUT_ALIGN = ALIGN_LEFT
-INPUT_TCOL = LCOL
-INPUT_CCOL = 4
-INPUT_BW = BOUND_WIDTH
-INPUT_MAX = 128
-LIGHTBUTTON = 12
-LIGHTBUTTON_BOXTYPE = UP_BOX
-LIGHTBUTTON_COL1 = 39
-LIGHTBUTTON_COL2 = 3
-LIGHTBUTTON_LCOL = LCOL
-LIGHTBUTTON_ALIGN = ALIGN_CENTER
-LIGHTBUTTON_TOPCOL = COL1
-LIGHTBUTTON_MCOL = MCOL
-LIGHTBUTTON_BW1 = BOUND_WIDTH
-LIGHTBUTTON_BW2 = BOUND_WIDTH/2.0
-LIGHTBUTTON_MINSIZE = 12.0
-MENU = 41
-TOUCH_MENU = 0
-PUSH_MENU = 1
-MENU_BOXTYPE = BORDER_BOX
-MENU_COL1 = 55
-MENU_COL2 = 37
-MENU_LCOL = LCOL
-MENU_ALIGN = ALIGN_CENTER
-MENU_BW = BOUND_WIDTH
-MENU_MAX = 300
-POSITIONER = 23
-NORMAL_POSITIONER = 0
-POSITIONER_BOXTYPE = DOWN_BOX
-POSITIONER_COL1 = COL1
-POSITIONER_COL2 = 1
-POSITIONER_LCOL = LCOL
-POSITIONER_ALIGN = ALIGN_BOTTOM
-POSITIONER_BW = BOUND_WIDTH
-ROUNDBUTTON = 13
-ROUNDBUTTON_BOXTYPE = NO_BOX
-ROUNDBUTTON_COL1 = 7
-ROUNDBUTTON_COL2 = 3
-ROUNDBUTTON_LCOL = LCOL
-ROUNDBUTTON_ALIGN = ALIGN_CENTER
-ROUNDBUTTON_TOPCOL = COL1
-ROUNDBUTTON_MCOL = MCOL
-ROUNDBUTTON_BW = BOUND_WIDTH
-SLIDER = 21
-VALSLIDER = 24
-VERT_SLIDER = 0
-HOR_SLIDER = 1
-VERT_FILL_SLIDER = 2
-HOR_FILL_SLIDER = 3
-VERT_NICE_SLIDER = 4
-HOR_NICE_SLIDER = 5
-SLIDER_BOXTYPE = DOWN_BOX
-SLIDER_COL1 = COL1
-SLIDER_COL2 = COL1
-SLIDER_LCOL = LCOL
-SLIDER_ALIGN = ALIGN_BOTTOM
-SLIDER_BW1 = BOUND_WIDTH
-SLIDER_BW2 = BOUND_WIDTH*0.75
-SLIDER_FINE = 0.05
-SLIDER_WIDTH = 0.08
-TEXT = 2
-NORMAL_TEXT = 0
-TEXT_BOXTYPE = NO_BOX
-TEXT_COL1 = COL1
-TEXT_LCOL = LCOL
-TEXT_ALIGN = ALIGN_LEFT
-TEXT_BW = BOUND_WIDTH
-TIMER = 62
-NORMAL_TIMER = 0
-VALUE_TIMER = 1
-HIDDEN_TIMER = 2
-TIMER_BOXTYPE = DOWN_BOX
-TIMER_COL1 = COL1
-TIMER_COL2 = 1
-TIMER_LCOL = LCOL
-TIMER_ALIGN = ALIGN_CENTER
-TIMER_BW = BOUND_WIDTH
-TIMER_BLINKRATE = 0.2
diff --git a/Lib/plat-irix6/GET.py b/Lib/plat-irix6/GET.py
deleted file mode 100644
index 842a3aa9a14..00000000000
--- a/Lib/plat-irix6/GET.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Symbols from <gl/get.h>
-from warnings import warnpy3k
-warnpy3k("the GET module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-BCKBUFFER = 0x1
-FRNTBUFFER = 0x2
-DRAWZBUFFER = 0x4
-DMRGB = 0
-DMSINGLE = 1
-DMDOUBLE = 2
-DMRGBDOUBLE = 5
-HZ30 = 0
-HZ60 = 1
-NTSC = 2
-HDTV = 3
-VGA = 4
-IRIS3K = 5
-PR60 = 6
-PAL = 9
-HZ30_SG = 11
-A343 = 14
-STR_RECT = 15
-VOF0 = 16
-VOF1 = 17
-VOF2 = 18
-VOF3 = 19
-SGI0 = 20
-SGI1 = 21
-SGI2 = 22
-HZ72 = 23
-GL_VIDEO_REG = 0x00800000
-GLV_GENLOCK = 0x00000001
-GLV_UNBLANK = 0x00000002
-GLV_SRED = 0x00000004
-GLV_SGREEN = 0x00000008
-GLV_SBLUE = 0x00000010
-GLV_SALPHA = 0x00000020
-GLV_TTLGENLOCK = 0x00000080
-GLV_TTLSYNC = GLV_TTLGENLOCK
-GLV_GREENGENLOCK = 0x0000100
-LEFTPLANE = 0x0001
-RIGHTPLANE = 0x0002
-BOTTOMPLANE = 0x0004
-TOPPLANE = 0x0008
-NEARPLANE = 0x0010
-FARPLANE = 0x0020
-## GETDEF = __GL_GET_H__
-NOBUFFER = 0x0
-BOTHBUFFERS = 0x3
-DMINTENSITYSINGLE = 3
-DMINTENSITYDOUBLE = 4
-MONSPECIAL = 0x20
-HZ50 = 3
-MONA = 5
-MONB = 6
-MONC = 7
-MOND = 8
-MON_ALL = 12
-MON_GEN_ALL = 13
-CMAPMULTI = 0
-CMAPONE = 1
diff --git a/Lib/plat-irix6/GL.py b/Lib/plat-irix6/GL.py
deleted file mode 100644
index d0e0074755b..00000000000
--- a/Lib/plat-irix6/GL.py
+++ /dev/null
@@ -1,397 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the GL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NULL = 0
-FALSE = 0
-TRUE = 1
-ATTRIBSTACKDEPTH = 10
-VPSTACKDEPTH = 8
-MATRIXSTACKDEPTH = 32
-NAMESTACKDEPTH = 1025
-STARTTAG = -2
-ENDTAG = -3
-BLACK = 0
-RED = 1
-GREEN = 2
-YELLOW = 3
-BLUE = 4
-MAGENTA = 5
-CYAN = 6
-WHITE = 7
-PUP_CLEAR = 0
-PUP_COLOR = 1
-PUP_BLACK = 2
-PUP_WHITE = 3
-NORMALDRAW = 0x010
-PUPDRAW = 0x020
-OVERDRAW = 0x040
-UNDERDRAW = 0x080
-CURSORDRAW = 0x100
-DUALDRAW = 0x200
-PATTERN_16 = 16
-PATTERN_32 = 32
-PATTERN_64 = 64
-PATTERN_16_SIZE = 16
-PATTERN_32_SIZE = 64
-PATTERN_64_SIZE = 256
-SRC_AUTO = 0
-SRC_FRONT = 1
-SRC_BACK = 2
-SRC_ZBUFFER = 3
-SRC_PUP = 4
-SRC_OVER = 5
-SRC_UNDER = 6
-SRC_FRAMEGRABBER = 7
-BF_ZERO = 0
-BF_ONE = 1
-BF_DC = 2
-BF_SC = 2
-BF_MDC = 3
-BF_MSC = 3
-BF_SA = 4
-BF_MSA = 5
-BF_DA = 6
-BF_MDA = 7
-BF_MIN_SA_MDA = 8
-AF_NEVER = 0
-AF_LESS = 1
-AF_EQUAL = 2
-AF_LEQUAL = 3
-AF_GREATER = 4
-AF_NOTEQUAL = 5
-AF_GEQUAL = 6
-AF_ALWAYS = 7
-ZF_NEVER = 0
-ZF_LESS = 1
-ZF_EQUAL = 2
-ZF_LEQUAL = 3
-ZF_GREATER = 4
-ZF_NOTEQUAL = 5
-ZF_GEQUAL = 6
-ZF_ALWAYS = 7
-ZSRC_DEPTH = 0
-ZSRC_COLOR = 1
-SMP_OFF = 0x0
-SMP_ON = 0x1
-SMP_SMOOTHER = 0x2
-SML_OFF = 0x0
-SML_ON = 0x1
-SML_SMOOTHER = 0x2
-SML_END_CORRECT = 0x4
-PYSM_OFF = 0
-PYSM_ON = 1
-PYSM_SHRINK = 2
-DT_OFF = 0
-DT_ON = 1
-PUP_NONE = 0
-PUP_GREY = 0x1
-PUP_BOX = 0x2
-PUP_CHECK = 0x4
-GLC_OLDPOLYGON = 0
-GLC_ZRANGEMAP = 1
-GLC_MQUEUERATE = 2
-GLC_SOFTATTACH = 3
-GLC_MANAGEBG = 4
-GLC_SLOWMAPCOLORS = 5
-GLC_INPUTCHANGEBUG = 6
-GLC_NOBORDERBUG = 7
-GLC_SET_VSYNC = 8
-GLC_GET_VSYNC = 9
-GLC_VSYNC_SLEEP = 10
-GLC_COMPATRATE = 15
-C16X1 = 0
-C16X2 = 1
-C32X1 = 2
-C32X2 = 3
-CCROSS = 4
-FLAT = 0
-GOURAUD = 1
-LO_ZERO = 0x0
-LO_AND = 0x1
-LO_ANDR = 0x2
-LO_SRC = 0x3
-LO_ANDI = 0x4
-LO_DST = 0x5
-LO_XOR = 0x6
-LO_OR = 0x7
-LO_NOR = 0x8
-LO_XNOR = 0x9
-LO_NDST = 0xa
-LO_ORR = 0xb
-LO_NSRC = 0xc
-LO_ORI = 0xd
-LO_NAND = 0xe
-LO_ONE = 0xf
-INFOCUSSCRN = -2
-ST_KEEP = 0
-ST_ZERO = 1
-ST_REPLACE = 2
-ST_INCR = 3
-ST_DECR = 4
-ST_INVERT = 5
-SF_NEVER = 0
-SF_LESS = 1
-SF_EQUAL = 2
-SF_LEQUAL = 3
-SF_GREATER = 4
-SF_NOTEQUAL = 5
-SF_GEQUAL = 6
-SF_ALWAYS = 7
-SS_OFF = 0
-SS_DEPTH = 1
-PYM_FILL = 1
-PYM_POINT = 2
-PYM_LINE = 3
-PYM_HOLLOW = 4
-PYM_LINE_FAST = 5
-FG_OFF = 0
-FG_ON = 1
-FG_DEFINE = 2
-FG_VTX_EXP = 2
-FG_VTX_LIN = 3
-FG_PIX_EXP = 4
-FG_PIX_LIN = 5
-FG_VTX_EXP2 = 6
-FG_PIX_EXP2 = 7
-PM_SHIFT = 0
-PM_EXPAND = 1
-PM_C0 = 2
-PM_C1 = 3
-PM_ADD24 = 4
-PM_SIZE = 5
-PM_OFFSET = 6
-PM_STRIDE = 7
-PM_TTOB = 8
-PM_RTOL = 9
-PM_ZDATA = 10
-PM_WARP = 11
-PM_RDX = 12
-PM_RDY = 13
-PM_CDX = 14
-PM_CDY = 15
-PM_XSTART = 16
-PM_YSTART = 17
-PM_VO1 = 1000
-NAUTO = 0
-NNORMALIZE = 1
-AC_CLEAR = 0
-AC_ACCUMULATE = 1
-AC_CLEAR_ACCUMULATE = 2
-AC_RETURN = 3
-AC_MULT = 4
-AC_ADD = 5
-CP_OFF = 0
-CP_ON = 1
-CP_DEFINE = 2
-SB_RESET = 0
-SB_TRACK = 1
-SB_HOLD = 2
-RD_FREEZE = 0x00000001
-RD_ALPHAONE = 0x00000002
-RD_IGNORE_UNDERLAY = 0x00000004
-RD_IGNORE_OVERLAY = 0x00000008
-RD_IGNORE_PUP = 0x00000010
-RD_OFFSCREEN = 0x00000020
-GD_XPMAX = 0
-GD_YPMAX = 1
-GD_XMMAX = 2
-GD_YMMAX = 3
-GD_ZMIN = 4
-GD_ZMAX = 5
-GD_BITS_NORM_SNG_RED = 6
-GD_BITS_NORM_SNG_GREEN = 7
-GD_BITS_NORM_SNG_BLUE = 8
-GD_BITS_NORM_DBL_RED = 9
-GD_BITS_NORM_DBL_GREEN = 10
-GD_BITS_NORM_DBL_BLUE = 11
-GD_BITS_NORM_SNG_CMODE = 12
-GD_BITS_NORM_DBL_CMODE = 13
-GD_BITS_NORM_SNG_MMAP = 14
-GD_BITS_NORM_DBL_MMAP = 15
-GD_BITS_NORM_ZBUFFER = 16
-GD_BITS_OVER_SNG_CMODE = 17
-GD_BITS_UNDR_SNG_CMODE = 18
-GD_BITS_PUP_SNG_CMODE = 19
-GD_BITS_NORM_SNG_ALPHA = 21
-GD_BITS_NORM_DBL_ALPHA = 22
-GD_BITS_CURSOR = 23
-GD_OVERUNDER_SHARED = 24
-GD_BLEND = 25
-GD_CIFRACT = 26
-GD_CROSSHAIR_CINDEX = 27
-GD_DITHER = 28
-GD_LINESMOOTH_CMODE = 30
-GD_LINESMOOTH_RGB = 31
-GD_LOGICOP = 33
-GD_NSCRNS = 35
-GD_NURBS_ORDER = 36
-GD_NBLINKS = 37
-GD_NVERTEX_POLY = 39
-GD_PATSIZE_64 = 40
-GD_PNTSMOOTH_CMODE = 41
-GD_PNTSMOOTH_RGB = 42
-GD_PUP_TO_OVERUNDER = 43
-GD_READSOURCE = 44
-GD_READSOURCE_ZBUFFER = 48
-GD_STEREO = 50
-GD_SUBPIXEL_LINE = 51
-GD_SUBPIXEL_PNT = 52
-GD_SUBPIXEL_POLY = 53
-GD_TRIMCURVE_ORDER = 54
-GD_WSYS = 55
-GD_ZDRAW_GEOM = 57
-GD_ZDRAW_PIXELS = 58
-GD_SCRNTYPE = 61
-GD_TEXTPORT = 62
-GD_NMMAPS = 63
-GD_FRAMEGRABBER = 64
-GD_TIMERHZ = 66
-GD_DBBOX = 67
-GD_AFUNCTION = 68
-GD_ALPHA_OVERUNDER = 69
-GD_BITS_ACBUF = 70
-GD_BITS_ACBUF_HW = 71
-GD_BITS_STENCIL = 72
-GD_CLIPPLANES = 73
-GD_FOGVERTEX = 74
-GD_LIGHTING_TWOSIDE = 76
-GD_POLYMODE = 77
-GD_POLYSMOOTH = 78
-GD_SCRBOX = 79
-GD_TEXTURE = 80
-GD_FOGPIXEL = 81
-GD_TEXTURE_PERSP = 82
-GD_MUXPIPES = 83
-GD_NOLIMIT = -2
-GD_WSYS_NONE = 0
-GD_WSYS_4S = 1
-GD_SCRNTYPE_WM = 0
-GD_SCRNTYPE_NOWM = 1
-N_PIXEL_TOLERANCE = 1
-N_CULLING = 2
-N_DISPLAY = 3
-N_ERRORCHECKING = 4
-N_SUBDIVISIONS = 5
-N_S_STEPS = 6
-N_T_STEPS = 7
-N_TILES = 8
-N_TMP1 = 9
-N_TMP2 = 10
-N_TMP3 = 11
-N_TMP4 = 12
-N_TMP5 = 13
-N_TMP6 = 14
-N_FILL = 1.0
-N_OUTLINE_POLY = 2.0
-N_OUTLINE_PATCH = 5.0
-N_ISOLINE_S = 12.0
-N_ST = 0x8
-N_STW = 0xd
-N_XYZ = 0x4c
-N_XYZW = 0x51
-N_TEX = 0x88
-N_TEXW = 0x8d
-N_RGBA = 0xd0
-N_RGBAW = 0xd5
-N_P2D = 0x8
-N_P2DR = 0xd
-N_V3D = 0x4c
-N_V3DR = 0x51
-N_T2D = 0x88
-N_T2DR = 0x8d
-N_C4D = 0xd0
-N_C4DR = 0xd5
-LMNULL = 0.0
-MSINGLE = 0
-MPROJECTION = 1
-MVIEWING = 2
-MTEXTURE = 3
-MAXLIGHTS = 8
-MAXRESTRICTIONS = 4
-DEFMATERIAL = 0
-EMISSION = 1
-AMBIENT = 2
-DIFFUSE = 3
-SPECULAR = 4
-SHININESS = 5
-COLORINDEXES = 6
-ALPHA = 7
-DEFLIGHT = 100
-LCOLOR = 101
-POSITION = 102
-SPOTDIRECTION = 103
-SPOTLIGHT = 104
-DEFLMODEL = 200
-LOCALVIEWER = 201
-ATTENUATION = 202
-ATTENUATION2 = 203
-TWOSIDE = 204
-MATERIAL = 1000
-BACKMATERIAL = 1001
-LIGHT0 = 1100
-LIGHT1 = 1101
-LIGHT2 = 1102
-LIGHT3 = 1103
-LIGHT4 = 1104
-LIGHT5 = 1105
-LIGHT6 = 1106
-LIGHT7 = 1107
-LMODEL = 1200
-LMC_COLOR = 0
-LMC_EMISSION = 1
-LMC_AMBIENT = 2
-LMC_DIFFUSE = 3
-LMC_SPECULAR = 4
-LMC_AD = 5
-LMC_NULL = 6
-TX_MINFILTER = 0x100
-TX_MAGFILTER = 0x200
-TX_WRAP = 0x300
-TX_WRAP_S = 0x310
-TX_WRAP_T = 0x320
-TX_TILE = 0x400
-TX_BORDER = 0x500
-TX_NULL = 0x000
-TX_POINT = 0x110
-TX_BILINEAR = 0x220
-TX_MIPMAP = 0x120
-TX_MIPMAP_POINT = 0x121
-TX_MIPMAP_LINEAR = 0x122
-TX_MIPMAP_BILINEAR = 0x123
-TX_MIPMAP_TRILINEAR = 0x124
-TX_REPEAT = 0x301
-TX_CLAMP = 0x302
-TX_SELECT = 0x303
-TX_TEXTURE_0 = 0
-TV_MODULATE = 0x101
-TV_BLEND = 0x102
-TV_DECAL = 0x103
-TV_COLOR = 0x200
-TV_NULL = 0x000
-TV_ENV0 = 0
-TX_S = 0
-TX_T = 1
-TG_OFF = 0
-TG_ON = 1
-TG_CONTOUR = 2
-TG_LINEAR = 3
-TG_SPHEREMAP = 4
-TG_REFRACTMAP = 5
-DGLSINK = 0
-DGLLOCAL = 1
-DGLTSOCKET = 2
-DGL4DDN = 3
-PUP_CURSOR = PUP_COLOR
-FATAL = 1
-WARNING = 2
-ASK_CONT = 3
-ASK_RESTART = 4
-XMAXSCREEN = 1279
-YMAXSCREEN = 1023
-XMAXMEDIUM = 1023
-YMAXMEDIUM = 767
-XMAX170 = 645
-YMAX170 = 484
-XMAXPAL = 779
-YMAXPAL = 574
diff --git a/Lib/plat-irix6/GLWS.py b/Lib/plat-irix6/GLWS.py
deleted file mode 100644
index c1338c73e02..00000000000
--- a/Lib/plat-irix6/GLWS.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the GLWS module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NOERROR = 0
-NOCONTEXT = -1
-NODISPLAY = -2
-NOWINDOW = -3
-NOGRAPHICS = -4
-NOTTOP = -5
-NOVISUAL = -6
-BUFSIZE = -7
-BADWINDOW = -8
-ALREADYBOUND = -100
-BINDFAILED = -101
-SETFAILED = -102
diff --git a/Lib/plat-irix6/IN.py b/Lib/plat-irix6/IN.py
deleted file mode 100644
index 8d140a710ac..00000000000
--- a/Lib/plat-irix6/IN.py
+++ /dev/null
@@ -1,388 +0,0 @@
-# Generated by h2py from /usr/include/netinet/in.h
-from warnings import warnpy3k
-warnpy3k("the IN module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from standards.h
-
-# Included from sgidefs.h
-_MIPS_ISA_MIPS1 = 1
-_MIPS_ISA_MIPS2 = 2
-_MIPS_ISA_MIPS3 = 3
-_MIPS_ISA_MIPS4 = 4
-_MIPS_SIM_ABI32 = 1
-_MIPS_SIM_NABI32 = 2
-_MIPS_SIM_ABI64 = 3
-
-# Included from sys/bsd_types.h
-
-# Included from sys/mkdev.h
-ONBITSMAJOR = 7
-ONBITSMINOR = 8
-OMAXMAJ = 0x7f
-OMAXMIN = 0xff
-NBITSMAJOR = 14
-NBITSMINOR = 18
-MAXMAJ = 0x1ff
-MAXMIN = 0x3ffff
-OLDDEV = 0
-NEWDEV = 1
-MKDEV_VER = NEWDEV
-def IS_STRING_SPEC_DEV(x): return ((dev_t)(x)==__makedev(MKDEV_VER, 0, 0))
-
-def major(dev): return __major(MKDEV_VER, dev)
-
-def minor(dev): return __minor(MKDEV_VER, dev)
-
-
-# Included from sys/select.h
-FD_SETSIZE = 1024
-__NBBY = 8
-
-# Included from string.h
-NULL = 0L
-NBBY = 8
-
-# Included from sys/endian.h
-LITTLE_ENDIAN = 1234
-BIG_ENDIAN = 4321
-PDP_ENDIAN = 3412
-_LITTLE_ENDIAN = 1234
-_BIG_ENDIAN = 4321
-_PDP_ENDIAN = 3412
-_BYTE_ORDER = _BIG_ENDIAN
-_BYTE_ORDER = _LITTLE_ENDIAN
-def ntohl(x): return (x)
-
-def ntohs(x): return (x)
-
-def htonl(x): return (x)
-
-def htons(x): return (x)
-
-def htonl(x): return ntohl(x)
-
-def htons(x): return ntohs(x)
-
-
-# Included from sys/types.h
-
-# Included from sys/pthread.h
-P_MYID = (-1)
-P_MYHOSTID = (-1)
-
-# Included from sys/cpumask.h
-MAXCPU = 128
-def CPUMASK_INDEX(bit): return ((bit) >> 6)
-
-def CPUMASK_SHFT(bit): return ((bit) & 0x3f)
-
-def CPUMASK_IS_ZERO(p): return ((p) == 0)
-
-def CPUMASK_IS_NONZERO(p): return ((p) != 0)
-
-
-# Included from sys/nodemask.h
-def CNODEMASK_IS_ZERO(p): return ((p) == 0)
-
-def CNODEMASK_IS_NONZERO(p): return ((p) != 0)
-
-IPPROTO_IP = 0
-IPPROTO_HOPOPTS = 0
-IPPROTO_ICMP = 1
-IPPROTO_IGMP = 2
-IPPROTO_GGP = 3
-IPPROTO_IPIP = 4
-IPPROTO_ENCAP = IPPROTO_IPIP
-IPPROTO_ST = 5
-IPPROTO_TCP = 6
-IPPROTO_UCL = 7
-IPPROTO_EGP = 8
-IPPROTO_IGP = 9
-IPPROTO_BBN_RCC_MON = 10
-IPPROTO_NVP_II = 11
-IPPROTO_PUP = 12
-IPPROTO_ARGUS = 13
-IPPROTO_EMCON = 14
-IPPROTO_XNET = 15
-IPPROTO_CHAOS = 16
-IPPROTO_UDP = 17
-IPPROTO_MUX = 18
-IPPROTO_DCN_MEAS = 19
-IPPROTO_HMP = 20
-IPPROTO_PRM = 21
-IPPROTO_IDP = 22
-IPPROTO_TRUNK_1 = 23
-IPPROTO_TRUNK_2 = 24
-IPPROTO_LEAF_1 = 25
-IPPROTO_LEAF_2 = 26
-IPPROTO_RDP = 27
-IPPROTO_IRTP = 28
-IPPROTO_TP = 29
-IPPROTO_NETBLT = 30
-IPPROTO_MFE_NSP = 31
-IPPROTO_MERIT_INP = 32
-IPPROTO_SEP = 33
-IPPROTO_3PC = 34
-IPPROTO_IDPR = 35
-IPPROTO_XTP = 36
-IPPROTO_DDP = 37
-IPPROTO_IDPR_CMTP = 38
-IPPROTO_TPPP = 39
-IPPROTO_IL = 40
-IPPROTO_IPV6 = 41
-IPPROTO_ROUTING = 43
-IPPROTO_FRAGMENT = 44
-IPPROTO_RSVP = 46
-IPPROTO_ESP = 50
-IPPROTO_AH = 51
-IPPROTO_ICMPV6 = 58
-IPPROTO_NONE = 59
-IPPROTO_DSTOPTS = 60
-IPPROTO_CFTP = 62
-IPPROTO_HELLO = 63
-IPPROTO_SAT_EXPAK = 64
-IPPROTO_KRYPTOLAN = 65
-IPPROTO_RVD = 66
-IPPROTO_IPPC = 67
-IPPROTO_SAT_MON = 69
-IPPROTO_VISA = 70
-IPPROTO_IPCV = 71
-IPPROTO_CPNX = 72
-IPPROTO_CPHB = 73
-IPPROTO_WSN = 74
-IPPROTO_PVP = 75
-IPPROTO_BR_SAT_MON = 76
-IPPROTO_ND = 77
-IPPROTO_WB_MON = 78
-IPPROTO_WB_EXPAK = 79
-IPPROTO_EON = 80
-IPPROTO_VMTP = 81
-IPPROTO_SECURE_VMTP = 82
-IPPROTO_VINES = 83
-IPPROTO_TTP = 84
-IPPROTO_NSFNET_IGP = 85
-IPPROTO_DGP = 86
-IPPROTO_TCF = 87
-IPPROTO_IGRP = 88
-IPPROTO_OSPF = 89
-IPPROTO_SPRITE_RPC = 90
-IPPROTO_LARP = 91
-IPPROTO_MTP = 92
-IPPROTO_AX25 = 93
-IPPROTO_SWIPE = 94
-IPPROTO_MICP = 95
-IPPROTO_AES_SP3_D = 96
-IPPROTO_ETHERIP = 97
-IPPROTO_ENCAPHDR = 98
-IPPROTO_RAW = 255
-IPPROTO_MAX = 256
-IPPROTO_STP = 257
-IPPORT_RESERVED = 1024
-IPPORT_MAXPORT = 65535
-INET_ADDRSTRLEN = 16
-INET6_ADDRSTRLEN = 46
-def IN_CLASSA(i): return (((__int32_t)(i) & 0x80000000) == 0)
-
-IN_CLASSA_NET = 0xff000000
-IN_CLASSA_NSHIFT = 24
-IN_CLASSA_HOST = 0x00ffffff
-IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((__int32_t)(i) & 0xc0000000) == 0x80000000)
-
-IN_CLASSB_NET = 0xffff0000
-IN_CLASSB_NSHIFT = 16
-IN_CLASSB_HOST = 0x0000ffff
-IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((__int32_t)(i) & 0xe0000000) == 0xc0000000)
-
-IN_CLASSC_NET = 0xffffff00
-IN_CLASSC_NSHIFT = 8
-IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((__int32_t)(i) & 0xf0000000) == 0xe0000000)
-
-IN_CLASSD_NET = 0xf0000000
-IN_CLASSD_NSHIFT = 28
-IN_CLASSD_HOST = 0x0fffffff
-def IN_MULTICAST(i): return IN_CLASSD(i)
-
-def IN_EXPERIMENTAL(i): return (((__int32_t)(i) & 0xf0000000) == 0xf0000000)
-
-def IN_BADCLASS(i): return (((__int32_t)(i) & 0xf0000000) == 0xf0000000)
-
-INADDR_NONE = 0xffffffff
-IN_LOOPBACKNET = 127
-IPNGVERSION = 6
-IPV6_FLOWINFO_FLOWLABEL = 0x00ffffff
-IPV6_FLOWINFO_PRIORITY = 0x0f000000
-IPV6_FLOWINFO_PRIFLOW = 0x0fffffff
-IPV6_FLOWINFO_SRFLAG = 0x10000000
-IPV6_FLOWINFO_VERSION = 0xf0000000
-IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000
-IPV6_PRIORITY_FILLER = 0x01000000
-IPV6_PRIORITY_UNATTENDED = 0x02000000
-IPV6_PRIORITY_RESERVED1 = 0x03000000
-IPV6_PRIORITY_BULK = 0x04000000
-IPV6_PRIORITY_RESERVED2 = 0x05000000
-IPV6_PRIORITY_INTERACTIVE = 0x06000000
-IPV6_PRIORITY_CONTROL = 0x07000000
-IPV6_PRIORITY_8 = 0x08000000
-IPV6_PRIORITY_9 = 0x09000000
-IPV6_PRIORITY_10 = 0x0a000000
-IPV6_PRIORITY_11 = 0x0b000000
-IPV6_PRIORITY_12 = 0x0c000000
-IPV6_PRIORITY_13 = 0x0d000000
-IPV6_PRIORITY_14 = 0x0e000000
-IPV6_PRIORITY_15 = 0x0f000000
-IPV6_SRFLAG_STRICT = 0x10000000
-IPV6_SRFLAG_LOOSE = 0x00000000
-IPV6_VERSION = 0x60000000
-IPV6_FLOWINFO_FLOWLABEL = 0xffffff00
-IPV6_FLOWINFO_PRIORITY = 0x0000000f
-IPV6_FLOWINFO_PRIFLOW = 0xffffff0f
-IPV6_FLOWINFO_SRFLAG = 0x00000010
-IPV6_FLOWINFO_VERSION = 0x000000f0
-IPV6_PRIORITY_UNCHARACTERIZED = 0x00000000
-IPV6_PRIORITY_FILLER = 0x00000001
-IPV6_PRIORITY_UNATTENDED = 0x00000002
-IPV6_PRIORITY_RESERVED1 = 0x00000003
-IPV6_PRIORITY_BULK = 0x00000004
-IPV6_PRIORITY_RESERVED2 = 0x00000005
-IPV6_PRIORITY_INTERACTIVE = 0x00000006
-IPV6_PRIORITY_CONTROL = 0x00000007
-IPV6_PRIORITY_8 = 0x00000008
-IPV6_PRIORITY_9 = 0x00000009
-IPV6_PRIORITY_10 = 0x0000000a
-IPV6_PRIORITY_11 = 0x0000000b
-IPV6_PRIORITY_12 = 0x0000000c
-IPV6_PRIORITY_13 = 0x0000000d
-IPV6_PRIORITY_14 = 0x0000000e
-IPV6_PRIORITY_15 = 0x0000000f
-IPV6_SRFLAG_STRICT = 0x00000010
-IPV6_SRFLAG_LOOSE = 0x00000000
-IPV6_VERSION = 0x00000060
-def IPV6_GET_FLOWLABEL(x): return (ntohl(x) & 0x00ffffff)
-
-def IPV6_GET_PRIORITY(x): return ((ntohl(x) >> 24) & 0xf)
-
-def IPV6_GET_VERSION(x): return ((ntohl(x) >> 28) & 0xf)
-
-def IPV6_SET_FLOWLABEL(x): return (htonl(x) & IPV6_FLOWINFO_FLOWLABEL)
-
-def IPV6_SET_PRIORITY(x): return (htonl((x & 0xf) << 24))
-
-def CLR_ADDR6(a): return \
-
-def IS_ANYSOCKADDR(a): return \
-
-def IS_ANYADDR6(a): return \
-
-def IS_COMPATSOCKADDR(a): return \
-
-def IS_COMPATADDR6(a): return \
-
-def IS_LOOPSOCKADDR(a): return \
-
-def IS_LOOPADDR6(a): return \
-
-def IS_IPV4SOCKADDR(a): return \
-
-def IS_IPV4ADDR6(a): return \
-
-def IS_LOOPSOCKADDR(a): return \
-
-def IS_LOOPADDR6(a): return \
-
-def IS_IPV4SOCKADDR(a): return \
-
-def IS_IPV4ADDR6(a): return \
-
-def IS_LOCALADDR6(a): return ((a).s6_addr8[0] == 0xfe)
-
-def IS_LINKLADDR6(a): return \
-
-def IS_SITELADDR6(a): return \
-
-def IS_MULTIADDR6(a): return ((a).s6_addr8[0] == 0xff)
-
-def MADDR6_FLAGS(a): return ((a).s6_addr8[1] >> 4)
-
-MADDR6_FLG_WK = 0
-MADDR6_FLG_TS = 1
-def MADDR6_SCOPE(a): return ((a).s6_addr8[1] & 0x0f)
-
-MADDR6_SCP_NODE = 0x1
-MADDR6_SCP_LINK = 0x2
-MADDR6_SCP_SITE = 0x5
-MADDR6_SCP_ORG = 0x8
-MADDR6_SCP_GLO = 0xe
-MADDR6_ALLNODES = 1
-MADDR6_ALLROUTERS = 2
-MADDR6_ALLHOSTS = 3
-def IN6_IS_ADDR_UNSPECIFIED(p): return IS_ANYADDR6(*p)
-
-def IN6_IS_ADDR_LOOPBACK(p): return IS_LOOPADDR6(*p)
-
-def IN6_IS_ADDR_MULTICAST(p): return IS_MULTIADDR6(*p)
-
-def IN6_IS_ADDR_LINKLOCAL(p): return IS_LINKLADDR6(*p)
-
-def IN6_IS_ADDR_SITELOCAL(p): return IS_SITELADDR6(*p)
-
-def IN6_IS_ADDR_V4MAPPED(p): return IS_IPV4ADDR6(*p)
-
-def IN6_IS_ADDR_V4COMPAT(p): return IS_COMPATADDR6(*p)
-
-def IN6_IS_ADDR_MC_NODELOCAL(p): return \
-
-def IN6_IS_ADDR_MC_LINKLOCAL(p): return \
-
-def IN6_IS_ADDR_MC_SITELOCAL(p): return \
-
-def IN6_IS_ADDR_MC_ORGLOCAL(p): return \
-
-def IN6_IS_ADDR_MC_GLOBAL(p): return \
-
-IP_OPTIONS = 1
-IP_HDRINCL = 2
-IP_TOS = 3
-IP_TTL = 4
-IP_RECVOPTS = 5
-IP_RECVRETOPTS = 6
-IP_RECVDSTADDR = 7
-IP_RETOPTS = 8
-IP_MULTICAST_IF = 20
-IP_MULTICAST_TTL = 21
-IP_MULTICAST_LOOP = 22
-IP_ADD_MEMBERSHIP = 23
-IP_DROP_MEMBERSHIP = 24
-IP_MULTICAST_VIF = 25
-IP_RSVP_VIF_ON = 26
-IP_RSVP_VIF_OFF = 27
-IP_RSVP_ON = 28
-IP_SENDSRCADDR = 36
-IPV6_UNICAST_HOPS = IP_TTL
-IPV6_MULTICAST_IF = IP_MULTICAST_IF
-IPV6_MULTICAST_HOPS = IP_MULTICAST_TTL
-IPV6_MULTICAST_LOOP = IP_MULTICAST_LOOP
-IPV6_ADD_MEMBERSHIP = IP_ADD_MEMBERSHIP
-IPV6_DROP_MEMBERSHIP = IP_DROP_MEMBERSHIP
-IPV6_SENDIF = 40
-IPV6_NOPROBE = 42
-IPV6_RECVPKTINFO = 43
-IPV6_PKTINFO = 44
-IP_RECVTTL = 45
-IPV6_RECVHOPS = IP_RECVTTL
-IPV6_CHECKSUM = 46
-ICMP6_FILTER = 47
-IPV6_HOPLIMIT = 48
-IPV6_HOPOPTS = 49
-IPV6_DSTOPTS = 50
-IPV6_RTHDR = 51
-IPV6_PKTOPTIONS = 52
-IPV6_NEXTHOP = 53
-IP_DEFAULT_MULTICAST_TTL = 1
-IP_DEFAULT_MULTICAST_LOOP = 1
-IPV6_RTHDR_LOOSE = 0
-IPV6_RTHDR_STRICT = 1
-IPV6_RTHDR_TYPE_0 = 0
diff --git a/Lib/plat-irix6/IOCTL.py b/Lib/plat-irix6/IOCTL.py
deleted file mode 100644
index ffe0f932d0e..00000000000
--- a/Lib/plat-irix6/IOCTL.py
+++ /dev/null
@@ -1,236 +0,0 @@
-# These lines were mostly generated by h2py.py (see demo/scripts)
-# from <sys/ioctl.h>, <sys/termio.h> and <termios.h> on Irix 4.0.2
-# with some manual changes to cope with imperfections in h2py.py.
-# The applicability on other systems is not clear; especially non-SYSV
-# systems may have a totally different set of ioctls.
-from warnings import warnpy3k
-warnpy3k("the IOCTL module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-IOCTYPE = 0xff00
-LIOC = (ord('l')<<8)
-LIOCGETP = (LIOC|1)
-LIOCSETP = (LIOC|2)
-LIOCGETS = (LIOC|5)
-LIOCSETS = (LIOC|6)
-DIOC = (ord('d')<<8)
-DIOCGETC = (DIOC|1)
-DIOCGETB = (DIOC|2)
-DIOCSETE = (DIOC|3)
-IOCPARM_MASK = 0x7f
-IOC_VOID = 0x20000000
-IOC_OUT = 0x40000000
-IOC_IN = 0x80000000
-IOC_INOUT = (IOC_IN|IOC_OUT)
-int = 'i'
-short = 'h'
-long = 'l'
-def sizeof(t): import struct; return struct.calcsize(t)
-def _IO(x,y): return (IOC_VOID|((x)<<8)|y)
-def _IOR(x,y,t): return (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-def _IOW(x,y,t): return (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-# this should be _IORW, but stdio got there first
-def _IOWR(x,y,t): return (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|((x)<<8)|y)
-FIONREAD = _IOR(ord('f'), 127, int)
-FIONBIO = _IOW(ord('f'), 126, int)
-FIOASYNC = _IOW(ord('f'), 125, int)
-FIOSETOWN = _IOW(ord('f'), 124, int)
-FIOGETOWN = _IOR(ord('f'), 123, int)
-NCC = 8
-NCC_PAD = 7
-NCC_EXT = 16
-NCCS = (NCC+NCC_PAD+NCC_EXT)
-VINTR = 0
-VQUIT = 1
-VERASE = 2
-VKILL = 3
-VEOF = 4
-VEOL = 5
-VEOL2 = 6
-VMIN = VEOF
-VTIME = VEOL
-VSWTCH = 7
-VLNEXT = (NCC+NCC_PAD+0)
-VWERASE = (NCC+NCC_PAD+1)
-VRPRNT = (NCC+NCC_PAD+2)
-VFLUSHO = (NCC+NCC_PAD+3)
-VSTOP = (NCC+NCC_PAD+4)
-VSTART = (NCC+NCC_PAD+5)
-CNUL = '\0'
-CDEL = '\377'
-CESC = '\\'
-CINTR = '\177'
-CQUIT = '\34'
-CBRK = '\377'
-def CTRL(c): return ord(c) & 0x0f
-CERASE = CTRL('H')
-CKILL = CTRL('U')
-CEOF = CTRL('d')
-CEOT = CEOF
-CSTART = CTRL('q')
-CSTOP = CTRL('s')
-CSWTCH = CTRL('z')
-CSUSP = CSWTCH
-CNSWTCH = 0
-CLNEXT = CTRL('v')
-CWERASE = CTRL('w')
-CFLUSHO = CTRL('o')
-CFLUSH = CFLUSHO
-CRPRNT = CTRL('r')
-CDSUSP = CTRL('y')
-IGNBRK = 0000001
-BRKINT = 0000002
-IGNPAR = 0000004
-PARMRK = 0000010
-INPCK = 0000020
-ISTRIP = 0000040
-INLCR = 0000100
-IGNCR = 0000200
-ICRNL = 0000400
-IUCLC = 0001000
-IXON = 0002000
-IXANY = 0004000
-IXOFF = 0010000
-IBLKMD = 0020000
-OPOST = 0000001
-OLCUC = 0000002
-ONLCR = 0000004
-OCRNL = 0000010
-ONOCR = 0000020
-ONLRET = 0000040
-OFILL = 0000100
-OFDEL = 0000200
-NLDLY = 0000400
-NL0 = 0
-NL1 = 0000400
-CRDLY = 0003000
-CR0 = 0
-CR1 = 0001000
-CR2 = 0002000
-CR3 = 0003000
-TABDLY = 0014000
-TAB0 = 0
-TAB1 = 0004000
-TAB2 = 0010000
-TAB3 = 0014000
-BSDLY = 0020000
-BS0 = 0
-BS1 = 0020000
-VTDLY = 0040000
-VT0 = 0
-VT1 = 0040000
-FFDLY = 0100000
-FF0 = 0
-FF1 = 0100000
-CBAUD = 0000017
-B0 = 0
-B50 = 0000001
-B75 = 0000002
-B110 = 0000003
-B134 = 0000004
-B150 = 0000005
-B200 = 0000006
-B300 = 0000007
-B600 = 0000010
-B1200 = 0000011
-B1800 = 0000012
-B2400 = 0000013
-B4800 = 0000014
-B9600 = 0000015
-B19200 = 0000016
-EXTA = 0000016
-B38400 = 0000017
-EXTB = 0000017
-CSIZE = 0000060
-CS5 = 0
-CS6 = 0000020
-CS7 = 0000040
-CS8 = 0000060
-CSTOPB = 0000100
-CREAD = 0000200
-PARENB = 0000400
-PARODD = 0001000
-HUPCL = 0002000
-CLOCAL = 0004000
-LOBLK = 0040000
-ISIG = 0000001
-ICANON = 0000002
-XCASE = 0000004
-ECHO = 0000010
-ECHOE = 0000020
-ECHOK = 0000040
-ECHONL = 0000100
-NOFLSH = 0000200
-IIEXTEN = 0000400
-ITOSTOP = 0001000
-SSPEED = B9600
-IOCTYPE = 0xff00
-TIOC = (ord('T')<<8)
-oTCGETA = (TIOC|1)
-oTCSETA = (TIOC|2)
-oTCSETAW = (TIOC|3)
-oTCSETAF = (TIOC|4)
-TCSBRK = (TIOC|5)
-TCXONC = (TIOC|6)
-TCFLSH = (TIOC|7)
-TCGETA = (TIOC|8)
-TCSETA = (TIOC|9)
-TCSETAW = (TIOC|10)
-TCSETAF = (TIOC|11)
-TIOCFLUSH = (TIOC|12)
-TCDSET = (TIOC|32)
-TCBLKMD = (TIOC|33)
-TIOCPKT = (TIOC|112)
-TIOCPKT_DATA = 0x00
-TIOCPKT_FLUSHREAD = 0x01
-TIOCPKT_FLUSHWRITE = 0x02
-TIOCPKT_NOSTOP = 0x10
-TIOCPKT_DOSTOP = 0x20
-TIOCNOTTY = (TIOC|113)
-TIOCSTI = (TIOC|114)
-TIOCSPGRP = _IOW(ord('t'), 118, int)
-TIOCGPGRP = _IOR(ord('t'), 119, int)
-TIOCCONS = _IOW(ord('t'), 120, int)
-struct_winsize = 'hhhh'
-TIOCGWINSZ = _IOR(ord('t'), 104, struct_winsize)
-TIOCSWINSZ = _IOW(ord('t'), 103, struct_winsize)
-TFIOC = (ord('F')<<8)
-oFIONREAD = (TFIOC|127)
-LDIOC = (ord('D')<<8)
-LDOPEN = (LDIOC|0)
-LDCLOSE = (LDIOC|1)
-LDCHG = (LDIOC|2)
-LDGETT = (LDIOC|8)
-LDSETT = (LDIOC|9)
-TERM_NONE = 0
-TERM_TEC = 1
-TERM_V61 = 2
-TERM_V10 = 3
-TERM_TEX = 4
-TERM_D40 = 5
-TERM_H45 = 6
-TERM_D42 = 7
-TM_NONE = 0000
-TM_SNL = 0001
-TM_ANL = 0002
-TM_LCF = 0004
-TM_CECHO = 0010
-TM_CINVIS = 0020
-TM_SET = 0200
-LDISC0 = 0
-LDISC1 = 1
-NTTYDISC = LDISC1
-VSUSP = VSWTCH
-TCSANOW = 0
-TCSADRAIN = 1
-TCSAFLUSH = 2
-TCIFLUSH = 0
-TCOFLUSH = 1
-TCIOFLUSH = 2
-TCOOFF = 0
-TCOON = 1
-TCIOFF = 2
-TCION = 3
-TO_STOP = LOBLK
-IEXTEN = IIEXTEN
-TOSTOP = ITOSTOP
diff --git a/Lib/plat-irix6/SV.py b/Lib/plat-irix6/SV.py
deleted file mode 100644
index e9e14f8dafa..00000000000
--- a/Lib/plat-irix6/SV.py
+++ /dev/null
@@ -1,124 +0,0 @@
-from warnings import warnpy3k
-warnpy3k("the SV module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-NTSC_XMAX = 640
-NTSC_YMAX = 480
-PAL_XMAX = 768
-PAL_YMAX = 576
-BLANKING_BUFFER_SIZE = 2
-
-MAX_SOURCES = 2
-
-# mode parameter for Bind calls
-IN_OFF = 0 # No Video
-IN_OVER = 1 # Video over graphics
-IN_UNDER = 2 # Video under graphics
-IN_REPLACE = 3 # Video replaces entire win
-
-# mode parameters for LoadMap calls. Specifies buffer, always 256 entries
-INPUT_COLORMAP = 0 # tuples of 8-bit RGB
-CHROMA_KEY_MAP = 1 # tuples of 8-bit RGB
-COLOR_SPACE_MAP = 2 # tuples of 8-bit RGB
-GAMMA_MAP = 3 # tuples of 24-bit red values
-
-# mode parameters for UseExclusive calls
-INPUT = 0
-OUTPUT = 1
-IN_OUT = 2
-
-# Format constants for the capture routines
-RGB8_FRAMES = 0 # noninterleaved 8 bit 3:2:3 RBG fields
-RGB32_FRAMES = 1 # 32-bit 8:8:8 RGB frames
-YUV411_FRAMES = 2 # interleaved, 8:2:2 YUV format
-YUV411_FRAMES_AND_BLANKING_BUFFER = 3
-
-#
-# sv.SetParam is passed variable length argument lists,
-# consisting of <name, value> pairs. The following
-# constants identify argument names.
-#
-_NAME_BASE = 1000
-SOURCE = (_NAME_BASE + 0)
-SOURCE1 = 0
-SOURCE2 = 1
-SOURCE3 = 2
-COLOR = (_NAME_BASE + 1)
-DEFAULT_COLOR = 0
-USER_COLOR = 1
-MONO = 2
-OUTPUTMODE = (_NAME_BASE + 2)
-LIVE_OUTPUT = 0
-STILL24_OUT = 1
-FREEZE = (_NAME_BASE + 3)
-DITHER = (_NAME_BASE + 4)
-OUTPUT_FILTER = (_NAME_BASE + 5)
-HUE = (_NAME_BASE + 6)
-GENLOCK = (_NAME_BASE + 7)
-GENLOCK_OFF = 0
-GENLOCK_ON = 1
-GENLOCK_HOUSE = 2
-BROADCAST = (_NAME_BASE + 8)
-NTSC = 0
-PAL = 1
-VIDEO_MODE = (_NAME_BASE + 9)
-COMP = 0
-SVIDEO = 1
-INPUT_BYPASS = (_NAME_BASE + 10)
-FIELDDROP = (_NAME_BASE + 11)
-SLAVE = (_NAME_BASE + 12)
-APERTURE_FACTOR = (_NAME_BASE + 13)
-AFACTOR_0 = 0
-AFACTOR_QTR = 1
-AFACTOR_HLF = 2
-AFACTOR_ONE = 3
-CORING = (_NAME_BASE + 14)
-COR_OFF = 0
-COR_1LSB = 1
-COR_2LSB = 2
-COR_3LSB = 3
-APERTURE_BANDPASS = (_NAME_BASE + 15)
-ABAND_F0 = 0
-ABAND_F1 = 1
-ABAND_F2 = 2
-ABAND_F3 = 3
-PREFILTER = (_NAME_BASE + 16)
-CHROMA_TRAP = (_NAME_BASE + 17)
-CK_THRESHOLD = (_NAME_BASE + 18)
-PAL_SENSITIVITY = (_NAME_BASE + 19)
-GAIN_CONTROL = (_NAME_BASE + 20)
-GAIN_SLOW = 0
-GAIN_MEDIUM = 1
-GAIN_FAST = 2
-GAIN_FROZEN = 3
-AUTO_CKILL = (_NAME_BASE + 21)
-VTR_MODE = (_NAME_BASE + 22)
-VTR_INPUT = 0
-CAMERA_INPUT = 1
-LUMA_DELAY = (_NAME_BASE + 23)
-VNOISE = (_NAME_BASE + 24)
-VNOISE_NORMAL = 0
-VNOISE_SEARCH = 1
-VNOISE_AUTO = 2
-VNOISE_BYPASS = 3
-CHCV_PAL = (_NAME_BASE + 25)
-CHCV_NTSC = (_NAME_BASE + 26)
-CCIR_LEVELS = (_NAME_BASE + 27)
-STD_CHROMA = (_NAME_BASE + 28)
-DENC_VTBYPASS = (_NAME_BASE + 29)
-FAST_TIMECONSTANT = (_NAME_BASE + 30)
-GENLOCK_DELAY = (_NAME_BASE + 31)
-PHASE_SYNC = (_NAME_BASE + 32)
-VIDEO_OUTPUT = (_NAME_BASE + 33)
-CHROMA_PHASEOUT = (_NAME_BASE + 34)
-CHROMA_CENTER = (_NAME_BASE + 35)
-YUV_TO_RGB_INVERT = (_NAME_BASE + 36)
-SOURCE1_BROADCAST = (_NAME_BASE + 37)
-SOURCE1_MODE = (_NAME_BASE + 38)
-SOURCE2_BROADCAST = (_NAME_BASE + 39)
-SOURCE2_MODE = (_NAME_BASE + 40)
-SOURCE3_BROADCAST = (_NAME_BASE + 41)
-SOURCE3_MODE = (_NAME_BASE + 42)
-SIGNAL_STD = (_NAME_BASE + 43)
-NOSIGNAL = 2
-SIGNAL_COLOR = (_NAME_BASE + 44)
diff --git a/Lib/plat-irix6/WAIT.py b/Lib/plat-irix6/WAIT.py
deleted file mode 100644
index 82ff8a1fbad..00000000000
--- a/Lib/plat-irix6/WAIT.py
+++ /dev/null
@@ -1,338 +0,0 @@
-# Generated by h2py from /usr/include/sys/wait.h
-from warnings import warnpy3k
-warnpy3k("the WAIT module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Included from standards.h
-def _W_INT(i): return (i)
-
-WUNTRACED = 0004
-WNOHANG = 0100
-_WSTOPPED = 0177
-def WIFEXITED(stat): return ((_W_INT(stat)&0377)==0)
-
-def WEXITSTATUS(stat): return ((_W_INT(stat)>>8)&0377)
-
-def WTERMSIG(stat): return (_W_INT(stat)&0177)
-
-def WSTOPSIG(stat): return ((_W_INT(stat)>>8)&0377)
-
-WEXITED = 0001
-WTRAPPED = 0002
-WSTOPPED = 0004
-WCONTINUED = 0010
-WNOWAIT = 0200
-WOPTMASK = (WEXITED|WTRAPPED|WSTOPPED|WCONTINUED|WNOHANG|WNOWAIT)
-WSTOPFLG = 0177
-WCONTFLG = 0177777
-WCOREFLAG = 0200
-WSIGMASK = 0177
-def WWORD(stat): return (_W_INT(stat)&0177777)
-
-def WIFCONTINUED(stat): return (WWORD(stat)==WCONTFLG)
-
-def WCOREDUMP(stat): return (_W_INT(stat) & WCOREFLAG)
-
-
-# Included from sys/types.h
-
-# Included from sgidefs.h
-_MIPS_ISA_MIPS1 = 1
-_MIPS_ISA_MIPS2 = 2
-_MIPS_ISA_MIPS3 = 3
-_MIPS_ISA_MIPS4 = 4
-_MIPS_SIM_ABI32 = 1
-_MIPS_SIM_NABI32 = 2
-_MIPS_SIM_ABI64 = 3
-P_MYID = (-1)
-P_MYHOSTID = (-1)
-
-# Included from sys/bsd_types.h
-
-# Included from sys/mkdev.h
-ONBITSMAJOR = 7
-ONBITSMINOR = 8
-OMAXMAJ = 0x7f
-OMAXMIN = 0xff
-NBITSMAJOR = 14
-NBITSMINOR = 18
-MAXMAJ = 0x1ff
-MAXMIN = 0x3ffff
-OLDDEV = 0
-NEWDEV = 1
-MKDEV_VER = NEWDEV
-def major(dev): return __major(MKDEV_VER, dev)
-
-def minor(dev): return __minor(MKDEV_VER, dev)
-
-
-# Included from sys/select.h
-FD_SETSIZE = 1024
-__NBBY = 8
-
-# Included from string.h
-NULL = 0L
-NBBY = 8
-
-# Included from sys/procset.h
-P_INITPID = 1
-P_INITUID = 0
-P_INITPGID = 0
-
-# Included from sys/signal.h
-SIGHUP = 1
-SIGINT = 2
-SIGQUIT = 3
-SIGILL = 4
-SIGTRAP = 5
-SIGIOT = 6
-SIGABRT = 6
-SIGEMT = 7
-SIGFPE = 8
-SIGKILL = 9
-SIGBUS = 10
-SIGSEGV = 11
-SIGSYS = 12
-SIGPIPE = 13
-SIGALRM = 14
-SIGTERM = 15
-SIGUSR1 = 16
-SIGUSR2 = 17
-SIGCLD = 18
-SIGCHLD = 18
-SIGPWR = 19
-SIGWINCH = 20
-SIGURG = 21
-SIGPOLL = 22
-SIGIO = 22
-SIGSTOP = 23
-SIGTSTP = 24
-SIGCONT = 25
-SIGTTIN = 26
-SIGTTOU = 27
-SIGVTALRM = 28
-SIGPROF = 29
-SIGXCPU = 30
-SIGXFSZ = 31
-SIG32 = 32
-SIGCKPT = 33
-SIGRTMIN = 49
-SIGRTMAX = 64
-SIGPTINTR = 47
-SIGPTRESCHED = 48
-__sigargs = int
-SIGEV_NONE = 128
-SIGEV_SIGNAL = 129
-SIGEV_CALLBACK = 130
-
-# Included from sys/siginfo.h
-ILL_ILLOPC = 1
-ILL_ILLOPN = 2
-ILL_ILLADR = 3
-ILL_ILLTRP = 4
-ILL_PRVOPC = 5
-ILL_PRVREG = 6
-ILL_COPROC = 7
-ILL_BADSTK = 8
-NSIGILL = 8
-FPE_INTDIV = 1
-FPE_INTOVF = 2
-FPE_FLTDIV = 3
-FPE_FLTOVF = 4
-FPE_FLTUND = 5
-FPE_FLTRES = 6
-FPE_FLTINV = 7
-FPE_FLTSUB = 8
-NSIGFPE = 8
-SEGV_MAPERR = 1
-SEGV_ACCERR = 2
-NSIGSEGV = 2
-BUS_ADRALN = 1
-BUS_ADRERR = 2
-BUS_OBJERR = 3
-NSIGBUS = 3
-TRAP_BRKPT = 1
-TRAP_TRACE = 2
-NSIGTRAP = 2
-CLD_EXITED = 1
-CLD_KILLED = 2
-CLD_DUMPED = 3
-CLD_TRAPPED = 4
-CLD_STOPPED = 5
-CLD_CONTINUED = 6
-NSIGCLD = 6
-POLL_IN = 1
-POLL_OUT = 2
-POLL_MSG = 3
-POLL_ERR = 4
-POLL_PRI = 5
-POLL_HUP = 6
-NSIGPOLL = 6
-SI_MAXSZ = 128
-SI_USER = 0
-SI_KILL = SI_USER
-SI_QUEUE = -1
-SI_ASYNCIO = -2
-SI_TIMER = -3
-SI_MESGQ = -4
-SIG_NOP = 0
-SIG_BLOCK = 1
-SIG_UNBLOCK = 2
-SIG_SETMASK = 3
-SIG_SETMASK32 = 256
-SA_ONSTACK = 0x00000001
-SA_RESETHAND = 0x00000002
-SA_RESTART = 0x00000004
-SA_SIGINFO = 0x00000008
-SA_NODEFER = 0x00000010
-SA_NOCLDWAIT = 0x00010000
-SA_NOCLDSTOP = 0x00020000
-_SA_BSDCALL = 0x10000000
-MINSIGSTKSZ = 512
-SIGSTKSZ = 8192
-SS_ONSTACK = 0x00000001
-SS_DISABLE = 0x00000002
-
-# Included from sys/ucontext.h
-NGREG = 36
-NGREG = 37
-GETCONTEXT = 0
-SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
-UC_MCONTEXT = (UC_CPU|UC_MAU)
-UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
-CTX_R0 = 0
-CTX_AT = 1
-CTX_V0 = 2
-CTX_V1 = 3
-CTX_A0 = 4
-CTX_A1 = 5
-CTX_A2 = 6
-CTX_A3 = 7
-CTX_T0 = 8
-CTX_T1 = 9
-CTX_T2 = 10
-CTX_T3 = 11
-CTX_T4 = 12
-CTX_T5 = 13
-CTX_T6 = 14
-CTX_T7 = 15
-CTX_A4 = 8
-CTX_A5 = 9
-CTX_A6 = 10
-CTX_A7 = 11
-CTX_T0 = 12
-CTX_T1 = 13
-CTX_T2 = 14
-CTX_T3 = 15
-CTX_S0 = 16
-CTX_S1 = 17
-CTX_S2 = 18
-CTX_S3 = 19
-CTX_S4 = 20
-CTX_S5 = 21
-CTX_S6 = 22
-CTX_S7 = 23
-CTX_T8 = 24
-CTX_T9 = 25
-CTX_K0 = 26
-CTX_K1 = 27
-CTX_GP = 28
-CTX_SP = 29
-CTX_S8 = 30
-CTX_RA = 31
-CTX_MDLO = 32
-CTX_MDHI = 33
-CTX_CAUSE = 34
-CTX_EPC = 35
-CTX_SR = 36
-CXT_R0 = CTX_R0
-CXT_AT = CTX_AT
-CXT_V0 = CTX_V0
-CXT_V1 = CTX_V1
-CXT_A0 = CTX_A0
-CXT_A1 = CTX_A1
-CXT_A2 = CTX_A2
-CXT_A3 = CTX_A3
-CXT_T0 = CTX_T0
-CXT_T1 = CTX_T1
-CXT_T2 = CTX_T2
-CXT_T3 = CTX_T3
-CXT_T4 = CTX_T4
-CXT_T5 = CTX_T5
-CXT_T6 = CTX_T6
-CXT_T7 = CTX_T7
-CXT_S0 = CTX_S0
-CXT_S1 = CTX_S1
-CXT_S2 = CTX_S2
-CXT_S3 = CTX_S3
-CXT_S4 = CTX_S4
-CXT_S5 = CTX_S5
-CXT_S6 = CTX_S6
-CXT_S7 = CTX_S7
-CXT_T8 = CTX_T8
-CXT_T9 = CTX_T9
-CXT_K0 = CTX_K0
-CXT_K1 = CTX_K1
-CXT_GP = CTX_GP
-CXT_SP = CTX_SP
-CXT_S8 = CTX_S8
-CXT_RA = CTX_RA
-CXT_MDLO = CTX_MDLO
-CXT_MDHI = CTX_MDHI
-CXT_CAUSE = CTX_CAUSE
-CXT_EPC = CTX_EPC
-CXT_SR = CTX_SR
-SV_ONSTACK = 0x0001
-SV_INTERRUPT = 0x0002
-NUMBSDSIGS = (32)
-def sigmask(sig): return (1L << ((sig)-1))
-
-def sigmask(sig): return (1L << ((sig)-1))
-
-SIG_ERR = (-1)
-SIG_IGN = (1)
-SIG_HOLD = (2)
-SIG_DFL = (0)
-NSIG = 65
-MAXSIG = (NSIG-1)
-NUMSIGS = (NSIG-1)
-BRK_USERBP = 0
-BRK_KERNELBP = 1
-BRK_ABORT = 2
-BRK_BD_TAKEN = 3
-BRK_BD_NOTTAKEN = 4
-BRK_SSTEPBP = 5
-BRK_OVERFLOW = 6
-BRK_DIVZERO = 7
-BRK_RANGE = 8
-BRK_PSEUDO_OP_BIT = 0x80
-BRK_PSEUDO_OP_MAX = 0x3
-BRK_CACHE_SYNC = 0x80
-BRK_SWASH_FLUSH = 0x81
-BRK_SWASH_SWTCH = 0x82
-BRK_MULOVF = 1023
-
-# Included from sys/resource.h
-PRIO_MIN = -20
-PRIO_MAX = 20
-PRIO_PROCESS = 0
-PRIO_PGRP = 1
-PRIO_USER = 2
-RUSAGE_SELF = 0
-RUSAGE_CHILDREN = -1
-RLIMIT_CPU = 0
-RLIMIT_FSIZE = 1
-RLIMIT_DATA = 2
-RLIMIT_STACK = 3
-RLIMIT_CORE = 4
-RLIMIT_NOFILE = 5
-RLIMIT_VMEM = 6
-RLIMIT_RSS = 7
-RLIMIT_AS = RLIMIT_VMEM
-RLIM_NLIMITS = 8
-RLIM32_INFINITY = 0x7fffffff
-RLIM_INFINITY = 0x7fffffff
diff --git a/Lib/plat-irix6/cddb.py b/Lib/plat-irix6/cddb.py
deleted file mode 100644
index b5584702c4e..00000000000
--- a/Lib/plat-irix6/cddb.py
+++ /dev/null
@@ -1,207 +0,0 @@
-# This file implements a class which forms an interface to the .cddb
-# directory that is maintained by SGI's cdman program.
-#
-# Usage is as follows:
-#
-# import readcd
-# r = readcd.Readcd()
-# c = Cddb(r.gettrackinfo())
-#
-# Now you can use c.artist, c.title and c.track[trackno] (where trackno
-# starts at 1). When the CD is not recognized, all values will be the empty
-# string.
-# It is also possible to set the above mentioned variables to new values.
-# You can then use c.write() to write out the changed values to the
-# .cdplayerrc file.
-from warnings import warnpy3k
-warnpy3k("the cddb module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import string, posix, os
-
-_cddbrc = '.cddb'
-_DB_ID_NTRACKS = 5
-_dbid_map = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ@_=+abcdefghijklmnopqrstuvwxyz'
-def _dbid(v):
- if v >= len(_dbid_map):
- return string.zfill(v, 2)
- else:
- return _dbid_map[v]
-
-def tochash(toc):
- if type(toc) == type(''):
- tracklist = []
- for i in range(2, len(toc), 4):
- tracklist.append((None,
- (int(toc[i:i+2]),
- int(toc[i+2:i+4]))))
- else:
- tracklist = toc
- ntracks = len(tracklist)
- hash = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- hash = hash + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- hash = hash + _dbid(length[0]) + _dbid(length[1])
- return hash
-
-class Cddb:
- def __init__(self, tracklist):
- if os.environ.has_key('CDDB_PATH'):
- path = os.environ['CDDB_PATH']
- cddb_path = path.split(',')
- else:
- home = os.environ['HOME']
- cddb_path = [home + '/' + _cddbrc]
-
- self._get_id(tracklist)
-
- for dir in cddb_path:
- file = dir + '/' + self.id + '.rdb'
- try:
- f = open(file, 'r')
- self.file = file
- break
- except IOError:
- pass
- ntracks = int(self.id[:2], 16)
- self.artist = ''
- self.title = ''
- self.track = [None] + [''] * ntracks
- self.trackartist = [None] + [''] * ntracks
- self.notes = []
- if not hasattr(self, 'file'):
- return
- import re
- reg = re.compile(r'^([^.]*)\.([^:]*):[\t ]+(.*)')
- while 1:
- line = f.readline()
- if not line:
- break
- match = reg.match(line)
- if not match:
- print 'syntax error in ' + file
- continue
- name1, name2, value = match.group(1, 2, 3)
- if name1 == 'album':
- if name2 == 'artist':
- self.artist = value
- elif name2 == 'title':
- self.title = value
- elif name2 == 'toc':
- if not self.toc:
- self.toc = value
- if self.toc != value:
- print 'toc\'s don\'t match'
- elif name2 == 'notes':
- self.notes.append(value)
- elif name1[:5] == 'track':
- try:
- trackno = int(name1[5:])
- except ValueError:
- print 'syntax error in ' + file
- continue
- if trackno > ntracks:
- print 'track number %r in file %s out of range' % (trackno, file)
- continue
- if name2 == 'title':
- self.track[trackno] = value
- elif name2 == 'artist':
- self.trackartist[trackno] = value
- f.close()
- for i in range(2, len(self.track)):
- track = self.track[i]
- # if track title starts with `,', use initial part
- # of previous track's title
- if track and track[0] == ',':
- try:
- off = self.track[i - 1].index(',')
- except ValueError:
- pass
- else:
- self.track[i] = self.track[i-1][:off] \
- + track
-
- def _get_id(self, tracklist):
- # fill in self.id and self.toc.
- # if the argument is a string ending in .rdb, the part
- # upto the suffix is taken as the id.
- if type(tracklist) == type(''):
- if tracklist[-4:] == '.rdb':
- self.id = tracklist[:-4]
- self.toc = ''
- return
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (int(tracklist[i:i+2]), \
- int(tracklist[i+2:i+4]))))
- tracklist = t
- ntracks = len(tracklist)
- self.id = _dbid((ntracks >> 4) & 0xF) + _dbid(ntracks & 0xF)
- if ntracks <= _DB_ID_NTRACKS:
- nidtracks = ntracks
- else:
- nidtracks = _DB_ID_NTRACKS - 1
- min = 0
- sec = 0
- for track in tracklist:
- start, length = track
- min = min + length[0]
- sec = sec + length[1]
- min = min + sec / 60
- sec = sec % 60
- self.id = self.id + _dbid(min) + _dbid(sec)
- for i in range(nidtracks):
- start, length = tracklist[i]
- self.id = self.id + _dbid(length[0]) + _dbid(length[1])
- self.toc = string.zfill(ntracks, 2)
- for track in tracklist:
- start, length = track
- self.toc = self.toc + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
-
- def write(self):
- import posixpath
- if os.environ.has_key('CDDB_WRITE_DIR'):
- dir = os.environ['CDDB_WRITE_DIR']
- else:
- dir = os.environ['HOME'] + '/' + _cddbrc
- file = dir + '/' + self.id + '.rdb'
- if posixpath.exists(file):
- # make backup copy
- posix.rename(file, file + '~')
- f = open(file, 'w')
- f.write('album.title:\t' + self.title + '\n')
- f.write('album.artist:\t' + self.artist + '\n')
- f.write('album.toc:\t' + self.toc + '\n')
- for note in self.notes:
- f.write('album.notes:\t' + note + '\n')
- prevpref = None
- for i in range(1, len(self.track)):
- if self.trackartist[i]:
- f.write('track%r.artist:\t%s\n' % (i, self.trackartist[i]))
- track = self.track[i]
- try:
- off = track.index(',')
- except ValueError:
- prevpref = None
- else:
- if prevpref and track[:off] == prevpref:
- track = track[off:]
- else:
- prevpref = track[:off]
- f.write('track%r.title:\t%s\n' % (i, track))
- f.close()
diff --git a/Lib/plat-irix6/cdplayer.py b/Lib/plat-irix6/cdplayer.py
deleted file mode 100644
index 9664b2c233a..00000000000
--- a/Lib/plat-irix6/cdplayer.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# This file implements a class which forms an interface to the .cdplayerrc
-# file that is maintained by SGI's cdplayer program.
-#
-# Usage is as follows:
-#
-# import readcd
-# r = readcd.Readcd()
-# c = Cdplayer(r.gettrackinfo())
-#
-# Now you can use c.artist, c.title and c.track[trackno] (where trackno
-# starts at 1). When the CD is not recognized, all values will be the empty
-# string.
-# It is also possible to set the above mentioned variables to new values.
-# You can then use c.write() to write out the changed values to the
-# .cdplayerrc file.
-from warnings import warnpy3k
-warnpy3k("the cdplayer module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-cdplayerrc = '.cdplayerrc'
-
-class Cdplayer:
- def __init__(self, tracklist):
- import string
- self.artist = ''
- self.title = ''
- if type(tracklist) == type(''):
- t = []
- for i in range(2, len(tracklist), 4):
- t.append((None, \
- (int(tracklist[i:i+2]), \
- int(tracklist[i+2:i+4]))))
- tracklist = t
- self.track = [None] + [''] * len(tracklist)
- self.id = 'd' + string.zfill(len(tracklist), 2)
- for track in tracklist:
- start, length = track
- self.id = self.id + string.zfill(length[0], 2) + \
- string.zfill(length[1], 2)
- try:
- import posix
- f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r')
- except IOError:
- return
- import re
- reg = re.compile(r'^([^:]*):\t(.*)')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = f.readline()
- if line == '':
- break
- if line[:l] == s:
- line = line[l:]
- match = reg.match(line)
- if not match:
- print 'syntax error in ~/' + cdplayerrc
- continue
- name, value = match.group(1, 2)
- if name == 'title':
- self.title = value
- elif name == 'artist':
- self.artist = value
- elif name[:5] == 'track':
- trackno = int(name[6:])
- self.track[trackno] = value
- f.close()
-
- def write(self):
- import posix
- filename = posix.environ['HOME'] + '/' + cdplayerrc
- try:
- old = open(filename, 'r')
- except IOError:
- old = open('/dev/null', 'r')
- new = open(filename + '.new', 'w')
- s = self.id + '.'
- l = len(s)
- while 1:
- line = old.readline()
- if line == '':
- break
- if line[:l] != s:
- new.write(line)
- new.write(self.id + '.title:\t' + self.title + '\n')
- new.write(self.id + '.artist:\t' + self.artist + '\n')
- for i in range(1, len(self.track)):
- new.write('%s.track.%r:\t%s\n' % (self.id, i, self.track[i]))
- old.close()
- new.close()
- posix.rename(filename + '.new', filename)
diff --git a/Lib/plat-irix6/flp.doc b/Lib/plat-irix6/flp.doc
deleted file mode 100644
index 1a2f374ae7a..00000000000
--- a/Lib/plat-irix6/flp.doc
+++ /dev/null
@@ -1,117 +0,0 @@
-.SH
-Module flp
-.LP
-The flp module loads fl-forms from fd files, as generated
-by fdesign. The module is designed to be flexible enough to allow
-almost anything to be done with the loaded form.
-.LP
-Loadform defines
-two types of functions: functions to parse fd files and functions to
-create the forms from the templates returned by the parse functions.
-There are fairly low-level create functions that create single objects,
-and convenience routines that create complete forms, including callbacks,
-etc.
-.LP
-The exception flp.error is raised whenever an error occurs while parsing a forms
-definition file or creating a form.
-.SH 2
-Parsing functions
-.LP
-There are two parsing functions, parse_form() and parse_forms(). They
-take the following form:
-.LP
-.ft C
-ftuple = parse_form(filename, formname)
-.br
-ftdict = parse_forms(filename)
-.IP
-Parse_form parses a single form, and returns a tuple (ftmp, otmplist).
-Ftmp is a template for a form, otmplist is a list of templates for
-objects. See below for a description of these templates.
-.IP
-Parse_forms parses all forms in an fd file. It returns a dictionary of
-(ftmp, otmplist) tuples, indexed by formname.
-.IP
-Filename is the name of the forms definition file to inspect. The functions
-appends '.fd' if needed, and use 'sys.path' to locate the file.
-.IP
-formname is the name of the form to load. This argument is mandatory,
-even if the file only contains one form.
-.LP
-The form template and object template are structures that contain all
-the information read from the fd file, in 'natural' form. A form
-template record contains the following fields:
-.IP
-.nf
-"Name", the name of the form;
-"Width", the width of the form;
-"Height", the height of the form; and
-"Numberofobjects", the number of objects in the form.
-.LP
-An object template contains the following fields:
-.IP
-.nf
-"Class", the class of object (eg. FL.BUTTON);
-"Type", the sub-class (eg. FL.NORMALBUTTON);
-"Box", a list with four members: [x, y, width, height];
-"Boxtype", the type of box (eg. FL.DOWNBOX);
-"Colors", a list with the two object colors;
-"Alignment", the label alignment (eg. FL.ALIGNLEFT);
-"Style", the label style (eg. FL.BOLDSTYLE);
-"Lcol", the label color;
-"Label", a string containing the label;
-"Name", a string containing the name of the object;
-"Callback", a string containing the callback routine name; and
-"Argument", a string containing the callback routine extra argument.
-.SH
-Low-level create routines.
-.LP
-The three low-level creation routines are called as follows:
-.LP
-.ft C
-form = create_form(form_template)
-.IP
-Create an fl form from a form template. Returns the form created.
-.LP
-.ft C
-obj = create_object(form, obj_template)
-.IP
-Create an object in an fl form. Return the new object.
-An error is raised if the object has a callback routine.
-.SH
-High-level create routines.
-.LP
-The 'standard' way to handle forms in python is to define a class
-that contains the form and all the objects (insofar as they are named),
-and that defines all the callback functions, and use an instance of
-this class to handle the form interaction.
-Flp contains three routines that simplify handling this paradigm:
-.LP
-.ft C
-create_full_form(instance, ftuple)
-.IP
-This routine takes an instance of your form-handling class and an
-ftuple (as returned by the parsing routines) as parameters. It inserts
-the form into the instance, defines all object names and arranges that
-the callback methods are called. All the names inserted into the
-instance are the same as the names used for the objects, etc. in the
-fd file.
-.LP
-.ft C
-merge_full_form(instance, form, ftuple)
-.IP
-This function does the same as create_full_form, only it does not create
-the form itself nor the 'background box' that fdesign automatically
-adds to each form. This is useful if your class inherits a superclass
-that already defines a skeleton form (with 'OK' and 'Cancel' buttons,
-for instance), and you want to merge the new form into that existing
-form. The 'form' parameter is the form to which the new objects are
-added.
-.LP
-If you use the paradigm sketched here but need slightly more control
-over object creation there is a routine that creates a single object
-and inserts its name (and arranges for the callback routine to be
-called):
-.LP
-.ft C
-create_object_instance(instance, form, obj_template)
diff --git a/Lib/plat-irix6/flp.py b/Lib/plat-irix6/flp.py
deleted file mode 100644
index 32e8b9d27df..00000000000
--- a/Lib/plat-irix6/flp.py
+++ /dev/null
@@ -1,454 +0,0 @@
-#
-# flp - Module to load fl forms from fd files
-#
-# Jack Jansen, December 1991
-#
-from warnings import warnpy3k
-warnpy3k("the flp module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-import sys
-import FL
-
-SPLITLINE = '--------------------'
-FORMLINE = '=============== FORM ==============='
-ENDLINE = '=============================='
-
-class error(Exception):
- pass
-
-##################################################################
-# Part 1 - The parsing routines #
-##################################################################
-
-#
-# Externally visible function. Load form.
-#
-def parse_form(filename, formname):
- forms = checkcache(filename)
- if forms is None:
- forms = parse_forms(filename)
- if forms.has_key(formname):
- return forms[formname]
- else:
- raise error, 'No such form in fd file'
-
-#
-# Externally visible function. Load all forms.
-#
-def parse_forms(filename):
- forms = checkcache(filename)
- if forms is not None: return forms
- fp = _open_formfile(filename)
- nforms = _parse_fd_header(fp)
- forms = {}
- for i in range(nforms):
- form = _parse_fd_form(fp, None)
- forms[form[0].Name] = form
- writecache(filename, forms)
- return forms
-
-#
-# Internal: see if a cached version of the file exists
-#
-MAGIC = '.fdc'
-_internal_cache = {} # Used by frozen scripts only
-def checkcache(filename):
- if _internal_cache.has_key(filename):
- altforms = _internal_cache[filename]
- return _unpack_cache(altforms)
- import marshal
- fp, filename = _open_formfile2(filename)
- fp.close()
- cachename = filename + 'c'
- try:
- fp = open(cachename, 'r')
- except IOError:
- #print 'flp: no cache file', cachename
- return None
- try:
- if fp.read(4) != MAGIC:
- print 'flp: bad magic word in cache file', cachename
- return None
- cache_mtime = rdlong(fp)
- file_mtime = getmtime(filename)
- if cache_mtime != file_mtime:
- #print 'flp: outdated cache file', cachename
- return None
- #print 'flp: valid cache file', cachename
- altforms = marshal.load(fp)
- return _unpack_cache(altforms)
- finally:
- fp.close()
-
-def _unpack_cache(altforms):
- forms = {}
- for name in altforms.keys():
- altobj, altlist = altforms[name]
- obj = _newobj()
- obj.make(altobj)
- list = []
- for altobj in altlist:
- nobj = _newobj()
- nobj.make(altobj)
- list.append(nobj)
- forms[name] = obj, list
- return forms
-
-def rdlong(fp):
- s = fp.read(4)
- if len(s) != 4: return None
- a, b, c, d = s[0], s[1], s[2], s[3]
- return ord(a)<<24 | ord(b)<<16 | ord(c)<<8 | ord(d)
-
-def wrlong(fp, x):
- a, b, c, d = (x>>24)&0xff, (x>>16)&0xff, (x>>8)&0xff, x&0xff
- fp.write(chr(a) + chr(b) + chr(c) + chr(d))
-
-def getmtime(filename):
- import os
- from stat import ST_MTIME
- try:
- return os.stat(filename)[ST_MTIME]
- except os.error:
- return None
-
-#
-# Internal: write cached version of the form (parsing is too slow!)
-#
-def writecache(filename, forms):
- import marshal
- fp, filename = _open_formfile2(filename)
- fp.close()
- cachename = filename + 'c'
- try:
- fp = open(cachename, 'w')
- except IOError:
- print 'flp: can\'t create cache file', cachename
- return # Never mind
- fp.write('\0\0\0\0') # Seek back and write MAGIC when done
- wrlong(fp, getmtime(filename))
- altforms = _pack_cache(forms)
- marshal.dump(altforms, fp)
- fp.seek(0)
- fp.write(MAGIC)
- fp.close()
- #print 'flp: wrote cache file', cachename
-
-#
-# External: print some statements that set up the internal cache.
-# This is for use with the "freeze" script. You should call
-# flp.freeze(filename) for all forms used by the script, and collect
-# the output on a file in a module file named "frozenforms.py". Then
-# in the main program of the script import frozenforms.
-# (Don't forget to take this out when using the unfrozen version of
-# the script!)
-#
-def freeze(filename):
- forms = parse_forms(filename)
- altforms = _pack_cache(forms)
- print 'import flp'
- print 'flp._internal_cache[', repr(filename), '] =', altforms
-
-#
-# Internal: create the data structure to be placed in the cache
-#
-def _pack_cache(forms):
- altforms = {}
- for name in forms.keys():
- obj, list = forms[name]
- altobj = obj.__dict__
- altlist = []
- for obj in list: altlist.append(obj.__dict__)
- altforms[name] = altobj, altlist
- return altforms
-
-#
-# Internal: Locate form file (using PYTHONPATH) and open file
-#
-def _open_formfile(filename):
- return _open_formfile2(filename)[0]
-
-def _open_formfile2(filename):
- if filename[-3:] != '.fd':
- filename = filename + '.fd'
- if filename[0] == '/':
- try:
- fp = open(filename,'r')
- except IOError:
- fp = None
- else:
- for pc in sys.path:
- pn = os.path.join(pc, filename)
- try:
- fp = open(pn, 'r')
- filename = pn
- break
- except IOError:
- fp = None
- if fp is None:
- raise error, 'Cannot find forms file ' + filename
- return fp, filename
-
-#
-# Internal: parse the fd file header, return number of forms
-#
-def _parse_fd_header(file):
- # First read the magic header line
- datum = _parse_1_line(file)
- if datum != ('Magic', 12321):
- raise error, 'Not a forms definition file'
- # Now skip until we know number of forms
- while 1:
- datum = _parse_1_line(file)
- if type(datum) == type(()) and datum[0] == 'Numberofforms':
- break
- return datum[1]
-#
-# Internal: parse fd form, or skip if name doesn't match.
-# the special value None means 'always parse it'.
-#
-def _parse_fd_form(file, name):
- datum = _parse_1_line(file)
- if datum != FORMLINE:
- raise error, 'Missing === FORM === line'
- form = _parse_object(file)
- if form.Name == name or name is None:
- objs = []
- for j in range(form.Numberofobjects):
- obj = _parse_object(file)
- objs.append(obj)
- return (form, objs)
- else:
- for j in range(form.Numberofobjects):
- _skip_object(file)
- return None
-
-#
-# Internal class: a convenient place to store object info fields
-#
-class _newobj:
- def add(self, name, value):
- self.__dict__[name] = value
- def make(self, dict):
- for name in dict.keys():
- self.add(name, dict[name])
-
-#
-# Internal parsing routines.
-#
-def _parse_string(str):
- if '\\' in str:
- s = '\'' + str + '\''
- try:
- return eval(s)
- except:
- pass
- return str
-
-def _parse_num(str):
- return eval(str)
-
-def _parse_numlist(str):
- slist = str.split()
- nlist = []
- for i in slist:
- nlist.append(_parse_num(i))
- return nlist
-
-# This dictionary maps item names to parsing routines.
-# If no routine is given '_parse_num' is default.
-_parse_func = { \
- 'Name': _parse_string, \
- 'Box': _parse_numlist, \
- 'Colors': _parse_numlist, \
- 'Label': _parse_string, \
- 'Name': _parse_string, \
- 'Callback': _parse_string, \
- 'Argument': _parse_string }
-
-# This function parses a line, and returns either
-# a string or a tuple (name,value)
-
-import re
-prog = re.compile('^([^:]*): *(.*)')
-
-def _parse_line(line):
- match = prog.match(line)
- if not match:
- return line
- name, value = match.group(1, 2)
- if name[0] == 'N':
- name = ''.join(name.split())
- name = name.lower()
- name = name.capitalize()
- try:
- pf = _parse_func[name]
- except KeyError:
- pf = _parse_num
- value = pf(value)
- return (name, value)
-
-def _readline(file):
- line = file.readline()
- if not line:
- raise EOFError
- return line[:-1]
-
-def _parse_1_line(file):
- line = _readline(file)
- while line == '':
- line = _readline(file)
- return _parse_line(line)
-
-def _skip_object(file):
- line = ''
- while not line in (SPLITLINE, FORMLINE, ENDLINE):
- pos = file.tell()
- line = _readline(file)
- if line == FORMLINE:
- file.seek(pos)
-
-def _parse_object(file):
- obj = _newobj()
- while 1:
- pos = file.tell()
- datum = _parse_1_line(file)
- if datum in (SPLITLINE, FORMLINE, ENDLINE):
- if datum == FORMLINE:
- file.seek(pos)
- return obj
- if type(datum) is not type(()) or len(datum) != 2:
- raise error, 'Parse error, illegal line in object: '+datum
- obj.add(datum[0], datum[1])
-
-#################################################################
-# Part 2 - High-level object/form creation routines #
-#################################################################
-
-#
-# External - Create a form an link to an instance variable.
-#
-def create_full_form(inst, (fdata, odatalist)):
- form = create_form(fdata)
- exec 'inst.'+fdata.Name+' = form\n'
- for odata in odatalist:
- create_object_instance(inst, form, odata)
-
-#
-# External - Merge a form into an existing form in an instance
-# variable.
-#
-def merge_full_form(inst, form, (fdata, odatalist)):
- exec 'inst.'+fdata.Name+' = form\n'
- if odatalist[0].Class != FL.BOX:
- raise error, 'merge_full_form() expects FL.BOX as first obj'
- for odata in odatalist[1:]:
- create_object_instance(inst, form, odata)
-
-
-#################################################################
-# Part 3 - Low-level object/form creation routines #
-#################################################################
-
-#
-# External Create_form - Create form from parameters
-#
-def create_form(fdata):
- import fl
- return fl.make_form(FL.NO_BOX, fdata.Width, fdata.Height)
-
-#
-# External create_object - Create an object. Make sure there are
-# no callbacks. Returns the object created.
-#
-def create_object(form, odata):
- obj = _create_object(form, odata)
- if odata.Callback:
- raise error, 'Creating free object with callback'
- return obj
-#
-# External create_object_instance - Create object in an instance.
-#
-def create_object_instance(inst, form, odata):
- obj = _create_object(form, odata)
- if odata.Callback:
- cbfunc = eval('inst.'+odata.Callback)
- obj.set_call_back(cbfunc, odata.Argument)
- if odata.Name:
- exec 'inst.' + odata.Name + ' = obj\n'
-#
-# Internal _create_object: Create the object and fill options
-#
-def _create_object(form, odata):
- crfunc = _select_crfunc(form, odata.Class)
- obj = crfunc(odata.Type, odata.Box[0], odata.Box[1], odata.Box[2], \
- odata.Box[3], odata.Label)
- if not odata.Class in (FL.BEGIN_GROUP, FL.END_GROUP):
- obj.boxtype = odata.Boxtype
- obj.col1 = odata.Colors[0]
- obj.col2 = odata.Colors[1]
- obj.align = odata.Alignment
- obj.lstyle = odata.Style
- obj.lsize = odata.Size
- obj.lcol = odata.Lcol
- return obj
-#
-# Internal crfunc: helper function that returns correct create function
-#
-def _select_crfunc(fm, cl):
- if cl == FL.BEGIN_GROUP: return fm.bgn_group
- elif cl == FL.END_GROUP: return fm.end_group
- elif cl == FL.BITMAP: return fm.add_bitmap
- elif cl == FL.BOX: return fm.add_box
- elif cl == FL.BROWSER: return fm.add_browser
- elif cl == FL.BUTTON: return fm.add_button
- elif cl == FL.CHART: return fm.add_chart
- elif cl == FL.CHOICE: return fm.add_choice
- elif cl == FL.CLOCK: return fm.add_clock
- elif cl == FL.COUNTER: return fm.add_counter
- elif cl == FL.DIAL: return fm.add_dial
- elif cl == FL.FREE: return fm.add_free
- elif cl == FL.INPUT: return fm.add_input
- elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
- elif cl == FL.MENU: return fm.add_menu
- elif cl == FL.POSITIONER: return fm.add_positioner
- elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
- elif cl == FL.SLIDER: return fm.add_slider
- elif cl == FL.VALSLIDER: return fm.add_valslider
- elif cl == FL.TEXT: return fm.add_text
- elif cl == FL.TIMER: return fm.add_timer
- else:
- raise error, 'Unknown object type: %r' % (cl,)
-
-
-def test():
- import time
- t0 = time.time()
- if len(sys.argv) == 2:
- forms = parse_forms(sys.argv[1])
- t1 = time.time()
- print 'parse time:', 0.001*(t1-t0), 'sec.'
- keys = forms.keys()
- keys.sort()
- for i in keys:
- _printform(forms[i])
- elif len(sys.argv) == 3:
- form = parse_form(sys.argv[1], sys.argv[2])
- t1 = time.time()
- print 'parse time:', round(t1-t0, 3), 'sec.'
- _printform(form)
- else:
- print 'Usage: test fdfile [form]'
-
-def _printform(form):
- f = form[0]
- objs = form[1]
- print 'Form ', f.Name, ', size: ', f.Width, f.Height, ' Nobj ', f.Numberofobjects
- for i in objs:
- print ' Obj ', i.Name, ' type ', i.Class, i.Type
- print ' Box ', i.Box, ' btype ', i.Boxtype
- print ' Label ', i.Label, ' size/style/col/align ', i.Size,i.Style, i.Lcol, i.Alignment
- print ' cols ', i.Colors
- print ' cback ', i.Callback, i.Argument
diff --git a/Lib/plat-irix6/jpeg.py b/Lib/plat-irix6/jpeg.py
deleted file mode 100644
index 38d781c9012..00000000000
--- a/Lib/plat-irix6/jpeg.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# Implement 'jpeg' interface using SGI's compression library
-
-# XXX Options 'smooth' and 'optimize' are ignored.
-
-# XXX It appears that compressing grayscale images doesn't work right;
-# XXX the resulting file causes weirdness.
-from warnings import warnpy3k
-warnpy3k("the jpeg module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-class error(Exception):
- pass
-
-options = {'quality': 75, 'optimize': 0, 'smooth': 0, 'forcegray': 0}
-
-comp = None
-decomp = None
-
-def compress(imgdata, width, height, bytesperpixel):
- global comp
- import cl
- if comp is None: comp = cl.OpenCompressor(cl.JPEG)
- if bytesperpixel == 1:
- format = cl.GRAYSCALE
- elif bytesperpixel == 4:
- format = cl.RGBX
- if options['forcegray']:
- iformat = cl.GRAYSCALE
- else:
- iformat = cl.YUV
- # XXX How to support 'optimize'?
- params = [cl.IMAGE_WIDTH, width, cl.IMAGE_HEIGHT, height,
- cl.ORIGINAL_FORMAT, format,
- cl.ORIENTATION, cl.BOTTOM_UP,
- cl.QUALITY_FACTOR, options['quality'],
- cl.INTERNAL_FORMAT, iformat,
- ]
- comp.SetParams(params)
- jpegdata = comp.Compress(1, imgdata)
- return jpegdata
-
-def decompress(jpegdata):
- global decomp
- import cl
- if decomp is None: decomp = cl.OpenDecompressor(cl.JPEG)
- headersize = decomp.ReadHeader(jpegdata)
- params = [cl.IMAGE_WIDTH, 0, cl.IMAGE_HEIGHT, 0, cl.INTERNAL_FORMAT, 0]
- decomp.GetParams(params)
- width, height, format = params[1], params[3], params[5]
- if format == cl.GRAYSCALE or options['forcegray']:
- format = cl.GRAYSCALE
- bytesperpixel = 1
- else:
- format = cl.RGBX
- bytesperpixel = 4
- # XXX How to support 'smooth'?
- params = [cl.ORIGINAL_FORMAT, format,
- cl.ORIENTATION, cl.BOTTOM_UP,
- cl.FRAME_BUFFER_SIZE, width*height*bytesperpixel]
- decomp.SetParams(params)
- imgdata = decomp.Decompress(1, jpegdata)
- return imgdata, width, height, bytesperpixel
-
-def setoption(name, value):
- if type(value) is not type(0):
- raise TypeError, 'jpeg.setoption: numeric options only'
- if name == 'forcegrey':
- name = 'forcegray'
- if not options.has_key(name):
- raise KeyError, 'jpeg.setoption: unknown option name'
- options[name] = int(value)
-
-def test():
- import sys
- if sys.argv[1:2] == ['-g']:
- del sys.argv[1]
- setoption('forcegray', 1)
- if not sys.argv[1:]:
- sys.argv.append('/usr/local/images/data/jpg/asterix.jpg')
- for file in sys.argv[1:]:
- show(file)
-
-def show(file):
- import gl, GL, DEVICE
- jpegdata = open(file, 'r').read()
- imgdata, width, height, bytesperpixel = decompress(jpegdata)
- gl.foreground()
- gl.prefsize(width, height)
- win = gl.winopen(file)
- if bytesperpixel == 1:
- gl.cmode()
- gl.pixmode(GL.PM_SIZE, 8)
- gl.gconfig()
- for i in range(256):
- gl.mapcolor(i, i, i, i)
- else:
- gl.RGBmode()
- gl.pixmode(GL.PM_SIZE, 32)
- gl.gconfig()
- gl.qdevice(DEVICE.REDRAW)
- gl.qdevice(DEVICE.ESCKEY)
- gl.qdevice(DEVICE.WINQUIT)
- gl.qdevice(DEVICE.WINSHUT)
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- while 1:
- dev, val = gl.qread()
- if dev in (DEVICE.ESCKEY, DEVICE.WINSHUT, DEVICE.WINQUIT):
- break
- if dev == DEVICE.REDRAW:
- gl.lrectwrite(0, 0, width-1, height-1, imgdata)
- gl.winclose(win)
- # Now test the compression and write the result to a fixed filename
- newjpegdata = compress(imgdata, width, height, bytesperpixel)
- open('/tmp/j.jpg', 'w').write(newjpegdata)
diff --git a/Lib/plat-irix6/panel.py b/Lib/plat-irix6/panel.py
deleted file mode 100644
index fcfa56b54d9..00000000000
--- a/Lib/plat-irix6/panel.py
+++ /dev/null
@@ -1,284 +0,0 @@
-# Module 'panel'
-#
-# Support for the Panel library.
-# Uses built-in module 'pnl'.
-# Applications should use 'panel.function' instead of 'pnl.function';
-# most 'pnl' functions are transparently exported by 'panel',
-# but dopanel() is overridden and you have to use this version
-# if you want to use callbacks.
-from warnings import warnpy3k
-warnpy3k("the panel module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-
-import pnl
-
-
-debug = 0
-
-
-# Test if an object is a list.
-#
-def is_list(x):
- return type(x) == type([])
-
-
-# Reverse a list.
-#
-def reverse(list):
- res = []
- for item in list:
- res.insert(0, item)
- return res
-
-
-# Get an attribute of a list, which may itself be another list.
-# Don't use 'prop' for name.
-#
-def getattrlist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == name:
- return item[1:]
- return []
-
-
-# Get a property of a list, which may itself be another list.
-#
-def getproplist(list, name):
- for item in list:
- if item and is_list(item) and item[0] == 'prop':
- if len(item) > 1 and item[1] == name:
- return item[2:]
- return []
-
-
-# Test if an actuator description contains the property 'end-of-group'
-#
-def is_endgroup(list):
- x = getproplist(list, 'end-of-group')
- return (x and x[0] == '#t')
-
-
-# Neatly display an actuator definition given as S-expression
-# the prefix string is printed before each line.
-#
-def show_actuator(prefix, a):
- for item in a:
- if not is_list(item):
- print prefix, item
- elif item and item[0] == 'al':
- print prefix, 'Subactuator list:'
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print prefix, item[0], '=>', item[1]
- elif len(item) == 3 and item[0] == 'prop':
- print prefix, 'Prop', item[1], '=>',
- print item[2]
- else:
- print prefix, '?', item
-
-
-# Neatly display a panel.
-#
-def show_panel(prefix, p):
- for item in p:
- if not is_list(item):
- print prefix, item
- elif item and item[0] == 'al':
- print prefix, 'Actuator list:'
- for a in item[1:]:
- show_actuator(prefix + ' ', a)
- elif len(item) == 2:
- print prefix, item[0], '=>', item[1]
- elif len(item) == 3 and item[0] == 'prop':
- print prefix, 'Prop', item[1], '=>',
- print item[2]
- else:
- print prefix, '?', item
-
-
-# Exception raised by build_actuator or build_panel.
-#
-panel_error = 'panel error'
-
-
-# Dummy callback used to initialize the callbacks.
-#
-def dummy_callback(arg):
- pass
-
-
-# Assign attributes to members of the target.
-# Attribute names in exclist are ignored.
-# The member name is the attribute name prefixed with the prefix.
-#
-def assign_members(target, attrlist, exclist, prefix):
- for item in attrlist:
- if is_list(item) and len(item) == 2 and item[0] not in exclist:
- name, value = item[0], item[1]
- ok = 1
- if value[0] in '-0123456789':
- value = eval(value)
- elif value[0] == '"':
- value = value[1:-1]
- elif value == 'move-then-resize':
- # Strange default set by Panel Editor...
- ok = 0
- else:
- print 'unknown value', value, 'for', name
- ok = 0
- if ok:
- lhs = 'target.' + prefix + name
- stmt = lhs + '=' + repr(value)
- if debug: print 'exec', stmt
- try:
- exec stmt + '\n'
- except KeyboardInterrupt: # Don't catch this!
- raise KeyboardInterrupt
- except:
- print 'assign failed:', stmt
-
-
-# Build a real actuator from an actuator description.
-# Return a pair (actuator, name).
-#
-def build_actuator(descr):
- namelist = getattrlist(descr, 'name')
- if namelist:
- # Assume it is a string
- actuatorname = namelist[0][1:-1]
- else:
- actuatorname = ''
- type = descr[0]
- if type[:4] == 'pnl_': type = type[4:]
- act = pnl.mkact(type)
- act.downfunc = act.activefunc = act.upfunc = dummy_callback
- #
- assign_members(act, descr[1:], ['al', 'data', 'name'], '')
- #
- # Treat actuator-specific data
- #
- datalist = getattrlist(descr, 'data')
- prefix = ''
- if type[-4:] == 'puck':
- prefix = 'puck_'
- elif type == 'mouse':
- prefix = 'mouse_'
- assign_members(act, datalist, [], prefix)
- #
- return act, actuatorname
-
-
-# Build all sub-actuators and add them to the super-actuator.
-# The super-actuator must already have been added to the panel.
-# Sub-actuators with defined names are added as members to the panel
-# so they can be referenced as p.name.
-#
-# Note: I have no idea how panel.endgroup() works when applied
-# to a sub-actuator.
-#
-def build_subactuators(panel, super_act, al):
- #
- # This is nearly the same loop as below in build_panel(),
- # except a call is made to addsubact() instead of addact().
- #
- for a in al:
- act, name = build_actuator(a)
- act.addsubact(super_act)
- if name:
- stmt = 'panel.' + name + ' = act'
- if debug: print 'exec', stmt
- exec stmt + '\n'
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- # Fix the actuator to which whe just added subactuators.
- # This can't hurt (I hope) and is needed for the scroll actuator.
- #
- super_act.fixact()
-
-
-# Build a real panel from a panel definition.
-# Return a panel object p, where for each named actuator a, p.name is a
-# reference to a.
-#
-def build_panel(descr):
- #
- # Sanity check
- #
- if (not descr) or descr[0] != 'panel':
- raise panel_error, 'panel description must start with "panel"'
- #
- if debug: show_panel('', descr)
- #
- # Create an empty panel
- #
- panel = pnl.mkpanel()
- #
- # Assign panel attributes
- #
- assign_members(panel, descr[1:], ['al'], '')
- #
- # Look for actuator list
- #
- al = getattrlist(descr, 'al')
- #
- # The order in which actuators are created is important
- # because of the endgroup() operator.
- # Unfortunately the Panel Editor outputs the actuator list
- # in reverse order, so we reverse it here.
- #
- al = reverse(al)
- #
- for a in al:
- act, name = build_actuator(a)
- act.addact(panel)
- if name:
- stmt = 'panel.' + name + ' = act'
- exec stmt + '\n'
- if is_endgroup(a):
- panel.endgroup()
- sub_al = getattrlist(a, 'al')
- if sub_al:
- build_subactuators(panel, act, sub_al)
- #
- return panel
-
-
-# Wrapper around pnl.dopanel() which calls call-back functions.
-#
-def my_dopanel():
- # Extract only the first 4 elements to allow for future expansion
- a, down, active, up = pnl.dopanel()[:4]
- if down:
- down.downfunc(down)
- if active:
- active.activefunc(active)
- if up:
- up.upfunc(up)
- return a
-
-
-# Create one or more panels from a description file (S-expressions)
-# generated by the Panel Editor.
-#
-def defpanellist(file):
- import panelparser
- descrlist = panelparser.parse_file(open(file, 'r'))
- panellist = []
- for descr in descrlist:
- panellist.append(build_panel(descr))
- return panellist
-
-
-# Import everything from built-in method pnl, so the user can always
-# use panel.foo() instead of pnl.foo().
-# This gives *no* performance penalty once this module is imported.
-#
-from pnl import * # for export
-
-dopanel = my_dopanel # override pnl.dopanel
diff --git a/Lib/plat-irix6/panelparser.py b/Lib/plat-irix6/panelparser.py
deleted file mode 100644
index 362156d4c19..00000000000
--- a/Lib/plat-irix6/panelparser.py
+++ /dev/null
@@ -1,131 +0,0 @@
-# Module 'parser'
-#
-# Parse S-expressions output by the Panel Editor
-# (which is written in Scheme so it can't help writing S-expressions).
-#
-# See notes at end of file.
-from warnings import warnpy3k
-warnpy3k("the panelparser module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-
-whitespace = ' \t\n'
-operators = '()\''
-separators = operators + whitespace + ';' + '"'
-
-
-# Tokenize a string.
-# Return a list of tokens (strings).
-#
-def tokenize_string(s):
- tokens = []
- while s:
- c = s[:1]
- if c in whitespace:
- s = s[1:]
- elif c == ';':
- s = ''
- elif c == '"':
- n = len(s)
- i = 1
- while i < n:
- c = s[i]
- i = i+1
- if c == '"': break
- if c == '\\': i = i+1
- tokens.append(s[:i])
- s = s[i:]
- elif c in operators:
- tokens.append(c)
- s = s[1:]
- else:
- n = len(s)
- i = 1
- while i < n:
- if s[i] in separators: break
- i = i+1
- tokens.append(s[:i])
- s = s[i:]
- return tokens
-
-
-# Tokenize a whole file (given as file object, not as file name).
-# Return a list of tokens (strings).
-#
-def tokenize_file(fp):
- tokens = []
- while 1:
- line = fp.readline()
- if not line: break
- tokens = tokens + tokenize_string(line)
- return tokens
-
-
-# Exception raised by parse_exr.
-#
-syntax_error = 'syntax error'
-
-
-# Parse an S-expression.
-# Input is a list of tokens as returned by tokenize_*().
-# Return a pair (expr, tokens)
-# where expr is a list representing the s-expression,
-# and tokens contains the remaining tokens.
-# May raise syntax_error.
-#
-def parse_expr(tokens):
- if (not tokens) or tokens[0] != '(':
- raise syntax_error, 'expected "("'
- tokens = tokens[1:]
- expr = []
- while 1:
- if not tokens:
- raise syntax_error, 'missing ")"'
- if tokens[0] == ')':
- return expr, tokens[1:]
- elif tokens[0] == '(':
- subexpr, tokens = parse_expr(tokens)
- expr.append(subexpr)
- else:
- expr.append(tokens[0])
- tokens = tokens[1:]
-
-
-# Parse a file (given as file object, not as file name).
-# Return a list of parsed S-expressions found at the top level.
-#
-def parse_file(fp):
- tokens = tokenize_file(fp)
- exprlist = []
- while tokens:
- expr, tokens = parse_expr(tokens)
- exprlist.append(expr)
- return exprlist
-
-
-# EXAMPLE:
-#
-# The input
-# '(hip (hop hur-ray))'
-#
-# passed to tokenize_string() returns the token list
-# ['(', 'hip', '(', 'hop', 'hur-ray', ')', ')']
-#
-# When this is passed to parse_expr() it returns the expression
-# ['hip', ['hop', 'hur-ray']]
-# plus an empty token list (because there are no tokens left.
-#
-# When a file containing the example is passed to parse_file() it returns
-# a list whose only element is the output of parse_expr() above:
-# [['hip', ['hop', 'hur-ray']]]
-
-
-# TOKENIZING:
-#
-# Comments start with semicolon (;) and continue till the end of the line.
-#
-# Tokens are separated by whitespace, except the following characters
-# always form a separate token (outside strings):
-# ( ) '
-# Strings are enclosed in double quotes (") and backslash (\) is used
-# as escape character in strings.
diff --git a/Lib/plat-irix6/readcd.doc b/Lib/plat-irix6/readcd.doc
deleted file mode 100644
index 1be549c7904..00000000000
--- a/Lib/plat-irix6/readcd.doc
+++ /dev/null
@@ -1,104 +0,0 @@
-Interface to CD-ROM player.
-
-This module implements an interface to the built-in cd module. The
-intention is to provide a more user-friendly interface than the
-built-in module.
-
-The module defines a class Readcd with several methods. The
-initialization of the class will try to open the CD player. This
-means that initialization will fail if the CD player is already in
-use. A RuntimeError will be raised by the cd module in that case.
-
-The way to work with this module is as follows. The user specifies
-the parts of the CD that are to be read and he specifies callback
-functions which are to be called by the system. At some point he can
-tell the system to play. The specified parts of the CD will then be
-read and the callbacks will be called.
-
-Initialization.
-===============
-
-r = readcd.Readcd([cd-player [, mode]])
-
-The optional arguments are the name of the CD device and the mode.
-When "mode" is not specified, it defaults to 'r' (which is the only
-possible value); when "cd-player" also isn't specified, it defaults
-to "None" which indicates the default CD player.
-
-Methods.
-========
-
-eject() -- Eject the CD from the player.
-
-reset() -- Reset the list of data stretches to be played.
-
-appendtrack(track) -- Append the specified track to the list of music
-stretches.
-
-appendstretch(first, last) -- Append the stretch from "first" to "last"
-to the list of music stretches. Both "first" and "last" can be in one
-of four forms. "None": for "first", the beginning of the CD, for
-"last" the end of the CD; a single integer: a track number--playing
-starts at the beginning of the track or ends at the end of the
-specified track; a three-tuple: the absolute time from the start of
-the CD in minutes, seconds, frames; a four-tuple: track number and
-relative time within the track in minutes, seconds, frames.
-
-settracks(tracklist) -- The argument is a list of integers. The list
-of stretches is set to argument list. The old list is discarded.
-
-setcallback(type, func, arg) -- Set a callback function for "type".
-The function will be called as func(arg, type, data) where "arg" is
-the third argument of setcallback, "type" is the type of callback,
-"data" is type-dependent data. See the CDsetcallback(3) manual page
-for more information. The possible "type" arguments are defined in
-the CD module.
-
-removecallback(type) -- Remove the callback for "type".
-
-gettrackinfo([tracklist]) -- Return a list of tuples. Each tuple
-consists of start and length information of a track. The start and
-length information consist of three-tuples with minutes, seconds and
-frames. The optional tracklist argument gives a list of interesting
-track numbers. If no tracklist is specified, information about all
-tracks is returned.
-
-getstatus() -- Return the status information of the CD.
-
-play() -- Play the preprogrammed stretches of music from the CD. When
-nothing was programmed, the whole CD is played.
-
-Specifying stretches.
-=====================
-
-There are three methods available to specify a stretch of music to be
-played. The easiest way is to use "settracklist(tracklist)" with which
-a list of tracks can be specified. "settracklist(tracklist)" is
-equivalent to the sequence
- reset()
- for track in tracklist:
- appendtrack(track)
-
-The next method is "appendtrack(track)" with which a whole track can be
-added to the list of music to be played. "appendtrack(track)" is
-equivalent to "appendstretch(track, track)".
-
-The most complete method is "appendstretch(first, last)". Using this
-method, it is possible to specify any stretch of music.
-
-When two consecutive tracks are played, it is possible to choose
-whether the pause that may be between the tracks is played as well or
-whether the pause should be skipped. When the end of a stretch is
-specified using a track number and the next stretch starts at the
-beginning of the following track and that was also specified using the
-track number (that is, both were specified as integers, not as tuples),
-the pause is played. When either value was specified using absolute
-time or track-relative time (that is, as three-tuple or as
-four-tuple), the pause will not be played.
-
-Errors.
-=======
-
-When an error occurs, an exception will be raised. Depending on where
-the error occurs, the exception may either be "readcd.Error" or
-"RuntimeError".
diff --git a/Lib/plat-irix6/readcd.py b/Lib/plat-irix6/readcd.py
deleted file mode 100644
index 54549e792cb..00000000000
--- a/Lib/plat-irix6/readcd.py
+++ /dev/null
@@ -1,247 +0,0 @@
-# Class interface to the CD module.
-from warnings import warnpy3k
-warnpy3k("the readcd module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import cd, CD
-
-class Error(Exception):
- pass
-class _Stop(Exception):
- pass
-
-def _doatime(self, cb_type, data):
- if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
-
-def _dopnum(self, cb_type, data):
- if data > self.end:
-## print 'done with list entry', repr(self.listindex)
- raise _Stop
- func, arg = self.callbacks[cb_type]
- if func:
- func(arg, cb_type, data)
-
-class Readcd:
- def __init__(self, *arg):
- if len(arg) == 0:
- self.player = cd.open()
- elif len(arg) == 1:
- self.player = cd.open(arg[0])
- elif len(arg) == 2:
- self.player = cd.open(arg[0], arg[1])
- else:
- raise Error, 'bad __init__ call'
- self.list = []
- self.callbacks = [(None, None)] * 8
- self.parser = cd.createparser()
- self.playing = 0
- self.end = 0
- self.status = None
- self.trackinfo = None
-
- def eject(self):
- self.player.eject()
- self.list = []
- self.end = 0
- self.listindex = 0
- self.status = None
- self.trackinfo = None
- if self.playing:
-## print 'stop playing from eject'
- raise _Stop
-
- def pmsf2msf(self, track, min, sec, frame):
- if not self.status:
- self.cachestatus()
- if track < self.status[5] or track > self.status[6]:
- raise Error, 'track number out of range'
- if not self.trackinfo:
- self.cacheinfo()
- start, total = self.trackinfo[track]
- start = ((start[0] * 60) + start[1]) * 75 + start[2]
- total = ((total[0] * 60) + total[1]) * 75 + total[2]
- block = ((min * 60) + sec) * 75 + frame
- if block > total:
- raise Error, 'out of range'
- block = start + block
- min, block = divmod(block, 75*60)
- sec, frame = divmod(block, 75)
- return min, sec, frame
-
- def reset(self):
- self.list = []
-
- def appendtrack(self, track):
- self.appendstretch(track, track)
-
- def appendstretch(self, start, end):
- if not self.status:
- self.cachestatus()
- if not start:
- start = 1
- if not end:
- end = self.status[6]
- if type(end) == type(0):
- if end < self.status[5] or end > self.status[6]:
- raise Error, 'range error'
- else:
- l = len(end)
- if l == 4:
- prog, min, sec, frame = end
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- end = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- if type(start) == type(0):
- if start < self.status[5] or start > self.status[6]:
- raise Error, 'range error'
- if len(self.list) > 0:
- s, e = self.list[-1]
- if type(e) == type(0):
- if start == e+1:
- start = s
- del self.list[-1]
- else:
- l = len(start)
- if l == 4:
- prog, min, sec, frame = start
- if prog < self.status[5] or prog > self.status[6]:
- raise Error, 'range error'
- start = self.pmsf2msf(prog, min, sec, frame)
- elif l != 3:
- raise Error, 'syntax error'
- self.list.append((start, end))
-
- def settracks(self, list):
- self.list = []
- for track in list:
- self.appendtrack(track)
-
- def setcallback(self, cb_type, func, arg):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (func, arg)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.setcallback(cb_type, func, arg)
- else:
- if cb_type != CD.ATIME:
- self.parser.setcallback(cb_type, func, arg)
-
- def removecallback(self, cb_type):
- if cb_type < 0 or cb_type >= 8:
- raise Error, 'type out of range'
- self.callbacks[cb_type] = (None, None)
- if self.playing:
- start, end = self.list[self.listindex]
- if type(end) == type(0):
- if cb_type != CD.PNUM:
- self.parser.removecallback(cb_type)
- else:
- if cb_type != CD.ATIME:
- self.parser.removecallback(cb_type)
-
- def gettrackinfo(self, *arg):
- if not self.status:
- self.cachestatus()
- if not self.trackinfo:
- self.cacheinfo()
- if len(arg) == 0:
- return self.trackinfo[self.status[5]:self.status[6]+1]
- result = []
- for i in arg:
- if i < self.status[5] or i > self.status[6]:
- raise Error, 'range error'
- result.append(self.trackinfo[i])
- return result
-
- def cacheinfo(self):
- if not self.status:
- self.cachestatus()
- self.trackinfo = []
- for i in range(self.status[5]):
- self.trackinfo.append(None)
- for i in range(self.status[5], self.status[6]+1):
- self.trackinfo.append(self.player.gettrackinfo(i))
-
- def cachestatus(self):
- self.status = self.player.getstatus()
- if self.status[0] == CD.NODISC:
- self.status = None
- raise Error, 'no disc in player'
-
- def getstatus(self):
- return self.player.getstatus()
-
- def play(self):
- if not self.status:
- self.cachestatus()
- size = self.player.bestreadsize()
- self.listindex = 0
- self.playing = 0
- for i in range(8):
- func, arg = self.callbacks[i]
- if func:
- self.parser.setcallback(i, func, arg)
- else:
- self.parser.removecallback(i)
- if len(self.list) == 0:
- for i in range(self.status[5], self.status[6]+1):
- self.appendtrack(i)
- try:
- while 1:
- if not self.playing:
- if self.listindex >= len(self.list):
- return
- start, end = self.list[self.listindex]
- if type(start) == type(0):
- dummy = self.player.seektrack(
- start)
- else:
- min, sec, frame = start
- dummy = self.player.seek(
- min, sec, frame)
- if type(end) == type(0):
- self.parser.setcallback(
- CD.PNUM, _dopnum, self)
- self.end = end
- func, arg = \
- self.callbacks[CD.ATIME]
- if func:
- self.parser.setcallback(CD.ATIME, func, arg)
- else:
- self.parser.removecallback(CD.ATIME)
- else:
- min, sec, frame = end
- self.parser.setcallback(
- CD.ATIME, _doatime,
- self)
- self.end = (min * 60 + sec) * \
- 75 + frame
- func, arg = \
- self.callbacks[CD.PNUM]
- if func:
- self.parser.setcallback(CD.PNUM, func, arg)
- else:
- self.parser.removecallback(CD.PNUM)
- self.playing = 1
- data = self.player.readda(size)
- if data == '':
- self.playing = 0
- self.listindex = self.listindex + 1
- continue
- try:
- self.parser.parseframe(data)
- except _Stop:
- self.playing = 0
- self.listindex = self.listindex + 1
- finally:
- self.playing = 0
diff --git a/Lib/plat-irix6/regen b/Lib/plat-irix6/regen
deleted file mode 100755
index 6a2cb408d9d..00000000000
--- a/Lib/plat-irix6/regen
+++ /dev/null
@@ -1,11 +0,0 @@
-#! /bin/sh
-case `uname -sr` in
-'IRIX '[456].*) ;;
-'IRIX64 '[456].*) ;;
-*) echo Probably not on an IRIX system 1>&2
- exit 1;;
-esac
-set -v
-h2py /usr/include/sys/file.h
-h2py -i '(u_long)' /usr/include/netinet/in.h
-h2py /usr/include/errno.h
diff --git a/Lib/plat-irix6/torgb.py b/Lib/plat-irix6/torgb.py
deleted file mode 100644
index 024d1ea4889..00000000000
--- a/Lib/plat-irix6/torgb.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# Convert "arbitrary" image files to rgb files (SGI's image format).
-# Input may be compressed.
-# The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster.
-# An exception is raised if the file is not of a recognized type.
-# Returned filename is either the input filename or a temporary filename;
-# in the latter case the caller must ensure that it is removed.
-# Other temporary files used are removed by the function.
-from warnings import warnpy3k
-warnpy3k("the torgb module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-import tempfile
-import pipes
-import imghdr
-
-table = {}
-
-t = pipes.Template()
-t.append('fromppm $IN $OUT', 'ff')
-table['ppm'] = t
-
-t = pipes.Template()
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['pnm'] = t
-table['pgm'] = t
-table['pbm'] = t
-
-t = pipes.Template()
-t.append('fromgif $IN $OUT', 'ff')
-table['gif'] = t
-
-t = pipes.Template()
-t.append('tifftopnm', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['tiff'] = t
-
-t = pipes.Template()
-t.append('rasttopnm', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['rast'] = t
-
-t = pipes.Template()
-t.append('djpeg', '--')
-t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--')
-t.append('fromppm $IN $OUT', 'ff')
-table['jpeg'] = t
-
-uncompress = pipes.Template()
-uncompress.append('uncompress', '--')
-
-
-class error(Exception):
- pass
-
-def torgb(filename):
- temps = []
- ret = None
- try:
- ret = _torgb(filename, temps)
- finally:
- for temp in temps[:]:
- if temp != ret:
- try:
- os.unlink(temp)
- except os.error:
- pass
- temps.remove(temp)
- return ret
-
-def _torgb(filename, temps):
- if filename[-2:] == '.Z':
- (fd, fname) = tempfile.mkstemp()
- os.close(fd)
- temps.append(fname)
- sts = uncompress.copy(filename, fname)
- if sts:
- raise error, filename + ': uncompress failed'
- else:
- fname = filename
- try:
- ftype = imghdr.what(fname)
- except IOError, msg:
- if type(msg) == type(()) and len(msg) == 2 and \
- type(msg[0]) == type(0) and type(msg[1]) == type(''):
- msg = msg[1]
- if type(msg) is not type(''):
- msg = repr(msg)
- raise error, filename + ': ' + msg
- if ftype == 'rgb':
- return fname
- if ftype is None or not table.has_key(ftype):
- raise error, '%s: unsupported image file type %r' % (filename, ftype)
- (fd, temp) = tempfile.mkstemp()
- os.close(fd)
- sts = table[ftype].copy(fname, temp)
- if sts:
- raise error, filename + ': conversion to rgb failed'
- return temp
diff --git a/Lib/plat-linux2/DLFCN.py b/Lib/plat-linux2/DLFCN.py
index e23340a13dc..dd10ac4ead7 100644
--- a/Lib/plat-linux2/DLFCN.py
+++ b/Lib/plat-linux2/DLFCN.py
@@ -7,7 +7,7 @@ __USE_ANSI = 1
__FAVOR_BSD = 1
_ISOC99_SOURCE = 1
_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_XOPEN_SOURCE = 600
_XOPEN_SOURCE_EXTENDED = 1
_LARGEFILE64_SOURCE = 1
@@ -18,7 +18,7 @@ _SVID_SOURCE = 1
__USE_ISOC99 = 1
_POSIX_SOURCE = 1
_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
__USE_POSIX = 1
__USE_POSIX2 = 1
__USE_POSIX199309 = 1
@@ -40,7 +40,7 @@ __USE_GNU = 1
__USE_REENTRANT = 1
__STDC_IEC_559__ = 1
__STDC_IEC_559_COMPLEX__ = 1
-__STDC_ISO_10646__ = 200009L
+__STDC_ISO_10646__ = 200009
__GNU_LIBRARY__ = 6
__GLIBC__ = 2
__GLIBC_MINOR__ = 2
diff --git a/Lib/plat-linux2/IN.py b/Lib/plat-linux2/IN.py
index ad307f65398..d7d30024c2c 100644
--- a/Lib/plat-linux2/IN.py
+++ b/Lib/plat-linux2/IN.py
@@ -7,7 +7,7 @@ __USE_ANSI = 1
__FAVOR_BSD = 1
_ISOC99_SOURCE = 1
_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_XOPEN_SOURCE = 600
_XOPEN_SOURCE_EXTENDED = 1
_LARGEFILE64_SOURCE = 1
@@ -18,7 +18,7 @@ _SVID_SOURCE = 1
__USE_ISOC99 = 1
_POSIX_SOURCE = 1
_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
__USE_POSIX = 1
__USE_POSIX2 = 1
__USE_POSIX199309 = 1
@@ -40,7 +40,7 @@ __USE_GNU = 1
__USE_REENTRANT = 1
__STDC_IEC_559__ = 1
__STDC_IEC_559_COMPLEX__ = 1
-__STDC_ISO_10646__ = 200009L
+__STDC_ISO_10646__ = 200009
__GNU_LIBRARY__ = 6
__GLIBC__ = 2
__GLIBC_MINOR__ = 2
@@ -78,8 +78,8 @@ _STDINT_H = 1
# Included from bits/wchar.h
_BITS_WCHAR_H = 1
-__WCHAR_MIN = (-2147483647l - 1l)
-__WCHAR_MAX = (2147483647l)
+__WCHAR_MIN = (-2147483647 - 1)
+__WCHAR_MAX = (2147483647)
# Included from bits/wordsize.h
__WORDSIZE = 32
@@ -114,28 +114,28 @@ UINT_LEAST8_MAX = (255)
UINT_LEAST16_MAX = (65535)
UINT_LEAST64_MAX = (__UINT64_C(18446744073709551615))
INT_FAST8_MIN = (-128)
-INT_FAST16_MIN = (-9223372036854775807L-1)
-INT_FAST32_MIN = (-9223372036854775807L-1)
+INT_FAST16_MIN = (-9223372036854775807-1)
+INT_FAST32_MIN = (-9223372036854775807-1)
INT_FAST16_MIN = (-2147483647-1)
INT_FAST32_MIN = (-2147483647-1)
INT_FAST64_MIN = (-__INT64_C(9223372036854775807)-1)
INT_FAST8_MAX = (127)
-INT_FAST16_MAX = (9223372036854775807L)
-INT_FAST32_MAX = (9223372036854775807L)
+INT_FAST16_MAX = (9223372036854775807)
+INT_FAST32_MAX = (9223372036854775807)
INT_FAST16_MAX = (2147483647)
INT_FAST32_MAX = (2147483647)
INT_FAST64_MAX = (__INT64_C(9223372036854775807))
UINT_FAST8_MAX = (255)
UINT_FAST64_MAX = (__UINT64_C(18446744073709551615))
-INTPTR_MIN = (-9223372036854775807L-1)
-INTPTR_MAX = (9223372036854775807L)
+INTPTR_MIN = (-9223372036854775807-1)
+INTPTR_MAX = (9223372036854775807)
INTPTR_MIN = (-2147483647-1)
INTPTR_MAX = (2147483647)
INTMAX_MIN = (-__INT64_C(9223372036854775807)-1)
INTMAX_MAX = (__INT64_C(9223372036854775807))
UINTMAX_MAX = (__UINT64_C(18446744073709551615))
-PTRDIFF_MIN = (-9223372036854775807L-1)
-PTRDIFF_MAX = (9223372036854775807L)
+PTRDIFF_MIN = (-9223372036854775807-1)
+PTRDIFF_MAX = (9223372036854775807)
PTRDIFF_MIN = (-2147483647-1)
PTRDIFF_MAX = (2147483647)
SIG_ATOMIC_MIN = (-2147483647-1)
@@ -238,9 +238,9 @@ SHRT_MIN = (-32768)
SHRT_MAX = 32767
USHRT_MAX = 65535
INT_MAX = 2147483647
-LONG_MAX = 9223372036854775807L
-LONG_MAX = 2147483647L
-LONG_MIN = (-LONG_MAX - 1L)
+LONG_MAX = 9223372036854775807
+LONG_MAX = 2147483647
+LONG_MIN = (-LONG_MAX - 1)
# Included from bits/posix1_lim.h
_BITS_POSIX1_LIM_H = 1
diff --git a/Lib/plat-linux2/TYPES.py b/Lib/plat-linux2/TYPES.py
index 0cdd5995dec..e7a324b25ab 100644
--- a/Lib/plat-linux2/TYPES.py
+++ b/Lib/plat-linux2/TYPES.py
@@ -7,7 +7,7 @@ __USE_ANSI = 1
__FAVOR_BSD = 1
_ISOC99_SOURCE = 1
_POSIX_SOURCE = 1
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_XOPEN_SOURCE = 600
_XOPEN_SOURCE_EXTENDED = 1
_LARGEFILE64_SOURCE = 1
@@ -18,7 +18,7 @@ _SVID_SOURCE = 1
__USE_ISOC99 = 1
_POSIX_SOURCE = 1
_POSIX_C_SOURCE = 2
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
__USE_POSIX = 1
__USE_POSIX2 = 1
__USE_POSIX199309 = 1
@@ -40,7 +40,7 @@ __USE_GNU = 1
__USE_REENTRANT = 1
__STDC_IEC_559__ = 1
__STDC_IEC_559_COMPLEX__ = 1
-__STDC_ISO_10646__ = 200009L
+__STDC_ISO_10646__ = 200009
__GNU_LIBRARY__ = 6
__GLIBC__ = 2
__GLIBC_MINOR__ = 2
@@ -99,7 +99,7 @@ _TIME_H = 1
# Included from bits/time.h
_BITS_TIME_H = 1
-CLOCKS_PER_SEC = 1000000l
+CLOCKS_PER_SEC = 1000000
CLOCK_REALTIME = 0
CLOCK_PROCESS_CPUTIME_ID = 2
CLOCK_THREAD_CPUTIME_ID = 3
diff --git a/Lib/plat-mac/Audio_mac.py b/Lib/plat-mac/Audio_mac.py
deleted file mode 100644
index ddf2a1cfd70..00000000000
--- a/Lib/plat-mac/Audio_mac.py
+++ /dev/null
@@ -1,124 +0,0 @@
-QSIZE = 100000
-error='Audio_mac.error'
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Play_Audio_mac module is removed.", stacklevel=2)
-
-class Play_Audio_mac:
-
- def __init__(self, qsize=QSIZE):
- self._chan = None
- self._qsize = qsize
- self._outrate = 22254
- self._sampwidth = 1
- self._nchannels = 1
- self._gc = []
- self._usercallback = None
-
- def __del__(self):
- self.stop()
- self._usercallback = None
-
- def wait(self):
- import time
- while self.getfilled():
- time.sleep(0.1)
- self._chan = None
- self._gc = []
-
- def stop(self, quietNow = 1):
- ##chan = self._chan
- self._chan = None
- ##chan.SndDisposeChannel(1)
- self._gc = []
-
- def setoutrate(self, outrate):
- self._outrate = outrate
-
- def setsampwidth(self, sampwidth):
- self._sampwidth = sampwidth
-
- def setnchannels(self, nchannels):
- self._nchannels = nchannels
-
- def writeframes(self, data):
- import time
- from Carbon.Sound import bufferCmd, callBackCmd, extSH
- import struct
- import MacOS
- if not self._chan:
- from Carbon import Snd
- self._chan = Snd.SndNewChannel(5, 0, self._callback)
- nframes = len(data) / self._nchannels / self._sampwidth
- if len(data) != nframes * self._nchannels * self._sampwidth:
- raise error, 'data is not a whole number of frames'
- while self._gc and \
- self.getfilled() + nframes > \
- self._qsize / self._nchannels / self._sampwidth:
- time.sleep(0.1)
- if self._sampwidth == 1:
- import audioop
- data = audioop.add(data, '\x80'*len(data), 1)
- h1 = struct.pack('llHhllbbl',
- id(data)+MacOS.string_id_to_buffer,
- self._nchannels,
- self._outrate, 0,
- 0,
- 0,
- extSH,
- 60,
- nframes)
- h2 = 22*'\0'
- h3 = struct.pack('hhlll',
- self._sampwidth*8,
- 0,
- 0,
- 0,
- 0)
- header = h1+h2+h3
- self._gc.append((header, data))
- self._chan.SndDoCommand((bufferCmd, 0, header), 0)
- self._chan.SndDoCommand((callBackCmd, 0, 0), 0)
-
- def _callback(self, *args):
- del self._gc[0]
- if self._usercallback:
- self._usercallback()
-
- def setcallback(self, callback):
- self._usercallback = callback
-
- def getfilled(self):
- filled = 0
- for header, data in self._gc:
- filled = filled + len(data)
- return filled / self._nchannels / self._sampwidth
-
- def getfillable(self):
- return (self._qsize / self._nchannels / self._sampwidth) - self.getfilled()
-
- def ulaw2lin(self, data):
- import audioop
- return audioop.ulaw2lin(data, 2)
-
-def test():
- import aifc
- import EasyDialogs
- fn = EasyDialogs.AskFileForOpen(message="Select an AIFF soundfile", typeList=("AIFF",))
- if not fn: return
- af = aifc.open(fn, 'r')
- print af.getparams()
- p = Play_Audio_mac()
- p.setoutrate(af.getframerate())
- p.setsampwidth(af.getsampwidth())
- p.setnchannels(af.getnchannels())
- BUFSIZ = 10000
- while 1:
- data = af.readframes(BUFSIZ)
- if not data: break
- p.writeframes(data)
- print 'wrote', len(data), 'space', p.getfillable()
- p.wait()
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/plat-mac/Carbon/AE.py b/Lib/plat-mac/Carbon/AE.py
deleted file mode 100644
index 0f460177327..00000000000
--- a/Lib/plat-mac/Carbon/AE.py
+++ /dev/null
@@ -1 +0,0 @@
-from _AE import *
diff --git a/Lib/plat-mac/Carbon/AH.py b/Lib/plat-mac/Carbon/AH.py
deleted file mode 100644
index 0701e7bd87b..00000000000
--- a/Lib/plat-mac/Carbon/AH.py
+++ /dev/null
@@ -1 +0,0 @@
-from _AH import *
diff --git a/Lib/plat-mac/Carbon/Alias.py b/Lib/plat-mac/Carbon/Alias.py
deleted file mode 100644
index cb612a66b0a..00000000000
--- a/Lib/plat-mac/Carbon/Alias.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Alias import *
diff --git a/Lib/plat-mac/Carbon/Aliases.py b/Lib/plat-mac/Carbon/Aliases.py
deleted file mode 100644
index 55e1a1f5a7b..00000000000
--- a/Lib/plat-mac/Carbon/Aliases.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Generated from 'Aliases.h'
-
-def FOUR_CHAR_CODE(x): return x
-true = True
-false = False
-rAliasType = FOUR_CHAR_CODE('alis')
-kARMMountVol = 0x00000001
-kARMNoUI = 0x00000002
-kARMMultVols = 0x00000008
-kARMSearch = 0x00000100
-kARMSearchMore = 0x00000200
-kARMSearchRelFirst = 0x00000400
-asiZoneName = -3
-asiServerName = -2
-asiVolumeName = -1
-asiAliasName = 0
-asiParentName = 1
-kResolveAliasFileNoUI = 0x00000001
diff --git a/Lib/plat-mac/Carbon/App.py b/Lib/plat-mac/Carbon/App.py
deleted file mode 100644
index cc0d46d5d03..00000000000
--- a/Lib/plat-mac/Carbon/App.py
+++ /dev/null
@@ -1 +0,0 @@
-from _App import *
diff --git a/Lib/plat-mac/Carbon/Appearance.py b/Lib/plat-mac/Carbon/Appearance.py
deleted file mode 100644
index d99c6dce0a6..00000000000
--- a/Lib/plat-mac/Carbon/Appearance.py
+++ /dev/null
@@ -1,648 +0,0 @@
-# Generated from 'Appearance.h'
-
-def FOUR_CHAR_CODE(x): return x
-kAppearanceEventClass = FOUR_CHAR_CODE('appr')
-kAEAppearanceChanged = FOUR_CHAR_CODE('thme')
-kAESystemFontChanged = FOUR_CHAR_CODE('sysf')
-kAESmallSystemFontChanged = FOUR_CHAR_CODE('ssfn')
-kAEViewsFontChanged = FOUR_CHAR_CODE('vfnt')
-kThemeDataFileType = FOUR_CHAR_CODE('thme')
-kThemePlatinumFileType = FOUR_CHAR_CODE('pltn')
-kThemeCustomThemesFileType = FOUR_CHAR_CODE('scen')
-kThemeSoundTrackFileType = FOUR_CHAR_CODE('tsnd')
-kThemeBrushDialogBackgroundActive = 1
-kThemeBrushDialogBackgroundInactive = 2
-kThemeBrushAlertBackgroundActive = 3
-kThemeBrushAlertBackgroundInactive = 4
-kThemeBrushModelessDialogBackgroundActive = 5
-kThemeBrushModelessDialogBackgroundInactive = 6
-kThemeBrushUtilityWindowBackgroundActive = 7
-kThemeBrushUtilityWindowBackgroundInactive = 8
-kThemeBrushListViewSortColumnBackground = 9
-kThemeBrushListViewBackground = 10
-kThemeBrushIconLabelBackground = 11
-kThemeBrushListViewSeparator = 12
-kThemeBrushChasingArrows = 13
-kThemeBrushDragHilite = 14
-kThemeBrushDocumentWindowBackground = 15
-kThemeBrushFinderWindowBackground = 16
-kThemeBrushScrollBarDelimiterActive = 17
-kThemeBrushScrollBarDelimiterInactive = 18
-kThemeBrushFocusHighlight = 19
-kThemeBrushPopupArrowActive = 20
-kThemeBrushPopupArrowPressed = 21
-kThemeBrushPopupArrowInactive = 22
-kThemeBrushAppleGuideCoachmark = 23
-kThemeBrushIconLabelBackgroundSelected = 24
-kThemeBrushStaticAreaFill = 25
-kThemeBrushActiveAreaFill = 26
-kThemeBrushButtonFrameActive = 27
-kThemeBrushButtonFrameInactive = 28
-kThemeBrushButtonFaceActive = 29
-kThemeBrushButtonFaceInactive = 30
-kThemeBrushButtonFacePressed = 31
-kThemeBrushButtonActiveDarkShadow = 32
-kThemeBrushButtonActiveDarkHighlight = 33
-kThemeBrushButtonActiveLightShadow = 34
-kThemeBrushButtonActiveLightHighlight = 35
-kThemeBrushButtonInactiveDarkShadow = 36
-kThemeBrushButtonInactiveDarkHighlight = 37
-kThemeBrushButtonInactiveLightShadow = 38
-kThemeBrushButtonInactiveLightHighlight = 39
-kThemeBrushButtonPressedDarkShadow = 40
-kThemeBrushButtonPressedDarkHighlight = 41
-kThemeBrushButtonPressedLightShadow = 42
-kThemeBrushButtonPressedLightHighlight = 43
-kThemeBrushBevelActiveLight = 44
-kThemeBrushBevelActiveDark = 45
-kThemeBrushBevelInactiveLight = 46
-kThemeBrushBevelInactiveDark = 47
-kThemeBrushNotificationWindowBackground = 48
-kThemeBrushMovableModalBackground = 49
-kThemeBrushSheetBackgroundOpaque = 50
-kThemeBrushDrawerBackground = 51
-kThemeBrushToolbarBackground = 52
-kThemeBrushSheetBackgroundTransparent = 53
-kThemeBrushMenuBackground = 54
-kThemeBrushMenuBackgroundSelected = 55
-kThemeBrushSheetBackground = kThemeBrushSheetBackgroundOpaque
-kThemeBrushBlack = -1
-kThemeBrushWhite = -2
-kThemeBrushPrimaryHighlightColor = -3
-kThemeBrushSecondaryHighlightColor = -4
-kThemeTextColorDialogActive = 1
-kThemeTextColorDialogInactive = 2
-kThemeTextColorAlertActive = 3
-kThemeTextColorAlertInactive = 4
-kThemeTextColorModelessDialogActive = 5
-kThemeTextColorModelessDialogInactive = 6
-kThemeTextColorWindowHeaderActive = 7
-kThemeTextColorWindowHeaderInactive = 8
-kThemeTextColorPlacardActive = 9
-kThemeTextColorPlacardInactive = 10
-kThemeTextColorPlacardPressed = 11
-kThemeTextColorPushButtonActive = 12
-kThemeTextColorPushButtonInactive = 13
-kThemeTextColorPushButtonPressed = 14
-kThemeTextColorBevelButtonActive = 15
-kThemeTextColorBevelButtonInactive = 16
-kThemeTextColorBevelButtonPressed = 17
-kThemeTextColorPopupButtonActive = 18
-kThemeTextColorPopupButtonInactive = 19
-kThemeTextColorPopupButtonPressed = 20
-kThemeTextColorIconLabel = 21
-kThemeTextColorListView = 22
-kThemeTextColorDocumentWindowTitleActive = 23
-kThemeTextColorDocumentWindowTitleInactive = 24
-kThemeTextColorMovableModalWindowTitleActive = 25
-kThemeTextColorMovableModalWindowTitleInactive = 26
-kThemeTextColorUtilityWindowTitleActive = 27
-kThemeTextColorUtilityWindowTitleInactive = 28
-kThemeTextColorPopupWindowTitleActive = 29
-kThemeTextColorPopupWindowTitleInactive = 30
-kThemeTextColorRootMenuActive = 31
-kThemeTextColorRootMenuSelected = 32
-kThemeTextColorRootMenuDisabled = 33
-kThemeTextColorMenuItemActive = 34
-kThemeTextColorMenuItemSelected = 35
-kThemeTextColorMenuItemDisabled = 36
-kThemeTextColorPopupLabelActive = 37
-kThemeTextColorPopupLabelInactive = 38
-kThemeTextColorTabFrontActive = 39
-kThemeTextColorTabNonFrontActive = 40
-kThemeTextColorTabNonFrontPressed = 41
-kThemeTextColorTabFrontInactive = 42
-kThemeTextColorTabNonFrontInactive = 43
-kThemeTextColorIconLabelSelected = 44
-kThemeTextColorBevelButtonStickyActive = 45
-kThemeTextColorBevelButtonStickyInactive = 46
-kThemeTextColorNotification = 47
-kThemeTextColorBlack = -1
-kThemeTextColorWhite = -2
-kThemeStateInactive = 0
-kThemeStateActive = 1
-kThemeStatePressed = 2
-kThemeStateRollover = 6
-kThemeStateUnavailable = 7
-kThemeStateUnavailableInactive = 8
-kThemeStateDisabled = 0
-kThemeStatePressedUp = 2
-kThemeStatePressedDown = 3
-kThemeArrowCursor = 0
-kThemeCopyArrowCursor = 1
-kThemeAliasArrowCursor = 2
-kThemeContextualMenuArrowCursor = 3
-kThemeIBeamCursor = 4
-kThemeCrossCursor = 5
-kThemePlusCursor = 6
-kThemeWatchCursor = 7
-kThemeClosedHandCursor = 8
-kThemeOpenHandCursor = 9
-kThemePointingHandCursor = 10
-kThemeCountingUpHandCursor = 11
-kThemeCountingDownHandCursor = 12
-kThemeCountingUpAndDownHandCursor = 13
-kThemeSpinningCursor = 14
-kThemeResizeLeftCursor = 15
-kThemeResizeRightCursor = 16
-kThemeResizeLeftRightCursor = 17
-kThemeMenuBarNormal = 0
-kThemeMenuBarSelected = 1
-kThemeMenuSquareMenuBar = (1 << 0)
-kThemeMenuActive = 0
-kThemeMenuSelected = 1
-kThemeMenuDisabled = 3
-kThemeMenuTypePullDown = 0
-kThemeMenuTypePopUp = 1
-kThemeMenuTypeHierarchical = 2
-kThemeMenuTypeInactive = 0x0100
-kThemeMenuItemPlain = 0
-kThemeMenuItemHierarchical = 1
-kThemeMenuItemScrollUpArrow = 2
-kThemeMenuItemScrollDownArrow = 3
-kThemeMenuItemAtTop = 0x0100
-kThemeMenuItemAtBottom = 0x0200
-kThemeMenuItemHierBackground = 0x0400
-kThemeMenuItemPopUpBackground = 0x0800
-kThemeMenuItemHasIcon = 0x8000
-kThemeMenuItemNoBackground = 0x4000
-kThemeBackgroundTabPane = 1
-kThemeBackgroundPlacard = 2
-kThemeBackgroundWindowHeader = 3
-kThemeBackgroundListViewWindowHeader = 4
-kThemeBackgroundSecondaryGroupBox = 5
-kThemeNameTag = FOUR_CHAR_CODE('name')
-kThemeVariantNameTag = FOUR_CHAR_CODE('varn')
-kThemeVariantBaseTintTag = FOUR_CHAR_CODE('tint')
-kThemeHighlightColorTag = FOUR_CHAR_CODE('hcol')
-kThemeScrollBarArrowStyleTag = FOUR_CHAR_CODE('sbar')
-kThemeScrollBarThumbStyleTag = FOUR_CHAR_CODE('sbth')
-kThemeSoundsEnabledTag = FOUR_CHAR_CODE('snds')
-kThemeDblClickCollapseTag = FOUR_CHAR_CODE('coll')
-kThemeAppearanceFileNameTag = FOUR_CHAR_CODE('thme')
-kThemeSystemFontTag = FOUR_CHAR_CODE('lgsf')
-kThemeSmallSystemFontTag = FOUR_CHAR_CODE('smsf')
-kThemeViewsFontTag = FOUR_CHAR_CODE('vfnt')
-kThemeViewsFontSizeTag = FOUR_CHAR_CODE('vfsz')
-kThemeDesktopPatternNameTag = FOUR_CHAR_CODE('patn')
-kThemeDesktopPatternTag = FOUR_CHAR_CODE('patt')
-kThemeDesktopPictureNameTag = FOUR_CHAR_CODE('dpnm')
-kThemeDesktopPictureAliasTag = FOUR_CHAR_CODE('dpal')
-kThemeDesktopPictureAlignmentTag = FOUR_CHAR_CODE('dpan')
-kThemeHighlightColorNameTag = FOUR_CHAR_CODE('hcnm')
-kThemeExamplePictureIDTag = FOUR_CHAR_CODE('epic')
-kThemeSoundTrackNameTag = FOUR_CHAR_CODE('sndt')
-kThemeSoundMaskTag = FOUR_CHAR_CODE('smsk')
-kThemeUserDefinedTag = FOUR_CHAR_CODE('user')
-kThemeSmoothFontEnabledTag = FOUR_CHAR_CODE('smoo')
-kThemeSmoothFontMinSizeTag = FOUR_CHAR_CODE('smos')
-kTiledOnScreen = 1
-kCenterOnScreen = 2
-kFitToScreen = 3
-kFillScreen = 4
-kUseBestGuess = 5
-kThemeCheckBoxClassicX = 0
-kThemeCheckBoxCheckMark = 1
-kThemeScrollBarArrowsSingle = 0
-kThemeScrollBarArrowsLowerRight = 1
-kThemeScrollBarThumbNormal = 0
-kThemeScrollBarThumbProportional = 1
-kThemeSystemFont = 0
-kThemeSmallSystemFont = 1
-kThemeSmallEmphasizedSystemFont = 2
-kThemeViewsFont = 3
-kThemeEmphasizedSystemFont = 4
-kThemeApplicationFont = 5
-kThemeLabelFont = 6
-kThemeMenuTitleFont = 100
-kThemeMenuItemFont = 101
-kThemeMenuItemMarkFont = 102
-kThemeMenuItemCmdKeyFont = 103
-kThemeWindowTitleFont = 104
-kThemePushButtonFont = 105
-kThemeUtilityWindowTitleFont = 106
-kThemeAlertHeaderFont = 107
-kThemeCurrentPortFont = 200
-kThemeTabNonFront = 0
-kThemeTabNonFrontPressed = 1
-kThemeTabNonFrontInactive = 2
-kThemeTabFront = 3
-kThemeTabFrontInactive = 4
-kThemeTabNonFrontUnavailable = 5
-kThemeTabFrontUnavailable = 6
-kThemeTabNorth = 0
-kThemeTabSouth = 1
-kThemeTabEast = 2
-kThemeTabWest = 3
-kThemeSmallTabHeight = 16
-kThemeLargeTabHeight = 21
-kThemeTabPaneOverlap = 3
-kThemeSmallTabHeightMax = 19
-kThemeLargeTabHeightMax = 24
-kThemeMediumScrollBar = 0
-kThemeSmallScrollBar = 1
-kThemeMediumSlider = 2
-kThemeMediumProgressBar = 3
-kThemeMediumIndeterminateBar = 4
-kThemeRelevanceBar = 5
-kThemeSmallSlider = 6
-kThemeLargeProgressBar = 7
-kThemeLargeIndeterminateBar = 8
-kThemeTrackActive = 0
-kThemeTrackDisabled = 1
-kThemeTrackNothingToScroll = 2
-kThemeTrackInactive = 3
-kThemeLeftOutsideArrowPressed = 0x01
-kThemeLeftInsideArrowPressed = 0x02
-kThemeLeftTrackPressed = 0x04
-kThemeThumbPressed = 0x08
-kThemeRightTrackPressed = 0x10
-kThemeRightInsideArrowPressed = 0x20
-kThemeRightOutsideArrowPressed = 0x40
-kThemeTopOutsideArrowPressed = kThemeLeftOutsideArrowPressed
-kThemeTopInsideArrowPressed = kThemeLeftInsideArrowPressed
-kThemeTopTrackPressed = kThemeLeftTrackPressed
-kThemeBottomTrackPressed = kThemeRightTrackPressed
-kThemeBottomInsideArrowPressed = kThemeRightInsideArrowPressed
-kThemeBottomOutsideArrowPressed = kThemeRightOutsideArrowPressed
-kThemeThumbPlain = 0
-kThemeThumbUpward = 1
-kThemeThumbDownward = 2
-kThemeTrackHorizontal = (1 << 0)
-kThemeTrackRightToLeft = (1 << 1)
-kThemeTrackShowThumb = (1 << 2)
-kThemeTrackThumbRgnIsNotGhost = (1 << 3)
-kThemeTrackNoScrollBarArrows = (1 << 4)
-kThemeWindowHasGrow = (1 << 0)
-kThemeWindowHasHorizontalZoom = (1 << 3)
-kThemeWindowHasVerticalZoom = (1 << 4)
-kThemeWindowHasFullZoom = kThemeWindowHasHorizontalZoom + kThemeWindowHasVerticalZoom
-kThemeWindowHasCloseBox = (1 << 5)
-kThemeWindowHasCollapseBox = (1 << 6)
-kThemeWindowHasTitleText = (1 << 7)
-kThemeWindowIsCollapsed = (1 << 8)
-kThemeWindowHasDirty = (1 << 9)
-kThemeDocumentWindow = 0
-kThemeDialogWindow = 1
-kThemeMovableDialogWindow = 2
-kThemeAlertWindow = 3
-kThemeMovableAlertWindow = 4
-kThemePlainDialogWindow = 5
-kThemeShadowDialogWindow = 6
-kThemePopupWindow = 7
-kThemeUtilityWindow = 8
-kThemeUtilitySideWindow = 9
-kThemeSheetWindow = 10
-kThemeDrawerWindow = 11
-kThemeWidgetCloseBox = 0
-kThemeWidgetZoomBox = 1
-kThemeWidgetCollapseBox = 2
-kThemeWidgetDirtyCloseBox = 6
-kThemeArrowLeft = 0
-kThemeArrowDown = 1
-kThemeArrowRight = 2
-kThemeArrowUp = 3
-kThemeArrow3pt = 0
-kThemeArrow5pt = 1
-kThemeArrow7pt = 2
-kThemeArrow9pt = 3
-kThemeGrowLeft = (1 << 0)
-kThemeGrowRight = (1 << 1)
-kThemeGrowUp = (1 << 2)
-kThemeGrowDown = (1 << 3)
-kThemePushButton = 0
-kThemeCheckBox = 1
-kThemeRadioButton = 2
-kThemeBevelButton = 3
-kThemeArrowButton = 4
-kThemePopupButton = 5
-kThemeDisclosureButton = 6
-kThemeIncDecButton = 7
-kThemeSmallBevelButton = 8
-kThemeMediumBevelButton = 3
-kThemeLargeBevelButton = 9
-kThemeListHeaderButton = 10
-kThemeRoundButton = 11
-kThemeLargeRoundButton = 12
-kThemeSmallCheckBox = 13
-kThemeSmallRadioButton = 14
-kThemeRoundedBevelButton = 15
-kThemeNormalCheckBox = kThemeCheckBox
-kThemeNormalRadioButton = kThemeRadioButton
-kThemeButtonOff = 0
-kThemeButtonOn = 1
-kThemeButtonMixed = 2
-kThemeDisclosureRight = 0
-kThemeDisclosureDown = 1
-kThemeDisclosureLeft = 2
-kThemeAdornmentNone = 0
-kThemeAdornmentDefault = (1 << 0)
-kThemeAdornmentFocus = (1 << 2)
-kThemeAdornmentRightToLeft = (1 << 4)
-kThemeAdornmentDrawIndicatorOnly = (1 << 5)
-kThemeAdornmentHeaderButtonLeftNeighborSelected = (1 << 6)
-kThemeAdornmentHeaderButtonRightNeighborSelected = (1 << 7)
-kThemeAdornmentHeaderButtonSortUp = (1 << 8)
-kThemeAdornmentHeaderMenuButton = (1 << 9)
-kThemeAdornmentHeaderButtonNoShadow = (1 << 10)
-kThemeAdornmentHeaderButtonShadowOnly = (1 << 11)
-kThemeAdornmentNoShadow = kThemeAdornmentHeaderButtonNoShadow
-kThemeAdornmentShadowOnly = kThemeAdornmentHeaderButtonShadowOnly
-kThemeAdornmentArrowLeftArrow = (1 << 6)
-kThemeAdornmentArrowDownArrow = (1 << 7)
-kThemeAdornmentArrowDoubleArrow = (1 << 8)
-kThemeAdornmentArrowUpArrow = (1 << 9)
-kThemeNoSounds = 0
-kThemeWindowSoundsMask = (1 << 0)
-kThemeMenuSoundsMask = (1 << 1)
-kThemeControlSoundsMask = (1 << 2)
-kThemeFinderSoundsMask = (1 << 3)
-kThemeDragSoundNone = 0
-kThemeDragSoundMoveWindow = FOUR_CHAR_CODE('wmov')
-kThemeDragSoundGrowWindow = FOUR_CHAR_CODE('wgro')
-kThemeDragSoundMoveUtilWindow = FOUR_CHAR_CODE('umov')
-kThemeDragSoundGrowUtilWindow = FOUR_CHAR_CODE('ugro')
-kThemeDragSoundMoveDialog = FOUR_CHAR_CODE('dmov')
-kThemeDragSoundMoveAlert = FOUR_CHAR_CODE('amov')
-kThemeDragSoundMoveIcon = FOUR_CHAR_CODE('imov')
-kThemeDragSoundSliderThumb = FOUR_CHAR_CODE('slth')
-kThemeDragSoundSliderGhost = FOUR_CHAR_CODE('slgh')
-kThemeDragSoundScrollBarThumb = FOUR_CHAR_CODE('sbth')
-kThemeDragSoundScrollBarGhost = FOUR_CHAR_CODE('sbgh')
-kThemeDragSoundScrollBarArrowDecreasing = FOUR_CHAR_CODE('sbad')
-kThemeDragSoundScrollBarArrowIncreasing = FOUR_CHAR_CODE('sbai')
-kThemeDragSoundDragging = FOUR_CHAR_CODE('drag')
-kThemeSoundNone = 0
-kThemeSoundMenuOpen = FOUR_CHAR_CODE('mnuo')
-kThemeSoundMenuClose = FOUR_CHAR_CODE('mnuc')
-kThemeSoundMenuItemHilite = FOUR_CHAR_CODE('mnui')
-kThemeSoundMenuItemRelease = FOUR_CHAR_CODE('mnus')
-kThemeSoundWindowClosePress = FOUR_CHAR_CODE('wclp')
-kThemeSoundWindowCloseEnter = FOUR_CHAR_CODE('wcle')
-kThemeSoundWindowCloseExit = FOUR_CHAR_CODE('wclx')
-kThemeSoundWindowCloseRelease = FOUR_CHAR_CODE('wclr')
-kThemeSoundWindowZoomPress = FOUR_CHAR_CODE('wzmp')
-kThemeSoundWindowZoomEnter = FOUR_CHAR_CODE('wzme')
-kThemeSoundWindowZoomExit = FOUR_CHAR_CODE('wzmx')
-kThemeSoundWindowZoomRelease = FOUR_CHAR_CODE('wzmr')
-kThemeSoundWindowCollapsePress = FOUR_CHAR_CODE('wcop')
-kThemeSoundWindowCollapseEnter = FOUR_CHAR_CODE('wcoe')
-kThemeSoundWindowCollapseExit = FOUR_CHAR_CODE('wcox')
-kThemeSoundWindowCollapseRelease = FOUR_CHAR_CODE('wcor')
-kThemeSoundWindowDragBoundary = FOUR_CHAR_CODE('wdbd')
-kThemeSoundUtilWinClosePress = FOUR_CHAR_CODE('uclp')
-kThemeSoundUtilWinCloseEnter = FOUR_CHAR_CODE('ucle')
-kThemeSoundUtilWinCloseExit = FOUR_CHAR_CODE('uclx')
-kThemeSoundUtilWinCloseRelease = FOUR_CHAR_CODE('uclr')
-kThemeSoundUtilWinZoomPress = FOUR_CHAR_CODE('uzmp')
-kThemeSoundUtilWinZoomEnter = FOUR_CHAR_CODE('uzme')
-kThemeSoundUtilWinZoomExit = FOUR_CHAR_CODE('uzmx')
-kThemeSoundUtilWinZoomRelease = FOUR_CHAR_CODE('uzmr')
-kThemeSoundUtilWinCollapsePress = FOUR_CHAR_CODE('ucop')
-kThemeSoundUtilWinCollapseEnter = FOUR_CHAR_CODE('ucoe')
-kThemeSoundUtilWinCollapseExit = FOUR_CHAR_CODE('ucox')
-kThemeSoundUtilWinCollapseRelease = FOUR_CHAR_CODE('ucor')
-kThemeSoundUtilWinDragBoundary = FOUR_CHAR_CODE('udbd')
-kThemeSoundWindowOpen = FOUR_CHAR_CODE('wopn')
-kThemeSoundWindowClose = FOUR_CHAR_CODE('wcls')
-kThemeSoundWindowZoomIn = FOUR_CHAR_CODE('wzmi')
-kThemeSoundWindowZoomOut = FOUR_CHAR_CODE('wzmo')
-kThemeSoundWindowCollapseUp = FOUR_CHAR_CODE('wcol')
-kThemeSoundWindowCollapseDown = FOUR_CHAR_CODE('wexp')
-kThemeSoundWindowActivate = FOUR_CHAR_CODE('wact')
-kThemeSoundUtilWindowOpen = FOUR_CHAR_CODE('uopn')
-kThemeSoundUtilWindowClose = FOUR_CHAR_CODE('ucls')
-kThemeSoundUtilWindowZoomIn = FOUR_CHAR_CODE('uzmi')
-kThemeSoundUtilWindowZoomOut = FOUR_CHAR_CODE('uzmo')
-kThemeSoundUtilWindowCollapseUp = FOUR_CHAR_CODE('ucol')
-kThemeSoundUtilWindowCollapseDown = FOUR_CHAR_CODE('uexp')
-kThemeSoundUtilWindowActivate = FOUR_CHAR_CODE('uact')
-kThemeSoundDialogOpen = FOUR_CHAR_CODE('dopn')
-kThemeSoundDialogClose = FOUR_CHAR_CODE('dlgc')
-kThemeSoundAlertOpen = FOUR_CHAR_CODE('aopn')
-kThemeSoundAlertClose = FOUR_CHAR_CODE('altc')
-kThemeSoundPopupWindowOpen = FOUR_CHAR_CODE('pwop')
-kThemeSoundPopupWindowClose = FOUR_CHAR_CODE('pwcl')
-kThemeSoundButtonPress = FOUR_CHAR_CODE('btnp')
-kThemeSoundButtonEnter = FOUR_CHAR_CODE('btne')
-kThemeSoundButtonExit = FOUR_CHAR_CODE('btnx')
-kThemeSoundButtonRelease = FOUR_CHAR_CODE('btnr')
-kThemeSoundDefaultButtonPress = FOUR_CHAR_CODE('dbtp')
-kThemeSoundDefaultButtonEnter = FOUR_CHAR_CODE('dbte')
-kThemeSoundDefaultButtonExit = FOUR_CHAR_CODE('dbtx')
-kThemeSoundDefaultButtonRelease = FOUR_CHAR_CODE('dbtr')
-kThemeSoundCancelButtonPress = FOUR_CHAR_CODE('cbtp')
-kThemeSoundCancelButtonEnter = FOUR_CHAR_CODE('cbte')
-kThemeSoundCancelButtonExit = FOUR_CHAR_CODE('cbtx')
-kThemeSoundCancelButtonRelease = FOUR_CHAR_CODE('cbtr')
-kThemeSoundCheckboxPress = FOUR_CHAR_CODE('chkp')
-kThemeSoundCheckboxEnter = FOUR_CHAR_CODE('chke')
-kThemeSoundCheckboxExit = FOUR_CHAR_CODE('chkx')
-kThemeSoundCheckboxRelease = FOUR_CHAR_CODE('chkr')
-kThemeSoundRadioPress = FOUR_CHAR_CODE('radp')
-kThemeSoundRadioEnter = FOUR_CHAR_CODE('rade')
-kThemeSoundRadioExit = FOUR_CHAR_CODE('radx')
-kThemeSoundRadioRelease = FOUR_CHAR_CODE('radr')
-kThemeSoundScrollArrowPress = FOUR_CHAR_CODE('sbap')
-kThemeSoundScrollArrowEnter = FOUR_CHAR_CODE('sbae')
-kThemeSoundScrollArrowExit = FOUR_CHAR_CODE('sbax')
-kThemeSoundScrollArrowRelease = FOUR_CHAR_CODE('sbar')
-kThemeSoundScrollEndOfTrack = FOUR_CHAR_CODE('sbte')
-kThemeSoundScrollTrackPress = FOUR_CHAR_CODE('sbtp')
-kThemeSoundSliderEndOfTrack = FOUR_CHAR_CODE('slte')
-kThemeSoundSliderTrackPress = FOUR_CHAR_CODE('sltp')
-kThemeSoundBalloonOpen = FOUR_CHAR_CODE('blno')
-kThemeSoundBalloonClose = FOUR_CHAR_CODE('blnc')
-kThemeSoundBevelPress = FOUR_CHAR_CODE('bevp')
-kThemeSoundBevelEnter = FOUR_CHAR_CODE('beve')
-kThemeSoundBevelExit = FOUR_CHAR_CODE('bevx')
-kThemeSoundBevelRelease = FOUR_CHAR_CODE('bevr')
-kThemeSoundLittleArrowUpPress = FOUR_CHAR_CODE('laup')
-kThemeSoundLittleArrowDnPress = FOUR_CHAR_CODE('ladp')
-kThemeSoundLittleArrowEnter = FOUR_CHAR_CODE('lare')
-kThemeSoundLittleArrowExit = FOUR_CHAR_CODE('larx')
-kThemeSoundLittleArrowUpRelease = FOUR_CHAR_CODE('laur')
-kThemeSoundLittleArrowDnRelease = FOUR_CHAR_CODE('ladr')
-kThemeSoundPopupPress = FOUR_CHAR_CODE('popp')
-kThemeSoundPopupEnter = FOUR_CHAR_CODE('pope')
-kThemeSoundPopupExit = FOUR_CHAR_CODE('popx')
-kThemeSoundPopupRelease = FOUR_CHAR_CODE('popr')
-kThemeSoundDisclosurePress = FOUR_CHAR_CODE('dscp')
-kThemeSoundDisclosureEnter = FOUR_CHAR_CODE('dsce')
-kThemeSoundDisclosureExit = FOUR_CHAR_CODE('dscx')
-kThemeSoundDisclosureRelease = FOUR_CHAR_CODE('dscr')
-kThemeSoundTabPressed = FOUR_CHAR_CODE('tabp')
-kThemeSoundTabEnter = FOUR_CHAR_CODE('tabe')
-kThemeSoundTabExit = FOUR_CHAR_CODE('tabx')
-kThemeSoundTabRelease = FOUR_CHAR_CODE('tabr')
-kThemeSoundDragTargetHilite = FOUR_CHAR_CODE('dthi')
-kThemeSoundDragTargetUnhilite = FOUR_CHAR_CODE('dtuh')
-kThemeSoundDragTargetDrop = FOUR_CHAR_CODE('dtdr')
-kThemeSoundEmptyTrash = FOUR_CHAR_CODE('ftrs')
-kThemeSoundSelectItem = FOUR_CHAR_CODE('fsel')
-kThemeSoundNewItem = FOUR_CHAR_CODE('fnew')
-kThemeSoundReceiveDrop = FOUR_CHAR_CODE('fdrp')
-kThemeSoundCopyDone = FOUR_CHAR_CODE('fcpd')
-kThemeSoundResolveAlias = FOUR_CHAR_CODE('fral')
-kThemeSoundLaunchApp = FOUR_CHAR_CODE('flap')
-kThemeSoundDiskInsert = FOUR_CHAR_CODE('dski')
-kThemeSoundDiskEject = FOUR_CHAR_CODE('dske')
-kThemeSoundFinderDragOnIcon = FOUR_CHAR_CODE('fdon')
-kThemeSoundFinderDragOffIcon = FOUR_CHAR_CODE('fdof')
-kThemePopupTabNormalPosition = 0
-kThemePopupTabCenterOnWindow = 1
-kThemePopupTabCenterOnOffset = 2
-kThemeMetricScrollBarWidth = 0
-kThemeMetricSmallScrollBarWidth = 1
-kThemeMetricCheckBoxHeight = 2
-kThemeMetricRadioButtonHeight = 3
-kThemeMetricEditTextWhitespace = 4
-kThemeMetricEditTextFrameOutset = 5
-kThemeMetricListBoxFrameOutset = 6
-kThemeMetricFocusRectOutset = 7
-kThemeMetricImageWellThickness = 8
-kThemeMetricScrollBarOverlap = 9
-kThemeMetricLargeTabHeight = 10
-kThemeMetricLargeTabCapsWidth = 11
-kThemeMetricTabFrameOverlap = 12
-kThemeMetricTabIndentOrStyle = 13
-kThemeMetricTabOverlap = 14
-kThemeMetricSmallTabHeight = 15
-kThemeMetricSmallTabCapsWidth = 16
-kThemeMetricDisclosureButtonHeight = 17
-kThemeMetricRoundButtonSize = 18
-kThemeMetricPushButtonHeight = 19
-kThemeMetricListHeaderHeight = 20
-kThemeMetricSmallCheckBoxHeight = 21
-kThemeMetricDisclosureButtonWidth = 22
-kThemeMetricSmallDisclosureButtonHeight = 23
-kThemeMetricSmallDisclosureButtonWidth = 24
-kThemeMetricDisclosureTriangleHeight = 25
-kThemeMetricDisclosureTriangleWidth = 26
-kThemeMetricLittleArrowsHeight = 27
-kThemeMetricLittleArrowsWidth = 28
-kThemeMetricPaneSplitterHeight = 29
-kThemeMetricPopupButtonHeight = 30
-kThemeMetricSmallPopupButtonHeight = 31
-kThemeMetricLargeProgressBarThickness = 32
-kThemeMetricPullDownHeight = 33
-kThemeMetricSmallPullDownHeight = 34
-kThemeMetricSmallPushButtonHeight = 35
-kThemeMetricSmallRadioButtonHeight = 36
-kThemeMetricRelevanceIndicatorHeight = 37
-kThemeMetricResizeControlHeight = 38
-kThemeMetricSmallResizeControlHeight = 39
-kThemeMetricLargeRoundButtonSize = 40
-kThemeMetricHSliderHeight = 41
-kThemeMetricHSliderTickHeight = 42
-kThemeMetricSmallHSliderHeight = 43
-kThemeMetricSmallHSliderTickHeight = 44
-kThemeMetricVSliderWidth = 45
-kThemeMetricVSliderTickWidth = 46
-kThemeMetricSmallVSliderWidth = 47
-kThemeMetricSmallVSliderTickWidth = 48
-kThemeMetricTitleBarControlsHeight = 49
-kThemeMetricCheckBoxWidth = 50
-kThemeMetricSmallCheckBoxWidth = 51
-kThemeMetricRadioButtonWidth = 52
-kThemeMetricSmallRadioButtonWidth = 53
-kThemeMetricSmallHSliderMinThumbWidth = 54
-kThemeMetricSmallVSliderMinThumbHeight = 55
-kThemeMetricSmallHSliderTickOffset = 56
-kThemeMetricSmallVSliderTickOffset = 57
-kThemeMetricNormalProgressBarThickness = 58
-kThemeMetricProgressBarShadowOutset = 59
-kThemeMetricSmallProgressBarShadowOutset = 60
-kThemeMetricPrimaryGroupBoxContentInset = 61
-kThemeMetricSecondaryGroupBoxContentInset = 62
-kThemeMetricMenuMarkColumnWidth = 63
-kThemeMetricMenuExcludedMarkColumnWidth = 64
-kThemeMetricMenuMarkIndent = 65
-kThemeMetricMenuTextLeadingEdgeMargin = 66
-kThemeMetricMenuTextTrailingEdgeMargin = 67
-kThemeMetricMenuIndentWidth = 68
-kThemeMetricMenuIconTrailingEdgeMargin = 69
-# appearanceBadBrushIndexErr = themeInvalidBrushErr
-# appearanceProcessRegisteredErr = themeProcessRegisteredErr
-# appearanceProcessNotRegisteredErr = themeProcessNotRegisteredErr
-# appearanceBadTextColorIndexErr = themeBadTextColorErr
-# appearanceThemeHasNoAccents = themeHasNoAccentsErr
-# appearanceBadCursorIndexErr = themeBadCursorIndexErr
-kThemeActiveDialogBackgroundBrush = kThemeBrushDialogBackgroundActive
-kThemeInactiveDialogBackgroundBrush = kThemeBrushDialogBackgroundInactive
-kThemeActiveAlertBackgroundBrush = kThemeBrushAlertBackgroundActive
-kThemeInactiveAlertBackgroundBrush = kThemeBrushAlertBackgroundInactive
-kThemeActiveModelessDialogBackgroundBrush = kThemeBrushModelessDialogBackgroundActive
-kThemeInactiveModelessDialogBackgroundBrush = kThemeBrushModelessDialogBackgroundInactive
-kThemeActiveUtilityWindowBackgroundBrush = kThemeBrushUtilityWindowBackgroundActive
-kThemeInactiveUtilityWindowBackgroundBrush = kThemeBrushUtilityWindowBackgroundInactive
-kThemeListViewSortColumnBackgroundBrush = kThemeBrushListViewSortColumnBackground
-kThemeListViewBackgroundBrush = kThemeBrushListViewBackground
-kThemeIconLabelBackgroundBrush = kThemeBrushIconLabelBackground
-kThemeListViewSeparatorBrush = kThemeBrushListViewSeparator
-kThemeChasingArrowsBrush = kThemeBrushChasingArrows
-kThemeDragHiliteBrush = kThemeBrushDragHilite
-kThemeDocumentWindowBackgroundBrush = kThemeBrushDocumentWindowBackground
-kThemeFinderWindowBackgroundBrush = kThemeBrushFinderWindowBackground
-kThemeActiveScrollBarDelimiterBrush = kThemeBrushScrollBarDelimiterActive
-kThemeInactiveScrollBarDelimiterBrush = kThemeBrushScrollBarDelimiterInactive
-kThemeFocusHighlightBrush = kThemeBrushFocusHighlight
-kThemeActivePopupArrowBrush = kThemeBrushPopupArrowActive
-kThemePressedPopupArrowBrush = kThemeBrushPopupArrowPressed
-kThemeInactivePopupArrowBrush = kThemeBrushPopupArrowInactive
-kThemeAppleGuideCoachmarkBrush = kThemeBrushAppleGuideCoachmark
-kThemeActiveDialogTextColor = kThemeTextColorDialogActive
-kThemeInactiveDialogTextColor = kThemeTextColorDialogInactive
-kThemeActiveAlertTextColor = kThemeTextColorAlertActive
-kThemeInactiveAlertTextColor = kThemeTextColorAlertInactive
-kThemeActiveModelessDialogTextColor = kThemeTextColorModelessDialogActive
-kThemeInactiveModelessDialogTextColor = kThemeTextColorModelessDialogInactive
-kThemeActiveWindowHeaderTextColor = kThemeTextColorWindowHeaderActive
-kThemeInactiveWindowHeaderTextColor = kThemeTextColorWindowHeaderInactive
-kThemeActivePlacardTextColor = kThemeTextColorPlacardActive
-kThemeInactivePlacardTextColor = kThemeTextColorPlacardInactive
-kThemePressedPlacardTextColor = kThemeTextColorPlacardPressed
-kThemeActivePushButtonTextColor = kThemeTextColorPushButtonActive
-kThemeInactivePushButtonTextColor = kThemeTextColorPushButtonInactive
-kThemePressedPushButtonTextColor = kThemeTextColorPushButtonPressed
-kThemeActiveBevelButtonTextColor = kThemeTextColorBevelButtonActive
-kThemeInactiveBevelButtonTextColor = kThemeTextColorBevelButtonInactive
-kThemePressedBevelButtonTextColor = kThemeTextColorBevelButtonPressed
-kThemeActivePopupButtonTextColor = kThemeTextColorPopupButtonActive
-kThemeInactivePopupButtonTextColor = kThemeTextColorPopupButtonInactive
-kThemePressedPopupButtonTextColor = kThemeTextColorPopupButtonPressed
-kThemeIconLabelTextColor = kThemeTextColorIconLabel
-kThemeListViewTextColor = kThemeTextColorListView
-kThemeActiveDocumentWindowTitleTextColor = kThemeTextColorDocumentWindowTitleActive
-kThemeInactiveDocumentWindowTitleTextColor = kThemeTextColorDocumentWindowTitleInactive
-kThemeActiveMovableModalWindowTitleTextColor = kThemeTextColorMovableModalWindowTitleActive
-kThemeInactiveMovableModalWindowTitleTextColor = kThemeTextColorMovableModalWindowTitleInactive
-kThemeActiveUtilityWindowTitleTextColor = kThemeTextColorUtilityWindowTitleActive
-kThemeInactiveUtilityWindowTitleTextColor = kThemeTextColorUtilityWindowTitleInactive
-kThemeActivePopupWindowTitleColor = kThemeTextColorPopupWindowTitleActive
-kThemeInactivePopupWindowTitleColor = kThemeTextColorPopupWindowTitleInactive
-kThemeActiveRootMenuTextColor = kThemeTextColorRootMenuActive
-kThemeSelectedRootMenuTextColor = kThemeTextColorRootMenuSelected
-kThemeDisabledRootMenuTextColor = kThemeTextColorRootMenuDisabled
-kThemeActiveMenuItemTextColor = kThemeTextColorMenuItemActive
-kThemeSelectedMenuItemTextColor = kThemeTextColorMenuItemSelected
-kThemeDisabledMenuItemTextColor = kThemeTextColorMenuItemDisabled
-kThemeActivePopupLabelTextColor = kThemeTextColorPopupLabelActive
-kThemeInactivePopupLabelTextColor = kThemeTextColorPopupLabelInactive
-kAEThemeSwitch = kAEAppearanceChanged
-kThemeNoAdornment = kThemeAdornmentNone
-kThemeDefaultAdornment = kThemeAdornmentDefault
-kThemeFocusAdornment = kThemeAdornmentFocus
-kThemeRightToLeftAdornment = kThemeAdornmentRightToLeft
-kThemeDrawIndicatorOnly = kThemeAdornmentDrawIndicatorOnly
-kThemeBrushPassiveAreaFill = kThemeBrushStaticAreaFill
-kThemeMetricCheckBoxGlyphHeight = kThemeMetricCheckBoxHeight
-kThemeMetricRadioButtonGlyphHeight = kThemeMetricRadioButtonHeight
-kThemeMetricDisclosureButtonSize = kThemeMetricDisclosureButtonHeight
-kThemeMetricBestListHeaderHeight = kThemeMetricListHeaderHeight
-kThemeMetricSmallProgressBarThickness = kThemeMetricNormalProgressBarThickness
-kThemeMetricProgressBarThickness = kThemeMetricLargeProgressBarThickness
-kThemeScrollBar = kThemeMediumScrollBar
-kThemeSlider = kThemeMediumSlider
-kThemeProgressBar = kThemeMediumProgressBar
-kThemeIndeterminateBar = kThemeMediumIndeterminateBar
diff --git a/Lib/plat-mac/Carbon/AppleEvents.py b/Lib/plat-mac/Carbon/AppleEvents.py
deleted file mode 100644
index a4d7dcf903c..00000000000
--- a/Lib/plat-mac/Carbon/AppleEvents.py
+++ /dev/null
@@ -1,961 +0,0 @@
-# Generated from 'AEDataModel.h'
-
-def FOUR_CHAR_CODE(x): return x
-typeApplicationBundleID = FOUR_CHAR_CODE('bund')
-typeBoolean = FOUR_CHAR_CODE('bool')
-typeChar = FOUR_CHAR_CODE('TEXT')
-typeSInt16 = FOUR_CHAR_CODE('shor')
-typeSInt32 = FOUR_CHAR_CODE('long')
-typeUInt32 = FOUR_CHAR_CODE('magn')
-typeSInt64 = FOUR_CHAR_CODE('comp')
-typeIEEE32BitFloatingPoint = FOUR_CHAR_CODE('sing')
-typeIEEE64BitFloatingPoint = FOUR_CHAR_CODE('doub')
-type128BitFloatingPoint = FOUR_CHAR_CODE('ldbl')
-typeDecimalStruct = FOUR_CHAR_CODE('decm')
-typeSMInt = typeSInt16
-typeShortInteger = typeSInt16
-typeInteger = typeSInt32
-typeLongInteger = typeSInt32
-typeMagnitude = typeUInt32
-typeComp = typeSInt64
-typeSMFloat = typeIEEE32BitFloatingPoint
-typeShortFloat = typeIEEE32BitFloatingPoint
-typeFloat = typeIEEE64BitFloatingPoint
-typeLongFloat = typeIEEE64BitFloatingPoint
-typeExtended = FOUR_CHAR_CODE('exte')
-typeAEList = FOUR_CHAR_CODE('list')
-typeAERecord = FOUR_CHAR_CODE('reco')
-typeAppleEvent = FOUR_CHAR_CODE('aevt')
-typeEventRecord = FOUR_CHAR_CODE('evrc')
-typeTrue = FOUR_CHAR_CODE('true')
-typeFalse = FOUR_CHAR_CODE('fals')
-typeAlias = FOUR_CHAR_CODE('alis')
-typeEnumerated = FOUR_CHAR_CODE('enum')
-typeType = FOUR_CHAR_CODE('type')
-typeAppParameters = FOUR_CHAR_CODE('appa')
-typeProperty = FOUR_CHAR_CODE('prop')
-typeFSS = FOUR_CHAR_CODE('fss ')
-typeFSRef = FOUR_CHAR_CODE('fsrf')
-typeFileURL = FOUR_CHAR_CODE('furl')
-typeKeyword = FOUR_CHAR_CODE('keyw')
-typeSectionH = FOUR_CHAR_CODE('sect')
-typeWildCard = FOUR_CHAR_CODE('****')
-typeApplSignature = FOUR_CHAR_CODE('sign')
-typeQDRectangle = FOUR_CHAR_CODE('qdrt')
-typeFixed = FOUR_CHAR_CODE('fixd')
-typeProcessSerialNumber = FOUR_CHAR_CODE('psn ')
-typeApplicationURL = FOUR_CHAR_CODE('aprl')
-typeNull = FOUR_CHAR_CODE('null')
-typeSessionID = FOUR_CHAR_CODE('ssid')
-typeTargetID = FOUR_CHAR_CODE('targ')
-typeDispatcherID = FOUR_CHAR_CODE('dspt')
-keyTransactionIDAttr = FOUR_CHAR_CODE('tran')
-keyReturnIDAttr = FOUR_CHAR_CODE('rtid')
-keyEventClassAttr = FOUR_CHAR_CODE('evcl')
-keyEventIDAttr = FOUR_CHAR_CODE('evid')
-keyAddressAttr = FOUR_CHAR_CODE('addr')
-keyOptionalKeywordAttr = FOUR_CHAR_CODE('optk')
-keyTimeoutAttr = FOUR_CHAR_CODE('timo')
-keyInteractLevelAttr = FOUR_CHAR_CODE('inte')
-keyEventSourceAttr = FOUR_CHAR_CODE('esrc')
-keyMissedKeywordAttr = FOUR_CHAR_CODE('miss')
-keyOriginalAddressAttr = FOUR_CHAR_CODE('from')
-keyAcceptTimeoutAttr = FOUR_CHAR_CODE('actm')
-kAEDescListFactorNone = 0
-kAEDescListFactorType = 4
-kAEDescListFactorTypeAndSize = 8
-kAutoGenerateReturnID = -1
-kAnyTransactionID = 0
-kAEDataArray = 0
-kAEPackedArray = 1
-kAEDescArray = 3
-kAEKeyDescArray = 4
-kAEHandleArray = 2
-kAENormalPriority = 0x00000000
-kAEHighPriority = 0x00000001
-kAENoReply = 0x00000001
-kAEQueueReply = 0x00000002
-kAEWaitReply = 0x00000003
-kAEDontReconnect = 0x00000080
-kAEWantReceipt = 0x00000200
-kAENeverInteract = 0x00000010
-kAECanInteract = 0x00000020
-kAEAlwaysInteract = 0x00000030
-kAECanSwitchLayer = 0x00000040
-kAEDontRecord = 0x00001000
-kAEDontExecute = 0x00002000
-kAEProcessNonReplyEvents = 0x00008000
-kAEDefaultTimeout = -1
-kNoTimeOut = -2
-kAEInteractWithSelf = 0
-kAEInteractWithLocal = 1
-kAEInteractWithAll = 2
-kAEDoNotIgnoreHandler = 0x00000000
-kAEIgnoreAppPhacHandler = 0x00000001
-kAEIgnoreAppEventHandler = 0x00000002
-kAEIgnoreSysPhacHandler = 0x00000004
-kAEIgnoreSysEventHandler = 0x00000008
-kAEIngoreBuiltInEventHandler = 0x00000010
-# kAEDontDisposeOnResume = (long)0x80000000
-kAENoDispatch = 0
-# kAEUseStandardDispatch = (long)0xFFFFFFFF
-keyDirectObject = FOUR_CHAR_CODE('----')
-keyErrorNumber = FOUR_CHAR_CODE('errn')
-keyErrorString = FOUR_CHAR_CODE('errs')
-keyProcessSerialNumber = FOUR_CHAR_CODE('psn ')
-keyPreDispatch = FOUR_CHAR_CODE('phac')
-keySelectProc = FOUR_CHAR_CODE('selh')
-keyAERecorderCount = FOUR_CHAR_CODE('recr')
-keyAEVersion = FOUR_CHAR_CODE('vers')
-kCoreEventClass = FOUR_CHAR_CODE('aevt')
-kAEOpenApplication = FOUR_CHAR_CODE('oapp')
-kAEOpenDocuments = FOUR_CHAR_CODE('odoc')
-kAEPrintDocuments = FOUR_CHAR_CODE('pdoc')
-kAEQuitApplication = FOUR_CHAR_CODE('quit')
-kAEAnswer = FOUR_CHAR_CODE('ansr')
-kAEApplicationDied = FOUR_CHAR_CODE('obit')
-kAEShowPreferences = FOUR_CHAR_CODE('pref')
-kAEStartRecording = FOUR_CHAR_CODE('reca')
-kAEStopRecording = FOUR_CHAR_CODE('recc')
-kAENotifyStartRecording = FOUR_CHAR_CODE('rec1')
-kAENotifyStopRecording = FOUR_CHAR_CODE('rec0')
-kAENotifyRecording = FOUR_CHAR_CODE('recr')
-kAEUnknownSource = 0
-kAEDirectCall = 1
-kAESameProcess = 2
-kAELocalProcess = 3
-kAERemoteProcess = 4
-cAEList = FOUR_CHAR_CODE('list')
-cApplication = FOUR_CHAR_CODE('capp')
-cArc = FOUR_CHAR_CODE('carc')
-cBoolean = FOUR_CHAR_CODE('bool')
-cCell = FOUR_CHAR_CODE('ccel')
-cChar = FOUR_CHAR_CODE('cha ')
-cColorTable = FOUR_CHAR_CODE('clrt')
-cColumn = FOUR_CHAR_CODE('ccol')
-cDocument = FOUR_CHAR_CODE('docu')
-cDrawingArea = FOUR_CHAR_CODE('cdrw')
-cEnumeration = FOUR_CHAR_CODE('enum')
-cFile = FOUR_CHAR_CODE('file')
-cFixed = FOUR_CHAR_CODE('fixd')
-cFixedPoint = FOUR_CHAR_CODE('fpnt')
-cFixedRectangle = FOUR_CHAR_CODE('frct')
-cGraphicLine = FOUR_CHAR_CODE('glin')
-cGraphicObject = FOUR_CHAR_CODE('cgob')
-cGraphicShape = FOUR_CHAR_CODE('cgsh')
-cGraphicText = FOUR_CHAR_CODE('cgtx')
-cGroupedGraphic = FOUR_CHAR_CODE('cpic')
-cInsertionLoc = FOUR_CHAR_CODE('insl')
-cInsertionPoint = FOUR_CHAR_CODE('cins')
-cIntlText = FOUR_CHAR_CODE('itxt')
-cIntlWritingCode = FOUR_CHAR_CODE('intl')
-cItem = FOUR_CHAR_CODE('citm')
-cLine = FOUR_CHAR_CODE('clin')
-cLongDateTime = FOUR_CHAR_CODE('ldt ')
-cLongFixed = FOUR_CHAR_CODE('lfxd')
-cLongFixedPoint = FOUR_CHAR_CODE('lfpt')
-cLongFixedRectangle = FOUR_CHAR_CODE('lfrc')
-cLongInteger = FOUR_CHAR_CODE('long')
-cLongPoint = FOUR_CHAR_CODE('lpnt')
-cLongRectangle = FOUR_CHAR_CODE('lrct')
-cMachineLoc = FOUR_CHAR_CODE('mLoc')
-cMenu = FOUR_CHAR_CODE('cmnu')
-cMenuItem = FOUR_CHAR_CODE('cmen')
-cObject = FOUR_CHAR_CODE('cobj')
-cObjectSpecifier = FOUR_CHAR_CODE('obj ')
-cOpenableObject = FOUR_CHAR_CODE('coob')
-cOval = FOUR_CHAR_CODE('covl')
-cParagraph = FOUR_CHAR_CODE('cpar')
-cPICT = FOUR_CHAR_CODE('PICT')
-cPixel = FOUR_CHAR_CODE('cpxl')
-cPixelMap = FOUR_CHAR_CODE('cpix')
-cPolygon = FOUR_CHAR_CODE('cpgn')
-cProperty = FOUR_CHAR_CODE('prop')
-cQDPoint = FOUR_CHAR_CODE('QDpt')
-cQDRectangle = FOUR_CHAR_CODE('qdrt')
-cRectangle = FOUR_CHAR_CODE('crec')
-cRGBColor = FOUR_CHAR_CODE('cRGB')
-cRotation = FOUR_CHAR_CODE('trot')
-cRoundedRectangle = FOUR_CHAR_CODE('crrc')
-cRow = FOUR_CHAR_CODE('crow')
-cSelection = FOUR_CHAR_CODE('csel')
-cShortInteger = FOUR_CHAR_CODE('shor')
-cTable = FOUR_CHAR_CODE('ctbl')
-cText = FOUR_CHAR_CODE('ctxt')
-cTextFlow = FOUR_CHAR_CODE('cflo')
-cTextStyles = FOUR_CHAR_CODE('tsty')
-cType = FOUR_CHAR_CODE('type')
-cVersion = FOUR_CHAR_CODE('vers')
-cWindow = FOUR_CHAR_CODE('cwin')
-cWord = FOUR_CHAR_CODE('cwor')
-enumArrows = FOUR_CHAR_CODE('arro')
-enumJustification = FOUR_CHAR_CODE('just')
-enumKeyForm = FOUR_CHAR_CODE('kfrm')
-enumPosition = FOUR_CHAR_CODE('posi')
-enumProtection = FOUR_CHAR_CODE('prtn')
-enumQuality = FOUR_CHAR_CODE('qual')
-enumSaveOptions = FOUR_CHAR_CODE('savo')
-enumStyle = FOUR_CHAR_CODE('styl')
-enumTransferMode = FOUR_CHAR_CODE('tran')
-formUniqueID = FOUR_CHAR_CODE('ID ')
-kAEAbout = FOUR_CHAR_CODE('abou')
-kAEAfter = FOUR_CHAR_CODE('afte')
-kAEAliasSelection = FOUR_CHAR_CODE('sali')
-kAEAllCaps = FOUR_CHAR_CODE('alcp')
-kAEArrowAtEnd = FOUR_CHAR_CODE('aren')
-kAEArrowAtStart = FOUR_CHAR_CODE('arst')
-kAEArrowBothEnds = FOUR_CHAR_CODE('arbo')
-kAEAsk = FOUR_CHAR_CODE('ask ')
-kAEBefore = FOUR_CHAR_CODE('befo')
-kAEBeginning = FOUR_CHAR_CODE('bgng')
-kAEBeginsWith = FOUR_CHAR_CODE('bgwt')
-kAEBeginTransaction = FOUR_CHAR_CODE('begi')
-kAEBold = FOUR_CHAR_CODE('bold')
-kAECaseSensEquals = FOUR_CHAR_CODE('cseq')
-kAECentered = FOUR_CHAR_CODE('cent')
-kAEChangeView = FOUR_CHAR_CODE('view')
-kAEClone = FOUR_CHAR_CODE('clon')
-kAEClose = FOUR_CHAR_CODE('clos')
-kAECondensed = FOUR_CHAR_CODE('cond')
-kAEContains = FOUR_CHAR_CODE('cont')
-kAECopy = FOUR_CHAR_CODE('copy')
-kAECoreSuite = FOUR_CHAR_CODE('core')
-kAECountElements = FOUR_CHAR_CODE('cnte')
-kAECreateElement = FOUR_CHAR_CODE('crel')
-kAECreatePublisher = FOUR_CHAR_CODE('cpub')
-kAECut = FOUR_CHAR_CODE('cut ')
-kAEDelete = FOUR_CHAR_CODE('delo')
-kAEDoObjectsExist = FOUR_CHAR_CODE('doex')
-kAEDoScript = FOUR_CHAR_CODE('dosc')
-kAEDrag = FOUR_CHAR_CODE('drag')
-kAEDuplicateSelection = FOUR_CHAR_CODE('sdup')
-kAEEditGraphic = FOUR_CHAR_CODE('edit')
-kAEEmptyTrash = FOUR_CHAR_CODE('empt')
-kAEEnd = FOUR_CHAR_CODE('end ')
-kAEEndsWith = FOUR_CHAR_CODE('ends')
-kAEEndTransaction = FOUR_CHAR_CODE('endt')
-kAEEquals = FOUR_CHAR_CODE('= ')
-kAEExpanded = FOUR_CHAR_CODE('pexp')
-kAEFast = FOUR_CHAR_CODE('fast')
-kAEFinderEvents = FOUR_CHAR_CODE('FNDR')
-kAEFormulaProtect = FOUR_CHAR_CODE('fpro')
-kAEFullyJustified = FOUR_CHAR_CODE('full')
-kAEGetClassInfo = FOUR_CHAR_CODE('qobj')
-kAEGetData = FOUR_CHAR_CODE('getd')
-kAEGetDataSize = FOUR_CHAR_CODE('dsiz')
-kAEGetEventInfo = FOUR_CHAR_CODE('gtei')
-kAEGetInfoSelection = FOUR_CHAR_CODE('sinf')
-kAEGetPrivilegeSelection = FOUR_CHAR_CODE('sprv')
-kAEGetSuiteInfo = FOUR_CHAR_CODE('gtsi')
-kAEGreaterThan = FOUR_CHAR_CODE('> ')
-kAEGreaterThanEquals = FOUR_CHAR_CODE('>= ')
-kAEGrow = FOUR_CHAR_CODE('grow')
-kAEHidden = FOUR_CHAR_CODE('hidn')
-kAEHiQuality = FOUR_CHAR_CODE('hiqu')
-kAEImageGraphic = FOUR_CHAR_CODE('imgr')
-kAEIsUniform = FOUR_CHAR_CODE('isun')
-kAEItalic = FOUR_CHAR_CODE('ital')
-kAELeftJustified = FOUR_CHAR_CODE('left')
-kAELessThan = FOUR_CHAR_CODE('< ')
-kAELessThanEquals = FOUR_CHAR_CODE('<= ')
-kAELowercase = FOUR_CHAR_CODE('lowc')
-kAEMakeObjectsVisible = FOUR_CHAR_CODE('mvis')
-kAEMiscStandards = FOUR_CHAR_CODE('misc')
-kAEModifiable = FOUR_CHAR_CODE('modf')
-kAEMove = FOUR_CHAR_CODE('move')
-kAENo = FOUR_CHAR_CODE('no ')
-kAENoArrow = FOUR_CHAR_CODE('arno')
-kAENonmodifiable = FOUR_CHAR_CODE('nmod')
-kAEOpen = FOUR_CHAR_CODE('odoc')
-kAEOpenSelection = FOUR_CHAR_CODE('sope')
-kAEOutline = FOUR_CHAR_CODE('outl')
-kAEPageSetup = FOUR_CHAR_CODE('pgsu')
-kAEPaste = FOUR_CHAR_CODE('past')
-kAEPlain = FOUR_CHAR_CODE('plan')
-kAEPrint = FOUR_CHAR_CODE('pdoc')
-kAEPrintSelection = FOUR_CHAR_CODE('spri')
-kAEPrintWindow = FOUR_CHAR_CODE('pwin')
-kAEPutAwaySelection = FOUR_CHAR_CODE('sput')
-kAEQDAddOver = FOUR_CHAR_CODE('addo')
-kAEQDAddPin = FOUR_CHAR_CODE('addp')
-kAEQDAdMax = FOUR_CHAR_CODE('admx')
-kAEQDAdMin = FOUR_CHAR_CODE('admn')
-kAEQDBic = FOUR_CHAR_CODE('bic ')
-kAEQDBlend = FOUR_CHAR_CODE('blnd')
-kAEQDCopy = FOUR_CHAR_CODE('cpy ')
-kAEQDNotBic = FOUR_CHAR_CODE('nbic')
-kAEQDNotCopy = FOUR_CHAR_CODE('ncpy')
-kAEQDNotOr = FOUR_CHAR_CODE('ntor')
-kAEQDNotXor = FOUR_CHAR_CODE('nxor')
-kAEQDOr = FOUR_CHAR_CODE('or ')
-kAEQDSubOver = FOUR_CHAR_CODE('subo')
-kAEQDSubPin = FOUR_CHAR_CODE('subp')
-kAEQDSupplementalSuite = FOUR_CHAR_CODE('qdsp')
-kAEQDXor = FOUR_CHAR_CODE('xor ')
-kAEQuickdrawSuite = FOUR_CHAR_CODE('qdrw')
-kAEQuitAll = FOUR_CHAR_CODE('quia')
-kAERedo = FOUR_CHAR_CODE('redo')
-kAERegular = FOUR_CHAR_CODE('regl')
-kAEReopenApplication = FOUR_CHAR_CODE('rapp')
-kAEReplace = FOUR_CHAR_CODE('rplc')
-kAERequiredSuite = FOUR_CHAR_CODE('reqd')
-kAERestart = FOUR_CHAR_CODE('rest')
-kAERevealSelection = FOUR_CHAR_CODE('srev')
-kAERevert = FOUR_CHAR_CODE('rvrt')
-kAERightJustified = FOUR_CHAR_CODE('rght')
-kAESave = FOUR_CHAR_CODE('save')
-kAESelect = FOUR_CHAR_CODE('slct')
-kAESetData = FOUR_CHAR_CODE('setd')
-kAESetPosition = FOUR_CHAR_CODE('posn')
-kAEShadow = FOUR_CHAR_CODE('shad')
-kAEShowClipboard = FOUR_CHAR_CODE('shcl')
-kAEShutDown = FOUR_CHAR_CODE('shut')
-kAESleep = FOUR_CHAR_CODE('slep')
-kAESmallCaps = FOUR_CHAR_CODE('smcp')
-kAESpecialClassProperties = FOUR_CHAR_CODE('c@#!')
-kAEStrikethrough = FOUR_CHAR_CODE('strk')
-kAESubscript = FOUR_CHAR_CODE('sbsc')
-kAESuperscript = FOUR_CHAR_CODE('spsc')
-kAETableSuite = FOUR_CHAR_CODE('tbls')
-kAETextSuite = FOUR_CHAR_CODE('TEXT')
-kAETransactionTerminated = FOUR_CHAR_CODE('ttrm')
-kAEUnderline = FOUR_CHAR_CODE('undl')
-kAEUndo = FOUR_CHAR_CODE('undo')
-kAEWholeWordEquals = FOUR_CHAR_CODE('wweq')
-kAEYes = FOUR_CHAR_CODE('yes ')
-kAEZoom = FOUR_CHAR_CODE('zoom')
-kAEMouseClass = FOUR_CHAR_CODE('mous')
-kAEDown = FOUR_CHAR_CODE('down')
-kAEUp = FOUR_CHAR_CODE('up ')
-kAEMoved = FOUR_CHAR_CODE('move')
-kAEStoppedMoving = FOUR_CHAR_CODE('stop')
-kAEWindowClass = FOUR_CHAR_CODE('wind')
-kAEUpdate = FOUR_CHAR_CODE('updt')
-kAEActivate = FOUR_CHAR_CODE('actv')
-kAEDeactivate = FOUR_CHAR_CODE('dact')
-kAECommandClass = FOUR_CHAR_CODE('cmnd')
-kAEKeyClass = FOUR_CHAR_CODE('keyc')
-kAERawKey = FOUR_CHAR_CODE('rkey')
-kAEVirtualKey = FOUR_CHAR_CODE('keyc')
-kAENavigationKey = FOUR_CHAR_CODE('nave')
-kAEAutoDown = FOUR_CHAR_CODE('auto')
-kAEApplicationClass = FOUR_CHAR_CODE('appl')
-kAESuspend = FOUR_CHAR_CODE('susp')
-kAEResume = FOUR_CHAR_CODE('rsme')
-kAEDiskEvent = FOUR_CHAR_CODE('disk')
-kAENullEvent = FOUR_CHAR_CODE('null')
-kAEWakeUpEvent = FOUR_CHAR_CODE('wake')
-kAEScrapEvent = FOUR_CHAR_CODE('scrp')
-kAEHighLevel = FOUR_CHAR_CODE('high')
-keyAEAngle = FOUR_CHAR_CODE('kang')
-keyAEArcAngle = FOUR_CHAR_CODE('parc')
-keyAEBaseAddr = FOUR_CHAR_CODE('badd')
-keyAEBestType = FOUR_CHAR_CODE('pbst')
-keyAEBgndColor = FOUR_CHAR_CODE('kbcl')
-keyAEBgndPattern = FOUR_CHAR_CODE('kbpt')
-keyAEBounds = FOUR_CHAR_CODE('pbnd')
-keyAECellList = FOUR_CHAR_CODE('kclt')
-keyAEClassID = FOUR_CHAR_CODE('clID')
-keyAEColor = FOUR_CHAR_CODE('colr')
-keyAEColorTable = FOUR_CHAR_CODE('cltb')
-keyAECurveHeight = FOUR_CHAR_CODE('kchd')
-keyAECurveWidth = FOUR_CHAR_CODE('kcwd')
-keyAEDashStyle = FOUR_CHAR_CODE('pdst')
-keyAEData = FOUR_CHAR_CODE('data')
-keyAEDefaultType = FOUR_CHAR_CODE('deft')
-keyAEDefinitionRect = FOUR_CHAR_CODE('pdrt')
-keyAEDescType = FOUR_CHAR_CODE('dstp')
-keyAEDestination = FOUR_CHAR_CODE('dest')
-keyAEDoAntiAlias = FOUR_CHAR_CODE('anta')
-keyAEDoDithered = FOUR_CHAR_CODE('gdit')
-keyAEDoRotate = FOUR_CHAR_CODE('kdrt')
-keyAEDoScale = FOUR_CHAR_CODE('ksca')
-keyAEDoTranslate = FOUR_CHAR_CODE('ktra')
-keyAEEditionFileLoc = FOUR_CHAR_CODE('eloc')
-keyAEElements = FOUR_CHAR_CODE('elms')
-keyAEEndPoint = FOUR_CHAR_CODE('pend')
-keyAEEventClass = FOUR_CHAR_CODE('evcl')
-keyAEEventID = FOUR_CHAR_CODE('evti')
-keyAEFile = FOUR_CHAR_CODE('kfil')
-keyAEFileType = FOUR_CHAR_CODE('fltp')
-keyAEFillColor = FOUR_CHAR_CODE('flcl')
-keyAEFillPattern = FOUR_CHAR_CODE('flpt')
-keyAEFlipHorizontal = FOUR_CHAR_CODE('kfho')
-keyAEFlipVertical = FOUR_CHAR_CODE('kfvt')
-keyAEFont = FOUR_CHAR_CODE('font')
-keyAEFormula = FOUR_CHAR_CODE('pfor')
-keyAEGraphicObjects = FOUR_CHAR_CODE('gobs')
-keyAEID = FOUR_CHAR_CODE('ID ')
-keyAEImageQuality = FOUR_CHAR_CODE('gqua')
-keyAEInsertHere = FOUR_CHAR_CODE('insh')
-keyAEKeyForms = FOUR_CHAR_CODE('keyf')
-keyAEKeyword = FOUR_CHAR_CODE('kywd')
-keyAELevel = FOUR_CHAR_CODE('levl')
-keyAELineArrow = FOUR_CHAR_CODE('arro')
-keyAEName = FOUR_CHAR_CODE('pnam')
-keyAENewElementLoc = FOUR_CHAR_CODE('pnel')
-keyAEObject = FOUR_CHAR_CODE('kobj')
-keyAEObjectClass = FOUR_CHAR_CODE('kocl')
-keyAEOffStyles = FOUR_CHAR_CODE('ofst')
-keyAEOnStyles = FOUR_CHAR_CODE('onst')
-keyAEParameters = FOUR_CHAR_CODE('prms')
-keyAEParamFlags = FOUR_CHAR_CODE('pmfg')
-keyAEPenColor = FOUR_CHAR_CODE('ppcl')
-keyAEPenPattern = FOUR_CHAR_CODE('pppa')
-keyAEPenWidth = FOUR_CHAR_CODE('ppwd')
-keyAEPixelDepth = FOUR_CHAR_CODE('pdpt')
-keyAEPixMapMinus = FOUR_CHAR_CODE('kpmm')
-keyAEPMTable = FOUR_CHAR_CODE('kpmt')
-keyAEPointList = FOUR_CHAR_CODE('ptlt')
-keyAEPointSize = FOUR_CHAR_CODE('ptsz')
-keyAEPosition = FOUR_CHAR_CODE('kpos')
-keyAEPropData = FOUR_CHAR_CODE('prdt')
-keyAEProperties = FOUR_CHAR_CODE('qpro')
-keyAEProperty = FOUR_CHAR_CODE('kprp')
-keyAEPropFlags = FOUR_CHAR_CODE('prfg')
-keyAEPropID = FOUR_CHAR_CODE('prop')
-keyAEProtection = FOUR_CHAR_CODE('ppro')
-keyAERenderAs = FOUR_CHAR_CODE('kren')
-keyAERequestedType = FOUR_CHAR_CODE('rtyp')
-keyAEResult = FOUR_CHAR_CODE('----')
-keyAEResultInfo = FOUR_CHAR_CODE('rsin')
-keyAERotation = FOUR_CHAR_CODE('prot')
-keyAERotPoint = FOUR_CHAR_CODE('krtp')
-keyAERowList = FOUR_CHAR_CODE('krls')
-keyAESaveOptions = FOUR_CHAR_CODE('savo')
-keyAEScale = FOUR_CHAR_CODE('pscl')
-keyAEScriptTag = FOUR_CHAR_CODE('psct')
-keyAEShowWhere = FOUR_CHAR_CODE('show')
-keyAEStartAngle = FOUR_CHAR_CODE('pang')
-keyAEStartPoint = FOUR_CHAR_CODE('pstp')
-keyAEStyles = FOUR_CHAR_CODE('ksty')
-keyAESuiteID = FOUR_CHAR_CODE('suit')
-keyAEText = FOUR_CHAR_CODE('ktxt')
-keyAETextColor = FOUR_CHAR_CODE('ptxc')
-keyAETextFont = FOUR_CHAR_CODE('ptxf')
-keyAETextPointSize = FOUR_CHAR_CODE('ptps')
-keyAETextStyles = FOUR_CHAR_CODE('txst')
-keyAETextLineHeight = FOUR_CHAR_CODE('ktlh')
-keyAETextLineAscent = FOUR_CHAR_CODE('ktas')
-keyAETheText = FOUR_CHAR_CODE('thtx')
-keyAETransferMode = FOUR_CHAR_CODE('pptm')
-keyAETranslation = FOUR_CHAR_CODE('ptrs')
-keyAETryAsStructGraf = FOUR_CHAR_CODE('toog')
-keyAEUniformStyles = FOUR_CHAR_CODE('ustl')
-keyAEUpdateOn = FOUR_CHAR_CODE('pupd')
-keyAEUserTerm = FOUR_CHAR_CODE('utrm')
-keyAEWindow = FOUR_CHAR_CODE('wndw')
-keyAEWritingCode = FOUR_CHAR_CODE('wrcd')
-keyMiscellaneous = FOUR_CHAR_CODE('fmsc')
-keySelection = FOUR_CHAR_CODE('fsel')
-keyWindow = FOUR_CHAR_CODE('kwnd')
-keyWhen = FOUR_CHAR_CODE('when')
-keyWhere = FOUR_CHAR_CODE('wher')
-keyModifiers = FOUR_CHAR_CODE('mods')
-keyKey = FOUR_CHAR_CODE('key ')
-keyKeyCode = FOUR_CHAR_CODE('code')
-keyKeyboard = FOUR_CHAR_CODE('keyb')
-keyDriveNumber = FOUR_CHAR_CODE('drv#')
-keyErrorCode = FOUR_CHAR_CODE('err#')
-keyHighLevelClass = FOUR_CHAR_CODE('hcls')
-keyHighLevelID = FOUR_CHAR_CODE('hid ')
-pArcAngle = FOUR_CHAR_CODE('parc')
-pBackgroundColor = FOUR_CHAR_CODE('pbcl')
-pBackgroundPattern = FOUR_CHAR_CODE('pbpt')
-pBestType = FOUR_CHAR_CODE('pbst')
-pBounds = FOUR_CHAR_CODE('pbnd')
-pClass = FOUR_CHAR_CODE('pcls')
-pClipboard = FOUR_CHAR_CODE('pcli')
-pColor = FOUR_CHAR_CODE('colr')
-pColorTable = FOUR_CHAR_CODE('cltb')
-pContents = FOUR_CHAR_CODE('pcnt')
-pCornerCurveHeight = FOUR_CHAR_CODE('pchd')
-pCornerCurveWidth = FOUR_CHAR_CODE('pcwd')
-pDashStyle = FOUR_CHAR_CODE('pdst')
-pDefaultType = FOUR_CHAR_CODE('deft')
-pDefinitionRect = FOUR_CHAR_CODE('pdrt')
-pEnabled = FOUR_CHAR_CODE('enbl')
-pEndPoint = FOUR_CHAR_CODE('pend')
-pFillColor = FOUR_CHAR_CODE('flcl')
-pFillPattern = FOUR_CHAR_CODE('flpt')
-pFont = FOUR_CHAR_CODE('font')
-pFormula = FOUR_CHAR_CODE('pfor')
-pGraphicObjects = FOUR_CHAR_CODE('gobs')
-pHasCloseBox = FOUR_CHAR_CODE('hclb')
-pHasTitleBar = FOUR_CHAR_CODE('ptit')
-pID = FOUR_CHAR_CODE('ID ')
-pIndex = FOUR_CHAR_CODE('pidx')
-pInsertionLoc = FOUR_CHAR_CODE('pins')
-pIsFloating = FOUR_CHAR_CODE('isfl')
-pIsFrontProcess = FOUR_CHAR_CODE('pisf')
-pIsModal = FOUR_CHAR_CODE('pmod')
-pIsModified = FOUR_CHAR_CODE('imod')
-pIsResizable = FOUR_CHAR_CODE('prsz')
-pIsStationeryPad = FOUR_CHAR_CODE('pspd')
-pIsZoomable = FOUR_CHAR_CODE('iszm')
-pIsZoomed = FOUR_CHAR_CODE('pzum')
-pItemNumber = FOUR_CHAR_CODE('itmn')
-pJustification = FOUR_CHAR_CODE('pjst')
-pLineArrow = FOUR_CHAR_CODE('arro')
-pMenuID = FOUR_CHAR_CODE('mnid')
-pName = FOUR_CHAR_CODE('pnam')
-pNewElementLoc = FOUR_CHAR_CODE('pnel')
-pPenColor = FOUR_CHAR_CODE('ppcl')
-pPenPattern = FOUR_CHAR_CODE('pppa')
-pPenWidth = FOUR_CHAR_CODE('ppwd')
-pPixelDepth = FOUR_CHAR_CODE('pdpt')
-pPointList = FOUR_CHAR_CODE('ptlt')
-pPointSize = FOUR_CHAR_CODE('ptsz')
-pProtection = FOUR_CHAR_CODE('ppro')
-pRotation = FOUR_CHAR_CODE('prot')
-pScale = FOUR_CHAR_CODE('pscl')
-pScript = FOUR_CHAR_CODE('scpt')
-pScriptTag = FOUR_CHAR_CODE('psct')
-pSelected = FOUR_CHAR_CODE('selc')
-pSelection = FOUR_CHAR_CODE('sele')
-pStartAngle = FOUR_CHAR_CODE('pang')
-pStartPoint = FOUR_CHAR_CODE('pstp')
-pTextColor = FOUR_CHAR_CODE('ptxc')
-pTextFont = FOUR_CHAR_CODE('ptxf')
-pTextItemDelimiters = FOUR_CHAR_CODE('txdl')
-pTextPointSize = FOUR_CHAR_CODE('ptps')
-pTextStyles = FOUR_CHAR_CODE('txst')
-pTransferMode = FOUR_CHAR_CODE('pptm')
-pTranslation = FOUR_CHAR_CODE('ptrs')
-pUniformStyles = FOUR_CHAR_CODE('ustl')
-pUpdateOn = FOUR_CHAR_CODE('pupd')
-pUserSelection = FOUR_CHAR_CODE('pusl')
-pVersion = FOUR_CHAR_CODE('vers')
-pVisible = FOUR_CHAR_CODE('pvis')
-typeAEText = FOUR_CHAR_CODE('tTXT')
-typeArc = FOUR_CHAR_CODE('carc')
-typeBest = FOUR_CHAR_CODE('best')
-typeCell = FOUR_CHAR_CODE('ccel')
-typeClassInfo = FOUR_CHAR_CODE('gcli')
-typeColorTable = FOUR_CHAR_CODE('clrt')
-typeColumn = FOUR_CHAR_CODE('ccol')
-typeDashStyle = FOUR_CHAR_CODE('tdas')
-typeData = FOUR_CHAR_CODE('tdta')
-typeDrawingArea = FOUR_CHAR_CODE('cdrw')
-typeElemInfo = FOUR_CHAR_CODE('elin')
-typeEnumeration = FOUR_CHAR_CODE('enum')
-typeEPS = FOUR_CHAR_CODE('EPS ')
-typeEventInfo = FOUR_CHAR_CODE('evin')
-typeFinderWindow = FOUR_CHAR_CODE('fwin')
-typeFixedPoint = FOUR_CHAR_CODE('fpnt')
-typeFixedRectangle = FOUR_CHAR_CODE('frct')
-typeGraphicLine = FOUR_CHAR_CODE('glin')
-typeGraphicText = FOUR_CHAR_CODE('cgtx')
-typeGroupedGraphic = FOUR_CHAR_CODE('cpic')
-typeInsertionLoc = FOUR_CHAR_CODE('insl')
-typeIntlText = FOUR_CHAR_CODE('itxt')
-typeIntlWritingCode = FOUR_CHAR_CODE('intl')
-typeLongDateTime = FOUR_CHAR_CODE('ldt ')
-typeLongFixed = FOUR_CHAR_CODE('lfxd')
-typeLongFixedPoint = FOUR_CHAR_CODE('lfpt')
-typeLongFixedRectangle = FOUR_CHAR_CODE('lfrc')
-typeLongPoint = FOUR_CHAR_CODE('lpnt')
-typeLongRectangle = FOUR_CHAR_CODE('lrct')
-typeMachineLoc = FOUR_CHAR_CODE('mLoc')
-typeOval = FOUR_CHAR_CODE('covl')
-typeParamInfo = FOUR_CHAR_CODE('pmin')
-typePict = FOUR_CHAR_CODE('PICT')
-typePixelMap = FOUR_CHAR_CODE('cpix')
-typePixMapMinus = FOUR_CHAR_CODE('tpmm')
-typePolygon = FOUR_CHAR_CODE('cpgn')
-typePropInfo = FOUR_CHAR_CODE('pinf')
-typePtr = FOUR_CHAR_CODE('ptr ')
-typeQDPoint = FOUR_CHAR_CODE('QDpt')
-typeQDRegion = FOUR_CHAR_CODE('Qrgn')
-typeRectangle = FOUR_CHAR_CODE('crec')
-typeRGB16 = FOUR_CHAR_CODE('tr16')
-typeRGB96 = FOUR_CHAR_CODE('tr96')
-typeRGBColor = FOUR_CHAR_CODE('cRGB')
-typeRotation = FOUR_CHAR_CODE('trot')
-typeRoundedRectangle = FOUR_CHAR_CODE('crrc')
-typeRow = FOUR_CHAR_CODE('crow')
-typeScrapStyles = FOUR_CHAR_CODE('styl')
-typeScript = FOUR_CHAR_CODE('scpt')
-typeStyledText = FOUR_CHAR_CODE('STXT')
-typeSuiteInfo = FOUR_CHAR_CODE('suin')
-typeTable = FOUR_CHAR_CODE('ctbl')
-typeTextStyles = FOUR_CHAR_CODE('tsty')
-typeTIFF = FOUR_CHAR_CODE('TIFF')
-typeVersion = FOUR_CHAR_CODE('vers')
-kAEMenuClass = FOUR_CHAR_CODE('menu')
-kAEMenuSelect = FOUR_CHAR_CODE('mhit')
-kAEMouseDown = FOUR_CHAR_CODE('mdwn')
-kAEMouseDownInBack = FOUR_CHAR_CODE('mdbk')
-kAEKeyDown = FOUR_CHAR_CODE('kdwn')
-kAEResized = FOUR_CHAR_CODE('rsiz')
-kAEPromise = FOUR_CHAR_CODE('prom')
-keyMenuID = FOUR_CHAR_CODE('mid ')
-keyMenuItem = FOUR_CHAR_CODE('mitm')
-keyCloseAllWindows = FOUR_CHAR_CODE('caw ')
-keyOriginalBounds = FOUR_CHAR_CODE('obnd')
-keyNewBounds = FOUR_CHAR_CODE('nbnd')
-keyLocalWhere = FOUR_CHAR_CODE('lwhr')
-typeHIMenu = FOUR_CHAR_CODE('mobj')
-typeHIWindow = FOUR_CHAR_CODE('wobj')
-kBySmallIcon = 0
-kByIconView = 1
-kByNameView = 2
-kByDateView = 3
-kBySizeView = 4
-kByKindView = 5
-kByCommentView = 6
-kByLabelView = 7
-kByVersionView = 8
-kAEInfo = 11
-kAEMain = 0
-kAESharing = 13
-kAEZoomIn = 7
-kAEZoomOut = 8
-kTextServiceClass = FOUR_CHAR_CODE('tsvc')
-kUpdateActiveInputArea = FOUR_CHAR_CODE('updt')
-kShowHideInputWindow = FOUR_CHAR_CODE('shiw')
-kPos2Offset = FOUR_CHAR_CODE('p2st')
-kOffset2Pos = FOUR_CHAR_CODE('st2p')
-kUnicodeNotFromInputMethod = FOUR_CHAR_CODE('unim')
-kGetSelectedText = FOUR_CHAR_CODE('gtxt')
-keyAETSMDocumentRefcon = FOUR_CHAR_CODE('refc')
-keyAEServerInstance = FOUR_CHAR_CODE('srvi')
-keyAETheData = FOUR_CHAR_CODE('kdat')
-keyAEFixLength = FOUR_CHAR_CODE('fixl')
-keyAEUpdateRange = FOUR_CHAR_CODE('udng')
-keyAECurrentPoint = FOUR_CHAR_CODE('cpos')
-keyAEBufferSize = FOUR_CHAR_CODE('buff')
-keyAEMoveView = FOUR_CHAR_CODE('mvvw')
-keyAENextBody = FOUR_CHAR_CODE('nxbd')
-keyAETSMScriptTag = FOUR_CHAR_CODE('sclg')
-keyAETSMTextFont = FOUR_CHAR_CODE('ktxf')
-keyAETSMTextFMFont = FOUR_CHAR_CODE('ktxm')
-keyAETSMTextPointSize = FOUR_CHAR_CODE('ktps')
-keyAETSMEventRecord = FOUR_CHAR_CODE('tevt')
-keyAETSMEventRef = FOUR_CHAR_CODE('tevr')
-keyAETextServiceEncoding = FOUR_CHAR_CODE('tsen')
-keyAETextServiceMacEncoding = FOUR_CHAR_CODE('tmen')
-typeTextRange = FOUR_CHAR_CODE('txrn')
-typeComponentInstance = FOUR_CHAR_CODE('cmpi')
-typeOffsetArray = FOUR_CHAR_CODE('ofay')
-typeTextRangeArray = FOUR_CHAR_CODE('tray')
-typeLowLevelEventRecord = FOUR_CHAR_CODE('evtr')
-typeEventRef = FOUR_CHAR_CODE('evrf')
-typeText = typeChar
-kTSMOutsideOfBody = 1
-kTSMInsideOfBody = 2
-kTSMInsideOfActiveInputArea = 3
-kNextBody = 1
-kPreviousBody = 2
-kCaretPosition = 1
-kRawText = 2
-kSelectedRawText = 3
-kConvertedText = 4
-kSelectedConvertedText = 5
-kBlockFillText = 6
-kOutlineText = 7
-kSelectedText = 8
-keyAEHiliteRange = FOUR_CHAR_CODE('hrng')
-keyAEPinRange = FOUR_CHAR_CODE('pnrg')
-keyAEClauseOffsets = FOUR_CHAR_CODE('clau')
-keyAEOffset = FOUR_CHAR_CODE('ofst')
-keyAEPoint = FOUR_CHAR_CODE('gpos')
-keyAELeftSide = FOUR_CHAR_CODE('klef')
-keyAERegionClass = FOUR_CHAR_CODE('rgnc')
-keyAEDragging = FOUR_CHAR_CODE('bool')
-keyAELeadingEdge = keyAELeftSide
-typeUnicodeText = FOUR_CHAR_CODE('utxt')
-typeStyledUnicodeText = FOUR_CHAR_CODE('sutx')
-typeEncodedString = FOUR_CHAR_CODE('encs')
-typeCString = FOUR_CHAR_CODE('cstr')
-typePString = FOUR_CHAR_CODE('pstr')
-typeMeters = FOUR_CHAR_CODE('metr')
-typeInches = FOUR_CHAR_CODE('inch')
-typeFeet = FOUR_CHAR_CODE('feet')
-typeYards = FOUR_CHAR_CODE('yard')
-typeMiles = FOUR_CHAR_CODE('mile')
-typeKilometers = FOUR_CHAR_CODE('kmtr')
-typeCentimeters = FOUR_CHAR_CODE('cmtr')
-typeSquareMeters = FOUR_CHAR_CODE('sqrm')
-typeSquareFeet = FOUR_CHAR_CODE('sqft')
-typeSquareYards = FOUR_CHAR_CODE('sqyd')
-typeSquareMiles = FOUR_CHAR_CODE('sqmi')
-typeSquareKilometers = FOUR_CHAR_CODE('sqkm')
-typeLiters = FOUR_CHAR_CODE('litr')
-typeQuarts = FOUR_CHAR_CODE('qrts')
-typeGallons = FOUR_CHAR_CODE('galn')
-typeCubicMeters = FOUR_CHAR_CODE('cmet')
-typeCubicFeet = FOUR_CHAR_CODE('cfet')
-typeCubicInches = FOUR_CHAR_CODE('cuin')
-typeCubicCentimeter = FOUR_CHAR_CODE('ccmt')
-typeCubicYards = FOUR_CHAR_CODE('cyrd')
-typeKilograms = FOUR_CHAR_CODE('kgrm')
-typeGrams = FOUR_CHAR_CODE('gram')
-typeOunces = FOUR_CHAR_CODE('ozs ')
-typePounds = FOUR_CHAR_CODE('lbs ')
-typeDegreesC = FOUR_CHAR_CODE('degc')
-typeDegreesF = FOUR_CHAR_CODE('degf')
-typeDegreesK = FOUR_CHAR_CODE('degk')
-kFAServerApp = FOUR_CHAR_CODE('ssrv')
-kDoFolderActionEvent = FOUR_CHAR_CODE('fola')
-kFolderActionCode = FOUR_CHAR_CODE('actn')
-kFolderOpenedEvent = FOUR_CHAR_CODE('fopn')
-kFolderClosedEvent = FOUR_CHAR_CODE('fclo')
-kFolderWindowMovedEvent = FOUR_CHAR_CODE('fsiz')
-kFolderItemsAddedEvent = FOUR_CHAR_CODE('fget')
-kFolderItemsRemovedEvent = FOUR_CHAR_CODE('flos')
-kItemList = FOUR_CHAR_CODE('flst')
-kNewSizeParameter = FOUR_CHAR_CODE('fnsz')
-kFASuiteCode = FOUR_CHAR_CODE('faco')
-kFAAttachCommand = FOUR_CHAR_CODE('atfa')
-kFARemoveCommand = FOUR_CHAR_CODE('rmfa')
-kFAEditCommand = FOUR_CHAR_CODE('edfa')
-kFAFileParam = FOUR_CHAR_CODE('faal')
-kFAIndexParam = FOUR_CHAR_CODE('indx')
-kAEInternetSuite = FOUR_CHAR_CODE('gurl')
-kAEISWebStarSuite = FOUR_CHAR_CODE('WWW\xbd')
-kAEISGetURL = FOUR_CHAR_CODE('gurl')
-KAEISHandleCGI = FOUR_CHAR_CODE('sdoc')
-cURL = FOUR_CHAR_CODE('url ')
-cInternetAddress = FOUR_CHAR_CODE('IPAD')
-cHTML = FOUR_CHAR_CODE('html')
-cFTPItem = FOUR_CHAR_CODE('ftp ')
-kAEISHTTPSearchArgs = FOUR_CHAR_CODE('kfor')
-kAEISPostArgs = FOUR_CHAR_CODE('post')
-kAEISMethod = FOUR_CHAR_CODE('meth')
-kAEISClientAddress = FOUR_CHAR_CODE('addr')
-kAEISUserName = FOUR_CHAR_CODE('user')
-kAEISPassword = FOUR_CHAR_CODE('pass')
-kAEISFromUser = FOUR_CHAR_CODE('frmu')
-kAEISServerName = FOUR_CHAR_CODE('svnm')
-kAEISServerPort = FOUR_CHAR_CODE('svpt')
-kAEISScriptName = FOUR_CHAR_CODE('scnm')
-kAEISContentType = FOUR_CHAR_CODE('ctyp')
-kAEISReferrer = FOUR_CHAR_CODE('refr')
-kAEISUserAgent = FOUR_CHAR_CODE('Agnt')
-kAEISAction = FOUR_CHAR_CODE('Kact')
-kAEISActionPath = FOUR_CHAR_CODE('Kapt')
-kAEISClientIP = FOUR_CHAR_CODE('Kcip')
-kAEISFullRequest = FOUR_CHAR_CODE('Kfrq')
-pScheme = FOUR_CHAR_CODE('pusc')
-pHost = FOUR_CHAR_CODE('HOST')
-pPath = FOUR_CHAR_CODE('FTPc')
-pUserName = FOUR_CHAR_CODE('RAun')
-pUserPassword = FOUR_CHAR_CODE('RApw')
-pDNSForm = FOUR_CHAR_CODE('pDNS')
-pURL = FOUR_CHAR_CODE('pURL')
-pTextEncoding = FOUR_CHAR_CODE('ptxe')
-pFTPKind = FOUR_CHAR_CODE('kind')
-eScheme = FOUR_CHAR_CODE('esch')
-eurlHTTP = FOUR_CHAR_CODE('http')
-eurlHTTPS = FOUR_CHAR_CODE('htps')
-eurlFTP = FOUR_CHAR_CODE('ftp ')
-eurlMail = FOUR_CHAR_CODE('mail')
-eurlFile = FOUR_CHAR_CODE('file')
-eurlGopher = FOUR_CHAR_CODE('gphr')
-eurlTelnet = FOUR_CHAR_CODE('tlnt')
-eurlNews = FOUR_CHAR_CODE('news')
-eurlSNews = FOUR_CHAR_CODE('snws')
-eurlNNTP = FOUR_CHAR_CODE('nntp')
-eurlMessage = FOUR_CHAR_CODE('mess')
-eurlMailbox = FOUR_CHAR_CODE('mbox')
-eurlMulti = FOUR_CHAR_CODE('mult')
-eurlLaunch = FOUR_CHAR_CODE('laun')
-eurlAFP = FOUR_CHAR_CODE('afp ')
-eurlAT = FOUR_CHAR_CODE('at ')
-eurlEPPC = FOUR_CHAR_CODE('eppc')
-eurlRTSP = FOUR_CHAR_CODE('rtsp')
-eurlIMAP = FOUR_CHAR_CODE('imap')
-eurlNFS = FOUR_CHAR_CODE('unfs')
-eurlPOP = FOUR_CHAR_CODE('upop')
-eurlLDAP = FOUR_CHAR_CODE('uldp')
-eurlUnknown = FOUR_CHAR_CODE('url?')
-kConnSuite = FOUR_CHAR_CODE('macc')
-cDevSpec = FOUR_CHAR_CODE('cdev')
-cAddressSpec = FOUR_CHAR_CODE('cadr')
-cADBAddress = FOUR_CHAR_CODE('cadb')
-cAppleTalkAddress = FOUR_CHAR_CODE('cat ')
-cBusAddress = FOUR_CHAR_CODE('cbus')
-cEthernetAddress = FOUR_CHAR_CODE('cen ')
-cFireWireAddress = FOUR_CHAR_CODE('cfw ')
-cIPAddress = FOUR_CHAR_CODE('cip ')
-cLocalTalkAddress = FOUR_CHAR_CODE('clt ')
-cSCSIAddress = FOUR_CHAR_CODE('cscs')
-cTokenRingAddress = FOUR_CHAR_CODE('ctok')
-cUSBAddress = FOUR_CHAR_CODE('cusb')
-pDeviceType = FOUR_CHAR_CODE('pdvt')
-pDeviceAddress = FOUR_CHAR_CODE('pdva')
-pConduit = FOUR_CHAR_CODE('pcon')
-pProtocol = FOUR_CHAR_CODE('pprt')
-pATMachine = FOUR_CHAR_CODE('patm')
-pATZone = FOUR_CHAR_CODE('patz')
-pATType = FOUR_CHAR_CODE('patt')
-pDottedDecimal = FOUR_CHAR_CODE('pipd')
-pDNS = FOUR_CHAR_CODE('pdns')
-pPort = FOUR_CHAR_CODE('ppor')
-pNetwork = FOUR_CHAR_CODE('pnet')
-pNode = FOUR_CHAR_CODE('pnod')
-pSocket = FOUR_CHAR_CODE('psoc')
-pSCSIBus = FOUR_CHAR_CODE('pscb')
-pSCSILUN = FOUR_CHAR_CODE('pslu')
-eDeviceType = FOUR_CHAR_CODE('edvt')
-eAddressSpec = FOUR_CHAR_CODE('eads')
-eConduit = FOUR_CHAR_CODE('econ')
-eProtocol = FOUR_CHAR_CODE('epro')
-eADB = FOUR_CHAR_CODE('eadb')
-eAnalogAudio = FOUR_CHAR_CODE('epau')
-eAppleTalk = FOUR_CHAR_CODE('epat')
-eAudioLineIn = FOUR_CHAR_CODE('ecai')
-eAudioLineOut = FOUR_CHAR_CODE('ecal')
-eAudioOut = FOUR_CHAR_CODE('ecao')
-eBus = FOUR_CHAR_CODE('ebus')
-eCDROM = FOUR_CHAR_CODE('ecd ')
-eCommSlot = FOUR_CHAR_CODE('eccm')
-eDigitalAudio = FOUR_CHAR_CODE('epda')
-eDisplay = FOUR_CHAR_CODE('edds')
-eDVD = FOUR_CHAR_CODE('edvd')
-eEthernet = FOUR_CHAR_CODE('ecen')
-eFireWire = FOUR_CHAR_CODE('ecfw')
-eFloppy = FOUR_CHAR_CODE('efd ')
-eHD = FOUR_CHAR_CODE('ehd ')
-eInfrared = FOUR_CHAR_CODE('ecir')
-eIP = FOUR_CHAR_CODE('epip')
-eIrDA = FOUR_CHAR_CODE('epir')
-eIRTalk = FOUR_CHAR_CODE('epit')
-eKeyboard = FOUR_CHAR_CODE('ekbd')
-eLCD = FOUR_CHAR_CODE('edlc')
-eLocalTalk = FOUR_CHAR_CODE('eclt')
-eMacIP = FOUR_CHAR_CODE('epmi')
-eMacVideo = FOUR_CHAR_CODE('epmv')
-eMicrophone = FOUR_CHAR_CODE('ecmi')
-eModemPort = FOUR_CHAR_CODE('ecmp')
-eModemPrinterPort = FOUR_CHAR_CODE('empp')
-eModem = FOUR_CHAR_CODE('edmm')
-eMonitorOut = FOUR_CHAR_CODE('ecmn')
-eMouse = FOUR_CHAR_CODE('emou')
-eNuBusCard = FOUR_CHAR_CODE('ednb')
-eNuBus = FOUR_CHAR_CODE('enub')
-ePCcard = FOUR_CHAR_CODE('ecpc')
-ePCIbus = FOUR_CHAR_CODE('ecpi')
-ePCIcard = FOUR_CHAR_CODE('edpi')
-ePDSslot = FOUR_CHAR_CODE('ecpd')
-ePDScard = FOUR_CHAR_CODE('epds')
-ePointingDevice = FOUR_CHAR_CODE('edpd')
-ePostScript = FOUR_CHAR_CODE('epps')
-ePPP = FOUR_CHAR_CODE('eppp')
-ePrinterPort = FOUR_CHAR_CODE('ecpp')
-ePrinter = FOUR_CHAR_CODE('edpr')
-eSvideo = FOUR_CHAR_CODE('epsv')
-eSCSI = FOUR_CHAR_CODE('ecsc')
-eSerial = FOUR_CHAR_CODE('epsr')
-eSpeakers = FOUR_CHAR_CODE('edsp')
-eStorageDevice = FOUR_CHAR_CODE('edst')
-eSVGA = FOUR_CHAR_CODE('epsg')
-eTokenRing = FOUR_CHAR_CODE('etok')
-eTrackball = FOUR_CHAR_CODE('etrk')
-eTrackpad = FOUR_CHAR_CODE('edtp')
-eUSB = FOUR_CHAR_CODE('ecus')
-eVideoIn = FOUR_CHAR_CODE('ecvi')
-eVideoMonitor = FOUR_CHAR_CODE('edvm')
-eVideoOut = FOUR_CHAR_CODE('ecvo')
-cKeystroke = FOUR_CHAR_CODE('kprs')
-pKeystrokeKey = FOUR_CHAR_CODE('kMsg')
-pModifiers = FOUR_CHAR_CODE('kMod')
-pKeyKind = FOUR_CHAR_CODE('kknd')
-eModifiers = FOUR_CHAR_CODE('eMds')
-eOptionDown = FOUR_CHAR_CODE('Kopt')
-eCommandDown = FOUR_CHAR_CODE('Kcmd')
-eControlDown = FOUR_CHAR_CODE('Kctl')
-eShiftDown = FOUR_CHAR_CODE('Ksft')
-eCapsLockDown = FOUR_CHAR_CODE('Kclk')
-eKeyKind = FOUR_CHAR_CODE('ekst')
-eEscapeKey = 0x6B733500
-eDeleteKey = 0x6B733300
-eTabKey = 0x6B733000
-eReturnKey = 0x6B732400
-eClearKey = 0x6B734700
-eEnterKey = 0x6B734C00
-eUpArrowKey = 0x6B737E00
-eDownArrowKey = 0x6B737D00
-eLeftArrowKey = 0x6B737B00
-eRightArrowKey = 0x6B737C00
-eHelpKey = 0x6B737200
-eHomeKey = 0x6B737300
-ePageUpKey = 0x6B737400
-ePageDownKey = 0x6B737900
-eForwardDelKey = 0x6B737500
-eEndKey = 0x6B737700
-eF1Key = 0x6B737A00
-eF2Key = 0x6B737800
-eF3Key = 0x6B736300
-eF4Key = 0x6B737600
-eF5Key = 0x6B736000
-eF6Key = 0x6B736100
-eF7Key = 0x6B736200
-eF8Key = 0x6B736400
-eF9Key = 0x6B736500
-eF10Key = 0x6B736D00
-eF11Key = 0x6B736700
-eF12Key = 0x6B736F00
-eF13Key = 0x6B736900
-eF14Key = 0x6B736B00
-eF15Key = 0x6B737100
-kAEAND = FOUR_CHAR_CODE('AND ')
-kAEOR = FOUR_CHAR_CODE('OR ')
-kAENOT = FOUR_CHAR_CODE('NOT ')
-kAEFirst = FOUR_CHAR_CODE('firs')
-kAELast = FOUR_CHAR_CODE('last')
-kAEMiddle = FOUR_CHAR_CODE('midd')
-kAEAny = FOUR_CHAR_CODE('any ')
-kAEAll = FOUR_CHAR_CODE('all ')
-kAENext = FOUR_CHAR_CODE('next')
-kAEPrevious = FOUR_CHAR_CODE('prev')
-keyAECompOperator = FOUR_CHAR_CODE('relo')
-keyAELogicalTerms = FOUR_CHAR_CODE('term')
-keyAELogicalOperator = FOUR_CHAR_CODE('logc')
-keyAEObject1 = FOUR_CHAR_CODE('obj1')
-keyAEObject2 = FOUR_CHAR_CODE('obj2')
-keyAEDesiredClass = FOUR_CHAR_CODE('want')
-keyAEContainer = FOUR_CHAR_CODE('from')
-keyAEKeyForm = FOUR_CHAR_CODE('form')
-keyAEKeyData = FOUR_CHAR_CODE('seld')
-keyAERangeStart = FOUR_CHAR_CODE('star')
-keyAERangeStop = FOUR_CHAR_CODE('stop')
-keyDisposeTokenProc = FOUR_CHAR_CODE('xtok')
-keyAECompareProc = FOUR_CHAR_CODE('cmpr')
-keyAECountProc = FOUR_CHAR_CODE('cont')
-keyAEMarkTokenProc = FOUR_CHAR_CODE('mkid')
-keyAEMarkProc = FOUR_CHAR_CODE('mark')
-keyAEAdjustMarksProc = FOUR_CHAR_CODE('adjm')
-keyAEGetErrDescProc = FOUR_CHAR_CODE('indc')
-formAbsolutePosition = FOUR_CHAR_CODE('indx')
-formRelativePosition = FOUR_CHAR_CODE('rele')
-formTest = FOUR_CHAR_CODE('test')
-formRange = FOUR_CHAR_CODE('rang')
-formPropertyID = FOUR_CHAR_CODE('prop')
-formName = FOUR_CHAR_CODE('name')
-typeObjectSpecifier = FOUR_CHAR_CODE('obj ')
-typeObjectBeingExamined = FOUR_CHAR_CODE('exmn')
-typeCurrentContainer = FOUR_CHAR_CODE('ccnt')
-typeToken = FOUR_CHAR_CODE('toke')
-typeRelativeDescriptor = FOUR_CHAR_CODE('rel ')
-typeAbsoluteOrdinal = FOUR_CHAR_CODE('abso')
-typeIndexDescriptor = FOUR_CHAR_CODE('inde')
-typeRangeDescriptor = FOUR_CHAR_CODE('rang')
-typeLogicalDescriptor = FOUR_CHAR_CODE('logi')
-typeCompDescriptor = FOUR_CHAR_CODE('cmpd')
-typeOSLTokenList = FOUR_CHAR_CODE('ostl')
-kAEIDoMinimum = 0x0000
-kAEIDoWhose = 0x0001
-kAEIDoMarking = 0x0004
-kAEPassSubDescs = 0x0008
-kAEResolveNestedLists = 0x0010
-kAEHandleSimpleRanges = 0x0020
-kAEUseRelativeIterators = 0x0040
-typeWhoseDescriptor = FOUR_CHAR_CODE('whos')
-formWhose = FOUR_CHAR_CODE('whos')
-typeWhoseRange = FOUR_CHAR_CODE('wrng')
-keyAEWhoseRangeStart = FOUR_CHAR_CODE('wstr')
-keyAEWhoseRangeStop = FOUR_CHAR_CODE('wstp')
-keyAEIndex = FOUR_CHAR_CODE('kidx')
-keyAETest = FOUR_CHAR_CODE('ktst')
diff --git a/Lib/plat-mac/Carbon/AppleHelp.py b/Lib/plat-mac/Carbon/AppleHelp.py
deleted file mode 100644
index 3496d5926c5..00000000000
--- a/Lib/plat-mac/Carbon/AppleHelp.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# Generated from 'AppleHelp.h'
-
-kAHInternalErr = -10790
-kAHInternetConfigPrefErr = -10791
-kAHTOCTypeUser = 0
-kAHTOCTypeDeveloper = 1
diff --git a/Lib/plat-mac/Carbon/CF.py b/Lib/plat-mac/Carbon/CF.py
deleted file mode 100644
index 4a784c0f8e7..00000000000
--- a/Lib/plat-mac/Carbon/CF.py
+++ /dev/null
@@ -1 +0,0 @@
-from _CF import *
diff --git a/Lib/plat-mac/Carbon/CG.py b/Lib/plat-mac/Carbon/CG.py
deleted file mode 100644
index 96f5772321c..00000000000
--- a/Lib/plat-mac/Carbon/CG.py
+++ /dev/null
@@ -1 +0,0 @@
-from _CG import *
diff --git a/Lib/plat-mac/Carbon/CarbonEvents.py b/Lib/plat-mac/Carbon/CarbonEvents.py
deleted file mode 100644
index 357ee5d3886..00000000000
--- a/Lib/plat-mac/Carbon/CarbonEvents.py
+++ /dev/null
@@ -1,451 +0,0 @@
-# Generated from 'CarbonEvents.h'
-
-def FOUR_CHAR_CODE(x): return x
-def FOUR_CHAR_CODE(x): return x
-false = 0
-true = 1
-keyAEEventClass = FOUR_CHAR_CODE('evcl')
-keyAEEventID = FOUR_CHAR_CODE('evti')
-eventAlreadyPostedErr = -9860
-eventTargetBusyErr = -9861
-eventClassInvalidErr = -9862
-eventClassIncorrectErr = -9864
-eventHandlerAlreadyInstalledErr = -9866
-eventInternalErr = -9868
-eventKindIncorrectErr = -9869
-eventParameterNotFoundErr = -9870
-eventNotHandledErr = -9874
-eventLoopTimedOutErr = -9875
-eventLoopQuitErr = -9876
-eventNotInQueueErr = -9877
-eventHotKeyExistsErr = -9878
-eventHotKeyInvalidErr = -9879
-kEventPriorityLow = 0
-kEventPriorityStandard = 1
-kEventPriorityHigh = 2
-kEventLeaveInQueue = false
-kEventRemoveFromQueue = true
-kTrackMouseLocationOptionDontConsumeMouseUp = (1 << 0)
-kMouseTrackingMouseDown = 1
-kMouseTrackingMouseUp = 2
-kMouseTrackingMouseExited = 3
-kMouseTrackingMouseEntered = 4
-kMouseTrackingMouseDragged = 5
-kMouseTrackingKeyModifiersChanged = 6
-kMouseTrackingUserCancelled = 7
-kMouseTrackingTimedOut = 8
-kMouseTrackingMouseMoved = 9
-kEventAttributeNone = 0
-kEventAttributeUserEvent = (1 << 0)
-kEventClassMouse = FOUR_CHAR_CODE('mous')
-kEventClassKeyboard = FOUR_CHAR_CODE('keyb')
-kEventClassTextInput = FOUR_CHAR_CODE('text')
-kEventClassApplication = FOUR_CHAR_CODE('appl')
-kEventClassAppleEvent = FOUR_CHAR_CODE('eppc')
-kEventClassMenu = FOUR_CHAR_CODE('menu')
-kEventClassWindow = FOUR_CHAR_CODE('wind')
-kEventClassControl = FOUR_CHAR_CODE('cntl')
-kEventClassCommand = FOUR_CHAR_CODE('cmds')
-kEventClassTablet = FOUR_CHAR_CODE('tblt')
-kEventClassVolume = FOUR_CHAR_CODE('vol ')
-kEventClassAppearance = FOUR_CHAR_CODE('appm')
-kEventClassService = FOUR_CHAR_CODE('serv')
-kEventMouseDown = 1
-kEventMouseUp = 2
-kEventMouseMoved = 5
-kEventMouseDragged = 6
-kEventMouseWheelMoved = 10
-kEventMouseButtonPrimary = 1
-kEventMouseButtonSecondary = 2
-kEventMouseButtonTertiary = 3
-kEventMouseWheelAxisX = 0
-kEventMouseWheelAxisY = 1
-kEventTextInputUpdateActiveInputArea = 1
-kEventTextInputUnicodeForKeyEvent = 2
-kEventTextInputOffsetToPos = 3
-kEventTextInputPosToOffset = 4
-kEventTextInputShowHideBottomWindow = 5
-kEventTextInputGetSelectedText = 6
-kEventRawKeyDown = 1
-kEventRawKeyRepeat = 2
-kEventRawKeyUp = 3
-kEventRawKeyModifiersChanged = 4
-kEventHotKeyPressed = 5
-kEventHotKeyReleased = 6
-kEventKeyModifierNumLockBit = 16
-kEventKeyModifierFnBit = 17
-kEventKeyModifierNumLockMask = 1L << kEventKeyModifierNumLockBit
-kEventKeyModifierFnMask = 1L << kEventKeyModifierFnBit
-kEventAppActivated = 1
-kEventAppDeactivated = 2
-kEventAppQuit = 3
-kEventAppLaunchNotification = 4
-kEventAppLaunched = 5
-kEventAppTerminated = 6
-kEventAppFrontSwitched = 7
-kEventAppGetDockTileMenu = 20
-kEventAppleEvent = 1
-kEventWindowUpdate = 1
-kEventWindowDrawContent = 2
-kEventWindowActivated = 5
-kEventWindowDeactivated = 6
-kEventWindowGetClickActivation = 7
-kEventWindowShowing = 22
-kEventWindowHiding = 23
-kEventWindowShown = 24
-kEventWindowHidden = 25
-kEventWindowCollapsing = 86
-kEventWindowCollapsed = 67
-kEventWindowExpanding = 87
-kEventWindowExpanded = 70
-kEventWindowZoomed = 76
-kEventWindowBoundsChanging = 26
-kEventWindowBoundsChanged = 27
-kEventWindowResizeStarted = 28
-kEventWindowResizeCompleted = 29
-kEventWindowDragStarted = 30
-kEventWindowDragCompleted = 31
-kEventWindowClosed = 73
-kWindowBoundsChangeUserDrag = (1 << 0)
-kWindowBoundsChangeUserResize = (1 << 1)
-kWindowBoundsChangeSizeChanged = (1 << 2)
-kWindowBoundsChangeOriginChanged = (1 << 3)
-kWindowBoundsChangeZoom = (1 << 4)
-kEventWindowClickDragRgn = 32
-kEventWindowClickResizeRgn = 33
-kEventWindowClickCollapseRgn = 34
-kEventWindowClickCloseRgn = 35
-kEventWindowClickZoomRgn = 36
-kEventWindowClickContentRgn = 37
-kEventWindowClickProxyIconRgn = 38
-kEventWindowClickToolbarButtonRgn = 41
-kEventWindowClickStructureRgn = 42
-kEventWindowCursorChange = 40
-kEventWindowCollapse = 66
-kEventWindowCollapseAll = 68
-kEventWindowExpand = 69
-kEventWindowExpandAll = 71
-kEventWindowClose = 72
-kEventWindowCloseAll = 74
-kEventWindowZoom = 75
-kEventWindowZoomAll = 77
-kEventWindowContextualMenuSelect = 78
-kEventWindowPathSelect = 79
-kEventWindowGetIdealSize = 80
-kEventWindowGetMinimumSize = 81
-kEventWindowGetMaximumSize = 82
-kEventWindowConstrain = 83
-kEventWindowHandleContentClick = 85
-kEventWindowProxyBeginDrag = 128
-kEventWindowProxyEndDrag = 129
-kEventWindowToolbarSwitchMode = 150
-kDockChangedUser = 1
-kDockChangedOrientation = 2
-kDockChangedAutohide = 3
-kDockChangedDisplay = 4
-kDockChangedItems = 5
-kDockChangedUnknown = 6
-kEventWindowFocusAcquired = 200
-kEventWindowFocusRelinquish = 201
-kEventWindowDrawFrame = 1000
-kEventWindowDrawPart = 1001
-kEventWindowGetRegion = 1002
-kEventWindowHitTest = 1003
-kEventWindowInit = 1004
-kEventWindowDispose = 1005
-kEventWindowDragHilite = 1006
-kEventWindowModified = 1007
-kEventWindowSetupProxyDragImage = 1008
-kEventWindowStateChanged = 1009
-kEventWindowMeasureTitle = 1010
-kEventWindowDrawGrowBox = 1011
-kEventWindowGetGrowImageRegion = 1012
-kEventWindowPaint = 1013
-kEventMenuBeginTracking = 1
-kEventMenuEndTracking = 2
-kEventMenuChangeTrackingMode = 3
-kEventMenuOpening = 4
-kEventMenuClosed = 5
-kEventMenuTargetItem = 6
-kEventMenuMatchKey = 7
-kEventMenuEnableItems = 8
-kEventMenuPopulate = 9
-kEventMenuMeasureItemWidth = 100
-kEventMenuMeasureItemHeight = 101
-kEventMenuDrawItem = 102
-kEventMenuDrawItemContent = 103
-kEventMenuDispose = 1001
-kMenuContextMenuBar = 1 << 0
-kMenuContextPullDown = 1 << 8
-kMenuContextPopUp = 1 << 9
-kMenuContextSubmenu = 1 << 10
-kMenuContextMenuBarTracking = 1 << 16
-kMenuContextPopUpTracking = 1 << 17
-kMenuContextKeyMatching = 1 << 18
-kMenuContextMenuEnabling = 1 << 19
-kMenuContextCommandIDSearch = 1 << 20
-kEventProcessCommand = 1
-kEventCommandProcess = 1
-kEventCommandUpdateStatus = 2
-kHICommandOK = FOUR_CHAR_CODE('ok ')
-kHICommandCancel = FOUR_CHAR_CODE('not!')
-kHICommandQuit = FOUR_CHAR_CODE('quit')
-kHICommandUndo = FOUR_CHAR_CODE('undo')
-kHICommandRedo = FOUR_CHAR_CODE('redo')
-kHICommandCut = FOUR_CHAR_CODE('cut ')
-kHICommandCopy = FOUR_CHAR_CODE('copy')
-kHICommandPaste = FOUR_CHAR_CODE('past')
-kHICommandClear = FOUR_CHAR_CODE('clea')
-kHICommandSelectAll = FOUR_CHAR_CODE('sall')
-kHICommandHide = FOUR_CHAR_CODE('hide')
-kHICommandHideOthers = FOUR_CHAR_CODE('hido')
-kHICommandShowAll = FOUR_CHAR_CODE('shal')
-kHICommandPreferences = FOUR_CHAR_CODE('pref')
-kHICommandZoomWindow = FOUR_CHAR_CODE('zoom')
-kHICommandMinimizeWindow = FOUR_CHAR_CODE('mini')
-kHICommandMinimizeAll = FOUR_CHAR_CODE('mina')
-kHICommandMaximizeWindow = FOUR_CHAR_CODE('maxi')
-kHICommandMaximizeAll = FOUR_CHAR_CODE('maxa')
-kHICommandArrangeInFront = FOUR_CHAR_CODE('frnt')
-kHICommandBringAllToFront = FOUR_CHAR_CODE('bfrt')
-kHICommandWindowListSeparator = FOUR_CHAR_CODE('wldv')
-kHICommandWindowListTerminator = FOUR_CHAR_CODE('wlst')
-kHICommandSelectWindow = FOUR_CHAR_CODE('swin')
-kHICommandAbout = FOUR_CHAR_CODE('abou')
-kHICommandNew = FOUR_CHAR_CODE('new ')
-kHICommandOpen = FOUR_CHAR_CODE('open')
-kHICommandClose = FOUR_CHAR_CODE('clos')
-kHICommandSave = FOUR_CHAR_CODE('save')
-kHICommandSaveAs = FOUR_CHAR_CODE('svas')
-kHICommandRevert = FOUR_CHAR_CODE('rvrt')
-kHICommandPrint = FOUR_CHAR_CODE('prnt')
-kHICommandPageSetup = FOUR_CHAR_CODE('page')
-kHICommandAppHelp = FOUR_CHAR_CODE('ahlp')
-kHICommandFromMenu = (1L << 0)
-kHICommandFromControl = (1L << 1)
-kHICommandFromWindow = (1L << 2)
-kEventControlInitialize = 1000
-kEventControlDispose = 1001
-kEventControlGetOptimalBounds = 1003
-kEventControlDefInitialize = kEventControlInitialize
-kEventControlDefDispose = kEventControlDispose
-kEventControlHit = 1
-kEventControlSimulateHit = 2
-kEventControlHitTest = 3
-kEventControlDraw = 4
-kEventControlApplyBackground = 5
-kEventControlApplyTextColor = 6
-kEventControlSetFocusPart = 7
-kEventControlGetFocusPart = 8
-kEventControlActivate = 9
-kEventControlDeactivate = 10
-kEventControlSetCursor = 11
-kEventControlContextualMenuClick = 12
-kEventControlClick = 13
-kEventControlTrack = 51
-kEventControlGetScrollToHereStartPoint = 52
-kEventControlGetIndicatorDragConstraint = 53
-kEventControlIndicatorMoved = 54
-kEventControlGhostingFinished = 55
-kEventControlGetActionProcPart = 56
-kEventControlGetPartRegion = 101
-kEventControlGetPartBounds = 102
-kEventControlSetData = 103
-kEventControlGetData = 104
-kEventControlValueFieldChanged = 151
-kEventControlAddedSubControl = 152
-kEventControlRemovingSubControl = 153
-kEventControlBoundsChanged = 154
-kEventControlOwningWindowChanged = 159
-kEventControlArbitraryMessage = 201
-kControlBoundsChangeSizeChanged = (1 << 2)
-kControlBoundsChangePositionChanged = (1 << 3)
-kEventTabletPoint = 1
-kEventTabletProximity = 2
-kEventTabletPointer = 1
-kEventVolumeMounted = 1
-kEventVolumeUnmounted = 2
-typeFSVolumeRefNum = FOUR_CHAR_CODE('voln')
-kEventAppearanceScrollBarVariantChanged = 1
-kEventServiceCopy = 1
-kEventServicePaste = 2
-kEventServiceGetTypes = 3
-kEventServicePerform = 4
-kEventParamDirectObject = FOUR_CHAR_CODE('----')
-kEventParamPostTarget = FOUR_CHAR_CODE('ptrg')
-typeEventTargetRef = FOUR_CHAR_CODE('etrg')
-kEventParamWindowRef = FOUR_CHAR_CODE('wind')
-kEventParamGrafPort = FOUR_CHAR_CODE('graf')
-kEventParamDragRef = FOUR_CHAR_CODE('drag')
-kEventParamMenuRef = FOUR_CHAR_CODE('menu')
-kEventParamEventRef = FOUR_CHAR_CODE('evnt')
-kEventParamControlRef = FOUR_CHAR_CODE('ctrl')
-kEventParamRgnHandle = FOUR_CHAR_CODE('rgnh')
-kEventParamEnabled = FOUR_CHAR_CODE('enab')
-kEventParamDimensions = FOUR_CHAR_CODE('dims')
-kEventParamAvailableBounds = FOUR_CHAR_CODE('avlb')
-kEventParamAEEventID = keyAEEventID
-kEventParamAEEventClass = keyAEEventClass
-kEventParamCGContextRef = FOUR_CHAR_CODE('cntx')
-kEventParamDeviceDepth = FOUR_CHAR_CODE('devd')
-kEventParamDeviceColor = FOUR_CHAR_CODE('devc')
-typeWindowRef = FOUR_CHAR_CODE('wind')
-typeGrafPtr = FOUR_CHAR_CODE('graf')
-typeGWorldPtr = FOUR_CHAR_CODE('gwld')
-typeDragRef = FOUR_CHAR_CODE('drag')
-typeMenuRef = FOUR_CHAR_CODE('menu')
-typeControlRef = FOUR_CHAR_CODE('ctrl')
-typeCollection = FOUR_CHAR_CODE('cltn')
-typeQDRgnHandle = FOUR_CHAR_CODE('rgnh')
-typeOSStatus = FOUR_CHAR_CODE('osst')
-typeCFStringRef = FOUR_CHAR_CODE('cfst')
-typeCFIndex = FOUR_CHAR_CODE('cfix')
-typeCFTypeRef = FOUR_CHAR_CODE('cfty')
-typeCGContextRef = FOUR_CHAR_CODE('cntx')
-typeHIPoint = FOUR_CHAR_CODE('hipt')
-typeHISize = FOUR_CHAR_CODE('hisz')
-typeHIRect = FOUR_CHAR_CODE('hirc')
-kEventParamMouseLocation = FOUR_CHAR_CODE('mloc')
-kEventParamMouseButton = FOUR_CHAR_CODE('mbtn')
-kEventParamClickCount = FOUR_CHAR_CODE('ccnt')
-kEventParamMouseWheelAxis = FOUR_CHAR_CODE('mwax')
-kEventParamMouseWheelDelta = FOUR_CHAR_CODE('mwdl')
-kEventParamMouseDelta = FOUR_CHAR_CODE('mdta')
-kEventParamMouseChord = FOUR_CHAR_CODE('chor')
-kEventParamTabletEventType = FOUR_CHAR_CODE('tblt')
-typeMouseButton = FOUR_CHAR_CODE('mbtn')
-typeMouseWheelAxis = FOUR_CHAR_CODE('mwax')
-kEventParamKeyCode = FOUR_CHAR_CODE('kcod')
-kEventParamKeyMacCharCodes = FOUR_CHAR_CODE('kchr')
-kEventParamKeyModifiers = FOUR_CHAR_CODE('kmod')
-kEventParamKeyUnicodes = FOUR_CHAR_CODE('kuni')
-kEventParamKeyboardType = FOUR_CHAR_CODE('kbdt')
-typeEventHotKeyID = FOUR_CHAR_CODE('hkid')
-kEventParamTextInputSendRefCon = FOUR_CHAR_CODE('tsrc')
-kEventParamTextInputSendComponentInstance = FOUR_CHAR_CODE('tsci')
-kEventParamTextInputSendSLRec = FOUR_CHAR_CODE('tssl')
-kEventParamTextInputReplySLRec = FOUR_CHAR_CODE('trsl')
-kEventParamTextInputSendText = FOUR_CHAR_CODE('tstx')
-kEventParamTextInputReplyText = FOUR_CHAR_CODE('trtx')
-kEventParamTextInputSendUpdateRng = FOUR_CHAR_CODE('tsup')
-kEventParamTextInputSendHiliteRng = FOUR_CHAR_CODE('tshi')
-kEventParamTextInputSendClauseRng = FOUR_CHAR_CODE('tscl')
-kEventParamTextInputSendPinRng = FOUR_CHAR_CODE('tspn')
-kEventParamTextInputSendFixLen = FOUR_CHAR_CODE('tsfx')
-kEventParamTextInputSendLeadingEdge = FOUR_CHAR_CODE('tsle')
-kEventParamTextInputReplyLeadingEdge = FOUR_CHAR_CODE('trle')
-kEventParamTextInputSendTextOffset = FOUR_CHAR_CODE('tsto')
-kEventParamTextInputReplyTextOffset = FOUR_CHAR_CODE('trto')
-kEventParamTextInputReplyRegionClass = FOUR_CHAR_CODE('trrg')
-kEventParamTextInputSendCurrentPoint = FOUR_CHAR_CODE('tscp')
-kEventParamTextInputSendDraggingMode = FOUR_CHAR_CODE('tsdm')
-kEventParamTextInputReplyPoint = FOUR_CHAR_CODE('trpt')
-kEventParamTextInputReplyFont = FOUR_CHAR_CODE('trft')
-kEventParamTextInputReplyFMFont = FOUR_CHAR_CODE('trfm')
-kEventParamTextInputReplyPointSize = FOUR_CHAR_CODE('trpz')
-kEventParamTextInputReplyLineHeight = FOUR_CHAR_CODE('trlh')
-kEventParamTextInputReplyLineAscent = FOUR_CHAR_CODE('trla')
-kEventParamTextInputReplyTextAngle = FOUR_CHAR_CODE('trta')
-kEventParamTextInputSendShowHide = FOUR_CHAR_CODE('tssh')
-kEventParamTextInputReplyShowHide = FOUR_CHAR_CODE('trsh')
-kEventParamTextInputSendKeyboardEvent = FOUR_CHAR_CODE('tske')
-kEventParamTextInputSendTextServiceEncoding = FOUR_CHAR_CODE('tsse')
-kEventParamTextInputSendTextServiceMacEncoding = FOUR_CHAR_CODE('tssm')
-kEventParamHICommand = FOUR_CHAR_CODE('hcmd')
-typeHICommand = FOUR_CHAR_CODE('hcmd')
-kEventParamWindowFeatures = FOUR_CHAR_CODE('wftr')
-kEventParamWindowDefPart = FOUR_CHAR_CODE('wdpc')
-kEventParamCurrentBounds = FOUR_CHAR_CODE('crct')
-kEventParamOriginalBounds = FOUR_CHAR_CODE('orct')
-kEventParamPreviousBounds = FOUR_CHAR_CODE('prct')
-kEventParamClickActivation = FOUR_CHAR_CODE('clac')
-kEventParamWindowRegionCode = FOUR_CHAR_CODE('wshp')
-kEventParamWindowDragHiliteFlag = FOUR_CHAR_CODE('wdhf')
-kEventParamWindowModifiedFlag = FOUR_CHAR_CODE('wmff')
-kEventParamWindowProxyGWorldPtr = FOUR_CHAR_CODE('wpgw')
-kEventParamWindowProxyImageRgn = FOUR_CHAR_CODE('wpir')
-kEventParamWindowProxyOutlineRgn = FOUR_CHAR_CODE('wpor')
-kEventParamWindowStateChangedFlags = FOUR_CHAR_CODE('wscf')
-kEventParamWindowTitleFullWidth = FOUR_CHAR_CODE('wtfw')
-kEventParamWindowTitleTextWidth = FOUR_CHAR_CODE('wttw')
-kEventParamWindowGrowRect = FOUR_CHAR_CODE('grct')
-kEventParamAttributes = FOUR_CHAR_CODE('attr')
-kEventParamDockChangedReason = FOUR_CHAR_CODE('dcrs')
-kEventParamPreviousDockRect = FOUR_CHAR_CODE('pdrc')
-kEventParamCurrentDockRect = FOUR_CHAR_CODE('cdrc')
-typeWindowRegionCode = FOUR_CHAR_CODE('wshp')
-typeWindowDefPartCode = FOUR_CHAR_CODE('wdpt')
-typeClickActivationResult = FOUR_CHAR_CODE('clac')
-kEventParamControlPart = FOUR_CHAR_CODE('cprt')
-kEventParamInitCollection = FOUR_CHAR_CODE('icol')
-kEventParamControlMessage = FOUR_CHAR_CODE('cmsg')
-kEventParamControlParam = FOUR_CHAR_CODE('cprm')
-kEventParamControlResult = FOUR_CHAR_CODE('crsl')
-kEventParamControlRegion = FOUR_CHAR_CODE('crgn')
-kEventParamControlAction = FOUR_CHAR_CODE('caup')
-kEventParamControlIndicatorDragConstraint = FOUR_CHAR_CODE('cidc')
-kEventParamControlIndicatorRegion = FOUR_CHAR_CODE('cirn')
-kEventParamControlIsGhosting = FOUR_CHAR_CODE('cgst')
-kEventParamControlIndicatorOffset = FOUR_CHAR_CODE('ciof')
-kEventParamControlClickActivationResult = FOUR_CHAR_CODE('ccar')
-kEventParamControlSubControl = FOUR_CHAR_CODE('csub')
-kEventParamControlOptimalBounds = FOUR_CHAR_CODE('cobn')
-kEventParamControlOptimalBaselineOffset = FOUR_CHAR_CODE('cobo')
-kEventParamControlDataTag = FOUR_CHAR_CODE('cdtg')
-kEventParamControlDataBuffer = FOUR_CHAR_CODE('cdbf')
-kEventParamControlDataBufferSize = FOUR_CHAR_CODE('cdbs')
-kEventParamControlDrawDepth = FOUR_CHAR_CODE('cddp')
-kEventParamControlDrawInColor = FOUR_CHAR_CODE('cdic')
-kEventParamControlFeatures = FOUR_CHAR_CODE('cftr')
-kEventParamControlPartBounds = FOUR_CHAR_CODE('cpbd')
-kEventParamControlOriginalOwningWindow = FOUR_CHAR_CODE('coow')
-kEventParamControlCurrentOwningWindow = FOUR_CHAR_CODE('ccow')
-typeControlActionUPP = FOUR_CHAR_CODE('caup')
-typeIndicatorDragConstraint = FOUR_CHAR_CODE('cidc')
-typeControlPartCode = FOUR_CHAR_CODE('cprt')
-kEventParamCurrentMenuTrackingMode = FOUR_CHAR_CODE('cmtm')
-kEventParamNewMenuTrackingMode = FOUR_CHAR_CODE('nmtm')
-kEventParamMenuFirstOpen = FOUR_CHAR_CODE('1sto')
-kEventParamMenuItemIndex = FOUR_CHAR_CODE('item')
-kEventParamMenuCommand = FOUR_CHAR_CODE('mcmd')
-kEventParamEnableMenuForKeyEvent = FOUR_CHAR_CODE('fork')
-kEventParamMenuEventOptions = FOUR_CHAR_CODE('meop')
-kEventParamMenuContext = FOUR_CHAR_CODE('mctx')
-kEventParamMenuItemBounds = FOUR_CHAR_CODE('mitb')
-kEventParamMenuMarkBounds = FOUR_CHAR_CODE('mmkb')
-kEventParamMenuIconBounds = FOUR_CHAR_CODE('micb')
-kEventParamMenuTextBounds = FOUR_CHAR_CODE('mtxb')
-kEventParamMenuTextBaseline = FOUR_CHAR_CODE('mtbl')
-kEventParamMenuCommandKeyBounds = FOUR_CHAR_CODE('mcmb')
-kEventParamMenuVirtualTop = FOUR_CHAR_CODE('mvrt')
-kEventParamMenuVirtualBottom = FOUR_CHAR_CODE('mvrb')
-kEventParamMenuDrawState = FOUR_CHAR_CODE('mdrs')
-kEventParamMenuItemType = FOUR_CHAR_CODE('mitp')
-kEventParamMenuItemWidth = FOUR_CHAR_CODE('mitw')
-kEventParamMenuItemHeight = FOUR_CHAR_CODE('mith')
-typeMenuItemIndex = FOUR_CHAR_CODE('midx')
-typeMenuCommand = FOUR_CHAR_CODE('mcmd')
-typeMenuTrackingMode = FOUR_CHAR_CODE('mtmd')
-typeMenuEventOptions = FOUR_CHAR_CODE('meop')
-typeThemeMenuState = FOUR_CHAR_CODE('tmns')
-typeThemeMenuItemType = FOUR_CHAR_CODE('tmit')
-kEventParamProcessID = FOUR_CHAR_CODE('psn ')
-kEventParamLaunchRefCon = FOUR_CHAR_CODE('lref')
-kEventParamLaunchErr = FOUR_CHAR_CODE('err ')
-kEventParamTabletPointRec = FOUR_CHAR_CODE('tbrc')
-kEventParamTabletProximityRec = FOUR_CHAR_CODE('tbpx')
-typeTabletPointRec = FOUR_CHAR_CODE('tbrc')
-typeTabletProximityRec = FOUR_CHAR_CODE('tbpx')
-kEventParamTabletPointerRec = FOUR_CHAR_CODE('tbrc')
-typeTabletPointerRec = FOUR_CHAR_CODE('tbrc')
-kEventParamNewScrollBarVariant = FOUR_CHAR_CODE('nsbv')
-kEventParamScrapRef = FOUR_CHAR_CODE('scrp')
-kEventParamServiceCopyTypes = FOUR_CHAR_CODE('svsd')
-kEventParamServicePasteTypes = FOUR_CHAR_CODE('svpt')
-kEventParamServiceMessageName = FOUR_CHAR_CODE('svmg')
-kEventParamServiceUserData = FOUR_CHAR_CODE('svud')
-typeScrapRef = FOUR_CHAR_CODE('scrp')
-typeCFMutableArrayRef = FOUR_CHAR_CODE('cfma')
-# sHandler = NewEventHandlerUPP( x )
-kMouseTrackingMousePressed = kMouseTrackingMouseDown
-kMouseTrackingMouseReleased = kMouseTrackingMouseUp
diff --git a/Lib/plat-mac/Carbon/CarbonEvt.py b/Lib/plat-mac/Carbon/CarbonEvt.py
deleted file mode 100644
index 63a77929931..00000000000
--- a/Lib/plat-mac/Carbon/CarbonEvt.py
+++ /dev/null
@@ -1 +0,0 @@
-from _CarbonEvt import *
diff --git a/Lib/plat-mac/Carbon/Cm.py b/Lib/plat-mac/Carbon/Cm.py
deleted file mode 100644
index 3c8bc331b10..00000000000
--- a/Lib/plat-mac/Carbon/Cm.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Cm import *
diff --git a/Lib/plat-mac/Carbon/Components.py b/Lib/plat-mac/Carbon/Components.py
deleted file mode 100644
index 75574cf6d04..00000000000
--- a/Lib/plat-mac/Carbon/Components.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# Generated from 'Components.h'
-
-def FOUR_CHAR_CODE(x): return x
-kAppleManufacturer = FOUR_CHAR_CODE('appl')
-kComponentResourceType = FOUR_CHAR_CODE('thng')
-kComponentAliasResourceType = FOUR_CHAR_CODE('thga')
-kAnyComponentType = 0
-kAnyComponentSubType = 0
-kAnyComponentManufacturer = 0
-kAnyComponentFlagsMask = 0
-cmpIsMissing = 1L << 29
-cmpWantsRegisterMessage = 1L << 31
-kComponentOpenSelect = -1
-kComponentCloseSelect = -2
-kComponentCanDoSelect = -3
-kComponentVersionSelect = -4
-kComponentRegisterSelect = -5
-kComponentTargetSelect = -6
-kComponentUnregisterSelect = -7
-kComponentGetMPWorkFunctionSelect = -8
-kComponentExecuteWiredActionSelect = -9
-kComponentGetPublicResourceSelect = -10
-componentDoAutoVersion = (1 << 0)
-componentWantsUnregister = (1 << 1)
-componentAutoVersionIncludeFlags = (1 << 2)
-componentHasMultiplePlatforms = (1 << 3)
-componentLoadResident = (1 << 4)
-defaultComponentIdentical = 0
-defaultComponentAnyFlags = 1
-defaultComponentAnyManufacturer = 2
-defaultComponentAnySubType = 4
-defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer)
-defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
-registerComponentGlobal = 1
-registerComponentNoDuplicates = 2
-registerComponentAfterExisting = 4
-registerComponentAliasesOnly = 8
-platform68k = 1
-platformPowerPC = 2
-platformInterpreted = 3
-platformWin32 = 4
-platformPowerPCNativeEntryPoint = 5
-mpWorkFlagDoWork = (1 << 0)
-mpWorkFlagDoCompletion = (1 << 1)
-mpWorkFlagCopyWorkBlock = (1 << 2)
-mpWorkFlagDontBlock = (1 << 3)
-mpWorkFlagGetProcessorCount = (1 << 4)
-mpWorkFlagGetIsRunning = (1 << 6)
-cmpAliasNoFlags = 0
-cmpAliasOnlyThisFile = 1
-uppComponentFunctionImplementedProcInfo = 0x000002F0
-uppGetComponentVersionProcInfo = 0x000000F0
-uppComponentSetTargetProcInfo = 0x000003F0
-uppCallComponentOpenProcInfo = 0x000003F0
-uppCallComponentCloseProcInfo = 0x000003F0
-uppCallComponentCanDoProcInfo = 0x000002F0
-uppCallComponentVersionProcInfo = 0x000000F0
-uppCallComponentRegisterProcInfo = 0x000000F0
-uppCallComponentTargetProcInfo = 0x000003F0
-uppCallComponentUnregisterProcInfo = 0x000000F0
-uppCallComponentGetMPWorkFunctionProcInfo = 0x00000FF0
-uppCallComponentGetPublicResourceProcInfo = 0x00003BF0
diff --git a/Lib/plat-mac/Carbon/ControlAccessor.py b/Lib/plat-mac/Carbon/ControlAccessor.py
deleted file mode 100644
index 099892538c8..00000000000
--- a/Lib/plat-mac/Carbon/ControlAccessor.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Accessor functions for control properties
-
-from Controls import *
-import struct
-
-# These needn't go through this module, but are here for completeness
-def SetControlData_Handle(control, part, selector, data):
- control.SetControlData_Handle(part, selector, data)
-
-def GetControlData_Handle(control, part, selector):
- return control.GetControlData_Handle(part, selector)
-
-_accessdict = {
- kControlPopupButtonMenuHandleTag: (SetControlData_Handle, GetControlData_Handle),
-}
-
-_codingdict = {
- kControlPushButtonDefaultTag : ("b", None, None),
-
- kControlEditTextTextTag: (None, None, None),
- kControlEditTextPasswordTag: (None, None, None),
-
- kControlPopupButtonMenuIDTag: ("h", None, None),
-
- kControlListBoxDoubleClickTag: ("b", None, None),
-}
-
-def SetControlData(control, part, selector, data):
- if _accessdict.has_key(selector):
- setfunc, getfunc = _accessdict[selector]
- setfunc(control, part, selector, data)
- return
- if not _codingdict.has_key(selector):
- raise KeyError, ('Unknown control selector', selector)
- structfmt, coder, decoder = _codingdict[selector]
- if coder:
- data = coder(data)
- if structfmt:
- data = struct.pack(structfmt, data)
- control.SetControlData(part, selector, data)
-
-def GetControlData(control, part, selector):
- if _accessdict.has_key(selector):
- setfunc, getfunc = _accessdict[selector]
- return getfunc(control, part, selector, data)
- if not _codingdict.has_key(selector):
- raise KeyError, ('Unknown control selector', selector)
- structfmt, coder, decoder = _codingdict[selector]
- data = control.GetControlData(part, selector)
- if structfmt:
- data = struct.unpack(structfmt, data)
- if decoder:
- data = decoder(data)
- if type(data) == type(()) and len(data) == 1:
- data = data[0]
- return data
diff --git a/Lib/plat-mac/Carbon/Controls.py b/Lib/plat-mac/Carbon/Controls.py
deleted file mode 100644
index 6e5d8ea7f8e..00000000000
--- a/Lib/plat-mac/Carbon/Controls.py
+++ /dev/null
@@ -1,668 +0,0 @@
-# Generated from 'Controls.h'
-
-def FOUR_CHAR_CODE(x): return x
-from Carbon.TextEdit import *
-from Carbon.QuickDraw import *
-from Carbon.Dragconst import *
-from Carbon.CarbonEvents import *
-from Carbon.Appearance import *
-kDataBrowserItemAnyState = -1
-kControlBevelButtonCenterPopupGlyphTag = -1
-kDataBrowserClientPropertyFlagsMask = 0xFF000000
-
-kControlDefProcType = FOUR_CHAR_CODE('CDEF')
-kControlTemplateResourceType = FOUR_CHAR_CODE('CNTL')
-kControlColorTableResourceType = FOUR_CHAR_CODE('cctb')
-kControlDefProcResourceType = FOUR_CHAR_CODE('CDEF')
-controlNotifyNothing = FOUR_CHAR_CODE('nada')
-controlNotifyClick = FOUR_CHAR_CODE('clik')
-controlNotifyFocus = FOUR_CHAR_CODE('focu')
-controlNotifyKey = FOUR_CHAR_CODE('key ')
-kControlCanAutoInvalidate = 1L << 0
-staticTextProc = 256
-editTextProc = 272
-iconProc = 288
-userItemProc = 304
-pictItemProc = 320
-cFrameColor = 0
-cBodyColor = 1
-cTextColor = 2
-cThumbColor = 3
-kNumberCtlCTabEntries = 4
-kControlNoVariant = 0
-kControlUsesOwningWindowsFontVariant = 1 << 3
-kControlNoPart = 0
-kControlIndicatorPart = 129
-kControlDisabledPart = 254
-kControlInactivePart = 255
-kControlEntireControl = 0
-kControlStructureMetaPart = -1
-kControlContentMetaPart = -2
-kControlFocusNoPart = 0
-kControlFocusNextPart = -1
-kControlFocusPrevPart = -2
-kControlCollectionTagBounds = FOUR_CHAR_CODE('boun')
-kControlCollectionTagValue = FOUR_CHAR_CODE('valu')
-kControlCollectionTagMinimum = FOUR_CHAR_CODE('min ')
-kControlCollectionTagMaximum = FOUR_CHAR_CODE('max ')
-kControlCollectionTagViewSize = FOUR_CHAR_CODE('view')
-kControlCollectionTagVisibility = FOUR_CHAR_CODE('visi')
-kControlCollectionTagRefCon = FOUR_CHAR_CODE('refc')
-kControlCollectionTagTitle = FOUR_CHAR_CODE('titl')
-kControlCollectionTagUnicodeTitle = FOUR_CHAR_CODE('uttl')
-kControlCollectionTagIDSignature = FOUR_CHAR_CODE('idsi')
-kControlCollectionTagIDID = FOUR_CHAR_CODE('idid')
-kControlCollectionTagCommand = FOUR_CHAR_CODE('cmd ')
-kControlCollectionTagVarCode = FOUR_CHAR_CODE('varc')
-kControlContentTextOnly = 0
-kControlNoContent = 0
-kControlContentIconSuiteRes = 1
-kControlContentCIconRes = 2
-kControlContentPictRes = 3
-kControlContentICONRes = 4
-kControlContentIconSuiteHandle = 129
-kControlContentCIconHandle = 130
-kControlContentPictHandle = 131
-kControlContentIconRef = 132
-kControlContentICON = 133
-kControlKeyScriptBehaviorAllowAnyScript = FOUR_CHAR_CODE('any ')
-kControlKeyScriptBehaviorPrefersRoman = FOUR_CHAR_CODE('prmn')
-kControlKeyScriptBehaviorRequiresRoman = FOUR_CHAR_CODE('rrmn')
-kControlFontBigSystemFont = -1
-kControlFontSmallSystemFont = -2
-kControlFontSmallBoldSystemFont = -3
-kControlFontViewSystemFont = -4
-kControlUseFontMask = 0x0001
-kControlUseFaceMask = 0x0002
-kControlUseSizeMask = 0x0004
-kControlUseForeColorMask = 0x0008
-kControlUseBackColorMask = 0x0010
-kControlUseModeMask = 0x0020
-kControlUseJustMask = 0x0040
-kControlUseAllMask = 0x00FF
-kControlAddFontSizeMask = 0x0100
-kControlAddToMetaFontMask = 0x0200
-kControlUseThemeFontIDMask = 0x0080
-kDoNotActivateAndIgnoreClick = 0
-kDoNotActivateAndHandleClick = 1
-kActivateAndIgnoreClick = 2
-kActivateAndHandleClick = 3
-kControlFontStyleTag = FOUR_CHAR_CODE('font')
-kControlKeyFilterTag = FOUR_CHAR_CODE('fltr')
-kControlKindTag = FOUR_CHAR_CODE('kind')
-kControlSizeTag = FOUR_CHAR_CODE('size')
-kControlSupportsGhosting = 1 << 0
-kControlSupportsEmbedding = 1 << 1
-kControlSupportsFocus = 1 << 2
-kControlWantsIdle = 1 << 3
-kControlWantsActivate = 1 << 4
-kControlHandlesTracking = 1 << 5
-kControlSupportsDataAccess = 1 << 6
-kControlHasSpecialBackground = 1 << 7
-kControlGetsFocusOnClick = 1 << 8
-kControlSupportsCalcBestRect = 1 << 9
-kControlSupportsLiveFeedback = 1 << 10
-kControlHasRadioBehavior = 1 << 11
-kControlSupportsDragAndDrop = 1 << 12
-kControlAutoToggles = 1 << 14
-kControlSupportsGetRegion = 1 << 17
-kControlSupportsFlattening = 1 << 19
-kControlSupportsSetCursor = 1 << 20
-kControlSupportsContextualMenus = 1 << 21
-kControlSupportsClickActivation = 1 << 22
-kControlIdlesWithTimer = 1 << 23
-drawCntl = 0
-testCntl = 1
-calcCRgns = 2
-initCntl = 3
-dispCntl = 4
-posCntl = 5
-thumbCntl = 6
-dragCntl = 7
-autoTrack = 8
-calcCntlRgn = 10
-calcThumbRgn = 11
-drawThumbOutline = 12
-kControlMsgDrawGhost = 13
-kControlMsgCalcBestRect = 14
-kControlMsgHandleTracking = 15
-kControlMsgFocus = 16
-kControlMsgKeyDown = 17
-kControlMsgIdle = 18
-kControlMsgGetFeatures = 19
-kControlMsgSetData = 20
-kControlMsgGetData = 21
-kControlMsgActivate = 22
-kControlMsgSetUpBackground = 23
-kControlMsgCalcValueFromPos = 26
-kControlMsgTestNewMsgSupport = 27
-kControlMsgSubValueChanged = 25
-kControlMsgSubControlAdded = 28
-kControlMsgSubControlRemoved = 29
-kControlMsgApplyTextColor = 30
-kControlMsgGetRegion = 31
-kControlMsgFlatten = 32
-kControlMsgSetCursor = 33
-kControlMsgDragEnter = 38
-kControlMsgDragLeave = 39
-kControlMsgDragWithin = 40
-kControlMsgDragReceive = 41
-kControlMsgDisplayDebugInfo = 46
-kControlMsgContextualMenuClick = 47
-kControlMsgGetClickActivation = 48
-kControlSizeNormal = 0
-kControlSizeSmall = 1
-kControlSizeLarge = 2
-kControlSizeAuto = 0xFFFF
-kDrawControlEntireControl = 0
-kDrawControlIndicatorOnly = 129
-kDragControlEntireControl = 0
-kDragControlIndicator = 1
-kControlSupportsNewMessages = FOUR_CHAR_CODE(' ok ')
-kControlKeyFilterBlockKey = 0
-kControlKeyFilterPassKey = 1
-noConstraint = kNoConstraint
-hAxisOnly = 1
-vAxisOnly = 2
-kControlDefProcPtr = 0
-kControlDefObjectClass = 1
-kControlKindSignatureApple = FOUR_CHAR_CODE('appl')
-kControlPropertyPersistent = 0x00000001
-kDragTrackingEnterControl = 2
-kDragTrackingInControl = 3
-kDragTrackingLeaveControl = 4
-useWFont = kControlUsesOwningWindowsFontVariant
-inThumb = kControlIndicatorPart
-kNoHiliteControlPart = kControlNoPart
-kInIndicatorControlPart = kControlIndicatorPart
-kReservedControlPart = kControlDisabledPart
-kControlInactiveControlPart = kControlInactivePart
-kControlTabListResType = FOUR_CHAR_CODE('tab#')
-kControlListDescResType = FOUR_CHAR_CODE('ldes')
-kControlCheckBoxUncheckedValue = 0
-kControlCheckBoxCheckedValue = 1
-kControlCheckBoxMixedValue = 2
-kControlRadioButtonUncheckedValue = 0
-kControlRadioButtonCheckedValue = 1
-kControlRadioButtonMixedValue = 2
-popupFixedWidth = 1 << 0
-popupVariableWidth = 1 << 1
-popupUseAddResMenu = 1 << 2
-popupUseWFont = 1 << 3
-popupTitleBold = 1 << 8
-popupTitleItalic = 1 << 9
-popupTitleUnderline = 1 << 10
-popupTitleOutline = 1 << 11
-popupTitleShadow = 1 << 12
-popupTitleCondense = 1 << 13
-popupTitleExtend = 1 << 14
-popupTitleNoStyle = 1 << 15
-popupTitleLeftJust = 0x00000000
-popupTitleCenterJust = 0x00000001
-popupTitleRightJust = 0x000000FF
-pushButProc = 0
-checkBoxProc = 1
-radioButProc = 2
-scrollBarProc = 16
-popupMenuProc = 1008
-kControlLabelPart = 1
-kControlMenuPart = 2
-kControlTrianglePart = 4
-kControlEditTextPart = 5
-kControlPicturePart = 6
-kControlIconPart = 7
-kControlClockPart = 8
-kControlListBoxPart = 24
-kControlListBoxDoubleClickPart = 25
-kControlImageWellPart = 26
-kControlRadioGroupPart = 27
-kControlButtonPart = 10
-kControlCheckBoxPart = 11
-kControlRadioButtonPart = 11
-kControlUpButtonPart = 20
-kControlDownButtonPart = 21
-kControlPageUpPart = 22
-kControlPageDownPart = 23
-kControlClockHourDayPart = 9
-kControlClockMinuteMonthPart = 10
-kControlClockSecondYearPart = 11
-kControlClockAMPMPart = 12
-kControlDataBrowserPart = 24
-kControlDataBrowserDraggedPart = 25
-kControlBevelButtonSmallBevelProc = 32
-kControlBevelButtonNormalBevelProc = 33
-kControlBevelButtonLargeBevelProc = 34
-kControlBevelButtonSmallBevelVariant = 0
-kControlBevelButtonNormalBevelVariant = (1 << 0)
-kControlBevelButtonLargeBevelVariant = (1 << 1)
-kControlBevelButtonMenuOnRightVariant = (1 << 2)
-kControlBevelButtonSmallBevel = 0
-kControlBevelButtonNormalBevel = 1
-kControlBevelButtonLargeBevel = 2
-kControlBehaviorPushbutton = 0
-kControlBehaviorToggles = 0x0100
-kControlBehaviorSticky = 0x0200
-kControlBehaviorSingleValueMenu = 0
-kControlBehaviorMultiValueMenu = 0x4000
-kControlBehaviorOffsetContents = 0x8000
-kControlBehaviorCommandMenu = 0x2000
-kControlBevelButtonMenuOnBottom = 0
-kControlBevelButtonMenuOnRight = (1 << 2)
-kControlKindBevelButton = FOUR_CHAR_CODE('bevl')
-kControlBevelButtonAlignSysDirection = -1
-kControlBevelButtonAlignCenter = 0
-kControlBevelButtonAlignLeft = 1
-kControlBevelButtonAlignRight = 2
-kControlBevelButtonAlignTop = 3
-kControlBevelButtonAlignBottom = 4
-kControlBevelButtonAlignTopLeft = 5
-kControlBevelButtonAlignBottomLeft = 6
-kControlBevelButtonAlignTopRight = 7
-kControlBevelButtonAlignBottomRight = 8
-kControlBevelButtonAlignTextSysDirection = teFlushDefault
-kControlBevelButtonAlignTextCenter = teCenter
-kControlBevelButtonAlignTextFlushRight = teFlushRight
-kControlBevelButtonAlignTextFlushLeft = teFlushLeft
-kControlBevelButtonPlaceSysDirection = -1
-kControlBevelButtonPlaceNormally = 0
-kControlBevelButtonPlaceToRightOfGraphic = 1
-kControlBevelButtonPlaceToLeftOfGraphic = 2
-kControlBevelButtonPlaceBelowGraphic = 3
-kControlBevelButtonPlaceAboveGraphic = 4
-kControlBevelButtonContentTag = FOUR_CHAR_CODE('cont')
-kControlBevelButtonTransformTag = FOUR_CHAR_CODE('tran')
-kControlBevelButtonTextAlignTag = FOUR_CHAR_CODE('tali')
-kControlBevelButtonTextOffsetTag = FOUR_CHAR_CODE('toff')
-kControlBevelButtonGraphicAlignTag = FOUR_CHAR_CODE('gali')
-kControlBevelButtonGraphicOffsetTag = FOUR_CHAR_CODE('goff')
-kControlBevelButtonTextPlaceTag = FOUR_CHAR_CODE('tplc')
-kControlBevelButtonMenuValueTag = FOUR_CHAR_CODE('mval')
-kControlBevelButtonMenuHandleTag = FOUR_CHAR_CODE('mhnd')
-kControlBevelButtonMenuRefTag = FOUR_CHAR_CODE('mhnd')
-# kControlBevelButtonCenterPopupGlyphTag = FOUR_CHAR_CODE('pglc')
-kControlBevelButtonLastMenuTag = FOUR_CHAR_CODE('lmnu')
-kControlBevelButtonMenuDelayTag = FOUR_CHAR_CODE('mdly')
-kControlBevelButtonScaleIconTag = FOUR_CHAR_CODE('scal')
-kControlBevelButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf')
-kControlBevelButtonKindTag = FOUR_CHAR_CODE('bebk')
-kControlSliderProc = 48
-kControlSliderLiveFeedback = (1 << 0)
-kControlSliderHasTickMarks = (1 << 1)
-kControlSliderReverseDirection = (1 << 2)
-kControlSliderNonDirectional = (1 << 3)
-kControlSliderPointsDownOrRight = 0
-kControlSliderPointsUpOrLeft = 1
-kControlSliderDoesNotPoint = 2
-kControlKindSlider = FOUR_CHAR_CODE('sldr')
-kControlTriangleProc = 64
-kControlTriangleLeftFacingProc = 65
-kControlTriangleAutoToggleProc = 66
-kControlTriangleLeftFacingAutoToggleProc = 67
-kControlDisclosureTrianglePointDefault = 0
-kControlDisclosureTrianglePointRight = 1
-kControlDisclosureTrianglePointLeft = 2
-kControlKindDisclosureTriangle = FOUR_CHAR_CODE('dist')
-kControlTriangleLastValueTag = FOUR_CHAR_CODE('last')
-kControlProgressBarProc = 80
-kControlRelevanceBarProc = 81
-kControlKindProgressBar = FOUR_CHAR_CODE('prgb')
-kControlKindRelevanceBar = FOUR_CHAR_CODE('relb')
-kControlProgressBarIndeterminateTag = FOUR_CHAR_CODE('inde')
-kControlProgressBarAnimatingTag = FOUR_CHAR_CODE('anim')
-kControlLittleArrowsProc = 96
-kControlKindLittleArrows = FOUR_CHAR_CODE('larr')
-kControlChasingArrowsProc = 112
-kControlKindChasingArrows = FOUR_CHAR_CODE('carr')
-kControlChasingArrowsAnimatingTag = FOUR_CHAR_CODE('anim')
-kControlTabLargeProc = 128
-kControlTabSmallProc = 129
-kControlTabLargeNorthProc = 128
-kControlTabSmallNorthProc = 129
-kControlTabLargeSouthProc = 130
-kControlTabSmallSouthProc = 131
-kControlTabLargeEastProc = 132
-kControlTabSmallEastProc = 133
-kControlTabLargeWestProc = 134
-kControlTabSmallWestProc = 135
-kControlTabDirectionNorth = 0
-kControlTabDirectionSouth = 1
-kControlTabDirectionEast = 2
-kControlTabDirectionWest = 3
-kControlTabSizeLarge = kControlSizeNormal
-kControlTabSizeSmall = kControlSizeSmall
-kControlKindTabs = FOUR_CHAR_CODE('tabs')
-kControlTabContentRectTag = FOUR_CHAR_CODE('rect')
-kControlTabEnabledFlagTag = FOUR_CHAR_CODE('enab')
-kControlTabFontStyleTag = kControlFontStyleTag
-kControlTabInfoTag = FOUR_CHAR_CODE('tabi')
-kControlTabImageContentTag = FOUR_CHAR_CODE('cont')
-kControlTabInfoVersionZero = 0
-kControlTabInfoVersionOne = 1
-kControlSeparatorLineProc = 144
-kControlKindSeparator = FOUR_CHAR_CODE('sepa')
-kControlGroupBoxTextTitleProc = 160
-kControlGroupBoxCheckBoxProc = 161
-kControlGroupBoxPopupButtonProc = 162
-kControlGroupBoxSecondaryTextTitleProc = 164
-kControlGroupBoxSecondaryCheckBoxProc = 165
-kControlGroupBoxSecondaryPopupButtonProc = 166
-kControlKindGroupBox = FOUR_CHAR_CODE('grpb')
-kControlKindCheckGroupBox = FOUR_CHAR_CODE('cgrp')
-kControlKindPopupGroupBox = FOUR_CHAR_CODE('pgrp')
-kControlGroupBoxMenuHandleTag = FOUR_CHAR_CODE('mhan')
-kControlGroupBoxMenuRefTag = FOUR_CHAR_CODE('mhan')
-kControlGroupBoxFontStyleTag = kControlFontStyleTag
-kControlGroupBoxTitleRectTag = FOUR_CHAR_CODE('trec')
-kControlImageWellProc = 176
-kControlKindImageWell = FOUR_CHAR_CODE('well')
-kControlImageWellContentTag = FOUR_CHAR_CODE('cont')
-kControlImageWellTransformTag = FOUR_CHAR_CODE('tran')
-kControlImageWellIsDragDestinationTag = FOUR_CHAR_CODE('drag')
-kControlPopupArrowEastProc = 192
-kControlPopupArrowWestProc = 193
-kControlPopupArrowNorthProc = 194
-kControlPopupArrowSouthProc = 195
-kControlPopupArrowSmallEastProc = 196
-kControlPopupArrowSmallWestProc = 197
-kControlPopupArrowSmallNorthProc = 198
-kControlPopupArrowSmallSouthProc = 199
-kControlPopupArrowOrientationEast = 0
-kControlPopupArrowOrientationWest = 1
-kControlPopupArrowOrientationNorth = 2
-kControlPopupArrowOrientationSouth = 3
-kControlPopupArrowSizeNormal = 0
-kControlPopupArrowSizeSmall = 1
-kControlKindPopupArrow = FOUR_CHAR_CODE('parr')
-kControlPlacardProc = 224
-kControlKindPlacard = FOUR_CHAR_CODE('plac')
-kControlClockTimeProc = 240
-kControlClockTimeSecondsProc = 241
-kControlClockDateProc = 242
-kControlClockMonthYearProc = 243
-kControlClockTypeHourMinute = 0
-kControlClockTypeHourMinuteSecond = 1
-kControlClockTypeMonthDayYear = 2
-kControlClockTypeMonthYear = 3
-kControlClockFlagStandard = 0
-kControlClockNoFlags = 0
-kControlClockFlagDisplayOnly = 1
-kControlClockIsDisplayOnly = 1
-kControlClockFlagLive = 2
-kControlClockIsLive = 2
-kControlKindClock = FOUR_CHAR_CODE('clck')
-kControlClockLongDateTag = FOUR_CHAR_CODE('date')
-kControlClockFontStyleTag = kControlFontStyleTag
-kControlClockAnimatingTag = FOUR_CHAR_CODE('anim')
-kControlUserPaneProc = 256
-kControlKindUserPane = FOUR_CHAR_CODE('upan')
-kControlUserItemDrawProcTag = FOUR_CHAR_CODE('uidp')
-kControlUserPaneDrawProcTag = FOUR_CHAR_CODE('draw')
-kControlUserPaneHitTestProcTag = FOUR_CHAR_CODE('hitt')
-kControlUserPaneTrackingProcTag = FOUR_CHAR_CODE('trak')
-kControlUserPaneIdleProcTag = FOUR_CHAR_CODE('idle')
-kControlUserPaneKeyDownProcTag = FOUR_CHAR_CODE('keyd')
-kControlUserPaneActivateProcTag = FOUR_CHAR_CODE('acti')
-kControlUserPaneFocusProcTag = FOUR_CHAR_CODE('foci')
-kControlUserPaneBackgroundProcTag = FOUR_CHAR_CODE('back')
-kControlEditTextProc = 272
-kControlEditTextPasswordProc = 274
-kControlEditTextInlineInputProc = 276
-kControlKindEditText = FOUR_CHAR_CODE('etxt')
-kControlEditTextStyleTag = kControlFontStyleTag
-kControlEditTextTextTag = FOUR_CHAR_CODE('text')
-kControlEditTextTEHandleTag = FOUR_CHAR_CODE('than')
-kControlEditTextKeyFilterTag = kControlKeyFilterTag
-kControlEditTextSelectionTag = FOUR_CHAR_CODE('sele')
-kControlEditTextPasswordTag = FOUR_CHAR_CODE('pass')
-kControlEditTextKeyScriptBehaviorTag = FOUR_CHAR_CODE('kscr')
-kControlEditTextLockedTag = FOUR_CHAR_CODE('lock')
-kControlEditTextFixedTextTag = FOUR_CHAR_CODE('ftxt')
-kControlEditTextValidationProcTag = FOUR_CHAR_CODE('vali')
-kControlEditTextInlinePreUpdateProcTag = FOUR_CHAR_CODE('prup')
-kControlEditTextInlinePostUpdateProcTag = FOUR_CHAR_CODE('poup')
-kControlEditTextCFStringTag = FOUR_CHAR_CODE('cfst')
-kControlEditTextPasswordCFStringTag = FOUR_CHAR_CODE('pwcf')
-kControlStaticTextProc = 288
-kControlKindStaticText = FOUR_CHAR_CODE('stxt')
-kControlStaticTextStyleTag = kControlFontStyleTag
-kControlStaticTextTextTag = FOUR_CHAR_CODE('text')
-kControlStaticTextTextHeightTag = FOUR_CHAR_CODE('thei')
-kControlStaticTextTruncTag = FOUR_CHAR_CODE('trun')
-kControlStaticTextCFStringTag = FOUR_CHAR_CODE('cfst')
-kControlPictureProc = 304
-kControlPictureNoTrackProc = 305
-kControlKindPicture = FOUR_CHAR_CODE('pict')
-kControlPictureHandleTag = FOUR_CHAR_CODE('pich')
-kControlIconProc = 320
-kControlIconNoTrackProc = 321
-kControlIconSuiteProc = 322
-kControlIconSuiteNoTrackProc = 323
-kControlIconRefProc = 324
-kControlIconRefNoTrackProc = 325
-kControlKindIcon = FOUR_CHAR_CODE('icon')
-kControlIconTransformTag = FOUR_CHAR_CODE('trfm')
-kControlIconAlignmentTag = FOUR_CHAR_CODE('algn')
-kControlIconResourceIDTag = FOUR_CHAR_CODE('ires')
-kControlIconContentTag = FOUR_CHAR_CODE('cont')
-kControlWindowHeaderProc = 336
-kControlWindowListViewHeaderProc = 337
-kControlKindWindowHeader = FOUR_CHAR_CODE('whed')
-kControlListBoxProc = 352
-kControlListBoxAutoSizeProc = 353
-kControlKindListBox = FOUR_CHAR_CODE('lbox')
-kControlListBoxListHandleTag = FOUR_CHAR_CODE('lhan')
-kControlListBoxKeyFilterTag = kControlKeyFilterTag
-kControlListBoxFontStyleTag = kControlFontStyleTag
-kControlListBoxDoubleClickTag = FOUR_CHAR_CODE('dblc')
-kControlListBoxLDEFTag = FOUR_CHAR_CODE('ldef')
-kControlPushButtonProc = 368
-kControlCheckBoxProc = 369
-kControlRadioButtonProc = 370
-kControlPushButLeftIconProc = 374
-kControlPushButRightIconProc = 375
-kControlCheckBoxAutoToggleProc = 371
-kControlRadioButtonAutoToggleProc = 372
-kControlPushButtonIconOnLeft = 6
-kControlPushButtonIconOnRight = 7
-kControlKindPushButton = FOUR_CHAR_CODE('push')
-kControlKindPushIconButton = FOUR_CHAR_CODE('picn')
-kControlKindRadioButton = FOUR_CHAR_CODE('rdio')
-kControlKindCheckBox = FOUR_CHAR_CODE('cbox')
-kControlPushButtonDefaultTag = FOUR_CHAR_CODE('dflt')
-kControlPushButtonCancelTag = FOUR_CHAR_CODE('cncl')
-kControlScrollBarProc = 384
-kControlScrollBarLiveProc = 386
-kControlKindScrollBar = FOUR_CHAR_CODE('sbar')
-kControlScrollBarShowsArrowsTag = FOUR_CHAR_CODE('arro')
-kControlPopupButtonProc = 400
-kControlPopupFixedWidthVariant = 1 << 0
-kControlPopupVariableWidthVariant = 1 << 1
-kControlPopupUseAddResMenuVariant = 1 << 2
-kControlPopupUseWFontVariant = kControlUsesOwningWindowsFontVariant
-kControlKindPopupButton = FOUR_CHAR_CODE('popb')
-kControlPopupButtonMenuHandleTag = FOUR_CHAR_CODE('mhan')
-kControlPopupButtonMenuRefTag = FOUR_CHAR_CODE('mhan')
-kControlPopupButtonMenuIDTag = FOUR_CHAR_CODE('mnid')
-kControlPopupButtonExtraHeightTag = FOUR_CHAR_CODE('exht')
-kControlPopupButtonOwnedMenuRefTag = FOUR_CHAR_CODE('omrf')
-kControlPopupButtonCheckCurrentTag = FOUR_CHAR_CODE('chck')
-kControlRadioGroupProc = 416
-kControlKindRadioGroup = FOUR_CHAR_CODE('rgrp')
-kControlScrollTextBoxProc = 432
-kControlScrollTextBoxAutoScrollProc = 433
-kControlKindScrollingTextBox = FOUR_CHAR_CODE('stbx')
-kControlScrollTextBoxDelayBeforeAutoScrollTag = FOUR_CHAR_CODE('stdl')
-kControlScrollTextBoxDelayBetweenAutoScrollTag = FOUR_CHAR_CODE('scdl')
-kControlScrollTextBoxAutoScrollAmountTag = FOUR_CHAR_CODE('samt')
-kControlScrollTextBoxContentsTag = FOUR_CHAR_CODE('tres')
-kControlScrollTextBoxAnimatingTag = FOUR_CHAR_CODE('anim')
-kControlKindDisclosureButton = FOUR_CHAR_CODE('disb')
-kControlDisclosureButtonClosed = 0
-kControlDisclosureButtonDisclosed = 1
-kControlRoundButtonNormalSize = kControlSizeNormal
-kControlRoundButtonLargeSize = kControlSizeLarge
-kControlRoundButtonContentTag = FOUR_CHAR_CODE('cont')
-kControlRoundButtonSizeTag = kControlSizeTag
-kControlKindRoundButton = FOUR_CHAR_CODE('rndb')
-kControlKindDataBrowser = FOUR_CHAR_CODE('datb')
-errDataBrowserNotConfigured = -4970
-errDataBrowserItemNotFound = -4971
-errDataBrowserItemNotAdded = -4975
-errDataBrowserPropertyNotFound = -4972
-errDataBrowserInvalidPropertyPart = -4973
-errDataBrowserInvalidPropertyData = -4974
-errDataBrowserPropertyNotSupported = -4979
-kControlDataBrowserIncludesFrameAndFocusTag = FOUR_CHAR_CODE('brdr')
-kControlDataBrowserKeyFilterTag = kControlEditTextKeyFilterTag
-kControlDataBrowserEditTextKeyFilterTag = kControlDataBrowserKeyFilterTag
-kControlDataBrowserEditTextValidationProcTag = kControlEditTextValidationProcTag
-kDataBrowserNoView = 0x3F3F3F3F
-kDataBrowserListView = FOUR_CHAR_CODE('lstv')
-kDataBrowserColumnView = FOUR_CHAR_CODE('clmv')
-kDataBrowserDragSelect = 1 << 0
-kDataBrowserSelectOnlyOne = 1 << 1
-kDataBrowserResetSelection = 1 << 2
-kDataBrowserCmdTogglesSelection = 1 << 3
-kDataBrowserNoDisjointSelection = 1 << 4
-kDataBrowserAlwaysExtendSelection = 1 << 5
-kDataBrowserNeverEmptySelectionSet = 1 << 6
-kDataBrowserOrderUndefined = 0
-kDataBrowserOrderIncreasing = 1
-kDataBrowserOrderDecreasing = 2
-kDataBrowserNoItem = 0L
-kDataBrowserItemNoState = 0
-# kDataBrowserItemAnyState = (unsigned long)(-1)
-kDataBrowserItemIsSelected = 1 << 0
-kDataBrowserContainerIsOpen = 1 << 1
-kDataBrowserItemIsDragTarget = 1 << 2
-kDataBrowserRevealOnly = 0
-kDataBrowserRevealAndCenterInView = 1 << 0
-kDataBrowserRevealWithoutSelecting = 1 << 1
-kDataBrowserItemsAdd = 0
-kDataBrowserItemsAssign = 1
-kDataBrowserItemsToggle = 2
-kDataBrowserItemsRemove = 3
-kDataBrowserSelectionAnchorUp = 0
-kDataBrowserSelectionAnchorDown = 1
-kDataBrowserSelectionAnchorLeft = 2
-kDataBrowserSelectionAnchorRight = 3
-kDataBrowserEditMsgUndo = kHICommandUndo
-kDataBrowserEditMsgRedo = kHICommandRedo
-kDataBrowserEditMsgCut = kHICommandCut
-kDataBrowserEditMsgCopy = kHICommandCopy
-kDataBrowserEditMsgPaste = kHICommandPaste
-kDataBrowserEditMsgClear = kHICommandClear
-kDataBrowserEditMsgSelectAll = kHICommandSelectAll
-kDataBrowserItemAdded = 1
-kDataBrowserItemRemoved = 2
-kDataBrowserEditStarted = 3
-kDataBrowserEditStopped = 4
-kDataBrowserItemSelected = 5
-kDataBrowserItemDeselected = 6
-kDataBrowserItemDoubleClicked = 7
-kDataBrowserContainerOpened = 8
-kDataBrowserContainerClosing = 9
-kDataBrowserContainerClosed = 10
-kDataBrowserContainerSorting = 11
-kDataBrowserContainerSorted = 12
-kDataBrowserUserToggledContainer = 16
-kDataBrowserTargetChanged = 15
-kDataBrowserUserStateChanged = 13
-kDataBrowserSelectionSetChanged = 14
-kDataBrowserItemNoProperty = 0L
-kDataBrowserItemIsActiveProperty = 1L
-kDataBrowserItemIsSelectableProperty = 2L
-kDataBrowserItemIsEditableProperty = 3L
-kDataBrowserItemIsContainerProperty = 4L
-kDataBrowserContainerIsOpenableProperty = 5L
-kDataBrowserContainerIsClosableProperty = 6L
-kDataBrowserContainerIsSortableProperty = 7L
-kDataBrowserItemSelfIdentityProperty = 8L
-kDataBrowserContainerAliasIDProperty = 9L
-kDataBrowserColumnViewPreviewProperty = 10L
-kDataBrowserItemParentContainerProperty = 11L
-kDataBrowserCustomType = 0x3F3F3F3F
-kDataBrowserIconType = FOUR_CHAR_CODE('icnr')
-kDataBrowserTextType = FOUR_CHAR_CODE('text')
-kDataBrowserDateTimeType = FOUR_CHAR_CODE('date')
-kDataBrowserSliderType = FOUR_CHAR_CODE('sldr')
-kDataBrowserCheckboxType = FOUR_CHAR_CODE('chbx')
-kDataBrowserProgressBarType = FOUR_CHAR_CODE('prog')
-kDataBrowserRelevanceRankType = FOUR_CHAR_CODE('rank')
-kDataBrowserPopupMenuType = FOUR_CHAR_CODE('menu')
-kDataBrowserIconAndTextType = FOUR_CHAR_CODE('ticn')
-kDataBrowserPropertyEnclosingPart = 0L
-kDataBrowserPropertyContentPart = FOUR_CHAR_CODE('----')
-kDataBrowserPropertyDisclosurePart = FOUR_CHAR_CODE('disc')
-kDataBrowserPropertyTextPart = kDataBrowserTextType
-kDataBrowserPropertyIconPart = kDataBrowserIconType
-kDataBrowserPropertySliderPart = kDataBrowserSliderType
-kDataBrowserPropertyCheckboxPart = kDataBrowserCheckboxType
-kDataBrowserPropertyProgressBarPart = kDataBrowserProgressBarType
-kDataBrowserPropertyRelevanceRankPart = kDataBrowserRelevanceRankType
-kDataBrowserUniversalPropertyFlagsMask = 0xFF
-kDataBrowserPropertyIsMutable = 1 << 0
-kDataBrowserDefaultPropertyFlags = 0 << 0
-kDataBrowserUniversalPropertyFlags = kDataBrowserUniversalPropertyFlagsMask
-kDataBrowserPropertyIsEditable = kDataBrowserPropertyIsMutable
-kDataBrowserPropertyFlagsOffset = 8
-kDataBrowserPropertyFlagsMask = 0xFF << kDataBrowserPropertyFlagsOffset
-kDataBrowserCheckboxTriState = 1 << kDataBrowserPropertyFlagsOffset
-kDataBrowserDateTimeRelative = 1 << (kDataBrowserPropertyFlagsOffset)
-kDataBrowserDateTimeDateOnly = 1 << (kDataBrowserPropertyFlagsOffset + 1)
-kDataBrowserDateTimeTimeOnly = 1 << (kDataBrowserPropertyFlagsOffset + 2)
-kDataBrowserDateTimeSecondsToo = 1 << (kDataBrowserPropertyFlagsOffset + 3)
-kDataBrowserSliderPlainThumb = kThemeThumbPlain << kDataBrowserPropertyFlagsOffset
-kDataBrowserSliderUpwardThumb = kThemeThumbUpward << kDataBrowserPropertyFlagsOffset
-kDataBrowserSliderDownwardThumb = kThemeThumbDownward << kDataBrowserPropertyFlagsOffset
-kDataBrowserDoNotTruncateText = 3 << kDataBrowserPropertyFlagsOffset
-kDataBrowserTruncateTextAtEnd = 2 << kDataBrowserPropertyFlagsOffset
-kDataBrowserTruncateTextMiddle = 0 << kDataBrowserPropertyFlagsOffset
-kDataBrowserTruncateTextAtStart = 1 << kDataBrowserPropertyFlagsOffset
-kDataBrowserPropertyModificationFlags = kDataBrowserPropertyFlagsMask
-kDataBrowserRelativeDateTime = kDataBrowserDateTimeRelative
-kDataBrowserViewSpecificFlagsOffset = 16
-kDataBrowserViewSpecificFlagsMask = 0xFF << kDataBrowserViewSpecificFlagsOffset
-kDataBrowserViewSpecificPropertyFlags = kDataBrowserViewSpecificFlagsMask
-kDataBrowserClientPropertyFlagsOffset = 24
-# kDataBrowserClientPropertyFlagsMask = (unsigned long)(0xFF << kDataBrowserClientPropertyFlagsOffset)
-kDataBrowserLatestCallbacks = 0
-kDataBrowserContentHit = 1
-kDataBrowserNothingHit = 0
-kDataBrowserStopTracking = -1
-kDataBrowserLatestCustomCallbacks = 0
-kDataBrowserTableViewMinimalHilite = 0
-kDataBrowserTableViewFillHilite = 1
-kDataBrowserTableViewSelectionColumn = 1 << kDataBrowserViewSpecificFlagsOffset
-kDataBrowserTableViewLastColumn = -1
-kDataBrowserListViewMovableColumn = 1 << (kDataBrowserViewSpecificFlagsOffset + 1)
-kDataBrowserListViewSortableColumn = 1 << (kDataBrowserViewSpecificFlagsOffset + 2)
-kDataBrowserListViewSelectionColumn = kDataBrowserTableViewSelectionColumn
-kDataBrowserListViewDefaultColumnFlags = kDataBrowserListViewMovableColumn + kDataBrowserListViewSortableColumn
-kDataBrowserListViewLatestHeaderDesc = 0
-kDataBrowserListViewAppendColumn = kDataBrowserTableViewLastColumn
-kControlEditUnicodeTextPostUpdateProcTag = FOUR_CHAR_CODE('upup')
-kControlEditUnicodeTextProc = 912
-kControlEditUnicodeTextPasswordProc = 914
-kControlKindEditUnicodeText = FOUR_CHAR_CODE('eutx')
-kControlCheckboxUncheckedValue = kControlCheckBoxUncheckedValue
-kControlCheckboxCheckedValue = kControlCheckBoxCheckedValue
-kControlCheckboxMixedValue = kControlCheckBoxMixedValue
-inLabel = kControlLabelPart
-inMenu = kControlMenuPart
-inTriangle = kControlTrianglePart
-inButton = kControlButtonPart
-inCheckBox = kControlCheckBoxPart
-inUpButton = kControlUpButtonPart
-inDownButton = kControlDownButtonPart
-inPageUp = kControlPageUpPart
-inPageDown = kControlPageDownPart
-kInLabelControlPart = kControlLabelPart
-kInMenuControlPart = kControlMenuPart
-kInTriangleControlPart = kControlTrianglePart
-kInButtonControlPart = kControlButtonPart
-kInCheckBoxControlPart = kControlCheckBoxPart
-kInUpButtonControlPart = kControlUpButtonPart
-kInDownButtonControlPart = kControlDownButtonPart
-kInPageUpControlPart = kControlPageUpPart
-kInPageDownControlPart = kControlPageDownPart
diff --git a/Lib/plat-mac/Carbon/CoreFoundation.py b/Lib/plat-mac/Carbon/CoreFoundation.py
deleted file mode 100644
index 8d9c894641b..00000000000
--- a/Lib/plat-mac/Carbon/CoreFoundation.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated from 'CFBase.h'
-
-def FOUR_CHAR_CODE(x): return x
-kCFCompareLessThan = -1
-kCFCompareEqualTo = 0
-kCFCompareGreaterThan = 1
-kCFNotFound = -1
-kCFPropertyListImmutable = 0
-kCFPropertyListMutableContainers = 1
-kCFPropertyListMutableContainersAndLeaves = 2
-# kCFStringEncodingInvalidId = (long)0xFFFFFFFF
-kCFStringEncodingMacRoman = 0
-kCFStringEncodingWindowsLatin1 = 0x0500
-kCFStringEncodingISOLatin1 = 0x0201
-kCFStringEncodingNextStepLatin = 0x0B01
-kCFStringEncodingASCII = 0x0600
-kCFStringEncodingUnicode = 0x0100
-kCFStringEncodingUTF8 = 0x08000100
-kCFStringEncodingNonLossyASCII = 0x0BFF
-kCFCompareCaseInsensitive = 1
-kCFCompareBackwards = 4
-kCFCompareAnchored = 8
-kCFCompareNonliteral = 16
-kCFCompareLocalized = 32
-kCFCompareNumerically = 64
-kCFURLPOSIXPathStyle = 0
-kCFURLHFSPathStyle = 1
-kCFURLWindowsPathStyle = 2
diff --git a/Lib/plat-mac/Carbon/CoreGraphics.py b/Lib/plat-mac/Carbon/CoreGraphics.py
deleted file mode 100644
index f4cb0b9440b..00000000000
--- a/Lib/plat-mac/Carbon/CoreGraphics.py
+++ /dev/null
@@ -1,28 +0,0 @@
-# Generated from 'CGContext.h'
-
-def FOUR_CHAR_CODE(x): return x
-kCGLineJoinMiter = 0
-kCGLineJoinRound = 1
-kCGLineJoinBevel = 2
-kCGLineCapButt = 0
-kCGLineCapRound = 1
-kCGLineCapSquare = 2
-kCGPathFill = 0
-kCGPathEOFill = 1
-kCGPathStroke = 2
-kCGPathFillStroke = 3
-kCGPathEOFillStroke = 4
-kCGTextFill = 0
-kCGTextStroke = 1
-kCGTextFillStroke = 2
-kCGTextInvisible = 3
-kCGTextFillClip = 4
-kCGTextStrokeClip = 5
-kCGTextFillStrokeClip = 6
-kCGTextClip = 7
-kCGEncodingFontSpecific = 0
-kCGEncodingMacRoman = 1
-kCGInterpolationDefault = 0
-kCGInterpolationNone = 1
-kCGInterpolationLow = 2
-kCGInterpolationHigh = 3
diff --git a/Lib/plat-mac/Carbon/Ctl.py b/Lib/plat-mac/Carbon/Ctl.py
deleted file mode 100644
index b9dc3ef1cef..00000000000
--- a/Lib/plat-mac/Carbon/Ctl.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Ctl import *
diff --git a/Lib/plat-mac/Carbon/Dialogs.py b/Lib/plat-mac/Carbon/Dialogs.py
deleted file mode 100644
index f846d7c39d6..00000000000
--- a/Lib/plat-mac/Carbon/Dialogs.py
+++ /dev/null
@@ -1,79 +0,0 @@
-# Generated from 'Dialogs.h'
-
-def FOUR_CHAR_CODE(x): return x
-kControlDialogItem = 4
-kButtonDialogItem = kControlDialogItem | 0
-kCheckBoxDialogItem = kControlDialogItem | 1
-kRadioButtonDialogItem = kControlDialogItem | 2
-kResourceControlDialogItem = kControlDialogItem | 3
-kStaticTextDialogItem = 8
-kEditTextDialogItem = 16
-kIconDialogItem = 32
-kPictureDialogItem = 64
-kUserDialogItem = 0
-kHelpDialogItem = 1
-kItemDisableBit = 128
-ctrlItem = 4
-btnCtrl = 0
-chkCtrl = 1
-radCtrl = 2
-resCtrl = 3
-statText = 8
-editText = 16
-iconItem = 32
-picItem = 64
-userItem = 0
-itemDisable = 128
-kStdOkItemIndex = 1
-kStdCancelItemIndex = 2
-ok = kStdOkItemIndex
-cancel = kStdCancelItemIndex
-kStopIcon = 0
-kNoteIcon = 1
-kCautionIcon = 2
-stopIcon = kStopIcon
-noteIcon = kNoteIcon
-cautionIcon = kCautionIcon
-kOkItemIndex = 1
-kCancelItemIndex = 2
-overlayDITL = 0
-appendDITLRight = 1
-appendDITLBottom = 2
-kAlertStopAlert = 0
-kAlertNoteAlert = 1
-kAlertCautionAlert = 2
-kAlertPlainAlert = 3
-kAlertDefaultOKText = -1
-kAlertDefaultCancelText = -1
-kAlertDefaultOtherText = -1
-kAlertStdAlertOKButton = 1
-kAlertStdAlertCancelButton = 2
-kAlertStdAlertOtherButton = 3
-kAlertStdAlertHelpButton = 4
-kDialogFlagsUseThemeBackground = (1 << 0)
-kDialogFlagsUseControlHierarchy = (1 << 1)
-kDialogFlagsHandleMovableModal = (1 << 2)
-kDialogFlagsUseThemeControls = (1 << 3)
-kAlertFlagsUseThemeBackground = (1 << 0)
-kAlertFlagsUseControlHierarchy = (1 << 1)
-kAlertFlagsAlertIsMovable = (1 << 2)
-kAlertFlagsUseThemeControls = (1 << 3)
-kDialogFontNoFontStyle = 0
-kDialogFontUseFontMask = 0x0001
-kDialogFontUseFaceMask = 0x0002
-kDialogFontUseSizeMask = 0x0004
-kDialogFontUseForeColorMask = 0x0008
-kDialogFontUseBackColorMask = 0x0010
-kDialogFontUseModeMask = 0x0020
-kDialogFontUseJustMask = 0x0040
-kDialogFontUseAllMask = 0x00FF
-kDialogFontAddFontSizeMask = 0x0100
-kDialogFontUseFontNameMask = 0x0200
-kDialogFontAddToMetaFontMask = 0x0400
-kDialogFontUseThemeFontIDMask = 0x0080
-kHICommandOther = FOUR_CHAR_CODE('othr')
-kStdCFStringAlertVersionOne = 1
-kStdAlertDoNotDisposeSheet = 1 << 0
-kStdAlertDoNotAnimateOnDefault = 1 << 1
-kStdAlertDoNotAnimateOnCancel = 1 << 2
-kStdAlertDoNotAnimateOnOther = 1 << 3
diff --git a/Lib/plat-mac/Carbon/Dlg.py b/Lib/plat-mac/Carbon/Dlg.py
deleted file mode 100644
index 7b22d849815..00000000000
--- a/Lib/plat-mac/Carbon/Dlg.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Dlg import *
diff --git a/Lib/plat-mac/Carbon/Drag.py b/Lib/plat-mac/Carbon/Drag.py
deleted file mode 100644
index a2349d714f9..00000000000
--- a/Lib/plat-mac/Carbon/Drag.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Drag import *
diff --git a/Lib/plat-mac/Carbon/Dragconst.py b/Lib/plat-mac/Carbon/Dragconst.py
deleted file mode 100644
index 38e12be7afe..00000000000
--- a/Lib/plat-mac/Carbon/Dragconst.py
+++ /dev/null
@@ -1,86 +0,0 @@
-# Generated from 'Drag.h'
-
-def FOUR_CHAR_CODE(x): return x
-from Carbon.TextEdit import *
-from Carbon.QuickDraw import *
-fkDragActionAll = -1
-
-
-kDragHasLeftSenderWindow = (1 << 0)
-kDragInsideSenderApplication = (1 << 1)
-kDragInsideSenderWindow = (1 << 2)
-kDragRegionAndImage = (1 << 4)
-flavorSenderOnly = (1 << 0)
-flavorSenderTranslated = (1 << 1)
-flavorNotSaved = (1 << 2)
-flavorSystemTranslated = (1 << 8)
-kDragHasLeftSenderWindow = (1L << 0)
-kDragInsideSenderApplication = (1L << 1)
-kDragInsideSenderWindow = (1L << 2)
-kDragBehaviorNone = 0
-kDragBehaviorZoomBackAnimation = (1L << 0)
-kDragRegionAndImage = (1L << 4)
-kDragStandardTranslucency = 0L
-kDragDarkTranslucency = 1L
-kDragDarkerTranslucency = 2L
-kDragOpaqueTranslucency = 3L
-kDragRegionBegin = 1
-kDragRegionDraw = 2
-kDragRegionHide = 3
-kDragRegionIdle = 4
-kDragRegionEnd = 5
-kZoomNoAcceleration = 0
-kZoomAccelerate = 1
-kZoomDecelerate = 2
-flavorSenderOnly = (1 << 0)
-flavorSenderTranslated = (1 << 1)
-flavorNotSaved = (1 << 2)
-flavorSystemTranslated = (1 << 8)
-flavorDataPromised = (1 << 9)
-kDragFlavorTypeHFS = FOUR_CHAR_CODE('hfs ')
-kDragFlavorTypePromiseHFS = FOUR_CHAR_CODE('phfs')
-flavorTypeHFS = kDragFlavorTypeHFS
-flavorTypePromiseHFS = kDragFlavorTypePromiseHFS
-kDragPromisedFlavorFindFile = FOUR_CHAR_CODE('rWm1')
-kDragPromisedFlavor = FOUR_CHAR_CODE('fssP')
-kDragPseudoCreatorVolumeOrDirectory = FOUR_CHAR_CODE('MACS')
-kDragPseudoFileTypeVolume = FOUR_CHAR_CODE('disk')
-kDragPseudoFileTypeDirectory = FOUR_CHAR_CODE('fold')
-flavorTypeDirectory = FOUR_CHAR_CODE('diry')
-kFlavorTypeClippingName = FOUR_CHAR_CODE('clnm')
-kFlavorTypeClippingFilename = FOUR_CHAR_CODE('clfn')
-kFlavorTypeDragToTrashOnly = FOUR_CHAR_CODE('fdtt')
-kFlavorTypeFinderNoTrackingBehavior = FOUR_CHAR_CODE('fntb')
-kDragTrackingEnterHandler = 1
-kDragTrackingEnterWindow = 2
-kDragTrackingInWindow = 3
-kDragTrackingLeaveWindow = 4
-kDragTrackingLeaveHandler = 5
-kDragActionNothing = 0L
-kDragActionCopy = 1L
-kDragActionAlias = (1L << 1)
-kDragActionGeneric = (1L << 2)
-kDragActionPrivate = (1L << 3)
-kDragActionMove = (1L << 4)
-kDragActionDelete = (1L << 5)
-# kDragActionAll = (long)0xFFFFFFFF
-dragHasLeftSenderWindow = kDragHasLeftSenderWindow
-dragInsideSenderApplication = kDragInsideSenderApplication
-dragInsideSenderWindow = kDragInsideSenderWindow
-dragTrackingEnterHandler = kDragTrackingEnterHandler
-dragTrackingEnterWindow = kDragTrackingEnterWindow
-dragTrackingInWindow = kDragTrackingInWindow
-dragTrackingLeaveWindow = kDragTrackingLeaveWindow
-dragTrackingLeaveHandler = kDragTrackingLeaveHandler
-dragRegionBegin = kDragRegionBegin
-dragRegionDraw = kDragRegionDraw
-dragRegionHide = kDragRegionHide
-dragRegionIdle = kDragRegionIdle
-dragRegionEnd = kDragRegionEnd
-zoomNoAcceleration = kZoomNoAcceleration
-zoomAccelerate = kZoomAccelerate
-zoomDecelerate = kZoomDecelerate
-kDragStandardImage = kDragStandardTranslucency
-kDragDarkImage = kDragDarkTranslucency
-kDragDarkerImage = kDragDarkerTranslucency
-kDragOpaqueImage = kDragOpaqueTranslucency
diff --git a/Lib/plat-mac/Carbon/Events.py b/Lib/plat-mac/Carbon/Events.py
deleted file mode 100644
index 269f4f1449f..00000000000
--- a/Lib/plat-mac/Carbon/Events.py
+++ /dev/null
@@ -1,102 +0,0 @@
-# Generated from 'Events.h'
-
-nullEvent = 0
-mouseDown = 1
-mouseUp = 2
-keyDown = 3
-keyUp = 4
-autoKey = 5
-updateEvt = 6
-diskEvt = 7
-activateEvt = 8
-osEvt = 15
-kHighLevelEvent = 23
-mDownMask = 1 << mouseDown
-mUpMask = 1 << mouseUp
-keyDownMask = 1 << keyDown
-keyUpMask = 1 << keyUp
-autoKeyMask = 1 << autoKey
-updateMask = 1 << updateEvt
-diskMask = 1 << diskEvt
-activMask = 1 << activateEvt
-highLevelEventMask = 0x0400
-osMask = 1 << osEvt
-everyEvent = 0xFFFF
-charCodeMask = 0x000000FF
-keyCodeMask = 0x0000FF00
-adbAddrMask = 0x00FF0000
-# osEvtMessageMask = (unsigned long)0xFF000000
-mouseMovedMessage = 0x00FA
-suspendResumeMessage = 0x0001
-resumeFlag = 1
-convertClipboardFlag = 2
-activeFlagBit = 0
-btnStateBit = 7
-cmdKeyBit = 8
-shiftKeyBit = 9
-alphaLockBit = 10
-optionKeyBit = 11
-controlKeyBit = 12
-rightShiftKeyBit = 13
-rightOptionKeyBit = 14
-rightControlKeyBit = 15
-activeFlag = 1 << activeFlagBit
-btnState = 1 << btnStateBit
-cmdKey = 1 << cmdKeyBit
-shiftKey = 1 << shiftKeyBit
-alphaLock = 1 << alphaLockBit
-optionKey = 1 << optionKeyBit
-controlKey = 1 << controlKeyBit
-rightShiftKey = 1 << rightShiftKeyBit
-rightOptionKey = 1 << rightOptionKeyBit
-rightControlKey = 1 << rightControlKeyBit
-kNullCharCode = 0
-kHomeCharCode = 1
-kEnterCharCode = 3
-kEndCharCode = 4
-kHelpCharCode = 5
-kBellCharCode = 7
-kBackspaceCharCode = 8
-kTabCharCode = 9
-kLineFeedCharCode = 10
-kVerticalTabCharCode = 11
-kPageUpCharCode = 11
-kFormFeedCharCode = 12
-kPageDownCharCode = 12
-kReturnCharCode = 13
-kFunctionKeyCharCode = 16
-kCommandCharCode = 17
-kCheckCharCode = 18
-kDiamondCharCode = 19
-kAppleLogoCharCode = 20
-kEscapeCharCode = 27
-kClearCharCode = 27
-kLeftArrowCharCode = 28
-kRightArrowCharCode = 29
-kUpArrowCharCode = 30
-kDownArrowCharCode = 31
-kSpaceCharCode = 32
-kDeleteCharCode = 127
-kBulletCharCode = 165
-kNonBreakingSpaceCharCode = 202
-kShiftUnicode = 0x21E7
-kControlUnicode = 0x2303
-kOptionUnicode = 0x2325
-kCommandUnicode = 0x2318
-kPencilUnicode = 0x270E
-kCheckUnicode = 0x2713
-kDiamondUnicode = 0x25C6
-kBulletUnicode = 0x2022
-kAppleLogoUnicode = 0xF8FF
-networkEvt = 10
-driverEvt = 11
-app1Evt = 12
-app2Evt = 13
-app3Evt = 14
-app4Evt = 15
-networkMask = 0x0400
-driverMask = 0x0800
-app1Mask = 0x1000
-app2Mask = 0x2000
-app3Mask = 0x4000
-app4Mask = 0x8000
diff --git a/Lib/plat-mac/Carbon/Evt.py b/Lib/plat-mac/Carbon/Evt.py
deleted file mode 100644
index 7a5ffa69933..00000000000
--- a/Lib/plat-mac/Carbon/Evt.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Evt import *
diff --git a/Lib/plat-mac/Carbon/File.py b/Lib/plat-mac/Carbon/File.py
deleted file mode 100644
index 58c28574c74..00000000000
--- a/Lib/plat-mac/Carbon/File.py
+++ /dev/null
@@ -1 +0,0 @@
-from _File import *
diff --git a/Lib/plat-mac/Carbon/Files.py b/Lib/plat-mac/Carbon/Files.py
deleted file mode 100644
index 678bbc79475..00000000000
--- a/Lib/plat-mac/Carbon/Files.py
+++ /dev/null
@@ -1,426 +0,0 @@
-# Generated from 'Files.h'
-
-def FOUR_CHAR_CODE(x): return x
-true = True
-false = False
-fsCurPerm = 0x00
-fsRdPerm = 0x01
-fsWrPerm = 0x02
-fsRdWrPerm = 0x03
-fsRdWrShPerm = 0x04
-fsRdDenyPerm = 0x10
-fsWrDenyPerm = 0x20
-fsRtParID = 1
-fsRtDirID = 2
-fsAtMark = 0
-fsFromStart = 1
-fsFromLEOF = 2
-fsFromMark = 3
-pleaseCacheBit = 4
-pleaseCacheMask = 0x0010
-noCacheBit = 5
-noCacheMask = 0x0020
-rdVerifyBit = 6
-rdVerifyMask = 0x0040
-rdVerify = 64
-forceReadBit = 6
-forceReadMask = 0x0040
-newLineBit = 7
-newLineMask = 0x0080
-newLineCharMask = 0xFF00
-fsSBPartialName = 1
-fsSBFullName = 2
-fsSBFlAttrib = 4
-fsSBFlFndrInfo = 8
-fsSBFlLgLen = 32
-fsSBFlPyLen = 64
-fsSBFlRLgLen = 128
-fsSBFlRPyLen = 256
-fsSBFlCrDat = 512
-fsSBFlMdDat = 1024
-fsSBFlBkDat = 2048
-fsSBFlXFndrInfo = 4096
-fsSBFlParID = 8192
-fsSBNegate = 16384
-fsSBDrUsrWds = 8
-fsSBDrNmFls = 16
-fsSBDrCrDat = 512
-fsSBDrMdDat = 1024
-fsSBDrBkDat = 2048
-fsSBDrFndrInfo = 4096
-fsSBDrParID = 8192
-fsSBPartialNameBit = 0
-fsSBFullNameBit = 1
-fsSBFlAttribBit = 2
-fsSBFlFndrInfoBit = 3
-fsSBFlLgLenBit = 5
-fsSBFlPyLenBit = 6
-fsSBFlRLgLenBit = 7
-fsSBFlRPyLenBit = 8
-fsSBFlCrDatBit = 9
-fsSBFlMdDatBit = 10
-fsSBFlBkDatBit = 11
-fsSBFlXFndrInfoBit = 12
-fsSBFlParIDBit = 13
-fsSBNegateBit = 14
-fsSBDrUsrWdsBit = 3
-fsSBDrNmFlsBit = 4
-fsSBDrCrDatBit = 9
-fsSBDrMdDatBit = 10
-fsSBDrBkDatBit = 11
-fsSBDrFndrInfoBit = 12
-fsSBDrParIDBit = 13
-bLimitFCBs = 31
-bLocalWList = 30
-bNoMiniFndr = 29
-bNoVNEdit = 28
-bNoLclSync = 27
-bTrshOffLine = 26
-bNoSwitchTo = 25
-bDontShareIt = 21
-bNoDeskItems = 20
-bNoBootBlks = 19
-bAccessCntl = 18
-bNoSysDir = 17
-bHasExtFSVol = 16
-bHasOpenDeny = 15
-bHasCopyFile = 14
-bHasMoveRename = 13
-bHasDesktopMgr = 12
-bHasShortName = 11
-bHasFolderLock = 10
-bHasPersonalAccessPrivileges = 9
-bHasUserGroupList = 8
-bHasCatSearch = 7
-bHasFileIDs = 6
-bHasBTreeMgr = 5
-bHasBlankAccessPrivileges = 4
-bSupportsAsyncRequests = 3
-bSupportsTrashVolumeCache = 2
-bIsEjectable = 0
-bSupportsHFSPlusAPIs = 1
-bSupportsFSCatalogSearch = 2
-bSupportsFSExchangeObjects = 3
-bSupports2TBFiles = 4
-bSupportsLongNames = 5
-bSupportsMultiScriptNames = 6
-bSupportsNamedForks = 7
-bSupportsSubtreeIterators = 8
-bL2PCanMapFileBlocks = 9
-bParentModDateChanges = 10
-bAncestorModDateChanges = 11
-bSupportsSymbolicLinks = 13
-bIsAutoMounted = 14
-bAllowCDiDataHandler = 17
-kLargeIcon = 1
-kLarge4BitIcon = 2
-kLarge8BitIcon = 3
-kSmallIcon = 4
-kSmall4BitIcon = 5
-kSmall8BitIcon = 6
-kicnsIconFamily = 239
-kLargeIconSize = 256
-kLarge4BitIconSize = 512
-kLarge8BitIconSize = 1024
-kSmallIconSize = 64
-kSmall4BitIconSize = 128
-kSmall8BitIconSize = 256
-kWidePosOffsetBit = 8
-kUseWidePositioning = (1 << kWidePosOffsetBit)
-kMaximumBlocksIn4GB = 0x007FFFFF
-fsUnixPriv = 1
-kNoUserAuthentication = 1
-kPassword = 2
-kEncryptPassword = 3
-kTwoWayEncryptPassword = 6
-kOwnerID2Name = 1
-kGroupID2Name = 2
-kOwnerName2ID = 3
-kGroupName2ID = 4
-kReturnNextUser = 1
-kReturnNextGroup = 2
-kReturnNextUG = 3
-kVCBFlagsIdleFlushBit = 3
-kVCBFlagsIdleFlushMask = 0x0008
-kVCBFlagsHFSPlusAPIsBit = 4
-kVCBFlagsHFSPlusAPIsMask = 0x0010
-kVCBFlagsHardwareGoneBit = 5
-kVCBFlagsHardwareGoneMask = 0x0020
-kVCBFlagsVolumeDirtyBit = 15
-kVCBFlagsVolumeDirtyMask = 0x8000
-kioVAtrbDefaultVolumeBit = 5
-kioVAtrbDefaultVolumeMask = 0x0020
-kioVAtrbFilesOpenBit = 6
-kioVAtrbFilesOpenMask = 0x0040
-kioVAtrbHardwareLockedBit = 7
-kioVAtrbHardwareLockedMask = 0x0080
-kioVAtrbSoftwareLockedBit = 15
-kioVAtrbSoftwareLockedMask = 0x8000
-kioFlAttribLockedBit = 0
-kioFlAttribLockedMask = 0x01
-kioFlAttribResOpenBit = 2
-kioFlAttribResOpenMask = 0x04
-kioFlAttribDataOpenBit = 3
-kioFlAttribDataOpenMask = 0x08
-kioFlAttribDirBit = 4
-kioFlAttribDirMask = 0x10
-ioDirFlg = 4
-ioDirMask = 0x10
-kioFlAttribCopyProtBit = 6
-kioFlAttribCopyProtMask = 0x40
-kioFlAttribFileOpenBit = 7
-kioFlAttribFileOpenMask = 0x80
-kioFlAttribInSharedBit = 2
-kioFlAttribInSharedMask = 0x04
-kioFlAttribMountedBit = 3
-kioFlAttribMountedMask = 0x08
-kioFlAttribSharePointBit = 5
-kioFlAttribSharePointMask = 0x20
-kioFCBWriteBit = 8
-kioFCBWriteMask = 0x0100
-kioFCBResourceBit = 9
-kioFCBResourceMask = 0x0200
-kioFCBWriteLockedBit = 10
-kioFCBWriteLockedMask = 0x0400
-kioFCBLargeFileBit = 11
-kioFCBLargeFileMask = 0x0800
-kioFCBSharedWriteBit = 12
-kioFCBSharedWriteMask = 0x1000
-kioFCBFileLockedBit = 13
-kioFCBFileLockedMask = 0x2000
-kioFCBOwnClumpBit = 14
-kioFCBOwnClumpMask = 0x4000
-kioFCBModifiedBit = 15
-kioFCBModifiedMask = 0x8000
-kioACUserNoSeeFolderBit = 0
-kioACUserNoSeeFolderMask = 0x01
-kioACUserNoSeeFilesBit = 1
-kioACUserNoSeeFilesMask = 0x02
-kioACUserNoMakeChangesBit = 2
-kioACUserNoMakeChangesMask = 0x04
-kioACUserNotOwnerBit = 7
-kioACUserNotOwnerMask = 0x80
-kioACAccessOwnerBit = 31
-# kioACAccessOwnerMask = (long)0x80000000
-kioACAccessBlankAccessBit = 28
-kioACAccessBlankAccessMask = 0x10000000
-kioACAccessUserWriteBit = 26
-kioACAccessUserWriteMask = 0x04000000
-kioACAccessUserReadBit = 25
-kioACAccessUserReadMask = 0x02000000
-kioACAccessUserSearchBit = 24
-kioACAccessUserSearchMask = 0x01000000
-kioACAccessEveryoneWriteBit = 18
-kioACAccessEveryoneWriteMask = 0x00040000
-kioACAccessEveryoneReadBit = 17
-kioACAccessEveryoneReadMask = 0x00020000
-kioACAccessEveryoneSearchBit = 16
-kioACAccessEveryoneSearchMask = 0x00010000
-kioACAccessGroupWriteBit = 10
-kioACAccessGroupWriteMask = 0x00000400
-kioACAccessGroupReadBit = 9
-kioACAccessGroupReadMask = 0x00000200
-kioACAccessGroupSearchBit = 8
-kioACAccessGroupSearchMask = 0x00000100
-kioACAccessOwnerWriteBit = 2
-kioACAccessOwnerWriteMask = 0x00000004
-kioACAccessOwnerReadBit = 1
-kioACAccessOwnerReadMask = 0x00000002
-kioACAccessOwnerSearchBit = 0
-kioACAccessOwnerSearchMask = 0x00000001
-kfullPrivileges = 0x00070007
-kownerPrivileges = 0x00000007
-knoUser = 0
-kadministratorUser = 1
-knoGroup = 0
-AppleShareMediaType = FOUR_CHAR_CODE('afpm')
-volMountNoLoginMsgFlagBit = 0
-volMountNoLoginMsgFlagMask = 0x0001
-volMountExtendedFlagsBit = 7
-volMountExtendedFlagsMask = 0x0080
-volMountInteractBit = 15
-volMountInteractMask = 0x8000
-volMountChangedBit = 14
-volMountChangedMask = 0x4000
-volMountFSReservedMask = 0x00FF
-volMountSysReservedMask = 0xFF00
-kAFPExtendedFlagsAlternateAddressMask = 1
-kAFPTagTypeIP = 0x01
-kAFPTagTypeIPPort = 0x02
-kAFPTagTypeDDP = 0x03
-kAFPTagTypeDNS = 0x04
-kAFPTagLengthIP = 0x06
-kAFPTagLengthIPPort = 0x08
-kAFPTagLengthDDP = 0x06
-kFSInvalidVolumeRefNum = 0
-kFSCatInfoNone = 0x00000000
-kFSCatInfoTextEncoding = 0x00000001
-kFSCatInfoNodeFlags = 0x00000002
-kFSCatInfoVolume = 0x00000004
-kFSCatInfoParentDirID = 0x00000008
-kFSCatInfoNodeID = 0x00000010
-kFSCatInfoCreateDate = 0x00000020
-kFSCatInfoContentMod = 0x00000040
-kFSCatInfoAttrMod = 0x00000080
-kFSCatInfoAccessDate = 0x00000100
-kFSCatInfoBackupDate = 0x00000200
-kFSCatInfoPermissions = 0x00000400
-kFSCatInfoFinderInfo = 0x00000800
-kFSCatInfoFinderXInfo = 0x00001000
-kFSCatInfoValence = 0x00002000
-kFSCatInfoDataSizes = 0x00004000
-kFSCatInfoRsrcSizes = 0x00008000
-kFSCatInfoSharingFlags = 0x00010000
-kFSCatInfoUserPrivs = 0x00020000
-kFSCatInfoUserAccess = 0x00080000
-kFSCatInfoAllDates = 0x000003E0
-kFSCatInfoGettableInfo = 0x0003FFFF
-kFSCatInfoSettableInfo = 0x00001FE3
-# kFSCatInfoReserved = (long)0xFFFC0000
-kFSNodeLockedBit = 0
-kFSNodeLockedMask = 0x0001
-kFSNodeResOpenBit = 2
-kFSNodeResOpenMask = 0x0004
-kFSNodeDataOpenBit = 3
-kFSNodeDataOpenMask = 0x0008
-kFSNodeIsDirectoryBit = 4
-kFSNodeIsDirectoryMask = 0x0010
-kFSNodeCopyProtectBit = 6
-kFSNodeCopyProtectMask = 0x0040
-kFSNodeForkOpenBit = 7
-kFSNodeForkOpenMask = 0x0080
-kFSNodeInSharedBit = 2
-kFSNodeInSharedMask = 0x0004
-kFSNodeIsMountedBit = 3
-kFSNodeIsMountedMask = 0x0008
-kFSNodeIsSharePointBit = 5
-kFSNodeIsSharePointMask = 0x0020
-kFSIterateFlat = 0
-kFSIterateSubtree = 1
-kFSIterateDelete = 2
-# kFSIterateReserved = (long)0xFFFFFFFC
-fsSBNodeID = 0x00008000
-fsSBAttributeModDate = 0x00010000
-fsSBAccessDate = 0x00020000
-fsSBPermissions = 0x00040000
-fsSBNodeIDBit = 15
-fsSBAttributeModDateBit = 16
-fsSBAccessDateBit = 17
-fsSBPermissionsBit = 18
-kFSAllocDefaultFlags = 0x0000
-kFSAllocAllOrNothingMask = 0x0001
-kFSAllocContiguousMask = 0x0002
-kFSAllocNoRoundUpMask = 0x0004
-kFSAllocReservedMask = 0xFFF8
-kFSVolInfoNone = 0x0000
-kFSVolInfoCreateDate = 0x0001
-kFSVolInfoModDate = 0x0002
-kFSVolInfoBackupDate = 0x0004
-kFSVolInfoCheckedDate = 0x0008
-kFSVolInfoFileCount = 0x0010
-kFSVolInfoDirCount = 0x0020
-kFSVolInfoSizes = 0x0040
-kFSVolInfoBlocks = 0x0080
-kFSVolInfoNextAlloc = 0x0100
-kFSVolInfoRsrcClump = 0x0200
-kFSVolInfoDataClump = 0x0400
-kFSVolInfoNextID = 0x0800
-kFSVolInfoFinderInfo = 0x1000
-kFSVolInfoFlags = 0x2000
-kFSVolInfoFSInfo = 0x4000
-kFSVolInfoDriveInfo = 0x8000
-kFSVolInfoGettableInfo = 0xFFFF
-kFSVolInfoSettableInfo = 0x3004
-kFSVolFlagDefaultVolumeBit = 5
-kFSVolFlagDefaultVolumeMask = 0x0020
-kFSVolFlagFilesOpenBit = 6
-kFSVolFlagFilesOpenMask = 0x0040
-kFSVolFlagHardwareLockedBit = 7
-kFSVolFlagHardwareLockedMask = 0x0080
-kFSVolFlagSoftwareLockedBit = 15
-kFSVolFlagSoftwareLockedMask = 0x8000
-kFNDirectoryModifiedMessage = 1
-kFNNoImplicitAllSubscription = (1 << 0)
-rAliasType = FOUR_CHAR_CODE('alis')
-kARMMountVol = 0x00000001
-kARMNoUI = 0x00000002
-kARMMultVols = 0x00000008
-kARMSearch = 0x00000100
-kARMSearchMore = 0x00000200
-kARMSearchRelFirst = 0x00000400
-asiZoneName = -3
-asiServerName = -2
-asiVolumeName = -1
-asiAliasName = 0
-asiParentName = 1
-kResolveAliasFileNoUI = 0x00000001
-kClippingCreator = FOUR_CHAR_CODE('drag')
-kClippingPictureType = FOUR_CHAR_CODE('clpp')
-kClippingTextType = FOUR_CHAR_CODE('clpt')
-kClippingSoundType = FOUR_CHAR_CODE('clps')
-kClippingUnknownType = FOUR_CHAR_CODE('clpu')
-kInternetLocationCreator = FOUR_CHAR_CODE('drag')
-kInternetLocationHTTP = FOUR_CHAR_CODE('ilht')
-kInternetLocationFTP = FOUR_CHAR_CODE('ilft')
-kInternetLocationFile = FOUR_CHAR_CODE('ilfi')
-kInternetLocationMail = FOUR_CHAR_CODE('ilma')
-kInternetLocationNNTP = FOUR_CHAR_CODE('ilnw')
-kInternetLocationAFP = FOUR_CHAR_CODE('ilaf')
-kInternetLocationAppleTalk = FOUR_CHAR_CODE('ilat')
-kInternetLocationNSL = FOUR_CHAR_CODE('ilns')
-kInternetLocationGeneric = FOUR_CHAR_CODE('ilge')
-kCustomIconResource = -16455
-kCustomBadgeResourceType = FOUR_CHAR_CODE('badg')
-kCustomBadgeResourceID = kCustomIconResource
-kCustomBadgeResourceVersion = 0
-# kSystemFolderType = 'macs'.
-kRoutingResourceType = FOUR_CHAR_CODE('rout')
-kRoutingResourceID = 0
-kContainerFolderAliasType = FOUR_CHAR_CODE('fdrp')
-kContainerTrashAliasType = FOUR_CHAR_CODE('trsh')
-kContainerHardDiskAliasType = FOUR_CHAR_CODE('hdsk')
-kContainerFloppyAliasType = FOUR_CHAR_CODE('flpy')
-kContainerServerAliasType = FOUR_CHAR_CODE('srvr')
-kApplicationAliasType = FOUR_CHAR_CODE('adrp')
-kContainerAliasType = FOUR_CHAR_CODE('drop')
-kDesktopPrinterAliasType = FOUR_CHAR_CODE('dtpa')
-kContainerCDROMAliasType = FOUR_CHAR_CODE('cddr')
-kApplicationCPAliasType = FOUR_CHAR_CODE('acdp')
-kApplicationDAAliasType = FOUR_CHAR_CODE('addp')
-kPackageAliasType = FOUR_CHAR_CODE('fpka')
-kAppPackageAliasType = FOUR_CHAR_CODE('fapa')
-kSystemFolderAliasType = FOUR_CHAR_CODE('fasy')
-kAppleMenuFolderAliasType = FOUR_CHAR_CODE('faam')
-kStartupFolderAliasType = FOUR_CHAR_CODE('fast')
-kPrintMonitorDocsFolderAliasType = FOUR_CHAR_CODE('fapn')
-kPreferencesFolderAliasType = FOUR_CHAR_CODE('fapf')
-kControlPanelFolderAliasType = FOUR_CHAR_CODE('fact')
-kExtensionFolderAliasType = FOUR_CHAR_CODE('faex')
-kExportedFolderAliasType = FOUR_CHAR_CODE('faet')
-kDropFolderAliasType = FOUR_CHAR_CODE('fadr')
-kSharedFolderAliasType = FOUR_CHAR_CODE('fash')
-kMountedFolderAliasType = FOUR_CHAR_CODE('famn')
-kIsOnDesk = 0x0001
-kColor = 0x000E
-kIsShared = 0x0040
-kHasNoINITs = 0x0080
-kHasBeenInited = 0x0100
-kHasCustomIcon = 0x0400
-kIsStationery = 0x0800
-kNameLocked = 0x1000
-kHasBundle = 0x2000
-kIsInvisible = 0x4000
-kIsAlias = 0x8000
-fOnDesk = kIsOnDesk
-fHasBundle = kHasBundle
-fInvisible = kIsInvisible
-fTrash = -3
-fDesktop = -2
-fDisk = 0
-kIsStationary = kIsStationery
-kExtendedFlagsAreInvalid = 0x8000
-kExtendedFlagHasCustomBadge = 0x0100
-kExtendedFlagHasRoutingInfo = 0x0004
-kFirstMagicBusyFiletype = FOUR_CHAR_CODE('bzy ')
-kLastMagicBusyFiletype = FOUR_CHAR_CODE('bzy?')
-kMagicBusyCreationDate = 0x4F3AFDB0
diff --git a/Lib/plat-mac/Carbon/Fm.py b/Lib/plat-mac/Carbon/Fm.py
deleted file mode 100644
index 0f42fdcd9a6..00000000000
--- a/Lib/plat-mac/Carbon/Fm.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Fm import *
diff --git a/Lib/plat-mac/Carbon/Folder.py b/Lib/plat-mac/Carbon/Folder.py
deleted file mode 100644
index a4e49028924..00000000000
--- a/Lib/plat-mac/Carbon/Folder.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Folder import *
diff --git a/Lib/plat-mac/Carbon/Folders.py b/Lib/plat-mac/Carbon/Folders.py
deleted file mode 100644
index 52cf15808ff..00000000000
--- a/Lib/plat-mac/Carbon/Folders.py
+++ /dev/null
@@ -1,190 +0,0 @@
-# Generated from 'Folders.h'
-
-def FOUR_CHAR_CODE(x): return x
-true = True
-false = False
-kOnSystemDisk = -32768L
-kOnAppropriateDisk = -32767
-kSystemDomain = -32766
-kLocalDomain = -32765
-kNetworkDomain = -32764
-kUserDomain = -32763
-kClassicDomain = -32762
-kCreateFolder = true
-kDontCreateFolder = false
-kSystemFolderType = FOUR_CHAR_CODE('macs')
-kDesktopFolderType = FOUR_CHAR_CODE('desk')
-kSystemDesktopFolderType = FOUR_CHAR_CODE('sdsk')
-kTrashFolderType = FOUR_CHAR_CODE('trsh')
-kSystemTrashFolderType = FOUR_CHAR_CODE('strs')
-kWhereToEmptyTrashFolderType = FOUR_CHAR_CODE('empt')
-kPrintMonitorDocsFolderType = FOUR_CHAR_CODE('prnt')
-kStartupFolderType = FOUR_CHAR_CODE('strt')
-kShutdownFolderType = FOUR_CHAR_CODE('shdf')
-kAppleMenuFolderType = FOUR_CHAR_CODE('amnu')
-kControlPanelFolderType = FOUR_CHAR_CODE('ctrl')
-kSystemControlPanelFolderType = FOUR_CHAR_CODE('sctl')
-kExtensionFolderType = FOUR_CHAR_CODE('extn')
-kFontsFolderType = FOUR_CHAR_CODE('font')
-kPreferencesFolderType = FOUR_CHAR_CODE('pref')
-kSystemPreferencesFolderType = FOUR_CHAR_CODE('sprf')
-kTemporaryFolderType = FOUR_CHAR_CODE('temp')
-kExtensionDisabledFolderType = FOUR_CHAR_CODE('extD')
-kControlPanelDisabledFolderType = FOUR_CHAR_CODE('ctrD')
-kSystemExtensionDisabledFolderType = FOUR_CHAR_CODE('macD')
-kStartupItemsDisabledFolderType = FOUR_CHAR_CODE('strD')
-kShutdownItemsDisabledFolderType = FOUR_CHAR_CODE('shdD')
-kApplicationsFolderType = FOUR_CHAR_CODE('apps')
-kDocumentsFolderType = FOUR_CHAR_CODE('docs')
-kVolumeRootFolderType = FOUR_CHAR_CODE('root')
-kChewableItemsFolderType = FOUR_CHAR_CODE('flnt')
-kApplicationSupportFolderType = FOUR_CHAR_CODE('asup')
-kTextEncodingsFolderType = FOUR_CHAR_CODE('\xc4tex')
-kStationeryFolderType = FOUR_CHAR_CODE('odst')
-kOpenDocFolderType = FOUR_CHAR_CODE('odod')
-kOpenDocShellPlugInsFolderType = FOUR_CHAR_CODE('odsp')
-kEditorsFolderType = FOUR_CHAR_CODE('oded')
-kOpenDocEditorsFolderType = FOUR_CHAR_CODE('\xc4odf')
-kOpenDocLibrariesFolderType = FOUR_CHAR_CODE('odlb')
-kGenEditorsFolderType = FOUR_CHAR_CODE('\xc4edi')
-kHelpFolderType = FOUR_CHAR_CODE('\xc4hlp')
-kInternetPlugInFolderType = FOUR_CHAR_CODE('\xc4net')
-kModemScriptsFolderType = FOUR_CHAR_CODE('\xc4mod')
-kPrinterDescriptionFolderType = FOUR_CHAR_CODE('ppdf')
-kPrinterDriverFolderType = FOUR_CHAR_CODE('\xc4prd')
-kScriptingAdditionsFolderType = FOUR_CHAR_CODE('\xc4scr')
-kSharedLibrariesFolderType = FOUR_CHAR_CODE('\xc4lib')
-kVoicesFolderType = FOUR_CHAR_CODE('fvoc')
-kControlStripModulesFolderType = FOUR_CHAR_CODE('sdev')
-kAssistantsFolderType = FOUR_CHAR_CODE('ast\xc4')
-kUtilitiesFolderType = FOUR_CHAR_CODE('uti\xc4')
-kAppleExtrasFolderType = FOUR_CHAR_CODE('aex\xc4')
-kContextualMenuItemsFolderType = FOUR_CHAR_CODE('cmnu')
-kMacOSReadMesFolderType = FOUR_CHAR_CODE('mor\xc4')
-kALMModulesFolderType = FOUR_CHAR_CODE('walk')
-kALMPreferencesFolderType = FOUR_CHAR_CODE('trip')
-kALMLocationsFolderType = FOUR_CHAR_CODE('fall')
-kColorSyncProfilesFolderType = FOUR_CHAR_CODE('prof')
-kThemesFolderType = FOUR_CHAR_CODE('thme')
-kFavoritesFolderType = FOUR_CHAR_CODE('favs')
-kInternetFolderType = FOUR_CHAR_CODE('int\xc4')
-kAppearanceFolderType = FOUR_CHAR_CODE('appr')
-kSoundSetsFolderType = FOUR_CHAR_CODE('snds')
-kDesktopPicturesFolderType = FOUR_CHAR_CODE('dtp\xc4')
-kInternetSearchSitesFolderType = FOUR_CHAR_CODE('issf')
-kFindSupportFolderType = FOUR_CHAR_CODE('fnds')
-kFindByContentFolderType = FOUR_CHAR_CODE('fbcf')
-kInstallerLogsFolderType = FOUR_CHAR_CODE('ilgf')
-kScriptsFolderType = FOUR_CHAR_CODE('scr\xc4')
-kFolderActionsFolderType = FOUR_CHAR_CODE('fasf')
-kLauncherItemsFolderType = FOUR_CHAR_CODE('laun')
-kRecentApplicationsFolderType = FOUR_CHAR_CODE('rapp')
-kRecentDocumentsFolderType = FOUR_CHAR_CODE('rdoc')
-kRecentServersFolderType = FOUR_CHAR_CODE('rsvr')
-kSpeakableItemsFolderType = FOUR_CHAR_CODE('spki')
-kKeychainFolderType = FOUR_CHAR_CODE('kchn')
-kQuickTimeExtensionsFolderType = FOUR_CHAR_CODE('qtex')
-kDisplayExtensionsFolderType = FOUR_CHAR_CODE('dspl')
-kMultiprocessingFolderType = FOUR_CHAR_CODE('mpxf')
-kPrintingPlugInsFolderType = FOUR_CHAR_CODE('pplg')
-kDomainTopLevelFolderType = FOUR_CHAR_CODE('dtop')
-kDomainLibraryFolderType = FOUR_CHAR_CODE('dlib')
-kColorSyncFolderType = FOUR_CHAR_CODE('sync')
-kColorSyncCMMFolderType = FOUR_CHAR_CODE('ccmm')
-kColorSyncScriptingFolderType = FOUR_CHAR_CODE('cscr')
-kPrintersFolderType = FOUR_CHAR_CODE('impr')
-kSpeechFolderType = FOUR_CHAR_CODE('spch')
-kCarbonLibraryFolderType = FOUR_CHAR_CODE('carb')
-kDocumentationFolderType = FOUR_CHAR_CODE('info')
-kDeveloperDocsFolderType = FOUR_CHAR_CODE('ddoc')
-kDeveloperHelpFolderType = FOUR_CHAR_CODE('devh')
-kISSDownloadsFolderType = FOUR_CHAR_CODE('issd')
-kUserSpecificTmpFolderType = FOUR_CHAR_CODE('utmp')
-kCachedDataFolderType = FOUR_CHAR_CODE('cach')
-kFrameworksFolderType = FOUR_CHAR_CODE('fram')
-kPrivateFrameworksFolderType = FOUR_CHAR_CODE('pfrm')
-kClassicDesktopFolderType = FOUR_CHAR_CODE('sdsk')
-kDeveloperFolderType = FOUR_CHAR_CODE('devf')
-kSystemSoundsFolderType = FOUR_CHAR_CODE('ssnd')
-kComponentsFolderType = FOUR_CHAR_CODE('cmpd')
-kQuickTimeComponentsFolderType = FOUR_CHAR_CODE('wcmp')
-kCoreServicesFolderType = FOUR_CHAR_CODE('csrv')
-kPictureDocumentsFolderType = FOUR_CHAR_CODE('pdoc')
-kMovieDocumentsFolderType = FOUR_CHAR_CODE('mdoc')
-kMusicDocumentsFolderType = FOUR_CHAR_CODE('\xb5doc')
-kInternetSitesFolderType = FOUR_CHAR_CODE('site')
-kPublicFolderType = FOUR_CHAR_CODE('pubb')
-kAudioSupportFolderType = FOUR_CHAR_CODE('adio')
-kAudioSoundsFolderType = FOUR_CHAR_CODE('asnd')
-kAudioSoundBanksFolderType = FOUR_CHAR_CODE('bank')
-kAudioAlertSoundsFolderType = FOUR_CHAR_CODE('alrt')
-kAudioPlugInsFolderType = FOUR_CHAR_CODE('aplg')
-kAudioComponentsFolderType = FOUR_CHAR_CODE('acmp')
-kKernelExtensionsFolderType = FOUR_CHAR_CODE('kext')
-kDirectoryServicesFolderType = FOUR_CHAR_CODE('dsrv')
-kDirectoryServicesPlugInsFolderType = FOUR_CHAR_CODE('dplg')
-kInstallerReceiptsFolderType = FOUR_CHAR_CODE('rcpt')
-kFileSystemSupportFolderType = FOUR_CHAR_CODE('fsys')
-kAppleShareSupportFolderType = FOUR_CHAR_CODE('shar')
-kAppleShareAuthenticationFolderType = FOUR_CHAR_CODE('auth')
-kMIDIDriversFolderType = FOUR_CHAR_CODE('midi')
-kLocalesFolderType = FOUR_CHAR_CODE('\xc4loc')
-kFindByContentPluginsFolderType = FOUR_CHAR_CODE('fbcp')
-kUsersFolderType = FOUR_CHAR_CODE('usrs')
-kCurrentUserFolderType = FOUR_CHAR_CODE('cusr')
-kCurrentUserRemoteFolderLocation = FOUR_CHAR_CODE('rusf')
-kCurrentUserRemoteFolderType = FOUR_CHAR_CODE('rusr')
-kSharedUserDataFolderType = FOUR_CHAR_CODE('sdat')
-kVolumeSettingsFolderType = FOUR_CHAR_CODE('vsfd')
-kAppleshareAutomountServerAliasesFolderType = FOUR_CHAR_CODE('srv\xc4')
-kPreMacOS91ApplicationsFolderType = FOUR_CHAR_CODE('\x8cpps')
-kPreMacOS91InstallerLogsFolderType = FOUR_CHAR_CODE('\x94lgf')
-kPreMacOS91AssistantsFolderType = FOUR_CHAR_CODE('\x8cst\xc4')
-kPreMacOS91UtilitiesFolderType = FOUR_CHAR_CODE('\x9fti\xc4')
-kPreMacOS91AppleExtrasFolderType = FOUR_CHAR_CODE('\x8cex\xc4')
-kPreMacOS91MacOSReadMesFolderType = FOUR_CHAR_CODE('\xb5or\xc4')
-kPreMacOS91InternetFolderType = FOUR_CHAR_CODE('\x94nt\xc4')
-kPreMacOS91AutomountedServersFolderType = FOUR_CHAR_CODE('\xa7rv\xc4')
-kPreMacOS91StationeryFolderType = FOUR_CHAR_CODE('\xbfdst')
-kCreateFolderAtBoot = 0x00000002
-kCreateFolderAtBootBit = 1
-kFolderCreatedInvisible = 0x00000004
-kFolderCreatedInvisibleBit = 2
-kFolderCreatedNameLocked = 0x00000008
-kFolderCreatedNameLockedBit = 3
-kFolderCreatedAdminPrivs = 0x00000010
-kFolderCreatedAdminPrivsBit = 4
-kFolderInUserFolder = 0x00000020
-kFolderInUserFolderBit = 5
-kFolderTrackedByAlias = 0x00000040
-kFolderTrackedByAliasBit = 6
-kFolderInRemoteUserFolderIfAvailable = 0x00000080
-kFolderInRemoteUserFolderIfAvailableBit = 7
-kFolderNeverMatchedInIdentifyFolder = 0x00000100
-kFolderNeverMatchedInIdentifyFolderBit = 8
-kFolderMustStayOnSameVolume = 0x00000200
-kFolderMustStayOnSameVolumeBit = 9
-kFolderManagerFolderInMacOS9FolderIfMacOSXIsInstalledMask = 0x00000400
-kFolderManagerFolderInMacOS9FolderIfMacOSXIsInstalledBit = 10
-kFolderInLocalOrRemoteUserFolder = kFolderInUserFolder | kFolderInRemoteUserFolderIfAvailable
-kRelativeFolder = FOUR_CHAR_CODE('relf')
-kSpecialFolder = FOUR_CHAR_CODE('spcf')
-kBlessedFolder = FOUR_CHAR_CODE('blsf')
-kRootFolder = FOUR_CHAR_CODE('rotf')
-kCurrentUserFolderLocation = FOUR_CHAR_CODE('cusf')
-kFindFolderRedirectionFlagUseDistinctUserFoldersBit = 0
-kFindFolderRedirectionFlagUseGivenVRefAndDirIDAsUserFolderBit = 1
-kFindFolderRedirectionFlagsUseGivenVRefNumAndDirIDAsRemoteUserFolderBit = 2
-kFolderManagerUserRedirectionGlobalsCurrentVersion = 1
-kFindFolderExtendedFlagsDoNotFollowAliasesBit = 0
-kFindFolderExtendedFlagsDoNotUseUserFolderBit = 1
-kFindFolderExtendedFlagsUseOtherUserRecord = 0x01000000
-kFolderManagerNotificationMessageUserLogIn = FOUR_CHAR_CODE('log+')
-kFolderManagerNotificationMessagePreUserLogIn = FOUR_CHAR_CODE('logj')
-kFolderManagerNotificationMessageUserLogOut = FOUR_CHAR_CODE('log-')
-kFolderManagerNotificationMessagePostUserLogOut = FOUR_CHAR_CODE('logp')
-kFolderManagerNotificationDiscardCachedData = FOUR_CHAR_CODE('dche')
-kFolderManagerNotificationMessageLoginStartup = FOUR_CHAR_CODE('stup')
-kDoNotRemoveWhenCurrentApplicationQuitsBit = 0
-kDoNotRemoveWheCurrentApplicationQuitsBit = kDoNotRemoveWhenCurrentApplicationQuitsBit
-kStopIfAnyNotificationProcReturnsErrorBit = 31
diff --git a/Lib/plat-mac/Carbon/Fonts.py b/Lib/plat-mac/Carbon/Fonts.py
deleted file mode 100644
index 8be7e7a4143..00000000000
--- a/Lib/plat-mac/Carbon/Fonts.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# Generated from 'Fonts.h'
-
-def FOUR_CHAR_CODE(x): return x
-kNilOptions = 0
-systemFont = 0
-applFont = 1
-kFMDefaultOptions = kNilOptions
-kFMDefaultActivationContext = kFMDefaultOptions
-kFMGlobalActivationContext = 0x00000001
-kFMLocalActivationContext = kFMDefaultActivationContext
-kFMDefaultIterationScope = kFMDefaultOptions
-kFMGlobalIterationScope = 0x00000001
-kFMLocalIterationScope = kFMDefaultIterationScope
-kPlatformDefaultGuiFontID = applFont
-kPlatformDefaultGuiFontID = -1
-commandMark = 17
-checkMark = 18
-diamondMark = 19
-appleMark = 20
-propFont = 36864L
-prpFntH = 36865L
-prpFntW = 36866L
-prpFntHW = 36867L
-fixedFont = 45056L
-fxdFntH = 45057L
-fxdFntW = 45058L
-fxdFntHW = 45059L
-fontWid = 44208L
-kFMUseGlobalScopeOption = 0x00000001
-kFontIDNewYork = 2
-kFontIDGeneva = 3
-kFontIDMonaco = 4
-kFontIDVenice = 5
-kFontIDLondon = 6
-kFontIDAthens = 7
-kFontIDSanFrancisco = 8
-kFontIDToronto = 9
-kFontIDCairo = 11
-kFontIDLosAngeles = 12
-kFontIDTimes = 20
-kFontIDHelvetica = 21
-kFontIDCourier = 22
-kFontIDSymbol = 23
-kFontIDMobile = 24
-newYork = kFontIDNewYork
-geneva = kFontIDGeneva
-monaco = kFontIDMonaco
-venice = kFontIDVenice
-london = kFontIDLondon
-athens = kFontIDAthens
-sanFran = kFontIDSanFrancisco
-toronto = kFontIDToronto
-cairo = kFontIDCairo
-losAngeles = kFontIDLosAngeles
-times = kFontIDTimes
-helvetica = kFontIDHelvetica
-courier = kFontIDCourier
-symbol = kFontIDSymbol
-mobile = kFontIDMobile
diff --git a/Lib/plat-mac/Carbon/Help.py b/Lib/plat-mac/Carbon/Help.py
deleted file mode 100644
index 5fca0d7fd73..00000000000
--- a/Lib/plat-mac/Carbon/Help.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Help import *
diff --git a/Lib/plat-mac/Carbon/IBCarbon.py b/Lib/plat-mac/Carbon/IBCarbon.py
deleted file mode 100644
index 60f0e74ca92..00000000000
--- a/Lib/plat-mac/Carbon/IBCarbon.py
+++ /dev/null
@@ -1 +0,0 @@
-from _IBCarbon import *
diff --git a/Lib/plat-mac/Carbon/IBCarbonRuntime.py b/Lib/plat-mac/Carbon/IBCarbonRuntime.py
deleted file mode 100644
index 46780187d65..00000000000
--- a/Lib/plat-mac/Carbon/IBCarbonRuntime.py
+++ /dev/null
@@ -1,5 +0,0 @@
-# Generated from 'IBCarbonRuntime.h'
-
-kIBCarbonRuntimeCantFindNibFile = -10960
-kIBCarbonRuntimeObjectNotOfRequestedType = -10961
-kIBCarbonRuntimeCantFindObject = -10962
diff --git a/Lib/plat-mac/Carbon/Icn.py b/Lib/plat-mac/Carbon/Icn.py
deleted file mode 100644
index b04134c8e22..00000000000
--- a/Lib/plat-mac/Carbon/Icn.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Icn import *
diff --git a/Lib/plat-mac/Carbon/Icons.py b/Lib/plat-mac/Carbon/Icons.py
deleted file mode 100644
index 86dae632dd9..00000000000
--- a/Lib/plat-mac/Carbon/Icons.py
+++ /dev/null
@@ -1,381 +0,0 @@
-# Generated from 'Icons.h'
-
-def FOUR_CHAR_CODE(x): return x
-from Carbon.Files import *
-kGenericDocumentIconResource = -4000
-kGenericStationeryIconResource = -3985
-kGenericEditionFileIconResource = -3989
-kGenericApplicationIconResource = -3996
-kGenericDeskAccessoryIconResource = -3991
-kGenericFolderIconResource = -3999
-kPrivateFolderIconResource = -3994
-kFloppyIconResource = -3998
-kTrashIconResource = -3993
-kGenericRAMDiskIconResource = -3988
-kGenericCDROMIconResource = -3987
-kDesktopIconResource = -3992
-kOpenFolderIconResource = -3997
-kGenericHardDiskIconResource = -3995
-kGenericFileServerIconResource = -3972
-kGenericSuitcaseIconResource = -3970
-kGenericMoverObjectIconResource = -3969
-kGenericPreferencesIconResource = -3971
-kGenericQueryDocumentIconResource = -16506
-kGenericExtensionIconResource = -16415
-kSystemFolderIconResource = -3983
-kHelpIconResource = -20271
-kAppleMenuFolderIconResource = -3982
-genericDocumentIconResource = kGenericDocumentIconResource
-genericStationeryIconResource = kGenericStationeryIconResource
-genericEditionFileIconResource = kGenericEditionFileIconResource
-genericApplicationIconResource = kGenericApplicationIconResource
-genericDeskAccessoryIconResource = kGenericDeskAccessoryIconResource
-genericFolderIconResource = kGenericFolderIconResource
-privateFolderIconResource = kPrivateFolderIconResource
-floppyIconResource = kFloppyIconResource
-trashIconResource = kTrashIconResource
-genericRAMDiskIconResource = kGenericRAMDiskIconResource
-genericCDROMIconResource = kGenericCDROMIconResource
-desktopIconResource = kDesktopIconResource
-openFolderIconResource = kOpenFolderIconResource
-genericHardDiskIconResource = kGenericHardDiskIconResource
-genericFileServerIconResource = kGenericFileServerIconResource
-genericSuitcaseIconResource = kGenericSuitcaseIconResource
-genericMoverObjectIconResource = kGenericMoverObjectIconResource
-genericPreferencesIconResource = kGenericPreferencesIconResource
-genericQueryDocumentIconResource = kGenericQueryDocumentIconResource
-genericExtensionIconResource = kGenericExtensionIconResource
-systemFolderIconResource = kSystemFolderIconResource
-appleMenuFolderIconResource = kAppleMenuFolderIconResource
-kStartupFolderIconResource = -3981
-kOwnedFolderIconResource = -3980
-kDropFolderIconResource = -3979
-kSharedFolderIconResource = -3978
-kMountedFolderIconResource = -3977
-kControlPanelFolderIconResource = -3976
-kPrintMonitorFolderIconResource = -3975
-kPreferencesFolderIconResource = -3974
-kExtensionsFolderIconResource = -3973
-kFontsFolderIconResource = -3968
-kFullTrashIconResource = -3984
-startupFolderIconResource = kStartupFolderIconResource
-ownedFolderIconResource = kOwnedFolderIconResource
-dropFolderIconResource = kDropFolderIconResource
-sharedFolderIconResource = kSharedFolderIconResource
-mountedFolderIconResource = kMountedFolderIconResource
-controlPanelFolderIconResource = kControlPanelFolderIconResource
-printMonitorFolderIconResource = kPrintMonitorFolderIconResource
-preferencesFolderIconResource = kPreferencesFolderIconResource
-extensionsFolderIconResource = kExtensionsFolderIconResource
-fontsFolderIconResource = kFontsFolderIconResource
-fullTrashIconResource = kFullTrashIconResource
-kThumbnail32BitData = FOUR_CHAR_CODE('it32')
-kThumbnail8BitMask = FOUR_CHAR_CODE('t8mk')
-kHuge1BitMask = FOUR_CHAR_CODE('ich#')
-kHuge4BitData = FOUR_CHAR_CODE('ich4')
-kHuge8BitData = FOUR_CHAR_CODE('ich8')
-kHuge32BitData = FOUR_CHAR_CODE('ih32')
-kHuge8BitMask = FOUR_CHAR_CODE('h8mk')
-kLarge1BitMask = FOUR_CHAR_CODE('ICN#')
-kLarge4BitData = FOUR_CHAR_CODE('icl4')
-kLarge8BitData = FOUR_CHAR_CODE('icl8')
-kLarge32BitData = FOUR_CHAR_CODE('il32')
-kLarge8BitMask = FOUR_CHAR_CODE('l8mk')
-kSmall1BitMask = FOUR_CHAR_CODE('ics#')
-kSmall4BitData = FOUR_CHAR_CODE('ics4')
-kSmall8BitData = FOUR_CHAR_CODE('ics8')
-kSmall32BitData = FOUR_CHAR_CODE('is32')
-kSmall8BitMask = FOUR_CHAR_CODE('s8mk')
-kMini1BitMask = FOUR_CHAR_CODE('icm#')
-kMini4BitData = FOUR_CHAR_CODE('icm4')
-kMini8BitData = FOUR_CHAR_CODE('icm8')
-kTileIconVariant = FOUR_CHAR_CODE('tile')
-kRolloverIconVariant = FOUR_CHAR_CODE('over')
-kDropIconVariant = FOUR_CHAR_CODE('drop')
-kOpenIconVariant = FOUR_CHAR_CODE('open')
-kOpenDropIconVariant = FOUR_CHAR_CODE('odrp')
-large1BitMask = kLarge1BitMask
-large4BitData = kLarge4BitData
-large8BitData = kLarge8BitData
-small1BitMask = kSmall1BitMask
-small4BitData = kSmall4BitData
-small8BitData = kSmall8BitData
-mini1BitMask = kMini1BitMask
-mini4BitData = kMini4BitData
-mini8BitData = kMini8BitData
-kAlignNone = 0x00
-kAlignVerticalCenter = 0x01
-kAlignTop = 0x02
-kAlignBottom = 0x03
-kAlignHorizontalCenter = 0x04
-kAlignAbsoluteCenter = kAlignVerticalCenter | kAlignHorizontalCenter
-kAlignCenterTop = kAlignTop | kAlignHorizontalCenter
-kAlignCenterBottom = kAlignBottom | kAlignHorizontalCenter
-kAlignLeft = 0x08
-kAlignCenterLeft = kAlignVerticalCenter | kAlignLeft
-kAlignTopLeft = kAlignTop | kAlignLeft
-kAlignBottomLeft = kAlignBottom | kAlignLeft
-kAlignRight = 0x0C
-kAlignCenterRight = kAlignVerticalCenter | kAlignRight
-kAlignTopRight = kAlignTop | kAlignRight
-kAlignBottomRight = kAlignBottom | kAlignRight
-atNone = kAlignNone
-atVerticalCenter = kAlignVerticalCenter
-atTop = kAlignTop
-atBottom = kAlignBottom
-atHorizontalCenter = kAlignHorizontalCenter
-atAbsoluteCenter = kAlignAbsoluteCenter
-atCenterTop = kAlignCenterTop
-atCenterBottom = kAlignCenterBottom
-atLeft = kAlignLeft
-atCenterLeft = kAlignCenterLeft
-atTopLeft = kAlignTopLeft
-atBottomLeft = kAlignBottomLeft
-atRight = kAlignRight
-atCenterRight = kAlignCenterRight
-atTopRight = kAlignTopRight
-atBottomRight = kAlignBottomRight
-kTransformNone = 0x00
-kTransformDisabled = 0x01
-kTransformOffline = 0x02
-kTransformOpen = 0x03
-kTransformLabel1 = 0x0100
-kTransformLabel2 = 0x0200
-kTransformLabel3 = 0x0300
-kTransformLabel4 = 0x0400
-kTransformLabel5 = 0x0500
-kTransformLabel6 = 0x0600
-kTransformLabel7 = 0x0700
-kTransformSelected = 0x4000
-kTransformSelectedDisabled = kTransformSelected | kTransformDisabled
-kTransformSelectedOffline = kTransformSelected | kTransformOffline
-kTransformSelectedOpen = kTransformSelected | kTransformOpen
-ttNone = kTransformNone
-ttDisabled = kTransformDisabled
-ttOffline = kTransformOffline
-ttOpen = kTransformOpen
-ttLabel1 = kTransformLabel1
-ttLabel2 = kTransformLabel2
-ttLabel3 = kTransformLabel3
-ttLabel4 = kTransformLabel4
-ttLabel5 = kTransformLabel5
-ttLabel6 = kTransformLabel6
-ttLabel7 = kTransformLabel7
-ttSelected = kTransformSelected
-ttSelectedDisabled = kTransformSelectedDisabled
-ttSelectedOffline = kTransformSelectedOffline
-ttSelectedOpen = kTransformSelectedOpen
-kSelectorLarge1Bit = 0x00000001
-kSelectorLarge4Bit = 0x00000002
-kSelectorLarge8Bit = 0x00000004
-kSelectorLarge32Bit = 0x00000008
-kSelectorLarge8BitMask = 0x00000010
-kSelectorSmall1Bit = 0x00000100
-kSelectorSmall4Bit = 0x00000200
-kSelectorSmall8Bit = 0x00000400
-kSelectorSmall32Bit = 0x00000800
-kSelectorSmall8BitMask = 0x00001000
-kSelectorMini1Bit = 0x00010000
-kSelectorMini4Bit = 0x00020000
-kSelectorMini8Bit = 0x00040000
-kSelectorHuge1Bit = 0x01000000
-kSelectorHuge4Bit = 0x02000000
-kSelectorHuge8Bit = 0x04000000
-kSelectorHuge32Bit = 0x08000000
-kSelectorHuge8BitMask = 0x10000000
-kSelectorAllLargeData = 0x000000FF
-kSelectorAllSmallData = 0x0000FF00
-kSelectorAllMiniData = 0x00FF0000
-# kSelectorAllHugeData = (long)0xFF000000
-kSelectorAll1BitData = kSelectorLarge1Bit | kSelectorSmall1Bit | kSelectorMini1Bit | kSelectorHuge1Bit
-kSelectorAll4BitData = kSelectorLarge4Bit | kSelectorSmall4Bit | kSelectorMini4Bit | kSelectorHuge4Bit
-kSelectorAll8BitData = kSelectorLarge8Bit | kSelectorSmall8Bit | kSelectorMini8Bit | kSelectorHuge8Bit
-kSelectorAll32BitData = kSelectorLarge32Bit | kSelectorSmall32Bit | kSelectorHuge32Bit
-# kSelectorAllAvailableData = (long)0xFFFFFFFF
-svLarge1Bit = kSelectorLarge1Bit
-svLarge4Bit = kSelectorLarge4Bit
-svLarge8Bit = kSelectorLarge8Bit
-svSmall1Bit = kSelectorSmall1Bit
-svSmall4Bit = kSelectorSmall4Bit
-svSmall8Bit = kSelectorSmall8Bit
-svMini1Bit = kSelectorMini1Bit
-svMini4Bit = kSelectorMini4Bit
-svMini8Bit = kSelectorMini8Bit
-svAllLargeData = kSelectorAllLargeData
-svAllSmallData = kSelectorAllSmallData
-svAllMiniData = kSelectorAllMiniData
-svAll1BitData = kSelectorAll1BitData
-svAll4BitData = kSelectorAll4BitData
-svAll8BitData = kSelectorAll8BitData
-# svAllAvailableData = kSelectorAllAvailableData
-kSystemIconsCreator = FOUR_CHAR_CODE('macs')
-# err = GetIconRef(kOnSystemDisk
-kClipboardIcon = FOUR_CHAR_CODE('CLIP')
-kClippingUnknownTypeIcon = FOUR_CHAR_CODE('clpu')
-kClippingPictureTypeIcon = FOUR_CHAR_CODE('clpp')
-kClippingTextTypeIcon = FOUR_CHAR_CODE('clpt')
-kClippingSoundTypeIcon = FOUR_CHAR_CODE('clps')
-kDesktopIcon = FOUR_CHAR_CODE('desk')
-kFinderIcon = FOUR_CHAR_CODE('FNDR')
-kFontSuitcaseIcon = FOUR_CHAR_CODE('FFIL')
-kFullTrashIcon = FOUR_CHAR_CODE('ftrh')
-kGenericApplicationIcon = FOUR_CHAR_CODE('APPL')
-kGenericCDROMIcon = FOUR_CHAR_CODE('cddr')
-kGenericControlPanelIcon = FOUR_CHAR_CODE('APPC')
-kGenericControlStripModuleIcon = FOUR_CHAR_CODE('sdev')
-kGenericComponentIcon = FOUR_CHAR_CODE('thng')
-kGenericDeskAccessoryIcon = FOUR_CHAR_CODE('APPD')
-kGenericDocumentIcon = FOUR_CHAR_CODE('docu')
-kGenericEditionFileIcon = FOUR_CHAR_CODE('edtf')
-kGenericExtensionIcon = FOUR_CHAR_CODE('INIT')
-kGenericFileServerIcon = FOUR_CHAR_CODE('srvr')
-kGenericFontIcon = FOUR_CHAR_CODE('ffil')
-kGenericFontScalerIcon = FOUR_CHAR_CODE('sclr')
-kGenericFloppyIcon = FOUR_CHAR_CODE('flpy')
-kGenericHardDiskIcon = FOUR_CHAR_CODE('hdsk')
-kGenericIDiskIcon = FOUR_CHAR_CODE('idsk')
-kGenericRemovableMediaIcon = FOUR_CHAR_CODE('rmov')
-kGenericMoverObjectIcon = FOUR_CHAR_CODE('movr')
-kGenericPCCardIcon = FOUR_CHAR_CODE('pcmc')
-kGenericPreferencesIcon = FOUR_CHAR_CODE('pref')
-kGenericQueryDocumentIcon = FOUR_CHAR_CODE('qery')
-kGenericRAMDiskIcon = FOUR_CHAR_CODE('ramd')
-kGenericSharedLibaryIcon = FOUR_CHAR_CODE('shlb')
-kGenericStationeryIcon = FOUR_CHAR_CODE('sdoc')
-kGenericSuitcaseIcon = FOUR_CHAR_CODE('suit')
-kGenericURLIcon = FOUR_CHAR_CODE('gurl')
-kGenericWORMIcon = FOUR_CHAR_CODE('worm')
-kInternationalResourcesIcon = FOUR_CHAR_CODE('ifil')
-kKeyboardLayoutIcon = FOUR_CHAR_CODE('kfil')
-kSoundFileIcon = FOUR_CHAR_CODE('sfil')
-kSystemSuitcaseIcon = FOUR_CHAR_CODE('zsys')
-kTrashIcon = FOUR_CHAR_CODE('trsh')
-kTrueTypeFontIcon = FOUR_CHAR_CODE('tfil')
-kTrueTypeFlatFontIcon = FOUR_CHAR_CODE('sfnt')
-kTrueTypeMultiFlatFontIcon = FOUR_CHAR_CODE('ttcf')
-kUserIDiskIcon = FOUR_CHAR_CODE('udsk')
-kInternationResourcesIcon = kInternationalResourcesIcon
-kInternetLocationHTTPIcon = FOUR_CHAR_CODE('ilht')
-kInternetLocationFTPIcon = FOUR_CHAR_CODE('ilft')
-kInternetLocationAppleShareIcon = FOUR_CHAR_CODE('ilaf')
-kInternetLocationAppleTalkZoneIcon = FOUR_CHAR_CODE('ilat')
-kInternetLocationFileIcon = FOUR_CHAR_CODE('ilfi')
-kInternetLocationMailIcon = FOUR_CHAR_CODE('ilma')
-kInternetLocationNewsIcon = FOUR_CHAR_CODE('ilnw')
-kInternetLocationNSLNeighborhoodIcon = FOUR_CHAR_CODE('ilns')
-kInternetLocationGenericIcon = FOUR_CHAR_CODE('ilge')
-kGenericFolderIcon = FOUR_CHAR_CODE('fldr')
-kDropFolderIcon = FOUR_CHAR_CODE('dbox')
-kMountedFolderIcon = FOUR_CHAR_CODE('mntd')
-kOpenFolderIcon = FOUR_CHAR_CODE('ofld')
-kOwnedFolderIcon = FOUR_CHAR_CODE('ownd')
-kPrivateFolderIcon = FOUR_CHAR_CODE('prvf')
-kSharedFolderIcon = FOUR_CHAR_CODE('shfl')
-kSharingPrivsNotApplicableIcon = FOUR_CHAR_CODE('shna')
-kSharingPrivsReadOnlyIcon = FOUR_CHAR_CODE('shro')
-kSharingPrivsReadWriteIcon = FOUR_CHAR_CODE('shrw')
-kSharingPrivsUnknownIcon = FOUR_CHAR_CODE('shuk')
-kSharingPrivsWritableIcon = FOUR_CHAR_CODE('writ')
-kUserFolderIcon = FOUR_CHAR_CODE('ufld')
-kWorkgroupFolderIcon = FOUR_CHAR_CODE('wfld')
-kGuestUserIcon = FOUR_CHAR_CODE('gusr')
-kUserIcon = FOUR_CHAR_CODE('user')
-kOwnerIcon = FOUR_CHAR_CODE('susr')
-kGroupIcon = FOUR_CHAR_CODE('grup')
-kAppearanceFolderIcon = FOUR_CHAR_CODE('appr')
-kAppleExtrasFolderIcon = FOUR_CHAR_CODE('aex\xc4')
-kAppleMenuFolderIcon = FOUR_CHAR_CODE('amnu')
-kApplicationsFolderIcon = FOUR_CHAR_CODE('apps')
-kApplicationSupportFolderIcon = FOUR_CHAR_CODE('asup')
-kAssistantsFolderIcon = FOUR_CHAR_CODE('ast\xc4')
-kColorSyncFolderIcon = FOUR_CHAR_CODE('prof')
-kContextualMenuItemsFolderIcon = FOUR_CHAR_CODE('cmnu')
-kControlPanelDisabledFolderIcon = FOUR_CHAR_CODE('ctrD')
-kControlPanelFolderIcon = FOUR_CHAR_CODE('ctrl')
-kControlStripModulesFolderIcon = FOUR_CHAR_CODE('sdv\xc4')
-kDocumentsFolderIcon = FOUR_CHAR_CODE('docs')
-kExtensionsDisabledFolderIcon = FOUR_CHAR_CODE('extD')
-kExtensionsFolderIcon = FOUR_CHAR_CODE('extn')
-kFavoritesFolderIcon = FOUR_CHAR_CODE('favs')
-kFontsFolderIcon = FOUR_CHAR_CODE('font')
-kHelpFolderIcon = FOUR_CHAR_CODE('\xc4hlp')
-kInternetFolderIcon = FOUR_CHAR_CODE('int\xc4')
-kInternetPlugInFolderIcon = FOUR_CHAR_CODE('\xc4net')
-kInternetSearchSitesFolderIcon = FOUR_CHAR_CODE('issf')
-kLocalesFolderIcon = FOUR_CHAR_CODE('\xc4loc')
-kMacOSReadMeFolderIcon = FOUR_CHAR_CODE('mor\xc4')
-kPublicFolderIcon = FOUR_CHAR_CODE('pubf')
-kPreferencesFolderIcon = FOUR_CHAR_CODE('prf\xc4')
-kPrinterDescriptionFolderIcon = FOUR_CHAR_CODE('ppdf')
-kPrinterDriverFolderIcon = FOUR_CHAR_CODE('\xc4prd')
-kPrintMonitorFolderIcon = FOUR_CHAR_CODE('prnt')
-kRecentApplicationsFolderIcon = FOUR_CHAR_CODE('rapp')
-kRecentDocumentsFolderIcon = FOUR_CHAR_CODE('rdoc')
-kRecentServersFolderIcon = FOUR_CHAR_CODE('rsrv')
-kScriptingAdditionsFolderIcon = FOUR_CHAR_CODE('\xc4scr')
-kSharedLibrariesFolderIcon = FOUR_CHAR_CODE('\xc4lib')
-kScriptsFolderIcon = FOUR_CHAR_CODE('scr\xc4')
-kShutdownItemsDisabledFolderIcon = FOUR_CHAR_CODE('shdD')
-kShutdownItemsFolderIcon = FOUR_CHAR_CODE('shdf')
-kSpeakableItemsFolder = FOUR_CHAR_CODE('spki')
-kStartupItemsDisabledFolderIcon = FOUR_CHAR_CODE('strD')
-kStartupItemsFolderIcon = FOUR_CHAR_CODE('strt')
-kSystemExtensionDisabledFolderIcon = FOUR_CHAR_CODE('macD')
-kSystemFolderIcon = FOUR_CHAR_CODE('macs')
-kTextEncodingsFolderIcon = FOUR_CHAR_CODE('\xc4tex')
-kUsersFolderIcon = FOUR_CHAR_CODE('usr\xc4')
-kUtilitiesFolderIcon = FOUR_CHAR_CODE('uti\xc4')
-kVoicesFolderIcon = FOUR_CHAR_CODE('fvoc')
-kSystemFolderXIcon = FOUR_CHAR_CODE('macx')
-kAppleScriptBadgeIcon = FOUR_CHAR_CODE('scrp')
-kLockedBadgeIcon = FOUR_CHAR_CODE('lbdg')
-kMountedBadgeIcon = FOUR_CHAR_CODE('mbdg')
-kSharedBadgeIcon = FOUR_CHAR_CODE('sbdg')
-kAliasBadgeIcon = FOUR_CHAR_CODE('abdg')
-kAlertCautionBadgeIcon = FOUR_CHAR_CODE('cbdg')
-kAlertNoteIcon = FOUR_CHAR_CODE('note')
-kAlertCautionIcon = FOUR_CHAR_CODE('caut')
-kAlertStopIcon = FOUR_CHAR_CODE('stop')
-kAppleTalkIcon = FOUR_CHAR_CODE('atlk')
-kAppleTalkZoneIcon = FOUR_CHAR_CODE('atzn')
-kAFPServerIcon = FOUR_CHAR_CODE('afps')
-kFTPServerIcon = FOUR_CHAR_CODE('ftps')
-kHTTPServerIcon = FOUR_CHAR_CODE('htps')
-kGenericNetworkIcon = FOUR_CHAR_CODE('gnet')
-kIPFileServerIcon = FOUR_CHAR_CODE('isrv')
-kToolbarCustomizeIcon = FOUR_CHAR_CODE('tcus')
-kToolbarDeleteIcon = FOUR_CHAR_CODE('tdel')
-kToolbarFavoritesIcon = FOUR_CHAR_CODE('tfav')
-kToolbarHomeIcon = FOUR_CHAR_CODE('thom')
-kAppleLogoIcon = FOUR_CHAR_CODE('capl')
-kAppleMenuIcon = FOUR_CHAR_CODE('sapl')
-kBackwardArrowIcon = FOUR_CHAR_CODE('baro')
-kFavoriteItemsIcon = FOUR_CHAR_CODE('favr')
-kForwardArrowIcon = FOUR_CHAR_CODE('faro')
-kGridIcon = FOUR_CHAR_CODE('grid')
-kHelpIcon = FOUR_CHAR_CODE('help')
-kKeepArrangedIcon = FOUR_CHAR_CODE('arng')
-kLockedIcon = FOUR_CHAR_CODE('lock')
-kNoFilesIcon = FOUR_CHAR_CODE('nfil')
-kNoFolderIcon = FOUR_CHAR_CODE('nfld')
-kNoWriteIcon = FOUR_CHAR_CODE('nwrt')
-kProtectedApplicationFolderIcon = FOUR_CHAR_CODE('papp')
-kProtectedSystemFolderIcon = FOUR_CHAR_CODE('psys')
-kRecentItemsIcon = FOUR_CHAR_CODE('rcnt')
-kShortcutIcon = FOUR_CHAR_CODE('shrt')
-kSortAscendingIcon = FOUR_CHAR_CODE('asnd')
-kSortDescendingIcon = FOUR_CHAR_CODE('dsnd')
-kUnlockedIcon = FOUR_CHAR_CODE('ulck')
-kConnectToIcon = FOUR_CHAR_CODE('cnct')
-kGenericWindowIcon = FOUR_CHAR_CODE('gwin')
-kQuestionMarkIcon = FOUR_CHAR_CODE('ques')
-kDeleteAliasIcon = FOUR_CHAR_CODE('dali')
-kEjectMediaIcon = FOUR_CHAR_CODE('ejec')
-kBurningIcon = FOUR_CHAR_CODE('burn')
-kRightContainerArrowIcon = FOUR_CHAR_CODE('rcar')
-kIconServicesNormalUsageFlag = 0
-kIconServicesCatalogInfoMask = (kFSCatInfoNodeID | kFSCatInfoParentDirID | kFSCatInfoVolume | kFSCatInfoNodeFlags | kFSCatInfoFinderInfo | kFSCatInfoFinderXInfo | kFSCatInfoUserAccess)
-kPlotIconRefNormalFlags = 0L
-kPlotIconRefNoImage = (1 << 1)
-kPlotIconRefNoMask = (1 << 2)
-kIconFamilyType = FOUR_CHAR_CODE('icns')
diff --git a/Lib/plat-mac/Carbon/Launch.py b/Lib/plat-mac/Carbon/Launch.py
deleted file mode 100644
index e553f8f4e5e..00000000000
--- a/Lib/plat-mac/Carbon/Launch.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Launch import *
diff --git a/Lib/plat-mac/Carbon/LaunchServices.py b/Lib/plat-mac/Carbon/LaunchServices.py
deleted file mode 100644
index daff4469338..00000000000
--- a/Lib/plat-mac/Carbon/LaunchServices.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# Generated from 'LaunchServices.h'
-
-def FOUR_CHAR_CODE(x): return x
-from Carbon.Files import *
-kLSRequestAllInfo = -1
-kLSRolesAll = -1
-kLSUnknownType = FOUR_CHAR_CODE('\0\0\0\0')
-kLSUnknownCreator = FOUR_CHAR_CODE('\0\0\0\0')
-kLSInvalidExtensionIndex = -1
-kLSUnknownErr = -10810
-kLSNotAnApplicationErr = -10811
-kLSNotInitializedErr = -10812
-kLSDataUnavailableErr = -10813
-kLSApplicationNotFoundErr = -10814
-kLSUnknownTypeErr = -10815
-kLSDataTooOldErr = -10816
-kLSDataErr = -10817
-kLSLaunchInProgressErr = -10818
-kLSNotRegisteredErr = -10819
-kLSAppDoesNotClaimTypeErr = -10820
-kLSAppDoesNotSupportSchemeWarning = -10821
-kLSServerCommunicationErr = -10822
-kLSCannotSetInfoErr = -10823
-kLSInitializeDefaults = 0x00000001
-kLSMinCatInfoBitmap = (kFSCatInfoNodeFlags | kFSCatInfoParentDirID | kFSCatInfoFinderInfo | kFSCatInfoFinderXInfo)
-# kLSInvalidExtensionIndex = (unsigned long)0xFFFFFFFF
-kLSRequestExtension = 0x00000001
-kLSRequestTypeCreator = 0x00000002
-kLSRequestBasicFlagsOnly = 0x00000004
-kLSRequestAppTypeFlags = 0x00000008
-kLSRequestAllFlags = 0x00000010
-kLSRequestIconAndKind = 0x00000020
-kLSRequestExtensionFlagsOnly = 0x00000040
-# kLSRequestAllInfo = (unsigned long)0xFFFFFFFF
-kLSItemInfoIsPlainFile = 0x00000001
-kLSItemInfoIsPackage = 0x00000002
-kLSItemInfoIsApplication = 0x00000004
-kLSItemInfoIsContainer = 0x00000008
-kLSItemInfoIsAliasFile = 0x00000010
-kLSItemInfoIsSymlink = 0x00000020
-kLSItemInfoIsInvisible = 0x00000040
-kLSItemInfoIsNativeApp = 0x00000080
-kLSItemInfoIsClassicApp = 0x00000100
-kLSItemInfoAppPrefersNative = 0x00000200
-kLSItemInfoAppPrefersClassic = 0x00000400
-kLSItemInfoAppIsScriptable = 0x00000800
-kLSItemInfoIsVolume = 0x00001000
-kLSItemInfoExtensionIsHidden = 0x00100000
-kLSRolesNone = 0x00000001
-kLSRolesViewer = 0x00000002
-kLSRolesEditor = 0x00000004
-# kLSRolesAll = (unsigned long)0xFFFFFFFF
-kLSUnknownKindID = 0
-# kLSUnknownType = 0
-# kLSUnknownCreator = 0
-kLSAcceptDefault = 0x00000001
-kLSAcceptAllowLoginUI = 0x00000002
-kLSLaunchDefaults = 0x00000001
-kLSLaunchAndPrint = 0x00000002
-kLSLaunchReserved2 = 0x00000004
-kLSLaunchReserved3 = 0x00000008
-kLSLaunchReserved4 = 0x00000010
-kLSLaunchReserved5 = 0x00000020
-kLSLaunchReserved6 = 0x00000040
-kLSLaunchInhibitBGOnly = 0x00000080
-kLSLaunchDontAddToRecents = 0x00000100
-kLSLaunchDontSwitch = 0x00000200
-kLSLaunchNoParams = 0x00000800
-kLSLaunchAsync = 0x00010000
-kLSLaunchStartClassic = 0x00020000
-kLSLaunchInClassic = 0x00040000
-kLSLaunchNewInstance = 0x00080000
-kLSLaunchAndHide = 0x00100000
-kLSLaunchAndHideOthers = 0x00200000
diff --git a/Lib/plat-mac/Carbon/List.py b/Lib/plat-mac/Carbon/List.py
deleted file mode 100644
index b0d6e2273a6..00000000000
--- a/Lib/plat-mac/Carbon/List.py
+++ /dev/null
@@ -1 +0,0 @@
-from _List import *
diff --git a/Lib/plat-mac/Carbon/Lists.py b/Lib/plat-mac/Carbon/Lists.py
deleted file mode 100644
index 723294c6147..00000000000
--- a/Lib/plat-mac/Carbon/Lists.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from 'Lists.h'
-
-def FOUR_CHAR_CODE(x): return x
-listNotifyNothing = FOUR_CHAR_CODE('nada')
-listNotifyClick = FOUR_CHAR_CODE('clik')
-listNotifyDoubleClick = FOUR_CHAR_CODE('dblc')
-listNotifyPreClick = FOUR_CHAR_CODE('pclk')
-lDrawingModeOffBit = 3
-lDoVAutoscrollBit = 1
-lDoHAutoscrollBit = 0
-lDrawingModeOff = 8
-lDoVAutoscroll = 2
-lDoHAutoscroll = 1
-lOnlyOneBit = 7
-lExtendDragBit = 6
-lNoDisjointBit = 5
-lNoExtendBit = 4
-lNoRectBit = 3
-lUseSenseBit = 2
-lNoNilHiliteBit = 1
-lOnlyOne = -128
-lExtendDrag = 64
-lNoDisjoint = 32
-lNoExtend = 16
-lNoRect = 8
-lUseSense = 4
-lNoNilHilite = 2
-lInitMsg = 0
-lDrawMsg = 1
-lHiliteMsg = 2
-lCloseMsg = 3
-kListDefProcPtr = 0
-kListDefUserProcType = kListDefProcPtr
-kListDefStandardTextType = 1
-kListDefStandardIconType = 2
diff --git a/Lib/plat-mac/Carbon/MacHelp.py b/Lib/plat-mac/Carbon/MacHelp.py
deleted file mode 100644
index 06b9912bfcf..00000000000
--- a/Lib/plat-mac/Carbon/MacHelp.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Generated from 'MacHelp.h'
-
-def FOUR_CHAR_CODE(x): return x
-kMacHelpVersion = 0x0003
-kHMSupplyContent = 0
-kHMDisposeContent = 1
-kHMNoContent = FOUR_CHAR_CODE('none')
-kHMCFStringContent = FOUR_CHAR_CODE('cfst')
-kHMPascalStrContent = FOUR_CHAR_CODE('pstr')
-kHMStringResContent = FOUR_CHAR_CODE('str#')
-kHMTEHandleContent = FOUR_CHAR_CODE('txth')
-kHMTextResContent = FOUR_CHAR_CODE('text')
-kHMStrResContent = FOUR_CHAR_CODE('str ')
-kHMDefaultSide = 0
-kHMOutsideTopScriptAligned = 1
-kHMOutsideLeftCenterAligned = 2
-kHMOutsideBottomScriptAligned = 3
-kHMOutsideRightCenterAligned = 4
-kHMOutsideTopLeftAligned = 5
-kHMOutsideTopRightAligned = 6
-kHMOutsideLeftTopAligned = 7
-kHMOutsideLeftBottomAligned = 8
-kHMOutsideBottomLeftAligned = 9
-kHMOutsideBottomRightAligned = 10
-kHMOutsideRightTopAligned = 11
-kHMOutsideRightBottomAligned = 12
-kHMOutsideTopCenterAligned = 13
-kHMOutsideBottomCenterAligned = 14
-kHMInsideRightCenterAligned = 15
-kHMInsideLeftCenterAligned = 16
-kHMInsideBottomCenterAligned = 17
-kHMInsideTopCenterAligned = 18
-kHMInsideTopLeftCorner = 19
-kHMInsideTopRightCorner = 20
-kHMInsideBottomLeftCorner = 21
-kHMInsideBottomRightCorner = 22
-kHMAbsoluteCenterAligned = 23
-kHMTopSide = kHMOutsideTopScriptAligned
-kHMLeftSide = kHMOutsideLeftCenterAligned
-kHMBottomSide = kHMOutsideBottomScriptAligned
-kHMRightSide = kHMOutsideRightCenterAligned
-kHMTopLeftCorner = kHMOutsideTopLeftAligned
-kHMTopRightCorner = kHMOutsideTopRightAligned
-kHMLeftTopCorner = kHMOutsideLeftTopAligned
-kHMLeftBottomCorner = kHMOutsideLeftBottomAligned
-kHMBottomLeftCorner = kHMOutsideBottomLeftAligned
-kHMBottomRightCorner = kHMOutsideBottomRightAligned
-kHMRightTopCorner = kHMOutsideRightTopAligned
-kHMRightBottomCorner = kHMOutsideRightBottomAligned
-kHMContentProvided = 0
-kHMContentNotProvided = 1
-kHMContentNotProvidedDontPropagate = 2
-kHMMinimumContentIndex = 0
-kHMMaximumContentIndex = 1
-errHMIllegalContentForMinimumState = -10980
-errHMIllegalContentForMaximumState = -10981
-kHMIllegalContentForMinimumState = errHMIllegalContentForMinimumState
-kHelpTagEventHandlerTag = FOUR_CHAR_CODE('hevt')
diff --git a/Lib/plat-mac/Carbon/MacTextEditor.py b/Lib/plat-mac/Carbon/MacTextEditor.py
deleted file mode 100644
index 4609d8db896..00000000000
--- a/Lib/plat-mac/Carbon/MacTextEditor.py
+++ /dev/null
@@ -1,226 +0,0 @@
-# Generated from 'MacTextEditor.h'
-
-
-def FOUR_CHAR_CODE(x): return x
-false = 0
-true = 1
-kTXNClearThisControl = 0xFFFFFFFF
-kTXNClearTheseFontFeatures = 0x80000000
-kTXNDontCareTypeSize = 0xFFFFFFFF
-kTXNDecrementTypeSize = 0x80000000
-kTXNUseCurrentSelection = 0xFFFFFFFF
-kTXNStartOffset = 0
-kTXNEndOffset = 0x7FFFFFFF
-MovieFileType = FOUR_CHAR_CODE('moov')
-kTXNUseEncodingWordRulesMask = 0x80000000
-kTXNFontSizeAttributeSize = 4
-normal = 0
-kTXNWillDefaultToATSUIBit = 0
-kTXNWillDefaultToCarbonEventBit = 1
-kTXNWillDefaultToATSUIMask = 1L << kTXNWillDefaultToATSUIBit
-kTXNWillDefaultToCarbonEventMask = 1L << kTXNWillDefaultToCarbonEventBit
-kTXNWantMoviesBit = 0
-kTXNWantSoundBit = 1
-kTXNWantGraphicsBit = 2
-kTXNAlwaysUseQuickDrawTextBit = 3
-kTXNUseTemporaryMemoryBit = 4
-kTXNWantMoviesMask = 1L << kTXNWantMoviesBit
-kTXNWantSoundMask = 1L << kTXNWantSoundBit
-kTXNWantGraphicsMask = 1L << kTXNWantGraphicsBit
-kTXNAlwaysUseQuickDrawTextMask = 1L << kTXNAlwaysUseQuickDrawTextBit
-kTXNUseTemporaryMemoryMask = 1L << kTXNUseTemporaryMemoryBit
-kTXNDrawGrowIconBit = 0
-kTXNShowWindowBit = 1
-kTXNWantHScrollBarBit = 2
-kTXNWantVScrollBarBit = 3
-kTXNNoTSMEverBit = 4
-kTXNReadOnlyBit = 5
-kTXNNoKeyboardSyncBit = 6
-kTXNNoSelectionBit = 7
-kTXNSaveStylesAsSTYLResourceBit = 8
-kOutputTextInUnicodeEncodingBit = 9
-kTXNDoNotInstallDragProcsBit = 10
-kTXNAlwaysWrapAtViewEdgeBit = 11
-kTXNDontDrawCaretWhenInactiveBit = 12
-kTXNDontDrawSelectionWhenInactiveBit = 13
-kTXNSingleLineOnlyBit = 14
-kTXNDisableDragAndDropBit = 15
-kTXNUseQDforImagingBit = 16
-kTXNDrawGrowIconMask = 1L << kTXNDrawGrowIconBit
-kTXNShowWindowMask = 1L << kTXNShowWindowBit
-kTXNWantHScrollBarMask = 1L << kTXNWantHScrollBarBit
-kTXNWantVScrollBarMask = 1L << kTXNWantVScrollBarBit
-kTXNNoTSMEverMask = 1L << kTXNNoTSMEverBit
-kTXNReadOnlyMask = 1L << kTXNReadOnlyBit
-kTXNNoKeyboardSyncMask = 1L << kTXNNoKeyboardSyncBit
-kTXNNoSelectionMask = 1L << kTXNNoSelectionBit
-kTXNSaveStylesAsSTYLResourceMask = 1L << kTXNSaveStylesAsSTYLResourceBit
-kOutputTextInUnicodeEncodingMask = 1L << kOutputTextInUnicodeEncodingBit
-kTXNDoNotInstallDragProcsMask = 1L << kTXNDoNotInstallDragProcsBit
-kTXNAlwaysWrapAtViewEdgeMask = 1L << kTXNAlwaysWrapAtViewEdgeBit
-kTXNDontDrawCaretWhenInactiveMask = 1L << kTXNDontDrawCaretWhenInactiveBit
-kTXNDontDrawSelectionWhenInactiveMask = 1L << kTXNDontDrawSelectionWhenInactiveBit
-kTXNSingleLineOnlyMask = 1L << kTXNSingleLineOnlyBit
-kTXNDisableDragAndDropMask = 1L << kTXNDisableDragAndDropBit
-kTXNUseQDforImagingMask = 1L << kTXNUseQDforImagingBit
-kTXNSetFlushnessBit = 0
-kTXNSetJustificationBit = 1
-kTXNUseFontFallBackBit = 2
-kTXNRotateTextBit = 3
-kTXNUseVerticalTextBit = 4
-kTXNDontUpdateBoxRectBit = 5
-kTXNDontDrawTextBit = 6
-kTXNUseCGContextRefBit = 7
-kTXNImageWithQDBit = 8
-kTXNDontWrapTextBit = 9
-kTXNSetFlushnessMask = 1L << kTXNSetFlushnessBit
-kTXNSetJustificationMask = 1L << kTXNSetJustificationBit
-kTXNUseFontFallBackMask = 1L << kTXNUseFontFallBackBit
-kTXNRotateTextMask = 1L << kTXNRotateTextBit
-kTXNUseVerticalTextMask = 1L << kTXNUseVerticalTextBit
-kTXNDontUpdateBoxRectMask = 1L << kTXNDontUpdateBoxRectBit
-kTXNDontDrawTextMask = 1L << kTXNDontDrawTextBit
-kTXNUseCGContextRefMask = 1L << kTXNUseCGContextRefBit
-kTXNImageWithQDMask = 1L << kTXNImageWithQDBit
-kTXNDontWrapTextMask = 1L << kTXNDontWrapTextBit
-kTXNFontContinuousBit = 0
-kTXNSizeContinuousBit = 1
-kTXNStyleContinuousBit = 2
-kTXNColorContinuousBit = 3
-kTXNFontContinuousMask = 1L << kTXNFontContinuousBit
-kTXNSizeContinuousMask = 1L << kTXNSizeContinuousBit
-kTXNStyleContinuousMask = 1L << kTXNStyleContinuousBit
-kTXNColorContinuousMask = 1L << kTXNColorContinuousBit
-kTXNIgnoreCaseBit = 0
-kTXNEntireWordBit = 1
-kTXNUseEncodingWordRulesBit = 31
-kTXNIgnoreCaseMask = 1L << kTXNIgnoreCaseBit
-kTXNEntireWordMask = 1L << kTXNEntireWordBit
-# kTXNUseEncodingWordRulesMask = (unsigned long)(1L << kTXNUseEncodingWordRulesBit)
-kTXNTextensionFile = FOUR_CHAR_CODE('txtn')
-kTXNTextFile = FOUR_CHAR_CODE('TEXT')
-kTXNPictureFile = FOUR_CHAR_CODE('PICT')
-kTXNMovieFile = FOUR_CHAR_CODE('MooV')
-kTXNSoundFile = FOUR_CHAR_CODE('sfil')
-kTXNAIFFFile = FOUR_CHAR_CODE('AIFF')
-kTXNUnicodeTextFile = FOUR_CHAR_CODE('utxt')
-kTXNTextEditStyleFrameType = 1
-kTXNPageFrameType = 2
-kTXNMultipleFrameType = 3
-kTXNTextData = FOUR_CHAR_CODE('TEXT')
-kTXNPictureData = FOUR_CHAR_CODE('PICT')
-kTXNMovieData = FOUR_CHAR_CODE('moov')
-kTXNSoundData = FOUR_CHAR_CODE('snd ')
-kTXNUnicodeTextData = FOUR_CHAR_CODE('utxt')
-kTXNLineDirectionTag = FOUR_CHAR_CODE('lndr')
-kTXNJustificationTag = FOUR_CHAR_CODE('just')
-kTXNIOPrivilegesTag = FOUR_CHAR_CODE('iopv')
-kTXNSelectionStateTag = FOUR_CHAR_CODE('slst')
-kTXNInlineStateTag = FOUR_CHAR_CODE('inst')
-kTXNWordWrapStateTag = FOUR_CHAR_CODE('wwrs')
-kTXNKeyboardSyncStateTag = FOUR_CHAR_CODE('kbsy')
-kTXNAutoIndentStateTag = FOUR_CHAR_CODE('auin')
-kTXNTabSettingsTag = FOUR_CHAR_CODE('tabs')
-kTXNRefConTag = FOUR_CHAR_CODE('rfcn')
-kTXNMarginsTag = FOUR_CHAR_CODE('marg')
-kTXNFlattenMoviesTag = FOUR_CHAR_CODE('flat')
-kTXNDoFontSubstitution = FOUR_CHAR_CODE('fSub')
-kTXNNoUserIOTag = FOUR_CHAR_CODE('nuio')
-kTXNUseCarbonEvents = FOUR_CHAR_CODE('cbcb')
-kTXNDrawCaretWhenInactiveTag = FOUR_CHAR_CODE('dcrt')
-kTXNDrawSelectionWhenInactiveTag = FOUR_CHAR_CODE('dsln')
-kTXNDisableDragAndDropTag = FOUR_CHAR_CODE('drag')
-kTXNTypingAction = 0
-kTXNCutAction = 1
-kTXNPasteAction = 2
-kTXNClearAction = 3
-kTXNChangeFontAction = 4
-kTXNChangeFontColorAction = 5
-kTXNChangeFontSizeAction = 6
-kTXNChangeStyleAction = 7
-kTXNAlignLeftAction = 8
-kTXNAlignCenterAction = 9
-kTXNAlignRightAction = 10
-kTXNDropAction = 11
-kTXNMoveAction = 12
-kTXNFontFeatureAction = 13
-kTXNFontVariationAction = 14
-kTXNUndoLastAction = 1024
-# kTXNClearThisControl = (long)0xFFFFFFFF
-# kTXNClearTheseFontFeatures = (long)0x80000000
-kTXNReadWrite = false
-kTXNReadOnly = true
-kTXNSelectionOn = true
-kTXNSelectionOff = false
-kTXNUseInline = false
-kTXNUseBottomline = true
-kTXNAutoWrap = false
-kTXNNoAutoWrap = true
-kTXNSyncKeyboard = false
-kTXNNoSyncKeyboard = true
-kTXNAutoIndentOff = false
-kTXNAutoIndentOn = true
-kTXNDontDrawCaretWhenInactive = false
-kTXNDrawCaretWhenInactive = true
-kTXNDontDrawSelectionWhenInactive = false
-kTXNDrawSelectionWhenInactive = true
-kTXNEnableDragAndDrop = false
-kTXNDisableDragAndDrop = true
-kTXNRightTab = -1
-kTXNLeftTab = 0
-kTXNCenterTab = 1
-kTXNLeftToRight = 0
-kTXNRightToLeft = 1
-kTXNFlushDefault = 0
-kTXNFlushLeft = 1
-kTXNFlushRight = 2
-kTXNCenter = 4
-kTXNFullJust = 8
-kTXNForceFullJust = 16
-kScrollBarsAlwaysActive = true
-kScrollBarsSyncWithFocus = false
-# kTXNDontCareTypeSize = (long)0xFFFFFFFF
-kTXNDontCareTypeStyle = 0xFF
-kTXNIncrementTypeSize = 0x00000001
-# kTXNDecrementTypeSize = (long)0x80000000
-kTXNUseScriptDefaultValue = -1
-kTXNNoFontVariations = 0x7FFF
-# kTXNUseCurrentSelection = (unsigned long)0xFFFFFFFF
-# kTXNStartOffset = 0
-# kTXNEndOffset = 0x7FFFFFFF
-kTXNSingleStylePerTextDocumentResType = FOUR_CHAR_CODE('MPSR')
-kTXNMultipleStylesPerTextDocumentResType = FOUR_CHAR_CODE('styl')
-kTXNShowStart = false
-kTXNShowEnd = true
-kTXNDefaultFontName = 0
-kTXNDefaultFontSize = 0x000C0000
-kTXNDefaultFontStyle = normal
-kTXNQDFontNameAttribute = FOUR_CHAR_CODE('fntn')
-kTXNQDFontFamilyIDAttribute = FOUR_CHAR_CODE('font')
-kTXNQDFontSizeAttribute = FOUR_CHAR_CODE('size')
-kTXNQDFontStyleAttribute = FOUR_CHAR_CODE('face')
-kTXNQDFontColorAttribute = FOUR_CHAR_CODE('klor')
-kTXNTextEncodingAttribute = FOUR_CHAR_CODE('encd')
-kTXNATSUIFontFeaturesAttribute = FOUR_CHAR_CODE('atfe')
-kTXNATSUIFontVariationsAttribute = FOUR_CHAR_CODE('atva')
-# kTXNQDFontNameAttributeSize = sizeof(Str255)
-# kTXNQDFontFamilyIDAttributeSize = sizeof(SInt16)
-# kTXNQDFontSizeAttributeSize = sizeof(SInt16)
-# kTXNQDFontStyleAttributeSize = sizeof(Style)
-# kTXNQDFontColorAttributeSize = sizeof(RGBColor)
-# kTXNTextEncodingAttributeSize = sizeof(TextEncoding)
-# kTXNFontSizeAttributeSize = sizeof(Fixed)
-kTXNSystemDefaultEncoding = 0
-kTXNMacOSEncoding = 1
-kTXNUnicodeEncoding = 2
-kTXNBackgroundTypeRGB = 1
-kTXNTextInputCountBit = 0
-kTXNRunCountBit = 1
-kTXNTextInputCountMask = 1L << kTXNTextInputCountBit
-kTXNRunCountMask = 1L << kTXNRunCountBit
-kTXNAllCountMask = kTXNTextInputCountMask | kTXNRunCountMask
-kTXNNoAppleEventHandlersBit = 0
-kTXNRestartAppleEventHandlersBit = 1
-kTXNNoAppleEventHandlersMask = 1 << kTXNNoAppleEventHandlersBit
-kTXNRestartAppleEventHandlersMask = 1 << kTXNRestartAppleEventHandlersBit
-# status = TXNInitTextension( &defaults
diff --git a/Lib/plat-mac/Carbon/MediaDescr.py b/Lib/plat-mac/Carbon/MediaDescr.py
deleted file mode 100644
index 5431d1e3e89..00000000000
--- a/Lib/plat-mac/Carbon/MediaDescr.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# Parsers/generators for QuickTime media descriptions
-import struct
-
-Error = 'MediaDescr.Error'
-
-class _MediaDescriptionCodec:
- def __init__(self, trunc, size, names, fmt):
- self.trunc = trunc
- self.size = size
- self.names = names
- self.fmt = fmt
-
- def decode(self, data):
- if self.trunc:
- data = data[:self.size]
- values = struct.unpack(self.fmt, data)
- if len(values) != len(self.names):
- raise Error, ('Format length does not match number of names')
- rv = {}
- for i in range(len(values)):
- name = self.names[i]
- value = values[i]
- if type(name) == type(()):
- name, cod, dec = name
- value = dec(value)
- rv[name] = value
- return rv
-
- def encode(self, dict):
- list = [self.fmt]
- for name in self.names:
- if type(name) == type(()):
- name, cod, dec = name
- else:
- cod = dec = None
- value = dict[name]
- if cod:
- value = cod(value)
- list.append(value)
- rv = struct.pack(*list)
- return rv
-
-# Helper functions
-def _tofixed(float):
- hi = int(float)
- lo = int(float*0x10000) & 0xffff
- return (hi<<16)|lo
-
-def _fromfixed(fixed):
- hi = (fixed >> 16) & 0xffff
- lo = (fixed & 0xffff)
- return hi + (lo / float(0x10000))
-
-def _tostr31(str):
- return chr(len(str)) + str + '\0'*(31-len(str))
-
-def _fromstr31(str31):
- return str31[1:1+ord(str31[0])]
-
-SampleDescription = _MediaDescriptionCodec(
- 1, # May be longer, truncate
- 16, # size
- ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex'), # Attributes
- "l4slhh" # Format
-)
-
-SoundDescription = _MediaDescriptionCodec(
- 1,
- 36,
- ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
- 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
- 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed)),
- "l4slhhhh4shhhhl" # Format
-)
-
-SoundDescriptionV1 = _MediaDescriptionCodec(
- 1,
- 52,
- ('descSize', 'dataFormat', 'resvd1', 'resvd2', 'dataRefIndex',
- 'version', 'revlevel', 'vendor', 'numChannels', 'sampleSize',
- 'compressionID', 'packetSize', ('sampleRate', _tofixed, _fromfixed), 'samplesPerPacket',
- 'bytesPerPacket', 'bytesPerFrame', 'bytesPerSample'),
- "l4slhhhh4shhhhlllll" # Format
-)
-
-ImageDescription = _MediaDescriptionCodec(
- 1, # May be longer, truncate
- 86, # size
- ('idSize', 'cType', 'resvd1', 'resvd2', 'dataRefIndex', 'version',
- 'revisionLevel', 'vendor', 'temporalQuality', 'spatialQuality',
- 'width', 'height', ('hRes', _tofixed, _fromfixed), ('vRes', _tofixed, _fromfixed),
- 'dataSize', 'frameCount', ('name', _tostr31, _fromstr31),
- 'depth', 'clutID'),
- 'l4slhhhh4sllhhlllh32shh',
-)
-
-# XXXX Others, like TextDescription and such, remain to be done.
diff --git a/Lib/plat-mac/Carbon/Menu.py b/Lib/plat-mac/Carbon/Menu.py
deleted file mode 100644
index 075cb9d8a40..00000000000
--- a/Lib/plat-mac/Carbon/Menu.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Menu import *
diff --git a/Lib/plat-mac/Carbon/Menus.py b/Lib/plat-mac/Carbon/Menus.py
deleted file mode 100644
index 01affb0968c..00000000000
--- a/Lib/plat-mac/Carbon/Menus.py
+++ /dev/null
@@ -1,169 +0,0 @@
-# Generated from 'Menus.h'
-
-def FOUR_CHAR_CODE(x): return x
-noMark = 0
-kMenuDrawMsg = 0
-kMenuSizeMsg = 2
-kMenuPopUpMsg = 3
-kMenuCalcItemMsg = 5
-kMenuThemeSavvyMsg = 7
-mDrawMsg = 0
-mSizeMsg = 2
-mPopUpMsg = 3
-mCalcItemMsg = 5
-mChooseMsg = 1
-mDrawItemMsg = 4
-kMenuChooseMsg = 1
-kMenuDrawItemMsg = 4
-kThemeSavvyMenuResponse = 0x7473
-kMenuInitMsg = 8
-kMenuDisposeMsg = 9
-kMenuFindItemMsg = 10
-kMenuHiliteItemMsg = 11
-kMenuDrawItemsMsg = 12
-textMenuProc = 0
-hMenuCmd = 27
-hierMenu = -1
-kInsertHierarchicalMenu = -1
-mctAllItems = -98
-mctLastIDIndic = -99
-kMenuStdMenuProc = 63
-kMenuStdMenuBarProc = 63
-kMenuNoModifiers = 0
-kMenuShiftModifier = (1 << 0)
-kMenuOptionModifier = (1 << 1)
-kMenuControlModifier = (1 << 2)
-kMenuNoCommandModifier = (1 << 3)
-kMenuNoIcon = 0
-kMenuIconType = 1
-kMenuShrinkIconType = 2
-kMenuSmallIconType = 3
-kMenuColorIconType = 4
-kMenuIconSuiteType = 5
-kMenuIconRefType = 6
-kMenuCGImageRefType = 7
-kMenuSystemIconSelectorType = 8
-kMenuIconResourceType = 9
-kMenuNullGlyph = 0x00
-kMenuTabRightGlyph = 0x02
-kMenuTabLeftGlyph = 0x03
-kMenuEnterGlyph = 0x04
-kMenuShiftGlyph = 0x05
-kMenuControlGlyph = 0x06
-kMenuOptionGlyph = 0x07
-kMenuSpaceGlyph = 0x09
-kMenuDeleteRightGlyph = 0x0A
-kMenuReturnGlyph = 0x0B
-kMenuReturnR2LGlyph = 0x0C
-kMenuNonmarkingReturnGlyph = 0x0D
-kMenuPencilGlyph = 0x0F
-kMenuDownwardArrowDashedGlyph = 0x10
-kMenuCommandGlyph = 0x11
-kMenuCheckmarkGlyph = 0x12
-kMenuDiamondGlyph = 0x13
-kMenuAppleLogoFilledGlyph = 0x14
-kMenuParagraphKoreanGlyph = 0x15
-kMenuDeleteLeftGlyph = 0x17
-kMenuLeftArrowDashedGlyph = 0x18
-kMenuUpArrowDashedGlyph = 0x19
-kMenuRightArrowDashedGlyph = 0x1A
-kMenuEscapeGlyph = 0x1B
-kMenuClearGlyph = 0x1C
-kMenuLeftDoubleQuotesJapaneseGlyph = 0x1D
-kMenuRightDoubleQuotesJapaneseGlyph = 0x1E
-kMenuTrademarkJapaneseGlyph = 0x1F
-kMenuBlankGlyph = 0x61
-kMenuPageUpGlyph = 0x62
-kMenuCapsLockGlyph = 0x63
-kMenuLeftArrowGlyph = 0x64
-kMenuRightArrowGlyph = 0x65
-kMenuNorthwestArrowGlyph = 0x66
-kMenuHelpGlyph = 0x67
-kMenuUpArrowGlyph = 0x68
-kMenuSoutheastArrowGlyph = 0x69
-kMenuDownArrowGlyph = 0x6A
-kMenuPageDownGlyph = 0x6B
-kMenuAppleLogoOutlineGlyph = 0x6C
-kMenuContextualMenuGlyph = 0x6D
-kMenuPowerGlyph = 0x6E
-kMenuF1Glyph = 0x6F
-kMenuF2Glyph = 0x70
-kMenuF3Glyph = 0x71
-kMenuF4Glyph = 0x72
-kMenuF5Glyph = 0x73
-kMenuF6Glyph = 0x74
-kMenuF7Glyph = 0x75
-kMenuF8Glyph = 0x76
-kMenuF9Glyph = 0x77
-kMenuF10Glyph = 0x78
-kMenuF11Glyph = 0x79
-kMenuF12Glyph = 0x7A
-kMenuF13Glyph = 0x87
-kMenuF14Glyph = 0x88
-kMenuF15Glyph = 0x89
-kMenuControlISOGlyph = 0x8A
-kMenuAttrExcludesMarkColumn = (1 << 0)
-kMenuAttrAutoDisable = (1 << 2)
-kMenuAttrUsePencilGlyph = (1 << 3)
-kMenuAttrHidden = (1 << 4)
-kMenuItemAttrDisabled = (1 << 0)
-kMenuItemAttrIconDisabled = (1 << 1)
-kMenuItemAttrSubmenuParentChoosable = (1 << 2)
-kMenuItemAttrDynamic = (1 << 3)
-kMenuItemAttrNotPreviousAlternate = (1 << 4)
-kMenuItemAttrHidden = (1 << 5)
-kMenuItemAttrSeparator = (1 << 6)
-kMenuItemAttrSectionHeader = (1 << 7)
-kMenuItemAttrIgnoreMeta = (1 << 8)
-kMenuItemAttrAutoRepeat = (1 << 9)
-kMenuItemAttrUseVirtualKey = (1 << 10)
-kMenuItemAttrCustomDraw = (1 << 11)
-kMenuItemAttrIncludeInCmdKeyMatching = (1 << 12)
-kMenuTrackingModeMouse = 1
-kMenuTrackingModeKeyboard = 2
-kMenuEventIncludeDisabledItems = 0x0001
-kMenuEventQueryOnly = 0x0002
-kMenuEventDontCheckSubmenus = 0x0004
-kMenuItemDataText = (1 << 0)
-kMenuItemDataMark = (1 << 1)
-kMenuItemDataCmdKey = (1 << 2)
-kMenuItemDataCmdKeyGlyph = (1 << 3)
-kMenuItemDataCmdKeyModifiers = (1 << 4)
-kMenuItemDataStyle = (1 << 5)
-kMenuItemDataEnabled = (1 << 6)
-kMenuItemDataIconEnabled = (1 << 7)
-kMenuItemDataIconID = (1 << 8)
-kMenuItemDataIconHandle = (1 << 9)
-kMenuItemDataCommandID = (1 << 10)
-kMenuItemDataTextEncoding = (1 << 11)
-kMenuItemDataSubmenuID = (1 << 12)
-kMenuItemDataSubmenuHandle = (1 << 13)
-kMenuItemDataFontID = (1 << 14)
-kMenuItemDataRefcon = (1 << 15)
-kMenuItemDataAttributes = (1 << 16)
-kMenuItemDataCFString = (1 << 17)
-kMenuItemDataProperties = (1 << 18)
-kMenuItemDataIndent = (1 << 19)
-kMenuItemDataCmdVirtualKey = (1 << 20)
-kMenuItemDataAllDataVersionOne = 0x000FFFFF
-kMenuItemDataAllDataVersionTwo = kMenuItemDataAllDataVersionOne | kMenuItemDataCmdVirtualKey
-kMenuDefProcPtr = 0
-kMenuPropertyPersistent = 0x00000001
-kHierarchicalFontMenuOption = 0x00000001
-gestaltContextualMenuAttr = FOUR_CHAR_CODE('cmnu')
-gestaltContextualMenuUnusedBit = 0
-gestaltContextualMenuTrapAvailable = 1
-gestaltContextualMenuHasAttributeAndModifierKeys = 2
-gestaltContextualMenuHasUnicodeSupport = 3
-kCMHelpItemNoHelp = 0
-kCMHelpItemAppleGuide = 1
-kCMHelpItemOtherHelp = 2
-kCMHelpItemRemoveHelp = 3
-kCMNothingSelected = 0
-kCMMenuItemSelected = 1
-kCMShowHelpSelected = 3
-keyContextualMenuName = FOUR_CHAR_CODE('pnam')
-keyContextualMenuCommandID = FOUR_CHAR_CODE('cmcd')
-keyContextualMenuSubmenu = FOUR_CHAR_CODE('cmsb')
-keyContextualMenuAttributes = FOUR_CHAR_CODE('cmat')
-keyContextualMenuModifiers = FOUR_CHAR_CODE('cmmd')
diff --git a/Lib/plat-mac/Carbon/Mlte.py b/Lib/plat-mac/Carbon/Mlte.py
deleted file mode 100644
index b81fbc52861..00000000000
--- a/Lib/plat-mac/Carbon/Mlte.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Mlte import *
diff --git a/Lib/plat-mac/Carbon/OSA.py b/Lib/plat-mac/Carbon/OSA.py
deleted file mode 100644
index 8d6732c9452..00000000000
--- a/Lib/plat-mac/Carbon/OSA.py
+++ /dev/null
@@ -1 +0,0 @@
-from _OSA import *
diff --git a/Lib/plat-mac/Carbon/OSAconst.py b/Lib/plat-mac/Carbon/OSAconst.py
deleted file mode 100644
index 3b64c248101..00000000000
--- a/Lib/plat-mac/Carbon/OSAconst.py
+++ /dev/null
@@ -1,133 +0,0 @@
-# Generated from 'OSA.h'
-
-def FOUR_CHAR_CODE(x): return x
-from Carbon.AppleEvents import *
-kAEUseStandardDispatch = -1
-kOSAComponentType = FOUR_CHAR_CODE('osa ')
-kOSAGenericScriptingComponentSubtype = FOUR_CHAR_CODE('scpt')
-kOSAFileType = FOUR_CHAR_CODE('osas')
-kOSASuite = FOUR_CHAR_CODE('ascr')
-kOSARecordedText = FOUR_CHAR_CODE('recd')
-kOSAScriptIsModified = FOUR_CHAR_CODE('modi')
-kOSAScriptIsTypeCompiledScript = FOUR_CHAR_CODE('cscr')
-kOSAScriptIsTypeScriptValue = FOUR_CHAR_CODE('valu')
-kOSAScriptIsTypeScriptContext = FOUR_CHAR_CODE('cntx')
-kOSAScriptBestType = FOUR_CHAR_CODE('best')
-kOSACanGetSource = FOUR_CHAR_CODE('gsrc')
-typeOSADialectInfo = FOUR_CHAR_CODE('difo')
-keyOSADialectName = FOUR_CHAR_CODE('dnam')
-keyOSADialectCode = FOUR_CHAR_CODE('dcod')
-keyOSADialectLangCode = FOUR_CHAR_CODE('dlcd')
-keyOSADialectScriptCode = FOUR_CHAR_CODE('dscd')
-kOSANullScript = 0L
-kOSANullMode = 0
-kOSAModeNull = 0
-kOSASupportsCompiling = 0x0002
-kOSASupportsGetSource = 0x0004
-kOSASupportsAECoercion = 0x0008
-kOSASupportsAESending = 0x0010
-kOSASupportsRecording = 0x0020
-kOSASupportsConvenience = 0x0040
-kOSASupportsDialects = 0x0080
-kOSASupportsEventHandling = 0x0100
-kOSASelectLoad = 0x0001
-kOSASelectStore = 0x0002
-kOSASelectExecute = 0x0003
-kOSASelectDisplay = 0x0004
-kOSASelectScriptError = 0x0005
-kOSASelectDispose = 0x0006
-kOSASelectSetScriptInfo = 0x0007
-kOSASelectGetScriptInfo = 0x0008
-kOSASelectSetActiveProc = 0x0009
-kOSASelectGetActiveProc = 0x000A
-kOSASelectScriptingComponentName = 0x0102
-kOSASelectCompile = 0x0103
-kOSASelectCopyID = 0x0104
-kOSASelectCopyScript = 0x0105
-kOSASelectGetSource = 0x0201
-kOSASelectCoerceFromDesc = 0x0301
-kOSASelectCoerceToDesc = 0x0302
-kOSASelectSetSendProc = 0x0401
-kOSASelectGetSendProc = 0x0402
-kOSASelectSetCreateProc = 0x0403
-kOSASelectGetCreateProc = 0x0404
-kOSASelectSetDefaultTarget = 0x0405
-kOSASelectStartRecording = 0x0501
-kOSASelectStopRecording = 0x0502
-kOSASelectLoadExecute = 0x0601
-kOSASelectCompileExecute = 0x0602
-kOSASelectDoScript = 0x0603
-kOSASelectSetCurrentDialect = 0x0701
-kOSASelectGetCurrentDialect = 0x0702
-kOSASelectAvailableDialects = 0x0703
-kOSASelectGetDialectInfo = 0x0704
-kOSASelectAvailableDialectCodeList = 0x0705
-kOSASelectSetResumeDispatchProc = 0x0801
-kOSASelectGetResumeDispatchProc = 0x0802
-kOSASelectExecuteEvent = 0x0803
-kOSASelectDoEvent = 0x0804
-kOSASelectMakeContext = 0x0805
-kOSADebuggerCreateSession = 0x0901
-kOSADebuggerGetSessionState = 0x0902
-kOSADebuggerSessionStep = 0x0903
-kOSADebuggerDisposeSession = 0x0904
-kOSADebuggerGetStatementRanges = 0x0905
-kOSADebuggerGetBreakpoint = 0x0910
-kOSADebuggerSetBreakpoint = 0x0911
-kOSADebuggerGetDefaultBreakpoint = 0x0912
-kOSADebuggerGetCurrentCallFrame = 0x0906
-kOSADebuggerGetCallFrameState = 0x0907
-kOSADebuggerGetVariable = 0x0908
-kOSADebuggerSetVariable = 0x0909
-kOSADebuggerGetPreviousCallFrame = 0x090A
-kOSADebuggerDisposeCallFrame = 0x090B
-kOSADebuggerCountVariables = 0x090C
-kOSASelectComponentSpecificStart = 0x1001
-kOSAModePreventGetSource = 0x00000001
-kOSAModeNeverInteract = kAENeverInteract
-kOSAModeCanInteract = kAECanInteract
-kOSAModeAlwaysInteract = kAEAlwaysInteract
-kOSAModeDontReconnect = kAEDontReconnect
-kOSAModeCantSwitchLayer = 0x00000040
-kOSAModeDoRecord = 0x00001000
-kOSAModeCompileIntoContext = 0x00000002
-kOSAModeAugmentContext = 0x00000004
-kOSAModeDisplayForHumans = 0x00000008
-kOSAModeDontStoreParent = 0x00010000
-kOSAModeDispatchToDirectObject = 0x00020000
-kOSAModeDontGetDataForArguments = 0x00040000
-kOSAScriptResourceType = kOSAGenericScriptingComponentSubtype
-typeOSAGenericStorage = kOSAScriptResourceType
-kOSAErrorNumber = keyErrorNumber
-kOSAErrorMessage = keyErrorString
-kOSAErrorBriefMessage = FOUR_CHAR_CODE('errb')
-kOSAErrorApp = FOUR_CHAR_CODE('erap')
-kOSAErrorPartialResult = FOUR_CHAR_CODE('ptlr')
-kOSAErrorOffendingObject = FOUR_CHAR_CODE('erob')
-kOSAErrorExpectedType = FOUR_CHAR_CODE('errt')
-kOSAErrorRange = FOUR_CHAR_CODE('erng')
-typeOSAErrorRange = FOUR_CHAR_CODE('erng')
-keyOSASourceStart = FOUR_CHAR_CODE('srcs')
-keyOSASourceEnd = FOUR_CHAR_CODE('srce')
-kOSAUseStandardDispatch = kAEUseStandardDispatch
-kOSANoDispatch = kAENoDispatch
-kOSADontUsePhac = 0x0001
-eNotStarted = 0
-eRunnable = 1
-eRunning = 2
-eStopped = 3
-eTerminated = 4
-eStepOver = 0
-eStepIn = 1
-eStepOut = 2
-eRun = 3
-eLocal = 0
-eGlobal = 1
-eProperties = 2
-keyProgramState = FOUR_CHAR_CODE('dsps')
-typeStatementRange = FOUR_CHAR_CODE('srng')
-keyProcedureName = FOUR_CHAR_CODE('dfnm')
-keyStatementRange = FOUR_CHAR_CODE('dfsr')
-keyLocalsNames = FOUR_CHAR_CODE('dfln')
-keyGlobalsNames = FOUR_CHAR_CODE('dfgn')
-keyParamsNames = FOUR_CHAR_CODE('dfpn')
diff --git a/Lib/plat-mac/Carbon/QDOffscreen.py b/Lib/plat-mac/Carbon/QDOffscreen.py
deleted file mode 100644
index b3f557e436f..00000000000
--- a/Lib/plat-mac/Carbon/QDOffscreen.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Generated from 'QDOffscreen.h'
-
-def FOUR_CHAR_CODE(x): return x
-pixPurgeBit = 0
-noNewDeviceBit = 1
-useTempMemBit = 2
-keepLocalBit = 3
-useDistantHdwrMemBit = 4
-useLocalHdwrMemBit = 5
-pixelsPurgeableBit = 6
-pixelsLockedBit = 7
-mapPixBit = 16
-newDepthBit = 17
-alignPixBit = 18
-newRowBytesBit = 19
-reallocPixBit = 20
-clipPixBit = 28
-stretchPixBit = 29
-ditherPixBit = 30
-gwFlagErrBit = 31
-pixPurge = 1L << pixPurgeBit
-noNewDevice = 1L << noNewDeviceBit
-useTempMem = 1L << useTempMemBit
-keepLocal = 1L << keepLocalBit
-useDistantHdwrMem = 1L << useDistantHdwrMemBit
-useLocalHdwrMem = 1L << useLocalHdwrMemBit
-pixelsPurgeable = 1L << pixelsPurgeableBit
-pixelsLocked = 1L << pixelsLockedBit
-kAllocDirectDrawSurface = 1L << 14
-mapPix = 1L << mapPixBit
-newDepth = 1L << newDepthBit
-alignPix = 1L << alignPixBit
-newRowBytes = 1L << newRowBytesBit
-reallocPix = 1L << reallocPixBit
-clipPix = 1L << clipPixBit
-stretchPix = 1L << stretchPixBit
-ditherPix = 1L << ditherPixBit
-gwFlagErr = 1L << gwFlagErrBit
-deviceIsIndirect = (1L << 0)
-deviceNeedsLock = (1L << 1)
-deviceIsStatic = (1L << 2)
-deviceIsExternalBuffer = (1L << 3)
-deviceIsDDSurface = (1L << 4)
-deviceIsDCISurface = (1L << 5)
-deviceIsGDISurface = (1L << 6)
-deviceIsAScreen = (1L << 7)
-deviceIsOverlaySurface = (1L << 8)
diff --git a/Lib/plat-mac/Carbon/Qd.py b/Lib/plat-mac/Carbon/Qd.py
deleted file mode 100644
index 227fe9855aa..00000000000
--- a/Lib/plat-mac/Carbon/Qd.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Qd import *
diff --git a/Lib/plat-mac/Carbon/Qdoffs.py b/Lib/plat-mac/Carbon/Qdoffs.py
deleted file mode 100644
index 90a3d2cec35..00000000000
--- a/Lib/plat-mac/Carbon/Qdoffs.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Qdoffs import *
diff --git a/Lib/plat-mac/Carbon/Qt.py b/Lib/plat-mac/Carbon/Qt.py
deleted file mode 100644
index 590a92ad178..00000000000
--- a/Lib/plat-mac/Carbon/Qt.py
+++ /dev/null
@@ -1,5 +0,0 @@
-from _Qt import *
-try:
- _ = AddFilePreview
-except:
- raise ImportError, "Old (2.3) _Qt.so module loaded in stead of new (2.4) _Qt.so"
diff --git a/Lib/plat-mac/Carbon/QuickDraw.py b/Lib/plat-mac/Carbon/QuickDraw.py
deleted file mode 100644
index 65c2f9a9463..00000000000
--- a/Lib/plat-mac/Carbon/QuickDraw.py
+++ /dev/null
@@ -1,218 +0,0 @@
-# Generated from 'QuickDraw.h'
-
-
-def FOUR_CHAR_CODE(x): return x
-normal = 0
-bold = 1
-italic = 2
-underline = 4
-outline = 8
-shadow = 0x10
-condense = 0x20
-extend = 0x40
-invalColReq = -1
-srcCopy = 0
-srcOr = 1
-srcXor = 2
-srcBic = 3
-notSrcCopy = 4
-notSrcOr = 5
-notSrcXor = 6
-notSrcBic = 7
-patCopy = 8
-patOr = 9
-patXor = 10
-patBic = 11
-notPatCopy = 12
-notPatOr = 13
-notPatXor = 14
-notPatBic = 15
-grayishTextOr = 49
-hilitetransfermode = 50
-hilite = 50
-blend = 32
-addPin = 33
-addOver = 34
-subPin = 35
-addMax = 37
-adMax = 37
-subOver = 38
-adMin = 39
-ditherCopy = 64
-transparent = 36
-italicBit = 1
-ulineBit = 2
-outlineBit = 3
-shadowBit = 4
-condenseBit = 5
-extendBit = 6
-normalBit = 0
-inverseBit = 1
-redBit = 4
-greenBit = 3
-blueBit = 2
-cyanBit = 8
-magentaBit = 7
-yellowBit = 6
-blackBit = 5
-blackColor = 33
-whiteColor = 30
-redColor = 205
-greenColor = 341
-blueColor = 409
-cyanColor = 273
-magentaColor = 137
-yellowColor = 69
-picLParen = 0
-picRParen = 1
-clutType = 0
-fixedType = 1
-directType = 2
-gdDevType = 0
-interlacedDevice = 2
-hwMirroredDevice = 4
-roundedDevice = 5
-hasAuxMenuBar = 6
-burstDevice = 7
-ext32Device = 8
-ramInit = 10
-mainScreen = 11
-allInit = 12
-screenDevice = 13
-noDriver = 14
-screenActive = 15
-hiliteBit = 7
-pHiliteBit = 0
-defQDColors = 127
-RGBDirect = 16
-baseAddr32 = 4
-sysPatListID = 0
-iBeamCursor = 1
-crossCursor = 2
-plusCursor = 3
-watchCursor = 4
-kQDGrafVerbFrame = 0
-kQDGrafVerbPaint = 1
-kQDGrafVerbErase = 2
-kQDGrafVerbInvert = 3
-kQDGrafVerbFill = 4
-frame = kQDGrafVerbFrame
-paint = kQDGrafVerbPaint
-erase = kQDGrafVerbErase
-invert = kQDGrafVerbInvert
-fill = kQDGrafVerbFill
-chunky = 0
-chunkyPlanar = 1
-planar = 2
-singleDevicesBit = 0
-dontMatchSeedsBit = 1
-allDevicesBit = 2
-singleDevices = 1 << singleDevicesBit
-dontMatchSeeds = 1 << dontMatchSeedsBit
-allDevices = 1 << allDevicesBit
-kPrinterFontStatus = 0
-kPrinterScalingStatus = 1
-kNoConstraint = 0
-kVerticalConstraint = 1
-kHorizontalConstraint = 2
-k1MonochromePixelFormat = 0x00000001
-k2IndexedPixelFormat = 0x00000002
-k4IndexedPixelFormat = 0x00000004
-k8IndexedPixelFormat = 0x00000008
-k16BE555PixelFormat = 0x00000010
-k24RGBPixelFormat = 0x00000018
-k32ARGBPixelFormat = 0x00000020
-k1IndexedGrayPixelFormat = 0x00000021
-k2IndexedGrayPixelFormat = 0x00000022
-k4IndexedGrayPixelFormat = 0x00000024
-k8IndexedGrayPixelFormat = 0x00000028
-k16LE555PixelFormat = FOUR_CHAR_CODE('L555')
-k16LE5551PixelFormat = FOUR_CHAR_CODE('5551')
-k16BE565PixelFormat = FOUR_CHAR_CODE('B565')
-k16LE565PixelFormat = FOUR_CHAR_CODE('L565')
-k24BGRPixelFormat = FOUR_CHAR_CODE('24BG')
-k32BGRAPixelFormat = FOUR_CHAR_CODE('BGRA')
-k32ABGRPixelFormat = FOUR_CHAR_CODE('ABGR')
-k32RGBAPixelFormat = FOUR_CHAR_CODE('RGBA')
-kYUVSPixelFormat = FOUR_CHAR_CODE('yuvs')
-kYUVUPixelFormat = FOUR_CHAR_CODE('yuvu')
-kYVU9PixelFormat = FOUR_CHAR_CODE('YVU9')
-kYUV411PixelFormat = FOUR_CHAR_CODE('Y411')
-kYVYU422PixelFormat = FOUR_CHAR_CODE('YVYU')
-kUYVY422PixelFormat = FOUR_CHAR_CODE('UYVY')
-kYUV211PixelFormat = FOUR_CHAR_CODE('Y211')
-k2vuyPixelFormat = FOUR_CHAR_CODE('2vuy')
-kCursorImageMajorVersion = 0x0001
-kCursorImageMinorVersion = 0x0000
-kQDParseRegionFromTop = (1 << 0)
-kQDParseRegionFromBottom = (1 << 1)
-kQDParseRegionFromLeft = (1 << 2)
-kQDParseRegionFromRight = (1 << 3)
-kQDParseRegionFromTopLeft = kQDParseRegionFromTop | kQDParseRegionFromLeft
-kQDParseRegionFromBottomRight = kQDParseRegionFromBottom | kQDParseRegionFromRight
-kQDRegionToRectsMsgInit = 1
-kQDRegionToRectsMsgParse = 2
-kQDRegionToRectsMsgTerminate = 3
-colorXorXFer = 52
-noiseXFer = 53
-customXFer = 54
-kXFer1PixelAtATime = 0x00000001
-kXFerConvertPixelToRGB32 = 0x00000002
-kCursorComponentsVersion = 0x00010001
-kCursorComponentType = FOUR_CHAR_CODE('curs')
-cursorDoesAnimate = 1L << 0
-cursorDoesHardware = 1L << 1
-cursorDoesUnreadableScreenBits = 1L << 2
-kRenderCursorInHardware = 1L << 0
-kRenderCursorInSoftware = 1L << 1
-kCursorComponentInit = 0x0001
-kCursorComponentGetInfo = 0x0002
-kCursorComponentSetOutputMode = 0x0003
-kCursorComponentSetData = 0x0004
-kCursorComponentReconfigure = 0x0005
-kCursorComponentDraw = 0x0006
-kCursorComponentErase = 0x0007
-kCursorComponentMove = 0x0008
-kCursorComponentAnimate = 0x0009
-kCursorComponentLastReserved = 0x0050
-# Generated from 'QuickDrawText.h'
-
-
-def FOUR_CHAR_CODE(x): return x
-normal = 0
-bold = 1
-italic = 2
-underline = 4
-outline = 8
-shadow = 0x10
-condense = 0x20
-extend = 0x40
-leftCaret = 0
-rightCaret = -1
-kHilite = 1
-smLeftCaret = 0
-smRightCaret = -1
-smHilite = 1
-onlyStyleRun = 0
-leftStyleRun = 1
-rightStyleRun = 2
-middleStyleRun = 3
-smOnlyStyleRun = 0
-smLeftStyleRun = 1
-smRightStyleRun = 2
-smMiddleStyleRun = 3
-truncEnd = 0
-truncMiddle = 0x4000
-smTruncEnd = 0
-smTruncMiddle = 0x4000
-notTruncated = 0
-truncated = 1
-truncErr = -1
-smNotTruncated = 0
-smTruncated = 1
-smTruncErr = -1
-smBreakWord = 0
-smBreakChar = 1
-smBreakOverflow = 2
-tfAntiAlias = 1 << 0
-tfUnicode = 1 << 1
diff --git a/Lib/plat-mac/Carbon/QuickTime.py b/Lib/plat-mac/Carbon/QuickTime.py
deleted file mode 100644
index 8fba58cb3e2..00000000000
--- a/Lib/plat-mac/Carbon/QuickTime.py
+++ /dev/null
@@ -1,3468 +0,0 @@
-# Generated from 'Movies.h'
-
-def FOUR_CHAR_CODE(x): return x
-xmlIdentifierUnrecognized = -1
-kControllerMinimum = -0xf777
-notImplementedMusicOSErr = -2071
-cantSendToSynthesizerOSErr = -2072
-cantReceiveFromSynthesizerOSErr = -2073
-illegalVoiceAllocationOSErr = -2074
-illegalPartOSErr = -2075
-illegalChannelOSErr = -2076
-illegalKnobOSErr = -2077
-illegalKnobValueOSErr = -2078
-illegalInstrumentOSErr = -2079
-illegalControllerOSErr = -2080
-midiManagerAbsentOSErr = -2081
-synthesizerNotRespondingOSErr = -2082
-synthesizerOSErr = -2083
-illegalNoteChannelOSErr = -2084
-noteChannelNotAllocatedOSErr = -2085
-tunePlayerFullOSErr = -2086
-tuneParseOSErr = -2087
-MovieFileType = FOUR_CHAR_CODE('MooV')
-MovieScrapType = FOUR_CHAR_CODE('moov')
-MovieResourceType = FOUR_CHAR_CODE('moov')
-MovieForwardPointerResourceType = FOUR_CHAR_CODE('fore')
-MovieBackwardPointerResourceType = FOUR_CHAR_CODE('back')
-MovieResourceAtomType = FOUR_CHAR_CODE('moov')
-MovieDataAtomType = FOUR_CHAR_CODE('mdat')
-FreeAtomType = FOUR_CHAR_CODE('free')
-SkipAtomType = FOUR_CHAR_CODE('skip')
-WideAtomPlaceholderType = FOUR_CHAR_CODE('wide')
-MediaHandlerType = FOUR_CHAR_CODE('mhlr')
-DataHandlerType = FOUR_CHAR_CODE('dhlr')
-VideoMediaType = FOUR_CHAR_CODE('vide')
-SoundMediaType = FOUR_CHAR_CODE('soun')
-TextMediaType = FOUR_CHAR_CODE('text')
-BaseMediaType = FOUR_CHAR_CODE('gnrc')
-MPEGMediaType = FOUR_CHAR_CODE('MPEG')
-MusicMediaType = FOUR_CHAR_CODE('musi')
-TimeCodeMediaType = FOUR_CHAR_CODE('tmcd')
-SpriteMediaType = FOUR_CHAR_CODE('sprt')
-FlashMediaType = FOUR_CHAR_CODE('flsh')
-MovieMediaType = FOUR_CHAR_CODE('moov')
-TweenMediaType = FOUR_CHAR_CODE('twen')
-ThreeDeeMediaType = FOUR_CHAR_CODE('qd3d')
-SkinMediaType = FOUR_CHAR_CODE('skin')
-HandleDataHandlerSubType = FOUR_CHAR_CODE('hndl')
-PointerDataHandlerSubType = FOUR_CHAR_CODE('ptr ')
-NullDataHandlerSubType = FOUR_CHAR_CODE('null')
-ResourceDataHandlerSubType = FOUR_CHAR_CODE('rsrc')
-URLDataHandlerSubType = FOUR_CHAR_CODE('url ')
-WiredActionHandlerType = FOUR_CHAR_CODE('wire')
-VisualMediaCharacteristic = FOUR_CHAR_CODE('eyes')
-AudioMediaCharacteristic = FOUR_CHAR_CODE('ears')
-kCharacteristicCanSendVideo = FOUR_CHAR_CODE('vsnd')
-kCharacteristicProvidesActions = FOUR_CHAR_CODE('actn')
-kCharacteristicNonLinear = FOUR_CHAR_CODE('nonl')
-kCharacteristicCanStep = FOUR_CHAR_CODE('step')
-kCharacteristicHasNoDuration = FOUR_CHAR_CODE('noti')
-kCharacteristicHasSkinData = FOUR_CHAR_CODE('skin')
-kCharacteristicProvidesKeyFocus = FOUR_CHAR_CODE('keyf')
-kUserDataMovieControllerType = FOUR_CHAR_CODE('ctyp')
-kUserDataName = FOUR_CHAR_CODE('name')
-kUserDataTextAlbum = FOUR_CHAR_CODE('\xa9alb')
-kUserDataTextArtist = FOUR_CHAR_CODE('\xa9ART')
-kUserDataTextAuthor = FOUR_CHAR_CODE('\xa9aut')
-kUserDataTextChapter = FOUR_CHAR_CODE('\xa9chp')
-kUserDataTextComment = FOUR_CHAR_CODE('\xa9cmt')
-kUserDataTextComposer = FOUR_CHAR_CODE('\xa9com')
-kUserDataTextCopyright = FOUR_CHAR_CODE('\xa9cpy')
-kUserDataTextCreationDate = FOUR_CHAR_CODE('\xa9day')
-kUserDataTextDescription = FOUR_CHAR_CODE('\xa9des')
-kUserDataTextDirector = FOUR_CHAR_CODE('\xa9dir')
-kUserDataTextDisclaimer = FOUR_CHAR_CODE('\xa9dis')
-kUserDataTextEncodedBy = FOUR_CHAR_CODE('\xa9enc')
-kUserDataTextFullName = FOUR_CHAR_CODE('\xa9nam')
-kUserDataTextGenre = FOUR_CHAR_CODE('\xa9gen')
-kUserDataTextHostComputer = FOUR_CHAR_CODE('\xa9hst')
-kUserDataTextInformation = FOUR_CHAR_CODE('\xa9inf')
-kUserDataTextKeywords = FOUR_CHAR_CODE('\xa9key')
-kUserDataTextMake = FOUR_CHAR_CODE('\xa9mak')
-kUserDataTextModel = FOUR_CHAR_CODE('\xa9mod')
-kUserDataTextOriginalArtist = FOUR_CHAR_CODE('\xa9ope')
-kUserDataTextOriginalFormat = FOUR_CHAR_CODE('\xa9fmt')
-kUserDataTextOriginalSource = FOUR_CHAR_CODE('\xa9src')
-kUserDataTextPerformers = FOUR_CHAR_CODE('\xa9prf')
-kUserDataTextProducer = FOUR_CHAR_CODE('\xa9prd')
-kUserDataTextProduct = FOUR_CHAR_CODE('\xa9PRD')
-kUserDataTextSoftware = FOUR_CHAR_CODE('\xa9swr')
-kUserDataTextSpecialPlaybackRequirements = FOUR_CHAR_CODE('\xa9req')
-kUserDataTextTrack = FOUR_CHAR_CODE('\xa9trk')
-kUserDataTextWarning = FOUR_CHAR_CODE('\xa9wrn')
-kUserDataTextWriter = FOUR_CHAR_CODE('\xa9wrt')
-kUserDataTextURLLink = FOUR_CHAR_CODE('\xa9url')
-kUserDataTextEditDate1 = FOUR_CHAR_CODE('\xa9ed1')
-kUserDataUnicodeBit = 1L << 7
-DoTheRightThing = 0
-kQTNetworkStatusNoNetwork = -2
-kQTNetworkStatusUncertain = -1
-kQTNetworkStatusNotConnected = 0
-kQTNetworkStatusConnected = 1
-kMusicFlagDontPlay2Soft = 1L << 0
-kMusicFlagDontSlaveToMovie = 1L << 1
-dfDontDisplay = 1 << 0
-dfDontAutoScale = 1 << 1
-dfClipToTextBox = 1 << 2
-dfUseMovieBGColor = 1 << 3
-dfShrinkTextBoxToFit = 1 << 4
-dfScrollIn = 1 << 5
-dfScrollOut = 1 << 6
-dfHorizScroll = 1 << 7
-dfReverseScroll = 1 << 8
-dfContinuousScroll = 1 << 9
-dfFlowHoriz = 1 << 10
-dfContinuousKaraoke = 1 << 11
-dfDropShadow = 1 << 12
-dfAntiAlias = 1 << 13
-dfKeyedText = 1 << 14
-dfInverseHilite = 1 << 15
-dfTextColorHilite = 1 << 16
-searchTextDontGoToFoundTime = 1L << 16
-searchTextDontHiliteFoundText = 1L << 17
-searchTextOneTrackOnly = 1L << 18
-searchTextEnabledTracksOnly = 1L << 19
-kTextTextHandle = 1
-kTextTextPtr = 2
-kTextTEStyle = 3
-kTextSelection = 4
-kTextBackColor = 5
-kTextForeColor = 6
-kTextFace = 7
-kTextFont = 8
-kTextSize = 9
-kTextAlignment = 10
-kTextHilite = 11
-kTextDropShadow = 12
-kTextDisplayFlags = 13
-kTextScroll = 14
-kTextRelativeScroll = 15
-kTextHyperTextFace = 16
-kTextHyperTextColor = 17
-kTextKeyEntry = 18
-kTextMouseDown = 19
-kTextTextBox = 20
-kTextEditState = 21
-kTextLength = 22
-k3DMediaRendererEntry = FOUR_CHAR_CODE('rend')
-k3DMediaRendererName = FOUR_CHAR_CODE('name')
-k3DMediaRendererCode = FOUR_CHAR_CODE('rcod')
-movieProgressOpen = 0
-movieProgressUpdatePercent = 1
-movieProgressClose = 2
-progressOpFlatten = 1
-progressOpInsertTrackSegment = 2
-progressOpInsertMovieSegment = 3
-progressOpPaste = 4
-progressOpAddMovieSelection = 5
-progressOpCopy = 6
-progressOpCut = 7
-progressOpLoadMovieIntoRam = 8
-progressOpLoadTrackIntoRam = 9
-progressOpLoadMediaIntoRam = 10
-progressOpImportMovie = 11
-progressOpExportMovie = 12
-mediaQualityDraft = 0x0000
-mediaQualityNormal = 0x0040
-mediaQualityBetter = 0x0080
-mediaQualityBest = 0x00C0
-kQTEventPayloadIsQTList = 1L << 0
-kActionMovieSetVolume = 1024
-kActionMovieSetRate = 1025
-kActionMovieSetLoopingFlags = 1026
-kActionMovieGoToTime = 1027
-kActionMovieGoToTimeByName = 1028
-kActionMovieGoToBeginning = 1029
-kActionMovieGoToEnd = 1030
-kActionMovieStepForward = 1031
-kActionMovieStepBackward = 1032
-kActionMovieSetSelection = 1033
-kActionMovieSetSelectionByName = 1034
-kActionMoviePlaySelection = 1035
-kActionMovieSetLanguage = 1036
-kActionMovieChanged = 1037
-kActionMovieRestartAtTime = 1038
-kActionMovieGotoNextChapter = 1039
-kActionMovieGotoPreviousChapter = 1040
-kActionMovieGotoFirstChapter = 1041
-kActionMovieGotoLastChapter = 1042
-kActionMovieGotoChapterByIndex = 1043
-kActionMovieSetScale = 1044
-kActionTrackSetVolume = 2048
-kActionTrackSetBalance = 2049
-kActionTrackSetEnabled = 2050
-kActionTrackSetMatrix = 2051
-kActionTrackSetLayer = 2052
-kActionTrackSetClip = 2053
-kActionTrackSetCursor = 2054
-kActionTrackSetGraphicsMode = 2055
-kActionTrackSetIdleFrequency = 2056
-kActionTrackSetBassTreble = 2057
-kActionSpriteSetMatrix = 3072
-kActionSpriteSetImageIndex = 3073
-kActionSpriteSetVisible = 3074
-kActionSpriteSetLayer = 3075
-kActionSpriteSetGraphicsMode = 3076
-kActionSpritePassMouseToCodec = 3078
-kActionSpriteClickOnCodec = 3079
-kActionSpriteTranslate = 3080
-kActionSpriteScale = 3081
-kActionSpriteRotate = 3082
-kActionSpriteStretch = 3083
-kActionSpriteSetCanBeHitTested = 3094
-kActionQTVRSetPanAngle = 4096
-kActionQTVRSetTiltAngle = 4097
-kActionQTVRSetFieldOfView = 4098
-kActionQTVRShowDefaultView = 4099
-kActionQTVRGoToNodeID = 4100
-kActionQTVREnableHotSpot = 4101
-kActionQTVRShowHotSpots = 4102
-kActionQTVRTranslateObject = 4103
-kActionQTVRSetViewState = 4109
-kActionMusicPlayNote = 5120
-kActionMusicSetController = 5121
-kActionCase = 6144
-kActionWhile = 6145
-kActionGoToURL = 6146
-kActionSendQTEventToSprite = 6147
-kActionDebugStr = 6148
-kActionPushCurrentTime = 6149
-kActionPushCurrentTimeWithLabel = 6150
-kActionPopAndGotoTopTime = 6151
-kActionPopAndGotoLabeledTime = 6152
-kActionStatusString = 6153
-kActionSendQTEventToTrackObject = 6154
-kActionAddChannelSubscription = 6155
-kActionRemoveChannelSubscription = 6156
-kActionOpenCustomActionHandler = 6157
-kActionDoScript = 6158
-kActionDoCompressedActions = 6159
-kActionSendAppMessage = 6160
-kActionLoadComponent = 6161
-kActionSetFocus = 6162
-kActionDontPassKeyEvent = 6163
-kActionSetRandomSeed = 6164
-kActionSpriteTrackSetVariable = 7168
-kActionSpriteTrackNewSprite = 7169
-kActionSpriteTrackDisposeSprite = 7170
-kActionSpriteTrackSetVariableToString = 7171
-kActionSpriteTrackConcatVariables = 7172
-kActionSpriteTrackSetVariableToMovieURL = 7173
-kActionSpriteTrackSetVariableToMovieBaseURL = 7174
-kActionSpriteTrackSetAllSpritesHitTestingMode = 7181
-kActionSpriteTrackNewImage = 7182
-kActionSpriteTrackDisposeImage = 7183
-kActionApplicationNumberAndString = 8192
-kActionQD3DNamedObjectTranslateTo = 9216
-kActionQD3DNamedObjectScaleTo = 9217
-kActionQD3DNamedObjectRotateTo = 9218
-kActionFlashTrackSetPan = 10240
-kActionFlashTrackSetZoom = 10241
-kActionFlashTrackSetZoomRect = 10242
-kActionFlashTrackGotoFrameNumber = 10243
-kActionFlashTrackGotoFrameLabel = 10244
-kActionFlashTrackSetFlashVariable = 10245
-kActionFlashTrackDoButtonActions = 10246
-kActionMovieTrackAddChildMovie = 11264
-kActionMovieTrackLoadChildMovie = 11265
-kActionMovieTrackLoadChildMovieWithQTListParams = 11266
-kActionTextTrackPasteText = 12288
-kActionTextTrackSetTextBox = 12291
-kActionTextTrackSetTextStyle = 12292
-kActionTextTrackSetSelection = 12293
-kActionTextTrackSetBackgroundColor = 12294
-kActionTextTrackSetForegroundColor = 12295
-kActionTextTrackSetFace = 12296
-kActionTextTrackSetFont = 12297
-kActionTextTrackSetSize = 12298
-kActionTextTrackSetAlignment = 12299
-kActionTextTrackSetHilite = 12300
-kActionTextTrackSetDropShadow = 12301
-kActionTextTrackSetDisplayFlags = 12302
-kActionTextTrackSetScroll = 12303
-kActionTextTrackRelativeScroll = 12304
-kActionTextTrackFindText = 12305
-kActionTextTrackSetHyperTextFace = 12306
-kActionTextTrackSetHyperTextColor = 12307
-kActionTextTrackKeyEntry = 12308
-kActionTextTrackMouseDown = 12309
-kActionTextTrackSetEditable = 12310
-kActionListAddElement = 13312
-kActionListRemoveElements = 13313
-kActionListSetElementValue = 13314
-kActionListPasteFromXML = 13315
-kActionListSetMatchingFromXML = 13316
-kActionListSetFromURL = 13317
-kActionListExchangeLists = 13318
-kActionListServerQuery = 13319
-kOperandExpression = 1
-kOperandConstant = 2
-kOperandSubscribedToChannel = 3
-kOperandUniqueCustomActionHandlerID = 4
-kOperandCustomActionHandlerIDIsOpen = 5
-kOperandConnectionSpeed = 6
-kOperandGMTDay = 7
-kOperandGMTMonth = 8
-kOperandGMTYear = 9
-kOperandGMTHours = 10
-kOperandGMTMinutes = 11
-kOperandGMTSeconds = 12
-kOperandLocalDay = 13
-kOperandLocalMonth = 14
-kOperandLocalYear = 15
-kOperandLocalHours = 16
-kOperandLocalMinutes = 17
-kOperandLocalSeconds = 18
-kOperandRegisteredForQuickTimePro = 19
-kOperandPlatformRunningOn = 20
-kOperandQuickTimeVersion = 21
-kOperandComponentVersion = 22
-kOperandOriginalHandlerRefcon = 23
-kOperandTicks = 24
-kOperandMaxLoadedTimeInMovie = 25
-kOperandEventParameter = 26
-kOperandFreeMemory = 27
-kOperandNetworkStatus = 28
-kOperandQuickTimeVersionRegistered = 29
-kOperandSystemVersion = 30
-kOperandMovieVolume = 1024
-kOperandMovieRate = 1025
-kOperandMovieIsLooping = 1026
-kOperandMovieLoopIsPalindrome = 1027
-kOperandMovieTime = 1028
-kOperandMovieDuration = 1029
-kOperandMovieTimeScale = 1030
-kOperandMovieWidth = 1031
-kOperandMovieHeight = 1032
-kOperandMovieLoadState = 1033
-kOperandMovieTrackCount = 1034
-kOperandMovieIsActive = 1035
-kOperandMovieName = 1036
-kOperandMovieID = 1037
-kOperandMovieChapterCount = 1038
-kOperandMovieChapterIndex = 1039
-kOperandMovieChapterName = 1040
-kOperandMovieChapterNameByIndex = 1041
-kOperandMovieChapterIndexByName = 1042
-kOperandMovieAnnotation = 1043
-kOperandMovieConnectionFlags = 1044
-kOperandMovieConnectionString = 1045
-kOperandTrackVolume = 2048
-kOperandTrackBalance = 2049
-kOperandTrackEnabled = 2050
-kOperandTrackLayer = 2051
-kOperandTrackWidth = 2052
-kOperandTrackHeight = 2053
-kOperandTrackDuration = 2054
-kOperandTrackName = 2055
-kOperandTrackID = 2056
-kOperandTrackIdleFrequency = 2057
-kOperandTrackBass = 2058
-kOperandTrackTreble = 2059
-kOperandSpriteBoundsLeft = 3072
-kOperandSpriteBoundsTop = 3073
-kOperandSpriteBoundsRight = 3074
-kOperandSpriteBoundsBottom = 3075
-kOperandSpriteImageIndex = 3076
-kOperandSpriteVisible = 3077
-kOperandSpriteLayer = 3078
-kOperandSpriteTrackVariable = 3079
-kOperandSpriteTrackNumSprites = 3080
-kOperandSpriteTrackNumImages = 3081
-kOperandSpriteID = 3082
-kOperandSpriteIndex = 3083
-kOperandSpriteFirstCornerX = 3084
-kOperandSpriteFirstCornerY = 3085
-kOperandSpriteSecondCornerX = 3086
-kOperandSpriteSecondCornerY = 3087
-kOperandSpriteThirdCornerX = 3088
-kOperandSpriteThirdCornerY = 3089
-kOperandSpriteFourthCornerX = 3090
-kOperandSpriteFourthCornerY = 3091
-kOperandSpriteImageRegistrationPointX = 3092
-kOperandSpriteImageRegistrationPointY = 3093
-kOperandSpriteTrackSpriteIDAtPoint = 3094
-kOperandSpriteName = 3095
-kOperandSpriteCanBeHitTested = 3105
-kOperandSpriteTrackAllSpritesHitTestingMode = 3106
-kOperandSpriteTrackImageIDByIndex = 3107
-kOperandSpriteTrackImageIndexByID = 3108
-kOperandQTVRPanAngle = 4096
-kOperandQTVRTiltAngle = 4097
-kOperandQTVRFieldOfView = 4098
-kOperandQTVRNodeID = 4099
-kOperandQTVRHotSpotsVisible = 4100
-kOperandQTVRViewCenterH = 4101
-kOperandQTVRViewCenterV = 4102
-kOperandQTVRViewStateCount = 4103
-kOperandQTVRViewState = 4104
-kOperandMouseLocalHLoc = 5120
-kOperandMouseLocalVLoc = 5121
-kOperandKeyIsDown = 5122
-kOperandRandom = 5123
-kOperandCanHaveFocus = 5124
-kOperandHasFocus = 5125
-kOperandTextTrackEditable = 6144
-kOperandTextTrackCopyText = 6145
-kOperandTextTrackStartSelection = 6146
-kOperandTextTrackEndSelection = 6147
-kOperandTextTrackTextBoxLeft = 6148
-kOperandTextTrackTextBoxTop = 6149
-kOperandTextTrackTextBoxRight = 6150
-kOperandTextTrackTextBoxBottom = 6151
-kOperandTextTrackTextLength = 6152
-kOperandListCountElements = 7168
-kOperandListGetElementPathByIndex = 7169
-kOperandListGetElementValue = 7170
-kOperandListCopyToXML = 7171
-kOperandSin = 8192
-kOperandCos = 8193
-kOperandTan = 8194
-kOperandATan = 8195
-kOperandATan2 = 8196
-kOperandDegreesToRadians = 8197
-kOperandRadiansToDegrees = 8198
-kOperandSquareRoot = 8199
-kOperandExponent = 8200
-kOperandLog = 8201
-kOperandFlashTrackVariable = 9216
-kOperandStringLength = 10240
-kOperandStringCompare = 10241
-kOperandStringSubString = 10242
-kOperandStringConcat = 10243
-kFirstMovieAction = kActionMovieSetVolume
-kLastMovieAction = kActionMovieSetScale
-kFirstTrackAction = kActionTrackSetVolume
-kLastTrackAction = kActionTrackSetBassTreble
-kFirstSpriteAction = kActionSpriteSetMatrix
-kLastSpriteAction = kActionSpriteSetCanBeHitTested
-kFirstQTVRAction = kActionQTVRSetPanAngle
-kLastQTVRAction = kActionQTVRSetViewState
-kFirstMusicAction = kActionMusicPlayNote
-kLastMusicAction = kActionMusicSetController
-kFirstSystemAction = kActionCase
-kLastSystemAction = kActionSetRandomSeed
-kFirstSpriteTrackAction = kActionSpriteTrackSetVariable
-kLastSpriteTrackAction = kActionSpriteTrackDisposeImage
-kFirstApplicationAction = kActionApplicationNumberAndString
-kLastApplicationAction = kActionApplicationNumberAndString
-kFirstQD3DNamedObjectAction = kActionQD3DNamedObjectTranslateTo
-kLastQD3DNamedObjectAction = kActionQD3DNamedObjectRotateTo
-kFirstFlashTrackAction = kActionFlashTrackSetPan
-kLastFlashTrackAction = kActionFlashTrackDoButtonActions
-kFirstMovieTrackAction = kActionMovieTrackAddChildMovie
-kLastMovieTrackAction = kActionMovieTrackLoadChildMovieWithQTListParams
-kFirstTextTrackAction = kActionTextTrackPasteText
-kLastTextTrackAction = kActionTextTrackSetEditable
-kFirstMultiTargetAction = kActionListAddElement
-kLastMultiTargetAction = kActionListServerQuery
-kFirstAction = kFirstMovieAction
-kLastAction = kLastMultiTargetAction
-kTargetMovie = FOUR_CHAR_CODE('moov')
-kTargetMovieName = FOUR_CHAR_CODE('mona')
-kTargetMovieID = FOUR_CHAR_CODE('moid')
-kTargetRootMovie = FOUR_CHAR_CODE('moro')
-kTargetParentMovie = FOUR_CHAR_CODE('mopa')
-kTargetChildMovieTrackName = FOUR_CHAR_CODE('motn')
-kTargetChildMovieTrackID = FOUR_CHAR_CODE('moti')
-kTargetChildMovieTrackIndex = FOUR_CHAR_CODE('motx')
-kTargetChildMovieMovieName = FOUR_CHAR_CODE('momn')
-kTargetChildMovieMovieID = FOUR_CHAR_CODE('momi')
-kTargetTrackName = FOUR_CHAR_CODE('trna')
-kTargetTrackID = FOUR_CHAR_CODE('trid')
-kTargetTrackType = FOUR_CHAR_CODE('trty')
-kTargetTrackIndex = FOUR_CHAR_CODE('trin')
-kTargetSpriteName = FOUR_CHAR_CODE('spna')
-kTargetSpriteID = FOUR_CHAR_CODE('spid')
-kTargetSpriteIndex = FOUR_CHAR_CODE('spin')
-kTargetQD3DNamedObjectName = FOUR_CHAR_CODE('nana')
-kTargetCurrentQTEventParams = FOUR_CHAR_CODE('evpa')
-kQTEventType = FOUR_CHAR_CODE('evnt')
-kAction = FOUR_CHAR_CODE('actn')
-kWhichAction = FOUR_CHAR_CODE('whic')
-kActionParameter = FOUR_CHAR_CODE('parm')
-kActionTarget = FOUR_CHAR_CODE('targ')
-kActionFlags = FOUR_CHAR_CODE('flag')
-kActionParameterMinValue = FOUR_CHAR_CODE('minv')
-kActionParameterMaxValue = FOUR_CHAR_CODE('maxv')
-kActionListAtomType = FOUR_CHAR_CODE('list')
-kExpressionContainerAtomType = FOUR_CHAR_CODE('expr')
-kConditionalAtomType = FOUR_CHAR_CODE('test')
-kOperatorAtomType = FOUR_CHAR_CODE('oper')
-kOperandAtomType = FOUR_CHAR_CODE('oprn')
-kCommentAtomType = FOUR_CHAR_CODE('why ')
-kCustomActionHandler = FOUR_CHAR_CODE('cust')
-kCustomHandlerID = FOUR_CHAR_CODE('id ')
-kCustomHandlerDesc = FOUR_CHAR_CODE('desc')
-kQTEventRecordAtomType = FOUR_CHAR_CODE('erec')
-kQTEventMouseClick = FOUR_CHAR_CODE('clik')
-kQTEventMouseClickEnd = FOUR_CHAR_CODE('cend')
-kQTEventMouseClickEndTriggerButton = FOUR_CHAR_CODE('trig')
-kQTEventMouseEnter = FOUR_CHAR_CODE('entr')
-kQTEventMouseExit = FOUR_CHAR_CODE('exit')
-kQTEventMouseMoved = FOUR_CHAR_CODE('move')
-kQTEventFrameLoaded = FOUR_CHAR_CODE('fram')
-kQTEventIdle = FOUR_CHAR_CODE('idle')
-kQTEventKey = FOUR_CHAR_CODE('key ')
-kQTEventMovieLoaded = FOUR_CHAR_CODE('load')
-kQTEventRequestToModifyMovie = FOUR_CHAR_CODE('reqm')
-kQTEventListReceived = FOUR_CHAR_CODE('list')
-kQTEventKeyUp = FOUR_CHAR_CODE('keyU')
-kActionFlagActionIsDelta = 1L << 1
-kActionFlagParameterWrapsAround = 1L << 2
-kActionFlagActionIsToggle = 1L << 3
-kStatusStringIsURLLink = 1L << 1
-kStatusStringIsStreamingStatus = 1L << 2
-kStatusHasCodeNumber = 1L << 3
-kStatusIsError = 1L << 4
-kScriptIsUnknownType = 1L << 0
-kScriptIsJavaScript = 1L << 1
-kScriptIsLingoEvent = 1L << 2
-kScriptIsVBEvent = 1L << 3
-kScriptIsProjectorCommand = 1L << 4
-kScriptIsAppleScript = 1L << 5
-kQTRegistrationDialogTimeOutFlag = 1 << 0
-kQTRegistrationDialogShowDialog = 1 << 1
-kQTRegistrationDialogForceDialog = 1 << 2
-kOperatorAdd = FOUR_CHAR_CODE('add ')
-kOperatorSubtract = FOUR_CHAR_CODE('sub ')
-kOperatorMultiply = FOUR_CHAR_CODE('mult')
-kOperatorDivide = FOUR_CHAR_CODE('div ')
-kOperatorOr = FOUR_CHAR_CODE('or ')
-kOperatorAnd = FOUR_CHAR_CODE('and ')
-kOperatorNot = FOUR_CHAR_CODE('not ')
-kOperatorLessThan = FOUR_CHAR_CODE('< ')
-kOperatorLessThanEqualTo = FOUR_CHAR_CODE('<= ')
-kOperatorEqualTo = FOUR_CHAR_CODE('= ')
-kOperatorNotEqualTo = FOUR_CHAR_CODE('!= ')
-kOperatorGreaterThan = FOUR_CHAR_CODE('> ')
-kOperatorGreaterThanEqualTo = FOUR_CHAR_CODE('>= ')
-kOperatorModulo = FOUR_CHAR_CODE('mod ')
-kOperatorIntegerDivide = FOUR_CHAR_CODE('idiv')
-kOperatorAbsoluteValue = FOUR_CHAR_CODE('abs ')
-kOperatorNegate = FOUR_CHAR_CODE('neg ')
-kPlatformMacintosh = 1
-kPlatformWindows = 2
-kSystemIsWindows9x = 0x00010000
-kSystemIsWindowsNT = 0x00020000
-kMediaPropertyNonLinearAtomType = FOUR_CHAR_CODE('nonl')
-kMediaPropertyHasActions = 105
-loopTimeBase = 1
-palindromeLoopTimeBase = 2
-maintainTimeBaseZero = 4
-triggerTimeFwd = 0x0001
-triggerTimeBwd = 0x0002
-triggerTimeEither = 0x0003
-triggerRateLT = 0x0004
-triggerRateGT = 0x0008
-triggerRateEqual = 0x0010
-triggerRateLTE = triggerRateLT | triggerRateEqual
-triggerRateGTE = triggerRateGT | triggerRateEqual
-triggerRateNotEqual = triggerRateGT | triggerRateEqual | triggerRateLT
-triggerRateChange = 0
-triggerAtStart = 0x0001
-triggerAtStop = 0x0002
-timeBaseBeforeStartTime = 1
-timeBaseAfterStopTime = 2
-callBackAtTime = 1
-callBackAtRate = 2
-callBackAtTimeJump = 3
-callBackAtExtremes = 4
-callBackAtTimeBaseDisposed = 5
-callBackAtInterrupt = 0x8000
-callBackAtDeferredTask = 0x4000
-qtcbNeedsRateChanges = 1
-qtcbNeedsTimeChanges = 2
-qtcbNeedsStartStopChanges = 4
-keepInRam = 1 << 0
-unkeepInRam = 1 << 1
-flushFromRam = 1 << 2
-loadForwardTrackEdits = 1 << 3
-loadBackwardTrackEdits = 1 << 4
-newMovieActive = 1 << 0
-newMovieDontResolveDataRefs = 1 << 1
-newMovieDontAskUnresolvedDataRefs = 1 << 2
-newMovieDontAutoAlternates = 1 << 3
-newMovieDontUpdateForeBackPointers = 1 << 4
-newMovieDontAutoUpdateClock = 1 << 5
-newMovieAsyncOK = 1 << 8
-newMovieIdleImportOK = 1 << 10
-newMovieDontInteractWithUser = 1 << 11
-trackUsageInMovie = 1 << 1
-trackUsageInPreview = 1 << 2
-trackUsageInPoster = 1 << 3
-mediaSampleNotSync = 1 << 0
-mediaSampleShadowSync = 1 << 1
-pasteInParallel = 1 << 0
-showUserSettingsDialog = 1 << 1
-movieToFileOnlyExport = 1 << 2
-movieFileSpecValid = 1 << 3
-nextTimeMediaSample = 1 << 0
-nextTimeMediaEdit = 1 << 1
-nextTimeTrackEdit = 1 << 2
-nextTimeSyncSample = 1 << 3
-nextTimeStep = 1 << 4
-nextTimeEdgeOK = 1 << 14
-nextTimeIgnoreActiveSegment = 1 << 15
-createMovieFileDeleteCurFile = 1L << 31
-createMovieFileDontCreateMovie = 1L << 30
-createMovieFileDontOpenFile = 1L << 29
-createMovieFileDontCreateResFile = 1L << 28
-flattenAddMovieToDataFork = 1L << 0
-flattenActiveTracksOnly = 1L << 2
-flattenDontInterleaveFlatten = 1L << 3
-flattenFSSpecPtrIsDataRefRecordPtr = 1L << 4
-flattenCompressMovieResource = 1L << 5
-flattenForceMovieResourceBeforeMovieData = 1L << 6
-movieInDataForkResID = -1
-mcTopLeftMovie = 1 << 0
-mcScaleMovieToFit = 1 << 1
-mcWithBadge = 1 << 2
-mcNotVisible = 1 << 3
-mcWithFrame = 1 << 4
-movieScrapDontZeroScrap = 1 << 0
-movieScrapOnlyPutMovie = 1 << 1
-dataRefSelfReference = 1 << 0
-dataRefWasNotResolved = 1 << 1
-kMovieAnchorDataRefIsDefault = 1 << 0
-hintsScrubMode = 1 << 0
-hintsLoop = 1 << 1
-hintsDontPurge = 1 << 2
-hintsUseScreenBuffer = 1 << 5
-hintsAllowInterlace = 1 << 6
-hintsUseSoundInterp = 1 << 7
-hintsHighQuality = 1 << 8
-hintsPalindrome = 1 << 9
-hintsInactive = 1 << 11
-hintsOffscreen = 1 << 12
-hintsDontDraw = 1 << 13
-hintsAllowBlacklining = 1 << 14
-hintsDontUseVideoOverlaySurface = 1 << 16
-hintsIgnoreBandwidthRestrictions = 1 << 17
-hintsPlayingEveryFrame = 1 << 18
-hintsAllowDynamicResize = 1 << 19
-hintsSingleField = 1 << 20
-hintsNoRenderingTimeOut = 1 << 21
-hintsFlushVideoInsteadOfDirtying = 1 << 22
-hintsEnableSubPixelPositioning = 1L << 23
-mediaHandlerFlagBaseClient = 1
-movieTrackMediaType = 1 << 0
-movieTrackCharacteristic = 1 << 1
-movieTrackEnabledOnly = 1 << 2
-kMovieControlOptionHideController = (1L << 0)
-kMovieControlOptionLocateTopLeft = (1L << 1)
-kMovieControlOptionEnableEditing = (1L << 2)
-kMovieControlOptionHandleEditingHI = (1L << 3)
-kMovieControlOptionSetKeysEnabled = (1L << 4)
-kMovieControlOptionManuallyIdled = (1L << 5)
-kMovieControlDataMovieController = FOUR_CHAR_CODE('mc ')
-kMovieControlDataMovie = FOUR_CHAR_CODE('moov')
-kMovieControlDataManualIdling = FOUR_CHAR_CODE('manu')
-movieDrawingCallWhenChanged = 0
-movieDrawingCallAlways = 1
-kQTCloneShareSamples = 1 << 0
-kQTCloneDontCopyEdits = 1 << 1
-kGetMovieImporterValidateToFind = 1L << 0
-kGetMovieImporterAllowNewFile = 1L << 1
-kGetMovieImporterDontConsiderGraphicsImporters = 1L << 2
-kGetMovieImporterDontConsiderFileOnlyImporters = 1L << 6
-kGetMovieImporterAutoImportOnly = 1L << 10
-kQTGetMIMETypeInfoIsQuickTimeMovieType = FOUR_CHAR_CODE('moov')
-kQTGetMIMETypeInfoIsUnhelpfulType = FOUR_CHAR_CODE('dumb')
-kQTCopyUserDataReplace = FOUR_CHAR_CODE('rplc')
-kQTCopyUserDataMerge = FOUR_CHAR_CODE('merg')
-kMovieLoadStateError = -1L
-kMovieLoadStateLoading = 1000
-kMovieLoadStateLoaded = 2000
-kMovieLoadStatePlayable = 10000
-kMovieLoadStatePlaythroughOK = 20000
-kMovieLoadStateComplete = 100000L
-kQTDontUseDataToFindImporter = 1L << 0
-kQTDontLookForMovieImporterIfGraphicsImporterFound = 1L << 1
-kQTAllowOpeningStillImagesAsMovies = 1L << 2
-kQTAllowImportersThatWouldCreateNewFile = 1L << 3
-kQTAllowAggressiveImporters = 1L << 4
-preloadAlways = 1L << 0
-preloadOnlyIfEnabled = 1L << 1
-fullScreenHideCursor = 1L << 0
-fullScreenAllowEvents = 1L << 1
-fullScreenDontChangeMenuBar = 1L << 2
-fullScreenPreflightSize = 1L << 3
-movieExecuteWiredActionDontExecute = 1L << 0
-kRefConNavigationNext = 0
-kRefConNavigationPrevious = 1
-kRefConPropertyCanHaveFocus = 1
-kRefConPropertyHasFocus = 2
-kTrackFocusCanEditFlag = FOUR_CHAR_CODE('kedt')
-kTrackDefaultFocusFlags = FOUR_CHAR_CODE('kfoc')
-kTrackFocusDefaultRefcon = FOUR_CHAR_CODE('kref')
-kTrackFocusOn = 1
-kTrackHandlesTabs = 2
-kFlashTrackPropertyAcceptAllClicks = FOUR_CHAR_CODE('clik')
-kBackgroundSpriteLayerNum = 32767
-kSpritePropertyMatrix = 1
-kSpritePropertyImageDescription = 2
-kSpritePropertyImageDataPtr = 3
-kSpritePropertyVisible = 4
-kSpritePropertyLayer = 5
-kSpritePropertyGraphicsMode = 6
-kSpritePropertyImageDataSize = 7
-kSpritePropertyActionHandlingSpriteID = 8
-kSpritePropertyCanBeHitTested = 9
-kSpritePropertyImageIndex = 100
-kSpriteTrackPropertyBackgroundColor = 101
-kSpriteTrackPropertyOffscreenBitDepth = 102
-kSpriteTrackPropertySampleFormat = 103
-kSpriteTrackPropertyScaleSpritesToScaleWorld = 104
-kSpriteTrackPropertyHasActions = 105
-kSpriteTrackPropertyVisible = 106
-kSpriteTrackPropertyQTIdleEventsFrequency = 107
-kSpriteTrackPropertyAllSpritesHitTestingMode = 108
-kSpriteTrackPropertyPreferredDepthInterpretationMode = 109
-kSpriteImagePropertyRegistrationPoint = 1000
-kSpriteImagePropertyGroupID = 1001
-kSpriteTrackPreferredDepthCompatibilityMode = 0
-kSpriteTrackPreferredDepthModernMode = 1
-kSpriteHitTestUseSpritesOwnPropertiesMode = 0
-kSpriteHitTestTreatAllSpritesAsHitTestableMode = 1
-kSpriteHitTestTreatAllSpritesAsNotHitTestableMode = 2
-kNoQTIdleEvents = -1
-kGetSpriteWorldInvalidRegionAndLeaveIntact = -1L
-kGetSpriteWorldInvalidRegionAndThenSetEmpty = -2L
-kOnlyDrawToSpriteWorld = 1L << 0
-kSpriteWorldPreflight = 1L << 1
-kSpriteWorldDidDraw = 1L << 0
-kSpriteWorldNeedsToDraw = 1L << 1
-kKeyFrameAndSingleOverride = 1L << 1
-kKeyFrameAndAllOverrides = 1L << 2
-kScaleSpritesToScaleWorld = 1L << 1
-kSpriteWorldHighQuality = 1L << 2
-kSpriteWorldDontAutoInvalidate = 1L << 3
-kSpriteWorldInvisible = 1L << 4
-kSpriteWorldDirtyInsteadOfFlush = 1L << 5
-kParentAtomIsContainer = 0
-kTweenRecordNoFlags = 0
-kTweenRecordIsAtInterruptTime = 0x00000001
-kEffectNameAtom = FOUR_CHAR_CODE('name')
-kEffectTypeAtom = FOUR_CHAR_CODE('type')
-kEffectManufacturerAtom = FOUR_CHAR_CODE('manu')
-pdActionConfirmDialog = 1
-pdActionSetAppleMenu = 2
-pdActionSetEditMenu = 3
-pdActionGetDialogValues = 4
-pdActionSetPreviewUserItem = 5
-pdActionSetPreviewPicture = 6
-pdActionSetColorPickerEventProc = 7
-pdActionSetDialogTitle = 8
-pdActionGetSubPanelMenu = 9
-pdActionActivateSubPanel = 10
-pdActionConductStopAlert = 11
-pdActionModelessCallback = 12
-pdActionFetchPreview = 13
-pdActionSetDialogSettings = 14
-pdActionGetDialogSettings = 15
-pdActionGetNextSample = 16
-pdActionGetPreviousSample = 17
-pdActionCompactSample = 18
-pdActionSetEditCallout = 19
-pdActionSetSampleTime = 20
-pdActionDoEditCommand = 21
-pdActionGetSubPanelMenuValue = 22
-pdActionCustomNewControl = 23
-pdActionCustomDisposeControl = 24
-pdActionCustomPositionControl = 25
-pdActionCustomShowHideControl = 26
-pdActionCustomHandleEvent = 27
-pdActionCustomSetFocus = 28
-pdActionCustomSetEditMenu = 29
-pdActionCustomSetPreviewPicture = 30
-pdActionCustomSetEditCallout = 31
-pdActionCustomGetEnableValue = 32
-pdActionCustomSetSampleTime = 33
-pdActionCustomGetValue = 34
-pdActionCustomDoEditCommand = 35
-pdSampleTimeDisplayOptionsNone = 0x00000000
-pdActionFocusOff = 0
-pdActionFocusFirst = 1
-pdActionFocusLast = 2
-pdActionFocusForward = 3
-pdActionFocusBackward = 4
-elOptionsIncludeNoneInList = 0x00000001
-pdOptionsCollectOneValue = 0x00000001
-pdOptionsAllowOptionalInterpolations = 0x00000002
-pdOptionsModalDialogBox = 0x00000004
-pdOptionsEditCurrentEffectOnly = 0x00000008
-pdOptionsHidePreview = 0x00000010
-effectIsRealtime = 0
-kAccessKeyAtomType = FOUR_CHAR_CODE('acky')
-kAccessKeySystemFlag = 1L << 0
-ConnectionSpeedPrefsType = FOUR_CHAR_CODE('cspd')
-BandwidthManagementPrefsType = FOUR_CHAR_CODE('bwmg')
-kQTIdlePriority = 10
-kQTNonRealTimePriority = 20
-kQTRealTimeSharedPriority = 25
-kQTRealTimePriority = 30
-kQTBandwidthNotifyNeedToStop = 1L << 0
-kQTBandwidthNotifyGoodToGo = 1L << 1
-kQTBandwidthChangeRequest = 1L << 2
-kQTBandwidthQueueRequest = 1L << 3
-kQTBandwidthScheduledRequest = 1L << 4
-kQTBandwidthVoluntaryRelease = 1L << 5
-kITextRemoveEverythingBut = 0 << 1
-kITextRemoveLeaveSuggestedAlternate = 1 << 1
-kITextAtomType = FOUR_CHAR_CODE('itxt')
-kITextStringAtomType = FOUR_CHAR_CODE('text')
-kQTParseTextHREFText = FOUR_CHAR_CODE('text')
-kQTParseTextHREFBaseURL = FOUR_CHAR_CODE('burl')
-kQTParseTextHREFClickPoint = FOUR_CHAR_CODE('clik')
-kQTParseTextHREFUseAltDelim = FOUR_CHAR_CODE('altd')
-kQTParseTextHREFDelimiter = FOUR_CHAR_CODE('delm')
-kQTParseTextHREFRecomposeHREF = FOUR_CHAR_CODE('rhrf')
-kQTParseTextHREFURL = FOUR_CHAR_CODE('url ')
-kQTParseTextHREFTarget = FOUR_CHAR_CODE('targ')
-kQTParseTextHREFChapter = FOUR_CHAR_CODE('chap')
-kQTParseTextHREFIsAutoHREF = FOUR_CHAR_CODE('auto')
-kQTParseTextHREFIsServerMap = FOUR_CHAR_CODE('smap')
-kQTParseTextHREFHREF = FOUR_CHAR_CODE('href')
-kQTParseTextHREFEMBEDArgs = FOUR_CHAR_CODE('mbed')
-kTrackReferenceChapterList = FOUR_CHAR_CODE('chap')
-kTrackReferenceTimeCode = FOUR_CHAR_CODE('tmcd')
-kTrackReferenceModifier = FOUR_CHAR_CODE('ssrc')
-kTrackModifierInput = 0x696E
-kTrackModifierType = 0x7479
-kTrackModifierReference = FOUR_CHAR_CODE('ssrc')
-kTrackModifierObjectID = FOUR_CHAR_CODE('obid')
-kTrackModifierInputName = FOUR_CHAR_CODE('name')
-kInputMapSubInputID = FOUR_CHAR_CODE('subi')
-kTrackModifierTypeMatrix = 1
-kTrackModifierTypeClip = 2
-kTrackModifierTypeGraphicsMode = 5
-kTrackModifierTypeVolume = 3
-kTrackModifierTypeBalance = 4
-kTrackModifierTypeImage = FOUR_CHAR_CODE('vide')
-kTrackModifierObjectMatrix = 6
-kTrackModifierObjectGraphicsMode = 7
-kTrackModifierType3d4x4Matrix = 8
-kTrackModifierCameraData = 9
-kTrackModifierSoundLocalizationData = 10
-kTrackModifierObjectImageIndex = 11
-kTrackModifierObjectLayer = 12
-kTrackModifierObjectVisible = 13
-kTrackModifierAngleAspectCamera = 14
-kTrackModifierPanAngle = FOUR_CHAR_CODE('pan ')
-kTrackModifierTiltAngle = FOUR_CHAR_CODE('tilt')
-kTrackModifierVerticalFieldOfViewAngle = FOUR_CHAR_CODE('fov ')
-kTrackModifierObjectQTEventSend = FOUR_CHAR_CODE('evnt')
-kTrackModifierObjectCanBeHitTested = 15
-kTweenTypeShort = 1
-kTweenTypeLong = 2
-kTweenTypeFixed = 3
-kTweenTypePoint = 4
-kTweenTypeQDRect = 5
-kTweenTypeQDRegion = 6
-kTweenTypeMatrix = 7
-kTweenTypeRGBColor = 8
-kTweenTypeGraphicsModeWithRGBColor = 9
-kTweenTypeQTFloatSingle = 10
-kTweenTypeQTFloatDouble = 11
-kTweenTypeFixedPoint = 12
-kTweenType3dScale = FOUR_CHAR_CODE('3sca')
-kTweenType3dTranslate = FOUR_CHAR_CODE('3tra')
-kTweenType3dRotate = FOUR_CHAR_CODE('3rot')
-kTweenType3dRotateAboutPoint = FOUR_CHAR_CODE('3rap')
-kTweenType3dRotateAboutAxis = FOUR_CHAR_CODE('3rax')
-kTweenType3dRotateAboutVector = FOUR_CHAR_CODE('3rvc')
-kTweenType3dQuaternion = FOUR_CHAR_CODE('3qua')
-kTweenType3dMatrix = FOUR_CHAR_CODE('3mat')
-kTweenType3dCameraData = FOUR_CHAR_CODE('3cam')
-kTweenType3dAngleAspectCameraData = FOUR_CHAR_CODE('3caa')
-kTweenType3dSoundLocalizationData = FOUR_CHAR_CODE('3slc')
-kTweenTypePathToMatrixTranslation = FOUR_CHAR_CODE('gxmt')
-kTweenTypePathToMatrixRotation = FOUR_CHAR_CODE('gxpr')
-kTweenTypePathToMatrixTranslationAndRotation = FOUR_CHAR_CODE('gxmr')
-kTweenTypePathToFixedPoint = FOUR_CHAR_CODE('gxfp')
-kTweenTypePathXtoY = FOUR_CHAR_CODE('gxxy')
-kTweenTypePathYtoX = FOUR_CHAR_CODE('gxyx')
-kTweenTypeAtomList = FOUR_CHAR_CODE('atom')
-kTweenTypePolygon = FOUR_CHAR_CODE('poly')
-kTweenTypeMultiMatrix = FOUR_CHAR_CODE('mulm')
-kTweenTypeSpin = FOUR_CHAR_CODE('spin')
-kTweenType3dMatrixNonLinear = FOUR_CHAR_CODE('3nlr')
-kTweenType3dVRObject = FOUR_CHAR_CODE('3vro')
-kTweenEntry = FOUR_CHAR_CODE('twen')
-kTweenData = FOUR_CHAR_CODE('data')
-kTweenType = FOUR_CHAR_CODE('twnt')
-kTweenStartOffset = FOUR_CHAR_CODE('twst')
-kTweenDuration = FOUR_CHAR_CODE('twdu')
-kTweenFlags = FOUR_CHAR_CODE('flag')
-kTweenOutputMin = FOUR_CHAR_CODE('omin')
-kTweenOutputMax = FOUR_CHAR_CODE('omax')
-kTweenSequenceElement = FOUR_CHAR_CODE('seqe')
-kTween3dInitialCondition = FOUR_CHAR_CODE('icnd')
-kTweenInterpolationID = FOUR_CHAR_CODE('intr')
-kTweenRegionData = FOUR_CHAR_CODE('qdrg')
-kTweenPictureData = FOUR_CHAR_CODE('PICT')
-kListElementType = FOUR_CHAR_CODE('type')
-kListElementDataType = FOUR_CHAR_CODE('daty')
-kNameAtom = FOUR_CHAR_CODE('name')
-kInitialRotationAtom = FOUR_CHAR_CODE('inro')
-kNonLinearTweenHeader = FOUR_CHAR_CODE('nlth')
-kTweenReturnDelta = 1L << 0
-kQTRestrictionClassSave = FOUR_CHAR_CODE('save')
-kQTRestrictionSaveDontAddMovieResource = (1L << 0)
-kQTRestrictionSaveDontFlatten = (1L << 1)
-kQTRestrictionSaveDontExport = (1L << 2)
-kQTRestrictionSaveDontExtract = (1L << 3)
-kQTRestrictionClassEdit = FOUR_CHAR_CODE('edit')
-kQTRestrictionEditDontCopy = (1L << 0)
-kQTRestrictionEditDontCut = (1L << 1)
-kQTRestrictionEditDontPaste = (1L << 2)
-kQTRestrictionEditDontClear = (1L << 3)
-kQTRestrictionEditDontModify = (1L << 4)
-kQTRestrictionEditDontExtract = (1L << 5)
-videoFlagDontLeanAhead = 1L << 0
-txtProcDefaultDisplay = 0
-txtProcDontDisplay = 1
-txtProcDoDisplay = 2
-findTextEdgeOK = 1 << 0
-findTextCaseSensitive = 1 << 1
-findTextReverseSearch = 1 << 2
-findTextWrapAround = 1 << 3
-findTextUseOffset = 1 << 4
-dropShadowOffsetType = FOUR_CHAR_CODE('drpo')
-dropShadowTranslucencyType = FOUR_CHAR_CODE('drpt')
-spriteHitTestBounds = 1L << 0
-spriteHitTestImage = 1L << 1
-spriteHitTestInvisibleSprites = 1L << 2
-spriteHitTestIsClick = 1L << 3
-spriteHitTestLocInDisplayCoordinates = 1L << 4
-spriteHitTestTreatAllSpritesAsHitTestable = 1L << 5
-kSpriteAtomType = FOUR_CHAR_CODE('sprt')
-kSpriteImagesContainerAtomType = FOUR_CHAR_CODE('imct')
-kSpriteImageAtomType = FOUR_CHAR_CODE('imag')
-kSpriteImageDataAtomType = FOUR_CHAR_CODE('imda')
-kSpriteImageDataRefAtomType = FOUR_CHAR_CODE('imre')
-kSpriteImageDataRefTypeAtomType = FOUR_CHAR_CODE('imrt')
-kSpriteImageGroupIDAtomType = FOUR_CHAR_CODE('imgr')
-kSpriteImageRegistrationAtomType = FOUR_CHAR_CODE('imrg')
-kSpriteImageDefaultImageIndexAtomType = FOUR_CHAR_CODE('defi')
-kSpriteSharedDataAtomType = FOUR_CHAR_CODE('dflt')
-kSpriteNameAtomType = FOUR_CHAR_CODE('name')
-kSpriteImageNameAtomType = FOUR_CHAR_CODE('name')
-kSpriteUsesImageIDsAtomType = FOUR_CHAR_CODE('uses')
-kSpriteBehaviorsAtomType = FOUR_CHAR_CODE('beha')
-kSpriteImageBehaviorAtomType = FOUR_CHAR_CODE('imag')
-kSpriteCursorBehaviorAtomType = FOUR_CHAR_CODE('crsr')
-kSpriteStatusStringsBehaviorAtomType = FOUR_CHAR_CODE('sstr')
-kSpriteVariablesContainerAtomType = FOUR_CHAR_CODE('vars')
-kSpriteStringVariableAtomType = FOUR_CHAR_CODE('strv')
-kSpriteFloatingPointVariableAtomType = FOUR_CHAR_CODE('flov')
-kMovieMediaDataReference = FOUR_CHAR_CODE('mmdr')
-kMovieMediaDefaultDataReferenceID = FOUR_CHAR_CODE('ddri')
-kMovieMediaSlaveTime = FOUR_CHAR_CODE('slti')
-kMovieMediaSlaveAudio = FOUR_CHAR_CODE('slau')
-kMovieMediaSlaveGraphicsMode = FOUR_CHAR_CODE('slgr')
-kMovieMediaAutoPlay = FOUR_CHAR_CODE('play')
-kMovieMediaLoop = FOUR_CHAR_CODE('loop')
-kMovieMediaUseMIMEType = FOUR_CHAR_CODE('mime')
-kMovieMediaTitle = FOUR_CHAR_CODE('titl')
-kMovieMediaAltText = FOUR_CHAR_CODE('altt')
-kMovieMediaClipBegin = FOUR_CHAR_CODE('clpb')
-kMovieMediaClipDuration = FOUR_CHAR_CODE('clpd')
-kMovieMediaRegionAtom = FOUR_CHAR_CODE('regi')
-kMovieMediaSlaveTrackDuration = FOUR_CHAR_CODE('sltr')
-kMovieMediaEnableFrameStepping = FOUR_CHAR_CODE('enfs')
-kMovieMediaBackgroundColor = FOUR_CHAR_CODE('bkcl')
-kMovieMediaPrerollTime = FOUR_CHAR_CODE('prer')
-kMovieMediaFitNone = 0
-kMovieMediaFitScroll = FOUR_CHAR_CODE('scro')
-kMovieMediaFitClipIfNecessary = FOUR_CHAR_CODE('hidd')
-kMovieMediaFitFill = FOUR_CHAR_CODE('fill')
-kMovieMediaFitMeet = FOUR_CHAR_CODE('meet')
-kMovieMediaFitSlice = FOUR_CHAR_CODE('slic')
-kMovieMediaSpatialAdjustment = FOUR_CHAR_CODE('fit ')
-kMovieMediaRectangleAtom = FOUR_CHAR_CODE('rect')
-kMovieMediaTop = FOUR_CHAR_CODE('top ')
-kMovieMediaLeft = FOUR_CHAR_CODE('left')
-kMovieMediaWidth = FOUR_CHAR_CODE('wd ')
-kMovieMediaHeight = FOUR_CHAR_CODE('ht ')
-kMoviePropertyDuration = FOUR_CHAR_CODE('dura')
-kMoviePropertyTimeScale = FOUR_CHAR_CODE('tims')
-kMoviePropertyTime = FOUR_CHAR_CODE('timv')
-kMoviePropertyNaturalBounds = FOUR_CHAR_CODE('natb')
-kMoviePropertyMatrix = FOUR_CHAR_CODE('mtrx')
-kMoviePropertyTrackList = FOUR_CHAR_CODE('tlst')
-kTrackPropertyMediaType = FOUR_CHAR_CODE('mtyp')
-kTrackPropertyInstantiation = FOUR_CHAR_CODE('inst')
-MovieControllerComponentType = FOUR_CHAR_CODE('play')
-kMovieControllerQTVRFlag = 1 << 0
-kMovieControllerDontDisplayToUser = 1 << 1
-mcActionIdle = 1
-mcActionDraw = 2
-mcActionActivate = 3
-mcActionDeactivate = 4
-mcActionMouseDown = 5
-mcActionKey = 6
-mcActionPlay = 8
-mcActionGoToTime = 12
-mcActionSetVolume = 14
-mcActionGetVolume = 15
-mcActionStep = 18
-mcActionSetLooping = 21
-mcActionGetLooping = 22
-mcActionSetLoopIsPalindrome = 23
-mcActionGetLoopIsPalindrome = 24
-mcActionSetGrowBoxBounds = 25
-mcActionControllerSizeChanged = 26
-mcActionSetSelectionBegin = 29
-mcActionSetSelectionDuration = 30
-mcActionSetKeysEnabled = 32
-mcActionGetKeysEnabled = 33
-mcActionSetPlaySelection = 34
-mcActionGetPlaySelection = 35
-mcActionSetUseBadge = 36
-mcActionGetUseBadge = 37
-mcActionSetFlags = 38
-mcActionGetFlags = 39
-mcActionSetPlayEveryFrame = 40
-mcActionGetPlayEveryFrame = 41
-mcActionGetPlayRate = 42
-mcActionShowBalloon = 43
-mcActionBadgeClick = 44
-mcActionMovieClick = 45
-mcActionSuspend = 46
-mcActionResume = 47
-mcActionSetControllerKeysEnabled = 48
-mcActionGetTimeSliderRect = 49
-mcActionMovieEdited = 50
-mcActionGetDragEnabled = 51
-mcActionSetDragEnabled = 52
-mcActionGetSelectionBegin = 53
-mcActionGetSelectionDuration = 54
-mcActionPrerollAndPlay = 55
-mcActionGetCursorSettingEnabled = 56
-mcActionSetCursorSettingEnabled = 57
-mcActionSetColorTable = 58
-mcActionLinkToURL = 59
-mcActionCustomButtonClick = 60
-mcActionForceTimeTableUpdate = 61
-mcActionSetControllerTimeLimits = 62
-mcActionExecuteAllActionsForQTEvent = 63
-mcActionExecuteOneActionForQTEvent = 64
-mcActionAdjustCursor = 65
-mcActionUseTrackForTimeTable = 66
-mcActionClickAndHoldPoint = 67
-mcActionShowMessageString = 68
-mcActionShowStatusString = 69
-mcActionGetExternalMovie = 70
-mcActionGetChapterTime = 71
-mcActionPerformActionList = 72
-mcActionEvaluateExpression = 73
-mcActionFetchParameterAs = 74
-mcActionGetCursorByID = 75
-mcActionGetNextURL = 76
-mcActionMovieChanged = 77
-mcActionDoScript = 78
-mcActionRestartAtTime = 79
-mcActionGetIndChapter = 80
-mcActionLinkToURLExtended = 81
-mcActionSetVolumeStep = 82
-mcActionAutoPlay = 83
-mcActionPauseToBuffer = 84
-mcActionAppMessageReceived = 85
-mcActionEvaluateExpressionWithType = 89
-mcActionGetMovieName = 90
-mcActionGetMovieID = 91
-mcActionGetMovieActive = 92
-mcFlagSuppressMovieFrame = 1 << 0
-mcFlagSuppressStepButtons = 1 << 1
-mcFlagSuppressSpeakerButton = 1 << 2
-mcFlagsUseWindowPalette = 1 << 3
-mcFlagsDontInvalidate = 1 << 4
-mcFlagsUseCustomButton = 1 << 5
-mcPositionDontInvalidate = 1 << 5
-kMCIEEnabledButtonPicture = 1
-kMCIEDisabledButtonPicture = 2
-kMCIEDepressedButtonPicture = 3
-kMCIEEnabledSizeBoxPicture = 4
-kMCIEDisabledSizeBoxPicture = 5
-kMCIEEnabledUnavailableButtonPicture = 6
-kMCIEDisabledUnavailableButtonPicture = 7
-kMCIESoundSlider = 128
-kMCIESoundThumb = 129
-kMCIEColorTable = 256
-kMCIEIsFlatAppearance = 257
-kMCIEDoButtonIconsDropOnDepress = 258
-mcInfoUndoAvailable = 1 << 0
-mcInfoCutAvailable = 1 << 1
-mcInfoCopyAvailable = 1 << 2
-mcInfoPasteAvailable = 1 << 3
-mcInfoClearAvailable = 1 << 4
-mcInfoHasSound = 1 << 5
-mcInfoIsPlaying = 1 << 6
-mcInfoIsLooping = 1 << 7
-mcInfoIsInPalindrome = 1 << 8
-mcInfoEditingEnabled = 1 << 9
-mcInfoMovieIsInteractive = 1 << 10
-mcMenuUndo = 1
-mcMenuCut = 3
-mcMenuCopy = 4
-mcMenuPaste = 5
-mcMenuClear = 6
-kQTAppMessageSoftwareChanged = 1
-kQTAppMessageWindowCloseRequested = 3
-kQTAppMessageExitFullScreenRequested = 4
-kQTAppMessageDisplayChannels = 5
-kQTAppMessageEnterFullScreenRequested = 6
-kFetchAsBooleanPtr = 1
-kFetchAsShortPtr = 2
-kFetchAsLongPtr = 3
-kFetchAsMatrixRecordPtr = 4
-kFetchAsModifierTrackGraphicsModeRecord = 5
-kFetchAsHandle = 6
-kFetchAsStr255 = 7
-kFetchAsFloatPtr = 8
-kFetchAsPointPtr = 9
-kFetchAsNewAtomContainer = 10
-kFetchAsQTEventRecordPtr = 11
-kFetchAsFixedPtr = 12
-kFetchAsSetControllerValuePtr = 13
-kFetchAsRgnHandle = 14
-kFetchAsComponentDescriptionPtr = 15
-kFetchAsCString = 16
-kQTCursorOpenHand = -19183
-kQTCursorClosedHand = -19182
-kQTCursorPointingHand = -19181
-kQTCursorRightArrow = -19180
-kQTCursorLeftArrow = -19179
-kQTCursorDownArrow = -19178
-kQTCursorUpArrow = -19177
-kQTCursorIBeam = -19176
-kControllerUnderstandsIdleManagers = 1 << 0
-kVideoMediaResetStatisticsSelect = 0x0105
-kVideoMediaGetStatisticsSelect = 0x0106
-kVideoMediaGetStallCountSelect = 0x010E
-kVideoMediaSetCodecParameterSelect = 0x010F
-kVideoMediaGetCodecParameterSelect = 0x0110
-kTextMediaSetTextProcSelect = 0x0101
-kTextMediaAddTextSampleSelect = 0x0102
-kTextMediaAddTESampleSelect = 0x0103
-kTextMediaAddHiliteSampleSelect = 0x0104
-kTextMediaDrawRawSelect = 0x0109
-kTextMediaSetTextPropertySelect = 0x010A
-kTextMediaRawSetupSelect = 0x010B
-kTextMediaRawIdleSelect = 0x010C
-kTextMediaGetTextPropertySelect = 0x010D
-kTextMediaFindNextTextSelect = 0x0105
-kTextMediaHiliteTextSampleSelect = 0x0106
-kTextMediaSetTextSampleDataSelect = 0x0107
-kSpriteMediaSetPropertySelect = 0x0101
-kSpriteMediaGetPropertySelect = 0x0102
-kSpriteMediaHitTestSpritesSelect = 0x0103
-kSpriteMediaCountSpritesSelect = 0x0104
-kSpriteMediaCountImagesSelect = 0x0105
-kSpriteMediaGetIndImageDescriptionSelect = 0x0106
-kSpriteMediaGetDisplayedSampleNumberSelect = 0x0107
-kSpriteMediaGetSpriteNameSelect = 0x0108
-kSpriteMediaGetImageNameSelect = 0x0109
-kSpriteMediaSetSpritePropertySelect = 0x010A
-kSpriteMediaGetSpritePropertySelect = 0x010B
-kSpriteMediaHitTestAllSpritesSelect = 0x010C
-kSpriteMediaHitTestOneSpriteSelect = 0x010D
-kSpriteMediaSpriteIndexToIDSelect = 0x010E
-kSpriteMediaSpriteIDToIndexSelect = 0x010F
-kSpriteMediaGetSpriteActionsForQTEventSelect = 0x0110
-kSpriteMediaSetActionVariableSelect = 0x0111
-kSpriteMediaGetActionVariableSelect = 0x0112
-kSpriteMediaGetIndImagePropertySelect = 0x0113
-kSpriteMediaNewSpriteSelect = 0x0114
-kSpriteMediaDisposeSpriteSelect = 0x0115
-kSpriteMediaSetActionVariableToStringSelect = 0x0116
-kSpriteMediaGetActionVariableAsStringSelect = 0x0117
-kSpriteMediaNewImageSelect = 0x011B
-kSpriteMediaDisposeImageSelect = 0x011C
-kSpriteMediaImageIndexToIDSelect = 0x011D
-kSpriteMediaImageIDToIndexSelect = 0x011E
-kFlashMediaSetPanSelect = 0x0101
-kFlashMediaSetZoomSelect = 0x0102
-kFlashMediaSetZoomRectSelect = 0x0103
-kFlashMediaGetRefConBoundsSelect = 0x0104
-kFlashMediaGetRefConIDSelect = 0x0105
-kFlashMediaIDToRefConSelect = 0x0106
-kFlashMediaGetDisplayedFrameNumberSelect = 0x0107
-kFlashMediaFrameNumberToMovieTimeSelect = 0x0108
-kFlashMediaFrameLabelToMovieTimeSelect = 0x0109
-kFlashMediaGetFlashVariableSelect = 0x010A
-kFlashMediaSetFlashVariableSelect = 0x010B
-kFlashMediaDoButtonActionsSelect = 0x010C
-kFlashMediaGetSupportedSwfVersionSelect = 0x010D
-kMovieMediaGetChildDoMCActionCallbackSelect = 0x0102
-kMovieMediaGetDoMCActionCallbackSelect = 0x0103
-kMovieMediaGetCurrentMoviePropertySelect = 0x0104
-kMovieMediaGetCurrentTrackPropertySelect = 0x0105
-kMovieMediaGetChildMovieDataReferenceSelect = 0x0106
-kMovieMediaSetChildMovieDataReferenceSelect = 0x0107
-kMovieMediaLoadChildMovieFromDataReferenceSelect = 0x0108
-kMedia3DGetNamedObjectListSelect = 0x0101
-kMedia3DGetRendererListSelect = 0x0102
-kMedia3DGetCurrentGroupSelect = 0x0103
-kMedia3DTranslateNamedObjectToSelect = 0x0104
-kMedia3DScaleNamedObjectToSelect = 0x0105
-kMedia3DRotateNamedObjectToSelect = 0x0106
-kMedia3DSetCameraDataSelect = 0x0107
-kMedia3DGetCameraDataSelect = 0x0108
-kMedia3DSetCameraAngleAspectSelect = 0x0109
-kMedia3DGetCameraAngleAspectSelect = 0x010A
-kMedia3DSetCameraRangeSelect = 0x010D
-kMedia3DGetCameraRangeSelect = 0x010E
-kMedia3DGetViewObjectSelect = 0x010F
-kMCSetMovieSelect = 0x0002
-kMCGetIndMovieSelect = 0x0005
-kMCRemoveAllMoviesSelect = 0x0006
-kMCRemoveAMovieSelect = 0x0003
-kMCRemoveMovieSelect = 0x0006
-kMCIsPlayerEventSelect = 0x0007
-kMCSetActionFilterSelect = 0x0008
-kMCDoActionSelect = 0x0009
-kMCSetControllerAttachedSelect = 0x000A
-kMCIsControllerAttachedSelect = 0x000B
-kMCSetControllerPortSelect = 0x000C
-kMCGetControllerPortSelect = 0x000D
-kMCSetVisibleSelect = 0x000E
-kMCGetVisibleSelect = 0x000F
-kMCGetControllerBoundsRectSelect = 0x0010
-kMCSetControllerBoundsRectSelect = 0x0011
-kMCGetControllerBoundsRgnSelect = 0x0012
-kMCGetWindowRgnSelect = 0x0013
-kMCMovieChangedSelect = 0x0014
-kMCSetDurationSelect = 0x0015
-kMCGetCurrentTimeSelect = 0x0016
-kMCNewAttachedControllerSelect = 0x0017
-kMCDrawSelect = 0x0018
-kMCActivateSelect = 0x0019
-kMCIdleSelect = 0x001A
-kMCKeySelect = 0x001B
-kMCClickSelect = 0x001C
-kMCEnableEditingSelect = 0x001D
-kMCIsEditingEnabledSelect = 0x001E
-kMCCopySelect = 0x001F
-kMCCutSelect = 0x0020
-kMCPasteSelect = 0x0021
-kMCClearSelect = 0x0022
-kMCUndoSelect = 0x0023
-kMCPositionControllerSelect = 0x0024
-kMCGetControllerInfoSelect = 0x0025
-kMCSetClipSelect = 0x0028
-kMCGetClipSelect = 0x0029
-kMCDrawBadgeSelect = 0x002A
-kMCSetUpEditMenuSelect = 0x002B
-kMCGetMenuStringSelect = 0x002C
-kMCSetActionFilterWithRefConSelect = 0x002D
-kMCPtInControllerSelect = 0x002E
-kMCInvalidateSelect = 0x002F
-kMCAdjustCursorSelect = 0x0030
-kMCGetInterfaceElementSelect = 0x0031
-kMCGetDoActionsProcSelect = 0x0032
-kMCAddMovieSegmentSelect = 0x0033
-kMCTrimMovieSegmentSelect = 0x0034
-kMCSetIdleManagerSelect = 0x0035
-kMCSetControllerCapabilitiesSelect = 0x0036
-kMusicMediaGetIndexedTunePlayerSelect = 0x0101
-kRawCodecType = FOUR_CHAR_CODE('raw ')
-kCinepakCodecType = FOUR_CHAR_CODE('cvid')
-kGraphicsCodecType = FOUR_CHAR_CODE('smc ')
-kAnimationCodecType = FOUR_CHAR_CODE('rle ')
-kVideoCodecType = FOUR_CHAR_CODE('rpza')
-kComponentVideoCodecType = FOUR_CHAR_CODE('yuv2')
-kJPEGCodecType = FOUR_CHAR_CODE('jpeg')
-kMotionJPEGACodecType = FOUR_CHAR_CODE('mjpa')
-kMotionJPEGBCodecType = FOUR_CHAR_CODE('mjpb')
-kSGICodecType = FOUR_CHAR_CODE('.SGI')
-kPlanarRGBCodecType = FOUR_CHAR_CODE('8BPS')
-kMacPaintCodecType = FOUR_CHAR_CODE('PNTG')
-kGIFCodecType = FOUR_CHAR_CODE('gif ')
-kPhotoCDCodecType = FOUR_CHAR_CODE('kpcd')
-kQuickDrawGXCodecType = FOUR_CHAR_CODE('qdgx')
-kAVRJPEGCodecType = FOUR_CHAR_CODE('avr ')
-kOpenDMLJPEGCodecType = FOUR_CHAR_CODE('dmb1')
-kBMPCodecType = FOUR_CHAR_CODE('WRLE')
-kWindowsRawCodecType = FOUR_CHAR_CODE('WRAW')
-kVectorCodecType = FOUR_CHAR_CODE('path')
-kQuickDrawCodecType = FOUR_CHAR_CODE('qdrw')
-kWaterRippleCodecType = FOUR_CHAR_CODE('ripl')
-kFireCodecType = FOUR_CHAR_CODE('fire')
-kCloudCodecType = FOUR_CHAR_CODE('clou')
-kH261CodecType = FOUR_CHAR_CODE('h261')
-kH263CodecType = FOUR_CHAR_CODE('h263')
-kDVCNTSCCodecType = FOUR_CHAR_CODE('dvc ')
-kDVCPALCodecType = FOUR_CHAR_CODE('dvcp')
-kDVCProPALCodecType = FOUR_CHAR_CODE('dvpp')
-kBaseCodecType = FOUR_CHAR_CODE('base')
-kFLCCodecType = FOUR_CHAR_CODE('flic')
-kTargaCodecType = FOUR_CHAR_CODE('tga ')
-kPNGCodecType = FOUR_CHAR_CODE('png ')
-kTIFFCodecType = FOUR_CHAR_CODE('tiff')
-kComponentVideoSigned = FOUR_CHAR_CODE('yuvu')
-kComponentVideoUnsigned = FOUR_CHAR_CODE('yuvs')
-kCMYKCodecType = FOUR_CHAR_CODE('cmyk')
-kMicrosoftVideo1CodecType = FOUR_CHAR_CODE('msvc')
-kSorensonCodecType = FOUR_CHAR_CODE('SVQ1')
-kSorenson3CodecType = FOUR_CHAR_CODE('SVQ3')
-kIndeo4CodecType = FOUR_CHAR_CODE('IV41')
-kMPEG4VisualCodecType = FOUR_CHAR_CODE('mp4v')
-k64ARGBCodecType = FOUR_CHAR_CODE('b64a')
-k48RGBCodecType = FOUR_CHAR_CODE('b48r')
-k32AlphaGrayCodecType = FOUR_CHAR_CODE('b32a')
-k16GrayCodecType = FOUR_CHAR_CODE('b16g')
-kMpegYUV420CodecType = FOUR_CHAR_CODE('myuv')
-kYUV420CodecType = FOUR_CHAR_CODE('y420')
-kSorensonYUV9CodecType = FOUR_CHAR_CODE('syv9')
-k422YpCbCr8CodecType = FOUR_CHAR_CODE('2vuy')
-k444YpCbCr8CodecType = FOUR_CHAR_CODE('v308')
-k4444YpCbCrA8CodecType = FOUR_CHAR_CODE('v408')
-k422YpCbCr16CodecType = FOUR_CHAR_CODE('v216')
-k422YpCbCr10CodecType = FOUR_CHAR_CODE('v210')
-k444YpCbCr10CodecType = FOUR_CHAR_CODE('v410')
-k4444YpCbCrA8RCodecType = FOUR_CHAR_CODE('r408')
-kBlurImageFilterType = FOUR_CHAR_CODE('blur')
-kSharpenImageFilterType = FOUR_CHAR_CODE('shrp')
-kEdgeDetectImageFilterType = FOUR_CHAR_CODE('edge')
-kEmbossImageFilterType = FOUR_CHAR_CODE('embs')
-kConvolveImageFilterType = FOUR_CHAR_CODE('genk')
-kAlphaGainImageFilterType = FOUR_CHAR_CODE('gain')
-kRGBColorBalanceImageFilterType = FOUR_CHAR_CODE('rgbb')
-kHSLColorBalanceImageFilterType = FOUR_CHAR_CODE('hslb')
-kColorSyncImageFilterType = FOUR_CHAR_CODE('sync')
-kFilmNoiseImageFilterType = FOUR_CHAR_CODE('fmns')
-kSolarizeImageFilterType = FOUR_CHAR_CODE('solr')
-kColorTintImageFilterType = FOUR_CHAR_CODE('tint')
-kLensFlareImageFilterType = FOUR_CHAR_CODE('lens')
-kBrightnessContrastImageFilterType = FOUR_CHAR_CODE('brco')
-kAlphaCompositorTransitionType = FOUR_CHAR_CODE('blnd')
-kCrossFadeTransitionType = FOUR_CHAR_CODE('dslv')
-kChannelCompositeEffectType = FOUR_CHAR_CODE('chan')
-kChromaKeyTransitionType = FOUR_CHAR_CODE('ckey')
-kImplodeTransitionType = FOUR_CHAR_CODE('mplo')
-kExplodeTransitionType = FOUR_CHAR_CODE('xplo')
-kGradientTransitionType = FOUR_CHAR_CODE('matt')
-kPushTransitionType = FOUR_CHAR_CODE('push')
-kSlideTransitionType = FOUR_CHAR_CODE('slid')
-kWipeTransitionType = FOUR_CHAR_CODE('smpt')
-kIrisTransitionType = FOUR_CHAR_CODE('smp2')
-kRadialTransitionType = FOUR_CHAR_CODE('smp3')
-kMatrixTransitionType = FOUR_CHAR_CODE('smp4')
-kZoomTransitionType = FOUR_CHAR_CODE('zoom')
-kTravellingMatteEffectType = FOUR_CHAR_CODE('trav')
-kCMYKPixelFormat = FOUR_CHAR_CODE('cmyk')
-k64ARGBPixelFormat = FOUR_CHAR_CODE('b64a')
-k48RGBPixelFormat = FOUR_CHAR_CODE('b48r')
-k32AlphaGrayPixelFormat = FOUR_CHAR_CODE('b32a')
-k16GrayPixelFormat = FOUR_CHAR_CODE('b16g')
-k422YpCbCr8PixelFormat = FOUR_CHAR_CODE('2vuy')
-k4444YpCbCrA8PixelFormat = FOUR_CHAR_CODE('v408')
-k4444YpCbCrA8RPixelFormat = FOUR_CHAR_CODE('r408')
-kYUV420PixelFormat = FOUR_CHAR_CODE('y420')
-codecInfoDoes1 = (1L << 0)
-codecInfoDoes2 = (1L << 1)
-codecInfoDoes4 = (1L << 2)
-codecInfoDoes8 = (1L << 3)
-codecInfoDoes16 = (1L << 4)
-codecInfoDoes32 = (1L << 5)
-codecInfoDoesDither = (1L << 6)
-codecInfoDoesStretch = (1L << 7)
-codecInfoDoesShrink = (1L << 8)
-codecInfoDoesMask = (1L << 9)
-codecInfoDoesTemporal = (1L << 10)
-codecInfoDoesDouble = (1L << 11)
-codecInfoDoesQuad = (1L << 12)
-codecInfoDoesHalf = (1L << 13)
-codecInfoDoesQuarter = (1L << 14)
-codecInfoDoesRotate = (1L << 15)
-codecInfoDoesHorizFlip = (1L << 16)
-codecInfoDoesVertFlip = (1L << 17)
-codecInfoHasEffectParameterList = (1L << 18)
-codecInfoDoesBlend = (1L << 19)
-codecInfoDoesWarp = (1L << 20)
-codecInfoDoesRecompress = (1L << 21)
-codecInfoDoesSpool = (1L << 22)
-codecInfoDoesRateConstrain = (1L << 23)
-codecInfoDepth1 = (1L << 0)
-codecInfoDepth2 = (1L << 1)
-codecInfoDepth4 = (1L << 2)
-codecInfoDepth8 = (1L << 3)
-codecInfoDepth16 = (1L << 4)
-codecInfoDepth32 = (1L << 5)
-codecInfoDepth24 = (1L << 6)
-codecInfoDepth33 = (1L << 7)
-codecInfoDepth34 = (1L << 8)
-codecInfoDepth36 = (1L << 9)
-codecInfoDepth40 = (1L << 10)
-codecInfoStoresClut = (1L << 11)
-codecInfoDoesLossless = (1L << 12)
-codecInfoSequenceSensitive = (1L << 13)
-codecFlagUseImageBuffer = (1L << 0)
-codecFlagUseScreenBuffer = (1L << 1)
-codecFlagUpdatePrevious = (1L << 2)
-codecFlagNoScreenUpdate = (1L << 3)
-codecFlagWasCompressed = (1L << 4)
-codecFlagDontOffscreen = (1L << 5)
-codecFlagUpdatePreviousComp = (1L << 6)
-codecFlagForceKeyFrame = (1L << 7)
-codecFlagOnlyScreenUpdate = (1L << 8)
-codecFlagLiveGrab = (1L << 9)
-codecFlagDiffFrame = (1L << 9)
-codecFlagDontUseNewImageBuffer = (1L << 10)
-codecFlagInterlaceUpdate = (1L << 11)
-codecFlagCatchUpDiff = (1L << 12)
-codecFlagSupportDisable = (1L << 13)
-codecFlagReenable = (1L << 14)
-codecFlagOutUpdateOnNextIdle = (1L << 9)
-codecFlagOutUpdateOnDataSourceChange = (1L << 10)
-codecFlagSequenceSensitive = (1L << 11)
-codecFlagOutUpdateOnTimeChange = (1L << 12)
-codecFlagImageBufferNotSourceImage = (1L << 13)
-codecFlagUsedNewImageBuffer = (1L << 14)
-codecFlagUsedImageBuffer = (1L << 15)
-codecMinimumDataSize = 32768L
-compressorComponentType = FOUR_CHAR_CODE('imco')
-decompressorComponentType = FOUR_CHAR_CODE('imdc')
-codecLosslessQuality = 0x00000400
-codecMaxQuality = 0x000003FF
-codecMinQuality = 0x00000000
-codecLowQuality = 0x00000100
-codecNormalQuality = 0x00000200
-codecHighQuality = 0x00000300
-codecLockBitsShieldCursor = (1 << 0)
-codecCompletionSource = (1 << 0)
-codecCompletionDest = (1 << 1)
-codecCompletionDontUnshield = (1 << 2)
-codecCompletionWentOffscreen = (1 << 3)
-codecCompletionUnlockBits = (1 << 4)
-codecCompletionForceChainFlush = (1 << 5)
-codecCompletionDropped = (1 << 6)
-codecProgressOpen = 0
-codecProgressUpdatePercent = 1
-codecProgressClose = 2
-defaultDither = 0
-forceDither = 1
-suppressDither = 2
-useColorMatching = 4
-callStdBits = 1
-callOldBits = 2
-noDefaultOpcodes = 4
-graphicsModeStraightAlpha = 256
-graphicsModePreWhiteAlpha = 257
-graphicsModePreBlackAlpha = 258
-graphicsModeComposition = 259
-graphicsModeStraightAlphaBlend = 260
-graphicsModePreMulColorAlpha = 261
-evenField1ToEvenFieldOut = 1 << 0
-evenField1ToOddFieldOut = 1 << 1
-oddField1ToEvenFieldOut = 1 << 2
-oddField1ToOddFieldOut = 1 << 3
-evenField2ToEvenFieldOut = 1 << 4
-evenField2ToOddFieldOut = 1 << 5
-oddField2ToEvenFieldOut = 1 << 6
-oddField2ToOddFieldOut = 1 << 7
-icmFrameTimeHasVirtualStartTimeAndDuration = 1 << 0
-codecDSequenceDisableOverlaySurface = (1L << 5)
-codecDSequenceSingleField = (1L << 6)
-codecDSequenceBidirectionalPrediction = (1L << 7)
-codecDSequenceFlushInsteadOfDirtying = (1L << 8)
-codecDSequenceEnableSubPixelPositioning = (1L << 9)
-kICMSequenceTaskWeight = FOUR_CHAR_CODE('twei')
-kICMSequenceTaskName = FOUR_CHAR_CODE('tnam')
-kICMSequenceUserPreferredCodecs = FOUR_CHAR_CODE('punt')
-kImageDescriptionSampleFormat = FOUR_CHAR_CODE('idfm')
-kImageDescriptionClassicAtomFormat = FOUR_CHAR_CODE('atom')
-kImageDescriptionQTAtomFormat = FOUR_CHAR_CODE('qtat')
-kImageDescriptionEffectDataFormat = FOUR_CHAR_CODE('fxat')
-kImageDescriptionPrivateDataFormat = FOUR_CHAR_CODE('priv')
-kImageDescriptionAlternateCodec = FOUR_CHAR_CODE('subs')
-kImageDescriptionColorSpace = FOUR_CHAR_CODE('cspc')
-sfpItemPreviewAreaUser = 11
-sfpItemPreviewStaticText = 12
-sfpItemPreviewDividerUser = 13
-sfpItemCreatePreviewButton = 14
-sfpItemShowPreviewButton = 15
-kICMPixelFormatIsPlanarMask = 0x0F
-kICMPixelFormatIsIndexed = (1L << 4)
-kICMPixelFormatIsSupportedByQD = (1L << 5)
-kICMPixelFormatIsMonochrome = (1L << 6)
-kICMPixelFormatHasAlphaChannel = (1L << 7)
-kICMGetChainUltimateParent = 0
-kICMGetChainParent = 1
-kICMGetChainChild = 2
-kICMGetChainUltimateChild = 3
-kDontUseValidateToFindGraphicsImporter = 1L << 0
-kICMTempThenAppMemory = 1L << 12
-kICMAppThenTempMemory = 1L << 13
-kQTUsePlatformDefaultGammaLevel = 0
-kQTUseSourceGammaLevel = -1L
-kQTCCIR601VideoGammaLevel = 0x00023333
-identityMatrixType = 0x00
-translateMatrixType = 0x01
-scaleMatrixType = 0x02
-scaleTranslateMatrixType = 0x03
-linearMatrixType = 0x04
-linearTranslateMatrixType = 0x05
-perspectiveMatrixType = 0x06
-GraphicsImporterComponentType = FOUR_CHAR_CODE('grip')
-graphicsImporterUsesImageDecompressor = 1L << 23
-quickTimeImageFileImageDescriptionAtom = FOUR_CHAR_CODE('idsc')
-quickTimeImageFileImageDataAtom = FOUR_CHAR_CODE('idat')
-quickTimeImageFileMetaDataAtom = FOUR_CHAR_CODE('meta')
-quickTimeImageFileColorSyncProfileAtom = FOUR_CHAR_CODE('iicc')
-graphicsImporterDrawsAllPixels = 0
-graphicsImporterDoesntDrawAllPixels = 1
-graphicsImporterDontKnowIfDrawAllPixels = 2
-kGraphicsImporterDontDoGammaCorrection = 1L << 0
-kGraphicsImporterTrustResolutionFromFile = 1L << 1
-kGraphicsImporterEnableSubPixelPositioning = 1L << 2
-kGraphicsExportGroup = FOUR_CHAR_CODE('expo')
-kGraphicsExportFileType = FOUR_CHAR_CODE('ftyp')
-kGraphicsExportMIMEType = FOUR_CHAR_CODE('mime')
-kGraphicsExportExtension = FOUR_CHAR_CODE('ext ')
-kGraphicsExportDescription = FOUR_CHAR_CODE('desc')
-kQTPhotoshopLayerMode = FOUR_CHAR_CODE('lmod')
-kQTPhotoshopLayerOpacity = FOUR_CHAR_CODE('lopa')
-kQTPhotoshopLayerClipping = FOUR_CHAR_CODE('lclp')
-kQTPhotoshopLayerFlags = FOUR_CHAR_CODE('lflg')
-kQTPhotoshopLayerName = FOUR_CHAR_CODE('\xa9lnm')
-kQTPhotoshopLayerUnicodeName = FOUR_CHAR_CODE('luni')
-kQTIndexedImageType = FOUR_CHAR_CODE('nth?')
-kQTIndexedImageIsThumbnail = FOUR_CHAR_CODE('n=th')
-kQTIndexedImageIsLayer = FOUR_CHAR_CODE('n=ly')
-kQTIndexedImageIsPage = FOUR_CHAR_CODE('n=pg')
-kQTIndexedImageIsMultiResolution = FOUR_CHAR_CODE('n=rs')
-kQTTIFFUserDataPrefix = 0x74690000
-kQTTIFFExifUserDataPrefix = 0x65780000
-kQTTIFFExifGPSUserDataPrefix = 0x67700000
-kQTAlphaMode = FOUR_CHAR_CODE('almo')
-kQTAlphaModePreMulColor = FOUR_CHAR_CODE('almp')
-kUserDataIPTC = FOUR_CHAR_CODE('iptc')
-kQTTIFFUserDataOrientation = 0x74690112
-kQTTIFFUserDataTransferFunction = 0x7469012D
-kQTTIFFUserDataWhitePoint = 0x7469013E
-kQTTIFFUserDataPrimaryChromaticities = 0x7469013F
-kQTTIFFUserDataTransferRange = 0x74690156
-kQTTIFFUserDataYCbCrPositioning = 0x74690213
-kQTTIFFUserDataReferenceBlackWhite = 0x74690214
-kQTTIFFUserDataModelPixelScale = 0x7469830E
-kQTTIFFUserDataModelTransformation = 0x746985D8
-kQTTIFFUserDataModelTiepoint = 0x74698482
-kQTTIFFUserDataGeoKeyDirectory = 0x746987AF
-kQTTIFFUserDataGeoDoubleParams = 0x746987B0
-kQTTIFFUserDataGeoAsciiParams = 0x746987B1
-kQTTIFFUserDataIntergraphMatrix = 0x74698480
-kQTExifUserDataExifVersion = 0x65789000
-kQTExifUserDataFlashPixVersion = 0x6578A000
-kQTExifUserDataColorSpace = 0x6578A001
-kQTExifUserDataComponentsConfiguration = 0x65789101
-kQTExifUserDataCompressedBitsPerPixel = 0x65789102
-kQTExifUserDataPixelXDimension = 0x6578A002
-kQTExifUserDataPixelYDimension = 0x6578A003
-kQTExifUserDataMakerNote = 0x6578927C
-kQTExifUserDataUserComment = 0x6578928C
-kQTExifUserDataRelatedSoundFile = 0x6578A004
-kQTExifUserDataDateTimeOriginal = 0x65789003
-kQTExifUserDataDateTimeDigitized = 0x65789004
-kQTExifUserDataSubSecTime = 0x65789290
-kQTExifUserDataSubSecTimeOriginal = 0x65789291
-kQTExifUserDataSubSecTimeDigitized = 0x65789292
-kQTExifUserDataExposureTime = 0x6578829A
-kQTExifUserDataFNumber = 0x6578829D
-kQTExifUserDataExposureProgram = 0x65788822
-kQTExifUserDataSpectralSensitivity = 0x65788824
-kQTExifUserDataISOSpeedRatings = 0x65788827
-kQTExifUserDataShutterSpeedValue = 0x65789201
-kQTExifUserDataApertureValue = 0x65789202
-kQTExifUserDataBrightnessValue = 0x65789203
-kQTExifUserDataExposureBiasValue = 0x65789204
-kQTExifUserDataMaxApertureValue = 0x65789205
-kQTExifUserDataSubjectDistance = 0x65789206
-kQTExifUserDataMeteringMode = 0x65789207
-kQTExifUserDataLightSource = 0x65789208
-kQTExifUserDataFlash = 0x65789209
-kQTExifUserDataFocalLength = 0x6578920A
-kQTExifUserDataFlashEnergy = 0x6578A20B
-kQTExifUserDataFocalPlaneXResolution = 0x6578A20E
-kQTExifUserDataFocalPlaneYResolution = 0x6578A20F
-kQTExifUserDataFocalPlaneResolutionUnit = 0x6578A210
-kQTExifUserDataSubjectLocation = 0x6578A214
-kQTExifUserDataExposureIndex = 0x6578A215
-kQTExifUserDataSensingMethod = 0x6578A217
-kQTExifUserDataFileSource = 0x6578A300
-kQTExifUserDataSceneType = 0x6578A301
-kQTExifUserDataGPSVersionID = 0x06770000
-kQTExifUserDataGPSLatitudeRef = 0x06770001
-kQTExifUserDataGPSLatitude = 0x06770002
-kQTExifUserDataGPSLongitudeRef = 0x06770003
-kQTExifUserDataGPSLongitude = 0x06770004
-kQTExifUserDataGPSAltitudeRef = 0x06770005
-kQTExifUserDataGPSAltitude = 0x06770006
-kQTExifUserDataGPSTimeStamp = 0x06770007
-kQTExifUserDataGPSSatellites = 0x06770008
-kQTExifUserDataGPSStatus = 0x06770009
-kQTExifUserDataGPSMeasureMode = 0x0677000A
-kQTExifUserDataGPSDOP = 0x0677000B
-kQTExifUserDataGPSSpeedRef = 0x0677000C
-kQTExifUserDataGPSSpeed = 0x0677000D
-kQTExifUserDataGPSTrackRef = 0x0677000E
-kQTExifUserDataGPSTrack = 0x0677000F
-kQTExifUserDataGPSImgDirectionRef = 0x06770010
-kQTExifUserDataGPSImgDirection = 0x06770011
-kQTExifUserDataGPSMapDatum = 0x06770012
-kQTExifUserDataGPSDestLatitudeRef = 0x06770013
-kQTExifUserDataGPSDestLatitude = 0x06770014
-kQTExifUserDataGPSDestLongitudeRef = 0x06770015
-kQTExifUserDataGPSDestLongitude = 0x06770016
-kQTExifUserDataGPSDestBearingRef = 0x06770017
-kQTExifUserDataGPSDestBearing = 0x06770018
-kQTExifUserDataGPSDestDistanceRef = 0x06770019
-kQTExifUserDataGPSDestDistance = 0x0677001A
-GraphicsExporterComponentType = FOUR_CHAR_CODE('grex')
-kBaseGraphicsExporterSubType = FOUR_CHAR_CODE('base')
-graphicsExporterIsBaseExporter = 1L << 0
-graphicsExporterCanTranscode = 1L << 1
-graphicsExporterUsesImageCompressor = 1L << 2
-kQTResolutionSettings = FOUR_CHAR_CODE('reso')
-kQTTargetDataSize = FOUR_CHAR_CODE('dasz')
-kQTDontRecompress = FOUR_CHAR_CODE('dntr')
-kQTInterlaceStyle = FOUR_CHAR_CODE('ilac')
-kQTColorSyncProfile = FOUR_CHAR_CODE('iccp')
-kQTThumbnailSettings = FOUR_CHAR_CODE('thum')
-kQTEnableExif = FOUR_CHAR_CODE('exif')
-kQTMetaData = FOUR_CHAR_CODE('meta')
-kQTTIFFCompressionMethod = FOUR_CHAR_CODE('tifc')
-kQTTIFFCompression_None = 1
-kQTTIFFCompression_PackBits = 32773L
-kQTTIFFLittleEndian = FOUR_CHAR_CODE('tife')
-kQTPNGFilterPreference = FOUR_CHAR_CODE('pngf')
-kQTPNGFilterBestForColorType = FOUR_CHAR_CODE('bflt')
-kQTPNGFilterNone = 0
-kQTPNGFilterSub = 1
-kQTPNGFilterUp = 2
-kQTPNGFilterAverage = 3
-kQTPNGFilterPaeth = 4
-kQTPNGFilterAdaptivePerRow = FOUR_CHAR_CODE('aflt')
-kQTPNGInterlaceStyle = FOUR_CHAR_CODE('ilac')
-kQTPNGInterlaceNone = 0
-kQTPNGInterlaceAdam7 = 1
-ImageTranscodererComponentType = FOUR_CHAR_CODE('imtc')
-kGraphicsImportSetDataReferenceSelect = 0x0001
-kGraphicsImportGetDataReferenceSelect = 0x0002
-kGraphicsImportSetDataFileSelect = 0x0003
-kGraphicsImportGetDataFileSelect = 0x0004
-kGraphicsImportSetDataHandleSelect = 0x0005
-kGraphicsImportGetDataHandleSelect = 0x0006
-kGraphicsImportGetImageDescriptionSelect = 0x0007
-kGraphicsImportGetDataOffsetAndSizeSelect = 0x0008
-kGraphicsImportReadDataSelect = 0x0009
-kGraphicsImportSetClipSelect = 0x000A
-kGraphicsImportGetClipSelect = 0x000B
-kGraphicsImportSetSourceRectSelect = 0x000C
-kGraphicsImportGetSourceRectSelect = 0x000D
-kGraphicsImportGetNaturalBoundsSelect = 0x000E
-kGraphicsImportDrawSelect = 0x000F
-kGraphicsImportSetGWorldSelect = 0x0010
-kGraphicsImportGetGWorldSelect = 0x0011
-kGraphicsImportSetMatrixSelect = 0x0012
-kGraphicsImportGetMatrixSelect = 0x0013
-kGraphicsImportSetBoundsRectSelect = 0x0014
-kGraphicsImportGetBoundsRectSelect = 0x0015
-kGraphicsImportSaveAsPictureSelect = 0x0016
-kGraphicsImportSetGraphicsModeSelect = 0x0017
-kGraphicsImportGetGraphicsModeSelect = 0x0018
-kGraphicsImportSetQualitySelect = 0x0019
-kGraphicsImportGetQualitySelect = 0x001A
-kGraphicsImportSaveAsQuickTimeImageFileSelect = 0x001B
-kGraphicsImportSetDataReferenceOffsetAndLimitSelect = 0x001C
-kGraphicsImportGetDataReferenceOffsetAndLimitSelect = 0x001D
-kGraphicsImportGetAliasedDataReferenceSelect = 0x001E
-kGraphicsImportValidateSelect = 0x001F
-kGraphicsImportGetMetaDataSelect = 0x0020
-kGraphicsImportGetMIMETypeListSelect = 0x0021
-kGraphicsImportDoesDrawAllPixelsSelect = 0x0022
-kGraphicsImportGetAsPictureSelect = 0x0023
-kGraphicsImportExportImageFileSelect = 0x0024
-kGraphicsImportGetExportImageTypeListSelect = 0x0025
-kGraphicsImportDoExportImageFileDialogSelect = 0x0026
-kGraphicsImportGetExportSettingsAsAtomContainerSelect = 0x0027
-kGraphicsImportSetExportSettingsFromAtomContainerSelect = 0x0028
-kGraphicsImportSetProgressProcSelect = 0x0029
-kGraphicsImportGetProgressProcSelect = 0x002A
-kGraphicsImportGetImageCountSelect = 0x002B
-kGraphicsImportSetImageIndexSelect = 0x002C
-kGraphicsImportGetImageIndexSelect = 0x002D
-kGraphicsImportGetDataOffsetAndSize64Select = 0x002E
-kGraphicsImportReadData64Select = 0x002F
-kGraphicsImportSetDataReferenceOffsetAndLimit64Select = 0x0030
-kGraphicsImportGetDataReferenceOffsetAndLimit64Select = 0x0031
-kGraphicsImportGetDefaultMatrixSelect = 0x0032
-kGraphicsImportGetDefaultClipSelect = 0x0033
-kGraphicsImportGetDefaultGraphicsModeSelect = 0x0034
-kGraphicsImportGetDefaultSourceRectSelect = 0x0035
-kGraphicsImportGetColorSyncProfileSelect = 0x0036
-kGraphicsImportSetDestRectSelect = 0x0037
-kGraphicsImportGetDestRectSelect = 0x0038
-kGraphicsImportSetFlagsSelect = 0x0039
-kGraphicsImportGetFlagsSelect = 0x003A
-kGraphicsImportGetBaseDataOffsetAndSize64Select = 0x003D
-kGraphicsImportSetImageIndexToThumbnailSelect = 0x003E
-kGraphicsExportDoExportSelect = 0x0001
-kGraphicsExportCanTranscodeSelect = 0x0002
-kGraphicsExportDoTranscodeSelect = 0x0003
-kGraphicsExportCanUseCompressorSelect = 0x0004
-kGraphicsExportDoUseCompressorSelect = 0x0005
-kGraphicsExportDoStandaloneExportSelect = 0x0006
-kGraphicsExportGetDefaultFileTypeAndCreatorSelect = 0x0007
-kGraphicsExportGetDefaultFileNameExtensionSelect = 0x0008
-kGraphicsExportGetMIMETypeListSelect = 0x0009
-kGraphicsExportRequestSettingsSelect = 0x000B
-kGraphicsExportSetSettingsFromAtomContainerSelect = 0x000C
-kGraphicsExportGetSettingsAsAtomContainerSelect = 0x000D
-kGraphicsExportGetSettingsAsTextSelect = 0x000E
-kGraphicsExportSetDontRecompressSelect = 0x000F
-kGraphicsExportGetDontRecompressSelect = 0x0010
-kGraphicsExportSetInterlaceStyleSelect = 0x0011
-kGraphicsExportGetInterlaceStyleSelect = 0x0012
-kGraphicsExportSetMetaDataSelect = 0x0013
-kGraphicsExportGetMetaDataSelect = 0x0014
-kGraphicsExportSetTargetDataSizeSelect = 0x0015
-kGraphicsExportGetTargetDataSizeSelect = 0x0016
-kGraphicsExportSetCompressionMethodSelect = 0x0017
-kGraphicsExportGetCompressionMethodSelect = 0x0018
-kGraphicsExportSetCompressionQualitySelect = 0x0019
-kGraphicsExportGetCompressionQualitySelect = 0x001A
-kGraphicsExportSetResolutionSelect = 0x001B
-kGraphicsExportGetResolutionSelect = 0x001C
-kGraphicsExportSetDepthSelect = 0x001D
-kGraphicsExportGetDepthSelect = 0x001E
-kGraphicsExportSetColorSyncProfileSelect = 0x0021
-kGraphicsExportGetColorSyncProfileSelect = 0x0022
-kGraphicsExportSetProgressProcSelect = 0x0023
-kGraphicsExportGetProgressProcSelect = 0x0024
-kGraphicsExportSetInputDataReferenceSelect = 0x0025
-kGraphicsExportGetInputDataReferenceSelect = 0x0026
-kGraphicsExportSetInputFileSelect = 0x0027
-kGraphicsExportGetInputFileSelect = 0x0028
-kGraphicsExportSetInputHandleSelect = 0x0029
-kGraphicsExportGetInputHandleSelect = 0x002A
-kGraphicsExportSetInputPtrSelect = 0x002B
-kGraphicsExportGetInputPtrSelect = 0x002C
-kGraphicsExportSetInputGraphicsImporterSelect = 0x002D
-kGraphicsExportGetInputGraphicsImporterSelect = 0x002E
-kGraphicsExportSetInputPictureSelect = 0x002F
-kGraphicsExportGetInputPictureSelect = 0x0030
-kGraphicsExportSetInputGWorldSelect = 0x0031
-kGraphicsExportGetInputGWorldSelect = 0x0032
-kGraphicsExportSetInputPixmapSelect = 0x0033
-kGraphicsExportGetInputPixmapSelect = 0x0034
-kGraphicsExportSetInputOffsetAndLimitSelect = 0x0035
-kGraphicsExportGetInputOffsetAndLimitSelect = 0x0036
-kGraphicsExportMayExporterReadInputDataSelect = 0x0037
-kGraphicsExportGetInputDataSizeSelect = 0x0038
-kGraphicsExportReadInputDataSelect = 0x0039
-kGraphicsExportGetInputImageDescriptionSelect = 0x003A
-kGraphicsExportGetInputImageDimensionsSelect = 0x003B
-kGraphicsExportGetInputImageDepthSelect = 0x003C
-kGraphicsExportDrawInputImageSelect = 0x003D
-kGraphicsExportSetOutputDataReferenceSelect = 0x003E
-kGraphicsExportGetOutputDataReferenceSelect = 0x003F
-kGraphicsExportSetOutputFileSelect = 0x0040
-kGraphicsExportGetOutputFileSelect = 0x0041
-kGraphicsExportSetOutputHandleSelect = 0x0042
-kGraphicsExportGetOutputHandleSelect = 0x0043
-kGraphicsExportSetOutputOffsetAndMaxSizeSelect = 0x0044
-kGraphicsExportGetOutputOffsetAndMaxSizeSelect = 0x0045
-kGraphicsExportSetOutputFileTypeAndCreatorSelect = 0x0046
-kGraphicsExportGetOutputFileTypeAndCreatorSelect = 0x0047
-kGraphicsExportWriteOutputDataSelect = 0x0048
-kGraphicsExportSetOutputMarkSelect = 0x0049
-kGraphicsExportGetOutputMarkSelect = 0x004A
-kGraphicsExportReadOutputDataSelect = 0x004B
-kGraphicsExportSetThumbnailEnabledSelect = 0x004C
-kGraphicsExportGetThumbnailEnabledSelect = 0x004D
-kGraphicsExportSetExifEnabledSelect = 0x004E
-kGraphicsExportGetExifEnabledSelect = 0x004F
-kImageTranscoderBeginSequenceSelect = 0x0001
-kImageTranscoderConvertSelect = 0x0002
-kImageTranscoderDisposeDataSelect = 0x0003
-kImageTranscoderEndSequenceSelect = 0x0004
-clockComponentType = FOUR_CHAR_CODE('clok')
-systemTickClock = FOUR_CHAR_CODE('tick')
-systemSecondClock = FOUR_CHAR_CODE('seco')
-systemMillisecondClock = FOUR_CHAR_CODE('mill')
-systemMicrosecondClock = FOUR_CHAR_CODE('micr')
-kClockRateIsLinear = 1
-kClockImplementsCallBacks = 2
-kClockCanHandleIntermittentSound = 4
-StandardCompressionType = FOUR_CHAR_CODE('scdi')
-StandardCompressionSubType = FOUR_CHAR_CODE('imag')
-StandardCompressionSubTypeSound = FOUR_CHAR_CODE('soun')
-scListEveryCodec = 1L << 1
-scAllowZeroFrameRate = 1L << 2
-scAllowZeroKeyFrameRate = 1L << 3
-scShowBestDepth = 1L << 4
-scUseMovableModal = 1L << 5
-scDisableFrameRateItem = 1L << 6
-scShowDataRateAsKilobits = 1L << 7
-scPreferCropping = 1 << 0
-scPreferScaling = 1 << 1
-scPreferScalingAndCropping = scPreferScaling | scPreferCropping
-scDontDetermineSettingsFromTestImage = 1 << 2
-scTestImageWidth = 80
-scTestImageHeight = 80
-scOKItem = 1
-scCancelItem = 2
-scCustomItem = 3
-scUserCancelled = 1
-scPositionRect = 2
-scPositionDialog = 3
-scSetTestImagePictHandle = 4
-scSetTestImagePictFile = 5
-scSetTestImagePixMap = 6
-scGetBestDeviceRect = 7
-scRequestImageSettings = 10
-scCompressImage = 11
-scCompressPicture = 12
-scCompressPictureFile = 13
-scRequestSequenceSettings = 14
-scCompressSequenceBegin = 15
-scCompressSequenceFrame = 16
-scCompressSequenceEnd = 17
-scDefaultPictHandleSettings = 18
-scDefaultPictFileSettings = 19
-scDefaultPixMapSettings = 20
-scGetInfo = 21
-scSetInfo = 22
-scNewGWorld = 23
-scSpatialSettingsType = FOUR_CHAR_CODE('sptl')
-scTemporalSettingsType = FOUR_CHAR_CODE('tprl')
-scDataRateSettingsType = FOUR_CHAR_CODE('drat')
-scColorTableType = FOUR_CHAR_CODE('clut')
-scProgressProcType = FOUR_CHAR_CODE('prog')
-scExtendedProcsType = FOUR_CHAR_CODE('xprc')
-scPreferenceFlagsType = FOUR_CHAR_CODE('pref')
-scSettingsStateType = FOUR_CHAR_CODE('ssta')
-scSequenceIDType = FOUR_CHAR_CODE('sequ')
-scWindowPositionType = FOUR_CHAR_CODE('wndw')
-scCodecFlagsType = FOUR_CHAR_CODE('cflg')
-scCodecSettingsType = FOUR_CHAR_CODE('cdec')
-scForceKeyValueType = FOUR_CHAR_CODE('ksim')
-scSoundSampleRateType = FOUR_CHAR_CODE('ssrt')
-scSoundSampleSizeType = FOUR_CHAR_CODE('ssss')
-scSoundChannelCountType = FOUR_CHAR_CODE('sscc')
-scSoundCompressionType = FOUR_CHAR_CODE('ssct')
-scCompressionListType = FOUR_CHAR_CODE('ctyl')
-scCodecManufacturerType = FOUR_CHAR_CODE('cmfr')
-scSoundVBRCompressionOK = FOUR_CHAR_CODE('cvbr')
-scSoundInputSampleRateType = FOUR_CHAR_CODE('ssir')
-scSoundSampleRateChangeOK = FOUR_CHAR_CODE('rcok')
-scAvailableCompressionListType = FOUR_CHAR_CODE('avai')
-scGetCompression = 1
-scShowMotionSettings = 1L << 0
-scSettingsChangedItem = -1
-scCompressFlagIgnoreIdenticalFrames = 1
-kQTSettingsVideo = FOUR_CHAR_CODE('vide')
-kQTSettingsSound = FOUR_CHAR_CODE('soun')
-kQTSettingsComponentVersion = FOUR_CHAR_CODE('vers')
-TweenComponentType = FOUR_CHAR_CODE('twen')
-TCSourceRefNameType = FOUR_CHAR_CODE('name')
-tcDropFrame = 1 << 0
-tc24HourMax = 1 << 1
-tcNegTimesOK = 1 << 2
-tcCounter = 1 << 3
-tctNegFlag = 0x80
-tcdfShowTimeCode = 1 << 0
-MovieImportType = FOUR_CHAR_CODE('eat ')
-MovieExportType = FOUR_CHAR_CODE('spit')
-canMovieImportHandles = 1 << 0
-canMovieImportFiles = 1 << 1
-hasMovieImportUserInterface = 1 << 2
-canMovieExportHandles = 1 << 3
-canMovieExportFiles = 1 << 4
-hasMovieExportUserInterface = 1 << 5
-movieImporterIsXMLBased = 1 << 5
-dontAutoFileMovieImport = 1 << 6
-canMovieExportAuxDataHandle = 1 << 7
-canMovieImportValidateHandles = 1 << 8
-canMovieImportValidateFile = 1 << 9
-dontRegisterWithEasyOpen = 1 << 10
-canMovieImportInPlace = 1 << 11
-movieImportSubTypeIsFileExtension = 1 << 12
-canMovieImportPartial = 1 << 13
-hasMovieImportMIMEList = 1 << 14
-canMovieImportAvoidBlocking = 1 << 15
-canMovieExportFromProcedures = 1 << 15
-canMovieExportValidateMovie = 1L << 16
-movieImportMustGetDestinationMediaType = 1L << 16
-movieExportNeedsResourceFork = 1L << 17
-canMovieImportDataReferences = 1L << 18
-movieExportMustGetSourceMediaType = 1L << 19
-canMovieImportWithIdle = 1L << 20
-canMovieImportValidateDataReferences = 1L << 21
-reservedForUseByGraphicsImporters = 1L << 23
-movieImportCreateTrack = 1
-movieImportInParallel = 2
-movieImportMustUseTrack = 4
-movieImportWithIdle = 16
-movieImportResultUsedMultipleTracks = 8
-movieImportResultNeedIdles = 32
-movieImportResultComplete = 64
-kMovieExportTextOnly = 0
-kMovieExportAbsoluteTime = 1
-kMovieExportRelativeTime = 2
-kMIDIImportSilenceBefore = 1 << 0
-kMIDIImportSilenceAfter = 1 << 1
-kMIDIImport20Playable = 1 << 2
-kMIDIImportWantLyrics = 1 << 3
-kQTMediaConfigResourceType = FOUR_CHAR_CODE('mcfg')
-kQTMediaConfigResourceVersion = 2
-kQTMediaGroupResourceType = FOUR_CHAR_CODE('mgrp')
-kQTMediaGroupResourceVersion = 1
-kQTBrowserInfoResourceType = FOUR_CHAR_CODE('brws')
-kQTBrowserInfoResourceVersion = 1
-kQTMediaMIMEInfoHasChanged = (1L << 1)
-kQTMediaFileInfoHasChanged = (1L << 2)
-kQTMediaConfigCanUseApp = (1L << 18)
-kQTMediaConfigCanUsePlugin = (1L << 19)
-kQTMediaConfigUNUSED = (1L << 20)
-kQTMediaConfigBinaryFile = (1L << 23)
-kQTMediaConfigTextFile = 0
-kQTMediaConfigMacintoshFile = (1L << 24)
-kQTMediaConfigAssociateByDefault = (1L << 27)
-kQTMediaConfigUseAppByDefault = (1L << 28)
-kQTMediaConfigUsePluginByDefault = (1L << 29)
-kQTMediaConfigDefaultsMask = (kQTMediaConfigUseAppByDefault | kQTMediaConfigUsePluginByDefault)
-kQTMediaConfigDefaultsShift = 12
-kQTMediaConfigHasFileHasQTAtoms = (1L << 30)
-kQTMediaConfigStreamGroupID = FOUR_CHAR_CODE('strm')
-kQTMediaConfigInteractiveGroupID = FOUR_CHAR_CODE('intr')
-kQTMediaConfigVideoGroupID = FOUR_CHAR_CODE('eyes')
-kQTMediaConfigAudioGroupID = FOUR_CHAR_CODE('ears')
-kQTMediaConfigMPEGGroupID = FOUR_CHAR_CODE('mpeg')
-kQTMediaConfigMP3GroupID = FOUR_CHAR_CODE('mp3 ')
-kQTMediaConfigImageGroupID = FOUR_CHAR_CODE('ogle')
-kQTMediaConfigMiscGroupID = FOUR_CHAR_CODE('misc')
-kQTMediaInfoNetGroup = FOUR_CHAR_CODE('net ')
-kQTMediaInfoWinGroup = FOUR_CHAR_CODE('win ')
-kQTMediaInfoMacGroup = FOUR_CHAR_CODE('mac ')
-kQTMediaInfoMiscGroup = 0x3F3F3F3F
-kMimeInfoMimeTypeTag = FOUR_CHAR_CODE('mime')
-kMimeInfoFileExtensionTag = FOUR_CHAR_CODE('ext ')
-kMimeInfoDescriptionTag = FOUR_CHAR_CODE('desc')
-kMimeInfoGroupTag = FOUR_CHAR_CODE('grop')
-kMimeInfoDoNotOverrideExistingFileTypeAssociation = FOUR_CHAR_CODE('nofa')
-kQTFileTypeAIFF = FOUR_CHAR_CODE('AIFF')
-kQTFileTypeAIFC = FOUR_CHAR_CODE('AIFC')
-kQTFileTypeDVC = FOUR_CHAR_CODE('dvc!')
-kQTFileTypeMIDI = FOUR_CHAR_CODE('Midi')
-kQTFileTypePicture = FOUR_CHAR_CODE('PICT')
-kQTFileTypeMovie = FOUR_CHAR_CODE('MooV')
-kQTFileTypeText = FOUR_CHAR_CODE('TEXT')
-kQTFileTypeWave = FOUR_CHAR_CODE('WAVE')
-kQTFileTypeSystemSevenSound = FOUR_CHAR_CODE('sfil')
-kQTFileTypeMuLaw = FOUR_CHAR_CODE('ULAW')
-kQTFileTypeAVI = FOUR_CHAR_CODE('VfW ')
-kQTFileTypeSoundDesignerII = FOUR_CHAR_CODE('Sd2f')
-kQTFileTypeAudioCDTrack = FOUR_CHAR_CODE('trak')
-kQTFileTypePICS = FOUR_CHAR_CODE('PICS')
-kQTFileTypeGIF = FOUR_CHAR_CODE('GIFf')
-kQTFileTypePNG = FOUR_CHAR_CODE('PNGf')
-kQTFileTypeTIFF = FOUR_CHAR_CODE('TIFF')
-kQTFileTypePhotoShop = FOUR_CHAR_CODE('8BPS')
-kQTFileTypeSGIImage = FOUR_CHAR_CODE('.SGI')
-kQTFileTypeBMP = FOUR_CHAR_CODE('BMPf')
-kQTFileTypeJPEG = FOUR_CHAR_CODE('JPEG')
-kQTFileTypeJFIF = FOUR_CHAR_CODE('JPEG')
-kQTFileTypeMacPaint = FOUR_CHAR_CODE('PNTG')
-kQTFileTypeTargaImage = FOUR_CHAR_CODE('TPIC')
-kQTFileTypeQuickDrawGXPicture = FOUR_CHAR_CODE('qdgx')
-kQTFileTypeQuickTimeImage = FOUR_CHAR_CODE('qtif')
-kQTFileType3DMF = FOUR_CHAR_CODE('3DMF')
-kQTFileTypeFLC = FOUR_CHAR_CODE('FLC ')
-kQTFileTypeFlash = FOUR_CHAR_CODE('SWFL')
-kQTFileTypeFlashPix = FOUR_CHAR_CODE('FPix')
-kQTFileTypeMP4 = FOUR_CHAR_CODE('mpg4')
-kQTSettingsDVExportNTSC = FOUR_CHAR_CODE('dvcv')
-kQTSettingsDVExportLockedAudio = FOUR_CHAR_CODE('lock')
-kQTSettingsEffect = FOUR_CHAR_CODE('effe')
-kQTSettingsGraphicsFileImportSequence = FOUR_CHAR_CODE('sequ')
-kQTSettingsGraphicsFileImportSequenceEnabled = FOUR_CHAR_CODE('enab')
-kQTSettingsMovieExportEnableVideo = FOUR_CHAR_CODE('envi')
-kQTSettingsMovieExportEnableSound = FOUR_CHAR_CODE('enso')
-kQTSettingsMovieExportSaveOptions = FOUR_CHAR_CODE('save')
-kQTSettingsMovieExportSaveForInternet = FOUR_CHAR_CODE('fast')
-kQTSettingsMovieExportSaveCompressedMovie = FOUR_CHAR_CODE('cmpm')
-kQTSettingsMIDI = FOUR_CHAR_CODE('MIDI')
-kQTSettingsMIDISettingFlags = FOUR_CHAR_CODE('sttg')
-kQTSettingsText = FOUR_CHAR_CODE('text')
-kQTSettingsTextDescription = FOUR_CHAR_CODE('desc')
-kQTSettingsTextSize = FOUR_CHAR_CODE('size')
-kQTSettingsTextSettingFlags = FOUR_CHAR_CODE('sttg')
-kQTSettingsTextTimeFraction = FOUR_CHAR_CODE('timf')
-kQTSettingsTime = FOUR_CHAR_CODE('time')
-kQTSettingsTimeDuration = FOUR_CHAR_CODE('dura')
-kQTSettingsAudioCDTrack = FOUR_CHAR_CODE('trak')
-kQTSettingsAudioCDTrackRateShift = FOUR_CHAR_CODE('rshf')
-kQTSettingsDVExportDVFormat = FOUR_CHAR_CODE('dvcf')
-kQTPresetsListResourceType = FOUR_CHAR_CODE('stg#')
-kQTPresetsPlatformListResourceType = FOUR_CHAR_CODE('stgp')
-kQTPresetInfoIsDivider = 1
-kQTMovieExportSourceInfoResourceType = FOUR_CHAR_CODE('src#')
-kQTMovieExportSourceInfoIsMediaType = 1L << 0
-kQTMovieExportSourceInfoIsMediaCharacteristic = 1L << 1
-kQTMovieExportSourceInfoIsSourceType = 1L << 2
-movieExportUseConfiguredSettings = FOUR_CHAR_CODE('ucfg')
-movieExportWidth = FOUR_CHAR_CODE('wdth')
-movieExportHeight = FOUR_CHAR_CODE('hegt')
-movieExportDuration = FOUR_CHAR_CODE('dura')
-movieExportVideoFilter = FOUR_CHAR_CODE('iflt')
-movieExportTimeScale = FOUR_CHAR_CODE('tmsc')
-kQTBrowserInfoCanUseSystemFolderPlugin = (1L << 0)
-kQTPreFlightOpenComponent = (1L << 1)
-pnotComponentWantsEvents = 1
-pnotComponentNeedsNoCache = 2
-ShowFilePreviewComponentType = FOUR_CHAR_CODE('pnot')
-CreateFilePreviewComponentType = FOUR_CHAR_CODE('pmak')
-DataCompressorComponentType = FOUR_CHAR_CODE('dcom')
-DataDecompressorComponentType = FOUR_CHAR_CODE('ddec')
-AppleDataCompressorSubType = FOUR_CHAR_CODE('adec')
-zlibDataCompressorSubType = FOUR_CHAR_CODE('zlib')
-kDataHCanRead = 1L << 0
-kDataHSpecialRead = 1L << 1
-kDataHSpecialReadFile = 1L << 2
-kDataHCanWrite = 1L << 3
-kDataHSpecialWrite = 1 << 4
-kDataHSpecialWriteFile = 1 << 5
-kDataHCanStreamingWrite = 1 << 6
-kDataHMustCheckDataRef = 1 << 7
-kDataRefExtensionChokeSpeed = FOUR_CHAR_CODE('chok')
-kDataRefExtensionFileName = FOUR_CHAR_CODE('fnam')
-kDataRefExtensionMIMEType = FOUR_CHAR_CODE('mime')
-kDataRefExtensionMacOSFileType = FOUR_CHAR_CODE('ftyp')
-kDataRefExtensionInitializationData = FOUR_CHAR_CODE('data')
-kDataRefExtensionQuickTimeMediaType = FOUR_CHAR_CODE('mtyp')
-kDataHChokeToMovieDataRate = 1 << 0
-kDataHChokeToParam = 1 << 1
-kDataHExtendedSchedule = FOUR_CHAR_CODE('xtnd')
-kDataHInfoFlagNeverStreams = 1 << 0
-kDataHInfoFlagCanUpdateDataRefs = 1 << 1
-kDataHInfoFlagNeedsNetworkBandwidth = 1 << 2
-kDataHFileTypeMacOSFileType = FOUR_CHAR_CODE('ftyp')
-kDataHFileTypeExtension = FOUR_CHAR_CODE('fext')
-kDataHFileTypeMIME = FOUR_CHAR_CODE('mime')
-kDataHCreateFileButDontCreateResFile = (1L << 0)
-kDataHMovieUsageDoAppendMDAT = 1L << 0
-kDataHTempUseSameDirectory = 1L << 0
-kDataHTempUseSameVolume = 1L << 1
-kDataHTempCreateFile = 1L << 2
-kDataHTempOpenFile = 1L << 3
-kDataHGetDataRateInfiniteRate = 0x7FFFFFFF
-kDataHSetTimeHintsSkipBandwidthRequest = 1 << 0
-videoDigitizerComponentType = FOUR_CHAR_CODE('vdig')
-vdigInterfaceRev = 2
-ntscIn = 0
-currentIn = 0
-palIn = 1
-secamIn = 2
-ntscReallyIn = 3
-compositeIn = 0
-sVideoIn = 1
-rgbComponentIn = 2
-rgbComponentSyncIn = 3
-yuvComponentIn = 4
-yuvComponentSyncIn = 5
-tvTunerIn = 6
-sdiIn = 7
-vdPlayThruOff = 0
-vdPlayThruOn = 1
-vdDigitizerBW = 0
-vdDigitizerRGB = 1
-vdBroadcastMode = 0
-vdVTRMode = 1
-vdUseAnyField = 0
-vdUseOddField = 1
-vdUseEvenField = 2
-vdTypeBasic = 0
-vdTypeAlpha = 1
-vdTypeMask = 2
-vdTypeKey = 3
-digiInDoesNTSC = 1L << 0
-digiInDoesPAL = 1L << 1
-digiInDoesSECAM = 1L << 2
-digiInDoesGenLock = 1L << 7
-digiInDoesComposite = 1L << 8
-digiInDoesSVideo = 1L << 9
-digiInDoesComponent = 1L << 10
-digiInVTR_Broadcast = 1L << 11
-digiInDoesColor = 1L << 12
-digiInDoesBW = 1L << 13
-digiInSignalLock = 1L << 31
-digiOutDoes1 = 1L << 0
-digiOutDoes2 = 1L << 1
-digiOutDoes4 = 1L << 2
-digiOutDoes8 = 1L << 3
-digiOutDoes16 = 1L << 4
-digiOutDoes32 = 1L << 5
-digiOutDoesDither = 1L << 6
-digiOutDoesStretch = 1L << 7
-digiOutDoesShrink = 1L << 8
-digiOutDoesMask = 1L << 9
-digiOutDoesDouble = 1L << 11
-digiOutDoesQuad = 1L << 12
-digiOutDoesQuarter = 1L << 13
-digiOutDoesSixteenth = 1L << 14
-digiOutDoesRotate = 1L << 15
-digiOutDoesHorizFlip = 1L << 16
-digiOutDoesVertFlip = 1L << 17
-digiOutDoesSkew = 1L << 18
-digiOutDoesBlend = 1L << 19
-digiOutDoesWarp = 1L << 20
-digiOutDoesHW_DMA = 1L << 21
-digiOutDoesHWPlayThru = 1L << 22
-digiOutDoesILUT = 1L << 23
-digiOutDoesKeyColor = 1L << 24
-digiOutDoesAsyncGrabs = 1L << 25
-digiOutDoesUnreadableScreenBits = 1L << 26
-digiOutDoesCompress = 1L << 27
-digiOutDoesCompressOnly = 1L << 28
-digiOutDoesPlayThruDuringCompress = 1L << 29
-digiOutDoesCompressPartiallyVisible = 1L << 30
-digiOutDoesNotNeedCopyOfCompressData = 1L << 31
-dmaDepth1 = 1
-dmaDepth2 = 2
-dmaDepth4 = 4
-dmaDepth8 = 8
-dmaDepth16 = 16
-dmaDepth32 = 32
-dmaDepth2Gray = 64
-dmaDepth4Gray = 128
-dmaDepth8Gray = 256
-kVDIGControlledFrameRate = -1
-vdDeviceFlagShowInputsAsDevices = (1 << 0)
-vdDeviceFlagHideDevice = (1 << 1)
-vdFlagCaptureStarting = (1 << 0)
-vdFlagCaptureStopping = (1 << 1)
-vdFlagCaptureIsForPreview = (1 << 2)
-vdFlagCaptureIsForRecord = (1 << 3)
-vdFlagCaptureLowLatency = (1 << 4)
-vdFlagCaptureAlwaysUseTimeBase = (1 << 5)
-vdFlagCaptureSetSettingsBegin = (1 << 6)
-vdFlagCaptureSetSettingsEnd = (1 << 7)
-xmlParseComponentType = FOUR_CHAR_CODE('pars')
-xmlParseComponentSubType = FOUR_CHAR_CODE('xml ')
-xmlIdentifierInvalid = 0
-# xmlIdentifierUnrecognized = (long)0xFFFFFFFF
-xmlContentTypeInvalid = 0
-xmlContentTypeElement = 1
-xmlContentTypeCharData = 2
-elementFlagAlwaysSelfContained = 1L << 0
-elementFlagPreserveWhiteSpace = 1L << 1
-xmlParseFlagAllowUppercase = 1L << 0
-xmlParseFlagAllowUnquotedAttributeValues = 1L << 1
-xmlParseFlagEventParseOnly = 1L << 2
-attributeValueKindCharString = 0
-attributeValueKindInteger = 1L << 0
-attributeValueKindPercent = 1L << 1
-attributeValueKindBoolean = 1L << 2
-attributeValueKindOnOff = 1L << 3
-attributeValueKindColor = 1L << 4
-attributeValueKindEnum = 1L << 5
-attributeValueKindCaseSensEnum = 1L << 6
-MAX_ATTRIBUTE_VALUE_KIND = attributeValueKindCaseSensEnum
-nameSpaceIDNone = 0
-element_xml = 1
-attr_src = 1
-SeqGrabComponentType = FOUR_CHAR_CODE('barg')
-SeqGrabChannelType = FOUR_CHAR_CODE('sgch')
-SeqGrabPanelType = FOUR_CHAR_CODE('sgpn')
-SeqGrabCompressionPanelType = FOUR_CHAR_CODE('cmpr')
-SeqGrabSourcePanelType = FOUR_CHAR_CODE('sour')
-seqGrabToDisk = 1
-seqGrabToMemory = 2
-seqGrabDontUseTempMemory = 4
-seqGrabAppendToFile = 8
-seqGrabDontAddMovieResource = 16
-seqGrabDontMakeMovie = 32
-seqGrabPreExtendFile = 64
-seqGrabDataProcIsInterruptSafe = 128
-seqGrabDataProcDoesOverlappingReads = 256
-seqGrabRecord = 1
-seqGrabPreview = 2
-seqGrabPlayDuringRecord = 4
-seqGrabLowLatencyCapture = 8
-seqGrabAlwaysUseTimeBase = 16
-seqGrabHasBounds = 1
-seqGrabHasVolume = 2
-seqGrabHasDiscreteSamples = 4
-seqGrabDoNotBufferizeData = 8
-seqGrabCanMoveWindowWhileRecording = 16
-grabPictOffScreen = 1
-grabPictIgnoreClip = 2
-grabPictCurrentImage = 4
-sgFlagControlledGrab = (1 << 0)
-sgFlagAllowNonRGBPixMaps = (1 << 1)
-sgDeviceInputNameFlagInputUnavailable = (1 << 0)
-sgDeviceNameFlagDeviceUnavailable = (1 << 0)
-sgDeviceNameFlagShowInputsAsDevices = (1 << 1)
-sgDeviceListWithIcons = (1 << 0)
-sgDeviceListDontCheckAvailability = (1 << 1)
-sgDeviceListIncludeInputs = (1 << 2)
-seqGrabWriteAppend = 0
-seqGrabWriteReserve = 1
-seqGrabWriteFill = 2
-seqGrabUnpause = 0
-seqGrabPause = 1
-seqGrabPauseForMenu = 3
-channelFlagDontOpenResFile = 2
-channelFlagHasDependency = 4
-sgPanelFlagForPanel = 1
-seqGrabSettingsPreviewOnly = 1
-channelPlayNormal = 0
-channelPlayFast = 1
-channelPlayHighQuality = 2
-channelPlayAllData = 4
-sgSetSettingsBegin = (1 << 0)
-sgSetSettingsEnd = (1 << 1)
-kSGSmallestDITLSize = -1
-kSGLargestDITLSize = -2
-sgChannelAtom = FOUR_CHAR_CODE('chan')
-sgChannelSettingsAtom = FOUR_CHAR_CODE('ctom')
-sgChannelDescription = FOUR_CHAR_CODE('cdsc')
-sgChannelSettings = FOUR_CHAR_CODE('cset')
-sgDeviceNameType = FOUR_CHAR_CODE('name')
-sgDeviceDisplayNameType = FOUR_CHAR_CODE('dnam')
-sgDeviceUIDType = FOUR_CHAR_CODE('duid')
-sgInputUIDType = FOUR_CHAR_CODE('iuid')
-sgUsageType = FOUR_CHAR_CODE('use ')
-sgPlayFlagsType = FOUR_CHAR_CODE('plyf')
-sgClipType = FOUR_CHAR_CODE('clip')
-sgMatrixType = FOUR_CHAR_CODE('mtrx')
-sgVolumeType = FOUR_CHAR_CODE('volu')
-sgPanelSettingsAtom = FOUR_CHAR_CODE('ptom')
-sgPanelDescription = FOUR_CHAR_CODE('pdsc')
-sgPanelSettings = FOUR_CHAR_CODE('pset')
-sgcSoundCompressionType = FOUR_CHAR_CODE('scmp')
-sgcSoundCodecSettingsType = FOUR_CHAR_CODE('cdec')
-sgcSoundSampleRateType = FOUR_CHAR_CODE('srat')
-sgcSoundChannelCountType = FOUR_CHAR_CODE('schn')
-sgcSoundSampleSizeType = FOUR_CHAR_CODE('ssiz')
-sgcSoundInputType = FOUR_CHAR_CODE('sinp')
-sgcSoundGainType = FOUR_CHAR_CODE('gain')
-sgcVideoHueType = FOUR_CHAR_CODE('hue ')
-sgcVideoSaturationType = FOUR_CHAR_CODE('satr')
-sgcVideoContrastType = FOUR_CHAR_CODE('trst')
-sgcVideoSharpnessType = FOUR_CHAR_CODE('shrp')
-sgcVideoBrigtnessType = FOUR_CHAR_CODE('brit')
-sgcVideoBlackLevelType = FOUR_CHAR_CODE('blkl')
-sgcVideoWhiteLevelType = FOUR_CHAR_CODE('whtl')
-sgcVideoInputType = FOUR_CHAR_CODE('vinp')
-sgcVideoFormatType = FOUR_CHAR_CODE('vstd')
-sgcVideoFilterType = FOUR_CHAR_CODE('vflt')
-sgcVideoRectType = FOUR_CHAR_CODE('vrct')
-sgcVideoDigitizerType = FOUR_CHAR_CODE('vdig')
-QTVideoOutputComponentType = FOUR_CHAR_CODE('vout')
-QTVideoOutputComponentBaseSubType = FOUR_CHAR_CODE('base')
-kQTVideoOutputDontDisplayToUser = 1L << 0
-kQTVODisplayModeItem = FOUR_CHAR_CODE('qdmi')
-kQTVODimensions = FOUR_CHAR_CODE('dimn')
-kQTVOResolution = FOUR_CHAR_CODE('resl')
-kQTVORefreshRate = FOUR_CHAR_CODE('refr')
-kQTVOPixelType = FOUR_CHAR_CODE('pixl')
-kQTVOName = FOUR_CHAR_CODE('name')
-kQTVODecompressors = FOUR_CHAR_CODE('deco')
-kQTVODecompressorType = FOUR_CHAR_CODE('dety')
-kQTVODecompressorContinuous = FOUR_CHAR_CODE('cont')
-kQTVODecompressorComponent = FOUR_CHAR_CODE('cmpt')
-kClockGetTimeSelect = 0x0001
-kClockNewCallBackSelect = 0x0002
-kClockDisposeCallBackSelect = 0x0003
-kClockCallMeWhenSelect = 0x0004
-kClockCancelCallBackSelect = 0x0005
-kClockRateChangedSelect = 0x0006
-kClockTimeChangedSelect = 0x0007
-kClockSetTimeBaseSelect = 0x0008
-kClockStartStopChangedSelect = 0x0009
-kClockGetRateSelect = 0x000A
-kSCGetCompressionExtendedSelect = 0x0001
-kSCPositionRectSelect = 0x0002
-kSCPositionDialogSelect = 0x0003
-kSCSetTestImagePictHandleSelect = 0x0004
-kSCSetTestImagePictFileSelect = 0x0005
-kSCSetTestImagePixMapSelect = 0x0006
-kSCGetBestDeviceRectSelect = 0x0007
-kSCRequestImageSettingsSelect = 0x000A
-kSCCompressImageSelect = 0x000B
-kSCCompressPictureSelect = 0x000C
-kSCCompressPictureFileSelect = 0x000D
-kSCRequestSequenceSettingsSelect = 0x000E
-kSCCompressSequenceBeginSelect = 0x000F
-kSCCompressSequenceFrameSelect = 0x0010
-kSCCompressSequenceEndSelect = 0x0011
-kSCDefaultPictHandleSettingsSelect = 0x0012
-kSCDefaultPictFileSettingsSelect = 0x0013
-kSCDefaultPixMapSettingsSelect = 0x0014
-kSCGetInfoSelect = 0x0015
-kSCSetInfoSelect = 0x0016
-kSCNewGWorldSelect = 0x0017
-kSCSetCompressFlagsSelect = 0x0018
-kSCGetCompressFlagsSelect = 0x0019
-kSCGetSettingsAsTextSelect = 0x001A
-kSCGetSettingsAsAtomContainerSelect = 0x001B
-kSCSetSettingsFromAtomContainerSelect = 0x001C
-kSCCompressSequenceFrameAsyncSelect = 0x001D
-kSCAsyncIdleSelect = 0x001E
-kTweenerInitializeSelect = 0x0001
-kTweenerDoTweenSelect = 0x0002
-kTweenerResetSelect = 0x0003
-kTCGetCurrentTimeCodeSelect = 0x0101
-kTCGetTimeCodeAtTimeSelect = 0x0102
-kTCTimeCodeToStringSelect = 0x0103
-kTCTimeCodeToFrameNumberSelect = 0x0104
-kTCFrameNumberToTimeCodeSelect = 0x0105
-kTCGetSourceRefSelect = 0x0106
-kTCSetSourceRefSelect = 0x0107
-kTCSetTimeCodeFlagsSelect = 0x0108
-kTCGetTimeCodeFlagsSelect = 0x0109
-kTCSetDisplayOptionsSelect = 0x010A
-kTCGetDisplayOptionsSelect = 0x010B
-kMovieImportHandleSelect = 0x0001
-kMovieImportFileSelect = 0x0002
-kMovieImportSetSampleDurationSelect = 0x0003
-kMovieImportSetSampleDescriptionSelect = 0x0004
-kMovieImportSetMediaFileSelect = 0x0005
-kMovieImportSetDimensionsSelect = 0x0006
-kMovieImportSetChunkSizeSelect = 0x0007
-kMovieImportSetProgressProcSelect = 0x0008
-kMovieImportSetAuxiliaryDataSelect = 0x0009
-kMovieImportSetFromScrapSelect = 0x000A
-kMovieImportDoUserDialogSelect = 0x000B
-kMovieImportSetDurationSelect = 0x000C
-kMovieImportGetAuxiliaryDataTypeSelect = 0x000D
-kMovieImportValidateSelect = 0x000E
-kMovieImportGetFileTypeSelect = 0x000F
-kMovieImportDataRefSelect = 0x0010
-kMovieImportGetSampleDescriptionSelect = 0x0011
-kMovieImportGetMIMETypeListSelect = 0x0012
-kMovieImportSetOffsetAndLimitSelect = 0x0013
-kMovieImportGetSettingsAsAtomContainerSelect = 0x0014
-kMovieImportSetSettingsFromAtomContainerSelect = 0x0015
-kMovieImportSetOffsetAndLimit64Select = 0x0016
-kMovieImportIdleSelect = 0x0017
-kMovieImportValidateDataRefSelect = 0x0018
-kMovieImportGetLoadStateSelect = 0x0019
-kMovieImportGetMaxLoadedTimeSelect = 0x001A
-kMovieImportEstimateCompletionTimeSelect = 0x001B
-kMovieImportSetDontBlockSelect = 0x001C
-kMovieImportGetDontBlockSelect = 0x001D
-kMovieImportSetIdleManagerSelect = 0x001E
-kMovieImportSetNewMovieFlagsSelect = 0x001F
-kMovieImportGetDestinationMediaTypeSelect = 0x0020
-kMovieExportToHandleSelect = 0x0080
-kMovieExportToFileSelect = 0x0081
-kMovieExportGetAuxiliaryDataSelect = 0x0083
-kMovieExportSetProgressProcSelect = 0x0084
-kMovieExportSetSampleDescriptionSelect = 0x0085
-kMovieExportDoUserDialogSelect = 0x0086
-kMovieExportGetCreatorTypeSelect = 0x0087
-kMovieExportToDataRefSelect = 0x0088
-kMovieExportFromProceduresToDataRefSelect = 0x0089
-kMovieExportAddDataSourceSelect = 0x008A
-kMovieExportValidateSelect = 0x008B
-kMovieExportGetSettingsAsAtomContainerSelect = 0x008C
-kMovieExportSetSettingsFromAtomContainerSelect = 0x008D
-kMovieExportGetFileNameExtensionSelect = 0x008E
-kMovieExportGetShortFileTypeStringSelect = 0x008F
-kMovieExportGetSourceMediaTypeSelect = 0x0090
-kMovieExportSetGetMoviePropertyProcSelect = 0x0091
-kTextExportGetDisplayDataSelect = 0x0100
-kTextExportGetTimeFractionSelect = 0x0101
-kTextExportSetTimeFractionSelect = 0x0102
-kTextExportGetSettingsSelect = 0x0103
-kTextExportSetSettingsSelect = 0x0104
-kMIDIImportGetSettingsSelect = 0x0100
-kMIDIImportSetSettingsSelect = 0x0101
-kMovieExportNewGetDataAndPropertiesProcsSelect = 0x0100
-kMovieExportDisposeGetDataAndPropertiesProcsSelect = 0x0101
-kGraphicsImageImportSetSequenceEnabledSelect = 0x0100
-kGraphicsImageImportGetSequenceEnabledSelect = 0x0101
-kPreviewShowDataSelect = 0x0001
-kPreviewMakePreviewSelect = 0x0002
-kPreviewMakePreviewReferenceSelect = 0x0003
-kPreviewEventSelect = 0x0004
-kDataCodecDecompressSelect = 0x0001
-kDataCodecGetCompressBufferSizeSelect = 0x0002
-kDataCodecCompressSelect = 0x0003
-kDataCodecBeginInterruptSafeSelect = 0x0004
-kDataCodecEndInterruptSafeSelect = 0x0005
-kDataCodecDecompressPartialSelect = 0x0006
-kDataCodecCompressPartialSelect = 0x0007
-kDataHGetDataSelect = 0x0002
-kDataHPutDataSelect = 0x0003
-kDataHFlushDataSelect = 0x0004
-kDataHOpenForWriteSelect = 0x0005
-kDataHCloseForWriteSelect = 0x0006
-kDataHOpenForReadSelect = 0x0008
-kDataHCloseForReadSelect = 0x0009
-kDataHSetDataRefSelect = 0x000A
-kDataHGetDataRefSelect = 0x000B
-kDataHCompareDataRefSelect = 0x000C
-kDataHTaskSelect = 0x000D
-kDataHScheduleDataSelect = 0x000E
-kDataHFinishDataSelect = 0x000F
-kDataHFlushCacheSelect = 0x0010
-kDataHResolveDataRefSelect = 0x0011
-kDataHGetFileSizeSelect = 0x0012
-kDataHCanUseDataRefSelect = 0x0013
-kDataHGetVolumeListSelect = 0x0014
-kDataHWriteSelect = 0x0015
-kDataHPreextendSelect = 0x0016
-kDataHSetFileSizeSelect = 0x0017
-kDataHGetFreeSpaceSelect = 0x0018
-kDataHCreateFileSelect = 0x0019
-kDataHGetPreferredBlockSizeSelect = 0x001A
-kDataHGetDeviceIndexSelect = 0x001B
-kDataHIsStreamingDataHandlerSelect = 0x001C
-kDataHGetDataInBufferSelect = 0x001D
-kDataHGetScheduleAheadTimeSelect = 0x001E
-kDataHSetCacheSizeLimitSelect = 0x001F
-kDataHGetCacheSizeLimitSelect = 0x0020
-kDataHGetMovieSelect = 0x0021
-kDataHAddMovieSelect = 0x0022
-kDataHUpdateMovieSelect = 0x0023
-kDataHDoesBufferSelect = 0x0024
-kDataHGetFileNameSelect = 0x0025
-kDataHGetAvailableFileSizeSelect = 0x0026
-kDataHGetMacOSFileTypeSelect = 0x0027
-kDataHGetMIMETypeSelect = 0x0028
-kDataHSetDataRefWithAnchorSelect = 0x0029
-kDataHGetDataRefWithAnchorSelect = 0x002A
-kDataHSetMacOSFileTypeSelect = 0x002B
-kDataHSetTimeBaseSelect = 0x002C
-kDataHGetInfoFlagsSelect = 0x002D
-kDataHScheduleData64Select = 0x002E
-kDataHWrite64Select = 0x002F
-kDataHGetFileSize64Select = 0x0030
-kDataHPreextend64Select = 0x0031
-kDataHSetFileSize64Select = 0x0032
-kDataHGetFreeSpace64Select = 0x0033
-kDataHAppend64Select = 0x0034
-kDataHReadAsyncSelect = 0x0035
-kDataHPollReadSelect = 0x0036
-kDataHGetDataAvailabilitySelect = 0x0037
-kDataHGetFileSizeAsyncSelect = 0x003A
-kDataHGetDataRefAsTypeSelect = 0x003B
-kDataHSetDataRefExtensionSelect = 0x003C
-kDataHGetDataRefExtensionSelect = 0x003D
-kDataHGetMovieWithFlagsSelect = 0x003E
-kDataHGetFileTypeOrderingSelect = 0x0040
-kDataHCreateFileWithFlagsSelect = 0x0041
-kDataHGetMIMETypeAsyncSelect = 0x0042
-kDataHGetInfoSelect = 0x0043
-kDataHSetIdleManagerSelect = 0x0044
-kDataHDeleteFileSelect = 0x0045
-kDataHSetMovieUsageFlagsSelect = 0x0046
-kDataHUseTemporaryDataRefSelect = 0x0047
-kDataHGetTemporaryDataRefCapabilitiesSelect = 0x0048
-kDataHRenameFileSelect = 0x0049
-kDataHPlaybackHintsSelect = 0x0103
-kDataHPlaybackHints64Select = 0x010E
-kDataHGetDataRateSelect = 0x0110
-kDataHSetTimeHintsSelect = 0x0111
-kVDGetMaxSrcRectSelect = 0x0001
-kVDGetActiveSrcRectSelect = 0x0002
-kVDSetDigitizerRectSelect = 0x0003
-kVDGetDigitizerRectSelect = 0x0004
-kVDGetVBlankRectSelect = 0x0005
-kVDGetMaskPixMapSelect = 0x0006
-kVDGetPlayThruDestinationSelect = 0x0008
-kVDUseThisCLUTSelect = 0x0009
-kVDSetInputGammaValueSelect = 0x000A
-kVDGetInputGammaValueSelect = 0x000B
-kVDSetBrightnessSelect = 0x000C
-kVDGetBrightnessSelect = 0x000D
-kVDSetContrastSelect = 0x000E
-kVDSetHueSelect = 0x000F
-kVDSetSharpnessSelect = 0x0010
-kVDSetSaturationSelect = 0x0011
-kVDGetContrastSelect = 0x0012
-kVDGetHueSelect = 0x0013
-kVDGetSharpnessSelect = 0x0014
-kVDGetSaturationSelect = 0x0015
-kVDGrabOneFrameSelect = 0x0016
-kVDGetMaxAuxBufferSelect = 0x0017
-kVDGetDigitizerInfoSelect = 0x0019
-kVDGetCurrentFlagsSelect = 0x001A
-kVDSetKeyColorSelect = 0x001B
-kVDGetKeyColorSelect = 0x001C
-kVDAddKeyColorSelect = 0x001D
-kVDGetNextKeyColorSelect = 0x001E
-kVDSetKeyColorRangeSelect = 0x001F
-kVDGetKeyColorRangeSelect = 0x0020
-kVDSetDigitizerUserInterruptSelect = 0x0021
-kVDSetInputColorSpaceModeSelect = 0x0022
-kVDGetInputColorSpaceModeSelect = 0x0023
-kVDSetClipStateSelect = 0x0024
-kVDGetClipStateSelect = 0x0025
-kVDSetClipRgnSelect = 0x0026
-kVDClearClipRgnSelect = 0x0027
-kVDGetCLUTInUseSelect = 0x0028
-kVDSetPLLFilterTypeSelect = 0x0029
-kVDGetPLLFilterTypeSelect = 0x002A
-kVDGetMaskandValueSelect = 0x002B
-kVDSetMasterBlendLevelSelect = 0x002C
-kVDSetPlayThruDestinationSelect = 0x002D
-kVDSetPlayThruOnOffSelect = 0x002E
-kVDSetFieldPreferenceSelect = 0x002F
-kVDGetFieldPreferenceSelect = 0x0030
-kVDPreflightDestinationSelect = 0x0032
-kVDPreflightGlobalRectSelect = 0x0033
-kVDSetPlayThruGlobalRectSelect = 0x0034
-kVDSetInputGammaRecordSelect = 0x0035
-kVDGetInputGammaRecordSelect = 0x0036
-kVDSetBlackLevelValueSelect = 0x0037
-kVDGetBlackLevelValueSelect = 0x0038
-kVDSetWhiteLevelValueSelect = 0x0039
-kVDGetWhiteLevelValueSelect = 0x003A
-kVDGetVideoDefaultsSelect = 0x003B
-kVDGetNumberOfInputsSelect = 0x003C
-kVDGetInputFormatSelect = 0x003D
-kVDSetInputSelect = 0x003E
-kVDGetInputSelect = 0x003F
-kVDSetInputStandardSelect = 0x0040
-kVDSetupBuffersSelect = 0x0041
-kVDGrabOneFrameAsyncSelect = 0x0042
-kVDDoneSelect = 0x0043
-kVDSetCompressionSelect = 0x0044
-kVDCompressOneFrameAsyncSelect = 0x0045
-kVDCompressDoneSelect = 0x0046
-kVDReleaseCompressBufferSelect = 0x0047
-kVDGetImageDescriptionSelect = 0x0048
-kVDResetCompressSequenceSelect = 0x0049
-kVDSetCompressionOnOffSelect = 0x004A
-kVDGetCompressionTypesSelect = 0x004B
-kVDSetTimeBaseSelect = 0x004C
-kVDSetFrameRateSelect = 0x004D
-kVDGetDataRateSelect = 0x004E
-kVDGetSoundInputDriverSelect = 0x004F
-kVDGetDMADepthsSelect = 0x0050
-kVDGetPreferredTimeScaleSelect = 0x0051
-kVDReleaseAsyncBuffersSelect = 0x0052
-kVDSetDataRateSelect = 0x0054
-kVDGetTimeCodeSelect = 0x0055
-kVDUseSafeBuffersSelect = 0x0056
-kVDGetSoundInputSourceSelect = 0x0057
-kVDGetCompressionTimeSelect = 0x0058
-kVDSetPreferredPacketSizeSelect = 0x0059
-kVDSetPreferredImageDimensionsSelect = 0x005A
-kVDGetPreferredImageDimensionsSelect = 0x005B
-kVDGetInputNameSelect = 0x005C
-kVDSetDestinationPortSelect = 0x005D
-kVDGetDeviceNameAndFlagsSelect = 0x005E
-kVDCaptureStateChangingSelect = 0x005F
-kVDGetUniqueIDsSelect = 0x0060
-kVDSelectUniqueIDsSelect = 0x0061
-kXMLParseDataRefSelect = 0x0001
-kXMLParseFileSelect = 0x0002
-kXMLParseDisposeXMLDocSelect = 0x0003
-kXMLParseGetDetailedParseErrorSelect = 0x0004
-kXMLParseAddElementSelect = 0x0005
-kXMLParseAddAttributeSelect = 0x0006
-kXMLParseAddMultipleAttributesSelect = 0x0007
-kXMLParseAddAttributeAndValueSelect = 0x0008
-kXMLParseAddMultipleAttributesAndValuesSelect = 0x0009
-kXMLParseAddAttributeValueKindSelect = 0x000A
-kXMLParseAddNameSpaceSelect = 0x000B
-kXMLParseSetOffsetAndLimitSelect = 0x000C
-kXMLParseSetEventParseRefConSelect = 0x000D
-kXMLParseSetStartDocumentHandlerSelect = 0x000E
-kXMLParseSetEndDocumentHandlerSelect = 0x000F
-kXMLParseSetStartElementHandlerSelect = 0x0010
-kXMLParseSetEndElementHandlerSelect = 0x0011
-kXMLParseSetCharDataHandlerSelect = 0x0012
-kXMLParseSetPreprocessInstructionHandlerSelect = 0x0013
-kXMLParseSetCommentHandlerSelect = 0x0014
-kXMLParseSetCDataHandlerSelect = 0x0015
-kSGInitializeSelect = 0x0001
-kSGSetDataOutputSelect = 0x0002
-kSGGetDataOutputSelect = 0x0003
-kSGSetGWorldSelect = 0x0004
-kSGGetGWorldSelect = 0x0005
-kSGNewChannelSelect = 0x0006
-kSGDisposeChannelSelect = 0x0007
-kSGStartPreviewSelect = 0x0010
-kSGStartRecordSelect = 0x0011
-kSGIdleSelect = 0x0012
-kSGStopSelect = 0x0013
-kSGPauseSelect = 0x0014
-kSGPrepareSelect = 0x0015
-kSGReleaseSelect = 0x0016
-kSGGetMovieSelect = 0x0017
-kSGSetMaximumRecordTimeSelect = 0x0018
-kSGGetMaximumRecordTimeSelect = 0x0019
-kSGGetStorageSpaceRemainingSelect = 0x001A
-kSGGetTimeRemainingSelect = 0x001B
-kSGGrabPictSelect = 0x001C
-kSGGetLastMovieResIDSelect = 0x001D
-kSGSetFlagsSelect = 0x001E
-kSGGetFlagsSelect = 0x001F
-kSGSetDataProcSelect = 0x0020
-kSGNewChannelFromComponentSelect = 0x0021
-kSGDisposeDeviceListSelect = 0x0022
-kSGAppendDeviceListToMenuSelect = 0x0023
-kSGSetSettingsSelect = 0x0024
-kSGGetSettingsSelect = 0x0025
-kSGGetIndChannelSelect = 0x0026
-kSGUpdateSelect = 0x0027
-kSGGetPauseSelect = 0x0028
-kSGSettingsDialogSelect = 0x0029
-kSGGetAlignmentProcSelect = 0x002A
-kSGSetChannelSettingsSelect = 0x002B
-kSGGetChannelSettingsSelect = 0x002C
-kSGGetModeSelect = 0x002D
-kSGSetDataRefSelect = 0x002E
-kSGGetDataRefSelect = 0x002F
-kSGNewOutputSelect = 0x0030
-kSGDisposeOutputSelect = 0x0031
-kSGSetOutputFlagsSelect = 0x0032
-kSGSetChannelOutputSelect = 0x0033
-kSGGetDataOutputStorageSpaceRemainingSelect = 0x0034
-kSGHandleUpdateEventSelect = 0x0035
-kSGSetOutputNextOutputSelect = 0x0036
-kSGGetOutputNextOutputSelect = 0x0037
-kSGSetOutputMaximumOffsetSelect = 0x0038
-kSGGetOutputMaximumOffsetSelect = 0x0039
-kSGGetOutputDataReferenceSelect = 0x003A
-kSGWriteExtendedMovieDataSelect = 0x003B
-kSGGetStorageSpaceRemaining64Select = 0x003C
-kSGGetDataOutputStorageSpaceRemaining64Select = 0x003D
-kSGWriteMovieDataSelect = 0x0100
-kSGAddFrameReferenceSelect = 0x0101
-kSGGetNextFrameReferenceSelect = 0x0102
-kSGGetTimeBaseSelect = 0x0103
-kSGSortDeviceListSelect = 0x0104
-kSGAddMovieDataSelect = 0x0105
-kSGChangedSourceSelect = 0x0106
-kSGAddExtendedFrameReferenceSelect = 0x0107
-kSGGetNextExtendedFrameReferenceSelect = 0x0108
-kSGAddExtendedMovieDataSelect = 0x0109
-kSGAddOutputDataRefToMediaSelect = 0x010A
-kSGSetSettingsSummarySelect = 0x010B
-kSGSetChannelUsageSelect = 0x0080
-kSGGetChannelUsageSelect = 0x0081
-kSGSetChannelBoundsSelect = 0x0082
-kSGGetChannelBoundsSelect = 0x0083
-kSGSetChannelVolumeSelect = 0x0084
-kSGGetChannelVolumeSelect = 0x0085
-kSGGetChannelInfoSelect = 0x0086
-kSGSetChannelPlayFlagsSelect = 0x0087
-kSGGetChannelPlayFlagsSelect = 0x0088
-kSGSetChannelMaxFramesSelect = 0x0089
-kSGGetChannelMaxFramesSelect = 0x008A
-kSGSetChannelRefConSelect = 0x008B
-kSGSetChannelClipSelect = 0x008C
-kSGGetChannelClipSelect = 0x008D
-kSGGetChannelSampleDescriptionSelect = 0x008E
-kSGGetChannelDeviceListSelect = 0x008F
-kSGSetChannelDeviceSelect = 0x0090
-kSGSetChannelMatrixSelect = 0x0091
-kSGGetChannelMatrixSelect = 0x0092
-kSGGetChannelTimeScaleSelect = 0x0093
-kSGChannelPutPictureSelect = 0x0094
-kSGChannelSetRequestedDataRateSelect = 0x0095
-kSGChannelGetRequestedDataRateSelect = 0x0096
-kSGChannelSetDataSourceNameSelect = 0x0097
-kSGChannelGetDataSourceNameSelect = 0x0098
-kSGChannelSetCodecSettingsSelect = 0x0099
-kSGChannelGetCodecSettingsSelect = 0x009A
-kSGGetChannelTimeBaseSelect = 0x009B
-kSGGetChannelRefConSelect = 0x009C
-kSGGetChannelDeviceAndInputNamesSelect = 0x009D
-kSGSetChannelDeviceInputSelect = 0x009E
-kSGSetChannelSettingsStateChangingSelect = 0x009F
-kSGInitChannelSelect = 0x0180
-kSGWriteSamplesSelect = 0x0181
-kSGGetDataRateSelect = 0x0182
-kSGAlignChannelRectSelect = 0x0183
-kSGPanelGetDitlSelect = 0x0200
-kSGPanelGetTitleSelect = 0x0201
-kSGPanelCanRunSelect = 0x0202
-kSGPanelInstallSelect = 0x0203
-kSGPanelEventSelect = 0x0204
-kSGPanelItemSelect = 0x0205
-kSGPanelRemoveSelect = 0x0206
-kSGPanelSetGrabberSelect = 0x0207
-kSGPanelSetResFileSelect = 0x0208
-kSGPanelGetSettingsSelect = 0x0209
-kSGPanelSetSettingsSelect = 0x020A
-kSGPanelValidateInputSelect = 0x020B
-kSGPanelSetEventFilterSelect = 0x020C
-kSGPanelGetDITLForSizeSelect = 0x020D
-kSGGetSrcVideoBoundsSelect = 0x0100
-kSGSetVideoRectSelect = 0x0101
-kSGGetVideoRectSelect = 0x0102
-kSGGetVideoCompressorTypeSelect = 0x0103
-kSGSetVideoCompressorTypeSelect = 0x0104
-kSGSetVideoCompressorSelect = 0x0105
-kSGGetVideoCompressorSelect = 0x0106
-kSGGetVideoDigitizerComponentSelect = 0x0107
-kSGSetVideoDigitizerComponentSelect = 0x0108
-kSGVideoDigitizerChangedSelect = 0x0109
-kSGSetVideoBottlenecksSelect = 0x010A
-kSGGetVideoBottlenecksSelect = 0x010B
-kSGGrabFrameSelect = 0x010C
-kSGGrabFrameCompleteSelect = 0x010D
-kSGDisplayFrameSelect = 0x010E
-kSGCompressFrameSelect = 0x010F
-kSGCompressFrameCompleteSelect = 0x0110
-kSGAddFrameSelect = 0x0111
-kSGTransferFrameForCompressSelect = 0x0112
-kSGSetCompressBufferSelect = 0x0113
-kSGGetCompressBufferSelect = 0x0114
-kSGGetBufferInfoSelect = 0x0115
-kSGSetUseScreenBufferSelect = 0x0116
-kSGGetUseScreenBufferSelect = 0x0117
-kSGGrabCompressCompleteSelect = 0x0118
-kSGDisplayCompressSelect = 0x0119
-kSGSetFrameRateSelect = 0x011A
-kSGGetFrameRateSelect = 0x011B
-kSGSetPreferredPacketSizeSelect = 0x0121
-kSGGetPreferredPacketSizeSelect = 0x0122
-kSGSetUserVideoCompressorListSelect = 0x0123
-kSGGetUserVideoCompressorListSelect = 0x0124
-kSGSetSoundInputDriverSelect = 0x0100
-kSGGetSoundInputDriverSelect = 0x0101
-kSGSoundInputDriverChangedSelect = 0x0102
-kSGSetSoundRecordChunkSizeSelect = 0x0103
-kSGGetSoundRecordChunkSizeSelect = 0x0104
-kSGSetSoundInputRateSelect = 0x0105
-kSGGetSoundInputRateSelect = 0x0106
-kSGSetSoundInputParametersSelect = 0x0107
-kSGGetSoundInputParametersSelect = 0x0108
-kSGSetAdditionalSoundRatesSelect = 0x0109
-kSGGetAdditionalSoundRatesSelect = 0x010A
-kSGSetFontNameSelect = 0x0100
-kSGSetFontSizeSelect = 0x0101
-kSGSetTextForeColorSelect = 0x0102
-kSGSetTextBackColorSelect = 0x0103
-kSGSetJustificationSelect = 0x0104
-kSGGetTextReturnToSpaceValueSelect = 0x0105
-kSGSetTextReturnToSpaceValueSelect = 0x0106
-kSGGetInstrumentSelect = 0x0100
-kSGSetInstrumentSelect = 0x0101
-kQTVideoOutputGetDisplayModeListSelect = 0x0001
-kQTVideoOutputGetCurrentClientNameSelect = 0x0002
-kQTVideoOutputSetClientNameSelect = 0x0003
-kQTVideoOutputGetClientNameSelect = 0x0004
-kQTVideoOutputBeginSelect = 0x0005
-kQTVideoOutputEndSelect = 0x0006
-kQTVideoOutputSetDisplayModeSelect = 0x0007
-kQTVideoOutputGetDisplayModeSelect = 0x0008
-kQTVideoOutputCustomConfigureDisplaySelect = 0x0009
-kQTVideoOutputSaveStateSelect = 0x000A
-kQTVideoOutputRestoreStateSelect = 0x000B
-kQTVideoOutputGetGWorldSelect = 0x000C
-kQTVideoOutputGetGWorldParametersSelect = 0x000D
-kQTVideoOutputGetIndSoundOutputSelect = 0x000E
-kQTVideoOutputGetClockSelect = 0x000F
-kQTVideoOutputSetEchoPortSelect = 0x0010
-kQTVideoOutputGetIndImageDecompressorSelect = 0x0011
-kQTVideoOutputBaseSetEchoPortSelect = 0x0012
-handlerHasSpatial = 1 << 0
-handlerCanClip = 1 << 1
-handlerCanMatte = 1 << 2
-handlerCanTransferMode = 1 << 3
-handlerNeedsBuffer = 1 << 4
-handlerNoIdle = 1 << 5
-handlerNoScheduler = 1 << 6
-handlerWantsTime = 1 << 7
-handlerCGrafPortOnly = 1 << 8
-handlerCanSend = 1 << 9
-handlerCanHandleComplexMatrix = 1 << 10
-handlerWantsDestinationPixels = 1 << 11
-handlerCanSendImageData = 1 << 12
-handlerCanPicSave = 1 << 13
-mMustDraw = 1 << 3
-mAtEnd = 1 << 4
-mPreflightDraw = 1 << 5
-mSyncDrawing = 1 << 6
-mPrecompositeOnly = 1 << 9
-mSoundOnly = 1 << 10
-mDoIdleActionsBeforeDraws = 1 << 11
-mDisableIdleActions = 1 << 12
-mDidDraw = 1 << 0
-mNeedsToDraw = 1 << 2
-mDrawAgain = 1 << 3
-mPartialDraw = 1 << 4
-mWantIdleActions = 1 << 5
-forceUpdateRedraw = 1 << 0
-forceUpdateNewBuffer = 1 << 1
-mHitTestBounds = 1L << 0
-mHitTestImage = 1L << 1
-mHitTestInvisible = 1L << 2
-mHitTestIsClick = 1L << 3
-mOpaque = 1L << 0
-mInvisible = 1L << 1
-kMediaQTIdleFrequencySelector = FOUR_CHAR_CODE('idfq')
-kMediaVideoParamBrightness = 1
-kMediaVideoParamContrast = 2
-kMediaVideoParamHue = 3
-kMediaVideoParamSharpness = 4
-kMediaVideoParamSaturation = 5
-kMediaVideoParamBlackLevel = 6
-kMediaVideoParamWhiteLevel = 7
-kMHInfoEncodedFrameRate = FOUR_CHAR_CODE('orat')
-kEmptyPurgableChunksOverAllowance = 1
-kCallComponentExecuteWiredActionSelect = -9
-kMediaSetChunkManagementFlagsSelect = 0x0415
-kMediaGetChunkManagementFlagsSelect = 0x0416
-kMediaSetPurgeableChunkMemoryAllowanceSelect = 0x0417
-kMediaGetPurgeableChunkMemoryAllowanceSelect = 0x0418
-kMediaEmptyAllPurgeableChunksSelect = 0x0419
-kMediaInitializeSelect = 0x0501
-kMediaSetHandlerCapabilitiesSelect = 0x0502
-kMediaIdleSelect = 0x0503
-kMediaGetMediaInfoSelect = 0x0504
-kMediaPutMediaInfoSelect = 0x0505
-kMediaSetActiveSelect = 0x0506
-kMediaSetRateSelect = 0x0507
-kMediaGGetStatusSelect = 0x0508
-kMediaTrackEditedSelect = 0x0509
-kMediaSetMediaTimeScaleSelect = 0x050A
-kMediaSetMovieTimeScaleSelect = 0x050B
-kMediaSetGWorldSelect = 0x050C
-kMediaSetDimensionsSelect = 0x050D
-kMediaSetClipSelect = 0x050E
-kMediaSetMatrixSelect = 0x050F
-kMediaGetTrackOpaqueSelect = 0x0510
-kMediaSetGraphicsModeSelect = 0x0511
-kMediaGetGraphicsModeSelect = 0x0512
-kMediaGSetVolumeSelect = 0x0513
-kMediaSetSoundBalanceSelect = 0x0514
-kMediaGetSoundBalanceSelect = 0x0515
-kMediaGetNextBoundsChangeSelect = 0x0516
-kMediaGetSrcRgnSelect = 0x0517
-kMediaPrerollSelect = 0x0518
-kMediaSampleDescriptionChangedSelect = 0x0519
-kMediaHasCharacteristicSelect = 0x051A
-kMediaGetOffscreenBufferSizeSelect = 0x051B
-kMediaSetHintsSelect = 0x051C
-kMediaGetNameSelect = 0x051D
-kMediaForceUpdateSelect = 0x051E
-kMediaGetDrawingRgnSelect = 0x051F
-kMediaGSetActiveSegmentSelect = 0x0520
-kMediaInvalidateRegionSelect = 0x0521
-kMediaGetNextStepTimeSelect = 0x0522
-kMediaSetNonPrimarySourceDataSelect = 0x0523
-kMediaChangedNonPrimarySourceSelect = 0x0524
-kMediaTrackReferencesChangedSelect = 0x0525
-kMediaGetSampleDataPointerSelect = 0x0526
-kMediaReleaseSampleDataPointerSelect = 0x0527
-kMediaTrackPropertyAtomChangedSelect = 0x0528
-kMediaSetTrackInputMapReferenceSelect = 0x0529
-kMediaSetVideoParamSelect = 0x052B
-kMediaGetVideoParamSelect = 0x052C
-kMediaCompareSelect = 0x052D
-kMediaGetClockSelect = 0x052E
-kMediaSetSoundOutputComponentSelect = 0x052F
-kMediaGetSoundOutputComponentSelect = 0x0530
-kMediaSetSoundLocalizationDataSelect = 0x0531
-kMediaGetInvalidRegionSelect = 0x053C
-kMediaSampleDescriptionB2NSelect = 0x053E
-kMediaSampleDescriptionN2BSelect = 0x053F
-kMediaQueueNonPrimarySourceDataSelect = 0x0540
-kMediaFlushNonPrimarySourceDataSelect = 0x0541
-kMediaGetURLLinkSelect = 0x0543
-kMediaMakeMediaTimeTableSelect = 0x0545
-kMediaHitTestForTargetRefConSelect = 0x0546
-kMediaHitTestTargetRefConSelect = 0x0547
-kMediaGetActionsForQTEventSelect = 0x0548
-kMediaDisposeTargetRefConSelect = 0x0549
-kMediaTargetRefConsEqualSelect = 0x054A
-kMediaSetActionsCallbackSelect = 0x054B
-kMediaPrePrerollBeginSelect = 0x054C
-kMediaPrePrerollCancelSelect = 0x054D
-kMediaEnterEmptyEditSelect = 0x054F
-kMediaCurrentMediaQueuedDataSelect = 0x0550
-kMediaGetEffectiveVolumeSelect = 0x0551
-kMediaResolveTargetRefConSelect = 0x0552
-kMediaGetSoundLevelMeteringEnabledSelect = 0x0553
-kMediaSetSoundLevelMeteringEnabledSelect = 0x0554
-kMediaGetSoundLevelMeterInfoSelect = 0x0555
-kMediaGetEffectiveSoundBalanceSelect = 0x0556
-kMediaSetScreenLockSelect = 0x0557
-kMediaSetDoMCActionCallbackSelect = 0x0558
-kMediaGetErrorStringSelect = 0x0559
-kMediaGetSoundEqualizerBandsSelect = 0x055A
-kMediaSetSoundEqualizerBandsSelect = 0x055B
-kMediaGetSoundEqualizerBandLevelsSelect = 0x055C
-kMediaDoIdleActionsSelect = 0x055D
-kMediaSetSoundBassAndTrebleSelect = 0x055E
-kMediaGetSoundBassAndTrebleSelect = 0x055F
-kMediaTimeBaseChangedSelect = 0x0560
-kMediaMCIsPlayerEventSelect = 0x0561
-kMediaGetMediaLoadStateSelect = 0x0562
-kMediaVideoOutputChangedSelect = 0x0563
-kMediaEmptySampleCacheSelect = 0x0564
-kMediaGetPublicInfoSelect = 0x0565
-kMediaSetPublicInfoSelect = 0x0566
-kMediaGetUserPreferredCodecsSelect = 0x0567
-kMediaSetUserPreferredCodecsSelect = 0x0568
-kMediaRefConSetPropertySelect = 0x0569
-kMediaRefConGetPropertySelect = 0x056A
-kMediaNavigateTargetRefConSelect = 0x056B
-kMediaGGetIdleManagerSelect = 0x056C
-kMediaGSetIdleManagerSelect = 0x056D
-kaiToneDescType = FOUR_CHAR_CODE('tone')
-kaiNoteRequestInfoType = FOUR_CHAR_CODE('ntrq')
-kaiKnobListType = FOUR_CHAR_CODE('knbl')
-kaiKeyRangeInfoType = FOUR_CHAR_CODE('sinf')
-kaiSampleDescType = FOUR_CHAR_CODE('sdsc')
-kaiSampleInfoType = FOUR_CHAR_CODE('smin')
-kaiSampleDataType = FOUR_CHAR_CODE('sdat')
-kaiSampleDataQUIDType = FOUR_CHAR_CODE('quid')
-kaiInstInfoType = FOUR_CHAR_CODE('iinf')
-kaiPictType = FOUR_CHAR_CODE('pict')
-kaiWriterType = FOUR_CHAR_CODE('\xa9wrt')
-kaiCopyrightType = FOUR_CHAR_CODE('\xa9cpy')
-kaiOtherStrType = FOUR_CHAR_CODE('str ')
-kaiInstrumentRefType = FOUR_CHAR_CODE('iref')
-kaiInstGMQualityType = FOUR_CHAR_CODE('qual')
-kaiLibraryInfoType = FOUR_CHAR_CODE('linf')
-kaiLibraryDescType = FOUR_CHAR_CODE('ldsc')
-kInstKnobMissingUnknown = 0
-kInstKnobMissingDefault = (1 << 0)
-kMusicLoopTypeNormal = 0
-kMusicLoopTypePalindrome = 1
-instSamplePreProcessFlag = 1 << 0
-kQTMIDIComponentType = FOUR_CHAR_CODE('midi')
-kOMSComponentSubType = FOUR_CHAR_CODE('OMS ')
-kFMSComponentSubType = FOUR_CHAR_CODE('FMS ')
-kMIDIManagerComponentSubType = FOUR_CHAR_CODE('mmgr')
-kOSXMIDIComponentSubType = FOUR_CHAR_CODE('osxm')
-kMusicPacketPortLost = 1
-kMusicPacketPortFound = 2
-kMusicPacketTimeGap = 3
-kAppleSysexID = 0x11
-kAppleSysexCmdSampleSize = 0x0001
-kAppleSysexCmdSampleBreak = 0x0002
-kAppleSysexCmdAtomicInstrument = 0x0010
-kAppleSysexCmdDeveloper = 0x7F00
-kSynthesizerConnectionFMS = 1
-kSynthesizerConnectionMMgr = 2
-kSynthesizerConnectionOMS = 4
-kSynthesizerConnectionQT = 8
-kSynthesizerConnectionOSXMIDI = 16
-kSynthesizerConnectionUnavailable = 256
-kMusicComponentType = FOUR_CHAR_CODE('musi')
-kInstrumentComponentType = FOUR_CHAR_CODE('inst')
-kSoftSynthComponentSubType = FOUR_CHAR_CODE('ss ')
-kGMSynthComponentSubType = FOUR_CHAR_CODE('gm ')
-kSynthesizerDynamicVoice = 1 << 0
-kSynthesizerUsesMIDIPort = 1 << 1
-kSynthesizerMicrotone = 1 << 2
-kSynthesizerHasSamples = 1 << 3
-kSynthesizerMixedDrums = 1 << 4
-kSynthesizerSoftware = 1 << 5
-kSynthesizerHardware = 1 << 6
-kSynthesizerDynamicChannel = 1 << 7
-kSynthesizerHogsSystemChannel = 1 << 8
-kSynthesizerHasSystemChannel = 1 << 9
-kSynthesizerSlowSetPart = 1 << 10
-kSynthesizerOffline = 1 << 12
-kSynthesizerGM = 1 << 14
-kSynthesizerDLS = 1 << 15
-kSynthesizerSoundLocalization = 1 << 16
-kControllerModulationWheel = 1
-kControllerBreath = 2
-kControllerFoot = 4
-kControllerPortamentoTime = 5
-kControllerVolume = 7
-kControllerBalance = 8
-kControllerPan = 10
-kControllerExpression = 11
-kControllerLever1 = 16
-kControllerLever2 = 17
-kControllerLever3 = 18
-kControllerLever4 = 19
-kControllerLever5 = 80
-kControllerLever6 = 81
-kControllerLever7 = 82
-kControllerLever8 = 83
-kControllerPitchBend = 32
-kControllerAfterTouch = 33
-kControllerPartTranspose = 40
-kControllerTuneTranspose = 41
-kControllerPartVolume = 42
-kControllerTuneVolume = 43
-kControllerSustain = 64
-kControllerPortamento = 65
-kControllerSostenuto = 66
-kControllerSoftPedal = 67
-kControllerReverb = 91
-kControllerTremolo = 92
-kControllerChorus = 93
-kControllerCeleste = 94
-kControllerPhaser = 95
-kControllerEditPart = 113
-kControllerMasterTune = 114
-kControllerMasterTranspose = 114
-kControllerMasterVolume = 115
-kControllerMasterCPULoad = 116
-kControllerMasterPolyphony = 117
-kControllerMasterFeatures = 118
-kQTMSKnobStartID = 0x02000000
-kQTMSKnobVolumeAttackTimeID = 0x02000001
-kQTMSKnobVolumeDecayTimeID = 0x02000002
-kQTMSKnobVolumeSustainLevelID = 0x02000003
-kQTMSKnobVolumeRelease1RateID = 0x02000004
-kQTMSKnobVolumeDecayKeyScalingID = 0x02000005
-kQTMSKnobVolumeReleaseTimeID = 0x02000006
-kQTMSKnobVolumeLFODelayID = 0x02000007
-kQTMSKnobVolumeLFORampTimeID = 0x02000008
-kQTMSKnobVolumeLFOPeriodID = 0x02000009
-kQTMSKnobVolumeLFOShapeID = 0x0200000A
-kQTMSKnobVolumeLFODepthID = 0x0200000B
-kQTMSKnobVolumeOverallID = 0x0200000C
-kQTMSKnobVolumeVelocity127ID = 0x0200000D
-kQTMSKnobVolumeVelocity96ID = 0x0200000E
-kQTMSKnobVolumeVelocity64ID = 0x0200000F
-kQTMSKnobVolumeVelocity32ID = 0x02000010
-kQTMSKnobVolumeVelocity16ID = 0x02000011
-kQTMSKnobPitchTransposeID = 0x02000012
-kQTMSKnobPitchLFODelayID = 0x02000013
-kQTMSKnobPitchLFORampTimeID = 0x02000014
-kQTMSKnobPitchLFOPeriodID = 0x02000015
-kQTMSKnobPitchLFOShapeID = 0x02000016
-kQTMSKnobPitchLFODepthID = 0x02000017
-kQTMSKnobPitchLFOQuantizeID = 0x02000018
-kQTMSKnobStereoDefaultPanID = 0x02000019
-kQTMSKnobStereoPositionKeyScalingID = 0x0200001A
-kQTMSKnobPitchLFOOffsetID = 0x0200001B
-kQTMSKnobExclusionGroupID = 0x0200001C
-kQTMSKnobSustainTimeID = 0x0200001D
-kQTMSKnobSustainInfiniteID = 0x0200001E
-kQTMSKnobVolumeLFOStereoID = 0x0200001F
-kQTMSKnobVelocityLowID = 0x02000020
-kQTMSKnobVelocityHighID = 0x02000021
-kQTMSKnobVelocitySensitivityID = 0x02000022
-kQTMSKnobPitchSensitivityID = 0x02000023
-kQTMSKnobVolumeLFODepthFromWheelID = 0x02000024
-kQTMSKnobPitchLFODepthFromWheelID = 0x02000025
-kQTMSKnobVolumeExpOptionsID = 0x02000026
-kQTMSKnobEnv1AttackTimeID = 0x02000027
-kQTMSKnobEnv1DecayTimeID = 0x02000028
-kQTMSKnobEnv1SustainLevelID = 0x02000029
-kQTMSKnobEnv1SustainTimeID = 0x0200002A
-kQTMSKnobEnv1SustainInfiniteID = 0x0200002B
-kQTMSKnobEnv1ReleaseTimeID = 0x0200002C
-kQTMSKnobEnv1ExpOptionsID = 0x0200002D
-kQTMSKnobEnv2AttackTimeID = 0x0200002E
-kQTMSKnobEnv2DecayTimeID = 0x0200002F
-kQTMSKnobEnv2SustainLevelID = 0x02000030
-kQTMSKnobEnv2SustainTimeID = 0x02000031
-kQTMSKnobEnv2SustainInfiniteID = 0x02000032
-kQTMSKnobEnv2ReleaseTimeID = 0x02000033
-kQTMSKnobEnv2ExpOptionsID = 0x02000034
-kQTMSKnobPitchEnvelopeID = 0x02000035
-kQTMSKnobPitchEnvelopeDepthID = 0x02000036
-kQTMSKnobFilterKeyFollowID = 0x02000037
-kQTMSKnobFilterTransposeID = 0x02000038
-kQTMSKnobFilterQID = 0x02000039
-kQTMSKnobFilterFrequencyEnvelopeID = 0x0200003A
-kQTMSKnobFilterFrequencyEnvelopeDepthID = 0x0200003B
-kQTMSKnobFilterQEnvelopeID = 0x0200003C
-kQTMSKnobFilterQEnvelopeDepthID = 0x0200003D
-kQTMSKnobReverbThresholdID = 0x0200003E
-kQTMSKnobVolumeAttackVelScalingID = 0x0200003F
-kQTMSKnobLastIDPlus1 = 0x02000040
-kControllerMaximum = 0x00007FFF
-# kControllerMinimum = (long)0xFFFF8000
-kVoiceCountDynamic = -1
-kFirstGMInstrument = 0x00000001
-kLastGMInstrument = 0x00000080
-kFirstGSInstrument = 0x00000081
-kLastGSInstrument = 0x00003FFF
-kFirstDrumkit = 0x00004000
-kLastDrumkit = 0x00004080
-kFirstROMInstrument = 0x00008000
-kLastROMInstrument = 0x0000FFFF
-kFirstUserInstrument = 0x00010000
-kLastUserInstrument = 0x0001FFFF
-kInstrumentMatchSynthesizerType = 1
-kInstrumentMatchSynthesizerName = 2
-kInstrumentMatchName = 4
-kInstrumentMatchNumber = 8
-kInstrumentMatchGMNumber = 16
-kInstrumentMatchGSNumber = 32
-kKnobBasic = 8
-kKnobReadOnly = 16
-kKnobInterruptUnsafe = 32
-kKnobKeyrangeOverride = 64
-kKnobGroupStart = 128
-kKnobFixedPoint8 = 1024
-kKnobFixedPoint16 = 2048
-kKnobTypeNumber = 0 << 12
-kKnobTypeGroupName = 1 << 12
-kKnobTypeBoolean = 2 << 12
-kKnobTypeNote = 3 << 12
-kKnobTypePan = 4 << 12
-kKnobTypeInstrument = 5 << 12
-kKnobTypeSetting = 6 << 12
-kKnobTypeMilliseconds = 7 << 12
-kKnobTypePercentage = 8 << 12
-kKnobTypeHertz = 9 << 12
-kKnobTypeButton = 10 << 12
-kUnknownKnobValue = 0x7FFFFFFF
-kDefaultKnobValue = 0x7FFFFFFE
-notImplementedMusicErr = (0x80000000 | (0xFFFF & (notImplementedMusicOSErr)))
-cantSendToSynthesizerErr = (0x80000000 | (0xFFFF & (cantSendToSynthesizerOSErr)))
-cantReceiveFromSynthesizerErr = (0x80000000 | (0xFFFF & (cantReceiveFromSynthesizerOSErr)))
-illegalVoiceAllocationErr = (0x80000000 | (0xFFFF & (illegalVoiceAllocationOSErr)))
-illegalPartErr = (0x80000000 | (0xFFFF & (illegalPartOSErr)))
-illegalChannelErr = (0x80000000 | (0xFFFF & (illegalChannelOSErr)))
-illegalKnobErr = (0x80000000 | (0xFFFF & (illegalKnobOSErr)))
-illegalKnobValueErr = (0x80000000 | (0xFFFF & (illegalKnobValueOSErr)))
-illegalInstrumentErr = (0x80000000 | (0xFFFF & (illegalInstrumentOSErr)))
-illegalControllerErr = (0x80000000 | (0xFFFF & (illegalControllerOSErr)))
-midiManagerAbsentErr = (0x80000000 | (0xFFFF & (midiManagerAbsentOSErr)))
-synthesizerNotRespondingErr = (0x80000000 | (0xFFFF & (synthesizerNotRespondingOSErr)))
-synthesizerErr = (0x80000000 | (0xFFFF & (synthesizerOSErr)))
-illegalNoteChannelErr = (0x80000000 | (0xFFFF & (illegalNoteChannelOSErr)))
-noteChannelNotAllocatedErr = (0x80000000 | (0xFFFF & (noteChannelNotAllocatedOSErr)))
-tunePlayerFullErr = (0x80000000 | (0xFFFF & (tunePlayerFullOSErr)))
-tuneParseErr = (0x80000000 | (0xFFFF & (tuneParseOSErr)))
-kGetAtomicInstNoExpandedSamples = 1 << 0
-kGetAtomicInstNoOriginalSamples = 1 << 1
-kGetAtomicInstNoSamples = kGetAtomicInstNoExpandedSamples | kGetAtomicInstNoOriginalSamples
-kGetAtomicInstNoKnobList = 1 << 2
-kGetAtomicInstNoInstrumentInfo = 1 << 3
-kGetAtomicInstOriginalKnobList = 1 << 4
-kGetAtomicInstAllKnobs = 1 << 5
-kSetAtomicInstKeepOriginalInstrument = 1 << 0
-kSetAtomicInstShareAcrossParts = 1 << 1
-kSetAtomicInstCallerTosses = 1 << 2
-kSetAtomicInstCallerGuarantees = 1 << 3
-kSetAtomicInstInterruptSafe = 1 << 4
-kSetAtomicInstDontPreprocess = 1 << 7
-kInstrumentNamesModifiable = 1
-kInstrumentNamesBoth = 2
-kGenericMusicComponentSubtype = FOUR_CHAR_CODE('gene')
-kGenericMusicKnob = 1
-kGenericMusicInstrumentKnob = 2
-kGenericMusicDrumKnob = 3
-kGenericMusicGlobalController = 4
-kGenericMusicResFirst = 0
-kGenericMusicResMiscStringList = 1
-kGenericMusicResMiscLongList = 2
-kGenericMusicResInstrumentList = 3
-kGenericMusicResDrumList = 4
-kGenericMusicResInstrumentKnobDescriptionList = 5
-kGenericMusicResDrumKnobDescriptionList = 6
-kGenericMusicResKnobDescriptionList = 7
-kGenericMusicResBitsLongList = 8
-kGenericMusicResModifiableInstrumentHW = 9
-kGenericMusicResGMTranslation = 10
-kGenericMusicResROMInstrumentData = 11
-kGenericMusicResAboutPICT = 12
-kGenericMusicResLast = 13
-kGenericMusicMiscLongFirst = 0
-kGenericMusicMiscLongVoiceCount = 1
-kGenericMusicMiscLongPartCount = 2
-kGenericMusicMiscLongModifiableInstrumentCount = 3
-kGenericMusicMiscLongChannelMask = 4
-kGenericMusicMiscLongDrumPartCount = 5
-kGenericMusicMiscLongModifiableDrumCount = 6
-kGenericMusicMiscLongDrumChannelMask = 7
-kGenericMusicMiscLongOutputCount = 8
-kGenericMusicMiscLongLatency = 9
-kGenericMusicMiscLongFlags = 10
-kGenericMusicMiscLongFirstGMHW = 11
-kGenericMusicMiscLongFirstGMDrumHW = 12
-kGenericMusicMiscLongFirstUserHW = 13
-kGenericMusicMiscLongLast = 14
-kMusicGenericRange = 0x0100
-kMusicDerivedRange = 0x0200
-kGenericMusicDoMIDI = 1 << 0
-kGenericMusicBank0 = 1 << 1
-kGenericMusicBank32 = 1 << 2
-kGenericMusicErsatzMIDI = 1 << 3
-kGenericMusicCallKnobs = 1 << 4
-kGenericMusicCallParts = 1 << 5
-kGenericMusicCallInstrument = 1 << 6
-kGenericMusicCallNumber = 1 << 7
-kGenericMusicCallROMInstrument = 1 << 8
-kGenericMusicAllDefaults = 1 << 9
-kGetInstrumentInfoNoBuiltIn = 1 << 0
-kGetInstrumentInfoMidiUserInst = 1 << 1
-kGetInstrumentInfoNoIText = 1 << 2
-kNoteRequestNoGM = 1
-kNoteRequestNoSynthType = 2
-kNoteRequestSynthMustMatch = 4
-kNoteRequestSpecifyMIDIChannel = 0x80
-kPickDontMix = 1
-kPickSameSynth = 2
-kPickUserInsts = 4
-kPickEditAllowEdit = 8
-kPickEditAllowPick = 16
-kPickEditSynthGlobal = 32
-kPickEditControllers = 64
-kNoteAllocatorComponentType = FOUR_CHAR_CODE('nota')
-kNADummyOneSelect = 29
-kNADummyTwoSelect = 30
-kTuneQueueDepth = 8
-kTunePlayerComponentType = FOUR_CHAR_CODE('tune')
-kTuneStartNow = 1
-kTuneDontClipNotes = 2
-kTuneExcludeEdgeNotes = 4
-kTuneQuickStart = 8
-kTuneLoopUntil = 16
-kTunePlayDifference = 32
-kTunePlayConcurrent = 64
-kTuneStartNewMaster = 16384
-kTuneStopFade = 1
-kTuneStopSustain = 2
-kTuneStopInstant = 4
-kTuneStopReleaseChannels = 8
-kTuneMixMute = 1
-kTuneMixSolo = 2
-kRestEventType = 0x00000000
-kNoteEventType = 0x00000001
-kControlEventType = 0x00000002
-kMarkerEventType = 0x00000003
-kUndefined1EventType = 0x00000008
-kXNoteEventType = 0x00000009
-kXControlEventType = 0x0000000A
-kKnobEventType = 0x0000000B
-kUndefined2EventType = 0x0000000C
-kUndefined3EventType = 0x0000000D
-kUndefined4EventType = 0x0000000E
-kGeneralEventType = 0x0000000F
-kXEventLengthBits = 0x00000002
-kGeneralEventLengthBits = 0x00000003
-kEventLen = 1L
-kXEventLen = 2L
-kRestEventLen = kEventLen
-kNoteEventLen = kEventLen
-kControlEventLen = kEventLen
-kMarkerEventLen = kEventLen
-kXNoteEventLen = kXEventLen
-kXControlEventLen = kXEventLen
-kGeneralEventLen = kXEventLen
-kEventLengthFieldPos = 30
-kEventLengthFieldWidth = 2
-kEventTypeFieldPos = 29
-kEventTypeFieldWidth = 3
-kXEventTypeFieldPos = 28
-kXEventTypeFieldWidth = 4
-kEventPartFieldPos = 24
-kEventPartFieldWidth = 5
-kXEventPartFieldPos = 16
-kXEventPartFieldWidth = 12
-kRestEventDurationFieldPos = 0
-kRestEventDurationFieldWidth = 24
-kRestEventDurationMax = ((1L << kRestEventDurationFieldWidth) - 1)
-kNoteEventPitchFieldPos = 18
-kNoteEventPitchFieldWidth = 6
-kNoteEventPitchOffset = 32
-kNoteEventVolumeFieldPos = 11
-kNoteEventVolumeFieldWidth = 7
-kNoteEventVolumeOffset = 0
-kNoteEventDurationFieldPos = 0
-kNoteEventDurationFieldWidth = 11
-kNoteEventDurationMax = ((1L << kNoteEventDurationFieldWidth) - 1)
-kXNoteEventPitchFieldPos = 0
-kXNoteEventPitchFieldWidth = 16
-kXNoteEventDurationFieldPos = 0
-kXNoteEventDurationFieldWidth = 22
-kXNoteEventDurationMax = ((1L << kXNoteEventDurationFieldWidth) - 1)
-kXNoteEventVolumeFieldPos = 22
-kXNoteEventVolumeFieldWidth = 7
-kControlEventControllerFieldPos = 16
-kControlEventControllerFieldWidth = 8
-kControlEventValueFieldPos = 0
-kControlEventValueFieldWidth = 16
-kXControlEventControllerFieldPos = 0
-kXControlEventControllerFieldWidth = 16
-kXControlEventValueFieldPos = 0
-kXControlEventValueFieldWidth = 16
-kKnobEventValueHighFieldPos = 0
-kKnobEventValueHighFieldWidth = 16
-kKnobEventKnobFieldPos = 16
-kKnobEventKnobFieldWidth = 14
-kKnobEventValueLowFieldPos = 0
-kKnobEventValueLowFieldWidth = 16
-kMarkerEventSubtypeFieldPos = 16
-kMarkerEventSubtypeFieldWidth = 8
-kMarkerEventValueFieldPos = 0
-kMarkerEventValueFieldWidth = 16
-kGeneralEventSubtypeFieldPos = 16
-kGeneralEventSubtypeFieldWidth = 14
-kGeneralEventLengthFieldPos = 0
-kGeneralEventLengthFieldWidth = 16
-kEndMarkerValue = 0x00000060
-kEndMarkerValue = 0x60000000
-# _ext = qtma_EXT(*lP
-# ulen = (_ext < 2) ? 1 : 2
-# ulen = (unsigned short)qtma_EXT(*lP
-# ulen = lP[1]
-# _ext = qtma_EXT(*lP
-# ulen = (_ext < 2) ? 1 : 2
-# ulen = (unsigned short)qtma_EXT(*lP
-# ulen = lP[-1]
-# x = (kRestEventType << kEventTypeFieldPos) \
-# x = EndianU32_NtoB(x) )
-# x = (kNoteEventType << kEventTypeFieldPos) \
-# x = EndianU32_NtoB(x) )
-# x = (kControlEventType << kEventTypeFieldPos) \
-# x = EndianU32_NtoB(x) )
-# x = (kMarkerEventType << kEventTypeFieldPos) \
-# x = EndianU32_NtoB(x) )
-# w1 = (kXNoteEventType << kXEventTypeFieldPos) \
-# w1 = EndianU32_NtoB(w1)
-# w2 = (kXEventLengthBits << kEventLengthFieldPos) \
-# w2 = EndianU32_NtoB(w2) )
-# w1 = (kXControlEventType << kXEventTypeFieldPos) \
-# w1 = EndianU32_NtoB(w1)
-# w2 = (kXEventLengthBits << kEventLengthFieldPos) \
-# w2 = EndianU32_NtoB(w2) )
-# w1 = (kKnobEventType << kXEventTypeFieldPos) \
-# w1 = EndianU32_NtoB(w1)
-# w2 = (kXEventLengthBits << kEventLengthFieldPos) \
-# w2 = EndianU32_NtoB(w2) )
-# w1 = (kGeneralEventType << kXEventTypeFieldPos) \
-# w1 = EndianU32_NtoB(w1)
-# w2 = (kGeneralEventLengthBits << kEventLengthFieldPos) \
-# w2 = EndianU32_NtoB(w2) )
-kGeneralEventNoteRequest = 1
-kGeneralEventPartKey = 4
-kGeneralEventTuneDifference = 5
-kGeneralEventAtomicInstrument = 6
-kGeneralEventKnob = 7
-kGeneralEventMIDIChannel = 8
-kGeneralEventPartChange = 9
-kGeneralEventNoOp = 10
-kGeneralEventUsedNotes = 11
-kGeneralEventPartMix = 12
-kMarkerEventEnd = 0
-kMarkerEventBeat = 1
-kMarkerEventTempo = 2
-kCurrentlyNativeEndian = 1
-kCurrentlyNotNativeEndian = 2
-kQTMIDIGetMIDIPortsSelect = 0x0001
-kQTMIDIUseSendPortSelect = 0x0002
-kQTMIDISendMIDISelect = 0x0003
-kMusicGetDescriptionSelect = 0x0001
-kMusicGetPartSelect = 0x0002
-kMusicSetPartSelect = 0x0003
-kMusicSetPartInstrumentNumberSelect = 0x0004
-kMusicGetPartInstrumentNumberSelect = 0x0005
-kMusicStorePartInstrumentSelect = 0x0006
-kMusicGetPartAtomicInstrumentSelect = 0x0009
-kMusicSetPartAtomicInstrumentSelect = 0x000A
-kMusicGetPartKnobSelect = 0x0010
-kMusicSetPartKnobSelect = 0x0011
-kMusicGetKnobSelect = 0x0012
-kMusicSetKnobSelect = 0x0013
-kMusicGetPartNameSelect = 0x0014
-kMusicSetPartNameSelect = 0x0015
-kMusicFindToneSelect = 0x0016
-kMusicPlayNoteSelect = 0x0017
-kMusicResetPartSelect = 0x0018
-kMusicSetPartControllerSelect = 0x0019
-kMusicGetPartControllerSelect = 0x001A
-kMusicGetMIDIProcSelect = 0x001B
-kMusicSetMIDIProcSelect = 0x001C
-kMusicGetInstrumentNamesSelect = 0x001D
-kMusicGetDrumNamesSelect = 0x001E
-kMusicGetMasterTuneSelect = 0x001F
-kMusicSetMasterTuneSelect = 0x0020
-kMusicGetInstrumentAboutInfoSelect = 0x0022
-kMusicGetDeviceConnectionSelect = 0x0023
-kMusicUseDeviceConnectionSelect = 0x0024
-kMusicGetKnobSettingStringsSelect = 0x0025
-kMusicGetMIDIPortsSelect = 0x0026
-kMusicSendMIDISelect = 0x0027
-kMusicStartOfflineSelect = 0x0029
-kMusicSetOfflineTimeToSelect = 0x002A
-kMusicGetInstrumentKnobDescriptionSelect = 0x002B
-kMusicGetDrumKnobDescriptionSelect = 0x002C
-kMusicGetKnobDescriptionSelect = 0x002D
-kMusicGetInfoTextSelect = 0x002E
-kMusicGetInstrumentInfoSelect = 0x002F
-kMusicTaskSelect = 0x0031
-kMusicSetPartInstrumentNumberInterruptSafeSelect = 0x0032
-kMusicSetPartSoundLocalizationSelect = 0x0033
-kMusicGenericConfigureSelect = 0x0100
-kMusicGenericGetPartSelect = 0x0101
-kMusicGenericGetKnobListSelect = 0x0102
-kMusicGenericSetResourceNumbersSelect = 0x0103
-kMusicDerivedMIDISendSelect = 0x0200
-kMusicDerivedSetKnobSelect = 0x0201
-kMusicDerivedSetPartSelect = 0x0202
-kMusicDerivedSetInstrumentSelect = 0x0203
-kMusicDerivedSetPartInstrumentNumberSelect = 0x0204
-kMusicDerivedSetMIDISelect = 0x0205
-kMusicDerivedStorePartInstrumentSelect = 0x0206
-kMusicDerivedOpenResFileSelect = 0x0207
-kMusicDerivedCloseResFileSelect = 0x0208
-kNARegisterMusicDeviceSelect = 0x0000
-kNAUnregisterMusicDeviceSelect = 0x0001
-kNAGetRegisteredMusicDeviceSelect = 0x0002
-kNASaveMusicConfigurationSelect = 0x0003
-kNANewNoteChannelSelect = 0x0004
-kNADisposeNoteChannelSelect = 0x0005
-kNAGetNoteChannelInfoSelect = 0x0006
-kNAPrerollNoteChannelSelect = 0x0007
-kNAUnrollNoteChannelSelect = 0x0008
-kNASetNoteChannelVolumeSelect = 0x000B
-kNAResetNoteChannelSelect = 0x000C
-kNAPlayNoteSelect = 0x000D
-kNASetControllerSelect = 0x000E
-kNASetKnobSelect = 0x000F
-kNAFindNoteChannelToneSelect = 0x0010
-kNASetInstrumentNumberSelect = 0x0011
-kNAPickInstrumentSelect = 0x0012
-kNAPickArrangementSelect = 0x0013
-kNAStuffToneDescriptionSelect = 0x001B
-kNACopyrightDialogSelect = 0x001C
-kNAGetIndNoteChannelSelect = 0x001F
-kNAGetMIDIPortsSelect = 0x0021
-kNAGetNoteRequestSelect = 0x0022
-kNASendMIDISelect = 0x0023
-kNAPickEditInstrumentSelect = 0x0024
-kNANewNoteChannelFromAtomicInstrumentSelect = 0x0025
-kNASetAtomicInstrumentSelect = 0x0026
-kNAGetKnobSelect = 0x0028
-kNATaskSelect = 0x0029
-kNASetNoteChannelBalanceSelect = 0x002A
-kNASetInstrumentNumberInterruptSafeSelect = 0x002B
-kNASetNoteChannelSoundLocalizationSelect = 0x002C
-kNAGetControllerSelect = 0x002D
-kTuneSetHeaderSelect = 0x0004
-kTuneGetTimeBaseSelect = 0x0005
-kTuneSetTimeScaleSelect = 0x0006
-kTuneGetTimeScaleSelect = 0x0007
-kTuneGetIndexedNoteChannelSelect = 0x0008
-kTuneQueueSelect = 0x000A
-kTuneInstantSelect = 0x000B
-kTuneGetStatusSelect = 0x000C
-kTuneStopSelect = 0x000D
-kTuneSetVolumeSelect = 0x0010
-kTuneGetVolumeSelect = 0x0011
-kTunePrerollSelect = 0x0012
-kTuneUnrollSelect = 0x0013
-kTuneSetNoteChannelsSelect = 0x0014
-kTuneSetPartTransposeSelect = 0x0015
-kTuneGetNoteAllocatorSelect = 0x0017
-kTuneSetSofterSelect = 0x0018
-kTuneTaskSelect = 0x0019
-kTuneSetBalanceSelect = 0x001A
-kTuneSetSoundLocalizationSelect = 0x001B
-kTuneSetHeaderWithSizeSelect = 0x001C
-kTuneSetPartMixSelect = 0x001D
-kTuneGetPartMixSelect = 0x001E
diff --git a/Lib/plat-mac/Carbon/Res.py b/Lib/plat-mac/Carbon/Res.py
deleted file mode 100644
index 8f45d094648..00000000000
--- a/Lib/plat-mac/Carbon/Res.py
+++ /dev/null
@@ -1,4 +0,0 @@
-try:
- from OverrideFrom23._Res import *
-except ImportError:
- from _Res import *
diff --git a/Lib/plat-mac/Carbon/Resources.py b/Lib/plat-mac/Carbon/Resources.py
deleted file mode 100644
index 2cd876168d0..00000000000
--- a/Lib/plat-mac/Carbon/Resources.py
+++ /dev/null
@@ -1,27 +0,0 @@
-# Generated from 'Resources.h'
-
-resSysHeap = 64
-resPurgeable = 32
-resLocked = 16
-resProtected = 8
-resPreload = 4
-resChanged = 2
-mapReadOnly = 128
-mapCompact = 64
-mapChanged = 32
-resSysRefBit = 7
-resSysHeapBit = 6
-resPurgeableBit = 5
-resLockedBit = 4
-resProtectedBit = 3
-resPreloadBit = 2
-resChangedBit = 1
-mapReadOnlyBit = 7
-mapCompactBit = 6
-mapChangedBit = 5
-kResFileNotOpened = -1
-kSystemResFile = 0
-kRsrcChainBelowSystemMap = 0
-kRsrcChainBelowApplicationMap = 1
-kRsrcChainAboveApplicationMap = 2
-kRsrcChainAboveAllMaps = 4
diff --git a/Lib/plat-mac/Carbon/Scrap.py b/Lib/plat-mac/Carbon/Scrap.py
deleted file mode 100644
index 0dcbd374879..00000000000
--- a/Lib/plat-mac/Carbon/Scrap.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Scrap import *
diff --git a/Lib/plat-mac/Carbon/Snd.py b/Lib/plat-mac/Carbon/Snd.py
deleted file mode 100644
index 679f10b9c03..00000000000
--- a/Lib/plat-mac/Carbon/Snd.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Snd import *
diff --git a/Lib/plat-mac/Carbon/Sndihooks.py b/Lib/plat-mac/Carbon/Sndihooks.py
deleted file mode 100644
index 73a3d284c11..00000000000
--- a/Lib/plat-mac/Carbon/Sndihooks.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Sndihooks import *
diff --git a/Lib/plat-mac/Carbon/Sound.py b/Lib/plat-mac/Carbon/Sound.py
deleted file mode 100644
index 0e7b2fb6449..00000000000
--- a/Lib/plat-mac/Carbon/Sound.py
+++ /dev/null
@@ -1,400 +0,0 @@
-# Generated from 'Sound.h'
-
-def FOUR_CHAR_CODE(x): return x
-soundListRsrc = FOUR_CHAR_CODE('snd ')
-kSimpleBeepID = 1
-# rate48khz = (long)0xBB800000
-# rate44khz = (long)0xAC440000
-rate32khz = 0x7D000000
-rate22050hz = 0x56220000
-rate22khz = 0x56EE8BA3
-rate16khz = 0x3E800000
-rate11khz = 0x2B7745D1
-rate11025hz = 0x2B110000
-rate8khz = 0x1F400000
-sampledSynth = 5
-squareWaveSynth = 1
-waveTableSynth = 3
-MACE3snthID = 11
-MACE6snthID = 13
-kMiddleC = 60
-kNoVolume = 0
-kFullVolume = 0x0100
-stdQLength = 128
-dataOffsetFlag = 0x8000
-kUseOptionalOutputDevice = -1
-notCompressed = 0
-fixedCompression = -1
-variableCompression = -2
-twoToOne = 1
-eightToThree = 2
-threeToOne = 3
-sixToOne = 4
-sixToOnePacketSize = 8
-threeToOnePacketSize = 16
-stateBlockSize = 64
-leftOverBlockSize = 32
-firstSoundFormat = 0x0001
-secondSoundFormat = 0x0002
-dbBufferReady = 0x00000001
-dbLastBuffer = 0x00000004
-sysBeepDisable = 0x0000
-sysBeepEnable = (1 << 0)
-sysBeepSynchronous = (1 << 1)
-unitTypeNoSelection = 0xFFFF
-unitTypeSeconds = 0x0000
-stdSH = 0x00
-extSH = 0xFF
-cmpSH = 0xFE
-nullCmd = 0
-quietCmd = 3
-flushCmd = 4
-reInitCmd = 5
-waitCmd = 10
-pauseCmd = 11
-resumeCmd = 12
-callBackCmd = 13
-syncCmd = 14
-availableCmd = 24
-versionCmd = 25
-volumeCmd = 46
-getVolumeCmd = 47
-clockComponentCmd = 50
-getClockComponentCmd = 51
-scheduledSoundCmd = 52
-linkSoundComponentsCmd = 53
-soundCmd = 80
-bufferCmd = 81
-rateMultiplierCmd = 86
-getRateMultiplierCmd = 87
-initCmd = 1
-freeCmd = 2
-totalLoadCmd = 26
-loadCmd = 27
-freqDurationCmd = 40
-restCmd = 41
-freqCmd = 42
-ampCmd = 43
-timbreCmd = 44
-getAmpCmd = 45
-waveTableCmd = 60
-phaseCmd = 61
-rateCmd = 82
-continueCmd = 83
-doubleBufferCmd = 84
-getRateCmd = 85
-sizeCmd = 90
-convertCmd = 91
-waveInitChannelMask = 0x07
-waveInitChannel0 = 0x04
-waveInitChannel1 = 0x05
-waveInitChannel2 = 0x06
-waveInitChannel3 = 0x07
-initChan0 = waveInitChannel0
-initChan1 = waveInitChannel1
-initChan2 = waveInitChannel2
-initChan3 = waveInitChannel3
-outsideCmpSH = 0
-insideCmpSH = 1
-aceSuccess = 0
-aceMemFull = 1
-aceNilBlock = 2
-aceBadComp = 3
-aceBadEncode = 4
-aceBadDest = 5
-aceBadCmd = 6
-initChanLeft = 0x0002
-initChanRight = 0x0003
-initNoInterp = 0x0004
-initNoDrop = 0x0008
-initMono = 0x0080
-initStereo = 0x00C0
-initMACE3 = 0x0300
-initMACE6 = 0x0400
-initPanMask = 0x0003
-initSRateMask = 0x0030
-initStereoMask = 0x00C0
-initCompMask = 0xFF00
-siActiveChannels = FOUR_CHAR_CODE('chac')
-siActiveLevels = FOUR_CHAR_CODE('lmac')
-siAGCOnOff = FOUR_CHAR_CODE('agc ')
-siAsync = FOUR_CHAR_CODE('asyn')
-siAVDisplayBehavior = FOUR_CHAR_CODE('avdb')
-siChannelAvailable = FOUR_CHAR_CODE('chav')
-siCompressionAvailable = FOUR_CHAR_CODE('cmav')
-siCompressionChannels = FOUR_CHAR_CODE('cpct')
-siCompressionFactor = FOUR_CHAR_CODE('cmfa')
-siCompressionHeader = FOUR_CHAR_CODE('cmhd')
-siCompressionNames = FOUR_CHAR_CODE('cnam')
-siCompressionParams = FOUR_CHAR_CODE('evaw')
-siCompressionSampleRate = FOUR_CHAR_CODE('cprt')
-siCompressionType = FOUR_CHAR_CODE('comp')
-siContinuous = FOUR_CHAR_CODE('cont')
-siDecompressionParams = FOUR_CHAR_CODE('wave')
-siDeviceBufferInfo = FOUR_CHAR_CODE('dbin')
-siDeviceConnected = FOUR_CHAR_CODE('dcon')
-siDeviceIcon = FOUR_CHAR_CODE('icon')
-siDeviceName = FOUR_CHAR_CODE('name')
-siEQSpectrumBands = FOUR_CHAR_CODE('eqsb')
-siEQSpectrumLevels = FOUR_CHAR_CODE('eqlv')
-siEQSpectrumOnOff = FOUR_CHAR_CODE('eqlo')
-siEQSpectrumResolution = FOUR_CHAR_CODE('eqrs')
-siEQToneControlGain = FOUR_CHAR_CODE('eqtg')
-siEQToneControlOnOff = FOUR_CHAR_CODE('eqtc')
-siHardwareBalance = FOUR_CHAR_CODE('hbal')
-siHardwareBalanceSteps = FOUR_CHAR_CODE('hbls')
-siHardwareBass = FOUR_CHAR_CODE('hbas')
-siHardwareBassSteps = FOUR_CHAR_CODE('hbst')
-siHardwareBusy = FOUR_CHAR_CODE('hwbs')
-siHardwareFormat = FOUR_CHAR_CODE('hwfm')
-siHardwareMute = FOUR_CHAR_CODE('hmut')
-siHardwareMuteNoPrefs = FOUR_CHAR_CODE('hmnp')
-siHardwareTreble = FOUR_CHAR_CODE('htrb')
-siHardwareTrebleSteps = FOUR_CHAR_CODE('hwts')
-siHardwareVolume = FOUR_CHAR_CODE('hvol')
-siHardwareVolumeSteps = FOUR_CHAR_CODE('hstp')
-siHeadphoneMute = FOUR_CHAR_CODE('pmut')
-siHeadphoneVolume = FOUR_CHAR_CODE('pvol')
-siHeadphoneVolumeSteps = FOUR_CHAR_CODE('hdst')
-siInputAvailable = FOUR_CHAR_CODE('inav')
-siInputGain = FOUR_CHAR_CODE('gain')
-siInputSource = FOUR_CHAR_CODE('sour')
-siInputSourceNames = FOUR_CHAR_CODE('snam')
-siLevelMeterOnOff = FOUR_CHAR_CODE('lmet')
-siModemGain = FOUR_CHAR_CODE('mgai')
-siMonitorAvailable = FOUR_CHAR_CODE('mnav')
-siMonitorSource = FOUR_CHAR_CODE('mons')
-siNumberChannels = FOUR_CHAR_CODE('chan')
-siOptionsDialog = FOUR_CHAR_CODE('optd')
-siOSTypeInputSource = FOUR_CHAR_CODE('inpt')
-siOSTypeInputAvailable = FOUR_CHAR_CODE('inav')
-siOutputDeviceName = FOUR_CHAR_CODE('onam')
-siPlayThruOnOff = FOUR_CHAR_CODE('plth')
-siPostMixerSoundComponent = FOUR_CHAR_CODE('psmx')
-siPreMixerSoundComponent = FOUR_CHAR_CODE('prmx')
-siQuality = FOUR_CHAR_CODE('qual')
-siRateMultiplier = FOUR_CHAR_CODE('rmul')
-siRecordingQuality = FOUR_CHAR_CODE('qual')
-siSampleRate = FOUR_CHAR_CODE('srat')
-siSampleRateAvailable = FOUR_CHAR_CODE('srav')
-siSampleSize = FOUR_CHAR_CODE('ssiz')
-siSampleSizeAvailable = FOUR_CHAR_CODE('ssav')
-siSetupCDAudio = FOUR_CHAR_CODE('sucd')
-siSetupModemAudio = FOUR_CHAR_CODE('sumd')
-siSlopeAndIntercept = FOUR_CHAR_CODE('flap')
-siSoundClock = FOUR_CHAR_CODE('sclk')
-siUseThisSoundClock = FOUR_CHAR_CODE('sclc')
-siSpeakerMute = FOUR_CHAR_CODE('smut')
-siSpeakerVolume = FOUR_CHAR_CODE('svol')
-siSSpCPULoadLimit = FOUR_CHAR_CODE('3dll')
-siSSpLocalization = FOUR_CHAR_CODE('3dif')
-siSSpSpeakerSetup = FOUR_CHAR_CODE('3dst')
-siStereoInputGain = FOUR_CHAR_CODE('sgai')
-siSubwooferMute = FOUR_CHAR_CODE('bmut')
-siTerminalType = FOUR_CHAR_CODE('ttyp')
-siTwosComplementOnOff = FOUR_CHAR_CODE('twos')
-siVendorProduct = FOUR_CHAR_CODE('vpro')
-siVolume = FOUR_CHAR_CODE('volu')
-siVoxRecordInfo = FOUR_CHAR_CODE('voxr')
-siVoxStopInfo = FOUR_CHAR_CODE('voxs')
-siWideStereo = FOUR_CHAR_CODE('wide')
-siSupportedExtendedFlags = FOUR_CHAR_CODE('exfl')
-siRateConverterRollOffSlope = FOUR_CHAR_CODE('rcdb')
-siOutputLatency = FOUR_CHAR_CODE('olte')
-siCloseDriver = FOUR_CHAR_CODE('clos')
-siInitializeDriver = FOUR_CHAR_CODE('init')
-siPauseRecording = FOUR_CHAR_CODE('paus')
-siUserInterruptProc = FOUR_CHAR_CODE('user')
-# kInvalidSource = (long)0xFFFFFFFF
-kNoSource = FOUR_CHAR_CODE('none')
-kCDSource = FOUR_CHAR_CODE('cd ')
-kExtMicSource = FOUR_CHAR_CODE('emic')
-kSoundInSource = FOUR_CHAR_CODE('sinj')
-kRCAInSource = FOUR_CHAR_CODE('irca')
-kTVFMTunerSource = FOUR_CHAR_CODE('tvfm')
-kDAVInSource = FOUR_CHAR_CODE('idav')
-kIntMicSource = FOUR_CHAR_CODE('imic')
-kMediaBaySource = FOUR_CHAR_CODE('mbay')
-kModemSource = FOUR_CHAR_CODE('modm')
-kPCCardSource = FOUR_CHAR_CODE('pcm ')
-kZoomVideoSource = FOUR_CHAR_CODE('zvpc')
-kDVDSource = FOUR_CHAR_CODE('dvda')
-kMicrophoneArray = FOUR_CHAR_CODE('mica')
-kNoSoundComponentType = FOUR_CHAR_CODE('****')
-kSoundComponentType = FOUR_CHAR_CODE('sift')
-kSoundComponentPPCType = FOUR_CHAR_CODE('nift')
-kRate8SubType = FOUR_CHAR_CODE('ratb')
-kRate16SubType = FOUR_CHAR_CODE('ratw')
-kConverterSubType = FOUR_CHAR_CODE('conv')
-kSndSourceSubType = FOUR_CHAR_CODE('sour')
-kMixerType = FOUR_CHAR_CODE('mixr')
-kMixer8SubType = FOUR_CHAR_CODE('mixb')
-kMixer16SubType = FOUR_CHAR_CODE('mixw')
-kSoundInputDeviceType = FOUR_CHAR_CODE('sinp')
-kWaveInSubType = FOUR_CHAR_CODE('wavi')
-kWaveInSnifferSubType = FOUR_CHAR_CODE('wisn')
-kSoundOutputDeviceType = FOUR_CHAR_CODE('sdev')
-kClassicSubType = FOUR_CHAR_CODE('clas')
-kASCSubType = FOUR_CHAR_CODE('asc ')
-kDSPSubType = FOUR_CHAR_CODE('dsp ')
-kAwacsSubType = FOUR_CHAR_CODE('awac')
-kGCAwacsSubType = FOUR_CHAR_CODE('awgc')
-kSingerSubType = FOUR_CHAR_CODE('sing')
-kSinger2SubType = FOUR_CHAR_CODE('sng2')
-kWhitSubType = FOUR_CHAR_CODE('whit')
-kSoundBlasterSubType = FOUR_CHAR_CODE('sbls')
-kWaveOutSubType = FOUR_CHAR_CODE('wavo')
-kWaveOutSnifferSubType = FOUR_CHAR_CODE('wosn')
-kDirectSoundSubType = FOUR_CHAR_CODE('dsnd')
-kDirectSoundSnifferSubType = FOUR_CHAR_CODE('dssn')
-kUNIXsdevSubType = FOUR_CHAR_CODE('un1x')
-kUSBSubType = FOUR_CHAR_CODE('usb ')
-kBlueBoxSubType = FOUR_CHAR_CODE('bsnd')
-kSoundCompressor = FOUR_CHAR_CODE('scom')
-kSoundDecompressor = FOUR_CHAR_CODE('sdec')
-kAudioComponentType = FOUR_CHAR_CODE('adio')
-kAwacsPhoneSubType = FOUR_CHAR_CODE('hphn')
-kAudioVisionSpeakerSubType = FOUR_CHAR_CODE('telc')
-kAudioVisionHeadphoneSubType = FOUR_CHAR_CODE('telh')
-kPhilipsFaderSubType = FOUR_CHAR_CODE('tvav')
-kSGSToneSubType = FOUR_CHAR_CODE('sgs0')
-kSoundEffectsType = FOUR_CHAR_CODE('snfx')
-kEqualizerSubType = FOUR_CHAR_CODE('eqal')
-kSSpLocalizationSubType = FOUR_CHAR_CODE('snd3')
-kSoundNotCompressed = FOUR_CHAR_CODE('NONE')
-k8BitOffsetBinaryFormat = FOUR_CHAR_CODE('raw ')
-k16BitBigEndianFormat = FOUR_CHAR_CODE('twos')
-k16BitLittleEndianFormat = FOUR_CHAR_CODE('sowt')
-kFloat32Format = FOUR_CHAR_CODE('fl32')
-kFloat64Format = FOUR_CHAR_CODE('fl64')
-k24BitFormat = FOUR_CHAR_CODE('in24')
-k32BitFormat = FOUR_CHAR_CODE('in32')
-k32BitLittleEndianFormat = FOUR_CHAR_CODE('23ni')
-kMACE3Compression = FOUR_CHAR_CODE('MAC3')
-kMACE6Compression = FOUR_CHAR_CODE('MAC6')
-kCDXA4Compression = FOUR_CHAR_CODE('cdx4')
-kCDXA2Compression = FOUR_CHAR_CODE('cdx2')
-kIMACompression = FOUR_CHAR_CODE('ima4')
-kULawCompression = FOUR_CHAR_CODE('ulaw')
-kALawCompression = FOUR_CHAR_CODE('alaw')
-kMicrosoftADPCMFormat = 0x6D730002
-kDVIIntelIMAFormat = 0x6D730011
-kDVAudioFormat = FOUR_CHAR_CODE('dvca')
-kQDesignCompression = FOUR_CHAR_CODE('QDMC')
-kQDesign2Compression = FOUR_CHAR_CODE('QDM2')
-kQUALCOMMCompression = FOUR_CHAR_CODE('Qclp')
-kOffsetBinary = k8BitOffsetBinaryFormat
-kTwosComplement = k16BitBigEndianFormat
-kLittleEndianFormat = k16BitLittleEndianFormat
-kMPEGLayer3Format = 0x6D730055
-kFullMPEGLay3Format = FOUR_CHAR_CODE('.mp3')
-k16BitNativeEndianFormat = k16BitLittleEndianFormat
-k16BitNonNativeEndianFormat = k16BitBigEndianFormat
-k16BitNativeEndianFormat = k16BitBigEndianFormat
-k16BitNonNativeEndianFormat = k16BitLittleEndianFormat
-k8BitRawIn = (1 << 0)
-k8BitTwosIn = (1 << 1)
-k16BitIn = (1 << 2)
-kStereoIn = (1 << 3)
-k8BitRawOut = (1 << 8)
-k8BitTwosOut = (1 << 9)
-k16BitOut = (1 << 10)
-kStereoOut = (1 << 11)
-kReverse = (1L << 16)
-kRateConvert = (1L << 17)
-kCreateSoundSource = (1L << 18)
-kVMAwareness = (1L << 21)
-kHighQuality = (1L << 22)
-kNonRealTime = (1L << 23)
-kSourcePaused = (1 << 0)
-kPassThrough = (1L << 16)
-kNoSoundComponentChain = (1L << 17)
-kNoMixing = (1 << 0)
-kNoSampleRateConversion = (1 << 1)
-kNoSampleSizeConversion = (1 << 2)
-kNoSampleFormatConversion = (1 << 3)
-kNoChannelConversion = (1 << 4)
-kNoDecompression = (1 << 5)
-kNoVolumeConversion = (1 << 6)
-kNoRealtimeProcessing = (1 << 7)
-kScheduledSource = (1 << 8)
-kNonInterleavedBuffer = (1 << 9)
-kNonPagingMixer = (1 << 10)
-kSoundConverterMixer = (1 << 11)
-kPagingMixer = (1 << 12)
-kVMAwareMixer = (1 << 13)
-kExtendedSoundData = (1 << 14)
-kBestQuality = (1 << 0)
-kInputMask = 0x000000FF
-kOutputMask = 0x0000FF00
-kOutputShift = 8
-kActionMask = 0x00FF0000
-kSoundComponentBits = 0x00FFFFFF
-kAudioFormatAtomType = FOUR_CHAR_CODE('frma')
-kAudioEndianAtomType = FOUR_CHAR_CODE('enda')
-kAudioVBRAtomType = FOUR_CHAR_CODE('vbra')
-kAudioTerminatorAtomType = 0
-kAVDisplayHeadphoneRemove = 0
-kAVDisplayHeadphoneInsert = 1
-kAVDisplayPlainTalkRemove = 2
-kAVDisplayPlainTalkInsert = 3
-audioAllChannels = 0
-audioLeftChannel = 1
-audioRightChannel = 2
-audioUnmuted = 0
-audioMuted = 1
-audioDoesMono = (1L << 0)
-audioDoesStereo = (1L << 1)
-audioDoesIndependentChannels = (1L << 2)
-siCDQuality = FOUR_CHAR_CODE('cd ')
-siBestQuality = FOUR_CHAR_CODE('best')
-siBetterQuality = FOUR_CHAR_CODE('betr')
-siGoodQuality = FOUR_CHAR_CODE('good')
-siNoneQuality = FOUR_CHAR_CODE('none')
-siDeviceIsConnected = 1
-siDeviceNotConnected = 0
-siDontKnowIfConnected = -1
-siReadPermission = 0
-siWritePermission = 1
-kSoundConverterDidntFillBuffer = (1 << 0)
-kSoundConverterHasLeftOverData = (1 << 1)
-kExtendedSoundSampleCountNotValid = 1L << 0
-kExtendedSoundBufferSizeValid = 1L << 1
-kScheduledSoundDoScheduled = 1 << 0
-kScheduledSoundDoCallBack = 1 << 1
-kScheduledSoundExtendedHdr = 1 << 2
-kSoundComponentInitOutputDeviceSelect = 0x0001
-kSoundComponentSetSourceSelect = 0x0002
-kSoundComponentGetSourceSelect = 0x0003
-kSoundComponentGetSourceDataSelect = 0x0004
-kSoundComponentSetOutputSelect = 0x0005
-kSoundComponentAddSourceSelect = 0x0101
-kSoundComponentRemoveSourceSelect = 0x0102
-kSoundComponentGetInfoSelect = 0x0103
-kSoundComponentSetInfoSelect = 0x0104
-kSoundComponentStartSourceSelect = 0x0105
-kSoundComponentStopSourceSelect = 0x0106
-kSoundComponentPauseSourceSelect = 0x0107
-kSoundComponentPlaySourceBufferSelect = 0x0108
-kAudioGetVolumeSelect = 0x0000
-kAudioSetVolumeSelect = 0x0001
-kAudioGetMuteSelect = 0x0002
-kAudioSetMuteSelect = 0x0003
-kAudioSetToDefaultsSelect = 0x0004
-kAudioGetInfoSelect = 0x0005
-kAudioGetBassSelect = 0x0006
-kAudioSetBassSelect = 0x0007
-kAudioGetTrebleSelect = 0x0008
-kAudioSetTrebleSelect = 0x0009
-kAudioGetOutputDeviceSelect = 0x000A
-kAudioMuteOnEventSelect = 0x0081
-kDelegatedSoundComponentSelectors = 0x0100
-kSndInputReadAsyncSelect = 0x0001
-kSndInputReadSyncSelect = 0x0002
-kSndInputPauseRecordingSelect = 0x0003
-kSndInputResumeRecordingSelect = 0x0004
-kSndInputStopRecordingSelect = 0x0005
-kSndInputGetStatusSelect = 0x0006
-kSndInputGetDeviceInfoSelect = 0x0007
-kSndInputSetDeviceInfoSelect = 0x0008
-kSndInputInitHardwareSelect = 0x0009
diff --git a/Lib/plat-mac/Carbon/TE.py b/Lib/plat-mac/Carbon/TE.py
deleted file mode 100644
index 4351d7a402d..00000000000
--- a/Lib/plat-mac/Carbon/TE.py
+++ /dev/null
@@ -1 +0,0 @@
-from _TE import *
diff --git a/Lib/plat-mac/Carbon/TextEdit.py b/Lib/plat-mac/Carbon/TextEdit.py
deleted file mode 100644
index 176795af96a..00000000000
--- a/Lib/plat-mac/Carbon/TextEdit.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Generated from 'TextEdit.h'
-
-teJustLeft = 0
-teJustCenter = 1
-teJustRight = -1
-teForceLeft = -2
-teFlushDefault = 0
-teCenter = 1
-teFlushRight = -1
-teFlushLeft = -2
-fontBit = 0
-faceBit = 1
-sizeBit = 2
-clrBit = 3
-addSizeBit = 4
-toggleBit = 5
-doFont = 1
-doFace = 2
-doSize = 4
-doColor = 8
-doAll = 15
-addSize = 16
-doToggle = 32
-EOLHook = 0
-DRAWHook = 4
-WIDTHHook = 8
-HITTESTHook = 12
-nWIDTHHook = 24
-TextWidthHook = 28
-intEOLHook = 0
-intDrawHook = 1
-intWidthHook = 2
-intHitTestHook = 3
-intNWidthHook = 6
-intTextWidthHook = 7
-intInlineInputTSMTEPreUpdateHook = 8
-intInlineInputTSMTEPostUpdateHook = 9
-teFAutoScroll = 0
-teFTextBuffering = 1
-teFOutlineHilite = 2
-teFInlineInput = 3
-teFUseWhiteBackground = 4
-teFUseInlineInput = 5
-teFInlineInputAutoScroll = 6
-teFIdleWithEventLoopTimer = 7
-teBitClear = 0
-teBitSet = 1
-teBitTest = -1
-teWordSelect = 4
-teWordDrag = 8
-teFromFind = 12
-teFromRecal = 16
-teFind = 0
-teHighlight = 1
-teDraw = -1
-teCaret = -2
-teFUseTextServices = 4
diff --git a/Lib/plat-mac/Carbon/Win.py b/Lib/plat-mac/Carbon/Win.py
deleted file mode 100644
index 28057723ebc..00000000000
--- a/Lib/plat-mac/Carbon/Win.py
+++ /dev/null
@@ -1 +0,0 @@
-from _Win import *
diff --git a/Lib/plat-mac/Carbon/Windows.py b/Lib/plat-mac/Carbon/Windows.py
deleted file mode 100644
index b09d53710a3..00000000000
--- a/Lib/plat-mac/Carbon/Windows.py
+++ /dev/null
@@ -1,279 +0,0 @@
-# Generated from 'MacWindows.h'
-
-def FOUR_CHAR_CODE(x): return x
-false = 0
-true = 1
-kWindowNoConstrainAttribute = 0x80000000
-kAlertWindowClass = 1
-kMovableAlertWindowClass = 2
-kModalWindowClass = 3
-kMovableModalWindowClass = 4
-kFloatingWindowClass = 5
-kDocumentWindowClass = 6
-kUtilityWindowClass = 8
-kHelpWindowClass = 10
-kSheetWindowClass = 11
-kToolbarWindowClass = 12
-kPlainWindowClass = 13
-kOverlayWindowClass = 14
-kSheetAlertWindowClass = 15
-kAltPlainWindowClass = 16
-kDrawerWindowClass = 20
-# kAllWindowClasses = (unsigned long)0xFFFFFFFF
-kWindowNoAttributes = 0L
-kWindowCloseBoxAttribute = (1L << 0)
-kWindowHorizontalZoomAttribute = (1L << 1)
-kWindowVerticalZoomAttribute = (1L << 2)
-kWindowFullZoomAttribute = (kWindowVerticalZoomAttribute | kWindowHorizontalZoomAttribute)
-kWindowCollapseBoxAttribute = (1L << 3)
-kWindowResizableAttribute = (1L << 4)
-kWindowSideTitlebarAttribute = (1L << 5)
-kWindowToolbarButtonAttribute = (1L << 6)
-kWindowNoUpdatesAttribute = (1L << 16)
-kWindowNoActivatesAttribute = (1L << 17)
-kWindowOpaqueForEventsAttribute = (1L << 18)
-kWindowNoShadowAttribute = (1L << 21)
-kWindowHideOnSuspendAttribute = (1L << 24)
-kWindowStandardHandlerAttribute = (1L << 25)
-kWindowHideOnFullScreenAttribute = (1L << 26)
-kWindowInWindowMenuAttribute = (1L << 27)
-kWindowLiveResizeAttribute = (1L << 28)
-# kWindowNoConstrainAttribute = (unsigned long)((1L << 31))
-kWindowStandardDocumentAttributes = (kWindowCloseBoxAttribute | kWindowFullZoomAttribute | kWindowCollapseBoxAttribute | kWindowResizableAttribute)
-kWindowStandardFloatingAttributes = (kWindowCloseBoxAttribute | kWindowCollapseBoxAttribute)
-kWindowDefProcType = FOUR_CHAR_CODE('WDEF')
-kStandardWindowDefinition = 0
-kRoundWindowDefinition = 1
-kFloatingWindowDefinition = 124
-kDocumentWindowVariantCode = 0
-kModalDialogVariantCode = 1
-kPlainDialogVariantCode = 2
-kShadowDialogVariantCode = 3
-kMovableModalDialogVariantCode = 5
-kAlertVariantCode = 7
-kMovableAlertVariantCode = 9
-kSideFloaterVariantCode = 8
-documentProc = 0
-dBoxProc = 1
-plainDBox = 2
-altDBoxProc = 3
-noGrowDocProc = 4
-movableDBoxProc = 5
-zoomDocProc = 8
-zoomNoGrow = 12
-floatProc = 1985
-floatGrowProc = 1987
-floatZoomProc = 1989
-floatZoomGrowProc = 1991
-floatSideProc = 1993
-floatSideGrowProc = 1995
-floatSideZoomProc = 1997
-floatSideZoomGrowProc = 1999
-rDocProc = 16
-kWindowDocumentDefProcResID = 64
-kWindowDialogDefProcResID = 65
-kWindowUtilityDefProcResID = 66
-kWindowUtilitySideTitleDefProcResID = 67
-kWindowSheetDefProcResID = 68
-kWindowSimpleDefProcResID = 69
-kWindowSheetAlertDefProcResID = 70
-kWindowDocumentProc = 1024
-kWindowGrowDocumentProc = 1025
-kWindowVertZoomDocumentProc = 1026
-kWindowVertZoomGrowDocumentProc = 1027
-kWindowHorizZoomDocumentProc = 1028
-kWindowHorizZoomGrowDocumentProc = 1029
-kWindowFullZoomDocumentProc = 1030
-kWindowFullZoomGrowDocumentProc = 1031
-kWindowPlainDialogProc = 1040
-kWindowShadowDialogProc = 1041
-kWindowModalDialogProc = 1042
-kWindowMovableModalDialogProc = 1043
-kWindowAlertProc = 1044
-kWindowMovableAlertProc = 1045
-kWindowMovableModalGrowProc = 1046
-kWindowFloatProc = 1057
-kWindowFloatGrowProc = 1059
-kWindowFloatVertZoomProc = 1061
-kWindowFloatVertZoomGrowProc = 1063
-kWindowFloatHorizZoomProc = 1065
-kWindowFloatHorizZoomGrowProc = 1067
-kWindowFloatFullZoomProc = 1069
-kWindowFloatFullZoomGrowProc = 1071
-kWindowFloatSideProc = 1073
-kWindowFloatSideGrowProc = 1075
-kWindowFloatSideVertZoomProc = 1077
-kWindowFloatSideVertZoomGrowProc = 1079
-kWindowFloatSideHorizZoomProc = 1081
-kWindowFloatSideHorizZoomGrowProc = 1083
-kWindowFloatSideFullZoomProc = 1085
-kWindowFloatSideFullZoomGrowProc = 1087
-kWindowSheetProc = 1088
-kWindowSheetAlertProc = 1120
-kWindowSimpleProc = 1104
-kWindowSimpleFrameProc = 1105
-kWindowNoPosition = 0x0000
-kWindowDefaultPosition = 0x0000
-kWindowCenterMainScreen = 0x280A
-kWindowAlertPositionMainScreen = 0x300A
-kWindowStaggerMainScreen = 0x380A
-kWindowCenterParentWindow = 0xA80A
-kWindowAlertPositionParentWindow = 0xB00A
-kWindowStaggerParentWindow = 0xB80A
-kWindowCenterParentWindowScreen = 0x680A
-kWindowAlertPositionParentWindowScreen = 0x700A
-kWindowStaggerParentWindowScreen = 0x780A
-kWindowCenterOnMainScreen = 1
-kWindowCenterOnParentWindow = 2
-kWindowCenterOnParentWindowScreen = 3
-kWindowCascadeOnMainScreen = 4
-kWindowCascadeOnParentWindow = 5
-kWindowCascadeOnParentWindowScreen = 6
-kWindowCascadeStartAtParentWindowScreen = 10
-kWindowAlertPositionOnMainScreen = 7
-kWindowAlertPositionOnParentWindow = 8
-kWindowAlertPositionOnParentWindowScreen = 9
-kWindowTitleBarRgn = 0
-kWindowTitleTextRgn = 1
-kWindowCloseBoxRgn = 2
-kWindowZoomBoxRgn = 3
-kWindowDragRgn = 5
-kWindowGrowRgn = 6
-kWindowCollapseBoxRgn = 7
-kWindowTitleProxyIconRgn = 8
-kWindowStructureRgn = 32
-kWindowContentRgn = 33
-kWindowUpdateRgn = 34
-kWindowOpaqueRgn = 35
-kWindowGlobalPortRgn = 40
-dialogKind = 2
-userKind = 8
-kDialogWindowKind = 2
-kApplicationWindowKind = 8
-inDesk = 0
-inNoWindow = 0
-inMenuBar = 1
-inSysWindow = 2
-inContent = 3
-inDrag = 4
-inGrow = 5
-inGoAway = 6
-inZoomIn = 7
-inZoomOut = 8
-inCollapseBox = 11
-inProxyIcon = 12
-inToolbarButton = 13
-inStructure = 15
-wNoHit = 0
-wInContent = 1
-wInDrag = 2
-wInGrow = 3
-wInGoAway = 4
-wInZoomIn = 5
-wInZoomOut = 6
-wInCollapseBox = 9
-wInProxyIcon = 10
-wInToolbarButton = 11
-wInStructure = 13
-kWindowMsgDraw = 0
-kWindowMsgHitTest = 1
-kWindowMsgCalculateShape = 2
-kWindowMsgInitialize = 3
-kWindowMsgCleanUp = 4
-kWindowMsgDrawGrowOutline = 5
-kWindowMsgDrawGrowBox = 6
-kWindowMsgGetFeatures = 7
-kWindowMsgGetRegion = 8
-kWindowMsgDragHilite = 9
-kWindowMsgModified = 10
-kWindowMsgDrawInCurrentPort = 11
-kWindowMsgSetupProxyDragImage = 12
-kWindowMsgStateChanged = 13
-kWindowMsgMeasureTitle = 14
-kWindowMsgGetGrowImageRegion = 19
-wDraw = 0
-wHit = 1
-wCalcRgns = 2
-wNew = 3
-wDispose = 4
-wGrow = 5
-wDrawGIcon = 6
-kWindowStateTitleChanged = (1 << 0)
-kWindowCanGrow = (1 << 0)
-kWindowCanZoom = (1 << 1)
-kWindowCanCollapse = (1 << 2)
-kWindowIsModal = (1 << 3)
-kWindowCanGetWindowRegion = (1 << 4)
-kWindowIsAlert = (1 << 5)
-kWindowHasTitleBar = (1 << 6)
-kWindowSupportsDragHilite = (1 << 7)
-kWindowSupportsModifiedBit = (1 << 8)
-kWindowCanDrawInCurrentPort = (1 << 9)
-kWindowCanSetupProxyDragImage = (1 << 10)
-kWindowCanMeasureTitle = (1 << 11)
-kWindowWantsDisposeAtProcessDeath = (1 << 12)
-kWindowSupportsGetGrowImageRegion = (1 << 13)
-kWindowDefSupportsColorGrafPort = 0x40000002
-kWindowIsOpaque = (1 << 14)
-kWindowSupportsSetGrowImageRegion = (1 << 13)
-deskPatID = 16
-wContentColor = 0
-wFrameColor = 1
-wTextColor = 2
-wHiliteColor = 3
-wTitleBarColor = 4
-# kMouseUpOutOfSlop = (long)0x80008000
-kWindowDefinitionVersionOne = 1
-kWindowDefinitionVersionTwo = 2
-kWindowIsCollapsedState = (1 << 0L)
-kStoredWindowSystemTag = FOUR_CHAR_CODE('appl')
-kStoredBasicWindowDescriptionID = FOUR_CHAR_CODE('sbas')
-kStoredWindowPascalTitleID = FOUR_CHAR_CODE('s255')
-kWindowDefProcPtr = 0
-kWindowDefObjectClass = 1
-kWindowDefProcID = 2
-kWindowModalityNone = 0
-kWindowModalitySystemModal = 1
-kWindowModalityAppModal = 2
-kWindowModalityWindowModal = 3
-kWindowGroupAttrSelectAsLayer = 1 << 0
-kWindowGroupAttrMoveTogether = 1 << 1
-kWindowGroupAttrLayerTogether = 1 << 2
-kWindowGroupAttrSharedActivation = 1 << 3
-kWindowGroupAttrHideOnCollapse = 1 << 4
-kWindowActivationScopeNone = 0
-kWindowActivationScopeIndependent = 1
-kWindowActivationScopeAll = 2
-kNextWindowGroup = true
-kPreviousWindowGroup = false
-kWindowGroupContentsReturnWindows = 1 << 0
-kWindowGroupContentsRecurse = 1 << 1
-kWindowGroupContentsVisible = 1 << 2
-kWindowPaintProcOptionsNone = 0
-kScrollWindowNoOptions = 0
-kScrollWindowInvalidate = (1L << 0)
-kScrollWindowEraseToPortBackground = (1L << 1)
-kWindowMenuIncludeRotate = 1 << 0
-kWindowZoomTransitionEffect = 1
-kWindowSheetTransitionEffect = 2
-kWindowSlideTransitionEffect = 3
-kWindowShowTransitionAction = 1
-kWindowHideTransitionAction = 2
-kWindowMoveTransitionAction = 3
-kWindowResizeTransitionAction = 4
-kWindowConstrainMayResize = (1L << 0)
-kWindowConstrainMoveRegardlessOfFit = (1L << 1)
-kWindowConstrainAllowPartial = (1L << 2)
-kWindowConstrainCalcOnly = (1L << 3)
-kWindowConstrainUseTransitionWindow = (1L << 4)
-kWindowConstrainStandardOptions = kWindowConstrainMoveRegardlessOfFit
-kWindowLatentVisibleFloater = 1 << 0
-kWindowLatentVisibleSuspend = 1 << 1
-kWindowLatentVisibleFullScreen = 1 << 2
-kWindowLatentVisibleAppHidden = 1 << 3
-kWindowLatentVisibleCollapsedOwner = 1 << 4
-kWindowLatentVisibleCollapsedGroup = 1 << 5
-kWindowPropertyPersistent = 0x00000001
-kWindowGroupAttrSelectable = kWindowGroupAttrSelectAsLayer
-kWindowGroupAttrPositionFixed = kWindowGroupAttrMoveTogether
-kWindowGroupAttrZOrderFixed = kWindowGroupAttrLayerTogether
diff --git a/Lib/plat-mac/Carbon/__init__.py b/Lib/plat-mac/Carbon/__init__.py
deleted file mode 100644
index 37a9ae3535a..00000000000
--- a/Lib/plat-mac/Carbon/__init__.py
+++ /dev/null
@@ -1,7 +0,0 @@
-# Filter out warnings about signed/unsigned constants
-import warnings
-warnings.filterwarnings("ignore", "", FutureWarning, ".*Controls")
-warnings.filterwarnings("ignore", "", FutureWarning, ".*MacTextEditor")
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Carbon package is removed.", stacklevel=2)
diff --git a/Lib/plat-mac/EasyDialogs.py b/Lib/plat-mac/EasyDialogs.py
deleted file mode 100644
index 129cf2cae26..00000000000
--- a/Lib/plat-mac/EasyDialogs.py
+++ /dev/null
@@ -1,841 +0,0 @@
-"""Easy to use dialogs.
-
-Message(msg) -- display a message and an OK button.
-AskString(prompt, default) -- ask for a string, display OK and Cancel buttons.
-AskPassword(prompt, default) -- like AskString(), but shows text as bullets.
-AskYesNoCancel(question, default) -- display a question and Yes, No and Cancel buttons.
-GetArgv(optionlist, commandlist) -- fill a sys.argv-like list using a dialog
-AskFileForOpen(...) -- Ask the user for an existing file
-AskFileForSave(...) -- Ask the user for an output file
-AskFolder(...) -- Ask the user to select a folder
-bar = Progress(label, maxvalue) -- Display a progress bar
-bar.set(value) -- Set value
-bar.inc( *amount ) -- increment value by amount (default=1)
-bar.label( *newlabel ) -- get or set text label.
-
-More documentation in each function.
-This module uses DLOG resources 260 and on.
-Based upon STDWIN dialogs with the same names and functions.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the EasyDialogs module is removed.", stacklevel=2)
-
-from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog
-from Carbon import Qd
-from Carbon import QuickDraw
-from Carbon import Dialogs
-from Carbon import Windows
-from Carbon import Dlg,Win,Evt,Events # sdm7g
-from Carbon import Ctl
-from Carbon import Controls
-from Carbon import Menu
-from Carbon import AE
-import Nav
-import MacOS
-import string
-from Carbon.ControlAccessor import * # Also import Controls constants
-import Carbon.File
-import macresource
-import os
-import sys
-
-__all__ = ['Message', 'AskString', 'AskPassword', 'AskYesNoCancel',
- 'GetArgv', 'AskFileForOpen', 'AskFileForSave', 'AskFolder',
- 'ProgressBar']
-
-_initialized = 0
-
-def _initialize():
- global _initialized
- if _initialized: return
- macresource.need("DLOG", 260, "dialogs.rsrc", __name__)
-
-def _interact():
- """Make sure the application is in the foreground"""
- AE.AEInteractWithUser(50000000)
-
-def cr2lf(text):
- if '\r' in text:
- text = string.join(string.split(text, '\r'), '\n')
- return text
-
-def lf2cr(text):
- if '\n' in text:
- text = string.join(string.split(text, '\n'), '\r')
- if len(text) > 253:
- text = text[:253] + '\311'
- return text
-
-def Message(msg, id=260, ok=None):
- """Display a MESSAGE string.
-
- Return when the user clicks the OK button or presses Return.
-
- The MESSAGE string can be at most 255 characters long.
- """
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
- return
- h = d.GetDialogItemAsControl(2)
- SetDialogItemText(h, lf2cr(msg))
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- d.SetDialogDefaultItem(1)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- return
-
-
-def AskString(prompt, default = "", id=261, ok=None, cancel=None):
- """Display a PROMPT string and a text entry field with a DEFAULT string.
-
- Return the contents of the text entry field when the user clicks the
- OK button or presses Return.
- Return None when the user clicks the Cancel button.
-
- If omitted, DEFAULT is empty.
-
- The PROMPT and DEFAULT strings, as well as the return value,
- can be at most 255 characters long.
- """
-
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
- return
- h = d.GetDialogItemAsControl(3)
- SetDialogItemText(h, lf2cr(prompt))
- h = d.GetDialogItemAsControl(4)
- SetDialogItemText(h, lf2cr(default))
- d.SelectDialogItemText(4, 0, 999)
-# d.SetDialogItem(4, 0, 255)
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- if cancel is not None:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(cancel)
- d.SetDialogDefaultItem(1)
- d.SetDialogCancelItem(2)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- h = d.GetDialogItemAsControl(4)
- return cr2lf(GetDialogItemText(h))
- if n == 2: return None
-
-def AskPassword(prompt, default='', id=264, ok=None, cancel=None):
- """Display a PROMPT string and a text entry field with a DEFAULT string.
- The string is displayed as bullets only.
-
- Return the contents of the text entry field when the user clicks the
- OK button or presses Return.
- Return None when the user clicks the Cancel button.
-
- If omitted, DEFAULT is empty.
-
- The PROMPT and DEFAULT strings, as well as the return value,
- can be at most 255 characters long.
- """
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
- return
- h = d.GetDialogItemAsControl(3)
- SetDialogItemText(h, lf2cr(prompt))
- pwd = d.GetDialogItemAsControl(4)
- bullets = '\245'*len(default)
-## SetControlData(pwd, kControlEditTextPart, kControlEditTextTextTag, bullets)
- SetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag, default)
- d.SelectDialogItemText(4, 0, 999)
- Ctl.SetKeyboardFocus(d.GetDialogWindow(), pwd, kControlEditTextPart)
- if ok is not None:
- h = d.GetDialogItemAsControl(1)
- h.SetControlTitle(ok)
- if cancel is not None:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(cancel)
- d.SetDialogDefaultItem(Dialogs.ok)
- d.SetDialogCancelItem(Dialogs.cancel)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1:
- h = d.GetDialogItemAsControl(4)
- return cr2lf(GetControlData(pwd, kControlEditTextPart, kControlEditTextPasswordTag))
- if n == 2: return None
-
-def AskYesNoCancel(question, default = 0, yes=None, no=None, cancel=None, id=262):
- """Display a QUESTION string which can be answered with Yes or No.
-
- Return 1 when the user clicks the Yes button.
- Return 0 when the user clicks the No button.
- Return -1 when the user clicks the Cancel button.
-
- When the user presses Return, the DEFAULT value is returned.
- If omitted, this is 0 (No).
-
- The QUESTION string can be at most 255 characters.
- """
-
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
- return
- # Button assignments:
- # 1 = default (invisible)
- # 2 = Yes
- # 3 = No
- # 4 = Cancel
- # The question string is item 5
- h = d.GetDialogItemAsControl(5)
- SetDialogItemText(h, lf2cr(question))
- if yes is not None:
- if yes == '':
- d.HideDialogItem(2)
- else:
- h = d.GetDialogItemAsControl(2)
- h.SetControlTitle(yes)
- if no is not None:
- if no == '':
- d.HideDialogItem(3)
- else:
- h = d.GetDialogItemAsControl(3)
- h.SetControlTitle(no)
- if cancel is not None:
- if cancel == '':
- d.HideDialogItem(4)
- else:
- h = d.GetDialogItemAsControl(4)
- h.SetControlTitle(cancel)
- d.SetDialogCancelItem(4)
- if default == 1:
- d.SetDialogDefaultItem(2)
- elif default == 0:
- d.SetDialogDefaultItem(3)
- elif default == -1:
- d.SetDialogDefaultItem(4)
- d.AutoSizeDialog()
- d.GetDialogWindow().ShowWindow()
- while 1:
- n = ModalDialog(None)
- if n == 1: return default
- if n == 2: return 1
- if n == 3: return 0
- if n == 4: return -1
-
-
-
-
-screenbounds = Qd.GetQDGlobalsScreenBits().bounds
-screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
- screenbounds[2]-4, screenbounds[3]-4
-
-kControlProgressBarIndeterminateTag = 'inde' # from Controls.py
-
-
-class ProgressBar:
- def __init__(self, title="Working...", maxval=0, label="", id=263):
- self.w = None
- self.d = None
- _initialize()
- self.d = GetNewDialog(id, -1)
- self.w = self.d.GetDialogWindow()
- self.label(label)
- self.title(title)
- self.set(0, maxval)
- self.d.AutoSizeDialog()
- self.w.ShowWindow()
- self.d.DrawDialog()
-
- def __del__(self):
- if self.w:
- self.w.BringToFront()
- self.w.HideWindow()
- del self.w
- del self.d
-
- def title(self, newstr=""):
- """title(text) - Set title of progress window"""
- self.w.BringToFront()
- self.w.SetWTitle(newstr)
-
- def label(self, *newstr):
- """label(text) - Set text in progress box"""
- self.w.BringToFront()
- if newstr:
- self._label = lf2cr(newstr[0])
- text_h = self.d.GetDialogItemAsControl(2)
- SetDialogItemText(text_h, self._label)
-
- def _update(self, value):
- maxval = self.maxval
- if maxval == 0: # an indeterminate bar
- Ctl.IdleControls(self.w) # spin the barber pole
- else: # a determinate bar
- if maxval > 32767:
- value = int(value/(maxval/32767.0))
- maxval = 32767
- maxval = int(maxval)
- value = int(value)
- progbar = self.d.GetDialogItemAsControl(3)
- progbar.SetControlMaximum(maxval)
- progbar.SetControlValue(value) # set the bar length
-
- # Test for cancel button
- ready, ev = Evt.WaitNextEvent( Events.mDownMask, 1 )
- if ready :
- what,msg,when,where,mod = ev
- part = Win.FindWindow(where)[0]
- if Dlg.IsDialogEvent(ev):
- ds = Dlg.DialogSelect(ev)
- if ds[0] and ds[1] == self.d and ds[-1] == 1:
- self.w.HideWindow()
- self.w = None
- self.d = None
- raise KeyboardInterrupt, ev
- else:
- if part == 4: # inDrag
- self.w.DragWindow(where, screenbounds)
- else:
- MacOS.HandleEvent(ev)
-
-
- def set(self, value, max=None):
- """set(value) - Set progress bar position"""
- if max is not None:
- self.maxval = max
- bar = self.d.GetDialogItemAsControl(3)
- if max <= 0: # indeterminate bar
- bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x01')
- else: # determinate bar
- bar.SetControlData(0,kControlProgressBarIndeterminateTag,'\x00')
- if value < 0:
- value = 0
- elif value > self.maxval:
- value = self.maxval
- self.curval = value
- self._update(value)
-
- def inc(self, n=1):
- """inc(amt) - Increment progress bar position"""
- self.set(self.curval + n)
-
-ARGV_ID=265
-ARGV_ITEM_OK=1
-ARGV_ITEM_CANCEL=2
-ARGV_OPTION_GROUP=3
-ARGV_OPTION_EXPLAIN=4
-ARGV_OPTION_VALUE=5
-ARGV_OPTION_ADD=6
-ARGV_COMMAND_GROUP=7
-ARGV_COMMAND_EXPLAIN=8
-ARGV_COMMAND_ADD=9
-ARGV_ADD_OLDFILE=10
-ARGV_ADD_NEWFILE=11
-ARGV_ADD_FOLDER=12
-ARGV_CMDLINE_GROUP=13
-ARGV_CMDLINE_DATA=14
-
-##def _myModalDialog(d):
-## while 1:
-## ready, ev = Evt.WaitNextEvent(0xffff, -1)
-## print 'DBG: WNE', ready, ev
-## if ready :
-## what,msg,when,where,mod = ev
-## part, window = Win.FindWindow(where)
-## if Dlg.IsDialogEvent(ev):
-## didit, dlgdone, itemdone = Dlg.DialogSelect(ev)
-## print 'DBG: DialogSelect', didit, dlgdone, itemdone, d
-## if didit and dlgdone == d:
-## return itemdone
-## elif window == d.GetDialogWindow():
-## d.GetDialogWindow().SelectWindow()
-## if part == 4: # inDrag
-## d.DragWindow(where, screenbounds)
-## else:
-## MacOS.HandleEvent(ev)
-## else:
-## MacOS.HandleEvent(ev)
-##
-def _setmenu(control, items):
- mhandle = control.GetControlData_Handle(Controls.kControlMenuPart,
- Controls.kControlPopupButtonMenuHandleTag)
- menu = Menu.as_Menu(mhandle)
- for item in items:
- if type(item) == type(()):
- label = item[0]
- else:
- label = item
- if label[-1] == '=' or label[-1] == ':':
- label = label[:-1]
- menu.AppendMenu(label)
-## mhandle, mid = menu.getpopupinfo()
-## control.SetControlData_Handle(Controls.kControlMenuPart,
-## Controls.kControlPopupButtonMenuHandleTag, mhandle)
- control.SetControlMinimum(1)
- control.SetControlMaximum(len(items)+1)
-
-def _selectoption(d, optionlist, idx):
- if idx < 0 or idx >= len(optionlist):
- MacOS.SysBeep()
- return
- option = optionlist[idx]
- if type(option) == type(()):
- if len(option) == 4:
- help = option[2]
- elif len(option) > 1:
- help = option[-1]
- else:
- help = ''
- else:
- help = ''
- h = d.GetDialogItemAsControl(ARGV_OPTION_EXPLAIN)
- if help and len(help) > 250:
- help = help[:250] + '...'
- Dlg.SetDialogItemText(h, help)
- hasvalue = 0
- if type(option) == type(()):
- label = option[0]
- else:
- label = option
- if label[-1] == '=' or label[-1] == ':':
- hasvalue = 1
- h = d.GetDialogItemAsControl(ARGV_OPTION_VALUE)
- Dlg.SetDialogItemText(h, '')
- if hasvalue:
- d.ShowDialogItem(ARGV_OPTION_VALUE)
- d.SelectDialogItemText(ARGV_OPTION_VALUE, 0, 0)
- else:
- d.HideDialogItem(ARGV_OPTION_VALUE)
-
-
-def GetArgv(optionlist=None, commandlist=None, addoldfile=1, addnewfile=1, addfolder=1, id=ARGV_ID):
- _initialize()
- _interact()
- d = GetNewDialog(id, -1)
- if not d:
- print "EasyDialogs: Can't get DLOG resource with id =", id, " (missing resource file?)"
- return
-# h = d.GetDialogItemAsControl(3)
-# SetDialogItemText(h, lf2cr(prompt))
-# h = d.GetDialogItemAsControl(4)
-# SetDialogItemText(h, lf2cr(default))
-# d.SelectDialogItemText(4, 0, 999)
-# d.SetDialogItem(4, 0, 255)
- if optionlist:
- _setmenu(d.GetDialogItemAsControl(ARGV_OPTION_GROUP), optionlist)
- _selectoption(d, optionlist, 0)
- else:
- d.GetDialogItemAsControl(ARGV_OPTION_GROUP).DeactivateControl()
- if commandlist:
- _setmenu(d.GetDialogItemAsControl(ARGV_COMMAND_GROUP), commandlist)
- if type(commandlist[0]) == type(()) and len(commandlist[0]) > 1:
- help = commandlist[0][-1]
- h = d.GetDialogItemAsControl(ARGV_COMMAND_EXPLAIN)
- Dlg.SetDialogItemText(h, help)
- else:
- d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).DeactivateControl()
- if not addoldfile:
- d.GetDialogItemAsControl(ARGV_ADD_OLDFILE).DeactivateControl()
- if not addnewfile:
- d.GetDialogItemAsControl(ARGV_ADD_NEWFILE).DeactivateControl()
- if not addfolder:
- d.GetDialogItemAsControl(ARGV_ADD_FOLDER).DeactivateControl()
- d.SetDialogDefaultItem(ARGV_ITEM_OK)
- d.SetDialogCancelItem(ARGV_ITEM_CANCEL)
- d.GetDialogWindow().ShowWindow()
- d.DrawDialog()
- if hasattr(MacOS, 'SchedParams'):
- appsw = MacOS.SchedParams(1, 0)
- try:
- while 1:
- stringstoadd = []
- n = ModalDialog(None)
- if n == ARGV_ITEM_OK:
- break
- elif n == ARGV_ITEM_CANCEL:
- raise SystemExit
- elif n == ARGV_OPTION_GROUP:
- idx = d.GetDialogItemAsControl(ARGV_OPTION_GROUP).GetControlValue()-1
- _selectoption(d, optionlist, idx)
- elif n == ARGV_OPTION_VALUE:
- pass
- elif n == ARGV_OPTION_ADD:
- idx = d.GetDialogItemAsControl(ARGV_OPTION_GROUP).GetControlValue()-1
- if 0 <= idx < len(optionlist):
- option = optionlist[idx]
- if type(option) == type(()):
- option = option[0]
- if option[-1] == '=' or option[-1] == ':':
- option = option[:-1]
- h = d.GetDialogItemAsControl(ARGV_OPTION_VALUE)
- value = Dlg.GetDialogItemText(h)
- else:
- value = ''
- if len(option) == 1:
- stringtoadd = '-' + option
- else:
- stringtoadd = '--' + option
- stringstoadd = [stringtoadd]
- if value:
- stringstoadd.append(value)
- else:
- MacOS.SysBeep()
- elif n == ARGV_COMMAND_GROUP:
- idx = d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).GetControlValue()-1
- if 0 <= idx < len(commandlist) and type(commandlist[idx]) == type(()) and \
- len(commandlist[idx]) > 1:
- help = commandlist[idx][-1]
- h = d.GetDialogItemAsControl(ARGV_COMMAND_EXPLAIN)
- Dlg.SetDialogItemText(h, help)
- elif n == ARGV_COMMAND_ADD:
- idx = d.GetDialogItemAsControl(ARGV_COMMAND_GROUP).GetControlValue()-1
- if 0 <= idx < len(commandlist):
- command = commandlist[idx]
- if type(command) == type(()):
- command = command[0]
- stringstoadd = [command]
- else:
- MacOS.SysBeep()
- elif n == ARGV_ADD_OLDFILE:
- pathname = AskFileForOpen()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_ADD_NEWFILE:
- pathname = AskFileForSave()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_ADD_FOLDER:
- pathname = AskFolder()
- if pathname:
- stringstoadd = [pathname]
- elif n == ARGV_CMDLINE_DATA:
- pass # Nothing to do
- else:
- raise RuntimeError, "Unknown dialog item %d"%n
-
- for stringtoadd in stringstoadd:
- if '"' in stringtoadd or "'" in stringtoadd or " " in stringtoadd:
- stringtoadd = repr(stringtoadd)
- h = d.GetDialogItemAsControl(ARGV_CMDLINE_DATA)
- oldstr = GetDialogItemText(h)
- if oldstr and oldstr[-1] != ' ':
- oldstr = oldstr + ' '
- oldstr = oldstr + stringtoadd
- if oldstr[-1] != ' ':
- oldstr = oldstr + ' '
- SetDialogItemText(h, oldstr)
- d.SelectDialogItemText(ARGV_CMDLINE_DATA, 0x7fff, 0x7fff)
- h = d.GetDialogItemAsControl(ARGV_CMDLINE_DATA)
- oldstr = GetDialogItemText(h)
- tmplist = string.split(oldstr)
- newlist = []
- while tmplist:
- item = tmplist[0]
- del tmplist[0]
- if item[0] == '"':
- while item[-1] != '"':
- if not tmplist:
- raise RuntimeError, "Unterminated quoted argument"
- item = item + ' ' + tmplist[0]
- del tmplist[0]
- item = item[1:-1]
- if item[0] == "'":
- while item[-1] != "'":
- if not tmplist:
- raise RuntimeError, "Unterminated quoted argument"
- item = item + ' ' + tmplist[0]
- del tmplist[0]
- item = item[1:-1]
- newlist.append(item)
- return newlist
- finally:
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*appsw)
- del d
-
-def _process_Nav_args(dftflags, **args):
- import Carbon.AppleEvents
- import Carbon.AE
- import Carbon.File
- for k in args.keys():
- if args[k] is None:
- del args[k]
- # Set some defaults, and modify some arguments
- if 'dialogOptionFlags' not in args:
- args['dialogOptionFlags'] = dftflags
- if 'defaultLocation' in args and \
- not isinstance(args['defaultLocation'], Carbon.AE.AEDesc):
- defaultLocation = args['defaultLocation']
- if isinstance(defaultLocation, Carbon.File.FSSpec):
- args['defaultLocation'] = Carbon.AE.AECreateDesc(
- Carbon.AppleEvents.typeFSS, defaultLocation.data)
- else:
- if not isinstance(defaultLocation, Carbon.File.FSRef):
- defaultLocation = Carbon.File.FSRef(defaultLocation)
- args['defaultLocation'] = Carbon.AE.AECreateDesc(
- Carbon.AppleEvents.typeFSRef, defaultLocation.data)
- if 'typeList' in args and not isinstance(args['typeList'], Carbon.Res.ResourceType):
- typeList = args['typeList'][:]
- # Workaround for OSX typeless files:
- if 'TEXT' in typeList and not '\0\0\0\0' in typeList:
- typeList = typeList + ('\0\0\0\0',)
- data = 'Pyth' + struct.pack("hh", 0, len(typeList))
- for type in typeList:
- data = data+type
- args['typeList'] = Carbon.Res.Handle(data)
- tpwanted = str
- if 'wanted' in args:
- tpwanted = args['wanted']
- del args['wanted']
- return args, tpwanted
-
-def _dummy_Nav_eventproc(msg, data):
- pass
-
-_default_Nav_eventproc = _dummy_Nav_eventproc
-
-def SetDefaultEventProc(proc):
- global _default_Nav_eventproc
- rv = _default_Nav_eventproc
- if proc is None:
- proc = _dummy_Nav_eventproc
- _default_Nav_eventproc = proc
- return rv
-
-def AskFileForOpen(
- message=None,
- typeList=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- previewProc=None,
- filterProc=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for a file to open.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
- default_flags = 0x56 # Or 0xe4?
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,previewProc=previewProc,
- filterProc=filterProc,typeList=typeList,wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavChooseFile(args)
- good = 1
- except Nav.error, arg:
- if arg[0] != -128: # userCancelledErr
- raise Nav.error, arg
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- return tpwanted(rr.selection_fsr[0])
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname())
- if issubclass(tpwanted, unicode):
- return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
- raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
-
-def AskFileForSave(
- message=None,
- savedFileName=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- fileType=None,
- fileCreator=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for a filename to save to.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
-
- default_flags = 0x07
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- savedFileName=savedFileName,message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,fileType=fileType,
- fileCreator=fileCreator,wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavPutFile(args)
- good = 1
- except Nav.error, arg:
- if arg[0] != -128: # userCancelledErr
- raise Nav.error, arg
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- raise TypeError, "Cannot pass wanted=FSRef to AskFileForSave"
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, (str, unicode)):
- # This is gross, and probably incorrect too
- vrefnum, dirid, name = rr.selection[0].as_tuple()
- pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
- pardir_fsr = Carbon.File.FSRef(pardir_fss)
- pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8
- name_utf8 = unicode(name, 'macroman').encode('utf8')
- fullpath = os.path.join(pardir_path, name_utf8)
- if issubclass(tpwanted, unicode):
- return unicode(fullpath, 'utf8')
- return tpwanted(fullpath)
- raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
-
-def AskFolder(
- message=None,
- # From here on the order is not documented
- version=None,
- defaultLocation=None,
- dialogOptionFlags=None,
- location=None,
- clientName=None,
- windowTitle=None,
- actionButtonLabel=None,
- cancelButtonLabel=None,
- preferenceKey=None,
- popupExtension=None,
- eventProc=_dummy_Nav_eventproc,
- filterProc=None,
- wanted=None,
- multiple=None):
- """Display a dialog asking the user for select a folder.
-
- wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
- the other arguments can be looked up in Apple's Navigation Services documentation"""
-
- default_flags = 0x17
- args, tpwanted = _process_Nav_args(default_flags, version=version,
- defaultLocation=defaultLocation, dialogOptionFlags=dialogOptionFlags,
- location=location,clientName=clientName,windowTitle=windowTitle,
- actionButtonLabel=actionButtonLabel,cancelButtonLabel=cancelButtonLabel,
- message=message,preferenceKey=preferenceKey,
- popupExtension=popupExtension,eventProc=eventProc,filterProc=filterProc,
- wanted=wanted,multiple=multiple)
- _interact()
- try:
- rr = Nav.NavChooseFolder(args)
- good = 1
- except Nav.error, arg:
- if arg[0] != -128: # userCancelledErr
- raise Nav.error, arg
- return None
- if not rr.validRecord or not rr.selection:
- return None
- if issubclass(tpwanted, Carbon.File.FSRef):
- return tpwanted(rr.selection_fsr[0])
- if issubclass(tpwanted, Carbon.File.FSSpec):
- return tpwanted(rr.selection[0])
- if issubclass(tpwanted, str):
- return tpwanted(rr.selection_fsr[0].as_pathname())
- if issubclass(tpwanted, unicode):
- return tpwanted(rr.selection_fsr[0].as_pathname(), 'utf8')
- raise TypeError, "Unknown value for argument 'wanted': %s" % repr(tpwanted)
-
-
-def test():
- import time
-
- Message("Testing EasyDialogs.")
- optionlist = (('v', 'Verbose'), ('verbose', 'Verbose as long option'),
- ('flags=', 'Valued option'), ('f:', 'Short valued option'))
- commandlist = (('start', 'Start something'), ('stop', 'Stop something'))
- argv = GetArgv(optionlist=optionlist, commandlist=commandlist, addoldfile=0)
- Message("Command line: %s"%' '.join(argv))
- for i in range(len(argv)):
- print 'arg[%d] = %r' % (i, argv[i])
- ok = AskYesNoCancel("Do you want to proceed?")
- ok = AskYesNoCancel("Do you want to identify?", yes="Identify", no="No")
- if ok > 0:
- s = AskString("Enter your first name", "Joe")
- s2 = AskPassword("Okay %s, tell us your nickname"%s, s, cancel="None")
- if not s2:
- Message("%s has no secret nickname"%s)
- else:
- Message("Hello everybody!!\nThe secret nickname of %s is %s!!!"%(s, s2))
- else:
- s = 'Anonymous'
- rv = AskFileForOpen(message="Gimme a file, %s"%s, wanted=Carbon.File.FSSpec)
- Message("rv: %s"%rv)
- rv = AskFileForSave(wanted=Carbon.File.FSRef, savedFileName="%s.txt"%s)
- Message("rv.as_pathname: %s"%rv.as_pathname())
- rv = AskFolder()
- Message("Folder name: %s"%rv)
- text = ( "Working Hard...", "Hardly Working..." ,
- "So far, so good!", "Keep on truckin'" )
- bar = ProgressBar("Progress, progress...", 0, label="Ramping up...")
- try:
- if hasattr(MacOS, 'SchedParams'):
- appsw = MacOS.SchedParams(1, 0)
- for i in xrange(20):
- bar.inc()
- time.sleep(0.05)
- bar.set(0,100)
- for i in xrange(100):
- bar.set(i)
- time.sleep(0.05)
- if i % 10 == 0:
- bar.label(text[(i/10) % 4])
- bar.label("Done.")
- time.sleep(1.0) # give'em a chance to see "Done."
- finally:
- del bar
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*appsw)
-
-if __name__ == '__main__':
- try:
- test()
- except KeyboardInterrupt:
- Message("Operation Canceled.")
diff --git a/Lib/plat-mac/FrameWork.py b/Lib/plat-mac/FrameWork.py
deleted file mode 100644
index ca8aaa600b3..00000000000
--- a/Lib/plat-mac/FrameWork.py
+++ /dev/null
@@ -1,1126 +0,0 @@
-"A sort of application framework for the Mac"
-
-DEBUG=0
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the FrameWork module is removed.", stacklevel=2)
-
-import MacOS
-import traceback
-
-from Carbon.AE import *
-from Carbon.AppleEvents import *
-from Carbon.Ctl import *
-from Carbon.Controls import *
-from Carbon.Dlg import *
-from Carbon.Dialogs import *
-from Carbon.Evt import *
-from Carbon.Events import *
-from Carbon.Help import *
-from Carbon.Menu import *
-from Carbon.Menus import *
-from Carbon.Qd import *
-from Carbon.QuickDraw import *
-#from Carbon.Res import *
-#from Carbon.Resources import *
-#from Carbon.Snd import *
-#from Carbon.Sound import *
-from Carbon.Win import *
-from Carbon.Windows import *
-import types
-
-import EasyDialogs
-
-try:
- MyFrontWindow = FrontNonFloatingWindow
-except NameError:
- MyFrontWindow = FrontWindow
-
-kHighLevelEvent = 23 # Don't know what header file this should come from
-SCROLLBARWIDTH = 16 # Again, not a clue...
-
-# Trick to forestall a set of SIOUX menus being added to our menubar
-SIOUX_APPLEMENU_ID=32000
-
-
-# Map event 'what' field to strings
-eventname = {}
-eventname[1] = 'mouseDown'
-eventname[2] = 'mouseUp'
-eventname[3] = 'keyDown'
-eventname[4] = 'keyUp'
-eventname[5] = 'autoKey'
-eventname[6] = 'updateEvt'
-eventname[7] = 'diskEvt'
-eventname[8] = 'activateEvt'
-eventname[15] = 'osEvt'
-eventname[23] = 'kHighLevelEvent'
-
-# Map part codes returned by WhichWindow() to strings
-partname = {}
-partname[0] = 'inDesk'
-partname[1] = 'inMenuBar'
-partname[2] = 'inSysWindow'
-partname[3] = 'inContent'
-partname[4] = 'inDrag'
-partname[5] = 'inGrow'
-partname[6] = 'inGoAway'
-partname[7] = 'inZoomIn'
-partname[8] = 'inZoomOut'
-
-#
-# The useable portion of the screen
-# ## but what happens with multiple screens? jvr
-screenbounds = GetQDGlobalsScreenBits().bounds
-screenbounds = screenbounds[0]+4, screenbounds[1]+4, \
- screenbounds[2]-4, screenbounds[3]-4
-
-next_window_x = 16 # jvr
-next_window_y = 44 # jvr
-
-def windowbounds(width, height):
- "Return sensible window bounds"
- global next_window_x, next_window_y
- r, b = next_window_x+width, next_window_y+height
- if r > screenbounds[2]:
- next_window_x = 16
- if b > screenbounds[3]:
- next_window_y = 44
- l, t = next_window_x, next_window_y
- r, b = next_window_x+width, next_window_y+height
- next_window_x, next_window_y = next_window_x + 8, next_window_y + 20 # jvr
- return l, t, r, b
-
-_watch = None
-def setwatchcursor():
- global _watch
-
- if _watch is None:
- _watch = GetCursor(4).data
- SetCursor(_watch)
-
-def setarrowcursor():
- SetCursor(GetQDGlobalsArrow())
-
-class Application:
-
- "Application framework -- your application should be a derived class"
-
- def __init__(self, nomenubar=0):
- self._doing_asyncevents = 0
- self.quitting = 0
- self.needmenubarredraw = 0
- self._windows = {}
- self._helpmenu = None
- if nomenubar:
- self.menubar = None
- else:
- self.makemenubar()
-
- def __del__(self):
- if self._doing_asyncevents:
- self._doing_asyncevents = 0
- MacOS.SetEventHandler()
-
- def makemenubar(self):
- self.menubar = MenuBar(self)
- AppleMenu(self.menubar, self.getabouttext(), self.do_about)
- self.makeusermenus()
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self._quititem = MenuItem(m, "Quit", "Q", self._quit)
-
- def gethelpmenu(self):
- if self._helpmenu is None:
- self._helpmenu = HelpMenu(self.menubar)
- return self._helpmenu
-
- def _quit(self, *args):
- self.quitting = 1
-
- def cleanup(self):
- for w in self._windows.values():
- w.do_close()
- return self._windows == {}
-
- def appendwindow(self, wid, window):
- self._windows[wid] = window
-
- def removewindow(self, wid):
- del self._windows[wid]
-
- def getabouttext(self):
- return "About %s..." % self.__class__.__name__
-
- def do_about(self, id, item, window, event):
- EasyDialogs.Message("Hello, world!" + "\015(%s)" % self.__class__.__name__)
-
- # The main event loop is broken up in several simple steps.
- # This is done so you can override each individual part,
- # if you have a need to do extra processing independent of the
- # event type.
- # Normally, however, you'd just define handlers for individual
- # events.
-
- schedparams = (0, 0) # By default disable Python's event handling
- default_wait = None # By default we wait GetCaretTime in WaitNextEvent
-
- def mainloop(self, mask = everyEvent, wait = None):
- self.quitting = 0
- if hasattr(MacOS, 'SchedParams'):
- saveparams = MacOS.SchedParams(*self.schedparams)
- try:
- while not self.quitting:
- try:
- self.do1event(mask, wait)
- except (Application, SystemExit):
- # Note: the raising of "self" is old-fashioned idiom to
- # exit the mainloop. Calling _quit() is better for new
- # applications.
- break
- finally:
- if hasattr(MacOS, 'SchedParams'):
- MacOS.SchedParams(*saveparams)
-
- def dopendingevents(self, mask = everyEvent):
- """dopendingevents - Handle all pending events"""
- while self.do1event(mask, wait=0):
- pass
-
- def do1event(self, mask = everyEvent, wait = None):
- ok, event = self.getevent(mask, wait)
- if IsDialogEvent(event):
- if self.do_dialogevent(event):
- return
- if ok:
- self.dispatch(event)
- else:
- self.idle(event)
-
- def idle(self, event):
- pass
-
- def getevent(self, mask = everyEvent, wait = None):
- if self.needmenubarredraw:
- DrawMenuBar()
- self.needmenubarredraw = 0
- if wait is None:
- wait = self.default_wait
- if wait is None:
- wait = GetCaretTime()
- ok, event = WaitNextEvent(mask, wait)
- return ok, event
-
- def dispatch(self, event):
- # The following appears to be double work (already done in do1event)
- # but we need it for asynchronous event handling
- if IsDialogEvent(event):
- if self.do_dialogevent(event):
- return
- (what, message, when, where, modifiers) = event
- if what in eventname:
- name = "do_" + eventname[what]
- else:
- name = "do_%d" % what
- try:
- handler = getattr(self, name)
- except AttributeError:
- handler = self.do_unknownevent
- handler(event)
-
- def asyncevents(self, onoff):
- """asyncevents - Set asynchronous event handling on or off"""
- if MacOS.runtimemodel == 'macho':
- raise 'Unsupported in MachoPython'
- old = self._doing_asyncevents
- if old:
- MacOS.SetEventHandler()
- MacOS.SchedParams(*self.schedparams)
- if onoff:
- MacOS.SetEventHandler(self.dispatch)
- doint, dummymask, benice, howoften, bgyield = \
- self.schedparams
- MacOS.SchedParams(doint, everyEvent, benice,
- howoften, bgyield)
- self._doing_asyncevents = onoff
- return old
-
- def do_dialogevent(self, event):
- gotone, dlg, item = DialogSelect(event)
- if gotone:
- window = dlg.GetDialogWindow()
- if window in self._windows:
- self._windows[window].do_itemhit(item, event)
- else:
- print 'Dialog event for unknown dialog'
- return 1
- return 0
-
- def do_mouseDown(self, event):
- (what, message, when, where, modifiers) = event
- partcode, wid = FindWindow(where)
-
- #
- # Find the correct name.
- #
- if partcode in partname:
- name = "do_" + partname[partcode]
- else:
- name = "do_%d" % partcode
-
- if wid is None:
- # No window, or a non-python window
- try:
- handler = getattr(self, name)
- except AttributeError:
- # Not menubar or something, so assume someone
- # else's window
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- return
- elif wid in self._windows:
- # It is a window. Hand off to correct window.
- window = self._windows[wid]
- try:
- handler = getattr(window, name)
- except AttributeError:
- handler = self.do_unknownpartcode
- else:
- # It is a python-toolbox window, but not ours.
- handler = self.do_unknownwindow
- handler(partcode, wid, event)
-
- def do_inSysWindow(self, partcode, window, event):
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_inDesk(self, partcode, window, event):
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_inMenuBar(self, partcode, window, event):
- if not self.menubar:
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- return
- (what, message, when, where, modifiers) = event
- result = MenuSelect(where)
- id = (result>>16) & 0xffff # Hi word
- if id >= 0x8000:
- id = -65536 + id
- item = result & 0xffff # Lo word
- self.do_rawmenu(id, item, window, event)
-
- def do_rawmenu(self, id, item, window, event):
- try:
- self.do_menu(id, item, window, event)
- finally:
- HiliteMenu(0)
-
- def do_menu(self, id, item, window, event):
- if hasattr(MacOS, 'OutputSeen'):
- MacOS.OutputSeen()
- self.menubar.dispatch(id, item, window, event)
-
-
- def do_unknownpartcode(self, partcode, window, event):
- (what, message, when, where, modifiers) = event
- if DEBUG: print "Mouse down at global:", where
- if DEBUG: print "\tUnknown part code:", partcode
- if DEBUG: print "\tEvent:", self.printevent(event)
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_unknownwindow(self, partcode, window, event):
- if DEBUG: print 'Unknown window:', window
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_keyDown(self, event):
- self.do_key(event)
-
- def do_autoKey(self, event):
- if not event[-1] & cmdKey:
- self.do_key(event)
-
- def do_key(self, event):
- (what, message, when, where, modifiers) = event
- c = chr(message & charCodeMask)
- if self.menubar:
- result = MenuEvent(event)
- id = (result>>16) & 0xffff # Hi word
- item = result & 0xffff # Lo word
- if id:
- self.do_rawmenu(id, item, None, event)
- return
- # Otherwise we fall-through
- if modifiers & cmdKey:
- if c == '.':
- raise self
- else:
- if not self.menubar:
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- return
- else:
- # See whether the front window wants it
- w = MyFrontWindow()
- if w and w in self._windows:
- window = self._windows[w]
- try:
- do_char = window.do_char
- except AttributeError:
- do_char = self.do_char
- do_char(c, event)
- # else it wasn't for us, sigh...
-
- def do_char(self, c, event):
- if DEBUG: print "Character", repr(c)
-
- def do_updateEvt(self, event):
- (what, message, when, where, modifiers) = event
- wid = WhichWindow(message)
- if wid and wid in self._windows:
- window = self._windows[wid]
- window.do_rawupdate(wid, event)
- else:
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_activateEvt(self, event):
- (what, message, when, where, modifiers) = event
- wid = WhichWindow(message)
- if wid and wid in self._windows:
- window = self._windows[wid]
- window.do_activate(modifiers & 1, event)
- else:
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
-
- def do_osEvt(self, event):
- (what, message, when, where, modifiers) = event
- which = (message >> 24) & 0xff
- if which == 1: # suspend/resume
- self.do_suspendresume(event)
- else:
- if DEBUG:
- print 'unknown osEvt:',
- self.printevent(event)
-
- def do_suspendresume(self, event):
- (what, message, when, where, modifiers) = event
- wid = MyFrontWindow()
- if wid and wid in self._windows:
- window = self._windows[wid]
- window.do_activate(message & 1, event)
-
- def do_kHighLevelEvent(self, event):
- (what, message, when, where, modifiers) = event
- if DEBUG:
- print "High Level Event:",
- self.printevent(event)
- try:
- AEProcessAppleEvent(event)
- except:
- pass
- #print "AEProcessAppleEvent error:"
- #traceback.print_exc()
-
- def do_unknownevent(self, event):
- if DEBUG:
- print "Unhandled event:",
- self.printevent(event)
-
- def printevent(self, event):
- (what, message, when, where, modifiers) = event
- nicewhat = repr(what)
- if what in eventname:
- nicewhat = eventname[what]
- print nicewhat,
- if what == kHighLevelEvent:
- h, v = where
- print repr(ostypecode(message)), hex(when), repr(ostypecode(h | (v<<16))),
- else:
- print hex(message), hex(when), where,
- print hex(modifiers)
-
-
-class MenuBar:
- """Represent a set of menus in a menu bar.
-
- Interface:
-
- - (constructor)
- - (destructor)
- - addmenu
- - addpopup (normally used internally)
- - dispatch (called from Application)
- """
-
- nextid = 1 # Necessarily a class variable
-
- def getnextid(self):
- id = MenuBar.nextid
- MenuBar.nextid = id+1
- return id
-
- def __init__(self, parent=None):
- self.parent = parent
- ClearMenuBar()
- self.bar = GetMenuBar()
- self.menus = {}
-
- # XXX necessary?
- def close(self):
- self.parent = None
- self.bar = None
- self.menus = None
-
- def addmenu(self, title, after = 0, id=None):
- if id is None:
- id = self.getnextid()
- if DEBUG: print 'Newmenu', title, id # XXXX
- m = NewMenu(id, title)
- m.InsertMenu(after)
- if after >= 0:
- if self.parent:
- self.parent.needmenubarredraw = 1
- else:
- DrawMenuBar()
- return id, m
-
- def delmenu(self, id):
- if DEBUG: print 'Delmenu', id # XXXX
- DeleteMenu(id)
-
- def addpopup(self, title = ''):
- return self.addmenu(title, -1)
-
-# Useless:
-# def install(self):
-# if not self.bar: return
-# SetMenuBar(self.bar)
-# if self.parent:
-# self.parent.needmenubarredraw = 1
-# else:
-# DrawMenuBar()
-
- def fixmenudimstate(self):
- for m in self.menus.keys():
- menu = self.menus[m]
- if menu.__class__ == FrameWork.AppleMenu:
- continue
- for i in range(len(menu.items)):
- label, shortcut, callback, kind = menu.items[i]
- if type(callback) == types.StringType:
- wid = MyFrontWindow()
- if wid and wid in self.parent._windows:
- window = self.parent._windows[wid]
- if hasattr(window, "domenu_" + callback):
- menu.menu.EnableMenuItem(i + 1)
- elif hasattr(self.parent, "domenu_" + callback):
- menu.menu.EnableMenuItem(i + 1)
- else:
- menu.menu.DisableMenuItem(i + 1)
- elif hasattr(self.parent, "domenu_" + callback):
- menu.menu.EnableMenuItem(i + 1)
- else:
- menu.menu.DisableMenuItem(i + 1)
- elif callback:
- pass
-
- def dispatch(self, id, item, window, event):
- if id in self.menus:
- self.menus[id].dispatch(id, item, window, event)
- else:
- if DEBUG: print "MenuBar.dispatch(%d, %d, %s, %s)" % \
- (id, item, window, event)
-
-
-# XXX Need a way to get menus as resources and bind them to callbacks
-
-class Menu:
- "One menu."
-
- def __init__(self, bar, title, after=0, id=None):
- self.bar = bar
- self.id, self.menu = self.bar.addmenu(title, after, id)
- bar.menus[self.id] = self
- self.items = []
- self._parent = None
-
- def delete(self):
- self.bar.delmenu(self.id)
- del self.bar.menus[self.id]
- self.menu.DisposeMenu()
- del self.bar
- del self.items
- del self.menu
- del self.id
- del self._parent
-
- def additem(self, label, shortcut=None, callback=None, kind=None):
- self.menu.AppendMenu('x') # add a dummy string
- self.items.append((label, shortcut, callback, kind))
- item = len(self.items)
- if isinstance(label, unicode):
- self.menu.SetMenuItemTextWithCFString(item, label)
- else:
- self.menu.SetMenuItemText(item, label)
- if shortcut and type(shortcut) == type(()):
- modifiers, char = shortcut[:2]
- self.menu.SetItemCmd(item, ord(char))
- self.menu.SetMenuItemModifiers(item, modifiers)
- if len(shortcut) > 2:
- self.menu.SetMenuItemKeyGlyph(item, shortcut[2])
- elif shortcut:
- self.menu.SetItemCmd(item, ord(shortcut))
- return item
-
- def delitem(self, item):
- if item != len(self.items):
- raise 'Can only delete last item of a menu'
- self.menu.DeleteMenuItem(item)
- del self.items[item-1]
-
- def addcheck(self, label, shortcut=None, callback=None):
- return self.additem(label, shortcut, callback, 'check')
-
- def addradio(self, label, shortcut=None, callback=None):
- return self.additem(label, shortcut, callback, 'radio')
-
- def addseparator(self):
- self.menu.AppendMenu('(-')
- self.items.append(('', None, None, 'separator'))
-
- def addsubmenu(self, label, title=''):
- sub = Menu(self.bar, title, -1)
- item = self.additem(label, '\x1B', None, 'submenu')
- self.menu.SetItemMark(item, sub.id)
- sub._parent = self
- sub._parent_item = item
- return sub
-
- def dispatch(self, id, item, window, event):
- title, shortcut, callback, mtype = self.items[item-1]
- if callback:
- if not self.bar.parent or type(callback) != types.StringType:
- menuhandler = callback
- else:
- # callback is string
- wid = MyFrontWindow()
- if wid and wid in self.bar.parent._windows:
- window = self.bar.parent._windows[wid]
- if hasattr(window, "domenu_" + callback):
- menuhandler = getattr(window, "domenu_" + callback)
- elif hasattr(self.bar.parent, "domenu_" + callback):
- menuhandler = getattr(self.bar.parent, "domenu_" + callback)
- else:
- # nothing we can do. we shouldn't have come this far
- # since the menu item should have been disabled...
- return
- elif hasattr(self.bar.parent, "domenu_" + callback):
- menuhandler = getattr(self.bar.parent, "domenu_" + callback)
- else:
- # nothing we can do. we shouldn't have come this far
- # since the menu item should have been disabled...
- return
- menuhandler(id, item, window, event)
-
- def enable(self, onoff):
- if onoff:
- self.menu.EnableMenuItem(0)
- if self._parent:
- self._parent.menu.EnableMenuItem(self._parent_item)
- else:
- self.menu.DisableMenuItem(0)
- if self._parent:
- self._parent.menu.DisableMenuItem(self._parent_item)
- if self.bar and self.bar.parent:
- self.bar.parent.needmenubarredraw = 1
-
-class PopupMenu(Menu):
- def __init__(self, bar):
- Menu.__init__(self, bar, '(popup)', -1)
-
- def popup(self, x, y, event, default=1, window=None):
- # NOTE that x and y are global coordinates, and they should probably
- # be topleft of the button the user clicked (not mouse-coordinates),
- # so the popup nicely overlaps.
- reply = self.menu.PopUpMenuSelect(x, y, default)
- if not reply:
- return
- id = (reply >> 16) & 0xffff
- item = reply & 0xffff
- if not window:
- wid = MyFrontWindow()
- try:
- window = self.bar.parent._windows[wid]
- except:
- pass # If we can't find the window we pass None
- self.dispatch(id, item, window, event)
-
-class MenuItem:
- def __init__(self, menu, title, shortcut=None, callback=None, kind=None):
- self.item = menu.additem(title, shortcut, callback)
- self.menu = menu
-
- def delete(self):
- self.menu.delitem(self.item)
- del self.menu
- del self.item
-
- def check(self, onoff):
- self.menu.menu.CheckMenuItem(self.item, onoff)
-
- def enable(self, onoff):
- if onoff:
- self.menu.menu.EnableMenuItem(self.item)
- else:
- self.menu.menu.DisableMenuItem(self.item)
-
- def settext(self, text):
- self.menu.menu.SetMenuItemText(self.item, text)
-
- def setstyle(self, style):
- self.menu.menu.SetItemStyle(self.item, style)
-
- def seticon(self, icon):
- self.menu.menu.SetItemIcon(self.item, icon)
-
- def setcmd(self, cmd):
- self.menu.menu.SetItemCmd(self.item, cmd)
-
- def setmark(self, cmd):
- self.menu.menu.SetItemMark(self.item, cmd)
-
-
-class RadioItem(MenuItem):
- def __init__(self, menu, title, shortcut=None, callback=None):
- MenuItem.__init__(self, menu, title, shortcut, callback, 'radio')
-
-class CheckItem(MenuItem):
- def __init__(self, menu, title, shortcut=None, callback=None):
- MenuItem.__init__(self, menu, title, shortcut, callback, 'check')
-
-def Separator(menu):
- menu.addseparator()
-
-def SubMenu(menu, label, title=''):
- return menu.addsubmenu(label, title)
-
-
-class AppleMenu(Menu):
-
- def __init__(self, bar, abouttext="About me...", aboutcallback=None):
- Menu.__init__(self, bar, "\024", id=SIOUX_APPLEMENU_ID)
- if MacOS.runtimemodel == 'ppc':
- self.additem(abouttext, None, aboutcallback)
- self.addseparator()
- self.menu.AppendResMenu('DRVR')
- else:
- # Additem()'s tricks do not work for "apple" menu under Carbon
- self.menu.InsertMenuItem(abouttext, 0)
- self.items.append((abouttext, None, aboutcallback, None))
-
- def dispatch(self, id, item, window, event):
- if item == 1:
- Menu.dispatch(self, id, item, window, event)
- elif MacOS.runtimemodel == 'ppc':
- name = self.menu.GetMenuItemText(item)
- OpenDeskAcc(name)
-
-class HelpMenu(Menu):
- def __init__(self, bar):
- # Note we don't call Menu.__init__, we do the necessary things by hand
- self.bar = bar
- self.menu, index = HMGetHelpMenu()
- self.id = self.menu.GetMenuID()
- bar.menus[self.id] = self
- # The next line caters for the entries the system already handles for us
- self.items = [None]*(index-1)
- self._parent = None
-
-
-class Window:
- """A single window belonging to an application"""
-
- def __init__(self, parent):
- self.wid = None
- self.parent = parent
-
- def open(self, bounds=(40, 40, 400, 400), resid=None):
- if resid != None:
- self.wid = GetNewWindow(resid, -1)
- else:
- self.wid = NewWindow(bounds, self.__class__.__name__, 1,
- 8, -1, 1, 0) # changed to proc id 8 to include zoom box. jvr
- self.do_postopen()
-
- def do_postopen(self):
- """Tell our parent we exist"""
- self.parent.appendwindow(self.wid, self)
-
- def close(self):
- self.do_postclose()
-
- def do_postclose(self):
- self.parent.removewindow(self.wid)
- self.parent = None
- self.wid = None
-
- def SetPort(self):
- # Convinience method
- SetPort(self.wid)
-
- def GetWindow(self):
- return self.wid
-
- def do_inDrag(self, partcode, window, event):
- where = event[3]
- window.DragWindow(where, self.draglimit)
-
- draglimit = screenbounds
-
- def do_inGoAway(self, partcode, window, event):
- where = event[3]
- if window.TrackGoAway(where):
- self.close()
-
- def do_inZoom(self, partcode, window, event):
- (what, message, when, where, modifiers) = event
- if window.TrackBox(where, partcode):
- window.ZoomWindow(partcode, 1)
- rect = window.GetWindowUserState() # so that zoom really works... jvr
- self.do_postresize(rect[2] - rect[0], rect[3] - rect[1], window) # jvr
-
- def do_inZoomIn(self, partcode, window, event):
- SetPort(window) # !!!
- self.do_inZoom(partcode, window, event)
-
- def do_inZoomOut(self, partcode, window, event):
- SetPort(window) # !!!
- self.do_inZoom(partcode, window, event)
-
- def do_inGrow(self, partcode, window, event):
- (what, message, when, where, modifiers) = event
- result = window.GrowWindow(where, self.growlimit)
- if result:
- height = (result>>16) & 0xffff # Hi word
- width = result & 0xffff # Lo word
- self.do_resize(width, height, window)
-
- growlimit = (50, 50, screenbounds[2] - screenbounds[0], screenbounds[3] - screenbounds[1]) # jvr
-
- def do_resize(self, width, height, window):
- l, t, r, b = self.wid.GetWindowPort().GetPortBounds() # jvr, forGrowIcon
- self.SetPort() # jvr
- self.wid.InvalWindowRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr
- window.SizeWindow(width, height, 1) # changed updateFlag to true jvr
- self.do_postresize(width, height, window)
-
- def do_postresize(self, width, height, window):
- SetPort(window)
- self.wid.InvalWindowRect(window.GetWindowPort().GetPortBounds())
-
- def do_inContent(self, partcode, window, event):
- #
- # If we're not frontmost, select ourselves and wait for
- # the activate event.
- #
- if MyFrontWindow() != window:
- window.SelectWindow()
- return
- # We are. Handle the event.
- (what, message, when, where, modifiers) = event
- SetPort(window)
- local = GlobalToLocal(where)
- self.do_contentclick(local, modifiers, event)
-
- def do_contentclick(self, local, modifiers, event):
- if DEBUG:
- print 'Click in contents at %s, modifiers %s'%(local, modifiers)
-
- def do_rawupdate(self, window, event):
- if DEBUG: print "raw update for", window
- SetPort(window)
- window.BeginUpdate()
- self.do_update(window, event)
- window.EndUpdate()
-
- def do_update(self, window, event):
- if DEBUG:
- import time
- for i in range(8):
- time.sleep(0.1)
- InvertRgn(window.GetWindowPort().visRgn)
- FillRgn(window.GetWindowPort().visRgn, GetQDGlobalsGray())
- else:
- EraseRgn(window.GetWindowPort().visRgn)
-
- def do_activate(self, activate, event):
- if DEBUG: print 'Activate %d for %s'%(activate, self.wid)
-
-class ControlsWindow(Window):
-
- def do_rawupdate(self, window, event):
- if DEBUG: print "raw update for", window
- SetPort(window)
- window.BeginUpdate()
- self.do_update(window, event)
- #DrawControls(window) # jvr
- UpdateControls(window, window.GetWindowPort().visRgn) # jvr
- window.DrawGrowIcon()
- window.EndUpdate()
-
- def do_controlhit(self, window, control, pcode, event):
- if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode
-
- def do_inContent(self, partcode, window, event):
- if MyFrontWindow() != window:
- window.SelectWindow()
- return
- (what, message, when, where, modifiers) = event
- SetPort(window) # XXXX Needed?
- local = GlobalToLocal(where)
- pcode, control = FindControl(local, window)
- if pcode and control:
- self.do_rawcontrolhit(window, control, pcode, local, event)
- else:
- if DEBUG: print "FindControl(%s, %s) -> (%s, %s)" % \
- (local, window, pcode, control)
- self.do_contentclick(local, modifiers, event)
-
- def do_rawcontrolhit(self, window, control, pcode, local, event):
- pcode = control.TrackControl(local)
- if pcode:
- self.do_controlhit(window, control, pcode, event)
-
-class ScrolledWindow(ControlsWindow):
- def __init__(self, parent):
- self.barx = self.bary = None
- self.barx_enabled = self.bary_enabled = 1
- self.activated = 1
- ControlsWindow.__init__(self, parent)
-
- def scrollbars(self, wantx=1, wanty=1):
- SetPort(self.wid)
- self.barx = self.bary = None
- self.barx_enabled = self.bary_enabled = 1
- x0, y0, x1, y1 = self.wid.GetWindowPort().GetPortBounds()
- vx, vy = self.getscrollbarvalues()
- if vx is None: self.barx_enabled, vx = 0, 0
- if vy is None: self.bary_enabled, vy = 0, 0
- if wantx:
- rect = x0-1, y1-(SCROLLBARWIDTH-1), x1-(SCROLLBARWIDTH-2), y1+1
- self.barx = NewControl(self.wid, rect, "", 1, vx, 0, 32767, 16, 0)
- if not self.barx_enabled: self.barx.HiliteControl(255)
-## self.wid.InvalWindowRect(rect)
- if wanty:
- rect = x1-(SCROLLBARWIDTH-1), y0-1, x1+1, y1-(SCROLLBARWIDTH-2)
- self.bary = NewControl(self.wid, rect, "", 1, vy, 0, 32767, 16, 0)
- if not self.bary_enabled: self.bary.HiliteControl(255)
-## self.wid.InvalWindowRect(rect)
-
- def do_postclose(self):
- self.barx = self.bary = None
- ControlsWindow.do_postclose(self)
-
- def do_activate(self, onoff, event):
- self.activated = onoff
- if onoff:
- if self.barx and self.barx_enabled:
- self.barx.ShowControl() # jvr
- if self.bary and self.bary_enabled:
- self.bary.ShowControl() # jvr
- else:
- if self.barx:
- self.barx.HideControl() # jvr; An inactive window should have *hidden*
- # scrollbars, not just dimmed (no matter what
- # BBEdit does... look at the Finder)
- if self.bary:
- self.bary.HideControl() # jvr
- self.wid.DrawGrowIcon() # jvr
-
- def do_postresize(self, width, height, window):
- l, t, r, b = self.wid.GetWindowPort().GetPortBounds()
- self.SetPort()
- if self.barx:
- self.barx.HideControl() # jvr
- self.barx.MoveControl(l-1, b-(SCROLLBARWIDTH-1))
- self.barx.SizeControl((r-l)-(SCROLLBARWIDTH-3), SCROLLBARWIDTH) # jvr
- if self.bary:
- self.bary.HideControl() # jvr
- self.bary.MoveControl(r-(SCROLLBARWIDTH-1), t-1)
- self.bary.SizeControl(SCROLLBARWIDTH, (b-t)-(SCROLLBARWIDTH-3)) # jvr
- if self.barx:
- self.barx.ShowControl() # jvr
- self.wid.ValidWindowRect((l, b - SCROLLBARWIDTH + 1, r - SCROLLBARWIDTH + 2, b)) # jvr
- if self.bary:
- self.bary.ShowControl() # jvr
- self.wid.ValidWindowRect((r - SCROLLBARWIDTH + 1, t, r, b - SCROLLBARWIDTH + 2)) # jvr
- self.wid.InvalWindowRect((r - SCROLLBARWIDTH + 1, b - SCROLLBARWIDTH + 1, r, b)) # jvr, growicon
-
-
- def do_rawcontrolhit(self, window, control, pcode, local, event):
- if control == self.barx:
- which = 'x'
- elif control == self.bary:
- which = 'y'
- else:
- return 0
- if pcode in (inUpButton, inDownButton, inPageUp, inPageDown):
- # We do the work for the buttons and grey area in the tracker
- dummy = control.TrackControl(local, self.do_controltrack)
- else:
- # but the thumb is handled here
- pcode = control.TrackControl(local)
- if pcode == inThumb:
- value = control.GetControlValue()
- print 'setbars', which, value #DBG
- self.scrollbar_callback(which, 'set', value)
- self.updatescrollbars()
- else:
- print 'funny part', pcode #DBG
- return 1
-
- def do_controltrack(self, control, pcode):
- if control == self.barx:
- which = 'x'
- elif control == self.bary:
- which = 'y'
- else:
- return
-
- if pcode == inUpButton:
- what = '-'
- elif pcode == inDownButton:
- what = '+'
- elif pcode == inPageUp:
- what = '--'
- elif pcode == inPageDown:
- what = '++'
- else:
- return
- self.scrollbar_callback(which, what, None)
- self.updatescrollbars()
-
- def updatescrollbars(self):
- SetPort(self.wid)
- vx, vy = self.getscrollbarvalues()
- if self.barx:
- if vx is None:
- self.barx.HiliteControl(255)
- self.barx_enabled = 0
- else:
- if not self.barx_enabled:
- self.barx_enabled = 1
- if self.activated:
- self.barx.HiliteControl(0)
- self.barx.SetControlValue(vx)
- if self.bary:
- if vy is None:
- self.bary.HiliteControl(255)
- self.bary_enabled = 0
- else:
- if not self.bary_enabled:
- self.bary_enabled = 1
- if self.activated:
- self.bary.HiliteControl(0)
- self.bary.SetControlValue(vy)
-
- # Auxiliary function: convert standard text/image/etc coordinate
- # to something palatable as getscrollbarvalues() return
- def scalebarvalue(self, absmin, absmax, curmin, curmax):
- if curmin <= absmin and curmax >= absmax:
- return None
- if curmin <= absmin:
- return 0
- if curmax >= absmax:
- return 32767
- perc = float(curmin-absmin)/float(absmax-absmin)
- return int(perc*32767)
-
- # To be overridden:
-
- def getscrollbarvalues(self):
- return 0, 0
-
- def scrollbar_callback(self, which, what, value):
- print 'scroll', which, what, value
-
-class DialogWindow(Window):
- """A modeless dialog window"""
-
- def open(self, resid):
- self.dlg = GetNewDialog(resid, -1)
- self.wid = self.dlg.GetDialogWindow()
- self.do_postopen()
-
- def close(self):
- self.do_postclose()
-
- def do_postclose(self):
- self.dlg = None
- Window.do_postclose(self)
-
- def do_itemhit(self, item, event):
- print 'Dialog %s, item %d hit'%(self.dlg, item)
-
- def do_rawupdate(self, window, event):
- pass
-
-def ostypecode(x):
- "Convert a long int to the 4-character code it really is"
- s = ''
- for i in range(4):
- x, c = divmod(x, 256)
- s = chr(c) + s
- return s
-
-
-class TestApp(Application):
-
- "This class is used by the test() function"
-
- def makeusermenus(self):
- self.filemenu = m = Menu(self.menubar, "File")
- self.saveitem = MenuItem(m, "Save", "S", self.save)
- Separator(m)
- self.optionsmenu = mm = SubMenu(m, "Options")
- self.opt1 = CheckItem(mm, "Arguments", "A")
- self.opt2 = CheckItem(mm, "Being hit on the head lessons", (kMenuOptionModifier, "A"))
- self.opt3 = CheckItem(mm, "Complaints", (kMenuOptionModifier|kMenuNoCommandModifier, "A"))
- Separator(m)
- self.itemeh = MenuItem(m, "Enable Help", None, self.enablehelp)
- self.itemdbg = MenuItem(m, "Debug", None, self.debug)
- Separator(m)
- self.quititem = MenuItem(m, "Quit", "Q", self.quit)
-
- def save(self, *args):
- print "Save"
-
- def quit(self, *args):
- raise self
-
- def enablehelp(self, *args):
- hm = self.gethelpmenu()
- self.nohelpitem = MenuItem(hm, "There isn't any", None, self.nohelp)
-
- def nohelp(self, *args):
- print "I told you there isn't any!"
-
- def debug(self, *args):
- import pdb
- pdb.set_trace()
-
-
-def test():
- "Test program"
- app = TestApp()
- app.mainloop()
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/plat-mac/MiniAEFrame.py b/Lib/plat-mac/MiniAEFrame.py
deleted file mode 100644
index d6126bb2a9a..00000000000
--- a/Lib/plat-mac/MiniAEFrame.py
+++ /dev/null
@@ -1,200 +0,0 @@
-"""MiniAEFrame - A minimal AppleEvent Application framework.
-
-There are two classes:
- AEServer -- a mixin class offering nice AE handling.
- MiniApplication -- a very minimal alternative to FrameWork.py,
- only suitable for the simplest of AppleEvent servers.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the MiniAEFrame module is removed.", stacklevel=2)
-
-import traceback
-import MacOS
-from Carbon import AE
-from Carbon.AppleEvents import *
-from Carbon import Evt
-from Carbon.Events import *
-from Carbon import Menu
-from Carbon import Win
-from Carbon.Windows import *
-from Carbon import Qd
-
-import aetools
-import EasyDialogs
-
-kHighLevelEvent = 23 # Not defined anywhere for Python yet?
-
-
-class MiniApplication:
-
- """A minimal FrameWork.Application-like class"""
-
- def __init__(self):
- self.quitting = 0
- # Initialize menu
- self.appleid = 1
- self.quitid = 2
- Menu.ClearMenuBar()
- self.applemenu = applemenu = Menu.NewMenu(self.appleid, "\024")
- applemenu.AppendMenu("%s;(-" % self.getaboutmenutext())
- if MacOS.runtimemodel == 'ppc':
- applemenu.AppendResMenu('DRVR')
- applemenu.InsertMenu(0)
- self.quitmenu = Menu.NewMenu(self.quitid, "File")
- self.quitmenu.AppendMenu("Quit")
- self.quitmenu.SetItemCmd(1, ord("Q"))
- self.quitmenu.InsertMenu(0)
- Menu.DrawMenuBar()
-
- def __del__(self):
- self.close()
-
- def close(self):
- pass
-
- def mainloop(self, mask = everyEvent, timeout = 60*60):
- while not self.quitting:
- self.dooneevent(mask, timeout)
-
- def _quit(self):
- self.quitting = 1
-
- def dooneevent(self, mask = everyEvent, timeout = 60*60):
- got, event = Evt.WaitNextEvent(mask, timeout)
- if got:
- self.lowlevelhandler(event)
-
- def lowlevelhandler(self, event):
- what, message, when, where, modifiers = event
- h, v = where
- if what == kHighLevelEvent:
- msg = "High Level Event: %r %r" % (code(message), code(h | (v<<16)))
- try:
- AE.AEProcessAppleEvent(event)
- except AE.Error, err:
- print 'AE error: ', err
- print 'in', msg
- traceback.print_exc()
- return
- elif what == keyDown:
- c = chr(message & charCodeMask)
- if modifiers & cmdKey:
- if c == '.':
- raise KeyboardInterrupt, "Command-period"
- if c == 'q':
- if hasattr(MacOS, 'OutputSeen'):
- MacOS.OutputSeen()
- self.quitting = 1
- return
- elif what == mouseDown:
- partcode, window = Win.FindWindow(where)
- if partcode == inMenuBar:
- result = Menu.MenuSelect(where)
- id = (result>>16) & 0xffff # Hi word
- item = result & 0xffff # Lo word
- if id == self.appleid:
- if item == 1:
- EasyDialogs.Message(self.getabouttext())
- elif item > 1 and hasattr(Menu, 'OpenDeskAcc'):
- name = self.applemenu.GetMenuItemText(item)
- Menu.OpenDeskAcc(name)
- elif id == self.quitid and item == 1:
- if hasattr(MacOS, 'OutputSeen'):
- MacOS.OutputSeen()
- self.quitting = 1
- Menu.HiliteMenu(0)
- return
- # Anything not handled is passed to Python/SIOUX
- if hasattr(MacOS, 'HandleEvent'):
- MacOS.HandleEvent(event)
- else:
- print "Unhandled event:", event
-
- def getabouttext(self):
- return self.__class__.__name__
-
- def getaboutmenutext(self):
- return "About %s\311" % self.__class__.__name__
-
-
-class AEServer:
-
- def __init__(self):
- self.ae_handlers = {}
-
- def installaehandler(self, classe, type, callback):
- AE.AEInstallEventHandler(classe, type, self.callback_wrapper)
- self.ae_handlers[(classe, type)] = callback
-
- def close(self):
- for classe, type in self.ae_handlers.keys():
- AE.AERemoveEventHandler(classe, type)
-
- def callback_wrapper(self, _request, _reply):
- _parameters, _attributes = aetools.unpackevent(_request)
- _class = _attributes['evcl'].type
- _type = _attributes['evid'].type
-
- if (_class, _type) in self.ae_handlers:
- _function = self.ae_handlers[(_class, _type)]
- elif (_class, '****') in self.ae_handlers:
- _function = self.ae_handlers[(_class, '****')]
- elif ('****', '****') in self.ae_handlers:
- _function = self.ae_handlers[('****', '****')]
- else:
- raise 'Cannot happen: AE callback without handler', (_class, _type)
-
- # XXXX Do key-to-name mapping here
-
- _parameters['_attributes'] = _attributes
- _parameters['_class'] = _class
- _parameters['_type'] = _type
- if '----' in _parameters:
- _object = _parameters['----']
- del _parameters['----']
- # The try/except that used to be here can mask programmer errors.
- # Let the program crash, the programmer can always add a **args
- # to the formal parameter list.
- rv = _function(_object, **_parameters)
- else:
- #Same try/except comment as above
- rv = _function(**_parameters)
-
- if rv is None:
- aetools.packevent(_reply, {})
- else:
- aetools.packevent(_reply, {'----':rv})
-
-
-def code(x):
- "Convert a long int to the 4-character code it really is"
- s = ''
- for i in range(4):
- x, c = divmod(x, 256)
- s = chr(c) + s
- return s
-
-class _Test(AEServer, MiniApplication):
- """Mini test application, handles required events"""
-
- def __init__(self):
- MiniApplication.__init__(self)
- AEServer.__init__(self)
- self.installaehandler('aevt', 'oapp', self.open_app)
- self.installaehandler('aevt', 'quit', self.quit)
- self.installaehandler('****', '****', self.other)
- self.mainloop()
-
- def quit(self, **args):
- self._quit()
-
- def open_app(self, **args):
- pass
-
- def other(self, _object=None, _class=None, _type=None, **args):
- print 'AppleEvent', (_class, _type), 'for', _object, 'Other args:', args
-
-
-if __name__ == '__main__':
- _Test()
diff --git a/Lib/plat-mac/PixMapWrapper.py b/Lib/plat-mac/PixMapWrapper.py
deleted file mode 100644
index 5ce304357d9..00000000000
--- a/Lib/plat-mac/PixMapWrapper.py
+++ /dev/null
@@ -1,218 +0,0 @@
-"""PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque
-QuickDraw PixMap data structure in a handy Python class. Also provides
-methods to convert to/from pixel data (from, e.g., the img module) or a
-Python Imaging Library Image object.
-
-J. Strout <joe@strout.net> February 1999"""
-
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the PixMapWrapper module is removed.", stacklevel=2)
-
-from Carbon import Qd
-from Carbon import QuickDraw
-import struct
-import MacOS
-import img
-import imgformat
-
-# PixMap data structure element format (as used with struct)
-_pmElemFormat = {
- 'baseAddr':'l', # address of pixel data
- 'rowBytes':'H', # bytes per row, plus 0x8000
- 'bounds':'hhhh', # coordinates imposed over pixel data
- 'top':'h',
- 'left':'h',
- 'bottom':'h',
- 'right':'h',
- 'pmVersion':'h', # flags for Color QuickDraw
- 'packType':'h', # format of compression algorithm
- 'packSize':'l', # size after compression
- 'hRes':'l', # horizontal pixels per inch
- 'vRes':'l', # vertical pixels per inch
- 'pixelType':'h', # pixel format
- 'pixelSize':'h', # bits per pixel
- 'cmpCount':'h', # color components per pixel
- 'cmpSize':'h', # bits per component
- 'planeBytes':'l', # offset in bytes to next plane
- 'pmTable':'l', # handle to color table
- 'pmReserved':'l' # reserved for future use
-}
-
-# PixMap data structure element offset
-_pmElemOffset = {
- 'baseAddr':0,
- 'rowBytes':4,
- 'bounds':6,
- 'top':6,
- 'left':8,
- 'bottom':10,
- 'right':12,
- 'pmVersion':14,
- 'packType':16,
- 'packSize':18,
- 'hRes':22,
- 'vRes':26,
- 'pixelType':30,
- 'pixelSize':32,
- 'cmpCount':34,
- 'cmpSize':36,
- 'planeBytes':38,
- 'pmTable':42,
- 'pmReserved':46
-}
-
-class PixMapWrapper:
- """PixMapWrapper -- wraps the QD PixMap object in a Python class,
- with methods to easily get/set various pixmap fields. Note: Use the
- PixMap() method when passing to QD calls."""
-
- def __init__(self):
- self.__dict__['data'] = ''
- self._header = struct.pack("lhhhhhhhlllhhhhlll",
- id(self.data)+MacOS.string_id_to_buffer,
- 0, # rowBytes
- 0, 0, 0, 0, # bounds
- 0, # pmVersion
- 0, 0, # packType, packSize
- 72<<16, 72<<16, # hRes, vRes
- QuickDraw.RGBDirect, # pixelType
- 16, # pixelSize
- 2, 5, # cmpCount, cmpSize,
- 0, 0, 0) # planeBytes, pmTable, pmReserved
- self.__dict__['_pm'] = Qd.RawBitMap(self._header)
-
- def _stuff(self, element, bytes):
- offset = _pmElemOffset[element]
- fmt = _pmElemFormat[element]
- self._header = self._header[:offset] \
- + struct.pack(fmt, bytes) \
- + self._header[offset + struct.calcsize(fmt):]
- self.__dict__['_pm'] = None
-
- def _unstuff(self, element):
- offset = _pmElemOffset[element]
- fmt = _pmElemFormat[element]
- return struct.unpack(fmt, self._header[offset:offset+struct.calcsize(fmt)])[0]
-
- def __setattr__(self, attr, val):
- if attr == 'baseAddr':
- raise 'UseErr', "don't assign to .baseAddr -- assign to .data instead"
- elif attr == 'data':
- self.__dict__['data'] = val
- self._stuff('baseAddr', id(self.data) + MacOS.string_id_to_buffer)
- elif attr == 'rowBytes':
- # high bit is always set for some odd reason
- self._stuff('rowBytes', val | 0x8000)
- elif attr == 'bounds':
- # assume val is in official Left, Top, Right, Bottom order!
- self._stuff('left',val[0])
- self._stuff('top',val[1])
- self._stuff('right',val[2])
- self._stuff('bottom',val[3])
- elif attr == 'hRes' or attr == 'vRes':
- # 16.16 fixed format, so just shift 16 bits
- self._stuff(attr, int(val) << 16)
- elif attr in _pmElemFormat.keys():
- # any other pm attribute -- just stuff
- self._stuff(attr, val)
- else:
- self.__dict__[attr] = val
-
- def __getattr__(self, attr):
- if attr == 'rowBytes':
- # high bit is always set for some odd reason
- return self._unstuff('rowBytes') & 0x7FFF
- elif attr == 'bounds':
- # return bounds in official Left, Top, Right, Bottom order!
- return ( \
- self._unstuff('left'),
- self._unstuff('top'),
- self._unstuff('right'),
- self._unstuff('bottom') )
- elif attr == 'hRes' or attr == 'vRes':
- # 16.16 fixed format, so just shift 16 bits
- return self._unstuff(attr) >> 16
- elif attr in _pmElemFormat.keys():
- # any other pm attribute -- just unstuff
- return self._unstuff(attr)
- else:
- return self.__dict__[attr]
-
-
- def PixMap(self):
- "Return a QuickDraw PixMap corresponding to this data."
- if not self.__dict__['_pm']:
- self.__dict__['_pm'] = Qd.RawBitMap(self._header)
- return self.__dict__['_pm']
-
- def blit(self, x1=0,y1=0,x2=None,y2=None, port=None):
- """Draw this pixmap into the given (default current) grafport."""
- src = self.bounds
- dest = [x1,y1,x2,y2]
- if x2 is None:
- dest[2] = x1 + src[2]-src[0]
- if y2 is None:
- dest[3] = y1 + src[3]-src[1]
- if not port: port = Qd.GetPort()
- Qd.CopyBits(self.PixMap(), port.GetPortBitMapForCopyBits(), src, tuple(dest),
- QuickDraw.srcCopy, None)
-
- def fromstring(self,s,width,height,format=imgformat.macrgb):
- """Stuff this pixmap with raw pixel data from a string.
- Supply width, height, and one of the imgformat specifiers."""
- # we only support 16- and 32-bit mac rgb...
- # so convert if necessary
- if format != imgformat.macrgb and format != imgformat.macrgb16:
- # (LATER!)
- raise "NotImplementedError", "conversion to macrgb or macrgb16"
- self.data = s
- self.bounds = (0,0,width,height)
- self.cmpCount = 3
- self.pixelType = QuickDraw.RGBDirect
- if format == imgformat.macrgb:
- self.pixelSize = 32
- self.cmpSize = 8
- else:
- self.pixelSize = 16
- self.cmpSize = 5
- self.rowBytes = width*self.pixelSize/8
-
- def tostring(self, format=imgformat.macrgb):
- """Return raw data as a string in the specified format."""
- # is the native format requested? if so, just return data
- if (format == imgformat.macrgb and self.pixelSize == 32) or \
- (format == imgformat.macrgb16 and self.pixelsize == 16):
- return self.data
- # otherwise, convert to the requested format
- # (LATER!)
- raise "NotImplementedError", "data format conversion"
-
- def fromImage(self,im):
- """Initialize this PixMap from a PIL Image object."""
- # We need data in ARGB format; PIL can't currently do that,
- # but it can do RGBA, which we can use by inserting one null
- # up frontpm =
- if im.mode != 'RGBA': im = im.convert('RGBA')
- data = chr(0) + im.tostring()
- self.fromstring(data, im.size[0], im.size[1])
-
- def toImage(self):
- """Return the contents of this PixMap as a PIL Image object."""
- import Image
- # our tostring() method returns data in ARGB format,
- # whereas Image uses RGBA; a bit of slicing fixes this...
- data = self.tostring()[1:] + chr(0)
- bounds = self.bounds
- return Image.fromstring('RGBA',(bounds[2]-bounds[0],bounds[3]-bounds[1]),data)
-
-def test():
- import MacOS
- import EasyDialogs
- import Image
- path = EasyDialogs.AskFileForOpen("Image File:")
- if not path: return
- pm = PixMapWrapper()
- pm.fromImage( Image.open(path) )
- pm.blit(20,20)
- return pm
diff --git a/Lib/plat-mac/aepack.py b/Lib/plat-mac/aepack.py
deleted file mode 100644
index bb2a37feb3a..00000000000
--- a/Lib/plat-mac/aepack.py
+++ /dev/null
@@ -1,369 +0,0 @@
-"""Tools for use in AppleEvent clients and servers:
-conversion between AE types and python types
-
-pack(x) converts a Python object to an AEDesc object
-unpack(desc) does the reverse
-coerce(x, wanted_sample) coerces a python object to another python object
-"""
-
-#
-# This code was originally written by Guido, and modified/extended by Jack
-# to include the various types that were missing. The reference used is
-# Apple Event Registry, chapter 9.
-#
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the aepack module is removed.", stacklevel=2)
-
-import struct
-import types
-from types import *
-from Carbon import AE
-from Carbon.AppleEvents import *
-import MacOS
-import Carbon.File
-import aetypes
-from aetypes import mkenum, ObjectSpecifier
-
-# These ones seem to be missing from AppleEvents
-# (they're in AERegistry.h)
-
-#typeColorTable = 'clrt'
-#typeDrawingArea = 'cdrw'
-#typePixelMap = 'cpix'
-#typePixelMapMinus = 'tpmm'
-#typeRotation = 'trot'
-#typeTextStyles = 'tsty'
-#typeStyledText = 'STXT'
-#typeAEText = 'tTXT'
-#typeEnumeration = 'enum'
-
-#
-# Some AE types are immedeately coerced into something
-# we like better (and which is equivalent)
-#
-unpacker_coercions = {
- typeComp : typeFloat,
- typeColorTable : typeAEList,
- typeDrawingArea : typeAERecord,
- typeFixed : typeFloat,
- typeExtended : typeFloat,
- typePixelMap : typeAERecord,
- typeRotation : typeAERecord,
- typeStyledText : typeAERecord,
- typeTextStyles : typeAERecord,
-};
-
-#
-# Some python types we need in the packer:
-#
-AEDescType = AE.AEDescType
-try:
- FSSType = Carbon.File.FSSpecType
-except AttributeError:
- class FSSType:
- pass
-FSRefType = Carbon.File.FSRefType
-AliasType = Carbon.File.AliasType
-
-def packkey(ae, key, value):
- if hasattr(key, 'which'):
- keystr = key.which
- elif hasattr(key, 'want'):
- keystr = key.want
- else:
- keystr = key
- ae.AEPutParamDesc(keystr, pack(value))
-
-def pack(x, forcetype = None):
- """Pack a python object into an AE descriptor"""
-
- if forcetype:
- if type(x) is StringType:
- return AE.AECreateDesc(forcetype, x)
- else:
- return pack(x).AECoerceDesc(forcetype)
-
- if x is None:
- return AE.AECreateDesc('null', '')
-
- if isinstance(x, AEDescType):
- return x
- if isinstance(x, FSSType):
- return AE.AECreateDesc('fss ', x.data)
- if isinstance(x, FSRefType):
- return AE.AECreateDesc('fsrf', x.data)
- if isinstance(x, AliasType):
- return AE.AECreateDesc('alis', x.data)
- if isinstance(x, IntType):
- return AE.AECreateDesc('long', struct.pack('l', x))
- if isinstance(x, FloatType):
- return AE.AECreateDesc('doub', struct.pack('d', x))
- if isinstance(x, StringType):
- return AE.AECreateDesc('TEXT', x)
- if isinstance(x, UnicodeType):
- data = x.encode('utf16')
- if data[:2] == '\xfe\xff':
- data = data[2:]
- return AE.AECreateDesc('utxt', data)
- if isinstance(x, ListType):
- list = AE.AECreateList('', 0)
- for item in x:
- list.AEPutDesc(0, pack(item))
- return list
- if isinstance(x, DictionaryType):
- record = AE.AECreateList('', 1)
- for key, value in x.items():
- packkey(record, key, value)
- #record.AEPutParamDesc(key, pack(value))
- return record
- if type(x) == types.ClassType and issubclass(x, ObjectSpecifier):
- # Note: we are getting a class object here, not an instance
- return AE.AECreateDesc('type', x.want)
- if hasattr(x, '__aepack__'):
- return x.__aepack__()
- if hasattr(x, 'which'):
- return AE.AECreateDesc('TEXT', x.which)
- if hasattr(x, 'want'):
- return AE.AECreateDesc('TEXT', x.want)
- return AE.AECreateDesc('TEXT', repr(x)) # Copout
-
-def unpack(desc, formodulename=""):
- """Unpack an AE descriptor to a python object"""
- t = desc.type
-
- if t in unpacker_coercions:
- desc = desc.AECoerceDesc(unpacker_coercions[t])
- t = desc.type # This is a guess by Jack....
-
- if t == typeAEList:
- l = []
- for i in range(desc.AECountItems()):
- keyword, item = desc.AEGetNthDesc(i+1, '****')
- l.append(unpack(item, formodulename))
- return l
- if t == typeAERecord:
- d = {}
- for i in range(desc.AECountItems()):
- keyword, item = desc.AEGetNthDesc(i+1, '****')
- d[keyword] = unpack(item, formodulename)
- return d
- if t == typeAEText:
- record = desc.AECoerceDesc('reco')
- return mkaetext(unpack(record, formodulename))
- if t == typeAlias:
- return Carbon.File.Alias(rawdata=desc.data)
- # typeAppleEvent returned as unknown
- if t == typeBoolean:
- return struct.unpack('b', desc.data)[0]
- if t == typeChar:
- return desc.data
- if t == typeUnicodeText:
- return unicode(desc.data, 'utf16')
- # typeColorTable coerced to typeAEList
- # typeComp coerced to extended
- # typeData returned as unknown
- # typeDrawingArea coerced to typeAERecord
- if t == typeEnumeration:
- return mkenum(desc.data)
- # typeEPS returned as unknown
- if t == typeFalse:
- return 0
- if t == typeFloat:
- data = desc.data
- return struct.unpack('d', data)[0]
- if t == typeFSS:
- return Carbon.File.FSSpec(rawdata=desc.data)
- if t == typeFSRef:
- return Carbon.File.FSRef(rawdata=desc.data)
- if t == typeInsertionLoc:
- record = desc.AECoerceDesc('reco')
- return mkinsertionloc(unpack(record, formodulename))
- # typeInteger equal to typeLongInteger
- if t == typeIntlText:
- script, language = struct.unpack('hh', desc.data[:4])
- return aetypes.IntlText(script, language, desc.data[4:])
- if t == typeIntlWritingCode:
- script, language = struct.unpack('hh', desc.data)
- return aetypes.IntlWritingCode(script, language)
- if t == typeKeyword:
- return mkkeyword(desc.data)
- if t == typeLongInteger:
- return struct.unpack('l', desc.data)[0]
- if t == typeLongDateTime:
- a, b = struct.unpack('lL', desc.data)
- return (long(a) << 32) + b
- if t == typeNull:
- return None
- if t == typeMagnitude:
- v = struct.unpack('l', desc.data)
- if v < 0:
- v = 0x100000000L + v
- return v
- if t == typeObjectSpecifier:
- record = desc.AECoerceDesc('reco')
- # If we have been told the name of the module we are unpacking aedescs for,
- # we can attempt to create the right type of python object from that module.
- if formodulename:
- return mkobjectfrommodule(unpack(record, formodulename), formodulename)
- return mkobject(unpack(record, formodulename))
- # typePict returned as unknown
- # typePixelMap coerced to typeAERecord
- # typePixelMapMinus returned as unknown
- # typeProcessSerialNumber returned as unknown
- if t == typeQDPoint:
- v, h = struct.unpack('hh', desc.data)
- return aetypes.QDPoint(v, h)
- if t == typeQDRectangle:
- v0, h0, v1, h1 = struct.unpack('hhhh', desc.data)
- return aetypes.QDRectangle(v0, h0, v1, h1)
- if t == typeRGBColor:
- r, g, b = struct.unpack('hhh', desc.data)
- return aetypes.RGBColor(r, g, b)
- # typeRotation coerced to typeAERecord
- # typeScrapStyles returned as unknown
- # typeSessionID returned as unknown
- if t == typeShortFloat:
- return struct.unpack('f', desc.data)[0]
- if t == typeShortInteger:
- return struct.unpack('h', desc.data)[0]
- # typeSMFloat identical to typeShortFloat
- # typeSMInt indetical to typeShortInt
- # typeStyledText coerced to typeAERecord
- if t == typeTargetID:
- return mktargetid(desc.data)
- # typeTextStyles coerced to typeAERecord
- # typeTIFF returned as unknown
- if t == typeTrue:
- return 1
- if t == typeType:
- return mktype(desc.data, formodulename)
- #
- # The following are special
- #
- if t == 'rang':
- record = desc.AECoerceDesc('reco')
- return mkrange(unpack(record, formodulename))
- if t == 'cmpd':
- record = desc.AECoerceDesc('reco')
- return mkcomparison(unpack(record, formodulename))
- if t == 'logi':
- record = desc.AECoerceDesc('reco')
- return mklogical(unpack(record, formodulename))
- return mkunknown(desc.type, desc.data)
-
-def coerce(data, egdata):
- """Coerce a python object to another type using the AE coercers"""
- pdata = pack(data)
- pegdata = pack(egdata)
- pdata = pdata.AECoerceDesc(pegdata.type)
- return unpack(pdata)
-
-#
-# Helper routines for unpack
-#
-def mktargetid(data):
- sessionID = getlong(data[:4])
- name = mkppcportrec(data[4:4+72])
- location = mklocationnamerec(data[76:76+36])
- rcvrName = mkppcportrec(data[112:112+72])
- return sessionID, name, location, rcvrName
-
-def mkppcportrec(rec):
- namescript = getword(rec[:2])
- name = getpstr(rec[2:2+33])
- portkind = getword(rec[36:38])
- if portkind == 1:
- ctor = rec[38:42]
- type = rec[42:46]
- identity = (ctor, type)
- else:
- identity = getpstr(rec[38:38+33])
- return namescript, name, portkind, identity
-
-def mklocationnamerec(rec):
- kind = getword(rec[:2])
- stuff = rec[2:]
- if kind == 0: stuff = None
- if kind == 2: stuff = getpstr(stuff)
- return kind, stuff
-
-def mkunknown(type, data):
- return aetypes.Unknown(type, data)
-
-def getpstr(s):
- return s[1:1+ord(s[0])]
-
-def getlong(s):
- return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
-
-def getword(s):
- return (ord(s[0])<<8) | (ord(s[1])<<0)
-
-def mkkeyword(keyword):
- return aetypes.Keyword(keyword)
-
-def mkrange(dict):
- return aetypes.Range(dict['star'], dict['stop'])
-
-def mkcomparison(dict):
- return aetypes.Comparison(dict['obj1'], dict['relo'].enum, dict['obj2'])
-
-def mklogical(dict):
- return aetypes.Logical(dict['logc'], dict['term'])
-
-def mkstyledtext(dict):
- return aetypes.StyledText(dict['ksty'], dict['ktxt'])
-
-def mkaetext(dict):
- return aetypes.AEText(dict[keyAEScriptTag], dict[keyAEStyles], dict[keyAEText])
-
-def mkinsertionloc(dict):
- return aetypes.InsertionLoc(dict[keyAEObject], dict[keyAEPosition])
-
-def mkobject(dict):
- want = dict['want'].type
- form = dict['form'].enum
- seld = dict['seld']
- fr = dict['from']
- if form in ('name', 'indx', 'rang', 'test'):
- if want == 'text': return aetypes.Text(seld, fr)
- if want == 'cha ': return aetypes.Character(seld, fr)
- if want == 'cwor': return aetypes.Word(seld, fr)
- if want == 'clin': return aetypes.Line(seld, fr)
- if want == 'cpar': return aetypes.Paragraph(seld, fr)
- if want == 'cwin': return aetypes.Window(seld, fr)
- if want == 'docu': return aetypes.Document(seld, fr)
- if want == 'file': return aetypes.File(seld, fr)
- if want == 'cins': return aetypes.InsertionPoint(seld, fr)
- if want == 'prop' and form == 'prop' and aetypes.IsType(seld):
- return aetypes.Property(seld.type, fr)
- return aetypes.ObjectSpecifier(want, form, seld, fr)
-
-# Note by Jack: I'm not 100% sure of the following code. This was
-# provided by Donovan Preston, but I wonder whether the assignment
-# to __class__ is safe. Moreover, shouldn't there be a better
-# initializer for the classes in the suites?
-def mkobjectfrommodule(dict, modulename):
- if type(dict['want']) == types.ClassType and issubclass(dict['want'], ObjectSpecifier):
- # The type has already been converted to Python. Convert back:-(
- classtype = dict['want']
- dict['want'] = aetypes.mktype(classtype.want)
- want = dict['want'].type
- module = __import__(modulename)
- codenamemapper = module._classdeclarations
- classtype = codenamemapper.get(want, None)
- newobj = mkobject(dict)
- if classtype:
- assert issubclass(classtype, ObjectSpecifier)
- newobj.__class__ = classtype
- return newobj
-
-def mktype(typecode, modulename=None):
- if modulename:
- module = __import__(modulename)
- codenamemapper = module._classdeclarations
- classtype = codenamemapper.get(typecode, None)
- if classtype:
- return classtype
- return aetypes.mktype(typecode)
diff --git a/Lib/plat-mac/aetools.py b/Lib/plat-mac/aetools.py
deleted file mode 100644
index 41d7a217094..00000000000
--- a/Lib/plat-mac/aetools.py
+++ /dev/null
@@ -1,363 +0,0 @@
-"""Tools for use in AppleEvent clients and servers.
-
-pack(x) converts a Python object to an AEDesc object
-unpack(desc) does the reverse
-
-packevent(event, parameters, attributes) sets params and attrs in an AEAppleEvent record
-unpackevent(event) returns the parameters and attributes from an AEAppleEvent record
-
-Plus... Lots of classes and routines that help representing AE objects,
-ranges, conditionals, logicals, etc., so you can write, e.g.:
-
- x = Character(1, Document("foobar"))
-
-and pack(x) will create an AE object reference equivalent to AppleScript's
-
- character 1 of document "foobar"
-
-Some of the stuff that appears to be exported from this module comes from other
-files: the pack stuff from aepack, the objects from aetypes.
-
-"""
-
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the aetools module is removed.", stacklevel=2)
-
-from types import *
-from Carbon import AE
-from Carbon import Evt
-from Carbon import AppleEvents
-import MacOS
-import sys
-import time
-
-from aetypes import *
-from aepack import packkey, pack, unpack, coerce, AEDescType
-
-Error = 'aetools.Error'
-
-# Amount of time to wait for program to be launched
-LAUNCH_MAX_WAIT_TIME=10
-
-# Special code to unpack an AppleEvent (which is *not* a disguised record!)
-# Note by Jack: No??!? If I read the docs correctly it *is*....
-
-aekeywords = [
- 'tran',
- 'rtid',
- 'evcl',
- 'evid',
- 'addr',
- 'optk',
- 'timo',
- 'inte', # this attribute is read only - will be set in AESend
- 'esrc', # this attribute is read only
- 'miss', # this attribute is read only
- 'from' # new in 1.0.1
-]
-
-def missed(ae):
- try:
- desc = ae.AEGetAttributeDesc('miss', 'keyw')
- except AE.Error, msg:
- return None
- return desc.data
-
-def unpackevent(ae, formodulename=""):
- parameters = {}
- try:
- dirobj = ae.AEGetParamDesc('----', '****')
- except AE.Error:
- pass
- else:
- parameters['----'] = unpack(dirobj, formodulename)
- del dirobj
- # Workaround for what I feel is a bug in OSX 10.2: 'errn' won't show up in missed...
- try:
- dirobj = ae.AEGetParamDesc('errn', '****')
- except AE.Error:
- pass
- else:
- parameters['errn'] = unpack(dirobj, formodulename)
- del dirobj
- while 1:
- key = missed(ae)
- if not key: break
- parameters[key] = unpack(ae.AEGetParamDesc(key, '****'), formodulename)
- attributes = {}
- for key in aekeywords:
- try:
- desc = ae.AEGetAttributeDesc(key, '****')
- except (AE.Error, MacOS.Error), msg:
- if msg[0] != -1701 and msg[0] != -1704:
- raise
- continue
- attributes[key] = unpack(desc, formodulename)
- return parameters, attributes
-
-def packevent(ae, parameters = {}, attributes = {}):
- for key, value in parameters.items():
- packkey(ae, key, value)
- for key, value in attributes.items():
- ae.AEPutAttributeDesc(key, pack(value))
-
-#
-# Support routine for automatically generated Suite interfaces
-# These routines are also useable for the reverse function.
-#
-def keysubst(arguments, keydict):
- """Replace long name keys by their 4-char counterparts, and check"""
- ok = keydict.values()
- for k in arguments.keys():
- if k in keydict:
- v = arguments[k]
- del arguments[k]
- arguments[keydict[k]] = v
- elif k != '----' and k not in ok:
- raise TypeError, 'Unknown keyword argument: %s'%k
-
-def enumsubst(arguments, key, edict):
- """Substitute a single enum keyword argument, if it occurs"""
- if key not in arguments or edict is None:
- return
- v = arguments[key]
- ok = edict.values()
- if v in edict:
- arguments[key] = Enum(edict[v])
- elif not v in ok:
- raise TypeError, 'Unknown enumerator: %s'%v
-
-def decodeerror(arguments):
- """Create the 'best' argument for a raise MacOS.Error"""
- errn = arguments['errn']
- err_a1 = errn
- if 'errs' in arguments:
- err_a2 = arguments['errs']
- else:
- err_a2 = MacOS.GetErrorString(errn)
- if 'erob' in arguments:
- err_a3 = arguments['erob']
- else:
- err_a3 = None
-
- return (err_a1, err_a2, err_a3)
-
-class TalkTo:
- """An AE connection to an application"""
- _signature = None # Can be overridden by subclasses
- _moduleName = None # Can be overridden by subclasses
- _elemdict = {} # Can be overridden by subclasses
- _propdict = {} # Can be overridden by subclasses
-
- __eventloop_initialized = 0
- def __ensure_WMAvailable(klass):
- if klass.__eventloop_initialized: return 1
- if not MacOS.WMAvailable(): return 0
- # Workaround for a but in MacOSX 10.2: we must have an event
- # loop before we can call AESend.
- Evt.WaitNextEvent(0,0)
- return 1
- __ensure_WMAvailable = classmethod(__ensure_WMAvailable)
-
- def __init__(self, signature=None, start=0, timeout=0):
- """Create a communication channel with a particular application.
-
- Addressing the application is done by specifying either a
- 4-byte signature, an AEDesc or an object that will __aepack__
- to an AEDesc.
- """
- self.target_signature = None
- if signature is None:
- signature = self._signature
- if type(signature) == AEDescType:
- self.target = signature
- elif type(signature) == InstanceType and hasattr(signature, '__aepack__'):
- self.target = signature.__aepack__()
- elif type(signature) == StringType and len(signature) == 4:
- self.target = AE.AECreateDesc(AppleEvents.typeApplSignature, signature)
- self.target_signature = signature
- else:
- raise TypeError, "signature should be 4-char string or AEDesc"
- self.send_flags = AppleEvents.kAEWaitReply
- self.send_priority = AppleEvents.kAENormalPriority
- if timeout:
- self.send_timeout = timeout
- else:
- self.send_timeout = AppleEvents.kAEDefaultTimeout
- if start:
- self._start()
-
- def _start(self):
- """Start the application, if it is not running yet"""
- try:
- self.send('ascr', 'noop')
- except AE.Error:
- _launch(self.target_signature)
- for i in range(LAUNCH_MAX_WAIT_TIME):
- try:
- self.send('ascr', 'noop')
- except AE.Error:
- pass
- else:
- break
- time.sleep(1)
-
- def start(self):
- """Deprecated, used _start()"""
- self._start()
-
- def newevent(self, code, subcode, parameters = {}, attributes = {}):
- """Create a complete structure for an apple event"""
-
- event = AE.AECreateAppleEvent(code, subcode, self.target,
- AppleEvents.kAutoGenerateReturnID, AppleEvents.kAnyTransactionID)
- packevent(event, parameters, attributes)
- return event
-
- def sendevent(self, event):
- """Send a pre-created appleevent, await the reply and unpack it"""
- if not self.__ensure_WMAvailable():
- raise RuntimeError, "No window manager access, cannot send AppleEvent"
- reply = event.AESend(self.send_flags, self.send_priority,
- self.send_timeout)
- parameters, attributes = unpackevent(reply, self._moduleName)
- return reply, parameters, attributes
-
- def send(self, code, subcode, parameters = {}, attributes = {}):
- """Send an appleevent given code/subcode/pars/attrs and unpack the reply"""
- return self.sendevent(self.newevent(code, subcode, parameters, attributes))
-
- #
- # The following events are somehow "standard" and don't seem to appear in any
- # suite...
- #
- def activate(self):
- """Send 'activate' command"""
- self.send('misc', 'actv')
-
- def _get(self, _object, asfile=None, _attributes={}):
- """_get: get data from an object
- Required argument: the object
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the data
- """
- _code = 'core'
- _subcode = 'getd'
-
- _arguments = {'----':_object}
- if asfile:
- _arguments['rtyp'] = mktype(asfile)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if 'errn' in _arguments:
- raise Error, decodeerror(_arguments)
-
- if '----' in _arguments:
- return _arguments['----']
- if asfile:
- item.__class__ = asfile
- return item
-
- get = _get
-
- _argmap_set = {
- 'to' : 'data',
- }
-
- def _set(self, _object, _attributes={}, **_arguments):
- """set: Set an object's data.
- Required argument: the object for the command
- Keyword argument to: The new value.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'setd'
-
- keysubst(_arguments, self._argmap_set)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise Error, decodeerror(_arguments)
- # XXXX Optionally decode result
- if '----' in _arguments:
- return _arguments['----']
-
- set = _set
-
- # Magic glue to allow suite-generated classes to function somewhat
- # like the "application" class in OSA.
-
- def __getattr__(self, name):
- if name in self._elemdict:
- cls = self._elemdict[name]
- return DelayedComponentItem(cls, None)
- if name in self._propdict:
- cls = self._propdict[name]
- return cls()
- raise AttributeError, name
-
-# Tiny Finder class, for local use only
-
-class _miniFinder(TalkTo):
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if 'errn' in _arguments:
- raise Error, decodeerror(_arguments)
- # XXXX Optionally decode result
- if '----' in _arguments:
- return _arguments['----']
-#pass
-
-_finder = _miniFinder('MACS')
-
-def _launch(appfile):
- """Open a file thru the finder. Specify file by name or fsspec"""
- _finder.open(_application_file(('ID ', appfile)))
-
-
-class _application_file(ComponentItem):
- """application file - An application's file on disk"""
- want = 'appf'
-
-_application_file._propdict = {
-}
-_application_file._elemdict = {
-}
-
-# Test program
-# XXXX Should test more, really...
-
-def test():
- target = AE.AECreateDesc('sign', 'quil')
- ae = AE.AECreateAppleEvent('aevt', 'oapp', target, -1, 0)
- print unpackevent(ae)
- raw_input(":")
- ae = AE.AECreateAppleEvent('core', 'getd', target, -1, 0)
- obj = Character(2, Word(1, Document(1)))
- print obj
- print repr(obj)
- packevent(ae, {'----': obj})
- params, attrs = unpackevent(ae)
- print params['----']
- raw_input(":")
-
-if __name__ == '__main__':
- test()
- sys.exit(1)
diff --git a/Lib/plat-mac/aetypes.py b/Lib/plat-mac/aetypes.py
deleted file mode 100644
index f3331564089..00000000000
--- a/Lib/plat-mac/aetypes.py
+++ /dev/null
@@ -1,571 +0,0 @@
-"""aetypes - Python objects representing various AE types."""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the aetypes module is removed.", stacklevel=2)
-
-from Carbon.AppleEvents import *
-import struct
-from types import *
-import string
-
-#
-# convoluted, since there are cyclic dependencies between this file and
-# aetools_convert.
-#
-def pack(*args, **kwargs):
- from aepack import pack
- return pack( *args, **kwargs)
-
-def nice(s):
- """'nice' representation of an object"""
- if type(s) is StringType: return repr(s)
- else: return str(s)
-
-class Unknown:
- """An uninterpreted AE object"""
-
- def __init__(self, type, data):
- self.type = type
- self.data = data
-
- def __repr__(self):
- return "Unknown(%r, %r)" % (self.type, self.data)
-
- def __aepack__(self):
- return pack(self.data, self.type)
-
-class Enum:
- """An AE enumeration value"""
-
- def __init__(self, enum):
- self.enum = "%-4.4s" % str(enum)
-
- def __repr__(self):
- return "Enum(%r)" % (self.enum,)
-
- def __str__(self):
- return string.strip(self.enum)
-
- def __aepack__(self):
- return pack(self.enum, typeEnumeration)
-
-def IsEnum(x):
- return isinstance(x, Enum)
-
-def mkenum(enum):
- if IsEnum(enum): return enum
- return Enum(enum)
-
-# Jack changed the way this is done
-class InsertionLoc:
- def __init__(self, of, pos):
- self.of = of
- self.pos = pos
-
- def __repr__(self):
- return "InsertionLoc(%r, %r)" % (self.of, self.pos)
-
- def __aepack__(self):
- rec = {'kobj': self.of, 'kpos': self.pos}
- return pack(rec, forcetype='insl')
-
-# Convenience functions for dsp:
-def beginning(of):
- return InsertionLoc(of, Enum('bgng'))
-
-def end(of):
- return InsertionLoc(of, Enum('end '))
-
-class Boolean:
- """An AE boolean value"""
-
- def __init__(self, bool):
- self.bool = (not not bool)
-
- def __repr__(self):
- return "Boolean(%r)" % (self.bool,)
-
- def __str__(self):
- if self.bool:
- return "True"
- else:
- return "False"
-
- def __aepack__(self):
- return pack(struct.pack('b', self.bool), 'bool')
-
-def IsBoolean(x):
- return isinstance(x, Boolean)
-
-def mkboolean(bool):
- if IsBoolean(bool): return bool
- return Boolean(bool)
-
-class Type:
- """An AE 4-char typename object"""
-
- def __init__(self, type):
- self.type = "%-4.4s" % str(type)
-
- def __repr__(self):
- return "Type(%r)" % (self.type,)
-
- def __str__(self):
- return string.strip(self.type)
-
- def __aepack__(self):
- return pack(self.type, typeType)
-
-def IsType(x):
- return isinstance(x, Type)
-
-def mktype(type):
- if IsType(type): return type
- return Type(type)
-
-
-class Keyword:
- """An AE 4-char keyword object"""
-
- def __init__(self, keyword):
- self.keyword = "%-4.4s" % str(keyword)
-
- def __repr__(self):
- return "Keyword(%r)" % repr(self.keyword)
-
- def __str__(self):
- return string.strip(self.keyword)
-
- def __aepack__(self):
- return pack(self.keyword, typeKeyword)
-
-def IsKeyword(x):
- return isinstance(x, Keyword)
-
-class Range:
- """An AE range object"""
-
- def __init__(self, start, stop):
- self.start = start
- self.stop = stop
-
- def __repr__(self):
- return "Range(%r, %r)" % (self.start, self.stop)
-
- def __str__(self):
- return "%s thru %s" % (nice(self.start), nice(self.stop))
-
- def __aepack__(self):
- return pack({'star': self.start, 'stop': self.stop}, 'rang')
-
-def IsRange(x):
- return isinstance(x, Range)
-
-class Comparison:
- """An AE Comparison"""
-
- def __init__(self, obj1, relo, obj2):
- self.obj1 = obj1
- self.relo = "%-4.4s" % str(relo)
- self.obj2 = obj2
-
- def __repr__(self):
- return "Comparison(%r, %r, %r)" % (self.obj1, self.relo, self.obj2)
-
- def __str__(self):
- return "%s %s %s" % (nice(self.obj1), string.strip(self.relo), nice(self.obj2))
-
- def __aepack__(self):
- return pack({'obj1': self.obj1,
- 'relo': mkenum(self.relo),
- 'obj2': self.obj2},
- 'cmpd')
-
-def IsComparison(x):
- return isinstance(x, Comparison)
-
-class NComparison(Comparison):
- # The class attribute 'relo' must be set in a subclass
-
- def __init__(self, obj1, obj2):
- Comparison.__init__(obj1, self.relo, obj2)
-
-class Ordinal:
- """An AE Ordinal"""
-
- def __init__(self, abso):
-# self.obj1 = obj1
- self.abso = "%-4.4s" % str(abso)
-
- def __repr__(self):
- return "Ordinal(%r)" % (self.abso,)
-
- def __str__(self):
- return "%s" % (string.strip(self.abso))
-
- def __aepack__(self):
- return pack(self.abso, 'abso')
-
-def IsOrdinal(x):
- return isinstance(x, Ordinal)
-
-class NOrdinal(Ordinal):
- # The class attribute 'abso' must be set in a subclass
-
- def __init__(self):
- Ordinal.__init__(self, self.abso)
-
-class Logical:
- """An AE logical expression object"""
-
- def __init__(self, logc, term):
- self.logc = "%-4.4s" % str(logc)
- self.term = term
-
- def __repr__(self):
- return "Logical(%r, %r)" % (self.logc, self.term)
-
- def __str__(self):
- if type(self.term) == ListType and len(self.term) == 2:
- return "%s %s %s" % (nice(self.term[0]),
- string.strip(self.logc),
- nice(self.term[1]))
- else:
- return "%s(%s)" % (string.strip(self.logc), nice(self.term))
-
- def __aepack__(self):
- return pack({'logc': mkenum(self.logc), 'term': self.term}, 'logi')
-
-def IsLogical(x):
- return isinstance(x, Logical)
-
-class StyledText:
- """An AE object respresenting text in a certain style"""
-
- def __init__(self, style, text):
- self.style = style
- self.text = text
-
- def __repr__(self):
- return "StyledText(%r, %r)" % (self.style, self.text)
-
- def __str__(self):
- return self.text
-
- def __aepack__(self):
- return pack({'ksty': self.style, 'ktxt': self.text}, 'STXT')
-
-def IsStyledText(x):
- return isinstance(x, StyledText)
-
-class AEText:
- """An AE text object with style, script and language specified"""
-
- def __init__(self, script, style, text):
- self.script = script
- self.style = style
- self.text = text
-
- def __repr__(self):
- return "AEText(%r, %r, %r)" % (self.script, self.style, self.text)
-
- def __str__(self):
- return self.text
-
- def __aepack__(self):
- return pack({keyAEScriptTag: self.script, keyAEStyles: self.style,
- keyAEText: self.text}, typeAEText)
-
-def IsAEText(x):
- return isinstance(x, AEText)
-
-class IntlText:
- """A text object with script and language specified"""
-
- def __init__(self, script, language, text):
- self.script = script
- self.language = language
- self.text = text
-
- def __repr__(self):
- return "IntlText(%r, %r, %r)" % (self.script, self.language, self.text)
-
- def __str__(self):
- return self.text
-
- def __aepack__(self):
- return pack(struct.pack('hh', self.script, self.language)+self.text,
- typeIntlText)
-
-def IsIntlText(x):
- return isinstance(x, IntlText)
-
-class IntlWritingCode:
- """An object representing script and language"""
-
- def __init__(self, script, language):
- self.script = script
- self.language = language
-
- def __repr__(self):
- return "IntlWritingCode(%r, %r)" % (self.script, self.language)
-
- def __str__(self):
- return "script system %d, language %d"%(self.script, self.language)
-
- def __aepack__(self):
- return pack(struct.pack('hh', self.script, self.language),
- typeIntlWritingCode)
-
-def IsIntlWritingCode(x):
- return isinstance(x, IntlWritingCode)
-
-class QDPoint:
- """A point"""
-
- def __init__(self, v, h):
- self.v = v
- self.h = h
-
- def __repr__(self):
- return "QDPoint(%r, %r)" % (self.v, self.h)
-
- def __str__(self):
- return "(%d, %d)"%(self.v, self.h)
-
- def __aepack__(self):
- return pack(struct.pack('hh', self.v, self.h),
- typeQDPoint)
-
-def IsQDPoint(x):
- return isinstance(x, QDPoint)
-
-class QDRectangle:
- """A rectangle"""
-
- def __init__(self, v0, h0, v1, h1):
- self.v0 = v0
- self.h0 = h0
- self.v1 = v1
- self.h1 = h1
-
- def __repr__(self):
- return "QDRectangle(%r, %r, %r, %r)" % (self.v0, self.h0, self.v1, self.h1)
-
- def __str__(self):
- return "(%d, %d)-(%d, %d)"%(self.v0, self.h0, self.v1, self.h1)
-
- def __aepack__(self):
- return pack(struct.pack('hhhh', self.v0, self.h0, self.v1, self.h1),
- typeQDRectangle)
-
-def IsQDRectangle(x):
- return isinstance(x, QDRectangle)
-
-class RGBColor:
- """An RGB color"""
-
- def __init__(self, r, g, b):
- self.r = r
- self.g = g
- self.b = b
-
- def __repr__(self):
- return "RGBColor(%r, %r, %r)" % (self.r, self.g, self.b)
-
- def __str__(self):
- return "0x%x red, 0x%x green, 0x%x blue"% (self.r, self.g, self.b)
-
- def __aepack__(self):
- return pack(struct.pack('hhh', self.r, self.g, self.b),
- typeRGBColor)
-
-def IsRGBColor(x):
- return isinstance(x, RGBColor)
-
-class ObjectSpecifier:
-
- """A class for constructing and manipulation AE object specifiers in python.
-
- An object specifier is actually a record with four fields:
-
- key type description
- --- ---- -----------
-
- 'want' type 4-char class code of thing we want,
- e.g. word, paragraph or property
-
- 'form' enum how we specify which 'want' thing(s) we want,
- e.g. by index, by range, by name, or by property specifier
-
- 'seld' any which thing(s) we want,
- e.g. its index, its name, or its property specifier
-
- 'from' object the object in which it is contained,
- or null, meaning look for it in the application
-
- Note that we don't call this class plain "Object", since that name
- is likely to be used by the application.
- """
-
- def __init__(self, want, form, seld, fr = None):
- self.want = want
- self.form = form
- self.seld = seld
- self.fr = fr
-
- def __repr__(self):
- s = "ObjectSpecifier(%r, %r, %r" % (self.want, self.form, self.seld)
- if self.fr:
- s = s + ", %r)" % (self.fr,)
- else:
- s = s + ")"
- return s
-
- def __aepack__(self):
- return pack({'want': mktype(self.want),
- 'form': mkenum(self.form),
- 'seld': self.seld,
- 'from': self.fr},
- 'obj ')
-
-def IsObjectSpecifier(x):
- return isinstance(x, ObjectSpecifier)
-
-
-# Backwards compatibility, sigh...
-class Property(ObjectSpecifier):
-
- def __init__(self, which, fr = None, want='prop'):
- ObjectSpecifier.__init__(self, want, 'prop', mktype(which), fr)
-
- def __repr__(self):
- if self.fr:
- return "Property(%r, %r)" % (self.seld.type, self.fr)
- else:
- return "Property(%r)" % (self.seld.type,)
-
- def __str__(self):
- if self.fr:
- return "Property %s of %s" % (str(self.seld), str(self.fr))
- else:
- return "Property %s" % str(self.seld)
-
-
-class NProperty(ObjectSpecifier):
- # Subclasses *must* self baseclass attributes:
- # want is the type of this property
- # which is the property name of this property
-
- def __init__(self, fr = None):
- #try:
- # dummy = self.want
- #except:
- # self.want = 'prop'
- self.want = 'prop'
- ObjectSpecifier.__init__(self, self.want, 'prop',
- mktype(self.which), fr)
-
- def __repr__(self):
- rv = "Property(%r" % (self.seld.type,)
- if self.fr:
- rv = rv + ", fr=%r" % (self.fr,)
- if self.want != 'prop':
- rv = rv + ", want=%r" % (self.want,)
- return rv + ")"
-
- def __str__(self):
- if self.fr:
- return "Property %s of %s" % (str(self.seld), str(self.fr))
- else:
- return "Property %s" % str(self.seld)
-
-
-class SelectableItem(ObjectSpecifier):
-
- def __init__(self, want, seld, fr = None):
- t = type(seld)
- if t == StringType:
- form = 'name'
- elif IsRange(seld):
- form = 'rang'
- elif IsComparison(seld) or IsLogical(seld):
- form = 'test'
- elif t == TupleType:
- # Breakout: specify both form and seld in a tuple
- # (if you want ID or rele or somesuch)
- form, seld = seld
- else:
- form = 'indx'
- ObjectSpecifier.__init__(self, want, form, seld, fr)
-
-
-class ComponentItem(SelectableItem):
- # Derived classes *must* set the *class attribute* 'want' to some constant
- # Also, dictionaries _propdict and _elemdict must be set to map property
- # and element names to the correct classes
-
- _propdict = {}
- _elemdict = {}
- def __init__(self, which, fr = None):
- SelectableItem.__init__(self, self.want, which, fr)
-
- def __repr__(self):
- if not self.fr:
- return "%s(%r)" % (self.__class__.__name__, self.seld)
- return "%s(%r, %r)" % (self.__class__.__name__, self.seld, self.fr)
-
- def __str__(self):
- seld = self.seld
- if type(seld) == StringType:
- ss = repr(seld)
- elif IsRange(seld):
- start, stop = seld.start, seld.stop
- if type(start) == InstanceType == type(stop) and \
- start.__class__ == self.__class__ == stop.__class__:
- ss = str(start.seld) + " thru " + str(stop.seld)
- else:
- ss = str(seld)
- else:
- ss = str(seld)
- s = "%s %s" % (self.__class__.__name__, ss)
- if self.fr: s = s + " of %s" % str(self.fr)
- return s
-
- def __getattr__(self, name):
- if name in self._elemdict:
- cls = self._elemdict[name]
- return DelayedComponentItem(cls, self)
- if name in self._propdict:
- cls = self._propdict[name]
- return cls(self)
- raise AttributeError, name
-
-
-class DelayedComponentItem:
- def __init__(self, compclass, fr):
- self.compclass = compclass
- self.fr = fr
-
- def __call__(self, which):
- return self.compclass(which, self.fr)
-
- def __repr__(self):
- return "%s(???, %r)" % (self.__class__.__name__, self.fr)
-
- def __str__(self):
- return "selector for element %s of %s"%(self.__class__.__name__, str(self.fr))
-
-template = """
-class %s(ComponentItem): want = '%s'
-"""
-
-exec template % ("Text", 'text')
-exec template % ("Character", 'cha ')
-exec template % ("Word", 'cwor')
-exec template % ("Line", 'clin')
-exec template % ("paragraph", 'cpar')
-exec template % ("Window", 'cwin')
-exec template % ("Document", 'docu')
-exec template % ("File", 'file')
-exec template % ("InsertionPoint", 'cins')
diff --git a/Lib/plat-mac/applesingle.py b/Lib/plat-mac/applesingle.py
deleted file mode 100644
index 13962f60982..00000000000
--- a/Lib/plat-mac/applesingle.py
+++ /dev/null
@@ -1,146 +0,0 @@
-r"""Routines to decode AppleSingle files
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the applesingle module is removed.", stacklevel=2)
-
-import struct
-import sys
-try:
- import MacOS
- import Carbon.File
-except:
- class MacOS:
- def openrf(path, mode):
- return open(path + '.rsrc', mode)
- openrf = classmethod(openrf)
- class Carbon:
- class File:
- class FSSpec:
- pass
- class FSRef:
- pass
- class Alias:
- pass
-
-# all of the errors in this module are really errors in the input
-# so I think it should test positive against ValueError.
-class Error(ValueError):
- pass
-
-# File header format: magic, version, unused, number of entries
-AS_HEADER_FORMAT=">LL16sh"
-AS_HEADER_LENGTH=26
-# The flag words for AppleSingle
-AS_MAGIC=0x00051600
-AS_VERSION=0x00020000
-
-# Entry header format: id, offset, length
-AS_ENTRY_FORMAT=">lll"
-AS_ENTRY_LENGTH=12
-
-# The id values
-AS_DATAFORK=1
-AS_RESOURCEFORK=2
-AS_IGNORE=(3,4,5,6,8,9,10,11,12,13,14,15)
-
-class AppleSingle(object):
- datafork = None
- resourcefork = None
-
- def __init__(self, fileobj, verbose=False):
- header = fileobj.read(AS_HEADER_LENGTH)
- try:
- magic, version, ig, nentry = struct.unpack(AS_HEADER_FORMAT, header)
- except ValueError, arg:
- raise Error, "Unpack header error: %s" % (arg,)
- if verbose:
- print 'Magic: 0x%8.8x' % (magic,)
- print 'Version: 0x%8.8x' % (version,)
- print 'Entries: %d' % (nentry,)
- if magic != AS_MAGIC:
- raise Error, "Unknown AppleSingle magic number 0x%8.8x" % (magic,)
- if version != AS_VERSION:
- raise Error, "Unknown AppleSingle version number 0x%8.8x" % (version,)
- if nentry <= 0:
- raise Error, "AppleSingle file contains no forks"
- headers = [fileobj.read(AS_ENTRY_LENGTH) for i in xrange(nentry)]
- self.forks = []
- for hdr in headers:
- try:
- restype, offset, length = struct.unpack(AS_ENTRY_FORMAT, hdr)
- except ValueError, arg:
- raise Error, "Unpack entry error: %s" % (arg,)
- if verbose:
- print "Fork %d, offset %d, length %d" % (restype, offset, length)
- fileobj.seek(offset)
- data = fileobj.read(length)
- if len(data) != length:
- raise Error, "Short read: expected %d bytes got %d" % (length, len(data))
- self.forks.append((restype, data))
- if restype == AS_DATAFORK:
- self.datafork = data
- elif restype == AS_RESOURCEFORK:
- self.resourcefork = data
-
- def tofile(self, path, resonly=False):
- outfile = open(path, 'wb')
- data = False
- if resonly:
- if self.resourcefork is None:
- raise Error, "No resource fork found"
- fp = open(path, 'wb')
- fp.write(self.resourcefork)
- fp.close()
- elif (self.resourcefork is None and self.datafork is None):
- raise Error, "No useful forks found"
- else:
- if self.datafork is not None:
- fp = open(path, 'wb')
- fp.write(self.datafork)
- fp.close()
- if self.resourcefork is not None:
- fp = MacOS.openrf(path, '*wb')
- fp.write(self.resourcefork)
- fp.close()
-
-def decode(infile, outpath, resonly=False, verbose=False):
- """decode(infile, outpath [, resonly=False, verbose=False])
-
- Creates a decoded file from an AppleSingle encoded file.
- If resonly is True, then it will create a regular file at
- outpath containing only the resource fork from infile.
- Otherwise it will create an AppleDouble file at outpath
- with the data and resource forks from infile. On platforms
- without the MacOS module, it will create inpath and inpath+'.rsrc'
- with the data and resource forks respectively.
-
- """
- if not hasattr(infile, 'read'):
- if isinstance(infile, Carbon.File.Alias):
- infile = infile.ResolveAlias()[0]
-
- if hasattr(Carbon.File, "FSSpec"):
- if isinstance(infile, (Carbon.File.FSSpec, Carbon.File.FSRef)):
- infile = infile.as_pathname()
- else:
- if isinstance(infile, Carbon.File.FSRef):
- infile = infile.as_pathname()
- infile = open(infile, 'rb')
-
- asfile = AppleSingle(infile, verbose=verbose)
- asfile.tofile(outpath, resonly=resonly)
-
-def _test():
- if len(sys.argv) < 3 or sys.argv[1] == '-r' and len(sys.argv) != 4:
- print 'Usage: applesingle.py [-r] applesinglefile decodedfile'
- sys.exit(1)
- if sys.argv[1] == '-r':
- resonly = True
- del sys.argv[1]
- else:
- resonly = False
- decode(sys.argv[1], sys.argv[2], resonly=resonly)
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/plat-mac/appletrawmain.py b/Lib/plat-mac/appletrawmain.py
deleted file mode 100644
index c863486aa95..00000000000
--- a/Lib/plat-mac/appletrawmain.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Emulate sys.argv and run __main__.py or __main__.pyc in an environment that
-# is as close to "normal" as possible.
-#
-# This script is put into __rawmain__.pyc for applets that need argv
-# emulation, by BuildApplet and friends.
-#
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the appletrawmain module is removed.", stacklevel=2)
-
-import argvemulator
-import os
-import sys
-import marshal
-
-#
-# Make sure we have an argv[0], and make _dir point to the Resources
-# directory.
-#
-if not sys.argv or sys.argv[0][:1] == '-':
- # Insert our (guessed) name.
- _dir = os.path.split(sys.executable)[0] # removes "python"
- _dir = os.path.split(_dir)[0] # Removes "MacOS"
- _dir = os.path.join(_dir, 'Resources')
- sys.argv.insert(0, '__rawmain__')
-else:
- _dir = os.path.split(sys.argv[0])[0]
-#
-# Add the Resources directory to the path. This is where files installed
-# by BuildApplet.py with the --extra option show up, and if those files are
-# modules this sys.path modification is necessary to be able to import them.
-#
-sys.path.insert(0, _dir)
-#
-# Create sys.argv
-#
-argvemulator.ArgvCollector().mainloop()
-#
-# Find the real main program to run
-#
-__file__ = os.path.join(_dir, '__main__.py')
-if os.path.exists(__file__):
- #
- # Setup something resembling a normal environment and go.
- #
- sys.argv[0] = __file__
- del argvemulator, os, sys, _dir
- execfile(__file__)
-else:
- __file__ = os.path.join(_dir, '__main__.pyc')
- if os.path.exists(__file__):
- #
- # If we have only a .pyc file we read the code object from that
- #
- sys.argv[0] = __file__
- _fp = open(__file__, 'rb')
- _fp.read(8)
- __code__ = marshal.load(_fp)
- #
- # Again, we create an almost-normal environment (only __code__ is
- # funny) and go.
- #
- del argvemulator, os, sys, marshal, _dir, _fp
- exec __code__
- else:
- sys.stderr.write("%s: neither __main__.py nor __main__.pyc found\n"%sys.argv[0])
- sys.exit(1)
diff --git a/Lib/plat-mac/appletrunner.py b/Lib/plat-mac/appletrunner.py
deleted file mode 100755
index cdfd4174598..00000000000
--- a/Lib/plat-mac/appletrunner.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env python
-# This file is meant as an executable script for running applets.
-# BuildApplet will use it as the main executable in the .app bundle if
-# we are not running in a framework build.
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the appletrunner module is removed.", stacklevel=2)
-
-import os
-import sys
-for name in ["__rawmain__.py", "__rawmain__.pyc", "__main__.py", "__main__.pyc"]:
- realmain = os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])),
- "Resources", name)
- if os.path.exists(realmain):
- break
-else:
- sys.stderr.write("%s: cannot find applet main program\n" % sys.argv[0])
- sys.exit(1)
-sys.argv.insert(1, realmain)
-os.execve(sys.executable, sys.argv, os.environ)
diff --git a/Lib/plat-mac/argvemulator.py b/Lib/plat-mac/argvemulator.py
deleted file mode 100644
index 3dfc9f83189..00000000000
--- a/Lib/plat-mac/argvemulator.py
+++ /dev/null
@@ -1,92 +0,0 @@
-"""argvemulator - create sys.argv from OSA events. Used by applets that
-want unix-style arguments.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the argvemulator module is removed.", stacklevel=2)
-
-import sys
-import traceback
-from Carbon import AE
-from Carbon.AppleEvents import *
-from Carbon import Evt
-from Carbon import File
-from Carbon.Events import *
-import aetools
-
-class ArgvCollector:
-
- """A minimal FrameWork.Application-like class"""
-
- def __init__(self):
- self.quitting = 0
- # Remove the funny -psn_xxx_xxx argument
- if len(sys.argv) > 1 and sys.argv[1][:4] == '-psn':
- del sys.argv[1]
-
- AE.AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, self.__runapp)
- AE.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, self.__openfiles)
-
- def close(self):
- AE.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication)
- AE.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments)
-
- def mainloop(self, mask = highLevelEventMask, timeout = 1*60):
- # Note: this is not the right way to run an event loop in OSX or even
- # "recent" versions of MacOS9. This is however code that has proven
- # itself.
- stoptime = Evt.TickCount() + timeout
- while not self.quitting and Evt.TickCount() < stoptime:
- self._dooneevent(mask, timeout)
-
- if not self.quitting:
- print "argvemulator: timeout waiting for arguments"
-
- self.close()
-
- def _dooneevent(self, mask = highLevelEventMask, timeout = 1*60):
- got, event = Evt.WaitNextEvent(mask, timeout)
- if got:
- self._lowlevelhandler(event)
-
- def _lowlevelhandler(self, event):
- what, message, when, where, modifiers = event
- h, v = where
- if what == kHighLevelEvent:
- try:
- AE.AEProcessAppleEvent(event)
- except AE.Error, err:
- msg = "High Level Event: %r %r" % (hex(message), hex(h | (v<<16)))
- print 'AE error: ', err
- print 'in', msg
- traceback.print_exc()
- return
- else:
- print "Unhandled event:", event
-
-
- def _quit(self):
- self.quitting = 1
-
- def __runapp(self, requestevent, replyevent):
- self._quit()
-
- def __openfiles(self, requestevent, replyevent):
- try:
- listdesc = requestevent.AEGetParamDesc(keyDirectObject, typeAEList)
- for i in range(listdesc.AECountItems()):
- aliasdesc = listdesc.AEGetNthDesc(i+1, typeAlias)[1]
- alias = File.Alias(rawdata=aliasdesc.data)
- fsref = alias.FSResolveAlias(None)[0]
- pathname = fsref.as_pathname()
- sys.argv.append(pathname)
- except Exception, e:
- print "argvemulator.py warning: can't unpack an open document event"
- import traceback
- traceback.print_exc()
-
- self._quit()
-
-if __name__ == '__main__':
- ArgvCollector().mainloop()
- print "sys.argv=", sys.argv
diff --git a/Lib/plat-mac/bgenlocations.py b/Lib/plat-mac/bgenlocations.py
deleted file mode 100644
index 38f41592f89..00000000000
--- a/Lib/plat-mac/bgenlocations.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Local customizations for generating the Carbon interface modules.
-# Edit this file to reflect where things should be on your system.
-# Note that pathnames are unix-style for OSX MachoPython/unix-Python,
-# but mac-style for MacPython, whether running on OS9 or OSX.
-#
-
-import os
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the bgenlocations module is removed.", stacklevel=2)
-
-Error = "bgenlocations.Error"
-#
-# Where bgen is. For unix-Python bgen isn't installed, so you have to refer to
-# the source tree here.
-BGENDIR="/Users/jack/src/python/Tools/bgen/bgen"
-
-#
-# Where to find the Universal Header include files. If you have CodeWarrior
-# installed you can use the Universal Headers from there, otherwise you can
-# download them from the Apple website. Bgen can handle both unix- and mac-style
-# end of lines, so don't worry about that.
-#
-INCLUDEDIR="/Users/jack/src/Universal/Interfaces/CIncludes"
-
-#
-# Where to put the python definitions files. Note that, on unix-Python,
-# if you want to commit your changes to the CVS repository this should refer to
-# your source directory, not your installed directory.
-#
-TOOLBOXDIR="/Users/jack/src/python/Lib/plat-mac/Carbon"
-
-# Creator for C files:
-CREATOR="CWIE"
-
-# The previous definitions can be overriden by creating a module
-# bgenlocationscustomize.py and putting it in site-packages (or anywere else
-# on sys.path, actually)
-try:
- from bgenlocationscustomize import *
-except ImportError:
- pass
-
-if not os.path.exists(BGENDIR):
- raise Error, "Please fix bgenlocations.py, BGENDIR does not exist: %s" % BGENDIR
-if not os.path.exists(INCLUDEDIR):
- raise Error, "Please fix bgenlocations.py, INCLUDEDIR does not exist: %s" % INCLUDEDIR
-if not os.path.exists(TOOLBOXDIR):
- raise Error, "Please fix bgenlocations.py, TOOLBOXDIR does not exist: %s" % TOOLBOXDIR
-
-# Sigh, due to the way these are used make sure they end with : or /.
-if BGENDIR[-1] != os.sep:
- BGENDIR = BGENDIR + os.sep
-if INCLUDEDIR[-1] != os.sep:
- INCLUDEDIR = INCLUDEDIR + os.sep
-if TOOLBOXDIR[-1] != os.sep:
- TOOLBOXDIR = TOOLBOXDIR + os.sep
diff --git a/Lib/plat-mac/buildtools.py b/Lib/plat-mac/buildtools.py
deleted file mode 100644
index bbb37abeda5..00000000000
--- a/Lib/plat-mac/buildtools.py
+++ /dev/null
@@ -1,435 +0,0 @@
-"""tools for BuildApplet and BuildApplication"""
-
-import warnings
-warnings.warnpy3k("the buildtools module is deprecated and is removed in 3.0",
- stacklevel=2)
-
-import sys
-import os
-import string
-import imp
-import marshal
-from Carbon import Res
-import Carbon.Files
-import Carbon.File
-import MacOS
-import macostools
-import macresource
-try:
- import EasyDialogs
-except ImportError:
- EasyDialogs = None
-import shutil
-
-
-BuildError = "BuildError"
-
-# .pyc file (and 'PYC ' resource magic number)
-MAGIC = imp.get_magic()
-
-# Template file (searched on sys.path)
-TEMPLATE = "PythonInterpreter"
-
-# Specification of our resource
-RESTYPE = 'PYC '
-RESNAME = '__main__'
-
-# A resource with this name sets the "owner" (creator) of the destination
-# It should also have ID=0. Either of these alone is not enough.
-OWNERNAME = "owner resource"
-
-# Default applet creator code
-DEFAULT_APPLET_CREATOR="Pyta"
-
-# OpenResFile mode parameters
-READ = 1
-WRITE = 2
-
-# Parameter for FSOpenResourceFile
-RESOURCE_FORK_NAME=Carbon.File.FSGetResourceForkName()
-
-def findtemplate(template=None):
- """Locate the applet template along sys.path"""
- if MacOS.runtimemodel == 'macho':
- return None
- if not template:
- template=TEMPLATE
- for p in sys.path:
- file = os.path.join(p, template)
- try:
- file, d1, d2 = Carbon.File.FSResolveAliasFile(file, 1)
- break
- except (Carbon.File.Error, ValueError):
- continue
- else:
- raise BuildError, "Template %r not found on sys.path" % (template,)
- file = file.as_pathname()
- return file
-
-def process(template, filename, destname, copy_codefragment=0,
- rsrcname=None, others=[], raw=0, progress="default", destroot=""):
-
- if progress == "default":
- if EasyDialogs is None:
- print "Compiling %s"%(os.path.split(filename)[1],)
- process = None
- else:
- progress = EasyDialogs.ProgressBar("Processing %s..."%os.path.split(filename)[1], 120)
- progress.label("Compiling...")
- progress.inc(0)
- # check for the script name being longer than 32 chars. This may trigger a bug
- # on OSX that can destroy your sourcefile.
- if '#' in os.path.split(filename)[1]:
- raise BuildError, "BuildApplet could destroy your sourcefile on OSX, please rename: %s" % filename
- # Read the source and compile it
- # (there's no point overwriting the destination if it has a syntax error)
-
- fp = open(filename, 'rU')
- text = fp.read()
- fp.close()
- try:
- code = compile(text + '\n', filename, "exec")
- except SyntaxError, arg:
- raise BuildError, "Syntax error in script %s: %s" % (filename, arg)
- except EOFError:
- raise BuildError, "End-of-file in script %s" % (filename,)
-
- # Set the destination file name. Note that basename
- # does contain the whole filepath, only a .py is stripped.
-
- if string.lower(filename[-3:]) == ".py":
- basename = filename[:-3]
- if MacOS.runtimemodel != 'macho' and not destname:
- destname = basename
- else:
- basename = filename
-
- if not destname:
- if MacOS.runtimemodel == 'macho':
- destname = basename + '.app'
- else:
- destname = basename + '.applet'
- if not rsrcname:
- rsrcname = basename + '.rsrc'
-
- # Try removing the output file. This fails in MachO, but it should
- # do any harm.
- try:
- os.remove(destname)
- except os.error:
- pass
- process_common(template, progress, code, rsrcname, destname, 0,
- copy_codefragment, raw, others, filename, destroot)
-
-
-def update(template, filename, output):
- if MacOS.runtimemodel == 'macho':
- raise BuildError, "No updating yet for MachO applets"
- if progress:
- if EasyDialogs is None:
- print "Updating %s"%(os.path.split(filename)[1],)
- progress = None
- else:
- progress = EasyDialogs.ProgressBar("Updating %s..."%os.path.split(filename)[1], 120)
- else:
- progress = None
- if not output:
- output = filename + ' (updated)'
-
- # Try removing the output file
- try:
- os.remove(output)
- except os.error:
- pass
- process_common(template, progress, None, filename, output, 1, 1)
-
-
-def process_common(template, progress, code, rsrcname, destname, is_update,
- copy_codefragment, raw=0, others=[], filename=None, destroot=""):
- if MacOS.runtimemodel == 'macho':
- return process_common_macho(template, progress, code, rsrcname, destname,
- is_update, raw, others, filename, destroot)
- if others:
- raise BuildError, "Extra files only allowed for MachoPython applets"
- # Create FSSpecs for the various files
- template_fsr, d1, d2 = Carbon.File.FSResolveAliasFile(template, 1)
- template = template_fsr.as_pathname()
-
- # Copy data (not resources, yet) from the template
- if progress:
- progress.label("Copy data fork...")
- progress.set(10)
-
- if copy_codefragment:
- tmpl = open(template, "rb")
- dest = open(destname, "wb")
- data = tmpl.read()
- if data:
- dest.write(data)
- dest.close()
- tmpl.close()
- del dest
- del tmpl
-
- # Open the output resource fork
-
- if progress:
- progress.label("Copy resources...")
- progress.set(20)
- try:
- output = Res.FSOpenResourceFile(destname, RESOURCE_FORK_NAME, WRITE)
- except MacOS.Error:
- destdir, destfile = os.path.split(destname)
- Res.FSCreateResourceFile(destdir, unicode(destfile), RESOURCE_FORK_NAME)
- output = Res.FSOpenResourceFile(destname, RESOURCE_FORK_NAME, WRITE)
-
- # Copy the resources from the target specific resource template, if any
- typesfound, ownertype = [], None
- try:
- input = Res.FSOpenResourceFile(rsrcname, RESOURCE_FORK_NAME, READ)
- except (MacOS.Error, ValueError):
- pass
- if progress:
- progress.inc(50)
- else:
- if is_update:
- skip_oldfile = ['cfrg']
- else:
- skip_oldfile = []
- typesfound, ownertype = copyres(input, output, skip_oldfile, 0, progress)
- Res.CloseResFile(input)
-
- # Check which resource-types we should not copy from the template
- skiptypes = []
- if 'vers' in typesfound: skiptypes.append('vers')
- if 'SIZE' in typesfound: skiptypes.append('SIZE')
- if 'BNDL' in typesfound: skiptypes = skiptypes + ['BNDL', 'FREF', 'icl4',
- 'icl8', 'ics4', 'ics8', 'ICN#', 'ics#']
- if not copy_codefragment:
- skiptypes.append('cfrg')
-## skipowner = (ownertype != None)
-
- # Copy the resources from the template
-
- input = Res.FSOpenResourceFile(template, RESOURCE_FORK_NAME, READ)
- dummy, tmplowner = copyres(input, output, skiptypes, 1, progress)
-
- Res.CloseResFile(input)
-## if ownertype is None:
-## raise BuildError, "No owner resource found in either resource file or template"
- # Make sure we're manipulating the output resource file now
-
- Res.UseResFile(output)
-
- if ownertype is None:
- # No owner resource in the template. We have skipped the
- # Python owner resource, so we have to add our own. The relevant
- # bundle stuff is already included in the interpret/applet template.
- newres = Res.Resource('\0')
- newres.AddResource(DEFAULT_APPLET_CREATOR, 0, "Owner resource")
- ownertype = DEFAULT_APPLET_CREATOR
-
- if code:
- # Delete any existing 'PYC ' resource named __main__
-
- try:
- res = Res.Get1NamedResource(RESTYPE, RESNAME)
- res.RemoveResource()
- except Res.Error:
- pass
-
- # Create the raw data for the resource from the code object
- if progress:
- progress.label("Write PYC resource...")
- progress.set(120)
-
- data = marshal.dumps(code)
- del code
- data = (MAGIC + '\0\0\0\0') + data
-
- # Create the resource and write it
-
- id = 0
- while id < 128:
- id = Res.Unique1ID(RESTYPE)
- res = Res.Resource(data)
- res.AddResource(RESTYPE, id, RESNAME)
- attrs = res.GetResAttrs()
- attrs = attrs | 0x04 # set preload
- res.SetResAttrs(attrs)
- res.WriteResource()
- res.ReleaseResource()
-
- # Close the output file
-
- Res.CloseResFile(output)
-
- # Now set the creator, type and bundle bit of the destination.
- # Done with FSSpec's, FSRef FInfo isn't good enough yet (2.3a1+)
- dest_fss = Carbon.File.FSSpec(destname)
- dest_finfo = dest_fss.FSpGetFInfo()
- dest_finfo.Creator = ownertype
- dest_finfo.Type = 'APPL'
- dest_finfo.Flags = dest_finfo.Flags | Carbon.Files.kHasBundle | Carbon.Files.kIsShared
- dest_finfo.Flags = dest_finfo.Flags & ~Carbon.Files.kHasBeenInited
- dest_fss.FSpSetFInfo(dest_finfo)
-
- macostools.touched(destname)
- if progress:
- progress.label("Done.")
- progress.inc(0)
-
-def process_common_macho(template, progress, code, rsrcname, destname, is_update,
- raw=0, others=[], filename=None, destroot=""):
- # Check that we have a filename
- if filename is None:
- raise BuildError, "Need source filename on MacOSX"
- # First make sure the name ends in ".app"
- if destname[-4:] != '.app':
- destname = destname + '.app'
- # Now deduce the short name
- destdir, shortname = os.path.split(destname)
- if shortname[-4:] == '.app':
- # Strip the .app suffix
- shortname = shortname[:-4]
- # And deduce the .plist and .icns names
- plistname = None
- icnsname = None
- if rsrcname and rsrcname[-5:] == '.rsrc':
- tmp = rsrcname[:-5]
- plistname = tmp + '.plist'
- if os.path.exists(plistname):
- icnsname = tmp + '.icns'
- if not os.path.exists(icnsname):
- icnsname = None
- else:
- plistname = None
- if not icnsname:
- dft_icnsname = os.path.join(sys.prefix, 'Resources/Python.app/Contents/Resources/PythonApplet.icns')
- if os.path.exists(dft_icnsname):
- icnsname = dft_icnsname
- if not os.path.exists(rsrcname):
- rsrcname = None
- if progress:
- progress.label('Creating bundle...')
- import bundlebuilder
- builder = bundlebuilder.AppBuilder(verbosity=0)
- builder.mainprogram = filename
- builder.builddir = destdir
- builder.name = shortname
- builder.destroot = destroot
- if rsrcname:
- realrsrcname = macresource.resource_pathname(rsrcname)
- builder.files.append((realrsrcname,
- os.path.join('Contents/Resources', os.path.basename(rsrcname))))
- for o in others:
- if type(o) == str:
- builder.resources.append(o)
- else:
- builder.files.append(o)
- if plistname:
- import plistlib
- builder.plist = plistlib.Plist.fromFile(plistname)
- if icnsname:
- builder.iconfile = icnsname
- if not raw:
- builder.argv_emulation = 1
- builder.setup()
- builder.build()
- if progress:
- progress.label('Done.')
- progress.inc(0)
-
-## macostools.touched(dest_fss)
-
-# Copy resources between two resource file descriptors.
-# skip a resource named '__main__' or (if skipowner is set) with ID zero.
-# Also skip resources with a type listed in skiptypes.
-#
-def copyres(input, output, skiptypes, skipowner, progress=None):
- ctor = None
- alltypes = []
- Res.UseResFile(input)
- ntypes = Res.Count1Types()
- progress_type_inc = 50/ntypes
- for itype in range(1, 1+ntypes):
- type = Res.Get1IndType(itype)
- if type in skiptypes:
- continue
- alltypes.append(type)
- nresources = Res.Count1Resources(type)
- progress_cur_inc = progress_type_inc/nresources
- for ires in range(1, 1+nresources):
- res = Res.Get1IndResource(type, ires)
- id, type, name = res.GetResInfo()
- lcname = string.lower(name)
-
- if lcname == OWNERNAME and id == 0:
- if skipowner:
- continue # Skip this one
- else:
- ctor = type
- size = res.size
- attrs = res.GetResAttrs()
- if progress:
- progress.label("Copy %s %d %s"%(type, id, name))
- progress.inc(progress_cur_inc)
- res.LoadResource()
- res.DetachResource()
- Res.UseResFile(output)
- try:
- res2 = Res.Get1Resource(type, id)
- except MacOS.Error:
- res2 = None
- if res2:
- if progress:
- progress.label("Overwrite %s %d %s"%(type, id, name))
- progress.inc(0)
- res2.RemoveResource()
- res.AddResource(type, id, name)
- res.WriteResource()
- attrs = attrs | res.GetResAttrs()
- res.SetResAttrs(attrs)
- Res.UseResFile(input)
- return alltypes, ctor
-
-def copyapptree(srctree, dsttree, exceptlist=[], progress=None):
- names = []
- if os.path.exists(dsttree):
- shutil.rmtree(dsttree)
- os.mkdir(dsttree)
- todo = os.listdir(srctree)
- while todo:
- this, todo = todo[0], todo[1:]
- if this in exceptlist:
- continue
- thispath = os.path.join(srctree, this)
- if os.path.isdir(thispath):
- thiscontent = os.listdir(thispath)
- for t in thiscontent:
- todo.append(os.path.join(this, t))
- names.append(this)
- for this in names:
- srcpath = os.path.join(srctree, this)
- dstpath = os.path.join(dsttree, this)
- if os.path.isdir(srcpath):
- os.mkdir(dstpath)
- elif os.path.islink(srcpath):
- endpoint = os.readlink(srcpath)
- os.symlink(endpoint, dstpath)
- else:
- if progress:
- progress.label('Copy '+this)
- progress.inc(0)
- shutil.copy2(srcpath, dstpath)
-
-def writepycfile(codeobject, cfile):
- import marshal
- fc = open(cfile, 'wb')
- fc.write('\0\0\0\0') # MAGIC placeholder, written later
- fc.write('\0\0\0\0') # Timestap placeholder, not needed
- marshal.dump(codeobject, fc)
- fc.flush()
- fc.seek(0, 0)
- fc.write(MAGIC)
- fc.close()
diff --git a/Lib/plat-mac/bundlebuilder.py b/Lib/plat-mac/bundlebuilder.py
deleted file mode 100755
index 433991394de..00000000000
--- a/Lib/plat-mac/bundlebuilder.py
+++ /dev/null
@@ -1,949 +0,0 @@
-#! /usr/bin/env python
-
-"""\
-bundlebuilder.py -- Tools to assemble MacOS X (application) bundles.
-
-This module contains two classes to build so called "bundles" for
-MacOS X. BundleBuilder is a general tool, AppBuilder is a subclass
-specialized in building application bundles.
-
-[Bundle|App]Builder objects are instantiated with a bunch of keyword
-arguments, and have a build() method that will do all the work. See
-the class doc strings for a description of the constructor arguments.
-
-The module contains a main program that can be used in two ways:
-
- % python bundlebuilder.py [options] build
- % python buildapp.py [options] build
-
-Where "buildapp.py" is a user-supplied setup.py-like script following
-this model:
-
- from bundlebuilder import buildapp
- buildapp(<lots-of-keyword-args>)
-
-"""
-
-
-__all__ = ["BundleBuilder", "BundleBuilderError", "AppBuilder", "buildapp"]
-
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the bundlebuilder module is removed.", stacklevel=2)
-
-import sys
-import os, errno, shutil
-import imp, marshal
-import re
-from copy import deepcopy
-import getopt
-from plistlib import Plist
-from types import FunctionType as function
-
-class BundleBuilderError(Exception): pass
-
-
-class Defaults:
-
- """Class attributes that don't start with an underscore and are
- not functions or classmethods are (deep)copied to self.__dict__.
- This allows for mutable default values.
- """
-
- def __init__(self, **kwargs):
- defaults = self._getDefaults()
- defaults.update(kwargs)
- self.__dict__.update(defaults)
-
- def _getDefaults(cls):
- defaults = {}
- for base in cls.__bases__:
- if hasattr(base, "_getDefaults"):
- defaults.update(base._getDefaults())
- for name, value in cls.__dict__.items():
- if name[0] != "_" and not isinstance(value,
- (function, classmethod)):
- defaults[name] = deepcopy(value)
- return defaults
- _getDefaults = classmethod(_getDefaults)
-
-
-class BundleBuilder(Defaults):
-
- """BundleBuilder is a barebones class for assembling bundles. It
- knows nothing about executables or icons, it only copies files
- and creates the PkgInfo and Info.plist files.
- """
-
- # (Note that Defaults.__init__ (deep)copies these values to
- # instance variables. Mutable defaults are therefore safe.)
-
- # Name of the bundle, with or without extension.
- name = None
-
- # The property list ("plist")
- plist = Plist(CFBundleDevelopmentRegion = "English",
- CFBundleInfoDictionaryVersion = "6.0")
-
- # The type of the bundle.
- type = "BNDL"
- # The creator code of the bundle.
- creator = None
-
- # the CFBundleIdentifier (this is used for the preferences file name)
- bundle_id = None
-
- # List of files that have to be copied to <bundle>/Contents/Resources.
- resources = []
-
- # List of (src, dest) tuples; dest should be a path relative to the bundle
- # (eg. "Contents/Resources/MyStuff/SomeFile.ext).
- files = []
-
- # List of shared libraries (dylibs, Frameworks) to bundle with the app
- # will be placed in Contents/Frameworks
- libs = []
-
- # Directory where the bundle will be assembled.
- builddir = "build"
-
- # Make symlinks instead copying files. This is handy during debugging, but
- # makes the bundle non-distributable.
- symlink = 0
-
- # Verbosity level.
- verbosity = 1
-
- # Destination root directory
- destroot = ""
-
- def setup(self):
- # XXX rethink self.name munging, this is brittle.
- self.name, ext = os.path.splitext(self.name)
- if not ext:
- ext = ".bundle"
- bundleextension = ext
- # misc (derived) attributes
- self.bundlepath = pathjoin(self.builddir, self.name + bundleextension)
-
- plist = self.plist
- plist.CFBundleName = self.name
- plist.CFBundlePackageType = self.type
- if self.creator is None:
- if hasattr(plist, "CFBundleSignature"):
- self.creator = plist.CFBundleSignature
- else:
- self.creator = "????"
- plist.CFBundleSignature = self.creator
- if self.bundle_id:
- plist.CFBundleIdentifier = self.bundle_id
- elif not hasattr(plist, "CFBundleIdentifier"):
- plist.CFBundleIdentifier = self.name
-
- def build(self):
- """Build the bundle."""
- builddir = self.builddir
- if builddir and not os.path.exists(builddir):
- os.mkdir(builddir)
- self.message("Building %s" % repr(self.bundlepath), 1)
- if os.path.exists(self.bundlepath):
- shutil.rmtree(self.bundlepath)
- if os.path.exists(self.bundlepath + '~'):
- shutil.rmtree(self.bundlepath + '~')
- bp = self.bundlepath
-
- # Create the app bundle in a temporary location and then
- # rename the completed bundle. This way the Finder will
- # never see an incomplete bundle (where it might pick up
- # and cache the wrong meta data)
- self.bundlepath = bp + '~'
- try:
- os.mkdir(self.bundlepath)
- self.preProcess()
- self._copyFiles()
- self._addMetaFiles()
- self.postProcess()
- os.rename(self.bundlepath, bp)
- finally:
- self.bundlepath = bp
- self.message("Done.", 1)
-
- def preProcess(self):
- """Hook for subclasses."""
- pass
- def postProcess(self):
- """Hook for subclasses."""
- pass
-
- def _addMetaFiles(self):
- contents = pathjoin(self.bundlepath, "Contents")
- makedirs(contents)
- #
- # Write Contents/PkgInfo
- assert len(self.type) == len(self.creator) == 4, \
- "type and creator must be 4-byte strings."
- pkginfo = pathjoin(contents, "PkgInfo")
- f = open(pkginfo, "wb")
- f.write(self.type + self.creator)
- f.close()
- #
- # Write Contents/Info.plist
- infoplist = pathjoin(contents, "Info.plist")
- self.plist.write(infoplist)
-
- def _copyFiles(self):
- files = self.files[:]
- for path in self.resources:
- files.append((path, pathjoin("Contents", "Resources",
- os.path.basename(path))))
- for path in self.libs:
- files.append((path, pathjoin("Contents", "Frameworks",
- os.path.basename(path))))
- if self.symlink:
- self.message("Making symbolic links", 1)
- msg = "Making symlink from"
- else:
- self.message("Copying files", 1)
- msg = "Copying"
- files.sort()
- for src, dst in files:
- if os.path.isdir(src):
- self.message("%s %s/ to %s/" % (msg, src, dst), 2)
- else:
- self.message("%s %s to %s" % (msg, src, dst), 2)
- dst = pathjoin(self.bundlepath, dst)
- if self.symlink:
- symlink(src, dst, mkdirs=1)
- else:
- copy(src, dst, mkdirs=1)
-
- def message(self, msg, level=0):
- if level <= self.verbosity:
- indent = ""
- if level > 1:
- indent = (level - 1) * " "
- sys.stderr.write(indent + msg + "\n")
-
- def report(self):
- # XXX something decent
- pass
-
-
-if __debug__:
- PYC_EXT = ".pyc"
-else:
- PYC_EXT = ".pyo"
-
-MAGIC = imp.get_magic()
-USE_ZIPIMPORT = "zipimport" in sys.builtin_module_names
-
-# For standalone apps, we have our own minimal site.py. We don't need
-# all the cruft of the real site.py.
-SITE_PY = """\
-import sys
-if not %(semi_standalone)s:
- del sys.path[1:] # sys.path[0] is Contents/Resources/
-"""
-
-ZIP_ARCHIVE = "Modules.zip"
-SITE_PY_ZIP = SITE_PY + ("sys.path.append(sys.path[0] + '/%s')\n" % ZIP_ARCHIVE)
-
-def getPycData(fullname, code, ispkg):
- if ispkg:
- fullname += ".__init__"
- path = fullname.replace(".", os.sep) + PYC_EXT
- return path, MAGIC + '\0\0\0\0' + marshal.dumps(code)
-
-#
-# Extension modules can't be in the modules zip archive, so a placeholder
-# is added instead, that loads the extension from a specified location.
-#
-EXT_LOADER = """\
-def __load():
- import imp, sys, os
- for p in sys.path:
- path = os.path.join(p, "%(filename)s")
- if os.path.exists(path):
- break
- else:
- assert 0, "file not found: %(filename)s"
- mod = imp.load_dynamic("%(name)s", path)
-
-__load()
-del __load
-"""
-
-MAYMISS_MODULES = ['os2', 'nt', 'ntpath', 'dos', 'dospath',
- 'win32api', 'ce', '_winreg', 'nturl2path', 'sitecustomize',
- 'org.python.core', 'riscos', 'riscosenviron', 'riscospath'
-]
-
-STRIP_EXEC = "/usr/bin/strip"
-
-#
-# We're using a stock interpreter to run the app, yet we need
-# a way to pass the Python main program to the interpreter. The
-# bootstrapping script fires up the interpreter with the right
-# arguments. os.execve() is used as OSX doesn't like us to
-# start a real new process. Also, the executable name must match
-# the CFBundleExecutable value in the Info.plist, so we lie
-# deliberately with argv[0]. The actual Python executable is
-# passed in an environment variable so we can "repair"
-# sys.executable later.
-#
-BOOTSTRAP_SCRIPT = """\
-#!%(hashbang)s
-
-import sys, os
-execdir = os.path.dirname(sys.argv[0])
-executable = os.path.join(execdir, "%(executable)s")
-resdir = os.path.join(os.path.dirname(execdir), "Resources")
-libdir = os.path.join(os.path.dirname(execdir), "Frameworks")
-mainprogram = os.path.join(resdir, "%(mainprogram)s")
-
-if %(optimize)s:
- sys.argv.insert(1, '-O')
-
-sys.argv.insert(1, mainprogram)
-if %(standalone)s or %(semi_standalone)s:
- os.environ["PYTHONPATH"] = resdir
- if %(standalone)s:
- os.environ["PYTHONHOME"] = resdir
-else:
- pypath = os.getenv("PYTHONPATH", "")
- if pypath:
- pypath = ":" + pypath
- os.environ["PYTHONPATH"] = resdir + pypath
-
-os.environ["PYTHONEXECUTABLE"] = executable
-os.environ["DYLD_LIBRARY_PATH"] = libdir
-os.environ["DYLD_FRAMEWORK_PATH"] = libdir
-os.execve(executable, sys.argv, os.environ)
-"""
-
-
-#
-# Optional wrapper that converts "dropped files" into sys.argv values.
-#
-ARGV_EMULATOR = """\
-import argvemulator, os
-
-argvemulator.ArgvCollector().mainloop()
-execfile(os.path.join(os.path.split(__file__)[0], "%(realmainprogram)s"))
-"""
-
-#
-# When building a standalone app with Python.framework, we need to copy
-# a subset from Python.framework to the bundle. The following list
-# specifies exactly what items we'll copy.
-#
-PYTHONFRAMEWORKGOODIES = [
- "Python", # the Python core library
- "Resources/English.lproj",
- "Resources/Info.plist",
-]
-
-def isFramework():
- return sys.exec_prefix.find("Python.framework") > 0
-
-
-LIB = os.path.join(sys.prefix, "lib", "python" + sys.version[:3])
-SITE_PACKAGES = os.path.join(LIB, "site-packages")
-
-
-class AppBuilder(BundleBuilder):
-
- use_zipimport = USE_ZIPIMPORT
-
- # Override type of the bundle.
- type = "APPL"
-
- # platform, name of the subfolder of Contents that contains the executable.
- platform = "MacOS"
-
- # A Python main program. If this argument is given, the main
- # executable in the bundle will be a small wrapper that invokes
- # the main program. (XXX Discuss why.)
- mainprogram = None
-
- # The main executable. If a Python main program is specified
- # the executable will be copied to Resources and be invoked
- # by the wrapper program mentioned above. Otherwise it will
- # simply be used as the main executable.
- executable = None
-
- # The name of the main nib, for Cocoa apps. *Must* be specified
- # when building a Cocoa app.
- nibname = None
-
- # The name of the icon file to be copied to Resources and used for
- # the Finder icon.
- iconfile = None
-
- # Symlink the executable instead of copying it.
- symlink_exec = 0
-
- # If True, build standalone app.
- standalone = 0
-
- # If True, build semi-standalone app (only includes third-party modules).
- semi_standalone = 0
-
- # If set, use this for #! lines in stead of sys.executable
- python = None
-
- # If True, add a real main program that emulates sys.argv before calling
- # mainprogram
- argv_emulation = 0
-
- # The following attributes are only used when building a standalone app.
-
- # Exclude these modules.
- excludeModules = []
-
- # Include these modules.
- includeModules = []
-
- # Include these packages.
- includePackages = []
-
- # Strip binaries from debug info.
- strip = 0
-
- # Found Python modules: [(name, codeobject, ispkg), ...]
- pymodules = []
-
- # Modules that modulefinder couldn't find:
- missingModules = []
- maybeMissingModules = []
-
- def setup(self):
- if ((self.standalone or self.semi_standalone)
- and self.mainprogram is None):
- raise BundleBuilderError, ("must specify 'mainprogram' when "
- "building a standalone application.")
- if self.mainprogram is None and self.executable is None:
- raise BundleBuilderError, ("must specify either or both of "
- "'executable' and 'mainprogram'")
-
- self.execdir = pathjoin("Contents", self.platform)
-
- if self.name is not None:
- pass
- elif self.mainprogram is not None:
- self.name = os.path.splitext(os.path.basename(self.mainprogram))[0]
- elif self.executable is not None:
- self.name = os.path.splitext(os.path.basename(self.executable))[0]
- if self.name[-4:] != ".app":
- self.name += ".app"
-
- if self.executable is None:
- if not self.standalone and not isFramework():
- self.symlink_exec = 1
- if self.python:
- self.executable = self.python
- else:
- self.executable = sys.executable
-
- if self.nibname:
- self.plist.NSMainNibFile = self.nibname
- if not hasattr(self.plist, "NSPrincipalClass"):
- self.plist.NSPrincipalClass = "NSApplication"
-
- if self.standalone and isFramework():
- self.addPythonFramework()
-
- BundleBuilder.setup(self)
-
- self.plist.CFBundleExecutable = self.name
-
- if self.standalone or self.semi_standalone:
- self.findDependencies()
-
- def preProcess(self):
- resdir = "Contents/Resources"
- if self.executable is not None:
- if self.mainprogram is None:
- execname = self.name
- else:
- execname = os.path.basename(self.executable)
- execpath = pathjoin(self.execdir, execname)
- if not self.symlink_exec:
- self.files.append((self.destroot + self.executable, execpath))
- self.execpath = execpath
-
- if self.mainprogram is not None:
- mainprogram = os.path.basename(self.mainprogram)
- self.files.append((self.mainprogram, pathjoin(resdir, mainprogram)))
- if self.argv_emulation:
- # Change the main program, and create the helper main program (which
- # does argv collection and then calls the real main).
- # Also update the included modules (if we're creating a standalone
- # program) and the plist
- realmainprogram = mainprogram
- mainprogram = '__argvemulator_' + mainprogram
- resdirpath = pathjoin(self.bundlepath, resdir)
- mainprogrampath = pathjoin(resdirpath, mainprogram)
- makedirs(resdirpath)
- open(mainprogrampath, "w").write(ARGV_EMULATOR % locals())
- if self.standalone or self.semi_standalone:
- self.includeModules.append("argvemulator")
- self.includeModules.append("os")
- if "CFBundleDocumentTypes" not in self.plist:
- self.plist["CFBundleDocumentTypes"] = [
- { "CFBundleTypeOSTypes" : [
- "****",
- "fold",
- "disk"],
- "CFBundleTypeRole": "Viewer"}]
- # Write bootstrap script
- executable = os.path.basename(self.executable)
- execdir = pathjoin(self.bundlepath, self.execdir)
- bootstrappath = pathjoin(execdir, self.name)
- makedirs(execdir)
- if self.standalone or self.semi_standalone:
- # XXX we're screwed when the end user has deleted
- # /usr/bin/python
- hashbang = "/usr/bin/python"
- elif self.python:
- hashbang = self.python
- else:
- hashbang = os.path.realpath(sys.executable)
- standalone = self.standalone
- semi_standalone = self.semi_standalone
- optimize = sys.flags.optimize
- open(bootstrappath, "w").write(BOOTSTRAP_SCRIPT % locals())
- os.chmod(bootstrappath, 0775)
-
- if self.iconfile is not None:
- iconbase = os.path.basename(self.iconfile)
- self.plist.CFBundleIconFile = iconbase
- self.files.append((self.iconfile, pathjoin(resdir, iconbase)))
-
- def postProcess(self):
- if self.standalone or self.semi_standalone:
- self.addPythonModules()
- if self.strip and not self.symlink:
- self.stripBinaries()
-
- if self.symlink_exec and self.executable:
- self.message("Symlinking executable %s to %s" % (self.executable,
- self.execpath), 2)
- dst = pathjoin(self.bundlepath, self.execpath)
- makedirs(os.path.dirname(dst))
- os.symlink(os.path.abspath(self.executable), dst)
-
- if self.missingModules or self.maybeMissingModules:
- self.reportMissing()
-
- def addPythonFramework(self):
- # If we're building a standalone app with Python.framework,
- # include a minimal subset of Python.framework, *unless*
- # Python.framework was specified manually in self.libs.
- for lib in self.libs:
- if os.path.basename(lib) == "Python.framework":
- # a Python.framework was specified as a library
- return
-
- frameworkpath = sys.exec_prefix[:sys.exec_prefix.find(
- "Python.framework") + len("Python.framework")]
-
- version = sys.version[:3]
- frameworkpath = pathjoin(frameworkpath, "Versions", version)
- destbase = pathjoin("Contents", "Frameworks", "Python.framework",
- "Versions", version)
- for item in PYTHONFRAMEWORKGOODIES:
- src = pathjoin(frameworkpath, item)
- dst = pathjoin(destbase, item)
- self.files.append((src, dst))
-
- def _getSiteCode(self):
- if self.use_zipimport:
- return compile(SITE_PY % {"semi_standalone": self.semi_standalone},
- "<-bundlebuilder.py->", "exec")
-
- def addPythonModules(self):
- self.message("Adding Python modules", 1)
-
- if self.use_zipimport:
- # Create a zip file containing all modules as pyc.
- import zipfile
- relpath = pathjoin("Contents", "Resources", ZIP_ARCHIVE)
- abspath = pathjoin(self.bundlepath, relpath)
- zf = zipfile.ZipFile(abspath, "w", zipfile.ZIP_DEFLATED)
- for name, code, ispkg in self.pymodules:
- self.message("Adding Python module %s" % name, 2)
- path, pyc = getPycData(name, code, ispkg)
- zf.writestr(path, pyc)
- zf.close()
- # add site.pyc
- sitepath = pathjoin(self.bundlepath, "Contents", "Resources",
- "site" + PYC_EXT)
- writePyc(self._getSiteCode(), sitepath)
- else:
- # Create individual .pyc files.
- for name, code, ispkg in self.pymodules:
- if ispkg:
- name += ".__init__"
- path = name.split(".")
- path = pathjoin("Contents", "Resources", *path) + PYC_EXT
-
- if ispkg:
- self.message("Adding Python package %s" % path, 2)
- else:
- self.message("Adding Python module %s" % path, 2)
-
- abspath = pathjoin(self.bundlepath, path)
- makedirs(os.path.dirname(abspath))
- writePyc(code, abspath)
-
- def stripBinaries(self):
- if not os.path.exists(STRIP_EXEC):
- self.message("Error: can't strip binaries: no strip program at "
- "%s" % STRIP_EXEC, 0)
- else:
- import stat
- self.message("Stripping binaries", 1)
- def walk(top):
- for name in os.listdir(top):
- path = pathjoin(top, name)
- if os.path.islink(path):
- continue
- if os.path.isdir(path):
- walk(path)
- else:
- mod = os.stat(path)[stat.ST_MODE]
- if not (mod & 0100):
- continue
- relpath = path[len(self.bundlepath):]
- self.message("Stripping %s" % relpath, 2)
- inf, outf = os.popen4("%s -S \"%s\"" %
- (STRIP_EXEC, path))
- output = outf.read().strip()
- if output:
- # usually not a real problem, like when we're
- # trying to strip a script
- self.message("Problem stripping %s:" % relpath, 3)
- self.message(output, 3)
- walk(self.bundlepath)
-
- def findDependencies(self):
- self.message("Finding module dependencies", 1)
- import modulefinder
- mf = modulefinder.ModuleFinder(excludes=self.excludeModules)
- if self.use_zipimport:
- # zipimport imports zlib, must add it manually
- mf.import_hook("zlib")
- # manually add our own site.py
- site = mf.add_module("site")
- site.__code__ = self._getSiteCode()
- mf.scan_code(site.__code__, site)
-
- # warnings.py gets imported implicitly from C
- mf.import_hook("warnings")
-
- includeModules = self.includeModules[:]
- for name in self.includePackages:
- includeModules.extend(findPackageContents(name).keys())
- for name in includeModules:
- try:
- mf.import_hook(name)
- except ImportError:
- self.missingModules.append(name)
-
- mf.run_script(self.mainprogram)
- modules = mf.modules.items()
- modules.sort()
- for name, mod in modules:
- path = mod.__file__
- if path and self.semi_standalone:
- # skip the standard library
- if path.startswith(LIB) and not path.startswith(SITE_PACKAGES):
- continue
- if path and mod.__code__ is None:
- # C extension
- filename = os.path.basename(path)
- pathitems = name.split(".")[:-1] + [filename]
- dstpath = pathjoin(*pathitems)
- if self.use_zipimport:
- if name != "zlib":
- # neatly pack all extension modules in a subdirectory,
- # except zlib, since it's necessary for bootstrapping.
- dstpath = pathjoin("ExtensionModules", dstpath)
- # Python modules are stored in a Zip archive, but put
- # extensions in Contents/Resources/. Add a tiny "loader"
- # program in the Zip archive. Due to Thomas Heller.
- source = EXT_LOADER % {"name": name, "filename": dstpath}
- code = compile(source, "<dynloader for %s>" % name, "exec")
- mod.__code__ = code
- self.files.append((path, pathjoin("Contents", "Resources", dstpath)))
- if mod.__code__ is not None:
- ispkg = mod.__path__ is not None
- if not self.use_zipimport or name != "site":
- # Our site.py is doing the bootstrapping, so we must
- # include a real .pyc file if self.use_zipimport is True.
- self.pymodules.append((name, mod.__code__, ispkg))
-
- if hasattr(mf, "any_missing_maybe"):
- missing, maybe = mf.any_missing_maybe()
- else:
- missing = mf.any_missing()
- maybe = []
- self.missingModules.extend(missing)
- self.maybeMissingModules.extend(maybe)
-
- def reportMissing(self):
- missing = [name for name in self.missingModules
- if name not in MAYMISS_MODULES]
- if self.maybeMissingModules:
- maybe = self.maybeMissingModules
- else:
- maybe = [name for name in missing if "." in name]
- missing = [name for name in missing if "." not in name]
- missing.sort()
- maybe.sort()
- if maybe:
- self.message("Warning: couldn't find the following submodules:", 1)
- self.message(" (Note that these could be false alarms -- "
- "it's not always", 1)
- self.message(" possible to distinguish between \"from package "
- "import submodule\" ", 1)
- self.message(" and \"from package import name\")", 1)
- for name in maybe:
- self.message(" ? " + name, 1)
- if missing:
- self.message("Warning: couldn't find the following modules:", 1)
- for name in missing:
- self.message(" ? " + name, 1)
-
- def report(self):
- # XXX something decent
- import pprint
- pprint.pprint(self.__dict__)
- if self.standalone or self.semi_standalone:
- self.reportMissing()
-
-#
-# Utilities.
-#
-
-SUFFIXES = [_suf for _suf, _mode, _tp in imp.get_suffixes()]
-identifierRE = re.compile(r"[_a-zA-z][_a-zA-Z0-9]*$")
-
-def findPackageContents(name, searchpath=None):
- head = name.split(".")[-1]
- if identifierRE.match(head) is None:
- return {}
- try:
- fp, path, (ext, mode, tp) = imp.find_module(head, searchpath)
- except ImportError:
- return {}
- modules = {name: None}
- if tp == imp.PKG_DIRECTORY and path:
- files = os.listdir(path)
- for sub in files:
- sub, ext = os.path.splitext(sub)
- fullname = name + "." + sub
- if sub != "__init__" and fullname not in modules:
- modules.update(findPackageContents(fullname, [path]))
- return modules
-
-def writePyc(code, path):
- f = open(path, "wb")
- f.write(MAGIC)
- f.write("\0" * 4) # don't bother about a time stamp
- marshal.dump(code, f)
- f.close()
-
-def copy(src, dst, mkdirs=0):
- """Copy a file or a directory."""
- if mkdirs:
- makedirs(os.path.dirname(dst))
- if os.path.isdir(src):
- shutil.copytree(src, dst, symlinks=1)
- else:
- shutil.copy2(src, dst)
-
-def copytodir(src, dstdir):
- """Copy a file or a directory to an existing directory."""
- dst = pathjoin(dstdir, os.path.basename(src))
- copy(src, dst)
-
-def makedirs(dir):
- """Make all directories leading up to 'dir' including the leaf
- directory. Don't moan if any path element already exists."""
- try:
- os.makedirs(dir)
- except OSError, why:
- if why.errno != errno.EEXIST:
- raise
-
-def symlink(src, dst, mkdirs=0):
- """Copy a file or a directory."""
- if not os.path.exists(src):
- raise IOError, "No such file or directory: '%s'" % src
- if mkdirs:
- makedirs(os.path.dirname(dst))
- os.symlink(os.path.abspath(src), dst)
-
-def pathjoin(*args):
- """Safe wrapper for os.path.join: asserts that all but the first
- argument are relative paths."""
- for seg in args[1:]:
- assert seg[0] != "/"
- return os.path.join(*args)
-
-
-cmdline_doc = """\
-Usage:
- python bundlebuilder.py [options] command
- python mybuildscript.py [options] command
-
-Commands:
- build build the application
- report print a report
-
-Options:
- -b, --builddir=DIR the build directory; defaults to "build"
- -n, --name=NAME application name
- -r, --resource=FILE extra file or folder to be copied to Resources
- -f, --file=SRC:DST extra file or folder to be copied into the bundle;
- DST must be a path relative to the bundle root
- -e, --executable=FILE the executable to be used
- -m, --mainprogram=FILE the Python main program
- -a, --argv add a wrapper main program to create sys.argv
- -p, --plist=FILE .plist file (default: generate one)
- --nib=NAME main nib name
- -c, --creator=CCCC 4-char creator code (default: '????')
- --iconfile=FILE filename of the icon (an .icns file) to be used
- as the Finder icon
- --bundle-id=ID the CFBundleIdentifier, in reverse-dns format
- (eg. org.python.BuildApplet; this is used for
- the preferences file name)
- -l, --link symlink files/folder instead of copying them
- --link-exec symlink the executable instead of copying it
- --standalone build a standalone application, which is fully
- independent of a Python installation
- --semi-standalone build a standalone application, which depends on
- an installed Python, yet includes all third-party
- modules.
- --no-zipimport Do not copy code into a zip file
- --python=FILE Python to use in #! line in stead of current Python
- --lib=FILE shared library or framework to be copied into
- the bundle
- -x, --exclude=MODULE exclude module (with --(semi-)standalone)
- -i, --include=MODULE include module (with --(semi-)standalone)
- --package=PACKAGE include a whole package (with --(semi-)standalone)
- --strip strip binaries (remove debug info)
- -v, --verbose increase verbosity level
- -q, --quiet decrease verbosity level
- -h, --help print this message
-"""
-
-def usage(msg=None):
- if msg:
- print msg
- print cmdline_doc
- sys.exit(1)
-
-def main(builder=None):
- if builder is None:
- builder = AppBuilder(verbosity=1)
-
- shortopts = "b:n:r:f:e:m:c:p:lx:i:hvqa"
- longopts = ("builddir=", "name=", "resource=", "file=", "executable=",
- "mainprogram=", "creator=", "nib=", "plist=", "link",
- "link-exec", "help", "verbose", "quiet", "argv", "standalone",
- "exclude=", "include=", "package=", "strip", "iconfile=",
- "lib=", "python=", "semi-standalone", "bundle-id=", "destroot="
- "no-zipimport"
- )
-
- try:
- options, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
- except getopt.error:
- usage()
-
- for opt, arg in options:
- if opt in ('-b', '--builddir'):
- builder.builddir = arg
- elif opt in ('-n', '--name'):
- builder.name = arg
- elif opt in ('-r', '--resource'):
- builder.resources.append(os.path.normpath(arg))
- elif opt in ('-f', '--file'):
- srcdst = arg.split(':')
- if len(srcdst) != 2:
- usage("-f or --file argument must be two paths, "
- "separated by a colon")
- builder.files.append(srcdst)
- elif opt in ('-e', '--executable'):
- builder.executable = arg
- elif opt in ('-m', '--mainprogram'):
- builder.mainprogram = arg
- elif opt in ('-a', '--argv'):
- builder.argv_emulation = 1
- elif opt in ('-c', '--creator'):
- builder.creator = arg
- elif opt == '--bundle-id':
- builder.bundle_id = arg
- elif opt == '--iconfile':
- builder.iconfile = arg
- elif opt == "--lib":
- builder.libs.append(os.path.normpath(arg))
- elif opt == "--nib":
- builder.nibname = arg
- elif opt in ('-p', '--plist'):
- builder.plist = Plist.fromFile(arg)
- elif opt in ('-l', '--link'):
- builder.symlink = 1
- elif opt == '--link-exec':
- builder.symlink_exec = 1
- elif opt in ('-h', '--help'):
- usage()
- elif opt in ('-v', '--verbose'):
- builder.verbosity += 1
- elif opt in ('-q', '--quiet'):
- builder.verbosity -= 1
- elif opt == '--standalone':
- builder.standalone = 1
- elif opt == '--semi-standalone':
- builder.semi_standalone = 1
- elif opt == '--python':
- builder.python = arg
- elif opt in ('-x', '--exclude'):
- builder.excludeModules.append(arg)
- elif opt in ('-i', '--include'):
- builder.includeModules.append(arg)
- elif opt == '--package':
- builder.includePackages.append(arg)
- elif opt == '--strip':
- builder.strip = 1
- elif opt == '--destroot':
- builder.destroot = arg
- elif opt == '--no-zipimport':
- builder.use_zipimport = False
-
- if len(args) != 1:
- usage("Must specify one command ('build', 'report' or 'help')")
- command = args[0]
-
- if command == "build":
- builder.setup()
- builder.build()
- elif command == "report":
- builder.setup()
- builder.report()
- elif command == "help":
- usage()
- else:
- usage("Unknown command '%s'" % command)
-
-
-def buildapp(**kwargs):
- builder = AppBuilder(**kwargs)
- main(builder)
-
-
-if __name__ == "__main__":
- main()
diff --git a/Lib/plat-mac/cfmfile.py b/Lib/plat-mac/cfmfile.py
deleted file mode 100644
index 26238e94543..00000000000
--- a/Lib/plat-mac/cfmfile.py
+++ /dev/null
@@ -1,187 +0,0 @@
-"""codefragments.py -- wrapper to modify code fragments."""
-
-# (c) 1998, Just van Rossum, Letterror
-
-__version__ = "0.8b3"
-__author__ = "jvr"
-
-import warnings
-warnings.warnpy3k("the cfmfile module is deprecated and is removed in 3,0",
- stacklevel=2)
-
-import Carbon.File
-import struct
-from Carbon import Res
-import os
-import sys
-
-DEBUG = 0
-
-error = "cfm.error"
-
-BUFSIZE = 0x80000
-
-def mergecfmfiles(srclist, dst, architecture = 'fat'):
- """Merge all files in srclist into a new file dst.
-
- If architecture is given, only code fragments of that type will be used:
- "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic"
- 68k code, since it does not use code fragments to begin with.
- If architecture is None, all fragments will be used, enabling FAT binaries.
- """
-
- srclist = list(srclist)
- for i in range(len(srclist)):
- srclist[i] = Carbon.File.pathname(srclist[i])
- dst = Carbon.File.pathname(dst)
-
- dstfile = open(dst, "wb")
- rf = Res.FSpOpenResFile(dst, 3)
- try:
- dstcfrg = CfrgResource()
- for src in srclist:
- srccfrg = CfrgResource(src)
- for frag in srccfrg.fragments:
- if frag.architecture == 'pwpc' and architecture == 'm68k':
- continue
- if frag.architecture == 'm68k' and architecture == 'pwpc':
- continue
- dstcfrg.append(frag)
-
- frag.copydata(dstfile)
-
- cfrgres = Res.Resource(dstcfrg.build())
- Res.UseResFile(rf)
- cfrgres.AddResource('cfrg', 0, "")
- finally:
- dstfile.close()
- rf = Res.CloseResFile(rf)
-
-
-class CfrgResource:
-
- def __init__(self, path = None):
- self.version = 1
- self.fragments = []
- self.path = path
- if path is not None and os.path.exists(path):
- currentresref = Res.CurResFile()
- resref = Res.FSpOpenResFile(path, 1)
- Res.UseResFile(resref)
- try:
- try:
- data = Res.Get1Resource('cfrg', 0).data
- except Res.Error:
- raise Res.Error, "no 'cfrg' resource found", sys.exc_traceback
- finally:
- Res.CloseResFile(resref)
- Res.UseResFile(currentresref)
- self.parse(data)
- if self.version != 1:
- raise error, "unknown 'cfrg' resource format"
-
- def parse(self, data):
- (res1, res2, self.version,
- res3, res4, res5, res6,
- self.memberCount) = struct.unpack("8l", data[:32])
- data = data[32:]
- while data:
- frag = FragmentDescriptor(self.path, data)
- data = data[frag.memberSize:]
- self.fragments.append(frag)
-
- def build(self):
- self.memberCount = len(self.fragments)
- data = struct.pack("8l", 0, 0, self.version, 0, 0, 0, 0, self.memberCount)
- for frag in self.fragments:
- data = data + frag.build()
- return data
-
- def append(self, frag):
- self.fragments.append(frag)
-
-
-class FragmentDescriptor:
-
- def __init__(self, path, data = None):
- self.path = path
- if data is not None:
- self.parse(data)
-
- def parse(self, data):
- self.architecture = data[:4]
- ( self.updatelevel,
- self.currentVersion,
- self.oldDefVersion,
- self.stacksize,
- self.applibdir,
- self.fragtype,
- self.where,
- self.offset,
- self.length,
- self.res1, self.res2,
- self.memberSize,) = struct.unpack("4lhBB4lh", data[4:42])
- pname = data[42:self.memberSize]
- self.name = pname[1:1+ord(pname[0])]
-
- def build(self):
- data = self.architecture
- data = data + struct.pack("4lhBB4l",
- self.updatelevel,
- self.currentVersion,
- self.oldDefVersion,
- self.stacksize,
- self.applibdir,
- self.fragtype,
- self.where,
- self.offset,
- self.length,
- self.res1, self.res2)
- self.memberSize = len(data) + 2 + 1 + len(self.name)
- # pad to 4 byte boundaries
- if self.memberSize % 4:
- self.memberSize = self.memberSize + 4 - (self.memberSize % 4)
- data = data + struct.pack("hb", self.memberSize, len(self.name))
- data = data + self.name
- data = data + '\000' * (self.memberSize - len(data))
- return data
-
- def getfragment(self):
- if self.where != 1:
- raise error, "can't read fragment, unsupported location"
- f = open(self.path, "rb")
- f.seek(self.offset)
- if self.length:
- frag = f.read(self.length)
- else:
- frag = f.read()
- f.close()
- return frag
-
- def copydata(self, outfile):
- if self.where != 1:
- raise error, "can't read fragment, unsupported location"
- infile = open(self.path, "rb")
- if self.length == 0:
- infile.seek(0, 2)
- self.length = infile.tell()
-
- # Position input file and record new offset from output file
- infile.seek(self.offset)
-
- # pad to 16 byte boundaries
- offset = outfile.tell()
- if offset % 16:
- offset = offset + 16 - (offset % 16)
- outfile.seek(offset)
- self.offset = offset
-
- l = self.length
- while l:
- if l > BUFSIZE:
- outfile.write(infile.read(BUFSIZE))
- l = l - BUFSIZE
- else:
- outfile.write(infile.read(l))
- l = 0
- infile.close()
diff --git a/Lib/plat-mac/dialogs.rsrc b/Lib/plat-mac/dialogs.rsrc
deleted file mode 100644
index 0107493b593..00000000000
--- a/Lib/plat-mac/dialogs.rsrc
+++ /dev/null
Binary files differ
diff --git a/Lib/plat-mac/errors.rsrc b/Lib/plat-mac/errors.rsrc
deleted file mode 100644
index 61c487e17f6..00000000000
--- a/Lib/plat-mac/errors.rsrc
+++ /dev/null
Binary files differ
diff --git a/Lib/plat-mac/findertools.py b/Lib/plat-mac/findertools.py
deleted file mode 100644
index d0c74a91256..00000000000
--- a/Lib/plat-mac/findertools.py
+++ /dev/null
@@ -1,835 +0,0 @@
-"""Utility routines depending on the finder,
-a combination of code by Jack Jansen and erik@letterror.com.
-
-Most events have been captured from
-Lasso Capture AE and than translated to python code.
-
-IMPORTANT
-Note that the processes() function returns different values
-depending on the OS version it is running on. On MacOS 9
-the Finder returns the process *names* which can then be
-used to find out more about them. On MacOS 8.6 and earlier
-the Finder returns a code which does not seem to work.
-So bottom line: the processes() stuff does not work on < MacOS9
-
-Mostly written by erik@letterror.com
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the findertools module is removed.", stacklevel=2)
-
-import Finder
-from Carbon import AppleEvents
-import aetools
-import MacOS
-import sys
-import Carbon.File
-import Carbon.Folder
-import aetypes
-from types import *
-
-__version__ = '1.1'
-Error = 'findertools.Error'
-
-_finder_talker = None
-
-def _getfinder():
- """returns basic (recyclable) Finder AE interface object"""
- global _finder_talker
- if not _finder_talker:
- _finder_talker = Finder.Finder()
- _finder_talker.send_flags = ( _finder_talker.send_flags |
- AppleEvents.kAECanInteract | AppleEvents.kAECanSwitchLayer)
- return _finder_talker
-
-def launch(file):
- """Open a file thru the finder. Specify file by name or fsspec"""
- finder = _getfinder()
- fss = Carbon.File.FSSpec(file)
- return finder.open(fss)
-
-def Print(file):
- """Print a file thru the finder. Specify file by name or fsspec"""
- finder = _getfinder()
- fss = Carbon.File.FSSpec(file)
- return finder._print(fss)
-
-def copy(src, dstdir):
- """Copy a file to a folder"""
- finder = _getfinder()
- if type(src) == type([]):
- src_fss = []
- for s in src:
- src_fss.append(Carbon.File.FSSpec(s))
- else:
- src_fss = Carbon.File.FSSpec(src)
- dst_fss = Carbon.File.FSSpec(dstdir)
- return finder.duplicate(src_fss, to=dst_fss)
-
-def move(src, dstdir):
- """Move a file to a folder"""
- finder = _getfinder()
- if type(src) == type([]):
- src_fss = []
- for s in src:
- src_fss.append(Carbon.File.FSSpec(s))
- else:
- src_fss = Carbon.File.FSSpec(src)
- dst_fss = Carbon.File.FSSpec(dstdir)
- return finder.move(src_fss, to=dst_fss)
-
-def sleep():
- """Put the mac to sleep"""
- finder = _getfinder()
- finder.sleep()
-
-def shutdown():
- """Shut the mac down"""
- finder = _getfinder()
- finder.shut_down()
-
-def restart():
- """Restart the mac"""
- finder = _getfinder()
- finder.restart()
-
-
-#---------------------------------------------------
-# Additional findertools
-#
-
-def reveal(file):
- """Reveal a file in the finder. Specify file by name, fsref or fsspec."""
- finder = _getfinder()
- fsr = Carbon.File.FSRef(file)
- file_alias = fsr.FSNewAliasMinimal()
- return finder.reveal(file_alias)
-
-def select(file):
- """select a file in the finder. Specify file by name, fsref or fsspec."""
- finder = _getfinder()
- fsr = Carbon.File.FSRef(file)
- file_alias = fsr.FSNewAliasMinimal()
- return finder.select(file_alias)
-
-def update(file):
- """Update the display of the specified object(s) to match
- their on-disk representation. Specify file by name, fsref or fsspec."""
- finder = _getfinder()
- fsr = Carbon.File.FSRef(file)
- file_alias = fsr.FSNewAliasMinimal()
- return finder.update(file_alias)
-
-
-#---------------------------------------------------
-# More findertools
-#
-
-def comment(object, comment=None):
- """comment: get or set the Finder-comment of the item, displayed in the 'Get Info' window."""
- object = Carbon.File.FSRef(object)
- object_alias = object.FSNewAliasMinimal()
- if comment is None:
- return _getcomment(object_alias)
- else:
- return _setcomment(object_alias, comment)
-
-def _setcomment(object_alias, comment):
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('comt'), fr=aeobj_00)
- args['----'] = aeobj_01
- args["data"] = comment
- _reply, args, attrs = finder.send("core", "setd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def _getcomment(object_alias):
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('comt'), fr=aeobj_00)
- args['----'] = aeobj_01
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-
-#---------------------------------------------------
-# Get information about current processes in the Finder.
-
-def processes():
- """processes returns a list of all active processes running on this computer and their creators."""
- finder = _getfinder()
- args = {}
- attrs = {}
- processnames = []
- processnumbers = []
- creators = []
- partitions = []
- used = []
- ## get the processnames or else the processnumbers
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form="indx", seld=aetypes.Unknown('abso', "all "), fr=None)
- _reply, args, attrs = finder.send('core', 'getd', args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- p = []
- if '----' in args:
- p = args['----']
- for proc in p:
- if hasattr(proc, 'seld'):
- # it has a real name
- processnames.append(proc.seld)
- elif hasattr(proc, 'type'):
- if proc.type == "psn ":
- # it has a process number
- processnumbers.append(proc.data)
- ## get the creators
- args = {}
- attrs = {}
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form="indx", seld=aetypes.Unknown('abso', "all "), fr=None)
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fcrt'), fr=aeobj_0)
- _reply, args, attrs = finder.send('core', 'getd', args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(_arg)
- if '----' in args:
- p = args['----']
- creators = p[:]
- ## concatenate in one dict
- result = []
- if len(processnames) > len(processnumbers):
- data = processnames
- else:
- data = processnumbers
- for i in range(len(creators)):
- result.append((data[i], creators[i]))
- return result
-
-class _process:
- pass
-
-def isactiveprocess(processname):
- """Check of processname is active. MacOS9"""
- all = processes()
- ok = 0
- for n, c in all:
- if n == processname:
- return 1
- return 0
-
-def processinfo(processname):
- """Return an object with all process properties as attributes for processname. MacOS9"""
- p = _process()
-
- if processname == "Finder":
- p.partition = None
- p.used = None
- else:
- p.partition = _processproperty(processname, 'appt')
- p.used = _processproperty(processname, 'pusd')
- p.visible = _processproperty(processname, 'pvis') #Is the process' layer visible?
- p.frontmost = _processproperty(processname, 'pisf') #Is the process the frontmost process?
- p.file = _processproperty(processname, 'file') #the file from which the process was launched
- p.filetype = _processproperty(processname, 'asty') #the OSType of the file type of the process
- p.creatortype = _processproperty(processname, 'fcrt') #the OSType of the creator of the process (the signature)
- p.accepthighlevel = _processproperty(processname, 'revt') #Is the process high-level event aware (accepts open application, open document, print document, and quit)?
- p.hasscripting = _processproperty(processname, 'hscr') #Does the process have a scripting terminology, i.e., can it be scripted?
- return p
-
-def _processproperty(processname, property):
- """return the partition size and memory used for processname"""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('prcs'), form="name", seld=processname, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type(property), fr=aeobj_00)
- args['----'] = aeobj_01
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-
-#---------------------------------------------------
-# Mess around with Finder windows.
-
-def openwindow(object):
- """Open a Finder window for object, Specify object by name or fsspec."""
- finder = _getfinder()
- object = Carbon.File.FSRef(object)
- object_alias = object.FSNewAliasMinimal()
- args = {}
- attrs = {}
- _code = 'aevt'
- _subcode = 'odoc'
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None)
- args['----'] = aeobj_0
- _reply, args, attrs = finder.send(_code, _subcode, args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
-
-def closewindow(object):
- """Close a Finder window for folder, Specify by path."""
- finder = _getfinder()
- object = Carbon.File.FSRef(object)
- object_alias = object.FSNewAliasMinimal()
- args = {}
- attrs = {}
- _code = 'core'
- _subcode = 'clos'
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None)
- args['----'] = aeobj_0
- _reply, args, attrs = finder.send(_code, _subcode, args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
-
-def location(object, pos=None):
- """Set the position of a Finder window for folder to pos=(w, h). Specify file by name or fsspec.
- If pos=None, location will return the current position of the object."""
- object = Carbon.File.FSRef(object)
- object_alias = object.FSNewAliasMinimal()
- if not pos:
- return _getlocation(object_alias)
- return _setlocation(object_alias, pos)
-
-def _setlocation(object_alias, (x, y)):
- """_setlocation: Set the location of the icon for the object."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_00)
- args['----'] = aeobj_01
- args["data"] = [x, y]
- _reply, args, attrs = finder.send("core", "setd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- return (x,y)
-
-def _getlocation(object_alias):
- """_getlocation: get the location of the icon for the object."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('posn'), fr=aeobj_00)
- args['----'] = aeobj_01
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- pos = args['----']
- return pos.h, pos.v
-
-def label(object, index=None):
- """label: set or get the label of the item. Specify file by name or fsspec."""
- object = Carbon.File.FSRef(object)
- object_alias = object.FSNewAliasMinimal()
- if index is None:
- return _getlabel(object_alias)
- if index < 0 or index > 7:
- index = 0
- return _setlabel(object_alias, index)
-
-def _getlabel(object_alias):
- """label: Get the label for the object."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'), form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('labi'), fr=aeobj_00)
- args['----'] = aeobj_01
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def _setlabel(object_alias, index):
- """label: Set the label for the object."""
- finder = _getfinder()
- args = {}
- attrs = {}
- _code = 'core'
- _subcode = 'setd'
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="alis", seld=object_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('labi'), fr=aeobj_0)
- args['----'] = aeobj_1
- args["data"] = index
- _reply, args, attrs = finder.send(_code, _subcode, args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- return index
-
-def windowview(folder, view=None):
- """windowview: Set the view of the window for the folder. Specify file by name or fsspec.
- 0 = by icon (default)
- 1 = by name
- 2 = by button
- """
- fsr = Carbon.File.FSRef(folder)
- folder_alias = fsr.FSNewAliasMinimal()
- if view is None:
- return _getwindowview(folder_alias)
- return _setwindowview(folder_alias, view)
-
-def _setwindowview(folder_alias, view=0):
- """set the windowview"""
- attrs = {}
- args = {}
- if view == 1:
- _v = aetypes.Type('pnam')
- elif view == 2:
- _v = aetypes.Type('lgbu')
- else:
- _v = aetypes.Type('iimg')
- finder = _getfinder()
- aeobj_0 = aetypes.ObjectSpecifier(want = aetypes.Type('cfol'),
- form = 'alis', seld = folder_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'),
- form = 'prop', seld = aetypes.Type('cwnd'), fr=aeobj_0)
- aeobj_2 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'),
- form = 'prop', seld = aetypes.Type('pvew'), fr=aeobj_1)
- aeobj_3 = aetypes.ObjectSpecifier(want = aetypes.Type('prop'),
- form = 'prop', seld = _v, fr=None)
- _code = 'core'
- _subcode = 'setd'
- args['----'] = aeobj_2
- args['data'] = aeobj_3
- _reply, args, attrs = finder.send(_code, _subcode, args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def _getwindowview(folder_alias):
- """get the windowview"""
- attrs = {}
- args = {}
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'), form="alis", seld=folder_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_00)
- aeobj_02 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('pvew'), fr=aeobj_01)
- args['----'] = aeobj_02
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- views = {'iimg':0, 'pnam':1, 'lgbu':2}
- if '----' in args:
- return views[args['----'].enum]
-
-def windowsize(folder, size=None):
- """Set the size of a Finder window for folder to size=(w, h), Specify by path.
- If size=None, windowsize will return the current size of the window.
- Specify file by name or fsspec.
- """
- fsr = Carbon.File.FSRef(folder)
- folder_alias = fsr.FSNewAliasMinimal()
- openwindow(fsr)
- if not size:
- return _getwindowsize(folder_alias)
- return _setwindowsize(folder_alias, size)
-
-def _setwindowsize(folder_alias, (w, h)):
- """Set the size of a Finder window for folder to (w, h)"""
- finder = _getfinder()
- args = {}
- attrs = {}
- _code = 'core'
- _subcode = 'setd'
- aevar00 = [w, h]
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'),
- form="alis", seld=folder_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0)
- aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1)
- args['----'] = aeobj_2
- args["data"] = aevar00
- _reply, args, attrs = finder.send(_code, _subcode, args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- return (w, h)
-
-def _getwindowsize(folder_alias):
- """Set the size of a Finder window for folder to (w, h)"""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'),
- form="alis", seld=folder_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0)
- aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('posn'), fr=aeobj_1)
- args['----'] = aeobj_2
- _reply, args, attrs = finder.send('core', 'getd', args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def windowposition(folder, pos=None):
- """Set the position of a Finder window for folder to pos=(w, h)."""
- fsr = Carbon.File.FSRef(folder)
- folder_alias = fsr.FSNewAliasMinimal()
- openwindow(fsr)
- if not pos:
- return _getwindowposition(folder_alias)
- if type(pos) == InstanceType:
- # pos might be a QDPoint object as returned by _getwindowposition
- pos = (pos.h, pos.v)
- return _setwindowposition(folder_alias, pos)
-
-def _setwindowposition(folder_alias, (x, y)):
- """Set the size of a Finder window for folder to (w, h)."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'),
- form="alis", seld=folder_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0)
- aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('posn'), fr=aeobj_1)
- args['----'] = aeobj_2
- args["data"] = [x, y]
- _reply, args, attrs = finder.send('core', 'setd', args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def _getwindowposition(folder_alias):
- """Get the size of a Finder window for folder, Specify by path."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_0 = aetypes.ObjectSpecifier(want=aetypes.Type('cfol'),
- form="alis", seld=folder_alias, fr=None)
- aeobj_1 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('cwnd'), fr=aeobj_0)
- aeobj_2 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('ptsz'), fr=aeobj_1)
- args['----'] = aeobj_2
- _reply, args, attrs = finder.send('core', 'getd', args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def icon(object, icondata=None):
- """icon sets the icon of object, if no icondata is given,
- icon will return an AE object with binary data for the current icon.
- If left untouched, this data can be used to paste the icon on another file.
- Development opportunity: get and set the data as PICT."""
- fsr = Carbon.File.FSRef(object)
- object_alias = fsr.FSNewAliasMinimal()
- if icondata is None:
- return _geticon(object_alias)
- return _seticon(object_alias, icondata)
-
-def _geticon(object_alias):
- """get the icondata for object. Binary data of some sort."""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'),
- form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00)
- args['----'] = aeobj_01
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def _seticon(object_alias, icondata):
- """set the icondata for object, formatted as produced by _geticon()"""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('cobj'),
- form="alis", seld=object_alias, fr=None)
- aeobj_01 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'),
- form="prop", seld=aetypes.Type('iimg'), fr=aeobj_00)
- args['----'] = aeobj_01
- args["data"] = icondata
- _reply, args, attrs = finder.send("core", "setd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----'].data
-
-
-#---------------------------------------------------
-# Volumes and servers.
-
-def mountvolume(volume, server=None, username=None, password=None):
- """mount a volume, local or on a server on AppleTalk.
- Note: mounting a ASIP server requires a different operation.
- server is the name of the server where the volume belongs
- username, password belong to a registered user of the volume."""
- finder = _getfinder()
- args = {}
- attrs = {}
- if password:
- args["PASS"] = password
- if username:
- args["USER"] = username
- if server:
- args["SRVR"] = server
- args['----'] = volume
- _reply, args, attrs = finder.send("aevt", "mvol", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def unmountvolume(volume):
- """unmount a volume that's on the desktop"""
- putaway(volume)
-
-def putaway(object):
- """puth the object away, whereever it came from."""
- finder = _getfinder()
- args = {}
- attrs = {}
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('cdis'), form="name", seld=object, fr=None)
- _reply, args, attrs = talker.send("fndr", "ptwy", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-
-#---------------------------------------------------
-# Miscellaneous functions
-#
-
-def volumelevel(level):
- """set the audio output level, parameter between 0 (silent) and 7 (full blast)"""
- finder = _getfinder()
- args = {}
- attrs = {}
- if level < 0:
- level = 0
- elif level > 7:
- level = 7
- args['----'] = level
- _reply, args, attrs = finder.send("aevt", "stvl", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def OSversion():
- """return the version of the system software"""
- finder = _getfinder()
- args = {}
- attrs = {}
- aeobj_00 = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('ver2'), fr=None)
- args['----'] = aeobj_00
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- return args['----']
-
-def filesharing():
- """return the current status of filesharing and whether it is starting up or not:
- -1 file sharing is off and not starting up
- 0 file sharing is off and starting up
- 1 file sharing is on"""
- status = -1
- finder = _getfinder()
- # see if it is on
- args = {}
- attrs = {}
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fshr'), fr=None)
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- if args['----'] == 0:
- status = -1
- else:
- status = 1
- # is it starting up perchance?
- args = {}
- attrs = {}
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('fsup'), fr=None)
- _reply, args, attrs = finder.send("core", "getd", args, attrs)
- if 'errn' in args:
- raise Error, aetools.decodeerror(args)
- if '----' in args:
- if args['----'] == 1:
- status = 0
- return status
-
-def movetotrash(path):
- """move the object to the trash"""
- fss = Carbon.File.FSSpec(path)
- trashfolder = Carbon.Folder.FSFindFolder(fss.as_tuple()[0], 'trsh', 0)
- move(path, trashfolder)
-
-def emptytrash():
- """empty the trash"""
- finder = _getfinder()
- args = {}
- attrs = {}
- args['----'] = aetypes.ObjectSpecifier(want=aetypes.Type('prop'), form="prop", seld=aetypes.Type('trsh'), fr=None)
- _reply, args, attrs = finder.send("fndr", "empt", args, attrs)
- if 'errn' in args:
- raise aetools.Error, aetools.decodeerror(args)
-
-
-def _test():
- import EasyDialogs
- print 'Original findertools functionality test...'
- print 'Testing launch...'
- pathname = EasyDialogs.AskFileForOpen('File to launch:')
- if pathname:
- result = launch(pathname)
- if result:
- print 'Result: ', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing print...'
- pathname = EasyDialogs.AskFileForOpen('File to print:')
- if pathname:
- result = Print(pathname)
- if result:
- print 'Result: ', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing copy...'
- pathname = EasyDialogs.AskFileForOpen('File to copy:')
- if pathname:
- destdir = EasyDialogs.AskFolder('Destination:')
- if destdir:
- result = copy(pathname, destdir)
- if result:
- print 'Result:', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing move...'
- pathname = EasyDialogs.AskFileForOpen('File to move:')
- if pathname:
- destdir = EasyDialogs.AskFolder('Destination:')
- if destdir:
- result = move(pathname, destdir)
- if result:
- print 'Result:', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing sleep...'
- if EasyDialogs.AskYesNoCancel('Sleep?') > 0:
- result = sleep()
- if result:
- print 'Result:', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing shutdown...'
- if EasyDialogs.AskYesNoCancel('Shut down?') > 0:
- result = shutdown()
- if result:
- print 'Result:', result
- print 'Press return-',
- sys.stdin.readline()
- print 'Testing restart...'
- if EasyDialogs.AskYesNoCancel('Restart?') > 0:
- result = restart()
- if result:
- print 'Result:', result
- print 'Press return-',
- sys.stdin.readline()
-
-def _test2():
- print '\nmorefindertools version %s\nTests coming up...' %__version__
- import os
- import random
-
- # miscellaneous
- print '\tfilesharing on?', filesharing() # is file sharing on, off, starting up?
- print '\tOS version', OSversion() # the version of the system software
-
- # set the soundvolume in a simple way
- print '\tSystem beep volume'
- for i in range(0, 7):
- volumelevel(i)
- MacOS.SysBeep()
-
- # Finder's windows, file location, file attributes
- open("@findertoolstest", "w")
- f = "@findertoolstest"
- reveal(f) # reveal this file in a Finder window
- select(f) # select this file
-
- base, file = os.path.split(f)
- closewindow(base) # close the window this file is in (opened by reveal)
- openwindow(base) # open it again
- windowview(base, 1) # set the view by list
-
- label(f, 2) # set the label of this file to something orange
- print '\tlabel', label(f) # get the label of this file
-
- # the file location only works in a window with icon view!
- print 'Random locations for an icon'
- windowview(base, 0) # set the view by icon
- windowsize(base, (600, 600))
- for i in range(50):
- location(f, (random.randint(10, 590), random.randint(10, 590)))
-
- windowsize(base, (200, 400))
- windowview(base, 1) # set the view by icon
-
- orgpos = windowposition(base)
- print 'Animated window location'
- for i in range(10):
- pos = (100+i*10, 100+i*10)
- windowposition(base, pos)
- print '\twindow position', pos
- windowposition(base, orgpos) # park it where it was before
-
- print 'Put a comment in file', f, ':'
- print '\t', comment(f) # print the Finder comment this file has
- s = 'This is a comment no one reads!'
- comment(f, s) # set the Finder comment
-
-def _test3():
- print 'MacOS9 or better specific functions'
- # processes
- pr = processes() # return a list of tuples with (active_processname, creatorcode)
- print 'Return a list of current active processes:'
- for p in pr:
- print '\t', p
-
- # get attributes of the first process in the list
- print 'Attributes of the first process in the list:'
- pinfo = processinfo(pr[0][0])
- print '\t', pr[0][0]
- print '\t\tmemory partition', pinfo.partition # the memory allocated to this process
- print '\t\tmemory used', pinfo.used # the memory actuall used by this process
- print '\t\tis visible', pinfo.visible # is the process visible to the user
- print '\t\tis frontmost', pinfo.frontmost # is the process the front most one?
- print '\t\thas scripting', pinfo.hasscripting # is the process scriptable?
- print '\t\taccepts high level events', pinfo.accepthighlevel # does the process accept high level appleevents?
-
-if __name__ == '__main__':
- _test()
- _test2()
- _test3()
diff --git a/Lib/plat-mac/gensuitemodule.py b/Lib/plat-mac/gensuitemodule.py
deleted file mode 100644
index 2bae08a4def..00000000000
--- a/Lib/plat-mac/gensuitemodule.py
+++ /dev/null
@@ -1,1216 +0,0 @@
-"""
-gensuitemodule - Generate an AE suite module from an aete/aeut resource
-
-Based on aete.py.
-
-Reading and understanding this code is left as an exercise to the reader.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the gensuitemodule module is removed.", stacklevel=2)
-
-import MacOS
-import EasyDialogs
-import os
-import string
-import sys
-import types
-import StringIO
-import keyword
-import macresource
-import aetools
-import distutils.sysconfig
-import OSATerminology
-from Carbon.Res import *
-import Carbon.Folder
-import MacOS
-import getopt
-import plistlib
-
-_MAC_LIB_FOLDER=os.path.dirname(aetools.__file__)
-DEFAULT_STANDARD_PACKAGEFOLDER=os.path.join(_MAC_LIB_FOLDER, 'lib-scriptpackages')
-DEFAULT_USER_PACKAGEFOLDER=distutils.sysconfig.get_python_lib()
-
-def usage():
- sys.stderr.write("Usage: %s [opts] application-or-resource-file\n" % sys.argv[0])
- sys.stderr.write("""Options:
---output pkgdir Pathname of the output package (short: -o)
---resource Parse resource file in stead of launching application (-r)
---base package Use another base package in stead of default StdSuites (-b)
---edit old=new Edit suite names, use empty new to skip a suite (-e)
---creator code Set creator code for package (-c)
---dump Dump aete resource to stdout in stead of creating module (-d)
---verbose Tell us what happens (-v)
-""")
- sys.exit(1)
-
-def main():
- if len(sys.argv) > 1:
- SHORTOPTS = "rb:o:e:c:dv"
- LONGOPTS = ("resource", "base=", "output=", "edit=", "creator=", "dump", "verbose")
- try:
- opts, args = getopt.getopt(sys.argv[1:], SHORTOPTS, LONGOPTS)
- except getopt.GetoptError:
- usage()
-
- process_func = processfile
- basepkgname = 'StdSuites'
- output = None
- edit_modnames = []
- creatorsignature = None
- dump = None
- verbose = None
-
- for o, a in opts:
- if o in ('-r', '--resource'):
- process_func = processfile_fromresource
- if o in ('-b', '--base'):
- basepkgname = a
- if o in ('-o', '--output'):
- output = a
- if o in ('-e', '--edit'):
- split = a.split('=')
- if len(split) != 2:
- usage()
- edit_modnames.append(split)
- if o in ('-c', '--creator'):
- if len(a) != 4:
- sys.stderr.write("creator must be 4-char string\n")
- sys.exit(1)
- creatorsignature = a
- if o in ('-d', '--dump'):
- dump = sys.stdout
- if o in ('-v', '--verbose'):
- verbose = sys.stderr
-
-
- if output and len(args) > 1:
- sys.stderr.write("%s: cannot specify --output with multiple inputs\n" % sys.argv[0])
- sys.exit(1)
-
- for filename in args:
- process_func(filename, output=output, basepkgname=basepkgname,
- edit_modnames=edit_modnames, creatorsignature=creatorsignature,
- dump=dump, verbose=verbose)
- else:
- main_interactive()
-
-def main_interactive(interact=0, basepkgname='StdSuites'):
- if interact:
- # Ask for save-filename for each module
- edit_modnames = None
- else:
- # Use default filenames for each module
- edit_modnames = []
- appsfolder = Carbon.Folder.FSFindFolder(-32765, 'apps', 0)
- filename = EasyDialogs.AskFileForOpen(
- message='Select scriptable application',
- dialogOptionFlags=0x1056, # allow selection of .app bundles
- defaultLocation=appsfolder)
- if not filename:
- return
- if not is_scriptable(filename):
- if EasyDialogs.AskYesNoCancel(
- "Warning: application does not seem scriptable",
- yes="Continue", default=2, no="") <= 0:
- return
- try:
- processfile(filename, edit_modnames=edit_modnames, basepkgname=basepkgname,
- verbose=sys.stderr)
- except MacOS.Error, arg:
- print "Error getting terminology:", arg
- print "Retry, manually parsing resources"
- processfile_fromresource(filename, edit_modnames=edit_modnames,
- basepkgname=basepkgname, verbose=sys.stderr)
-
-def is_scriptable(application):
- """Return true if the application is scriptable"""
- if os.path.isdir(application):
- plistfile = os.path.join(application, 'Contents', 'Info.plist')
- if not os.path.exists(plistfile):
- return False
- plist = plistlib.Plist.fromFile(plistfile)
- return plist.get('NSAppleScriptEnabled', False)
- # If it is a file test for an aete/aeut resource.
- currf = CurResFile()
- try:
- refno = macresource.open_pathname(application)
- except MacOS.Error:
- return False
- UseResFile(refno)
- n_terminology = Count1Resources('aete') + Count1Resources('aeut') + \
- Count1Resources('scsz') + Count1Resources('osiz')
- CloseResFile(refno)
- UseResFile(currf)
- return n_terminology > 0
-
-def processfile_fromresource(fullname, output=None, basepkgname=None,
- edit_modnames=None, creatorsignature=None, dump=None, verbose=None):
- """Process all resources in a single file"""
- if not is_scriptable(fullname) and verbose:
- print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
- cur = CurResFile()
- if verbose:
- print >>verbose, "Processing", fullname
- rf = macresource.open_pathname(fullname)
- try:
- UseResFile(rf)
- resources = []
- for i in range(Count1Resources('aete')):
- res = Get1IndResource('aete', 1+i)
- resources.append(res)
- for i in range(Count1Resources('aeut')):
- res = Get1IndResource('aeut', 1+i)
- resources.append(res)
- if verbose:
- print >>verbose, "\nLISTING aete+aeut RESOURCES IN", repr(fullname)
- aetelist = []
- for res in resources:
- if verbose:
- print >>verbose, "decoding", res.GetResInfo(), "..."
- data = res.data
- aete = decode(data, verbose)
- aetelist.append((aete, res.GetResInfo()))
- finally:
- if rf != cur:
- CloseResFile(rf)
- UseResFile(cur)
- # switch back (needed for dialogs in Python)
- UseResFile(cur)
- if dump:
- dumpaetelist(aetelist, dump)
- compileaetelist(aetelist, fullname, output=output,
- basepkgname=basepkgname, edit_modnames=edit_modnames,
- creatorsignature=creatorsignature, verbose=verbose)
-
-def processfile(fullname, output=None, basepkgname=None,
- edit_modnames=None, creatorsignature=None, dump=None,
- verbose=None):
- """Ask an application for its terminology and process that"""
- if not is_scriptable(fullname) and verbose:
- print >>verbose, "Warning: app does not seem scriptable: %s" % fullname
- if verbose:
- print >>verbose, "\nASKING FOR aete DICTIONARY IN", repr(fullname)
- try:
- aedescobj, launched = OSATerminology.GetAppTerminology(fullname)
- except MacOS.Error, arg:
- if arg[0] in (-1701, -192): # errAEDescNotFound, resNotFound
- if verbose:
- print >>verbose, "GetAppTerminology failed with errAEDescNotFound/resNotFound, trying manually"
- aedata, sig = getappterminology(fullname, verbose=verbose)
- if not creatorsignature:
- creatorsignature = sig
- else:
- raise
- else:
- if launched:
- if verbose:
- print >>verbose, "Launched", fullname
- raw = aetools.unpack(aedescobj)
- if not raw:
- if verbose:
- print >>verbose, 'Unpack returned empty value:', raw
- return
- if not raw[0].data:
- if verbose:
- print >>verbose, 'Unpack returned value without data:', raw
- return
- aedata = raw[0]
- aete = decode(aedata.data, verbose)
- if dump:
- dumpaetelist([aete], dump)
- return
- compileaete(aete, None, fullname, output=output, basepkgname=basepkgname,
- creatorsignature=creatorsignature, edit_modnames=edit_modnames,
- verbose=verbose)
-
-def getappterminology(fullname, verbose=None):
- """Get application terminology by sending an AppleEvent"""
- # First check that we actually can send AppleEvents
- if not MacOS.WMAvailable():
- raise RuntimeError, "Cannot send AppleEvents, no access to window manager"
- # Next, a workaround for a bug in MacOS 10.2: sending events will hang unless
- # you have created an event loop first.
- import Carbon.Evt
- Carbon.Evt.WaitNextEvent(0,0)
- if os.path.isdir(fullname):
- # Now get the signature of the application, hoping it is a bundle
- pkginfo = os.path.join(fullname, 'Contents', 'PkgInfo')
- if not os.path.exists(pkginfo):
- raise RuntimeError, "No PkgInfo file found"
- tp_cr = open(pkginfo, 'rb').read()
- cr = tp_cr[4:8]
- else:
- # Assume it is a file
- cr, tp = MacOS.GetCreatorAndType(fullname)
- # Let's talk to it and ask for its AETE
- talker = aetools.TalkTo(cr)
- try:
- talker._start()
- except (MacOS.Error, aetools.Error), arg:
- if verbose:
- print >>verbose, 'Warning: start() failed, continuing anyway:', arg
- reply = talker.send("ascr", "gdte")
- #reply2 = talker.send("ascr", "gdut")
- # Now pick the bits out of the return that we need.
- return reply[1]['----'], cr
-
-
-def compileaetelist(aetelist, fullname, output=None, basepkgname=None,
- edit_modnames=None, creatorsignature=None, verbose=None):
- for aete, resinfo in aetelist:
- compileaete(aete, resinfo, fullname, output=output,
- basepkgname=basepkgname, edit_modnames=edit_modnames,
- creatorsignature=creatorsignature, verbose=verbose)
-
-def dumpaetelist(aetelist, output):
- import pprint
- pprint.pprint(aetelist, output)
-
-def decode(data, verbose=None):
- """Decode a resource into a python data structure"""
- f = StringIO.StringIO(data)
- aete = generic(getaete, f)
- aete = simplify(aete)
- processed = f.tell()
- unprocessed = len(f.read())
- total = f.tell()
- if unprocessed and verbose:
- verbose.write("%d processed + %d unprocessed = %d total\n" %
- (processed, unprocessed, total))
- return aete
-
-def simplify(item):
- """Recursively replace singleton tuples by their constituent item"""
- if type(item) is types.ListType:
- return map(simplify, item)
- elif type(item) == types.TupleType and len(item) == 2:
- return simplify(item[1])
- else:
- return item
-
-
-# Here follows the aete resource decoder.
-# It is presented bottom-up instead of top-down because there are direct
-# references to the lower-level part-decoders from the high-level part-decoders.
-
-def getbyte(f, *args):
- c = f.read(1)
- if not c:
- raise EOFError, 'in getbyte' + str(args)
- return ord(c)
-
-def getword(f, *args):
- getalign(f)
- s = f.read(2)
- if len(s) < 2:
- raise EOFError, 'in getword' + str(args)
- return (ord(s[0])<<8) | ord(s[1])
-
-def getlong(f, *args):
- getalign(f)
- s = f.read(4)
- if len(s) < 4:
- raise EOFError, 'in getlong' + str(args)
- return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
-
-def getostype(f, *args):
- getalign(f)
- s = f.read(4)
- if len(s) < 4:
- raise EOFError, 'in getostype' + str(args)
- return s
-
-def getpstr(f, *args):
- c = f.read(1)
- if len(c) < 1:
- raise EOFError, 'in getpstr[1]' + str(args)
- nbytes = ord(c)
- if nbytes == 0: return ''
- s = f.read(nbytes)
- if len(s) < nbytes:
- raise EOFError, 'in getpstr[2]' + str(args)
- return s
-
-def getalign(f):
- if f.tell() & 1:
- c = f.read(1)
- ##if c != '\0':
- ## print align:', repr(c)
-
-def getlist(f, description, getitem):
- count = getword(f)
- list = []
- for i in range(count):
- list.append(generic(getitem, f))
- getalign(f)
- return list
-
-def alt_generic(what, f, *args):
- print "generic", repr(what), args
- res = vageneric(what, f, args)
- print '->', repr(res)
- return res
-
-def generic(what, f, *args):
- if type(what) == types.FunctionType:
- return apply(what, (f,) + args)
- if type(what) == types.ListType:
- record = []
- for thing in what:
- item = apply(generic, thing[:1] + (f,) + thing[1:])
- record.append((thing[1], item))
- return record
- return "BAD GENERIC ARGS: %r" % (what,)
-
-getdata = [
- (getostype, "type"),
- (getpstr, "description"),
- (getword, "flags")
- ]
-getargument = [
- (getpstr, "name"),
- (getostype, "keyword"),
- (getdata, "what")
- ]
-getevent = [
- (getpstr, "name"),
- (getpstr, "description"),
- (getostype, "suite code"),
- (getostype, "event code"),
- (getdata, "returns"),
- (getdata, "accepts"),
- (getlist, "optional arguments", getargument)
- ]
-getproperty = [
- (getpstr, "name"),
- (getostype, "code"),
- (getdata, "what")
- ]
-getelement = [
- (getostype, "type"),
- (getlist, "keyform", getostype)
- ]
-getclass = [
- (getpstr, "name"),
- (getostype, "class code"),
- (getpstr, "description"),
- (getlist, "properties", getproperty),
- (getlist, "elements", getelement)
- ]
-getcomparison = [
- (getpstr, "operator name"),
- (getostype, "operator ID"),
- (getpstr, "operator comment"),
- ]
-getenumerator = [
- (getpstr, "enumerator name"),
- (getostype, "enumerator ID"),
- (getpstr, "enumerator comment")
- ]
-getenumeration = [
- (getostype, "enumeration ID"),
- (getlist, "enumerator", getenumerator)
- ]
-getsuite = [
- (getpstr, "suite name"),
- (getpstr, "suite description"),
- (getostype, "suite ID"),
- (getword, "suite level"),
- (getword, "suite version"),
- (getlist, "events", getevent),
- (getlist, "classes", getclass),
- (getlist, "comparisons", getcomparison),
- (getlist, "enumerations", getenumeration)
- ]
-getaete = [
- (getword, "major/minor version in BCD"),
- (getword, "language code"),
- (getword, "script code"),
- (getlist, "suites", getsuite)
- ]
-
-def compileaete(aete, resinfo, fname, output=None, basepkgname=None,
- edit_modnames=None, creatorsignature=None, verbose=None):
- """Generate code for a full aete resource. fname passed for doc purposes"""
- [version, language, script, suites] = aete
- major, minor = divmod(version, 256)
- if not creatorsignature:
- creatorsignature, dummy = MacOS.GetCreatorAndType(fname)
- packagename = identify(os.path.splitext(os.path.basename(fname))[0])
- if language:
- packagename = packagename+'_lang%d'%language
- if script:
- packagename = packagename+'_script%d'%script
- if len(packagename) > 27:
- packagename = packagename[:27]
- if output:
- # XXXX Put this in site-packages if it isn't a full pathname?
- if not os.path.exists(output):
- os.mkdir(output)
- pathname = output
- else:
- pathname = EasyDialogs.AskFolder(message='Create and select package folder for %s'%packagename,
- defaultLocation=DEFAULT_USER_PACKAGEFOLDER)
- output = pathname
- if not pathname:
- return
- packagename = os.path.split(os.path.normpath(pathname))[1]
- if not basepkgname:
- basepkgname = EasyDialogs.AskFolder(message='Package folder for base suite (usually StdSuites)',
- defaultLocation=DEFAULT_STANDARD_PACKAGEFOLDER)
- if basepkgname:
- dirname, basepkgname = os.path.split(os.path.normpath(basepkgname))
- if dirname and not dirname in sys.path:
- sys.path.insert(0, dirname)
- basepackage = __import__(basepkgname)
- else:
- basepackage = None
- suitelist = []
- allprecompinfo = []
- allsuites = []
- for suite in suites:
- compiler = SuiteCompiler(suite, basepackage, output, edit_modnames, verbose)
- code, modname, precompinfo = compiler.precompilesuite()
- if not code:
- continue
- allprecompinfo = allprecompinfo + precompinfo
- suiteinfo = suite, pathname, modname
- suitelist.append((code, modname))
- allsuites.append(compiler)
- for compiler in allsuites:
- compiler.compilesuite(major, minor, language, script, fname, allprecompinfo)
- initfilename = os.path.join(output, '__init__.py')
- fp = open(initfilename, 'w')
- MacOS.SetCreatorAndType(initfilename, 'Pyth', 'TEXT')
- fp.write('"""\n')
- fp.write("Package generated from %s\n"%ascii(fname))
- if resinfo:
- fp.write("Resource %s resid %d %s\n"%(ascii(resinfo[1]), resinfo[0], ascii(resinfo[2])))
- fp.write('"""\n')
- fp.write('import aetools\n')
- fp.write('Error = aetools.Error\n')
- suitelist.sort()
- for code, modname in suitelist:
- fp.write("import %s\n" % modname)
- fp.write("\n\n_code_to_module = {\n")
- for code, modname in suitelist:
- fp.write(" '%s' : %s,\n"%(ascii(code), modname))
- fp.write("}\n\n")
- fp.write("\n\n_code_to_fullname = {\n")
- for code, modname in suitelist:
- fp.write(" '%s' : ('%s.%s', '%s'),\n"%(ascii(code), packagename, modname, modname))
- fp.write("}\n\n")
- for code, modname in suitelist:
- fp.write("from %s import *\n"%modname)
-
- # Generate property dicts and element dicts for all types declared in this module
- fp.write("\ndef getbaseclasses(v):\n")
- fp.write(" if not getattr(v, '_propdict', None):\n")
- fp.write(" v._propdict = {}\n")
- fp.write(" v._elemdict = {}\n")
- fp.write(" for superclassname in getattr(v, '_superclassnames', []):\n")
- fp.write(" superclass = eval(superclassname)\n")
- fp.write(" getbaseclasses(superclass)\n")
- fp.write(" v._propdict.update(getattr(superclass, '_propdict', {}))\n")
- fp.write(" v._elemdict.update(getattr(superclass, '_elemdict', {}))\n")
- fp.write(" v._propdict.update(getattr(v, '_privpropdict', {}))\n")
- fp.write(" v._elemdict.update(getattr(v, '_privelemdict', {}))\n")
- fp.write("\n")
- fp.write("import StdSuites\n")
- allprecompinfo.sort()
- if allprecompinfo:
- fp.write("\n#\n# Set property and element dictionaries now that all classes have been defined\n#\n")
- for codenamemapper in allprecompinfo:
- for k, v in codenamemapper.getall('class'):
- fp.write("getbaseclasses(%s)\n" % v)
-
- # Generate a code-to-name mapper for all of the types (classes) declared in this module
- application_class = None
- if allprecompinfo:
- fp.write("\n#\n# Indices of types declared in this module\n#\n")
- fp.write("_classdeclarations = {\n")
- for codenamemapper in allprecompinfo:
- for k, v in codenamemapper.getall('class'):
- fp.write(" %r : %s,\n" % (k, v))
- if k == 'capp':
- application_class = v
- fp.write("}\n")
-
-
- if suitelist:
- fp.write("\n\nclass %s(%s_Events"%(packagename, suitelist[0][1]))
- for code, modname in suitelist[1:]:
- fp.write(",\n %s_Events"%modname)
- fp.write(",\n aetools.TalkTo):\n")
- fp.write(" _signature = %r\n\n"%(creatorsignature,))
- fp.write(" _moduleName = '%s'\n\n"%packagename)
- if application_class:
- fp.write(" _elemdict = %s._elemdict\n" % application_class)
- fp.write(" _propdict = %s._propdict\n" % application_class)
- fp.close()
-
-class SuiteCompiler:
- def __init__(self, suite, basepackage, output, edit_modnames, verbose):
- self.suite = suite
- self.basepackage = basepackage
- self.edit_modnames = edit_modnames
- self.output = output
- self.verbose = verbose
-
- # Set by precompilesuite
- self.pathname = None
- self.modname = None
-
- # Set by compilesuite
- self.fp = None
- self.basemodule = None
- self.enumsneeded = {}
-
- def precompilesuite(self):
- """Parse a single suite without generating the output. This step is needed
- so we can resolve recursive references by suites to enums/comps/etc declared
- in other suites"""
- [name, desc, code, level, version, events, classes, comps, enums] = self.suite
-
- modname = identify(name)
- if len(modname) > 28:
- modname = modname[:27]
- if self.edit_modnames is None:
- self.pathname = EasyDialogs.AskFileForSave(message='Python output file',
- savedFileName=modname+'.py')
- else:
- for old, new in self.edit_modnames:
- if old == modname:
- modname = new
- if modname:
- self.pathname = os.path.join(self.output, modname + '.py')
- else:
- self.pathname = None
- if not self.pathname:
- return None, None, None
-
- self.modname = os.path.splitext(os.path.split(self.pathname)[1])[0]
-
- if self.basepackage and code in self.basepackage._code_to_module:
- # We are an extension of a baseclass (usually an application extending
- # Standard_Suite or so). Import everything from our base module
- basemodule = self.basepackage._code_to_module[code]
- else:
- # We are not an extension.
- basemodule = None
-
- self.enumsneeded = {}
- for event in events:
- self.findenumsinevent(event)
-
- objc = ObjectCompiler(None, self.modname, basemodule, interact=(self.edit_modnames is None),
- verbose=self.verbose)
- for cls in classes:
- objc.compileclass(cls)
- for cls in classes:
- objc.fillclasspropsandelems(cls)
- for comp in comps:
- objc.compilecomparison(comp)
- for enum in enums:
- objc.compileenumeration(enum)
-
- for enum in self.enumsneeded.keys():
- objc.checkforenum(enum)
-
- objc.dumpindex()
-
- precompinfo = objc.getprecompinfo(self.modname)
-
- return code, self.modname, precompinfo
-
- def compilesuite(self, major, minor, language, script, fname, precompinfo):
- """Generate code for a single suite"""
- [name, desc, code, level, version, events, classes, comps, enums] = self.suite
- # Sort various lists, so re-generated source is easier compared
- def class_sorter(k1, k2):
- """Sort classes by code, and make sure main class sorts before synonyms"""
- # [name, code, desc, properties, elements] = cls
- if k1[1] < k2[1]: return -1
- if k1[1] > k2[1]: return 1
- if not k2[3] or k2[3][0][1] == 'c@#!':
- # This is a synonym, the other one is better
- return -1
- if not k1[3] or k1[3][0][1] == 'c@#!':
- # This is a synonym, the other one is better
- return 1
- return 0
-
- events.sort()
- classes.sort(class_sorter)
- comps.sort()
- enums.sort()
-
- self.fp = fp = open(self.pathname, 'w')
- MacOS.SetCreatorAndType(self.pathname, 'Pyth', 'TEXT')
-
- fp.write('"""Suite %s: %s\n' % (ascii(name), ascii(desc)))
- fp.write("Level %d, version %d\n\n" % (level, version))
- fp.write("Generated from %s\n"%ascii(fname))
- fp.write("AETE/AEUT resource version %d/%d, language %d, script %d\n" % \
- (major, minor, language, script))
- fp.write('"""\n\n')
-
- fp.write('import aetools\n')
- fp.write('import MacOS\n\n')
- fp.write("_code = %r\n\n"% (code,))
- if self.basepackage and code in self.basepackage._code_to_module:
- # We are an extension of a baseclass (usually an application extending
- # Standard_Suite or so). Import everything from our base module
- fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code][0])
- basemodule = self.basepackage._code_to_module[code]
- elif self.basepackage and code.lower() in self.basepackage._code_to_module:
- # This is needed by CodeWarrior and some others.
- fp.write('from %s import *\n'%self.basepackage._code_to_fullname[code.lower()][0])
- basemodule = self.basepackage._code_to_module[code.lower()]
- else:
- # We are not an extension.
- basemodule = None
- self.basemodule = basemodule
- self.compileclassheader()
-
- self.enumsneeded = {}
- if events:
- for event in events:
- self.compileevent(event)
- else:
- fp.write(" pass\n\n")
-
- objc = ObjectCompiler(fp, self.modname, basemodule, precompinfo, interact=(self.edit_modnames is None),
- verbose=self.verbose)
- for cls in classes:
- objc.compileclass(cls)
- for cls in classes:
- objc.fillclasspropsandelems(cls)
- for comp in comps:
- objc.compilecomparison(comp)
- for enum in enums:
- objc.compileenumeration(enum)
-
- for enum in self.enumsneeded.keys():
- objc.checkforenum(enum)
-
- objc.dumpindex()
-
- def compileclassheader(self):
- """Generate class boilerplate"""
- classname = '%s_Events'%self.modname
- if self.basemodule:
- modshortname = string.split(self.basemodule.__name__, '.')[-1]
- baseclassname = '%s_Events'%modshortname
- self.fp.write("class %s(%s):\n\n"%(classname, baseclassname))
- else:
- self.fp.write("class %s:\n\n"%classname)
-
- def compileevent(self, event):
- """Generate code for a single event"""
- [name, desc, code, subcode, returns, accepts, arguments] = event
- fp = self.fp
- funcname = identify(name)
- #
- # generate name->keyword map
- #
- if arguments:
- fp.write(" _argmap_%s = {\n"%funcname)
- for a in arguments:
- fp.write(" %r : %r,\n"%(identify(a[0]), a[1]))
- fp.write(" }\n\n")
-
- #
- # Generate function header
- #
- has_arg = (not is_null(accepts))
- opt_arg = (has_arg and is_optional(accepts))
-
- fp.write(" def %s(self, "%funcname)
- if has_arg:
- if not opt_arg:
- fp.write("_object, ") # Include direct object, if it has one
- else:
- fp.write("_object=None, ") # Also include if it is optional
- else:
- fp.write("_no_object=None, ") # For argument checking
- fp.write("_attributes={}, **_arguments):\n") # include attribute dict and args
- #
- # Generate doc string (important, since it may be the only
- # available documentation, due to our name-remaping)
- #
- fp.write(' """%s: %s\n'%(ascii(name), ascii(desc)))
- if has_arg:
- fp.write(" Required argument: %s\n"%getdatadoc(accepts))
- elif opt_arg:
- fp.write(" Optional argument: %s\n"%getdatadoc(accepts))
- for arg in arguments:
- fp.write(" Keyword argument %s: %s\n"%(identify(arg[0]),
- getdatadoc(arg[2])))
- fp.write(" Keyword argument _attributes: AppleEvent attribute dictionary\n")
- if not is_null(returns):
- fp.write(" Returns: %s\n"%getdatadoc(returns))
- fp.write(' """\n')
- #
- # Fiddle the args so everything ends up in 'arguments' dictionary
- #
- fp.write(" _code = %r\n"% (code,))
- fp.write(" _subcode = %r\n\n"% (subcode,))
- #
- # Do keyword name substitution
- #
- if arguments:
- fp.write(" aetools.keysubst(_arguments, self._argmap_%s)\n"%funcname)
- else:
- fp.write(" if _arguments: raise TypeError, 'No optional args expected'\n")
- #
- # Stuff required arg (if there is one) into arguments
- #
- if has_arg:
- fp.write(" _arguments['----'] = _object\n")
- elif opt_arg:
- fp.write(" if _object:\n")
- fp.write(" _arguments['----'] = _object\n")
- else:
- fp.write(" if _no_object is not None: raise TypeError, 'No direct arg expected'\n")
- fp.write("\n")
- #
- # Do enum-name substitution
- #
- for a in arguments:
- if is_enum(a[2]):
- kname = a[1]
- ename = a[2][0]
- if ename != '****':
- fp.write(" aetools.enumsubst(_arguments, %r, _Enum_%s)\n" %
- (kname, identify(ename)))
- self.enumsneeded[ename] = 1
- fp.write("\n")
- #
- # Do the transaction
- #
- fp.write(" _reply, _arguments, _attributes = self.send(_code, _subcode,\n")
- fp.write(" _arguments, _attributes)\n")
- #
- # Error handling
- #
- fp.write(" if _arguments.get('errn', 0):\n")
- fp.write(" raise aetools.Error, aetools.decodeerror(_arguments)\n")
- fp.write(" # XXXX Optionally decode result\n")
- #
- # Decode result
- #
- fp.write(" if '----' in _arguments:\n")
- if is_enum(returns):
- fp.write(" # XXXX Should do enum remapping here...\n")
- fp.write(" return _arguments['----']\n")
- fp.write("\n")
-
- def findenumsinevent(self, event):
- """Find all enums for a single event"""
- [name, desc, code, subcode, returns, accepts, arguments] = event
- for a in arguments:
- if is_enum(a[2]):
- ename = a[2][0]
- if ename != '****':
- self.enumsneeded[ename] = 1
-
-#
-# This class stores the code<->name translations for a single module. It is used
-# to keep the information while we're compiling the module, but we also keep these objects
-# around so if one suite refers to, say, an enum in another suite we know where to
-# find it. Finally, if we really can't find a code, the user can add modules by
-# hand.
-#
-class CodeNameMapper:
-
- def __init__(self, interact=1, verbose=None):
- self.code2name = {
- "property" : {},
- "class" : {},
- "enum" : {},
- "comparison" : {},
- }
- self.name2code = {
- "property" : {},
- "class" : {},
- "enum" : {},
- "comparison" : {},
- }
- self.modulename = None
- self.star_imported = 0
- self.can_interact = interact
- self.verbose = verbose
-
- def addnamecode(self, type, name, code):
- self.name2code[type][name] = code
- if code not in self.code2name[type]:
- self.code2name[type][code] = name
-
- def hasname(self, name):
- for dict in self.name2code.values():
- if name in dict:
- return True
- return False
-
- def hascode(self, type, code):
- return code in self.code2name[type]
-
- def findcodename(self, type, code):
- if not self.hascode(type, code):
- return None, None, None
- name = self.code2name[type][code]
- if self.modulename and not self.star_imported:
- qualname = '%s.%s'%(self.modulename, name)
- else:
- qualname = name
- return name, qualname, self.modulename
-
- def getall(self, type):
- return self.code2name[type].items()
-
- def addmodule(self, module, name, star_imported):
- self.modulename = name
- self.star_imported = star_imported
- for code, name in module._propdeclarations.items():
- self.addnamecode('property', name, code)
- for code, name in module._classdeclarations.items():
- self.addnamecode('class', name, code)
- for code in module._enumdeclarations.keys():
- self.addnamecode('enum', '_Enum_'+identify(code), code)
- for code, name in module._compdeclarations.items():
- self.addnamecode('comparison', name, code)
-
- def prepareforexport(self, name=None):
- if not self.modulename:
- self.modulename = name
- return self
-
-class ObjectCompiler:
- def __init__(self, fp, modname, basesuite, othernamemappers=None, interact=1,
- verbose=None):
- self.fp = fp
- self.verbose = verbose
- self.basesuite = basesuite
- self.can_interact = interact
- self.modulename = modname
- self.namemappers = [CodeNameMapper(self.can_interact, self.verbose)]
- if othernamemappers:
- self.othernamemappers = othernamemappers[:]
- else:
- self.othernamemappers = []
- if basesuite:
- basemapper = CodeNameMapper(self.can_interact, self.verbose)
- basemapper.addmodule(basesuite, '', 1)
- self.namemappers.append(basemapper)
-
- def getprecompinfo(self, modname):
- list = []
- for mapper in self.namemappers:
- emapper = mapper.prepareforexport(modname)
- if emapper:
- list.append(emapper)
- return list
-
- def findcodename(self, type, code):
- while 1:
- # First try: check whether we already know about this code.
- for mapper in self.namemappers:
- if mapper.hascode(type, code):
- return mapper.findcodename(type, code)
- # Second try: maybe one of the other modules knows about it.
- for mapper in self.othernamemappers:
- if mapper.hascode(type, code):
- self.othernamemappers.remove(mapper)
- self.namemappers.append(mapper)
- if self.fp:
- self.fp.write("import %s\n"%mapper.modulename)
- break
- else:
- # If all this has failed we ask the user for a guess on where it could
- # be and retry.
- if self.fp:
- m = self.askdefinitionmodule(type, code)
- else:
- m = None
- if not m: return None, None, None
- mapper = CodeNameMapper(self.can_interact, self.verbose)
- mapper.addmodule(m, m.__name__, 0)
- self.namemappers.append(mapper)
-
- def hasname(self, name):
- for mapper in self.othernamemappers:
- if mapper.hasname(name) and mapper.modulename != self.modulename:
- if self.verbose:
- print >>self.verbose, "Duplicate Python identifier:", name, self.modulename, mapper.modulename
- return True
- return False
-
- def askdefinitionmodule(self, type, code):
- if not self.can_interact:
- if self.verbose:
- print >>self.verbose, "** No definition for %s '%s' found" % (type, code)
- return None
- path = EasyDialogs.AskFileForSave(message='Where is %s %s declared?'%(type, code))
- if not path: return
- path, file = os.path.split(path)
- modname = os.path.splitext(file)[0]
- if not path in sys.path:
- sys.path.insert(0, path)
- m = __import__(modname)
- self.fp.write("import %s\n"%modname)
- return m
-
- def compileclass(self, cls):
- [name, code, desc, properties, elements] = cls
- pname = identify(name)
- if self.namemappers[0].hascode('class', code):
- # plural forms and such
- othername, dummy, dummy = self.namemappers[0].findcodename('class', code)
- if self.fp:
- self.fp.write("\n%s = %s\n"%(pname, othername))
- else:
- if self.fp:
- self.fp.write('\nclass %s(aetools.ComponentItem):\n' % pname)
- self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(desc)))
- self.fp.write(' want = %r\n' % (code,))
- self.namemappers[0].addnamecode('class', pname, code)
- is_application_class = (code == 'capp')
- properties.sort()
- for prop in properties:
- self.compileproperty(prop, is_application_class)
- elements.sort()
- for elem in elements:
- self.compileelement(elem)
-
- def compileproperty(self, prop, is_application_class=False):
- [name, code, what] = prop
- if code == 'c@#!':
- # Something silly with plurals. Skip it.
- return
- pname = identify(name)
- if self.namemappers[0].hascode('property', code):
- # plural forms and such
- othername, dummy, dummy = self.namemappers[0].findcodename('property', code)
- if pname == othername:
- return
- if self.fp:
- self.fp.write("\n_Prop_%s = _Prop_%s\n"%(pname, othername))
- else:
- if self.fp:
- self.fp.write("class _Prop_%s(aetools.NProperty):\n" % pname)
- self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(what[1])))
- self.fp.write(" which = %r\n" % (code,))
- self.fp.write(" want = %r\n" % (what[0],))
- self.namemappers[0].addnamecode('property', pname, code)
- if is_application_class and self.fp:
- self.fp.write("%s = _Prop_%s()\n" % (pname, pname))
-
- def compileelement(self, elem):
- [code, keyform] = elem
- if self.fp:
- self.fp.write("# element %r as %s\n" % (code, keyform))
-
- def fillclasspropsandelems(self, cls):
- [name, code, desc, properties, elements] = cls
- cname = identify(name)
- if self.namemappers[0].hascode('class', code) and \
- self.namemappers[0].findcodename('class', code)[0] != cname:
- # This is an other name (plural or so) for something else. Skip.
- if self.fp and (elements or len(properties) > 1 or (len(properties) == 1 and
- properties[0][1] != 'c@#!')):
- if self.verbose:
- print >>self.verbose, '** Skip multiple %s of %s (code %r)' % (cname, self.namemappers[0].findcodename('class', code)[0], code)
- raise RuntimeError, "About to skip non-empty class"
- return
- plist = []
- elist = []
- superclasses = []
- for prop in properties:
- [pname, pcode, what] = prop
- if pcode == "c@#^":
- superclasses.append(what)
- if pcode == 'c@#!':
- continue
- pname = identify(pname)
- plist.append(pname)
-
- superclassnames = []
- for superclass in superclasses:
- superId, superDesc, dummy = superclass
- superclassname, fullyqualifiedname, module = self.findcodename("class", superId)
- # I don't think this is correct:
- if superclassname == cname:
- pass # superclassnames.append(fullyqualifiedname)
- else:
- superclassnames.append(superclassname)
-
- if self.fp:
- self.fp.write("%s._superclassnames = %r\n"%(cname, superclassnames))
-
- for elem in elements:
- [ecode, keyform] = elem
- if ecode == 'c@#!':
- continue
- name, ename, module = self.findcodename('class', ecode)
- if not name:
- if self.fp:
- self.fp.write("# XXXX %s element %r not found!!\n"%(cname, ecode))
- else:
- elist.append((name, ename))
-
- plist.sort()
- elist.sort()
-
- if self.fp:
- self.fp.write("%s._privpropdict = {\n"%cname)
- for n in plist:
- self.fp.write(" '%s' : _Prop_%s,\n"%(n, n))
- self.fp.write("}\n")
- self.fp.write("%s._privelemdict = {\n"%cname)
- for n, fulln in elist:
- self.fp.write(" '%s' : %s,\n"%(n, fulln))
- self.fp.write("}\n")
-
- def compilecomparison(self, comp):
- [name, code, comment] = comp
- iname = identify(name)
- self.namemappers[0].addnamecode('comparison', iname, code)
- if self.fp:
- self.fp.write("class %s(aetools.NComparison):\n" % iname)
- self.fp.write(' """%s - %s """\n' % (ascii(name), ascii(comment)))
-
- def compileenumeration(self, enum):
- [code, items] = enum
- name = "_Enum_%s" % identify(code)
- if self.fp:
- self.fp.write("%s = {\n" % name)
- for item in items:
- self.compileenumerator(item)
- self.fp.write("}\n\n")
- self.namemappers[0].addnamecode('enum', name, code)
- return code
-
- def compileenumerator(self, item):
- [name, code, desc] = item
- self.fp.write(" %r : %r,\t# %s\n" % (identify(name), code, ascii(desc)))
-
- def checkforenum(self, enum):
- """This enum code is used by an event. Make sure it's available"""
- name, fullname, module = self.findcodename('enum', enum)
- if not name:
- if self.fp:
- self.fp.write("_Enum_%s = None # XXXX enum %s not found!!\n"%(identify(enum), ascii(enum)))
- return
- if module:
- if self.fp:
- self.fp.write("from %s import %s\n"%(module, name))
-
- def dumpindex(self):
- if not self.fp:
- return
- self.fp.write("\n#\n# Indices of types declared in this module\n#\n")
-
- self.fp.write("_classdeclarations = {\n")
- classlist = self.namemappers[0].getall('class')
- classlist.sort()
- for k, v in classlist:
- self.fp.write(" %r : %s,\n" % (k, v))
- self.fp.write("}\n")
-
- self.fp.write("\n_propdeclarations = {\n")
- proplist = self.namemappers[0].getall('property')
- proplist.sort()
- for k, v in proplist:
- self.fp.write(" %r : _Prop_%s,\n" % (k, v))
- self.fp.write("}\n")
-
- self.fp.write("\n_compdeclarations = {\n")
- complist = self.namemappers[0].getall('comparison')
- complist.sort()
- for k, v in complist:
- self.fp.write(" %r : %s,\n" % (k, v))
- self.fp.write("}\n")
-
- self.fp.write("\n_enumdeclarations = {\n")
- enumlist = self.namemappers[0].getall('enum')
- enumlist.sort()
- for k, v in enumlist:
- self.fp.write(" %r : %s,\n" % (k, v))
- self.fp.write("}\n")
-
-def compiledata(data):
- [type, description, flags] = data
- return "%r -- %r %s" % (type, description, compiledataflags(flags))
-
-def is_null(data):
- return data[0] == 'null'
-
-def is_optional(data):
- return (data[2] & 0x8000)
-
-def is_enum(data):
- return (data[2] & 0x2000)
-
-def getdatadoc(data):
- [type, descr, flags] = data
- if descr:
- return ascii(descr)
- if type == '****':
- return 'anything'
- if type == 'obj ':
- return 'an AE object reference'
- return "undocumented, typecode %r"%(type,)
-
-dataflagdict = {15: "optional", 14: "list", 13: "enum", 12: "mutable"}
-def compiledataflags(flags):
- bits = []
- for i in range(16):
- if flags & (1<<i):
- if i in dataflagdict.keys():
- bits.append(dataflagdict[i])
- else:
- bits.append(repr(i))
- return '[%s]' % string.join(bits)
-
-def ascii(str):
- """Return a string with all non-ascii characters hex-encoded"""
- if type(str) != type(''):
- return map(ascii, str)
- rv = ''
- for c in str:
- if c in ('\t', '\n', '\r') or ' ' <= c < chr(0x7f):
- rv = rv + c
- else:
- rv = rv + '\\' + 'x%02.2x' % ord(c)
- return rv
-
-def identify(str):
- """Turn any string into an identifier:
- - replace space by _
- - replace other illegal chars by _xx_ (hex code)
- - append _ if the result is a python keyword
- """
- if not str:
- return "empty_ae_name_"
- rv = ''
- ok = string.ascii_letters + '_'
- ok2 = ok + string.digits
- for c in str:
- if c in ok:
- rv = rv + c
- elif c == ' ':
- rv = rv + '_'
- else:
- rv = rv + '_%02.2x_'%ord(c)
- ok = ok2
- if keyword.iskeyword(rv):
- rv = rv + '_'
- return rv
-
-# Call the main program
-
-if __name__ == '__main__':
- main()
- sys.exit(1)
diff --git a/Lib/plat-mac/ic.py b/Lib/plat-mac/ic.py
deleted file mode 100644
index 321eba84d24..00000000000
--- a/Lib/plat-mac/ic.py
+++ /dev/null
@@ -1,271 +0,0 @@
-"""IC wrapper module, based on Internet Config 1.3"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the ic module is removed.", stacklevel=2)
-
-import icglue
-import string
-import sys
-import os
-from Carbon import Res
-import Carbon.File
-import macostools
-
-error=icglue.error
-
-# From ictypes.h:
-icPrefNotFoundErr = -666 # preference not found (duh!)
-icPermErr = -667 # cannot set preference
-icPrefDataErr = -668 # problem with preference data
-icInternalErr = -669 # hmm, this is not good
-icTruncatedErr = -670 # more data was present than was returned
-icNoMoreWritersErr = -671 # you cannot begin a write session because someone else is already doing it */
-icNothingToOverrideErr = -672 # no component for the override component to capture
-icNoURLErr = -673 # no URL found
-icConfigNotFoundErr = -674 # no configuration was found
-icConfigInappropriateErr = -675 # incorrect manufacturer code
-
-ICattr_no_change = -1
-
-icNoPerm = 0
-icReadOnlyPerm = 1
-icReadWritePerm = 2
-# End of ictypes.h
-
-class ICOpaqueData:
- """An unparseable IC entry"""
- def __init__(self, data):
- self.data = data
-
- def __repr__(self):
- return "ICOpaqueData(%r)"%(self.data,)
-
-_ICOpaqueDataType=type(ICOpaqueData(''))
-
-def _decode_default(data, key):
- if len(data) == 0:
- return data
- if ord(data[0]) == len(data)-1:
- # Assume Pstring
- return data[1:]
- return ICOpaqueData(data)
-
-
-def _decode_multistr(data, key):
- numstr = ord(data[0]) << 8 | ord(data[1])
- rv = []
- ptr = 2
- for i in range(numstr):
- strlen = ord(data[ptr])
- str = data[ptr+1:ptr+strlen+1]
- rv.append(str)
- ptr = ptr + strlen + 1
- return rv
-
-def _decode_fontrecord(data, key):
- size = ord(data[0]) << 8 | ord(data[1])
- face = ord(data[2])
- namelen = ord(data[4])
- return size, face, data[5:5+namelen]
-
-def _decode_boolean(data, key):
- return ord(data[0])
-
-def _decode_text(data, key):
- return data
-
-def _decode_charset(data, key):
- return data[:256], data[256:]
-
-def _decode_appspec(data, key):
- namelen = ord(data[4])
- return data[0:4], data[5:5+namelen]
-
-def _code_default(data, key):
- return chr(len(data)) + data
-
-def _code_multistr(data, key):
- numstr = len(data)
- rv = chr((numstr>>8) & 0xff) + chr(numstr & 0xff)
- for i in data:
- rv = rv + _code_default(i)
- return rv
-
-def _code_fontrecord(data, key):
- size, face, name = data
- return chr((size>>8) & 0xff) + chr(size & 0xff) + chr(face & 0xff) + \
- chr(0) + _code_default(name)
-
-def _code_boolean(data, key):
- print 'XXXX boolean:', repr(data)
- return chr(data)
-
-def _code_text(data, key):
- return data
-
-def _code_charset(data, key):
- return data[0] + data[1]
-
-def _code_appspec(data, key):
- return data[0] + _code_default(data[1])
-
-_decoder_table = {
- "ArchieAll" : (_decode_multistr , _code_multistr),
- "UMichAll" : (_decode_multistr , _code_multistr),
- "InfoMacAll" : (_decode_multistr , _code_multistr),
- "ListFont" : (_decode_fontrecord , _code_fontrecord),
- "ScreenFont" : (_decode_fontrecord , _code_fontrecord),
- "PrinterFont" : (_decode_fontrecord , _code_fontrecord),
-# "DownloadFolder" : (_decode_filespec , _code_filespec),
- "Signature": (_decode_text , _code_text),
- "Plan" : (_decode_text , _code_text),
- "MailHeaders" : (_decode_text , _code_text),
- "NewsHeaders" : (_decode_text , _code_text),
-# "Mapping"
- "CharacterSet" : (_decode_charset , _code_charset),
- "Helper\245" : (_decode_appspec , _code_appspec),
-# "Services" : (_decode_services, ????),
- "NewMailFlashIcon" : (_decode_boolean , _code_boolean),
- "NewMailDialog" : (_decode_boolean , _code_boolean),
- "NewMailPlaySound" : (_decode_boolean , _code_boolean),
-# "WebBackgroundColor" : _decode_color,
- "NoProxyDomains" : (_decode_multistr , _code_multistr),
- "UseHTTPProxy" : (_decode_boolean , _code_boolean),
- "UseGopherProxy": (_decode_boolean , _code_boolean),
- "UseFTPProxy" : (_decode_boolean , _code_boolean),
- "UsePassiveFTP" : (_decode_boolean , _code_boolean),
-}
-
-def _decode(data, key):
- if '\245' in key:
- key2 = key[:string.index(key, '\245')+1]
- else:
- key2 = key
- if key2 in _decoder_table:
- decoder = _decoder_table[key2][0]
- else:
- decoder = _decode_default
- return decoder(data, key)
-
-def _code(data, key):
- if type(data) == _ICOpaqueDataType:
- return data.data
- if '\245' in key:
- key2 = key[:string.index(key, '\245')+1]
- else:
- key2 = key
- if key2 in _decoder_table:
- coder = _decoder_table[key2][1]
- else:
- coder = _code_default
- return coder(data, key)
-
-class IC:
- def __init__(self, signature='Pyth', ic=None):
- if ic:
- self.ic = ic
- else:
- self.ic = icglue.ICStart(signature)
- if hasattr(self.ic, 'ICFindConfigFile'):
- self.ic.ICFindConfigFile()
- self.h = Res.Resource('')
-
- def keys(self):
- rv = []
- self.ic.ICBegin(icReadOnlyPerm)
- num = self.ic.ICCountPref()
- for i in range(num):
- rv.append(self.ic.ICGetIndPref(i+1))
- self.ic.ICEnd()
- return rv
-
- def has_key(self, key):
- return self.__contains__(key)
-
- def __contains__(self, key):
- try:
- dummy = self.ic.ICFindPrefHandle(key, self.h)
- except icglue.error:
- return 0
- return 1
-
- def __getitem__(self, key):
- attr = self.ic.ICFindPrefHandle(key, self.h)
- return _decode(self.h.data, key)
-
- def __setitem__(self, key, value):
- value = _code(value, key)
- self.ic.ICSetPref(key, ICattr_no_change, value)
-
- def launchurl(self, url, hint=""):
- # Work around a bug in ICLaunchURL: file:/foo does
- # not work but file:///foo does.
- if url[:6] == 'file:/' and url[6] != '/':
- url = 'file:///' + url[6:]
- self.ic.ICLaunchURL(hint, url, 0, len(url))
-
- def parseurl(self, data, start=None, end=None, hint=""):
- if start is None:
- selStart = 0
- selEnd = len(data)
- else:
- selStart = selEnd = start
- if end is not None:
- selEnd = end
- selStart, selEnd = self.ic.ICParseURL(hint, data, selStart, selEnd, self.h)
- return self.h.data, selStart, selEnd
-
- def mapfile(self, file):
- if type(file) != type(''):
- file = file.as_tuple()[2]
- return self.ic.ICMapFilename(file)
-
- def maptypecreator(self, type, creator, filename=""):
- return self.ic.ICMapTypeCreator(type, creator, filename)
-
- def settypecreator(self, file):
- file = Carbon.File.pathname(file)
- record = self.mapfile(os.path.split(file)[1])
- MacOS.SetCreatorAndType(file, record[2], record[1])
- macostools.touched(fss)
-
-# Convenience routines
-_dft_ic = None
-
-def launchurl(url, hint=""):
- global _dft_ic
- if _dft_ic is None: _dft_ic = IC()
- return _dft_ic.launchurl(url, hint)
-
-def parseurl(data, start=None, end=None, hint=""):
- global _dft_ic
- if _dft_ic is None: _dft_ic = IC()
- return _dft_ic.parseurl(data, start, end, hint)
-
-def mapfile(filename):
- global _dft_ic
- if _dft_ic is None: _dft_ic = IC()
- return _dft_ic.mapfile(filename)
-
-def maptypecreator(type, creator, filename=""):
- global _dft_ic
- if _dft_ic is None: _dft_ic = IC()
- return _dft_ic.maptypecreator(type, creator, filename)
-
-def settypecreator(file):
- global _dft_ic
- if _dft_ic is None: _dft_ic = IC()
- return _dft_ic.settypecreator(file)
-
-def _test():
- ic = IC()
- for k in ic.keys():
- try:
- v = ic[k]
- except error:
- v = '????'
- print k, '\t', v
- sys.exit(1)
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/plat-mac/icopen.py b/Lib/plat-mac/icopen.py
deleted file mode 100644
index 941dbb64008..00000000000
--- a/Lib/plat-mac/icopen.py
+++ /dev/null
@@ -1,69 +0,0 @@
-"""icopen patch
-
-OVERVIEW
-
-icopen patches MacOS Python to use the Internet Config file mappings to select
-the type and creator for a file.
-
-Version 1 released to the public domain 3 November 1999
-by Oliver Steele (steele@cs.brandeis.edu).
-
-DETAILS
-
-This patch causes files created by Python's open(filename, 'w') command (and
-by functions and scripts that call it) to set the type and creator of the file
-to the type and creator associated with filename's extension (the
-portion of the filename after the last period), according to Internet Config.
-Thus, a script that creates a file foo.html will create one that opens in whatever
-browser you've set to handle *.html files, and so on.
-
-Python IDE uses its own algorithm to select the type and creator for saved
-editor windows, so this patch won't effect their types.
-
-As of System 8.6 at least, Internet Config is built into the system, and the
-file mappings are accessed from the Advanced pane of the Internet control
-panel. User Mode (in the Edit menu) needs to be set to Advanced in order to
-access this pane.
-
-INSTALLATION
-
-Put this file in your Python path, and create a file named {Python}:sitecustomize.py
-that contains:
- import icopen
-
-(If {Python}:sitecustomizer.py already exists, just add the 'import' line to it.)
-
-The next time you launch PythonInterpreter or Python IDE, the patch will take
-effect.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the icopen module is removed.", stacklevel=2)
-
-import __builtin__
-
-_builtin_open = globals().get('_builtin_open', __builtin__.open)
-
-def _open_with_typer(*args):
- file = _builtin_open(*args)
- filename = args[0]
- mode = 'r'
- if args[1:]:
- mode = args[1]
- if mode[0] == 'w':
- from ic import error, settypecreator
- try:
- settypecreator(filename)
- except error:
- pass
- return file
-
-__builtin__.open = _open_with_typer
-
-"""
-open('test.py')
-_open_with_typer('test.py', 'w')
-_open_with_typer('test.txt', 'w')
-_open_with_typer('test.html', 'w')
-_open_with_typer('test.foo', 'w')
-"""
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py
deleted file mode 100644
index 84b8561d65f..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/CodeWarrior_suite.py
+++ /dev/null
@@ -1,682 +0,0 @@
-"""Suite CodeWarrior suite: Terms for scripting the CodeWarrior IDE
-Level 0, version 0
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'CWIE'
-
-class CodeWarrior_suite_Events:
-
- _argmap_add = {
- 'new' : 'kocl',
- 'with_data' : 'data',
- 'to_targets' : 'TTGT',
- 'to_group' : 'TGRP',
- }
-
- def add(self, _object, _attributes={}, **_arguments):
- """add: add elements to a project or target
- Required argument: an AE object reference
- Keyword argument new: the class of the new element or elements to add
- Keyword argument with_data: the initial data for the element or elements
- Keyword argument to_targets: the targets to which the new element or elements will be added
- Keyword argument to_group: the group to which the new element or elements will be added
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'ADDF'
-
- aetools.keysubst(_arguments, self._argmap_add)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def build(self, _no_object=None, _attributes={}, **_arguments):
- """build: build a project or target (equivalent of the Make menu command)
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'MAKE'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def check(self, _object=None, _attributes={}, **_arguments):
- """check: check the syntax of a file in a project or target
- Required argument: the file or files to be checked
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'CHEK'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def compile_file(self, _object=None, _attributes={}, **_arguments):
- """compile file: compile a file in a project or target
- Required argument: the file or files to be compiled
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'COMP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def disassemble_file(self, _object=None, _attributes={}, **_arguments):
- """disassemble file: disassemble a file in a project or target
- Required argument: the file or files to be disassembled
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'DASM'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_export = {
- 'in_' : 'kfil',
- }
-
- def export(self, _no_object=None, _attributes={}, **_arguments):
- """export: Export the project file as an XML file
- Keyword argument in_: the XML file in which to export the project
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'EXPT'
-
- aetools.keysubst(_arguments, self._argmap_export)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def remove_object_code(self, _no_object=None, _attributes={}, **_arguments):
- """remove object code: remove object code from a project or target
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'RMOB'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def remove_target_files(self, _object, _attributes={}, **_arguments):
- """remove target files: remove files from a target
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'RMFL'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def run_target(self, _no_object=None, _attributes={}, **_arguments):
- """run target: run a project or target
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'RUN '
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def touch_file(self, _object=None, _attributes={}, **_arguments):
- """touch file: touch a file in a project or target for compilation
- Required argument: the file or files to be touched
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'TOCH'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def update(self, _no_object=None, _attributes={}, **_arguments):
- """update: bring a project or target up to date
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'CWIE'
- _subcode = 'UP2D'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class single_class_browser(aetools.ComponentItem):
- """single class browser - a single class browser """
- want = '1BRW'
-class _Prop_inherits(aetools.NProperty):
- """inherits - all properties and elements of the given class are inherited by this class. """
- which = 'c@#^'
- want = 'TXTD'
-
-single_class_browsers = single_class_browser
-
-class single_class_hierarchy(aetools.ComponentItem):
- """single class hierarchy - a single class hierarchy document """
- want = '1HIR'
-
-single_class_hierarchies = single_class_hierarchy
-
-class class_browser(aetools.ComponentItem):
- """class browser - a class browser """
- want = 'BROW'
-
-class_browsers = class_browser
-
-class file_compare_document(aetools.ComponentItem):
- """file compare document - a file compare document """
- want = 'COMP'
-
-file_compare_documents = file_compare_document
-
-class catalog_document(aetools.ComponentItem):
- """catalog document - a browser catalog document """
- want = 'CTLG'
-
-catalog_documents = catalog_document
-
-class editor_document(aetools.ComponentItem):
- """editor document - an editor document """
- want = 'EDIT'
-
-editor_documents = editor_document
-
-class class_hierarchy(aetools.ComponentItem):
- """class hierarchy - a class hierarchy document """
- want = 'HIER'
-
-class_hierarchies = class_hierarchy
-
-class project_inspector(aetools.ComponentItem):
- """project inspector - the project inspector """
- want = 'INSP'
-
-project_inspectors = project_inspector
-
-class message_document(aetools.ComponentItem):
- """message document - a message document """
- want = 'MSSG'
-
-message_documents = message_document
-
-class build_progress_document(aetools.ComponentItem):
- """build progress document - a build progress document """
- want = 'PRGS'
-
-build_progress_documents = build_progress_document
-
-class project_document(aetools.ComponentItem):
- """project document - a project document """
- want = 'PRJD'
-class _Prop_current_target(aetools.NProperty):
- """current target - the current target """
- which = 'CURT'
- want = 'TRGT'
-# element 'TRGT' as ['indx', 'name', 'test', 'rang']
-
-project_documents = project_document
-
-class subtarget(aetools.ComponentItem):
- """subtarget - a target that is prerequisite for another target """
- want = 'SBTG'
-class _Prop_link_against_output(aetools.NProperty):
- """link against output - is the output of this subtarget linked into its dependent target? """
- which = 'LNKO'
- want = 'bool'
-class _Prop_target(aetools.NProperty):
- """target - the target that is dependent on this subtarget """
- which = 'TrgT'
- want = 'TRGT'
-
-subtargets = subtarget
-
-class target_file(aetools.ComponentItem):
- """target file - a source or header file in a target """
- want = 'SRCF'
-class _Prop_code_size(aetools.NProperty):
- """code size - the size of the code (in bytes) produced by compiling this source file """
- which = 'CSZE'
- want = 'long'
-class _Prop_compiled_date(aetools.NProperty):
- """compiled date - the date and this source file was last compiled """
- which = 'CMPD'
- want = 'ldt '
-class _Prop_data_size(aetools.NProperty):
- """data size - the size of the date (in bytes) produced by compiling this source file """
- which = 'DSZE'
- want = 'long'
-class _Prop_debug(aetools.NProperty):
- """debug - is debugging information generated for this source file? """
- which = 'DBUG'
- want = 'bool'
-class _Prop_dependents(aetools.NProperty):
- """dependents - the source files that need this source file in order to build """
- which = 'DPND'
- want = 'list'
-class _Prop_id(aetools.NProperty):
- """id - the unique ID number of the target file """
- which = 'ID '
- want = 'long'
-class _Prop_init_before(aetools.NProperty):
- """init before - is the \xd4initialize before\xd5 flag set for this shared library? """
- which = 'INIT'
- want = 'bool'
-class _Prop_link_index(aetools.NProperty):
- """link index - the index of the source file in its target\xd5s link order (-1 if source file is not in link order) """
- which = 'LIDX'
- want = 'long'
-class _Prop_linked(aetools.NProperty):
- """linked - is the source file in the link order of its target? """
- which = 'LINK'
- want = 'bool'
-class _Prop_location(aetools.NProperty):
- """location - the location of the target file on disk """
- which = 'FILE'
- want = 'fss '
-class _Prop_merge_output(aetools.NProperty):
- """merge output - is this shared library merged into another code fragment? """
- which = 'MRGE'
- want = 'bool'
-class _Prop_modified_date(aetools.NProperty):
- """modified date - the date and time this source file was last modified """
- which = 'MODD'
- want = 'ldt '
-class _Prop_path(aetools.NProperty):
- """path - the path of the source file on disk """
- which = 'Path'
- want = 'itxt'
-class _Prop_prerequisites(aetools.NProperty):
- """prerequisites - the source files needed to build this source file """
- which = 'PRER'
- want = 'list'
-class _Prop_type(aetools.NProperty):
- """type - the type of source file """
- which = 'FTYP'
- want = 'FTYP'
-class _Prop_weak_link(aetools.NProperty):
- """weak link - is this shared library linked weakly? """
- which = 'WEAK'
- want = 'bool'
-
-target_files = target_file
-
-class symbol_browser(aetools.ComponentItem):
- """symbol browser - a symbol browser """
- want = 'SYMB'
-
-symbol_browsers = symbol_browser
-
-class ToolServer_worksheet(aetools.ComponentItem):
- """ToolServer worksheet - a ToolServer worksheet """
- want = 'TOOL'
-
-ToolServer_worksheets = ToolServer_worksheet
-
-class target(aetools.ComponentItem):
- """target - a target in a project """
- want = 'TRGT'
-class _Prop_name(aetools.NProperty):
- """name - """
- which = 'pnam'
- want = 'itxt'
-class _Prop_project_document(aetools.NProperty):
- """project document - the project document that contains this target """
- which = 'PrjD'
- want = 'PRJD'
-# element 'SBTG' as ['indx', 'test', 'rang']
-# element 'SRCF' as ['indx', 'test', 'rang']
-
-targets = target
-
-class text_document(aetools.ComponentItem):
- """text document - a document that contains text """
- want = 'TXTD'
-class _Prop_modified(aetools.NProperty):
- """modified - Has the document been modified since the last save? """
- which = 'imod'
- want = 'bool'
-class _Prop_selection(aetools.NProperty):
- """selection - the selection visible to the user """
- which = 'sele'
- want = 'csel'
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cins' as ['rele']
-# element 'clin' as ['indx', 'rang', 'rele']
-# element 'ctxt' as ['rang']
-
-text_documents = text_document
-single_class_browser._superclassnames = ['text_document']
-single_class_browser._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-single_class_browser._privelemdict = {
-}
-import Standard_Suite
-single_class_hierarchy._superclassnames = ['document']
-single_class_hierarchy._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-single_class_hierarchy._privelemdict = {
-}
-class_browser._superclassnames = ['text_document']
-class_browser._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-class_browser._privelemdict = {
-}
-file_compare_document._superclassnames = ['text_document']
-file_compare_document._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-file_compare_document._privelemdict = {
-}
-catalog_document._superclassnames = ['text_document']
-catalog_document._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-catalog_document._privelemdict = {
-}
-editor_document._superclassnames = ['text_document']
-editor_document._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-editor_document._privelemdict = {
-}
-class_hierarchy._superclassnames = ['document']
-class_hierarchy._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-class_hierarchy._privelemdict = {
-}
-project_inspector._superclassnames = ['document']
-project_inspector._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-project_inspector._privelemdict = {
-}
-message_document._superclassnames = ['text_document']
-message_document._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-message_document._privelemdict = {
-}
-build_progress_document._superclassnames = ['document']
-build_progress_document._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-build_progress_document._privelemdict = {
-}
-project_document._superclassnames = ['document']
-project_document._privpropdict = {
- 'current_target' : _Prop_current_target,
- 'inherits' : _Prop_inherits,
-}
-project_document._privelemdict = {
- 'target' : target,
-}
-subtarget._superclassnames = ['target']
-subtarget._privpropdict = {
- 'inherits' : _Prop_inherits,
- 'link_against_output' : _Prop_link_against_output,
- 'target' : _Prop_target,
-}
-subtarget._privelemdict = {
-}
-target_file._superclassnames = []
-target_file._privpropdict = {
- 'code_size' : _Prop_code_size,
- 'compiled_date' : _Prop_compiled_date,
- 'data_size' : _Prop_data_size,
- 'debug' : _Prop_debug,
- 'dependents' : _Prop_dependents,
- 'id' : _Prop_id,
- 'init_before' : _Prop_init_before,
- 'link_index' : _Prop_link_index,
- 'linked' : _Prop_linked,
- 'location' : _Prop_location,
- 'merge_output' : _Prop_merge_output,
- 'modified_date' : _Prop_modified_date,
- 'path' : _Prop_path,
- 'prerequisites' : _Prop_prerequisites,
- 'type' : _Prop_type,
- 'weak_link' : _Prop_weak_link,
-}
-target_file._privelemdict = {
-}
-symbol_browser._superclassnames = ['text_document']
-symbol_browser._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-symbol_browser._privelemdict = {
-}
-ToolServer_worksheet._superclassnames = ['text_document']
-ToolServer_worksheet._privpropdict = {
- 'inherits' : _Prop_inherits,
-}
-ToolServer_worksheet._privelemdict = {
-}
-target._superclassnames = []
-target._privpropdict = {
- 'name' : _Prop_name,
- 'project_document' : _Prop_project_document,
-}
-target._privelemdict = {
- 'subtarget' : subtarget,
- 'target_file' : target_file,
-}
-text_document._superclassnames = ['document']
-text_document._privpropdict = {
- 'inherits' : _Prop_inherits,
- 'modified' : _Prop_modified,
- 'selection' : _Prop_selection,
-}
-text_document._privelemdict = {
- 'character' : Standard_Suite.character,
- 'insertion_point' : Standard_Suite.insertion_point,
- 'line' : Standard_Suite.line,
- 'text' : Standard_Suite.text,
-}
-_Enum_DKND = {
- 'project' : 'PRJD', # a project document
- 'editor_document' : 'EDIT', # an editor document
- 'message' : 'MSSG', # a message document
- 'file_compare' : 'COMP', # a file compare document
- 'catalog_document' : 'CTLG', # a browser catalog
- 'class_browser' : 'BROW', # a class browser document
- 'single_class_browser' : '1BRW', # a single class browser document
- 'symbol_browser' : 'SYMB', # a symbol browser document
- 'class_hierarchy' : 'HIER', # a class hierarchy document
- 'single_class_hierarchy' : '1HIR', # a single class hierarchy document
- 'project_inspector' : 'INSP', # a project inspector
- 'ToolServer_worksheet' : 'TOOL', # the ToolServer worksheet
- 'build_progress_document' : 'PRGS', # the build progress window
-}
-
-_Enum_FTYP = {
- 'library_file' : 'LIBF', # a library file
- 'project_file' : 'PRJF', # a project file
- 'resource_file' : 'RESF', # a resource file
- 'text_file' : 'TXTF', # a text file
- 'unknown_file' : 'UNKN', # unknown file type
-}
-
-_Enum_Inte = {
- 'never_interact' : 'eNvr', # never allow user interactions
- 'interact_with_self' : 'eInS', # allow user interaction only when an AppleEvent is sent from within CodeWarrior
- 'interact_with_local' : 'eInL', # allow user interaction when AppleEvents are sent from applications on the same machine (default)
- 'interact_with_all' : 'eInA', # allow user interaction from both local and remote AppleEvents
-}
-
-_Enum_PERM = {
- 'read_write' : 'RdWr', # the file is open with read/write permission
- 'read_only' : 'Read', # the file is open with read/only permission
- 'checked_out_read_write' : 'CkRW', # the file is checked out with read/write permission
- 'checked_out_read_only' : 'CkRO', # the file is checked out with read/only permission
- 'checked_out_read_modify' : 'CkRM', # the file is checked out with read/modify permission
- 'locked' : 'Lock', # the file is locked on disk
- 'none' : 'LNNO', # the file is new
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- '1BRW' : single_class_browser,
- '1HIR' : single_class_hierarchy,
- 'BROW' : class_browser,
- 'COMP' : file_compare_document,
- 'CTLG' : catalog_document,
- 'EDIT' : editor_document,
- 'HIER' : class_hierarchy,
- 'INSP' : project_inspector,
- 'MSSG' : message_document,
- 'PRGS' : build_progress_document,
- 'PRJD' : project_document,
- 'SBTG' : subtarget,
- 'SRCF' : target_file,
- 'SYMB' : symbol_browser,
- 'TOOL' : ToolServer_worksheet,
- 'TRGT' : target,
- 'TXTD' : text_document,
-}
-
-_propdeclarations = {
- 'CMPD' : _Prop_compiled_date,
- 'CSZE' : _Prop_code_size,
- 'CURT' : _Prop_current_target,
- 'DBUG' : _Prop_debug,
- 'DPND' : _Prop_dependents,
- 'DSZE' : _Prop_data_size,
- 'FILE' : _Prop_location,
- 'FTYP' : _Prop_type,
- 'ID ' : _Prop_id,
- 'INIT' : _Prop_init_before,
- 'LIDX' : _Prop_link_index,
- 'LINK' : _Prop_linked,
- 'LNKO' : _Prop_link_against_output,
- 'MODD' : _Prop_modified_date,
- 'MRGE' : _Prop_merge_output,
- 'PRER' : _Prop_prerequisites,
- 'Path' : _Prop_path,
- 'PrjD' : _Prop_project_document,
- 'TrgT' : _Prop_target,
- 'WEAK' : _Prop_weak_link,
- 'c@#^' : _Prop_inherits,
- 'imod' : _Prop_modified,
- 'pnam' : _Prop_name,
- 'sele' : _Prop_selection,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'DKND' : _Enum_DKND,
- 'FTYP' : _Enum_FTYP,
- 'Inte' : _Enum_Inte,
- 'PERM' : _Enum_PERM,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py
deleted file mode 100644
index ca1f6943f38..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Metrowerks_Shell_Suite.py
+++ /dev/null
@@ -1,2373 +0,0 @@
-"""Suite Metrowerks Shell Suite: Events supported by the Metrowerks Project Shell
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'MMPR'
-
-class Metrowerks_Shell_Suite_Events:
-
- _argmap_Add_Files = {
- 'To_Segment' : 'Segm',
- }
-
- def Add_Files(self, _object, _attributes={}, **_arguments):
- """Add Files: Add the specified file(s) to the current project
- Required argument: List of files to add
- Keyword argument To_Segment: Segment number into which to add the file(s)
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Error code for each file added
- """
- _code = 'MMPR'
- _subcode = 'AddF'
-
- aetools.keysubst(_arguments, self._argmap_Add_Files)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Check_Syntax = {
- 'ExternalEditor' : 'Errs',
- }
-
- def Check_Syntax(self, _object, _attributes={}, **_arguments):
- """Check Syntax: Check the syntax of the specified file(s)
- Required argument: List of files to check the syntax of
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors for each file whose syntax was checked
- """
- _code = 'MMPR'
- _subcode = 'Chek'
-
- aetools.keysubst(_arguments, self._argmap_Check_Syntax)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Close_Project(self, _no_object=None, _attributes={}, **_arguments):
- """Close Project: Close the current project
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'ClsP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Close_Window = {
- 'Saving' : 'savo',
- }
-
- def Close_Window(self, _object, _attributes={}, **_arguments):
- """Close Window: Close the windows showing the specified files
- Required argument: The files to close
- Keyword argument Saving: Whether to save changes to each file before closing its window
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'ClsW'
-
- aetools.keysubst(_arguments, self._argmap_Close_Window)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Compile = {
- 'ExternalEditor' : 'Errs',
- }
-
- def Compile(self, _object, _attributes={}, **_arguments):
- """Compile: Compile the specified file(s)
- Required argument: List of files to compile
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors for each file compiled
- """
- _code = 'MMPR'
- _subcode = 'Comp'
-
- aetools.keysubst(_arguments, self._argmap_Compile)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Create_Project = {
- 'from_stationery' : 'Tmpl',
- }
-
- def Create_Project(self, _object, _attributes={}, **_arguments):
- """Create Project: Create a new project file
- Required argument: New project file specifier
- Keyword argument from_stationery: undocumented, typecode 'alis'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'NewP'
-
- aetools.keysubst(_arguments, self._argmap_Create_Project)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_Definition(self, _object, _attributes={}, **_arguments):
- """Get Definition: Returns the location(s) of a globally scoped function or data object.
- Required argument: undocumented, typecode 'TEXT'
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'FDef'
- """
- _code = 'MMPR'
- _subcode = 'GDef'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_Open_Documents(self, _no_object=None, _attributes={}, **_arguments):
- """Get Open Documents: Returns the list of open documents
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: The list of documents
- """
- _code = 'MMPR'
- _subcode = 'GDoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Get_Preferences = {
- 'of' : 'PRec',
- 'from_panel' : 'PNam',
- }
-
- def Get_Preferences(self, _no_object=None, _attributes={}, **_arguments):
- """Get Preferences: Get the preferences for the current project
- Keyword argument of: Names of requested preferences
- Keyword argument from_panel: Name of the preference panel
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: The requested preferences
- """
- _code = 'MMPR'
- _subcode = 'Gref'
-
- aetools.keysubst(_arguments, self._argmap_Get_Preferences)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Get_Project_File = {
- 'Segment' : 'Segm',
- }
-
- def Get_Project_File(self, _object, _attributes={}, **_arguments):
- """Get Project File: Returns a description of a file in the project window.
- Required argument: The index of the file within its segment.
- Keyword argument Segment: The segment containing the file.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'SrcF'
- """
- _code = 'MMPR'
- _subcode = 'GFil'
-
- aetools.keysubst(_arguments, self._argmap_Get_Project_File)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_Project_Specifier(self, _no_object=None, _attributes={}, **_arguments):
- """Get Project Specifier: Return the File Specifier for the current project
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: File Specifier for the current project
- """
- _code = 'MMPR'
- _subcode = 'GetP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_Segments(self, _no_object=None, _attributes={}, **_arguments):
- """Get Segments: Returns a description of each segment in the project.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'Seg '
- """
- _code = 'MMPR'
- _subcode = 'GSeg'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_member_function_names(self, _object, _attributes={}, **_arguments):
- """Get member function names: Returns a list containing the names of all the member functions of a class object
- Required argument: must be a class object
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'list'
- """
- _code = 'MMPR'
- _subcode = 'MbFN'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_nonsimple_classes(self, _no_object=None, _attributes={}, **_arguments):
- """Get nonsimple classes: Returns an alphabetical list of classes with member functions, bases classes, or subclasses
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'list'
- """
- _code = 'MMPR'
- _subcode = 'NsCl'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Goto_Function(self, _object, _attributes={}, **_arguments):
- """Goto Function: Goto Specified Function Name
- Required argument: undocumented, typecode 'TEXT'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'GoFn'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Goto_Line(self, _object, _attributes={}, **_arguments):
- """Goto Line: Goto Specified Line Number
- Required argument: The requested source file line number
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'GoLn'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Is_In_Project(self, _object, _attributes={}, **_arguments):
- """Is In Project: Whether or not the specified file(s) is in the current project
- Required argument: List of files to check for project membership
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Result code for each file
- """
- _code = 'MMPR'
- _subcode = 'FInP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Make_Project = {
- 'ExternalEditor' : 'Errs',
- }
-
- def Make_Project(self, _no_object=None, _attributes={}, **_arguments):
- """Make Project: Make the current project
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors that occurred while making the project
- """
- _code = 'MMPR'
- _subcode = 'Make'
-
- aetools.keysubst(_arguments, self._argmap_Make_Project)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Open_browser(self, _object, _attributes={}, **_arguments):
- """Open browser: Display a class, member function, or data member object in a single class browser window
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'Brow'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Precompile = {
- 'Saving_As' : 'Targ',
- 'ExternalEditor' : 'Errs',
- }
-
- def Precompile(self, _object, _attributes={}, **_arguments):
- """Precompile: Precompile the specified file to the specified destination file
- Required argument: File to precompile
- Keyword argument Saving_As: Destination file for precompiled header
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors for the precompiled file
- """
- _code = 'MMPR'
- _subcode = 'PreC'
-
- aetools.keysubst(_arguments, self._argmap_Precompile)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Preprocess = {
- 'ExternalEditor' : 'Errs',
- }
-
- def Preprocess(self, _object, _attributes={}, **_arguments):
- """Preprocess: Preprocesses the specified file(s)
- Required argument: undocumented, typecode 'alis'
- Keyword argument ExternalEditor: undocumented, typecode 'bool'
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors for each preprocessed file
- """
- _code = 'MMPR'
- _subcode = 'PreP'
-
- aetools.keysubst(_arguments, self._argmap_Preprocess)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Remove_Binaries(self, _no_object=None, _attributes={}, **_arguments):
- """Remove Binaries: Remove the binary object code from the current project
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'RemB'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Remove_Files(self, _object, _attributes={}, **_arguments):
- """Remove Files: Remove the specified file(s) from the current project
- Required argument: List of files to remove
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Error code for each file removed
- """
- _code = 'MMPR'
- _subcode = 'RemF'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Reset_File_Paths(self, _no_object=None, _attributes={}, **_arguments):
- """Reset File Paths: Resets access paths for all files belonging to open project.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'ReFP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Run_Project = {
- 'ExternalEditor' : 'Errs',
- 'SourceDebugger' : 'DeBg',
- }
-
- def Run_Project(self, _no_object=None, _attributes={}, **_arguments):
- """Run Project: Run the current project
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument SourceDebugger: Run the application under the control of the source-level debugger
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors that occurred when running the project
- """
- _code = 'MMPR'
- _subcode = 'RunP'
-
- aetools.keysubst(_arguments, self._argmap_Run_Project)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Save_Error_Window_As(self, _object, _attributes={}, **_arguments):
- """Save Error Window As: Saves the Errors & Warnings window as a text file
- Required argument: Destination file for Save Message Window As
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'SvMs'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Set_Current_Target(self, _object=None, _attributes={}, **_arguments):
- """Set Current Target: Set the current target of a project
- Required argument: Name of target
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'STrg'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Set_Default_Project(self, _object, _attributes={}, **_arguments):
- """Set Default Project: Set the default project
- Required argument: Name of project
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'SDfP'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Set_Modification_Date = {
- 'to' : 'MDat',
- }
-
- def Set_Modification_Date(self, _object, _attributes={}, **_arguments):
- """Set Modification Date: Changes the internal modification date of the specified file(s)
- Required argument: List of files
- Keyword argument to: undocumented, typecode 'ldt '
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Error code for each modified file
- """
- _code = 'MMPR'
- _subcode = 'SMod'
-
- aetools.keysubst(_arguments, self._argmap_Set_Modification_Date)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Set_Preferences = {
- 'of_panel' : 'PNam',
- 'to' : 'PRec',
- }
-
- def Set_Preferences(self, _no_object=None, _attributes={}, **_arguments):
- """Set Preferences: Set the preferences for the current project
- Keyword argument of_panel: Name of the preference panel
- Keyword argument to: Preferences settings
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'Pref'
-
- aetools.keysubst(_arguments, self._argmap_Set_Preferences)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Set_Project_File = {
- 'to' : 'SrcS',
- }
-
- def Set_Project_File(self, _object, _attributes={}, **_arguments):
- """Set Project File: Changes the settings for a given file in the project.
- Required argument: The name of the file
- Keyword argument to: The new settings for the file
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'SFil'
-
- aetools.keysubst(_arguments, self._argmap_Set_Project_File)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Set_Segment = {
- 'to' : 'Segm',
- }
-
- def Set_Segment(self, _object, _attributes={}, **_arguments):
- """Set Segment: Changes the name and attributes of a segment.
- Required argument: The segment to change
- Keyword argument to: The new name and attributes for the segment.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MMPR'
- _subcode = 'SSeg'
-
- aetools.keysubst(_arguments, self._argmap_Set_Segment)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Touch(self, _object, _attributes={}, **_arguments):
- """Touch: Force recompilation of the specified file(s)
- Required argument: List of files to compile
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Error code for each file touched
- """
- _code = 'MMPR'
- _subcode = 'Toch'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Update_Project = {
- 'ExternalEditor' : 'Errs',
- }
-
- def Update_Project(self, _no_object=None, _attributes={}, **_arguments):
- """Update Project: Update the current project
- Keyword argument ExternalEditor: Should the contents of the message window be returned to the caller?
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Errors that occurred while updating the project
- """
- _code = 'MMPR'
- _subcode = 'UpdP'
-
- aetools.keysubst(_arguments, self._argmap_Update_Project)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class Browser_Coloring(aetools.ComponentItem):
- """Browser Coloring - Colors for Browser symbols. """
- want = 'BRKW'
-class _Prop_Browser_Keywords(aetools.NProperty):
- """Browser Keywords - Mark Browser symbols with color. """
- which = 'BW00'
- want = 'bool'
-class _Prop_Classes_Color(aetools.NProperty):
- """Classes Color - The color for classes. """
- which = 'BW01'
- want = 'cRGB'
-class _Prop_Constants_Color(aetools.NProperty):
- """Constants Color - The color for constants. """
- which = 'BW02'
- want = 'cRGB'
-class _Prop_Enums_Color(aetools.NProperty):
- """Enums Color - The color for enums. """
- which = 'BW03'
- want = 'cRGB'
-class _Prop_Functions_Color(aetools.NProperty):
- """Functions Color - Set color for functions. """
- which = 'BW04'
- want = 'cRGB'
-class _Prop_Globals_Color(aetools.NProperty):
- """Globals Color - The color for globals """
- which = 'BW05'
- want = 'cRGB'
-class _Prop_Macros_Color(aetools.NProperty):
- """Macros Color - The color for macros. """
- which = 'BW06'
- want = 'cRGB'
-class _Prop_Template_Commands_in_Menu(aetools.NProperty):
- """Template Commands in Menu - Include template commands in context menus """
- which = 'BW10'
- want = 'bool'
-class _Prop_Templates_Color(aetools.NProperty):
- """Templates Color - Set color for templates. """
- which = 'BW07'
- want = 'cRGB'
-class _Prop_Typedefs_Color(aetools.NProperty):
- """Typedefs Color - The color for typedefs. """
- which = 'BW08'
- want = 'cRGB'
-
-class Build_Settings(aetools.ComponentItem):
- """Build Settings - Build Settings preferences. """
- want = 'BSTG'
-class _Prop_Build_Before_Running(aetools.NProperty):
- """Build Before Running - Build the target before running. """
- which = 'BX04'
- want = 'BXbr'
-class _Prop_Compiler_Thread_Stack_Size(aetools.NProperty):
- """Compiler Thread Stack Size - Compiler Thread Stack Size """
- which = 'BX06'
- want = 'long'
-class _Prop_Completion_Sound(aetools.NProperty):
- """Completion Sound - Play a sound when finished a Bring Up To Date or Make command. """
- which = 'BX01'
- want = 'bool'
-class _Prop_Failure_Sound(aetools.NProperty):
- """Failure Sound - The sound CodeWarrior plays when it cannot finish a Bring Up To Date or Make command. """
- which = 'BX03'
- want = 'TEXT'
-class _Prop_Include_Cache_Size(aetools.NProperty):
- """Include Cache Size - Include file cache size. """
- which = 'BX05'
- want = 'long'
-class _Prop_Save_Before_Building(aetools.NProperty):
- """Save Before Building - Save open editor files before build operations """
- which = 'BX07'
- want = 'bool'
-class _Prop_Success_Sound(aetools.NProperty):
- """Success Sound - The sound CodeWarrior plays when it successfully finishes a Bring Up To Date or Make command. """
- which = 'BX02'
- want = 'TEXT'
-
-class base_class(aetools.ComponentItem):
- """base class - A base class or super class of a class """
- want = 'BsCl'
-class _Prop_access(aetools.NProperty):
- """access - """
- which = 'Acce'
- want = 'Acce'
-class _Prop_class_(aetools.NProperty):
- """class - The class object corresponding to this base class """
- which = 'Clas'
- want = 'obj '
-class _Prop_virtual(aetools.NProperty):
- """virtual - """
- which = 'Virt'
- want = 'bool'
-
-base_classes = base_class
-
-class Custom_Keywords(aetools.ComponentItem):
- """Custom Keywords - """
- want = 'CUKW'
-class _Prop_Custom_Color_1(aetools.NProperty):
- """Custom Color 1 - The color for the first set of custom keywords. """
- which = 'GH05'
- want = 'cRGB'
-class _Prop_Custom_Color_2(aetools.NProperty):
- """Custom Color 2 - The color for the second set custom keywords. """
- which = 'GH06'
- want = 'cRGB'
-class _Prop_Custom_Color_3(aetools.NProperty):
- """Custom Color 3 - The color for the third set of custom keywords. """
- which = 'GH07'
- want = 'cRGB'
-class _Prop_Custom_Color_4(aetools.NProperty):
- """Custom Color 4 - The color for the fourth set of custom keywords. """
- which = 'GH08'
- want = 'cRGB'
-
-class browser_catalog(aetools.ComponentItem):
- """browser catalog - The browser symbol catalog for the current project """
- want = 'Cata'
-# element 'Clas' as ['indx', 'name']
-
-class class_(aetools.ComponentItem):
- """class - A class, struct, or record type in the current project. """
- want = 'Clas'
-class _Prop_all_subclasses(aetools.NProperty):
- """all subclasses - the classes directly or indirectly derived from this class """
- which = 'SubA'
- want = 'Clas'
-class _Prop_declaration_end_offset(aetools.NProperty):
- """declaration end offset - End of class declaration """
- which = 'DcEn'
- want = 'long'
-class _Prop_declaration_file(aetools.NProperty):
- """declaration file - Source file containing the class declaration """
- which = 'DcFl'
- want = 'fss '
-class _Prop_declaration_start_offset(aetools.NProperty):
- """declaration start offset - Start of class declaration source code """
- which = 'DcSt'
- want = 'long'
-class _Prop_language(aetools.NProperty):
- """language - Implementation language of this class """
- which = 'Lang'
- want = 'Lang'
-class _Prop_name(aetools.NProperty):
- """name - """
- which = 'pnam'
- want = 'TEXT'
-class _Prop_subclasses(aetools.NProperty):
- """subclasses - the immediate subclasses of this class """
- which = 'SubC'
- want = 'Clas'
-# element 'BsCl' as ['indx']
-# element 'DtMb' as ['indx', 'name']
-# element 'MbFn' as ['indx', 'name']
-
-classes = class_
-
-class Debugger_Display(aetools.ComponentItem):
- """Debugger Display - Debugger Display preferences """
- want = 'DbDS'
-class _Prop_Default_Array_Size(aetools.NProperty):
- """Default Array Size - Controls whether CodeWarrior uses its own integrated editor or an external application for editing text files. """
- which = 'Db08'
- want = 'shor'
-class _Prop_Show_As_Decimal(aetools.NProperty):
- """Show As Decimal - Show variable values as decimal by default """
- which = 'Db10'
- want = 'bool'
-class _Prop_Show_Locals(aetools.NProperty):
- """Show Locals - Show locals by default """
- which = 'Db09'
- want = 'bool'
-class _Prop_Show_Variable_Types(aetools.NProperty):
- """Show Variable Types - Show variable types by default. """
- which = 'Db01'
- want = 'bool'
-class _Prop_Sort_By_Method(aetools.NProperty):
- """Sort By Method - Sort functions by method. """
- which = 'Db02'
- want = 'bool'
-class _Prop_Threads_in_Window(aetools.NProperty):
- """Threads in Window - Show threads in separate windows. """
- which = 'Db04'
- want = 'bool'
-class _Prop_Use_RTTI(aetools.NProperty):
- """Use RTTI - Enable RunTime Type Information. """
- which = 'Db03'
- want = 'bool'
-class _Prop_Variable_Changed_Hilite(aetools.NProperty):
- """Variable Changed Hilite - Variable changed hilite color. """
- which = 'Db07'
- want = 'cRGB'
-class _Prop_Variable_Hints(aetools.NProperty):
- """Variable Hints - Show variable hints. """
- which = 'Db05'
- want = 'bool'
-class _Prop_Watchpoint_Hilite(aetools.NProperty):
- """Watchpoint Hilite - Watchpoint hilite color. """
- which = 'Db06'
- want = 'cRGB'
-
-class Debugger_Global(aetools.ComponentItem):
- """Debugger Global - Debugger Global preferences """
- want = 'DbGL'
-class _Prop_Auto_Target_Libraries(aetools.NProperty):
- """Auto Target Libraries - Automatically target libraries when debugging """
- which = 'Dg11'
- want = 'bool'
-class _Prop_Cache_Edited_Files(aetools.NProperty):
- """Cache Edited Files - Cache edit files between debug sessions """
- which = 'Dg12'
- want = 'bool'
-class _Prop_Confirm_Kill(aetools.NProperty):
- """Confirm Kill - Confirm the \xd4killing\xd5 of the process. """
- which = 'Dg04'
- want = 'bool'
-class _Prop_Dont_Step_in_Runtime(aetools.NProperty):
- """Dont Step in Runtime - Don\xd5t step into runtime code when debugging. """
- which = 'Dg07'
- want = 'bool'
-class _Prop_File_Cache_Duration(aetools.NProperty):
- """File Cache Duration - Duration to keep files in cache (in days) """
- which = 'Dg13'
- want = 'shor'
-class _Prop_Ignore_Mod_Dates(aetools.NProperty):
- """Ignore Mod Dates - Ignore modification dates of files. """
- which = 'Dg01'
- want = 'bool'
-class _Prop_Launch_Apps_on_Open(aetools.NProperty):
- """Launch Apps on Open - Launch applications on the opening of sym files. """
- which = 'Dg03'
- want = 'bool'
-class _Prop_Open_All_Classes(aetools.NProperty):
- """Open All Classes - Open all Java class files. """
- which = 'Dg02'
- want = 'bool'
-class _Prop_Select_Stack_Crawl(aetools.NProperty):
- """Select Stack Crawl - Select the stack crawl. """
- which = 'Dg06'
- want = 'bool'
-class _Prop_Stop_at_Main(aetools.NProperty):
- """Stop at Main - Stop to debug on the main() function. """
- which = 'Dg05'
- want = 'bool'
-
-class Debugger_Target(aetools.ComponentItem):
- """Debugger Target - Debugger Target preferences """
- want = 'DbTG'
-class _Prop_Cache_symbolics(aetools.NProperty):
- """Cache symbolics - Cache symbolics between runs when executable doesn\xd5t change, else release symbolics files after killing process. """
- which = 'Dt15'
- want = 'bool'
-class _Prop_Data_Update_Interval(aetools.NProperty):
- """Data Update Interval - How often to update the data while running (in seconds) """
- which = 'Dt09'
- want = 'long'
-class _Prop_Log_System_Messages(aetools.NProperty):
- """Log System Messages - Log all system messages while debugging. """
- which = 'Dt02'
- want = 'bool'
-class _Prop_Relocated_Executable_Path(aetools.NProperty):
- """Relocated Executable Path - Path to location of relocated libraries, code resources or remote debugging folder """
- which = 'Dt10'
- want = 'RlPt'
-class _Prop_Stop_at_temp_breakpoint(aetools.NProperty):
- """Stop at temp breakpoint - Stop at a temp breakpoint on program launch. Set breakpoint type in Temp Breakpoint Type AppleEvent. """
- which = 'Dt13'
- want = 'bool'
-class _Prop_Temp_Breakpoint_Type(aetools.NProperty):
- """Temp Breakpoint Type - Type of temp breakpoint to set on program launch. """
- which = 'Dt16'
- want = 'TmpB'
-class _Prop_Temp_breakpoint_names(aetools.NProperty):
- """Temp breakpoint names - Comma separated list of names to attempt to stop at on program launch. First symbol to resolve in list is the temp BP that will be set. """
- which = 'Dt14'
- want = 'ctxt'
-class _Prop_Update_Data_While_Running(aetools.NProperty):
- """Update Data While Running - Should pause to update data while running """
- which = 'Dt08'
- want = 'bool'
-
-class Debugger_Windowing(aetools.ComponentItem):
- """Debugger Windowing - """
- want = 'DbWN'
-class _Prop_Debugging_Start_Action(aetools.NProperty):
- """Debugging Start Action - What action to take when debug session starts """
- which = 'Dw01'
- want = 'DbSA'
-class _Prop_Do_Nothing_To_Projects(aetools.NProperty):
- """Do Nothing To Projects - Suppress debugging start action for project windows """
- which = 'Dw02'
- want = 'bool'
-
-class data_member(aetools.ComponentItem):
- """data member - A class data member or field """
- want = 'DtMb'
-class _Prop_static(aetools.NProperty):
- """static - """
- which = 'Stat'
- want = 'bool'
-
-data_members = data_member
-
-class Editor(aetools.ComponentItem):
- """Editor - """
- want = 'EDTR'
-class _Prop_Background_Color(aetools.NProperty):
- """Background Color - Color of the background of editor windows. """
- which = 'ED13'
- want = 'cRGB'
-class _Prop_Balance(aetools.NProperty):
- """Balance - Flash the matching opening bracket when you type a closing bracket. """
- which = 'ED03'
- want = 'bool'
-class _Prop_Context_Popup_Delay(aetools.NProperty):
- """Context Popup Delay - The amount of time, in sixtieths of a second, before the context popup is displayed if you click and hold on a browser symbol. """
- which = 'ED14'
- want = 'long'
-class _Prop_Default_Text_File_Format(aetools.NProperty):
- """Default Text File Format - Default text file format (i.e. which type of line endings to use) """
- which = 'ED17'
- want = 'TxtF'
-class _Prop_Dynamic_Scroll(aetools.NProperty):
- """Dynamic Scroll - Display a window\xd5s contents as you move the scroll box. """
- which = 'ED02'
- want = 'bool'
-class _Prop_Flash_Delay(aetools.NProperty):
- """Flash Delay - The amount of time, in sixtieths of a second, the editor highlights a matching bracket. """
- which = 'ED01'
- want = 'long'
-class _Prop_Left_Margin_Line_Select(aetools.NProperty):
- """Left Margin Line Select - Clicking in the left margin selects lines """
- which = 'ED16'
- want = 'bool'
-class _Prop_Main_Text_Color(aetools.NProperty):
- """Main Text Color - Main, default, color for text. """
- which = 'ED12'
- want = 'cRGB'
-class _Prop_Relaxed_C_Popup_Parsing(aetools.NProperty):
- """Relaxed C Popup Parsing - Relax the function parser for C source files """
- which = 'ED15'
- want = 'bool'
-class _Prop_Remember_Font(aetools.NProperty):
- """Remember Font - Display a source file with its own font settings. """
- which = 'ED08'
- want = 'bool'
-class _Prop_Remember_Selection(aetools.NProperty):
- """Remember Selection - Restore the previous selection in a file when you open it. """
- which = 'ED09'
- want = 'bool'
-class _Prop_Remember_Window(aetools.NProperty):
- """Remember Window - Restore the last size and position for a source file window when you open it. """
- which = 'ED10'
- want = 'bool'
-class _Prop_Sort_Function_Popup(aetools.NProperty):
- """Sort Function Popup - """
- which = 'ED06'
- want = 'bool'
-class _Prop_Use_Drag__26__Drop_Editing(aetools.NProperty):
- """Use Drag & Drop Editing - Use Drag & Drop text editing. """
- which = 'ED04'
- want = 'bool'
-class _Prop_Use_Multiple_Undo(aetools.NProperty):
- """Use Multiple Undo - """
- which = 'ED07'
- want = 'bool'
-
-class Environment_Variable(aetools.ComponentItem):
- """Environment Variable - Environment variable for host OS """
- want = 'EnvV'
-class _Prop_value(aetools.NProperty):
- """value - Value of the environment variable """
- which = 'Valu'
- want = 'TEXT'
-
-class Error_Information(aetools.ComponentItem):
- """Error Information - Describes a single error or warning from the compiler or the linker. """
- want = 'ErrM'
-class _Prop_disk_file(aetools.NProperty):
- """disk file - The file where the error occurred. May not be returned for certain kinds of errors (eg, link errors). """
- which = 'file'
- want = 'fss '
-class _Prop_lineNumber(aetools.NProperty):
- """lineNumber - The line in the file where the error occurred. May not be returned for certain kinds of errors (eg, link errors). """
- which = 'ErrL'
- want = 'long'
-class _Prop_message(aetools.NProperty):
- """message - The error or warning message. """
- which = 'ErrS'
- want = 'TEXT'
-class _Prop_messageKind(aetools.NProperty):
- """messageKind - The type of error or warning. """
- which = 'ErrT'
- want = 'ErrT'
-
-class Function_Information(aetools.ComponentItem):
- """Function Information - Describes the location of any function or global data definition within the current project. """
- want = 'FDef'
-
-class File_Mappings(aetools.ComponentItem):
- """File Mappings - Mappings of extensions & file types to compilers """
- want = 'FLMP'
-class _Prop_Mappings(aetools.NProperty):
- """Mappings - """
- which = 'FMps'
- want = 'FMap'
-
-class File_Mapping(aetools.ComponentItem):
- """File Mapping - """
- want = 'FMap'
-class _Prop_Compiler(aetools.NProperty):
- """Compiler - """
- which = 'TA07'
- want = 'TEXT'
-class _Prop_Extension(aetools.NProperty):
- """Extension - """
- which = 'TA02'
- want = 'TEXT'
-class _Prop_File_Type(aetools.NProperty):
- """File Type - """
- which = 'PR04'
- want = 'TEXT'
-class _Prop_Ignored_by_Make(aetools.NProperty):
- """Ignored by Make - """
- which = 'TA06'
- want = 'bool'
-class _Prop_Launchable(aetools.NProperty):
- """Launchable - """
- which = 'TA05'
- want = 'bool'
-class _Prop_Precompiled(aetools.NProperty):
- """Precompiled - """
- which = 'TA03'
- want = 'bool'
-class _Prop_Resource_File(aetools.NProperty):
- """Resource File - """
- which = 'TA04'
- want = 'bool'
-
-class Global_Source_Trees(aetools.ComponentItem):
- """Global Source Trees - Globally-defined source tree roots """
- want = 'GSTs'
-class _Prop_Source_Trees(aetools.NProperty):
- """Source Trees - List of source tree roots """
- which = 'ST01'
- want = 'SrcT'
-
-class Extras(aetools.ComponentItem):
- """Extras - """
- want = 'GXTR'
-class _Prop_Automatic_Toolbar_Help(aetools.NProperty):
- """Automatic Toolbar Help - Automatically show balloon help in toolbar after delay """
- which = 'EX19'
- want = 'bool'
-class _Prop_External_Reference(aetools.NProperty):
- """External Reference - Which on-line function reference to use. """
- which = 'EX08'
- want = 'RefP'
-class _Prop_Full_Screen_Zoom(aetools.NProperty):
- """Full Screen Zoom - Zoom windows to the full screen width. """
- which = 'EX07'
- want = 'bool'
-class _Prop_Recent_Editor_Count(aetools.NProperty):
- """Recent Editor Count - Maximum number of editor documents to show in the \xd2Open Recent\xd3 menu """
- which = 'EX16'
- want = 'shor'
-class _Prop_Recent_Project_Count(aetools.NProperty):
- """Recent Project Count - Maximum number of project documents to show in the \xd2Open Recent\xd3 menu """
- which = 'EX17'
- want = 'shor'
-class _Prop_Use_Editor_Extensions(aetools.NProperty):
- """Use Editor Extensions - Controls the use of the Editor Extensions menu """
- which = 'EX10'
- want = 'bool'
-class _Prop_Use_External_Editor(aetools.NProperty):
- """Use External Editor - Controls whether CodeWarrior uses its own integrated editor or an external application for editing text files. """
- which = 'EX11'
- want = 'bool'
-class _Prop_Use_Script_Menu(aetools.NProperty):
- """Use Script Menu - Controls the use of the AppleScript menu """
- which = 'EX12'
- want = 'bool'
-class _Prop_Use_ToolServer_Menu(aetools.NProperty):
- """Use ToolServer Menu - Controls the use of the ToolServer menu """
- which = 'EX18'
- want = 'bool'
-
-class Build_Extras(aetools.ComponentItem):
- """Build Extras - """
- want = 'LXTR'
-class _Prop_Browser_Active(aetools.NProperty):
- """Browser Active - Allow the collection of browser information. """
- which = 'EX09'
- want = 'bool'
-class _Prop_Cache_Subproject_Data(aetools.NProperty):
- """Cache Subproject Data - """
- which = 'EX31'
- want = 'bool'
-class _Prop_Dump_Browser_Info(aetools.NProperty):
- """Dump Browser Info - """
- which = 'EX30'
- want = 'bool'
-class _Prop_Modification_Date_Caching(aetools.NProperty):
- """Modification Date Caching - """
- which = 'EX04'
- want = 'bool'
-
-class member_function(aetools.ComponentItem):
- """member function - A class member function or method. """
- want = 'MbFn'
-class _Prop_implementation_end_offset(aetools.NProperty):
- """implementation end offset - end of member function definition """
- which = 'DfEn'
- want = 'long'
-class _Prop_implementation_file(aetools.NProperty):
- """implementation file - Source file containing the member function definition """
- which = 'DfFl'
- want = 'fss '
-class _Prop_implementation_start_offset(aetools.NProperty):
- """implementation start offset - start of member function definition source code """
- which = 'DfSt'
- want = 'long'
-
-member_functions = member_function
-
-class Access_Paths(aetools.ComponentItem):
- """Access Paths - Contains the definitions of a project\xd5s access (search) paths. """
- want = 'PATH'
-class _Prop_Always_Full_Search(aetools.NProperty):
- """Always Full Search - To force the compiler to search for system includes like it searches for user includes. """
- which = 'PA02'
- want = 'bool'
-class _Prop_Convert_Paths(aetools.NProperty):
- """Convert Paths - Enables conversion of DOS & Unix-style relative paths when searching for files. """
- which = 'PA04'
- want = 'bool'
-class _Prop_Require_Framework_Includes(aetools.NProperty):
- """Require Framework Includes - Causes the IDE to only look in the framework access paths if a Mac OS X framework style include (i.e. <Carbon/Carbon.h> ) is used. """
- which = 'PA05'
- want = 'bool'
-class _Prop_System_Paths(aetools.NProperty):
- """System Paths - To add an access path for the include files. (Not supported in Pascal) """
- which = 'PA03'
- want = 'PInf'
-class _Prop_User_Paths(aetools.NProperty):
- """User Paths - To add an access path for the source files. """
- which = 'PA01'
- want = 'PInf'
-
-class Path_Information(aetools.ComponentItem):
- """Path Information - Contains all of the parameters that describe an access path. """
- want = 'PInf'
-class _Prop_format(aetools.NProperty):
- """format - Format of the a """
- which = 'Frmt'
- want = 'PthF'
-class _Prop_framework(aetools.NProperty):
- """framework - Is the path a Mac OS X framework style path? (This flag is readable but not writeable from AppleScript.) """
- which = 'Frmw'
- want = 'bool'
-class _Prop_host_flags(aetools.NProperty):
- """host flags - Bit fields enabling the access path for each host OS (1 = Mac OS, 2 = Windows) """
- which = 'HstF'
- want = 'long'
-class _Prop_origin(aetools.NProperty):
- """origin - """
- which = 'Orig'
- want = 'PPrm'
-class _Prop_recursive(aetools.NProperty):
- """recursive - Will the path be searched recursively? (Default is true) """
- which = 'Recu'
- want = 'bool'
-class _Prop_root(aetools.NProperty):
- """root - Name of the root of the relative path. Pre-defined values are \xd2Absolute\xd3, \xd2Project\xd3, \xd2CodeWarrior\xd3, and \xd2System\xd3. Anything else is a user-defined root. """
- which = 'Root'
- want = 'TEXT'
-
-class Plugin_Settings(aetools.ComponentItem):
- """Plugin Settings - Settings for plugin tools """
- want = 'PSTG'
-class _Prop_Disable_Third_Party_COM_Plugins(aetools.NProperty):
- """Disable Third Party COM Plugins - Disable COM plugins from third parties """
- which = 'PX02'
- want = 'bool'
-class _Prop_Plugin_Diagnostics_Level(aetools.NProperty):
- """Plugin Diagnostics Level - Plugin Diagnostics Level is for those who are developing plugins for the IDE and need to debug them. """
- which = 'PX01'
- want = 'PXdg'
-
-class Runtime_Settings(aetools.ComponentItem):
- """Runtime Settings - Runtime settings """
- want = 'RSTG'
-class _Prop_Command_Line_Arguments(aetools.NProperty):
- """Command Line Arguments - Extra command line args to pass to executable """
- which = 'RS02'
- want = 'TEXT'
-class _Prop_Environment_Variables(aetools.NProperty):
- """Environment Variables - Environment variables to use when running the executable """
- which = 'RS04'
- want = 'EnvV'
-class _Prop_Host_Application(aetools.NProperty):
- """Host Application - Host application for running/debugging libraries and code resources """
- which = 'RS01'
- want = 'RlPt'
-class _Prop_Working_Directory(aetools.NProperty):
- """Working Directory - Working directory to use when running the executable """
- which = 'RS03'
- want = 'TEXT'
-
-class Relative_Path(aetools.ComponentItem):
- """Relative Path - Relative path from some root """
- want = 'RlPt'
-
-class Shielded_Folder(aetools.ComponentItem):
- """Shielded Folder - """
- want = 'SFit'
-class _Prop_Expression_To_Match(aetools.NProperty):
- """Expression To Match - Regular expression which describes folders to skip """
- which = 'SF01'
- want = 'TEXT'
-class _Prop_Skip_Find_And_Compare_Operations(aetools.NProperty):
- """Skip Find And Compare Operations - Matching folders will be skipped during find and compare operations """
- which = 'SF03'
- want = 'bool'
-class _Prop_Skip_Project_Operations(aetools.NProperty):
- """Skip Project Operations - Matching folders will be skipped during project operations """
- which = 'SF02'
- want = 'bool'
-
-class Shielded_Folders(aetools.ComponentItem):
- """Shielded Folders - Folders skipped when performing project and find-and-compare operations """
- want = 'SHFL'
-class _Prop_Shielded_Items(aetools.NProperty):
- """Shielded Items - """
- which = 'SFis'
- want = 'SFit'
-
-class Syntax_Coloring(aetools.ComponentItem):
- """Syntax Coloring - """
- want = 'SNTX'
-class _Prop_Comment_Color(aetools.NProperty):
- """Comment Color - The color for comments. """
- which = 'GH02'
- want = 'cRGB'
-class _Prop_Keyword_Color(aetools.NProperty):
- """Keyword Color - The color for language keywords. """
- which = 'GH03'
- want = 'cRGB'
-class _Prop_String_Color(aetools.NProperty):
- """String Color - The color for strings. """
- which = 'GH04'
- want = 'cRGB'
-class _Prop_Syntax_Coloring(aetools.NProperty):
- """Syntax Coloring - Mark keywords and comments with color. """
- which = 'GH01'
- want = 'bool'
-
-class Segment(aetools.ComponentItem):
- """Segment - A segment or group in the project """
- want = 'Seg '
-class _Prop_filecount(aetools.NProperty):
- """filecount - """
- which = 'NumF'
- want = 'shor'
-class _Prop_seg_2d_locked(aetools.NProperty):
- """seg-locked - Is the segment locked ? [68K only] """
- which = 'PLck'
- want = 'bool'
-class _Prop_seg_2d_preloaded(aetools.NProperty):
- """seg-preloaded - Is the segment preloaded ? [68K only] """
- which = 'Prel'
- want = 'bool'
-class _Prop_seg_2d_protected(aetools.NProperty):
- """seg-protected - Is the segment protected ? [68K only] """
- which = 'Prot'
- want = 'bool'
-class _Prop_seg_2d_purgeable(aetools.NProperty):
- """seg-purgeable - Is the segment purgeable ? [68K only] """
- which = 'Purg'
- want = 'bool'
-class _Prop_seg_2d_system_heap(aetools.NProperty):
- """seg-system heap - Is the segment loaded into the system heap ? [68K only] """
- which = 'SysH'
- want = 'bool'
-
-class ProjectFile(aetools.ComponentItem):
- """ProjectFile - A file contained in a project """
- want = 'SrcF'
-class _Prop_codesize(aetools.NProperty):
- """codesize - The size of this file\xd5s code. """
- which = 'CSiz'
- want = 'long'
-class _Prop_datasize(aetools.NProperty):
- """datasize - The size of this file\xd5s data. """
- which = 'DSiz'
- want = 'long'
-class _Prop_filetype(aetools.NProperty):
- """filetype - What kind of file is this ? """
- which = 'SrcT'
- want = 'SrcT'
-class _Prop_includes(aetools.NProperty):
- """includes - """
- which = 'IncF'
- want = 'fss '
-class _Prop_initialize_before(aetools.NProperty):
- """initialize before - Initialize the shared library before the main application. """
- which = 'Bfor'
- want = 'bool'
-class _Prop_symbols(aetools.NProperty):
- """symbols - Are debugging symbols generated for this file ? """
- which = 'SymG'
- want = 'bool'
-class _Prop_up_to_date(aetools.NProperty):
- """up to date - Has the file been compiled since its last modification ? """
- which = 'UpTD'
- want = 'bool'
-class _Prop_weak_link(aetools.NProperty):
- """weak link - Is this file imported weakly into the project ? [PowerPC only] """
- which = 'Weak'
- want = 'bool'
-
-class Source_Tree(aetools.ComponentItem):
- """Source Tree - User-defined source tree root """
- want = 'SrcT'
-class _Prop_path(aetools.NProperty):
- """path - path for the user-defined source tree root """
- which = 'Path'
- want = 'TEXT'
-class _Prop_path_kind(aetools.NProperty):
- """path kind - kind of path """
- which = 'Kind'
- want = 'STKd'
-
-class Target_Settings(aetools.ComponentItem):
- """Target Settings - Contains the definitions of a project\xd5s target. """
- want = 'TARG'
-class _Prop_Linker(aetools.NProperty):
- """Linker - The name of the current linker. """
- which = 'TA01'
- want = 'TEXT'
-class _Prop_Output_Directory_Location(aetools.NProperty):
- """Output Directory Location - Location of output directory """
- which = 'TA16'
- want = 'RlPt'
-class _Prop_Output_Directory_Origin(aetools.NProperty):
- """Output Directory Origin - Origin of path to output directory. Usage of this property is deprecated. Use the \xd2Output Directory Location\xd3 property instead. """
- which = 'TA12'
- want = 'PPrm'
-class _Prop_Output_Directory_Path(aetools.NProperty):
- """Output Directory Path - Path to output directory. Usage of this property is deprecated. Use the \xd2Output Directory Location\xd3 property instead. """
- which = 'TA11'
- want = 'TEXT'
-class _Prop_Post_Linker(aetools.NProperty):
- """Post Linker - """
- which = 'TA09'
- want = 'TEXT'
-class _Prop_Pre_Linker(aetools.NProperty):
- """Pre Linker - """
- which = 'TA13'
- want = 'TEXT'
-class _Prop_Target_Name(aetools.NProperty):
- """Target Name - """
- which = 'TA10'
- want = 'TEXT'
-class _Prop_Use_Relative_Paths(aetools.NProperty):
- """Use Relative Paths - Save project entries using relative paths """
- which = 'TA15'
- want = 'bool'
-
-class Target_Source_Trees(aetools.ComponentItem):
- """Target Source Trees - Target-specific user-defined source tree roots """
- want = 'TSTs'
-
-class VCS_Setup(aetools.ComponentItem):
- """VCS Setup - The version control system preferences. """
- want = 'VCSs'
-class _Prop_Always_Prompt(aetools.NProperty):
- """Always Prompt - Always show login dialog """
- which = 'VC07'
- want = 'bool'
-class _Prop_Auto_Connect(aetools.NProperty):
- """Auto Connect - Automatically connect to database when starting. """
- which = 'VC05'
- want = 'bool'
-class _Prop_Connection_Method(aetools.NProperty):
- """Connection Method - Name of Version Control System to use. """
- which = 'VC02'
- want = 'TEXT'
-class _Prop_Database_Path(aetools.NProperty):
- """Database Path - Path to the VCS database. """
- which = 'VC09'
- want = 'RlPt'
-class _Prop_Local_Path(aetools.NProperty):
- """Local Path - Path to the local root """
- which = 'VC10'
- want = 'RlPt'
-class _Prop_Mount_Volume(aetools.NProperty):
- """Mount Volume - Attempt to mount the database volume if it isn't available. """
- which = 'VC08'
- want = 'bool'
-class _Prop_Password(aetools.NProperty):
- """Password - The password for the VCS. """
- which = 'VC04'
- want = 'TEXT'
-class _Prop_Store_Password(aetools.NProperty):
- """Store Password - Store the password. """
- which = 'VC06'
- want = 'bool'
-class _Prop_Use_Global_Settings(aetools.NProperty):
- """Use Global Settings - Use the global VCS settings by default """
- which = 'VC11'
- want = 'bool'
-class _Prop_Username(aetools.NProperty):
- """Username - The user name for the VCS. """
- which = 'VC03'
- want = 'TEXT'
-class _Prop_VCS_Active(aetools.NProperty):
- """VCS Active - Use Version Control """
- which = 'VC01'
- want = 'bool'
-
-class Font(aetools.ComponentItem):
- """Font - """
- want = 'mFNT'
-class _Prop_Auto_Indent(aetools.NProperty):
- """Auto Indent - Indent new lines automatically. """
- which = 'FN01'
- want = 'bool'
-class _Prop_Tab_Indents_Selection(aetools.NProperty):
- """Tab Indents Selection - Tab indents selection when multiple lines are selected """
- which = 'FN03'
- want = 'bool'
-class _Prop_Tab_Inserts_Spaces(aetools.NProperty):
- """Tab Inserts Spaces - Insert spaces instead of tab character """
- which = 'FN04'
- want = 'bool'
-class _Prop_Tab_Size(aetools.NProperty):
- """Tab Size - """
- which = 'FN02'
- want = 'shor'
-class _Prop_Text_Font(aetools.NProperty):
- """Text Font - The font used in editing windows. """
- which = 'ptxf'
- want = 'TEXT'
-class _Prop_Text_Size(aetools.NProperty):
- """Text Size - The size of the text in an editing window. """
- which = 'ptps'
- want = 'shor'
-Browser_Coloring._superclassnames = []
-Browser_Coloring._privpropdict = {
- 'Browser_Keywords' : _Prop_Browser_Keywords,
- 'Classes_Color' : _Prop_Classes_Color,
- 'Constants_Color' : _Prop_Constants_Color,
- 'Enums_Color' : _Prop_Enums_Color,
- 'Functions_Color' : _Prop_Functions_Color,
- 'Globals_Color' : _Prop_Globals_Color,
- 'Macros_Color' : _Prop_Macros_Color,
- 'Template_Commands_in_Menu' : _Prop_Template_Commands_in_Menu,
- 'Templates_Color' : _Prop_Templates_Color,
- 'Typedefs_Color' : _Prop_Typedefs_Color,
-}
-Browser_Coloring._privelemdict = {
-}
-Build_Settings._superclassnames = []
-Build_Settings._privpropdict = {
- 'Build_Before_Running' : _Prop_Build_Before_Running,
- 'Compiler_Thread_Stack_Size' : _Prop_Compiler_Thread_Stack_Size,
- 'Completion_Sound' : _Prop_Completion_Sound,
- 'Failure_Sound' : _Prop_Failure_Sound,
- 'Include_Cache_Size' : _Prop_Include_Cache_Size,
- 'Save_Before_Building' : _Prop_Save_Before_Building,
- 'Success_Sound' : _Prop_Success_Sound,
-}
-Build_Settings._privelemdict = {
-}
-base_class._superclassnames = []
-base_class._privpropdict = {
- 'access' : _Prop_access,
- 'class_' : _Prop_class_,
- 'virtual' : _Prop_virtual,
-}
-base_class._privelemdict = {
-}
-Custom_Keywords._superclassnames = []
-Custom_Keywords._privpropdict = {
- 'Custom_Color_1' : _Prop_Custom_Color_1,
- 'Custom_Color_2' : _Prop_Custom_Color_2,
- 'Custom_Color_3' : _Prop_Custom_Color_3,
- 'Custom_Color_4' : _Prop_Custom_Color_4,
-}
-Custom_Keywords._privelemdict = {
-}
-browser_catalog._superclassnames = []
-browser_catalog._privpropdict = {
-}
-browser_catalog._privelemdict = {
- 'class_' : class_,
-}
-class_._superclassnames = []
-class_._privpropdict = {
- 'all_subclasses' : _Prop_all_subclasses,
- 'declaration_end_offset' : _Prop_declaration_end_offset,
- 'declaration_file' : _Prop_declaration_file,
- 'declaration_start_offset' : _Prop_declaration_start_offset,
- 'language' : _Prop_language,
- 'name' : _Prop_name,
- 'subclasses' : _Prop_subclasses,
-}
-class_._privelemdict = {
- 'base_class' : base_class,
- 'data_member' : data_member,
- 'member_function' : member_function,
-}
-Debugger_Display._superclassnames = []
-Debugger_Display._privpropdict = {
- 'Default_Array_Size' : _Prop_Default_Array_Size,
- 'Show_As_Decimal' : _Prop_Show_As_Decimal,
- 'Show_Locals' : _Prop_Show_Locals,
- 'Show_Variable_Types' : _Prop_Show_Variable_Types,
- 'Sort_By_Method' : _Prop_Sort_By_Method,
- 'Threads_in_Window' : _Prop_Threads_in_Window,
- 'Use_RTTI' : _Prop_Use_RTTI,
- 'Variable_Changed_Hilite' : _Prop_Variable_Changed_Hilite,
- 'Variable_Hints' : _Prop_Variable_Hints,
- 'Watchpoint_Hilite' : _Prop_Watchpoint_Hilite,
-}
-Debugger_Display._privelemdict = {
-}
-Debugger_Global._superclassnames = []
-Debugger_Global._privpropdict = {
- 'Auto_Target_Libraries' : _Prop_Auto_Target_Libraries,
- 'Cache_Edited_Files' : _Prop_Cache_Edited_Files,
- 'Confirm_Kill' : _Prop_Confirm_Kill,
- 'Dont_Step_in_Runtime' : _Prop_Dont_Step_in_Runtime,
- 'File_Cache_Duration' : _Prop_File_Cache_Duration,
- 'Ignore_Mod_Dates' : _Prop_Ignore_Mod_Dates,
- 'Launch_Apps_on_Open' : _Prop_Launch_Apps_on_Open,
- 'Open_All_Classes' : _Prop_Open_All_Classes,
- 'Select_Stack_Crawl' : _Prop_Select_Stack_Crawl,
- 'Stop_at_Main' : _Prop_Stop_at_Main,
-}
-Debugger_Global._privelemdict = {
-}
-Debugger_Target._superclassnames = []
-Debugger_Target._privpropdict = {
- 'Auto_Target_Libraries' : _Prop_Auto_Target_Libraries,
- 'Cache_symbolics' : _Prop_Cache_symbolics,
- 'Data_Update_Interval' : _Prop_Data_Update_Interval,
- 'Log_System_Messages' : _Prop_Log_System_Messages,
- 'Relocated_Executable_Path' : _Prop_Relocated_Executable_Path,
- 'Stop_at_temp_breakpoint' : _Prop_Stop_at_temp_breakpoint,
- 'Temp_Breakpoint_Type' : _Prop_Temp_Breakpoint_Type,
- 'Temp_breakpoint_names' : _Prop_Temp_breakpoint_names,
- 'Update_Data_While_Running' : _Prop_Update_Data_While_Running,
-}
-Debugger_Target._privelemdict = {
-}
-Debugger_Windowing._superclassnames = []
-Debugger_Windowing._privpropdict = {
- 'Debugging_Start_Action' : _Prop_Debugging_Start_Action,
- 'Do_Nothing_To_Projects' : _Prop_Do_Nothing_To_Projects,
-}
-Debugger_Windowing._privelemdict = {
-}
-data_member._superclassnames = []
-data_member._privpropdict = {
- 'access' : _Prop_access,
- 'declaration_end_offset' : _Prop_declaration_end_offset,
- 'declaration_start_offset' : _Prop_declaration_start_offset,
- 'name' : _Prop_name,
- 'static' : _Prop_static,
-}
-data_member._privelemdict = {
-}
-Editor._superclassnames = []
-Editor._privpropdict = {
- 'Background_Color' : _Prop_Background_Color,
- 'Balance' : _Prop_Balance,
- 'Context_Popup_Delay' : _Prop_Context_Popup_Delay,
- 'Default_Text_File_Format' : _Prop_Default_Text_File_Format,
- 'Dynamic_Scroll' : _Prop_Dynamic_Scroll,
- 'Flash_Delay' : _Prop_Flash_Delay,
- 'Left_Margin_Line_Select' : _Prop_Left_Margin_Line_Select,
- 'Main_Text_Color' : _Prop_Main_Text_Color,
- 'Relaxed_C_Popup_Parsing' : _Prop_Relaxed_C_Popup_Parsing,
- 'Remember_Font' : _Prop_Remember_Font,
- 'Remember_Selection' : _Prop_Remember_Selection,
- 'Remember_Window' : _Prop_Remember_Window,
- 'Sort_Function_Popup' : _Prop_Sort_Function_Popup,
- 'Use_Drag__26__Drop_Editing' : _Prop_Use_Drag__26__Drop_Editing,
- 'Use_Multiple_Undo' : _Prop_Use_Multiple_Undo,
-}
-Editor._privelemdict = {
-}
-Environment_Variable._superclassnames = []
-Environment_Variable._privpropdict = {
- 'name' : _Prop_name,
- 'value' : _Prop_value,
-}
-Environment_Variable._privelemdict = {
-}
-Error_Information._superclassnames = []
-Error_Information._privpropdict = {
- 'disk_file' : _Prop_disk_file,
- 'lineNumber' : _Prop_lineNumber,
- 'message' : _Prop_message,
- 'messageKind' : _Prop_messageKind,
-}
-Error_Information._privelemdict = {
-}
-Function_Information._superclassnames = []
-Function_Information._privpropdict = {
- 'disk_file' : _Prop_disk_file,
- 'lineNumber' : _Prop_lineNumber,
-}
-Function_Information._privelemdict = {
-}
-File_Mappings._superclassnames = []
-File_Mappings._privpropdict = {
- 'Mappings' : _Prop_Mappings,
-}
-File_Mappings._privelemdict = {
-}
-File_Mapping._superclassnames = []
-File_Mapping._privpropdict = {
- 'Compiler' : _Prop_Compiler,
- 'Extension' : _Prop_Extension,
- 'File_Type' : _Prop_File_Type,
- 'Ignored_by_Make' : _Prop_Ignored_by_Make,
- 'Launchable' : _Prop_Launchable,
- 'Precompiled' : _Prop_Precompiled,
- 'Resource_File' : _Prop_Resource_File,
-}
-File_Mapping._privelemdict = {
-}
-Global_Source_Trees._superclassnames = []
-Global_Source_Trees._privpropdict = {
- 'Source_Trees' : _Prop_Source_Trees,
-}
-Global_Source_Trees._privelemdict = {
-}
-Extras._superclassnames = []
-Extras._privpropdict = {
- 'Automatic_Toolbar_Help' : _Prop_Automatic_Toolbar_Help,
- 'External_Reference' : _Prop_External_Reference,
- 'Full_Screen_Zoom' : _Prop_Full_Screen_Zoom,
- 'Recent_Editor_Count' : _Prop_Recent_Editor_Count,
- 'Recent_Project_Count' : _Prop_Recent_Project_Count,
- 'Use_Editor_Extensions' : _Prop_Use_Editor_Extensions,
- 'Use_External_Editor' : _Prop_Use_External_Editor,
- 'Use_Script_Menu' : _Prop_Use_Script_Menu,
- 'Use_ToolServer_Menu' : _Prop_Use_ToolServer_Menu,
-}
-Extras._privelemdict = {
-}
-Build_Extras._superclassnames = []
-Build_Extras._privpropdict = {
- 'Browser_Active' : _Prop_Browser_Active,
- 'Cache_Subproject_Data' : _Prop_Cache_Subproject_Data,
- 'Dump_Browser_Info' : _Prop_Dump_Browser_Info,
- 'Modification_Date_Caching' : _Prop_Modification_Date_Caching,
-}
-Build_Extras._privelemdict = {
-}
-member_function._superclassnames = []
-member_function._privpropdict = {
- 'access' : _Prop_access,
- 'declaration_end_offset' : _Prop_declaration_end_offset,
- 'declaration_file' : _Prop_declaration_file,
- 'declaration_start_offset' : _Prop_declaration_start_offset,
- 'implementation_end_offset' : _Prop_implementation_end_offset,
- 'implementation_file' : _Prop_implementation_file,
- 'implementation_start_offset' : _Prop_implementation_start_offset,
- 'name' : _Prop_name,
- 'static' : _Prop_static,
- 'virtual' : _Prop_virtual,
-}
-member_function._privelemdict = {
-}
-Access_Paths._superclassnames = []
-Access_Paths._privpropdict = {
- 'Always_Full_Search' : _Prop_Always_Full_Search,
- 'Convert_Paths' : _Prop_Convert_Paths,
- 'Require_Framework_Includes' : _Prop_Require_Framework_Includes,
- 'System_Paths' : _Prop_System_Paths,
- 'User_Paths' : _Prop_User_Paths,
-}
-Access_Paths._privelemdict = {
-}
-Path_Information._superclassnames = []
-Path_Information._privpropdict = {
- 'format' : _Prop_format,
- 'framework' : _Prop_framework,
- 'host_flags' : _Prop_host_flags,
- 'name' : _Prop_name,
- 'origin' : _Prop_origin,
- 'recursive' : _Prop_recursive,
- 'root' : _Prop_root,
-}
-Path_Information._privelemdict = {
-}
-Plugin_Settings._superclassnames = []
-Plugin_Settings._privpropdict = {
- 'Disable_Third_Party_COM_Plugins' : _Prop_Disable_Third_Party_COM_Plugins,
- 'Plugin_Diagnostics_Level' : _Prop_Plugin_Diagnostics_Level,
-}
-Plugin_Settings._privelemdict = {
-}
-Runtime_Settings._superclassnames = []
-Runtime_Settings._privpropdict = {
- 'Command_Line_Arguments' : _Prop_Command_Line_Arguments,
- 'Environment_Variables' : _Prop_Environment_Variables,
- 'Host_Application' : _Prop_Host_Application,
- 'Working_Directory' : _Prop_Working_Directory,
-}
-Runtime_Settings._privelemdict = {
-}
-Relative_Path._superclassnames = []
-Relative_Path._privpropdict = {
- 'format' : _Prop_format,
- 'name' : _Prop_name,
- 'origin' : _Prop_origin,
- 'root' : _Prop_root,
-}
-Relative_Path._privelemdict = {
-}
-Shielded_Folder._superclassnames = []
-Shielded_Folder._privpropdict = {
- 'Expression_To_Match' : _Prop_Expression_To_Match,
- 'Skip_Find_And_Compare_Operations' : _Prop_Skip_Find_And_Compare_Operations,
- 'Skip_Project_Operations' : _Prop_Skip_Project_Operations,
-}
-Shielded_Folder._privelemdict = {
-}
-Shielded_Folders._superclassnames = []
-Shielded_Folders._privpropdict = {
- 'Shielded_Items' : _Prop_Shielded_Items,
-}
-Shielded_Folders._privelemdict = {
-}
-Syntax_Coloring._superclassnames = []
-Syntax_Coloring._privpropdict = {
- 'Comment_Color' : _Prop_Comment_Color,
- 'Custom_Color_1' : _Prop_Custom_Color_1,
- 'Custom_Color_2' : _Prop_Custom_Color_2,
- 'Custom_Color_3' : _Prop_Custom_Color_3,
- 'Custom_Color_4' : _Prop_Custom_Color_4,
- 'Keyword_Color' : _Prop_Keyword_Color,
- 'String_Color' : _Prop_String_Color,
- 'Syntax_Coloring' : _Prop_Syntax_Coloring,
-}
-Syntax_Coloring._privelemdict = {
-}
-Segment._superclassnames = []
-Segment._privpropdict = {
- 'filecount' : _Prop_filecount,
- 'name' : _Prop_name,
- 'seg_2d_locked' : _Prop_seg_2d_locked,
- 'seg_2d_preloaded' : _Prop_seg_2d_preloaded,
- 'seg_2d_protected' : _Prop_seg_2d_protected,
- 'seg_2d_purgeable' : _Prop_seg_2d_purgeable,
- 'seg_2d_system_heap' : _Prop_seg_2d_system_heap,
-}
-Segment._privelemdict = {
-}
-ProjectFile._superclassnames = []
-ProjectFile._privpropdict = {
- 'codesize' : _Prop_codesize,
- 'datasize' : _Prop_datasize,
- 'disk_file' : _Prop_disk_file,
- 'filetype' : _Prop_filetype,
- 'includes' : _Prop_includes,
- 'initialize_before' : _Prop_initialize_before,
- 'name' : _Prop_name,
- 'symbols' : _Prop_symbols,
- 'up_to_date' : _Prop_up_to_date,
- 'weak_link' : _Prop_weak_link,
-}
-ProjectFile._privelemdict = {
-}
-Source_Tree._superclassnames = []
-Source_Tree._privpropdict = {
- 'format' : _Prop_format,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'path_kind' : _Prop_path_kind,
-}
-Source_Tree._privelemdict = {
-}
-Target_Settings._superclassnames = []
-Target_Settings._privpropdict = {
- 'Linker' : _Prop_Linker,
- 'Output_Directory_Location' : _Prop_Output_Directory_Location,
- 'Output_Directory_Origin' : _Prop_Output_Directory_Origin,
- 'Output_Directory_Path' : _Prop_Output_Directory_Path,
- 'Post_Linker' : _Prop_Post_Linker,
- 'Pre_Linker' : _Prop_Pre_Linker,
- 'Target_Name' : _Prop_Target_Name,
- 'Use_Relative_Paths' : _Prop_Use_Relative_Paths,
-}
-Target_Settings._privelemdict = {
-}
-Target_Source_Trees._superclassnames = []
-Target_Source_Trees._privpropdict = {
- 'Source_Trees' : _Prop_Source_Trees,
-}
-Target_Source_Trees._privelemdict = {
-}
-VCS_Setup._superclassnames = []
-VCS_Setup._privpropdict = {
- 'Always_Prompt' : _Prop_Always_Prompt,
- 'Auto_Connect' : _Prop_Auto_Connect,
- 'Connection_Method' : _Prop_Connection_Method,
- 'Database_Path' : _Prop_Database_Path,
- 'Local_Path' : _Prop_Local_Path,
- 'Mount_Volume' : _Prop_Mount_Volume,
- 'Password' : _Prop_Password,
- 'Store_Password' : _Prop_Store_Password,
- 'Use_Global_Settings' : _Prop_Use_Global_Settings,
- 'Username' : _Prop_Username,
- 'VCS_Active' : _Prop_VCS_Active,
-}
-VCS_Setup._privelemdict = {
-}
-Font._superclassnames = []
-Font._privpropdict = {
- 'Auto_Indent' : _Prop_Auto_Indent,
- 'Tab_Indents_Selection' : _Prop_Tab_Indents_Selection,
- 'Tab_Inserts_Spaces' : _Prop_Tab_Inserts_Spaces,
- 'Tab_Size' : _Prop_Tab_Size,
- 'Text_Font' : _Prop_Text_Font,
- 'Text_Size' : _Prop_Text_Size,
-}
-Font._privelemdict = {
-}
-_Enum_Acce = {
- 'public' : 'Publ', #
- 'protected' : 'Prot', #
- 'private' : 'Priv', #
-}
-
-_Enum_BXbr = {
- 'Always_Build' : 'BXb1', # Always build the target before running.
- 'Ask_Build' : 'BXb2', # Ask before building the target when running.
- 'Never_Build' : 'BXb3', # Never before building the target before running.
-}
-
-_Enum_DbSA = {
- 'No_Action' : 'DSA1', # Don\xd5t do anything to non-debug windows
- 'Hide_Windows' : 'DSA2', # Hide non-debugging windows
- 'Collapse_Windows' : 'DSA3', # Collapse non-debugging windows
- 'Close_Windows' : 'DSA4', # Close non-debugging windows
-}
-
-_Enum_DgBL = {
- 'Always' : 'DgB0', # Always build before debugging.
- 'Never' : 'DgB1', # Never build before debugging.
- 'Ask' : 'DgB2', # Ask about building before debugging.
-}
-
-_Enum_ErrT = {
- 'information' : 'ErIn', #
- 'compiler_warning' : 'ErCW', #
- 'compiler_error' : 'ErCE', #
- 'definition' : 'ErDf', #
- 'linker_warning' : 'ErLW', #
- 'linker_error' : 'ErLE', #
- 'find_result' : 'ErFn', #
- 'generic_error' : 'ErGn', #
-}
-
-_Enum_Inte = {
- 'never_interact' : 'eNvr', # Never allow user interactions
- 'interact_with_self' : 'eInS', # Allow user interaction only when an AppleEvent is sent from within CodeWarrior
- 'interact_with_local' : 'eInL', # Allow user interaction when AppleEvents are sent from applications on the same machine (default)
- 'interact_with_all' : 'eInA', # Allow user interaction from both local and remote AppleEvents
-}
-
-_Enum_Lang = {
- 'C' : 'LC ', #
- 'C_2b__2b_' : 'LC++', #
- 'Pascal' : 'LP ', #
- 'Object_Pascal' : 'LP++', #
- 'Java' : 'LJav', #
- 'Assembler' : 'LAsm', #
- 'Unknown' : 'L? ', #
-}
-
-_Enum_PPrm = {
- 'absolute' : 'Abso', # An absolute path name, including volume name.
- 'project_relative' : 'PRel', # A path relative to the current project\xd5s folder.
- 'shell_relative' : 'SRel', # A path relative to the CodeWarrior\xaa folder.
- 'system_relative' : 'YRel', # A path relative to the system folder
- 'root_relative' : 'RRel', #
-}
-
-_Enum_PXdg = {
- 'Diagnose_None' : 'PXd1', # No Plugin Diagnostics.
- 'Diagnose_Errors' : 'PXd2', # Plugin Diagnostics for errors only.
- 'Diagnose_All' : 'PXd3', # Plugin Diagnostics for everything.
-}
-
-_Enum_PthF = {
- 'Generic_Path' : 'PFGn', #
- 'MacOS_Path' : 'PFMc', # MacOS path using colon as separator
- 'Windows_Path' : 'PFWn', # Windows path using backslash as separator
- 'Unix_Path' : 'PFUx', # Unix path using slash as separator
-}
-
-_Enum_RefP = {
- 'Think_Reference' : 'DanR', #
- 'QuickView' : 'ALTV', #
-}
-
-_Enum_STKd = {
- 'Absolute_Path' : 'STK0', # The \xd2path\xd3 property is an absolute path to the location of the source tree.
- 'Registry_Key' : 'STK1', # The \xd2path\xd3 property is the name of a registry key that contains the path to the root.
- 'Environment_Variable' : 'STK2', # The \xd2path\xd3 property is the name of an environment variable that contains the path to the root.
-}
-
-_Enum_SrcT = {
- 'source' : 'FTxt', # A source file (.c, .cp, .p, etc).
- 'unknown' : 'FUnk', # An unknown file type.
-}
-
-_Enum_TmpB = {
- 'User_Specified' : 'Usrs', # Use user specified symbols when setting temporary breakpoints on program launch.
- 'Default' : 'Dflt', # Use system default symbols when setting temporary breakpoints on program launch.
-}
-
-_Enum_TxtF = {
- 'MacOS' : 'TxF0', # MacOS text format
- 'DOS' : 'TxF1', # DOS text format
- 'Unix' : 'TxF2', # Unix text format
-}
-
-_Enum_savo = {
- 'yes' : 'yes ', # Save changes
- 'no' : 'no ', # Do not save changes
- 'ask' : 'ask ', # Ask the user whether to save
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'BRKW' : Browser_Coloring,
- 'BSTG' : Build_Settings,
- 'BsCl' : base_class,
- 'CUKW' : Custom_Keywords,
- 'Cata' : browser_catalog,
- 'Clas' : class_,
- 'DbDS' : Debugger_Display,
- 'DbGL' : Debugger_Global,
- 'DbTG' : Debugger_Target,
- 'DbWN' : Debugger_Windowing,
- 'DtMb' : data_member,
- 'EDTR' : Editor,
- 'EnvV' : Environment_Variable,
- 'ErrM' : Error_Information,
- 'FDef' : Function_Information,
- 'FLMP' : File_Mappings,
- 'FMap' : File_Mapping,
- 'GSTs' : Global_Source_Trees,
- 'GXTR' : Extras,
- 'LXTR' : Build_Extras,
- 'MbFn' : member_function,
- 'PATH' : Access_Paths,
- 'PInf' : Path_Information,
- 'PSTG' : Plugin_Settings,
- 'RSTG' : Runtime_Settings,
- 'RlPt' : Relative_Path,
- 'SFit' : Shielded_Folder,
- 'SHFL' : Shielded_Folders,
- 'SNTX' : Syntax_Coloring,
- 'Seg ' : Segment,
- 'SrcF' : ProjectFile,
- 'SrcT' : Source_Tree,
- 'TARG' : Target_Settings,
- 'TSTs' : Target_Source_Trees,
- 'VCSs' : VCS_Setup,
- 'mFNT' : Font,
-}
-
-_propdeclarations = {
- 'Acce' : _Prop_access,
- 'BW00' : _Prop_Browser_Keywords,
- 'BW01' : _Prop_Classes_Color,
- 'BW02' : _Prop_Constants_Color,
- 'BW03' : _Prop_Enums_Color,
- 'BW04' : _Prop_Functions_Color,
- 'BW05' : _Prop_Globals_Color,
- 'BW06' : _Prop_Macros_Color,
- 'BW07' : _Prop_Templates_Color,
- 'BW08' : _Prop_Typedefs_Color,
- 'BW10' : _Prop_Template_Commands_in_Menu,
- 'BX01' : _Prop_Completion_Sound,
- 'BX02' : _Prop_Success_Sound,
- 'BX03' : _Prop_Failure_Sound,
- 'BX04' : _Prop_Build_Before_Running,
- 'BX05' : _Prop_Include_Cache_Size,
- 'BX06' : _Prop_Compiler_Thread_Stack_Size,
- 'BX07' : _Prop_Save_Before_Building,
- 'Bfor' : _Prop_initialize_before,
- 'CSiz' : _Prop_codesize,
- 'Clas' : _Prop_class_,
- 'DSiz' : _Prop_datasize,
- 'Db01' : _Prop_Show_Variable_Types,
- 'Db02' : _Prop_Sort_By_Method,
- 'Db03' : _Prop_Use_RTTI,
- 'Db04' : _Prop_Threads_in_Window,
- 'Db05' : _Prop_Variable_Hints,
- 'Db06' : _Prop_Watchpoint_Hilite,
- 'Db07' : _Prop_Variable_Changed_Hilite,
- 'Db08' : _Prop_Default_Array_Size,
- 'Db09' : _Prop_Show_Locals,
- 'Db10' : _Prop_Show_As_Decimal,
- 'DcEn' : _Prop_declaration_end_offset,
- 'DcFl' : _Prop_declaration_file,
- 'DcSt' : _Prop_declaration_start_offset,
- 'DfEn' : _Prop_implementation_end_offset,
- 'DfFl' : _Prop_implementation_file,
- 'DfSt' : _Prop_implementation_start_offset,
- 'Dg01' : _Prop_Ignore_Mod_Dates,
- 'Dg02' : _Prop_Open_All_Classes,
- 'Dg03' : _Prop_Launch_Apps_on_Open,
- 'Dg04' : _Prop_Confirm_Kill,
- 'Dg05' : _Prop_Stop_at_Main,
- 'Dg06' : _Prop_Select_Stack_Crawl,
- 'Dg07' : _Prop_Dont_Step_in_Runtime,
- 'Dg11' : _Prop_Auto_Target_Libraries,
- 'Dg12' : _Prop_Cache_Edited_Files,
- 'Dg13' : _Prop_File_Cache_Duration,
- 'Dt02' : _Prop_Log_System_Messages,
- 'Dt08' : _Prop_Update_Data_While_Running,
- 'Dt09' : _Prop_Data_Update_Interval,
- 'Dt10' : _Prop_Relocated_Executable_Path,
- 'Dt13' : _Prop_Stop_at_temp_breakpoint,
- 'Dt14' : _Prop_Temp_breakpoint_names,
- 'Dt15' : _Prop_Cache_symbolics,
- 'Dt16' : _Prop_Temp_Breakpoint_Type,
- 'Dw01' : _Prop_Debugging_Start_Action,
- 'Dw02' : _Prop_Do_Nothing_To_Projects,
- 'ED01' : _Prop_Flash_Delay,
- 'ED02' : _Prop_Dynamic_Scroll,
- 'ED03' : _Prop_Balance,
- 'ED04' : _Prop_Use_Drag__26__Drop_Editing,
- 'ED06' : _Prop_Sort_Function_Popup,
- 'ED07' : _Prop_Use_Multiple_Undo,
- 'ED08' : _Prop_Remember_Font,
- 'ED09' : _Prop_Remember_Selection,
- 'ED10' : _Prop_Remember_Window,
- 'ED12' : _Prop_Main_Text_Color,
- 'ED13' : _Prop_Background_Color,
- 'ED14' : _Prop_Context_Popup_Delay,
- 'ED15' : _Prop_Relaxed_C_Popup_Parsing,
- 'ED16' : _Prop_Left_Margin_Line_Select,
- 'ED17' : _Prop_Default_Text_File_Format,
- 'EX04' : _Prop_Modification_Date_Caching,
- 'EX07' : _Prop_Full_Screen_Zoom,
- 'EX08' : _Prop_External_Reference,
- 'EX09' : _Prop_Browser_Active,
- 'EX10' : _Prop_Use_Editor_Extensions,
- 'EX11' : _Prop_Use_External_Editor,
- 'EX12' : _Prop_Use_Script_Menu,
- 'EX16' : _Prop_Recent_Editor_Count,
- 'EX17' : _Prop_Recent_Project_Count,
- 'EX18' : _Prop_Use_ToolServer_Menu,
- 'EX19' : _Prop_Automatic_Toolbar_Help,
- 'EX30' : _Prop_Dump_Browser_Info,
- 'EX31' : _Prop_Cache_Subproject_Data,
- 'ErrL' : _Prop_lineNumber,
- 'ErrS' : _Prop_message,
- 'ErrT' : _Prop_messageKind,
- 'FMps' : _Prop_Mappings,
- 'FN01' : _Prop_Auto_Indent,
- 'FN02' : _Prop_Tab_Size,
- 'FN03' : _Prop_Tab_Indents_Selection,
- 'FN04' : _Prop_Tab_Inserts_Spaces,
- 'Frmt' : _Prop_format,
- 'Frmw' : _Prop_framework,
- 'GH01' : _Prop_Syntax_Coloring,
- 'GH02' : _Prop_Comment_Color,
- 'GH03' : _Prop_Keyword_Color,
- 'GH04' : _Prop_String_Color,
- 'GH05' : _Prop_Custom_Color_1,
- 'GH06' : _Prop_Custom_Color_2,
- 'GH07' : _Prop_Custom_Color_3,
- 'GH08' : _Prop_Custom_Color_4,
- 'HstF' : _Prop_host_flags,
- 'IncF' : _Prop_includes,
- 'Kind' : _Prop_path_kind,
- 'Lang' : _Prop_language,
- 'NumF' : _Prop_filecount,
- 'Orig' : _Prop_origin,
- 'PA01' : _Prop_User_Paths,
- 'PA02' : _Prop_Always_Full_Search,
- 'PA03' : _Prop_System_Paths,
- 'PA04' : _Prop_Convert_Paths,
- 'PA05' : _Prop_Require_Framework_Includes,
- 'PLck' : _Prop_seg_2d_locked,
- 'PR04' : _Prop_File_Type,
- 'PX01' : _Prop_Plugin_Diagnostics_Level,
- 'PX02' : _Prop_Disable_Third_Party_COM_Plugins,
- 'Path' : _Prop_path,
- 'Prel' : _Prop_seg_2d_preloaded,
- 'Prot' : _Prop_seg_2d_protected,
- 'Purg' : _Prop_seg_2d_purgeable,
- 'RS01' : _Prop_Host_Application,
- 'RS02' : _Prop_Command_Line_Arguments,
- 'RS03' : _Prop_Working_Directory,
- 'RS04' : _Prop_Environment_Variables,
- 'Recu' : _Prop_recursive,
- 'Root' : _Prop_root,
- 'SF01' : _Prop_Expression_To_Match,
- 'SF02' : _Prop_Skip_Project_Operations,
- 'SF03' : _Prop_Skip_Find_And_Compare_Operations,
- 'SFis' : _Prop_Shielded_Items,
- 'ST01' : _Prop_Source_Trees,
- 'SrcT' : _Prop_filetype,
- 'Stat' : _Prop_static,
- 'SubA' : _Prop_all_subclasses,
- 'SubC' : _Prop_subclasses,
- 'SymG' : _Prop_symbols,
- 'SysH' : _Prop_seg_2d_system_heap,
- 'TA01' : _Prop_Linker,
- 'TA02' : _Prop_Extension,
- 'TA03' : _Prop_Precompiled,
- 'TA04' : _Prop_Resource_File,
- 'TA05' : _Prop_Launchable,
- 'TA06' : _Prop_Ignored_by_Make,
- 'TA07' : _Prop_Compiler,
- 'TA09' : _Prop_Post_Linker,
- 'TA10' : _Prop_Target_Name,
- 'TA11' : _Prop_Output_Directory_Path,
- 'TA12' : _Prop_Output_Directory_Origin,
- 'TA13' : _Prop_Pre_Linker,
- 'TA15' : _Prop_Use_Relative_Paths,
- 'TA16' : _Prop_Output_Directory_Location,
- 'UpTD' : _Prop_up_to_date,
- 'VC01' : _Prop_VCS_Active,
- 'VC02' : _Prop_Connection_Method,
- 'VC03' : _Prop_Username,
- 'VC04' : _Prop_Password,
- 'VC05' : _Prop_Auto_Connect,
- 'VC06' : _Prop_Store_Password,
- 'VC07' : _Prop_Always_Prompt,
- 'VC08' : _Prop_Mount_Volume,
- 'VC09' : _Prop_Database_Path,
- 'VC10' : _Prop_Local_Path,
- 'VC11' : _Prop_Use_Global_Settings,
- 'Valu' : _Prop_value,
- 'Virt' : _Prop_virtual,
- 'Weak' : _Prop_weak_link,
- 'file' : _Prop_disk_file,
- 'pnam' : _Prop_name,
- 'ptps' : _Prop_Text_Size,
- 'ptxf' : _Prop_Text_Font,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'Acce' : _Enum_Acce,
- 'BXbr' : _Enum_BXbr,
- 'DbSA' : _Enum_DbSA,
- 'DgBL' : _Enum_DgBL,
- 'ErrT' : _Enum_ErrT,
- 'Inte' : _Enum_Inte,
- 'Lang' : _Enum_Lang,
- 'PPrm' : _Enum_PPrm,
- 'PXdg' : _Enum_PXdg,
- 'PthF' : _Enum_PthF,
- 'RefP' : _Enum_RefP,
- 'STKd' : _Enum_STKd,
- 'SrcT' : _Enum_SrcT,
- 'TmpB' : _Enum_TmpB,
- 'TxtF' : _Enum_TxtF,
- 'savo' : _Enum_savo,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py
deleted file mode 100644
index b0749e873f8..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Required.py
+++ /dev/null
@@ -1,62 +0,0 @@
-"""Suite Required: Terms that every application should support
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'reqd'
-
-from StdSuites.Required_Suite import *
-class Required_Events(Required_Suite_Events):
-
- _argmap_open = {
- 'converting' : 'Conv',
- }
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument converting: Whether to convert project to latest version (yes/no; default is ask).
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- aetools.keysubst(_arguments, self._argmap_open)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'Conv', _Enum_Conv)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-_Enum_Conv = {
- 'yes' : 'yes ', # Convert the project if necessary on open
- 'no' : 'no ', # Do not convert the project if needed on open
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'Conv' : _Enum_Conv,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Standard_Suite.py
deleted file mode 100644
index 25324f88163..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/Standard_Suite.py
+++ /dev/null
@@ -1,408 +0,0 @@
-"""Suite Standard Suite: Common terms for most applications
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'CoRe'
-
-from StdSuites.Standard_Suite import *
-class Standard_Suite_Events(Standard_Suite_Events):
-
- _argmap_close = {
- 'saving' : 'savo',
- 'saving_in' : 'kfil',
- }
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: close an object
- Required argument: the object to close
- Keyword argument saving: specifies whether or not changes should be saved before closing
- Keyword argument saving_in: the file in which to save the object
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- aetools.keysubst(_arguments, self._argmap_close)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_count = {
- 'each' : 'kocl',
- }
-
- def count(self, _object, _attributes={}, **_arguments):
- """count: return the number of elements of a particular class within an object
- Required argument: the object whose elements are to be counted
- Keyword argument each: the class of the elements to be counted. Keyword 'each' is optional in AppleScript
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the number of elements
- """
- _code = 'core'
- _subcode = 'cnte'
-
- aetools.keysubst(_arguments, self._argmap_count)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_get = {
- 'as' : 'rtyp',
- }
-
- def get(self, _object, _attributes={}, **_arguments):
- """get: get the data for an object
- Required argument: the object whose data is to be returned
- Keyword argument as: the desired types for the data, in order of preference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: The data from the object
- """
- _code = 'core'
- _subcode = 'getd'
-
- aetools.keysubst(_arguments, self._argmap_get)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_make = {
- 'new' : 'kocl',
- 'as' : 'rtyp',
- 'at' : 'insh',
- 'with_data' : 'data',
- 'with_properties' : 'prdt',
- }
-
- def make(self, _no_object=None, _attributes={}, **_arguments):
- """make: make a new element
- Keyword argument new: the class of the new element\xd1keyword 'new' is optional in AppleScript
- Keyword argument as: the desired types for the data, in order of preference
- Keyword argument at: the location at which to insert the element
- Keyword argument with_data: the initial data for the element
- Keyword argument with_properties: the initial values for the properties of the element
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the new object(s)
- """
- _code = 'core'
- _subcode = 'crel'
-
- aetools.keysubst(_arguments, self._argmap_make)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def select(self, _object=None, _attributes={}, **_arguments):
- """select: select the specified object
- Required argument: the object to select
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'slct'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_set = {
- 'to' : 'data',
- }
-
- def set(self, _object, _attributes={}, **_arguments):
- """set: set an object's data
- Required argument: the object to change
- Keyword argument to: the new value
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'setd'
-
- aetools.keysubst(_arguments, self._argmap_set)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - an application program """
- want = 'capp'
-class _Prop_user_interaction(aetools.NProperty):
- """user interaction - user interaction level """
- which = 'inte'
- want = 'Inte'
-user_interaction = _Prop_user_interaction()
-# element 'cwin' as ['indx', 'name', 'rang']
-# element 'docu' as ['indx', 'name', 'rang']
-
-class character(aetools.ComponentItem):
- """character - a character """
- want = 'cha '
-class _Prop_length(aetools.NProperty):
- """length - length in characters of this object """
- which = 'pLen'
- want = 'long'
-class _Prop_offset(aetools.NProperty):
- """offset - offset of a text object from the beginning of the document (first char has offset 1) """
- which = 'pOff'
- want = 'long'
-
-class insertion_point(aetools.ComponentItem):
- """insertion point - An insertion location between two objects """
- want = 'cins'
-
-class line(aetools.ComponentItem):
- """line - lines of text """
- want = 'clin'
-class _Prop_index(aetools.NProperty):
- """index - index of a line object from the beginning of the document (first line has index 1) """
- which = 'pidx'
- want = 'long'
-# element 'cha ' as ['indx', 'rang', 'rele']
-
-lines = line
-
-class selection_2d_object(aetools.ComponentItem):
- """selection-object - the selection visible to the user """
- want = 'csel'
-class _Prop_contents(aetools.NProperty):
- """contents - the contents of the selection """
- which = 'pcnt'
- want = 'type'
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'clin' as ['indx', 'rang', 'rele']
-# element 'ctxt' as ['rang']
-
-class text(aetools.ComponentItem):
- """text - Text """
- want = 'ctxt'
-# element 'cha ' as ['indx', 'rele', 'rang']
-# element 'cins' as ['rele']
-# element 'clin' as ['indx', 'rang', 'rele']
-# element 'ctxt' as ['rang']
-
-class window(aetools.ComponentItem):
- """window - A window """
- want = 'cwin'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the boundary rectangle for the window """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_document(aetools.NProperty):
- """document - the document that owns this window """
- which = 'docu'
- want = 'docu'
-class _Prop_name(aetools.NProperty):
- """name - the title of the window """
- which = 'pnam'
- want = 'itxt'
-class _Prop_position(aetools.NProperty):
- """position - upper left coordinates of window """
- which = 'ppos'
- want = 'QDpt'
-class _Prop_visible(aetools.NProperty):
- """visible - is the window visible? """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Is the window zoomed? """
- which = 'pzum'
- want = 'bool'
-
-windows = window
-
-class document(aetools.ComponentItem):
- """document - a document """
- want = 'docu'
-class _Prop_file_permissions(aetools.NProperty):
- """file permissions - the file permissions for the document """
- which = 'PERM'
- want = 'PERM'
-class _Prop_kind(aetools.NProperty):
- """kind - the kind of document """
- which = 'DKND'
- want = 'DKND'
-class _Prop_location(aetools.NProperty):
- """location - the file of the document """
- which = 'FILE'
- want = 'fss '
-class _Prop_window(aetools.NProperty):
- """window - the window of the document. """
- which = 'cwin'
- want = 'cwin'
-
-documents = document
-
-class files(aetools.ComponentItem):
- """files - Every file """
- want = 'file'
-
-file = files
-application._superclassnames = []
-application._privpropdict = {
- 'user_interaction' : _Prop_user_interaction,
-}
-application._privelemdict = {
- 'document' : document,
- 'window' : window,
-}
-character._superclassnames = []
-character._privpropdict = {
- 'length' : _Prop_length,
- 'offset' : _Prop_offset,
-}
-character._privelemdict = {
-}
-insertion_point._superclassnames = []
-insertion_point._privpropdict = {
- 'length' : _Prop_length,
- 'offset' : _Prop_offset,
-}
-insertion_point._privelemdict = {
-}
-line._superclassnames = []
-line._privpropdict = {
- 'index' : _Prop_index,
- 'length' : _Prop_length,
- 'offset' : _Prop_offset,
-}
-line._privelemdict = {
- 'character' : character,
-}
-selection_2d_object._superclassnames = []
-selection_2d_object._privpropdict = {
- 'contents' : _Prop_contents,
- 'length' : _Prop_length,
- 'offset' : _Prop_offset,
-}
-selection_2d_object._privelemdict = {
- 'character' : character,
- 'line' : line,
- 'text' : text,
-}
-text._superclassnames = []
-text._privpropdict = {
- 'length' : _Prop_length,
- 'offset' : _Prop_offset,
-}
-text._privelemdict = {
- 'character' : character,
- 'insertion_point' : insertion_point,
- 'line' : line,
- 'text' : text,
-}
-window._superclassnames = []
-window._privpropdict = {
- 'bounds' : _Prop_bounds,
- 'document' : _Prop_document,
- 'index' : _Prop_index,
- 'name' : _Prop_name,
- 'position' : _Prop_position,
- 'visible' : _Prop_visible,
- 'zoomed' : _Prop_zoomed,
-}
-window._privelemdict = {
-}
-document._superclassnames = []
-document._privpropdict = {
- 'file_permissions' : _Prop_file_permissions,
- 'index' : _Prop_index,
- 'kind' : _Prop_kind,
- 'location' : _Prop_location,
- 'name' : _Prop_name,
- 'window' : _Prop_window,
-}
-document._privelemdict = {
-}
-files._superclassnames = []
-files._privpropdict = {
-}
-files._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cha ' : character,
- 'cins' : insertion_point,
- 'clin' : line,
- 'csel' : selection_2d_object,
- 'ctxt' : text,
- 'cwin' : window,
- 'docu' : document,
- 'file' : files,
-}
-
-_propdeclarations = {
- 'DKND' : _Prop_kind,
- 'FILE' : _Prop_location,
- 'PERM' : _Prop_file_permissions,
- 'cwin' : _Prop_window,
- 'docu' : _Prop_document,
- 'inte' : _Prop_user_interaction,
- 'pLen' : _Prop_length,
- 'pOff' : _Prop_offset,
- 'pbnd' : _Prop_bounds,
- 'pcnt' : _Prop_contents,
- 'pidx' : _Prop_index,
- 'pnam' : _Prop_name,
- 'ppos' : _Prop_position,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py b/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
deleted file mode 100644
index 38e33502d56..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/CodeWarrior/__init__.py
+++ /dev/null
@@ -1,193 +0,0 @@
-"""
-Package generated from /Volumes/Sap/Applications (Mac OS 9)/Metrowerks CodeWarrior 7.0/Metrowerks CodeWarrior/CodeWarrior IDE 4.2.5
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the CodeWarrior package is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import CodeWarrior_suite
-import Standard_Suite
-import Metrowerks_Shell_Suite
-import Required
-
-
-_code_to_module = {
- 'CWIE' : CodeWarrior_suite,
- 'CoRe' : Standard_Suite,
- 'MMPR' : Metrowerks_Shell_Suite,
- 'reqd' : Required,
-}
-
-
-
-_code_to_fullname = {
- 'CWIE' : ('CodeWarrior.CodeWarrior_suite', 'CodeWarrior_suite'),
- 'CoRe' : ('CodeWarrior.Standard_Suite', 'Standard_Suite'),
- 'MMPR' : ('CodeWarrior.Metrowerks_Shell_Suite', 'Metrowerks_Shell_Suite'),
- 'reqd' : ('CodeWarrior.Required', 'Required'),
-}
-
-from CodeWarrior_suite import *
-from Standard_Suite import *
-from Metrowerks_Shell_Suite import *
-from Required import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(character)
-getbaseclasses(selection_2d_object)
-getbaseclasses(application)
-getbaseclasses(document)
-getbaseclasses(text)
-getbaseclasses(window)
-getbaseclasses(file)
-getbaseclasses(line)
-getbaseclasses(insertion_point)
-getbaseclasses(single_class_browser)
-getbaseclasses(project_document)
-getbaseclasses(symbol_browser)
-getbaseclasses(editor_document)
-getbaseclasses(file_compare_document)
-getbaseclasses(class_browser)
-getbaseclasses(subtarget)
-getbaseclasses(message_document)
-getbaseclasses(project_inspector)
-getbaseclasses(text_document)
-getbaseclasses(catalog_document)
-getbaseclasses(class_hierarchy)
-getbaseclasses(target)
-getbaseclasses(build_progress_document)
-getbaseclasses(target_file)
-getbaseclasses(ToolServer_worksheet)
-getbaseclasses(single_class_hierarchy)
-getbaseclasses(File_Mapping)
-getbaseclasses(browser_catalog)
-getbaseclasses(Build_Settings)
-getbaseclasses(ProjectFile)
-getbaseclasses(VCS_Setup)
-getbaseclasses(data_member)
-getbaseclasses(Shielded_Folder)
-getbaseclasses(Custom_Keywords)
-getbaseclasses(Path_Information)
-getbaseclasses(Segment)
-getbaseclasses(Source_Tree)
-getbaseclasses(Access_Paths)
-getbaseclasses(Debugger_Windowing)
-getbaseclasses(Relative_Path)
-getbaseclasses(Environment_Variable)
-getbaseclasses(base_class)
-getbaseclasses(Debugger_Display)
-getbaseclasses(Build_Extras)
-getbaseclasses(Error_Information)
-getbaseclasses(Editor)
-getbaseclasses(Shielded_Folders)
-getbaseclasses(Extras)
-getbaseclasses(File_Mappings)
-getbaseclasses(Function_Information)
-getbaseclasses(Debugger_Target)
-getbaseclasses(Syntax_Coloring)
-getbaseclasses(class_)
-getbaseclasses(Global_Source_Trees)
-getbaseclasses(Target_Settings)
-getbaseclasses(Debugger_Global)
-getbaseclasses(member_function)
-getbaseclasses(Runtime_Settings)
-getbaseclasses(Plugin_Settings)
-getbaseclasses(Browser_Coloring)
-getbaseclasses(Font)
-getbaseclasses(Target_Source_Trees)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cha ' : character,
- 'csel' : selection_2d_object,
- 'capp' : application,
- 'docu' : document,
- 'ctxt' : text,
- 'cwin' : window,
- 'file' : file,
- 'clin' : line,
- 'cins' : insertion_point,
- '1BRW' : single_class_browser,
- 'PRJD' : project_document,
- 'SYMB' : symbol_browser,
- 'EDIT' : editor_document,
- 'COMP' : file_compare_document,
- 'BROW' : class_browser,
- 'SBTG' : subtarget,
- 'MSSG' : message_document,
- 'INSP' : project_inspector,
- 'TXTD' : text_document,
- 'CTLG' : catalog_document,
- 'HIER' : class_hierarchy,
- 'TRGT' : target,
- 'PRGS' : build_progress_document,
- 'SRCF' : target_file,
- 'TOOL' : ToolServer_worksheet,
- '1HIR' : single_class_hierarchy,
- 'FMap' : File_Mapping,
- 'Cata' : browser_catalog,
- 'BSTG' : Build_Settings,
- 'SrcF' : ProjectFile,
- 'VCSs' : VCS_Setup,
- 'DtMb' : data_member,
- 'SFit' : Shielded_Folder,
- 'CUKW' : Custom_Keywords,
- 'PInf' : Path_Information,
- 'Seg ' : Segment,
- 'SrcT' : Source_Tree,
- 'PATH' : Access_Paths,
- 'DbWN' : Debugger_Windowing,
- 'RlPt' : Relative_Path,
- 'EnvV' : Environment_Variable,
- 'BsCl' : base_class,
- 'DbDS' : Debugger_Display,
- 'LXTR' : Build_Extras,
- 'ErrM' : Error_Information,
- 'EDTR' : Editor,
- 'SHFL' : Shielded_Folders,
- 'GXTR' : Extras,
- 'FLMP' : File_Mappings,
- 'FDef' : Function_Information,
- 'DbTG' : Debugger_Target,
- 'SNTX' : Syntax_Coloring,
- 'Clas' : class_,
- 'GSTs' : Global_Source_Trees,
- 'TARG' : Target_Settings,
- 'DbGL' : Debugger_Global,
- 'MbFn' : member_function,
- 'RSTG' : Runtime_Settings,
- 'PSTG' : Plugin_Settings,
- 'BRKW' : Browser_Coloring,
- 'mFNT' : Font,
- 'TSTs' : Target_Source_Trees,
-}
-
-
-class CodeWarrior(CodeWarrior_suite_Events,
- Standard_Suite_Events,
- Metrowerks_Shell_Suite_Events,
- Required_Events,
- aetools.TalkTo):
- _signature = 'CWIE'
-
- _moduleName = 'CodeWarrior'
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/Microsoft_Internet_Explorer.py b/Lib/plat-mac/lib-scriptpackages/Explorer/Microsoft_Internet_Explorer.py
deleted file mode 100644
index bce9e7698de..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/Microsoft_Internet_Explorer.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""Suite Microsoft Internet Explorer Suite: Events defined by Internet Explorer
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'MSIE'
-
-class Microsoft_Internet_Explorer_Events:
-
- def GetSource(self, _object=None, _attributes={}, **_arguments):
- """GetSource: Get the HTML source of a browser window
- Required argument: Window Identifier of window from which to get the source. No value means get the source from the frontmost window.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'TEXT'
- """
- _code = 'MSIE'
- _subcode = 'SORC'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def PrintBrowserWindow(self, _object=None, _attributes={}, **_arguments):
- """PrintBrowserWindow: Print contents of browser window (HTML)
- Required argument: Window Identifier of the window to print. No value means print the frontmost browser window.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'pWND'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_do_script = {
- 'window' : 'WIND',
- }
-
- def do_script(self, _object, _attributes={}, **_arguments):
- """do script: Execute script commands
- Required argument: JavaScript text to execute
- Keyword argument window: optional Window Identifier (as supplied by the ListWindows event) specifying context in which to execute the script
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Return value
- """
- _code = 'misc'
- _subcode = 'dosc'
-
- aetools.keysubst(_arguments, self._argmap_do_script)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/Netscape_Suite.py b/Lib/plat-mac/lib-scriptpackages/Explorer/Netscape_Suite.py
deleted file mode 100644
index c274e70d1db..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/Netscape_Suite.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""Suite Netscape Suite: Events defined by Netscape
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'MOSS'
-
-class Netscape_Suite_Events:
-
- def Open_bookmark(self, _object=None, _attributes={}, **_arguments):
- """Open bookmark: Opens a bookmark file
- Required argument: If not available, reloads the current bookmark file
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'book'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py b/Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py
deleted file mode 100644
index 9e2541e5a4d..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/Required_Suite.py
+++ /dev/null
@@ -1,108 +0,0 @@
-"""Suite Required Suite: Events that every application should support
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'reqd'
-
-from StdSuites.Required_Suite import *
-class Required_Suite_Events(Required_Suite_Events):
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open documents
- Required argument: undocumented, typecode 'alis'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def print_(self, _object, _attributes={}, **_arguments):
- """print: Print documents
- Required argument: undocumented, typecode 'alis'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def quit(self, _no_object=None, _attributes={}, **_arguments):
- """quit: Quit application
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def run(self, _no_object=None, _attributes={}, **_arguments):
- """run:
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'oapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py
deleted file mode 100644
index 7ead98af967..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/Standard_Suite.py
+++ /dev/null
@@ -1,72 +0,0 @@
-"""Suite Standard Suite: Common terms for most applications
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = '****'
-
-class Standard_Suite_Events:
-
- _argmap_get = {
- 'as' : 'rtyp',
- }
-
- def get(self, _object, _attributes={}, **_arguments):
- """get:
- Required argument: an AE object reference
- Keyword argument as: undocumented, typecode 'type'
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'core'
- _subcode = 'getd'
-
- aetools.keysubst(_arguments, self._argmap_get)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - An application program """
- want = 'capp'
-class _Prop_selected_text(aetools.NProperty):
- """selected text - the selected text """
- which = 'stxt'
- want = 'TEXT'
-selected_text = _Prop_selected_text()
-application._superclassnames = []
-application._privpropdict = {
- 'selected_text' : _Prop_selected_text,
-}
-application._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
-}
-
-_propdeclarations = {
- 'stxt' : _Prop_selected_text,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/URL_Suite.py b/Lib/plat-mac/lib-scriptpackages/Explorer/URL_Suite.py
deleted file mode 100644
index e234546ceed..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/URL_Suite.py
+++ /dev/null
@@ -1,54 +0,0 @@
-"""Suite URL Suite: Standard suite for Uniform Resource Locators
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'GURL'
-
-class URL_Suite_Events:
-
- _argmap_GetURL = {
- 'to' : 'dest',
- }
-
- def GetURL(self, _object, _attributes={}, **_arguments):
- """GetURL: Open the URL (and optionally save it to disk)
- Required argument: URL to open
- Keyword argument to: File into which to save resource located at URL.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'GURL'
- _subcode = 'GURL'
-
- aetools.keysubst(_arguments, self._argmap_GetURL)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py b/Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py
deleted file mode 100644
index e87526f5480..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/Web_Browser_Suite.py
+++ /dev/null
@@ -1,226 +0,0 @@
-"""Suite Web Browser Suite: Class of events supported by Web Browser applications
-Level 1, version 1
-
-Generated from /Applications/Internet Explorer.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'WWW!'
-
-class Web_Browser_Suite_Events:
-
- def Activate(self, _object=None, _attributes={}, **_arguments):
- """Activate: Activate Internet Explorer and optionally select window designated by Window Identifier.
- Required argument: Window Identifier
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Window Identifier of window to activate
- """
- _code = 'WWW!'
- _subcode = 'ACTV'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def CloseAllWindows(self, _no_object=None, _attributes={}, **_arguments):
- """CloseAllWindows: Closes all windows
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Success
- """
- _code = 'WWW!'
- _subcode = 'CLSA'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_CloseWindow = {
- 'ID' : 'WIND',
- 'Title' : 'TITL',
- }
-
- def CloseWindow(self, _no_object=None, _attributes={}, **_arguments):
- """CloseWindow: Close the window specified by either Window Identifier or Title. If no parameter is specified, close the top window.
- Keyword argument ID: ID of the window to close. (Can use -1 for top window)
- Keyword argument Title: Title of the window to close
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Success
- """
- _code = 'WWW!'
- _subcode = 'CLOS'
-
- aetools.keysubst(_arguments, self._argmap_CloseWindow)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def GetWindowInfo(self, _object, _attributes={}, **_arguments):
- """GetWindowInfo: Returns a window info record (URL/Title) for the specified window.
- Required argument: Window Identifier of the window
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns:
- """
- _code = 'WWW!'
- _subcode = 'WNFO'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def ListWindows(self, _no_object=None, _attributes={}, **_arguments):
- """ListWindows: Returns list of Window Identifiers for all open windows.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'list'
- """
- _code = 'WWW!'
- _subcode = 'LSTW'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_OpenURL = {
- 'to' : 'INTO',
- 'toWindow' : 'WIND',
- 'Flags' : 'FLGS',
- 'FormData' : 'POST',
- 'MIME_Type' : 'MIME',
- }
-
- def OpenURL(self, _object, _attributes={}, **_arguments):
- """OpenURL: Retrieves URL off the Web.
- Required argument: Fully-qualified URL
- Keyword argument to: Target file for saving downloaded data
- Keyword argument toWindow: Target window for resource at URL (-1 for top window, 0 for new window)
- Keyword argument Flags: Valid Flags settings are: 1-Ignore the document cache; 2-Ignore the image cache; 4-Operate in background mode.
- Keyword argument FormData: data to post
- Keyword argument MIME_Type: MIME type of data being posted
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'OURL'
-
- aetools.keysubst(_arguments, self._argmap_OpenURL)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_ParseAnchor = {
- 'withURL' : 'RELA',
- }
-
- def ParseAnchor(self, _object, _attributes={}, **_arguments):
- """ParseAnchor: Combines a base URL and a relative URL to produce a fully-qualified URL
- Required argument: Base URL
- Keyword argument withURL: Relative URL that is combined with the Base URL (in the direct object) to produce a fully-qualified URL.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Fully-qualified URL
- """
- _code = 'WWW!'
- _subcode = 'PRSA'
-
- aetools.keysubst(_arguments, self._argmap_ParseAnchor)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_ShowFile = {
- 'MIME_Type' : 'MIME',
- 'Window_Identifier' : 'WIND',
- 'URL' : 'URL ',
- }
-
- def ShowFile(self, _object, _attributes={}, **_arguments):
- """ShowFile: FileSpec containing data of specified MIME type to be rendered in window specified by Window Identifier.
- Required argument: The file
- Keyword argument MIME_Type: MIME type
- Keyword argument Window_Identifier: Identifier of the target window for the URL. (Can use -1 for top window)
- Keyword argument URL: URL that allows this document to be reloaded.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'SHWF'
-
- aetools.keysubst(_arguments, self._argmap_ShowFile)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py b/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
deleted file mode 100644
index 967bc0e5a92..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Explorer/__init__.py
+++ /dev/null
@@ -1,84 +0,0 @@
-"""
-Package generated from /Applications/Internet Explorer.app
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Explorer module is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Standard_Suite
-import URL_Suite
-import Netscape_Suite
-import Microsoft_Internet_Explorer
-import Web_Browser_Suite
-import Required_Suite
-
-
-_code_to_module = {
- '****' : Standard_Suite,
- 'GURL' : URL_Suite,
- 'MOSS' : Netscape_Suite,
- 'MSIE' : Microsoft_Internet_Explorer,
- 'WWW!' : Web_Browser_Suite,
- 'reqd' : Required_Suite,
-}
-
-
-
-_code_to_fullname = {
- '****' : ('Explorer.Standard_Suite', 'Standard_Suite'),
- 'GURL' : ('Explorer.URL_Suite', 'URL_Suite'),
- 'MOSS' : ('Explorer.Netscape_Suite', 'Netscape_Suite'),
- 'MSIE' : ('Explorer.Microsoft_Internet_Explorer', 'Microsoft_Internet_Explorer'),
- 'WWW!' : ('Explorer.Web_Browser_Suite', 'Web_Browser_Suite'),
- 'reqd' : ('Explorer.Required_Suite', 'Required_Suite'),
-}
-
-from Standard_Suite import *
-from URL_Suite import *
-from Netscape_Suite import *
-from Microsoft_Internet_Explorer import *
-from Web_Browser_Suite import *
-from Required_Suite import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(application)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
-}
-
-
-class Explorer(Standard_Suite_Events,
- URL_Suite_Events,
- Netscape_Suite_Events,
- Microsoft_Internet_Explorer_Events,
- Web_Browser_Suite_Events,
- Required_Suite_Events,
- aetools.TalkTo):
- _signature = 'MSIE'
-
- _moduleName = 'Explorer'
-
- _elemdict = application._elemdict
- _propdict = application._propdict
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Containers_and_folders.py b/Lib/plat-mac/lib-scriptpackages/Finder/Containers_and_folders.py
deleted file mode 100644
index e495ef496ca..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Containers_and_folders.py
+++ /dev/null
@@ -1,279 +0,0 @@
-"""Suite Containers and folders: Classes that can contain other file system items
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fndr'
-
-class Containers_and_folders_Events:
-
- pass
-
-
-class disk(aetools.ComponentItem):
- """disk - A disk """
- want = 'cdis'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - inherits some of its properties from the container class """
- which = 'c@#^'
- want = 'ctnr'
-class _Prop_capacity(aetools.NProperty):
- """capacity - the total number of bytes (free or used) on the disk """
- which = 'capa'
- want = 'comp'
-class _Prop_ejectable(aetools.NProperty):
- """ejectable - Can the media be ejected (floppies, CD's, and so on)? """
- which = 'isej'
- want = 'bool'
-class _Prop_format(aetools.NProperty):
- """format - the filesystem format of this disk """
- which = 'dfmt'
- want = 'edfm'
-class _Prop_free_space(aetools.NProperty):
- """free space - the number of free bytes left on the disk """
- which = 'frsp'
- want = 'comp'
-class _Prop_ignore_privileges(aetools.NProperty):
- """ignore privileges - Ignore permissions on this disk? """
- which = 'igpr'
- want = 'bool'
-class _Prop_local_volume(aetools.NProperty):
- """local volume - Is the media a local volume (as opposed to a file server)? """
- which = 'isrv'
- want = 'bool'
-class _Prop_startup(aetools.NProperty):
- """startup - Is this disk the boot disk? """
- which = 'istd'
- want = 'bool'
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'name']
-# element 'ctnr' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-
-disks = disk
-
-class desktop_2d_object(aetools.ComponentItem):
- """desktop-object - Desktop-object is the class of the \xd2desktop\xd3 object """
- want = 'cdsk'
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'cdis' as ['indx', 'name']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'name']
-# element 'ctnr' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-
-class folder(aetools.ComponentItem):
- """folder - A folder """
- want = 'cfol'
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'name']
-# element 'ctnr' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-
-folders = folder
-
-class container(aetools.ComponentItem):
- """container - An item that contains other items """
- want = 'ctnr'
-class _Prop_completely_expanded(aetools.NProperty):
- """completely expanded - (NOT AVAILABLE YET) Are the container and all of its children opened as outlines? (can only be set for containers viewed as lists) """
- which = 'pexc'
- want = 'bool'
-class _Prop_container_window(aetools.NProperty):
- """container window - the container window for this folder """
- which = 'cwnd'
- want = 'obj '
-class _Prop_entire_contents(aetools.NProperty):
- """entire contents - the entire contents of the container, including the contents of its children """
- which = 'ects'
- want = 'obj '
-class _Prop_expandable(aetools.NProperty):
- """expandable - (NOT AVAILABLE YET) Is the container capable of being expanded as an outline? """
- which = 'pexa'
- want = 'bool'
-class _Prop_expanded(aetools.NProperty):
- """expanded - (NOT AVAILABLE YET) Is the container opened as an outline? (can only be set for containers viewed as lists) """
- which = 'pexp'
- want = 'bool'
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'name']
-# element 'ctnr' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-
-containers = container
-
-class trash_2d_object(aetools.ComponentItem):
- """trash-object - Trash-object is the class of the \xd2trash\xd3 object """
- want = 'ctrs'
-class _Prop_warns_before_emptying(aetools.NProperty):
- """warns before emptying - Display a dialog when emptying the trash? """
- which = 'warn'
- want = 'bool'
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'name']
-# element 'ctnr' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-disk._superclassnames = ['container']
-import Files
-import Finder_items
-disk._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'capacity' : _Prop_capacity,
- 'ejectable' : _Prop_ejectable,
- 'format' : _Prop_format,
- 'free_space' : _Prop_free_space,
- 'ignore_privileges' : _Prop_ignore_privileges,
- 'local_volume' : _Prop_local_volume,
- 'startup' : _Prop_startup,
-}
-disk._privelemdict = {
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'container' : container,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
-}
-desktop_2d_object._superclassnames = ['container']
-desktop_2d_object._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-desktop_2d_object._privelemdict = {
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'container' : container,
- 'disk' : disk,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
-}
-folder._superclassnames = ['container']
-folder._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-folder._privelemdict = {
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'container' : container,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
-}
-container._superclassnames = ['item']
-container._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'completely_expanded' : _Prop_completely_expanded,
- 'container_window' : _Prop_container_window,
- 'entire_contents' : _Prop_entire_contents,
- 'expandable' : _Prop_expandable,
- 'expanded' : _Prop_expanded,
-}
-container._privelemdict = {
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'container' : container,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
-}
-trash_2d_object._superclassnames = ['container']
-trash_2d_object._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'warns_before_emptying' : _Prop_warns_before_emptying,
-}
-trash_2d_object._privelemdict = {
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'container' : container,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cdis' : disk,
- 'cdsk' : desktop_2d_object,
- 'cfol' : folder,
- 'ctnr' : container,
- 'ctrs' : trash_2d_object,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'capa' : _Prop_capacity,
- 'cwnd' : _Prop_container_window,
- 'dfmt' : _Prop_format,
- 'ects' : _Prop_entire_contents,
- 'frsp' : _Prop_free_space,
- 'igpr' : _Prop_ignore_privileges,
- 'isej' : _Prop_ejectable,
- 'isrv' : _Prop_local_volume,
- 'istd' : _Prop_startup,
- 'pexa' : _Prop_expandable,
- 'pexc' : _Prop_completely_expanded,
- 'pexp' : _Prop_expanded,
- 'warn' : _Prop_warns_before_emptying,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py b/Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py
deleted file mode 100644
index 558d7ff23b3..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Enumerations.py
+++ /dev/null
@@ -1,145 +0,0 @@
-"""Suite Enumerations: Enumerations for the Finder
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'tpnm'
-
-from StdSuites.Type_Names_Suite import *
-class Enumerations_Events(Type_Names_Suite_Events):
-
- pass
-
-_Enum_earr = {
- 'not_arranged' : 'narr', #
- 'snap_to_grid' : 'grda', #
- 'arranged_by_name' : 'nama', #
- 'arranged_by_modification_date' : 'mdta', #
- 'arranged_by_creation_date' : 'cdta', #
- 'arranged_by_size' : 'siza', #
- 'arranged_by_kind' : 'kina', #
- 'arranged_by_label' : 'laba', #
-}
-
-_Enum_ecvw = {
- 'icon_view' : 'icnv', #
- 'list_view' : 'lsvw', #
- 'column_view' : 'clvw', #
-}
-
-_Enum_edfm = {
- 'Mac_OS_format' : 'dfhf', #
- 'Mac_OS_Extended_format' : 'dfh+', #
- 'UFS_format' : 'dfuf', #
- 'NFS_format' : 'dfnf', #
- 'audio_format' : 'dfau', #
- 'ProDOS_format' : 'dfpr', #
- 'MS_2d_DOS_format' : 'dfms', #
- 'ISO_9660_format' : 'df96', #
- 'High_Sierra_format' : 'dfhs', #
- 'QuickTake_format' : 'dfqt', #
- 'Apple_Photo_format' : 'dfph', #
- 'AppleShare_format' : 'dfas', #
- 'UDF_format' : 'dfud', #
- 'WebDAV_format' : 'dfwd', #
- 'FTP_format' : 'dfft', #
- 'Packet_2d_written_UDF_format' : 'dfpu', #
- 'unknown_format' : 'df??', #
-}
-
-_Enum_elsv = {
- 'name_column' : 'elsn', #
- 'modification_date_column' : 'elsm', #
- 'creation_date_column' : 'elsc', #
- 'size_column' : 'elss', #
- 'kind_column' : 'elsk', #
- 'label_column' : 'elsl', #
- 'version_column' : 'elsv', #
- 'comment_column' : 'elsC', #
-}
-
-_Enum_ipnl = {
- 'General_Information_panel' : 'gpnl', #
- 'Sharing_panel' : 'spnl', #
- 'Memory_panel' : 'mpnl', #
- 'Preview_panel' : 'vpnl', #
- 'Application_panel' : 'apnl', #
- 'Languages_panel' : 'pklg', #
- 'Plugins_panel' : 'pkpg', #
- 'Name__26__Extension_panel' : 'npnl', #
- 'Comments_panel' : 'cpnl', #
- 'Content_Index_panel' : 'cinl', #
-}
-
-_Enum_isiz = {
- 'mini' : 'miic', #
- 'small' : 'smic', #
- 'large' : 'lgic', #
-}
-
-_Enum_lvic = {
- 'small_icon' : 'smic', #
- 'large_icon' : 'lgic', #
-}
-
-_Enum_priv = {
- 'read_only' : 'read', #
- 'read_write' : 'rdwr', #
- 'write_only' : 'writ', #
- 'none' : 'none', #
-}
-
-_Enum_sodr = {
- 'normal' : 'snrm', #
- 'reversed' : 'srvs', #
-}
-
-_Enum_vwby = {
- 'conflicts' : 'cflc', #
- 'existing_items' : 'exsi', #
- 'small_icon' : 'smic', #
- 'icon' : 'iimg', #
- 'name' : 'pnam', #
- 'modification_date' : 'asmo', #
- 'size' : 'ptsz', #
- 'kind' : 'kind', #
- 'comment' : 'comt', #
- 'label' : 'labi', #
- 'version' : 'vers', #
- 'creation_date' : 'ascd', #
- 'small_button' : 'smbu', #
- 'large_button' : 'lgbu', #
- 'grid' : 'grid', #
- 'all' : 'kyal', #
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'earr' : _Enum_earr,
- 'ecvw' : _Enum_ecvw,
- 'edfm' : _Enum_edfm,
- 'elsv' : _Enum_elsv,
- 'ipnl' : _Enum_ipnl,
- 'isiz' : _Enum_isiz,
- 'lvic' : _Enum_lvic,
- 'priv' : _Enum_priv,
- 'sodr' : _Enum_sodr,
- 'vwby' : _Enum_vwby,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Files.py b/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
deleted file mode 100644
index ddbe1bafbb1..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Files.py
+++ /dev/null
@@ -1,212 +0,0 @@
-"""Suite Files: Classes representing files
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fndr'
-
-class Files_Events:
-
- pass
-
-
-class alias_file(aetools.ComponentItem):
- """alias file - An alias file (created with \xd2Make Alias\xd3) """
- want = 'alia'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - inherits some of its properties from the file class """
- which = 'c@#^'
- want = 'file'
-class _Prop_original_item(aetools.NProperty):
- """original item - the original item pointed to by the alias """
- which = 'orig'
- want = 'obj '
-
-alias_files = alias_file
-
-class application_file(aetools.ComponentItem):
- """application file - An application's file on disk """
- want = 'appf'
-class _Prop_accepts_high_level_events(aetools.NProperty):
- """accepts high level events - Is the application high-level event aware? (OBSOLETE: always returns true) """
- which = 'isab'
- want = 'bool'
-class _Prop_has_scripting_terminology(aetools.NProperty):
- """has scripting terminology - Does the process have a scripting terminology, i.e., can it be scripted? """
- which = 'hscr'
- want = 'bool'
-class _Prop_minimum_size(aetools.NProperty):
- """minimum size - the smallest memory size with which the application can be launched """
- which = 'mprt'
- want = 'long'
-class _Prop_opens_in_Classic(aetools.NProperty):
- """opens in Classic - Should the application launch in the Classic environment? """
- which = 'Clsc'
- want = 'bool'
-class _Prop_preferred_size(aetools.NProperty):
- """preferred size - the memory size with which the application will be launched """
- which = 'appt'
- want = 'long'
-class _Prop_suggested_size(aetools.NProperty):
- """suggested size - the memory size with which the developer recommends the application be launched """
- which = 'sprt'
- want = 'long'
-
-application_files = application_file
-
-class clipping(aetools.ComponentItem):
- """clipping - A clipping """
- want = 'clpf'
-class _Prop_clipping_window(aetools.NProperty):
- """clipping window - (NOT AVAILABLE YET) the clipping window for this clipping """
- which = 'lwnd'
- want = 'obj '
-
-clippings = clipping
-
-class document_file(aetools.ComponentItem):
- """document file - A document file """
- want = 'docf'
-
-document_files = document_file
-
-class file(aetools.ComponentItem):
- """file - A file """
- want = 'file'
-class _Prop_creator_type(aetools.NProperty):
- """creator type - the OSType identifying the application that created the item """
- which = 'fcrt'
- want = 'type'
-class _Prop_file_type(aetools.NProperty):
- """file type - the OSType identifying the type of data contained in the item """
- which = 'asty'
- want = 'type'
-class _Prop_product_version(aetools.NProperty):
- """product version - the version of the product (visible at the top of the \xd2Get Info\xd3 window) """
- which = 'ver2'
- want = 'utxt'
-class _Prop_stationery(aetools.NProperty):
- """stationery - Is the file a stationery pad? """
- which = 'pspd'
- want = 'bool'
-class _Prop_version(aetools.NProperty):
- """version - the version of the file (visible at the bottom of the \xd2Get Info\xd3 window) """
- which = 'vers'
- want = 'utxt'
-
-files = file
-
-class internet_location_file(aetools.ComponentItem):
- """internet location file - An file containing an internet location """
- want = 'inlf'
-class _Prop_location(aetools.NProperty):
- """location - the internet location """
- which = 'iloc'
- want = 'utxt'
-
-internet_location_files = internet_location_file
-
-class package(aetools.ComponentItem):
- """package - A package """
- want = 'pack'
-
-packages = package
-alias_file._superclassnames = ['file']
-alias_file._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'original_item' : _Prop_original_item,
-}
-alias_file._privelemdict = {
-}
-application_file._superclassnames = ['file']
-application_file._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'accepts_high_level_events' : _Prop_accepts_high_level_events,
- 'has_scripting_terminology' : _Prop_has_scripting_terminology,
- 'minimum_size' : _Prop_minimum_size,
- 'opens_in_Classic' : _Prop_opens_in_Classic,
- 'preferred_size' : _Prop_preferred_size,
- 'suggested_size' : _Prop_suggested_size,
-}
-application_file._privelemdict = {
-}
-clipping._superclassnames = ['file']
-clipping._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'clipping_window' : _Prop_clipping_window,
-}
-clipping._privelemdict = {
-}
-document_file._superclassnames = ['file']
-document_file._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-document_file._privelemdict = {
-}
-import Finder_items
-file._superclassnames = ['item']
-file._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'creator_type' : _Prop_creator_type,
- 'file_type' : _Prop_file_type,
- 'product_version' : _Prop_product_version,
- 'stationery' : _Prop_stationery,
- 'version' : _Prop_version,
-}
-file._privelemdict = {
-}
-internet_location_file._superclassnames = ['file']
-internet_location_file._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'location' : _Prop_location,
-}
-internet_location_file._privelemdict = {
-}
-package._superclassnames = ['item']
-package._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-package._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'alia' : alias_file,
- 'appf' : application_file,
- 'clpf' : clipping,
- 'docf' : document_file,
- 'file' : file,
- 'inlf' : internet_location_file,
- 'pack' : package,
-}
-
-_propdeclarations = {
- 'Clsc' : _Prop_opens_in_Classic,
- 'appt' : _Prop_preferred_size,
- 'asty' : _Prop_file_type,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'fcrt' : _Prop_creator_type,
- 'hscr' : _Prop_has_scripting_terminology,
- 'iloc' : _Prop_location,
- 'isab' : _Prop_accepts_high_level_events,
- 'lwnd' : _Prop_clipping_window,
- 'mprt' : _Prop_minimum_size,
- 'orig' : _Prop_original_item,
- 'pspd' : _Prop_stationery,
- 'sprt' : _Prop_suggested_size,
- 'ver2' : _Prop_product_version,
- 'vers' : _Prop_version,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Finder_Basics.py b/Lib/plat-mac/lib-scriptpackages/Finder/Finder_Basics.py
deleted file mode 100644
index 4e3928c3799..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Finder_Basics.py
+++ /dev/null
@@ -1,207 +0,0 @@
-"""Suite Finder Basics: Commonly-used Finder commands and object classes
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fndr'
-
-class Finder_Basics_Events:
-
- def copy(self, _no_object=None, _attributes={}, **_arguments):
- """copy: (NOT AVAILABLE YET) Copy the selected items to the clipboard (the Finder must be the front application)
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'copy'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_sort = {
- 'by' : 'by ',
- }
-
- def sort(self, _object, _attributes={}, **_arguments):
- """sort: (NOT AVAILABLE YET) Return the specified object(s) in a sorted list
- Required argument: a list of finder objects to sort
- Keyword argument by: the property to sort the items by (name, index, date, etc.)
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the sorted items in their new order
- """
- _code = 'DATA'
- _subcode = 'SORT'
-
- aetools.keysubst(_arguments, self._argmap_sort)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The Finder """
- want = 'capp'
-class _Prop_Finder_preferences(aetools.NProperty):
- """Finder preferences - (NOT AVAILABLE YET) Various preferences that apply to the Finder as a whole """
- which = 'pfrp'
- want = 'cprf'
-Finder_preferences = _Prop_Finder_preferences()
-class _Prop_clipboard(aetools.NProperty):
- """clipboard - (NOT AVAILABLE YET) the Finder\xd5s clipboard window """
- which = 'pcli'
- want = 'obj '
-clipboard = _Prop_clipboard()
-class _Prop_desktop(aetools.NProperty):
- """desktop - the desktop """
- which = 'desk'
- want = 'cdsk'
-desktop = _Prop_desktop()
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is the Finder the frontmost process? """
- which = 'pisf'
- want = 'bool'
-frontmost = _Prop_frontmost()
-class _Prop_home(aetools.NProperty):
- """home - the home directory """
- which = 'home'
- want = 'cfol'
-home = _Prop_home()
-class _Prop_insertion_location(aetools.NProperty):
- """insertion location - the container in which a new folder would appear if \xd2New Folder\xd3 was selected """
- which = 'pins'
- want = 'obj '
-insertion_location = _Prop_insertion_location()
-class _Prop_name(aetools.NProperty):
- """name - the Finder\xd5s name """
- which = 'pnam'
- want = 'itxt'
-name = _Prop_name()
-class _Prop_product_version(aetools.NProperty):
- """product version - the version of the System software running on this computer """
- which = 'ver2'
- want = 'utxt'
-product_version = _Prop_product_version()
-class _Prop_selection(aetools.NProperty):
- """selection - the selection in the frontmost Finder window """
- which = 'sele'
- want = 'obj '
-selection = _Prop_selection()
-class _Prop_startup_disk(aetools.NProperty):
- """startup disk - the startup disk """
- which = 'sdsk'
- want = 'cdis'
-startup_disk = _Prop_startup_disk()
-class _Prop_trash(aetools.NProperty):
- """trash - the trash """
- which = 'trsh'
- want = 'ctrs'
-trash = _Prop_trash()
-class _Prop_version(aetools.NProperty):
- """version - the version of the Finder """
- which = 'vers'
- want = 'utxt'
-version = _Prop_version()
-class _Prop_visible(aetools.NProperty):
- """visible - Is the Finder\xd5s layer visible? """
- which = 'pvis'
- want = 'bool'
-visible = _Prop_visible()
-# element 'alia' as ['indx', 'name']
-# element 'appf' as ['indx', 'name', 'ID ']
-# element 'brow' as ['indx', 'ID ']
-# element 'cdis' as ['indx', 'name', 'ID ']
-# element 'cfol' as ['indx', 'name', 'ID ']
-# element 'clpf' as ['indx', 'name']
-# element 'cobj' as ['indx', 'rele', 'name', 'rang', 'test']
-# element 'ctnr' as ['indx', 'name']
-# element 'cwin' as ['indx', 'name']
-# element 'docf' as ['indx', 'name']
-# element 'file' as ['indx', 'name']
-# element 'inlf' as ['indx', 'name']
-# element 'lwnd' as ['indx', 'name']
-# element 'pack' as ['indx', 'name']
-application._superclassnames = []
-import Files
-import Window_classes
-import Containers_and_folders
-import Finder_items
-application._privpropdict = {
- 'Finder_preferences' : _Prop_Finder_preferences,
- 'clipboard' : _Prop_clipboard,
- 'desktop' : _Prop_desktop,
- 'frontmost' : _Prop_frontmost,
- 'home' : _Prop_home,
- 'insertion_location' : _Prop_insertion_location,
- 'name' : _Prop_name,
- 'product_version' : _Prop_product_version,
- 'selection' : _Prop_selection,
- 'startup_disk' : _Prop_startup_disk,
- 'trash' : _Prop_trash,
- 'version' : _Prop_version,
- 'visible' : _Prop_visible,
-}
-application._privelemdict = {
- 'Finder_window' : Window_classes.Finder_window,
- 'alias_file' : Files.alias_file,
- 'application_file' : Files.application_file,
- 'clipping' : Files.clipping,
- 'clipping_window' : Window_classes.clipping_window,
- 'container' : Containers_and_folders.container,
- 'disk' : Containers_and_folders.disk,
- 'document_file' : Files.document_file,
- 'file' : Files.file,
- 'folder' : Containers_and_folders.folder,
- 'internet_location_file' : Files.internet_location_file,
- 'item' : Finder_items.item,
- 'package' : Files.package,
- 'window' : Window_classes.window,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
-}
-
-_propdeclarations = {
- 'desk' : _Prop_desktop,
- 'home' : _Prop_home,
- 'pcli' : _Prop_clipboard,
- 'pfrp' : _Prop_Finder_preferences,
- 'pins' : _Prop_insertion_location,
- 'pisf' : _Prop_frontmost,
- 'pnam' : _Prop_name,
- 'pvis' : _Prop_visible,
- 'sdsk' : _Prop_startup_disk,
- 'sele' : _Prop_selection,
- 'trsh' : _Prop_trash,
- 'ver2' : _Prop_product_version,
- 'vers' : _Prop_version,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Finder_items.py b/Lib/plat-mac/lib-scriptpackages/Finder/Finder_items.py
deleted file mode 100644
index 7120ea6c588..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Finder_items.py
+++ /dev/null
@@ -1,355 +0,0 @@
-"""Suite Finder items: Commands used with file system items, and basic item definition
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fndr'
-
-class Finder_items_Events:
-
- def add_to_favorites(self, _object, _attributes={}, **_arguments):
- """add to favorites: (NOT AVAILABLE YET) Add the items to the user\xd5s Favorites
- Required argument: the items to add to the collection of Favorites
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'ffav'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_clean_up = {
- 'by' : 'by ',
- }
-
- def clean_up(self, _object, _attributes={}, **_arguments):
- """clean up: (NOT AVAILABLE YET) Arrange items in window nicely (only applies to open windows in icon view that are not kept arranged)
- Required argument: the window to clean up
- Keyword argument by: the order in which to clean up the objects (name, index, date, etc.)
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'fclu'
-
- aetools.keysubst(_arguments, self._argmap_clean_up)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def eject(self, _object=None, _attributes={}, **_arguments):
- """eject: Eject the specified disk(s)
- Required argument: the disk(s) to eject
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'ejct'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def empty(self, _object=None, _attributes={}, **_arguments):
- """empty: Empty the trash
- Required argument: \xd2empty\xd3 and \xd2empty trash\xd3 both do the same thing
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'empt'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def erase(self, _object, _attributes={}, **_arguments):
- """erase: (NOT AVAILABLE) Erase the specified disk(s)
- Required argument: the items to erase
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'fera'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def reveal(self, _object, _attributes={}, **_arguments):
- """reveal: Bring the specified object(s) into view
- Required argument: the object to be made visible
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'mvis'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_update = {
- 'necessity' : 'nec?',
- 'registering_applications' : 'reg?',
- }
-
- def update(self, _object, _attributes={}, **_arguments):
- """update: Update the display of the specified object(s) to match their on-disk representation
- Required argument: the item to update
- Keyword argument necessity: only update if necessary (i.e. a finder window is open). default is false
- Keyword argument registering_applications: register applications. default is true
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'fupd'
-
- aetools.keysubst(_arguments, self._argmap_update)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class item(aetools.ComponentItem):
- """item - An item """
- want = 'cobj'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the bounding rectangle of the item (can only be set for an item in a window viewed as icons or buttons) """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_comment(aetools.NProperty):
- """comment - the comment of the item, displayed in the \xd2Get Info\xd3 window """
- which = 'comt'
- want = 'utxt'
-class _Prop_container(aetools.NProperty):
- """container - the container of the item """
- which = 'ctnr'
- want = 'obj '
-class _Prop_creation_date(aetools.NProperty):
- """creation date - the date on which the item was created """
- which = 'ascd'
- want = 'ldt '
-class _Prop_description(aetools.NProperty):
- """description - a description of the item """
- which = 'dscr'
- want = 'utxt'
-class _Prop_disk(aetools.NProperty):
- """disk - the disk on which the item is stored """
- which = 'cdis'
- want = 'obj '
-class _Prop_displayed_name(aetools.NProperty):
- """displayed name - the user-visible name of the item """
- which = 'dnam'
- want = 'utxt'
-class _Prop_everyones_privileges(aetools.NProperty):
- """everyones privileges - """
- which = 'gstp'
- want = 'priv'
-class _Prop_extension_hidden(aetools.NProperty):
- """extension hidden - Is the item's extension hidden from the user? """
- which = 'hidx'
- want = 'bool'
-class _Prop_group(aetools.NProperty):
- """group - the user or group that has special access to the container """
- which = 'sgrp'
- want = 'utxt'
-class _Prop_group_privileges(aetools.NProperty):
- """group privileges - """
- which = 'gppr'
- want = 'priv'
-class _Prop_icon(aetools.NProperty):
- """icon - the icon bitmap of the item """
- which = 'iimg'
- want = 'ifam'
-class _Prop_index(aetools.NProperty):
- """index - the index in the front-to-back ordering within its container """
- which = 'pidx'
- want = 'long'
-class _Prop_information_window(aetools.NProperty):
- """information window - the information window for the item """
- which = 'iwnd'
- want = 'obj '
-class _Prop_kind(aetools.NProperty):
- """kind - the kind of the item """
- which = 'kind'
- want = 'utxt'
-class _Prop_label_index(aetools.NProperty):
- """label index - the label of the item """
- which = 'labi'
- want = 'long'
-class _Prop_locked(aetools.NProperty):
- """locked - Is the file locked? """
- which = 'aslk'
- want = 'bool'
-class _Prop_modification_date(aetools.NProperty):
- """modification date - the date on which the item was last modified """
- which = 'asmo'
- want = 'ldt '
-class _Prop_name(aetools.NProperty):
- """name - the name of the item """
- which = 'pnam'
- want = 'utxt'
-class _Prop_name_extension(aetools.NProperty):
- """name extension - the name extension of the item (such as \xd2txt\xd3) """
- which = 'nmxt'
- want = 'utxt'
-class _Prop_owner(aetools.NProperty):
- """owner - the user that owns the container """
- which = 'sown'
- want = 'utxt'
-class _Prop_owner_privileges(aetools.NProperty):
- """owner privileges - """
- which = 'ownr'
- want = 'priv'
-class _Prop_physical_size(aetools.NProperty):
- """physical size - the actual space used by the item on disk """
- which = 'phys'
- want = 'comp'
-class _Prop_position(aetools.NProperty):
- """position - the position of the item within its parent window (can only be set for an item in a window viewed as icons or buttons) """
- which = 'posn'
- want = 'QDpt'
-class _Prop_properties(aetools.NProperty):
- """properties - every property of an item """
- which = 'pALL'
- want = 'reco'
-class _Prop_size(aetools.NProperty):
- """size - the logical size of the item """
- which = 'ptsz'
- want = 'comp'
-class _Prop_url(aetools.NProperty):
- """url - the url of the item """
- which = 'pURL'
- want = 'utxt'
-
-items = item
-item._superclassnames = []
-item._privpropdict = {
- 'bounds' : _Prop_bounds,
- 'comment' : _Prop_comment,
- 'container' : _Prop_container,
- 'creation_date' : _Prop_creation_date,
- 'description' : _Prop_description,
- 'disk' : _Prop_disk,
- 'displayed_name' : _Prop_displayed_name,
- 'everyones_privileges' : _Prop_everyones_privileges,
- 'extension_hidden' : _Prop_extension_hidden,
- 'group' : _Prop_group,
- 'group_privileges' : _Prop_group_privileges,
- 'icon' : _Prop_icon,
- 'index' : _Prop_index,
- 'information_window' : _Prop_information_window,
- 'kind' : _Prop_kind,
- 'label_index' : _Prop_label_index,
- 'locked' : _Prop_locked,
- 'modification_date' : _Prop_modification_date,
- 'name' : _Prop_name,
- 'name_extension' : _Prop_name_extension,
- 'owner' : _Prop_owner,
- 'owner_privileges' : _Prop_owner_privileges,
- 'physical_size' : _Prop_physical_size,
- 'position' : _Prop_position,
- 'properties' : _Prop_properties,
- 'size' : _Prop_size,
- 'url' : _Prop_url,
-}
-item._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cobj' : item,
-}
-
-_propdeclarations = {
- 'ascd' : _Prop_creation_date,
- 'aslk' : _Prop_locked,
- 'asmo' : _Prop_modification_date,
- 'cdis' : _Prop_disk,
- 'comt' : _Prop_comment,
- 'ctnr' : _Prop_container,
- 'dnam' : _Prop_displayed_name,
- 'dscr' : _Prop_description,
- 'gppr' : _Prop_group_privileges,
- 'gstp' : _Prop_everyones_privileges,
- 'hidx' : _Prop_extension_hidden,
- 'iimg' : _Prop_icon,
- 'iwnd' : _Prop_information_window,
- 'kind' : _Prop_kind,
- 'labi' : _Prop_label_index,
- 'nmxt' : _Prop_name_extension,
- 'ownr' : _Prop_owner_privileges,
- 'pALL' : _Prop_properties,
- 'pURL' : _Prop_url,
- 'pbnd' : _Prop_bounds,
- 'phys' : _Prop_physical_size,
- 'pidx' : _Prop_index,
- 'pnam' : _Prop_name,
- 'posn' : _Prop_position,
- 'ptsz' : _Prop_size,
- 'sgrp' : _Prop_group,
- 'sown' : _Prop_owner,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Legacy_suite.py b/Lib/plat-mac/lib-scriptpackages/Finder/Legacy_suite.py
deleted file mode 100644
index b17fdf471e1..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Legacy_suite.py
+++ /dev/null
@@ -1,224 +0,0 @@
-"""Suite Legacy suite: Operations formerly handled by the Finder, but now automatically delegated to other applications
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fleg'
-
-class Legacy_suite_Events:
-
- def restart(self, _no_object=None, _attributes={}, **_arguments):
- """restart: Restart the computer
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'rest'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def shut_down(self, _no_object=None, _attributes={}, **_arguments):
- """shut down: Shut Down the computer
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'shut'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def sleep(self, _no_object=None, _attributes={}, **_arguments):
- """sleep: Put the computer to sleep
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'slep'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The Finder """
- want = 'capp'
-class _Prop_desktop_picture(aetools.NProperty):
- """desktop picture - the desktop picture of the main monitor """
- which = 'dpic'
- want = 'file'
-desktop_picture = _Prop_desktop_picture()
-
-class application_process(aetools.ComponentItem):
- """application process - A process launched from an application file """
- want = 'pcap'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - inherits some of its properties from the process class """
- which = 'c@#^'
- want = 'prcs'
-class _Prop_application_file(aetools.NProperty):
- """application file - the application file from which this process was launched """
- which = 'appf'
- want = 'appf'
-
-application_processes = application_process
-
-class desk_accessory_process(aetools.ComponentItem):
- """desk accessory process - A process launched from a desk accessory file """
- want = 'pcda'
-class _Prop_desk_accessory_file(aetools.NProperty):
- """desk accessory file - the desk accessory file from which this process was launched """
- which = 'dafi'
- want = 'obj '
-
-desk_accessory_processes = desk_accessory_process
-
-class process(aetools.ComponentItem):
- """process - A process running on this computer """
- want = 'prcs'
-class _Prop_accepts_high_level_events(aetools.NProperty):
- """accepts high level events - Is the process high-level event aware (accepts open application, open document, print document, and quit)? """
- which = 'isab'
- want = 'bool'
-class _Prop_accepts_remote_events(aetools.NProperty):
- """accepts remote events - Does the process accept remote events? """
- which = 'revt'
- want = 'bool'
-class _Prop_creator_type(aetools.NProperty):
- """creator type - the OSType of the creator of the process (the signature) """
- which = 'fcrt'
- want = 'type'
-class _Prop_file(aetools.NProperty):
- """file - the file from which the process was launched """
- which = 'file'
- want = 'obj '
-class _Prop_file_type(aetools.NProperty):
- """file type - the OSType of the file type of the process """
- which = 'asty'
- want = 'type'
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is the process the frontmost process? """
- which = 'pisf'
- want = 'bool'
-class _Prop_has_scripting_terminology(aetools.NProperty):
- """has scripting terminology - Does the process have a scripting terminology, i.e., can it be scripted? """
- which = 'hscr'
- want = 'bool'
-class _Prop_name(aetools.NProperty):
- """name - the name of the process """
- which = 'pnam'
- want = 'itxt'
-class _Prop_partition_space_used(aetools.NProperty):
- """partition space used - the number of bytes currently used in the process' partition """
- which = 'pusd'
- want = 'long'
-class _Prop_total_partition_size(aetools.NProperty):
- """total partition size - the size of the partition with which the process was launched """
- which = 'appt'
- want = 'long'
-class _Prop_visible(aetools.NProperty):
- """visible - Is the process' layer visible? """
- which = 'pvis'
- want = 'bool'
-
-processes = process
-application._superclassnames = []
-application._privpropdict = {
- 'desktop_picture' : _Prop_desktop_picture,
-}
-application._privelemdict = {
-}
-application_process._superclassnames = ['process']
-application_process._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'application_file' : _Prop_application_file,
-}
-application_process._privelemdict = {
-}
-desk_accessory_process._superclassnames = ['process']
-desk_accessory_process._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'desk_accessory_file' : _Prop_desk_accessory_file,
-}
-desk_accessory_process._privelemdict = {
-}
-process._superclassnames = []
-process._privpropdict = {
- 'accepts_high_level_events' : _Prop_accepts_high_level_events,
- 'accepts_remote_events' : _Prop_accepts_remote_events,
- 'creator_type' : _Prop_creator_type,
- 'file' : _Prop_file,
- 'file_type' : _Prop_file_type,
- 'frontmost' : _Prop_frontmost,
- 'has_scripting_terminology' : _Prop_has_scripting_terminology,
- 'name' : _Prop_name,
- 'partition_space_used' : _Prop_partition_space_used,
- 'total_partition_size' : _Prop_total_partition_size,
- 'visible' : _Prop_visible,
-}
-process._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'pcap' : application_process,
- 'pcda' : desk_accessory_process,
- 'prcs' : process,
-}
-
-_propdeclarations = {
- 'appf' : _Prop_application_file,
- 'appt' : _Prop_total_partition_size,
- 'asty' : _Prop_file_type,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'dafi' : _Prop_desk_accessory_file,
- 'dpic' : _Prop_desktop_picture,
- 'fcrt' : _Prop_creator_type,
- 'file' : _Prop_file,
- 'hscr' : _Prop_has_scripting_terminology,
- 'isab' : _Prop_accepts_high_level_events,
- 'pisf' : _Prop_frontmost,
- 'pnam' : _Prop_name,
- 'pusd' : _Prop_partition_space_used,
- 'pvis' : _Prop_visible,
- 'revt' : _Prop_accepts_remote_events,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/Finder/Standard_Suite.py
deleted file mode 100644
index b97918f9966..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Standard_Suite.py
+++ /dev/null
@@ -1,335 +0,0 @@
-"""Suite Standard Suite: Common terms that most applications should support
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'CoRe'
-
-from StdSuites.Standard_Suite import *
-class Standard_Suite_Events(Standard_Suite_Events):
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: Close an object
- Required argument: the object to close
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_count = {
- 'each' : 'kocl',
- }
-
- def count(self, _object, _attributes={}, **_arguments):
- """count: Return the number of elements of a particular class within an object
- Required argument: the object whose elements are to be counted
- Keyword argument each: the class of the elements to be counted
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the number of elements
- """
- _code = 'core'
- _subcode = 'cnte'
-
- aetools.keysubst(_arguments, self._argmap_count)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_data_size = {
- 'as' : 'rtyp',
- }
-
- def data_size(self, _object, _attributes={}, **_arguments):
- """data size: Return the size in bytes of an object
- Required argument: the object whose data size is to be returned
- Keyword argument as: the data type for which the size is calculated
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the size of the object in bytes
- """
- _code = 'core'
- _subcode = 'dsiz'
-
- aetools.keysubst(_arguments, self._argmap_data_size)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def delete(self, _object, _attributes={}, **_arguments):
- """delete: Move an item from its container to the trash
- Required argument: the item to delete
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the item that was just deleted
- """
- _code = 'core'
- _subcode = 'delo'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_duplicate = {
- 'to' : 'insh',
- 'replacing' : 'alrp',
- 'routing_suppressed' : 'rout',
- }
-
- def duplicate(self, _object, _attributes={}, **_arguments):
- """duplicate: Duplicate one or more object(s)
- Required argument: the object(s) to duplicate
- Keyword argument to: the new location for the object(s)
- Keyword argument replacing: Specifies whether or not to replace items in the destination that have the same name as items being duplicated
- Keyword argument routing_suppressed: Specifies whether or not to autoroute items (default is false). Only applies when copying to the system folder.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the duplicated object(s)
- """
- _code = 'core'
- _subcode = 'clon'
-
- aetools.keysubst(_arguments, self._argmap_duplicate)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'alrp', _Enum_bool)
- aetools.enumsubst(_arguments, 'rout', _Enum_bool)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def exists(self, _object, _attributes={}, **_arguments):
- """exists: Verify if an object exists
- Required argument: the object in question
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: true if it exists, false if not
- """
- _code = 'core'
- _subcode = 'doex'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_make = {
- 'new' : 'kocl',
- 'at' : 'insh',
- 'to' : 'to ',
- 'with_properties' : 'prdt',
- }
-
- def make(self, _no_object=None, _attributes={}, **_arguments):
- """make: Make a new element
- Keyword argument new: the class of the new element
- Keyword argument at: the location at which to insert the element
- Keyword argument to: when creating an alias file, the original item to create an alias to or when creating a file viewer window, the target of the window
- Keyword argument with_properties: the initial values for the properties of the element
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the new object(s)
- """
- _code = 'core'
- _subcode = 'crel'
-
- aetools.keysubst(_arguments, self._argmap_make)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_move = {
- 'to' : 'insh',
- 'replacing' : 'alrp',
- 'positioned_at' : 'mvpl',
- 'routing_suppressed' : 'rout',
- }
-
- def move(self, _object, _attributes={}, **_arguments):
- """move: Move object(s) to a new location
- Required argument: the object(s) to move
- Keyword argument to: the new location for the object(s)
- Keyword argument replacing: Specifies whether or not to replace items in the destination that have the same name as items being moved
- Keyword argument positioned_at: Gives a list (in local window coordinates) of positions for the destination items
- Keyword argument routing_suppressed: Specifies whether or not to autoroute items (default is false). Only applies when moving to the system folder.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the object(s) after they have been moved
- """
- _code = 'core'
- _subcode = 'move'
-
- aetools.keysubst(_arguments, self._argmap_move)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'alrp', _Enum_bool)
- aetools.enumsubst(_arguments, 'mvpl', _Enum_list)
- aetools.enumsubst(_arguments, 'rout', _Enum_bool)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_open = {
- 'using' : 'usin',
- 'with_properties' : 'prdt',
- }
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument using: the application file to open the object with
- Keyword argument with_properties: the initial values for the properties, to be included with the open command sent to the application that opens the direct object
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- aetools.keysubst(_arguments, self._argmap_open)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_print_ = {
- 'with_properties' : 'prdt',
- }
-
- def print_(self, _object, _attributes={}, **_arguments):
- """print: Print the specified object(s)
- Required argument: list of objects to print
- Keyword argument with_properties: optional properties to be included with the print command sent to the application that prints the direct object
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- aetools.keysubst(_arguments, self._argmap_print_)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def quit(self, _no_object=None, _attributes={}, **_arguments):
- """quit: Quit the Finder
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def select(self, _object, _attributes={}, **_arguments):
- """select: Select the specified object(s)
- Required argument: the object to select
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'slct'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-_Enum_list = None # XXXX enum list not found!!
-_Enum_bool = None # XXXX enum bool not found!!
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Type_Definitions.py b/Lib/plat-mac/lib-scriptpackages/Finder/Type_Definitions.py
deleted file mode 100644
index 3e7d8179914..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Type_Definitions.py
+++ /dev/null
@@ -1,346 +0,0 @@
-"""Suite Type Definitions: Definitions of records used in scripting the Finder
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'tpdf'
-
-class Type_Definitions_Events:
-
- pass
-
-
-class alias_list(aetools.ComponentItem):
- """alias list - A list of aliases. Use \xd4as alias list\xd5 when a list of aliases is needed (instead of a list of file system item references). """
- want = 'alst'
-
-class label(aetools.ComponentItem):
- """label - (NOT AVAILABLE YET) A Finder label (name and color) """
- want = 'clbl'
-class _Prop_color(aetools.NProperty):
- """color - the color associated with the label """
- which = 'colr'
- want = 'cRGB'
-class _Prop_index(aetools.NProperty):
- """index - the index in the front-to-back ordering within its container """
- which = 'pidx'
- want = 'long'
-class _Prop_name(aetools.NProperty):
- """name - the name associated with the label """
- which = 'pnam'
- want = 'utxt'
-
-class preferences(aetools.ComponentItem):
- """preferences - (NOT AVAILABLE, SUBJECT TO CHANGE) The Finder Preferences """
- want = 'cprf'
-class _Prop_button_view_arrangement(aetools.NProperty):
- """button view arrangement - the method of arrangement of icons in default Finder button view windows """
- which = 'barr'
- want = 'earr'
-class _Prop_button_view_icon_size(aetools.NProperty):
- """button view icon size - the size of icons displayed in Finder button view windows. """
- which = 'bisz'
- want = 'long'
-class _Prop_calculates_folder_sizes(aetools.NProperty):
- """calculates folder sizes - Are folder sizes calculated and displayed in Finder list view windows? """
- which = 'sfsz'
- want = 'bool'
-class _Prop_delay_before_springing(aetools.NProperty):
- """delay before springing - the delay before springing open a container in ticks (1/60th of a second) (12 is shortest delay, 60 is longest delay) """
- which = 'dela'
- want = 'shor'
-class _Prop_list_view_icon_size(aetools.NProperty):
- """list view icon size - the size of icons displayed in Finder list view windows. """
- which = 'lisz'
- want = 'long'
-class _Prop_shows_comments(aetools.NProperty):
- """shows comments - Are comments displayed in default Finder list view windows? """
- which = 'scom'
- want = 'bool'
-class _Prop_shows_creation_date(aetools.NProperty):
- """shows creation date - Are creation dates displayed in default Finder list view windows? """
- which = 'scda'
- want = 'bool'
-class _Prop_shows_kind(aetools.NProperty):
- """shows kind - Are document kinds displayed in default Finder list view windows? """
- which = 'sknd'
- want = 'bool'
-class _Prop_shows_label(aetools.NProperty):
- """shows label - Are labels displayed in default Finder list view windows? """
- which = 'slbl'
- want = 'bool'
-class _Prop_shows_modification_date(aetools.NProperty):
- """shows modification date - Are modification dates displayed in default Finder list view windows? """
- which = 'sdat'
- want = 'bool'
-class _Prop_shows_size(aetools.NProperty):
- """shows size - Are file sizes displayed in default Finder list view windows? """
- which = 'ssiz'
- want = 'bool'
-class _Prop_shows_version(aetools.NProperty):
- """shows version - Are file versions displayed in default Finder list view windows? """
- which = 'svrs'
- want = 'bool'
-class _Prop_spatial_view_arrangement(aetools.NProperty):
- """spatial view arrangement - the method of arrangement of icons in default Finder spatial view windows """
- which = 'iarr'
- want = 'earr'
-class _Prop_spatial_view_icon_size(aetools.NProperty):
- """spatial view icon size - the size of icons displayed in Finder spatial view windows. """
- which = 'iisz'
- want = 'long'
-class _Prop_spring_open_folders(aetools.NProperty):
- """spring open folders - Spring open folders after the specified delay? """
- which = 'sprg'
- want = 'bool'
-class _Prop_uses_relative_dates(aetools.NProperty):
- """uses relative dates - Are relative dates (e.g., today, yesterday) shown in Finder list view windows? """
- which = 'urdt'
- want = 'bool'
-class _Prop_uses_simple_menus(aetools.NProperty):
- """uses simple menus - Use simplified Finder menus? """
- which = 'usme'
- want = 'bool'
-class _Prop_uses_wide_grid(aetools.NProperty):
- """uses wide grid - Space icons on a wide grid? """
- which = 'uswg'
- want = 'bool'
-class _Prop_view_font(aetools.NProperty):
- """view font - the id of the font used in Finder views. """
- which = 'vfnt'
- want = 'long'
-class _Prop_view_font_size(aetools.NProperty):
- """view font size - the size of the font used in Finder views """
- which = 'vfsz'
- want = 'long'
-class _Prop_window(aetools.NProperty):
- """window - the window that would open if Finder preferences was opened """
- which = 'cwin'
- want = 'pwnd'
-# element 'clbl' as ['indx', 'name']
-
-class icon_view_options(aetools.ComponentItem):
- """icon view options - the icon view options """
- want = 'icop'
-
-_Prop_arrangement = _Prop_spatial_view_arrangement
-class _Prop_icon_size(aetools.NProperty):
- """icon size - the size of icons displayed in the icon view """
- which = 'lvis'
- want = 'shor'
-
-class icon_family(aetools.ComponentItem):
- """icon family - (NOT AVAILABLE YET) A family of icons """
- want = 'ifam'
-class _Prop_large_32_bit_icon(aetools.NProperty):
- """large 32 bit icon - the large 32-bit color icon """
- which = 'il32'
- want = 'il32'
-class _Prop_large_4_bit_icon(aetools.NProperty):
- """large 4 bit icon - the large 4-bit color icon """
- which = 'icl4'
- want = 'icl4'
-class _Prop_large_8_bit_icon(aetools.NProperty):
- """large 8 bit icon - the large 8-bit color icon """
- which = 'icl8'
- want = 'icl8'
-class _Prop_large_8_bit_mask(aetools.NProperty):
- """large 8 bit mask - the large 8-bit mask for large 32-bit icons """
- which = 'l8mk'
- want = 'l8mk'
-class _Prop_large_monochrome_icon_and_mask(aetools.NProperty):
- """large monochrome icon and mask - the large black-and-white icon and the mask for large icons """
- which = 'ICN#'
- want = 'ICN#'
-class _Prop_small_32_bit_icon(aetools.NProperty):
- """small 32 bit icon - the small 32-bit color icon """
- which = 'is32'
- want = 'is32'
-class _Prop_small_4_bit_icon(aetools.NProperty):
- """small 4 bit icon - the small 4-bit color icon """
- which = 'ics4'
- want = 'ics4'
-class _Prop_small_8_bit_icon(aetools.NProperty):
- """small 8 bit icon - the small 8-bit color icon """
- which = 'ics8'
- want = 'ics8'
-
-_Prop_small_8_bit_mask = _Prop_small_8_bit_icon
-class _Prop_small_monochrome_icon_and_mask(aetools.NProperty):
- """small monochrome icon and mask - the small black-and-white icon and the mask for small icons """
- which = 'ics#'
- want = 'ics#'
-
-class column(aetools.ComponentItem):
- """column - a column of a list view """
- want = 'lvcl'
-class _Prop_sort_direction(aetools.NProperty):
- """sort direction - The direction in which the window is sorted """
- which = 'sord'
- want = 'sodr'
-class _Prop_visible(aetools.NProperty):
- """visible - is this column visible """
- which = 'pvis'
- want = 'bool'
-class _Prop_width(aetools.NProperty):
- """width - the width of this column """
- which = 'clwd'
- want = 'shor'
-
-columns = column
-
-class list_view_options(aetools.ComponentItem):
- """list view options - the list view options """
- want = 'lvop'
-class _Prop_sort_column(aetools.NProperty):
- """sort column - the column that the list view is sorted on """
- which = 'srtc'
- want = 'lvcl'
-# element 'lvcl' as ['indx', 'rele', 'rang', 'test']
-alias_list._superclassnames = []
-alias_list._privpropdict = {
-}
-alias_list._privelemdict = {
-}
-label._superclassnames = []
-label._privpropdict = {
- 'color' : _Prop_color,
- 'index' : _Prop_index,
- 'name' : _Prop_name,
-}
-label._privelemdict = {
-}
-preferences._superclassnames = []
-preferences._privpropdict = {
- 'button_view_arrangement' : _Prop_button_view_arrangement,
- 'button_view_icon_size' : _Prop_button_view_icon_size,
- 'calculates_folder_sizes' : _Prop_calculates_folder_sizes,
- 'delay_before_springing' : _Prop_delay_before_springing,
- 'list_view_icon_size' : _Prop_list_view_icon_size,
- 'shows_comments' : _Prop_shows_comments,
- 'shows_creation_date' : _Prop_shows_creation_date,
- 'shows_kind' : _Prop_shows_kind,
- 'shows_label' : _Prop_shows_label,
- 'shows_modification_date' : _Prop_shows_modification_date,
- 'shows_size' : _Prop_shows_size,
- 'shows_version' : _Prop_shows_version,
- 'spatial_view_arrangement' : _Prop_spatial_view_arrangement,
- 'spatial_view_icon_size' : _Prop_spatial_view_icon_size,
- 'spring_open_folders' : _Prop_spring_open_folders,
- 'uses_relative_dates' : _Prop_uses_relative_dates,
- 'uses_simple_menus' : _Prop_uses_simple_menus,
- 'uses_wide_grid' : _Prop_uses_wide_grid,
- 'view_font' : _Prop_view_font,
- 'view_font_size' : _Prop_view_font_size,
- 'window' : _Prop_window,
-}
-preferences._privelemdict = {
- 'label' : label,
-}
-icon_view_options._superclassnames = []
-icon_view_options._privpropdict = {
- 'arrangement' : _Prop_arrangement,
- 'icon_size' : _Prop_icon_size,
-}
-icon_view_options._privelemdict = {
-}
-icon_family._superclassnames = []
-icon_family._privpropdict = {
- 'large_32_bit_icon' : _Prop_large_32_bit_icon,
- 'large_4_bit_icon' : _Prop_large_4_bit_icon,
- 'large_8_bit_icon' : _Prop_large_8_bit_icon,
- 'large_8_bit_mask' : _Prop_large_8_bit_mask,
- 'large_monochrome_icon_and_mask' : _Prop_large_monochrome_icon_and_mask,
- 'small_32_bit_icon' : _Prop_small_32_bit_icon,
- 'small_4_bit_icon' : _Prop_small_4_bit_icon,
- 'small_8_bit_icon' : _Prop_small_8_bit_icon,
- 'small_8_bit_mask' : _Prop_small_8_bit_mask,
- 'small_monochrome_icon_and_mask' : _Prop_small_monochrome_icon_and_mask,
-}
-icon_family._privelemdict = {
-}
-column._superclassnames = []
-column._privpropdict = {
- 'index' : _Prop_index,
- 'name' : _Prop_name,
- 'sort_direction' : _Prop_sort_direction,
- 'visible' : _Prop_visible,
- 'width' : _Prop_width,
-}
-column._privelemdict = {
-}
-list_view_options._superclassnames = []
-list_view_options._privpropdict = {
- 'calculates_folder_sizes' : _Prop_calculates_folder_sizes,
- 'icon_size' : _Prop_icon_size,
- 'sort_column' : _Prop_sort_column,
- 'uses_relative_dates' : _Prop_uses_relative_dates,
-}
-list_view_options._privelemdict = {
- 'column' : column,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'alst' : alias_list,
- 'clbl' : label,
- 'cprf' : preferences,
- 'icop' : icon_view_options,
- 'ifam' : icon_family,
- 'lvcl' : column,
- 'lvop' : list_view_options,
-}
-
-_propdeclarations = {
- 'ICN#' : _Prop_large_monochrome_icon_and_mask,
- 'barr' : _Prop_button_view_arrangement,
- 'bisz' : _Prop_button_view_icon_size,
- 'clwd' : _Prop_width,
- 'colr' : _Prop_color,
- 'cwin' : _Prop_window,
- 'dela' : _Prop_delay_before_springing,
- 'iarr' : _Prop_spatial_view_arrangement,
- 'icl4' : _Prop_large_4_bit_icon,
- 'icl8' : _Prop_large_8_bit_icon,
- 'ics#' : _Prop_small_monochrome_icon_and_mask,
- 'ics4' : _Prop_small_4_bit_icon,
- 'ics8' : _Prop_small_8_bit_icon,
- 'iisz' : _Prop_spatial_view_icon_size,
- 'il32' : _Prop_large_32_bit_icon,
- 'is32' : _Prop_small_32_bit_icon,
- 'l8mk' : _Prop_large_8_bit_mask,
- 'lisz' : _Prop_list_view_icon_size,
- 'lvis' : _Prop_icon_size,
- 'pidx' : _Prop_index,
- 'pnam' : _Prop_name,
- 'pvis' : _Prop_visible,
- 'scda' : _Prop_shows_creation_date,
- 'scom' : _Prop_shows_comments,
- 'sdat' : _Prop_shows_modification_date,
- 'sfsz' : _Prop_calculates_folder_sizes,
- 'sknd' : _Prop_shows_kind,
- 'slbl' : _Prop_shows_label,
- 'sord' : _Prop_sort_direction,
- 'sprg' : _Prop_spring_open_folders,
- 'srtc' : _Prop_sort_column,
- 'ssiz' : _Prop_shows_size,
- 'svrs' : _Prop_shows_version,
- 'urdt' : _Prop_uses_relative_dates,
- 'usme' : _Prop_uses_simple_menus,
- 'uswg' : _Prop_uses_wide_grid,
- 'vfnt' : _Prop_view_font,
- 'vfsz' : _Prop_view_font_size,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/Window_classes.py b/Lib/plat-mac/lib-scriptpackages/Finder/Window_classes.py
deleted file mode 100644
index 496968a640f..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/Window_classes.py
+++ /dev/null
@@ -1,229 +0,0 @@
-"""Suite Window classes: Classes representing windows
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/Finder.app
-AETE/AEUT resource version 0/144, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'fndr'
-
-class Window_classes_Events:
-
- pass
-
-
-class Finder_window(aetools.ComponentItem):
- """Finder window - A file viewer window """
- want = 'brow'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - inherits some of its properties from the window class """
- which = 'c@#^'
- want = 'cwin'
-class _Prop_current_view(aetools.NProperty):
- """current view - the current view for the container window """
- which = 'pvew'
- want = 'ecvw'
-class _Prop_icon_view_options(aetools.NProperty):
- """icon view options - the icon view options for the container window """
- which = 'icop'
- want = 'icop'
-class _Prop_list_view_options(aetools.NProperty):
- """list view options - the list view options for the container window """
- which = 'lvop'
- want = 'lvop'
-class _Prop_target(aetools.NProperty):
- """target - the container at which this file viewer is targeted """
- which = 'fvtg'
- want = 'obj '
-
-Finder_windows = Finder_window
-
-class window(aetools.ComponentItem):
- """window - A window """
- want = 'cwin'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the boundary rectangle for the window """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_closeable(aetools.NProperty):
- """closeable - Does the window have a close box? """
- which = 'hclb'
- want = 'bool'
-class _Prop_collapsed(aetools.NProperty):
- """collapsed - Is the window collapsed """
- which = 'wshd'
- want = 'bool'
-class _Prop_floating(aetools.NProperty):
- """floating - Does the window have a title bar? """
- which = 'isfl'
- want = 'bool'
-class _Prop_id(aetools.NProperty):
- """id - the unique id for this window """
- which = 'ID '
- want = 'magn'
-class _Prop_index(aetools.NProperty):
- """index - the number of the window in the front-to-back layer ordering """
- which = 'pidx'
- want = 'long'
-class _Prop_modal(aetools.NProperty):
- """modal - Is the window modal? """
- which = 'pmod'
- want = 'bool'
-class _Prop_name(aetools.NProperty):
- """name - the name of the window """
- which = 'pnam'
- want = 'utxt'
-class _Prop_position(aetools.NProperty):
- """position - the upper left position of the window """
- which = 'posn'
- want = 'QDpt'
-class _Prop_properties(aetools.NProperty):
- """properties - every property of a window """
- which = 'pALL'
- want = 'reco'
-class _Prop_resizable(aetools.NProperty):
- """resizable - Is the window resizable? """
- which = 'prsz'
- want = 'bool'
-class _Prop_titled(aetools.NProperty):
- """titled - Does the window have a title bar? """
- which = 'ptit'
- want = 'bool'
-class _Prop_visible(aetools.NProperty):
- """visible - Is the window visible (always true for open Finder windows)? """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomable(aetools.NProperty):
- """zoomable - Is the window zoomable? """
- which = 'iszm'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Is the window zoomed? """
- which = 'pzum'
- want = 'bool'
-class _Prop_zoomed_full_size(aetools.NProperty):
- """zoomed full size - Is the window zoomed to the full size of the screen? (can only be set, not read) """
- which = 'zumf'
- want = 'bool'
-
-windows = window
-
-class information_window(aetools.ComponentItem):
- """information window - An inspector window (opened by \xd2Show Info\xd3) """
- want = 'iwnd'
-class _Prop_current_panel(aetools.NProperty):
- """current panel - the current panel in the information window """
- which = 'panl'
- want = 'ipnl'
-class _Prop_item(aetools.NProperty):
- """item - the item from which this window was opened """
- which = 'cobj'
- want = 'obj '
-
-class clipping_window(aetools.ComponentItem):
- """clipping window - The window containing a clipping """
- want = 'lwnd'
-
-clipping_windows = clipping_window
-
-class preferences_window(aetools.ComponentItem):
- """preferences window - (NOT AVAILABLE YET) The Finder Preferences window """
- want = 'pwnd'
-Finder_window._superclassnames = ['window']
-Finder_window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'current_view' : _Prop_current_view,
- 'icon_view_options' : _Prop_icon_view_options,
- 'list_view_options' : _Prop_list_view_options,
- 'target' : _Prop_target,
-}
-Finder_window._privelemdict = {
-}
-window._superclassnames = []
-window._privpropdict = {
- 'bounds' : _Prop_bounds,
- 'closeable' : _Prop_closeable,
- 'collapsed' : _Prop_collapsed,
- 'floating' : _Prop_floating,
- 'id' : _Prop_id,
- 'index' : _Prop_index,
- 'modal' : _Prop_modal,
- 'name' : _Prop_name,
- 'position' : _Prop_position,
- 'properties' : _Prop_properties,
- 'resizable' : _Prop_resizable,
- 'titled' : _Prop_titled,
- 'visible' : _Prop_visible,
- 'zoomable' : _Prop_zoomable,
- 'zoomed' : _Prop_zoomed,
- 'zoomed_full_size' : _Prop_zoomed_full_size,
-}
-window._privelemdict = {
-}
-information_window._superclassnames = ['window']
-information_window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'current_panel' : _Prop_current_panel,
- 'item' : _Prop_item,
-}
-information_window._privelemdict = {
-}
-clipping_window._superclassnames = ['window']
-clipping_window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-clipping_window._privelemdict = {
-}
-preferences_window._superclassnames = ['window']
-preferences_window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'current_panel' : _Prop_current_panel,
-}
-preferences_window._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'brow' : Finder_window,
- 'cwin' : window,
- 'iwnd' : information_window,
- 'lwnd' : clipping_window,
- 'pwnd' : preferences_window,
-}
-
-_propdeclarations = {
- 'ID ' : _Prop_id,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'cobj' : _Prop_item,
- 'fvtg' : _Prop_target,
- 'hclb' : _Prop_closeable,
- 'icop' : _Prop_icon_view_options,
- 'isfl' : _Prop_floating,
- 'iszm' : _Prop_zoomable,
- 'lvop' : _Prop_list_view_options,
- 'pALL' : _Prop_properties,
- 'panl' : _Prop_current_panel,
- 'pbnd' : _Prop_bounds,
- 'pidx' : _Prop_index,
- 'pmod' : _Prop_modal,
- 'pnam' : _Prop_name,
- 'posn' : _Prop_position,
- 'prsz' : _Prop_resizable,
- 'ptit' : _Prop_titled,
- 'pvew' : _Prop_current_view,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
- 'wshd' : _Prop_collapsed,
- 'zumf' : _Prop_zoomed_full_size,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py b/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
deleted file mode 100644
index 84d178d8f27..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Finder/__init__.py
+++ /dev/null
@@ -1,237 +0,0 @@
-"""
-Package generated from /System/Library/CoreServices/Finder.app
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Finder package is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Standard_Suite
-import Legacy_suite
-import Containers_and_folders
-import Files
-import Finder_Basics
-import Finder_items
-import Window_classes
-import Type_Definitions
-import Enumerations
-
-
-_code_to_module = {
- 'CoRe' : Standard_Suite,
- 'fleg' : Legacy_suite,
- 'fndr' : Containers_and_folders,
- 'fndr' : Files,
- 'fndr' : Finder_Basics,
- 'fndr' : Finder_items,
- 'fndr' : Window_classes,
- 'tpdf' : Type_Definitions,
- 'tpnm' : Enumerations,
-}
-
-
-
-_code_to_fullname = {
- 'CoRe' : ('Finder.Standard_Suite', 'Standard_Suite'),
- 'fleg' : ('Finder.Legacy_suite', 'Legacy_suite'),
- 'fndr' : ('Finder.Containers_and_folders', 'Containers_and_folders'),
- 'fndr' : ('Finder.Files', 'Files'),
- 'fndr' : ('Finder.Finder_Basics', 'Finder_Basics'),
- 'fndr' : ('Finder.Finder_items', 'Finder_items'),
- 'fndr' : ('Finder.Window_classes', 'Window_classes'),
- 'tpdf' : ('Finder.Type_Definitions', 'Type_Definitions'),
- 'tpnm' : ('Finder.Enumerations', 'Enumerations'),
-}
-
-from Standard_Suite import *
-from Legacy_suite import *
-from Containers_and_folders import *
-from Files import *
-from Finder_Basics import *
-from Finder_items import *
-from Window_classes import *
-from Type_Definitions import *
-from Enumerations import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(StdSuites.Type_Names_Suite.small_integer)
-getbaseclasses(StdSuites.Type_Names_Suite.system_dictionary)
-getbaseclasses(StdSuites.Type_Names_Suite.color_table)
-getbaseclasses(StdSuites.Type_Names_Suite.fixed_point)
-getbaseclasses(StdSuites.Type_Names_Suite.string)
-getbaseclasses(StdSuites.Type_Names_Suite.type_element_info)
-getbaseclasses(StdSuites.Type_Names_Suite.machine_location)
-getbaseclasses(StdSuites.Type_Names_Suite.PostScript_picture)
-getbaseclasses(StdSuites.Type_Names_Suite.type_property_info)
-getbaseclasses(StdSuites.Type_Names_Suite.menu_item)
-getbaseclasses(StdSuites.Type_Names_Suite.scrap_styles)
-getbaseclasses(StdSuites.Type_Names_Suite.fixed_rectangle)
-getbaseclasses(StdSuites.Type_Names_Suite.null)
-getbaseclasses(StdSuites.Type_Names_Suite.type_event_info)
-getbaseclasses(StdSuites.Type_Names_Suite.rotation)
-getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_rectangle)
-getbaseclasses(StdSuites.Type_Names_Suite.long_point)
-getbaseclasses(StdSuites.Type_Names_Suite.target_id)
-getbaseclasses(StdSuites.Type_Names_Suite.type_suite_info)
-getbaseclasses(StdSuites.Type_Names_Suite.type_parameter_info)
-getbaseclasses(StdSuites.Type_Names_Suite.long_fixed_point)
-getbaseclasses(StdSuites.Type_Names_Suite.bounding_rectangle)
-getbaseclasses(StdSuites.Type_Names_Suite.TIFF_picture)
-getbaseclasses(StdSuites.Type_Names_Suite.long_fixed)
-getbaseclasses(StdSuites.Type_Names_Suite.version)
-getbaseclasses(StdSuites.Type_Names_Suite.RGB16_color)
-getbaseclasses(StdSuites.Type_Names_Suite.double_integer)
-getbaseclasses(StdSuites.Type_Names_Suite.location_reference)
-getbaseclasses(StdSuites.Type_Names_Suite.point)
-getbaseclasses(StdSuites.Type_Names_Suite.application_dictionary)
-getbaseclasses(StdSuites.Type_Names_Suite.unsigned_integer)
-getbaseclasses(StdSuites.Type_Names_Suite.menu)
-getbaseclasses(StdSuites.Type_Names_Suite.small_real)
-getbaseclasses(StdSuites.Type_Names_Suite.fixed)
-getbaseclasses(StdSuites.Type_Names_Suite.type_class_info)
-getbaseclasses(StdSuites.Type_Names_Suite.RGB96_color)
-getbaseclasses(StdSuites.Type_Names_Suite.dash_style)
-getbaseclasses(StdSuites.Type_Names_Suite.pixel_map_record)
-getbaseclasses(StdSuites.Type_Names_Suite.extended_real)
-getbaseclasses(StdSuites.Type_Names_Suite.long_rectangle)
-getbaseclasses(process)
-getbaseclasses(application_process)
-getbaseclasses(desk_accessory_process)
-getbaseclasses(application)
-getbaseclasses(trash_2d_object)
-getbaseclasses(desktop_2d_object)
-getbaseclasses(container)
-getbaseclasses(folder)
-getbaseclasses(disk)
-getbaseclasses(application)
-getbaseclasses(alias_file)
-getbaseclasses(package)
-getbaseclasses(file)
-getbaseclasses(application_file)
-getbaseclasses(internet_location_file)
-getbaseclasses(document_file)
-getbaseclasses(clipping)
-getbaseclasses(preferences_window)
-getbaseclasses(Finder_window)
-getbaseclasses(window)
-getbaseclasses(clipping_window)
-getbaseclasses(information_window)
-getbaseclasses(item)
-getbaseclasses(icon_view_options)
-getbaseclasses(preferences)
-getbaseclasses(alias_list)
-getbaseclasses(icon_family)
-getbaseclasses(label)
-getbaseclasses(column)
-getbaseclasses(list_view_options)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'shor' : StdSuites.Type_Names_Suite.small_integer,
- 'aeut' : StdSuites.Type_Names_Suite.system_dictionary,
- 'clrt' : StdSuites.Type_Names_Suite.color_table,
- 'fpnt' : StdSuites.Type_Names_Suite.fixed_point,
- 'TEXT' : StdSuites.Type_Names_Suite.string,
- 'elin' : StdSuites.Type_Names_Suite.type_element_info,
- 'mLoc' : StdSuites.Type_Names_Suite.machine_location,
- 'EPS ' : StdSuites.Type_Names_Suite.PostScript_picture,
- 'pinf' : StdSuites.Type_Names_Suite.type_property_info,
- 'cmen' : StdSuites.Type_Names_Suite.menu_item,
- 'styl' : StdSuites.Type_Names_Suite.scrap_styles,
- 'frct' : StdSuites.Type_Names_Suite.fixed_rectangle,
- 'null' : StdSuites.Type_Names_Suite.null,
- 'evin' : StdSuites.Type_Names_Suite.type_event_info,
- 'trot' : StdSuites.Type_Names_Suite.rotation,
- 'lfrc' : StdSuites.Type_Names_Suite.long_fixed_rectangle,
- 'lpnt' : StdSuites.Type_Names_Suite.long_point,
- 'targ' : StdSuites.Type_Names_Suite.target_id,
- 'suin' : StdSuites.Type_Names_Suite.type_suite_info,
- 'pmin' : StdSuites.Type_Names_Suite.type_parameter_info,
- 'lfpt' : StdSuites.Type_Names_Suite.long_fixed_point,
- 'qdrt' : StdSuites.Type_Names_Suite.bounding_rectangle,
- 'TIFF' : StdSuites.Type_Names_Suite.TIFF_picture,
- 'lfxd' : StdSuites.Type_Names_Suite.long_fixed,
- 'vers' : StdSuites.Type_Names_Suite.version,
- 'tr16' : StdSuites.Type_Names_Suite.RGB16_color,
- 'comp' : StdSuites.Type_Names_Suite.double_integer,
- 'insl' : StdSuites.Type_Names_Suite.location_reference,
- 'QDpt' : StdSuites.Type_Names_Suite.point,
- 'aete' : StdSuites.Type_Names_Suite.application_dictionary,
- 'magn' : StdSuites.Type_Names_Suite.unsigned_integer,
- 'cmnu' : StdSuites.Type_Names_Suite.menu,
- 'sing' : StdSuites.Type_Names_Suite.small_real,
- 'fixd' : StdSuites.Type_Names_Suite.fixed,
- 'gcli' : StdSuites.Type_Names_Suite.type_class_info,
- 'tr96' : StdSuites.Type_Names_Suite.RGB96_color,
- 'tdas' : StdSuites.Type_Names_Suite.dash_style,
- 'tpmm' : StdSuites.Type_Names_Suite.pixel_map_record,
- 'exte' : StdSuites.Type_Names_Suite.extended_real,
- 'lrct' : StdSuites.Type_Names_Suite.long_rectangle,
- 'prcs' : process,
- 'pcap' : application_process,
- 'pcda' : desk_accessory_process,
- 'capp' : application,
- 'ctrs' : trash_2d_object,
- 'cdsk' : desktop_2d_object,
- 'ctnr' : container,
- 'cfol' : folder,
- 'cdis' : disk,
- 'capp' : application,
- 'alia' : alias_file,
- 'pack' : package,
- 'file' : file,
- 'appf' : application_file,
- 'inlf' : internet_location_file,
- 'docf' : document_file,
- 'clpf' : clipping,
- 'pwnd' : preferences_window,
- 'brow' : Finder_window,
- 'cwin' : window,
- 'lwnd' : clipping_window,
- 'iwnd' : information_window,
- 'cobj' : item,
- 'icop' : icon_view_options,
- 'cprf' : preferences,
- 'alst' : alias_list,
- 'ifam' : icon_family,
- 'clbl' : label,
- 'lvcl' : column,
- 'lvop' : list_view_options,
-}
-
-
-class Finder(Standard_Suite_Events,
- Legacy_suite_Events,
- Containers_and_folders_Events,
- Files_Events,
- Finder_Basics_Events,
- Finder_items_Events,
- Window_classes_Events,
- Type_Definitions_Events,
- Enumerations_Events,
- aetools.TalkTo):
- _signature = 'MACS'
-
- _moduleName = 'Finder'
-
- _elemdict = application._elemdict
- _propdict = application._propdict
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/Mozilla_suite.py b/Lib/plat-mac/lib-scriptpackages/Netscape/Mozilla_suite.py
deleted file mode 100644
index 9d2625f5ca9..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/Mozilla_suite.py
+++ /dev/null
@@ -1,269 +0,0 @@
-"""Suite Mozilla suite: Experimental Mozilla suite
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'MOSS'
-
-class Mozilla_suite_Events:
-
- def Get_Import_Data(self, _no_object=None, _attributes={}, **_arguments):
- """Get Import Data: Returns a structure containing information that is of use to an external module in importing data from an external mail application into Communicator.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: vRefNum and dirID of profile folder (2+4 bytes), vRefNum and DirID of the local mail folder (2+4 bytes), window type of front window (0 if none, \xd4Brwz\xd5 browser, \xd4Addr\xd5 addressbook, \xd4Mesg\xd5 messenger, etc., 4 bytes)
- """
- _code = 'MOSS'
- _subcode = 'Impt'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_Profile_Name(self, _no_object=None, _attributes={}, **_arguments):
- """Get Profile Name: Get the current User Profile
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Name of the current profile, like \xd2Joe Bloggs\xd3. This is the name of the profile folder in the Netscape Users folder.
- """
- _code = 'MOSS'
- _subcode = 'upro'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Get_workingURL(self, _no_object=None, _attributes={}, **_arguments):
- """Get workingURL: Get the path to the running application in URL format. This will allow a script to construct a relative URL
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Will return text of the from \xd2FILE://foo/applicationname\xd3
- """
- _code = 'MOSS'
- _subcode = 'wurl'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Go = {
- 'direction' : 'dire',
- }
-
- def Go(self, _object, _attributes={}, **_arguments):
- """Go: navigate a window: back, forward, again(reload), home)
- Required argument: window
- Keyword argument direction: undocumented, typecode 'dire'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'gogo'
-
- aetools.keysubst(_arguments, self._argmap_Go)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'dire', _Enum_dire)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Handle_command(self, _object, _attributes={}, **_arguments):
- """Handle command: Handle a command
- Required argument: The command to handle
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'hcmd'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Open_Address_Book(self, _no_object=None, _attributes={}, **_arguments):
- """Open Address Book: Opens the address book
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'addr'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Open_Component(self, _object, _attributes={}, **_arguments):
- """Open Component: Open a Communicator component
- Required argument: The component to open
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'cpnt'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Open_Profile_Manager(self, _no_object=None, _attributes={}, **_arguments):
- """Open Profile Manager: Open the user profile manager (obsolete)
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'prfl'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def Open_bookmark(self, _object=None, _attributes={}, **_arguments):
- """Open bookmark: Reads in a bookmark file
- Required argument: If not available, reloads the current bookmark file
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'book'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Read_help_file = {
- 'with_index' : 'idid',
- 'search_text' : 'sear',
- }
-
- def Read_help_file(self, _object, _attributes={}, **_arguments):
- """Read help file: Reads in the help file (file should be in the help file format)
- Required argument: undocumented, typecode 'alis'
- Keyword argument with_index: Index to the help file. Defaults to \xd4DEFAULT\xd5)
- Keyword argument search_text: Optional text to search for
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'MOSS'
- _subcode = 'help'
-
- aetools.keysubst(_arguments, self._argmap_Read_help_file)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-_Enum_comp = {
- 'Navigator' : 'navg', # The Navigator component
- 'InBox' : 'inbx', # The InBox component
- 'Newsgroups' : 'colb', # The Newsgroups component
- 'Composer' : 'cpsr', # The Page Composer component
- 'Conference' : 'conf', # The Conference Component
- 'Calendar' : 'cald', # The Calendar Component
-}
-
-_Enum_dire = {
- 'again' : 'agai', # Again (reload)
- 'home' : 'home', # Home
- 'backward' : 'prev', # Previous page
- 'forward' : 'next', # Next page
-}
-
-_Enum_ncmd = {
- 'Get_new_mail' : '\x00\x00\x04W', #
- 'Send_queued_messages' : '\x00\x00\x04X', #
- 'Read_newsgroups' : '\x00\x00\x04\x04', #
- 'Show_Inbox' : '\x00\x00\x04\x05', #
- 'Show_Bookmarks_window' : '\x00\x00\x04\x06', #
- 'Show_History_window' : '\x00\x00\x04\x07', #
- 'Show_Address_Book_window' : '\x00\x00\x04\t', #
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'comp' : _Enum_comp,
- 'dire' : _Enum_dire,
- 'ncmd' : _Enum_ncmd,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/PowerPlant.py b/Lib/plat-mac/lib-scriptpackages/Netscape/PowerPlant.py
deleted file mode 100644
index d37e66fc807..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/PowerPlant.py
+++ /dev/null
@@ -1,86 +0,0 @@
-"""Suite PowerPlant:
-Level 0, version 0
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'ppnt'
-
-class PowerPlant_Events:
-
- _argmap_SwitchTellTarget = {
- 'to' : 'data',
- }
-
- def SwitchTellTarget(self, _no_object=None, _attributes={}, **_arguments):
- """SwitchTellTarget: Makes an object the \xd2focus\xd3 of AppleEvents
- Keyword argument to: reference to new focus of AppleEvents
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ppnt'
- _subcode = 'sttg'
-
- aetools.keysubst(_arguments, self._argmap_SwitchTellTarget)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_select = {
- 'data' : 'data',
- }
-
- def select(self, _object, _attributes={}, **_arguments):
- """select: Sets the present selection
- Required argument: object to select or container of sub-objects to select
- Keyword argument data: sub-object(s) to select
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'slct'
-
- aetools.keysubst(_arguments, self._argmap_select)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-_Enum_dbac = {
- 'DoNothing' : '\x00\x00\x00\x00', # No debugging action is taken.
- 'PostAlert' : '\x00\x00\x00\x01', # Post an alert.
- 'LowLevelDebugger' : '\x00\x00\x00\x02', # Break into the low level debugger (MacsBug).
- 'SourceDebugger' : '\x00\x00\x00\x03', # Break into the source level debugger (if source debugger is executing).
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'dbac' : _Enum_dbac,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/Required_suite.py b/Lib/plat-mac/lib-scriptpackages/Netscape/Required_suite.py
deleted file mode 100644
index c99794f5a8f..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/Required_suite.py
+++ /dev/null
@@ -1,108 +0,0 @@
-"""Suite Required suite:
-Level 0, version 0
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'reqd'
-
-from StdSuites.Required_Suite import *
-class Required_suite_Events(Required_Suite_Events):
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def print_(self, _object, _attributes={}, **_arguments):
- """print: Print the specified object(s)
- Required argument: list of objects to print
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def quit(self, _no_object=None, _attributes={}, **_arguments):
- """quit: Quit Navigator
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def run(self, _no_object=None, _attributes={}, **_arguments):
- """run: Sent to an application when it is double-clicked
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'oapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_Suite.py
deleted file mode 100644
index 5c3e927893c..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_Suite.py
+++ /dev/null
@@ -1,243 +0,0 @@
-"""Suite Standard Suite: Common terms for most applications
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'CoRe'
-
-from StdSuites.Standard_Suite import *
-class Standard_Suite_Events(Standard_Suite_Events):
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: Close an object
- Required argument: the objects to close
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def data_size(self, _object, _attributes={}, **_arguments):
- """data size: Return the size in bytes of an object
- Required argument: the object whose data size is to be returned
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the size of the object in bytes
- """
- _code = 'core'
- _subcode = 'dsiz'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def get(self, _object, _attributes={}, **_arguments):
- """get: Get the data for an object
- Required argument: the object whose data is to be returned
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: The data from the object
- """
- _code = 'core'
- _subcode = 'getd'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_set = {
- 'to' : 'data',
- }
-
- def set(self, _object, _attributes={}, **_arguments):
- """set: Set an object\xd5s data
- Required argument: the object to change
- Keyword argument to: the new value
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'setd'
-
- aetools.keysubst(_arguments, self._argmap_set)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - An application program """
- want = 'capp'
-class _Prop_alert_application(aetools.NProperty):
- """alert application - Most of the alerts will be sent to this application using yet unspecified AE interface. We need a few alert boxes: alert, confirm and notify. Any ideas on how to design this event? mailto:atotic@netscape.com. I\xd5d like to conform to the standard. """
- which = 'ALAP'
- want = 'type'
-alert_application = _Prop_alert_application()
-class _Prop_kiosk_mode(aetools.NProperty):
- """kiosk mode - Kiosk mode leaves very few menus enabled """
- which = 'KOSK'
- want = 'long'
-kiosk_mode = _Prop_kiosk_mode()
-# element 'cwin' as ['indx', 'name', 'ID ']
-
-class window(aetools.ComponentItem):
- """window - A Window """
- want = 'cwin'
-class _Prop_URL(aetools.NProperty):
- """URL - Current URL """
- which = 'curl'
- want = 'TEXT'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the boundary rectangle for the window """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_busy(aetools.NProperty):
- """busy - Is window loading something right now. 2, window is busy and will reject load requests. 1, window is busy, but will interrupt outstanding loads """
- which = 'busy'
- want = 'long'
-class _Prop_closeable(aetools.NProperty):
- """closeable - Does the window have a close box? """
- which = 'hclb'
- want = 'bool'
-class _Prop_floating(aetools.NProperty):
- """floating - Does the window float? """
- which = 'isfl'
- want = 'bool'
-class _Prop_index(aetools.NProperty):
- """index - the number of the window """
- which = 'pidx'
- want = 'long'
-class _Prop_modal(aetools.NProperty):
- """modal - Is the window modal? """
- which = 'pmod'
- want = 'bool'
-class _Prop_name(aetools.NProperty):
- """name - the title of the window """
- which = 'pnam'
- want = 'itxt'
-class _Prop_position(aetools.NProperty):
- """position - upper left coordinates of window """
- which = 'ppos'
- want = 'QDpt'
-class _Prop_resizable(aetools.NProperty):
- """resizable - Is the window resizable? """
- which = 'prsz'
- want = 'bool'
-class _Prop_titled(aetools.NProperty):
- """titled - Does the window have a title bar? """
- which = 'ptit'
- want = 'bool'
-class _Prop_unique_ID(aetools.NProperty):
- """unique ID - Window\xd5s unique ID (a bridge between WWW! suite window id\xd5s and standard AE windows) """
- which = 'wiid'
- want = 'long'
-class _Prop_visible(aetools.NProperty):
- """visible - is the window visible? """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomable(aetools.NProperty):
- """zoomable - Is the window zoomable? """
- which = 'iszm'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Is the window zoomed? """
- which = 'pzum'
- want = 'bool'
-application._superclassnames = []
-application._privpropdict = {
- 'alert_application' : _Prop_alert_application,
- 'kiosk_mode' : _Prop_kiosk_mode,
-}
-application._privelemdict = {
- 'window' : window,
-}
-window._superclassnames = []
-window._privpropdict = {
- 'URL' : _Prop_URL,
- 'bounds' : _Prop_bounds,
- 'busy' : _Prop_busy,
- 'closeable' : _Prop_closeable,
- 'floating' : _Prop_floating,
- 'index' : _Prop_index,
- 'modal' : _Prop_modal,
- 'name' : _Prop_name,
- 'position' : _Prop_position,
- 'resizable' : _Prop_resizable,
- 'titled' : _Prop_titled,
- 'unique_ID' : _Prop_unique_ID,
- 'visible' : _Prop_visible,
- 'zoomable' : _Prop_zoomable,
- 'zoomed' : _Prop_zoomed,
-}
-window._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cwin' : window,
-}
-
-_propdeclarations = {
- 'ALAP' : _Prop_alert_application,
- 'KOSK' : _Prop_kiosk_mode,
- 'busy' : _Prop_busy,
- 'curl' : _Prop_URL,
- 'hclb' : _Prop_closeable,
- 'isfl' : _Prop_floating,
- 'iszm' : _Prop_zoomable,
- 'pbnd' : _Prop_bounds,
- 'pidx' : _Prop_index,
- 'pmod' : _Prop_modal,
- 'pnam' : _Prop_name,
- 'ppos' : _Prop_position,
- 'prsz' : _Prop_resizable,
- 'ptit' : _Prop_titled,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
- 'wiid' : _Prop_unique_ID,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_URL_suite.py b/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_URL_suite.py
deleted file mode 100644
index de4a01c9e59..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/Standard_URL_suite.py
+++ /dev/null
@@ -1,60 +0,0 @@
-"""Suite Standard URL suite: Mac URL standard, supported by many apps
-
-
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'GURL'
-
-class Standard_URL_suite_Events:
-
- _argmap_GetURL = {
- 'to' : 'dest',
- 'inside' : 'HWIN',
- 'from_' : 'refe',
- }
-
- def GetURL(self, _object, _attributes={}, **_arguments):
- """GetURL: Loads the URL (optionally to disk)
- Required argument: The url
- Keyword argument to: file the URL should be loaded into
- Keyword argument inside: Window the URL should be loaded to
- Keyword argument from_: Referrer, to be sent with the HTTP request
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'GURL'
- _subcode = 'GURL'
-
- aetools.keysubst(_arguments, self._argmap_GetURL)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/Text.py b/Lib/plat-mac/lib-scriptpackages/Netscape/Text.py
deleted file mode 100644
index 2360d949a38..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/Text.py
+++ /dev/null
@@ -1,122 +0,0 @@
-"""Suite Text:
-Level 0, version 0
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'TEXT'
-
-from StdSuites.Text_Suite import *
-class Text_Events(Text_Suite_Events):
-
- pass
-
-
-class text(aetools.ComponentItem):
- """text - independent text view objects """
- want = 'ctxt'
-class _Prop_beginning(aetools.NProperty):
- """beginning - Beginning of element """
- which = 'bgng'
- want = 'obj '
-class _Prop_end(aetools.NProperty):
- """end - Ending of element """
- which = 'end '
- want = 'obj '
-class _Prop_infront(aetools.NProperty):
- """infront - Immediately before element """
- which = 'pBef'
- want = 'obj '
-class _Prop_justbehind(aetools.NProperty):
- """justbehind - Immediately after element """
- which = 'pAft'
- want = 'obj '
-class _Prop_updateLevel(aetools.NProperty):
- """updateLevel - updating level. Can only be incremented or decremented. Do so only in a try block -- if the level is greater than zero, visual text updating will cease. """
- which = 'pUpL'
- want = 'long'
-# element 'stys' as ['indx', 'name']
-
-class styleset(aetools.ComponentItem):
- """styleset - A style \xd2set\xd3 that may be used repeatedly in text objects. """
- want = 'stys'
-class _Prop_color(aetools.NProperty):
- """color - the color """
- which = 'colr'
- want = 'RGB '
-class _Prop_font(aetools.NProperty):
- """font - font name """
- which = 'font'
- want = 'TEXT'
-class _Prop_name(aetools.NProperty):
- """name - style name """
- which = 'pnam'
- want = 'TEXT'
-class _Prop_size(aetools.NProperty):
- """size - the size in points """
- which = 'ptsz'
- want = 'long'
-class _Prop_style(aetools.NProperty):
- """style - the text styles or face attributes """
- which = 'txst'
- want = 'tsty'
-class _Prop_writing_code(aetools.NProperty):
- """writing code - the script system and language """
- which = 'psct'
- want = 'tsty'
-
-stylesets = styleset
-text._superclassnames = []
-text._privpropdict = {
- 'beginning' : _Prop_beginning,
- 'end' : _Prop_end,
- 'infront' : _Prop_infront,
- 'justbehind' : _Prop_justbehind,
- 'updateLevel' : _Prop_updateLevel,
-}
-text._privelemdict = {
- 'styleset' : styleset,
-}
-styleset._superclassnames = []
-styleset._privpropdict = {
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'name' : _Prop_name,
- 'size' : _Prop_size,
- 'style' : _Prop_style,
- 'writing_code' : _Prop_writing_code,
-}
-styleset._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'ctxt' : text,
- 'stys' : styleset,
-}
-
-_propdeclarations = {
- 'bgng' : _Prop_beginning,
- 'colr' : _Prop_color,
- 'end ' : _Prop_end,
- 'font' : _Prop_font,
- 'pAft' : _Prop_justbehind,
- 'pBef' : _Prop_infront,
- 'pUpL' : _Prop_updateLevel,
- 'pnam' : _Prop_name,
- 'psct' : _Prop_writing_code,
- 'ptsz' : _Prop_size,
- 'txst' : _Prop_style,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/WorldWideWeb_suite.py b/Lib/plat-mac/lib-scriptpackages/Netscape/WorldWideWeb_suite.py
deleted file mode 100644
index 1706b25c232..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/WorldWideWeb_suite.py
+++ /dev/null
@@ -1,426 +0,0 @@
-"""Suite WorldWideWeb suite, as defined in Spyglass spec.:
-Level 1, version 1
-
-Generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'WWW!'
-
-class WorldWideWeb_suite_Events:
-
- _argmap_OpenURL = {
- 'to' : 'INTO',
- 'toWindow' : 'WIND',
- 'flags' : 'FLGS',
- 'post_data' : 'POST',
- 'post_type' : 'MIME',
- 'progressApp' : 'PROG',
- }
-
- def OpenURL(self, _object, _attributes={}, **_arguments):
- """OpenURL: Opens a URL. Allows for more options than GetURL event
- Required argument: URL
- Keyword argument to: file destination
- Keyword argument toWindow: window iD
- Keyword argument flags: Binary: any combination of 1, 2 and 4 is allowed: 1 and 2 mean force reload the document. 4 is ignored
- Keyword argument post_data: Form posting data
- Keyword argument post_type: MIME type of the posting data. Defaults to application/x-www-form-urlencoded
- Keyword argument progressApp: Application that will display progress
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: ID of the loading window
- """
- _code = 'WWW!'
- _subcode = 'OURL'
-
- aetools.keysubst(_arguments, self._argmap_OpenURL)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_ShowFile = {
- 'MIME_type' : 'MIME',
- 'Window_ID' : 'WIND',
- 'URL' : 'URL ',
- }
-
- def ShowFile(self, _object, _attributes={}, **_arguments):
- """ShowFile: Similar to OpenDocuments, except that it specifies the parent URL, and MIME type of the file
- Required argument: File to open
- Keyword argument MIME_type: MIME type
- Keyword argument Window_ID: Window to open the file in
- Keyword argument URL: Use this as a base URL
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Window ID of the loaded window. 0 means ShowFile failed, FFFFFFF means that data was not appropriate type to display in the browser.
- """
- _code = 'WWW!'
- _subcode = 'SHWF'
-
- aetools.keysubst(_arguments, self._argmap_ShowFile)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_cancel_progress = {
- 'in_window' : 'WIND',
- }
-
- def cancel_progress(self, _object=None, _attributes={}, **_arguments):
- """cancel progress: Interrupts the download of the document in the given window
- Required argument: progress ID, obtained from the progress app
- Keyword argument in_window: window ID of the progress to cancel
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'CNCL'
-
- aetools.keysubst(_arguments, self._argmap_cancel_progress)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def find_URL(self, _object, _attributes={}, **_arguments):
- """find URL: If the file was downloaded by Netscape, you can call FindURL to find out the URL used to download the file.
- Required argument: File spec
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: The URL
- """
- _code = 'WWW!'
- _subcode = 'FURL'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def get_window_info(self, _object=None, _attributes={}, **_arguments):
- """get window info: Returns the information about the window as a list. Currently the list contains the window title and the URL. You can get the same information using standard Apple Event GetProperty.
- Required argument: window ID
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: undocumented, typecode 'list'
- """
- _code = 'WWW!'
- _subcode = 'WNFO'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def list_windows(self, _no_object=None, _attributes={}, **_arguments):
- """list windows: Lists the IDs of all the hypertext windows
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: List of unique IDs of all the hypertext windows
- """
- _code = 'WWW!'
- _subcode = 'LSTW'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_parse_anchor = {
- 'relative_to' : 'RELA',
- }
-
- def parse_anchor(self, _object, _attributes={}, **_arguments):
- """parse anchor: Resolves the relative URL
- Required argument: Main URL
- Keyword argument relative_to: Relative URL
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: Parsed URL
- """
- _code = 'WWW!'
- _subcode = 'PRSA'
-
- aetools.keysubst(_arguments, self._argmap_parse_anchor)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def register_URL_echo(self, _object=None, _attributes={}, **_arguments):
- """register URL echo: Registers the \xd2echo\xd3 application. Each download from now on will be echoed to this application.
- Required argument: Application signature
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'RGUE'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_register_protocol = {
- 'for_protocol' : 'PROT',
- }
-
- def register_protocol(self, _object=None, _attributes={}, **_arguments):
- """register protocol: Registers application as a \xd2handler\xd3 for this protocol with a given prefix. The handler will receive \xd2OpenURL\xd3, or if that fails, \xd2GetURL\xd3 event.
- Required argument: Application sig
- Keyword argument for_protocol: protocol prefix: \xd2finger:\xd3, \xd2file\xd3,
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: TRUE if registration has been successful
- """
- _code = 'WWW!'
- _subcode = 'RGPR'
-
- aetools.keysubst(_arguments, self._argmap_register_protocol)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_register_viewer = {
- 'MIME_type' : 'MIME',
- 'with_file_type' : 'FTYP',
- }
-
- def register_viewer(self, _object, _attributes={}, **_arguments):
- """register viewer: Registers an application as a \xd4special\xd5 viewer for this MIME type. The application will be launched with ViewDoc events
- Required argument: Application sig
- Keyword argument MIME_type: MIME type viewer is registering for
- Keyword argument with_file_type: Mac file type for the downloaded files
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: TRUE if registration has been successful
- """
- _code = 'WWW!'
- _subcode = 'RGVW'
-
- aetools.keysubst(_arguments, self._argmap_register_viewer)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_register_window_close = {
- 'for_window' : 'WIND',
- }
-
- def register_window_close(self, _object=None, _attributes={}, **_arguments):
- """register window close: Netscape will notify registered application when this window closes
- Required argument: Application signature
- Keyword argument for_window: window ID
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: true if successful
- """
- _code = 'WWW!'
- _subcode = 'RGWC'
-
- aetools.keysubst(_arguments, self._argmap_register_window_close)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def unregister_URL_echo(self, _object, _attributes={}, **_arguments):
- """unregister URL echo: cancels URL echo
- Required argument: application signature
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'UNRU'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_unregister_protocol = {
- 'for_protocol' : 'PROT',
- }
-
- def unregister_protocol(self, _object=None, _attributes={}, **_arguments):
- """unregister protocol: reverses the effects of \xd2register protocol\xd3
- Required argument: Application sig.
- Keyword argument for_protocol: protocol prefix. If none, unregister for all protocols
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: TRUE if successful
- """
- _code = 'WWW!'
- _subcode = 'UNRP'
-
- aetools.keysubst(_arguments, self._argmap_unregister_protocol)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_unregister_viewer = {
- 'MIME_type' : 'MIME',
- }
-
- def unregister_viewer(self, _object, _attributes={}, **_arguments):
- """unregister viewer: Revert to the old way of handling this MIME type
- Required argument: Application sig
- Keyword argument MIME_type: MIME type to be unregistered
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: TRUE if the event was successful
- """
- _code = 'WWW!'
- _subcode = 'UNRV'
-
- aetools.keysubst(_arguments, self._argmap_unregister_viewer)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_unregister_window_close = {
- 'for_window' : 'WIND',
- }
-
- def unregister_window_close(self, _object=None, _attributes={}, **_arguments):
- """unregister window close: Undo for register window close
- Required argument: Application signature
- Keyword argument for_window: window ID
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: true if successful
- """
- _code = 'WWW!'
- _subcode = 'UNRC'
-
- aetools.keysubst(_arguments, self._argmap_unregister_window_close)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def webActivate(self, _object=None, _attributes={}, **_arguments):
- """webActivate: Makes Netscape the frontmost application, and selects a given window. This event is here for suite completeness/ cross-platform compatibility only, you should use standard AppleEvents instead.
- Required argument: window to bring to front
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'WWW!'
- _subcode = 'ACTV'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py b/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
deleted file mode 100644
index 802f18a3b4f..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Netscape/__init__.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""
-Package generated from /Volumes/Sap/Applications (Mac OS 9)/Netscape Communicator\xe2\x84\xa2 Folder/Netscape Communicator\xe2\x84\xa2
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Netscape package is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Standard_Suite
-import Standard_URL_suite
-import Mozilla_suite
-import Text
-import WorldWideWeb_suite
-import PowerPlant
-import Required_suite
-
-
-_code_to_module = {
- 'CoRe' : Standard_Suite,
- 'GURL' : Standard_URL_suite,
- 'MOSS' : Mozilla_suite,
- 'TEXT' : Text,
- 'WWW!' : WorldWideWeb_suite,
- 'ppnt' : PowerPlant,
- 'reqd' : Required_suite,
-}
-
-
-
-_code_to_fullname = {
- 'CoRe' : ('Netscape.Standard_Suite', 'Standard_Suite'),
- 'GURL' : ('Netscape.Standard_URL_suite', 'Standard_URL_suite'),
- 'MOSS' : ('Netscape.Mozilla_suite', 'Mozilla_suite'),
- 'TEXT' : ('Netscape.Text', 'Text'),
- 'WWW!' : ('Netscape.WorldWideWeb_suite', 'WorldWideWeb_suite'),
- 'ppnt' : ('Netscape.PowerPlant', 'PowerPlant'),
- 'reqd' : ('Netscape.Required_suite', 'Required_suite'),
-}
-
-from Standard_Suite import *
-from Standard_URL_suite import *
-from Mozilla_suite import *
-from Text import *
-from WorldWideWeb_suite import *
-from PowerPlant import *
-from Required_suite import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(text)
-getbaseclasses(styleset)
-getbaseclasses(StdSuites.Text_Suite.character)
-getbaseclasses(StdSuites.Text_Suite.text_flow)
-getbaseclasses(StdSuites.Text_Suite.word)
-getbaseclasses(StdSuites.Text_Suite.paragraph)
-getbaseclasses(StdSuites.Text_Suite.text_style_info)
-getbaseclasses(StdSuites.Text_Suite.line)
-getbaseclasses(StdSuites.Text_Suite.text)
-getbaseclasses(window)
-getbaseclasses(application)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'ctxt' : text,
- 'stys' : styleset,
- 'cha ' : StdSuites.Text_Suite.character,
- 'cflo' : StdSuites.Text_Suite.text_flow,
- 'cwor' : StdSuites.Text_Suite.word,
- 'cpar' : StdSuites.Text_Suite.paragraph,
- 'tsty' : StdSuites.Text_Suite.text_style_info,
- 'clin' : StdSuites.Text_Suite.line,
- 'ctxt' : StdSuites.Text_Suite.text,
- 'cwin' : window,
- 'capp' : application,
-}
-
-
-class Netscape(Standard_Suite_Events,
- Standard_URL_suite_Events,
- Mozilla_suite_Events,
- Text_Events,
- WorldWideWeb_suite_Events,
- PowerPlant_Events,
- Required_suite_Events,
- aetools.TalkTo):
- _signature = 'MOSS'
-
- _moduleName = 'Netscape'
-
- _elemdict = application._elemdict
- _propdict = application._propdict
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py
deleted file mode 100644
index ff5bcc4318d..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py
+++ /dev/null
@@ -1,2215 +0,0 @@
-"""Suite AppleScript Suite: Standard terms for AppleScript
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'ascr'
-
-class AppleScript_Suite_Events:
-
- def _26_(self, _object, _attributes={}, **_arguments):
- """&: Concatenation
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'ccat'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _2a_(self, _object, _attributes={}, **_arguments):
- """*: Multiplication
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '* '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _2b_(self, _object, _attributes={}, **_arguments):
- """+: Addition
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '+ '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _2d_(self, _object, _attributes={}, **_arguments):
- """-: Subtraction
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '- '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _3c_(self, _object, _attributes={}, **_arguments):
- """<: Less than
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '< '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _3d_(self, _object, _attributes={}, **_arguments):
- """=: Equality
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '= '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _3e_(self, _object, _attributes={}, **_arguments):
- """>: Greater than
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '> '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_Call_a5_subroutine = {
- 'at' : 'at ',
- 'from_' : 'from',
- 'for_' : 'for ',
- 'to' : 'to ',
- 'thru' : 'thru',
- 'through' : 'thgh',
- 'by' : 'by ',
- 'on' : 'on ',
- 'into' : 'into',
- 'onto' : 'onto',
- 'between' : 'btwn',
- 'against' : 'agst',
- 'out_of' : 'outo',
- 'instead_of' : 'isto',
- 'aside_from' : 'asdf',
- 'around' : 'arnd',
- 'beside' : 'bsid',
- 'beneath' : 'bnth',
- 'under' : 'undr',
- 'over' : 'over',
- 'above' : 'abve',
- 'below' : 'belw',
- 'apart_from' : 'aprt',
- 'about' : 'abou',
- 'since' : 'snce',
- 'given' : 'givn',
- 'with' : 'with',
- 'without' : 'wout',
- }
-
- def Call_a5_subroutine(self, _object=None, _attributes={}, **_arguments):
- """Call\xa5subroutine: A subroutine call
- Required argument: anything
- Keyword argument at: a preposition
- Keyword argument from_: a preposition
- Keyword argument for_: a preposition
- Keyword argument to: a preposition
- Keyword argument thru: a preposition
- Keyword argument through: a preposition
- Keyword argument by: a preposition
- Keyword argument on: a preposition
- Keyword argument into: a preposition
- Keyword argument onto: a preposition
- Keyword argument between: a preposition
- Keyword argument against: a preposition
- Keyword argument out_of: a preposition
- Keyword argument instead_of: a preposition
- Keyword argument aside_from: a preposition
- Keyword argument around: a preposition
- Keyword argument beside: a preposition
- Keyword argument beneath: a preposition
- Keyword argument under: a preposition
- Keyword argument over: a preposition
- Keyword argument above: a preposition
- Keyword argument below: a preposition
- Keyword argument apart_from: a preposition
- Keyword argument about: a preposition
- Keyword argument since: a preposition
- Keyword argument given: parameter:value pairs, comma-separated
- Keyword argument with: formal parameter set to true if matching actual parameter is provided
- Keyword argument without: formal parameter set to false if matching actual parmeter is provided
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'psbr'
-
- aetools.keysubst(_arguments, self._argmap_Call_a5_subroutine)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _5e_(self, _object, _attributes={}, **_arguments):
- """^: Exponentiation
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '^ '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def activate(self, _no_object=None, _attributes={}, **_arguments):
- """activate: Bring the targeted application program to the front
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'actv'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def and_(self, _object, _attributes={}, **_arguments):
- """and: Logical conjunction
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'AND '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def as_(self, _object, _attributes={}, **_arguments):
- """as: Coercion
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'coer'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def contains(self, _object, _attributes={}, **_arguments):
- """contains: Containment
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'cont'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def div(self, _object, _attributes={}, **_arguments):
- """div: Quotient
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'div '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def end_tell(self, _no_object=None, _attributes={}, **_arguments):
- """end tell: Record or log an \xd4end tell\xd5 statement
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ascr'
- _subcode = 'tend'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def ends_with(self, _object, _attributes={}, **_arguments):
- """ends with: Ends with
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'ends'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_error = {
- 'number' : 'errn',
- 'partial_result' : 'ptlr',
- 'from_' : 'erob',
- 'to' : 'errt',
- }
-
- def error(self, _object=None, _attributes={}, **_arguments):
- """error: Raise an error
- Required argument: anything
- Keyword argument number: an error number
- Keyword argument partial_result: any partial result occurring before the error
- Keyword argument from_: the object that caused the error
- Keyword argument to: the desired class for a failed coercion
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ascr'
- _subcode = 'err '
-
- aetools.keysubst(_arguments, self._argmap_error)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def idle(self, _no_object=None, _attributes={}, **_arguments):
- """idle: Sent to a script application when it is idle
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the number of seconds to wait for next idle event
- """
- _code = 'misc'
- _subcode = 'idle'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def launch(self, _no_object=None, _attributes={}, **_arguments):
- """launch: Start an application for scripting
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ascr'
- _subcode = 'noop'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def log(self, _object, _attributes={}, **_arguments):
- """log: Cause a comment to be logged
- Required argument: undocumented, typecode 'TEXT'
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ascr'
- _subcode = 'cmnt'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def mod(self, _object, _attributes={}, **_arguments):
- """mod: Remainder
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'mod '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def negate(self, _object, _attributes={}, **_arguments):
- """negate: Numeric negation
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'neg '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def not_(self, _object, _attributes={}, **_arguments):
- """not: Logical negation
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'NOT '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def or_(self, _object, _attributes={}, **_arguments):
- """or: Logical disjunction
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'OR '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def start_log(self, _no_object=None, _attributes={}, **_arguments):
- """start log: Start event logging in the script editor
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ToyS'
- _subcode = 'log1'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def starts_with(self, _object, _attributes={}, **_arguments):
- """starts with: Starts with
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = 'bgwt'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def stop_log(self, _no_object=None, _attributes={}, **_arguments):
- """stop log: Stop event logging in the script editor
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ToyS'
- _subcode = 'log0'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def tell(self, _no_object=None, _attributes={}, **_arguments):
- """tell: Record or log a \xd4tell\xd5 statement
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'ascr'
- _subcode = 'tell'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _ad_(self, _object, _attributes={}, **_arguments):
- """\xad: Inequality
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '\xad '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _b2_(self, _object, _attributes={}, **_arguments):
- """\xb2: Less than or equal to
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '<= '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _b3_(self, _object, _attributes={}, **_arguments):
- """\xb3: Greater than or equal to
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '>= '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _d6_(self, _object, _attributes={}, **_arguments):
- """\xd6: Division
- Required argument: an AE object reference
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: anything
- """
- _code = 'ascr'
- _subcode = '/ '
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class anything(aetools.ComponentItem):
- """anything - any class or reference """
- want = '****'
-
-class pictures(aetools.ComponentItem):
- """pictures - """
- want = 'PICT'
-
-picture = pictures
-
-class styled_text(aetools.ComponentItem):
- """styled text - text with font, size, and style information """
- want = 'STXT'
-
-styled_text = styled_text
-
-class strings(aetools.ComponentItem):
- """strings - """
- want = 'TEXT'
-
-string = strings
-
-class alias(aetools.ComponentItem):
- """alias - a file on a disk or server. The file must exist when you check the syntax of your script. """
- want = 'alis'
-class _Prop_POSIX_path(aetools.NProperty):
- """POSIX path - the POSIX path of the file """
- which = 'psxp'
- want = 'TEXT'
-
-aliases = alias
-
-class April(aetools.ComponentItem):
- """April - the month of April """
- want = 'apr '
-
-class August(aetools.ComponentItem):
- """August - the month of August """
- want = 'aug '
-
-class booleans(aetools.ComponentItem):
- """booleans - """
- want = 'bool'
-
-boolean = booleans
-
-class RGB_colors(aetools.ComponentItem):
- """RGB colors - """
- want = 'cRGB'
-
-RGB_color = RGB_colors
-
-class application(aetools.ComponentItem):
- """application - specifies global properties of AppleScript """
- want = 'capp'
-class _Prop_AppleScript(aetools.NProperty):
- """AppleScript - the top-level script object """
- which = 'ascr'
- want = 'scpt'
-AppleScript = _Prop_AppleScript()
-class _Prop_days(aetools.NProperty):
- """days - the number of seconds in a day """
- which = 'days'
- want = 'long'
-days = _Prop_days()
-class _Prop_hours(aetools.NProperty):
- """hours - the number of seconds in an hour """
- which = 'hour'
- want = 'long'
-hours = _Prop_hours()
-class _Prop_minutes(aetools.NProperty):
- """minutes - the number of seconds in a minute """
- which = 'min '
- want = 'long'
-minutes = _Prop_minutes()
-class _Prop_pi(aetools.NProperty):
- """pi - the constant pi """
- which = 'pi '
- want = 'doub'
-pi = _Prop_pi()
-class _Prop_print_depth(aetools.NProperty):
- """print depth - the maximum depth to print """
- which = 'prdp'
- want = 'long'
-print_depth = _Prop_print_depth()
-class _Prop_print_length(aetools.NProperty):
- """print length - the maximum length to print """
- which = 'prln'
- want = 'long'
-print_length = _Prop_print_length()
-class _Prop_result(aetools.NProperty):
- """result - the last result of evaluation """
- which = 'rslt'
- want = '****'
-result = _Prop_result()
-class _Prop_return_(aetools.NProperty):
- """return - a return character """
- which = 'ret '
- want = 'cha '
-return_ = _Prop_return_()
-class _Prop_space(aetools.NProperty):
- """space - a space character """
- which = 'spac'
- want = 'cha '
-space = _Prop_space()
-class _Prop_tab(aetools.NProperty):
- """tab - a tab character """
- which = 'tab '
- want = 'cha '
-tab = _Prop_tab()
-class _Prop_text_item_delimiters(aetools.NProperty):
- """text item delimiters - the text item delimiters of a string """
- which = 'txdl'
- want = 'list'
-text_item_delimiters = _Prop_text_item_delimiters()
-class _Prop_weeks(aetools.NProperty):
- """weeks - the number of seconds in a week """
- which = 'week'
- want = 'long'
-weeks = _Prop_weeks()
-
-applications = application
-
-app = application
-
-class upper_case(aetools.ComponentItem):
- """upper case - Text with lower case converted to upper case """
- want = 'case'
-
-class cubic_centimeters(aetools.ComponentItem):
- """cubic centimeters - a volume measurement in SI cubic centimeters """
- want = 'ccmt'
-
-cubic_centimetres = cubic_centimeters
-
-class cubic_feet(aetools.ComponentItem):
- """cubic feet - a volume measurement in Imperial cubic feet """
- want = 'cfet'
-
-class characters(aetools.ComponentItem):
- """characters - """
- want = 'cha '
-
-character = characters
-
-class writing_code_info(aetools.ComponentItem):
- """writing code info - script code and language code of text run """
- want = 'citl'
-class _Prop_language_code(aetools.NProperty):
- """language code - the language code for the text """
- which = 'plcd'
- want = 'shor'
-class _Prop_script_code(aetools.NProperty):
- """script code - the script code for the text """
- which = 'pscd'
- want = 'shor'
-
-writing_code_infos = writing_code_info
-
-class text_items(aetools.ComponentItem):
- """text items - """
- want = 'citm'
-
-text_item = text_items
-
-class cubic_meters(aetools.ComponentItem):
- """cubic meters - a volume measurement in SI cubic meters """
- want = 'cmet'
-
-cubic_metres = cubic_meters
-
-class centimeters(aetools.ComponentItem):
- """centimeters - a distance measurement in SI centimeters """
- want = 'cmtr'
-
-centimetres = centimeters
-
-class item(aetools.ComponentItem):
- """item - An item of any type """
- want = 'cobj'
-class _Prop_id(aetools.NProperty):
- """id - the unique ID number of this object """
- which = 'ID '
- want = 'long'
-
-items = item
-
-class C_strings(aetools.ComponentItem):
- """C strings - """
- want = 'cstr'
-
-C_string = C_strings
-
-class text(aetools.ComponentItem):
- """text - text with language and style information """
- want = 'ctxt'
-
-class cubic_inches(aetools.ComponentItem):
- """cubic inches - a volume measurement in Imperial cubic inches """
- want = 'cuin'
-
-class cubic_yards(aetools.ComponentItem):
- """cubic yards - a distance measurement in Imperial cubic yards """
- want = 'cyrd'
-
-class December(aetools.ComponentItem):
- """December - the month of December """
- want = 'dec '
-
-class degrees_Celsius(aetools.ComponentItem):
- """degrees Celsius - a temperature measurement in SI degrees Celsius """
- want = 'degc'
-
-class degrees_Fahrenheit(aetools.ComponentItem):
- """degrees Fahrenheit - a temperature measurement in degrees Fahrenheit """
- want = 'degf'
-
-class degrees_Kelvin(aetools.ComponentItem):
- """degrees Kelvin - a temperature measurement in degrees Kelvin """
- want = 'degk'
-
-class reals(aetools.ComponentItem):
- """reals - """
- want = 'doub'
-
-real = reals
-
-class encoded_strings(aetools.ComponentItem):
- """encoded strings - """
- want = 'encs'
-
-encoded_string = encoded_strings
-
-class constants(aetools.ComponentItem):
- """constants - """
- want = 'enum'
-
-constant = constants
-
-class events(aetools.ComponentItem):
- """events - """
- want = 'evnt'
-
-event = events
-
-class February(aetools.ComponentItem):
- """February - the month of February """
- want = 'feb '
-
-class feet(aetools.ComponentItem):
- """feet - a distance measurement in Imperial feet """
- want = 'feet'
-
-class Friday(aetools.ComponentItem):
- """Friday - Friday """
- want = 'fri '
-
-class file_specification(aetools.ComponentItem):
- """file specification - a file specification as used by the operating system """
- want = 'fss '
-
-file_specifications = file_specification
-
-class gallons(aetools.ComponentItem):
- """gallons - a volume measurement in Imperial gallons """
- want = 'galn'
-
-class grams(aetools.ComponentItem):
- """grams - a mass measurement in SI meters """
- want = 'gram'
-
-class handlers(aetools.ComponentItem):
- """handlers - """
- want = 'hand'
-
-handler = handlers
-
-class inches(aetools.ComponentItem):
- """inches - a distance measurement in Imperial inches """
- want = 'inch'
-
-class international_text(aetools.ComponentItem):
- """international text - text that begins with a writing code """
- want = 'itxt'
-
-international_text = international_text
-
-class January(aetools.ComponentItem):
- """January - the month of January """
- want = 'jan '
-
-class July(aetools.ComponentItem):
- """July - the month of July """
- want = 'jul '
-
-class June(aetools.ComponentItem):
- """June - the month of June """
- want = 'jun '
-
-class reference_forms(aetools.ComponentItem):
- """reference forms - """
- want = 'kfrm'
-
-reference_form = reference_forms
-
-class kilograms(aetools.ComponentItem):
- """kilograms - a mass measurement in SI kilograms """
- want = 'kgrm'
-
-class kilometers(aetools.ComponentItem):
- """kilometers - a distance measurement in SI kilometers """
- want = 'kmtr'
-
-kilometres = kilometers
-
-class keystroke(aetools.ComponentItem):
- """keystroke - a press of a key combination on a Macintosh keyboard """
- want = 'kprs'
-class _Prop_key(aetools.NProperty):
- """key - the character for the key was pressed (ignoring modifiers) """
- which = 'kMsg'
- want = 'cha '
-class _Prop_key_kind(aetools.NProperty):
- """key kind - the kind of key that was pressed """
- which = 'kknd'
- want = 'ekst'
-class _Prop_modifiers(aetools.NProperty):
- """modifiers - the modifier keys pressed in combination """
- which = 'kMod'
- want = 'eMds'
-
-keystrokes = keystroke
-
-class pounds(aetools.ComponentItem):
- """pounds - a weight measurement in SI meters """
- want = 'lbs '
-
-class date(aetools.ComponentItem):
- """date - Absolute date and time values """
- want = 'ldt '
-class _Prop_date_string(aetools.NProperty):
- """date string - the date portion of a date-time value as text """
- which = 'dstr'
- want = 'TEXT'
-class _Prop_day(aetools.NProperty):
- """day - the day of the month of a date """
- which = 'day '
- want = 'long'
-class _Prop_month(aetools.NProperty):
- """month - the month of a date """
- which = 'mnth'
- want = 'mnth'
-class _Prop_time(aetools.NProperty):
- """time - the time since midnight of a date """
- which = 'time'
- want = 'long'
-class _Prop_time_string(aetools.NProperty):
- """time string - the time portion of a date-time value as text """
- which = 'tstr'
- want = 'TEXT'
-class _Prop_weekday(aetools.NProperty):
- """weekday - the day of a week of a date """
- which = 'wkdy'
- want = 'wkdy'
-class _Prop_year(aetools.NProperty):
- """year - the year of a date """
- which = 'year'
- want = 'long'
-
-dates = date
-
-class list(aetools.ComponentItem):
- """list - An ordered collection of items """
- want = 'list'
-class _Prop_length(aetools.NProperty):
- """length - the length of a list """
- which = 'leng'
- want = 'long'
-class _Prop_rest(aetools.NProperty):
- """rest - all items of the list excluding first """
- which = 'rest'
- want = 'list'
-class _Prop_reverse(aetools.NProperty):
- """reverse - the items of the list in reverse order """
- which = 'rvse'
- want = 'list'
-
-lists = list
-
-class liters(aetools.ComponentItem):
- """liters - a volume measurement in SI liters """
- want = 'litr'
-
-litres = liters
-
-class linked_list(aetools.ComponentItem):
- """linked list - An ordered collection of items """
- want = 'llst'
-
-linked_lists = linked_list
-
-class integers(aetools.ComponentItem):
- """integers - """
- want = 'long'
-
-integer = integers
-
-class list_or_record(aetools.ComponentItem):
- """list or record - a list or record """
- want = 'lr '
-
-class list_2c__record_or_text(aetools.ComponentItem):
- """list, record or text - a list, record or text """
- want = 'lrs '
-
-class list_or_string(aetools.ComponentItem):
- """list or string - a list or string """
- want = 'ls '
-
-class machines(aetools.ComponentItem):
- """machines - """
- want = 'mach'
-
-machine = machines
-
-class March(aetools.ComponentItem):
- """March - the month of March """
- want = 'mar '
-
-class May(aetools.ComponentItem):
- """May - the month of May """
- want = 'may '
-
-class meters(aetools.ComponentItem):
- """meters - a distance measurement in SI meters """
- want = 'metr'
-
-metres = meters
-
-class miles(aetools.ComponentItem):
- """miles - a distance measurement in Imperial miles """
- want = 'mile'
-
-class months(aetools.ComponentItem):
- """months - """
- want = 'mnth'
-
-month = months
-
-class Monday(aetools.ComponentItem):
- """Monday - Monday """
- want = 'mon '
-
-class missing_values(aetools.ComponentItem):
- """missing values - """
- want = 'msng'
-
-missing_value = missing_values
-
-class number_or_date(aetools.ComponentItem):
- """number or date - a number or date """
- want = 'nd '
-
-class number_2c__date_or_text(aetools.ComponentItem):
- """number, date or text - a number, date or text """
- want = 'nds '
-
-class numbers(aetools.ComponentItem):
- """numbers - """
- want = 'nmbr'
-
-number = numbers
-
-class November(aetools.ComponentItem):
- """November - the month of November """
- want = 'nov '
-
-class number_or_string(aetools.ComponentItem):
- """number or string - a number or string """
- want = 'ns '
-
-class references(aetools.ComponentItem):
- """references - """
- want = 'obj '
-
-reference = references
-
-class October(aetools.ComponentItem):
- """October - the month of October """
- want = 'oct '
-
-class ounces(aetools.ComponentItem):
- """ounces - a weight measurement in SI meters """
- want = 'ozs '
-
-class class_(aetools.ComponentItem):
- """class - the type of a value """
- want = 'pcls'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - inherits some of its properties from this class """
- which = 'c@#^'
- want = 'type'
-
-classes = class_
-
-class prepositions(aetools.ComponentItem):
- """prepositions - """
- want = 'prep'
-
-preposition = prepositions
-
-class properties(aetools.ComponentItem):
- """properties - """
- want = 'prop'
-
-property = properties
-
-class writing_code(aetools.ComponentItem):
- """writing code - codes that identify the language and script system """
- want = 'psct'
-
-class Pascal_strings(aetools.ComponentItem):
- """Pascal strings - """
- want = 'pstr'
-
-Pascal_string = Pascal_strings
-
-class quarts(aetools.ComponentItem):
- """quarts - a volume measurement in Imperial quarts """
- want = 'qrts'
-
-class data(aetools.ComponentItem):
- """data - an AppleScript raw data object """
- want = 'rdat'
-
-class records(aetools.ComponentItem):
- """records - """
- want = 'reco'
-
-record = records
-
-class Saturday(aetools.ComponentItem):
- """Saturday - Saturday """
- want = 'sat '
-
-class seconds(aetools.ComponentItem):
- """seconds - more than one second """
- want = 'scnd'
-
-class script(aetools.ComponentItem):
- """script - An AppleScript script """
- want = 'scpt'
-class _Prop_name(aetools.NProperty):
- """name - the name of the script """
- which = 'pnam'
- want = 'TEXT'
-class _Prop_parent(aetools.NProperty):
- """parent - its parent, i.e. the script that will handle events that this script doesn\xd5t """
- which = 'pare'
- want = 'scpt'
-
-scripts = script
-
-class September(aetools.ComponentItem):
- """September - the month of September """
- want = 'sep '
-
-class alias_or_string(aetools.ComponentItem):
- """alias or string - an alias or string """
- want = 'sf '
-
-class sounds(aetools.ComponentItem):
- """sounds - """
- want = 'snd '
-
-sound = sounds
-
-class square_feet(aetools.ComponentItem):
- """square feet - an area measurement in Imperial square feet """
- want = 'sqft'
-
-class square_kilometers(aetools.ComponentItem):
- """square kilometers - an area measurement in SI square kilometers """
- want = 'sqkm'
-
-square_kilometres = square_kilometers
-
-class square_miles(aetools.ComponentItem):
- """square miles - an area measurement in Imperial square miles """
- want = 'sqmi'
-
-class square_meters(aetools.ComponentItem):
- """square meters - an area measurement in SI square meters """
- want = 'sqrm'
-
-square_metres = square_meters
-
-class square_yards(aetools.ComponentItem):
- """square yards - an area measurement in Imperial square yards """
- want = 'sqyd'
-
-class styled_Clipboard_text(aetools.ComponentItem):
- """styled Clipboard text - clipboard text with font, size, and style information """
- want = 'styl'
-
-styled_Clipboard_text = styled_Clipboard_text
-
-class Sunday(aetools.ComponentItem):
- """Sunday - Sunday """
- want = 'sun '
-
-class styled_Unicode_text(aetools.ComponentItem):
- """styled Unicode text - styled text in the Unicode format """
- want = 'sutx'
-
-styled_Unicode_text = styled_Unicode_text
-
-class Thursday(aetools.ComponentItem):
- """Thursday - Thursday """
- want = 'thu '
-
-class Tuesday(aetools.ComponentItem):
- """Tuesday - Tuesday """
- want = 'tue '
-
-class type_class(aetools.ComponentItem):
- """type class - the name of a particular class (or any four-character code) """
- want = 'type'
-
-class empty_ae_name_(aetools.ComponentItem):
- """ - the undefined value """
- want = 'undf'
-
-class Unicode_text(aetools.ComponentItem):
- """Unicode text - text in the Unicode format (cannot be viewed without conversion) """
- want = 'utxt'
-
-Unicode_text = Unicode_text
-
-class vector(aetools.ComponentItem):
- """vector - An ordered collection of items """
- want = 'vect'
-
-vectors = vector
-
-class version(aetools.ComponentItem):
- """version - a version value """
- want = 'vers'
-
-class Wednesday(aetools.ComponentItem):
- """Wednesday - Wednesday """
- want = 'wed '
-
-class weekdays(aetools.ComponentItem):
- """weekdays - """
- want = 'wkdy'
-
-weekday = weekdays
-
-class yards(aetools.ComponentItem):
- """yards - a distance measurement in Imperial yards """
- want = 'yard'
-
-class zones(aetools.ComponentItem):
- """zones - """
- want = 'zone'
-
-zone = zones
-anything._superclassnames = []
-anything._privpropdict = {
-}
-anything._privelemdict = {
-}
-pictures._superclassnames = []
-pictures._privpropdict = {
-}
-pictures._privelemdict = {
-}
-styled_text._superclassnames = []
-styled_text._privpropdict = {
-}
-styled_text._privelemdict = {
-}
-styled_text._superclassnames = []
-styled_text._privpropdict = {
-}
-styled_text._privelemdict = {
-}
-strings._superclassnames = []
-strings._privpropdict = {
-}
-strings._privelemdict = {
-}
-alias._superclassnames = []
-alias._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
-}
-alias._privelemdict = {
-}
-April._superclassnames = []
-April._privpropdict = {
-}
-April._privelemdict = {
-}
-August._superclassnames = []
-August._privpropdict = {
-}
-August._privelemdict = {
-}
-booleans._superclassnames = []
-booleans._privpropdict = {
-}
-booleans._privelemdict = {
-}
-RGB_colors._superclassnames = []
-RGB_colors._privpropdict = {
-}
-RGB_colors._privelemdict = {
-}
-application._superclassnames = []
-application._privpropdict = {
- 'AppleScript' : _Prop_AppleScript,
- 'days' : _Prop_days,
- 'hours' : _Prop_hours,
- 'minutes' : _Prop_minutes,
- 'pi' : _Prop_pi,
- 'print_depth' : _Prop_print_depth,
- 'print_length' : _Prop_print_length,
- 'result' : _Prop_result,
- 'return_' : _Prop_return_,
- 'space' : _Prop_space,
- 'tab' : _Prop_tab,
- 'text_item_delimiters' : _Prop_text_item_delimiters,
- 'weeks' : _Prop_weeks,
-}
-application._privelemdict = {
-}
-upper_case._superclassnames = []
-upper_case._privpropdict = {
-}
-upper_case._privelemdict = {
-}
-cubic_centimeters._superclassnames = []
-cubic_centimeters._privpropdict = {
-}
-cubic_centimeters._privelemdict = {
-}
-cubic_feet._superclassnames = []
-cubic_feet._privpropdict = {
-}
-cubic_feet._privelemdict = {
-}
-characters._superclassnames = []
-characters._privpropdict = {
-}
-characters._privelemdict = {
-}
-writing_code_info._superclassnames = []
-writing_code_info._privpropdict = {
- 'language_code' : _Prop_language_code,
- 'script_code' : _Prop_script_code,
-}
-writing_code_info._privelemdict = {
-}
-text_items._superclassnames = []
-text_items._privpropdict = {
-}
-text_items._privelemdict = {
-}
-cubic_meters._superclassnames = []
-cubic_meters._privpropdict = {
-}
-cubic_meters._privelemdict = {
-}
-centimeters._superclassnames = []
-centimeters._privpropdict = {
-}
-centimeters._privelemdict = {
-}
-item._superclassnames = []
-item._privpropdict = {
- 'id' : _Prop_id,
-}
-item._privelemdict = {
-}
-C_strings._superclassnames = []
-C_strings._privpropdict = {
-}
-C_strings._privelemdict = {
-}
-text._superclassnames = []
-text._privpropdict = {
-}
-text._privelemdict = {
-}
-cubic_inches._superclassnames = []
-cubic_inches._privpropdict = {
-}
-cubic_inches._privelemdict = {
-}
-cubic_yards._superclassnames = []
-cubic_yards._privpropdict = {
-}
-cubic_yards._privelemdict = {
-}
-December._superclassnames = []
-December._privpropdict = {
-}
-December._privelemdict = {
-}
-degrees_Celsius._superclassnames = []
-degrees_Celsius._privpropdict = {
-}
-degrees_Celsius._privelemdict = {
-}
-degrees_Fahrenheit._superclassnames = []
-degrees_Fahrenheit._privpropdict = {
-}
-degrees_Fahrenheit._privelemdict = {
-}
-degrees_Kelvin._superclassnames = []
-degrees_Kelvin._privpropdict = {
-}
-degrees_Kelvin._privelemdict = {
-}
-reals._superclassnames = []
-reals._privpropdict = {
-}
-reals._privelemdict = {
-}
-encoded_strings._superclassnames = []
-encoded_strings._privpropdict = {
-}
-encoded_strings._privelemdict = {
-}
-constants._superclassnames = []
-constants._privpropdict = {
-}
-constants._privelemdict = {
-}
-events._superclassnames = []
-events._privpropdict = {
-}
-events._privelemdict = {
-}
-February._superclassnames = []
-February._privpropdict = {
-}
-February._privelemdict = {
-}
-feet._superclassnames = []
-feet._privpropdict = {
-}
-feet._privelemdict = {
-}
-Friday._superclassnames = []
-Friday._privpropdict = {
-}
-Friday._privelemdict = {
-}
-file_specification._superclassnames = []
-file_specification._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
-}
-file_specification._privelemdict = {
-}
-gallons._superclassnames = []
-gallons._privpropdict = {
-}
-gallons._privelemdict = {
-}
-grams._superclassnames = []
-grams._privpropdict = {
-}
-grams._privelemdict = {
-}
-handlers._superclassnames = []
-handlers._privpropdict = {
-}
-handlers._privelemdict = {
-}
-inches._superclassnames = []
-inches._privpropdict = {
-}
-inches._privelemdict = {
-}
-international_text._superclassnames = []
-international_text._privpropdict = {
-}
-international_text._privelemdict = {
-}
-international_text._superclassnames = []
-international_text._privpropdict = {
-}
-international_text._privelemdict = {
-}
-January._superclassnames = []
-January._privpropdict = {
-}
-January._privelemdict = {
-}
-July._superclassnames = []
-July._privpropdict = {
-}
-July._privelemdict = {
-}
-June._superclassnames = []
-June._privpropdict = {
-}
-June._privelemdict = {
-}
-reference_forms._superclassnames = []
-reference_forms._privpropdict = {
-}
-reference_forms._privelemdict = {
-}
-kilograms._superclassnames = []
-kilograms._privpropdict = {
-}
-kilograms._privelemdict = {
-}
-kilometers._superclassnames = []
-kilometers._privpropdict = {
-}
-kilometers._privelemdict = {
-}
-keystroke._superclassnames = []
-keystroke._privpropdict = {
- 'key' : _Prop_key,
- 'key_kind' : _Prop_key_kind,
- 'modifiers' : _Prop_modifiers,
-}
-keystroke._privelemdict = {
-}
-pounds._superclassnames = []
-pounds._privpropdict = {
-}
-pounds._privelemdict = {
-}
-date._superclassnames = []
-date._privpropdict = {
- 'date_string' : _Prop_date_string,
- 'day' : _Prop_day,
- 'month' : _Prop_month,
- 'time' : _Prop_time,
- 'time_string' : _Prop_time_string,
- 'weekday' : _Prop_weekday,
- 'year' : _Prop_year,
-}
-date._privelemdict = {
-}
-list._superclassnames = []
-list._privpropdict = {
- 'length' : _Prop_length,
- 'rest' : _Prop_rest,
- 'reverse' : _Prop_reverse,
-}
-list._privelemdict = {
-}
-liters._superclassnames = []
-liters._privpropdict = {
-}
-liters._privelemdict = {
-}
-linked_list._superclassnames = []
-linked_list._privpropdict = {
- 'length' : _Prop_length,
-}
-linked_list._privelemdict = {
-}
-integers._superclassnames = []
-integers._privpropdict = {
-}
-integers._privelemdict = {
-}
-list_or_record._superclassnames = []
-list_or_record._privpropdict = {
-}
-list_or_record._privelemdict = {
-}
-list_2c__record_or_text._superclassnames = []
-list_2c__record_or_text._privpropdict = {
-}
-list_2c__record_or_text._privelemdict = {
-}
-list_or_string._superclassnames = []
-list_or_string._privpropdict = {
-}
-list_or_string._privelemdict = {
-}
-machines._superclassnames = []
-machines._privpropdict = {
-}
-machines._privelemdict = {
-}
-March._superclassnames = []
-March._privpropdict = {
-}
-March._privelemdict = {
-}
-May._superclassnames = []
-May._privpropdict = {
-}
-May._privelemdict = {
-}
-meters._superclassnames = []
-meters._privpropdict = {
-}
-meters._privelemdict = {
-}
-miles._superclassnames = []
-miles._privpropdict = {
-}
-miles._privelemdict = {
-}
-months._superclassnames = []
-months._privpropdict = {
-}
-months._privelemdict = {
-}
-Monday._superclassnames = []
-Monday._privpropdict = {
-}
-Monday._privelemdict = {
-}
-missing_values._superclassnames = []
-missing_values._privpropdict = {
-}
-missing_values._privelemdict = {
-}
-number_or_date._superclassnames = []
-number_or_date._privpropdict = {
-}
-number_or_date._privelemdict = {
-}
-number_2c__date_or_text._superclassnames = []
-number_2c__date_or_text._privpropdict = {
-}
-number_2c__date_or_text._privelemdict = {
-}
-numbers._superclassnames = []
-numbers._privpropdict = {
-}
-numbers._privelemdict = {
-}
-November._superclassnames = []
-November._privpropdict = {
-}
-November._privelemdict = {
-}
-number_or_string._superclassnames = []
-number_or_string._privpropdict = {
-}
-number_or_string._privelemdict = {
-}
-references._superclassnames = []
-references._privpropdict = {
-}
-references._privelemdict = {
-}
-October._superclassnames = []
-October._privpropdict = {
-}
-October._privelemdict = {
-}
-ounces._superclassnames = []
-ounces._privpropdict = {
-}
-ounces._privelemdict = {
-}
-class_._superclassnames = ['type_class']
-class_._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-class_._privelemdict = {
-}
-prepositions._superclassnames = []
-prepositions._privpropdict = {
-}
-prepositions._privelemdict = {
-}
-properties._superclassnames = []
-properties._privpropdict = {
-}
-properties._privelemdict = {
-}
-writing_code._superclassnames = []
-writing_code._privpropdict = {
-}
-writing_code._privelemdict = {
-}
-Pascal_strings._superclassnames = []
-Pascal_strings._privpropdict = {
-}
-Pascal_strings._privelemdict = {
-}
-quarts._superclassnames = []
-quarts._privpropdict = {
-}
-quarts._privelemdict = {
-}
-data._superclassnames = []
-data._privpropdict = {
-}
-data._privelemdict = {
-}
-records._superclassnames = []
-records._privpropdict = {
-}
-records._privelemdict = {
-}
-Saturday._superclassnames = []
-Saturday._privpropdict = {
-}
-Saturday._privelemdict = {
-}
-seconds._superclassnames = []
-seconds._privpropdict = {
-}
-seconds._privelemdict = {
-}
-script._superclassnames = []
-script._privpropdict = {
- 'name' : _Prop_name,
- 'parent' : _Prop_parent,
-}
-script._privelemdict = {
-}
-September._superclassnames = []
-September._privpropdict = {
-}
-September._privelemdict = {
-}
-alias_or_string._superclassnames = []
-alias_or_string._privpropdict = {
-}
-alias_or_string._privelemdict = {
-}
-sounds._superclassnames = []
-sounds._privpropdict = {
-}
-sounds._privelemdict = {
-}
-square_feet._superclassnames = []
-square_feet._privpropdict = {
-}
-square_feet._privelemdict = {
-}
-square_kilometers._superclassnames = []
-square_kilometers._privpropdict = {
-}
-square_kilometers._privelemdict = {
-}
-square_miles._superclassnames = []
-square_miles._privpropdict = {
-}
-square_miles._privelemdict = {
-}
-square_meters._superclassnames = []
-square_meters._privpropdict = {
-}
-square_meters._privelemdict = {
-}
-square_yards._superclassnames = []
-square_yards._privpropdict = {
-}
-square_yards._privelemdict = {
-}
-styled_Clipboard_text._superclassnames = []
-styled_Clipboard_text._privpropdict = {
-}
-styled_Clipboard_text._privelemdict = {
-}
-styled_Clipboard_text._superclassnames = []
-styled_Clipboard_text._privpropdict = {
-}
-styled_Clipboard_text._privelemdict = {
-}
-Sunday._superclassnames = []
-Sunday._privpropdict = {
-}
-Sunday._privelemdict = {
-}
-styled_Unicode_text._superclassnames = []
-styled_Unicode_text._privpropdict = {
-}
-styled_Unicode_text._privelemdict = {
-}
-styled_Unicode_text._superclassnames = []
-styled_Unicode_text._privpropdict = {
-}
-styled_Unicode_text._privelemdict = {
-}
-Thursday._superclassnames = []
-Thursday._privpropdict = {
-}
-Thursday._privelemdict = {
-}
-Tuesday._superclassnames = []
-Tuesday._privpropdict = {
-}
-Tuesday._privelemdict = {
-}
-type_class._superclassnames = []
-type_class._privpropdict = {
-}
-type_class._privelemdict = {
-}
-empty_ae_name_._superclassnames = []
-empty_ae_name_._privpropdict = {
-}
-empty_ae_name_._privelemdict = {
-}
-Unicode_text._superclassnames = []
-Unicode_text._privpropdict = {
-}
-Unicode_text._privelemdict = {
-}
-Unicode_text._superclassnames = []
-Unicode_text._privpropdict = {
-}
-Unicode_text._privelemdict = {
-}
-vector._superclassnames = []
-vector._privpropdict = {
- 'length' : _Prop_length,
-}
-vector._privelemdict = {
-}
-version._superclassnames = []
-version._privpropdict = {
-}
-version._privelemdict = {
-}
-Wednesday._superclassnames = []
-Wednesday._privpropdict = {
-}
-Wednesday._privelemdict = {
-}
-weekdays._superclassnames = []
-weekdays._privpropdict = {
-}
-weekdays._privelemdict = {
-}
-yards._superclassnames = []
-yards._privpropdict = {
-}
-yards._privelemdict = {
-}
-zones._superclassnames = []
-zones._privpropdict = {
-}
-zones._privelemdict = {
-}
-_Enum_boov = {
- 'true' : 'true', # the true boolean value
- 'false' : 'fals', # the false boolean value
-}
-
-_Enum_cons = {
- 'case' : 'case', # case
- 'diacriticals' : 'diac', # diacriticals
- 'white_space' : 'whit', # white space
- 'hyphens' : 'hyph', # hyphens
- 'expansion' : 'expa', # expansion
- 'punctuation' : 'punc', # punctuation
- 'application_responses' : 'rmte', # remote event replies
-}
-
-_Enum_eMds = {
- 'option_down' : 'Kopt', #
- 'command_down' : 'Kcmd', #
- 'control_down' : 'Kctl', #
- 'shift_down' : 'Ksft', #
- 'caps_lock_down' : 'Kclk', #
-}
-
-_Enum_ekst = {
- 'escape_key' : 'ks5\x00', #
- 'delete_key' : 'ks3\x00', #
- 'tab_key' : 'ks0\x00', #
- 'return_key' : 'ks$\x00', #
- 'clear_key' : 'ksG\x00', #
- 'enter_key' : 'ksL\x00', #
- 'up_arrow_key' : 'ks~\x00', #
- 'down_arrow_key' : 'ks}\x00', #
- 'left_arrow_key' : 'ks{\x00', #
- 'right_arrow_key' : 'ks|\x00', #
- 'help_key' : 'ksr\x00', #
- 'home_key' : 'kss\x00', #
- 'page_up_key' : 'kst\x00', #
- 'page_down_key' : 'ksy\x00', #
- 'forward_del_key' : 'ksu\x00', #
- 'end_key' : 'ksw\x00', #
- 'F1_key' : 'ksz\x00', #
- 'F2_key' : 'ksx\x00', #
- 'F3_key' : 'ksc\x00', #
- 'F4_key' : 'ksv\x00', #
- 'F5_key' : 'ks`\x00', #
- 'F6_key' : 'ksa\x00', #
- 'F7_key' : 'ksb\x00', #
- 'F8_key' : 'ksd\x00', #
- 'F9_key' : 'kse\x00', #
- 'F10_key' : 'ksm\x00', #
- 'F11_key' : 'ksg\x00', #
- 'F12_key' : 'kso\x00', #
- 'F13_key' : 'ksi\x00', #
- 'F14_key' : 'ksk\x00', #
- 'F15_key' : 'ksq\x00', #
-}
-
-_Enum_misc = {
- 'current_application' : 'cura', # the current application
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- '****' : anything,
- 'PICT' : pictures,
- 'STXT' : styled_text,
- 'TEXT' : strings,
- 'alis' : alias,
- 'apr ' : April,
- 'aug ' : August,
- 'bool' : booleans,
- 'cRGB' : RGB_colors,
- 'capp' : application,
- 'case' : upper_case,
- 'ccmt' : cubic_centimeters,
- 'cfet' : cubic_feet,
- 'cha ' : characters,
- 'citl' : writing_code_info,
- 'citm' : text_items,
- 'cmet' : cubic_meters,
- 'cmtr' : centimeters,
- 'cobj' : item,
- 'cstr' : C_strings,
- 'ctxt' : text,
- 'cuin' : cubic_inches,
- 'cyrd' : cubic_yards,
- 'dec ' : December,
- 'degc' : degrees_Celsius,
- 'degf' : degrees_Fahrenheit,
- 'degk' : degrees_Kelvin,
- 'doub' : reals,
- 'encs' : encoded_strings,
- 'enum' : constants,
- 'evnt' : events,
- 'feb ' : February,
- 'feet' : feet,
- 'fri ' : Friday,
- 'fss ' : file_specification,
- 'galn' : gallons,
- 'gram' : grams,
- 'hand' : handlers,
- 'inch' : inches,
- 'itxt' : international_text,
- 'jan ' : January,
- 'jul ' : July,
- 'jun ' : June,
- 'kfrm' : reference_forms,
- 'kgrm' : kilograms,
- 'kmtr' : kilometers,
- 'kprs' : keystroke,
- 'lbs ' : pounds,
- 'ldt ' : date,
- 'list' : list,
- 'litr' : liters,
- 'llst' : linked_list,
- 'long' : integers,
- 'lr ' : list_or_record,
- 'lrs ' : list_2c__record_or_text,
- 'ls ' : list_or_string,
- 'mach' : machines,
- 'mar ' : March,
- 'may ' : May,
- 'metr' : meters,
- 'mile' : miles,
- 'mnth' : months,
- 'mon ' : Monday,
- 'msng' : missing_values,
- 'nd ' : number_or_date,
- 'nds ' : number_2c__date_or_text,
- 'nmbr' : numbers,
- 'nov ' : November,
- 'ns ' : number_or_string,
- 'obj ' : references,
- 'oct ' : October,
- 'ozs ' : ounces,
- 'pcls' : class_,
- 'prep' : prepositions,
- 'prop' : properties,
- 'psct' : writing_code,
- 'pstr' : Pascal_strings,
- 'qrts' : quarts,
- 'rdat' : data,
- 'reco' : records,
- 'sat ' : Saturday,
- 'scnd' : seconds,
- 'scpt' : script,
- 'sep ' : September,
- 'sf ' : alias_or_string,
- 'snd ' : sounds,
- 'sqft' : square_feet,
- 'sqkm' : square_kilometers,
- 'sqmi' : square_miles,
- 'sqrm' : square_meters,
- 'sqyd' : square_yards,
- 'styl' : styled_Clipboard_text,
- 'sun ' : Sunday,
- 'sutx' : styled_Unicode_text,
- 'thu ' : Thursday,
- 'tue ' : Tuesday,
- 'type' : type_class,
- 'undf' : empty_ae_name_,
- 'utxt' : Unicode_text,
- 'vect' : vector,
- 'vers' : version,
- 'wed ' : Wednesday,
- 'wkdy' : weekdays,
- 'yard' : yards,
- 'zone' : zones,
-}
-
-_propdeclarations = {
- 'ID ' : _Prop_id,
- 'ascr' : _Prop_AppleScript,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'day ' : _Prop_day,
- 'days' : _Prop_days,
- 'dstr' : _Prop_date_string,
- 'hour' : _Prop_hours,
- 'kMod' : _Prop_modifiers,
- 'kMsg' : _Prop_key,
- 'kknd' : _Prop_key_kind,
- 'leng' : _Prop_length,
- 'min ' : _Prop_minutes,
- 'mnth' : _Prop_month,
- 'pare' : _Prop_parent,
- 'pi ' : _Prop_pi,
- 'plcd' : _Prop_language_code,
- 'pnam' : _Prop_name,
- 'prdp' : _Prop_print_depth,
- 'prln' : _Prop_print_length,
- 'pscd' : _Prop_script_code,
- 'psxp' : _Prop_POSIX_path,
- 'rest' : _Prop_rest,
- 'ret ' : _Prop_return_,
- 'rslt' : _Prop_result,
- 'rvse' : _Prop_reverse,
- 'spac' : _Prop_space,
- 'tab ' : _Prop_tab,
- 'time' : _Prop_time,
- 'tstr' : _Prop_time_string,
- 'txdl' : _Prop_text_item_delimiters,
- 'week' : _Prop_weeks,
- 'wkdy' : _Prop_weekday,
- 'year' : _Prop_year,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'boov' : _Enum_boov,
- 'cons' : _Enum_cons,
- 'eMds' : _Enum_eMds,
- 'ekst' : _Enum_ekst,
- 'misc' : _Enum_misc,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Macintosh_Connectivity_Clas.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Macintosh_Connectivity_Clas.py
deleted file mode 100644
index 99fe5e348a2..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Macintosh_Connectivity_Clas.py
+++ /dev/null
@@ -1,373 +0,0 @@
-"""Suite Macintosh Connectivity Classes: Classes relating to Apple Macintosh personal computer connectivity
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'macc'
-
-class Macintosh_Connectivity_Clas_Events:
-
- pass
-
-
-class ADB_address(aetools.ComponentItem):
- """ADB address - Addresses a device connected via Apple Desktop Bus """
- want = 'cadb'
-class _Prop__3c_inheritance_3e_(aetools.NProperty):
- """<inheritance> - inherits some of its properties from this class """
- which = 'c@#^'
- want = 'cadr'
-class _Prop_ID(aetools.NProperty):
- """ID - the Apple Desktop Bus device ID """
- which = 'ID '
- want = 'shor'
-
-ADB_addresses = ADB_address
-
-class address_specification(aetools.ComponentItem):
- """address specification - Unique designation of a device or service connected to this computer """
- want = 'cadr'
-class _Prop_conduit(aetools.NProperty):
- """conduit - How the addressee is physically connected """
- which = 'pcon'
- want = 'econ'
-class _Prop_properties(aetools.NProperty):
- """properties - property that allows getting and setting of multiple properties """
- which = 'pALL'
- want = 'reco'
-class _Prop_protocol(aetools.NProperty):
- """protocol - How to talk to this addressee """
- which = 'pprt'
- want = 'epro'
-
-address_specifications = address_specification
-
-class AppleTalk_address(aetools.ComponentItem):
- """AppleTalk address - Addresses a device or service connected via the AppleTalk protocol """
- want = 'cat '
-class _Prop_AppleTalk_machine(aetools.NProperty):
- """AppleTalk machine - the machine name part of the address """
- which = 'patm'
- want = 'TEXT'
-class _Prop_AppleTalk_type(aetools.NProperty):
- """AppleTalk type - the type part of the AppleTalk address """
- which = 'patt'
- want = 'TEXT'
-class _Prop_AppleTalk_zone(aetools.NProperty):
- """AppleTalk zone - the zone part of the address """
- which = 'patz'
- want = 'TEXT'
-
-AppleTalk_addresses = AppleTalk_address
-
-class bus_slot(aetools.ComponentItem):
- """bus slot - Addresses a PC, PCI, or NuBus card """
- want = 'cbus'
-
-bus_slots = bus_slot
-
-class device_specification(aetools.ComponentItem):
- """device specification - A device connected to a computer """
- want = 'cdev'
-class _Prop_device_address(aetools.NProperty):
- """device address - the address of the device """
- which = 'pdva'
- want = 'cadr'
-class _Prop_device_type(aetools.NProperty):
- """device type - the kind of device """
- which = 'pdvt'
- want = 'edvt'
-
-device_specifications = device_specification
-
-class Ethernet_address(aetools.ComponentItem):
- """Ethernet address - Addresses a device by its Ethernet address """
- want = 'cen '
-
-Ethernet_addresses = Ethernet_address
-
-class FireWire_address(aetools.ComponentItem):
- """FireWire address - Addresses a device on the FireWire bus """
- want = 'cfw '
-
-FireWire_addresses = FireWire_address
-
-class IP_address(aetools.ComponentItem):
- """IP address - Addresses a device or service via the Internet Protocol (IP) """
- want = 'cip '
-class _Prop_DNS_form(aetools.NProperty):
- """DNS form - the address in the form "apple.com" """
- which = 'pdns'
- want = 'TEXT'
-class _Prop_port(aetools.NProperty):
- """port - the port number of the service or client being addressed """
- which = 'ppor'
- want = 'TEXT'
-
-IP_addresses = IP_address
-
-class LocalTalk_address(aetools.ComponentItem):
- """LocalTalk address - Addresses a device by its LocalTalk address """
- want = 'clt '
-class _Prop_network(aetools.NProperty):
- """network - the LocalTalk network number """
- which = 'pnet'
- want = 'shor'
-class _Prop_node(aetools.NProperty):
- """node - the LocalTalk node number """
- which = 'pnod'
- want = 'shor'
-class _Prop_socket(aetools.NProperty):
- """socket - the LocalTalk socket number """
- which = 'psoc'
- want = 'shor'
-
-LocalTalk_addresses = LocalTalk_address
-
-class SCSI_address(aetools.ComponentItem):
- """SCSI address - Addresses a SCSI device """
- want = 'cscs'
-class _Prop_LUN(aetools.NProperty):
- """LUN - the SCSI logical unit number """
- which = 'pslu'
- want = 'shor'
-class _Prop_SCSI_bus(aetools.NProperty):
- """SCSI bus - the SCSI bus number """
- which = 'pscb'
- want = 'shor'
-
-SCSI_addresses = SCSI_address
-
-class Token_Ring_address(aetools.ComponentItem):
- """Token Ring address - Addresses a device or service via the Token Ring protocol """
- want = 'ctok'
-
-Token_Ring_addresses = Token_Ring_address
-
-class USB_address(aetools.ComponentItem):
- """USB address - Addresses a device on the Universal Serial Bus """
- want = 'cusb'
-class _Prop_name(aetools.NProperty):
- """name - the USB device name """
- which = 'pnam'
- want = 'TEXT'
-
-USB_Addresses = USB_address
-ADB_address._superclassnames = ['address_specification']
-ADB_address._privpropdict = {
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-ADB_address._privelemdict = {
-}
-address_specification._superclassnames = []
-address_specification._privpropdict = {
- 'conduit' : _Prop_conduit,
- 'properties' : _Prop_properties,
- 'protocol' : _Prop_protocol,
-}
-address_specification._privelemdict = {
-}
-AppleTalk_address._superclassnames = ['address_specification']
-AppleTalk_address._privpropdict = {
- 'AppleTalk_machine' : _Prop_AppleTalk_machine,
- 'AppleTalk_type' : _Prop_AppleTalk_type,
- 'AppleTalk_zone' : _Prop_AppleTalk_zone,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-AppleTalk_address._privelemdict = {
-}
-bus_slot._superclassnames = ['address_specification']
-bus_slot._privpropdict = {
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-bus_slot._privelemdict = {
-}
-device_specification._superclassnames = []
-device_specification._privpropdict = {
- 'device_address' : _Prop_device_address,
- 'device_type' : _Prop_device_type,
- 'properties' : _Prop_properties,
-}
-device_specification._privelemdict = {
-}
-Ethernet_address._superclassnames = ['address_specification']
-Ethernet_address._privpropdict = {
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-Ethernet_address._privelemdict = {
-}
-FireWire_address._superclassnames = ['address_specification']
-FireWire_address._privpropdict = {
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-FireWire_address._privelemdict = {
-}
-IP_address._superclassnames = ['address_specification']
-IP_address._privpropdict = {
- 'DNS_form' : _Prop_DNS_form,
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
- 'port' : _Prop_port,
-}
-IP_address._privelemdict = {
-}
-LocalTalk_address._superclassnames = ['address_specification']
-LocalTalk_address._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
- 'network' : _Prop_network,
- 'node' : _Prop_node,
- 'socket' : _Prop_socket,
-}
-LocalTalk_address._privelemdict = {
-}
-SCSI_address._superclassnames = ['address_specification']
-SCSI_address._privpropdict = {
- 'ID' : _Prop_ID,
- 'LUN' : _Prop_LUN,
- 'SCSI_bus' : _Prop_SCSI_bus,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-SCSI_address._privelemdict = {
-}
-Token_Ring_address._superclassnames = ['address_specification']
-Token_Ring_address._privpropdict = {
- 'ID' : _Prop_ID,
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-Token_Ring_address._privelemdict = {
-}
-USB_address._superclassnames = ['address_specification']
-USB_address._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
- 'name' : _Prop_name,
-}
-USB_address._privelemdict = {
-}
-_Enum_econ = {
- 'ADB' : 'eadb', #
- 'printer_port' : 'ecpp', #
- 'modem_port' : 'ecmp', #
- 'modem_printer_port' : 'empp', #
- 'LocalTalk' : 'eclt', #
- 'Ethernet' : 'ecen', #
- 'Token_Ring' : 'etok', #
- 'SCSI' : 'ecsc', #
- 'USB' : 'ecus', #
- 'FireWire' : 'ecfw', #
- 'infrared' : 'ecir', #
- 'PC_card' : 'ecpc', #
- 'PCI_bus' : 'ecpi', #
- 'NuBus' : 'enub', #
- 'PDS_slot' : 'ecpd', #
- 'Comm_slot' : 'eccm', #
- 'monitor_out' : 'ecmn', #
- 'video_out' : 'ecvo', #
- 'video_in' : 'ecvi', #
- 'audio_out' : 'ecao', #
- 'audio_line_in' : 'ecai', #
- 'audio_line_out' : 'ecal', #
- 'microphone' : 'ecmi', #
-}
-
-_Enum_edvt = {
- 'hard_disk_drive' : 'ehd ', #
- 'floppy_disk_drive' : 'efd ', #
- 'CD_ROM_drive' : 'ecd ', #
- 'DVD_drive' : 'edvd', #
- 'storage_device' : 'edst', #
- 'keyboard' : 'ekbd', #
- 'mouse' : 'emou', #
- 'trackball' : 'etrk', #
- 'trackpad' : 'edtp', #
- 'pointing_device' : 'edpd', #
- 'video_monitor' : 'edvm', #
- 'LCD_display' : 'edlc', #
- 'display' : 'edds', #
- 'modem' : 'edmm', #
- 'PC_card' : 'ecpc', #
- 'PCI_card' : 'edpi', #
- 'NuBus_card' : 'ednb', #
- 'printer' : 'edpr', #
- 'speakers' : 'edsp', #
- 'microphone' : 'ecmi', #
-}
-
-_Enum_epro = {
- 'serial' : 'epsr', #
- 'AppleTalk' : 'epat', #
- 'IP' : 'epip', #
- 'SCSI' : 'ecsc', #
- 'ADB' : 'eadb', #
- 'FireWire' : 'ecfw', #
- 'IrDA' : 'epir', #
- 'IRTalk' : 'epit', #
- 'USB' : 'ecus', #
- 'PC_card' : 'ecpc', #
- 'PCI_bus' : 'ecpi', #
- 'NuBus' : 'enub', #
- 'bus' : 'ebus', #
- 'Macintosh_video' : 'epmv', #
- 'SVGA' : 'epsg', #
- 'S_video' : 'epsv', #
- 'analog_audio' : 'epau', #
- 'digital_audio' : 'epda', #
- 'PostScript' : 'epps', #
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cadb' : ADB_address,
- 'cadr' : address_specification,
- 'cat ' : AppleTalk_address,
- 'cbus' : bus_slot,
- 'cdev' : device_specification,
- 'cen ' : Ethernet_address,
- 'cfw ' : FireWire_address,
- 'cip ' : IP_address,
- 'clt ' : LocalTalk_address,
- 'cscs' : SCSI_address,
- 'ctok' : Token_Ring_address,
- 'cusb' : USB_address,
-}
-
-_propdeclarations = {
- 'ID ' : _Prop_ID,
- 'c@#^' : _Prop__3c_inheritance_3e_,
- 'pALL' : _Prop_properties,
- 'patm' : _Prop_AppleTalk_machine,
- 'patt' : _Prop_AppleTalk_type,
- 'patz' : _Prop_AppleTalk_zone,
- 'pcon' : _Prop_conduit,
- 'pdns' : _Prop_DNS_form,
- 'pdva' : _Prop_device_address,
- 'pdvt' : _Prop_device_type,
- 'pnam' : _Prop_name,
- 'pnet' : _Prop_network,
- 'pnod' : _Prop_node,
- 'ppor' : _Prop_port,
- 'pprt' : _Prop_protocol,
- 'pscb' : _Prop_SCSI_bus,
- 'pslu' : _Prop_LUN,
- 'psoc' : _Prop_socket,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'econ' : _Enum_econ,
- 'edvt' : _Enum_edvt,
- 'epro' : _Enum_epro,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suite.py
deleted file mode 100644
index 11747f9c3da..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suite.py
+++ /dev/null
@@ -1,417 +0,0 @@
-"""Suite QuickDraw Graphics Suite: A set of basic classes for graphics
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'qdrw'
-
-class QuickDraw_Graphics_Suite_Events:
-
- pass
-
-
-class arc(aetools.ComponentItem):
- """arc - An arc """
- want = 'carc'
-class _Prop_arc_angle(aetools.NProperty):
- """arc angle - the angle of the arc in degrees """
- which = 'parc'
- want = 'fixd'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the smallest rectangle that contains the entire arc """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_definition_rect(aetools.NProperty):
- """definition rect - the rectangle that contains the circle or oval used to define the arc """
- which = 'pdrt'
- want = 'qdrt'
-class _Prop_fill_color(aetools.NProperty):
- """fill color - the fill color """
- which = 'flcl'
- want = 'cRGB'
-class _Prop_fill_pattern(aetools.NProperty):
- """fill pattern - the fill pattern """
- which = 'flpt'
- want = 'cpix'
-class _Prop_pen_color(aetools.NProperty):
- """pen color - the pen color """
- which = 'ppcl'
- want = 'cRGB'
-class _Prop_pen_pattern(aetools.NProperty):
- """pen pattern - the pen pattern """
- which = 'pppa'
- want = 'cpix'
-class _Prop_pen_width(aetools.NProperty):
- """pen width - the pen width """
- which = 'ppwd'
- want = 'shor'
-class _Prop_start_angle(aetools.NProperty):
- """start angle - the angle that defines the start of the arc, in degrees """
- which = 'pang'
- want = 'fixd'
-class _Prop_transfer_mode(aetools.NProperty):
- """transfer mode - the transfer mode """
- which = 'pptm'
- want = 'tran'
-
-arcs = arc
-
-class drawing_area(aetools.ComponentItem):
- """drawing area - Container for graphics and supporting information """
- want = 'cdrw'
-class _Prop_background_color(aetools.NProperty):
- """background color - the color used to fill in unoccupied areas """
- which = 'pbcl'
- want = 'cRGB'
-class _Prop_background_pattern(aetools.NProperty):
- """background pattern - the pattern used to fill in unoccupied areas """
- which = 'pbpt'
- want = 'cpix'
-class _Prop_color_table(aetools.NProperty):
- """color table - the color table """
- which = 'cltb'
- want = 'clrt'
-class _Prop_default_font(aetools.NProperty):
- """default font - the name of the default font for text objects """
- which = 'ptxf'
- want = 'itxt'
-class _Prop_default_location(aetools.NProperty):
- """default location - the default location of each new graphic object """
- which = 'pnel'
- want = 'QDpt'
-class _Prop_default_size(aetools.NProperty):
- """default size - the default size for text objects """
- which = 'ptps'
- want = 'fixd'
-class _Prop_name(aetools.NProperty):
- """name - the name """
- which = 'pnam'
- want = 'itxt'
-class _Prop_ordering(aetools.NProperty):
- """ordering - the ordered list of graphic objects in the drawing area """
- which = 'gobs'
- want = 'obj '
-class _Prop_pixel_depth(aetools.NProperty):
- """pixel depth - the number of bits per pixel """
- which = 'pdpt'
- want = 'shor'
-class _Prop_style(aetools.NProperty):
- """style - the default text style for text objects """
- which = 'txst'
- want = 'tsty'
-class _Prop_text_color(aetools.NProperty):
- """text color - the default color for text objects """
- which = 'ptxc'
- want = 'cRGB'
-class _Prop_update_on_change(aetools.NProperty):
- """update on change - Redraw after each change? """
- which = 'pupd'
- want = 'bool'
-class _Prop_writing_code(aetools.NProperty):
- """writing code - the script system and language of text objects in the drawing area """
- which = 'psct'
- want = 'intl'
-
-drawing_areas = drawing_area
-
-class graphic_objects(aetools.ComponentItem):
- """graphic objects - """
- want = 'cgob'
-
-graphic_object = graphic_objects
-
-class graphic_shapes(aetools.ComponentItem):
- """graphic shapes - """
- want = 'cgsh'
-
-graphic_shape = graphic_shapes
-
-class graphic_text(aetools.ComponentItem):
- """graphic text - A series of characters within a drawing area """
- want = 'cgtx'
-class _Prop_color(aetools.NProperty):
- """color - the color of the first character """
- which = 'colr'
- want = 'cRGB'
-class _Prop_font(aetools.NProperty):
- """font - the name of the font of the first character """
- which = 'font'
- want = 'ctxt'
-class _Prop_size(aetools.NProperty):
- """size - the size in points of the first character """
- which = 'ptsz'
- want = 'fixd'
-class _Prop_uniform_styles(aetools.NProperty):
- """uniform styles - the text styles that are uniform throughout the text """
- which = 'ustl'
- want = 'tsty'
-
-class ovals(aetools.ComponentItem):
- """ovals - """
- want = 'covl'
-
-oval = ovals
-
-class polygon(aetools.ComponentItem):
- """polygon - A polygon """
- want = 'cpgn'
-class _Prop_point_list(aetools.NProperty):
- """point list - the list of points that define the polygon """
- which = 'ptlt'
- want = 'QDpt'
-
-polygons = polygon
-
-class graphic_groups(aetools.ComponentItem):
- """graphic groups - """
- want = 'cpic'
-
-graphic_group = graphic_groups
-
-class pixel_maps(aetools.ComponentItem):
- """pixel maps - """
- want = 'cpix'
-
-pixel_map = pixel_maps
-
-class pixel(aetools.ComponentItem):
- """pixel - A pixel """
- want = 'cpxl'
-
-pixels = pixel
-
-class rectangles(aetools.ComponentItem):
- """rectangles - """
- want = 'crec'
-
-rectangle = rectangles
-
-class rounded_rectangle(aetools.ComponentItem):
- """rounded rectangle - A rounded rectangle """
- want = 'crrc'
-class _Prop_corner_curve_height(aetools.NProperty):
- """corner curve height - the height of the oval used to define the shape of the rounded corners """
- which = 'pchd'
- want = 'shor'
-class _Prop_corner_curve_width(aetools.NProperty):
- """corner curve width - the width of the oval used to define the shape of the rounded corners """
- which = 'pcwd'
- want = 'shor'
-
-rounded_rectangles = rounded_rectangle
-
-class graphic_line(aetools.ComponentItem):
- """graphic line - A graphic line """
- want = 'glin'
-class _Prop_arrow_style(aetools.NProperty):
- """arrow style - the arrow style """
- which = 'arro'
- want = 'arro'
-class _Prop_dash_style(aetools.NProperty):
- """dash style - the dash style """
- which = 'pdst'
- want = 'tdas'
-class _Prop_end_point(aetools.NProperty):
- """end point - the ending point of the line """
- which = 'pend'
- want = 'QDpt'
-class _Prop_start_point(aetools.NProperty):
- """start point - the starting point of the line """
- which = 'pstp'
- want = 'QDpt'
-
-graphic_lines = graphic_line
-arc._superclassnames = []
-arc._privpropdict = {
- 'arc_angle' : _Prop_arc_angle,
- 'bounds' : _Prop_bounds,
- 'definition_rect' : _Prop_definition_rect,
- 'fill_color' : _Prop_fill_color,
- 'fill_pattern' : _Prop_fill_pattern,
- 'pen_color' : _Prop_pen_color,
- 'pen_pattern' : _Prop_pen_pattern,
- 'pen_width' : _Prop_pen_width,
- 'start_angle' : _Prop_start_angle,
- 'transfer_mode' : _Prop_transfer_mode,
-}
-arc._privelemdict = {
-}
-drawing_area._superclassnames = []
-drawing_area._privpropdict = {
- 'background_color' : _Prop_background_color,
- 'background_pattern' : _Prop_background_pattern,
- 'color_table' : _Prop_color_table,
- 'default_font' : _Prop_default_font,
- 'default_location' : _Prop_default_location,
- 'default_size' : _Prop_default_size,
- 'name' : _Prop_name,
- 'ordering' : _Prop_ordering,
- 'pixel_depth' : _Prop_pixel_depth,
- 'style' : _Prop_style,
- 'text_color' : _Prop_text_color,
- 'update_on_change' : _Prop_update_on_change,
- 'writing_code' : _Prop_writing_code,
-}
-drawing_area._privelemdict = {
-}
-graphic_objects._superclassnames = []
-graphic_objects._privpropdict = {
-}
-graphic_objects._privelemdict = {
-}
-graphic_shapes._superclassnames = []
-graphic_shapes._privpropdict = {
-}
-graphic_shapes._privelemdict = {
-}
-graphic_text._superclassnames = []
-graphic_text._privpropdict = {
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
- 'uniform_styles' : _Prop_uniform_styles,
-}
-graphic_text._privelemdict = {
-}
-ovals._superclassnames = []
-ovals._privpropdict = {
-}
-ovals._privelemdict = {
-}
-polygon._superclassnames = []
-polygon._privpropdict = {
- 'point_list' : _Prop_point_list,
-}
-polygon._privelemdict = {
-}
-graphic_groups._superclassnames = []
-graphic_groups._privpropdict = {
-}
-graphic_groups._privelemdict = {
-}
-pixel_maps._superclassnames = []
-pixel_maps._privpropdict = {
-}
-pixel_maps._privelemdict = {
-}
-pixel._superclassnames = []
-pixel._privpropdict = {
- 'color' : _Prop_color,
-}
-pixel._privelemdict = {
-}
-rectangles._superclassnames = []
-rectangles._privpropdict = {
-}
-rectangles._privelemdict = {
-}
-rounded_rectangle._superclassnames = []
-rounded_rectangle._privpropdict = {
- 'corner_curve_height' : _Prop_corner_curve_height,
- 'corner_curve_width' : _Prop_corner_curve_width,
-}
-rounded_rectangle._privelemdict = {
-}
-graphic_line._superclassnames = []
-graphic_line._privpropdict = {
- 'arrow_style' : _Prop_arrow_style,
- 'dash_style' : _Prop_dash_style,
- 'end_point' : _Prop_end_point,
- 'start_point' : _Prop_start_point,
-}
-graphic_line._privelemdict = {
-}
-_Enum_arro = {
- 'no_arrow' : 'arno', # No arrow on line
- 'arrow_at_start' : 'arst', # Arrow at start of line
- 'arrow_at_end' : 'aren', # Arrow at end of line
- 'arrow_at_both_ends' : 'arbo', # Arrow at both the start and the end of the line
-}
-
-_Enum_tran = {
- 'copy_pixels' : 'cpy ', #
- 'not_copy_pixels' : 'ncpy', #
- 'or_pixels' : 'or ', #
- 'not_or_pixels' : 'ntor', #
- 'bic_pixels' : 'bic ', #
- 'not_bic_pixels' : 'nbic', #
- 'xor_pixels' : 'xor ', #
- 'not_xor_pixels' : 'nxor', #
- 'add_over_pixels' : 'addo', #
- 'add_pin_pixels' : 'addp', #
- 'sub_over_pixels' : 'subo', #
- 'sub_pin_pixels' : 'subp', #
- 'ad_max_pixels' : 'admx', #
- 'ad_min_pixels' : 'admn', #
- 'blend_pixels' : 'blnd', #
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'carc' : arc,
- 'cdrw' : drawing_area,
- 'cgob' : graphic_objects,
- 'cgsh' : graphic_shapes,
- 'cgtx' : graphic_text,
- 'covl' : ovals,
- 'cpgn' : polygon,
- 'cpic' : graphic_groups,
- 'cpix' : pixel_maps,
- 'cpxl' : pixel,
- 'crec' : rectangles,
- 'crrc' : rounded_rectangle,
- 'glin' : graphic_line,
-}
-
-_propdeclarations = {
- 'arro' : _Prop_arrow_style,
- 'cltb' : _Prop_color_table,
- 'colr' : _Prop_color,
- 'flcl' : _Prop_fill_color,
- 'flpt' : _Prop_fill_pattern,
- 'font' : _Prop_font,
- 'gobs' : _Prop_ordering,
- 'pang' : _Prop_start_angle,
- 'parc' : _Prop_arc_angle,
- 'pbcl' : _Prop_background_color,
- 'pbnd' : _Prop_bounds,
- 'pbpt' : _Prop_background_pattern,
- 'pchd' : _Prop_corner_curve_height,
- 'pcwd' : _Prop_corner_curve_width,
- 'pdpt' : _Prop_pixel_depth,
- 'pdrt' : _Prop_definition_rect,
- 'pdst' : _Prop_dash_style,
- 'pend' : _Prop_end_point,
- 'pnam' : _Prop_name,
- 'pnel' : _Prop_default_location,
- 'ppcl' : _Prop_pen_color,
- 'pppa' : _Prop_pen_pattern,
- 'pptm' : _Prop_transfer_mode,
- 'ppwd' : _Prop_pen_width,
- 'psct' : _Prop_writing_code,
- 'pstp' : _Prop_start_point,
- 'ptlt' : _Prop_point_list,
- 'ptps' : _Prop_default_size,
- 'ptsz' : _Prop_size,
- 'ptxc' : _Prop_text_color,
- 'ptxf' : _Prop_default_font,
- 'pupd' : _Prop_update_on_change,
- 'txst' : _Prop_style,
- 'ustl' : _Prop_uniform_styles,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'arro' : _Enum_arro,
- 'tran' : _Enum_tran,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suppleme.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suppleme.py
deleted file mode 100644
index d78193796df..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/QuickDraw_Graphics_Suppleme.py
+++ /dev/null
@@ -1,73 +0,0 @@
-"""Suite QuickDraw Graphics Supplemental Suite: Defines transformations of graphic objects
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'qdsp'
-
-class QuickDraw_Graphics_Suppleme_Events:
-
- pass
-
-
-class drawing_area(aetools.ComponentItem):
- """drawing area - Container for graphics and supporting information """
- want = 'cdrw'
-class _Prop_rotation(aetools.NProperty):
- """rotation - the default rotation for objects in the drawing area """
- which = 'prot'
- want = 'trot'
-class _Prop_scale(aetools.NProperty):
- """scale - the default scaling for objects in the drawing area """
- which = 'pscl'
- want = 'fixd'
-class _Prop_translation(aetools.NProperty):
- """translation - the default repositioning for objects in the drawing area """
- which = 'ptrs'
- want = 'QDpt'
-
-drawing_areas = drawing_area
-
-class graphic_groups(aetools.ComponentItem):
- """graphic groups - """
- want = 'cpic'
-
-graphic_group = graphic_groups
-drawing_area._superclassnames = []
-drawing_area._privpropdict = {
- 'rotation' : _Prop_rotation,
- 'scale' : _Prop_scale,
- 'translation' : _Prop_translation,
-}
-drawing_area._privelemdict = {
-}
-graphic_groups._superclassnames = []
-graphic_groups._privpropdict = {
-}
-graphic_groups._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cdrw' : drawing_area,
- 'cpic' : graphic_groups,
-}
-
-_propdeclarations = {
- 'prot' : _Prop_rotation,
- 'pscl' : _Prop_scale,
- 'ptrs' : _Prop_translation,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Required_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Required_Suite.py
deleted file mode 100644
index 7e77dbbf5b9..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Required_Suite.py
+++ /dev/null
@@ -1,32 +0,0 @@
-"""Suite Required Suite: Every application supports open, print, run, and quit
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'reqd'
-
-from _builtinSuites.builtin_Suite import *
-class Required_Suite_Events(builtin_Suite_Events):
-
- pass
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Standard_Suite.py
deleted file mode 100644
index 10e5423771d..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Standard_Suite.py
+++ /dev/null
@@ -1,738 +0,0 @@
-"""Suite Standard Suite: Common terms for most applications
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'core'
-
-from _builtinSuites.builtin_Suite import *
-class Standard_Suite_Events(builtin_Suite_Events):
-
- _argmap_class_info = {
- 'in_' : 'wrcd',
- }
-
- def class_info(self, _object=None, _attributes={}, **_arguments):
- """class info: (optional) Get information about an object class
- Required argument: the object class about which information is requested
- Keyword argument in_: the human language and script system in which to return information
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: a record containing the object\xd5s properties and elements
- """
- _code = 'core'
- _subcode = 'qobj'
-
- aetools.keysubst(_arguments, self._argmap_class_info)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_close = {
- 'saving' : 'savo',
- 'saving_in' : 'kfil',
- }
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: Close an object
- Required argument: the object to close
- Keyword argument saving: specifies whether changes should be saved before closing
- Keyword argument saving_in: the file or alias in which to save the object
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- aetools.keysubst(_arguments, self._argmap_close)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_count = {
- 'each' : 'kocl',
- }
-
- def count(self, _object, _attributes={}, **_arguments):
- """count: Return the number of elements of an object
- Required argument: the object whose elements are to be counted
- Keyword argument each: if specified, restricts counting to objects of this class
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the number of elements
- """
- _code = 'core'
- _subcode = 'cnte'
-
- aetools.keysubst(_arguments, self._argmap_count)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_data_size = {
- 'as' : 'rtyp',
- }
-
- def data_size(self, _object, _attributes={}, **_arguments):
- """data size: (optional) Return the size in bytes of an object
- Required argument: the object whose data size is to be returned
- Keyword argument as: the data type for which the size is calculated
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the size of the object in bytes
- """
- _code = 'core'
- _subcode = 'dsiz'
-
- aetools.keysubst(_arguments, self._argmap_data_size)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def delete(self, _object, _attributes={}, **_arguments):
- """delete: Delete an object from its container. Note this does not work on script variables, only on elements of application classes.
- Required argument: the element to delete
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'delo'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_duplicate = {
- 'to' : 'insh',
- 'with_properties' : 'prdt',
- }
-
- def duplicate(self, _object, _attributes={}, **_arguments):
- """duplicate: Duplicate one or more objects
- Required argument: the object(s) to duplicate
- Keyword argument to: the new location for the object(s)
- Keyword argument with_properties: the initial values for properties of the new object that are to be different from the original
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the duplicated object(s)
- """
- _code = 'core'
- _subcode = 'clon'
-
- aetools.keysubst(_arguments, self._argmap_duplicate)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_event_info = {
- 'in_' : 'wrcd',
- }
-
- def event_info(self, _object, _attributes={}, **_arguments):
- """event info: (optional) Get information about the Apple events in a suite
- Required argument: the event class of the Apple events for which to return information
- Keyword argument in_: the human language and script system in which to return information
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: a record containing the events and their parameters
- """
- _code = 'core'
- _subcode = 'gtei'
-
- aetools.keysubst(_arguments, self._argmap_event_info)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def exists(self, _object, _attributes={}, **_arguments):
- """exists: Verify if an object exists
- Required argument: the object in question
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: true if it exists, false if not
- """
- _code = 'core'
- _subcode = 'doex'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def handleBreakpoint(self, _object, _attributes={}, **_arguments):
- """handleBreakpoint: return true to stop at a breakpoint
- Required argument: the call frame of the breakpoint
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: true to stop, false if not
- """
- _code = 'core'
- _subcode = 'brak'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_make = {
- 'new' : 'kocl',
- 'at' : 'insh',
- 'with_data' : 'data',
- 'with_properties' : 'prdt',
- }
-
- def make(self, _no_object=None, _attributes={}, **_arguments):
- """make: Make a new element
- Keyword argument new: the class of the new element
- Keyword argument at: the location at which to insert the element
- Keyword argument with_data: the initial data for the element
- Keyword argument with_properties: the initial values for the properties of the element
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the new object(s)
- """
- _code = 'core'
- _subcode = 'crel'
-
- aetools.keysubst(_arguments, self._argmap_make)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_move = {
- 'to' : 'insh',
- }
-
- def move(self, _object, _attributes={}, **_arguments):
- """move: Move object(s) to a new location
- Required argument: the object(s) to move
- Keyword argument to: the new location for the object(s)
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: to the object(s) after they have been moved
- """
- _code = 'core'
- _subcode = 'move'
-
- aetools.keysubst(_arguments, self._argmap_move)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def print_(self, _object, _attributes={}, **_arguments):
- """print: Print the specified object(s)
- Required argument: list of objects to print
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_quit = {
- 'saving' : 'savo',
- }
-
- def quit(self, _no_object=None, _attributes={}, **_arguments):
- """quit: Quit an application
- Keyword argument saving: specifies whether to save currently open documents
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- aetools.keysubst(_arguments, self._argmap_quit)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def reopen(self, _no_object=None, _attributes={}, **_arguments):
- """reopen: Reactivate a running application. Some applications will open a new untitled window if no window is open.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'rapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def run(self, _no_object=None, _attributes={}, **_arguments):
- """run: Run an application. Most applications will open an empty, untitled window.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'oapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_save = {
- 'in_' : 'kfil',
- 'as' : 'fltp',
- }
-
- def save(self, _object, _attributes={}, **_arguments):
- """save: Save an object
- Required argument: the object to save, usually a document or window
- Keyword argument in_: the file or alias in which to save the object
- Keyword argument as: the file type of the document in which to save the data
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'save'
-
- aetools.keysubst(_arguments, self._argmap_save)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def select(self, _object, _attributes={}, **_arguments):
- """select: Make a selection
- Required argument: the object to select
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'slct'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_suite_info = {
- 'in_' : 'wrcd',
- }
-
- def suite_info(self, _object, _attributes={}, **_arguments):
- """suite info: (optional) Get information about event suite(s)
- Required argument: the suite for which to return information
- Keyword argument in_: the human language and script system in which to return information
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: a record containing the suites and their versions
- """
- _code = 'core'
- _subcode = 'gtsi'
-
- aetools.keysubst(_arguments, self._argmap_suite_info)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class alias(aetools.ComponentItem):
- """alias - a file on a disk or server. The file must exist when you check the syntax of your script. """
- want = 'alis'
-class _Prop_POSIX_path(aetools.NProperty):
- """POSIX path - the POSIX path of the file """
- which = 'psxp'
- want = 'TEXT'
-
-aliases = alias
-
-class application(aetools.ComponentItem):
- """application - An application program """
- want = 'capp'
-class _Prop_clipboard(aetools.NProperty):
- """clipboard - the contents of the clipboard for this application """
- which = 'pcli'
- want = '****'
-clipboard = _Prop_clipboard()
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is this the frontmost application? """
- which = 'pisf'
- want = 'bool'
-frontmost = _Prop_frontmost()
-class _Prop_name(aetools.NProperty):
- """name - the name of the application """
- which = 'pnam'
- want = 'itxt'
-name = _Prop_name()
-class _Prop_selection(aetools.NProperty):
- """selection - the selection visible to the user. Use the \xd4select\xd5 command to set a new selection; use \xd4contents of selection\xd5 to get or change information in the document. """
- which = 'sele'
- want = 'csel'
-selection = _Prop_selection()
-class _Prop_version(aetools.NProperty):
- """version - the version of the application """
- which = 'vers'
- want = 'vers'
-version = _Prop_version()
-
-applications = application
-
-class insertion_points(aetools.ComponentItem):
- """insertion points - """
- want = 'cins'
-
-insertion_point = insertion_points
-
-class selection_2d_object(aetools.ComponentItem):
- """selection-object - A way to refer to the state of the current of the selection. Use the \xd4select\xd5 command to make a new selection. """
- want = 'csel'
-class _Prop_contents(aetools.NProperty):
- """contents - the information currently selected. Use \xd4contents of selection\xd5 to get or change information in a document. """
- which = 'pcnt'
- want = '****'
-
-class window(aetools.ComponentItem):
- """window - A window """
- want = 'cwin'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the boundary rectangle for the window """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_closeable(aetools.NProperty):
- """closeable - Does the window have a close box? """
- which = 'hclb'
- want = 'bool'
-class _Prop_floating(aetools.NProperty):
- """floating - Does the window float? """
- which = 'isfl'
- want = 'bool'
-class _Prop_index(aetools.NProperty):
- """index - the number of the window """
- which = 'pidx'
- want = 'long'
-class _Prop_modal(aetools.NProperty):
- """modal - Is the window modal? """
- which = 'pmod'
- want = 'bool'
-class _Prop_resizable(aetools.NProperty):
- """resizable - Is the window resizable? """
- which = 'prsz'
- want = 'bool'
-class _Prop_titled(aetools.NProperty):
- """titled - Does the window have a title bar? """
- which = 'ptit'
- want = 'bool'
-class _Prop_visible(aetools.NProperty):
- """visible - Is the window visible? """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomable(aetools.NProperty):
- """zoomable - Is the window zoomable? """
- which = 'iszm'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Is the window zoomed? """
- which = 'pzum'
- want = 'bool'
-
-windows = window
-
-class document(aetools.ComponentItem):
- """document - A document of a scriptable application """
- want = 'docu'
-class _Prop_modified(aetools.NProperty):
- """modified - Has the document been modified since the last save? """
- which = 'imod'
- want = 'bool'
-
-documents = document
-
-class file(aetools.ComponentItem):
- """file - a file on a disk or server """
- want = 'file'
-
-files = file
-alias._superclassnames = []
-alias._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
-}
-alias._privelemdict = {
-}
-application._superclassnames = []
-application._privpropdict = {
- 'clipboard' : _Prop_clipboard,
- 'frontmost' : _Prop_frontmost,
- 'name' : _Prop_name,
- 'selection' : _Prop_selection,
- 'version' : _Prop_version,
-}
-application._privelemdict = {
-}
-insertion_points._superclassnames = []
-insertion_points._privpropdict = {
-}
-insertion_points._privelemdict = {
-}
-selection_2d_object._superclassnames = []
-selection_2d_object._privpropdict = {
- 'contents' : _Prop_contents,
-}
-selection_2d_object._privelemdict = {
-}
-window._superclassnames = []
-window._privpropdict = {
- 'bounds' : _Prop_bounds,
- 'closeable' : _Prop_closeable,
- 'floating' : _Prop_floating,
- 'index' : _Prop_index,
- 'modal' : _Prop_modal,
- 'resizable' : _Prop_resizable,
- 'titled' : _Prop_titled,
- 'visible' : _Prop_visible,
- 'zoomable' : _Prop_zoomable,
- 'zoomed' : _Prop_zoomed,
-}
-window._privelemdict = {
-}
-document._superclassnames = []
-document._privpropdict = {
- 'modified' : _Prop_modified,
-}
-document._privelemdict = {
-}
-file._superclassnames = []
-file._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
-}
-file._privelemdict = {
-}
-class _3c_(aetools.NComparison):
- """< - Less than """
-class _3d_(aetools.NComparison):
- """= - Equal """
-class _3e_(aetools.NComparison):
- """> - Greater than """
-class contains(aetools.NComparison):
- """contains - Contains """
-class ends_with(aetools.NComparison):
- """ends with - Ends with """
-class starts_with(aetools.NComparison):
- """starts with - Starts with """
-class _b2_(aetools.NComparison):
- """\xb2 - Less than or equal to """
-class _b3_(aetools.NComparison):
- """\xb3 - Greater than or equal to """
-_Enum_kfrm = {
- 'index' : 'indx', # keyform designating indexed access
- 'named' : 'name', # keyform designating named access
- 'id' : 'ID ', # keyform designating access by unique identifier
-}
-
-_Enum_savo = {
- 'yes' : 'yes ', # Save objects now
- 'no' : 'no ', # Do not save objects
- 'ask' : 'ask ', # Ask the user whether to save
-}
-
-_Enum_styl = {
- 'plain' : 'plan', # Plain
- 'bold' : 'bold', # Bold
- 'italic' : 'ital', # Italic
- 'outline' : 'outl', # Outline
- 'shadow' : 'shad', # Shadow
- 'underline' : 'undl', # Underline
- 'superscript' : 'spsc', # Superscript
- 'subscript' : 'sbsc', # Subscript
- 'strikethrough' : 'strk', # Strikethrough
- 'small_caps' : 'smcp', # Small caps
- 'all_caps' : 'alcp', # All capital letters
- 'all_lowercase' : 'lowc', # Lowercase
- 'condensed' : 'cond', # Condensed
- 'expanded' : 'pexp', # Expanded
- 'hidden' : 'hidn', # Hidden
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'alis' : alias,
- 'capp' : application,
- 'cins' : insertion_points,
- 'csel' : selection_2d_object,
- 'cwin' : window,
- 'docu' : document,
- 'file' : file,
-}
-
-_propdeclarations = {
- 'hclb' : _Prop_closeable,
- 'imod' : _Prop_modified,
- 'isfl' : _Prop_floating,
- 'iszm' : _Prop_zoomable,
- 'pbnd' : _Prop_bounds,
- 'pcli' : _Prop_clipboard,
- 'pcnt' : _Prop_contents,
- 'pidx' : _Prop_index,
- 'pisf' : _Prop_frontmost,
- 'pmod' : _Prop_modal,
- 'pnam' : _Prop_name,
- 'prsz' : _Prop_resizable,
- 'psxp' : _Prop_POSIX_path,
- 'ptit' : _Prop_titled,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
- 'sele' : _Prop_selection,
- 'vers' : _Prop_version,
-}
-
-_compdeclarations = {
- '< ' : _3c_,
- '<= ' : _b2_,
- '= ' : _3d_,
- '> ' : _3e_,
- '>= ' : _b3_,
- 'bgwt' : starts_with,
- 'cont' : contains,
- 'ends' : ends_with,
-}
-
-_enumdeclarations = {
- 'kfrm' : _Enum_kfrm,
- 'savo' : _Enum_savo,
- 'styl' : _Enum_styl,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Table_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Table_Suite.py
deleted file mode 100644
index afa01a0e001..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Table_Suite.py
+++ /dev/null
@@ -1,104 +0,0 @@
-"""Suite Table Suite: Classes for manipulating tables
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'tbls'
-
-class Table_Suite_Events:
-
- pass
-
-
-class cell(aetools.ComponentItem):
- """cell - A cell """
- want = 'ccel'
-class _Prop_formula(aetools.NProperty):
- """formula - the formula of the cell """
- which = 'pfor'
- want = 'ctxt'
-class _Prop_protection(aetools.NProperty):
- """protection - Indicates whether value or formula in the cell can be changed """
- which = 'ppro'
- want = 'prtn'
-
-cells = cell
-
-class column(aetools.ComponentItem):
- """column - A column """
- want = 'ccol'
-class _Prop_name(aetools.NProperty):
- """name - the name of the column """
- which = 'pnam'
- want = 'itxt'
-
-columns = column
-
-class rows(aetools.ComponentItem):
- """rows - """
- want = 'crow'
-
-row = rows
-
-class tables(aetools.ComponentItem):
- """tables - """
- want = 'ctbl'
-
-table = tables
-cell._superclassnames = []
-cell._privpropdict = {
- 'formula' : _Prop_formula,
- 'protection' : _Prop_protection,
-}
-cell._privelemdict = {
-}
-column._superclassnames = []
-column._privpropdict = {
- 'name' : _Prop_name,
-}
-column._privelemdict = {
-}
-rows._superclassnames = []
-rows._privpropdict = {
-}
-rows._privelemdict = {
-}
-tables._superclassnames = []
-tables._privpropdict = {
-}
-tables._privelemdict = {
-}
-_Enum_prtn = {
- 'read_only' : 'nmod', # Can\xd5t change values or formulas
- 'formulas_protected' : 'fpro', # Can changes values but not formulas
- 'read_2f_write' : 'modf', # Can change values and formulas
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'ccel' : cell,
- 'ccol' : column,
- 'crow' : rows,
- 'ctbl' : tables,
-}
-
-_propdeclarations = {
- 'pfor' : _Prop_formula,
- 'pnam' : _Prop_name,
- 'ppro' : _Prop_protection,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'prtn' : _Enum_prtn,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Text_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Text_Suite.py
deleted file mode 100644
index 1845f4d4352..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Text_Suite.py
+++ /dev/null
@@ -1,224 +0,0 @@
-"""Suite Text Suite: A set of basic classes for text processing
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'TEXT'
-
-class Text_Suite_Events:
-
- pass
-
-
-class text_flow(aetools.ComponentItem):
- """text flow - A contiguous block of text. Page layout applications call this a \xd4story.\xd5 """
- want = 'cflo'
-class _Prop__3c_inheritance_3e_(aetools.NProperty):
- """<inheritance> - inherits some of its properties from this class """
- which = 'c@#^'
- want = 'ctxt'
-class _Prop_name(aetools.NProperty):
- """name - the name """
- which = 'pnam'
- want = 'itxt'
-
-text_flows = text_flow
-
-class character(aetools.ComponentItem):
- """character - A character """
- want = 'cha '
-
-class line(aetools.ComponentItem):
- """line - A line of text """
- want = 'clin'
-class _Prop_justification(aetools.NProperty):
- """justification - the justification of the text """
- which = 'pjst'
- want = 'just'
-
-lines = line
-
-class paragraph(aetools.ComponentItem):
- """paragraph - A paragraph """
- want = 'cpar'
-
-paragraphs = paragraph
-
-class text(aetools.ComponentItem):
- """text - Text """
- want = 'ctxt'
-class _Prop_color(aetools.NProperty):
- """color - the color of the first character """
- which = 'colr'
- want = 'cRGB'
-class _Prop_font(aetools.NProperty):
- """font - the name of the font of the first character """
- which = 'font'
- want = 'ctxt'
-class _Prop_quoted_form(aetools.NProperty):
- """quoted form - the text in quoted form """
- which = 'strq'
- want = 'ctxt'
-class _Prop_size(aetools.NProperty):
- """size - the size in points of the first character """
- which = 'ptsz'
- want = 'fixd'
-class _Prop_style(aetools.NProperty):
- """style - the text style of the first character of the first character """
- which = 'txst'
- want = 'tsty'
-class _Prop_uniform_styles(aetools.NProperty):
- """uniform styles - the text styles that are uniform throughout the text """
- which = 'ustl'
- want = 'tsty'
-class _Prop_writing_code(aetools.NProperty):
- """writing code - the script system and language """
- which = 'psct'
- want = 'intl'
-# element 'cha ' as ['indx']
-# element 'clin' as ['indx']
-# element 'cpar' as ['indx']
-# element 'ctxt' as ['indx']
-# element 'cwor' as ['indx']
-
-class word(aetools.ComponentItem):
- """word - A word """
- want = 'cwor'
-
-words = word
-
-class text_style_info(aetools.ComponentItem):
- """text style info - On and Off styles of text run """
- want = 'tsty'
-class _Prop_off_styles(aetools.NProperty):
- """off styles - the styles that are off for the text """
- which = 'ofst'
- want = 'styl'
-class _Prop_on_styles(aetools.NProperty):
- """on styles - the styles that are on for the text """
- which = 'onst'
- want = 'styl'
-
-text_style_infos = text_style_info
-text_flow._superclassnames = ['text']
-text_flow._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
- 'name' : _Prop_name,
-}
-text_flow._privelemdict = {
-}
-character._superclassnames = ['text']
-character._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-character._privelemdict = {
-}
-line._superclassnames = ['text']
-line._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
- 'justification' : _Prop_justification,
-}
-line._privelemdict = {
-}
-paragraph._superclassnames = ['text']
-paragraph._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-paragraph._privelemdict = {
-}
-text._superclassnames = []
-text._privpropdict = {
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'quoted_form' : _Prop_quoted_form,
- 'size' : _Prop_size,
- 'style' : _Prop_style,
- 'uniform_styles' : _Prop_uniform_styles,
- 'writing_code' : _Prop_writing_code,
-}
-text._privelemdict = {
- 'character' : character,
- 'line' : line,
- 'paragraph' : paragraph,
- 'text' : text,
- 'word' : word,
-}
-word._superclassnames = ['text']
-word._privpropdict = {
- '_3c_inheritance_3e_' : _Prop__3c_inheritance_3e_,
-}
-word._privelemdict = {
-}
-text_style_info._superclassnames = []
-text_style_info._privpropdict = {
- 'off_styles' : _Prop_off_styles,
- 'on_styles' : _Prop_on_styles,
-}
-text_style_info._privelemdict = {
-}
-_Enum_just = {
- 'left' : 'left', # Align with left margin
- 'right' : 'rght', # Align with right margin
- 'center' : 'cent', # Align with center
- 'full' : 'full', # Align with both left and right margins
-}
-
-_Enum_styl = {
- 'plain' : 'plan', # Plain
- 'bold' : 'bold', # Bold
- 'italic' : 'ital', # Italic
- 'outline' : 'outl', # Outline
- 'shadow' : 'shad', # Shadow
- 'underline' : 'undl', # Underline
- 'superscript' : 'spsc', # Superscript
- 'subscript' : 'sbsc', # Subscript
- 'strikethrough' : 'strk', # Strikethrough
- 'small_caps' : 'smcp', # Small caps
- 'all_caps' : 'alcp', # All capital letters
- 'all_lowercase' : 'lowc', # Lowercase
- 'condensed' : 'cond', # Condensed
- 'expanded' : 'pexp', # Expanded
- 'hidden' : 'hidn', # Hidden
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cflo' : text_flow,
- 'cha ' : character,
- 'clin' : line,
- 'cpar' : paragraph,
- 'ctxt' : text,
- 'cwor' : word,
- 'tsty' : text_style_info,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_inheritance_3e_,
- 'colr' : _Prop_color,
- 'font' : _Prop_font,
- 'ofst' : _Prop_off_styles,
- 'onst' : _Prop_on_styles,
- 'pjst' : _Prop_justification,
- 'pnam' : _Prop_name,
- 'psct' : _Prop_writing_code,
- 'ptsz' : _Prop_size,
- 'strq' : _Prop_quoted_form,
- 'txst' : _Prop_style,
- 'ustl' : _Prop_uniform_styles,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'just' : _Enum_just,
- 'styl' : _Enum_styl,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/Type_Names_Suite.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/Type_Names_Suite.py
deleted file mode 100644
index cd9fa19870e..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/Type_Names_Suite.py
+++ /dev/null
@@ -1,435 +0,0 @@
-"""Suite Type Names Suite: Terminology for Registry data types
-Level 1, version 1
-
-Generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'tpnm'
-
-class Type_Names_Suite_Events:
-
- pass
-
-
-class PostScript_picture(aetools.ComponentItem):
- """PostScript picture - """
- want = 'EPS '
-
-class point(aetools.ComponentItem):
- """point - point coordinates """
- want = 'QDpt'
-
-class string(aetools.ComponentItem):
- """string - a string of characters """
- want = 'TEXT'
-
-plain_text = string
-
-plain_text = string
-
-class TIFF_picture(aetools.ComponentItem):
- """TIFF picture - """
- want = 'TIFF'
-
-class application_dictionary(aetools.ComponentItem):
- """application dictionary - """
- want = 'aete'
-
-class system_dictionary(aetools.ComponentItem):
- """system dictionary - """
- want = 'aeut'
-
-class color_table(aetools.ComponentItem):
- """color table - """
- want = 'clrt'
-
-class menu_item(aetools.ComponentItem):
- """menu item - """
- want = 'cmen'
-
-class menu(aetools.ComponentItem):
- """menu - """
- want = 'cmnu'
-
-class double_integer(aetools.ComponentItem):
- """double integer - """
- want = 'comp'
-
-class type_element_info(aetools.ComponentItem):
- """type element info - """
- want = 'elin'
-
-class type_event_info(aetools.ComponentItem):
- """type event info - information about an event """
- want = 'evin'
-
-class extended_real(aetools.ComponentItem):
- """extended real - """
- want = 'exte'
-
-class fixed(aetools.ComponentItem):
- """fixed - a real number """
- want = 'fixd'
-
-class fixed_point(aetools.ComponentItem):
- """fixed point - """
- want = 'fpnt'
-
-class fixed_rectangle(aetools.ComponentItem):
- """fixed rectangle - """
- want = 'frct'
-
-class type_class_info(aetools.ComponentItem):
- """type class info - information about properties and elements of a class """
- want = 'gcli'
-
-class location_reference(aetools.ComponentItem):
- """location reference - """
- want = 'insl'
-
-class long_fixed_point(aetools.ComponentItem):
- """long fixed point - """
- want = 'lfpt'
-
-class long_fixed_rectangle(aetools.ComponentItem):
- """long fixed rectangle - """
- want = 'lfrc'
-
-class long_fixed(aetools.ComponentItem):
- """long fixed - """
- want = 'lfxd'
-
-class long_point(aetools.ComponentItem):
- """long point - """
- want = 'lpnt'
-
-class long_rectangle(aetools.ComponentItem):
- """long rectangle - """
- want = 'lrct'
-
-class machine_location(aetools.ComponentItem):
- """machine location - """
- want = 'mLoc'
-
-class unsigned_integer(aetools.ComponentItem):
- """unsigned integer - """
- want = 'magn'
-
-class null(aetools.ComponentItem):
- """null - """
- want = 'null'
-
-class type_property_info(aetools.ComponentItem):
- """type property info - """
- want = 'pinf'
-
-class type_parameter_info(aetools.ComponentItem):
- """type parameter info - """
- want = 'pmin'
-
-class bounding_rectangle(aetools.ComponentItem):
- """bounding rectangle - bounding rectangle """
- want = 'qdrt'
-
-class small_integer(aetools.ComponentItem):
- """small integer - """
- want = 'shor'
-
-class small_real(aetools.ComponentItem):
- """small real - """
- want = 'sing'
-
-class scrap_styles(aetools.ComponentItem):
- """scrap styles - """
- want = 'styl'
-
-class type_suite_info(aetools.ComponentItem):
- """type suite info - """
- want = 'suin'
-
-class target_id(aetools.ComponentItem):
- """target id - """
- want = 'targ'
-
-class dash_style(aetools.ComponentItem):
- """dash style - """
- want = 'tdas'
-
-class pixel_map_record(aetools.ComponentItem):
- """pixel map record - """
- want = 'tpmm'
-
-class RGB16_color(aetools.ComponentItem):
- """RGB16 color - """
- want = 'tr16'
-
-class RGB96_color(aetools.ComponentItem):
- """RGB96 color - """
- want = 'tr96'
-
-class rotation(aetools.ComponentItem):
- """rotation - """
- want = 'trot'
-
-class version(aetools.ComponentItem):
- """version - """
- want = 'vers'
-PostScript_picture._superclassnames = []
-PostScript_picture._privpropdict = {
-}
-PostScript_picture._privelemdict = {
-}
-point._superclassnames = []
-point._privpropdict = {
-}
-point._privelemdict = {
-}
-string._superclassnames = []
-string._privpropdict = {
-}
-string._privelemdict = {
-}
-TIFF_picture._superclassnames = []
-TIFF_picture._privpropdict = {
-}
-TIFF_picture._privelemdict = {
-}
-application_dictionary._superclassnames = []
-application_dictionary._privpropdict = {
-}
-application_dictionary._privelemdict = {
-}
-system_dictionary._superclassnames = []
-system_dictionary._privpropdict = {
-}
-system_dictionary._privelemdict = {
-}
-color_table._superclassnames = []
-color_table._privpropdict = {
-}
-color_table._privelemdict = {
-}
-menu_item._superclassnames = []
-menu_item._privpropdict = {
-}
-menu_item._privelemdict = {
-}
-menu._superclassnames = []
-menu._privpropdict = {
-}
-menu._privelemdict = {
-}
-double_integer._superclassnames = []
-double_integer._privpropdict = {
-}
-double_integer._privelemdict = {
-}
-type_element_info._superclassnames = []
-type_element_info._privpropdict = {
-}
-type_element_info._privelemdict = {
-}
-type_event_info._superclassnames = []
-type_event_info._privpropdict = {
-}
-type_event_info._privelemdict = {
-}
-extended_real._superclassnames = []
-extended_real._privpropdict = {
-}
-extended_real._privelemdict = {
-}
-fixed._superclassnames = []
-fixed._privpropdict = {
-}
-fixed._privelemdict = {
-}
-fixed_point._superclassnames = []
-fixed_point._privpropdict = {
-}
-fixed_point._privelemdict = {
-}
-fixed_rectangle._superclassnames = []
-fixed_rectangle._privpropdict = {
-}
-fixed_rectangle._privelemdict = {
-}
-type_class_info._superclassnames = []
-type_class_info._privpropdict = {
-}
-type_class_info._privelemdict = {
-}
-location_reference._superclassnames = []
-location_reference._privpropdict = {
-}
-location_reference._privelemdict = {
-}
-long_fixed_point._superclassnames = []
-long_fixed_point._privpropdict = {
-}
-long_fixed_point._privelemdict = {
-}
-long_fixed_rectangle._superclassnames = []
-long_fixed_rectangle._privpropdict = {
-}
-long_fixed_rectangle._privelemdict = {
-}
-long_fixed._superclassnames = []
-long_fixed._privpropdict = {
-}
-long_fixed._privelemdict = {
-}
-long_point._superclassnames = []
-long_point._privpropdict = {
-}
-long_point._privelemdict = {
-}
-long_rectangle._superclassnames = []
-long_rectangle._privpropdict = {
-}
-long_rectangle._privelemdict = {
-}
-machine_location._superclassnames = []
-machine_location._privpropdict = {
-}
-machine_location._privelemdict = {
-}
-unsigned_integer._superclassnames = []
-unsigned_integer._privpropdict = {
-}
-unsigned_integer._privelemdict = {
-}
-null._superclassnames = []
-null._privpropdict = {
-}
-null._privelemdict = {
-}
-type_property_info._superclassnames = []
-type_property_info._privpropdict = {
-}
-type_property_info._privelemdict = {
-}
-type_parameter_info._superclassnames = []
-type_parameter_info._privpropdict = {
-}
-type_parameter_info._privelemdict = {
-}
-bounding_rectangle._superclassnames = []
-bounding_rectangle._privpropdict = {
-}
-bounding_rectangle._privelemdict = {
-}
-small_integer._superclassnames = []
-small_integer._privpropdict = {
-}
-small_integer._privelemdict = {
-}
-small_real._superclassnames = []
-small_real._privpropdict = {
-}
-small_real._privelemdict = {
-}
-scrap_styles._superclassnames = []
-scrap_styles._privpropdict = {
-}
-scrap_styles._privelemdict = {
-}
-type_suite_info._superclassnames = []
-type_suite_info._privpropdict = {
-}
-type_suite_info._privelemdict = {
-}
-target_id._superclassnames = []
-target_id._privpropdict = {
-}
-target_id._privelemdict = {
-}
-dash_style._superclassnames = []
-dash_style._privpropdict = {
-}
-dash_style._privelemdict = {
-}
-pixel_map_record._superclassnames = []
-pixel_map_record._privpropdict = {
-}
-pixel_map_record._privelemdict = {
-}
-RGB16_color._superclassnames = []
-RGB16_color._privpropdict = {
-}
-RGB16_color._privelemdict = {
-}
-RGB96_color._superclassnames = []
-RGB96_color._privpropdict = {
-}
-RGB96_color._privelemdict = {
-}
-rotation._superclassnames = []
-rotation._privpropdict = {
-}
-rotation._privelemdict = {
-}
-version._superclassnames = []
-version._privpropdict = {
-}
-version._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'EPS ' : PostScript_picture,
- 'QDpt' : point,
- 'TEXT' : string,
- 'TIFF' : TIFF_picture,
- 'aete' : application_dictionary,
- 'aeut' : system_dictionary,
- 'clrt' : color_table,
- 'cmen' : menu_item,
- 'cmnu' : menu,
- 'comp' : double_integer,
- 'elin' : type_element_info,
- 'evin' : type_event_info,
- 'exte' : extended_real,
- 'fixd' : fixed,
- 'fpnt' : fixed_point,
- 'frct' : fixed_rectangle,
- 'gcli' : type_class_info,
- 'insl' : location_reference,
- 'lfpt' : long_fixed_point,
- 'lfrc' : long_fixed_rectangle,
- 'lfxd' : long_fixed,
- 'lpnt' : long_point,
- 'lrct' : long_rectangle,
- 'mLoc' : machine_location,
- 'magn' : unsigned_integer,
- 'null' : null,
- 'pinf' : type_property_info,
- 'pmin' : type_parameter_info,
- 'qdrt' : bounding_rectangle,
- 'shor' : small_integer,
- 'sing' : small_real,
- 'styl' : scrap_styles,
- 'suin' : type_suite_info,
- 'targ' : target_id,
- 'tdas' : dash_style,
- 'tpmm' : pixel_map_record,
- 'tr16' : RGB16_color,
- 'tr96' : RGB96_color,
- 'trot' : rotation,
- 'vers' : version,
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py b/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
deleted file mode 100644
index b96055d6962..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/StdSuites/__init__.py
+++ /dev/null
@@ -1,475 +0,0 @@
-"""
-Package generated from /Volumes/Sap/System Folder/Extensions/AppleScript
-Resource aeut resid 0 Standard Event Suites for English
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the StdSuites package is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Text_Suite
-import AppleScript_Suite
-import Standard_Suite
-import Macintosh_Connectivity_Clas
-import QuickDraw_Graphics_Suite
-import QuickDraw_Graphics_Suppleme
-import Required_Suite
-import Table_Suite
-import Type_Names_Suite
-
-
-_code_to_module = {
- 'TEXT' : Text_Suite,
- 'ascr' : AppleScript_Suite,
- 'core' : Standard_Suite,
- 'macc' : Macintosh_Connectivity_Clas,
- 'qdrw' : QuickDraw_Graphics_Suite,
- 'qdsp' : QuickDraw_Graphics_Suppleme,
- 'reqd' : Required_Suite,
- 'tbls' : Table_Suite,
- 'tpnm' : Type_Names_Suite,
-}
-
-
-
-_code_to_fullname = {
- 'TEXT' : ('StdSuites.Text_Suite', 'Text_Suite'),
- 'ascr' : ('StdSuites.AppleScript_Suite', 'AppleScript_Suite'),
- 'core' : ('StdSuites.Standard_Suite', 'Standard_Suite'),
- 'macc' : ('StdSuites.Macintosh_Connectivity_Clas', 'Macintosh_Connectivity_Clas'),
- 'qdrw' : ('StdSuites.QuickDraw_Graphics_Suite', 'QuickDraw_Graphics_Suite'),
- 'qdsp' : ('StdSuites.QuickDraw_Graphics_Suppleme', 'QuickDraw_Graphics_Suppleme'),
- 'reqd' : ('StdSuites.Required_Suite', 'Required_Suite'),
- 'tbls' : ('StdSuites.Table_Suite', 'Table_Suite'),
- 'tpnm' : ('StdSuites.Type_Names_Suite', 'Type_Names_Suite'),
-}
-
-from Text_Suite import *
-from AppleScript_Suite import *
-from Standard_Suite import *
-from Macintosh_Connectivity_Clas import *
-from QuickDraw_Graphics_Suite import *
-from QuickDraw_Graphics_Suppleme import *
-from Required_Suite import *
-from Table_Suite import *
-from Type_Names_Suite import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(graphic_group)
-getbaseclasses(oval)
-getbaseclasses(graphic_text)
-getbaseclasses(graphic_shape)
-getbaseclasses(drawing_area)
-getbaseclasses(graphic_line)
-getbaseclasses(polygon)
-getbaseclasses(pixel)
-getbaseclasses(rounded_rectangle)
-getbaseclasses(graphic_object)
-getbaseclasses(arc)
-getbaseclasses(pixel_map)
-getbaseclasses(rectangle)
-getbaseclasses(selection_2d_object)
-getbaseclasses(application)
-getbaseclasses(document)
-getbaseclasses(window)
-getbaseclasses(file)
-getbaseclasses(alias)
-getbaseclasses(insertion_point)
-getbaseclasses(character)
-getbaseclasses(paragraph)
-getbaseclasses(word)
-getbaseclasses(text_flow)
-getbaseclasses(text_style_info)
-getbaseclasses(line)
-getbaseclasses(text)
-getbaseclasses(AppleTalk_address)
-getbaseclasses(address_specification)
-getbaseclasses(Token_Ring_address)
-getbaseclasses(FireWire_address)
-getbaseclasses(bus_slot)
-getbaseclasses(SCSI_address)
-getbaseclasses(ADB_address)
-getbaseclasses(USB_address)
-getbaseclasses(device_specification)
-getbaseclasses(LocalTalk_address)
-getbaseclasses(IP_address)
-getbaseclasses(Ethernet_address)
-getbaseclasses(graphic_group)
-getbaseclasses(drawing_area)
-getbaseclasses(cell)
-getbaseclasses(column)
-getbaseclasses(table)
-getbaseclasses(row)
-getbaseclasses(small_integer)
-getbaseclasses(system_dictionary)
-getbaseclasses(color_table)
-getbaseclasses(fixed_point)
-getbaseclasses(plain_text)
-getbaseclasses(type_element_info)
-getbaseclasses(machine_location)
-getbaseclasses(PostScript_picture)
-getbaseclasses(type_suite_info)
-getbaseclasses(menu_item)
-getbaseclasses(pixel_map_record)
-getbaseclasses(small_real)
-getbaseclasses(null)
-getbaseclasses(rotation)
-getbaseclasses(fixed)
-getbaseclasses(long_point)
-getbaseclasses(target_id)
-getbaseclasses(type_property_info)
-getbaseclasses(type_parameter_info)
-getbaseclasses(long_fixed_point)
-getbaseclasses(bounding_rectangle)
-getbaseclasses(TIFF_picture)
-getbaseclasses(long_fixed)
-getbaseclasses(location_reference)
-getbaseclasses(version)
-getbaseclasses(RGB16_color)
-getbaseclasses(double_integer)
-getbaseclasses(type_event_info)
-getbaseclasses(point)
-getbaseclasses(application_dictionary)
-getbaseclasses(unsigned_integer)
-getbaseclasses(menu)
-getbaseclasses(fixed_rectangle)
-getbaseclasses(long_fixed_rectangle)
-getbaseclasses(type_class_info)
-getbaseclasses(RGB96_color)
-getbaseclasses(dash_style)
-getbaseclasses(scrap_styles)
-getbaseclasses(extended_real)
-getbaseclasses(long_rectangle)
-getbaseclasses(May)
-getbaseclasses(string)
-getbaseclasses(miles)
-getbaseclasses(number_or_date)
-getbaseclasses(October)
-getbaseclasses(event)
-getbaseclasses(Pascal_string)
-getbaseclasses(zone)
-getbaseclasses(picture)
-getbaseclasses(list_or_string)
-getbaseclasses(number)
-getbaseclasses(Tuesday)
-getbaseclasses(version)
-getbaseclasses(December)
-getbaseclasses(square_kilometres)
-getbaseclasses(reference)
-getbaseclasses(vector)
-getbaseclasses(weekday)
-getbaseclasses(Sunday)
-getbaseclasses(international_text)
-getbaseclasses(seconds)
-getbaseclasses(RGB_color)
-getbaseclasses(kilometres)
-getbaseclasses(styled_Unicode_text)
-getbaseclasses(missing_value)
-getbaseclasses(metres)
-getbaseclasses(number_or_string)
-getbaseclasses(list)
-getbaseclasses(linked_list)
-getbaseclasses(real)
-getbaseclasses(encoded_string)
-getbaseclasses(list_or_record)
-getbaseclasses(Monday)
-getbaseclasses(September)
-getbaseclasses(anything)
-getbaseclasses(property)
-getbaseclasses(reference_form)
-getbaseclasses(item)
-getbaseclasses(grams)
-getbaseclasses(record)
-getbaseclasses(empty_ae_name_)
-getbaseclasses(constant)
-getbaseclasses(square_miles)
-getbaseclasses(data)
-getbaseclasses(Unicode_text)
-getbaseclasses(yards)
-getbaseclasses(cubic_yards)
-getbaseclasses(pounds)
-getbaseclasses(cubic_centimetres)
-getbaseclasses(text)
-getbaseclasses(July)
-getbaseclasses(cubic_metres)
-getbaseclasses(styled_text)
-getbaseclasses(number_2c__date_or_text)
-getbaseclasses(feet)
-getbaseclasses(February)
-getbaseclasses(degrees_Celsius)
-getbaseclasses(keystroke)
-getbaseclasses(integer)
-getbaseclasses(degrees_Fahrenheit)
-getbaseclasses(list_2c__record_or_text)
-getbaseclasses(date)
-getbaseclasses(degrees_Kelvin)
-getbaseclasses(centimetres)
-getbaseclasses(writing_code)
-getbaseclasses(alias_or_string)
-getbaseclasses(writing_code_info)
-getbaseclasses(text_item)
-getbaseclasses(machine)
-getbaseclasses(type_class)
-getbaseclasses(preposition)
-getbaseclasses(Wednesday)
-getbaseclasses(upper_case)
-getbaseclasses(March)
-getbaseclasses(square_feet)
-getbaseclasses(November)
-getbaseclasses(quarts)
-getbaseclasses(alias)
-getbaseclasses(January)
-getbaseclasses(month)
-getbaseclasses(June)
-getbaseclasses(August)
-getbaseclasses(styled_Clipboard_text)
-getbaseclasses(gallons)
-getbaseclasses(cubic_inches)
-getbaseclasses(Friday)
-getbaseclasses(sound)
-getbaseclasses(class_)
-getbaseclasses(kilograms)
-getbaseclasses(script)
-getbaseclasses(litres)
-getbaseclasses(boolean)
-getbaseclasses(square_metres)
-getbaseclasses(inches)
-getbaseclasses(character)
-getbaseclasses(April)
-getbaseclasses(ounces)
-getbaseclasses(app)
-getbaseclasses(handler)
-getbaseclasses(C_string)
-getbaseclasses(Thursday)
-getbaseclasses(square_yards)
-getbaseclasses(cubic_feet)
-getbaseclasses(Saturday)
-getbaseclasses(file_specification)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'cpic' : graphic_group,
- 'covl' : oval,
- 'cgtx' : graphic_text,
- 'cgsh' : graphic_shape,
- 'cdrw' : drawing_area,
- 'glin' : graphic_line,
- 'cpgn' : polygon,
- 'cpxl' : pixel,
- 'crrc' : rounded_rectangle,
- 'cgob' : graphic_object,
- 'carc' : arc,
- 'cpix' : pixel_map,
- 'crec' : rectangle,
- 'csel' : selection_2d_object,
- 'capp' : application,
- 'docu' : document,
- 'cwin' : window,
- 'file' : file,
- 'alis' : alias,
- 'cins' : insertion_point,
- 'cha ' : character,
- 'cpar' : paragraph,
- 'cwor' : word,
- 'cflo' : text_flow,
- 'tsty' : text_style_info,
- 'clin' : line,
- 'ctxt' : text,
- 'cat ' : AppleTalk_address,
- 'cadr' : address_specification,
- 'ctok' : Token_Ring_address,
- 'cfw ' : FireWire_address,
- 'cbus' : bus_slot,
- 'cscs' : SCSI_address,
- 'cadb' : ADB_address,
- 'cusb' : USB_address,
- 'cdev' : device_specification,
- 'clt ' : LocalTalk_address,
- 'cip ' : IP_address,
- 'cen ' : Ethernet_address,
- 'cpic' : graphic_group,
- 'cdrw' : drawing_area,
- 'ccel' : cell,
- 'ccol' : column,
- 'ctbl' : table,
- 'crow' : row,
- 'shor' : small_integer,
- 'aeut' : system_dictionary,
- 'clrt' : color_table,
- 'fpnt' : fixed_point,
- 'TEXT' : plain_text,
- 'elin' : type_element_info,
- 'mLoc' : machine_location,
- 'EPS ' : PostScript_picture,
- 'suin' : type_suite_info,
- 'cmen' : menu_item,
- 'tpmm' : pixel_map_record,
- 'sing' : small_real,
- 'null' : null,
- 'trot' : rotation,
- 'fixd' : fixed,
- 'lpnt' : long_point,
- 'targ' : target_id,
- 'pinf' : type_property_info,
- 'pmin' : type_parameter_info,
- 'lfpt' : long_fixed_point,
- 'qdrt' : bounding_rectangle,
- 'TIFF' : TIFF_picture,
- 'lfxd' : long_fixed,
- 'insl' : location_reference,
- 'vers' : version,
- 'tr16' : RGB16_color,
- 'comp' : double_integer,
- 'evin' : type_event_info,
- 'QDpt' : point,
- 'aete' : application_dictionary,
- 'magn' : unsigned_integer,
- 'cmnu' : menu,
- 'frct' : fixed_rectangle,
- 'lfrc' : long_fixed_rectangle,
- 'gcli' : type_class_info,
- 'tr96' : RGB96_color,
- 'tdas' : dash_style,
- 'styl' : scrap_styles,
- 'exte' : extended_real,
- 'lrct' : long_rectangle,
- 'may ' : May,
- 'TEXT' : string,
- 'mile' : miles,
- 'nd ' : number_or_date,
- 'oct ' : October,
- 'evnt' : event,
- 'pstr' : Pascal_string,
- 'zone' : zone,
- 'PICT' : picture,
- 'ls ' : list_or_string,
- 'nmbr' : number,
- 'tue ' : Tuesday,
- 'vers' : version,
- 'dec ' : December,
- 'sqkm' : square_kilometres,
- 'obj ' : reference,
- 'vect' : vector,
- 'wkdy' : weekday,
- 'sun ' : Sunday,
- 'itxt' : international_text,
- 'scnd' : seconds,
- 'cRGB' : RGB_color,
- 'kmtr' : kilometres,
- 'sutx' : styled_Unicode_text,
- 'msng' : missing_value,
- 'metr' : metres,
- 'ns ' : number_or_string,
- 'list' : list,
- 'llst' : linked_list,
- 'doub' : real,
- 'encs' : encoded_string,
- 'lr ' : list_or_record,
- 'mon ' : Monday,
- 'sep ' : September,
- '****' : anything,
- 'prop' : property,
- 'kfrm' : reference_form,
- 'cobj' : item,
- 'gram' : grams,
- 'reco' : record,
- 'undf' : empty_ae_name_,
- 'enum' : constant,
- 'sqmi' : square_miles,
- 'rdat' : data,
- 'utxt' : Unicode_text,
- 'yard' : yards,
- 'cyrd' : cubic_yards,
- 'lbs ' : pounds,
- 'ccmt' : cubic_centimetres,
- 'ctxt' : text,
- 'jul ' : July,
- 'cmet' : cubic_metres,
- 'STXT' : styled_text,
- 'nds ' : number_2c__date_or_text,
- 'feet' : feet,
- 'feb ' : February,
- 'degc' : degrees_Celsius,
- 'kprs' : keystroke,
- 'long' : integer,
- 'degf' : degrees_Fahrenheit,
- 'lrs ' : list_2c__record_or_text,
- 'ldt ' : date,
- 'degk' : degrees_Kelvin,
- 'cmtr' : centimetres,
- 'psct' : writing_code,
- 'sf ' : alias_or_string,
- 'citl' : writing_code_info,
- 'citm' : text_item,
- 'mach' : machine,
- 'type' : type_class,
- 'prep' : preposition,
- 'wed ' : Wednesday,
- 'case' : upper_case,
- 'mar ' : March,
- 'sqft' : square_feet,
- 'nov ' : November,
- 'qrts' : quarts,
- 'alis' : alias,
- 'jan ' : January,
- 'mnth' : month,
- 'jun ' : June,
- 'aug ' : August,
- 'styl' : styled_Clipboard_text,
- 'galn' : gallons,
- 'cuin' : cubic_inches,
- 'fri ' : Friday,
- 'snd ' : sound,
- 'pcls' : class_,
- 'kgrm' : kilograms,
- 'scpt' : script,
- 'litr' : litres,
- 'bool' : boolean,
- 'sqrm' : square_metres,
- 'inch' : inches,
- 'cha ' : character,
- 'apr ' : April,
- 'ozs ' : ounces,
- 'capp' : app,
- 'hand' : handler,
- 'cstr' : C_string,
- 'thu ' : Thursday,
- 'sqyd' : square_yards,
- 'cfet' : cubic_feet,
- 'sat ' : Saturday,
- 'fss ' : file_specification,
-}
-
-
-class StdSuites(Text_Suite_Events,
- AppleScript_Suite_Events,
- Standard_Suite_Events,
- Macintosh_Connectivity_Clas_Events,
- QuickDraw_Graphics_Suite_Events,
- QuickDraw_Graphics_Suppleme_Events,
- Required_Suite_Events,
- Table_Suite_Events,
- Type_Names_Suite_Events,
- aetools.TalkTo):
- _signature = 'ascr'
-
- _moduleName = 'StdSuites'
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Disk_Folder_File_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Disk_Folder_File_Suite.py
deleted file mode 100644
index a9ac3dd2790..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Disk_Folder_File_Suite.py
+++ /dev/null
@@ -1,381 +0,0 @@
-"""Suite Disk-Folder-File Suite: Terms and Events for controlling Disks, Folders, and Files
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'cdis'
-
-class Disk_Folder_File_Suite_Events:
-
- _argmap_move = {
- 'to' : 'insh',
- }
-
- def move(self, _object, _attributes={}, **_arguments):
- """move: Move disk item(s) to a new location.
- Required argument: the object for the command
- Keyword argument to: The new location for the disk item(s).
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'move'
-
- aetools.keysubst(_arguments, self._argmap_move)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The Disk-Folder-File Suite host program """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_folder_actions_enabled(aetools.NProperty):
- """folder actions enabled - Are Folder Actions currently being processed? """
- which = 'faen'
- want = 'bool'
-folder_actions_enabled = _Prop_folder_actions_enabled()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the Disk-Folder-File Suite host program """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cdis' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'foac' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'logi' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcap' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcda' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'prcs' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class disk(aetools.ComponentItem):
- """disk - A disk in the file system """
- want = 'cdis'
-class _Prop_POSIX_path(aetools.NProperty):
- """POSIX path - the POSIX file system path of the disk """
- which = 'posx'
- want = 'utxt'
-class _Prop_capacity(aetools.NProperty):
- """capacity - the total number of bytes (free or used) on the disk """
- which = 'capa'
- want = 'magn'
-class _Prop_ejectable(aetools.NProperty):
- """ejectable - Can the media be ejected (floppies, CD's, and so on)? """
- which = 'isej'
- want = 'bool'
-class _Prop_format(aetools.NProperty):
- """format - the file system format of this disk """
- which = 'dfmt'
- want = 'edfm'
-class _Prop_free_space(aetools.NProperty):
- """free space - the number of free bytes left on the disk """
- which = 'frsp'
- want = 'magn'
-class _Prop_ignore_privileges(aetools.NProperty):
- """ignore privileges - Ignore permissions on this disk? """
- which = 'igpr'
- want = 'bool'
-class _Prop_local_volume(aetools.NProperty):
- """local volume - Is the media a local volume (as opposed to a file server? """
- which = 'isrv'
- want = 'bool'
-class _Prop_name(aetools.NProperty):
- """name - the name of the disk """
- which = 'pnam'
- want = 'utxt'
-class _Prop_path(aetools.NProperty):
- """path - the file system path of the disk """
- which = 'ppth'
- want = 'utxt'
-class _Prop_startup(aetools.NProperty):
- """startup - Is this disk the boot disk? """
- which = 'istd'
- want = 'bool'
-class _Prop_volume(aetools.NProperty):
- """volume - the volume on which the folder resides """
- which = 'volu'
- want = 'utxt'
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-
-disks = disk
-
-class folder(aetools.ComponentItem):
- """folder - A folder in the file system """
- want = 'cfol'
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-
-folders = folder
-
-class item(aetools.ComponentItem):
- """item - An item in the file system """
- want = 'cobj'
-class _Prop_busy_status(aetools.NProperty):
- """busy status - Is the item busy? """
- which = 'busy'
- want = 'bool'
-class _Prop_creation_date(aetools.NProperty):
- """creation date - the date on which the item was created """
- which = 'ascd'
- want = '****'
-class _Prop_modification_date(aetools.NProperty):
- """modification date - the date on which the item was last modified """
- which = 'asmo'
- want = '****'
-class _Prop_name_extension(aetools.NProperty):
- """name extension - the extension portion of the name """
- which = 'extn'
- want = 'utxt'
-class _Prop_package_folder(aetools.NProperty):
- """package folder - Is the item a package? """
- which = 'pkgf'
- want = 'bool'
-class _Prop_url(aetools.NProperty):
- """url - the url of the item """
- which = 'url '
- want = 'utxt'
-class _Prop_visible(aetools.NProperty):
- """visible - Is the item visible? """
- which = 'visi'
- want = 'bool'
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-
-items = item
-
-class file(aetools.ComponentItem):
- """file - A file in the file system """
- want = 'file'
-class _Prop_creator_type(aetools.NProperty):
- """creator type - the OSType identifying the application that created the item """
- which = 'fcrt'
- want = 'utxt'
-class _Prop_file_type(aetools.NProperty):
- """file type - the OSType identifying the type of data contained in the item """
- which = 'asty'
- want = 'utxt'
-class _Prop_physical_size(aetools.NProperty):
- """physical size - the actual space used by the file on disk """
- which = 'phys'
- want = 'magn'
-class _Prop_product_version(aetools.NProperty):
- """product version - the version of the product (visible at the top of the ?et Info?window) """
- which = 'ver2'
- want = 'utxt'
-class _Prop_size(aetools.NProperty):
- """size - the logical size of the file """
- which = 'ptsz'
- want = 'magn'
-class _Prop_stationery(aetools.NProperty):
- """stationery - Is the file a stationery pad? """
- which = 'pspd'
- want = 'bool'
-class _Prop_version(aetools.NProperty):
- """version - the version of the file (visible at the bottom of the ?et Info?window) """
- which = 'vers'
- want = 'utxt'
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-
-files = file
-application._superclassnames = []
-import Standard_Suite
-import Folder_Actions_Suite
-import Login_Items_Suite
-import Processes_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'folder_actions_enabled' : _Prop_folder_actions_enabled,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'application_process' : Processes_Suite.application_process,
- 'desk_accessory_process' : Processes_Suite.desk_accessory_process,
- 'disk' : disk,
- 'document' : Standard_Suite.document,
- 'file' : file,
- 'folder' : folder,
- 'folder_action' : Folder_Actions_Suite.folder_action,
- 'item' : item,
- 'login_item' : Login_Items_Suite.login_item,
- 'process' : Processes_Suite.process,
- 'window' : Standard_Suite.window,
-}
-disk._superclassnames = ['item']
-disk._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'capacity' : _Prop_capacity,
- 'ejectable' : _Prop_ejectable,
- 'format' : _Prop_format,
- 'free_space' : _Prop_free_space,
- 'ignore_privileges' : _Prop_ignore_privileges,
- 'local_volume' : _Prop_local_volume,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'properties' : _Prop_properties,
- 'startup' : _Prop_startup,
- 'volume' : _Prop_volume,
-}
-disk._privelemdict = {
- 'file' : file,
- 'folder' : folder,
- 'item' : item,
-}
-folder._superclassnames = ['item']
-folder._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'properties' : _Prop_properties,
- 'volume' : _Prop_volume,
-}
-folder._privelemdict = {
- 'file' : file,
- 'file' : file,
- 'folder' : folder,
- 'folder' : folder,
- 'item' : item,
- 'item' : item,
-}
-item._superclassnames = []
-item._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'busy_status' : _Prop_busy_status,
- 'creation_date' : _Prop_creation_date,
- 'modification_date' : _Prop_modification_date,
- 'name' : _Prop_name,
- 'name_extension' : _Prop_name_extension,
- 'package_folder' : _Prop_package_folder,
- 'path' : _Prop_path,
- 'properties' : _Prop_properties,
- 'url' : _Prop_url,
- 'visible' : _Prop_visible,
- 'volume' : _Prop_volume,
-}
-item._privelemdict = {
- 'file' : file,
- 'folder' : folder,
- 'item' : item,
-}
-file._superclassnames = ['item']
-file._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'creator_type' : _Prop_creator_type,
- 'file_type' : _Prop_file_type,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'physical_size' : _Prop_physical_size,
- 'product_version' : _Prop_product_version,
- 'properties' : _Prop_properties,
- 'size' : _Prop_size,
- 'stationery' : _Prop_stationery,
- 'version' : _Prop_version,
- 'volume' : _Prop_volume,
-}
-file._privelemdict = {
- 'file' : file,
- 'folder' : folder,
- 'item' : item,
-}
-_Enum_edfm = {
- 'MS_2d_DOS_format' : 'dfms', # MS-DOS format
- 'Apple_Photo_format' : 'dfph', # Apple Photo format
- 'ISO_9660_format' : 'df96', # ISO 9660 format
- 'QuickTake_format' : 'dfqt', # QuickTake format
- 'AppleShare_format' : 'dfas', # AppleShare format
- 'High_Sierra_format' : 'dfhs', # High Sierra format
- 'Mac_OS_Extended_format' : 'dfh+', # Mac OS Extended format
- 'UDF_format' : 'dfud', # UDF format
- 'unknown_format' : 'df??', # unknown format
- 'audio_format' : 'dfau', # audio format
- 'Mac_OS_format' : 'dfhf', # Mac OS format
- 'UFS_format' : 'dfuf', # UFS format
- 'NFS_format' : 'dfnf', # NFS format
- 'ProDOS_format' : 'dfpr', # ProDOS format
- 'WebDAV_format' : 'dfwd', # WebDAV format
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cdis' : disk,
- 'cfol' : folder,
- 'cobj' : item,
- 'file' : file,
-}
-
-_propdeclarations = {
- 'ascd' : _Prop_creation_date,
- 'asmo' : _Prop_modification_date,
- 'asty' : _Prop_file_type,
- 'busy' : _Prop_busy_status,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'capa' : _Prop_capacity,
- 'dfmt' : _Prop_format,
- 'extn' : _Prop_name_extension,
- 'faen' : _Prop_folder_actions_enabled,
- 'fcrt' : _Prop_creator_type,
- 'frsp' : _Prop_free_space,
- 'igpr' : _Prop_ignore_privileges,
- 'isej' : _Prop_ejectable,
- 'isrv' : _Prop_local_volume,
- 'istd' : _Prop_startup,
- 'pALL' : _Prop_properties,
- 'phys' : _Prop_physical_size,
- 'pkgf' : _Prop_package_folder,
- 'pnam' : _Prop_name,
- 'posx' : _Prop_POSIX_path,
- 'ppth' : _Prop_path,
- 'pspd' : _Prop_stationery,
- 'ptsz' : _Prop_size,
- 'url ' : _Prop_url,
- 'ver2' : _Prop_product_version,
- 'vers' : _Prop_version,
- 'visi' : _Prop_visible,
- 'volu' : _Prop_volume,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'edfm' : _Enum_edfm,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Folder_Actions_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Folder_Actions_Suite.py
deleted file mode 100644
index c2c7e5e0383..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Folder_Actions_Suite.py
+++ /dev/null
@@ -1,287 +0,0 @@
-"""Suite Folder Actions Suite: Terms and Events for controlling Folder Actions
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'faco'
-
-class Folder_Actions_Suite_Events:
-
- _argmap_attach_action_to = {
- 'using' : 'faal',
- }
-
- def attach_action_to(self, _object, _attributes={}, **_arguments):
- """attach action to: Attach an action to a folder
- Required argument: the object for the command
- Keyword argument using: a file containing the script to attach
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'faco'
- _subcode = 'atfa'
-
- aetools.keysubst(_arguments, self._argmap_attach_action_to)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def attached_scripts(self, _object, _attributes={}, **_arguments):
- """attached scripts: List the actions attached to a folder
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'faco'
- _subcode = 'lact'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_do_folder_action = {
- 'with_window_size' : 'fnsz',
- 'with_item_list' : 'flst',
- 'folder_action_code' : 'actn',
- }
-
- def do_folder_action(self, _object, _attributes={}, **_arguments):
- """do folder action: Event the Finder sends to the Folder Actions FBA
- Required argument: the object for the command
- Keyword argument with_window_size: the new window size for the folder action message to process
- Keyword argument with_item_list: a list of items for the folder action message to process
- Keyword argument folder_action_code: the folder action message to process
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'faco'
- _subcode = 'fola'
-
- aetools.keysubst(_arguments, self._argmap_do_folder_action)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'actn', _Enum_actn)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_edit_action_of = {
- 'using_action_name' : 'snam',
- 'using_action_number' : 'indx',
- }
-
- def edit_action_of(self, _object, _attributes={}, **_arguments):
- """edit action of: Edit as action of a folder
- Required argument: the object for the command
- Keyword argument using_action_name: ...or the name of the action to edit
- Keyword argument using_action_number: the index number of the action to edit...
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'faco'
- _subcode = 'edfa'
-
- aetools.keysubst(_arguments, self._argmap_edit_action_of)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_remove_action_from = {
- 'using_action_name' : 'snam',
- 'using_action_number' : 'indx',
- }
-
- def remove_action_from(self, _object, _attributes={}, **_arguments):
- """remove action from: Remove a folder action from a folder
- Required argument: the object for the command
- Keyword argument using_action_name: ...or the name of the action to remove
- Keyword argument using_action_number: the index number of the action to remove...
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'faco'
- _subcode = 'rmfa'
-
- aetools.keysubst(_arguments, self._argmap_remove_action_from)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The Folder Actions Suite host program """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_folder_actions_enabled(aetools.NProperty):
- """folder actions enabled - Are Folder Actions currently being processed? """
- which = 'faen'
- want = 'bool'
-folder_actions_enabled = _Prop_folder_actions_enabled()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the Folder Actions Suite host program """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cdis' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'foac' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'logi' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcap' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcda' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'prcs' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class folder_action(aetools.ComponentItem):
- """folder action - An action attached to a folder in the file system """
- want = 'foac'
-class _Prop_name(aetools.NProperty):
- """name - the name of the folder action, which is also the name of the folder """
- which = 'pnam'
- want = 'utxt'
-class _Prop_path(aetools.NProperty):
- """path - the path to the folder to which the folder action applies """
- which = 'ppth'
- want = '****'
-class _Prop_volume(aetools.NProperty):
- """volume - the volume on which the folder action resides """
- which = 'volu'
- want = 'utxt'
-# element 'scpt' as ['name', 'indx', 'rele', 'rang', 'test']
-
-folder_actions = folder_action
-
-class script(aetools.ComponentItem):
- """script - A script invoked by a folder action """
- want = 'scpt'
-class _Prop_POSIX_path(aetools.NProperty):
- """POSIX path - the POSIX file system path of the disk """
- which = 'posx'
- want = 'utxt'
-
-scripts = script
-application._superclassnames = []
-import Disk_Folder_File_Suite
-import Standard_Suite
-import Login_Items_Suite
-import Processes_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'folder_actions_enabled' : _Prop_folder_actions_enabled,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'application_process' : Processes_Suite.application_process,
- 'desk_accessory_process' : Processes_Suite.desk_accessory_process,
- 'disk' : Disk_Folder_File_Suite.disk,
- 'document' : Standard_Suite.document,
- 'file' : Disk_Folder_File_Suite.file,
- 'folder' : Disk_Folder_File_Suite.folder,
- 'folder_action' : folder_action,
- 'item' : Disk_Folder_File_Suite.item,
- 'login_item' : Login_Items_Suite.login_item,
- 'process' : Processes_Suite.process,
- 'window' : Standard_Suite.window,
-}
-folder_action._superclassnames = ['item']
-folder_action._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'properties' : _Prop_properties,
- 'volume' : _Prop_volume,
-}
-folder_action._privelemdict = {
- 'script' : script,
-}
-script._superclassnames = ['item']
-script._privpropdict = {
- 'POSIX_path' : _Prop_POSIX_path,
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
- 'properties' : _Prop_properties,
-}
-script._privelemdict = {
-}
-_Enum_actn = {
- 'items_added' : 'fget', # items added
- 'items_removed' : 'flos', # items removed
- 'window_closed' : 'fclo', # window closed
- 'window_moved' : 'fsiz', # window moved
- 'window_opened' : 'fopn', # window opened
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'foac' : folder_action,
- 'scpt' : script,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'faen' : _Prop_folder_actions_enabled,
- 'pALL' : _Prop_properties,
- 'pnam' : _Prop_name,
- 'posx' : _Prop_POSIX_path,
- 'ppth' : _Prop_path,
- 'volu' : _Prop_volume,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'actn' : _Enum_actn,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Hidden_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Hidden_Suite.py
deleted file mode 100644
index e80ace1e51d..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Hidden_Suite.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""Suite Hidden Suite: Hidden Terms and Events for controlling the System Events application
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'tpnm'
-
-from StdSuites.Type_Names_Suite import *
-class Hidden_Suite_Events(Type_Names_Suite_Events):
-
- def do_script(self, _object, _attributes={}, **_arguments):
- """do script: Execute an OSA script.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'dosc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Login_Items_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Login_Items_Suite.py
deleted file mode 100644
index ed09245157a..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Login_Items_Suite.py
+++ /dev/null
@@ -1,74 +0,0 @@
-"""Suite Login Items Suite: Terms and Events for controlling the Login Items application
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'logi'
-
-class Login_Items_Suite_Events:
-
- pass
-
-
-class login_item(aetools.ComponentItem):
- """login item - an item to be launched or opened at login """
- want = 'logi'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'cobj'
-class _Prop_hidden(aetools.NProperty):
- """hidden - Is the Login Item hidden when launched? """
- which = 'hidn'
- want = 'bool'
-class _Prop_kind(aetools.NProperty):
- """kind - the file type of the Login Item """
- which = 'kind'
- want = 'utxt'
-class _Prop_name(aetools.NProperty):
- """name - the name of the Login Item """
- which = 'pnam'
- want = 'utxt'
-class _Prop_path(aetools.NProperty):
- """path - the file system path to the Login Item """
- which = 'ppth'
- want = 'utxt'
-
-login_items = login_item
-import Standard_Suite
-login_item._superclassnames = ['item']
-login_item._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'hidden' : _Prop_hidden,
- 'kind' : _Prop_kind,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
-}
-login_item._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'logi' : login_item,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'hidn' : _Prop_hidden,
- 'kind' : _Prop_kind,
- 'pnam' : _Prop_name,
- 'ppth' : _Prop_path,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Power_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Power_Suite.py
deleted file mode 100644
index ef539b1e033..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Power_Suite.py
+++ /dev/null
@@ -1,149 +0,0 @@
-"""Suite Power Suite: Terms and Events for controlling System power
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'powr'
-
-class Power_Suite_Events:
-
- def restart(self, _object, _attributes={}, **_arguments):
- """restart: Restart the computer
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'rest'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def shut_down(self, _object, _attributes={}, **_arguments):
- """shut down: Shut Down the computer
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'shut'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def sleep(self, _object, _attributes={}, **_arguments):
- """sleep: Put the computer to sleep
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'fndr'
- _subcode = 'slep'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The System Events application """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_folder_actions_enabled(aetools.NProperty):
- """folder actions enabled - Are Folder Actions currently being processed? """
- which = 'faen'
- want = 'bool'
-folder_actions_enabled = _Prop_folder_actions_enabled()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the System Events application """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cdis' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'foac' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'logi' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcap' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcda' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'prcs' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-application._superclassnames = []
-import Disk_Folder_File_Suite
-import Standard_Suite
-import Folder_Actions_Suite
-import Login_Items_Suite
-import Processes_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'folder_actions_enabled' : _Prop_folder_actions_enabled,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'application_process' : Processes_Suite.application_process,
- 'desk_accessory_process' : Processes_Suite.desk_accessory_process,
- 'disk' : Disk_Folder_File_Suite.disk,
- 'document' : Standard_Suite.document,
- 'file' : Disk_Folder_File_Suite.file,
- 'folder' : Disk_Folder_File_Suite.folder,
- 'folder_action' : Folder_Actions_Suite.folder_action,
- 'item' : Disk_Folder_File_Suite.item,
- 'login_item' : Login_Items_Suite.login_item,
- 'process' : Processes_Suite.process,
- 'window' : Standard_Suite.window,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'faen' : _Prop_folder_actions_enabled,
- 'pALL' : _Prop_properties,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py
deleted file mode 100644
index 9dcb85fb2f9..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Processes_Suite.py
+++ /dev/null
@@ -1,214 +0,0 @@
-"""Suite Processes Suite: Terms and Events for controlling Processes
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'prcs'
-
-class Processes_Suite_Events:
-
- pass
-
-
-class application(aetools.ComponentItem):
- """application - The Processes Suite host program """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_folder_actions_enabled(aetools.NProperty):
- """folder actions enabled - Are Folder Actions currently being processed? """
- which = 'faen'
- want = 'bool'
-folder_actions_enabled = _Prop_folder_actions_enabled()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the Processes Suite host program """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cdis' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'foac' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'logi' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcap' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcda' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'prcs' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class application_process(aetools.ComponentItem):
- """application process - A process launched from an application file """
- want = 'pcap'
-class _Prop_application_file(aetools.NProperty):
- """application file - a reference to the application file from which this process was launched """
- which = 'appf'
- want = '****'
-
-application_processes = application_process
-
-class desk_accessory_process(aetools.ComponentItem):
- """desk accessory process - A process launched from an desk accessory file """
- want = 'pcda'
-class _Prop_desk_accessory_file(aetools.NProperty):
- """desk accessory file - a reference to the desk accessory file from which this process was launched """
- which = 'dafi'
- want = '****'
-
-desk_accessory_processes = desk_accessory_process
-
-class process(aetools.ComponentItem):
- """process - A process running on this computer """
- want = 'prcs'
-class _Prop_accepts_high_level_events(aetools.NProperty):
- """accepts high level events - Is the process high-level event aware (accepts open application, open document, print document, and quit)? """
- which = 'isab'
- want = 'bool'
-class _Prop_accepts_remote_events(aetools.NProperty):
- """accepts remote events - Does the process accept remote events? """
- which = 'revt'
- want = 'bool'
-class _Prop_classic(aetools.NProperty):
- """classic - Is the process running in the Classic environment? """
- which = 'clsc'
- want = 'bool'
-class _Prop_creator_type(aetools.NProperty):
- """creator type - the OSType of the creator of the process (the signature) """
- which = 'fcrt'
- want = 'utxt'
-class _Prop_file(aetools.NProperty):
- """file - the file from which the process was launched """
- which = 'file'
- want = '****'
-class _Prop_file_type(aetools.NProperty):
- """file type - the OSType of the file type of the process """
- which = 'asty'
- want = 'utxt'
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is the process the frontmost process """
- which = 'pisf'
- want = 'bool'
-class _Prop_has_scripting_terminology(aetools.NProperty):
- """has scripting terminology - Does the process have a scripting terminology, i.e., can it be scripted? """
- which = 'hscr'
- want = 'bool'
-class _Prop_name(aetools.NProperty):
- """name - the name of the process """
- which = 'pnam'
- want = 'utxt'
-class _Prop_partition_space_used(aetools.NProperty):
- """partition space used - the number of bytes currently used in the process' partition """
- which = 'pusd'
- want = 'magn'
-class _Prop_total_partition_size(aetools.NProperty):
- """total partition size - the size of the partition with which the process was launched """
- which = 'appt'
- want = 'magn'
-class _Prop_visible(aetools.NProperty):
- """visible - Is the process' layer visible? """
- which = 'pvis'
- want = 'bool'
-
-processes = process
-application._superclassnames = []
-import Disk_Folder_File_Suite
-import Standard_Suite
-import Folder_Actions_Suite
-import Login_Items_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'folder_actions_enabled' : _Prop_folder_actions_enabled,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'application_process' : application_process,
- 'desk_accessory_process' : desk_accessory_process,
- 'disk' : Disk_Folder_File_Suite.disk,
- 'document' : Standard_Suite.document,
- 'file' : Disk_Folder_File_Suite.file,
- 'folder' : Disk_Folder_File_Suite.folder,
- 'folder_action' : Folder_Actions_Suite.folder_action,
- 'item' : Disk_Folder_File_Suite.item,
- 'login_item' : Login_Items_Suite.login_item,
- 'process' : process,
- 'window' : Standard_Suite.window,
-}
-application_process._superclassnames = ['process']
-application_process._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'application_file' : _Prop_application_file,
-}
-application_process._privelemdict = {
-}
-desk_accessory_process._superclassnames = ['process']
-desk_accessory_process._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'desk_accessory_file' : _Prop_desk_accessory_file,
-}
-desk_accessory_process._privelemdict = {
-}
-process._superclassnames = ['item']
-process._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'accepts_high_level_events' : _Prop_accepts_high_level_events,
- 'accepts_remote_events' : _Prop_accepts_remote_events,
- 'classic' : _Prop_classic,
- 'creator_type' : _Prop_creator_type,
- 'file' : _Prop_file,
- 'file_type' : _Prop_file_type,
- 'frontmost' : _Prop_frontmost,
- 'has_scripting_terminology' : _Prop_has_scripting_terminology,
- 'name' : _Prop_name,
- 'partition_space_used' : _Prop_partition_space_used,
- 'properties' : _Prop_properties,
- 'total_partition_size' : _Prop_total_partition_size,
- 'visible' : _Prop_visible,
-}
-process._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'pcap' : application_process,
- 'pcda' : desk_accessory_process,
- 'prcs' : process,
-}
-
-_propdeclarations = {
- 'appf' : _Prop_application_file,
- 'appt' : _Prop_total_partition_size,
- 'asty' : _Prop_file_type,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'clsc' : _Prop_classic,
- 'dafi' : _Prop_desk_accessory_file,
- 'faen' : _Prop_folder_actions_enabled,
- 'fcrt' : _Prop_creator_type,
- 'file' : _Prop_file,
- 'hscr' : _Prop_has_scripting_terminology,
- 'isab' : _Prop_accepts_high_level_events,
- 'pALL' : _Prop_properties,
- 'pisf' : _Prop_frontmost,
- 'pnam' : _Prop_name,
- 'pusd' : _Prop_partition_space_used,
- 'pvis' : _Prop_visible,
- 'revt' : _Prop_accepts_remote_events,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Standard_Suite.py
deleted file mode 100644
index 0ec16c08003..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Standard_Suite.py
+++ /dev/null
@@ -1,582 +0,0 @@
-"""Suite Standard Suite: Common classes and commands for most applications.
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = '????'
-
-class Standard_Suite_Events:
-
- _argmap_close = {
- 'saving_in' : 'kfil',
- 'saving' : 'savo',
- }
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: Close an object.
- Required argument: the object for the command
- Keyword argument saving_in: The file in which to save the object.
- Keyword argument saving: Specifies whether changes should be saved before closing.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- aetools.keysubst(_arguments, self._argmap_close)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_count = {
- 'each' : 'kocl',
- }
-
- def count(self, _object, _attributes={}, **_arguments):
- """count: Return the number of elements of a particular class within an object.
- Required argument: the object for the command
- Keyword argument each: The class of objects to be counted.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'cnte'
-
- aetools.keysubst(_arguments, self._argmap_count)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def delete(self, _object, _attributes={}, **_arguments):
- """delete: Delete an object.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'delo'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_duplicate = {
- 'to' : 'insh',
- 'with_properties' : 'prdt',
- }
-
- def duplicate(self, _object, _attributes={}, **_arguments):
- """duplicate: Copy object(s) and put the copies at a new location.
- Required argument: the object for the command
- Keyword argument to: The location for the new object(s).
- Keyword argument with_properties: Properties to be set in the new duplicated object(s).
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clon'
-
- aetools.keysubst(_arguments, self._argmap_duplicate)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def exists(self, _object, _attributes={}, **_arguments):
- """exists: Verify if an object exists.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'doex'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def get(self, _object, _attributes={}, **_arguments):
- """get: Get the data for an object.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'getd'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_make = {
- 'at' : 'insh',
- 'new' : 'kocl',
- 'with_data' : 'data',
- 'with_properties' : 'prdt',
- }
-
- def make(self, _no_object=None, _attributes={}, **_arguments):
- """make: Make a new object.
- Keyword argument at: The location at which to insert the object.
- Keyword argument new: The class of the new object.
- Keyword argument with_data: The initial data for the object.
- Keyword argument with_properties: The initial values for properties of the object.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'crel'
-
- aetools.keysubst(_arguments, self._argmap_make)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_move = {
- 'to' : 'insh',
- }
-
- def move(self, _object, _attributes={}, **_arguments):
- """move: Move object(s) to a new location.
- Required argument: the object for the command
- Keyword argument to: The new location for the object(s).
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'move'
-
- aetools.keysubst(_arguments, self._argmap_move)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def open(self, _object=None, _attributes={}, **_arguments):
- """open: Open an object.
- Required argument: list of objects
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def print_(self, _object=None, _attributes={}, **_arguments):
- """print: Print an object.
- Required argument: list of objects
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_quit = {
- 'saving' : 'savo',
- }
-
- def quit(self, _object, _attributes={}, **_arguments):
- """quit: Quit an application.
- Required argument: the object for the command
- Keyword argument saving: Specifies whether changes should be saved before quitting.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- aetools.keysubst(_arguments, self._argmap_quit)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_save = {
- 'in_' : 'kfil',
- 'as' : 'fltp',
- }
-
- def save(self, _object, _attributes={}, **_arguments):
- """save: Save an object.
- Required argument: the object for the command
- Keyword argument in_: The file in which to save the object.
- Keyword argument as: The file type in which to save the data.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'save'
-
- aetools.keysubst(_arguments, self._argmap_save)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_set = {
- 'to' : 'data',
- }
-
- def set(self, _object, _attributes={}, **_arguments):
- """set: Set an object's data.
- Required argument: the object for the command
- Keyword argument to: The new value.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'setd'
-
- aetools.keysubst(_arguments, self._argmap_set)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - An application's top level scripting object. """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'cobj'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is this the frontmost (active) application? """
- which = 'pisf'
- want = 'bool'
-frontmost = _Prop_frontmost()
-class _Prop_name(aetools.NProperty):
- """name - The name of the application. """
- which = 'pnam'
- want = 'utxt'
-name = _Prop_name()
-class _Prop_version(aetools.NProperty):
- """version - The version of the application. """
- which = 'vers'
- want = 'utxt'
-version = _Prop_version()
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class item(aetools.ComponentItem):
- """item - A scriptable object. """
- want = 'cobj'
-class _Prop_class_(aetools.NProperty):
- """class - The class of the object. """
- which = 'pcls'
- want = 'type'
-class _Prop_properties(aetools.NProperty):
- """properties - All of the object's properties. """
- which = 'pALL'
- want = 'reco'
-
-items = item
-
-class color(aetools.ComponentItem):
- """color - A color. """
- want = 'colr'
-
-colors = color
-
-class window(aetools.ComponentItem):
- """window - A window. """
- want = 'cwin'
-class _Prop_bounds(aetools.NProperty):
- """bounds - The bounding rectangle of the window. """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_closeable(aetools.NProperty):
- """closeable - Whether the window has a close box. """
- which = 'hclb'
- want = 'bool'
-class _Prop_document(aetools.NProperty):
- """document - The document whose contents are being displayed in the window. """
- which = 'docu'
- want = 'docu'
-class _Prop_floating(aetools.NProperty):
- """floating - Whether the window floats. """
- which = 'isfl'
- want = 'bool'
-class _Prop_id(aetools.NProperty):
- """id - The unique identifier of the window. """
- which = 'ID '
- want = 'long'
-class _Prop_index(aetools.NProperty):
- """index - The index of the window in the back-to-front window ordering. """
- which = 'pidx'
- want = 'long'
-class _Prop_miniaturizable(aetools.NProperty):
- """miniaturizable - Whether the window can be miniaturized. """
- which = 'ismn'
- want = 'bool'
-class _Prop_miniaturized(aetools.NProperty):
- """miniaturized - Whether the window is currently miniaturized. """
- which = 'pmnd'
- want = 'bool'
-class _Prop_modal(aetools.NProperty):
- """modal - Whether the window is the application's current modal window. """
- which = 'pmod'
- want = 'bool'
-class _Prop_resizable(aetools.NProperty):
- """resizable - Whether the window can be resized. """
- which = 'prsz'
- want = 'bool'
-class _Prop_titled(aetools.NProperty):
- """titled - Whether the window has a title bar. """
- which = 'ptit'
- want = 'bool'
-class _Prop_visible(aetools.NProperty):
- """visible - Whether the window is currently visible. """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomable(aetools.NProperty):
- """zoomable - Whether the window can be zoomed. """
- which = 'iszm'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Whether the window is currently zoomed. """
- which = 'pzum'
- want = 'bool'
-
-windows = window
-
-class document(aetools.ComponentItem):
- """document - A document. """
- want = 'docu'
-class _Prop_modified(aetools.NProperty):
- """modified - Has the document been modified since the last save? """
- which = 'imod'
- want = 'bool'
-class _Prop_path(aetools.NProperty):
- """path - The document's path. """
- which = 'ppth'
- want = 'utxt'
-
-documents = document
-application._superclassnames = ['item']
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'frontmost' : _Prop_frontmost,
- 'name' : _Prop_name,
- 'version' : _Prop_version,
-}
-application._privelemdict = {
- 'document' : document,
- 'window' : window,
-}
-item._superclassnames = []
-item._privpropdict = {
- 'class_' : _Prop_class_,
- 'properties' : _Prop_properties,
-}
-item._privelemdict = {
-}
-color._superclassnames = ['item']
-color._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-color._privelemdict = {
-}
-window._superclassnames = ['item']
-window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'bounds' : _Prop_bounds,
- 'closeable' : _Prop_closeable,
- 'document' : _Prop_document,
- 'floating' : _Prop_floating,
- 'id' : _Prop_id,
- 'index' : _Prop_index,
- 'miniaturizable' : _Prop_miniaturizable,
- 'miniaturized' : _Prop_miniaturized,
- 'modal' : _Prop_modal,
- 'name' : _Prop_name,
- 'resizable' : _Prop_resizable,
- 'titled' : _Prop_titled,
- 'visible' : _Prop_visible,
- 'zoomable' : _Prop_zoomable,
- 'zoomed' : _Prop_zoomed,
-}
-window._privelemdict = {
-}
-document._superclassnames = ['item']
-document._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'modified' : _Prop_modified,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
-}
-document._privelemdict = {
-}
-class _3c_(aetools.NComparison):
- """< - Less than """
-class _3d_(aetools.NComparison):
- """= - Equal """
-class _3e_(aetools.NComparison):
- """> - Greater than """
-class contains(aetools.NComparison):
- """contains - Contains """
-class ends_with(aetools.NComparison):
- """ends with - Ends with """
-class starts_with(aetools.NComparison):
- """starts with - Starts with """
-class _b2_(aetools.NComparison):
- """\xb2 - Less than or equal to """
-class _b3_(aetools.NComparison):
- """\xb3 - Greater than or equal to """
-_Enum_savo = {
- 'ask' : 'ask ', # Ask the user whether or not to save the file.
- 'yes' : 'yes ', # Save the file.
- 'no' : 'no ', # Do not save the file.
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cobj' : item,
- 'colr' : color,
- 'cwin' : window,
- 'docu' : document,
-}
-
-_propdeclarations = {
- 'ID ' : _Prop_id,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'docu' : _Prop_document,
- 'hclb' : _Prop_closeable,
- 'imod' : _Prop_modified,
- 'isfl' : _Prop_floating,
- 'ismn' : _Prop_miniaturizable,
- 'iszm' : _Prop_zoomable,
- 'pALL' : _Prop_properties,
- 'pbnd' : _Prop_bounds,
- 'pcls' : _Prop_class_,
- 'pidx' : _Prop_index,
- 'pisf' : _Prop_frontmost,
- 'pmnd' : _Prop_miniaturized,
- 'pmod' : _Prop_modal,
- 'pnam' : _Prop_name,
- 'ppth' : _Prop_path,
- 'prsz' : _Prop_resizable,
- 'ptit' : _Prop_titled,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
- 'vers' : _Prop_version,
-}
-
-_compdeclarations = {
- '< ' : _3c_,
- '<= ' : _b2_,
- '= ' : _3d_,
- '> ' : _3e_,
- '>= ' : _b3_,
- 'bgwt' : starts_with,
- 'cont' : contains,
- 'ends' : ends_with,
-}
-
-_enumdeclarations = {
- 'savo' : _Enum_savo,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/System_Events_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/System_Events_Suite.py
deleted file mode 100644
index d5b4bfc6e7d..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/System_Events_Suite.py
+++ /dev/null
@@ -1,109 +0,0 @@
-"""Suite System Events Suite: Terms and Events for controlling the System Events application
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'sevs'
-
-class System_Events_Suite_Events:
-
- def do_script(self, _object, _attributes={}, **_arguments):
- """do script: Execute an OSA script.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'misc'
- _subcode = 'dosc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The System Events application """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_folder_actions_enabled(aetools.NProperty):
- """folder actions enabled - Are Folder Actions currently being processed? """
- which = 'faen'
- want = 'bool'
-folder_actions_enabled = _Prop_folder_actions_enabled()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the System Events application """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cdis' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cfol' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cobj' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'file' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'foac' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'logi' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcap' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'pcda' as ['name', 'indx', 'rele', 'rang', 'test']
-# element 'prcs' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-application._superclassnames = []
-import Disk_Folder_File_Suite
-import Standard_Suite
-import Folder_Actions_Suite
-import Login_Items_Suite
-import Processes_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'folder_actions_enabled' : _Prop_folder_actions_enabled,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'application_process' : Processes_Suite.application_process,
- 'desk_accessory_process' : Processes_Suite.desk_accessory_process,
- 'disk' : Disk_Folder_File_Suite.disk,
- 'document' : Standard_Suite.document,
- 'file' : Disk_Folder_File_Suite.file,
- 'folder' : Disk_Folder_File_Suite.folder,
- 'folder_action' : Folder_Actions_Suite.folder_action,
- 'item' : Disk_Folder_File_Suite.item,
- 'login_item' : Login_Items_Suite.login_item,
- 'process' : Processes_Suite.process,
- 'window' : Standard_Suite.window,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
-}
-
-_propdeclarations = {
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'faen' : _Prop_folder_actions_enabled,
- 'pALL' : _Prop_properties,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Text_Suite.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/Text_Suite.py
deleted file mode 100644
index 9f109e111e1..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/Text_Suite.py
+++ /dev/null
@@ -1,195 +0,0 @@
-"""Suite Text Suite: A set of basic classes for text processing.
-Level 1, version 1
-
-Generated from /System/Library/CoreServices/System Events.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = '????'
-
-class Text_Suite_Events:
-
- pass
-
-
-class attachment(aetools.ComponentItem):
- """attachment - Represents an inline text attachment. This class is used mainly for make commands. """
- want = 'atts'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'ctxt'
-class _Prop_file_name(aetools.NProperty):
- """file name - The path to the file for the attachment """
- which = 'atfn'
- want = 'utxt'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-class attribute_run(aetools.ComponentItem):
- """attribute run - This subdivides the text into chunks that all have the same attributes. """
- want = 'catr'
-class _Prop_color(aetools.NProperty):
- """color - The color of the first character. """
- which = 'colr'
- want = 'colr'
-class _Prop_font(aetools.NProperty):
- """font - The name of the font of the first character. """
- which = 'font'
- want = 'utxt'
-class _Prop_size(aetools.NProperty):
- """size - The size in points of the first character. """
- which = 'ptsz'
- want = 'long'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-attribute_runs = attribute_run
-
-class character(aetools.ComponentItem):
- """character - This subdivides the text into characters. """
- want = 'cha '
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-characters = character
-
-class paragraph(aetools.ComponentItem):
- """paragraph - This subdivides the text into paragraphs. """
- want = 'cpar'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-paragraphs = paragraph
-
-class text(aetools.ComponentItem):
- """text - Rich (styled) text """
- want = 'ctxt'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-class word(aetools.ComponentItem):
- """word - This subdivides the text into words. """
- want = 'cwor'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-words = word
-attachment._superclassnames = ['text']
-attachment._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'file_name' : _Prop_file_name,
-}
-attachment._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-import Standard_Suite
-attribute_run._superclassnames = ['item']
-attribute_run._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-attribute_run._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-character._superclassnames = ['item']
-character._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-character._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-paragraph._superclassnames = ['item']
-paragraph._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-paragraph._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-text._superclassnames = ['item']
-text._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-text._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-word._superclassnames = ['item']
-word._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-word._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'atts' : attachment,
- 'catr' : attribute_run,
- 'cha ' : character,
- 'cpar' : paragraph,
- 'ctxt' : text,
- 'cwor' : word,
-}
-
-_propdeclarations = {
- 'atfn' : _Prop_file_name,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'colr' : _Prop_color,
- 'font' : _Prop_font,
- 'ptsz' : _Prop_size,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py b/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
deleted file mode 100644
index 80ce28ee6c2..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/SystemEvents/__init__.py
+++ /dev/null
@@ -1,144 +0,0 @@
-"""
-Package generated from /System/Library/CoreServices/System Events.app
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the SystemEvents package is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Standard_Suite
-import Text_Suite
-import Disk_Folder_File_Suite
-import Folder_Actions_Suite
-import Login_Items_Suite
-import Power_Suite
-import Processes_Suite
-import System_Events_Suite
-
-
-_code_to_module = {
- '????' : Standard_Suite,
- '????' : Text_Suite,
- 'cdis' : Disk_Folder_File_Suite,
- 'faco' : Folder_Actions_Suite,
- 'logi' : Login_Items_Suite,
- 'powr' : Power_Suite,
- 'prcs' : Processes_Suite,
- 'sevs' : System_Events_Suite,
-}
-
-
-
-_code_to_fullname = {
- '????' : ('SystemEvents.Standard_Suite', 'Standard_Suite'),
- '????' : ('SystemEvents.Text_Suite', 'Text_Suite'),
- 'cdis' : ('SystemEvents.Disk_Folder_File_Suite', 'Disk_Folder_File_Suite'),
- 'faco' : ('SystemEvents.Folder_Actions_Suite', 'Folder_Actions_Suite'),
- 'logi' : ('SystemEvents.Login_Items_Suite', 'Login_Items_Suite'),
- 'powr' : ('SystemEvents.Power_Suite', 'Power_Suite'),
- 'prcs' : ('SystemEvents.Processes_Suite', 'Processes_Suite'),
- 'sevs' : ('SystemEvents.System_Events_Suite', 'System_Events_Suite'),
-}
-
-from Standard_Suite import *
-from Text_Suite import *
-from Disk_Folder_File_Suite import *
-from Folder_Actions_Suite import *
-from Login_Items_Suite import *
-from Power_Suite import *
-from Processes_Suite import *
-from System_Events_Suite import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(login_item)
-getbaseclasses(color)
-getbaseclasses(window)
-getbaseclasses(application)
-getbaseclasses(item)
-getbaseclasses(document)
-getbaseclasses(character)
-getbaseclasses(attachment)
-getbaseclasses(paragraph)
-getbaseclasses(word)
-getbaseclasses(attribute_run)
-getbaseclasses(text)
-getbaseclasses(file)
-getbaseclasses(application)
-getbaseclasses(item)
-getbaseclasses(folder)
-getbaseclasses(disk)
-getbaseclasses(script)
-getbaseclasses(application)
-getbaseclasses(folder_action)
-getbaseclasses(application)
-getbaseclasses(application)
-getbaseclasses(process)
-getbaseclasses(application_process)
-getbaseclasses(desk_accessory_process)
-getbaseclasses(application)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'logi' : login_item,
- 'colr' : color,
- 'cwin' : window,
- 'capp' : application,
- 'cobj' : item,
- 'docu' : document,
- 'cha ' : character,
- 'atts' : attachment,
- 'cpar' : paragraph,
- 'cwor' : word,
- 'catr' : attribute_run,
- 'ctxt' : text,
- 'file' : file,
- 'capp' : application,
- 'cobj' : item,
- 'cfol' : folder,
- 'cdis' : disk,
- 'scpt' : script,
- 'capp' : application,
- 'foac' : folder_action,
- 'capp' : application,
- 'capp' : application,
- 'prcs' : process,
- 'pcap' : application_process,
- 'pcda' : desk_accessory_process,
- 'capp' : application,
-}
-
-
-class SystemEvents(Standard_Suite_Events,
- Text_Suite_Events,
- Disk_Folder_File_Suite_Events,
- Folder_Actions_Suite_Events,
- Login_Items_Suite_Events,
- Power_Suite_Events,
- Processes_Suite_Events,
- System_Events_Suite_Events,
- aetools.TalkTo):
- _signature = 'sevs'
-
- _moduleName = 'SystemEvents'
-
- _elemdict = application._elemdict
- _propdict = application._propdict
diff --git a/Lib/plat-mac/lib-scriptpackages/Terminal/Standard_Suite.py b/Lib/plat-mac/lib-scriptpackages/Terminal/Standard_Suite.py
deleted file mode 100644
index e42528ca742..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Terminal/Standard_Suite.py
+++ /dev/null
@@ -1,582 +0,0 @@
-"""Suite Standard Suite: Common classes and commands for most applications.
-Level 1, version 1
-
-Generated from /Applications/Utilities/Terminal.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = '????'
-
-class Standard_Suite_Events:
-
- _argmap_close = {
- 'saving_in' : 'kfil',
- 'saving' : 'savo',
- }
-
- def close(self, _object, _attributes={}, **_arguments):
- """close: Close an object.
- Required argument: the object for the command
- Keyword argument saving_in: The file in which to save the object.
- Keyword argument saving: Specifies whether changes should be saved before closing.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clos'
-
- aetools.keysubst(_arguments, self._argmap_close)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_count = {
- 'each' : 'kocl',
- }
-
- def count(self, _object, _attributes={}, **_arguments):
- """count: Return the number of elements of a particular class within an object.
- Required argument: the object for the command
- Keyword argument each: The class of objects to be counted.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'cnte'
-
- aetools.keysubst(_arguments, self._argmap_count)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def delete(self, _object, _attributes={}, **_arguments):
- """delete: Delete an object.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'delo'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_duplicate = {
- 'to' : 'insh',
- 'with_properties' : 'prdt',
- }
-
- def duplicate(self, _object, _attributes={}, **_arguments):
- """duplicate: Copy object(s) and put the copies at a new location.
- Required argument: the object for the command
- Keyword argument to: The location for the new object(s).
- Keyword argument with_properties: Properties to be set in the new duplicated object(s).
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'clon'
-
- aetools.keysubst(_arguments, self._argmap_duplicate)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def exists(self, _object, _attributes={}, **_arguments):
- """exists: Verify if an object exists.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'doex'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def get(self, _object, _attributes={}, **_arguments):
- """get: Get the data for an object.
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'getd'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_make = {
- 'at' : 'insh',
- 'new' : 'kocl',
- 'with_data' : 'data',
- 'with_properties' : 'prdt',
- }
-
- def make(self, _no_object=None, _attributes={}, **_arguments):
- """make: Make a new object.
- Keyword argument at: The location at which to insert the object.
- Keyword argument new: The class of the new object.
- Keyword argument with_data: The initial data for the object.
- Keyword argument with_properties: The initial values for properties of the object.
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'crel'
-
- aetools.keysubst(_arguments, self._argmap_make)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_move = {
- 'to' : 'insh',
- }
-
- def move(self, _object, _attributes={}, **_arguments):
- """move: Move object(s) to a new location.
- Required argument: the object for the command
- Keyword argument to: The new location for the object(s).
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'move'
-
- aetools.keysubst(_arguments, self._argmap_move)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def open(self, _object=None, _attributes={}, **_arguments):
- """open: Open an object.
- Required argument: list of objects
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def print_(self, _object=None, _attributes={}, **_arguments):
- """print: Print an object.
- Required argument: list of objects
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_quit = {
- 'saving' : 'savo',
- }
-
- def quit(self, _object, _attributes={}, **_arguments):
- """quit: Quit an application.
- Required argument: the object for the command
- Keyword argument saving: Specifies whether changes should be saved before quitting.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- aetools.keysubst(_arguments, self._argmap_quit)
- _arguments['----'] = _object
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_save = {
- 'in_' : 'kfil',
- 'as' : 'fltp',
- }
-
- def save(self, _object, _attributes={}, **_arguments):
- """save: Save an object.
- Required argument: the object for the command
- Keyword argument in_: The file in which to save the object.
- Keyword argument as: The file type in which to save the data.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'save'
-
- aetools.keysubst(_arguments, self._argmap_save)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_set = {
- 'to' : 'data',
- }
-
- def set(self, _object, _attributes={}, **_arguments):
- """set: Set an object's data.
- Required argument: the object for the command
- Keyword argument to: The new value.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'core'
- _subcode = 'setd'
-
- aetools.keysubst(_arguments, self._argmap_set)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - An application's top level scripting object. """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'cobj'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is this the frontmost (active) application? """
- which = 'pisf'
- want = 'bool'
-frontmost = _Prop_frontmost()
-class _Prop_name(aetools.NProperty):
- """name - The name of the application. """
- which = 'pnam'
- want = 'utxt'
-name = _Prop_name()
-class _Prop_version(aetools.NProperty):
- """version - The version of the application. """
- which = 'vers'
- want = 'utxt'
-version = _Prop_version()
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class item(aetools.ComponentItem):
- """item - A scriptable object. """
- want = 'cobj'
-class _Prop_class_(aetools.NProperty):
- """class - The class of the object. """
- which = 'pcls'
- want = 'type'
-class _Prop_properties(aetools.NProperty):
- """properties - All of the object's properties. """
- which = 'pALL'
- want = 'reco'
-
-items = item
-
-class color(aetools.ComponentItem):
- """color - A color. """
- want = 'colr'
-
-colors = color
-
-class window(aetools.ComponentItem):
- """window - A window. """
- want = 'cwin'
-class _Prop_bounds(aetools.NProperty):
- """bounds - The bounding rectangle of the window. """
- which = 'pbnd'
- want = 'qdrt'
-class _Prop_closeable(aetools.NProperty):
- """closeable - Whether the window has a close box. """
- which = 'hclb'
- want = 'bool'
-class _Prop_document(aetools.NProperty):
- """document - The document whose contents are being displayed in the window. """
- which = 'docu'
- want = 'docu'
-class _Prop_floating(aetools.NProperty):
- """floating - Whether the window floats. """
- which = 'isfl'
- want = 'bool'
-class _Prop_id(aetools.NProperty):
- """id - The unique identifier of the window. """
- which = 'ID '
- want = 'long'
-class _Prop_index(aetools.NProperty):
- """index - The index of the window in the back-to-front window ordering. """
- which = 'pidx'
- want = 'long'
-class _Prop_miniaturizable(aetools.NProperty):
- """miniaturizable - Whether the window can be miniaturized. """
- which = 'ismn'
- want = 'bool'
-class _Prop_miniaturized(aetools.NProperty):
- """miniaturized - Whether the window is currently miniaturized. """
- which = 'pmnd'
- want = 'bool'
-class _Prop_modal(aetools.NProperty):
- """modal - Whether the window is the application's current modal window. """
- which = 'pmod'
- want = 'bool'
-class _Prop_resizable(aetools.NProperty):
- """resizable - Whether the window can be resized. """
- which = 'prsz'
- want = 'bool'
-class _Prop_titled(aetools.NProperty):
- """titled - Whether the window has a title bar. """
- which = 'ptit'
- want = 'bool'
-class _Prop_visible(aetools.NProperty):
- """visible - Whether the window is currently visible. """
- which = 'pvis'
- want = 'bool'
-class _Prop_zoomable(aetools.NProperty):
- """zoomable - Whether the window can be zoomed. """
- which = 'iszm'
- want = 'bool'
-class _Prop_zoomed(aetools.NProperty):
- """zoomed - Whether the window is currently zoomed. """
- which = 'pzum'
- want = 'bool'
-
-windows = window
-
-class document(aetools.ComponentItem):
- """document - A document. """
- want = 'docu'
-class _Prop_modified(aetools.NProperty):
- """modified - Has the document been modified since the last save? """
- which = 'imod'
- want = 'bool'
-class _Prop_path(aetools.NProperty):
- """path - The document's path. """
- which = 'ppth'
- want = 'utxt'
-
-documents = document
-application._superclassnames = ['item']
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'frontmost' : _Prop_frontmost,
- 'name' : _Prop_name,
- 'version' : _Prop_version,
-}
-application._privelemdict = {
- 'document' : document,
- 'window' : window,
-}
-item._superclassnames = []
-item._privpropdict = {
- 'class_' : _Prop_class_,
- 'properties' : _Prop_properties,
-}
-item._privelemdict = {
-}
-color._superclassnames = ['item']
-color._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
-}
-color._privelemdict = {
-}
-window._superclassnames = ['item']
-window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'bounds' : _Prop_bounds,
- 'closeable' : _Prop_closeable,
- 'document' : _Prop_document,
- 'floating' : _Prop_floating,
- 'id' : _Prop_id,
- 'index' : _Prop_index,
- 'miniaturizable' : _Prop_miniaturizable,
- 'miniaturized' : _Prop_miniaturized,
- 'modal' : _Prop_modal,
- 'name' : _Prop_name,
- 'resizable' : _Prop_resizable,
- 'titled' : _Prop_titled,
- 'visible' : _Prop_visible,
- 'zoomable' : _Prop_zoomable,
- 'zoomed' : _Prop_zoomed,
-}
-window._privelemdict = {
-}
-document._superclassnames = ['item']
-document._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'modified' : _Prop_modified,
- 'name' : _Prop_name,
- 'path' : _Prop_path,
-}
-document._privelemdict = {
-}
-class _3c_(aetools.NComparison):
- """< - Less than """
-class _3d_(aetools.NComparison):
- """= - Equal """
-class _3e_(aetools.NComparison):
- """> - Greater than """
-class contains(aetools.NComparison):
- """contains - Contains """
-class ends_with(aetools.NComparison):
- """ends with - Ends with """
-class starts_with(aetools.NComparison):
- """starts with - Starts with """
-class _b2_(aetools.NComparison):
- """\xb2 - Less than or equal to """
-class _b3_(aetools.NComparison):
- """\xb3 - Greater than or equal to """
-_Enum_savo = {
- 'ask' : 'ask ', # Ask the user whether or not to save the file.
- 'yes' : 'yes ', # Save the file.
- 'no' : 'no ', # Do not save the file.
-}
-
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cobj' : item,
- 'colr' : color,
- 'cwin' : window,
- 'docu' : document,
-}
-
-_propdeclarations = {
- 'ID ' : _Prop_id,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'docu' : _Prop_document,
- 'hclb' : _Prop_closeable,
- 'imod' : _Prop_modified,
- 'isfl' : _Prop_floating,
- 'ismn' : _Prop_miniaturizable,
- 'iszm' : _Prop_zoomable,
- 'pALL' : _Prop_properties,
- 'pbnd' : _Prop_bounds,
- 'pcls' : _Prop_class_,
- 'pidx' : _Prop_index,
- 'pisf' : _Prop_frontmost,
- 'pmnd' : _Prop_miniaturized,
- 'pmod' : _Prop_modal,
- 'pnam' : _Prop_name,
- 'ppth' : _Prop_path,
- 'prsz' : _Prop_resizable,
- 'ptit' : _Prop_titled,
- 'pvis' : _Prop_visible,
- 'pzum' : _Prop_zoomed,
- 'vers' : _Prop_version,
-}
-
-_compdeclarations = {
- '< ' : _3c_,
- '<= ' : _b2_,
- '= ' : _3d_,
- '> ' : _3e_,
- '>= ' : _b3_,
- 'bgwt' : starts_with,
- 'cont' : contains,
- 'ends' : ends_with,
-}
-
-_enumdeclarations = {
- 'savo' : _Enum_savo,
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Terminal/Terminal_Suite.py b/Lib/plat-mac/lib-scriptpackages/Terminal/Terminal_Suite.py
deleted file mode 100644
index afa02b39fc8..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Terminal/Terminal_Suite.py
+++ /dev/null
@@ -1,254 +0,0 @@
-"""Suite Terminal Suite: Terms and Events for controlling the Terminal application
-Level 1, version 1
-
-Generated from /Applications/Utilities/Terminal.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = 'trmx'
-
-class Terminal_Suite_Events:
-
- def GetURL(self, _object, _attributes={}, **_arguments):
- """GetURL: Opens a telnet: URL
- Required argument: the object for the command
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'GURL'
- _subcode = 'GURL'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_do_script = {
- 'in_' : 'kfil',
- 'with_command' : 'cmnd',
- }
-
- def do_script(self, _object, _attributes={}, **_arguments):
- """do script: Run a UNIX shell script or command
- Required argument: the object for the command
- Keyword argument in_: the window in which to execute the command
- Keyword argument with_command: data to be passed to the Terminal application as the command line, deprecated, use direct parameter
- Keyword argument _attributes: AppleEvent attribute dictionary
- Returns: the reply for the command
- """
- _code = 'core'
- _subcode = 'dosc'
-
- aetools.keysubst(_arguments, self._argmap_do_script)
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
-
-class application(aetools.ComponentItem):
- """application - The Terminal program """
- want = 'capp'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'capp'
-_3c_Inheritance_3e_ = _Prop__3c_Inheritance_3e_()
-class _Prop_properties(aetools.NProperty):
- """properties - every property of the Terminal program """
- which = 'pALL'
- want = '****'
-properties = _Prop_properties()
-# element 'cwin' as ['name', 'indx', 'rele', 'rang', 'test', 'ID ']
-# element 'docu' as ['name', 'indx', 'rele', 'rang', 'test']
-
-applications = application
-
-class window(aetools.ComponentItem):
- """window - A Terminal window """
- want = 'cwin'
-class _Prop_background_color(aetools.NProperty):
- """background color - the background color for the window """
- which = 'pbcl'
- want = '****'
-class _Prop_bold_text_color(aetools.NProperty):
- """bold text color - the bold text color for the window """
- which = 'pbtc'
- want = '****'
-class _Prop_bounds(aetools.NProperty):
- """bounds - the boundary rectangle for the window, relative to the upper left corner of the screen """
- which = 'pbnd'
- want = '****'
-class _Prop_busy(aetools.NProperty):
- """busy - Is the window busy running a process? """
- which = 'busy'
- want = 'bool'
-class _Prop_contents(aetools.NProperty):
- """contents - the currently visible contents of the window """
- which = 'pcnt'
- want = 'utxt'
-class _Prop_cursor_color(aetools.NProperty):
- """cursor color - the cursor color for the window """
- which = 'pcuc'
- want = '****'
-class _Prop_custom_title(aetools.NProperty):
- """custom title - the custom title for the window """
- which = 'titl'
- want = 'utxt'
-class _Prop_frame(aetools.NProperty):
- """frame - the origin and size of the window """
- which = 'pfra'
- want = '****'
-class _Prop_frontmost(aetools.NProperty):
- """frontmost - Is the window in front of the other Terminal windows? """
- which = 'pisf'
- want = 'bool'
-class _Prop_history(aetools.NProperty):
- """history - the contents of the entire scrolling buffer of the window """
- which = 'hist'
- want = 'utxt'
-class _Prop_normal_text_color(aetools.NProperty):
- """normal text color - the normal text color for the window """
- which = 'ptxc'
- want = '****'
-class _Prop_number_of_columns(aetools.NProperty):
- """number of columns - the number of columns in the window """
- which = 'ccol'
- want = 'long'
-class _Prop_number_of_rows(aetools.NProperty):
- """number of rows - the number of rows in the window """
- which = 'crow'
- want = 'long'
-class _Prop_origin(aetools.NProperty):
- """origin - the lower left coordinates of the window, relative to the lower left corner of the screen """
- which = 'pori'
- want = '****'
-class _Prop_position(aetools.NProperty):
- """position - the upper left coordinates of the window, relative to the upper left corner of the screen """
- which = 'ppos'
- want = '****'
-class _Prop_processes(aetools.NProperty):
- """processes - a list of the currently running processes """
- which = 'prcs'
- want = 'utxt'
-class _Prop_size(aetools.NProperty):
- """size - the width and height of the window """
- which = 'psiz'
- want = '****'
-class _Prop_title_displays_custom_title(aetools.NProperty):
- """title displays custom title - Does the title for the window contain a custom title? """
- which = 'tdct'
- want = 'bool'
-class _Prop_title_displays_device_name(aetools.NProperty):
- """title displays device name - Does the title for the window contain the device name? """
- which = 'tddn'
- want = 'bool'
-class _Prop_title_displays_file_name(aetools.NProperty):
- """title displays file name - Does the title for the window contain the file name? """
- which = 'tdfn'
- want = 'bool'
-class _Prop_title_displays_shell_path(aetools.NProperty):
- """title displays shell path - Does the title for the window contain the shell path? """
- which = 'tdsp'
- want = 'bool'
-class _Prop_title_displays_window_size(aetools.NProperty):
- """title displays window size - Does the title for the window contain the window size? """
- which = 'tdws'
- want = 'bool'
-
-windows = window
-application._superclassnames = []
-import Standard_Suite
-application._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'properties' : _Prop_properties,
-}
-application._privelemdict = {
- 'document' : Standard_Suite.document,
- 'window' : window,
-}
-window._superclassnames = []
-window._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'background_color' : _Prop_background_color,
- 'bold_text_color' : _Prop_bold_text_color,
- 'bounds' : _Prop_bounds,
- 'busy' : _Prop_busy,
- 'contents' : _Prop_contents,
- 'cursor_color' : _Prop_cursor_color,
- 'custom_title' : _Prop_custom_title,
- 'frame' : _Prop_frame,
- 'frontmost' : _Prop_frontmost,
- 'history' : _Prop_history,
- 'normal_text_color' : _Prop_normal_text_color,
- 'number_of_columns' : _Prop_number_of_columns,
- 'number_of_rows' : _Prop_number_of_rows,
- 'origin' : _Prop_origin,
- 'position' : _Prop_position,
- 'processes' : _Prop_processes,
- 'properties' : _Prop_properties,
- 'size' : _Prop_size,
- 'title_displays_custom_title' : _Prop_title_displays_custom_title,
- 'title_displays_device_name' : _Prop_title_displays_device_name,
- 'title_displays_file_name' : _Prop_title_displays_file_name,
- 'title_displays_shell_path' : _Prop_title_displays_shell_path,
- 'title_displays_window_size' : _Prop_title_displays_window_size,
-}
-window._privelemdict = {
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'capp' : application,
- 'cwin' : window,
-}
-
-_propdeclarations = {
- 'busy' : _Prop_busy,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'ccol' : _Prop_number_of_columns,
- 'crow' : _Prop_number_of_rows,
- 'hist' : _Prop_history,
- 'pALL' : _Prop_properties,
- 'pbcl' : _Prop_background_color,
- 'pbnd' : _Prop_bounds,
- 'pbtc' : _Prop_bold_text_color,
- 'pcnt' : _Prop_contents,
- 'pcuc' : _Prop_cursor_color,
- 'pfra' : _Prop_frame,
- 'pisf' : _Prop_frontmost,
- 'pori' : _Prop_origin,
- 'ppos' : _Prop_position,
- 'prcs' : _Prop_processes,
- 'psiz' : _Prop_size,
- 'ptxc' : _Prop_normal_text_color,
- 'tdct' : _Prop_title_displays_custom_title,
- 'tddn' : _Prop_title_displays_device_name,
- 'tdfn' : _Prop_title_displays_file_name,
- 'tdsp' : _Prop_title_displays_shell_path,
- 'tdws' : _Prop_title_displays_window_size,
- 'titl' : _Prop_custom_title,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Terminal/Text_Suite.py b/Lib/plat-mac/lib-scriptpackages/Terminal/Text_Suite.py
deleted file mode 100644
index 62f4744b21e..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Terminal/Text_Suite.py
+++ /dev/null
@@ -1,195 +0,0 @@
-"""Suite Text Suite: A set of basic classes for text processing.
-Level 1, version 1
-
-Generated from /Applications/Utilities/Terminal.app
-AETE/AEUT resource version 1/0, language 0, script 0
-"""
-
-import aetools
-import MacOS
-
-_code = '????'
-
-class Text_Suite_Events:
-
- pass
-
-
-class attachment(aetools.ComponentItem):
- """attachment - Represents an inline text attachment. This class is used mainly for make commands. """
- want = 'atts'
-class _Prop__3c_Inheritance_3e_(aetools.NProperty):
- """<Inheritance> - All of the properties of the superclass. """
- which = 'c@#^'
- want = 'ctxt'
-class _Prop_file_name(aetools.NProperty):
- """file name - The path to the file for the attachment """
- which = 'atfn'
- want = 'utxt'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-class attribute_run(aetools.ComponentItem):
- """attribute run - This subdivides the text into chunks that all have the same attributes. """
- want = 'catr'
-class _Prop_color(aetools.NProperty):
- """color - The color of the first character. """
- which = 'colr'
- want = 'colr'
-class _Prop_font(aetools.NProperty):
- """font - The name of the font of the first character. """
- which = 'font'
- want = 'utxt'
-class _Prop_size(aetools.NProperty):
- """size - The size in points of the first character. """
- which = 'ptsz'
- want = 'long'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-attribute_runs = attribute_run
-
-class character(aetools.ComponentItem):
- """character - This subdivides the text into characters. """
- want = 'cha '
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-characters = character
-
-class paragraph(aetools.ComponentItem):
- """paragraph - This subdivides the text into paragraphs. """
- want = 'cpar'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-paragraphs = paragraph
-
-class text(aetools.ComponentItem):
- """text - Rich (styled) text """
- want = 'ctxt'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-class word(aetools.ComponentItem):
- """word - This subdivides the text into words. """
- want = 'cwor'
-# element 'catr' as ['indx', 'rele', 'rang', 'test']
-# element 'cha ' as ['indx', 'rele', 'rang', 'test']
-# element 'cpar' as ['indx', 'rele', 'rang', 'test']
-# element 'cwor' as ['indx', 'rele', 'rang', 'test']
-
-words = word
-attachment._superclassnames = ['text']
-attachment._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'file_name' : _Prop_file_name,
-}
-attachment._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-import Standard_Suite
-attribute_run._superclassnames = ['item']
-attribute_run._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-attribute_run._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-character._superclassnames = ['item']
-character._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-character._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-paragraph._superclassnames = ['item']
-paragraph._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-paragraph._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-text._superclassnames = ['item']
-text._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-text._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-word._superclassnames = ['item']
-word._privpropdict = {
- '_3c_Inheritance_3e_' : _Prop__3c_Inheritance_3e_,
- 'color' : _Prop_color,
- 'font' : _Prop_font,
- 'size' : _Prop_size,
-}
-word._privelemdict = {
- 'attribute_run' : attribute_run,
- 'character' : character,
- 'paragraph' : paragraph,
- 'word' : word,
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'atts' : attachment,
- 'catr' : attribute_run,
- 'cha ' : character,
- 'cpar' : paragraph,
- 'ctxt' : text,
- 'cwor' : word,
-}
-
-_propdeclarations = {
- 'atfn' : _Prop_file_name,
- 'c@#^' : _Prop__3c_Inheritance_3e_,
- 'colr' : _Prop_color,
- 'font' : _Prop_font,
- 'ptsz' : _Prop_size,
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
-}
diff --git a/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py b/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
deleted file mode 100644
index 00330b9ac9b..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/Terminal/__init__.py
+++ /dev/null
@@ -1,93 +0,0 @@
-"""
-Package generated from /Applications/Utilities/Terminal.app
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the Terminal module is removed.", stacklevel=2)
-
-import aetools
-Error = aetools.Error
-import Standard_Suite
-import Text_Suite
-import Terminal_Suite
-
-
-_code_to_module = {
- '????' : Standard_Suite,
- '????' : Text_Suite,
- 'trmx' : Terminal_Suite,
-}
-
-
-
-_code_to_fullname = {
- '????' : ('Terminal.Standard_Suite', 'Standard_Suite'),
- '????' : ('Terminal.Text_Suite', 'Text_Suite'),
- 'trmx' : ('Terminal.Terminal_Suite', 'Terminal_Suite'),
-}
-
-from Standard_Suite import *
-from Text_Suite import *
-from Terminal_Suite import *
-
-def getbaseclasses(v):
- if not getattr(v, '_propdict', None):
- v._propdict = {}
- v._elemdict = {}
- for superclassname in getattr(v, '_superclassnames', []):
- superclass = eval(superclassname)
- getbaseclasses(superclass)
- v._propdict.update(getattr(superclass, '_propdict', {}))
- v._elemdict.update(getattr(superclass, '_elemdict', {}))
- v._propdict.update(getattr(v, '_privpropdict', {}))
- v._elemdict.update(getattr(v, '_privelemdict', {}))
-
-import StdSuites
-
-#
-# Set property and element dictionaries now that all classes have been defined
-#
-getbaseclasses(color)
-getbaseclasses(window)
-getbaseclasses(application)
-getbaseclasses(item)
-getbaseclasses(document)
-getbaseclasses(window)
-getbaseclasses(application)
-getbaseclasses(character)
-getbaseclasses(attachment)
-getbaseclasses(paragraph)
-getbaseclasses(word)
-getbaseclasses(attribute_run)
-getbaseclasses(text)
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
- 'colr' : color,
- 'cwin' : window,
- 'capp' : application,
- 'cobj' : item,
- 'docu' : document,
- 'cwin' : window,
- 'capp' : application,
- 'cha ' : character,
- 'atts' : attachment,
- 'cpar' : paragraph,
- 'cwor' : word,
- 'catr' : attribute_run,
- 'ctxt' : text,
-}
-
-
-class Terminal(Standard_Suite_Events,
- Text_Suite_Events,
- Terminal_Suite_Events,
- aetools.TalkTo):
- _signature = 'trmx'
-
- _moduleName = 'Terminal'
-
- _elemdict = application._elemdict
- _propdict = application._propdict
diff --git a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py b/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
deleted file mode 100644
index b675b985030..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/__init__.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""
-Manually generated suite used as base class for StdSuites Required and Standard
-suites. This is needed because the events and enums in this suite belong
-in the Required suite according to the Apple docs, but they often seem to be
-in the Standard suite.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the _builtinSuites module is removed.", stacklevel=2)
-
-import aetools
-import builtin_Suite
-
-
-_code_to_module = {
- 'reqd' : builtin_Suite,
- 'core' : builtin_Suite,
-}
-
-
-
-_code_to_fullname = {
- 'reqd' : ('_builtinSuites.builtin_Suite', 'builtin_Suite'),
- 'core' : ('_builtinSuites.builtin_Suite', 'builtin_Suite'),
-}
-
-from builtin_Suite import *
-
-class _builtinSuites(builtin_Suite_Events,
- aetools.TalkTo):
- _signature = 'ascr'
diff --git a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/builtin_Suite.py b/Lib/plat-mac/lib-scriptpackages/_builtinSuites/builtin_Suite.py
deleted file mode 100644
index e3ee2715c64..00000000000
--- a/Lib/plat-mac/lib-scriptpackages/_builtinSuites/builtin_Suite.py
+++ /dev/null
@@ -1,140 +0,0 @@
-"""Suite builtin_Suite: Every application supports open, reopen, print, run, and quit
-Level 1, version 1
-"""
-
-import aetools
-import MacOS
-
-_code = 'aevt'
-
-class builtin_Suite_Events:
-
- def open(self, _object, _attributes={}, **_arguments):
- """open: Open the specified object(s)
- Required argument: list of objects to open
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'odoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def run(self, _no_object=None, _attributes={}, **_arguments):
- """run: Run an application. Most applications will open an empty, untitled window.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'oapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def reopen(self, _no_object=None, _attributes={}, **_arguments):
- """reopen: Reactivate a running application. Some applications will open a new untitled window if no window is open.
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'rapp'
-
- if _arguments: raise TypeError, 'No optional args expected'
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- def _print(self, _object, _attributes={}, **_arguments):
- """print: Print the specified object(s)
- Required argument: list of objects to print
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'pdoc'
-
- if _arguments: raise TypeError, 'No optional args expected'
- _arguments['----'] = _object
-
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_quit = {
- 'saving' : 'savo',
- }
-
- def quit(self, _no_object=None, _attributes={}, **_arguments):
- """quit: Quit an application
- Keyword argument saving: specifies whether to save currently open documents
- Keyword argument _attributes: AppleEvent attribute dictionary
- """
- _code = 'aevt'
- _subcode = 'quit'
-
- aetools.keysubst(_arguments, self._argmap_quit)
- if _no_object is not None: raise TypeError, 'No direct arg expected'
-
- aetools.enumsubst(_arguments, 'savo', _Enum_savo)
-
- _reply, _arguments, _attributes = self.send(_code, _subcode,
- _arguments, _attributes)
- if _arguments.get('errn', 0):
- raise aetools.Error, aetools.decodeerror(_arguments)
- # XXXX Optionally decode result
- if _arguments.has_key('----'):
- return _arguments['----']
-
- _argmap_close = {
- 'saving' : 'savo',
- 'saving_in' : 'kfil',
- }
-
-_Enum_savo = {
- 'yes' : 'yes ', # Save objects now
- 'no' : 'no ', # Do not save objects
- 'ask' : 'ask ', # Ask the user whether to save
-}
-
-#
-# Indices of types declared in this module
-#
-_classdeclarations = {
-}
-
-_propdeclarations = {
-}
-
-_compdeclarations = {
-}
-
-_enumdeclarations = {
- 'savo' : _Enum_savo,
-}
diff --git a/Lib/plat-mac/macerrors.py b/Lib/plat-mac/macerrors.py
deleted file mode 100644
index 58d79d61746..00000000000
--- a/Lib/plat-mac/macerrors.py
+++ /dev/null
@@ -1,1857 +0,0 @@
-# -coding=latin1-
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the macerrors module is removed.", stacklevel=2)
-
-svTempDisable = -32768 #svTempDisable
-svDisabled = -32640 #Reserve range -32640 to -32768 for Apple temp disables.
-fontNotOutlineErr = -32615 #bitmap font passed to routine that does outlines only
-kURL68kNotSupportedError = -30788 #kURL68kNotSupportedError
-kURLAccessNotAvailableError = -30787 #kURLAccessNotAvailableError
-kURLInvalidConfigurationError = -30786 #kURLInvalidConfigurationError
-kURLExtensionFailureError = -30785 #kURLExtensionFailureError
-kURLFileEmptyError = -30783 #kURLFileEmptyError
-kURLInvalidCallError = -30781 #kURLInvalidCallError
-kURLUnsettablePropertyError = -30780 #kURLUnsettablePropertyError
-kURLPropertyBufferTooSmallError = -30779 #kURLPropertyBufferTooSmallError
-kURLUnknownPropertyError = -30778 #kURLUnknownPropertyError
-kURLPropertyNotYetKnownError = -30777 #kURLPropertyNotYetKnownError
-kURLAuthenticationError = -30776 #kURLAuthenticationError
-kURLServerBusyError = -30775 #kURLServerBusyError
-kURLUnsupportedSchemeError = -30774 #kURLUnsupportedSchemeError
-kURLInvalidURLError = -30773 #kURLInvalidURLError
-kURLDestinationExistsError = -30772 #kURLDestinationExistsError
-kURLProgressAlreadyDisplayedError = -30771 #kURLProgressAlreadyDisplayedError
-kURLInvalidURLReferenceError = -30770 #kURLInvalidURLReferenceError
-controlHandleInvalidErr = -30599 #controlHandleInvalidErr
-controlInvalidDataVersionErr = -30597 #controlInvalidDataVersionErr
-errItemNotControl = -30596 #errItemNotControl
-errCantEmbedRoot = -30595 #errCantEmbedRoot
-errCantEmbedIntoSelf = -30594 #errCantEmbedIntoSelf
-errWindowRegionCodeInvalid = -30593 #errWindowRegionCodeInvalid
-errControlHiddenOrDisabled = -30592 #errControlHiddenOrDisabled
-errDataSizeMismatch = -30591 #errDataSizeMismatch
-errControlIsNotEmbedder = -30590 #errControlIsNotEmbedder
-errControlsAlreadyExist = -30589 #errControlsAlreadyExist
-errInvalidPartCode = -30588 #errInvalidPartCode
-errRootAlreadyExists = -30587 #errRootAlreadyExists
-errNoRootControl = -30586 #errNoRootControl
-errCouldntSetFocus = -30585 #errCouldntSetFocus
-errUnknownControl = -30584 #errUnknownControl
-errWindowDoesntSupportFocus = -30583 #errWindowDoesntSupportFocus
-errControlDoesntSupportFocus = -30582 #errControlDoesntSupportFocus
-errDataNotSupported = -30581 #errDataNotSupported
-errMessageNotSupported = -30580 #errMessageNotSupported
-themeMonitorDepthNotSupportedErr = -30567 #theme not supported at monitor depth
-themeScriptFontNotFoundErr = -30566 #theme font requested for uninstalled script system
-themeBadCursorIndexErr = -30565 #themeBadCursorIndexErr
-themeHasNoAccentsErr = -30564 #themeHasNoAccentsErr
-themeBadTextColorErr = -30563 #themeBadTextColorErr
-themeProcessNotRegisteredErr = -30562 #themeProcessNotRegisteredErr
-themeProcessRegisteredErr = -30561 #themeProcessRegisteredErr
-themeInvalidBrushErr = -30560 #pattern index invalid
-qtvrUninitialized = -30555 #qtvrUninitialized
-qtvrLibraryLoadErr = -30554 #qtvrLibraryLoadErr
-streamingNodeNotReadyErr = -30553 #streamingNodeNotReadyErr
-noMemoryNodeFailedInitialize = -30552 #noMemoryNodeFailedInitialize
-invalidHotSpotIDErr = -30551 #invalidHotSpotIDErr
-invalidNodeFormatErr = -30550 #invalidNodeFormatErr
-limitReachedErr = -30549 #limitReachedErr
-settingNotSupportedByNodeErr = -30548 #settingNotSupportedByNodeErr
-propertyNotSupportedByNodeErr = -30547 #propertyNotSupportedByNodeErr
-timeNotInViewErr = -30546 #timeNotInViewErr
-invalidViewStateErr = -30545 #invalidViewStateErr
-invalidNodeIDErr = -30544 #invalidNodeIDErr
-selectorNotSupportedByNodeErr = -30543 #selectorNotSupportedByNodeErr
-callNotSupportedByNodeErr = -30542 #callNotSupportedByNodeErr
-constraintReachedErr = -30541 #constraintReachedErr
-notAQTVRMovieErr = -30540 #notAQTVRMovieErr
-kFBCnoSuchHit = -30532 #kFBCnoSuchHit
-kFBCbadSearchSession = -30531 #kFBCbadSearchSession
-kFBCindexDiskIOFailed = -30530 #kFBCindexDiskIOFailed
-kFBCsummarizationCanceled = -30529 #kFBCsummarizationCanceled
-kFBCbadIndexFileVersion = -30528 #kFBCbadIndexFileVersion
-kFBCanalysisNotAvailable = -30527 #kFBCanalysisNotAvailable
-kFBCillegalSessionChange = -30526 #tried to add/remove vols to a session
-kFBCsomeFilesNotIndexed = -30525 #kFBCsomeFilesNotIndexed
-kFBCsearchFailed = -30524 #kFBCsearchFailed
-kFBCindexNotAvailable = -30523 #kFBCindexNotAvailable
-kFBCindexFileDestroyed = -30522 #kFBCindexFileDestroyed
-kFBCaccessCanceled = -30521 #kFBCaccessCanceled
-kFBCindexingCanceled = -30520 #kFBCindexingCanceled
-kFBCnoSearchSession = -30519 #kFBCnoSearchSession
-kFBCindexNotFound = -30518 #kFBCindexNotFound
-kFBCflushFailed = -30517 #kFBCflushFailed
-kFBCaddDocFailed = -30516 #kFBCaddDocFailed
-kFBCaccessorStoreFailed = -30515 #kFBCaccessorStoreFailed
-kFBCindexCreationFailed = -30514 #couldn't create index
-kFBCmergingFailed = -30513 #couldn't merge index files
-kFBCtokenizationFailed = -30512 #couldn't read from document or query
-kFBCmoveFailed = -30511 #V-Twin exception caught
-kFBCdeletionFailed = -30510 #V-Twin exception caught
-kFBCcommitFailed = -30509 #V-Twin exception caught
-kFBCindexingFailed = -30508 #V-Twin exception caught
-kFBCvalidationFailed = -30507 #V-Twin exception caught
-kFBCcompactionFailed = -30506 #V-Twin exception caught
-kFBCbadIndexFile = -30505 #bad FSSpec, or bad data in file
-kFBCfileNotIndexed = -30504 #kFBCfileNotIndexed
-kFBCbadParam = -30503 #kFBCbadParam
-kFBCallocFailed = -30502 #probably low memory
-kFBCnoIndexesFound = -30501 #kFBCnoIndexesFound
-kFBCvTwinExceptionErr = -30500 #no telling what it was
-kDSpStereoContextErr = -30450 #kDSpStereoContextErr
-kDSpInternalErr = -30449 #kDSpInternalErr
-kDSpConfirmSwitchWarning = -30448 #kDSpConfirmSwitchWarning
-kDSpFrameRateNotReadyErr = -30447 #kDSpFrameRateNotReadyErr
-kDSpContextNotFoundErr = -30446 #kDSpContextNotFoundErr
-kDSpContextNotReservedErr = -30445 #kDSpContextNotReservedErr
-kDSpContextAlreadyReservedErr = -30444 #kDSpContextAlreadyReservedErr
-kDSpInvalidAttributesErr = -30443 #kDSpInvalidAttributesErr
-kDSpInvalidContextErr = -30442 #kDSpInvalidContextErr
-kDSpSystemSWTooOldErr = -30441 #kDSpSystemSWTooOldErr
-kDSpNotInitializedErr = -30440 #kDSpNotInitializedErr
-kISpListBusyErr = -30429 #kISpListBusyErr
-kISpDeviceActiveErr = -30428 #kISpDeviceActiveErr
-kISpSystemActiveErr = -30427 #kISpSystemActiveErr
-kISpDeviceInactiveErr = -30426 #kISpDeviceInactiveErr
-kISpSystemInactiveErr = -30425 #kISpSystemInactiveErr
-kISpElementNotInListErr = -30424 #kISpElementNotInListErr
-kISpElementInListErr = -30423 #kISpElementInListErr
-kISpBufferToSmallErr = -30422 #kISpBufferToSmallErr
-kISpSystemListErr = -30421 #kISpSystemListErr
-kISpInternalErr = -30420 #kISpInternalErr
-kNSpJoinFailedErr = -30399 #kNSpJoinFailedErr
-kNSpCantBlockErr = -30398 #kNSpCantBlockErr
-kNSpMessageTooBigErr = -30397 #kNSpMessageTooBigErr
-kNSpSendFailedErr = -30396 #kNSpSendFailedErr
-kNSpConnectFailedErr = -30395 #kNSpConnectFailedErr
-kNSpGameTerminatedErr = -30394 #kNSpGameTerminatedErr
-kNSpTimeoutErr = -30393 #kNSpTimeoutErr
-kNSpInvalidProtocolListErr = -30392 #kNSpInvalidProtocolListErr
-kNSpInvalidProtocolRefErr = -30391 #kNSpInvalidProtocolRefErr
-kNSpInvalidDefinitionErr = -30390 #kNSpInvalidDefinitionErr
-kNSpAddPlayerFailedErr = -30389 #kNSpAddPlayerFailedErr
-kNSpCreateGroupFailedErr = -30388 #kNSpCreateGroupFailedErr
-kNSpNoHostVolunteersErr = -30387 #kNSpNoHostVolunteersErr
-kNSpNoGroupsErr = -30386 #kNSpNoGroupsErr
-kNSpNoPlayersErr = -30385 #kNSpNoPlayersErr
-kNSpInvalidGroupIDErr = -30384 #kNSpInvalidGroupIDErr
-kNSpInvalidPlayerIDErr = -30383 #kNSpInvalidPlayerIDErr
-kNSpNameRequiredErr = -30382 #kNSpNameRequiredErr
-kNSpFeatureNotImplementedErr = -30381 #kNSpFeatureNotImplementedErr
-kNSpAddressInUseErr = -30380 #kNSpAddressInUseErr
-kNSpRemovePlayerFailedErr = -30379 #kNSpRemovePlayerFailedErr
-kNSpFreeQExhaustedErr = -30378 #kNSpFreeQExhaustedErr
-kNSpInvalidAddressErr = -30377 #kNSpInvalidAddressErr
-kNSpNotAdvertisingErr = -30376 #kNSpNotAdvertisingErr
-kNSpAlreadyAdvertisingErr = -30374 #kNSpAlreadyAdvertisingErr
-kNSpMemAllocationErr = -30373 #kNSpMemAllocationErr
-kNSpOTVersionTooOldErr = -30371 #kNSpOTVersionTooOldErr
-kNSpOTNotPresentErr = -30370 #kNSpOTNotPresentErr
-kNSpInvalidParameterErr = -30369 #kNSpInvalidParameterErr
-kNSpInvalidGameRefErr = -30367 #kNSpInvalidGameRefErr
-kNSpProtocolNotAvailableErr = -30366 #kNSpProtocolNotAvailableErr
-kNSpHostFailedErr = -30365 #kNSpHostFailedErr
-kNSpPipeFullErr = -30364 #kNSpPipeFullErr
-kNSpTopologyNotSupportedErr = -30362 #kNSpTopologyNotSupportedErr
-kNSpAlreadyInitializedErr = -30361 #kNSpAlreadyInitializedErr
-kNSpInitializationFailedErr = -30360 #kNSpInitializationFailedErr
-kSSpScaleToZeroErr = -30344 #kSSpScaleToZeroErr
-kSSpParallelUpVectorErr = -30343 #kSSpParallelUpVectorErr
-kSSpCantInstallErr = -30342 #kSSpCantInstallErr
-kSSpVersionErr = -30341 #kSSpVersionErr
-kSSpInternalErr = -30340 #kSSpInternalErr
-kALMInternalErr = -30049 #kALMInternalErr
-kALMGroupNotFoundErr = -30048 #kALMGroupNotFoundErr
-kALMNoSuchModuleErr = -30047 #kALMNoSuchModuleErr
-kALMModuleCommunicationErr = -30046 #kALMModuleCommunicationErr
-kALMDuplicateModuleErr = -30045 #kALMDuplicateModuleErr
-kALMInstallationErr = -30044 #kALMInstallationErr
-kALMDeferSwitchErr = -30043 #kALMDeferSwitchErr
-kALMRebootFlagsLevelErr = -30042 #kALMRebootFlagsLevelErr
-kLocalesDefaultDisplayStatus = -30029 #Requested display locale unavailable, used default
-kLocalesTableFormatErr = -30002 #kLocalesTableFormatErr
-kLocalesBufferTooSmallErr = -30001 #kLocalesBufferTooSmallErr
-kFNSNameNotFoundErr = -29589 #The name with the requested paramters was not found
-kFNSBadFlattenedSizeErr = -29587 #flattened size didn't match input or was too small
-kFNSInsufficientDataErr = -29586 #insufficient data for the operation
-kFNSMismatchErr = -29585 #reference didn't match or wasn't found in profile
-kFNSDuplicateReferenceErr = -29584 #the ref. being added is already in the profile
-kFNSBadProfileVersionErr = -29583 #profile version is out of known range
-kFNSInvalidProfileErr = -29582 #profile is NULL or otherwise bad
-kFNSBadReferenceVersionErr = -29581 #ref. version is out of known range
-kFNSInvalidReferenceErr = -29580 #ref. was NULL or otherwise bad
-kCollateInvalidCollationRef = -29507 #kCollateInvalidCollationRef
-kCollateBufferTooSmall = -29506 #kCollateBufferTooSmall
-kCollateInvalidChar = -29505 #kCollateInvalidChar
-kCollatePatternNotFoundErr = -29504 #kCollatePatternNotFoundErr
-kCollateUnicodeConvertFailedErr = -29503 #kCollateUnicodeConvertFailedErr
-kCollateMissingUnicodeTableErr = -29502 #kCollateMissingUnicodeTableErr
-kCollateInvalidOptions = -29501 #kCollateInvalidOptions
-kCollateAttributesNotFoundErr = -29500 #kCollateAttributesNotFoundErr
-kMPInvalidIDErr = -29299 #kMPInvalidIDErr
-kMPInsufficientResourcesErr = -29298 #kMPInsufficientResourcesErr
-kMPTaskAbortedErr = -29297 #kMPTaskAbortedErr
-kMPTimeoutErr = -29296 #kMPTimeoutErr
-kMPDeletedErr = -29295 #kMPDeletedErr
-kMPBlueBlockingErr = -29293 #kMPBlueBlockingErr
-kMPTaskStoppedErr = -29292 #A convention used with MPThrowException.
-kMPTaskBlockedErr = -29291 #kMPTaskBlockedErr
-kMPTaskCreatedErr = -29290 #kMPTaskCreatedErr
-kMPProcessTerminatedErr = -29289 #kMPProcessTerminatedErr
-kMPProcessCreatedErr = -29288 #kMPProcessCreatedErr
-kMPPrivilegedErr = -29276 #kMPPrivilegedErr
-kMPIterationEndErr = -29275 #kMPIterationEndErr
-kUCTextBreakLocatorMissingType = -25341 #Unicode text break error
-kUCOutputBufferTooSmall = -25340 #Output buffer too small for Unicode string result
-errKCCreateChainFailed = -25318 #errKCCreateChainFailed
-errKCDataNotModifiable = -25317 #errKCDataNotModifiable
-errKCDataNotAvailable = -25316 #errKCDataNotAvailable
-errKCInteractionRequired = -25315 #errKCInteractionRequired
-errKCNoPolicyModule = -25314 #errKCNoPolicyModule
-errKCNoCertificateModule = -25313 #errKCNoCertificateModule
-errKCNoStorageModule = -25312 #errKCNoStorageModule
-errKCKeySizeNotAllowed = -25311 #errKCKeySizeNotAllowed
-errKCWrongKCVersion = -25310 #errKCWrongKCVersion
-errKCReadOnlyAttr = -25309 #errKCReadOnlyAttr
-errKCInteractionNotAllowed = -25308 #errKCInteractionNotAllowed
-errKCNoDefaultKeychain = -25307 #errKCNoDefaultKeychain
-errKCNoSuchClass = -25306 #errKCNoSuchClass
-errKCInvalidSearchRef = -25305 #errKCInvalidSearchRef
-errKCInvalidItemRef = -25304 #errKCInvalidItemRef
-errKCNoSuchAttr = -25303 #errKCNoSuchAttr
-errKCDataTooLarge = -25302 #errKCDataTooLarge
-errKCBufferTooSmall = -25301 #errKCBufferTooSmall
-errKCItemNotFound = -25300 #errKCItemNotFound
-errKCDuplicateItem = -25299 #errKCDuplicateItem
-errKCInvalidCallback = -25298 #errKCInvalidCallback
-errKCDuplicateCallback = -25297 #errKCDuplicateCallback
-errKCDuplicateKeychain = -25296 #errKCDuplicateKeychain
-errKCInvalidKeychain = -25295 #errKCInvalidKeychain
-errKCNoSuchKeychain = -25294 #errKCNoSuchKeychain
-errKCAuthFailed = -25293 #errKCAuthFailed
-errKCReadOnly = -25292 #errKCReadOnly
-errKCNotAvailable = -25291 #errKCNotAvailable
-printerStatusOpCodeNotSupportedErr = -25280 #printerStatusOpCodeNotSupportedErr
-kTXNOutsideOfFrameErr = -22018 #kTXNOutsideOfFrameErr
-kTXNOutsideOfLineErr = -22017 #kTXNOutsideOfLineErr
-kTXNATSUIIsNotInstalledErr = -22016 #kTXNATSUIIsNotInstalledErr
-kTXNDataTypeNotAllowedErr = -22015 #kTXNDataTypeNotAllowedErr
-kTXNCopyNotAllowedInEchoModeErr = -22014 #kTXNCopyNotAllowedInEchoModeErr
-kTXNCannotTurnTSMOffWhenUsingUnicodeErr = -22013 #kTXNCannotTurnTSMOffWhenUsingUnicodeErr
-kTXNAlreadyInitializedErr = -22012 #kTXNAlreadyInitializedErr
-kTXNInvalidRunIndex = -22011 #kTXNInvalidRunIndex
-kTXNSomeOrAllTagsInvalidForRunErr = -22010 #kTXNSomeOrAllTagsInvalidForRunErr
-kTXNAttributeTagInvalidForRunErr = -22009 #dataValue is set to this per invalid tag
-kTXNNoMatchErr = -22008 #kTXNNoMatchErr
-kTXNRunIndexOutofBoundsErr = -22007 #kTXNRunIndexOutofBoundsErr
-kTXNCannotSetAutoIndentErr = -22006 #kTXNCannotSetAutoIndentErr
-kTXNBadDefaultFileTypeWarning = -22005 #kTXNBadDefaultFileTypeWarning
-kTXNUserCanceledOperationErr = -22004 #kTXNUserCanceledOperationErr
-kTXNIllegalToCrossDataBoundariesErr = -22003 #kTXNIllegalToCrossDataBoundariesErr
-kTXNInvalidFrameIDErr = -22002 #kTXNInvalidFrameIDErr
-kTXNCannotAddFrameErr = -22001 #kTXNCannotAddFrameErr
-kTXNEndIterationErr = -22000 #kTXNEndIterationErr
-invalidIndexErr = -20002 #The recordIndex parameter is not valid.
-recordDataTooBigErr = -20001 #The record data is bigger than buffer size (1024 bytes).
-unknownInsertModeErr = -20000 #There is no such an insert mode.
-kModemScriptMissing = -14002 #kModemScriptMissing
-kModemPreferencesMissing = -14001 #kModemPreferencesMissing
-kModemOutOfMemory = -14000 #kModemOutOfMemory
-kHIDBaseError = -13950 #kHIDBaseError
-kHIDNullStateErr = -13949 #kHIDNullStateErr
-kHIDBufferTooSmallErr = -13948 #kHIDBufferTooSmallErr
-kHIDValueOutOfRangeErr = -13947 #kHIDValueOutOfRangeErr
-kHIDUsageNotFoundErr = -13946 #kHIDUsageNotFoundErr
-kHIDNotValueArrayErr = -13945 #kHIDNotValueArrayErr
-kHIDInvalidPreparsedDataErr = -13944 #kHIDInvalidPreparsedDataErr
-kHIDIncompatibleReportErr = -13943 #kHIDIncompatibleReportErr
-kHIDBadLogPhysValuesErr = -13942 #kHIDBadLogPhysValuesErr
-kHIDInvalidReportTypeErr = -13941 #kHIDInvalidReportTypeErr
-kHIDInvalidReportLengthErr = -13940 #kHIDInvalidReportLengthErr
-kHIDNullPointerErr = -13939 #kHIDNullPointerErr
-kHIDBadParameterErr = -13938 #kHIDBadParameterErr
-kHIDNotEnoughMemoryErr = -13937 #kHIDNotEnoughMemoryErr
-kHIDEndOfDescriptorErr = -13936 #kHIDEndOfDescriptorErr
-kHIDUsagePageZeroErr = -13935 #kHIDUsagePageZeroErr
-kHIDBadLogicalMinimumErr = -13934 #kHIDBadLogicalMinimumErr
-kHIDBadLogicalMaximumErr = -13933 #kHIDBadLogicalMaximumErr
-kHIDInvertedLogicalRangeErr = -13932 #kHIDInvertedLogicalRangeErr
-kHIDInvertedPhysicalRangeErr = -13931 #kHIDInvertedPhysicalRangeErr
-kHIDUnmatchedUsageRangeErr = -13930 #kHIDUnmatchedUsageRangeErr
-kHIDInvertedUsageRangeErr = -13929 #kHIDInvertedUsageRangeErr
-kHIDUnmatchedStringRangeErr = -13928 #kHIDUnmatchedStringRangeErr
-kHIDUnmatchedDesignatorRangeErr = -13927 #kHIDUnmatchedDesignatorRangeErr
-kHIDReportSizeZeroErr = -13926 #kHIDReportSizeZeroErr
-kHIDReportCountZeroErr = -13925 #kHIDReportCountZeroErr
-kHIDReportIDZeroErr = -13924 #kHIDReportIDZeroErr
-kHIDInvalidRangePageErr = -13923 #kHIDInvalidRangePageErr
-kHIDDeviceNotReady = -13910 #The device is still initializing, try again later
-kHIDVersionIncompatibleErr = -13909 #kHIDVersionIncompatibleErr
-debuggingNoMatchErr = -13887 #debugging component or option not found at this index
-debuggingNoCallbackErr = -13886 #debugging component has no callback
-debuggingInvalidNameErr = -13885 #componentName or optionName is invalid (NULL)
-debuggingInvalidOptionErr = -13884 #optionSelectorNum is not registered
-debuggingInvalidSignatureErr = -13883 #componentSignature not registered
-debuggingDuplicateOptionErr = -13882 #optionSelectorNum already registered
-debuggingDuplicateSignatureErr = -13881 #componentSignature already registered
-debuggingExecutionContextErr = -13880 #routine cannot be called at this time
-kBridgeSoftwareRunningCantSleep = -13038 #kBridgeSoftwareRunningCantSleep
-kNoSuchPowerSource = -13020 #kNoSuchPowerSource
-kProcessorTempRoutineRequiresMPLib2 = -13014 #kProcessorTempRoutineRequiresMPLib2
-kCantReportProcessorTemperatureErr = -13013 #kCantReportProcessorTemperatureErr
-kPowerMgtRequestDenied = -13010 #kPowerMgtRequestDenied
-kPowerMgtMessageNotHandled = -13009 #kPowerMgtMessageNotHandled
-kPowerHandlerNotFoundForProcErr = -13008 #kPowerHandlerNotFoundForProcErr
-kPowerHandlerNotFoundForDeviceErr = -13007 #kPowerHandlerNotFoundForDeviceErr
-kPowerHandlerExistsForDeviceErr = -13006 #kPowerHandlerExistsForDeviceErr
-pmRecvEndErr = -13005 #during receive, pmgr did not finish hs configured for this connection
-pmRecvStartErr = -13004 #during receive, pmgr did not start hs
-pmSendEndErr = -13003 #during send, pmgr did not finish hs
-pmSendStartErr = -13002 #during send, pmgr did not start hs
-pmReplyTOErr = -13001 #Timed out waiting for reply
-pmBusyErr = -13000 #Power Mgr never ready to start handshake
-pictureDataErr = -11005 #the picture data was invalid
-colorsRequestedErr = -11004 #the number of colors requested was illegal
-cantLoadPickMethodErr = -11003 #unable to load the custom pick proc
-pictInfoVerbErr = -11002 #the passed verb was invalid
-pictInfoIDErr = -11001 #the internal consistancy check for the PictInfoID is wrong
-pictInfoVersionErr = -11000 #wrong version of the PictInfo structure
-errTaskNotFound = -10780 #no task with that task id exists
-telNotEnoughdspBW = -10116 #not enough real-time for allocation
-telBadSampleRate = -10115 #incompatible sample rate
-telBadSWErr = -10114 #Software not installed properly
-telDetAlreadyOn = -10113 #detection is already turned on
-telAutoAnsNotOn = -10112 #autoAnswer in not turned on
-telValidateFailed = -10111 #telValidate failed
-telBadProcID = -10110 #invalid procID
-telDeviceNotFound = -10109 #device not found
-telBadCodeResource = -10108 #code resource not found
-telInitFailed = -10107 #initialization failed
-telNoCommFolder = -10106 #Communications/Extensions € not found
-telUnknownErr = -10103 #unable to set config
-telNoSuchTool = -10102 #unable to find tool with name specified
-telBadFunction = -10091 #bad msgCode specified
-telPBErr = -10090 #parameter block error, bad format
-telCANotDeflectable = -10082 #CA not "deflectable"
-telCANotRejectable = -10081 #CA not "rejectable"
-telCANotAcceptable = -10080 #CA not "acceptable"
-telTermNotOpen = -10072 #terminal not opened via TELOpenTerm
-telStillNeeded = -10071 #terminal driver still needed by someone else
-telAlreadyOpen = -10070 #terminal already open
-telNoCallbackRef = -10064 #no call back reference was specified, but is required
-telDisplayModeNotSupp = -10063 #display mode not supported by tool
-telBadDisplayMode = -10062 #bad display mode specified
-telFwdTypeNotSupp = -10061 #forward type not supported by tool
-telDNTypeNotSupp = -10060 #DN type not supported by tool
-telBadRate = -10059 #bad rate specified
-telBadBearerType = -10058 #bad bearerType specified
-telBadSelect = -10057 #unable to select or deselect DN
-telBadParkID = -10056 #bad park id specified
-telBadPickupGroupID = -10055 #bad pickup group ID specified
-telBadFwdType = -10054 #bad fwdType specified
-telBadFeatureID = -10053 #bad feature ID specified
-telBadIntercomID = -10052 #bad intercom ID specified
-telBadPageID = -10051 #bad page ID specified
-telBadDNType = -10050 #DN type invalid
-telConfLimitExceeded = -10047 #attempt to exceed switch conference limits
-telCBErr = -10046 #call back feature not set previously
-telTransferRej = -10045 #transfer request rejected
-telTransferErr = -10044 #transfer not prepared
-telConfRej = -10043 #conference request was rejected
-telConfErr = -10042 #conference was not prepared
-telConfNoLimit = -10041 #no limit was specified but required
-telConfLimitErr = -10040 #limit specified is too high for this configuration
-telFeatNotSupp = -10033 #feature program call not supported by this tool
-telFeatActive = -10032 #feature already active
-telFeatNotAvail = -10031 #feature subscribed but not available
-telFeatNotSub = -10030 #feature not subscribed
-errAEPropertiesClash = -10025 #illegal combination of properties settings for Set Data, make new, or duplicate
-errAECantPutThatThere = -10024 #in make new, duplicate, etc. class can't be an element of container
-errAENotAnEnumMember = -10023 #enumerated value in SetData is not allowed for this property
-telIntExtNotSupp = -10022 #internal external type not supported by this tool
-telBadIntExt = -10021 #bad internal external error
-telStateNotSupp = -10020 #device state not supported by tool
-telBadStateErr = -10019 #bad device state specified
-telIndexNotSupp = -10018 #index not supported by this tool
-telBadIndex = -10017 #bad index specified
-telAPattNotSupp = -10016 #alerting pattern not supported by tool
-telBadAPattErr = -10015 #bad alerting pattern specified
-telVTypeNotSupp = -10014 #volume type not supported by this tool
-telBadVTypeErr = -10013 #bad volume type error
-telBadLevelErr = -10012 #bad volume level setting
-telHTypeNotSupp = -10011 #hook type not supported by this tool
-telBadHTypeErr = -10010 #bad hook type specified
-errAECantSupplyType = -10009 #errAECantSupplyType
-telNoOpenErr = -10008 #unable to open terminal
-telNoMemErr = -10007 #no memory to allocate handle
-errOSACantAssign = -10006 #Signaled when an object cannot be set in a container.
-telBadProcErr = -10005 #bad msgProc specified
-telBadHandErr = -10004 #bad handle specified
-OSAIllegalAssign = -10003 #Signaled when an object can never be set in a container
-telBadDNErr = -10002 #TELDNHandle not found or invalid
-telBadTermErr = -10001 #invalid TELHandle or handle not found
-errAEEventFailed = -10000 #errAEEventFailed
-cannotMoveAttachedController = -9999 #cannotMoveAttachedController
-controllerHasFixedHeight = -9998 #controllerHasFixedHeight
-cannotSetWidthOfAttachedController = -9997 #cannotSetWidthOfAttachedController
-controllerBoundsNotExact = -9996 #controllerBoundsNotExact
-editingNotAllowed = -9995 #editingNotAllowed
-badControllerHeight = -9994 #badControllerHeight
-deviceCantMeetRequest = -9408 #deviceCantMeetRequest
-seqGrabInfoNotAvailable = -9407 #seqGrabInfoNotAvailable
-badSGChannel = -9406 #badSGChannel
-couldntGetRequiredComponent = -9405 #couldntGetRequiredComponent
-notEnoughDiskSpaceToGrab = -9404 #notEnoughDiskSpaceToGrab
-notEnoughMemoryToGrab = -9403 #notEnoughMemoryToGrab
-cantDoThatInCurrentMode = -9402 #cantDoThatInCurrentMode
-grabTimeComplete = -9401 #grabTimeComplete
-noDeviceForChannel = -9400 #noDeviceForChannel
-kNoCardBusCISErr = -9109 #No valid CIS exists for this CardBus card
-kNotZVCapableErr = -9108 #This socket does not support Zoomed Video
-kCardPowerOffErr = -9107 #Power to the card has been turned off
-kAttemptDupCardEntryErr = -9106 #The Enabler was asked to create a duplicate card entry
-kAlreadySavedStateErr = -9105 #The state has been saved on previous call
-kTooManyIOWindowsErr = -9104 #device requested more than one I/O window
-kNotReadyErr = -9103 #PC Card failed to go ready
-kClientRequestDenied = -9102 #CS Clients should return this code inorder to
-kNoCompatibleNameErr = -9101 #There is no compatible driver name for this device
-kNoEnablerForCardErr = -9100 #No Enablers were found that can support the card
-kNoCardEnablersFoundErr = -9099 #No Enablers were found
-kUnsupportedCardErr = -9098 #Card not supported by generic enabler
-kNoClientTableErr = -9097 #The client table has not be initialized yet
-kNoMoreInterruptSlotsErr = -9096 #All internal Interrupt slots are in use
-kNoMoreTimerClientsErr = -9095 #All timer callbacks are in use
-kNoIOWindowRequestedErr = -9094 #Request I/O window before calling configuration
-kBadCustomIFIDErr = -9093 #Custom interface ID is invalid
-kBadTupleDataErr = -9092 #Data in tuple is invalid
-kInvalidCSClientErr = -9091 #Card Services ClientID is not registered
-kUnsupportedVsErr = -9090 #Unsupported Voltage Sense
-kInvalidDeviceNumber = -9089 #kInvalidDeviceNumber
-kPostCardEventErr = -9088 #_PCCSLPostCardEvent failed and dropped an event
-kCantConfigureCardErr = -9087 #kCantConfigureCardErr
-kPassCallToChainErr = -9086 #kPassCallToChainErr
-kCardBusCardErr = -9085 #kCardBusCardErr
-k16BitCardErr = -9084 #k16BitCardErr
-kBadDeviceErr = -9083 #kBadDeviceErr
-kBadLinkErr = -9082 #kBadLinkErr
-kInvalidRegEntryErr = -9081 #kInvalidRegEntryErr
-kNoCardSevicesSocketsErr = -9080 #kNoCardSevicesSocketsErr
-kOutOfResourceErr = -9079 #Card Services has exhausted the resource
-kNoMoreItemsErr = -9078 #there are no more of the requested item
-kInUseErr = -9077 #requested resource is being used by a client
-kConfigurationLockedErr = -9076 #a configuration has already been locked
-kWriteProtectedErr = -9075 #media is write-protected
-kBusyErr = -9074 #unable to process request at this time - try later
-kUnsupportedModeErr = -9073 #mode is not supported
-kUnsupportedFunctionErr = -9072 #function is not supported by this implementation
-kNoCardErr = -9071 #no PC card in the socket
-kGeneralFailureErr = -9070 #an undefined error has occurred
-kWriteFailureErr = -9069 #unable to complete write request
-kReadFailureErr = -9068 #unable to complete read request
-kBadSpeedErr = -9067 #specified speed is unavailable
-kBadCISErr = -9066 #CIS on card is invalid
-kBadHandleErr = -9065 #clientHandle is invalid
-kBadArgsErr = -9064 #values in argument packet are invalid
-kBadArgLengthErr = -9063 #ArgLength argument is invalid
-kBadWindowErr = -9062 #specified window is invalid
-kBadVppErr = -9061 #specified Vpp1 or Vpp2 power level index is invalid
-kBadVccErr = -9060 #specified Vcc power level index is invalid
-kBadTypeErr = -9059 #specified window or interface type is invalid
-kBadSocketErr = -9058 #specified logical or physical socket number is invalid
-kBadSizeErr = -9057 #specified size is invalid
-kBadPageErr = -9056 #specified page is invalid
-kBadOffsetErr = -9055 #specified PC card memory array offset is invalid
-kBadIRQErr = -9054 #specified IRQ level is invalid
-kBadEDCErr = -9053 #specified EDC generator specified is invalid
-kBadBaseErr = -9052 #specified base system memory address is invalid
-kBadAttributeErr = -9051 #specified attributes field value is invalid
-kBadAdapterErr = -9050 #invalid adapter number
-codecOffscreenFailedPleaseRetryErr = -8992 #codecOffscreenFailedPleaseRetryErr
-lockPortBitsWrongGDeviceErr = -8991 #lockPortBitsWrongGDeviceErr
-directXObjectAlreadyExists = -8990 #directXObjectAlreadyExists
-codecDroppedFrameErr = -8989 #returned from ImageCodecDrawBand
-codecOffscreenFailedErr = -8988 #codecOffscreenFailedErr
-codecNeedAccessKeyErr = -8987 #codec needs password in order to decompress
-codecParameterDialogConfirm = -8986 #codecParameterDialogConfirm
-lockPortBitsSurfaceLostErr = -8985 #lockPortBitsSurfaceLostErr
-lockPortBitsBadPortErr = -8984 #lockPortBitsBadPortErr
-lockPortBitsWindowClippedErr = -8983 #lockPortBitsWindowClippedErr
-lockPortBitsWindowResizedErr = -8982 #lockPortBitsWindowResizedErr
-lockPortBitsWindowMovedErr = -8981 #lockPortBitsWindowMovedErr
-lockPortBitsBadSurfaceErr = -8980 #lockPortBitsBadSurfaceErr
-codecNeedToFlushChainErr = -8979 #codecNeedToFlushChainErr
-codecDisabledErr = -8978 #codec disabled itself -- pass codecFlagReenable to reset
-codecNoMemoryPleaseWaitErr = -8977 #codecNoMemoryPleaseWaitErr
-codecNothingToBlitErr = -8976 #codecNothingToBlitErr
-codecCantQueueErr = -8975 #codecCantQueueErr
-codecCantWhenErr = -8974 #codecCantWhenErr
-codecOpenErr = -8973 #codecOpenErr
-codecConditionErr = -8972 #codecConditionErr
-codecExtensionNotFoundErr = -8971 #codecExtensionNotFoundErr
-codecDataVersErr = -8970 #codecDataVersErr
-codecBadDataErr = -8969 #codecBadDataErr
-codecWouldOffscreenErr = -8968 #codecWouldOffscreenErr
-codecAbortErr = -8967 #codecAbortErr
-codecSpoolErr = -8966 #codecSpoolErr
-codecImageBufErr = -8965 #codecImageBufErr
-codecScreenBufErr = -8964 #codecScreenBufErr
-codecSizeErr = -8963 #codecSizeErr
-codecUnimpErr = -8962 #codecUnimpErr
-noCodecErr = -8961 #noCodecErr
-codecErr = -8960 #codecErr
-kIllegalClockValueErr = -8852 #kIllegalClockValueErr
-kUTCOverflowErr = -8851 #kUTCOverflowErr
-kUTCUnderflowErr = -8850 #kUTCUnderflowErr
-kATSULastErr = -8809 #The last ATSUI error code.
-kATSULineBreakInWord = -8808 #This is not an error code but is returned by ATSUBreakLine to
-kATSUCoordinateOverflowErr = -8807 #Used to indicate the coordinates provided to an ATSUI routine caused
-kATSUNoFontScalerAvailableErr = -8806 #Used when no font scaler is available for the font passed
-kATSUNoFontCmapAvailableErr = -8805 #Used when no CMAP table can be accessed or synthesized for the
-kATSULowLevelErr = -8804 #Used when an error was encountered within the low level ATS
-kATSUQuickDrawTextErr = -8803 #Used when QuickDraw Text encounters an error rendering or measuring
-kATSUNoStyleRunsAssignedErr = -8802 #Used when an attempt was made to measure, highlight or draw
-kATSUNotSetErr = -8801 #Used when the client attempts to retrieve an attribute,
-kATSUInvalidCacheErr = -8800 #Used when an attempt was made to read in style data
-kATSUInvalidAttributeTagErr = -8799 #Used when an attempt was made to use a tag value that
-kATSUInvalidAttributeSizeErr = -8798 #Used when an attempt was made to use an attribute with a
-kATSUInvalidAttributeValueErr = -8797 #Used when an attempt was made to use an attribute with
-kATSUInvalidFontErr = -8796 #Used when an attempt was made to use an invalid font ID.
-kATSUNoCorrespondingFontErr = -8795 #This value is retrned by font ID conversion
-kATSUFontsNotMatched = -8794 #This value is returned by ATSUMatchFontsToText()
-kATSUFontsMatched = -8793 #This is not an error code but is returned by
-kATSUInvalidTextRangeErr = -8792 #An attempt was made to extract information
-kATSUInvalidStyleErr = -8791 #An attempt was made to use a ATSUStyle which
-kATSUInvalidTextLayoutErr = -8790 #An attempt was made to use a ATSUTextLayout
-kTECOutputBufferFullStatus = -8785 #output buffer has no room for conversion of next input text element (partial conversion)
-kTECNeedFlushStatus = -8784 #kTECNeedFlushStatus
-kTECUsedFallbacksStatus = -8783 #kTECUsedFallbacksStatus
-kTECItemUnavailableErr = -8771 #item (e.g. name) not available for specified region (& encoding if relevant)
-kTECGlobalsUnavailableErr = -8770 #globals have already been deallocated (premature TERM)
-unicodeChecksumErr = -8769 #unicodeChecksumErr
-unicodeNoTableErr = -8768 #unicodeNoTableErr
-unicodeVariantErr = -8767 #unicodeVariantErr
-unicodeFallbacksErr = -8766 #unicodeFallbacksErr
-unicodePartConvertErr = -8765 #unicodePartConvertErr
-unicodeBufErr = -8764 #unicodeBufErr
-unicodeCharErr = -8763 #unicodeCharErr
-unicodeElementErr = -8762 #unicodeElementErr
-unicodeNotFoundErr = -8761 #unicodeNotFoundErr
-unicodeTableFormatErr = -8760 #unicodeTableFormatErr
-unicodeDirectionErr = -8759 #unicodeDirectionErr
-unicodeContextualErr = -8758 #unicodeContextualErr
-unicodeTextEncodingDataErr = -8757 #unicodeTextEncodingDataErr
-kTECDirectionErr = -8756 #direction stack overflow, etc.
-kTECIncompleteElementErr = -8755 #text element may be incomplete or is too long for internal buffers
-kTECUnmappableElementErr = -8754 #kTECUnmappableElementErr
-kTECPartialCharErr = -8753 #input buffer ends in the middle of a multibyte character, conversion stopped
-kTECBadTextRunErr = -8752 #kTECBadTextRunErr
-kTECArrayFullErr = -8751 #supplied name buffer or TextRun, TextEncoding, or UnicodeMapping array is too small
-kTECBufferBelowMinimumSizeErr = -8750 #output buffer too small to allow processing of first input text element
-kTECNoConversionPathErr = -8749 #kTECNoConversionPathErr
-kTECCorruptConverterErr = -8748 #invalid converter object reference
-kTECTableFormatErr = -8747 #kTECTableFormatErr
-kTECTableChecksumErr = -8746 #kTECTableChecksumErr
-kTECMissingTableErr = -8745 #kTECMissingTableErr
-kTextUndefinedElementErr = -8740 #text conversion errors
-kTextMalformedInputErr = -8739 #in DBCS, for example, high byte followed by invalid low byte
-kTextUnsupportedEncodingErr = -8738 #specified encoding not supported for this operation
-kRANotEnabled = -7139 #kRANotEnabled
-kRACallBackFailed = -7138 #kRACallBackFailed
-kRADuplicateIPAddr = -7137 #kRADuplicateIPAddr
-kRANCPRejectedbyPeer = -7136 #kRANCPRejectedbyPeer
-kRAExtAuthenticationFailed = -7135 #kRAExtAuthenticationFailed
-kRAATalkInactive = -7134 #kRAATalkInactive
-kRAPeerNotResponding = -7133 #kRAPeerNotResponding
-kRAPPPPeerDisconnected = -7132 #kRAPPPPeerDisconnected
-kRAPPPUserDisconnected = -7131 #kRAPPPUserDisconnected
-kRAPPPNegotiationFailed = -7130 #kRAPPPNegotiationFailed
-kRAPPPAuthenticationFailed = -7129 #kRAPPPAuthenticationFailed
-kRAPPPProtocolRejected = -7128 #kRAPPPProtocolRejected
-dcmBufferOverflowErr = -7127 #data is larger than buffer size
-kRANotPrimaryInterface = -7126 #when IPCP is not primary TCP/IP intf.
-kRATCPIPNotConfigured = -7125 #TCP/IP not configured, could be loaded
-kRATCPIPInactive = -7124 #TCP/IP inactive, cannot be loaded
-kRARemoteAccessNotReady = -7123 #kRARemoteAccessNotReady
-kRAInitOpenTransportFailed = -7122 #kRAInitOpenTransportFailed
-dcmProtectedErr = -7121 #need keyword to use dictionary
-kRAUserPwdEntryRequired = -7120 #kRAUserPwdEntryRequired
-kRAUserPwdChangeRequired = -7119 #kRAUserPwdChangeRequired
-dcmBadFindMethodErr = -7118 #no such find method supported
-kRAInvalidSerialProtocol = -7117 #kRAInvalidSerialProtocol
-kRAInvalidPortState = -7116 #kRAInvalidPortState
-dcmBadKeyErr = -7115 #bad key information
-kRAPortBusy = -7114 #kRAPortBusy
-kRAInstallationDamaged = -7113 #kRAInstallationDamaged
-dcmBadFieldTypeErr = -7112 #no such field type supported
-dcmBadFieldInfoErr = -7111 #incomplete information
-dcmNecessaryFieldErr = -7110 #lack required/identify field
-dcmDupRecordErr = -7109 #same record already exist
-kRANotConnected = -7108 #kRANotConnected
-dcmBlockFullErr = -7107 #dictionary block full
-kRAMissingResources = -7106 #kRAMissingResources
-dcmDictionaryBusyErr = -7105 #dictionary is busy
-dcmDictionaryNotOpenErr = -7104 #dictionary not opened
-dcmPermissionErr = -7103 #invalid permission
-dcmBadDictionaryErr = -7102 #invalid dictionary
-dcmNotDictionaryErr = -7101 #not dictionary
-kRAInvalidParameter = -7100 #kRAInvalidParameter
-laEngineNotFoundErr = -7000 #can't find the engine
-laPropertyErr = -6999 #Error in properties
-kUSBUnknownDeviceErr = -6998 #device ref not recognised
-laPropertyIsReadOnlyErr = -6997 #the property is read only
-laPropertyUnknownErr = -6996 #the property is unknown to this environment
-laPropertyValueErr = -6995 #Invalid property value
-laDictionaryTooManyErr = -6994 #too many dictionaries
-laDictionaryUnknownErr = -6993 #can't use this dictionary with this environment
-laDictionaryNotOpenedErr = -6992 #the dictionary is not opened
-laTextOverFlowErr = -6991 #text is too long
-laFailAnalysisErr = -6990 #analysis failed
-laNoMoreMorphemeErr = -6989 #nothing to read
-laInvalidPathErr = -6988 #path is not correct
-kUSBNotHandled = -6987 #Notification was not handled (same as NotFound)
-laEnvironmentNotFoundErr = -6986 #can't fint the specified environment
-laEnvironmentBusyErr = -6985 #specified environment is used
-laTooSmallBufferErr = -6984 #output buffer is too small to store any result
-kUSBFlagsError = -6983 #Unused flags not zeroed
-kUSBAbortedError = -6982 #Pipe aborted
-kUSBNoBandwidthError = -6981 #Not enough bandwidth available
-kUSBPipeIdleError = -6980 #Pipe is Idle, it will not accept transactions
-kUSBPipeStalledError = -6979 #Pipe has stalled, error needs to be cleared
-kUSBUnknownInterfaceErr = -6978 #Interface ref not recognised
-kUSBDeviceBusy = -6977 #Device is already being configured
-kUSBDevicePowerProblem = -6976 #Device has a power problem
-kUSBInvalidBuffer = -6975 #bad buffer, usually nil
-kUSBDeviceSuspended = -6974 #Device is suspended
-kUSBDeviceNotSuspended = -6973 #device is not suspended for resume
-kUSBDeviceDisconnected = -6972 #Disconnected during suspend or reset
-kUSBTimedOut = -6971 #Transaction timed out.
-kUSBQueueAborted = -6970 #Pipe zero stall cleared.
-kUSBPortDisabled = -6969 #The port you are attached to is disabled, use USBDeviceReset.
-kUSBBadDispatchTable = -6950 #Improper driver dispatch table
-kUSBUnknownNotification = -6949 #Notification type not defined
-kUSBQueueFull = -6948 #Internal queue maxxed
-kUSBLinkErr = -6916 #kUSBLinkErr
-kUSBCRCErr = -6915 #Pipe stall, bad CRC
-kUSBBitstufErr = -6914 #Pipe stall, bitstuffing
-kUSBDataToggleErr = -6913 #Pipe stall, Bad data toggle
-kUSBEndpointStallErr = -6912 #Device didn't understand
-kUSBNotRespondingErr = -6911 #Pipe stall, No device, device hung
-kUSBPIDCheckErr = -6910 #Pipe stall, PID CRC error
-kUSBWrongPIDErr = -6909 #Pipe stall, Bad or wrong PID
-kUSBOverRunErr = -6908 #Packet too large or more data than buffer
-kUSBUnderRunErr = -6907 #Less data than buffer
-kUSBRes1Err = -6906 #kUSBRes1Err
-kUSBRes2Err = -6905 #kUSBRes2Err
-kUSBBufOvrRunErr = -6904 #Host hardware failure on data in, PCI busy?
-kUSBBufUnderRunErr = -6903 #Host hardware failure on data out, PCI busy?
-kUSBNotSent1Err = -6902 #Transaction not sent
-kUSBNotSent2Err = -6901 #Transaction not sent
-kDMFoundErr = -6232 #Did not proceed because we found an item
-kDMMainDisplayCannotMoveErr = -6231 #Trying to move main display (or a display mirrored to it)
-kDMDisplayAlreadyInstalledErr = -6230 #Attempt to add an already installed display.
-kDMDisplayNotFoundErr = -6229 #Could not find item (will someday remove).
-kDMDriverNotDisplayMgrAwareErr = -6228 #Video Driver does not support display manager.
-kDMSWNotInitializedErr = -6227 #Required software not initialized (eg windowmanager or display mgr).
-kSysSWTooOld = -6226 #Missing critical pieces of System Software.
-kDMMirroringNotOn = -6225 #Returned by all calls that need mirroring to be on to do their thing.
-kDMCantBlock = -6224 #Mirroring is already on, canÕt Block now (call DMUnMirror() first).
-kDMMirroringBlocked = -6223 #DMBlockMirroring() has been called.
-kDMWrongNumberOfDisplays = -6222 #Can only handle 2 displays for now.
-kDMMirroringOnAlready = -6221 #Returned by all calls that need mirroring to be off to do their thing.
-kDMGenErr = -6220 #Unexpected Error
-kQTSSUnknownErr = -6150 #kQTSSUnknownErr
-collectionVersionErr = -5753 #collectionVersionErr
-collectionIndexRangeErr = -5752 #collectionIndexRangeErr
-collectionItemNotFoundErr = -5751 #collectionItemNotFoundErr
-collectionItemLockedErr = -5750 #collectionItemLockedErr
-kNavMissingKindStringErr = -5699 #kNavMissingKindStringErr
-kNavInvalidCustomControlMessageErr = -5698 #kNavInvalidCustomControlMessageErr
-kNavCustomControlMessageFailedErr = -5697 #kNavCustomControlMessageFailedErr
-kNavInvalidSystemConfigErr = -5696 #kNavInvalidSystemConfigErr
-kNavWrongDialogClassErr = -5695 #kNavWrongDialogClassErr
-kNavWrongDialogStateErr = -5694 #kNavWrongDialogStateErr
-dialogNoTimeoutErr = -5640 #dialogNoTimeoutErr
-menuInvalidErr = -5623 #menu is invalid
-menuItemNotFoundErr = -5622 #specified menu item wasn't found
-menuUsesSystemDefErr = -5621 #GetMenuDefinition failed because the menu uses the system MDEF
-menuNotFoundErr = -5620 #specified menu or menu ID wasn't found
-windowWrongStateErr = -5615 #window is not in a state that is valid for the current action
-windowManagerInternalErr = -5614 #something really weird happened inside the window manager
-windowAttributesConflictErr = -5613 #passed some attributes that are mutually exclusive
-windowAttributeImmutableErr = -5612 #tried to change attributes which can't be changed
-errWindowDoesNotFitOnscreen = -5611 #ConstrainWindowToScreen could not make the window fit onscreen
-errWindowNotFound = -5610 #returned from FindWindowOfClass
-errFloatingWindowsNotInitialized = -5609 #called HideFloatingWindows or ShowFloatingWindows without calling InitFloatingWindows
-errWindowsAlreadyInitialized = -5608 #tried to call InitFloatingWindows twice, or called InitWindows and then floating windows
-errUserWantsToDragWindow = -5607 #if returned from TrackWindowProxyDrag, you should call DragWindow on the window
-errCorruptWindowDescription = -5606 #tried to load a corrupt window description (size or version fields incorrect)
-errUnrecognizedWindowClass = -5605 #tried to create a window with a bad WindowClass
-errWindowPropertyNotFound = -5604 #tried to get a nonexistent property
-errInvalidWindowProperty = -5603 #tried to access a property tag with private creator
-errWindowDoesNotHaveProxy = -5602 #tried to do something requiring a proxy to a window which doesnÕt have a proxy
-errUnsupportedWindowAttributesForClass = -5601 #tried to create a window with WindowAttributes not supported by the WindowClass
-errInvalidWindowPtr = -5600 #tried to pass a bad WindowRef argument
-gestaltLocationErr = -5553 #gestalt function ptr wasn't in sysheap
-gestaltDupSelectorErr = -5552 #tried to add an entry that already existed
-gestaltUndefSelectorErr = -5551 #undefined selector was passed to Gestalt
-gestaltUnknownErr = -5550 #value returned if Gestalt doesn't know the answer
-envVersTooBig = -5502 #Version bigger than call can handle
-envBadVers = -5501 #Version non-positive
-envNotPresent = -5500 #returned by glue.
-qtsAddressBusyErr = -5421 #qtsAddressBusyErr
-qtsConnectionFailedErr = -5420 #qtsConnectionFailedErr
-qtsTimeoutErr = -5408 #qtsTimeoutErr
-qtsUnknownValueErr = -5407 #qtsUnknownValueErr
-qtsTooMuchDataErr = -5406 #qtsTooMuchDataErr
-qtsUnsupportedFeatureErr = -5405 #qtsUnsupportedFeatureErr
-qtsUnsupportedRateErr = -5404 #qtsUnsupportedRateErr
-qtsUnsupportedDataTypeErr = -5403 #qtsUnsupportedDataTypeErr
-qtsBadDataErr = -5402 #something is wrong with the data
-qtsBadStateErr = -5401 #qtsBadStateErr
-qtsBadSelectorErr = -5400 #qtsBadSelectorErr
-errIAEndOfTextRun = -5388 #errIAEndOfTextRun
-errIATextExtractionErr = -5387 #errIATextExtractionErr
-errIAInvalidDocument = -5386 #errIAInvalidDocument
-errIACanceled = -5385 #errIACanceled
-errIABufferTooSmall = -5384 #errIABufferTooSmall
-errIANoMoreItems = -5383 #errIANoMoreItems
-errIAParamErr = -5382 #errIAParamErr
-errIAAllocationErr = -5381 #errIAAllocationErr
-errIAUnknownErr = -5380 #errIAUnknownErr
-hrURLNotHandledErr = -5363 #hrURLNotHandledErr
-hrUnableToResizeHandleErr = -5362 #hrUnableToResizeHandleErr
-hrMiscellaneousExceptionErr = -5361 #hrMiscellaneousExceptionErr
-hrHTMLRenderingLibNotInstalledErr = -5360 #hrHTMLRenderingLibNotInstalledErr
-errCannotUndo = -5253 #errCannotUndo
-errNonContiuousAttribute = -5252 #errNonContiuousAttribute
-errUnknownElement = -5251 #errUnknownElement
-errReadOnlyText = -5250 #errReadOnlyText
-errEmptyScrap = -5249 #errEmptyScrap
-errNoHiliteText = -5248 #errNoHiliteText
-errOffsetNotOnElementBounday = -5247 #errOffsetNotOnElementBounday
-errInvalidRange = -5246 #errInvalidRange
-errIteratorReachedEnd = -5245 #errIteratorReachedEnd
-errEngineNotFound = -5244 #errEngineNotFound
-errAlreadyInImagingMode = -5243 #errAlreadyInImagingMode
-errNotInImagingMode = -5242 #errNotInImagingMode
-errMarginWilllNotFit = -5241 #errMarginWilllNotFit
-errUnknownAttributeTag = -5240 #errUnknownAttributeTag
-afpSameNodeErr = -5063 #An Attempt was made to connect to a file server running on the same machine
-afpAlreadyMounted = -5062 #The volume is already mounted
-afpCantMountMoreSrvre = -5061 #The Maximum number of server connections has been reached
-afpBadDirIDType = -5060 #afpBadDirIDType
-afpCallNotAllowed = -5048 #The server knows what you wanted to do, but won't let you do it just now
-afpAlreadyLoggedInErr = -5047 #User has been authenticated but is already logged in from another machine (and that's not allowed on this server)
-afpPwdPolicyErr = -5046 #Password does not conform to servers password policy
-afpPwdNeedsChangeErr = -5045 #The password needs to be changed
-afpInsideTrashErr = -5044 #The folder being shared is inside the trash folder OR the shared folder is being moved into the trash folder
-afpInsideSharedErr = -5043 #The folder being shared is inside a shared folder OR the folder contains a shared folder and is being moved into a shared folder
-afpPwdExpiredErr = -5042 #The password being used is too old: this requires the user to change the password before log-in can continue
-afpPwdTooShortErr = -5041 #The password being set is too short: there is a minimum length that must be met or exceeded
-afpPwdSameErr = -5040 #Someone tried to change their password to the same password on a mantadory password change
-afpBadIDErr = -5039 #afpBadIDErr
-afpSameObjectErr = -5038 #afpSameObjectErr
-afpCatalogChanged = -5037 #afpCatalogChanged
-afpDiffVolErr = -5036 #afpDiffVolErr
-afpIDExists = -5035 #afpIDExists
-afpIDNotFound = -5034 #afpIDNotFound
-afpContainsSharedErr = -5033 #the folder being shared contains a shared folder
-afpObjectLocked = -5032 #Object is M/R/D/W inhibited
-afpVolLocked = -5031 #Volume is Read-Only
-afpIconTypeError = -5030 #Icon size specified different from existing icon size
-afpDirNotFound = -5029 #Unknown directory specified
-afpCantRename = -5028 #AFPRename cannot rename volume
-afpServerGoingDown = -5027 #Server is shutting down
-afpTooManyFilesOpen = -5026 #Maximum open file count reached
-afpObjectTypeErr = -5025 #File/Directory specified where Directory/File expected
-afpCallNotSupported = -5024 #Unsupported AFP call was made
-afpUserNotAuth = -5023 #No AFPLogin call has successfully been made for this session
-afpSessClosed = -5022 #Session closed
-afpRangeOverlap = -5021 #Some or all of range already locked by same user
-afpRangeNotLocked = -5020 #Tried to unlock range that was not locked by user
-afpParmErr = -5019 #A specified parameter was out of allowable range
-afpObjectNotFound = -5018 #Specified file or directory does not exist
-afpObjectExists = -5017 #Specified destination file or directory already exists
-afpNoServer = -5016 #Server not responding
-afpNoMoreLocks = -5015 #Maximum lock limit reached
-afpMiscErr = -5014 #Unexpected error encountered during execution
-afpLockErr = -5013 #Some or all of requested range is locked by another user
-afpItemNotFound = -5012 #Unknown UserName/UserID or missing comment/APPL entry
-afpFlatVol = -5011 #Cannot create directory on specified volume
-afpFileBusy = -5010 #Cannot delete an open file
-afpEofError = -5009 #Read beyond logical end-of-file
-afpDiskFull = -5008 #Insufficient free space on volume for operation
-afpDirNotEmpty = -5007 #Cannot delete non-empty directory
-afpDenyConflict = -5006 #Specified open/deny modes conflict with current open modes
-afpCantMove = -5005 #Move destination is offspring of source, or root was specified
-afpBitmapErr = -5004 #Bitmap contained bits undefined for call
-afpBadVersNum = -5003 #Unknown AFP protocol version number specified
-afpBadUAM = -5002 #Unknown user authentication method specified
-afpAuthContinue = -5001 #Further information required to complete AFPLogin call
-afpAccessDenied = -5000 #Insufficient access privileges for operation
-illegalScrapFlavorSizeErr = -4999 #illegalScrapFlavorSizeErr
-illegalScrapFlavorTypeErr = -4998 #illegalScrapFlavorTypeErr
-illegalScrapFlavorFlagsErr = -4997 #illegalScrapFlavorFlagsErr
-scrapFlavorSizeMismatchErr = -4996 #scrapFlavorSizeMismatchErr
-scrapFlavorFlagsMismatchErr = -4995 #scrapFlavorFlagsMismatchErr
-nilScrapFlavorDataErr = -4994 #nilScrapFlavorDataErr
-noScrapPromiseKeeperErr = -4993 #noScrapPromiseKeeperErr
-scrapPromiseNotKeptErr = -4992 #scrapPromiseNotKeptErr
-processStateIncorrectErr = -4991 #processStateIncorrectErr
-badScrapRefErr = -4990 #badScrapRefErr
-duplicateScrapFlavorErr = -4989 #duplicateScrapFlavorErr
-internalScrapErr = -4988 #internalScrapErr
-coreFoundationUnknownErr = -4960 #coreFoundationUnknownErr
-badRoutingSizeErr = -4276 #badRoutingSizeErr
-routingNotFoundErr = -4275 #routingNotFoundErr
-duplicateRoutingErr = -4274 #duplicateRoutingErr
-invalidFolderTypeErr = -4273 #invalidFolderTypeErr
-noMoreFolderDescErr = -4272 #noMoreFolderDescErr
-duplicateFolderDescErr = -4271 #duplicateFolderDescErr
-badFolderDescErr = -4270 #badFolderDescErr
-cmCantGamutCheckError = -4217 #Gammut checking not supported by this ColorWorld
-cmNamedColorNotFound = -4216 #NamedColor not found
-cmCantCopyModifiedV1Profile = -4215 #Illegal to copy version 1 profiles that have been modified
-cmRangeOverFlow = -4214 #Color conversion warning that some output color values over/underflowed and were clipped
-cmInvalidProfileComment = -4213 #Bad Profile comment during drawpicture
-cmNoGDevicesError = -4212 #Begin/End Matching -- no gdevices available
-cmInvalidDstMap = -4211 #Destination pix/bit map was invalid
-cmInvalidSrcMap = -4210 #Source pix/bit map was invalid
-cmInvalidColorSpace = -4209 #Profile colorspace does not match bitmap type
-cmErrIncompatibleProfile = -4208 #Other ColorSync Errors
-cmSearchError = -4207 #cmSearchError
-cmInvalidSearch = -4206 #Bad Search Handle
-cmInvalidProfileLocation = -4205 #Operation not supported for this profile location
-cmInvalidProfile = -4204 #A Profile must contain a 'cs1 ' tag to be valid
-cmFatalProfileErr = -4203 #cmFatalProfileErr
-cmCantDeleteElement = -4202 #cmCantDeleteElement
-cmIndexRangeErr = -4201 #Tag index out of range
-kNSLInitializationFailed = -4200 #UNABLE TO INITIALIZE THE MANAGER!!!!! DO NOT CONTINUE!!!!
-kNSLNotInitialized = -4199 #kNSLNotInitialized
-kNSLInsufficientSysVer = -4198 #kNSLInsufficientSysVer
-kNSLInsufficientOTVer = -4197 #kNSLInsufficientOTVer
-kNSLNoElementsInList = -4196 #kNSLNoElementsInList
-kNSLBadReferenceErr = -4195 #kNSLBadReferenceErr
-kNSLBadServiceTypeErr = -4194 #kNSLBadServiceTypeErr
-kNSLBadDataTypeErr = -4193 #kNSLBadDataTypeErr
-kNSLBadNetConnection = -4192 #kNSLBadNetConnection
-kNSLNoSupportForService = -4191 #kNSLNoSupportForService
-kNSLInvalidPluginSpec = -4190 #kNSLInvalidPluginSpec
-kNSLRequestBufferAlreadyInList = -4189 #kNSLRequestBufferAlreadyInList
-kNSLNoContextAvailable = -4188 #(ContinueLookup function ptr invalid)
-kNSLBufferTooSmallForData = -4187 #(Client buffer too small for data from plugin)
-kNSLCannotContinueLookup = -4186 #(Can't continue lookup; error or bad state)
-kNSLBadClientInfoPtr = -4185 #(nil ClientAsyncInfoPtr; no reference available)
-kNSLNullListPtr = -4184 #(client is trying to add items to a nil list)
-kNSLBadProtocolTypeErr = -4183 #(client is trying to add a null protocol type)
-kNSLPluginLoadFailed = -4182 #(manager unable to load one of the plugins)
-kNSLNoPluginsFound = -4181 #(manager didn't find any valid plugins to load)
-kNSLSearchAlreadyInProgress = -4180 #(you can only have one ongoing search per clientRef)
-kNSLNoPluginsForSearch = -4179 #(no plugins will respond to search request; bad protocol(s)?)
-kNSLNullNeighborhoodPtr = -4178 #(client passed a null neighborhood ptr)
-kNSLSomePluginsFailedToLoad = -4177 #(one or more plugins failed to load, but at least one did load; this error isn't fatal)
-kNSLErrNullPtrError = -4176 #kNSLErrNullPtrError
-kNSLNotImplementedYet = -4175 #kNSLNotImplementedYet
-kNSLUILibraryNotAvailable = -4174 #The NSL UI Library needs to be in the Extensions Folder
-kNSLNoCarbonLib = -4173 #kNSLNoCarbonLib
-kNSLBadURLSyntax = -4172 #URL contains illegal characters
-kNSLSchedulerError = -4171 #A custom thread routine encountered an error
-kNSL68kContextNotSupported = -4170 #no 68k allowed
-noHelpForItem = -4009 #noHelpForItem
-badProfileError = -4008 #badProfileError
-colorSyncNotInstalled = -4007 #colorSyncNotInstalled
-pickerCantLive = -4006 #pickerCantLive
-cantLoadPackage = -4005 #cantLoadPackage
-cantCreatePickerWindow = -4004 #cantCreatePickerWindow
-cantLoadPicker = -4003 #cantLoadPicker
-pickerResourceError = -4002 #pickerResourceError
-requiredFlagsDontMatch = -4001 #requiredFlagsDontMatch
-firstPickerError = -4000 #firstPickerError
-kOTPortLostConnection = -3285 #
-kOTUserRequestedErr = -3284 #
-kOTConfigurationChangedErr = -3283 #
-kOTBadConfigurationErr = -3282 #
-kOTPortWasEjectedErr = -3281 #
-kOTPortHasDiedErr = -3280 #
-kOTClientNotInittedErr = -3279 #
-kENOMSGErr = -3278 #
-kESRCHErr = -3277 #
-kEINPROGRESSErr = -3276 #
-kENODATAErr = -3275 #
-kENOSTRErr = -3274 #
-kECANCELErr = -3273 #
-kEBADMSGErr = -3272 #
-kENOSRErr = -3271 #
-kETIMEErr = -3270 #
-kEPROTOErr = -3269 #‚‚‚ fill out missing codes ‚‚‚
-kEHOSTUNREACHErr = -3264 #No route to host
-kEHOSTDOWNErr = -3263 #Host is down
-kECONNREFUSEDErr = -3260 #Connection refused
-kETIMEDOUTErr = -3259 #Connection timed out
-kETOOMANYREFSErr = -3258 #Too many references: can't splice
-kESHUTDOWNErr = -3257 #Can't send after socket shutdown
-kENOTCONNErr = -3256 #Socket is not connected
-kEISCONNErr = -3255 #Socket is already connected
-kENOBUFSErr = -3254 #No buffer space available
-kECONNRESETErr = -3253 #Connection reset by peer
-kECONNABORTEDErr = -3252 #Software caused connection abort
-kENETRESETErr = -3251 #Network dropped connection on reset
-kENETUNREACHErr = -3250 #Network is unreachable
-kENETDOWNErr = -3249 #Network is down
-kEADDRNOTAVAILErr = -3248 #Can't assign requested address
-kEADDRINUSEErr = -3247 #Address already in use
-kEOPNOTSUPPErr = -3244 #Operation not supported on socket
-kESOCKTNOSUPPORTErr = -3243 #Socket type not supported
-kEPROTONOSUPPORTErr = -3242 #Protocol not supported
-kENOPROTOOPTErr = -3241 #Protocol not available
-kEPROTOTYPEErr = -3240 #Protocol wrong type for socket
-kEMSGSIZEErr = -3239 #Message too long
-kEDESTADDRREQErr = -3238 #Destination address required
-kENOTSOCKErr = -3237 #Socket operation on non-socket
-kEALREADYErr = -3236 #
-kEWOULDBLOCKErr = -3234 #Call would block, so was aborted
-kERANGEErr = -3233 #Message size too large for STREAM
-kEPIPEErr = -3231 #Broken pipe
-kENOTTYErr = -3224 #Not a character device
-kEINVALErr = -3221 #Invalid argument
-kENODEVErr = -3218 #No such device
-kOTDuplicateFoundErr = -3216 #OT generic duplicate found error
-kEBUSYErr = -3215 #Device or resource busy
-kEFAULTErr = -3213 #Bad address
-kEACCESErr = -3212 #Permission denied
-kOTOutOfMemoryErr = -3211 #OT ran out of memory, may be a temporary
-kEAGAINErr = -3210 #Try operation again later
-kEBADFErr = -3208 #Bad file number
-kENXIOErr = -3205 #No such device or address
-kEIOErr = -3204 #I/O error
-kEINTRErr = -3203 #Interrupted system service
-kENORSRCErr = -3202 #No such resource
-kOTNotFoundErr = -3201 #OT generic not found error
-kEPERMErr = -3200 #Permission denied
-kOTCanceledErr = -3180 #XTI2OSStatus(TCANCELED) The command was cancelled
-kOTBadSyncErr = -3179 #XTI2OSStatus(TBADSYNC) A synchronous call at interrupt time
-kOTProtocolErr = -3178 #XTI2OSStatus(TPROTO) An unspecified provider error occurred
-kOTQFullErr = -3177 #XTI2OSStatus(TQFULL)
-kOTResAddressErr = -3176 #XTI2OSStatus(TRESADDR)
-kOTResQLenErr = -3175 #XTI2OSStatus(TRESQLEN)
-kOTProviderMismatchErr = -3174 #XTI2OSStatus(TPROVMISMATCH) Tried to accept on incompatible endpoint
-kOTIndOutErr = -3173 #XTI2OSStatus(TINDOUT) Accept failed because of pending listen
-kOTAddressBusyErr = -3172 #XTI2OSStatus(TADDRBUSY) Address requested is already in use
-kOTBadQLenErr = -3171 #XTI2OSStatus(TBADQLEN) A Bind to an in-use addr with qlen > 0
-kOTBadNameErr = -3170 #XTI2OSStatus(TBADNAME) A bad endpoint name was supplied
-kOTNoStructureTypeErr = -3169 #XTI2OSStatus(TNOSTRUCTYPE) Bad structure type requested for OTAlloc
-kOTStateChangeErr = -3168 #XTI2OSStatus(TSTATECHNG) State is changing - try again later
-kOTNotSupportedErr = -3167 #XTI2OSStatus(TNOTSUPPORT) Command is not supported
-kOTNoReleaseErr = -3166 #XTI2OSStatus(TNOREL) No orderly release indication available
-kOTBadFlagErr = -3165 #XTI2OSStatus(TBADFLAG) A Bad flag value was supplied
-kOTNoUDErrErr = -3164 #XTI2OSStatus(TNOUDERR) No Unit Data Error indication available
-kOTNoDisconnectErr = -3163 #XTI2OSStatus(TNODIS) No disconnect indication available
-kOTNoDataErr = -3162 #XTI2OSStatus(TNODATA) No data available for reading
-kOTFlowErr = -3161 #XTI2OSStatus(TFLOW) Provider is flow-controlled
-kOTBufferOverflowErr = -3160 #XTI2OSStatus(TBUFOVFLW) Passed buffer not big enough
-kOTBadDataErr = -3159 #XTI2OSStatus(TBADDATA) An illegal amount of data was specified
-kOTLookErr = -3158 #XTI2OSStatus(TLOOK) An event occurred - call Look()
-kOTSysErrorErr = -3157 #XTI2OSStatus(TSYSERR) A system error occurred
-kOTBadSequenceErr = -3156 #XTI2OSStatus(TBADSEQ) Sequence specified does not exist
-kOTOutStateErr = -3155 #XTI2OSStatus(TOUTSTATE) Call issued in wrong state
-kOTNoAddressErr = -3154 #XTI2OSStatus(TNOADDR) No address was specified
-kOTBadReferenceErr = -3153 #XTI2OSStatus(TBADF) Bad provider reference
-kOTAccessErr = -3152 #XTI2OSStatus(TACCES) Missing access permission
-kOTBadOptionErr = -3151 #XTI2OSStatus(TBADOPT) A Bad option was specified
-kOTBadAddressErr = -3150 #XTI2OSStatus(TBADADDR) A Bad address was specified
-sktClosedErr = -3109 #sktClosedErr
-recNotFnd = -3108 #recNotFnd
-atpBadRsp = -3107 #atpBadRsp
-atpLenErr = -3106 #atpLenErr
-readQErr = -3105 #readQErr
-extractErr = -3104 #extractErr
-ckSumErr = -3103 #ckSumErr
-noMPPErr = -3102 #noMPPErr
-buf2SmallErr = -3101 #buf2SmallErr
-noPrefAppErr = -3032 #noPrefAppErr
-badTranslationSpecErr = -3031 #badTranslationSpecErr
-noTranslationPathErr = -3030 #noTranslationPathErr
-couldNotParseSourceFileErr = -3026 #Source document does not contain source type
-invalidTranslationPathErr = -3025 #Source type to destination type not a valid path
-retryComponentRegistrationErr = -3005 #retryComponentRegistrationErr
-unresolvedComponentDLLErr = -3004 #unresolvedComponentDLLErr
-componentDontRegister = -3003 #componentDontRegister
-componentNotCaptured = -3002 #componentNotCaptured
-validInstancesExist = -3001 #validInstancesExist
-invalidComponentID = -3000 #invalidComponentID
-cfragLastErrCode = -2899 #The last value in the range of CFM errors.
-cfragOutputLengthErr = -2831 #An output parameter is too small to hold the value.
-cfragAbortClosureErr = -2830 #Used by notification handlers to abort a closure.
-cfragClosureIDErr = -2829 #The closure ID was not valid.
-cfragContainerIDErr = -2828 #The fragment container ID was not valid.
-cfragNoRegistrationErr = -2827 #The registration name was not found.
-cfragNotClosureErr = -2826 #The closure ID was actually a connection ID.
-cfragFileSizeErr = -2825 #A file was too large to be mapped.
-cfragFragmentUsageErr = -2824 #A semantic error in usage of the fragment.
-cfragArchitectureErr = -2823 #A fragment has an unacceptable architecture.
-cfragNoApplicationErr = -2822 #No application member found in the cfrg resource.
-cfragInitFunctionErr = -2821 #A fragment's initialization routine returned an error.
-cfragFragmentCorruptErr = -2820 #A fragment's container was corrupt (known format).
-cfragCFMInternalErr = -2819 #An internal inconstistancy has been detected.
-cfragCFMStartupErr = -2818 #Internal error during CFM initialization.
-cfragLibConnErr = -2817 #
-cfragInitAtBootErr = -2816 #A boot library has an initialization function. (System 7 only)
-cfragInitLoopErr = -2815 #Circularity in required initialization order.
-cfragImportTooNewErr = -2814 #An import library was too new for a client.
-cfragImportTooOldErr = -2813 #An import library was too old for a client.
-cfragInitOrderErr = -2812 #
-cfragNoIDsErr = -2811 #No more CFM IDs for contexts, connections, etc.
-cfragNoClientMemErr = -2810 #Out of memory for fragment mapping or section instances.
-cfragNoPrivateMemErr = -2809 #Out of memory for internal bookkeeping.
-cfragNoPositionErr = -2808 #The registration insertion point was not found.
-cfragUnresolvedErr = -2807 #A fragment had "hard" unresolved imports.
-cfragFragmentFormatErr = -2806 #A fragment's container format is unknown.
-cfragDupRegistrationErr = -2805 #The registration name was already in use.
-cfragNoLibraryErr = -2804 #The named library was not found.
-cfragNoSectionErr = -2803 #The specified section was not found.
-cfragNoSymbolErr = -2802 #The specified symbol was not found.
-cfragConnectionIDErr = -2801 #The connection ID was not valid.
-cfragFirstErrCode = -2800 #The first value in the range of CFM errors.
-errASInconsistentNames = -2780 #English errors:
-errASNoResultReturned = -2763 #The range -2780 thru -2799 is reserved for dialect specific error codes. (Error codes from different dialects may overlap.)
-errASParameterNotForEvent = -2762 #errASParameterNotForEvent
-errASIllegalFormalParameter = -2761 #errASIllegalFormalParameter
-errASTerminologyNestingTooDeep = -2760 #errASTerminologyNestingTooDeep
-OSAControlFlowError = -2755 #Signaled when illegal control flow occurs in an application (no catcher for throw, non-lexical loop exit, etc.)
-OSAInconsistentDeclarations = -2754 #Signaled when a variable is declared inconsistently in the same scope, such as both local and global
-OSAUndefinedVariable = -2753 #Signaled when a variable is accessed that has no value
-OSADuplicateHandler = -2752 #Signaled when more than one handler is defined with the same name in a scope where the language doesn't allow it
-OSADuplicateProperty = -2751 #Signaled when a formal parameter, local variable, or instance variable is specified more than once.
-OSADuplicateParameter = -2750 #Signaled when a formal parameter, local variable, or instance variable is specified more than once
-OSATokenTooLong = -2742 #Signaled when a name or number is too long to be parsed
-OSASyntaxTypeError = -2741 #Signaled when another form of syntax was expected. (e.g. "expected a <type> but found <this>")
-OSASyntaxError = -2740 #Signaled when a syntax error occurs. (e.g. "Syntax error" or "<this> can't go after <that>")
-errASCantCompareMoreThan32k = -2721 #Parser/Compiler errors:
-errASCantConsiderAndIgnore = -2720 #errASCantConsiderAndIgnore
-errOSACantCreate = -2710 #errOSACantCreate
-errOSACantGetTerminology = -2709 #errOSACantGetTerminology
-errOSADataBlockTooLarge = -2708 #Signaled when an intrinsic limitation is exceeded for the size of a value or data structure.
-errOSAInternalTableOverflow = -2707 #Signaled when a runtime internal data structure overflows
-errOSAStackOverflow = -2706 #Signaled when the runtime stack overflows
-errOSACorruptTerminology = -2705 #Signaled when an application's terminology resource is not readable
-errOSAAppNotHighLevelEventAware = -2704 #Signaled when an application can't respond to AppleEvents
-errOSACantLaunch = -2703 #Signaled when application can't be launched or when it is remote and program linking is not enabled
-errOSANumericOverflow = -2702 #Signaled when integer or real value is too large to be represented
-errOSADivideByZero = -2701 #Signaled when there is an attempt to divide by zero
-errOSAGeneralError = -2700 #Signaled by user scripts or applications when no actual error code is to be returned.
-noIconDataAvailableErr = -2582 #The necessary icon data is not available
-noSuchIconErr = -2581 #The requested icon could not be found
-invalidIconRefErr = -2580 #The icon ref is not valid
-nrCallNotSupported = -2557 #This call is not available or supported on this machine
-nrTransactionAborted = -2556 #transaction was aborted
-nrExitedIteratorScope = -2555 #outer scope of iterator was exited
-nrIterationDone = -2554 #iteration operation is done
-nrPropertyAlreadyExists = -2553 #property already exists
-nrInvalidEntryIterationOp = -2552 #invalid entry iteration operation
-nrPathBufferTooSmall = -2551 #buffer for path is too small
-nrPathNotFound = -2550 #a path component lookup failed
-nrResultCodeBase = -2549 #nrResultCodeBase
-nrOverrunErr = -2548 #nrOverrunErr
-nrNotModifiedErr = -2547 #nrNotModifiedErr
-nrTypeMismatchErr = -2546 #nrTypeMismatchErr
-nrPowerSwitchAbortErr = -2545 #nrPowerSwitchAbortErr
-nrPowerErr = -2544 #nrPowerErr
-nrDataTruncatedErr = -2543 #nrDataTruncatedErr
-nrNotSlotDeviceErr = -2542 #nrNotSlotDeviceErr
-nrNameErr = -2541 #nrNameErr
-nrNotCreatedErr = -2540 #nrNotCreatedErr
-nrNotFoundErr = -2539 #nrNotFoundErr
-nrInvalidNodeErr = -2538 #nrInvalidNodeErr
-nrNotEnoughMemoryErr = -2537 #nrNotEnoughMemoryErr
-nrLockedErr = -2536 #nrLockedErr
-mmInternalError = -2526 #mmInternalError
-tsmDefaultIsNotInputMethodErr = -2524 #Current Input source is KCHR or uchr, not Input Method (GetDefaultInputMethod)
-tsmNoStem = -2523 #No stem exists for the token
-tsmNoMoreTokens = -2522 #No more tokens are available for the source text
-tsmNoHandler = -2521 #No Callback Handler exists for callback
-tsmInvalidContext = -2520 #Invalid TSMContext specified in call
-tsmUnknownErr = -2519 #any other errors
-tsmUnsupportedTypeErr = -2518 #unSupported interface type error
-tsmScriptHasNoIMErr = -2517 #script has no imput method or is using old IM
-tsmInputMethodIsOldErr = -2516 #returned by GetDefaultInputMethod
-tsmComponentAlreadyOpenErr = -2515 #text service already opened for the document
-tsmTSNotOpenErr = -2514 #text service is not open
-tsmTSHasNoMenuErr = -2513 #the text service has no menu
-tsmUseInputWindowErr = -2512 #not TSM aware because we are using input window
-tsmDocumentOpenErr = -2511 #there are open documents
-tsmTextServiceNotFoundErr = -2510 #no text service found
-tsmCantOpenComponentErr = -2509 #canÕt open the component
-tsmNoOpenTSErr = -2508 #no open text service
-tsmDocNotActiveErr = -2507 #document is NOT active
-tsmTSMDocBusyErr = -2506 #document is still active
-tsmInvalidDocIDErr = -2505 #invalid TSM documentation id
-tsmNeverRegisteredErr = -2504 #app never registered error (not TSM aware)
-tsmAlreadyRegisteredErr = -2503 #want to register again error
-tsmNotAnAppErr = -2502 #not an application error
-tsmInputMethodNotFoundErr = -2501 #tsmInputMethodNotFoundErr
-tsmUnsupScriptLanguageErr = -2500 #tsmUnsupScriptLanguageErr
-kernelUnrecoverableErr = -2499 #kernelUnrecoverableErr
-kernelReturnValueErr = -2422 #kernelReturnValueErr
-kernelAlreadyFreeErr = -2421 #kernelAlreadyFreeErr
-kernelIDErr = -2419 #kernelIDErr
-kernelExceptionErr = -2418 #kernelExceptionErr
-kernelTerminatedErr = -2417 #kernelTerminatedErr
-kernelInUseErr = -2416 #kernelInUseErr
-kernelTimeoutErr = -2415 #kernelTimeoutErr
-kernelAsyncReceiveLimitErr = -2414 #kernelAsyncReceiveLimitErr
-kernelAsyncSendLimitErr = -2413 #kernelAsyncSendLimitErr
-kernelAttributeErr = -2412 #kernelAttributeErr
-kernelExecutionLevelErr = -2411 #kernelExecutionLevelErr
-kernelDeletePermissionErr = -2410 #kernelDeletePermissionErr
-kernelExecutePermissionErr = -2409 #kernelExecutePermissionErr
-kernelReadPermissionErr = -2408 #kernelReadPermissionErr
-kernelWritePermissionErr = -2407 #kernelWritePermissionErr
-kernelObjectExistsErr = -2406 #kernelObjectExistsErr
-kernelUnsupportedErr = -2405 #kernelUnsupportedErr
-kernelPrivilegeErr = -2404 #kernelPrivilegeErr
-kernelOptionsErr = -2403 #kernelOptionsErr
-kernelCanceledErr = -2402 #kernelCanceledErr
-kernelIncompleteErr = -2401 #kernelIncompleteErr
-badCallOrderErr = -2209 #Usually due to a status call being called prior to being setup first
-noDMAErr = -2208 #CanÕt do DMA digitizing (i.e. can't go to requested dest
-badDepthErr = -2207 #CanÕt digitize into this depth
-notExactSizeErr = -2206 #CanÕt do exact size requested
-noMoreKeyColorsErr = -2205 #all key indexes in use
-notExactMatrixErr = -2204 #warning of bad matrix, digitizer did its best
-matrixErr = -2203 #bad matrix, digitizer did nothing
-qtParamErr = -2202 #bad input parameter (out of range, etc)
-digiUnimpErr = -2201 #feature unimplemented
-qtXMLApplicationErr = -2159 #qtXMLApplicationErr
-qtXMLParseErr = -2158 #qtXMLParseErr
-qtActionNotHandledErr = -2157 #qtActionNotHandledErr
-notEnoughDataErr = -2149 #notEnoughDataErr
-urlDataHFTPURLErr = -2148 #urlDataHFTPURLErr
-urlDataHFTPServerDisconnectedErr = -2147 #urlDataHFTPServerDisconnectedErr
-urlDataHFTPNoPasswordErr = -2146 #urlDataHFTPNoPasswordErr
-urlDataHFTPNeedPasswordErr = -2145 #urlDataHFTPNeedPasswordErr
-urlDataHFTPBadNameListErr = -2144 #urlDataHFTPBadNameListErr
-urlDataHFTPNoNetDriverErr = -2143 #urlDataHFTPNoNetDriverErr
-urlDataHFTPFilenameErr = -2142 #urlDataHFTPFilenameErr
-urlDataHFTPPermissionsErr = -2141 #urlDataHFTPPermissionsErr
-urlDataHFTPQuotaErr = -2140 #urlDataHFTPQuotaErr
-urlDataHFTPNoDirectoryErr = -2139 #urlDataHFTPNoDirectoryErr
-urlDataHFTPDataConnectionErr = -2138 #urlDataHFTPDataConnectionErr
-urlDataHFTPServerErr = -2137 #urlDataHFTPServerErr
-urlDataHFTPBadPasswordErr = -2136 #urlDataHFTPBadPasswordErr
-urlDataHFTPBadUserErr = -2135 #urlDataHFTPBadUserErr
-urlDataHFTPShutdownErr = -2134 #urlDataHFTPShutdownErr
-urlDataHFTPProtocolErr = -2133 #urlDataHFTPProtocolErr
-urlDataHHTTPRedirectErr = -2132 #urlDataHHTTPRedirectErr
-urlDataHHTTPURLErr = -2131 #urlDataHHTTPURLErr
-urlDataHHTTPNoNetDriverErr = -2130 #urlDataHHTTPNoNetDriverErr
-urlDataHHTTPProtocolErr = -2129 #urlDataHHTTPProtocolErr
-qtNetworkAlreadyAllocatedErr = -2127 #qtNetworkAlreadyAllocatedErr
-notAllowedToSaveMovieErr = -2126 #notAllowedToSaveMovieErr
-fileOffsetTooBigErr = -2125 #fileOffsetTooBigErr
-ASDEntryNotFoundErr = -2124 #ASDEntryNotFoundErr
-ASDBadForkErr = -2123 #ASDBadForkErr
-ASDBadHeaderErr = -2122 #ASDBadHeaderErr
-AAPNotFoundErr = -2121 #AAPNotFoundErr
-AAPNotCreatedErr = -2120 #AAPNotCreatedErr
-qfcbNotCreatedErr = -2119 #qfcbNotCreatedErr
-qfcbNotFoundErr = -2118 #qfcbNotFoundErr
-wackBadMetaDataErr = -2117 #wackBadMetaDataErr
-wackForkNotFoundErr = -2116 #wackForkNotFoundErr
-wackBadFileErr = -2115 #wackBadFileErr
-unknownFormatErr = -2114 #unknownFormatErr
-pathNotVerifiedErr = -2113 #pathNotVerifiedErr
-noPathMappingErr = -2112 #noPathMappingErr
-emptyPathErr = -2111 #emptyPathErr
-pathTooLongErr = -2110 #pathTooLongErr
-cannotBeLeafAtomErr = -2109 #cannotBeLeafAtomErr
-invalidAtomTypeErr = -2108 #invalidAtomTypeErr
-invalidAtomContainerErr = -2107 #invalidAtomContainerErr
-invalidAtomErr = -2106 #invalidAtomErr
-duplicateAtomTypeAndIDErr = -2105 #duplicateAtomTypeAndIDErr
-atomIndexInvalidErr = -2104 #atomIndexInvalidErr
-atomsNotOfSameTypeErr = -2103 #atomsNotOfSameTypeErr
-notLeafAtomErr = -2102 #notLeafAtomErr
-cannotFindAtomErr = -2101 #cannotFindAtomErr
-unsupportedProcessorErr = -2097 #unsupportedProcessorErr
-unsupportedOSErr = -2096 #unsupportedOSErr
-qtmlUninitialized = -2095 #qtmlUninitialized
-qtmlDllEntryNotFoundErr = -2094 #Windows specific errors (when qtml is loading)
-qtmlDllLoadErr = -2093 #Windows specific errors (when qtml is loading)
-componentDllEntryNotFoundErr = -2092 #Windows specific errors (when component is loading)
-componentDllLoadErr = -2091 #Windows specific errors (when component is loading)
-videoOutputInUseErr = -2090 #videoOutputInUseErr
-noExportProcAvailableErr = -2089 #noExportProcAvailableErr
-tuneParseOSErr = -2087 #tuneParseOSErr
-tunePlayerFullOSErr = -2086 #tunePlayerFullOSErr
-noteChannelNotAllocatedOSErr = -2085 #noteChannelNotAllocatedOSErr
-illegalNoteChannelOSErr = -2084 #illegalNoteChannelOSErr
-synthesizerOSErr = -2083 #synthesizerOSErr
-synthesizerNotRespondingOSErr = -2082 #synthesizerNotRespondingOSErr
-midiManagerAbsentOSErr = -2081 #midiManagerAbsentOSErr
-illegalControllerOSErr = -2080 #illegalControllerOSErr
-illegalInstrumentOSErr = -2079 #illegalInstrumentOSErr
-illegalKnobValueOSErr = -2078 #illegalKnobValueOSErr
-illegalKnobOSErr = -2077 #illegalKnobOSErr
-illegalChannelOSErr = -2076 #illegalChannelOSErr
-illegalPartOSErr = -2075 #illegalPartOSErr
-illegalVoiceAllocationOSErr = -2074 #illegalVoiceAllocationOSErr
-cantReceiveFromSynthesizerOSErr = -2073 #cantReceiveFromSynthesizerOSErr
-cantSendToSynthesizerOSErr = -2072 #cantSendToSynthesizerOSErr
-notImplementedMusicOSErr = -2071 #notImplementedMusicOSErr
-internalComponentErr = -2070 #internalComponentErr
-invalidSpriteIDErr = -2069 #invalidSpriteIDErr
-invalidImageIndexErr = -2068 #invalidImageIndexErr
-invalidSpriteIndexErr = -2067 #invalidSpriteIndexErr
-gWorldsNotSameDepthAndSizeErr = -2066 #gWorldsNotSameDepthAndSizeErr
-invalidSpritePropertyErr = -2065 #invalidSpritePropertyErr
-invalidSpriteWorldPropertyErr = -2064 #invalidSpriteWorldPropertyErr
-missingRequiredParameterErr = -2063 #missingRequiredParameterErr
-movieTextNotFoundErr = -2062 #movieTextNotFoundErr
-sourceNotFoundErr = -2061 #sourceNotFoundErr
-noSourceTreeFoundErr = -2060 #noSourceTreeFoundErr
-samplesAlreadyInMediaErr = -2059 #samplesAlreadyInMediaErr
-auxiliaryExportDataUnavailable = -2058 #auxiliaryExportDataUnavailable
-unsupportedAuxiliaryImportData = -2057 #unsupportedAuxiliaryImportData
-soundSupportNotAvailableErr = -2056 #QT for Windows error
-noSoundTrackInMovieErr = -2055 #QT for Windows error
-noVideoTrackInMovieErr = -2054 #QT for Windows error
-featureUnsupported = -2053 #featureUnsupported
-couldNotUseAnExistingSample = -2052 #couldNotUseAnExistingSample
-noDefaultDataRef = -2051 #noDefaultDataRef
-badDataRefIndex = -2050 #badDataRefIndex
-invalidDataRefContainer = -2049 #invalidDataRefContainer
-noMovieFound = -2048 #noMovieFound
-dataNoDataRef = -2047 #dataNoDataRef
-endOfDataReached = -2046 #endOfDataReached
-dataAlreadyClosed = -2045 #dataAlreadyClosed
-dataAlreadyOpenForWrite = -2044 #dataAlreadyOpenForWrite
-dataNotOpenForWrite = -2043 #dataNotOpenForWrite
-dataNotOpenForRead = -2042 #dataNotOpenForRead
-invalidSampleDescription = -2041 #invalidSampleDescription
-invalidChunkCache = -2040 #invalidChunkCache
-invalidSampleDescIndex = -2039 #invalidSampleDescIndex
-invalidChunkNum = -2038 #invalidChunkNum
-invalidSampleNum = -2037 #invalidSampleNum
-invalidRect = -2036 #invalidRect
-cantEnableTrack = -2035 #cantEnableTrack
-internalQuickTimeError = -2034 #internalQuickTimeError
-badEditIndex = -2033 #badEditIndex
-timeNotInMedia = -2032 #timeNotInMedia
-timeNotInTrack = -2031 #timeNotInTrack
-trackNotInMovie = -2030 #trackNotInMovie
-trackIDNotFound = -2029 #trackIDNotFound
-badTrackIndex = -2028 #badTrackIndex
-maxSizeToGrowTooSmall = -2027 #maxSizeToGrowTooSmall
-userDataItemNotFound = -2026 #userDataItemNotFound
-staleEditState = -2025 #staleEditState
-nonMatchingEditState = -2024 #nonMatchingEditState
-invalidEditState = -2023 #invalidEditState
-cantCreateSingleForkFile = -2022 #happens when file already exists
-wfFileNotFound = -2021 #wfFileNotFound
-movieToolboxUninitialized = -2020 #movieToolboxUninitialized
-progressProcAborted = -2019 #progressProcAborted
-mediaTypesDontMatch = -2018 #mediaTypesDontMatch
-badEditList = -2017 #badEditList
-cantPutPublicMovieAtom = -2016 #cantPutPublicMovieAtom
-invalidTime = -2015 #invalidTime
-invalidDuration = -2014 #invalidDuration
-invalidHandler = -2013 #invalidHandler
-invalidDataRef = -2012 #invalidDataRef
-invalidSampleTable = -2011 #invalidSampleTable
-invalidMovie = -2010 #invalidMovie
-invalidTrack = -2009 #invalidTrack
-invalidMedia = -2008 #invalidMedia
-noDataHandler = -2007 #noDataHandler
-noMediaHandler = -2006 #noMediaHandler
-badComponentType = -2005 #badComponentType
-cantOpenHandler = -2004 #cantOpenHandler
-cantFindHandler = -2003 #cantFindHandler
-badPublicMovieAtom = -2002 #badPublicMovieAtom
-badImageDescription = -2001 #badImageDescription
-couldNotResolveDataRef = -2000 #couldNotResolveDataRef
-nonDragOriginatorErr = -1862 #illegal attempt at originator only data
-badImageErr = -1861 #bad translucent image PixMap
-badImageRgnErr = -1860 #bad translucent image region
-noSuitableDisplaysErr = -1859 #no displays support translucency
-unsupportedForPlatformErr = -1858 #call is for PowerPC only
-dragNotAcceptedErr = -1857 #drag was not accepted by receiver
-handlerNotFoundErr = -1856 #handler not found
-duplicateHandlerErr = -1855 #handler already exists
-cantGetFlavorErr = -1854 #error while trying to get flavor data
-duplicateFlavorErr = -1853 #flavor type already exists
-badDragFlavorErr = -1852 #unknown flavor type
-badDragItemErr = -1851 #unknown drag item reference
-badDragRefErr = -1850 #unknown drag reference
-errEndOfBody = -1813 #errEndOfBody
-errEndOfDocument = -1812 #errEndOfDocument
-errTopOfBody = -1811 #errTopOfBody
-errTopOfDocument = -1810 #errTopOfDocument
-errOffsetIsOutsideOfView = -1801 #errOffsetIsOutsideOfView
-errOffsetInvalid = -1800 #errOffsetInvalid
-errOSACantOpenComponent = -1762 #Can't connect to scripting system with that ID
-errOSAComponentMismatch = -1761 #Parameters are from 2 different components
-errOSADataFormatTooNew = -1759 #errOSADataFormatTooNew
-errOSADataFormatObsolete = -1758 #errOSADataFormatObsolete
-errOSANoSuchDialect = -1757 #errOSANoSuchDialect
-errOSASourceNotAvailable = -1756 #errOSASourceNotAvailable
-errOSABadSelector = -1754 #errOSABadSelector
-errOSAScriptError = -1753 #errOSAScriptError
-errOSABadStorageType = -1752 #errOSABadStorageType
-errOSAInvalidID = -1751 #errOSAInvalidID
-errOSASystemError = -1750 #errOSASystemError
-errAEBufferTooSmall = -1741 #buffer for AEFlattenDesc too small
-errAEBuildSyntaxError = -1740 #AEBuildDesc and friends detected a syntax error
-errAEDescIsNull = -1739 #attempting to perform an invalid operation on a null descriptor
-errAEStreamAlreadyConverted = -1738 #attempt to convert a stream that has already been converted
-errAEStreamBadNesting = -1737 #nesting violation while streaming
-errAEDuplicateHandler = -1736 #attempt to install handler in table for identical class and id (1.1 or greater)
-errAEEventFiltered = -1735 #event has been filtered, and should not be propogated (1.1 or greater)
-errAEReceiveEscapeCurrent = -1734 #break out of only lowest level of AEReceive (1.1 or greater)
-errAEReceiveTerminate = -1733 #break out of all levels of AEReceive to the topmost (1.1 or greater)
-errAERecordingIsAlreadyOn = -1732 #available only in version 1.0.1 or greater
-errAEUnknownObjectType = -1731 #available only in version 1.0.1 or greater
-errAEEmptyListContainer = -1730 #Attempt to pass empty list as container to accessor
-errAENegativeCount = -1729 #CountProc returned negative value
-errAENoSuchObject = -1728 #e.g.,: specifier asked for the 3rd, but there are only 2. Basically, this indicates a run-time resolution error.
-errAENotAnObjSpec = -1727 #Param to AEResolve not of type 'obj '
-errAEBadTestKey = -1726 #Test is neither typeLogicalDescriptor nor typeCompDescriptor
-errAENoSuchLogical = -1725 #Something other than AND, OR, or NOT
-errAEAccessorNotFound = -1723 #Accessor proc matching wantClass and containerType or wildcards not found
-errAEWrongNumberArgs = -1721 #Logical op kAENOT used with other than 1 term
-errAEImpossibleRange = -1720 #A range like 3rd to 2nd, or 1st to all.
-errAEIllegalIndex = -1719 #index is out of range in a put operation
-errAEReplyNotArrived = -1718 #the contents of the reply you are accessing have not arrived yet
-errAEHandlerNotFound = -1717 #no handler in the dispatch tables fits the parameters to AEGetEventHandler or AEGetCoercionHandler
-errAEUnknownAddressType = -1716 #the target address type is not known
-errAEParamMissed = -1715 #a required parameter was not accessed
-errAENotASpecialFunction = -1714 #there is no special function for/with this keyword
-errAENoUserInteraction = -1713 #no user interaction is allowed
-errAETimeout = -1712 #the AppleEvent timed out
-errAEWaitCanceled = -1711 #in AESend, the user cancelled out of wait loop for reply or receipt
-errAEUnknownSendMode = -1710 #mode wasn't NoReply, WaitReply, or QueueReply or Interaction level is unknown
-errAEReplyNotValid = -1709 #AEResetTimer was passed an invalid reply parameter
-errAEEventNotHandled = -1708 #the AppleEvent was not handled by any handler
-errAENotAppleEvent = -1707 #the event is not in AppleEvent format
-errAENewerVersion = -1706 #need newer version of the AppleEvent manager
-errAEBadListItem = -1705 #the specified list item does not exist
-errAENotAEDesc = -1704 #errAENotAEDesc
-errAEWrongDataType = -1703 #errAEWrongDataType
-errAECorruptData = -1702 #errAECorruptData
-errAEDescNotFound = -1701 #errAEDescNotFound
-errAECoercionFail = -1700 #bad parameter data or unable to coerce the data supplied
-errFSIteratorNotSupported = -1424 #The iterator's flags or container are not supported by this call
-errFSIteratorNotFound = -1423 #Passed FSIterator is not an open iterator
-errFSBadIteratorFlags = -1422 #Flags passed to FSOpenIterator are bad
-errFSForkExists = -1421 #Named fork already exists.
-errFSRefsDifferent = -1420 #FSCompareFSRefs; refs are for different objects
-errFSBadSearchParams = -1419 #Something wrong with CatalogSearch searchParams
-errFSBadItemCount = -1418 #maximumItems was zero
-errFSNoMoreItems = -1417 #Iteration ran out of items to return
-errFSBadAllocFlags = -1413 #Invalid bits set in allocationFlags
-errFSBadPosMode = -1412 #Newline bits set in positionMode
-errFSMissingName = -1411 #A Unicode name parameter was NULL or nameLength parameter was zero
-errFSNameTooLong = -1410 #File/fork name is too long to create/rename
-errFSForkNotFound = -1409 #Named fork does not exist
-errFSNotAFolder = -1407 #Expected a folder, got a file
-errFSMissingCatInfo = -1406 #A CatalogInfo parameter was NULL
-errFSBadInfoBitmap = -1405 #A CatalogInfoBitmap or VolumeInfoBitmap has reserved or invalid bits set
-errFSBadForkRef = -1404 #A ForkRefNum parameter was bad
-errFSBadBuffer = -1403 #A buffer parameter was bad
-errFSBadForkName = -1402 #Fork name parameter is bad
-errFSBadFSRef = -1401 #FSRef parameter is bad
-errFSUnknownCall = -1400 #selector is not recognized by this filesystem
-badFCBErr = -1327 #FCBRecPtr is not valid
-volVMBusyErr = -1311 #can't eject because volume is in use by VM
-fsDataTooBigErr = -1310 #file or volume is too big for system
-fileBoundsErr = -1309 #file's EOF, offset, mark or size is too big
-notARemountErr = -1308 #when _Mount allows only remounts and doesn't get one
-badFidErr = -1307 #file id is dangling or doesn't match with the file number
-sameFileErr = -1306 #can't exchange a file with itself
-desktopDamagedErr = -1305 #desktop database files are corrupted
-catChangedErr = -1304 #the catalog has been modified
-diffVolErr = -1303 #files on different volumes
-notAFileErr = -1302 #directory specified
-fidExists = -1301 #file id already exists
-fidNotFound = -1300 #no file thread exists.
-errRefNum = -1280 #bad connection refNum
-errAborted = -1279 #control call was aborted
-errState = -1278 #bad connection state for this operation
-errOpening = -1277 #open connection request failed
-errAttention = -1276 #attention message too long
-errFwdReset = -1275 #read terminated by forward reset
-errDSPQueueSize = -1274 #DSP Read/Write Queue Too small
-errOpenDenied = -1273 #open connection request was denied
-reqAborted = -1105 #reqAborted
-noDataArea = -1104 #noDataArea
-noSendResp = -1103 #noSendResp
-cbNotFound = -1102 #cbNotFound
-noRelErr = -1101 #noRelErr
-badBuffNum = -1100 #badBuffNum
-badATPSkt = -1099 #badATPSkt
-tooManySkts = -1098 #tooManySkts
-tooManyReqs = -1097 #tooManyReqs
-reqFailed = -1096 #reqFailed
-aspNoAck = -1075 #No ack on attention request (server err)
-aspTooMany = -1074 #Too many clients (server error)
-aspSizeErr = -1073 #Command block too big
-aspSessClosed = -1072 #Session closed
-aspServerBusy = -1071 #Server cannot open another session
-aspParamErr = -1070 #Parameter error
-aspNoServers = -1069 #No servers at that address
-aspNoMoreSess = -1068 #No more sessions on server
-aspBufTooSmall = -1067 #Buffer too small
-aspBadVersNum = -1066 #Server cannot support this ASP version
-nbpNISErr = -1029 #Error trying to open the NIS
-nbpNotFound = -1028 #Name not found on remove
-nbpDuplicate = -1027 #Duplicate name exists already
-nbpConfDiff = -1026 #Name confirmed at different socket
-nbpNoConfirm = -1025 #nbpNoConfirm
-nbpBuffOvr = -1024 #Buffer overflow in LookupName
-noMaskFoundErr = -1000 #Icon Utilties Error
-kFMFontContainerAccessErr = -985 #kFMFontContainerAccessErr
-kFMFontTableAccessErr = -984 #kFMFontTableAccessErr
-kFMIterationScopeModifiedErr = -983 #kFMIterationScopeModifiedErr
-kFMInvalidFontErr = -982 #kFMInvalidFontErr
-kFMInvalidFontFamilyErr = -981 #kFMInvalidFontFamilyErr
-kFMIterationCompleted = -980 #kFMIterationCompleted
-guestNotAllowedErr = -932 #destination port requires authentication
-badLocNameErr = -931 #location name malformed
-badServiceMethodErr = -930 #illegal service type, or not supported
-noUserRecErr = -928 #Invalid user reference number
-authFailErr = -927 #unable to authenticate user at destination
-noInformErr = -926 #PPCStart failed because destination did not have inform pending
-networkErr = -925 #An error has occurred in the network, not too likely
-noUserRefErr = -924 #unable to create a new userRefNum
-notLoggedInErr = -923 #The default userRefNum does not yet exist
-noDefaultUserErr = -922 #user hasn't typed in owners name in Network Setup Control Pannel
-badPortNameErr = -919 #PPCPortRec malformed
-sessClosedErr = -917 #session was closed
-portClosedErr = -916 #port was closed
-noResponseErr = -915 #unable to contact destination
-noToolboxNameErr = -914 #A system resource is missing, not too likely
-noMachineNameErr = -913 #user hasn't named his Macintosh in the Network Setup Control Panel
-userRejectErr = -912 #Destination rejected the session request
-noUserNameErr = -911 #user name unknown on destination machine
-portNameExistsErr = -910 #port is already open (perhaps in another app)
-badReqErr = -909 #bad parameter or invalid state for operation
-noSessionErr = -908 #Invalid session reference number
-sessTableErr = -907 #Out of session tables, try again later
-destPortErr = -906 #Port does not exist at destination
-localOnlyErr = -905 #Network activity is currently disabled
-noGlobalsErr = -904 #The system is hosed, better re-boot
-noPortErr = -903 #Unable to open port or bad portRefNum. If you're calling
-nameTypeErr = -902 #Invalid or inappropriate locationKindSelector in locationName
-notInitErr = -900 #PPCToolBox not initialized
-notAppropriateForClassic = -877 #This application won't or shouldn't run on Classic (Problem 2481058).
-appVersionTooOld = -876 #The application's creator and version are incompatible with the current version of Mac OS.
-wrongApplicationPlatform = -875 #The application could not launch because the required platform is not available
-hmCloseViewActive = -863 #Returned from HMRemoveBalloon if CloseView was active
-hmNoBalloonUp = -862 #Returned from HMRemoveBalloon if no balloon was visible when call was made
-hmOperationUnsupported = -861 #Returned from HMShowBalloon call if bad method passed to routine
-hmUnknownHelpType = -859 #Returned if help msg record contained a bad type
-hmWrongVersion = -858 #Returned if help mgr resource was the wrong version
-hmSkippedBalloon = -857 #Returned from calls if helpmsg specified a skip balloon
-hmHelpManagerNotInited = -855 #Returned from HMGetHelpMenuHandle if help menu not setup
-hmSameAsLastBalloon = -854 #Returned from HMShowMenuBalloon if menu & item is same as last time
-hmBalloonAborted = -853 #Returned if mouse was moving or mouse wasn't in window port rect
-hmHelpDisabled = -850 #Show Balloons mode was off, call to routine ignored
-rcDBPackNotInited = -813 #attempt to call other routine before InitDBPack
-rcDBWrongVersion = -812 #incompatible versions
-rcDBNoHandler = -811 #no app handler for specified data type
-rcDBBadAsyncPB = -810 #tried to kill a bad pb
-rcDBAsyncNotSupp = -809 #ddev does not support async calls
-rcDBBadDDEV = -808 #bad ddev specified on DBInit
-rcDBBadSessNum = -807 #bad session number for DBGetConnInfo
-rcDBBadSessID = -806 #rcDBBadSessID
-rcDBExec = -805 #rcDBExec
-rcDBBreak = -804 #rcDBBreak
-rcDBBadType = -803 #rcDBBadType
-rcDBError = -802 #rcDBError
-rcDBValue = -801 #rcDBValue
-rcDBNull = -800 #rcDBNull
-icTooManyProfilesErr = -677 #too many profiles in database
-icProfileNotFoundErr = -676 #profile not found
-icConfigInappropriateErr = -675 #incorrect manufacturer code
-icConfigNotFoundErr = -674 #no internet configuration was found
-icNoURLErr = -673 #no URL found
-icNothingToOverrideErr = -672 #no component for the override component to capture
-icNoMoreWritersErr = -671 #you cannot begin a write session because someone else is already doing it
-icTruncatedErr = -670 #more data was present than was returned
-icInternalErr = -669 #Internet Config internal error
-icPrefDataErr = -668 #problem with preference data
-icPermErr = -667 #cannot set preference
-icPrefNotFoundErr = -666 #Internet preference not found
-vmInvalidOwningProcessErr = -648 #current process does not own the BackingFileID or FileViewID
-vmAddressNotInFileViewErr = -647 #address is not in a FileView
-vmNoMoreFileViewsErr = -646 #no more FileViews were found
-vmFileViewAccessErr = -645 #requested FileViewAccess cannot be obtained
-vmInvalidFileViewIDErr = -644 #invalid FileViewID
-vmNoMoreBackingFilesErr = -643 #no more BackingFiles were found
-vmBusyBackingFileErr = -642 #open views found on BackingFile
-vmMappingPrivilegesErr = -641 #requested MappingPrivileges cannot be obtained
-vmInvalidBackingFileIDErr = -640 #invalid BackingFileID
-noMMUErr = -626 #no MMU present
-cannotDeferErr = -625 #unable to defer additional functions
-interruptsMaskedErr = -624 #donÕt call with interrupts masked
-notLockedErr = -623 #specified range of memory is not locked
-cannotMakeContiguousErr = -622 #cannot make specified range contiguous
-notHeldErr = -621 #specified range of memory is not held
-notEnoughMemoryErr = -620 #insufficient physical memory
-threadProtocolErr = -619 #threadProtocolErr
-threadNotFoundErr = -618 #threadNotFoundErr
-threadTooManyReqsErr = -617 #threadTooManyReqsErr
-noUserInteractionAllowed = -610 #no user interaction allowed
-connectionInvalid = -609 #connectionInvalid
-noOutstandingHLE = -608 #noOutstandingHLE
-bufferIsSmall = -607 #error returns from Post and Accept
-appIsDaemon = -606 #app is BG-only, and launch flags disallow this
-appMemFullErr = -605 #application SIZE not big enough for launch
-hardwareConfigErr = -604 #hardware configuration not correct for call
-protocolErr = -603 #app made module calls in improper order
-appModeErr = -602 #memory mode is 32-bit, but app not 32-bit clean
-memFragErr = -601 #not enough room to launch app w/special requirements
-procNotFound = -600 #no eligible process with specified descriptor
-driverHardwareGoneErr = -503 #disk driver's hardware was disconnected
-hwParamErr = -502 #bad selector for _HWPriv
-teScrapSizeErr = -501 #scrap item too big for text edit record
-rgnTooBigErr = -500 #rgnTooBigErr
-exUserBreak = -492 #user debugger break; execute debugger commands on stack
-strUserBreak = -491 #user debugger break; display string on stack
-userBreak = -490 #user debugger break
-notThePublisherWrn = -463 #not the first registered publisher for that container
-containerAlreadyOpenWrn = -462 #container already opened by this section
-containerNotFoundWrn = -461 #could not find editionContainer at this time
-multiplePublisherWrn = -460 #A Publisher is already registered for that container
-badSubPartErr = -454 #can not use sub parts in this release
-badEditionFileErr = -453 #edition file is corrupt
-notRegisteredSectionErr = -452 #not a registered SectionRecord
-badSectionErr = -451 #not a valid SectionRecord
-editionMgrInitErr = -450 #edition manager not inited by this app
-fsmUnknownFSMMessageErr = -438 #unknown message passed to FSM
-fsmNoAlternateStackErr = -437 #no alternate stack for HFS CI
-fsmBadFSDVersionErr = -436 #FSM version incompatible with FSD
-fsmDuplicateFSIDErr = -435 #FSID already exists on InstallFS
-fsmBadFSDLenErr = -434 #FSD size incompatible with current FSM vers
-fsmBadFFSNameErr = -433 #Name length not 1 <= length <= 31
-fsmBusyFFSErr = -432 #File system is busy, cannot be removed
-fsmFFSNotFoundErr = -431 #Foreign File system does not exist - new Pack2 could return this error too
-btKeyAttrErr = -417 #There is no such a key attribute.
-btKeyLenErr = -416 #Maximum key length is too long or equal to zero.
-btRecNotFnd = -415 #Record cannot be found.
-btDupRecErr = -414 #Record already exists.
-btNoSpace = -413 #Can't allocate disk space.
-notBTree = -410 #The file is not a dictionary.
-gcrOnMFMErr = -400 #gcr format on high density media error
-slotNumErr = -360 #invalid slot # error
-smRecNotFnd = -351 #Record not found in the SRT.
-smSRTOvrFlErr = -350 #SRT over flow.
-smNoGoodOpens = -349 #No opens were successfull in the loop.
-smOffsetErr = -348 #Offset was too big (temporary error
-smByteLanesErr = -347 #NumByteLanes was determined to be zero.
-smBadsPtrErr = -346 #Bad pointer was passed to sCalcsPointer
-smsGetDrvrErr = -345 #Error occurred during _sGetDriver.
-smNoMoresRsrcs = -344 #No more sResources
-smDisDrvrNamErr = -343 #Error occurred during _sDisDrvrName.
-smGetDrvrNamErr = -342 #Error occurred during _sGetDrvrName.
-smCkStatusErr = -341 #Status of slot = fail.
-smBlkMoveErr = -340 #_BlockMove error
-smNewPErr = -339 #_NewPtr error
-smSelOOBErr = -338 #Selector out of bounds error
-smSlotOOBErr = -337 #Slot out of bounds error
-smNilsBlockErr = -336 #Nil sBlock error (Dont allocate and try to use a nil sBlock)
-smsPointerNil = -335 #LPointer is nil From sOffsetData. If this error occurs; check sInfo rec for more information.
-smCPUErr = -334 #Code revision is wrong
-smCodeRevErr = -333 #Code revision is wrong
-smReservedErr = -332 #Reserved field not zero
-smBadsList = -331 #Bad sList: Id1 < Id2 < Id3 ...format is not followed.
-smBadRefId = -330 #Reference Id not found in List
-smBusErrTO = -320 #BusError time out.
-smBadBoardId = -319 #BoardId was wrong; re-init the PRAM record.
-smReservedSlot = -318 #slot is reserved, VM should not use this address space.
-smInitTblVErr = -317 #An error occurred while trying to initialize the Slot Resource Table.
-smInitStatVErr = -316 #The InitStatusV field was negative after primary or secondary init.
-smNoBoardId = -315 #No Board Id.
-smGetPRErr = -314 #Error occurred during _sGetPRAMRec (See SIMStatus).
-smNoBoardSRsrc = -313 #No Board sResource.
-smDisposePErr = -312 #_DisposePointer error
-smFHBlkDispErr = -311 #Error occurred during _sDisposePtr (Dispose of FHeader block).
-smFHBlockRdErr = -310 #Error occurred during _sGetFHeader.
-smBLFieldBad = -309 #ByteLanes field was bad.
-smUnExBusErr = -308 #Unexpected BusError
-smResrvErr = -307 #Fatal reserved error. Reserved field != 0.
-smNosInfoArray = -306 #No sInfoArray. Memory Mgr error.
-smDisabledSlot = -305 #This slot is disabled (-305 use to be smLWTstBad)
-smNoDir = -304 #Directory offset is Nil
-smRevisionErr = -303 #Wrong revison level
-smFormatErr = -302 #FHeader Format is not Apple's
-smCRCFail = -301 #CRC check failed for declaration data
-smEmptySlot = -300 #No card in slot
-nmTypErr = -299 #Notification Manager:wrong queue type
-smPriInitErr = -293 #Error; Cards could not be initialized.
-smPRAMInitErr = -292 #Error; Slot Resource Table could not be initialized.
-smSRTInitErr = -291 #Error; Slot Resource Table could not be initialized.
-smSDMInitErr = -290 #Error; SDM could not be initialized.
-midiInvalidCmdErr = -261 #command not supported for port type
-midiDupIDErr = -260 #duplicate client ID
-midiNameLenErr = -259 #name supplied is longer than 31 characters
-midiWriteErr = -258 #MIDIWritePacket couldn't write to all connected ports
-midiNoConErr = -257 #no connection exists between specified ports
-midiVConnectRmvd = -256 #pending virtual connection removed
-midiVConnectMade = -255 #pending virtual connection resolved
-midiVConnectErr = -254 #pending virtual connection created
-midiTooManyConsErr = -253 #too many connections made
-midiTooManyPortsErr = -252 #too many ports already installed in the system
-midiNoPortErr = -251 #no port with that ID found
-midiNoClientErr = -250 #no client with that ID found
-badInputText = -247 #badInputText
-badDictFormat = -246 #badDictFormat
-incompatibleVoice = -245 #incompatibleVoice
-voiceNotFound = -244 #voiceNotFound
-bufTooSmall = -243 #bufTooSmall
-synthNotReady = -242 #synthNotReady
-synthOpenFailed = -241 #synthOpenFailed
-noSynthFound = -240 #noSynthFound
-siUnknownQuality = -232 #invalid quality selector (returned by driver)
-siUnknownInfoType = -231 #invalid info type selector (returned by driver)
-siInputDeviceErr = -230 #input device hardware failure
-siBadRefNum = -229 #invalid input device reference number
-siBadDeviceName = -228 #input device could not be opened
-siDeviceBusyErr = -227 #input device already in use
-siInvalidSampleSize = -226 #invalid sample size
-siInvalidSampleRate = -225 #invalid sample rate
-siHardDriveTooSlow = -224 #hard drive too slow to record to disk
-siInvalidCompression = -223 #invalid compression type
-siNoBufferSpecified = -222 #returned by synchronous SPBRecord if nil buffer passed
-siBadSoundInDevice = -221 #invalid index passed to SoundInGetIndexedDevice
-siNoSoundInHardware = -220 #no Sound Input hardware
-siVBRCompressionNotSupported = -213 #vbr audio compression not supported for this operation
-noMoreRealTime = -212 #not enough CPU cycles left to add another task
-channelNotBusy = -211 #channelNotBusy
-buffersTooSmall = -210 #can not operate in the memory allowed
-channelBusy = -209 #the Channel is being used for a PFD already
-badFileFormat = -208 #was not type AIFF or was of bad format,corrupt
-notEnoughBufferSpace = -207 #could not allocate enough memory
-badFormat = -206 #Sound Manager Error Returns
-badChannel = -205 #Sound Manager Error Returns
-resProblem = -204 #Sound Manager Error Returns
-queueFull = -203 #Sound Manager Error Returns
-notEnoughHardwareErr = -201 #Sound Manager Error Returns
-noHardwareErr = -200 #Sound Manager Error Returns
-mapReadErr = -199 #map inconsistent with operation
-resAttrErr = -198 #attribute inconsistent with operation
-rmvRefFailed = -197 #RmveReference failed
-rmvResFailed = -196 #RmveResource failed
-addRefFailed = -195 #AddReference failed
-addResFailed = -194 #AddResource failed
-resFNotFound = -193 #Resource file not found
-resNotFound = -192 #Resource not found
-inputOutOfBounds = -190 #Offset of Count out of bounds
-writingPastEnd = -189 #Writing past end of file
-resourceInMemory = -188 #Resource already in memory
-CantDecompress = -186 #resource bent ("the bends") - can't decompress a compressed resource
-badExtResource = -185 #extended resource has a bad format.
-cmNoCurrentProfile = -182 #Responder error
-cmUnsupportedDataType = -181 #Responder error
-cmCantDeleteProfile = -180 #Responder error
-cmCantXYZ = -179 #CMM cant handle XYZ space
-cmCantConcatenateError = -178 #Profile can't be concatenated
-cmProfilesIdentical = -177 #Profiles the same
-cmProfileNotFound = -176 #Responder error
-cmMethodNotFound = -175 #CMM not present
-cmMethodError = -171 #cmMethodError
-cmProfileError = -170 #cmProfileError
-cDepthErr = -157 #invalid pixel depth
-cResErr = -156 #invalid resolution for MakeITable
-cDevErr = -155 #invalid type of graphics device
-cProtectErr = -154 #colorTable entry protection violation
-cRangeErr = -153 #range error on colorTable request
-cNoMemErr = -152 #failed to allocate memory for structure
-cTempMemErr = -151 #failed to allocate memory for temporary structures
-cMatchErr = -150 #Color2Index failed to find an index
-insufficientStackErr = -149 #insufficientStackErr
-pixMapTooDeepErr = -148 #pixMapTooDeepErr
-rgnOverflowErr = -147 #rgnOverflowErr
-noMemForPictPlaybackErr = -145 #noMemForPictPlaybackErr
-userCanceledErr = -128 #userCanceledErr
-hMenuFindErr = -127 #could not find HMenu's parent in MenuKey (wrong error code - obsolete)
-mBarNFnd = -126 #system error code for MBDF not found
-updPixMemErr = -125 #insufficient memory to update a pixmap
-volGoneErr = -124 #Server volume has been disconnected.
-wrgVolTypErr = -123 #Wrong volume type error [operation not supported for MFS]
-badMovErr = -122 #Move into offspring error
-tmwdoErr = -121 #No free WDCB available
-dirNFErr = -120 #Directory not found
-memLockedErr = -117 #trying to move a locked block (MoveHHi)
-memSCErr = -116 #Size Check failed
-memBCErr = -115 #Block Check failed
-memPCErr = -114 #Pointer Check failed
-memAZErr = -113 #Address in zone check failed
-memPurErr = -112 #trying to purge a locked or non-purgeable block
-memWZErr = -111 #WhichZone failed (applied to free block)
-memAdrErr = -110 #address was odd; or out of range
-nilHandleErr = -109 #Master Pointer was NIL in HandleZone or other
-memFullErr = -108 #Not enough room in heap zone
-noTypeErr = -102 #No object of that type in scrap
-noScrapErr = -100 #No scrap exists error
-memROZWarn = -99 #soft error in ROZ
-portNotCf = -98 #driver Open error code (parameter RAM not configured for this connection)
-portInUse = -97 #driver Open error code (port is in use)
-portNotPwr = -96 #serial port not currently powered
-excessCollsns = -95 #excessive collisions on write
-lapProtErr = -94 #error in attaching/detaching protocol
-noBridgeErr = -93 #no network bridge for non-local send
-eLenErr = -92 #Length error ddpLenErr
-eMultiErr = -91 #Multicast address error ddpSktErr
-breakRecd = -90 #Break received (SCC)
-rcvrErr = -89 #SCC receiver error (framing; parity; OR)
-prInitErr = -88 #InitUtil found the parameter ram uninitialized
-prWrErr = -87 #parameter ram written didn't read-verify
-clkWrErr = -86 #time written did not verify
-clkRdErr = -85 #unable to read same clock value twice
-verErr = -84 #track failed to verify
-fmt2Err = -83 #can't get enough sync
-fmt1Err = -82 #can't find sector 0 after track format
-sectNFErr = -81 #sector number never found on a track
-seekErr = -80 #track number wrong on address mark
-spdAdjErr = -79 #unable to correctly adjust disk speed
-twoSideErr = -78 #tried to read 2nd side on a 1-sided drive
-initIWMErr = -77 #unable to initialize IWM
-tk0BadErr = -76 #track 0 detect doesn't change
-cantStepErr = -75 #step handshake failed
-wrUnderrun = -74 #write underrun occurred
-badDBtSlp = -73 #bad data mark bit slip nibbles
-badDCksum = -72 #bad data mark checksum
-noDtaMkErr = -71 #couldn't find a data mark header
-badBtSlpErr = -70 #bad addr mark bit slip nibbles
-badCksmErr = -69 #addr mark checksum didn't check
-dataVerErr = -68 #read verify compare failed
-noAdrMkErr = -67 #couldn't find valid addr mark
-noNybErr = -66 #couldn't find 5 nybbles in 200 tries
-offLinErr = -65 #r/w requested for an off-line drive
-fontDecError = -64 #error during font declaration
-wrPermErr = -61 #write permissions error
-badMDBErr = -60 #bad master directory block
-fsRnErr = -59 #file system internal error:during rename the old entry was deleted but could not be restored.
-extFSErr = -58 #volume in question belongs to an external fs
-noMacDskErr = -57 #not a mac diskette (sig bytes are wrong)
-nsDrvErr = -56 #no such drive (tried to mount a bad drive num)
-volOnLinErr = -55 #drive volume already on-line at MountVol
-permErr = -54 #permissions error (on file open)
-volOffLinErr = -53 #volume not on line error (was Ejected)
-gfpErr = -52 #get file position error
-rfNumErr = -51 #refnum error
-paramErr = -50 #error in user parameter list
-opWrErr = -49 #file already open with with write permission
-dupFNErr = -48 #duplicate filename (rename)
-fBsyErr = -47 #File is busy (delete)
-vLckdErr = -46 #volume is locked
-fLckdErr = -45 #file is locked
-wPrErr = -44 #diskette is write protected.
-fnfErr = -43 #File not found
-tmfoErr = -42 #too many files open
-mFulErr = -41 #memory full (open) or file won't fit (load)
-posErr = -40 #tried to position to before start of file (r/w)
-eofErr = -39 #End of file
-fnOpnErr = -38 #File not open
-bdNamErr = -37 #there may be no bad names in the final system!
-ioErr = -36 #I/O error (bummers)
-nsvErr = -35 #no such volume
-dskFulErr = -34 #disk full
-dirFulErr = -33 #Directory full
-dceExtErr = -30 #dce extension error
-unitTblFullErr = -29 #unit table has no more entries
-notOpenErr = -28 #Couldn't rd/wr/ctl/sts cause driver not opened
-iIOAbortErr = -27 #IO abort error (Printing Manager)
-dInstErr = -26 #DrvrInstall couldn't find driver in resources
-dRemovErr = -25 #tried to remove an open driver
-closErr = -24 #I/O System Errors
-openErr = -23 #I/O System Errors
-unitEmptyErr = -22 #I/O System Errors
-badUnitErr = -21 #I/O System Errors
-writErr = -20 #I/O System Errors
-readErr = -19 #I/O System Errors
-statusErr = -18 #I/O System Errors
-controlErr = -17 #I/O System Errors
-dsExtensionsDisabled = -13 #say –Extensions Disabled”
-dsHD20Installed = -12 #say –HD20 Startup”
-dsDisassemblerInstalled = -11 #say –Disassembler Installed”
-dsMacsBugInstalled = -10 #say –MacsBug Installed”
-seNoDB = -8 #no debugger installed to handle debugger command
-SlpTypeErr = -5 #invalid queue element
-unimpErr = -4 #unimplemented core routine
-corErr = -3 #core routine number out of range
-dsNoExtsDisassembler = -2 #not a SysErr, just a placeholder
-qErr = -1 #queue element not found during deletion
-tsmComponentNoErr = 0 #component result = no error
-EPERM = 1 #Operation not permitted
-ENOENT = 2 #No such file or directory
-ESRCH = 3 #No such process
-EINTR = 4 #Interrupted system call
-EIO = 5 #Input/output error
-ENXIO = 6 #Device not configured
-E2BIG = 7 #Argument list too long
-ENOEXEC = 8 #Exec format error
-EBADF = 9 #Bad file descriptor
-ECHILD = 10 #No child processes
-EDEADLK = 11 #Resource deadlock avoided
-ENOMEM = 12 #Cannot allocate memory
-EACCES = 13 #Permission denied
-EFAULT = 14 #Bad address
-ECANCELED = 15 #Operation cancelled
-EBUSY = 16 #Device busy
-EEXIST = 17 #File exists
-EXDEV = 18 #Cross-device link
-ENODEV = 19 #Operation not supported by device
-ENOTDIR = 20 #Not a directory
-EISDIR = 21 #Is a directory
-EINVAL = 22 #Invalid argument
-ENFILE = 23 #Too many open files in system
-EMFILE = 24 #Too many open files
-ENOTTY = 25 #Inappropriate ioctl for device
-ESIGPARM = 26 #Signal error
-EFBIG = 27 #File too large
-ENOSPC = 28 #No space left on device
-ESPIPE = 29 #Illegal seek
-EROFS = 30 #Read-only file system
-EMLINK = 31 #Too many links
-EPIPE = 32 #Broken pipe
-EDOM = 33 #Numerical argument out of domain
-ERANGE = 34 #Result too large
-EAGAIN = 35 #Resource temporarily unavailable
-EINPROGRESS = 36 #Operation now in progress
-EALREADY = 37 #Operation already in progress
-ENOTSOCK = 38 #Socket operation on non-socket
-EDESTADDRREQ = 39 #Destination address required
-EMSGSIZE = 40 #Message too long
-EPROTOTYPE = 41 #Protocol wrong type for socket
-ENOPROTOOPT = 42 #Protocol not available
-EPROTONOSUPPORT = 43 #Protocol not supported
-ESOCKTNOSUPPORT = 44 #Socket type not supported
-EOPNOTSUPP = 45 #Operation not supported
-EPFNOSUPPORT = 46 #Protocol family not supported
-EAFNOSUPPORT = 47 #Address family not supported by protocol family
-EADDRINUSE = 48 #Address already in use
-EADDRNOTAVAIL = 49 #Can't assign requested address
-ENETDOWN = 50 #Network is down
-ENETUNREACH = 51 #Network is unreachable
-ENETRESET = 52 #Network dropped connection on reset
-ECONNABORTED = 53 #Software caused connection abort
-ECONNRESET = 54 #Connection reset by peer
-ENOBUFS = 55 #No buffer space available
-EISCONN = 56 #Socket is already connected
-ENOTCONN = 57 #Socket is not connected
-ESHUTDOWN = 58 #Can't send after socket shutdown
-ETOOMANYREFS = 59 #Too many references: can't splice
-ETIMEDOUT = 60 #Operation timed out
-ECONNREFUSED = 61 #Connection refused
-ELOOP = 62 #Too many levels of symbolic links
-ENAMETOOLONG = 63 #File name too long
-EHOSTDOWN = 64 #Host is down
-EHOSTUNREACH = 65 #No route to host
-ENOTEMPTY = 66 #Directory not empty
-ELOOK = 67 #Internal mapping for kOTLookErr, don't return to client
-ENOLCK = 77 #No locks available
-ENOSYS = 78 #Function not implemented
-EILSEQ = 88 #Wide character encoding error
-EUNKNOWN = 99 #Unknown error
diff --git a/Lib/plat-mac/macostools.py b/Lib/plat-mac/macostools.py
deleted file mode 100644
index 395001ddc12..00000000000
--- a/Lib/plat-mac/macostools.py
+++ /dev/null
@@ -1,138 +0,0 @@
-"""macostools - Various utility functions for MacOS.
-
-mkalias(src, dst) - Create a finder alias 'dst' pointing to 'src'
-copy(src, dst) - Full copy of 'src' to 'dst'
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the macostools module is removed.", stacklevel=2)
-
-from Carbon import Res
-from Carbon import File, Files
-import os
-import errno
-import MacOS
-try:
- openrf = MacOS.openrf
-except AttributeError:
- # Backward compatibility
- openrf = open
-
-Error = 'macostools.Error'
-
-BUFSIZ=0x80000 # Copy in 0.5Mb chunks
-
-COPY_FLAGS = (Files.kIsStationary|Files.kNameLocked|Files.kHasBundle|
- Files.kIsInvisible|Files.kIsAlias)
-
-#
-# Not guaranteed to be correct or stay correct (Apple doesn't tell you
-# how to do this), but it seems to work.
-#
-def mkalias(src, dst, relative=None):
- """Create a finder alias"""
- srcfsr = File.FSRef(src)
- # The next line will fail under unix-Python if the destination
- # doesn't exist yet. We should change this code to be fsref-based.
- dstdir, dstname = os.path.split(dst)
- if not dstdir: dstdir = os.curdir
- dstdirfsr = File.FSRef(dstdir)
- if relative:
- relativefsr = File.FSRef(relative)
- # ik mag er geen None in stoppen :-(
- alias = File.FSNewAlias(relativefsr, srcfsr)
- else:
- alias = srcfsr.FSNewAliasMinimal()
-
- dstfsr, dstfss = Res.FSCreateResourceFile(dstdirfsr, unicode(dstname),
- File.FSGetResourceForkName())
- h = Res.FSOpenResourceFile(dstfsr, File.FSGetResourceForkName(), 3)
- resource = Res.Resource(alias.data)
- resource.AddResource('alis', 0, '')
- Res.CloseResFile(h)
-
- dstfinfo = dstfss.FSpGetFInfo()
- dstfinfo.Flags = dstfinfo.Flags|0x8000 # Alias flag
- dstfss.FSpSetFInfo(dstfinfo)
-
-def mkdirs(dst):
- """Make directories leading to 'dst' if they don't exist yet"""
- if dst == '' or os.path.exists(dst):
- return
- head, tail = os.path.split(dst)
- if os.sep == ':' and not ':' in head:
- head = head + ':'
- mkdirs(head)
-
- try:
- os.mkdir(dst, 0777)
- except OSError, e:
- # be happy if someone already created the path
- if e.errno != errno.EEXIST:
- raise
-
-
-def touched(dst):
- """Tell the finder a file has changed. No-op on MacOSX."""
- import warnings
- warnings.warn("macostools.touched() has been deprecated",
- DeprecationWarning, 2)
-
-def touched_ae(dst):
- """Tell the finder a file has changed"""
- pardir = os.path.split(dst)[0]
- if not pardir:
- pardir = os.curdir
- import Finder
- f = Finder.Finder()
- f.update(File.FSRef(pardir))
-
-def copy(src, dst, createpath=0, copydates=1, forcetype=None):
- """Copy a file, including finder info, resource fork, etc"""
- src = File.pathname(src)
- dst = File.pathname(dst)
- if createpath:
- mkdirs(os.path.split(dst)[0])
-
- ifp = open(src, 'rb')
- ofp = open(dst, 'wb')
- d = ifp.read(BUFSIZ)
- while d:
- ofp.write(d)
- d = ifp.read(BUFSIZ)
- ifp.close()
- ofp.close()
-
- ifp = openrf(src, '*rb')
- ofp = openrf(dst, '*wb')
- d = ifp.read(BUFSIZ)
- while d:
- ofp.write(d)
- d = ifp.read(BUFSIZ)
- ifp.close()
- ofp.close()
-
- srcfss = File.FSSpec(src)
- dstfss = File.FSSpec(dst)
- sf = srcfss.FSpGetFInfo()
- df = dstfss.FSpGetFInfo()
- df.Creator, df.Type = sf.Creator, sf.Type
- if forcetype is not None:
- df.Type = forcetype
- df.Flags = (sf.Flags & COPY_FLAGS)
- dstfss.FSpSetFInfo(df)
- if copydates:
- srcfsr = File.FSRef(src)
- dstfsr = File.FSRef(dst)
- catinfo, _, _, _ = srcfsr.FSGetCatalogInfo(Files.kFSCatInfoAllDates)
- dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo)
-
-def copytree(src, dst, copydates=1):
- """Copy a complete file tree to a new destination"""
- if os.path.isdir(src):
- mkdirs(dst)
- files = os.listdir(src)
- for f in files:
- copytree(os.path.join(src, f), os.path.join(dst, f), copydates)
- else:
- copy(src, dst, 1, copydates)
diff --git a/Lib/plat-mac/macresource.py b/Lib/plat-mac/macresource.py
deleted file mode 100644
index 3b48d4b5336..00000000000
--- a/Lib/plat-mac/macresource.py
+++ /dev/null
@@ -1,135 +0,0 @@
-"""macresource - Locate and open the resources needed for a script."""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the macresource module is removed.", stacklevel=2)
-
-from Carbon import Res
-import os
-import sys
-import MacOS
-import macostools
-
-class ArgumentError(TypeError): pass
-class ResourceFileNotFoundError(ImportError): pass
-
-def need(restype, resid, filename=None, modname=None):
- """Open a resource file, if needed. restype and resid
- are required parameters, and identify the resource for which to test. If it
- is available we are done. If it is not available we look for a file filename
- (default: modname with .rsrc appended) either in the same folder as
- where modname was loaded from, or otherwise across sys.path.
-
- Returns the refno of the resource file opened (or None)"""
-
- if modname is None and filename is None:
- raise ArgumentError, "Either filename or modname argument (or both) must be given"
-
- if type(resid) is type(1):
- try:
- h = Res.GetResource(restype, resid)
- except Res.Error:
- pass
- else:
- return None
- else:
- try:
- h = Res.GetNamedResource(restype, resid)
- except Res.Error:
- pass
- else:
- return None
-
- # Construct a filename if we don't have one
- if not filename:
- if '.' in modname:
- filename = modname.split('.')[-1] + '.rsrc'
- else:
- filename = modname + '.rsrc'
-
- # Now create a list of folders to search
- searchdirs = []
- if modname == '__main__':
- # If we're main we look in the current directory
- searchdirs = [os.curdir]
- if modname in sys.modules:
- mod = sys.modules[modname]
- if hasattr(mod, '__file__'):
- searchdirs = [os.path.dirname(mod.__file__)]
- searchdirs.extend(sys.path)
-
- # And look for the file
- for dir in searchdirs:
- pathname = os.path.join(dir, filename)
- if os.path.exists(pathname):
- break
- else:
- raise ResourceFileNotFoundError, filename
-
- refno = open_pathname(pathname)
-
- # And check that the resource exists now
- if type(resid) is type(1):
- h = Res.GetResource(restype, resid)
- else:
- h = Res.GetNamedResource(restype, resid)
- return refno
-
-def open_pathname(pathname, verbose=0):
- """Open a resource file given by pathname, possibly decoding an
- AppleSingle file"""
- # No resource fork. We may be on OSX, and this may be either
- # a data-fork based resource file or a AppleSingle file
- # from the CVS repository.
- try:
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- except Res.Error, arg:
- if arg[0] != -199:
- # -199 is "bad resource map"
- raise
- else:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
-
-def resource_pathname(pathname, verbose=0):
- """Return the pathname for a resource file (either DF or RF based).
- If the pathname given already refers to such a file simply return it,
- otherwise first decode it."""
- # No resource fork. We may be on OSX, and this may be either
- # a data-fork based resource file or a AppleSingle file
- # from the CVS repository.
- try:
- refno = Res.FSOpenResourceFile(pathname, u'', 1)
- except Res.Error, arg:
- if arg[0] != -199:
- # -199 is "bad resource map"
- raise
- else:
- return refno
- # Finally try decoding an AppleSingle file
- pathname = _decode(pathname, verbose=verbose)
- return pathname
-
-def open_error_resource():
- """Open the resource file containing the error code to error message
- mapping."""
- need('Estr', 1, filename="errors.rsrc", modname=__name__)
-
-def _decode(pathname, verbose=0):
- # Decode an AppleSingle resource file, return the new pathname.
- newpathname = pathname + '.df.rsrc'
- if os.path.exists(newpathname) and \
- os.stat(newpathname).st_mtime >= os.stat(pathname).st_mtime:
- return newpathname
- if hasattr(os, 'access') and not \
- os.access(os.path.dirname(pathname), os.W_OK|os.X_OK):
- # The destination directory isn't writeable. Create the file in
- # a temporary directory
- import tempfile
- fd, newpathname = tempfile.mkstemp(".rsrc")
- if verbose:
- print 'Decoding', pathname, 'to', newpathname
- import applesingle
- applesingle.decode(pathname, newpathname, resonly=1)
- return newpathname
diff --git a/Lib/plat-mac/pimp.py b/Lib/plat-mac/pimp.py
deleted file mode 100644
index 9a3e82e2691..00000000000
--- a/Lib/plat-mac/pimp.py
+++ /dev/null
@@ -1,1182 +0,0 @@
-"""Package Install Manager for Python.
-
-This is currently a MacOSX-only strawman implementation.
-Despite other rumours the name stands for "Packman IMPlementation".
-
-Tools to allow easy installation of packages. The idea is that there is
-an online XML database per (platform, python-version) containing packages
-known to work with that combination. This module contains tools for getting
-and parsing the database, testing whether packages are installed, computing
-dependencies and installing packages.
-
-There is a minimal main program that works as a command line tool, but the
-intention is that the end user will use this through a GUI.
-"""
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the pimp module is removed.", stacklevel=2)
-
-import sys
-import os
-import subprocess
-import urllib
-import urllib2
-import urlparse
-import plistlib
-import distutils.util
-import distutils.sysconfig
-import hashlib
-import tarfile
-import tempfile
-import shutil
-import time
-
-__all__ = ["PimpPreferences", "PimpDatabase", "PimpPackage", "main",
- "getDefaultDatabase", "PIMP_VERSION", "main"]
-
-_scriptExc_NotInstalled = "pimp._scriptExc_NotInstalled"
-_scriptExc_OldInstalled = "pimp._scriptExc_OldInstalled"
-_scriptExc_BadInstalled = "pimp._scriptExc_BadInstalled"
-
-NO_EXECUTE=0
-
-PIMP_VERSION="0.5"
-
-# Flavors:
-# source: setup-based package
-# binary: tar (or other) archive created with setup.py bdist.
-# installer: something that can be opened
-DEFAULT_FLAVORORDER=['source', 'binary', 'installer']
-DEFAULT_DOWNLOADDIR='/tmp'
-DEFAULT_BUILDDIR='/tmp'
-DEFAULT_INSTALLDIR=distutils.sysconfig.get_python_lib()
-DEFAULT_PIMPDATABASE_FMT="http://www.python.org/packman/version-%s/%s-%s-%s-%s-%s.plist"
-
-def getDefaultDatabase(experimental=False):
- if experimental:
- status = "exp"
- else:
- status = "prod"
-
- major, minor, micro, state, extra = sys.version_info
- pyvers = '%d.%d' % (major, minor)
- if micro == 0 and state != 'final':
- pyvers = pyvers + '%s%d' % (state, extra)
-
- longplatform = distutils.util.get_platform()
- osname, release, machine = longplatform.split('-')
- # For some platforms we may want to differentiate between
- # installation types
- if osname == 'darwin':
- if sys.prefix.startswith('/System/Library/Frameworks/Python.framework'):
- osname = 'darwin_apple'
- elif sys.prefix.startswith('/Library/Frameworks/Python.framework'):
- osname = 'darwin_macpython'
- # Otherwise we don't know...
- # Now we try various URLs by playing with the release string.
- # We remove numbers off the end until we find a match.
- rel = release
- while True:
- url = DEFAULT_PIMPDATABASE_FMT % (PIMP_VERSION, status, pyvers, osname, rel, machine)
- try:
- urllib2.urlopen(url)
- except urllib2.HTTPError, arg:
- pass
- else:
- break
- if not rel:
- # We're out of version numbers to try. Use the
- # full release number, this will give a reasonable
- # error message later
- url = DEFAULT_PIMPDATABASE_FMT % (PIMP_VERSION, status, pyvers, osname, release, machine)
- break
- idx = rel.rfind('.')
- if idx < 0:
- rel = ''
- else:
- rel = rel[:idx]
- return url
-
-def _cmd(output, dir, *cmditems):
- """Internal routine to run a shell command in a given directory."""
-
- cmd = ("cd \"%s\"; " % dir) + " ".join(cmditems)
- if output:
- output.write("+ %s\n" % cmd)
- if NO_EXECUTE:
- return 0
- child = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- child.stdin.close()
- while 1:
- line = child.stdout.readline()
- if not line:
- break
- if output:
- output.write(line)
- return child.wait()
-
-class PimpDownloader:
- """Abstract base class - Downloader for archives"""
-
- def __init__(self, argument,
- dir="",
- watcher=None):
- self.argument = argument
- self._dir = dir
- self._watcher = watcher
-
- def download(self, url, filename, output=None):
- return None
-
- def update(self, str):
- if self._watcher:
- return self._watcher.update(str)
- return True
-
-class PimpCurlDownloader(PimpDownloader):
-
- def download(self, url, filename, output=None):
- self.update("Downloading %s..." % url)
- exitstatus = _cmd(output, self._dir,
- "curl",
- "--output", filename,
- url)
- self.update("Downloading %s: finished" % url)
- return (not exitstatus)
-
-class PimpUrllibDownloader(PimpDownloader):
-
- def download(self, url, filename, output=None):
- output = open(filename, 'wb')
- self.update("Downloading %s: opening connection" % url)
- keepgoing = True
- download = urllib2.urlopen(url)
- if 'content-length' in download.headers:
- length = long(download.headers['content-length'])
- else:
- length = -1
-
- data = download.read(4096) #read 4K at a time
- dlsize = 0
- lasttime = 0
- while keepgoing:
- dlsize = dlsize + len(data)
- if len(data) == 0:
- #this is our exit condition
- break
- output.write(data)
- if int(time.time()) != lasttime:
- # Update at most once per second
- lasttime = int(time.time())
- if length == -1:
- keepgoing = self.update("Downloading %s: %d bytes..." % (url, dlsize))
- else:
- keepgoing = self.update("Downloading %s: %d%% (%d bytes)..." % (url, int(100.0*dlsize/length), dlsize))
- data = download.read(4096)
- if keepgoing:
- self.update("Downloading %s: finished" % url)
- return keepgoing
-
-class PimpUnpacker:
- """Abstract base class - Unpacker for archives"""
-
- _can_rename = False
-
- def __init__(self, argument,
- dir="",
- renames=[],
- watcher=None):
- self.argument = argument
- if renames and not self._can_rename:
- raise RuntimeError, "This unpacker cannot rename files"
- self._dir = dir
- self._renames = renames
- self._watcher = watcher
-
- def unpack(self, archive, output=None, package=None):
- return None
-
- def update(self, str):
- if self._watcher:
- return self._watcher.update(str)
- return True
-
-class PimpCommandUnpacker(PimpUnpacker):
- """Unpack archives by calling a Unix utility"""
-
- _can_rename = False
-
- def unpack(self, archive, output=None, package=None):
- cmd = self.argument % archive
- if _cmd(output, self._dir, cmd):
- return "unpack command failed"
-
-class PimpTarUnpacker(PimpUnpacker):
- """Unpack tarfiles using the builtin tarfile module"""
-
- _can_rename = True
-
- def unpack(self, archive, output=None, package=None):
- tf = tarfile.open(archive, "r")
- members = tf.getmembers()
- skip = []
- if self._renames:
- for member in members:
- for oldprefix, newprefix in self._renames:
- if oldprefix[:len(self._dir)] == self._dir:
- oldprefix2 = oldprefix[len(self._dir):]
- else:
- oldprefix2 = None
- if member.name[:len(oldprefix)] == oldprefix:
- if newprefix is None:
- skip.append(member)
- #print 'SKIP', member.name
- else:
- member.name = newprefix + member.name[len(oldprefix):]
- print ' ', member.name
- break
- elif oldprefix2 and member.name[:len(oldprefix2)] == oldprefix2:
- if newprefix is None:
- skip.append(member)
- #print 'SKIP', member.name
- else:
- member.name = newprefix + member.name[len(oldprefix2):]
- #print ' ', member.name
- break
- else:
- skip.append(member)
- #print '????', member.name
- for member in members:
- if member in skip:
- self.update("Skipping %s" % member.name)
- continue
- self.update("Extracting %s" % member.name)
- tf.extract(member, self._dir)
- if skip:
- names = [member.name for member in skip if member.name[-1] != '/']
- if package:
- names = package.filterExpectedSkips(names)
- if names:
- return "Not all files were unpacked: %s" % " ".join(names)
-
-ARCHIVE_FORMATS = [
- (".tar.Z", PimpTarUnpacker, None),
- (".taz", PimpTarUnpacker, None),
- (".tar.gz", PimpTarUnpacker, None),
- (".tgz", PimpTarUnpacker, None),
- (".tar.bz", PimpTarUnpacker, None),
- (".zip", PimpCommandUnpacker, "unzip \"%s\""),
-]
-
-class PimpPreferences:
- """Container for per-user preferences, such as the database to use
- and where to install packages."""
-
- def __init__(self,
- flavorOrder=None,
- downloadDir=None,
- buildDir=None,
- installDir=None,
- pimpDatabase=None):
- if not flavorOrder:
- flavorOrder = DEFAULT_FLAVORORDER
- if not downloadDir:
- downloadDir = DEFAULT_DOWNLOADDIR
- if not buildDir:
- buildDir = DEFAULT_BUILDDIR
- if not pimpDatabase:
- pimpDatabase = getDefaultDatabase()
- self.setInstallDir(installDir)
- self.flavorOrder = flavorOrder
- self.downloadDir = downloadDir
- self.buildDir = buildDir
- self.pimpDatabase = pimpDatabase
- self.watcher = None
-
- def setWatcher(self, watcher):
- self.watcher = watcher
-
- def setInstallDir(self, installDir=None):
- if installDir:
- # Installing to non-standard location.
- self.installLocations = [
- ('--install-lib', installDir),
- ('--install-headers', None),
- ('--install-scripts', None),
- ('--install-data', None)]
- else:
- installDir = DEFAULT_INSTALLDIR
- self.installLocations = []
- self.installDir = installDir
-
- def isUserInstall(self):
- return self.installDir != DEFAULT_INSTALLDIR
-
- def check(self):
- """Check that the preferences make sense: directories exist and are
- writable, the install directory is on sys.path, etc."""
-
- rv = ""
- RWX_OK = os.R_OK|os.W_OK|os.X_OK
- if not os.path.exists(self.downloadDir):
- rv += "Warning: Download directory \"%s\" does not exist\n" % self.downloadDir
- elif not os.access(self.downloadDir, RWX_OK):
- rv += "Warning: Download directory \"%s\" is not writable or not readable\n" % self.downloadDir
- if not os.path.exists(self.buildDir):
- rv += "Warning: Build directory \"%s\" does not exist\n" % self.buildDir
- elif not os.access(self.buildDir, RWX_OK):
- rv += "Warning: Build directory \"%s\" is not writable or not readable\n" % self.buildDir
- if not os.path.exists(self.installDir):
- rv += "Warning: Install directory \"%s\" does not exist\n" % self.installDir
- elif not os.access(self.installDir, RWX_OK):
- rv += "Warning: Install directory \"%s\" is not writable or not readable\n" % self.installDir
- else:
- installDir = os.path.realpath(self.installDir)
- for p in sys.path:
- try:
- realpath = os.path.realpath(p)
- except:
- pass
- if installDir == realpath:
- break
- else:
- rv += "Warning: Install directory \"%s\" is not on sys.path\n" % self.installDir
- return rv
-
- def compareFlavors(self, left, right):
- """Compare two flavor strings. This is part of your preferences
- because whether the user prefers installing from source or binary is."""
- if left in self.flavorOrder:
- if right in self.flavorOrder:
- return cmp(self.flavorOrder.index(left), self.flavorOrder.index(right))
- return -1
- if right in self.flavorOrder:
- return 1
- return cmp(left, right)
-
-class PimpDatabase:
- """Class representing a pimp database. It can actually contain
- information from multiple databases through inclusion, but the
- toplevel database is considered the master, as its maintainer is
- "responsible" for the contents."""
-
- def __init__(self, prefs):
- self._packages = []
- self.preferences = prefs
- self._url = ""
- self._urllist = []
- self._version = ""
- self._maintainer = ""
- self._description = ""
-
- # Accessor functions
- def url(self): return self._url
- def version(self): return self._version
- def maintainer(self): return self._maintainer
- def description(self): return self._description
-
- def close(self):
- """Clean up"""
- self._packages = []
- self.preferences = None
-
- def appendURL(self, url, included=0):
- """Append packages from the database with the given URL.
- Only the first database should specify included=0, so the
- global information (maintainer, description) get stored."""
-
- if url in self._urllist:
- return
- self._urllist.append(url)
- fp = urllib2.urlopen(url).fp
- plistdata = plistlib.Plist.fromFile(fp)
- # Test here for Pimp version, etc
- if included:
- version = plistdata.get('Version')
- if version and version > self._version:
- sys.stderr.write("Warning: included database %s is for pimp version %s\n" %
- (url, version))
- else:
- self._version = plistdata.get('Version')
- if not self._version:
- sys.stderr.write("Warning: database has no Version information\n")
- elif self._version > PIMP_VERSION:
- sys.stderr.write("Warning: database version %s newer than pimp version %s\n"
- % (self._version, PIMP_VERSION))
- self._maintainer = plistdata.get('Maintainer', '')
- self._description = plistdata.get('Description', '').strip()
- self._url = url
- self._appendPackages(plistdata['Packages'], url)
- others = plistdata.get('Include', [])
- for o in others:
- o = urllib.basejoin(url, o)
- self.appendURL(o, included=1)
-
- def _appendPackages(self, packages, url):
- """Given a list of dictionaries containing package
- descriptions create the PimpPackage objects and append them
- to our internal storage."""
-
- for p in packages:
- p = dict(p)
- if 'Download-URL' in p:
- p['Download-URL'] = urllib.basejoin(url, p['Download-URL'])
- flavor = p.get('Flavor')
- if flavor == 'source':
- pkg = PimpPackage_source(self, p)
- elif flavor == 'binary':
- pkg = PimpPackage_binary(self, p)
- elif flavor == 'installer':
- pkg = PimpPackage_installer(self, p)
- elif flavor == 'hidden':
- pkg = PimpPackage_installer(self, p)
- else:
- pkg = PimpPackage(self, dict(p))
- self._packages.append(pkg)
-
- def list(self):
- """Return a list of all PimpPackage objects in the database."""
-
- return self._packages
-
- def listnames(self):
- """Return a list of names of all packages in the database."""
-
- rv = []
- for pkg in self._packages:
- rv.append(pkg.fullname())
- rv.sort()
- return rv
-
- def dump(self, pathOrFile):
- """Dump the contents of the database to an XML .plist file.
-
- The file can be passed as either a file object or a pathname.
- All data, including included databases, is dumped."""
-
- packages = []
- for pkg in self._packages:
- packages.append(pkg.dump())
- plistdata = {
- 'Version': self._version,
- 'Maintainer': self._maintainer,
- 'Description': self._description,
- 'Packages': packages
- }
- plist = plistlib.Plist(**plistdata)
- plist.write(pathOrFile)
-
- def find(self, ident):
- """Find a package. The package can be specified by name
- or as a dictionary with name, version and flavor entries.
-
- Only name is obligatory. If there are multiple matches the
- best one (higher version number, flavors ordered according to
- users' preference) is returned."""
-
- if type(ident) == str:
- # Remove ( and ) for pseudo-packages
- if ident[0] == '(' and ident[-1] == ')':
- ident = ident[1:-1]
- # Split into name-version-flavor
- fields = ident.split('-')
- if len(fields) < 1 or len(fields) > 3:
- return None
- name = fields[0]
- if len(fields) > 1:
- version = fields[1]
- else:
- version = None
- if len(fields) > 2:
- flavor = fields[2]
- else:
- flavor = None
- else:
- name = ident['Name']
- version = ident.get('Version')
- flavor = ident.get('Flavor')
- found = None
- for p in self._packages:
- if name == p.name() and \
- (not version or version == p.version()) and \
- (not flavor or flavor == p.flavor()):
- if not found or found < p:
- found = p
- return found
-
-ALLOWED_KEYS = [
- "Name",
- "Version",
- "Flavor",
- "Description",
- "Home-page",
- "Download-URL",
- "Install-test",
- "Install-command",
- "Pre-install-command",
- "Post-install-command",
- "Prerequisites",
- "MD5Sum",
- "User-install-skips",
- "Systemwide-only",
-]
-
-class PimpPackage:
- """Class representing a single package."""
-
- def __init__(self, db, plistdata):
- self._db = db
- name = plistdata["Name"]
- for k in plistdata.keys():
- if not k in ALLOWED_KEYS:
- sys.stderr.write("Warning: %s: unknown key %s\n" % (name, k))
- self._dict = plistdata
-
- def __getitem__(self, key):
- return self._dict[key]
-
- def name(self): return self._dict['Name']
- def version(self): return self._dict.get('Version')
- def flavor(self): return self._dict.get('Flavor')
- def description(self): return self._dict['Description'].strip()
- def shortdescription(self): return self.description().splitlines()[0]
- def homepage(self): return self._dict.get('Home-page')
- def downloadURL(self): return self._dict.get('Download-URL')
- def systemwideOnly(self): return self._dict.get('Systemwide-only')
-
- def fullname(self):
- """Return the full name "name-version-flavor" of a package.
-
- If the package is a pseudo-package, something that cannot be
- installed through pimp, return the name in (parentheses)."""
-
- rv = self._dict['Name']
- if 'Version' in self._dict:
- rv = rv + '-%s' % self._dict['Version']
- if 'Flavor' in self._dict:
- rv = rv + '-%s' % self._dict['Flavor']
- if self._dict.get('Flavor') == 'hidden':
- # Pseudo-package, show in parentheses
- rv = '(%s)' % rv
- return rv
-
- def dump(self):
- """Return a dict object containing the information on the package."""
- return self._dict
-
- def __cmp__(self, other):
- """Compare two packages, where the "better" package sorts lower."""
-
- if not isinstance(other, PimpPackage):
- return cmp(id(self), id(other))
- if self.name() != other.name():
- return cmp(self.name(), other.name())
- if self.version() != other.version():
- return -cmp(self.version(), other.version())
- return self._db.preferences.compareFlavors(self.flavor(), other.flavor())
-
- def installed(self):
- """Test wheter the package is installed.
-
- Returns two values: a status indicator which is one of
- "yes", "no", "old" (an older version is installed) or "bad"
- (something went wrong during the install test) and a human
- readable string which may contain more details."""
-
- namespace = {
- "NotInstalled": _scriptExc_NotInstalled,
- "OldInstalled": _scriptExc_OldInstalled,
- "BadInstalled": _scriptExc_BadInstalled,
- "os": os,
- "sys": sys,
- }
- installTest = self._dict['Install-test'].strip() + '\n'
- try:
- exec installTest in namespace
- except ImportError, arg:
- return "no", str(arg)
- except _scriptExc_NotInstalled, arg:
- return "no", str(arg)
- except _scriptExc_OldInstalled, arg:
- return "old", str(arg)
- except _scriptExc_BadInstalled, arg:
- return "bad", str(arg)
- except:
- sys.stderr.write("-------------------------------------\n")
- sys.stderr.write("---- %s: install test got exception\n" % self.fullname())
- sys.stderr.write("---- source:\n")
- sys.stderr.write(installTest)
- sys.stderr.write("---- exception:\n")
- import traceback
- traceback.print_exc(file=sys.stderr)
- if self._db._maintainer:
- sys.stderr.write("---- Please copy this and mail to %s\n" % self._db._maintainer)
- sys.stderr.write("-------------------------------------\n")
- return "bad", "Package install test got exception"
- return "yes", ""
-
- def prerequisites(self):
- """Return a list of prerequisites for this package.
-
- The list contains 2-tuples, of which the first item is either
- a PimpPackage object or None, and the second is a descriptive
- string. The first item can be None if this package depends on
- something that isn't pimp-installable, in which case the descriptive
- string should tell the user what to do."""
-
- rv = []
- if not self._dict.get('Download-URL'):
- # For pseudo-packages that are already installed we don't
- # return an error message
- status, _ = self.installed()
- if status == "yes":
- return []
- return [(None,
- "Package %s cannot be installed automatically, see the description" %
- self.fullname())]
- if self.systemwideOnly() and self._db.preferences.isUserInstall():
- return [(None,
- "Package %s can only be installed system-wide" %
- self.fullname())]
- if not self._dict.get('Prerequisites'):
- return []
- for item in self._dict['Prerequisites']:
- if type(item) == str:
- pkg = None
- descr = str(item)
- else:
- name = item['Name']
- if 'Version' in item:
- name = name + '-' + item['Version']
- if 'Flavor' in item:
- name = name + '-' + item['Flavor']
- pkg = self._db.find(name)
- if not pkg:
- descr = "Requires unknown %s"%name
- else:
- descr = pkg.shortdescription()
- rv.append((pkg, descr))
- return rv
-
-
- def downloadPackageOnly(self, output=None):
- """Download a single package, if needed.
-
- An MD5 signature is used to determine whether download is needed,
- and to test that we actually downloaded what we expected.
- If output is given it is a file-like object that will receive a log
- of what happens.
-
- If anything unforeseen happened the method returns an error message
- string.
- """
-
- scheme, loc, path, query, frag = urlparse.urlsplit(self._dict['Download-URL'])
- path = urllib.url2pathname(path)
- filename = os.path.split(path)[1]
- self.archiveFilename = os.path.join(self._db.preferences.downloadDir, filename)
- if not self._archiveOK():
- if scheme == 'manual':
- return "Please download package manually and save as %s" % self.archiveFilename
- downloader = PimpUrllibDownloader(None, self._db.preferences.downloadDir,
- watcher=self._db.preferences.watcher)
- if not downloader.download(self._dict['Download-URL'],
- self.archiveFilename, output):
- return "download command failed"
- if not os.path.exists(self.archiveFilename) and not NO_EXECUTE:
- return "archive not found after download"
- if not self._archiveOK():
- return "archive does not have correct MD5 checksum"
-
- def _archiveOK(self):
- """Test an archive. It should exist and the MD5 checksum should be correct."""
-
- if not os.path.exists(self.archiveFilename):
- return 0
- if not self._dict.get('MD5Sum'):
- sys.stderr.write("Warning: no MD5Sum for %s\n" % self.fullname())
- return 1
- data = open(self.archiveFilename, 'rb').read()
- checksum = hashlib.md5(data).hexdigest()
- return checksum == self._dict['MD5Sum']
-
- def unpackPackageOnly(self, output=None):
- """Unpack a downloaded package archive."""
-
- filename = os.path.split(self.archiveFilename)[1]
- for ext, unpackerClass, arg in ARCHIVE_FORMATS:
- if filename[-len(ext):] == ext:
- break
- else:
- return "unknown extension for archive file: %s" % filename
- self.basename = filename[:-len(ext)]
- unpacker = unpackerClass(arg, dir=self._db.preferences.buildDir,
- watcher=self._db.preferences.watcher)
- rv = unpacker.unpack(self.archiveFilename, output=output)
- if rv:
- return rv
-
- def installPackageOnly(self, output=None):
- """Default install method, to be overridden by subclasses"""
- return "%s: This package needs to be installed manually (no support for flavor=\"%s\")" \
- % (self.fullname(), self._dict.get(flavor, ""))
-
- def installSinglePackage(self, output=None):
- """Download, unpack and install a single package.
-
- If output is given it should be a file-like object and it
- will receive a log of what happened."""
-
- if not self._dict.get('Download-URL'):
- return "%s: This package needs to be installed manually (no Download-URL field)" % self.fullname()
- msg = self.downloadPackageOnly(output)
- if msg:
- return "%s: download: %s" % (self.fullname(), msg)
-
- msg = self.unpackPackageOnly(output)
- if msg:
- return "%s: unpack: %s" % (self.fullname(), msg)
-
- return self.installPackageOnly(output)
-
- def beforeInstall(self):
- """Bookkeeping before installation: remember what we have in site-packages"""
- self._old_contents = os.listdir(self._db.preferences.installDir)
-
- def afterInstall(self):
- """Bookkeeping after installation: interpret any new .pth files that have
- appeared"""
-
- new_contents = os.listdir(self._db.preferences.installDir)
- for fn in new_contents:
- if fn in self._old_contents:
- continue
- if fn[-4:] != '.pth':
- continue
- fullname = os.path.join(self._db.preferences.installDir, fn)
- f = open(fullname)
- for line in f.readlines():
- if not line:
- continue
- if line[0] == '#':
- continue
- if line[:6] == 'import':
- exec line
- continue
- if line[-1] == '\n':
- line = line[:-1]
- if not os.path.isabs(line):
- line = os.path.join(self._db.preferences.installDir, line)
- line = os.path.realpath(line)
- if not line in sys.path:
- sys.path.append(line)
-
- def filterExpectedSkips(self, names):
- """Return a list that contains only unpexpected skips"""
- if not self._db.preferences.isUserInstall():
- return names
- expected_skips = self._dict.get('User-install-skips')
- if not expected_skips:
- return names
- newnames = []
- for name in names:
- for skip in expected_skips:
- if name[:len(skip)] == skip:
- break
- else:
- newnames.append(name)
- return newnames
-
-class PimpPackage_binary(PimpPackage):
-
- def unpackPackageOnly(self, output=None):
- """We don't unpack binary packages until installing"""
- pass
-
- def installPackageOnly(self, output=None):
- """Install a single source package.
-
- If output is given it should be a file-like object and it
- will receive a log of what happened."""
-
- if 'Install-command' in self._dict:
- return "%s: Binary package cannot have Install-command" % self.fullname()
-
- if 'Pre-install-command' in self._dict:
- if _cmd(output, '/tmp', self._dict['Pre-install-command']):
- return "pre-install %s: running \"%s\" failed" % \
- (self.fullname(), self._dict['Pre-install-command'])
-
- self.beforeInstall()
-
- # Install by unpacking
- filename = os.path.split(self.archiveFilename)[1]
- for ext, unpackerClass, arg in ARCHIVE_FORMATS:
- if filename[-len(ext):] == ext:
- break
- else:
- return "%s: unknown extension for archive file: %s" % (self.fullname(), filename)
- self.basename = filename[:-len(ext)]
-
- install_renames = []
- for k, newloc in self._db.preferences.installLocations:
- if not newloc:
- continue
- if k == "--install-lib":
- oldloc = DEFAULT_INSTALLDIR
- else:
- return "%s: Don't know installLocation %s" % (self.fullname(), k)
- install_renames.append((oldloc, newloc))
-
- unpacker = unpackerClass(arg, dir="/", renames=install_renames)
- rv = unpacker.unpack(self.archiveFilename, output=output, package=self)
- if rv:
- return rv
-
- self.afterInstall()
-
- if 'Post-install-command' in self._dict:
- if _cmd(output, '/tmp', self._dict['Post-install-command']):
- return "%s: post-install: running \"%s\" failed" % \
- (self.fullname(), self._dict['Post-install-command'])
-
- return None
-
-
-class PimpPackage_source(PimpPackage):
-
- def unpackPackageOnly(self, output=None):
- """Unpack a source package and check that setup.py exists"""
- PimpPackage.unpackPackageOnly(self, output)
- # Test that a setup script has been create
- self._buildDirname = os.path.join(self._db.preferences.buildDir, self.basename)
- setupname = os.path.join(self._buildDirname, "setup.py")
- if not os.path.exists(setupname) and not NO_EXECUTE:
- return "no setup.py found after unpack of archive"
-
- def installPackageOnly(self, output=None):
- """Install a single source package.
-
- If output is given it should be a file-like object and it
- will receive a log of what happened."""
-
- if 'Pre-install-command' in self._dict:
- if _cmd(output, self._buildDirname, self._dict['Pre-install-command']):
- return "pre-install %s: running \"%s\" failed" % \
- (self.fullname(), self._dict['Pre-install-command'])
-
- self.beforeInstall()
- installcmd = self._dict.get('Install-command')
- if installcmd and self._install_renames:
- return "Package has install-command and can only be installed to standard location"
- # This is the "bit-bucket" for installations: everything we don't
- # want. After installation we check that it is actually empty
- unwanted_install_dir = None
- if not installcmd:
- extra_args = ""
- for k, v in self._db.preferences.installLocations:
- if not v:
- # We don't want these files installed. Send them
- # to the bit-bucket.
- if not unwanted_install_dir:
- unwanted_install_dir = tempfile.mkdtemp()
- v = unwanted_install_dir
- extra_args = extra_args + " %s \"%s\"" % (k, v)
- installcmd = '"%s" setup.py install %s' % (sys.executable, extra_args)
- if _cmd(output, self._buildDirname, installcmd):
- return "install %s: running \"%s\" failed" % \
- (self.fullname(), installcmd)
- if unwanted_install_dir and os.path.exists(unwanted_install_dir):
- unwanted_files = os.listdir(unwanted_install_dir)
- if unwanted_files:
- rv = "Warning: some files were not installed: %s" % " ".join(unwanted_files)
- else:
- rv = None
- shutil.rmtree(unwanted_install_dir)
- return rv
-
- self.afterInstall()
-
- if 'Post-install-command' in self._dict:
- if _cmd(output, self._buildDirname, self._dict['Post-install-command']):
- return "post-install %s: running \"%s\" failed" % \
- (self.fullname(), self._dict['Post-install-command'])
- return None
-
-class PimpPackage_installer(PimpPackage):
-
- def unpackPackageOnly(self, output=None):
- """We don't unpack dmg packages until installing"""
- pass
-
- def installPackageOnly(self, output=None):
- """Install a single source package.
-
- If output is given it should be a file-like object and it
- will receive a log of what happened."""
-
- if 'Post-install-command' in self._dict:
- return "%s: Installer package cannot have Post-install-command" % self.fullname()
-
- if 'Pre-install-command' in self._dict:
- if _cmd(output, '/tmp', self._dict['Pre-install-command']):
- return "pre-install %s: running \"%s\" failed" % \
- (self.fullname(), self._dict['Pre-install-command'])
-
- self.beforeInstall()
-
- installcmd = self._dict.get('Install-command')
- if installcmd:
- if '%' in installcmd:
- installcmd = installcmd % self.archiveFilename
- else:
- installcmd = 'open \"%s\"' % self.archiveFilename
- if _cmd(output, "/tmp", installcmd):
- return '%s: install command failed (use verbose for details)' % self.fullname()
- return '%s: downloaded and opened. Install manually and restart Package Manager' % self.archiveFilename
-
-class PimpInstaller:
- """Installer engine: computes dependencies and installs
- packages in the right order."""
-
- def __init__(self, db):
- self._todo = []
- self._db = db
- self._curtodo = []
- self._curmessages = []
-
- def __contains__(self, package):
- return package in self._todo
-
- def _addPackages(self, packages):
- for package in packages:
- if not package in self._todo:
- self._todo.append(package)
-
- def _prepareInstall(self, package, force=0, recursive=1):
- """Internal routine, recursive engine for prepareInstall.
-
- Test whether the package is installed and (if not installed
- or if force==1) prepend it to the temporary todo list and
- call ourselves recursively on all prerequisites."""
-
- if not force:
- status, message = package.installed()
- if status == "yes":
- return
- if package in self._todo or package in self._curtodo:
- return
- self._curtodo.insert(0, package)
- if not recursive:
- return
- prereqs = package.prerequisites()
- for pkg, descr in prereqs:
- if pkg:
- self._prepareInstall(pkg, False, recursive)
- else:
- self._curmessages.append("Problem with dependency: %s" % descr)
-
- def prepareInstall(self, package, force=0, recursive=1):
- """Prepare installation of a package.
-
- If the package is already installed and force is false nothing
- is done. If recursive is true prerequisites are installed first.
-
- Returns a list of packages (to be passed to install) and a list
- of messages of any problems encountered.
- """
-
- self._curtodo = []
- self._curmessages = []
- self._prepareInstall(package, force, recursive)
- rv = self._curtodo, self._curmessages
- self._curtodo = []
- self._curmessages = []
- return rv
-
- def install(self, packages, output):
- """Install a list of packages."""
-
- self._addPackages(packages)
- status = []
- for pkg in self._todo:
- msg = pkg.installSinglePackage(output)
- if msg:
- status.append(msg)
- return status
-
-
-
-def _run(mode, verbose, force, args, prefargs, watcher):
- """Engine for the main program"""
-
- prefs = PimpPreferences(**prefargs)
- if watcher:
- prefs.setWatcher(watcher)
- rv = prefs.check()
- if rv:
- sys.stdout.write(rv)
- db = PimpDatabase(prefs)
- db.appendURL(prefs.pimpDatabase)
-
- if mode == 'dump':
- db.dump(sys.stdout)
- elif mode =='list':
- if not args:
- args = db.listnames()
- print "%-20.20s\t%s" % ("Package", "Description")
- print
- for pkgname in args:
- pkg = db.find(pkgname)
- if pkg:
- description = pkg.shortdescription()
- pkgname = pkg.fullname()
- else:
- description = 'Error: no such package'
- print "%-20.20s\t%s" % (pkgname, description)
- if verbose:
- print "\tHome page:\t", pkg.homepage()
- try:
- print "\tDownload URL:\t", pkg.downloadURL()
- except KeyError:
- pass
- description = pkg.description()
- description = '\n\t\t\t\t\t'.join(description.splitlines())
- print "\tDescription:\t%s" % description
- elif mode =='status':
- if not args:
- args = db.listnames()
- print "%-20.20s\t%s\t%s" % ("Package", "Installed", "Message")
- print
- for pkgname in args:
- pkg = db.find(pkgname)
- if pkg:
- status, msg = pkg.installed()
- pkgname = pkg.fullname()
- else:
- status = 'error'
- msg = 'No such package'
- print "%-20.20s\t%-9.9s\t%s" % (pkgname, status, msg)
- if verbose and status == "no":
- prereq = pkg.prerequisites()
- for pkg, msg in prereq:
- if not pkg:
- pkg = ''
- else:
- pkg = pkg.fullname()
- print "%-20.20s\tRequirement: %s %s" % ("", pkg, msg)
- elif mode == 'install':
- if not args:
- print 'Please specify packages to install'
- sys.exit(1)
- inst = PimpInstaller(db)
- for pkgname in args:
- pkg = db.find(pkgname)
- if not pkg:
- print '%s: No such package' % pkgname
- continue
- list, messages = inst.prepareInstall(pkg, force)
- if messages and not force:
- print "%s: Not installed:" % pkgname
- for m in messages:
- print "\t", m
- else:
- if verbose:
- output = sys.stdout
- else:
- output = None
- messages = inst.install(list, output)
- if messages:
- print "%s: Not installed:" % pkgname
- for m in messages:
- print "\t", m
-
-def main():
- """Minimal commandline tool to drive pimp."""
-
- import getopt
- def _help():
- print "Usage: pimp [options] -s [package ...] List installed status"
- print " pimp [options] -l [package ...] Show package information"
- print " pimp [options] -i package ... Install packages"
- print " pimp -d Dump database to stdout"
- print " pimp -V Print version number"
- print "Options:"
- print " -v Verbose"
- print " -f Force installation"
- print " -D dir Set destination directory"
- print " (default: %s)" % DEFAULT_INSTALLDIR
- print " -u url URL for database"
- sys.exit(1)
-
- class _Watcher:
- def update(self, msg):
- sys.stderr.write(msg + '\r')
- return 1
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], "slifvdD:Vu:")
- except getopt.GetoptError:
- _help()
- if not opts and not args:
- _help()
- mode = None
- force = 0
- verbose = 0
- prefargs = {}
- watcher = None
- for o, a in opts:
- if o == '-s':
- if mode:
- _help()
- mode = 'status'
- if o == '-l':
- if mode:
- _help()
- mode = 'list'
- if o == '-d':
- if mode:
- _help()
- mode = 'dump'
- if o == '-V':
- if mode:
- _help()
- mode = 'version'
- if o == '-i':
- mode = 'install'
- if o == '-f':
- force = 1
- if o == '-v':
- verbose = 1
- watcher = _Watcher()
- if o == '-D':
- prefargs['installDir'] = a
- if o == '-u':
- prefargs['pimpDatabase'] = a
- if not mode:
- _help()
- if mode == 'version':
- print 'Pimp version %s; module name is %s' % (PIMP_VERSION, __name__)
- else:
- _run(mode, verbose, force, args, prefargs, watcher)
-
-# Finally, try to update ourselves to a newer version.
-# If the end-user updates pimp through pimp the new version
-# will be called pimp_update and live in site-packages
-# or somewhere similar
-if __name__ != 'pimp_update':
- try:
- import pimp_update
- except ImportError:
- pass
- else:
- if pimp_update.PIMP_VERSION <= PIMP_VERSION:
- import warnings
- warnings.warn("pimp_update is version %s, not newer than pimp version %s" %
- (pimp_update.PIMP_VERSION, PIMP_VERSION))
- else:
- from pimp_update import *
-
-if __name__ == '__main__':
- main()
diff --git a/Lib/plat-mac/terminalcommand.py b/Lib/plat-mac/terminalcommand.py
deleted file mode 100644
index ef8cb6c4101..00000000000
--- a/Lib/plat-mac/terminalcommand.py
+++ /dev/null
@@ -1,50 +0,0 @@
-"""terminalcommand.py -- A minimal interface to Terminal.app.
-
-To run a shell command in a new Terminal.app window:
-
- import terminalcommand
- terminalcommand.run("ls -l")
-
-No result is returned; it is purely meant as a quick way to run a script
-with a decent input/output window.
-"""
-
-#
-# This module is a fairly straightforward translation of Jack Jansen's
-# Mac/OSX/PythonLauncher/doscript.m.
-#
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the terminalcommand module is removed.", stacklevel=2)
-
-import time
-import os
-from Carbon import AE
-from Carbon.AppleEvents import *
-
-
-TERMINAL_SIG = "trmx"
-START_TERMINAL = "/usr/bin/open /Applications/Utilities/Terminal.app"
-SEND_MODE = kAENoReply # kAEWaitReply hangs when run from Terminal.app itself
-
-
-def run(command):
- """Run a shell command in a new Terminal.app window."""
- termAddress = AE.AECreateDesc(typeApplicationBundleID, "com.apple.Terminal")
- theEvent = AE.AECreateAppleEvent(kAECoreSuite, kAEDoScript, termAddress,
- kAutoGenerateReturnID, kAnyTransactionID)
- commandDesc = AE.AECreateDesc(typeChar, command)
- theEvent.AEPutParamDesc(kAECommandClass, commandDesc)
-
- try:
- theEvent.AESend(SEND_MODE, kAENormalPriority, kAEDefaultTimeout)
- except AE.Error, why:
- if why[0] != -600: # Terminal.app not yet running
- raise
- os.system(START_TERMINAL)
- time.sleep(1)
- theEvent.AESend(SEND_MODE, kAENormalPriority, kAEDefaultTimeout)
-
-
-if __name__ == "__main__":
- run("ls -l")
diff --git a/Lib/plat-mac/videoreader.py b/Lib/plat-mac/videoreader.py
deleted file mode 100644
index 9dd7d67b022..00000000000
--- a/Lib/plat-mac/videoreader.py
+++ /dev/null
@@ -1,294 +0,0 @@
-# Video file reader, using QuickTime
-#
-# This module was quickly ripped out of another software package, so there is a good
-# chance that it does not work as-is and it needs some hacking.
-#
-# Jack Jansen, August 2000
-#
-
-from warnings import warnpy3k
-warnpy3k("In 3.x, the videoreader module is removed.", stacklevel=2)
-
-
-import sys
-from Carbon import Qt
-from Carbon import QuickTime
-from Carbon import Qd
-from Carbon import Qdoffs
-from Carbon import QDOffscreen
-from Carbon import Res
-try:
- from Carbon import MediaDescr
-except ImportError:
- def _audiodescr(data):
- return None
-else:
- def _audiodescr(data):
- return MediaDescr.SoundDescription.decode(data)
-try:
- from imgformat import macrgb
-except ImportError:
- macrgb = "Macintosh RGB format"
-import os
-# import audio.format
-
-class VideoFormat:
- def __init__(self, name, descr, width, height, format):
- self.__name = name
- self.__descr = descr
- self.__width = width
- self.__height = height
- self.__format = format
-
- def getname(self):
- return self.__name
-
- def getdescr(self):
- return self.__descr
-
- def getsize(self):
- return self.__width, self.__height
-
- def getformat(self):
- return self.__format
-
-class _Reader:
- def __init__(self, path):
- fd = Qt.OpenMovieFile(path, 0)
- self.movie, d1, d2 = Qt.NewMovieFromFile(fd, 0, 0)
- self.movietimescale = self.movie.GetMovieTimeScale()
- try:
- self.audiotrack = self.movie.GetMovieIndTrackType(1,
- QuickTime.AudioMediaCharacteristic, QuickTime.movieTrackCharacteristic)
- self.audiomedia = self.audiotrack.GetTrackMedia()
- except Qt.Error:
- self.audiotrack = self.audiomedia = None
- self.audiodescr = {}
- else:
- handle = Res.Handle('')
- n = self.audiomedia.GetMediaSampleDescriptionCount()
- self.audiomedia.GetMediaSampleDescription(1, handle)
- self.audiodescr = _audiodescr(handle.data)
- self.audiotimescale = self.audiomedia.GetMediaTimeScale()
- del handle
-
- try:
- self.videotrack = self.movie.GetMovieIndTrackType(1,
- QuickTime.VisualMediaCharacteristic, QuickTime.movieTrackCharacteristic)
- self.videomedia = self.videotrack.GetTrackMedia()
- except Qt.Error:
- self.videotrack = self.videomedia = self.videotimescale = None
- if self.videotrack:
- self.videotimescale = self.videomedia.GetMediaTimeScale()
- x0, y0, x1, y1 = self.movie.GetMovieBox()
- self.videodescr = {'width':(x1-x0), 'height':(y1-y0)}
- self._initgworld()
- self.videocurtime = None
- self.audiocurtime = None
-
-
- def __del__(self):
- self.audiomedia = None
- self.audiotrack = None
- self.videomedia = None
- self.videotrack = None
- self.movie = None
-
- def _initgworld(self):
- old_port, old_dev = Qdoffs.GetGWorld()
- try:
- movie_w = self.videodescr['width']
- movie_h = self.videodescr['height']
- movie_rect = (0, 0, movie_w, movie_h)
- self.gworld = Qdoffs.NewGWorld(32, movie_rect, None, None, QDOffscreen.keepLocal)
- self.pixmap = self.gworld.GetGWorldPixMap()
- Qdoffs.LockPixels(self.pixmap)
- Qdoffs.SetGWorld(self.gworld.as_GrafPtr(), None)
- Qd.EraseRect(movie_rect)
- self.movie.SetMovieGWorld(self.gworld.as_GrafPtr(), None)
- self.movie.SetMovieBox(movie_rect)
- self.movie.SetMovieActive(1)
- self.movie.MoviesTask(0)
- self.movie.SetMoviePlayHints(QuickTime.hintsHighQuality, QuickTime.hintsHighQuality)
- # XXXX framerate
- finally:
- Qdoffs.SetGWorld(old_port, old_dev)
-
- def _gettrackduration_ms(self, track):
- tracktime = track.GetTrackDuration()
- return self._movietime_to_ms(tracktime)
-
- def _movietime_to_ms(self, time):
- value, d1, d2 = Qt.ConvertTimeScale((time, self.movietimescale, None), 1000)
- return value
-
- def _videotime_to_ms(self, time):
- value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None), 1000)
- return value
-
- def _audiotime_to_ms(self, time):
- value, d1, d2 = Qt.ConvertTimeScale((time, self.audiotimescale, None), 1000)
- return value
-
- def _videotime_to_movietime(self, time):
- value, d1, d2 = Qt.ConvertTimeScale((time, self.videotimescale, None),
- self.movietimescale)
- return value
-
- def HasAudio(self):
- return not self.audiotrack is None
-
- def HasVideo(self):
- return not self.videotrack is None
-
- def GetAudioDuration(self):
- if not self.audiotrack:
- return 0
- return self._gettrackduration_ms(self.audiotrack)
-
- def GetVideoDuration(self):
- if not self.videotrack:
- return 0
- return self._gettrackduration_ms(self.videotrack)
-
- def GetAudioFormat(self):
- if not self.audiodescr:
- return None, None, None, None, None
- bps = self.audiodescr['sampleSize']
- nch = self.audiodescr['numChannels']
- if nch == 1:
- channels = ['mono']
- elif nch == 2:
- channels = ['left', 'right']
- else:
- channels = map(lambda x: str(x+1), range(nch))
- if bps % 8:
- # Funny bits-per sample. We pretend not to understand
- blocksize = 0
- fpb = 0
- else:
- # QuickTime is easy (for as far as we support it): samples are always a whole
- # number of bytes, so frames are nchannels*samplesize, and there's one frame per block.
- blocksize = (bps/8)*nch
- fpb = 1
- if self.audiodescr['dataFormat'] == 'raw ':
- encoding = 'linear-excess'
- elif self.audiodescr['dataFormat'] == 'twos':
- encoding = 'linear-signed'
- else:
- encoding = 'quicktime-coding-%s'%self.audiodescr['dataFormat']
-## return audio.format.AudioFormatLinear('quicktime_audio', 'QuickTime Audio Format',
-## channels, encoding, blocksize=blocksize, fpb=fpb, bps=bps)
- return channels, encoding, blocksize, fpb, bps
-
- def GetAudioFrameRate(self):
- if not self.audiodescr:
- return None
- return int(self.audiodescr['sampleRate'])
-
- def GetVideoFormat(self):
- width = self.videodescr['width']
- height = self.videodescr['height']
- return VideoFormat('dummy_format', 'Dummy Video Format', width, height, macrgb)
-
- def GetVideoFrameRate(self):
- tv = self.videocurtime
- if tv is None:
- tv = 0
- flags = QuickTime.nextTimeStep|QuickTime.nextTimeEdgeOK
- tv, dur = self.videomedia.GetMediaNextInterestingTime(flags, tv, 1.0)
- dur = self._videotime_to_ms(dur)
- return int((1000.0/dur)+0.5)
-
- def ReadAudio(self, nframes, time=None):
- if not time is None:
- self.audiocurtime = time
- flags = QuickTime.nextTimeStep|QuickTime.nextTimeEdgeOK
- if self.audiocurtime is None:
- self.audiocurtime = 0
- tv = self.audiomedia.GetMediaNextInterestingTimeOnly(flags, self.audiocurtime, 1.0)
- if tv < 0 or (self.audiocurtime and tv < self.audiocurtime):
- return self._audiotime_to_ms(self.audiocurtime), None
- h = Res.Handle('')
- desc_h = Res.Handle('')
- size, actualtime, sampleduration, desc_index, actualcount, flags = \
- self.audiomedia.GetMediaSample(h, 0, tv, desc_h, nframes)
- self.audiocurtime = actualtime + actualcount*sampleduration
- return self._audiotime_to_ms(actualtime), h.data
-
- def ReadVideo(self, time=None):
- if not time is None:
- self.videocurtime = time
- flags = QuickTime.nextTimeStep
- if self.videocurtime is None:
- flags = flags | QuickTime.nextTimeEdgeOK
- self.videocurtime = 0
- tv = self.videomedia.GetMediaNextInterestingTimeOnly(flags, self.videocurtime, 1.0)
- if tv < 0 or (self.videocurtime and tv <= self.videocurtime):
- return self._videotime_to_ms(self.videocurtime), None
- self.videocurtime = tv
- moviecurtime = self._videotime_to_movietime(self.videocurtime)
- self.movie.SetMovieTimeValue(moviecurtime)
- self.movie.MoviesTask(0)
- return self._videotime_to_ms(self.videocurtime), self._getpixmapcontent()
-
- def _getpixmapcontent(self):
- """Shuffle the offscreen PixMap data, because it may have funny stride values"""
- rowbytes = Qdoffs.GetPixRowBytes(self.pixmap)
- width = self.videodescr['width']
- height = self.videodescr['height']
- start = 0
- rv = []
- for i in range(height):
- nextline = Qdoffs.GetPixMapBytes(self.pixmap, start, width*4)
- start = start + rowbytes
- rv.append(nextline)
- return ''.join(rv)
-
-def reader(url):
- try:
- rdr = _Reader(url)
- except IOError:
- return None
- return rdr
-
-def _test():
- import EasyDialogs
- try:
- from PIL import Image
- except ImportError:
- Image = None
- import MacOS
- Qt.EnterMovies()
- path = EasyDialogs.AskFileForOpen(message='Video to convert')
- if not path: sys.exit(0)
- rdr = reader(path)
- if not rdr:
- sys.exit(1)
- dstdir = EasyDialogs.AskFileForSave(message='Name for output folder')
- if not dstdir: sys.exit(0)
- num = 0
- os.mkdir(dstdir)
- videofmt = rdr.GetVideoFormat()
- imgfmt = videofmt.getformat()
- imgw, imgh = videofmt.getsize()
- timestamp, data = rdr.ReadVideo()
- while data:
- fname = 'frame%04.4d.jpg'%num
- num = num+1
- pname = os.path.join(dstdir, fname)
- if not Image: print 'Not',
- print 'Writing %s, size %dx%d, %d bytes'%(fname, imgw, imgh, len(data))
- if Image:
- img = Image.fromstring("RGBA", (imgw, imgh), data)
- img.save(pname, 'JPEG')
- timestamp, data = rdr.ReadVideo()
- MacOS.SetCreatorAndType(pname, 'ogle', 'JPEG')
- if num > 20:
- print 'stopping at 20 frames so your disk does not fill up:-)'
- break
- print 'Total frames:', num
-
-if __name__ == '__main__':
- _test()
- sys.exit(1)
diff --git a/Lib/plat-os2emx/IN.py b/Lib/plat-os2emx/IN.py
index 8b06eb8f07e..753ae248836 100644
--- a/Lib/plat-os2emx/IN.py
+++ b/Lib/plat-os2emx/IN.py
@@ -28,33 +28,33 @@ IPPROTO_RAW = 255
IPPROTO_MAX = 256
IPPORT_RESERVED = 1024
IPPORT_USERRESERVED = 5000
-def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
+def IN_CLASSA(i): return (((int)(i) & 0x80000000) == 0)
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 24
IN_CLASSA_HOST = 0x00ffffff
IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
+def IN_CLASSB(i): return (((int)(i) & 0xc0000000) == 0x80000000)
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 16
IN_CLASSB_HOST = 0x0000ffff
IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
+def IN_CLASSC(i): return (((int)(i) & 0xe0000000) == 0xc0000000)
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 8
IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
+def IN_CLASSD(i): return (((int)(i) & 0xf0000000) == 0xe0000000)
IN_CLASSD_NET = 0xf0000000
IN_CLASSD_NSHIFT = 28
IN_CLASSD_HOST = 0x0fffffff
def IN_MULTICAST(i): return IN_CLASSD(i)
-def IN_EXPERIMENTAL(i): return (((long)(i) & 0xe0000000) == 0xe0000000)
+def IN_EXPERIMENTAL(i): return (((int)(i) & 0xe0000000) == 0xe0000000)
-def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
+def IN_BADCLASS(i): return (((int)(i) & 0xf0000000) == 0xf0000000)
INADDR_ANY = 0x00000000
INADDR_LOOPBACK = 0x7f000001
diff --git a/Lib/plat-os2emx/_emx_link.py b/Lib/plat-os2emx/_emx_link.py
index 422c2bbf6f0..01e6b54c8d5 100644
--- a/Lib/plat-os2emx/_emx_link.py
+++ b/Lib/plat-os2emx/_emx_link.py
@@ -47,7 +47,7 @@ def link(source, target):
s = os.open(source, os.O_RDONLY | os.O_BINARY)
if os.isatty(s):
- raise OSError, (errno.EXDEV, 'Cross-device link')
+ raise OSError(errno.EXDEV, 'Cross-device link')
data = os.read(s, 1024)
try:
@@ -74,6 +74,6 @@ if __name__ == '__main__':
try:
link(sys.argv[1], sys.argv[2])
except IndexError:
- print 'Usage: emx_link <source> <target>'
+ print('Usage: emx_link <source> <target>')
except OSError:
- print 'emx_link: %s' % str(sys.exc_info()[1])
+ print('emx_link: %s' % str(sys.exc_info()[1]))
diff --git a/Lib/plat-os2emx/grp.py b/Lib/plat-os2emx/grp.py
index a5f346872ae..ee63ef8ae20 100644
--- a/Lib/plat-os2emx/grp.py
+++ b/Lib/plat-os2emx/grp.py
@@ -58,11 +58,11 @@ import os
# try and find the group file
__group_path = []
-if os.environ.has_key('ETC_GROUP'):
+if 'ETC_GROUP' in os.environ:
__group_path.append(os.environ['ETC_GROUP'])
-if os.environ.has_key('ETC'):
+if 'ETC' in os.environ:
__group_path.append('%s/group' % os.environ['ETC'])
-if os.environ.has_key('PYTHONHOME'):
+if 'PYTHONHOME' in os.environ:
__group_path.append('%s/Etc/group' % os.environ['PYTHONHOME'])
group_file = None
@@ -94,7 +94,7 @@ def __get_field_sep(record):
if fs:
return fs
else:
- raise KeyError, '>> group database fields not delimited <<'
+ raise KeyError('>> group database fields not delimited <<')
# class to match the new record field name accessors.
# the resulting object is intended to behave like a read-only tuple,
@@ -136,7 +136,7 @@ def __read_group_file():
if group_file:
group = open(group_file, 'r')
else:
- raise KeyError, '>> no group database <<'
+ raise KeyError('>> no group database <<')
gidx = {}
namx = {}
sep = None
@@ -149,9 +149,9 @@ def __read_group_file():
fields[2] = int(fields[2])
fields[3] = [f.strip() for f in fields[3].split(',')]
record = Group(*fields)
- if not gidx.has_key(fields[2]):
+ if fields[2] not in gidx:
gidx[fields[2]] = record
- if not namx.has_key(fields[0]):
+ if fields[0] not in namx:
namx[fields[0]] = record
elif len(entry) > 0:
pass # skip empty or malformed records
diff --git a/Lib/plat-os2emx/pwd.py b/Lib/plat-os2emx/pwd.py
index ceb92d918c0..2cb077f5abe 100644
--- a/Lib/plat-os2emx/pwd.py
+++ b/Lib/plat-os2emx/pwd.py
@@ -61,11 +61,11 @@ import os
# try and find the passwd file
__passwd_path = []
-if os.environ.has_key('ETC_PASSWD'):
+if 'ETC_PASSWD' in os.environ:
__passwd_path.append(os.environ['ETC_PASSWD'])
-if os.environ.has_key('ETC'):
+if 'ETC' in os.environ:
__passwd_path.append('%s/passwd' % os.environ['ETC'])
-if os.environ.has_key('PYTHONHOME'):
+if 'PYTHONHOME' in os.environ:
__passwd_path.append('%s/Etc/passwd' % os.environ['PYTHONHOME'])
passwd_file = None
@@ -113,7 +113,7 @@ def __get_field_sep(record):
if fs:
return fs
else:
- raise KeyError, '>> passwd database fields not delimited <<'
+ raise KeyError('>> passwd database fields not delimited <<')
# class to match the new record field name accessors.
# the resulting object is intended to behave like a read-only tuple,
@@ -160,11 +160,11 @@ def __read_passwd_file():
if passwd_file:
passwd = open(passwd_file, 'r')
else:
- raise KeyError, '>> no password database <<'
+ raise KeyError('>> no password database <<')
uidx = {}
namx = {}
sep = None
- while 1:
+ while True:
entry = passwd.readline().strip()
if len(entry) > 6:
if sep is None:
@@ -175,9 +175,9 @@ def __read_passwd_file():
for i in (5, 6):
fields[i] = __field_sep[sep](fields[i])
record = Passwd(*fields)
- if not uidx.has_key(fields[2]):
+ if fields[2] not in uidx:
uidx[fields[2]] = record
- if not namx.has_key(fields[0]):
+ if fields[0] not in namx:
namx[fields[0]] = record
elif len(entry) > 0:
pass # skip empty or malformed records
diff --git a/Lib/plat-riscos/riscosenviron.py b/Lib/plat-riscos/riscosenviron.py
deleted file mode 100644
index 95a2ce55d99..00000000000
--- a/Lib/plat-riscos/riscosenviron.py
+++ /dev/null
@@ -1,45 +0,0 @@
-"""A more or less complete dictionary like interface for the RISC OS environment."""
-
-import riscos
-
-class _Environ:
- def __init__(self, initial = None):
- pass
- def __repr__(self):
- return repr(riscos.getenvdict())
- def __cmp__(self, dict):
- return cmp(riscos.getenvdict(), dict)
- def __len__(self):
- return len(riscos.getenvdict())
- def __getitem__(self, key):
- ret = riscos.getenv(key)
- if ret<>None:
- return ret
- else:
- raise KeyError
- def __setitem__(self, key, item):
- riscos.putenv(key, item)
- def __delitem__(self, key):
- riscos.delenv(key)
- def clear(self):
- # too dangerous on RISC OS
- pass
- def copy(self):
- return riscos.getenvdict()
- def keys(self): return riscos.getenvdict().keys()
- def items(self): return riscos.getenvdict().items()
- def values(self): return riscos.getenvdict().values()
- def has_key(self, key):
- value = riscos.getenv(key)
- return value<>None
- def __contains__(self, key):
- return riscos.getenv(key) is not None
- def update(self, dict):
- for k, v in dict.items():
- riscos.putenv(k, v)
- def get(self, key, failobj=None):
- value = riscos.getenv(key)
- if value<>None:
- return value
- else:
- return failobj
diff --git a/Lib/plat-riscos/riscospath.py b/Lib/plat-riscos/riscospath.py
deleted file mode 100644
index ea39e60f103..00000000000
--- a/Lib/plat-riscos/riscospath.py
+++ /dev/null
@@ -1,378 +0,0 @@
-# Module 'riscospath' -- common operations on RISC OS pathnames.
-
-# contributed by Andrew Clover ( andrew@oaktree.co.uk )
-
-# The "os.path" name is an alias for this module on RISC OS systems;
-# on other systems (e.g. Mac, Windows), os.path provides the same
-# operations in a manner specific to that platform, and is an alias
-# to another module (e.g. macpath, ntpath).
-
-"""
-Instead of importing this module directly, import os and refer to this module
-as os.path.
-"""
-
-# strings representing various path-related bits and pieces
-curdir = '@'
-pardir = '^'
-extsep = '/'
-sep = '.'
-pathsep = ','
-defpath = '<Run$Dir>'
-altsep = None
-
-# Imports - make an error-generating swi object if the swi module is not
-# available (ie. we are not running on RISC OS Python)
-
-import os, stat, string
-
-try:
- import swi
-except ImportError:
- class _swi:
- def swi(*a):
- raise AttributeError, 'This function only available under RISC OS'
- block= swi
- swi= _swi()
-
-[_false, _true]= range(2)
-
-_roots= ['$', '&', '%', '@', '\\']
-
-
-# _allowMOSFSNames
-# After importing riscospath, set _allowMOSFSNames true if you want the module
-# to understand the "-SomeFS-" notation left over from the old BBC Master MOS,
-# as well as the standard "SomeFS:" notation. Set this to be fully backwards
-# compatible but remember that "-SomeFS-" can also be a perfectly valid file
-# name so care must be taken when splitting and joining paths.
-
-_allowMOSFSNames= _false
-
-
-## Path manipulation, RISC OS stylee.
-
-def _split(p):
- """
- split filing system name (including special field) and drive specifier from rest
- of path. This is needed by many riscospath functions.
- """
- dash= _allowMOSFSNames and p[:1]=='-'
- if dash:
- q= string.find(p, '-', 1)+1
- else:
- if p[:1]==':':
- q= 0
- else:
- q= string.find(p, ':')+1 # q= index of start of non-FS portion of path
- s= string.find(p, '#')
- if s==-1 or s>q:
- s= q # find end of main FS name, not including special field
- else:
- for c in p[dash:s]:
- if c not in string.ascii_letters:
- q= 0
- break # disallow invalid non-special-field characters in FS name
- r= q
- if p[q:q+1]==':':
- r= string.find(p, '.', q+1)+1
- if r==0:
- r= len(p) # find end of drive name (if any) following FS name (if any)
- return (p[:q], p[q:r], p[r:])
-
-
-def normcase(p):
- """
- Normalize the case of a pathname. This converts to lowercase as the native RISC
- OS filesystems are case-insensitive. However, not all filesystems have to be,
- and there's no simple way to find out what type an FS is argh.
- """
- return string.lower(p)
-
-
-def isabs(p):
- """
- Return whether a path is absolute. Under RISC OS, a file system specifier does
- not make a path absolute, but a drive name or number does, and so does using the
- symbol for root, URD, library, CSD or PSD. This means it is perfectly possible
- to have an "absolute" URL dependent on the current working directory, and
- equally you can have a "relative" URL that's on a completely different device to
- the current one argh.
- """
- (fs, drive, path)= _split(p)
- return drive!='' or path[:1] in _roots
-
-
-def join(a, *p):
- """
- Join path elements with the directory separator, replacing the entire path when
- an absolute or FS-changing path part is found.
- """
- j= a
- for b in p:
- (fs, drive, path)= _split(b)
- if j=='' or fs!='' or drive!='' or path[:1] in _roots:
- j= b
- elif j[-1]==':':
- j= j+b
- else:
- j= j+'.'+b
- return j
-
-
-def split(p):
- """
- Split a path in head (everything up to the last '.') and tail (the rest). FS
- name must still be dealt with separately since special field may contain '.'.
- """
- (fs, drive, path)= _split(p)
- q= string.rfind(path, '.')
- if q!=-1:
- return (fs+drive+path[:q], path[q+1:])
- return ('', p)
-
-
-def splitext(p):
- """
- Split a path in root and extension. This assumes the 'using slash for dot and
- dot for slash with foreign files' convention common in RISC OS is in force.
- """
- (tail, head)= split(p)
- if '/' in head:
- q= len(head)-string.rfind(head, '/')
- return (p[:-q], p[-q:])
- return (p, '')
-
-
-def splitdrive(p):
- """
- Split a pathname into a drive specification (including FS name) and the rest of
- the path. The terminating dot of the drive name is included in the drive
- specification.
- """
- (fs, drive, path)= _split(p)
- return (fs+drive, p)
-
-
-def basename(p):
- """
- Return the tail (basename) part of a path.
- """
- return split(p)[1]
-
-
-def dirname(p):
- """
- Return the head (dirname) part of a path.
- """
- return split(p)[0]
-
-
-def commonprefix(m):
- "Given a list of pathnames, returns the longest common leading component"
- if not m: return ''
- s1 = min(m)
- s2 = max(m)
- n = min(len(s1), len(s2))
- for i in xrange(n):
- if s1[i] != s2[i]:
- return s1[:i]
- return s1[:n]
-
-
-## File access functions. Why are we in os.path?
-
-def getsize(p):
- """
- Return the size of a file, reported by os.stat().
- """
- st= os.stat(p)
- return st[stat.ST_SIZE]
-
-
-def getmtime(p):
- """
- Return the last modification time of a file, reported by os.stat().
- """
- st = os.stat(p)
- return st[stat.ST_MTIME]
-
-getatime= getmtime
-
-
-# RISC OS-specific file access functions
-
-def exists(p):
- """
- Test whether a path exists.
- """
- try:
- return swi.swi('OS_File', '5s;i', p)!=0
- except swi.error:
- return 0
-
-lexists = exists
-
-
-def isdir(p):
- """
- Is a path a directory? Includes image files.
- """
- try:
- return swi.swi('OS_File', '5s;i', p) in [2, 3]
- except swi.error:
- return 0
-
-
-def isfile(p):
- """
- Test whether a path is a file, including image files.
- """
- try:
- return swi.swi('OS_File', '5s;i', p) in [1, 3]
- except swi.error:
- return 0
-
-
-def islink(p):
- """
- RISC OS has no links or mounts.
- """
- return _false
-
-ismount= islink
-
-
-# Same-file testing.
-
-# samefile works on filename comparison since there is no ST_DEV and ST_INO is
-# not reliably unique (esp. directories). First it has to normalise the
-# pathnames, which it can do 'properly' using OS_FSControl since samefile can
-# assume it's running on RISC OS (unlike normpath).
-
-def samefile(fa, fb):
- """
- Test whether two pathnames reference the same actual file.
- """
- l= 512
- b= swi.block(l)
- swi.swi('OS_FSControl', 'isb..i', 37, fa, b, l)
- fa= b.ctrlstring()
- swi.swi('OS_FSControl', 'isb..i', 37, fb, b, l)
- fb= b.ctrlstring()
- return fa==fb
-
-
-def sameopenfile(a, b):
- """
- Test whether two open file objects reference the same file.
- """
- return os.fstat(a)[stat.ST_INO]==os.fstat(b)[stat.ST_INO]
-
-
-## Path canonicalisation
-
-# 'user directory' is taken as meaning the User Root Directory, which is in
-# practice never used, for anything.
-
-def expanduser(p):
- (fs, drive, path)= _split(p)
- l= 512
- b= swi.block(l)
-
- if path[:1]!='@':
- return p
- if fs=='':
- fsno= swi.swi('OS_Args', '00;i')
- swi.swi('OS_FSControl', 'iibi', 33, fsno, b, l)
- fsname= b.ctrlstring()
- else:
- if fs[:1]=='-':
- fsname= fs[1:-1]
- else:
- fsname= fs[:-1]
- fsname= string.split(fsname, '#', 1)[0] # remove special field from fs
- x= swi.swi('OS_FSControl', 'ib2s.i;.....i', 54, b, fsname, l)
- if x<l:
- urd= b.tostring(0, l-x-1)
- else: # no URD! try CSD
- x= swi.swi('OS_FSControl', 'ib0s.i;.....i', 54, b, fsname, l)
- if x<l:
- urd= b.tostring(0, l-x-1)
- else: # no CSD! use root
- urd= '$'
- return fsname+':'+urd+path[1:]
-
-# Environment variables are in angle brackets.
-
-def expandvars(p):
- """
- Expand environment variables using OS_GSTrans.
- """
- l= 512
- b= swi.block(l)
- return b.tostring(0, swi.swi('OS_GSTrans', 'sbi;..i', p, b, l))
-
-
-# Return an absolute path. RISC OS' osfscontrol_canonicalise_path does this among others
-abspath = os.expand
-
-
-# realpath is a no-op on systems without islink support
-realpath = abspath
-
-
-# Normalize a path. Only special path element under RISC OS is "^" for "..".
-
-def normpath(p):
- """
- Normalize path, eliminating up-directory ^s.
- """
- (fs, drive, path)= _split(p)
- rhs= ''
- ups= 0
- while path!='':
- (path, el)= split(path)
- if el=='^':
- ups= ups+1
- else:
- if ups>0:
- ups= ups-1
- else:
- if rhs=='':
- rhs= el
- else:
- rhs= el+'.'+rhs
- while ups>0:
- ups= ups-1
- rhs= '^.'+rhs
- return fs+drive+rhs
-
-
-# Directory tree walk.
-# Independent of host system. Why am I in os.path?
-
-def walk(top, func, arg):
- """Directory tree walk with callback function.
-
- For each directory in the directory tree rooted at top (including top
- itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
- dirname is the name of the directory, and fnames a list of the names of
- the files and subdirectories in dirname (excluding '.' and '..'). func
- may modify the fnames list in-place (e.g. via del or slice assignment),
- and walk will only recurse into the subdirectories whose names remain in
- fnames; this can be used to implement a filter, or to impose a specific
- order of visiting. No semantics are defined for, or required of, arg,
- beyond that arg is always passed to func. It can be used, e.g., to pass
- a filename pattern, or a mutable object designed to accumulate
- statistics. Passing None for arg is common."""
-
- try:
- names= os.listdir(top)
- except os.error:
- return
- func(arg, top, names)
- for name in names:
- name= join(top, name)
- if isdir(name) and not islink(name):
- walk(name, func, arg)
diff --git a/Lib/plat-riscos/rourl2path.py b/Lib/plat-riscos/rourl2path.py
deleted file mode 100644
index 5d5386e65cc..00000000000
--- a/Lib/plat-riscos/rourl2path.py
+++ /dev/null
@@ -1,70 +0,0 @@
-"""riscos specific module for conversion between pathnames and URLs.
-Based on macurl2path.
-Do not import directly, use urllib instead."""
-
-import string
-import urllib
-
-__all__ = ["url2pathname","pathname2url"]
-
-__slash_dot = string.maketrans("/.", "./")
-
-def url2pathname(url):
- """OS-specific conversion from a relative URL of the 'file' scheme
- to a file system path; not recommended for general use."""
- tp = urllib.splittype(url)[0]
- if tp and tp <> 'file':
- raise RuntimeError, 'Cannot convert non-local URL to pathname'
- # Turn starting /// into /, an empty hostname means current host
- if url[:3] == '///':
- url = url[2:]
- elif url[:2] == '//':
- raise RuntimeError, 'Cannot convert non-local URL to pathname'
- components = string.split(url, '/')
- if not components[0]:
- if '$' in components:
- del components[0]
- else:
- components[0] = '$'
- # Remove . and embedded ..
- i = 0
- while i < len(components):
- if components[i] == '.':
- del components[i]
- elif components[i] == '..' and i > 0 and \
- components[i-1] not in ('', '..'):
- del components[i-1:i+1]
- i -= 1
- elif components[i] == '..':
- components[i] = '^'
- i += 1
- elif components[i] == '' and i > 0 and components[i-1] <> '':
- del components[i]
- else:
- i += 1
- components = map(lambda x: urllib.unquote(x).translate(__slash_dot), components)
- return '.'.join(components)
-
-def pathname2url(pathname):
- """OS-specific conversion from a file system path to a relative URL
- of the 'file' scheme; not recommended for general use."""
- return urllib.quote('///' + pathname.translate(__slash_dot), "/$:")
-
-def test():
- for url in ["index.html",
- "/SCSI::SCSI4/$/Anwendung/Comm/Apps/!Fresco/Welcome",
- "/SCSI::SCSI4/$/Anwendung/Comm/Apps/../!Fresco/Welcome",
- "../index.html",
- "bar/index.html",
- "/foo/bar/index.html",
- "/foo/bar/",
- "/"]:
- print '%r -> %r' % (url, url2pathname(url))
- print "*******************************************************"
- for path in ["SCSI::SCSI4.$.Anwendung",
- "PythonApp:Lib",
- "PythonApp:Lib.rourl2path/py"]:
- print '%r -> %r' % (path, pathname2url(path))
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/plat-sunos5/IN.py b/Lib/plat-sunos5/IN.py
index 867b9eb5f8e..9572ead8a22 100644
--- a/Lib/plat-sunos5/IN.py
+++ b/Lib/plat-sunos5/IN.py
@@ -42,7 +42,7 @@ _LARGEFILE64_SOURCE = 1
_LARGEFILE_SOURCE = 1
_FILE_OFFSET_BITS = 64
_FILE_OFFSET_BITS = 32
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_POSIX_PTHREAD_SEMANTICS = 1
_XOPEN_VERSION = 500
_XOPEN_VERSION = 4
@@ -95,10 +95,10 @@ NGROUPS_UMIN = 0
NGROUPS_UMAX = 32
NGROUPS_MAX_DEFAULT = 16
NZERO = 20
-NULL = 0L
NULL = 0
-CMASK = 022
-CDLIMIT = (1L<<11)
+NULL = 0
+CMASK = 0o22
+CDLIMIT = (1<<11)
NBPS = 0x20000
NBPSCTR = 512
UBSIZE = 512
@@ -117,9 +117,9 @@ DEV_BSIZE = 512
DEV_BSHIFT = 9
MAXFRAG = 8
MAXOFF32_T = 0x7fffffff
-MAXOFF_T = 0x7fffffffffffffffl
-MAXOFFSET_T = 0x7fffffffffffffffl
-MAXOFF_T = 0x7fffffffl
+MAXOFF_T = 0x7fffffffffffffff
+MAXOFFSET_T = 0x7fffffffffffffff
+MAXOFF_T = 0x7fffffff
MAXOFFSET_T = 0x7fffffff
def btodb(bytes): return \
@@ -312,9 +312,9 @@ _PC_PRIO_IO = 11
_PC_SYNC_IO = 12
_PC_FILESIZEBITS = 67
_PC_LAST = 67
-_POSIX_VERSION = 199506L
-_POSIX2_VERSION = 199209L
-_POSIX2_C_VERSION = 199209L
+_POSIX_VERSION = 199506
+_POSIX2_VERSION = 199209
+_POSIX2_C_VERSION = 199209
_XOPEN_XCU_VERSION = 4
_XOPEN_REALTIME = 1
_XOPEN_ENH_I18N = 1
@@ -431,7 +431,7 @@ def TIMESTRUC_TO_TICK(tsp): return \
from TYPES import *
# Included from iso/time_iso.h
-NULL = 0L
+NULL = 0
NULL = 0
CLOCKS_PER_SEC = 1000000
@@ -733,13 +733,13 @@ _SPARC_MAXREGWINDOW = 31
_XRS_ID = 0x78727300
GETCONTEXT = 0
SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
+UC_SIGMASK = 0o01
+UC_STACK = 0o02
+UC_CPU = 0o04
+UC_MAU = 0o10
UC_FPU = UC_MAU
-UC_INTR = 020
-UC_ASR = 040
+UC_INTR = 0o20
+UC_ASR = 0o40
UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR)
UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
_SIGQUEUE_MAX = 32
@@ -869,9 +869,9 @@ RLIMIT_NOFILE = 5
RLIMIT_VMEM = 6
RLIMIT_AS = RLIMIT_VMEM
RLIM_NLIMITS = 7
-RLIM_INFINITY = (-3l)
-RLIM_SAVED_MAX = (-2l)
-RLIM_SAVED_CUR = (-1l)
+RLIM_INFINITY = (-3)
+RLIM_SAVED_MAX = (-2)
+RLIM_SAVED_CUR = (-1)
RLIM_INFINITY = 0x7fffffff
RLIM_SAVED_MAX = 0x7ffffffe
RLIM_SAVED_CUR = 0x7ffffffd
@@ -1021,14 +1021,14 @@ AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME)
AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_VCODE)
-VSUID = 04000
-VSGID = 02000
-VSVTX = 01000
-VREAD = 00400
-VWRITE = 00200
-VEXEC = 00100
-MODEMASK = 07777
-PERMMASK = 00777
+VSUID = 0o4000
+VSGID = 0o2000
+VSVTX = 0o1000
+VREAD = 0o0400
+VWRITE = 0o0200
+VEXEC = 0o0100
+MODEMASK = 0o7777
+PERMMASK = 0o0777
def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
VSA_ACL = 0x0001
@@ -1063,7 +1063,7 @@ POLLNOERR = 0x0400
POLLCLOSED = 0x8000
# Included from sys/strmdep.h
-def str_aligned(X): return (((ulong_t)(X) & (sizeof (long) - 1)) == 0)
+def str_aligned(X): return (((ulong_t)(X) & (sizeof (int) - 1)) == 0)
# Included from sys/strft.h
diff --git a/Lib/plat-sunos5/STROPTS.py b/Lib/plat-sunos5/STROPTS.py
index 4970bd722d7..8f735c4f846 100644
--- a/Lib/plat-sunos5/STROPTS.py
+++ b/Lib/plat-sunos5/STROPTS.py
@@ -42,7 +42,7 @@ _LARGEFILE64_SOURCE = 1
_LARGEFILE_SOURCE = 1
_FILE_OFFSET_BITS = 64
_FILE_OFFSET_BITS = 32
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_POSIX_PTHREAD_SEMANTICS = 1
_XOPEN_VERSION = 500
_XOPEN_VERSION = 4
@@ -92,10 +92,10 @@ NGROUPS_UMIN = 0
NGROUPS_UMAX = 32
NGROUPS_MAX_DEFAULT = 16
NZERO = 20
-NULL = 0L
NULL = 0
-CMASK = 022
-CDLIMIT = (1L<<11)
+NULL = 0
+CMASK = 0o22
+CDLIMIT = (1<<11)
NBPS = 0x20000
NBPSCTR = 512
UBSIZE = 512
@@ -114,9 +114,9 @@ DEV_BSIZE = 512
DEV_BSHIFT = 9
MAXFRAG = 8
MAXOFF32_T = 0x7fffffff
-MAXOFF_T = 0x7fffffffffffffffl
-MAXOFFSET_T = 0x7fffffffffffffffl
-MAXOFF_T = 0x7fffffffl
+MAXOFF_T = 0x7fffffffffffffff
+MAXOFFSET_T = 0x7fffffffffffffff
+MAXOFF_T = 0x7fffffff
MAXOFFSET_T = 0x7fffffff
def btodb(bytes): return \
@@ -309,9 +309,9 @@ _PC_PRIO_IO = 11
_PC_SYNC_IO = 12
_PC_FILESIZEBITS = 67
_PC_LAST = 67
-_POSIX_VERSION = 199506L
-_POSIX2_VERSION = 199209L
-_POSIX2_C_VERSION = 199209L
+_POSIX_VERSION = 199506
+_POSIX2_VERSION = 199209
+_POSIX2_C_VERSION = 199209
_XOPEN_XCU_VERSION = 4
_XOPEN_REALTIME = 1
_XOPEN_ENH_I18N = 1
@@ -428,7 +428,7 @@ def TIMESTRUC_TO_TICK(tsp): return \
from TYPES import *
# Included from iso/time_iso.h
-NULL = 0L
+NULL = 0
NULL = 0
CLOCKS_PER_SEC = 1000000
@@ -730,13 +730,13 @@ _SPARC_MAXREGWINDOW = 31
_XRS_ID = 0x78727300
GETCONTEXT = 0
SETCONTEXT = 1
-UC_SIGMASK = 001
-UC_STACK = 002
-UC_CPU = 004
-UC_MAU = 010
+UC_SIGMASK = 0o01
+UC_STACK = 0o02
+UC_CPU = 0o04
+UC_MAU = 0o10
UC_FPU = UC_MAU
-UC_INTR = 020
-UC_ASR = 040
+UC_INTR = 0o20
+UC_ASR = 0o40
UC_MCONTEXT = (UC_CPU|UC_FPU|UC_ASR)
UC_ALL = (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
_SIGQUEUE_MAX = 32
@@ -872,9 +872,9 @@ RLIMIT_NOFILE = 5
RLIMIT_VMEM = 6
RLIMIT_AS = RLIMIT_VMEM
RLIM_NLIMITS = 7
-RLIM_INFINITY = (-3l)
-RLIM_SAVED_MAX = (-2l)
-RLIM_SAVED_CUR = (-1l)
+RLIM_INFINITY = (-3)
+RLIM_SAVED_MAX = (-2)
+RLIM_SAVED_CUR = (-1)
RLIM_INFINITY = 0x7fffffff
RLIM_SAVED_MAX = 0x7ffffffe
RLIM_SAVED_CUR = 0x7ffffffd
@@ -1400,14 +1400,14 @@ AT_STAT = (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
AT_TIMES = (AT_ATIME|AT_MTIME|AT_CTIME)
AT_NOSET = (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
AT_BLKSIZE|AT_NBLOCKS|AT_VCODE)
-VSUID = 04000
-VSGID = 02000
-VSVTX = 01000
-VREAD = 00400
-VWRITE = 00200
-VEXEC = 00100
-MODEMASK = 07777
-PERMMASK = 00777
+VSUID = 0o4000
+VSGID = 0o2000
+VSVTX = 0o1000
+VREAD = 0o0400
+VWRITE = 0o0200
+VEXEC = 0o0100
+MODEMASK = 0o7777
+PERMMASK = 0o0777
def MANDMODE(mode): return (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
VSA_ACL = 0x0001
diff --git a/Lib/plat-sunos5/SUNAUDIODEV.py b/Lib/plat-sunos5/SUNAUDIODEV.py
deleted file mode 100644
index 25599bb882b..00000000000
--- a/Lib/plat-sunos5/SUNAUDIODEV.py
+++ /dev/null
@@ -1,43 +0,0 @@
-# Symbolic constants for use with sunaudiodev module
-# The names are the same as in audioio.h with the leading AUDIO_
-# removed.
-from warnings import warnpy3k
-warnpy3k("the SUNAUDIODEV module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Not all values are supported on all releases of SunOS.
-
-# Encoding types, for fields i_encoding and o_encoding
-
-ENCODING_NONE = 0 # no encoding assigned
-ENCODING_ULAW = 1 # u-law encoding
-ENCODING_ALAW = 2 # A-law encoding
-ENCODING_LINEAR = 3 # Linear PCM encoding
-
-# Gain ranges for i_gain, o_gain and monitor_gain
-
-MIN_GAIN = 0 # minimum gain value
-MAX_GAIN = 255 # maximum gain value
-
-# Balance values for i_balance and o_balance
-
-LEFT_BALANCE = 0 # left channel only
-MID_BALANCE = 32 # equal left/right channel
-RIGHT_BALANCE = 64 # right channel only
-BALANCE_SHIFT = 3
-
-# Port names for i_port and o_port
-
-PORT_A = 1
-PORT_B = 2
-PORT_C = 3
-PORT_D = 4
-
-SPEAKER = 0x01 # output to built-in speaker
-HEADPHONE = 0x02 # output to headphone jack
-LINE_OUT = 0x04 # output to line out
-
-MICROPHONE = 0x01 # input from microphone
-LINE_IN = 0x02 # input from line in
-CD = 0x04 # input from on-board CD inputs
-INTERNAL_CD_IN = CD # input from internal CDROM
diff --git a/Lib/plat-sunos5/TYPES.py b/Lib/plat-sunos5/TYPES.py
index e8e4a0074f6..da4e6b17865 100644
--- a/Lib/plat-sunos5/TYPES.py
+++ b/Lib/plat-sunos5/TYPES.py
@@ -42,7 +42,7 @@ _LARGEFILE64_SOURCE = 1
_LARGEFILE_SOURCE = 1
_FILE_OFFSET_BITS = 64
_FILE_OFFSET_BITS = 32
-_POSIX_C_SOURCE = 199506L
+_POSIX_C_SOURCE = 199506
_POSIX_PTHREAD_SEMANTICS = 1
_XOPEN_VERSION = 500
_XOPEN_VERSION = 4
@@ -216,10 +216,10 @@ SHRT_MAX = 32767
USHRT_MAX = 65535
INT_MIN = (-2147483647-1)
INT_MAX = 2147483647
-LONG_MIN = (-9223372036854775807L-1L)
-LONG_MAX = 9223372036854775807L
-LONG_MIN = (-2147483647L-1L)
-LONG_MAX = 2147483647L
+LONG_MIN = (-9223372036854775807-1)
+LONG_MAX = 9223372036854775807
+LONG_MIN = (-2147483647-1)
+LONG_MAX = 2147483647
P_MYID = (-1)
# Included from sys/select.h
@@ -303,7 +303,7 @@ def TIMESTRUC_TO_TICK(tsp): return \
from TYPES import *
# Included from iso/time_iso.h
-NULL = 0L
+NULL = 0
NULL = 0
CLOCKS_PER_SEC = 1000000
FD_SETSIZE = 65536
diff --git a/Lib/plat-unixware7/IN.py b/Lib/plat-unixware7/IN.py
index d66ae970c5f..af023b4f2d6 100644
--- a/Lib/plat-unixware7/IN.py
+++ b/Lib/plat-unixware7/IN.py
@@ -1,33 +1,33 @@
# Generated by h2py from /usr/include/netinet/in.h
# Included from netinet/in_f.h
-def IN_CLASSA(i): return (((long)(i) & 0x80000000) == 0)
+def IN_CLASSA(i): return (((int)(i) & 0x80000000) == 0)
IN_CLASSA_NET = 0xff000000
IN_CLASSA_NSHIFT = 24
IN_CLASSA_HOST = 0x00ffffff
IN_CLASSA_MAX = 128
-def IN_CLASSB(i): return (((long)(i) & 0xc0000000) == 0x80000000)
+def IN_CLASSB(i): return (((int)(i) & 0xc0000000) == 0x80000000)
IN_CLASSB_NET = 0xffff0000
IN_CLASSB_NSHIFT = 16
IN_CLASSB_HOST = 0x0000ffff
IN_CLASSB_MAX = 65536
-def IN_CLASSC(i): return (((long)(i) & 0xe0000000) == 0xc0000000)
+def IN_CLASSC(i): return (((int)(i) & 0xe0000000) == 0xc0000000)
IN_CLASSC_NET = 0xffffff00
IN_CLASSC_NSHIFT = 8
IN_CLASSC_HOST = 0x000000ff
-def IN_CLASSD(i): return (((long)(i) & 0xf0000000) == 0xe0000000)
+def IN_CLASSD(i): return (((int)(i) & 0xf0000000) == 0xe0000000)
IN_CLASSD_NET = 0xf0000000
IN_CLASSD_NSHIFT = 28
IN_CLASSD_HOST = 0x0fffffff
def IN_MULTICAST(i): return IN_CLASSD(i)
-def IN_EXPERIMENTAL(i): return (((long)(i) & 0xe0000000) == 0xe0000000)
+def IN_EXPERIMENTAL(i): return (((int)(i) & 0xe0000000) == 0xe0000000)
-def IN_BADCLASS(i): return (((long)(i) & 0xf0000000) == 0xf0000000)
+def IN_BADCLASS(i): return (((int)(i) & 0xf0000000) == 0xf0000000)
INADDR_ANY = 0x00000000
INADDR_LOOPBACK = 0x7f000001
@@ -187,8 +187,8 @@ NC_TPI_COTS = 2
NC_TPI_COTS_ORD = 3
NC_TPI_RAW = 4
NC_NOFLAG = 00
-NC_VISIBLE = 01
-NC_BROADCAST = 02
+NC_VISIBLE = 0o1
+NC_BROADCAST = 0o2
NC_NOPROTOFMLY = "-"
NC_LOOPBACK = "loopback"
NC_INET = "inet"
@@ -330,7 +330,7 @@ MSG_TRUNC = 0x10
MSG_EOR = 0x30
MSG_WAITALL = 0x20
MSG_MAXIOVLEN = 16
-def OPTLEN(x): return ((((x) + sizeof(long) - 1) / sizeof(long)) * sizeof(long))
+def OPTLEN(x): return ((((x) + sizeof(int) - 1) / sizeof(int)) * sizeof(int))
GIARG = 0x1
CONTI = 0x2
@@ -715,7 +715,7 @@ FLUSHDATA = 0
STRHIGH = 5120
STRLOW = 1024
MAXIOCBSZ = 1024
-def straln(a): return (caddr_t)((long)(a) & ~(sizeof(int)-1))
+def straln(a): return (caddr_t)((int)(a) & ~(sizeof(int)-1))
IPM_ID = 200
ICMPM_ID = 201
diff --git a/Lib/plat-unixware7/STROPTS.py b/Lib/plat-unixware7/STROPTS.py
index 0f0cb251690..ef50a9cb2b7 100644
--- a/Lib/plat-unixware7/STROPTS.py
+++ b/Lib/plat-unixware7/STROPTS.py
@@ -65,41 +65,41 @@ ES_PRVSETS = 6
ES_MACADTLID = 7
ES_PRVID = 8
ES_TPGETMAJOR = 9
-SA_EXEC = 001
-SA_WRITE = 002
-SA_READ = 004
-SA_SUBSIZE = 010
+SA_EXEC = 0o01
+SA_WRITE = 0o02
+SA_READ = 0o04
+SA_SUBSIZE = 0o10
# Included from sys/stropts_f.h
X_STR = (ord('S')<<8)
-X_I_BASE = (X_STR|0200)
-X_I_NREAD = (X_STR|0201)
-X_I_PUSH = (X_STR|0202)
-X_I_POP = (X_STR|0203)
-X_I_LOOK = (X_STR|0204)
-X_I_FLUSH = (X_STR|0205)
-X_I_SRDOPT = (X_STR|0206)
-X_I_GRDOPT = (X_STR|0207)
-X_I_STR = (X_STR|0210)
-X_I_SETSIG = (X_STR|0211)
-X_I_GETSIG = (X_STR|0212)
-X_I_FIND = (X_STR|0213)
-X_I_LINK = (X_STR|0214)
-X_I_UNLINK = (X_STR|0215)
-X_I_PEEK = (X_STR|0217)
-X_I_FDINSERT = (X_STR|0220)
-X_I_SENDFD = (X_STR|0221)
-X_I_RECVFD = (X_STR|0222)
+X_I_BASE = (X_STR|0o200)
+X_I_NREAD = (X_STR|0o201)
+X_I_PUSH = (X_STR|0o202)
+X_I_POP = (X_STR|0o203)
+X_I_LOOK = (X_STR|0o204)
+X_I_FLUSH = (X_STR|0o205)
+X_I_SRDOPT = (X_STR|0o206)
+X_I_GRDOPT = (X_STR|0o207)
+X_I_STR = (X_STR|0o210)
+X_I_SETSIG = (X_STR|0o211)
+X_I_GETSIG = (X_STR|0o212)
+X_I_FIND = (X_STR|0o213)
+X_I_LINK = (X_STR|0o214)
+X_I_UNLINK = (X_STR|0o215)
+X_I_PEEK = (X_STR|0o217)
+X_I_FDINSERT = (X_STR|0o220)
+X_I_SENDFD = (X_STR|0o221)
+X_I_RECVFD = (X_STR|0o222)
# Included from unistd.h
# Included from sys/unistd.h
-R_OK = 004
-W_OK = 002
-X_OK = 001
+R_OK = 0o04
+W_OK = 0o02
+X_OK = 0o01
F_OK = 000
-EFF_ONLY_OK = 010
-EX_OK = 020
+EFF_ONLY_OK = 0o10
+EX_OK = 0o20
SEEK_SET = 0
SEEK_CUR = 1
SEEK_END = 2
@@ -213,7 +213,7 @@ _PC_NO_TRUNC = 7
_PC_VDISABLE = 8
_PC_CHOWN_RESTRICTED = 9
_PC_FILESIZEBITS = 10
-_POSIX_VERSION = 199009L
+_POSIX_VERSION = 199009
_XOPEN_VERSION = 4
GF_PATH = "/etc/group"
PF_PATH = "/etc/passwd"
@@ -231,8 +231,8 @@ STDERR_FILENO = 2
_XOPEN_UNIX = 1
_XOPEN_ENH_I18N = 1
_XOPEN_XPG4 = 1
-_POSIX2_C_VERSION = 199209L
-_POSIX2_VERSION = 199209L
+_POSIX2_C_VERSION = 199209
+_POSIX2_VERSION = 199209
_XOPEN_XCU_VERSION = 4
_POSIX_SEMAPHORES = 1
_POSIX_THREADS = 1
@@ -289,40 +289,40 @@ MUXID_ALL = (-1)
ANYMARK = 0x01
LASTMARK = 0x02
STR = (ord('S')<<8)
-I_NREAD = (STR|01)
-I_PUSH = (STR|02)
-I_POP = (STR|03)
-I_LOOK = (STR|04)
-I_FLUSH = (STR|05)
-I_SRDOPT = (STR|06)
-I_GRDOPT = (STR|07)
-I_STR = (STR|010)
-I_SETSIG = (STR|011)
-I_GETSIG = (STR|012)
-I_FIND = (STR|013)
-I_LINK = (STR|014)
-I_UNLINK = (STR|015)
-I_PEEK = (STR|017)
-I_FDINSERT = (STR|020)
-I_SENDFD = (STR|021)
-I_RECVFD = (STR|022)
-I_E_RECVFD = (STR|016)
-I_RECVFD = (STR|016)
-I_RECVFD = (STR|022)
-I_SWROPT = (STR|023)
-I_GWROPT = (STR|024)
-I_LIST = (STR|025)
-I_PLINK = (STR|026)
-I_PUNLINK = (STR|027)
-I_FLUSHBAND = (STR|034)
-I_CKBAND = (STR|035)
-I_GETBAND = (STR|036)
-I_ATMARK = (STR|037)
-I_SETCLTIME = (STR|040)
-I_GETCLTIME = (STR|041)
-I_CANPUT = (STR|042)
-I_S_RECVFD = (STR|043)
-I_STATS = (STR|044)
-I_BIGPIPE = (STR|045)
-I_GETTP = (STR|046)
+I_NREAD = (STR|0o1)
+I_PUSH = (STR|0o2)
+I_POP = (STR|0o3)
+I_LOOK = (STR|0o4)
+I_FLUSH = (STR|0o5)
+I_SRDOPT = (STR|0o6)
+I_GRDOPT = (STR|0o7)
+I_STR = (STR|0o10)
+I_SETSIG = (STR|0o11)
+I_GETSIG = (STR|0o12)
+I_FIND = (STR|0o13)
+I_LINK = (STR|0o14)
+I_UNLINK = (STR|0o15)
+I_PEEK = (STR|0o17)
+I_FDINSERT = (STR|0o20)
+I_SENDFD = (STR|0o21)
+I_RECVFD = (STR|0o22)
+I_E_RECVFD = (STR|0o16)
+I_RECVFD = (STR|0o16)
+I_RECVFD = (STR|0o22)
+I_SWROPT = (STR|0o23)
+I_GWROPT = (STR|0o24)
+I_LIST = (STR|0o25)
+I_PLINK = (STR|0o26)
+I_PUNLINK = (STR|0o27)
+I_FLUSHBAND = (STR|0o34)
+I_CKBAND = (STR|0o35)
+I_GETBAND = (STR|0o36)
+I_ATMARK = (STR|0o37)
+I_SETCLTIME = (STR|0o40)
+I_GETCLTIME = (STR|0o41)
+I_CANPUT = (STR|0o42)
+I_S_RECVFD = (STR|0o43)
+I_STATS = (STR|0o44)
+I_BIGPIPE = (STR|0o45)
+I_GETTP = (STR|0o46)
INFTIM = -1
diff --git a/Lib/platform.py b/Lib/platform.py
index c0016a8198c..686a0458453 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
""" This module tries to retrieve as much platform-identifying data as
possible. It makes this information available via function APIs.
@@ -12,8 +12,6 @@
# If you find problems, please submit bug reports/patches via the
# Python bug tracker (http://bugs.python.org) and assign them to "lemburg".
#
-# Note: Please keep this module compatible to Python 1.5.2.
-#
# Still needed:
# * more support for WinCE
# * support for MS-DOS (PythonDX ?)
@@ -113,7 +111,7 @@ __copyright__ = """
__version__ = '1.0.7'
-import sys,string,os,re
+import sys, os, re, subprocess
### Globals & Constants
@@ -136,7 +134,7 @@ _libc_search = re.compile(r'(__libc_init)'
'|'
'(GLIBC_([0-9.]+))'
'|'
- '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)')
+ '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)', re.ASCII)
def libc_ver(executable=sys.executable,lib='',version='',
@@ -161,12 +159,12 @@ def libc_ver(executable=sys.executable,lib='',version='',
# able to open symlinks for reading
executable = os.path.realpath(executable)
f = open(executable,'rb')
- binary = f.read(chunksize)
+ binary = f.read(chunksize).decode('latin-1')
pos = 0
while 1:
m = _libc_search.search(binary,pos)
if not m:
- binary = f.read(chunksize)
+ binary = f.read(chunksize).decode('latin-1')
if not binary:
break
pos = 0
@@ -202,26 +200,24 @@ def _dist_try_harder(distname,version,id):
"""
if os.path.exists('/var/adm/inst-log/info'):
# SuSE Linux stores distribution information in that file
- info = open('/var/adm/inst-log/info').readlines()
distname = 'SuSE'
- for line in info:
- tv = string.split(line)
+ for line in open('/var/adm/inst-log/info'):
+ tv = line.split()
if len(tv) == 2:
tag,value = tv
else:
continue
if tag == 'MIN_DIST_VERSION':
- version = string.strip(value)
+ version = value.strip()
elif tag == 'DIST_IDENT':
- values = string.split(value,'-')
+ values = value.split('-')
id = values[2]
return distname,version,id
if os.path.exists('/etc/.installed'):
# Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
- info = open('/etc/.installed').readlines()
- for line in info:
- pkg = string.split(line,'-')
+ for line in open('/etc/.installed'):
+ pkg = line.split('-')
if len(pkg) >= 2 and pkg[0] == 'OpenLinux':
# XXX does Caldera support non Intel platforms ? If yes,
# where can we find the needed id ?
@@ -241,15 +237,15 @@ def _dist_try_harder(distname,version,id):
return distname,version,id
-_release_filename = re.compile(r'(\w+)[-_](release|version)')
+_release_filename = re.compile(r'(\w+)[-_](release|version)', re.ASCII)
_lsb_release_version = re.compile(r'(.+)'
' release '
'([\d.]+)'
- '[^(]*(?:\((.+)\))?')
+ '[^(]*(?:\((.+)\))?', re.ASCII)
_release_version = re.compile(r'([^0-9]+)'
'(?: release )?'
'([\d.]+)'
- '[^(]*(?:\((.+)\))?')
+ '[^(]*(?:\((.+)\))?', re.ASCII)
# See also http://www.novell.com/coolsolutions/feature/11251.html
# and http://linuxmafia.com/faq/Admin/release-files.html
@@ -281,7 +277,7 @@ def _parse_release_file(firstline):
return tuple(m.groups())
# Unkown format... take the first two words
- l = string.split(string.strip(firstline))
+ l = firstline.strip().split()
if l:
version = l[0]
if len(l) > 1:
@@ -329,9 +325,8 @@ def linux_distribution(distname='', version='', id='',
return _dist_try_harder(distname,version,id)
# Read the first line
- f = open('/etc/'+file, 'r')
- firstline = f.readline()
- f.close()
+ with open('/etc/'+file, 'r') as f:
+ firstline = f.readline()
_distname, _version, _id = _parse_release_file(firstline)
if _distname and full_distribution_name:
@@ -381,7 +376,7 @@ class _popen:
def __init__(self,cmd,mode='r',bufsize=None):
if mode != 'r':
- raise ValueError,'popen()-emulation only supports read mode'
+ raise ValueError('popen()-emulation only supports read mode')
import tempfile
self.tmpfile = tmpfile = tempfile.mktemp()
os.system(cmd + ' > %s' % tmpfile)
@@ -416,7 +411,7 @@ class _popen:
# Alias
__del__ = close
-def popen(cmd, mode='r', bufsize=None):
+def popen(cmd, mode='r', bufsize=-1):
""" Portable popen() interface.
"""
@@ -454,7 +449,7 @@ def _norm_version(version, build=''):
""" Normalize the version and build strings and return a single
version string using the format major.minor.build (or patchlevel).
"""
- l = string.split(version,'.')
+ l = version.split('.')
if build:
l.append(build)
try:
@@ -462,8 +457,8 @@ def _norm_version(version, build=''):
except ValueError:
strings = l
else:
- strings = map(str,ints)
- version = string.join(strings[:3],'.')
+ strings = list(map(str,ints))
+ version = '.'.join(strings[:3])
return version
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
@@ -502,13 +497,13 @@ def _syscmd_ver(system='', release='', version='',
pipe = popen(cmd)
info = pipe.read()
if pipe.close():
- raise os.error,'command failed'
+ raise os.error('command failed')
# XXX How can I suppress shell errors from being written
# to stderr ?
- except os.error,why:
+ except os.error as why:
#print 'Command %s failed: %s' % (cmd,why)
continue
- except IOError,why:
+ except IOError as why:
#print 'Command %s failed: %s' % (cmd,why)
continue
else:
@@ -517,7 +512,7 @@ def _syscmd_ver(system='', release='', version='',
return system,release,version
# Parse the output
- info = string.strip(info)
+ info = info.strip()
m = _ver_output.match(info)
if m is not None:
system,release,version = m.groups()
@@ -542,9 +537,9 @@ def _win32_getvalue(key,name,default=''):
# Use win32api if available
from win32api import RegQueryValueEx
except ImportError:
- # On Python 2.0 and later, emulate using _winreg
- import _winreg
- RegQueryValueEx = _winreg.QueryValueEx
+ # On Python 2.0 and later, emulate using winreg
+ import winreg
+ RegQueryValueEx = winreg.QueryValueEx
try:
return RegQueryValueEx(key,name)
except:
@@ -592,14 +587,14 @@ def win32_ver(release='',version='',csd='',ptype=''):
# No emulation possible, so return the defaults...
return release,version,csd,ptype
else:
- # Emulation using _winreg (added in Python 2.0) and
+ # Emulation using winreg (added in Python 2.0) and
# sys.getwindowsversion() (added in Python 2.3)
- import _winreg
+ import winreg
GetVersionEx = sys.getwindowsversion
- RegQueryValueEx = _winreg.QueryValueEx
- RegOpenKeyEx = _winreg.OpenKeyEx
- RegCloseKey = _winreg.CloseKey
- HKEY_LOCAL_MACHINE = _winreg.HKEY_LOCAL_MACHINE
+ RegQueryValueEx = winreg.QueryValueEx
+ RegOpenKeyEx = winreg.OpenKeyEx
+ RegCloseKey = winreg.CloseKey
+ HKEY_LOCAL_MACHINE = winreg.HKEY_LOCAL_MACHINE
VER_PLATFORM_WIN32_WINDOWS = 1
VER_PLATFORM_WIN32_NT = 2
VER_NT_WORKSTATION = 1
@@ -717,14 +712,13 @@ def win32_ver(release='',version='',csd='',ptype=''):
def _mac_ver_lookup(selectors,default=None):
- from gestalt import gestalt
- import MacOS
+ from _gestalt import gestalt
l = []
append = l.append
for selector in selectors:
try:
append(gestalt(selector))
- except (RuntimeError, MacOS.Error):
+ except (RuntimeError, OSError):
append(default)
return l
@@ -742,12 +736,11 @@ def _mac_ver_gestalt():
"""
# Check whether the version info module is available
try:
- import gestalt
- import MacOS
+ import _gestalt
except ImportError:
return None
# Get the infos
- sysv,sysa = _mac_ver_lookup(('sysv','sysa'))
+ sysv, sysa = _mac_ver_lookup(('sysv','sysa'))
# Decode the infos
if sysv:
major = (sysv & 0xFF00) >> 8
@@ -885,7 +878,7 @@ def system_alias(system,release,version):
# These releases use the old name SunOS
return system,release,version
# Modify release (marketing release = SunOS release - 3)
- l = string.split(release,'.')
+ l = release.split('.')
if l:
try:
major = int(l[0])
@@ -894,7 +887,7 @@ def system_alias(system,release,version):
else:
major = major - 3
l[0] = str(major)
- release = string.join(l,'.')
+ release = '.'.join(l)
if release < '6':
system = 'Solaris'
else:
@@ -925,28 +918,24 @@ def _platform(*args):
compatible format e.g. "system-version-machine".
"""
# Format the platform string
- platform = string.join(
- map(string.strip,
- filter(len, args)),
- '-')
+ platform = '-'.join(x.strip() for x in filter(len, args))
# Cleanup some possible filename obstacles...
- replace = string.replace
- platform = replace(platform,' ','_')
- platform = replace(platform,'/','-')
- platform = replace(platform,'\\','-')
- platform = replace(platform,':','-')
- platform = replace(platform,';','-')
- platform = replace(platform,'"','-')
- platform = replace(platform,'(','-')
- platform = replace(platform,')','-')
+ platform = platform.replace(' ','_')
+ platform = platform.replace('/','-')
+ platform = platform.replace('\\','-')
+ platform = platform.replace(':','-')
+ platform = platform.replace(';','-')
+ platform = platform.replace('"','-')
+ platform = platform.replace('(','-')
+ platform = platform.replace(')','-')
# No need to report 'unknown' information...
- platform = replace(platform,'unknown','')
+ platform = platform.replace('unknown','')
# Fold '--'s and remove trailing '-'
while 1:
- cleaned = replace(platform,'--','-')
+ cleaned = platform.replace('--','-')
if cleaned == platform:
break
platform = cleaned
@@ -970,28 +959,12 @@ def _node(default=''):
# Still not working...
return default
-# os.path.abspath is new in Python 1.5.2:
-if not hasattr(os.path,'abspath'):
-
- def _abspath(path,
-
- isabs=os.path.isabs,join=os.path.join,getcwd=os.getcwd,
- normpath=os.path.normpath):
-
- if not isabs(path):
- path = join(getcwd(), path)
- return normpath(path)
-
-else:
-
- _abspath = os.path.abspath
-
def _follow_symlinks(filepath):
""" In case filepath is a symlink, follow it until a
real file is reached.
"""
- filepath = _abspath(filepath)
+ filepath = os.path.abspath(filepath)
while os.path.islink(filepath):
filepath = os.path.normpath(
os.path.join(os.path.dirname(filepath),os.readlink(filepath)))
@@ -1008,7 +981,7 @@ def _syscmd_uname(option,default=''):
f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error):
return default
- output = string.strip(f.read())
+ output = f.read().strip()
rc = f.close()
if not output or rc:
return default
@@ -1020,31 +993,10 @@ def _syscmd_file(target,default=''):
""" Interface to the system's file command.
The function uses the -b option of the file command to have it
- ommit the filename in its output and if possible the -L option
- to have the command follow symlinks. It returns default in
- case the command should fail.
+ omit the filename in its output. Follow the symlinks. It returns
+ default in case the command should fail.
"""
-
- # We do the import here to avoid a bootstrap issue.
- # See c73b90b6dadd changeset.
- #
- # [..]
- # ranlib libpython2.7.a
- # gcc -o python \
- # Modules/python.o \
- # libpython2.7.a -lsocket -lnsl -ldl -lm
- # Traceback (most recent call last):
- # File "./setup.py", line 8, in <module>
- # from platform import machine as platform_machine
- # File "[..]/build/Lib/platform.py", line 116, in <module>
- # import sys,string,os,re,subprocess
- # File "[..]/build/Lib/subprocess.py", line 429, in <module>
- # import select
- # ImportError: No module named select
-
- import subprocess
-
if sys.platform in ('dos','win32','win16','os2'):
# XXX Others too ?
return default
@@ -1052,10 +1004,9 @@ def _syscmd_file(target,default=''):
try:
proc = subprocess.Popen(['file', target],
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-
except (AttributeError,os.error):
return default
- output = proc.communicate()[0]
+ output = proc.communicate()[0].decode("latin-1")
rc = proc.wait()
if not output or rc:
return default
@@ -1072,8 +1023,6 @@ _default_architecture = {
'dos': ('','MSDOS'),
}
-_architecture_split = re.compile(r'[\s,]').split
-
def architecture(executable=sys.executable,bits='',linkage=''):
""" Queries the given executable (defaults to the Python interpreter
@@ -1108,24 +1057,21 @@ def architecture(executable=sys.executable,bits='',linkage=''):
# Get data from the 'file' system command
if executable:
- output = _syscmd_file(executable, '')
+ fileout = _syscmd_file(executable, '')
else:
- output = ''
+ fileout = ''
- if not output and \
+ if not fileout and \
executable == sys.executable:
# "file" command did not return anything; we'll try to provide
# some sensible defaults then...
if sys.platform in _default_architecture:
- b, l = _default_architecture[sys.platform]
+ b,l = _default_architecture[sys.platform]
if b:
bits = b
if l:
linkage = l
- return bits, linkage
-
- # Split the output into a list of strings omitting the filename
- fileout = _architecture_split(output)[1:]
+ return bits,linkage
if 'executable' not in fileout:
# Format not supported
@@ -1189,7 +1135,7 @@ def uname():
except AttributeError:
no_os_uname = 1
- if no_os_uname or not filter(None, (system, node, release, version, machine)):
+ if no_os_uname or not list(filter(None, (system, node, release, version, machine))):
# Hmm, no there is either no uname or uname has returned
#'unknowns'... we'll have to poke around the system then.
if no_os_uname:
@@ -1251,7 +1197,7 @@ def uname():
elif system[:4] == 'java':
release,vendor,vminfo,osinfo = java_ver()
system = 'Java'
- version = string.join(vminfo,', ')
+ version = ', '.join(vminfo)
if not version:
version = vendor
@@ -1363,13 +1309,13 @@ def processor():
_sys_version_parser = re.compile(
r'([\w.+]+)\s*'
'\(#?([^,]+),\s*([\w ]+),\s*([\w :]+)\)\s*'
- '\[([^\]]+)\]?')
+ '\[([^\]]+)\]?', re.ASCII)
_ironpython_sys_version_parser = re.compile(
r'IronPython\s*'
'([\d\.]+)'
'(?: \(([\d\.]+)\))?'
- ' on (.NET [\d\.]+)')
+ ' on (.NET [\d\.]+)', re.ASCII)
_pypy_sys_version_parser = re.compile(
r'([\w.+]+)\s*'
@@ -1453,7 +1399,9 @@ def _sys_version(sys_version=None):
name = 'CPython'
builddate = builddate + ' ' + buildtime
- if hasattr(sys, 'subversion'):
+ if hasattr(sys, '_mercurial'):
+ _, branch, revision = sys._mercurial
+ elif hasattr(sys, 'subversion'):
# sys.subversion was added in Python 2.5
_, branch, revision = sys.subversion
else:
@@ -1461,10 +1409,10 @@ def _sys_version(sys_version=None):
revision = ''
# Add the patchlevel version if missing
- l = string.split(version, '.')
+ l = version.split('.')
if len(l) == 2:
l.append('0')
- version = string.join(l, '.')
+ version = '.'.join(l)
# Build and cache the result
result = (name, version, branch, revision, buildno, builddate, compiler)
@@ -1503,7 +1451,7 @@ def python_version_tuple():
will always include the patchlevel (it defaults to 0).
"""
- return tuple(string.split(_sys_version()[1], '.'))
+ return tuple(_sys_version()[1].split('.'))
def python_branch():
@@ -1638,5 +1586,5 @@ if __name__ == '__main__':
# Default is to print the aliased verbose platform string
terse = ('terse' in sys.argv or '--terse' in sys.argv)
aliased = (not 'nonaliased' in sys.argv and not '--nonaliased' in sys.argv)
- print platform(aliased,terse)
+ print(platform(aliased,terse))
sys.exit(0)
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index 51944eecb0f..2e7e5126d74 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -1,6 +1,6 @@
r"""plistlib.py -- a tool to generate and parse MacOSX .plist files.
-The PropertyList (.plist) file format is a simple XML pickle supporting
+The property list (.plist) file format is a simple XML pickle supporting
basic object types, like dictionaries, lists, numbers and strings.
Usually the top level object is a dictionary.
@@ -12,36 +12,35 @@ To parse a plist from a file, use the readPlist(pathOrFile) function,
with a file name or a (readable) file object as the only argument. It
returns the top level object (again, usually a dictionary).
-To work with plist data in strings, you can use readPlistFromString()
-and writePlistToString().
+To work with plist data in bytes objects, you can use readPlistFromBytes()
+and writePlistToBytes().
Values can be strings, integers, floats, booleans, tuples, lists,
-dictionaries, Data or datetime.datetime objects. String values (including
-dictionary keys) may be unicode strings -- they will be written out as
-UTF-8.
+dictionaries (but only with string keys), Data or datetime.datetime objects.
+String values (including dictionary keys) have to be unicode strings -- they
+will be written out as UTF-8.
The <data> plist type is supported through the Data class. This is a
-thin wrapper around a Python string.
+thin wrapper around a Python bytes object. Use 'Data' if your strings
+contain control characters.
Generate Plist example:
pl = dict(
- aString="Doodah",
- aList=["A", "B", 12, 32.1, [1, 2, 3]],
- aFloat=0.1,
- anInt=728,
- aDict=dict(
- anotherString="<hello & hi there!>",
- aUnicodeValue=u'M\xe4ssig, Ma\xdf',
- aTrueValue=True,
- aFalseValue=False,
+ aString = "Doodah",
+ aList = ["A", "B", 12, 32.1, [1, 2, 3]],
+ aFloat = 0.1,
+ anInt = 728,
+ aDict = dict(
+ anotherString = "<hello & hi there!>",
+ aUnicodeValue = "M\xe4ssig, Ma\xdf",
+ aTrueValue = True,
+ aFalseValue = False,
),
- someData=Data("<binary gunk>"),
- someMoreData=Data("<lots of binary gunk>" * 10),
- aDate=datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
+ someData = Data(b"<binary gunk>"),
+ someMoreData = Data(b"<lots of binary gunk>" * 10),
+ aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
)
- # unicode keys are possible, but a little awkward to use:
- pl[u'\xc5benraa'] = "That was a unicode key."
writePlist(pl, fileName)
Parse Plist example:
@@ -52,17 +51,15 @@ Parse Plist example:
__all__ = [
- "readPlist", "writePlist", "readPlistFromString", "writePlistToString",
- "readPlistFromResource", "writePlistToResource",
+ "readPlist", "writePlist", "readPlistFromBytes", "writePlistToBytes",
"Plist", "Data", "Dict"
]
# Note: the Plist and Dict classes have been deprecated.
import binascii
import datetime
-from cStringIO import StringIO
+from io import BytesIO
import re
-import warnings
def readPlist(pathOrFile):
@@ -70,14 +67,16 @@ def readPlist(pathOrFile):
(readable) file object. Return the unpacked root object (which
usually is a dictionary).
"""
- didOpen = 0
- if isinstance(pathOrFile, (str, unicode)):
- pathOrFile = open(pathOrFile)
- didOpen = 1
- p = PlistParser()
- rootObject = p.parse(pathOrFile)
- if didOpen:
- pathOrFile.close()
+ didOpen = False
+ try:
+ if isinstance(pathOrFile, str):
+ pathOrFile = open(pathOrFile, 'rb')
+ didOpen = True
+ p = PlistParser()
+ rootObject = p.parse(pathOrFile)
+ finally:
+ if didOpen:
+ pathOrFile.close()
return rootObject
@@ -85,71 +84,35 @@ def writePlist(rootObject, pathOrFile):
"""Write 'rootObject' to a .plist file. 'pathOrFile' may either be a
file name or a (writable) file object.
"""
- didOpen = 0
- if isinstance(pathOrFile, (str, unicode)):
- pathOrFile = open(pathOrFile, "w")
- didOpen = 1
- writer = PlistWriter(pathOrFile)
- writer.writeln("<plist version=\"1.0\">")
- writer.writeValue(rootObject)
- writer.writeln("</plist>")
- if didOpen:
- pathOrFile.close()
-
-
-def readPlistFromString(data):
- """Read a plist data from a string. Return the root object.
+ didOpen = False
+ try:
+ if isinstance(pathOrFile, str):
+ pathOrFile = open(pathOrFile, 'wb')
+ didOpen = True
+ writer = PlistWriter(pathOrFile)
+ writer.writeln("<plist version=\"1.0\">")
+ writer.writeValue(rootObject)
+ writer.writeln("</plist>")
+ finally:
+ if didOpen:
+ pathOrFile.close()
+
+
+def readPlistFromBytes(data):
+ """Read a plist data from a bytes object. Return the root object.
"""
- return readPlist(StringIO(data))
+ return readPlist(BytesIO(data))
-def writePlistToString(rootObject):
- """Return 'rootObject' as a plist-formatted string.
+def writePlistToBytes(rootObject):
+ """Return 'rootObject' as a plist-formatted bytes object.
"""
- f = StringIO()
+ f = BytesIO()
writePlist(rootObject, f)
return f.getvalue()
-def readPlistFromResource(path, restype='plst', resid=0):
- """Read plst resource from the resource fork of path.
- """
- warnings.warnpy3k("In 3.x, readPlistFromResource is removed.",
- stacklevel=2)
- from Carbon.File import FSRef, FSGetResourceForkName
- from Carbon.Files import fsRdPerm
- from Carbon import Res
- fsRef = FSRef(path)
- resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdPerm)
- Res.UseResFile(resNum)
- plistData = Res.Get1Resource(restype, resid).data
- Res.CloseResFile(resNum)
- return readPlistFromString(plistData)
-
-
-def writePlistToResource(rootObject, path, restype='plst', resid=0):
- """Write 'rootObject' as a plst resource to the resource fork of path.
- """
- warnings.warnpy3k("In 3.x, writePlistToResource is removed.", stacklevel=2)
- from Carbon.File import FSRef, FSGetResourceForkName
- from Carbon.Files import fsRdWrPerm
- from Carbon import Res
- plistData = writePlistToString(rootObject)
- fsRef = FSRef(path)
- resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdWrPerm)
- Res.UseResFile(resNum)
- try:
- Res.Get1Resource(restype, resid).RemoveResource()
- except Res.Error:
- pass
- res = Res.Resource(plistData)
- res.AddResource(restype, resid, '')
- res.WriteResource()
- Res.CloseResFile(resNum)
-
-
class DumbXMLWriter:
-
def __init__(self, file, indentLevel=0, indent="\t"):
self.file = file
self.stack = []
@@ -169,22 +132,25 @@ class DumbXMLWriter:
def simpleElement(self, element, value=None):
if value is not None:
- value = _escapeAndEncode(value)
+ value = _escape(value)
self.writeln("<%s>%s</%s>" % (element, value, element))
else:
self.writeln("<%s/>" % element)
def writeln(self, line):
if line:
- self.file.write(self.indentLevel * self.indent + line + "\n")
- else:
- self.file.write("\n")
+ # plist has fixed encoding of utf-8
+ if isinstance(line, str):
+ line = line.encode('utf-8')
+ self.file.write(self.indentLevel * self.indent)
+ self.file.write(line)
+ self.file.write(b'\n')
# Contents should conform to a subset of ISO 8601
# (in particular, YYYY '-' MM '-' DD 'T' HH ':' MM ':' SS 'Z'. Smaller units may be omitted with
# a loss of precision)
-_dateParser = re.compile(r"(?P<year>\d\d\d\d)(?:-(?P<month>\d\d)(?:-(?P<day>\d\d)(?:T(?P<hour>\d\d)(?::(?P<minute>\d\d)(?::(?P<second>\d\d))?)?)?)?)?Z")
+_dateParser = re.compile(r"(?P<year>\d\d\d\d)(?:-(?P<month>\d\d)(?:-(?P<day>\d\d)(?:T(?P<hour>\d\d)(?::(?P<minute>\d\d)(?::(?P<second>\d\d))?)?)?)?)?Z", re.ASCII)
def _dateFromString(s):
order = ('year', 'month', 'day', 'hour', 'minute', 'second')
@@ -209,7 +175,7 @@ _controlCharPat = re.compile(
r"[\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0b\x0c\x0e\x0f"
r"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f]")
-def _escapeAndEncode(text):
+def _escape(text):
m = _controlCharPat.search(text)
if m is not None:
raise ValueError("strings can't contains control characters; "
@@ -219,23 +185,23 @@ def _escapeAndEncode(text):
text = text.replace("&", "&amp;") # escape '&'
text = text.replace("<", "&lt;") # escape '<'
text = text.replace(">", "&gt;") # escape '>'
- return text.encode("utf-8") # encode as UTF-8
+ return text
-PLISTHEADER = """\
+PLISTHEADER = b"""\
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
"""
class PlistWriter(DumbXMLWriter):
- def __init__(self, file, indentLevel=0, indent="\t", writeHeader=1):
+ def __init__(self, file, indentLevel=0, indent=b"\t", writeHeader=1):
if writeHeader:
file.write(PLISTHEADER)
DumbXMLWriter.__init__(self, file, indentLevel, indent)
def writeValue(self, value):
- if isinstance(value, (str, unicode)):
+ if isinstance(value, str):
self.simpleElement("string", value)
elif isinstance(value, bool):
# must switch for bool before int, as bool is a
@@ -244,7 +210,7 @@ class PlistWriter(DumbXMLWriter):
self.simpleElement("true")
else:
self.simpleElement("false")
- elif isinstance(value, (int, long)):
+ elif isinstance(value, int):
self.simpleElement("integer", "%d" % value)
elif isinstance(value, float):
self.simpleElement("real", repr(value))
@@ -257,14 +223,14 @@ class PlistWriter(DumbXMLWriter):
elif isinstance(value, (tuple, list)):
self.writeArray(value)
else:
- raise TypeError("unsuported type: %s" % type(value))
+ raise TypeError("unsupported type: %s" % type(value))
def writeData(self, data):
self.beginElement("data")
self.indentLevel -= 1
- maxlinelength = 76 - len(self.indent.replace("\t", " " * 8) *
+ maxlinelength = 76 - len(self.indent.replace(b"\t", b" " * 8) *
self.indentLevel)
- for line in data.asBase64(maxlinelength).split("\n"):
+ for line in data.asBase64(maxlinelength).split(b"\n"):
if line:
self.writeln(line)
self.indentLevel += 1
@@ -272,10 +238,9 @@ class PlistWriter(DumbXMLWriter):
def writeDict(self, d):
self.beginElement("dict")
- items = d.items()
- items.sort()
+ items = sorted(d.items())
for key, value in items:
- if not isinstance(key, (str, unicode)):
+ if not isinstance(key, str):
raise TypeError("keys must be strings")
self.simpleElement("key", key)
self.writeValue(value)
@@ -298,7 +263,7 @@ class _InternalDict(dict):
try:
value = self[attr]
except KeyError:
- raise AttributeError, attr
+ raise AttributeError(attr)
from warnings import warn
warn("Attribute access from plist dicts is deprecated, use d[key] "
"notation instead", PendingDeprecationWarning, 2)
@@ -314,7 +279,7 @@ class _InternalDict(dict):
try:
del self[attr]
except KeyError:
- raise AttributeError, attr
+ raise AttributeError(attr)
from warnings import warn
warn("Attribute access from plist dicts is deprecated, use d[key] "
"notation instead", PendingDeprecationWarning, 2)
@@ -325,7 +290,7 @@ class Dict(_InternalDict):
from warnings import warn
warn("The plistlib.Dict class is deprecated, use builtin dict instead",
PendingDeprecationWarning, 2)
- super(Dict, self).__init__(**kwargs)
+ super().__init__(**kwargs)
class Plist(_InternalDict):
@@ -338,7 +303,7 @@ class Plist(_InternalDict):
from warnings import warn
warn("The Plist class is deprecated, use the readPlist() and "
"writePlist() functions instead", PendingDeprecationWarning, 2)
- super(Plist, self).__init__(**kwargs)
+ super().__init__(**kwargs)
def fromFile(cls, pathOrFile):
"""Deprecated. Use the readPlist() function instead."""
@@ -354,42 +319,43 @@ class Plist(_InternalDict):
def _encodeBase64(s, maxlinelength=76):
- # copied from base64.encodestring(), with added maxlinelength argument
+ # copied from base64.encodebytes(), with added maxlinelength argument
maxbinsize = (maxlinelength//4)*3
pieces = []
for i in range(0, len(s), maxbinsize):
chunk = s[i : i + maxbinsize]
pieces.append(binascii.b2a_base64(chunk))
- return "".join(pieces)
+ return b''.join(pieces)
class Data:
"""Wrapper for binary data."""
def __init__(self, data):
+ if not isinstance(data, bytes):
+ raise TypeError("data must be as bytes")
self.data = data
+ @classmethod
def fromBase64(cls, data):
- # base64.decodestring just calls binascii.a2b_base64;
+ # base64.decodebytes just calls binascii.a2b_base64;
# it seems overkill to use both base64 and binascii.
return cls(binascii.a2b_base64(data))
- fromBase64 = classmethod(fromBase64)
def asBase64(self, maxlinelength=76):
return _encodeBase64(self.data, maxlinelength)
- def __cmp__(self, other):
+ def __eq__(self, other):
if isinstance(other, self.__class__):
- return cmp(self.data, other.data)
+ return self.data == other.data
elif isinstance(other, str):
- return cmp(self.data, other)
+ return self.data == other
else:
- return cmp(id(self), id(other))
+ return id(self) == id(other)
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__, repr(self.data))
-
class PlistParser:
def __init__(self):
@@ -399,11 +365,11 @@ class PlistParser:
def parse(self, fileobj):
from xml.parsers.expat import ParserCreate
- parser = ParserCreate()
- parser.StartElementHandler = self.handleBeginElement
- parser.EndElementHandler = self.handleEndElement
- parser.CharacterDataHandler = self.handleData
- parser.ParseFile(fileobj)
+ self.parser = ParserCreate()
+ self.parser.StartElementHandler = self.handleBeginElement
+ self.parser.EndElementHandler = self.handleEndElement
+ self.parser.CharacterDataHandler = self.handleData
+ self.parser.ParseFile(fileobj)
return self.root
def handleBeginElement(self, element, attrs):
@@ -422,20 +388,22 @@ class PlistParser:
def addObject(self, value):
if self.currentKey is not None:
+ if not isinstance(self.stack[-1], type({})):
+ raise ValueError("unexpected element at line %d" %
+ self.parser.CurrentLineNumber)
self.stack[-1][self.currentKey] = value
self.currentKey = None
elif not self.stack:
# this is the root object
self.root = value
else:
+ if not isinstance(self.stack[-1], type([])):
+ raise ValueError("unexpected element at line %d" %
+ self.parser.CurrentLineNumber)
self.stack[-1].append(value)
def getData(self):
- data = "".join(self.data)
- try:
- data = data.encode("ascii")
- except UnicodeError:
- pass
+ data = ''.join(self.data)
self.data = []
return data
@@ -446,9 +414,15 @@ class PlistParser:
self.addObject(d)
self.stack.append(d)
def end_dict(self):
+ if self.currentKey:
+ raise ValueError("missing value for key '%s' at line %d" %
+ (self.currentKey,self.parser.CurrentLineNumber))
self.stack.pop()
def end_key(self):
+ if self.currentKey or not isinstance(self.stack[-1], type({})):
+ raise ValueError("unexpected key at line %d" %
+ self.parser.CurrentLineNumber)
self.currentKey = self.getData()
def begin_array(self, attrs):
@@ -469,6 +443,6 @@ class PlistParser:
def end_string(self):
self.addObject(self.getData())
def end_data(self):
- self.addObject(Data.fromBase64(self.getData()))
+ self.addObject(Data.fromBase64(self.getData().encode("utf-8")))
def end_date(self):
self.addObject(_dateFromString(self.getData()))
diff --git a/Lib/popen2.py b/Lib/popen2.py
deleted file mode 100644
index cb769f88627..00000000000
--- a/Lib/popen2.py
+++ /dev/null
@@ -1,201 +0,0 @@
-"""Spawn a command with pipes to its stdin, stdout, and optionally stderr.
-
-The normal os.popen(cmd, mode) call spawns a shell command and provides a
-file interface to just the input or output of the process depending on
-whether mode is 'r' or 'w'. This module provides the functions popen2(cmd)
-and popen3(cmd) which return two or three pipes to the spawned command.
-"""
-
-import os
-import sys
-import warnings
-warnings.warn("The popen2 module is deprecated. Use the subprocess module.",
- DeprecationWarning, stacklevel=2)
-
-__all__ = ["popen2", "popen3", "popen4"]
-
-try:
- MAXFD = os.sysconf('SC_OPEN_MAX')
-except (AttributeError, ValueError):
- MAXFD = 256
-
-_active = []
-
-def _cleanup():
- for inst in _active[:]:
- if inst.poll(_deadstate=sys.maxint) >= 0:
- try:
- _active.remove(inst)
- except ValueError:
- # This can happen if two threads create a new Popen instance.
- # It's harmless that it was already removed, so ignore.
- pass
-
-class Popen3:
- """Class representing a child process. Normally, instances are created
- internally by the functions popen2() and popen3()."""
-
- sts = -1 # Child not completed yet
-
- def __init__(self, cmd, capturestderr=False, bufsize=-1):
- """The parameter 'cmd' is the shell command to execute in a
- sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments
- will be passed directly to the program without shell intervention (as
- with os.spawnv()). If 'cmd' is a string it will be passed to the shell
- (as with os.system()). The 'capturestderr' flag, if true, specifies
- that the object should capture standard error output of the child
- process. The default is false. If the 'bufsize' parameter is
- specified, it specifies the size of the I/O buffers to/from the child
- process."""
- _cleanup()
- self.cmd = cmd
- p2cread, p2cwrite = os.pipe()
- c2pread, c2pwrite = os.pipe()
- if capturestderr:
- errout, errin = os.pipe()
- self.pid = os.fork()
- if self.pid == 0:
- # Child
- os.dup2(p2cread, 0)
- os.dup2(c2pwrite, 1)
- if capturestderr:
- os.dup2(errin, 2)
- self._run_child(cmd)
- os.close(p2cread)
- self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
- os.close(c2pwrite)
- self.fromchild = os.fdopen(c2pread, 'r', bufsize)
- if capturestderr:
- os.close(errin)
- self.childerr = os.fdopen(errout, 'r', bufsize)
- else:
- self.childerr = None
-
- def __del__(self):
- # In case the child hasn't been waited on, check if it's done.
- self.poll(_deadstate=sys.maxint)
- if self.sts < 0:
- if _active is not None:
- # Child is still running, keep us alive until we can wait on it.
- _active.append(self)
-
- def _run_child(self, cmd):
- if isinstance(cmd, basestring):
- cmd = ['/bin/sh', '-c', cmd]
- os.closerange(3, MAXFD)
- try:
- os.execvp(cmd[0], cmd)
- finally:
- os._exit(1)
-
- def poll(self, _deadstate=None):
- """Return the exit status of the child process if it has finished,
- or -1 if it hasn't finished yet."""
- if self.sts < 0:
- try:
- pid, sts = os.waitpid(self.pid, os.WNOHANG)
- # pid will be 0 if self.pid hasn't terminated
- if pid == self.pid:
- self.sts = sts
- except os.error:
- if _deadstate is not None:
- self.sts = _deadstate
- return self.sts
-
- def wait(self):
- """Wait for and return the exit status of the child process."""
- if self.sts < 0:
- pid, sts = os.waitpid(self.pid, 0)
- # This used to be a test, but it is believed to be
- # always true, so I changed it to an assertion - mvl
- assert pid == self.pid
- self.sts = sts
- return self.sts
-
-
-class Popen4(Popen3):
- childerr = None
-
- def __init__(self, cmd, bufsize=-1):
- _cleanup()
- self.cmd = cmd
- p2cread, p2cwrite = os.pipe()
- c2pread, c2pwrite = os.pipe()
- self.pid = os.fork()
- if self.pid == 0:
- # Child
- os.dup2(p2cread, 0)
- os.dup2(c2pwrite, 1)
- os.dup2(c2pwrite, 2)
- self._run_child(cmd)
- os.close(p2cread)
- self.tochild = os.fdopen(p2cwrite, 'w', bufsize)
- os.close(c2pwrite)
- self.fromchild = os.fdopen(c2pread, 'r', bufsize)
-
-
-if sys.platform[:3] == "win" or sys.platform == "os2emx":
- # Some things don't make sense on non-Unix platforms.
- del Popen3, Popen4
-
- def popen2(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin) are returned."""
- w, r = os.popen2(cmd, mode, bufsize)
- return r, w
-
- def popen3(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin, child_stderr) are returned."""
- w, r, e = os.popen3(cmd, mode, bufsize)
- return r, w, e
-
- def popen4(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout_stderr, child_stdin) are returned."""
- w, r = os.popen4(cmd, mode, bufsize)
- return r, w
-else:
- def popen2(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin) are returned."""
- inst = Popen3(cmd, False, bufsize)
- return inst.fromchild, inst.tochild
-
- def popen3(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout, child_stdin, child_stderr) are returned."""
- inst = Popen3(cmd, True, bufsize)
- return inst.fromchild, inst.tochild, inst.childerr
-
- def popen4(cmd, bufsize=-1, mode='t'):
- """Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
- be a sequence, in which case arguments will be passed directly to the
- program without shell intervention (as with os.spawnv()). If 'cmd' is a
- string it will be passed to the shell (as with os.system()). If
- 'bufsize' is specified, it sets the buffer size for the I/O pipes. The
- file objects (child_stdout_stderr, child_stdin) are returned."""
- inst = Popen4(cmd, bufsize)
- return inst.fromchild, inst.tochild
-
- __all__.extend(["Popen3", "Popen4"])
diff --git a/Lib/poplib.py b/Lib/poplib.py
index e2b33ef10f4..84ea88de46b 100644
--- a/Lib/poplib.py
+++ b/Lib/poplib.py
@@ -28,8 +28,8 @@ POP3_PORT = 110
POP3_SSL_PORT = 995
# Line terminators (we always output CRLF, but accept any of CRLF, LFCR, LF)
-CR = '\r'
-LF = '\n'
+CR = b'\r'
+LF = b'\n'
CRLF = CR+LF
@@ -75,26 +75,30 @@ class POP3:
above.
"""
+ encoding = 'UTF-8'
def __init__(self, host, port=POP3_PORT,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
self.host = host
self.port = port
- self.sock = socket.create_connection((host, port), timeout)
+ self.sock = self._create_socket(timeout)
self.file = self.sock.makefile('rb')
self._debugging = 0
self.welcome = self._getresp()
+ def _create_socket(self, timeout):
+ return socket.create_connection((self.host, self.port), timeout)
def _putline(self, line):
- if self._debugging > 1: print '*put*', repr(line)
- self.sock.sendall('%s%s' % (line, CRLF))
+ if self._debugging > 1: print('*put*', repr(line))
+ self.sock.sendall(line + CRLF)
# Internal: send one command to the server (through _putline())
def _putcmd(self, line):
- if self._debugging: print '*cmd*', repr(line)
+ if self._debugging: print('*cmd*', repr(line))
+ line = bytes(line, self.encoding)
self._putline(line)
@@ -104,7 +108,7 @@ class POP3:
def _getline(self):
line = self.file.readline()
- if self._debugging > 1: print '*get*', repr(line)
+ if self._debugging > 1: print('*get*', repr(line))
if not line: raise error_proto('-ERR EOF')
octets = len(line)
# server can send any combination of CR & LF
@@ -122,9 +126,8 @@ class POP3:
def _getresp(self):
resp, o = self._getline()
- if self._debugging > 1: print '*resp*', repr(resp)
- c = resp[:1]
- if c != '+':
+ if self._debugging > 1: print('*resp*', repr(resp))
+ if not resp.startswith(b'+'):
raise error_proto(resp)
return resp
@@ -135,8 +138,8 @@ class POP3:
resp = self._getresp()
list = []; octets = 0
line, o = self._getline()
- while line != '.':
- if line[:2] == '..':
+ while line != b'.':
+ if line.startswith(b'..'):
o = o-1
line = line[1:]
octets = octets + o
@@ -196,7 +199,7 @@ class POP3:
"""
retval = self._shortcmd('STAT')
rets = retval.split()
- if self._debugging: print '*stat*', repr(rets)
+ if self._debugging: print('*stat*', repr(rets))
numMessages = int(rets[1])
sizeMessages = int(rets[2])
return (numMessages, sizeMessages)
@@ -249,7 +252,7 @@ class POP3:
"""Signoff: commit changes on server, unlock mailbox, close connection."""
try:
resp = self._shortcmd('QUIT')
- except error_proto, val:
+ except error_proto as val:
resp = val
self.file.close()
self.sock.close()
@@ -266,25 +269,26 @@ class POP3:
return self._shortcmd('RPOP %s' % user)
- timestamp = re.compile(r'\+OK.*(<[^>]+>)')
+ timestamp = re.compile(br'\+OK.*(<[^>]+>)')
- def apop(self, user, secret):
+ def apop(self, user, password):
"""Authorisation
- only possible if server has supplied a timestamp in initial greeting.
Args:
- user - mailbox user;
- secret - secret shared between client and server.
+ user - mailbox user;
+ password - mailbox password.
NB: mailbox is locked by server from here to 'quit()'
"""
+ secret = bytes(password, self.encoding)
m = self.timestamp.match(self.welcome)
if not m:
raise error_proto('-ERR APOP not supported by server')
import hashlib
- digest = hashlib.md5(m.group(1)+secret).digest()
- digest = ''.join(map(lambda x:'%02x'%ord(x), digest))
+ digest = m.group(1)+secret
+ digest = hashlib.md5(digest).hexdigest()
return self._shortcmd('APOP %s %s' % (user, digest))
@@ -324,94 +328,44 @@ else:
keyfile - PEM formatted file that countains your private key
certfile - PEM formatted certificate chain file
- See the methods of the parent class POP3 for more documentation.
+ See the methods of the parent class POP3 for more documentation.
"""
- def __init__(self, host, port = POP3_SSL_PORT, keyfile = None, certfile = None):
- self.host = host
- self.port = port
+ def __init__(self, host, port=POP3_SSL_PORT, keyfile=None, certfile=None,
+ timeout=socket._GLOBAL_DEFAULT_TIMEOUT, context=None):
+ if context is not None and keyfile is not None:
+ raise ValueError("context and keyfile arguments are mutually "
+ "exclusive")
+ if context is not None and certfile is not None:
+ raise ValueError("context and certfile arguments are mutually "
+ "exclusive")
self.keyfile = keyfile
self.certfile = certfile
- self.buffer = ""
- msg = "getaddrinfo returns an empty list"
- self.sock = None
- for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
- af, socktype, proto, canonname, sa = res
- try:
- self.sock = socket.socket(af, socktype, proto)
- self.sock.connect(sa)
- except socket.error, msg:
- if self.sock:
- self.sock.close()
- self.sock = None
- continue
- break
- if not self.sock:
- raise socket.error, msg
- self.file = self.sock.makefile('rb')
- self.sslobj = ssl.wrap_socket(self.sock, self.keyfile, self.certfile)
- self._debugging = 0
- self.welcome = self._getresp()
-
- def _fillBuffer(self):
- localbuf = self.sslobj.read()
- if len(localbuf) == 0:
- raise error_proto('-ERR EOF')
- self.buffer += localbuf
-
- def _getline(self):
- line = ""
- renewline = re.compile(r'.*?\n')
- match = renewline.match(self.buffer)
- while not match:
- self._fillBuffer()
- match = renewline.match(self.buffer)
- line = match.group(0)
- self.buffer = renewline.sub('' ,self.buffer, 1)
- if self._debugging > 1: print '*get*', repr(line)
-
- octets = len(line)
- if line[-2:] == CRLF:
- return line[:-2], octets
- if line[0] == CR:
- return line[1:-1], octets
- return line[:-1], octets
-
- def _putline(self, line):
- if self._debugging > 1: print '*put*', repr(line)
- line += CRLF
- bytes = len(line)
- while bytes > 0:
- sent = self.sslobj.write(line)
- if sent == bytes:
- break # avoid copy
- line = line[sent:]
- bytes = bytes - sent
-
- def quit(self):
- """Signoff: commit changes on server, unlock mailbox, close connection."""
- try:
- resp = self._shortcmd('QUIT')
- except error_proto, val:
- resp = val
- self.sock.close()
- del self.sslobj, self.sock
- return resp
+ self.context = context
+ POP3.__init__(self, host, port, timeout)
+
+ def _create_socket(self, timeout):
+ sock = POP3._create_socket(self, timeout)
+ if self.context is not None:
+ sock = self.context.wrap_socket(sock)
+ else:
+ sock = ssl.wrap_socket(sock, self.keyfile, self.certfile)
+ return sock
__all__.append("POP3_SSL")
if __name__ == "__main__":
import sys
a = POP3(sys.argv[1])
- print a.getwelcome()
+ print(a.getwelcome())
a.user(sys.argv[2])
a.pass_(sys.argv[3])
a.list()
(numMsgs, totalSize) = a.stat()
for i in range(1, numMsgs + 1):
(header, msg, octets) = a.retr(i)
- print "Message %d:" % i
+ print("Message %d:" % i)
for line in msg:
- print ' ' + line
- print '-----------------------'
+ print(' ' + line)
+ print('-----------------------')
a.quit()
diff --git a/Lib/posixfile.py b/Lib/posixfile.py
deleted file mode 100644
index ff2910779bc..00000000000
--- a/Lib/posixfile.py
+++ /dev/null
@@ -1,237 +0,0 @@
-"""Extended file operations available in POSIX.
-
-f = posixfile.open(filename, [mode, [bufsize]])
- will create a new posixfile object
-
-f = posixfile.fileopen(fileobject)
- will create a posixfile object from a builtin file object
-
-f.file()
- will return the original builtin file object
-
-f.dup()
- will return a new file object based on a new filedescriptor
-
-f.dup2(fd)
- will return a new file object based on the given filedescriptor
-
-f.flags(mode)
- will turn on the associated flag (merge)
- mode can contain the following characters:
-
- (character representing a flag)
- a append only flag
- c close on exec flag
- n no delay flag
- s synchronization flag
- (modifiers)
- ! turn flags 'off' instead of default 'on'
- = copy flags 'as is' instead of default 'merge'
- ? return a string in which the characters represent the flags
- that are set
-
- note: - the '!' and '=' modifiers are mutually exclusive.
- - the '?' modifier will return the status of the flags after they
- have been changed by other characters in the mode string
-
-f.lock(mode [, len [, start [, whence]]])
- will (un)lock a region
- mode can contain the following characters:
-
- (character representing type of lock)
- u unlock
- r read lock
- w write lock
- (modifiers)
- | wait until the lock can be granted
- ? return the first lock conflicting with the requested lock
- or 'None' if there is no conflict. The lock returned is in the
- format (mode, len, start, whence, pid) where mode is a
- character representing the type of lock ('r' or 'w')
-
- note: - the '?' modifier prevents a region from being locked; it is
- query only
-"""
-import warnings
-warnings.warn("The posixfile module is deprecated; "
- "fcntl.lockf() provides better locking", DeprecationWarning, 2)
-
-class _posixfile_:
- """File wrapper class that provides extra POSIX file routines."""
-
- states = ['open', 'closed']
-
- #
- # Internal routines
- #
- def __repr__(self):
- file = self._file_
- return "<%s posixfile '%s', mode '%s' at %s>" % \
- (self.states[file.closed], file.name, file.mode, \
- hex(id(self))[2:])
-
- #
- # Initialization routines
- #
- def open(self, name, mode='r', bufsize=-1):
- import __builtin__
- return self.fileopen(__builtin__.open(name, mode, bufsize))
-
- def fileopen(self, file):
- import types
- if repr(type(file)) != "<type 'file'>":
- raise TypeError, 'posixfile.fileopen() arg must be file object'
- self._file_ = file
- # Copy basic file methods
- for maybemethod in dir(file):
- if not maybemethod.startswith('_'):
- attr = getattr(file, maybemethod)
- if isinstance(attr, types.BuiltinMethodType):
- setattr(self, maybemethod, attr)
- return self
-
- #
- # New methods
- #
- def file(self):
- return self._file_
-
- def dup(self):
- import posix
-
- if not hasattr(posix, 'fdopen'):
- raise AttributeError, 'dup() method unavailable'
-
- return posix.fdopen(posix.dup(self._file_.fileno()), self._file_.mode)
-
- def dup2(self, fd):
- import posix
-
- if not hasattr(posix, 'fdopen'):
- raise AttributeError, 'dup() method unavailable'
-
- posix.dup2(self._file_.fileno(), fd)
- return posix.fdopen(fd, self._file_.mode)
-
- def flags(self, *which):
- import fcntl, os
-
- if which:
- if len(which) > 1:
- raise TypeError, 'Too many arguments'
- which = which[0]
- else: which = '?'
-
- l_flags = 0
- if 'n' in which: l_flags = l_flags | os.O_NDELAY
- if 'a' in which: l_flags = l_flags | os.O_APPEND
- if 's' in which: l_flags = l_flags | os.O_SYNC
-
- file = self._file_
-
- if '=' not in which:
- cur_fl = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
- if '!' in which: l_flags = cur_fl & ~ l_flags
- else: l_flags = cur_fl | l_flags
-
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFL, l_flags)
-
- if 'c' in which:
- arg = ('!' not in which) # 0 is don't, 1 is do close on exec
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_SETFD, arg)
-
- if '?' in which:
- which = '' # Return current flags
- l_flags = fcntl.fcntl(file.fileno(), fcntl.F_GETFL, 0)
- if os.O_APPEND & l_flags: which = which + 'a'
- if fcntl.fcntl(file.fileno(), fcntl.F_GETFD, 0) & 1:
- which = which + 'c'
- if os.O_NDELAY & l_flags: which = which + 'n'
- if os.O_SYNC & l_flags: which = which + 's'
- return which
-
- def lock(self, how, *args):
- import struct, fcntl
-
- if 'w' in how: l_type = fcntl.F_WRLCK
- elif 'r' in how: l_type = fcntl.F_RDLCK
- elif 'u' in how: l_type = fcntl.F_UNLCK
- else: raise TypeError, 'no type of lock specified'
-
- if '|' in how: cmd = fcntl.F_SETLKW
- elif '?' in how: cmd = fcntl.F_GETLK
- else: cmd = fcntl.F_SETLK
-
- l_whence = 0
- l_start = 0
- l_len = 0
-
- if len(args) == 1:
- l_len = args[0]
- elif len(args) == 2:
- l_len, l_start = args
- elif len(args) == 3:
- l_len, l_start, l_whence = args
- elif len(args) > 3:
- raise TypeError, 'too many arguments'
-
- # Hack by davem@magnet.com to get locking to go on freebsd;
- # additions for AIX by Vladimir.Marangozov@imag.fr
- import sys, os
- if sys.platform in ('netbsd1',
- 'openbsd2',
- 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
- 'freebsd6', 'freebsd7', 'freebsd8',
- 'bsdos2', 'bsdos3', 'bsdos4'):
- flock = struct.pack('lxxxxlxxxxlhh', \
- l_start, l_len, os.getpid(), l_type, l_whence)
- elif sys.platform in ('aix3', 'aix4'):
- flock = struct.pack('hhlllii', \
- l_type, l_whence, l_start, l_len, 0, 0, 0)
- else:
- flock = struct.pack('hhllhh', \
- l_type, l_whence, l_start, l_len, 0, 0)
-
- flock = fcntl.fcntl(self._file_.fileno(), cmd, flock)
-
- if '?' in how:
- if sys.platform in ('netbsd1',
- 'openbsd2',
- 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
- 'bsdos2', 'bsdos3', 'bsdos4'):
- l_start, l_len, l_pid, l_type, l_whence = \
- struct.unpack('lxxxxlxxxxlhh', flock)
- elif sys.platform in ('aix3', 'aix4'):
- l_type, l_whence, l_start, l_len, l_sysid, l_pid, l_vfs = \
- struct.unpack('hhlllii', flock)
- elif sys.platform == "linux2":
- l_type, l_whence, l_start, l_len, l_pid, l_sysid = \
- struct.unpack('hhllhh', flock)
- else:
- l_type, l_whence, l_start, l_len, l_sysid, l_pid = \
- struct.unpack('hhllhh', flock)
-
- if l_type != fcntl.F_UNLCK:
- if l_type == fcntl.F_RDLCK:
- return 'r', l_len, l_start, l_whence, l_pid
- else:
- return 'w', l_len, l_start, l_whence, l_pid
-
-def open(name, mode='r', bufsize=-1):
- """Public routine to open a file as a posixfile object."""
- return _posixfile_().open(name, mode, bufsize)
-
-def fileopen(file):
- """Public routine to get a posixfile object from a Python file object."""
- return _posixfile_().fileopen(file)
-
-#
-# Constants
-#
-SEEK_SET = 0
-SEEK_CUR = 1
-SEEK_END = 2
-
-#
-# End of posixfile.py
-#
diff --git a/Lib/posixpath.py b/Lib/posixpath.py
index 5ddf25b1067..2e3625bc6f1 100644
--- a/Lib/posixpath.py
+++ b/Lib/posixpath.py
@@ -14,26 +14,18 @@ import os
import sys
import stat
import genericpath
-import warnings
from genericpath import *
-try:
- _unicode = unicode
-except NameError:
- # If Python is built without Unicode support, the unicode type
- # will not exist. Fake one.
- class _unicode(object):
- pass
-
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
"basename","dirname","commonprefix","getsize","getmtime",
"getatime","getctime","islink","exists","lexists","isdir","isfile",
- "ismount","walk","expanduser","expandvars","normpath","abspath",
+ "ismount", "expanduser","expandvars","normpath","abspath",
"samefile","sameopenfile","samestat",
"curdir","pardir","sep","pathsep","defpath","altsep","extsep",
"devnull","realpath","supports_unicode_filenames","relpath"]
-# strings representing various path-related bits and pieces
+# Strings representing various path-related bits and pieces.
+# These are primarily for export; internally, they are hardcoded.
curdir = '.'
pardir = '..'
extsep = '.'
@@ -43,6 +35,12 @@ defpath = ':/bin:/usr/bin'
altsep = None
devnull = '/dev/null'
+def _get_sep(path):
+ if isinstance(path, bytes):
+ return b'/'
+ else:
+ return '/'
+
# Normalize the case of a pathname. Trivial in Posix, string.lower on Mac.
# On MS-DOS this may also turn slashes into backslashes; however, other
# normalizations (such as optimizing '../' away) are not allowed
@@ -50,6 +48,10 @@ devnull = '/dev/null'
def normcase(s):
"""Normalize case of pathname. Has no effect under Posix"""
+ # TODO: on Mac OS X, this should really return s.lower().
+ if not isinstance(s, (bytes, str)):
+ raise TypeError("normcase() argument must be str or bytes, "
+ "not '{}'".format(s.__class__.__name__))
return s
@@ -58,7 +60,8 @@ def normcase(s):
def isabs(s):
"""Test whether a path is absolute"""
- return s.startswith('/')
+ sep = _get_sep(s)
+ return s.startswith(sep)
# Join pathnames.
@@ -70,14 +73,23 @@ def join(a, *p):
If any component is an absolute path, all previous path components
will be discarded. An empty last part will result in a path that
ends with a separator."""
+ sep = _get_sep(a)
path = a
- for b in p:
- if b.startswith('/'):
- path = b
- elif path == '' or path.endswith('/'):
- path += b
- else:
- path += '/' + b
+ try:
+ for b in p:
+ if b.startswith(sep):
+ path = b
+ elif not path or path.endswith(sep):
+ path += b
+ else:
+ path += sep + b
+ except TypeError:
+ valid_types = all(isinstance(s, (str, bytes, bytearray))
+ for s in (a, ) + p)
+ if valid_types:
+ # Must have a mixture of text and binary data
+ raise TypeError("Can't mix strings and bytes in path components.")
+ raise
return path
@@ -89,10 +101,11 @@ def join(a, *p):
def split(p):
"""Split a pathname. Returns tuple "(head, tail)" where "tail" is
everything after the final slash. Either part may be empty."""
- i = p.rfind('/') + 1
+ sep = _get_sep(p)
+ i = p.rfind(sep) + 1
head, tail = p[:i], p[i:]
- if head and head != '/'*len(head):
- head = head.rstrip('/')
+ if head and head != sep*len(head):
+ head = head.rstrip(sep)
return head, tail
@@ -102,7 +115,13 @@ def split(p):
# It is always true that root + ext == p.
def splitext(p):
- return genericpath._splitext(p, sep, altsep, extsep)
+ if isinstance(p, bytes):
+ sep = b'/'
+ extsep = b'.'
+ else:
+ sep = '/'
+ extsep = '.'
+ return genericpath._splitext(p, sep, None, extsep)
splitext.__doc__ = genericpath._splitext.__doc__
# Split a pathname into a drive specification and the rest of the
@@ -111,14 +130,15 @@ splitext.__doc__ = genericpath._splitext.__doc__
def splitdrive(p):
"""Split a pathname into drive and path. On Posix, drive is always
empty."""
- return '', p
+ return p[:0], p
# Return the tail (basename) part of a path, same as split(path)[1].
def basename(p):
"""Returns the final component of a pathname"""
- i = p.rfind('/') + 1
+ sep = _get_sep(p)
+ i = p.rfind(sep) + 1
return p[i:]
@@ -126,10 +146,11 @@ def basename(p):
def dirname(p):
"""Returns the directory component of a pathname"""
- i = p.rfind('/') + 1
+ sep = _get_sep(p)
+ i = p.rfind(sep) + 1
head = p[:i]
- if head and head != '/'*len(head):
- head = head.rstrip('/')
+ if head and head != sep*len(head):
+ head = head.rstrip(sep)
return head
@@ -193,7 +214,11 @@ def ismount(path):
return False
try:
s1 = os.lstat(path)
- s2 = os.lstat(join(path, '..'))
+ if isinstance(path, bytes):
+ parent = join(path, b'..')
+ else:
+ parent = join(path, '..')
+ s2 = os.lstat(parent)
except os.error:
return False # It doesn't exist -- so not a mount point :-)
dev1 = s1.st_dev
@@ -207,45 +232,6 @@ def ismount(path):
return False
-# Directory tree walk.
-# For each directory under top (including top itself, but excluding
-# '.' and '..'), func(arg, dirname, filenames) is called, where
-# dirname is the name of the directory and filenames is the list
-# of files (and subdirectories etc.) in the directory.
-# The func may modify the filenames list, to implement a filter,
-# or to impose a different order of visiting.
-
-def walk(top, func, arg):
- """Directory tree walk with callback function.
-
- For each directory in the directory tree rooted at top (including top
- itself, but excluding '.' and '..'), call func(arg, dirname, fnames).
- dirname is the name of the directory, and fnames a list of the names of
- the files and subdirectories in dirname (excluding '.' and '..'). func
- may modify the fnames list in-place (e.g. via del or slice assignment),
- and walk will only recurse into the subdirectories whose names remain in
- fnames; this can be used to implement a filter, or to impose a specific
- order of visiting. No semantics are defined for, or required of, arg,
- beyond that arg is always passed to func. It can be used, e.g., to pass
- a filename pattern, or a mutable object designed to accumulate
- statistics. Passing None for arg is common."""
- warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.",
- stacklevel=2)
- try:
- names = os.listdir(top)
- except os.error:
- return
- func(arg, top, names)
- for name in names:
- name = join(top, name)
- try:
- st = os.lstat(name)
- except os.error:
- continue
- if stat.S_ISDIR(st.st_mode):
- walk(name, func, arg)
-
-
# Expand paths beginning with '~' or '~user'.
# '~' means $HOME; '~user' means that user's home directory.
# If the path doesn't begin with '~', or if the user or $HOME is unknown,
@@ -258,9 +244,14 @@ def walk(top, func, arg):
def expanduser(path):
"""Expand ~ and ~user constructions. If user or $HOME is unknown,
do nothing."""
- if not path.startswith('~'):
+ if isinstance(path, bytes):
+ tilde = b'~'
+ else:
+ tilde = '~'
+ if not path.startswith(tilde):
return path
- i = path.find('/', 1)
+ sep = _get_sep(path)
+ i = path.find(sep, 1)
if i < 0:
i = len(path)
if i == 1:
@@ -271,13 +262,21 @@ def expanduser(path):
userhome = os.environ['HOME']
else:
import pwd
+ name = path[1:i]
+ if isinstance(name, bytes):
+ name = str(name, 'ASCII')
try:
- pwent = pwd.getpwnam(path[1:i])
+ pwent = pwd.getpwnam(name)
except KeyError:
return path
userhome = pwent.pw_dir
- userhome = userhome.rstrip('/')
- return (userhome + path[i:]) or '/'
+ if isinstance(path, bytes):
+ userhome = os.fsencode(userhome)
+ root = b'/'
+ else:
+ root = '/'
+ userhome = userhome.rstrip(root)
+ return (userhome + path[i:]) or root
# Expand paths containing shell variable substitutions.
@@ -285,28 +284,47 @@ def expanduser(path):
# Non-existent variables are left unchanged.
_varprog = None
+_varprogb = None
def expandvars(path):
"""Expand shell variables of form $var and ${var}. Unknown variables
are left unchanged."""
- global _varprog
- if '$' not in path:
- return path
- if not _varprog:
- import re
- _varprog = re.compile(r'\$(\w+|\{[^}]*\})')
+ global _varprog, _varprogb
+ if isinstance(path, bytes):
+ if b'$' not in path:
+ return path
+ if not _varprogb:
+ import re
+ _varprogb = re.compile(br'\$(\w+|\{[^}]*\})', re.ASCII)
+ search = _varprogb.search
+ start = b'{'
+ end = b'}'
+ else:
+ if '$' not in path:
+ return path
+ if not _varprog:
+ import re
+ _varprog = re.compile(r'\$(\w+|\{[^}]*\})', re.ASCII)
+ search = _varprog.search
+ start = '{'
+ end = '}'
i = 0
while True:
- m = _varprog.search(path, i)
+ m = search(path, i)
if not m:
break
i, j = m.span(0)
name = m.group(1)
- if name.startswith('{') and name.endswith('}'):
+ if name.startswith(start) and name.endswith(end):
name = name[1:-1]
+ if isinstance(name, bytes):
+ name = str(name, 'ASCII')
if name in os.environ:
tail = path[j:]
- path = path[:i] + os.environ[name]
+ value = os.environ[name]
+ if isinstance(path, bytes):
+ value = value.encode('ASCII')
+ path = path[:i] + value
i = len(path)
path += tail
else:
@@ -320,38 +338,46 @@ def expandvars(path):
def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
- # Preserve unicode (if path is unicode)
- slash, dot = (u'/', u'.') if isinstance(path, _unicode) else ('/', '.')
- if path == '':
+ if isinstance(path, bytes):
+ sep = b'/'
+ empty = b''
+ dot = b'.'
+ dotdot = b'..'
+ else:
+ sep = '/'
+ empty = ''
+ dot = '.'
+ dotdot = '..'
+ if path == empty:
return dot
- initial_slashes = path.startswith('/')
+ initial_slashes = path.startswith(sep)
# POSIX allows one or two initial slashes, but treats three or more
# as single slash.
if (initial_slashes and
- path.startswith('//') and not path.startswith('///')):
+ path.startswith(sep*2) and not path.startswith(sep*3)):
initial_slashes = 2
- comps = path.split('/')
+ comps = path.split(sep)
new_comps = []
for comp in comps:
- if comp in ('', '.'):
+ if comp in (empty, dot):
continue
- if (comp != '..' or (not initial_slashes and not new_comps) or
- (new_comps and new_comps[-1] == '..')):
+ if (comp != dotdot or (not initial_slashes and not new_comps) or
+ (new_comps and new_comps[-1] == dotdot)):
new_comps.append(comp)
elif new_comps:
new_comps.pop()
comps = new_comps
- path = slash.join(comps)
+ path = sep.join(comps)
if initial_slashes:
- path = slash*initial_slashes + path
+ path = sep*initial_slashes + path
return path or dot
def abspath(path):
"""Return an absolute path."""
if not isabs(path):
- if isinstance(path, _unicode):
- cwd = os.getcwdu()
+ if isinstance(path, bytes):
+ cwd = os.getcwdb()
else:
cwd = os.getcwd()
path = join(cwd, path)
@@ -364,10 +390,16 @@ def abspath(path):
def realpath(filename):
"""Return the canonical path of the specified filename, eliminating any
symbolic links encountered in the path."""
+ if isinstance(filename, bytes):
+ sep = b'/'
+ empty = b''
+ else:
+ sep = '/'
+ empty = ''
if isabs(filename):
- bits = ['/'] + filename.split('/')[1:]
+ bits = [sep] + filename.split(sep)[1:]
else:
- bits = [''] + filename.split('/')
+ bits = [empty] + filename.split(sep)
for i in range(2, len(bits)+1):
component = join(*bits[0:i])
@@ -406,12 +438,24 @@ def _resolve_link(path):
supports_unicode_filenames = (sys.platform == 'darwin')
-def relpath(path, start=curdir):
+def relpath(path, start=None):
"""Return a relative version of a path"""
if not path:
raise ValueError("no path specified")
+ if isinstance(path, bytes):
+ curdir = b'.'
+ sep = b'/'
+ pardir = b'..'
+ else:
+ curdir = '.'
+ sep = '/'
+ pardir = '..'
+
+ if start is None:
+ start = curdir
+
start_list = [x for x in abspath(start).split(sep) if x]
path_list = [x for x in abspath(path).split(sep) if x]
diff --git a/Lib/pprint.py b/Lib/pprint.py
index 910283e6091..ae96dde1e02 100644
--- a/Lib/pprint.py
+++ b/Lib/pprint.py
@@ -35,9 +35,8 @@ saferepr()
"""
import sys as _sys
-import warnings
-
-from cStringIO import StringIO as _StringIO
+from collections import OrderedDict as _OrderedDict
+from io import StringIO as _StringIO
__all__ = ["pprint","pformat","isreadable","isrecursive","saferepr",
"PrettyPrinter"]
@@ -71,12 +70,35 @@ def isrecursive(object):
"""Determine if object requires a recursive representation."""
return _safe_repr(object, {}, None, 0)[2]
-def _sorted(iterable):
- with warnings.catch_warnings():
- if _sys.py3kwarning:
- warnings.filterwarnings("ignore", "comparing unequal types "
- "not supported", DeprecationWarning)
- return sorted(iterable)
+class _safe_key:
+ """Helper function for key functions when sorting unorderable objects.
+
+ The wrapped-object will fallback to an Py2.x style comparison for
+ unorderable types (sorting first comparing the type name and then by
+ the obj ids). Does not work recursively, so dict.items() must have
+ _safe_key applied to both the key and the value.
+
+ """
+
+ __slots__ = ['obj']
+
+ def __init__(self, obj):
+ self.obj = obj
+
+ def __lt__(self, other):
+ try:
+ rv = self.obj.__lt__(other.obj)
+ except TypeError:
+ rv = NotImplemented
+
+ if rv is NotImplemented:
+ rv = (str(type(self.obj)), id(self.obj)) < \
+ (str(type(other.obj)), id(other.obj))
+ return rv
+
+def _safe_tuple(t):
+ "Helper function for comparing 2-tuples"
+ return _safe_key(t[0]), _safe_key(t[1])
class PrettyPrinter:
def __init__(self, indent=1, width=80, depth=None, stream=None):
@@ -143,85 +165,82 @@ class PrettyPrinter:
write(rep)
return
- r = getattr(typ, "__repr__", None)
- if issubclass(typ, dict) and r is dict.__repr__:
- write('{')
- if self._indent_per_level > 1:
- write((self._indent_per_level - 1) * ' ')
- length = _len(object)
- if length:
- context[objid] = 1
- indent = indent + self._indent_per_level
- items = _sorted(object.items())
- key, ent = items[0]
- rep = self._repr(key, context, level)
- write(rep)
- write(': ')
- self._format(ent, stream, indent + _len(rep) + 2,
- allowance + 1, context, level)
- if length > 1:
- for key, ent in items[1:]:
- rep = self._repr(key, context, level)
- if sepLines:
+ if sepLines:
+ r = getattr(typ, "__repr__", None)
+ if issubclass(typ, dict):
+ write('{')
+ if self._indent_per_level > 1:
+ write((self._indent_per_level - 1) * ' ')
+ length = _len(object)
+ if length:
+ context[objid] = 1
+ indent = indent + self._indent_per_level
+ if issubclass(typ, _OrderedDict):
+ items = list(object.items())
+ else:
+ items = sorted(object.items(), key=_safe_tuple)
+ key, ent = items[0]
+ rep = self._repr(key, context, level)
+ write(rep)
+ write(': ')
+ self._format(ent, stream, indent + _len(rep) + 2,
+ allowance + 1, context, level)
+ if length > 1:
+ for key, ent in items[1:]:
+ rep = self._repr(key, context, level)
write(',\n%s%s: ' % (' '*indent, rep))
- else:
- write(', %s: ' % rep)
- self._format(ent, stream, indent + _len(rep) + 2,
- allowance + 1, context, level)
- indent = indent - self._indent_per_level
- del context[objid]
- write('}')
- return
-
- if ((issubclass(typ, list) and r is list.__repr__) or
- (issubclass(typ, tuple) and r is tuple.__repr__) or
- (issubclass(typ, set) and r is set.__repr__) or
- (issubclass(typ, frozenset) and r is frozenset.__repr__)
- ):
- length = _len(object)
- if issubclass(typ, list):
- write('[')
- endchar = ']'
- elif issubclass(typ, set):
- if not length:
- write('set()')
- return
- write('set([')
- endchar = '])'
- object = _sorted(object)
- indent += 4
- elif issubclass(typ, frozenset):
- if not length:
- write('frozenset()')
- return
- write('frozenset([')
- endchar = '])'
- object = _sorted(object)
- indent += 10
- else:
- write('(')
- endchar = ')'
- if self._indent_per_level > 1 and sepLines:
- write((self._indent_per_level - 1) * ' ')
- if length:
- context[objid] = 1
- indent = indent + self._indent_per_level
- self._format(object[0], stream, indent, allowance + 1,
- context, level)
- if length > 1:
- for ent in object[1:]:
- if sepLines:
+ self._format(ent, stream, indent + _len(rep) + 2,
+ allowance + 1, context, level)
+ indent = indent - self._indent_per_level
+ del context[objid]
+ write('}')
+ return
+
+ if ((issubclass(typ, list) and r is list.__repr__) or
+ (issubclass(typ, tuple) and r is tuple.__repr__) or
+ (issubclass(typ, set) and r is set.__repr__) or
+ (issubclass(typ, frozenset) and r is frozenset.__repr__)
+ ):
+ length = _len(object)
+ if issubclass(typ, list):
+ write('[')
+ endchar = ']'
+ elif issubclass(typ, set):
+ if not length:
+ write('set()')
+ return
+ write('{')
+ endchar = '}'
+ object = sorted(object, key=_safe_key)
+ elif issubclass(typ, frozenset):
+ if not length:
+ write('frozenset()')
+ return
+ write('frozenset({')
+ endchar = '})'
+ object = sorted(object, key=_safe_key)
+ indent += 10
+ else:
+ write('(')
+ endchar = ')'
+ if self._indent_per_level > 1:
+ write((self._indent_per_level - 1) * ' ')
+ if length:
+ context[objid] = 1
+ indent = indent + self._indent_per_level
+ self._format(object[0], stream, indent, allowance + 1,
+ context, level)
+ if length > 1:
+ for ent in object[1:]:
write(',\n' + ' '*indent)
- else:
- write(', ')
- self._format(ent, stream, indent,
- allowance + 1, context, level)
- indent = indent - self._indent_per_level
- del context[objid]
- if issubclass(typ, tuple) and length == 1:
- write(',')
- write(endchar)
- return
+ self._format(ent, stream, indent,
+ allowance + 1, context, level)
+ indent = indent - self._indent_per_level
+ del context[objid]
+ if issubclass(typ, tuple) and length == 1:
+ write(',')
+ write(endchar)
+ return
write(rep)
@@ -281,7 +300,8 @@ def _safe_repr(object, context, maxlevels, level):
append = components.append
level += 1
saferepr = _safe_repr
- for k, v in _sorted(object.items()):
+ items = sorted(object.items(), key=_safe_tuple)
+ for k, v in items:
krepr, kreadable, krecur = saferepr(k, context, maxlevels, level)
vrepr, vreadable, vrecur = saferepr(v, context, maxlevels, level)
append("%s: %s" % (krepr, vrepr))
@@ -343,8 +363,8 @@ def _perfcheck(object=None):
t2 = time.time()
p.pformat(object)
t3 = time.time()
- print "_safe_repr:", t2 - t1
- print "pformat:", t3 - t2
+ print("_safe_repr:", t2 - t1)
+ print("pformat:", t3 - t2)
if __name__ == "__main__":
_perfcheck()
diff --git a/Lib/profile.py b/Lib/profile.py
index 297aa04cf7c..297e32d64ad 100755
--- a/Lib/profile.py
+++ b/Lib/profile.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
#
# Class for profiling python code. rev 1.0 6/2/94
#
@@ -30,7 +30,7 @@ import time
import marshal
from optparse import OptionParser
-__all__ = ["run", "runctx", "help", "Profile"]
+__all__ = ["run", "runctx", "Profile"]
# Sample timer for use with
#i_count = 0
@@ -83,11 +83,6 @@ def runctx(statement, globals, locals, filename=None, sort=-1):
else:
return prof.print_stats(sort)
-# Backwards compatibility.
-def help():
- print "Documentation for the profile module can be found "
- print "in the Python Library Reference, section 'The Python Profiler'."
-
if hasattr(os, "times"):
def _get_time_times(timer=os.times):
t = timer()
@@ -421,10 +416,10 @@ class Profile:
def snapshot_stats(self):
self.stats = {}
- for func, (cc, ns, tt, ct, callers) in self.timings.iteritems():
+ for func, (cc, ns, tt, ct, callers) in self.timings.items():
callers = callers.copy()
nc = 0
- for callcnt in callers.itervalues():
+ for callcnt in callers.values():
nc += callcnt
self.stats[func] = cc, nc, tt, ct, callers
@@ -441,7 +436,7 @@ class Profile:
self.set_cmd(cmd)
sys.setprofile(self.dispatcher)
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
sys.setprofile(None)
return self
@@ -532,7 +527,7 @@ class Profile:
t1 = get_time()
elapsed_noprofile = t1 - t0
if verbose:
- print "elapsed time without profiling =", elapsed_noprofile
+ print("elapsed time without profiling =", elapsed_noprofile)
# elapsed_profile <- time f(m) takes with profiling. The difference
# is profiling overhead, only some of which the profiler subtracts
@@ -543,7 +538,7 @@ class Profile:
t1 = get_time()
elapsed_profile = t1 - t0
if verbose:
- print "elapsed time with profiling =", elapsed_profile
+ print("elapsed time with profiling =", elapsed_profile)
# reported_time <- "CPU seconds" the profiler charged to f and f1.
total_calls = 0.0
@@ -555,8 +550,8 @@ class Profile:
reported_time += tt
if verbose:
- print "'CPU seconds' profiler reported =", reported_time
- print "total # calls =", total_calls
+ print("'CPU seconds' profiler reported =", reported_time)
+ print("total # calls =", total_calls)
if total_calls != m + 1:
raise ValueError("internal error: total calls = %d" % total_calls)
@@ -566,12 +561,10 @@ class Profile:
# overhead per event.
mean = (reported_time - elapsed_noprofile) / 2.0 / total_calls
if verbose:
- print "mean stopwatch overhead per profile event =", mean
+ print("mean stopwatch overhead per profile event =", mean)
return mean
#****************************************************************************
-def Stats(*args):
- print 'Report generating functions are in the "pstats" module\a'
def main():
usage = "profile.py [-o output_file_path] [-s sort] scriptfile [arg] ..."
@@ -599,6 +592,7 @@ def main():
'__file__': progname,
'__name__': '__main__',
'__package__': None,
+ '__cached__': None,
}
runctx(code, globs, None, options.outfile, options.sort)
else:
diff --git a/Lib/pstats.py b/Lib/pstats.py
index 4338994e5d4..bfbaa41386e 100644
--- a/Lib/pstats.py
+++ b/Lib/pstats.py
@@ -59,20 +59,8 @@ class Stats:
print_stats(5).print_callers(5)
"""
- def __init__(self, *args, **kwds):
- # I can't figure out how to explictly specify a stream keyword arg
- # with *args:
- # def __init__(self, *args, stream=sys.stdout): ...
- # so I use **kwds and sqauwk if something unexpected is passed in.
- self.stream = sys.stdout
- if "stream" in kwds:
- self.stream = kwds["stream"]
- del kwds["stream"]
- if kwds:
- keys = kwds.keys()
- keys.sort()
- extras = ", ".join(["%s=%s" % (k, kwds[k]) for k in keys])
- raise ValueError, "unrecognized keyword args: %s" % extras
+ def __init__(self, *args, stream=None):
+ self.stream = stream or sys.stdout
if not len(args):
arg = None
else:
@@ -89,23 +77,22 @@ class Stats:
self.total_calls = 0
self.prim_calls = 0
self.max_name_len = 0
- self.top_level = {}
+ self.top_level = set()
self.stats = {}
self.sort_arg_dict = {}
self.load_stats(arg)
- trouble = 1
try:
self.get_top_level_stats()
- trouble = 0
- finally:
- if trouble:
- print >> self.stream, "Invalid timing data",
- if self.files: print >> self.stream, self.files[-1],
- print >> self.stream
+ except Exception:
+ print("Invalid timing data %s" %
+ (self.files[-1] if self.files else ''), file=self.stream)
+ raise
def load_stats(self, arg):
- if not arg: self.stats = {}
- elif isinstance(arg, basestring):
+ if arg is None:
+ self.stats = {}
+ return
+ elif isinstance(arg, str):
f = open(arg, 'rb')
self.stats = marshal.load(f)
f.close()
@@ -114,7 +101,7 @@ class Stats:
arg = time.ctime(file_stats.st_mtime) + " " + arg
except: # in case this is not unix
pass
- self.files = [ arg ]
+ self.files = [arg]
elif hasattr(arg, 'create_stats'):
arg.create_stats()
self.stats = arg.stats
@@ -130,39 +117,39 @@ class Stats:
self.prim_calls += cc
self.total_tt += tt
if ("jprofile", 0, "profiler") in callers:
- self.top_level[func] = None
+ self.top_level.add(func)
if len(func_std_string(func)) > self.max_name_len:
self.max_name_len = len(func_std_string(func))
def add(self, *arg_list):
- if not arg_list: return self
- if len(arg_list) > 1: self.add(*arg_list[1:])
- other = arg_list[0]
- if type(self) != type(other) or self.__class__ != other.__class__:
- other = Stats(other)
- self.files += other.files
- self.total_calls += other.total_calls
- self.prim_calls += other.prim_calls
- self.total_tt += other.total_tt
- for func in other.top_level:
- self.top_level[func] = None
-
- if self.max_name_len < other.max_name_len:
- self.max_name_len = other.max_name_len
-
- self.fcn_list = None
-
- for func, stat in other.stats.iteritems():
- if func in self.stats:
- old_func_stat = self.stats[func]
- else:
- old_func_stat = (0, 0, 0, 0, {},)
- self.stats[func] = add_func_stats(old_func_stat, stat)
+ if not arg_list:
+ return self
+ for item in reversed(arg_list):
+ if type(self) != type(item):
+ item = Stats(item)
+ self.files += item.files
+ self.total_calls += item.total_calls
+ self.prim_calls += item.prim_calls
+ self.total_tt += item.total_tt
+ for func in item.top_level:
+ self.top_level.add(func)
+
+ if self.max_name_len < item.max_name_len:
+ self.max_name_len = item.max_name_len
+
+ self.fcn_list = None
+
+ for func, stat in item.stats.items():
+ if func in self.stats:
+ old_func_stat = self.stats[func]
+ else:
+ old_func_stat = (0, 0, 0, 0, {},)
+ self.stats[func] = add_func_stats(old_func_stat, stat)
return self
def dump_stats(self, filename):
"""Write the profile data to a file we know how to load back."""
- f = file(filename, 'wb')
+ f = open(filename, 'wb')
try:
marshal.dump(self.stats, f)
finally:
@@ -192,7 +179,7 @@ class Stats:
if not self.sort_arg_dict:
self.sort_arg_dict = dict = {}
bad_list = {}
- for word, tup in self.sort_arg_dict_default.iteritems():
+ for word, tup in self.sort_arg_dict_default.items():
fragment = word
while fragment:
if not fragment:
@@ -210,7 +197,7 @@ class Stats:
if not field:
self.fcn_list = 0
return self
- if len(field) == 1 and isinstance(field[0], (int, long)):
+ if len(field) == 1 and isinstance(field[0], int):
# Be compatible with old profiler
field = [ {-1: "stdname",
0: "calls",
@@ -227,7 +214,7 @@ class Stats:
connector = ", "
stats_list = []
- for func, (cc, nc, tt, ct, callers) in self.stats.iteritems():
+ for func, (cc, nc, tt, ct, callers) in self.stats.items():
stats_list.append((cc, nc, tt, ct) + func +
(func_std_string(func), func))
@@ -247,12 +234,12 @@ class Stats:
oldstats = self.stats
self.stats = newstats = {}
max_name_len = 0
- for func, (cc, nc, tt, ct, callers) in oldstats.iteritems():
+ for func, (cc, nc, tt, ct, callers) in oldstats.items():
newfunc = func_strip_path(func)
if len(func_std_string(newfunc)) > max_name_len:
max_name_len = len(func_std_string(newfunc))
newcallers = {}
- for func2, caller in callers.iteritems():
+ for func2, caller in callers.items():
newcallers[func_strip_path(func2)] = caller
if newfunc in newstats:
@@ -262,9 +249,9 @@ class Stats:
else:
newstats[newfunc] = (cc, nc, tt, ct, newcallers)
old_top = self.top_level
- self.top_level = new_top = {}
+ self.top_level = new_top = set()
for func in old_top:
- new_top[func_strip_path(func)] = None
+ new_top.add(func_strip_path(func))
self.max_name_len = max_name_len
@@ -273,12 +260,13 @@ class Stats:
return self
def calc_callees(self):
- if self.all_callees: return
+ if self.all_callees:
+ return
self.all_callees = all_callees = {}
- for func, (cc, nc, tt, ct, callers) in self.stats.iteritems():
+ for func, (cc, nc, tt, ct, callers) in self.stats.items():
if not func in all_callees:
all_callees[func] = {}
- for func2, caller in callers.iteritems():
+ for func2, caller in callers.items():
if not func2 in all_callees:
all_callees[func2] = {}
all_callees[func2][func] = caller
@@ -292,7 +280,7 @@ class Stats:
def eval_print_amount(self, sel, list, msg):
new_list = list
- if isinstance(sel, basestring):
+ if isinstance(sel, str):
try:
rex = re.compile(sel)
except re.error:
@@ -307,7 +295,7 @@ class Stats:
if isinstance(sel, float) and 0.0 <= sel < 1.0:
count = int(count * sel + .5)
new_list = list[:count]
- elif isinstance(sel, (int, long)) and 0 <= sel < count:
+ elif isinstance(sel, int) and 0 <= sel < count:
count = sel
new_list = list[:count]
if len(list) != len(new_list):
@@ -322,7 +310,7 @@ class Stats:
stat_list = self.fcn_list[:]
msg = " Ordered by: " + self.sort_type + '\n'
else:
- stat_list = self.stats.keys()
+ stat_list = list(self.stats.keys())
msg = " Random listing order was used\n"
for selection in sel_list:
@@ -332,7 +320,7 @@ class Stats:
if not stat_list:
return 0, stat_list
- print >> self.stream, msg
+ print(msg, file=self.stream)
if count < len(self.stats):
width = 0
for func in stat_list:
@@ -342,24 +330,25 @@ class Stats:
def print_stats(self, *amount):
for filename in self.files:
- print >> self.stream, filename
- if self.files: print >> self.stream
+ print(filename, file=self.stream)
+ if self.files:
+ print(file=self.stream)
indent = ' ' * 8
for func in self.top_level:
- print >> self.stream, indent, func_get_function_name(func)
+ print(indent, func_get_function_name(func), file=self.stream)
- print >> self.stream, indent, self.total_calls, "function calls",
+ print(indent, self.total_calls, "function calls", end=' ', file=self.stream)
if self.total_calls != self.prim_calls:
- print >> self.stream, "(%d primitive calls)" % self.prim_calls,
- print >> self.stream, "in %.3f seconds" % self.total_tt
- print >> self.stream
+ print("(%d primitive calls)" % self.prim_calls, end=' ', file=self.stream)
+ print("in %.3f seconds" % self.total_tt, file=self.stream)
+ print(file=self.stream)
width, list = self.get_print_list(amount)
if list:
self.print_title()
for func in list:
self.print_line(func)
- print >> self.stream
- print >> self.stream
+ print(file=self.stream)
+ print(file=self.stream)
return self
def print_callees(self, *amount):
@@ -373,8 +362,8 @@ class Stats:
self.print_call_line(width, func, self.all_callees[func])
else:
self.print_call_line(width, func, {})
- print >> self.stream
- print >> self.stream
+ print(file=self.stream)
+ print(file=self.stream)
return self
def print_callers(self, *amount):
@@ -384,29 +373,28 @@ class Stats:
for func in list:
cc, nc, tt, ct, callers = self.stats[func]
self.print_call_line(width, func, callers, "<-")
- print >> self.stream
- print >> self.stream
+ print(file=self.stream)
+ print(file=self.stream)
return self
def print_call_heading(self, name_size, column_title):
- print >> self.stream, "Function ".ljust(name_size) + column_title
+ print("Function ".ljust(name_size) + column_title, file=self.stream)
# print sub-header only if we have new-style callers
subheader = False
- for cc, nc, tt, ct, callers in self.stats.itervalues():
+ for cc, nc, tt, ct, callers in self.stats.values():
if callers:
- value = callers.itervalues().next()
+ value = next(iter(callers.values()))
subheader = isinstance(value, tuple)
break
if subheader:
- print >> self.stream, " "*name_size + " ncalls tottime cumtime"
+ print(" "*name_size + " ncalls tottime cumtime", file=self.stream)
def print_call_line(self, name_size, source, call_dict, arrow="->"):
- print >> self.stream, func_std_string(source).ljust(name_size) + arrow,
+ print(func_std_string(source).ljust(name_size) + arrow, end=' ', file=self.stream)
if not call_dict:
- print >> self.stream
+ print(file=self.stream)
return
- clist = call_dict.keys()
- clist.sort()
+ clist = sorted(call_dict.keys())
indent = ""
for func in clist:
name = func_std_string(func)
@@ -423,30 +411,30 @@ class Stats:
else:
substats = '%s(%r) %s' % (name, value, f8(self.stats[func][3]))
left_width = name_size + 3
- print >> self.stream, indent*left_width + substats
+ print(indent*left_width + substats, file=self.stream)
indent = " "
def print_title(self):
- print >> self.stream, ' ncalls tottime percall cumtime percall',
- print >> self.stream, 'filename:lineno(function)'
+ print(' ncalls tottime percall cumtime percall', end=' ', file=self.stream)
+ print('filename:lineno(function)', file=self.stream)
- def print_line(self, func): # hack : should print percentages
+ def print_line(self, func): # hack: should print percentages
cc, nc, tt, ct, callers = self.stats[func]
c = str(nc)
if nc != cc:
c = c + '/' + str(cc)
- print >> self.stream, c.rjust(9),
- print >> self.stream, f8(tt),
+ print(c.rjust(9), end=' ', file=self.stream)
+ print(f8(tt), end=' ', file=self.stream)
if nc == 0:
- print >> self.stream, ' '*8,
+ print(' '*8, end=' ', file=self.stream)
else:
- print >> self.stream, f8(float(tt)/nc),
- print >> self.stream, f8(ct),
+ print(f8(tt/nc), end=' ', file=self.stream)
+ print(f8(ct), end=' ', file=self.stream)
if cc == 0:
- print >> self.stream, ' '*8,
+ print(' '*8, end=' ', file=self.stream)
else:
- print >> self.stream, f8(float(ct)/cc),
- print >> self.stream, func_std_string(func)
+ print(f8(ct/cc), end=' ', file=self.stream)
+ print(func_std_string(func), file=self.stream)
class TupleComp:
"""This class provides a generic function for comparing any two tuples.
@@ -469,6 +457,7 @@ class TupleComp:
return direction
return 0
+
#**************************************************************************
# func_name is a triple (file:string, line:int, name:string)
@@ -506,9 +495,9 @@ def add_func_stats(target, source):
def add_callers(target, source):
"""Combine two caller lists in a single list."""
new_callers = {}
- for func, caller in target.iteritems():
+ for func, caller in target.items():
new_callers[func] = caller
- for func, caller in source.iteritems():
+ for func, caller in source.items():
if func in new_callers:
if isinstance(caller, tuple):
# format used by cProfile
@@ -524,7 +513,7 @@ def add_callers(target, source):
def count_calls(callers):
"""Sum the caller statistics to get total number of calls received."""
nc = 0
- for calls in callers.itervalues():
+ for calls in callers.values():
nc += calls
return nc
@@ -567,7 +556,7 @@ if __name__ == '__main__':
try:
frac = float(term)
if frac > 1 or frac < 0:
- print >> self.stream, "Fraction argument must be in [0, 1]"
+ print("Fraction argument must be in [0, 1]", file=self.stream)
continue
processed.append(frac)
continue
@@ -577,112 +566,112 @@ if __name__ == '__main__':
if self.stats:
getattr(self.stats, fn)(*processed)
else:
- print >> self.stream, "No statistics object is loaded."
+ print("No statistics object is loaded.", file=self.stream)
return 0
def generic_help(self):
- print >> self.stream, "Arguments may be:"
- print >> self.stream, "* An integer maximum number of entries to print."
- print >> self.stream, "* A decimal fractional number between 0 and 1, controlling"
- print >> self.stream, " what fraction of selected entries to print."
- print >> self.stream, "* A regular expression; only entries with function names"
- print >> self.stream, " that match it are printed."
+ print("Arguments may be:", file=self.stream)
+ print("* An integer maximum number of entries to print.", file=self.stream)
+ print("* A decimal fractional number between 0 and 1, controlling", file=self.stream)
+ print(" what fraction of selected entries to print.", file=self.stream)
+ print("* A regular expression; only entries with function names", file=self.stream)
+ print(" that match it are printed.", file=self.stream)
def do_add(self, line):
if self.stats:
self.stats.add(line)
else:
- print >> self.stream, "No statistics object is loaded."
+ print("No statistics object is loaded.", file=self.stream)
return 0
def help_add(self):
- print >> self.stream, "Add profile info from given file to current statistics object."
+ print("Add profile info from given file to current statistics object.", file=self.stream)
def do_callees(self, line):
return self.generic('print_callees', line)
def help_callees(self):
- print >> self.stream, "Print callees statistics from the current stat object."
+ print("Print callees statistics from the current stat object.", file=self.stream)
self.generic_help()
def do_callers(self, line):
return self.generic('print_callers', line)
def help_callers(self):
- print >> self.stream, "Print callers statistics from the current stat object."
+ print("Print callers statistics from the current stat object.", file=self.stream)
self.generic_help()
def do_EOF(self, line):
- print >> self.stream, ""
+ print("", file=self.stream)
return 1
def help_EOF(self):
- print >> self.stream, "Leave the profile brower."
+ print("Leave the profile brower.", file=self.stream)
def do_quit(self, line):
return 1
def help_quit(self):
- print >> self.stream, "Leave the profile brower."
+ print("Leave the profile brower.", file=self.stream)
def do_read(self, line):
if line:
try:
self.stats = Stats(line)
- except IOError, args:
- print >> self.stream, args[1]
+ except IOError as err:
+ print(err.args[1], file=self.stream)
return
except Exception as err:
- print >> self.stream, err.__class__.__name__ + ':', err
+ print(err.__class__.__name__ + ':', err, file=self.stream)
return
self.prompt = line + "% "
elif len(self.prompt) > 2:
line = self.prompt[:-2]
self.do_read(line)
else:
- print >> self.stream, "No statistics object is current -- cannot reload."
+ print("No statistics object is current -- cannot reload.", file=self.stream)
return 0
def help_read(self):
- print >> self.stream, "Read in profile data from a specified file."
- print >> self.stream, "Without argument, reload the current file."
+ print("Read in profile data from a specified file.", file=self.stream)
+ print("Without argument, reload the current file.", file=self.stream)
def do_reverse(self, line):
if self.stats:
self.stats.reverse_order()
else:
- print >> self.stream, "No statistics object is loaded."
+ print("No statistics object is loaded.", file=self.stream)
return 0
def help_reverse(self):
- print >> self.stream, "Reverse the sort order of the profiling report."
+ print("Reverse the sort order of the profiling report.", file=self.stream)
def do_sort(self, line):
if not self.stats:
- print >> self.stream, "No statistics object is loaded."
+ print("No statistics object is loaded.", file=self.stream)
return
abbrevs = self.stats.get_sort_arg_defs()
if line and all((x in abbrevs) for x in line.split()):
self.stats.sort_stats(*line.split())
else:
- print >> self.stream, "Valid sort keys (unique prefixes are accepted):"
- for (key, value) in Stats.sort_arg_dict_default.iteritems():
- print >> self.stream, "%s -- %s" % (key, value[1])
+ print("Valid sort keys (unique prefixes are accepted):", file=self.stream)
+ for (key, value) in Stats.sort_arg_dict_default.items():
+ print("%s -- %s" % (key, value[1]), file=self.stream)
return 0
def help_sort(self):
- print >> self.stream, "Sort profile data according to specified keys."
- print >> self.stream, "(Typing `sort' without arguments lists valid keys.)"
+ print("Sort profile data according to specified keys.", file=self.stream)
+ print("(Typing `sort' without arguments lists valid keys.)", file=self.stream)
def complete_sort(self, text, *args):
return [a for a in Stats.sort_arg_dict_default if a.startswith(text)]
def do_stats(self, line):
return self.generic('print_stats', line)
def help_stats(self):
- print >> self.stream, "Print statistics from the current stat object."
+ print("Print statistics from the current stat object.", file=self.stream)
self.generic_help()
def do_strip(self, line):
if self.stats:
self.stats.strip_dirs()
else:
- print >> self.stream, "No statistics object is loaded."
+ print("No statistics object is loaded.", file=self.stream)
def help_strip(self):
- print >> self.stream, "Strip leading path information from filenames in the report."
+ print("Strip leading path information from filenames in the report.", file=self.stream)
def help_help(self):
- print >> self.stream, "Show help for a given command."
+ print("Show help for a given command.", file=self.stream)
def postcmd(self, stop, line):
if stop:
@@ -696,9 +685,9 @@ if __name__ == '__main__':
initprofile = None
try:
browser = ProfileBrowser(initprofile)
- print >> browser.stream, "Welcome to the profile statistics browser."
+ print("Welcome to the profile statistics browser.", file=browser.stream)
browser.cmdloop()
- print >> browser.stream, "Goodbye."
+ print("Goodbye.", file=browser.stream)
except KeyboardInterrupt:
pass
diff --git a/Lib/pty.py b/Lib/pty.py
index 05ff6860c1b..3ccf619896c 100644
--- a/Lib/pty.py
+++ b/Lib/pty.py
@@ -55,9 +55,9 @@ def _open_terminal():
pass
else:
try:
- tty_name, master_fd = sgi._getpty(os.O_RDWR, 0666, 0)
- except IOError, msg:
- raise os.error, msg
+ tty_name, master_fd = sgi._getpty(os.O_RDWR, 0o666, 0)
+ except IOError as msg:
+ raise os.error(msg)
return master_fd, tty_name
for x in 'pqrstuvwxyzPQRST':
for y in '0123456789abcdef':
@@ -67,7 +67,7 @@ def _open_terminal():
except os.error:
continue
return (fd, '/dev/tty' + x + y)
- raise os.error, 'out of pty devices'
+ raise os.error('out of pty devices')
def slave_open(tty_name):
"""slave_open(tty_name) -> slave_fd
@@ -129,7 +129,7 @@ def fork():
def _writen(fd, data):
"""Write all the data to a descriptor."""
- while data != '':
+ while data:
n = os.write(fd, data)
data = data[n:]
diff --git a/Lib/py_compile.py b/Lib/py_compile.py
index dc1cae98dd9..5adb70a2939 100644
--- a/Lib/py_compile.py
+++ b/Lib/py_compile.py
@@ -3,11 +3,13 @@
This module has intimate knowledge of the format of .pyc files.
"""
-import __builtin__
+import builtins
+import errno
import imp
import marshal
import os
import sys
+import tokenize
import traceback
MAGIC = imp.get_magic()
@@ -36,16 +38,18 @@ class PyCompileError(Exception):
can be accesses as class variable 'file'
msg: string message to be written as error message
- If no value is given, a default exception message will be given,
- consistent with 'standard' py_compile output.
- message (or default) can be accesses as class variable 'msg'
+ If no value is given, a default exception message will be
+ given, consistent with 'standard' py_compile output.
+ message (or default) can be accesses as class variable
+ 'msg'
"""
def __init__(self, exc_type, exc_value, file, msg=''):
exc_type_name = exc_type.__name__
if exc_type is SyntaxError:
- tbtext = ''.join(traceback.format_exception_only(exc_type, exc_value))
+ tbtext = ''.join(traceback.format_exception_only(
+ exc_type, exc_value))
errmsg = tbtext.replace('File "<string>"', 'File "%s"' % file)
else:
errmsg = "Sorry: %s: %s" % (exc_type_name,exc_value)
@@ -63,28 +67,30 @@ class PyCompileError(Exception):
def wr_long(f, x):
"""Internal; write a 32-bit int to a file in little-endian order."""
- f.write(chr( x & 0xff))
- f.write(chr((x >> 8) & 0xff))
- f.write(chr((x >> 16) & 0xff))
- f.write(chr((x >> 24) & 0xff))
+ f.write(bytes([x & 0xff,
+ (x >> 8) & 0xff,
+ (x >> 16) & 0xff,
+ (x >> 24) & 0xff]))
-def compile(file, cfile=None, dfile=None, doraise=False):
+def compile(file, cfile=None, dfile=None, doraise=False, optimize=-1):
"""Byte-compile one Python source file to Python bytecode.
- Arguments:
-
- file: source filename
- cfile: target filename; defaults to source with 'c' or 'o' appended
- ('c' normally, 'o' in optimizing mode, giving .pyc or .pyo)
- dfile: purported filename; defaults to source (this is the filename
- that will show up in error messages)
- doraise: flag indicating whether or not an exception should be
- raised when a compile error is found. If an exception
- occurs and this flag is set to False, a string
- indicating the nature of the exception will be printed,
- and the function will return to the caller. If an
- exception occurs and this flag is set to True, a
- PyCompileError exception will be raised.
+ :param file: The source file name.
+ :param cfile: The target byte compiled file name. When not given, this
+ defaults to the PEP 3147 location.
+ :param dfile: Purported file name, i.e. the file name that shows up in
+ error messages. Defaults to the source file name.
+ :param doraise: Flag indicating whether or not an exception should be
+ raised when a compile error is found. If an exception occurs and this
+ flag is set to False, a string indicating the nature of the exception
+ will be printed, and the function will return to the caller. If an
+ exception occurs and this flag is set to True, a PyCompileError
+ exception will be raised.
+ :param optimize: The optimization level for the compiler. Valid values
+ are -1, 0, 1 and 2. A value of -1 means to use the optimization
+ level of the current interpreter, as given by -O command line options.
+
+ :return: Path to the resulting byte compiled file.
Note that it isn't necessary to byte-compile Python modules for
execution efficiency -- Python itself byte-compiles a module when
@@ -101,32 +107,43 @@ def compile(file, cfile=None, dfile=None, doraise=False):
See compileall.py for a script/module that uses this module to
byte-compile all installed files (or all files in selected
directories).
-
"""
- with open(file, 'U') as f:
+ with tokenize.open(file) as f:
try:
- timestamp = long(os.fstat(f.fileno()).st_mtime)
+ timestamp = int(os.fstat(f.fileno()).st_mtime)
except AttributeError:
- timestamp = long(os.stat(file).st_mtime)
+ timestamp = int(os.stat(file).st_mtime)
codestring = f.read()
try:
- codeobject = __builtin__.compile(codestring, dfile or file,'exec')
- except Exception,err:
- py_exc = PyCompileError(err.__class__,err.args,dfile or file)
+ codeobject = builtins.compile(codestring, dfile or file, 'exec',
+ optimize=optimize)
+ except Exception as err:
+ py_exc = PyCompileError(err.__class__, err, dfile or file)
if doraise:
raise py_exc
else:
sys.stderr.write(py_exc.msg + '\n')
return
if cfile is None:
- cfile = file + (__debug__ and 'c' or 'o')
+ if optimize >= 0:
+ cfile = imp.cache_from_source(file, debug_override=not optimize)
+ else:
+ cfile = imp.cache_from_source(file)
+ try:
+ dirname = os.path.dirname(cfile)
+ if dirname:
+ os.makedirs(dirname)
+ except OSError as error:
+ if error.errno != errno.EEXIST:
+ raise
with open(cfile, 'wb') as fc:
- fc.write('\0\0\0\0')
+ fc.write(b'\0\0\0\0')
wr_long(fc, timestamp)
marshal.dump(codeobject, fc)
fc.flush()
fc.seek(0, 0)
fc.write(MAGIC)
+ return cfile
def main(args=None):
"""Compile several source files.
diff --git a/Lib/pyclbr.py b/Lib/pyclbr.py
index b8f71ae6b64..65e9fbedfdd 100644
--- a/Lib/pyclbr.py
+++ b/Lib/pyclbr.py
@@ -163,7 +163,7 @@ def _readmodule(module, path, inpackage=None):
# close previous nested classes and defs
while stack and stack[-1][1] >= thisindent:
del stack[-1]
- tokentype, meth_name, start = g.next()[0:3]
+ tokentype, meth_name, start = next(g)[0:3]
if tokentype != NAME:
continue # Syntax error
if stack:
@@ -182,11 +182,11 @@ def _readmodule(module, path, inpackage=None):
# close previous nested classes and defs
while stack and stack[-1][1] >= thisindent:
del stack[-1]
- tokentype, class_name, start = g.next()[0:3]
+ tokentype, class_name, start = next(g)[0:3]
if tokentype != NAME:
continue # Syntax error
# parse what follows the class name
- tokentype, token, start = g.next()[0:3]
+ tokentype, token, start = next(g)[0:3]
inherit = None
if token == '(':
names = [] # List of superclasses
@@ -194,7 +194,7 @@ def _readmodule(module, path, inpackage=None):
level = 1
super = [] # Tokens making up current superclass
while True:
- tokentype, token, start = g.next()[0:3]
+ tokentype, token, start = next(g)[0:3]
if token in (')', ',') and level == 1:
n = "".join(super)
if n in dict:
@@ -291,7 +291,7 @@ def _getnamelist(g):
name2 = None
names.append((name, name2))
while token != "," and "\n" not in token:
- token = g.next()[1]
+ token = next(g)[1]
if token != ",":
break
return names
@@ -301,15 +301,15 @@ def _getname(g):
# name is the dotted name, or None if there was no dotted name,
# and token is the next input token.
parts = []
- tokentype, token = g.next()[0:2]
+ tokentype, token = next(g)[0:2]
if tokentype != NAME and token != '*':
return (None, token)
parts.append(token)
while True:
- tokentype, token = g.next()[0:2]
+ tokentype, token = next(g)[0:2]
if token != '.':
break
- tokentype, token = g.next()[0:2]
+ tokentype, token = next(g)[0:2]
if tokentype != NAME:
break
parts.append(token)
@@ -327,18 +327,17 @@ def _main():
else:
path = []
dict = readmodule_ex(mod, path)
- objs = dict.values()
- objs.sort(lambda a, b: cmp(getattr(a, 'lineno', 0),
- getattr(b, 'lineno', 0)))
+ objs = list(dict.values())
+ objs.sort(key=lambda a: getattr(a, 'lineno', 0))
for obj in objs:
if isinstance(obj, Class):
- print "class", obj.name, obj.super, obj.lineno
- methods = sorted(obj.methods.iteritems(), key=itemgetter(1))
+ print("class", obj.name, obj.super, obj.lineno)
+ methods = sorted(obj.methods.items(), key=itemgetter(1))
for name, lineno in methods:
if name != "__path__":
- print " def", name, lineno
+ print(" def", name, lineno)
elif isinstance(obj, Function):
- print "def", obj.name, obj.lineno
+ print("def", obj.name, obj.lineno)
if __name__ == "__main__":
_main()
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 68ba21f30fc..37616fb3edd 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1,5 +1,4 @@
-#!/usr/bin/env python
-# -*- coding: latin-1 -*-
+#!/usr/bin/env python3
"""Generate Python documentation in HTML or text for interactive use.
In the Python interpreter, do "from pydoc import help" to provide online
@@ -16,28 +15,34 @@ backslash on Windows) it is treated as the path to a Python source file.
Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
of all available modules.
-Run "pydoc -p <port>" to start an HTTP server on a given port on the
-local machine to generate documentation web pages.
+Run "pydoc -p <port>" to start an HTTP server on the given port on the
+local machine. Port number 0 can be used to get an arbitrary unused port.
+
+Run "pydoc -b" to start an HTTP server on an arbitrary unused port and
+open a Web browser to interactively browse documentation. The -p option
+can be used with the -b option to explicitly specify the server port.
For platforms without a command line, "pydoc -g" starts the HTTP server
-and also pops up a little window for controlling it.
+and also pops up a little window for controlling it. This option is
+deprecated, since the server can now be controlled directly from HTTP
+clients.
Run "pydoc -w <name>" to write out the HTML documentation for a module
to a file named "<name>.html".
Module docs for core modules are assumed to be in
- http://docs.python.org/library/
+ http://docs.python.org/X.Y/library/
This can be overridden by setting the PYTHONDOCS environment variable
to a different URL or to a local directory containing the Library
Reference Manual pages.
"""
-
+__all__ = ['help']
__author__ = "Ka-Ping Yee <ping@lfw.org>"
__date__ = "26 February 2001"
-__version__ = "$Revision: 88564 $"
+__version__ = "$Revision$"
__credits__ = """Guido van Rossum, for an excellent programming language.
Tommy Burnette, the original creator of manpy.
Paul Prescod, for all his work on onlinehelp.
@@ -52,17 +57,22 @@ Richard Chamberlain, for the first implementation of textdoc.
# the current directory is changed with os.chdir(), an incorrect
# path will be displayed.
-import sys, imp, os, re, types, inspect, __builtin__, pkgutil, warnings
-from repr import Repr
-from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
-from traceback import extract_tb
-try:
- from collections import deque
-except ImportError:
- # Python 2.3 compatibility
- class deque(list):
- def popleft(self):
- return self.pop(0)
+import builtins
+import imp
+import inspect
+import io
+import os
+import pkgutil
+import platform
+import re
+import sys
+import time
+import tokenize
+import warnings
+from collections import deque
+from reprlib import Repr
+from traceback import extract_tb, format_exception_only
+
# --------------------------------------------------------- common routines
@@ -81,16 +91,16 @@ def pathdirs():
def getdoc(object):
"""Get the doc string or comments for an object."""
result = inspect.getdoc(object) or inspect.getcomments(object)
- return result and re.sub('^ *\n', '', rstrip(result)) or ''
+ return result and re.sub('^ *\n', '', result.rstrip()) or ''
def splitdoc(doc):
"""Split a doc string into a synopsis line (if any) and the rest."""
- lines = split(strip(doc), '\n')
+ lines = doc.strip().split('\n')
if len(lines) == 1:
return lines[0], ''
- elif len(lines) >= 2 and not rstrip(lines[1]):
- return lines[0], join(lines[2:], '\n')
- return '', join(lines, '\n')
+ elif len(lines) >= 2 and not lines[1].rstrip():
+ return lines[0], '\n'.join(lines[2:])
+ return '', '\n'.join(lines)
def classname(object, modname):
"""Get a class name and qualify it with a module name if necessary."""
@@ -108,7 +118,7 @@ def isdata(object):
def replace(text, *pairs):
"""Do a series of global replacements on a string."""
while pairs:
- text = join(split(text, pairs[0]), pairs[1])
+ text = pairs[1].join(text.split(pairs[0]))
pairs = pairs[2:]
return text
@@ -160,13 +170,15 @@ def visiblename(name, all=None, obj=None):
"""Decide whether to show documentation on a variable."""
# Certain special names are redundant.
_hidden_names = ('__builtins__', '__doc__', '__file__', '__path__',
- '__module__', '__name__', '__slots__', '__package__')
+ '__module__', '__name__', '__slots__', '__package__',
+ '__cached__', '__author__', '__credits__', '__date__',
+ '__version__')
if name in _hidden_names: return 0
# Private names are hidden, but special names are displayed.
if name.startswith('__') and name.endswith('__'): return 1
# Namedtuples have public fields and methods with a single leading underscore
if name.startswith('_') and hasattr(obj, '_fields'):
- return 1
+ return True
if all is not None:
# only document that which the programmer exported in __all__
return name in all
@@ -175,12 +187,12 @@ def visiblename(name, all=None, obj=None):
def classify_class_attrs(object):
"""Wrap inspect.classify_class_attrs, with fixup for data descriptors."""
- def fixup(data):
- name, kind, cls, value = data
+ results = []
+ for (name, kind, cls, value) in inspect.classify_class_attrs(object):
if inspect.isdatadescriptor(value):
kind = 'data descriptor'
- return name, kind, cls, value
- return map(fixup, inspect.classify_class_attrs(object))
+ results.append((name, kind, cls, value))
+ return results
# ----------------------------------------------------- module manipulation
@@ -194,18 +206,18 @@ def ispackage(path):
def source_synopsis(file):
line = file.readline()
- while line[:1] == '#' or not strip(line):
+ while line[:1] == '#' or not line.strip():
line = file.readline()
if not line: break
- line = strip(line)
+ line = line.strip()
if line[:4] == 'r"""': line = line[1:]
if line[:3] == '"""':
line = line[3:]
if line[-1:] == '\\': line = line[:-1]
- while not strip(line):
+ while not line.strip():
line = file.readline()
if not line: break
- result = strip(split(line, '"""')[0])
+ result = line.split('"""')[0].strip()
else: result = None
return result
@@ -216,7 +228,7 @@ def synopsis(filename, cache={}):
if lastupdate is None or lastupdate < mtime:
info = inspect.getmoduleinfo(filename)
try:
- file = open(filename)
+ file = tokenize.open(filename)
except IOError:
# module can't be opened, so skip it
return None
@@ -234,35 +246,28 @@ def synopsis(filename, cache={}):
class ErrorDuringImport(Exception):
"""Errors that occurred while trying to import something to document it."""
def __init__(self, filename, exc_info):
- exc, value, tb = exc_info
self.filename = filename
- self.exc = exc
- self.value = value
- self.tb = tb
+ self.exc, self.value, self.tb = exc_info
def __str__(self):
- exc = self.exc
- if type(exc) is types.ClassType:
- exc = exc.__name__
+ exc = self.exc.__name__
return 'problem in %s - %s: %s' % (self.filename, exc, self.value)
def importfile(path):
"""Import a Python source file or compiled file given its path."""
magic = imp.get_magic()
- file = open(path, 'r')
- if file.read(len(magic)) == magic:
- kind = imp.PY_COMPILED
- else:
- kind = imp.PY_SOURCE
- file.close()
- filename = os.path.basename(path)
- name, ext = os.path.splitext(filename)
- file = open(path, 'r')
- try:
- module = imp.load_module(name, file, path, (ext, 'r', kind))
- except:
- raise ErrorDuringImport(path, sys.exc_info())
- file.close()
+ with open(path, 'rb') as file:
+ if file.read(len(magic)) == magic:
+ kind = imp.PY_COMPILED
+ else:
+ kind = imp.PY_SOURCE
+ file.seek(0)
+ filename = os.path.basename(path)
+ name, ext = os.path.splitext(filename)
+ try:
+ module = imp.load_module(name, file, path, (ext, 'r', kind))
+ except:
+ raise ErrorDuringImport(path, sys.exc_info())
return module
def safeimport(path, forceload=0, cache={}):
@@ -280,12 +285,11 @@ def safeimport(path, forceload=0, cache={}):
# that inherits from another module that has changed).
if forceload and path in sys.modules:
if path not in sys.builtin_module_names:
- # Avoid simply calling reload() because it leaves names in
- # the currently loaded module lying around if they're not
- # defined in the new source file. Instead, remove the
- # module from sys.modules and re-import. Also remove any
- # submodules because they won't appear in the newly loaded
- # module's namespace if they're already in sys.modules.
+ # Remove the module from sys.modules and re-import to try
+ # and avoid problems with partially loaded modules.
+ # Also remove any submodules because they won't appear
+ # in the newly loaded module's namespace if they're already
+ # in sys.modules.
subs = [m for m in sys.modules if m.startswith(path + '.')]
for key in [path] + subs:
# Prevent garbage collection.
@@ -308,7 +312,7 @@ def safeimport(path, forceload=0, cache={}):
else:
# Some other error occurred during the importing process.
raise ErrorDuringImport(path, sys.exc_info())
- for part in split(path, '.')[1:]:
+ for part in path.split('.')[1:]:
try: module = getattr(module, part)
except AttributeError: return None
return module
@@ -316,6 +320,11 @@ def safeimport(path, forceload=0, cache={}):
# ---------------------------------------------------- formatter base class
class Doc:
+
+ PYTHONDOCS = os.environ.get("PYTHONDOCS",
+ "http://docs.python.org/%d.%d/library"
+ % sys.version_info[:2])
+
def document(self, object, name=None, *args):
"""Generate documentation for an object."""
args = (object, name) + args
@@ -338,7 +347,7 @@ class Doc:
"""Raise an exception for unimplemented types."""
message = "don't know how to document object%s of type %s" % (
name and ' ' + repr(name), type(object).__name__)
- raise TypeError, message
+ raise TypeError(message)
docmodule = docclass = docroutine = docother = docproperty = docdata = fail
@@ -350,14 +359,14 @@ class Doc:
except TypeError:
file = '(built-in)'
- docloc = os.environ.get("PYTHONDOCS",
- "http://docs.python.org/library")
+ docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS)
+
basedir = os.path.join(sys.exec_prefix, "lib",
- "python"+sys.version[0:3])
+ "python%d.%d" % sys.version_info[:2])
if (isinstance(object, type(os)) and
(object.__name__ in ('errno', 'exceptions', 'gc', 'imp',
'marshal', 'posix', 'signal', 'sys',
- 'thread', 'zipimport') or
+ '_thread', 'zipimport') or
(file.startswith(basedir) and
not file.startswith(os.path.join(basedir, 'site-packages')))) and
object.__name__ not in ('xml.etree', 'test.pydoc_mod')):
@@ -387,7 +396,7 @@ class HTMLRepr(Repr):
def repr1(self, x, level):
if hasattr(type(x), '__name__'):
- methodname = 'repr_' + join(split(type(x).__name__), '_')
+ methodname = 'repr_' + '_'.join(type(x).__name__.split())
if hasattr(self, methodname):
return getattr(self, methodname)(x, level)
return self.escape(cram(stripid(repr(x)), self.maxother))
@@ -424,9 +433,10 @@ class HTMLDoc(Doc):
def page(self, title, contents):
"""Format an HTML page."""
- return '''
+ return '''\
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: %s</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head><body bgcolor="#f0f0f8">
%s
</body></html>''' % (title, contents)
@@ -471,7 +481,7 @@ class HTMLDoc(Doc):
def preformat(self, text):
"""Format literal preformatted text."""
- text = self.escape(expandtabs(text))
+ text = self.escape(text.expandtabs())
return replace(text, '\n\n', '\n \n', '\n\n', '\n \n',
' ', '&nbsp;', '\n', '<br>\n')
@@ -508,9 +518,9 @@ class HTMLDoc(Doc):
"""Make a link for a module."""
return '<a href="%s.html">%s</a>' % (object.__name__, object.__name__)
- def modpkglink(self, data):
+ def modpkglink(self, modpkginfo):
"""Make a link for a module or package to display in an index."""
- name, path, ispackage, shadowed = data
+ name, path, ispackage, shadowed = modpkginfo
if shadowed:
return self.grey(name)
if path:
@@ -523,6 +533,10 @@ class HTMLDoc(Doc):
text = name
return '<a href="%s">%s</a>' % (url, text)
+ def filelink(self, url, path):
+ """Make a link to source file."""
+ return '<a href="file:%s">%s</a>' % (url, path)
+
def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
"""Mark up some plain text, given a context of symbols to look for.
Each context dictionary maps object names to anchor names."""
@@ -557,7 +571,7 @@ class HTMLDoc(Doc):
results.append(self.namelink(name, classes))
here = end
results.append(escape(text[here:]))
- return join(results, '')
+ return ''.join(results)
# ---------------------------------------------- type-specific routines
@@ -573,7 +587,7 @@ class HTMLDoc(Doc):
parents = []
for base in bases:
parents.append(self.classlink(base, modname))
- result = result + '(' + join(parents, ', ') + ')'
+ result = result + '(' + ', '.join(parents) + ')'
result = result + '\n</font></dt>'
elif type(entry) is type([]):
result = result + '<dd>\n%s</dd>\n' % self.formattree(
@@ -587,13 +601,13 @@ class HTMLDoc(Doc):
all = object.__all__
except AttributeError:
all = None
- parts = split(name, '.')
+ parts = name.split('.')
links = []
for i in range(len(parts)-1):
links.append(
'<a href="%s.html"><font color="#ffffff">%s</font></a>' %
- (join(parts[:i+1], '.'), parts[i]))
- linkedname = join(links + parts[-1:], '.')
+ ('.'.join(parts[:i+1]), parts[i]))
+ linkedname = '.'.join(links + parts[-1:])
head = '<big><big><strong>%s</strong></big></big>' % linkedname
try:
path = inspect.getabsfile(object)
@@ -601,22 +615,22 @@ class HTMLDoc(Doc):
if sys.platform == 'win32':
import nturl2path
url = nturl2path.pathname2url(path)
- filelink = '<a href="file:%s">%s</a>' % (url, path)
+ filelink = self.filelink(url, path)
except TypeError:
filelink = '(built-in)'
info = []
if hasattr(object, '__version__'):
version = str(object.__version__)
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
- version = strip(version[11:-1])
+ version = version[11:-1].strip()
info.append('version %s' % self.escape(version))
if hasattr(object, '__date__'):
info.append(self.escape(str(object.__date__)))
if info:
- head = head + ' (%s)' % join(info, ', ')
+ head = head + ' (%s)' % ', '.join(info)
docloc = self.getdocloc(object)
if docloc is not None:
- docloc = '<br><a href="%(docloc)s">Module Docs</a>' % locals()
+ docloc = '<br><a href="%(docloc)s">Module Reference</a>' % locals()
else:
docloc = ''
result = self.heading(
@@ -669,30 +683,30 @@ class HTMLDoc(Doc):
'Package Contents', '#ffffff', '#aa55cc', contents)
elif modules:
contents = self.multicolumn(
- modules, lambda key_value, s=self: s.modulelink(key_value[1]))
+ modules, lambda t: self.modulelink(t[1]))
result = result + self.bigsection(
'Modules', '#ffffff', '#aa55cc', contents)
if classes:
- classlist = map(lambda key_value: key_value[1], classes)
+ classlist = [value for (key, value) in classes]
contents = [
self.formattree(inspect.getclasstree(classlist, 1), name)]
for key, value in classes:
contents.append(self.document(value, key, name, fdict, cdict))
result = result + self.bigsection(
- 'Classes', '#ffffff', '#ee77aa', join(contents))
+ 'Classes', '#ffffff', '#ee77aa', ' '.join(contents))
if funcs:
contents = []
for key, value in funcs:
contents.append(self.document(value, key, name, fdict, cdict))
result = result + self.bigsection(
- 'Functions', '#ffffff', '#eeaa77', join(contents))
+ 'Functions', '#ffffff', '#eeaa77', ' '.join(contents))
if data:
contents = []
for key, value in data:
contents.append(self.document(value, key))
result = result + self.bigsection(
- 'Data', '#ffffff', '#55aa55', join(contents, '<br>\n'))
+ 'Data', '#ffffff', '#55aa55', '<br>\n'.join(contents))
if hasattr(object, '__author__'):
contents = self.markup(str(object.__author__), self.preformat)
result = result + self.bigsection(
@@ -768,8 +782,7 @@ class HTMLDoc(Doc):
push(msg)
for name, kind, homecls, value in ok:
base = self.docother(getattr(object, name), name, mod)
- if (hasattr(value, '__call__') or
- inspect.isdatadescriptor(value)):
+ if callable(value) or inspect.isdatadescriptor(value):
doc = getattr(value, "__doc__", None)
else:
doc = None
@@ -783,8 +796,10 @@ class HTMLDoc(Doc):
push('\n')
return attrs
- attrs = filter(lambda data: visiblename(data[0], obj=object),
- classify_class_attrs(object))
+ attrs = [(name, kind, cls, value)
+ for name, kind, cls, value in classify_class_attrs(object)
+ if visiblename(name, obj=object)]
+
mdict = {}
for key, kind, homecls, value in attrs:
mdict[key] = anchor = '#' + name + '-' + key
@@ -808,7 +823,7 @@ class HTMLDoc(Doc):
thisclass = attrs[0][2]
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
- if thisclass is __builtin__.object:
+ if thisclass is builtins.object:
attrs = inherited
continue
elif thisclass is object:
@@ -819,10 +834,7 @@ class HTMLDoc(Doc):
tag += ':<br>\n'
# Sort attrs by name.
- try:
- attrs.sort(key=lambda t: t[0])
- except TypeError:
- attrs.sort(lambda t1, t2: cmp(t1[0], t2[0])) # 2.3 compat
+ attrs.sort(key=lambda t: t[0])
# Pump out the attrs, segregated by kind.
attrs = spill('Methods %s' % tag, attrs,
@@ -850,7 +862,7 @@ class HTMLDoc(Doc):
parents = []
for base in bases:
parents.append(self.classlink(base, object.__module__))
- title = title + '(%s)' % join(parents, ', ')
+ title = title + '(%s)' % ', '.join(parents)
doc = self.markup(getdoc(object), self.preformat, funcs, classes, mdict)
doc = doc and '<tt>%s<br>&nbsp;</tt>' % doc
@@ -869,17 +881,17 @@ class HTMLDoc(Doc):
note = ''
skipdocs = 0
if inspect.ismethod(object):
- imclass = object.im_class
+ imclass = object.__self__.__class__
if cl:
if imclass is not cl:
note = ' from ' + self.classlink(imclass, mod)
else:
- if object.im_self is not None:
+ if object.__self__ is not None:
note = ' method of %s instance' % self.classlink(
- object.im_self.__class__, mod)
+ object.__self__.__class__, mod)
else:
note = ' unbound %s method' % self.classlink(imclass,mod)
- object = object.im_func
+ object = object.__func__
if name == realname:
title = '<a name="%s"><strong>%s</strong></a>' % (anchor, realname)
@@ -894,11 +906,17 @@ class HTMLDoc(Doc):
title = '<a name="%s"><strong>%s</strong></a> = %s' % (
anchor, name, reallink)
if inspect.isfunction(object):
- args, varargs, varkw, defaults = inspect.getargspec(object)
+ args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann = \
+ inspect.getfullargspec(object)
argspec = inspect.formatargspec(
- args, varargs, varkw, defaults, formatvalue=self.formatvalue)
+ args, varargs, kwonlyargs, kwdefaults, varkw, defaults, ann,
+ formatvalue=self.formatvalue,
+ formatannotation=inspect.formatannotationrelativeto(object))
if realname == '<lambda>':
title = '<strong>%s</strong> <em>lambda</em> ' % name
+ # XXX lambda's won't usually have func_annotations['return']
+ # since the syntax doesn't support but it is possible.
+ # So removing parentheses isn't truly safe.
argspec = argspec[1:-1] # remove parentheses
else:
argspec = '(...)'
@@ -964,7 +982,7 @@ class TextRepr(Repr):
def repr1(self, x, level):
if hasattr(type(x), '__name__'):
- methodname = 'repr_' + join(split(type(x).__name__), '_')
+ methodname = 'repr_' + '_'.join(type(x).__name__.split())
if hasattr(self, methodname):
return getattr(self, methodname)(x, level)
return cram(stripid(repr(x)), self.maxother)
@@ -996,19 +1014,19 @@ class TextDoc(Doc):
def bold(self, text):
"""Format a string in bold by overstriking."""
- return join(map(lambda ch: ch + '\b' + ch, text), '')
+ return ''.join(ch + '\b' + ch for ch in text)
def indent(self, text, prefix=' '):
"""Indent text by prepending a given prefix to each line."""
if not text: return ''
- lines = split(text, '\n')
- lines = map(lambda line, prefix=prefix: prefix + line, lines)
- if lines: lines[-1] = rstrip(lines[-1])
- return join(lines, '\n')
+ lines = [prefix + line for line in text.split('\n')]
+ if lines: lines[-1] = lines[-1].rstrip()
+ return '\n'.join(lines)
def section(self, title, contents):
"""Format a section with a given heading."""
- return self.bold(title) + '\n' + rstrip(self.indent(contents)) + '\n\n'
+ clean_contents = self.indent(contents).rstrip()
+ return self.bold(title) + '\n' + clean_contents + '\n\n'
# ---------------------------------------------- type-specific routines
@@ -1020,8 +1038,8 @@ class TextDoc(Doc):
c, bases = entry
result = result + prefix + classname(c, modname)
if bases and bases != (parent,):
- parents = map(lambda c, m=modname: classname(c, m), bases)
- result = result + '(%s)' % join(parents, ', ')
+ parents = (classname(c, modname) for c in bases)
+ result = result + '(%s)' % ', '.join(parents)
result = result + '\n'
elif type(entry) is type([]):
result = result + self.formattree(
@@ -1033,21 +1051,17 @@ class TextDoc(Doc):
name = object.__name__ # ignore the passed-in name
synop, desc = splitdoc(getdoc(object))
result = self.section('NAME', name + (synop and ' - ' + synop))
-
- try:
- all = object.__all__
- except AttributeError:
- all = None
-
- try:
- file = inspect.getabsfile(object)
- except TypeError:
- file = '(built-in)'
- result = result + self.section('FILE', file)
-
+ all = getattr(object, '__all__', None)
docloc = self.getdocloc(object)
if docloc is not None:
- result = result + self.section('MODULE DOCS', docloc)
+ result = result + self.section('MODULE REFERENCE', docloc + """
+
+The following documentation is automatically generated from the Python
+source files. It may be incomplete, incorrect or include features that
+are considered implementation detail and may vary between Python
+implementations. When in doubt, consult the module reference at the
+location listed above.
+""")
if desc:
result = result + self.section('DESCRIPTION', desc)
@@ -1083,7 +1097,7 @@ class TextDoc(Doc):
modpkgs.sort()
result = result + self.section(
- 'PACKAGE CONTENTS', join(modpkgs, '\n'))
+ 'PACKAGE CONTENTS', '\n'.join(modpkgs))
# Detect submodules as sometimes created by C extensions
submodules = []
@@ -1093,32 +1107,32 @@ class TextDoc(Doc):
if submodules:
submodules.sort()
result = result + self.section(
- 'SUBMODULES', join(submodules, '\n'))
+ 'SUBMODULES', '\n'.join(submodules))
if classes:
- classlist = map(lambda key_value: key_value[1], classes)
+ classlist = [value for key, value in classes]
contents = [self.formattree(
inspect.getclasstree(classlist, 1), name)]
for key, value in classes:
contents.append(self.document(value, key, name))
- result = result + self.section('CLASSES', join(contents, '\n'))
+ result = result + self.section('CLASSES', '\n'.join(contents))
if funcs:
contents = []
for key, value in funcs:
contents.append(self.document(value, key, name))
- result = result + self.section('FUNCTIONS', join(contents, '\n'))
+ result = result + self.section('FUNCTIONS', '\n'.join(contents))
if data:
contents = []
for key, value in data:
contents.append(self.docother(value, key, name, maxlen=70))
- result = result + self.section('DATA', join(contents, '\n'))
+ result = result + self.section('DATA', '\n'.join(contents))
if hasattr(object, '__version__'):
version = str(object.__version__)
if version[:11] == '$' + 'Revision: ' and version[-1:] == '$':
- version = strip(version[11:-1])
+ version = version[11:-1].strip()
result = result + self.section('VERSION', version)
if hasattr(object, '__date__'):
result = result + self.section('DATE', str(object.__date__))
@@ -1126,6 +1140,11 @@ class TextDoc(Doc):
result = result + self.section('AUTHOR', str(object.__author__))
if hasattr(object, '__credits__'):
result = result + self.section('CREDITS', str(object.__credits__))
+ try:
+ file = inspect.getabsfile(object)
+ except TypeError:
+ file = '(built-in)'
+ result = result + self.section('FILE', file)
return result
def docclass(self, object, name=None, mod=None, *ignored):
@@ -1143,7 +1162,7 @@ class TextDoc(Doc):
title = self.bold(name) + ' = class ' + realname
if bases:
parents = map(makename, bases)
- title = title + '(%s)' % join(parents, ', ')
+ title = title + '(%s)' % ', '.join(parents)
doc = getdoc(object)
contents = doc and [doc + '\n'] or []
@@ -1199,8 +1218,7 @@ class TextDoc(Doc):
hr.maybe()
push(msg)
for name, kind, homecls, value in ok:
- if (hasattr(value, '__call__') or
- inspect.isdatadescriptor(value)):
+ if callable(value) or inspect.isdatadescriptor(value):
doc = getdoc(value)
else:
doc = None
@@ -1208,8 +1226,10 @@ class TextDoc(Doc):
name, mod, maxlen=70, doc=doc) + '\n')
return attrs
- attrs = filter(lambda data: visiblename(data[0], obj=object),
- classify_class_attrs(object))
+ attrs = [(name, kind, cls, value)
+ for name, kind, cls, value in classify_class_attrs(object)
+ if visiblename(name, obj=object)]
+
while attrs:
if mro:
thisclass = mro.popleft()
@@ -1217,7 +1237,7 @@ class TextDoc(Doc):
thisclass = attrs[0][2]
attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass)
- if thisclass is __builtin__.object:
+ if thisclass is builtins.object:
attrs = inherited
continue
elif thisclass is object:
@@ -1246,7 +1266,7 @@ class TextDoc(Doc):
contents = '\n'.join(contents)
if not contents:
return title + '\n'
- return title + '\n' + self.indent(rstrip(contents), ' | ') + '\n'
+ return title + '\n' + self.indent(contents.rstrip(), ' | ') + '\n'
def formatvalue(self, object):
"""Format an argument default value as text."""
@@ -1259,17 +1279,17 @@ class TextDoc(Doc):
note = ''
skipdocs = 0
if inspect.ismethod(object):
- imclass = object.im_class
+ imclass = object.__self__.__class__
if cl:
if imclass is not cl:
note = ' from ' + classname(imclass, mod)
else:
- if object.im_self is not None:
+ if object.__self__ is not None:
note = ' method of %s instance' % classname(
- object.im_self.__class__, mod)
+ object.__self__.__class__, mod)
else:
note = ' unbound %s method' % classname(imclass,mod)
- object = object.im_func
+ object = object.__func__
if name == realname:
title = self.bold(realname)
@@ -1279,11 +1299,17 @@ class TextDoc(Doc):
skipdocs = 1
title = self.bold(name) + ' = ' + realname
if inspect.isfunction(object):
- args, varargs, varkw, defaults = inspect.getargspec(object)
+ args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann = \
+ inspect.getfullargspec(object)
argspec = inspect.formatargspec(
- args, varargs, varkw, defaults, formatvalue=self.formatvalue)
+ args, varargs, varkw, defaults, kwonlyargs, kwdefaults, ann,
+ formatvalue=self.formatvalue,
+ formatannotation=inspect.formatannotationrelativeto(object))
if realname == '<lambda>':
title = self.bold(name) + ' lambda '
+ # XXX lambda's won't usually have func_annotations['return']
+ # since the syntax doesn't support but it is possible.
+ # So removing parentheses isn't truly safe.
argspec = argspec[1:-1] # remove parentheses
else:
argspec = '(...)'
@@ -1293,7 +1319,7 @@ class TextDoc(Doc):
return decl + '\n'
else:
doc = getdoc(object) or ''
- return decl + '\n' + (doc and rstrip(self.indent(doc)) + '\n')
+ return decl + '\n' + (doc and self.indent(doc).rstrip() + '\n')
def _docdescriptor(self, name, value, mod):
results = []
@@ -1328,6 +1354,11 @@ class TextDoc(Doc):
line += '\n' + self.indent(str(doc))
return line
+class _PlainTextDoc(TextDoc):
+ """Subclass of TextDoc which overrides string styling"""
+ def bold(self, text):
+ return text
+
# --------------------------------------------------------- user interfaces
def pager(text):
@@ -1338,7 +1369,7 @@ def pager(text):
def getpager():
"""Decide what method to use for paging through text."""
- if type(sys.stdout) is not types.FileType:
+ if not hasattr(sys.stdout, "isatty"):
return plainpager
if not sys.stdin.isatty() or not sys.stdout.isatty():
return plainpager
@@ -1394,7 +1425,7 @@ def tempfilepager(text, cmd):
def ttypager(text):
"""Page through text on a text terminal."""
- lines = split(plain(text), '\n')
+ lines = plain(text).split('\n')
try:
import tty
fd = sys.stdin.fileno()
@@ -1407,7 +1438,7 @@ def ttypager(text):
try:
r = inc = os.environ.get('LINES', 25) - 1
- sys.stdout.write(join(lines[:inc], '\n') + '\n')
+ sys.stdout.write('\n'.join(lines[:inc]) + '\n')
while lines[r:]:
sys.stdout.write('-- more --')
sys.stdout.flush()
@@ -1423,7 +1454,7 @@ def ttypager(text):
if c in ('b', 'B', '\x1b'):
r = r - inc - inc
if r < 0: r = 0
- sys.stdout.write('\n' + join(lines[r:r+inc], '\n') + '\n')
+ sys.stdout.write('\n' + '\n'.join(lines[r:r+inc]) + '\n')
r = r + inc
finally:
@@ -1459,22 +1490,20 @@ def describe(thing):
return 'function ' + thing.__name__
if inspect.ismethod(thing):
return 'method ' + thing.__name__
- if type(thing) is types.InstanceType:
- return 'instance of ' + thing.__class__.__name__
return type(thing).__name__
def locate(path, forceload=0):
"""Locate an object by name or dotted path, importing as necessary."""
- parts = [part for part in split(path, '.') if part]
+ parts = [part for part in path.split('.') if part]
module, n = None, 0
while n < len(parts):
- nextmodule = safeimport(join(parts[:n+1], '.'), forceload)
+ nextmodule = safeimport('.'.join(parts[:n+1]), forceload)
if nextmodule: module, n = nextmodule, n + 1
else: break
if module:
object = module
else:
- object = __builtin__
+ object = builtins
for part in parts[n:]:
try:
object = getattr(object, part)
@@ -1485,24 +1514,25 @@ def locate(path, forceload=0):
# --------------------------------------- interactive interpreter interface
text = TextDoc()
+plaintext = _PlainTextDoc()
html = HTMLDoc()
-class _OldStyleClass: pass
-_OLD_INSTANCE_TYPE = type(_OldStyleClass())
-
def resolve(thing, forceload=0):
"""Given an object or a path to an object, get the object and its name."""
if isinstance(thing, str):
object = locate(thing, forceload)
if not object:
- raise ImportError, 'no Python documentation found for %r' % thing
+ raise ImportError('no Python documentation found for %r' % thing)
return object, thing
else:
name = getattr(thing, '__name__', None)
return thing, name if isinstance(name, str) else None
-def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
+def render_doc(thing, title='Python Library Documentation: %s', forceload=0,
+ renderer=None):
"""Render text documentation, given an object or a path to an object."""
+ if renderer is None:
+ renderer = text
object, name = resolve(thing, forceload)
desc = describe(object)
module = inspect.getmodule(object)
@@ -1510,11 +1540,8 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
desc += ' in ' + name[:name.rfind('.')]
elif module and module is not object:
desc += ' in module ' + module.__name__
- if type(object) is _OLD_INSTANCE_TYPE:
- # If the passed object is an instance of an old-style class,
- # document its available methods instead of its value.
- object = object.__class__
- elif not (inspect.ismodule(object) or
+
+ if not (inspect.ismodule(object) or
inspect.isclass(object) or
inspect.isroutine(object) or
inspect.isgetsetdescriptor(object) or
@@ -1524,26 +1551,30 @@ def render_doc(thing, title='Python Library Documentation: %s', forceload=0):
# document its available methods instead of its value.
object = type(object)
desc += ' object'
- return title % desc + '\n\n' + text.document(object, name)
+ return title % desc + '\n\n' + renderer.document(object, name)
-def doc(thing, title='Python Library Documentation: %s', forceload=0):
+def doc(thing, title='Python Library Documentation: %s', forceload=0,
+ output=None):
"""Display text documentation, given an object or a path to an object."""
try:
- pager(render_doc(thing, title, forceload))
- except (ImportError, ErrorDuringImport), value:
- print value
+ if output is None:
+ pager(render_doc(thing, title, forceload))
+ else:
+ output.write(render_doc(thing, title, forceload, plaintext))
+ except (ImportError, ErrorDuringImport) as value:
+ print(value)
def writedoc(thing, forceload=0):
"""Write HTML documentation to a file in the current directory."""
try:
object, name = resolve(thing, forceload)
page = html.page(describe(object), html.document(object, name))
- file = open(name + '.html', 'w')
+ file = open(name + '.html', 'w', encoding='utf-8')
file.write(page)
file.close()
- print 'wrote', name + '.html'
- except (ImportError, ErrorDuringImport), value:
- print value
+ print('wrote', name + '.html')
+ except (ImportError, ErrorDuringImport) as value:
+ print(value)
def writedocs(dir, pkgpath='', done=None):
"""Write out HTML documentation for all modules in a directory tree."""
@@ -1566,6 +1597,9 @@ class Helper:
# in Doc/ and copying the output file into the Lib/ directory.
keywords = {
+ 'False': '',
+ 'None': '',
+ 'True': '',
'and': 'BOOLEAN',
'as': 'with',
'assert': ('assert', ''),
@@ -1577,20 +1611,19 @@ class Helper:
'elif': 'if',
'else': ('else', 'while for'),
'except': 'try',
- 'exec': ('exec', ''),
'finally': 'try',
'for': ('for', 'break continue while'),
'from': 'import',
- 'global': ('global', 'NAMESPACES'),
+ 'global': ('global', 'nonlocal NAMESPACES'),
'if': ('if', 'TRUTHVALUE'),
'import': ('import', 'MODULES'),
- 'in': ('in', 'SEQUENCEMETHODS2'),
+ 'in': ('in', 'SEQUENCEMETHODS'),
'is': 'COMPARISON',
'lambda': ('lambda', 'FUNCTIONS'),
+ 'nonlocal': ('nonlocal', 'global NAMESPACES'),
'not': 'BOOLEAN',
'or': 'BOOLEAN',
'pass': ('pass', ''),
- 'print': ('print', ''),
'raise': ('raise', 'EXCEPTIONS'),
'return': ('return', 'FUNCTIONS'),
'try': ('try', 'EXCEPTIONS'),
@@ -1601,7 +1634,7 @@ class Helper:
# Either add symbols to this dictionary or to the symbols dictionary
# directly: Whichever is easier. They are merged later.
_symbols_inverse = {
- 'STRINGS' : ("'", "'''", "r'", "u'", '"""', '"', 'r"', 'u"'),
+ 'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'),
'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
'|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
@@ -1628,7 +1661,7 @@ class Helper:
'[': 'LISTS SUBSCRIPTS SLICINGS',
']': 'LISTS SUBSCRIPTS SLICINGS'
}
- for topic, symbols_ in _symbols_inverse.iteritems():
+ for topic, symbols_ in _symbols_inverse.items():
for symbol in symbols_:
topics = symbols.get(symbol, topic)
if topic not in topics:
@@ -1638,8 +1671,8 @@ class Helper:
topics = {
'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
'FUNCTIONS CLASSES MODULES FILES inspect'),
- 'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS FORMATTING '
- 'TYPES'),
+ 'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS '
+ 'FORMATTING TYPES'),
'STRINGMETHODS': ('string-methods', 'STRINGS FORMATTING'),
'FORMATTING': ('formatstrings', 'OPERATORS'),
'UNICODE': ('strings', 'encodings unicode SEQUENCES STRINGMETHODS '
@@ -1648,7 +1681,7 @@ class Helper:
'INTEGER': ('integers', 'int range'),
'FLOAT': ('floating', 'float math'),
'COMPLEX': ('imaginary', 'complex cmath'),
- 'SEQUENCES': ('typesseq', 'STRINGMETHODS FORMATTING xrange LISTS'),
+ 'SEQUENCES': ('typesseq', 'STRINGMETHODS FORMATTING range LISTS'),
'MAPPINGS': 'DICTIONARIES',
'FUNCTIONS': ('typesfunctions', 'def TYPES'),
'METHODS': ('typesmethods', 'class def CLASSES TYPES'),
@@ -1666,47 +1699,42 @@ class Helper:
'EXPRESSIONS': ('operator-summary', 'lambda or and not in is BOOLEAN '
'COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER '
'UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES '
- 'LISTS DICTIONARIES BACKQUOTES'),
+ 'LISTS DICTIONARIES'),
'OPERATORS': 'EXPRESSIONS',
'PRECEDENCE': 'EXPRESSIONS',
'OBJECTS': ('objects', 'TYPES'),
'SPECIALMETHODS': ('specialnames', 'BASICMETHODS ATTRIBUTEMETHODS '
- 'CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS '
- 'SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'),
- 'BASICMETHODS': ('customization', 'cmp hash repr str SPECIALMETHODS'),
+ 'CALLABLEMETHODS SEQUENCEMETHODS MAPPINGMETHODS '
+ 'NUMBERMETHODS CLASSES'),
+ 'BASICMETHODS': ('customization', 'hash repr str SPECIALMETHODS'),
'ATTRIBUTEMETHODS': ('attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
'CALLABLEMETHODS': ('callable-types', 'CALLS SPECIALMETHODS'),
- 'SEQUENCEMETHODS1': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS2 '
- 'SPECIALMETHODS'),
- 'SEQUENCEMETHODS2': ('sequence-methods', 'SEQUENCES SEQUENCEMETHODS1 '
+ 'SEQUENCEMETHODS': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS '
'SPECIALMETHODS'),
'MAPPINGMETHODS': ('sequence-types', 'MAPPINGS SPECIALMETHODS'),
'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
'SPECIALMETHODS'),
'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
- 'NAMESPACES': ('naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
+ 'NAMESPACES': ('naming', 'global nonlocal ASSIGNMENT DELETION DYNAMICFEATURES'),
'DYNAMICFEATURES': ('dynamic-features', ''),
'SCOPING': 'NAMESPACES',
'FRAMES': 'NAMESPACES',
'EXCEPTIONS': ('exceptions', 'try except finally raise'),
- 'COERCIONS': ('coercion-rules','CONVERSIONS'),
- 'CONVERSIONS': ('conversions', 'COERCIONS'),
+ 'CONVERSIONS': ('conversions', ''),
'IDENTIFIERS': ('identifiers', 'keywords SPECIALIDENTIFIERS'),
'SPECIALIDENTIFIERS': ('id-classes', ''),
'PRIVATENAMES': ('atom-identifiers', ''),
- 'LITERALS': ('atom-literals', 'STRINGS BACKQUOTES NUMBERS '
- 'TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'),
+ 'LITERALS': ('atom-literals', 'STRINGS NUMBERS TUPLELITERALS '
+ 'LISTLITERALS DICTIONARYLITERALS'),
'TUPLES': 'SEQUENCES',
'TUPLELITERALS': ('exprlists', 'TUPLES LITERALS'),
'LISTS': ('typesseq-mutable', 'LISTLITERALS'),
'LISTLITERALS': ('lists', 'LISTS LITERALS'),
'DICTIONARIES': ('typesmapping', 'DICTIONARYLITERALS'),
'DICTIONARYLITERALS': ('dict', 'DICTIONARIES LITERALS'),
- 'BACKQUOTES': ('string-conversions', 'repr str STRINGS LITERALS'),
- 'ATTRIBUTES': ('attribute-references', 'getattr hasattr setattr '
- 'ATTRIBUTEMETHODS'),
- 'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS1'),
- 'SLICINGS': ('slicings', 'SEQUENCEMETHODS2'),
+ 'ATTRIBUTES': ('attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'),
+ 'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS'),
+ 'SLICINGS': ('slicings', 'SEQUENCEMETHODS'),
'CALLS': ('calls', 'EXPRESSIONS'),
'POWER': ('power', 'EXPRESSIONS'),
'UNARY': ('unary', 'EXPRESSIONS'),
@@ -1719,7 +1747,6 @@ class Helper:
'ASSIGNMENT': ('assignment', 'AUGMENTEDASSIGNMENT'),
'AUGMENTEDASSIGNMENT': ('augassign', 'NUMBERMETHODS'),
'DELETION': 'del',
- 'PRINTING': 'print',
'RETURNING': 'return',
'IMPORTING': 'import',
'CONDITIONAL': 'if',
@@ -1764,14 +1791,14 @@ has the same effect as typing a particular string at the help> prompt.
if not request: break
except (KeyboardInterrupt, EOFError):
break
- request = strip(replace(request, '"', '', "'", ''))
- if lower(request) in ('q', 'quit'): break
+ request = replace(request, '"', '', "'", '').strip()
+ if request.lower() in ('q', 'quit'): break
self.help(request)
def getline(self, prompt):
- """Read one line, using raw_input when available."""
+ """Read one line, using input() when appropriate."""
if self.input is sys.stdin:
- return raw_input(prompt)
+ return input(prompt)
else:
self.output.write(prompt)
self.output.flush()
@@ -1786,13 +1813,16 @@ has the same effect as typing a particular string at the help> prompt.
elif request == 'topics': self.listtopics()
elif request == 'modules': self.listmodules()
elif request[:8] == 'modules ':
- self.listmodules(split(request)[1])
+ self.listmodules(request.split()[1])
elif request in self.symbols: self.showsymbol(request)
+ elif request in ['True', 'False', 'None']:
+ # special case these keywords since they are objects too
+ doc(eval(request), 'Help on %s:')
elif request in self.keywords: self.showtopic(request)
elif request in self.topics: self.showtopic(request)
- elif request: doc(request, 'Help on %s:')
+ elif request: doc(request, 'Help on %s:', output=self._output)
elif isinstance(request, Helper): self()
- else: doc(request, 'Help on %s:')
+ else: doc(request, 'Help on %s:', output=self._output)
self.output.write('\n')
def intro(self):
@@ -1813,17 +1843,16 @@ such as "spam", type "modules spam".
''' % tuple([sys.version[:3]]*2))
def list(self, items, columns=4, width=80):
- items = items[:]
- items.sort()
- colw = width / columns
- rows = (len(items) + columns - 1) / columns
+ items = list(sorted(items))
+ colw = width // columns
+ rows = (len(items) + columns - 1) // columns
for row in range(rows):
for col in range(columns):
i = col * rows + row
if i < len(items):
self.output.write(items[i])
if col < columns - 1:
- self.output.write(' ' + ' ' * (colw-1 - len(items[i])))
+ self.output.write(' ' + ' ' * (colw - 1 - len(items[i])))
self.output.write('\n')
def listkeywords(self):
@@ -1870,16 +1899,43 @@ module "pydoc_data.topics" could not be found.
except KeyError:
self.output.write('no documentation found for %s\n' % repr(topic))
return
- pager(strip(doc) + '\n')
+ pager(doc.strip() + '\n')
if more_xrefs:
xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs:
- import StringIO, formatter
- buffer = StringIO.StringIO()
+ import formatter
+ buffer = io.StringIO()
formatter.DumbWriter(buffer).send_flowing_data(
- 'Related help topics: ' + join(split(xrefs), ', ') + '\n')
+ 'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
self.output.write('\n%s\n' % buffer.getvalue())
+ def _gettopic(self, topic, more_xrefs=''):
+ """Return unbuffered tuple of (topic, xrefs).
+
+ If an error occurs here, the exception is caught and displayed by
+ the url handler.
+
+ This function duplicates the showtopic method but returns its
+ result directly so it can be formatted for display in an html page.
+ """
+ try:
+ import pydoc_data.topics
+ except ImportError:
+ return('''
+Sorry, topic and keyword documentation is not available because the
+module "pydoc_data.topics" could not be found.
+''' , '')
+ target = self.topics.get(topic, self.keywords.get(topic))
+ if not target:
+ raise ValueError('could not find topic')
+ if isinstance(target, str):
+ return self._gettopic(target, more_xrefs)
+ label, xrefs = target
+ doc = pydoc_data.topics.topics[label]
+ if more_xrefs:
+ xrefs = (xrefs or '') + ' ' + more_xrefs
+ return doc, xrefs
+
def showsymbol(self, symbol):
target = self.symbols[symbol]
topic, _, xrefs = target.partition(' ')
@@ -1901,7 +1957,7 @@ Please wait a moment while I gather a list of all available modules...
def callback(path, modname, desc, modules=modules):
if modname and modname[-9:] == '.__init__':
modname = modname[:-9] + ' (package)'
- if find(modname, '.') < 0:
+ if modname.find('.') < 0:
modules[modname] = 1
def onerror(modname):
callback(None, modname, None)
@@ -1942,7 +1998,7 @@ class ModuleScanner:
"""An interruptible scanner that searches module synopses."""
def run(self, callback, key=None, completer=None, onerror=None):
- if key: key = lower(key)
+ if key: key = key.lower()
self.quit = False
seen = {}
@@ -1952,31 +2008,55 @@ class ModuleScanner:
if key is None:
callback(None, modname, '')
else:
- desc = split(__import__(modname).__doc__ or '', '\n')[0]
- if find(lower(modname + ' - ' + desc), key) >= 0:
+ name = __import__(modname).__doc__ or ''
+ desc = name.split('\n')[0]
+ name = modname + ' - ' + desc
+ if name.lower().find(key) >= 0:
callback(None, modname, desc)
for importer, modname, ispkg in pkgutil.walk_packages(onerror=onerror):
if self.quit:
break
+
+ # XXX Skipping this file is a workaround for a bug
+ # that causes python to crash with a segfault.
+ # http://bugs.python.org/issue9319
+ #
+ # TODO Remove this once the bug is fixed.
+ if modname in {'test.badsyntax_pep3120', 'badsyntax_pep3120'}:
+ continue
+
if key is None:
callback(None, modname, '')
else:
- loader = importer.find_module(modname)
- if hasattr(loader,'get_source'):
- import StringIO
- desc = source_synopsis(
- StringIO.StringIO(loader.get_source(modname))
- ) or ''
- if hasattr(loader,'get_filename'):
+ try:
+ loader = importer.find_module(modname)
+ except SyntaxError:
+ # raised by tests for bad coding cookies or BOM
+ continue
+ if hasattr(loader, 'get_source'):
+ try:
+ source = loader.get_source(modname)
+ except UnicodeDecodeError:
+ if onerror:
+ onerror(modname)
+ continue
+ desc = source_synopsis(io.StringIO(source)) or ''
+ if hasattr(loader, 'get_filename'):
path = loader.get_filename(modname)
else:
path = None
else:
- module = loader.load_module(modname)
+ try:
+ module = loader.load_module(modname)
+ except ImportError:
+ if onerror:
+ onerror(modname)
+ continue
desc = (module.__doc__ or '').splitlines()[0]
path = getattr(module,'__file__',None)
- if find(lower(modname + ' - ' + desc), key) >= 0:
+ name = modname + ' - ' + desc
+ if name.lower().find(key) >= 0:
callback(path, modname, desc)
if completer:
@@ -1987,35 +2067,28 @@ def apropos(key):
def callback(path, modname, desc):
if modname[-9:] == '.__init__':
modname = modname[:-9] + ' (package)'
- print modname, desc and '- ' + desc
+ print(modname, desc and '- ' + desc)
def onerror(modname):
pass
with warnings.catch_warnings():
warnings.filterwarnings('ignore') # ignore problems during import
ModuleScanner().run(callback, key, onerror=onerror)
-# --------------------------------------------------- web browser interface
+# --------------------------------------------------- Web browser interface
def serve(port, callback=None, completer=None):
- import BaseHTTPServer, mimetools, select
-
- # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded.
- class Message(mimetools.Message):
- def __init__(self, fp, seekable=1):
- Message = self.__class__
- Message.__bases__[0].__bases__[0].__init__(self, fp, seekable)
- self.encodingheader = self.getheader('content-transfer-encoding')
- self.typeheader = self.getheader('content-type')
- self.parsetype()
- self.parseplist()
-
- class DocHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ import http.server, email.message, select
+
+ msg = 'the pydoc.serve() function is deprecated'
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
+ class DocHandler(http.server.BaseHTTPRequestHandler):
def send_document(self, title, contents):
try:
self.send_response(200)
- self.send_header('Content-Type', 'text/html')
+ self.send_header('Content-Type', 'text/html; charset=UTF-8')
self.end_headers()
- self.wfile.write(html.page(title, contents))
+ self.wfile.write(html.page(title, contents).encode('utf-8'))
except IOError: pass
def do_GET(self):
@@ -2025,7 +2098,7 @@ def serve(port, callback=None, completer=None):
if path and path != '.':
try:
obj = locate(path, forceload=1)
- except ErrorDuringImport, value:
+ except ErrorDuringImport as value:
self.send_document(path, html.escape(str(value)))
return
if obj:
@@ -2039,8 +2112,7 @@ def serve(port, callback=None, completer=None):
'#ffffff', '#7799ee')
def bltinlink(name):
return '<a href="%s.html">%s</a>' % (name, name)
- names = filter(lambda x: x != '__main__',
- sys.builtin_module_names)
+ names = [x for x in sys.builtin_module_names if x != '__main__']
contents = html.multicolumn(names, bltinlink)
indices = ['<p>' + html.bigsection(
'Built-in Modules', '#ffffff', '#ee77aa', contents)]
@@ -2048,14 +2120,14 @@ def serve(port, callback=None, completer=None):
seen = {}
for dir in sys.path:
indices.append(html.index(dir, seen))
- contents = heading + join(indices) + '''<p align=right>
+ contents = heading + ' '.join(indices) + '''<p align=right>
<font color="#909090" face="helvetica, arial"><strong>
pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
self.send_document('Index of Modules', contents)
def log_message(self, *args): pass
- class DocServer(BaseHTTPServer.HTTPServer):
+ class DocServer(http.server.HTTPServer):
def __init__(self, port, callback):
host = 'localhost'
self.address = (host, port)
@@ -2069,14 +2141,15 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
while not self.quit:
rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
if rd: self.handle_request()
+ self.server_close()
def server_activate(self):
self.base.server_activate(self)
if self.callback: self.callback(self)
- DocServer.base = BaseHTTPServer.HTTPServer
+ DocServer.base = http.server.HTTPServer
DocServer.handler = DocHandler
- DocHandler.MessageClass = Message
+ DocHandler.MessageClass = email.message.Message
try:
try:
DocServer(port, callback).serve_until_quit()
@@ -2088,27 +2161,32 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
# ----------------------------------------------------- graphical interface
def gui():
- """Graphical interface (starts web server and pops up a control window)."""
+ """Graphical interface (starts Web server and pops up a control window)."""
+
+ msg = ('the pydoc.gui() function and "pydoc -g" option are deprecated\n',
+ 'use "pydoc.browse() function and "pydoc -b" option instead.')
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+
class GUI:
def __init__(self, window, port=7464):
self.window = window
self.server = None
self.scanner = None
- import Tkinter
- self.server_frm = Tkinter.Frame(window)
- self.title_lbl = Tkinter.Label(self.server_frm,
+ import tkinter
+ self.server_frm = tkinter.Frame(window)
+ self.title_lbl = tkinter.Label(self.server_frm,
text='Starting server...\n ')
- self.open_btn = Tkinter.Button(self.server_frm,
+ self.open_btn = tkinter.Button(self.server_frm,
text='open browser', command=self.open, state='disabled')
- self.quit_btn = Tkinter.Button(self.server_frm,
+ self.quit_btn = tkinter.Button(self.server_frm,
text='quit serving', command=self.quit, state='disabled')
- self.search_frm = Tkinter.Frame(window)
- self.search_lbl = Tkinter.Label(self.search_frm, text='Search for')
- self.search_ent = Tkinter.Entry(self.search_frm)
+ self.search_frm = tkinter.Frame(window)
+ self.search_lbl = tkinter.Label(self.search_frm, text='Search for')
+ self.search_ent = tkinter.Entry(self.search_frm)
self.search_ent.bind('<Return>', self.search)
- self.stop_btn = Tkinter.Button(self.search_frm,
+ self.stop_btn = tkinter.Button(self.search_frm,
text='stop', pady=0, command=self.stop, state='disabled')
if sys.platform == 'win32':
# Trying to hide and show this button crashes under Windows.
@@ -2127,17 +2205,17 @@ def gui():
self.search_ent.focus_set()
font = ('helvetica', sys.platform == 'win32' and 8 or 10)
- self.result_lst = Tkinter.Listbox(window, font=font, height=6)
+ self.result_lst = tkinter.Listbox(window, font=font, height=6)
self.result_lst.bind('<Button-1>', self.select)
self.result_lst.bind('<Double-Button-1>', self.goto)
- self.result_scr = Tkinter.Scrollbar(window,
+ self.result_scr = tkinter.Scrollbar(window,
orient='vertical', command=self.result_lst.yview)
self.result_lst.config(yscrollcommand=self.result_scr.set)
- self.result_frm = Tkinter.Frame(window)
- self.goto_btn = Tkinter.Button(self.result_frm,
+ self.result_frm = tkinter.Frame(window)
+ self.goto_btn = tkinter.Button(self.result_frm,
text='go to selected', command=self.goto)
- self.hide_btn = Tkinter.Button(self.result_frm,
+ self.hide_btn = tkinter.Button(self.result_frm,
text='hide results', command=self.hide)
self.goto_btn.pack(side='left', fill='x', expand=1)
self.hide_btn.pack(side='right', fill='x', expand=1)
@@ -2168,15 +2246,8 @@ def gui():
def open(self, event=None, url=None):
url = url or self.server.url
- try:
- import webbrowser
- webbrowser.open(url)
- except ImportError: # pre-webbrowser.py compatibility
- if sys.platform == 'win32':
- os.system('start "%s"' % url)
- else:
- rc = os.system('netscape -remote "openURL(%s)" &' % url)
- if rc: os.system('netscape "%s" &' % url)
+ import webbrowser
+ webbrowser.open(url)
def quit(self, event=None):
if self.server:
@@ -2226,7 +2297,7 @@ def gui():
def goto(self, event=None):
selection = self.result_lst.curselection()
if selection:
- modname = split(self.result_lst.get(selection[0]))[0]
+ modname = self.result_lst.get(selection[0]).split()[0]
self.open(url=self.server.url + modname + '.html')
def collapse(self):
@@ -2253,9 +2324,9 @@ def gui():
self.stop()
self.collapse()
- import Tkinter
+ import tkinter
try:
- root = Tkinter.Tk()
+ root = tkinter.Tk()
# Tk will crash if pythonw.exe has an XP .manifest
# file and the root has is not destroyed explicitly.
# If the problem is ever fixed in Tk, the explicit
@@ -2268,15 +2339,453 @@ def gui():
except KeyboardInterrupt:
pass
+
+# --------------------------------------- enhanced Web browser interface
+
+def _start_server(urlhandler, port):
+ """Start an HTTP server thread on a specific port.
+
+ Start an HTML/text server thread, so HTML or text documents can be
+ browsed dynamically and interactively with a Web browser. Example use:
+
+ >>> import time
+ >>> import pydoc
+
+ Define a URL handler. To determine what the client is asking
+ for, check the URL and content_type.
+
+ Then get or generate some text or HTML code and return it.
+
+ >>> def my_url_handler(url, content_type):
+ ... text = 'the URL sent was: (%s, %s)' % (url, content_type)
+ ... return text
+
+ Start server thread on port 0.
+ If you use port 0, the server will pick a random port number.
+ You can then use serverthread.port to get the port number.
+
+ >>> port = 0
+ >>> serverthread = pydoc._start_server(my_url_handler, port)
+
+ Check that the server is really started. If it is, open browser
+ and get first page. Use serverthread.url as the starting page.
+
+ >>> if serverthread.serving:
+ ... import webbrowser
+
+ The next two lines are commented out so a browser doesn't open if
+ doctest is run on this module.
+
+ #... webbrowser.open(serverthread.url)
+ #True
+
+ Let the server do its thing. We just need to monitor its status.
+ Use time.sleep so the loop doesn't hog the CPU.
+
+ >>> starttime = time.time()
+ >>> timeout = 1 #seconds
+
+ This is a short timeout for testing purposes.
+
+ >>> while serverthread.serving:
+ ... time.sleep(.01)
+ ... if serverthread.serving and time.time() - starttime > timeout:
+ ... serverthread.stop()
+ ... break
+
+ Print any errors that may have occurred.
+
+ >>> print(serverthread.error)
+ None
+ """
+ import http.server
+ import email.message
+ import select
+ import threading
+
+ class DocHandler(http.server.BaseHTTPRequestHandler):
+
+ def do_GET(self):
+ """Process a request from an HTML browser.
+
+ The URL received is in self.path.
+ Get an HTML page from self.urlhandler and send it.
+ """
+ if self.path.endswith('.css'):
+ content_type = 'text/css'
+ else:
+ content_type = 'text/html'
+ self.send_response(200)
+ self.send_header('Content-Type', '%s; charset=UTF-8' % content_type)
+ self.end_headers()
+ self.wfile.write(self.urlhandler(
+ self.path, content_type).encode('utf-8'))
+
+ def log_message(self, *args):
+ # Don't log messages.
+ pass
+
+ class DocServer(http.server.HTTPServer):
+
+ def __init__(self, port, callback):
+ self.host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
+ self.address = ('', port)
+ self.callback = callback
+ self.base.__init__(self, self.address, self.handler)
+ self.quit = False
+
+ def serve_until_quit(self):
+ while not self.quit:
+ rd, wr, ex = select.select([self.socket.fileno()], [], [], 1)
+ if rd:
+ self.handle_request()
+ self.server_close()
+
+ def server_activate(self):
+ self.base.server_activate(self)
+ if self.callback:
+ self.callback(self)
+
+ class ServerThread(threading.Thread):
+
+ def __init__(self, urlhandler, port):
+ self.urlhandler = urlhandler
+ self.port = int(port)
+ threading.Thread.__init__(self)
+ self.serving = False
+ self.error = None
+
+ def run(self):
+ """Start the server."""
+ try:
+ DocServer.base = http.server.HTTPServer
+ DocServer.handler = DocHandler
+ DocHandler.MessageClass = email.message.Message
+ DocHandler.urlhandler = staticmethod(self.urlhandler)
+ docsvr = DocServer(self.port, self.ready)
+ self.docserver = docsvr
+ docsvr.serve_until_quit()
+ except Exception as e:
+ self.error = e
+
+ def ready(self, server):
+ self.serving = True
+ self.host = server.host
+ self.port = server.server_port
+ self.url = 'http://%s:%d/' % (self.host, self.port)
+
+ def stop(self):
+ """Stop the server and this thread nicely"""
+ self.docserver.quit = True
+ self.serving = False
+ self.url = None
+
+ thread = ServerThread(urlhandler, port)
+ thread.start()
+ # Wait until thread.serving is True to make sure we are
+ # really up before returning.
+ while not thread.error and not thread.serving:
+ time.sleep(.01)
+ return thread
+
+
+def _url_handler(url, content_type="text/html"):
+ """The pydoc url handler for use with the pydoc server.
+
+ If the content_type is 'text/css', the _pydoc.css style
+ sheet is read and returned if it exits.
+
+ If the content_type is 'text/html', then the result of
+ get_html_page(url) is returned.
+ """
+ class _HTMLDoc(HTMLDoc):
+
+ def page(self, title, contents):
+ """Format an HTML page."""
+ css_path = "pydoc_data/_pydoc.css"
+ css_link = (
+ '<link rel="stylesheet" type="text/css" href="%s">' %
+ css_path)
+ return '''\
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html><head><title>Pydoc: %s</title>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+%s</head><body bgcolor="#f0f0f8">%s<div style="clear:both;padding-top:.5em;">%s</div>
+</body></html>''' % (title, css_link, html_navbar(), contents)
+
+ def filelink(self, url, path):
+ return '<a href="getfile?key=%s">%s</a>' % (url, path)
+
+
+ html = _HTMLDoc()
+
+ def html_navbar():
+ version = html.escape("%s [%s, %s]" % (platform.python_version(),
+ platform.python_build()[0],
+ platform.python_compiler()))
+ return """
+ <div style='float:left'>
+ Python %s<br>%s
+ </div>
+ <div style='float:right'>
+ <div style='text-align:center'>
+ <a href="index.html">Module Index</a>
+ : <a href="topics.html">Topics</a>
+ : <a href="keywords.html">Keywords</a>
+ </div>
+ <div>
+ <form action="get" style='display:inline;'>
+ <input type=text name=key size=15>
+ <input type=submit value="Get">
+ </form>&nbsp;
+ <form action="search" style='display:inline;'>
+ <input type=text name=key size=15>
+ <input type=submit value="Search">
+ </form>
+ </div>
+ </div>
+ """ % (version, html.escape(platform.platform(terse=True)))
+
+ def html_index():
+ """Module Index page."""
+
+ def bltinlink(name):
+ return '<a href="%s.html">%s</a>' % (name, name)
+
+ heading = html.heading(
+ '<big><big><strong>Index of Modules</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = [name for name in sys.builtin_module_names
+ if name != '__main__']
+ contents = html.multicolumn(names, bltinlink)
+ contents = [heading, '<p>' + html.bigsection(
+ 'Built-in Modules', '#ffffff', '#ee77aa', contents)]
+
+ seen = {}
+ for dir in sys.path:
+ contents.append(html.index(dir, seen))
+
+ contents.append(
+ '<p align=right><font color="#909090" face="helvetica,'
+ 'arial"><strong>pydoc</strong> by Ka-Ping Yee'
+ '&lt;ping@lfw.org&gt;</font>')
+ return 'Index of Modules', ''.join(contents)
+
+ def html_search(key):
+ """Search results page."""
+ # scan for modules
+ search_result = []
+
+ def callback(path, modname, desc):
+ if modname[-9:] == '.__init__':
+ modname = modname[:-9] + ' (package)'
+ search_result.append((modname, desc and '- ' + desc))
+
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore') # ignore problems during import
+ ModuleScanner().run(callback, key)
+
+ # format page
+ def bltinlink(name):
+ return '<a href="%s.html">%s</a>' % (name, name)
+
+ results = []
+ heading = html.heading(
+ '<big><big><strong>Search Results</strong></big></big>',
+ '#ffffff', '#7799ee')
+ for name, desc in search_result:
+ results.append(bltinlink(name) + desc)
+ contents = heading + html.bigsection(
+ 'key = %s' % key, '#ffffff', '#ee77aa', '<br>'.join(results))
+ return 'Search Results', contents
+
+ def html_getfile(path):
+ """Get and display a source file listing safely."""
+ path = path.replace('%20', ' ')
+ with tokenize.open(path) as fp:
+ lines = html.escape(fp.read())
+ body = '<pre>%s</pre>' % lines
+ heading = html.heading(
+ '<big><big><strong>File Listing</strong></big></big>',
+ '#ffffff', '#7799ee')
+ contents = heading + html.bigsection(
+ 'File: %s' % path, '#ffffff', '#ee77aa', body)
+ return 'getfile %s' % path, contents
+
+ def html_topics():
+ """Index of topic texts available."""
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ heading = html.heading(
+ '<big><big><strong>INDEX</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = sorted(Helper.topics.keys())
+
+ contents = html.multicolumn(names, bltinlink)
+ contents = heading + html.bigsection(
+ 'Topics', '#ffffff', '#ee77aa', contents)
+ return 'Topics', contents
+
+ def html_keywords():
+ """Index of keywords."""
+ heading = html.heading(
+ '<big><big><strong>INDEX</strong></big></big>',
+ '#ffffff', '#7799ee')
+ names = sorted(Helper.keywords.keys())
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ contents = html.multicolumn(names, bltinlink)
+ contents = heading + html.bigsection(
+ 'Keywords', '#ffffff', '#ee77aa', contents)
+ return 'Keywords', contents
+
+ def html_topicpage(topic):
+ """Topic or keyword help page."""
+ buf = io.StringIO()
+ htmlhelp = Helper(buf, buf)
+ contents, xrefs = htmlhelp._gettopic(topic)
+ if topic in htmlhelp.keywords:
+ title = 'KEYWORD'
+ else:
+ title = 'TOPIC'
+ heading = html.heading(
+ '<big><big><strong>%s</strong></big></big>' % title,
+ '#ffffff', '#7799ee')
+ contents = '<pre>%s</pre>' % html.markup(contents)
+ contents = html.bigsection(topic , '#ffffff','#ee77aa', contents)
+ if xrefs:
+ xrefs = sorted(xrefs.split())
+
+ def bltinlink(name):
+ return '<a href="topic?key=%s">%s</a>' % (name, name)
+
+ xrefs = html.multicolumn(xrefs, bltinlink)
+ xrefs = html.section('Related help topics: ',
+ '#ffffff', '#ee77aa', xrefs)
+ return ('%s %s' % (title, topic),
+ ''.join((heading, contents, xrefs)))
+
+ def html_getobj(url):
+ obj = locate(url, forceload=1)
+ if obj is None and url != 'None':
+ raise ValueError('could not find object')
+ title = describe(obj)
+ content = html.document(obj, url)
+ return title, content
+
+ def html_error(url, exc):
+ heading = html.heading(
+ '<big><big><strong>Error</strong></big></big>',
+ '#ffffff', '#7799ee')
+ contents = '<br>'.join(html.escape(line) for line in
+ format_exception_only(type(exc), exc))
+ contents = heading + html.bigsection(url, '#ffffff', '#bb0000',
+ contents)
+ return "Error - %s" % url, contents
+
+ def get_html_page(url):
+ """Generate an HTML page for url."""
+ complete_url = url
+ if url.endswith('.html'):
+ url = url[:-5]
+ try:
+ if url in ("", "index"):
+ title, content = html_index()
+ elif url == "topics":
+ title, content = html_topics()
+ elif url == "keywords":
+ title, content = html_keywords()
+ elif '=' in url:
+ op, _, url = url.partition('=')
+ if op == "search?key":
+ title, content = html_search(url)
+ elif op == "getfile?key":
+ title, content = html_getfile(url)
+ elif op == "topic?key":
+ # try topics first, then objects.
+ try:
+ title, content = html_topicpage(url)
+ except ValueError:
+ title, content = html_getobj(url)
+ elif op == "get?key":
+ # try objects first, then topics.
+ if url in ("", "index"):
+ title, content = html_index()
+ else:
+ try:
+ title, content = html_getobj(url)
+ except ValueError:
+ title, content = html_topicpage(url)
+ else:
+ raise ValueError('bad pydoc url')
+ else:
+ title, content = html_getobj(url)
+ except Exception as exc:
+ # Catch any errors and display them in an error page.
+ title, content = html_error(complete_url, exc)
+ return html.page(title, content)
+
+ if url.startswith('/'):
+ url = url[1:]
+ if content_type == 'text/css':
+ path_here = os.path.dirname(os.path.realpath(__file__))
+ css_path = os.path.join(path_here, url)
+ with open(css_path) as fp:
+ return ''.join(fp.readlines())
+ elif content_type == 'text/html':
+ return get_html_page(url)
+ # Errors outside the url handler are caught by the server.
+ raise TypeError('unknown content type %r for url %s' % (content_type, url))
+
+
+def browse(port=0, *, open_browser=True):
+ """Start the enhanced pydoc Web server and open a Web browser.
+
+ Use port '0' to start the server on an arbitrary port.
+ Set open_browser to False to suppress opening a browser.
+ """
+ import webbrowser
+ serverthread = _start_server(_url_handler, port)
+ if serverthread.error:
+ print(serverthread.error)
+ return
+ if serverthread.serving:
+ server_help_msg = 'Server commands: [b]rowser, [q]uit'
+ if open_browser:
+ webbrowser.open(serverthread.url)
+ try:
+ print('Server ready at', serverthread.url)
+ print(server_help_msg)
+ while serverthread.serving:
+ cmd = input('server> ')
+ cmd = cmd.lower()
+ if cmd == 'q':
+ break
+ elif cmd == 'b':
+ webbrowser.open(serverthread.url)
+ else:
+ print(server_help_msg)
+ except (KeyboardInterrupt, EOFError):
+ print()
+ finally:
+ if serverthread.serving:
+ serverthread.stop()
+ print('Server stopped')
+
+
# -------------------------------------------------- command-line interface
def ispath(x):
- return isinstance(x, str) and find(x, os.sep) >= 0
+ return isinstance(x, str) and x.find(os.sep) >= 0
def cli():
"""Command-line interface (looks at sys.argv to decide what to do)."""
import getopt
- class BadUsage: pass
+ class BadUsage(Exception): pass
# Scripts don't get the current directory in their path by default
# unless they are run with the '-m' switch
@@ -2287,34 +2796,37 @@ def cli():
sys.path.insert(0, '.')
try:
- opts, args = getopt.getopt(sys.argv[1:], 'gk:p:w')
- writing = 0
-
+ opts, args = getopt.getopt(sys.argv[1:], 'bgk:p:w')
+ writing = False
+ start_server = False
+ open_browser = False
+ port = None
for opt, val in opts:
if opt == '-g':
gui()
return
+ if opt == '-b':
+ start_server = True
+ open_browser = True
if opt == '-k':
apropos(val)
return
if opt == '-p':
- try:
- port = int(val)
- except ValueError:
- raise BadUsage
- def ready(server):
- print 'pydoc server ready at %s' % server.url
- def stopped():
- print 'pydoc server stopped'
- serve(port, ready, stopped)
- return
+ start_server = True
+ port = val
if opt == '-w':
- writing = 1
+ writing = True
+
+ if start_server == True:
+ if port == None:
+ port = 0
+ browse(port, open_browser=open_browser)
+ return
if not args: raise BadUsage
for arg in args:
if ispath(arg) and not os.path.exists(arg):
- print 'file %r does not exist' % arg
+ print('file %r does not exist' % arg)
break
try:
if ispath(arg) and os.path.isfile(arg):
@@ -2326,34 +2838,41 @@ def cli():
writedoc(arg)
else:
help.help(arg)
- except ErrorDuringImport, value:
- print value
+ except ErrorDuringImport as value:
+ print(value)
except (getopt.error, BadUsage):
- cmd = os.path.basename(sys.argv[0])
- print """pydoc - the Python documentation tool
+ cmd = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+ print("""pydoc - the Python documentation tool
-%s <name> ...
+{cmd} <name> ...
Show text documentation on something. <name> may be the name of a
Python keyword, topic, function, module, or package, or a dotted
reference to a class or function within a module or module in a
- package. If <name> contains a '%s', it is used as the path to a
+ package. If <name> contains a '{sep}', it is used as the path to a
Python source file to document. If name is 'keywords', 'topics',
or 'modules', a listing of these things is displayed.
-%s -k <keyword>
+{cmd} -k <keyword>
Search for a keyword in the synopsis lines of all available modules.
-%s -p <port>
- Start an HTTP server on the given port on the local machine.
+{cmd} -p <port>
+ Start an HTTP server on the given port on the local machine. Port
+ number 0 can be used to get an arbitrary unused port.
+
+{cmd} -b
+ Start an HTTP server on an arbitrary unused port and open a Web browser
+ to interactively browse documentation. The -p option can be used with
+ the -b option to explicitly specify the server port.
-%s -g
- Pop up a graphical interface for finding and serving documentation.
+{cmd} -g
+ Deprecated.
-%s -w <name> ...
+{cmd} -w <name> ...
Write out the HTML documentation for a module to a file in the current
- directory. If <name> contains a '%s', it is treated as a filename; if
+ directory. If <name> contains a '{sep}', it is treated as a filename; if
it names a directory, documentation is written for all the contents.
-""" % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep)
+""".format(cmd=cmd, sep=os.sep))
-if __name__ == '__main__': cli()
+if __name__ == '__main__':
+ cli()
diff --git a/Lib/pydoc_data/_pydoc.css b/Lib/pydoc_data/_pydoc.css
new file mode 100644
index 00000000000..f036ef37a5a
--- /dev/null
+++ b/Lib/pydoc_data/_pydoc.css
@@ -0,0 +1,6 @@
+/*
+ CSS file for pydoc.
+
+ Contents of this file are subject to change without notice.
+
+*/
diff --git a/Lib/pydoc_data/topics.py b/Lib/pydoc_data/topics.py
index 13ee272a6f0..08a9e7c01eb 100644
--- a/Lib/pydoc_data/topics.py
+++ b/Lib/pydoc_data/topics.py
@@ -1,77 +1,78 @@
-# Autogenerated by Sphinx on Thu Feb 23 15:17:35 2012
+# Autogenerated by Sphinx on Thu Feb 23 18:37:54 2012
topics = {'assert': '\nThe ``assert`` statement\n************************\n\nAssert statements are a convenient way to insert debugging assertions\ninto a program:\n\n assert_stmt ::= "assert" expression ["," expression]\n\nThe simple form, ``assert expression``, is equivalent to\n\n if __debug__:\n if not expression: raise AssertionError\n\nThe extended form, ``assert expression1, expression2``, is equivalent\nto\n\n if __debug__:\n if not expression1: raise AssertionError(expression2)\n\nThese equivalences assume that ``__debug__`` and ``AssertionError``\nrefer to the built-in variables with those names. In the current\nimplementation, the built-in variable ``__debug__`` is ``True`` under\nnormal circumstances, ``False`` when optimization is requested\n(command line option -O). The current code generator emits no code\nfor an assert statement when optimization is requested at compile\ntime. Note that it is unnecessary to include the source code for the\nexpression that failed in the error message; it will be displayed as\npart of the stack trace.\n\nAssignments to ``__debug__`` are illegal. The value for the built-in\nvariable is determined when the interpreter starts.\n',
- 'assignment': '\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list is recursively defined as\nfollows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` statement in the\n current code block: the name is bound to the object in the current\n local namespace.\n\n * Otherwise: the name is bound to the object in the current global\n namespace.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n ``a.x`` can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target ``a.x`` is\n always set as an instance attribute, creating it if necessary.\n Thus, the two occurrences of ``a.x`` do not necessarily refer to the\n same attribute: if the RHS expression refers to a class attribute,\n the LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with ``property()``.\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield a plain integer. If it is negative, the\n sequence\'s length is added to it. The resulting value must be a\n nonnegative integer less than the sequence\'s length, and the\n sequence is asked to assign the assigned object to its item with\n that index. If the index is out of range, ``IndexError`` is raised\n (assignment to a subscripted sequence cannot add new items to a\n list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to (small) integers. If either\n bound is negative, the sequence\'s length is added to it. The\n resulting bounds are clipped to lie between zero and the sequence\'s\n length, inclusive. Finally, the sequence object is asked to replace\n the slice with the items of the assigned sequence. The length of\n the slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print x\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
+ 'assignment': '\nAssignment statements\n*********************\n\nAssignment statements are used to (re)bind names to values and to\nmodify attributes or items of mutable objects:\n\n assignment_stmt ::= (target_list "=")+ (expression_list | yield_expression)\n target_list ::= target ("," target)* [","]\n target ::= identifier\n | "(" target_list ")"\n | "[" target_list "]"\n | attributeref\n | subscription\n | slicing\n | "*" target\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn assignment statement evaluates the expression list (remember that\nthis can be a single expression or a comma-separated list, the latter\nyielding a tuple) and assigns the single resulting object to each of\nthe target lists, from left to right.\n\nAssignment is defined recursively depending on the form of the target\n(list). When a target is part of a mutable object (an attribute\nreference, subscription or slicing), the mutable object must\nultimately perform the assignment and decide about its validity, and\nmay raise an exception if the assignment is unacceptable. The rules\nobserved by various types and the exceptions raised are given with the\ndefinition of the object types (see section *The standard type\nhierarchy*).\n\nAssignment of an object to a target list, optionally enclosed in\nparentheses or square brackets, is recursively defined as follows.\n\n* If the target list is a single target: The object is assigned to\n that target.\n\n* If the target list is a comma-separated list of targets: The object\n must be an iterable with the same number of items as there are\n targets in the target list, and the items are assigned, from left to\n right, to the corresponding targets.\n\n * If the target list contains one target prefixed with an asterisk,\n called a "starred" target: The object must be a sequence with at\n least as many items as there are targets in the target list, minus\n one. The first items of the sequence are assigned, from left to\n right, to the targets before the starred target. The final items\n of the sequence are assigned to the targets after the starred\n target. A list of the remaining items in the sequence is then\n assigned to the starred target (the list can be empty).\n\n * Else: The object must be a sequence with the same number of items\n as there are targets in the target list, and the items are\n assigned, from left to right, to the corresponding targets.\n\nAssignment of an object to a single target is recursively defined as\nfollows.\n\n* If the target is an identifier (name):\n\n * If the name does not occur in a ``global`` or ``nonlocal``\n statement in the current code block: the name is bound to the\n object in the current local namespace.\n\n * Otherwise: the name is bound to the object in the global namespace\n or the outer namespace determined by ``nonlocal``, respectively.\n\n The name is rebound if it was already bound. This may cause the\n reference count for the object previously bound to the name to reach\n zero, causing the object to be deallocated and its destructor (if it\n has one) to be called.\n\n* If the target is a target list enclosed in parentheses or in square\n brackets: The object must be an iterable with the same number of\n items as there are targets in the target list, and its items are\n assigned, from left to right, to the corresponding targets.\n\n* If the target is an attribute reference: The primary expression in\n the reference is evaluated. It should yield an object with\n assignable attributes; if this is not the case, ``TypeError`` is\n raised. That object is then asked to assign the assigned object to\n the given attribute; if it cannot perform the assignment, it raises\n an exception (usually but not necessarily ``AttributeError``).\n\n Note: If the object is a class instance and the attribute reference\n occurs on both sides of the assignment operator, the RHS expression,\n ``a.x`` can access either an instance attribute or (if no instance\n attribute exists) a class attribute. The LHS target ``a.x`` is\n always set as an instance attribute, creating it if necessary.\n Thus, the two occurrences of ``a.x`` do not necessarily refer to the\n same attribute: if the RHS expression refers to a class attribute,\n the LHS creates a new instance attribute as the target of the\n assignment:\n\n class Cls:\n x = 3 # class variable\n inst = Cls()\n inst.x = inst.x + 1 # writes inst.x as 4 leaving Cls.x as 3\n\n This description does not necessarily apply to descriptor\n attributes, such as properties created with ``property()``.\n\n* If the target is a subscription: The primary expression in the\n reference is evaluated. It should yield either a mutable sequence\n object (such as a list) or a mapping object (such as a dictionary).\n Next, the subscript expression is evaluated.\n\n If the primary is a mutable sequence object (such as a list), the\n subscript must yield an integer. If it is negative, the sequence\'s\n length is added to it. The resulting value must be a nonnegative\n integer less than the sequence\'s length, and the sequence is asked\n to assign the assigned object to its item with that index. If the\n index is out of range, ``IndexError`` is raised (assignment to a\n subscripted sequence cannot add new items to a list).\n\n If the primary is a mapping object (such as a dictionary), the\n subscript must have a type compatible with the mapping\'s key type,\n and the mapping is then asked to create a key/datum pair which maps\n the subscript to the assigned object. This can either replace an\n existing key/value pair with the same key value, or insert a new\n key/value pair (if no key with the same value existed).\n\n For user-defined objects, the ``__setitem__()`` method is called\n with appropriate arguments.\n\n* If the target is a slicing: The primary expression in the reference\n is evaluated. It should yield a mutable sequence object (such as a\n list). The assigned object should be a sequence object of the same\n type. Next, the lower and upper bound expressions are evaluated,\n insofar they are present; defaults are zero and the sequence\'s\n length. The bounds should evaluate to integers. If either bound is\n negative, the sequence\'s length is added to it. The resulting\n bounds are clipped to lie between zero and the sequence\'s length,\n inclusive. Finally, the sequence object is asked to replace the\n slice with the items of the assigned sequence. The length of the\n slice may be different from the length of the assigned sequence,\n thus changing the length of the target sequence, if the object\n allows it.\n\n**CPython implementation detail:** In the current implementation, the\nsyntax for targets is taken to be the same as for expressions, and\ninvalid syntax is rejected during the code generation phase, causing\nless detailed error messages.\n\nWARNING: Although the definition of assignment implies that overlaps\nbetween the left-hand side and the right-hand side are \'safe\' (for\nexample ``a, b = b, a`` swaps two variables), overlaps *within* the\ncollection of assigned-to variables are not safe! For instance, the\nfollowing program prints ``[0, 2]``:\n\n x = [0, 1]\n i = 0\n i, x[i] = 1, 2\n print(x)\n\nSee also:\n\n **PEP 3132** - Extended Iterable Unpacking\n The specification for the ``*target`` feature.\n\n\nAugmented assignment statements\n===============================\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
'atom-identifiers': '\nIdentifiers (Names)\n*******************\n\nAn identifier occurring as an atom is a name. See section\n*Identifiers and keywords* for lexical definition and section *Naming\nand binding* for documentation of naming and binding.\n\nWhen the name is bound to an object, evaluation of the atom yields\nthat object. When a name is not bound, an attempt to evaluate it\nraises a ``NameError`` exception.\n\n**Private name mangling:** When an identifier that textually occurs in\na class definition begins with two or more underscore characters and\ndoes not end in two or more underscores, it is considered a *private\nname* of that class. Private names are transformed to a longer form\nbefore code is generated for them. The transformation inserts the\nclass name in front of the name, with leading underscores removed, and\na single underscore inserted in front of the class name. For example,\nthe identifier ``__spam`` occurring in a class named ``Ham`` will be\ntransformed to ``_Ham__spam``. This transformation is independent of\nthe syntactical context in which the identifier is used. If the\ntransformed name is extremely long (longer than 255 characters),\nimplementation defined truncation may happen. If the class name\nconsists only of underscores, no transformation is done.\n',
- 'atom-literals': "\nLiterals\n********\n\nPython supports string literals and various numeric literals:\n\n literal ::= stringliteral | integer | longinteger\n | floatnumber | imagnumber\n\nEvaluation of a literal yields an object of the given type (string,\ninteger, long integer, floating point number, complex number) with the\ngiven value. The value may be approximated in the case of floating\npoint and imaginary (complex) literals. See section *Literals* for\ndetails.\n\nAll literals correspond to immutable data types, and hence the\nobject's identity is less important than its value. Multiple\nevaluations of literals with the same value (either the same\noccurrence in the program text or a different occurrence) may obtain\nthe same object or a different object with the same value.\n",
- 'attribute-access': '\nCustomizing attribute access\n****************************\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control in new-style classes.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should not simply execute ``self.name = value`` --- this would\n cause a recursive call to itself. Instead, it should insert the\n value in the dictionary of instance attributes, e.g.,\n ``self.__dict__[name] = value``. For new-style classes, rather\n than accessing the instance dictionary, it should call the base\n class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\n\nMore attribute access for new-style classes\n===========================================\n\nThe following methods only apply to new-style classes.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup for new-style\n classes*.\n\n\nImplementing Descriptors\n========================\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n====================\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called. Note that descriptors are only invoked for new\nstyle objects or classes (ones that subclass ``object()`` or\n``type()``).\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to a new-style object instance, ``a.x`` is transformed\n into the call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a new-style class, ``A.x`` is transformed into the\n call: ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, obj.__class__)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n=========\n\nBy default, instances of both old and new-style classes have a\ndictionary for attribute storage. This wastes space for objects\nhaving very few instance variables. The space consumption can become\nacute when creating large numbers of instances.\n\nThe default can be overridden by defining *__slots__* in a new-style\nclass definition. The *__slots__* declaration takes a sequence of\ninstance variables and reserves just enough space in each instance to\nhold a value for each variable. Space is saved because *__dict__* is\nnot created for each instance.\n\n__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n new-style class, *__slots__* reserves space for the declared\n variables and prevents the automatic creation of *__dict__* and\n *__weakref__* for each instance.\n\n New in version 2.2.\n\nNotes on using *__slots__*\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n Changed in version 2.3: Previously, adding ``\'__dict__\'`` to the\n *__slots__* declaration would not enable the assignment of new\n attributes not specifically listed in the sequence of instance\n variable names.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n Changed in version 2.3: Previously, adding ``\'__weakref__\'`` to the\n *__slots__* declaration would not enable support for weak\n references.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``long``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n Changed in version 2.6: Previously, *__class__* assignment raised an\n error if either new or old class had *__slots__*.\n',
- 'attribute-references': '\nAttribute references\n********************\n\nAn attribute reference is a primary followed by a period and a name:\n\n attributeref ::= primary "." identifier\n\nThe primary must evaluate to an object of a type that supports\nattribute references, e.g., a module, list, or an instance. This\nobject is then asked to produce the attribute whose name is the\nidentifier. If this attribute is not available, the exception\n``AttributeError`` is raised. Otherwise, the type and value of the\nobject produced is determined by the object. Multiple evaluations of\nthe same attribute reference may yield different objects.\n',
+ 'atom-literals': "\nLiterals\n********\n\nPython supports string and bytes literals and various numeric\nliterals:\n\n literal ::= stringliteral | bytesliteral\n | integer | floatnumber | imagnumber\n\nEvaluation of a literal yields an object of the given type (string,\nbytes, integer, floating point number, complex number) with the given\nvalue. The value may be approximated in the case of floating point\nand imaginary (complex) literals. See section *Literals* for details.\n\nAll literals correspond to immutable data types, and hence the\nobject's identity is less important than its value. Multiple\nevaluations of literals with the same value (either the same\noccurrence in the program text or a different occurrence) may obtain\nthe same object or a different object with the same value.\n",
+ 'attribute-access': '\nCustomizing attribute access\n****************************\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n========================\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n====================\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, obj.__class__)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n=========\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n--------------------------\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n',
+ 'attribute-references': '\nAttribute references\n********************\n\nAn attribute reference is a primary followed by a period and a name:\n\n attributeref ::= primary "." identifier\n\nThe primary must evaluate to an object of a type that supports\nattribute references, which most objects do. This object is then\nasked to produce the attribute whose name is the identifier (which can\nbe customized by overriding the ``__getattr__()`` method). If this\nattribute is not available, the exception ``AttributeError`` is\nraised. Otherwise, the type and value of the object produced is\ndetermined by the object. Multiple evaluations of the same attribute\nreference may yield different objects.\n',
'augassign': '\nAugmented assignment statements\n*******************************\n\nAugmented assignment is the combination, in a single statement, of a\nbinary operation and an assignment statement:\n\n augmented_assignment_stmt ::= augtarget augop (expression_list | yield_expression)\n augtarget ::= identifier | attributeref | subscription | slicing\n augop ::= "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="\n | ">>=" | "<<=" | "&=" | "^=" | "|="\n\n(See section *Primaries* for the syntax definitions for the last three\nsymbols.)\n\nAn augmented assignment evaluates the target (which, unlike normal\nassignment statements, cannot be an unpacking) and the expression\nlist, performs the binary operation specific to the type of assignment\non the two operands, and assigns the result to the original target.\nThe target is only evaluated once.\n\nAn augmented assignment expression like ``x += 1`` can be rewritten as\n``x = x + 1`` to achieve a similar, but not exactly equal effect. In\nthe augmented version, ``x`` is only evaluated once. Also, when\npossible, the actual operation is performed *in-place*, meaning that\nrather than creating a new object and assigning that to the target,\nthe old object is modified instead.\n\nWith the exception of assigning to tuples and multiple targets in a\nsingle statement, the assignment done by augmented assignment\nstatements is handled the same way as normal assignments. Similarly,\nwith the exception of the possible *in-place* behavior, the binary\noperation performed by augmented assignment is the same as the normal\nbinary operations.\n\nFor targets which are attribute references, the same *caveat about\nclass and instance attributes* applies as for regular assignments.\n',
- 'binary': '\nBinary arithmetic operations\n****************************\n\nThe binary arithmetic operations have the conventional priority\nlevels. Note that some of these operations also apply to certain non-\nnumeric types. Apart from the power operator, there are only two\nlevels, one for multiplicative operators and one for additive\noperators:\n\n m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr\n | m_expr "%" u_expr\n a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n\nThe ``*`` (multiplication) operator yields the product of its\narguments. The arguments must either both be numbers, or one argument\nmust be an integer (plain or long) and the other must be a sequence.\nIn the former case, the numbers are converted to a common type and\nthen multiplied together. In the latter case, sequence repetition is\nperformed; a negative repetition factor yields an empty sequence.\n\nThe ``/`` (division) and ``//`` (floor division) operators yield the\nquotient of their arguments. The numeric arguments are first\nconverted to a common type. Plain or long integer division yields an\ninteger of the same type; the result is that of mathematical division\nwith the \'floor\' function applied to the result. Division by zero\nraises the ``ZeroDivisionError`` exception.\n\nThe ``%`` (modulo) operator yields the remainder from the division of\nthe first argument by the second. The numeric arguments are first\nconverted to a common type. A zero right argument raises the\n``ZeroDivisionError`` exception. The arguments may be floating point\nnumbers, e.g., ``3.14%0.7`` equals ``0.34`` (since ``3.14`` equals\n``4*0.7 + 0.34``.) The modulo operator always yields a result with\nthe same sign as its second operand (or zero); the absolute value of\nthe result is strictly smaller than the absolute value of the second\noperand [2].\n\nThe integer division and modulo operators are connected by the\nfollowing identity: ``x == (x/y)*y + (x%y)``. Integer division and\nmodulo are also connected with the built-in function ``divmod()``:\n``divmod(x, y) == (x/y, x%y)``. These identities don\'t hold for\nfloating point numbers; there similar identities hold approximately\nwhere ``x/y`` is replaced by ``floor(x/y)`` or ``floor(x/y) - 1`` [3].\n\nIn addition to performing the modulo operation on numbers, the ``%``\noperator is also overloaded by string and unicode objects to perform\nstring formatting (also known as interpolation). The syntax for string\nformatting is described in the Python Library Reference, section\n*String Formatting Operations*.\n\nDeprecated since version 2.3: The floor division operator, the modulo\noperator, and the ``divmod()`` function are no longer defined for\ncomplex numbers. Instead, convert to a floating point number using\nthe ``abs()`` function if appropriate.\n\nThe ``+`` (addition) operator yields the sum of its arguments. The\narguments must either both be numbers or both sequences of the same\ntype. In the former case, the numbers are converted to a common type\nand then added together. In the latter case, the sequences are\nconcatenated.\n\nThe ``-`` (subtraction) operator yields the difference of its\narguments. The numeric arguments are first converted to a common\ntype.\n',
- 'bitwise': '\nBinary bitwise operations\n*************************\n\nEach of the three bitwise operations has a different priority level:\n\n and_expr ::= shift_expr | and_expr "&" shift_expr\n xor_expr ::= and_expr | xor_expr "^" and_expr\n or_expr ::= xor_expr | or_expr "|" xor_expr\n\nThe ``&`` operator yields the bitwise AND of its arguments, which must\nbe plain or long integers. The arguments are converted to a common\ntype.\n\nThe ``^`` operator yields the bitwise XOR (exclusive OR) of its\narguments, which must be plain or long integers. The arguments are\nconverted to a common type.\n\nThe ``|`` operator yields the bitwise (inclusive) OR of its arguments,\nwhich must be plain or long integers. The arguments are converted to\na common type.\n',
- 'bltin-code-objects': '\nCode Objects\n************\n\nCode objects are used by the implementation to represent "pseudo-\ncompiled" executable Python code such as a function body. They differ\nfrom function objects because they don\'t contain a reference to their\nglobal execution environment. Code objects are returned by the built-\nin ``compile()`` function and can be extracted from function objects\nthrough their ``func_code`` attribute. See also the ``code`` module.\n\nA code object can be executed or evaluated by passing it (instead of a\nsource string) to the ``exec`` statement or the built-in ``eval()``\nfunction.\n\nSee *The standard type hierarchy* for more information.\n',
- 'bltin-ellipsis-object': '\nThe Ellipsis Object\n*******************\n\nThis object is used by extended slice notation (see *Slicings*). It\nsupports no special operations. There is exactly one ellipsis object,\nnamed ``Ellipsis`` (a built-in name).\n\nIt is written as ``Ellipsis``. When in a subscript, it can also be\nwritten as ``...``, for example ``seq[...]``.\n',
+ 'binary': '\nBinary arithmetic operations\n****************************\n\nThe binary arithmetic operations have the conventional priority\nlevels. Note that some of these operations also apply to certain non-\nnumeric types. Apart from the power operator, there are only two\nlevels, one for multiplicative operators and one for additive\noperators:\n\n m_expr ::= u_expr | m_expr "*" u_expr | m_expr "//" u_expr | m_expr "/" u_expr\n | m_expr "%" u_expr\n a_expr ::= m_expr | a_expr "+" m_expr | a_expr "-" m_expr\n\nThe ``*`` (multiplication) operator yields the product of its\narguments. The arguments must either both be numbers, or one argument\nmust be an integer and the other must be a sequence. In the former\ncase, the numbers are converted to a common type and then multiplied\ntogether. In the latter case, sequence repetition is performed; a\nnegative repetition factor yields an empty sequence.\n\nThe ``/`` (division) and ``//`` (floor division) operators yield the\nquotient of their arguments. The numeric arguments are first\nconverted to a common type. Integer division yields a float, while\nfloor division of integers results in an integer; the result is that\nof mathematical division with the \'floor\' function applied to the\nresult. Division by zero raises the ``ZeroDivisionError`` exception.\n\nThe ``%`` (modulo) operator yields the remainder from the division of\nthe first argument by the second. The numeric arguments are first\nconverted to a common type. A zero right argument raises the\n``ZeroDivisionError`` exception. The arguments may be floating point\nnumbers, e.g., ``3.14%0.7`` equals ``0.34`` (since ``3.14`` equals\n``4*0.7 + 0.34``.) The modulo operator always yields a result with\nthe same sign as its second operand (or zero); the absolute value of\nthe result is strictly smaller than the absolute value of the second\noperand [1].\n\nThe floor division and modulo operators are connected by the following\nidentity: ``x == (x//y)*y + (x%y)``. Floor division and modulo are\nalso connected with the built-in function ``divmod()``: ``divmod(x, y)\n== (x//y, x%y)``. [2].\n\nIn addition to performing the modulo operation on numbers, the ``%``\noperator is also overloaded by string objects to perform old-style\nstring formatting (also known as interpolation). The syntax for\nstring formatting is described in the Python Library Reference,\nsection *Old String Formatting Operations*.\n\nThe floor division operator, the modulo operator, and the ``divmod()``\nfunction are not defined for complex numbers. Instead, convert to a\nfloating point number using the ``abs()`` function if appropriate.\n\nThe ``+`` (addition) operator yields the sum of its arguments. The\narguments must either both be numbers or both sequences of the same\ntype. In the former case, the numbers are converted to a common type\nand then added together. In the latter case, the sequences are\nconcatenated.\n\nThe ``-`` (subtraction) operator yields the difference of its\narguments. The numeric arguments are first converted to a common\ntype.\n',
+ 'bitwise': '\nBinary bitwise operations\n*************************\n\nEach of the three bitwise operations has a different priority level:\n\n and_expr ::= shift_expr | and_expr "&" shift_expr\n xor_expr ::= and_expr | xor_expr "^" and_expr\n or_expr ::= xor_expr | or_expr "|" xor_expr\n\nThe ``&`` operator yields the bitwise AND of its arguments, which must\nbe integers.\n\nThe ``^`` operator yields the bitwise XOR (exclusive OR) of its\narguments, which must be integers.\n\nThe ``|`` operator yields the bitwise (inclusive) OR of its arguments,\nwhich must be integers.\n',
+ 'bltin-code-objects': '\nCode Objects\n************\n\nCode objects are used by the implementation to represent "pseudo-\ncompiled" executable Python code such as a function body. They differ\nfrom function objects because they don\'t contain a reference to their\nglobal execution environment. Code objects are returned by the built-\nin ``compile()`` function and can be extracted from function objects\nthrough their ``__code__`` attribute. See also the ``code`` module.\n\nA code object can be executed or evaluated by passing it (instead of a\nsource string) to the ``exec()`` or ``eval()`` built-in functions.\n\nSee *The standard type hierarchy* for more information.\n',
+ 'bltin-ellipsis-object': '\nThe Ellipsis Object\n*******************\n\nThis object is commonly used by slicing (see *Slicings*). It supports\nno special operations. There is exactly one ellipsis object, named\n``Ellipsis`` (a built-in name).\n\nIt is written as ``Ellipsis`` or ``...``.\n',
'bltin-null-object': "\nThe Null Object\n***************\n\nThis object is returned by functions that don't explicitly return a\nvalue. It supports no special operations. There is exactly one null\nobject, named ``None`` (a built-in name).\n\nIt is written as ``None``.\n",
- 'bltin-type-objects': "\nType Objects\n************\n\nType objects represent the various object types. An object's type is\naccessed by the built-in function ``type()``. There are no special\noperations on types. The standard module ``types`` defines names for\nall standard built-in types.\n\nTypes are written like this: ``<type 'int'>``.\n",
- 'booleans': '\nBoolean operations\n******************\n\n or_test ::= and_test | or_test "or" and_test\n and_test ::= not_test | and_test "and" not_test\n not_test ::= comparison | "not" not_test\n\nIn the context of Boolean operations, and also when expressions are\nused by control flow statements, the following values are interpreted\nas false: ``False``, ``None``, numeric zero of all types, and empty\nstrings and containers (including strings, tuples, lists,\ndictionaries, sets and frozensets). All other values are interpreted\nas true. (See the ``__nonzero__()`` special method for a way to\nchange this.)\n\nThe operator ``not`` yields ``True`` if its argument is false,\n``False`` otherwise.\n\nThe expression ``x and y`` first evaluates *x*; if *x* is false, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\nThe expression ``x or y`` first evaluates *x*; if *x* is true, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\n(Note that neither ``and`` nor ``or`` restrict the value and type they\nreturn to ``False`` and ``True``, but rather return the last evaluated\nargument. This is sometimes useful, e.g., if ``s`` is a string that\nshould be replaced by a default value if it is empty, the expression\n``s or \'foo\'`` yields the desired value. Because ``not`` has to\ninvent a value anyway, it does not bother to return a value of the\nsame type as its argument, so e.g., ``not \'foo\'`` yields ``False``,\nnot ``\'\'``.)\n',
+ 'bltin-type-objects': "\nType Objects\n************\n\nType objects represent the various object types. An object's type is\naccessed by the built-in function ``type()``. There are no special\noperations on types. The standard module ``types`` defines names for\nall standard built-in types.\n\nTypes are written like this: ``<class 'int'>``.\n",
+ 'booleans': '\nBoolean operations\n******************\n\n or_test ::= and_test | or_test "or" and_test\n and_test ::= not_test | and_test "and" not_test\n not_test ::= comparison | "not" not_test\n\nIn the context of Boolean operations, and also when expressions are\nused by control flow statements, the following values are interpreted\nas false: ``False``, ``None``, numeric zero of all types, and empty\nstrings and containers (including strings, tuples, lists,\ndictionaries, sets and frozensets). All other values are interpreted\nas true. User-defined objects can customize their truth value by\nproviding a ``__bool__()`` method.\n\nThe operator ``not`` yields ``True`` if its argument is false,\n``False`` otherwise.\n\nThe expression ``x and y`` first evaluates *x*; if *x* is false, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\nThe expression ``x or y`` first evaluates *x*; if *x* is true, its\nvalue is returned; otherwise, *y* is evaluated and the resulting value\nis returned.\n\n(Note that neither ``and`` nor ``or`` restrict the value and type they\nreturn to ``False`` and ``True``, but rather return the last evaluated\nargument. This is sometimes useful, e.g., if ``s`` is a string that\nshould be replaced by a default value if it is empty, the expression\n``s or \'foo\'`` yields the desired value. Because ``not`` has to\ninvent a value anyway, it does not bother to return a value of the\nsame type as its argument, so e.g., ``not \'foo\'`` yields ``False``,\nnot ``\'\'``.)\n',
'break': '\nThe ``break`` statement\n***********************\n\n break_stmt ::= "break"\n\n``break`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition\nwithin that loop.\n\nIt terminates the nearest enclosing loop, skipping the optional\n``else`` clause if the loop has one.\n\nIf a ``for`` loop is terminated by ``break``, the loop control target\nkeeps its current value.\n\nWhen ``break`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the loop.\n',
'callable-types': '\nEmulating callable objects\n**************************\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n',
- 'calls': '\nCalls\n*****\n\nA call calls a callable object (e.g., a function) with a possibly\nempty series of arguments:\n\n call ::= primary "(" [argument_list [","]\n | expression genexpr_for] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," "**" expression]\n | "*" expression ["," "*" expression] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nA trailing comma may be present after the positional and keyword\narguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and certain class instances\nthemselves are callable; extensions may define additional callable\nobject types). All argument expressions are evaluated before the call\nis attempted. Please refer to section *Function definitions* for the\nsyntax of formal parameter lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a ``TypeError`` exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is ``None``, it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a\n``TypeError`` exception is raised. Otherwise, the list of filled\nslots is used as the argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use ``PyArg_ParseTuple()`` to\nparse their arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``*identifier`` is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``**identifier`` is present; in this case, that\nformal parameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax ``*expression`` appears in the function call,\n``expression`` must evaluate to an iterable. Elements from this\niterable are treated as if they were additional positional arguments;\nif there are positional arguments *x1*, ..., *xN*, and ``expression``\nevaluates to a sequence *y1*, ..., *yM*, this is equivalent to a call\nwith M+N positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the ``*expression`` syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the ``**expression`` argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print a, b\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the ``*expression``\nsyntax to be used in the same call, so in practice this confusion does\nnot arise.\n\nIf the syntax ``**expression`` appears in the function call,\n``expression`` must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both ``expression`` and as an explicit keyword argument,\na ``TypeError`` exception is raised.\n\nFormal parameters using the syntax ``*identifier`` or ``**identifier``\ncannot be used as positional argument slots or as keyword argument\nnames. Formal parameters using the syntax ``(sublist)`` cannot be\nused as keyword argument names; the outermost sublist corresponds to a\nsingle unnamed argument slot, and the argument value is assigned to\nthe sublist using the usual tuple assignment rules after all other\nparameter processing is done.\n\nA call always returns some value, possibly ``None``, unless it raises\nan exception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a ``return``\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a ``__call__()`` method; the effect is then\n the same as if that method was called.\n',
- 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= "class" classname [inheritance] ":" suite\n inheritance ::= "(" [expression_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. It first evaluates the\ninheritance list, if present. Each item in the inheritance list\nshould evaluate to a class object or class type which allows\nsubclassing. The class\'s suite is then executed in a new execution\nframe (see section *Naming and binding*), using a newly created local\nnamespace and the original global namespace. (Usually, the suite\ncontains only function definitions.) When the class\'s suite finishes\nexecution, its execution frame is discarded but its local namespace is\nsaved. [4] A class object is then created using the inheritance list\nfor the base classes and the saved local namespace for the attribute\ndictionary. The class name is bound to this class object in the\noriginal local namespace.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass variables; they are shared by all instances. To create instance\nvariables, they can be set in a method with ``self.name = value``.\nBoth class and instance variables are accessible through the notation\n"``self.name``", and an instance variable hides a class variable with\nthe same name when accessed in this way. Class variables can be used\nas defaults for instance variables, but using mutable values there can\nlead to unexpected results. For *new-style class*es, descriptors can\nbe used to create instance variables with different implementation\ndetails.\n\nClass definitions, like function definitions, may be wrapped by one or\nmore *decorator* expressions. The evaluation rules for the decorator\nexpressions are the same as for functions. The result must be a class\nobject, which is then bound to the class name.\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless there\n is a ``finally`` clause which happens to raise another exception.\n That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
- 'comparisons': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe forms ``<>`` and ``!=`` are equivalent; for consistency with C,\n``!=`` is preferred; where ``!=`` is mentioned below ``<>`` is also\naccepted. The ``<>`` spelling is considered obsolescent.\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nobjects of different types *always* compare unequal, and are ordered\nconsistently but arbitrarily. You can control comparison behavior of\nobjects of non-built-in types by defining a ``__cmp__`` method or rich\ncomparison methods like ``__gt__``, described in section *Special\nmethod names*.\n\n(This unusual definition of comparison was used to simplify the\ndefinition of operations like sorting and the ``in`` and ``not in``\noperators. In the future, the comparison rules for objects of\ndifferent types are likely to change.)\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n Unicode and 8-bit strings are fully interoperable in this behavior.\n [4]\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``cmp([1,2,x], [1,2,y])`` returns\n the same as ``cmp(x,y)``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if their sorted\n (key, value) lists compare equal. [5] Outcomes other than equality\n are resolved consistently, but are not otherwise defined. [6]\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nThe operators ``in`` and ``not in`` test for collection membership.\n``x in s`` evaluates to true if *x* is a member of the collection *s*,\nand false otherwise. ``x not in s`` returns the negation of ``x in\ns``. The collection membership test has traditionally been bound to\nsequences; an object is a member of a collection if the collection is\na sequence and contains an element equal to that object. However, it\nmake sense for many other object types to support membership tests\nwithout being a sequence. In particular, dictionaries (for keys) and\nsets support membership testing.\n\nFor the list and tuple types, ``x in y`` is true if and only if there\nexists an index *i* such that ``x == y[i]`` is true.\n\nFor the Unicode and string types, ``x in y`` is true if and only if\n*x* is a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nNote, *x* and *y* need not be the same type; consequently, ``u\'ab\' in\n\'abc\'`` will return ``True``. Empty strings are always considered to\nbe a substring of any other string, so ``"" in "abc"`` will return\n``True``.\n\nChanged in version 2.3: Previously, *x* was required to be a string of\nlength ``1``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [7]\n',
- 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs. ``try`` specifies exception handlers and/or\ncleanup code for a group of statements. Function and class\ndefinitions are also syntactically compound statements.\n\nCompound statements consist of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n if test1: if test2: print x\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print`` statements are executed:\n\n if x < y < z: print x; print y; print z\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n | decorated\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``. Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments, and then the suite is executed. When the items are\nexhausted (which is immediately when the sequence is empty), the suite\nin the ``else`` clause, if present, is executed, and the loop\nterminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nThe target list is not deleted when the loop is finished, but if the\nsequence is empty, it will not have been assigned to at all by the\nloop. Hint: the built-in function ``range()`` returns a sequence of\nintegers suitable to emulate the effect of Pascal\'s ``for i := a to b\ndo``; e.g., ``range(3)`` returns the list ``[0, 1, 2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An internal\n counter is used to keep track of which item is used next, and this\n is incremented on each iteration. When this counter has reached the\n length of the sequence the loop terminates. This means that if the\n suite deletes the current (or a previous) item from the sequence,\n the next item will be skipped (since it gets the index of the\n current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression [("as" | ",") target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nChanged in version 2.5: In previous versions of Python,\n``try``...``except``...``finally`` did not work. ``try``...``except``\nhad to be nested in ``try``...``finally``.\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object, a tuple containing an item compatible with the\nexception, or, in the (deprecated) case of string exceptions, is the\nraised string itself (note that the object identities must match, i.e.\nit must be the same string object, not just a string with the same\nvalue).\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified in that except clause, if present, and the except\nclause\'s suite is executed. All except clauses must have an\nexecutable block. When the end of this block is reached, execution\ncontinues normally after the entire try statement. (This means that\nif two nested handlers exist for the same exception, and the exception\noccurs in the try clause of the inner handler, the outer handler will\nnot handle the exception.)\n\nBefore an except clause\'s suite is executed, details about the\nexception are assigned to three variables in the ``sys`` module:\n``sys.exc_type`` receives the object identifying the exception;\n``sys.exc_value`` receives the exception\'s parameter;\n``sys.exc_traceback`` receives a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. These details are also available through the\n``sys.exc_info()`` function, which returns a tuple ``(exc_type,\nexc_value, exc_traceback)``. Use of the corresponding variables is\ndeprecated in favor of this function, since their use is unsafe in a\nthreaded program. As of Python 1.5, the variables are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nNew in version 2.5.\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nNote: In Python 2.5, the ``with`` statement is only allowed when the\n ``with_statement`` feature has been enabled. It is always enabled\n in Python 2.6.\n\nChanged in version 2.7: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n decorated ::= decorators (classdef | funcdef)\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n funcdef ::= "def" funcname "(" [parameter_list] ")" ":" suite\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" identifier [, "**" identifier]\n | "**" identifier\n | defparameter [","] )\n defparameter ::= parameter ["=" expression]\n sublist ::= parameter ("," parameter)* [","]\n parameter ::= identifier | "(" sublist ")"\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code:\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to:\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more top-level parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters must also have a default value --- this is a syntactic\nrestriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that the same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= "class" classname [inheritance] ":" suite\n inheritance ::= "(" [expression_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. It first evaluates the\ninheritance list, if present. Each item in the inheritance list\nshould evaluate to a class object or class type which allows\nsubclassing. The class\'s suite is then executed in a new execution\nframe (see section *Naming and binding*), using a newly created local\nnamespace and the original global namespace. (Usually, the suite\ncontains only function definitions.) When the class\'s suite finishes\nexecution, its execution frame is discarded but its local namespace is\nsaved. [4] A class object is then created using the inheritance list\nfor the base classes and the saved local namespace for the attribute\ndictionary. The class name is bound to this class object in the\noriginal local namespace.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass variables; they are shared by all instances. To create instance\nvariables, they can be set in a method with ``self.name = value``.\nBoth class and instance variables are accessible through the notation\n"``self.name``", and an instance variable hides a class variable with\nthe same name when accessed in this way. Class variables can be used\nas defaults for instance variables, but using mutable values there can\nlead to unexpected results. For *new-style class*es, descriptors can\nbe used to create instance variables with different implementation\ndetails.\n\nClass definitions, like function definitions, may be wrapped by one or\nmore *decorator* expressions. The evaluation rules for the decorator\nexpressions are the same as for functions. The result must be a class\nobject, which is then bound to the class name.\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless there\n is a ``finally`` clause which happens to raise another exception.\n That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
- 'context-managers': '\nWith Statement Context Managers\n*******************************\n\nNew in version 2.5.\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
+ 'calls': '\nCalls\n*****\n\nA call calls a callable object (e.g., a function) with a possibly\nempty series of arguments:\n\n call ::= primary "(" [argument_list [","] | comprehension] ")"\n argument_list ::= positional_arguments ["," keyword_arguments]\n ["," "*" expression] ["," keyword_arguments]\n ["," "**" expression]\n | keyword_arguments ["," "*" expression]\n ["," keyword_arguments] ["," "**" expression]\n | "*" expression ["," keyword_arguments] ["," "**" expression]\n | "**" expression\n positional_arguments ::= expression ("," expression)*\n keyword_arguments ::= keyword_item ("," keyword_item)*\n keyword_item ::= identifier "=" expression\n\nA trailing comma may be present after the positional and keyword\narguments but does not affect the semantics.\n\nThe primary must evaluate to a callable object (user-defined\nfunctions, built-in functions, methods of built-in objects, class\nobjects, methods of class instances, and all objects having a\n``__call__()`` method are callable). All argument expressions are\nevaluated before the call is attempted. Please refer to section\n*Function definitions* for the syntax of formal parameter lists.\n\nIf keyword arguments are present, they are first converted to\npositional arguments, as follows. First, a list of unfilled slots is\ncreated for the formal parameters. If there are N positional\narguments, they are placed in the first N slots. Next, for each\nkeyword argument, the identifier is used to determine the\ncorresponding slot (if the identifier is the same as the first formal\nparameter name, the first slot is used, and so on). If the slot is\nalready filled, a ``TypeError`` exception is raised. Otherwise, the\nvalue of the argument is placed in the slot, filling it (even if the\nexpression is ``None``, it fills the slot). When all arguments have\nbeen processed, the slots that are still unfilled are filled with the\ncorresponding default value from the function definition. (Default\nvalues are calculated, once, when the function is defined; thus, a\nmutable object such as a list or dictionary used as default value will\nbe shared by all calls that don\'t specify an argument value for the\ncorresponding slot; this should usually be avoided.) If there are any\nunfilled slots for which no default value is specified, a\n``TypeError`` exception is raised. Otherwise, the list of filled\nslots is used as the argument list for the call.\n\n**CPython implementation detail:** An implementation may provide\nbuilt-in functions whose positional parameters do not have names, even\nif they are \'named\' for the purpose of documentation, and which\ntherefore cannot be supplied by keyword. In CPython, this is the case\nfor functions implemented in C that use ``PyArg_ParseTuple()`` to\nparse their arguments.\n\nIf there are more positional arguments than there are formal parameter\nslots, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``*identifier`` is present; in this case, that formal\nparameter receives a tuple containing the excess positional arguments\n(or an empty tuple if there were no excess positional arguments).\n\nIf any keyword argument does not correspond to a formal parameter\nname, a ``TypeError`` exception is raised, unless a formal parameter\nusing the syntax ``**identifier`` is present; in this case, that\nformal parameter receives a dictionary containing the excess keyword\narguments (using the keywords as keys and the argument values as\ncorresponding values), or a (new) empty dictionary if there were no\nexcess keyword arguments.\n\nIf the syntax ``*expression`` appears in the function call,\n``expression`` must evaluate to an iterable. Elements from this\niterable are treated as if they were additional positional arguments;\nif there are positional arguments *x1*, ..., *xN*, and ``expression``\nevaluates to a sequence *y1*, ..., *yM*, this is equivalent to a call\nwith M+N positional arguments *x1*, ..., *xN*, *y1*, ..., *yM*.\n\nA consequence of this is that although the ``*expression`` syntax may\nappear *after* some keyword arguments, it is processed *before* the\nkeyword arguments (and the ``**expression`` argument, if any -- see\nbelow). So:\n\n >>> def f(a, b):\n ... print(a, b)\n ...\n >>> f(b=1, *(2,))\n 2 1\n >>> f(a=1, *(2,))\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n TypeError: f() got multiple values for keyword argument \'a\'\n >>> f(1, *(2,))\n 1 2\n\nIt is unusual for both keyword arguments and the ``*expression``\nsyntax to be used in the same call, so in practice this confusion does\nnot arise.\n\nIf the syntax ``**expression`` appears in the function call,\n``expression`` must evaluate to a mapping, the contents of which are\ntreated as additional keyword arguments. In the case of a keyword\nappearing in both ``expression`` and as an explicit keyword argument,\na ``TypeError`` exception is raised.\n\nFormal parameters using the syntax ``*identifier`` or ``**identifier``\ncannot be used as positional argument slots or as keyword argument\nnames.\n\nA call always returns some value, possibly ``None``, unless it raises\nan exception. How this value is computed depends on the type of the\ncallable object.\n\nIf it is---\n\na user-defined function:\n The code block for the function is executed, passing it the\n argument list. The first thing the code block will do is bind the\n formal parameters to the arguments; this is described in section\n *Function definitions*. When the code block executes a ``return``\n statement, this specifies the return value of the function call.\n\na built-in function or method:\n The result is up to the interpreter; see *Built-in Functions* for\n the descriptions of built-in functions and methods.\n\na class object:\n A new instance of that class is returned.\n\na class instance method:\n The corresponding user-defined function is called, with an argument\n list that is one longer than the argument list of the call: the\n instance becomes the first argument.\n\na class instance:\n The class must define a ``__call__()`` method; the effect is then\n the same as if that method was called.\n',
+ 'class': '\nClass definitions\n*****************\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with ``self.name = value``. Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way. Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results. *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n **PEP 3115** - Metaclasses in Python 3 **PEP 3129** - Class\n Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless there\n is a ``finally`` clause which happens to raise another exception.\n That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
+ 'comparisons': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [4]\n',
+ 'compound': '\nCompound statements\n*******************\n\nCompound statements contain (groups of) other statements; they affect\nor control the execution of those other statements in some way. In\ngeneral, compound statements span multiple lines, although in simple\nincarnations a whole compound statement may be contained in one line.\n\nThe ``if``, ``while`` and ``for`` statements implement traditional\ncontrol flow constructs. ``try`` specifies exception handlers and/or\ncleanup code for a group of statements, while the ``with`` statement\nallows the execution of initialization and finalization code around a\nblock of code. Function and class definitions are also syntactically\ncompound statements.\n\nCompound statements consist of one or more \'clauses.\' A clause\nconsists of a header and a \'suite.\' The clause headers of a\nparticular compound statement are all at the same indentation level.\nEach clause header begins with a uniquely identifying keyword and ends\nwith a colon. A suite is a group of statements controlled by a\nclause. A suite can be one or more semicolon-separated simple\nstatements on the same line as the header, following the header\'s\ncolon, or it can be one or more indented statements on subsequent\nlines. Only the latter form of suite can contain nested compound\nstatements; the following is illegal, mostly because it wouldn\'t be\nclear to which ``if`` clause a following ``else`` clause would belong:\n\n if test1: if test2: print(x)\n\nAlso note that the semicolon binds tighter than the colon in this\ncontext, so that in the following example, either all or none of the\n``print()`` calls are executed:\n\n if x < y < z: print(x); print(y); print(z)\n\nSummarizing:\n\n compound_stmt ::= if_stmt\n | while_stmt\n | for_stmt\n | try_stmt\n | with_stmt\n | funcdef\n | classdef\n suite ::= stmt_list NEWLINE | NEWLINE INDENT statement+ DEDENT\n statement ::= stmt_list NEWLINE | compound_stmt\n stmt_list ::= simple_stmt (";" simple_stmt)* [";"]\n\nNote that statements always end in a ``NEWLINE`` possibly followed by\na ``DEDENT``. Also note that optional continuation clauses always\nbegin with a keyword that cannot start a statement, thus there are no\nambiguities (the \'dangling ``else``\' problem is solved in Python by\nrequiring nested ``if`` statements to be indented).\n\nThe formatting of the grammar rules in the following sections places\neach clause on a separate line for clarity.\n\n\nThe ``if`` statement\n====================\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n\n\nThe ``while`` statement\n=======================\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n\n\nThe ``for`` statement\n=====================\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop. Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n\n\nThe ``try`` statement\n=====================\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting of\nthe exception class, the exception instance and a traceback object\n(see section *The standard type hierarchy*) identifying the point in\nthe program where the exception occurred. ``sys.exc_info()`` values\nare restored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is set as the context of the new exception. The exception\ninformation is not available to the program during execution of the\n``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n\n\nThe ``with`` statement\n======================\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nFunction definitions\n====================\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" [parameter] ("," defparameter)*\n [, "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that the same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name. Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``. Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list. These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code. The presence of annotations does not change the\nsemantics of a function. The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n\n\nClass definitions\n=================\n\nA class definition defines a class object (see section *The standard\ntype hierarchy*):\n\n classdef ::= [decorators] "class" classname [inheritance] ":" suite\n inheritance ::= "(" [parameter_list] ")"\n classname ::= identifier\n\nA class definition is an executable statement. The inheritance list\nusually gives a list of base classes (see *Customizing class creation*\nfor more advanced uses), so each item in the list should evaluate to a\nclass object which allows subclassing. Classes without an inheritance\nlist inherit, by default, from the base class ``object``; hence,\n\n class Foo:\n pass\n\nis equivalent to\n\n class Foo(object):\n pass\n\nThe class\'s suite is then executed in a new execution frame (see\n*Naming and binding*), using a newly created local namespace and the\noriginal global namespace. (Usually, the suite contains mostly\nfunction definitions.) When the class\'s suite finishes execution, its\nexecution frame is discarded but its local namespace is saved. [4] A\nclass object is then created using the inheritance list for the base\nclasses and the saved local namespace for the attribute dictionary.\nThe class name is bound to this class object in the original local\nnamespace.\n\nClass creation can be customized heavily using *metaclasses*.\n\nClasses can also be decorated: just like when decorating functions,\n\n @f1(arg)\n @f2\n class Foo: pass\n\nis equivalent to\n\n class Foo: pass\n Foo = f1(arg)(f2(Foo))\n\nThe evaluation rules for the decorator expressions are the same as for\nfunction decorators. The result must be a class object, which is then\nbound to the class name.\n\n**Programmer\'s note:** Variables defined in the class definition are\nclass attributes; they are shared by instances. Instance attributes\ncan be set in a method with ``self.name = value``. Both class and\ninstance attributes are accessible through the notation\n"``self.name``", and an instance attribute hides a class attribute\nwith the same name when accessed in this way. Class attributes can be\nused as defaults for instance attributes, but using mutable values\nthere can lead to unexpected results. *Descriptors* can be used to\ncreate instance variables with different implementation details.\n\nSee also:\n\n **PEP 3115** - Metaclasses in Python 3 **PEP 3129** - Class\n Decorators\n\n-[ Footnotes ]-\n\n[1] The exception is propagated to the invocation stack unless there\n is a ``finally`` clause which happens to raise another exception.\n That new exception causes the old one to be lost.\n\n[2] Currently, control "flows off the end" except in the case of an\n exception or the execution of a ``return``, ``continue``, or\n ``break`` statement.\n\n[3] A string literal appearing as the first statement in the function\n body is transformed into the function\'s ``__doc__`` attribute and\n therefore the function\'s *docstring*.\n\n[4] A string literal appearing as the first statement in the class\n body is transformed into the namespace\'s ``__doc__`` item and\n therefore the class\'s *docstring*.\n',
+ 'context-managers': '\nWith Statement Context Managers\n*******************************\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
'continue': '\nThe ``continue`` statement\n**************************\n\n continue_stmt ::= "continue"\n\n``continue`` may only occur syntactically nested in a ``for`` or\n``while`` loop, but not nested in a function or class definition or\n``finally`` clause within that loop. It continues with the next cycle\nof the nearest enclosing loop.\n\nWhen ``continue`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nstarting the next loop cycle.\n',
- 'conversions': '\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," the arguments\nare coerced using the coercion rules listed at *Coercion rules*. If\nboth arguments are standard numeric types, the following coercions are\napplied:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the other\n is converted to floating point;\n\n* otherwise, if either argument is a long integer, the other is\n converted to long integer;\n\n* otherwise, both must be plain integers and no conversion is\n necessary.\n\nSome additional rules apply for certain operators (e.g., a string left\nargument to the \'%\' operator). Extensions can define their own\ncoercions.\n',
- 'customization': '\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_traceback`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.exc_traceback`` or ``sys.last_traceback``. Circular\n references which are garbage are detected when the option cycle\n detector is enabled (it\'s on by default), but can only be cleaned\n up if there are no Python-level ``__del__()`` methods involved.\n Refer to the documentation for the ``gc`` module for more\n information about how ``__del__()`` methods are handled by the\n cycle detector, particularly the description of the ``garbage``\n value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\n See also the *-R* command-line option.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function and by string\n conversions (reverse quotes) to compute the "official" string\n representation of an object. If at all possible, this should look\n like a valid Python expression that could be used to recreate an\n object with the same value (given an appropriate environment). If\n this is not possible, a string of the form ``<...some useful\n description...>`` should be returned. The return value must be a\n string object. If a class defines ``__repr__()`` but not\n ``__str__()``, then ``__repr__()`` is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print``\n statement to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n New in version 2.1.\n\n These are the so-called "rich comparison" methods, and are called\n for comparison operators in preference to ``__cmp__()`` below. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` and\n ``x<>y`` call ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and\n ``x>=y`` calls ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__cmp__(self, other)\n\n Called by comparison operations if rich comparison (see above) is\n not defined. Should return a negative integer if ``self < other``,\n zero if ``self == other``, a positive integer if ``self > other``.\n If no ``__cmp__()``, ``__eq__()`` or ``__ne__()`` operation is\n defined, class instances are compared by object identity\n ("address"). See also the description of ``__hash__()`` for some\n important notes on creating *hashable* objects which support custom\n comparison operations and are usable as dictionary keys. (Note: the\n restriction that exceptions are not propagated by ``__cmp__()`` has\n been removed since Python 1.5.)\n\nobject.__rcmp__(self, other)\n\n Changed in version 2.1: No longer supported.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define a ``__cmp__()`` or ``__eq__()`` method\n it should not define a ``__hash__()`` operation either; if it\n defines ``__cmp__()`` or ``__eq__()`` but not ``__hash__()``, its\n instances will not be usable in hashed collections. If a class\n defines mutable objects and implements a ``__cmp__()`` or\n ``__eq__()`` method, it should not implement ``__hash__()``, since\n hashable collection implementations require that a object\'s hash\n value is immutable (if the object\'s hash value changes, it will be\n in the wrong hash bucket).\n\n User-defined classes have ``__cmp__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__cmp__()`` or ``__eq__()`` such that\n the hash value returned is no longer appropriate (e.g. by switching\n to a value-based concept of equality instead of the default\n identity based equality) can explicitly flag themselves as being\n unhashable by setting ``__hash__ = None`` in the class definition.\n Doing so means that not only will instances of the class raise an\n appropriate ``TypeError`` when a program attempts to retrieve their\n hash value, but they will also be correctly identified as\n unhashable when checking ``isinstance(obj, collections.Hashable)``\n (unlike classes which define their own ``__hash__()`` to explicitly\n raise ``TypeError``).\n\n Changed in version 2.5: ``__hash__()`` may now also return a long\n integer object; the 32-bit integer is then derived from the hash of\n that object.\n\n Changed in version 2.6: ``__hash__`` may now be set to ``None`` to\n explicitly flag instances of a class as unhashable.\n\nobject.__nonzero__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``, or their integer\n equivalents ``0`` or ``1``. When this method is not defined,\n ``__len__()`` is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither ``__len__()`` nor ``__nonzero__()``, all its instances are\n considered true.\n\nobject.__unicode__(self)\n\n Called to implement ``unicode()`` built-in; should return a Unicode\n object. When this method is not defined, string conversion is\n attempted, and the result of string conversion is converted to\n Unicode using the system default encoding.\n',
- 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible --- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source. The extension interface uses the modules ``bdb``\nand ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > <string>(0)?()\n (Pdb) continue\n > <string>(1)?()\n (Pdb) continue\n NameError: \'spam\'\n > <string>(1)?()\n (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n python -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 2.4: Restarting post-mortem behavior added.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the ``c`` command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print spam\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print spam\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement[, globals[, locals]])\n\n Execute the *statement* (given as a string) under debugger control.\n The debugger prompt appears before any code is executed; you can\n set breakpoints and type ``continue``, or you can step through the\n statement using ``step`` or ``next`` (all these commands are\n explained below). The optional *globals* and *locals* arguments\n specify the environment in which the code is executed; by default\n the dictionary of the module ``__main__`` is used. (See the\n explanation of the ``exec`` statement or the ``eval()`` built-in\n function.)\n\npdb.runeval(expression[, globals[, locals]])\n\n Evaluate the *expression* (given as a string) under debugger\n control. When ``runeval()`` returns, it returns the value of the\n expression. Otherwise this function is similar to ``run()``.\n\npdb.runcall(function[, argument, ...])\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When ``runcall()`` returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem([traceback])\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n ``sys.last_traceback``.\n\nThe ``run*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname. If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None)\n\n ``Pdb`` is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying ``cmd.Cmd`` class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 2.7: The *skip* argument.\n\n run(statement[, globals[, locals]])\n runeval(expression[, globals[, locals]])\n runcall(function[, argument, ...])\n set_trace()\n\n See the documentation for the functions explained above.\n',
- 'del': '\nThe ``del`` statement\n*********************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather than spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a ``global``\nstatement in the same code block. If the name is unbound, a\n``NameError`` exception will be raised.\n\nIt is illegal to delete a name from the local namespace if it occurs\nas a free variable in a nested block.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n',
+ 'conversions': '\nArithmetic conversions\n**********************\n\nWhen a description of an arithmetic operator below uses the phrase\n"the numeric arguments are converted to a common type," this means\nthat the operator implementation for built-in types works that way:\n\n* If either argument is a complex number, the other is converted to\n complex;\n\n* otherwise, if either argument is a floating point number, the other\n is converted to floating point;\n\n* otherwise, both must be integers and no conversion is necessary.\n\nSome additional rules apply for certain operators (e.g., a string left\nargument to the \'%\' operator). Extensions must define their own\nconversion behavior.\n',
+ 'customization': '\nBasic customization\n*******************\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__bytes__(self)\n\n Called by ``bytes()`` to compute a byte-string representation of an\n object. This should return a ``bytes`` object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\n See also the *-R* command-line option.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``. When this method\n is not defined, ``__len__()`` is called, if it is defined, and the\n object is considered true if its result is nonzero. If a class\n defines neither ``__len__()`` nor ``__bool__()``, all its instances\n are considered true.\n',
+ 'debugger': '\n``pdb`` --- The Python Debugger\n*******************************\n\nThe module ``pdb`` defines an interactive source code debugger for\nPython programs. It supports setting (conditional) breakpoints and\nsingle stepping at the source line level, inspection of stack frames,\nsource code listing, and evaluation of arbitrary Python code in the\ncontext of any stack frame. It also supports post-mortem debugging\nand can be called under program control.\n\nThe debugger is extensible -- it is actually defined as the class\n``Pdb``. This is currently undocumented but easily understood by\nreading the source. The extension interface uses the modules ``bdb``\nand ``cmd``.\n\nThe debugger\'s prompt is ``(Pdb)``. Typical usage to run a program\nunder control of the debugger is:\n\n >>> import pdb\n >>> import mymodule\n >>> pdb.run(\'mymodule.test()\')\n > <string>(0)?()\n (Pdb) continue\n > <string>(1)?()\n (Pdb) continue\n NameError: \'spam\'\n > <string>(1)?()\n (Pdb)\n\n``pdb.py`` can also be invoked as a script to debug other scripts.\nFor example:\n\n python3 -m pdb myscript.py\n\nWhen invoked as a script, pdb will automatically enter post-mortem\ndebugging if the program being debugged exits abnormally. After post-\nmortem debugging (or after normal exit of the program), pdb will\nrestart the program. Automatic restarting preserves pdb\'s state (such\nas breakpoints) and in most cases is more useful than quitting the\ndebugger upon program\'s exit.\n\nNew in version 3.2: ``pdb.py`` now accepts a ``-c`` option that\nexecutes commands as if given in a ``.pdbrc`` file, see *Debugger\nCommands*.\n\nThe typical usage to break into the debugger from a running program is\nto insert\n\n import pdb; pdb.set_trace()\n\nat the location you want to break into the debugger. You can then\nstep through the code following this statement, and continue running\nwithout the debugger using the ``continue`` command.\n\nThe typical usage to inspect a crashed program is:\n\n >>> import pdb\n >>> import mymodule\n >>> mymodule.test()\n Traceback (most recent call last):\n File "<stdin>", line 1, in ?\n File "./mymodule.py", line 4, in test\n test2()\n File "./mymodule.py", line 3, in test2\n print(spam)\n NameError: spam\n >>> pdb.pm()\n > ./mymodule.py(3)test2()\n -> print(spam)\n (Pdb)\n\nThe module defines the following functions; each enters the debugger\nin a slightly different way:\n\npdb.run(statement, globals=None, locals=None)\n\n Execute the *statement* (given as a string or a code object) under\n debugger control. The debugger prompt appears before any code is\n executed; you can set breakpoints and type ``continue``, or you can\n step through the statement using ``step`` or ``next`` (all these\n commands are explained below). The optional *globals* and *locals*\n arguments specify the environment in which the code is executed; by\n default the dictionary of the module ``__main__`` is used. (See\n the explanation of the built-in ``exec()`` or ``eval()``\n functions.)\n\npdb.runeval(expression, globals=None, locals=None)\n\n Evaluate the *expression* (given as a string or a code object)\n under debugger control. When ``runeval()`` returns, it returns the\n value of the expression. Otherwise this function is similar to\n ``run()``.\n\npdb.runcall(function, *args, **kwds)\n\n Call the *function* (a function or method object, not a string)\n with the given arguments. When ``runcall()`` returns, it returns\n whatever the function call returned. The debugger prompt appears\n as soon as the function is entered.\n\npdb.set_trace()\n\n Enter the debugger at the calling stack frame. This is useful to\n hard-code a breakpoint at a given point in a program, even if the\n code is not otherwise being debugged (e.g. when an assertion\n fails).\n\npdb.post_mortem(traceback=None)\n\n Enter post-mortem debugging of the given *traceback* object. If no\n *traceback* is given, it uses the one of the exception that is\n currently being handled (an exception must be being handled if the\n default is to be used).\n\npdb.pm()\n\n Enter post-mortem debugging of the traceback found in\n ``sys.last_traceback``.\n\nThe ``run*`` functions and ``set_trace()`` are aliases for\ninstantiating the ``Pdb`` class and calling the method of the same\nname. If you want to access further features, you have to do this\nyourself:\n\nclass class pdb.Pdb(completekey=\'tab\', stdin=None, stdout=None, skip=None, nosigint=False)\n\n ``Pdb`` is the debugger class.\n\n The *completekey*, *stdin* and *stdout* arguments are passed to the\n underlying ``cmd.Cmd`` class; see the description there.\n\n The *skip* argument, if given, must be an iterable of glob-style\n module name patterns. The debugger will not step into frames that\n originate in a module that matches one of these patterns. [1]\n\n By default, Pdb sets a handler for the SIGINT signal (which is sent\n when the user presses Ctrl-C on the console) when you give a\n ``continue`` command. This allows you to break into the debugger\n again by pressing Ctrl-C. If you want Pdb not to touch the SIGINT\n handler, set *nosigint* tot true.\n\n Example call to enable tracing with *skip*:\n\n import pdb; pdb.Pdb(skip=[\'django.*\']).set_trace()\n\n New in version 3.1: The *skip* argument.\n\n New in version 3.2: The *nosigint* argument. Previously, a SIGINT\n handler was never set by Pdb.\n\n run(statement, globals=None, locals=None)\n runeval(expression, globals=None, locals=None)\n runcall(function, *args, **kwds)\n set_trace()\n\n See the documentation for the functions explained above.\n\n\nDebugger Commands\n=================\n\nThe commands recognized by the debugger are listed below. Most\ncommands can be abbreviated to one or two letters as indicated; e.g.\n``h(elp)`` means that either ``h`` or ``help`` can be used to enter\nthe help command (but not ``he`` or ``hel``, nor ``H`` or ``Help`` or\n``HELP``). Arguments to commands must be separated by whitespace\n(spaces or tabs). Optional arguments are enclosed in square brackets\n(``[]``) in the command syntax; the square brackets must not be typed.\nAlternatives in the command syntax are separated by a vertical bar\n(``|``).\n\nEntering a blank line repeats the last command entered. Exception: if\nthe last command was a ``list`` command, the next 11 lines are listed.\n\nCommands that the debugger doesn\'t recognize are assumed to be Python\nstatements and are executed in the context of the program being\ndebugged. Python statements can also be prefixed with an exclamation\npoint (``!``). This is a powerful way to inspect the program being\ndebugged; it is even possible to change a variable or call a function.\nWhen an exception occurs in such a statement, the exception name is\nprinted but the debugger\'s state is not changed.\n\nThe debugger supports *aliases*. Aliases can have parameters which\nallows one a certain level of adaptability to the context under\nexamination.\n\nMultiple commands may be entered on a single line, separated by\n``;;``. (A single ``;`` is not used as it is the separator for\nmultiple commands in a line that is passed to the Python parser.) No\nintelligence is applied to separating the commands; the input is split\nat the first ``;;`` pair, even if it is in the middle of a quoted\nstring.\n\nIf a file ``.pdbrc`` exists in the user\'s home directory or in the\ncurrent directory, it is read in and executed as if it had been typed\nat the debugger prompt. This is particularly useful for aliases. If\nboth files exist, the one in the home directory is read first and\naliases defined there can be overridden by the local file.\n\nChanged in version 3.2: ``.pdbrc`` can now contain commands that\ncontinue debugging, such as ``continue`` or ``next``. Previously,\nthese commands had no effect.\n\nh(elp) [command]\n\n Without argument, print the list of available commands. With a\n *command* as argument, print help about that command. ``help pdb``\n displays the full documentation (the docstring of the ``pdb``\n module). Since the *command* argument must be an identifier,\n ``help exec`` must be entered to get help on the ``!`` command.\n\nw(here)\n\n Print a stack trace, with the most recent frame at the bottom. An\n arrow indicates the current frame, which determines the context of\n most commands.\n\nd(own) [count]\n\n Move the current frame *count* (default one) levels down in the\n stack trace (to a newer frame).\n\nu(p) [count]\n\n Move the current frame *count* (default one) levels up in the stack\n trace (to an older frame).\n\nb(reak) [([filename:]lineno | function) [, condition]]\n\n With a *lineno* argument, set a break there in the current file.\n With a *function* argument, set a break at the first executable\n statement within that function. The line number may be prefixed\n with a filename and a colon, to specify a breakpoint in another\n file (probably one that hasn\'t been loaded yet). The file is\n searched on ``sys.path``. Note that each breakpoint is assigned a\n number to which all the other breakpoint commands refer.\n\n If a second argument is present, it is an expression which must\n evaluate to true before the breakpoint is honored.\n\n Without argument, list all breaks, including for each breakpoint,\n the number of times that breakpoint has been hit, the current\n ignore count, and the associated condition if any.\n\ntbreak [([filename:]lineno | function) [, condition]]\n\n Temporary breakpoint, which is removed automatically when it is\n first hit. The arguments are the same as for ``break``.\n\ncl(ear) [filename:lineno | bpnumber [bpnumber ...]]\n\n With a *filename:lineno* argument, clear all the breakpoints at\n this line. With a space separated list of breakpoint numbers, clear\n those breakpoints. Without argument, clear all breaks (but first\n ask confirmation).\n\ndisable [bpnumber [bpnumber ...]]\n\n Disable the breakpoints given as a space separated list of\n breakpoint numbers. Disabling a breakpoint means it cannot cause\n the program to stop execution, but unlike clearing a breakpoint, it\n remains in the list of breakpoints and can be (re-)enabled.\n\nenable [bpnumber [bpnumber ...]]\n\n Enable the breakpoints specified.\n\nignore bpnumber [count]\n\n Set the ignore count for the given breakpoint number. If count is\n omitted, the ignore count is set to 0. A breakpoint becomes active\n when the ignore count is zero. When non-zero, the count is\n decremented each time the breakpoint is reached and the breakpoint\n is not disabled and any associated condition evaluates to true.\n\ncondition bpnumber [condition]\n\n Set a new *condition* for the breakpoint, an expression which must\n evaluate to true before the breakpoint is honored. If *condition*\n is absent, any existing condition is removed; i.e., the breakpoint\n is made unconditional.\n\ncommands [bpnumber]\n\n Specify a list of commands for breakpoint number *bpnumber*. The\n commands themselves appear on the following lines. Type a line\n containing just ``end`` to terminate the commands. An example:\n\n (Pdb) commands 1\n (com) print some_variable\n (com) end\n (Pdb)\n\n To remove all commands from a breakpoint, type commands and follow\n it immediately with ``end``; that is, give no commands.\n\n With no *bpnumber* argument, commands refers to the last breakpoint\n set.\n\n You can use breakpoint commands to start your program up again.\n Simply use the continue command, or step, or any other command that\n resumes execution.\n\n Specifying any command resuming execution (currently continue,\n step, next, return, jump, quit and their abbreviations) terminates\n the command list (as if that command was immediately followed by\n end). This is because any time you resume execution (even with a\n simple next or step), you may encounter another breakpoint--which\n could have its own command list, leading to ambiguities about which\n list to execute.\n\n If you use the \'silent\' command in the command list, the usual\n message about stopping at a breakpoint is not printed. This may be\n desirable for breakpoints that are to print a specific message and\n then continue. If none of the other commands print anything, you\n see no sign that the breakpoint was reached.\n\ns(tep)\n\n Execute the current line, stop at the first possible occasion\n (either in a function that is called or on the next line in the\n current function).\n\nn(ext)\n\n Continue execution until the next line in the current function is\n reached or it returns. (The difference between ``next`` and\n ``step`` is that ``step`` stops inside a called function, while\n ``next`` executes called functions at (nearly) full speed, only\n stopping at the next line in the current function.)\n\nunt(il) [lineno]\n\n Without argument, continue execution until the line with a number\n greater than the current one is reached.\n\n With a line number, continue execution until a line with a number\n greater or equal to that is reached. In both cases, also stop when\n the current frame returns.\n\n Changed in version 3.2: Allow giving an explicit line number.\n\nr(eturn)\n\n Continue execution until the current function returns.\n\nc(ont(inue))\n\n Continue execution, only stop when a breakpoint is encountered.\n\nj(ump) lineno\n\n Set the next line that will be executed. Only available in the\n bottom-most frame. This lets you jump back and execute code again,\n or jump forward to skip code that you don\'t want to run.\n\n It should be noted that not all jumps are allowed -- for instance\n it is not possible to jump into the middle of a ``for`` loop or out\n of a ``finally`` clause.\n\nl(ist) [first[, last]]\n\n List source code for the current file. Without arguments, list 11\n lines around the current line or continue the previous listing.\n With ``.`` as argument, list 11 lines around the current line.\n With one argument, list 11 lines around at that line. With two\n arguments, list the given range; if the second argument is less\n than the first, it is interpreted as a count.\n\n The current line in the current frame is indicated by ``->``. If\n an exception is being debugged, the line where the exception was\n originally raised or propagated is indicated by ``>>``, if it\n differs from the current line.\n\n New in version 3.2: The ``>>`` marker.\n\nll | longlist\n\n List all source code for the current function or frame.\n Interesting lines are marked as for ``list``.\n\n New in version 3.2.\n\na(rgs)\n\n Print the argument list of the current function.\n\np(rint) expression\n\n Evaluate the *expression* in the current context and print its\n value.\n\npp expression\n\n Like the ``print`` command, except the value of the expression is\n pretty-printed using the ``pprint`` module.\n\nwhatis expression\n\n Print the type of the *expression*.\n\nsource expression\n\n Try to get source code for the given object and display it.\n\n New in version 3.2.\n\ndisplay [expression]\n\n Display the value of the expression if it changed, each time\n execution stops in the current frame.\n\n Without expression, list all display expressions for the current\n frame.\n\n New in version 3.2.\n\nundisplay [expression]\n\n Do not display the expression any more in the current frame.\n Without expression, clear all display expressions for the current\n frame.\n\n New in version 3.2.\n\ninteract\n\n Start an interative interpreter (using the ``code`` module) whose\n global namespace contains all the (global and local) names found in\n the current scope.\n\n New in version 3.2.\n\nalias [name [command]]\n\n Create an alias called *name* that executes *command*. The command\n must *not* be enclosed in quotes. Replaceable parameters can be\n indicated by ``%1``, ``%2``, and so on, while ``%*`` is replaced by\n all the parameters. If no command is given, the current alias for\n *name* is shown. If no arguments are given, all aliases are listed.\n\n Aliases may be nested and can contain anything that can be legally\n typed at the pdb prompt. Note that internal pdb commands *can* be\n overridden by aliases. Such a command is then hidden until the\n alias is removed. Aliasing is recursively applied to the first\n word of the command line; all other words in the line are left\n alone.\n\n As an example, here are two useful aliases (especially when placed\n in the ``.pdbrc`` file):\n\n # Print instance variables (usage "pi classInst")\n alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])\n # Print instance variables in self\n alias ps pi self\n\nunalias name\n\n Delete the specified alias.\n\n! statement\n\n Execute the (one-line) *statement* in the context of the current\n stack frame. The exclamation point can be omitted unless the first\n word of the statement resembles a debugger command. To set a\n global variable, you can prefix the assignment command with a\n ``global`` statement on the same line, e.g.:\n\n (Pdb) global list_options; list_options = [\'-l\']\n (Pdb)\n\nrun [args ...]\nrestart [args ...]\n\n Restart the debugged Python program. If an argument is supplied,\n it is split with ``shlex`` and the result is used as the new\n ``sys.argv``. History, breakpoints, actions and debugger options\n are preserved. ``restart`` is an alias for ``run``.\n\nq(uit)\n\n Quit from the debugger. The program being executed is aborted.\n\n-[ Footnotes ]-\n\n[1] Whether a frame is considered to originate in a certain module is\n determined by the ``__name__`` in the frame globals.\n',
+ 'del': '\nThe ``del`` statement\n*********************\n\n del_stmt ::= "del" target_list\n\nDeletion is recursively defined very similar to the way assignment is\ndefined. Rather than spelling it out in full details, here are some\nhints.\n\nDeletion of a target list recursively deletes each target, from left\nto right.\n\nDeletion of a name removes the binding of that name from the local or\nglobal namespace, depending on whether the name occurs in a ``global``\nstatement in the same code block. If the name is unbound, a\n``NameError`` exception will be raised.\n\nDeletion of attribute references, subscriptions and slicings is passed\nto the primary object involved; deletion of a slicing is in general\nequivalent to assignment of an empty slice of the right type (but even\nthis is determined by the sliced object).\n\nChanged in version 3.2.\n',
'dict': '\nDictionary displays\n*******************\n\nA dictionary display is a possibly empty series of key/datum pairs\nenclosed in curly braces:\n\n dict_display ::= "{" [key_datum_list | dict_comprehension] "}"\n key_datum_list ::= key_datum ("," key_datum)* [","]\n key_datum ::= expression ":" expression\n dict_comprehension ::= expression ":" expression comp_for\n\nA dictionary display yields a new dictionary object.\n\nIf a comma-separated sequence of key/datum pairs is given, they are\nevaluated from left to right to define the entries of the dictionary:\neach key object is used as a key into the dictionary to store the\ncorresponding datum. This means that you can specify the same key\nmultiple times in the key/datum list, and the final dictionary\'s value\nfor that key will be the last one given.\n\nA dict comprehension, in contrast to list and set comprehensions,\nneeds two expressions separated with a colon followed by the usual\n"for" and "if" clauses. When the comprehension is run, the resulting\nkey and value elements are inserted in the new dictionary in the order\nthey are produced.\n\nRestrictions on the types of the key values are listed earlier in\nsection *The standard type hierarchy*. (To summarize, the key type\nshould be *hashable*, which excludes all mutable objects.) Clashes\nbetween duplicate keys are not detected; the last datum (textually\nrightmost in the display) stored for a given key value prevails.\n',
- 'dynamic-features': '\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nIf ``exec`` is used in a function and the function contains or is a\nnested block with free variables, the compiler will raise a\n``SyntaxError`` unless the exec explicitly specifies the local\nnamespace for the ``exec``. (In other words, ``exec obj`` would be\nillegal, but ``exec obj in ns`` would be legal.)\n\nThe ``eval()``, ``execfile()``, and ``input()`` functions and the\n``exec`` statement do not have access to the full environment for\nresolving names. Names may be resolved in the local and global\nnamespaces of the caller. Free variables are not resolved in the\nnearest enclosing namespace, but in the global namespace. [1] The\n``exec`` statement and the ``eval()`` and ``execfile()`` functions\nhave optional arguments to override the global and local namespace.\nIf only one namespace is specified, it is used for both.\n',
+ 'dynamic-features': '\nInteraction with dynamic features\n*********************************\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n',
'else': '\nThe ``if`` statement\n********************\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n',
- 'exceptions': '\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nExceptions can also be identified by strings, in which case the\n``except`` clause is selected by object identity. An arbitrary value\ncan be raised along with the identifying string which can be passed to\nthe handler.\n\nNote: Messages to exceptions are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
- 'execmodel': '\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The file read by the\nbuilt-in function ``execfile()`` is a code block. The string argument\npassed to the built-in function ``eval()`` and to the ``exec``\nstatement is a code block. The expression read and evaluated by the\nbuilt-in function ``input()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes generator expressions since\nthey are implemented using a function scope. This means that the\nfollowing will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block.\nIf a name is bound at the module level, it is a global variable. (The\nvariables of the module code block are local and global.) If a\nvariable is used in a code block but not defined there, it is a *free\nvariable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, in the\nsecond position of an ``except`` clause header or after ``as`` in a\n``with`` statement. The ``import`` statement of the form ``from ...\nimport *`` binds all names defined in the imported module, except\nthose beginning with an underscore. This form may only be used at the\nmodule level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the global statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module ``__builtin__``. The global namespace is searched\nfirst. If the name is not found there, the builtins namespace is\nsearched. The global statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module\'s dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``__builtin__`` (note: no \'s\'); when in any other module,\n``__builtins__`` is an alias for the dictionary of the ``__builtin__``\nmodule itself. ``__builtins__`` can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``__builtin__`` (no \'s\') module and modify its attributes\nappropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nIf ``exec`` is used in a function and the function contains or is a\nnested block with free variables, the compiler will raise a\n``SyntaxError`` unless the exec explicitly specifies the local\nnamespace for the ``exec``. (In other words, ``exec obj`` would be\nillegal, but ``exec obj in ns`` would be legal.)\n\nThe ``eval()``, ``execfile()``, and ``input()`` functions and the\n``exec`` statement do not have access to the full environment for\nresolving names. Names may be resolved in the local and global\nnamespaces of the caller. Free variables are not resolved in the\nnearest enclosing namespace, but in the global namespace. [1] The\n``exec`` statement and the ``eval()`` and ``execfile()`` functions\nhave optional arguments to override the global and local namespace.\nIf only one namespace is specified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nExceptions can also be identified by strings, in which case the\n``except`` clause is selected by object identity. An arbitrary value\ncan be raised along with the identifying string which can be passed to\nthe handler.\n\nNote: Messages to exceptions are not part of the Python API. Their\n contents may change from one version of Python to the next without\n warning and should not be relied on by code which will run under\n multiple versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
+ 'exceptions': '\nExceptions\n**********\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nNote: Exception messages are not part of the Python API. Their contents\n may change from one version of Python to the next without warning\n and should not be relied on by code which will run under multiple\n versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
+ 'execmodel': '\nExecution model\n***************\n\n\nNaming and binding\n==================\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the \'**-c**\' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block\'s execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block\'s *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or ``except`` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtins namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtins\nnamespace is searched. The global statement must precede all uses of\nthe name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module\'s dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``builtins`` module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n---------------------------------\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n\n\nExceptions\n==========\n\nExceptions are a means of breaking out of the normal flow of control\nof a code block in order to handle errors or other exceptional\nconditions. An exception is *raised* at the point where the error is\ndetected; it may be *handled* by the surrounding code block or by any\ncode block that directly or indirectly invoked the code block where\nthe error occurred.\n\nThe Python interpreter raises an exception when it detects a run-time\nerror (such as division by zero). A Python program can also\nexplicitly raise an exception with the ``raise`` statement. Exception\nhandlers are specified with the ``try`` ... ``except`` statement. The\n``finally`` clause of such a statement can be used to specify cleanup\ncode which does not handle the exception, but is executed whether an\nexception occurred or not in the preceding code.\n\nPython uses the "termination" model of error handling: an exception\nhandler can find out what happened and continue execution at an outer\nlevel, but it cannot repair the cause of the error and retry the\nfailing operation (except by re-entering the offending piece of code\nfrom the top).\n\nWhen an exception is not handled at all, the interpreter terminates\nexecution of the program, or returns to its interactive main loop. In\neither case, it prints a stack backtrace, except when the exception is\n``SystemExit``.\n\nExceptions are identified by class instances. The ``except`` clause\nis selected depending on the class of the instance: it must reference\nthe class of the instance or a base class thereof. The instance can\nbe received by the handler and can carry additional information about\nthe exceptional condition.\n\nNote: Exception messages are not part of the Python API. Their contents\n may change from one version of Python to the next without warning\n and should not be relied on by code which will run under multiple\n versions of the interpreter.\n\nSee also the description of the ``try`` statement in section *The try\nstatement* and ``raise`` statement in section *The raise statement*.\n\n-[ Footnotes ]-\n\n[1] This limitation occurs because the code that is executed by these\n operations is not available at the time the module is compiled.\n',
'exprlists': '\nExpression lists\n****************\n\n expression_list ::= expression ( "," expression )* [","]\n\nAn expression list containing at least one comma yields a tuple. The\nlength of the tuple is the number of expressions in the list. The\nexpressions are evaluated from left to right.\n\nThe trailing comma is required only to create a single tuple (a.k.a. a\n*singleton*); it is optional in all other cases. A single expression\nwithout a trailing comma doesn\'t create a tuple, but rather yields the\nvalue of that expression. (To create an empty tuple, use an empty pair\nof parentheses: ``()``.)\n',
- 'floating': '\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts of floating point numbers can\nlook like octal integers, but are interpreted using radix 10. For\nexample, ``077e010`` is legal, and denotes the same number as\n``77e10``. The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator ``-`` and the\nliteral ``1``.\n',
- 'for': '\nThe ``for`` statement\n*********************\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments, and then the suite is executed. When the items are\nexhausted (which is immediately when the sequence is empty), the suite\nin the ``else`` clause, if present, is executed, and the loop\nterminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nThe target list is not deleted when the loop is finished, but if the\nsequence is empty, it will not have been assigned to at all by the\nloop. Hint: the built-in function ``range()`` returns a sequence of\nintegers suitable to emulate the effect of Pascal\'s ``for i := a to b\ndo``; e.g., ``range(3)`` returns the list ``[0, 1, 2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An internal\n counter is used to keep track of which item is used next, and this\n is incremented on each iteration. When this counter has reached the\n length of the sequence the loop terminates. This means that if the\n suite deletes the current (or a previous) item from the sequence,\n the next item will be skipped (since it gets the index of the\n current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n',
- 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output. If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n field_name ::= arg_name ("." attribute_name | "[" element_index "]")*\n arg_name ::= [identifier | integer]\n attribute_name ::= identifier\n element_index ::= integer | index_string\n index_string ::= <any source character except "]"> +\n conversion ::= "r" | "s"\n format_spec ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a *conversion* field, which is\npreceded by an exclamation point ``\'!\'``, and a *format_spec*, which\nis preceded by a colon ``\':\'``. These specify a non-default format\nfor the replacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either a\nnumber or a keyword. If it\'s a number, it refers to a positional\nargument, and if it\'s a keyword, it refers to a named keyword\nargument. If the numerical arg_names in a format string are 0, 1, 2,\n... in sequence, they can all be omitted (not just some) and the\nnumbers 0, 1, 2, ... will be automatically inserted in that order.\nBecause *arg_name* is not quote-delimited, it is not possible to\nspecify arbitrary dictionary keys (e.g., the strings ``\'10\'`` or\n``\':-]\'``) within a format string. The *arg_name* can be followed by\nany number of index or attribute expressions. An expression of the\nform ``\'.name\'`` selects the named attribute using ``getattr()``,\nwhile an expression of the form ``\'[index]\'`` does an index lookup\nusing ``__getitem__()``.\n\nChanged in version 2.7: The positional argument specifiers can be\nomitted, so ``\'{} {}\'`` is equivalent to ``\'{0} {1}\'``.\n\nSome simple format string examples:\n\n "First, thou shalt count to {0}" # References first positional argument\n "Bring me a {}" # Implicitly references the first positional argument\n "From {} to {}" # Same as "From {0} to {1}"\n "My quest is {name}" # References keyword argument \'name\'\n "Weight in tons {0.weight}" # \'weight\' attribute of first positional arg\n "Units destroyed: {players[0]}" # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself. However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting. By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nTwo conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, and ``\'!r\'`` which calls ``repr()``.\n\nSome examples:\n\n "Harold\'s a clever {0!s}" # Calls str() on the argument first\n "Bring out the holy {name!r}" # Calls repr() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on. Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed. The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*). They can also be passed directly to the\nbuilt-in ``format()`` function. Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value. A non-\nempty format string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n fill ::= <a character other than \'}\'>\n align ::= "<" | ">" | "=" | "^"\n sign ::= "+" | "-" | " "\n width ::= integer\n precision ::= integer\n type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'{\' or \'}\'. The\npresence of a fill character is signaled by the character following\nit, which must be one of the alignment options. If the second\ncharacter of *format_spec* is not a valid alignment option, then it is\nassumed that both the fill character and the alignment option are\nabsent.\n\nThe meaning of the various alignment options is as follows:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'<\'`` | Forces the field to be left-aligned within the available |\n | | space (this is the default for most objects). |\n +-----------+------------------------------------------------------------+\n | ``\'>\'`` | Forces the field to be right-aligned within the available |\n | | space (this is the default for numbers). |\n +-----------+------------------------------------------------------------+\n | ``\'=\'`` | Forces the padding to be placed after the sign (if any) |\n | | but before the digits. This is used for printing fields |\n | | in the form \'+000000120\'. This alignment option is only |\n | | valid for numeric types. |\n +-----------+------------------------------------------------------------+\n | ``\'^\'`` | Forces the field to be centered within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'+\'`` | indicates that a sign should be used for both positive as |\n | | well as negative numbers. |\n +-----------+------------------------------------------------------------+\n | ``\'-\'`` | indicates that a sign should be used only for negative |\n | | numbers (this is the default behavior). |\n +-----------+------------------------------------------------------------+\n | space | indicates that a leading space should be used on positive |\n | | numbers, and a minus sign on negative numbers. |\n +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option is only valid for integers, and only for binary,\noctal, or hexadecimal output. If present, it specifies that the\noutput will be prefixed by ``\'0b\'``, ``\'0o\'``, or ``\'0x\'``,\nrespectively.\n\nThe ``\',\'`` option signals the use of a comma for a thousands\nseparator. For a locale aware separator, use the ``\'n\'`` integer\npresentation type instead.\n\nChanged in version 2.7: Added the ``\',\'`` option (see also **PEP\n378**).\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding. This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'s\'`` | String format. This is the default type for strings and |\n | | may be omitted. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'s\'``. |\n +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'b\'`` | Binary format. Outputs the number in base 2. |\n +-----------+------------------------------------------------------------+\n | ``\'c\'`` | Character. Converts the integer to the corresponding |\n | | unicode character before printing. |\n +-----------+------------------------------------------------------------+\n | ``\'d\'`` | Decimal Integer. Outputs the number in base 10. |\n +-----------+------------------------------------------------------------+\n | ``\'o\'`` | Octal format. Outputs the number in base 8. |\n +-----------+------------------------------------------------------------+\n | ``\'x\'`` | Hex format. Outputs the number in base 16, using lower- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'X\'`` | Hex format. Outputs the number in base 16, using upper- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'d\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'d\'``. |\n +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except\n``\'n\'`` and None). When doing so, ``float()`` is used to convert the\ninteger to a floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'e\'`` | Exponent notation. Prints the number in scientific |\n | | notation using the letter \'e\' to indicate the exponent. |\n +-----------+------------------------------------------------------------+\n | ``\'E\'`` | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n | | case \'E\' as the separator character. |\n +-----------+------------------------------------------------------------+\n | ``\'f\'`` | Fixed point. Displays the number as a fixed-point number. |\n +-----------+------------------------------------------------------------+\n | ``\'F\'`` | Fixed point. Same as ``\'f\'``. |\n +-----------+------------------------------------------------------------+\n | ``\'g\'`` | General format. For a given precision ``p >= 1``, this |\n | | rounds the number to ``p`` significant digits and then |\n | | formats the result in either fixed-point format or in |\n | | scientific notation, depending on its magnitude. The |\n | | precise rules are as follows: suppose that the result |\n | | formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1`` would have exponent ``exp``. Then if ``-4 <= exp |\n | | < p``, the number is formatted with presentation type |\n | | ``\'f\'`` and precision ``p-1-exp``. Otherwise, the number |\n | | is formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1``. In both cases insignificant trailing zeros are |\n | | removed from the significand, and the decimal point is |\n | | also removed if there are no remaining digits following |\n | | it. Positive and negative infinity, positive and negative |\n | | zero, and nans, are formatted as ``inf``, ``-inf``, ``0``, |\n | | ``-0`` and ``nan`` respectively, regardless of the |\n | | precision. A precision of ``0`` is treated as equivalent |\n | | to a precision of ``1``. |\n +-----------+------------------------------------------------------------+\n | ``\'G\'`` | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n | | if the number gets too large. The representations of |\n | | infinity and NaN are uppercased, too. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'g\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | ``\'%\'`` | Percentage. Multiplies the number by 100 and displays in |\n | | fixed (``\'f\'``) format, followed by a percent sign. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'g\'``. |\n +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the new format syntax and comparison\nwith the old ``%``-formatting.\n\nIn most of the cases the syntax is similar to the old\n``%``-formatting, with the addition of the ``{}`` and with ``:`` used\ninstead of ``%``. For example, ``\'%03.2f\'`` can be translated to\n``\'{:03.2f}\'``.\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n \'a, b, c\'\n >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\') # 2.7+ only\n \'a, b, c\'\n >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n \'c, b, a\'\n >>> \'{2}, {1}, {0}\'.format(*\'abc\') # unpacking argument sequence\n \'c, b, a\'\n >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\') # arguments\' indices can be repeated\n \'abracadabra\'\n\nAccessing arguments by name:\n\n >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n \'Coordinates: 37.24N, -115.81W\'\n >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n >>> c = 3-5j\n >>> (\'The complex number {0} is formed from the real part {0.real} \'\n ... \'and the imaginary part {0.imag}.\').format(c)\n \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n >>> class Point(object):\n ... def __init__(self, x, y):\n ... self.x, self.y = x, y\n ... def __str__(self):\n ... return \'Point({self.x}, {self.y})\'.format(self=self)\n ...\n >>> str(Point(4, 2))\n \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n >>> coord = (3, 5)\n >>> \'X: {0[0]}; Y: {0[1]}\'.format(coord)\n \'X: 3; Y: 5\'\n\nReplacing ``%s`` and ``%r``:\n\n >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n >>> \'{:<30}\'.format(\'left aligned\')\n \'left aligned \'\n >>> \'{:>30}\'.format(\'right aligned\')\n \' right aligned\'\n >>> \'{:^30}\'.format(\'centered\')\n \' centered \'\n >>> \'{:*^30}\'.format(\'centered\') # use \'*\' as a fill char\n \'***********centered***********\'\n\nReplacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:\n\n >>> \'{:+f}; {:+f}\'.format(3.14, -3.14) # show it always\n \'+3.140000; -3.140000\'\n >>> \'{: f}; {: f}\'.format(3.14, -3.14) # show a space for positive numbers\n \' 3.140000; -3.140000\'\n >>> \'{:-f}; {:-f}\'.format(3.14, -3.14) # show only the minus -- same as \'{:f}; {:f}\'\n \'3.140000; -3.140000\'\n\nReplacing ``%x`` and ``%o`` and converting the value to different\nbases:\n\n >>> # format also supports binary numbers\n >>> "int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}".format(42)\n \'int: 42; hex: 2a; oct: 52; bin: 101010\'\n >>> # with 0x, 0o, or 0b as prefix:\n >>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)\n \'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n >>> \'{:,}\'.format(1234567890)\n \'1,234,567,890\'\n\nExpressing a percentage:\n\n >>> points = 19.5\n >>> total = 22\n >>> \'Correct answers: {:.2%}\'.format(points/total)\n \'Correct answers: 88.64%\'\n\nUsing type-specific formatting:\n\n >>> import datetime\n >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n ... \'{0:{fill}{align}16}\'.format(text, fill=align, align=align)\n ...\n \'left<<<<<<<<<<<<\'\n \'^^^^^center^^^^^\'\n \'>>>>>>>>>>>right\'\n >>>\n >>> octets = [192, 168, 0, 1]\n >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n \'C0A80001\'\n >>> int(_, 16)\n 3232235521\n >>>\n >>> width = 5\n >>> for num in range(5,12):\n ... for base in \'dXob\':\n ... print \'{0:{width}{base}}\'.format(num, base=base, width=width),\n ... print\n ...\n 5 5 5 101\n 6 6 6 110\n 7 7 7 111\n 8 8 10 1000\n 9 9 11 1001\n 10 A 12 1010\n 11 B 13 1011\n',
- 'function': '\nFunction definitions\n********************\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n decorated ::= decorators (classdef | funcdef)\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [argument_list [","]] ")"] NEWLINE\n funcdef ::= "def" funcname "(" [parameter_list] ")" ":" suite\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" identifier [, "**" identifier]\n | "**" identifier\n | defparameter [","] )\n defparameter ::= parameter ["=" expression]\n sublist ::= parameter ("," parameter)* [","]\n parameter ::= identifier | "(" sublist ")"\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code:\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to:\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more top-level parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters must also have a default value --- this is a syntactic\nrestriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that the same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n',
- 'global': '\nThe ``global`` statement\n************************\n\n global_stmt ::= "global" identifier ("," identifier)*\n\nThe ``global`` statement is a declaration which holds for the entire\ncurrent code block. It means that the listed identifiers are to be\ninterpreted as globals. It would be impossible to assign to a global\nvariable without ``global``, although free variables may refer to\nglobals without being declared global.\n\nNames listed in a ``global`` statement must not be used in the same\ncode block textually preceding that ``global`` statement.\n\nNames listed in a ``global`` statement must not be defined as formal\nparameters or in a ``for`` loop control target, ``class`` definition,\nfunction definition, or ``import`` statement.\n\n**CPython implementation detail:** The current implementation does not\nenforce the latter two restrictions, but programs should not abuse\nthis freedom, as future implementations may enforce them or silently\nchange the meaning of the program.\n\n**Programmer\'s note:** the ``global`` is a directive to the parser.\nIt applies only to code parsed at the same time as the ``global``\nstatement. In particular, a ``global`` statement contained in an\n``exec`` statement does not affect the code block *containing* the\n``exec`` statement, and code contained in an ``exec`` statement is\nunaffected by ``global`` statements in the code containing the\n``exec`` statement. The same applies to the ``eval()``,\n``execfile()`` and ``compile()`` functions.\n',
- 'id-classes': '\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``__builtin__`` module.\n When not in interactive mode, ``_`` has no special meaning and is\n not defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
- 'identifiers': '\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions:\n\n identifier ::= (letter|"_") (letter | digit | "_")*\n letter ::= lowercase | uppercase\n lowercase ::= "a"..."z"\n uppercase ::= "A"..."Z"\n digit ::= "0"..."9"\n\nIdentifiers are unlimited in length. Case is significant.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers. They must\nbe spelled exactly as written here:\n\n and del from not while\n as elif global or with\n assert else if pass yield\n break except import print\n class exec in raise\n continue finally is return\n def for lambda try\n\nChanged in version 2.4: ``None`` became a constant and is now\nrecognized by the compiler as a name for the built-in object ``None``.\nAlthough it is not a keyword, you cannot assign a different object to\nit.\n\nChanged in version 2.5: Using ``as`` and ``with`` as identifiers\ntriggers a warning. To use them as keywords, enable the\n``with_statement`` future feature .\n\nChanged in version 2.6: ``as`` and ``with`` are full keywords.\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``__builtin__`` module.\n When not in interactive mode, ``_`` has no special meaning and is\n not defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
+ 'floating': '\nFloating point literals\n***********************\n\nFloating point literals are described by the following lexical\ndefinitions:\n\n floatnumber ::= pointfloat | exponentfloat\n pointfloat ::= [intpart] fraction | intpart "."\n exponentfloat ::= (intpart | pointfloat) exponent\n intpart ::= digit+\n fraction ::= "." digit+\n exponent ::= ("e" | "E") ["+" | "-"] digit+\n\nNote that the integer and exponent parts are always interpreted using\nradix 10. For example, ``077e010`` is legal, and denotes the same\nnumber as ``77e10``. The allowed range of floating point literals is\nimplementation-dependent. Some examples of floating point literals:\n\n 3.14 10. .001 1e100 3.14e-10 0e0\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator ``-`` and the\nliteral ``1``.\n',
+ 'for': '\nThe ``for`` statement\n*********************\n\nThe ``for`` statement is used to iterate over the elements of a\nsequence (such as a string, tuple or list) or other iterable object:\n\n for_stmt ::= "for" target_list "in" expression_list ":" suite\n ["else" ":" suite]\n\nThe expression list is evaluated once; it should yield an iterable\nobject. An iterator is created for the result of the\n``expression_list``. The suite is then executed once for each item\nprovided by the iterator, in the order of ascending indices. Each\nitem in turn is assigned to the target list using the standard rules\nfor assignments (see *Assignment statements*), and then the suite is\nexecuted. When the items are exhausted (which is immediately when the\nsequence is empty or an iterator raises a ``StopIteration``\nexception), the suite in the ``else`` clause, if present, is executed,\nand the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ncontinues with the next item, or with the ``else`` clause if there was\nno next item.\n\nThe suite may assign to the variable(s) in the target list; this does\nnot affect the next item assigned to it.\n\nNames in the target list are not deleted when the loop is finished,\nbut if the sequence is empty, it will not have been assigned to at all\nby the loop. Hint: the built-in function ``range()`` returns an\niterator of integers suitable to emulate the effect of Pascal\'s ``for\ni := a to b do``; e.g., ``list(range(3))`` returns the list ``[0, 1,\n2]``.\n\nNote: There is a subtlety when the sequence is being modified by the loop\n (this can only occur for mutable sequences, i.e. lists). An\n internal counter is used to keep track of which item is used next,\n and this is incremented on each iteration. When this counter has\n reached the length of the sequence the loop terminates. This means\n that if the suite deletes the current (or a previous) item from the\n sequence, the next item will be skipped (since it gets the index of\n the current item which has already been treated). Likewise, if the\n suite inserts an item in the sequence before the current item, the\n current item will be treated again the next time through the loop.\n This can lead to nasty bugs that can be avoided by making a\n temporary copy using a slice of the whole sequence, e.g.,\n\n for x in a[:]:\n if x < 0: a.remove(x)\n',
+ 'formatstrings': '\nFormat String Syntax\n********************\n\nThe ``str.format()`` method and the ``Formatter`` class share the same\nsyntax for format strings (although in the case of ``Formatter``,\nsubclasses can define their own format string syntax).\n\nFormat strings contain "replacement fields" surrounded by curly braces\n``{}``. Anything that is not contained in braces is considered literal\ntext, which is copied unchanged to the output. If you need to include\na brace character in the literal text, it can be escaped by doubling:\n``{{`` and ``}}``.\n\nThe grammar for a replacement field is as follows:\n\n replacement_field ::= "{" [field_name] ["!" conversion] [":" format_spec] "}"\n field_name ::= arg_name ("." attribute_name | "[" element_index "]")*\n arg_name ::= [identifier | integer]\n attribute_name ::= identifier\n element_index ::= integer | index_string\n index_string ::= <any source character except "]"> +\n conversion ::= "r" | "s" | "a"\n format_spec ::= <described in the next section>\n\nIn less formal terms, the replacement field can start with a\n*field_name* that specifies the object whose value is to be formatted\nand inserted into the output instead of the replacement field. The\n*field_name* is optionally followed by a *conversion* field, which is\npreceded by an exclamation point ``\'!\'``, and a *format_spec*, which\nis preceded by a colon ``\':\'``. These specify a non-default format\nfor the replacement value.\n\nSee also the *Format Specification Mini-Language* section.\n\nThe *field_name* itself begins with an *arg_name* that is either a\nnumber or a keyword. If it\'s a number, it refers to a positional\nargument, and if it\'s a keyword, it refers to a named keyword\nargument. If the numerical arg_names in a format string are 0, 1, 2,\n... in sequence, they can all be omitted (not just some) and the\nnumbers 0, 1, 2, ... will be automatically inserted in that order.\nBecause *arg_name* is not quote-delimited, it is not possible to\nspecify arbitrary dictionary keys (e.g., the strings ``\'10\'`` or\n``\':-]\'``) within a format string. The *arg_name* can be followed by\nany number of index or attribute expressions. An expression of the\nform ``\'.name\'`` selects the named attribute using ``getattr()``,\nwhile an expression of the form ``\'[index]\'`` does an index lookup\nusing ``__getitem__()``.\n\nChanged in version 3.1: The positional argument specifiers can be\nomitted, so ``\'{} {}\'`` is equivalent to ``\'{0} {1}\'``.\n\nSome simple format string examples:\n\n "First, thou shalt count to {0}" # References first positional argument\n "Bring me a {}" # Implicitly references the first positional argument\n "From {} to {}" # Same as "From {0} to {1}"\n "My quest is {name}" # References keyword argument \'name\'\n "Weight in tons {0.weight}" # \'weight\' attribute of first positional arg\n "Units destroyed: {players[0]}" # First element of keyword argument \'players\'.\n\nThe *conversion* field causes a type coercion before formatting.\nNormally, the job of formatting a value is done by the\n``__format__()`` method of the value itself. However, in some cases\nit is desirable to force a type to be formatted as a string,\noverriding its own definition of formatting. By converting the value\nto a string before calling ``__format__()``, the normal formatting\nlogic is bypassed.\n\nThree conversion flags are currently supported: ``\'!s\'`` which calls\n``str()`` on the value, ``\'!r\'`` which calls ``repr()`` and ``\'!a\'``\nwhich calls ``ascii()``.\n\nSome examples:\n\n "Harold\'s a clever {0!s}" # Calls str() on the argument first\n "Bring out the holy {name!r}" # Calls repr() on the argument first\n "More {!a}" # Calls ascii() on the argument first\n\nThe *format_spec* field contains a specification of how the value\nshould be presented, including such details as field width, alignment,\npadding, decimal precision and so on. Each value type can define its\nown "formatting mini-language" or interpretation of the *format_spec*.\n\nMost built-in types support a common formatting mini-language, which\nis described in the next section.\n\nA *format_spec* field can also include nested replacement fields\nwithin it. These nested replacement fields can contain only a field\nname; conversion flags and format specifications are not allowed. The\nreplacement fields within the format_spec are substituted before the\n*format_spec* string is interpreted. This allows the formatting of a\nvalue to be dynamically specified.\n\nSee the *Format examples* section for some examples.\n\n\nFormat Specification Mini-Language\n==================================\n\n"Format specifications" are used within replacement fields contained\nwithin a format string to define how individual values are presented\n(see *Format String Syntax*). They can also be passed directly to the\nbuilt-in ``format()`` function. Each formattable type may define how\nthe format specification is to be interpreted.\n\nMost built-in types implement the following options for format\nspecifications, although some of the formatting options are only\nsupported by the numeric types.\n\nA general convention is that an empty format string (``""``) produces\nthe same result as if you had called ``str()`` on the value. A non-\nempty format string typically modifies the result.\n\nThe general form of a *standard format specifier* is:\n\n format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]\n fill ::= <a character other than \'}\'>\n align ::= "<" | ">" | "=" | "^"\n sign ::= "+" | "-" | " "\n width ::= integer\n precision ::= integer\n type ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "n" | "o" | "s" | "x" | "X" | "%"\n\nThe *fill* character can be any character other than \'{\' or \'}\'. The\npresence of a fill character is signaled by the character following\nit, which must be one of the alignment options. If the second\ncharacter of *format_spec* is not a valid alignment option, then it is\nassumed that both the fill character and the alignment option are\nabsent.\n\nThe meaning of the various alignment options is as follows:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'<\'`` | Forces the field to be left-aligned within the available |\n | | space (this is the default for most objects). |\n +-----------+------------------------------------------------------------+\n | ``\'>\'`` | Forces the field to be right-aligned within the available |\n | | space (this is the default for numbers). |\n +-----------+------------------------------------------------------------+\n | ``\'=\'`` | Forces the padding to be placed after the sign (if any) |\n | | but before the digits. This is used for printing fields |\n | | in the form \'+000000120\'. This alignment option is only |\n | | valid for numeric types. |\n +-----------+------------------------------------------------------------+\n | ``\'^\'`` | Forces the field to be centered within the available |\n | | space. |\n +-----------+------------------------------------------------------------+\n\nNote that unless a minimum field width is defined, the field width\nwill always be the same size as the data to fill it, so that the\nalignment option has no meaning in this case.\n\nThe *sign* option is only valid for number types, and can be one of\nthe following:\n\n +-----------+------------------------------------------------------------+\n | Option | Meaning |\n +===========+============================================================+\n | ``\'+\'`` | indicates that a sign should be used for both positive as |\n | | well as negative numbers. |\n +-----------+------------------------------------------------------------+\n | ``\'-\'`` | indicates that a sign should be used only for negative |\n | | numbers (this is the default behavior). |\n +-----------+------------------------------------------------------------+\n | space | indicates that a leading space should be used on positive |\n | | numbers, and a minus sign on negative numbers. |\n +-----------+------------------------------------------------------------+\n\nThe ``\'#\'`` option causes the "alternate form" to be used for the\nconversion. The alternate form is defined differently for different\ntypes. This option is only valid for integer, float, complex and\nDecimal types. For integers, when binary, octal, or hexadecimal output\nis used, this option adds the prefix respective ``\'0b\'``, ``\'0o\'``, or\n``\'0x\'`` to the output value. For floats, complex and Decimal the\nalternate form causes the result of the conversion to always contain a\ndecimal-point character, even if no digits follow it. Normally, a\ndecimal-point character appears in the result of these conversions\nonly if a digit follows it. In addition, for ``\'g\'`` and ``\'G\'``\nconversions, trailing zeros are not removed from the result.\n\nThe ``\',\'`` option signals the use of a comma for a thousands\nseparator. For a locale aware separator, use the ``\'n\'`` integer\npresentation type instead.\n\nChanged in version 3.1: Added the ``\',\'`` option (see also **PEP\n378**).\n\n*width* is a decimal integer defining the minimum field width. If not\nspecified, then the field width will be determined by the content.\n\nIf the *width* field is preceded by a zero (``\'0\'``) character, this\nenables zero-padding. This is equivalent to an *alignment* type of\n``\'=\'`` and a *fill* character of ``\'0\'``.\n\nThe *precision* is a decimal number indicating how many digits should\nbe displayed after the decimal point for a floating point value\nformatted with ``\'f\'`` and ``\'F\'``, or before and after the decimal\npoint for a floating point value formatted with ``\'g\'`` or ``\'G\'``.\nFor non-number types the field indicates the maximum field size - in\nother words, how many characters will be used from the field content.\nThe *precision* is not allowed for integer values.\n\nFinally, the *type* determines how the data should be presented.\n\nThe available string presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'s\'`` | String format. This is the default type for strings and |\n | | may be omitted. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'s\'``. |\n +-----------+------------------------------------------------------------+\n\nThe available integer presentation types are:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'b\'`` | Binary format. Outputs the number in base 2. |\n +-----------+------------------------------------------------------------+\n | ``\'c\'`` | Character. Converts the integer to the corresponding |\n | | unicode character before printing. |\n +-----------+------------------------------------------------------------+\n | ``\'d\'`` | Decimal Integer. Outputs the number in base 10. |\n +-----------+------------------------------------------------------------+\n | ``\'o\'`` | Octal format. Outputs the number in base 8. |\n +-----------+------------------------------------------------------------+\n | ``\'x\'`` | Hex format. Outputs the number in base 16, using lower- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'X\'`` | Hex format. Outputs the number in base 16, using upper- |\n | | case letters for the digits above 9. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'d\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | None | The same as ``\'d\'``. |\n +-----------+------------------------------------------------------------+\n\nIn addition to the above presentation types, integers can be formatted\nwith the floating point presentation types listed below (except\n``\'n\'`` and None). When doing so, ``float()`` is used to convert the\ninteger to a floating point number before formatting.\n\nThe available presentation types for floating point and decimal values\nare:\n\n +-----------+------------------------------------------------------------+\n | Type | Meaning |\n +===========+============================================================+\n | ``\'e\'`` | Exponent notation. Prints the number in scientific |\n | | notation using the letter \'e\' to indicate the exponent. |\n +-----------+------------------------------------------------------------+\n | ``\'E\'`` | Exponent notation. Same as ``\'e\'`` except it uses an upper |\n | | case \'E\' as the separator character. |\n +-----------+------------------------------------------------------------+\n | ``\'f\'`` | Fixed point. Displays the number as a fixed-point number. |\n +-----------+------------------------------------------------------------+\n | ``\'F\'`` | Fixed point. Same as ``\'f\'``, but converts ``nan`` to |\n | | ``NAN`` and ``inf`` to ``INF``. |\n +-----------+------------------------------------------------------------+\n | ``\'g\'`` | General format. For a given precision ``p >= 1``, this |\n | | rounds the number to ``p`` significant digits and then |\n | | formats the result in either fixed-point format or in |\n | | scientific notation, depending on its magnitude. The |\n | | precise rules are as follows: suppose that the result |\n | | formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1`` would have exponent ``exp``. Then if ``-4 <= exp |\n | | < p``, the number is formatted with presentation type |\n | | ``\'f\'`` and precision ``p-1-exp``. Otherwise, the number |\n | | is formatted with presentation type ``\'e\'`` and precision |\n | | ``p-1``. In both cases insignificant trailing zeros are |\n | | removed from the significand, and the decimal point is |\n | | also removed if there are no remaining digits following |\n | | it. Positive and negative infinity, positive and negative |\n | | zero, and nans, are formatted as ``inf``, ``-inf``, ``0``, |\n | | ``-0`` and ``nan`` respectively, regardless of the |\n | | precision. A precision of ``0`` is treated as equivalent |\n | | to a precision of ``1``. |\n +-----------+------------------------------------------------------------+\n | ``\'G\'`` | General format. Same as ``\'g\'`` except switches to ``\'E\'`` |\n | | if the number gets too large. The representations of |\n | | infinity and NaN are uppercased, too. |\n +-----------+------------------------------------------------------------+\n | ``\'n\'`` | Number. This is the same as ``\'g\'``, except that it uses |\n | | the current locale setting to insert the appropriate |\n | | number separator characters. |\n +-----------+------------------------------------------------------------+\n | ``\'%\'`` | Percentage. Multiplies the number by 100 and displays in |\n | | fixed (``\'f\'``) format, followed by a percent sign. |\n +-----------+------------------------------------------------------------+\n | None | Similar to ``\'g\'``, except with at least one digit past |\n | | the decimal point and a default precision of 12. This is |\n | | intended to match ``str()``, except you can add the other |\n | | format modifiers. |\n +-----------+------------------------------------------------------------+\n\n\nFormat examples\n===============\n\nThis section contains examples of the new format syntax and comparison\nwith the old ``%``-formatting.\n\nIn most of the cases the syntax is similar to the old\n``%``-formatting, with the addition of the ``{}`` and with ``:`` used\ninstead of ``%``. For example, ``\'%03.2f\'`` can be translated to\n``\'{:03.2f}\'``.\n\nThe new format syntax also supports new and different options, shown\nin the follow examples.\n\nAccessing arguments by position:\n\n >>> \'{0}, {1}, {2}\'.format(\'a\', \'b\', \'c\')\n \'a, b, c\'\n >>> \'{}, {}, {}\'.format(\'a\', \'b\', \'c\') # 3.1+ only\n \'a, b, c\'\n >>> \'{2}, {1}, {0}\'.format(\'a\', \'b\', \'c\')\n \'c, b, a\'\n >>> \'{2}, {1}, {0}\'.format(*\'abc\') # unpacking argument sequence\n \'c, b, a\'\n >>> \'{0}{1}{0}\'.format(\'abra\', \'cad\') # arguments\' indices can be repeated\n \'abracadabra\'\n\nAccessing arguments by name:\n\n >>> \'Coordinates: {latitude}, {longitude}\'.format(latitude=\'37.24N\', longitude=\'-115.81W\')\n \'Coordinates: 37.24N, -115.81W\'\n >>> coord = {\'latitude\': \'37.24N\', \'longitude\': \'-115.81W\'}\n >>> \'Coordinates: {latitude}, {longitude}\'.format(**coord)\n \'Coordinates: 37.24N, -115.81W\'\n\nAccessing arguments\' attributes:\n\n >>> c = 3-5j\n >>> (\'The complex number {0} is formed from the real part {0.real} \'\n ... \'and the imaginary part {0.imag}.\').format(c)\n \'The complex number (3-5j) is formed from the real part 3.0 and the imaginary part -5.0.\'\n >>> class Point:\n ... def __init__(self, x, y):\n ... self.x, self.y = x, y\n ... def __str__(self):\n ... return \'Point({self.x}, {self.y})\'.format(self=self)\n ...\n >>> str(Point(4, 2))\n \'Point(4, 2)\'\n\nAccessing arguments\' items:\n\n >>> coord = (3, 5)\n >>> \'X: {0[0]}; Y: {0[1]}\'.format(coord)\n \'X: 3; Y: 5\'\n\nReplacing ``%s`` and ``%r``:\n\n >>> "repr() shows quotes: {!r}; str() doesn\'t: {!s}".format(\'test1\', \'test2\')\n "repr() shows quotes: \'test1\'; str() doesn\'t: test2"\n\nAligning the text and specifying a width:\n\n >>> \'{:<30}\'.format(\'left aligned\')\n \'left aligned \'\n >>> \'{:>30}\'.format(\'right aligned\')\n \' right aligned\'\n >>> \'{:^30}\'.format(\'centered\')\n \' centered \'\n >>> \'{:*^30}\'.format(\'centered\') # use \'*\' as a fill char\n \'***********centered***********\'\n\nReplacing ``%+f``, ``%-f``, and ``% f`` and specifying a sign:\n\n >>> \'{:+f}; {:+f}\'.format(3.14, -3.14) # show it always\n \'+3.140000; -3.140000\'\n >>> \'{: f}; {: f}\'.format(3.14, -3.14) # show a space for positive numbers\n \' 3.140000; -3.140000\'\n >>> \'{:-f}; {:-f}\'.format(3.14, -3.14) # show only the minus -- same as \'{:f}; {:f}\'\n \'3.140000; -3.140000\'\n\nReplacing ``%x`` and ``%o`` and converting the value to different\nbases:\n\n >>> # format also supports binary numbers\n >>> "int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}".format(42)\n \'int: 42; hex: 2a; oct: 52; bin: 101010\'\n >>> # with 0x, 0o, or 0b as prefix:\n >>> "int: {0:d}; hex: {0:#x}; oct: {0:#o}; bin: {0:#b}".format(42)\n \'int: 42; hex: 0x2a; oct: 0o52; bin: 0b101010\'\n\nUsing the comma as a thousands separator:\n\n >>> \'{:,}\'.format(1234567890)\n \'1,234,567,890\'\n\nExpressing a percentage:\n\n >>> points = 19\n >>> total = 22\n >>> \'Correct answers: {:.2%}\'.format(points/total)\n \'Correct answers: 86.36%\'\n\nUsing type-specific formatting:\n\n >>> import datetime\n >>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)\n >>> \'{:%Y-%m-%d %H:%M:%S}\'.format(d)\n \'2010-07-04 12:15:58\'\n\nNesting arguments and more complex examples:\n\n >>> for align, text in zip(\'<^>\', [\'left\', \'center\', \'right\']):\n ... \'{0:{fill}{align}16}\'.format(text, fill=align, align=align)\n ...\n \'left<<<<<<<<<<<<\'\n \'^^^^^center^^^^^\'\n \'>>>>>>>>>>>right\'\n >>>\n >>> octets = [192, 168, 0, 1]\n >>> \'{:02X}{:02X}{:02X}{:02X}\'.format(*octets)\n \'C0A80001\'\n >>> int(_, 16)\n 3232235521\n >>>\n >>> width = 5\n >>> for num in range(5,12):\n ... for base in \'dXob\':\n ... print(\'{0:{width}{base}}\'.format(num, base=base, width=width), end=\' \')\n ... print()\n ...\n 5 5 5 101\n 6 6 6 110\n 7 7 7 111\n 8 8 10 1000\n 9 9 11 1001\n 10 A 12 1010\n 11 B 13 1011\n',
+ 'function': '\nFunction definitions\n********************\n\nA function definition defines a user-defined function object (see\nsection *The standard type hierarchy*):\n\n funcdef ::= [decorators] "def" funcname "(" [parameter_list] ")" ["->" expression] ":" suite\n decorators ::= decorator+\n decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE\n dotted_name ::= identifier ("." identifier)*\n parameter_list ::= (defparameter ",")*\n ( "*" [parameter] ("," defparameter)*\n [, "**" parameter]\n | "**" parameter\n | defparameter [","] )\n parameter ::= identifier [":" expression]\n defparameter ::= parameter ["=" expression]\n funcname ::= identifier\n\nA function definition is an executable statement. Its execution binds\nthe function name in the current local namespace to a function object\n(a wrapper around the executable code for the function). This\nfunction object contains a reference to the current global namespace\nas the global namespace to be used when the function is called.\n\nThe function definition does not execute the function body; this gets\nexecuted only when the function is called. [3]\n\nA function definition may be wrapped by one or more *decorator*\nexpressions. Decorator expressions are evaluated when the function is\ndefined, in the scope that contains the function definition. The\nresult must be a callable, which is invoked with the function object\nas the only argument. The returned value is bound to the function name\ninstead of the function object. Multiple decorators are applied in\nnested fashion. For example, the following code\n\n @f1(arg)\n @f2\n def func(): pass\n\nis equivalent to\n\n def func(): pass\n func = f1(arg)(f2(func))\n\nWhen one or more parameters have the form *parameter* ``=``\n*expression*, the function is said to have "default parameter values."\nFor a parameter with a default value, the corresponding argument may\nbe omitted from a call, in which case the parameter\'s default value is\nsubstituted. If a parameter has a default value, all following\nparameters up until the "``*``" must also have a default value ---\nthis is a syntactic restriction that is not expressed by the grammar.\n\n**Default parameter values are evaluated when the function definition\nis executed.** This means that the expression is evaluated once, when\nthe function is defined, and that the same "pre-computed" value is\nused for each call. This is especially important to understand when a\ndefault parameter is a mutable object, such as a list or a dictionary:\nif the function modifies the object (e.g. by appending an item to a\nlist), the default value is in effect modified. This is generally not\nwhat was intended. A way around this is to use ``None`` as the\ndefault, and explicitly test for it in the body of the function, e.g.:\n\n def whats_on_the_telly(penguin=None):\n if penguin is None:\n penguin = []\n penguin.append("property of the zoo")\n return penguin\n\nFunction call semantics are described in more detail in section\n*Calls*. A function call always assigns values to all parameters\nmentioned in the parameter list, either from position arguments, from\nkeyword arguments, or from default values. If the form\n"``*identifier``" is present, it is initialized to a tuple receiving\nany excess positional parameters, defaulting to the empty tuple. If\nthe form "``**identifier``" is present, it is initialized to a new\ndictionary receiving any excess keyword arguments, defaulting to a new\nempty dictionary. Parameters after "``*``" or "``*identifier``" are\nkeyword-only parameters and may only be passed used keyword arguments.\n\nParameters may have annotations of the form "``: expression``"\nfollowing the parameter name. Any parameter may have an annotation\neven those of the form ``*identifier`` or ``**identifier``. Functions\nmay have "return" annotation of the form "``-> expression``" after the\nparameter list. These annotations can be any valid Python expression\nand are evaluated when the function definition is executed.\nAnnotations may be evaluated in a different order than they appear in\nthe source code. The presence of annotations does not change the\nsemantics of a function. The annotation values are available as\nvalues of a dictionary keyed by the parameters\' names in the\n``__annotations__`` attribute of the function object.\n\nIt is also possible to create anonymous functions (functions not bound\nto a name), for immediate use in expressions. This uses lambda forms,\ndescribed in section *Lambdas*. Note that the lambda form is merely a\nshorthand for a simplified function definition; a function defined in\na "``def``" statement can be passed around or assigned to another name\njust like a function defined by a lambda form. The "``def``" form is\nactually more powerful since it allows the execution of multiple\nstatements and annotations.\n\n**Programmer\'s note:** Functions are first-class objects. A "``def``"\nform executed inside a function definition defines a local function\nthat can be returned or passed around. Free variables used in the\nnested function can access the local variables of the function\ncontaining the def. See section *Naming and binding* for details.\n',
+ 'global': '\nThe ``global`` statement\n************************\n\n global_stmt ::= "global" identifier ("," identifier)*\n\nThe ``global`` statement is a declaration which holds for the entire\ncurrent code block. It means that the listed identifiers are to be\ninterpreted as globals. It would be impossible to assign to a global\nvariable without ``global``, although free variables may refer to\nglobals without being declared global.\n\nNames listed in a ``global`` statement must not be used in the same\ncode block textually preceding that ``global`` statement.\n\nNames listed in a ``global`` statement must not be defined as formal\nparameters or in a ``for`` loop control target, ``class`` definition,\nfunction definition, or ``import`` statement.\n\n**CPython implementation detail:** The current implementation does not\nenforce the latter two restrictions, but programs should not abuse\nthis freedom, as future implementations may enforce them or silently\nchange the meaning of the program.\n\n**Programmer\'s note:** the ``global`` is a directive to the parser.\nIt applies only to code parsed at the same time as the ``global``\nstatement. In particular, a ``global`` statement contained in a string\nor code object supplied to the built-in ``exec()`` function does not\naffect the code block *containing* the function call, and code\ncontained in such a string is unaffected by ``global`` statements in\nthe code containing the function call. The same applies to the\n``eval()`` and ``compile()`` functions.\n',
+ 'id-classes': '\nReserved classes of identifiers\n*******************************\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
+ 'identifiers': '\nIdentifiers and keywords\n************************\n\nIdentifiers (also referred to as *names*) are described by the\nfollowing lexical definitions.\n\nThe syntax of identifiers in Python is based on the Unicode standard\nannex UAX-31, with elaboration and changes as defined below; see also\n**PEP 3131** for further details.\n\nWithin the ASCII range (U+0001..U+007F), the valid characters for\nidentifiers are the same as in Python 2.x: the uppercase and lowercase\nletters ``A`` through ``Z``, the underscore ``_`` and, except for the\nfirst character, the digits ``0`` through ``9``.\n\nPython 3.0 introduces additional characters from outside the ASCII\nrange (see **PEP 3131**). For these characters, the classification\nuses the version of the Unicode Character Database as included in the\n``unicodedata`` module.\n\nIdentifiers are unlimited in length. Case is significant.\n\n identifier ::= xid_start xid_continue*\n id_start ::= <all characters in general categories Lu, Ll, Lt, Lm, Lo, Nl, the underscore, and characters with the Other_ID_Start property>\n id_continue ::= <all characters in id_start, plus characters in the categories Mn, Mc, Nd, Pc and others with the Other_ID_Continue property>\n xid_start ::= <all characters in id_start whose NFKC normalization is in "id_start xid_continue*">\n xid_continue ::= <all characters in id_continue whose NFKC normalization is in "id_continue*">\n\nThe Unicode category codes mentioned above stand for:\n\n* *Lu* - uppercase letters\n\n* *Ll* - lowercase letters\n\n* *Lt* - titlecase letters\n\n* *Lm* - modifier letters\n\n* *Lo* - other letters\n\n* *Nl* - letter numbers\n\n* *Mn* - nonspacing marks\n\n* *Mc* - spacing combining marks\n\n* *Nd* - decimal numbers\n\n* *Pc* - connector punctuations\n\n* *Other_ID_Start* - explicit list of characters in PropList.txt to\n support backwards compatibility\n\n* *Other_ID_Continue* - likewise\n\nAll identifiers are converted into the normal form NFKC while parsing;\ncomparison of identifiers is based on NFKC.\n\nA non-normative HTML file listing all valid identifier characters for\nUnicode 4.1 can be found at http://www.dcl.hpi.uni-\npotsdam.de/home/loewis/table-3131.html.\n\n\nKeywords\n========\n\nThe following identifiers are used as reserved words, or *keywords* of\nthe language, and cannot be used as ordinary identifiers. They must\nbe spelled exactly as written here:\n\n False class finally is return\n None continue for lambda try\n True def from nonlocal while\n and del global not with\n as elif if or yield\n assert else import pass\n break except in raise\n\n\nReserved classes of identifiers\n===============================\n\nCertain classes of identifiers (besides keywords) have special\nmeanings. These classes are identified by the patterns of leading and\ntrailing underscore characters:\n\n``_*``\n Not imported by ``from module import *``. The special identifier\n ``_`` is used in the interactive interpreter to store the result of\n the last evaluation; it is stored in the ``builtins`` module. When\n not in interactive mode, ``_`` has no special meaning and is not\n defined. See section *The import statement*.\n\n Note: The name ``_`` is often used in conjunction with\n internationalization; refer to the documentation for the\n ``gettext`` module for more information on this convention.\n\n``__*__``\n System-defined names. These names are defined by the interpreter\n and its implementation (including the standard library). Current\n system names are discussed in the *Special method names* section\n and elsewhere. More will likely be defined in future versions of\n Python. *Any* use of ``__*__`` names, in any context, that does\n not follow explicitly documented use, is subject to breakage\n without warning.\n\n``__*``\n Class-private names. Names in this category, when used within the\n context of a class definition, are re-written to use a mangled form\n to help avoid name clashes between "private" attributes of base and\n derived classes. See section *Identifiers (Names)*.\n',
'if': '\nThe ``if`` statement\n********************\n\nThe ``if`` statement is used for conditional execution:\n\n if_stmt ::= "if" expression ":" suite\n ( "elif" expression ":" suite )*\n ["else" ":" suite]\n\nIt selects exactly one of the suites by evaluating the expressions one\nby one until one is found to be true (see section *Boolean operations*\nfor the definition of true and false); then that suite is executed\n(and no other part of the ``if`` statement is executed or evaluated).\nIf all expressions are false, the suite of the ``else`` clause, if\npresent, is executed.\n',
'imaginary': '\nImaginary literals\n******************\n\nImaginary literals are described by the following lexical definitions:\n\n imagnumber ::= (floatnumber | intpart) ("j" | "J")\n\nAn imaginary literal yields a complex number with a real part of 0.0.\nComplex numbers are represented as a pair of floating point numbers\nand have the same restrictions on their range. To create a complex\nnumber with a nonzero real part, add a floating point number to it,\ne.g., ``(3+4j)``. Some examples of imaginary literals:\n\n 3.14j 10.j 10j .001j 1e100j 3.14e-10j\n',
- 'import': '\nThe ``import`` statement\n************************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns *None`* is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any. If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound. As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname". If a name is not\nfound, ``ImportError`` is raised. If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement..\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module. The names given in ``__all__`` are all considered public\nand are required to exist. If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope. If the\nwild card form of import --- ``import *`` --- is used in a function\nand the function contains or is a nested block with free variables,\nthe compiler will raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimport mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python. The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language. It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 2.6 are ``unicode_literals``,\n``print_function``, ``absolute_import``, ``division``, ``generators``,\n``nested_scopes`` and ``with_statement``. ``generators``,\n``with_statement``, ``nested_scopes`` are redundant in Python version\n2.6 and above because they are always enabled.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by an ``exec`` statement or calls to the built-in\nfunctions ``compile()`` and ``execfile()`` that occur in a module\n``M`` containing a future statement will, by default, use the new\nsyntax or semantics associated with the future statement. This can,\nstarting with Python 2.2 be controlled by optional arguments to\n``compile()`` --- see the documentation of that function for details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n **PEP 236** - Back to the __future__\n The original proposal for the __future__ mechanism.\n',
- 'in': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "<>" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe forms ``<>`` and ``!=`` are equivalent; for consistency with C,\n``!=`` is preferred; where ``!=`` is mentioned below ``<>`` is also\naccepted. The ``<>`` spelling is considered obsolescent.\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nobjects of different types *always* compare unequal, and are ordered\nconsistently but arbitrarily. You can control comparison behavior of\nobjects of non-built-in types by defining a ``__cmp__`` method or rich\ncomparison methods like ``__gt__``, described in section *Special\nmethod names*.\n\n(This unusual definition of comparison was used to simplify the\ndefinition of operations like sorting and the ``in`` and ``not in``\noperators. In the future, the comparison rules for objects of\ndifferent types are likely to change.)\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n Unicode and 8-bit strings are fully interoperable in this behavior.\n [4]\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``cmp([1,2,x], [1,2,y])`` returns\n the same as ``cmp(x,y)``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if their sorted\n (key, value) lists compare equal. [5] Outcomes other than equality\n are resolved consistently, but are not otherwise defined. [6]\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nThe operators ``in`` and ``not in`` test for collection membership.\n``x in s`` evaluates to true if *x* is a member of the collection *s*,\nand false otherwise. ``x not in s`` returns the negation of ``x in\ns``. The collection membership test has traditionally been bound to\nsequences; an object is a member of a collection if the collection is\na sequence and contains an element equal to that object. However, it\nmake sense for many other object types to support membership tests\nwithout being a sequence. In particular, dictionaries (for keys) and\nsets support membership testing.\n\nFor the list and tuple types, ``x in y`` is true if and only if there\nexists an index *i* such that ``x == y[i]`` is true.\n\nFor the Unicode and string types, ``x in y`` is true if and only if\n*x* is a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nNote, *x* and *y* need not be the same type; consequently, ``u\'ab\' in\n\'abc\'`` will return ``True``. Empty strings are always considered to\nbe a substring of any other string, so ``"" in "abc"`` will return\n``True``.\n\nChanged in version 2.3: Previously, *x* was required to be a string of\nlength ``1``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [7]\n',
- 'integers': '\nInteger and long integer literals\n*********************************\n\nInteger and long integer literals are described by the following\nlexical definitions:\n\n longinteger ::= integer ("l" | "L")\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"\n octinteger ::= "0" ("o" | "O") octdigit+ | "0" octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n nonzerodigit ::= "1"..."9"\n octdigit ::= "0"..."7"\n bindigit ::= "0" | "1"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n\nAlthough both lower case ``\'l\'`` and upper case ``\'L\'`` are allowed as\nsuffix for long integers, it is strongly recommended to always use\n``\'L\'``, since the letter ``\'l\'`` looks too much like the digit\n``\'1\'``.\n\nPlain integer literals that are above the largest representable plain\ninteger (e.g., 2147483647 when using 32-bit arithmetic) are accepted\nas if they were long integers instead. [1] There is no limit for long\ninteger literals apart from what can be stored in available memory.\n\nSome examples of plain integer literals (first row) and long integer\nliterals (second and third rows):\n\n 7 2147483647 0177\n 3L 79228162514264337593543950336L 0377L 0x100000000L\n 79228162514264337593543950336 0xdeadbeef\n',
- 'lambda': '\nLambdas\n*******\n\n lambda_form ::= "lambda" [parameter_list]: expression\n old_lambda_form ::= "lambda" [parameter_list]: old_expression\n\nLambda forms (lambda expressions) have the same syntactic position as\nexpressions. They are a shorthand to create anonymous functions; the\nexpression ``lambda arguments: expression`` yields a function object.\nThe unnamed object behaves like a function object defined with\n\n def name(arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda forms cannot contain\nstatements.\n',
- 'lists': '\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [expression_list | list_comprehension] "]"\n list_comprehension ::= expression list_for\n list_for ::= "for" target_list "in" old_expression_list [list_iter]\n old_expression_list ::= old_expression [("," old_expression)+ [","]]\n old_expression ::= or_test | old_lambda_form\n list_iter ::= list_for | list_if\n list_if ::= "if" old_expression [list_iter]\n\nA list display yields a new list object. Its contents are specified\nby providing either a list of expressions or a list comprehension.\nWhen a comma-separated list of expressions is supplied, its elements\nare evaluated from left to right and placed into the list object in\nthat order. When a list comprehension is supplied, it consists of a\nsingle expression followed by at least one ``for`` clause and zero or\nmore ``for`` or ``if`` clauses. In this case, the elements of the new\nlist are those that would be produced by considering each of the\n``for`` or ``if`` clauses a block, nesting from left to right, and\nevaluating the expression to produce a list element each time the\ninnermost block is reached [1].\n',
- 'naming': "\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the '**-c**' option) is a code block. The file read by the\nbuilt-in function ``execfile()`` is a code block. The string argument\npassed to the built-in function ``eval()`` and to the ``exec``\nstatement is a code block. The expression read and evaluated by the\nbuilt-in function ``input()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block's execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes generator expressions since\nthey are implemented using a function scope. This means that the\nfollowing will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block's *environment*.\n\nIf a name is bound in a block, it is a local variable of that block.\nIf a name is bound at the module level, it is a global variable. (The\nvariables of the module code block are local and global.) If a\nvariable is used in a code block but not defined there, it is a *free\nvariable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, in the\nsecond position of an ``except`` clause header or after ``as`` in a\n``with`` statement. The ``import`` statement of the form ``from ...\nimport *`` binds all names defined in the imported module, except\nthose beginning with an underscore. This form may only be used at the\nmodule level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name). It\nis illegal to unbind a name that is referenced by an enclosing scope;\nthe compiler will report a ``SyntaxError``.\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the global statement occurs within a block, all uses of the name\nspecified in the statement refer to the binding of that name in the\ntop-level namespace. Names are resolved in the top-level namespace by\nsearching the global namespace, i.e. the namespace of the module\ncontaining the code block, and the builtins namespace, the namespace\nof the module ``__builtin__``. The global namespace is searched\nfirst. If the name is not found there, the builtins namespace is\nsearched. The global statement must precede all uses of the name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module's dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``__builtin__`` (note: no 's'); when in any other module,\n``__builtins__`` is an alias for the dictionary of the ``__builtin__``\nmodule itself. ``__builtins__`` can be set to a user-created\ndictionary to create a weak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``__builtin__`` (no 's') module and modify its attributes\nappropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nIf ``exec`` is used in a function and the function contains or is a\nnested block with free variables, the compiler will raise a\n``SyntaxError`` unless the exec explicitly specifies the local\nnamespace for the ``exec``. (In other words, ``exec obj`` would be\nillegal, but ``exec obj in ns`` would be legal.)\n\nThe ``eval()``, ``execfile()``, and ``input()`` functions and the\n``exec`` statement do not have access to the full environment for\nresolving names. Names may be resolved in the local and global\nnamespaces of the caller. Free variables are not resolved in the\nnearest enclosing namespace, but in the global namespace. [1] The\n``exec`` statement and the ``eval()`` and ``execfile()`` functions\nhave optional arguments to override the global and local namespace.\nIf only one namespace is specified, it is used for both.\n",
- 'numbers': "\nNumeric literals\n****************\n\nThere are four types of numeric literals: plain integers, long\nintegers, floating point numbers, and imaginary numbers. There are no\ncomplex literals (complex numbers can be formed by adding a real\nnumber and an imaginary number).\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator '``-``' and\nthe literal ``1``.\n",
- 'numeric-types': '\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``//``, ``%``, ``divmod()``,\n ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For\n instance, to evaluate the expression ``x + y``, where *x* is an\n instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()`` (described below). Note\n that ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__div__(self, other)\nobject.__truediv__(self, other)\n\n The division operator (``/``) is implemented by these methods. The\n ``__truediv__()`` method is used when ``__future__.division`` is in\n effect, otherwise ``__div__()`` is used. If only one of these two\n methods is defined, the object will not support division in the\n alternate context; ``TypeError`` will be raised instead.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rdiv__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``%``, ``divmod()``,\n ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``) with\n reflected (swapped) operands. These functions are only called if\n the left operand does not support the corresponding operation and\n the operands are of different types. [2] For instance, to evaluate\n the expression ``x - y``, where *y* is an instance of a class that\n has an ``__rsub__()`` method, ``y.__rsub__(x)`` is called if\n ``x.__sub__(y)`` returns *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left operand\'s\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand\'s\n non-reflected method. This behavior allows subclasses to\n override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__idiv__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__long__(self)\nobject.__float__(self)\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``long()``, and ``float()``. Should return a value of\n the appropriate type.\n\nobject.__oct__(self)\nobject.__hex__(self)\n\n Called to implement the built-in functions ``oct()`` and ``hex()``.\n Should return a string value.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing). Must return\n an integer (int or long).\n\n New in version 2.5.\n\nobject.__coerce__(self, other)\n\n Called to implement "mixed-mode" numeric arithmetic. Should either\n return a 2-tuple containing *self* and *other* converted to a\n common numeric type, or ``None`` if conversion is impossible. When\n the common type would be the type of ``other``, it is sufficient to\n return ``None``, since the interpreter will also ask the other\n object to attempt a coercion (but sometimes, if the implementation\n of the other type cannot be changed, it is useful to do the\n conversion to the other type here). A return value of\n ``NotImplemented`` is equivalent to returning ``None``.\n',
- 'objects': '\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'``is``\' operator compares the\nidentity of two objects; the ``id()`` function returns an integer\nrepresenting its identity (currently implemented as its address). An\nobject\'s *type* is also unchangeable. [1] An object\'s type determines\nthe operations that the object supports (e.g., "does it have a\nlength?") and also defines the possible values for objects of that\ntype. The ``type()`` function returns an object\'s type (which is an\nobject itself). The *value* of some objects can change. Objects\nwhose value can change are said to be *mutable*; objects whose value\nis unchangeable once they are created are called *immutable*. (The\nvalue of an immutable container object that contains a reference to a\nmutable object can change when the latter\'s value is changed; however\nthe container is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the ``gc`` module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change. Do not depend\non immediate finalization of objects when they become unreachable (ex:\nalways close files).\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'``try``...``except``\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a ``close()`` method. Programs\nare strongly recommended to explicitly close such objects. The\n\'``try``...``finally``\' statement provides a convenient way to do\nthis.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after ``a = 1; b =\n1``, ``a`` and ``b`` may or may not refer to the same object with the\nvalue one, depending on the implementation, but after ``c = []; d =\n[]``, ``c`` and ``d`` are guaranteed to refer to two different,\nunique, newly created empty lists. (Note that ``c = d = []`` assigns\nthe same object to both ``c`` and ``d``.)\n',
- 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| ``lambda`` | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| ``if`` -- ``else`` | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| ``or`` | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| ``and`` | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x* | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``, | Comparisons, including membership |\n| ``<``, ``<=``, ``>``, ``>=``, ``<>``, ``!=``, | tests and identity tests, |\n| ``==`` | |\n+-------------------------------------------------+---------------------------------------+\n| ``|`` | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| ``^`` | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| ``&`` | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>`` | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-`` | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |\n| | [8] |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``**`` | Exponentiation [9] |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``, | Subscription, slicing, call, |\n| ``x(arguments...)``, ``x.attribute`` | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``, | Binding or tuple display, list |\n| ``{key:datum...}``, ```expressions...``` | display, dictionary display, string |\n| | conversion |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] In Python 2.3 and later releases, a list comprehension "leaks" the\n control variables of each ``for`` it contains into the containing\n scope. However, this behavior is deprecated, and relying on it\n will not work in Python 3.0\n\n[2] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that ``-1e-100 % 1e100`` have the same\n sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n which is numerically exactly equal to ``1e100``. The function\n ``math.fmod()`` returns a result whose sign matches the sign of\n the first argument instead, and so returns ``-1e-100`` in this\n case. Which approach is more appropriate depends on the\n application.\n\n[3] If x is very close to an exact integer multiple of y, it\'s\n possible for ``floor(x/y)`` to be one larger than ``(x-x%y)/y``\n due to rounding. In such cases, Python returns the latter result,\n in order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n close to ``x``.\n\n[4] While comparisons between unicode strings make sense at the byte\n level, they may be counter-intuitive to users. For example, the\n strings ``u"\\u00C7"`` and ``u"\\u0043\\u0327"`` compare differently,\n even though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using ``unicodedata.normalize()``.\n\n[5] The implementation computes this efficiently, without constructing\n lists or sorting.\n\n[6] Earlier versions of Python used lexicographic comparison of the\n sorted (key, value) lists, but this was very expensive for the\n common case of comparing for equality. An even earlier version of\n Python compared dictionaries by identity only, but this caused\n surprises because people expected to be able to test a dictionary\n for emptiness by comparing it to ``{}``.\n\n[7] Due to automatic garbage-collection, free lists, and the dynamic\n nature of descriptors, you may notice seemingly unusual behaviour\n in certain uses of the ``is`` operator, like those involving\n comparisons between instance methods, or constants. Check their\n documentation for more info.\n\n[8] The ``%`` operator is also used for string formatting; the same\n precedence applies.\n\n[9] The power operator ``**`` binds less tightly than an arithmetic or\n bitwise unary operator on its right, that is, ``2**-1`` is\n ``0.5``.\n',
+ 'import': '\nThe ``import`` statement\n************************\n\n import_stmt ::= "import" module ["as" name] ( "," module ["as" name] )*\n | "from" relative_module "import" identifier ["as" name]\n ( "," identifier ["as" name] )*\n | "from" relative_module "import" "(" identifier ["as" name]\n ( "," identifier ["as" name] )* [","] ")"\n | "from" module "import" "*"\n module ::= (identifier ".")* identifier\n relative_module ::= "."* module | "."+\n name ::= identifier\n\nImport statements are executed in two steps: (1) find a module, and\ninitialize it if necessary; (2) define a name or names in the local\nnamespace (of the scope where the ``import`` statement occurs). The\nstatement comes in two forms differing on whether it uses the ``from``\nkeyword. The first form (without ``from``) repeats these steps for\neach identifier in the list. The form with ``from`` performs step (1)\nonce, and then performs step (2) repeatedly. For a reference\nimplementation of step (1), see the ``importlib`` module.\n\nTo understand how step (1) occurs, one must first understand how\nPython handles hierarchical naming of modules. To help organize\nmodules and provide a hierarchy in naming, Python has a concept of\npackages. A package can contain other packages and modules while\nmodules cannot contain other modules or packages. From a file system\nperspective, packages are directories and modules are files. The\noriginal specification for packages is still available to read,\nalthough minor details have changed since the writing of that\ndocument.\n\nOnce the name of the module is known (unless otherwise specified, the\nterm "module" will refer to both packages and modules), searching for\nthe module or package can begin. The first place checked is\n``sys.modules``, the cache of all modules that have been imported\npreviously. If the module is found there then it is used in step (2)\nof import unless ``None`` is found in ``sys.modules``, in which case\n``ImportError`` is raised.\n\nIf the module is not found in the cache, then ``sys.meta_path`` is\nsearched (the specification for ``sys.meta_path`` can be found in\n**PEP 302**). The object is a list of *finder* objects which are\nqueried in order as to whether they know how to load the module by\ncalling their ``find_module()`` method with the name of the module. If\nthe module happens to be contained within a package (as denoted by the\nexistence of a dot in the name), then a second argument to\n``find_module()`` is given as the value of the ``__path__`` attribute\nfrom the parent package (everything up to the last dot in the name of\nthe module being imported). If a finder can find the module it returns\na *loader* (discussed later) or returns ``None``.\n\nIf none of the finders on ``sys.meta_path`` are able to find the\nmodule then some implicitly defined finders are queried.\nImplementations of Python vary in what implicit meta path finders are\ndefined. The one they all do define, though, is one that handles\n``sys.path_hooks``, ``sys.path_importer_cache``, and ``sys.path``.\n\nThe implicit finder searches for the requested module in the "paths"\nspecified in one of two places ("paths" do not have to be file system\npaths). If the module being imported is supposed to be contained\nwithin a package then the second argument passed to ``find_module()``,\n``__path__`` on the parent package, is used as the source of paths. If\nthe module is not contained in a package then ``sys.path`` is used as\nthe source of paths.\n\nOnce the source of paths is chosen it is iterated over to find a\nfinder that can handle that path. The dict at\n``sys.path_importer_cache`` caches finders for paths and is checked\nfor a finder. If the path does not have a finder cached then\n``sys.path_hooks`` is searched by calling each object in the list with\na single argument of the path, returning a finder or raises\n``ImportError``. If a finder is returned then it is cached in\n``sys.path_importer_cache`` and then used for that path entry. If no\nfinder can be found but the path exists then a value of ``None`` is\nstored in ``sys.path_importer_cache`` to signify that an implicit,\nfile-based finder that handles modules stored as individual files\nshould be used for that path. If the path does not exist then a finder\nwhich always returns ``None`` is placed in the cache for the path.\n\nIf no finder can find the module then ``ImportError`` is raised.\nOtherwise some finder returned a loader whose ``load_module()`` method\nis called with the name of the module to load (see **PEP 302** for the\noriginal definition of loaders). A loader has several responsibilities\nto perform on a module it loads. First, if the module already exists\nin ``sys.modules`` (a possibility if the loader is called outside of\nthe import machinery) then it is to use that module for initialization\nand not a new module. But if the module does not exist in\n``sys.modules`` then it is to be added to that dict before\ninitialization begins. If an error occurs during loading of the module\nand it was added to ``sys.modules`` it is to be removed from the dict.\nIf an error occurs but the module was already in ``sys.modules`` it is\nleft in the dict.\n\nThe loader must set several attributes on the module. ``__name__`` is\nto be set to the name of the module. ``__file__`` is to be the "path"\nto the file unless the module is built-in (and thus listed in\n``sys.builtin_module_names``) in which case the attribute is not set.\nIf what is being imported is a package then ``__path__`` is to be set\nto a list of paths to be searched when looking for modules and\npackages contained within the package being imported. ``__package__``\nis optional but should be set to the name of package that contains the\nmodule or package (the empty string is used for module not contained\nin a package). ``__loader__`` is also optional but should be set to\nthe loader object that is loading the module.\n\nIf an error occurs during loading then the loader raises\n``ImportError`` if some other exception is not already being\npropagated. Otherwise the loader returns the module that was loaded\nand initialized.\n\nWhen step (1) finishes without raising an exception, step (2) can\nbegin.\n\nThe first form of ``import`` statement binds the module name in the\nlocal namespace to the module object, and then goes on to import the\nnext identifier, if any. If the module name is followed by ``as``,\nthe name following ``as`` is used as the local name for the module.\n\nThe ``from`` form does not bind the module name: it goes through the\nlist of identifiers, looks each one of them up in the module found in\nstep (1), and binds the name in the local namespace to the object thus\nfound. As with the first form of ``import``, an alternate local name\ncan be supplied by specifying "``as`` localname". If a name is not\nfound, ``ImportError`` is raised. If the list of identifiers is\nreplaced by a star (``\'*\'``), all public names defined in the module\nare bound in the local namespace of the ``import`` statement.\n\nThe *public names* defined by a module are determined by checking the\nmodule\'s namespace for a variable named ``__all__``; if defined, it\nmust be a sequence of strings which are names defined or imported by\nthat module. The names given in ``__all__`` are all considered public\nand are required to exist. If ``__all__`` is not defined, the set of\npublic names includes all names found in the module\'s namespace which\ndo not begin with an underscore character (``\'_\'``). ``__all__``\nshould contain the entire public API. It is intended to avoid\naccidentally exporting items that are not part of the API (such as\nlibrary modules which were imported and used within the module).\n\nThe ``from`` form with ``*`` may only occur in a module scope. The\nwild card form of import --- ``import *`` --- is only allowed at the\nmodule level. Attempting to use it in class or function definitions\nwill raise a ``SyntaxError``.\n\nWhen specifying what module to import you do not have to specify the\nabsolute name of the module. When a module or package is contained\nwithin another package it is possible to make a relative import within\nthe same top package without having to mention the package name. By\nusing leading dots in the specified module or package after ``from``\nyou can specify how high to traverse up the current package hierarchy\nwithout specifying exact names. One leading dot means the current\npackage where the module making the import exists. Two dots means up\none package level. Three dots is up two levels, etc. So if you execute\n``from . import mod`` from a module in the ``pkg`` package then you\nwill end up importing ``pkg.mod``. If you execute ``from ..subpkg2\nimport mod`` from within ``pkg.subpkg1`` you will import\n``pkg.subpkg2.mod``. The specification for relative imports is\ncontained within **PEP 328**.\n\n``importlib.import_module()`` is provided to support applications that\ndetermine which modules need to be loaded dynamically.\n\n\nFuture statements\n=================\n\nA *future statement* is a directive to the compiler that a particular\nmodule should be compiled using syntax or semantics that will be\navailable in a specified future release of Python. The future\nstatement is intended to ease migration to future versions of Python\nthat introduce incompatible changes to the language. It allows use of\nthe new features on a per-module basis before the release in which the\nfeature becomes standard.\n\n future_statement ::= "from" "__future__" "import" feature ["as" name]\n ("," feature ["as" name])*\n | "from" "__future__" "import" "(" feature ["as" name]\n ("," feature ["as" name])* [","] ")"\n feature ::= identifier\n name ::= identifier\n\nA future statement must appear near the top of the module. The only\nlines that can appear before a future statement are:\n\n* the module docstring (if any),\n\n* comments,\n\n* blank lines, and\n\n* other future statements.\n\nThe features recognized by Python 3.0 are ``absolute_import``,\n``division``, ``generators``, ``unicode_literals``,\n``print_function``, ``nested_scopes`` and ``with_statement``. They\nare all redundant because they are always enabled, and only kept for\nbackwards compatibility.\n\nA future statement is recognized and treated specially at compile\ntime: Changes to the semantics of core constructs are often\nimplemented by generating different code. It may even be the case\nthat a new feature introduces new incompatible syntax (such as a new\nreserved word), in which case the compiler may need to parse the\nmodule differently. Such decisions cannot be pushed off until\nruntime.\n\nFor any given release, the compiler knows which feature names have\nbeen defined, and raises a compile-time error if a future statement\ncontains a feature not known to it.\n\nThe direct runtime semantics are the same as for any import statement:\nthere is a standard module ``__future__``, described later, and it\nwill be imported in the usual way at the time the future statement is\nexecuted.\n\nThe interesting runtime semantics depend on the specific feature\nenabled by the future statement.\n\nNote that there is nothing special about the statement:\n\n import __future__ [as name]\n\nThat is not a future statement; it\'s an ordinary import statement with\nno special semantics or syntax restrictions.\n\nCode compiled by calls to the built-in functions ``exec()`` and\n``compile()`` that occur in a module ``M`` containing a future\nstatement will, by default, use the new syntax or semantics associated\nwith the future statement. This can be controlled by optional\narguments to ``compile()`` --- see the documentation of that function\nfor details.\n\nA future statement typed at an interactive interpreter prompt will\ntake effect for the rest of the interpreter session. If an\ninterpreter is started with the *-i* option, is passed a script name\nto execute, and the script includes a future statement, it will be in\neffect in the interactive session started after the script is\nexecuted.\n\nSee also:\n\n **PEP 236** - Back to the __future__\n The original proposal for the __future__ mechanism.\n',
+ 'in': '\nComparisons\n***********\n\nUnlike C, all comparison operations in Python have the same priority,\nwhich is lower than that of any arithmetic, shifting or bitwise\noperation. Also unlike C, expressions like ``a < b < c`` have the\ninterpretation that is conventional in mathematics:\n\n comparison ::= or_expr ( comp_operator or_expr )*\n comp_operator ::= "<" | ">" | "==" | ">=" | "<=" | "!="\n | "is" ["not"] | ["not"] "in"\n\nComparisons yield boolean values: ``True`` or ``False``.\n\nComparisons can be chained arbitrarily, e.g., ``x < y <= z`` is\nequivalent to ``x < y and y <= z``, except that ``y`` is evaluated\nonly once (but in both cases ``z`` is not evaluated at all when ``x <\ny`` is found to be false).\n\nFormally, if *a*, *b*, *c*, ..., *y*, *z* are expressions and *op1*,\n*op2*, ..., *opN* are comparison operators, then ``a op1 b op2 c ... y\nopN z`` is equivalent to ``a op1 b and b op2 c and ... y opN z``,\nexcept that each expression is evaluated at most once.\n\nNote that ``a op1 b op2 c`` doesn\'t imply any kind of comparison\nbetween *a* and *c*, so that, e.g., ``x < y > z`` is perfectly legal\n(though perhaps not pretty).\n\nThe operators ``<``, ``>``, ``==``, ``>=``, ``<=``, and ``!=`` compare\nthe values of two objects. The objects need not have the same type.\nIf both are numbers, they are converted to a common type. Otherwise,\nthe ``==`` and ``!=`` operators *always* consider objects of different\ntypes to be unequal, while the ``<``, ``>``, ``>=`` and ``<=``\noperators raise a ``TypeError`` when comparing objects of different\ntypes that do not implement these operators for the given pair of\ntypes. You can control comparison behavior of objects of non-built-in\ntypes by defining rich comparison methods like ``__gt__()``, described\nin section *Basic customization*.\n\nComparison of objects of the same type depends on the type:\n\n* Numbers are compared arithmetically.\n\n* The values ``float(\'NaN\')`` and ``Decimal(\'NaN\')`` are special. The\n are identical to themselves, ``x is x`` but are not equal to\n themselves, ``x != x``. Additionally, comparing any value to a\n not-a-number value will return ``False``. For example, both ``3 <\n float(\'NaN\')`` and ``float(\'NaN\') < 3`` will return ``False``.\n\n* Bytes objects are compared lexicographically using the numeric\n values of their elements.\n\n* Strings are compared lexicographically using the numeric equivalents\n (the result of the built-in function ``ord()``) of their characters.\n [3] String and bytes object can\'t be compared!\n\n* Tuples and lists are compared lexicographically using comparison of\n corresponding elements. This means that to compare equal, each\n element must compare equal and the two sequences must be of the same\n type and have the same length.\n\n If not equal, the sequences are ordered the same as their first\n differing elements. For example, ``[1,2,x] <= [1,2,y]`` has the\n same value as ``x <= y``. If the corresponding element does not\n exist, the shorter sequence is ordered first (for example, ``[1,2] <\n [1,2,3]``).\n\n* Mappings (dictionaries) compare equal if and only if they have the\n same ``(key, value)`` pairs. Order comparisons ``(\'<\', \'<=\', \'>=\',\n \'>\')`` raise ``TypeError``.\n\n* Sets and frozensets define comparison operators to mean subset and\n superset tests. Those relations do not define total orderings (the\n two sets ``{1,2}`` and {2,3} are not equal, nor subsets of one\n another, nor supersets of one another). Accordingly, sets are not\n appropriate arguments for functions which depend on total ordering.\n For example, ``min()``, ``max()``, and ``sorted()`` produce\n undefined results given a list of sets as inputs.\n\n* Most other objects of built-in types compare unequal unless they are\n the same object; the choice whether one object is considered smaller\n or larger than another one is made arbitrarily but consistently\n within one execution of a program.\n\nComparison of objects of the differing types depends on whether either\nof the types provide explicit support for the comparison. Most\nnumeric types can be compared with one another, but comparisons of\n``float`` and ``Decimal`` are not supported to avoid the inevitable\nconfusion arising from representation issues such as ``float(\'1.1\')``\nbeing inexactly represented and therefore not exactly equal to\n``Decimal(\'1.1\')`` which is. When cross-type comparison is not\nsupported, the comparison method returns ``NotImplemented``. This can\ncreate the illusion of non-transitivity between supported cross-type\ncomparisons and unsupported comparisons. For example, ``Decimal(2) ==\n2`` and ``2 == float(2)`` but ``Decimal(2) != float(2)``.\n\nThe operators ``in`` and ``not in`` test for membership. ``x in s``\nevaluates to true if *x* is a member of *s*, and false otherwise. ``x\nnot in s`` returns the negation of ``x in s``. All built-in sequences\nand set types support this as well as dictionary, for which ``in``\ntests whether a the dictionary has a given key. For container types\nsuch as list, tuple, set, frozenset, dict, or collections.deque, the\nexpression ``x in y`` is equivalent to ``any(x is e or x == e for e in\ny)``.\n\nFor the string and bytes types, ``x in y`` is true if and only if *x*\nis a substring of *y*. An equivalent test is ``y.find(x) != -1``.\nEmpty strings are always considered to be a substring of any other\nstring, so ``"" in "abc"`` will return ``True``.\n\nFor user-defined classes which define the ``__contains__()`` method,\n``x in y`` is true if and only if ``y.__contains__(x)`` is true.\n\nFor user-defined classes which do not define ``__contains__()`` but do\ndefine ``__iter__()``, ``x in y`` is true if some value ``z`` with ``x\n== z`` is produced while iterating over ``y``. If an exception is\nraised during the iteration, it is as if ``in`` raised that exception.\n\nLastly, the old-style iteration protocol is tried: if a class defines\n``__getitem__()``, ``x in y`` is true if and only if there is a non-\nnegative integer index *i* such that ``x == y[i]``, and all lower\ninteger indices do not raise ``IndexError`` exception. (If any other\nexception is raised, it is as if ``in`` raised that exception).\n\nThe operator ``not in`` is defined to have the inverse true value of\n``in``.\n\nThe operators ``is`` and ``is not`` test for object identity: ``x is\ny`` is true if and only if *x* and *y* are the same object. ``x is\nnot y`` yields the inverse truth value. [4]\n',
+ 'integers': '\nInteger literals\n****************\n\nInteger literals are described by the following lexical definitions:\n\n integer ::= decimalinteger | octinteger | hexinteger | bininteger\n decimalinteger ::= nonzerodigit digit* | "0"+\n nonzerodigit ::= "1"..."9"\n digit ::= "0"..."9"\n octinteger ::= "0" ("o" | "O") octdigit+\n hexinteger ::= "0" ("x" | "X") hexdigit+\n bininteger ::= "0" ("b" | "B") bindigit+\n octdigit ::= "0"..."7"\n hexdigit ::= digit | "a"..."f" | "A"..."F"\n bindigit ::= "0" | "1"\n\nThere is no limit for the length of integer literals apart from what\ncan be stored in available memory.\n\nNote that leading zeros in a non-zero decimal number are not allowed.\nThis is for disambiguation with C-style octal literals, which Python\nused before version 3.0.\n\nSome examples of integer literals:\n\n 7 2147483647 0o177 0b100110111\n 3 79228162514264337593543950336 0o377 0x100000000\n 79228162514264337593543950336 0xdeadbeef\n',
+ 'lambda': '\nLambdas\n*******\n\n lambda_form ::= "lambda" [parameter_list]: expression\n lambda_form_nocond ::= "lambda" [parameter_list]: expression_nocond\n\nLambda forms (lambda expressions) have the same syntactic position as\nexpressions. They are a shorthand to create anonymous functions; the\nexpression ``lambda arguments: expression`` yields a function object.\nThe unnamed object behaves like a function object defined with\n\n def <lambda>(arguments):\n return expression\n\nSee section *Function definitions* for the syntax of parameter lists.\nNote that functions created with lambda forms cannot contain\nstatements or annotations.\n',
+ 'lists': '\nList displays\n*************\n\nA list display is a possibly empty series of expressions enclosed in\nsquare brackets:\n\n list_display ::= "[" [expression_list | comprehension] "]"\n\nA list display yields a new list object, the contents being specified\nby either a list of expressions or a comprehension. When a comma-\nseparated list of expressions is supplied, its elements are evaluated\nfrom left to right and placed into the list object in that order.\nWhen a comprehension is supplied, the list is constructed from the\nelements resulting from the comprehension.\n',
+ 'naming': "\nNaming and binding\n******************\n\n*Names* refer to objects. Names are introduced by name binding\noperations. Each occurrence of a name in the program text refers to\nthe *binding* of that name established in the innermost function block\ncontaining the use.\n\nA *block* is a piece of Python program text that is executed as a\nunit. The following are blocks: a module, a function body, and a class\ndefinition. Each command typed interactively is a block. A script\nfile (a file given as standard input to the interpreter or specified\non the interpreter command line the first argument) is a code block.\nA script command (a command specified on the interpreter command line\nwith the '**-c**' option) is a code block. The string argument passed\nto the built-in functions ``eval()`` and ``exec()`` is a code block.\n\nA code block is executed in an *execution frame*. A frame contains\nsome administrative information (used for debugging) and determines\nwhere and how execution continues after the code block's execution has\ncompleted.\n\nA *scope* defines the visibility of a name within a block. If a local\nvariable is defined in a block, its scope includes that block. If the\ndefinition occurs in a function block, the scope extends to any blocks\ncontained within the defining one, unless a contained block introduces\na different binding for the name. The scope of names defined in a\nclass block is limited to the class block; it does not extend to the\ncode blocks of methods -- this includes comprehensions and generator\nexpressions since they are implemented using a function scope. This\nmeans that the following will fail:\n\n class A:\n a = 42\n b = list(a + i for i in range(10))\n\nWhen a name is used in a code block, it is resolved using the nearest\nenclosing scope. The set of all such scopes visible to a code block\nis called the block's *environment*.\n\nIf a name is bound in a block, it is a local variable of that block,\nunless declared as ``nonlocal``. If a name is bound at the module\nlevel, it is a global variable. (The variables of the module code\nblock are local and global.) If a variable is used in a code block\nbut not defined there, it is a *free variable*.\n\nWhen a name is not found at all, a ``NameError`` exception is raised.\nIf the name refers to a local variable that has not been bound, a\n``UnboundLocalError`` exception is raised. ``UnboundLocalError`` is a\nsubclass of ``NameError``.\n\nThe following constructs bind names: formal parameters to functions,\n``import`` statements, class and function definitions (these bind the\nclass or function name in the defining block), and targets that are\nidentifiers if occurring in an assignment, ``for`` loop header, or\nafter ``as`` in a ``with`` statement or ``except`` clause. The\n``import`` statement of the form ``from ... import *`` binds all names\ndefined in the imported module, except those beginning with an\nunderscore. This form may only be used at the module level.\n\nA target occurring in a ``del`` statement is also considered bound for\nthis purpose (though the actual semantics are to unbind the name).\n\nEach assignment or import statement occurs within a block defined by a\nclass or function definition or at the module level (the top-level\ncode block).\n\nIf a name binding operation occurs anywhere within a code block, all\nuses of the name within the block are treated as references to the\ncurrent block. This can lead to errors when a name is used within a\nblock before it is bound. This rule is subtle. Python lacks\ndeclarations and allows name binding operations to occur anywhere\nwithin a code block. The local variables of a code block can be\ndetermined by scanning the entire text of the block for name binding\noperations.\n\nIf the ``global`` statement occurs within a block, all uses of the\nname specified in the statement refer to the binding of that name in\nthe top-level namespace. Names are resolved in the top-level\nnamespace by searching the global namespace, i.e. the namespace of the\nmodule containing the code block, and the builtins namespace, the\nnamespace of the module ``builtins``. The global namespace is\nsearched first. If the name is not found there, the builtins\nnamespace is searched. The global statement must precede all uses of\nthe name.\n\nThe builtins namespace associated with the execution of a code block\nis actually found by looking up the name ``__builtins__`` in its\nglobal namespace; this should be a dictionary or a module (in the\nlatter case the module's dictionary is used). By default, when in the\n``__main__`` module, ``__builtins__`` is the built-in module\n``builtins``; when in any other module, ``__builtins__`` is an alias\nfor the dictionary of the ``builtins`` module itself.\n``__builtins__`` can be set to a user-created dictionary to create a\nweak form of restricted execution.\n\n**CPython implementation detail:** Users should not touch\n``__builtins__``; it is strictly an implementation detail. Users\nwanting to override values in the builtins namespace should ``import``\nthe ``builtins`` module and modify its attributes appropriately.\n\nThe namespace for a module is automatically created the first time a\nmodule is imported. The main module for a script is always called\n``__main__``.\n\nThe ``global`` statement has the same scope as a name binding\noperation in the same block. If the nearest enclosing scope for a\nfree variable contains a global statement, the free variable is\ntreated as a global.\n\nA class definition is an executable statement that may use and define\nnames. These references follow the normal rules for name resolution.\nThe namespace of the class definition becomes the attribute dictionary\nof the class. Names defined at the class scope are not visible in\nmethods.\n\n\nInteraction with dynamic features\n=================================\n\nThere are several cases where Python statements are illegal when used\nin conjunction with nested scopes that contain free variables.\n\nIf a variable is referenced in an enclosing scope, it is illegal to\ndelete the name. An error will be reported at compile time.\n\nIf the wild card form of import --- ``import *`` --- is used in a\nfunction and the function contains or is a nested block with free\nvariables, the compiler will raise a ``SyntaxError``.\n\nThe ``eval()`` and ``exec()`` functions do not have access to the full\nenvironment for resolving names. Names may be resolved in the local\nand global namespaces of the caller. Free variables are not resolved\nin the nearest enclosing namespace, but in the global namespace. [1]\nThe ``exec()`` and ``eval()`` functions have optional arguments to\noverride the global and local namespace. If only one namespace is\nspecified, it is used for both.\n",
+ 'nonlocal': '\nThe ``nonlocal`` statement\n**************************\n\n nonlocal_stmt ::= "nonlocal" identifier ("," identifier)*\n\nThe ``nonlocal`` statement causes the listed identifiers to refer to\npreviously bound variables in the nearest enclosing scope. This is\nimportant because the default behavior for binding is to search the\nlocal namespace first. The statement allows encapsulated code to\nrebind variables outside of the local scope besides the global\n(module) scope.\n\nNames listed in a ``nonlocal`` statement, unlike to those listed in a\n``global`` statement, must refer to pre-existing bindings in an\nenclosing scope (the scope in which a new binding should be created\ncannot be determined unambiguously).\n\nNames listed in a ``nonlocal`` statement must not collide with pre-\nexisting bindings in the local scope.\n\nSee also:\n\n **PEP 3104** - Access to Names in Outer Scopes\n The specification for the ``nonlocal`` statement.\n',
+ 'numbers': "\nNumeric literals\n****************\n\nThere are three types of numeric literals: integers, floating point\nnumbers, and imaginary numbers. There are no complex literals\n(complex numbers can be formed by adding a real number and an\nimaginary number).\n\nNote that numeric literals do not include a sign; a phrase like ``-1``\nis actually an expression composed of the unary operator '``-``' and\nthe literal ``1``.\n",
+ 'numeric-types': "\nEmulating numeric types\n***********************\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [2] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand's type is a subclass of the left operand's\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand's\n non-reflected method. This behavior allows subclasses to\n override their ancestors' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n",
+ 'objects': '\nObjects, values and types\n*************************\n\n*Objects* are Python\'s abstraction for data. All data in a Python\nprogram is represented by objects or by relations between objects. (In\na sense, and in conformance to Von Neumann\'s model of a "stored\nprogram computer," code is also represented by objects.)\n\nEvery object has an identity, a type and a value. An object\'s\n*identity* never changes once it has been created; you may think of it\nas the object\'s address in memory. The \'``is``\' operator compares the\nidentity of two objects; the ``id()`` function returns an integer\nrepresenting its identity (currently implemented as its address). An\nobject\'s *type* is also unchangeable. [1] An object\'s type determines\nthe operations that the object supports (e.g., "does it have a\nlength?") and also defines the possible values for objects of that\ntype. The ``type()`` function returns an object\'s type (which is an\nobject itself). The *value* of some objects can change. Objects\nwhose value can change are said to be *mutable*; objects whose value\nis unchangeable once they are created are called *immutable*. (The\nvalue of an immutable container object that contains a reference to a\nmutable object can change when the latter\'s value is changed; however\nthe container is still considered immutable, because the collection of\nobjects it contains cannot be changed. So, immutability is not\nstrictly the same as having an unchangeable value, it is more subtle.)\nAn object\'s mutability is determined by its type; for instance,\nnumbers, strings and tuples are immutable, while dictionaries and\nlists are mutable.\n\nObjects are never explicitly destroyed; however, when they become\nunreachable they may be garbage-collected. An implementation is\nallowed to postpone garbage collection or omit it altogether --- it is\na matter of implementation quality how garbage collection is\nimplemented, as long as no objects are collected that are still\nreachable.\n\n**CPython implementation detail:** CPython currently uses a reference-\ncounting scheme with (optional) delayed detection of cyclically linked\ngarbage, which collects most objects as soon as they become\nunreachable, but is not guaranteed to collect garbage containing\ncircular references. See the documentation of the ``gc`` module for\ninformation on controlling the collection of cyclic garbage. Other\nimplementations act differently and CPython may change. Do not depend\non immediate finalization of objects when they become unreachable (ex:\nalways close files).\n\nNote that the use of the implementation\'s tracing or debugging\nfacilities may keep objects alive that would normally be collectable.\nAlso note that catching an exception with a \'``try``...``except``\'\nstatement may keep objects alive.\n\nSome objects contain references to "external" resources such as open\nfiles or windows. It is understood that these resources are freed\nwhen the object is garbage-collected, but since garbage collection is\nnot guaranteed to happen, such objects also provide an explicit way to\nrelease the external resource, usually a ``close()`` method. Programs\nare strongly recommended to explicitly close such objects. The\n\'``try``...``finally``\' statement and the \'``with``\' statement provide\nconvenient ways to do this.\n\nSome objects contain references to other objects; these are called\n*containers*. Examples of containers are tuples, lists and\ndictionaries. The references are part of a container\'s value. In\nmost cases, when we talk about the value of a container, we imply the\nvalues, not the identities of the contained objects; however, when we\ntalk about the mutability of a container, only the identities of the\nimmediately contained objects are implied. So, if an immutable\ncontainer (like a tuple) contains a reference to a mutable object, its\nvalue changes if that mutable object is changed.\n\nTypes affect almost all aspects of object behavior. Even the\nimportance of object identity is affected in some sense: for immutable\ntypes, operations that compute new values may actually return a\nreference to any existing object with the same type and value, while\nfor mutable objects this is not allowed. E.g., after ``a = 1; b =\n1``, ``a`` and ``b`` may or may not refer to the same object with the\nvalue one, depending on the implementation, but after ``c = []; d =\n[]``, ``c`` and ``d`` are guaranteed to refer to two different,\nunique, newly created empty lists. (Note that ``c = d = []`` assigns\nthe same object to both ``c`` and ``d``.)\n',
+ 'operator-summary': '\nSummary\n*******\n\nThe following table summarizes the operator precedences in Python,\nfrom lowest precedence (least binding) to highest precedence (most\nbinding). Operators in the same box have the same precedence. Unless\nthe syntax is explicitly given, operators are binary. Operators in\nthe same box group left to right (except for comparisons, including\ntests, which all have the same precedence and chain from left to right\n--- see section *Comparisons* --- and exponentiation, which groups\nfrom right to left).\n\n+-------------------------------------------------+---------------------------------------+\n| Operator | Description |\n+=================================================+=======================================+\n| ``lambda`` | Lambda expression |\n+-------------------------------------------------+---------------------------------------+\n| ``if`` -- ``else`` | Conditional expression |\n+-------------------------------------------------+---------------------------------------+\n| ``or`` | Boolean OR |\n+-------------------------------------------------+---------------------------------------+\n| ``and`` | Boolean AND |\n+-------------------------------------------------+---------------------------------------+\n| ``not`` *x* | Boolean NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``in``, ``not`` ``in``, ``is``, ``is not``, | Comparisons, including membership |\n| ``<``, ``<=``, ``>``, ``>=``, ``!=``, ``==`` | tests and identity tests, |\n+-------------------------------------------------+---------------------------------------+\n| ``|`` | Bitwise OR |\n+-------------------------------------------------+---------------------------------------+\n| ``^`` | Bitwise XOR |\n+-------------------------------------------------+---------------------------------------+\n| ``&`` | Bitwise AND |\n+-------------------------------------------------+---------------------------------------+\n| ``<<``, ``>>`` | Shifts |\n+-------------------------------------------------+---------------------------------------+\n| ``+``, ``-`` | Addition and subtraction |\n+-------------------------------------------------+---------------------------------------+\n| ``*``, ``/``, ``//``, ``%`` | Multiplication, division, remainder |\n| | [5] |\n+-------------------------------------------------+---------------------------------------+\n| ``+x``, ``-x``, ``~x`` | Positive, negative, bitwise NOT |\n+-------------------------------------------------+---------------------------------------+\n| ``**`` | Exponentiation [6] |\n+-------------------------------------------------+---------------------------------------+\n| ``x[index]``, ``x[index:index]``, | Subscription, slicing, call, |\n| ``x(arguments...)``, ``x.attribute`` | attribute reference |\n+-------------------------------------------------+---------------------------------------+\n| ``(expressions...)``, ``[expressions...]``, | Binding or tuple display, list |\n| ``{key:datum...}``, ``{expressions...}`` | display, dictionary display, set |\n| | display |\n+-------------------------------------------------+---------------------------------------+\n\n-[ Footnotes ]-\n\n[1] While ``abs(x%y) < abs(y)`` is true mathematically, for floats it\n may not be true numerically due to roundoff. For example, and\n assuming a platform on which a Python float is an IEEE 754 double-\n precision number, in order that ``-1e-100 % 1e100`` have the same\n sign as ``1e100``, the computed result is ``-1e-100 + 1e100``,\n which is numerically exactly equal to ``1e100``. The function\n ``math.fmod()`` returns a result whose sign matches the sign of\n the first argument instead, and so returns ``-1e-100`` in this\n case. Which approach is more appropriate depends on the\n application.\n\n[2] If x is very close to an exact integer multiple of y, it\'s\n possible for ``x//y`` to be one larger than ``(x-x%y)//y`` due to\n rounding. In such cases, Python returns the latter result, in\n order to preserve that ``divmod(x,y)[0] * y + x % y`` be very\n close to ``x``.\n\n[3] While comparisons between strings make sense at the byte level,\n they may be counter-intuitive to users. For example, the strings\n ``"\\u00C7"`` and ``"\\u0327\\u0043"`` compare differently, even\n though they both represent the same unicode character (LATIN\n CAPITAL LETTER C WITH CEDILLA). To compare strings in a human\n recognizable way, compare using ``unicodedata.normalize()``.\n\n[4] Due to automatic garbage-collection, free lists, and the dynamic\n nature of descriptors, you may notice seemingly unusual behaviour\n in certain uses of the ``is`` operator, like those involving\n comparisons between instance methods, or constants. Check their\n documentation for more info.\n\n[5] The ``%`` operator is also used for string formatting; the same\n precedence applies.\n\n[6] The power operator ``**`` binds less tightly than an arithmetic or\n bitwise unary operator on its right, that is, ``2**-1`` is\n ``0.5``.\n',
'pass': '\nThe ``pass`` statement\n**********************\n\n pass_stmt ::= "pass"\n\n``pass`` is a null operation --- when it is executed, nothing happens.\nIt is useful as a placeholder when a statement is required\nsyntactically, but no code needs to be executed, for example:\n\n def f(arg): pass # a function that does nothing (yet)\n\n class C: pass # a class with no methods (yet)\n',
- 'power': '\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): ``-1**2`` results in ``-1``.\n\nThe power operator has the same semantics as the built-in ``pow()``\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type. The result type is that of the\narguments after coercion.\n\nWith mixed operand types, the coercion rules for binary arithmetic\noperators apply. For int and long int operands, the result has the\nsame type as the operands (after coercion) unless the second argument\nis negative; in that case, all arguments are converted to float and a\nfloat result is delivered. For example, ``10**2`` returns ``100``, but\n``10**-2`` returns ``0.01``. (This last feature was added in Python\n2.2. In Python 2.1 and before, if both arguments were of integer types\nand the second argument was negative, an exception was raised).\n\nRaising ``0.0`` to a negative power results in a\n``ZeroDivisionError``. Raising a negative number to a fractional power\nresults in a ``ValueError``.\n',
- 'raise': '\nThe ``raise`` statement\n***********************\n\n raise_stmt ::= "raise" [expression ["," expression ["," expression]]]\n\nIf no expressions are present, ``raise`` re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a ``TypeError`` exception is raised indicating that\nthis is an error (if running under IDLE, a ``Queue.Empty`` exception\nis raised instead).\n\nOtherwise, ``raise`` evaluates the expressions to get three objects,\nusing ``None`` as the value of omitted expressions. The first two\nobjects are used to determine the *type* and *value* of the exception.\n\nIf the first object is an instance, the type of the exception is the\nclass of the instance, the instance itself is the value, and the\nsecond object must be ``None``.\n\nIf the first object is a class, it becomes the type of the exception.\nThe second object is used to determine the exception value: If it is\nan instance of the class, the instance becomes the exception value. If\nthe second object is a tuple, it is used as the argument list for the\nclass constructor; if it is ``None``, an empty argument list is used,\nand any other object is treated as a single argument to the\nconstructor. The instance so created by calling the constructor is\nused as the exception value.\n\nIf a third object is present and not ``None``, it must be a traceback\nobject (see section *The standard type hierarchy*), and it is\nsubstituted instead of the current location as the place where the\nexception occurred. If the third object is present and not a\ntraceback object or ``None``, a ``TypeError`` exception is raised.\nThe three-expression form of ``raise`` is useful to re-raise an\nexception transparently in an except clause, but ``raise`` with no\nexpressions should be preferred if the exception to be re-raised was\nthe most recently active exception in the current scope.\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n',
+ 'power': '\nThe power operator\n******************\n\nThe power operator binds more tightly than unary operators on its\nleft; it binds less tightly than unary operators on its right. The\nsyntax is:\n\n power ::= primary ["**" u_expr]\n\nThus, in an unparenthesized sequence of power and unary operators, the\noperators are evaluated from right to left (this does not constrain\nthe evaluation order for the operands): ``-1**2`` results in ``-1``.\n\nThe power operator has the same semantics as the built-in ``pow()``\nfunction, when called with two arguments: it yields its left argument\nraised to the power of its right argument. The numeric arguments are\nfirst converted to a common type, and the result is of that type.\n\nFor int operands, the result has the same type as the operands unless\nthe second argument is negative; in that case, all arguments are\nconverted to float and a float result is delivered. For example,\n``10**2`` returns ``100``, but ``10**-2`` returns ``0.01``.\n\nRaising ``0.0`` to a negative power results in a\n``ZeroDivisionError``. Raising a negative number to a fractional power\nresults in a ``complex`` number. (In earlier versions it raised a\n``ValueError``.)\n',
+ 'raise': '\nThe ``raise`` statement\n***********************\n\n raise_stmt ::= "raise" [expression ["from" expression]]\n\nIf no expressions are present, ``raise`` re-raises the last exception\nthat was active in the current scope. If no exception is active in\nthe current scope, a ``RuntimeError`` exception is raised indicating\nthat this is an error.\n\nOtherwise, ``raise`` evaluates the first expression as the exception\nobject. It must be either a subclass or an instance of\n``BaseException``. If it is a class, the exception instance will be\nobtained when needed by instantiating the class with no arguments.\n\nThe *type* of the exception is the exception instance\'s class, the\n*value* is the instance itself.\n\nA traceback object is normally created automatically when an exception\nis raised and attached to it as the ``__traceback__`` attribute, which\nis writable. You can create an exception and set your own traceback in\none step using the ``with_traceback()`` exception method (which\nreturns the same exception instance, with its traceback set to its\nargument), like so:\n\n raise Exception("foo occurred").with_traceback(tracebackobj)\n\nThe ``from`` clause is used for exception chaining: if given, the\nsecond *expression* must be another exception class or instance, which\nwill then be attached to the raised exception as the ``__cause__``\nattribute (which is writable). If the raised exception is not\nhandled, both exceptions will be printed:\n\n >>> try:\n ... print(1 / 0)\n ... except Exception as exc:\n ... raise RuntimeError("Something bad happened") from exc\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n The above exception was the direct cause of the following exception:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nA similar mechanism works implicitly if an exception is raised inside\nan exception handler: the previous exception is then attached as the\nnew exception\'s ``__context__`` attribute:\n\n >>> try:\n ... print(1 / 0)\n ... except:\n ... raise RuntimeError("Something bad happened")\n ...\n Traceback (most recent call last):\n File "<stdin>", line 2, in <module>\n ZeroDivisionError: int division or modulo by zero\n\n During handling of the above exception, another exception occurred:\n\n Traceback (most recent call last):\n File "<stdin>", line 4, in <module>\n RuntimeError: Something bad happened\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information about handling exceptions is in section\n*The try statement*.\n',
'return': '\nThe ``return`` statement\n************************\n\n return_stmt ::= "return" [expression_list]\n\n``return`` may only occur syntactically nested in a function\ndefinition, not within a nested class definition.\n\nIf an expression list is present, it is evaluated, else ``None`` is\nsubstituted.\n\n``return`` leaves the current function call with the expression list\n(or ``None``) as return value.\n\nWhen ``return`` passes control out of a ``try`` statement with a\n``finally`` clause, that ``finally`` clause is executed before really\nleaving the function.\n\nIn a generator function, the ``return`` statement is not allowed to\ninclude an ``expression_list``. In that context, a bare ``return``\nindicates that the generator is done and will cause ``StopIteration``\nto be raised.\n',
- 'sequence-types': "\nEmulating container types\n*************************\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. (For backwards compatibility, the method\n``__getslice__()`` (see below) can also be defined to handle simple,\nbut not extended slices.) It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``has_key()``,\n``get()``, ``clear()``, ``setdefault()``, ``iterkeys()``,\n``itervalues()``, ``iteritems()``, ``pop()``, ``popitem()``,\n``copy()``, and ``update()`` behaving similar to those for Python's\nstandard dictionary objects. The ``UserDict`` module provides a\n``DictMixin`` class to help create those methods from a base set of\n``__getitem__()``, ``__setitem__()``, ``__delitem__()``, and\n``keys()``. Mutable sequences should provide methods ``append()``,\n``count()``, ``index()``, ``extend()``, ``insert()``, ``pop()``,\n``remove()``, ``reverse()`` and ``sort()``, like Python standard list\nobjects. Finally, sequence types should implement addition (meaning\nconcatenation) and multiplication (meaning repetition) by defining the\nmethods ``__add__()``, ``__radd__()``, ``__iadd__()``, ``__mul__()``,\n``__rmul__()`` and ``__imul__()`` described below; they should not\ndefine ``__coerce__()`` or other numerical operators. It is\nrecommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should be equivalent of ``has_key()``;\nfor sequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``iterkeys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn't define a ``__nonzero__()`` method and whose\n ``__len__()`` method returns zero is considered to be false in a\n Boolean context.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``iterkeys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\n New in version 2.6.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don't define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n",
- 'shifting': '\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept plain or long integers as arguments. The\narguments are converted to a common type. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as division by ``pow(2, n)``. A\nleft shift by *n* bits is defined as multiplication with ``pow(2,\nn)``. Negative shift counts raise a ``ValueError`` exception.\n\nNote: In the current implementation, the right-hand operand is required to\n be at most ``sys.maxsize``. If the right-hand operand is larger\n than ``sys.maxsize`` an ``OverflowError`` exception is raised.\n',
- 'slicings': '\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or ``del`` statements. The syntax for a\nslicing:\n\n slicing ::= simple_slicing | extended_slicing\n simple_slicing ::= primary "[" short_slice "]"\n extended_slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice | ellipsis\n proper_slice ::= short_slice | long_slice\n short_slice ::= [lower_bound] ":" [upper_bound]\n long_slice ::= short_slice ":" [stride]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n ellipsis ::= "..."\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice nor ellipses). Similarly, when the slice\nlist has exactly one short slice and no trailing comma, the\ninterpretation as a simple slicing takes priority over that as an\nextended slicing.\n\nThe semantics for a simple slicing are as follows. The primary must\nevaluate to a sequence object. The lower and upper bound expressions,\nif present, must evaluate to plain integers; defaults are zero and the\n``sys.maxint``, respectively. If either bound is negative, the\nsequence\'s length is added to it. The slicing now selects all items\nwith index *k* such that ``i <= k < j`` where *i* and *j* are the\nspecified lower and upper bounds. This may be an empty sequence. It\nis not an error if *i* or *j* lie outside the range of valid indexes\n(such items don\'t exist so they aren\'t selected).\n\nThe semantics for an extended slicing are as follows. The primary\nmust evaluate to a mapping object, and it is indexed with a key that\nis constructed from the slice list, as follows. If the slice list\ncontains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of an ellipsis slice\nitem is the built-in ``Ellipsis`` object. The conversion of a proper\nslice is a slice object (see section *The standard type hierarchy*)\nwhose ``start``, ``stop`` and ``step`` attributes are the values of\nthe expressions given as lower bound, upper bound and stride,\nrespectively, substituting ``None`` for missing expressions.\n',
- 'specialattrs': '\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the ``dir()`` built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object\'s\n (writable) attributes.\n\nobject.__methods__\n\n Deprecated since version 2.2: Use the built-in function ``dir()``\n to get a list of an object\'s attributes. This attribute is no\n longer available.\n\nobject.__members__\n\n Deprecated since version 2.2: Use the built-in function ``dir()``\n to get a list of an object\'s attributes. This attribute is no\n longer available.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nThe following attributes are only supported by *new-style class*es.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in ``__mro__``.\n\nclass.__subclasses__()\n\n Each new-style class keeps a list of weak references to its\n immediate subclasses. This method returns a list of all those\n references still alive. Example:\n\n >>> int.__subclasses__()\n [<type \'bool\'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found in\n the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list ``[1, 2]`` is considered equal to\n ``[1.0, 2.0]``, and similarly for tuples.\n\n[3] They must have since the parser can\'t tell the type of the\n operands.\n\n[4] Cased characters are those with general category property being\n one of "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt"\n (Letter, titlecase).\n\n[5] To format only a tuple you should therefore provide a singleton\n tuple whose only element is the tuple to be formatted.\n\n[6] The advantage of leaving the newline on is that returning an empty\n string is then an unambiguous EOF indication. It is also possible\n (in cases where it might matter, for example, if you want to make\n an exact copy of a file while scanning its lines) to tell whether\n the last line of a file ended in a newline or not (yes this\n happens!).\n',
- 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``x.__getitem__(i)`` for\nold-style classes and ``type(x).__getitem__(x, i)`` for new-style\nclasses. Except where mentioned, attempts to execute an operation\nraise an exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_traceback`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.exc_traceback`` or ``sys.last_traceback``. Circular\n references which are garbage are detected when the option cycle\n detector is enabled (it\'s on by default), but can only be cleaned\n up if there are no Python-level ``__del__()`` methods involved.\n Refer to the documentation for the ``gc`` module for more\n information about how ``__del__()`` methods are handled by the\n cycle detector, particularly the description of the ``garbage``\n value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\n See also the *-R* command-line option.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function and by string\n conversions (reverse quotes) to compute the "official" string\n representation of an object. If at all possible, this should look\n like a valid Python expression that could be used to recreate an\n object with the same value (given an appropriate environment). If\n this is not possible, a string of the form ``<...some useful\n description...>`` should be returned. The return value must be a\n string object. If a class defines ``__repr__()`` but not\n ``__str__()``, then ``__repr__()`` is also used when an "informal"\n string representation of instances of that class is required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print``\n statement to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n New in version 2.1.\n\n These are the so-called "rich comparison" methods, and are called\n for comparison operators in preference to ``__cmp__()`` below. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` and\n ``x<>y`` call ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and\n ``x>=y`` calls ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__cmp__(self, other)\n\n Called by comparison operations if rich comparison (see above) is\n not defined. Should return a negative integer if ``self < other``,\n zero if ``self == other``, a positive integer if ``self > other``.\n If no ``__cmp__()``, ``__eq__()`` or ``__ne__()`` operation is\n defined, class instances are compared by object identity\n ("address"). See also the description of ``__hash__()`` for some\n important notes on creating *hashable* objects which support custom\n comparison operations and are usable as dictionary keys. (Note: the\n restriction that exceptions are not propagated by ``__cmp__()`` has\n been removed since Python 1.5.)\n\nobject.__rcmp__(self, other)\n\n Changed in version 2.1: No longer supported.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define a ``__cmp__()`` or ``__eq__()`` method\n it should not define a ``__hash__()`` operation either; if it\n defines ``__cmp__()`` or ``__eq__()`` but not ``__hash__()``, its\n instances will not be usable in hashed collections. If a class\n defines mutable objects and implements a ``__cmp__()`` or\n ``__eq__()`` method, it should not implement ``__hash__()``, since\n hashable collection implementations require that a object\'s hash\n value is immutable (if the object\'s hash value changes, it will be\n in the wrong hash bucket).\n\n User-defined classes have ``__cmp__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__cmp__()`` or ``__eq__()`` such that\n the hash value returned is no longer appropriate (e.g. by switching\n to a value-based concept of equality instead of the default\n identity based equality) can explicitly flag themselves as being\n unhashable by setting ``__hash__ = None`` in the class definition.\n Doing so means that not only will instances of the class raise an\n appropriate ``TypeError`` when a program attempts to retrieve their\n hash value, but they will also be correctly identified as\n unhashable when checking ``isinstance(obj, collections.Hashable)``\n (unlike classes which define their own ``__hash__()`` to explicitly\n raise ``TypeError``).\n\n Changed in version 2.5: ``__hash__()`` may now also return a long\n integer object; the 32-bit integer is then derived from the hash of\n that object.\n\n Changed in version 2.6: ``__hash__`` may now be set to ``None`` to\n explicitly flag instances of a class as unhashable.\n\nobject.__nonzero__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``, or their integer\n equivalents ``0`` or ``1``. When this method is not defined,\n ``__len__()`` is called, if it is defined, and the object is\n considered true if its result is nonzero. If a class defines\n neither ``__len__()`` nor ``__nonzero__()``, all its instances are\n considered true.\n\nobject.__unicode__(self)\n\n Called to implement ``unicode()`` built-in; should return a Unicode\n object. When this method is not defined, string conversion is\n attempted, and the result of string conversion is converted to\n Unicode using the system default encoding.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control in new-style classes.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should not simply execute ``self.name = value`` --- this would\n cause a recursive call to itself. Instead, it should insert the\n value in the dictionary of instance attributes, e.g.,\n ``self.__dict__[name] = value``. For new-style classes, rather\n than accessing the instance dictionary, it should call the base\n class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\n\nMore attribute access for new-style classes\n-------------------------------------------\n\nThe following methods only apply to new-style classes.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup for new-style\n classes*.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called. Note that descriptors are only invoked for new\nstyle objects or classes (ones that subclass ``object()`` or\n``type()``).\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to a new-style object instance, ``a.x`` is transformed\n into the call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a new-style class, ``A.x`` is transformed into the\n call: ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, obj.__class__)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of both old and new-style classes have a\ndictionary for attribute storage. This wastes space for objects\nhaving very few instance variables. The space consumption can become\nacute when creating large numbers of instances.\n\nThe default can be overridden by defining *__slots__* in a new-style\nclass definition. The *__slots__* declaration takes a sequence of\ninstance variables and reserves just enough space in each instance to\nhold a value for each variable. Space is saved because *__dict__* is\nnot created for each instance.\n\n__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n new-style class, *__slots__* reserves space for the declared\n variables and prevents the automatic creation of *__dict__* and\n *__weakref__* for each instance.\n\n New in version 2.2.\n\nNotes on using *__slots__*\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n Changed in version 2.3: Previously, adding ``\'__dict__\'`` to the\n *__slots__* declaration would not enable the assignment of new\n attributes not specifically listed in the sequence of instance\n variable names.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n Changed in version 2.3: Previously, adding ``\'__weakref__\'`` to the\n *__slots__* declaration would not enable support for weak\n references.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``long``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n Changed in version 2.6: Previously, *__class__* assignment raised an\n error if either new or old class had *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, new-style classes are constructed using ``type()``. A\nclass definition is read into a separate namespace and the value of\nclass name is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if *__metaclass__* is defined then\nthe callable assigned to it will be called instead of ``type()``. This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties. This example adds a new\nelement to the class dictionary before creating the class:\n\n class metacls(type):\n def __new__(mcs, name, bases, dict):\n dict[\'foo\'] = \'metacls was here\'\n return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\n__metaclass__\n\n This variable can be any callable accepting arguments for ``name``,\n ``bases``, and ``dict``. Upon class creation, the callable is used\n instead of the built-in ``type()``.\n\n New in version 2.2.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If ``dict[\'__metaclass__\']`` exists, it is used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n used (this looks for a *__class__* attribute first and if not found,\n uses its type).\n\n* Otherwise, if a global variable named __metaclass__ exists, it is\n used.\n\n* Otherwise, the old-style, classic metaclass (types.ClassType) is\n used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\n\nCustomizing instance and subclass checks\n========================================\n\nNew in version 2.6.\n\nThe following methods are used to override the default behavior of the\n``isinstance()`` and ``issubclass()`` built-in functions.\n\nIn particular, the metaclass ``abc.ABCMeta`` implements these methods\nin order to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n ``isinstance(instance, class)``.\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n ``issubclass(subclass, class)``.\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also:\n\n **PEP 3119** - Introducing Abstract Base Classes\n Includes the specification for customizing ``isinstance()`` and\n ``issubclass()`` behavior through ``__instancecheck__()`` and\n ``__subclasscheck__()``, with motivation for this functionality\n in the context of adding Abstract Base Classes (see the ``abc``\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. (For backwards compatibility, the method\n``__getslice__()`` (see below) can also be defined to handle simple,\nbut not extended slices.) It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``has_key()``,\n``get()``, ``clear()``, ``setdefault()``, ``iterkeys()``,\n``itervalues()``, ``iteritems()``, ``pop()``, ``popitem()``,\n``copy()``, and ``update()`` behaving similar to those for Python\'s\nstandard dictionary objects. The ``UserDict`` module provides a\n``DictMixin`` class to help create those methods from a base set of\n``__getitem__()``, ``__setitem__()``, ``__delitem__()``, and\n``keys()``. Mutable sequences should provide methods ``append()``,\n``count()``, ``index()``, ``extend()``, ``insert()``, ``pop()``,\n``remove()``, ``reverse()`` and ``sort()``, like Python standard list\nobjects. Finally, sequence types should implement addition (meaning\nconcatenation) and multiplication (meaning repetition) by defining the\nmethods ``__add__()``, ``__radd__()``, ``__iadd__()``, ``__mul__()``,\n``__rmul__()`` and ``__imul__()`` described below; they should not\ndefine ``__coerce__()`` or other numerical operators. It is\nrecommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should be equivalent of ``has_key()``;\nfor sequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``iterkeys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn\'t define a ``__nonzero__()`` method and whose\n ``__len__()`` method returns zero is considered to be false in a\n Boolean context.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``iterkeys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\n New in version 2.6.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n\n\nAdditional methods for emulation of sequence types\n==================================================\n\nThe following optional methods can be defined to further emulate\nsequence objects. Immutable sequences methods should at most only\ndefine ``__getslice__()``; mutable sequences might define all three\nmethods.\n\nobject.__getslice__(self, i, j)\n\n Deprecated since version 2.0: Support slice objects as parameters\n to the ``__getitem__()`` method. (However, built-in types in\n CPython currently still implement ``__getslice__()``. Therefore,\n you have to override it in derived classes when implementing\n slicing.)\n\n Called to implement evaluation of ``self[i:j]``. The returned\n object should be of the same type as *self*. Note that missing *i*\n or *j* in the slice expression are replaced by zero or\n ``sys.maxint``, respectively. If negative indexes are used in the\n slice, the length of the sequence is added to that index. If the\n instance does not implement the ``__len__()`` method, an\n ``AttributeError`` is raised. No guarantee is made that indexes\n adjusted this way are not still negative. Indexes which are\n greater than the length of the sequence are not modified. If no\n ``__getslice__()`` is found, a slice object is created instead, and\n passed to ``__getitem__()`` instead.\n\nobject.__setslice__(self, i, j, sequence)\n\n Called to implement assignment to ``self[i:j]``. Same notes for *i*\n and *j* as for ``__getslice__()``.\n\n This method is deprecated. If no ``__setslice__()`` is found, or\n for extended slicing of the form ``self[i:j:k]``, a slice object is\n created, and passed to ``__setitem__()``, instead of\n ``__setslice__()`` being called.\n\nobject.__delslice__(self, i, j)\n\n Called to implement deletion of ``self[i:j]``. Same notes for *i*\n and *j* as for ``__getslice__()``. This method is deprecated. If no\n ``__delslice__()`` is found, or for extended slicing of the form\n ``self[i:j:k]``, a slice object is created, and passed to\n ``__delitem__()``, instead of ``__delslice__()`` being called.\n\nNotice that these methods are only invoked when a single slice with a\nsingle colon is used, and the slice method is available. For slice\noperations involving extended slice notation, or in absence of the\nslice methods, ``__getitem__()``, ``__setitem__()`` or\n``__delitem__()`` is called with a slice object as argument.\n\nThe following example demonstrate how to make your program or module\ncompatible with earlier versions of Python (assuming that methods\n``__getitem__()``, ``__setitem__()`` and ``__delitem__()`` support\nslice objects as arguments):\n\n class MyClass:\n ...\n def __getitem__(self, index):\n ...\n def __setitem__(self, index, value):\n ...\n def __delitem__(self, index):\n ...\n\n if sys.version_info < (2, 0):\n # They won\'t be defined if version is at least 2.0 final\n\n def __getslice__(self, i, j):\n return self[max(0, i):max(0, j):]\n def __setslice__(self, i, j, seq):\n self[max(0, i):max(0, j):] = seq\n def __delslice__(self, i, j):\n del self[max(0, i):max(0, j):]\n ...\n\nNote the calls to ``max()``; these are necessary because of the\nhandling of negative indices before the ``__*slice__()`` methods are\ncalled. When negative indexes are used, the ``__*item__()`` methods\nreceive them as provided, but the ``__*slice__()`` methods get a\n"cooked" form of the index values. For each negative index value, the\nlength of the sequence is added to the index before calling the method\n(which may still result in a negative index); this is the customary\nhandling of negative indexes by the built-in sequence types, and the\n``__*item__()`` methods are expected to do this as well. However,\nsince they should already be doing that, negative indexes cannot be\npassed in; they must be constrained to the bounds of the sequence\nbefore being passed to the ``__*item__()`` methods. Calling ``max(0,\ni)`` conveniently returns the proper value.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``//``, ``%``, ``divmod()``,\n ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``). For\n instance, to evaluate the expression ``x + y``, where *x* is an\n instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()`` (described below). Note\n that ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__div__(self, other)\nobject.__truediv__(self, other)\n\n The division operator (``/``) is implemented by these methods. The\n ``__truediv__()`` method is used when ``__future__.division`` is in\n effect, otherwise ``__div__()`` is used. If only one of these two\n methods is defined, the object will not support division in the\n alternate context; ``TypeError`` will be raised instead.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rdiv__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``%``, ``divmod()``,\n ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``, ``|``) with\n reflected (swapped) operands. These functions are only called if\n the left operand does not support the corresponding operation and\n the operands are of different types. [2] For instance, to evaluate\n the expression ``x - y``, where *y* is an instance of a class that\n has an ``__rsub__()`` method, ``y.__rsub__(x)`` is called if\n ``x.__sub__(y)`` returns *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left operand\'s\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand\'s\n non-reflected method. This behavior allows subclasses to\n override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__idiv__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__long__(self)\nobject.__float__(self)\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``long()``, and ``float()``. Should return a value of\n the appropriate type.\n\nobject.__oct__(self)\nobject.__hex__(self)\n\n Called to implement the built-in functions ``oct()`` and ``hex()``.\n Should return a string value.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing). Must return\n an integer (int or long).\n\n New in version 2.5.\n\nobject.__coerce__(self, other)\n\n Called to implement "mixed-mode" numeric arithmetic. Should either\n return a 2-tuple containing *self* and *other* converted to a\n common numeric type, or ``None`` if conversion is impossible. When\n the common type would be the type of ``other``, it is sufficient to\n return ``None``, since the interpreter will also ask the other\n object to attempt a coercion (but sometimes, if the implementation\n of the other type cannot be changed, it is useful to do the\n conversion to the other type here). A return value of\n ``NotImplemented`` is equivalent to returning ``None``.\n\n\nCoercion rules\n==============\n\nThis section used to document the rules for coercion. As the language\nhas evolved, the coercion rules have become hard to document\nprecisely; documenting what one version of one particular\nimplementation does is undesirable. Instead, here are some informal\nguidelines regarding coercion. In Python 3.0, coercion will not be\nsupported.\n\n* If the left operand of a % operator is a string or Unicode object,\n no coercion takes place and the string formatting operation is\n invoked instead.\n\n* It is no longer recommended to define a coercion operation. Mixed-\n mode operations on types that don\'t define coercion pass the\n original arguments to the operation.\n\n* New-style classes (those derived from ``object``) never invoke the\n ``__coerce__()`` method in response to a binary operator; the only\n time ``__coerce__()`` is invoked is when the built-in function\n ``coerce()`` is called.\n\n* For most intents and purposes, an operator that returns\n ``NotImplemented`` is treated the same as one that is not\n implemented at all.\n\n* Below, ``__op__()`` and ``__rop__()`` are used to signify the\n generic method names corresponding to an operator; ``__iop__()`` is\n used for the corresponding in-place operator. For example, for the\n operator \'``+``\', ``__add__()`` and ``__radd__()`` are used for the\n left and right variant of the binary operator, and ``__iadd__()``\n for the in-place variant.\n\n* For objects *x* and *y*, first ``x.__op__(y)`` is tried. If this is\n not implemented or returns ``NotImplemented``, ``y.__rop__(x)`` is\n tried. If this is also not implemented or returns\n ``NotImplemented``, a ``TypeError`` exception is raised. But see\n the following exception:\n\n* Exception to the previous item: if the left operand is an instance\n of a built-in type or a new-style class, and the right operand is an\n instance of a proper subclass of that type or class and overrides\n the base\'s ``__rop__()`` method, the right operand\'s ``__rop__()``\n method is tried *before* the left operand\'s ``__op__()`` method.\n\n This is done so that a subclass can completely override binary\n operators. Otherwise, the left operand\'s ``__op__()`` method would\n always accept the right operand: when an instance of a given class\n is expected, an instance of a subclass of that class is always\n acceptable.\n\n* When either operand type defines a coercion, this coercion is called\n before that type\'s ``__op__()`` or ``__rop__()`` method is called,\n but no sooner. If the coercion returns an object of a different\n type for the operand whose coercion is invoked, part of the process\n is redone using the new object.\n\n* When an in-place operator (like \'``+=``\') is used, if the left\n operand implements ``__iop__()``, it is invoked without any\n coercion. When the operation falls back to ``__op__()`` and/or\n ``__rop__()``, the normal coercion rules apply.\n\n* In ``x + y``, if *x* is a sequence that implements sequence\n concatenation, sequence concatenation is invoked.\n\n* In ``x * y``, if one operand is a sequence that implements sequence\n repetition, and the other is an integer (``int`` or ``long``),\n sequence repetition is invoked.\n\n* Rich comparisons (implemented by methods ``__eq__()`` and so on)\n never use coercion. Three-way comparison (implemented by\n ``__cmp__()``) does use coercion under the same conditions as other\n binary operations use it.\n\n* In the current implementation, the built-in numeric types ``int``,\n ``long``, ``float``, and ``complex`` do not use coercion. All these\n types implement a ``__coerce__()`` method, for use by the built-in\n ``coerce()`` function.\n\n Changed in version 2.7.\n\n\nWith Statement Context Managers\n===============================\n\nNew in version 2.5.\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nSpecial method lookup for old-style classes\n===========================================\n\nFor old-style classes, special methods are always looked up in exactly\nthe same way as any other method or attribute. This is the case\nregardless of whether the method is being looked up explicitly as in\n``x.__getitem__(i)`` or implicitly as in ``x[i]``.\n\nThis behaviour means that special methods may exhibit different\nbehaviour for different instances of a single old-style class if the\nappropriate special attributes are set differently:\n\n >>> class C:\n ... pass\n ...\n >>> c1 = C()\n >>> c2 = C()\n >>> c1.__len__ = lambda: 5\n >>> c2.__len__ = lambda: 9\n >>> len(c1)\n 5\n >>> len(c2)\n 9\n\n\nSpecial method lookup for new-style classes\n===========================================\n\nFor new-style classes, implicit invocations of special methods are\nonly guaranteed to work correctly if defined on an object\'s type, not\nin the object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception (unlike the equivalent example\nwith old-style classes):\n\n >>> class C(object):\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print "Metaclass getattribute invoked"\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object):\n ... __metaclass__ = Meta\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print "Class getattribute invoked"\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n certain controlled conditions. It generally isn\'t a good idea\n though, since it can lead to some very strange behaviour if it is\n handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as ``__add__()``) fails the operation is\n not supported, which is why the reflected method is not called.\n',
- 'string-methods': '\nString Methods\n**************\n\nBelow are listed the string methods which both 8-bit strings and\nUnicode objects support. Some of them are also available on\n``bytearray`` objects.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, unicode, list, tuple,\nbytearray, buffer, xrange* section. To output formatted strings use\ntemplate strings or the ``%`` operator described in the *String\nFormatting Operations* section. Also, see the ``re`` module for string\nfunctions based on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.decode([encoding[, errors]])\n\n Decodes the string using the codec registered for *encoding*.\n *encoding* defaults to the default string encoding. *errors* may\n be given to set a different error handling scheme. The default is\n ``\'strict\'``, meaning that encoding errors raise ``UnicodeError``.\n Other possible values are ``\'ignore\'``, ``\'replace\'`` and any other\n name registered via ``codecs.register_error()``, see section *Codec\n Base Classes*.\n\n New in version 2.2.\n\n Changed in version 2.3: Support for other error handling schemes\n added.\n\n Changed in version 2.7: Support for keyword arguments added.\n\nstr.encode([encoding[, errors]])\n\n Return an encoded version of the string. Default encoding is the\n current default string encoding. *errors* may be given to set a\n different error handling scheme. The default for *errors* is\n ``\'strict\'``, meaning that encoding errors raise a\n ``UnicodeError``. Other possible values are ``\'ignore\'``,\n ``\'replace\'``, ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and\n any other name registered via ``codecs.register_error()``, see\n section *Codec Base Classes*. For a list of possible encodings, see\n section *Standard Encodings*.\n\n New in version 2.0.\n\n Changed in version 2.3: Support for ``\'xmlcharrefreplace\'`` and\n ``\'backslashreplace\'`` and other error handling schemes added.\n\n Changed in version 2.7: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\n Changed in version 2.5: Accept tuples as *suffix*.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\n Note: The ``find()`` method should be used only if you need to know the\n position of *sub*. To check if *sub* is a substring or not, use\n the ``in`` operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\n This method of string formatting is the new standard in Python 3.0,\n and should be preferred to the ``%`` formatting described in\n *String Formatting Operations* in new code.\n\n New in version 2.6.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. The separator between elements is the\n string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\n New in version 2.5.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\n New in version 2.5.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\n New in version 2.4.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\n Changed in version 2.5: Accept tuples as *prefix*.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.translate(table[, deletechars])\n\n Return a copy of the string where all characters occurring in the\n optional argument *deletechars* are removed, and the remaining\n characters have been mapped through the given translation table,\n which must be a string of length 256.\n\n You can use the ``maketrans()`` helper function in the ``string``\n module to create a translation table. For string objects, set the\n *table* argument to ``None`` for translations that only delete\n characters:\n\n >>> \'read this short text\'.translate(None, \'aeiou\')\n \'rd ths shrt txt\'\n\n New in version 2.6: Support for a ``None`` *table* argument.\n\n For Unicode objects, the ``translate()`` method does not accept the\n optional *deletechars* argument. Instead, it returns a copy of the\n *s* where all characters have been mapped through the given\n translation table which must be a mapping of Unicode ordinals to\n Unicode ordinals, Unicode strings or ``None``. Unmapped characters\n are left untouched. Characters mapped to ``None`` are deleted.\n Note, a more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see ``encodings.cp1251``\n for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that ``str.upper().isupper()`` might\n be ``False`` if ``s`` contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than or equal to ``len(s)``.\n\n New in version 2.2.2.\n\nThe following methods are present only on unicode objects:\n\nunicode.isnumeric()\n\n Return ``True`` if there are only numeric characters in S,\n ``False`` otherwise. Numeric characters include digit characters,\n and all characters that have the Unicode numeric value property,\n e.g. U+2155, VULGAR FRACTION ONE FIFTH.\n\nunicode.isdecimal()\n\n Return ``True`` if there are only decimal characters in S,\n ``False`` otherwise. Decimal characters include digit characters,\n and all characters that can be used to form decimal-radix numbers,\n e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n',
- 'strings': '\nString literals\n***************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "u" | "ur" | "R" | "U" | "UR" | "Ur" | "uR"\n | "b" | "B" | "br" | "Br" | "bR" | "BR"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'"\n | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | escapeseq\n longstringitem ::= longstringchar | escapeseq\n shortstringchar ::= <any source character except "\\" or newline or the quote>\n longstringchar ::= <any source character except "\\">\n escapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the ``stringprefix`` and the rest of\nthe string literal. The source character set is defined by the\nencoding declaration; it is ASCII if no encoding declaration is given\nin the source file; see section *Encoding declarations*.\n\nIn plain English: String literals can be enclosed in matching single\nquotes (``\'``) or double quotes (``"``). They can also be enclosed in\nmatching groups of three single or double quotes (these are generally\nreferred to as *triple-quoted strings*). The backslash (``\\``)\ncharacter is used to escape characters that otherwise have a special\nmeaning, such as newline, backslash itself, or the quote character.\nString literals may optionally be prefixed with a letter ``\'r\'`` or\n``\'R\'``; such strings are called *raw strings* and use different rules\nfor interpreting backslash escape sequences. A prefix of ``\'u\'`` or\n``\'U\'`` makes the string a Unicode string. Unicode strings use the\nUnicode character set as defined by the Unicode Consortium and ISO\n10646. Some additional escape sequences, described below, are\navailable in Unicode strings. A prefix of ``\'b\'`` or ``\'B\'`` is\nignored in Python 2; it indicates that the literal should become a\nbytes literal in Python 3 (e.g. when code is automatically converted\nwith 2to3). A ``\'u\'`` or ``\'b\'`` prefix may be followed by an ``\'r\'``\nprefix.\n\nIn triple-quoted strings, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the string. (A "quote" is the character used to open the\nstring, i.e. either ``\'`` or ``"``.)\n\nUnless an ``\'r\'`` or ``\'R\'`` prefix is present, escape sequences in\nstrings are interpreted according to rules similar to those used by\nStandard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\newline`` | Ignored | |\n+-------------------+-----------------------------------+---------+\n| ``\\\\`` | Backslash (``\\``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\\'`` | Single quote (``\'``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\"`` | Double quote (``"``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\a`` | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| ``\\b`` | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| ``\\f`` | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\n`` | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\N{name}`` | Character named *name* in the | |\n| | Unicode database (Unicode only) | |\n+-------------------+-----------------------------------+---------+\n| ``\\r`` | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| ``\\t`` | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| ``\\uxxxx`` | Character with 16-bit hex value | (1) |\n| | *xxxx* (Unicode only) | |\n+-------------------+-----------------------------------+---------+\n| ``\\Uxxxxxxxx`` | Character with 32-bit hex value | (2) |\n| | *xxxxxxxx* (Unicode only) | |\n+-------------------+-----------------------------------+---------+\n| ``\\v`` | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| ``\\ooo`` | Character with octal value *ooo* | (3,5) |\n+-------------------+-----------------------------------+---------+\n| ``\\xhh`` | Character with hex value *hh* | (4,5) |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. Individual code units which form parts of a surrogate pair can be\n encoded using this escape sequence.\n\n2. Any Unicode character can be encoded this way, but characters\n outside the Basic Multilingual Plane (BMP) will be encoded using a\n surrogate pair if Python is compiled to use 16-bit code units (the\n default). Individual code units which form parts of a surrogate\n pair can be encoded using this escape sequence.\n\n3. As in Standard C, up to three octal digits are accepted.\n\n4. Unlike in Standard C, exactly two hex digits are required.\n\n5. In a string literal, hexadecimal and octal escapes denote the byte\n with the given value; it is not necessary that the byte encodes a\n character in the source character set. In a Unicode literal, these\n escapes denote a Unicode character with the given value.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the string*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences marked as "(Unicode only)"\nin the table above fall into the category of unrecognized escapes for\nnon-Unicode string literals.\n\nWhen an ``\'r\'`` or ``\'R\'`` prefix is present, a character following a\nbackslash is included in the string without change, and *all\nbackslashes are left in the string*. For example, the string literal\n``r"\\n"`` consists of two characters: a backslash and a lowercase\n``\'n\'``. String quotes can be escaped with a backslash, but the\nbackslash remains in the string; for example, ``r"\\""`` is a valid\nstring literal consisting of two characters: a backslash and a double\nquote; ``r"\\"`` is not a valid string literal (even a raw string\ncannot end in an odd number of backslashes). Specifically, *a raw\nstring cannot end in a single backslash* (since the backslash would\nescape the following quote character). Note also that a single\nbackslash followed by a newline is interpreted as those two characters\nas part of the string, *not* as a line continuation.\n\nWhen an ``\'r\'`` or ``\'R\'`` prefix is used in conjunction with a\n``\'u\'`` or ``\'U\'`` prefix, then the ``\\uXXXX`` and ``\\UXXXXXXXX``\nescape sequences are processed while *all other backslashes are left\nin the string*. For example, the string literal ``ur"\\u0062\\n"``\nconsists of three Unicode characters: \'LATIN SMALL LETTER B\', \'REVERSE\nSOLIDUS\', and \'LATIN SMALL LETTER N\'. Backslashes can be escaped with\na preceding backslash; however, both remain in the string. As a\nresult, ``\\uXXXX`` escape sequences are only recognized when there are\nan odd number of backslashes.\n',
- 'subscriptions': '\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object of a sequence or mapping type.\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to a\nplain integer. If this value is negative, the length of the sequence\nis added to it (so that, e.g., ``x[-1]`` selects the last item of\n``x``.) The resulting value must be a nonnegative integer less than\nthe number of items in the sequence, and the subscription selects the\nitem whose index is that value (counting from zero).\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n',
- 'truth': "\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an ``if`` or\n``while`` condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* ``None``\n\n* ``False``\n\n* zero of any numeric type, for example, ``0``, ``0L``, ``0.0``,\n ``0j``.\n\n* any empty sequence, for example, ``''``, ``()``, ``[]``.\n\n* any empty mapping, for example, ``{}``.\n\n* instances of user-defined classes, if the class defines a\n ``__nonzero__()`` or ``__len__()`` method, when that method returns\n the integer zero or ``bool`` value ``False``. [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn ``0`` or ``False`` for false and ``1`` or ``True`` for true,\nunless otherwise stated. (Important exception: the Boolean operations\n``or`` and ``and`` always return one of their operands.)\n",
- 'try': '\nThe ``try`` statement\n*********************\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression [("as" | ",") target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nChanged in version 2.5: In previous versions of Python,\n``try``...``except``...``finally`` did not work. ``try``...``except``\nhad to be nested in ``try``...``finally``.\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object, a tuple containing an item compatible with the\nexception, or, in the (deprecated) case of string exceptions, is the\nraised string itself (note that the object identities must match, i.e.\nit must be the same string object, not just a string with the same\nvalue).\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified in that except clause, if present, and the except\nclause\'s suite is executed. All except clauses must have an\nexecutable block. When the end of this block is reached, execution\ncontinues normally after the entire try statement. (This means that\nif two nested handlers exist for the same exception, and the exception\noccurs in the try clause of the inner handler, the outer handler will\nnot handle the exception.)\n\nBefore an except clause\'s suite is executed, details about the\nexception are assigned to three variables in the ``sys`` module:\n``sys.exc_type`` receives the object identifying the exception;\n``sys.exc_value`` receives the exception\'s parameter;\n``sys.exc_traceback`` receives a traceback object (see section *The\nstandard type hierarchy*) identifying the point in the program where\nthe exception occurred. These details are also available through the\n``sys.exc_info()`` function, which returns a tuple ``(exc_type,\nexc_value, exc_traceback)``. Use of the corresponding variables is\ndeprecated in favor of this function, since their use is unsafe in a\nthreaded program. As of Python 1.5, the variables are restored to\ntheir previous values (before the call) when returning from a function\nthat handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is lost. The exception information is not available to the\nprogram during execution of the ``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n',
- 'types': '\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.).\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name ``None``.\n It is used to signify the absence of a value in many situations,\n e.g., it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n ``NotImplemented``. Numeric methods and rich comparison methods may\n return this value if they do not implement the operation for the\n operands provided. (The interpreter will then try the reflected\n operation, or some other fallback, depending on the operator.) Its\n truth value is true.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n ``Ellipsis``. It is used to indicate the presence of the ``...``\n syntax in a slice. Its truth value is true.\n\n``numbers.Number``\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n ``numbers.Integral``\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are three types of integers:\n\n Plain integers\n These represent numbers in the range -2147483648 through\n 2147483647. (The range may be larger on machines with a\n larger natural word size, but not smaller.) When the result\n of an operation would fall outside this range, the result is\n normally returned as a long integer (in some cases, the\n exception ``OverflowError`` is raised instead). For the\n purpose of shift and mask operations, integers are assumed to\n have a binary, 2\'s complement notation using 32 or more bits,\n and hiding no bits from the user (i.e., all 4294967296\n different bit patterns correspond to different values).\n\n Long integers\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans\n These represent the truth values False and True. The two\n objects representing the values False and True are the only\n Boolean objects. The Boolean type is a subtype of plain\n integers, and Boolean values behave like the values 0 and 1,\n respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ``"False"`` or\n ``"True"`` are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers and the least surprises when\n switching between the plain and long integer domains. Any\n operation, if it yields a result in the plain integer domain,\n will yield the same result in the long integer domain or when\n using mixed operands. The switch between domains is transparent\n to the programmer.\n\n ``numbers.Real`` (``float``)\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these is\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n ``numbers.Complex``\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number ``z`` can be retrieved through the read-only\n attributes ``z.real`` and ``z.imag``.\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function ``len()`` returns the number of\n items of a sequence. When the length of a sequence is *n*, the\n index set contains the numbers 0, 1, ..., *n*-1. Item *i* of\n sequence *a* is selected by ``a[i]``.\n\n Sequences also support slicing: ``a[i:j]`` selects all items with\n index *k* such that *i* ``<=`` *k* ``<`` *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: ``a[i:j:k]`` selects all items of *a* with index *x*\n where ``x = i + n*k``, *n* ``>=`` ``0`` and *i* ``<=`` *x* ``<``\n *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n The items of a string are characters. There is no separate\n character type; a character is represented by a string of one\n item. Characters represent (at least) 8-bit bytes. The\n built-in functions ``chr()`` and ``ord()`` convert between\n characters and nonnegative integers representing the byte\n values. Bytes with the values 0-127 usually represent the\n corresponding ASCII values, but the interpretation of values\n is up to the program. The string data type is also used to\n represent arrays of bytes, e.g., to hold data read from a\n file.\n\n (On systems whose native character set is not ASCII, strings\n may use EBCDIC in their internal representation, provided the\n functions ``chr()`` and ``ord()`` implement a mapping between\n ASCII and EBCDIC, and string comparison preserves the ASCII\n order. Or perhaps someone can propose a better rule?)\n\n Unicode\n The items of a Unicode object are Unicode code units. A\n Unicode code unit is represented by a Unicode object of one\n item and can hold either a 16-bit or 32-bit value\n representing a Unicode ordinal (the maximum value for the\n ordinal is given in ``sys.maxunicode``, and depends on how\n Python is configured at compile time). Surrogate pairs may\n be present in the Unicode object, and will be reported as two\n separate items. The built-in functions ``unichr()`` and\n ``ord()`` convert between code units and nonnegative integers\n representing the Unicode ordinals as defined in the Unicode\n Standard 3.0. Conversion from and to other encodings are\n possible through the Unicode method ``encode()`` and the\n built-in function ``unicode()``.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and ``del`` (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in ``bytearray()`` constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module ``array`` provides an additional example of\n a mutable sequence type.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function ``len()``\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n ``set()`` constructor and can be modified afterwards by several\n methods, such as ``add()``.\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in ``frozenset()`` constructor. As a frozenset is\n immutable and *hashable*, it can be used again as an element of\n another set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation ``a[k]`` selects the item indexed by\n ``k`` from the mapping ``a``; this can be used in expressions and\n as the target of assignments or ``del`` statements. The built-in\n function ``len()`` returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``) then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the ``{...}``\n notation (see section *Dictionary displays*).\n\n The extension modules ``dbm``, ``gdbm``, and ``bsddb`` provide\n additional examples of mapping types.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +-------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +=========================+=================================+=============+\n | ``func_doc`` | The function\'s documentation | Writable |\n | | string, or ``None`` if | |\n | | unavailable | |\n +-------------------------+---------------------------------+-------------+\n | ``__doc__`` | Another way of spelling | Writable |\n | | ``func_doc`` | |\n +-------------------------+---------------------------------+-------------+\n | ``func_name`` | The function\'s name | Writable |\n +-------------------------+---------------------------------+-------------+\n | ``__name__`` | Another way of spelling | Writable |\n | | ``func_name`` | |\n +-------------------------+---------------------------------+-------------+\n | ``__module__`` | The name of the module the | Writable |\n | | function was defined in, or | |\n | | ``None`` if unavailable. | |\n +-------------------------+---------------------------------+-------------+\n | ``func_defaults`` | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or ``None`` if no arguments | |\n | | have a default value | |\n +-------------------------+---------------------------------+-------------+\n | ``func_code`` | The code object representing | Writable |\n | | the compiled function body. | |\n +-------------------------+---------------------------------+-------------+\n | ``func_globals`` | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +-------------------------+---------------------------------+-------------+\n | ``func_dict`` | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +-------------------------+---------------------------------+-------------+\n | ``func_closure`` | ``None`` or a tuple of cells | Read-only |\n | | that contain bindings for the | |\n | | function\'s free variables. | |\n +-------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Changed in version 2.4: ``func_name`` is now writable.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n User-defined methods\n A user-defined method object combines a class, a class instance\n (or ``None``) and any callable object (normally a user-defined\n function).\n\n Special read-only attributes: ``im_self`` is the class instance\n object, ``im_func`` is the function object; ``im_class`` is the\n class of ``im_self`` for bound methods or the class that asked\n for the method for unbound methods; ``__doc__`` is the method\'s\n documentation (same as ``im_func.__doc__``); ``__name__`` is the\n method name (same as ``im_func.__name__``); ``__module__`` is\n the name of the module the method was defined in, or ``None`` if\n unavailable.\n\n Changed in version 2.2: ``im_self`` used to refer to the class\n that defined the method.\n\n Changed in version 2.6: For 3.0 forward-compatibility,\n ``im_func`` is also available as ``__func__``, and ``im_self``\n as ``__self__``.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object, an unbound\n user-defined method object, or a class method object. When the\n attribute is a user-defined method object, a new method object\n is only created if the class from which it is being retrieved is\n the same as, or a derived class of, the class stored in the\n original method object; otherwise, the original method object is\n used as it is.\n\n When a user-defined method object is created by retrieving a\n user-defined function object from a class, its ``im_self``\n attribute is ``None`` and the method object is said to be\n unbound. When one is created by retrieving a user-defined\n function object from a class via one of its instances, its\n ``im_self`` attribute is the instance, and the method object is\n said to be bound. In either case, the new method\'s ``im_class``\n attribute is the class from which the retrieval takes place, and\n its ``im_func`` attribute is the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the ``im_func``\n attribute of the new instance is not the original method object\n but its ``im_func`` attribute.\n\n When a user-defined method object is created by retrieving a\n class method object from a class or instance, its ``im_self``\n attribute is the class itself (the same as the ``im_class``\n attribute), and its ``im_func`` attribute is the function object\n underlying the class method.\n\n When an unbound user-defined method object is called, the\n underlying function (``im_func``) is called, with the\n restriction that the first argument must be an instance of the\n proper class (``im_class``) or of a derived class thereof.\n\n When a bound user-defined method object is called, the\n underlying function (``im_func``) is called, inserting the class\n instance (``im_self``) in front of the argument list. For\n instance, when ``C`` is a class which contains a definition for\n a function ``f()``, and ``x`` is an instance of ``C``, calling\n ``x.f(1)`` is equivalent to calling ``C.f(x, 1)``.\n\n When a user-defined method object is derived from a class method\n object, the "class instance" stored in ``im_self`` will actually\n be the class itself, so that calling either ``x.f(1)`` or\n ``C.f(1)`` is equivalent to calling ``f(C,1)`` where ``f`` is\n the underlying function.\n\n Note that the transformation from function object to (unbound or\n bound) method object happens each time the attribute is\n retrieved from the class or instance. In some cases, a fruitful\n optimization is to assign the attribute to a local variable and\n call that local variable. Also notice that this transformation\n only happens for user-defined functions; other callable objects\n (and all non-callable objects) are retrieved without\n transformation. It is also important to note that user-defined\n functions which are attributes of a class instance are not\n converted to bound methods; this *only* happens when the\n function is an attribute of the class.\n\n Generator functions\n A function or method which uses the ``yield`` statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s ``next()`` method will cause the function to\n execute until it provides a value using the ``yield`` statement.\n When the function executes a ``return`` statement or falls off\n the end, a ``StopIteration`` exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are ``len()`` and ``math.sin()``\n (``math`` is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: ``__doc__`` is the function\'s documentation\n string, or ``None`` if unavailable; ``__name__`` is the\n function\'s name; ``__self__`` is set to ``None`` (but see the\n next item); ``__module__`` is the name of the module the\n function was defined in or ``None`` if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n ``alist.append()``, assuming *alist* is a list object. In this\n case, the special read-only attribute ``__self__`` is set to the\n object denoted by *alist*.\n\n Class Types\n Class types, or "new-style classes," are callable. These\n objects normally act as factories for new instances of\n themselves, but variations are possible for class types that\n override ``__new__()``. The arguments of the call are passed to\n ``__new__()`` and, in the typical case, to ``__init__()`` to\n initialize the new instance.\n\n Classic Classes\n Class objects are described below. When a class object is\n called, a new class instance (also described below) is created\n and returned. This implies a call to the class\'s ``__init__()``\n method if it has one. Any arguments are passed on to the\n ``__init__()`` method. If there is no ``__init__()`` method,\n the class must be called without arguments.\n\n Class instances\n Class instances are described below. Class instances are\n callable only when the class has a ``__call__()`` method;\n ``x(arguments)`` is a shorthand for ``x.__call__(arguments)``.\n\nModules\n Modules are imported by the ``import`` statement (see section *The\n import statement*). A module object has a namespace implemented by\n a dictionary object (this is the dictionary referenced by the\n func_globals attribute of functions defined in the module).\n Attribute references are translated to lookups in this dictionary,\n e.g., ``m.x`` is equivalent to ``m.__dict__["x"]``. A module object\n does not contain the code object used to initialize the module\n (since it isn\'t needed once the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., ``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.\n\n Special read-only attribute: ``__dict__`` is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: ``__name__`` is the module\'s\n name; ``__doc__`` is the module\'s documentation string, or ``None``\n if unavailable; ``__file__`` is the pathname of the file from which\n the module was loaded, if it was loaded from a file. The\n ``__file__`` attribute is not present for C modules that are\n statically linked into the interpreter; for extension modules\n loaded dynamically from a shared library, it is the pathname of the\n shared library file.\n\nClasses\n Both class types (new-style classes) and class objects (old-\n style/classic classes) are typically created by class definitions\n (see section *Class definitions*). A class has a namespace\n implemented by a dictionary object. Class attribute references are\n translated to lookups in this dictionary, e.g., ``C.x`` is\n translated to ``C.__dict__["x"]`` (although for new-style classes\n in particular there are a number of hooks which allow for other\n means of locating attributes). When the attribute name is not found\n there, the attribute search continues in the base classes. For\n old-style classes, the search is depth-first, left-to-right in the\n order of occurrence in the base class list. New-style classes use\n the more complex C3 method resolution order which behaves correctly\n even in the presence of \'diamond\' inheritance structures where\n there are multiple inheritance paths leading back to a common\n ancestor. Additional details on the C3 MRO used by new-style\n classes can be found in the documentation accompanying the 2.3\n release at http://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class ``C``, say) would yield\n a user-defined function object or an unbound user-defined method\n object whose associated class is either ``C`` or one of its base\n classes, it is transformed into an unbound user-defined method\n object whose ``im_class`` attribute is ``C``. When it would yield a\n class method object, it is transformed into a bound user-defined\n method object whose ``im_class`` and ``im_self`` attributes are\n both ``C``. When it would yield a static method object, it is\n transformed into the object wrapped by the static method object.\n See section *Implementing Descriptors* for another way in which\n attributes retrieved from a class may differ from those actually\n contained in its ``__dict__`` (note that only new-style classes\n support descriptors).\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: ``__name__`` is the class name; ``__module__``\n is the module name in which the class was defined; ``__dict__`` is\n the dictionary containing the class\'s namespace; ``__bases__`` is a\n tuple (possibly empty or a singleton) containing the base classes,\n in the order of their occurrence in the base class list;\n ``__doc__`` is the class\'s documentation string, or None if\n undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object or an unbound user-defined method object whose\n associated class is the class (call it ``C``) of the instance for\n which the attribute reference was initiated or one of its bases, it\n is transformed into a bound user-defined method object whose\n ``im_class`` attribute is ``C`` and whose ``im_self`` attribute is\n the instance. Static method and class method objects are also\n transformed, as if they had been retrieved from class ``C``; see\n above under "Classes". See section *Implementing Descriptors* for\n another way in which attributes of a class retrieved via its\n instances may differ from the objects actually stored in the\n class\'s ``__dict__``. If no class attribute is found, and the\n object\'s class has a ``__getattr__()`` method, that is called to\n satisfy the lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n ``__setattr__()`` or ``__delattr__()`` method, this is called\n instead of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: ``__dict__`` is the attribute dictionary;\n ``__class__`` is the instance\'s class.\n\nFiles\n A file object represents an open file. File objects are created by\n the ``open()`` built-in function, and also by ``os.popen()``,\n ``os.fdopen()``, and the ``makefile()`` method of socket objects\n (and perhaps by other functions or methods provided by extension\n modules). The objects ``sys.stdin``, ``sys.stdout`` and\n ``sys.stderr`` are initialized to file objects corresponding to the\n interpreter\'s standard input, output and error streams. See *File\n Objects* for complete documentation of file objects.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: ``co_name`` gives the function\n name; ``co_argcount`` is the number of positional arguments\n (including arguments with default values); ``co_nlocals`` is the\n number of local variables used by the function (including\n arguments); ``co_varnames`` is a tuple containing the names of\n the local variables (starting with the argument names);\n ``co_cellvars`` is a tuple containing the names of local\n variables that are referenced by nested functions;\n ``co_freevars`` is a tuple containing the names of free\n variables; ``co_code`` is a string representing the sequence of\n bytecode instructions; ``co_consts`` is a tuple containing the\n literals used by the bytecode; ``co_names`` is a tuple\n containing the names used by the bytecode; ``co_filename`` is\n the filename from which the code was compiled;\n ``co_firstlineno`` is the first line number of the function;\n ``co_lnotab`` is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); ``co_stacksize`` is the required stack size\n (including local variables); ``co_flags`` is an integer encoding\n a number of flags for the interpreter.\n\n The following flag bits are defined for ``co_flags``: bit\n ``0x04`` is set if the function uses the ``*arguments`` syntax\n to accept an arbitrary number of positional arguments; bit\n ``0x08`` is set if the function uses the ``**keywords`` syntax\n to accept arbitrary keyword arguments; bit ``0x20`` is set if\n the function is a generator.\n\n Future feature declarations (``from __future__ import\n division``) also use bits in ``co_flags`` to indicate whether a\n code object was compiled with a particular feature enabled: bit\n ``0x2000`` is set if the function was compiled with future\n division enabled; bits ``0x10`` and ``0x1000`` were used in\n earlier versions of Python.\n\n Other bits in ``co_flags`` are reserved for internal use.\n\n If a code object represents a function, the first item in\n ``co_consts`` is the documentation string of the function, or\n ``None`` if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: ``f_back`` is to the previous\n stack frame (towards the caller), or ``None`` if this is the\n bottom stack frame; ``f_code`` is the code object being executed\n in this frame; ``f_locals`` is the dictionary used to look up\n local variables; ``f_globals`` is used for global variables;\n ``f_builtins`` is used for built-in (intrinsic) names;\n ``f_restricted`` is a flag indicating whether the function is\n executing in restricted execution mode; ``f_lasti`` gives the\n precise instruction (this is an index into the bytecode string\n of the code object).\n\n Special writable attributes: ``f_trace``, if not ``None``, is a\n function called at the start of each source code line (this is\n used by the debugger); ``f_exc_type``, ``f_exc_value``,\n ``f_exc_traceback`` represent the last exception raised in the\n parent frame provided another exception was ever raised in the\n current frame (in all other cases they are None); ``f_lineno``\n is the current line number of the frame --- writing to this from\n within a trace function jumps to the given line (only for the\n bottom-most frame). A debugger can implement a Jump command\n (aka Set Next Statement) by writing to f_lineno.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as ``sys.exc_traceback``,\n and also as the third item of the tuple returned by\n ``sys.exc_info()``. The latter is the preferred interface,\n since it works correctly when the program is using multiple\n threads. When the program contains no suitable handler, the\n stack trace is written (nicely formatted) to the standard error\n stream; if the interpreter is interactive, it is also made\n available to the user as ``sys.last_traceback``.\n\n Special read-only attributes: ``tb_next`` is the next level in\n the stack trace (towards the frame where the exception\n occurred), or ``None`` if there is no next level; ``tb_frame``\n points to the execution frame of the current level;\n ``tb_lineno`` gives the line number where the exception\n occurred; ``tb_lasti`` indicates the precise instruction. The\n line number and last instruction in the traceback may differ\n from the line number of its frame object if the exception\n occurred in a ``try`` statement with no matching except clause\n or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices when *extended slice\n syntax* is used. This is a slice using two colons, or multiple\n slices or ellipses separated by commas, e.g., ``a[i:j:step]``,\n ``a[i:j, k:l]``, or ``a[..., i:j]``. They are also created by\n the built-in ``slice()`` function.\n\n Special read-only attributes: ``start`` is the lower bound;\n ``stop`` is the upper bound; ``step`` is the step value; each is\n ``None`` if omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the extended slice that the slice\n object would describe if applied to a sequence of *length*\n items. It returns a tuple of three integers; respectively\n these are the *start* and *stop* indices and the *step* or\n stride length of the slice. Missing or out-of-bounds indices\n are handled in a manner consistent with regular slices.\n\n New in version 2.3.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n ``staticmethod()`` constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in ``classmethod()`` constructor.\n',
+ 'sequence-types': "\nEmulating container types\n*************************\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python's standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping's keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn't define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don't define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n",
+ 'shifting': '\nShifting operations\n*******************\n\nThe shifting operations have lower priority than the arithmetic\noperations:\n\n shift_expr ::= a_expr | shift_expr ( "<<" | ">>" ) a_expr\n\nThese operators accept integers as arguments. They shift the first\nargument to the left or right by the number of bits given by the\nsecond argument.\n\nA right shift by *n* bits is defined as division by ``pow(2,n)``. A\nleft shift by *n* bits is defined as multiplication with ``pow(2,n)``.\n\nNote: In the current implementation, the right-hand operand is required to\n be at most ``sys.maxsize``. If the right-hand operand is larger\n than ``sys.maxsize`` an ``OverflowError`` exception is raised.\n',
+ 'slicings': '\nSlicings\n********\n\nA slicing selects a range of items in a sequence object (e.g., a\nstring, tuple or list). Slicings may be used as expressions or as\ntargets in assignment or ``del`` statements. The syntax for a\nslicing:\n\n slicing ::= primary "[" slice_list "]"\n slice_list ::= slice_item ("," slice_item)* [","]\n slice_item ::= expression | proper_slice\n proper_slice ::= [lower_bound] ":" [upper_bound] [ ":" [stride] ]\n lower_bound ::= expression\n upper_bound ::= expression\n stride ::= expression\n\nThere is ambiguity in the formal syntax here: anything that looks like\nan expression list also looks like a slice list, so any subscription\ncan be interpreted as a slicing. Rather than further complicating the\nsyntax, this is disambiguated by defining that in this case the\ninterpretation as a subscription takes priority over the\ninterpretation as a slicing (this is the case if the slice list\ncontains no proper slice).\n\nThe semantics for a slicing are as follows. The primary must evaluate\nto a mapping object, and it is indexed (using the same\n``__getitem__()`` method as normal subscription) with a key that is\nconstructed from the slice list, as follows. If the slice list\ncontains at least one comma, the key is a tuple containing the\nconversion of the slice items; otherwise, the conversion of the lone\nslice item is the key. The conversion of a slice item that is an\nexpression is that expression. The conversion of a proper slice is a\nslice object (see section *The standard type hierarchy*) whose\n``start``, ``stop`` and ``step`` attributes are the values of the\nexpressions given as lower bound, upper bound and stride,\nrespectively, substituting ``None`` for missing expressions.\n',
+ 'specialattrs': '\nSpecial Attributes\n******************\n\nThe implementation adds a few special read-only attributes to several\nobject types, where they are relevant. Some of these are not reported\nby the ``dir()`` built-in function.\n\nobject.__dict__\n\n A dictionary or other mapping object used to store an object\'s\n (writable) attributes.\n\ninstance.__class__\n\n The class to which a class instance belongs.\n\nclass.__bases__\n\n The tuple of base classes of a class object.\n\nclass.__name__\n\n The name of the class or type.\n\nclass.__mro__\n\n This attribute is a tuple of classes that are considered when\n looking for base classes during method resolution.\n\nclass.mro()\n\n This method can be overridden by a metaclass to customize the\n method resolution order for its instances. It is called at class\n instantiation, and its result is stored in ``__mro__``.\n\nclass.__subclasses__()\n\n Each class keeps a list of weak references to its immediate\n subclasses. This method returns a list of all those references\n still alive. Example:\n\n >>> int.__subclasses__()\n [<class \'bool\'>]\n\n-[ Footnotes ]-\n\n[1] Additional information on these special methods may be found in\n the Python Reference Manual (*Basic customization*).\n\n[2] As a consequence, the list ``[1, 2]`` is considered equal to\n ``[1.0, 2.0]``, and similarly for tuples.\n\n[3] They must have since the parser can\'t tell the type of the\n operands.\n\n[4] Cased characters are those with general category property being\n one of "Lu" (Letter, uppercase), "Ll" (Letter, lowercase), or "Lt"\n (Letter, titlecase).\n\n[5] To format only a tuple you should therefore provide a singleton\n tuple whose only element is the tuple to be formatted.\n',
+ 'specialnames': '\nSpecial method names\n********************\n\nA class can implement certain operations that are invoked by special\nsyntax (such as arithmetic operations or subscripting and slicing) by\ndefining methods with special names. This is Python\'s approach to\n*operator overloading*, allowing classes to define their own behavior\nwith respect to language operators. For instance, if a class defines\na method named ``__getitem__()``, and ``x`` is an instance of this\nclass, then ``x[i]`` is roughly equivalent to ``type(x).__getitem__(x,\ni)``. Except where mentioned, attempts to execute an operation raise\nan exception when no appropriate method is defined (typically\n``AttributeError`` or ``TypeError``).\n\nWhen implementing a class that emulates any built-in type, it is\nimportant that the emulation only be implemented to the degree that it\nmakes sense for the object being modelled. For example, some\nsequences may work well with retrieval of individual elements, but\nextracting a slice may not make sense. (One example of this is the\n``NodeList`` interface in the W3C\'s Document Object Model.)\n\n\nBasic customization\n===================\n\nobject.__new__(cls[, ...])\n\n Called to create a new instance of class *cls*. ``__new__()`` is a\n static method (special-cased so you need not declare it as such)\n that takes the class of which an instance was requested as its\n first argument. The remaining arguments are those passed to the\n object constructor expression (the call to the class). The return\n value of ``__new__()`` should be the new object instance (usually\n an instance of *cls*).\n\n Typical implementations create a new instance of the class by\n invoking the superclass\'s ``__new__()`` method using\n ``super(currentclass, cls).__new__(cls[, ...])`` with appropriate\n arguments and then modifying the newly-created instance as\n necessary before returning it.\n\n If ``__new__()`` returns an instance of *cls*, then the new\n instance\'s ``__init__()`` method will be invoked like\n ``__init__(self[, ...])``, where *self* is the new instance and the\n remaining arguments are the same as were passed to ``__new__()``.\n\n If ``__new__()`` does not return an instance of *cls*, then the new\n instance\'s ``__init__()`` method will not be invoked.\n\n ``__new__()`` is intended mainly to allow subclasses of immutable\n types (like int, str, or tuple) to customize instance creation. It\n is also commonly overridden in custom metaclasses in order to\n customize class creation.\n\nobject.__init__(self[, ...])\n\n Called when the instance is created. The arguments are those\n passed to the class constructor expression. If a base class has an\n ``__init__()`` method, the derived class\'s ``__init__()`` method,\n if any, must explicitly call it to ensure proper initialization of\n the base class part of the instance; for example:\n ``BaseClass.__init__(self, [args...])``. As a special constraint\n on constructors, no value may be returned; doing so will cause a\n ``TypeError`` to be raised at runtime.\n\nobject.__del__(self)\n\n Called when the instance is about to be destroyed. This is also\n called a destructor. If a base class has a ``__del__()`` method,\n the derived class\'s ``__del__()`` method, if any, must explicitly\n call it to ensure proper deletion of the base class part of the\n instance. Note that it is possible (though not recommended!) for\n the ``__del__()`` method to postpone destruction of the instance by\n creating a new reference to it. It may then be called at a later\n time when this new reference is deleted. It is not guaranteed that\n ``__del__()`` methods are called for objects that still exist when\n the interpreter exits.\n\n Note: ``del x`` doesn\'t directly call ``x.__del__()`` --- the former\n decrements the reference count for ``x`` by one, and the latter\n is only called when ``x``\'s reference count reaches zero. Some\n common situations that may prevent the reference count of an\n object from going to zero include: circular references between\n objects (e.g., a doubly-linked list or a tree data structure with\n parent and child pointers); a reference to the object on the\n stack frame of a function that caught an exception (the traceback\n stored in ``sys.exc_info()[2]`` keeps the stack frame alive); or\n a reference to the object on the stack frame that raised an\n unhandled exception in interactive mode (the traceback stored in\n ``sys.last_traceback`` keeps the stack frame alive). The first\n situation can only be remedied by explicitly breaking the cycles;\n the latter two situations can be resolved by storing ``None`` in\n ``sys.last_traceback``. Circular references which are garbage are\n detected when the option cycle detector is enabled (it\'s on by\n default), but can only be cleaned up if there are no Python-\n level ``__del__()`` methods involved. Refer to the documentation\n for the ``gc`` module for more information about how\n ``__del__()`` methods are handled by the cycle detector,\n particularly the description of the ``garbage`` value.\n\n Warning: Due to the precarious circumstances under which ``__del__()``\n methods are invoked, exceptions that occur during their execution\n are ignored, and a warning is printed to ``sys.stderr`` instead.\n Also, when ``__del__()`` is invoked in response to a module being\n deleted (e.g., when execution of the program is done), other\n globals referenced by the ``__del__()`` method may already have\n been deleted or in the process of being torn down (e.g. the\n import machinery shutting down). For this reason, ``__del__()``\n methods should do the absolute minimum needed to maintain\n external invariants. Starting with version 1.5, Python\n guarantees that globals whose name begins with a single\n underscore are deleted from their module before other globals are\n deleted; if no other references to such globals exist, this may\n help in assuring that imported modules are still available at the\n time when the ``__del__()`` method is called.\n\nobject.__repr__(self)\n\n Called by the ``repr()`` built-in function to compute the\n "official" string representation of an object. If at all possible,\n this should look like a valid Python expression that could be used\n to recreate an object with the same value (given an appropriate\n environment). If this is not possible, a string of the form\n ``<...some useful description...>`` should be returned. The return\n value must be a string object. If a class defines ``__repr__()``\n but not ``__str__()``, then ``__repr__()`` is also used when an\n "informal" string representation of instances of that class is\n required.\n\n This is typically used for debugging, so it is important that the\n representation is information-rich and unambiguous.\n\nobject.__str__(self)\n\n Called by the ``str()`` built-in function and by the ``print()``\n function to compute the "informal" string representation of an\n object. This differs from ``__repr__()`` in that it does not have\n to be a valid Python expression: a more convenient or concise\n representation may be used instead. The return value must be a\n string object.\n\nobject.__bytes__(self)\n\n Called by ``bytes()`` to compute a byte-string representation of an\n object. This should return a ``bytes`` object.\n\nobject.__format__(self, format_spec)\n\n Called by the ``format()`` built-in function (and by extension, the\n ``format()`` method of class ``str``) to produce a "formatted"\n string representation of an object. The ``format_spec`` argument is\n a string that contains a description of the formatting options\n desired. The interpretation of the ``format_spec`` argument is up\n to the type implementing ``__format__()``, however most classes\n will either delegate formatting to one of the built-in types, or\n use a similar formatting option syntax.\n\n See *Format Specification Mini-Language* for a description of the\n standard formatting syntax.\n\n The return value must be a string object.\n\nobject.__lt__(self, other)\nobject.__le__(self, other)\nobject.__eq__(self, other)\nobject.__ne__(self, other)\nobject.__gt__(self, other)\nobject.__ge__(self, other)\n\n These are the so-called "rich comparison" methods. The\n correspondence between operator symbols and method names is as\n follows: ``x<y`` calls ``x.__lt__(y)``, ``x<=y`` calls\n ``x.__le__(y)``, ``x==y`` calls ``x.__eq__(y)``, ``x!=y`` calls\n ``x.__ne__(y)``, ``x>y`` calls ``x.__gt__(y)``, and ``x>=y`` calls\n ``x.__ge__(y)``.\n\n A rich comparison method may return the singleton\n ``NotImplemented`` if it does not implement the operation for a\n given pair of arguments. By convention, ``False`` and ``True`` are\n returned for a successful comparison. However, these methods can\n return any value, so if the comparison operator is used in a\n Boolean context (e.g., in the condition of an ``if`` statement),\n Python will call ``bool()`` on the value to determine if the result\n is true or false.\n\n There are no implied relationships among the comparison operators.\n The truth of ``x==y`` does not imply that ``x!=y`` is false.\n Accordingly, when defining ``__eq__()``, one should also define\n ``__ne__()`` so that the operators will behave as expected. See\n the paragraph on ``__hash__()`` for some important notes on\n creating *hashable* objects which support custom comparison\n operations and are usable as dictionary keys.\n\n There are no swapped-argument versions of these methods (to be used\n when the left argument does not support the operation but the right\n argument does); rather, ``__lt__()`` and ``__gt__()`` are each\n other\'s reflection, ``__le__()`` and ``__ge__()`` are each other\'s\n reflection, and ``__eq__()`` and ``__ne__()`` are their own\n reflection.\n\n Arguments to rich comparison methods are never coerced.\n\n To automatically generate ordering operations from a single root\n operation, see ``functools.total_ordering()``.\n\nobject.__hash__(self)\n\n Called by built-in function ``hash()`` and for operations on\n members of hashed collections including ``set``, ``frozenset``, and\n ``dict``. ``__hash__()`` should return an integer. The only\n required property is that objects which compare equal have the same\n hash value; it is advised to somehow mix together (e.g. using\n exclusive or) the hash values for the components of the object that\n also play a part in comparison of objects.\n\n If a class does not define an ``__eq__()`` method it should not\n define a ``__hash__()`` operation either; if it defines\n ``__eq__()`` but not ``__hash__()``, its instances will not be\n usable as items in hashable collections. If a class defines\n mutable objects and implements an ``__eq__()`` method, it should\n not implement ``__hash__()``, since the implementation of hashable\n collections requires that a key\'s hash value is immutable (if the\n object\'s hash value changes, it will be in the wrong hash bucket).\n\n User-defined classes have ``__eq__()`` and ``__hash__()`` methods\n by default; with them, all objects compare unequal (except with\n themselves) and ``x.__hash__()`` returns ``id(x)``.\n\n Classes which inherit a ``__hash__()`` method from a parent class\n but change the meaning of ``__eq__()`` such that the hash value\n returned is no longer appropriate (e.g. by switching to a value-\n based concept of equality instead of the default identity based\n equality) can explicitly flag themselves as being unhashable by\n setting ``__hash__ = None`` in the class definition. Doing so means\n that not only will instances of the class raise an appropriate\n ``TypeError`` when a program attempts to retrieve their hash value,\n but they will also be correctly identified as unhashable when\n checking ``isinstance(obj, collections.Hashable)`` (unlike classes\n which define their own ``__hash__()`` to explicitly raise\n ``TypeError``).\n\n If a class that overrides ``__eq__()`` needs to retain the\n implementation of ``__hash__()`` from a parent class, the\n interpreter must be told this explicitly by setting ``__hash__ =\n <ParentClass>.__hash__``. Otherwise the inheritance of\n ``__hash__()`` will be blocked, just as if ``__hash__`` had been\n explicitly set to ``None``.\n\n See also the *-R* command-line option.\n\nobject.__bool__(self)\n\n Called to implement truth value testing and the built-in operation\n ``bool()``; should return ``False`` or ``True``. When this method\n is not defined, ``__len__()`` is called, if it is defined, and the\n object is considered true if its result is nonzero. If a class\n defines neither ``__len__()`` nor ``__bool__()``, all its instances\n are considered true.\n\n\nCustomizing attribute access\n============================\n\nThe following methods can be defined to customize the meaning of\nattribute access (use of, assignment to, or deletion of ``x.name``)\nfor class instances.\n\nobject.__getattr__(self, name)\n\n Called when an attribute lookup has not found the attribute in the\n usual places (i.e. it is not an instance attribute nor is it found\n in the class tree for ``self``). ``name`` is the attribute name.\n This method should return the (computed) attribute value or raise\n an ``AttributeError`` exception.\n\n Note that if the attribute is found through the normal mechanism,\n ``__getattr__()`` is not called. (This is an intentional asymmetry\n between ``__getattr__()`` and ``__setattr__()``.) This is done both\n for efficiency reasons and because otherwise ``__getattr__()``\n would have no way to access other attributes of the instance. Note\n that at least for instance variables, you can fake total control by\n not inserting any values in the instance attribute dictionary (but\n instead inserting them in another object). See the\n ``__getattribute__()`` method below for a way to actually get total\n control over attribute access.\n\nobject.__getattribute__(self, name)\n\n Called unconditionally to implement attribute accesses for\n instances of the class. If the class also defines\n ``__getattr__()``, the latter will not be called unless\n ``__getattribute__()`` either calls it explicitly or raises an\n ``AttributeError``. This method should return the (computed)\n attribute value or raise an ``AttributeError`` exception. In order\n to avoid infinite recursion in this method, its implementation\n should always call the base class method with the same name to\n access any attributes it needs, for example,\n ``object.__getattribute__(self, name)``.\n\n Note: This method may still be bypassed when looking up special methods\n as the result of implicit invocation via language syntax or\n built-in functions. See *Special method lookup*.\n\nobject.__setattr__(self, name, value)\n\n Called when an attribute assignment is attempted. This is called\n instead of the normal mechanism (i.e. store the value in the\n instance dictionary). *name* is the attribute name, *value* is the\n value to be assigned to it.\n\n If ``__setattr__()`` wants to assign to an instance attribute, it\n should call the base class method with the same name, for example,\n ``object.__setattr__(self, name, value)``.\n\nobject.__delattr__(self, name)\n\n Like ``__setattr__()`` but for attribute deletion instead of\n assignment. This should only be implemented if ``del obj.name`` is\n meaningful for the object.\n\nobject.__dir__(self)\n\n Called when ``dir()`` is called on the object. A list must be\n returned.\n\n\nImplementing Descriptors\n------------------------\n\nThe following methods only apply when an instance of the class\ncontaining the method (a so-called *descriptor* class) appears in an\n*owner* class (the descriptor must be in either the owner\'s class\ndictionary or in the class dictionary for one of its parents). In the\nexamples below, "the attribute" refers to the attribute whose name is\nthe key of the property in the owner class\' ``__dict__``.\n\nobject.__get__(self, instance, owner)\n\n Called to get the attribute of the owner class (class attribute\n access) or of an instance of that class (instance attribute\n access). *owner* is always the owner class, while *instance* is the\n instance that the attribute was accessed through, or ``None`` when\n the attribute is accessed through the *owner*. This method should\n return the (computed) attribute value or raise an\n ``AttributeError`` exception.\n\nobject.__set__(self, instance, value)\n\n Called to set the attribute on an instance *instance* of the owner\n class to a new value, *value*.\n\nobject.__delete__(self, instance)\n\n Called to delete the attribute on an instance *instance* of the\n owner class.\n\n\nInvoking Descriptors\n--------------------\n\nIn general, a descriptor is an object attribute with "binding\nbehavior", one whose attribute access has been overridden by methods\nin the descriptor protocol: ``__get__()``, ``__set__()``, and\n``__delete__()``. If any of those methods are defined for an object,\nit is said to be a descriptor.\n\nThe default behavior for attribute access is to get, set, or delete\nthe attribute from an object\'s dictionary. For instance, ``a.x`` has a\nlookup chain starting with ``a.__dict__[\'x\']``, then\n``type(a).__dict__[\'x\']``, and continuing through the base classes of\n``type(a)`` excluding metaclasses.\n\nHowever, if the looked-up value is an object defining one of the\ndescriptor methods, then Python may override the default behavior and\ninvoke the descriptor method instead. Where this occurs in the\nprecedence chain depends on which descriptor methods were defined and\nhow they were called.\n\nThe starting point for descriptor invocation is a binding, ``a.x``.\nHow the arguments are assembled depends on ``a``:\n\nDirect Call\n The simplest and least common call is when user code directly\n invokes a descriptor method: ``x.__get__(a)``.\n\nInstance Binding\n If binding to an object instance, ``a.x`` is transformed into the\n call: ``type(a).__dict__[\'x\'].__get__(a, type(a))``.\n\nClass Binding\n If binding to a class, ``A.x`` is transformed into the call:\n ``A.__dict__[\'x\'].__get__(None, A)``.\n\nSuper Binding\n If ``a`` is an instance of ``super``, then the binding ``super(B,\n obj).m()`` searches ``obj.__class__.__mro__`` for the base class\n ``A`` immediately preceding ``B`` and then invokes the descriptor\n with the call: ``A.__dict__[\'m\'].__get__(obj, obj.__class__)``.\n\nFor instance bindings, the precedence of descriptor invocation depends\non the which descriptor methods are defined. A descriptor can define\nany combination of ``__get__()``, ``__set__()`` and ``__delete__()``.\nIf it does not define ``__get__()``, then accessing the attribute will\nreturn the descriptor object itself unless there is a value in the\nobject\'s instance dictionary. If the descriptor defines ``__set__()``\nand/or ``__delete__()``, it is a data descriptor; if it defines\nneither, it is a non-data descriptor. Normally, data descriptors\ndefine both ``__get__()`` and ``__set__()``, while non-data\ndescriptors have just the ``__get__()`` method. Data descriptors with\n``__set__()`` and ``__get__()`` defined always override a redefinition\nin an instance dictionary. In contrast, non-data descriptors can be\noverridden by instances.\n\nPython methods (including ``staticmethod()`` and ``classmethod()``)\nare implemented as non-data descriptors. Accordingly, instances can\nredefine and override methods. This allows individual instances to\nacquire behaviors that differ from other instances of the same class.\n\nThe ``property()`` function is implemented as a data descriptor.\nAccordingly, instances cannot override the behavior of a property.\n\n\n__slots__\n---------\n\nBy default, instances of classes have a dictionary for attribute\nstorage. This wastes space for objects having very few instance\nvariables. The space consumption can become acute when creating large\nnumbers of instances.\n\nThe default can be overridden by defining *__slots__* in a class\ndefinition. The *__slots__* declaration takes a sequence of instance\nvariables and reserves just enough space in each instance to hold a\nvalue for each variable. Space is saved because *__dict__* is not\ncreated for each instance.\n\nobject.__slots__\n\n This class variable can be assigned a string, iterable, or sequence\n of strings with variable names used by instances. If defined in a\n class, *__slots__* reserves space for the declared variables and\n prevents the automatic creation of *__dict__* and *__weakref__* for\n each instance.\n\n\nNotes on using *__slots__*\n~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n* When inheriting from a class without *__slots__*, the *__dict__*\n attribute of that class will always be accessible, so a *__slots__*\n definition in the subclass is meaningless.\n\n* Without a *__dict__* variable, instances cannot be assigned new\n variables not listed in the *__slots__* definition. Attempts to\n assign to an unlisted variable name raises ``AttributeError``. If\n dynamic assignment of new variables is desired, then add\n ``\'__dict__\'`` to the sequence of strings in the *__slots__*\n declaration.\n\n* Without a *__weakref__* variable for each instance, classes defining\n *__slots__* do not support weak references to its instances. If weak\n reference support is needed, then add ``\'__weakref__\'`` to the\n sequence of strings in the *__slots__* declaration.\n\n* *__slots__* are implemented at the class level by creating\n descriptors (*Implementing Descriptors*) for each variable name. As\n a result, class attributes cannot be used to set default values for\n instance variables defined by *__slots__*; otherwise, the class\n attribute would overwrite the descriptor assignment.\n\n* The action of a *__slots__* declaration is limited to the class\n where it is defined. As a result, subclasses will have a *__dict__*\n unless they also define *__slots__* (which must only contain names\n of any *additional* slots).\n\n* If a class defines a slot also defined in a base class, the instance\n variable defined by the base class slot is inaccessible (except by\n retrieving its descriptor directly from the base class). This\n renders the meaning of the program undefined. In the future, a\n check may be added to prevent this.\n\n* Nonempty *__slots__* does not work for classes derived from\n "variable-length" built-in types such as ``int``, ``str`` and\n ``tuple``.\n\n* Any non-string iterable may be assigned to *__slots__*. Mappings may\n also be used; however, in the future, special meaning may be\n assigned to the values corresponding to each key.\n\n* *__class__* assignment works only if both classes have the same\n *__slots__*.\n\n\nCustomizing class creation\n==========================\n\nBy default, classes are constructed using ``type()``. A class\ndefinition is read into a separate namespace and the value of class\nname is bound to the result of ``type(name, bases, dict)``.\n\nWhen the class definition is read, if a callable ``metaclass`` keyword\nargument is passed after the bases in the class definition, the\ncallable given will be called instead of ``type()``. If other keyword\narguments are passed, they will also be passed to the metaclass. This\nallows classes or functions to be written which monitor or alter the\nclass creation process:\n\n* Modifying the class dictionary prior to the class being created.\n\n* Returning an instance of another class -- essentially performing the\n role of a factory function.\n\nThese steps will have to be performed in the metaclass\'s ``__new__()``\nmethod -- ``type.__new__()`` can then be called from this method to\ncreate a class with different properties. This example adds a new\nelement to the class dictionary before creating the class:\n\n class metacls(type):\n def __new__(mcs, name, bases, dict):\n dict[\'foo\'] = \'metacls was here\'\n return type.__new__(mcs, name, bases, dict)\n\nYou can of course also override other class methods (or add new\nmethods); for example defining a custom ``__call__()`` method in the\nmetaclass allows custom behavior when the class is called, e.g. not\nalways creating a new instance.\n\nIf the metaclass has a ``__prepare__()`` attribute (usually\nimplemented as a class or static method), it is called before the\nclass body is evaluated with the name of the class and a tuple of its\nbases for arguments. It should return an object that supports the\nmapping interface that will be used to store the namespace of the\nclass. The default is a plain dictionary. This could be used, for\nexample, to keep track of the order that class attributes are declared\nin by returning an ordered dictionary.\n\nThe appropriate metaclass is determined by the following precedence\nrules:\n\n* If the ``metaclass`` keyword argument is passed with the bases, it\n is used.\n\n* Otherwise, if there is at least one base class, its metaclass is\n used.\n\n* Otherwise, the default metaclass (``type``) is used.\n\nThe potential uses for metaclasses are boundless. Some ideas that have\nbeen explored including logging, interface checking, automatic\ndelegation, automatic property creation, proxies, frameworks, and\nautomatic resource locking/synchronization.\n\nHere is an example of a metaclass that uses an\n``collections.OrderedDict`` to remember the order that class members\nwere defined:\n\n class OrderedClass(type):\n\n @classmethod\n def __prepare__(metacls, name, bases, **kwds):\n return collections.OrderedDict()\n\n def __new__(cls, name, bases, classdict):\n result = type.__new__(cls, name, bases, dict(classdict))\n result.members = tuple(classdict)\n return result\n\n class A(metaclass=OrderedClass):\n def one(self): pass\n def two(self): pass\n def three(self): pass\n def four(self): pass\n\n >>> A.members\n (\'__module__\', \'one\', \'two\', \'three\', \'four\')\n\nWhen the class definition for *A* gets executed, the process begins\nwith calling the metaclass\'s ``__prepare__()`` method which returns an\nempty ``collections.OrderedDict``. That mapping records the methods\nand attributes of *A* as they are defined within the body of the class\nstatement. Once those definitions are executed, the ordered dictionary\nis fully populated and the metaclass\'s ``__new__()`` method gets\ninvoked. That method builds the new type and it saves the ordered\ndictionary keys in an attribute called ``members``.\n\n\nCustomizing instance and subclass checks\n========================================\n\nThe following methods are used to override the default behavior of the\n``isinstance()`` and ``issubclass()`` built-in functions.\n\nIn particular, the metaclass ``abc.ABCMeta`` implements these methods\nin order to allow the addition of Abstract Base Classes (ABCs) as\n"virtual base classes" to any class or type (including built-in\ntypes), including other ABCs.\n\nclass.__instancecheck__(self, instance)\n\n Return true if *instance* should be considered a (direct or\n indirect) instance of *class*. If defined, called to implement\n ``isinstance(instance, class)``.\n\nclass.__subclasscheck__(self, subclass)\n\n Return true if *subclass* should be considered a (direct or\n indirect) subclass of *class*. If defined, called to implement\n ``issubclass(subclass, class)``.\n\nNote that these methods are looked up on the type (metaclass) of a\nclass. They cannot be defined as class methods in the actual class.\nThis is consistent with the lookup of special methods that are called\non instances, only in this case the instance is itself a class.\n\nSee also:\n\n **PEP 3119** - Introducing Abstract Base Classes\n Includes the specification for customizing ``isinstance()`` and\n ``issubclass()`` behavior through ``__instancecheck__()`` and\n ``__subclasscheck__()``, with motivation for this functionality\n in the context of adding Abstract Base Classes (see the ``abc``\n module) to the language.\n\n\nEmulating callable objects\n==========================\n\nobject.__call__(self[, args...])\n\n Called when the instance is "called" as a function; if this method\n is defined, ``x(arg1, arg2, ...)`` is a shorthand for\n ``x.__call__(arg1, arg2, ...)``.\n\n\nEmulating container types\n=========================\n\nThe following methods can be defined to implement container objects.\nContainers usually are sequences (such as lists or tuples) or mappings\n(like dictionaries), but can represent other containers as well. The\nfirst set of methods is used either to emulate a sequence or to\nemulate a mapping; the difference is that for a sequence, the\nallowable keys should be the integers *k* for which ``0 <= k < N``\nwhere *N* is the length of the sequence, or slice objects, which\ndefine a range of items. It is also recommended that mappings provide\nthe methods ``keys()``, ``values()``, ``items()``, ``get()``,\n``clear()``, ``setdefault()``, ``pop()``, ``popitem()``, ``copy()``,\nand ``update()`` behaving similar to those for Python\'s standard\ndictionary objects. The ``collections`` module provides a\n``MutableMapping`` abstract base class to help create those methods\nfrom a base set of ``__getitem__()``, ``__setitem__()``,\n``__delitem__()``, and ``keys()``. Mutable sequences should provide\nmethods ``append()``, ``count()``, ``index()``, ``extend()``,\n``insert()``, ``pop()``, ``remove()``, ``reverse()`` and ``sort()``,\nlike Python standard list objects. Finally, sequence types should\nimplement addition (meaning concatenation) and multiplication (meaning\nrepetition) by defining the methods ``__add__()``, ``__radd__()``,\n``__iadd__()``, ``__mul__()``, ``__rmul__()`` and ``__imul__()``\ndescribed below; they should not define other numerical operators. It\nis recommended that both mappings and sequences implement the\n``__contains__()`` method to allow efficient use of the ``in``\noperator; for mappings, ``in`` should search the mapping\'s keys; for\nsequences, it should search through the values. It is further\nrecommended that both mappings and sequences implement the\n``__iter__()`` method to allow efficient iteration through the\ncontainer; for mappings, ``__iter__()`` should be the same as\n``keys()``; for sequences, it should iterate through the values.\n\nobject.__len__(self)\n\n Called to implement the built-in function ``len()``. Should return\n the length of the object, an integer ``>=`` 0. Also, an object\n that doesn\'t define a ``__bool__()`` method and whose ``__len__()``\n method returns zero is considered to be false in a Boolean context.\n\nNote: Slicing is done exclusively with the following three methods. A\n call like\n\n a[1:2] = b\n\n is translated to\n\n a[slice(1, 2, None)] = b\n\n and so forth. Missing slice items are always filled in with\n ``None``.\n\nobject.__getitem__(self, key)\n\n Called to implement evaluation of ``self[key]``. For sequence\n types, the accepted keys should be integers and slice objects.\n Note that the special interpretation of negative indexes (if the\n class wishes to emulate a sequence type) is up to the\n ``__getitem__()`` method. If *key* is of an inappropriate type,\n ``TypeError`` may be raised; if of a value outside the set of\n indexes for the sequence (after any special interpretation of\n negative values), ``IndexError`` should be raised. For mapping\n types, if *key* is missing (not in the container), ``KeyError``\n should be raised.\n\n Note: ``for`` loops expect that an ``IndexError`` will be raised for\n illegal indexes to allow proper detection of the end of the\n sequence.\n\nobject.__setitem__(self, key, value)\n\n Called to implement assignment to ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support changes to the values for keys, or if new keys\n can be added, or for sequences if elements can be replaced. The\n same exceptions should be raised for improper *key* values as for\n the ``__getitem__()`` method.\n\nobject.__delitem__(self, key)\n\n Called to implement deletion of ``self[key]``. Same note as for\n ``__getitem__()``. This should only be implemented for mappings if\n the objects support removal of keys, or for sequences if elements\n can be removed from the sequence. The same exceptions should be\n raised for improper *key* values as for the ``__getitem__()``\n method.\n\nobject.__iter__(self)\n\n This method is called when an iterator is required for a container.\n This method should return a new iterator object that can iterate\n over all the objects in the container. For mappings, it should\n iterate over the keys of the container, and should also be made\n available as the method ``keys()``.\n\n Iterator objects also need to implement this method; they are\n required to return themselves. For more information on iterator\n objects, see *Iterator Types*.\n\nobject.__reversed__(self)\n\n Called (if present) by the ``reversed()`` built-in to implement\n reverse iteration. It should return a new iterator object that\n iterates over all the objects in the container in reverse order.\n\n If the ``__reversed__()`` method is not provided, the\n ``reversed()`` built-in will fall back to using the sequence\n protocol (``__len__()`` and ``__getitem__()``). Objects that\n support the sequence protocol should only provide\n ``__reversed__()`` if they can provide an implementation that is\n more efficient than the one provided by ``reversed()``.\n\nThe membership test operators (``in`` and ``not in``) are normally\nimplemented as an iteration through a sequence. However, container\nobjects can supply the following special method with a more efficient\nimplementation, which also does not require the object be a sequence.\n\nobject.__contains__(self, item)\n\n Called to implement membership test operators. Should return true\n if *item* is in *self*, false otherwise. For mapping objects, this\n should consider the keys of the mapping rather than the values or\n the key-item pairs.\n\n For objects that don\'t define ``__contains__()``, the membership\n test first tries iteration via ``__iter__()``, then the old\n sequence iteration protocol via ``__getitem__()``, see *this\n section in the language reference*.\n\n\nEmulating numeric types\n=======================\n\nThe following methods can be defined to emulate numeric objects.\nMethods corresponding to operations that are not supported by the\nparticular kind of number implemented (e.g., bitwise operations for\nnon-integral numbers) should be left undefined.\n\nobject.__add__(self, other)\nobject.__sub__(self, other)\nobject.__mul__(self, other)\nobject.__truediv__(self, other)\nobject.__floordiv__(self, other)\nobject.__mod__(self, other)\nobject.__divmod__(self, other)\nobject.__pow__(self, other[, modulo])\nobject.__lshift__(self, other)\nobject.__rshift__(self, other)\nobject.__and__(self, other)\nobject.__xor__(self, other)\nobject.__or__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``). For instance, to evaluate the expression ``x + y``, where\n *x* is an instance of a class that has an ``__add__()`` method,\n ``x.__add__(y)`` is called. The ``__divmod__()`` method should be\n the equivalent to using ``__floordiv__()`` and ``__mod__()``; it\n should not be related to ``__truediv__()``. Note that\n ``__pow__()`` should be defined to accept an optional third\n argument if the ternary version of the built-in ``pow()`` function\n is to be supported.\n\n If one of those methods does not support the operation with the\n supplied arguments, it should return ``NotImplemented``.\n\nobject.__radd__(self, other)\nobject.__rsub__(self, other)\nobject.__rmul__(self, other)\nobject.__rtruediv__(self, other)\nobject.__rfloordiv__(self, other)\nobject.__rmod__(self, other)\nobject.__rdivmod__(self, other)\nobject.__rpow__(self, other)\nobject.__rlshift__(self, other)\nobject.__rrshift__(self, other)\nobject.__rand__(self, other)\nobject.__rxor__(self, other)\nobject.__ror__(self, other)\n\n These methods are called to implement the binary arithmetic\n operations (``+``, ``-``, ``*``, ``/``, ``//``, ``%``,\n ``divmod()``, ``pow()``, ``**``, ``<<``, ``>>``, ``&``, ``^``,\n ``|``) with reflected (swapped) operands. These functions are only\n called if the left operand does not support the corresponding\n operation and the operands are of different types. [2] For\n instance, to evaluate the expression ``x - y``, where *y* is an\n instance of a class that has an ``__rsub__()`` method,\n ``y.__rsub__(x)`` is called if ``x.__sub__(y)`` returns\n *NotImplemented*.\n\n Note that ternary ``pow()`` will not try calling ``__rpow__()``\n (the coercion rules would become too complicated).\n\n Note: If the right operand\'s type is a subclass of the left operand\'s\n type and that subclass provides the reflected method for the\n operation, this method will be called before the left operand\'s\n non-reflected method. This behavior allows subclasses to\n override their ancestors\' operations.\n\nobject.__iadd__(self, other)\nobject.__isub__(self, other)\nobject.__imul__(self, other)\nobject.__itruediv__(self, other)\nobject.__ifloordiv__(self, other)\nobject.__imod__(self, other)\nobject.__ipow__(self, other[, modulo])\nobject.__ilshift__(self, other)\nobject.__irshift__(self, other)\nobject.__iand__(self, other)\nobject.__ixor__(self, other)\nobject.__ior__(self, other)\n\n These methods are called to implement the augmented arithmetic\n assignments (``+=``, ``-=``, ``*=``, ``/=``, ``//=``, ``%=``,\n ``**=``, ``<<=``, ``>>=``, ``&=``, ``^=``, ``|=``). These methods\n should attempt to do the operation in-place (modifying *self*) and\n return the result (which could be, but does not have to be,\n *self*). If a specific method is not defined, the augmented\n assignment falls back to the normal methods. For instance, to\n execute the statement ``x += y``, where *x* is an instance of a\n class that has an ``__iadd__()`` method, ``x.__iadd__(y)`` is\n called. If *x* is an instance of a class that does not define a\n ``__iadd__()`` method, ``x.__add__(y)`` and ``y.__radd__(x)`` are\n considered, as with the evaluation of ``x + y``.\n\nobject.__neg__(self)\nobject.__pos__(self)\nobject.__abs__(self)\nobject.__invert__(self)\n\n Called to implement the unary arithmetic operations (``-``, ``+``,\n ``abs()`` and ``~``).\n\nobject.__complex__(self)\nobject.__int__(self)\nobject.__float__(self)\nobject.__round__(self[, n])\n\n Called to implement the built-in functions ``complex()``,\n ``int()``, ``float()`` and ``round()``. Should return a value of\n the appropriate type.\n\nobject.__index__(self)\n\n Called to implement ``operator.index()``. Also called whenever\n Python needs an integer object (such as in slicing, or in the\n built-in ``bin()``, ``hex()`` and ``oct()`` functions). Must return\n an integer.\n\n\nWith Statement Context Managers\n===============================\n\nA *context manager* is an object that defines the runtime context to\nbe established when executing a ``with`` statement. The context\nmanager handles the entry into, and the exit from, the desired runtime\ncontext for the execution of the block of code. Context managers are\nnormally invoked using the ``with`` statement (described in section\n*The with statement*), but can also be used by directly invoking their\nmethods.\n\nTypical uses of context managers include saving and restoring various\nkinds of global state, locking and unlocking resources, closing opened\nfiles, etc.\n\nFor more information on context managers, see *Context Manager Types*.\n\nobject.__enter__(self)\n\n Enter the runtime context related to this object. The ``with``\n statement will bind this method\'s return value to the target(s)\n specified in the ``as`` clause of the statement, if any.\n\nobject.__exit__(self, exc_type, exc_value, traceback)\n\n Exit the runtime context related to this object. The parameters\n describe the exception that caused the context to be exited. If the\n context was exited without an exception, all three arguments will\n be ``None``.\n\n If an exception is supplied, and the method wishes to suppress the\n exception (i.e., prevent it from being propagated), it should\n return a true value. Otherwise, the exception will be processed\n normally upon exit from this method.\n\n Note that ``__exit__()`` methods should not reraise the passed-in\n exception; this is the caller\'s responsibility.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n\n\nSpecial method lookup\n=====================\n\nFor custom classes, implicit invocations of special methods are only\nguaranteed to work correctly if defined on an object\'s type, not in\nthe object\'s instance dictionary. That behaviour is the reason why\nthe following code raises an exception:\n\n >>> class C:\n ... pass\n ...\n >>> c = C()\n >>> c.__len__ = lambda: 5\n >>> len(c)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: object of type \'C\' has no len()\n\nThe rationale behind this behaviour lies with a number of special\nmethods such as ``__hash__()`` and ``__repr__()`` that are implemented\nby all objects, including type objects. If the implicit lookup of\nthese methods used the conventional lookup process, they would fail\nwhen invoked on the type object itself:\n\n >>> 1 .__hash__() == hash(1)\n True\n >>> int.__hash__() == hash(int)\n Traceback (most recent call last):\n File "<stdin>", line 1, in <module>\n TypeError: descriptor \'__hash__\' of \'int\' object needs an argument\n\nIncorrectly attempting to invoke an unbound method of a class in this\nway is sometimes referred to as \'metaclass confusion\', and is avoided\nby bypassing the instance when looking up special methods:\n\n >>> type(1).__hash__(1) == hash(1)\n True\n >>> type(int).__hash__(int) == hash(int)\n True\n\nIn addition to bypassing any instance attributes in the interest of\ncorrectness, implicit special method lookup generally also bypasses\nthe ``__getattribute__()`` method even of the object\'s metaclass:\n\n >>> class Meta(type):\n ... def __getattribute__(*args):\n ... print("Metaclass getattribute invoked")\n ... return type.__getattribute__(*args)\n ...\n >>> class C(object, metaclass=Meta):\n ... def __len__(self):\n ... return 10\n ... def __getattribute__(*args):\n ... print("Class getattribute invoked")\n ... return object.__getattribute__(*args)\n ...\n >>> c = C()\n >>> c.__len__() # Explicit lookup via instance\n Class getattribute invoked\n 10\n >>> type(c).__len__(c) # Explicit lookup via type\n Metaclass getattribute invoked\n 10\n >>> len(c) # Implicit lookup\n 10\n\nBypassing the ``__getattribute__()`` machinery in this fashion\nprovides significant scope for speed optimisations within the\ninterpreter, at the cost of some flexibility in the handling of\nspecial methods (the special method *must* be set on the class object\nitself in order to be consistently invoked by the interpreter).\n\n-[ Footnotes ]-\n\n[1] It *is* possible in some cases to change an object\'s type, under\n certain controlled conditions. It generally isn\'t a good idea\n though, since it can lead to some very strange behaviour if it is\n handled incorrectly.\n\n[2] For operands of the same type, it is assumed that if the non-\n reflected method (such as ``__add__()``) fails the operation is\n not supported, which is why the reflected method is not called.\n',
+ 'string-methods': '\nString Methods\n**************\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is ``\'utf-8\'``. *errors* may be given to set a different\n error handling scheme. The default for *errors* is ``\'strict\'``,\n meaning that encoding errors raise a ``UnicodeError``. Other\n possible values are ``\'ignore\'``, ``\'replace\'``,\n ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by zero or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\n Note: The ``find()`` method should be used only if you need to know the\n position of *sub*. To check if *sub* is a substring or not, use\n the ``in`` operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to ``str.format(**mapping)``, except that ``mapping`` is\n used directly and not copied to a ``dict`` . This is useful if for\n example ``mapping`` is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character\n ``c`` is alphanumeric if one of the following returns ``True``:\n ``c.isalpha()``, ``c.isdecimal()``, ``c.isdigit()``, or\n ``c.isnumeric()``.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A ``TypeError`` will be raised if there are\n any non-string values in *iterable*, including ``bytes`` objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that ``str.upper().isupper()`` might\n be ``False`` if ``s`` contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than or equal to ``len(s)``.\n',
+ 'strings': '\nString and Bytes literals\n*************************\n\nString literals are described by the following lexical definitions:\n\n stringliteral ::= [stringprefix](shortstring | longstring)\n stringprefix ::= "r" | "R"\n shortstring ::= "\'" shortstringitem* "\'" | \'"\' shortstringitem* \'"\'\n longstring ::= "\'\'\'" longstringitem* "\'\'\'" | \'"""\' longstringitem* \'"""\'\n shortstringitem ::= shortstringchar | stringescapeseq\n longstringitem ::= longstringchar | stringescapeseq\n shortstringchar ::= <any source character except "\\" or newline or the quote>\n longstringchar ::= <any source character except "\\">\n stringescapeseq ::= "\\" <any source character>\n\n bytesliteral ::= bytesprefix(shortbytes | longbytes)\n bytesprefix ::= "b" | "B" | "br" | "Br" | "bR" | "BR"\n shortbytes ::= "\'" shortbytesitem* "\'" | \'"\' shortbytesitem* \'"\'\n longbytes ::= "\'\'\'" longbytesitem* "\'\'\'" | \'"""\' longbytesitem* \'"""\'\n shortbytesitem ::= shortbyteschar | bytesescapeseq\n longbytesitem ::= longbyteschar | bytesescapeseq\n shortbyteschar ::= <any ASCII character except "\\" or newline or the quote>\n longbyteschar ::= <any ASCII character except "\\">\n bytesescapeseq ::= "\\" <any ASCII character>\n\nOne syntactic restriction not indicated by these productions is that\nwhitespace is not allowed between the ``stringprefix`` or\n``bytesprefix`` and the rest of the literal. The source character set\nis defined by the encoding declaration; it is UTF-8 if no encoding\ndeclaration is given in the source file; see section *Encoding\ndeclarations*.\n\nIn plain English: Both types of literals can be enclosed in matching\nsingle quotes (``\'``) or double quotes (``"``). They can also be\nenclosed in matching groups of three single or double quotes (these\nare generally referred to as *triple-quoted strings*). The backslash\n(``\\``) character is used to escape characters that otherwise have a\nspecial meaning, such as newline, backslash itself, or the quote\ncharacter.\n\nBytes literals are always prefixed with ``\'b\'`` or ``\'B\'``; they\nproduce an instance of the ``bytes`` type instead of the ``str`` type.\nThey may only contain ASCII characters; bytes with a numeric value of\n128 or greater must be expressed with escapes.\n\nBoth string and bytes literals may optionally be prefixed with a\nletter ``\'r\'`` or ``\'R\'``; such strings are called *raw strings* and\ntreat backslashes as literal characters. As a result, in string\nliterals, ``\'\\U\'`` and ``\'\\u\'`` escapes in raw strings are not treated\nspecially.\n\nIn triple-quoted strings, unescaped newlines and quotes are allowed\n(and are retained), except that three unescaped quotes in a row\nterminate the string. (A "quote" is the character used to open the\nstring, i.e. either ``\'`` or ``"``.)\n\nUnless an ``\'r\'`` or ``\'R\'`` prefix is present, escape sequences in\nstrings are interpreted according to rules similar to those used by\nStandard C. The recognized escape sequences are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\newline`` | Backslash and newline ignored | |\n+-------------------+-----------------------------------+---------+\n| ``\\\\`` | Backslash (``\\``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\\'`` | Single quote (``\'``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\"`` | Double quote (``"``) | |\n+-------------------+-----------------------------------+---------+\n| ``\\a`` | ASCII Bell (BEL) | |\n+-------------------+-----------------------------------+---------+\n| ``\\b`` | ASCII Backspace (BS) | |\n+-------------------+-----------------------------------+---------+\n| ``\\f`` | ASCII Formfeed (FF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\n`` | ASCII Linefeed (LF) | |\n+-------------------+-----------------------------------+---------+\n| ``\\r`` | ASCII Carriage Return (CR) | |\n+-------------------+-----------------------------------+---------+\n| ``\\t`` | ASCII Horizontal Tab (TAB) | |\n+-------------------+-----------------------------------+---------+\n| ``\\v`` | ASCII Vertical Tab (VT) | |\n+-------------------+-----------------------------------+---------+\n| ``\\ooo`` | Character with octal value *ooo* | (1,3) |\n+-------------------+-----------------------------------+---------+\n| ``\\xhh`` | Character with hex value *hh* | (2,3) |\n+-------------------+-----------------------------------+---------+\n\nEscape sequences only recognized in string literals are:\n\n+-------------------+-----------------------------------+---------+\n| Escape Sequence | Meaning | Notes |\n+===================+===================================+=========+\n| ``\\N{name}`` | Character named *name* in the | |\n| | Unicode database | |\n+-------------------+-----------------------------------+---------+\n| ``\\uxxxx`` | Character with 16-bit hex value | (4) |\n| | *xxxx* | |\n+-------------------+-----------------------------------+---------+\n| ``\\Uxxxxxxxx`` | Character with 32-bit hex value | (5) |\n| | *xxxxxxxx* | |\n+-------------------+-----------------------------------+---------+\n\nNotes:\n\n1. As in Standard C, up to three octal digits are accepted.\n\n2. Unlike in Standard C, exactly two hex digits are required.\n\n3. In a bytes literal, hexadecimal and octal escapes denote the byte\n with the given value. In a string literal, these escapes denote a\n Unicode character with the given value.\n\n4. Individual code units which form parts of a surrogate pair can be\n encoded using this escape sequence. Exactly four hex digits are\n required.\n\n5. Any Unicode character can be encoded this way, but characters\n outside the Basic Multilingual Plane (BMP) will be encoded using a\n surrogate pair if Python is compiled to use 16-bit code units (the\n default). Exactly eight hex digits are required.\n\nUnlike Standard C, all unrecognized escape sequences are left in the\nstring unchanged, i.e., *the backslash is left in the string*. (This\nbehavior is useful when debugging: if an escape sequence is mistyped,\nthe resulting output is more easily recognized as broken.) It is also\nimportant to note that the escape sequences only recognized in string\nliterals fall into the category of unrecognized escapes for bytes\nliterals.\n\nEven in a raw string, string quotes can be escaped with a backslash,\nbut the backslash remains in the string; for example, ``r"\\""`` is a\nvalid string literal consisting of two characters: a backslash and a\ndouble quote; ``r"\\"`` is not a valid string literal (even a raw\nstring cannot end in an odd number of backslashes). Specifically, *a\nraw string cannot end in a single backslash* (since the backslash\nwould escape the following quote character). Note also that a single\nbackslash followed by a newline is interpreted as those two characters\nas part of the string, *not* as a line continuation.\n',
+ 'subscriptions': '\nSubscriptions\n*************\n\nA subscription selects an item of a sequence (string, tuple or list)\nor mapping (dictionary) object:\n\n subscription ::= primary "[" expression_list "]"\n\nThe primary must evaluate to an object that supports subscription,\ne.g. a list or dictionary. User-defined objects can support\nsubscription by defining a ``__getitem__()`` method.\n\nFor built-in objects, there are two types of objects that support\nsubscription:\n\nIf the primary is a mapping, the expression list must evaluate to an\nobject whose value is one of the keys of the mapping, and the\nsubscription selects the value in the mapping that corresponds to that\nkey. (The expression list is a tuple except if it has exactly one\nitem.)\n\nIf the primary is a sequence, the expression (list) must evaluate to\nan integer or a slice (as discussed in the following section).\n\nThe formal syntax makes no special provision for negative indices in\nsequences; however, built-in sequences all provide a ``__getitem__()``\nmethod that interprets negative indices by adding the length of the\nsequence to the index (so that ``x[-1]`` selects the last item of\n``x``). The resulting value must be a nonnegative integer less than\nthe number of items in the sequence, and the subscription selects the\nitem whose index is that value (counting from zero). Since the support\nfor negative indices and slicing occurs in the object\'s\n``__getitem__()`` method, subclasses overriding this method will need\nto explicitly add that support.\n\nA string\'s items are characters. A character is not a separate data\ntype but a string of exactly one character.\n',
+ 'truth': "\nTruth Value Testing\n*******************\n\nAny object can be tested for truth value, for use in an ``if`` or\n``while`` condition or as operand of the Boolean operations below. The\nfollowing values are considered false:\n\n* ``None``\n\n* ``False``\n\n* zero of any numeric type, for example, ``0``, ``0.0``, ``0j``.\n\n* any empty sequence, for example, ``''``, ``()``, ``[]``.\n\n* any empty mapping, for example, ``{}``.\n\n* instances of user-defined classes, if the class defines a\n ``__bool__()`` or ``__len__()`` method, when that method returns the\n integer zero or ``bool`` value ``False``. [1]\n\nAll other values are considered true --- so objects of many types are\nalways true.\n\nOperations and built-in functions that have a Boolean result always\nreturn ``0`` or ``False`` for false and ``1`` or ``True`` for true,\nunless otherwise stated. (Important exception: the Boolean operations\n``or`` and ``and`` always return one of their operands.)\n",
+ 'try': '\nThe ``try`` statement\n*********************\n\nThe ``try`` statement specifies exception handlers and/or cleanup code\nfor a group of statements:\n\n try_stmt ::= try1_stmt | try2_stmt\n try1_stmt ::= "try" ":" suite\n ("except" [expression ["as" target]] ":" suite)+\n ["else" ":" suite]\n ["finally" ":" suite]\n try2_stmt ::= "try" ":" suite\n "finally" ":" suite\n\nThe ``except`` clause(s) specify one or more exception handlers. When\nno exception occurs in the ``try`` clause, no exception handler is\nexecuted. When an exception occurs in the ``try`` suite, a search for\nan exception handler is started. This search inspects the except\nclauses in turn until one is found that matches the exception. An\nexpression-less except clause, if present, must be last; it matches\nany exception. For an except clause with an expression, that\nexpression is evaluated, and the clause matches the exception if the\nresulting object is "compatible" with the exception. An object is\ncompatible with an exception if it is the class or a base class of the\nexception object or a tuple containing an item compatible with the\nexception.\n\nIf no except clause matches the exception, the search for an exception\nhandler continues in the surrounding code and on the invocation stack.\n[1]\n\nIf the evaluation of an expression in the header of an except clause\nraises an exception, the original search for a handler is canceled and\na search starts for the new exception in the surrounding code and on\nthe call stack (it is treated as if the entire ``try`` statement\nraised the exception).\n\nWhen a matching except clause is found, the exception is assigned to\nthe target specified after the ``as`` keyword in that except clause,\nif present, and the except clause\'s suite is executed. All except\nclauses must have an executable block. When the end of this block is\nreached, execution continues normally after the entire try statement.\n(This means that if two nested handlers exist for the same exception,\nand the exception occurs in the try clause of the inner handler, the\nouter handler will not handle the exception.)\n\nWhen an exception has been assigned using ``as target``, it is cleared\nat the end of the except clause. This is as if\n\n except E as N:\n foo\n\nwas translated to\n\n except E as N:\n try:\n foo\n finally:\n del N\n\nThis means the exception must be assigned to a different name to be\nable to refer to it after the except clause. Exceptions are cleared\nbecause with the traceback attached to them, they form a reference\ncycle with the stack frame, keeping all locals in that frame alive\nuntil the next garbage collection occurs.\n\nBefore an except clause\'s suite is executed, details about the\nexception are stored in the ``sys`` module and can be access via\n``sys.exc_info()``. ``sys.exc_info()`` returns a 3-tuple consisting of\nthe exception class, the exception instance and a traceback object\n(see section *The standard type hierarchy*) identifying the point in\nthe program where the exception occurred. ``sys.exc_info()`` values\nare restored to their previous values (before the call) when returning\nfrom a function that handled an exception.\n\nThe optional ``else`` clause is executed if and when control flows off\nthe end of the ``try`` clause. [2] Exceptions in the ``else`` clause\nare not handled by the preceding ``except`` clauses.\n\nIf ``finally`` is present, it specifies a \'cleanup\' handler. The\n``try`` clause is executed, including any ``except`` and ``else``\nclauses. If an exception occurs in any of the clauses and is not\nhandled, the exception is temporarily saved. The ``finally`` clause is\nexecuted. If there is a saved exception, it is re-raised at the end\nof the ``finally`` clause. If the ``finally`` clause raises another\nexception or executes a ``return`` or ``break`` statement, the saved\nexception is set as the context of the new exception. The exception\ninformation is not available to the program during execution of the\n``finally`` clause.\n\nWhen a ``return``, ``break`` or ``continue`` statement is executed in\nthe ``try`` suite of a ``try``...``finally`` statement, the\n``finally`` clause is also executed \'on the way out.\' A ``continue``\nstatement is illegal in the ``finally`` clause. (The reason is a\nproblem with the current implementation --- this restriction may be\nlifted in the future).\n\nAdditional information on exceptions can be found in section\n*Exceptions*, and information on using the ``raise`` statement to\ngenerate exceptions may be found in section *The raise statement*.\n',
+ 'types': '\nThe standard type hierarchy\n***************************\n\nBelow is a list of the types that are built into Python. Extension\nmodules (written in C, Java, or other languages, depending on the\nimplementation) can define additional types. Future versions of\nPython may add types to the type hierarchy (e.g., rational numbers,\nefficiently stored arrays of integers, etc.), although such additions\nwill often be provided via the standard library instead.\n\nSome of the type descriptions below contain a paragraph listing\n\'special attributes.\' These are attributes that provide access to the\nimplementation and are not intended for general use. Their definition\nmay change in the future.\n\nNone\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name ``None``.\n It is used to signify the absence of a value in many situations,\n e.g., it is returned from functions that don\'t explicitly return\n anything. Its truth value is false.\n\nNotImplemented\n This type has a single value. There is a single object with this\n value. This object is accessed through the built-in name\n ``NotImplemented``. Numeric methods and rich comparison methods may\n return this value if they do not implement the operation for the\n operands provided. (The interpreter will then try the reflected\n operation, or some other fallback, depending on the operator.) Its\n truth value is true.\n\nEllipsis\n This type has a single value. There is a single object with this\n value. This object is accessed through the literal ``...`` or the\n built-in name ``Ellipsis``. Its truth value is true.\n\n``numbers.Number``\n These are created by numeric literals and returned as results by\n arithmetic operators and arithmetic built-in functions. Numeric\n objects are immutable; once created their value never changes.\n Python numbers are of course strongly related to mathematical\n numbers, but subject to the limitations of numerical representation\n in computers.\n\n Python distinguishes between integers, floating point numbers, and\n complex numbers:\n\n ``numbers.Integral``\n These represent elements from the mathematical set of integers\n (positive and negative).\n\n There are two types of integers:\n\n Integers (``int``)\n\n These represent numbers in an unlimited range, subject to\n available (virtual) memory only. For the purpose of shift\n and mask operations, a binary representation is assumed, and\n negative numbers are represented in a variant of 2\'s\n complement which gives the illusion of an infinite string of\n sign bits extending to the left.\n\n Booleans (``bool``)\n These represent the truth values False and True. The two\n objects representing the values False and True are the only\n Boolean objects. The Boolean type is a subtype of the integer\n type, and Boolean values behave like the values 0 and 1,\n respectively, in almost all contexts, the exception being\n that when converted to a string, the strings ``"False"`` or\n ``"True"`` are returned, respectively.\n\n The rules for integer representation are intended to give the\n most meaningful interpretation of shift and mask operations\n involving negative integers.\n\n ``numbers.Real`` (``float``)\n These represent machine-level double precision floating point\n numbers. You are at the mercy of the underlying machine\n architecture (and C or Java implementation) for the accepted\n range and handling of overflow. Python does not support single-\n precision floating point numbers; the savings in processor and\n memory usage that are usually the reason for using these is\n dwarfed by the overhead of using objects in Python, so there is\n no reason to complicate the language with two kinds of floating\n point numbers.\n\n ``numbers.Complex`` (``complex``)\n These represent complex numbers as a pair of machine-level\n double precision floating point numbers. The same caveats apply\n as for floating point numbers. The real and imaginary parts of a\n complex number ``z`` can be retrieved through the read-only\n attributes ``z.real`` and ``z.imag``.\n\nSequences\n These represent finite ordered sets indexed by non-negative\n numbers. The built-in function ``len()`` returns the number of\n items of a sequence. When the length of a sequence is *n*, the\n index set contains the numbers 0, 1, ..., *n*-1. Item *i* of\n sequence *a* is selected by ``a[i]``.\n\n Sequences also support slicing: ``a[i:j]`` selects all items with\n index *k* such that *i* ``<=`` *k* ``<`` *j*. When used as an\n expression, a slice is a sequence of the same type. This implies\n that the index set is renumbered so that it starts at 0.\n\n Some sequences also support "extended slicing" with a third "step"\n parameter: ``a[i:j:k]`` selects all items of *a* with index *x*\n where ``x = i + n*k``, *n* ``>=`` ``0`` and *i* ``<=`` *x* ``<``\n *j*.\n\n Sequences are distinguished according to their mutability:\n\n Immutable sequences\n An object of an immutable sequence type cannot change once it is\n created. (If the object contains references to other objects,\n these other objects may be mutable and may be changed; however,\n the collection of objects directly referenced by an immutable\n object cannot change.)\n\n The following types are immutable sequences:\n\n Strings\n The items of a string object are Unicode code units. A\n Unicode code unit is represented by a string object of one\n item and can hold either a 16-bit or 32-bit value\n representing a Unicode ordinal (the maximum value for the\n ordinal is given in ``sys.maxunicode``, and depends on how\n Python is configured at compile time). Surrogate pairs may\n be present in the Unicode object, and will be reported as two\n separate items. The built-in functions ``chr()`` and\n ``ord()`` convert between code units and nonnegative integers\n representing the Unicode ordinals as defined in the Unicode\n Standard 3.0. Conversion from and to other encodings are\n possible through the string method ``encode()``.\n\n Tuples\n The items of a tuple are arbitrary Python objects. Tuples of\n two or more items are formed by comma-separated lists of\n expressions. A tuple of one item (a \'singleton\') can be\n formed by affixing a comma to an expression (an expression by\n itself does not create a tuple, since parentheses must be\n usable for grouping of expressions). An empty tuple can be\n formed by an empty pair of parentheses.\n\n Bytes\n A bytes object is an immutable array. The items are 8-bit\n bytes, represented by integers in the range 0 <= x < 256.\n Bytes literals (like ``b\'abc\'`` and the built-in function\n ``bytes()`` can be used to construct bytes objects. Also,\n bytes objects can be decoded to strings via the ``decode()``\n method.\n\n Mutable sequences\n Mutable sequences can be changed after they are created. The\n subscription and slicing notations can be used as the target of\n assignment and ``del`` (delete) statements.\n\n There are currently two intrinsic mutable sequence types:\n\n Lists\n The items of a list are arbitrary Python objects. Lists are\n formed by placing a comma-separated list of expressions in\n square brackets. (Note that there are no special cases needed\n to form lists of length 0 or 1.)\n\n Byte Arrays\n A bytearray object is a mutable array. They are created by\n the built-in ``bytearray()`` constructor. Aside from being\n mutable (and hence unhashable), byte arrays otherwise provide\n the same interface and functionality as immutable bytes\n objects.\n\n The extension module ``array`` provides an additional example of\n a mutable sequence type, as does the ``collections`` module.\n\nSet types\n These represent unordered, finite sets of unique, immutable\n objects. As such, they cannot be indexed by any subscript. However,\n they can be iterated over, and the built-in function ``len()``\n returns the number of items in a set. Common uses for sets are fast\n membership testing, removing duplicates from a sequence, and\n computing mathematical operations such as intersection, union,\n difference, and symmetric difference.\n\n For set elements, the same immutability rules apply as for\n dictionary keys. Note that numeric types obey the normal rules for\n numeric comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``), only one of them can be contained in a set.\n\n There are currently two intrinsic set types:\n\n Sets\n These represent a mutable set. They are created by the built-in\n ``set()`` constructor and can be modified afterwards by several\n methods, such as ``add()``.\n\n Frozen sets\n These represent an immutable set. They are created by the\n built-in ``frozenset()`` constructor. As a frozenset is\n immutable and *hashable*, it can be used again as an element of\n another set, or as a dictionary key.\n\nMappings\n These represent finite sets of objects indexed by arbitrary index\n sets. The subscript notation ``a[k]`` selects the item indexed by\n ``k`` from the mapping ``a``; this can be used in expressions and\n as the target of assignments or ``del`` statements. The built-in\n function ``len()`` returns the number of items in a mapping.\n\n There is currently a single intrinsic mapping type:\n\n Dictionaries\n These represent finite sets of objects indexed by nearly\n arbitrary values. The only types of values not acceptable as\n keys are values containing lists or dictionaries or other\n mutable types that are compared by value rather than by object\n identity, the reason being that the efficient implementation of\n dictionaries requires a key\'s hash value to remain constant.\n Numeric types used for keys obey the normal rules for numeric\n comparison: if two numbers compare equal (e.g., ``1`` and\n ``1.0``) then they can be used interchangeably to index the same\n dictionary entry.\n\n Dictionaries are mutable; they can be created by the ``{...}``\n notation (see section *Dictionary displays*).\n\n The extension modules ``dbm.ndbm`` and ``dbm.gnu`` provide\n additional examples of mapping types, as does the\n ``collections`` module.\n\nCallable types\n These are the types to which the function call operation (see\n section *Calls*) can be applied:\n\n User-defined functions\n A user-defined function object is created by a function\n definition (see section *Function definitions*). It should be\n called with an argument list containing the same number of items\n as the function\'s formal parameter list.\n\n Special attributes:\n\n +---------------------------+---------------------------------+-------------+\n | Attribute | Meaning | |\n +===========================+=================================+=============+\n | ``__doc__`` | The function\'s documentation | Writable |\n | | string, or ``None`` if | |\n | | unavailable | |\n +---------------------------+---------------------------------+-------------+\n | ``__name__`` | The function\'s name | Writable |\n +---------------------------+---------------------------------+-------------+\n | ``__module__`` | The name of the module the | Writable |\n | | function was defined in, or | |\n | | ``None`` if unavailable. | |\n +---------------------------+---------------------------------+-------------+\n | ``__defaults__`` | A tuple containing default | Writable |\n | | argument values for those | |\n | | arguments that have defaults, | |\n | | or ``None`` if no arguments | |\n | | have a default value | |\n +---------------------------+---------------------------------+-------------+\n | ``__code__`` | The code object representing | Writable |\n | | the compiled function body. | |\n +---------------------------+---------------------------------+-------------+\n | ``__globals__`` | A reference to the dictionary | Read-only |\n | | that holds the function\'s | |\n | | global variables --- the global | |\n | | namespace of the module in | |\n | | which the function was defined. | |\n +---------------------------+---------------------------------+-------------+\n | ``__dict__`` | The namespace supporting | Writable |\n | | arbitrary function attributes. | |\n +---------------------------+---------------------------------+-------------+\n | ``__closure__`` | ``None`` or a tuple of cells | Read-only |\n | | that contain bindings for the | |\n | | function\'s free variables. | |\n +---------------------------+---------------------------------+-------------+\n | ``__annotations__`` | A dict containing annotations | Writable |\n | | of parameters. The keys of the | |\n | | dict are the parameter names, | |\n | | or ``\'return\'`` for the return | |\n | | annotation, if provided. | |\n +---------------------------+---------------------------------+-------------+\n | ``__kwdefaults__`` | A dict containing defaults for | Writable |\n | | keyword-only parameters. | |\n +---------------------------+---------------------------------+-------------+\n\n Most of the attributes labelled "Writable" check the type of the\n assigned value.\n\n Function objects also support getting and setting arbitrary\n attributes, which can be used, for example, to attach metadata\n to functions. Regular attribute dot-notation is used to get and\n set such attributes. *Note that the current implementation only\n supports function attributes on user-defined functions. Function\n attributes on built-in functions may be supported in the\n future.*\n\n Additional information about a function\'s definition can be\n retrieved from its code object; see the description of internal\n types below.\n\n Instance methods\n An instance method object combines a class, a class instance and\n any callable object (normally a user-defined function).\n\n Special read-only attributes: ``__self__`` is the class instance\n object, ``__func__`` is the function object; ``__doc__`` is the\n method\'s documentation (same as ``__func__.__doc__``);\n ``__name__`` is the method name (same as ``__func__.__name__``);\n ``__module__`` is the name of the module the method was defined\n in, or ``None`` if unavailable.\n\n Methods also support accessing (but not setting) the arbitrary\n function attributes on the underlying function object.\n\n User-defined method objects may be created when getting an\n attribute of a class (perhaps via an instance of that class), if\n that attribute is a user-defined function object or a class\n method object.\n\n When an instance method object is created by retrieving a user-\n defined function object from a class via one of its instances,\n its ``__self__`` attribute is the instance, and the method\n object is said to be bound. The new method\'s ``__func__``\n attribute is the original function object.\n\n When a user-defined method object is created by retrieving\n another method object from a class or instance, the behaviour is\n the same as for a function object, except that the ``__func__``\n attribute of the new instance is not the original method object\n but its ``__func__`` attribute.\n\n When an instance method object is created by retrieving a class\n method object from a class or instance, its ``__self__``\n attribute is the class itself, and its ``__func__`` attribute is\n the function object underlying the class method.\n\n When an instance method object is called, the underlying\n function (``__func__``) is called, inserting the class instance\n (``__self__``) in front of the argument list. For instance,\n when ``C`` is a class which contains a definition for a function\n ``f()``, and ``x`` is an instance of ``C``, calling ``x.f(1)``\n is equivalent to calling ``C.f(x, 1)``.\n\n When an instance method object is derived from a class method\n object, the "class instance" stored in ``__self__`` will\n actually be the class itself, so that calling either ``x.f(1)``\n or ``C.f(1)`` is equivalent to calling ``f(C,1)`` where ``f`` is\n the underlying function.\n\n Note that the transformation from function object to instance\n method object happens each time the attribute is retrieved from\n the instance. In some cases, a fruitful optimization is to\n assign the attribute to a local variable and call that local\n variable. Also notice that this transformation only happens for\n user-defined functions; other callable objects (and all non-\n callable objects) are retrieved without transformation. It is\n also important to note that user-defined functions which are\n attributes of a class instance are not converted to bound\n methods; this *only* happens when the function is an attribute\n of the class.\n\n Generator functions\n A function or method which uses the ``yield`` statement (see\n section *The yield statement*) is called a *generator function*.\n Such a function, when called, always returns an iterator object\n which can be used to execute the body of the function: calling\n the iterator\'s ``__next__()`` method will cause the function to\n execute until it provides a value using the ``yield`` statement.\n When the function executes a ``return`` statement or falls off\n the end, a ``StopIteration`` exception is raised and the\n iterator will have reached the end of the set of values to be\n returned.\n\n Built-in functions\n A built-in function object is a wrapper around a C function.\n Examples of built-in functions are ``len()`` and ``math.sin()``\n (``math`` is a standard built-in module). The number and type of\n the arguments are determined by the C function. Special read-\n only attributes: ``__doc__`` is the function\'s documentation\n string, or ``None`` if unavailable; ``__name__`` is the\n function\'s name; ``__self__`` is set to ``None`` (but see the\n next item); ``__module__`` is the name of the module the\n function was defined in or ``None`` if unavailable.\n\n Built-in methods\n This is really a different disguise of a built-in function, this\n time containing an object passed to the C function as an\n implicit extra argument. An example of a built-in method is\n ``alist.append()``, assuming *alist* is a list object. In this\n case, the special read-only attribute ``__self__`` is set to the\n object denoted by *alist*.\n\n Classes\n Classes are callable. These objects normally act as factories\n for new instances of themselves, but variations are possible for\n class types that override ``__new__()``. The arguments of the\n call are passed to ``__new__()`` and, in the typical case, to\n ``__init__()`` to initialize the new instance.\n\n Class Instances\n Instances of arbitrary classes can be made callable by defining\n a ``__call__()`` method in their class.\n\nModules\n Modules are imported by the ``import`` statement (see section *The\n import statement*). A module object has a namespace implemented by\n a dictionary object (this is the dictionary referenced by the\n __globals__ attribute of functions defined in the module).\n Attribute references are translated to lookups in this dictionary,\n e.g., ``m.x`` is equivalent to ``m.__dict__["x"]``. A module object\n does not contain the code object used to initialize the module\n (since it isn\'t needed once the initialization is done).\n\n Attribute assignment updates the module\'s namespace dictionary,\n e.g., ``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``.\n\n Special read-only attribute: ``__dict__`` is the module\'s namespace\n as a dictionary object.\n\n **CPython implementation detail:** Because of the way CPython\n clears module dictionaries, the module dictionary will be cleared\n when the module falls out of scope even if the dictionary still has\n live references. To avoid this, copy the dictionary or keep the\n module around while using its dictionary directly.\n\n Predefined (writable) attributes: ``__name__`` is the module\'s\n name; ``__doc__`` is the module\'s documentation string, or ``None``\n if unavailable; ``__file__`` is the pathname of the file from which\n the module was loaded, if it was loaded from a file. The\n ``__file__`` attribute is not present for C modules that are\n statically linked into the interpreter; for extension modules\n loaded dynamically from a shared library, it is the pathname of the\n shared library file.\n\nCustom classes\n Custom class types are typically created by class definitions (see\n section *Class definitions*). A class has a namespace implemented\n by a dictionary object. Class attribute references are translated\n to lookups in this dictionary, e.g., ``C.x`` is translated to\n ``C.__dict__["x"]`` (although there are a number of hooks which\n allow for other means of locating attributes). When the attribute\n name is not found there, the attribute search continues in the base\n classes. This search of the base classes uses the C3 method\n resolution order which behaves correctly even in the presence of\n \'diamond\' inheritance structures where there are multiple\n inheritance paths leading back to a common ancestor. Additional\n details on the C3 MRO used by Python can be found in the\n documentation accompanying the 2.3 release at\n http://www.python.org/download/releases/2.3/mro/.\n\n When a class attribute reference (for class ``C``, say) would yield\n a class method object, it is transformed into an instance method\n object whose ``__self__`` attributes is ``C``. When it would yield\n a static method object, it is transformed into the object wrapped\n by the static method object. See section *Implementing Descriptors*\n for another way in which attributes retrieved from a class may\n differ from those actually contained in its ``__dict__``.\n\n Class attribute assignments update the class\'s dictionary, never\n the dictionary of a base class.\n\n A class object can be called (see above) to yield a class instance\n (see below).\n\n Special attributes: ``__name__`` is the class name; ``__module__``\n is the module name in which the class was defined; ``__dict__`` is\n the dictionary containing the class\'s namespace; ``__bases__`` is a\n tuple (possibly empty or a singleton) containing the base classes,\n in the order of their occurrence in the base class list;\n ``__doc__`` is the class\'s documentation string, or None if\n undefined.\n\nClass instances\n A class instance is created by calling a class object (see above).\n A class instance has a namespace implemented as a dictionary which\n is the first place in which attribute references are searched.\n When an attribute is not found there, and the instance\'s class has\n an attribute by that name, the search continues with the class\n attributes. If a class attribute is found that is a user-defined\n function object, it is transformed into an instance method object\n whose ``__self__`` attribute is the instance. Static method and\n class method objects are also transformed; see above under\n "Classes". See section *Implementing Descriptors* for another way\n in which attributes of a class retrieved via its instances may\n differ from the objects actually stored in the class\'s\n ``__dict__``. If no class attribute is found, and the object\'s\n class has a ``__getattr__()`` method, that is called to satisfy the\n lookup.\n\n Attribute assignments and deletions update the instance\'s\n dictionary, never a class\'s dictionary. If the class has a\n ``__setattr__()`` or ``__delattr__()`` method, this is called\n instead of updating the instance dictionary directly.\n\n Class instances can pretend to be numbers, sequences, or mappings\n if they have methods with certain special names. See section\n *Special method names*.\n\n Special attributes: ``__dict__`` is the attribute dictionary;\n ``__class__`` is the instance\'s class.\n\nI/O objects (also known as file objects)\n A *file object* represents an open file. Various shortcuts are\n available to create file objects: the ``open()`` built-in function,\n and also ``os.popen()``, ``os.fdopen()``, and the ``makefile()``\n method of socket objects (and perhaps by other functions or methods\n provided by extension modules).\n\n The objects ``sys.stdin``, ``sys.stdout`` and ``sys.stderr`` are\n initialized to file objects corresponding to the interpreter\'s\n standard input, output and error streams; they are all open in text\n mode and therefore follow the interface defined by the\n ``io.TextIOBase`` abstract class.\n\nInternal types\n A few types used internally by the interpreter are exposed to the\n user. Their definitions may change with future versions of the\n interpreter, but they are mentioned here for completeness.\n\n Code objects\n Code objects represent *byte-compiled* executable Python code,\n or *bytecode*. The difference between a code object and a\n function object is that the function object contains an explicit\n reference to the function\'s globals (the module in which it was\n defined), while a code object contains no context; also the\n default argument values are stored in the function object, not\n in the code object (because they represent values calculated at\n run-time). Unlike function objects, code objects are immutable\n and contain no references (directly or indirectly) to mutable\n objects.\n\n Special read-only attributes: ``co_name`` gives the function\n name; ``co_argcount`` is the number of positional arguments\n (including arguments with default values); ``co_nlocals`` is the\n number of local variables used by the function (including\n arguments); ``co_varnames`` is a tuple containing the names of\n the local variables (starting with the argument names);\n ``co_cellvars`` is a tuple containing the names of local\n variables that are referenced by nested functions;\n ``co_freevars`` is a tuple containing the names of free\n variables; ``co_code`` is a string representing the sequence of\n bytecode instructions; ``co_consts`` is a tuple containing the\n literals used by the bytecode; ``co_names`` is a tuple\n containing the names used by the bytecode; ``co_filename`` is\n the filename from which the code was compiled;\n ``co_firstlineno`` is the first line number of the function;\n ``co_lnotab`` is a string encoding the mapping from bytecode\n offsets to line numbers (for details see the source code of the\n interpreter); ``co_stacksize`` is the required stack size\n (including local variables); ``co_flags`` is an integer encoding\n a number of flags for the interpreter.\n\n The following flag bits are defined for ``co_flags``: bit\n ``0x04`` is set if the function uses the ``*arguments`` syntax\n to accept an arbitrary number of positional arguments; bit\n ``0x08`` is set if the function uses the ``**keywords`` syntax\n to accept arbitrary keyword arguments; bit ``0x20`` is set if\n the function is a generator.\n\n Future feature declarations (``from __future__ import\n division``) also use bits in ``co_flags`` to indicate whether a\n code object was compiled with a particular feature enabled: bit\n ``0x2000`` is set if the function was compiled with future\n division enabled; bits ``0x10`` and ``0x1000`` were used in\n earlier versions of Python.\n\n Other bits in ``co_flags`` are reserved for internal use.\n\n If a code object represents a function, the first item in\n ``co_consts`` is the documentation string of the function, or\n ``None`` if undefined.\n\n Frame objects\n Frame objects represent execution frames. They may occur in\n traceback objects (see below).\n\n Special read-only attributes: ``f_back`` is to the previous\n stack frame (towards the caller), or ``None`` if this is the\n bottom stack frame; ``f_code`` is the code object being executed\n in this frame; ``f_locals`` is the dictionary used to look up\n local variables; ``f_globals`` is used for global variables;\n ``f_builtins`` is used for built-in (intrinsic) names;\n ``f_lasti`` gives the precise instruction (this is an index into\n the bytecode string of the code object).\n\n Special writable attributes: ``f_trace``, if not ``None``, is a\n function called at the start of each source code line (this is\n used by the debugger); ``f_lineno`` is the current line number\n of the frame --- writing to this from within a trace function\n jumps to the given line (only for the bottom-most frame). A\n debugger can implement a Jump command (aka Set Next Statement)\n by writing to f_lineno.\n\n Traceback objects\n Traceback objects represent a stack trace of an exception. A\n traceback object is created when an exception occurs. When the\n search for an exception handler unwinds the execution stack, at\n each unwound level a traceback object is inserted in front of\n the current traceback. When an exception handler is entered,\n the stack trace is made available to the program. (See section\n *The try statement*.) It is accessible as the third item of the\n tuple returned by ``sys.exc_info()``. When the program contains\n no suitable handler, the stack trace is written (nicely\n formatted) to the standard error stream; if the interpreter is\n interactive, it is also made available to the user as\n ``sys.last_traceback``.\n\n Special read-only attributes: ``tb_next`` is the next level in\n the stack trace (towards the frame where the exception\n occurred), or ``None`` if there is no next level; ``tb_frame``\n points to the execution frame of the current level;\n ``tb_lineno`` gives the line number where the exception\n occurred; ``tb_lasti`` indicates the precise instruction. The\n line number and last instruction in the traceback may differ\n from the line number of its frame object if the exception\n occurred in a ``try`` statement with no matching except clause\n or with a finally clause.\n\n Slice objects\n Slice objects are used to represent slices for ``__getitem__()``\n methods. They are also created by the built-in ``slice()``\n function.\n\n Special read-only attributes: ``start`` is the lower bound;\n ``stop`` is the upper bound; ``step`` is the step value; each is\n ``None`` if omitted. These attributes can have any type.\n\n Slice objects support one method:\n\n slice.indices(self, length)\n\n This method takes a single integer argument *length* and\n computes information about the slice that the slice object\n would describe if applied to a sequence of *length* items.\n It returns a tuple of three integers; respectively these are\n the *start* and *stop* indices and the *step* or stride\n length of the slice. Missing or out-of-bounds indices are\n handled in a manner consistent with regular slices.\n\n Static method objects\n Static method objects provide a way of defeating the\n transformation of function objects to method objects described\n above. A static method object is a wrapper around any other\n object, usually a user-defined method object. When a static\n method object is retrieved from a class or a class instance, the\n object actually returned is the wrapped object, which is not\n subject to any further transformation. Static method objects are\n not themselves callable, although the objects they wrap usually\n are. Static method objects are created by the built-in\n ``staticmethod()`` constructor.\n\n Class method objects\n A class method object, like a static method object, is a wrapper\n around another object that alters the way in which that object\n is retrieved from classes and class instances. The behaviour of\n class method objects upon such retrieval is described above,\n under "User-defined methods". Class method objects are created\n by the built-in ``classmethod()`` constructor.\n',
'typesfunctions': '\nFunctions\n*********\n\nFunction objects are created by function definitions. The only\noperation on a function object is to call it: ``func(argument-list)``.\n\nThere are really two flavors of function objects: built-in functions\nand user-defined functions. Both support the same operation (to call\nthe function), but the implementation is different, hence the\ndifferent object types.\n\nSee *Function definitions* for more information.\n',
- 'typesmapping': '\nMapping Types --- ``dict``\n**************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built\nin ``list``, ``set``, and ``tuple`` classes, and the ``collections``\nmodule.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as ``1`` and ``1.0``) then they can be used interchangeably to\nindex the same dictionary entry. (Note however, that since computers\nstore floating-point numbers as approximations it is usually unwise to\nuse them as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of\n``key: value`` pairs within braces, for example: ``{\'jack\': 4098,\n\'sjoerd\': 4127}`` or ``{4098: \'jack\', 4127: \'sjoerd\'}``, or by the\n``dict`` constructor.\n\nclass class dict([arg])\n\n Return a new dictionary initialized from an optional positional\n argument or from a set of keyword arguments. If no arguments are\n given, return a new empty dictionary. If the positional argument\n *arg* is a mapping object, return a dictionary mapping the same\n keys to the same values as does the mapping object. Otherwise the\n positional argument must be a sequence, a container that supports\n iteration, or an iterator object. The elements of the argument\n must each also be of one of those kinds, and each must in turn\n contain exactly two objects. The first is used as a key in the new\n dictionary, and the second as the key\'s value. If a given key is\n seen more than once, the last value associated with it is retained\n in the new dictionary.\n\n If keyword arguments are given, the keywords themselves with their\n associated values are added as items to the dictionary. If a key is\n specified both in the positional argument and as a keyword\n argument, the value associated with the keyword is retained in the\n dictionary. For example, these all return a dictionary equal to\n ``{"one": 1, "two": 2}``:\n\n * ``dict(one=1, two=2)``\n\n * ``dict({\'one\': 1, \'two\': 2})``\n\n * ``dict(zip((\'one\', \'two\'), (1, 2)))``\n\n * ``dict([[\'two\', 2], [\'one\', 1]])``\n\n The first example only works for keys that are valid Python\n identifiers; the others work with any valid keys.\n\n New in version 2.2.\n\n Changed in version 2.3: Support for building a dictionary from\n keyword arguments added.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a ``KeyError`` if\n *key* is not in the map.\n\n New in version 2.5: If a subclass of dict defines a method\n ``__missing__()``, if the key *key* is not present, the\n ``d[key]`` operation calls that method with the key *key* as\n argument. The ``d[key]`` operation then returns or raises\n whatever is returned or raised by the ``__missing__(key)`` call\n if the key is not present. No other operations or methods invoke\n ``__missing__()``. If ``__missing__()`` is not defined,\n ``KeyError`` is raised. ``__missing__()`` must be a method; it\n cannot be an instance variable. For an example, see\n ``collections.defaultdict``.\n\n d[key] = value\n\n Set ``d[key]`` to *value*.\n\n del d[key]\n\n Remove ``d[key]`` from *d*. Raises a ``KeyError`` if *key* is\n not in the map.\n\n key in d\n\n Return ``True`` if *d* has a key *key*, else ``False``.\n\n New in version 2.2.\n\n key not in d\n\n Equivalent to ``not key in d``.\n\n New in version 2.2.\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for ``iterkeys()``.\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n ``fromkeys()`` is a class method that returns a new dictionary.\n *value* defaults to ``None``.\n\n New in version 2.3.\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to ``None``,\n so that this method never raises a ``KeyError``.\n\n has_key(key)\n\n Test for the presence of *key* in the dictionary. ``has_key()``\n is deprecated in favor of ``key in d``.\n\n items()\n\n Return a copy of the dictionary\'s list of ``(key, value)``\n pairs.\n\n **CPython implementation detail:** Keys and values are listed in\n an arbitrary order which is non-random, varies across Python\n implementations, and depends on the dictionary\'s history of\n insertions and deletions.\n\n If ``items()``, ``keys()``, ``values()``, ``iteritems()``,\n ``iterkeys()``, and ``itervalues()`` are called with no\n intervening modifications to the dictionary, the lists will\n directly correspond. This allows the creation of ``(value,\n key)`` pairs using ``zip()``: ``pairs = zip(d.values(),\n d.keys())``. The same relationship holds for the ``iterkeys()``\n and ``itervalues()`` methods: ``pairs = zip(d.itervalues(),\n d.iterkeys())`` provides the same value for ``pairs``. Another\n way to create the same list is ``pairs = [(v, k) for (k, v) in\n d.iteritems()]``.\n\n iteritems()\n\n Return an iterator over the dictionary\'s ``(key, value)`` pairs.\n See the note for ``dict.items()``.\n\n Using ``iteritems()`` while adding or deleting entries in the\n dictionary may raise a ``RuntimeError`` or fail to iterate over\n all entries.\n\n New in version 2.2.\n\n iterkeys()\n\n Return an iterator over the dictionary\'s keys. See the note for\n ``dict.items()``.\n\n Using ``iterkeys()`` while adding or deleting entries in the\n dictionary may raise a ``RuntimeError`` or fail to iterate over\n all entries.\n\n New in version 2.2.\n\n itervalues()\n\n Return an iterator over the dictionary\'s values. See the note\n for ``dict.items()``.\n\n Using ``itervalues()`` while adding or deleting entries in the\n dictionary may raise a ``RuntimeError`` or fail to iterate over\n all entries.\n\n New in version 2.2.\n\n keys()\n\n Return a copy of the dictionary\'s list of keys. See the note\n for ``dict.items()``.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a ``KeyError`` is raised.\n\n New in version 2.3.\n\n popitem()\n\n Remove and return an arbitrary ``(key, value)`` pair from the\n dictionary.\n\n ``popitem()`` is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling ``popitem()`` raises a ``KeyError``.\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to ``None``.\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return ``None``.\n\n ``update()`` accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: ``d.update(red=1,\n blue=2)``.\n\n Changed in version 2.4: Allowed the argument to be an iterable\n of key/value pairs and allowed keyword arguments.\n\n values()\n\n Return a copy of the dictionary\'s list of values. See the note\n for ``dict.items()``.\n\n viewitems()\n\n Return a new view of the dictionary\'s items (``(key, value)``\n pairs). See below for documentation of view objects.\n\n New in version 2.7.\n\n viewkeys()\n\n Return a new view of the dictionary\'s keys. See below for\n documentation of view objects.\n\n New in version 2.7.\n\n viewvalues()\n\n Return a new view of the dictionary\'s values. See below for\n documentation of view objects.\n\n New in version 2.7.\n\n\nDictionary view objects\n=======================\n\nThe objects returned by ``dict.viewkeys()``, ``dict.viewvalues()`` and\n``dict.viewitems()`` are *view objects*. They provide a dynamic view\non the dictionary\'s entries, which means that when the dictionary\nchanges, the view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of ``(key, value)``) in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of ``(value, key)`` pairs\n using ``zip()``: ``pairs = zip(d.values(), d.keys())``. Another\n way to create the same list is ``pairs = [(v, k) for (k, v) in\n d.items()]``.\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a ``RuntimeError`` or fail to iterate over all entries.\n\nx in dictview\n\n Return ``True`` if *x* is in the underlying dictionary\'s keys,\n values or items (in the latter case, *x* should be a ``(key,\n value)`` tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that (key, value) pairs are unique and\nhashable, then the items view is also set-like. (Values views are not\ntreated as set-like since the entries are generally not unique.) Then\nthese set operations are available ("other" refers either to another\nview or a set):\n\ndictview & other\n\n Return the intersection of the dictview and the other object as a\n new set.\n\ndictview | other\n\n Return the union of the dictview and the other object as a new set.\n\ndictview - other\n\n Return the difference between the dictview and the other object\n (all elements in *dictview* that aren\'t in *other*) as a new set.\n\ndictview ^ other\n\n Return the symmetric difference (all elements either in *dictview*\n or *other*, but not in both) of the dictview and the other object\n as a new set.\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.viewkeys()\n >>> values = dishes.viewvalues()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n',
- 'typesmethods': "\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as ``append()`` on\nlists) and class instance methods. Built-in methods are described\nwith the types that support them.\n\nThe implementation adds two special read-only attributes to class\ninstance methods: ``m.im_self`` is the object on which the method\noperates, and ``m.im_func`` is the function implementing the method.\nCalling ``m(arg-1, arg-2, ..., arg-n)`` is completely equivalent to\ncalling ``m.im_func(m.im_self, arg-1, arg-2, ..., arg-n)``.\n\nClass instance methods are either *bound* or *unbound*, referring to\nwhether the method was accessed through an instance or a class,\nrespectively. When a method is unbound, its ``im_self`` attribute\nwill be ``None`` and if called, an explicit ``self`` object must be\npassed as the first argument. In this case, ``self`` must be an\ninstance of the unbound method's class (or a subclass of that class),\notherwise a ``TypeError`` is raised.\n\nLike function objects, methods objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object (``meth.im_func``), setting method\nattributes on either bound or unbound methods is disallowed.\nAttempting to set a method attribute results in a ``TypeError`` being\nraised. In order to set a method attribute, you need to explicitly\nset it on the underlying function object:\n\n class C:\n def method(self):\n pass\n\n c = C()\n c.method.im_func.whoami = 'my name is c'\n\nSee *The standard type hierarchy* for more information.\n",
+ 'typesmapping': '\nMapping Types --- ``dict``\n**************************\n\nA *mapping* object maps *hashable* values to arbitrary objects.\nMappings are mutable objects. There is currently only one standard\nmapping type, the *dictionary*. (For other containers see the built\nin ``list``, ``set``, and ``tuple`` classes, and the ``collections``\nmodule.)\n\nA dictionary\'s keys are *almost* arbitrary values. Values that are\nnot *hashable*, that is, values containing lists, dictionaries or\nother mutable types (that are compared by value rather than by object\nidentity) may not be used as keys. Numeric types used for keys obey\nthe normal rules for numeric comparison: if two numbers compare equal\n(such as ``1`` and ``1.0``) then they can be used interchangeably to\nindex the same dictionary entry. (Note however, that since computers\nstore floating-point numbers as approximations it is usually unwise to\nuse them as dictionary keys.)\n\nDictionaries can be created by placing a comma-separated list of\n``key: value`` pairs within braces, for example: ``{\'jack\': 4098,\n\'sjoerd\': 4127}`` or ``{4098: \'jack\', 4127: \'sjoerd\'}``, or by the\n``dict`` constructor.\n\nclass class dict([arg])\n\n Return a new dictionary initialized from an optional positional\n argument or from a set of keyword arguments. If no arguments are\n given, return a new empty dictionary. If the positional argument\n *arg* is a mapping object, return a dictionary mapping the same\n keys to the same values as does the mapping object. Otherwise the\n positional argument must be a sequence, a container that supports\n iteration, or an iterator object. The elements of the argument\n must each also be of one of those kinds, and each must in turn\n contain exactly two objects. The first is used as a key in the new\n dictionary, and the second as the key\'s value. If a given key is\n seen more than once, the last value associated with it is retained\n in the new dictionary.\n\n If keyword arguments are given, the keywords themselves with their\n associated values are added as items to the dictionary. If a key\n is specified both in the positional argument and as a keyword\n argument, the value associated with the keyword is retained in the\n dictionary. For example, these all return a dictionary equal to\n ``{"one": 1, "two": 2}``:\n\n * ``dict(one=1, two=2)``\n\n * ``dict({\'one\': 1, \'two\': 2})``\n\n * ``dict(zip((\'one\', \'two\'), (1, 2)))``\n\n * ``dict([[\'two\', 2], [\'one\', 1]])``\n\n The first example only works for keys that are valid Python\n identifiers; the others work with any valid keys.\n\n These are the operations that dictionaries support (and therefore,\n custom mapping types should support too):\n\n len(d)\n\n Return the number of items in the dictionary *d*.\n\n d[key]\n\n Return the item of *d* with key *key*. Raises a ``KeyError`` if\n *key* is not in the map.\n\n If a subclass of dict defines a method ``__missing__()``, if the\n key *key* is not present, the ``d[key]`` operation calls that\n method with the key *key* as argument. The ``d[key]`` operation\n then returns or raises whatever is returned or raised by the\n ``__missing__(key)`` call if the key is not present. No other\n operations or methods invoke ``__missing__()``. If\n ``__missing__()`` is not defined, ``KeyError`` is raised.\n ``__missing__()`` must be a method; it cannot be an instance\n variable:\n\n >>> class Counter(dict):\n ... def __missing__(self, key):\n ... return 0\n >>> c = Counter()\n >>> c[\'red\']\n 0\n >>> c[\'red\'] += 1\n >>> c[\'red\']\n 1\n\n See ``collections.Counter`` for a complete implementation\n including other methods helpful for accumulating and managing\n tallies.\n\n d[key] = value\n\n Set ``d[key]`` to *value*.\n\n del d[key]\n\n Remove ``d[key]`` from *d*. Raises a ``KeyError`` if *key* is\n not in the map.\n\n key in d\n\n Return ``True`` if *d* has a key *key*, else ``False``.\n\n key not in d\n\n Equivalent to ``not key in d``.\n\n iter(d)\n\n Return an iterator over the keys of the dictionary. This is a\n shortcut for ``iter(d.keys())``.\n\n clear()\n\n Remove all items from the dictionary.\n\n copy()\n\n Return a shallow copy of the dictionary.\n\n classmethod fromkeys(seq[, value])\n\n Create a new dictionary with keys from *seq* and values set to\n *value*.\n\n ``fromkeys()`` is a class method that returns a new dictionary.\n *value* defaults to ``None``.\n\n get(key[, default])\n\n Return the value for *key* if *key* is in the dictionary, else\n *default*. If *default* is not given, it defaults to ``None``,\n so that this method never raises a ``KeyError``.\n\n items()\n\n Return a new view of the dictionary\'s items (``(key, value)``\n pairs). See below for documentation of view objects.\n\n keys()\n\n Return a new view of the dictionary\'s keys. See below for\n documentation of view objects.\n\n pop(key[, default])\n\n If *key* is in the dictionary, remove it and return its value,\n else return *default*. If *default* is not given and *key* is\n not in the dictionary, a ``KeyError`` is raised.\n\n popitem()\n\n Remove and return an arbitrary ``(key, value)`` pair from the\n dictionary.\n\n ``popitem()`` is useful to destructively iterate over a\n dictionary, as often used in set algorithms. If the dictionary\n is empty, calling ``popitem()`` raises a ``KeyError``.\n\n setdefault(key[, default])\n\n If *key* is in the dictionary, return its value. If not, insert\n *key* with a value of *default* and return *default*. *default*\n defaults to ``None``.\n\n update([other])\n\n Update the dictionary with the key/value pairs from *other*,\n overwriting existing keys. Return ``None``.\n\n ``update()`` accepts either another dictionary object or an\n iterable of key/value pairs (as tuples or other iterables of\n length two). If keyword arguments are specified, the dictionary\n is then updated with those key/value pairs: ``d.update(red=1,\n blue=2)``.\n\n values()\n\n Return a new view of the dictionary\'s values. See below for\n documentation of view objects.\n\n\nDictionary view objects\n=======================\n\nThe objects returned by ``dict.keys()``, ``dict.values()`` and\n``dict.items()`` are *view objects*. They provide a dynamic view on\nthe dictionary\'s entries, which means that when the dictionary\nchanges, the view reflects these changes.\n\nDictionary views can be iterated over to yield their respective data,\nand support membership tests:\n\nlen(dictview)\n\n Return the number of entries in the dictionary.\n\niter(dictview)\n\n Return an iterator over the keys, values or items (represented as\n tuples of ``(key, value)``) in the dictionary.\n\n Keys and values are iterated over in an arbitrary order which is\n non-random, varies across Python implementations, and depends on\n the dictionary\'s history of insertions and deletions. If keys,\n values and items views are iterated over with no intervening\n modifications to the dictionary, the order of items will directly\n correspond. This allows the creation of ``(value, key)`` pairs\n using ``zip()``: ``pairs = zip(d.values(), d.keys())``. Another\n way to create the same list is ``pairs = [(v, k) for (k, v) in\n d.items()]``.\n\n Iterating views while adding or deleting entries in the dictionary\n may raise a ``RuntimeError`` or fail to iterate over all entries.\n\nx in dictview\n\n Return ``True`` if *x* is in the underlying dictionary\'s keys,\n values or items (in the latter case, *x* should be a ``(key,\n value)`` tuple).\n\nKeys views are set-like since their entries are unique and hashable.\nIf all values are hashable, so that ``(key, value)`` pairs are unique\nand hashable, then the items view is also set-like. (Values views are\nnot treated as set-like since the entries are generally not unique.)\nFor set-like views, all of the operations defined for the abstract\nbase class ``collections.Set`` are available (for example, ``==``,\n``<``, or ``^``).\n\nAn example of dictionary view usage:\n\n >>> dishes = {\'eggs\': 2, \'sausage\': 1, \'bacon\': 1, \'spam\': 500}\n >>> keys = dishes.keys()\n >>> values = dishes.values()\n\n >>> # iteration\n >>> n = 0\n >>> for val in values:\n ... n += val\n >>> print(n)\n 504\n\n >>> # keys and values are iterated over in the same order\n >>> list(keys)\n [\'eggs\', \'bacon\', \'sausage\', \'spam\']\n >>> list(values)\n [2, 1, 1, 500]\n\n >>> # view objects are dynamic and reflect dict changes\n >>> del dishes[\'eggs\']\n >>> del dishes[\'sausage\']\n >>> list(keys)\n [\'spam\', \'bacon\']\n\n >>> # set operations\n >>> keys & {\'eggs\', \'bacon\', \'salad\'}\n {\'bacon\'}\n >>> keys ^ {\'sausage\', \'juice\'}\n {\'juice\', \'sausage\', \'bacon\', \'spam\'}\n',
+ 'typesmethods': "\nMethods\n*******\n\nMethods are functions that are called using the attribute notation.\nThere are two flavors: built-in methods (such as ``append()`` on\nlists) and class instance methods. Built-in methods are described\nwith the types that support them.\n\nIf you access a method (a function defined in a class namespace)\nthrough an instance, you get a special object: a *bound method* (also\ncalled *instance method*) object. When called, it will add the\n``self`` argument to the argument list. Bound methods have two\nspecial read-only attributes: ``m.__self__`` is the object on which\nthe method operates, and ``m.__func__`` is the function implementing\nthe method. Calling ``m(arg-1, arg-2, ..., arg-n)`` is completely\nequivalent to calling ``m.__func__(m.__self__, arg-1, arg-2, ...,\narg-n)``.\n\nLike function objects, bound method objects support getting arbitrary\nattributes. However, since method attributes are actually stored on\nthe underlying function object (``meth.__func__``), setting method\nattributes on bound methods is disallowed. Attempting to set a method\nattribute results in a ``TypeError`` being raised. In order to set a\nmethod attribute, you need to explicitly set it on the underlying\nfunction object:\n\n class C:\n def method(self):\n pass\n\n c = C()\n c.method.__func__.whoami = 'my name is c'\n\nSee *The standard type hierarchy* for more information.\n",
'typesmodules': "\nModules\n*******\n\nThe only special operation on a module is attribute access:\n``m.name``, where *m* is a module and *name* accesses a name defined\nin *m*'s symbol table. Module attributes can be assigned to. (Note\nthat the ``import`` statement is not, strictly speaking, an operation\non a module object; ``import foo`` does not require a module object\nnamed *foo* to exist, rather it requires an (external) *definition*\nfor a module named *foo* somewhere.)\n\nA special attribute of every module is ``__dict__``. This is the\ndictionary containing the module's symbol table. Modifying this\ndictionary will actually change the module's symbol table, but direct\nassignment to the ``__dict__`` attribute is not possible (you can\nwrite ``m.__dict__['a'] = 1``, which defines ``m.a`` to be ``1``, but\nyou can't write ``m.__dict__ = {}``). Modifying ``__dict__`` directly\nis not recommended.\n\nModules built into the interpreter are written like this: ``<module\n'sys' (built-in)>``. If loaded from a file, they are written as\n``<module 'os' from '/usr/local/lib/pythonX.Y/os.pyc'>``.\n",
- 'typesseq': '\nSequence Types --- ``str``, ``unicode``, ``list``, ``tuple``, ``bytearray``, ``buffer``, ``xrange``\n***************************************************************************************************\n\nThere are seven sequence types: strings, Unicode strings, lists,\ntuples, bytearrays, buffers, and xrange objects.\n\nFor other containers see the built in ``dict`` and ``set`` classes,\nand the ``collections`` module.\n\nString literals are written in single or double quotes: ``\'xyzzy\'``,\n``"frobozz"``. See *String literals* for more about string literals.\nUnicode strings are much like strings, but are specified in the syntax\nusing a preceding ``\'u\'`` character: ``u\'abc\'``, ``u"def"``. In\naddition to the functionality described here, there are also string-\nspecific methods described in the *String Methods* section. Lists are\nconstructed with square brackets, separating items with commas: ``[a,\nb, c]``. Tuples are constructed by the comma operator (not within\nsquare brackets), with or without enclosing parentheses, but an empty\ntuple must have the enclosing parentheses, such as ``a, b, c`` or\n``()``. A single item tuple must have a trailing comma, such as\n``(d,)``.\n\nBytearray objects are created with the built-in function\n``bytearray()``.\n\nBuffer objects are not directly supported by Python syntax, but can be\ncreated by calling the built-in function ``buffer()``. They don\'t\nsupport concatenation or repetition.\n\nObjects of type xrange are similar to buffers in that there is no\nspecific syntax to create them, but they are created using the\n``xrange()`` function. They don\'t support slicing, concatenation or\nrepetition, and using ``in``, ``not in``, ``min()`` or ``max()`` on\nthem is inefficient.\n\nMost sequence types support the following operations. The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations. The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority). In the table,\n*s* and *t* are sequences of the same type; *n*, *i* and *j* are\nintegers:\n\n+--------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+====================+==================================+============+\n| ``x in s`` | ``True`` if an item of *s* is | (1) |\n| | equal to *x*, else ``False`` | |\n+--------------------+----------------------------------+------------+\n| ``x not in s`` | ``False`` if an item of *s* is | (1) |\n| | equal to *x*, else ``True`` | |\n+--------------------+----------------------------------+------------+\n| ``s + t`` | the concatenation of *s* and *t* | (6) |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s`` | *n* shallow copies of *s* | (2) |\n| | concatenated | |\n+--------------------+----------------------------------+------------+\n| ``s[i]`` | *i*th item of *s*, origin 0 | (3) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]`` | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+--------------------+----------------------------------+------------+\n| ``len(s)`` | length of *s* | |\n+--------------------+----------------------------------+------------+\n| ``min(s)`` | smallest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``max(s)`` | largest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.index(i)`` | index of the first occurence of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.count(i)`` | total number of occurences of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons. In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements. This means that to compare equal, every element must compare\nequal and the two sequences must be of the same type and have the same\nlength. (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string or Unicode string object the ``in`` and ``not\n in`` operations act like a substring test. In Python versions\n before 2.3, *x* had to be a string of length 1. In Python 2.3 and\n beyond, *x* may be a string of any length.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that ``[[]]`` is a one-element list containing\n an empty list, so all three elements of ``[[]] * 3`` are (pointers\n to) this single empty list. Modifying any of the elements of\n ``lists`` modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n string: ``len(s) + i`` or ``len(s) + j`` is substituted. But note\n that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that ``i <= k < j``. If *i* or *j* is\n greater than ``len(s)``, use ``len(s)``. If *i* is omitted or\n ``None``, use ``0``. If *j* is omitted or ``None``, use\n ``len(s)``. If *i* is greater than or equal to *j*, the slice is\n empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index ``x = i + n*k`` such that ``0 <= n <\n (j-i)/k``. In other words, the indices are ``i``, ``i+k``,\n ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n never including *j*). If *i* or *j* is greater than ``len(s)``,\n use ``len(s)``. If *i* or *j* are omitted or ``None``, they become\n "end" values (which end depends on the sign of *k*). Note, *k*\n cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. **CPython implementation detail:** If *s* and *t* are both strings,\n some Python implementations such as CPython can usually perform an\n in-place optimization for assignments of the form ``s = s + t`` or\n ``s += t``. When applicable, this optimization makes quadratic\n run-time much less likely. This optimization is both version and\n implementation dependent. For performance sensitive code, it is\n preferable to use the ``str.join()`` method which assures\n consistent linear concatenation performance across versions and\n implementations.\n\n Changed in version 2.4: Formerly, string concatenation never\n occurred in-place.\n\n\nString Methods\n==============\n\nBelow are listed the string methods which both 8-bit strings and\nUnicode objects support. Some of them are also available on\n``bytearray`` objects.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, unicode, list, tuple,\nbytearray, buffer, xrange* section. To output formatted strings use\ntemplate strings or the ``%`` operator described in the *String\nFormatting Operations* section. Also, see the ``re`` module for string\nfunctions based on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.decode([encoding[, errors]])\n\n Decodes the string using the codec registered for *encoding*.\n *encoding* defaults to the default string encoding. *errors* may\n be given to set a different error handling scheme. The default is\n ``\'strict\'``, meaning that encoding errors raise ``UnicodeError``.\n Other possible values are ``\'ignore\'``, ``\'replace\'`` and any other\n name registered via ``codecs.register_error()``, see section *Codec\n Base Classes*.\n\n New in version 2.2.\n\n Changed in version 2.3: Support for other error handling schemes\n added.\n\n Changed in version 2.7: Support for keyword arguments added.\n\nstr.encode([encoding[, errors]])\n\n Return an encoded version of the string. Default encoding is the\n current default string encoding. *errors* may be given to set a\n different error handling scheme. The default for *errors* is\n ``\'strict\'``, meaning that encoding errors raise a\n ``UnicodeError``. Other possible values are ``\'ignore\'``,\n ``\'replace\'``, ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and\n any other name registered via ``codecs.register_error()``, see\n section *Codec Base Classes*. For a list of possible encodings, see\n section *Standard Encodings*.\n\n New in version 2.0.\n\n Changed in version 2.3: Support for ``\'xmlcharrefreplace\'`` and\n ``\'backslashreplace\'`` and other error handling schemes added.\n\n Changed in version 2.7: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\n Changed in version 2.5: Accept tuples as *suffix*.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by one or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\n Note: The ``find()`` method should be used only if you need to know the\n position of *sub*. To check if *sub* is a substring or not, use\n the ``in`` operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\n This method of string formatting is the new standard in Python 3.0,\n and should be preferred to the ``%`` formatting described in\n *String Formatting Operations* in new code.\n\n New in version 2.6.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. The separator between elements is the\n string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\n New in version 2.5.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\n Changed in version 2.4: Support for the *fillchar* argument.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\n New in version 2.5.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\n New in version 2.4.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\n Changed in version 2.5: Accept tuples as *prefix*.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\n Changed in version 2.2.2: Support for the *chars* argument.\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.translate(table[, deletechars])\n\n Return a copy of the string where all characters occurring in the\n optional argument *deletechars* are removed, and the remaining\n characters have been mapped through the given translation table,\n which must be a string of length 256.\n\n You can use the ``maketrans()`` helper function in the ``string``\n module to create a translation table. For string objects, set the\n *table* argument to ``None`` for translations that only delete\n characters:\n\n >>> \'read this short text\'.translate(None, \'aeiou\')\n \'rd ths shrt txt\'\n\n New in version 2.6: Support for a ``None`` *table* argument.\n\n For Unicode objects, the ``translate()`` method does not accept the\n optional *deletechars* argument. Instead, it returns a copy of the\n *s* where all characters have been mapped through the given\n translation table which must be a mapping of Unicode ordinals to\n Unicode ordinals, Unicode strings or ``None``. Unmapped characters\n are left untouched. Characters mapped to ``None`` are deleted.\n Note, a more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see ``encodings.cp1251``\n for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that ``str.upper().isupper()`` might\n be ``False`` if ``s`` contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\n For 8-bit strings, this method is locale-dependent.\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than or equal to ``len(s)``.\n\n New in version 2.2.2.\n\nThe following methods are present only on unicode objects:\n\nunicode.isnumeric()\n\n Return ``True`` if there are only numeric characters in S,\n ``False`` otherwise. Numeric characters include digit characters,\n and all characters that have the Unicode numeric value property,\n e.g. U+2155, VULGAR FRACTION ONE FIFTH.\n\nunicode.isdecimal()\n\n Return ``True`` if there are only decimal characters in S,\n ``False`` otherwise. Decimal characters include digit characters,\n and all characters that can be used to form decimal-radix numbers,\n e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\n\nString Formatting Operations\n============================\n\nString and Unicode objects have one unique built-in operation: the\n``%`` operator (modulo). This is also known as the string\n*formatting* or *interpolation* operator. Given ``format % values``\n(where *format* is a string or Unicode object), ``%`` conversion\nspecifications in *format* are replaced with zero or more elements of\n*values*. The effect is similar to the using ``sprintf()`` in the C\nlanguage. If *format* is a Unicode object, or if any of the objects\nbeing converted using the ``%s`` conversion are Unicode objects, the\nresult will also be a Unicode object.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [5] Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n conversion types.\n\n4. Minimum field width (optional). If specified as an ``\'*\'``\n (asterisk), the actual width is read from the next element of the\n tuple in *values*, and the object to convert comes after the\n minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n precision. If specified as ``\'*\'`` (an asterisk), the actual width\n is read from the next element of the tuple in *values*, and the\n value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print \'%(language)s has %(number)03d quote types.\' % \\\n... {"language": "Python", "number": 2}\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag | Meaning |\n+===========+=======================================================================+\n| ``\'#\'`` | The value conversion will use the "alternate form" (where defined |\n| | below). |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'`` | The conversion will be zero padded for numeric values. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'`` | The converted value is left adjusted (overrides the ``\'0\'`` |\n| | conversion if both are given). |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'`` | (a space) A blank should be left before a positive number (or empty |\n| | string) produced by a signed conversion. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'`` | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion |\n| | (overrides a "space" flag). |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion | Meaning | Notes |\n+==============+=======================================================+=========+\n| ``\'d\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'`` | Signed octal value. | (1) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'`` | Obsolete type -- it is identical to ``\'d\'``. | (7) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'`` | Signed hexadecimal (lowercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'`` | Signed hexadecimal (uppercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'`` | Floating point exponential format (lowercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'`` | Floating point exponential format (uppercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'`` | Floating point format. Uses lowercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'`` | Floating point format. Uses uppercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'`` | Single character (accepts integer or single character | |\n| | string). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'`` | String (converts any Python object using ``repr()``). | (5) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'`` | String (converts any Python object using ``str()``). | (6) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'`` | No argument is converted, results in a ``\'%\'`` | |\n| | character in the result. | |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n point, even if no digits follow it.\n\n The precision determines the number of digits after the decimal\n point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n point, and trailing zeroes are not removed as they would otherwise\n be.\n\n The precision determines the number of significant digits before\n and after the decimal point and defaults to 6.\n\n5. The ``%r`` conversion was added in Python 2.0.\n\n The precision determines the maximal number of characters used.\n\n6. If the object or format provided is a ``unicode`` string, the\n resulting string will also be ``unicode``.\n\n The precision determines the maximal number of characters used.\n\n7. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 2.7: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nXRange Type\n===========\n\nThe ``xrange`` type is an immutable sequence which is commonly used\nfor looping. The advantage of the ``xrange`` type is that an\n``xrange`` object will always take the same amount of memory, no\nmatter the size of the range it represents. There are no consistent\nperformance advantages.\n\nXRange objects have very little behavior: they only support indexing,\niteration, and the ``len()`` function.\n\n\nMutable Sequence Types\n======================\n\nList and ``bytearray`` objects support additional operations that\nallow in-place modification of the object. Other mutable sequence\ntypes (when added to the language) should also support these\noperations. Strings and tuples are immutable sequence types: such\nobjects cannot be modified once created. The following operations are\ndefined on mutable sequence types (where *x* is an arbitrary object):\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | (2) |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (4) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (5) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (6) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (7) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([cmp[, key[, | sort the items of *s* in place | (7)(8)(9)(10) |\n| reverse]]])`` | | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The C implementation of Python has historically accepted multiple\n parameters and implicitly joined them into a tuple; this no longer\n works in Python 2.0. Use of this misfeature has been deprecated\n since Python 1.4.\n\n3. *x* can be any iterable object.\n\n4. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the list length is added, as for slice indices. If it is\n still negative, it is truncated to zero, as for slice indices.\n\n Changed in version 2.3: Previously, ``index()`` didn\'t have\n arguments for specifying start and stop positions.\n\n5. When a negative index is passed as the first parameter to the\n ``insert()`` method, the list length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n Changed in version 2.3: Previously, all negative indices were\n truncated to zero.\n\n6. The ``pop()`` method is only supported by the list and array types.\n The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n7. The ``sort()`` and ``reverse()`` methods modify the list in place\n for economy of space when sorting or reversing a large list. To\n remind you that they operate by side effect, they don\'t return the\n sorted or reversed list.\n\n8. The ``sort()`` method takes optional arguments for controlling the\n comparisons.\n\n *cmp* specifies a custom comparison function of two arguments (list\n items) which should return a negative, zero or positive number\n depending on whether the first argument is considered smaller than,\n equal to, or larger than the second argument: ``cmp=lambda x,y:\n cmp(x.lower(), y.lower())``. The default value is ``None``.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n In general, the *key* and *reverse* conversion processes are much\n faster than specifying an equivalent *cmp* function. This is\n because *cmp* is called multiple times for each list element while\n *key* and *reverse* touch each element only once. Use\n ``functools.cmp_to_key()`` to convert an old-style *cmp* function\n to a *key* function.\n\n Changed in version 2.3: Support for ``None`` as an equivalent to\n omitting *cmp* was added.\n\n Changed in version 2.4: Support for *key* and *reverse* was added.\n\n9. Starting with Python 2.3, the ``sort()`` method is guaranteed to be\n stable. A sort is stable if it guarantees not to change the\n relative order of elements that compare equal --- this is helpful\n for sorting in multiple passes (for example, sort by department,\n then by salary grade).\n\n10. **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python 2.3 and newer makes the\n list appear empty for the duration, and raises ``ValueError`` if\n it can detect that the list has been mutated during a sort.\n',
- 'typesseq-mutable': "\nMutable Sequence Types\n**********************\n\nList and ``bytearray`` objects support additional operations that\nallow in-place modification of the object. Other mutable sequence\ntypes (when added to the language) should also support these\noperations. Strings and tuples are immutable sequence types: such\nobjects cannot be modified once created. The following operations are\ndefined on mutable sequence types (where *x* is an arbitrary object):\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | (2) |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (4) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (5) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (6) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (7) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([cmp[, key[, | sort the items of *s* in place | (7)(8)(9)(10) |\n| reverse]]])`` | | |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. The C implementation of Python has historically accepted multiple\n parameters and implicitly joined them into a tuple; this no longer\n works in Python 2.0. Use of this misfeature has been deprecated\n since Python 1.4.\n\n3. *x* can be any iterable object.\n\n4. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the list length is added, as for slice indices. If it is\n still negative, it is truncated to zero, as for slice indices.\n\n Changed in version 2.3: Previously, ``index()`` didn't have\n arguments for specifying start and stop positions.\n\n5. When a negative index is passed as the first parameter to the\n ``insert()`` method, the list length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n Changed in version 2.3: Previously, all negative indices were\n truncated to zero.\n\n6. The ``pop()`` method is only supported by the list and array types.\n The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n7. The ``sort()`` and ``reverse()`` methods modify the list in place\n for economy of space when sorting or reversing a large list. To\n remind you that they operate by side effect, they don't return the\n sorted or reversed list.\n\n8. The ``sort()`` method takes optional arguments for controlling the\n comparisons.\n\n *cmp* specifies a custom comparison function of two arguments (list\n items) which should return a negative, zero or positive number\n depending on whether the first argument is considered smaller than,\n equal to, or larger than the second argument: ``cmp=lambda x,y:\n cmp(x.lower(), y.lower())``. The default value is ``None``.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n In general, the *key* and *reverse* conversion processes are much\n faster than specifying an equivalent *cmp* function. This is\n because *cmp* is called multiple times for each list element while\n *key* and *reverse* touch each element only once. Use\n ``functools.cmp_to_key()`` to convert an old-style *cmp* function\n to a *key* function.\n\n Changed in version 2.3: Support for ``None`` as an equivalent to\n omitting *cmp* was added.\n\n Changed in version 2.4: Support for *key* and *reverse* was added.\n\n9. Starting with Python 2.3, the ``sort()`` method is guaranteed to be\n stable. A sort is stable if it guarantees not to change the\n relative order of elements that compare equal --- this is helpful\n for sorting in multiple passes (for example, sort by department,\n then by salary grade).\n\n10. **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python 2.3 and newer makes the\n list appear empty for the duration, and raises ``ValueError`` if\n it can detect that the list has been mutated during a sort.\n",
- 'unary': '\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary ``-`` (minus) operator yields the negation of its numeric\nargument.\n\nThe unary ``+`` (plus) operator yields its numeric argument unchanged.\n\nThe unary ``~`` (invert) operator yields the bitwise inversion of its\nplain or long integer argument. The bitwise inversion of ``x`` is\ndefined as ``-(x+1)``. It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n``TypeError`` exception is raised.\n',
+ 'typesseq': '\nSequence Types --- ``str``, ``bytes``, ``bytearray``, ``list``, ``tuple``, ``range``\n************************************************************************************\n\nThere are six sequence types: strings, byte sequences (``bytes``\nobjects), byte arrays (``bytearray`` objects), lists, tuples, and\nrange objects. For other containers see the built in ``dict`` and\n``set`` classes, and the ``collections`` module.\n\nStrings contain Unicode characters. Their literals are written in\nsingle or double quotes: ``\'xyzzy\'``, ``"frobozz"``. See *String and\nBytes literals* for more about string literals. In addition to the\nfunctionality described here, there are also string-specific methods\ndescribed in the *String Methods* section.\n\nBytes and bytearray objects contain single bytes -- the former is\nimmutable while the latter is a mutable sequence. Bytes objects can\nbe constructed the constructor, ``bytes()``, and from literals; use a\n``b`` prefix with normal string syntax: ``b\'xyzzy\'``. To construct\nbyte arrays, use the ``bytearray()`` function.\n\nWhile string objects are sequences of characters (represented by\nstrings of length 1), bytes and bytearray objects are sequences of\n*integers* (between 0 and 255), representing the ASCII value of single\nbytes. That means that for a bytes or bytearray object *b*, ``b[0]``\nwill be an integer, while ``b[0:1]`` will be a bytes or bytearray\nobject of length 1. The representation of bytes objects uses the\nliteral format (``b\'...\'``) since it is generally more useful than\ne.g. ``bytes([50, 19, 100])``. You can always convert a bytes object\ninto a list of integers using ``list(b)``.\n\nAlso, while in previous Python versions, byte strings and Unicode\nstrings could be exchanged for each other rather freely (barring\nencoding issues), strings and bytes are now completely separate\nconcepts. There\'s no implicit en-/decoding if you pass an object of\nthe wrong type. A string always compares unequal to a bytes or\nbytearray object.\n\nLists are constructed with square brackets, separating items with\ncommas: ``[a, b, c]``. Tuples are constructed by the comma operator\n(not within square brackets), with or without enclosing parentheses,\nbut an empty tuple must have the enclosing parentheses, such as ``a,\nb, c`` or ``()``. A single item tuple must have a trailing comma,\nsuch as ``(d,)``.\n\nObjects of type range are created using the ``range()`` function.\nThey don\'t support concatenation or repetition, and using ``min()`` or\n``max()`` on them is inefficient.\n\nMost sequence types support the following operations. The ``in`` and\n``not in`` operations have the same priorities as the comparison\noperations. The ``+`` and ``*`` operations have the same priority as\nthe corresponding numeric operations. [3] Additional methods are\nprovided for *Mutable Sequence Types*.\n\nThis table lists the sequence operations sorted in ascending priority\n(operations in the same box have the same priority). In the table,\n*s* and *t* are sequences of the same type; *n*, *i*, *j* and *k* are\nintegers.\n\n+--------------------+----------------------------------+------------+\n| Operation | Result | Notes |\n+====================+==================================+============+\n| ``x in s`` | ``True`` if an item of *s* is | (1) |\n| | equal to *x*, else ``False`` | |\n+--------------------+----------------------------------+------------+\n| ``x not in s`` | ``False`` if an item of *s* is | (1) |\n| | equal to *x*, else ``True`` | |\n+--------------------+----------------------------------+------------+\n| ``s + t`` | the concatenation of *s* and *t* | (6) |\n+--------------------+----------------------------------+------------+\n| ``s * n, n * s`` | *n* shallow copies of *s* | (2) |\n| | concatenated | |\n+--------------------+----------------------------------+------------+\n| ``s[i]`` | *i*th item of *s*, origin 0 | (3) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j]`` | slice of *s* from *i* to *j* | (3)(4) |\n+--------------------+----------------------------------+------------+\n| ``s[i:j:k]`` | slice of *s* from *i* to *j* | (3)(5) |\n| | with step *k* | |\n+--------------------+----------------------------------+------------+\n| ``len(s)`` | length of *s* | |\n+--------------------+----------------------------------+------------+\n| ``min(s)`` | smallest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``max(s)`` | largest item of *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.index(i)`` | index of the first occurence of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n| ``s.count(i)`` | total number of occurences of | |\n| | *i* in *s* | |\n+--------------------+----------------------------------+------------+\n\nSequence types also support comparisons. In particular, tuples and\nlists are compared lexicographically by comparing corresponding\nelements. This means that to compare equal, every element must\ncompare equal and the two sequences must be of the same type and have\nthe same length. (For full details see *Comparisons* in the language\nreference.)\n\nNotes:\n\n1. When *s* is a string object, the ``in`` and ``not in`` operations\n act like a substring test.\n\n2. Values of *n* less than ``0`` are treated as ``0`` (which yields an\n empty sequence of the same type as *s*). Note also that the copies\n are shallow; nested structures are not copied. This often haunts\n new Python programmers; consider:\n\n >>> lists = [[]] * 3\n >>> lists\n [[], [], []]\n >>> lists[0].append(3)\n >>> lists\n [[3], [3], [3]]\n\n What has happened is that ``[[]]`` is a one-element list containing\n an empty list, so all three elements of ``[[]] * 3`` are (pointers\n to) this single empty list. Modifying any of the elements of\n ``lists`` modifies this single list. You can create a list of\n different lists this way:\n\n >>> lists = [[] for i in range(3)]\n >>> lists[0].append(3)\n >>> lists[1].append(5)\n >>> lists[2].append(7)\n >>> lists\n [[3], [5], [7]]\n\n3. If *i* or *j* is negative, the index is relative to the end of the\n string: ``len(s) + i`` or ``len(s) + j`` is substituted. But note\n that ``-0`` is still ``0``.\n\n4. The slice of *s* from *i* to *j* is defined as the sequence of\n items with index *k* such that ``i <= k < j``. If *i* or *j* is\n greater than ``len(s)``, use ``len(s)``. If *i* is omitted or\n ``None``, use ``0``. If *j* is omitted or ``None``, use\n ``len(s)``. If *i* is greater than or equal to *j*, the slice is\n empty.\n\n5. The slice of *s* from *i* to *j* with step *k* is defined as the\n sequence of items with index ``x = i + n*k`` such that ``0 <= n <\n (j-i)/k``. In other words, the indices are ``i``, ``i+k``,\n ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but\n never including *j*). If *i* or *j* is greater than ``len(s)``,\n use ``len(s)``. If *i* or *j* are omitted or ``None``, they become\n "end" values (which end depends on the sign of *k*). Note, *k*\n cannot be zero. If *k* is ``None``, it is treated like ``1``.\n\n6. Concatenating immutable strings always results in a new object.\n This means that building up a string by repeated concatenation will\n have a quadratic runtime cost in the total string length. To get a\n linear runtime cost, you must switch to one of the alternatives\n below:\n\n * if concatenating ``str`` objects, you can build a list and use\n ``str.join()`` at the end;\n\n * if concatenating ``bytes`` objects, you can similarly use\n ``bytes.join()``, or you can do in-place concatenation with a\n ``bytearray`` object. ``bytearray`` objects are mutable and have\n an efficient overallocation mechanism.\n\n\nString Methods\n==============\n\nString objects support the methods listed below.\n\nIn addition, Python\'s strings support the sequence type methods\ndescribed in the *Sequence Types --- str, bytes, bytearray, list,\ntuple, range* section. To output formatted strings, see the *String\nFormatting* section. Also, see the ``re`` module for string functions\nbased on regular expressions.\n\nstr.capitalize()\n\n Return a copy of the string with its first character capitalized\n and the rest lowercased.\n\nstr.center(width[, fillchar])\n\n Return centered in a string of length *width*. Padding is done\n using the specified *fillchar* (default is a space).\n\nstr.count(sub[, start[, end]])\n\n Return the number of non-overlapping occurrences of substring *sub*\n in the range [*start*, *end*]. Optional arguments *start* and\n *end* are interpreted as in slice notation.\n\nstr.encode(encoding="utf-8", errors="strict")\n\n Return an encoded version of the string as a bytes object. Default\n encoding is ``\'utf-8\'``. *errors* may be given to set a different\n error handling scheme. The default for *errors* is ``\'strict\'``,\n meaning that encoding errors raise a ``UnicodeError``. Other\n possible values are ``\'ignore\'``, ``\'replace\'``,\n ``\'xmlcharrefreplace\'``, ``\'backslashreplace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Support for keyword arguments added.\n\nstr.endswith(suffix[, start[, end]])\n\n Return ``True`` if the string ends with the specified *suffix*,\n otherwise return ``False``. *suffix* can also be a tuple of\n suffixes to look for. With optional *start*, test beginning at\n that position. With optional *end*, stop comparing at that\n position.\n\nstr.expandtabs([tabsize])\n\n Return a copy of the string where all tab characters are replaced\n by zero or more spaces, depending on the current column and the\n given tab size. The column number is reset to zero after each\n newline occurring in the string. If *tabsize* is not given, a tab\n size of ``8`` characters is assumed. This doesn\'t understand other\n non-printing characters or escape sequences.\n\nstr.find(sub[, start[, end]])\n\n Return the lowest index in the string where substring *sub* is\n found, such that *sub* is contained in the slice ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` if *sub* is not found.\n\n Note: The ``find()`` method should be used only if you need to know the\n position of *sub*. To check if *sub* is a substring or not, use\n the ``in`` operator:\n\n >>> \'Py\' in \'Python\'\n True\n\nstr.format(*args, **kwargs)\n\n Perform a string formatting operation. The string on which this\n method is called can contain literal text or replacement fields\n delimited by braces ``{}``. Each replacement field contains either\n the numeric index of a positional argument, or the name of a\n keyword argument. Returns a copy of the string where each\n replacement field is replaced with the string value of the\n corresponding argument.\n\n >>> "The sum of 1 + 2 is {0}".format(1+2)\n \'The sum of 1 + 2 is 3\'\n\n See *Format String Syntax* for a description of the various\n formatting options that can be specified in format strings.\n\nstr.format_map(mapping)\n\n Similar to ``str.format(**mapping)``, except that ``mapping`` is\n used directly and not copied to a ``dict`` . This is useful if for\n example ``mapping`` is a dict subclass:\n\n >>> class Default(dict):\n ... def __missing__(self, key):\n ... return key\n ...\n >>> \'{name} was born in {country}\'.format_map(Default(name=\'Guido\'))\n \'Guido was born in country\'\n\n New in version 3.2.\n\nstr.index(sub[, start[, end]])\n\n Like ``find()``, but raise ``ValueError`` when the substring is not\n found.\n\nstr.isalnum()\n\n Return true if all characters in the string are alphanumeric and\n there is at least one character, false otherwise. A character\n ``c`` is alphanumeric if one of the following returns ``True``:\n ``c.isalpha()``, ``c.isdecimal()``, ``c.isdigit()``, or\n ``c.isnumeric()``.\n\nstr.isalpha()\n\n Return true if all characters in the string are alphabetic and\n there is at least one character, false otherwise. Alphabetic\n characters are those characters defined in the Unicode character\n database as "Letter", i.e., those with general category property\n being one of "Lm", "Lt", "Lu", "Ll", or "Lo". Note that this is\n different from the "Alphabetic" property defined in the Unicode\n Standard.\n\nstr.isdecimal()\n\n Return true if all characters in the string are decimal characters\n and there is at least one character, false otherwise. Decimal\n characters are those from general category "Nd". This category\n includes digit characters, and all characters that can be used to\n form decimal-radix numbers, e.g. U+0660, ARABIC-INDIC DIGIT ZERO.\n\nstr.isdigit()\n\n Return true if all characters in the string are digits and there is\n at least one character, false otherwise. Digits include decimal\n characters and digits that need special handling, such as the\n compatibility superscript digits. Formally, a digit is a character\n that has the property value Numeric_Type=Digit or\n Numeric_Type=Decimal.\n\nstr.isidentifier()\n\n Return true if the string is a valid identifier according to the\n language definition, section *Identifiers and keywords*.\n\nstr.islower()\n\n Return true if all cased characters [4] in the string are lowercase\n and there is at least one cased character, false otherwise.\n\nstr.isnumeric()\n\n Return true if all characters in the string are numeric characters,\n and there is at least one character, false otherwise. Numeric\n characters include digit characters, and all characters that have\n the Unicode numeric value property, e.g. U+2155, VULGAR FRACTION\n ONE FIFTH. Formally, numeric characters are those with the\n property value Numeric_Type=Digit, Numeric_Type=Decimal or\n Numeric_Type=Numeric.\n\nstr.isprintable()\n\n Return true if all characters in the string are printable or the\n string is empty, false otherwise. Nonprintable characters are\n those characters defined in the Unicode character database as\n "Other" or "Separator", excepting the ASCII space (0x20) which is\n considered printable. (Note that printable characters in this\n context are those which should not be escaped when ``repr()`` is\n invoked on a string. It has no bearing on the handling of strings\n written to ``sys.stdout`` or ``sys.stderr``.)\n\nstr.isspace()\n\n Return true if there are only whitespace characters in the string\n and there is at least one character, false otherwise. Whitespace\n characters are those characters defined in the Unicode character\n database as "Other" or "Separator" and those with bidirectional\n property being one of "WS", "B", or "S".\n\nstr.istitle()\n\n Return true if the string is a titlecased string and there is at\n least one character, for example uppercase characters may only\n follow uncased characters and lowercase characters only cased ones.\n Return false otherwise.\n\nstr.isupper()\n\n Return true if all cased characters [4] in the string are uppercase\n and there is at least one cased character, false otherwise.\n\nstr.join(iterable)\n\n Return a string which is the concatenation of the strings in the\n *iterable* *iterable*. A ``TypeError`` will be raised if there are\n any non-string values in *iterable*, including ``bytes`` objects.\n The separator between elements is the string providing this method.\n\nstr.ljust(width[, fillchar])\n\n Return the string left justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\nstr.lower()\n\n Return a copy of the string with all the cased characters [4]\n converted to lowercase.\n\nstr.lstrip([chars])\n\n Return a copy of the string with leading characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a prefix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.lstrip()\n \'spacious \'\n >>> \'www.example.com\'.lstrip(\'cmowz.\')\n \'example.com\'\n\nstatic str.maketrans(x[, y[, z]])\n\n This static method returns a translation table usable for\n ``str.translate()``.\n\n If there is only one argument, it must be a dictionary mapping\n Unicode ordinals (integers) or characters (strings of length 1) to\n Unicode ordinals, strings (of arbitrary lengths) or None.\n Character keys will then be converted to ordinals.\n\n If there are two arguments, they must be strings of equal length,\n and in the resulting dictionary, each character in x will be mapped\n to the character at the same position in y. If there is a third\n argument, it must be a string, whose characters will be mapped to\n None in the result.\n\nstr.partition(sep)\n\n Split the string at the first occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing the string itself, followed by\n two empty strings.\n\nstr.replace(old, new[, count])\n\n Return a copy of the string with all occurrences of substring *old*\n replaced by *new*. If the optional argument *count* is given, only\n the first *count* occurrences are replaced.\n\nstr.rfind(sub[, start[, end]])\n\n Return the highest index in the string where substring *sub* is\n found, such that *sub* is contained within ``s[start:end]``.\n Optional arguments *start* and *end* are interpreted as in slice\n notation. Return ``-1`` on failure.\n\nstr.rindex(sub[, start[, end]])\n\n Like ``rfind()`` but raises ``ValueError`` when the substring *sub*\n is not found.\n\nstr.rjust(width[, fillchar])\n\n Return the string right justified in a string of length *width*.\n Padding is done using the specified *fillchar* (default is a\n space). The original string is returned if *width* is less than or\n equal to ``len(s)``.\n\nstr.rpartition(sep)\n\n Split the string at the last occurrence of *sep*, and return a\n 3-tuple containing the part before the separator, the separator\n itself, and the part after the separator. If the separator is not\n found, return a 3-tuple containing two empty strings, followed by\n the string itself.\n\nstr.rsplit([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit* splits\n are done, the *rightmost* ones. If *sep* is not specified or\n ``None``, any whitespace string is a separator. Except for\n splitting from the right, ``rsplit()`` behaves like ``split()``\n which is described in detail below.\n\nstr.rstrip([chars])\n\n Return a copy of the string with trailing characters removed. The\n *chars* argument is a string specifying the set of characters to be\n removed. If omitted or ``None``, the *chars* argument defaults to\n removing whitespace. The *chars* argument is not a suffix; rather,\n all combinations of its values are stripped:\n\n >>> \' spacious \'.rstrip()\n \' spacious\'\n >>> \'mississippi\'.rstrip(\'ipz\')\n \'mississ\'\n\nstr.split([sep[, maxsplit]])\n\n Return a list of the words in the string, using *sep* as the\n delimiter string. If *maxsplit* is given, at most *maxsplit*\n splits are done (thus, the list will have at most ``maxsplit+1``\n elements). If *maxsplit* is not specified, then there is no limit\n on the number of splits (all possible splits are made).\n\n If *sep* is given, consecutive delimiters are not grouped together\n and are deemed to delimit empty strings (for example,\n ``\'1,,2\'.split(\',\')`` returns ``[\'1\', \'\', \'2\']``). The *sep*\n argument may consist of multiple characters (for example,\n ``\'1<>2<>3\'.split(\'<>\')`` returns ``[\'1\', \'2\', \'3\']``). Splitting\n an empty string with a specified separator returns ``[\'\']``.\n\n If *sep* is not specified or is ``None``, a different splitting\n algorithm is applied: runs of consecutive whitespace are regarded\n as a single separator, and the result will contain no empty strings\n at the start or end if the string has leading or trailing\n whitespace. Consequently, splitting an empty string or a string\n consisting of just whitespace with a ``None`` separator returns\n ``[]``.\n\n For example, ``\' 1 2 3 \'.split()`` returns ``[\'1\', \'2\', \'3\']``,\n and ``\' 1 2 3 \'.split(None, 1)`` returns ``[\'1\', \'2 3 \']``.\n\nstr.splitlines([keepends])\n\n Return a list of the lines in the string, breaking at line\n boundaries. Line breaks are not included in the resulting list\n unless *keepends* is given and true.\n\nstr.startswith(prefix[, start[, end]])\n\n Return ``True`` if string starts with the *prefix*, otherwise\n return ``False``. *prefix* can also be a tuple of prefixes to look\n for. With optional *start*, test string beginning at that\n position. With optional *end*, stop comparing string at that\n position.\n\nstr.strip([chars])\n\n Return a copy of the string with the leading and trailing\n characters removed. The *chars* argument is a string specifying the\n set of characters to be removed. If omitted or ``None``, the\n *chars* argument defaults to removing whitespace. The *chars*\n argument is not a prefix or suffix; rather, all combinations of its\n values are stripped:\n\n >>> \' spacious \'.strip()\n \'spacious\'\n >>> \'www.example.com\'.strip(\'cmowz.\')\n \'example\'\n\nstr.swapcase()\n\n Return a copy of the string with uppercase characters converted to\n lowercase and vice versa.\n\nstr.title()\n\n Return a titlecased version of the string where words start with an\n uppercase character and the remaining characters are lowercase.\n\n The algorithm uses a simple language-independent definition of a\n word as groups of consecutive letters. The definition works in\n many contexts but it means that apostrophes in contractions and\n possessives form word boundaries, which may not be the desired\n result:\n\n >>> "they\'re bill\'s friends from the UK".title()\n "They\'Re Bill\'S Friends From The Uk"\n\n A workaround for apostrophes can be constructed using regular\n expressions:\n\n >>> import re\n >>> def titlecase(s):\n return re.sub(r"[A-Za-z]+(\'[A-Za-z]+)?",\n lambda mo: mo.group(0)[0].upper() +\n mo.group(0)[1:].lower(),\n s)\n\n >>> titlecase("they\'re bill\'s friends.")\n "They\'re Bill\'s Friends."\n\nstr.translate(map)\n\n Return a copy of the *s* where all characters have been mapped\n through the *map* which must be a dictionary of Unicode ordinals\n (integers) to Unicode ordinals, strings or ``None``. Unmapped\n characters are left untouched. Characters mapped to ``None`` are\n deleted.\n\n You can use ``str.maketrans()`` to create a translation map from\n character-to-character mappings in different formats.\n\n Note: An even more flexible approach is to create a custom character\n mapping codec using the ``codecs`` module (see\n ``encodings.cp1251`` for an example).\n\nstr.upper()\n\n Return a copy of the string with all the cased characters [4]\n converted to uppercase. Note that ``str.upper().isupper()`` might\n be ``False`` if ``s`` contains uncased characters or if the Unicode\n category of the resulting character(s) is not "Lu" (Letter,\n uppercase), but e.g. "Lt" (Letter, titlecase).\n\nstr.zfill(width)\n\n Return the numeric string left filled with zeros in a string of\n length *width*. A sign prefix is handled correctly. The original\n string is returned if *width* is less than or equal to ``len(s)``.\n\n\nOld String Formatting Operations\n================================\n\nNote: The formatting operations described here are obsolete and may go\n away in future versions of Python. Use the new *String Formatting*\n in new code.\n\nString objects have one unique built-in operation: the ``%`` operator\n(modulo). This is also known as the string *formatting* or\n*interpolation* operator. Given ``format % values`` (where *format* is\na string), ``%`` conversion specifications in *format* are replaced\nwith zero or more elements of *values*. The effect is similar to the\nusing ``sprintf()`` in the C language.\n\nIf *format* requires a single argument, *values* may be a single non-\ntuple object. [5] Otherwise, *values* must be a tuple with exactly\nthe number of items specified by the format string, or a single\nmapping object (for example, a dictionary).\n\nA conversion specifier contains two or more characters and has the\nfollowing components, which must occur in this order:\n\n1. The ``\'%\'`` character, which marks the start of the specifier.\n\n2. Mapping key (optional), consisting of a parenthesised sequence of\n characters (for example, ``(somename)``).\n\n3. Conversion flags (optional), which affect the result of some\n conversion types.\n\n4. Minimum field width (optional). If specified as an ``\'*\'``\n (asterisk), the actual width is read from the next element of the\n tuple in *values*, and the object to convert comes after the\n minimum field width and optional precision.\n\n5. Precision (optional), given as a ``\'.\'`` (dot) followed by the\n precision. If specified as ``\'*\'`` (an asterisk), the actual\n precision is read from the next element of the tuple in *values*,\n and the value to convert comes after the precision.\n\n6. Length modifier (optional).\n\n7. Conversion type.\n\nWhen the right argument is a dictionary (or other mapping type), then\nthe formats in the string *must* include a parenthesised mapping key\ninto that dictionary inserted immediately after the ``\'%\'`` character.\nThe mapping key selects the value to be formatted from the mapping.\nFor example:\n\n>>> print(\'%(language)s has %(number)03d quote types.\' %\n... {\'language\': "Python", "number": 2})\nPython has 002 quote types.\n\nIn this case no ``*`` specifiers may occur in a format (since they\nrequire a sequential parameter list).\n\nThe conversion flag characters are:\n\n+-----------+-----------------------------------------------------------------------+\n| Flag | Meaning |\n+===========+=======================================================================+\n| ``\'#\'`` | The value conversion will use the "alternate form" (where defined |\n| | below). |\n+-----------+-----------------------------------------------------------------------+\n| ``\'0\'`` | The conversion will be zero padded for numeric values. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'-\'`` | The converted value is left adjusted (overrides the ``\'0\'`` |\n| | conversion if both are given). |\n+-----------+-----------------------------------------------------------------------+\n| ``\' \'`` | (a space) A blank should be left before a positive number (or empty |\n| | string) produced by a signed conversion. |\n+-----------+-----------------------------------------------------------------------+\n| ``\'+\'`` | A sign character (``\'+\'`` or ``\'-\'``) will precede the conversion |\n| | (overrides a "space" flag). |\n+-----------+-----------------------------------------------------------------------+\n\nA length modifier (``h``, ``l``, or ``L``) may be present, but is\nignored as it is not necessary for Python -- so e.g. ``%ld`` is\nidentical to ``%d``.\n\nThe conversion types are:\n\n+--------------+-------------------------------------------------------+---------+\n| Conversion | Meaning | Notes |\n+==============+=======================================================+=========+\n| ``\'d\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'i\'`` | Signed integer decimal. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'o\'`` | Signed octal value. | (1) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'u\'`` | Obsolete type -- it is identical to ``\'d\'``. | (7) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'x\'`` | Signed hexadecimal (lowercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'X\'`` | Signed hexadecimal (uppercase). | (2) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'e\'`` | Floating point exponential format (lowercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'E\'`` | Floating point exponential format (uppercase). | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'f\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'F\'`` | Floating point decimal format. | (3) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'g\'`` | Floating point format. Uses lowercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'G\'`` | Floating point format. Uses uppercase exponential | (4) |\n| | format if exponent is less than -4 or not less than | |\n| | precision, decimal format otherwise. | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'c\'`` | Single character (accepts integer or single character | |\n| | string). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'r\'`` | String (converts any Python object using ``repr()``). | (5) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'s\'`` | String (converts any Python object using ``str()``). | (5) |\n+--------------+-------------------------------------------------------+---------+\n| ``\'a\'`` | String (converts any Python object using | (5) |\n| | ``ascii()``). | |\n+--------------+-------------------------------------------------------+---------+\n| ``\'%\'`` | No argument is converted, results in a ``\'%\'`` | |\n| | character in the result. | |\n+--------------+-------------------------------------------------------+---------+\n\nNotes:\n\n1. The alternate form causes a leading zero (``\'0\'``) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n2. The alternate form causes a leading ``\'0x\'`` or ``\'0X\'`` (depending\n on whether the ``\'x\'`` or ``\'X\'`` format was used) to be inserted\n between left-hand padding and the formatting of the number if the\n leading character of the result is not already a zero.\n\n3. The alternate form causes the result to always contain a decimal\n point, even if no digits follow it.\n\n The precision determines the number of digits after the decimal\n point and defaults to 6.\n\n4. The alternate form causes the result to always contain a decimal\n point, and trailing zeroes are not removed as they would otherwise\n be.\n\n The precision determines the number of significant digits before\n and after the decimal point and defaults to 6.\n\n5. If precision is ``N``, the output is truncated to ``N`` characters.\n\n1. See **PEP 237**.\n\nSince Python strings have an explicit length, ``%s`` conversions do\nnot assume that ``\'\\0\'`` is the end of the string.\n\nChanged in version 3.1: ``%f`` conversions for numbers whose absolute\nvalue is over 1e50 are no longer replaced by ``%g`` conversions.\n\nAdditional string operations are defined in standard modules\n``string`` and ``re``.\n\n\nRange Type\n==========\n\nThe ``range`` type is an immutable sequence which is commonly used for\nlooping. The advantage of the ``range`` type is that an ``range``\nobject will always take the same amount of memory, no matter the size\nof the range it represents.\n\nRange objects have relatively little behavior: they support indexing,\ncontains, iteration, the ``len()`` function, and the following\nmethods:\n\nrange.count(x)\n\n Return the number of *i*\'s for which ``s[i] == x``.\n\n New in version 3.2.\n\nrange.index(x)\n\n Return the smallest *i* such that ``s[i] == x``. Raises\n ``ValueError`` when *x* is not in the range.\n\n New in version 3.2.\n\n\nMutable Sequence Types\n======================\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``. Use ``functools.cmp_to_key()`` to\n convert an old-style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises ``ValueError`` if it can detect\n that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n\n\nBytes and Byte Array Methods\n============================\n\nBytes and bytearray objects, being "strings of bytes", have all\nmethods found on strings, with the exception of ``encode()``,\n``format()`` and ``isidentifier()``, which do not make sense with\nthese types. For converting the objects to strings, they have a\n``decode()`` method.\n\nWherever one of these methods needs to interpret the bytes as\ncharacters (e.g. the ``is...()`` methods), the ASCII character set is\nassumed.\n\nNote: The methods on bytes and bytearray objects don\'t accept strings as\n their arguments, just as the methods on strings don\'t accept bytes\n as their arguments. For example, you have to write\n\n a = "abc"\n b = a.replace("a", "f")\n\n and\n\n a = b"abc"\n b = a.replace(b"a", b"f")\n\nbytes.decode(encoding="utf-8", errors="strict")\nbytearray.decode(encoding="utf-8", errors="strict")\n\n Return a string decoded from the given bytes. Default encoding is\n ``\'utf-8\'``. *errors* may be given to set a different error\n handling scheme. The default for *errors* is ``\'strict\'``, meaning\n that encoding errors raise a ``UnicodeError``. Other possible\n values are ``\'ignore\'``, ``\'replace\'`` and any other name\n registered via ``codecs.register_error()``, see section *Codec Base\n Classes*. For a list of possible encodings, see section *Standard\n Encodings*.\n\n Changed in version 3.1: Added support for keyword arguments.\n\nThe bytes and bytearray types have an additional class method:\n\nclassmethod bytes.fromhex(string)\nclassmethod bytearray.fromhex(string)\n\n This ``bytes`` class method returns a bytes or bytearray object,\n decoding the given string object. The string must contain two\n hexadecimal digits per byte, spaces are ignored.\n\n >>> bytes.fromhex(\'f0 f1f2 \')\n b\'\\xf0\\xf1\\xf2\'\n\nThe maketrans and translate methods differ in semantics from the\nversions available on strings:\n\nbytes.translate(table[, delete])\nbytearray.translate(table[, delete])\n\n Return a copy of the bytes or bytearray object where all bytes\n occurring in the optional argument *delete* are removed, and the\n remaining bytes have been mapped through the given translation\n table, which must be a bytes object of length 256.\n\n You can use the ``bytes.maketrans()`` method to create a\n translation table.\n\n Set the *table* argument to ``None`` for translations that only\n delete characters:\n\n >>> b\'read this short text\'.translate(None, b\'aeiou\')\n b\'rd ths shrt txt\'\n\nstatic bytes.maketrans(from, to)\nstatic bytearray.maketrans(from, to)\n\n This static method returns a translation table usable for\n ``bytes.translate()`` that will map each character in *from* into\n the character at the same position in *to*; *from* and *to* must be\n bytes objects and have the same length.\n\n New in version 3.1.\n',
+ 'typesseq-mutable': '\nMutable Sequence Types\n**********************\n\nList and bytearray objects support additional operations that allow\nin-place modification of the object. Other mutable sequence types\n(when added to the language) should also support these operations.\nStrings and tuples are immutable sequence types: such objects cannot\nbe modified once created. The following operations are defined on\nmutable sequence types (where *x* is an arbitrary object).\n\nNote that while lists allow their items to be of any type, bytearray\nobject "items" are all integers in the range 0 <= x < 256.\n\n+--------------------------------+----------------------------------+-----------------------+\n| Operation | Result | Notes |\n+================================+==================================+=======================+\n| ``s[i] = x`` | item *i* of *s* is replaced by | |\n| | *x* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j] = t`` | slice of *s* from *i* to *j* is | |\n| | replaced by the contents of the | |\n| | iterable *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j]`` | same as ``s[i:j] = []`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s[i:j:k] = t`` | the elements of ``s[i:j:k]`` are | (1) |\n| | replaced by those of *t* | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``del s[i:j:k]`` | removes the elements of | |\n| | ``s[i:j:k]`` from the list | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.append(x)`` | same as ``s[len(s):len(s)] = | |\n| | [x]`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.extend(x)`` | same as ``s[len(s):len(s)] = x`` | (2) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.count(x)`` | return number of *i*\'s for which | |\n| | ``s[i] == x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.index(x[, i[, j]])`` | return smallest *k* such that | (3) |\n| | ``s[k] == x`` and ``i <= k < j`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | (4) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | (5) |\n| | return x`` | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | (3) |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.reverse()`` | reverses the items of *s* in | (6) |\n| | place | |\n+--------------------------------+----------------------------------+-----------------------+\n| ``s.sort([key[, reverse]])`` | sort the items of *s* in place | (6), (7), (8) |\n+--------------------------------+----------------------------------+-----------------------+\n\nNotes:\n\n1. *t* must have the same length as the slice it is replacing.\n\n2. *x* can be any iterable object.\n\n3. Raises ``ValueError`` when *x* is not found in *s*. When a negative\n index is passed as the second or third parameter to the ``index()``\n method, the sequence length is added, as for slice indices. If it\n is still negative, it is truncated to zero, as for slice indices.\n\n4. When a negative index is passed as the first parameter to the\n ``insert()`` method, the sequence length is added, as for slice\n indices. If it is still negative, it is truncated to zero, as for\n slice indices.\n\n5. The optional argument *i* defaults to ``-1``, so that by default\n the last item is removed and returned.\n\n6. The ``sort()`` and ``reverse()`` methods modify the sequence in\n place for economy of space when sorting or reversing a large\n sequence. To remind you that they operate by side effect, they\n don\'t return the sorted or reversed sequence.\n\n7. The ``sort()`` method takes optional arguments for controlling the\n comparisons. Each must be specified as a keyword argument.\n\n *key* specifies a function of one argument that is used to extract\n a comparison key from each list element: ``key=str.lower``. The\n default value is ``None``. Use ``functools.cmp_to_key()`` to\n convert an old-style *cmp* function to a *key* function.\n\n *reverse* is a boolean value. If set to ``True``, then the list\n elements are sorted as if each comparison were reversed.\n\n The ``sort()`` method is guaranteed to be stable. A sort is stable\n if it guarantees not to change the relative order of elements that\n compare equal --- this is helpful for sorting in multiple passes\n (for example, sort by department, then by salary grade).\n\n **CPython implementation detail:** While a list is being sorted,\n the effect of attempting to mutate, or even inspect, the list is\n undefined. The C implementation of Python makes the list appear\n empty for the duration, and raises ``ValueError`` if it can detect\n that the list has been mutated during a sort.\n\n8. ``sort()`` is not supported by ``bytearray`` objects.\n',
+ 'unary': '\nUnary arithmetic and bitwise operations\n***************************************\n\nAll unary arithmetic and bitwise operations have the same priority:\n\n u_expr ::= power | "-" u_expr | "+" u_expr | "~" u_expr\n\nThe unary ``-`` (minus) operator yields the negation of its numeric\nargument.\n\nThe unary ``+`` (plus) operator yields its numeric argument unchanged.\n\nThe unary ``~`` (invert) operator yields the bitwise inversion of its\ninteger argument. The bitwise inversion of ``x`` is defined as\n``-(x+1)``. It only applies to integral numbers.\n\nIn all three cases, if the argument does not have the proper type, a\n``TypeError`` exception is raised.\n',
'while': '\nThe ``while`` statement\n***********************\n\nThe ``while`` statement is used for repeated execution as long as an\nexpression is true:\n\n while_stmt ::= "while" expression ":" suite\n ["else" ":" suite]\n\nThis repeatedly tests the expression and, if it is true, executes the\nfirst suite; if the expression is false (which may be the first time\nit is tested) the suite of the ``else`` clause, if present, is\nexecuted and the loop terminates.\n\nA ``break`` statement executed in the first suite terminates the loop\nwithout executing the ``else`` clause\'s suite. A ``continue``\nstatement executed in the first suite skips the rest of the suite and\ngoes back to testing the expression.\n',
- 'with': '\nThe ``with`` statement\n**********************\n\nNew in version 2.5.\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nNote: In Python 2.5, the ``with`` statement is only allowed when the\n ``with_statement`` feature has been enabled. It is always enabled\n in Python 2.6.\n\nChanged in version 2.7: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
- 'yield': '\nThe ``yield`` statement\n***********************\n\n yield_stmt ::= yield_expression\n\nThe ``yield`` statement is only used when defining a generator\nfunction, and is only used in the body of the generator function.\nUsing a ``yield`` statement in a function definition is sufficient to\ncause that definition to create a generator function instead of a\nnormal function.\n\nWhen a generator function is called, it returns an iterator known as a\ngenerator iterator, or more commonly, a generator. The body of the\ngenerator function is executed by calling the generator\'s ``next()``\nmethod repeatedly until it raises an exception.\n\nWhen a ``yield`` statement is executed, the state of the generator is\nfrozen and the value of ``expression_list`` is returned to\n``next()``\'s caller. By "frozen" we mean that all local state is\nretained, including the current bindings of local variables, the\ninstruction pointer, and the internal evaluation stack: enough\ninformation is saved so that the next time ``next()`` is invoked, the\nfunction can proceed exactly as if the ``yield`` statement were just\nanother external call.\n\nAs of Python version 2.5, the ``yield`` statement is now allowed in\nthe ``try`` clause of a ``try`` ... ``finally`` construct. If the\ngenerator is not resumed before it is finalized (by reaching a zero\nreference count or by being garbage collected), the generator-\niterator\'s ``close()`` method will be called, allowing any pending\n``finally`` clauses to execute.\n\nNote: In Python 2.2, the ``yield`` statement was only allowed when the\n ``generators`` feature has been enabled. This ``__future__`` import\n statement was used to enable the feature:\n\n from __future__ import generators\n\nSee also:\n\n **PEP 0255** - Simple Generators\n The proposal for adding generators and the ``yield`` statement\n to Python.\n\n **PEP 0342** - Coroutines via Enhanced Generators\n The proposal that, among other generator enhancements, proposed\n allowing ``yield`` to appear inside a ``try`` ... ``finally``\n block.\n'}
+ 'with': '\nThe ``with`` statement\n**********************\n\nThe ``with`` statement is used to wrap the execution of a block with\nmethods defined by a context manager (see section *With Statement\nContext Managers*). This allows common\n``try``...``except``...``finally`` usage patterns to be encapsulated\nfor convenient reuse.\n\n with_stmt ::= "with" with_item ("," with_item)* ":" suite\n with_item ::= expression ["as" target]\n\nThe execution of the ``with`` statement with one "item" proceeds as\nfollows:\n\n1. The context expression (the expression given in the ``with_item``)\n is evaluated to obtain a context manager.\n\n2. The context manager\'s ``__exit__()`` is loaded for later use.\n\n3. The context manager\'s ``__enter__()`` method is invoked.\n\n4. If a target was included in the ``with`` statement, the return\n value from ``__enter__()`` is assigned to it.\n\n Note: The ``with`` statement guarantees that if the ``__enter__()``\n method returns without an error, then ``__exit__()`` will always\n be called. Thus, if an error occurs during the assignment to the\n target list, it will be treated the same as an error occurring\n within the suite would be. See step 6 below.\n\n5. The suite is executed.\n\n6. The context manager\'s ``__exit__()`` method is invoked. If an\n exception caused the suite to be exited, its type, value, and\n traceback are passed as arguments to ``__exit__()``. Otherwise,\n three ``None`` arguments are supplied.\n\n If the suite was exited due to an exception, and the return value\n from the ``__exit__()`` method was false, the exception is\n reraised. If the return value was true, the exception is\n suppressed, and execution continues with the statement following\n the ``with`` statement.\n\n If the suite was exited for any reason other than an exception, the\n return value from ``__exit__()`` is ignored, and execution proceeds\n at the normal location for the kind of exit that was taken.\n\nWith more than one item, the context managers are processed as if\nmultiple ``with`` statements were nested:\n\n with A() as a, B() as b:\n suite\n\nis equivalent to\n\n with A() as a:\n with B() as b:\n suite\n\nChanged in version 3.1: Support for multiple context expressions.\n\nSee also:\n\n **PEP 0343** - The "with" statement\n The specification, background, and examples for the Python\n ``with`` statement.\n',
+ 'yield': '\nThe ``yield`` statement\n***********************\n\n yield_stmt ::= yield_expression\n\nThe ``yield`` statement is only used when defining a generator\nfunction, and is only used in the body of the generator function.\nUsing a ``yield`` statement in a function definition is sufficient to\ncause that definition to create a generator function instead of a\nnormal function. When a generator function is called, it returns an\niterator known as a generator iterator, or more commonly, a generator.\nThe body of the generator function is executed by calling the\n``next()`` function on the generator repeatedly until it raises an\nexception.\n\nWhen a ``yield`` statement is executed, the state of the generator is\nfrozen and the value of ``expression_list`` is returned to\n``next()``\'s caller. By "frozen" we mean that all local state is\nretained, including the current bindings of local variables, the\ninstruction pointer, and the internal evaluation stack: enough\ninformation is saved so that the next time ``next()`` is invoked, the\nfunction can proceed exactly as if the ``yield`` statement were just\nanother external call.\n\nThe ``yield`` statement is allowed in the ``try`` clause of a ``try``\n... ``finally`` construct. If the generator is not resumed before it\nis finalized (by reaching a zero reference count or by being garbage\ncollected), the generator-iterator\'s ``close()`` method will be\ncalled, allowing any pending ``finally`` clauses to execute.\n\nSee also:\n\n **PEP 0255** - Simple Generators\n The proposal for adding generators and the ``yield`` statement\n to Python.\n\n **PEP 0342** - Coroutines via Enhanced Generators\n The proposal that, among other generator enhancements, proposed\n allowing ``yield`` to appear inside a ``try`` ... ``finally``\n block.\n'}
diff --git a/Lib/Queue.py b/Lib/queue.py
index 2db8d769665..bee7ed4086a 100644
--- a/Lib/Queue.py
+++ b/Lib/queue.py
@@ -91,16 +91,33 @@ class Queue:
return n
def empty(self):
- """Return True if the queue is empty, False otherwise (not reliable!)."""
+ """Return True if the queue is empty, False otherwise (not reliable!).
+
+ This method is likely to be removed at some point. Use qsize() == 0
+ as a direct substitute, but be aware that either approach risks a race
+ condition where a queue can grow before the result of empty() or
+ qsize() can be used.
+
+ To create code that needs to wait for all queued tasks to be
+ completed, the preferred technique is to use the join() method.
+
+ """
self.mutex.acquire()
n = not self._qsize()
self.mutex.release()
return n
def full(self):
- """Return True if the queue is full, False otherwise (not reliable!)."""
+ """Return True if the queue is full, False otherwise (not reliable!).
+
+ This method is likely to be removed at some point. Use qsize() >= n
+ as a direct substitute, but be aware that either approach risks a race
+ condition where a queue can shrink before the result of full() or
+ qsize() can be used.
+
+ """
self.mutex.acquire()
- n = 0 < self.maxsize == self._qsize()
+ n = 0 < self.maxsize <= self._qsize()
self.mutex.release()
return n
@@ -119,16 +136,16 @@ class Queue:
try:
if self.maxsize > 0:
if not block:
- if self._qsize() == self.maxsize:
+ if self._qsize() >= self.maxsize:
raise Full
elif timeout is None:
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
self.not_full.wait()
elif timeout < 0:
raise ValueError("'timeout' must be a positive number")
else:
endtime = _time() + timeout
- while self._qsize() == self.maxsize:
+ while self._qsize() >= self.maxsize:
remaining = endtime - _time()
if remaining <= 0.0:
raise Full
diff --git a/Lib/quopri.py b/Lib/quopri.py
index 8788afc2f18..3d0f0ac078f 100755
--- a/Lib/quopri.py
+++ b/Lib/quopri.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Conversions to/from quoted-printable transport encoding as per RFC 1521."""
@@ -6,10 +6,10 @@
__all__ = ["encode", "decode", "encodestring", "decodestring"]
-ESCAPE = '='
+ESCAPE = b'='
MAXLINESIZE = 76
-HEX = '0123456789ABCDEF'
-EMPTYSTRING = ''
+HEX = b'0123456789ABCDEF'
+EMPTYSTRING = b''
try:
from binascii import a2b_qp, b2a_qp
@@ -19,27 +19,29 @@ except ImportError:
def needsquoting(c, quotetabs, header):
- """Decide whether a particular character needs to be quoted.
+ """Decide whether a particular byte ordinal needs to be quoted.
The 'quotetabs' flag indicates whether embedded tabs and spaces should be
quoted. Note that line-ending tabs and spaces are always encoded, as per
RFC 1521.
"""
- if c in ' \t':
+ assert isinstance(c, bytes)
+ if c in b' \t':
return quotetabs
# if header, we have to escape _ because _ is used to escape space
- if c == '_':
+ if c == b'_':
return header
- return c == ESCAPE or not (' ' <= c <= '~')
+ return c == ESCAPE or not (b' ' <= c <= b'~')
def quote(c):
"""Quote a single character."""
- i = ord(c)
- return ESCAPE + HEX[i//16] + HEX[i%16]
+ assert isinstance(c, bytes) and len(c)==1
+ c = ord(c)
+ return ESCAPE + bytes((HEX[c//16], HEX[c%16]))
-def encode(input, output, quotetabs, header = 0):
+def encode(input, output, quotetabs, header=False):
"""Read 'input', apply quoted-printable encoding, and write to 'output'.
'input' and 'output' are files with readline() and write() methods.
@@ -52,16 +54,16 @@ def encode(input, output, quotetabs, header = 0):
if b2a_qp is not None:
data = input.read()
- odata = b2a_qp(data, quotetabs = quotetabs, header = header)
+ odata = b2a_qp(data, quotetabs=quotetabs, header=header)
output.write(odata)
return
- def write(s, output=output, lineEnd='\n'):
+ def write(s, output=output, lineEnd=b'\n'):
# RFC 1521 requires that the line ending in a space or tab must have
# that trailing character encoded.
- if s and s[-1:] in ' \t':
- output.write(s[:-1] + quote(s[-1]) + lineEnd)
- elif s == '.':
+ if s and s[-1:] in b' \t':
+ output.write(s[:-1] + quote(s[-1:]) + lineEnd)
+ elif s == b'.':
output.write(quote(s) + lineEnd)
else:
output.write(s + lineEnd)
@@ -73,16 +75,17 @@ def encode(input, output, quotetabs, header = 0):
break
outline = []
# Strip off any readline induced trailing newline
- stripped = ''
- if line[-1:] == '\n':
+ stripped = b''
+ if line[-1:] == b'\n':
line = line[:-1]
- stripped = '\n'
+ stripped = b'\n'
# Calculate the un-length-limited encoded line
for c in line:
+ c = bytes((c,))
if needsquoting(c, quotetabs, header):
c = quote(c)
- if header and c == ' ':
- outline.append('_')
+ if header and c == b' ':
+ outline.append(b'_')
else:
outline.append(c)
# First, write out the previous line
@@ -94,7 +97,7 @@ def encode(input, output, quotetabs, header = 0):
while len(thisline) > MAXLINESIZE:
# Don't forget to include the soft line break `=' sign in the
# length calculation!
- write(thisline[:MAXLINESIZE-1], lineEnd='=\n')
+ write(thisline[:MAXLINESIZE-1], lineEnd=b'=\n')
thisline = thisline[MAXLINESIZE-1:]
# Write out the current line
prevline = thisline
@@ -102,88 +105,90 @@ def encode(input, output, quotetabs, header = 0):
if prevline is not None:
write(prevline, lineEnd=stripped)
-def encodestring(s, quotetabs = 0, header = 0):
+def encodestring(s, quotetabs=False, header=False):
if b2a_qp is not None:
- return b2a_qp(s, quotetabs = quotetabs, header = header)
- from cStringIO import StringIO
- infp = StringIO(s)
- outfp = StringIO()
+ return b2a_qp(s, quotetabs=quotetabs, header=header)
+ from io import BytesIO
+ infp = BytesIO(s)
+ outfp = BytesIO()
encode(infp, outfp, quotetabs, header)
return outfp.getvalue()
-def decode(input, output, header = 0):
+def decode(input, output, header=False):
"""Read 'input', apply quoted-printable decoding, and write to 'output'.
'input' and 'output' are files with readline() and write() methods.
If 'header' is true, decode underscore as space (per RFC 1522)."""
if a2b_qp is not None:
data = input.read()
- odata = a2b_qp(data, header = header)
+ odata = a2b_qp(data, header=header)
output.write(odata)
return
- new = ''
+ new = b''
while 1:
line = input.readline()
if not line: break
i, n = 0, len(line)
- if n > 0 and line[n-1] == '\n':
+ if n > 0 and line[n-1:n] == b'\n':
partial = 0; n = n-1
# Strip trailing whitespace
- while n > 0 and line[n-1] in " \t\r":
+ while n > 0 and line[n-1:n] in b" \t\r":
n = n-1
else:
partial = 1
while i < n:
- c = line[i]
- if c == '_' and header:
- new = new + ' '; i = i+1
+ c = line[i:i+1]
+ if c == b'_' and header:
+ new = new + b' '; i = i+1
elif c != ESCAPE:
new = new + c; i = i+1
elif i+1 == n and not partial:
partial = 1; break
elif i+1 < n and line[i+1] == ESCAPE:
new = new + ESCAPE; i = i+2
- elif i+2 < n and ishex(line[i+1]) and ishex(line[i+2]):
- new = new + chr(unhex(line[i+1:i+3])); i = i+3
+ elif i+2 < n and ishex(line[i+1:i+2]) and ishex(line[i+2:i+3]):
+ new = new + bytes((unhex(line[i+1:i+3]),)); i = i+3
else: # Bad escape sequence -- leave it in
new = new + c; i = i+1
if not partial:
- output.write(new + '\n')
- new = ''
+ output.write(new + b'\n')
+ new = b''
if new:
output.write(new)
-def decodestring(s, header = 0):
+def decodestring(s, header=False):
if a2b_qp is not None:
- return a2b_qp(s, header = header)
- from cStringIO import StringIO
- infp = StringIO(s)
- outfp = StringIO()
- decode(infp, outfp, header = header)
+ return a2b_qp(s, header=header)
+ from io import BytesIO
+ infp = BytesIO(s)
+ outfp = BytesIO()
+ decode(infp, outfp, header=header)
return outfp.getvalue()
# Other helper functions
def ishex(c):
- """Return true if the character 'c' is a hexadecimal digit."""
- return '0' <= c <= '9' or 'a' <= c <= 'f' or 'A' <= c <= 'F'
+ """Return true if the byte ordinal 'c' is a hexadecimal digit in ASCII."""
+ assert isinstance(c, bytes)
+ return b'0' <= c <= b'9' or b'a' <= c <= b'f' or b'A' <= c <= b'F'
def unhex(s):
"""Get the integer value of a hexadecimal number."""
bits = 0
for c in s:
- if '0' <= c <= '9':
+ c = bytes((c,))
+ if b'0' <= c <= b'9':
i = ord('0')
- elif 'a' <= c <= 'f':
+ elif b'a' <= c <= b'f':
i = ord('a')-10
- elif 'A' <= c <= 'F':
- i = ord('A')-10
+ elif b'A' <= c <= b'F':
+ i = ord(b'A')-10
else:
- break
+ assert False, "non-hex digit "+repr(c)
bits = bits*16 + (ord(c) - i)
return bits
@@ -194,12 +199,12 @@ def main():
import getopt
try:
opts, args = getopt.getopt(sys.argv[1:], 'td')
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stdout = sys.stderr
- print msg
- print "usage: quopri [-t | -d] [file] ..."
- print "-t: quote tabs"
- print "-d: decode; default encode"
+ print(msg)
+ print("usage: quopri [-t | -d] [file] ...")
+ print("-t: quote tabs")
+ print("-d: decode; default encode")
sys.exit(2)
deco = 0
tabs = 0
@@ -208,26 +213,28 @@ def main():
if o == '-d': deco = 1
if tabs and deco:
sys.stdout = sys.stderr
- print "-t and -d are mutually exclusive"
+ print("-t and -d are mutually exclusive")
sys.exit(2)
if not args: args = ['-']
sts = 0
for file in args:
if file == '-':
- fp = sys.stdin
+ fp = sys.stdin.buffer
else:
try:
- fp = open(file)
- except IOError, msg:
+ fp = open(file, "rb")
+ except IOError as msg:
sys.stderr.write("%s: can't open (%s)\n" % (file, msg))
sts = 1
continue
- if deco:
- decode(fp, sys.stdout)
- else:
- encode(fp, sys.stdout, tabs)
- if fp is not sys.stdin:
- fp.close()
+ try:
+ if deco:
+ decode(fp, sys.stdout.buffer)
+ else:
+ encode(fp, sys.stdout.buffer, tabs)
+ finally:
+ if file != '-':
+ fp.close()
if sts:
sys.exit(sts)
diff --git a/Lib/random.py b/Lib/random.py
index 36b956540bf..9b61208d2eb 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -31,28 +31,24 @@ General notes on the underlying Mersenne Twister core generator:
* The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
-* Without a direct way to compute N steps forward, the semantics of
- jumpahead(n) are weakened to simply jump to another distant state and rely
- on the large period to avoid overlapping sequences.
* The random() method is implemented in C, executes in a single Python step,
and is, therefore, threadsafe.
"""
-from __future__ import division
from warnings import warn as _warn
from types import MethodType as _MethodType, BuiltinMethodType as _BuiltinMethodType
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
from math import sqrt as _sqrt, acos as _acos, cos as _cos, sin as _sin
from os import urandom as _urandom
-from binascii import hexlify as _hexlify
-import hashlib as _hashlib
+from collections import Set as _Set, Sequence as _Sequence
+from hashlib import sha512 as _sha512
__all__ = ["Random","seed","random","uniform","randint","choice","sample",
"randrange","shuffle","normalvariate","lognormvariate",
"expovariate","vonmisesvariate","gammavariate","triangular",
"gauss","betavariate","paretovariate","weibullvariate",
- "getstate","setstate","jumpahead", "WichmannHill", "getrandbits",
+ "getstate","setstate", "getrandbits",
"SystemRandom"]
NV_MAGICCONST = 4 * _exp(-0.5)/_sqrt(2.0)
@@ -73,16 +69,13 @@ class Random(_random.Random):
"""Random number generator base class used by bound module functions.
Used to instantiate instances of Random to get generators that don't
- share state. Especially useful for multi-threaded programs, creating
- a different instance of Random for each thread, and using the jumpahead()
- method to ensure that the generated sequences seen by each thread don't
- overlap.
+ share state.
Class Random can also be subclassed if you want to use a different basic
generator of your own devising: in that case, override the following
- methods: random(), seed(), getstate(), setstate() and jumpahead().
- Optionally, implement a getrandbits() method so that randrange() can cover
- arbitrarily large ranges.
+ methods: random(), seed(), getstate(), and setstate().
+ Optionally, implement a getrandbits() method so that randrange()
+ can cover arbitrarily large ranges.
"""
@@ -97,35 +90,46 @@ class Random(_random.Random):
self.seed(x)
self.gauss_next = None
- def seed(self, a=None):
+ def seed(self, a=None, version=2):
"""Initialize internal state from hashable object.
None or no argument seeds from current time or from an operating
system specific randomness source if available.
- If a is not None or an int or long, hash(a) is used instead.
+ For version 2 (the default), all of the bits are used if *a* is a str,
+ bytes, or bytearray. For version 1, the hash() of *a* is used instead.
+
+ If *a* is an int, all bits are used.
+
"""
if a is None:
try:
- a = long(_hexlify(_urandom(16)), 16)
+ a = int.from_bytes(_urandom(32), 'big')
except NotImplementedError:
import time
- a = long(time.time() * 256) # use fractional seconds
+ a = int(time.time() * 256) # use fractional seconds
+
+ if version == 2:
+ if isinstance(a, (str, bytes, bytearray)):
+ if isinstance(a, str):
+ a = a.encode()
+ a += _sha512(a).digest()
+ a = int.from_bytes(a, 'big')
- super(Random, self).seed(a)
+ super().seed(a)
self.gauss_next = None
def getstate(self):
"""Return internal state; can be passed to setstate() later."""
- return self.VERSION, super(Random, self).getstate(), self.gauss_next
+ return self.VERSION, super().getstate(), self.gauss_next
def setstate(self, state):
"""Restore internal state from object returned by getstate()."""
version = state[0]
if version == 3:
version, internalstate, self.gauss_next = state
- super(Random, self).setstate(internalstate)
+ super().setstate(internalstate)
elif version == 2:
version, internalstate, self.gauss_next = state
# In version 2, the state was saved as signed ints, which causes
@@ -133,27 +137,15 @@ class Random(_random.Random):
# really unsigned 32-bit ints, so we convert negative ints from
# version 2 to positive longs for version 3.
try:
- internalstate = tuple( long(x) % (2**32) for x in internalstate )
- except ValueError, e:
- raise TypeError, e
- super(Random, self).setstate(internalstate)
+ internalstate = tuple(x % (2**32) for x in internalstate)
+ except ValueError as e:
+ raise TypeError from e
+ super().setstate(internalstate)
else:
raise ValueError("state with version %s passed to "
"Random.setstate() of version %s" %
(version, self.VERSION))
- def jumpahead(self, n):
- """Change the internal state to one that is likely far away
- from the current state. This method will not be in Py3.x,
- so it is better to simply reseed.
- """
- # The super.jumpahead() method uses shuffling to change state,
- # so it needs a large and "interesting" n to work with. Here,
- # we use hashing to create a large n for the shuffle.
- s = repr(n) + repr(self.getstate())
- n = int(_hashlib.new('sha512', s).hexdigest(), 16)
- super(Random, self).jumpahead(n)
-
## ---- Methods below this point do not need to be overridden when
## ---- subclassing for the purpose of using a different core generator.
@@ -170,69 +162,50 @@ class Random(_random.Random):
## -------------------- integer methods -------------------
- def randrange(self, start, stop=None, step=1, int=int, default=None,
- maxwidth=1L<<BPF):
+ def randrange(self, start, stop=None, step=1, int=int):
"""Choose a random item from range(start, stop[, step]).
This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want.
- Do not supply the 'int', 'default', and 'maxwidth' arguments.
+
+ Do not supply the 'int' argument.
"""
# This code is a bit messy to make it fast for the
# common case while still doing adequate error checking.
istart = int(start)
if istart != start:
- raise ValueError, "non-integer arg 1 for randrange()"
- if stop is default:
+ raise ValueError("non-integer arg 1 for randrange()")
+ if stop is None:
if istart > 0:
- if istart >= maxwidth:
- return self._randbelow(istart)
- return int(self.random() * istart)
- raise ValueError, "empty range for randrange()"
+ return self._randbelow(istart)
+ raise ValueError("empty range for randrange()")
# stop argument supplied.
istop = int(stop)
if istop != stop:
- raise ValueError, "non-integer stop for randrange()"
+ raise ValueError("non-integer stop for randrange()")
width = istop - istart
if step == 1 and width > 0:
- # Note that
- # int(istart + self.random()*width)
- # instead would be incorrect. For example, consider istart
- # = -2 and istop = 0. Then the guts would be in
- # -2.0 to 0.0 exclusive on both ends (ignoring that random()
- # might return 0.0), and because int() truncates toward 0, the
- # final result would be -1 or 0 (instead of -2 or -1).
- # istart + int(self.random()*width)
- # would also be incorrect, for a subtler reason: the RHS
- # can return a long, and then randrange() would also return
- # a long, but we're supposed to return an int (for backward
- # compatibility).
-
- if width >= maxwidth:
- return int(istart + self._randbelow(width))
- return int(istart + int(self.random()*width))
+ return istart + self._randbelow(width)
if step == 1:
- raise ValueError, "empty range for randrange() (%d,%d, %d)" % (istart, istop, width)
+ raise ValueError("empty range for randrange() (%d,%d, %d)" % (istart, istop, width))
# Non-unit step argument supplied.
istep = int(step)
if istep != step:
- raise ValueError, "non-integer step for randrange()"
+ raise ValueError("non-integer step for randrange()")
if istep > 0:
n = (width + istep - 1) // istep
elif istep < 0:
n = (width + istep + 1) // istep
else:
- raise ValueError, "zero step for randrange()"
+ raise ValueError("zero step for randrange()")
if n <= 0:
- raise ValueError, "empty range for randrange()"
+ raise ValueError("empty range for randrange()")
- if n >= maxwidth:
- return istart + istep*self._randbelow(n)
- return istart + istep*int(self.random() * n)
+ return istart + istep*self._randbelow(n)
def randint(self, a, b):
"""Return random integer in range [a, b], including both end points.
@@ -240,38 +213,43 @@ class Random(_random.Random):
return self.randrange(a, b+1)
- def _randbelow(self, n, _log=_log, int=int, _maxwidth=1L<<BPF,
- _Method=_MethodType, _BuiltinMethod=_BuiltinMethodType):
- """Return a random int in the range [0,n)
-
- Handles the case where n has more bits than returned
- by a single call to the underlying generator.
- """
-
- try:
- getrandbits = self.getrandbits
- except AttributeError:
- pass
- else:
- # Only call self.getrandbits if the original random() builtin method
- # has not been overridden or if a new getrandbits() was supplied.
- # This assures that the two methods correspond.
- if type(self.random) is _BuiltinMethod or type(getrandbits) is _Method:
- k = int(1.00001 + _log(n-1, 2.0)) # 2**k > n-1 > 2**(k-2)
+ def _randbelow(self, n, int=int, maxsize=1<<BPF, type=type,
+ Method=_MethodType, BuiltinMethod=_BuiltinMethodType):
+ "Return a random int in the range [0,n). Raises ValueError if n==0."
+
+ getrandbits = self.getrandbits
+ # Only call self.getrandbits if the original random() builtin method
+ # has not been overridden or if a new getrandbits() was supplied.
+ if type(self.random) is BuiltinMethod or type(getrandbits) is Method:
+ k = n.bit_length() # don't use (n-1) here because n can be 1
+ r = getrandbits(k) # 0 <= r < 2**k
+ while r >= n:
r = getrandbits(k)
- while r >= n:
- r = getrandbits(k)
- return r
- if n >= _maxwidth:
+ return r
+ # There's an overriden random() method but no new getrandbits() method,
+ # so we can only use random() from here.
+ random = self.random
+ if n >= maxsize:
_warn("Underlying random() generator does not supply \n"
- "enough bits to choose from a population range this large")
- return int(self.random() * n)
+ "enough bits to choose from a population range this large.\n"
+ "To remove the range limitation, add a getrandbits() method.")
+ return int(random() * n)
+ rem = maxsize % n
+ limit = (maxsize - rem) / maxsize # int(limit * maxsize) % n == 0
+ r = random()
+ while r >= limit:
+ r = random()
+ return int(r*maxsize) % n
## -------------------- sequence methods -------------------
def choice(self, seq):
"""Choose a random element from a non-empty sequence."""
- return seq[int(self.random() * len(seq))] # raises IndexError if seq is empty
+ try:
+ i = self._randbelow(len(seq))
+ except ValueError:
+ raise IndexError('Cannot choose from an empty sequence')
+ return seq[i]
def shuffle(self, x, random=None, int=int):
"""x, random=random.random -> shuffle list x in place; return None.
@@ -280,15 +258,14 @@ class Random(_random.Random):
float in [0.0, 1.0); by default, the standard random.random.
"""
- if random is None:
- random = self.random
- for i in reversed(xrange(1, len(x))):
+ randbelow = self._randbelow
+ for i in reversed(range(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
- j = int(random() * (i+1))
+ j = randbelow(i+1) if random is None else int(random() * (i+1))
x[i], x[j] = x[j], x[i]
def sample(self, population, k):
- """Chooses k unique random elements from a population sequence.
+ """Chooses k unique random elements from a population sequence or set.
Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
@@ -300,9 +277,9 @@ class Random(_random.Random):
population contains repeats, then each occurrence is a possible
selection in the sample.
- To choose a sample in a range of integers, use xrange as an argument.
+ To choose a sample in a range of integers, use range as an argument.
This is especially fast and space efficient for sampling from a
- large population: sample(xrange(10000000), 60)
+ large population: sample(range(10000000), 60)
"""
# Sampling without replacement entails tracking either potential
@@ -315,37 +292,34 @@ class Random(_random.Random):
# preferred since the list takes less space than the
# set and it doesn't suffer from frequent reselections.
+ if isinstance(population, _Set):
+ population = tuple(population)
+ if not isinstance(population, _Sequence):
+ raise TypeError("Population must be a sequence or set. For dicts, use list(d).")
+ randbelow = self._randbelow
n = len(population)
if not 0 <= k <= n:
- raise ValueError("sample larger than population")
- random = self.random
- _int = int
+ raise ValueError("Sample larger than population")
result = [None] * k
setsize = 21 # size of a small set minus size of an empty list
if k > 5:
setsize += 4 ** _ceil(_log(k * 3, 4)) # table size for big sets
- if n <= setsize or hasattr(population, "keys"):
- # An n-length list is smaller than a k-length set, or this is a
- # mapping type so the other algorithm wouldn't work.
+ if n <= setsize:
+ # An n-length list is smaller than a k-length set
pool = list(population)
- for i in xrange(k): # invariant: non-selected at [0,n-i)
- j = _int(random() * (n-i))
+ for i in range(k): # invariant: non-selected at [0,n-i)
+ j = randbelow(n-i)
result[i] = pool[j]
pool[j] = pool[n-i-1] # move non-selected item into vacancy
else:
- try:
- selected = set()
- selected_add = selected.add
- for i in xrange(k):
- j = _int(random() * n)
- while j in selected:
- j = _int(random() * n)
- selected_add(j)
- result[i] = population[j]
- except (TypeError, KeyError): # handle (at least) sets
- if isinstance(population, list):
- raise
- return self.sample(tuple(population), k)
+ selected = set()
+ selected_add = selected.add
+ for i in range(k):
+ j = randbelow(n)
+ while j in selected:
+ j = randbelow(n)
+ selected_add(j)
+ result[i] = population[j]
return result
## -------------------- real-valued distributions -------------------
@@ -501,7 +475,7 @@ class Random(_random.Random):
# Warning: a few older sources define the gamma distribution in terms
# of alpha > -1.0
if alpha <= 0.0 or beta <= 0.0:
- raise ValueError, 'gammavariate: alpha and beta must be > 0.0'
+ raise ValueError('gammavariate: alpha and beta must be > 0.0')
random = self.random
if alpha > 1.0:
@@ -631,7 +605,7 @@ class Random(_random.Random):
# Jain, pg. 495
u = 1.0 - self.random()
- return 1.0 / pow(u, 1.0/alpha)
+ return 1.0 / u ** (1.0/alpha)
## -------------------- Weibull --------------------
@@ -644,157 +618,7 @@ class Random(_random.Random):
# Jain, pg. 499; bug fix courtesy Bill Arms
u = 1.0 - self.random()
- return alpha * pow(-_log(u), 1.0/beta)
-
-## -------------------- Wichmann-Hill -------------------
-
-class WichmannHill(Random):
-
- VERSION = 1 # used by getstate/setstate
-
- def seed(self, a=None):
- """Initialize internal state from hashable object.
-
- None or no argument seeds from current time or from an operating
- system specific randomness source if available.
-
- If a is not None or an int or long, hash(a) is used instead.
-
- If a is an int or long, a is used directly. Distinct values between
- 0 and 27814431486575L inclusive are guaranteed to yield distinct
- internal states (this guarantee is specific to the default
- Wichmann-Hill generator).
- """
-
- if a is None:
- try:
- a = long(_hexlify(_urandom(16)), 16)
- except NotImplementedError:
- import time
- a = long(time.time() * 256) # use fractional seconds
-
- if not isinstance(a, (int, long)):
- a = hash(a)
-
- a, x = divmod(a, 30268)
- a, y = divmod(a, 30306)
- a, z = divmod(a, 30322)
- self._seed = int(x)+1, int(y)+1, int(z)+1
-
- self.gauss_next = None
-
- def random(self):
- """Get the next random number in the range [0.0, 1.0)."""
-
- # Wichman-Hill random number generator.
- #
- # Wichmann, B. A. & Hill, I. D. (1982)
- # Algorithm AS 183:
- # An efficient and portable pseudo-random number generator
- # Applied Statistics 31 (1982) 188-190
- #
- # see also:
- # Correction to Algorithm AS 183
- # Applied Statistics 33 (1984) 123
- #
- # McLeod, A. I. (1985)
- # A remark on Algorithm AS 183
- # Applied Statistics 34 (1985),198-200
-
- # This part is thread-unsafe:
- # BEGIN CRITICAL SECTION
- x, y, z = self._seed
- x = (171 * x) % 30269
- y = (172 * y) % 30307
- z = (170 * z) % 30323
- self._seed = x, y, z
- # END CRITICAL SECTION
-
- # Note: on a platform using IEEE-754 double arithmetic, this can
- # never return 0.0 (asserted by Tim; proof too long for a comment).
- return (x/30269.0 + y/30307.0 + z/30323.0) % 1.0
-
- def getstate(self):
- """Return internal state; can be passed to setstate() later."""
- return self.VERSION, self._seed, self.gauss_next
-
- def setstate(self, state):
- """Restore internal state from object returned by getstate()."""
- version = state[0]
- if version == 1:
- version, self._seed, self.gauss_next = state
- else:
- raise ValueError("state with version %s passed to "
- "Random.setstate() of version %s" %
- (version, self.VERSION))
-
- def jumpahead(self, n):
- """Act as if n calls to random() were made, but quickly.
-
- n is an int, greater than or equal to 0.
-
- Example use: If you have 2 threads and know that each will
- consume no more than a million random numbers, create two Random
- objects r1 and r2, then do
- r2.setstate(r1.getstate())
- r2.jumpahead(1000000)
- Then r1 and r2 will use guaranteed-disjoint segments of the full
- period.
- """
-
- if not n >= 0:
- raise ValueError("n must be >= 0")
- x, y, z = self._seed
- x = int(x * pow(171, n, 30269)) % 30269
- y = int(y * pow(172, n, 30307)) % 30307
- z = int(z * pow(170, n, 30323)) % 30323
- self._seed = x, y, z
-
- def __whseed(self, x=0, y=0, z=0):
- """Set the Wichmann-Hill seed from (x, y, z).
-
- These must be integers in the range [0, 256).
- """
-
- if not type(x) == type(y) == type(z) == int:
- raise TypeError('seeds must be integers')
- if not (0 <= x < 256 and 0 <= y < 256 and 0 <= z < 256):
- raise ValueError('seeds must be in range(0, 256)')
- if 0 == x == y == z:
- # Initialize from current time
- import time
- t = long(time.time() * 256)
- t = int((t&0xffffff) ^ (t>>24))
- t, x = divmod(t, 256)
- t, y = divmod(t, 256)
- t, z = divmod(t, 256)
- # Zero is a poor seed, so substitute 1
- self._seed = (x or 1, y or 1, z or 1)
-
- self.gauss_next = None
-
- def whseed(self, a=None):
- """Seed from hashable object's hash code.
-
- None or no argument seeds from current time. It is not guaranteed
- that objects with distinct hash codes lead to distinct internal
- states.
-
- This is obsolete, provided for compatibility with the seed routine
- used prior to Python 2.1. Use the .seed() method instead.
- """
-
- if a is None:
- self.__whseed()
- return
- a = hash(a)
- a, x = divmod(a, 256)
- a, y = divmod(a, 256)
- a, z = divmod(a, 256)
- x = (x + a) % 256 or 1
- y = (y + a) % 256 or 1
- z = (z + a) % 256 or 1
- self.__whseed(x, y, z)
+ return alpha * (-_log(u)) ** (1.0/beta)
## --------------- Operating System Random Source ------------------
@@ -808,7 +632,7 @@ class SystemRandom(Random):
def random(self):
"""Get the next random number in the range [0.0, 1.0)."""
- return (long(_hexlify(_urandom(7)), 16) >> 3) * RECIP_BPF
+ return (int.from_bytes(_urandom(7), 'big') >> 3) * RECIP_BPF
def getrandbits(self, k):
"""getrandbits(k) -> x. Generates a long int with k random bits."""
@@ -816,14 +640,13 @@ class SystemRandom(Random):
raise ValueError('number of bits must be greater than zero')
if k != int(k):
raise TypeError('number of bits should be an integer')
- bytes = (k + 7) // 8 # bits / 8 and rounded up
- x = long(_hexlify(_urandom(bytes)), 16)
- return x >> (bytes * 8 - k) # trim excess bits
+ numbytes = (k + 7) // 8 # bits / 8 and rounded up
+ x = int.from_bytes(_urandom(numbytes), 'big')
+ return x >> (numbytes * 8 - k) # trim excess bits
- def _stub(self, *args, **kwds):
+ def seed(self, *args, **kwds):
"Stub method. Not used for a system random number generator."
return None
- seed = jumpahead = _stub
def _notimplemented(self, *args, **kwds):
"Method should not be called for a system random number generator."
@@ -834,7 +657,7 @@ class SystemRandom(Random):
def _test_generator(n, func, args):
import time
- print n, 'times', func.__name__
+ print(n, 'times', func.__name__)
total = 0.0
sqsum = 0.0
smallest = 1e10
@@ -847,11 +670,11 @@ def _test_generator(n, func, args):
smallest = min(x, smallest)
largest = max(x, largest)
t1 = time.time()
- print round(t1-t0, 3), 'sec,',
+ print(round(t1-t0, 3), 'sec,', end=' ')
avg = total/n
stddev = _sqrt(sqsum/n - avg*avg)
- print 'avg %g, stddev %g, min %g, max %g' % \
- (avg, stddev, smallest, largest)
+ print('avg %g, stddev %g, min %g, max %g' % \
+ (avg, stddev, smallest, largest))
def _test(N=2000):
@@ -899,7 +722,6 @@ paretovariate = _inst.paretovariate
weibullvariate = _inst.weibullvariate
getstate = _inst.getstate
setstate = _inst.setstate
-jumpahead = _inst.jumpahead
getrandbits = _inst.getrandbits
if __name__ == '__main__':
diff --git a/Lib/re.py b/Lib/re.py
index aab5d37e589..85c5a570249 100644
--- a/Lib/re.py
+++ b/Lib/re.py
@@ -44,7 +44,7 @@ The special characters are:
"|" A|B, creates an RE that will match either A or B.
(...) Matches the RE inside the parentheses.
The contents can be retrieved or matched later in the string.
- (?iLmsux) Set the I, L, M, S, U, or X flag for the RE (see below).
+ (?aiLmsux) Set the A, I, L, M, S, U, or X flag for the RE (see below).
(?:...) Non-grouping version of regular parentheses.
(?P<name>...) The substring matched by the group is accessible by name.
(?P=name) Matches the text matched earlier by the group named name.
@@ -64,11 +64,21 @@ resulting RE will match the second character.
\Z Matches only at the end of the string.
\b Matches the empty string, but only at the start or end of a word.
\B Matches the empty string, but not at the start or end of a word.
- \d Matches any decimal digit; equivalent to the set [0-9].
- \D Matches any non-digit character; equivalent to the set [^0-9].
- \s Matches any whitespace character; equivalent to [ \t\n\r\f\v].
- \S Matches any non-whitespace character; equiv. to [^ \t\n\r\f\v].
- \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_].
+ \d Matches any decimal digit; equivalent to the set [0-9] in
+ bytes patterns or string patterns with the ASCII flag.
+ In string patterns without the ASCII flag, it will match the whole
+ range of Unicode digits.
+ \D Matches any non-digit character; equivalent to [^\d].
+ \s Matches any whitespace character; equivalent to [ \t\n\r\f\v] in
+ bytes patterns or string patterns with the ASCII flag.
+ In string patterns without the ASCII flag, it will match the whole
+ range of Unicode whitespace characters.
+ \S Matches any non-whitespace character; equivalent to [^\s].
+ \w Matches any alphanumeric character; equivalent to [a-zA-Z0-9_]
+ in bytes patterns or string patterns with the ASCII flag.
+ In string patterns without the ASCII flag, it will match the
+ range of Unicode alphanumeric characters (letters plus digits
+ plus underscore).
With LOCALE, it will match the set [0-9_] plus characters defined
as letters for the current locale.
\W Matches the complement of \w.
@@ -87,6 +97,12 @@ This module exports the following functions:
escape Backslash all non-alphanumerics in a string.
Some of the functions in this module takes flags as optional parameters:
+ A ASCII For string patterns, make \w, \W, \b, \B, \d, \D
+ match the corresponding ASCII character categories
+ (rather than the whole Unicode categories, which is the
+ default).
+ For bytes patterns, this flag is the only available
+ behaviour and needn't be specified.
I IGNORECASE Perform case-insensitive matching.
L LOCALE Make \w, \W, \b, \B, dependent on the current locale.
M MULTILINE "^" matches the beginning of lines (after a newline)
@@ -95,7 +111,8 @@ Some of the functions in this module takes flags as optional parameters:
as the end of the string.
S DOTALL "." matches any character at all, including the newline.
X VERBOSE Ignore whitespace and comments for nicer looking RE's.
- U UNICODE Make \w, \W, \b, \B, dependent on the Unicode locale.
+ U UNICODE For compatibility only. Ignored for string patterns (it
+ is the default), and forbidden for bytes patterns.
This module also defines an exception 'error'.
@@ -104,19 +121,21 @@ This module also defines an exception 'error'.
import sys
import sre_compile
import sre_parse
+import functools
# public symbols
__all__ = [ "match", "search", "sub", "subn", "split", "findall",
- "compile", "purge", "template", "escape", "I", "L", "M", "S", "X",
- "U", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE",
+ "compile", "purge", "template", "escape", "A", "I", "L", "M", "S", "X",
+ "U", "ASCII", "IGNORECASE", "LOCALE", "MULTILINE", "DOTALL", "VERBOSE",
"UNICODE", "error" ]
__version__ = "2.2.1"
# flags
+A = ASCII = sre_compile.SRE_FLAG_ASCII # assume ascii "locale"
I = IGNORECASE = sre_compile.SRE_FLAG_IGNORECASE # ignore case
L = LOCALE = sre_compile.SRE_FLAG_LOCALE # assume current 8-bit locale
-U = UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode locale
+U = UNICODE = sre_compile.SRE_FLAG_UNICODE # assume unicode "locale"
M = MULTILINE = sre_compile.SRE_FLAG_MULTILINE # make anchors look for newline
S = DOTALL = sre_compile.SRE_FLAG_DOTALL # make dot match newline
X = VERBOSE = sre_compile.SRE_FLAG_VERBOSE # ignore whitespace and comments
@@ -163,14 +182,19 @@ def subn(pattern, repl, string, count=0, flags=0):
def split(pattern, string, maxsplit=0, flags=0):
"""Split the source string by the occurrences of the pattern,
- returning a list containing the resulting substrings."""
+ returning a list containing the resulting substrings. If
+ capturing parentheses are used in pattern, then the text of all
+ groups in the pattern are also returned as part of the resulting
+ list. If maxsplit is nonzero, at most maxsplit splits occur,
+ and the remainder of the string is returned as the final element
+ of the list."""
return _compile(pattern, flags).split(string, maxsplit)
def findall(pattern, string, flags=0):
"""Return a list of all non-overlapping matches in the string.
- If one or more groups are present in the pattern, return a
- list of groups; this will be a list of tuples if the pattern
+ If one or more capturing groups are present in the pattern, return
+ a list of groups; this will be a list of tuples if the pattern
has more than one group.
Empty matches are included in the result."""
@@ -190,75 +214,70 @@ def compile(pattern, flags=0):
return _compile(pattern, flags)
def purge():
- "Clear the regular expression cache"
- _cache.clear()
- _cache_repl.clear()
+ "Clear the regular expression caches"
+ _compile_typed.cache_clear()
+ _compile_repl.cache_clear()
def template(pattern, flags=0):
"Compile a template pattern, returning a pattern object"
return _compile(pattern, flags|T)
-_alphanum = frozenset(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
+_alphanum_str = frozenset(
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890")
+_alphanum_bytes = frozenset(
+ b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890")
def escape(pattern):
"Escape all non-alphanumeric characters in pattern."
- s = list(pattern)
- alphanum = _alphanum
- for i, c in enumerate(pattern):
- if c not in alphanum:
- if c == "\000":
- s[i] = "\\000"
+ if isinstance(pattern, str):
+ alphanum = _alphanum_str
+ s = list(pattern)
+ for i, c in enumerate(pattern):
+ if c not in alphanum:
+ if c == "\000":
+ s[i] = "\\000"
+ else:
+ s[i] = "\\" + c
+ return "".join(s)
+ else:
+ alphanum = _alphanum_bytes
+ s = []
+ esc = ord(b"\\")
+ for c in pattern:
+ if c in alphanum:
+ s.append(c)
else:
- s[i] = "\\" + c
- return pattern[:0].join(s)
+ if c == 0:
+ s.extend(b"\\000")
+ else:
+ s.append(esc)
+ s.append(c)
+ return bytes(s)
# --------------------------------------------------------------------
# internals
-_cache = {}
-_cache_repl = {}
-
_pattern_type = type(sre_compile.compile("", 0))
-_MAXCACHE = 100
+def _compile(pattern, flags):
+ return _compile_typed(type(pattern), pattern, flags)
-def _compile(*key):
+@functools.lru_cache(maxsize=500)
+def _compile_typed(text_bytes_type, pattern, flags):
# internal: compile pattern
- cachekey = (type(key[0]),) + key
- p = _cache.get(cachekey)
- if p is not None:
- return p
- pattern, flags = key
if isinstance(pattern, _pattern_type):
if flags:
- raise ValueError('Cannot process flags argument with a compiled pattern')
+ raise ValueError(
+ "Cannot process flags argument with a compiled pattern")
return pattern
if not sre_compile.isstring(pattern):
- raise TypeError, "first argument must be string or compiled pattern"
- try:
- p = sre_compile.compile(pattern, flags)
- except error, v:
- raise error, v # invalid expression
- if len(_cache) >= _MAXCACHE:
- _cache.clear()
- _cache[cachekey] = p
- return p
-
-def _compile_repl(*key):
+ raise TypeError("first argument must be string or compiled pattern")
+ return sre_compile.compile(pattern, flags)
+
+@functools.lru_cache(maxsize=500)
+def _compile_repl(repl, pattern):
# internal: compile replacement pattern
- p = _cache_repl.get(key)
- if p is not None:
- return p
- repl, pattern = key
- try:
- p = sre_parse.parse_template(repl, pattern)
- except error, v:
- raise error, v # invalid expression
- if len(_cache_repl) >= _MAXCACHE:
- _cache_repl.clear()
- _cache_repl[key] = p
- return p
+ return sre_parse.parse_template(repl, pattern)
def _expand(pattern, match, template):
# internal: match.expand implementation hook
@@ -277,12 +296,12 @@ def _subx(pattern, template):
# register myself for pickling
-import copy_reg
+import copyreg
def _pickle(p):
return _compile, (p.pattern, p.flags)
-copy_reg.pickle(_pattern_type, _pickle, _compile)
+copyreg.pickle(_pattern_type, _pickle, _compile)
# --------------------------------------------------------------------
# experimental stuff (see python-dev discussions for details)
@@ -315,7 +334,7 @@ class Scanner:
if i == j:
break
action = self.lexicon[m.lastindex-1][1]
- if hasattr(action, '__call__'):
+ if callable(action):
self.match = m
action = action(self, m.group())
if action is not None:
diff --git a/Lib/repr.py b/Lib/reprlib.py
index 3c26cc39a21..f8033604da2 100644
--- a/Lib/repr.py
+++ b/Lib/reprlib.py
@@ -1,9 +1,39 @@
"""Redo the builtin repr() (representation) but with limits on most sizes."""
-__all__ = ["Repr","repr"]
+__all__ = ["Repr", "repr", "recursive_repr"]
-import __builtin__
+import builtins
from itertools import islice
+try:
+ from _thread import get_ident
+except ImportError:
+ from _dummy_thread import get_ident
+
+def recursive_repr(fillvalue='...'):
+ 'Decorator to make a repr function return fillvalue for a recursive call'
+
+ def decorating_function(user_function):
+ repr_running = set()
+
+ def wrapper(self):
+ key = id(self), get_ident()
+ if key in repr_running:
+ return fillvalue
+ repr_running.add(key)
+ try:
+ result = user_function(self)
+ finally:
+ repr_running.discard(key)
+ return result
+
+ # Can't use functools.wraps() here because of bootstrap issues
+ wrapper.__module__ = getattr(user_function, '__module__')
+ wrapper.__doc__ = getattr(user_function, '__doc__')
+ wrapper.__name__ = getattr(user_function, '__name__')
+ wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
+ return wrapper
+
+ return decorating_function
class Repr:
@@ -18,7 +48,7 @@ class Repr:
self.maxdeque = 6
self.maxstring = 30
self.maxlong = 40
- self.maxother = 20
+ self.maxother = 30
def repr(self, x):
return self.repr1(x, self.maxlevel)
@@ -31,12 +61,7 @@ class Repr:
if hasattr(self, 'repr_' + typename):
return getattr(self, 'repr_' + typename)(x, level)
else:
- s = __builtin__.repr(x)
- if len(s) > self.maxother:
- i = max(0, (self.maxother-3)//2)
- j = max(0, self.maxother-3-i)
- s = s[:i] + '...' + s[len(s)-j:]
- return s
+ return self.repr_instance(x, level)
def _repr_iterable(self, x, level, left, right, maxiter, trail=''):
n = len(x)
@@ -89,16 +114,16 @@ class Repr:
return '{%s}' % (s,)
def repr_str(self, x, level):
- s = __builtin__.repr(x[:self.maxstring])
+ s = builtins.repr(x[:self.maxstring])
if len(s) > self.maxstring:
i = max(0, (self.maxstring-3)//2)
j = max(0, self.maxstring-3-i)
- s = __builtin__.repr(x[:i] + x[len(x)-j:])
+ s = builtins.repr(x[:i] + x[len(x)-j:])
s = s[:i] + '...' + s[len(s)-j:]
return s
- def repr_long(self, x, level):
- s = __builtin__.repr(x) # XXX Hope this isn't too slow...
+ def repr_int(self, x, level):
+ s = builtins.repr(x) # XXX Hope this isn't too slow...
if len(s) > self.maxlong:
i = max(0, (self.maxlong-3)//2)
j = max(0, self.maxlong-3-i)
@@ -107,14 +132,14 @@ class Repr:
def repr_instance(self, x, level):
try:
- s = __builtin__.repr(x)
+ s = builtins.repr(x)
# Bugs in x.__repr__() can cause arbitrary
# exceptions -- then make up something
except Exception:
return '<%s instance at %x>' % (x.__class__.__name__, id(x))
- if len(s) > self.maxstring:
- i = max(0, (self.maxstring-3)//2)
- j = max(0, self.maxstring-3-i)
+ if len(s) > self.maxother:
+ i = max(0, (self.maxother-3)//2)
+ j = max(0, self.maxother-3-i)
s = s[:i] + '...' + s[len(s)-j:]
return s
diff --git a/Lib/rexec.py b/Lib/rexec.py
deleted file mode 100644
index 74461512ddc..00000000000
--- a/Lib/rexec.py
+++ /dev/null
@@ -1,588 +0,0 @@
-"""Restricted execution facilities.
-
-The class RExec exports methods r_exec(), r_eval(), r_execfile(), and
-r_import(), which correspond roughly to the built-in operations
-exec, eval(), execfile() and import, but executing the code in an
-environment that only exposes those built-in operations that are
-deemed safe. To this end, a modest collection of 'fake' modules is
-created which mimics the standard modules by the same names. It is a
-policy decision which built-in modules and operations are made
-available; this module provides a reasonable default, but derived
-classes can change the policies e.g. by overriding or extending class
-variables like ok_builtin_modules or methods like make_sys().
-
-XXX To do:
-- r_open should allow writing tmp dir
-- r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?)
-
-"""
-from warnings import warnpy3k
-warnpy3k("the rexec module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-
-import sys
-import __builtin__
-import os
-import ihooks
-import imp
-
-__all__ = ["RExec"]
-
-class FileBase:
-
- ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline',
- 'readlines', 'seek', 'tell', 'write', 'writelines', 'xreadlines',
- '__iter__')
-
-
-class FileWrapper(FileBase):
-
- # XXX This is just like a Bastion -- should use that!
-
- def __init__(self, f):
- for m in self.ok_file_methods:
- if not hasattr(self, m) and hasattr(f, m):
- setattr(self, m, getattr(f, m))
-
- def close(self):
- self.flush()
-
-
-TEMPLATE = """
-def %s(self, *args):
- return getattr(self.mod, self.name).%s(*args)
-"""
-
-class FileDelegate(FileBase):
-
- def __init__(self, mod, name):
- self.mod = mod
- self.name = name
-
- for m in FileBase.ok_file_methods + ('close',):
- exec TEMPLATE % (m, m)
-
-
-class RHooks(ihooks.Hooks):
-
- def __init__(self, *args):
- # Hacks to support both old and new interfaces:
- # old interface was RHooks(rexec[, verbose])
- # new interface is RHooks([verbose])
- verbose = 0
- rexec = None
- if args and type(args[-1]) == type(0):
- verbose = args[-1]
- args = args[:-1]
- if args and hasattr(args[0], '__class__'):
- rexec = args[0]
- args = args[1:]
- if args:
- raise TypeError, "too many arguments"
- ihooks.Hooks.__init__(self, verbose)
- self.rexec = rexec
-
- def set_rexec(self, rexec):
- # Called by RExec instance to complete initialization
- self.rexec = rexec
-
- def get_suffixes(self):
- return self.rexec.get_suffixes()
-
- def is_builtin(self, name):
- return self.rexec.is_builtin(name)
-
- def init_builtin(self, name):
- m = __import__(name)
- return self.rexec.copy_except(m, ())
-
- def init_frozen(self, name): raise SystemError, "don't use this"
- def load_source(self, *args): raise SystemError, "don't use this"
- def load_compiled(self, *args): raise SystemError, "don't use this"
- def load_package(self, *args): raise SystemError, "don't use this"
-
- def load_dynamic(self, name, filename, file):
- return self.rexec.load_dynamic(name, filename, file)
-
- def add_module(self, name):
- return self.rexec.add_module(name)
-
- def modules_dict(self):
- return self.rexec.modules
-
- def default_path(self):
- return self.rexec.modules['sys'].path
-
-
-# XXX Backwards compatibility
-RModuleLoader = ihooks.FancyModuleLoader
-RModuleImporter = ihooks.ModuleImporter
-
-
-class RExec(ihooks._Verbose):
- """Basic restricted execution framework.
-
- Code executed in this restricted environment will only have access to
- modules and functions that are deemed safe; you can subclass RExec to
- add or remove capabilities as desired.
-
- The RExec class can prevent code from performing unsafe operations like
- reading or writing disk files, or using TCP/IP sockets. However, it does
- not protect against code using extremely large amounts of memory or
- processor time.
-
- """
-
- ok_path = tuple(sys.path) # That's a policy decision
-
- ok_builtin_modules = ('audioop', 'array', 'binascii',
- 'cmath', 'errno', 'imageop',
- 'marshal', 'math', 'md5', 'operator',
- 'parser', 'select',
- 'sha', '_sre', 'strop', 'struct', 'time',
- '_weakref')
-
- ok_posix_names = ('error', 'fstat', 'listdir', 'lstat', 'readlink',
- 'stat', 'times', 'uname', 'getpid', 'getppid',
- 'getcwd', 'getuid', 'getgid', 'geteuid', 'getegid')
-
- ok_sys_names = ('byteorder', 'copyright', 'exit', 'getdefaultencoding',
- 'getrefcount', 'hexversion', 'maxint', 'maxunicode',
- 'platform', 'ps1', 'ps2', 'version', 'version_info')
-
- nok_builtin_names = ('open', 'file', 'reload', '__import__')
-
- ok_file_types = (imp.C_EXTENSION, imp.PY_SOURCE)
-
- def __init__(self, hooks = None, verbose = 0):
- """Returns an instance of the RExec class.
-
- The hooks parameter is an instance of the RHooks class or a subclass
- of it. If it is omitted or None, the default RHooks class is
- instantiated.
-
- Whenever the RExec module searches for a module (even a built-in one)
- or reads a module's code, it doesn't actually go out to the file
- system itself. Rather, it calls methods of an RHooks instance that
- was passed to or created by its constructor. (Actually, the RExec
- object doesn't make these calls --- they are made by a module loader
- object that's part of the RExec object. This allows another level of
- flexibility, which can be useful when changing the mechanics of
- import within the restricted environment.)
-
- By providing an alternate RHooks object, we can control the file
- system accesses made to import a module, without changing the
- actual algorithm that controls the order in which those accesses are
- made. For instance, we could substitute an RHooks object that
- passes all filesystem requests to a file server elsewhere, via some
- RPC mechanism such as ILU. Grail's applet loader uses this to support
- importing applets from a URL for a directory.
-
- If the verbose parameter is true, additional debugging output may be
- sent to standard output.
-
- """
-
- raise RuntimeError, "This code is not secure in Python 2.2 and later"
-
- ihooks._Verbose.__init__(self, verbose)
- # XXX There's a circular reference here:
- self.hooks = hooks or RHooks(verbose)
- self.hooks.set_rexec(self)
- self.modules = {}
- self.ok_dynamic_modules = self.ok_builtin_modules
- list = []
- for mname in self.ok_builtin_modules:
- if mname in sys.builtin_module_names:
- list.append(mname)
- self.ok_builtin_modules = tuple(list)
- self.set_trusted_path()
- self.make_builtin()
- self.make_initial_modules()
- # make_sys must be last because it adds the already created
- # modules to its builtin_module_names
- self.make_sys()
- self.loader = RModuleLoader(self.hooks, verbose)
- self.importer = RModuleImporter(self.loader, verbose)
-
- def set_trusted_path(self):
- # Set the path from which dynamic modules may be loaded.
- # Those dynamic modules must also occur in ok_builtin_modules
- self.trusted_path = filter(os.path.isabs, sys.path)
-
- def load_dynamic(self, name, filename, file):
- if name not in self.ok_dynamic_modules:
- raise ImportError, "untrusted dynamic module: %s" % name
- if name in sys.modules:
- src = sys.modules[name]
- else:
- src = imp.load_dynamic(name, filename, file)
- dst = self.copy_except(src, [])
- return dst
-
- def make_initial_modules(self):
- self.make_main()
- self.make_osname()
-
- # Helpers for RHooks
-
- def get_suffixes(self):
- return [item # (suff, mode, type)
- for item in imp.get_suffixes()
- if item[2] in self.ok_file_types]
-
- def is_builtin(self, mname):
- return mname in self.ok_builtin_modules
-
- # The make_* methods create specific built-in modules
-
- def make_builtin(self):
- m = self.copy_except(__builtin__, self.nok_builtin_names)
- m.__import__ = self.r_import
- m.reload = self.r_reload
- m.open = m.file = self.r_open
-
- def make_main(self):
- self.add_module('__main__')
-
- def make_osname(self):
- osname = os.name
- src = __import__(osname)
- dst = self.copy_only(src, self.ok_posix_names)
- dst.environ = e = {}
- for key, value in os.environ.items():
- e[key] = value
-
- def make_sys(self):
- m = self.copy_only(sys, self.ok_sys_names)
- m.modules = self.modules
- m.argv = ['RESTRICTED']
- m.path = map(None, self.ok_path)
- m.exc_info = self.r_exc_info
- m = self.modules['sys']
- l = self.modules.keys() + list(self.ok_builtin_modules)
- l.sort()
- m.builtin_module_names = tuple(l)
-
- # The copy_* methods copy existing modules with some changes
-
- def copy_except(self, src, exceptions):
- dst = self.copy_none(src)
- for name in dir(src):
- setattr(dst, name, getattr(src, name))
- for name in exceptions:
- try:
- delattr(dst, name)
- except AttributeError:
- pass
- return dst
-
- def copy_only(self, src, names):
- dst = self.copy_none(src)
- for name in names:
- try:
- value = getattr(src, name)
- except AttributeError:
- continue
- setattr(dst, name, value)
- return dst
-
- def copy_none(self, src):
- m = self.add_module(src.__name__)
- m.__doc__ = src.__doc__
- return m
-
- # Add a module -- return an existing module or create one
-
- def add_module(self, mname):
- m = self.modules.get(mname)
- if m is None:
- self.modules[mname] = m = self.hooks.new_module(mname)
- m.__builtins__ = self.modules['__builtin__']
- return m
-
- # The r* methods are public interfaces
-
- def r_exec(self, code):
- """Execute code within a restricted environment.
-
- The code parameter must either be a string containing one or more
- lines of Python code, or a compiled code object, which will be
- executed in the restricted environment's __main__ module.
-
- """
- m = self.add_module('__main__')
- exec code in m.__dict__
-
- def r_eval(self, code):
- """Evaluate code within a restricted environment.
-
- The code parameter must either be a string containing a Python
- expression, or a compiled code object, which will be evaluated in
- the restricted environment's __main__ module. The value of the
- expression or code object will be returned.
-
- """
- m = self.add_module('__main__')
- return eval(code, m.__dict__)
-
- def r_execfile(self, file):
- """Execute the Python code in the file in the restricted
- environment's __main__ module.
-
- """
- m = self.add_module('__main__')
- execfile(file, m.__dict__)
-
- def r_import(self, mname, globals={}, locals={}, fromlist=[]):
- """Import a module, raising an ImportError exception if the module
- is considered unsafe.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- """
- return self.importer.import_module(mname, globals, locals, fromlist)
-
- def r_reload(self, m):
- """Reload the module object, re-parsing and re-initializing it.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- """
- return self.importer.reload(m)
-
- def r_unload(self, m):
- """Unload the module.
-
- Removes it from the restricted environment's sys.modules dictionary.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- """
- return self.importer.unload(m)
-
- # The s_* methods are similar but also swap std{in,out,err}
-
- def make_delegate_files(self):
- s = self.modules['sys']
- self.delegate_stdin = FileDelegate(s, 'stdin')
- self.delegate_stdout = FileDelegate(s, 'stdout')
- self.delegate_stderr = FileDelegate(s, 'stderr')
- self.restricted_stdin = FileWrapper(sys.stdin)
- self.restricted_stdout = FileWrapper(sys.stdout)
- self.restricted_stderr = FileWrapper(sys.stderr)
-
- def set_files(self):
- if not hasattr(self, 'save_stdin'):
- self.save_files()
- if not hasattr(self, 'delegate_stdin'):
- self.make_delegate_files()
- s = self.modules['sys']
- s.stdin = self.restricted_stdin
- s.stdout = self.restricted_stdout
- s.stderr = self.restricted_stderr
- sys.stdin = self.delegate_stdin
- sys.stdout = self.delegate_stdout
- sys.stderr = self.delegate_stderr
-
- def reset_files(self):
- self.restore_files()
- s = self.modules['sys']
- self.restricted_stdin = s.stdin
- self.restricted_stdout = s.stdout
- self.restricted_stderr = s.stderr
-
-
- def save_files(self):
- self.save_stdin = sys.stdin
- self.save_stdout = sys.stdout
- self.save_stderr = sys.stderr
-
- def restore_files(self):
- sys.stdin = self.save_stdin
- sys.stdout = self.save_stdout
- sys.stderr = self.save_stderr
-
- def s_apply(self, func, args=(), kw={}):
- self.save_files()
- try:
- self.set_files()
- r = func(*args, **kw)
- finally:
- self.restore_files()
- return r
-
- def s_exec(self, *args):
- """Execute code within a restricted environment.
-
- Similar to the r_exec() method, but the code will be granted access
- to restricted versions of the standard I/O streams sys.stdin,
- sys.stderr, and sys.stdout.
-
- The code parameter must either be a string containing one or more
- lines of Python code, or a compiled code object, which will be
- executed in the restricted environment's __main__ module.
-
- """
- return self.s_apply(self.r_exec, args)
-
- def s_eval(self, *args):
- """Evaluate code within a restricted environment.
-
- Similar to the r_eval() method, but the code will be granted access
- to restricted versions of the standard I/O streams sys.stdin,
- sys.stderr, and sys.stdout.
-
- The code parameter must either be a string containing a Python
- expression, or a compiled code object, which will be evaluated in
- the restricted environment's __main__ module. The value of the
- expression or code object will be returned.
-
- """
- return self.s_apply(self.r_eval, args)
-
- def s_execfile(self, *args):
- """Execute the Python code in the file in the restricted
- environment's __main__ module.
-
- Similar to the r_execfile() method, but the code will be granted
- access to restricted versions of the standard I/O streams sys.stdin,
- sys.stderr, and sys.stdout.
-
- """
- return self.s_apply(self.r_execfile, args)
-
- def s_import(self, *args):
- """Import a module, raising an ImportError exception if the module
- is considered unsafe.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- Similar to the r_import() method, but has access to restricted
- versions of the standard I/O streams sys.stdin, sys.stderr, and
- sys.stdout.
-
- """
- return self.s_apply(self.r_import, args)
-
- def s_reload(self, *args):
- """Reload the module object, re-parsing and re-initializing it.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- Similar to the r_reload() method, but has access to restricted
- versions of the standard I/O streams sys.stdin, sys.stderr, and
- sys.stdout.
-
- """
- return self.s_apply(self.r_reload, args)
-
- def s_unload(self, *args):
- """Unload the module.
-
- Removes it from the restricted environment's sys.modules dictionary.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- Similar to the r_unload() method, but has access to restricted
- versions of the standard I/O streams sys.stdin, sys.stderr, and
- sys.stdout.
-
- """
- return self.s_apply(self.r_unload, args)
-
- # Restricted open(...)
-
- def r_open(self, file, mode='r', buf=-1):
- """Method called when open() is called in the restricted environment.
-
- The arguments are identical to those of the open() function, and a
- file object (or a class instance compatible with file objects)
- should be returned. RExec's default behaviour is allow opening
- any file for reading, but forbidding any attempt to write a file.
-
- This method is implicitly called by code executing in the
- restricted environment. Overriding this method in a subclass is
- used to change the policies enforced by a restricted environment.
-
- """
- mode = str(mode)
- if mode not in ('r', 'rb'):
- raise IOError, "can't open files for writing in restricted mode"
- return open(file, mode, buf)
-
- # Restricted version of sys.exc_info()
-
- def r_exc_info(self):
- ty, va, tr = sys.exc_info()
- tr = None
- return ty, va, tr
-
-
-def test():
- import getopt, traceback
- opts, args = getopt.getopt(sys.argv[1:], 'vt:')
- verbose = 0
- trusted = []
- for o, a in opts:
- if o == '-v':
- verbose = verbose+1
- if o == '-t':
- trusted.append(a)
- r = RExec(verbose=verbose)
- if trusted:
- r.ok_builtin_modules = r.ok_builtin_modules + tuple(trusted)
- if args:
- r.modules['sys'].argv = args
- r.modules['sys'].path.insert(0, os.path.dirname(args[0]))
- else:
- r.modules['sys'].path.insert(0, "")
- fp = sys.stdin
- if args and args[0] != '-':
- try:
- fp = open(args[0])
- except IOError, msg:
- print "%s: can't open file %r" % (sys.argv[0], args[0])
- return 1
- if fp.isatty():
- try:
- import readline
- except ImportError:
- pass
- import code
- class RestrictedConsole(code.InteractiveConsole):
- def runcode(self, co):
- self.locals['__builtins__'] = r.modules['__builtin__']
- r.s_apply(code.InteractiveConsole.runcode, (self, co))
- try:
- RestrictedConsole(r.modules['__main__'].__dict__).interact()
- except SystemExit, n:
- return n
- else:
- text = fp.read()
- fp.close()
- c = compile(text, fp.name, 'exec')
- try:
- r.s_exec(c)
- except SystemExit, n:
- return n
- except:
- traceback.print_exc()
- return 1
-
-
-if __name__ == '__main__':
- sys.exit(test())
diff --git a/Lib/rfc822.py b/Lib/rfc822.py
deleted file mode 100644
index b65d8da0d25..00000000000
--- a/Lib/rfc822.py
+++ /dev/null
@@ -1,1011 +0,0 @@
-"""RFC 2822 message manipulation.
-
-Note: This is only a very rough sketch of a full RFC-822 parser; in particular
-the tokenizing of addresses does not adhere to all the quoting rules.
-
-Note: RFC 2822 is a long awaited update to RFC 822. This module should
-conform to RFC 2822, and is thus mis-named (it's not worth renaming it). Some
-effort at RFC 2822 updates have been made, but a thorough audit has not been
-performed. Consider any RFC 2822 non-conformance to be a bug.
-
- RFC 2822: http://www.faqs.org/rfcs/rfc2822.html
- RFC 822 : http://www.faqs.org/rfcs/rfc822.html (obsolete)
-
-Directions for use:
-
-To create a Message object: first open a file, e.g.:
-
- fp = open(file, 'r')
-
-You can use any other legal way of getting an open file object, e.g. use
-sys.stdin or call os.popen(). Then pass the open file object to the Message()
-constructor:
-
- m = Message(fp)
-
-This class can work with any input object that supports a readline method. If
-the input object has seek and tell capability, the rewindbody method will
-work; also illegal lines will be pushed back onto the input stream. If the
-input object lacks seek but has an `unread' method that can push back a line
-of input, Message will use that to push back illegal lines. Thus this class
-can be used to parse messages coming from a buffered stream.
-
-The optional `seekable' argument is provided as a workaround for certain stdio
-libraries in which tell() discards buffered data before discovering that the
-lseek() system call doesn't work. For maximum portability, you should set the
-seekable argument to zero to prevent that initial \code{tell} when passing in
-an unseekable object such as a file object created from a socket object. If
-it is 1 on entry -- which it is by default -- the tell() method of the open
-file object is called once; if this raises an exception, seekable is reset to
-0. For other nonzero values of seekable, this test is not made.
-
-To get the text of a particular header there are several methods:
-
- str = m.getheader(name)
- str = m.getrawheader(name)
-
-where name is the name of the header, e.g. 'Subject'. The difference is that
-getheader() strips the leading and trailing whitespace, while getrawheader()
-doesn't. Both functions retain embedded whitespace (including newlines)
-exactly as they are specified in the header, and leave the case of the text
-unchanged.
-
-For addresses and address lists there are functions
-
- realname, mailaddress = m.getaddr(name)
- list = m.getaddrlist(name)
-
-where the latter returns a list of (realname, mailaddr) tuples.
-
-There is also a method
-
- time = m.getdate(name)
-
-which parses a Date-like field and returns a time-compatible tuple,
-i.e. a tuple such as returned by time.localtime() or accepted by
-time.mktime().
-
-See the class definition for lower level access methods.
-
-There are also some utility functions here.
-"""
-# Cleanup and extensions by Eric S. Raymond <esr@thyrsus.com>
-
-import time
-
-from warnings import warnpy3k
-warnpy3k("in 3.x, rfc822 has been removed in favor of the email package",
- stacklevel=2)
-
-__all__ = ["Message","AddressList","parsedate","parsedate_tz","mktime_tz"]
-
-_blanklines = ('\r\n', '\n') # Optimization for islast()
-
-
-class Message:
- """Represents a single RFC 2822-compliant message."""
-
- def __init__(self, fp, seekable = 1):
- """Initialize the class instance and read the headers."""
- if seekable == 1:
- # Exercise tell() to make sure it works
- # (and then assume seek() works, too)
- try:
- fp.tell()
- except (AttributeError, IOError):
- seekable = 0
- self.fp = fp
- self.seekable = seekable
- self.startofheaders = None
- self.startofbody = None
- #
- if self.seekable:
- try:
- self.startofheaders = self.fp.tell()
- except IOError:
- self.seekable = 0
- #
- self.readheaders()
- #
- if self.seekable:
- try:
- self.startofbody = self.fp.tell()
- except IOError:
- self.seekable = 0
-
- def rewindbody(self):
- """Rewind the file to the start of the body (if seekable)."""
- if not self.seekable:
- raise IOError, "unseekable file"
- self.fp.seek(self.startofbody)
-
- def readheaders(self):
- """Read header lines.
-
- Read header lines up to the entirely blank line that terminates them.
- The (normally blank) line that ends the headers is skipped, but not
- included in the returned list. If a non-header line ends the headers,
- (which is an error), an attempt is made to backspace over it; it is
- never included in the returned list.
-
- The variable self.status is set to the empty string if all went well,
- otherwise it is an error message. The variable self.headers is a
- completely uninterpreted list of lines contained in the header (so
- printing them will reproduce the header exactly as it appears in the
- file).
- """
- self.dict = {}
- self.unixfrom = ''
- self.headers = lst = []
- self.status = ''
- headerseen = ""
- firstline = 1
- startofline = unread = tell = None
- if hasattr(self.fp, 'unread'):
- unread = self.fp.unread
- elif self.seekable:
- tell = self.fp.tell
- while 1:
- if tell:
- try:
- startofline = tell()
- except IOError:
- startofline = tell = None
- self.seekable = 0
- line = self.fp.readline()
- if not line:
- self.status = 'EOF in headers'
- break
- # Skip unix From name time lines
- if firstline and line.startswith('From '):
- self.unixfrom = self.unixfrom + line
- continue
- firstline = 0
- if headerseen and line[0] in ' \t':
- # It's a continuation line.
- lst.append(line)
- x = (self.dict[headerseen] + "\n " + line.strip())
- self.dict[headerseen] = x.strip()
- continue
- elif self.iscomment(line):
- # It's a comment. Ignore it.
- continue
- elif self.islast(line):
- # Note! No pushback here! The delimiter line gets eaten.
- break
- headerseen = self.isheader(line)
- if headerseen:
- # It's a legal header line, save it.
- lst.append(line)
- self.dict[headerseen] = line[len(headerseen)+1:].strip()
- continue
- else:
- # It's not a header line; throw it back and stop here.
- if not self.dict:
- self.status = 'No headers'
- else:
- self.status = 'Non-header line where header expected'
- # Try to undo the read.
- if unread:
- unread(line)
- elif tell:
- self.fp.seek(startofline)
- else:
- self.status = self.status + '; bad seek'
- break
-
- def isheader(self, line):
- """Determine whether a given line is a legal header.
-
- This method should return the header name, suitably canonicalized.
- You may override this method in order to use Message parsing on tagged
- data in RFC 2822-like formats with special header formats.
- """
- i = line.find(':')
- if i > 0:
- return line[:i].lower()
- return None
-
- def islast(self, line):
- """Determine whether a line is a legal end of RFC 2822 headers.
-
- You may override this method if your application wants to bend the
- rules, e.g. to strip trailing whitespace, or to recognize MH template
- separators ('--------'). For convenience (e.g. for code reading from
- sockets) a line consisting of \\r\\n also matches.
- """
- return line in _blanklines
-
- def iscomment(self, line):
- """Determine whether a line should be skipped entirely.
-
- You may override this method in order to use Message parsing on tagged
- data in RFC 2822-like formats that support embedded comments or
- free-text data.
- """
- return False
-
- def getallmatchingheaders(self, name):
- """Find all header lines matching a given header name.
-
- Look through the list of headers and find all lines matching a given
- header name (and their continuation lines). A list of the lines is
- returned, without interpretation. If the header does not occur, an
- empty list is returned. If the header occurs multiple times, all
- occurrences are returned. Case is not important in the header name.
- """
- name = name.lower() + ':'
- n = len(name)
- lst = []
- hit = 0
- for line in self.headers:
- if line[:n].lower() == name:
- hit = 1
- elif not line[:1].isspace():
- hit = 0
- if hit:
- lst.append(line)
- return lst
-
- def getfirstmatchingheader(self, name):
- """Get the first header line matching name.
-
- This is similar to getallmatchingheaders, but it returns only the
- first matching header (and its continuation lines).
- """
- name = name.lower() + ':'
- n = len(name)
- lst = []
- hit = 0
- for line in self.headers:
- if hit:
- if not line[:1].isspace():
- break
- elif line[:n].lower() == name:
- hit = 1
- if hit:
- lst.append(line)
- return lst
-
- def getrawheader(self, name):
- """A higher-level interface to getfirstmatchingheader().
-
- Return a string containing the literal text of the header but with the
- keyword stripped. All leading, trailing and embedded whitespace is
- kept in the string, however. Return None if the header does not
- occur.
- """
-
- lst = self.getfirstmatchingheader(name)
- if not lst:
- return None
- lst[0] = lst[0][len(name) + 1:]
- return ''.join(lst)
-
- def getheader(self, name, default=None):
- """Get the header value for a name.
-
- This is the normal interface: it returns a stripped version of the
- header value for a given header name, or None if it doesn't exist.
- This uses the dictionary version which finds the *last* such header.
- """
- return self.dict.get(name.lower(), default)
- get = getheader
-
- def getheaders(self, name):
- """Get all values for a header.
-
- This returns a list of values for headers given more than once; each
- value in the result list is stripped in the same way as the result of
- getheader(). If the header is not given, return an empty list.
- """
- result = []
- current = ''
- have_header = 0
- for s in self.getallmatchingheaders(name):
- if s[0].isspace():
- if current:
- current = "%s\n %s" % (current, s.strip())
- else:
- current = s.strip()
- else:
- if have_header:
- result.append(current)
- current = s[s.find(":") + 1:].strip()
- have_header = 1
- if have_header:
- result.append(current)
- return result
-
- def getaddr(self, name):
- """Get a single address from a header, as a tuple.
-
- An example return value:
- ('Guido van Rossum', 'guido@cwi.nl')
- """
- # New, by Ben Escoto
- alist = self.getaddrlist(name)
- if alist:
- return alist[0]
- else:
- return (None, None)
-
- def getaddrlist(self, name):
- """Get a list of addresses from a header.
-
- Retrieves a list of addresses from a header, where each address is a
- tuple as returned by getaddr(). Scans all named headers, so it works
- properly with multiple To: or Cc: headers for example.
- """
- raw = []
- for h in self.getallmatchingheaders(name):
- if h[0] in ' \t':
- raw.append(h)
- else:
- if raw:
- raw.append(', ')
- i = h.find(':')
- if i > 0:
- addr = h[i+1:]
- raw.append(addr)
- alladdrs = ''.join(raw)
- a = AddressList(alladdrs)
- return a.addresslist
-
- def getdate(self, name):
- """Retrieve a date field from a header.
-
- Retrieves a date field from the named header, returning a tuple
- compatible with time.mktime().
- """
- try:
- data = self[name]
- except KeyError:
- return None
- return parsedate(data)
-
- def getdate_tz(self, name):
- """Retrieve a date field from a header as a 10-tuple.
-
- The first 9 elements make up a tuple compatible with time.mktime(),
- and the 10th is the offset of the poster's time zone from GMT/UTC.
- """
- try:
- data = self[name]
- except KeyError:
- return None
- return parsedate_tz(data)
-
-
- # Access as a dictionary (only finds *last* header of each type):
-
- def __len__(self):
- """Get the number of headers in a message."""
- return len(self.dict)
-
- def __getitem__(self, name):
- """Get a specific header, as from a dictionary."""
- return self.dict[name.lower()]
-
- def __setitem__(self, name, value):
- """Set the value of a header.
-
- Note: This is not a perfect inversion of __getitem__, because any
- changed headers get stuck at the end of the raw-headers list rather
- than where the altered header was.
- """
- del self[name] # Won't fail if it doesn't exist
- self.dict[name.lower()] = value
- text = name + ": " + value
- for line in text.split("\n"):
- self.headers.append(line + "\n")
-
- def __delitem__(self, name):
- """Delete all occurrences of a specific header, if it is present."""
- name = name.lower()
- if not name in self.dict:
- return
- del self.dict[name]
- name = name + ':'
- n = len(name)
- lst = []
- hit = 0
- for i in range(len(self.headers)):
- line = self.headers[i]
- if line[:n].lower() == name:
- hit = 1
- elif not line[:1].isspace():
- hit = 0
- if hit:
- lst.append(i)
- for i in reversed(lst):
- del self.headers[i]
-
- def setdefault(self, name, default=""):
- lowername = name.lower()
- if lowername in self.dict:
- return self.dict[lowername]
- else:
- text = name + ": " + default
- for line in text.split("\n"):
- self.headers.append(line + "\n")
- self.dict[lowername] = default
- return default
-
- def has_key(self, name):
- """Determine whether a message contains the named header."""
- return name.lower() in self.dict
-
- def __contains__(self, name):
- """Determine whether a message contains the named header."""
- return name.lower() in self.dict
-
- def __iter__(self):
- return iter(self.dict)
-
- def keys(self):
- """Get all of a message's header field names."""
- return self.dict.keys()
-
- def values(self):
- """Get all of a message's header field values."""
- return self.dict.values()
-
- def items(self):
- """Get all of a message's headers.
-
- Returns a list of name, value tuples.
- """
- return self.dict.items()
-
- def __str__(self):
- return ''.join(self.headers)
-
-
-# Utility functions
-# -----------------
-
-# XXX Should fix unquote() and quote() to be really conformant.
-# XXX The inverses of the parse functions may also be useful.
-
-
-def unquote(s):
- """Remove quotes from a string."""
- if len(s) > 1:
- if s.startswith('"') and s.endswith('"'):
- return s[1:-1].replace('\\\\', '\\').replace('\\"', '"')
- if s.startswith('<') and s.endswith('>'):
- return s[1:-1]
- return s
-
-
-def quote(s):
- """Add quotes around a string."""
- return s.replace('\\', '\\\\').replace('"', '\\"')
-
-
-def parseaddr(address):
- """Parse an address into a (realname, mailaddr) tuple."""
- a = AddressList(address)
- lst = a.addresslist
- if not lst:
- return (None, None)
- return lst[0]
-
-
-class AddrlistClass:
- """Address parser class by Ben Escoto.
-
- To understand what this class does, it helps to have a copy of
- RFC 2822 in front of you.
-
- http://www.faqs.org/rfcs/rfc2822.html
-
- Note: this class interface is deprecated and may be removed in the future.
- Use rfc822.AddressList instead.
- """
-
- def __init__(self, field):
- """Initialize a new instance.
-
- `field' is an unparsed address header field, containing one or more
- addresses.
- """
- self.specials = '()<>@,:;.\"[]'
- self.pos = 0
- self.LWS = ' \t'
- self.CR = '\r\n'
- self.atomends = self.specials + self.LWS + self.CR
- # Note that RFC 2822 now specifies `.' as obs-phrase, meaning that it
- # is obsolete syntax. RFC 2822 requires that we recognize obsolete
- # syntax, so allow dots in phrases.
- self.phraseends = self.atomends.replace('.', '')
- self.field = field
- self.commentlist = []
-
- def gotonext(self):
- """Parse up to the start of the next address."""
- while self.pos < len(self.field):
- if self.field[self.pos] in self.LWS + '\n\r':
- self.pos = self.pos + 1
- elif self.field[self.pos] == '(':
- self.commentlist.append(self.getcomment())
- else: break
-
- def getaddrlist(self):
- """Parse all addresses.
-
- Returns a list containing all of the addresses.
- """
- result = []
- ad = self.getaddress()
- while ad:
- result += ad
- ad = self.getaddress()
- return result
-
- def getaddress(self):
- """Parse the next address."""
- self.commentlist = []
- self.gotonext()
-
- oldpos = self.pos
- oldcl = self.commentlist
- plist = self.getphraselist()
-
- self.gotonext()
- returnlist = []
-
- if self.pos >= len(self.field):
- # Bad email address technically, no domain.
- if plist:
- returnlist = [(' '.join(self.commentlist), plist[0])]
-
- elif self.field[self.pos] in '.@':
- # email address is just an addrspec
- # this isn't very efficient since we start over
- self.pos = oldpos
- self.commentlist = oldcl
- addrspec = self.getaddrspec()
- returnlist = [(' '.join(self.commentlist), addrspec)]
-
- elif self.field[self.pos] == ':':
- # address is a group
- returnlist = []
-
- fieldlen = len(self.field)
- self.pos += 1
- while self.pos < len(self.field):
- self.gotonext()
- if self.pos < fieldlen and self.field[self.pos] == ';':
- self.pos += 1
- break
- returnlist = returnlist + self.getaddress()
-
- elif self.field[self.pos] == '<':
- # Address is a phrase then a route addr
- routeaddr = self.getrouteaddr()
-
- if self.commentlist:
- returnlist = [(' '.join(plist) + ' (' + \
- ' '.join(self.commentlist) + ')', routeaddr)]
- else: returnlist = [(' '.join(plist), routeaddr)]
-
- else:
- if plist:
- returnlist = [(' '.join(self.commentlist), plist[0])]
- elif self.field[self.pos] in self.specials:
- self.pos += 1
-
- self.gotonext()
- if self.pos < len(self.field) and self.field[self.pos] == ',':
- self.pos += 1
- return returnlist
-
- def getrouteaddr(self):
- """Parse a route address (Return-path value).
-
- This method just skips all the route stuff and returns the addrspec.
- """
- if self.field[self.pos] != '<':
- return
-
- expectroute = 0
- self.pos += 1
- self.gotonext()
- adlist = ""
- while self.pos < len(self.field):
- if expectroute:
- self.getdomain()
- expectroute = 0
- elif self.field[self.pos] == '>':
- self.pos += 1
- break
- elif self.field[self.pos] == '@':
- self.pos += 1
- expectroute = 1
- elif self.field[self.pos] == ':':
- self.pos += 1
- else:
- adlist = self.getaddrspec()
- self.pos += 1
- break
- self.gotonext()
-
- return adlist
-
- def getaddrspec(self):
- """Parse an RFC 2822 addr-spec."""
- aslist = []
-
- self.gotonext()
- while self.pos < len(self.field):
- if self.field[self.pos] == '.':
- aslist.append('.')
- self.pos += 1
- elif self.field[self.pos] == '"':
- aslist.append('"%s"' % self.getquote())
- elif self.field[self.pos] in self.atomends:
- break
- else: aslist.append(self.getatom())
- self.gotonext()
-
- if self.pos >= len(self.field) or self.field[self.pos] != '@':
- return ''.join(aslist)
-
- aslist.append('@')
- self.pos += 1
- self.gotonext()
- return ''.join(aslist) + self.getdomain()
-
- def getdomain(self):
- """Get the complete domain name from an address."""
- sdlist = []
- while self.pos < len(self.field):
- if self.field[self.pos] in self.LWS:
- self.pos += 1
- elif self.field[self.pos] == '(':
- self.commentlist.append(self.getcomment())
- elif self.field[self.pos] == '[':
- sdlist.append(self.getdomainliteral())
- elif self.field[self.pos] == '.':
- self.pos += 1
- sdlist.append('.')
- elif self.field[self.pos] in self.atomends:
- break
- else: sdlist.append(self.getatom())
- return ''.join(sdlist)
-
- def getdelimited(self, beginchar, endchars, allowcomments = 1):
- """Parse a header fragment delimited by special characters.
-
- `beginchar' is the start character for the fragment. If self is not
- looking at an instance of `beginchar' then getdelimited returns the
- empty string.
-
- `endchars' is a sequence of allowable end-delimiting characters.
- Parsing stops when one of these is encountered.
-
- If `allowcomments' is non-zero, embedded RFC 2822 comments are allowed
- within the parsed fragment.
- """
- if self.field[self.pos] != beginchar:
- return ''
-
- slist = ['']
- quote = 0
- self.pos += 1
- while self.pos < len(self.field):
- if quote == 1:
- slist.append(self.field[self.pos])
- quote = 0
- elif self.field[self.pos] in endchars:
- self.pos += 1
- break
- elif allowcomments and self.field[self.pos] == '(':
- slist.append(self.getcomment())
- continue # have already advanced pos from getcomment
- elif self.field[self.pos] == '\\':
- quote = 1
- else:
- slist.append(self.field[self.pos])
- self.pos += 1
-
- return ''.join(slist)
-
- def getquote(self):
- """Get a quote-delimited fragment from self's field."""
- return self.getdelimited('"', '"\r', 0)
-
- def getcomment(self):
- """Get a parenthesis-delimited fragment from self's field."""
- return self.getdelimited('(', ')\r', 1)
-
- def getdomainliteral(self):
- """Parse an RFC 2822 domain-literal."""
- return '[%s]' % self.getdelimited('[', ']\r', 0)
-
- def getatom(self, atomends=None):
- """Parse an RFC 2822 atom.
-
- Optional atomends specifies a different set of end token delimiters
- (the default is to use self.atomends). This is used e.g. in
- getphraselist() since phrase endings must not include the `.' (which
- is legal in phrases)."""
- atomlist = ['']
- if atomends is None:
- atomends = self.atomends
-
- while self.pos < len(self.field):
- if self.field[self.pos] in atomends:
- break
- else: atomlist.append(self.field[self.pos])
- self.pos += 1
-
- return ''.join(atomlist)
-
- def getphraselist(self):
- """Parse a sequence of RFC 2822 phrases.
-
- A phrase is a sequence of words, which are in turn either RFC 2822
- atoms or quoted-strings. Phrases are canonicalized by squeezing all
- runs of continuous whitespace into one space.
- """
- plist = []
-
- while self.pos < len(self.field):
- if self.field[self.pos] in self.LWS:
- self.pos += 1
- elif self.field[self.pos] == '"':
- plist.append(self.getquote())
- elif self.field[self.pos] == '(':
- self.commentlist.append(self.getcomment())
- elif self.field[self.pos] in self.phraseends:
- break
- else:
- plist.append(self.getatom(self.phraseends))
-
- return plist
-
-class AddressList(AddrlistClass):
- """An AddressList encapsulates a list of parsed RFC 2822 addresses."""
- def __init__(self, field):
- AddrlistClass.__init__(self, field)
- if field:
- self.addresslist = self.getaddrlist()
- else:
- self.addresslist = []
-
- def __len__(self):
- return len(self.addresslist)
-
- def __str__(self):
- return ", ".join(map(dump_address_pair, self.addresslist))
-
- def __add__(self, other):
- # Set union
- newaddr = AddressList(None)
- newaddr.addresslist = self.addresslist[:]
- for x in other.addresslist:
- if not x in self.addresslist:
- newaddr.addresslist.append(x)
- return newaddr
-
- def __iadd__(self, other):
- # Set union, in-place
- for x in other.addresslist:
- if not x in self.addresslist:
- self.addresslist.append(x)
- return self
-
- def __sub__(self, other):
- # Set difference
- newaddr = AddressList(None)
- for x in self.addresslist:
- if not x in other.addresslist:
- newaddr.addresslist.append(x)
- return newaddr
-
- def __isub__(self, other):
- # Set difference, in-place
- for x in other.addresslist:
- if x in self.addresslist:
- self.addresslist.remove(x)
- return self
-
- def __getitem__(self, index):
- # Make indexing, slices, and 'in' work
- return self.addresslist[index]
-
-def dump_address_pair(pair):
- """Dump a (name, address) pair in a canonicalized form."""
- if pair[0]:
- return '"' + pair[0] + '" <' + pair[1] + '>'
- else:
- return pair[1]
-
-# Parse a date field
-
-_monthnames = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul',
- 'aug', 'sep', 'oct', 'nov', 'dec',
- 'january', 'february', 'march', 'april', 'may', 'june', 'july',
- 'august', 'september', 'october', 'november', 'december']
-_daynames = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
-
-# The timezone table does not include the military time zones defined
-# in RFC822, other than Z. According to RFC1123, the description in
-# RFC822 gets the signs wrong, so we can't rely on any such time
-# zones. RFC1123 recommends that numeric timezone indicators be used
-# instead of timezone names.
-
-_timezones = {'UT':0, 'UTC':0, 'GMT':0, 'Z':0,
- 'AST': -400, 'ADT': -300, # Atlantic (used in Canada)
- 'EST': -500, 'EDT': -400, # Eastern
- 'CST': -600, 'CDT': -500, # Central
- 'MST': -700, 'MDT': -600, # Mountain
- 'PST': -800, 'PDT': -700 # Pacific
- }
-
-
-def parsedate_tz(data):
- """Convert a date string to a time tuple.
-
- Accounts for military timezones.
- """
- if not data:
- return None
- data = data.split()
- if data[0][-1] in (',', '.') or data[0].lower() in _daynames:
- # There's a dayname here. Skip it
- del data[0]
- else:
- # no space after the "weekday,"?
- i = data[0].rfind(',')
- if i >= 0:
- data[0] = data[0][i+1:]
- if len(data) == 3: # RFC 850 date, deprecated
- stuff = data[0].split('-')
- if len(stuff) == 3:
- data = stuff + data[1:]
- if len(data) == 4:
- s = data[3]
- i = s.find('+')
- if i > 0:
- data[3:] = [s[:i], s[i+1:]]
- else:
- data.append('') # Dummy tz
- if len(data) < 5:
- return None
- data = data[:5]
- [dd, mm, yy, tm, tz] = data
- mm = mm.lower()
- if not mm in _monthnames:
- dd, mm = mm, dd.lower()
- if not mm in _monthnames:
- return None
- mm = _monthnames.index(mm)+1
- if mm > 12: mm = mm - 12
- if dd[-1] == ',':
- dd = dd[:-1]
- i = yy.find(':')
- if i > 0:
- yy, tm = tm, yy
- if yy[-1] == ',':
- yy = yy[:-1]
- if not yy[0].isdigit():
- yy, tz = tz, yy
- if tm[-1] == ',':
- tm = tm[:-1]
- tm = tm.split(':')
- if len(tm) == 2:
- [thh, tmm] = tm
- tss = '0'
- elif len(tm) == 3:
- [thh, tmm, tss] = tm
- else:
- return None
- try:
- yy = int(yy)
- dd = int(dd)
- thh = int(thh)
- tmm = int(tmm)
- tss = int(tss)
- except ValueError:
- return None
- tzoffset = None
- tz = tz.upper()
- if tz in _timezones:
- tzoffset = _timezones[tz]
- else:
- try:
- tzoffset = int(tz)
- except ValueError:
- pass
- # Convert a timezone offset into seconds ; -0500 -> -18000
- if tzoffset:
- if tzoffset < 0:
- tzsign = -1
- tzoffset = -tzoffset
- else:
- tzsign = 1
- tzoffset = tzsign * ( (tzoffset//100)*3600 + (tzoffset % 100)*60)
- return (yy, mm, dd, thh, tmm, tss, 0, 1, 0, tzoffset)
-
-
-def parsedate(data):
- """Convert a time string to a time tuple."""
- t = parsedate_tz(data)
- if t is None:
- return t
- return t[:9]
-
-
-def mktime_tz(data):
- """Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp."""
- if data[9] is None:
- # No zone info, so localtime is better assumption than GMT
- return time.mktime(data[:8] + (-1,))
- else:
- t = time.mktime(data[:8] + (0,))
- return t - data[9] - time.timezone
-
-def formatdate(timeval=None):
- """Returns time format preferred for Internet standards.
-
- Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123
-
- According to RFC 1123, day and month names must always be in
- English. If not for that, this code could use strftime(). It
- can't because strftime() honors the locale and could generated
- non-English names.
- """
- if timeval is None:
- timeval = time.time()
- timeval = time.gmtime(timeval)
- return "%s, %02d %s %04d %02d:%02d:%02d GMT" % (
- ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[timeval[6]],
- timeval[2],
- ("Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[timeval[1]-1],
- timeval[0], timeval[3], timeval[4], timeval[5])
-
-
-# When used as script, run a small test program.
-# The first command line argument must be a filename containing one
-# message in RFC-822 format.
-
-if __name__ == '__main__':
- import sys, os
- file = os.path.join(os.environ['HOME'], 'Mail/inbox/1')
- if sys.argv[1:]: file = sys.argv[1]
- f = open(file, 'r')
- m = Message(f)
- print 'From:', m.getaddr('from')
- print 'To:', m.getaddrlist('to')
- print 'Subject:', m.getheader('subject')
- print 'Date:', m.getheader('date')
- date = m.getdate_tz('date')
- tz = date[-1]
- date = time.localtime(mktime_tz(date))
- if date:
- print 'ParsedDate:', time.asctime(date),
- hhmmss = tz
- hhmm, ss = divmod(hhmmss, 60)
- hh, mm = divmod(hhmm, 60)
- print "%+03d%02d" % (hh, mm),
- if ss: print ".%02d" % ss,
- print
- else:
- print 'ParsedDate:', None
- m.rewindbody()
- n = 0
- while f.readline():
- n += 1
- print 'Lines:', n
- print '-'*70
- print 'len =', len(m)
- if 'Date' in m: print 'Date =', m['Date']
- if 'X-Nonsense' in m: pass
- print 'keys =', m.keys()
- print 'values =', m.values()
- print 'items =', m.items()
diff --git a/Lib/rlcompleter.py b/Lib/rlcompleter.py
index 366c59c0cdf..d3a443737a5 100644
--- a/Lib/rlcompleter.py
+++ b/Lib/rlcompleter.py
@@ -24,18 +24,12 @@ Notes:
feature, I consider this an acceptable risk. More complicated expressions
(e.g. function calls or indexing operations) are *not* evaluated.
-- GNU readline is also used by the built-in functions input() and
-raw_input(), and thus these also benefit/suffer from the completer
-features. Clearly an interactive application can benefit by
-specifying its own completer function and using raw_input() for all
-its input.
-
- When the original stdin is not a tty device, GNU readline is never
used, and this module (and the readline module) are silently inactive.
"""
-import __builtin__
+import builtins
import __main__
__all__ = ["Completer"]
@@ -57,7 +51,7 @@ class Completer:
"""
if namespace and not isinstance(namespace, dict):
- raise TypeError,'namespace must be a dictionary'
+ raise TypeError('namespace must be a dictionary')
# Don't bind to namespace quite yet, but flag whether the user wants a
# specific namespace or to use __main__.__dict__. This will allow us
@@ -89,7 +83,7 @@ class Completer:
return None
def _callable_postfix(self, val, word):
- if hasattr(val, '__call__'):
+ if callable(val):
word = word + "("
return word
@@ -106,7 +100,7 @@ class Completer:
for word in keyword.kwlist:
if word[:n] == text:
matches.append(word)
- for nspace in [__builtin__.__dict__, self.namespace]:
+ for nspace in [builtins.__dict__, self.namespace]:
for word, val in nspace.items():
if word[:n] == text and word != "__builtins__":
matches.append(self._callable_postfix(val, word))
diff --git a/Lib/runpy.py b/Lib/runpy.py
index c4d7cc26a25..a14a62e128a 100644
--- a/Lib/runpy.py
+++ b/Lib/runpy.py
@@ -67,9 +67,11 @@ def _run_code(code, run_globals, init_globals=None,
run_globals.update(init_globals)
run_globals.update(__name__ = mod_name,
__file__ = mod_fname,
+ __cached__ = None,
+ __doc__ = None,
__loader__ = mod_loader,
__package__ = pkg_name)
- exec code in run_globals
+ exec(code, run_globals)
return run_globals
def _run_module_code(code, init_globals=None,
@@ -107,7 +109,7 @@ def _get_module_details(mod_name):
try:
pkg_main_name = mod_name + ".__main__"
return _get_module_details(pkg_main_name)
- except ImportError, e:
+ except ImportError as e:
raise ImportError(("%s; %r is a package and cannot " +
"be directly executed") %(e, mod_name))
code = loader.get_code(mod_name)
@@ -116,23 +118,10 @@ def _get_module_details(mod_name):
filename = _get_filename(loader, mod_name)
return mod_name, loader, code, filename
-
-def _get_main_module_details():
- # Helper that gives a nicer error message when attempting to
- # execute a zipfile or directory by invoking __main__.py
- main_name = "__main__"
- try:
- return _get_module_details(main_name)
- except ImportError as exc:
- if main_name in str(exc):
- raise ImportError("can't find %r module in %r" %
- (main_name, sys.path[0]))
- raise
-
-# This function is the actual implementation of the -m switch and direct
-# execution of zipfiles and directories and is deliberately kept private.
-# This avoids a repeat of the situation where run_module() no longer met the
-# needs of mainmodule.c, but couldn't be changed because it was public
+# XXX ncoghlan: Should this be documented and made public?
+# (Current thoughts: don't repeat the mistake that lead to its
+# creation when run_module() no longer met the needs of
+# mainmodule.c, but couldn't be changed because it was public)
def _run_module_as_main(mod_name, alter_argv=True):
"""Runs the designated module in the __main__ namespace
@@ -143,6 +132,7 @@ def _run_module_as_main(mod_name, alter_argv=True):
At the very least, these variables in __main__ will be overwritten:
__name__
__file__
+ __cached__
__loader__
__package__
"""
@@ -152,7 +142,16 @@ def _run_module_as_main(mod_name, alter_argv=True):
else: # i.e. directory or zipfile execution
mod_name, loader, code, fname = _get_main_module_details()
except ImportError as exc:
- msg = "%s: %s" % (sys.executable, str(exc))
+ # Try to provide a good error message
+ # for directories, zip files and the -m switch
+ if alter_argv:
+ # For -m switch, just display the exception
+ info = str(exc)
+ else:
+ # For directories/zipfiles, let the user
+ # know what the code was looking for
+ info = "can't find '__main__' module in %r" % sys.argv[0]
+ msg = "%s: %s" % (sys.executable, info)
sys.exit(msg)
pkg_name = mod_name.rpartition('.')[0]
main_globals = sys.modules["__main__"].__dict__
@@ -179,6 +178,18 @@ def run_module(mod_name, init_globals=None,
return _run_code(code, {}, init_globals, run_name,
fname, loader, pkg_name)
+def _get_main_module_details():
+ # Helper that gives a nicer error message when attempting to
+ # execute a zipfile or directory by invoking __main__.py
+ main_name = "__main__"
+ try:
+ return _get_module_details(main_name)
+ except ImportError as exc:
+ if main_name in str(exc):
+ raise ImportError("can't find %r module in %r" %
+ (main_name, sys.path[0]))
+ raise
+
# XXX (ncoghlan): Perhaps expose the C API function
# as imp.get_importer instead of reimplementing it in Python?
@@ -216,7 +227,7 @@ def _get_code_from_file(fname):
code = read_code(f)
if code is None:
# That didn't work, so try it as normal source code
- with open(fname, "rU") as f:
+ with open(fname, "rb") as f:
code = compile(f.read(), fname, 'exec')
return code
@@ -232,12 +243,14 @@ def run_path(path_name, init_globals=None, run_name=None):
"""
if run_name is None:
run_name = "<run_path>"
+ pkg_name = run_name.rpartition(".")[0]
importer = _get_importer(path_name)
if isinstance(importer, imp.NullImporter):
# Not a valid sys.path entry, so run the code directly
# execfile() doesn't help as we want to allow compiled files
code = _get_code_from_file(path_name)
- return _run_module_code(code, init_globals, run_name, path_name)
+ return _run_module_code(code, init_globals, run_name, path_name,
+ pkg_name=pkg_name)
else:
# Importer is defined for path, so add it to
# the start of sys.path
@@ -256,7 +269,6 @@ def run_path(path_name, init_globals=None, run_name=None):
mod_name, loader, code, fname = _get_main_module_details()
finally:
sys.modules[main_name] = saved_main
- pkg_name = ""
with _TempModule(run_name) as temp_module, \
_ModifiedArgv0(path_name):
mod_globals = temp_module.module.__dict__
@@ -272,7 +284,7 @@ def run_path(path_name, init_globals=None, run_name=None):
if __name__ == "__main__":
# Run the module specified as the next command line argument
if len(sys.argv) < 2:
- print >> sys.stderr, "No module specified for execution"
+ print("No module specified for execution", file=sys.stderr)
else:
del sys.argv[0] # Make the requested module sys.argv[0]
_run_module_as_main(sys.argv[0])
diff --git a/Lib/sched.py b/Lib/sched.py
index 47646a10081..a119892c3f6 100644
--- a/Lib/sched.py
+++ b/Lib/sched.py
@@ -33,7 +33,13 @@ from collections import namedtuple
__all__ = ["scheduler"]
-Event = namedtuple('Event', 'time, priority, action, argument')
+class Event(namedtuple('Event', 'time, priority, action, argument')):
+ def __eq__(s, o): return (s.time, s.priority) == (o.time, o.priority)
+ def __ne__(s, o): return (s.time, s.priority) != (o.time, o.priority)
+ def __lt__(s, o): return (s.time, s.priority) < (o.time, o.priority)
+ def __le__(s, o): return (s.time, s.priority) <= (o.time, o.priority)
+ def __gt__(s, o): return (s.time, s.priority) > (o.time, o.priority)
+ def __ge__(s, o): return (s.time, s.priority) >= (o.time, o.priority)
class scheduler:
def __init__(self, timefunc, delayfunc):
diff --git a/Lib/sets.py b/Lib/sets.py
deleted file mode 100644
index fe31a0b7e97..00000000000
--- a/Lib/sets.py
+++ /dev/null
@@ -1,557 +0,0 @@
-"""Classes to represent arbitrary sets (including sets of sets).
-
-This module implements sets using dictionaries whose values are
-ignored. The usual operations (union, intersection, deletion, etc.)
-are provided as both methods and operators.
-
-Important: sets are not sequences! While they support 'x in s',
-'len(s)', and 'for x in s', none of those operations are unique for
-sequences; for example, mappings support all three as well. The
-characteristic operation for sequences is subscripting with small
-integers: s[i], for i in range(len(s)). Sets don't support
-subscripting at all. Also, sequences allow multiple occurrences and
-their elements have a definite order; sets on the other hand don't
-record multiple occurrences and don't remember the order of element
-insertion (which is why they don't support s[i]).
-
-The following classes are provided:
-
-BaseSet -- All the operations common to both mutable and immutable
- sets. This is an abstract class, not meant to be directly
- instantiated.
-
-Set -- Mutable sets, subclass of BaseSet; not hashable.
-
-ImmutableSet -- Immutable sets, subclass of BaseSet; hashable.
- An iterable argument is mandatory to create an ImmutableSet.
-
-_TemporarilyImmutableSet -- A wrapper around a Set, hashable,
- giving the same hash value as the immutable set equivalent
- would have. Do not use this class directly.
-
-Only hashable objects can be added to a Set. In particular, you cannot
-really add a Set as an element to another Set; if you try, what is
-actually added is an ImmutableSet built from it (it compares equal to
-the one you tried adding).
-
-When you ask if `x in y' where x is a Set and y is a Set or
-ImmutableSet, x is wrapped into a _TemporarilyImmutableSet z, and
-what's tested is actually `z in y'.
-
-"""
-
-# Code history:
-#
-# - Greg V. Wilson wrote the first version, using a different approach
-# to the mutable/immutable problem, and inheriting from dict.
-#
-# - Alex Martelli modified Greg's version to implement the current
-# Set/ImmutableSet approach, and make the data an attribute.
-#
-# - Guido van Rossum rewrote much of the code, made some API changes,
-# and cleaned up the docstrings.
-#
-# - Raymond Hettinger added a number of speedups and other
-# improvements.
-
-from itertools import ifilter, ifilterfalse
-
-__all__ = ['BaseSet', 'Set', 'ImmutableSet']
-
-import warnings
-warnings.warn("the sets module is deprecated", DeprecationWarning,
- stacklevel=2)
-
-class BaseSet(object):
- """Common base class for mutable and immutable sets."""
-
- __slots__ = ['_data']
-
- # Constructor
-
- def __init__(self):
- """This is an abstract class."""
- # Don't call this from a concrete subclass!
- if self.__class__ is BaseSet:
- raise TypeError, ("BaseSet is an abstract class. "
- "Use Set or ImmutableSet.")
-
- # Standard protocols: __len__, __repr__, __str__, __iter__
-
- def __len__(self):
- """Return the number of elements of a set."""
- return len(self._data)
-
- def __repr__(self):
- """Return string representation of a set.
-
- This looks like 'Set([<list of elements>])'.
- """
- return self._repr()
-
- # __str__ is the same as __repr__
- __str__ = __repr__
-
- def _repr(self, sorted=False):
- elements = self._data.keys()
- if sorted:
- elements.sort()
- return '%s(%r)' % (self.__class__.__name__, elements)
-
- def __iter__(self):
- """Return an iterator over the elements or a set.
-
- This is the keys iterator for the underlying dict.
- """
- return self._data.iterkeys()
-
- # Three-way comparison is not supported. However, because __eq__ is
- # tried before __cmp__, if Set x == Set y, x.__eq__(y) returns True and
- # then cmp(x, y) returns 0 (Python doesn't actually call __cmp__ in this
- # case).
-
- def __cmp__(self, other):
- raise TypeError, "can't compare sets using cmp()"
-
- # Equality comparisons using the underlying dicts. Mixed-type comparisons
- # are allowed here, where Set == z for non-Set z always returns False,
- # and Set != z always True. This allows expressions like "x in y" to
- # give the expected result when y is a sequence of mixed types, not
- # raising a pointless TypeError just because y contains a Set, or x is
- # a Set and y contain's a non-set ("in" invokes only __eq__).
- # Subtle: it would be nicer if __eq__ and __ne__ could return
- # NotImplemented instead of True or False. Then the other comparand
- # would get a chance to determine the result, and if the other comparand
- # also returned NotImplemented then it would fall back to object address
- # comparison (which would always return False for __eq__ and always
- # True for __ne__). However, that doesn't work, because this type
- # *also* implements __cmp__: if, e.g., __eq__ returns NotImplemented,
- # Python tries __cmp__ next, and the __cmp__ here then raises TypeError.
-
- def __eq__(self, other):
- if isinstance(other, BaseSet):
- return self._data == other._data
- else:
- return False
-
- def __ne__(self, other):
- if isinstance(other, BaseSet):
- return self._data != other._data
- else:
- return True
-
- # Copying operations
-
- def copy(self):
- """Return a shallow copy of a set."""
- result = self.__class__()
- result._data.update(self._data)
- return result
-
- __copy__ = copy # For the copy module
-
- def __deepcopy__(self, memo):
- """Return a deep copy of a set; used by copy module."""
- # This pre-creates the result and inserts it in the memo
- # early, in case the deep copy recurses into another reference
- # to this same set. A set can't be an element of itself, but
- # it can certainly contain an object that has a reference to
- # itself.
- from copy import deepcopy
- result = self.__class__()
- memo[id(self)] = result
- data = result._data
- value = True
- for elt in self:
- data[deepcopy(elt, memo)] = value
- return result
-
- # Standard set operations: union, intersection, both differences.
- # Each has an operator version (e.g. __or__, invoked with |) and a
- # method version (e.g. union).
- # Subtle: Each pair requires distinct code so that the outcome is
- # correct when the type of other isn't suitable. For example, if
- # we did "union = __or__" instead, then Set().union(3) would return
- # NotImplemented instead of raising TypeError (albeit that *why* it
- # raises TypeError as-is is also a bit subtle).
-
- def __or__(self, other):
- """Return the union of two sets as a new set.
-
- (I.e. all elements that are in either set.)
- """
- if not isinstance(other, BaseSet):
- return NotImplemented
- return self.union(other)
-
- def union(self, other):
- """Return the union of two sets as a new set.
-
- (I.e. all elements that are in either set.)
- """
- result = self.__class__(self)
- result._update(other)
- return result
-
- def __and__(self, other):
- """Return the intersection of two sets as a new set.
-
- (I.e. all elements that are in both sets.)
- """
- if not isinstance(other, BaseSet):
- return NotImplemented
- return self.intersection(other)
-
- def intersection(self, other):
- """Return the intersection of two sets as a new set.
-
- (I.e. all elements that are in both sets.)
- """
- if not isinstance(other, BaseSet):
- other = Set(other)
- if len(self) <= len(other):
- little, big = self, other
- else:
- little, big = other, self
- common = ifilter(big._data.__contains__, little)
- return self.__class__(common)
-
- def __xor__(self, other):
- """Return the symmetric difference of two sets as a new set.
-
- (I.e. all elements that are in exactly one of the sets.)
- """
- if not isinstance(other, BaseSet):
- return NotImplemented
- return self.symmetric_difference(other)
-
- def symmetric_difference(self, other):
- """Return the symmetric difference of two sets as a new set.
-
- (I.e. all elements that are in exactly one of the sets.)
- """
- result = self.__class__()
- data = result._data
- value = True
- selfdata = self._data
- try:
- otherdata = other._data
- except AttributeError:
- otherdata = Set(other)._data
- for elt in ifilterfalse(otherdata.__contains__, selfdata):
- data[elt] = value
- for elt in ifilterfalse(selfdata.__contains__, otherdata):
- data[elt] = value
- return result
-
- def __sub__(self, other):
- """Return the difference of two sets as a new Set.
-
- (I.e. all elements that are in this set and not in the other.)
- """
- if not isinstance(other, BaseSet):
- return NotImplemented
- return self.difference(other)
-
- def difference(self, other):
- """Return the difference of two sets as a new Set.
-
- (I.e. all elements that are in this set and not in the other.)
- """
- result = self.__class__()
- data = result._data
- try:
- otherdata = other._data
- except AttributeError:
- otherdata = Set(other)._data
- value = True
- for elt in ifilterfalse(otherdata.__contains__, self):
- data[elt] = value
- return result
-
- # Membership test
-
- def __contains__(self, element):
- """Report whether an element is a member of a set.
-
- (Called in response to the expression `element in self'.)
- """
- try:
- return element in self._data
- except TypeError:
- transform = getattr(element, "__as_temporarily_immutable__", None)
- if transform is None:
- raise # re-raise the TypeError exception we caught
- return transform() in self._data
-
- # Subset and superset test
-
- def issubset(self, other):
- """Report whether another set contains this set."""
- self._binary_sanity_check(other)
- if len(self) > len(other): # Fast check for obvious cases
- return False
- for elt in ifilterfalse(other._data.__contains__, self):
- return False
- return True
-
- def issuperset(self, other):
- """Report whether this set contains another set."""
- self._binary_sanity_check(other)
- if len(self) < len(other): # Fast check for obvious cases
- return False
- for elt in ifilterfalse(self._data.__contains__, other):
- return False
- return True
-
- # Inequality comparisons using the is-subset relation.
- __le__ = issubset
- __ge__ = issuperset
-
- def __lt__(self, other):
- self._binary_sanity_check(other)
- return len(self) < len(other) and self.issubset(other)
-
- def __gt__(self, other):
- self._binary_sanity_check(other)
- return len(self) > len(other) and self.issuperset(other)
-
- # We inherit object.__hash__, so we must deny this explicitly
- __hash__ = None
-
- # Assorted helpers
-
- def _binary_sanity_check(self, other):
- # Check that the other argument to a binary operation is also
- # a set, raising a TypeError otherwise.
- if not isinstance(other, BaseSet):
- raise TypeError, "Binary operation only permitted between sets"
-
- def _compute_hash(self):
- # Calculate hash code for a set by xor'ing the hash codes of
- # the elements. This ensures that the hash code does not depend
- # on the order in which elements are added to the set. This is
- # not called __hash__ because a BaseSet should not be hashable;
- # only an ImmutableSet is hashable.
- result = 0
- for elt in self:
- result ^= hash(elt)
- return result
-
- def _update(self, iterable):
- # The main loop for update() and the subclass __init__() methods.
- data = self._data
-
- # Use the fast update() method when a dictionary is available.
- if isinstance(iterable, BaseSet):
- data.update(iterable._data)
- return
-
- value = True
-
- if type(iterable) in (list, tuple, xrange):
- # Optimized: we know that __iter__() and next() can't
- # raise TypeError, so we can move 'try:' out of the loop.
- it = iter(iterable)
- while True:
- try:
- for element in it:
- data[element] = value
- return
- except TypeError:
- transform = getattr(element, "__as_immutable__", None)
- if transform is None:
- raise # re-raise the TypeError exception we caught
- data[transform()] = value
- else:
- # Safe: only catch TypeError where intended
- for element in iterable:
- try:
- data[element] = value
- except TypeError:
- transform = getattr(element, "__as_immutable__", None)
- if transform is None:
- raise # re-raise the TypeError exception we caught
- data[transform()] = value
-
-
-class ImmutableSet(BaseSet):
- """Immutable set class."""
-
- __slots__ = ['_hashcode']
-
- # BaseSet + hashing
-
- def __init__(self, iterable=None):
- """Construct an immutable set from an optional iterable."""
- self._hashcode = None
- self._data = {}
- if iterable is not None:
- self._update(iterable)
-
- def __hash__(self):
- if self._hashcode is None:
- self._hashcode = self._compute_hash()
- return self._hashcode
-
- def __getstate__(self):
- return self._data, self._hashcode
-
- def __setstate__(self, state):
- self._data, self._hashcode = state
-
-class Set(BaseSet):
- """ Mutable set class."""
-
- __slots__ = []
-
- # BaseSet + operations requiring mutability; no hashing
-
- def __init__(self, iterable=None):
- """Construct a set from an optional iterable."""
- self._data = {}
- if iterable is not None:
- self._update(iterable)
-
- def __getstate__(self):
- # getstate's results are ignored if it is not
- return self._data,
-
- def __setstate__(self, data):
- self._data, = data
-
- # In-place union, intersection, differences.
- # Subtle: The xyz_update() functions deliberately return None,
- # as do all mutating operations on built-in container types.
- # The __xyz__ spellings have to return self, though.
-
- def __ior__(self, other):
- """Update a set with the union of itself and another."""
- self._binary_sanity_check(other)
- self._data.update(other._data)
- return self
-
- def union_update(self, other):
- """Update a set with the union of itself and another."""
- self._update(other)
-
- def __iand__(self, other):
- """Update a set with the intersection of itself and another."""
- self._binary_sanity_check(other)
- self._data = (self & other)._data
- return self
-
- def intersection_update(self, other):
- """Update a set with the intersection of itself and another."""
- if isinstance(other, BaseSet):
- self &= other
- else:
- self._data = (self.intersection(other))._data
-
- def __ixor__(self, other):
- """Update a set with the symmetric difference of itself and another."""
- self._binary_sanity_check(other)
- self.symmetric_difference_update(other)
- return self
-
- def symmetric_difference_update(self, other):
- """Update a set with the symmetric difference of itself and another."""
- data = self._data
- value = True
- if not isinstance(other, BaseSet):
- other = Set(other)
- if self is other:
- self.clear()
- for elt in other:
- if elt in data:
- del data[elt]
- else:
- data[elt] = value
-
- def __isub__(self, other):
- """Remove all elements of another set from this set."""
- self._binary_sanity_check(other)
- self.difference_update(other)
- return self
-
- def difference_update(self, other):
- """Remove all elements of another set from this set."""
- data = self._data
- if not isinstance(other, BaseSet):
- other = Set(other)
- if self is other:
- self.clear()
- for elt in ifilter(data.__contains__, other):
- del data[elt]
-
- # Python dict-like mass mutations: update, clear
-
- def update(self, iterable):
- """Add all values from an iterable (such as a list or file)."""
- self._update(iterable)
-
- def clear(self):
- """Remove all elements from this set."""
- self._data.clear()
-
- # Single-element mutations: add, remove, discard
-
- def add(self, element):
- """Add an element to a set.
-
- This has no effect if the element is already present.
- """
- try:
- self._data[element] = True
- except TypeError:
- transform = getattr(element, "__as_immutable__", None)
- if transform is None:
- raise # re-raise the TypeError exception we caught
- self._data[transform()] = True
-
- def remove(self, element):
- """Remove an element from a set; it must be a member.
-
- If the element is not a member, raise a KeyError.
- """
- try:
- del self._data[element]
- except TypeError:
- transform = getattr(element, "__as_temporarily_immutable__", None)
- if transform is None:
- raise # re-raise the TypeError exception we caught
- del self._data[transform()]
-
- def discard(self, element):
- """Remove an element from a set if it is a member.
-
- If the element is not a member, do nothing.
- """
- try:
- self.remove(element)
- except KeyError:
- pass
-
- def pop(self):
- """Remove and return an arbitrary set element."""
- return self._data.popitem()[0]
-
- def __as_immutable__(self):
- # Return a copy of self as an immutable set
- return ImmutableSet(self)
-
- def __as_temporarily_immutable__(self):
- # Return self wrapped in a temporarily immutable set
- return _TemporarilyImmutableSet(self)
-
-
-class _TemporarilyImmutableSet(BaseSet):
- # Wrap a mutable set as if it was temporarily immutable.
- # This only supplies hashing and equality comparisons.
-
- def __init__(self, set):
- self._set = set
- self._data = set._data # Needed by ImmutableSet.__eq__()
-
- def __hash__(self):
- return self._set._compute_hash()
diff --git a/Lib/sgmllib.py b/Lib/sgmllib.py
deleted file mode 100644
index 104b25f2a07..00000000000
--- a/Lib/sgmllib.py
+++ /dev/null
@@ -1,553 +0,0 @@
-"""A parser for SGML, using the derived class as a static DTD."""
-
-# XXX This only supports those SGML features used by HTML.
-
-# XXX There should be a way to distinguish between PCDATA (parsed
-# character data -- the normal case), RCDATA (replaceable character
-# data -- only char and entity references and end tags are special)
-# and CDATA (character data -- only end tags are special). RCDATA is
-# not supported at all.
-
-
-from warnings import warnpy3k
-warnpy3k("the sgmllib module has been removed in Python 3.0",
- stacklevel=2)
-del warnpy3k
-
-import markupbase
-import re
-
-__all__ = ["SGMLParser", "SGMLParseError"]
-
-# Regular expressions used for parsing
-
-interesting = re.compile('[&<]')
-incomplete = re.compile('&([a-zA-Z][a-zA-Z0-9]*|#[0-9]*)?|'
- '<([a-zA-Z][^<>]*|'
- '/([a-zA-Z][^<>]*)?|'
- '![^<>]*)?')
-
-entityref = re.compile('&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]')
-charref = re.compile('&#([0-9]+)[^0-9]')
-
-starttagopen = re.compile('<[>a-zA-Z]')
-shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/')
-shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/')
-piclose = re.compile('>')
-endbracket = re.compile('[<>]')
-tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*')
-attrfind = re.compile(
- r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
- r'(\'[^\']*\'|"[^"]*"|[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?')
-
-
-class SGMLParseError(RuntimeError):
- """Exception raised for all parse errors."""
- pass
-
-
-# SGML parser base class -- find tags and call handler functions.
-# Usage: p = SGMLParser(); p.feed(data); ...; p.close().
-# The dtd is defined by deriving a class which defines methods
-# with special names to handle tags: start_foo and end_foo to handle
-# <foo> and </foo>, respectively, or do_foo to handle <foo> by itself.
-# (Tags are converted to lower case for this purpose.) The data
-# between tags is passed to the parser by calling self.handle_data()
-# with some data as argument (the data may be split up in arbitrary
-# chunks). Entity references are passed by calling
-# self.handle_entityref() with the entity reference as argument.
-
-class SGMLParser(markupbase.ParserBase):
- # Definition of entities -- derived classes may override
- entity_or_charref = re.compile('&(?:'
- '([a-zA-Z][-.a-zA-Z0-9]*)|#([0-9]+)'
- ')(;?)')
-
- def __init__(self, verbose=0):
- """Initialize and reset this instance."""
- self.verbose = verbose
- self.reset()
-
- def reset(self):
- """Reset this instance. Loses all unprocessed data."""
- self.__starttag_text = None
- self.rawdata = ''
- self.stack = []
- self.lasttag = '???'
- self.nomoretags = 0
- self.literal = 0
- markupbase.ParserBase.reset(self)
-
- def setnomoretags(self):
- """Enter literal mode (CDATA) till EOF.
-
- Intended for derived classes only.
- """
- self.nomoretags = self.literal = 1
-
- def setliteral(self, *args):
- """Enter literal mode (CDATA).
-
- Intended for derived classes only.
- """
- self.literal = 1
-
- def feed(self, data):
- """Feed some data to the parser.
-
- Call this as often as you want, with as little or as much text
- as you want (may include '\n'). (This just saves the text,
- all the processing is done by goahead().)
- """
-
- self.rawdata = self.rawdata + data
- self.goahead(0)
-
- def close(self):
- """Handle the remaining data."""
- self.goahead(1)
-
- def error(self, message):
- raise SGMLParseError(message)
-
- # Internal -- handle data as far as reasonable. May leave state
- # and data to be processed by a subsequent call. If 'end' is
- # true, force handling all data as if followed by EOF marker.
- def goahead(self, end):
- rawdata = self.rawdata
- i = 0
- n = len(rawdata)
- while i < n:
- if self.nomoretags:
- self.handle_data(rawdata[i:n])
- i = n
- break
- match = interesting.search(rawdata, i)
- if match: j = match.start()
- else: j = n
- if i < j:
- self.handle_data(rawdata[i:j])
- i = j
- if i == n: break
- if rawdata[i] == '<':
- if starttagopen.match(rawdata, i):
- if self.literal:
- self.handle_data(rawdata[i])
- i = i+1
- continue
- k = self.parse_starttag(i)
- if k < 0: break
- i = k
- continue
- if rawdata.startswith("</", i):
- k = self.parse_endtag(i)
- if k < 0: break
- i = k
- self.literal = 0
- continue
- if self.literal:
- if n > (i + 1):
- self.handle_data("<")
- i = i+1
- else:
- # incomplete
- break
- continue
- if rawdata.startswith("<!--", i):
- # Strictly speaking, a comment is --.*--
- # within a declaration tag <!...>.
- # This should be removed,
- # and comments handled only in parse_declaration.
- k = self.parse_comment(i)
- if k < 0: break
- i = k
- continue
- if rawdata.startswith("<?", i):
- k = self.parse_pi(i)
- if k < 0: break
- i = i+k
- continue
- if rawdata.startswith("<!", i):
- # This is some sort of declaration; in "HTML as
- # deployed," this should only be the document type
- # declaration ("<!DOCTYPE html...>").
- k = self.parse_declaration(i)
- if k < 0: break
- i = k
- continue
- elif rawdata[i] == '&':
- if self.literal:
- self.handle_data(rawdata[i])
- i = i+1
- continue
- match = charref.match(rawdata, i)
- if match:
- name = match.group(1)
- self.handle_charref(name)
- i = match.end(0)
- if rawdata[i-1] != ';': i = i-1
- continue
- match = entityref.match(rawdata, i)
- if match:
- name = match.group(1)
- self.handle_entityref(name)
- i = match.end(0)
- if rawdata[i-1] != ';': i = i-1
- continue
- else:
- self.error('neither < nor & ??')
- # We get here only if incomplete matches but
- # nothing else
- match = incomplete.match(rawdata, i)
- if not match:
- self.handle_data(rawdata[i])
- i = i+1
- continue
- j = match.end(0)
- if j == n:
- break # Really incomplete
- self.handle_data(rawdata[i:j])
- i = j
- # end while
- if end and i < n:
- self.handle_data(rawdata[i:n])
- i = n
- self.rawdata = rawdata[i:]
- # XXX if end: check for empty stack
-
- # Extensions for the DOCTYPE scanner:
- _decl_otherchars = '='
-
- # Internal -- parse processing instr, return length or -1 if not terminated
- def parse_pi(self, i):
- rawdata = self.rawdata
- if rawdata[i:i+2] != '<?':
- self.error('unexpected call to parse_pi()')
- match = piclose.search(rawdata, i+2)
- if not match:
- return -1
- j = match.start(0)
- self.handle_pi(rawdata[i+2: j])
- j = match.end(0)
- return j-i
-
- def get_starttag_text(self):
- return self.__starttag_text
-
- # Internal -- handle starttag, return length or -1 if not terminated
- def parse_starttag(self, i):
- self.__starttag_text = None
- start_pos = i
- rawdata = self.rawdata
- if shorttagopen.match(rawdata, i):
- # SGML shorthand: <tag/data/ == <tag>data</tag>
- # XXX Can data contain &... (entity or char refs)?
- # XXX Can data contain < or > (tag characters)?
- # XXX Can there be whitespace before the first /?
- match = shorttag.match(rawdata, i)
- if not match:
- return -1
- tag, data = match.group(1, 2)
- self.__starttag_text = '<%s/' % tag
- tag = tag.lower()
- k = match.end(0)
- self.finish_shorttag(tag, data)
- self.__starttag_text = rawdata[start_pos:match.end(1) + 1]
- return k
- # XXX The following should skip matching quotes (' or ")
- # As a shortcut way to exit, this isn't so bad, but shouldn't
- # be used to locate the actual end of the start tag since the
- # < or > characters may be embedded in an attribute value.
- match = endbracket.search(rawdata, i+1)
- if not match:
- return -1
- j = match.start(0)
- # Now parse the data between i+1 and j into a tag and attrs
- attrs = []
- if rawdata[i:i+2] == '<>':
- # SGML shorthand: <> == <last open tag seen>
- k = j
- tag = self.lasttag
- else:
- match = tagfind.match(rawdata, i+1)
- if not match:
- self.error('unexpected call to parse_starttag')
- k = match.end(0)
- tag = rawdata[i+1:k].lower()
- self.lasttag = tag
- while k < j:
- match = attrfind.match(rawdata, k)
- if not match: break
- attrname, rest, attrvalue = match.group(1, 2, 3)
- if not rest:
- attrvalue = attrname
- else:
- if (attrvalue[:1] == "'" == attrvalue[-1:] or
- attrvalue[:1] == '"' == attrvalue[-1:]):
- # strip quotes
- attrvalue = attrvalue[1:-1]
- attrvalue = self.entity_or_charref.sub(
- self._convert_ref, attrvalue)
- attrs.append((attrname.lower(), attrvalue))
- k = match.end(0)
- if rawdata[j] == '>':
- j = j+1
- self.__starttag_text = rawdata[start_pos:j]
- self.finish_starttag(tag, attrs)
- return j
-
- # Internal -- convert entity or character reference
- def _convert_ref(self, match):
- if match.group(2):
- return self.convert_charref(match.group(2)) or \
- '&#%s%s' % match.groups()[1:]
- elif match.group(3):
- return self.convert_entityref(match.group(1)) or \
- '&%s;' % match.group(1)
- else:
- return '&%s' % match.group(1)
-
- # Internal -- parse endtag
- def parse_endtag(self, i):
- rawdata = self.rawdata
- match = endbracket.search(rawdata, i+1)
- if not match:
- return -1
- j = match.start(0)
- tag = rawdata[i+2:j].strip().lower()
- if rawdata[j] == '>':
- j = j+1
- self.finish_endtag(tag)
- return j
-
- # Internal -- finish parsing of <tag/data/ (same as <tag>data</tag>)
- def finish_shorttag(self, tag, data):
- self.finish_starttag(tag, [])
- self.handle_data(data)
- self.finish_endtag(tag)
-
- # Internal -- finish processing of start tag
- # Return -1 for unknown tag, 0 for open-only tag, 1 for balanced tag
- def finish_starttag(self, tag, attrs):
- try:
- method = getattr(self, 'start_' + tag)
- except AttributeError:
- try:
- method = getattr(self, 'do_' + tag)
- except AttributeError:
- self.unknown_starttag(tag, attrs)
- return -1
- else:
- self.handle_starttag(tag, method, attrs)
- return 0
- else:
- self.stack.append(tag)
- self.handle_starttag(tag, method, attrs)
- return 1
-
- # Internal -- finish processing of end tag
- def finish_endtag(self, tag):
- if not tag:
- found = len(self.stack) - 1
- if found < 0:
- self.unknown_endtag(tag)
- return
- else:
- if tag not in self.stack:
- try:
- method = getattr(self, 'end_' + tag)
- except AttributeError:
- self.unknown_endtag(tag)
- else:
- self.report_unbalanced(tag)
- return
- found = len(self.stack)
- for i in range(found):
- if self.stack[i] == tag: found = i
- while len(self.stack) > found:
- tag = self.stack[-1]
- try:
- method = getattr(self, 'end_' + tag)
- except AttributeError:
- method = None
- if method:
- self.handle_endtag(tag, method)
- else:
- self.unknown_endtag(tag)
- del self.stack[-1]
-
- # Overridable -- handle start tag
- def handle_starttag(self, tag, method, attrs):
- method(attrs)
-
- # Overridable -- handle end tag
- def handle_endtag(self, tag, method):
- method()
-
- # Example -- report an unbalanced </...> tag.
- def report_unbalanced(self, tag):
- if self.verbose:
- print '*** Unbalanced </' + tag + '>'
- print '*** Stack:', self.stack
-
- def convert_charref(self, name):
- """Convert character reference, may be overridden."""
- try:
- n = int(name)
- except ValueError:
- return
- if not 0 <= n <= 127:
- return
- return self.convert_codepoint(n)
-
- def convert_codepoint(self, codepoint):
- return chr(codepoint)
-
- def handle_charref(self, name):
- """Handle character reference, no need to override."""
- replacement = self.convert_charref(name)
- if replacement is None:
- self.unknown_charref(name)
- else:
- self.handle_data(replacement)
-
- # Definition of entities -- derived classes may override
- entitydefs = \
- {'lt': '<', 'gt': '>', 'amp': '&', 'quot': '"', 'apos': '\''}
-
- def convert_entityref(self, name):
- """Convert entity references.
-
- As an alternative to overriding this method; one can tailor the
- results by setting up the self.entitydefs mapping appropriately.
- """
- table = self.entitydefs
- if name in table:
- return table[name]
- else:
- return
-
- def handle_entityref(self, name):
- """Handle entity references, no need to override."""
- replacement = self.convert_entityref(name)
- if replacement is None:
- self.unknown_entityref(name)
- else:
- self.handle_data(replacement)
-
- # Example -- handle data, should be overridden
- def handle_data(self, data):
- pass
-
- # Example -- handle comment, could be overridden
- def handle_comment(self, data):
- pass
-
- # Example -- handle declaration, could be overridden
- def handle_decl(self, decl):
- pass
-
- # Example -- handle processing instruction, could be overridden
- def handle_pi(self, data):
- pass
-
- # To be overridden -- handlers for unknown objects
- def unknown_starttag(self, tag, attrs): pass
- def unknown_endtag(self, tag): pass
- def unknown_charref(self, ref): pass
- def unknown_entityref(self, ref): pass
-
-
-class TestSGMLParser(SGMLParser):
-
- def __init__(self, verbose=0):
- self.testdata = ""
- SGMLParser.__init__(self, verbose)
-
- def handle_data(self, data):
- self.testdata = self.testdata + data
- if len(repr(self.testdata)) >= 70:
- self.flush()
-
- def flush(self):
- data = self.testdata
- if data:
- self.testdata = ""
- print 'data:', repr(data)
-
- def handle_comment(self, data):
- self.flush()
- r = repr(data)
- if len(r) > 68:
- r = r[:32] + '...' + r[-32:]
- print 'comment:', r
-
- def unknown_starttag(self, tag, attrs):
- self.flush()
- if not attrs:
- print 'start tag: <' + tag + '>'
- else:
- print 'start tag: <' + tag,
- for name, value in attrs:
- print name + '=' + '"' + value + '"',
- print '>'
-
- def unknown_endtag(self, tag):
- self.flush()
- print 'end tag: </' + tag + '>'
-
- def unknown_entityref(self, ref):
- self.flush()
- print '*** unknown entity ref: &' + ref + ';'
-
- def unknown_charref(self, ref):
- self.flush()
- print '*** unknown char ref: &#' + ref + ';'
-
- def unknown_decl(self, data):
- self.flush()
- print '*** unknown decl: [' + data + ']'
-
- def close(self):
- SGMLParser.close(self)
- self.flush()
-
-
-def test(args = None):
- import sys
-
- if args is None:
- args = sys.argv[1:]
-
- if args and args[0] == '-s':
- args = args[1:]
- klass = SGMLParser
- else:
- klass = TestSGMLParser
-
- if args:
- file = args[0]
- else:
- file = 'test.html'
-
- if file == '-':
- f = sys.stdin
- else:
- try:
- f = open(file, 'r')
- except IOError, msg:
- print file, ":", msg
- sys.exit(1)
-
- data = f.read()
- if f is not sys.stdin:
- f.close()
-
- x = klass()
- for c in data:
- x.feed(c)
- x.close()
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/sha.py b/Lib/sha.py
deleted file mode 100644
index 41dde8dde27..00000000000
--- a/Lib/sha.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# $Id$
-#
-# Copyright (C) 2005 Gregory P. Smith (greg@krypto.org)
-# Licensed to PSF under a Contributor Agreement.
-
-import warnings
-warnings.warn("the sha module is deprecated; use the hashlib module instead",
- DeprecationWarning, 2)
-
-from hashlib import sha1 as sha
-new = sha
-
-blocksize = 1 # legacy value (wrong in any useful sense)
-digest_size = 20
-digestsize = 20
diff --git a/Lib/shelve.py b/Lib/shelve.py
index c8cba8582d6..cc1815e3eb8 100644
--- a/Lib/shelve.py
+++ b/Lib/shelve.py
@@ -20,7 +20,7 @@ object):
# access returns a *copy* of the entry!
del d[key] # delete data stored at key (raises KeyError
# if no such key)
- flag = d.has_key(key) # true if the key exists; same as "key in d"
+ flag = key in d # true if the key exists
list = d.keys() # a list of all existing keys (slow!)
d.close() # close it
@@ -56,61 +56,53 @@ entries in the cache, and empty the cache (d.sync() also synchronizes
the persistent dictionary on disk, if feasible).
"""
-# Try using cPickle and cStringIO if available.
+from pickle import Pickler, Unpickler
+from io import BytesIO
-try:
- from cPickle import Pickler, Unpickler
-except ImportError:
- from pickle import Pickler, Unpickler
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-import UserDict
+import collections
__all__ = ["Shelf","BsdDbShelf","DbfilenameShelf","open"]
-class _ClosedDict(UserDict.DictMixin):
+class _ClosedDict(collections.MutableMapping):
'Marker for a closed dict. Access attempts raise a ValueError.'
def closed(self, *args):
raise ValueError('invalid operation on closed shelf')
- __getitem__ = __setitem__ = __delitem__ = keys = closed
+ __iter__ = __len__ = __getitem__ = __setitem__ = __delitem__ = keys = closed
def __repr__(self):
return '<Closed Dictionary>'
-class Shelf(UserDict.DictMixin):
+
+class Shelf(collections.MutableMapping):
"""Base class for shelf implementations.
This is initialized with a dictionary-like object.
See the module's __doc__ string for an overview of the interface.
"""
- def __init__(self, dict, protocol=None, writeback=False):
+ def __init__(self, dict, protocol=None, writeback=False,
+ keyencoding="utf-8"):
self.dict = dict
if protocol is None:
- protocol = 0
+ protocol = 3
self._protocol = protocol
self.writeback = writeback
self.cache = {}
+ self.keyencoding = keyencoding
- def keys(self):
- return self.dict.keys()
+ def __iter__(self):
+ for k in self.dict.keys():
+ yield k.decode(self.keyencoding)
def __len__(self):
return len(self.dict)
- def has_key(self, key):
- return key in self.dict
-
def __contains__(self, key):
- return key in self.dict
+ return key.encode(self.keyencoding) in self.dict
def get(self, key, default=None):
- if key in self.dict:
+ if key.encode(self.keyencoding) in self.dict:
return self[key]
return default
@@ -118,7 +110,7 @@ class Shelf(UserDict.DictMixin):
try:
value = self.cache[key]
except KeyError:
- f = StringIO(self.dict[key])
+ f = BytesIO(self.dict[key.encode(self.keyencoding)])
value = Unpickler(f).load()
if self.writeback:
self.cache[key] = value
@@ -127,13 +119,13 @@ class Shelf(UserDict.DictMixin):
def __setitem__(self, key, value):
if self.writeback:
self.cache[key] = value
- f = StringIO()
+ f = BytesIO()
p = Pickler(f, self._protocol)
p.dump(value)
- self.dict[key] = f.getvalue()
+ self.dict[key.encode(self.keyencoding)] = f.getvalue()
def __delitem__(self, key):
- del self.dict[key]
+ del self.dict[key.encode(self.keyencoding)]
try:
del self.cache[key]
except KeyError:
@@ -161,7 +153,7 @@ class Shelf(UserDict.DictMixin):
def sync(self):
if self.writeback and self.cache:
self.writeback = False
- for key, entry in self.cache.iteritems():
+ for key, entry in self.cache.items():
self[key] = entry
self.writeback = True
self.cache = {}
@@ -182,45 +174,46 @@ class BsdDbShelf(Shelf):
See the module's __doc__ string for an overview of the interface.
"""
- def __init__(self, dict, protocol=None, writeback=False):
- Shelf.__init__(self, dict, protocol, writeback)
+ def __init__(self, dict, protocol=None, writeback=False,
+ keyencoding="utf-8"):
+ Shelf.__init__(self, dict, protocol, writeback, keyencoding)
def set_location(self, key):
(key, value) = self.dict.set_location(key)
- f = StringIO(value)
- return (key, Unpickler(f).load())
+ f = BytesIO(value)
+ return (key.decode(self.keyencoding), Unpickler(f).load())
def next(self):
- (key, value) = self.dict.next()
- f = StringIO(value)
- return (key, Unpickler(f).load())
+ (key, value) = next(self.dict)
+ f = BytesIO(value)
+ return (key.decode(self.keyencoding), Unpickler(f).load())
def previous(self):
(key, value) = self.dict.previous()
- f = StringIO(value)
- return (key, Unpickler(f).load())
+ f = BytesIO(value)
+ return (key.decode(self.keyencoding), Unpickler(f).load())
def first(self):
(key, value) = self.dict.first()
- f = StringIO(value)
- return (key, Unpickler(f).load())
+ f = BytesIO(value)
+ return (key.decode(self.keyencoding), Unpickler(f).load())
def last(self):
(key, value) = self.dict.last()
- f = StringIO(value)
- return (key, Unpickler(f).load())
+ f = BytesIO(value)
+ return (key.decode(self.keyencoding), Unpickler(f).load())
class DbfilenameShelf(Shelf):
- """Shelf implementation using the "anydbm" generic dbm interface.
+ """Shelf implementation using the "dbm" generic dbm interface.
This is initialized with the filename for the dbm database.
See the module's __doc__ string for an overview of the interface.
"""
def __init__(self, filename, flag='c', protocol=None, writeback=False):
- import anydbm
- Shelf.__init__(self, anydbm.open(filename, flag), protocol, writeback)
+ import dbm
+ Shelf.__init__(self, dbm.open(filename, flag), protocol, writeback)
def open(filename, flag='c', protocol=None, writeback=False):
@@ -230,7 +223,7 @@ def open(filename, flag='c', protocol=None, writeback=False):
database. As a side-effect, an extension may be added to the
filename and more than one file may be created. The optional flag
parameter has the same interpretation as the flag parameter of
- anydbm.open(). The optional protocol parameter specifies the
+ dbm.open(). The optional protocol parameter specifies the
version of the pickle protocol (0, 1, or 2).
See the module's __doc__ string for an overview of the interface.
diff --git a/Lib/shlex.py b/Lib/shlex.py
index e7c8accd427..3edd3db1ed9 100644
--- a/Lib/shlex.py
+++ b/Lib/shlex.py
@@ -1,4 +1,3 @@
-# -*- coding: iso-8859-1 -*-
"""A lexical analyzer class for simple shell-like syntaxes."""
# Module and documentation by Eric S. Raymond, 21 Dec 1998
@@ -11,17 +10,14 @@ import os.path
import sys
from collections import deque
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+from io import StringIO
__all__ = ["shlex", "split"]
class shlex:
"A lexical analyzer class for simple shell-like syntaxes."
def __init__(self, instream=None, infile=None, posix=False):
- if isinstance(instream, basestring):
+ if isinstance(instream, str):
instream = StringIO(instream)
if instream is not None:
self.instream = instream
@@ -38,8 +34,8 @@ class shlex:
self.wordchars = ('abcdfeghijklmnopqrstuvwxyz'
'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_')
if self.posix:
- self.wordchars += ('ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
- 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ')
+ self.wordchars += ('ßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ'
+ 'ÀÃÂÃÄÅÆÇÈÉÊËÌÃÃŽÃÃÑÒÓÔÕÖØÙÚÛÜÃÞ')
self.whitespace = ' \t\r\n'
self.whitespace_split = False
self.quotes = '\'"'
@@ -53,18 +49,18 @@ class shlex:
self.filestack = deque()
self.source = None
if self.debug:
- print 'shlex: reading from %s, line %d' \
- % (self.instream, self.lineno)
+ print('shlex: reading from %s, line %d' \
+ % (self.instream, self.lineno))
def push_token(self, tok):
"Push a token onto the stack popped by the get_token method"
if self.debug >= 1:
- print "shlex: pushing token " + repr(tok)
+ print("shlex: pushing token " + repr(tok))
self.pushback.appendleft(tok)
def push_source(self, newstream, newfile=None):
"Push an input source onto the lexer's input source stack."
- if isinstance(newstream, basestring):
+ if isinstance(newstream, str):
newstream = StringIO(newstream)
self.filestack.appendleft((self.infile, self.instream, self.lineno))
self.infile = newfile
@@ -72,17 +68,17 @@ class shlex:
self.lineno = 1
if self.debug:
if newfile is not None:
- print 'shlex: pushing to file %s' % (self.infile,)
+ print('shlex: pushing to file %s' % (self.infile,))
else:
- print 'shlex: pushing to stream %s' % (self.instream,)
+ print('shlex: pushing to stream %s' % (self.instream,))
def pop_source(self):
"Pop the input source stack."
self.instream.close()
(self.infile, self.instream, self.lineno) = self.filestack.popleft()
if self.debug:
- print 'shlex: popping to %s, line %d' \
- % (self.instream, self.lineno)
+ print('shlex: popping to %s, line %d' \
+ % (self.instream, self.lineno))
self.state = ' '
def get_token(self):
@@ -90,7 +86,7 @@ class shlex:
if self.pushback:
tok = self.pushback.popleft()
if self.debug >= 1:
- print "shlex: popping token " + repr(tok)
+ print("shlex: popping token " + repr(tok))
return tok
# No pushback. Get a token.
raw = self.read_token()
@@ -112,9 +108,9 @@ class shlex:
# Neither inclusion nor EOF
if self.debug >= 1:
if raw != self.eof:
- print "shlex: token=" + repr(raw)
+ print("shlex: token=" + repr(raw))
else:
- print "shlex: token=EOF"
+ print("shlex: token=EOF")
return raw
def read_token(self):
@@ -125,8 +121,8 @@ class shlex:
if nextchar == '\n':
self.lineno = self.lineno + 1
if self.debug >= 3:
- print "shlex: in state", repr(self.state), \
- "I see character:", repr(nextchar)
+ print("shlex: in state", repr(self.state), \
+ "I see character:", repr(nextchar))
if self.state is None:
self.token = '' # past end of file
break
@@ -136,7 +132,7 @@ class shlex:
break
elif nextchar in self.whitespace:
if self.debug >= 2:
- print "shlex: I see whitespace in whitespace state"
+ print("shlex: I see whitespace in whitespace state")
if self.token or (self.posix and quoted):
break # emit current token
else:
@@ -167,9 +163,9 @@ class shlex:
quoted = True
if not nextchar: # end of file
if self.debug >= 2:
- print "shlex: I see EOF in quotes state"
+ print("shlex: I see EOF in quotes state")
# XXX what error should be raised here?
- raise ValueError, "No closing quotation"
+ raise ValueError("No closing quotation")
if nextchar == self.state:
if not self.posix:
self.token = self.token + nextchar
@@ -186,9 +182,9 @@ class shlex:
elif self.state in self.escape:
if not nextchar: # end of file
if self.debug >= 2:
- print "shlex: I see EOF in escape state"
+ print("shlex: I see EOF in escape state")
# XXX what error should be raised here?
- raise ValueError, "No escaped character"
+ raise ValueError("No escaped character")
# In posix shells, only the quote itself or the escape
# character may be escaped within quotes.
if escapedstate in self.quotes and \
@@ -202,7 +198,7 @@ class shlex:
break
elif nextchar in self.whitespace:
if self.debug >= 2:
- print "shlex: I see whitespace in word state"
+ print("shlex: I see whitespace in word state")
self.state = ' '
if self.token or (self.posix and quoted):
break # emit current token
@@ -228,7 +224,7 @@ class shlex:
else:
self.pushback.appendleft(nextchar)
if self.debug >= 2:
- print "shlex: I see punctuation in word state"
+ print("shlex: I see punctuation in word state")
self.state = ' '
if self.token:
break # emit current token
@@ -240,9 +236,9 @@ class shlex:
result = None
if self.debug > 1:
if result:
- print "shlex: raw token=" + repr(result)
+ print("shlex: raw token=" + repr(result))
else:
- print "shlex: raw token=EOF"
+ print("shlex: raw token=EOF")
return result
def sourcehook(self, newfile):
@@ -250,7 +246,7 @@ class shlex:
if newfile[0] == '"':
newfile = newfile[1:-1]
# This implements cpp-like semantics for relative-path inclusion.
- if isinstance(self.infile, basestring) and not os.path.isabs(newfile):
+ if isinstance(self.infile, str) and not os.path.isabs(newfile):
newfile = os.path.join(os.path.dirname(self.infile), newfile)
return (newfile, open(newfile, "r"))
@@ -265,7 +261,7 @@ class shlex:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
token = self.get_token()
if token == self.eof:
raise StopIteration
@@ -287,6 +283,6 @@ if __name__ == '__main__':
while 1:
tt = lexer.get_token()
if tt:
- print "Token: " + repr(tt)
+ print("Token: " + repr(tt))
else:
break
diff --git a/Lib/shutil.py b/Lib/shutil.py
index 420802fafdf..ef29ae2303c 100644
--- a/Lib/shutil.py
+++ b/Lib/shutil.py
@@ -11,6 +11,13 @@ from os.path import abspath
import fnmatch
import collections
import errno
+import tarfile
+
+try:
+ import bz2
+ _BZ2_SUPPORTED = True
+except ImportError:
+ _BZ2_SUPPORTED = False
try:
from pwd import getpwnam
@@ -26,7 +33,8 @@ __all__ = ["copyfileobj", "copyfile", "copymode", "copystat", "copy", "copy2",
"copytree", "move", "rmtree", "Error", "SpecialFileError",
"ExecError", "make_archive", "get_archive_formats",
"register_archive_format", "unregister_archive_format",
- "ignore_patterns"]
+ "get_unpack_formats", "register_unpack_format",
+ "unregister_unpack_format", "unpack_archive", "ignore_patterns"]
class Error(EnvironmentError):
pass
@@ -38,6 +46,14 @@ class SpecialFileError(EnvironmentError):
class ExecError(EnvironmentError):
"""Raised when a command could not be executed"""
+class ReadError(EnvironmentError):
+ """Raised when an archive cannot be read"""
+
+class RegistryError(Exception):
+ """Raised when a registery operation with the archiving
+ and unpacking registeries fails"""
+
+
try:
WindowsError
except NameError:
@@ -101,7 +117,7 @@ def copystat(src, dst):
if hasattr(os, 'chflags') and hasattr(st, 'st_flags'):
try:
os.chflags(dst, st.st_flags)
- except OSError, why:
+ except OSError as why:
for err in 'EOPNOTSUPP', 'ENOTSUP':
if hasattr(errno, err) and why.errno == getattr(errno, err):
break
@@ -142,8 +158,9 @@ def ignore_patterns(*patterns):
return set(ignored_names)
return _ignore_patterns
-def copytree(src, dst, symlinks=False, ignore=None):
- """Recursively copy a directory tree using copy2().
+def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
+ ignore_dangling_symlinks=False):
+ """Recursively copy a directory tree.
The destination directory must not already exist.
If exception(s) occur, an Error is raised with a list of reasons.
@@ -151,7 +168,13 @@ def copytree(src, dst, symlinks=False, ignore=None):
If the optional symlinks flag is true, symbolic links in the
source tree result in symbolic links in the destination tree; if
it is false, the contents of the files pointed to by symbolic
- links are copied.
+ links are copied. If the file pointed by the symlink doesn't
+ exist, an exception will be added in the list of errors raised in
+ an Error exception at the end of the copy process.
+
+ You can set the optional ignore_dangling_symlinks flag to true if you
+ want to silence this exception. Notice that this has no effect on
+ platforms that don't support os.symlink.
The optional ignore argument is a callable. If given, it
is called with the `src` parameter, which is the directory
@@ -165,7 +188,10 @@ def copytree(src, dst, symlinks=False, ignore=None):
list of names relative to the `src` directory that should
not be copied.
- XXX Consider this example code rather than the ultimate tool.
+ The optional copy_function argument is a callable that will be used
+ to copy each file. It will be called with the source path and the
+ destination path as arguments. By default, copy2() is used, but any
+ function that supports the same signature (like copy()) can be used.
"""
names = os.listdir(src)
@@ -182,30 +208,37 @@ def copytree(src, dst, symlinks=False, ignore=None):
srcname = os.path.join(src, name)
dstname = os.path.join(dst, name)
try:
- if symlinks and os.path.islink(srcname):
+ if os.path.islink(srcname):
linkto = os.readlink(srcname)
- os.symlink(linkto, dstname)
+ if symlinks:
+ os.symlink(linkto, dstname)
+ else:
+ # ignore dangling symlink if the flag is on
+ if not os.path.exists(linkto) and ignore_dangling_symlinks:
+ continue
+ # otherwise let the copy occurs. copy2 will raise an error
+ copy_function(srcname, dstname)
elif os.path.isdir(srcname):
- copytree(srcname, dstname, symlinks, ignore)
+ copytree(srcname, dstname, symlinks, ignore, copy_function)
else:
# Will raise a SpecialFileError for unsupported file types
- copy2(srcname, dstname)
+ copy_function(srcname, dstname)
# catch the Error from the recursive copytree so that we can
# continue with other files
- except Error, err:
+ except Error as err:
errors.extend(err.args[0])
- except EnvironmentError, why:
+ except EnvironmentError as why:
errors.append((srcname, dstname, str(why)))
try:
copystat(src, dst)
- except OSError, why:
+ except OSError as why:
if WindowsError is not None and isinstance(why, WindowsError):
# Copying file access times may fail on Windows
pass
else:
errors.append((src, dst, str(why)))
if errors:
- raise Error, errors
+ raise Error(errors)
def rmtree(path, ignore_errors=False, onerror=None):
"""Recursively delete a directory tree.
@@ -235,7 +268,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
names = []
try:
names = os.listdir(path)
- except os.error, err:
+ except os.error as err:
onerror(os.listdir, path, sys.exc_info())
for name in names:
fullname = os.path.join(path, name)
@@ -248,7 +281,7 @@ def rmtree(path, ignore_errors=False, onerror=None):
else:
try:
os.remove(fullname)
- except os.error, err:
+ except os.error as err:
onerror(os.remove, fullname, sys.exc_info())
try:
os.rmdir(path)
@@ -288,13 +321,13 @@ def move(src, dst):
real_dst = os.path.join(dst, _basename(src))
if os.path.exists(real_dst):
- raise Error, "Destination path '%s' already exists" % real_dst
+ raise Error("Destination path '%s' already exists" % real_dst)
try:
os.rename(src, real_dst)
- except OSError:
+ except OSError as exc:
if os.path.isdir(src):
if _destinsrc(src, dst):
- raise Error, "Cannot move a directory '%s' into itself '%s'." % (src, dst)
+ raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst))
copytree(src, real_dst, symlinks=True)
rmtree(src)
else:
@@ -350,13 +383,17 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
Returns the output filename.
"""
- tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: ''}
- compress_ext = {'gzip': '.gz', 'bzip2': '.bz2'}
+ tar_compression = {'gzip': 'gz', None: ''}
+ compress_ext = {'gzip': '.gz'}
+
+ if _BZ2_SUPPORTED:
+ tar_compression['bzip2'] = 'bz2'
+ compress_ext['bzip2'] = '.bz2'
# flags for compression program, each element of list will be an argument
if compress is not None and compress not in compress_ext.keys():
- raise ValueError, \
- ("bad value for 'compress': must be None, 'gzip' or 'bzip2'")
+ raise ValueError("bad value for 'compress', or compression format not "
+ "supported : {0}".format(compress))
archive_name = base_name + '.tar' + compress_ext.get(compress, '')
archive_dir = os.path.dirname(archive_name)
@@ -367,10 +404,7 @@ def _make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
if not dry_run:
os.makedirs(archive_dir)
-
# creating the tarball
- import tarfile # late import so Python build itself doesn't break
-
if logger is not None:
logger.info('Creating tar archive')
@@ -408,8 +442,7 @@ def _call_external_zip(base_dir, zip_filename, verbose=False, dry_run=False):
except DistutilsExecError:
# XXX really should distinguish between "couldn't find
# external 'zip' command" and "zip failed".
- raise ExecError, \
- ("unable to create zip file '%s': "
+ raise ExecError("unable to create zip file '%s': "
"could neither import the 'zipfile' module nor "
"find a standalone zip utility") % zip_filename
@@ -462,11 +495,14 @@ def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
_ARCHIVE_FORMATS = {
'gztar': (_make_tarball, [('compress', 'gzip')], "gzip'ed tar-file"),
- 'bztar': (_make_tarball, [('compress', 'bzip2')], "bzip2'ed tar-file"),
'tar': (_make_tarball, [('compress', None)], "uncompressed tar file"),
'zip': (_make_zipfile, [],"ZIP file")
}
+if _BZ2_SUPPORTED:
+ _ARCHIVE_FORMATS['bztar'] = (_make_tarball, [('compress', 'bzip2')],
+ "bzip2'ed tar-file")
+
def get_archive_formats():
"""Returns a list of supported formats for archiving and unarchiving.
@@ -488,7 +524,7 @@ def register_archive_format(name, function, extra_args=None, description=''):
"""
if extra_args is None:
extra_args = []
- if not isinstance(function, collections.Callable):
+ if not callable(function):
raise TypeError('The %s object is not callable' % function)
if not isinstance(extra_args, (tuple, list)):
raise TypeError('extra_args needs to be a sequence')
@@ -535,7 +571,7 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
try:
format_info = _ARCHIVE_FORMATS[format]
except KeyError:
- raise ValueError, "unknown archive format '%s'" % format
+ raise ValueError("unknown archive format '%s'" % format)
func = format_info[0]
for arg, val in format_info[1]:
@@ -554,3 +590,168 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
os.chdir(save_cwd)
return filename
+
+
+def get_unpack_formats():
+ """Returns a list of supported formats for unpacking.
+
+ Each element of the returned sequence is a tuple
+ (name, extensions, description)
+ """
+ formats = [(name, info[0], info[3]) for name, info in
+ _UNPACK_FORMATS.items()]
+ formats.sort()
+ return formats
+
+def _check_unpack_options(extensions, function, extra_args):
+ """Checks what gets registered as an unpacker."""
+ # first make sure no other unpacker is registered for this extension
+ existing_extensions = {}
+ for name, info in _UNPACK_FORMATS.items():
+ for ext in info[0]:
+ existing_extensions[ext] = name
+
+ for extension in extensions:
+ if extension in existing_extensions:
+ msg = '%s is already registered for "%s"'
+ raise RegistryError(msg % (extension,
+ existing_extensions[extension]))
+
+ if not callable(function):
+ raise TypeError('The registered function must be a callable')
+
+
+def register_unpack_format(name, extensions, function, extra_args=None,
+ description=''):
+ """Registers an unpack format.
+
+ `name` is the name of the format. `extensions` is a list of extensions
+ corresponding to the format.
+
+ `function` is the callable that will be
+ used to unpack archives. The callable will receive archives to unpack.
+ If it's unable to handle an archive, it needs to raise a ReadError
+ exception.
+
+ If provided, `extra_args` is a sequence of
+ (name, value) tuples that will be passed as arguments to the callable.
+ description can be provided to describe the format, and will be returned
+ by the get_unpack_formats() function.
+ """
+ if extra_args is None:
+ extra_args = []
+ _check_unpack_options(extensions, function, extra_args)
+ _UNPACK_FORMATS[name] = extensions, function, extra_args, description
+
+def unregister_unpack_format(name):
+ """Removes the pack format from the registery."""
+ del _UNPACK_FORMATS[name]
+
+def _ensure_directory(path):
+ """Ensure that the parent directory of `path` exists"""
+ dirname = os.path.dirname(path)
+ if not os.path.isdir(dirname):
+ os.makedirs(dirname)
+
+def _unpack_zipfile(filename, extract_dir):
+ """Unpack zip `filename` to `extract_dir`
+ """
+ try:
+ import zipfile
+ except ImportError:
+ raise ReadError('zlib not supported, cannot unpack this archive.')
+
+ if not zipfile.is_zipfile(filename):
+ raise ReadError("%s is not a zip file" % filename)
+
+ zip = zipfile.ZipFile(filename)
+ try:
+ for info in zip.infolist():
+ name = info.filename
+
+ # don't extract absolute paths or ones with .. in them
+ if name.startswith('/') or '..' in name:
+ continue
+
+ target = os.path.join(extract_dir, *name.split('/'))
+ if not target:
+ continue
+
+ _ensure_directory(target)
+ if not name.endswith('/'):
+ # file
+ data = zip.read(info.filename)
+ f = open(target,'wb')
+ try:
+ f.write(data)
+ finally:
+ f.close()
+ del data
+ finally:
+ zip.close()
+
+def _unpack_tarfile(filename, extract_dir):
+ """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
+ """
+ try:
+ tarobj = tarfile.open(filename)
+ except tarfile.TarError:
+ raise ReadError(
+ "%s is not a compressed or uncompressed tar file" % filename)
+ try:
+ tarobj.extractall(extract_dir)
+ finally:
+ tarobj.close()
+
+_UNPACK_FORMATS = {
+ 'gztar': (['.tar.gz', '.tgz'], _unpack_tarfile, [], "gzip'ed tar-file"),
+ 'tar': (['.tar'], _unpack_tarfile, [], "uncompressed tar file"),
+ 'zip': (['.zip'], _unpack_zipfile, [], "ZIP file")
+ }
+
+if _BZ2_SUPPORTED:
+ _UNPACK_FORMATS['bztar'] = (['.bz2'], _unpack_tarfile, [],
+ "bzip2'ed tar-file")
+
+def _find_unpack_format(filename):
+ for name, info in _UNPACK_FORMATS.items():
+ for extension in info[0]:
+ if filename.endswith(extension):
+ return name
+ return None
+
+def unpack_archive(filename, extract_dir=None, format=None):
+ """Unpack an archive.
+
+ `filename` is the name of the archive.
+
+ `extract_dir` is the name of the target directory, where the archive
+ is unpacked. If not provided, the current working directory is used.
+
+ `format` is the archive format: one of "zip", "tar", or "gztar". Or any
+ other registered format. If not provided, unpack_archive will use the
+ filename extension and see if an unpacker was registered for that
+ extension.
+
+ In case none is found, a ValueError is raised.
+ """
+ if extract_dir is None:
+ extract_dir = os.getcwd()
+
+ if format is not None:
+ try:
+ format_info = _UNPACK_FORMATS[format]
+ except KeyError:
+ raise ValueError("Unknown unpack format '{0}'".format(format))
+
+ func = format_info[1]
+ func(filename, extract_dir, **dict(format_info[2]))
+ else:
+ # we need to look at the registered unpackers supported extensions
+ format = _find_unpack_format(filename)
+ if format is None:
+ raise ReadError("Unknown archive format '{0}'".format(filename))
+
+ func = _UNPACK_FORMATS[format][1]
+ kwargs = dict(_UNPACK_FORMATS[format][2])
+ func(filename, extract_dir, **kwargs)
diff --git a/Lib/site.py b/Lib/site.py
index 54e515479a9..a2c0becbc1e 100644
--- a/Lib/site.py
+++ b/Lib/site.py
@@ -4,12 +4,6 @@
* This module is automatically imported during initialization. *
****************************************************************
-In earlier versions of Python (up to 1.5a3), scripts or modules that
-needed to use site-specific modules would place ``import site''
-somewhere near the top of their code. Because of the automatic
-import, this is no longer necessary (but code that does it still
-works).
-
This will append site-specific paths to the module search path. On
Unix (including Mac OSX), it starts with sys.prefix and
sys.exec_prefix (if different) and appends
@@ -60,7 +54,7 @@ ImportError exception, it is silently ignored.
import sys
import os
-import __builtin__
+import builtins
import traceback
# Prefixes for site-packages; add additional prefixes like /usr/local here
@@ -85,15 +79,19 @@ def makepath(*paths):
return dir, os.path.normcase(dir)
-def abs__file__():
- """Set all module' __file__ attribute to an absolute path"""
- for m in sys.modules.values():
+def abs_paths():
+ """Set all module __file__ and __cached__ attributes to an absolute path"""
+ for m in set(sys.modules.values()):
if hasattr(m, '__loader__'):
continue # don't mess with a PEP 302-supplied __file__
try:
m.__file__ = os.path.abspath(m.__file__)
except (AttributeError, OSError):
pass
+ try:
+ m.__cached__ = os.path.abspath(m.__cached__)
+ except (AttributeError, OSError):
+ pass
def removeduppaths():
@@ -114,18 +112,6 @@ def removeduppaths():
sys.path[:] = L
return known_paths
-# XXX This should not be part of site.py, since it is needed even when
-# using the -S option for Python. See http://www.python.org/sf/586680
-def addbuilddir():
- """Append ./build/lib.<platform> in case we're running in the build dir
- (especially for Guido :-)"""
- from sysconfig import get_platform
- s = "build/lib.%s-%.3s" % (get_platform(), sys.version)
- if hasattr(sys, 'gettotalrefcount'):
- s += '-pydebug'
- s = os.path.join(os.path.dirname(sys.path.pop()), s)
- sys.path.append(s)
-
def _init_pathinfo():
"""Return a set containing all existing directory entries from sys.path"""
@@ -161,7 +147,7 @@ def addpackage(sitedir, name, known_paths):
continue
try:
if line.startswith(("import ", "import\t")):
- exec line
+ exec(line)
continue
line = line.rstrip()
dir, dircase = makepath(sitedir, line)
@@ -169,12 +155,12 @@ def addpackage(sitedir, name, known_paths):
sys.path.append(dir)
known_paths.add(dircase)
except Exception as err:
- print >>sys.stderr, "Error processing line {:d} of {}:\n".format(
- n+1, fullname)
+ print("Error processing line {:d} of {}:\n".format(n+1, fullname),
+ file=sys.stderr)
for record in traceback.format_exception(*sys.exc_info()):
for line in record.splitlines():
- print >>sys.stderr, ' '+line
- print >>sys.stderr, "\nRemainder of file ignored"
+ print(' '+line, file=sys.stderr)
+ print("\nRemainder of file ignored", file=sys.stderr)
break
if reset:
known_paths = None
@@ -196,8 +182,7 @@ def addsitedir(sitedir, known_paths=None):
names = os.listdir(sitedir)
except os.error:
return
- dotpth = os.extsep + "pth"
- names = [name for name in names if name.endswith(dotpth)]
+ names = [name for name in names if name.endswith(".pth")]
for name in sorted(names):
addpackage(sitedir, name, known_paths)
if reset:
@@ -366,12 +351,17 @@ def setquit():
# Shells like IDLE catch the SystemExit, but listen when their
# stdin wrapper is closed.
try:
- sys.stdin.close()
+ fd = -1
+ if hasattr(sys.stdin, "fileno"):
+ fd = sys.stdin.fileno()
+ if fd != 0:
+ # Don't close stdin if it wraps fd 0
+ sys.stdin.close()
except:
pass
raise SystemExit(code)
- __builtin__.quit = Quitter('quit')
- __builtin__.exit = Quitter('exit')
+ builtins.quit = Quitter('quit')
+ builtins.exit = Quitter('exit')
class _Printer(object):
@@ -395,7 +385,7 @@ class _Printer(object):
for filename in self.__files:
filename = os.path.join(dir, filename)
try:
- fp = file(filename, "rU")
+ fp = open(filename, "rU")
data = fp.read()
fp.close()
break
@@ -422,32 +412,32 @@ class _Printer(object):
while 1:
try:
for i in range(lineno, lineno + self.MAXLINES):
- print self.__lines[i]
+ print(self.__lines[i])
except IndexError:
break
else:
lineno += self.MAXLINES
key = None
while key is None:
- key = raw_input(prompt)
+ key = input(prompt)
if key not in ('', 'q'):
key = None
if key == 'q':
break
def setcopyright():
- """Set 'copyright' and 'credits' in __builtin__"""
- __builtin__.copyright = _Printer("copyright", sys.copyright)
+ """Set 'copyright' and 'credits' in builtins"""
+ builtins.copyright = _Printer("copyright", sys.copyright)
if sys.platform[:4] == 'java':
- __builtin__.credits = _Printer(
+ builtins.credits = _Printer(
"credits",
"Jython is maintained by the Jython developers (www.jython.org).")
else:
- __builtin__.credits = _Printer("credits", """\
+ builtins.credits = _Printer("credits", """\
Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
for supporting Python development. See www.python.org for more information.""")
here = os.path.dirname(os.__file__)
- __builtin__.license = _Printer(
+ builtins.license = _Printer(
"license", "See http://www.python.org/%.3s/license.html" % sys.version,
["LICENSE.txt", "LICENSE"],
[os.path.join(here, os.pardir), here, os.curdir])
@@ -467,7 +457,7 @@ class _Helper(object):
return pydoc.help(*args, **kwds)
def sethelper():
- __builtin__.help = _Helper()
+ builtins.help = _Helper()
def aliasmbcs():
"""On Windows, some default encodings are not provided by Python,
@@ -484,25 +474,6 @@ def aliasmbcs():
encodings._cache[enc] = encodings._unknown
encodings.aliases.aliases[enc] = 'mbcs'
-def setencoding():
- """Set the string encoding used by the Unicode implementation. The
- default is 'ascii', but if you're willing to experiment, you can
- change this."""
- encoding = "ascii" # Default value set by _PyUnicode_Init()
- if 0:
- # Enable to support locale aware default string encodings.
- import locale
- loc = locale.getdefaultlocale()
- if loc[1]:
- encoding = loc[1]
- if 0:
- # Enable to switch off string to Unicode coercion and implicit
- # Unicode to string conversion.
- encoding = "undefined"
- if encoding != "ascii":
- # On Non-Unicode builds this will raise an AttributeError...
- sys.setdefaultencoding(encoding) # Needs Python Unicode build !
-
def execsitecustomize():
"""Run custom site specific code, if available."""
@@ -510,12 +481,14 @@ def execsitecustomize():
import sitecustomize
except ImportError:
pass
- except Exception:
- if sys.flags.verbose:
+ except Exception as err:
+ if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())
else:
- print >>sys.stderr, \
- "'import sitecustomize' failed; use -v for traceback"
+ sys.stderr.write(
+ "Error in sitecustomize; set PYTHONVERBOSE for traceback:\n"
+ "%s: %s\n" %
+ (err.__class__.__name__, err))
def execusercustomize():
@@ -524,22 +497,21 @@ def execusercustomize():
import usercustomize
except ImportError:
pass
- except Exception:
- if sys.flags.verbose:
+ except Exception as err:
+ if os.environ.get("PYTHONVERBOSE"):
sys.excepthook(*sys.exc_info())
else:
- print>>sys.stderr, \
- "'import usercustomize' failed; use -v for traceback"
+ sys.stderr.write(
+ "Error in usercustomize; set PYTHONVERBOSE for traceback:\n"
+ "%s: %s\n" %
+ (err.__class__.__name__, err))
def main():
global ENABLE_USER_SITE
- abs__file__()
+ abs_paths()
known_paths = removeduppaths()
- if (os.name == "posix" and sys.path and
- os.path.basename(sys.path[-1]) == "Modules"):
- addbuilddir()
if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite()
known_paths = addusersitepackages(known_paths)
@@ -550,15 +522,9 @@ def main():
setcopyright()
sethelper()
aliasmbcs()
- setencoding()
execsitecustomize()
if ENABLE_USER_SITE:
execusercustomize()
- # Remove sys.setdefaultencoding() so that users cannot change the
- # encoding after initialization. The test for presence is needed when
- # this module is run as a script, because this code is executed twice.
- if hasattr(sys, "setdefaultencoding"):
- del sys.setdefaultencoding
main()
@@ -579,15 +545,15 @@ def _script():
"""
args = sys.argv[1:]
if not args:
- print "sys.path = ["
+ print("sys.path = [")
for dir in sys.path:
- print " %r," % (dir,)
- print "]"
- print "USER_BASE: %r (%s)" % (USER_BASE,
- "exists" if os.path.isdir(USER_BASE) else "doesn't exist")
- print "USER_SITE: %r (%s)" % (USER_SITE,
- "exists" if os.path.isdir(USER_SITE) else "doesn't exist")
- print "ENABLE_USER_SITE: %r" % ENABLE_USER_SITE
+ print(" %r," % (dir,))
+ print("]")
+ print("USER_BASE: %r (%s)" % (USER_BASE,
+ "exists" if os.path.isdir(USER_BASE) else "doesn't exist"))
+ print("USER_SITE: %r (%s)" % (USER_SITE,
+ "exists" if os.path.isdir(USER_SITE) else "doesn't exist"))
+ print("ENABLE_USER_SITE: %r" % ENABLE_USER_SITE)
sys.exit(0)
buffer = []
@@ -597,7 +563,7 @@ def _script():
buffer.append(USER_SITE)
if buffer:
- print os.pathsep.join(buffer)
+ print(os.pathsep.join(buffer))
if ENABLE_USER_SITE:
sys.exit(0)
elif ENABLE_USER_SITE is False:
@@ -608,7 +574,7 @@ def _script():
sys.exit(3)
else:
import textwrap
- print textwrap.dedent(help % (sys.argv[0], os.pathsep))
+ print(textwrap.dedent(help % (sys.argv[0], os.pathsep)))
sys.exit(10)
if __name__ == '__main__':
diff --git a/Lib/smtpd.py b/Lib/smtpd.py
index b4d208b2eeb..8cd405c5f6c 100755
--- a/Lib/smtpd.py
+++ b/Lib/smtpd.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""An RFC 2821 smtp proxy.
Usage: %(program)s [options] [localhost:localport [remotehost:remoteport]]
@@ -35,6 +35,7 @@ given then 8025 is used. If remotehost is not given then `localhost' is used,
and if remoteport is not given, then 25 is used.
"""
+
# Overview:
#
# This file implements the minimal SMTP protocol as defined in RFC 821. It
@@ -58,7 +59,6 @@ and if remoteport is not given, then 25 is used.
# gets forwarded to a real backend smtpd, as with PureProxy. Again, errors
# are not handled correctly yet.
#
-# Please note that this script requires Python 2.0
#
# Author: Barry Warsaw <barry@python.org>
#
@@ -77,6 +77,7 @@ import time
import socket
import asyncore
import asynchat
+from warnings import warn
__all__ = ["SMTPServer","DebuggingServer","PureProxy","MailmanProxy"]
@@ -95,56 +96,198 @@ EMPTYSTRING = ''
COMMASPACE = ', '
+
def usage(code, msg=''):
- print >> sys.stderr, __doc__ % globals()
+ print(__doc__ % globals(), file=sys.stderr)
if msg:
- print >> sys.stderr, msg
+ print(msg, file=sys.stderr)
sys.exit(code)
+
class SMTPChannel(asynchat.async_chat):
COMMAND = 0
DATA = 1
+ data_size_limit = 33554432
+ command_size_limit = 512
+
def __init__(self, server, conn, addr):
asynchat.async_chat.__init__(self, conn)
- self.__server = server
- self.__conn = conn
- self.__addr = addr
- self.__line = []
- self.__state = self.COMMAND
- self.__greeting = 0
- self.__mailfrom = None
- self.__rcpttos = []
- self.__data = ''
- self.__fqdn = socket.getfqdn()
+ self.smtp_server = server
+ self.conn = conn
+ self.addr = addr
+ self.received_lines = []
+ self.smtp_state = self.COMMAND
+ self.seen_greeting = ''
+ self.mailfrom = None
+ self.rcpttos = []
+ self.received_data = ''
+ self.fqdn = socket.getfqdn()
+ self.num_bytes = 0
try:
- self.__peer = conn.getpeername()
- except socket.error, err:
+ self.peer = conn.getpeername()
+ except socket.error as err:
# a race condition may occur if the other end is closing
# before we can get the peername
self.close()
- if err[0] != errno.ENOTCONN:
+ if err.args[0] != errno.ENOTCONN:
raise
return
- print >> DEBUGSTREAM, 'Peer:', repr(self.__peer)
- self.push('220 %s %s' % (self.__fqdn, __version__))
- self.set_terminator('\r\n')
+ print('Peer:', repr(self.peer), file=DEBUGSTREAM)
+ self.push('220 %s %s' % (self.fqdn, __version__))
+ self.set_terminator(b'\r\n')
+
+ # properties for backwards-compatibility
+ @property
+ def __server(self):
+ warn("Access to __server attribute on SMTPChannel is deprecated, "
+ "use 'smtp_server' instead", PendingDeprecationWarning, 2)
+ return self.smtp_server
+ @__server.setter
+ def __server(self, value):
+ warn("Setting __server attribute on SMTPChannel is deprecated, "
+ "set 'smtp_server' instead", PendingDeprecationWarning, 2)
+ self.smtp_server = value
+
+ @property
+ def __line(self):
+ warn("Access to __line attribute on SMTPChannel is deprecated, "
+ "use 'received_lines' instead", PendingDeprecationWarning, 2)
+ return self.received_lines
+ @__line.setter
+ def __line(self, value):
+ warn("Setting __line attribute on SMTPChannel is deprecated, "
+ "set 'received_lines' instead", PendingDeprecationWarning, 2)
+ self.received_lines = value
+
+ @property
+ def __state(self):
+ warn("Access to __state attribute on SMTPChannel is deprecated, "
+ "use 'smtp_state' instead", PendingDeprecationWarning, 2)
+ return self.smtp_state
+ @__state.setter
+ def __state(self, value):
+ warn("Setting __state attribute on SMTPChannel is deprecated, "
+ "set 'smtp_state' instead", PendingDeprecationWarning, 2)
+ self.smtp_state = value
+
+ @property
+ def __greeting(self):
+ warn("Access to __greeting attribute on SMTPChannel is deprecated, "
+ "use 'seen_greeting' instead", PendingDeprecationWarning, 2)
+ return self.seen_greeting
+ @__greeting.setter
+ def __greeting(self, value):
+ warn("Setting __greeting attribute on SMTPChannel is deprecated, "
+ "set 'seen_greeting' instead", PendingDeprecationWarning, 2)
+ self.seen_greeting = value
+
+ @property
+ def __mailfrom(self):
+ warn("Access to __mailfrom attribute on SMTPChannel is deprecated, "
+ "use 'mailfrom' instead", PendingDeprecationWarning, 2)
+ return self.mailfrom
+ @__mailfrom.setter
+ def __mailfrom(self, value):
+ warn("Setting __mailfrom attribute on SMTPChannel is deprecated, "
+ "set 'mailfrom' instead", PendingDeprecationWarning, 2)
+ self.mailfrom = value
+
+ @property
+ def __rcpttos(self):
+ warn("Access to __rcpttos attribute on SMTPChannel is deprecated, "
+ "use 'rcpttos' instead", PendingDeprecationWarning, 2)
+ return self.rcpttos
+ @__rcpttos.setter
+ def __rcpttos(self, value):
+ warn("Setting __rcpttos attribute on SMTPChannel is deprecated, "
+ "set 'rcpttos' instead", PendingDeprecationWarning, 2)
+ self.rcpttos = value
+
+ @property
+ def __data(self):
+ warn("Access to __data attribute on SMTPChannel is deprecated, "
+ "use 'received_data' instead", PendingDeprecationWarning, 2)
+ return self.received_data
+ @__data.setter
+ def __data(self, value):
+ warn("Setting __data attribute on SMTPChannel is deprecated, "
+ "set 'received_data' instead", PendingDeprecationWarning, 2)
+ self.received_data = value
+
+ @property
+ def __fqdn(self):
+ warn("Access to __fqdn attribute on SMTPChannel is deprecated, "
+ "use 'fqdn' instead", PendingDeprecationWarning, 2)
+ return self.fqdn
+ @__fqdn.setter
+ def __fqdn(self, value):
+ warn("Setting __fqdn attribute on SMTPChannel is deprecated, "
+ "set 'fqdn' instead", PendingDeprecationWarning, 2)
+ self.fqdn = value
+
+ @property
+ def __peer(self):
+ warn("Access to __peer attribute on SMTPChannel is deprecated, "
+ "use 'peer' instead", PendingDeprecationWarning, 2)
+ return self.peer
+ @__peer.setter
+ def __peer(self, value):
+ warn("Setting __peer attribute on SMTPChannel is deprecated, "
+ "set 'peer' instead", PendingDeprecationWarning, 2)
+ self.peer = value
+
+ @property
+ def __conn(self):
+ warn("Access to __conn attribute on SMTPChannel is deprecated, "
+ "use 'conn' instead", PendingDeprecationWarning, 2)
+ return self.conn
+ @__conn.setter
+ def __conn(self, value):
+ warn("Setting __conn attribute on SMTPChannel is deprecated, "
+ "set 'conn' instead", PendingDeprecationWarning, 2)
+ self.conn = value
+
+ @property
+ def __addr(self):
+ warn("Access to __addr attribute on SMTPChannel is deprecated, "
+ "use 'addr' instead", PendingDeprecationWarning, 2)
+ return self.addr
+ @__addr.setter
+ def __addr(self, value):
+ warn("Setting __addr attribute on SMTPChannel is deprecated, "
+ "set 'addr' instead", PendingDeprecationWarning, 2)
+ self.addr = value
# Overrides base class for convenience
def push(self, msg):
- asynchat.async_chat.push(self, msg + '\r\n')
+ asynchat.async_chat.push(self, bytes(msg + '\r\n', 'ascii'))
# Implementation of base class abstract method
def collect_incoming_data(self, data):
- self.__line.append(data)
+ limit = None
+ if self.smtp_state == self.COMMAND:
+ limit = self.command_size_limit
+ elif self.smtp_state == self.DATA:
+ limit = self.data_size_limit
+ if limit and self.num_bytes > limit:
+ return
+ elif limit:
+ self.num_bytes += len(data)
+ self.received_lines.append(str(data, "utf8"))
# Implementation of base class abstract method
def found_terminator(self):
- line = EMPTYSTRING.join(self.__line)
- print >> DEBUGSTREAM, 'Data:', repr(line)
- self.__line = []
- if self.__state == self.COMMAND:
+ line = EMPTYSTRING.join(self.received_lines)
+ print('Data:', repr(line), file=DEBUGSTREAM)
+ self.received_lines = []
+ if self.smtp_state == self.COMMAND:
+ if self.num_bytes > self.command_size_limit:
+ self.push('500 Error: line too long')
+ self.num_bytes = 0
+ return
+ self.num_bytes = 0
if not line:
self.push('500 Error: bad syntax')
return
@@ -163,8 +306,13 @@ class SMTPChannel(asynchat.async_chat):
method(arg)
return
else:
- if self.__state != self.DATA:
+ if self.smtp_state != self.DATA:
self.push('451 Internal confusion')
+ self.num_bytes = 0
+ return
+ if self.num_bytes > self.data_size_limit:
+ self.push('552 Error: Too much mail data')
+ self.num_bytes = 0
return
# Remove extraneous carriage returns and de-transparency according
# to RFC 821, Section 4.5.2.
@@ -174,15 +322,16 @@ class SMTPChannel(asynchat.async_chat):
data.append(text[1:])
else:
data.append(text)
- self.__data = NEWLINE.join(data)
- status = self.__server.process_message(self.__peer,
- self.__mailfrom,
- self.__rcpttos,
- self.__data)
- self.__rcpttos = []
- self.__mailfrom = None
- self.__state = self.COMMAND
- self.set_terminator('\r\n')
+ self.received_data = NEWLINE.join(data)
+ status = self.smtp_server.process_message(self.peer,
+ self.mailfrom,
+ self.rcpttos,
+ self.received_data)
+ self.rcpttos = []
+ self.mailfrom = None
+ self.smtp_state = self.COMMAND
+ self.num_bytes = 0
+ self.set_terminator(b'\r\n')
if not status:
self.push('250 Ok')
else:
@@ -193,11 +342,11 @@ class SMTPChannel(asynchat.async_chat):
if not arg:
self.push('501 Syntax: HELO hostname')
return
- if self.__greeting:
+ if self.seen_greeting:
self.push('503 Duplicate HELO/EHLO')
else:
- self.__greeting = arg
- self.push('250 %s' % self.__fqdn)
+ self.seen_greeting = arg
+ self.push('250 %s' % self.fqdn)
def smtp_NOOP(self, arg):
if arg:
@@ -225,29 +374,29 @@ class SMTPChannel(asynchat.async_chat):
return address
def smtp_MAIL(self, arg):
- print >> DEBUGSTREAM, '===> MAIL', arg
+ print('===> MAIL', arg, file=DEBUGSTREAM)
address = self.__getaddr('FROM:', arg) if arg else None
if not address:
self.push('501 Syntax: MAIL FROM:<address>')
return
- if self.__mailfrom:
+ if self.mailfrom:
self.push('503 Error: nested MAIL command')
return
- self.__mailfrom = address
- print >> DEBUGSTREAM, 'sender:', self.__mailfrom
+ self.mailfrom = address
+ print('sender:', self.mailfrom, file=DEBUGSTREAM)
self.push('250 Ok')
def smtp_RCPT(self, arg):
- print >> DEBUGSTREAM, '===> RCPT', arg
- if not self.__mailfrom:
+ print('===> RCPT', arg, file=DEBUGSTREAM)
+ if not self.mailfrom:
self.push('503 Error: need MAIL command')
return
address = self.__getaddr('TO:', arg) if arg else None
if not address:
self.push('501 Syntax: RCPT TO: <address>')
return
- self.__rcpttos.append(address)
- print >> DEBUGSTREAM, 'recips:', self.__rcpttos
+ self.rcpttos.append(address)
+ print('recips:', self.rcpttos, file=DEBUGSTREAM)
self.push('250 Ok')
def smtp_RSET(self, arg):
@@ -255,25 +404,29 @@ class SMTPChannel(asynchat.async_chat):
self.push('501 Syntax: RSET')
return
# Resets the sender, recipients, and data, but not the greeting
- self.__mailfrom = None
- self.__rcpttos = []
- self.__data = ''
- self.__state = self.COMMAND
+ self.mailfrom = None
+ self.rcpttos = []
+ self.received_data = ''
+ self.smtp_state = self.COMMAND
self.push('250 Ok')
def smtp_DATA(self, arg):
- if not self.__rcpttos:
+ if not self.rcpttos:
self.push('503 Error: need RCPT command')
return
if arg:
self.push('501 Syntax: DATA')
return
- self.__state = self.DATA
- self.set_terminator('\r\n.\r\n')
+ self.smtp_state = self.DATA
+ self.set_terminator(b'\r\n.\r\n')
self.push('354 End data with <CR><LF>.<CR><LF>')
+
class SMTPServer(asyncore.dispatcher):
+ # SMTPChannel class to use for managing client connections
+ channel_class = SMTPChannel
+
def __init__(self, localaddr, remoteaddr):
self._localaddr = localaddr
self._remoteaddr = remoteaddr
@@ -285,21 +438,16 @@ class SMTPServer(asyncore.dispatcher):
self.bind(localaddr)
self.listen(5)
except:
- # cleanup asyncore.socket_map before raising
self.close()
raise
else:
- print >> DEBUGSTREAM, \
- '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % (
+ print('%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % (
self.__class__.__name__, time.ctime(time.time()),
- localaddr, remoteaddr)
+ localaddr, remoteaddr), file=DEBUGSTREAM)
- def handle_accept(self):
- pair = self.accept()
- if pair is not None:
- conn, addr = pair
- print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr)
- channel = SMTPChannel(self, conn, addr)
+ def handle_accepted(self, conn, addr):
+ print('Incoming connection from %s' % repr(addr), file=DEBUGSTREAM)
+ channel = self.channel_class(self, conn, addr)
# API for "doing something useful with the message"
def process_message(self, peer, mailfrom, rcpttos, data):
@@ -327,21 +475,23 @@ class SMTPServer(asyncore.dispatcher):
raise NotImplementedError
+
class DebuggingServer(SMTPServer):
# Do something with the gathered message
def process_message(self, peer, mailfrom, rcpttos, data):
inheaders = 1
lines = data.split('\n')
- print '---------- MESSAGE FOLLOWS ----------'
+ print('---------- MESSAGE FOLLOWS ----------')
for line in lines:
# headers first
if inheaders and not line:
- print 'X-Peer:', peer[0]
+ print('X-Peer:', peer[0])
inheaders = 0
- print line
- print '------------ END MESSAGE ------------'
+ print(line)
+ print('------------ END MESSAGE ------------')
+
class PureProxy(SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
lines = data.split('\n')
@@ -355,7 +505,7 @@ class PureProxy(SMTPServer):
data = NEWLINE.join(lines)
refused = self._deliver(mailfrom, rcpttos, data)
# TBD: what to do with refused addresses?
- print >> DEBUGSTREAM, 'we got some refusals:', refused
+ print('we got some refusals:', refused, file=DEBUGSTREAM)
def _deliver(self, mailfrom, rcpttos, data):
import smtplib
@@ -367,11 +517,11 @@ class PureProxy(SMTPServer):
refused = s.sendmail(mailfrom, rcpttos, data)
finally:
s.quit()
- except smtplib.SMTPRecipientsRefused, e:
- print >> DEBUGSTREAM, 'got SMTPRecipientsRefused'
+ except smtplib.SMTPRecipientsRefused as e:
+ print('got SMTPRecipientsRefused', file=DEBUGSTREAM)
refused = e.recipients
- except (socket.error, smtplib.SMTPException), e:
- print >> DEBUGSTREAM, 'got', e.__class__
+ except (socket.error, smtplib.SMTPException) as e:
+ print('got', e.__class__, file=DEBUGSTREAM)
# All recipients were refused. If the exception had an associated
# error code, use it. Otherwise,fake it with a non-triggering
# exception code.
@@ -382,9 +532,10 @@ class PureProxy(SMTPServer):
return refused
+
class MailmanProxy(PureProxy):
def process_message(self, peer, mailfrom, rcpttos, data):
- from cStringIO import StringIO
+ from io import StringIO
from Mailman import Utils
from Mailman import Message
from Mailman import MailList
@@ -419,11 +570,11 @@ class MailmanProxy(PureProxy):
for rcpt, listname, command in listnames:
rcpttos.remove(rcpt)
# If there's any non-list destined recipients left,
- print >> DEBUGSTREAM, 'forwarding recips:', ' '.join(rcpttos)
+ print('forwarding recips:', ' '.join(rcpttos), file=DEBUGSTREAM)
if rcpttos:
refused = self._deliver(mailfrom, rcpttos, data)
# TBD: what to do with refused addresses?
- print >> DEBUGSTREAM, 'we got refusals:', refused
+ print('we got refusals:', refused, file=DEBUGSTREAM)
# Now deliver directly to the list commands
mlists = {}
s = StringIO(data)
@@ -431,12 +582,12 @@ class MailmanProxy(PureProxy):
# These headers are required for the proper execution of Mailman. All
# MTAs in existence seem to add these if the original message doesn't
# have them.
- if not msg.getheader('from'):
+ if not msg.get('from'):
msg['From'] = mailfrom
- if not msg.getheader('date'):
+ if not msg.get('date'):
msg['Date'] = time.ctime(time.time())
for rcpt, listname, command in listnames:
- print >> DEBUGSTREAM, 'sending message to', rcpt
+ print('sending message to', rcpt, file=DEBUGSTREAM)
mlist = mlists.get(listname)
if not mlist:
mlist = MailList.MailList(listname, lock=0)
@@ -460,18 +611,20 @@ class MailmanProxy(PureProxy):
msg.Enqueue(mlist, torequest=1)
+
class Options:
setuid = 1
classname = 'PureProxy'
+
def parseargs():
global DEBUGSTREAM
try:
opts, args = getopt.getopt(
sys.argv[1:], 'nVhc:d',
['class=', 'nosetuid', 'version', 'help', 'debug'])
- except getopt.error, e:
+ except getopt.error as e:
usage(1, e)
options = Options()
@@ -479,7 +632,7 @@ def parseargs():
if opt in ('-h', '--help'):
usage(0)
elif opt in ('-V', '--version'):
- print >> sys.stderr, __version__
+ print(__version__, file=sys.stderr)
sys.exit(0)
elif opt in ('-n', '--nosetuid'):
options.setuid = 0
@@ -521,6 +674,7 @@ def parseargs():
return options
+
if __name__ == '__main__':
options = parseargs()
# Become nobody
@@ -538,16 +692,14 @@ if __name__ == '__main__':
try:
import pwd
except ImportError:
- print >> sys.stderr, \
- 'Cannot import module "pwd"; try running with -n option.'
+ print('Cannot import module "pwd"; try running with -n option.', file=sys.stderr)
sys.exit(1)
nobody = pwd.getpwnam('nobody')[2]
try:
os.setuid(nobody)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EPERM: raise
- print >> sys.stderr, \
- 'Cannot setuid "nobody"; try running with -n option.'
+ print('Cannot setuid "nobody"; try running with -n option.', file=sys.stderr)
sys.exit(1)
try:
asyncore.loop()
diff --git a/Lib/smtplib.py b/Lib/smtplib.py
index 099e54a4fa1..e06a9be7413 100755..100644
--- a/Lib/smtplib.py
+++ b/Lib/smtplib.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
'''SMTP/ESMTP client class.
@@ -15,7 +15,7 @@ Example:
>>> import smtplib
>>> s=smtplib.SMTP("localhost")
- >>> print s.help()
+ >>> print(s.help())
This is Sendmail version 8.8.4
Topics:
HELO EHLO MAIL RCPT DATA
@@ -42,11 +42,15 @@ Example:
# This was modified from the Python 1.5 library HTTP lib.
import socket
+import io
import re
import email.utils
+import email.message
+import email.generator
import base64
import hmac
-from email.base64mime import encode as encode_base64
+import copy
+from email.base64mime import body_encode as encode_base64
from sys import stderr
__all__ = ["SMTPException", "SMTPServerDisconnected", "SMTPResponseException",
@@ -57,10 +61,10 @@ __all__ = ["SMTPException", "SMTPServerDisconnected", "SMTPResponseException",
SMTP_PORT = 25
SMTP_SSL_PORT = 465
CRLF = "\r\n"
+bCRLF = b"\r\n"
OLDSTYLE_AUTH = re.compile(r"auth=(.*)", re.I)
-
# Exception classes used by this module.
class SMTPException(Exception):
"""Base class for all exceptions raised by this module."""
@@ -129,11 +133,10 @@ class SMTPAuthenticationError(SMTPResponseException):
combination provided.
"""
-
def quoteaddr(addr):
"""Quote a subset of the email addresses defined by RFC 821.
- Should be able to handle anything rfc822.parseaddr can handle.
+ Should be able to handle anything email.utils.parseaddr can handle.
"""
m = (None, None)
try:
@@ -156,6 +159,7 @@ def _addr_only(addrstring):
return addrstring
return addr
+# Legacy method kept for backward compatibility.
def quotedata(data):
"""Quote data for email.
@@ -165,6 +169,11 @@ def quotedata(data):
return re.sub(r'(?m)^\.', '..',
re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data))
+def _quote_periods(bindata):
+ return re.sub(br'(?m)^\.', b'..', bindata)
+
+def _fix_eols(data):
+ return re.sub(r'(?:\r\n|\n|\r(?!\n))', CRLF, data)
try:
import ssl
@@ -180,9 +189,9 @@ else:
self.sslobj = sslobj
def readline(self):
- str = ""
+ str = b""
chr = None
- while chr != "\n":
+ while chr != b"\n":
chr = self.sslobj.read(1)
if not chr:
break
@@ -194,6 +203,7 @@ else:
_have_ssl = True
+
class SMTP:
"""This class manages a connection to an SMTP or ESMTP server.
SMTP Objects:
@@ -276,12 +286,12 @@ class SMTP:
"""
self.debuglevel = debuglevel
- def _get_socket(self, port, host, timeout):
+ def _get_socket(self, host, port, timeout):
# This makes it simpler for SMTP_SSL to use the SMTP connect code
# and just alter the socket connection bit.
if self.debuglevel > 0:
- print>>stderr, 'connect:', (host, port)
- return socket.create_connection((port, host), timeout)
+ print('connect:', (host, port), file=stderr)
+ return socket.create_connection((host, port), timeout)
def connect(self, host='localhost', port=0):
"""Connect to a host on a given port.
@@ -301,24 +311,26 @@ class SMTP:
try:
port = int(port)
except ValueError:
- raise socket.error, "nonnumeric port"
+ raise socket.error("nonnumeric port")
if not port:
port = self.default_port
if self.debuglevel > 0:
- print>>stderr, 'connect:', (host, port)
+ print('connect:', (host, port), file=stderr)
self.sock = self._get_socket(host, port, self.timeout)
(code, msg) = self.getreply()
if self.debuglevel > 0:
- print>>stderr, "connect:", msg
+ print("connect:", msg, file=stderr)
return (code, msg)
- def send(self, str):
- """Send `str' to the server."""
+ def send(self, s):
+ """Send `s' to the server."""
if self.debuglevel > 0:
- print>>stderr, 'send:', repr(str)
+ print('send:', repr(s), file=stderr)
if hasattr(self, 'sock') and self.sock:
+ if isinstance(s, str):
+ s = s.encode("ascii")
try:
- self.sock.sendall(str)
+ self.sock.sendall(s)
except socket.error:
self.close()
raise SMTPServerDisconnected('Server not connected')
@@ -356,12 +368,12 @@ class SMTP:
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed: "
+ str(e))
- if line == '':
+ if not line:
self.close()
raise SMTPServerDisconnected("Connection unexpectedly closed")
if self.debuglevel > 0:
- print>>stderr, 'reply:', repr(line)
- resp.append(line[4:].strip())
+ print('reply:', repr(line), file=stderr)
+ resp.append(line[4:].strip(b' \t\r\n'))
code = line[:3]
# Check that the error code is syntactically correct.
# Don't attempt to read a continuation line if it is broken.
@@ -371,12 +383,12 @@ class SMTP:
errcode = -1
break
# Check if multiline response.
- if line[3:4] != "-":
+ if line[3:4] != b"-":
break
- errmsg = "\n".join(resp)
+ errmsg = b"\n".join(resp)
if self.debuglevel > 0:
- print>>stderr, 'reply: retcode (%s); Msg: %s' % (errcode, errmsg)
+ print('reply: retcode (%s); Msg: %s' % (errcode, errmsg), file=stderr)
return errcode, errmsg
def docmd(self, cmd, args=""):
@@ -414,7 +426,8 @@ class SMTP:
return (code, msg)
self.does_esmtp = 1
#parse the ehlo response -ddm
- resp = self.ehlo_resp.split('\n')
+ assert isinstance(self.ehlo_resp, bytes), repr(self.ehlo_resp)
+ resp = self.ehlo_resp.decode("latin-1").split('\n')
del resp[0]
for each in resp:
# To be able to communicate with as many SMTP servers as possible,
@@ -485,23 +498,27 @@ class SMTP:
Automatically quotes lines beginning with a period per rfc821.
Raises SMTPDataError if there is an unexpected reply to the
DATA command; the return value from this method is the final
- response code received when the all data is sent.
+ response code received when the all data is sent. If msg
+ is a string, lone '\r' and '\n' characters are converted to
+ '\r\n' characters. If msg is bytes, it is transmitted as is.
"""
self.putcmd("data")
(code, repl) = self.getreply()
if self.debuglevel > 0:
- print>>stderr, "data:", (code, repl)
+ print("data:", (code, repl), file=stderr)
if code != 354:
raise SMTPDataError(code, repl)
else:
- q = quotedata(msg)
- if q[-2:] != CRLF:
- q = q + CRLF
- q = q + "." + CRLF
+ if isinstance(msg, str):
+ msg = _fix_eols(msg).encode('ascii')
+ q = _quote_periods(msg)
+ if q[-2:] != bCRLF:
+ q = q + bCRLF
+ q = q + b"." + bCRLF
self.send(q)
(code, msg) = self.getreply()
if self.debuglevel > 0:
- print>>stderr, "data:", (code, msg)
+ print("data:", (code, msg), file=stderr)
return (code, msg)
def verify(self, address):
@@ -558,13 +575,14 @@ class SMTP:
"""
def encode_cram_md5(challenge, user, password):
- challenge = base64.decodestring(challenge)
- response = user + " " + hmac.HMAC(password, challenge).hexdigest()
- return encode_base64(response, eol="")
+ challenge = base64.decodebytes(challenge)
+ response = user + " " + hmac.HMAC(password.encode('ascii'),
+ challenge).hexdigest()
+ return encode_base64(response.encode('ascii'), eol='')
def encode_plain(user, password):
- return encode_base64("\0%s\0%s" % (user, password), eol="")
-
+ s = "\0%s\0%s" % (user, password)
+ return encode_base64(s.encode('ascii'), eol='')
AUTH_PLAIN = "PLAIN"
AUTH_CRAM_MD5 = "CRAM-MD5"
@@ -575,43 +593,44 @@ class SMTP:
if not self.has_extn("auth"):
raise SMTPException("SMTP AUTH extension not supported by server.")
- # Authentication methods the server supports:
- authlist = self.esmtp_features["auth"].split()
+ # Authentication methods the server claims to support
+ advertised_authlist = self.esmtp_features["auth"].split()
# List of authentication methods we support: from preferred to
# less preferred methods. Except for the purpose of testing the weaker
# ones, we prefer stronger methods like CRAM-MD5:
preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]
- # Determine the authentication method we'll use
- authmethod = None
- for method in preferred_auths:
- if method in authlist:
- authmethod = method
- break
-
- if authmethod == AUTH_CRAM_MD5:
- (code, resp) = self.docmd("AUTH", AUTH_CRAM_MD5)
- if code == 503:
- # 503 == 'Error: already authenticated'
- return (code, resp)
- (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
- elif authmethod == AUTH_PLAIN:
- (code, resp) = self.docmd("AUTH",
- AUTH_PLAIN + " " + encode_plain(user, password))
- elif authmethod == AUTH_LOGIN:
- (code, resp) = self.docmd("AUTH",
- "%s %s" % (AUTH_LOGIN, encode_base64(user, eol="")))
- if code != 334:
- raise SMTPAuthenticationError(code, resp)
- (code, resp) = self.docmd(encode_base64(password, eol=""))
- elif authmethod is None:
+ # We try the authentication methods the server advertises, but only the
+ # ones *we* support. And in our preferred order.
+ authlist = [auth for auth in preferred_auths if auth in advertised_authlist]
+ if not authlist:
raise SMTPException("No suitable authentication method found.")
- if code not in (235, 503):
+
+ # Some servers advertise authentication methods they don't really
+ # support, so if authentication fails, we continue until we've tried
+ # all methods.
+ for authmethod in authlist:
+ if authmethod == AUTH_CRAM_MD5:
+ (code, resp) = self.docmd("AUTH", AUTH_CRAM_MD5)
+ if code == 334:
+ (code, resp) = self.docmd(encode_cram_md5(resp, user, password))
+ elif authmethod == AUTH_PLAIN:
+ (code, resp) = self.docmd("AUTH",
+ AUTH_PLAIN + " " + encode_plain(user, password))
+ elif authmethod == AUTH_LOGIN:
+ (code, resp) = self.docmd("AUTH",
+ "%s %s" % (AUTH_LOGIN, encode_base64(user.encode('ascii'), eol='')))
+ if code == 334:
+ (code, resp) = self.docmd(encode_base64(password.encode('ascii'), eol=''))
+
# 235 == 'Authentication successful'
# 503 == 'Error: already authenticated'
- raise SMTPAuthenticationError(code, resp)
- return (code, resp)
+ if code in (235, 503):
+ return (code, resp)
+
+ # We could not login sucessfully. Return result of last attempt.
+ raise SMTPAuthenticationError(code, resp)
def starttls(self, keyfile=None, certfile=None):
"""Puts the connection to the SMTP server into TLS mode.
@@ -663,6 +682,10 @@ class SMTP:
- rcpt_options : List of ESMTP options (such as DSN commands) for
all the rcpt commands.
+ msg may be a string containing characters in the ASCII range, or a byte
+ string. A string is encoded to bytes using the ascii codec, and lone
+ \\r and \\n characters are converted to \\r\\n characters.
+
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first. If the server does ESMTP, message size
and each of the specified options will be passed to it. If EHLO
@@ -708,6 +731,8 @@ class SMTP:
"""
self.ehlo_or_helo_if_needed()
esmtp_opts = []
+ if isinstance(msg, str):
+ msg = _fix_eols(msg).encode('ascii')
if self.does_esmtp:
# Hmmm? what's this? -ddm
# self.esmtp_features['7bit']=""
@@ -715,13 +740,12 @@ class SMTP:
esmtp_opts.append("size=%d" % len(msg))
for option in mail_options:
esmtp_opts.append(option)
-
(code, resp) = self.mail(from_addr, esmtp_opts)
if code != 250:
self.rset()
raise SMTPSenderRefused(code, resp, from_addr)
senderrs = {}
- if isinstance(to_addrs, basestring):
+ if isinstance(to_addrs, str):
to_addrs = [to_addrs]
for each in to_addrs:
(code, resp) = self.rcpt(each, rcpt_options)
@@ -738,6 +762,57 @@ class SMTP:
#if we got here then somebody got our mail
return senderrs
+ def send_message(self, msg, from_addr=None, to_addrs=None,
+ mail_options=[], rcpt_options={}):
+ """Converts message to a bytestring and passes it to sendmail.
+
+ The arguments are as for sendmail, except that msg is an
+ email.message.Message object. If from_addr is None or to_addrs is
+ None, these arguments are taken from the headers of the Message as
+ described in RFC 2822 (a ValueError is raised if there is more than
+ one set of 'Resent-' headers). Regardless of the values of from_addr and
+ to_addr, any Bcc field (or Resent-Bcc field, when the Message is a
+ resent) of the Message object won't be transmitted. The Message
+ object is then serialized using email.generator.BytesGenerator and
+ sendmail is called to transmit the message.
+
+ """
+ # 'Resent-Date' is a mandatory field if the Message is resent (RFC 2822
+ # Section 3.6.6). In such a case, we use the 'Resent-*' fields. However,
+ # if there is more than one 'Resent-' block there's no way to
+ # unambiguously determine which one is the most recent in all cases,
+ # so rather than guess we raise a ValueError in that case.
+ #
+ # TODO implement heuristics to guess the correct Resent-* block with an
+ # option allowing the user to enable the heuristics. (It should be
+ # possible to guess correctly almost all of the time.)
+ resent =msg.get_all('Resent-Date')
+ if resent is None:
+ header_prefix = ''
+ elif len(resent) == 1:
+ header_prefix = 'Resent-'
+ else:
+ raise ValueError("message has more than one 'Resent-' header block")
+ if from_addr is None:
+ # Prefer the sender field per RFC 2822:3.6.2.
+ from_addr = (msg[header_prefix+'Sender']
+ if (header_prefix+'Sender') in msg
+ else msg[header_prefix+'From'])
+ if to_addrs is None:
+ addr_fields = [f for f in (msg[header_prefix+'To'],
+ msg[header_prefix+'Bcc'],
+ msg[header_prefix+'Cc']) if f is not None]
+ to_addrs = [a[1] for a in email.utils.getaddresses(addr_fields)]
+ # Make a local copy so we can delete the bcc headers.
+ msg_copy = copy.copy(msg)
+ del msg_copy['Bcc']
+ del msg_copy['Resent-Bcc']
+ with io.BytesIO() as bytesmsg:
+ g = email.generator.BytesGenerator(bytesmsg)
+ g.flatten(msg_copy, linesep='\r\n')
+ flatmsg = bytesmsg.getvalue()
+ return self.sendmail(from_addr, to_addrs, flatmsg, mail_options,
+ rcpt_options)
def close(self):
"""Close the connection to the SMTP server."""
@@ -748,7 +823,6 @@ class SMTP:
self.sock.close()
self.sock = None
-
def quit(self):
"""Terminate the SMTP session."""
res = self.docmd("quit")
@@ -777,7 +851,7 @@ if _have_ssl:
def _get_socket(self, host, port, timeout):
if self.debuglevel > 0:
- print>>stderr, 'connect:', (host, port)
+ print('connect:', (host, port), file=stderr)
new_socket = socket.create_connection((host, port), timeout)
new_socket = ssl.wrap_socket(new_socket, self.keyfile, self.certfile)
self.file = SSLFakeFile(new_socket)
@@ -820,14 +894,14 @@ class LMTP(SMTP):
self.sock.connect(host)
except socket.error:
if self.debuglevel > 0:
- print>>stderr, 'connect fail:', host
+ print('connect fail:', host, file=stderr)
if self.sock:
self.sock.close()
self.sock = None
raise
(code, msg) = self.getreply()
if self.debuglevel > 0:
- print>>stderr, "connect:", msg
+ print('connect:', msg, file=stderr)
return (code, msg)
@@ -838,18 +912,19 @@ if __name__ == '__main__':
def prompt(prompt):
sys.stdout.write(prompt + ": ")
+ sys.stdout.flush()
return sys.stdin.readline().strip()
fromaddr = prompt("From")
toaddrs = prompt("To").split(',')
- print "Enter message, end with ^D:"
+ print("Enter message, end with ^D:")
msg = ''
while 1:
line = sys.stdin.readline()
if not line:
break
msg = msg + line
- print "Message length is %d" % len(msg)
+ print("Message length is %d" % len(msg))
server = SMTP('localhost')
server.set_debuglevel(1)
diff --git a/Lib/sndhdr.py b/Lib/sndhdr.py
index cc2d6b8b197..9f5dcc90d43 100644
--- a/Lib/sndhdr.py
+++ b/Lib/sndhdr.py
@@ -30,23 +30,23 @@ explicitly given directories.
# The file structure is top-down except that the test program and its
# subroutine come last.
-__all__ = ["what","whathdr"]
+__all__ = ['what', 'whathdr']
def what(filename):
- """Guess the type of a sound file"""
+ """Guess the type of a sound file."""
res = whathdr(filename)
return res
def whathdr(filename):
- """Recognize sound headers"""
- f = open(filename, 'rb')
- h = f.read(512)
- for tf in tests:
- res = tf(h, f)
- if res:
- return res
- return None
+ """Recognize sound headers."""
+ with open(filename, 'rb') as f:
+ h = f.read(512)
+ for tf in tests:
+ res = tf(h, f)
+ if res:
+ return res
+ return None
#-----------------------------------#
@@ -57,38 +57,38 @@ tests = []
def test_aifc(h, f):
import aifc
- if h[:4] != 'FORM':
+ if not h.startswith(b'FORM'):
return None
- if h[8:12] == 'AIFC':
+ if h[8:12] == b'AIFC':
fmt = 'aifc'
- elif h[8:12] == 'AIFF':
+ elif h[8:12] == b'AIFF':
fmt = 'aiff'
else:
return None
f.seek(0)
try:
- a = aifc.openfp(f, 'r')
+ a = aifc.open(f, 'r')
except (EOFError, aifc.Error):
return None
- return (fmt, a.getframerate(), a.getnchannels(), \
- a.getnframes(), 8*a.getsampwidth())
+ return (fmt, a.getframerate(), a.getnchannels(),
+ a.getnframes(), 8 * a.getsampwidth())
tests.append(test_aifc)
def test_au(h, f):
- if h[:4] == '.snd':
- f = get_long_be
- elif h[:4] in ('\0ds.', 'dns.'):
- f = get_long_le
+ if h.startswith(b'.snd'):
+ func = get_long_be
+ elif h[:4] in (b'\0ds.', b'dns.'):
+ func = get_long_le
else:
return None
- type = 'au'
- hdr_size = f(h[4:8])
- data_size = f(h[8:12])
- encoding = f(h[12:16])
- rate = f(h[16:20])
- nchannels = f(h[20:24])
+ filetype = 'au'
+ hdr_size = func(h[4:8])
+ data_size = func(h[8:12])
+ encoding = func(h[12:16])
+ rate = func(h[16:20])
+ nchannels = func(h[20:24])
sample_size = 1 # default
if encoding == 1:
sample_bits = 'U'
@@ -100,28 +100,37 @@ def test_au(h, f):
else:
sample_bits = '?'
frame_size = sample_size * nchannels
- return type, rate, nchannels, data_size//frame_size, sample_bits
+ if frame_size:
+ nframe = data_size / frame_size
+ else:
+ nframe = -1
+ return filetype, rate, nchannels, nframe, sample_bits
tests.append(test_au)
def test_hcom(h, f):
- if h[65:69] != 'FSSD' or h[128:132] != 'HCOM':
+ if h[65:69] != b'FSSD' or h[128:132] != b'HCOM':
return None
- divisor = get_long_be(h[128+16:128+20])
- return 'hcom', 22050//divisor, 1, -1, 8
+ divisor = get_long_be(h[144:148])
+ if divisor:
+ rate = 22050 / divisor
+ else:
+ rate = 0
+ return 'hcom', rate, 1, -1, 8
tests.append(test_hcom)
def test_voc(h, f):
- if h[:20] != 'Creative Voice File\032':
+ if not h.startswith(b'Creative Voice File\032'):
return None
sbseek = get_short_le(h[20:22])
rate = 0
- if 0 <= sbseek < 500 and h[sbseek] == '\1':
- ratecode = ord(h[sbseek+4])
- rate = int(1000000.0 / (256 - ratecode))
+ if 0 <= sbseek < 500 and h[sbseek] == 1:
+ ratecode = 256 - h[sbseek+4]
+ if ratecode:
+ rate = int(1000000.0 / ratecode)
return 'voc', rate, 1, -1, 8
tests.append(test_voc)
@@ -129,7 +138,7 @@ tests.append(test_voc)
def test_wav(h, f):
# 'RIFF' <len> 'WAVE' 'fmt ' <len>
- if h[:4] != 'RIFF' or h[8:12] != 'WAVE' or h[12:16] != 'fmt ':
+ if not h.startswith(b'RIFF') or h[8:12] != b'WAVE' or h[12:16] != b'fmt ':
return None
style = get_short_le(h[20:22])
nchannels = get_short_le(h[22:24])
@@ -141,7 +150,7 @@ tests.append(test_wav)
def test_8svx(h, f):
- if h[:4] != 'FORM' or h[8:12] != '8SVX':
+ if not h.startswith(b'FORM') or h[8:12] != b'8SVX':
return None
# Should decode it to get #channels -- assume always 1
return '8svx', 0, 1, 0, 8
@@ -150,7 +159,7 @@ tests.append(test_8svx)
def test_sndt(h, f):
- if h[:5] == 'SOUND':
+ if h.startswith(b'SOUND'):
nsamples = get_long_le(h[8:12])
rate = get_short_le(h[20:22])
return 'sndt', rate, 1, nsamples, 8
@@ -159,7 +168,7 @@ tests.append(test_sndt)
def test_sndr(h, f):
- if h[:2] == '\0\0':
+ if h.startswith(b'\0\0'):
rate = get_short_le(h[2:4])
if 4000 <= rate <= 25000:
return 'sndr', rate, 1, -1, 8
@@ -167,21 +176,21 @@ def test_sndr(h, f):
tests.append(test_sndr)
-#---------------------------------------------#
-# Subroutines to extract numbers from strings #
-#---------------------------------------------#
+#-------------------------------------------#
+# Subroutines to extract numbers from bytes #
+#-------------------------------------------#
-def get_long_be(s):
- return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
+def get_long_be(b):
+ return (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3]
-def get_long_le(s):
- return (ord(s[3])<<24) | (ord(s[2])<<16) | (ord(s[1])<<8) | ord(s[0])
+def get_long_le(b):
+ return (b[3] << 24) | (b[2] << 16) | (b[1] << 8) | b[0]
-def get_short_be(s):
- return (ord(s[0])<<8) | ord(s[1])
+def get_short_be(b):
+ return (b[0] << 8) | b[1]
-def get_short_le(s):
- return (ord(s[1])<<8) | ord(s[0])
+def get_short_le(b):
+ return (b[1] << 8) | b[0]
#--------------------#
@@ -208,21 +217,21 @@ def testall(list, recursive, toplevel):
import os
for filename in list:
if os.path.isdir(filename):
- print filename + '/:',
+ print(filename + '/:', end=' ')
if recursive or toplevel:
- print 'recursing down:'
+ print('recursing down:')
import glob
names = glob.glob(os.path.join(filename, '*'))
testall(names, recursive, 0)
else:
- print '*** directory (use -r) ***'
+ print('*** directory (use -r) ***')
else:
- print filename + ':',
+ print(filename + ':', end=' ')
sys.stdout.flush()
try:
- print what(filename)
+ print(what(filename))
except IOError:
- print '*** not found ***'
+ print('*** not found ***')
if __name__ == '__main__':
test()
diff --git a/Lib/socket.py b/Lib/socket.py
index aac04f6ca7a..ea56a67d555 100644
--- a/Lib/socket.py
+++ b/Lib/socket.py
@@ -21,7 +21,6 @@ ntohs(), ntohl() -- convert 16, 32 bit int from network to host byte order
htons(), htonl() -- convert 16, 32 bit int from host to network byte order
inet_aton() -- convert IP addr string (123.45.67.89) to 32-bit packed format
inet_ntoa() -- convert 32-bit packed format IP to string (123.45.67.89)
-ssl() -- secure socket layer support (only available if configured)
socket.getdefaulttimeout() -- get the default timeout value
socket.setdefaulttimeout() -- set the default timeout value
create_connection() -- connects to an address, with an optional timeout and
@@ -46,45 +45,8 @@ the setsockopt() and getsockopt() methods.
import _socket
from _socket import *
-from functools import partial
-from types import MethodType
-try:
- import _ssl
-except ImportError:
- # no SSL support
- pass
-else:
- def ssl(sock, keyfile=None, certfile=None):
- # we do an internal import here because the ssl
- # module imports the socket module
- import ssl as _realssl
- warnings.warn("socket.ssl() is deprecated. Use ssl.wrap_socket() instead.",
- DeprecationWarning, stacklevel=2)
- return _realssl.sslwrap_simple(sock, keyfile, certfile)
-
- # we need to import the same constants we used to...
- from _ssl import SSLError as sslerror
- from _ssl import \
- RAND_add, \
- RAND_egd, \
- RAND_status, \
- SSL_ERROR_ZERO_RETURN, \
- SSL_ERROR_WANT_READ, \
- SSL_ERROR_WANT_WRITE, \
- SSL_ERROR_WANT_X509_LOOKUP, \
- SSL_ERROR_SYSCALL, \
- SSL_ERROR_SSL, \
- SSL_ERROR_WANT_CONNECT, \
- SSL_ERROR_EOF, \
- SSL_ERROR_INVALID_ERROR_CODE
-
-import os, sys, warnings
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+import os, sys, io
try:
import errno
@@ -92,6 +54,8 @@ except ImportError:
errno = None
EBADF = getattr(errno, 'EBADF', 9)
EINTR = getattr(errno, 'EINTR', 4)
+EAGAIN = getattr(errno, 'EAGAIN', 11)
+EWOULDBLOCK = getattr(errno, 'EWOULDBLOCK', 11)
__all__ = ["getfqdn", "create_connection"]
__all__.extend(os._get_exports_list(_socket))
@@ -120,417 +84,308 @@ if sys.platform.lower().startswith("win"):
__all__.append("errorTab")
+class socket(_socket.socket):
-def getfqdn(name=''):
- """Get fully qualified domain name from name.
+ """A subclass of _socket.socket adding the makefile() method."""
- An empty argument is interpreted as meaning the local host.
+ __slots__ = ["__weakref__", "_io_refs", "_closed"]
- First the hostname returned by gethostbyaddr() is checked, then
- possibly existing aliases. In case no FQDN is available, hostname
- from gethostname() is returned.
- """
- name = name.strip()
- if not name or name == '0.0.0.0':
- name = gethostname()
- try:
- hostname, aliases, ipaddrs = gethostbyaddr(name)
- except error:
- pass
- else:
- aliases.insert(0, hostname)
- for name in aliases:
- if '.' in name:
- break
- else:
- name = hostname
- return name
+ def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None):
+ _socket.socket.__init__(self, family, type, proto, fileno)
+ self._io_refs = 0
+ self._closed = False
+ def __enter__(self):
+ return self
-_socketmethods = (
- 'bind', 'connect', 'connect_ex', 'fileno', 'listen',
- 'getpeername', 'getsockname', 'getsockopt', 'setsockopt',
- 'sendall', 'setblocking',
- 'settimeout', 'gettimeout', 'shutdown')
+ def __exit__(self, *args):
+ if not self._closed:
+ self.close()
-if os.name == "nt":
- _socketmethods = _socketmethods + ('ioctl',)
+ def __repr__(self):
+ """Wrap __repr__() to reveal the real class name."""
+ s = _socket.socket.__repr__(self)
+ if s.startswith("<socket object"):
+ s = "<%s.%s%s%s" % (self.__class__.__module__,
+ self.__class__.__name__,
+ getattr(self, '_closed', False) and " [closed] " or "",
+ s[7:])
+ return s
-if sys.platform == "riscos":
- _socketmethods = _socketmethods + ('sleeptaskw',)
+ def dup(self):
+ """dup() -> socket object
-# All the method names that must be delegated to either the real socket
-# object or the _closedsocket object.
-_delegate_methods = ("recv", "recvfrom", "recv_into", "recvfrom_into",
- "send", "sendto")
+ Return a new socket object connected to the same system resource.
+ """
+ fd = dup(self.fileno())
+ sock = self.__class__(self.family, self.type, self.proto, fileno=fd)
+ sock.settimeout(self.gettimeout())
+ return sock
-class _closedsocket(object):
- __slots__ = []
- def _dummy(*args):
- raise error(EBADF, 'Bad file descriptor')
- # All _delegate_methods must also be initialized here.
- send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
- __getattr__ = _dummy
+ def accept(self):
+ """accept() -> (socket object, address info)
+
+ Wait for an incoming connection. Return a new socket
+ representing the connection, and the address of the client.
+ For IP sockets, the address info is a pair (hostaddr, port).
+ """
+ fd, addr = self._accept()
+ sock = socket(self.family, self.type, self.proto, fileno=fd)
+ # Issue #7995: if no default timeout is set and the listening
+ # socket had a (non-zero) timeout, force the new socket in blocking
+ # mode to override platform-specific socket flags inheritance.
+ if getdefaulttimeout() is None and self.gettimeout():
+ sock.setblocking(True)
+ return sock, addr
+
+ def makefile(self, mode="r", buffering=None, *,
+ encoding=None, errors=None, newline=None):
+ """makefile(...) -> an I/O stream connected to the socket
+
+ The arguments are as for io.open() after the filename,
+ except the only mode characters supported are 'r', 'w' and 'b'.
+ The semantics are similar too. (XXX refactor to share code?)
+ """
+ for c in mode:
+ if c not in {"r", "w", "b"}:
+ raise ValueError("invalid mode %r (only r, w, b allowed)")
+ writing = "w" in mode
+ reading = "r" in mode or not writing
+ assert reading or writing
+ binary = "b" in mode
+ rawmode = ""
+ if reading:
+ rawmode += "r"
+ if writing:
+ rawmode += "w"
+ raw = SocketIO(self, rawmode)
+ self._io_refs += 1
+ if buffering is None:
+ buffering = -1
+ if buffering < 0:
+ buffering = io.DEFAULT_BUFFER_SIZE
+ if buffering == 0:
+ if not binary:
+ raise ValueError("unbuffered streams must be binary")
+ return raw
+ if reading and writing:
+ buffer = io.BufferedRWPair(raw, raw, buffering)
+ elif reading:
+ buffer = io.BufferedReader(raw, buffering)
+ else:
+ assert writing
+ buffer = io.BufferedWriter(raw, buffering)
+ if binary:
+ return buffer
+ text = io.TextIOWrapper(buffer, encoding, errors, newline)
+ text.mode = mode
+ return text
+
+ def _decref_socketios(self):
+ if self._io_refs > 0:
+ self._io_refs -= 1
+ if self._closed:
+ self.close()
-# Wrapper around platform socket objects. This implements
-# a platform-independent dup() functionality. The
-# implementation currently relies on reference counting
-# to close the underlying socket object.
-class _socketobject(object):
+ def _real_close(self, _ss=_socket.socket):
+ # This function should not reference any globals. See issue #808164.
+ _ss.close(self)
- __doc__ = _realsocket.__doc__
+ def close(self):
+ # This function should not reference any globals. See issue #808164.
+ self._closed = True
+ if self._io_refs <= 0:
+ self._real_close()
- __slots__ = ["_sock", "__weakref__"] + list(_delegate_methods)
+ def detach(self):
+ """detach() -> file descriptor
- def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
- if _sock is None:
- _sock = _realsocket(family, type, proto)
- self._sock = _sock
- for method in _delegate_methods:
- setattr(self, method, getattr(_sock, method))
+ Close the socket object without closing the underlying file descriptor.
+ The object cannot be used after this call, but the file descriptor
+ can be reused for other purposes. The file descriptor is returned.
+ """
+ self._closed = True
+ return super().detach()
- def close(self, _closedsocket=_closedsocket,
- _delegate_methods=_delegate_methods, setattr=setattr):
- # This function should not reference any globals. See issue #808164.
- self._sock = _closedsocket()
- dummy = self._sock._dummy
- for method in _delegate_methods:
- setattr(self, method, dummy)
- close.__doc__ = _realsocket.close.__doc__
- def accept(self):
- sock, addr = self._sock.accept()
- return _socketobject(_sock=sock), addr
- accept.__doc__ = _realsocket.accept.__doc__
+def fromfd(fd, family, type, proto=0):
+ """ fromfd(fd, family, type[, proto]) -> socket object
- def dup(self):
- """dup() -> socket object
+ Create a socket object from a duplicate of the given file
+ descriptor. The remaining arguments are the same as for socket().
+ """
+ nfd = dup(fd)
+ return socket(family, type, proto, nfd)
- Return a new socket object connected to the same system resource."""
- return _socketobject(_sock=self._sock)
- def makefile(self, mode='r', bufsize=-1):
- """makefile([mode[, bufsize]]) -> file object
+if hasattr(_socket, "socketpair"):
- Return a regular file object corresponding to the socket. The mode
- and bufsize arguments are as for the built-in open() function."""
- return _fileobject(self._sock, mode, bufsize)
+ def socketpair(family=None, type=SOCK_STREAM, proto=0):
+ """socketpair([family[, type[, proto]]]) -> (socket object, socket object)
- family = property(lambda self: self._sock.family, doc="the socket family")
- type = property(lambda self: self._sock.type, doc="the socket type")
- proto = property(lambda self: self._sock.proto, doc="the socket protocol")
+ Create a pair of socket objects from the sockets returned by the platform
+ socketpair() function.
+ The arguments are the same as for socket() except the default family is
+ AF_UNIX if defined on the platform; otherwise, the default is AF_INET.
+ """
+ if family is None:
+ try:
+ family = AF_UNIX
+ except NameError:
+ family = AF_INET
+ a, b = _socket.socketpair(family, type, proto)
+ a = socket(family, type, proto, a.detach())
+ b = socket(family, type, proto, b.detach())
+ return a, b
-def meth(name,self,*args):
- return getattr(self._sock,name)(*args)
-for _m in _socketmethods:
- p = partial(meth,_m)
- p.__name__ = _m
- p.__doc__ = getattr(_realsocket,_m).__doc__
- m = MethodType(p,None,_socketobject)
- setattr(_socketobject,_m,m)
+_blocking_errnos = { EAGAIN, EWOULDBLOCK }
-socket = SocketType = _socketobject
+class SocketIO(io.RawIOBase):
-class _fileobject(object):
- """Faux file object attached to a socket object."""
+ """Raw I/O implementation for stream sockets.
- default_bufsize = 8192
- name = "<socket>"
+ This class supports the makefile() method on sockets. It provides
+ the raw I/O interface on top of a socket object.
+ """
- __slots__ = ["mode", "bufsize", "softspace",
- # "closed" is a property, see below
- "_sock", "_rbufsize", "_wbufsize", "_rbuf", "_wbuf", "_wbuf_len",
- "_close"]
+ # One might wonder why not let FileIO do the job instead. There are two
+ # main reasons why FileIO is not adapted:
+ # - it wouldn't work under Windows (where you can't used read() and
+ # write() on a socket handle)
+ # - it wouldn't work with socket timeouts (FileIO would ignore the
+ # timeout and consider the socket non-blocking)
- def __init__(self, sock, mode='rb', bufsize=-1, close=False):
- self._sock = sock
- self.mode = mode # Not actually used in this version
- if bufsize < 0:
- bufsize = self.default_bufsize
- self.bufsize = bufsize
- self.softspace = False
- # _rbufsize is the suggested recv buffer size. It is *strictly*
- # obeyed within readline() for recv calls. If it is larger than
- # default_bufsize it will be used for recv calls within read().
- if bufsize == 0:
- self._rbufsize = 1
- elif bufsize == 1:
- self._rbufsize = self.default_bufsize
- else:
- self._rbufsize = bufsize
- self._wbufsize = bufsize
- # We use StringIO for the read buffer to avoid holding a list
- # of variously sized string objects which have been known to
- # fragment the heap due to how they are malloc()ed and often
- # realloc()ed down much smaller than their original allocation.
- self._rbuf = StringIO()
- self._wbuf = [] # A list of strings
- self._wbuf_len = 0
- self._close = close
-
- def _getclosed(self):
- return self._sock is None
- closed = property(_getclosed, doc="True if the file is closed")
+ # XXX More docs
- def close(self):
- try:
- if self._sock:
- self.flush()
- finally:
- if self._close:
- self._sock.close()
- self._sock = None
-
- def __del__(self):
- try:
- self.close()
- except:
- # close() may fail if __init__ didn't complete
- pass
-
- def flush(self):
- if self._wbuf:
- data = "".join(self._wbuf)
- self._wbuf = []
- self._wbuf_len = 0
- buffer_size = max(self._rbufsize, self.default_bufsize)
- data_size = len(data)
- write_offset = 0
- view = memoryview(data)
+ def __init__(self, sock, mode):
+ if mode not in ("r", "w", "rw", "rb", "wb", "rwb"):
+ raise ValueError("invalid mode: %r" % mode)
+ io.RawIOBase.__init__(self)
+ self._sock = sock
+ if "b" not in mode:
+ mode += "b"
+ self._mode = mode
+ self._reading = "r" in mode
+ self._writing = "w" in mode
+ self._timeout_occurred = False
+
+ def readinto(self, b):
+ """Read up to len(b) bytes into the writable buffer *b* and return
+ the number of bytes read. If the socket is non-blocking and no bytes
+ are available, None is returned.
+
+ If *b* is non-empty, a 0 return value indicates that the connection
+ was shutdown at the other end.
+ """
+ self._checkClosed()
+ self._checkReadable()
+ if self._timeout_occurred:
+ raise IOError("cannot read from timed out object")
+ while True:
try:
- while write_offset < data_size:
- self._sock.sendall(view[write_offset:write_offset+buffer_size])
- write_offset += buffer_size
- finally:
- if write_offset < data_size:
- remainder = data[write_offset:]
- del view, data # explicit free
- self._wbuf.append(remainder)
- self._wbuf_len = len(remainder)
+ return self._sock.recv_into(b)
+ except timeout:
+ self._timeout_occurred = True
+ raise
+ except error as e:
+ n = e.args[0]
+ if n == EINTR:
+ continue
+ if n in _blocking_errnos:
+ return None
+ raise
+
+ def write(self, b):
+ """Write the given bytes or bytearray object *b* to the socket
+ and return the number of bytes written. This can be less than
+ len(b) if not all data could be written. If the socket is
+ non-blocking and no bytes could be written None is returned.
+ """
+ self._checkClosed()
+ self._checkWritable()
+ try:
+ return self._sock.send(b)
+ except error as e:
+ # XXX what about EINTR?
+ if e.args[0] in _blocking_errnos:
+ return None
+ raise
+
+ def readable(self):
+ """True if the SocketIO is open for reading.
+ """
+ if self.closed:
+ raise ValueError("I/O operation on closed socket.")
+ return self._reading
+
+ def writable(self):
+ """True if the SocketIO is open for writing.
+ """
+ if self.closed:
+ raise ValueError("I/O operation on closed socket.")
+ return self._writing
+
+ def seekable(self):
+ """True if the SocketIO is open for seeking.
+ """
+ if self.closed:
+ raise ValueError("I/O operation on closed socket.")
+ return super().seekable()
def fileno(self):
+ """Return the file descriptor of the underlying socket.
+ """
+ self._checkClosed()
return self._sock.fileno()
- def write(self, data):
- data = str(data) # XXX Should really reject non-string non-buffers
- if not data:
- return
- self._wbuf.append(data)
- self._wbuf_len += len(data)
- if (self._wbufsize == 0 or
- (self._wbufsize == 1 and '\n' in data) or
- (self._wbufsize > 1 and self._wbuf_len >= self._wbufsize)):
- self.flush()
-
- def writelines(self, list):
- # XXX We could do better here for very long lists
- # XXX Should really reject non-string non-buffers
- lines = filter(None, map(str, list))
- self._wbuf_len += sum(map(len, lines))
- self._wbuf.extend(lines)
- if (self._wbufsize <= 1 or
- self._wbuf_len >= self._wbufsize):
- self.flush()
-
- def read(self, size=-1):
- # Use max, disallow tiny reads in a loop as they are very inefficient.
- # We never leave read() with any leftover data from a new recv() call
- # in our internal buffer.
- rbufsize = max(self._rbufsize, self.default_bufsize)
- # Our use of StringIO rather than lists of string objects returned by
- # recv() minimizes memory usage and fragmentation that occurs when
- # rbufsize is large compared to the typical return value of recv().
- buf = self._rbuf
- buf.seek(0, 2) # seek end
- if size < 0:
- # Read until EOF
- self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
- while True:
- try:
- data = self._sock.recv(rbufsize)
- except error, e:
- if e.args[0] == EINTR:
- continue
- raise
- if not data:
- break
- buf.write(data)
- return buf.getvalue()
- else:
- # Read until size bytes or EOF seen, whichever comes first
- buf_len = buf.tell()
- if buf_len >= size:
- # Already have size bytes in our buffer? Extract and return.
- buf.seek(0)
- rv = buf.read(size)
- self._rbuf = StringIO()
- self._rbuf.write(buf.read())
- return rv
-
- self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
- while True:
- left = size - buf_len
- # recv() will malloc the amount of memory given as its
- # parameter even though it often returns much less data
- # than that. The returned data string is short lived
- # as we copy it into a StringIO and free it. This avoids
- # fragmentation issues on many platforms.
- try:
- data = self._sock.recv(left)
- except error, e:
- if e.args[0] == EINTR:
- continue
- raise
- if not data:
- break
- n = len(data)
- if n == size and not buf_len:
- # Shortcut. Avoid buffer data copies when:
- # - We have no data in our buffer.
- # AND
- # - Our call to recv returned exactly the
- # number of bytes we were asked to read.
- return data
- if n == left:
- buf.write(data)
- del data # explicit free
- break
- assert n <= left, "recv(%d) returned %d bytes" % (left, n)
- buf.write(data)
- buf_len += n
- del data # explicit free
- #assert buf_len == buf.tell()
- return buf.getvalue()
-
- def readline(self, size=-1):
- buf = self._rbuf
- buf.seek(0, 2) # seek end
- if buf.tell() > 0:
- # check if we already have it in our buffer
- buf.seek(0)
- bline = buf.readline(size)
- if bline.endswith('\n') or len(bline) == size:
- self._rbuf = StringIO()
- self._rbuf.write(buf.read())
- return bline
- del bline
- if size < 0:
- # Read until \n or EOF, whichever comes first
- if self._rbufsize <= 1:
- # Speed up unbuffered case
- buf.seek(0)
- buffers = [buf.read()]
- self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
- data = None
- recv = self._sock.recv
- while True:
- try:
- while data != "\n":
- data = recv(1)
- if not data:
- break
- buffers.append(data)
- except error, e:
- # The try..except to catch EINTR was moved outside the
- # recv loop to avoid the per byte overhead.
- if e.args[0] == EINTR:
- continue
- raise
- break
- return "".join(buffers)
-
- buf.seek(0, 2) # seek end
- self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
- while True:
- try:
- data = self._sock.recv(self._rbufsize)
- except error, e:
- if e.args[0] == EINTR:
- continue
- raise
- if not data:
- break
- nl = data.find('\n')
- if nl >= 0:
- nl += 1
- buf.write(data[:nl])
- self._rbuf.write(data[nl:])
- del data
- break
- buf.write(data)
- return buf.getvalue()
+ @property
+ def name(self):
+ if not self.closed:
+ return self.fileno()
else:
- # Read until size bytes or \n or EOF seen, whichever comes first
- buf.seek(0, 2) # seek end
- buf_len = buf.tell()
- if buf_len >= size:
- buf.seek(0)
- rv = buf.read(size)
- self._rbuf = StringIO()
- self._rbuf.write(buf.read())
- return rv
- self._rbuf = StringIO() # reset _rbuf. we consume it via buf.
- while True:
- try:
- data = self._sock.recv(self._rbufsize)
- except error, e:
- if e.args[0] == EINTR:
- continue
- raise
- if not data:
- break
- left = size - buf_len
- # did we just receive a newline?
- nl = data.find('\n', 0, left)
- if nl >= 0:
- nl += 1
- # save the excess data to _rbuf
- self._rbuf.write(data[nl:])
- if buf_len:
- buf.write(data[:nl])
- break
- else:
- # Shortcut. Avoid data copy through buf when returning
- # a substring of our first recv().
- return data[:nl]
- n = len(data)
- if n == size and not buf_len:
- # Shortcut. Avoid data copy through buf when
- # returning exactly all of our first recv().
- return data
- if n >= left:
- buf.write(data[:left])
- self._rbuf.write(data[left:])
- break
- buf.write(data)
- buf_len += n
- #assert buf_len == buf.tell()
- return buf.getvalue()
-
- def readlines(self, sizehint=0):
- total = 0
- list = []
- while True:
- line = self.readline()
- if not line:
- break
- list.append(line)
- total += len(line)
- if sizehint and total >= sizehint:
- break
- return list
+ return -1
- # Iterator protocols
+ @property
+ def mode(self):
+ return self._mode
- def __iter__(self):
- return self
+ def close(self):
+ """Close the SocketIO object. This doesn't close the underlying
+ socket, except if all references to it have disappeared.
+ """
+ if self.closed:
+ return
+ io.RawIOBase.close(self)
+ self._sock._decref_socketios()
+ self._sock = None
+
+
+def getfqdn(name=''):
+ """Get fully qualified domain name from name.
+
+ An empty argument is interpreted as meaning the local host.
+
+ First the hostname returned by gethostbyaddr() is checked, then
+ possibly existing aliases. In case no FQDN is available, hostname
+ from gethostname() is returned.
+ """
+ name = name.strip()
+ if not name or name == '0.0.0.0':
+ name = gethostname()
+ try:
+ hostname, aliases, ipaddrs = gethostbyaddr(name)
+ except error:
+ pass
+ else:
+ aliases.insert(0, hostname)
+ for name in aliases:
+ if '.' in name:
+ break
+ else:
+ name = hostname
+ return name
- def next(self):
- line = self.readline()
- if not line:
- raise StopIteration
- return line
_GLOBAL_DEFAULT_TIMEOUT = object()
diff --git a/Lib/SocketServer.py b/Lib/socketserver.py
index 26611b74d1f..8f80a7dc314 100644
--- a/Lib/SocketServer.py
+++ b/Lib/socketserver.py
@@ -347,12 +347,12 @@ class BaseServer:
The default is to print a traceback and continue.
"""
- print '-'*40
- print 'Exception happened during processing of request from',
- print client_address
+ print('-'*40)
+ print('Exception happened during processing of request from', end=' ')
+ print(client_address)
import traceback
traceback.print_exc() # XXX But this goes to stderr!
- print '-'*40
+ print('-'*40)
class TCPServer(BaseServer):
@@ -539,7 +539,7 @@ class ForkingMixIn:
if not pid: continue
try:
self.active_children.remove(pid)
- except ValueError, e:
+ except ValueError as e:
raise ValueError('%s. x=%d and list=%r' % (e.message, pid,
self.active_children))
@@ -559,8 +559,7 @@ class ForkingMixIn:
if self.active_children is None:
self.active_children = []
self.active_children.append(pid)
- self.close_request(request) #close handle in parent process
- return
+ self.close_request(request)
else:
# Child process.
# This must never return, hence os._exit()!
@@ -719,13 +718,10 @@ class DatagramRequestHandler(BaseRequestHandler):
"""Define self.rfile and self.wfile for datagram sockets."""
def setup(self):
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
+ from io import BytesIO
self.packet, self.socket = self.request
- self.rfile = StringIO(self.packet)
- self.wfile = StringIO()
+ self.rfile = BytesIO(self.packet)
+ self.wfile = BytesIO()
def finish(self):
self.socket.sendto(self.wfile.getvalue(), self.client_address)
diff --git a/Lib/sqlite3/__init__.py b/Lib/sqlite3/__init__.py
index 41ef2b76dfc..6c91df27cca 100644
--- a/Lib/sqlite3/__init__.py
+++ b/Lib/sqlite3/__init__.py
@@ -1,7 +1,6 @@
-#-*- coding: ISO-8859-1 -*-
# pysqlite2/__init__.py: the pysqlite2 package.
#
-# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -21,4 +20,4 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-from dbapi2 import *
+from sqlite3.dbapi2 import *
diff --git a/Lib/sqlite3/dbapi2.py b/Lib/sqlite3/dbapi2.py
index 7eb28e87b1b..6c121a5c06d 100644
--- a/Lib/sqlite3/dbapi2.py
+++ b/Lib/sqlite3/dbapi2.py
@@ -1,7 +1,6 @@
-#-*- coding: ISO-8859-1 -*-
# pysqlite2/dbapi2.py: the DB-API 2.0 interface
#
-# Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2004-2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -50,7 +49,7 @@ def TimestampFromTicks(ticks):
version_info = tuple([int(x) for x in version.split(".")])
sqlite_version_info = tuple([int(x) for x in sqlite_version.split(".")])
-Binary = buffer
+Binary = memoryview
def register_adapters_and_converters():
def adapt_date(val):
@@ -60,13 +59,13 @@ def register_adapters_and_converters():
return val.isoformat(" ")
def convert_date(val):
- return datetime.date(*map(int, val.split("-")))
+ return datetime.date(*map(int, val.split(b"-")))
def convert_timestamp(val):
- datepart, timepart = val.split(" ")
- year, month, day = map(int, datepart.split("-"))
- timepart_full = timepart.split(".")
- hours, minutes, seconds = map(int, timepart_full[0].split(":"))
+ datepart, timepart = val.split(b" ")
+ year, month, day = map(int, datepart.split(b"-"))
+ timepart_full = timepart.split(b".")
+ hours, minutes, seconds = map(int, timepart_full[0].split(b":"))
if len(timepart_full) == 2:
microseconds = int(timepart_full[1])
else:
diff --git a/Lib/sqlite3/test/dbapi.py b/Lib/sqlite3/test/dbapi.py
index c356d4706c4..202bd388760 100644
--- a/Lib/sqlite3/test/dbapi.py
+++ b/Lib/sqlite3/test/dbapi.py
@@ -22,7 +22,6 @@
# 3. This notice may not be removed or altered from any source distribution.
import unittest
-import sys
import sqlite3 as sqlite
try:
import threading
@@ -44,12 +43,12 @@ class ModuleTests(unittest.TestCase):
sqlite.paramstyle)
def CheckWarning(self):
- self.assertTrue(issubclass(sqlite.Warning, StandardError),
- "Warning is not a subclass of StandardError")
+ self.assertTrue(issubclass(sqlite.Warning, Exception),
+ "Warning is not a subclass of Exception")
def CheckError(self):
- self.assertTrue(issubclass(sqlite.Error, StandardError),
- "Error is not a subclass of StandardError")
+ self.assertTrue(issubclass(sqlite.Error, Exception),
+ "Error is not a subclass of Exception")
def CheckInterfaceError(self):
self.assertTrue(issubclass(sqlite.InterfaceError, sqlite.Error),
@@ -85,6 +84,7 @@ class ModuleTests(unittest.TestCase):
"NotSupportedError is not a subclass of DatabaseError")
class ConnectionTests(unittest.TestCase):
+
def setUp(self):
self.cx = sqlite.connect(":memory:")
cu = self.cx.cursor()
@@ -141,6 +141,28 @@ class ConnectionTests(unittest.TestCase):
self.assertEqual(self.cx.ProgrammingError, sqlite.ProgrammingError)
self.assertEqual(self.cx.NotSupportedError, sqlite.NotSupportedError)
+ def CheckInTransaction(self):
+ # Can't use db from setUp because we want to test initial state.
+ cx = sqlite.connect(":memory:")
+ cu = cx.cursor()
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("create table transactiontest(id integer primary key, name text)")
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("insert into transactiontest(name) values (?)", ("foo",))
+ self.assertEqual(cx.in_transaction, True)
+ cu.execute("select name from transactiontest where name=?", ["foo"])
+ row = cu.fetchone()
+ self.assertEqual(cx.in_transaction, True)
+ cx.commit()
+ self.assertEqual(cx.in_transaction, False)
+ cu.execute("select name from transactiontest where name=?", ["foo"])
+ row = cu.fetchone()
+ self.assertEqual(cx.in_transaction, False)
+
+ def CheckInTransactionRO(self):
+ with self.assertRaises(AttributeError):
+ self.cx.in_transaction = True
+
class CursorTests(unittest.TestCase):
def setUp(self):
self.cx = sqlite.connect(":memory:")
@@ -260,10 +282,6 @@ class CursorTests(unittest.TestCase):
self.assertEqual(row[0], "foo")
def CheckExecuteDictMapping_Mapping(self):
- # Test only works with Python 2.5 or later
- if sys.version_info < (2, 5, 0):
- return
-
class D(dict):
def __missing__(self, key):
return "foo"
@@ -339,7 +357,7 @@ class CursorTests(unittest.TestCase):
def __init__(self):
self.value = 5
- def next(self):
+ def __next__(self):
if self.value == 10:
raise StopIteration
else:
@@ -379,8 +397,8 @@ class CursorTests(unittest.TestCase):
self.fail("should have raised a TypeError")
except TypeError:
return
- except Exception, e:
- print "raised", e.__class__
+ except Exception as e:
+ print("raised", e.__class__)
self.fail("raised wrong exception.")
def CheckFetchIter(self):
@@ -653,7 +671,7 @@ class ConstructorTests(unittest.TestCase):
ts = sqlite.TimestampFromTicks(42)
def CheckBinary(self):
- b = sqlite.Binary(chr(0) + "'")
+ b = sqlite.Binary(b"\0'")
class ExtensionTests(unittest.TestCase):
def CheckScriptStringSql(self):
@@ -669,20 +687,6 @@ class ExtensionTests(unittest.TestCase):
res = cur.fetchone()[0]
self.assertEqual(res, 5)
- def CheckScriptStringUnicode(self):
- con = sqlite.connect(":memory:")
- cur = con.cursor()
- cur.executescript(u"""
- create table a(i);
- insert into a(i) values (5);
- select i from a;
- delete from a;
- insert into a(i) values (6);
- """)
- cur.execute("select i from a")
- res = cur.fetchone()[0]
- self.assertEqual(res, 6)
-
def CheckScriptSyntaxError(self):
con = sqlite.connect(":memory:")
cur = con.cursor()
diff --git a/Lib/sqlite3/test/dump.py b/Lib/sqlite3/test/dump.py
index 2e9b436f30a..b200333afac 100644
--- a/Lib/sqlite3/test/dump.py
+++ b/Lib/sqlite3/test/dump.py
@@ -47,7 +47,7 @@ class DumpTests(unittest.TestCase):
expected_sqls = ['BEGIN TRANSACTION;'] + expected_sqls + \
['COMMIT;']
[self.assertEqual(expected_sqls[i], actual_sqls[i])
- for i in xrange(len(expected_sqls))]
+ for i in range(len(expected_sqls))]
def suite():
return unittest.TestSuite(unittest.makeSuite(DumpTests, "Check"))
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py
index 52854be2b99..7f6f3473f3e 100644
--- a/Lib/sqlite3/test/factory.py
+++ b/Lib/sqlite3/test/factory.py
@@ -159,31 +159,31 @@ class TextFactoryTests(unittest.TestCase):
self.con = sqlite.connect(":memory:")
def CheckUnicode(self):
- austria = unicode("Österreich", "latin1")
+ austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone()
- self.assertTrue(type(row[0]) == unicode, "type of row[0] must be unicode")
+ self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode")
def CheckString(self):
- self.con.text_factory = str
- austria = unicode("Österreich", "latin1")
+ self.con.text_factory = bytes
+ austria = "Österreich"
row = self.con.execute("select ?", (austria,)).fetchone()
- self.assertTrue(type(row[0]) == str, "type of row[0] must be str")
+ self.assertTrue(type(row[0]) == bytes, "type of row[0] must be bytes")
self.assertTrue(row[0] == austria.encode("utf-8"), "column must equal original data in UTF-8")
def CheckCustom(self):
- self.con.text_factory = lambda x: unicode(x, "utf-8", "ignore")
- austria = unicode("Österreich", "latin1")
- row = self.con.execute("select ?", (austria.encode("latin1"),)).fetchone()
- self.assertTrue(type(row[0]) == unicode, "type of row[0] must be unicode")
- self.assertTrue(row[0].endswith(u"reich"), "column must contain original data")
+ self.con.text_factory = lambda x: str(x, "utf-8", "ignore")
+ austria = "Österreich"
+ row = self.con.execute("select ?", (austria,)).fetchone()
+ self.assertTrue(type(row[0]) == str, "type of row[0] must be unicode")
+ self.assertTrue(row[0].endswith("reich"), "column must contain original data")
def CheckOptimizedUnicode(self):
self.con.text_factory = sqlite.OptimizedUnicode
- austria = unicode("Österreich", "latin1")
- germany = unicode("Deutchland")
+ austria = "Österreich"
+ germany = "Deutchland"
a_row = self.con.execute("select ?", (austria,)).fetchone()
d_row = self.con.execute("select ?", (germany,)).fetchone()
- self.assertTrue(type(a_row[0]) == unicode, "type of non-ASCII row must be unicode")
+ self.assertTrue(type(a_row[0]) == str, "type of non-ASCII row must be str")
self.assertTrue(type(d_row[0]) == str, "type of ASCII-only row must be str")
def tearDown(self):
@@ -196,33 +196,29 @@ class TextFactoryTestsWithEmbeddedZeroBytes(unittest.TestCase):
self.con.execute("insert into test (value) values (?)", ("a\x00b",))
def CheckString(self):
- # text_factory defaults to unicode
+ # text_factory defaults to str
row = self.con.execute("select value from test").fetchone()
- self.assertIs(type(row[0]), unicode)
+ self.assertIs(type(row[0]), str)
self.assertEqual(row[0], "a\x00b")
- def CheckCustom(self):
- # A custom factory should receive an str argument
- self.con.text_factory = lambda x: x
+ def CheckBytes(self):
+ self.con.text_factory = bytes
row = self.con.execute("select value from test").fetchone()
- self.assertIs(type(row[0]), str)
- self.assertEqual(row[0], "a\x00b")
+ self.assertIs(type(row[0]), bytes)
+ self.assertEqual(row[0], b"a\x00b")
- def CheckOptimizedUnicodeAsString(self):
- # ASCII -> str argument
- self.con.text_factory = sqlite.OptimizedUnicode
+ def CheckBytearray(self):
+ self.con.text_factory = bytearray
row = self.con.execute("select value from test").fetchone()
- self.assertIs(type(row[0]), str)
- self.assertEqual(row[0], "a\x00b")
+ self.assertIs(type(row[0]), bytearray)
+ self.assertEqual(row[0], b"a\x00b")
- def CheckOptimizedUnicodeAsUnicode(self):
- # Non-ASCII -> unicode argument
- self.con.text_factory = sqlite.OptimizedUnicode
- self.con.execute("delete from test")
- self.con.execute("insert into test (value) values (?)", (u'ä\0ö',))
+ def CheckCustom(self):
+ # A custom factory should receive a bytes argument
+ self.con.text_factory = lambda x: x
row = self.con.execute("select value from test").fetchone()
- self.assertIs(type(row[0]), unicode)
- self.assertEqual(row[0], u"ä\x00ö")
+ self.assertIs(type(row[0]), bytes)
+ self.assertEqual(row[0], b"a\x00b")
def tearDown(self):
self.con.close()
diff --git a/Lib/sqlite3/test/hooks.py b/Lib/sqlite3/test/hooks.py
index b798e749add..a92e8387861 100644
--- a/Lib/sqlite3/test/hooks.py
+++ b/Lib/sqlite3/test/hooks.py
@@ -21,7 +21,7 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-import os, unittest
+import unittest
import sqlite3 as sqlite
class CollationTests(unittest.TestCase):
@@ -36,15 +36,15 @@ class CollationTests(unittest.TestCase):
try:
con.create_collation("X", 42)
self.fail("should have raised a TypeError")
- except TypeError, e:
+ except TypeError as e:
self.assertEqual(e.args[0], "parameter must be callable")
def CheckCreateCollationNotAscii(self):
con = sqlite.connect(":memory:")
try:
- con.create_collation("collä", cmp)
+ con.create_collation("collä", lambda x, y: (x > y) - (x < y))
self.fail("should have raised a ProgrammingError")
- except sqlite.ProgrammingError, e:
+ except sqlite.ProgrammingError as e:
pass
def CheckCollationIsUsed(self):
@@ -52,7 +52,7 @@ class CollationTests(unittest.TestCase):
return
def mycoll(x, y):
# reverse order
- return -cmp(x, y)
+ return -((x > y) - (x < y))
con = sqlite.connect(":memory:")
con.create_collation("mycoll", mycoll)
@@ -73,7 +73,7 @@ class CollationTests(unittest.TestCase):
try:
result = con.execute(sql).fetchall()
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0].lower(), "no such collation sequence: mycoll")
def CheckCollationRegisterTwice(self):
@@ -82,8 +82,8 @@ class CollationTests(unittest.TestCase):
Verify that the last one is actually used.
"""
con = sqlite.connect(":memory:")
- con.create_collation("mycoll", cmp)
- con.create_collation("mycoll", lambda x, y: -cmp(x, y))
+ con.create_collation("mycoll", lambda x, y: (x > y) - (x < y))
+ con.create_collation("mycoll", lambda x, y: -((x > y) - (x < y)))
result = con.execute("""
select x from (select 'a' as x union select 'b' as x) order by x collate mycoll
""").fetchall()
@@ -96,12 +96,12 @@ class CollationTests(unittest.TestCase):
to use it.
"""
con = sqlite.connect(":memory:")
- con.create_collation("mycoll", cmp)
+ con.create_collation("mycoll", lambda x, y: (x > y) - (x < y))
con.create_collation("mycoll", None)
try:
con.execute("select 'a' as x union select 'b' as x order by x collate mycoll")
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
if not e.args[0].startswith("no such collation sequence"):
self.fail("wrong OperationalError raised")
@@ -166,14 +166,15 @@ class ProgressTests(unittest.TestCase):
Test that setting the progress handler to None clears the previously set handler.
"""
con = sqlite.connect(":memory:")
- action = []
+ action = 0
def progress():
- action.append(1)
+ nonlocal action
+ action = 1
return 0
con.set_progress_handler(progress, 1)
con.set_progress_handler(None, 1)
con.execute("select 1 union select 2 union select 3").fetchall()
- self.assertEqual(len(action), 0, "progress handler was not cleared")
+ self.assertEqual(action, 0, "progress handler was not cleared")
def suite():
collation_suite = unittest.makeSuite(CollationTests, "Check")
diff --git a/Lib/sqlite3/test/py25tests.py b/Lib/sqlite3/test/py25tests.py
deleted file mode 100644
index 7fd3c0e0cf8..00000000000
--- a/Lib/sqlite3/test/py25tests.py
+++ /dev/null
@@ -1,80 +0,0 @@
-#-*- coding: ISO-8859-1 -*-
-# pysqlite2/test/regression.py: pysqlite regression tests
-#
-# Copyright (C) 2007 Gerhard Häring <gh@ghaering.de>
-#
-# This file is part of pysqlite.
-#
-# This software is provided 'as-is', without any express or implied
-# warranty. In no event will the authors be held liable for any damages
-# arising from the use of this software.
-#
-# Permission is granted to anyone to use this software for any purpose,
-# including commercial applications, and to alter it and redistribute it
-# freely, subject to the following restrictions:
-#
-# 1. The origin of this software must not be misrepresented; you must not
-# claim that you wrote the original software. If you use this software
-# in a product, an acknowledgment in the product documentation would be
-# appreciated but is not required.
-# 2. Altered source versions must be plainly marked as such, and must not be
-# misrepresented as being the original software.
-# 3. This notice may not be removed or altered from any source distribution.
-
-from __future__ import with_statement
-import unittest
-import sqlite3 as sqlite
-
-did_rollback = False
-
-class MyConnection(sqlite.Connection):
- def rollback(self):
- global did_rollback
- did_rollback = True
- sqlite.Connection.rollback(self)
-
-class ContextTests(unittest.TestCase):
- def setUp(self):
- global did_rollback
- self.con = sqlite.connect(":memory:", factory=MyConnection)
- self.con.execute("create table test(c unique)")
- did_rollback = False
-
- def tearDown(self):
- self.con.close()
-
- def CheckContextManager(self):
- """Can the connection be used as a context manager at all?"""
- with self.con:
- pass
-
- def CheckContextManagerCommit(self):
- """Is a commit called in the context manager?"""
- with self.con:
- self.con.execute("insert into test(c) values ('foo')")
- self.con.rollback()
- count = self.con.execute("select count(*) from test").fetchone()[0]
- self.assertEqual(count, 1)
-
- def CheckContextManagerRollback(self):
- """Is a rollback called in the context manager?"""
- global did_rollback
- self.assertEqual(did_rollback, False)
- try:
- with self.con:
- self.con.execute("insert into test(c) values (4)")
- self.con.execute("insert into test(c) values (4)")
- except sqlite.IntegrityError:
- pass
- self.assertEqual(did_rollback, True)
-
-def suite():
- ctx_suite = unittest.makeSuite(ContextTests, "Check")
- return unittest.TestSuite((ctx_suite,))
-
-def test():
- runner = unittest.TextTestRunner()
- runner.run(suite())
-
-if __name__ == "__main__":
- test()
diff --git a/Lib/sqlite3/test/regression.py b/Lib/sqlite3/test/regression.py
index eec2fcde951..c7551e35a1b 100644
--- a/Lib/sqlite3/test/regression.py
+++ b/Lib/sqlite3/test/regression.py
@@ -1,7 +1,7 @@
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/regression.py: pysqlite regression tests
#
-# Copyright (C) 2006-2007 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2006-2010 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -52,10 +52,10 @@ class RegressionTests(unittest.TestCase):
# reset before a rollback, but only those that are still in the
# statement cache. The others are not accessible from the connection object.
con = sqlite.connect(":memory:", cached_statements=5)
- cursors = [con.cursor() for x in xrange(5)]
+ cursors = [con.cursor() for x in range(5)]
cursors[0].execute("create table test(x)")
for i in range(10):
- cursors[0].executemany("insert into test(x) values (?)", [(x,) for x in xrange(10)])
+ cursors[0].executemany("insert into test(x) values (?)", [(x,) for x in range(10)])
for i in range(5):
cursors[i].execute(" " * i + "select x from test")
@@ -116,18 +116,6 @@ class RegressionTests(unittest.TestCase):
"""
self.con.execute("")
- def CheckUnicodeConnect(self):
- """
- With pysqlite 2.4.0 you needed to use a string or a APSW connection
- object for opening database connections.
-
- Formerly, both bytestrings and unicode strings used to work.
-
- Let's make sure unicode strings work in the future.
- """
- con = sqlite.connect(u":memory:")
- con.close()
-
def CheckTypeMapUsage(self):
"""
pysqlite until 2.4.1 did not rebuild the row_cast_map when recompiling
@@ -143,6 +131,21 @@ class RegressionTests(unittest.TestCase):
con.execute("insert into foo(bar) values (5)")
con.execute(SELECT)
+ def CheckErrorMsgDecodeError(self):
+ # When porting the module to Python 3.0, the error message about
+ # decoding errors disappeared. This verifies they're back again.
+ failure = None
+ try:
+ self.con.execute("select 'xxx' || ? || 'yyy' colname",
+ (bytes(bytearray([250])),)).fetchone()
+ failure = "should have raised an OperationalError with detailed description"
+ except sqlite.OperationalError as e:
+ msg = e.args[0]
+ if not msg.startswith("Could not decode to UTF-8 column 'colname' with text 'xxx"):
+ failure = "OperationalError did not have expected description text"
+ if failure:
+ self.fail(failure)
+
def CheckRegisterAdapter(self):
"""
See issue 3312.
@@ -154,8 +157,7 @@ class RegressionTests(unittest.TestCase):
See issue 3312.
"""
con = sqlite.connect(":memory:")
- self.assertRaises(UnicodeEncodeError, setattr, con,
- "isolation_level", u"\xe9")
+ setattr(con, "isolation_level", "\xe9")
def CheckCursorConstructorCallCheck(self):
"""
@@ -175,6 +177,14 @@ class RegressionTests(unittest.TestCase):
except:
self.fail("should have raised ProgrammingError")
+
+ def CheckStrSubclass(self):
+ """
+ The Python 3.0 port of the module didn't cope with values of subclasses of str.
+ """
+ class MyStr(str): pass
+ self.con.execute("select ?", (MyStr("abc"),))
+
def CheckConnectionConstructorCallCheck(self):
"""
Verifies that connection methods check wether base class __init__ was called.
@@ -264,6 +274,13 @@ class RegressionTests(unittest.TestCase):
"""
self.assertRaises(sqlite.Warning, self.con, 1)
+ def CheckCollation(self):
+ def collation_cb(a, b):
+ return 1
+ self.assertRaises(sqlite.ProgrammingError, self.con.create_collation,
+ # Lone surrogate cannot be encoded to the default encoding (utf8)
+ "\uDC80", collation_cb)
+
def CheckRecursiveCursorUse(self):
"""
http://bugs.python.org/issue10811
diff --git a/Lib/sqlite3/test/transactions.py b/Lib/sqlite3/test/transactions.py
index a732251b2d4..70e96a12ed3 100644
--- a/Lib/sqlite3/test/transactions.py
+++ b/Lib/sqlite3/test/transactions.py
@@ -21,7 +21,6 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
-import sys
import os, unittest
import sqlite3 as sqlite
@@ -163,7 +162,7 @@ class TransactionTests(unittest.TestCase):
try:
cur.fetchall()
self.fail("InterfaceError should have been raised")
- except sqlite.InterfaceError, e:
+ except sqlite.InterfaceError as e:
pass
except:
self.fail("InterfaceError should have been raised")
diff --git a/Lib/sqlite3/test/types.py b/Lib/sqlite3/test/types.py
index c5ab39bb771..29413e14ec3 100644
--- a/Lib/sqlite3/test/types.py
+++ b/Lib/sqlite3/test/types.py
@@ -1,7 +1,7 @@
#-*- coding: ISO-8859-1 -*-
# pysqlite2/test/types.py: tests for type conversion and detection
#
-# Copyright (C) 2005-2007 Gerhard Häring <gh@ghaering.de>
+# Copyright (C) 2005 Gerhard Häring <gh@ghaering.de>
#
# This file is part of pysqlite.
#
@@ -41,10 +41,10 @@ class SqliteTypeTests(unittest.TestCase):
self.con.close()
def CheckString(self):
- self.cur.execute("insert into test(s) values (?)", (u"Österreich",))
+ self.cur.execute("insert into test(s) values (?)", ("Österreich",))
self.cur.execute("select s from test")
row = self.cur.fetchone()
- self.assertEqual(row[0], u"Österreich")
+ self.assertEqual(row[0], "Österreich")
def CheckSmallInt(self):
self.cur.execute("insert into test(i) values (?)", (42,))
@@ -67,47 +67,25 @@ class SqliteTypeTests(unittest.TestCase):
self.assertEqual(row[0], val)
def CheckBlob(self):
- val = buffer("Guglhupf")
+ sample = b"Guglhupf"
+ val = memoryview(sample)
self.cur.execute("insert into test(b) values (?)", (val,))
self.cur.execute("select b from test")
row = self.cur.fetchone()
- self.assertEqual(row[0], val)
+ self.assertEqual(row[0], sample)
def CheckUnicodeExecute(self):
- self.cur.execute(u"select 'Österreich'")
+ self.cur.execute("select 'Österreich'")
row = self.cur.fetchone()
- self.assertEqual(row[0], u"Österreich")
-
- def CheckNonUtf8_Default(self):
- try:
- self.cur.execute("select ?", (chr(150),))
- self.fail("should have raised a ProgrammingError")
- except sqlite.ProgrammingError:
- pass
-
- def CheckNonUtf8_TextFactoryString(self):
- orig_text_factory = self.con.text_factory
- try:
- self.con.text_factory = str
- self.cur.execute("select ?", (chr(150),))
- finally:
- self.con.text_factory = orig_text_factory
-
- def CheckNonUtf8_TextFactoryOptimizedUnicode(self):
- orig_text_factory = self.con.text_factory
- try:
- try:
- self.con.text_factory = sqlite.OptimizedUnicode
- self.cur.execute("select ?", (chr(150),))
- self.fail("should have raised a ProgrammingError")
- except sqlite.ProgrammingError:
- pass
- finally:
- self.con.text_factory = orig_text_factory
+ self.assertEqual(row[0], "Österreich")
class DeclTypesTests(unittest.TestCase):
class Foo:
def __init__(self, _val):
+ if isinstance(_val, bytes):
+ # sqlite3 always calls __init__ with a bytes created from a
+ # UTF-8 string when __conform__ was used to store the object.
+ _val = _val.decode('utf8')
self.val = _val
def __cmp__(self, other):
@@ -118,6 +96,12 @@ class DeclTypesTests(unittest.TestCase):
else:
return 1
+ def __eq__(self, other):
+ c = self.__cmp__(other)
+ if c is NotImplemented:
+ return c
+ return c == 0
+
def __conform__(self, protocol):
if protocol is sqlite.PrepareProtocol:
return self.val
@@ -194,7 +178,7 @@ class DeclTypesTests(unittest.TestCase):
def CheckUnicode(self):
# default
- val = u"\xd6sterreich"
+ val = "\xd6sterreich"
self.cur.execute("insert into test(u) values (?)", (val,))
self.cur.execute("select u from test")
row = self.cur.fetchone()
@@ -231,11 +215,12 @@ class DeclTypesTests(unittest.TestCase):
def CheckBlob(self):
# default
- val = buffer("Guglhupf")
+ sample = b"Guglhupf"
+ val = memoryview(sample)
self.cur.execute("insert into test(bin) values (?)", (val,))
self.cur.execute("select bin from test")
row = self.cur.fetchone()
- self.assertEqual(row[0], val)
+ self.assertEqual(row[0], sample)
def CheckNumber1(self):
self.cur.execute("insert into test(n1) values (5)")
@@ -256,9 +241,9 @@ class ColNamesTests(unittest.TestCase):
self.cur = self.con.cursor()
self.cur.execute("create table test(x foo)")
- sqlite.converters["FOO"] = lambda x: "[%s]" % x
- sqlite.converters["BAR"] = lambda x: "<%s>" % x
- sqlite.converters["EXC"] = lambda x: 5 // 0
+ sqlite.converters["FOO"] = lambda x: "[%s]" % x.decode("ascii")
+ sqlite.converters["BAR"] = lambda x: "<%s>" % x.decode("ascii")
+ sqlite.converters["EXC"] = lambda x: 5/0
sqlite.converters["B1B1"] = lambda x: "MARKER"
def tearDown(self):
@@ -296,7 +281,7 @@ class ColNamesTests(unittest.TestCase):
self.assertEqual(self.cur.description[0][0], "x")
def CheckCaseInConverterName(self):
- self.cur.execute("""select 'other' as "x [b1b1]\"""")
+ self.cur.execute("select 'other' as \"x [b1b1]\"")
val = self.cur.fetchone()[0]
self.assertEqual(val, "MARKER")
@@ -346,8 +331,8 @@ class BinaryConverterTests(unittest.TestCase):
self.con.close()
def CheckBinaryInputForConverter(self):
- testdata = "abcdefg" * 10
- result = self.con.execute('select ? as "x [bin]"', (buffer(zlib.compress(testdata)),)).fetchone()[0]
+ testdata = b"abcdefg" * 10
+ result = self.con.execute('select ? as "x [bin]"', (memoryview(zlib.compress(testdata)),)).fetchone()[0]
self.assertEqual(testdata, result)
class DateTimeTests(unittest.TestCase):
diff --git a/Lib/sqlite3/test/userfunctions.py b/Lib/sqlite3/test/userfunctions.py
index 2db3a610b34..e01341e9159 100644
--- a/Lib/sqlite3/test/userfunctions.py
+++ b/Lib/sqlite3/test/userfunctions.py
@@ -28,7 +28,7 @@ import sqlite3 as sqlite
def func_returntext():
return "foo"
def func_returnunicode():
- return u"bar"
+ return "bar"
def func_returnint():
return 42
def func_returnfloat():
@@ -36,14 +36,14 @@ def func_returnfloat():
def func_returnnull():
return None
def func_returnblob():
- return buffer("blob")
+ return b"blob"
def func_returnlonglong():
return 1<<31
def func_raiseexception():
- 5 // 0
+ 5/0
def func_isstring(v):
- return type(v) is unicode
+ return type(v) is str
def func_isint(v):
return type(v) is int
def func_isfloat(v):
@@ -51,9 +51,9 @@ def func_isfloat(v):
def func_isnone(v):
return type(v) is type(None)
def func_isblob(v):
- return type(v) is buffer
+ return isinstance(v, (bytes, memoryview))
def func_islonglong(v):
- return isinstance(v, (int, long)) and v >= 1<<31
+ return isinstance(v, int) and v >= 1<<31
class AggrNoStep:
def __init__(self):
@@ -71,7 +71,7 @@ class AggrNoFinalize:
class AggrExceptionInInit:
def __init__(self):
- 5 // 0
+ 5/0
def step(self, x):
pass
@@ -84,7 +84,7 @@ class AggrExceptionInStep:
pass
def step(self, x):
- 5 // 0
+ 5/0
def finalize(self):
return 42
@@ -97,14 +97,15 @@ class AggrExceptionInFinalize:
pass
def finalize(self):
- 5 // 0
+ 5/0
class AggrCheckType:
def __init__(self):
self.val = None
def step(self, whichType, val):
- theType = {"str": unicode, "int": int, "float": float, "None": type(None), "blob": buffer}
+ theType = {"str": str, "int": int, "float": float, "None": type(None),
+ "blob": bytes}
self.val = int(theType[whichType] is type(val))
def finalize(self):
@@ -166,15 +167,15 @@ class FunctionTests(unittest.TestCase):
cur = self.con.cursor()
cur.execute("select returntext()")
val = cur.fetchone()[0]
- self.assertEqual(type(val), unicode)
+ self.assertEqual(type(val), str)
self.assertEqual(val, "foo")
def CheckFuncReturnUnicode(self):
cur = self.con.cursor()
cur.execute("select returnunicode()")
val = cur.fetchone()[0]
- self.assertEqual(type(val), unicode)
- self.assertEqual(val, u"bar")
+ self.assertEqual(type(val), str)
+ self.assertEqual(val, "bar")
def CheckFuncReturnInt(self):
cur = self.con.cursor()
@@ -202,8 +203,8 @@ class FunctionTests(unittest.TestCase):
cur = self.con.cursor()
cur.execute("select returnblob()")
val = cur.fetchone()[0]
- self.assertEqual(type(val), buffer)
- self.assertEqual(val, buffer("blob"))
+ self.assertEqual(type(val), bytes)
+ self.assertEqual(val, b"blob")
def CheckFuncReturnLongLong(self):
cur = self.con.cursor()
@@ -217,7 +218,7 @@ class FunctionTests(unittest.TestCase):
cur.execute("select raiseexception()")
cur.fetchone()
self.fail("should have raised OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0], 'user-defined function raised exception')
def CheckParamString(self):
@@ -246,7 +247,7 @@ class FunctionTests(unittest.TestCase):
def CheckParamBlob(self):
cur = self.con.cursor()
- cur.execute("select isblob(?)", (buffer("blob"),))
+ cur.execute("select isblob(?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
@@ -270,7 +271,7 @@ class AggregateTests(unittest.TestCase):
)
""")
cur.execute("insert into test(t, i, f, n, b) values (?, ?, ?, ?, ?)",
- ("foo", 5, 3.14, None, buffer("blob"),))
+ ("foo", 5, 3.14, None, memoryview(b"blob"),))
self.con.create_aggregate("nostep", 1, AggrNoStep)
self.con.create_aggregate("nofinalize", 1, AggrNoFinalize)
@@ -297,8 +298,8 @@ class AggregateTests(unittest.TestCase):
try:
cur.execute("select nostep(t) from test")
self.fail("should have raised an AttributeError")
- except AttributeError, e:
- self.assertEqual(e.args[0], "AggrNoStep instance has no attribute 'step'")
+ except AttributeError as e:
+ self.assertEqual(e.args[0], "'AggrNoStep' object has no attribute 'step'")
def CheckAggrNoFinalize(self):
cur = self.con.cursor()
@@ -306,7 +307,7 @@ class AggregateTests(unittest.TestCase):
cur.execute("select nofinalize(t) from test")
val = cur.fetchone()[0]
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
def CheckAggrExceptionInInit(self):
@@ -315,7 +316,7 @@ class AggregateTests(unittest.TestCase):
cur.execute("select excInit(t) from test")
val = cur.fetchone()[0]
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0], "user-defined aggregate's '__init__' method raised error")
def CheckAggrExceptionInStep(self):
@@ -324,7 +325,7 @@ class AggregateTests(unittest.TestCase):
cur.execute("select excStep(t) from test")
val = cur.fetchone()[0]
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0], "user-defined aggregate's 'step' method raised error")
def CheckAggrExceptionInFinalize(self):
@@ -333,7 +334,7 @@ class AggregateTests(unittest.TestCase):
cur.execute("select excFinalize(t) from test")
val = cur.fetchone()[0]
self.fail("should have raised an OperationalError")
- except sqlite.OperationalError, e:
+ except sqlite.OperationalError as e:
self.assertEqual(e.args[0], "user-defined aggregate's 'finalize' method raised error")
def CheckAggrCheckParamStr(self):
@@ -362,7 +363,7 @@ class AggregateTests(unittest.TestCase):
def CheckAggrCheckParamBlob(self):
cur = self.con.cursor()
- cur.execute("select checkType('blob', ?)", (buffer("blob"),))
+ cur.execute("select checkType('blob', ?)", (memoryview(b"blob"),))
val = cur.fetchone()[0]
self.assertEqual(val, 1)
@@ -402,7 +403,7 @@ class AuthorizerTests(unittest.TestCase):
def CheckTableAccess(self):
try:
self.con.execute("select * from t2")
- except sqlite.DatabaseError, e:
+ except sqlite.DatabaseError as e:
if not e.args[0].endswith("prohibited"):
self.fail("wrong exception text: %s" % e.args[0])
return
@@ -411,7 +412,7 @@ class AuthorizerTests(unittest.TestCase):
def CheckColumnAccess(self):
try:
self.con.execute("select c2 from t1")
- except sqlite.DatabaseError, e:
+ except sqlite.DatabaseError as e:
if not e.args[0].endswith("prohibited"):
self.fail("wrong exception text: %s" % e.args[0])
return
diff --git a/Lib/sre.py b/Lib/sre.py
deleted file mode 100644
index c04576bafa5..00000000000
--- a/Lib/sre.py
+++ /dev/null
@@ -1,13 +0,0 @@
-"""This file is only retained for backwards compatibility.
-It will be removed in the future. sre was moved to re in version 2.5.
-"""
-
-import warnings
-warnings.warn("The sre module is deprecated, please import re.",
- DeprecationWarning, 2)
-
-from re import *
-from re import __all__
-
-# old pickles expect the _compile() reconstructor in this module
-from re import _compile
diff --git a/Lib/sre_compile.py b/Lib/sre_compile.py
index 2a0c745a5d3..f52ea014597 100644
--- a/Lib/sre_compile.py
+++ b/Lib/sre_compile.py
@@ -19,7 +19,7 @@ assert _sre.MAGIC == MAGIC, "SRE module mismatch"
if _sre.CODESIZE == 2:
MAXCODE = 65535
else:
- MAXCODE = 0xFFFFFFFFL
+ MAXCODE = 0xFFFFFFFF
def _identityfunction(x):
return x
@@ -63,7 +63,7 @@ def _compile(code, pattern, flags):
emit(OPCODES[ANY])
elif op in REPEATING_CODES:
if flags & SRE_FLAG_TEMPLATE:
- raise error, "internal: unsupported template operator"
+ raise error("internal: unsupported template operator")
emit(OPCODES[REPEAT])
skip = _len(code); emit(0)
emit(av[0])
@@ -112,7 +112,7 @@ def _compile(code, pattern, flags):
else:
lo, hi = av[1].getwidth()
if lo != hi:
- raise error, "look-behind requires fixed-width pattern"
+ raise error("look-behind requires fixed-width pattern")
emit(lo) # look behind
_compile(code, av[1], flags)
emit(OPCODES[SUCCESS])
@@ -173,7 +173,7 @@ def _compile(code, pattern, flags):
else:
code[skipyes] = _len(code) - skipyes + 1
else:
- raise ValueError, ("unsupported operand type", op)
+ raise ValueError("unsupported operand type", op)
def _compile_charset(charset, flags, code, fixup=None):
# compile charset subprogram
@@ -201,7 +201,7 @@ def _compile_charset(charset, flags, code, fixup=None):
else:
emit(CHCODES[av])
else:
- raise error, "internal: unsupported set operator"
+ raise error("internal: unsupported set operator")
emit(OPCODES[FAILURE])
def _optimize_charset(charset, fixup):
@@ -261,7 +261,7 @@ def _mk_bitmap(bits):
if _sre.CODESIZE == 2:
start = (1, 0)
else:
- start = (1L, 0L)
+ start = (1, 0)
m, v = start
for c in bits:
if c:
@@ -312,7 +312,7 @@ def _optimize_unicode(charset, fixup):
elif op is LITERAL:
charmap[fixup(av)] = 1
elif op is RANGE:
- for i in xrange(fixup(av[0]), fixup(av[1])+1):
+ for i in range(fixup(av[0]), fixup(av[1])+1):
charmap[i] = 1
elif op is CATEGORY:
# XXX: could expand category
@@ -324,13 +324,13 @@ def _optimize_unicode(charset, fixup):
if sys.maxunicode != 65535:
# XXX: negation does not work with big charsets
return charset
- for i in xrange(65536):
+ for i in range(65536):
charmap[i] = not charmap[i]
comps = {}
mapping = [0]*256
block = 0
data = []
- for i in xrange(256):
+ for i in range(256):
chunk = tuple(charmap[i*256:(i+1)*256])
new = comps.setdefault(chunk, block)
mapping[i] = new
@@ -343,10 +343,11 @@ def _optimize_unicode(charset, fixup):
else:
code = 'I'
# Convert block indices to byte array of 256 bytes
- mapping = array.array('b', mapping).tostring()
+ mapping = array.array('b', mapping).tobytes()
# Convert byte array to word array
mapping = array.array(code, mapping)
assert mapping.itemsize == _sre.CODESIZE
+ assert len(mapping) * mapping.itemsize == 256
header = header + mapping.tolist()
data[0:0] = header
return [(BIGCHARSET, data)]
@@ -355,7 +356,7 @@ def _simple(av):
# check if av is a "simple" operator
lo, hi = av[2].getwidth()
if lo == 0 and hi == MAXREPEAT:
- raise error, "nothing to repeat"
+ raise error("nothing to repeat")
return lo == hi == 1 and av[2][0][0] != SUBPATTERN
def _compile_info(code, pattern, flags):
@@ -455,7 +456,7 @@ def _compile_info(code, pattern, flags):
code.extend(prefix)
# generate overlap table
table = [-1] + ([0]*len(prefix))
- for i in xrange(len(prefix)):
+ for i in range(len(prefix)):
table[i+1] = table[i]+1
while table[i+1] > 0 and prefix[i] != prefix[table[i+1]-1]:
table[i+1] = table[table[i+1]-1]+1
@@ -464,18 +465,8 @@ def _compile_info(code, pattern, flags):
_compile_charset(charset, flags, code)
code[skip] = len(code) - skip
-try:
- unicode
-except NameError:
- STRING_TYPES = (type(""),)
-else:
- STRING_TYPES = (type(""), type(unicode("")))
-
def isstring(obj):
- for tp in STRING_TYPES:
- if isinstance(obj, tp):
- return 1
- return 0
+ return isinstance(obj, (str, bytes))
def _code(p, flags):
diff --git a/Lib/sre_constants.py b/Lib/sre_constants.py
index 1863f48bb16..6cf69c321b8 100644
--- a/Lib/sre_constants.py
+++ b/Lib/sre_constants.py
@@ -207,9 +207,10 @@ SRE_FLAG_IGNORECASE = 2 # case insensitive
SRE_FLAG_LOCALE = 4 # honour system locale
SRE_FLAG_MULTILINE = 8 # treat target as multiline string
SRE_FLAG_DOTALL = 16 # treat target as a single string
-SRE_FLAG_UNICODE = 32 # use unicode locale
+SRE_FLAG_UNICODE = 32 # use unicode "locale"
SRE_FLAG_VERBOSE = 64 # ignore whitespace and comments
SRE_FLAG_DEBUG = 128 # debugging
+SRE_FLAG_ASCII = 256 # use ascii "locale"
# flags for INFO primitive
SRE_INFO_PREFIX = 1 # has prefix
@@ -258,4 +259,4 @@ if __name__ == "__main__":
f.write("#define SRE_INFO_CHARSET %d\n" % SRE_INFO_CHARSET)
f.close()
- print "done"
+ print("done")
diff --git a/Lib/sre_parse.py b/Lib/sre_parse.py
index 7149dca491b..9aea56a825b 100644
--- a/Lib/sre_parse.py
+++ b/Lib/sre_parse.py
@@ -58,6 +58,7 @@ FLAGS = {
"s": SRE_FLAG_DOTALL,
"x": SRE_FLAG_VERBOSE,
# extensions
+ "a": SRE_FLAG_ASCII,
"t": SRE_FLAG_TEMPLATE,
"u": SRE_FLAG_UNICODE,
}
@@ -75,8 +76,8 @@ class Pattern:
if name is not None:
ogid = self.groupdict.get(name, None)
if ogid is not None:
- raise error, ("redefinition of group name %s as group %d; "
- "was group %d" % (repr(name), gid, ogid))
+ raise error("redefinition of group name %s as group %d; "
+ "was group %d" % (repr(name), gid, ogid))
self.groupdict[name] = gid
self.open.append(gid)
return gid
@@ -95,32 +96,32 @@ class SubPattern:
self.width = None
def dump(self, level=0):
nl = 1
- seqtypes = type(()), type([])
+ seqtypes = (tuple, list)
for op, av in self.data:
- print level*" " + op,; nl = 0
+ print(level*" " + op, end=' '); nl = 0
if op == "in":
# member sublanguage
- print; nl = 1
+ print(); nl = 1
for op, a in av:
- print (level+1)*" " + op, a
+ print((level+1)*" " + op, a)
elif op == "branch":
- print; nl = 1
+ print(); nl = 1
i = 0
for a in av[1]:
if i > 0:
- print level*" " + "or"
+ print(level*" " + "or")
a.dump(level+1); nl = 1
i = i + 1
- elif type(av) in seqtypes:
+ elif isinstance(av, seqtypes):
for a in av:
if isinstance(a, SubPattern):
- if not nl: print
+ if not nl: print()
a.dump(level+1); nl = 1
else:
- print a, ; nl = 0
+ print(a, end=' ') ; nl = 0
else:
- print av, ; nl = 0
- if not nl: print
+ print(av, end=' ') ; nl = 0
+ if not nl: print()
def __repr__(self):
return repr(self.data)
def __len__(self):
@@ -141,12 +142,12 @@ class SubPattern:
# determine the width (min, max) for this subpattern
if self.width:
return self.width
- lo = hi = 0L
+ lo = hi = 0
UNITCODES = (ANY, RANGE, IN, LITERAL, NOT_LITERAL, CATEGORY)
REPEATCODES = (MIN_REPEAT, MAX_REPEAT)
for op, av in self.data:
if op is BRANCH:
- i = sys.maxint
+ i = sys.maxsize
j = 0
for av in av[1]:
l, h = av.getwidth()
@@ -164,14 +165,14 @@ class SubPattern:
hi = hi + j
elif op in REPEATCODES:
i, j = av[2].getwidth()
- lo = lo + long(i) * av[0]
- hi = hi + long(j) * av[1]
+ lo = lo + int(i) * av[0]
+ hi = hi + int(j) * av[1]
elif op in UNITCODES:
lo = lo + 1
hi = hi + 1
elif op == SUCCESS:
break
- self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint))
+ self.width = int(min(lo, sys.maxsize)), int(min(hi, sys.maxsize))
return self.width
class Tokenizer:
@@ -183,12 +184,18 @@ class Tokenizer:
if self.index >= len(self.string):
self.next = None
return
- char = self.string[self.index]
- if char[0] == "\\":
+ char = self.string[self.index:self.index+1]
+ # Special case for the str8, since indexing returns a integer
+ # XXX This is only needed for test_bug_926075 in test_re.py
+ if char and isinstance(char, bytes):
+ char = chr(char[0])
+ if char == "\\":
try:
c = self.string[self.index + 1]
except IndexError:
- raise error, "bogus escape (end of line)"
+ raise error("bogus escape (end of line)")
+ if isinstance(self.string, bytes):
+ c = chr(c)
char = char + c
self.index = self.index + len(char)
self.next = char
@@ -238,7 +245,7 @@ def _class_escape(source, escape):
escape = escape + source.get()
escape = escape[2:]
if len(escape) != 2:
- raise error, "bogus escape: %s" % repr("\\" + escape)
+ raise error("bogus escape: %s" % repr("\\" + escape))
return LITERAL, int(escape, 16) & 0xff
elif c in OCTDIGITS:
# octal escape (up to three digits)
@@ -247,12 +254,12 @@ def _class_escape(source, escape):
escape = escape[1:]
return LITERAL, int(escape, 8) & 0xff
elif c in DIGITS:
- raise error, "bogus escape: %s" % repr(escape)
+ raise error("bogus escape: %s" % repr(escape))
if len(escape) == 2:
return LITERAL, ord(escape[1])
except ValueError:
pass
- raise error, "bogus escape: %s" % repr(escape)
+ raise error("bogus escape: %s" % repr(escape))
def _escape(source, escape, state):
# handle escape code in expression
@@ -289,14 +296,14 @@ def _escape(source, escape, state):
group = int(escape[1:])
if group < state.groups:
if not state.checkgroup(group):
- raise error, "cannot refer to open group"
+ raise error("cannot refer to open group")
return GROUPREF, group
raise ValueError
if len(escape) == 2:
return LITERAL, ord(escape[1])
except ValueError:
pass
- raise error, "bogus escape: %s" % repr(escape)
+ raise error("bogus escape: %s" % repr(escape))
def _parse_sub(source, state, nested=1):
# parse an alternation: a|b|c
@@ -313,7 +320,7 @@ def _parse_sub(source, state, nested=1):
if not source.next or sourcematch(")", 0):
break
else:
- raise error, "pattern not properly closed"
+ raise error("pattern not properly closed")
if len(items) == 1:
return items[0]
@@ -362,11 +369,11 @@ def _parse_sub_cond(source, state, condgroup):
if source.match("|"):
item_no = _parse(source, state)
if source.match("|"):
- raise error, "conditional backref with more than two branches"
+ raise error("conditional backref with more than two branches")
else:
item_no = None
if source.next and not source.match(")", 0):
- raise error, "pattern not properly closed"
+ raise error("pattern not properly closed")
subpattern = SubPattern(state)
subpattern.append((GROUPREF_EXISTS, (condgroup, item_yes, item_no)))
return subpattern
@@ -431,7 +438,7 @@ def _parse(source, state):
elif this:
code1 = LITERAL, ord(this)
else:
- raise error, "unexpected end of regular expression"
+ raise error("unexpected end of regular expression")
if sourcematch("-"):
# potential range
this = sourceget()
@@ -447,14 +454,14 @@ def _parse(source, state):
else:
code2 = LITERAL, ord(this)
if code1[0] != LITERAL or code2[0] != LITERAL:
- raise error, "bad character range"
+ raise error("bad character range")
lo = code1[1]
hi = code2[1]
if hi < lo:
- raise error, "bad character range"
+ raise error("bad character range")
setappend((RANGE, (lo, hi)))
else:
- raise error, "unexpected end of regular expression"
+ raise error("unexpected end of regular expression")
else:
if code1[0] is IN:
code1 = code1[1][0]
@@ -501,18 +508,18 @@ def _parse(source, state):
if hi:
max = int(hi)
if max < min:
- raise error, "bad repeat interval"
+ raise error("bad repeat interval")
else:
- raise error, "not supported"
+ raise error("not supported")
# figure out which item to repeat
if subpattern:
item = subpattern[-1:]
else:
item = None
if not item or (_len(item) == 1 and item[0][0] == AT):
- raise error, "nothing to repeat"
+ raise error("nothing to repeat")
if item[0][0] in REPEATCODES:
- raise error, "multiple repeat"
+ raise error("multiple repeat")
if sourcematch("?"):
subpattern[-1] = (MIN_REPEAT, (min, max, item))
else:
@@ -536,7 +543,7 @@ def _parse(source, state):
while 1:
char = sourceget()
if char is None:
- raise error, "unterminated name"
+ raise error("unterminated name")
if char == ">":
break
name = name + char
@@ -544,31 +551,31 @@ def _parse(source, state):
if not name:
raise error("missing group name")
if not isname(name):
- raise error, "bad character in group name"
+ raise error("bad character in group name")
elif sourcematch("="):
# named backreference
name = ""
while 1:
char = sourceget()
if char is None:
- raise error, "unterminated name"
+ raise error("unterminated name")
if char == ")":
break
name = name + char
if not name:
raise error("missing group name")
if not isname(name):
- raise error, "bad character in group name"
+ raise error("bad character in group name")
gid = state.groupdict.get(name)
if gid is None:
- raise error, "unknown group name"
+ raise error("unknown group name")
subpatternappend((GROUPREF, gid))
continue
else:
char = sourceget()
if char is None:
- raise error, "unexpected end of pattern"
- raise error, "unknown specifier: ?P%s" % char
+ raise error("unexpected end of pattern")
+ raise error("unknown specifier: ?P%s" % char)
elif sourcematch(":"):
# non-capturing group
group = 2
@@ -579,7 +586,7 @@ def _parse(source, state):
break
sourceget()
if not sourcematch(")"):
- raise error, "unbalanced parenthesis"
+ raise error("unbalanced parenthesis")
continue
elif source.next in ASSERTCHARS:
# lookahead assertions
@@ -587,12 +594,12 @@ def _parse(source, state):
dir = 1
if char == "<":
if source.next not in LOOKBEHINDASSERTCHARS:
- raise error, "syntax error"
+ raise error("syntax error")
dir = -1 # lookbehind
char = sourceget()
p = _parse_sub(source, state)
if not sourcematch(")"):
- raise error, "unbalanced parenthesis"
+ raise error("unbalanced parenthesis")
if char == "=":
subpatternappend((ASSERT, (dir, p)))
else:
@@ -604,7 +611,7 @@ def _parse(source, state):
while 1:
char = sourceget()
if char is None:
- raise error, "unterminated name"
+ raise error("unterminated name")
if char == ")":
break
condname = condname + char
@@ -614,16 +621,16 @@ def _parse(source, state):
if isname(condname):
condgroup = state.groupdict.get(condname)
if condgroup is None:
- raise error, "unknown group name"
+ raise error("unknown group name")
else:
try:
condgroup = int(condname)
except ValueError:
- raise error, "bad character in group name"
+ raise error("bad character in group name")
else:
# flags
if not source.next in FLAGS:
- raise error, "unexpected end of pattern"
+ raise error("unexpected end of pattern")
while source.next in FLAGS:
state.flags = state.flags | FLAGS[sourceget()]
if group:
@@ -638,7 +645,7 @@ def _parse(source, state):
else:
p = _parse_sub(source, state)
if not sourcematch(")"):
- raise error, "unbalanced parenthesis"
+ raise error("unbalanced parenthesis")
if group is not None:
state.closegroup(group)
subpatternappend((SUBPATTERN, (group, p)))
@@ -646,10 +653,10 @@ def _parse(source, state):
while 1:
char = sourceget()
if char is None:
- raise error, "unexpected end of pattern"
+ raise error("unexpected end of pattern")
if char == ")":
break
- raise error, "unknown extension"
+ raise error("unknown extension")
elif this == "^":
subpatternappend((AT, AT_BEGINNING))
@@ -662,10 +669,22 @@ def _parse(source, state):
subpatternappend(code)
else:
- raise error, "parser error"
+ raise error("parser error")
return subpattern
+def fix_flags(src, flags):
+ # Check and fix flags according to the type of pattern (str or bytes)
+ if isinstance(src, str):
+ if not flags & SRE_FLAG_ASCII:
+ flags |= SRE_FLAG_UNICODE
+ elif flags & SRE_FLAG_UNICODE:
+ raise ValueError("ASCII and UNICODE flags are incompatible")
+ else:
+ if flags & SRE_FLAG_UNICODE:
+ raise ValueError("can't use UNICODE flag with a bytes pattern")
+ return flags
+
def parse(str, flags=0, pattern=None):
# parse 're' pattern into list of (opcode, argument) tuples
@@ -677,12 +696,13 @@ def parse(str, flags=0, pattern=None):
pattern.str = str
p = _parse_sub(source, pattern, 0)
+ p.pattern.flags = fix_flags(str, p.pattern.flags)
tail = source.get()
if tail == ")":
- raise error, "unbalanced parenthesis"
+ raise error("unbalanced parenthesis")
elif tail:
- raise error, "bogus characters at end of regular expression"
+ raise error("bogus characters at end of regular expression")
if flags & SRE_FLAG_DEBUG:
p.dump()
@@ -707,10 +727,10 @@ def parse_template(source, pattern):
else:
pappend((LITERAL, literal))
sep = source[:0]
- if type(sep) is type(""):
+ if isinstance(sep, str):
makechar = chr
else:
- makechar = unichr
+ makechar = chr
while 1:
this = sget()
if this is None:
@@ -724,23 +744,23 @@ def parse_template(source, pattern):
while 1:
char = sget()
if char is None:
- raise error, "unterminated group name"
+ raise error("unterminated group name")
if char == ">":
break
name = name + char
if not name:
- raise error, "missing group name"
+ raise error("missing group name")
try:
index = int(name)
if index < 0:
- raise error, "negative group number"
+ raise error("negative group number")
except ValueError:
if not isname(name):
- raise error, "bad character in group name"
+ raise error("bad character in group name")
try:
index = pattern.groupindex[name]
except KeyError:
- raise IndexError, "unknown group name"
+ raise IndexError("unknown group name")
a((MARK, index))
elif c == "0":
if s.next in OCTDIGITS:
@@ -772,12 +792,18 @@ def parse_template(source, pattern):
groups = []
groupsappend = groups.append
literals = [None] * len(p)
+ if isinstance(source, str):
+ encode = lambda x: x
+ else:
+ # The tokenizer implicitly decodes bytes objects as latin-1, we must
+ # therefore re-encode the final representation.
+ encode = lambda x: x.encode('latin1')
for c, s in p:
if c is MARK:
groupsappend((i, s))
# literal[i] is already None
else:
- literals[i] = s
+ literals[i] = encode(s)
i = i + 1
return groups, literals
@@ -790,7 +816,7 @@ def expand_template(template, match):
for index, group in groups:
literals[index] = s = g(group)
if s is None:
- raise error, "unmatched group"
+ raise error("unmatched group")
except IndexError:
- raise error, "invalid group reference"
+ raise error("invalid group reference")
return sep.join(literals)
diff --git a/Lib/ssl.py b/Lib/ssl.py
index 88296358a02..e901b640a62 100644
--- a/Lib/ssl.py
+++ b/Lib/ssl.py
@@ -1,8 +1,7 @@
# Wrapper module for _ssl, providing some additional facilities
# implemented in Python. Written by Bill Janssen.
-"""\
-This module provides some more Pythonic support for SSL.
+"""This module provides some more Pythonic support for SSL.
Object types:
@@ -56,24 +55,30 @@ PROTOCOL_TLSv1
"""
import textwrap
+import re
import _ssl # if we can't import it, let the error propagate
from _ssl import OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_INFO, OPENSSL_VERSION
-from _ssl import SSLError
+from _ssl import _SSLContext, SSLError
from _ssl import CERT_NONE, CERT_OPTIONAL, CERT_REQUIRED
+from _ssl import OP_ALL, OP_NO_SSLv2, OP_NO_SSLv3, OP_NO_TLSv1
from _ssl import RAND_status, RAND_egd, RAND_add
-from _ssl import \
- SSL_ERROR_ZERO_RETURN, \
- SSL_ERROR_WANT_READ, \
- SSL_ERROR_WANT_WRITE, \
- SSL_ERROR_WANT_X509_LOOKUP, \
- SSL_ERROR_SYSCALL, \
- SSL_ERROR_SSL, \
- SSL_ERROR_WANT_CONNECT, \
- SSL_ERROR_EOF, \
- SSL_ERROR_INVALID_ERROR_CODE
+from _ssl import (
+ SSL_ERROR_ZERO_RETURN,
+ SSL_ERROR_WANT_READ,
+ SSL_ERROR_WANT_WRITE,
+ SSL_ERROR_WANT_X509_LOOKUP,
+ SSL_ERROR_SYSCALL,
+ SSL_ERROR_SSL,
+ SSL_ERROR_WANT_CONNECT,
+ SSL_ERROR_EOF,
+ SSL_ERROR_INVALID_ERROR_CODE,
+ )
+from _ssl import HAS_SNI
from _ssl import PROTOCOL_SSLv3, PROTOCOL_SSLv23, PROTOCOL_TLSv1
+from _ssl import _OPENSSL_API_VERSION
+
_PROTOCOL_NAMES = {
PROTOCOL_TLSv1: "TLSv1",
PROTOCOL_SSLv23: "SSLv23",
@@ -87,9 +92,11 @@ except ImportError:
else:
_PROTOCOL_NAMES[PROTOCOL_SSLv2] = "SSLv2"
-from socket import socket, _fileobject, _delegate_methods, error as socket_error
from socket import getnameinfo as _getnameinfo
+from socket import error as socket_error
+from socket import socket, AF_INET, SOCK_STREAM
import base64 # for DER-to-PEM translation
+import traceback
import errno
# Disable weak or insecure ciphers by default
@@ -97,97 +104,230 @@ import errno
_DEFAULT_CIPHERS = 'DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2'
-class SSLSocket(socket):
+class CertificateError(ValueError):
+ pass
+
+
+def _dnsname_to_pat(dn):
+ pats = []
+ for frag in dn.split(r'.'):
+ if frag == '*':
+ # When '*' is a fragment by itself, it matches a non-empty dotless
+ # fragment.
+ pats.append('[^.]+')
+ else:
+ # Otherwise, '*' matches any dotless fragment.
+ frag = re.escape(frag)
+ pats.append(frag.replace(r'\*', '[^.]*'))
+ return re.compile(r'\A' + r'\.'.join(pats) + r'\Z', re.IGNORECASE)
+
+
+def match_hostname(cert, hostname):
+ """Verify that *cert* (in decoded format as returned by
+ SSLSocket.getpeercert()) matches the *hostname*. RFC 2818 rules
+ are mostly followed, but IP addresses are not accepted for *hostname*.
+
+ CertificateError is raised on failure. On success, the function
+ returns nothing.
+ """
+ if not cert:
+ raise ValueError("empty or no certificate")
+ dnsnames = []
+ san = cert.get('subjectAltName', ())
+ for key, value in san:
+ if key == 'DNS':
+ if _dnsname_to_pat(value).match(hostname):
+ return
+ dnsnames.append(value)
+ if not dnsnames:
+ # The subject is only checked when there is no dNSName entry
+ # in subjectAltName
+ for sub in cert.get('subject', ()):
+ for key, value in sub:
+ # XXX according to RFC 2818, the most specific Common Name
+ # must be used.
+ if key == 'commonName':
+ if _dnsname_to_pat(value).match(hostname):
+ return
+ dnsnames.append(value)
+ if len(dnsnames) > 1:
+ raise CertificateError("hostname %r "
+ "doesn't match either of %s"
+ % (hostname, ', '.join(map(repr, dnsnames))))
+ elif len(dnsnames) == 1:
+ raise CertificateError("hostname %r "
+ "doesn't match %r"
+ % (hostname, dnsnames[0]))
+ else:
+ raise CertificateError("no appropriate commonName or "
+ "subjectAltName fields were found")
+
+
+class SSLContext(_SSLContext):
+ """An SSLContext holds various SSL-related configuration options and
+ data, such as certificates and possibly a private key."""
+
+ __slots__ = ('protocol',)
+ def __new__(cls, protocol, *args, **kwargs):
+ self = _SSLContext.__new__(cls, protocol)
+ if protocol != _SSLv2_IF_EXISTS:
+ self.set_ciphers(_DEFAULT_CIPHERS)
+ return self
+
+ def __init__(self, protocol):
+ self.protocol = protocol
+
+ def wrap_socket(self, sock, server_side=False,
+ do_handshake_on_connect=True,
+ suppress_ragged_eofs=True,
+ server_hostname=None):
+ return SSLSocket(sock=sock, server_side=server_side,
+ do_handshake_on_connect=do_handshake_on_connect,
+ suppress_ragged_eofs=suppress_ragged_eofs,
+ server_hostname=server_hostname,
+ _context=self)
+
+
+class SSLSocket(socket):
"""This class implements a subtype of socket.socket that wraps
the underlying OS socket in an SSL context when necessary, and
provides read and write methods over that channel."""
- def __init__(self, sock, keyfile=None, certfile=None,
+ def __init__(self, sock=None, keyfile=None, certfile=None,
server_side=False, cert_reqs=CERT_NONE,
ssl_version=PROTOCOL_SSLv23, ca_certs=None,
do_handshake_on_connect=True,
- suppress_ragged_eofs=True, ciphers=None):
- socket.__init__(self, _sock=sock._sock)
- # The initializer for socket overrides the methods send(), recv(), etc.
- # in the instancce, which we don't need -- but we want to provide the
- # methods defined in SSLSocket.
- for attr in _delegate_methods:
- try:
- delattr(self, attr)
- except AttributeError:
- pass
+ family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None,
+ suppress_ragged_eofs=True, ciphers=None,
+ server_hostname=None,
+ _context=None):
- if ciphers is None and ssl_version != _SSLv2_IF_EXISTS:
- ciphers = _DEFAULT_CIPHERS
-
- if certfile and not keyfile:
- keyfile = certfile
- # see if it's connected
- try:
- socket.getpeername(self)
- except socket_error, e:
- if e.errno != errno.ENOTCONN:
- raise
- # no, no connection yet
- self._connected = False
- self._sslobj = None
+ if _context:
+ self.context = _context
else:
- # yes, create the SSL object
- self._connected = True
- self._sslobj = _ssl.sslwrap(self._sock, server_side,
- keyfile, certfile,
- cert_reqs, ssl_version, ca_certs,
- ciphers)
- if do_handshake_on_connect:
- self.do_handshake()
- self.keyfile = keyfile
- self.certfile = certfile
- self.cert_reqs = cert_reqs
- self.ssl_version = ssl_version
- self.ca_certs = ca_certs
- self.ciphers = ciphers
+ if server_side and not certfile:
+ raise ValueError("certfile must be specified for server-side "
+ "operations")
+ if keyfile and not certfile:
+ raise ValueError("certfile must be specified")
+ if certfile and not keyfile:
+ keyfile = certfile
+ self.context = SSLContext(ssl_version)
+ self.context.verify_mode = cert_reqs
+ if ca_certs:
+ self.context.load_verify_locations(ca_certs)
+ if certfile:
+ self.context.load_cert_chain(certfile, keyfile)
+ if ciphers:
+ self.context.set_ciphers(ciphers)
+ self.keyfile = keyfile
+ self.certfile = certfile
+ self.cert_reqs = cert_reqs
+ self.ssl_version = ssl_version
+ self.ca_certs = ca_certs
+ self.ciphers = ciphers
+ if server_side and server_hostname:
+ raise ValueError("server_hostname can only be specified "
+ "in client mode")
+ self.server_side = server_side
+ self.server_hostname = server_hostname
self.do_handshake_on_connect = do_handshake_on_connect
self.suppress_ragged_eofs = suppress_ragged_eofs
- self._makefile_refs = 0
+ connected = False
+ if sock is not None:
+ socket.__init__(self,
+ family=sock.family,
+ type=sock.type,
+ proto=sock.proto,
+ fileno=sock.fileno())
+ self.settimeout(sock.gettimeout())
+ # see if it's connected
+ try:
+ sock.getpeername()
+ except socket_error as e:
+ if e.errno != errno.ENOTCONN:
+ raise
+ else:
+ connected = True
+ sock.detach()
+ elif fileno is not None:
+ socket.__init__(self, fileno=fileno)
+ else:
+ socket.__init__(self, family=family, type=type, proto=proto)
+
+ self._closed = False
+ self._sslobj = None
+ self._connected = connected
+ if connected:
+ # create the SSL object
+ try:
+ self._sslobj = self.context._wrap_socket(self, server_side,
+ server_hostname)
+ if do_handshake_on_connect:
+ timeout = self.gettimeout()
+ if timeout == 0.0:
+ # non-blocking
+ raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets")
+ self.do_handshake()
- def read(self, len=1024):
+ except socket_error as x:
+ self.close()
+ raise x
+ def dup(self):
+ raise NotImplemented("Can't dup() %s instances" %
+ self.__class__.__name__)
+
+ def _checkClosed(self, msg=None):
+ # raise an exception here if you wish to check for spurious closes
+ pass
+
+ def read(self, len=0, buffer=None):
"""Read up to LEN bytes and return them.
Return zero-length string on EOF."""
+ self._checkClosed()
try:
- return self._sslobj.read(len)
- except SSLError, x:
+ if buffer is not None:
+ v = self._sslobj.read(len, buffer)
+ else:
+ v = self._sslobj.read(len or 1024)
+ return v
+ except SSLError as x:
if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs:
- return ''
+ if buffer is not None:
+ return 0
+ else:
+ return b''
else:
raise
def write(self, data):
-
"""Write DATA to the underlying SSL channel. Returns
number of bytes of DATA actually transmitted."""
+ self._checkClosed()
return self._sslobj.write(data)
def getpeercert(self, binary_form=False):
-
"""Returns a formatted version of the data in the
certificate provided by the other end of the SSL channel.
Return None if no certificate was provided, {} if a
certificate was provided, but not validated."""
+ self._checkClosed()
return self._sslobj.peer_certificate(binary_form)
def cipher(self):
-
+ self._checkClosed()
if not self._sslobj:
return None
else:
return self._sslobj.cipher()
def send(self, data, flags=0):
+ self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError(
@@ -196,7 +336,7 @@ class SSLSocket(socket):
while True:
try:
v = self._sslobj.write(data)
- except SSLError, x:
+ except SSLError as x:
if x.args[0] == SSL_ERROR_WANT_READ:
return 0
elif x.args[0] == SSL_ERROR_WANT_WRITE:
@@ -206,18 +346,20 @@ class SSLSocket(socket):
else:
return v
else:
- return self._sock.send(data, flags)
+ return socket.send(self, data, flags)
def sendto(self, data, flags_or_addr, addr=None):
+ self._checkClosed()
if self._sslobj:
raise ValueError("sendto not allowed on instances of %s" %
self.__class__)
elif addr is None:
- return self._sock.sendto(data, flags_or_addr)
+ return socket.sendto(self, data, flags_or_addr)
else:
- return self._sock.sendto(data, flags_or_addr, addr)
+ return socket.sendto(self, data, flags_or_addr, addr)
def sendall(self, data, flags=0):
+ self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError(
@@ -233,6 +375,7 @@ class SSLSocket(socket):
return socket.sendall(self, data, flags)
def recv(self, buflen=1024, flags=0):
+ self._checkClosed()
if self._sslobj:
if flags != 0:
raise ValueError(
@@ -240,9 +383,10 @@ class SSLSocket(socket):
self.__class__)
return self.read(buflen)
else:
- return self._sock.recv(buflen, flags)
+ return socket.recv(self, buflen, flags)
def recv_into(self, buffer, nbytes=None, flags=0):
+ self._checkClosed()
if buffer and (nbytes is None):
nbytes = len(buffer)
elif nbytes is None:
@@ -252,33 +396,38 @@ class SSLSocket(socket):
raise ValueError(
"non-zero flags not allowed in calls to recv_into() on %s" %
self.__class__)
- tmp_buffer = self.read(nbytes)
- v = len(tmp_buffer)
- buffer[:v] = tmp_buffer
- return v
+ return self.read(nbytes, buffer)
else:
- return self._sock.recv_into(buffer, nbytes, flags)
+ return socket.recv_into(self, buffer, nbytes, flags)
def recvfrom(self, buflen=1024, flags=0):
+ self._checkClosed()
if self._sslobj:
raise ValueError("recvfrom not allowed on instances of %s" %
self.__class__)
else:
- return self._sock.recvfrom(buflen, flags)
+ return socket.recvfrom(self, buflen, flags)
def recvfrom_into(self, buffer, nbytes=None, flags=0):
+ self._checkClosed()
if self._sslobj:
raise ValueError("recvfrom_into not allowed on instances of %s" %
self.__class__)
else:
- return self._sock.recvfrom_into(buffer, nbytes, flags)
+ return socket.recvfrom_into(self, buffer, nbytes, flags)
def pending(self):
+ self._checkClosed()
if self._sslobj:
return self._sslobj.pending()
else:
return 0
+ def shutdown(self, how):
+ self._checkClosed()
+ self._sslobj = None
+ socket.shutdown(self, how)
+
def unwrap(self):
if self._sslobj:
s = self._sslobj.shutdown()
@@ -287,33 +436,32 @@ class SSLSocket(socket):
else:
raise ValueError("No SSL wrapper around " + str(self))
- def shutdown(self, how):
+ def _real_close(self):
self._sslobj = None
- socket.shutdown(self, how)
-
- def close(self):
- if self._makefile_refs < 1:
- self._sslobj = None
- socket.close(self)
- else:
- self._makefile_refs -= 1
-
- def do_handshake(self):
+ # self._closed = True
+ socket._real_close(self)
+ def do_handshake(self, block=False):
"""Perform a TLS/SSL handshake."""
- self._sslobj.do_handshake()
-
- def _real_connect(self, addr, return_errno):
+ timeout = self.gettimeout()
+ try:
+ if timeout == 0.0 and block:
+ self.settimeout(None)
+ self._sslobj.do_handshake()
+ finally:
+ self.settimeout(timeout)
+
+ def _real_connect(self, addr, connect_ex):
+ if self.server_side:
+ raise ValueError("can't connect in server-side mode")
# Here we assume that the socket is client-side, and not
# connected at the time of the call. We connect it, then wrap it.
if self._connected:
raise ValueError("attempt to connect already-connected SSLSocket!")
- self._sslobj = _ssl.sslwrap(self._sock, False, self.keyfile, self.certfile,
- self.cert_reqs, self.ssl_version,
- self.ca_certs, self.ciphers)
+ self._sslobj = self.context._wrap_socket(self, False, self.server_hostname)
try:
- if return_errno:
+ if connect_ex:
rc = socket.connect_ex(self, addr)
else:
rc = None
@@ -338,35 +486,20 @@ class SSLSocket(socket):
return self._real_connect(addr, True)
def accept(self):
-
"""Accepts a new connection from a remote client, and returns
a tuple containing that new connection wrapped with a server-side
SSL channel, and the address of the remote client."""
newsock, addr = socket.accept(self)
- return (SSLSocket(newsock,
- keyfile=self.keyfile,
- certfile=self.certfile,
- server_side=True,
- cert_reqs=self.cert_reqs,
- ssl_version=self.ssl_version,
- ca_certs=self.ca_certs,
- ciphers=self.ciphers,
- do_handshake_on_connect=self.do_handshake_on_connect,
- suppress_ragged_eofs=self.suppress_ragged_eofs),
- addr)
-
- def makefile(self, mode='r', bufsize=-1):
-
- """Make and return a file-like object that
- works with the SSL connection. Just use the code
- from the socket module."""
-
- self._makefile_refs += 1
- # close=True so as to decrement the reference count when done with
- # the file-like object.
- return _fileobject(self, mode, bufsize, close=True)
+ newsock = self.context.wrap_socket(newsock,
+ do_handshake_on_connect=self.do_handshake_on_connect,
+ suppress_ragged_eofs=self.suppress_ragged_eofs,
+ server_side=True)
+ return newsock, addr
+ def __del__(self):
+ # sys.stderr.write("__del__ on %s\n" % repr(self))
+ self._real_close()
def wrap_socket(sock, keyfile=None, certfile=None,
@@ -375,18 +508,16 @@ def wrap_socket(sock, keyfile=None, certfile=None,
do_handshake_on_connect=True,
suppress_ragged_eofs=True, ciphers=None):
- return SSLSocket(sock, keyfile=keyfile, certfile=certfile,
+ return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile,
server_side=server_side, cert_reqs=cert_reqs,
ssl_version=ssl_version, ca_certs=ca_certs,
do_handshake_on_connect=do_handshake_on_connect,
suppress_ragged_eofs=suppress_ragged_eofs,
ciphers=ciphers)
-
# some utility functions
def cert_time_to_seconds(cert_time):
-
"""Takes a date-time string in standard ASN1_print form
("MON DAY 24HOUR:MINUTE:SEC YEAR TIMEZONE") and return
a Python time value in seconds past the epoch."""
@@ -398,23 +529,15 @@ PEM_HEADER = "-----BEGIN CERTIFICATE-----"
PEM_FOOTER = "-----END CERTIFICATE-----"
def DER_cert_to_PEM_cert(der_cert_bytes):
-
"""Takes a certificate in binary DER format and returns the
PEM version of it as a string."""
- if hasattr(base64, 'standard_b64encode'):
- # preferred because older API gets line-length wrong
- f = base64.standard_b64encode(der_cert_bytes)
- return (PEM_HEADER + '\n' +
- textwrap.fill(f, 64) + '\n' +
- PEM_FOOTER + '\n')
- else:
- return (PEM_HEADER + '\n' +
- base64.encodestring(der_cert_bytes) +
- PEM_FOOTER + '\n')
+ f = str(base64.standard_b64encode(der_cert_bytes), 'ASCII', 'strict')
+ return (PEM_HEADER + '\n' +
+ textwrap.fill(f, 64) + '\n' +
+ PEM_FOOTER + '\n')
def PEM_cert_to_DER_cert(pem_cert_string):
-
"""Takes a certificate in ASCII PEM format and returns the
DER-encoded version of it as a byte sequence"""
@@ -425,10 +548,9 @@ def PEM_cert_to_DER_cert(pem_cert_string):
raise ValueError("Invalid PEM encoding; must end with %s"
% PEM_FOOTER)
d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)]
- return base64.decodestring(d)
+ return base64.decodebytes(d.encode('ASCII', 'strict'))
def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
-
"""Retrieve the certificate from the server at the specified address,
and return it as a PEM-encoded string.
If 'ca_certs' is specified, validate the server cert against it.
@@ -448,28 +570,3 @@ def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
def get_protocol_name(protocol_code):
return _PROTOCOL_NAMES.get(protocol_code, '<unknown>')
-
-
-# a replacement for the old socket.ssl function
-
-def sslwrap_simple(sock, keyfile=None, certfile=None):
-
- """A replacement for the old socket.ssl function. Designed
- for compability with Python 2.5 and earlier. Will disappear in
- Python 3.0."""
-
- if hasattr(sock, "_sock"):
- sock = sock._sock
-
- ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE,
- PROTOCOL_SSLv23, None)
- try:
- sock.getpeername()
- except socket_error:
- # no, no connection yet
- pass
- else:
- # yes, do the handshake
- ssl_sock.do_handshake()
-
- return ssl_sock
diff --git a/Lib/stat.py b/Lib/stat.py
index abed5c9e0f5..78ccd5e8fff 100644
--- a/Lib/stat.py
+++ b/Lib/stat.py
@@ -19,21 +19,21 @@ ST_CTIME = 9
# Extract bits from the mode
def S_IMODE(mode):
- return mode & 07777
+ return mode & 0o7777
def S_IFMT(mode):
- return mode & 0170000
+ return mode & 0o170000
# Constants used as S_IFMT() for various file types
# (not all are implemented on all systems)
-S_IFDIR = 0040000
-S_IFCHR = 0020000
-S_IFBLK = 0060000
-S_IFREG = 0100000
-S_IFIFO = 0010000
-S_IFLNK = 0120000
-S_IFSOCK = 0140000
+S_IFDIR = 0o040000
+S_IFCHR = 0o020000
+S_IFBLK = 0o060000
+S_IFREG = 0o100000
+S_IFIFO = 0o010000
+S_IFLNK = 0o120000
+S_IFSOCK = 0o140000
# Functions to test for each file type
@@ -60,25 +60,25 @@ def S_ISSOCK(mode):
# Names for permission bits
-S_ISUID = 04000
-S_ISGID = 02000
+S_ISUID = 0o4000
+S_ISGID = 0o2000
S_ENFMT = S_ISGID
-S_ISVTX = 01000
-S_IREAD = 00400
-S_IWRITE = 00200
-S_IEXEC = 00100
-S_IRWXU = 00700
-S_IRUSR = 00400
-S_IWUSR = 00200
-S_IXUSR = 00100
-S_IRWXG = 00070
-S_IRGRP = 00040
-S_IWGRP = 00020
-S_IXGRP = 00010
-S_IRWXO = 00007
-S_IROTH = 00004
-S_IWOTH = 00002
-S_IXOTH = 00001
+S_ISVTX = 0o1000
+S_IREAD = 0o0400
+S_IWRITE = 0o0200
+S_IEXEC = 0o0100
+S_IRWXU = 0o0700
+S_IRUSR = 0o0400
+S_IWUSR = 0o0200
+S_IXUSR = 0o0100
+S_IRWXG = 0o0070
+S_IRGRP = 0o0040
+S_IWGRP = 0o0020
+S_IXGRP = 0o0010
+S_IRWXO = 0o0007
+S_IROTH = 0o0004
+S_IWOTH = 0o0002
+S_IXOTH = 0o0001
# Names for file flags
diff --git a/Lib/statvfs.py b/Lib/statvfs.py
deleted file mode 100644
index f572422e8a5..00000000000
--- a/Lib/statvfs.py
+++ /dev/null
@@ -1,18 +0,0 @@
-"""Constants for interpreting the results of os.statvfs() and os.fstatvfs()."""
-from warnings import warnpy3k
-warnpy3k("the statvfs module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Indices for statvfs struct members in the tuple returned by
-# os.statvfs() and os.fstatvfs().
-
-F_BSIZE = 0 # Preferred file system block size
-F_FRSIZE = 1 # Fundamental file system block size
-F_BLOCKS = 2 # Total number of file system blocks (FRSIZE)
-F_BFREE = 3 # Total number of free blocks
-F_BAVAIL = 4 # Free blocks available to non-superuser
-F_FILES = 5 # Total number of file nodes
-F_FFREE = 6 # Total number of free file nodes
-F_FAVAIL = 7 # Free nodes available to non-superuser
-F_FLAG = 8 # Flags (see your local statvfs man page)
-F_NAMEMAX = 9 # Maximum file name length
diff --git a/Lib/string.py b/Lib/string.py
index 97278034a0f..0f4ede23e14 100644
--- a/Lib/string.py
+++ b/Lib/string.py
@@ -1,43 +1,31 @@
-"""A collection of string operations (most are no longer used).
-
-Warning: most of the code you see here isn't normally used nowadays.
-Beginning with Python 1.6, many of these functions are implemented as
-methods on the standard string object. They used to be implemented by
-a built-in module called strop, but strop is now obsolete itself.
+"""A collection of string constants.
Public module variables:
-whitespace -- a string containing all characters considered whitespace
-lowercase -- a string containing all characters considered lowercase letters
-uppercase -- a string containing all characters considered uppercase letters
-letters -- a string containing all characters considered letters
-digits -- a string containing all characters considered decimal digits
-hexdigits -- a string containing all characters considered hexadecimal digits
-octdigits -- a string containing all characters considered octal digits
-punctuation -- a string containing all characters considered punctuation
-printable -- a string containing all characters considered printable
+whitespace -- a string containing all ASCII whitespace
+ascii_lowercase -- a string containing all ASCII lowercase letters
+ascii_uppercase -- a string containing all ASCII uppercase letters
+ascii_letters -- a string containing all ASCII letters
+digits -- a string containing all ASCII decimal digits
+hexdigits -- a string containing all ASCII hexadecimal digits
+octdigits -- a string containing all ASCII octal digits
+punctuation -- a string containing all ASCII punctuation characters
+printable -- a string containing all ASCII characters considered printable
"""
+import _string
+
# Some strings for ctype-style character classification
whitespace = ' \t\n\r\v\f'
-lowercase = 'abcdefghijklmnopqrstuvwxyz'
-uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-letters = lowercase + uppercase
-ascii_lowercase = lowercase
-ascii_uppercase = uppercase
+ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
+ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_letters = ascii_lowercase + ascii_uppercase
digits = '0123456789'
hexdigits = digits + 'abcdef' + 'ABCDEF'
octdigits = '01234567'
punctuation = """!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~"""
-printable = digits + letters + punctuation + whitespace
-
-# Case conversion helpers
-# Use str to convert Unicode literal in case of -U
-l = map(chr, xrange(256))
-_idmap = str('').join(l)
-del l
+printable = digits + ascii_letters + punctuation + whitespace
# Functions which aren't available as string methods.
@@ -56,29 +44,6 @@ def capwords(s, sep=None):
return (sep or ' ').join(x.capitalize() for x in s.split(sep))
-# Construct a translation string
-_idmapL = None
-def maketrans(fromstr, tostr):
- """maketrans(frm, to) -> string
-
- Return a translation table (a string of 256 bytes long)
- suitable for use in string.translate. The strings frm and to
- must be of the same length.
-
- """
- if len(fromstr) != len(tostr):
- raise ValueError, "maketrans arguments must have same length"
- global _idmapL
- if not _idmapL:
- _idmapL = list(_idmap)
- L = _idmapL[:]
- fromstr = map(ord, fromstr)
- for i in range(len(fromstr)):
- L[fromstr[i]] = tostr[i]
- return ''.join(L)
-
-
-
####################################################################
import re as _re
@@ -118,15 +83,15 @@ class _TemplateMetaclass(type):
'delim' : _re.escape(cls.delimiter),
'id' : cls.idpattern,
}
- cls.pattern = _re.compile(pattern, _re.IGNORECASE | _re.VERBOSE)
+ cls.pattern = _re.compile(pattern, cls.flags | _re.VERBOSE)
-class Template:
+class Template(metaclass=_TemplateMetaclass):
"""A string class for supporting $-substitutions."""
- __metaclass__ = _TemplateMetaclass
delimiter = '$'
idpattern = r'[_a-z][_a-z0-9]*'
+ flags = _re.IGNORECASE
def __init__(self, template):
self.template = template
@@ -182,365 +147,35 @@ class Template:
mapping = args[0]
# Helper function for .sub()
def convert(mo):
- named = mo.group('named')
+ named = mo.group('named') or mo.group('braced')
if named is not None:
try:
# We use this idiom instead of str() because the latter
# will fail if val is a Unicode containing non-ASCII
return '%s' % (mapping[named],)
except KeyError:
- return self.delimiter + named
- braced = mo.group('braced')
- if braced is not None:
- try:
- return '%s' % (mapping[braced],)
- except KeyError:
- return self.delimiter + '{' + braced + '}'
+ return mo.group()
if mo.group('escaped') is not None:
return self.delimiter
if mo.group('invalid') is not None:
- return self.delimiter
+ return mo.group()
raise ValueError('Unrecognized named group in pattern',
self.pattern)
return self.pattern.sub(convert, self.template)
-####################################################################
-# NOTE: Everything below here is deprecated. Use string methods instead.
-# This stuff will go away in Python 3.0.
-
-# Backward compatible names for exceptions
-index_error = ValueError
-atoi_error = ValueError
-atof_error = ValueError
-atol_error = ValueError
-
-# convert UPPER CASE letters to lower case
-def lower(s):
- """lower(s) -> string
-
- Return a copy of the string s converted to lowercase.
-
- """
- return s.lower()
-
-# Convert lower case letters to UPPER CASE
-def upper(s):
- """upper(s) -> string
-
- Return a copy of the string s converted to uppercase.
-
- """
- return s.upper()
-
-# Swap lower case letters and UPPER CASE
-def swapcase(s):
- """swapcase(s) -> string
-
- Return a copy of the string s with upper case characters
- converted to lowercase and vice versa.
-
- """
- return s.swapcase()
-
-# Strip leading and trailing tabs and spaces
-def strip(s, chars=None):
- """strip(s [,chars]) -> string
-
- Return a copy of the string s with leading and trailing
- whitespace removed.
- If chars is given and not None, remove characters in chars instead.
- If chars is unicode, S will be converted to unicode before stripping.
-
- """
- return s.strip(chars)
-
-# Strip leading tabs and spaces
-def lstrip(s, chars=None):
- """lstrip(s [,chars]) -> string
-
- Return a copy of the string s with leading whitespace removed.
- If chars is given and not None, remove characters in chars instead.
-
- """
- return s.lstrip(chars)
-
-# Strip trailing tabs and spaces
-def rstrip(s, chars=None):
- """rstrip(s [,chars]) -> string
-
- Return a copy of the string s with trailing whitespace removed.
- If chars is given and not None, remove characters in chars instead.
-
- """
- return s.rstrip(chars)
-
-
-# Split a string into a list of space/tab-separated words
-def split(s, sep=None, maxsplit=-1):
- """split(s [,sep [,maxsplit]]) -> list of strings
-
- Return a list of the words in the string s, using sep as the
- delimiter string. If maxsplit is given, splits at no more than
- maxsplit places (resulting in at most maxsplit+1 words). If sep
- is not specified or is None, any whitespace string is a separator.
-
- (split and splitfields are synonymous)
-
- """
- return s.split(sep, maxsplit)
-splitfields = split
-
-# Split a string into a list of space/tab-separated words
-def rsplit(s, sep=None, maxsplit=-1):
- """rsplit(s [,sep [,maxsplit]]) -> list of strings
-
- Return a list of the words in the string s, using sep as the
- delimiter string, starting at the end of the string and working
- to the front. If maxsplit is given, at most maxsplit splits are
- done. If sep is not specified or is None, any whitespace string
- is a separator.
- """
- return s.rsplit(sep, maxsplit)
-
-# Join fields with optional separator
-def join(words, sep = ' '):
- """join(list [,sep]) -> string
-
- Return a string composed of the words in list, with
- intervening occurrences of sep. The default separator is a
- single space.
-
- (joinfields and join are synonymous)
-
- """
- return sep.join(words)
-joinfields = join
-
-# Find substring, raise exception if not found
-def index(s, *args):
- """index(s, sub [,start [,end]]) -> int
-
- Like find but raises ValueError when the substring is not found.
-
- """
- return s.index(*args)
-
-# Find last substring, raise exception if not found
-def rindex(s, *args):
- """rindex(s, sub [,start [,end]]) -> int
-
- Like rfind but raises ValueError when the substring is not found.
-
- """
- return s.rindex(*args)
-
-# Count non-overlapping occurrences of substring
-def count(s, *args):
- """count(s, sub[, start[,end]]) -> int
-
- Return the number of occurrences of substring sub in string
- s[start:end]. Optional arguments start and end are
- interpreted as in slice notation.
-
- """
- return s.count(*args)
-
-# Find substring, return -1 if not found
-def find(s, *args):
- """find(s, sub [,start [,end]]) -> in
-
- Return the lowest index in s where substring sub is found,
- such that sub is contained within s[start,end]. Optional
- arguments start and end are interpreted as in slice notation.
-
- Return -1 on failure.
-
- """
- return s.find(*args)
-
-# Find last substring, return -1 if not found
-def rfind(s, *args):
- """rfind(s, sub [,start [,end]]) -> int
-
- Return the highest index in s where substring sub is found,
- such that sub is contained within s[start,end]. Optional
- arguments start and end are interpreted as in slice notation.
-
- Return -1 on failure.
-
- """
- return s.rfind(*args)
-
-# for a bit of speed
-_float = float
-_int = int
-_long = long
-
-# Convert string to float
-def atof(s):
- """atof(s) -> float
-
- Return the floating point number represented by the string s.
-
- """
- return _float(s)
-
-
-# Convert string to integer
-def atoi(s , base=10):
- """atoi(s [,base]) -> int
-
- Return the integer represented by the string s in the given
- base, which defaults to 10. The string s must consist of one
- or more digits, possibly preceded by a sign. If base is 0, it
- is chosen from the leading characters of s, 0 for octal, 0x or
- 0X for hexadecimal. If base is 16, a preceding 0x or 0X is
- accepted.
-
- """
- return _int(s, base)
-
-
-# Convert string to long integer
-def atol(s, base=10):
- """atol(s [,base]) -> long
-
- Return the long integer represented by the string s in the
- given base, which defaults to 10. The string s must consist
- of one or more digits, possibly preceded by a sign. If base
- is 0, it is chosen from the leading characters of s, 0 for
- octal, 0x or 0X for hexadecimal. If base is 16, a preceding
- 0x or 0X is accepted. A trailing L or l is not accepted,
- unless base is 0.
-
- """
- return _long(s, base)
-
-
-# Left-justify a string
-def ljust(s, width, *args):
- """ljust(s, width[, fillchar]) -> string
-
- Return a left-justified version of s, in a field of the
- specified width, padded with spaces as needed. The string is
- never truncated. If specified the fillchar is used instead of spaces.
-
- """
- return s.ljust(width, *args)
-
-# Right-justify a string
-def rjust(s, width, *args):
- """rjust(s, width[, fillchar]) -> string
-
- Return a right-justified version of s, in a field of the
- specified width, padded with spaces as needed. The string is
- never truncated. If specified the fillchar is used instead of spaces.
-
- """
- return s.rjust(width, *args)
-
-# Center a string
-def center(s, width, *args):
- """center(s, width[, fillchar]) -> string
-
- Return a center version of s, in a field of the specified
- width. padded with spaces as needed. The string is never
- truncated. If specified the fillchar is used instead of spaces.
-
- """
- return s.center(width, *args)
-
-# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'
-# Decadent feature: the argument may be a string or a number
-# (Use of this is deprecated; it should be a string as with ljust c.s.)
-def zfill(x, width):
- """zfill(x, width) -> string
-
- Pad a numeric string x with zeros on the left, to fill a field
- of the specified width. The string x is never truncated.
-
- """
- if not isinstance(x, basestring):
- x = repr(x)
- return x.zfill(width)
-
-# Expand tabs in a string.
-# Doesn't take non-printing chars into account, but does understand \n.
-def expandtabs(s, tabsize=8):
- """expandtabs(s [,tabsize]) -> string
-
- Return a copy of the string s with all tab characters replaced
- by the appropriate number of spaces, depending on the current
- column, and the tabsize (default 8).
-
- """
- return s.expandtabs(tabsize)
-
-# Character translation through look-up table.
-def translate(s, table, deletions=""):
- """translate(s,table [,deletions]) -> string
-
- Return a copy of the string s, where all characters occurring
- in the optional argument deletions are removed, and the
- remaining characters have been mapped through the given
- translation table, which must be a string of length 256. The
- deletions argument is not allowed for Unicode strings.
-
- """
- if deletions or table is None:
- return s.translate(table, deletions)
- else:
- # Add s[:0] so that if s is Unicode and table is an 8-bit string,
- # table is converted to Unicode. This means that table *cannot*
- # be a dictionary -- for that feature, use u.translate() directly.
- return s.translate(table + s[:0])
-
-# Capitalize a string, e.g. "aBc dEf" -> "Abc def".
-def capitalize(s):
- """capitalize(s) -> string
-
- Return a copy of the string s with only its first character
- capitalized.
-
- """
- return s.capitalize()
-
-# Substring replacement (global)
-def replace(s, old, new, maxreplace=-1):
- """replace (str, old, new[, maxreplace]) -> string
-
- Return a copy of string str with all occurrences of substring
- old replaced by new. If the optional argument maxreplace is
- given, only the first maxreplace occurrences are replaced.
-
- """
- return s.replace(old, new, maxreplace)
-
-
-# Try importing optional built-in module "strop" -- if it exists,
-# it redefines some string operations that are 100-1000 times faster.
-# It also defines values for whitespace, lowercase and uppercase
-# that match <ctype.h>'s definitions.
-
-try:
- from strop import maketrans, lowercase, uppercase, whitespace
- letters = lowercase + uppercase
-except ImportError:
- pass # Use the original versions
-
########################################################################
# the Formatter class
# see PEP 3101 for details and purpose of this class
# The hard parts are reused from the C implementation. They're exposed as "_"
-# prefixed methods of str and unicode.
+# prefixed methods of str.
-# The overall parser is implemented in str._formatter_parser.
-# The field name parser is implemented in str._formatter_field_name_split
+# The overall parser is implemented in _string.formatter_parser.
+# The field name parser is implemented in _string.formatter_field_name_split
-class Formatter(object):
+class Formatter:
def format(self, format_string, *args, **kwargs):
return self.vformat(format_string, args, kwargs)
@@ -585,7 +220,7 @@ class Formatter(object):
def get_value(self, key, args, kwargs):
- if isinstance(key, (int, long)):
+ if isinstance(key, int):
return args[key]
else:
return kwargs[key]
@@ -607,6 +242,8 @@ class Formatter(object):
return str(value)
elif conversion == 'r':
return repr(value)
+ elif conversion == 'a':
+ return ascii(value)
raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
@@ -618,7 +255,7 @@ class Formatter(object):
# if field_name is not None, it is looked up, formatted
# with format_spec and conversion and then used
def parse(self, format_string):
- return format_string._formatter_parser()
+ return _string.formatter_parser(format_string)
# given a field_name, find the object it references.
@@ -627,7 +264,7 @@ class Formatter(object):
# used_args: a set of which args have been used
# args, kwargs: as passed in to vformat
def get_field(self, field_name, args, kwargs):
- first, rest = field_name._formatter_field_name_split()
+ first, rest = _string.formatter_field_name_split(field_name)
obj = self.get_value(first, args, kwargs)
diff --git a/Lib/stringold.py b/Lib/stringold.py
deleted file mode 100644
index ebfe38313a7..00000000000
--- a/Lib/stringold.py
+++ /dev/null
@@ -1,432 +0,0 @@
-# module 'string' -- A collection of string operations
-
-# Warning: most of the code you see here isn't normally used nowadays. With
-# Python 1.6, many of these functions are implemented as methods on the
-# standard string object. They used to be implemented by a built-in module
-# called strop, but strop is now obsolete itself.
-
-"""Common string manipulations.
-
-Public module variables:
-
-whitespace -- a string containing all characters considered whitespace
-lowercase -- a string containing all characters considered lowercase letters
-uppercase -- a string containing all characters considered uppercase letters
-letters -- a string containing all characters considered letters
-digits -- a string containing all characters considered decimal digits
-hexdigits -- a string containing all characters considered hexadecimal digits
-octdigits -- a string containing all characters considered octal digits
-
-"""
-from warnings import warnpy3k
-warnpy3k("the stringold module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-# Some strings for ctype-style character classification
-whitespace = ' \t\n\r\v\f'
-lowercase = 'abcdefghijklmnopqrstuvwxyz'
-uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-letters = lowercase + uppercase
-digits = '0123456789'
-hexdigits = digits + 'abcdef' + 'ABCDEF'
-octdigits = '01234567'
-
-# Case conversion helpers
-_idmap = ''
-for i in range(256): _idmap = _idmap + chr(i)
-del i
-
-# Backward compatible names for exceptions
-index_error = ValueError
-atoi_error = ValueError
-atof_error = ValueError
-atol_error = ValueError
-
-# convert UPPER CASE letters to lower case
-def lower(s):
- """lower(s) -> string
-
- Return a copy of the string s converted to lowercase.
-
- """
- return s.lower()
-
-# Convert lower case letters to UPPER CASE
-def upper(s):
- """upper(s) -> string
-
- Return a copy of the string s converted to uppercase.
-
- """
- return s.upper()
-
-# Swap lower case letters and UPPER CASE
-def swapcase(s):
- """swapcase(s) -> string
-
- Return a copy of the string s with upper case characters
- converted to lowercase and vice versa.
-
- """
- return s.swapcase()
-
-# Strip leading and trailing tabs and spaces
-def strip(s):
- """strip(s) -> string
-
- Return a copy of the string s with leading and trailing
- whitespace removed.
-
- """
- return s.strip()
-
-# Strip leading tabs and spaces
-def lstrip(s):
- """lstrip(s) -> string
-
- Return a copy of the string s with leading whitespace removed.
-
- """
- return s.lstrip()
-
-# Strip trailing tabs and spaces
-def rstrip(s):
- """rstrip(s) -> string
-
- Return a copy of the string s with trailing whitespace
- removed.
-
- """
- return s.rstrip()
-
-
-# Split a string into a list of space/tab-separated words
-def split(s, sep=None, maxsplit=0):
- """split(str [,sep [,maxsplit]]) -> list of strings
-
- Return a list of the words in the string s, using sep as the
- delimiter string. If maxsplit is nonzero, splits into at most
- maxsplit words If sep is not specified, any whitespace string
- is a separator. Maxsplit defaults to 0.
-
- (split and splitfields are synonymous)
-
- """
- return s.split(sep, maxsplit)
-splitfields = split
-
-# Join fields with optional separator
-def join(words, sep = ' '):
- """join(list [,sep]) -> string
-
- Return a string composed of the words in list, with
- intervening occurrences of sep. The default separator is a
- single space.
-
- (joinfields and join are synonymous)
-
- """
- return sep.join(words)
-joinfields = join
-
-# for a little bit of speed
-_apply = apply
-
-# Find substring, raise exception if not found
-def index(s, *args):
- """index(s, sub [,start [,end]]) -> int
-
- Like find but raises ValueError when the substring is not found.
-
- """
- return _apply(s.index, args)
-
-# Find last substring, raise exception if not found
-def rindex(s, *args):
- """rindex(s, sub [,start [,end]]) -> int
-
- Like rfind but raises ValueError when the substring is not found.
-
- """
- return _apply(s.rindex, args)
-
-# Count non-overlapping occurrences of substring
-def count(s, *args):
- """count(s, sub[, start[,end]]) -> int
-
- Return the number of occurrences of substring sub in string
- s[start:end]. Optional arguments start and end are
- interpreted as in slice notation.
-
- """
- return _apply(s.count, args)
-
-# Find substring, return -1 if not found
-def find(s, *args):
- """find(s, sub [,start [,end]]) -> in
-
- Return the lowest index in s where substring sub is found,
- such that sub is contained within s[start,end]. Optional
- arguments start and end are interpreted as in slice notation.
-
- Return -1 on failure.
-
- """
- return _apply(s.find, args)
-
-# Find last substring, return -1 if not found
-def rfind(s, *args):
- """rfind(s, sub [,start [,end]]) -> int
-
- Return the highest index in s where substring sub is found,
- such that sub is contained within s[start,end]. Optional
- arguments start and end are interpreted as in slice notation.
-
- Return -1 on failure.
-
- """
- return _apply(s.rfind, args)
-
-# for a bit of speed
-_float = float
-_int = int
-_long = long
-_StringType = type('')
-
-# Convert string to float
-def atof(s):
- """atof(s) -> float
-
- Return the floating point number represented by the string s.
-
- """
- if type(s) == _StringType:
- return _float(s)
- else:
- raise TypeError('argument 1: expected string, %s found' %
- type(s).__name__)
-
-# Convert string to integer
-def atoi(*args):
- """atoi(s [,base]) -> int
-
- Return the integer represented by the string s in the given
- base, which defaults to 10. The string s must consist of one
- or more digits, possibly preceded by a sign. If base is 0, it
- is chosen from the leading characters of s, 0 for octal, 0x or
- 0X for hexadecimal. If base is 16, a preceding 0x or 0X is
- accepted.
-
- """
- try:
- s = args[0]
- except IndexError:
- raise TypeError('function requires at least 1 argument: %d given' %
- len(args))
- # Don't catch type error resulting from too many arguments to int(). The
- # error message isn't compatible but the error type is, and this function
- # is complicated enough already.
- if type(s) == _StringType:
- return _apply(_int, args)
- else:
- raise TypeError('argument 1: expected string, %s found' %
- type(s).__name__)
-
-
-# Convert string to long integer
-def atol(*args):
- """atol(s [,base]) -> long
-
- Return the long integer represented by the string s in the
- given base, which defaults to 10. The string s must consist
- of one or more digits, possibly preceded by a sign. If base
- is 0, it is chosen from the leading characters of s, 0 for
- octal, 0x or 0X for hexadecimal. If base is 16, a preceding
- 0x or 0X is accepted. A trailing L or l is not accepted,
- unless base is 0.
-
- """
- try:
- s = args[0]
- except IndexError:
- raise TypeError('function requires at least 1 argument: %d given' %
- len(args))
- # Don't catch type error resulting from too many arguments to long(). The
- # error message isn't compatible but the error type is, and this function
- # is complicated enough already.
- if type(s) == _StringType:
- return _apply(_long, args)
- else:
- raise TypeError('argument 1: expected string, %s found' %
- type(s).__name__)
-
-
-# Left-justify a string
-def ljust(s, width):
- """ljust(s, width) -> string
-
- Return a left-justified version of s, in a field of the
- specified width, padded with spaces as needed. The string is
- never truncated.
-
- """
- n = width - len(s)
- if n <= 0: return s
- return s + ' '*n
-
-# Right-justify a string
-def rjust(s, width):
- """rjust(s, width) -> string
-
- Return a right-justified version of s, in a field of the
- specified width, padded with spaces as needed. The string is
- never truncated.
-
- """
- n = width - len(s)
- if n <= 0: return s
- return ' '*n + s
-
-# Center a string
-def center(s, width):
- """center(s, width) -> string
-
- Return a center version of s, in a field of the specified
- width. padded with spaces as needed. The string is never
- truncated.
-
- """
- n = width - len(s)
- if n <= 0: return s
- half = n/2
- if n%2 and width%2:
- # This ensures that center(center(s, i), j) = center(s, j)
- half = half+1
- return ' '*half + s + ' '*(n-half)
-
-# Zero-fill a number, e.g., (12, 3) --> '012' and (-3, 3) --> '-03'
-# Decadent feature: the argument may be a string or a number
-# (Use of this is deprecated; it should be a string as with ljust c.s.)
-def zfill(x, width):
- """zfill(x, width) -> string
-
- Pad a numeric string x with zeros on the left, to fill a field
- of the specified width. The string x is never truncated.
-
- """
- if type(x) == type(''): s = x
- else: s = repr(x)
- n = len(s)
- if n >= width: return s
- sign = ''
- if s[0] in ('-', '+'):
- sign, s = s[0], s[1:]
- return sign + '0'*(width-n) + s
-
-# Expand tabs in a string.
-# Doesn't take non-printing chars into account, but does understand \n.
-def expandtabs(s, tabsize=8):
- """expandtabs(s [,tabsize]) -> string
-
- Return a copy of the string s with all tab characters replaced
- by the appropriate number of spaces, depending on the current
- column, and the tabsize (default 8).
-
- """
- res = line = ''
- for c in s:
- if c == '\t':
- c = ' '*(tabsize - len(line) % tabsize)
- line = line + c
- if c == '\n':
- res = res + line
- line = ''
- return res + line
-
-# Character translation through look-up table.
-def translate(s, table, deletions=""):
- """translate(s,table [,deletechars]) -> string
-
- Return a copy of the string s, where all characters occurring
- in the optional argument deletechars are removed, and the
- remaining characters have been mapped through the given
- translation table, which must be a string of length 256.
-
- """
- return s.translate(table, deletions)
-
-# Capitalize a string, e.g. "aBc dEf" -> "Abc def".
-def capitalize(s):
- """capitalize(s) -> string
-
- Return a copy of the string s with only its first character
- capitalized.
-
- """
- return s.capitalize()
-
-# Capitalize the words in a string, e.g. " aBc dEf " -> "Abc Def".
-def capwords(s, sep=None):
- """capwords(s, [sep]) -> string
-
- Split the argument into words using split, capitalize each
- word using capitalize, and join the capitalized words using
- join. Note that this replaces runs of whitespace characters by
- a single space.
-
- """
- return join(map(capitalize, s.split(sep)), sep or ' ')
-
-# Construct a translation string
-_idmapL = None
-def maketrans(fromstr, tostr):
- """maketrans(frm, to) -> string
-
- Return a translation table (a string of 256 bytes long)
- suitable for use in string.translate. The strings frm and to
- must be of the same length.
-
- """
- if len(fromstr) != len(tostr):
- raise ValueError, "maketrans arguments must have same length"
- global _idmapL
- if not _idmapL:
- _idmapL = list(_idmap)
- L = _idmapL[:]
- fromstr = map(ord, fromstr)
- for i in range(len(fromstr)):
- L[fromstr[i]] = tostr[i]
- return join(L, "")
-
-# Substring replacement (global)
-def replace(s, old, new, maxsplit=0):
- """replace (str, old, new[, maxsplit]) -> string
-
- Return a copy of string str with all occurrences of substring
- old replaced by new. If the optional argument maxsplit is
- given, only the first maxsplit occurrences are replaced.
-
- """
- return s.replace(old, new, maxsplit)
-
-
-# XXX: transitional
-#
-# If string objects do not have methods, then we need to use the old string.py
-# library, which uses strop for many more things than just the few outlined
-# below.
-try:
- ''.upper
-except AttributeError:
- from stringold import *
-
-# Try importing optional built-in module "strop" -- if it exists,
-# it redefines some string operations that are 100-1000 times faster.
-# It also defines values for whitespace, lowercase and uppercase
-# that match <ctype.h>'s definitions.
-
-try:
- from strop import maketrans, lowercase, uppercase, whitespace
- letters = lowercase + uppercase
-except ImportError:
- pass # Use the original versions
diff --git a/Lib/stringprep.py b/Lib/stringprep.py
index 1d49dd1dddd..44ecdb266ce 100644
--- a/Lib/stringprep.py
+++ b/Lib/stringprep.py
@@ -16,175 +16,175 @@ def in_table_a1(code):
return (c & 0xFFFF) not in (0xFFFE, 0xFFFF)
-b1_set = set([173, 847, 6150, 6155, 6156, 6157, 8203, 8204, 8205, 8288, 65279] + range(65024,65040))
+b1_set = set([173, 847, 6150, 6155, 6156, 6157, 8203, 8204, 8205, 8288, 65279] + list(range(65024,65040)))
def in_table_b1(code):
return ord(code) in b1_set
b3_exceptions = {
-0xb5:u'\u03bc', 0xdf:u'ss', 0x130:u'i\u0307', 0x149:u'\u02bcn',
-0x17f:u's', 0x1f0:u'j\u030c', 0x345:u'\u03b9', 0x37a:u' \u03b9',
-0x390:u'\u03b9\u0308\u0301', 0x3b0:u'\u03c5\u0308\u0301', 0x3c2:u'\u03c3', 0x3d0:u'\u03b2',
-0x3d1:u'\u03b8', 0x3d2:u'\u03c5', 0x3d3:u'\u03cd', 0x3d4:u'\u03cb',
-0x3d5:u'\u03c6', 0x3d6:u'\u03c0', 0x3f0:u'\u03ba', 0x3f1:u'\u03c1',
-0x3f2:u'\u03c3', 0x3f5:u'\u03b5', 0x587:u'\u0565\u0582', 0x1e96:u'h\u0331',
-0x1e97:u't\u0308', 0x1e98:u'w\u030a', 0x1e99:u'y\u030a', 0x1e9a:u'a\u02be',
-0x1e9b:u'\u1e61', 0x1f50:u'\u03c5\u0313', 0x1f52:u'\u03c5\u0313\u0300', 0x1f54:u'\u03c5\u0313\u0301',
-0x1f56:u'\u03c5\u0313\u0342', 0x1f80:u'\u1f00\u03b9', 0x1f81:u'\u1f01\u03b9', 0x1f82:u'\u1f02\u03b9',
-0x1f83:u'\u1f03\u03b9', 0x1f84:u'\u1f04\u03b9', 0x1f85:u'\u1f05\u03b9', 0x1f86:u'\u1f06\u03b9',
-0x1f87:u'\u1f07\u03b9', 0x1f88:u'\u1f00\u03b9', 0x1f89:u'\u1f01\u03b9', 0x1f8a:u'\u1f02\u03b9',
-0x1f8b:u'\u1f03\u03b9', 0x1f8c:u'\u1f04\u03b9', 0x1f8d:u'\u1f05\u03b9', 0x1f8e:u'\u1f06\u03b9',
-0x1f8f:u'\u1f07\u03b9', 0x1f90:u'\u1f20\u03b9', 0x1f91:u'\u1f21\u03b9', 0x1f92:u'\u1f22\u03b9',
-0x1f93:u'\u1f23\u03b9', 0x1f94:u'\u1f24\u03b9', 0x1f95:u'\u1f25\u03b9', 0x1f96:u'\u1f26\u03b9',
-0x1f97:u'\u1f27\u03b9', 0x1f98:u'\u1f20\u03b9', 0x1f99:u'\u1f21\u03b9', 0x1f9a:u'\u1f22\u03b9',
-0x1f9b:u'\u1f23\u03b9', 0x1f9c:u'\u1f24\u03b9', 0x1f9d:u'\u1f25\u03b9', 0x1f9e:u'\u1f26\u03b9',
-0x1f9f:u'\u1f27\u03b9', 0x1fa0:u'\u1f60\u03b9', 0x1fa1:u'\u1f61\u03b9', 0x1fa2:u'\u1f62\u03b9',
-0x1fa3:u'\u1f63\u03b9', 0x1fa4:u'\u1f64\u03b9', 0x1fa5:u'\u1f65\u03b9', 0x1fa6:u'\u1f66\u03b9',
-0x1fa7:u'\u1f67\u03b9', 0x1fa8:u'\u1f60\u03b9', 0x1fa9:u'\u1f61\u03b9', 0x1faa:u'\u1f62\u03b9',
-0x1fab:u'\u1f63\u03b9', 0x1fac:u'\u1f64\u03b9', 0x1fad:u'\u1f65\u03b9', 0x1fae:u'\u1f66\u03b9',
-0x1faf:u'\u1f67\u03b9', 0x1fb2:u'\u1f70\u03b9', 0x1fb3:u'\u03b1\u03b9', 0x1fb4:u'\u03ac\u03b9',
-0x1fb6:u'\u03b1\u0342', 0x1fb7:u'\u03b1\u0342\u03b9', 0x1fbc:u'\u03b1\u03b9', 0x1fbe:u'\u03b9',
-0x1fc2:u'\u1f74\u03b9', 0x1fc3:u'\u03b7\u03b9', 0x1fc4:u'\u03ae\u03b9', 0x1fc6:u'\u03b7\u0342',
-0x1fc7:u'\u03b7\u0342\u03b9', 0x1fcc:u'\u03b7\u03b9', 0x1fd2:u'\u03b9\u0308\u0300', 0x1fd3:u'\u03b9\u0308\u0301',
-0x1fd6:u'\u03b9\u0342', 0x1fd7:u'\u03b9\u0308\u0342', 0x1fe2:u'\u03c5\u0308\u0300', 0x1fe3:u'\u03c5\u0308\u0301',
-0x1fe4:u'\u03c1\u0313', 0x1fe6:u'\u03c5\u0342', 0x1fe7:u'\u03c5\u0308\u0342', 0x1ff2:u'\u1f7c\u03b9',
-0x1ff3:u'\u03c9\u03b9', 0x1ff4:u'\u03ce\u03b9', 0x1ff6:u'\u03c9\u0342', 0x1ff7:u'\u03c9\u0342\u03b9',
-0x1ffc:u'\u03c9\u03b9', 0x20a8:u'rs', 0x2102:u'c', 0x2103:u'\xb0c',
-0x2107:u'\u025b', 0x2109:u'\xb0f', 0x210b:u'h', 0x210c:u'h',
-0x210d:u'h', 0x2110:u'i', 0x2111:u'i', 0x2112:u'l',
-0x2115:u'n', 0x2116:u'no', 0x2119:u'p', 0x211a:u'q',
-0x211b:u'r', 0x211c:u'r', 0x211d:u'r', 0x2120:u'sm',
-0x2121:u'tel', 0x2122:u'tm', 0x2124:u'z', 0x2128:u'z',
-0x212c:u'b', 0x212d:u'c', 0x2130:u'e', 0x2131:u'f',
-0x2133:u'm', 0x213e:u'\u03b3', 0x213f:u'\u03c0', 0x2145:u'd',
-0x3371:u'hpa', 0x3373:u'au', 0x3375:u'ov', 0x3380:u'pa',
-0x3381:u'na', 0x3382:u'\u03bca', 0x3383:u'ma', 0x3384:u'ka',
-0x3385:u'kb', 0x3386:u'mb', 0x3387:u'gb', 0x338a:u'pf',
-0x338b:u'nf', 0x338c:u'\u03bcf', 0x3390:u'hz', 0x3391:u'khz',
-0x3392:u'mhz', 0x3393:u'ghz', 0x3394:u'thz', 0x33a9:u'pa',
-0x33aa:u'kpa', 0x33ab:u'mpa', 0x33ac:u'gpa', 0x33b4:u'pv',
-0x33b5:u'nv', 0x33b6:u'\u03bcv', 0x33b7:u'mv', 0x33b8:u'kv',
-0x33b9:u'mv', 0x33ba:u'pw', 0x33bb:u'nw', 0x33bc:u'\u03bcw',
-0x33bd:u'mw', 0x33be:u'kw', 0x33bf:u'mw', 0x33c0:u'k\u03c9',
-0x33c1:u'm\u03c9', 0x33c3:u'bq', 0x33c6:u'c\u2215kg', 0x33c7:u'co.',
-0x33c8:u'db', 0x33c9:u'gy', 0x33cb:u'hp', 0x33cd:u'kk',
-0x33ce:u'km', 0x33d7:u'ph', 0x33d9:u'ppm', 0x33da:u'pr',
-0x33dc:u'sv', 0x33dd:u'wb', 0xfb00:u'ff', 0xfb01:u'fi',
-0xfb02:u'fl', 0xfb03:u'ffi', 0xfb04:u'ffl', 0xfb05:u'st',
-0xfb06:u'st', 0xfb13:u'\u0574\u0576', 0xfb14:u'\u0574\u0565', 0xfb15:u'\u0574\u056b',
-0xfb16:u'\u057e\u0576', 0xfb17:u'\u0574\u056d', 0x1d400:u'a', 0x1d401:u'b',
-0x1d402:u'c', 0x1d403:u'd', 0x1d404:u'e', 0x1d405:u'f',
-0x1d406:u'g', 0x1d407:u'h', 0x1d408:u'i', 0x1d409:u'j',
-0x1d40a:u'k', 0x1d40b:u'l', 0x1d40c:u'm', 0x1d40d:u'n',
-0x1d40e:u'o', 0x1d40f:u'p', 0x1d410:u'q', 0x1d411:u'r',
-0x1d412:u's', 0x1d413:u't', 0x1d414:u'u', 0x1d415:u'v',
-0x1d416:u'w', 0x1d417:u'x', 0x1d418:u'y', 0x1d419:u'z',
-0x1d434:u'a', 0x1d435:u'b', 0x1d436:u'c', 0x1d437:u'd',
-0x1d438:u'e', 0x1d439:u'f', 0x1d43a:u'g', 0x1d43b:u'h',
-0x1d43c:u'i', 0x1d43d:u'j', 0x1d43e:u'k', 0x1d43f:u'l',
-0x1d440:u'm', 0x1d441:u'n', 0x1d442:u'o', 0x1d443:u'p',
-0x1d444:u'q', 0x1d445:u'r', 0x1d446:u's', 0x1d447:u't',
-0x1d448:u'u', 0x1d449:u'v', 0x1d44a:u'w', 0x1d44b:u'x',
-0x1d44c:u'y', 0x1d44d:u'z', 0x1d468:u'a', 0x1d469:u'b',
-0x1d46a:u'c', 0x1d46b:u'd', 0x1d46c:u'e', 0x1d46d:u'f',
-0x1d46e:u'g', 0x1d46f:u'h', 0x1d470:u'i', 0x1d471:u'j',
-0x1d472:u'k', 0x1d473:u'l', 0x1d474:u'm', 0x1d475:u'n',
-0x1d476:u'o', 0x1d477:u'p', 0x1d478:u'q', 0x1d479:u'r',
-0x1d47a:u's', 0x1d47b:u't', 0x1d47c:u'u', 0x1d47d:u'v',
-0x1d47e:u'w', 0x1d47f:u'x', 0x1d480:u'y', 0x1d481:u'z',
-0x1d49c:u'a', 0x1d49e:u'c', 0x1d49f:u'd', 0x1d4a2:u'g',
-0x1d4a5:u'j', 0x1d4a6:u'k', 0x1d4a9:u'n', 0x1d4aa:u'o',
-0x1d4ab:u'p', 0x1d4ac:u'q', 0x1d4ae:u's', 0x1d4af:u't',
-0x1d4b0:u'u', 0x1d4b1:u'v', 0x1d4b2:u'w', 0x1d4b3:u'x',
-0x1d4b4:u'y', 0x1d4b5:u'z', 0x1d4d0:u'a', 0x1d4d1:u'b',
-0x1d4d2:u'c', 0x1d4d3:u'd', 0x1d4d4:u'e', 0x1d4d5:u'f',
-0x1d4d6:u'g', 0x1d4d7:u'h', 0x1d4d8:u'i', 0x1d4d9:u'j',
-0x1d4da:u'k', 0x1d4db:u'l', 0x1d4dc:u'm', 0x1d4dd:u'n',
-0x1d4de:u'o', 0x1d4df:u'p', 0x1d4e0:u'q', 0x1d4e1:u'r',
-0x1d4e2:u's', 0x1d4e3:u't', 0x1d4e4:u'u', 0x1d4e5:u'v',
-0x1d4e6:u'w', 0x1d4e7:u'x', 0x1d4e8:u'y', 0x1d4e9:u'z',
-0x1d504:u'a', 0x1d505:u'b', 0x1d507:u'd', 0x1d508:u'e',
-0x1d509:u'f', 0x1d50a:u'g', 0x1d50d:u'j', 0x1d50e:u'k',
-0x1d50f:u'l', 0x1d510:u'm', 0x1d511:u'n', 0x1d512:u'o',
-0x1d513:u'p', 0x1d514:u'q', 0x1d516:u's', 0x1d517:u't',
-0x1d518:u'u', 0x1d519:u'v', 0x1d51a:u'w', 0x1d51b:u'x',
-0x1d51c:u'y', 0x1d538:u'a', 0x1d539:u'b', 0x1d53b:u'd',
-0x1d53c:u'e', 0x1d53d:u'f', 0x1d53e:u'g', 0x1d540:u'i',
-0x1d541:u'j', 0x1d542:u'k', 0x1d543:u'l', 0x1d544:u'm',
-0x1d546:u'o', 0x1d54a:u's', 0x1d54b:u't', 0x1d54c:u'u',
-0x1d54d:u'v', 0x1d54e:u'w', 0x1d54f:u'x', 0x1d550:u'y',
-0x1d56c:u'a', 0x1d56d:u'b', 0x1d56e:u'c', 0x1d56f:u'd',
-0x1d570:u'e', 0x1d571:u'f', 0x1d572:u'g', 0x1d573:u'h',
-0x1d574:u'i', 0x1d575:u'j', 0x1d576:u'k', 0x1d577:u'l',
-0x1d578:u'm', 0x1d579:u'n', 0x1d57a:u'o', 0x1d57b:u'p',
-0x1d57c:u'q', 0x1d57d:u'r', 0x1d57e:u's', 0x1d57f:u't',
-0x1d580:u'u', 0x1d581:u'v', 0x1d582:u'w', 0x1d583:u'x',
-0x1d584:u'y', 0x1d585:u'z', 0x1d5a0:u'a', 0x1d5a1:u'b',
-0x1d5a2:u'c', 0x1d5a3:u'd', 0x1d5a4:u'e', 0x1d5a5:u'f',
-0x1d5a6:u'g', 0x1d5a7:u'h', 0x1d5a8:u'i', 0x1d5a9:u'j',
-0x1d5aa:u'k', 0x1d5ab:u'l', 0x1d5ac:u'm', 0x1d5ad:u'n',
-0x1d5ae:u'o', 0x1d5af:u'p', 0x1d5b0:u'q', 0x1d5b1:u'r',
-0x1d5b2:u's', 0x1d5b3:u't', 0x1d5b4:u'u', 0x1d5b5:u'v',
-0x1d5b6:u'w', 0x1d5b7:u'x', 0x1d5b8:u'y', 0x1d5b9:u'z',
-0x1d5d4:u'a', 0x1d5d5:u'b', 0x1d5d6:u'c', 0x1d5d7:u'd',
-0x1d5d8:u'e', 0x1d5d9:u'f', 0x1d5da:u'g', 0x1d5db:u'h',
-0x1d5dc:u'i', 0x1d5dd:u'j', 0x1d5de:u'k', 0x1d5df:u'l',
-0x1d5e0:u'm', 0x1d5e1:u'n', 0x1d5e2:u'o', 0x1d5e3:u'p',
-0x1d5e4:u'q', 0x1d5e5:u'r', 0x1d5e6:u's', 0x1d5e7:u't',
-0x1d5e8:u'u', 0x1d5e9:u'v', 0x1d5ea:u'w', 0x1d5eb:u'x',
-0x1d5ec:u'y', 0x1d5ed:u'z', 0x1d608:u'a', 0x1d609:u'b',
-0x1d60a:u'c', 0x1d60b:u'd', 0x1d60c:u'e', 0x1d60d:u'f',
-0x1d60e:u'g', 0x1d60f:u'h', 0x1d610:u'i', 0x1d611:u'j',
-0x1d612:u'k', 0x1d613:u'l', 0x1d614:u'm', 0x1d615:u'n',
-0x1d616:u'o', 0x1d617:u'p', 0x1d618:u'q', 0x1d619:u'r',
-0x1d61a:u's', 0x1d61b:u't', 0x1d61c:u'u', 0x1d61d:u'v',
-0x1d61e:u'w', 0x1d61f:u'x', 0x1d620:u'y', 0x1d621:u'z',
-0x1d63c:u'a', 0x1d63d:u'b', 0x1d63e:u'c', 0x1d63f:u'd',
-0x1d640:u'e', 0x1d641:u'f', 0x1d642:u'g', 0x1d643:u'h',
-0x1d644:u'i', 0x1d645:u'j', 0x1d646:u'k', 0x1d647:u'l',
-0x1d648:u'm', 0x1d649:u'n', 0x1d64a:u'o', 0x1d64b:u'p',
-0x1d64c:u'q', 0x1d64d:u'r', 0x1d64e:u's', 0x1d64f:u't',
-0x1d650:u'u', 0x1d651:u'v', 0x1d652:u'w', 0x1d653:u'x',
-0x1d654:u'y', 0x1d655:u'z', 0x1d670:u'a', 0x1d671:u'b',
-0x1d672:u'c', 0x1d673:u'd', 0x1d674:u'e', 0x1d675:u'f',
-0x1d676:u'g', 0x1d677:u'h', 0x1d678:u'i', 0x1d679:u'j',
-0x1d67a:u'k', 0x1d67b:u'l', 0x1d67c:u'm', 0x1d67d:u'n',
-0x1d67e:u'o', 0x1d67f:u'p', 0x1d680:u'q', 0x1d681:u'r',
-0x1d682:u's', 0x1d683:u't', 0x1d684:u'u', 0x1d685:u'v',
-0x1d686:u'w', 0x1d687:u'x', 0x1d688:u'y', 0x1d689:u'z',
-0x1d6a8:u'\u03b1', 0x1d6a9:u'\u03b2', 0x1d6aa:u'\u03b3', 0x1d6ab:u'\u03b4',
-0x1d6ac:u'\u03b5', 0x1d6ad:u'\u03b6', 0x1d6ae:u'\u03b7', 0x1d6af:u'\u03b8',
-0x1d6b0:u'\u03b9', 0x1d6b1:u'\u03ba', 0x1d6b2:u'\u03bb', 0x1d6b3:u'\u03bc',
-0x1d6b4:u'\u03bd', 0x1d6b5:u'\u03be', 0x1d6b6:u'\u03bf', 0x1d6b7:u'\u03c0',
-0x1d6b8:u'\u03c1', 0x1d6b9:u'\u03b8', 0x1d6ba:u'\u03c3', 0x1d6bb:u'\u03c4',
-0x1d6bc:u'\u03c5', 0x1d6bd:u'\u03c6', 0x1d6be:u'\u03c7', 0x1d6bf:u'\u03c8',
-0x1d6c0:u'\u03c9', 0x1d6d3:u'\u03c3', 0x1d6e2:u'\u03b1', 0x1d6e3:u'\u03b2',
-0x1d6e4:u'\u03b3', 0x1d6e5:u'\u03b4', 0x1d6e6:u'\u03b5', 0x1d6e7:u'\u03b6',
-0x1d6e8:u'\u03b7', 0x1d6e9:u'\u03b8', 0x1d6ea:u'\u03b9', 0x1d6eb:u'\u03ba',
-0x1d6ec:u'\u03bb', 0x1d6ed:u'\u03bc', 0x1d6ee:u'\u03bd', 0x1d6ef:u'\u03be',
-0x1d6f0:u'\u03bf', 0x1d6f1:u'\u03c0', 0x1d6f2:u'\u03c1', 0x1d6f3:u'\u03b8',
-0x1d6f4:u'\u03c3', 0x1d6f5:u'\u03c4', 0x1d6f6:u'\u03c5', 0x1d6f7:u'\u03c6',
-0x1d6f8:u'\u03c7', 0x1d6f9:u'\u03c8', 0x1d6fa:u'\u03c9', 0x1d70d:u'\u03c3',
-0x1d71c:u'\u03b1', 0x1d71d:u'\u03b2', 0x1d71e:u'\u03b3', 0x1d71f:u'\u03b4',
-0x1d720:u'\u03b5', 0x1d721:u'\u03b6', 0x1d722:u'\u03b7', 0x1d723:u'\u03b8',
-0x1d724:u'\u03b9', 0x1d725:u'\u03ba', 0x1d726:u'\u03bb', 0x1d727:u'\u03bc',
-0x1d728:u'\u03bd', 0x1d729:u'\u03be', 0x1d72a:u'\u03bf', 0x1d72b:u'\u03c0',
-0x1d72c:u'\u03c1', 0x1d72d:u'\u03b8', 0x1d72e:u'\u03c3', 0x1d72f:u'\u03c4',
-0x1d730:u'\u03c5', 0x1d731:u'\u03c6', 0x1d732:u'\u03c7', 0x1d733:u'\u03c8',
-0x1d734:u'\u03c9', 0x1d747:u'\u03c3', 0x1d756:u'\u03b1', 0x1d757:u'\u03b2',
-0x1d758:u'\u03b3', 0x1d759:u'\u03b4', 0x1d75a:u'\u03b5', 0x1d75b:u'\u03b6',
-0x1d75c:u'\u03b7', 0x1d75d:u'\u03b8', 0x1d75e:u'\u03b9', 0x1d75f:u'\u03ba',
-0x1d760:u'\u03bb', 0x1d761:u'\u03bc', 0x1d762:u'\u03bd', 0x1d763:u'\u03be',
-0x1d764:u'\u03bf', 0x1d765:u'\u03c0', 0x1d766:u'\u03c1', 0x1d767:u'\u03b8',
-0x1d768:u'\u03c3', 0x1d769:u'\u03c4', 0x1d76a:u'\u03c5', 0x1d76b:u'\u03c6',
-0x1d76c:u'\u03c7', 0x1d76d:u'\u03c8', 0x1d76e:u'\u03c9', 0x1d781:u'\u03c3',
-0x1d790:u'\u03b1', 0x1d791:u'\u03b2', 0x1d792:u'\u03b3', 0x1d793:u'\u03b4',
-0x1d794:u'\u03b5', 0x1d795:u'\u03b6', 0x1d796:u'\u03b7', 0x1d797:u'\u03b8',
-0x1d798:u'\u03b9', 0x1d799:u'\u03ba', 0x1d79a:u'\u03bb', 0x1d79b:u'\u03bc',
-0x1d79c:u'\u03bd', 0x1d79d:u'\u03be', 0x1d79e:u'\u03bf', 0x1d79f:u'\u03c0',
-0x1d7a0:u'\u03c1', 0x1d7a1:u'\u03b8', 0x1d7a2:u'\u03c3', 0x1d7a3:u'\u03c4',
-0x1d7a4:u'\u03c5', 0x1d7a5:u'\u03c6', 0x1d7a6:u'\u03c7', 0x1d7a7:u'\u03c8',
-0x1d7a8:u'\u03c9', 0x1d7bb:u'\u03c3', }
+0xb5:'\u03bc', 0xdf:'ss', 0x130:'i\u0307', 0x149:'\u02bcn',
+0x17f:'s', 0x1f0:'j\u030c', 0x345:'\u03b9', 0x37a:' \u03b9',
+0x390:'\u03b9\u0308\u0301', 0x3b0:'\u03c5\u0308\u0301', 0x3c2:'\u03c3', 0x3d0:'\u03b2',
+0x3d1:'\u03b8', 0x3d2:'\u03c5', 0x3d3:'\u03cd', 0x3d4:'\u03cb',
+0x3d5:'\u03c6', 0x3d6:'\u03c0', 0x3f0:'\u03ba', 0x3f1:'\u03c1',
+0x3f2:'\u03c3', 0x3f5:'\u03b5', 0x587:'\u0565\u0582', 0x1e96:'h\u0331',
+0x1e97:'t\u0308', 0x1e98:'w\u030a', 0x1e99:'y\u030a', 0x1e9a:'a\u02be',
+0x1e9b:'\u1e61', 0x1f50:'\u03c5\u0313', 0x1f52:'\u03c5\u0313\u0300', 0x1f54:'\u03c5\u0313\u0301',
+0x1f56:'\u03c5\u0313\u0342', 0x1f80:'\u1f00\u03b9', 0x1f81:'\u1f01\u03b9', 0x1f82:'\u1f02\u03b9',
+0x1f83:'\u1f03\u03b9', 0x1f84:'\u1f04\u03b9', 0x1f85:'\u1f05\u03b9', 0x1f86:'\u1f06\u03b9',
+0x1f87:'\u1f07\u03b9', 0x1f88:'\u1f00\u03b9', 0x1f89:'\u1f01\u03b9', 0x1f8a:'\u1f02\u03b9',
+0x1f8b:'\u1f03\u03b9', 0x1f8c:'\u1f04\u03b9', 0x1f8d:'\u1f05\u03b9', 0x1f8e:'\u1f06\u03b9',
+0x1f8f:'\u1f07\u03b9', 0x1f90:'\u1f20\u03b9', 0x1f91:'\u1f21\u03b9', 0x1f92:'\u1f22\u03b9',
+0x1f93:'\u1f23\u03b9', 0x1f94:'\u1f24\u03b9', 0x1f95:'\u1f25\u03b9', 0x1f96:'\u1f26\u03b9',
+0x1f97:'\u1f27\u03b9', 0x1f98:'\u1f20\u03b9', 0x1f99:'\u1f21\u03b9', 0x1f9a:'\u1f22\u03b9',
+0x1f9b:'\u1f23\u03b9', 0x1f9c:'\u1f24\u03b9', 0x1f9d:'\u1f25\u03b9', 0x1f9e:'\u1f26\u03b9',
+0x1f9f:'\u1f27\u03b9', 0x1fa0:'\u1f60\u03b9', 0x1fa1:'\u1f61\u03b9', 0x1fa2:'\u1f62\u03b9',
+0x1fa3:'\u1f63\u03b9', 0x1fa4:'\u1f64\u03b9', 0x1fa5:'\u1f65\u03b9', 0x1fa6:'\u1f66\u03b9',
+0x1fa7:'\u1f67\u03b9', 0x1fa8:'\u1f60\u03b9', 0x1fa9:'\u1f61\u03b9', 0x1faa:'\u1f62\u03b9',
+0x1fab:'\u1f63\u03b9', 0x1fac:'\u1f64\u03b9', 0x1fad:'\u1f65\u03b9', 0x1fae:'\u1f66\u03b9',
+0x1faf:'\u1f67\u03b9', 0x1fb2:'\u1f70\u03b9', 0x1fb3:'\u03b1\u03b9', 0x1fb4:'\u03ac\u03b9',
+0x1fb6:'\u03b1\u0342', 0x1fb7:'\u03b1\u0342\u03b9', 0x1fbc:'\u03b1\u03b9', 0x1fbe:'\u03b9',
+0x1fc2:'\u1f74\u03b9', 0x1fc3:'\u03b7\u03b9', 0x1fc4:'\u03ae\u03b9', 0x1fc6:'\u03b7\u0342',
+0x1fc7:'\u03b7\u0342\u03b9', 0x1fcc:'\u03b7\u03b9', 0x1fd2:'\u03b9\u0308\u0300', 0x1fd3:'\u03b9\u0308\u0301',
+0x1fd6:'\u03b9\u0342', 0x1fd7:'\u03b9\u0308\u0342', 0x1fe2:'\u03c5\u0308\u0300', 0x1fe3:'\u03c5\u0308\u0301',
+0x1fe4:'\u03c1\u0313', 0x1fe6:'\u03c5\u0342', 0x1fe7:'\u03c5\u0308\u0342', 0x1ff2:'\u1f7c\u03b9',
+0x1ff3:'\u03c9\u03b9', 0x1ff4:'\u03ce\u03b9', 0x1ff6:'\u03c9\u0342', 0x1ff7:'\u03c9\u0342\u03b9',
+0x1ffc:'\u03c9\u03b9', 0x20a8:'rs', 0x2102:'c', 0x2103:'\xb0c',
+0x2107:'\u025b', 0x2109:'\xb0f', 0x210b:'h', 0x210c:'h',
+0x210d:'h', 0x2110:'i', 0x2111:'i', 0x2112:'l',
+0x2115:'n', 0x2116:'no', 0x2119:'p', 0x211a:'q',
+0x211b:'r', 0x211c:'r', 0x211d:'r', 0x2120:'sm',
+0x2121:'tel', 0x2122:'tm', 0x2124:'z', 0x2128:'z',
+0x212c:'b', 0x212d:'c', 0x2130:'e', 0x2131:'f',
+0x2133:'m', 0x213e:'\u03b3', 0x213f:'\u03c0', 0x2145:'d',
+0x3371:'hpa', 0x3373:'au', 0x3375:'ov', 0x3380:'pa',
+0x3381:'na', 0x3382:'\u03bca', 0x3383:'ma', 0x3384:'ka',
+0x3385:'kb', 0x3386:'mb', 0x3387:'gb', 0x338a:'pf',
+0x338b:'nf', 0x338c:'\u03bcf', 0x3390:'hz', 0x3391:'khz',
+0x3392:'mhz', 0x3393:'ghz', 0x3394:'thz', 0x33a9:'pa',
+0x33aa:'kpa', 0x33ab:'mpa', 0x33ac:'gpa', 0x33b4:'pv',
+0x33b5:'nv', 0x33b6:'\u03bcv', 0x33b7:'mv', 0x33b8:'kv',
+0x33b9:'mv', 0x33ba:'pw', 0x33bb:'nw', 0x33bc:'\u03bcw',
+0x33bd:'mw', 0x33be:'kw', 0x33bf:'mw', 0x33c0:'k\u03c9',
+0x33c1:'m\u03c9', 0x33c3:'bq', 0x33c6:'c\u2215kg', 0x33c7:'co.',
+0x33c8:'db', 0x33c9:'gy', 0x33cb:'hp', 0x33cd:'kk',
+0x33ce:'km', 0x33d7:'ph', 0x33d9:'ppm', 0x33da:'pr',
+0x33dc:'sv', 0x33dd:'wb', 0xfb00:'ff', 0xfb01:'fi',
+0xfb02:'fl', 0xfb03:'ffi', 0xfb04:'ffl', 0xfb05:'st',
+0xfb06:'st', 0xfb13:'\u0574\u0576', 0xfb14:'\u0574\u0565', 0xfb15:'\u0574\u056b',
+0xfb16:'\u057e\u0576', 0xfb17:'\u0574\u056d', 0x1d400:'a', 0x1d401:'b',
+0x1d402:'c', 0x1d403:'d', 0x1d404:'e', 0x1d405:'f',
+0x1d406:'g', 0x1d407:'h', 0x1d408:'i', 0x1d409:'j',
+0x1d40a:'k', 0x1d40b:'l', 0x1d40c:'m', 0x1d40d:'n',
+0x1d40e:'o', 0x1d40f:'p', 0x1d410:'q', 0x1d411:'r',
+0x1d412:'s', 0x1d413:'t', 0x1d414:'u', 0x1d415:'v',
+0x1d416:'w', 0x1d417:'x', 0x1d418:'y', 0x1d419:'z',
+0x1d434:'a', 0x1d435:'b', 0x1d436:'c', 0x1d437:'d',
+0x1d438:'e', 0x1d439:'f', 0x1d43a:'g', 0x1d43b:'h',
+0x1d43c:'i', 0x1d43d:'j', 0x1d43e:'k', 0x1d43f:'l',
+0x1d440:'m', 0x1d441:'n', 0x1d442:'o', 0x1d443:'p',
+0x1d444:'q', 0x1d445:'r', 0x1d446:'s', 0x1d447:'t',
+0x1d448:'u', 0x1d449:'v', 0x1d44a:'w', 0x1d44b:'x',
+0x1d44c:'y', 0x1d44d:'z', 0x1d468:'a', 0x1d469:'b',
+0x1d46a:'c', 0x1d46b:'d', 0x1d46c:'e', 0x1d46d:'f',
+0x1d46e:'g', 0x1d46f:'h', 0x1d470:'i', 0x1d471:'j',
+0x1d472:'k', 0x1d473:'l', 0x1d474:'m', 0x1d475:'n',
+0x1d476:'o', 0x1d477:'p', 0x1d478:'q', 0x1d479:'r',
+0x1d47a:'s', 0x1d47b:'t', 0x1d47c:'u', 0x1d47d:'v',
+0x1d47e:'w', 0x1d47f:'x', 0x1d480:'y', 0x1d481:'z',
+0x1d49c:'a', 0x1d49e:'c', 0x1d49f:'d', 0x1d4a2:'g',
+0x1d4a5:'j', 0x1d4a6:'k', 0x1d4a9:'n', 0x1d4aa:'o',
+0x1d4ab:'p', 0x1d4ac:'q', 0x1d4ae:'s', 0x1d4af:'t',
+0x1d4b0:'u', 0x1d4b1:'v', 0x1d4b2:'w', 0x1d4b3:'x',
+0x1d4b4:'y', 0x1d4b5:'z', 0x1d4d0:'a', 0x1d4d1:'b',
+0x1d4d2:'c', 0x1d4d3:'d', 0x1d4d4:'e', 0x1d4d5:'f',
+0x1d4d6:'g', 0x1d4d7:'h', 0x1d4d8:'i', 0x1d4d9:'j',
+0x1d4da:'k', 0x1d4db:'l', 0x1d4dc:'m', 0x1d4dd:'n',
+0x1d4de:'o', 0x1d4df:'p', 0x1d4e0:'q', 0x1d4e1:'r',
+0x1d4e2:'s', 0x1d4e3:'t', 0x1d4e4:'u', 0x1d4e5:'v',
+0x1d4e6:'w', 0x1d4e7:'x', 0x1d4e8:'y', 0x1d4e9:'z',
+0x1d504:'a', 0x1d505:'b', 0x1d507:'d', 0x1d508:'e',
+0x1d509:'f', 0x1d50a:'g', 0x1d50d:'j', 0x1d50e:'k',
+0x1d50f:'l', 0x1d510:'m', 0x1d511:'n', 0x1d512:'o',
+0x1d513:'p', 0x1d514:'q', 0x1d516:'s', 0x1d517:'t',
+0x1d518:'u', 0x1d519:'v', 0x1d51a:'w', 0x1d51b:'x',
+0x1d51c:'y', 0x1d538:'a', 0x1d539:'b', 0x1d53b:'d',
+0x1d53c:'e', 0x1d53d:'f', 0x1d53e:'g', 0x1d540:'i',
+0x1d541:'j', 0x1d542:'k', 0x1d543:'l', 0x1d544:'m',
+0x1d546:'o', 0x1d54a:'s', 0x1d54b:'t', 0x1d54c:'u',
+0x1d54d:'v', 0x1d54e:'w', 0x1d54f:'x', 0x1d550:'y',
+0x1d56c:'a', 0x1d56d:'b', 0x1d56e:'c', 0x1d56f:'d',
+0x1d570:'e', 0x1d571:'f', 0x1d572:'g', 0x1d573:'h',
+0x1d574:'i', 0x1d575:'j', 0x1d576:'k', 0x1d577:'l',
+0x1d578:'m', 0x1d579:'n', 0x1d57a:'o', 0x1d57b:'p',
+0x1d57c:'q', 0x1d57d:'r', 0x1d57e:'s', 0x1d57f:'t',
+0x1d580:'u', 0x1d581:'v', 0x1d582:'w', 0x1d583:'x',
+0x1d584:'y', 0x1d585:'z', 0x1d5a0:'a', 0x1d5a1:'b',
+0x1d5a2:'c', 0x1d5a3:'d', 0x1d5a4:'e', 0x1d5a5:'f',
+0x1d5a6:'g', 0x1d5a7:'h', 0x1d5a8:'i', 0x1d5a9:'j',
+0x1d5aa:'k', 0x1d5ab:'l', 0x1d5ac:'m', 0x1d5ad:'n',
+0x1d5ae:'o', 0x1d5af:'p', 0x1d5b0:'q', 0x1d5b1:'r',
+0x1d5b2:'s', 0x1d5b3:'t', 0x1d5b4:'u', 0x1d5b5:'v',
+0x1d5b6:'w', 0x1d5b7:'x', 0x1d5b8:'y', 0x1d5b9:'z',
+0x1d5d4:'a', 0x1d5d5:'b', 0x1d5d6:'c', 0x1d5d7:'d',
+0x1d5d8:'e', 0x1d5d9:'f', 0x1d5da:'g', 0x1d5db:'h',
+0x1d5dc:'i', 0x1d5dd:'j', 0x1d5de:'k', 0x1d5df:'l',
+0x1d5e0:'m', 0x1d5e1:'n', 0x1d5e2:'o', 0x1d5e3:'p',
+0x1d5e4:'q', 0x1d5e5:'r', 0x1d5e6:'s', 0x1d5e7:'t',
+0x1d5e8:'u', 0x1d5e9:'v', 0x1d5ea:'w', 0x1d5eb:'x',
+0x1d5ec:'y', 0x1d5ed:'z', 0x1d608:'a', 0x1d609:'b',
+0x1d60a:'c', 0x1d60b:'d', 0x1d60c:'e', 0x1d60d:'f',
+0x1d60e:'g', 0x1d60f:'h', 0x1d610:'i', 0x1d611:'j',
+0x1d612:'k', 0x1d613:'l', 0x1d614:'m', 0x1d615:'n',
+0x1d616:'o', 0x1d617:'p', 0x1d618:'q', 0x1d619:'r',
+0x1d61a:'s', 0x1d61b:'t', 0x1d61c:'u', 0x1d61d:'v',
+0x1d61e:'w', 0x1d61f:'x', 0x1d620:'y', 0x1d621:'z',
+0x1d63c:'a', 0x1d63d:'b', 0x1d63e:'c', 0x1d63f:'d',
+0x1d640:'e', 0x1d641:'f', 0x1d642:'g', 0x1d643:'h',
+0x1d644:'i', 0x1d645:'j', 0x1d646:'k', 0x1d647:'l',
+0x1d648:'m', 0x1d649:'n', 0x1d64a:'o', 0x1d64b:'p',
+0x1d64c:'q', 0x1d64d:'r', 0x1d64e:'s', 0x1d64f:'t',
+0x1d650:'u', 0x1d651:'v', 0x1d652:'w', 0x1d653:'x',
+0x1d654:'y', 0x1d655:'z', 0x1d670:'a', 0x1d671:'b',
+0x1d672:'c', 0x1d673:'d', 0x1d674:'e', 0x1d675:'f',
+0x1d676:'g', 0x1d677:'h', 0x1d678:'i', 0x1d679:'j',
+0x1d67a:'k', 0x1d67b:'l', 0x1d67c:'m', 0x1d67d:'n',
+0x1d67e:'o', 0x1d67f:'p', 0x1d680:'q', 0x1d681:'r',
+0x1d682:'s', 0x1d683:'t', 0x1d684:'u', 0x1d685:'v',
+0x1d686:'w', 0x1d687:'x', 0x1d688:'y', 0x1d689:'z',
+0x1d6a8:'\u03b1', 0x1d6a9:'\u03b2', 0x1d6aa:'\u03b3', 0x1d6ab:'\u03b4',
+0x1d6ac:'\u03b5', 0x1d6ad:'\u03b6', 0x1d6ae:'\u03b7', 0x1d6af:'\u03b8',
+0x1d6b0:'\u03b9', 0x1d6b1:'\u03ba', 0x1d6b2:'\u03bb', 0x1d6b3:'\u03bc',
+0x1d6b4:'\u03bd', 0x1d6b5:'\u03be', 0x1d6b6:'\u03bf', 0x1d6b7:'\u03c0',
+0x1d6b8:'\u03c1', 0x1d6b9:'\u03b8', 0x1d6ba:'\u03c3', 0x1d6bb:'\u03c4',
+0x1d6bc:'\u03c5', 0x1d6bd:'\u03c6', 0x1d6be:'\u03c7', 0x1d6bf:'\u03c8',
+0x1d6c0:'\u03c9', 0x1d6d3:'\u03c3', 0x1d6e2:'\u03b1', 0x1d6e3:'\u03b2',
+0x1d6e4:'\u03b3', 0x1d6e5:'\u03b4', 0x1d6e6:'\u03b5', 0x1d6e7:'\u03b6',
+0x1d6e8:'\u03b7', 0x1d6e9:'\u03b8', 0x1d6ea:'\u03b9', 0x1d6eb:'\u03ba',
+0x1d6ec:'\u03bb', 0x1d6ed:'\u03bc', 0x1d6ee:'\u03bd', 0x1d6ef:'\u03be',
+0x1d6f0:'\u03bf', 0x1d6f1:'\u03c0', 0x1d6f2:'\u03c1', 0x1d6f3:'\u03b8',
+0x1d6f4:'\u03c3', 0x1d6f5:'\u03c4', 0x1d6f6:'\u03c5', 0x1d6f7:'\u03c6',
+0x1d6f8:'\u03c7', 0x1d6f9:'\u03c8', 0x1d6fa:'\u03c9', 0x1d70d:'\u03c3',
+0x1d71c:'\u03b1', 0x1d71d:'\u03b2', 0x1d71e:'\u03b3', 0x1d71f:'\u03b4',
+0x1d720:'\u03b5', 0x1d721:'\u03b6', 0x1d722:'\u03b7', 0x1d723:'\u03b8',
+0x1d724:'\u03b9', 0x1d725:'\u03ba', 0x1d726:'\u03bb', 0x1d727:'\u03bc',
+0x1d728:'\u03bd', 0x1d729:'\u03be', 0x1d72a:'\u03bf', 0x1d72b:'\u03c0',
+0x1d72c:'\u03c1', 0x1d72d:'\u03b8', 0x1d72e:'\u03c3', 0x1d72f:'\u03c4',
+0x1d730:'\u03c5', 0x1d731:'\u03c6', 0x1d732:'\u03c7', 0x1d733:'\u03c8',
+0x1d734:'\u03c9', 0x1d747:'\u03c3', 0x1d756:'\u03b1', 0x1d757:'\u03b2',
+0x1d758:'\u03b3', 0x1d759:'\u03b4', 0x1d75a:'\u03b5', 0x1d75b:'\u03b6',
+0x1d75c:'\u03b7', 0x1d75d:'\u03b8', 0x1d75e:'\u03b9', 0x1d75f:'\u03ba',
+0x1d760:'\u03bb', 0x1d761:'\u03bc', 0x1d762:'\u03bd', 0x1d763:'\u03be',
+0x1d764:'\u03bf', 0x1d765:'\u03c0', 0x1d766:'\u03c1', 0x1d767:'\u03b8',
+0x1d768:'\u03c3', 0x1d769:'\u03c4', 0x1d76a:'\u03c5', 0x1d76b:'\u03c6',
+0x1d76c:'\u03c7', 0x1d76d:'\u03c8', 0x1d76e:'\u03c9', 0x1d781:'\u03c3',
+0x1d790:'\u03b1', 0x1d791:'\u03b2', 0x1d792:'\u03b3', 0x1d793:'\u03b4',
+0x1d794:'\u03b5', 0x1d795:'\u03b6', 0x1d796:'\u03b7', 0x1d797:'\u03b8',
+0x1d798:'\u03b9', 0x1d799:'\u03ba', 0x1d79a:'\u03bb', 0x1d79b:'\u03bc',
+0x1d79c:'\u03bd', 0x1d79d:'\u03be', 0x1d79e:'\u03bf', 0x1d79f:'\u03c0',
+0x1d7a0:'\u03c1', 0x1d7a1:'\u03b8', 0x1d7a2:'\u03c3', 0x1d7a3:'\u03c4',
+0x1d7a4:'\u03c5', 0x1d7a5:'\u03c6', 0x1d7a6:'\u03c7', 0x1d7a7:'\u03c8',
+0x1d7a8:'\u03c9', 0x1d7bb:'\u03c3', }
def map_table_b3(code):
r = b3_exceptions.get(ord(code))
@@ -195,7 +195,7 @@ def map_table_b3(code):
def map_table_b2(a):
al = map_table_b3(a)
b = unicodedata.normalize("NFKC", al)
- bl = u"".join([map_table_b3(ch) for ch in b])
+ bl = "".join([map_table_b3(ch) for ch in b])
c = unicodedata.normalize("NFKC", bl)
if b != c:
return c
@@ -204,11 +204,11 @@ def map_table_b2(a):
def in_table_c11(code):
- return code == u" "
+ return code == " "
def in_table_c12(code):
- return unicodedata.category(code) == "Zs" and code != u" "
+ return unicodedata.category(code) == "Zs" and code != " "
def in_table_c11_c12(code):
return unicodedata.category(code) == "Zs"
@@ -217,7 +217,7 @@ def in_table_c11_c12(code):
def in_table_c21(code):
return ord(code) < 128 and unicodedata.category(code) == "Cc"
-c22_specials = set([1757, 1807, 6158, 8204, 8205, 8232, 8233, 65279] + range(8288,8292) + range(8298,8304) + range(65529,65533) + range(119155,119163))
+c22_specials = set([1757, 1807, 6158, 8204, 8205, 8232, 8233, 65279] + list(range(8288,8292)) + list(range(8298,8304)) + list(range(65529,65533)) + list(range(119155,119163)))
def in_table_c22(code):
c = ord(code)
if c < 128: return False
@@ -254,12 +254,12 @@ def in_table_c7(code):
return ord(code) in c7_set
-c8_set = set([832, 833, 8206, 8207] + range(8234,8239) + range(8298,8304))
+c8_set = set([832, 833, 8206, 8207] + list(range(8234,8239)) + list(range(8298,8304)))
def in_table_c8(code):
return ord(code) in c8_set
-c9_set = set([917505] + range(917536,917632))
+c9_set = set([917505] + list(range(917536,917632)))
def in_table_c9(code):
return ord(code) in c9_set
diff --git a/Lib/struct.py b/Lib/struct.py
index b022355c180..9bfc23f8d5b 100644
--- a/Lib/struct.py
+++ b/Lib/struct.py
@@ -1,3 +1,14 @@
+__all__ = [
+ # Functions
+ 'calcsize', 'pack', 'pack_into', 'unpack', 'unpack_from',
+
+ # Classes
+ 'Struct',
+
+ # Exceptions
+ 'error'
+ ]
+
from _struct import *
from _struct import _clearcache
from _struct import __doc__
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 19a51889ea1..f32f081e97d 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -2,8 +2,6 @@
#
# For more information about this module, see PEP 324.
#
-# This module should remain compatible with Python 2.2, see PEP 291.
-#
# Copyright (c) 2003-2005 by Peter Astrand <astrand@lysator.liu.se>
#
# Licensed to PSF under a Contributor Agreement.
@@ -17,9 +15,6 @@ intends to replace several other, older modules and functions, like:
os.system
os.spawn*
-os.popen*
-popen2.*
-commands.*
Information about how the subprocess module can be used to replace these
modules and functions can be found below.
@@ -32,9 +27,10 @@ This module defines one class called Popen:
class Popen(args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
+ preexec_fn=None, close_fds=True, shell=False,
cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0):
+ startupinfo=None, creationflags=0,
+ restore_signals=True, start_new_session=False, pass_fds=()):
Arguments are:
@@ -43,12 +39,12 @@ args should be a string, or a sequence of program arguments. The
program to execute is normally the first item in the args sequence or
string, but can be explicitly set by using the executable argument.
-On UNIX, with shell=False (default): In this case, the Popen class
+On POSIX, with shell=False (default): In this case, the Popen class
uses os.execvp() to execute the child program. args should normally
be a sequence. A string will be treated as a sequence with the string
as the only item (the program to execute).
-On UNIX, with shell=True: If args is a string, it specifies the
+On POSIX, with shell=True: If args is a string, it specifies the
command string to execute through the shell. If args is a sequence,
the first item specifies the command string, and any additional items
will be treated as additional shell arguments.
@@ -77,11 +73,19 @@ parent. Additionally, stderr can be STDOUT, which indicates that the
stderr data from the applications should be captured into the same
file handle as for stdout.
-If preexec_fn is set to a callable object, this object will be called
-in the child process just before the child is executed.
+On POSIX, if preexec_fn is set to a callable object, this object will be
+called in the child process just before the child is executed. The use
+of preexec_fn is not thread safe, using it in the presence of threads
+could lead to a deadlock in the child process before the new executable
+is executed.
If close_fds is true, all file descriptors except 0, 1 and 2 will be
-closed before the child process is executed.
+closed before the child process is executed. The default for close_fds
+varies by platform: Always true on POSIX. True when stdin/stdout/stderr
+are None on Windows, false otherwise.
+
+pass_fds is an optional sequence of file descriptors to keep open between the
+parent and child. Providing any pass_fds implicitly sets close_fds to true.
if shell is true, the specified command will be executed through the
shell.
@@ -89,12 +93,20 @@ shell.
If cwd is not None, the current directory will be changed to cwd
before the child is executed.
+On POSIX, if restore_signals is True all signals that Python sets to
+SIG_IGN are restored to SIG_DFL in the child process before the exec.
+Currently this includes the SIGPIPE, SIGXFZ and SIGXFSZ signals. This
+parameter does nothing on Windows.
+
+On POSIX, if start_new_session is True, the setsid() system call will be made
+in the child process prior to executing the command.
+
If env is not None, it defines the environment variables for the new
process.
If universal_newlines is true, the file objects stdout and stderr are
opened as a text files, but lines may be terminated by any of '\n',
-the Unix end-of-line convention, '\r', the Macintosh convention or
+the Unix end-of-line convention, '\r', the old Macintosh convention or
'\r\n', the Windows convention. All of these external representations
are seen as '\n' by the Python program. Note: This feature is only
available if Python is built with universal newline support (the
@@ -115,7 +127,7 @@ call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
- retcode = call(["ls", "-l"])
+ >>> retcode = subprocess.call(["ls", "-l"])
check_call(*popenargs, **kwargs):
Run command with arguments. Wait for command to complete. If the
@@ -125,7 +137,33 @@ check_call(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
- check_call(["ls", "-l"])
+ >>> subprocess.check_call(["ls", "-l"])
+ 0
+
+getstatusoutput(cmd):
+ Return (status, output) of executing cmd in a shell.
+
+ Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
+ (status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the
+ returned output will contain output or error messages. A trailing newline
+ is stripped from the output. The exit status for the command can be
+ interpreted according to the rules for the C function wait(). Example:
+
+ >>> subprocess.getstatusoutput('ls /bin/ls')
+ (0, '/bin/ls')
+ >>> subprocess.getstatusoutput('cat /bin/junk')
+ (256, 'cat: /bin/junk: No such file or directory')
+ >>> subprocess.getstatusoutput('/bin/junk')
+ (256, 'sh: /bin/junk: not found')
+
+getoutput(cmd):
+ Return output (stdout or stderr) of executing cmd in a shell.
+
+ Like getstatusoutput(), except the exit status is ignored and the return
+ value is a string containing the command's output. Example:
+
+ >>> subprocess.getoutput('ls /bin/ls')
+ '/bin/ls'
check_output(*popenargs, **kwargs):
Run command with arguments and return its output as a byte string.
@@ -136,7 +174,7 @@ check_output(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
- output = check_output(["ls", "-l", "/dev/null"])
+ >>> output = subprocess.check_output(["ls", "-l", "/dev/null"])
Exceptions
@@ -209,7 +247,7 @@ pid
returncode
The child return code. A None value indicates that the process
hasn't terminated yet. A negative value -N indicates that the
- child was terminated by signal N (UNIX only).
+ child was terminated by signal N (POSIX only).
Replacing older functions with the subprocess module
@@ -260,11 +298,11 @@ A more real-world example would look like this:
try:
retcode = call("mycmd" + " myarg", shell=True)
if retcode < 0:
- print >>sys.stderr, "Child was terminated by signal", -retcode
+ print("Child was terminated by signal", -retcode, file=sys.stderr)
else:
- print >>sys.stderr, "Child returned", retcode
-except OSError, e:
- print >>sys.stderr, "Execution failed:", e
+ print("Child returned", retcode, file=sys.stderr)
+except OSError as e:
+ print("Execution failed:", e, file=sys.stderr)
Replacing os.spawn*
@@ -295,107 +333,18 @@ Environment example:
os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env)
==>
Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})
-
-
-Replacing os.popen*
--------------------
-pipe = os.popen("cmd", mode='r', bufsize)
-==>
-pipe = Popen("cmd", shell=True, bufsize=bufsize, stdout=PIPE).stdout
-
-pipe = os.popen("cmd", mode='w', bufsize)
-==>
-pipe = Popen("cmd", shell=True, bufsize=bufsize, stdin=PIPE).stdin
-
-
-(child_stdin, child_stdout) = os.popen2("cmd", mode, bufsize)
-==>
-p = Popen("cmd", shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdin, child_stdout) = (p.stdin, p.stdout)
-
-
-(child_stdin,
- child_stdout,
- child_stderr) = os.popen3("cmd", mode, bufsize)
-==>
-p = Popen("cmd", shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
-(child_stdin,
- child_stdout,
- child_stderr) = (p.stdin, p.stdout, p.stderr)
-
-
-(child_stdin, child_stdout_and_stderr) = os.popen4("cmd", mode,
- bufsize)
-==>
-p = Popen("cmd", shell=True, bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
-(child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)
-
-On Unix, os.popen2, os.popen3 and os.popen4 also accept a sequence as
-the command to execute, in which case arguments will be passed
-directly to the program without shell intervention. This usage can be
-replaced as follows:
-
-(child_stdin, child_stdout) = os.popen2(["/bin/ls", "-l"], mode,
- bufsize)
-==>
-p = Popen(["/bin/ls", "-l"], bufsize=bufsize, stdin=PIPE, stdout=PIPE)
-(child_stdin, child_stdout) = (p.stdin, p.stdout)
-
-Return code handling translates as follows:
-
-pipe = os.popen("cmd", 'w')
-...
-rc = pipe.close()
-if rc is not None and rc % 256:
- print "There were some errors"
-==>
-process = Popen("cmd", 'w', shell=True, stdin=PIPE)
-...
-process.stdin.close()
-if process.wait() != 0:
- print "There were some errors"
-
-
-Replacing popen2.*
-------------------
-(child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode)
-==>
-p = Popen(["somestring"], shell=True, bufsize=bufsize
- stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
-
-On Unix, popen2 also accepts a sequence as the command to execute, in
-which case arguments will be passed directly to the program without
-shell intervention. This usage can be replaced as follows:
-
-(child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize,
- mode)
-==>
-p = Popen(["mycmd", "myarg"], bufsize=bufsize,
- stdin=PIPE, stdout=PIPE, close_fds=True)
-(child_stdout, child_stdin) = (p.stdout, p.stdin)
-
-The popen2.Popen3 and popen2.Popen4 basically works as subprocess.Popen,
-except that:
-
-* subprocess.Popen raises an exception if the execution fails
-* the capturestderr argument is replaced with the stderr argument.
-* stdin=PIPE and stdout=PIPE must be specified.
-* popen2 closes all filedescriptors by default, but you have to specify
- close_fds=True with subprocess.Popen.
"""
import sys
mswindows = (sys.platform == "win32")
+import io
import os
-import types
import traceback
import gc
import signal
+import builtins
+import warnings
import errno
# Exception classes used by this module.
@@ -431,14 +380,39 @@ else:
import fcntl
import pickle
+ try:
+ import _posixsubprocess
+ except ImportError:
+ _posixsubprocess = None
+ warnings.warn("The _posixsubprocess module is not being used. "
+ "Child process reliability may suffer if your "
+ "program uses threads.", RuntimeWarning)
+
# When select or poll has indicated that the file is writable,
# we can write up to _PIPE_BUF bytes without risk of blocking.
# POSIX defines PIPE_BUF as >= 512.
_PIPE_BUF = getattr(select, 'PIPE_BUF', 512)
+ _FD_CLOEXEC = getattr(fcntl, 'FD_CLOEXEC', 1)
-__all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call",
- "check_output", "CalledProcessError"]
+ def _set_cloexec(fd, cloexec):
+ old = fcntl.fcntl(fd, fcntl.F_GETFD)
+ if cloexec:
+ fcntl.fcntl(fd, fcntl.F_SETFD, old | _FD_CLOEXEC)
+ else:
+ fcntl.fcntl(fd, fcntl.F_SETFD, old & ~_FD_CLOEXEC)
+
+ if _posixsubprocess:
+ _create_pipe = _posixsubprocess.cloexec_pipe
+ else:
+ def _create_pipe():
+ fds = os.pipe()
+ _set_cloexec(fds[0], True)
+ _set_cloexec(fds[1], True)
+ return fds
+
+__all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call", "getstatusoutput",
+ "getoutput", "check_output", "CalledProcessError"]
if mswindows:
from _subprocess import (CREATE_NEW_CONSOLE, CREATE_NEW_PROCESS_GROUP,
@@ -455,11 +429,15 @@ try:
except:
MAXFD = 256
+# This lists holds Popen instances for which the underlying process had not
+# exited at the time its __del__ method got called: those processes are wait()ed
+# for synchronously from _cleanup() when a new Popen object is created, to avoid
+# zombie processes.
_active = []
def _cleanup():
for inst in _active[:]:
- res = inst._internal_poll(_deadstate=sys.maxint)
+ res = inst._internal_poll(_deadstate=sys.maxsize)
if res is not None:
try:
_active.remove(inst)
@@ -522,7 +500,7 @@ def check_output(*popenargs, **kwargs):
The arguments are the same as for the Popen constructor. Example:
>>> check_output(["ls", "-l", "/dev/null"])
- 'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
+ b'crw-rw-rw- 1 root root 1, 3 Oct 18 2007 /dev/null\n'
The stdout argument is not allowed as it is used internally.
To capture standard error in the result, use stderr=STDOUT.
@@ -530,11 +508,11 @@ def check_output(*popenargs, **kwargs):
>>> check_output(["/bin/sh", "-c",
... "ls -l non_existent_file ; exit 0"],
... stderr=STDOUT)
- 'ls: non_existent_file: No such file or directory\n'
+ b'ls: non_existent_file: No such file or directory\n'
"""
if 'stdout' in kwargs:
raise ValueError('stdout argument not allowed, it will be overridden.')
- process = Popen(stdout=PIPE, *popenargs, **kwargs)
+ process = Popen(*popenargs, stdout=PIPE, **kwargs)
output, unused_err = process.communicate()
retcode = process.poll()
if retcode:
@@ -615,29 +593,90 @@ def list2cmdline(seq):
return ''.join(result)
+# Various tools for executing commands and looking at their output and status.
+#
+# NB This only works (and is only relevant) for POSIX.
+
+def getstatusoutput(cmd):
+ """Return (status, output) of executing cmd in a shell.
+
+ Execute the string 'cmd' in a shell with os.popen() and return a 2-tuple
+ (status, output). cmd is actually run as '{ cmd ; } 2>&1', so that the
+ returned output will contain output or error messages. A trailing newline
+ is stripped from the output. The exit status for the command can be
+ interpreted according to the rules for the C function wait(). Example:
+
+ >>> import subprocess
+ >>> subprocess.getstatusoutput('ls /bin/ls')
+ (0, '/bin/ls')
+ >>> subprocess.getstatusoutput('cat /bin/junk')
+ (256, 'cat: /bin/junk: No such file or directory')
+ >>> subprocess.getstatusoutput('/bin/junk')
+ (256, 'sh: /bin/junk: not found')
+ """
+ pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r')
+ text = pipe.read()
+ sts = pipe.close()
+ if sts is None: sts = 0
+ if text[-1:] == '\n': text = text[:-1]
+ return sts, text
+
+
+def getoutput(cmd):
+ """Return output (stdout or stderr) of executing cmd in a shell.
+
+ Like getstatusoutput(), except the exit status is ignored and the return
+ value is a string containing the command's output. Example:
+
+ >>> import subprocess
+ >>> subprocess.getoutput('ls /bin/ls')
+ '/bin/ls'
+ """
+ return getstatusoutput(cmd)[1]
+
+
+_PLATFORM_DEFAULT_CLOSE_FDS = object()
+
+
class Popen(object):
def __init__(self, args, bufsize=0, executable=None,
stdin=None, stdout=None, stderr=None,
- preexec_fn=None, close_fds=False, shell=False,
- cwd=None, env=None, universal_newlines=False,
- startupinfo=None, creationflags=0):
+ preexec_fn=None, close_fds=_PLATFORM_DEFAULT_CLOSE_FDS,
+ shell=False, cwd=None, env=None, universal_newlines=False,
+ startupinfo=None, creationflags=0,
+ restore_signals=True, start_new_session=False,
+ pass_fds=()):
"""Create new Popen instance."""
_cleanup()
self._child_created = False
- if not isinstance(bufsize, (int, long)):
+ if bufsize is None:
+ bufsize = 0 # Restore default
+ if not isinstance(bufsize, int):
raise TypeError("bufsize must be an integer")
if mswindows:
if preexec_fn is not None:
raise ValueError("preexec_fn is not supported on Windows "
"platforms")
- if close_fds and (stdin is not None or stdout is not None or
- stderr is not None):
- raise ValueError("close_fds is not supported on Windows "
- "platforms if you redirect stdin/stdout/stderr")
+ any_stdio_set = (stdin is not None or stdout is not None or
+ stderr is not None)
+ if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+ if any_stdio_set:
+ close_fds = False
+ else:
+ close_fds = True
+ elif close_fds and any_stdio_set:
+ raise ValueError(
+ "close_fds is not supported on Windows platforms"
+ " if you redirect stdin/stdout/stderr")
else:
# POSIX
+ if close_fds is _PLATFORM_DEFAULT_CLOSE_FDS:
+ close_fds = True
+ if pass_fds and not close_fds:
+ warnings.warn("pass_fds overriding close_fds.", RuntimeWarning)
+ close_fds = True
if startupinfo is not None:
raise ValueError("startupinfo is only supported on Windows "
"platforms")
@@ -664,70 +703,89 @@ class Popen(object):
# On POSIX, the child objects are file descriptors. On
# Windows, these are Windows file handles. The parent objects
# are file descriptors on both platforms. The parent objects
- # are None when not using PIPEs. The child objects are None
+ # are -1 when not using PIPEs. The child objects are -1
# when not redirecting.
(p2cread, p2cwrite,
c2pread, c2pwrite,
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
+ # We wrap OS handles *before* launching the child, otherwise a
+ # quickly terminating child could make our fds unwrappable
+ # (see #8458).
+
+ if mswindows:
+ if p2cwrite != -1:
+ p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0)
+ if c2pread != -1:
+ c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0)
+ if errread != -1:
+ errread = msvcrt.open_osfhandle(errread.Detach(), 0)
+
+ if p2cwrite != -1:
+ self.stdin = io.open(p2cwrite, 'wb', bufsize)
+ if self.universal_newlines:
+ self.stdin = io.TextIOWrapper(self.stdin, write_through=True)
+ if c2pread != -1:
+ self.stdout = io.open(c2pread, 'rb', bufsize)
+ if universal_newlines:
+ self.stdout = io.TextIOWrapper(self.stdout)
+ if errread != -1:
+ self.stderr = io.open(errread, 'rb', bufsize)
+ if universal_newlines:
+ self.stderr = io.TextIOWrapper(self.stderr)
+
try:
self._execute_child(args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
+ pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite)
- except Exception:
- # Preserve original exception in case os.close raises.
- exc_type, exc_value, exc_trace = sys.exc_info()
+ errread, errwrite,
+ restore_signals, start_new_session)
+ except:
+ # Cleanup if the child failed starting.
+ for f in filter(None, (self.stdin, self.stdout, self.stderr)):
+ try:
+ f.close()
+ except EnvironmentError:
+ pass # Ignore EBADF or other errors.
+ # Make sure the child pipes are closed as well.
to_close = []
- # Only close the pipes we created.
if stdin == PIPE:
- to_close.extend((p2cread, p2cwrite))
+ to_close.append(p2cread)
if stdout == PIPE:
- to_close.extend((c2pread, c2pwrite))
+ to_close.append(c2pwrite)
if stderr == PIPE:
- to_close.extend((errread, errwrite))
-
+ to_close.append(errwrite)
for fd in to_close:
try:
os.close(fd)
except EnvironmentError:
pass
- raise exc_type, exc_value, exc_trace
+ raise
- if mswindows:
- if p2cwrite is not None:
- p2cwrite = msvcrt.open_osfhandle(p2cwrite.Detach(), 0)
- if c2pread is not None:
- c2pread = msvcrt.open_osfhandle(c2pread.Detach(), 0)
- if errread is not None:
- errread = msvcrt.open_osfhandle(errread.Detach(), 0)
-
- if p2cwrite is not None:
- self.stdin = os.fdopen(p2cwrite, 'wb', bufsize)
- if c2pread is not None:
- if universal_newlines:
- self.stdout = os.fdopen(c2pread, 'rU', bufsize)
- else:
- self.stdout = os.fdopen(c2pread, 'rb', bufsize)
- if errread is not None:
- if universal_newlines:
- self.stderr = os.fdopen(errread, 'rU', bufsize)
- else:
- self.stderr = os.fdopen(errread, 'rb', bufsize)
+ def _translate_newlines(self, data, encoding):
+ data = data.decode(encoding)
+ return data.replace("\r\n", "\n").replace("\r", "\n")
- def _translate_newlines(self, data):
- data = data.replace("\r\n", "\n")
- data = data.replace("\r", "\n")
- return data
+ def __enter__(self):
+ return self
+ def __exit__(self, type, value, traceback):
+ if self.stdout:
+ self.stdout.close()
+ if self.stderr:
+ self.stderr.close()
+ if self.stdin:
+ self.stdin.close()
+ # Wait for the process to terminate, to avoid zombies.
+ self.wait()
- def __del__(self, _maxint=sys.maxint, _active=_active):
+ def __del__(self, _maxsize=sys.maxsize, _active=_active):
# If __init__ hasn't had a chance to execute (e.g. if it
# was passed an undeclared keyword argument), we don't
# have a _child_created attribute at all.
@@ -735,7 +793,7 @@ class Popen(object):
# We didn't get to successfully create a child process.
return
# In case the child hasn't been waited on, check if it's done.
- self._internal_poll(_deadstate=_maxint)
+ self._internal_poll(_deadstate=_maxsize)
if self.returncode is None and _active is not None:
# Child is still running, keep us alive until we can wait on it.
_active.append(self)
@@ -788,11 +846,11 @@ class Popen(object):
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
"""
if stdin is None and stdout is None and stderr is None:
- return (None, None, None, None, None, None)
+ return (-1, -1, -1, -1, -1, -1)
- p2cread, p2cwrite = None, None
- c2pread, c2pwrite = None, None
- errread, errwrite = None, None
+ p2cread, p2cwrite = -1, -1
+ c2pread, c2pwrite = -1, -1
+ errread, errwrite = -1, -1
if stdin is None:
p2cread = _subprocess.GetStdHandle(_subprocess.STD_INPUT_HANDLE)
@@ -865,20 +923,23 @@ class Popen(object):
def _execute_child(self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
+ pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite):
+ errread, errwrite,
+ unused_restore_signals, unused_start_new_session):
"""Execute program (MS Windows version)"""
- if not isinstance(args, types.StringTypes):
+ assert not pass_fds, "pass_fds not supported on Windows."
+
+ if not isinstance(args, str):
args = list2cmdline(args)
# Process startup details
if startupinfo is None:
startupinfo = STARTUPINFO()
- if None not in (p2cread, c2pwrite, errwrite):
+ if -1 not in (p2cread, c2pwrite, errwrite):
startupinfo.dwFlags |= _subprocess.STARTF_USESTDHANDLES
startupinfo.hStdInput = p2cread
startupinfo.hStdOutput = c2pwrite
@@ -901,7 +962,7 @@ class Popen(object):
# cause random failures on win9x. Specifically a
# dialog: "Your program accessed mem currently in
# use at xxx" and a hopeful warning about the
- # stability of your system. Cost is Ctrl+C wont
+ # stability of your system. Cost is Ctrl+C won't
# kill children.
creationflags |= _subprocess.CREATE_NEW_CONSOLE
@@ -915,7 +976,7 @@ class Popen(object):
env,
cwd,
startupinfo)
- except pywintypes.error, e:
+ except pywintypes.error as e:
# Translate pywintypes.error to WindowsError, which is
# a subclass of OSError. FIXME: We should really
# translate errno using _sys_errlist (or similar), but
@@ -928,11 +989,11 @@ class Popen(object):
# output pipe are maintained in this process or else the
# pipe will not close when the child process exits and the
# ReadFile will hang.
- if p2cread is not None:
+ if p2cread != -1:
p2cread.Close()
- if c2pwrite is not None:
+ if c2pwrite != -1:
c2pwrite.Close()
- if errwrite is not None:
+ if errwrite != -1:
errwrite.Close()
# Retain the process handle, but close the thread handle
@@ -970,6 +1031,7 @@ class Popen(object):
def _readerthread(self, fh, buffer):
buffer.append(fh.read())
+ fh.close()
def _communicate(self, input):
@@ -980,13 +1042,13 @@ class Popen(object):
stdout = []
stdout_thread = threading.Thread(target=self._readerthread,
args=(self.stdout, stdout))
- stdout_thread.setDaemon(True)
+ stdout_thread.daemon = True
stdout_thread.start()
if self.stderr:
stderr = []
stderr_thread = threading.Thread(target=self._readerthread,
args=(self.stderr, stderr))
- stderr_thread.setDaemon(True)
+ stderr_thread.daemon = True
stderr_thread.start()
if self.stdin:
@@ -1009,16 +1071,6 @@ class Popen(object):
if stderr is not None:
stderr = stderr[0]
- # Translate newlines, if requested. We cannot let the file
- # object do the translation: It is based on stdio, which is
- # impossible to combine with select (unless forcing no
- # buffering).
- if self.universal_newlines and hasattr(file, 'newlines'):
- if stdout:
- stdout = self._translate_newlines(stdout)
- if stderr:
- stderr = self._translate_newlines(stderr)
-
self.wait()
return (stdout, stderr)
@@ -1059,14 +1111,14 @@ class Popen(object):
"""Construct and return tuple with IO objects:
p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite
"""
- p2cread, p2cwrite = None, None
- c2pread, c2pwrite = None, None
- errread, errwrite = None, None
+ p2cread, p2cwrite = -1, -1
+ c2pread, c2pwrite = -1, -1
+ errread, errwrite = -1, -1
if stdin is None:
pass
elif stdin == PIPE:
- p2cread, p2cwrite = self.pipe_cloexec()
+ p2cread, p2cwrite = _create_pipe()
elif isinstance(stdin, int):
p2cread = stdin
else:
@@ -1076,7 +1128,7 @@ class Popen(object):
if stdout is None:
pass
elif stdout == PIPE:
- c2pread, c2pwrite = self.pipe_cloexec()
+ c2pread, c2pwrite = _create_pipe()
elif isinstance(stdout, int):
c2pwrite = stdout
else:
@@ -1086,7 +1138,7 @@ class Popen(object):
if stderr is None:
pass
elif stderr == PIPE:
- errread, errwrite = self.pipe_cloexec()
+ errread, errwrite = _create_pipe()
elif stderr == STDOUT:
errwrite = c2pwrite
elif isinstance(stderr, int):
@@ -1100,54 +1152,26 @@ class Popen(object):
errread, errwrite)
- def _set_cloexec_flag(self, fd, cloexec=True):
- try:
- cloexec_flag = fcntl.FD_CLOEXEC
- except AttributeError:
- cloexec_flag = 1
-
- old = fcntl.fcntl(fd, fcntl.F_GETFD)
- if cloexec:
- fcntl.fcntl(fd, fcntl.F_SETFD, old | cloexec_flag)
- else:
- fcntl.fcntl(fd, fcntl.F_SETFD, old & ~cloexec_flag)
-
-
- def pipe_cloexec(self):
- """Create a pipe with FDs set CLOEXEC."""
- # Pipes' FDs are set CLOEXEC by default because we don't want them
- # to be inherited by other subprocesses: the CLOEXEC flag is removed
- # from the child's FDs by _dup2(), between fork() and exec().
- # This is not atomic: we would need the pipe2() syscall for that.
- r, w = os.pipe()
- self._set_cloexec_flag(r)
- self._set_cloexec_flag(w)
- return r, w
-
-
- def _close_fds(self, but):
- if hasattr(os, 'closerange'):
- os.closerange(3, but)
- os.closerange(but + 1, MAXFD)
- else:
- for i in xrange(3, MAXFD):
- if i == but:
- continue
- try:
- os.close(i)
- except:
- pass
+ def _close_fds(self, fds_to_keep):
+ start_fd = 3
+ for fd in sorted(fds_to_keep):
+ if fd >= start_fd:
+ os.closerange(start_fd, fd)
+ start_fd = fd + 1
+ if start_fd <= MAXFD:
+ os.closerange(start_fd, MAXFD)
def _execute_child(self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
+ pass_fds, cwd, env, universal_newlines,
startupinfo, creationflags, shell,
p2cread, p2cwrite,
c2pread, c2pwrite,
- errread, errwrite):
+ errread, errwrite,
+ restore_signals, start_new_session):
"""Execute program (POSIX version)"""
- if isinstance(args, types.StringTypes):
+ if isinstance(args, str):
args = [args]
else:
args = list(args)
@@ -1159,122 +1183,217 @@ class Popen(object):
if executable is None:
executable = args[0]
+ orig_executable = executable
- # For transferring possible exec failure from child to parent
- # The first char specifies the exception type: 0 means
- # OSError, 1 means some other error.
- errpipe_read, errpipe_write = self.pipe_cloexec()
+ # For transferring possible exec failure from child to parent.
+ # Data format: "exception name:hex errno:description"
+ # Pickle is not used; it is complex and involves memory allocation.
+ errpipe_read, errpipe_write = _create_pipe()
try:
try:
- gc_was_enabled = gc.isenabled()
- # Disable gc to avoid bug where gc -> file_dealloc ->
- # write to stderr -> hang. http://bugs.python.org/issue1336
- gc.disable()
- try:
- self.pid = os.fork()
- except:
- if gc_was_enabled:
- gc.enable()
- raise
- self._child_created = True
- if self.pid == 0:
- # Child
- try:
- # Close parent's pipe ends
- if p2cwrite is not None:
- os.close(p2cwrite)
- if c2pread is not None:
- os.close(c2pread)
- if errread is not None:
- os.close(errread)
- os.close(errpipe_read)
-
- # When duping fds, if there arises a situation
- # where one of the fds is either 0, 1 or 2, it
- # is possible that it is overwritten (#12607).
- if c2pwrite == 0:
- c2pwrite = os.dup(c2pwrite)
- if errwrite == 0 or errwrite == 1:
- errwrite = os.dup(errwrite)
-
- # Dup fds for child
- def _dup2(a, b):
- # dup2() removes the CLOEXEC flag but
- # we must do it ourselves if dup2()
- # would be a no-op (issue #10806).
- if a == b:
- self._set_cloexec_flag(a, False)
- elif a is not None:
- os.dup2(a, b)
- _dup2(p2cread, 0)
- _dup2(c2pwrite, 1)
- _dup2(errwrite, 2)
-
- # Close pipe fds. Make sure we don't close the
- # same fd more than once, or standard fds.
- closed = { None }
- for fd in [p2cread, c2pwrite, errwrite]:
- if fd not in closed and fd > 2:
- os.close(fd)
- closed.add(fd)
-
- # Close all other fds, if asked for
- if close_fds:
- self._close_fds(but=errpipe_write)
-
- if cwd is not None:
- os.chdir(cwd)
-
- if preexec_fn:
- preexec_fn()
-
- if env is None:
- os.execvp(executable, args)
- else:
- os.execvpe(executable, args, env)
+ if _posixsubprocess:
+ # We must avoid complex work that could involve
+ # malloc or free in the child process to avoid
+ # potential deadlocks, thus we do all this here.
+ # and pass it to fork_exec()
+
+ if env is not None:
+ env_list = [os.fsencode(k) + b'=' + os.fsencode(v)
+ for k, v in env.items()]
+ else:
+ env_list = None # Use execv instead of execve.
+ executable = os.fsencode(executable)
+ if os.path.dirname(executable):
+ executable_list = (executable,)
+ else:
+ # This matches the behavior of os._execvpe().
+ executable_list = tuple(
+ os.path.join(os.fsencode(dir), executable)
+ for dir in os.get_exec_path(env))
+ fds_to_keep = set(pass_fds)
+ fds_to_keep.add(errpipe_write)
+ self.pid = _posixsubprocess.fork_exec(
+ args, executable_list,
+ close_fds, sorted(fds_to_keep), cwd, env_list,
+ p2cread, p2cwrite, c2pread, c2pwrite,
+ errread, errwrite,
+ errpipe_read, errpipe_write,
+ restore_signals, start_new_session, preexec_fn)
+ self._child_created = True
+ else:
+ # Pure Python implementation: It is not thread safe.
+ # This implementation may deadlock in the child if your
+ # parent process has any other threads running.
+
+ gc_was_enabled = gc.isenabled()
+ # Disable gc to avoid bug where gc -> file_dealloc ->
+ # write to stderr -> hang. See issue1336
+ gc.disable()
+ try:
+ self.pid = os.fork()
except:
- exc_type, exc_value, tb = sys.exc_info()
- # Save the traceback and attach it to the exception object
- exc_lines = traceback.format_exception(exc_type,
- exc_value,
- tb)
- exc_value.child_traceback = ''.join(exc_lines)
- os.write(errpipe_write, pickle.dumps(exc_value))
-
- # This exitcode won't be reported to applications, so it
- # really doesn't matter what we return.
- os._exit(255)
-
- # Parent
- if gc_was_enabled:
- gc.enable()
+ if gc_was_enabled:
+ gc.enable()
+ raise
+ self._child_created = True
+ if self.pid == 0:
+ # Child
+ reached_preexec = False
+ try:
+ # Close parent's pipe ends
+ if p2cwrite != -1:
+ os.close(p2cwrite)
+ if c2pread != -1:
+ os.close(c2pread)
+ if errread != -1:
+ os.close(errread)
+ os.close(errpipe_read)
+
+ # When duping fds, if there arises a situation
+ # where one of the fds is either 0, 1 or 2, it
+ # is possible that it is overwritten (#12607).
+ if c2pwrite == 0:
+ c2pwrite = os.dup(c2pwrite)
+ if errwrite == 0 or errwrite == 1:
+ errwrite = os.dup(errwrite)
+
+ # Dup fds for child
+ def _dup2(a, b):
+ # dup2() removes the CLOEXEC flag but
+ # we must do it ourselves if dup2()
+ # would be a no-op (issue #10806).
+ if a == b:
+ _set_cloexec(a, False)
+ elif a != -1:
+ os.dup2(a, b)
+ _dup2(p2cread, 0)
+ _dup2(c2pwrite, 1)
+ _dup2(errwrite, 2)
+
+ # Close pipe fds. Make sure we don't close the
+ # same fd more than once, or standard fds.
+ closed = set()
+ for fd in [p2cread, c2pwrite, errwrite]:
+ if fd > 2 and fd not in closed:
+ os.close(fd)
+ closed.add(fd)
+
+ # Close all other fds, if asked for
+ if close_fds:
+ fds_to_keep = set(pass_fds)
+ fds_to_keep.add(errpipe_write)
+ self._close_fds(fds_to_keep)
+
+
+ if cwd is not None:
+ os.chdir(cwd)
+
+ # This is a copy of Python/pythonrun.c
+ # _Py_RestoreSignals(). If that were exposed
+ # as a sys._py_restoresignals func it would be
+ # better.. but this pure python implementation
+ # isn't likely to be used much anymore.
+ if restore_signals:
+ signals = ('SIGPIPE', 'SIGXFZ', 'SIGXFSZ')
+ for sig in signals:
+ if hasattr(signal, sig):
+ signal.signal(getattr(signal, sig),
+ signal.SIG_DFL)
+
+ if start_new_session and hasattr(os, 'setsid'):
+ os.setsid()
+
+ reached_preexec = True
+ if preexec_fn:
+ preexec_fn()
+
+ if env is None:
+ os.execvp(executable, args)
+ else:
+ os.execvpe(executable, args, env)
+
+ except:
+ try:
+ exc_type, exc_value = sys.exc_info()[:2]
+ if isinstance(exc_value, OSError):
+ errno_num = exc_value.errno
+ else:
+ errno_num = 0
+ if not reached_preexec:
+ exc_value = "noexec"
+ message = '%s:%x:%s' % (exc_type.__name__,
+ errno_num, exc_value)
+ message = message.encode(errors="surrogatepass")
+ os.write(errpipe_write, message)
+ except Exception:
+ # We MUST not allow anything odd happening
+ # above to prevent us from exiting below.
+ pass
+
+ # This exitcode won't be reported to applications
+ # so it really doesn't matter what we return.
+ os._exit(255)
+
+ # Parent
+ if gc_was_enabled:
+ gc.enable()
finally:
# be sure the FD is closed no matter what
os.close(errpipe_write)
- if p2cread is not None and p2cwrite is not None:
+ if p2cread != -1 and p2cwrite != -1:
os.close(p2cread)
- if c2pwrite is not None and c2pread is not None:
+ if c2pwrite != -1 and c2pread != -1:
os.close(c2pwrite)
- if errwrite is not None and errread is not None:
+ if errwrite != -1 and errread != -1:
os.close(errwrite)
- # Wait for exec to fail or succeed; possibly raising exception
- # Exception limited to 1M
- data = _eintr_retry_call(os.read, errpipe_read, 1048576)
+ # Wait for exec to fail or succeed; possibly raising an
+ # exception (limited in size)
+ errpipe_data = bytearray()
+ while True:
+ part = _eintr_retry_call(os.read, errpipe_read, 50000)
+ errpipe_data += part
+ if not part or len(errpipe_data) > 50000:
+ break
finally:
# be sure the FD is closed no matter what
os.close(errpipe_read)
- if data != "":
+ if errpipe_data:
try:
_eintr_retry_call(os.waitpid, self.pid, 0)
except OSError as e:
if e.errno != errno.ECHILD:
raise
- child_exception = pickle.loads(data)
- raise child_exception
+ try:
+ exception_name, hex_errno, err_msg = (
+ errpipe_data.split(b':', 2))
+ except ValueError:
+ exception_name = b'RuntimeError'
+ hex_errno = b'0'
+ err_msg = (b'Bad exception data from child: ' +
+ repr(errpipe_data))
+ child_exception_type = getattr(
+ builtins, exception_name.decode('ascii'),
+ RuntimeError)
+ err_msg = err_msg.decode(errors="surrogatepass")
+ if issubclass(child_exception_type, OSError) and hex_errno:
+ errno_num = int(hex_errno, 16)
+ child_exec_never_called = (err_msg == "noexec")
+ if child_exec_never_called:
+ err_msg = ""
+ if errno_num != 0:
+ err_msg = os.strerror(errno_num)
+ if errno_num == errno.ENOENT:
+ if child_exec_never_called:
+ # The error must be from chdir(cwd).
+ err_msg += ': ' + repr(cwd)
+ else:
+ err_msg += ': ' + repr(orig_executable)
+ raise child_exception_type(errno_num, err_msg)
+ raise child_exception_type(err_msg)
def _handle_exitstatus(self, sts, _WIFSIGNALED=os.WIFSIGNALED,
@@ -1308,7 +1427,7 @@ class Popen(object):
except _os_error as e:
if _deadstate is not None:
self.returncode = _deadstate
- if e.errno == _ECHILD:
+ elif e.errno == _ECHILD:
# This happens if SIGCLD is set to be ignored or
# waiting for child processes has otherwise been
# disabled for our process. This child is dead, we
@@ -1354,19 +1473,19 @@ class Popen(object):
# All data exchanged. Translate lists into strings.
if stdout is not None:
- stdout = ''.join(stdout)
+ stdout = b''.join(stdout)
if stderr is not None:
- stderr = ''.join(stderr)
-
- # Translate newlines, if requested. We cannot let the file
- # object do the translation: It is based on stdio, which is
- # impossible to combine with select (unless forcing no
- # buffering).
- if self.universal_newlines and hasattr(file, 'newlines'):
- if stdout:
- stdout = self._translate_newlines(stdout)
- if stderr:
- stderr = self._translate_newlines(stderr)
+ stderr = b''.join(stderr)
+
+ # Translate newlines, if requested.
+ # This also turns bytes into strings.
+ if self.universal_newlines:
+ if stdout is not None:
+ stdout = self._translate_newlines(stdout,
+ self.stdout.encoding)
+ if stderr is not None:
+ stderr = self._translate_newlines(stderr,
+ self.stderr.encoding)
self.wait()
return (stdout, stderr)
@@ -1403,11 +1522,14 @@ class Popen(object):
while fd2file:
try:
ready = poller.poll()
- except select.error, e:
+ except select.error as e:
if e.args[0] == errno.EINTR:
continue
raise
+ # XXX Rewrite these to use non-blocking I/O on the
+ # file objects; they are no longer using C stdio!
+
for fd, mode in ready:
if mode & select.POLLOUT:
chunk = input[input_offset : input_offset + _PIPE_BUF]
@@ -1452,11 +1574,14 @@ class Popen(object):
while read_set or write_set:
try:
rlist, wlist, xlist = select.select(read_set, write_set, [])
- except select.error, e:
+ except select.error as e:
if e.args[0] == errno.EINTR:
continue
raise
+ # XXX Rewrite these to use non-blocking I/O on the
+ # file objects; they are no longer using C stdio!
+
if self.stdin in wlist:
chunk = input[input_offset : input_offset + _PIPE_BUF]
try:
@@ -1475,14 +1600,14 @@ class Popen(object):
if self.stdout in rlist:
data = os.read(self.stdout.fileno(), 1024)
- if data == "":
+ if not data:
self.stdout.close()
read_set.remove(self.stdout)
stdout.append(data)
if self.stderr in rlist:
data = os.read(self.stderr.fileno(), 1024)
- if data == "":
+ if not data:
self.stderr.close()
read_set.remove(self.stderr)
stderr.append(data)
@@ -1511,8 +1636,8 @@ def _demo_posix():
# Example 1: Simple redirection: Get process list
#
plist = Popen(["ps"], stdout=PIPE).communicate()[0]
- print "Process list:"
- print plist
+ print("Process list:")
+ print(plist)
#
# Example 2: Change uid before executing child
@@ -1524,42 +1649,42 @@ def _demo_posix():
#
# Example 3: Connecting several subprocesses
#
- print "Looking for 'hda'..."
+ print("Looking for 'hda'...")
p1 = Popen(["dmesg"], stdout=PIPE)
p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
- print repr(p2.communicate()[0])
+ print(repr(p2.communicate()[0]))
#
# Example 4: Catch execution error
#
- print
- print "Trying a weird file..."
+ print()
+ print("Trying a weird file...")
try:
- print Popen(["/this/path/does/not/exist"]).communicate()
- except OSError, e:
+ print(Popen(["/this/path/does/not/exist"]).communicate())
+ except OSError as e:
if e.errno == errno.ENOENT:
- print "The file didn't exist. I thought so..."
- print "Child traceback:"
- print e.child_traceback
+ print("The file didn't exist. I thought so...")
+ print("Child traceback:")
+ print(e.child_traceback)
else:
- print "Error", e.errno
+ print("Error", e.errno)
else:
- print >>sys.stderr, "Gosh. No error."
+ print("Gosh. No error.", file=sys.stderr)
def _demo_windows():
#
# Example 1: Connecting several subprocesses
#
- print "Looking for 'PROMPT' in set output..."
+ print("Looking for 'PROMPT' in set output...")
p1 = Popen("set", stdout=PIPE, shell=True)
p2 = Popen('find "PROMPT"', stdin=p1.stdout, stdout=PIPE)
- print repr(p2.communicate()[0])
+ print(repr(p2.communicate()[0]))
#
# Example 2: Simple execution of program
#
- print "Executing calc..."
+ print("Executing calc...")
p = Popen("calc")
p.wait()
diff --git a/Lib/sunau.py b/Lib/sunau.py
index a04d8c01314..6775a53cf73 100644
--- a/Lib/sunau.py
+++ b/Lib/sunau.py
@@ -119,7 +119,7 @@ AUDIO_FILE_ENCODING_ADPCM_G723_5 = 26
AUDIO_FILE_ENCODING_ALAW_8 = 27
# from <multimedia/audio_hdr.h>
-AUDIO_UNKNOWN_SIZE = 0xFFFFFFFFL # ((unsigned)(~0))
+AUDIO_UNKNOWN_SIZE = 0xFFFFFFFF # ((unsigned)(~0))
_simple_encodings = [AUDIO_FILE_ENCODING_MULAW_8,
AUDIO_FILE_ENCODING_LINEAR_8,
@@ -132,10 +132,10 @@ class Error(Exception):
pass
def _read_u32(file):
- x = 0L
+ x = 0
for i in range(4):
byte = file.read(1)
- if byte == '':
+ if not byte:
raise EOFError
x = x*256 + ord(byte)
return x
@@ -144,17 +144,19 @@ def _write_u32(file, x):
data = []
for i in range(4):
d, m = divmod(x, 256)
- data.insert(0, m)
+ data.insert(0, int(m))
x = d
- for i in range(4):
- file.write(chr(int(data[i])))
+ file.write(bytes(data))
class Au_read:
def __init__(self, f):
if type(f) == type(''):
- import __builtin__
- f = __builtin__.open(f, 'rb')
+ import builtins
+ f = builtins.open(f, 'rb')
+ self._opened = True
+ else:
+ self._opened = False
self.initfp(f)
def __del__(self):
@@ -166,18 +168,18 @@ class Au_read:
self._soundpos = 0
magic = int(_read_u32(file))
if magic != AUDIO_FILE_MAGIC:
- raise Error, 'bad magic number'
+ raise Error('bad magic number')
self._hdr_size = int(_read_u32(file))
if self._hdr_size < 24:
- raise Error, 'header size too small'
+ raise Error('header size too small')
if self._hdr_size > 100:
- raise Error, 'header size ridiculously large'
+ raise Error('header size ridiculously large')
self._data_size = _read_u32(file)
if self._data_size != AUDIO_UNKNOWN_SIZE:
self._data_size = int(self._data_size)
self._encoding = int(_read_u32(file))
if self._encoding not in _simple_encodings:
- raise Error, 'encoding not (yet) supported'
+ raise Error('encoding not (yet) supported')
if self._encoding in (AUDIO_FILE_ENCODING_MULAW_8,
AUDIO_FILE_ENCODING_ALAW_8):
self._sampwidth = 2
@@ -191,14 +193,14 @@ class Au_read:
elif self._encoding == AUDIO_FILE_ENCODING_LINEAR_32:
self._framesize = self._sampwidth = 4
else:
- raise Error, 'unknown encoding'
+ raise Error('unknown encoding')
self._framerate = int(_read_u32(file))
self._nchannels = int(_read_u32(file))
self._framesize = self._framesize * self._nchannels
if self._hdr_size > 24:
self._info = file.read(self._hdr_size - 24)
for i in range(len(self._info)):
- if self._info[i] == '\0':
+ if self._info[i] == b'\0':
self._info = self._info[:i]
break
else:
@@ -248,7 +250,7 @@ class Au_read:
return None
def getmark(self, id):
- raise Error, 'no marks'
+ raise Error('no marks')
def readframes(self, nframes):
if self._encoding in _simple_encodings:
@@ -271,24 +273,30 @@ class Au_read:
def setpos(self, pos):
if pos < 0 or pos > self.getnframes():
- raise Error, 'position not in range'
+ raise Error('position not in range')
self._file.seek(pos * self._framesize + self._hdr_size)
self._soundpos = pos
def close(self):
+ if self._opened and self._file:
+ self._file.close()
self._file = None
class Au_write:
def __init__(self, f):
if type(f) == type(''):
- import __builtin__
- f = __builtin__.open(f, 'wb')
+ import builtins
+ f = builtins.open(f, 'wb')
+ self._opened = True
+ else:
+ self._opened = False
self.initfp(f)
def __del__(self):
if self._file:
self.close()
+ self._file = None
def initfp(self, file):
self._file = file
@@ -300,48 +308,48 @@ class Au_write:
self._nframeswritten = 0
self._datawritten = 0
self._datalength = 0
- self._info = ''
+ self._info = b''
self._comptype = 'ULAW' # default is U-law
def setnchannels(self, nchannels):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if nchannels not in (1, 2, 4):
- raise Error, 'only 1, 2, or 4 channels supported'
+ raise Error('only 1, 2, or 4 channels supported')
self._nchannels = nchannels
def getnchannels(self):
if not self._nchannels:
- raise Error, 'number of channels not set'
+ raise Error('number of channels not set')
return self._nchannels
def setsampwidth(self, sampwidth):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if sampwidth not in (1, 2, 4):
- raise Error, 'bad sample width'
+ raise Error('bad sample width')
self._sampwidth = sampwidth
def getsampwidth(self):
if not self._framerate:
- raise Error, 'sample width not specified'
+ raise Error('sample width not specified')
return self._sampwidth
def setframerate(self, framerate):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self._framerate = framerate
def getframerate(self):
if not self._framerate:
- raise Error, 'frame rate not set'
+ raise Error('frame rate not set')
return self._framerate
def setnframes(self, nframes):
if self._nframeswritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if nframes < 0:
- raise Error, '# of frames cannot be negative'
+ raise Error('# of frames cannot be negative')
self._nframes = nframes
def getnframes(self):
@@ -351,7 +359,7 @@ class Au_write:
if type in ('NONE', 'ULAW'):
self._comptype = type
else:
- raise Error, 'unknown compression type'
+ raise Error('unknown compression type')
def getcomptype(self):
return self._comptype
@@ -402,6 +410,8 @@ class Au_write:
self._datalength != self._datawritten:
self._patchheader()
self._file.flush()
+ if self._opened and self._file:
+ self._file.close()
self._file = None
#
@@ -411,11 +421,11 @@ class Au_write:
def _ensure_header_written(self):
if not self._nframeswritten:
if not self._nchannels:
- raise Error, '# of channels not specified'
+ raise Error('# of channels not specified')
if not self._sampwidth:
- raise Error, 'sample width not specified'
+ raise Error('sample width not specified')
if not self._framerate:
- raise Error, 'frame rate not specified'
+ raise Error('frame rate not specified')
self._write_header()
def _write_header(self):
@@ -430,12 +440,12 @@ class Au_write:
encoding = AUDIO_FILE_ENCODING_LINEAR_32
self._framesize = 4
else:
- raise Error, 'internal error'
+ raise Error('internal error')
elif self._comptype == 'ULAW':
encoding = AUDIO_FILE_ENCODING_MULAW_8
self._framesize = 1
else:
- raise Error, 'internal error'
+ raise Error('internal error')
self._framesize = self._framesize * self._nchannels
_write_u32(self._file, AUDIO_FILE_MAGIC)
header_size = 25 + len(self._info)
@@ -451,7 +461,7 @@ class Au_write:
_write_u32(self._file, self._framerate)
_write_u32(self._file, self._nchannels)
self._file.write(self._info)
- self._file.write('\0'*(header_size - len(self._info) - 24))
+ self._file.write(b'\0'*(header_size - len(self._info) - 24))
def _patchheader(self):
self._file.seek(8)
@@ -470,6 +480,6 @@ def open(f, mode=None):
elif mode in ('w', 'wb'):
return Au_write(f)
else:
- raise Error, "mode must be 'r', 'rb', 'w', or 'wb'"
+ raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
openfp = open
diff --git a/Lib/sunaudio.py b/Lib/sunaudio.py
deleted file mode 100644
index 97d7332c485..00000000000
--- a/Lib/sunaudio.py
+++ /dev/null
@@ -1,49 +0,0 @@
-"""Interpret sun audio headers."""
-from warnings import warnpy3k
-warnpy3k("the sunaudio module has been removed in Python 3.0; "
- "use the sunau module instead", stacklevel=2)
-del warnpy3k
-
-
-MAGIC = '.snd'
-
-class error(Exception):
- pass
-
-
-def get_long_be(s):
- """Convert a 4-char value to integer."""
- return (ord(s[0])<<24) | (ord(s[1])<<16) | (ord(s[2])<<8) | ord(s[3])
-
-
-def gethdr(fp):
- """Read a sound header from an open file."""
- if fp.read(4) != MAGIC:
- raise error, 'gethdr: bad magic word'
- hdr_size = get_long_be(fp.read(4))
- data_size = get_long_be(fp.read(4))
- encoding = get_long_be(fp.read(4))
- sample_rate = get_long_be(fp.read(4))
- channels = get_long_be(fp.read(4))
- excess = hdr_size - 24
- if excess < 0:
- raise error, 'gethdr: bad hdr_size'
- if excess > 0:
- info = fp.read(excess)
- else:
- info = ''
- return (data_size, encoding, sample_rate, channels, info)
-
-
-def printhdr(file):
- """Read and print the sound header of a named file."""
- hdr = gethdr(open(file, 'r'))
- data_size, encoding, sample_rate, channels, info = hdr
- while info[-1:] == '\0':
- info = info[:-1]
- print 'File name: ', file
- print 'Data size: ', data_size
- print 'Encoding: ', encoding
- print 'Sample rate:', sample_rate
- print 'Channels: ', channels
- print 'Info: ', repr(info)
diff --git a/Lib/symbol.py b/Lib/symbol.py
index b4d4e13ab80..679e5c8cc7e 100755
--- a/Lib/symbol.py
+++ b/Lib/symbol.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Non-terminal symbols of Python grammar (from "graminit.h")."""
@@ -18,64 +18,64 @@ decorators = 260
decorated = 261
funcdef = 262
parameters = 263
-varargslist = 264
-fpdef = 265
-fplist = 266
-stmt = 267
-simple_stmt = 268
-small_stmt = 269
-expr_stmt = 270
-augassign = 271
-print_stmt = 272
-del_stmt = 273
-pass_stmt = 274
-flow_stmt = 275
-break_stmt = 276
-continue_stmt = 277
-return_stmt = 278
-yield_stmt = 279
-raise_stmt = 280
-import_stmt = 281
-import_name = 282
-import_from = 283
-import_as_name = 284
-dotted_as_name = 285
-import_as_names = 286
-dotted_as_names = 287
-dotted_name = 288
-global_stmt = 289
-exec_stmt = 290
-assert_stmt = 291
-compound_stmt = 292
-if_stmt = 293
-while_stmt = 294
-for_stmt = 295
-try_stmt = 296
-with_stmt = 297
-with_item = 298
-except_clause = 299
-suite = 300
-testlist_safe = 301
-old_test = 302
-old_lambdef = 303
-test = 304
-or_test = 305
-and_test = 306
-not_test = 307
-comparison = 308
-comp_op = 309
-expr = 310
-xor_expr = 311
-and_expr = 312
-shift_expr = 313
-arith_expr = 314
-term = 315
-factor = 316
-power = 317
-atom = 318
-listmaker = 319
-testlist_comp = 320
-lambdef = 321
+typedargslist = 264
+tfpdef = 265
+varargslist = 266
+vfpdef = 267
+stmt = 268
+simple_stmt = 269
+small_stmt = 270
+expr_stmt = 271
+testlist_star_expr = 272
+augassign = 273
+del_stmt = 274
+pass_stmt = 275
+flow_stmt = 276
+break_stmt = 277
+continue_stmt = 278
+return_stmt = 279
+yield_stmt = 280
+raise_stmt = 281
+import_stmt = 282
+import_name = 283
+import_from = 284
+import_as_name = 285
+dotted_as_name = 286
+import_as_names = 287
+dotted_as_names = 288
+dotted_name = 289
+global_stmt = 290
+nonlocal_stmt = 291
+assert_stmt = 292
+compound_stmt = 293
+if_stmt = 294
+while_stmt = 295
+for_stmt = 296
+try_stmt = 297
+with_stmt = 298
+with_item = 299
+except_clause = 300
+suite = 301
+test = 302
+test_nocond = 303
+lambdef = 304
+lambdef_nocond = 305
+or_test = 306
+and_test = 307
+not_test = 308
+comparison = 309
+comp_op = 310
+star_expr = 311
+expr = 312
+xor_expr = 313
+and_expr = 314
+shift_expr = 315
+arith_expr = 316
+term = 317
+factor = 318
+power = 319
+atom = 320
+testlist_comp = 321
trailer = 322
subscriptlist = 323
subscript = 324
@@ -86,19 +86,15 @@ dictorsetmaker = 328
classdef = 329
arglist = 330
argument = 331
-list_iter = 332
-list_for = 333
-list_if = 334
-comp_iter = 335
-comp_for = 336
-comp_if = 337
-testlist1 = 338
-encoding_decl = 339
-yield_expr = 340
+comp_iter = 332
+comp_for = 333
+comp_if = 334
+encoding_decl = 335
+yield_expr = 336
#--end constants--
sym_name = {}
-for _name, _value in globals().items():
+for _name, _value in list(globals().items()):
if type(_value) is type(0):
sym_name[_value] = _name
diff --git a/Lib/symtable.py b/Lib/symtable.py
index ca73f586511..39c1a8014fc 100644
--- a/Lib/symtable.py
+++ b/Lib/symtable.py
@@ -2,8 +2,8 @@
import _symtable
from _symtable import (USE, DEF_GLOBAL, DEF_LOCAL, DEF_PARAM,
- DEF_IMPORT, DEF_BOUND, OPT_IMPORT_STAR, OPT_EXEC, OPT_BARE_EXEC,
- SCOPE_OFF, SCOPE_MASK, FREE, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL, LOCAL)
+ DEF_IMPORT, DEF_BOUND, OPT_IMPORT_STAR, SCOPE_OFF, SCOPE_MASK, FREE,
+ LOCAL, GLOBAL_IMPLICIT, GLOBAL_EXPLICIT, CELL)
import weakref
@@ -11,7 +11,7 @@ __all__ = ["symtable", "SymbolTable", "Class", "Function", "Symbol"]
def symtable(code, filename, compile_type):
raw = _symtable.symtable(code, filename, compile_type)
- for top in raw.itervalues():
+ for top in raw.values():
if top.name == 'top':
break
return _newSymbolTable(top, filename)
@@ -87,8 +87,8 @@ class SymbolTable(object):
return bool(self._table.children)
def has_exec(self):
- """Return true if the scope uses exec"""
- return bool(self._table.optimized & (OPT_EXEC | OPT_BARE_EXEC))
+ """Return true if the scope uses exec. Deprecated method."""
+ return False
def has_import_star(self):
"""Return true if the scope uses import *"""
@@ -230,7 +230,7 @@ class Symbol(object):
Raises ValueError if the name is bound to multiple namespaces.
"""
if len(self.__namespaces) != 1:
- raise ValueError, "name is bound to multiple namespaces"
+ raise ValueError("name is bound to multiple namespaces")
return self.__namespaces[0]
if __name__ == "__main__":
@@ -239,4 +239,4 @@ if __name__ == "__main__":
mod = symtable(src, os.path.split(sys.argv[0])[1], "exec")
for ident in mod.get_identifiers():
info = mod.lookup(ident)
- print info, info.is_local(), info.is_namespace()
+ print(info, info.is_local(), info.is_namespace())
diff --git a/Lib/sysconfig.py b/Lib/sysconfig.py
index 6314cfe00d9..b2183d8e67f 100644
--- a/Lib/sysconfig.py
+++ b/Lib/sysconfig.py
@@ -5,14 +5,30 @@ import sys
import os
from os.path import pardir, realpath
+__all__ = [
+ 'get_config_h_filename',
+ 'get_config_var',
+ 'get_config_vars',
+ 'get_makefile_filename',
+ 'get_path',
+ 'get_path_names',
+ 'get_paths',
+ 'get_platform',
+ 'get_python_version',
+ 'get_scheme_names',
+ 'parse_config_h',
+ ]
+
_INSTALL_SCHEMES = {
'posix_prefix': {
'stdlib': '{base}/lib/python{py_version_short}',
'platstdlib': '{platbase}/lib/python{py_version_short}',
'purelib': '{base}/lib/python{py_version_short}/site-packages',
'platlib': '{platbase}/lib/python{py_version_short}/site-packages',
- 'include': '{base}/include/python{py_version_short}',
- 'platinclude': '{platbase}/include/python{py_version_short}',
+ 'include':
+ '{base}/include/python{py_version_short}{abiflags}',
+ 'platinclude':
+ '{platbase}/include/python{py_version_short}{abiflags}',
'scripts': '{base}/bin',
'data': '{base}',
},
@@ -126,8 +142,8 @@ _PYTHON_BUILD = is_python_build()
if _PYTHON_BUILD:
for scheme in ('posix_prefix', 'posix_home'):
- _INSTALL_SCHEMES[scheme]['include'] = '{projectbase}/Include'
- _INSTALL_SCHEMES[scheme]['platinclude'] = '{srcdir}'
+ _INSTALL_SCHEMES[scheme]['include'] = '{srcdir}/Include'
+ _INSTALL_SCHEMES[scheme]['platinclude'] = '{projectbase}/.'
def _subst_vars(s, local_vars):
try:
@@ -135,7 +151,7 @@ def _subst_vars(s, local_vars):
except KeyError:
try:
return s.format(**os.environ)
- except KeyError, var:
+ except KeyError as var:
raise AttributeError('{%s}' % var)
def _extend_dict(target_dict, other_dict):
@@ -176,9 +192,8 @@ def _getuserbase():
if sys.platform == "darwin":
framework = get_config_var("PYTHONFRAMEWORK")
if framework:
- return env_base if env_base else \
- joinuser("~", "Library", framework, "%d.%d"
- % (sys.version_info[:2]))
+ return env_base if env_base else joinuser("~", "Library", framework, "%d.%d"%(
+ sys.version_info[:2]))
return env_base if env_base else joinuser("~", ".local")
@@ -202,7 +217,7 @@ def _parse_makefile(filename, vars=None):
done = {}
notdone = {}
- with open(filename) as f:
+ with open(filename, errors="surrogateescape") as f:
lines = f.readlines()
for line in lines:
@@ -227,11 +242,19 @@ def _parse_makefile(filename, vars=None):
done[n] = v
# do variable interpolation here
- while notdone:
- for name in notdone.keys():
+ variables = list(notdone.keys())
+
+ # Variables with a 'PY_' prefix in the makefile. These need to
+ # be made available without that prefix through sysconfig.
+ # Special care is needed to ensure that variable expansion works, even
+ # if the expansion uses the name without a prefix.
+ renamed_variables = ('CFLAGS', 'LDFLAGS', 'CPPFLAGS')
+
+ while len(variables) > 0:
+ for name in tuple(variables):
value = notdone[name]
m = _findvar1_rx.search(value) or _findvar2_rx.search(value)
- if m:
+ if m is not None:
n = m.group(1)
found = True
if n in done:
@@ -242,23 +265,48 @@ def _parse_makefile(filename, vars=None):
elif n in os.environ:
# do it like make: fall back to environment
item = os.environ[n]
+
+ elif n in renamed_variables:
+ if name.startswith('PY_') and name[3:] in renamed_variables:
+ item = ""
+
+ elif 'PY_' + n in notdone:
+ found = False
+
+ else:
+ item = str(done['PY_' + n])
+
else:
done[n] = item = ""
+
if found:
after = value[m.end():]
value = value[:m.start()] + item + after
if "$" in after:
notdone[name] = value
else:
- try: value = int(value)
+ try:
+ value = int(value)
except ValueError:
done[name] = value.strip()
else:
done[name] = value
- del notdone[name]
+ variables.remove(name)
+
+ if name.startswith('PY_') \
+ and name[3:] in renamed_variables:
+
+ name = name[3:]
+ if name not in done:
+ done[name] = value
+
+
else:
- # bogus variable reference; just drop it since we can't deal
- del notdone[name]
+ # bogus variable reference (e.g. "prefix=$/opt/python");
+ # just drop it since we can't deal
+ done[name] = value
+ variables.remove(name)
+
# strip spurious spaces
for k, v in done.items():
if isinstance(v, str):
@@ -269,35 +317,36 @@ def _parse_makefile(filename, vars=None):
return vars
-def _get_makefile_filename():
+def get_makefile_filename():
+ """Return the path of the Makefile."""
if _PYTHON_BUILD:
return os.path.join(_PROJECT_BASE, "Makefile")
- return os.path.join(get_path('platstdlib'), "config", "Makefile")
+ return os.path.join(get_path('stdlib'),
+ 'config-{}{}'.format(_PY_VERSION_SHORT, sys.abiflags),
+ 'Makefile')
def _init_posix(vars):
"""Initialize the module as appropriate for POSIX systems."""
# load the installed Makefile:
- makefile = _get_makefile_filename()
+ makefile = get_makefile_filename()
try:
_parse_makefile(makefile, vars)
- except IOError, e:
+ except IOError as e:
msg = "invalid Python installation: unable to open %s" % makefile
if hasattr(e, "strerror"):
msg = msg + " (%s)" % e.strerror
raise IOError(msg)
-
# load the installed pyconfig.h:
config_h = get_config_h_filename()
try:
with open(config_h) as f:
parse_config_h(f, vars)
- except IOError, e:
+ except IOError as e:
msg = "invalid Python installation: unable to open %s" % config_h
if hasattr(e, "strerror"):
msg = msg + " (%s)" % e.strerror
raise IOError(msg)
-
# On AIX, there are wrong paths to the linker scripts in the Makefile
# -- these paths are relative to the Python source, but when installed
# the scripts are in another directory.
@@ -350,7 +399,7 @@ def parse_config_h(fp, vars=None):
return vars
def get_config_h_filename():
- """Returns the path of pyconfig.h."""
+ """Return the path of pyconfig.h."""
if _PYTHON_BUILD:
if os.name == "nt":
inc_dir = os.path.join(_PROJECT_BASE, "PC")
@@ -361,17 +410,17 @@ def get_config_h_filename():
return os.path.join(inc_dir, 'pyconfig.h')
def get_scheme_names():
- """Returns a tuple containing the schemes names."""
- schemes = _INSTALL_SCHEMES.keys()
+ """Return a tuple containing the schemes names."""
+ schemes = list(_INSTALL_SCHEMES.keys())
schemes.sort()
return tuple(schemes)
def get_path_names():
- """Returns a tuple containing the paths names."""
+ """Return a tuple containing the paths names."""
return _SCHEME_KEYS
def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
- """Returns a mapping containing an install scheme.
+ """Return a mapping containing an install scheme.
``scheme`` is the install scheme name. If not provided, it will
return the default scheme for the current platform.
@@ -382,7 +431,7 @@ def get_paths(scheme=_get_default_scheme(), vars=None, expand=True):
return _INSTALL_SCHEMES[scheme]
def get_path(name, scheme=_get_default_scheme(), vars=None, expand=True):
- """Returns a path corresponding to the scheme.
+ """Return a path corresponding to the scheme.
``scheme`` is the install scheme name.
"""
@@ -413,12 +462,16 @@ def get_config_vars(*args):
_CONFIG_VARS['base'] = _PREFIX
_CONFIG_VARS['platbase'] = _EXEC_PREFIX
_CONFIG_VARS['projectbase'] = _PROJECT_BASE
+ try:
+ _CONFIG_VARS['abiflags'] = sys.abiflags
+ except AttributeError:
+ # sys.abiflags may not be defined on all platforms.
+ _CONFIG_VARS['abiflags'] = ''
if os.name in ('nt', 'os2'):
_init_non_posix(_CONFIG_VARS)
if os.name == 'posix':
_init_posix(_CONFIG_VARS)
-
# Setting 'userbase' is done below the call to the
# init function to enable using 'get_config_var' in
# the init-function.
@@ -426,6 +479,9 @@ def get_config_vars(*args):
if 'srcdir' not in _CONFIG_VARS:
_CONFIG_VARS['srcdir'] = _PROJECT_BASE
+ else:
+ _CONFIG_VARS['srcdir'] = _safe_realpath(_CONFIG_VARS['srcdir'])
+
# Convert srcdir into an absolute path if it appears necessary.
# Normally it is relative to the build directory. However, during
@@ -587,7 +643,7 @@ def get_platform():
# bootstrap problem. We use a dict to get an error
# if some suspicious happens.
bitness = {2147483647:"32bit", 9223372036854775807:"64bit"}
- machine += ".%s" % bitness[sys.maxint]
+ machine += ".%s" % bitness[sys.maxsize]
# fall through to standard osname-release-machine representation
elif osname[:4] == "irix": # could be "irix64"!
return "%s-%s" % (osname, release)
@@ -606,6 +662,7 @@ def get_platform():
# to. This makes the compatibility story a bit more sane because the
# machine is going to compile and link as if it were
# MACOSX_DEPLOYMENT_TARGET.
+ #
cfgvars = get_config_vars()
macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
@@ -675,13 +732,13 @@ def get_platform():
# On OSX the machine type returned by uname is always the
# 32-bit variant, even if the executable architecture is
# the 64-bit variant
- if sys.maxint >= 2**32:
+ if sys.maxsize >= 2**32:
machine = 'x86_64'
elif machine in ('PowerPC', 'Power_Macintosh'):
# Pick a sane name for the PPC architecture.
# See 'i386' case
- if sys.maxint >= 2**32:
+ if sys.maxsize >= 2**32:
machine = 'ppc64'
else:
machine = 'ppc'
@@ -691,3 +748,22 @@ def get_platform():
def get_python_version():
return _PY_VERSION_SHORT
+
+def _print_dict(title, data):
+ for index, (key, value) in enumerate(sorted(data.items())):
+ if index == 0:
+ print('{0}: '.format(title))
+ print('\t{0} = "{1}"'.format(key, value))
+
+def _main():
+ """Display all information sysconfig detains."""
+ print('Platform: "{0}"'.format(get_platform()))
+ print('Python version: "{0}"'.format(get_python_version()))
+ print('Current installation scheme: "{0}"'.format(_get_default_scheme()))
+ print('')
+ _print_dict('Paths', get_paths())
+ print('')
+ _print_dict('Variables', get_config_vars())
+
+if __name__ == '__main__':
+ _main()
diff --git a/Lib/tabnanny.py b/Lib/tabnanny.py
index 76665ac91a0..5b9b444c1aa 100755
--- a/Lib/tabnanny.py
+++ b/Lib/tabnanny.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""The Tab Nanny despises ambiguous indentation. She knows no mercy.
@@ -43,7 +43,7 @@ def main():
global verbose, filename_only
try:
opts, args = getopt.getopt(sys.argv[1:], "qv")
- except getopt.error, msg:
+ except getopt.error as msg:
errprint(msg)
return
for o, a in opts:
@@ -83,7 +83,7 @@ def check(file):
if os.path.isdir(file) and not os.path.islink(file):
if verbose:
- print "%r: listing directory" % (file,)
+ print("%r: listing directory" % (file,))
names = os.listdir(file)
for name in names:
fullname = os.path.join(file, name)
@@ -94,40 +94,43 @@ def check(file):
return
try:
- f = open(file)
- except IOError, msg:
+ f = tokenize.open(file)
+ except IOError as msg:
errprint("%r: I/O Error: %s" % (file, msg))
return
if verbose > 1:
- print "checking %r ..." % file
+ print("checking %r ..." % file)
try:
process_tokens(tokenize.generate_tokens(f.readline))
- except tokenize.TokenError, msg:
+ except tokenize.TokenError as msg:
errprint("%r: Token Error: %s" % (file, msg))
return
- except IndentationError, msg:
+ except IndentationError as msg:
errprint("%r: Indentation Error: %s" % (file, msg))
return
- except NannyNag, nag:
+ except NannyNag as nag:
badline = nag.get_lineno()
line = nag.get_line()
if verbose:
- print "%r: *** Line %d: trouble in tab city! ***" % (file, badline)
- print "offending line: %r" % (line,)
- print nag.get_msg()
+ print("%r: *** Line %d: trouble in tab city! ***" % (file, badline))
+ print("offending line: %r" % (line,))
+ print(nag.get_msg())
else:
if ' ' in file: file = '"' + file + '"'
- if filename_only: print file
- else: print file, badline, repr(line)
+ if filename_only: print(file)
+ else: print(file, badline, repr(line))
return
+ finally:
+ f.close()
+
if verbose:
- print "%r: Clean bill of health." % (file,)
+ print("%r: Clean bill of health." % (file,))
class Whitespace:
# the characters used for space and tab
@@ -185,21 +188,21 @@ class Whitespace:
# count, il = self.norm
# for i in range(len(count)):
# if count[i]:
- # il = il + (i/tabsize + 1)*tabsize * count[i]
+ # il = il + (i//tabsize + 1)*tabsize * count[i]
# return il
# quicker:
- # il = trailing + sum (i/ts + 1)*ts*count[i] =
- # trailing + ts * sum (i/ts + 1)*count[i] =
- # trailing + ts * sum i/ts*count[i] + count[i] =
- # trailing + ts * [(sum i/ts*count[i]) + (sum count[i])] =
- # trailing + ts * [(sum i/ts*count[i]) + num_tabs]
- # and note that i/ts*count[i] is 0 when i < ts
+ # il = trailing + sum (i//ts + 1)*ts*count[i] =
+ # trailing + ts * sum (i//ts + 1)*count[i] =
+ # trailing + ts * sum i//ts*count[i] + count[i] =
+ # trailing + ts * [(sum i//ts*count[i]) + (sum count[i])] =
+ # trailing + ts * [(sum i//ts*count[i]) + num_tabs]
+ # and note that i//ts*count[i] is 0 when i < ts
count, trailing = self.norm
il = 0
for i in range(tabsize, len(count)):
- il = il + i/tabsize * count[i]
+ il = il + i//tabsize * count[i]
return trailing + tabsize * (il + self.nt)
# return true iff self.indent_level(t) == other.indent_level(t)
@@ -264,7 +267,7 @@ class Whitespace:
return a
def format_witnesses(w):
- firsts = map(lambda tup: str(tup[0]), w)
+ firsts = (str(tup[0]) for tup in w)
prefix = "at tab size"
if len(w) > 1:
prefix = prefix + "s"
diff --git a/Lib/tarfile.py b/Lib/tarfile.py
index 89d8cc3ffd5..54d0e0e173f 100644
--- a/Lib/tarfile.py
+++ b/Lib/tarfile.py
@@ -1,9 +1,8 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
#-------------------------------------------------------------------
# tarfile.py
#-------------------------------------------------------------------
-# Copyright (C) 2002 Lars Gustäbel <lars@gustaebel.de>
+# Copyright (C) 2002 Lars Gustaebel <lars@gustaebel.de>
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person
@@ -30,14 +29,13 @@
"""Read from and write to tar format archives.
"""
-__version__ = "$Revision: 85213 $"
-# $Source$
+__version__ = "$Revision$"
version = "0.9.0"
-__author__ = "Lars Gustäbel (lars@gustaebel.de)"
-__date__ = "$Date$"
-__cvsid__ = "$Id$"
-__credits__ = "Gustavo Niemeyer, Niels Gustäbel, Richard Townsend."
+__author__ = "Lars Gust\u00e4bel (lars@gustaebel.de)"
+__date__ = "$Date: 2011-02-25 17:42:01 +0200 (Fri, 25 Feb 2011) $"
+__cvsid__ = "$Id: tarfile.py 88586 2011-02-25 15:42:01Z marc-andre.lemburg $"
+__credits__ = "Gustavo Niemeyer, Niels Gust\u00e4bel, Richard Townsend."
#---------
# Imports
@@ -51,46 +49,56 @@ import time
import struct
import copy
import re
-import operator
try:
import grp, pwd
except ImportError:
grp = pwd = None
+# os.symlink on Windows prior to 6.0 raises NotImplementedError
+symlink_exception = (AttributeError, NotImplementedError)
+try:
+ # WindowsError (1314) will be raised if the caller does not hold the
+ # SeCreateSymbolicLinkPrivilege privilege
+ symlink_exception += (WindowsError,)
+except NameError:
+ pass
+
# from tarfile import *
__all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"]
+from builtins import open as _open # Since 'open' is TarFile.open
+
#---------------------------------------------------------
# tar constants
#---------------------------------------------------------
-NUL = "\0" # the null character
+NUL = b"\0" # the null character
BLOCKSIZE = 512 # length of processing blocks
RECORDSIZE = BLOCKSIZE * 20 # length of records
-GNU_MAGIC = "ustar \0" # magic gnu tar string
-POSIX_MAGIC = "ustar\x0000" # magic posix tar string
+GNU_MAGIC = b"ustar \0" # magic gnu tar string
+POSIX_MAGIC = b"ustar\x0000" # magic posix tar string
LENGTH_NAME = 100 # maximum length of a filename
LENGTH_LINK = 100 # maximum length of a linkname
LENGTH_PREFIX = 155 # maximum length of the prefix field
-REGTYPE = "0" # regular file
-AREGTYPE = "\0" # regular file
-LNKTYPE = "1" # link (inside tarfile)
-SYMTYPE = "2" # symbolic link
-CHRTYPE = "3" # character special device
-BLKTYPE = "4" # block special device
-DIRTYPE = "5" # directory
-FIFOTYPE = "6" # fifo special device
-CONTTYPE = "7" # contiguous file
+REGTYPE = b"0" # regular file
+AREGTYPE = b"\0" # regular file
+LNKTYPE = b"1" # link (inside tarfile)
+SYMTYPE = b"2" # symbolic link
+CHRTYPE = b"3" # character special device
+BLKTYPE = b"4" # block special device
+DIRTYPE = b"5" # directory
+FIFOTYPE = b"6" # fifo special device
+CONTTYPE = b"7" # contiguous file
-GNUTYPE_LONGNAME = "L" # GNU tar longname
-GNUTYPE_LONGLINK = "K" # GNU tar longlink
-GNUTYPE_SPARSE = "S" # GNU tar sparse file
+GNUTYPE_LONGNAME = b"L" # GNU tar longname
+GNUTYPE_LONGLINK = b"K" # GNU tar longlink
+GNUTYPE_SPARSE = b"S" # GNU tar sparse file
-XHDTYPE = "x" # POSIX.1-2001 extended header
-XGLTYPE = "g" # POSIX.1-2001 global header
-SOLARIS_XHDTYPE = "X" # Solaris extended header
+XHDTYPE = b"x" # POSIX.1-2001 extended header
+XGLTYPE = b"g" # POSIX.1-2001 global header
+SOLARIS_XHDTYPE = b"X" # Solaris extended header
USTAR_FORMAT = 0 # POSIX.1-1988 (ustar) format
GNU_FORMAT = 1 # GNU tar format
@@ -119,6 +127,9 @@ GNU_TYPES = (GNUTYPE_LONGNAME, GNUTYPE_LONGLINK,
PAX_FIELDS = ("path", "linkpath", "size", "mtime",
"uid", "gid", "uname", "gname")
+# Fields from a pax header that are affected by hdrcharset.
+PAX_NAME_FIELDS = {"path", "linkpath", "uname", "gname"}
+
# Fields in a pax header that are numbers, all other fields
# are treated as strings.
PAX_NUMBER_FIELDS = {
@@ -133,67 +144,70 @@ PAX_NUMBER_FIELDS = {
#---------------------------------------------------------
# Bits used in the mode field, values in octal.
#---------------------------------------------------------
-S_IFLNK = 0120000 # symbolic link
-S_IFREG = 0100000 # regular file
-S_IFBLK = 0060000 # block device
-S_IFDIR = 0040000 # directory
-S_IFCHR = 0020000 # character device
-S_IFIFO = 0010000 # fifo
-
-TSUID = 04000 # set UID on execution
-TSGID = 02000 # set GID on execution
-TSVTX = 01000 # reserved
-
-TUREAD = 0400 # read by owner
-TUWRITE = 0200 # write by owner
-TUEXEC = 0100 # execute/search by owner
-TGREAD = 0040 # read by group
-TGWRITE = 0020 # write by group
-TGEXEC = 0010 # execute/search by group
-TOREAD = 0004 # read by other
-TOWRITE = 0002 # write by other
-TOEXEC = 0001 # execute/search by other
+S_IFLNK = 0o120000 # symbolic link
+S_IFREG = 0o100000 # regular file
+S_IFBLK = 0o060000 # block device
+S_IFDIR = 0o040000 # directory
+S_IFCHR = 0o020000 # character device
+S_IFIFO = 0o010000 # fifo
+
+TSUID = 0o4000 # set UID on execution
+TSGID = 0o2000 # set GID on execution
+TSVTX = 0o1000 # reserved
+
+TUREAD = 0o400 # read by owner
+TUWRITE = 0o200 # write by owner
+TUEXEC = 0o100 # execute/search by owner
+TGREAD = 0o040 # read by group
+TGWRITE = 0o020 # write by group
+TGEXEC = 0o010 # execute/search by group
+TOREAD = 0o004 # read by other
+TOWRITE = 0o002 # write by other
+TOEXEC = 0o001 # execute/search by other
#---------------------------------------------------------
# initialization
#---------------------------------------------------------
-ENCODING = sys.getfilesystemencoding()
-if ENCODING is None:
- ENCODING = sys.getdefaultencoding()
+if os.name in ("nt", "ce"):
+ ENCODING = "utf-8"
+else:
+ ENCODING = sys.getfilesystemencoding()
#---------------------------------------------------------
# Some useful functions
#---------------------------------------------------------
-def stn(s, length):
- """Convert a python string to a null-terminated string buffer.
+def stn(s, length, encoding, errors):
+ """Convert a string to a null-terminated bytes object.
"""
+ s = s.encode(encoding, errors)
return s[:length] + (length - len(s)) * NUL
-def nts(s):
- """Convert a null-terminated string field to a python string.
+def nts(s, encoding, errors):
+ """Convert a null-terminated bytes object to a string.
"""
- # Use the string up to the first null char.
- p = s.find("\0")
- if p == -1:
- return s
- return s[:p]
+ p = s.find(b"\0")
+ if p != -1:
+ s = s[:p]
+ return s.decode(encoding, errors)
def nti(s):
"""Convert a number field to a python number.
"""
# There are two possible encodings for a number field, see
# itn() below.
- if s[0] != chr(0200):
+ if s[0] in (0o200, 0o377):
+ n = 0
+ for i in range(len(s) - 1):
+ n <<= 8
+ n += s[i + 1]
+ if s[0] == 0o377:
+ n = -(256 ** (len(s) - 1) - n)
+ else:
try:
- n = int(nts(s) or "0", 8)
+ n = int(nts(s, "ascii", "strict") or "0", 8)
except ValueError:
raise InvalidHeaderError("invalid header")
- else:
- n = 0L
- for i in xrange(len(s) - 1):
- n <<= 8
- n += ord(s[i + 1])
return n
def itn(n, digits=8, format=DEFAULT_FORMAT):
@@ -202,46 +216,27 @@ def itn(n, digits=8, format=DEFAULT_FORMAT):
# POSIX 1003.1-1988 requires numbers to be encoded as a string of
# octal digits followed by a null-byte, this allows values up to
# (8**(digits-1))-1. GNU tar allows storing numbers greater than
- # that if necessary. A leading 0200 byte indicates this particular
- # encoding, the following digits-1 bytes are a big-endian
- # representation. This allows values up to (256**(digits-1))-1.
+ # that if necessary. A leading 0o200 or 0o377 byte indicate this
+ # particular encoding, the following digits-1 bytes are a big-endian
+ # base-256 representation. This allows values up to (256**(digits-1))-1.
+ # A 0o200 byte indicates a positive number, a 0o377 byte a negative
+ # number.
if 0 <= n < 8 ** (digits - 1):
- s = "%0*o" % (digits - 1, n) + NUL
- else:
- if format != GNU_FORMAT or n >= 256 ** (digits - 1):
- raise ValueError("overflow in number field")
-
- if n < 0:
- # XXX We mimic GNU tar's behaviour with negative numbers,
- # this could raise OverflowError.
- n = struct.unpack("L", struct.pack("l", n))[0]
+ s = bytes("%0*o" % (digits - 1, n), "ascii") + NUL
+ elif format == GNU_FORMAT and -256 ** (digits - 1) <= n < 256 ** (digits - 1):
+ if n >= 0:
+ s = bytearray([0o200])
+ else:
+ s = bytearray([0o377])
+ n = 256 ** digits + n
- s = ""
- for i in xrange(digits - 1):
- s = chr(n & 0377) + s
+ for i in range(digits - 1):
+ s.insert(1, n & 0o377)
n >>= 8
- s = chr(0200) + s
- return s
-
-def uts(s, encoding, errors):
- """Convert a unicode object to a string.
- """
- if errors == "utf-8":
- # An extra error handler similar to the -o invalid=UTF-8 option
- # in POSIX.1-2001. Replace untranslatable characters with their
- # UTF-8 representation.
- try:
- return s.encode(encoding, "strict")
- except UnicodeEncodeError:
- x = []
- for c in s:
- try:
- x.append(c.encode(encoding, "strict"))
- except UnicodeEncodeError:
- x.append(c.encode("utf8"))
- return "".join(x)
else:
- return s.encode(encoding, errors)
+ raise ValueError("overflow in number field")
+
+ return s
def calc_chksums(buf):
"""Calculate the checksum for a member's header by summing up all
@@ -268,7 +263,7 @@ def copyfileobj(src, dst, length=None):
BUFSIZE = 16 * 1024
blocks, remainder = divmod(length, BUFSIZE)
- for b in xrange(blocks):
+ for b in range(blocks):
buf = src.read(BUFSIZE)
if len(buf) < BUFSIZE:
raise IOError("end of file reached")
@@ -373,7 +368,7 @@ class _LowLevelFile:
}[mode]
if hasattr(os, "O_BINARY"):
mode |= os.O_BINARY
- self.fd = os.open(name, mode, 0666)
+ self.fd = os.open(name, mode, 0o666)
def close(self):
os.close(self.fd)
@@ -414,32 +409,38 @@ class _Stream:
self.comptype = comptype
self.fileobj = fileobj
self.bufsize = bufsize
- self.buf = ""
- self.pos = 0L
+ self.buf = b""
+ self.pos = 0
self.closed = False
- if comptype == "gz":
- try:
- import zlib
- except ImportError:
- raise CompressionError("zlib module is not available")
- self.zlib = zlib
- self.crc = zlib.crc32("") & 0xffffffffL
- if mode == "r":
- self._init_read_gz()
- else:
- self._init_write_gz()
+ try:
+ if comptype == "gz":
+ try:
+ import zlib
+ except ImportError:
+ raise CompressionError("zlib module is not available")
+ self.zlib = zlib
+ self.crc = zlib.crc32(b"")
+ if mode == "r":
+ self._init_read_gz()
+ else:
+ self._init_write_gz()
- if comptype == "bz2":
- try:
- import bz2
- except ImportError:
- raise CompressionError("bz2 module is not available")
- if mode == "r":
- self.dbuf = ""
- self.cmp = bz2.BZ2Decompressor()
- else:
- self.cmp = bz2.BZ2Compressor()
+ if comptype == "bz2":
+ try:
+ import bz2
+ except ImportError:
+ raise CompressionError("bz2 module is not available")
+ if mode == "r":
+ self.dbuf = b""
+ self.cmp = bz2.BZ2Decompressor()
+ else:
+ self.cmp = bz2.BZ2Compressor()
+ except:
+ if not self._extfileobj:
+ self.fileobj.close()
+ self.closed = True
+ raise
def __del__(self):
if hasattr(self, "closed") and not self.closed:
@@ -452,19 +453,18 @@ class _Stream:
-self.zlib.MAX_WBITS,
self.zlib.DEF_MEM_LEVEL,
0)
- timestamp = struct.pack("<L", long(time.time()))
- self.__write("\037\213\010\010%s\002\377" % timestamp)
- if type(self.name) is unicode:
- self.name = self.name.encode("iso-8859-1", "replace")
+ timestamp = struct.pack("<L", int(time.time()))
+ self.__write(b"\037\213\010\010" + timestamp + b"\002\377")
if self.name.endswith(".gz"):
self.name = self.name[:-3]
- self.__write(self.name + NUL)
+ # RFC1952 says we must use ISO-8859-1 for the FNAME field.
+ self.__write(self.name.encode("iso-8859-1", "replace") + NUL)
def write(self, s):
"""Write string s to the stream.
"""
if self.comptype == "gz":
- self.crc = self.zlib.crc32(s, self.crc) & 0xffffffffL
+ self.crc = self.zlib.crc32(s, self.crc)
self.pos += len(s)
if self.comptype != "tar":
s = self.cmp.compress(s)
@@ -491,7 +491,7 @@ class _Stream:
if self.mode == "w" and self.buf:
self.fileobj.write(self.buf)
- self.buf = ""
+ self.buf = b""
if self.comptype == "gz":
# The native zlib crc is an unsigned 32-bit integer, but
# the Python wrapper implicitly casts that to a signed C
@@ -499,8 +499,8 @@ class _Stream:
# while the same crc on a 64-bit box may "look positive".
# To avoid irksome warnings from the `struct` module, force
# it to look positive on all boxes.
- self.fileobj.write(struct.pack("<L", self.crc & 0xffffffffL))
- self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFFL))
+ self.fileobj.write(struct.pack("<L", self.crc & 0xffffffff))
+ self.fileobj.write(struct.pack("<L", self.pos & 0xffffFFFF))
if not self._extfileobj:
self.fileobj.close()
@@ -511,12 +511,12 @@ class _Stream:
"""Initialize for reading a gzip compressed fileobj.
"""
self.cmp = self.zlib.decompressobj(-self.zlib.MAX_WBITS)
- self.dbuf = ""
+ self.dbuf = b""
# taken from gzip.GzipFile with some alterations
- if self.__read(2) != "\037\213":
+ if self.__read(2) != b"\037\213":
raise ReadError("not a gzip file")
- if self.__read(1) != "\010":
+ if self.__read(1) != b"\010":
raise CompressionError("unsupported compression method")
flag = ord(self.__read(1))
@@ -549,7 +549,7 @@ class _Stream:
"""
if pos - self.pos >= 0:
blocks, remainder = divmod(pos - self.pos, self.bufsize)
- for i in xrange(blocks):
+ for i in range(blocks):
self.read(self.bufsize)
self.read(remainder)
else:
@@ -581,7 +581,6 @@ class _Stream:
return self.__read(size)
c = len(self.dbuf)
- t = [self.dbuf]
while c < size:
buf = self.__read(self.bufsize)
if not buf:
@@ -590,27 +589,26 @@ class _Stream:
buf = self.cmp.decompress(buf)
except IOError:
raise ReadError("invalid compressed data")
- t.append(buf)
+ self.dbuf += buf
c += len(buf)
- t = "".join(t)
- self.dbuf = t[size:]
- return t[:size]
+ buf = self.dbuf[:size]
+ self.dbuf = self.dbuf[size:]
+ return buf
def __read(self, size):
"""Return size bytes from stream. If internal buffer is empty,
read another block from the stream.
"""
c = len(self.buf)
- t = [self.buf]
while c < size:
buf = self.fileobj.read(self.bufsize)
if not buf:
break
- t.append(buf)
+ self.buf += buf
c += len(buf)
- t = "".join(t)
- self.buf = t[size:]
- return t[:size]
+ buf = self.buf[:size]
+ self.buf = self.buf[size:]
+ return buf
# class _Stream
class _StreamProxy(object):
@@ -627,9 +625,9 @@ class _StreamProxy(object):
return self.buf
def getcomptype(self):
- if self.buf.startswith("\037\213\010"):
+ if self.buf.startswith(b"\037\213\010"):
return "gz"
- if self.buf[0:3] == "BZh" and self.buf[4:10] == "1AY&SY":
+ if self.buf[0:3] == b"BZh" and self.buf[4:10] == b"1AY&SY":
return "bz2"
return "tar"
@@ -659,21 +657,19 @@ class _BZ2Proxy(object):
if self.mode == "r":
self.bz2obj = bz2.BZ2Decompressor()
self.fileobj.seek(0)
- self.buf = ""
+ self.buf = b""
else:
self.bz2obj = bz2.BZ2Compressor()
def read(self, size):
- b = [self.buf]
x = len(self.buf)
while x < size:
raw = self.fileobj.read(self.blocksize)
if not raw:
break
data = self.bz2obj.decompress(raw)
- b.append(data)
+ self.buf += data
x += len(data)
- self.buf = "".join(b)
buf = self.buf[:size]
self.buf = self.buf[size:]
@@ -708,13 +704,35 @@ class _FileInFile(object):
object.
"""
- def __init__(self, fileobj, offset, size, sparse=None):
+ def __init__(self, fileobj, offset, size, blockinfo=None):
self.fileobj = fileobj
self.offset = offset
self.size = size
- self.sparse = sparse
self.position = 0
+ if blockinfo is None:
+ blockinfo = [(0, size)]
+
+ # Construct a map with data and zero blocks.
+ self.map_index = 0
+ self.map = []
+ lastpos = 0
+ realpos = self.offset
+ for offset, size in blockinfo:
+ if offset > lastpos:
+ self.map.append((False, lastpos, offset, None))
+ self.map.append((True, offset, offset + size, realpos))
+ realpos += size
+ lastpos = offset + size
+ if lastpos < self.size:
+ self.map.append((False, lastpos, self.size, None))
+
+ def seekable(self):
+ if not hasattr(self.fileobj, "seekable"):
+ # XXX gzip.GzipFile and bz2.BZ2File
+ return True
+ return self.fileobj.seekable()
+
def tell(self):
"""Return the current file position.
"""
@@ -733,48 +751,25 @@ class _FileInFile(object):
else:
size = min(size, self.size - self.position)
- if self.sparse is None:
- return self.readnormal(size)
- else:
- return self.readsparse(size)
-
- def readnormal(self, size):
- """Read operation for regular files.
- """
- self.fileobj.seek(self.offset + self.position)
- self.position += size
- return self.fileobj.read(size)
-
- def readsparse(self, size):
- """Read operation for sparse files.
- """
- data = []
+ buf = b""
while size > 0:
- buf = self.readsparsesection(size)
- if not buf:
- break
- size -= len(buf)
- data.append(buf)
- return "".join(data)
-
- def readsparsesection(self, size):
- """Read a single section of a sparse file.
- """
- section = self.sparse.find(self.position)
-
- if section is None:
- return ""
-
- size = min(size, section.offset + section.size - self.position)
-
- if isinstance(section, _data):
- realpos = section.realpos + self.position - section.offset
- self.fileobj.seek(self.offset + realpos)
- self.position += size
- return self.fileobj.read(size)
- else:
- self.position += size
- return NUL * size
+ while True:
+ data, start, stop, offset = self.map[self.map_index]
+ if start <= self.position < stop:
+ break
+ else:
+ self.map_index += 1
+ if self.map_index == len(self.map):
+ self.map_index = 0
+ length = min(size, stop - self.position)
+ if data:
+ self.fileobj.seek(offset + (self.position - start))
+ buf += self.fileobj.read(length)
+ else:
+ buf += NUL * length
+ size -= length
+ self.position += length
+ return buf
#class _FileInFile
@@ -788,14 +783,23 @@ class ExFileObject(object):
self.fileobj = _FileInFile(tarfile.fileobj,
tarinfo.offset_data,
tarinfo.size,
- getattr(tarinfo, "sparse", None))
+ tarinfo.sparse)
self.name = tarinfo.name
self.mode = "r"
self.closed = False
self.size = tarinfo.size
self.position = 0
- self.buffer = ""
+ self.buffer = b""
+
+ def readable(self):
+ return True
+
+ def writable(self):
+ return False
+
+ def seekable(self):
+ return self.fileobj.seekable()
def read(self, size=None):
"""Read at most size bytes from the file. If size is not
@@ -804,11 +808,11 @@ class ExFileObject(object):
if self.closed:
raise ValueError("I/O operation on closed file")
- buf = ""
+ buf = b""
if self.buffer:
if size is None:
buf = self.buffer
- self.buffer = ""
+ self.buffer = b""
else:
buf = self.buffer[:size]
self.buffer = self.buffer[size:]
@@ -821,6 +825,9 @@ class ExFileObject(object):
self.position += len(buf)
return buf
+ # XXX TextIOWrapper uses the read1() method.
+ read1 = read
+
def readline(self, size=-1):
"""Read one entire line from the file. If size is present
and non-negative, return a string with at most that
@@ -829,16 +836,14 @@ class ExFileObject(object):
if self.closed:
raise ValueError("I/O operation on closed file")
- if "\n" in self.buffer:
- pos = self.buffer.find("\n") + 1
- else:
- buffers = [self.buffer]
+ pos = self.buffer.find(b"\n") + 1
+ if pos == 0:
+ # no newline found.
while True:
buf = self.fileobj.read(self.blocksize)
- buffers.append(buf)
- if not buf or "\n" in buf:
- self.buffer = "".join(buffers)
- pos = self.buffer.find("\n") + 1
+ self.buffer += buf
+ if not buf or b"\n" in buf:
+ pos = self.buffer.find(b"\n") + 1
if pos == 0:
# no newline found.
pos = len(self.buffer)
@@ -888,7 +893,7 @@ class ExFileObject(object):
else:
raise ValueError("Invalid argument")
- self.buffer = ""
+ self.buffer = b""
self.fileobj.seek(self.position)
def close(self):
@@ -917,12 +922,18 @@ class TarInfo(object):
usually created internally.
"""
+ __slots__ = ("name", "mode", "uid", "gid", "size", "mtime",
+ "chksum", "type", "linkname", "uname", "gname",
+ "devmajor", "devminor",
+ "offset", "offset_data", "pax_headers", "sparse",
+ "tarfile", "_sparse_structs", "_link_target")
+
def __init__(self, name=""):
"""Construct a TarInfo object. name is the optional name
of the member.
"""
self.name = name # member name
- self.mode = 0644 # file permissions
+ self.mode = 0o644 # file permissions
self.uid = 0 # user id
self.gid = 0 # group id
self.size = 0 # file size
@@ -938,6 +949,7 @@ class TarInfo(object):
self.offset = 0 # the tar header starts here
self.offset_data = 0 # the file's data starts here
+ self.sparse = None # sparse member information
self.pax_headers = {} # pax header information
# In pax headers the "name" and "linkname" field are called
@@ -957,12 +969,12 @@ class TarInfo(object):
def __repr__(self):
return "<%s %r at %#x>" % (self.__class__.__name__,self.name,id(self))
- def get_info(self, encoding, errors):
+ def get_info(self):
"""Return the TarInfo's attributes as a dictionary.
"""
info = {
"name": self.name,
- "mode": self.mode & 07777,
+ "mode": self.mode & 0o7777,
"uid": self.uid,
"gid": self.gid,
"size": self.size,
@@ -979,27 +991,23 @@ class TarInfo(object):
if info["type"] == DIRTYPE and not info["name"].endswith("/"):
info["name"] += "/"
- for key in ("name", "linkname", "uname", "gname"):
- if type(info[key]) is unicode:
- info[key] = info[key].encode(encoding, errors)
-
return info
- def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="strict"):
+ def tobuf(self, format=DEFAULT_FORMAT, encoding=ENCODING, errors="surrogateescape"):
"""Return a tar header as a string of 512 byte blocks.
"""
- info = self.get_info(encoding, errors)
+ info = self.get_info()
if format == USTAR_FORMAT:
- return self.create_ustar_header(info)
+ return self.create_ustar_header(info, encoding, errors)
elif format == GNU_FORMAT:
- return self.create_gnu_header(info)
+ return self.create_gnu_header(info, encoding, errors)
elif format == PAX_FORMAT:
- return self.create_pax_header(info, encoding, errors)
+ return self.create_pax_header(info, encoding)
else:
raise ValueError("invalid format")
- def create_ustar_header(self, info):
+ def create_ustar_header(self, info, encoding, errors):
"""Return the object as a ustar header block.
"""
info["magic"] = POSIX_MAGIC
@@ -1010,23 +1018,23 @@ class TarInfo(object):
if len(info["name"]) > LENGTH_NAME:
info["prefix"], info["name"] = self._posix_split_name(info["name"])
- return self._create_header(info, USTAR_FORMAT)
+ return self._create_header(info, USTAR_FORMAT, encoding, errors)
- def create_gnu_header(self, info):
+ def create_gnu_header(self, info, encoding, errors):
"""Return the object as a GNU header block sequence.
"""
info["magic"] = GNU_MAGIC
- buf = ""
+ buf = b""
if len(info["linkname"]) > LENGTH_LINK:
- buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK)
+ buf += self._create_gnu_long_header(info["linkname"], GNUTYPE_LONGLINK, encoding, errors)
if len(info["name"]) > LENGTH_NAME:
- buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME)
+ buf += self._create_gnu_long_header(info["name"], GNUTYPE_LONGNAME, encoding, errors)
- return buf + self._create_header(info, GNU_FORMAT)
+ return buf + self._create_header(info, GNU_FORMAT, encoding, errors)
- def create_pax_header(self, info, encoding, errors):
+ def create_pax_header(self, info, encoding):
"""Return the object as a ustar header block. If it cannot be
represented this way, prepend a pax extended header sequence
with supplement information.
@@ -1044,17 +1052,15 @@ class TarInfo(object):
# The pax header has priority.
continue
- val = info[name].decode(encoding, errors)
-
# Try to encode the string as ASCII.
try:
- val.encode("ascii")
+ info[name].encode("ascii", "strict")
except UnicodeEncodeError:
- pax_headers[hname] = val
+ pax_headers[hname] = info[name]
continue
if len(info[name]) > length:
- pax_headers[hname] = val
+ pax_headers[hname] = info[name]
# Test number fields for values that exceed the field limit or values
# that like to be stored as float.
@@ -1066,22 +1072,22 @@ class TarInfo(object):
val = info[name]
if not 0 <= val < 8 ** (digits - 1) or isinstance(val, float):
- pax_headers[name] = unicode(val)
+ pax_headers[name] = str(val)
info[name] = 0
# Create a pax extended header if necessary.
if pax_headers:
- buf = self._create_pax_generic_header(pax_headers)
+ buf = self._create_pax_generic_header(pax_headers, XHDTYPE, encoding)
else:
- buf = ""
+ buf = b""
- return buf + self._create_header(info, USTAR_FORMAT)
+ return buf + self._create_header(info, USTAR_FORMAT, "ascii", "replace")
@classmethod
def create_pax_global_header(cls, pax_headers):
"""Return the object as a pax global header block sequence.
"""
- return cls._create_pax_generic_header(pax_headers, type=XGLTYPE)
+ return cls._create_pax_generic_header(pax_headers, XGLTYPE, "utf8")
def _posix_split_name(self, name):
"""Split a name longer than 100 chars into a prefix
@@ -1099,31 +1105,31 @@ class TarInfo(object):
return prefix, name
@staticmethod
- def _create_header(info, format):
+ def _create_header(info, format, encoding, errors):
"""Return a header block. info is a dictionary with file
information, format must be one of the *_FORMAT constants.
"""
parts = [
- stn(info.get("name", ""), 100),
- itn(info.get("mode", 0) & 07777, 8, format),
+ stn(info.get("name", ""), 100, encoding, errors),
+ itn(info.get("mode", 0) & 0o7777, 8, format),
itn(info.get("uid", 0), 8, format),
itn(info.get("gid", 0), 8, format),
itn(info.get("size", 0), 12, format),
itn(info.get("mtime", 0), 12, format),
- " ", # checksum field
+ b" ", # checksum field
info.get("type", REGTYPE),
- stn(info.get("linkname", ""), 100),
- stn(info.get("magic", POSIX_MAGIC), 8),
- stn(info.get("uname", ""), 32),
- stn(info.get("gname", ""), 32),
+ stn(info.get("linkname", ""), 100, encoding, errors),
+ info.get("magic", POSIX_MAGIC),
+ stn(info.get("uname", ""), 32, encoding, errors),
+ stn(info.get("gname", ""), 32, encoding, errors),
itn(info.get("devmajor", 0), 8, format),
itn(info.get("devminor", 0), 8, format),
- stn(info.get("prefix", ""), 155)
+ stn(info.get("prefix", ""), 155, encoding, errors)
]
- buf = struct.pack("%ds" % BLOCKSIZE, "".join(parts))
+ buf = struct.pack("%ds" % BLOCKSIZE, b"".join(parts))
chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
- buf = buf[:-364] + "%06o\0" % chksum + buf[-357:]
+ buf = buf[:-364] + bytes("%06o\0" % chksum, "ascii") + buf[-357:]
return buf
@staticmethod
@@ -1137,11 +1143,11 @@ class TarInfo(object):
return payload
@classmethod
- def _create_gnu_long_header(cls, name, type):
+ def _create_gnu_long_header(cls, name, type, encoding, errors):
"""Return a GNUTYPE_LONGNAME or GNUTYPE_LONGLINK sequence
for name.
"""
- name += NUL
+ name = name.encode(encoding, errors) + NUL
info = {}
info["name"] = "././@LongLink"
@@ -1150,19 +1156,39 @@ class TarInfo(object):
info["magic"] = GNU_MAGIC
# create extended header + name blocks.
- return cls._create_header(info, USTAR_FORMAT) + \
+ return cls._create_header(info, USTAR_FORMAT, encoding, errors) + \
cls._create_payload(name)
@classmethod
- def _create_pax_generic_header(cls, pax_headers, type=XHDTYPE):
- """Return a POSIX.1-2001 extended or global header sequence
+ def _create_pax_generic_header(cls, pax_headers, type, encoding):
+ """Return a POSIX.1-2008 extended or global header sequence
that contains a list of keyword, value pairs. The values
- must be unicode objects.
+ must be strings.
"""
- records = []
- for keyword, value in pax_headers.iteritems():
+ # Check if one of the fields contains surrogate characters and thereby
+ # forces hdrcharset=BINARY, see _proc_pax() for more information.
+ binary = False
+ for keyword, value in pax_headers.items():
+ try:
+ value.encode("utf8", "strict")
+ except UnicodeEncodeError:
+ binary = True
+ break
+
+ records = b""
+ if binary:
+ # Put the hdrcharset field at the beginning of the header.
+ records += b"21 hdrcharset=BINARY\n"
+
+ for keyword, value in pax_headers.items():
keyword = keyword.encode("utf8")
- value = value.encode("utf8")
+ if binary:
+ # Try to restore the original byte representation of `value'.
+ # Needless to say, that the encoding must match the string.
+ value = value.encode(encoding, "surrogateescape")
+ else:
+ value = value.encode("utf8")
+
l = len(keyword) + len(value) + 3 # ' ' + '=' + '\n'
n = p = 0
while True:
@@ -1170,8 +1196,7 @@ class TarInfo(object):
if n == p:
break
p = n
- records.append("%d %s=%s\n" % (p, keyword, value))
- records = "".join(records)
+ records += bytes(str(p), "ascii") + b" " + keyword + b"=" + value + b"\n"
# We use a hardcoded "././@PaxHeader" name like star does
# instead of the one that POSIX recommends.
@@ -1182,12 +1207,12 @@ class TarInfo(object):
info["magic"] = POSIX_MAGIC
# Create pax header + record blocks.
- return cls._create_header(info, USTAR_FORMAT) + \
+ return cls._create_header(info, USTAR_FORMAT, "ascii", "replace") + \
cls._create_payload(records)
@classmethod
- def frombuf(cls, buf):
- """Construct a TarInfo object from a 512 byte string buffer.
+ def frombuf(cls, buf, encoding, errors):
+ """Construct a TarInfo object from a 512 byte bytes object.
"""
if len(buf) == 0:
raise EmptyHeaderError("empty header")
@@ -1201,8 +1226,7 @@ class TarInfo(object):
raise InvalidHeaderError("bad checksum")
obj = cls()
- obj.buf = buf
- obj.name = nts(buf[0:100])
+ obj.name = nts(buf[0:100], encoding, errors)
obj.mode = nti(buf[100:108])
obj.uid = nti(buf[108:116])
obj.gid = nti(buf[116:124])
@@ -1210,18 +1234,36 @@ class TarInfo(object):
obj.mtime = nti(buf[136:148])
obj.chksum = chksum
obj.type = buf[156:157]
- obj.linkname = nts(buf[157:257])
- obj.uname = nts(buf[265:297])
- obj.gname = nts(buf[297:329])
+ obj.linkname = nts(buf[157:257], encoding, errors)
+ obj.uname = nts(buf[265:297], encoding, errors)
+ obj.gname = nts(buf[297:329], encoding, errors)
obj.devmajor = nti(buf[329:337])
obj.devminor = nti(buf[337:345])
- prefix = nts(buf[345:500])
+ prefix = nts(buf[345:500], encoding, errors)
# Old V7 tar format represents a directory as a regular
# file with a trailing slash.
if obj.type == AREGTYPE and obj.name.endswith("/"):
obj.type = DIRTYPE
+ # The old GNU sparse format occupies some of the unused
+ # space in the buffer for up to 4 sparse structures.
+ # Save the them for later processing in _proc_sparse().
+ if obj.type == GNUTYPE_SPARSE:
+ pos = 386
+ structs = []
+ for i in range(4):
+ try:
+ offset = nti(buf[pos:pos + 12])
+ numbytes = nti(buf[pos + 12:pos + 24])
+ except ValueError:
+ break
+ structs.append((offset, numbytes))
+ pos += 24
+ isextended = bool(buf[482])
+ origsize = nti(buf[483:495])
+ obj._sparse_structs = (structs, isextended, origsize)
+
# Remove redundant slashes from directories.
if obj.isdir():
obj.name = obj.name.rstrip("/")
@@ -1237,7 +1279,7 @@ class TarInfo(object):
tarfile.
"""
buf = tarfile.fileobj.read(BLOCKSIZE)
- obj = cls.frombuf(buf)
+ obj = cls.frombuf(buf, tarfile.encoding, tarfile.errors)
obj.offset = tarfile.fileobj.tell() - BLOCKSIZE
return obj._proc_member(tarfile)
@@ -1298,71 +1340,43 @@ class TarInfo(object):
# the longname information.
next.offset = self.offset
if self.type == GNUTYPE_LONGNAME:
- next.name = nts(buf)
+ next.name = nts(buf, tarfile.encoding, tarfile.errors)
elif self.type == GNUTYPE_LONGLINK:
- next.linkname = nts(buf)
+ next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
return next
def _proc_sparse(self, tarfile):
"""Process a GNU sparse header plus extra headers.
"""
- buf = self.buf
- sp = _ringbuffer()
- pos = 386
- lastpos = 0L
- realpos = 0L
- # There are 4 possible sparse structs in the
- # first header.
- for i in xrange(4):
- try:
- offset = nti(buf[pos:pos + 12])
- numbytes = nti(buf[pos + 12:pos + 24])
- except ValueError:
- break
- if offset > lastpos:
- sp.append(_hole(lastpos, offset - lastpos))
- sp.append(_data(offset, numbytes, realpos))
- realpos += numbytes
- lastpos = offset + numbytes
- pos += 24
-
- isextended = ord(buf[482])
- origsize = nti(buf[483:495])
-
- # If the isextended flag is given,
- # there are extra headers to process.
- while isextended == 1:
+ # We already collected some sparse structures in frombuf().
+ structs, isextended, origsize = self._sparse_structs
+ del self._sparse_structs
+
+ # Collect sparse structures from extended header blocks.
+ while isextended:
buf = tarfile.fileobj.read(BLOCKSIZE)
pos = 0
- for i in xrange(21):
+ for i in range(21):
try:
offset = nti(buf[pos:pos + 12])
numbytes = nti(buf[pos + 12:pos + 24])
except ValueError:
break
- if offset > lastpos:
- sp.append(_hole(lastpos, offset - lastpos))
- sp.append(_data(offset, numbytes, realpos))
- realpos += numbytes
- lastpos = offset + numbytes
+ if offset and numbytes:
+ structs.append((offset, numbytes))
pos += 24
- isextended = ord(buf[504])
-
- if lastpos < origsize:
- sp.append(_hole(lastpos, origsize - lastpos))
-
- self.sparse = sp
+ isextended = bool(buf[504])
+ self.sparse = structs
self.offset_data = tarfile.fileobj.tell()
tarfile.offset = self.offset_data + self._block(self.size)
self.size = origsize
-
return self
def _proc_pax(self, tarfile):
"""Process an extended or global header as described in
- POSIX.1-2001.
+ POSIX.1-2008.
"""
# Read the header information.
buf = tarfile.fileobj.read(self._block(self.size))
@@ -1375,11 +1389,29 @@ class TarInfo(object):
else:
pax_headers = tarfile.pax_headers.copy()
+ # Check if the pax header contains a hdrcharset field. This tells us
+ # the encoding of the path, linkpath, uname and gname fields. Normally,
+ # these fields are UTF-8 encoded but since POSIX.1-2008 tar
+ # implementations are allowed to store them as raw binary strings if
+ # the translation to UTF-8 fails.
+ match = re.search(br"\d+ hdrcharset=([^\n]+)\n", buf)
+ if match is not None:
+ pax_headers["hdrcharset"] = match.group(1).decode("utf8")
+
+ # For the time being, we don't care about anything other than "BINARY".
+ # The only other value that is currently allowed by the standard is
+ # "ISO-IR 10646 2000 UTF-8" in other words UTF-8.
+ hdrcharset = pax_headers.get("hdrcharset")
+ if hdrcharset == "BINARY":
+ encoding = tarfile.encoding
+ else:
+ encoding = "utf8"
+
# Parse pax header information. A record looks like that:
# "%d %s=%s\n" % (length, keyword, value). length is the size
# of the complete record including the length field itself and
# the newline. keyword and value are both UTF-8 encoded strings.
- regex = re.compile(r"(\d+) ([^=]+)=", re.U)
+ regex = re.compile(br"(\d+) ([^=]+)=")
pos = 0
while True:
match = regex.match(buf, pos)
@@ -1390,8 +1422,21 @@ class TarInfo(object):
length = int(length)
value = buf[match.end(2) + 1:match.start(1) + length - 1]
- keyword = keyword.decode("utf8")
- value = value.decode("utf8")
+ # Normally, we could just use "utf8" as the encoding and "strict"
+ # as the error handler, but we better not take the risk. For
+ # example, GNU tar <= 1.23 is known to store filenames it cannot
+ # translate to UTF-8 as raw strings (unfortunately without a
+ # hdrcharset=BINARY header).
+ # We first try the strict standard encoding, and if that fails we
+ # fall back on the user's encoding and error handler.
+ keyword = self._decode_pax_field(keyword, "utf8", "utf8",
+ tarfile.errors)
+ if keyword in PAX_NAME_FIELDS:
+ value = self._decode_pax_field(value, encoding, tarfile.encoding,
+ tarfile.errors)
+ else:
+ value = self._decode_pax_field(value, "utf8", "utf8",
+ tarfile.errors)
pax_headers[keyword] = value
pos += length
@@ -1402,6 +1447,19 @@ class TarInfo(object):
except HeaderError:
raise SubsequentHeaderError("missing or bad subsequent header")
+ # Process GNU sparse information.
+ if "GNU.sparse.map" in pax_headers:
+ # GNU extended sparse format version 0.1.
+ self._proc_gnusparse_01(next, pax_headers)
+
+ elif "GNU.sparse.size" in pax_headers:
+ # GNU extended sparse format version 0.0.
+ self._proc_gnusparse_00(next, pax_headers, buf)
+
+ elif pax_headers.get("GNU.sparse.major") == "1" and pax_headers.get("GNU.sparse.minor") == "0":
+ # GNU extended sparse format version 1.0.
+ self._proc_gnusparse_10(next, pax_headers, tarfile)
+
if self.type in (XHDTYPE, SOLARIS_XHDTYPE):
# Patch the TarInfo object with the extended header info.
next._apply_pax_info(pax_headers, tarfile.encoding, tarfile.errors)
@@ -1418,29 +1476,70 @@ class TarInfo(object):
return next
- def _apply_pax_info(self, pax_headers, encoding, errors):
- """Replace fields with supplemental information from a previous
- pax extended or global header.
+ def _proc_gnusparse_00(self, next, pax_headers, buf):
+ """Process a GNU tar extended sparse header, version 0.0.
"""
- for keyword, value in pax_headers.iteritems():
- if keyword not in PAX_FIELDS:
- continue
+ offsets = []
+ for match in re.finditer(br"\d+ GNU.sparse.offset=(\d+)\n", buf):
+ offsets.append(int(match.group(1)))
+ numbytes = []
+ for match in re.finditer(br"\d+ GNU.sparse.numbytes=(\d+)\n", buf):
+ numbytes.append(int(match.group(1)))
+ next.sparse = list(zip(offsets, numbytes))
- if keyword == "path":
- value = value.rstrip("/")
+ def _proc_gnusparse_01(self, next, pax_headers):
+ """Process a GNU tar extended sparse header, version 0.1.
+ """
+ sparse = [int(x) for x in pax_headers["GNU.sparse.map"].split(",")]
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
- if keyword in PAX_NUMBER_FIELDS:
- try:
- value = PAX_NUMBER_FIELDS[keyword](value)
- except ValueError:
- value = 0
- else:
- value = uts(value, encoding, errors)
+ def _proc_gnusparse_10(self, next, pax_headers, tarfile):
+ """Process a GNU tar extended sparse header, version 1.0.
+ """
+ fields = None
+ sparse = []
+ buf = tarfile.fileobj.read(BLOCKSIZE)
+ fields, buf = buf.split(b"\n", 1)
+ fields = int(fields)
+ while len(sparse) < fields * 2:
+ if b"\n" not in buf:
+ buf += tarfile.fileobj.read(BLOCKSIZE)
+ number, buf = buf.split(b"\n", 1)
+ sparse.append(int(number))
+ next.offset_data = tarfile.fileobj.tell()
+ next.sparse = list(zip(sparse[::2], sparse[1::2]))
- setattr(self, keyword, value)
+ def _apply_pax_info(self, pax_headers, encoding, errors):
+ """Replace fields with supplemental information from a previous
+ pax extended or global header.
+ """
+ for keyword, value in pax_headers.items():
+ if keyword == "GNU.sparse.name":
+ setattr(self, "path", value)
+ elif keyword == "GNU.sparse.size":
+ setattr(self, "size", int(value))
+ elif keyword == "GNU.sparse.realsize":
+ setattr(self, "size", int(value))
+ elif keyword in PAX_FIELDS:
+ if keyword in PAX_NUMBER_FIELDS:
+ try:
+ value = PAX_NUMBER_FIELDS[keyword](value)
+ except ValueError:
+ value = 0
+ if keyword == "path":
+ value = value.rstrip("/")
+ setattr(self, keyword, value)
self.pax_headers = pax_headers.copy()
+ def _decode_pax_field(self, value, encoding, fallback_encoding, fallback_errors):
+ """Decode a single field from a pax record.
+ """
+ try:
+ return value.decode(encoding, "strict")
+ except UnicodeDecodeError:
+ return value.decode(fallback_encoding, fallback_errors)
+
def _block(self, count):
"""Round up a byte count by BLOCKSIZE and return it,
e.g. _block(834) => 1024.
@@ -1467,7 +1566,7 @@ class TarInfo(object):
def isfifo(self):
return self.type == FIFOTYPE
def issparse(self):
- return self.type == GNUTYPE_SPARSE
+ return self.sparse is not None
def isdev(self):
return self.type in (CHRTYPE, BLKTYPE, FIFOTYPE)
# class TarInfo
@@ -1500,7 +1599,7 @@ class TarFile(object):
def __init__(self, name=None, mode="r", fileobj=None, format=None,
tarinfo=None, dereference=None, ignore_zeros=None, encoding=None,
- errors=None, pax_headers=None, debug=None, errorlevel=None):
+ errors="surrogateescape", pax_headers=None, debug=None, errorlevel=None):
"""Open an (uncompressed) tar archive `name'. `mode' is either 'r' to
read from an existing archive, 'a' to append data to an existing
file or 'w' to create a new file overwriting an existing one. `mode'
@@ -1541,13 +1640,7 @@ class TarFile(object):
self.ignore_zeros = ignore_zeros
if encoding is not None:
self.encoding = encoding
-
- if errors is not None:
- self.errors = errors
- elif mode == "r":
- self.errors = "utf-8"
- else:
- self.errors = "strict"
+ self.errors = errors
if pax_headers is not None and self.format == PAX_FORMAT:
self.pax_headers = pax_headers
@@ -1584,7 +1677,7 @@ class TarFile(object):
except EOFHeaderError:
self.fileobj.seek(self.offset)
break
- except HeaderError, e:
+ except HeaderError as e:
raise ReadError(str(e))
if self.mode in "aw":
@@ -1600,18 +1693,6 @@ class TarFile(object):
self.closed = True
raise
- def _getposix(self):
- return self.format == USTAR_FORMAT
- def _setposix(self, value):
- import warnings
- warnings.warn("use the format attribute instead", DeprecationWarning,
- 2)
- if value:
- self.format = USTAR_FORMAT
- else:
- self.format = GNU_FORMAT
- posix = property(_getposix, _setposix)
-
#--------------------------------------------------------------------------
# Below are the classmethods which act as alternate constructors to the
# TarFile class. The open() method is the only one that is needed for
@@ -1658,7 +1739,7 @@ class TarFile(object):
saved_pos = fileobj.tell()
try:
return func(name, "r", fileobj, **kwargs)
- except (ReadError, CompressionError), e:
+ except (ReadError, CompressionError) as e:
if fileobj is not None:
fileobj.seek(saved_pos)
continue
@@ -1685,9 +1766,12 @@ class TarFile(object):
if filemode not in "rw":
raise ValueError("mode must be 'r' or 'w'")
- t = cls(name, filemode,
- _Stream(name, filemode, comptype, fileobj, bufsize),
- **kwargs)
+ stream = _Stream(name, filemode, comptype, fileobj, bufsize)
+ try:
+ t = cls(name, filemode, stream, **kwargs)
+ except:
+ stream.close()
+ raise
t._extfileobj = False
return t
@@ -1718,16 +1802,21 @@ class TarFile(object):
except (ImportError, AttributeError):
raise CompressionError("gzip module is not available")
- if fileobj is None:
- fileobj = bltn_open(name, mode + "b")
-
+ extfileobj = fileobj is not None
try:
- t = cls.taropen(name, mode,
- gzip.GzipFile(name, mode, compresslevel, fileobj),
- **kwargs)
+ fileobj = gzip.GzipFile(name, mode + "b", compresslevel, fileobj)
+ t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
+ if not extfileobj and fileobj is not None:
+ fileobj.close()
+ if fileobj is None:
+ raise
raise ReadError("not a gzip file")
- t._extfileobj = False
+ except:
+ if not extfileobj and fileobj is not None:
+ fileobj.close()
+ raise
+ t._extfileobj = extfileobj
return t
@classmethod
@@ -1751,6 +1840,7 @@ class TarFile(object):
try:
t = cls.taropen(name, mode, fileobj, **kwargs)
except (IOError, EOFError):
+ fileobj.close()
raise ReadError("not a bzip2 file")
t._extfileobj = False
return t
@@ -1889,7 +1979,7 @@ class TarFile(object):
if type == REGTYPE:
tarinfo.size = statres.st_size
else:
- tarinfo.size = 0L
+ tarinfo.size = 0
tarinfo.mtime = statres.st_mtime
tarinfo.type = type
tarinfo.linkname = linkname
@@ -1919,27 +2009,27 @@ class TarFile(object):
for tarinfo in self:
if verbose:
- print filemode(tarinfo.mode),
- print "%s/%s" % (tarinfo.uname or tarinfo.uid,
- tarinfo.gname or tarinfo.gid),
+ print(filemode(tarinfo.mode), end=' ')
+ print("%s/%s" % (tarinfo.uname or tarinfo.uid,
+ tarinfo.gname or tarinfo.gid), end=' ')
if tarinfo.ischr() or tarinfo.isblk():
- print "%10s" % ("%d,%d" \
- % (tarinfo.devmajor, tarinfo.devminor)),
+ print("%10s" % ("%d,%d" \
+ % (tarinfo.devmajor, tarinfo.devminor)), end=' ')
else:
- print "%10d" % tarinfo.size,
- print "%d-%02d-%02d %02d:%02d:%02d" \
- % time.localtime(tarinfo.mtime)[:6],
+ print("%10d" % tarinfo.size, end=' ')
+ print("%d-%02d-%02d %02d:%02d:%02d" \
+ % time.localtime(tarinfo.mtime)[:6], end=' ')
- print tarinfo.name + ("/" if tarinfo.isdir() else ""),
+ print(tarinfo.name + ("/" if tarinfo.isdir() else ""), end=' ')
if verbose:
if tarinfo.issym():
- print "->", tarinfo.linkname,
+ print("->", tarinfo.linkname, end=' ')
if tarinfo.islnk():
- print "link to", tarinfo.linkname,
- print
+ 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, exclude=None, *, 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.
@@ -1995,7 +2085,7 @@ class TarFile(object):
if recursive:
for f in os.listdir(name):
self.add(os.path.join(name, f), os.path.join(arcname, f),
- recursive, exclude, filter)
+ recursive, exclude, filter=filter)
else:
self.addfile(tarinfo)
@@ -2043,11 +2133,12 @@ class TarFile(object):
# Extract directories with a safe mode.
directories.append(tarinfo)
tarinfo = copy.copy(tarinfo)
- tarinfo.mode = 0700
- self.extract(tarinfo, path)
+ tarinfo.mode = 0o700
+ # Do not set_attrs directories, as we will do that further down
+ self.extract(tarinfo, path, set_attrs=not tarinfo.isdir())
# Reverse sort directories.
- directories.sort(key=operator.attrgetter('name'))
+ directories.sort(key=lambda a: a.name)
directories.reverse()
# Set correct owner, mtime and filemode on directories.
@@ -2057,21 +2148,22 @@ class TarFile(object):
self.chown(tarinfo, dirpath)
self.utime(tarinfo, dirpath)
self.chmod(tarinfo, dirpath)
- except ExtractError, e:
+ except ExtractError as e:
if self.errorlevel > 1:
raise
else:
self._dbg(1, "tarfile: %s" % e)
- def extract(self, member, path=""):
+ def extract(self, member, path="", set_attrs=True):
"""Extract a member from the archive to the current working directory,
using its full name. Its file information is extracted as accurately
as possible. `member' may be a filename or a TarInfo object. You can
- specify a different directory using `path'.
+ specify a different directory using `path'. File attributes (owner,
+ mtime, mode) are set unless `set_attrs' is False.
"""
self._check("r")
- if isinstance(member, basestring):
+ if isinstance(member, str):
tarinfo = self.getmember(member)
else:
tarinfo = member
@@ -2081,8 +2173,9 @@ class TarFile(object):
tarinfo._link_target = os.path.join(path, tarinfo.linkname)
try:
- self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
- except EnvironmentError, e:
+ self._extract_member(tarinfo, os.path.join(path, tarinfo.name),
+ set_attrs=set_attrs)
+ except EnvironmentError as e:
if self.errorlevel > 0:
raise
else:
@@ -2090,7 +2183,7 @@ class TarFile(object):
self._dbg(1, "tarfile: %s" % e.strerror)
else:
self._dbg(1, "tarfile: %s %r" % (e.strerror, e.filename))
- except ExtractError, e:
+ except ExtractError as e:
if self.errorlevel > 1:
raise
else:
@@ -2107,7 +2200,7 @@ class TarFile(object):
"""
self._check("r")
- if isinstance(member, basestring):
+ if isinstance(member, str):
tarinfo = self.getmember(member)
else:
tarinfo = member
@@ -2134,7 +2227,7 @@ class TarFile(object):
# blkdev, etc.), return None instead of a file object.
return None
- def _extract_member(self, tarinfo, targetpath):
+ def _extract_member(self, tarinfo, targetpath, set_attrs=True):
"""Extract the TarInfo object tarinfo to a physical
file called targetpath.
"""
@@ -2171,10 +2264,11 @@ class TarFile(object):
else:
self.makefile(tarinfo, targetpath)
- self.chown(tarinfo, targetpath)
- if not tarinfo.issym():
- self.chmod(tarinfo, targetpath)
- self.utime(tarinfo, targetpath)
+ if set_attrs:
+ self.chown(tarinfo, targetpath)
+ if not tarinfo.issym():
+ self.chmod(tarinfo, targetpath)
+ self.utime(tarinfo, targetpath)
#--------------------------------------------------------------------------
# Below are the different file methods. They are called via
@@ -2187,20 +2281,25 @@ class TarFile(object):
try:
# Use a safe mode for the directory, the real mode is set
# later in _extract_member().
- os.mkdir(targetpath, 0700)
- except EnvironmentError, e:
+ os.mkdir(targetpath, 0o700)
+ except EnvironmentError as e:
if e.errno != errno.EEXIST:
raise
def makefile(self, tarinfo, targetpath):
"""Make a file called targetpath.
"""
- source = self.extractfile(tarinfo)
- try:
- with bltn_open(targetpath, "wb") as target:
- copyfileobj(source, target)
- finally:
- source.close()
+ source = self.fileobj
+ source.seek(tarinfo.offset_data)
+ with bltn_open(targetpath, "wb") as target:
+ if tarinfo.sparse is not None:
+ for offset, size in tarinfo.sparse:
+ target.seek(offset)
+ copyfileobj(source, target, size)
+ else:
+ copyfileobj(source, target, tarinfo.size)
+ target.seek(tarinfo.size)
+ target.truncate()
def makeunknown(self, tarinfo, targetpath):
"""Make a file from a TarInfo object with an unknown type
@@ -2238,23 +2337,21 @@ class TarFile(object):
(platform limitation), we try to make a copy of the referenced file
instead of a link.
"""
- if hasattr(os, "symlink") and hasattr(os, "link"):
+ try:
# For systems that support symbolic and hard links.
if tarinfo.issym():
- if os.path.lexists(targetpath):
- os.unlink(targetpath)
os.symlink(tarinfo.linkname, targetpath)
else:
# See extract().
if os.path.exists(tarinfo._link_target):
- if os.path.lexists(targetpath):
- os.unlink(targetpath)
os.link(tarinfo._link_target, targetpath)
else:
- self._extract_member(self._find_link_target(tarinfo), targetpath)
- else:
+ self._extract_member(self._find_link_target(tarinfo),
+ targetpath)
+ except symlink_exception:
try:
- self._extract_member(self._find_link_target(tarinfo), targetpath)
+ self._extract_member(self._find_link_target(tarinfo),
+ targetpath)
except KeyError:
raise ExtractError("unable to resolve link inside archive")
@@ -2277,7 +2374,7 @@ class TarFile(object):
else:
if sys.platform != "os2emx":
os.chown(targetpath, u, g)
- except EnvironmentError, e:
+ except EnvironmentError as e:
raise ExtractError("could not change owner")
def chmod(self, tarinfo, targetpath):
@@ -2286,7 +2383,7 @@ class TarFile(object):
if hasattr(os, 'chmod'):
try:
os.chmod(targetpath, tarinfo.mode)
- except EnvironmentError, e:
+ except EnvironmentError as e:
raise ExtractError("could not change mode")
def utime(self, tarinfo, targetpath):
@@ -2296,7 +2393,7 @@ class TarFile(object):
return
try:
os.utime(targetpath, (tarinfo.mtime, tarinfo.mtime))
- except EnvironmentError, e:
+ except EnvironmentError as e:
raise ExtractError("could not change modification time")
#--------------------------------------------------------------------------
@@ -2317,12 +2414,12 @@ class TarFile(object):
while True:
try:
tarinfo = self.tarinfo.fromtarfile(self)
- except EOFHeaderError, e:
+ except EOFHeaderError as e:
if self.ignore_zeros:
self._dbg(2, "0x%X: %s" % (self.offset, e))
self.offset += BLOCKSIZE
continue
- except InvalidHeaderError, e:
+ except InvalidHeaderError as e:
if self.ignore_zeros:
self._dbg(2, "0x%X: %s" % (self.offset, e))
self.offset += BLOCKSIZE
@@ -2332,10 +2429,10 @@ class TarFile(object):
except EmptyHeaderError:
if self.offset == 0:
raise ReadError("empty file")
- except TruncatedHeaderError, e:
+ except TruncatedHeaderError as e:
if self.offset == 0:
raise ReadError(str(e))
- except SubsequentHeaderError, e:
+ except SubsequentHeaderError as e:
raise ReadError(str(e))
break
@@ -2422,7 +2519,7 @@ class TarFile(object):
"""Write debugging output to sys.stderr.
"""
if level <= self.debug:
- print >> sys.stderr, msg
+ print(msg, file=sys.stderr)
def __enter__(self):
self._check()
@@ -2455,7 +2552,7 @@ class TarIter:
"""Return iterator object.
"""
return self
- def next(self):
+ def __next__(self):
"""Return the next item using TarFile's next() method.
When all members have been read, set TarFile as _loaded.
"""
@@ -2475,103 +2572,6 @@ class TarIter:
self.index += 1
return tarinfo
-# Helper classes for sparse file support
-class _section:
- """Base class for _data and _hole.
- """
- def __init__(self, offset, size):
- self.offset = offset
- self.size = size
- def __contains__(self, offset):
- return self.offset <= offset < self.offset + self.size
-
-class _data(_section):
- """Represent a data section in a sparse file.
- """
- def __init__(self, offset, size, realpos):
- _section.__init__(self, offset, size)
- self.realpos = realpos
-
-class _hole(_section):
- """Represent a hole section in a sparse file.
- """
- pass
-
-class _ringbuffer(list):
- """Ringbuffer class which increases performance
- over a regular list.
- """
- def __init__(self):
- self.idx = 0
- def find(self, offset):
- idx = self.idx
- while True:
- item = self[idx]
- if offset in item:
- break
- idx += 1
- if idx == len(self):
- idx = 0
- if idx == self.idx:
- # End of File
- return None
- self.idx = idx
- return item
-
-#---------------------------------------------
-# zipfile compatible TarFile class
-#---------------------------------------------
-TAR_PLAIN = 0 # zipfile.ZIP_STORED
-TAR_GZIPPED = 8 # zipfile.ZIP_DEFLATED
-class TarFileCompat:
- """TarFile class compatible with standard module zipfile's
- ZipFile class.
- """
- def __init__(self, file, mode="r", compression=TAR_PLAIN):
- from warnings import warnpy3k
- warnpy3k("the TarFileCompat class has been removed in Python 3.0",
- stacklevel=2)
- if compression == TAR_PLAIN:
- self.tarfile = TarFile.taropen(file, mode)
- elif compression == TAR_GZIPPED:
- self.tarfile = TarFile.gzopen(file, mode)
- else:
- raise ValueError("unknown compression constant")
- if mode[0:1] == "r":
- members = self.tarfile.getmembers()
- for m in members:
- m.filename = m.name
- m.file_size = m.size
- m.date_time = time.gmtime(m.mtime)[:6]
- def namelist(self):
- return map(lambda m: m.name, self.infolist())
- def infolist(self):
- return filter(lambda m: m.type in REGULAR_TYPES,
- self.tarfile.getmembers())
- def printdir(self):
- self.tarfile.list()
- def testzip(self):
- return
- def getinfo(self, name):
- return self.tarfile.getmember(name)
- def read(self, name):
- return self.tarfile.extractfile(self.tarfile.getmember(name)).read()
- def write(self, filename, arcname=None, compress_type=None):
- self.tarfile.add(filename, arcname)
- def writestr(self, zinfo, bytes):
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- import calendar
- tinfo = TarInfo(zinfo.filename)
- tinfo.size = len(bytes)
- tinfo.mtime = calendar.timegm(zinfo.date_time)
- self.tarfile.addfile(tinfo, StringIO(bytes))
- def close(self):
- self.tarfile.close()
-#class TarFileCompat
-
#--------------------
# exported functions
#--------------------
diff --git a/Lib/telnetlib.py b/Lib/telnetlib.py
index 727e8f7c688..a59693e7463 100644
--- a/Lib/telnetlib.py
+++ b/Lib/telnetlib.py
@@ -7,8 +7,8 @@ Example:
>>> from telnetlib import Telnet
>>> tn = Telnet('www.python.org', 79) # connect to finger port
->>> tn.write('guido\r\n')
->>> print tn.read_all()
+>>> tn.write(b'guido\r\n')
+>>> print(tn.read_all())
Login Name TTY Idle When Where
guido Guido van Rossum pts/2 <Dec 2 11:10> snag.cnri.reston..
@@ -19,7 +19,7 @@ Note that read_all() won't read until eof -- it just reads some data
It is possible to pass a Telnet object to select.select() in order to
wait until more data is available. Note that in this case,
-read_eager() may return '' even if there was data on the socket,
+read_eager() may return b'' even if there was data on the socket,
because the protocol negotiation may have eaten the data. This is why
EOFError is needed in some cases to distinguish between "no data" and
"connection closed" (since the socket also appears ready for reading
@@ -48,87 +48,87 @@ DEBUGLEVEL = 0
TELNET_PORT = 23
# Telnet protocol characters (don't change)
-IAC = chr(255) # "Interpret As Command"
-DONT = chr(254)
-DO = chr(253)
-WONT = chr(252)
-WILL = chr(251)
-theNULL = chr(0)
-
-SE = chr(240) # Subnegotiation End
-NOP = chr(241) # No Operation
-DM = chr(242) # Data Mark
-BRK = chr(243) # Break
-IP = chr(244) # Interrupt process
-AO = chr(245) # Abort output
-AYT = chr(246) # Are You There
-EC = chr(247) # Erase Character
-EL = chr(248) # Erase Line
-GA = chr(249) # Go Ahead
-SB = chr(250) # Subnegotiation Begin
+IAC = bytes([255]) # "Interpret As Command"
+DONT = bytes([254])
+DO = bytes([253])
+WONT = bytes([252])
+WILL = bytes([251])
+theNULL = bytes([0])
+
+SE = bytes([240]) # Subnegotiation End
+NOP = bytes([241]) # No Operation
+DM = bytes([242]) # Data Mark
+BRK = bytes([243]) # Break
+IP = bytes([244]) # Interrupt process
+AO = bytes([245]) # Abort output
+AYT = bytes([246]) # Are You There
+EC = bytes([247]) # Erase Character
+EL = bytes([248]) # Erase Line
+GA = bytes([249]) # Go Ahead
+SB = bytes([250]) # Subnegotiation Begin
# Telnet protocol options code (don't change)
# These ones all come from arpa/telnet.h
-BINARY = chr(0) # 8-bit data path
-ECHO = chr(1) # echo
-RCP = chr(2) # prepare to reconnect
-SGA = chr(3) # suppress go ahead
-NAMS = chr(4) # approximate message size
-STATUS = chr(5) # give status
-TM = chr(6) # timing mark
-RCTE = chr(7) # remote controlled transmission and echo
-NAOL = chr(8) # negotiate about output line width
-NAOP = chr(9) # negotiate about output page size
-NAOCRD = chr(10) # negotiate about CR disposition
-NAOHTS = chr(11) # negotiate about horizontal tabstops
-NAOHTD = chr(12) # negotiate about horizontal tab disposition
-NAOFFD = chr(13) # negotiate about formfeed disposition
-NAOVTS = chr(14) # negotiate about vertical tab stops
-NAOVTD = chr(15) # negotiate about vertical tab disposition
-NAOLFD = chr(16) # negotiate about output LF disposition
-XASCII = chr(17) # extended ascii character set
-LOGOUT = chr(18) # force logout
-BM = chr(19) # byte macro
-DET = chr(20) # data entry terminal
-SUPDUP = chr(21) # supdup protocol
-SUPDUPOUTPUT = chr(22) # supdup output
-SNDLOC = chr(23) # send location
-TTYPE = chr(24) # terminal type
-EOR = chr(25) # end or record
-TUID = chr(26) # TACACS user identification
-OUTMRK = chr(27) # output marking
-TTYLOC = chr(28) # terminal location number
-VT3270REGIME = chr(29) # 3270 regime
-X3PAD = chr(30) # X.3 PAD
-NAWS = chr(31) # window size
-TSPEED = chr(32) # terminal speed
-LFLOW = chr(33) # remote flow control
-LINEMODE = chr(34) # Linemode option
-XDISPLOC = chr(35) # X Display Location
-OLD_ENVIRON = chr(36) # Old - Environment variables
-AUTHENTICATION = chr(37) # Authenticate
-ENCRYPT = chr(38) # Encryption option
-NEW_ENVIRON = chr(39) # New - Environment variables
+BINARY = bytes([0]) # 8-bit data path
+ECHO = bytes([1]) # echo
+RCP = bytes([2]) # prepare to reconnect
+SGA = bytes([3]) # suppress go ahead
+NAMS = bytes([4]) # approximate message size
+STATUS = bytes([5]) # give status
+TM = bytes([6]) # timing mark
+RCTE = bytes([7]) # remote controlled transmission and echo
+NAOL = bytes([8]) # negotiate about output line width
+NAOP = bytes([9]) # negotiate about output page size
+NAOCRD = bytes([10]) # negotiate about CR disposition
+NAOHTS = bytes([11]) # negotiate about horizontal tabstops
+NAOHTD = bytes([12]) # negotiate about horizontal tab disposition
+NAOFFD = bytes([13]) # negotiate about formfeed disposition
+NAOVTS = bytes([14]) # negotiate about vertical tab stops
+NAOVTD = bytes([15]) # negotiate about vertical tab disposition
+NAOLFD = bytes([16]) # negotiate about output LF disposition
+XASCII = bytes([17]) # extended ascii character set
+LOGOUT = bytes([18]) # force logout
+BM = bytes([19]) # byte macro
+DET = bytes([20]) # data entry terminal
+SUPDUP = bytes([21]) # supdup protocol
+SUPDUPOUTPUT = bytes([22]) # supdup output
+SNDLOC = bytes([23]) # send location
+TTYPE = bytes([24]) # terminal type
+EOR = bytes([25]) # end or record
+TUID = bytes([26]) # TACACS user identification
+OUTMRK = bytes([27]) # output marking
+TTYLOC = bytes([28]) # terminal location number
+VT3270REGIME = bytes([29]) # 3270 regime
+X3PAD = bytes([30]) # X.3 PAD
+NAWS = bytes([31]) # window size
+TSPEED = bytes([32]) # terminal speed
+LFLOW = bytes([33]) # remote flow control
+LINEMODE = bytes([34]) # Linemode option
+XDISPLOC = bytes([35]) # X Display Location
+OLD_ENVIRON = bytes([36]) # Old - Environment variables
+AUTHENTICATION = bytes([37]) # Authenticate
+ENCRYPT = bytes([38]) # Encryption option
+NEW_ENVIRON = bytes([39]) # New - Environment variables
# the following ones come from
# http://www.iana.org/assignments/telnet-options
# Unfortunately, that document does not assign identifiers
# to all of them, so we are making them up
-TN3270E = chr(40) # TN3270E
-XAUTH = chr(41) # XAUTH
-CHARSET = chr(42) # CHARSET
-RSP = chr(43) # Telnet Remote Serial Port
-COM_PORT_OPTION = chr(44) # Com Port Control Option
-SUPPRESS_LOCAL_ECHO = chr(45) # Telnet Suppress Local Echo
-TLS = chr(46) # Telnet Start TLS
-KERMIT = chr(47) # KERMIT
-SEND_URL = chr(48) # SEND-URL
-FORWARD_X = chr(49) # FORWARD_X
-PRAGMA_LOGON = chr(138) # TELOPT PRAGMA LOGON
-SSPI_LOGON = chr(139) # TELOPT SSPI LOGON
-PRAGMA_HEARTBEAT = chr(140) # TELOPT PRAGMA HEARTBEAT
-EXOPL = chr(255) # Extended-Options-List
-NOOPT = chr(0)
+TN3270E = bytes([40]) # TN3270E
+XAUTH = bytes([41]) # XAUTH
+CHARSET = bytes([42]) # CHARSET
+RSP = bytes([43]) # Telnet Remote Serial Port
+COM_PORT_OPTION = bytes([44]) # Com Port Control Option
+SUPPRESS_LOCAL_ECHO = bytes([45]) # Telnet Suppress Local Echo
+TLS = bytes([46]) # Telnet Start TLS
+KERMIT = bytes([47]) # KERMIT
+SEND_URL = bytes([48]) # SEND-URL
+FORWARD_X = bytes([49]) # FORWARD_X
+PRAGMA_LOGON = bytes([138]) # TELOPT PRAGMA LOGON
+SSPI_LOGON = bytes([139]) # TELOPT SSPI LOGON
+PRAGMA_HEARTBEAT = bytes([140]) # TELOPT PRAGMA HEARTBEAT
+EXOPL = bytes([255]) # Extended-Options-List
+NOOPT = bytes([0])
class Telnet:
@@ -198,13 +198,13 @@ class Telnet:
self.port = port
self.timeout = timeout
self.sock = None
- self.rawq = ''
+ self.rawq = b''
self.irawq = 0
- self.cookedq = ''
+ self.cookedq = b''
self.eof = 0
- self.iacseq = '' # Buffer for IAC sequence.
+ self.iacseq = b'' # Buffer for IAC sequence.
self.sb = 0 # flag for SB and SE sequence.
- self.sbdataq = ''
+ self.sbdataq = b''
self.option_callback = None
self._has_poll = hasattr(select, 'poll')
if host is not None:
@@ -238,11 +238,11 @@ class Telnet:
"""
if self.debuglevel > 0:
- print 'Telnet(%s,%s):' % (self.host, self.port),
+ print('Telnet(%s,%s):' % (self.host, self.port), end=' ')
if args:
- print msg % args
+ print(msg % args)
else:
- print msg
+ print(msg)
def set_debuglevel(self, debuglevel):
"""Set the debug level.
@@ -258,7 +258,7 @@ class Telnet:
self.sock.close()
self.sock = 0
self.eof = 1
- self.iacseq = ''
+ self.iacseq = b''
self.sb = 0
def get_socket(self):
@@ -382,13 +382,13 @@ class Telnet:
self.fill_rawq()
self.process_rawq()
buf = self.cookedq
- self.cookedq = ''
+ self.cookedq = b''
return buf
def read_some(self):
"""Read at least one byte of cooked data unless EOF is hit.
- Return '' if EOF is hit. Block if no data is immediately
+ Return b'' if EOF is hit. Block if no data is immediately
available.
"""
@@ -397,14 +397,14 @@ class Telnet:
self.fill_rawq()
self.process_rawq()
buf = self.cookedq
- self.cookedq = ''
+ self.cookedq = b''
return buf
def read_very_eager(self):
"""Read everything that's possible without blocking in I/O (eager).
Raise EOFError if connection closed and no cooked data
- available. Return '' if no cooked data available otherwise.
+ available. Return b'' if no cooked data available otherwise.
Don't block unless in the midst of an IAC sequence.
"""
@@ -418,7 +418,7 @@ class Telnet:
"""Read readily available data.
Raise EOFError if connection closed and no cooked data
- available. Return '' if no cooked data available otherwise.
+ available. Return b'' if no cooked data available otherwise.
Don't block unless in the midst of an IAC sequence.
"""
@@ -432,7 +432,7 @@ class Telnet:
"""Process and return data that's already in the queues (lazy).
Raise EOFError if connection closed and no data available.
- Return '' if no cooked data available otherwise. Don't block
+ Return b'' if no cooked data available otherwise. Don't block
unless in the midst of an IAC sequence.
"""
@@ -443,25 +443,25 @@ class Telnet:
"""Return any data available in the cooked queue (very lazy).
Raise EOFError if connection closed and no data available.
- Return '' if no cooked data available otherwise. Don't block.
+ Return b'' if no cooked data available otherwise. Don't block.
"""
buf = self.cookedq
- self.cookedq = ''
+ self.cookedq = b''
if not buf and self.eof and not self.rawq:
- raise EOFError, 'telnet connection closed'
+ raise EOFError('telnet connection closed')
return buf
def read_sb_data(self):
"""Return any data available in the SB ... SE queue.
- Return '' if no SB ... SE available. Should only be called
+ Return b'' if no SB ... SE available. Should only be called
after seeing a SB or SE command. When a new SB command is
found, old unread SB data will be discarded. Don't block.
"""
buf = self.sbdataq
- self.sbdataq = ''
+ self.sbdataq = b''
return buf
def set_option_negotiation_callback(self, callback):
@@ -475,14 +475,14 @@ class Telnet:
the midst of an IAC sequence.
"""
- buf = ['', '']
+ buf = [b'', b'']
try:
while self.rawq:
c = self.rawq_getchar()
if not self.iacseq:
if c == theNULL:
continue
- if c == "\021":
+ if c == b"\021":
continue
if c != IAC:
buf[self.sb] = buf[self.sb] + c
@@ -495,17 +495,17 @@ class Telnet:
self.iacseq += c
continue
- self.iacseq = ''
+ self.iacseq = b''
if c == IAC:
buf[self.sb] = buf[self.sb] + c
else:
if c == SB: # SB ... SE start.
self.sb = 1
- self.sbdataq = ''
+ self.sbdataq = b''
elif c == SE:
self.sb = 0
self.sbdataq = self.sbdataq + buf[1]
- buf[1] = ''
+ buf[1] = b''
if self.option_callback:
# Callback is supposed to look into
# the sbdataq
@@ -516,8 +516,8 @@ class Telnet:
# unless we did a WILL/DO before.
self.msg('IAC %d not recognized' % ord(c))
elif len(self.iacseq) == 2:
- cmd = self.iacseq[1]
- self.iacseq = ''
+ cmd = self.iacseq[1:2]
+ self.iacseq = b''
opt = c
if cmd in (DO, DONT):
self.msg('IAC %s %d',
@@ -534,7 +534,7 @@ class Telnet:
else:
self.sock.sendall(IAC + DONT + opt)
except EOFError: # raised by self.rawq_getchar()
- self.iacseq = '' # Reset on EOF
+ self.iacseq = b'' # Reset on EOF
self.sb = 0
pass
self.cookedq = self.cookedq + buf[0]
@@ -551,10 +551,10 @@ class Telnet:
self.fill_rawq()
if self.eof:
raise EOFError
- c = self.rawq[self.irawq]
+ c = self.rawq[self.irawq:self.irawq+1]
self.irawq = self.irawq + 1
if self.irawq >= len(self.rawq):
- self.rawq = ''
+ self.rawq = b''
self.irawq = 0
return c
@@ -566,7 +566,7 @@ class Telnet:
"""
if self.irawq >= len(self.rawq):
- self.rawq = ''
+ self.rawq = b''
self.irawq = 0
# The buffer size should be fairly small so as to avoid quadratic
# behavior in process_rawq() above
@@ -590,26 +590,26 @@ class Telnet:
try:
text = self.read_eager()
except EOFError:
- print '*** Connection closed by remote host ***'
+ print('*** Connection closed by remote host ***')
break
if text:
- sys.stdout.write(text)
+ sys.stdout.write(text.decode('ascii'))
sys.stdout.flush()
if sys.stdin in rfd:
- line = sys.stdin.readline()
+ line = sys.stdin.readline().encode('ascii')
if not line:
break
self.write(line)
def mt_interact(self):
"""Multithreaded version of interact()."""
- import thread
- thread.start_new_thread(self.listener, ())
+ import _thread
+ _thread.start_new_thread(self.listener, ())
while 1:
line = sys.stdin.readline()
if not line:
break
- self.write(line)
+ self.write(line.encode('ascii'))
def listener(self):
"""Helper for mt_interact() -- this executes in the other thread."""
@@ -617,10 +617,10 @@ class Telnet:
try:
data = self.read_eager()
except EOFError:
- print '*** Connection closed by remote host ***'
+ print('*** Connection closed by remote host ***')
return
if data:
- sys.stdout.write(data)
+ sys.stdout.write(data.decode('ascii'))
else:
sys.stdout.flush()
diff --git a/Lib/tempfile.py b/Lib/tempfile.py
index 2023280d037..b8fc18c3bf7 100644
--- a/Lib/tempfile.py
+++ b/Lib/tempfile.py
@@ -19,7 +19,7 @@ This module also provides some data items to the user:
__all__ = [
"NamedTemporaryFile", "TemporaryFile", # high level safe interfaces
- "SpooledTemporaryFile",
+ "SpooledTemporaryFile", "TemporaryDirectory",
"mkstemp", "mkdtemp", # low level safe interfaces
"mktemp", # deprecated unsafe interface
"TMP_MAX", "gettempprefix", # constants
@@ -29,16 +29,14 @@ __all__ = [
# Imports.
+import warnings as _warnings
+import sys as _sys
+import io as _io
import os as _os
import errno as _errno
from random import Random as _Random
try:
- from cStringIO import StringIO as _StringIO
-except ImportError:
- from StringIO import StringIO as _StringIO
-
-try:
import fcntl as _fcntl
except ImportError:
def _set_cloexec(fd):
@@ -56,9 +54,9 @@ else:
try:
- import thread as _thread
+ import _thread
except ImportError:
- import dummy_thread as _thread
+ import _dummy_thread as _thread
_allocate_lock = _thread.allocate_lock
_text_openflags = _os.O_RDWR | _os.O_CREAT | _os.O_EXCL
@@ -112,13 +110,7 @@ class _RandomNameSequence:
_RandomNameSequence is an iterator."""
- characters = ("abcdefghijklmnopqrstuvwxyz" +
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
- "0123456789_")
-
- def __init__(self):
- self.mutex = _allocate_lock()
- self.normcase = _os.path.normcase
+ characters = "abcdefghijklmnopqrstuvwxyz0123456789_"
@property
def rng(self):
@@ -131,18 +123,11 @@ class _RandomNameSequence:
def __iter__(self):
return self
- def next(self):
- m = self.mutex
+ def __next__(self):
c = self.characters
choose = self.rng.choice
-
- m.acquire()
- try:
- letters = [choose(c) for dummy in "123456"]
- finally:
- m.release()
-
- return self.normcase(''.join(letters))
+ letters = [choose(c) for dummy in "123456"]
+ return ''.join(letters)
def _candidate_tempdir_list():
"""Generate a list of candidate temporary directories which
@@ -156,10 +141,7 @@ def _candidate_tempdir_list():
if dirname: dirlist.append(dirname)
# Failing that, try OS-specific locations.
- if _os.name == 'riscos':
- dirname = _os.getenv('Wimp$ScrapDir')
- if dirname: dirlist.append(dirname)
- elif _os.name == 'nt':
+ if _os.name == 'nt':
dirlist.extend([ r'c:\temp', r'c:\tmp', r'\temp', r'\tmp' ])
else:
dirlist.extend([ '/tmp', '/var/tmp', '/usr/tmp' ])
@@ -183,29 +165,28 @@ def _get_default_tempdir():
namer = _RandomNameSequence()
dirlist = _candidate_tempdir_list()
- flags = _text_openflags
for dir in dirlist:
if dir != _os.curdir:
dir = _os.path.normcase(_os.path.abspath(dir))
# Try only a few names per directory.
- for seq in xrange(100):
- name = namer.next()
+ for seq in range(100):
+ name = next(namer)
filename = _os.path.join(dir, name)
try:
- fd = _os.open(filename, flags, 0600)
- fp = _os.fdopen(fd, 'w')
- fp.write('blat')
+ fd = _os.open(filename, _bin_openflags, 0o600)
+ fp = _io.open(fd, 'wb')
+ fp.write(b'blat')
fp.close()
_os.unlink(filename)
del fp, fd
return dir
- except (OSError, IOError), e:
- if e[0] != _errno.EEXIST:
+ except (OSError, IOError) as e:
+ if e.args[0] != _errno.EEXIST:
break # no point trying more names in this directory
pass
- raise IOError, (_errno.ENOENT,
- ("No usable temporary directory found in %s" % dirlist))
+ raise IOError(_errno.ENOENT,
+ "No usable temporary directory found in %s" % dirlist)
_name_sequence = None
@@ -228,19 +209,19 @@ def _mkstemp_inner(dir, pre, suf, flags):
names = _get_candidate_names()
- for seq in xrange(TMP_MAX):
- name = names.next()
+ for seq in range(TMP_MAX):
+ name = next(names)
file = _os.path.join(dir, pre + name + suf)
try:
- fd = _os.open(file, flags, 0600)
+ fd = _os.open(file, flags, 0o600)
_set_cloexec(fd)
return (fd, _os.path.abspath(file))
- except OSError, e:
+ except OSError as e:
if e.errno == _errno.EEXIST:
continue # try again
raise
- raise IOError, (_errno.EEXIST, "No usable temporary file name found")
+ raise IOError(_errno.EEXIST, "No usable temporary file name found")
# User visible interfaces.
@@ -318,18 +299,18 @@ def mkdtemp(suffix="", prefix=template, dir=None):
names = _get_candidate_names()
- for seq in xrange(TMP_MAX):
- name = names.next()
+ for seq in range(TMP_MAX):
+ name = next(names)
file = _os.path.join(dir, prefix + name + suffix)
try:
- _os.mkdir(file, 0700)
+ _os.mkdir(file, 0o700)
return file
- except OSError, e:
+ except OSError as e:
if e.errno == _errno.EEXIST:
continue # try again
raise
- raise IOError, (_errno.EEXIST, "No usable temporary directory name found")
+ raise IOError(_errno.EEXIST, "No usable temporary directory name found")
def mktemp(suffix="", prefix=template, dir=None):
"""User-callable function to return a unique temporary file name. The
@@ -352,13 +333,13 @@ def mktemp(suffix="", prefix=template, dir=None):
dir = gettempdir()
names = _get_candidate_names()
- for seq in xrange(TMP_MAX):
- name = names.next()
+ for seq in range(TMP_MAX):
+ name = next(names)
file = _os.path.join(dir, prefix + name + suffix)
if not _exists(file):
return file
- raise IOError, (_errno.EEXIST, "No usable temporary filename found")
+ raise IOError(_errno.EEXIST, "No usable temporary filename found")
class _TemporaryFileWrapper:
@@ -381,7 +362,7 @@ class _TemporaryFileWrapper:
# (i.e. methods are cached, closed and friends are not)
file = self.__dict__['file']
a = getattr(file, name)
- if not issubclass(type(a), type(0)):
+ if not isinstance(a, int):
setattr(self, name, a)
return a
@@ -391,6 +372,10 @@ class _TemporaryFileWrapper:
self.file.__enter__()
return self
+ # iter() doesn't use __getattr__ to find the __iter__ method
+ def __iter__(self):
+ return iter(self.file)
+
# NT provides delete-on-close as a primitive, so we don't need
# the wrapper to do anything special. We still use it so that
# file.name is useful (i.e. not "(fdopen)") with NamedTemporaryFile.
@@ -423,13 +408,16 @@ class _TemporaryFileWrapper:
self.file.__exit__(exc, value, tb)
-def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
- prefix=template, dir=None, delete=True):
+def NamedTemporaryFile(mode='w+b', buffering=-1, encoding=None,
+ newline=None, suffix="", prefix=template,
+ dir=None, delete=True):
"""Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
- 'mode' -- the mode argument to os.fdopen (default "w+b").
- 'bufsize' -- the buffer size argument to os.fdopen (default -1).
+ 'mode' -- the mode argument to io.open (default "w+b").
+ 'buffering' -- the buffer size argument to io.open (default -1).
+ 'encoding' -- the encoding argument to io.open (default None)
+ 'newline' -- the newline argument to io.open (default None)
'delete' -- whether the file is deleted on close (default True).
The file is created as mkstemp() would do it.
@@ -441,10 +429,7 @@ def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
if dir is None:
dir = gettempdir()
- if 'b' in mode:
- flags = _bin_openflags
- else:
- flags = _text_openflags
+ flags = _bin_openflags
# Setting O_TEMPORARY in the flags causes the OS to delete
# the file when it is closed. This is only supported by Windows.
@@ -452,7 +437,9 @@ def NamedTemporaryFile(mode='w+b', bufsize=-1, suffix="",
flags |= _os.O_TEMPORARY
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
- file = _os.fdopen(fd, mode, bufsize)
+ file = _io.open(fd, mode, buffering=buffering,
+ newline=newline, encoding=encoding)
+
return _TemporaryFileWrapper(file, name, delete)
if _os.name != 'posix' or _os.sys.platform == 'cygwin':
@@ -461,13 +448,16 @@ if _os.name != 'posix' or _os.sys.platform == 'cygwin':
TemporaryFile = NamedTemporaryFile
else:
- def TemporaryFile(mode='w+b', bufsize=-1, suffix="",
- prefix=template, dir=None):
+ def TemporaryFile(mode='w+b', buffering=-1, encoding=None,
+ newline=None, suffix="", prefix=template,
+ dir=None):
"""Create and return a temporary file.
Arguments:
'prefix', 'suffix', 'dir' -- as for mkstemp.
- 'mode' -- the mode argument to os.fdopen (default "w+b").
- 'bufsize' -- the buffer size argument to os.fdopen (default -1).
+ 'mode' -- the mode argument to io.open (default "w+b").
+ 'buffering' -- the buffer size argument to io.open (default -1).
+ 'encoding' -- the encoding argument to io.open (default None)
+ 'newline' -- the newline argument to io.open (default None)
The file is created as mkstemp() would do it.
Returns an object with a file-like interface. The file has no
@@ -477,15 +467,13 @@ else:
if dir is None:
dir = gettempdir()
- if 'b' in mode:
- flags = _bin_openflags
- else:
- flags = _text_openflags
+ flags = _bin_openflags
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags)
try:
_os.unlink(name)
- return _os.fdopen(fd, mode, bufsize)
+ return _io.open(fd, mode, buffering=buffering,
+ newline=newline, encoding=encoding)
except:
_os.close(fd)
raise
@@ -497,12 +485,22 @@ class SpooledTemporaryFile:
"""
_rolled = False
- def __init__(self, max_size=0, mode='w+b', bufsize=-1,
+ def __init__(self, max_size=0, mode='w+b', buffering=-1,
+ encoding=None, newline=None,
suffix="", prefix=template, dir=None):
- self._file = _StringIO()
+ if 'b' in mode:
+ self._file = _io.BytesIO()
+ else:
+ # Setting newline="\n" avoids newline translation;
+ # this is important because otherwise on Windows we'd
+ # hget double newline translation upon rollover().
+ self._file = _io.StringIO(newline="\n")
self._max_size = max_size
self._rolled = False
- self._TemporaryFileArgs = (mode, bufsize, suffix, prefix, dir)
+ self._TemporaryFileArgs = {'mode': mode, 'buffering': buffering,
+ 'suffix': suffix, 'prefix': prefix,
+ 'encoding': encoding, 'newline': newline,
+ 'dir': dir}
def _check(self, file):
if self._rolled: return
@@ -513,7 +511,7 @@ class SpooledTemporaryFile:
def rollover(self):
if self._rolled: return
file = self._file
- newfile = self._file = TemporaryFile(*self._TemporaryFileArgs)
+ newfile = self._file = TemporaryFile(**self._TemporaryFileArgs)
del self._TemporaryFileArgs
newfile.write(file.getvalue())
@@ -611,3 +609,86 @@ class SpooledTemporaryFile:
def xreadlines(self, *args):
return self._file.xreadlines(*args)
+
+
+class TemporaryDirectory(object):
+ """Create and return a temporary directory. This has the same
+ behavior as mkdtemp but can be used as a context manager. For
+ example:
+
+ with TemporaryDirectory() as tmpdir:
+ ...
+
+ Upon exiting the context, the directory and everthing contained
+ in it are removed.
+ """
+
+ def __init__(self, suffix="", prefix=template, dir=None):
+ self._closed = False
+ self.name = None # Handle mkdtemp raising an exception
+ self.name = mkdtemp(suffix, prefix, dir)
+
+ def __repr__(self):
+ return "<{} {!r}>".format(self.__class__.__name__, self.name)
+
+ def __enter__(self):
+ return self.name
+
+ def cleanup(self, _warn=False):
+ if self.name and not self._closed:
+ try:
+ self._rmtree(self.name)
+ except (TypeError, AttributeError) as ex:
+ # Issue #10188: Emit a warning on stderr
+ # if the directory could not be cleaned
+ # up due to missing globals
+ if "None" not in str(ex):
+ raise
+ print("ERROR: {!r} while cleaning up {!r}".format(ex, self,),
+ file=_sys.stderr)
+ return
+ self._closed = True
+ if _warn:
+ self._warn("Implicitly cleaning up {!r}".format(self),
+ ResourceWarning)
+
+ def __exit__(self, exc, value, tb):
+ self.cleanup()
+
+ def __del__(self):
+ # Issue a ResourceWarning if implicit cleanup needed
+ self.cleanup(_warn=True)
+
+ # XXX (ncoghlan): The following code attempts to make
+ # this class tolerant of the module nulling out process
+ # that happens during CPython interpreter shutdown
+ # Alas, it doesn't actually manage it. See issue #10188
+ _listdir = staticmethod(_os.listdir)
+ _path_join = staticmethod(_os.path.join)
+ _isdir = staticmethod(_os.path.isdir)
+ _islink = staticmethod(_os.path.islink)
+ _remove = staticmethod(_os.remove)
+ _rmdir = staticmethod(_os.rmdir)
+ _os_error = _os.error
+ _warn = _warnings.warn
+
+ def _rmtree(self, path):
+ # Essentially a stripped down version of shutil.rmtree. We can't
+ # use globals because they may be None'ed out at shutdown.
+ for name in self._listdir(path):
+ fullname = self._path_join(path, name)
+ try:
+ isdir = self._isdir(fullname) and not self._islink(fullname)
+ except self._os_error:
+ isdir = False
+ if isdir:
+ self._rmtree(fullname)
+ else:
+ try:
+ self._remove(fullname)
+ except self._os_error:
+ pass
+ try:
+ self._rmdir(path)
+ except self._os_error:
+ pass
diff --git a/Lib/test/__main__.py b/Lib/test/__main__.py
new file mode 100644
index 00000000000..ce5615b8890
--- /dev/null
+++ b/Lib/test/__main__.py
@@ -0,0 +1,13 @@
+from test import regrtest, support
+
+
+TEMPDIR, TESTCWD = regrtest._make_temp_dir_for_build(regrtest.TEMPDIR)
+regrtest.TEMPDIR = TEMPDIR
+regrtest.TESTCWD = TESTCWD
+
+# Run the tests in a context manager that temporary changes the CWD to a
+# temporary and writable directory. If it's not possible to create or
+# change the CWD, the original CWD will be used. The original CWD is
+# available from support.SAVEDCWD.
+with support.temp_cwd(TESTCWD, quiet=True):
+ regrtest.main()
diff --git a/Lib/test/bad_coding2.py b/Lib/test/bad_coding2.py
index ea901b500ac..bb2bb7e1e75 100644
--- a/Lib/test/bad_coding2.py
+++ b/Lib/test/bad_coding2.py
@@ -1,2 +1,2 @@
#coding: utf8
-print '我'
+print('我')
diff --git a/Lib/test/badsyntax_3131.py b/Lib/test/badsyntax_3131.py
new file mode 100644
index 00000000000..901d3744ca0
--- /dev/null
+++ b/Lib/test/badsyntax_3131.py
@@ -0,0 +1,2 @@
+# -*- coding: utf-8 -*-
+€ = 2
diff --git a/Lib/test/badsyntax_future8.py b/Lib/test/badsyntax_future8.py
index c167b0933df..ca45289e2e5 100644
--- a/Lib/test/badsyntax_future8.py
+++ b/Lib/test/badsyntax_future8.py
@@ -7,4 +7,4 @@ def f(x):
return x + y
return g
-print f(2)(4)
+print(f(2)(4))
diff --git a/Lib/test/badsyntax_future9.py b/Lib/test/badsyntax_future9.py
index cdce32a4ebb..916de06ab71 100644
--- a/Lib/test/badsyntax_future9.py
+++ b/Lib/test/badsyntax_future9.py
@@ -7,4 +7,4 @@ def f(x):
return x + y
return g
-print f(2)(4)
+print(f(2)(4))
diff --git a/Lib/test/badsyntax_nocaret.py b/Lib/test/badsyntax_nocaret.py
deleted file mode 100644
index 01ec9ea5f0b..00000000000
--- a/Lib/test/badsyntax_nocaret.py
+++ /dev/null
@@ -1,2 +0,0 @@
-def f(x):
- [x for x in x] = x
diff --git a/Lib/test/badsyntax_pep3120.py b/Lib/test/badsyntax_pep3120.py
new file mode 100644
index 00000000000..d14b4c96ede
--- /dev/null
+++ b/Lib/test/badsyntax_pep3120.py
@@ -0,0 +1 @@
+print("böse")
diff --git a/Lib/test/buffer_tests.py b/Lib/test/buffer_tests.py
index d0d8a56f0ed..6d20f7d9e10 100644
--- a/Lib/test/buffer_tests.py
+++ b/Lib/test/buffer_tests.py
@@ -112,7 +112,7 @@ class MixinBytesBufferCommonTests(object):
self.assertEqual(b'abc ', self.marshal(b'abc').ljust(6))
self.assertEqual(b'abc', self.marshal(b'abc').ljust(3))
self.assertEqual(b'abc', self.marshal(b'abc').ljust(2))
- self.assertEqual(b'abc*******', self.marshal(b'abc').ljust(10, '*'))
+ self.assertEqual(b'abc*******', self.marshal(b'abc').ljust(10, b'*'))
self.assertRaises(TypeError, self.marshal(b'abc').ljust)
def test_rjust(self):
@@ -120,7 +120,7 @@ class MixinBytesBufferCommonTests(object):
self.assertEqual(b' abc', self.marshal(b'abc').rjust(6))
self.assertEqual(b'abc', self.marshal(b'abc').rjust(3))
self.assertEqual(b'abc', self.marshal(b'abc').rjust(2))
- self.assertEqual(b'*******abc', self.marshal(b'abc').rjust(10, '*'))
+ self.assertEqual(b'*******abc', self.marshal(b'abc').rjust(10, b'*'))
self.assertRaises(TypeError, self.marshal(b'abc').rjust)
def test_center(self):
@@ -128,7 +128,7 @@ class MixinBytesBufferCommonTests(object):
self.assertEqual(b' abc ', self.marshal(b'abc').center(6))
self.assertEqual(b'abc', self.marshal(b'abc').center(3))
self.assertEqual(b'abc', self.marshal(b'abc').center(2))
- self.assertEqual(b'***abc****', self.marshal(b'abc').center(10, '*'))
+ self.assertEqual(b'***abc****', self.marshal(b'abc').center(10, b'*'))
self.assertRaises(TypeError, self.marshal(b'abc').center)
def test_swapcase(self):
@@ -172,9 +172,9 @@ class MixinBytesBufferCommonTests(object):
self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42)
# This test is only valid when sizeof(int) == sizeof(void*) == 4.
- if sys.maxint < (1 << 32) and struct.calcsize('P') == 4:
+ if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
self.assertRaises(OverflowError,
- self.marshal(b'\ta\n\tb').expandtabs, sys.maxint)
+ self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize)
def test_title(self):
self.assertEqual(b' Hello ', self.marshal(b' hello ').title())
diff --git a/Lib/test/capath/4e1295a3.0 b/Lib/test/capath/4e1295a3.0
new file mode 100644
index 00000000000..9d7ac238d86
--- /dev/null
+++ b/Lib/test/capath/4e1295a3.0
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
+VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
+bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
+dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
+DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
+EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
+dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
+EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
+MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
+L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
+BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
+9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/5ed36f99.0 b/Lib/test/capath/5ed36f99.0
new file mode 100644
index 00000000000..e7dfc82947e
--- /dev/null
+++ b/Lib/test/capath/5ed36f99.0
@@ -0,0 +1,41 @@
+-----BEGIN CERTIFICATE-----
+MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290
+IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB
+IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA
+Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO
+BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi
+MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ
+ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
+CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ
+8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6
+zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y
+fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7
+w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc
+G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k
+epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q
+laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ
+QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU
+fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826
+YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w
+ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY
+gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe
+MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0
+IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy
+dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw
+czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0
+dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl
+aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC
+AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg
+b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
+ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc
+nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg
+18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c
+gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl
+Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY
+sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T
+SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF
+CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum
+GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk
+zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW
+omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/6e88d7b8.0 b/Lib/test/capath/6e88d7b8.0
new file mode 100644
index 00000000000..9d7ac238d86
--- /dev/null
+++ b/Lib/test/capath/6e88d7b8.0
@@ -0,0 +1,14 @@
+-----BEGIN CERTIFICATE-----
+MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
+VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
+bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
+dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
+DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
+EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
+dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
+EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
+MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
+L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
+BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
+9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+-----END CERTIFICATE-----
diff --git a/Lib/test/capath/99d0fa06.0 b/Lib/test/capath/99d0fa06.0
new file mode 100644
index 00000000000..e7dfc82947e
--- /dev/null
+++ b/Lib/test/capath/99d0fa06.0
@@ -0,0 +1,41 @@
+-----BEGIN CERTIFICATE-----
+MIIHPTCCBSWgAwIBAgIBADANBgkqhkiG9w0BAQQFADB5MRAwDgYDVQQKEwdSb290
+IENBMR4wHAYDVQQLExVodHRwOi8vd3d3LmNhY2VydC5vcmcxIjAgBgNVBAMTGUNB
+IENlcnQgU2lnbmluZyBBdXRob3JpdHkxITAfBgkqhkiG9w0BCQEWEnN1cHBvcnRA
+Y2FjZXJ0Lm9yZzAeFw0wMzAzMzAxMjI5NDlaFw0zMzAzMjkxMjI5NDlaMHkxEDAO
+BgNVBAoTB1Jvb3QgQ0ExHjAcBgNVBAsTFWh0dHA6Ly93d3cuY2FjZXJ0Lm9yZzEi
+MCAGA1UEAxMZQ0EgQ2VydCBTaWduaW5nIEF1dGhvcml0eTEhMB8GCSqGSIb3DQEJ
+ARYSc3VwcG9ydEBjYWNlcnQub3JnMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIIC
+CgKCAgEAziLA4kZ97DYoB1CW8qAzQIxL8TtmPzHlawI229Z89vGIj053NgVBlfkJ
+8BLPRoZzYLdufujAWGSuzbCtRRcMY/pnCujW0r8+55jE8Ez64AO7NV1sId6eINm6
+zWYyN3L69wj1x81YyY7nDl7qPv4coRQKFWyGhFtkZip6qUtTefWIonvuLwphK42y
+fk1WpRPs6tqSnqxEQR5YYGUFZvjARL3LlPdCfgv3ZWiYUQXw8wWRBB0bF4LsyFe7
+w2t6iPGwcswlWyCR7BYCEo8y6RcYSNDHBS4CMEK4JZwFaz+qOqfrU0j36NK2B5jc
+G8Y0f3/JHIJ6BVgrCFvzOKKrF11myZjXnhCLotLddJr3cQxyYN/Nb5gznZY0dj4k
+epKwDpUeb+agRThHqtdB7Uq3EvbXG4OKDy7YCbZZ16oE/9KTfWgu3YtLq1i6L43q
+laegw1SJpfvbi1EinbLDvhG+LJGGi5Z4rSDTii8aP8bQUWWHIbEZAWV/RRyH9XzQ
+QUxPKZgh/TMfdQwEUfoZd9vUFBzugcMd9Zi3aQaRIt0AUMyBMawSB3s42mhb5ivU
+fslfrejrckzzAeVLIL+aplfKkQABi6F1ITe1Yw1nPkZPcCBnzsXWWdsC4PDSy826
+YreQQejdIOQpvGQpQsgi3Hia/0PsmBsJUUtaWsJx8cTLc6nloQsCAwEAAaOCAc4w
+ggHKMB0GA1UdDgQWBBQWtTIb1Mfz4OaO873SsDrusjkY0TCBowYDVR0jBIGbMIGY
+gBQWtTIb1Mfz4OaO873SsDrusjkY0aF9pHsweTEQMA4GA1UEChMHUm9vdCBDQTEe
+MBwGA1UECxMVaHR0cDovL3d3dy5jYWNlcnQub3JnMSIwIAYDVQQDExlDQSBDZXJ0
+IFNpZ25pbmcgQXV0aG9yaXR5MSEwHwYJKoZIhvcNAQkBFhJzdXBwb3J0QGNhY2Vy
+dC5vcmeCAQAwDwYDVR0TAQH/BAUwAwEB/zAyBgNVHR8EKzApMCegJaAjhiFodHRw
+czovL3d3dy5jYWNlcnQub3JnL3Jldm9rZS5jcmwwMAYJYIZIAYb4QgEEBCMWIWh0
+dHBzOi8vd3d3LmNhY2VydC5vcmcvcmV2b2tlLmNybDA0BglghkgBhvhCAQgEJxYl
+aHR0cDovL3d3dy5jYWNlcnQub3JnL2luZGV4LnBocD9pZD0xMDBWBglghkgBhvhC
+AQ0ESRZHVG8gZ2V0IHlvdXIgb3duIGNlcnRpZmljYXRlIGZvciBGUkVFIGhlYWQg
+b3ZlciB0byBodHRwOi8vd3d3LmNhY2VydC5vcmcwDQYJKoZIhvcNAQEEBQADggIB
+ACjH7pyCArpcgBLKNQodgW+JapnM8mgPf6fhjViVPr3yBsOQWqy1YPaZQwGjiHCc
+nWKdpIevZ1gNMDY75q1I08t0AoZxPuIrA2jxNGJARjtT6ij0rPtmlVOKTV39O9lg
+18p5aTuxZZKmxoGCXJzN600BiqXfEVWqFcofN8CCmHBh22p8lqOOLlQ+TyGpkO/c
+gr/c6EWtTZBzCDyUZbAEmXZ/4rzCahWqlwQ3JNgelE5tDlG+1sSPypZt90Pf6DBl
+Jzt7u0NDY8RD97LsaMzhGY4i+5jhe1o+ATc7iwiwovOVThrLm82asduycPAtStvY
+sONvRUgzEv/+PDIqVPfE94rwiCPCR/5kenHA0R6mY7AHfqQv0wGP3J8rtsYIqQ+T
+SCX8Ev2fQtzzxD72V7DX3WnRBnc0CkvSyqD/HMaMyRa+xMwyN2hzXwj7UfdJUzYF
+CpUCTPJ5GhD22Dp1nPMd8aINcGeGG7MW9S/lpOt5hvk9C8JzC6WZrG/8Z7jlLwum
+GCSNe9FINSkYQKyTYOGWhlC0elnYjyELn8+CkcY7v2vcB5G5l1YjqrZslMZIBjzk
+zk6q5PYvCdxTby78dOs6Y5nCpqyJvKeyRKANihDjbPIky/qbn3BHLt4Ui9SyIAmW
+omTxJBzcoTWcFbLUvFUufQb1nA5V9FrWk9p2rSVzTMVD
+-----END CERTIFICATE-----
diff --git a/Lib/test/cfgparser.2 b/Lib/test/cfgparser.2
new file mode 100644
index 00000000000..19a420a9a5c
--- /dev/null
+++ b/Lib/test/cfgparser.2
@@ -0,0 +1,537 @@
+# This is the main Samba configuration file. You should read the
+# smb.conf(5) manual page in order to understand the options listed
+# here. Samba has a huge number of configurable options (perhaps too
+# many!) most of which are not shown in this example
+#
+# Any line which starts with a ; (semi-colon) or a # (hash)
+# is a comment and is ignored. In this example we will use a #
+# for commentry and a ; for parts of the config file that you
+# may wish to enable
+#
+# NOTE: Whenever you modify this file you should run the command #"testparm" # to check that you have not made any basic syntactic #errors.
+#
+#======================= Global Settings =====================================
+[global]
+
+# 1. Server Naming Options:
+# workgroup = NT-Domain-Name or Workgroup-Name
+
+ workgroup = MDKGROUP
+
+# netbios name is the name you will see in "Network Neighbourhood",
+# but defaults to your hostname
+
+; netbios name = <name_of_this_server>
+
+# server string is the equivalent of the NT Description field
+
+ server string = Samba Server %v
+
+# Message command is run by samba when a "popup" message is sent to it.
+# The example below is for use with LinPopUp:
+; message command = /usr/bin/linpopup "%f" "%m" %s; rm %s
+
+# 2. Printing Options:
+# CHANGES TO ENABLE PRINTING ON ALL CUPS PRINTERS IN THE NETWORK
+# (as cups is now used in linux-mandrake 7.2 by default)
+# if you want to automatically load your printer list rather
+# than setting them up individually then you'll need this
+
+ printcap name = lpstat
+ load printers = yes
+
+# It should not be necessary to spell out the print system type unless
+# yours is non-standard. Currently supported print systems include:
+# bsd, sysv, plp, lprng, aix, hpux, qnx, cups
+
+ printing = cups
+
+# Samba 2.2 supports the Windows NT-style point-and-print feature. To
+# use this, you need to be able to upload print drivers to the samba
+# server. The printer admins (or root) may install drivers onto samba.
+# Note that this feature uses the print$ share, so you will need to
+# enable it below.
+# This parameter works like domain admin group:
+# printer admin = @<group> <user>
+; printer admin = @adm
+# This should work well for winbind:
+; printer admin = @"Domain Admins"
+
+# 3. Logging Options:
+# this tells Samba to use a separate log file for each machine
+# that connects
+
+ log file = /var/log/samba/log.%m
+
+# Put a capping on the size of the log files (in Kb).
+ max log size = 50
+
+# Set the log (verbosity) level (0 <= log level <= 10)
+; log level = 3
+
+# 4. Security and Domain Membership Options:
+# This option is important for security. It allows you to restrict
+# connections to machines which are on your local network. The
+# following example restricts access to two C class networks and
+# the "loopback" interface. For more examples of the syntax see
+# the smb.conf man page. Do not enable this if (tcp/ip) name resolution #does
+# not work for all the hosts in your network.
+; hosts allow = 192.168.1. 192.168.2. 127.
+
+ hosts allow = 127. //note this is only my private IP address
+
+# Uncomment this if you want a guest account, you must add this to
+# /etc/passwd
+# otherwise the user "nobody" is used
+; guest account = pcguest
+
+# Security mode. Most people will want user level security. See
+# security_level.txt for details.
+
+ security = user
+
+# Use password server option only with security = server or security = # domain
+# When using security = domain, you should use password server = *
+; password server =
+; password server = *
+
+# Password Level allows matching of _n_ characters of the password for
+# all combinations of upper and lower case.
+
+ password level = 8
+
+; username level = 8
+
+# You may wish to use password encryption. Please read
+# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.
+# Do not enable this option unless you have read those documents
+# Encrypted passwords are required for any use of samba in a Windows NT #domain
+# The smbpasswd file is only required by a server doing authentication, #thus members of a domain do not need one.
+
+ encrypt passwords = yes
+ smb passwd file = /etc/samba/smbpasswd
+
+# The following are needed to allow password changing from Windows to
+# also update the Linux system password.
+# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.
+# NOTE2: You do NOT need these to allow workstations to change only
+# the encrypted SMB passwords. They allow the Unix password
+# to be kept in sync with the SMB password.
+; unix password sync = Yes
+# You either need to setup a passwd program and passwd chat, or
+# enable pam password change
+; pam password change = yes
+; passwd program = /usr/bin/passwd %u
+; passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password*
+# %n\n
+;*passwd:*all*authentication*tokens*updated*successfully*
+
+# Unix users can map to different SMB User names
+; username map = /etc/samba/smbusers
+
+# Using the following line enables you to customise your configuration
+# on a per machine basis. The %m gets replaced with the netbios name
+# of the machine that is connecting
+; include = /etc/samba/smb.conf.%m
+
+# Options for using winbind. Winbind allows you to do all account and
+# authentication from a Windows or samba domain controller, creating
+# accounts on the fly, and maintaining a mapping of Windows RIDs to
+# unix uid's
+# and gid's. winbind uid and winbind gid are the only required
+# parameters.
+#
+# winbind uid is the range of uid's winbind can use when mapping RIDs #to uid's
+; winbind uid = 10000-20000
+#
+# winbind gid is the range of uid's winbind can use when mapping RIDs
+# to gid's
+; winbind gid = 10000-20000
+#
+# winbind separator is the character a user must use between their
+# domain name and username, defaults to "\"
+; winbind separator = +
+#
+# winbind use default domain allows you to have winbind return
+# usernames in the form user instead of DOMAIN+user for the domain
+# listed in the workgroup parameter.
+; winbind use default domain = yes
+#
+# template homedir determines the home directory for winbind users,
+# with %D expanding to their domain name and %U expanding to their
+# username:
+; template homedir = /home/%D/%U
+
+# When using winbind, you may want to have samba create home
+# directories on the fly for authenticated users. Ensure that
+# /etc/pam.d/samba is using 'service=system-auth-winbind' in pam_stack
+# modules, and then enable obedience of pam restrictions below:
+; obey pam restrictions = yes
+
+#
+# template shell determines the shell users authenticated by winbind #get
+; template shell = /bin/bash
+
+# 5. Browser Control and Networking Options:
+# Most people will find that this option gives better performance.
+# See speed.txt and the manual pages for details
+
+ socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
+
+# Configure Samba to use multiple interfaces
+# If you have multiple network interfaces then you must list them
+# here. See the man page for details.
+; interfaces = 192.168.12.2/24 192.168.13.2/24
+
+# Configure remote browse list synchronisation here
+# request announcement to, or browse list sync from:
+# a specific host or from / to a whole subnet (see below)
+; remote browse sync = 192.168.3.25 192.168.5.255
+# Cause this host to announce itself to local subnets here
+; remote announce = 192.168.1.255 192.168.2.44
+
+# set local master to no if you don't want Samba to become a master
+# browser on your network. Otherwise the normal election rules apply
+; local master = no
+
+# OS Level determines the precedence of this server in master browser
+# elections. The default value should be reasonable
+; os level = 33
+
+# Domain Master specifies Samba to be the Domain Master Browser. This
+# allows Samba to collate browse lists between subnets. Don't use this
+# if you already have a Windows NT domain controller doing this job
+; domain master = yes
+
+# Preferred Master causes Samba to force a local browser election on
+# startup and gives it a slightly higher chance of winning the election
+; preferred master = yes
+
+# 6. Domain Control Options:
+# Enable this if you want Samba to be a domain logon server for
+# Windows95 workstations or Primary Domain Controller for WinNT and
+# Win2k
+
+; domain logons = yes
+
+
+# if you enable domain logons then you may want a per-machine or
+# per user logon script
+# run a specific logon batch file per workstation (machine)
+; logon script = %m.bat
+# run a specific logon batch file per username
+; logon script = %U.bat
+
+# Where to store roaming profiles for WinNT and Win2k
+# %L substitutes for this servers netbios name, %U is username
+# You must uncomment the [Profiles] share below
+; logon path = \\%L\Profiles\%U
+
+# Where to store roaming profiles for Win9x. Be careful with this as it
+# also impacts where Win2k finds it's /HOME share
+; logon home = \\%L\%U\.profile
+
+# The add user script is used by a domain member to add local user
+# accounts that have been authenticated by the domain controller, or by
+# the domain controller to add local machine accounts when adding
+# machines to the domain.
+# The script must work from the command line when replacing the macros,
+# or the operation will fail. Check that groups exist if forcing a
+# group.
+# Script for domain controller for adding machines:
+; add user script = /usr/sbin/useradd -d /dev/null -g machines –c
+# 'Machine Account' -s /bin/false -M %u
+# Script for domain controller with LDAP backend for adding machines
+#(please
+# configure in /etc/samba/smbldap_conf.pm first):
+; add user script = /usr/share/samba/scripts/smbldap-useradd.pl -w –d
+# /dev/null -g machines -c 'Machine Account' -s /bin/false %u
+# Script for domain member for adding local accounts for authenticated
+# users:
+; add user script = /usr/sbin/useradd -s /bin/false %u
+
+# Domain groups:
+# domain admin group is a list of unix users or groups who are made
+# members
+# of the Domain Admin group
+; domain admin group = root @wheel
+#
+# domain guest groups is a list of unix users or groups who are made
+# members
+# of the Domain Guests group
+; domain guest group = nobody @guest
+
+# LDAP configuration for Domain Controlling:
+# The account (dn) that samba uses to access the LDAP server
+# This account needs to have write access to the LDAP tree
+# You will need to give samba the password for this dn, by
+# running 'smbpasswd -w mypassword'
+; ldap admin dn = cn=root,dc=mydomain,dc=com
+; ldap ssl = start_tls
+# start_tls should run on 389, but samba defaults incorrectly to 636
+; ldap port = 389
+; ldap suffix = dc=mydomain,dc=com
+; ldap server = ldap.mydomain.com
+
+
+# 7. Name Resolution Options:
+# All NetBIOS names must be resolved to IP Addresses
+# 'Name Resolve Order' allows the named resolution mechanism to be
+# specified the default order is "host lmhosts wins bcast". "host"
+# means use the unix system gethostbyname() function call that will use
+# either /etc/hosts OR DNS or NIS depending on the settings of
+# /etc/host.config, /etc/nsswitch.conf
+# and the /etc/resolv.conf file. "host" therefore is system
+# configuration dependant. This parameter is most often of use to
+# prevent DNS lookups
+# in order to resolve NetBIOS names to IP Addresses. Use with care!
+# The example below excludes use of name resolution for machines that
+# are NOT on the local network segment - OR - are not deliberately to
+# be known via lmhosts or via WINS.
+; name resolve order = wins lmhosts bcast
+
+# Windows Internet Name Serving Support Section:
+# WINS Support - Tells the NMBD component of Samba to enable it's WINS
+# Server
+; wins support = yes
+
+# WINS Server - Tells the NMBD components of Samba to be a WINS Client
+# Note: Samba can be either a WINS Server, or a WINS Client, but
+# NOT both
+; wins server = w.x.y.z
+
+# WINS Proxy - Tells Samba to answer name resolution queries on
+# behalf of a non WINS capable client, for this to work there must be
+# at least one WINS Server on the network. The default is NO.
+; wins proxy = yes
+
+# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS
+# names via DNS nslookups. The built-in default for versions 1.9.17 is
+# yes, this has been changed in version 1.9.18 to no.
+
+ dns proxy = no
+
+# 8. File Naming Options:
+# Case Preservation can be handy - system default is _no_
+# NOTE: These can be set on a per share basis
+; preserve case = no
+; short preserve case = no
+# Default case is normally upper case for all DOS files
+; default case = lower
+# Be very careful with case sensitivity - it can break things!
+; case sensitive = no
+
+# Enabling internationalization:
+# you can match a Windows code page with a UNIX character set.
+# Windows: 437 (US), 737 (GREEK), 850 (Latin1 - Western European),
+# 852 (Eastern Eu.), 861 (Icelandic), 932 (Cyrillic - Russian),
+# 936 (Japanese - Shift-JIS), 936 (Simpl. Chinese), 949 (Korean
+# Hangul),
+# 950 (Trad. Chin.).
+# UNIX: ISO8859-1 (Western European), ISO8859-2 (Eastern Eu.),
+# ISO8859-5 (Russian Cyrillic), KOI8-R (Alt-Russ. Cyril.)
+# This is an example for french users:
+; client code page = 850
+; character set = ISO8859-1
+
+#============================ Share Definitions ==============================
+
+[homes]
+ comment = Home Directories
+ browseable = no
+ writable = yes
+
+# You can enable VFS recycle bin on a per share basis:
+# Uncomment the next 2 lines (make sure you create a
+# .recycle folder in the base of the share and ensure
+# all users will have write access to it. See
+# examples/VFS/recycle/REAME in samba-doc for details
+; vfs object = /usr/lib/samba/vfs/recycle.so
+; vfs options= /etc/samba/recycle.conf
+
+# Un-comment the following and create the netlogon directory for Domain
+# Logons
+; [netlogon]
+; comment = Network Logon Service
+; path = /var/lib/samba/netlogon
+; guest ok = yes
+; writable = no
+
+#Uncomment the following 2 lines if you would like your login scripts
+# to be created dynamically by ntlogon (check that you have it in the
+# correct location (the default of the ntlogon rpm available in
+# contribs)
+
+;root preexec = /usr/bin/ntlogon -u %U -g %G -o %a -d /var/lib/samba/netlogon
+;root postexec = rm -f /var/lib/samba/netlogon/%U.bat
+
+# Un-comment the following to provide a specific roving profile share
+# the default is to use the user's home directory
+;[Profiles]
+; path = /var/lib/samba/profiles
+; browseable = no
+; guest ok = yes
+
+
+# NOTE: If you have a CUPS print system there is no need to
+# specifically define each individual printer.
+# You must configure the samba printers with the appropriate Windows
+# drivers on your Windows clients. On the Samba server no filtering is
+# done. If you wish that the server provides the driver and the clients
+# send PostScript ("Generic PostScript Printer" under Windows), you
+# have to swap the 'print command' line below with the commented one.
+
+[printers]
+ comment = All Printers
+ path = /var/spool/samba
+ browseable = no
+# to allow user 'guest account' to print.
+ guest ok = yes
+ writable = no
+ printable = yes
+ create mode = 0700
+
+# =====================================
+# print command: see above for details.
+# =====================================
+
+ print command = lpr-cups -P %p -o raw %s -r
+# using client side printer drivers.
+; print command = lpr-cups -P %p %s
+# using cups own drivers (use generic PostScript on clients).
+# The following two commands are the samba defaults for printing=cups
+# change them only if you need different options:
+; lpq command = lpq -P %p
+; lprm command = cancel %p-%j
+
+# This share is used for Windows NT-style point-and-print support.
+# To be able to install drivers, you need to be either root, or listed
+# in the printer admin parameter above. Note that you also need write
+# access to the directory and share definition to be able to upload the
+# drivers.
+# For more information on this, please see the Printing Support Section
+# of /usr/share/doc/samba-/docs/Samba-HOWTO-Collection.pdf
+
+[print$]
+ path = /var/lib/samba/printers
+ browseable = yes
+ read only = yes
+ write list = @adm root
+
+# A useful application of samba is to make a PDF-generation service
+# To streamline this, install windows postscript drivers (preferably
+# colour)on the samba server, so that clients can automatically install
+# them.
+
+[pdf-generator]
+ path = /var/tmp
+ guest ok = No
+ printable = Yes
+ comment = PDF Generator (only valid users)
+ #print command = /usr/share/samba/scripts/print-pdf file path win_path recipient IP &
+ print command = /usr/share/samba/scripts/print-pdf %s ~%u \\\\\\\\%L\\\\%u %m %I &
+
+# This one is useful for people to share files
+[tmp]
+ comment = Temporary file space
+ path = /tmp
+ read only = no
+ public = yes
+ echo command = cat %s; rm %s
+
+# A publicly accessible directory, but read only, except for people in
+# the "staff" group
+
+
+
+
+;[public]
+; comment = Public Stuff
+; path = /home/samba/public
+; public = yes
+; writable = no
+; write list = @staff
+# Audited directory through experimental VFS audit.so module:
+# Uncomment next line.
+; vfs object = /usr/lib/samba/vfs/audit.so
+
+# Other examples.
+#
+# A private printer, usable only by Fred. Spool data will be placed in
+# Fred's
+# home directory. Note that fred must have write access to the spool
+# directory,
+# wherever it is.
+;[fredsprn]
+; comment = Fred's Printer
+; valid users = fred
+; path = /homes/fred
+; printer = freds_printer
+; public = no
+; writable = no
+; printable = yes
+
+
+-----------------------------------------------------------
+# A private directory, usable only by Fred. Note that Fred requires
+# write access to the directory.
+
+;[fredsdir]
+
+ [Agustin]
+; comment = Fred's Service
+ comment = Agustin Private Files
+; path = /usr/somewhere/private
+ path = /home/agustin/Documents
+; valid users = fred
+ valid users = agustin
+; public = no
+; writable = yes
+ writable = yes
+; printable = no
+
+
+-----------------------------------------------------------
+
+# a service which has a different directory for each machine that
+# connects this allows you to tailor configurations to incoming
+# machines. You could also use the %u option to tailor it by user name.
+# The %m gets replaced with the machine name that is connecting.
+;[pchome]
+; comment = PC Directories
+; path = /usr/pc/%m
+; public = no
+; writable = yes
+
+
+-----------------------------------------------------------
+# A publicly accessible directory, read/write to all users. Note that
+# all files created in the directory by users will be owned by the
+# default user, so any user with access can delete any other user's
+# files. Obviously this directory must be writable by the default user.
+# Another user could of course be specified, in which case all files
+# would be owned by that user instead.
+
+;[public]
+; path = /usr/somewhere/else/public
+; public = yes
+; only guest = yes
+; writable = yes
+; printable = no
+
+-----------------------------------------------------------
+
+# The following two entries demonstrate how to share a directory so
+# that two users can place files there that will be owned by the
+# specific users. In this setup, the directory should be writable by
+# both users and should have the sticky bit set on it to prevent abuse.
+# Obviously this could be extended to as many users as required.
+
+;[myshare]
+; comment = Mary's and Fred's stuff
+; path = /usr/somewhere/shared
+; valid users = mary fred
+; public = no
+; writable = yes
+; printable = no
+; create mask = 0765
diff --git a/Lib/test/cfgparser.3 b/Lib/test/cfgparser.3
new file mode 100644
index 00000000000..c182cd739c2
--- /dev/null
+++ b/Lib/test/cfgparser.3
@@ -0,0 +1,69 @@
+ # INI with as many tricky parts as possible
+ # Most of them could not be used before 3.2
+
+ # This will be parsed with the following options
+ # delimiters = {'='}
+ # comment_prefixes = {'#'}
+ # allow_no_value = True
+
+[DEFAULT]
+go = %(interpolate)s
+
+[strange]
+ values = that are indented # and end with hash comments
+ other = that do continue
+ in # and still have
+ other # comments mixed
+ lines # with the values
+
+
+
+
+
+[corruption]
+ value = that is
+
+
+ actually still here
+
+
+ and holds all these weird newlines
+
+
+ # but not for the lines that are comments
+ nor the indentation
+
+ another value = # empty string
+ yet another # None!
+
+ [yeah, sections can be indented as well]
+ and that does not mean = anything
+ are they subsections = False
+ if you want subsections = use XML
+ lets use some Unicode = 片仮å
+
+ [another one!]
+ even if values are indented like this = seriously
+yes, this still applies to = section "another one!"
+this too = are there people with configurations broken as this?
+ beware, this is going to be a continuation
+ of the value for
+ key "this too"
+ even if it has a = character
+ this is still the continuation
+ your editor probably highlights it wrong
+ but that's life
+# let's set this value so there is no error
+# when getting all items for this section:
+interpolate = anything will do
+
+[no values here]
+# but there's this `go` in DEFAULT
+
+ [tricky interpolation]
+ interpolate = do this
+ lets = %(go)s
+
+ [more interpolation]
+ interpolate = go shopping
+ lets = %(go)s
diff --git a/Lib/test/cmath_testcases.txt b/Lib/test/cmath_testcases.txt
index e159380507d..9b0865302ec 100644
--- a/Lib/test/cmath_testcases.txt
+++ b/Lib/test/cmath_testcases.txt
@@ -733,10 +733,11 @@ asinh1036 asinh -inf inf -> -inf 0.78539816339744828
---------------------------
-- zeros
-atan0000 atan 0.0 0.0 -> 0.0 0.0
-atan0001 atan 0.0 -0.0 -> 0.0 -0.0
-atan0002 atan -0.0 0.0 -> -0.0 0.0
-atan0003 atan -0.0 -0.0 -> -0.0 -0.0
+-- These are tested in testAtanSign in test_cmath.py
+-- atan0000 atan 0.0 0.0 -> 0.0 0.0
+-- atan0001 atan 0.0 -0.0 -> 0.0 -0.0
+-- atan0002 atan -0.0 0.0 -> -0.0 0.0
+-- atan0003 atan -0.0 -0.0 -> -0.0 -0.0
-- values along both sides of imaginary axis
atan0010 atan 0.0 -9.8813129168249309e-324 -> 0.0 -9.8813129168249309e-324
@@ -896,10 +897,11 @@ atan1040 atan -inf -inf -> -1.5707963267948966 -0.0
---------------------------------------
-- zeros
-atanh0000 atanh 0.0 0.0 -> 0.0 0.0
-atanh0001 atanh 0.0 -0.0 -> 0.0 -0.0
-atanh0002 atanh -0.0 0.0 -> -0.0 0.0
-atanh0003 atanh -0.0 -0.0 -> -0.0 -0.0
+-- These are tested in testAtanhSign in test_cmath.py
+-- atanh0000 atanh 0.0 0.0 -> 0.0 0.0
+-- atanh0001 atanh 0.0 -0.0 -> 0.0 -0.0
+-- atanh0002 atanh -0.0 0.0 -> -0.0 0.0
+-- atanh0003 atanh -0.0 -0.0 -> -0.0 -0.0
-- values along both sides of real axis
atanh0010 atanh -9.8813129168249309e-324 0.0 -> -9.8813129168249309e-324 0.0
@@ -1858,11 +1860,14 @@ sinh1052 sinh -inf inf -> inf nan invalid ignore-real-sign
-- tanh: Hyperbolic Tangent --
------------------------------
--- zeros
-tanh0000 tanh 0.0 0.0 -> 0.0 0.0
-tanh0001 tanh 0.0 -0.0 -> 0.0 -0.0
-tanh0002 tanh -0.0 0.0 -> -0.0 0.0
-tanh0003 tanh -0.0 -0.0 -> -0.0 -0.0
+-- Disabled test: replaced by test_math.testTanhSign()
+-- and test_cmath.testTanhSign()
+
+-- -- zeros
+-- tanh0000 tanh 0.0 0.0 -> 0.0 0.0
+-- tanh0001 tanh 0.0 -0.0 -> 0.0 -0.0
+-- tanh0002 tanh -0.0 0.0 -> -0.0 0.0
+-- tanh0003 tanh -0.0 -0.0 -> -0.0 -0.0
-- random inputs
tanh0004 tanh -21.200500450664993 -1.6970729480342996 -> -1.0 1.9241352344849399e-19
diff --git a/Lib/test/crashers/bogus_code_obj.py b/Lib/test/crashers/bogus_code_obj.py
index 613ae518d4e..198d229491b 100644
--- a/Lib/test/crashers/bogus_code_obj.py
+++ b/Lib/test/crashers/bogus_code_obj.py
@@ -14,6 +14,6 @@ the user build or load random bytecodes anyway. Otherwise, this is a
import types
-co = types.CodeType(0, 0, 0, 0, '\x04\x71\x00\x00', (),
- (), (), '', '', 1, '')
-exec co
+co = types.CodeType(0, 0, 0, 0, 0, b'\x04\x71\x00\x00',
+ (), (), (), '', '', 1, b'')
+exec(co)
diff --git a/Lib/test/crashers/borrowed_ref_1.py b/Lib/test/crashers/borrowed_ref_1.py
index d16ede2e461..b82f4644bf9 100644
--- a/Lib/test/crashers/borrowed_ref_1.py
+++ b/Lib/test/crashers/borrowed_ref_1.py
@@ -8,7 +8,7 @@ class A(object):
class B(object):
def __del__(self):
- print 'hi'
+ print('hi')
del D.__missing__
class D(dict):
diff --git a/Lib/test/crashers/borrowed_ref_2.py b/Lib/test/crashers/borrowed_ref_2.py
index 1a7b3ff7504..6e403eb344c 100644
--- a/Lib/test/crashers/borrowed_ref_2.py
+++ b/Lib/test/crashers/borrowed_ref_2.py
@@ -10,7 +10,7 @@ class A(object):
class B(object):
def __del__(self):
- print "hi"
+ print("hi")
del C.d
class D(object):
@@ -33,6 +33,6 @@ lst = [None] * 1000000
i = 0
del a
while 1:
- c.d = 42 # segfaults in PyMethod_New(im_func=D.__set__, im_self=d)
+ c.d = 42 # segfaults in PyMethod_New(__func__=D.__set__, __self__=d)
lst[i] = c.g # consume the free list of instancemethod objects
i += 1
diff --git a/Lib/test/crashers/buffer_mutate.py b/Lib/test/crashers/buffer_mutate.py
deleted file mode 100644
index d68d7cc0fc6..00000000000
--- a/Lib/test/crashers/buffer_mutate.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# The various methods of bufferobject.c (here buffer_subscript()) call
-# get_buf() before calling potentially more Python code (here via
-# PySlice_GetIndicesEx()). But get_buf() already returned a void*
-# pointer. This void* pointer can become invalid if the object
-# underlying the buffer is mutated (here a bytearray object).
-#
-# As usual, please keep in mind that the three "here" in the sentence
-# above are only examples. Each can be changed easily and lead to
-# another crasher.
-#
-# This crashes for me on Linux 32-bits with CPython 2.6 and 2.7
-# with a segmentation fault.
-#
-
-
-class PseudoIndex(object):
- def __index__(self):
- for c in "foobar"*n:
- a.append(c)
- return n * 4
-
-
-for n in range(1, 100000, 100):
- a = bytearray("test"*n)
- buf = buffer(a)
-
- s = buf[:PseudoIndex():1]
- #print repr(s)
- #assert s == "test"*n
diff --git a/Lib/test/crashers/decref_before_assignment.py b/Lib/test/crashers/decref_before_assignment.py
deleted file mode 100644
index b5b17fa1498..00000000000
--- a/Lib/test/crashers/decref_before_assignment.py
+++ /dev/null
@@ -1,44 +0,0 @@
-"""
-General example for an attack against code like this:
-
- Py_DECREF(obj->attr); obj->attr = ...;
-
-here in Module/_json.c:scanner_init().
-
-Explanation: if the first Py_DECREF() calls either a __del__ or a
-weakref callback, it will run while the 'obj' appears to have in
-'obj->attr' still the old reference to the object, but not holding
-the reference count any more.
-
-Status: progress has been made replacing these cases, but there is an
-infinite number of such cases.
-"""
-
-import _json, weakref
-
-class Ctx1(object):
- encoding = "utf8"
- strict = None
- object_hook = None
- object_pairs_hook = None
- parse_float = None
- parse_int = None
- parse_constant = None
-
-class Foo(unicode):
- pass
-
-def delete_me(*args):
- print scanner.encoding.__dict__
-
-class Ctx2(Ctx1):
- @property
- def encoding(self):
- global wref
- f = Foo("utf8")
- f.abc = globals()
- wref = weakref.ref(f, delete_me)
- return f
-
-scanner = _json.make_scanner(Ctx1())
-scanner.__init__(Ctx2())
diff --git a/Lib/test/crashers/gc_has_finalizer.py b/Lib/test/crashers/gc_has_finalizer.py
deleted file mode 100644
index 737959bb9b5..00000000000
--- a/Lib/test/crashers/gc_has_finalizer.py
+++ /dev/null
@@ -1,36 +0,0 @@
-"""
-The gc module can still invoke arbitrary Python code and crash.
-This is an attack against _PyInstance_Lookup(), which is documented
-as follows:
-
- The point of this routine is that it never calls arbitrary Python
- code, so is always "safe": all it does is dict lookups.
-
-But of course dict lookups can call arbitrary Python code.
-The following code causes mutation of the object graph during
-the call to has_finalizer() in gcmodule.c, and that might
-segfault.
-"""
-
-import gc
-
-
-class A:
- def __hash__(self):
- return hash("__del__")
- def __eq__(self, other):
- del self.other
- return False
-
-a = A()
-b = A()
-
-a.__dict__[b] = 'A'
-
-a.other = b
-b.other = a
-
-gc.collect()
-del a, b
-
-gc.collect()
diff --git a/Lib/test/crashers/gc_inspection.py b/Lib/test/crashers/gc_inspection.py
index 10caa797825..ae85f97a74a 100644
--- a/Lib/test/crashers/gc_inspection.py
+++ b/Lib/test/crashers/gc_inspection.py
@@ -25,8 +25,8 @@ def g():
yield marker
# now the marker is in the tuple being constructed
[tup] = [x for x in gc.get_referrers(marker) if type(x) is tuple]
- print tup
- print tup[1]
+ print(tup)
+ print(tup[1])
tuple(g())
diff --git a/Lib/test/crashers/loosing_mro_ref.py b/Lib/test/crashers/loosing_mro_ref.py
index b5fa93b53d4..b3bcd32c58c 100644
--- a/Lib/test/crashers/loosing_mro_ref.py
+++ b/Lib/test/crashers/loosing_mro_ref.py
@@ -10,7 +10,7 @@ class MyKey(object):
def __hash__(self):
return hash('mykey')
- def __cmp__(self, other):
+ def __eq__(self, other):
# the following line decrefs the previous X.__mro__
X.__bases__ = (Base2,)
# trash all tuples of length 3, to make sure that the items of
@@ -18,7 +18,7 @@ class MyKey(object):
z = []
for i in range(1000):
z.append((i, None, None))
- return -1
+ return 0
class Base(object):
@@ -31,5 +31,5 @@ class Base2(object):
# there from the beginning :-)
X = type('X', (Base,), {MyKey(): 5})
-print X.mykey
+print(X.mykey)
# I get a segfault, or a slightly wrong assertion error in a debug build.
diff --git a/Lib/test/crashers/nasty_eq_vs_dict.py b/Lib/test/crashers/nasty_eq_vs_dict.py
index 3f3083da89d..85f7cafa238 100644
--- a/Lib/test/crashers/nasty_eq_vs_dict.py
+++ b/Lib/test/crashers/nasty_eq_vs_dict.py
@@ -44,4 +44,4 @@ dict = {y: "OK!"}
z = Yuck()
y.make_dangerous()
-print dict[z]
+print(dict[z])
diff --git a/Lib/test/crashers/recursive_call.py b/Lib/test/crashers/recursive_call.py
index 31c89633032..2d160a7de5d 100644
--- a/Lib/test/crashers/recursive_call.py
+++ b/Lib/test/crashers/recursive_call.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# No bug report AFAIK, mail on python-dev on 2006-01-10
diff --git a/Lib/test/crashers/trace_at_recursion_limit.py b/Lib/test/crashers/trace_at_recursion_limit.py
new file mode 100644
index 00000000000..acd863f5509
--- /dev/null
+++ b/Lib/test/crashers/trace_at_recursion_limit.py
@@ -0,0 +1,27 @@
+"""
+From http://bugs.python.org/issue6717
+
+A misbehaving trace hook can trigger a segfault by exceeding the recursion
+limit.
+"""
+import sys
+
+
+def x():
+ pass
+
+def g(*args):
+ if True: # change to True to crash interpreter
+ try:
+ x()
+ except:
+ pass
+ return g
+
+def f():
+ print(sys.getrecursionlimit())
+ f()
+
+sys.settrace(g)
+
+f()
diff --git a/Lib/test/crashers/underlying_dict.py b/Lib/test/crashers/underlying_dict.py
new file mode 100644
index 00000000000..a4b79937438
--- /dev/null
+++ b/Lib/test/crashers/underlying_dict.py
@@ -0,0 +1,20 @@
+import gc
+
+thingy = object()
+class A(object):
+ def f(self):
+ return 1
+ x = thingy
+
+r = gc.get_referrers(thingy)
+if "__module__" in r[0]:
+ dct = r[0]
+else:
+ dct = r[1]
+
+a = A()
+for i in range(10):
+ a.f()
+dct["f"] = lambda self: 2
+
+print(a.f()) # should print 1
diff --git a/Lib/test/curses_tests.py b/Lib/test/curses_tests.py
index 7dedbbc937e..40e832dec25 100644
--- a/Lib/test/curses_tests.py
+++ b/Lib/test/curses_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# $Id: ncurses.py 36559 2004-07-18 05:56:09Z tim_one $
#
diff --git a/Lib/test/data/README b/Lib/test/data/README
index 8bf8c9b31e0..bd05984e439 100644
--- a/Lib/test/data/README
+++ b/Lib/test/data/README
@@ -1,2 +1,2 @@
This empty directory serves as destination for temporary files
-created by some tests.
+created by some tests, in particular, the test_codecmaps_* tests.
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
new file mode 100644
index 00000000000..bb18630339d
--- /dev/null
+++ b/Lib/test/datetimetester.py
@@ -0,0 +1,3685 @@
+"""Test date/time type.
+
+See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
+"""
+
+import sys
+import pickle
+import unittest
+
+from operator import lt, le, gt, ge, eq, ne, truediv, floordiv, mod
+
+from test import support
+
+import datetime as datetime_module
+from datetime import MINYEAR, MAXYEAR
+from datetime import timedelta
+from datetime import tzinfo
+from datetime import time
+from datetime import timezone
+from datetime import date, datetime
+import time as _time
+
+# Needed by test_datetime
+import _strptime
+#
+
+
+pickle_choices = [(pickle, pickle, proto)
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1)]
+assert len(pickle_choices) == pickle.HIGHEST_PROTOCOL + 1
+
+# An arbitrary collection of objects of non-datetime types, for testing
+# mixed-type comparisons.
+OTHERSTUFF = (10, 34.5, "abc", {}, [], ())
+
+
+# XXX Copied from test_float.
+INF = float("inf")
+NAN = float("nan")
+
+
+#############################################################################
+# module tests
+
+class TestModule(unittest.TestCase):
+
+ def test_constants(self):
+ datetime = datetime_module
+ self.assertEqual(datetime.MINYEAR, 1)
+ self.assertEqual(datetime.MAXYEAR, 9999)
+
+#############################################################################
+# tzinfo tests
+
+class FixedOffset(tzinfo):
+
+ def __init__(self, offset, name, dstoffset=42):
+ if isinstance(offset, int):
+ offset = timedelta(minutes=offset)
+ if isinstance(dstoffset, int):
+ dstoffset = timedelta(minutes=dstoffset)
+ self.__offset = offset
+ self.__name = name
+ self.__dstoffset = dstoffset
+ def __repr__(self):
+ return self.__name.lower()
+ def utcoffset(self, dt):
+ return self.__offset
+ def tzname(self, dt):
+ return self.__name
+ def dst(self, dt):
+ return self.__dstoffset
+
+class PicklableFixedOffset(FixedOffset):
+
+ def __init__(self, offset=None, name=None, dstoffset=None):
+ FixedOffset.__init__(self, offset, name, dstoffset)
+
+class TestTZInfo(unittest.TestCase):
+
+ def test_non_abstractness(self):
+ # In order to allow subclasses to get pickled, the C implementation
+ # wasn't able to get away with having __init__ raise
+ # NotImplementedError.
+ useless = tzinfo()
+ dt = datetime.max
+ self.assertRaises(NotImplementedError, useless.tzname, dt)
+ self.assertRaises(NotImplementedError, useless.utcoffset, dt)
+ self.assertRaises(NotImplementedError, useless.dst, dt)
+
+ def test_subclass_must_override(self):
+ class NotEnough(tzinfo):
+ def __init__(self, offset, name):
+ self.__offset = offset
+ self.__name = name
+ self.assertTrue(issubclass(NotEnough, tzinfo))
+ ne = NotEnough(3, "NotByALongShot")
+ self.assertIsInstance(ne, tzinfo)
+
+ dt = datetime.now()
+ self.assertRaises(NotImplementedError, ne.tzname, dt)
+ self.assertRaises(NotImplementedError, ne.utcoffset, dt)
+ self.assertRaises(NotImplementedError, ne.dst, dt)
+
+ def test_normal(self):
+ fo = FixedOffset(3, "Three")
+ self.assertIsInstance(fo, tzinfo)
+ for dt in datetime.now(), None:
+ self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
+ self.assertEqual(fo.tzname(dt), "Three")
+ self.assertEqual(fo.dst(dt), timedelta(minutes=42))
+
+ def test_pickling_base(self):
+ # There's no point to pickling tzinfo objects on their own (they
+ # carry no data), but they need to be picklable anyway else
+ # concrete subclasses can't be pickled.
+ orig = tzinfo.__new__(tzinfo)
+ self.assertTrue(type(orig) is tzinfo)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertTrue(type(derived) is tzinfo)
+
+ def test_pickling_subclass(self):
+ # Make sure we can pickle/unpickle an instance of a subclass.
+ offset = timedelta(minutes=-300)
+ for otype, args in [
+ (PicklableFixedOffset, (offset, 'cookie')),
+ (timezone, (offset,)),
+ (timezone, (offset, "EST"))]:
+ orig = otype(*args)
+ oname = orig.tzname(None)
+ self.assertIsInstance(orig, tzinfo)
+ self.assertIs(type(orig), otype)
+ self.assertEqual(orig.utcoffset(None), offset)
+ self.assertEqual(orig.tzname(None), oname)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertIsInstance(derived, tzinfo)
+ self.assertIs(type(derived), otype)
+ self.assertEqual(derived.utcoffset(None), offset)
+ self.assertEqual(derived.tzname(None), oname)
+
+class TestTimeZone(unittest.TestCase):
+
+ def setUp(self):
+ self.ACDT = timezone(timedelta(hours=9.5), 'ACDT')
+ self.EST = timezone(-timedelta(hours=5), 'EST')
+ self.DT = datetime(2010, 1, 1)
+
+ def test_str(self):
+ for tz in [self.ACDT, self.EST, timezone.utc,
+ timezone.min, timezone.max]:
+ self.assertEqual(str(tz), tz.tzname(None))
+
+ def test_repr(self):
+ datetime = datetime_module
+ for tz in [self.ACDT, self.EST, timezone.utc,
+ timezone.min, timezone.max]:
+ # test round-trip
+ tzrep = repr(tz)
+ self.assertEqual(tz, eval(tzrep))
+
+
+ def test_class_members(self):
+ limit = timedelta(hours=23, minutes=59)
+ self.assertEqual(timezone.utc.utcoffset(None), ZERO)
+ self.assertEqual(timezone.min.utcoffset(None), -limit)
+ self.assertEqual(timezone.max.utcoffset(None), limit)
+
+
+ def test_constructor(self):
+ self.assertIs(timezone.utc, timezone(timedelta(0)))
+ self.assertIsNot(timezone.utc, timezone(timedelta(0), 'UTC'))
+ self.assertEqual(timezone.utc, timezone(timedelta(0), 'UTC'))
+ # invalid offsets
+ for invalid in [timedelta(microseconds=1), timedelta(1, 1),
+ timedelta(seconds=1), timedelta(1), -timedelta(1)]:
+ self.assertRaises(ValueError, timezone, invalid)
+ self.assertRaises(ValueError, timezone, -invalid)
+
+ with self.assertRaises(TypeError): timezone(None)
+ with self.assertRaises(TypeError): timezone(42)
+ with self.assertRaises(TypeError): timezone(ZERO, None)
+ with self.assertRaises(TypeError): timezone(ZERO, 42)
+ with self.assertRaises(TypeError): timezone(ZERO, 'ABC', 'extra')
+
+ def test_inheritance(self):
+ self.assertIsInstance(timezone.utc, tzinfo)
+ self.assertIsInstance(self.EST, tzinfo)
+
+ def test_utcoffset(self):
+ dummy = self.DT
+ for h in [0, 1.5, 12]:
+ offset = h * HOUR
+ self.assertEqual(offset, timezone(offset).utcoffset(dummy))
+ self.assertEqual(-offset, timezone(-offset).utcoffset(dummy))
+
+ with self.assertRaises(TypeError): self.EST.utcoffset('')
+ with self.assertRaises(TypeError): self.EST.utcoffset(5)
+
+
+ def test_dst(self):
+ self.assertIsNone(timezone.utc.dst(self.DT))
+
+ with self.assertRaises(TypeError): self.EST.dst('')
+ with self.assertRaises(TypeError): self.EST.dst(5)
+
+ def test_tzname(self):
+ self.assertEqual('UTC+00:00', timezone(ZERO).tzname(None))
+ self.assertEqual('UTC-05:00', timezone(-5 * HOUR).tzname(None))
+ self.assertEqual('UTC+09:30', timezone(9.5 * HOUR).tzname(None))
+ self.assertEqual('UTC-00:01', timezone(timedelta(minutes=-1)).tzname(None))
+ self.assertEqual('XYZ', timezone(-5 * HOUR, 'XYZ').tzname(None))
+
+ with self.assertRaises(TypeError): self.EST.tzname('')
+ with self.assertRaises(TypeError): self.EST.tzname(5)
+
+ def test_fromutc(self):
+ with self.assertRaises(ValueError):
+ timezone.utc.fromutc(self.DT)
+ with self.assertRaises(TypeError):
+ timezone.utc.fromutc('not datetime')
+ for tz in [self.EST, self.ACDT, Eastern]:
+ utctime = self.DT.replace(tzinfo=tz)
+ local = tz.fromutc(utctime)
+ self.assertEqual(local - utctime, tz.utcoffset(local))
+ self.assertEqual(local,
+ self.DT.replace(tzinfo=timezone.utc))
+
+ def test_comparison(self):
+ self.assertNotEqual(timezone(ZERO), timezone(HOUR))
+ self.assertEqual(timezone(HOUR), timezone(HOUR))
+ self.assertEqual(timezone(-5 * HOUR), timezone(-5 * HOUR, 'EST'))
+ with self.assertRaises(TypeError): timezone(ZERO) < timezone(ZERO)
+ self.assertIn(timezone(ZERO), {timezone(ZERO)})
+ self.assertTrue(timezone(ZERO) != None)
+ self.assertFalse(timezone(ZERO) == None)
+
+ def test_aware_datetime(self):
+ # test that timezone instances can be used by datetime
+ t = datetime(1, 1, 1)
+ for tz in [timezone.min, timezone.max, timezone.utc]:
+ self.assertEqual(tz.tzname(t),
+ t.replace(tzinfo=tz).tzname())
+ self.assertEqual(tz.utcoffset(t),
+ t.replace(tzinfo=tz).utcoffset())
+ self.assertEqual(tz.dst(t),
+ t.replace(tzinfo=tz).dst())
+
+#############################################################################
+# Base clase for testing a particular aspect of timedelta, time, date and
+# datetime comparisons.
+
+class HarmlessMixedComparison:
+ # Test that __eq__ and __ne__ don't complain for mixed-type comparisons.
+
+ # Subclasses must define 'theclass', and theclass(1, 1, 1) must be a
+ # legit constructor.
+
+ def test_harmless_mixed_comparison(self):
+ me = self.theclass(1, 1, 1)
+
+ self.assertFalse(me == ())
+ self.assertTrue(me != ())
+ self.assertFalse(() == me)
+ self.assertTrue(() != me)
+
+ self.assertIn(me, [1, 20, [], me])
+ self.assertIn([], [me, 1, 20, []])
+
+ def test_harmful_mixed_comparison(self):
+ me = self.theclass(1, 1, 1)
+
+ self.assertRaises(TypeError, lambda: me < ())
+ self.assertRaises(TypeError, lambda: me <= ())
+ self.assertRaises(TypeError, lambda: me > ())
+ self.assertRaises(TypeError, lambda: me >= ())
+
+ self.assertRaises(TypeError, lambda: () < me)
+ self.assertRaises(TypeError, lambda: () <= me)
+ self.assertRaises(TypeError, lambda: () > me)
+ self.assertRaises(TypeError, lambda: () >= me)
+
+#############################################################################
+# timedelta tests
+
+class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
+
+ theclass = timedelta
+
+ def test_constructor(self):
+ eq = self.assertEqual
+ td = timedelta
+
+ # Check keyword args to constructor
+ eq(td(), td(weeks=0, days=0, hours=0, minutes=0, seconds=0,
+ milliseconds=0, microseconds=0))
+ eq(td(1), td(days=1))
+ eq(td(0, 1), td(seconds=1))
+ eq(td(0, 0, 1), td(microseconds=1))
+ eq(td(weeks=1), td(days=7))
+ eq(td(days=1), td(hours=24))
+ eq(td(hours=1), td(minutes=60))
+ eq(td(minutes=1), td(seconds=60))
+ eq(td(seconds=1), td(milliseconds=1000))
+ eq(td(milliseconds=1), td(microseconds=1000))
+
+ # Check float args to constructor
+ eq(td(weeks=1.0/7), td(days=1))
+ eq(td(days=1.0/24), td(hours=1))
+ eq(td(hours=1.0/60), td(minutes=1))
+ eq(td(minutes=1.0/60), td(seconds=1))
+ eq(td(seconds=0.001), td(milliseconds=1))
+ eq(td(milliseconds=0.001), td(microseconds=1))
+
+ def test_computations(self):
+ eq = self.assertEqual
+ td = timedelta
+
+ a = td(7) # One week
+ b = td(0, 60) # One minute
+ c = td(0, 0, 1000) # One millisecond
+ eq(a+b+c, td(7, 60, 1000))
+ eq(a-b, td(6, 24*3600 - 60))
+ eq(b.__rsub__(a), td(6, 24*3600 - 60))
+ eq(-a, td(-7))
+ eq(+a, td(7))
+ eq(-b, td(-1, 24*3600 - 60))
+ eq(-c, td(-1, 24*3600 - 1, 999000))
+ eq(abs(a), a)
+ eq(abs(-a), a)
+ eq(td(6, 24*3600), a)
+ eq(td(0, 0, 60*1000000), b)
+ eq(a*10, td(70))
+ eq(a*10, 10*a)
+ eq(a*10, 10*a)
+ eq(b*10, td(0, 600))
+ eq(10*b, td(0, 600))
+ eq(b*10, td(0, 600))
+ eq(c*10, td(0, 0, 10000))
+ eq(10*c, td(0, 0, 10000))
+ eq(c*10, td(0, 0, 10000))
+ eq(a*-1, -a)
+ eq(b*-2, -b-b)
+ eq(c*-2, -c+-c)
+ eq(b*(60*24), (b*60)*24)
+ eq(b*(60*24), (60*b)*24)
+ eq(c*1000, td(0, 1))
+ eq(1000*c, td(0, 1))
+ eq(a//7, td(1))
+ eq(b//10, td(0, 6))
+ eq(c//1000, td(0, 0, 1))
+ eq(a//10, td(0, 7*24*360))
+ eq(a//3600000, td(0, 0, 7*24*1000))
+ eq(a/0.5, td(14))
+ eq(b/0.5, td(0, 120))
+ eq(a/7, td(1))
+ eq(b/10, td(0, 6))
+ eq(c/1000, td(0, 0, 1))
+ eq(a/10, td(0, 7*24*360))
+ eq(a/3600000, td(0, 0, 7*24*1000))
+
+ # Multiplication by float
+ us = td(microseconds=1)
+ eq((3*us) * 0.5, 2*us)
+ eq((5*us) * 0.5, 2*us)
+ eq(0.5 * (3*us), 2*us)
+ eq(0.5 * (5*us), 2*us)
+ eq((-3*us) * 0.5, -2*us)
+ eq((-5*us) * 0.5, -2*us)
+
+ # Division by int and float
+ eq((3*us) / 2, 2*us)
+ eq((5*us) / 2, 2*us)
+ eq((-3*us) / 2.0, -2*us)
+ eq((-5*us) / 2.0, -2*us)
+ eq((3*us) / -2, -2*us)
+ eq((5*us) / -2, -2*us)
+ eq((3*us) / -2.0, -2*us)
+ eq((5*us) / -2.0, -2*us)
+ for i in range(-10, 10):
+ eq((i*us/3)//us, round(i/3))
+ for i in range(-10, 10):
+ eq((i*us/-3)//us, round(i/-3))
+
+ # Issue #11576
+ eq(td(999999999, 86399, 999999) - td(999999999, 86399, 999998),
+ td(0, 0, 1))
+ eq(td(999999999, 1, 1) - td(999999999, 1, 0),
+ td(0, 0, 1))
+
+ def test_disallowed_computations(self):
+ a = timedelta(42)
+
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # Division of int by timedelta doesn't make sense.
+ # Division by zero doesn't make sense.
+ zero = 0
+ self.assertRaises(TypeError, lambda: zero // a)
+ self.assertRaises(ZeroDivisionError, lambda: a // zero)
+ self.assertRaises(ZeroDivisionError, lambda: a / zero)
+ self.assertRaises(ZeroDivisionError, lambda: a / 0.0)
+ self.assertRaises(TypeError, lambda: a / '')
+
+ @support.requires_IEEE_754
+ def test_disallowed_special(self):
+ a = timedelta(42)
+ self.assertRaises(ValueError, a.__mul__, NAN)
+ self.assertRaises(ValueError, a.__truediv__, NAN)
+
+ def test_basic_attributes(self):
+ days, seconds, us = 1, 7, 31
+ td = timedelta(days, seconds, us)
+ self.assertEqual(td.days, days)
+ self.assertEqual(td.seconds, seconds)
+ self.assertEqual(td.microseconds, us)
+
+ def test_total_seconds(self):
+ td = timedelta(days=365)
+ self.assertEqual(td.total_seconds(), 31536000.0)
+ for total_seconds in [123456.789012, -123456.789012, 0.123456, 0, 1e6]:
+ td = timedelta(seconds=total_seconds)
+ self.assertEqual(td.total_seconds(), total_seconds)
+ # Issue8644: Test that td.total_seconds() has the same
+ # accuracy as td / timedelta(seconds=1).
+ for ms in [-1, -2, -123]:
+ td = timedelta(microseconds=ms)
+ self.assertEqual(td.total_seconds(), td / timedelta(seconds=1))
+
+ def test_carries(self):
+ t1 = timedelta(days=100,
+ weeks=-7,
+ hours=-24*(100-49),
+ minutes=-3,
+ seconds=12,
+ microseconds=(3*60 - 12) * 1e6 + 1)
+ t2 = timedelta(microseconds=1)
+ self.assertEqual(t1, t2)
+
+ def test_hash_equality(self):
+ t1 = timedelta(days=100,
+ weeks=-7,
+ hours=-24*(100-49),
+ minutes=-3,
+ seconds=12,
+ microseconds=(3*60 - 12) * 1000000)
+ t2 = timedelta()
+ self.assertEqual(hash(t1), hash(t2))
+
+ t1 += timedelta(weeks=7)
+ t2 += timedelta(days=7*7)
+ self.assertEqual(t1, t2)
+ self.assertEqual(hash(t1), hash(t2))
+
+ d = {t1: 1}
+ d[t2] = 2
+ self.assertEqual(len(d), 1)
+ self.assertEqual(d[t1], 2)
+
+ def test_pickling(self):
+ args = 12, 34, 56
+ orig = timedelta(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_compare(self):
+ t1 = timedelta(2, 3, 4)
+ t2 = timedelta(2, 3, 4)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
+ t2 = timedelta(*args) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 <= badarg)
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_str(self):
+ td = timedelta
+ eq = self.assertEqual
+
+ eq(str(td(1)), "1 day, 0:00:00")
+ eq(str(td(-1)), "-1 day, 0:00:00")
+ eq(str(td(2)), "2 days, 0:00:00")
+ eq(str(td(-2)), "-2 days, 0:00:00")
+
+ eq(str(td(hours=12, minutes=58, seconds=59)), "12:58:59")
+ eq(str(td(hours=2, minutes=3, seconds=4)), "2:03:04")
+ eq(str(td(weeks=-30, hours=23, minutes=12, seconds=34)),
+ "-210 days, 23:12:34")
+
+ eq(str(td(milliseconds=1)), "0:00:00.001000")
+ eq(str(td(microseconds=3)), "0:00:00.000003")
+
+ eq(str(td(days=999999999, hours=23, minutes=59, seconds=59,
+ microseconds=999999)),
+ "999999999 days, 23:59:59.999999")
+
+ def test_repr(self):
+ name = 'datetime.' + self.theclass.__name__
+ self.assertEqual(repr(self.theclass(1)),
+ "%s(1)" % name)
+ self.assertEqual(repr(self.theclass(10, 2)),
+ "%s(10, 2)" % name)
+ self.assertEqual(repr(self.theclass(-10, 2, 400000)),
+ "%s(-10, 2, 400000)" % name)
+
+ def test_roundtrip(self):
+ for td in (timedelta(days=999999999, hours=23, minutes=59,
+ seconds=59, microseconds=999999),
+ timedelta(days=-999999999),
+ timedelta(days=-999999999, seconds=1),
+ timedelta(days=1, seconds=2, microseconds=3)):
+
+ # Verify td -> string -> td identity.
+ s = repr(td)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ td2 = eval(s)
+ self.assertEqual(td, td2)
+
+ # Verify identity via reconstructing from pieces.
+ td2 = timedelta(td.days, td.seconds, td.microseconds)
+ self.assertEqual(td, td2)
+
+ def test_resolution_info(self):
+ self.assertIsInstance(timedelta.min, timedelta)
+ self.assertIsInstance(timedelta.max, timedelta)
+ self.assertIsInstance(timedelta.resolution, timedelta)
+ self.assertTrue(timedelta.max > timedelta.min)
+ self.assertEqual(timedelta.min, timedelta(-999999999))
+ self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
+ self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
+
+ def test_overflow(self):
+ tiny = timedelta.resolution
+
+ td = timedelta.min + tiny
+ td -= tiny # no problem
+ self.assertRaises(OverflowError, td.__sub__, tiny)
+ self.assertRaises(OverflowError, td.__add__, -tiny)
+
+ td = timedelta.max - tiny
+ td += tiny # no problem
+ self.assertRaises(OverflowError, td.__add__, tiny)
+ self.assertRaises(OverflowError, td.__sub__, -tiny)
+
+ self.assertRaises(OverflowError, lambda: -timedelta.max)
+
+ day = timedelta(1)
+ self.assertRaises(OverflowError, day.__mul__, 10**9)
+ self.assertRaises(OverflowError, day.__mul__, 1e9)
+ self.assertRaises(OverflowError, day.__truediv__, 1e-20)
+ self.assertRaises(OverflowError, day.__truediv__, 1e-10)
+ self.assertRaises(OverflowError, day.__truediv__, 9e-10)
+
+ @support.requires_IEEE_754
+ def _test_overflow_special(self):
+ day = timedelta(1)
+ self.assertRaises(OverflowError, day.__mul__, INF)
+ self.assertRaises(OverflowError, day.__mul__, -INF)
+
+ def test_microsecond_rounding(self):
+ td = timedelta
+ eq = self.assertEqual
+
+ # Single-field rounding.
+ eq(td(milliseconds=0.4/1000), td(0)) # rounds to 0
+ eq(td(milliseconds=-0.4/1000), td(0)) # rounds to 0
+ eq(td(milliseconds=0.6/1000), td(microseconds=1))
+ eq(td(milliseconds=-0.6/1000), td(microseconds=-1))
+
+ # Rounding due to contributions from more than one field.
+ us_per_hour = 3600e6
+ us_per_day = us_per_hour * 24
+ eq(td(days=.4/us_per_day), td(0))
+ eq(td(hours=.2/us_per_hour), td(0))
+ eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
+
+ eq(td(days=-.4/us_per_day), td(0))
+ eq(td(hours=-.2/us_per_hour), td(0))
+ eq(td(days=-.4/us_per_day, hours=-.2/us_per_hour), td(microseconds=-1))
+
+ def test_massive_normalization(self):
+ td = timedelta(microseconds=-1)
+ self.assertEqual((td.days, td.seconds, td.microseconds),
+ (-1, 24*3600-1, 999999))
+
+ def test_bool(self):
+ self.assertTrue(timedelta(1))
+ self.assertTrue(timedelta(0, 1))
+ self.assertTrue(timedelta(0, 0, 1))
+ self.assertTrue(timedelta(microseconds=1))
+ self.assertTrue(not timedelta(0))
+
+ def test_subclass_timedelta(self):
+
+ class T(timedelta):
+ @staticmethod
+ def from_td(td):
+ return T(td.days, td.seconds, td.microseconds)
+
+ def as_hours(self):
+ sum = (self.days * 24 +
+ self.seconds / 3600.0 +
+ self.microseconds / 3600e6)
+ return round(sum)
+
+ t1 = T(days=1)
+ self.assertTrue(type(t1) is T)
+ self.assertEqual(t1.as_hours(), 24)
+
+ t2 = T(days=-1, seconds=-3600)
+ self.assertTrue(type(t2) is T)
+ self.assertEqual(t2.as_hours(), -25)
+
+ t3 = t1 + t2
+ self.assertTrue(type(t3) is timedelta)
+ t4 = T.from_td(t3)
+ self.assertTrue(type(t4) is T)
+ self.assertEqual(t3.days, t4.days)
+ self.assertEqual(t3.seconds, t4.seconds)
+ self.assertEqual(t3.microseconds, t4.microseconds)
+ self.assertEqual(str(t3), str(t4))
+ self.assertEqual(t4.as_hours(), -1)
+
+ def test_division(self):
+ t = timedelta(hours=1, minutes=24, seconds=19)
+ second = timedelta(seconds=1)
+ self.assertEqual(t / second, 5059.0)
+ self.assertEqual(t // second, 5059)
+
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ self.assertEqual(t / minute, 2.5)
+ self.assertEqual(t // minute, 2)
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, truediv, t, zerotd)
+ self.assertRaises(ZeroDivisionError, floordiv, t, zerotd)
+
+ # self.assertRaises(TypeError, truediv, t, 2)
+ # note: floor division of a timedelta by an integer *is*
+ # currently permitted.
+
+ def test_remainder(self):
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ r = t % minute
+ self.assertEqual(r, timedelta(seconds=30))
+
+ t = timedelta(minutes=-2, seconds=30)
+ r = t % minute
+ self.assertEqual(r, timedelta(seconds=30))
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, mod, t, zerotd)
+
+ self.assertRaises(TypeError, mod, t, 10)
+
+ def test_divmod(self):
+ t = timedelta(minutes=2, seconds=30)
+ minute = timedelta(minutes=1)
+ q, r = divmod(t, minute)
+ self.assertEqual(q, 2)
+ self.assertEqual(r, timedelta(seconds=30))
+
+ t = timedelta(minutes=-2, seconds=30)
+ q, r = divmod(t, minute)
+ self.assertEqual(q, -2)
+ self.assertEqual(r, timedelta(seconds=30))
+
+ zerotd = timedelta(0)
+ self.assertRaises(ZeroDivisionError, divmod, t, zerotd)
+
+ self.assertRaises(TypeError, divmod, t, 10)
+
+
+#############################################################################
+# date tests
+
+class TestDateOnly(unittest.TestCase):
+ # Tests here won't pass if also run on datetime objects, so don't
+ # subclass this to test datetimes too.
+
+ def test_delta_non_days_ignored(self):
+ dt = date(2000, 1, 2)
+ delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
+ microseconds=5)
+ days = timedelta(delta.days)
+ self.assertEqual(days, timedelta(1))
+
+ dt2 = dt + delta
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = delta + dt
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = dt - delta
+ self.assertEqual(dt2, dt - days)
+
+ delta = -delta
+ days = timedelta(delta.days)
+ self.assertEqual(days, timedelta(-2))
+
+ dt2 = dt + delta
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = delta + dt
+ self.assertEqual(dt2, dt + days)
+
+ dt2 = dt - delta
+ self.assertEqual(dt2, dt - days)
+
+class SubclassDate(date):
+ sub_var = 1
+
+class TestDate(HarmlessMixedComparison, unittest.TestCase):
+ # Tests here should pass for both dates and datetimes, except for a
+ # few tests that TestDateTime overrides.
+
+ theclass = date
+
+ def test_basic_attributes(self):
+ dt = self.theclass(2002, 3, 1)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+
+ def test_roundtrip(self):
+ for dt in (self.theclass(1, 2, 3),
+ self.theclass.today()):
+ # Verify dt -> string -> date identity.
+ s = repr(dt)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ dt2 = eval(s)
+ self.assertEqual(dt, dt2)
+
+ # Verify identity via reconstructing from pieces.
+ dt2 = self.theclass(dt.year, dt.month, dt.day)
+ self.assertEqual(dt, dt2)
+
+ def test_ordinal_conversions(self):
+ # Check some fixed values.
+ for y, m, d, n in [(1, 1, 1, 1), # calendar origin
+ (1, 12, 31, 365),
+ (2, 1, 1, 366),
+ # first example from "Calendrical Calculations"
+ (1945, 11, 12, 710347)]:
+ d = self.theclass(y, m, d)
+ self.assertEqual(n, d.toordinal())
+ fromord = self.theclass.fromordinal(n)
+ self.assertEqual(d, fromord)
+ if hasattr(fromord, "hour"):
+ # if we're checking something fancier than a date, verify
+ # the extra fields have been zeroed out
+ self.assertEqual(fromord.hour, 0)
+ self.assertEqual(fromord.minute, 0)
+ self.assertEqual(fromord.second, 0)
+ self.assertEqual(fromord.microsecond, 0)
+
+ # Check first and last days of year spottily across the whole
+ # range of years supported.
+ for year in range(MINYEAR, MAXYEAR+1, 7):
+ # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
+ d = self.theclass(year, 1, 1)
+ n = d.toordinal()
+ d2 = self.theclass.fromordinal(n)
+ self.assertEqual(d, d2)
+ # Verify that moving back a day gets to the end of year-1.
+ if year > 1:
+ d = self.theclass.fromordinal(n-1)
+ d2 = self.theclass(year-1, 12, 31)
+ self.assertEqual(d, d2)
+ self.assertEqual(d2.toordinal(), n-1)
+
+ # Test every day in a leap-year and a non-leap year.
+ dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
+ for year, isleap in (2000, True), (2002, False):
+ n = self.theclass(year, 1, 1).toordinal()
+ for month, maxday in zip(range(1, 13), dim):
+ if month == 2 and isleap:
+ maxday += 1
+ for day in range(1, maxday+1):
+ d = self.theclass(year, month, day)
+ self.assertEqual(d.toordinal(), n)
+ self.assertEqual(d, self.theclass.fromordinal(n))
+ n += 1
+
+ def test_extreme_ordinals(self):
+ a = self.theclass.min
+ a = self.theclass(a.year, a.month, a.day) # get rid of time parts
+ aord = a.toordinal()
+ b = a.fromordinal(aord)
+ self.assertEqual(a, b)
+
+ self.assertRaises(ValueError, lambda: a.fromordinal(aord - 1))
+
+ b = a + timedelta(days=1)
+ self.assertEqual(b.toordinal(), aord + 1)
+ self.assertEqual(b, self.theclass.fromordinal(aord + 1))
+
+ a = self.theclass.max
+ a = self.theclass(a.year, a.month, a.day) # get rid of time parts
+ aord = a.toordinal()
+ b = a.fromordinal(aord)
+ self.assertEqual(a, b)
+
+ self.assertRaises(ValueError, lambda: a.fromordinal(aord + 1))
+
+ b = a - timedelta(days=1)
+ self.assertEqual(b.toordinal(), aord - 1)
+ self.assertEqual(b, self.theclass.fromordinal(aord - 1))
+
+ def test_bad_constructor_arguments(self):
+ # bad years
+ self.theclass(MINYEAR, 1, 1) # no exception
+ self.theclass(MAXYEAR, 1, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
+ self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
+ # bad months
+ self.theclass(2000, 1, 1) # no exception
+ self.theclass(2000, 12, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
+ self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
+ # bad days
+ self.theclass(2000, 2, 29) # no exception
+ self.theclass(2004, 2, 29) # no exception
+ self.theclass(2400, 2, 29) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
+ self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
+
+ def test_hash_equality(self):
+ d = self.theclass(2000, 12, 31)
+ # same thing
+ e = self.theclass(2000, 12, 31)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(2001, 1, 1)
+ # same thing
+ e = self.theclass(2001, 1, 1)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_computations(self):
+ a = self.theclass(2002, 1, 31)
+ b = self.theclass(1956, 1, 31)
+ c = self.theclass(2001,2,1)
+
+ diff = a-b
+ self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
+ self.assertEqual(diff.seconds, 0)
+ self.assertEqual(diff.microseconds, 0)
+
+ day = timedelta(1)
+ week = timedelta(7)
+ a = self.theclass(2002, 3, 2)
+ self.assertEqual(a + day, self.theclass(2002, 3, 3))
+ self.assertEqual(day + a, self.theclass(2002, 3, 3))
+ self.assertEqual(a - day, self.theclass(2002, 3, 1))
+ self.assertEqual(-day + a, self.theclass(2002, 3, 1))
+ self.assertEqual(a + week, self.theclass(2002, 3, 9))
+ self.assertEqual(a - week, self.theclass(2002, 2, 23))
+ self.assertEqual(a + 52*week, self.theclass(2003, 3, 1))
+ self.assertEqual(a - 52*week, self.theclass(2001, 3, 3))
+ self.assertEqual((a + week) - a, week)
+ self.assertEqual((a + day) - a, day)
+ self.assertEqual((a - week) - a, -week)
+ self.assertEqual((a - day) - a, -day)
+ self.assertEqual(a - (a + week), -week)
+ self.assertEqual(a - (a + day), -day)
+ self.assertEqual(a - (a - week), week)
+ self.assertEqual(a - (a - day), day)
+ self.assertEqual(c - (c - day), day)
+
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # delta - date is senseless.
+ self.assertRaises(TypeError, lambda: day - a)
+ # mixing date and (delta or date) via * or // is senseless
+ self.assertRaises(TypeError, lambda: day * a)
+ self.assertRaises(TypeError, lambda: a * day)
+ self.assertRaises(TypeError, lambda: day // a)
+ self.assertRaises(TypeError, lambda: a // day)
+ self.assertRaises(TypeError, lambda: a * a)
+ self.assertRaises(TypeError, lambda: a // a)
+ # date + date is senseless
+ self.assertRaises(TypeError, lambda: a + a)
+
+ def test_overflow(self):
+ tiny = self.theclass.resolution
+
+ for delta in [tiny, timedelta(1), timedelta(2)]:
+ dt = self.theclass.min + delta
+ dt -= delta # no problem
+ self.assertRaises(OverflowError, dt.__sub__, delta)
+ self.assertRaises(OverflowError, dt.__add__, -delta)
+
+ dt = self.theclass.max - delta
+ dt += delta # no problem
+ self.assertRaises(OverflowError, dt.__add__, delta)
+ self.assertRaises(OverflowError, dt.__sub__, -delta)
+
+ def test_fromtimestamp(self):
+ import time
+
+ # Try an arbitrary fixed value.
+ year, month, day = 1999, 9, 19
+ ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
+ d = self.theclass.fromtimestamp(ts)
+ self.assertEqual(d.year, year)
+ self.assertEqual(d.month, month)
+ self.assertEqual(d.day, day)
+
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
+ def test_today(self):
+ import time
+
+ # We claim that today() is like fromtimestamp(time.time()), so
+ # prove it.
+ for dummy in range(3):
+ today = self.theclass.today()
+ ts = time.time()
+ todayagain = self.theclass.fromtimestamp(ts)
+ if today == todayagain:
+ break
+ # There are several legit reasons that could fail:
+ # 1. It recently became midnight, between the today() and the
+ # time() calls.
+ # 2. The platform time() has such fine resolution that we'll
+ # never get the same value twice.
+ # 3. The platform time() has poor resolution, and we just
+ # happened to call today() right before a resolution quantum
+ # boundary.
+ # 4. The system clock got fiddled between calls.
+ # In any case, wait a little while and try again.
+ time.sleep(0.1)
+
+ # It worked or it didn't. If it didn't, assume it's reason #2, and
+ # let the test pass if they're within half a second of each other.
+ self.assertTrue(today == todayagain or
+ abs(todayagain - today) < timedelta(seconds=0.5))
+
+ def test_weekday(self):
+ for i in range(7):
+ # March 4, 2002 is a Monday
+ self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i)
+ self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1)
+ # January 2, 1956 is a Monday
+ self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i)
+ self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1)
+
+ def test_isocalendar(self):
+ # Check examples from
+ # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ for i in range(7):
+ d = self.theclass(2003, 12, 22+i)
+ self.assertEqual(d.isocalendar(), (2003, 52, i+1))
+ d = self.theclass(2003, 12, 29) + timedelta(i)
+ self.assertEqual(d.isocalendar(), (2004, 1, i+1))
+ d = self.theclass(2004, 1, 5+i)
+ self.assertEqual(d.isocalendar(), (2004, 2, i+1))
+ d = self.theclass(2009, 12, 21+i)
+ self.assertEqual(d.isocalendar(), (2009, 52, i+1))
+ d = self.theclass(2009, 12, 28) + timedelta(i)
+ self.assertEqual(d.isocalendar(), (2009, 53, i+1))
+ d = self.theclass(2010, 1, 4+i)
+ self.assertEqual(d.isocalendar(), (2010, 1, i+1))
+
+ def test_iso_long_years(self):
+ # Calculate long ISO years and compare to table from
+ # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
+ ISO_LONG_YEARS_TABLE = """
+ 4 32 60 88
+ 9 37 65 93
+ 15 43 71 99
+ 20 48 76
+ 26 54 82
+
+ 105 133 161 189
+ 111 139 167 195
+ 116 144 172
+ 122 150 178
+ 128 156 184
+
+ 201 229 257 285
+ 207 235 263 291
+ 212 240 268 296
+ 218 246 274
+ 224 252 280
+
+ 303 331 359 387
+ 308 336 364 392
+ 314 342 370 398
+ 320 348 376
+ 325 353 381
+ """
+ iso_long_years = sorted(map(int, ISO_LONG_YEARS_TABLE.split()))
+ L = []
+ for i in range(400):
+ d = self.theclass(2000+i, 12, 31)
+ d1 = self.theclass(1600+i, 12, 31)
+ self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:])
+ if d.isocalendar()[1] == 53:
+ L.append(i)
+ self.assertEqual(L, iso_long_years)
+
+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2)
+ self.assertEqual(t.isoformat(), "0002-03-02")
+
+ def test_ctime(self):
+ t = self.theclass(2002, 3, 2)
+ self.assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002")
+
+ def test_strftime(self):
+ t = self.theclass(2005, 3, 2)
+ self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05")
+ self.assertEqual(t.strftime(""), "") # SF bug #761337
+ self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784
+
+ self.assertRaises(TypeError, t.strftime) # needs an arg
+ self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
+ self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
+
+ # test that unicode input is allowed (issue 2782)
+ self.assertEqual(t.strftime("%m"), "03")
+
+ # A naive object replaces %z and %Z w/ empty strings.
+ self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
+
+ #make sure that invalid format specifiers are handled correctly
+ #self.assertRaises(ValueError, t.strftime, "%e")
+ #self.assertRaises(ValueError, t.strftime, "%")
+ #self.assertRaises(ValueError, t.strftime, "%#")
+
+ #oh well, some systems just ignore those invalid ones.
+ #at least, excercise them to make sure that no crashes
+ #are generated
+ for f in ["%e", "%", "%#"]:
+ try:
+ t.strftime(f)
+ except ValueError:
+ pass
+
+ #check that this standard extension works
+ t.strftime("%f")
+
+
+ def test_format(self):
+ dt = self.theclass(2007, 9, 10)
+ self.assertEqual(dt.__format__(''), str(dt))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(2007, 9, 10)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(2007, 9, 10)
+ self.assertEqual(b.__format__(''), str(dt))
+
+ for fmt in ["m:%m d:%d y:%y",
+ "m:%m d:%d y:%y H:%H M:%M S:%S",
+ "%z %Z",
+ ]:
+ self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_resolution_info(self):
+ # XXX: Should min and max respect subclassing?
+ if issubclass(self.theclass, datetime):
+ expected_class = datetime
+ else:
+ expected_class = date
+ self.assertIsInstance(self.theclass.min, expected_class)
+ self.assertIsInstance(self.theclass.max, expected_class)
+ self.assertIsInstance(self.theclass.resolution, timedelta)
+ self.assertTrue(self.theclass.max > self.theclass.min)
+
+ def test_extreme_timedelta(self):
+ big = self.theclass.max - self.theclass.min
+ # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds
+ n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds
+ # n == 315537897599999999 ~= 2**58.13
+ justasbig = timedelta(0, 0, n)
+ self.assertEqual(big, justasbig)
+ self.assertEqual(self.theclass.min + big, self.theclass.max)
+ self.assertEqual(self.theclass.max - big, self.theclass.min)
+
+ def test_timetuple(self):
+ for i in range(7):
+ # January 2, 1956 is a Monday (0)
+ d = self.theclass(1956, 1, 2+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 1, 2+i, 0, 0, 0, i, 2+i, -1))
+ # February 1, 1956 is a Wednesday (2)
+ d = self.theclass(1956, 2, 1+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 2, 1+i, 0, 0, 0, (2+i)%7, 32+i, -1))
+ # March 1, 1956 is a Thursday (3), and is the 31+29+1 = 61st day
+ # of the year.
+ d = self.theclass(1956, 3, 1+i)
+ t = d.timetuple()
+ self.assertEqual(t, (1956, 3, 1+i, 0, 0, 0, (3+i)%7, 61+i, -1))
+ self.assertEqual(t.tm_year, 1956)
+ self.assertEqual(t.tm_mon, 3)
+ self.assertEqual(t.tm_mday, 1+i)
+ self.assertEqual(t.tm_hour, 0)
+ self.assertEqual(t.tm_min, 0)
+ self.assertEqual(t.tm_sec, 0)
+ self.assertEqual(t.tm_wday, (3+i)%7)
+ self.assertEqual(t.tm_yday, 61+i)
+ self.assertEqual(t.tm_isdst, -1)
+
+ def test_pickling(self):
+ args = 6, 7, 23
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_compare(self):
+ t1 = self.theclass(2, 3, 4)
+ t2 = self.theclass(2, 3, 4)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
+ t2 = self.theclass(*args) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_mixed_compare(self):
+ our = self.theclass(2000, 4, 5)
+
+ # Our class can be compared for equality to other classes
+ self.assertEqual(our == 1, False)
+ self.assertEqual(1 == our, False)
+ self.assertEqual(our != 1, True)
+ self.assertEqual(1 != our, True)
+
+ # But the ordering is undefined
+ self.assertRaises(TypeError, lambda: our < 1)
+ self.assertRaises(TypeError, lambda: 1 < our)
+
+ # Repeat those tests with a different class
+
+ class SomeClass:
+ pass
+
+ their = SomeClass()
+ self.assertEqual(our == their, False)
+ self.assertEqual(their == our, False)
+ self.assertEqual(our != their, True)
+ self.assertEqual(their != our, True)
+ self.assertRaises(TypeError, lambda: our < their)
+ self.assertRaises(TypeError, lambda: their < our)
+
+ # However, if the other class explicitly defines ordering
+ # relative to our class, it is allowed to do so
+
+ class LargerThanAnything:
+ def __lt__(self, other):
+ return False
+ def __le__(self, other):
+ return isinstance(other, LargerThanAnything)
+ def __eq__(self, other):
+ return isinstance(other, LargerThanAnything)
+ def __ne__(self, other):
+ return not isinstance(other, LargerThanAnything)
+ def __gt__(self, other):
+ return not isinstance(other, LargerThanAnything)
+ def __ge__(self, other):
+ return True
+
+ their = LargerThanAnything()
+ self.assertEqual(our == their, False)
+ self.assertEqual(their == our, False)
+ self.assertEqual(our != their, True)
+ self.assertEqual(their != our, True)
+ self.assertEqual(our < their, True)
+ self.assertEqual(their < our, False)
+
+ def test_bool(self):
+ # All dates are considered true.
+ self.assertTrue(self.theclass.min)
+ self.assertTrue(self.theclass.max)
+
+ def test_strftime_out_of_range(self):
+ # For nasty technical reasons, we can't handle years before 1000.
+ cls = self.theclass
+ self.assertEqual(cls(1000, 1, 1).strftime("%Y"), "1000")
+ for y in 1, 49, 51, 99, 100, 999:
+ self.assertRaises(ValueError, cls(y, 1, 1).strftime, "%Y")
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_subclass_date(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.year + self.month
+
+ args = 2003, 4, 14
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.toordinal(), dt2.toordinal())
+ self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month - 7)
+
+ def test_pickling_subclass_date(self):
+
+ args = 6, 7, 23
+ orig = SubclassDate(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_backdoor_resistance(self):
+ # For fast unpickling, the constructor accepts a pickle byte string.
+ # This is a low-overhead backdoor. A user can (by intent or
+ # mistake) pass a string directly, which (if it's the right length)
+ # will get treated like a pickle, and bypass the normal sanity
+ # checks in the constructor. This can create insane objects.
+ # The constructor doesn't want to burn the time to validate all
+ # fields, but does check the month field. This stops, e.g.,
+ # datetime.datetime('1995-03-25') from yielding an insane object.
+ base = b'1995-03-25'
+ if not issubclass(self.theclass, datetime):
+ base = base[:4]
+ for month_byte in b'9', b'\0', b'\r', b'\xff':
+ self.assertRaises(TypeError, self.theclass,
+ base[:2] + month_byte + base[3:])
+ # Good bytes, but bad tzinfo:
+ self.assertRaises(TypeError, self.theclass,
+ bytes([1] * len(base)), 'EST')
+
+ for ord_byte in range(1, 13):
+ # This shouldn't blow up because of the month byte alone. If
+ # the implementation changes to do more-careful checking, it may
+ # blow up because other fields are insane.
+ self.theclass(base[:2] + bytes([ord_byte]) + base[3:])
+
+#############################################################################
+# datetime tests
+
+class SubclassDatetime(datetime):
+ sub_var = 1
+
+class TestDateTime(TestDate):
+
+ theclass = datetime
+
+ def test_basic_attributes(self):
+ dt = self.theclass(2002, 3, 1, 12, 0)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+ self.assertEqual(dt.hour, 12)
+ self.assertEqual(dt.minute, 0)
+ self.assertEqual(dt.second, 0)
+ self.assertEqual(dt.microsecond, 0)
+
+ def test_basic_attributes_nonzero(self):
+ # Make sure all attributes are non-zero so bugs in
+ # bit-shifting access show up.
+ dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
+ self.assertEqual(dt.year, 2002)
+ self.assertEqual(dt.month, 3)
+ self.assertEqual(dt.day, 1)
+ self.assertEqual(dt.hour, 12)
+ self.assertEqual(dt.minute, 59)
+ self.assertEqual(dt.second, 59)
+ self.assertEqual(dt.microsecond, 8000)
+
+ def test_roundtrip(self):
+ for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
+ self.theclass.now()):
+ # Verify dt -> string -> datetime identity.
+ s = repr(dt)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ dt2 = eval(s)
+ self.assertEqual(dt, dt2)
+
+ # Verify identity via reconstructing from pieces.
+ dt2 = self.theclass(dt.year, dt.month, dt.day,
+ dt.hour, dt.minute, dt.second,
+ dt.microsecond)
+ self.assertEqual(dt, dt2)
+
+ def test_isoformat(self):
+ t = self.theclass(2, 3, 2, 4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
+ self.assertEqual(t.isoformat('\x00'), "0002-03-02\x0004:05:01.000123")
+ # str is ISO format with the separator forced to a blank.
+ self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
+
+ t = self.theclass(2, 3, 2)
+ self.assertEqual(t.isoformat(), "0002-03-02T00:00:00")
+ self.assertEqual(t.isoformat('T'), "0002-03-02T00:00:00")
+ self.assertEqual(t.isoformat(' '), "0002-03-02 00:00:00")
+ # str is ISO format with the separator forced to a blank.
+ self.assertEqual(str(t), "0002-03-02 00:00:00")
+
+ def test_format(self):
+ dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(dt.__format__(''), str(dt))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(2007, 9, 10, 4, 5, 1, 123)
+ self.assertEqual(b.__format__(''), str(dt))
+
+ for fmt in ["m:%m d:%d y:%y",
+ "m:%m d:%d y:%y H:%H M:%M S:%S",
+ "%z %Z",
+ ]:
+ self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_more_ctime(self):
+ # Test fields that TestDate doesn't touch.
+ import time
+
+ t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
+ self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002")
+ # Oops! The next line fails on Win2K under MSVC 6, so it's commented
+ # out. The difference is that t.ctime() produces " 2" for the day,
+ # but platform ctime() produces "02" for the day. According to
+ # C99, t.ctime() is correct here.
+ # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
+
+ # So test a case where that difference doesn't matter.
+ t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
+ self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
+
+ def test_tz_independent_comparing(self):
+ dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
+ dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
+ dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
+ self.assertEqual(dt1, dt3)
+ self.assertTrue(dt2 > dt3)
+
+ # Make sure comparison doesn't forget microseconds, and isn't done
+ # via comparing a float timestamp (an IEEE double doesn't have enough
+ # precision to span microsecond resolution across years 1 thru 9999,
+ # so comparing via timestamp necessarily calls some distinct values
+ # equal).
+ dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
+ us = timedelta(microseconds=1)
+ dt2 = dt1 + us
+ self.assertEqual(dt2 - dt1, us)
+ self.assertTrue(dt1 < dt2)
+
+ def test_strftime_with_bad_tzname_replace(self):
+ # verify ok if tzinfo.tzname().replace() returns a non-string
+ class MyTzInfo(FixedOffset):
+ def tzname(self, dt):
+ class MyStr(str):
+ def replace(self, *args):
+ return None
+ return MyStr('name')
+ t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
+ self.assertRaises(TypeError, t.strftime, '%Z')
+
+ def test_bad_constructor_arguments(self):
+ # bad years
+ self.theclass(MINYEAR, 1, 1) # no exception
+ self.theclass(MAXYEAR, 1, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
+ self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
+ # bad months
+ self.theclass(2000, 1, 1) # no exception
+ self.theclass(2000, 12, 1) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
+ self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
+ # bad days
+ self.theclass(2000, 2, 29) # no exception
+ self.theclass(2004, 2, 29) # no exception
+ self.theclass(2400, 2, 29) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
+ self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
+ # bad hours
+ self.theclass(2000, 1, 31, 0) # no exception
+ self.theclass(2000, 1, 31, 23) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 24)
+ # bad minutes
+ self.theclass(2000, 1, 31, 23, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 60)
+ # bad seconds
+ self.theclass(2000, 1, 31, 23, 59, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, 60)
+ # bad microseconds
+ self.theclass(2000, 1, 31, 23, 59, 59, 0) # no exception
+ self.theclass(2000, 1, 31, 23, 59, 59, 999999) # no exception
+ self.assertRaises(ValueError, self.theclass,
+ 2000, 1, 31, 23, 59, 59, -1)
+ self.assertRaises(ValueError, self.theclass,
+ 2000, 1, 31, 23, 59, 59,
+ 1000000)
+
+ def test_hash_equality(self):
+ d = self.theclass(2000, 12, 31, 23, 30, 17)
+ e = self.theclass(2000, 12, 31, 23, 30, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(2001, 1, 1, 0, 5, 17)
+ e = self.theclass(2001, 1, 1, 0, 5, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_computations(self):
+ a = self.theclass(2002, 1, 31)
+ b = self.theclass(1956, 1, 31)
+ diff = a-b
+ self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
+ self.assertEqual(diff.seconds, 0)
+ self.assertEqual(diff.microseconds, 0)
+ a = self.theclass(2002, 3, 2, 17, 6)
+ millisec = timedelta(0, 0, 1000)
+ hour = timedelta(0, 3600)
+ day = timedelta(1)
+ week = timedelta(7)
+ self.assertEqual(a + hour, self.theclass(2002, 3, 2, 18, 6))
+ self.assertEqual(hour + a, self.theclass(2002, 3, 2, 18, 6))
+ self.assertEqual(a + 10*hour, self.theclass(2002, 3, 3, 3, 6))
+ self.assertEqual(a - hour, self.theclass(2002, 3, 2, 16, 6))
+ self.assertEqual(-hour + a, self.theclass(2002, 3, 2, 16, 6))
+ self.assertEqual(a - hour, a + -hour)
+ self.assertEqual(a - 20*hour, self.theclass(2002, 3, 1, 21, 6))
+ self.assertEqual(a + day, self.theclass(2002, 3, 3, 17, 6))
+ self.assertEqual(a - day, self.theclass(2002, 3, 1, 17, 6))
+ self.assertEqual(a + week, self.theclass(2002, 3, 9, 17, 6))
+ self.assertEqual(a - week, self.theclass(2002, 2, 23, 17, 6))
+ self.assertEqual(a + 52*week, self.theclass(2003, 3, 1, 17, 6))
+ self.assertEqual(a - 52*week, self.theclass(2001, 3, 3, 17, 6))
+ self.assertEqual((a + week) - a, week)
+ self.assertEqual((a + day) - a, day)
+ self.assertEqual((a + hour) - a, hour)
+ self.assertEqual((a + millisec) - a, millisec)
+ self.assertEqual((a - week) - a, -week)
+ self.assertEqual((a - day) - a, -day)
+ self.assertEqual((a - hour) - a, -hour)
+ self.assertEqual((a - millisec) - a, -millisec)
+ self.assertEqual(a - (a + week), -week)
+ self.assertEqual(a - (a + day), -day)
+ self.assertEqual(a - (a + hour), -hour)
+ self.assertEqual(a - (a + millisec), -millisec)
+ self.assertEqual(a - (a - week), week)
+ self.assertEqual(a - (a - day), day)
+ self.assertEqual(a - (a - hour), hour)
+ self.assertEqual(a - (a - millisec), millisec)
+ self.assertEqual(a + (week + day + hour + millisec),
+ self.theclass(2002, 3, 10, 18, 6, 0, 1000))
+ self.assertEqual(a + (week + day + hour + millisec),
+ (((a + week) + day) + hour) + millisec)
+ self.assertEqual(a - (week + day + hour + millisec),
+ self.theclass(2002, 2, 22, 16, 5, 59, 999000))
+ self.assertEqual(a - (week + day + hour + millisec),
+ (((a - week) - day) - hour) - millisec)
+ # Add/sub ints or floats should be illegal
+ for i in 1, 1.0:
+ self.assertRaises(TypeError, lambda: a+i)
+ self.assertRaises(TypeError, lambda: a-i)
+ self.assertRaises(TypeError, lambda: i+a)
+ self.assertRaises(TypeError, lambda: i-a)
+
+ # delta - datetime is senseless.
+ self.assertRaises(TypeError, lambda: day - a)
+ # mixing datetime and (delta or datetime) via * or // is senseless
+ self.assertRaises(TypeError, lambda: day * a)
+ self.assertRaises(TypeError, lambda: a * day)
+ self.assertRaises(TypeError, lambda: day // a)
+ self.assertRaises(TypeError, lambda: a // day)
+ self.assertRaises(TypeError, lambda: a * a)
+ self.assertRaises(TypeError, lambda: a // a)
+ # datetime + datetime is senseless
+ self.assertRaises(TypeError, lambda: a + a)
+
+ def test_pickling(self):
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_more_pickling(self):
+ a = self.theclass(2003, 2, 7, 16, 48, 37, 444116)
+ s = pickle.dumps(a)
+ b = pickle.loads(s)
+ self.assertEqual(b.year, 2003)
+ self.assertEqual(b.month, 2)
+ self.assertEqual(b.day, 7)
+
+ def test_pickling_subclass_datetime(self):
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = SubclassDatetime(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_more_compare(self):
+ # The test_compare() inherited from TestDate covers the error cases.
+ # We just want to test lexicographic ordering on the members datetime
+ # has that date lacks.
+ args = [2000, 11, 29, 20, 58, 16, 999998]
+ t1 = self.theclass(*args)
+ t2 = self.theclass(*args)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for i in range(len(args)):
+ newargs = args[:]
+ newargs[i] = args[i] + 1
+ t2 = self.theclass(*newargs) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+
+ # A helper for timestamp constructor tests.
+ def verify_field_equality(self, expected, got):
+ self.assertEqual(expected.tm_year, got.year)
+ self.assertEqual(expected.tm_mon, got.month)
+ self.assertEqual(expected.tm_mday, got.day)
+ self.assertEqual(expected.tm_hour, got.hour)
+ self.assertEqual(expected.tm_min, got.minute)
+ self.assertEqual(expected.tm_sec, got.second)
+
+ def test_fromtimestamp(self):
+ import time
+
+ ts = time.time()
+ expected = time.localtime(ts)
+ got = self.theclass.fromtimestamp(ts)
+ self.verify_field_equality(expected, got)
+
+ def test_utcfromtimestamp(self):
+ import time
+
+ ts = time.time()
+ expected = time.gmtime(ts)
+ got = self.theclass.utcfromtimestamp(ts)
+ self.verify_field_equality(expected, got)
+
+ def test_microsecond_rounding(self):
+ # Test whether fromtimestamp "rounds up" floats that are less
+ # than 1/2 microsecond smaller than an integer.
+ for fts in [self.theclass.fromtimestamp,
+ self.theclass.utcfromtimestamp]:
+ self.assertEqual(fts(0.9999999), fts(1))
+ self.assertEqual(fts(0.99999949).microsecond, 999999)
+
+ def test_insane_fromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.fromtimestamp,
+ insane)
+
+ def test_insane_utcfromtimestamp(self):
+ # It's possible that some platform maps time_t to double,
+ # and that this test will fail there. This test should
+ # exempt such platforms (provided they return reasonable
+ # results!).
+ for insane in -1e200, 1e200:
+ self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
+ insane)
+ @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
+ def test_negative_float_fromtimestamp(self):
+ # The result is tz-dependent; at least test that this doesn't
+ # fail (like it did before bug 1646728 was fixed).
+ self.theclass.fromtimestamp(-1.05)
+
+ @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
+ def test_negative_float_utcfromtimestamp(self):
+ d = self.theclass.utcfromtimestamp(-1.05)
+ self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
+
+ def test_utcnow(self):
+ import time
+
+ # Call it a success if utcnow() and utcfromtimestamp() are within
+ # a second of each other.
+ tolerance = timedelta(seconds=1)
+ for dummy in range(3):
+ from_now = self.theclass.utcnow()
+ from_timestamp = self.theclass.utcfromtimestamp(time.time())
+ if abs(from_timestamp - from_now) <= tolerance:
+ break
+ # Else try again a few times.
+ self.assertTrue(abs(from_timestamp - from_now) <= tolerance)
+
+ def test_strptime(self):
+ string = '2004-12-01 13:02:47.197'
+ format = '%Y-%m-%d %H:%M:%S.%f'
+ expected = _strptime._strptime_datetime(self.theclass, string, format)
+ got = self.theclass.strptime(string, format)
+ self.assertEqual(expected, got)
+ self.assertIs(type(expected), self.theclass)
+ self.assertIs(type(got), self.theclass)
+
+ strptime = self.theclass.strptime
+ self.assertEqual(strptime("+0002", "%z").utcoffset(), 2 * MINUTE)
+ self.assertEqual(strptime("-0002", "%z").utcoffset(), -2 * MINUTE)
+ # Only local timezone and UTC are supported
+ for tzseconds, tzname in ((0, 'UTC'), (0, 'GMT'),
+ (-_time.timezone, _time.tzname[0])):
+ if tzseconds < 0:
+ sign = '-'
+ seconds = -tzseconds
+ else:
+ sign ='+'
+ seconds = tzseconds
+ hours, minutes = divmod(seconds//60, 60)
+ dtstr = "{}{:02d}{:02d} {}".format(sign, hours, minutes, tzname)
+ dt = strptime(dtstr, "%z %Z")
+ self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
+ self.assertEqual(dt.tzname(), tzname)
+ # Can produce inconsistent datetime
+ dtstr, fmt = "+1234 UTC", "%z %Z"
+ dt = strptime(dtstr, fmt)
+ self.assertEqual(dt.utcoffset(), 12 * HOUR + 34 * MINUTE)
+ self.assertEqual(dt.tzname(), 'UTC')
+ # yet will roundtrip
+ self.assertEqual(dt.strftime(fmt), dtstr)
+
+ # Produce naive datetime if no %z is provided
+ self.assertEqual(strptime("UTC", "%Z").tzinfo, None)
+
+ with self.assertRaises(ValueError): strptime("-2400", "%z")
+ with self.assertRaises(ValueError): strptime("-000", "%z")
+
+ def test_more_timetuple(self):
+ # This tests fields beyond those tested by the TestDate.test_timetuple.
+ t = self.theclass(2004, 12, 31, 6, 22, 33)
+ self.assertEqual(t.timetuple(), (2004, 12, 31, 6, 22, 33, 4, 366, -1))
+ self.assertEqual(t.timetuple(),
+ (t.year, t.month, t.day,
+ t.hour, t.minute, t.second,
+ t.weekday(),
+ t.toordinal() - date(t.year, 1, 1).toordinal() + 1,
+ -1))
+ tt = t.timetuple()
+ self.assertEqual(tt.tm_year, t.year)
+ self.assertEqual(tt.tm_mon, t.month)
+ self.assertEqual(tt.tm_mday, t.day)
+ self.assertEqual(tt.tm_hour, t.hour)
+ self.assertEqual(tt.tm_min, t.minute)
+ self.assertEqual(tt.tm_sec, t.second)
+ self.assertEqual(tt.tm_wday, t.weekday())
+ self.assertEqual(tt.tm_yday, t.toordinal() -
+ date(t.year, 1, 1).toordinal() + 1)
+ self.assertEqual(tt.tm_isdst, -1)
+
+ def test_more_strftime(self):
+ # This tests fields beyond those tested by the TestDate.test_strftime.
+ t = self.theclass(2004, 12, 31, 6, 22, 33, 47)
+ self.assertEqual(t.strftime("%m %d %y %f %S %M %H %j"),
+ "12 31 04 000047 33 22 06 366")
+
+ def test_extract(self):
+ dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
+ self.assertEqual(dt.date(), date(2002, 3, 4))
+ self.assertEqual(dt.time(), time(18, 45, 3, 1234))
+
+ def test_combine(self):
+ d = date(2002, 3, 4)
+ t = time(18, 45, 3, 1234)
+ expected = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
+ combine = self.theclass.combine
+ dt = combine(d, t)
+ self.assertEqual(dt, expected)
+
+ dt = combine(time=t, date=d)
+ self.assertEqual(dt, expected)
+
+ self.assertEqual(d, dt.date())
+ self.assertEqual(t, dt.time())
+ self.assertEqual(dt, combine(dt.date(), dt.time()))
+
+ self.assertRaises(TypeError, combine) # need an arg
+ self.assertRaises(TypeError, combine, d) # need two args
+ self.assertRaises(TypeError, combine, t, d) # args reversed
+ self.assertRaises(TypeError, combine, d, t, 1) # too many args
+ self.assertRaises(TypeError, combine, "date", "time") # wrong types
+ self.assertRaises(TypeError, combine, d, "time") # wrong type
+ self.assertRaises(TypeError, combine, "date", t) # wrong type
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3, 4, 5, 6, 7]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4),
+ ("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_astimezone(self):
+ # Pretty boring! The TZ test is more interesting here. astimezone()
+ # simply can't be applied to a naive object.
+ dt = self.theclass.now()
+ f = FixedOffset(44, "")
+ self.assertRaises(TypeError, dt.astimezone) # not enough args
+ self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
+ self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
+ self.assertRaises(ValueError, dt.astimezone, f) # naive
+ self.assertRaises(ValueError, dt.astimezone, tz=f) # naive
+
+ class Bogus(tzinfo):
+ def utcoffset(self, dt): return None
+ def dst(self, dt): return timedelta(0)
+ bog = Bogus()
+ self.assertRaises(ValueError, dt.astimezone, bog) # naive
+ self.assertRaises(ValueError,
+ dt.replace(tzinfo=bog).astimezone, f)
+
+ class AlsoBogus(tzinfo):
+ def utcoffset(self, dt): return timedelta(0)
+ def dst(self, dt): return None
+ alsobog = AlsoBogus()
+ self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
+
+ def test_subclass_datetime(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.year + self.month + self.second
+
+ args = 2003, 4, 14, 12, 13, 41
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.toordinal(), dt2.toordinal())
+ self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month +
+ dt1.second - 7)
+
+class TestSubclassDateTime(TestDateTime):
+ theclass = SubclassDatetime
+ # Override tests not designed for subclass
+ def test_roundtrip(self):
+ pass
+
+class SubclassTime(time):
+ sub_var = 1
+
+class TestTime(HarmlessMixedComparison, unittest.TestCase):
+
+ theclass = time
+
+ def test_basic_attributes(self):
+ t = self.theclass(12, 0)
+ self.assertEqual(t.hour, 12)
+ self.assertEqual(t.minute, 0)
+ self.assertEqual(t.second, 0)
+ self.assertEqual(t.microsecond, 0)
+
+ def test_basic_attributes_nonzero(self):
+ # Make sure all attributes are non-zero so bugs in
+ # bit-shifting access show up.
+ t = self.theclass(12, 59, 59, 8000)
+ self.assertEqual(t.hour, 12)
+ self.assertEqual(t.minute, 59)
+ self.assertEqual(t.second, 59)
+ self.assertEqual(t.microsecond, 8000)
+
+ def test_roundtrip(self):
+ t = self.theclass(1, 2, 3, 4)
+
+ # Verify t -> string -> time identity.
+ s = repr(t)
+ self.assertTrue(s.startswith('datetime.'))
+ s = s[9:]
+ t2 = eval(s)
+ self.assertEqual(t, t2)
+
+ # Verify identity via reconstructing from pieces.
+ t2 = self.theclass(t.hour, t.minute, t.second,
+ t.microsecond)
+ self.assertEqual(t, t2)
+
+ def test_comparing(self):
+ args = [1, 2, 3, 4]
+ t1 = self.theclass(*args)
+ t2 = self.theclass(*args)
+ self.assertEqual(t1, t2)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t1 >= t2)
+ self.assertTrue(not t1 != t2)
+ self.assertTrue(not t1 < t2)
+ self.assertTrue(not t1 > t2)
+
+ for i in range(len(args)):
+ newargs = args[:]
+ newargs[i] = args[i] + 1
+ t2 = self.theclass(*newargs) # this is larger than t1
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t2 > t1)
+ self.assertTrue(t1 <= t2)
+ self.assertTrue(t2 >= t1)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 != t1)
+ self.assertTrue(not t1 == t2)
+ self.assertTrue(not t2 == t1)
+ self.assertTrue(not t1 > t2)
+ self.assertTrue(not t2 < t1)
+ self.assertTrue(not t1 >= t2)
+ self.assertTrue(not t2 <= t1)
+
+ for badarg in OTHERSTUFF:
+ self.assertEqual(t1 == badarg, False)
+ self.assertEqual(t1 != badarg, True)
+ self.assertEqual(badarg == t1, False)
+ self.assertEqual(badarg != t1, True)
+
+ self.assertRaises(TypeError, lambda: t1 <= badarg)
+ self.assertRaises(TypeError, lambda: t1 < badarg)
+ self.assertRaises(TypeError, lambda: t1 > badarg)
+ self.assertRaises(TypeError, lambda: t1 >= badarg)
+ self.assertRaises(TypeError, lambda: badarg <= t1)
+ self.assertRaises(TypeError, lambda: badarg < t1)
+ self.assertRaises(TypeError, lambda: badarg > t1)
+ self.assertRaises(TypeError, lambda: badarg >= t1)
+
+ def test_bad_constructor_arguments(self):
+ # bad hours
+ self.theclass(0, 0) # no exception
+ self.theclass(23, 0) # no exception
+ self.assertRaises(ValueError, self.theclass, -1, 0)
+ self.assertRaises(ValueError, self.theclass, 24, 0)
+ # bad minutes
+ self.theclass(23, 0) # no exception
+ self.theclass(23, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 60)
+ # bad seconds
+ self.theclass(23, 59, 0) # no exception
+ self.theclass(23, 59, 59) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 59, 60)
+ # bad microseconds
+ self.theclass(23, 59, 59, 0) # no exception
+ self.theclass(23, 59, 59, 999999) # no exception
+ self.assertRaises(ValueError, self.theclass, 23, 59, 59, -1)
+ self.assertRaises(ValueError, self.theclass, 23, 59, 59, 1000000)
+
+ def test_hash_equality(self):
+ d = self.theclass(23, 30, 17)
+ e = self.theclass(23, 30, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ d = self.theclass(0, 5, 17)
+ e = self.theclass(0, 5, 17)
+ self.assertEqual(d, e)
+ self.assertEqual(hash(d), hash(e))
+
+ dic = {d: 1}
+ dic[e] = 2
+ self.assertEqual(len(dic), 1)
+ self.assertEqual(dic[d], 2)
+ self.assertEqual(dic[e], 2)
+
+ def test_isoformat(self):
+ t = self.theclass(4, 5, 1, 123)
+ self.assertEqual(t.isoformat(), "04:05:01.000123")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass()
+ self.assertEqual(t.isoformat(), "00:00:00")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=1)
+ self.assertEqual(t.isoformat(), "00:00:00.000001")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=10)
+ self.assertEqual(t.isoformat(), "00:00:00.000010")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=100)
+ self.assertEqual(t.isoformat(), "00:00:00.000100")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=1000)
+ self.assertEqual(t.isoformat(), "00:00:00.001000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=10000)
+ self.assertEqual(t.isoformat(), "00:00:00.010000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ t = self.theclass(microsecond=100000)
+ self.assertEqual(t.isoformat(), "00:00:00.100000")
+ self.assertEqual(t.isoformat(), str(t))
+
+ def test_1653736(self):
+ # verify it doesn't accept extra keyword arguments
+ t = self.theclass(second=1)
+ self.assertRaises(TypeError, t.isoformat, foo=3)
+
+ def test_strftime(self):
+ t = self.theclass(1, 2, 3, 4)
+ self.assertEqual(t.strftime('%H %M %S %f'), "01 02 03 000004")
+ # A naive object replaces %z and %Z with empty strings.
+ self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
+
+ def test_format(self):
+ t = self.theclass(1, 2, 3, 4)
+ self.assertEqual(t.__format__(''), str(t))
+
+ # check that a derived class's __str__() gets called
+ class A(self.theclass):
+ def __str__(self):
+ return 'A'
+ a = A(1, 2, 3, 4)
+ self.assertEqual(a.__format__(''), 'A')
+
+ # check that a derived class's strftime gets called
+ class B(self.theclass):
+ def strftime(self, format_spec):
+ return 'B'
+ b = B(1, 2, 3, 4)
+ self.assertEqual(b.__format__(''), str(t))
+
+ for fmt in ['%H %M %S',
+ ]:
+ self.assertEqual(t.__format__(fmt), t.strftime(fmt))
+ self.assertEqual(a.__format__(fmt), t.strftime(fmt))
+ self.assertEqual(b.__format__(fmt), 'B')
+
+ def test_str(self):
+ self.assertEqual(str(self.theclass(1, 2, 3, 4)), "01:02:03.000004")
+ self.assertEqual(str(self.theclass(10, 2, 3, 4000)), "10:02:03.004000")
+ self.assertEqual(str(self.theclass(0, 2, 3, 400000)), "00:02:03.400000")
+ self.assertEqual(str(self.theclass(12, 2, 3, 0)), "12:02:03")
+ self.assertEqual(str(self.theclass(23, 15, 0, 0)), "23:15:00")
+
+ def test_repr(self):
+ name = 'datetime.' + self.theclass.__name__
+ self.assertEqual(repr(self.theclass(1, 2, 3, 4)),
+ "%s(1, 2, 3, 4)" % name)
+ self.assertEqual(repr(self.theclass(10, 2, 3, 4000)),
+ "%s(10, 2, 3, 4000)" % name)
+ self.assertEqual(repr(self.theclass(0, 2, 3, 400000)),
+ "%s(0, 2, 3, 400000)" % name)
+ self.assertEqual(repr(self.theclass(12, 2, 3, 0)),
+ "%s(12, 2, 3)" % name)
+ self.assertEqual(repr(self.theclass(23, 15, 0, 0)),
+ "%s(23, 15)" % name)
+
+ def test_resolution_info(self):
+ self.assertIsInstance(self.theclass.min, self.theclass)
+ self.assertIsInstance(self.theclass.max, self.theclass)
+ self.assertIsInstance(self.theclass.resolution, timedelta)
+ self.assertTrue(self.theclass.max > self.theclass.min)
+
+ def test_pickling(self):
+ args = 20, 59, 16, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_pickling_subclass_time(self):
+ args = 20, 59, 16, 64**2
+ orig = SubclassTime(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ def test_bool(self):
+ cls = self.theclass
+ self.assertTrue(cls(1))
+ self.assertTrue(cls(0, 1))
+ self.assertTrue(cls(0, 0, 1))
+ self.assertTrue(cls(0, 0, 0, 1))
+ self.assertTrue(not cls(0))
+ self.assertTrue(not cls())
+
+ def test_replace(self):
+ cls = self.theclass
+ args = [1, 2, 3, 4]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Out of bounds.
+ base = cls(1)
+ self.assertRaises(ValueError, base.replace, hour=24)
+ self.assertRaises(ValueError, base.replace, minute=-1)
+ self.assertRaises(ValueError, base.replace, second=100)
+ self.assertRaises(ValueError, base.replace, microsecond=1000000)
+
+ def test_subclass_time(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.second
+
+ args = 4, 5, 6
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.isoformat(), dt2.isoformat())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
+
+ def test_backdoor_resistance(self):
+ # see TestDate.test_backdoor_resistance().
+ base = '2:59.0'
+ for hour_byte in ' ', '9', chr(24), '\xff':
+ self.assertRaises(TypeError, self.theclass,
+ hour_byte + base[1:])
+
+# A mixin for classes with a tzinfo= argument. Subclasses must define
+# theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever)
+# must be legit (which is true for time and datetime).
+class TZInfoBase:
+
+ def test_argument_passing(self):
+ cls = self.theclass
+ # A datetime passes itself on, a time passes None.
+ class introspective(tzinfo):
+ def tzname(self, dt): return dt and "real" or "none"
+ def utcoffset(self, dt):
+ return timedelta(minutes = dt and 42 or -42)
+ dst = utcoffset
+
+ obj = cls(1, 2, 3, tzinfo=introspective())
+
+ expected = cls is time and "none" or "real"
+ self.assertEqual(obj.tzname(), expected)
+
+ expected = timedelta(minutes=(cls is time and -42 or 42))
+ self.assertEqual(obj.utcoffset(), expected)
+ self.assertEqual(obj.dst(), expected)
+
+ def test_bad_tzinfo_classes(self):
+ cls = self.theclass
+ self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=12)
+
+ class NiceTry(object):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=NiceTry)
+
+ class BetterTry(tzinfo):
+ def __init__(self): pass
+ def utcoffset(self, dt): pass
+ b = BetterTry()
+ t = cls(1, 1, 1, tzinfo=b)
+ self.assertTrue(t.tzinfo is b)
+
+ def test_utc_offset_out_of_bounds(self):
+ class Edgy(tzinfo):
+ def __init__(self, offset):
+ self.offset = timedelta(minutes=offset)
+ def utcoffset(self, dt):
+ return self.offset
+
+ cls = self.theclass
+ for offset, legit in ((-1440, False),
+ (-1439, True),
+ (1439, True),
+ (1440, False)):
+ if cls is time:
+ t = cls(1, 2, 3, tzinfo=Edgy(offset))
+ elif cls is datetime:
+ t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
+ else:
+ assert 0, "impossible"
+ if legit:
+ aofs = abs(offset)
+ h, m = divmod(aofs, 60)
+ tag = "%c%02d:%02d" % (offset < 0 and '-' or '+', h, m)
+ if isinstance(t, datetime):
+ t = t.timetz()
+ self.assertEqual(str(t), "01:02:03" + tag)
+ else:
+ self.assertRaises(ValueError, str, t)
+
+ def test_tzinfo_classes(self):
+ cls = self.theclass
+ class C1(tzinfo):
+ def utcoffset(self, dt): return None
+ def dst(self, dt): return None
+ def tzname(self, dt): return None
+ for t in (cls(1, 1, 1),
+ cls(1, 1, 1, tzinfo=None),
+ cls(1, 1, 1, tzinfo=C1())):
+ self.assertTrue(t.utcoffset() is None)
+ self.assertTrue(t.dst() is None)
+ self.assertTrue(t.tzname() is None)
+
+ class C3(tzinfo):
+ def utcoffset(self, dt): return timedelta(minutes=-1439)
+ def dst(self, dt): return timedelta(minutes=1439)
+ def tzname(self, dt): return "aname"
+ t = cls(1, 1, 1, tzinfo=C3())
+ self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
+ self.assertEqual(t.dst(), timedelta(minutes=1439))
+ self.assertEqual(t.tzname(), "aname")
+
+ # Wrong types.
+ class C4(tzinfo):
+ def utcoffset(self, dt): return "aname"
+ def dst(self, dt): return 7
+ def tzname(self, dt): return 0
+ t = cls(1, 1, 1, tzinfo=C4())
+ self.assertRaises(TypeError, t.utcoffset)
+ self.assertRaises(TypeError, t.dst)
+ self.assertRaises(TypeError, t.tzname)
+
+ # Offset out of range.
+ class C6(tzinfo):
+ def utcoffset(self, dt): return timedelta(hours=-24)
+ def dst(self, dt): return timedelta(hours=24)
+ t = cls(1, 1, 1, tzinfo=C6())
+ self.assertRaises(ValueError, t.utcoffset)
+ self.assertRaises(ValueError, t.dst)
+
+ # Not a whole number of minutes.
+ class C7(tzinfo):
+ def utcoffset(self, dt): return timedelta(seconds=61)
+ def dst(self, dt): return timedelta(microseconds=-81)
+ t = cls(1, 1, 1, tzinfo=C7())
+ self.assertRaises(ValueError, t.utcoffset)
+ self.assertRaises(ValueError, t.dst)
+
+ def test_aware_compare(self):
+ cls = self.theclass
+
+ # Ensure that utcoffset() gets ignored if the comparands have
+ # the same tzinfo member.
+ class OperandDependentOffset(tzinfo):
+ def utcoffset(self, t):
+ if t.minute < 10:
+ # d0 and d1 equal after adjustment
+ return timedelta(minutes=t.minute)
+ else:
+ # d2 off in the weeds
+ return timedelta(minutes=59)
+
+ base = cls(8, 9, 10, tzinfo=OperandDependentOffset())
+ d0 = base.replace(minute=3)
+ d1 = base.replace(minute=9)
+ d2 = base.replace(minute=11)
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ for op in lt, le, gt, ge, eq, ne:
+ got = op(x, y)
+ expected = op(x.minute, y.minute)
+ self.assertEqual(got, expected)
+
+ # However, if they're different members, uctoffset is not ignored.
+ # Note that a time can't actually have an operand-depedent offset,
+ # though (and time.utcoffset() passes None to tzinfo.utcoffset()),
+ # so skip this test for time.
+ if cls is not time:
+ d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
+ d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
+ d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = (x > y) - (x < y)
+ if (x is d0 or x is d1) and (y is d0 or y is d1):
+ expected = 0
+ elif x is y is d2:
+ expected = 0
+ elif x is d2:
+ expected = -1
+ else:
+ assert y is d2
+ expected = 1
+ self.assertEqual(got, expected)
+
+
+# Testing time objects with a non-None tzinfo.
+class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
+ theclass = time
+
+ def test_empty(self):
+ t = self.theclass()
+ self.assertEqual(t.hour, 0)
+ self.assertEqual(t.minute, 0)
+ self.assertEqual(t.second, 0)
+ self.assertEqual(t.microsecond, 0)
+ self.assertTrue(t.tzinfo is None)
+
+ def test_zones(self):
+ est = FixedOffset(-300, "EST", 1)
+ utc = FixedOffset(0, "UTC", -2)
+ met = FixedOffset(60, "MET", 3)
+ t1 = time( 7, 47, tzinfo=est)
+ t2 = time(12, 47, tzinfo=utc)
+ t3 = time(13, 47, tzinfo=met)
+ t4 = time(microsecond=40)
+ t5 = time(microsecond=40, tzinfo=utc)
+
+ self.assertEqual(t1.tzinfo, est)
+ self.assertEqual(t2.tzinfo, utc)
+ self.assertEqual(t3.tzinfo, met)
+ self.assertTrue(t4.tzinfo is None)
+ self.assertEqual(t5.tzinfo, utc)
+
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
+ self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
+ self.assertTrue(t4.utcoffset() is None)
+ self.assertRaises(TypeError, t1.utcoffset, "no args")
+
+ self.assertEqual(t1.tzname(), "EST")
+ self.assertEqual(t2.tzname(), "UTC")
+ self.assertEqual(t3.tzname(), "MET")
+ self.assertTrue(t4.tzname() is None)
+ self.assertRaises(TypeError, t1.tzname, "no args")
+
+ self.assertEqual(t1.dst(), timedelta(minutes=1))
+ self.assertEqual(t2.dst(), timedelta(minutes=-2))
+ self.assertEqual(t3.dst(), timedelta(minutes=3))
+ self.assertTrue(t4.dst() is None)
+ self.assertRaises(TypeError, t1.dst, "no args")
+
+ self.assertEqual(hash(t1), hash(t2))
+ self.assertEqual(hash(t1), hash(t3))
+ self.assertEqual(hash(t2), hash(t3))
+
+ self.assertEqual(t1, t2)
+ self.assertEqual(t1, t3)
+ self.assertEqual(t2, t3)
+ self.assertRaises(TypeError, lambda: t4 == t5) # mixed tz-aware & naive
+ self.assertRaises(TypeError, lambda: t4 < t5) # mixed tz-aware & naive
+ self.assertRaises(TypeError, lambda: t5 < t4) # mixed tz-aware & naive
+
+ self.assertEqual(str(t1), "07:47:00-05:00")
+ self.assertEqual(str(t2), "12:47:00+00:00")
+ self.assertEqual(str(t3), "13:47:00+01:00")
+ self.assertEqual(str(t4), "00:00:00.000040")
+ self.assertEqual(str(t5), "00:00:00.000040+00:00")
+
+ self.assertEqual(t1.isoformat(), "07:47:00-05:00")
+ self.assertEqual(t2.isoformat(), "12:47:00+00:00")
+ self.assertEqual(t3.isoformat(), "13:47:00+01:00")
+ self.assertEqual(t4.isoformat(), "00:00:00.000040")
+ self.assertEqual(t5.isoformat(), "00:00:00.000040+00:00")
+
+ d = 'datetime.time'
+ self.assertEqual(repr(t1), d + "(7, 47, tzinfo=est)")
+ self.assertEqual(repr(t2), d + "(12, 47, tzinfo=utc)")
+ self.assertEqual(repr(t3), d + "(13, 47, tzinfo=met)")
+ self.assertEqual(repr(t4), d + "(0, 0, 0, 40)")
+ self.assertEqual(repr(t5), d + "(0, 0, 0, 40, tzinfo=utc)")
+
+ self.assertEqual(t1.strftime("%H:%M:%S %%Z=%Z %%z=%z"),
+ "07:47:00 %Z=EST %z=-0500")
+ self.assertEqual(t2.strftime("%H:%M:%S %Z %z"), "12:47:00 UTC +0000")
+ self.assertEqual(t3.strftime("%H:%M:%S %Z %z"), "13:47:00 MET +0100")
+
+ yuck = FixedOffset(-1439, "%z %Z %%z%%Z")
+ t1 = time(23, 59, tzinfo=yuck)
+ self.assertEqual(t1.strftime("%H:%M %%Z='%Z' %%z='%z'"),
+ "23:59 %Z='%z %Z %%z%%Z' %z='-2359'")
+
+ # Check that an invalid tzname result raises an exception.
+ class Badtzname(tzinfo):
+ tz = 42
+ def tzname(self, dt): return self.tz
+ t = time(2, 3, 4, tzinfo=Badtzname())
+ self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
+ self.assertRaises(TypeError, t.strftime, "%Z")
+
+ # Issue #6697:
+ if '_Fast' in str(type(self)):
+ Badtzname.tz = '\ud800'
+ self.assertRaises(ValueError, t.strftime, "%Z")
+
+ def test_hash_edge_cases(self):
+ # Offsets that overflow a basic time.
+ t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
+ t2 = self.theclass(0, 0, 2, 3, tzinfo=FixedOffset(1438, ""))
+ self.assertEqual(hash(t1), hash(t2))
+
+ t1 = self.theclass(23, 58, 6, 100, tzinfo=FixedOffset(-1000, ""))
+ t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, ""))
+ self.assertEqual(hash(t1), hash(t2))
+
+ def test_pickling(self):
+ # Try one without a tzinfo.
+ args = 20, 59, 16, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ # Try one with a tzinfo.
+ tinfo = PicklableFixedOffset(-300, 'cookie')
+ orig = self.theclass(5, 6, 7, tzinfo=tinfo)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+ self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
+ self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(derived.tzname(), 'cookie')
+
+ def test_more_bool(self):
+ # Test cases with non-None tzinfo.
+ cls = self.theclass
+
+ t = cls(0, tzinfo=FixedOffset(-300, ""))
+ self.assertTrue(t)
+
+ t = cls(5, tzinfo=FixedOffset(-300, ""))
+ self.assertTrue(t)
+
+ t = cls(5, tzinfo=FixedOffset(300, ""))
+ self.assertTrue(not t)
+
+ t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
+ self.assertTrue(not t)
+
+ # Mostly ensuring this doesn't overflow internally.
+ t = cls(0, tzinfo=FixedOffset(23*60 + 59, ""))
+ self.assertTrue(t)
+
+ # But this should yield a value error -- the utcoffset is bogus.
+ t = cls(0, tzinfo=FixedOffset(24*60, ""))
+ self.assertRaises(ValueError, lambda: bool(t))
+
+ # Likewise.
+ t = cls(0, tzinfo=FixedOffset(-24*60, ""))
+ self.assertRaises(ValueError, lambda: bool(t))
+
+ def test_replace(self):
+ cls = self.theclass
+ z100 = FixedOffset(100, "+100")
+ zm200 = FixedOffset(timedelta(minutes=-200), "-200")
+ args = [1, 2, 3, 4, z100]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8),
+ ("tzinfo", zm200)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Ensure we can get rid of a tzinfo.
+ self.assertEqual(base.tzname(), "+100")
+ base2 = base.replace(tzinfo=None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
+
+ # Ensure we can add one.
+ base3 = base2.replace(tzinfo=z100)
+ self.assertEqual(base, base3)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
+
+ # Out of bounds.
+ base = cls(1)
+ self.assertRaises(ValueError, base.replace, hour=24)
+ self.assertRaises(ValueError, base.replace, minute=-1)
+ self.assertRaises(ValueError, base.replace, second=100)
+ self.assertRaises(ValueError, base.replace, microsecond=1000000)
+
+ def test_mixed_compare(self):
+ t1 = time(1, 2, 3)
+ t2 = time(1, 2, 3)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=None)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(None, ""))
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(0, ""))
+ self.assertRaises(TypeError, lambda: t1 == t2)
+
+ # In time w/ identical tzinfo objects, utcoffset is ignored.
+ class Varies(tzinfo):
+ def __init__(self):
+ self.offset = timedelta(minutes=22)
+ def utcoffset(self, t):
+ self.offset += timedelta(minutes=1)
+ return self.offset
+
+ v = Varies()
+ t1 = t2.replace(tzinfo=v)
+ t2 = t2.replace(tzinfo=v)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
+ self.assertEqual(t1, t2)
+
+ # But if they're not identical, it isn't ignored.
+ t2 = t2.replace(tzinfo=Varies())
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
+
+ def test_subclass_timetz(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.second
+
+ args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
+
+
+# Testing datetime objects with a non-None tzinfo.
+
+class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
+ theclass = datetime
+
+ def test_trivial(self):
+ dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
+ self.assertEqual(dt.year, 1)
+ self.assertEqual(dt.month, 2)
+ self.assertEqual(dt.day, 3)
+ self.assertEqual(dt.hour, 4)
+ self.assertEqual(dt.minute, 5)
+ self.assertEqual(dt.second, 6)
+ self.assertEqual(dt.microsecond, 7)
+ self.assertEqual(dt.tzinfo, None)
+
+ def test_even_more_compare(self):
+ # The test_compare() and test_more_compare() inherited from TestDate
+ # and TestDateTime covered non-tzinfo cases.
+
+ # Smallest possible after UTC adjustment.
+ t1 = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
+ # Largest possible after UTC adjustment.
+ t2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, ""))
+
+ # Make sure those compare correctly, and w/o overflow.
+ self.assertTrue(t1 < t2)
+ self.assertTrue(t1 != t2)
+ self.assertTrue(t2 > t1)
+
+ self.assertEqual(t1, t1)
+ self.assertEqual(t2, t2)
+
+ # Equal afer adjustment.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
+ t2 = self.theclass(2, 1, 1, 3, 13, tzinfo=FixedOffset(3*60+13+2, ""))
+ self.assertEqual(t1, t2)
+
+ # Change t1 not to subtract a minute, and t1 should be larger.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
+ self.assertTrue(t1 > t2)
+
+ # Change t1 to subtract 2 minutes, and t1 should be smaller.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
+ self.assertTrue(t1 < t2)
+
+ # Back to the original t1, but make seconds resolve it.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
+ second=1)
+ self.assertTrue(t1 > t2)
+
+ # Likewise, but make microseconds resolve it.
+ t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
+ microsecond=1)
+ self.assertTrue(t1 > t2)
+
+ # Make t2 naive and it should fail.
+ t2 = self.theclass.min
+ self.assertRaises(TypeError, lambda: t1 == t2)
+ self.assertEqual(t2, t2)
+
+ # It's also naive if it has tzinfo but tzinfo.utcoffset() is None.
+ class Naive(tzinfo):
+ def utcoffset(self, dt): return None
+ t2 = self.theclass(5, 6, 7, tzinfo=Naive())
+ self.assertRaises(TypeError, lambda: t1 == t2)
+ self.assertEqual(t2, t2)
+
+ # OTOH, it's OK to compare two of these mixing the two ways of being
+ # naive.
+ t1 = self.theclass(5, 6, 7)
+ self.assertEqual(t1, t2)
+
+ # Try a bogus uctoffset.
+ class Bogus(tzinfo):
+ def utcoffset(self, dt):
+ return timedelta(minutes=1440) # out of bounds
+ t1 = self.theclass(2, 2, 2, tzinfo=Bogus())
+ t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, ""))
+ self.assertRaises(ValueError, lambda: t1 == t2)
+
+ def test_pickling(self):
+ # Try one without a tzinfo.
+ args = 6, 7, 23, 20, 59, 1, 64**2
+ orig = self.theclass(*args)
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+
+ # Try one with a tzinfo.
+ tinfo = PicklableFixedOffset(-300, 'cookie')
+ orig = self.theclass(*args, **{'tzinfo': tinfo})
+ derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
+ for pickler, unpickler, proto in pickle_choices:
+ green = pickler.dumps(orig, proto)
+ derived = unpickler.loads(green)
+ self.assertEqual(orig, derived)
+ self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
+ self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(derived.tzname(), 'cookie')
+
+ def test_extreme_hashes(self):
+ # If an attempt is made to hash these via subtracting the offset
+ # then hashing a datetime object, OverflowError results. The
+ # Python implementation used to blow up here.
+ t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
+ hash(t)
+ t = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, ""))
+ hash(t)
+
+ # OTOH, an OOB offset should blow up.
+ t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
+ self.assertRaises(ValueError, hash, t)
+
+ def test_zones(self):
+ est = FixedOffset(-300, "EST")
+ utc = FixedOffset(0, "UTC")
+ met = FixedOffset(60, "MET")
+ t1 = datetime(2002, 3, 19, 7, 47, tzinfo=est)
+ t2 = datetime(2002, 3, 19, 12, 47, tzinfo=utc)
+ t3 = datetime(2002, 3, 19, 13, 47, tzinfo=met)
+ self.assertEqual(t1.tzinfo, est)
+ self.assertEqual(t2.tzinfo, utc)
+ self.assertEqual(t3.tzinfo, met)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
+ self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
+ self.assertEqual(t1.tzname(), "EST")
+ self.assertEqual(t2.tzname(), "UTC")
+ self.assertEqual(t3.tzname(), "MET")
+ self.assertEqual(hash(t1), hash(t2))
+ self.assertEqual(hash(t1), hash(t3))
+ self.assertEqual(hash(t2), hash(t3))
+ self.assertEqual(t1, t2)
+ self.assertEqual(t1, t3)
+ self.assertEqual(t2, t3)
+ self.assertEqual(str(t1), "2002-03-19 07:47:00-05:00")
+ self.assertEqual(str(t2), "2002-03-19 12:47:00+00:00")
+ self.assertEqual(str(t3), "2002-03-19 13:47:00+01:00")
+ d = 'datetime.datetime(2002, 3, 19, '
+ self.assertEqual(repr(t1), d + "7, 47, tzinfo=est)")
+ self.assertEqual(repr(t2), d + "12, 47, tzinfo=utc)")
+ self.assertEqual(repr(t3), d + "13, 47, tzinfo=met)")
+
+ def test_combine(self):
+ met = FixedOffset(60, "MET")
+ d = date(2002, 3, 4)
+ tz = time(18, 45, 3, 1234, tzinfo=met)
+ dt = datetime.combine(d, tz)
+ self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
+ tzinfo=met))
+
+ def test_extract(self):
+ met = FixedOffset(60, "MET")
+ dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
+ self.assertEqual(dt.date(), date(2002, 3, 4))
+ self.assertEqual(dt.time(), time(18, 45, 3, 1234))
+ self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
+
+ def test_tz_aware_arithmetic(self):
+ import random
+
+ now = self.theclass.now()
+ tz55 = FixedOffset(-330, "west 5:30")
+ timeaware = now.time().replace(tzinfo=tz55)
+ nowaware = self.theclass.combine(now.date(), timeaware)
+ self.assertTrue(nowaware.tzinfo is tz55)
+ self.assertEqual(nowaware.timetz(), timeaware)
+
+ # Can't mix aware and non-aware.
+ self.assertRaises(TypeError, lambda: now - nowaware)
+ self.assertRaises(TypeError, lambda: nowaware - now)
+
+ # And adding datetime's doesn't make sense, aware or not.
+ self.assertRaises(TypeError, lambda: now + nowaware)
+ self.assertRaises(TypeError, lambda: nowaware + now)
+ self.assertRaises(TypeError, lambda: nowaware + nowaware)
+
+ # Subtracting should yield 0.
+ self.assertEqual(now - now, timedelta(0))
+ self.assertEqual(nowaware - nowaware, timedelta(0))
+
+ # Adding a delta should preserve tzinfo.
+ delta = timedelta(weeks=1, minutes=12, microseconds=5678)
+ nowawareplus = nowaware + delta
+ self.assertTrue(nowaware.tzinfo is tz55)
+ nowawareplus2 = delta + nowaware
+ self.assertTrue(nowawareplus2.tzinfo is tz55)
+ self.assertEqual(nowawareplus, nowawareplus2)
+
+ # that - delta should be what we started with, and that - what we
+ # started with should be delta.
+ diff = nowawareplus - delta
+ self.assertTrue(diff.tzinfo is tz55)
+ self.assertEqual(nowaware, diff)
+ self.assertRaises(TypeError, lambda: delta - nowawareplus)
+ self.assertEqual(nowawareplus - nowaware, delta)
+
+ # Make up a random timezone.
+ tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone")
+ # Attach it to nowawareplus.
+ nowawareplus = nowawareplus.replace(tzinfo=tzr)
+ self.assertTrue(nowawareplus.tzinfo is tzr)
+ # Make sure the difference takes the timezone adjustments into account.
+ got = nowaware - nowawareplus
+ # Expected: (nowaware base - nowaware offset) -
+ # (nowawareplus base - nowawareplus offset) =
+ # (nowaware base - nowawareplus base) +
+ # (nowawareplus offset - nowaware offset) =
+ # -delta + nowawareplus offset - nowaware offset
+ expected = nowawareplus.utcoffset() - nowaware.utcoffset() - delta
+ self.assertEqual(got, expected)
+
+ # Try max possible difference.
+ min = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, "min"))
+ max = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
+ tzinfo=FixedOffset(-1439, "max"))
+ maxdiff = max - min
+ self.assertEqual(maxdiff, self.theclass.max - self.theclass.min +
+ timedelta(minutes=2*1439))
+ # Different tzinfo, but the same offset
+ tza = timezone(HOUR, 'A')
+ tzb = timezone(HOUR, 'B')
+ delta = min.replace(tzinfo=tza) - max.replace(tzinfo=tzb)
+ self.assertEqual(delta, self.theclass.min - self.theclass.max)
+
+ def test_tzinfo_now(self):
+ meth = self.theclass.now
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth()
+ # Try with and without naming the keyword.
+ off42 = FixedOffset(42, "42")
+ another = meth(off42)
+ again = meth(tz=off42)
+ self.assertTrue(another.tzinfo is again.tzinfo)
+ self.assertEqual(another.utcoffset(), timedelta(minutes=42))
+ # Bad argument with and w/o naming the keyword.
+ self.assertRaises(TypeError, meth, 16)
+ self.assertRaises(TypeError, meth, tzinfo=16)
+ # Bad keyword name.
+ self.assertRaises(TypeError, meth, tinfo=off42)
+ # Too many args.
+ self.assertRaises(TypeError, meth, off42, off42)
+
+ # We don't know which time zone we're in, and don't have a tzinfo
+ # class to represent it, so seeing whether a tz argument actually
+ # does a conversion is tricky.
+ utc = FixedOffset(0, "utc", 0)
+ for weirdtz in [FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0),
+ timezone(timedelta(hours=15, minutes=58), "weirdtz"),]:
+ for dummy in range(3):
+ now = datetime.now(weirdtz)
+ self.assertTrue(now.tzinfo is weirdtz)
+ utcnow = datetime.utcnow().replace(tzinfo=utc)
+ now2 = utcnow.astimezone(weirdtz)
+ if abs(now - now2) < timedelta(seconds=30):
+ break
+ # Else the code is broken, or more than 30 seconds passed between
+ # calls; assuming the latter, just try again.
+ else:
+ # Three strikes and we're out.
+ self.fail("utcnow(), now(tz), or astimezone() may be broken")
+
+ def test_tzinfo_fromtimestamp(self):
+ import time
+ meth = self.theclass.fromtimestamp
+ ts = time.time()
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth(ts)
+ # Try with and without naming the keyword.
+ off42 = FixedOffset(42, "42")
+ another = meth(ts, off42)
+ again = meth(ts, tz=off42)
+ self.assertTrue(another.tzinfo is again.tzinfo)
+ self.assertEqual(another.utcoffset(), timedelta(minutes=42))
+ # Bad argument with and w/o naming the keyword.
+ self.assertRaises(TypeError, meth, ts, 16)
+ self.assertRaises(TypeError, meth, ts, tzinfo=16)
+ # Bad keyword name.
+ self.assertRaises(TypeError, meth, ts, tinfo=off42)
+ # Too many args.
+ self.assertRaises(TypeError, meth, ts, off42, off42)
+ # Too few args.
+ self.assertRaises(TypeError, meth)
+
+ # Try to make sure tz= actually does some conversion.
+ timestamp = 1000000000
+ utcdatetime = datetime.utcfromtimestamp(timestamp)
+ # In POSIX (epoch 1970), that's 2001-09-09 01:46:40 UTC, give or take.
+ # But on some flavor of Mac, it's nowhere near that. So we can't have
+ # any idea here what time that actually is, we can only test that
+ # relative changes match.
+ utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
+ tz = FixedOffset(utcoffset, "tz", 0)
+ expected = utcdatetime + utcoffset
+ got = datetime.fromtimestamp(timestamp, tz)
+ self.assertEqual(expected, got.replace(tzinfo=None))
+
+ def test_tzinfo_utcnow(self):
+ meth = self.theclass.utcnow
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth()
+ # Try with and without naming the keyword; for whatever reason,
+ # utcnow() doesn't accept a tzinfo argument.
+ off42 = FixedOffset(42, "42")
+ self.assertRaises(TypeError, meth, off42)
+ self.assertRaises(TypeError, meth, tzinfo=off42)
+
+ def test_tzinfo_utcfromtimestamp(self):
+ import time
+ meth = self.theclass.utcfromtimestamp
+ ts = time.time()
+ # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
+ base = meth(ts)
+ # Try with and without naming the keyword; for whatever reason,
+ # utcfromtimestamp() doesn't accept a tzinfo argument.
+ off42 = FixedOffset(42, "42")
+ self.assertRaises(TypeError, meth, ts, off42)
+ self.assertRaises(TypeError, meth, ts, tzinfo=off42)
+
+ def test_tzinfo_timetuple(self):
+ # TestDateTime tested most of this. datetime adds a twist to the
+ # DST flag.
+ class DST(tzinfo):
+ def __init__(self, dstvalue):
+ if isinstance(dstvalue, int):
+ dstvalue = timedelta(minutes=dstvalue)
+ self.dstvalue = dstvalue
+ def dst(self, dt):
+ return self.dstvalue
+
+ cls = self.theclass
+ for dstvalue, flag in (-33, 1), (33, 1), (0, 0), (None, -1):
+ d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue))
+ t = d.timetuple()
+ self.assertEqual(1, t.tm_year)
+ self.assertEqual(1, t.tm_mon)
+ self.assertEqual(1, t.tm_mday)
+ self.assertEqual(10, t.tm_hour)
+ self.assertEqual(20, t.tm_min)
+ self.assertEqual(30, t.tm_sec)
+ self.assertEqual(0, t.tm_wday)
+ self.assertEqual(1, t.tm_yday)
+ self.assertEqual(flag, t.tm_isdst)
+
+ # dst() returns wrong type.
+ self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple)
+
+ # dst() at the edge.
+ self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1)
+ self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1)
+
+ # dst() out of range.
+ self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple)
+ self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
+
+ def test_utctimetuple(self):
+ class DST(tzinfo):
+ def __init__(self, dstvalue=0):
+ if isinstance(dstvalue, int):
+ dstvalue = timedelta(minutes=dstvalue)
+ self.dstvalue = dstvalue
+ def dst(self, dt):
+ return self.dstvalue
+
+ cls = self.theclass
+ # This can't work: DST didn't implement utcoffset.
+ self.assertRaises(NotImplementedError,
+ cls(1, 1, 1, tzinfo=DST(0)).utcoffset)
+
+ class UOFS(DST):
+ def __init__(self, uofs, dofs=None):
+ DST.__init__(self, dofs)
+ self.uofs = timedelta(minutes=uofs)
+ def utcoffset(self, dt):
+ return self.uofs
+
+ for dstvalue in -33, 33, 0, None:
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=UOFS(-53, dstvalue))
+ t = d.utctimetuple()
+ self.assertEqual(d.year, t.tm_year)
+ self.assertEqual(d.month, t.tm_mon)
+ self.assertEqual(d.day, t.tm_mday)
+ self.assertEqual(11, t.tm_hour) # 20mm + 53mm = 1hn + 13mm
+ self.assertEqual(13, t.tm_min)
+ self.assertEqual(d.second, t.tm_sec)
+ self.assertEqual(d.weekday(), t.tm_wday)
+ self.assertEqual(d.toordinal() - date(1, 1, 1).toordinal() + 1,
+ t.tm_yday)
+ # Ensure tm_isdst is 0 regardless of what dst() says: DST
+ # is never in effect for a UTC time.
+ self.assertEqual(0, t.tm_isdst)
+
+ # For naive datetime, utctimetuple == timetuple except for isdst
+ d = cls(1, 2, 3, 10, 20, 30, 40)
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Same if utcoffset is None
+ class NOFS(DST):
+ def utcoffset(self, dt):
+ return None
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=NOFS())
+ t = d.utctimetuple()
+ self.assertEqual(t[:-1], d.timetuple()[:-1])
+ self.assertEqual(0, t.tm_isdst)
+ # Check that bad tzinfo is detected
+ class BOFS(DST):
+ def utcoffset(self, dt):
+ return "EST"
+ d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=BOFS())
+ self.assertRaises(TypeError, d.utctimetuple)
+
+ # Check that utctimetuple() is the same as
+ # astimezone(utc).timetuple()
+ d = cls(2010, 11, 13, 14, 15, 16, 171819)
+ for tz in [timezone.min, timezone.utc, timezone.max]:
+ dtz = d.replace(tzinfo=tz)
+ self.assertEqual(dtz.utctimetuple()[:-1],
+ dtz.astimezone(timezone.utc).timetuple()[:-1])
+ # At the edges, UTC adjustment can produce years out-of-range
+ # for a datetime object. Ensure that an OverflowError is
+ # raised.
+ tiny = cls(MINYEAR, 1, 1, 0, 0, 37, tzinfo=UOFS(1439))
+ # That goes back 1 minute less than a full day.
+ self.assertRaises(OverflowError, tiny.utctimetuple)
+
+ huge = cls(MAXYEAR, 12, 31, 23, 59, 37, 999999, tzinfo=UOFS(-1439))
+ # That goes forward 1 minute less than a full day.
+ self.assertRaises(OverflowError, huge.utctimetuple)
+ # More overflow cases
+ tiny = cls.min.replace(tzinfo=timezone(MINUTE))
+ self.assertRaises(OverflowError, tiny.utctimetuple)
+ huge = cls.max.replace(tzinfo=timezone(-MINUTE))
+ self.assertRaises(OverflowError, huge.utctimetuple)
+
+ def test_tzinfo_isoformat(self):
+ zero = FixedOffset(0, "+00:00")
+ plus = FixedOffset(220, "+03:40")
+ minus = FixedOffset(-231, "-03:51")
+ unknown = FixedOffset(None, "")
+
+ cls = self.theclass
+ datestr = '0001-02-03'
+ for ofs in None, zero, plus, minus, unknown:
+ for us in 0, 987001:
+ d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
+ timestr = '04:05:59' + (us and '.987001' or '')
+ ofsstr = ofs is not None and d.tzname() or ''
+ tailstr = timestr + ofsstr
+ iso = d.isoformat()
+ self.assertEqual(iso, datestr + 'T' + tailstr)
+ self.assertEqual(iso, d.isoformat('T'))
+ self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr)
+ self.assertEqual(d.isoformat('\u1234'), datestr + '\u1234' + tailstr)
+ self.assertEqual(str(d), datestr + ' ' + tailstr)
+
+ def test_replace(self):
+ cls = self.theclass
+ z100 = FixedOffset(100, "+100")
+ zm200 = FixedOffset(timedelta(minutes=-200), "-200")
+ args = [1, 2, 3, 4, 5, 6, 7, z100]
+ base = cls(*args)
+ self.assertEqual(base, base.replace())
+
+ i = 0
+ for name, newval in (("year", 2),
+ ("month", 3),
+ ("day", 4),
+ ("hour", 5),
+ ("minute", 6),
+ ("second", 7),
+ ("microsecond", 8),
+ ("tzinfo", zm200)):
+ newargs = args[:]
+ newargs[i] = newval
+ expected = cls(*newargs)
+ got = base.replace(**{name: newval})
+ self.assertEqual(expected, got)
+ i += 1
+
+ # Ensure we can get rid of a tzinfo.
+ self.assertEqual(base.tzname(), "+100")
+ base2 = base.replace(tzinfo=None)
+ self.assertTrue(base2.tzinfo is None)
+ self.assertTrue(base2.tzname() is None)
+
+ # Ensure we can add one.
+ base3 = base2.replace(tzinfo=z100)
+ self.assertEqual(base, base3)
+ self.assertTrue(base.tzinfo is base3.tzinfo)
+
+ # Out of bounds.
+ base = cls(2000, 2, 29)
+ self.assertRaises(ValueError, base.replace, year=2001)
+
+ def test_more_astimezone(self):
+ # The inherited test_astimezone covered some trivial and error cases.
+ fnone = FixedOffset(None, "None")
+ f44m = FixedOffset(44, "44")
+ fm5h = FixedOffset(-timedelta(hours=5), "m300")
+
+ dt = self.theclass.now(tz=f44m)
+ self.assertTrue(dt.tzinfo is f44m)
+ # Replacing with degenerate tzinfo raises an exception.
+ self.assertRaises(ValueError, dt.astimezone, fnone)
+ # Ditto with None tz.
+ self.assertRaises(TypeError, dt.astimezone, None)
+ # Replacing with same tzinfo makes no change.
+ x = dt.astimezone(dt.tzinfo)
+ self.assertTrue(x.tzinfo is f44m)
+ self.assertEqual(x.date(), dt.date())
+ self.assertEqual(x.time(), dt.time())
+
+ # Replacing with different tzinfo does adjust.
+ got = dt.astimezone(fm5h)
+ self.assertTrue(got.tzinfo is fm5h)
+ self.assertEqual(got.utcoffset(), timedelta(hours=-5))
+ expected = dt - dt.utcoffset() # in effect, convert to UTC
+ expected += fm5h.utcoffset(dt) # and from there to local time
+ expected = expected.replace(tzinfo=fm5h) # and attach new tzinfo
+ self.assertEqual(got.date(), expected.date())
+ self.assertEqual(got.time(), expected.time())
+ self.assertEqual(got.timetz(), expected.timetz())
+ self.assertTrue(got.tzinfo is expected.tzinfo)
+ self.assertEqual(got, expected)
+
+ def test_aware_subtract(self):
+ cls = self.theclass
+
+ # Ensure that utcoffset() is ignored when the operands have the
+ # same tzinfo member.
+ class OperandDependentOffset(tzinfo):
+ def utcoffset(self, t):
+ if t.minute < 10:
+ # d0 and d1 equal after adjustment
+ return timedelta(minutes=t.minute)
+ else:
+ # d2 off in the weeds
+ return timedelta(minutes=59)
+
+ base = cls(8, 9, 10, 11, 12, 13, 14, tzinfo=OperandDependentOffset())
+ d0 = base.replace(minute=3)
+ d1 = base.replace(minute=9)
+ d2 = base.replace(minute=11)
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = x - y
+ expected = timedelta(minutes=x.minute - y.minute)
+ self.assertEqual(got, expected)
+
+ # OTOH, if the tzinfo members are distinct, utcoffsets aren't
+ # ignored.
+ base = cls(8, 9, 10, 11, 12, 13, 14)
+ d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
+ d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
+ d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
+ for x in d0, d1, d2:
+ for y in d0, d1, d2:
+ got = x - y
+ if (x is d0 or x is d1) and (y is d0 or y is d1):
+ expected = timedelta(0)
+ elif x is y is d2:
+ expected = timedelta(0)
+ elif x is d2:
+ expected = timedelta(minutes=(11-59)-0)
+ else:
+ assert y is d2
+ expected = timedelta(minutes=0-(11-59))
+ self.assertEqual(got, expected)
+
+ def test_mixed_compare(self):
+ t1 = datetime(1, 2, 3, 4, 5, 6, 7)
+ t2 = datetime(1, 2, 3, 4, 5, 6, 7)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=None)
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(None, ""))
+ self.assertEqual(t1, t2)
+ t2 = t2.replace(tzinfo=FixedOffset(0, ""))
+ self.assertRaises(TypeError, lambda: t1 == t2)
+
+ # In datetime w/ identical tzinfo objects, utcoffset is ignored.
+ class Varies(tzinfo):
+ def __init__(self):
+ self.offset = timedelta(minutes=22)
+ def utcoffset(self, t):
+ self.offset += timedelta(minutes=1)
+ return self.offset
+
+ v = Varies()
+ t1 = t2.replace(tzinfo=v)
+ t2 = t2.replace(tzinfo=v)
+ self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
+ self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
+ self.assertEqual(t1, t2)
+
+ # But if they're not identical, it isn't ignored.
+ t2 = t2.replace(tzinfo=Varies())
+ self.assertTrue(t1 < t2) # t1's offset counter still going up
+
+ def test_subclass_datetimetz(self):
+
+ class C(self.theclass):
+ theAnswer = 42
+
+ def __new__(cls, *args, **kws):
+ temp = kws.copy()
+ extra = temp.pop('extra')
+ result = self.theclass.__new__(cls, *args, **temp)
+ result.extra = extra
+ return result
+
+ def newmeth(self, start):
+ return start + self.hour + self.year
+
+ args = 2002, 12, 31, 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
+
+ dt1 = self.theclass(*args)
+ dt2 = C(*args, **{'extra': 7})
+
+ self.assertEqual(dt2.__class__, C)
+ self.assertEqual(dt2.theAnswer, 42)
+ self.assertEqual(dt2.extra, 7)
+ self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
+ self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.year - 7)
+
+# Pain to set up DST-aware tzinfo classes.
+
+def first_sunday_on_or_after(dt):
+ days_to_go = 6 - dt.weekday()
+ if days_to_go:
+ dt += timedelta(days_to_go)
+ return dt
+
+ZERO = timedelta(0)
+MINUTE = timedelta(minutes=1)
+HOUR = timedelta(hours=1)
+DAY = timedelta(days=1)
+# In the US, DST starts at 2am (standard time) on the first Sunday in April.
+DSTSTART = datetime(1, 4, 1, 2)
+# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct,
+# which is the first Sunday on or after Oct 25. Because we view 1:MM as
+# being standard time on that day, there is no spelling in local time of
+# the last hour of DST (that's 1:MM DST, but 1:MM is taken as standard time).
+DSTEND = datetime(1, 10, 25, 1)
+
+class USTimeZone(tzinfo):
+
+ def __init__(self, hours, reprname, stdname, dstname):
+ self.stdoffset = timedelta(hours=hours)
+ self.reprname = reprname
+ self.stdname = stdname
+ self.dstname = dstname
+
+ def __repr__(self):
+ return self.reprname
+
+ def tzname(self, dt):
+ if self.dst(dt):
+ return self.dstname
+ else:
+ return self.stdname
+
+ def utcoffset(self, dt):
+ return self.stdoffset + self.dst(dt)
+
+ def dst(self, dt):
+ if dt is None or dt.tzinfo is None:
+ # An exception instead may be sensible here, in one or more of
+ # the cases.
+ return ZERO
+ assert dt.tzinfo is self
+
+ # Find first Sunday in April.
+ start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
+ assert start.weekday() == 6 and start.month == 4 and start.day <= 7
+
+ # Find last Sunday in October.
+ end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
+ assert end.weekday() == 6 and end.month == 10 and end.day >= 25
+
+ # Can't compare naive to aware objects, so strip the timezone from
+ # dt first.
+ if start <= dt.replace(tzinfo=None) < end:
+ return HOUR
+ else:
+ return ZERO
+
+Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
+Central = USTimeZone(-6, "Central", "CST", "CDT")
+Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
+Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
+utc_real = FixedOffset(0, "UTC", 0)
+# For better test coverage, we want another flavor of UTC that's west of
+# the Eastern and Pacific timezones.
+utc_fake = FixedOffset(-12*60, "UTCfake", 0)
+
+class TestTimezoneConversions(unittest.TestCase):
+ # The DST switch times for 2002, in std time.
+ dston = datetime(2002, 4, 7, 2)
+ dstoff = datetime(2002, 10, 27, 1)
+
+ theclass = datetime
+
+ # Check a time that's inside DST.
+ def checkinside(self, dt, tz, utc, dston, dstoff):
+ self.assertEqual(dt.dst(), HOUR)
+
+ # Conversion to our own timezone is always an identity.
+ self.assertEqual(dt.astimezone(tz), dt)
+
+ asutc = dt.astimezone(utc)
+ there_and_back = asutc.astimezone(tz)
+
+ # Conversion to UTC and back isn't always an identity here,
+ # because there are redundant spellings (in local time) of
+ # UTC time when DST begins: the clock jumps from 1:59:59
+ # to 3:00:00, and a local time of 2:MM:SS doesn't really
+ # make sense then. The classes above treat 2:MM:SS as
+ # daylight time then (it's "after 2am"), really an alias
+ # for 1:MM:SS standard time. The latter form is what
+ # conversion back from UTC produces.
+ if dt.date() == dston.date() and dt.hour == 2:
+ # We're in the redundant hour, and coming back from
+ # UTC gives the 1:MM:SS standard-time spelling.
+ self.assertEqual(there_and_back + HOUR, dt)
+ # Although during was considered to be in daylight
+ # time, there_and_back is not.
+ self.assertEqual(there_and_back.dst(), ZERO)
+ # They're the same times in UTC.
+ self.assertEqual(there_and_back.astimezone(utc),
+ dt.astimezone(utc))
+ else:
+ # We're not in the redundant hour.
+ self.assertEqual(dt, there_and_back)
+
+ # Because we have a redundant spelling when DST begins, there is
+ # (unfortunately) an hour when DST ends that can't be spelled at all in
+ # local time. When DST ends, the clock jumps from 1:59 back to 1:00
+ # again. The hour 1:MM DST has no spelling then: 1:MM is taken to be
+ # standard time. 1:MM DST == 0:MM EST, but 0:MM is taken to be
+ # daylight time. The hour 1:MM daylight == 0:MM standard can't be
+ # expressed in local time. Nevertheless, we want conversion back
+ # from UTC to mimic the local clock's "repeat an hour" behavior.
+ nexthour_utc = asutc + HOUR
+ nexthour_tz = nexthour_utc.astimezone(tz)
+ if dt.date() == dstoff.date() and dt.hour == 0:
+ # We're in the hour before the last DST hour. The last DST hour
+ # is ineffable. We want the conversion back to repeat 1:MM.
+ self.assertEqual(nexthour_tz, dt.replace(hour=1))
+ nexthour_utc += HOUR
+ nexthour_tz = nexthour_utc.astimezone(tz)
+ self.assertEqual(nexthour_tz, dt.replace(hour=1))
+ else:
+ self.assertEqual(nexthour_tz - dt, HOUR)
+
+ # Check a time that's outside DST.
+ def checkoutside(self, dt, tz, utc):
+ self.assertEqual(dt.dst(), ZERO)
+
+ # Conversion to our own timezone is always an identity.
+ self.assertEqual(dt.astimezone(tz), dt)
+
+ # Converting to UTC and back is an identity too.
+ asutc = dt.astimezone(utc)
+ there_and_back = asutc.astimezone(tz)
+ self.assertEqual(dt, there_and_back)
+
+ def convert_between_tz_and_utc(self, tz, utc):
+ dston = self.dston.replace(tzinfo=tz)
+ # Because 1:MM on the day DST ends is taken as being standard time,
+ # there is no spelling in tz for the last hour of daylight time.
+ # For purposes of the test, the last hour of DST is 0:MM, which is
+ # taken as being daylight time (and 1:MM is taken as being standard
+ # time).
+ dstoff = self.dstoff.replace(tzinfo=tz)
+ for delta in (timedelta(weeks=13),
+ DAY,
+ HOUR,
+ timedelta(minutes=1),
+ timedelta(microseconds=1)):
+
+ self.checkinside(dston, tz, utc, dston, dstoff)
+ for during in dston + delta, dstoff - delta:
+ self.checkinside(during, tz, utc, dston, dstoff)
+
+ self.checkoutside(dstoff, tz, utc)
+ for outside in dston - delta, dstoff + delta:
+ self.checkoutside(outside, tz, utc)
+
+ def test_easy(self):
+ # Despite the name of this test, the endcases are excruciating.
+ self.convert_between_tz_and_utc(Eastern, utc_real)
+ self.convert_between_tz_and_utc(Pacific, utc_real)
+ self.convert_between_tz_and_utc(Eastern, utc_fake)
+ self.convert_between_tz_and_utc(Pacific, utc_fake)
+ # The next is really dancing near the edge. It works because
+ # Pacific and Eastern are far enough apart that their "problem
+ # hours" don't overlap.
+ self.convert_between_tz_and_utc(Eastern, Pacific)
+ self.convert_between_tz_and_utc(Pacific, Eastern)
+ # OTOH, these fail! Don't enable them. The difficulty is that
+ # the edge case tests assume that every hour is representable in
+ # the "utc" class. This is always true for a fixed-offset tzinfo
+ # class (lke utc_real and utc_fake), but not for Eastern or Central.
+ # For these adjacent DST-aware time zones, the range of time offsets
+ # tested ends up creating hours in the one that aren't representable
+ # in the other. For the same reason, we would see failures in the
+ # Eastern vs Pacific tests too if we added 3*HOUR to the list of
+ # offset deltas in convert_between_tz_and_utc().
+ #
+ # self.convert_between_tz_and_utc(Eastern, Central) # can't work
+ # self.convert_between_tz_and_utc(Central, Eastern) # can't work
+
+ def test_tricky(self):
+ # 22:00 on day before daylight starts.
+ fourback = self.dston - timedelta(hours=4)
+ ninewest = FixedOffset(-9*60, "-0900", 0)
+ fourback = fourback.replace(tzinfo=ninewest)
+ # 22:00-0900 is 7:00 UTC == 2:00 EST == 3:00 DST. Since it's "after
+ # 2", we should get the 3 spelling.
+ # If we plug 22:00 the day before into Eastern, it "looks like std
+ # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4
+ # to 22:00 lands on 2:00, which makes no sense in local time (the
+ # local clock jumps from 1 to 3). The point here is to make sure we
+ # get the 3 spelling.
+ expected = self.dston.replace(hour=3)
+ got = fourback.astimezone(Eastern).replace(tzinfo=None)
+ self.assertEqual(expected, got)
+
+ # Similar, but map to 6:00 UTC == 1:00 EST == 2:00 DST. In that
+ # case we want the 1:00 spelling.
+ sixutc = self.dston.replace(hour=6, tzinfo=utc_real)
+ # Now 6:00 "looks like daylight", so the offset wrt Eastern is -4,
+ # and adding -4-0 == -4 gives the 2:00 spelling. We want the 1:00 EST
+ # spelling.
+ expected = self.dston.replace(hour=1)
+ got = sixutc.astimezone(Eastern).replace(tzinfo=None)
+ self.assertEqual(expected, got)
+
+ # Now on the day DST ends, we want "repeat an hour" behavior.
+ # UTC 4:MM 5:MM 6:MM 7:MM checking these
+ # EST 23:MM 0:MM 1:MM 2:MM
+ # EDT 0:MM 1:MM 2:MM 3:MM
+ # wall 0:MM 1:MM 1:MM 2:MM against these
+ for utc in utc_real, utc_fake:
+ for tz in Eastern, Pacific:
+ first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
+ # Convert that to UTC.
+ first_std_hour -= tz.utcoffset(None)
+ # Adjust for possibly fake UTC.
+ asutc = first_std_hour + utc.utcoffset(None)
+ # First UTC hour to convert; this is 4:00 when utc=utc_real &
+ # tz=Eastern.
+ asutcbase = asutc.replace(tzinfo=utc)
+ for tzhour in (0, 1, 1, 2):
+ expectedbase = self.dstoff.replace(hour=tzhour)
+ for minute in 0, 30, 59:
+ expected = expectedbase.replace(minute=minute)
+ asutc = asutcbase.replace(minute=minute)
+ astz = asutc.astimezone(tz)
+ self.assertEqual(astz.replace(tzinfo=None), expected)
+ asutcbase += HOUR
+
+
+ def test_bogus_dst(self):
+ class ok(tzinfo):
+ def utcoffset(self, dt): return HOUR
+ def dst(self, dt): return HOUR
+
+ now = self.theclass.now().replace(tzinfo=utc_real)
+ # Doesn't blow up.
+ now.astimezone(ok())
+
+ # Does blow up.
+ class notok(ok):
+ def dst(self, dt): return None
+ self.assertRaises(ValueError, now.astimezone, notok())
+
+ # Sometimes blow up. In the following, tzinfo.dst()
+ # implementation may return None or not None depending on
+ # whether DST is assumed to be in effect. In this situation,
+ # a ValueError should be raised by astimezone().
+ class tricky_notok(ok):
+ def dst(self, dt):
+ if dt.year == 2000:
+ return None
+ else:
+ return 10*HOUR
+ dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
+ self.assertRaises(ValueError, dt.astimezone, tricky_notok())
+
+ def test_fromutc(self):
+ self.assertRaises(TypeError, Eastern.fromutc) # not enough args
+ now = datetime.utcnow().replace(tzinfo=utc_real)
+ self.assertRaises(ValueError, Eastern.fromutc, now) # wrong tzinfo
+ now = now.replace(tzinfo=Eastern) # insert correct tzinfo
+ enow = Eastern.fromutc(now) # doesn't blow up
+ self.assertEqual(enow.tzinfo, Eastern) # has right tzinfo member
+ self.assertRaises(TypeError, Eastern.fromutc, now, now) # too many args
+ self.assertRaises(TypeError, Eastern.fromutc, date.today()) # wrong type
+
+ # Always converts UTC to standard time.
+ class FauxUSTimeZone(USTimeZone):
+ def fromutc(self, dt):
+ return dt + self.stdoffset
+ FEastern = FauxUSTimeZone(-5, "FEastern", "FEST", "FEDT")
+
+ # UTC 4:MM 5:MM 6:MM 7:MM 8:MM 9:MM
+ # EST 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM
+ # EDT 0:MM 1:MM 2:MM 3:MM 4:MM 5:MM
+
+ # Check around DST start.
+ start = self.dston.replace(hour=4, tzinfo=Eastern)
+ fstart = start.replace(tzinfo=FEastern)
+ for wall in 23, 0, 1, 3, 4, 5:
+ expected = start.replace(hour=wall)
+ if wall == 23:
+ expected -= timedelta(days=1)
+ got = Eastern.fromutc(start)
+ self.assertEqual(expected, got)
+
+ expected = fstart + FEastern.stdoffset
+ got = FEastern.fromutc(fstart)
+ self.assertEqual(expected, got)
+
+ # Ensure astimezone() calls fromutc() too.
+ got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
+ self.assertEqual(expected, got)
+
+ start += HOUR
+ fstart += HOUR
+
+ # Check around DST end.
+ start = self.dstoff.replace(hour=4, tzinfo=Eastern)
+ fstart = start.replace(tzinfo=FEastern)
+ for wall in 0, 1, 1, 2, 3, 4:
+ expected = start.replace(hour=wall)
+ got = Eastern.fromutc(start)
+ self.assertEqual(expected, got)
+
+ expected = fstart + FEastern.stdoffset
+ got = FEastern.fromutc(fstart)
+ self.assertEqual(expected, got)
+
+ # Ensure astimezone() calls fromutc() too.
+ got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
+ self.assertEqual(expected, got)
+
+ start += HOUR
+ fstart += HOUR
+
+
+#############################################################################
+# oddballs
+
+class Oddballs(unittest.TestCase):
+
+ def test_bug_1028306(self):
+ # Trying to compare a date to a datetime should act like a mixed-
+ # type comparison, despite that datetime is a subclass of date.
+ as_date = date.today()
+ as_datetime = datetime.combine(as_date, time())
+ self.assertTrue(as_date != as_datetime)
+ self.assertTrue(as_datetime != as_date)
+ self.assertTrue(not as_date == as_datetime)
+ self.assertTrue(not as_datetime == as_date)
+ self.assertRaises(TypeError, lambda: as_date < as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime < as_date)
+ self.assertRaises(TypeError, lambda: as_date <= as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime <= as_date)
+ self.assertRaises(TypeError, lambda: as_date > as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime > as_date)
+ self.assertRaises(TypeError, lambda: as_date >= as_datetime)
+ self.assertRaises(TypeError, lambda: as_datetime >= as_date)
+
+ # Neverthelss, comparison should work with the base-class (date)
+ # projection if use of a date method is forced.
+ self.assertEqual(as_date.__eq__(as_datetime), True)
+ different_day = (as_date.day + 1) % 20 + 1
+ as_different = as_datetime.replace(day= different_day)
+ self.assertEqual(as_date.__eq__(as_different), False)
+
+ # And date should compare with other subclasses of date. If a
+ # subclass wants to stop this, it's up to the subclass to do so.
+ date_sc = SubclassDate(as_date.year, as_date.month, as_date.day)
+ self.assertEqual(as_date, date_sc)
+ self.assertEqual(date_sc, as_date)
+
+ # Ditto for datetimes.
+ datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month,
+ as_date.day, 0, 0, 0)
+ self.assertEqual(as_datetime, datetime_sc)
+ self.assertEqual(datetime_sc, as_datetime)
+
+def test_main():
+ support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/decimaltestdata/and.decTest b/Lib/test/decimaltestdata/and.decTest
index a0cc7865164..e912394877e 100644
--- a/Lib/test/decimaltestdata/and.decTest
+++ b/Lib/test/decimaltestdata/and.decTest
@@ -1,338 +1,338 @@
-------------------------------------------------------------------------
--- and.decTest -- digitwise logical AND --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-andx001 and 0 0 -> 0
-andx002 and 0 1 -> 0
-andx003 and 1 0 -> 0
-andx004 and 1 1 -> 1
-andx005 and 1100 1010 -> 1000
-andx006 and 1111 10 -> 10
-andx007 and 1111 1010 -> 1010
-
--- and at msd and msd-1
-andx010 and 000000000 000000000 -> 0
-andx011 and 000000000 100000000 -> 0
-andx012 and 100000000 000000000 -> 0
-andx013 and 100000000 100000000 -> 100000000
-andx014 and 000000000 000000000 -> 0
-andx015 and 000000000 010000000 -> 0
-andx016 and 010000000 000000000 -> 0
-andx017 and 010000000 010000000 -> 10000000
-
--- Various lengths
--- 123456789 123456789 123456789
-andx021 and 111111111 111111111 -> 111111111
-andx022 and 111111111111 111111111 -> 111111111
-andx023 and 111111111111 11111111 -> 11111111
-andx024 and 111111111 11111111 -> 11111111
-andx025 and 111111111 1111111 -> 1111111
-andx026 and 111111111111 111111 -> 111111
-andx027 and 111111111111 11111 -> 11111
-andx028 and 111111111111 1111 -> 1111
-andx029 and 111111111111 111 -> 111
-andx031 and 111111111111 11 -> 11
-andx032 and 111111111111 1 -> 1
-andx033 and 111111111111 1111111111 -> 111111111
-andx034 and 11111111111 11111111111 -> 111111111
-andx035 and 1111111111 111111111111 -> 111111111
-andx036 and 111111111 1111111111111 -> 111111111
-
-andx040 and 111111111 111111111111 -> 111111111
-andx041 and 11111111 111111111111 -> 11111111
-andx042 and 11111111 111111111 -> 11111111
-andx043 and 1111111 111111111 -> 1111111
-andx044 and 111111 111111111 -> 111111
-andx045 and 11111 111111111 -> 11111
-andx046 and 1111 111111111 -> 1111
-andx047 and 111 111111111 -> 111
-andx048 and 11 111111111 -> 11
-andx049 and 1 111111111 -> 1
-
-andx050 and 1111111111 1 -> 1
-andx051 and 111111111 1 -> 1
-andx052 and 11111111 1 -> 1
-andx053 and 1111111 1 -> 1
-andx054 and 111111 1 -> 1
-andx055 and 11111 1 -> 1
-andx056 and 1111 1 -> 1
-andx057 and 111 1 -> 1
-andx058 and 11 1 -> 1
-andx059 and 1 1 -> 1
-
-andx060 and 1111111111 0 -> 0
-andx061 and 111111111 0 -> 0
-andx062 and 11111111 0 -> 0
-andx063 and 1111111 0 -> 0
-andx064 and 111111 0 -> 0
-andx065 and 11111 0 -> 0
-andx066 and 1111 0 -> 0
-andx067 and 111 0 -> 0
-andx068 and 11 0 -> 0
-andx069 and 1 0 -> 0
-
-andx070 and 1 1111111111 -> 1
-andx071 and 1 111111111 -> 1
-andx072 and 1 11111111 -> 1
-andx073 and 1 1111111 -> 1
-andx074 and 1 111111 -> 1
-andx075 and 1 11111 -> 1
-andx076 and 1 1111 -> 1
-andx077 and 1 111 -> 1
-andx078 and 1 11 -> 1
-andx079 and 1 1 -> 1
-
-andx080 and 0 1111111111 -> 0
-andx081 and 0 111111111 -> 0
-andx082 and 0 11111111 -> 0
-andx083 and 0 1111111 -> 0
-andx084 and 0 111111 -> 0
-andx085 and 0 11111 -> 0
-andx086 and 0 1111 -> 0
-andx087 and 0 111 -> 0
-andx088 and 0 11 -> 0
-andx089 and 0 1 -> 0
-
-andx090 and 011111111 111111111 -> 11111111
-andx091 and 101111111 111111111 -> 101111111
-andx092 and 110111111 111111111 -> 110111111
-andx093 and 111011111 111111111 -> 111011111
-andx094 and 111101111 111111111 -> 111101111
-andx095 and 111110111 111111111 -> 111110111
-andx096 and 111111011 111111111 -> 111111011
-andx097 and 111111101 111111111 -> 111111101
-andx098 and 111111110 111111111 -> 111111110
-
-andx100 and 111111111 011111111 -> 11111111
-andx101 and 111111111 101111111 -> 101111111
-andx102 and 111111111 110111111 -> 110111111
-andx103 and 111111111 111011111 -> 111011111
-andx104 and 111111111 111101111 -> 111101111
-andx105 and 111111111 111110111 -> 111110111
-andx106 and 111111111 111111011 -> 111111011
-andx107 and 111111111 111111101 -> 111111101
-andx108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-andx220 and 111111112 111111111 -> NaN Invalid_operation
-andx221 and 333333333 333333333 -> NaN Invalid_operation
-andx222 and 555555555 555555555 -> NaN Invalid_operation
-andx223 and 777777777 777777777 -> NaN Invalid_operation
-andx224 and 999999999 999999999 -> NaN Invalid_operation
-andx225 and 222222222 999999999 -> NaN Invalid_operation
-andx226 and 444444444 999999999 -> NaN Invalid_operation
-andx227 and 666666666 999999999 -> NaN Invalid_operation
-andx228 and 888888888 999999999 -> NaN Invalid_operation
-andx229 and 999999999 222222222 -> NaN Invalid_operation
-andx230 and 999999999 444444444 -> NaN Invalid_operation
-andx231 and 999999999 666666666 -> NaN Invalid_operation
-andx232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-andx240 and 567468689 -934981942 -> NaN Invalid_operation
-andx241 and 567367689 934981942 -> NaN Invalid_operation
-andx242 and -631917772 -706014634 -> NaN Invalid_operation
-andx243 and -756253257 138579234 -> NaN Invalid_operation
-andx244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-andx250 and 200000000 100000000 -> NaN Invalid_operation
-andx251 and 700000000 100000000 -> NaN Invalid_operation
-andx252 and 800000000 100000000 -> NaN Invalid_operation
-andx253 and 900000000 100000000 -> NaN Invalid_operation
-andx254 and 200000000 000000000 -> NaN Invalid_operation
-andx255 and 700000000 000000000 -> NaN Invalid_operation
-andx256 and 800000000 000000000 -> NaN Invalid_operation
-andx257 and 900000000 000000000 -> NaN Invalid_operation
-andx258 and 100000000 200000000 -> NaN Invalid_operation
-andx259 and 100000000 700000000 -> NaN Invalid_operation
-andx260 and 100000000 800000000 -> NaN Invalid_operation
-andx261 and 100000000 900000000 -> NaN Invalid_operation
-andx262 and 000000000 200000000 -> NaN Invalid_operation
-andx263 and 000000000 700000000 -> NaN Invalid_operation
-andx264 and 000000000 800000000 -> NaN Invalid_operation
-andx265 and 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-andx270 and 020000000 100000000 -> NaN Invalid_operation
-andx271 and 070100000 100000000 -> NaN Invalid_operation
-andx272 and 080010000 100000001 -> NaN Invalid_operation
-andx273 and 090001000 100000010 -> NaN Invalid_operation
-andx274 and 100000100 020010100 -> NaN Invalid_operation
-andx275 and 100000000 070001000 -> NaN Invalid_operation
-andx276 and 100000010 080010100 -> NaN Invalid_operation
-andx277 and 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-andx280 and 001000002 100000000 -> NaN Invalid_operation
-andx281 and 000000007 100000000 -> NaN Invalid_operation
-andx282 and 000000008 100000000 -> NaN Invalid_operation
-andx283 and 000000009 100000000 -> NaN Invalid_operation
-andx284 and 100000000 000100002 -> NaN Invalid_operation
-andx285 and 100100000 001000007 -> NaN Invalid_operation
-andx286 and 100010000 010000008 -> NaN Invalid_operation
-andx287 and 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-andx288 and 001020000 100000000 -> NaN Invalid_operation
-andx289 and 000070001 100000000 -> NaN Invalid_operation
-andx290 and 000080000 100010000 -> NaN Invalid_operation
-andx291 and 000090000 100001000 -> NaN Invalid_operation
-andx292 and 100000010 000020100 -> NaN Invalid_operation
-andx293 and 100100000 000070010 -> NaN Invalid_operation
-andx294 and 100010100 000080001 -> NaN Invalid_operation
-andx295 and 100001000 000090000 -> NaN Invalid_operation
--- signs
-andx296 and -100001000 -000000000 -> NaN Invalid_operation
-andx297 and -100001000 000010000 -> NaN Invalid_operation
-andx298 and 100001000 -000000000 -> NaN Invalid_operation
-andx299 and 100001000 000011000 -> 1000
-
--- Nmax, Nmin, Ntiny
-andx331 and 2 9.99999999E+999 -> NaN Invalid_operation
-andx332 and 3 1E-999 -> NaN Invalid_operation
-andx333 and 4 1.00000000E-999 -> NaN Invalid_operation
-andx334 and 5 1E-1007 -> NaN Invalid_operation
-andx335 and 6 -1E-1007 -> NaN Invalid_operation
-andx336 and 7 -1.00000000E-999 -> NaN Invalid_operation
-andx337 and 8 -1E-999 -> NaN Invalid_operation
-andx338 and 9 -9.99999999E+999 -> NaN Invalid_operation
-andx341 and 9.99999999E+999 -18 -> NaN Invalid_operation
-andx342 and 1E-999 01 -> NaN Invalid_operation
-andx343 and 1.00000000E-999 -18 -> NaN Invalid_operation
-andx344 and 1E-1007 18 -> NaN Invalid_operation
-andx345 and -1E-1007 -10 -> NaN Invalid_operation
-andx346 and -1.00000000E-999 18 -> NaN Invalid_operation
-andx347 and -1E-999 10 -> NaN Invalid_operation
-andx348 and -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-andx361 and 1.0 1 -> NaN Invalid_operation
-andx362 and 1E+1 1 -> NaN Invalid_operation
-andx363 and 0.0 1 -> NaN Invalid_operation
-andx364 and 0E+1 1 -> NaN Invalid_operation
-andx365 and 9.9 1 -> NaN Invalid_operation
-andx366 and 9E+1 1 -> NaN Invalid_operation
-andx371 and 0 1.0 -> NaN Invalid_operation
-andx372 and 0 1E+1 -> NaN Invalid_operation
-andx373 and 0 0.0 -> NaN Invalid_operation
-andx374 and 0 0E+1 -> NaN Invalid_operation
-andx375 and 0 9.9 -> NaN Invalid_operation
-andx376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-andx780 and -Inf -Inf -> NaN Invalid_operation
-andx781 and -Inf -1000 -> NaN Invalid_operation
-andx782 and -Inf -1 -> NaN Invalid_operation
-andx783 and -Inf -0 -> NaN Invalid_operation
-andx784 and -Inf 0 -> NaN Invalid_operation
-andx785 and -Inf 1 -> NaN Invalid_operation
-andx786 and -Inf 1000 -> NaN Invalid_operation
-andx787 and -1000 -Inf -> NaN Invalid_operation
-andx788 and -Inf -Inf -> NaN Invalid_operation
-andx789 and -1 -Inf -> NaN Invalid_operation
-andx790 and -0 -Inf -> NaN Invalid_operation
-andx791 and 0 -Inf -> NaN Invalid_operation
-andx792 and 1 -Inf -> NaN Invalid_operation
-andx793 and 1000 -Inf -> NaN Invalid_operation
-andx794 and Inf -Inf -> NaN Invalid_operation
-
-andx800 and Inf -Inf -> NaN Invalid_operation
-andx801 and Inf -1000 -> NaN Invalid_operation
-andx802 and Inf -1 -> NaN Invalid_operation
-andx803 and Inf -0 -> NaN Invalid_operation
-andx804 and Inf 0 -> NaN Invalid_operation
-andx805 and Inf 1 -> NaN Invalid_operation
-andx806 and Inf 1000 -> NaN Invalid_operation
-andx807 and Inf Inf -> NaN Invalid_operation
-andx808 and -1000 Inf -> NaN Invalid_operation
-andx809 and -Inf Inf -> NaN Invalid_operation
-andx810 and -1 Inf -> NaN Invalid_operation
-andx811 and -0 Inf -> NaN Invalid_operation
-andx812 and 0 Inf -> NaN Invalid_operation
-andx813 and 1 Inf -> NaN Invalid_operation
-andx814 and 1000 Inf -> NaN Invalid_operation
-andx815 and Inf Inf -> NaN Invalid_operation
-
-andx821 and NaN -Inf -> NaN Invalid_operation
-andx822 and NaN -1000 -> NaN Invalid_operation
-andx823 and NaN -1 -> NaN Invalid_operation
-andx824 and NaN -0 -> NaN Invalid_operation
-andx825 and NaN 0 -> NaN Invalid_operation
-andx826 and NaN 1 -> NaN Invalid_operation
-andx827 and NaN 1000 -> NaN Invalid_operation
-andx828 and NaN Inf -> NaN Invalid_operation
-andx829 and NaN NaN -> NaN Invalid_operation
-andx830 and -Inf NaN -> NaN Invalid_operation
-andx831 and -1000 NaN -> NaN Invalid_operation
-andx832 and -1 NaN -> NaN Invalid_operation
-andx833 and -0 NaN -> NaN Invalid_operation
-andx834 and 0 NaN -> NaN Invalid_operation
-andx835 and 1 NaN -> NaN Invalid_operation
-andx836 and 1000 NaN -> NaN Invalid_operation
-andx837 and Inf NaN -> NaN Invalid_operation
-
-andx841 and sNaN -Inf -> NaN Invalid_operation
-andx842 and sNaN -1000 -> NaN Invalid_operation
-andx843 and sNaN -1 -> NaN Invalid_operation
-andx844 and sNaN -0 -> NaN Invalid_operation
-andx845 and sNaN 0 -> NaN Invalid_operation
-andx846 and sNaN 1 -> NaN Invalid_operation
-andx847 and sNaN 1000 -> NaN Invalid_operation
-andx848 and sNaN NaN -> NaN Invalid_operation
-andx849 and sNaN sNaN -> NaN Invalid_operation
-andx850 and NaN sNaN -> NaN Invalid_operation
-andx851 and -Inf sNaN -> NaN Invalid_operation
-andx852 and -1000 sNaN -> NaN Invalid_operation
-andx853 and -1 sNaN -> NaN Invalid_operation
-andx854 and -0 sNaN -> NaN Invalid_operation
-andx855 and 0 sNaN -> NaN Invalid_operation
-andx856 and 1 sNaN -> NaN Invalid_operation
-andx857 and 1000 sNaN -> NaN Invalid_operation
-andx858 and Inf sNaN -> NaN Invalid_operation
-andx859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-andx861 and NaN1 -Inf -> NaN Invalid_operation
-andx862 and +NaN2 -1000 -> NaN Invalid_operation
-andx863 and NaN3 1000 -> NaN Invalid_operation
-andx864 and NaN4 Inf -> NaN Invalid_operation
-andx865 and NaN5 +NaN6 -> NaN Invalid_operation
-andx866 and -Inf NaN7 -> NaN Invalid_operation
-andx867 and -1000 NaN8 -> NaN Invalid_operation
-andx868 and 1000 NaN9 -> NaN Invalid_operation
-andx869 and Inf +NaN10 -> NaN Invalid_operation
-andx871 and sNaN11 -Inf -> NaN Invalid_operation
-andx872 and sNaN12 -1000 -> NaN Invalid_operation
-andx873 and sNaN13 1000 -> NaN Invalid_operation
-andx874 and sNaN14 NaN17 -> NaN Invalid_operation
-andx875 and sNaN15 sNaN18 -> NaN Invalid_operation
-andx876 and NaN16 sNaN19 -> NaN Invalid_operation
-andx877 and -Inf +sNaN20 -> NaN Invalid_operation
-andx878 and -1000 sNaN21 -> NaN Invalid_operation
-andx879 and 1000 sNaN22 -> NaN Invalid_operation
-andx880 and Inf sNaN23 -> NaN Invalid_operation
-andx881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-andx882 and -NaN26 NaN28 -> NaN Invalid_operation
-andx883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-andx884 and 1000 -NaN30 -> NaN Invalid_operation
-andx885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- and.decTest -- digitwise logical AND --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+andx001 and 0 0 -> 0
+andx002 and 0 1 -> 0
+andx003 and 1 0 -> 0
+andx004 and 1 1 -> 1
+andx005 and 1100 1010 -> 1000
+andx006 and 1111 10 -> 10
+andx007 and 1111 1010 -> 1010
+
+-- and at msd and msd-1
+andx010 and 000000000 000000000 -> 0
+andx011 and 000000000 100000000 -> 0
+andx012 and 100000000 000000000 -> 0
+andx013 and 100000000 100000000 -> 100000000
+andx014 and 000000000 000000000 -> 0
+andx015 and 000000000 010000000 -> 0
+andx016 and 010000000 000000000 -> 0
+andx017 and 010000000 010000000 -> 10000000
+
+-- Various lengths
+-- 123456789 123456789 123456789
+andx021 and 111111111 111111111 -> 111111111
+andx022 and 111111111111 111111111 -> 111111111
+andx023 and 111111111111 11111111 -> 11111111
+andx024 and 111111111 11111111 -> 11111111
+andx025 and 111111111 1111111 -> 1111111
+andx026 and 111111111111 111111 -> 111111
+andx027 and 111111111111 11111 -> 11111
+andx028 and 111111111111 1111 -> 1111
+andx029 and 111111111111 111 -> 111
+andx031 and 111111111111 11 -> 11
+andx032 and 111111111111 1 -> 1
+andx033 and 111111111111 1111111111 -> 111111111
+andx034 and 11111111111 11111111111 -> 111111111
+andx035 and 1111111111 111111111111 -> 111111111
+andx036 and 111111111 1111111111111 -> 111111111
+
+andx040 and 111111111 111111111111 -> 111111111
+andx041 and 11111111 111111111111 -> 11111111
+andx042 and 11111111 111111111 -> 11111111
+andx043 and 1111111 111111111 -> 1111111
+andx044 and 111111 111111111 -> 111111
+andx045 and 11111 111111111 -> 11111
+andx046 and 1111 111111111 -> 1111
+andx047 and 111 111111111 -> 111
+andx048 and 11 111111111 -> 11
+andx049 and 1 111111111 -> 1
+
+andx050 and 1111111111 1 -> 1
+andx051 and 111111111 1 -> 1
+andx052 and 11111111 1 -> 1
+andx053 and 1111111 1 -> 1
+andx054 and 111111 1 -> 1
+andx055 and 11111 1 -> 1
+andx056 and 1111 1 -> 1
+andx057 and 111 1 -> 1
+andx058 and 11 1 -> 1
+andx059 and 1 1 -> 1
+
+andx060 and 1111111111 0 -> 0
+andx061 and 111111111 0 -> 0
+andx062 and 11111111 0 -> 0
+andx063 and 1111111 0 -> 0
+andx064 and 111111 0 -> 0
+andx065 and 11111 0 -> 0
+andx066 and 1111 0 -> 0
+andx067 and 111 0 -> 0
+andx068 and 11 0 -> 0
+andx069 and 1 0 -> 0
+
+andx070 and 1 1111111111 -> 1
+andx071 and 1 111111111 -> 1
+andx072 and 1 11111111 -> 1
+andx073 and 1 1111111 -> 1
+andx074 and 1 111111 -> 1
+andx075 and 1 11111 -> 1
+andx076 and 1 1111 -> 1
+andx077 and 1 111 -> 1
+andx078 and 1 11 -> 1
+andx079 and 1 1 -> 1
+
+andx080 and 0 1111111111 -> 0
+andx081 and 0 111111111 -> 0
+andx082 and 0 11111111 -> 0
+andx083 and 0 1111111 -> 0
+andx084 and 0 111111 -> 0
+andx085 and 0 11111 -> 0
+andx086 and 0 1111 -> 0
+andx087 and 0 111 -> 0
+andx088 and 0 11 -> 0
+andx089 and 0 1 -> 0
+
+andx090 and 011111111 111111111 -> 11111111
+andx091 and 101111111 111111111 -> 101111111
+andx092 and 110111111 111111111 -> 110111111
+andx093 and 111011111 111111111 -> 111011111
+andx094 and 111101111 111111111 -> 111101111
+andx095 and 111110111 111111111 -> 111110111
+andx096 and 111111011 111111111 -> 111111011
+andx097 and 111111101 111111111 -> 111111101
+andx098 and 111111110 111111111 -> 111111110
+
+andx100 and 111111111 011111111 -> 11111111
+andx101 and 111111111 101111111 -> 101111111
+andx102 and 111111111 110111111 -> 110111111
+andx103 and 111111111 111011111 -> 111011111
+andx104 and 111111111 111101111 -> 111101111
+andx105 and 111111111 111110111 -> 111110111
+andx106 and 111111111 111111011 -> 111111011
+andx107 and 111111111 111111101 -> 111111101
+andx108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+andx220 and 111111112 111111111 -> NaN Invalid_operation
+andx221 and 333333333 333333333 -> NaN Invalid_operation
+andx222 and 555555555 555555555 -> NaN Invalid_operation
+andx223 and 777777777 777777777 -> NaN Invalid_operation
+andx224 and 999999999 999999999 -> NaN Invalid_operation
+andx225 and 222222222 999999999 -> NaN Invalid_operation
+andx226 and 444444444 999999999 -> NaN Invalid_operation
+andx227 and 666666666 999999999 -> NaN Invalid_operation
+andx228 and 888888888 999999999 -> NaN Invalid_operation
+andx229 and 999999999 222222222 -> NaN Invalid_operation
+andx230 and 999999999 444444444 -> NaN Invalid_operation
+andx231 and 999999999 666666666 -> NaN Invalid_operation
+andx232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+andx240 and 567468689 -934981942 -> NaN Invalid_operation
+andx241 and 567367689 934981942 -> NaN Invalid_operation
+andx242 and -631917772 -706014634 -> NaN Invalid_operation
+andx243 and -756253257 138579234 -> NaN Invalid_operation
+andx244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+andx250 and 200000000 100000000 -> NaN Invalid_operation
+andx251 and 700000000 100000000 -> NaN Invalid_operation
+andx252 and 800000000 100000000 -> NaN Invalid_operation
+andx253 and 900000000 100000000 -> NaN Invalid_operation
+andx254 and 200000000 000000000 -> NaN Invalid_operation
+andx255 and 700000000 000000000 -> NaN Invalid_operation
+andx256 and 800000000 000000000 -> NaN Invalid_operation
+andx257 and 900000000 000000000 -> NaN Invalid_operation
+andx258 and 100000000 200000000 -> NaN Invalid_operation
+andx259 and 100000000 700000000 -> NaN Invalid_operation
+andx260 and 100000000 800000000 -> NaN Invalid_operation
+andx261 and 100000000 900000000 -> NaN Invalid_operation
+andx262 and 000000000 200000000 -> NaN Invalid_operation
+andx263 and 000000000 700000000 -> NaN Invalid_operation
+andx264 and 000000000 800000000 -> NaN Invalid_operation
+andx265 and 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+andx270 and 020000000 100000000 -> NaN Invalid_operation
+andx271 and 070100000 100000000 -> NaN Invalid_operation
+andx272 and 080010000 100000001 -> NaN Invalid_operation
+andx273 and 090001000 100000010 -> NaN Invalid_operation
+andx274 and 100000100 020010100 -> NaN Invalid_operation
+andx275 and 100000000 070001000 -> NaN Invalid_operation
+andx276 and 100000010 080010100 -> NaN Invalid_operation
+andx277 and 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+andx280 and 001000002 100000000 -> NaN Invalid_operation
+andx281 and 000000007 100000000 -> NaN Invalid_operation
+andx282 and 000000008 100000000 -> NaN Invalid_operation
+andx283 and 000000009 100000000 -> NaN Invalid_operation
+andx284 and 100000000 000100002 -> NaN Invalid_operation
+andx285 and 100100000 001000007 -> NaN Invalid_operation
+andx286 and 100010000 010000008 -> NaN Invalid_operation
+andx287 and 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+andx288 and 001020000 100000000 -> NaN Invalid_operation
+andx289 and 000070001 100000000 -> NaN Invalid_operation
+andx290 and 000080000 100010000 -> NaN Invalid_operation
+andx291 and 000090000 100001000 -> NaN Invalid_operation
+andx292 and 100000010 000020100 -> NaN Invalid_operation
+andx293 and 100100000 000070010 -> NaN Invalid_operation
+andx294 and 100010100 000080001 -> NaN Invalid_operation
+andx295 and 100001000 000090000 -> NaN Invalid_operation
+-- signs
+andx296 and -100001000 -000000000 -> NaN Invalid_operation
+andx297 and -100001000 000010000 -> NaN Invalid_operation
+andx298 and 100001000 -000000000 -> NaN Invalid_operation
+andx299 and 100001000 000011000 -> 1000
+
+-- Nmax, Nmin, Ntiny
+andx331 and 2 9.99999999E+999 -> NaN Invalid_operation
+andx332 and 3 1E-999 -> NaN Invalid_operation
+andx333 and 4 1.00000000E-999 -> NaN Invalid_operation
+andx334 and 5 1E-1007 -> NaN Invalid_operation
+andx335 and 6 -1E-1007 -> NaN Invalid_operation
+andx336 and 7 -1.00000000E-999 -> NaN Invalid_operation
+andx337 and 8 -1E-999 -> NaN Invalid_operation
+andx338 and 9 -9.99999999E+999 -> NaN Invalid_operation
+andx341 and 9.99999999E+999 -18 -> NaN Invalid_operation
+andx342 and 1E-999 01 -> NaN Invalid_operation
+andx343 and 1.00000000E-999 -18 -> NaN Invalid_operation
+andx344 and 1E-1007 18 -> NaN Invalid_operation
+andx345 and -1E-1007 -10 -> NaN Invalid_operation
+andx346 and -1.00000000E-999 18 -> NaN Invalid_operation
+andx347 and -1E-999 10 -> NaN Invalid_operation
+andx348 and -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+andx361 and 1.0 1 -> NaN Invalid_operation
+andx362 and 1E+1 1 -> NaN Invalid_operation
+andx363 and 0.0 1 -> NaN Invalid_operation
+andx364 and 0E+1 1 -> NaN Invalid_operation
+andx365 and 9.9 1 -> NaN Invalid_operation
+andx366 and 9E+1 1 -> NaN Invalid_operation
+andx371 and 0 1.0 -> NaN Invalid_operation
+andx372 and 0 1E+1 -> NaN Invalid_operation
+andx373 and 0 0.0 -> NaN Invalid_operation
+andx374 and 0 0E+1 -> NaN Invalid_operation
+andx375 and 0 9.9 -> NaN Invalid_operation
+andx376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+andx780 and -Inf -Inf -> NaN Invalid_operation
+andx781 and -Inf -1000 -> NaN Invalid_operation
+andx782 and -Inf -1 -> NaN Invalid_operation
+andx783 and -Inf -0 -> NaN Invalid_operation
+andx784 and -Inf 0 -> NaN Invalid_operation
+andx785 and -Inf 1 -> NaN Invalid_operation
+andx786 and -Inf 1000 -> NaN Invalid_operation
+andx787 and -1000 -Inf -> NaN Invalid_operation
+andx788 and -Inf -Inf -> NaN Invalid_operation
+andx789 and -1 -Inf -> NaN Invalid_operation
+andx790 and -0 -Inf -> NaN Invalid_operation
+andx791 and 0 -Inf -> NaN Invalid_operation
+andx792 and 1 -Inf -> NaN Invalid_operation
+andx793 and 1000 -Inf -> NaN Invalid_operation
+andx794 and Inf -Inf -> NaN Invalid_operation
+
+andx800 and Inf -Inf -> NaN Invalid_operation
+andx801 and Inf -1000 -> NaN Invalid_operation
+andx802 and Inf -1 -> NaN Invalid_operation
+andx803 and Inf -0 -> NaN Invalid_operation
+andx804 and Inf 0 -> NaN Invalid_operation
+andx805 and Inf 1 -> NaN Invalid_operation
+andx806 and Inf 1000 -> NaN Invalid_operation
+andx807 and Inf Inf -> NaN Invalid_operation
+andx808 and -1000 Inf -> NaN Invalid_operation
+andx809 and -Inf Inf -> NaN Invalid_operation
+andx810 and -1 Inf -> NaN Invalid_operation
+andx811 and -0 Inf -> NaN Invalid_operation
+andx812 and 0 Inf -> NaN Invalid_operation
+andx813 and 1 Inf -> NaN Invalid_operation
+andx814 and 1000 Inf -> NaN Invalid_operation
+andx815 and Inf Inf -> NaN Invalid_operation
+
+andx821 and NaN -Inf -> NaN Invalid_operation
+andx822 and NaN -1000 -> NaN Invalid_operation
+andx823 and NaN -1 -> NaN Invalid_operation
+andx824 and NaN -0 -> NaN Invalid_operation
+andx825 and NaN 0 -> NaN Invalid_operation
+andx826 and NaN 1 -> NaN Invalid_operation
+andx827 and NaN 1000 -> NaN Invalid_operation
+andx828 and NaN Inf -> NaN Invalid_operation
+andx829 and NaN NaN -> NaN Invalid_operation
+andx830 and -Inf NaN -> NaN Invalid_operation
+andx831 and -1000 NaN -> NaN Invalid_operation
+andx832 and -1 NaN -> NaN Invalid_operation
+andx833 and -0 NaN -> NaN Invalid_operation
+andx834 and 0 NaN -> NaN Invalid_operation
+andx835 and 1 NaN -> NaN Invalid_operation
+andx836 and 1000 NaN -> NaN Invalid_operation
+andx837 and Inf NaN -> NaN Invalid_operation
+
+andx841 and sNaN -Inf -> NaN Invalid_operation
+andx842 and sNaN -1000 -> NaN Invalid_operation
+andx843 and sNaN -1 -> NaN Invalid_operation
+andx844 and sNaN -0 -> NaN Invalid_operation
+andx845 and sNaN 0 -> NaN Invalid_operation
+andx846 and sNaN 1 -> NaN Invalid_operation
+andx847 and sNaN 1000 -> NaN Invalid_operation
+andx848 and sNaN NaN -> NaN Invalid_operation
+andx849 and sNaN sNaN -> NaN Invalid_operation
+andx850 and NaN sNaN -> NaN Invalid_operation
+andx851 and -Inf sNaN -> NaN Invalid_operation
+andx852 and -1000 sNaN -> NaN Invalid_operation
+andx853 and -1 sNaN -> NaN Invalid_operation
+andx854 and -0 sNaN -> NaN Invalid_operation
+andx855 and 0 sNaN -> NaN Invalid_operation
+andx856 and 1 sNaN -> NaN Invalid_operation
+andx857 and 1000 sNaN -> NaN Invalid_operation
+andx858 and Inf sNaN -> NaN Invalid_operation
+andx859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+andx861 and NaN1 -Inf -> NaN Invalid_operation
+andx862 and +NaN2 -1000 -> NaN Invalid_operation
+andx863 and NaN3 1000 -> NaN Invalid_operation
+andx864 and NaN4 Inf -> NaN Invalid_operation
+andx865 and NaN5 +NaN6 -> NaN Invalid_operation
+andx866 and -Inf NaN7 -> NaN Invalid_operation
+andx867 and -1000 NaN8 -> NaN Invalid_operation
+andx868 and 1000 NaN9 -> NaN Invalid_operation
+andx869 and Inf +NaN10 -> NaN Invalid_operation
+andx871 and sNaN11 -Inf -> NaN Invalid_operation
+andx872 and sNaN12 -1000 -> NaN Invalid_operation
+andx873 and sNaN13 1000 -> NaN Invalid_operation
+andx874 and sNaN14 NaN17 -> NaN Invalid_operation
+andx875 and sNaN15 sNaN18 -> NaN Invalid_operation
+andx876 and NaN16 sNaN19 -> NaN Invalid_operation
+andx877 and -Inf +sNaN20 -> NaN Invalid_operation
+andx878 and -1000 sNaN21 -> NaN Invalid_operation
+andx879 and 1000 sNaN22 -> NaN Invalid_operation
+andx880 and Inf sNaN23 -> NaN Invalid_operation
+andx881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+andx882 and -NaN26 NaN28 -> NaN Invalid_operation
+andx883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+andx884 and 1000 -NaN30 -> NaN Invalid_operation
+andx885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/class.decTest b/Lib/test/decimaltestdata/class.decTest
index fa5bc3a12f0..62d2fa472f1 100644
--- a/Lib/test/decimaltestdata/class.decTest
+++ b/Lib/test/decimaltestdata/class.decTest
@@ -1,131 +1,131 @@
-------------------------------------------------------------------------
--- class.decTest -- Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-
-precision: 9
-maxExponent: 999
-minExponent: -999
-extended: 1
-clamp: 1
-rounding: half_even
-
-clasx001 class 0 -> +Zero
-clasx002 class 0.00 -> +Zero
-clasx003 class 0E+5 -> +Zero
-clasx004 class 1E-1007 -> +Subnormal
-clasx005 class 0.1E-999 -> +Subnormal
-clasx006 class 0.99999999E-999 -> +Subnormal
-clasx007 class 1.00000000E-999 -> +Normal
-clasx008 class 1E-999 -> +Normal
-clasx009 class 1E-100 -> +Normal
-clasx010 class 1E-10 -> +Normal
-clasx012 class 1E-1 -> +Normal
-clasx013 class 1 -> +Normal
-clasx014 class 2.50 -> +Normal
-clasx015 class 100.100 -> +Normal
-clasx016 class 1E+30 -> +Normal
-clasx017 class 1E+999 -> +Normal
-clasx018 class 9.99999999E+999 -> +Normal
-clasx019 class Inf -> +Infinity
-
-clasx021 class -0 -> -Zero
-clasx022 class -0.00 -> -Zero
-clasx023 class -0E+5 -> -Zero
-clasx024 class -1E-1007 -> -Subnormal
-clasx025 class -0.1E-999 -> -Subnormal
-clasx026 class -0.99999999E-999 -> -Subnormal
-clasx027 class -1.00000000E-999 -> -Normal
-clasx028 class -1E-999 -> -Normal
-clasx029 class -1E-100 -> -Normal
-clasx030 class -1E-10 -> -Normal
-clasx032 class -1E-1 -> -Normal
-clasx033 class -1 -> -Normal
-clasx034 class -2.50 -> -Normal
-clasx035 class -100.100 -> -Normal
-clasx036 class -1E+30 -> -Normal
-clasx037 class -1E+999 -> -Normal
-clasx038 class -9.99999999E+999 -> -Normal
-clasx039 class -Inf -> -Infinity
-
-clasx041 class NaN -> NaN
-clasx042 class -NaN -> NaN
-clasx043 class +NaN12345 -> NaN
-clasx044 class sNaN -> sNaN
-clasx045 class -sNaN -> sNaN
-clasx046 class +sNaN12345 -> sNaN
-
-
--- decimal64 bounds
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-clamp: 1
-rounding: half_even
-
-clasx201 class 0 -> +Zero
-clasx202 class 0.00 -> +Zero
-clasx203 class 0E+5 -> +Zero
-clasx204 class 1E-396 -> +Subnormal
-clasx205 class 0.1E-383 -> +Subnormal
-clasx206 class 0.999999999999999E-383 -> +Subnormal
-clasx207 class 1.000000000000000E-383 -> +Normal
-clasx208 class 1E-383 -> +Normal
-clasx209 class 1E-100 -> +Normal
-clasx210 class 1E-10 -> +Normal
-clasx212 class 1E-1 -> +Normal
-clasx213 class 1 -> +Normal
-clasx214 class 2.50 -> +Normal
-clasx215 class 100.100 -> +Normal
-clasx216 class 1E+30 -> +Normal
-clasx217 class 1E+384 -> +Normal
-clasx218 class 9.999999999999999E+384 -> +Normal
-clasx219 class Inf -> +Infinity
-
-clasx221 class -0 -> -Zero
-clasx222 class -0.00 -> -Zero
-clasx223 class -0E+5 -> -Zero
-clasx224 class -1E-396 -> -Subnormal
-clasx225 class -0.1E-383 -> -Subnormal
-clasx226 class -0.999999999999999E-383 -> -Subnormal
-clasx227 class -1.000000000000000E-383 -> -Normal
-clasx228 class -1E-383 -> -Normal
-clasx229 class -1E-100 -> -Normal
-clasx230 class -1E-10 -> -Normal
-clasx232 class -1E-1 -> -Normal
-clasx233 class -1 -> -Normal
-clasx234 class -2.50 -> -Normal
-clasx235 class -100.100 -> -Normal
-clasx236 class -1E+30 -> -Normal
-clasx237 class -1E+384 -> -Normal
-clasx238 class -9.999999999999999E+384 -> -Normal
-clasx239 class -Inf -> -Infinity
-
-clasx241 class NaN -> NaN
-clasx242 class -NaN -> NaN
-clasx243 class +NaN12345 -> NaN
-clasx244 class sNaN -> sNaN
-clasx245 class -sNaN -> sNaN
-clasx246 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- class.decTest -- Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+
+precision: 9
+maxExponent: 999
+minExponent: -999
+extended: 1
+clamp: 1
+rounding: half_even
+
+clasx001 class 0 -> +Zero
+clasx002 class 0.00 -> +Zero
+clasx003 class 0E+5 -> +Zero
+clasx004 class 1E-1007 -> +Subnormal
+clasx005 class 0.1E-999 -> +Subnormal
+clasx006 class 0.99999999E-999 -> +Subnormal
+clasx007 class 1.00000000E-999 -> +Normal
+clasx008 class 1E-999 -> +Normal
+clasx009 class 1E-100 -> +Normal
+clasx010 class 1E-10 -> +Normal
+clasx012 class 1E-1 -> +Normal
+clasx013 class 1 -> +Normal
+clasx014 class 2.50 -> +Normal
+clasx015 class 100.100 -> +Normal
+clasx016 class 1E+30 -> +Normal
+clasx017 class 1E+999 -> +Normal
+clasx018 class 9.99999999E+999 -> +Normal
+clasx019 class Inf -> +Infinity
+
+clasx021 class -0 -> -Zero
+clasx022 class -0.00 -> -Zero
+clasx023 class -0E+5 -> -Zero
+clasx024 class -1E-1007 -> -Subnormal
+clasx025 class -0.1E-999 -> -Subnormal
+clasx026 class -0.99999999E-999 -> -Subnormal
+clasx027 class -1.00000000E-999 -> -Normal
+clasx028 class -1E-999 -> -Normal
+clasx029 class -1E-100 -> -Normal
+clasx030 class -1E-10 -> -Normal
+clasx032 class -1E-1 -> -Normal
+clasx033 class -1 -> -Normal
+clasx034 class -2.50 -> -Normal
+clasx035 class -100.100 -> -Normal
+clasx036 class -1E+30 -> -Normal
+clasx037 class -1E+999 -> -Normal
+clasx038 class -9.99999999E+999 -> -Normal
+clasx039 class -Inf -> -Infinity
+
+clasx041 class NaN -> NaN
+clasx042 class -NaN -> NaN
+clasx043 class +NaN12345 -> NaN
+clasx044 class sNaN -> sNaN
+clasx045 class -sNaN -> sNaN
+clasx046 class +sNaN12345 -> sNaN
+
+
+-- decimal64 bounds
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+clamp: 1
+rounding: half_even
+
+clasx201 class 0 -> +Zero
+clasx202 class 0.00 -> +Zero
+clasx203 class 0E+5 -> +Zero
+clasx204 class 1E-396 -> +Subnormal
+clasx205 class 0.1E-383 -> +Subnormal
+clasx206 class 0.999999999999999E-383 -> +Subnormal
+clasx207 class 1.000000000000000E-383 -> +Normal
+clasx208 class 1E-383 -> +Normal
+clasx209 class 1E-100 -> +Normal
+clasx210 class 1E-10 -> +Normal
+clasx212 class 1E-1 -> +Normal
+clasx213 class 1 -> +Normal
+clasx214 class 2.50 -> +Normal
+clasx215 class 100.100 -> +Normal
+clasx216 class 1E+30 -> +Normal
+clasx217 class 1E+384 -> +Normal
+clasx218 class 9.999999999999999E+384 -> +Normal
+clasx219 class Inf -> +Infinity
+
+clasx221 class -0 -> -Zero
+clasx222 class -0.00 -> -Zero
+clasx223 class -0E+5 -> -Zero
+clasx224 class -1E-396 -> -Subnormal
+clasx225 class -0.1E-383 -> -Subnormal
+clasx226 class -0.999999999999999E-383 -> -Subnormal
+clasx227 class -1.000000000000000E-383 -> -Normal
+clasx228 class -1E-383 -> -Normal
+clasx229 class -1E-100 -> -Normal
+clasx230 class -1E-10 -> -Normal
+clasx232 class -1E-1 -> -Normal
+clasx233 class -1 -> -Normal
+clasx234 class -2.50 -> -Normal
+clasx235 class -100.100 -> -Normal
+clasx236 class -1E+30 -> -Normal
+clasx237 class -1E+384 -> -Normal
+clasx238 class -9.999999999999999E+384 -> -Normal
+clasx239 class -Inf -> -Infinity
+
+clasx241 class NaN -> NaN
+clasx242 class -NaN -> NaN
+clasx243 class +NaN12345 -> NaN
+clasx244 class sNaN -> sNaN
+clasx245 class -sNaN -> sNaN
+clasx246 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/comparetotal.decTest b/Lib/test/decimaltestdata/comparetotal.decTest
index 252c49fb61c..ad87b4ce29d 100644
--- a/Lib/test/decimaltestdata/comparetotal.decTest
+++ b/Lib/test/decimaltestdata/comparetotal.decTest
@@ -1,798 +1,798 @@
-------------------------------------------------------------------------
--- comparetotal.decTest -- decimal comparison using total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
-extended: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- sanity checks
-cotx001 comparetotal -2 -2 -> 0
-cotx002 comparetotal -2 -1 -> -1
-cotx003 comparetotal -2 0 -> -1
-cotx004 comparetotal -2 1 -> -1
-cotx005 comparetotal -2 2 -> -1
-cotx006 comparetotal -1 -2 -> 1
-cotx007 comparetotal -1 -1 -> 0
-cotx008 comparetotal -1 0 -> -1
-cotx009 comparetotal -1 1 -> -1
-cotx010 comparetotal -1 2 -> -1
-cotx011 comparetotal 0 -2 -> 1
-cotx012 comparetotal 0 -1 -> 1
-cotx013 comparetotal 0 0 -> 0
-cotx014 comparetotal 0 1 -> -1
-cotx015 comparetotal 0 2 -> -1
-cotx016 comparetotal 1 -2 -> 1
-cotx017 comparetotal 1 -1 -> 1
-cotx018 comparetotal 1 0 -> 1
-cotx019 comparetotal 1 1 -> 0
-cotx020 comparetotal 1 2 -> -1
-cotx021 comparetotal 2 -2 -> 1
-cotx022 comparetotal 2 -1 -> 1
-cotx023 comparetotal 2 0 -> 1
-cotx025 comparetotal 2 1 -> 1
-cotx026 comparetotal 2 2 -> 0
-
-cotx031 comparetotal -20 -20 -> 0
-cotx032 comparetotal -20 -10 -> -1
-cotx033 comparetotal -20 00 -> -1
-cotx034 comparetotal -20 10 -> -1
-cotx035 comparetotal -20 20 -> -1
-cotx036 comparetotal -10 -20 -> 1
-cotx037 comparetotal -10 -10 -> 0
-cotx038 comparetotal -10 00 -> -1
-cotx039 comparetotal -10 10 -> -1
-cotx040 comparetotal -10 20 -> -1
-cotx041 comparetotal 00 -20 -> 1
-cotx042 comparetotal 00 -10 -> 1
-cotx043 comparetotal 00 00 -> 0
-cotx044 comparetotal 00 10 -> -1
-cotx045 comparetotal 00 20 -> -1
-cotx046 comparetotal 10 -20 -> 1
-cotx047 comparetotal 10 -10 -> 1
-cotx048 comparetotal 10 00 -> 1
-cotx049 comparetotal 10 10 -> 0
-cotx050 comparetotal 10 20 -> -1
-cotx051 comparetotal 20 -20 -> 1
-cotx052 comparetotal 20 -10 -> 1
-cotx053 comparetotal 20 00 -> 1
-cotx055 comparetotal 20 10 -> 1
-cotx056 comparetotal 20 20 -> 0
-
-cotx061 comparetotal -2.0 -2.0 -> 0
-cotx062 comparetotal -2.0 -1.0 -> -1
-cotx063 comparetotal -2.0 0.0 -> -1
-cotx064 comparetotal -2.0 1.0 -> -1
-cotx065 comparetotal -2.0 2.0 -> -1
-cotx066 comparetotal -1.0 -2.0 -> 1
-cotx067 comparetotal -1.0 -1.0 -> 0
-cotx068 comparetotal -1.0 0.0 -> -1
-cotx069 comparetotal -1.0 1.0 -> -1
-cotx070 comparetotal -1.0 2.0 -> -1
-cotx071 comparetotal 0.0 -2.0 -> 1
-cotx072 comparetotal 0.0 -1.0 -> 1
-cotx073 comparetotal 0.0 0.0 -> 0
-cotx074 comparetotal 0.0 1.0 -> -1
-cotx075 comparetotal 0.0 2.0 -> -1
-cotx076 comparetotal 1.0 -2.0 -> 1
-cotx077 comparetotal 1.0 -1.0 -> 1
-cotx078 comparetotal 1.0 0.0 -> 1
-cotx079 comparetotal 1.0 1.0 -> 0
-cotx080 comparetotal 1.0 2.0 -> -1
-cotx081 comparetotal 2.0 -2.0 -> 1
-cotx082 comparetotal 2.0 -1.0 -> 1
-cotx083 comparetotal 2.0 0.0 -> 1
-cotx085 comparetotal 2.0 1.0 -> 1
-cotx086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-maxexponent: 999999999
-minexponent: -999999999
-cotx090 comparetotal 9.99999999E+999999999 9.99999999E+999999999 -> 0
-cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999 -> -1
-cotx092 comparetotal 9.99999999E+999999999 -9.99999999E+999999999 -> 1
-cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0
-
--- Examples
-cotx094 comparetotal 12.73 127.9 -> -1
-cotx095 comparetotal -127 12 -> -1
-cotx096 comparetotal 12.30 12.3 -> -1
-cotx097 comparetotal 12.30 12.30 -> 0
-cotx098 comparetotal 12.3 12.300 -> 1
-cotx099 comparetotal 12.3 NaN -> -1
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-cotx100 comparetotal 7.0 7.0 -> 0
-cotx101 comparetotal 7.0 7 -> -1
-cotx102 comparetotal 7 7.0 -> 1
-cotx103 comparetotal 7E+0 7.0 -> 1
-cotx104 comparetotal 70E-1 7.0 -> 0
-cotx105 comparetotal 0.7E+1 7 -> 0
-cotx106 comparetotal 70E-1 7 -> -1
-cotx107 comparetotal 7.0 7E+0 -> -1
-cotx108 comparetotal 7.0 70E-1 -> 0
-cotx109 comparetotal 7 0.7E+1 -> 0
-cotx110 comparetotal 7 70E-1 -> 1
-
-cotx120 comparetotal 8.0 7.0 -> 1
-cotx121 comparetotal 8.0 7 -> 1
-cotx122 comparetotal 8 7.0 -> 1
-cotx123 comparetotal 8E+0 7.0 -> 1
-cotx124 comparetotal 80E-1 7.0 -> 1
-cotx125 comparetotal 0.8E+1 7 -> 1
-cotx126 comparetotal 80E-1 7 -> 1
-cotx127 comparetotal 8.0 7E+0 -> 1
-cotx128 comparetotal 8.0 70E-1 -> 1
-cotx129 comparetotal 8 0.7E+1 -> 1
-cotx130 comparetotal 8 70E-1 -> 1
-
-cotx140 comparetotal 8.0 9.0 -> -1
-cotx141 comparetotal 8.0 9 -> -1
-cotx142 comparetotal 8 9.0 -> -1
-cotx143 comparetotal 8E+0 9.0 -> -1
-cotx144 comparetotal 80E-1 9.0 -> -1
-cotx145 comparetotal 0.8E+1 9 -> -1
-cotx146 comparetotal 80E-1 9 -> -1
-cotx147 comparetotal 8.0 9E+0 -> -1
-cotx148 comparetotal 8.0 90E-1 -> -1
-cotx149 comparetotal 8 0.9E+1 -> -1
-cotx150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-cotx200 comparetotal -7.0 7.0 -> -1
-cotx201 comparetotal -7.0 7 -> -1
-cotx202 comparetotal -7 7.0 -> -1
-cotx203 comparetotal -7E+0 7.0 -> -1
-cotx204 comparetotal -70E-1 7.0 -> -1
-cotx205 comparetotal -0.7E+1 7 -> -1
-cotx206 comparetotal -70E-1 7 -> -1
-cotx207 comparetotal -7.0 7E+0 -> -1
-cotx208 comparetotal -7.0 70E-1 -> -1
-cotx209 comparetotal -7 0.7E+1 -> -1
-cotx210 comparetotal -7 70E-1 -> -1
-
-cotx220 comparetotal -8.0 7.0 -> -1
-cotx221 comparetotal -8.0 7 -> -1
-cotx222 comparetotal -8 7.0 -> -1
-cotx223 comparetotal -8E+0 7.0 -> -1
-cotx224 comparetotal -80E-1 7.0 -> -1
-cotx225 comparetotal -0.8E+1 7 -> -1
-cotx226 comparetotal -80E-1 7 -> -1
-cotx227 comparetotal -8.0 7E+0 -> -1
-cotx228 comparetotal -8.0 70E-1 -> -1
-cotx229 comparetotal -8 0.7E+1 -> -1
-cotx230 comparetotal -8 70E-1 -> -1
-
-cotx240 comparetotal -8.0 9.0 -> -1
-cotx241 comparetotal -8.0 9 -> -1
-cotx242 comparetotal -8 9.0 -> -1
-cotx243 comparetotal -8E+0 9.0 -> -1
-cotx244 comparetotal -80E-1 9.0 -> -1
-cotx245 comparetotal -0.8E+1 9 -> -1
-cotx246 comparetotal -80E-1 9 -> -1
-cotx247 comparetotal -8.0 9E+0 -> -1
-cotx248 comparetotal -8.0 90E-1 -> -1
-cotx249 comparetotal -8 0.9E+1 -> -1
-cotx250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-cotx300 comparetotal 7.0 -7.0 -> 1
-cotx301 comparetotal 7.0 -7 -> 1
-cotx302 comparetotal 7 -7.0 -> 1
-cotx303 comparetotal 7E+0 -7.0 -> 1
-cotx304 comparetotal 70E-1 -7.0 -> 1
-cotx305 comparetotal .7E+1 -7 -> 1
-cotx306 comparetotal 70E-1 -7 -> 1
-cotx307 comparetotal 7.0 -7E+0 -> 1
-cotx308 comparetotal 7.0 -70E-1 -> 1
-cotx309 comparetotal 7 -.7E+1 -> 1
-cotx310 comparetotal 7 -70E-1 -> 1
-
-cotx320 comparetotal 8.0 -7.0 -> 1
-cotx321 comparetotal 8.0 -7 -> 1
-cotx322 comparetotal 8 -7.0 -> 1
-cotx323 comparetotal 8E+0 -7.0 -> 1
-cotx324 comparetotal 80E-1 -7.0 -> 1
-cotx325 comparetotal .8E+1 -7 -> 1
-cotx326 comparetotal 80E-1 -7 -> 1
-cotx327 comparetotal 8.0 -7E+0 -> 1
-cotx328 comparetotal 8.0 -70E-1 -> 1
-cotx329 comparetotal 8 -.7E+1 -> 1
-cotx330 comparetotal 8 -70E-1 -> 1
-
-cotx340 comparetotal 8.0 -9.0 -> 1
-cotx341 comparetotal 8.0 -9 -> 1
-cotx342 comparetotal 8 -9.0 -> 1
-cotx343 comparetotal 8E+0 -9.0 -> 1
-cotx344 comparetotal 80E-1 -9.0 -> 1
-cotx345 comparetotal .8E+1 -9 -> 1
-cotx346 comparetotal 80E-1 -9 -> 1
-cotx347 comparetotal 8.0 -9E+0 -> 1
-cotx348 comparetotal 8.0 -90E-1 -> 1
-cotx349 comparetotal 8 -.9E+1 -> 1
-cotx350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-cotx400 comparetotal -7.0 -7.0 -> 0
-cotx401 comparetotal -7.0 -7 -> 1
-cotx402 comparetotal -7 -7.0 -> -1
-cotx403 comparetotal -7E+0 -7.0 -> -1
-cotx404 comparetotal -70E-1 -7.0 -> 0
-cotx405 comparetotal -.7E+1 -7 -> 0
-cotx406 comparetotal -70E-1 -7 -> 1
-cotx407 comparetotal -7.0 -7E+0 -> 1
-cotx408 comparetotal -7.0 -70E-1 -> 0
-cotx409 comparetotal -7 -.7E+1 -> 0
-cotx410 comparetotal -7 -70E-1 -> -1
-
-cotx420 comparetotal -8.0 -7.0 -> -1
-cotx421 comparetotal -8.0 -7 -> -1
-cotx422 comparetotal -8 -7.0 -> -1
-cotx423 comparetotal -8E+0 -7.0 -> -1
-cotx424 comparetotal -80E-1 -7.0 -> -1
-cotx425 comparetotal -.8E+1 -7 -> -1
-cotx426 comparetotal -80E-1 -7 -> -1
-cotx427 comparetotal -8.0 -7E+0 -> -1
-cotx428 comparetotal -8.0 -70E-1 -> -1
-cotx429 comparetotal -8 -.7E+1 -> -1
-cotx430 comparetotal -8 -70E-1 -> -1
-
-cotx440 comparetotal -8.0 -9.0 -> 1
-cotx441 comparetotal -8.0 -9 -> 1
-cotx442 comparetotal -8 -9.0 -> 1
-cotx443 comparetotal -8E+0 -9.0 -> 1
-cotx444 comparetotal -80E-1 -9.0 -> 1
-cotx445 comparetotal -.8E+1 -9 -> 1
-cotx446 comparetotal -80E-1 -9 -> 1
-cotx447 comparetotal -8.0 -9E+0 -> 1
-cotx448 comparetotal -8.0 -90E-1 -> 1
-cotx449 comparetotal -8 -.9E+1 -> 1
-cotx450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-precision: 40
-cotx470 comparetotal 123.4560000000000000E789 123.456E789 -> -1
-cotx471 comparetotal 123.456000000000000E-89 123.456E-89 -> -1
-cotx472 comparetotal 123.45600000000000E789 123.456E789 -> -1
-cotx473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-cotx474 comparetotal 123.456000000000E789 123.456E789 -> -1
-cotx475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-cotx476 comparetotal 123.4560000000E789 123.456E789 -> -1
-cotx477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-cotx478 comparetotal 123.45600000E789 123.456E789 -> -1
-cotx479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-cotx480 comparetotal 123.456000E789 123.456E789 -> -1
-cotx481 comparetotal 123.45600E-89 123.456E-89 -> -1
-cotx482 comparetotal 123.4560E789 123.456E789 -> -1
-cotx483 comparetotal 123.456E-89 123.456E-89 -> 0
-cotx484 comparetotal 123.456E-89 123.4560000000000000E-89 -> 1
-cotx485 comparetotal 123.456E789 123.456000000000000E789 -> 1
-cotx486 comparetotal 123.456E-89 123.45600000000000E-89 -> 1
-cotx487 comparetotal 123.456E789 123.4560000000000E789 -> 1
-cotx488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-cotx489 comparetotal 123.456E789 123.45600000000E789 -> 1
-cotx490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-cotx491 comparetotal 123.456E789 123.456000000E789 -> 1
-cotx492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-cotx493 comparetotal 123.456E789 123.4560000E789 -> 1
-cotx494 comparetotal 123.456E-89 123.456000E-89 -> 1
-cotx495 comparetotal 123.456E789 123.45600E789 -> 1
-cotx496 comparetotal 123.456E-89 123.4560E-89 -> 1
-cotx497 comparetotal 123.456E789 123.456E789 -> 0
-
--- wide-ranging, around precision; signs equal
-precision: 9
-cotx500 comparetotal 1 1E-15 -> 1
-cotx501 comparetotal 1 1E-14 -> 1
-cotx502 comparetotal 1 1E-13 -> 1
-cotx503 comparetotal 1 1E-12 -> 1
-cotx504 comparetotal 1 1E-11 -> 1
-cotx505 comparetotal 1 1E-10 -> 1
-cotx506 comparetotal 1 1E-9 -> 1
-cotx507 comparetotal 1 1E-8 -> 1
-cotx508 comparetotal 1 1E-7 -> 1
-cotx509 comparetotal 1 1E-6 -> 1
-cotx510 comparetotal 1 1E-5 -> 1
-cotx511 comparetotal 1 1E-4 -> 1
-cotx512 comparetotal 1 1E-3 -> 1
-cotx513 comparetotal 1 1E-2 -> 1
-cotx514 comparetotal 1 1E-1 -> 1
-cotx515 comparetotal 1 1E-0 -> 0
-cotx516 comparetotal 1 1E+1 -> -1
-cotx517 comparetotal 1 1E+2 -> -1
-cotx518 comparetotal 1 1E+3 -> -1
-cotx519 comparetotal 1 1E+4 -> -1
-cotx521 comparetotal 1 1E+5 -> -1
-cotx522 comparetotal 1 1E+6 -> -1
-cotx523 comparetotal 1 1E+7 -> -1
-cotx524 comparetotal 1 1E+8 -> -1
-cotx525 comparetotal 1 1E+9 -> -1
-cotx526 comparetotal 1 1E+10 -> -1
-cotx527 comparetotal 1 1E+11 -> -1
-cotx528 comparetotal 1 1E+12 -> -1
-cotx529 comparetotal 1 1E+13 -> -1
-cotx530 comparetotal 1 1E+14 -> -1
-cotx531 comparetotal 1 1E+15 -> -1
--- LR swap
-cotx540 comparetotal 1E-15 1 -> -1
-cotx541 comparetotal 1E-14 1 -> -1
-cotx542 comparetotal 1E-13 1 -> -1
-cotx543 comparetotal 1E-12 1 -> -1
-cotx544 comparetotal 1E-11 1 -> -1
-cotx545 comparetotal 1E-10 1 -> -1
-cotx546 comparetotal 1E-9 1 -> -1
-cotx547 comparetotal 1E-8 1 -> -1
-cotx548 comparetotal 1E-7 1 -> -1
-cotx549 comparetotal 1E-6 1 -> -1
-cotx550 comparetotal 1E-5 1 -> -1
-cotx551 comparetotal 1E-4 1 -> -1
-cotx552 comparetotal 1E-3 1 -> -1
-cotx553 comparetotal 1E-2 1 -> -1
-cotx554 comparetotal 1E-1 1 -> -1
-cotx555 comparetotal 1E-0 1 -> 0
-cotx556 comparetotal 1E+1 1 -> 1
-cotx557 comparetotal 1E+2 1 -> 1
-cotx558 comparetotal 1E+3 1 -> 1
-cotx559 comparetotal 1E+4 1 -> 1
-cotx561 comparetotal 1E+5 1 -> 1
-cotx562 comparetotal 1E+6 1 -> 1
-cotx563 comparetotal 1E+7 1 -> 1
-cotx564 comparetotal 1E+8 1 -> 1
-cotx565 comparetotal 1E+9 1 -> 1
-cotx566 comparetotal 1E+10 1 -> 1
-cotx567 comparetotal 1E+11 1 -> 1
-cotx568 comparetotal 1E+12 1 -> 1
-cotx569 comparetotal 1E+13 1 -> 1
-cotx570 comparetotal 1E+14 1 -> 1
-cotx571 comparetotal 1E+15 1 -> 1
--- similar with an useful coefficient, one side only
-cotx580 comparetotal 0.000000987654321 1E-15 -> 1
-cotx581 comparetotal 0.000000987654321 1E-14 -> 1
-cotx582 comparetotal 0.000000987654321 1E-13 -> 1
-cotx583 comparetotal 0.000000987654321 1E-12 -> 1
-cotx584 comparetotal 0.000000987654321 1E-11 -> 1
-cotx585 comparetotal 0.000000987654321 1E-10 -> 1
-cotx586 comparetotal 0.000000987654321 1E-9 -> 1
-cotx587 comparetotal 0.000000987654321 1E-8 -> 1
-cotx588 comparetotal 0.000000987654321 1E-7 -> 1
-cotx589 comparetotal 0.000000987654321 1E-6 -> -1
-cotx590 comparetotal 0.000000987654321 1E-5 -> -1
-cotx591 comparetotal 0.000000987654321 1E-4 -> -1
-cotx592 comparetotal 0.000000987654321 1E-3 -> -1
-cotx593 comparetotal 0.000000987654321 1E-2 -> -1
-cotx594 comparetotal 0.000000987654321 1E-1 -> -1
-cotx595 comparetotal 0.000000987654321 1E-0 -> -1
-cotx596 comparetotal 0.000000987654321 1E+1 -> -1
-cotx597 comparetotal 0.000000987654321 1E+2 -> -1
-cotx598 comparetotal 0.000000987654321 1E+3 -> -1
-cotx599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-precision: 20
-cotx600 comparetotal 12 12.2345 -> -1
-cotx601 comparetotal 12.0 12.2345 -> -1
-cotx602 comparetotal 12.00 12.2345 -> -1
-cotx603 comparetotal 12.000 12.2345 -> -1
-cotx604 comparetotal 12.0000 12.2345 -> -1
-cotx605 comparetotal 12.00000 12.2345 -> -1
-cotx606 comparetotal 12.000000 12.2345 -> -1
-cotx607 comparetotal 12.0000000 12.2345 -> -1
-cotx608 comparetotal 12.00000000 12.2345 -> -1
-cotx609 comparetotal 12.000000000 12.2345 -> -1
-cotx610 comparetotal 12.1234 12 -> 1
-cotx611 comparetotal 12.1234 12.0 -> 1
-cotx612 comparetotal 12.1234 12.00 -> 1
-cotx613 comparetotal 12.1234 12.000 -> 1
-cotx614 comparetotal 12.1234 12.0000 -> 1
-cotx615 comparetotal 12.1234 12.00000 -> 1
-cotx616 comparetotal 12.1234 12.000000 -> 1
-cotx617 comparetotal 12.1234 12.0000000 -> 1
-cotx618 comparetotal 12.1234 12.00000000 -> 1
-cotx619 comparetotal 12.1234 12.000000000 -> 1
-cotx620 comparetotal -12 -12.2345 -> 1
-cotx621 comparetotal -12.0 -12.2345 -> 1
-cotx622 comparetotal -12.00 -12.2345 -> 1
-cotx623 comparetotal -12.000 -12.2345 -> 1
-cotx624 comparetotal -12.0000 -12.2345 -> 1
-cotx625 comparetotal -12.00000 -12.2345 -> 1
-cotx626 comparetotal -12.000000 -12.2345 -> 1
-cotx627 comparetotal -12.0000000 -12.2345 -> 1
-cotx628 comparetotal -12.00000000 -12.2345 -> 1
-cotx629 comparetotal -12.000000000 -12.2345 -> 1
-cotx630 comparetotal -12.1234 -12 -> -1
-cotx631 comparetotal -12.1234 -12.0 -> -1
-cotx632 comparetotal -12.1234 -12.00 -> -1
-cotx633 comparetotal -12.1234 -12.000 -> -1
-cotx634 comparetotal -12.1234 -12.0000 -> -1
-cotx635 comparetotal -12.1234 -12.00000 -> -1
-cotx636 comparetotal -12.1234 -12.000000 -> -1
-cotx637 comparetotal -12.1234 -12.0000000 -> -1
-cotx638 comparetotal -12.1234 -12.00000000 -> -1
-cotx639 comparetotal -12.1234 -12.000000000 -> -1
-precision: 9
-
--- extended zeros
-cotx640 comparetotal 0 0 -> 0
-cotx641 comparetotal 0 -0 -> 1
-cotx642 comparetotal 0 -0.0 -> 1
-cotx643 comparetotal 0 0.0 -> 1
-cotx644 comparetotal -0 0 -> -1
-cotx645 comparetotal -0 -0 -> 0
-cotx646 comparetotal -0 -0.0 -> -1
-cotx647 comparetotal -0 0.0 -> -1
-cotx648 comparetotal 0.0 0 -> -1
-cotx649 comparetotal 0.0 -0 -> 1
-cotx650 comparetotal 0.0 -0.0 -> 1
-cotx651 comparetotal 0.0 0.0 -> 0
-cotx652 comparetotal -0.0 0 -> -1
-cotx653 comparetotal -0.0 -0 -> 1
-cotx654 comparetotal -0.0 -0.0 -> 0
-cotx655 comparetotal -0.0 0.0 -> -1
-
-cotx656 comparetotal -0E1 0.0 -> -1
-cotx657 comparetotal -0E2 0.0 -> -1
-cotx658 comparetotal 0E1 0.0 -> 1
-cotx659 comparetotal 0E2 0.0 -> 1
-cotx660 comparetotal -0E1 0 -> -1
-cotx661 comparetotal -0E2 0 -> -1
-cotx662 comparetotal 0E1 0 -> 1
-cotx663 comparetotal 0E2 0 -> 1
-cotx664 comparetotal -0E1 -0E1 -> 0
-cotx665 comparetotal -0E2 -0E1 -> -1
-cotx666 comparetotal 0E1 -0E1 -> 1
-cotx667 comparetotal 0E2 -0E1 -> 1
-cotx668 comparetotal -0E1 -0E2 -> 1
-cotx669 comparetotal -0E2 -0E2 -> 0
-cotx670 comparetotal 0E1 -0E2 -> 1
-cotx671 comparetotal 0E2 -0E2 -> 1
-cotx672 comparetotal -0E1 0E1 -> -1
-cotx673 comparetotal -0E2 0E1 -> -1
-cotx674 comparetotal 0E1 0E1 -> 0
-cotx675 comparetotal 0E2 0E1 -> 1
-cotx676 comparetotal -0E1 0E2 -> -1
-cotx677 comparetotal -0E2 0E2 -> -1
-cotx678 comparetotal 0E1 0E2 -> -1
-cotx679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-precision: 20
-cotx680 comparetotal 12 12 -> 0
-cotx681 comparetotal 12 12.0 -> 1
-cotx682 comparetotal 12 12.00 -> 1
-cotx683 comparetotal 12 12.000 -> 1
-cotx684 comparetotal 12 12.0000 -> 1
-cotx685 comparetotal 12 12.00000 -> 1
-cotx686 comparetotal 12 12.000000 -> 1
-cotx687 comparetotal 12 12.0000000 -> 1
-cotx688 comparetotal 12 12.00000000 -> 1
-cotx689 comparetotal 12 12.000000000 -> 1
-cotx690 comparetotal 12 12 -> 0
-cotx691 comparetotal 12.0 12 -> -1
-cotx692 comparetotal 12.00 12 -> -1
-cotx693 comparetotal 12.000 12 -> -1
-cotx694 comparetotal 12.0000 12 -> -1
-cotx695 comparetotal 12.00000 12 -> -1
-cotx696 comparetotal 12.000000 12 -> -1
-cotx697 comparetotal 12.0000000 12 -> -1
-cotx698 comparetotal 12.00000000 12 -> -1
-cotx699 comparetotal 12.000000000 12 -> -1
-
--- long operand checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-cotx701 comparetotal 12345678000 1 -> 1
-cotx702 comparetotal 1 12345678000 -> -1
-cotx703 comparetotal 1234567800 1 -> 1
-cotx704 comparetotal 1 1234567800 -> -1
-cotx705 comparetotal 1234567890 1 -> 1
-cotx706 comparetotal 1 1234567890 -> -1
-cotx707 comparetotal 1234567891 1 -> 1
-cotx708 comparetotal 1 1234567891 -> -1
-cotx709 comparetotal 12345678901 1 -> 1
-cotx710 comparetotal 1 12345678901 -> -1
-cotx711 comparetotal 1234567896 1 -> 1
-cotx712 comparetotal 1 1234567896 -> -1
-cotx713 comparetotal -1234567891 1 -> -1
-cotx714 comparetotal 1 -1234567891 -> 1
-cotx715 comparetotal -12345678901 1 -> -1
-cotx716 comparetotal 1 -12345678901 -> 1
-cotx717 comparetotal -1234567896 1 -> -1
-cotx718 comparetotal 1 -1234567896 -> 1
-
-precision: 15
--- same with plenty of precision
-cotx721 comparetotal 12345678000 1 -> 1
-cotx722 comparetotal 1 12345678000 -> -1
-cotx723 comparetotal 1234567800 1 -> 1
-cotx724 comparetotal 1 1234567800 -> -1
-cotx725 comparetotal 1234567890 1 -> 1
-cotx726 comparetotal 1 1234567890 -> -1
-cotx727 comparetotal 1234567891 1 -> 1
-cotx728 comparetotal 1 1234567891 -> -1
-cotx729 comparetotal 12345678901 1 -> 1
-cotx730 comparetotal 1 12345678901 -> -1
-cotx731 comparetotal 1234567896 1 -> 1
-cotx732 comparetotal 1 1234567896 -> -1
-
--- residue cases
-precision: 5
-cotx740 comparetotal 1 0.9999999 -> 1
-cotx741 comparetotal 1 0.999999 -> 1
-cotx742 comparetotal 1 0.99999 -> 1
-cotx743 comparetotal 1 1.0000 -> 1
-cotx744 comparetotal 1 1.00001 -> -1
-cotx745 comparetotal 1 1.000001 -> -1
-cotx746 comparetotal 1 1.0000001 -> -1
-cotx750 comparetotal 0.9999999 1 -> -1
-cotx751 comparetotal 0.999999 1 -> -1
-cotx752 comparetotal 0.99999 1 -> -1
-cotx753 comparetotal 1.0000 1 -> -1
-cotx754 comparetotal 1.00001 1 -> 1
-cotx755 comparetotal 1.000001 1 -> 1
-cotx756 comparetotal 1.0000001 1 -> 1
-
--- a selection of longies
-cotx760 comparetotal -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
-cotx761 comparetotal -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
-cotx762 comparetotal -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
-cotx763 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
--- precisions above or below the difference should have no effect
-precision: 11
-cotx764 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 10
-cotx765 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 9
-cotx766 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 8
-cotx767 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 7
-cotx768 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 6
-cotx769 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 5
-cotx770 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 4
-cotx771 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 3
-cotx772 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 2
-cotx773 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-precision: 1
-cotx774 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
-
--- Specials
-precision: 9
-cotx780 comparetotal Inf -Inf -> 1
-cotx781 comparetotal Inf -1000 -> 1
-cotx782 comparetotal Inf -1 -> 1
-cotx783 comparetotal Inf -0 -> 1
-cotx784 comparetotal Inf 0 -> 1
-cotx785 comparetotal Inf 1 -> 1
-cotx786 comparetotal Inf 1000 -> 1
-cotx787 comparetotal Inf Inf -> 0
-cotx788 comparetotal -1000 Inf -> -1
-cotx789 comparetotal -Inf Inf -> -1
-cotx790 comparetotal -1 Inf -> -1
-cotx791 comparetotal -0 Inf -> -1
-cotx792 comparetotal 0 Inf -> -1
-cotx793 comparetotal 1 Inf -> -1
-cotx794 comparetotal 1000 Inf -> -1
-cotx795 comparetotal Inf Inf -> 0
-
-cotx800 comparetotal -Inf -Inf -> 0
-cotx801 comparetotal -Inf -1000 -> -1
-cotx802 comparetotal -Inf -1 -> -1
-cotx803 comparetotal -Inf -0 -> -1
-cotx804 comparetotal -Inf 0 -> -1
-cotx805 comparetotal -Inf 1 -> -1
-cotx806 comparetotal -Inf 1000 -> -1
-cotx807 comparetotal -Inf Inf -> -1
-cotx808 comparetotal -Inf -Inf -> 0
-cotx809 comparetotal -1000 -Inf -> 1
-cotx810 comparetotal -1 -Inf -> 1
-cotx811 comparetotal -0 -Inf -> 1
-cotx812 comparetotal 0 -Inf -> 1
-cotx813 comparetotal 1 -Inf -> 1
-cotx814 comparetotal 1000 -Inf -> 1
-cotx815 comparetotal Inf -Inf -> 1
-
-cotx821 comparetotal NaN -Inf -> 1
-cotx822 comparetotal NaN -1000 -> 1
-cotx823 comparetotal NaN -1 -> 1
-cotx824 comparetotal NaN -0 -> 1
-cotx825 comparetotal NaN 0 -> 1
-cotx826 comparetotal NaN 1 -> 1
-cotx827 comparetotal NaN 1000 -> 1
-cotx828 comparetotal NaN Inf -> 1
-cotx829 comparetotal NaN NaN -> 0
-cotx830 comparetotal -Inf NaN -> -1
-cotx831 comparetotal -1000 NaN -> -1
-cotx832 comparetotal -1 NaN -> -1
-cotx833 comparetotal -0 NaN -> -1
-cotx834 comparetotal 0 NaN -> -1
-cotx835 comparetotal 1 NaN -> -1
-cotx836 comparetotal 1000 NaN -> -1
-cotx837 comparetotal Inf NaN -> -1
-cotx838 comparetotal -NaN -NaN -> 0
-cotx839 comparetotal +NaN -NaN -> 1
-cotx840 comparetotal -NaN +NaN -> -1
-
-cotx841 comparetotal sNaN -sNaN -> 1
-cotx842 comparetotal sNaN -NaN -> 1
-cotx843 comparetotal sNaN -Inf -> 1
-cotx844 comparetotal sNaN -1000 -> 1
-cotx845 comparetotal sNaN -1 -> 1
-cotx846 comparetotal sNaN -0 -> 1
-cotx847 comparetotal sNaN 0 -> 1
-cotx848 comparetotal sNaN 1 -> 1
-cotx849 comparetotal sNaN 1000 -> 1
-cotx850 comparetotal sNaN NaN -> -1
-cotx851 comparetotal sNaN sNaN -> 0
-
-cotx852 comparetotal -sNaN sNaN -> -1
-cotx853 comparetotal -NaN sNaN -> -1
-cotx854 comparetotal -Inf sNaN -> -1
-cotx855 comparetotal -1000 sNaN -> -1
-cotx856 comparetotal -1 sNaN -> -1
-cotx857 comparetotal -0 sNaN -> -1
-cotx858 comparetotal 0 sNaN -> -1
-cotx859 comparetotal 1 sNaN -> -1
-cotx860 comparetotal 1000 sNaN -> -1
-cotx861 comparetotal Inf sNaN -> -1
-cotx862 comparetotal NaN sNaN -> 1
-cotx863 comparetotal sNaN sNaN -> 0
-
-cotx871 comparetotal -sNaN -sNaN -> 0
-cotx872 comparetotal -sNaN -NaN -> 1
-cotx873 comparetotal -sNaN -Inf -> -1
-cotx874 comparetotal -sNaN -1000 -> -1
-cotx875 comparetotal -sNaN -1 -> -1
-cotx876 comparetotal -sNaN -0 -> -1
-cotx877 comparetotal -sNaN 0 -> -1
-cotx878 comparetotal -sNaN 1 -> -1
-cotx879 comparetotal -sNaN 1000 -> -1
-cotx880 comparetotal -sNaN NaN -> -1
-cotx881 comparetotal -sNaN sNaN -> -1
-
-cotx882 comparetotal -sNaN -sNaN -> 0
-cotx883 comparetotal -NaN -sNaN -> -1
-cotx884 comparetotal -Inf -sNaN -> 1
-cotx885 comparetotal -1000 -sNaN -> 1
-cotx886 comparetotal -1 -sNaN -> 1
-cotx887 comparetotal -0 -sNaN -> 1
-cotx888 comparetotal 0 -sNaN -> 1
-cotx889 comparetotal 1 -sNaN -> 1
-cotx890 comparetotal 1000 -sNaN -> 1
-cotx891 comparetotal Inf -sNaN -> 1
-cotx892 comparetotal NaN -sNaN -> 1
-cotx893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-cotx960 comparetotal NaN9 -Inf -> 1
-cotx961 comparetotal NaN8 999 -> 1
-cotx962 comparetotal NaN77 Inf -> 1
-cotx963 comparetotal -NaN67 NaN5 -> -1
-cotx964 comparetotal -Inf -NaN4 -> 1
-cotx965 comparetotal -999 -NaN33 -> 1
-cotx966 comparetotal Inf NaN2 -> -1
-
-cotx970 comparetotal -NaN41 -NaN42 -> 1
-cotx971 comparetotal +NaN41 -NaN42 -> 1
-cotx972 comparetotal -NaN41 +NaN42 -> -1
-cotx973 comparetotal +NaN41 +NaN42 -> -1
-cotx974 comparetotal -NaN42 -NaN01 -> -1
-cotx975 comparetotal +NaN42 -NaN01 -> 1
-cotx976 comparetotal -NaN42 +NaN01 -> -1
-cotx977 comparetotal +NaN42 +NaN01 -> 1
-
-cotx980 comparetotal -sNaN771 -sNaN772 -> 1
-cotx981 comparetotal +sNaN771 -sNaN772 -> 1
-cotx982 comparetotal -sNaN771 +sNaN772 -> -1
-cotx983 comparetotal +sNaN771 +sNaN772 -> -1
-cotx984 comparetotal -sNaN772 -sNaN771 -> -1
-cotx985 comparetotal +sNaN772 -sNaN771 -> 1
-cotx986 comparetotal -sNaN772 +sNaN771 -> -1
-cotx987 comparetotal +sNaN772 +sNaN771 -> 1
-
-cotx991 comparetotal -sNaN99 -Inf -> -1
-cotx992 comparetotal sNaN98 -11 -> 1
-cotx993 comparetotal sNaN97 NaN -> -1
-cotx994 comparetotal sNaN16 sNaN94 -> -1
-cotx995 comparetotal NaN85 sNaN83 -> 1
-cotx996 comparetotal -Inf sNaN92 -> -1
-cotx997 comparetotal 088 sNaN81 -> -1
-cotx998 comparetotal Inf sNaN90 -> -1
-cotx999 comparetotal NaN -sNaN89 -> 1
-
--- overflow and underflow tests .. subnormal results now allowed
-maxExponent: 999999999
-minexponent: -999999999
-cotx1080 comparetotal +1.23456789012345E-0 9E+999999999 -> -1
-cotx1081 comparetotal 9E+999999999 +1.23456789012345E-0 -> 1
-cotx1082 comparetotal +0.100 9E-999999999 -> 1
-cotx1083 comparetotal 9E-999999999 +0.100 -> -1
-cotx1085 comparetotal -1.23456789012345E-0 9E+999999999 -> -1
-cotx1086 comparetotal 9E+999999999 -1.23456789012345E-0 -> 1
-cotx1087 comparetotal -0.100 9E-999999999 -> -1
-cotx1088 comparetotal 9E-999999999 -0.100 -> 1
-
-cotx1089 comparetotal 1e-599999999 1e-400000001 -> -1
-cotx1090 comparetotal 1e-599999999 1e-400000000 -> -1
-cotx1091 comparetotal 1e-600000000 1e-400000000 -> -1
-cotx1092 comparetotal 9e-999999998 0.01 -> -1
-cotx1093 comparetotal 9e-999999998 0.1 -> -1
-cotx1094 comparetotal 0.01 9e-999999998 -> 1
-cotx1095 comparetotal 1e599999999 1e400000001 -> 1
-cotx1096 comparetotal 1e599999999 1e400000000 -> 1
-cotx1097 comparetotal 1e600000000 1e400000000 -> 1
-cotx1098 comparetotal 9e999999998 100 -> 1
-cotx1099 comparetotal 9e999999998 10 -> 1
-cotx1100 comparetotal 100 9e999999998 -> -1
--- signs
-cotx1101 comparetotal 1e+777777777 1e+411111111 -> 1
-cotx1102 comparetotal 1e+777777777 -1e+411111111 -> 1
-cotx1103 comparetotal -1e+777777777 1e+411111111 -> -1
-cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
-cotx1105 comparetotal 1e-777777777 1e-411111111 -> -1
-cotx1106 comparetotal 1e-777777777 -1e-411111111 -> 1
-cotx1107 comparetotal -1e-777777777 1e-411111111 -> -1
-cotx1108 comparetotal -1e-777777777 -1e-411111111 -> 1
-
--- spread zeros
-cotx1110 comparetotal 0E-383 0 -> -1
-cotx1111 comparetotal 0E-383 -0 -> 1
-cotx1112 comparetotal -0E-383 0 -> -1
-cotx1113 comparetotal -0E-383 -0 -> 1
-cotx1114 comparetotal 0E-383 0E+384 -> -1
-cotx1115 comparetotal 0E-383 -0E+384 -> 1
-cotx1116 comparetotal -0E-383 0E+384 -> -1
-cotx1117 comparetotal -0E-383 -0E+384 -> 1
-cotx1118 comparetotal 0 0E+384 -> -1
-cotx1119 comparetotal 0 -0E+384 -> 1
-cotx1120 comparetotal -0 0E+384 -> -1
-cotx1121 comparetotal -0 -0E+384 -> 1
-
-cotx1130 comparetotal 0E+384 0 -> 1
-cotx1131 comparetotal 0E+384 -0 -> 1
-cotx1132 comparetotal -0E+384 0 -> -1
-cotx1133 comparetotal -0E+384 -0 -> -1
-cotx1134 comparetotal 0E+384 0E-383 -> 1
-cotx1135 comparetotal 0E+384 -0E-383 -> 1
-cotx1136 comparetotal -0E+384 0E-383 -> -1
-cotx1137 comparetotal -0E+384 -0E-383 -> -1
-cotx1138 comparetotal 0 0E-383 -> 1
-cotx1139 comparetotal 0 -0E-383 -> 1
-cotx1140 comparetotal -0 0E-383 -> -1
-cotx1141 comparetotal -0 -0E-383 -> -1
-
--- Null tests
-cotx9990 comparetotal 10 # -> NaN Invalid_operation
-cotx9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- comparetotal.decTest -- decimal comparison using total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+extended: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- sanity checks
+cotx001 comparetotal -2 -2 -> 0
+cotx002 comparetotal -2 -1 -> -1
+cotx003 comparetotal -2 0 -> -1
+cotx004 comparetotal -2 1 -> -1
+cotx005 comparetotal -2 2 -> -1
+cotx006 comparetotal -1 -2 -> 1
+cotx007 comparetotal -1 -1 -> 0
+cotx008 comparetotal -1 0 -> -1
+cotx009 comparetotal -1 1 -> -1
+cotx010 comparetotal -1 2 -> -1
+cotx011 comparetotal 0 -2 -> 1
+cotx012 comparetotal 0 -1 -> 1
+cotx013 comparetotal 0 0 -> 0
+cotx014 comparetotal 0 1 -> -1
+cotx015 comparetotal 0 2 -> -1
+cotx016 comparetotal 1 -2 -> 1
+cotx017 comparetotal 1 -1 -> 1
+cotx018 comparetotal 1 0 -> 1
+cotx019 comparetotal 1 1 -> 0
+cotx020 comparetotal 1 2 -> -1
+cotx021 comparetotal 2 -2 -> 1
+cotx022 comparetotal 2 -1 -> 1
+cotx023 comparetotal 2 0 -> 1
+cotx025 comparetotal 2 1 -> 1
+cotx026 comparetotal 2 2 -> 0
+
+cotx031 comparetotal -20 -20 -> 0
+cotx032 comparetotal -20 -10 -> -1
+cotx033 comparetotal -20 00 -> -1
+cotx034 comparetotal -20 10 -> -1
+cotx035 comparetotal -20 20 -> -1
+cotx036 comparetotal -10 -20 -> 1
+cotx037 comparetotal -10 -10 -> 0
+cotx038 comparetotal -10 00 -> -1
+cotx039 comparetotal -10 10 -> -1
+cotx040 comparetotal -10 20 -> -1
+cotx041 comparetotal 00 -20 -> 1
+cotx042 comparetotal 00 -10 -> 1
+cotx043 comparetotal 00 00 -> 0
+cotx044 comparetotal 00 10 -> -1
+cotx045 comparetotal 00 20 -> -1
+cotx046 comparetotal 10 -20 -> 1
+cotx047 comparetotal 10 -10 -> 1
+cotx048 comparetotal 10 00 -> 1
+cotx049 comparetotal 10 10 -> 0
+cotx050 comparetotal 10 20 -> -1
+cotx051 comparetotal 20 -20 -> 1
+cotx052 comparetotal 20 -10 -> 1
+cotx053 comparetotal 20 00 -> 1
+cotx055 comparetotal 20 10 -> 1
+cotx056 comparetotal 20 20 -> 0
+
+cotx061 comparetotal -2.0 -2.0 -> 0
+cotx062 comparetotal -2.0 -1.0 -> -1
+cotx063 comparetotal -2.0 0.0 -> -1
+cotx064 comparetotal -2.0 1.0 -> -1
+cotx065 comparetotal -2.0 2.0 -> -1
+cotx066 comparetotal -1.0 -2.0 -> 1
+cotx067 comparetotal -1.0 -1.0 -> 0
+cotx068 comparetotal -1.0 0.0 -> -1
+cotx069 comparetotal -1.0 1.0 -> -1
+cotx070 comparetotal -1.0 2.0 -> -1
+cotx071 comparetotal 0.0 -2.0 -> 1
+cotx072 comparetotal 0.0 -1.0 -> 1
+cotx073 comparetotal 0.0 0.0 -> 0
+cotx074 comparetotal 0.0 1.0 -> -1
+cotx075 comparetotal 0.0 2.0 -> -1
+cotx076 comparetotal 1.0 -2.0 -> 1
+cotx077 comparetotal 1.0 -1.0 -> 1
+cotx078 comparetotal 1.0 0.0 -> 1
+cotx079 comparetotal 1.0 1.0 -> 0
+cotx080 comparetotal 1.0 2.0 -> -1
+cotx081 comparetotal 2.0 -2.0 -> 1
+cotx082 comparetotal 2.0 -1.0 -> 1
+cotx083 comparetotal 2.0 0.0 -> 1
+cotx085 comparetotal 2.0 1.0 -> 1
+cotx086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+maxexponent: 999999999
+minexponent: -999999999
+cotx090 comparetotal 9.99999999E+999999999 9.99999999E+999999999 -> 0
+cotx091 comparetotal -9.99999999E+999999999 9.99999999E+999999999 -> -1
+cotx092 comparetotal 9.99999999E+999999999 -9.99999999E+999999999 -> 1
+cotx093 comparetotal -9.99999999E+999999999 -9.99999999E+999999999 -> 0
+
+-- Examples
+cotx094 comparetotal 12.73 127.9 -> -1
+cotx095 comparetotal -127 12 -> -1
+cotx096 comparetotal 12.30 12.3 -> -1
+cotx097 comparetotal 12.30 12.30 -> 0
+cotx098 comparetotal 12.3 12.300 -> 1
+cotx099 comparetotal 12.3 NaN -> -1
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+cotx100 comparetotal 7.0 7.0 -> 0
+cotx101 comparetotal 7.0 7 -> -1
+cotx102 comparetotal 7 7.0 -> 1
+cotx103 comparetotal 7E+0 7.0 -> 1
+cotx104 comparetotal 70E-1 7.0 -> 0
+cotx105 comparetotal 0.7E+1 7 -> 0
+cotx106 comparetotal 70E-1 7 -> -1
+cotx107 comparetotal 7.0 7E+0 -> -1
+cotx108 comparetotal 7.0 70E-1 -> 0
+cotx109 comparetotal 7 0.7E+1 -> 0
+cotx110 comparetotal 7 70E-1 -> 1
+
+cotx120 comparetotal 8.0 7.0 -> 1
+cotx121 comparetotal 8.0 7 -> 1
+cotx122 comparetotal 8 7.0 -> 1
+cotx123 comparetotal 8E+0 7.0 -> 1
+cotx124 comparetotal 80E-1 7.0 -> 1
+cotx125 comparetotal 0.8E+1 7 -> 1
+cotx126 comparetotal 80E-1 7 -> 1
+cotx127 comparetotal 8.0 7E+0 -> 1
+cotx128 comparetotal 8.0 70E-1 -> 1
+cotx129 comparetotal 8 0.7E+1 -> 1
+cotx130 comparetotal 8 70E-1 -> 1
+
+cotx140 comparetotal 8.0 9.0 -> -1
+cotx141 comparetotal 8.0 9 -> -1
+cotx142 comparetotal 8 9.0 -> -1
+cotx143 comparetotal 8E+0 9.0 -> -1
+cotx144 comparetotal 80E-1 9.0 -> -1
+cotx145 comparetotal 0.8E+1 9 -> -1
+cotx146 comparetotal 80E-1 9 -> -1
+cotx147 comparetotal 8.0 9E+0 -> -1
+cotx148 comparetotal 8.0 90E-1 -> -1
+cotx149 comparetotal 8 0.9E+1 -> -1
+cotx150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+cotx200 comparetotal -7.0 7.0 -> -1
+cotx201 comparetotal -7.0 7 -> -1
+cotx202 comparetotal -7 7.0 -> -1
+cotx203 comparetotal -7E+0 7.0 -> -1
+cotx204 comparetotal -70E-1 7.0 -> -1
+cotx205 comparetotal -0.7E+1 7 -> -1
+cotx206 comparetotal -70E-1 7 -> -1
+cotx207 comparetotal -7.0 7E+0 -> -1
+cotx208 comparetotal -7.0 70E-1 -> -1
+cotx209 comparetotal -7 0.7E+1 -> -1
+cotx210 comparetotal -7 70E-1 -> -1
+
+cotx220 comparetotal -8.0 7.0 -> -1
+cotx221 comparetotal -8.0 7 -> -1
+cotx222 comparetotal -8 7.0 -> -1
+cotx223 comparetotal -8E+0 7.0 -> -1
+cotx224 comparetotal -80E-1 7.0 -> -1
+cotx225 comparetotal -0.8E+1 7 -> -1
+cotx226 comparetotal -80E-1 7 -> -1
+cotx227 comparetotal -8.0 7E+0 -> -1
+cotx228 comparetotal -8.0 70E-1 -> -1
+cotx229 comparetotal -8 0.7E+1 -> -1
+cotx230 comparetotal -8 70E-1 -> -1
+
+cotx240 comparetotal -8.0 9.0 -> -1
+cotx241 comparetotal -8.0 9 -> -1
+cotx242 comparetotal -8 9.0 -> -1
+cotx243 comparetotal -8E+0 9.0 -> -1
+cotx244 comparetotal -80E-1 9.0 -> -1
+cotx245 comparetotal -0.8E+1 9 -> -1
+cotx246 comparetotal -80E-1 9 -> -1
+cotx247 comparetotal -8.0 9E+0 -> -1
+cotx248 comparetotal -8.0 90E-1 -> -1
+cotx249 comparetotal -8 0.9E+1 -> -1
+cotx250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+cotx300 comparetotal 7.0 -7.0 -> 1
+cotx301 comparetotal 7.0 -7 -> 1
+cotx302 comparetotal 7 -7.0 -> 1
+cotx303 comparetotal 7E+0 -7.0 -> 1
+cotx304 comparetotal 70E-1 -7.0 -> 1
+cotx305 comparetotal .7E+1 -7 -> 1
+cotx306 comparetotal 70E-1 -7 -> 1
+cotx307 comparetotal 7.0 -7E+0 -> 1
+cotx308 comparetotal 7.0 -70E-1 -> 1
+cotx309 comparetotal 7 -.7E+1 -> 1
+cotx310 comparetotal 7 -70E-1 -> 1
+
+cotx320 comparetotal 8.0 -7.0 -> 1
+cotx321 comparetotal 8.0 -7 -> 1
+cotx322 comparetotal 8 -7.0 -> 1
+cotx323 comparetotal 8E+0 -7.0 -> 1
+cotx324 comparetotal 80E-1 -7.0 -> 1
+cotx325 comparetotal .8E+1 -7 -> 1
+cotx326 comparetotal 80E-1 -7 -> 1
+cotx327 comparetotal 8.0 -7E+0 -> 1
+cotx328 comparetotal 8.0 -70E-1 -> 1
+cotx329 comparetotal 8 -.7E+1 -> 1
+cotx330 comparetotal 8 -70E-1 -> 1
+
+cotx340 comparetotal 8.0 -9.0 -> 1
+cotx341 comparetotal 8.0 -9 -> 1
+cotx342 comparetotal 8 -9.0 -> 1
+cotx343 comparetotal 8E+0 -9.0 -> 1
+cotx344 comparetotal 80E-1 -9.0 -> 1
+cotx345 comparetotal .8E+1 -9 -> 1
+cotx346 comparetotal 80E-1 -9 -> 1
+cotx347 comparetotal 8.0 -9E+0 -> 1
+cotx348 comparetotal 8.0 -90E-1 -> 1
+cotx349 comparetotal 8 -.9E+1 -> 1
+cotx350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+cotx400 comparetotal -7.0 -7.0 -> 0
+cotx401 comparetotal -7.0 -7 -> 1
+cotx402 comparetotal -7 -7.0 -> -1
+cotx403 comparetotal -7E+0 -7.0 -> -1
+cotx404 comparetotal -70E-1 -7.0 -> 0
+cotx405 comparetotal -.7E+1 -7 -> 0
+cotx406 comparetotal -70E-1 -7 -> 1
+cotx407 comparetotal -7.0 -7E+0 -> 1
+cotx408 comparetotal -7.0 -70E-1 -> 0
+cotx409 comparetotal -7 -.7E+1 -> 0
+cotx410 comparetotal -7 -70E-1 -> -1
+
+cotx420 comparetotal -8.0 -7.0 -> -1
+cotx421 comparetotal -8.0 -7 -> -1
+cotx422 comparetotal -8 -7.0 -> -1
+cotx423 comparetotal -8E+0 -7.0 -> -1
+cotx424 comparetotal -80E-1 -7.0 -> -1
+cotx425 comparetotal -.8E+1 -7 -> -1
+cotx426 comparetotal -80E-1 -7 -> -1
+cotx427 comparetotal -8.0 -7E+0 -> -1
+cotx428 comparetotal -8.0 -70E-1 -> -1
+cotx429 comparetotal -8 -.7E+1 -> -1
+cotx430 comparetotal -8 -70E-1 -> -1
+
+cotx440 comparetotal -8.0 -9.0 -> 1
+cotx441 comparetotal -8.0 -9 -> 1
+cotx442 comparetotal -8 -9.0 -> 1
+cotx443 comparetotal -8E+0 -9.0 -> 1
+cotx444 comparetotal -80E-1 -9.0 -> 1
+cotx445 comparetotal -.8E+1 -9 -> 1
+cotx446 comparetotal -80E-1 -9 -> 1
+cotx447 comparetotal -8.0 -9E+0 -> 1
+cotx448 comparetotal -8.0 -90E-1 -> 1
+cotx449 comparetotal -8 -.9E+1 -> 1
+cotx450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+precision: 40
+cotx470 comparetotal 123.4560000000000000E789 123.456E789 -> -1
+cotx471 comparetotal 123.456000000000000E-89 123.456E-89 -> -1
+cotx472 comparetotal 123.45600000000000E789 123.456E789 -> -1
+cotx473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+cotx474 comparetotal 123.456000000000E789 123.456E789 -> -1
+cotx475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+cotx476 comparetotal 123.4560000000E789 123.456E789 -> -1
+cotx477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+cotx478 comparetotal 123.45600000E789 123.456E789 -> -1
+cotx479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+cotx480 comparetotal 123.456000E789 123.456E789 -> -1
+cotx481 comparetotal 123.45600E-89 123.456E-89 -> -1
+cotx482 comparetotal 123.4560E789 123.456E789 -> -1
+cotx483 comparetotal 123.456E-89 123.456E-89 -> 0
+cotx484 comparetotal 123.456E-89 123.4560000000000000E-89 -> 1
+cotx485 comparetotal 123.456E789 123.456000000000000E789 -> 1
+cotx486 comparetotal 123.456E-89 123.45600000000000E-89 -> 1
+cotx487 comparetotal 123.456E789 123.4560000000000E789 -> 1
+cotx488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+cotx489 comparetotal 123.456E789 123.45600000000E789 -> 1
+cotx490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+cotx491 comparetotal 123.456E789 123.456000000E789 -> 1
+cotx492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+cotx493 comparetotal 123.456E789 123.4560000E789 -> 1
+cotx494 comparetotal 123.456E-89 123.456000E-89 -> 1
+cotx495 comparetotal 123.456E789 123.45600E789 -> 1
+cotx496 comparetotal 123.456E-89 123.4560E-89 -> 1
+cotx497 comparetotal 123.456E789 123.456E789 -> 0
+
+-- wide-ranging, around precision; signs equal
+precision: 9
+cotx500 comparetotal 1 1E-15 -> 1
+cotx501 comparetotal 1 1E-14 -> 1
+cotx502 comparetotal 1 1E-13 -> 1
+cotx503 comparetotal 1 1E-12 -> 1
+cotx504 comparetotal 1 1E-11 -> 1
+cotx505 comparetotal 1 1E-10 -> 1
+cotx506 comparetotal 1 1E-9 -> 1
+cotx507 comparetotal 1 1E-8 -> 1
+cotx508 comparetotal 1 1E-7 -> 1
+cotx509 comparetotal 1 1E-6 -> 1
+cotx510 comparetotal 1 1E-5 -> 1
+cotx511 comparetotal 1 1E-4 -> 1
+cotx512 comparetotal 1 1E-3 -> 1
+cotx513 comparetotal 1 1E-2 -> 1
+cotx514 comparetotal 1 1E-1 -> 1
+cotx515 comparetotal 1 1E-0 -> 0
+cotx516 comparetotal 1 1E+1 -> -1
+cotx517 comparetotal 1 1E+2 -> -1
+cotx518 comparetotal 1 1E+3 -> -1
+cotx519 comparetotal 1 1E+4 -> -1
+cotx521 comparetotal 1 1E+5 -> -1
+cotx522 comparetotal 1 1E+6 -> -1
+cotx523 comparetotal 1 1E+7 -> -1
+cotx524 comparetotal 1 1E+8 -> -1
+cotx525 comparetotal 1 1E+9 -> -1
+cotx526 comparetotal 1 1E+10 -> -1
+cotx527 comparetotal 1 1E+11 -> -1
+cotx528 comparetotal 1 1E+12 -> -1
+cotx529 comparetotal 1 1E+13 -> -1
+cotx530 comparetotal 1 1E+14 -> -1
+cotx531 comparetotal 1 1E+15 -> -1
+-- LR swap
+cotx540 comparetotal 1E-15 1 -> -1
+cotx541 comparetotal 1E-14 1 -> -1
+cotx542 comparetotal 1E-13 1 -> -1
+cotx543 comparetotal 1E-12 1 -> -1
+cotx544 comparetotal 1E-11 1 -> -1
+cotx545 comparetotal 1E-10 1 -> -1
+cotx546 comparetotal 1E-9 1 -> -1
+cotx547 comparetotal 1E-8 1 -> -1
+cotx548 comparetotal 1E-7 1 -> -1
+cotx549 comparetotal 1E-6 1 -> -1
+cotx550 comparetotal 1E-5 1 -> -1
+cotx551 comparetotal 1E-4 1 -> -1
+cotx552 comparetotal 1E-3 1 -> -1
+cotx553 comparetotal 1E-2 1 -> -1
+cotx554 comparetotal 1E-1 1 -> -1
+cotx555 comparetotal 1E-0 1 -> 0
+cotx556 comparetotal 1E+1 1 -> 1
+cotx557 comparetotal 1E+2 1 -> 1
+cotx558 comparetotal 1E+3 1 -> 1
+cotx559 comparetotal 1E+4 1 -> 1
+cotx561 comparetotal 1E+5 1 -> 1
+cotx562 comparetotal 1E+6 1 -> 1
+cotx563 comparetotal 1E+7 1 -> 1
+cotx564 comparetotal 1E+8 1 -> 1
+cotx565 comparetotal 1E+9 1 -> 1
+cotx566 comparetotal 1E+10 1 -> 1
+cotx567 comparetotal 1E+11 1 -> 1
+cotx568 comparetotal 1E+12 1 -> 1
+cotx569 comparetotal 1E+13 1 -> 1
+cotx570 comparetotal 1E+14 1 -> 1
+cotx571 comparetotal 1E+15 1 -> 1
+-- similar with an useful coefficient, one side only
+cotx580 comparetotal 0.000000987654321 1E-15 -> 1
+cotx581 comparetotal 0.000000987654321 1E-14 -> 1
+cotx582 comparetotal 0.000000987654321 1E-13 -> 1
+cotx583 comparetotal 0.000000987654321 1E-12 -> 1
+cotx584 comparetotal 0.000000987654321 1E-11 -> 1
+cotx585 comparetotal 0.000000987654321 1E-10 -> 1
+cotx586 comparetotal 0.000000987654321 1E-9 -> 1
+cotx587 comparetotal 0.000000987654321 1E-8 -> 1
+cotx588 comparetotal 0.000000987654321 1E-7 -> 1
+cotx589 comparetotal 0.000000987654321 1E-6 -> -1
+cotx590 comparetotal 0.000000987654321 1E-5 -> -1
+cotx591 comparetotal 0.000000987654321 1E-4 -> -1
+cotx592 comparetotal 0.000000987654321 1E-3 -> -1
+cotx593 comparetotal 0.000000987654321 1E-2 -> -1
+cotx594 comparetotal 0.000000987654321 1E-1 -> -1
+cotx595 comparetotal 0.000000987654321 1E-0 -> -1
+cotx596 comparetotal 0.000000987654321 1E+1 -> -1
+cotx597 comparetotal 0.000000987654321 1E+2 -> -1
+cotx598 comparetotal 0.000000987654321 1E+3 -> -1
+cotx599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+precision: 20
+cotx600 comparetotal 12 12.2345 -> -1
+cotx601 comparetotal 12.0 12.2345 -> -1
+cotx602 comparetotal 12.00 12.2345 -> -1
+cotx603 comparetotal 12.000 12.2345 -> -1
+cotx604 comparetotal 12.0000 12.2345 -> -1
+cotx605 comparetotal 12.00000 12.2345 -> -1
+cotx606 comparetotal 12.000000 12.2345 -> -1
+cotx607 comparetotal 12.0000000 12.2345 -> -1
+cotx608 comparetotal 12.00000000 12.2345 -> -1
+cotx609 comparetotal 12.000000000 12.2345 -> -1
+cotx610 comparetotal 12.1234 12 -> 1
+cotx611 comparetotal 12.1234 12.0 -> 1
+cotx612 comparetotal 12.1234 12.00 -> 1
+cotx613 comparetotal 12.1234 12.000 -> 1
+cotx614 comparetotal 12.1234 12.0000 -> 1
+cotx615 comparetotal 12.1234 12.00000 -> 1
+cotx616 comparetotal 12.1234 12.000000 -> 1
+cotx617 comparetotal 12.1234 12.0000000 -> 1
+cotx618 comparetotal 12.1234 12.00000000 -> 1
+cotx619 comparetotal 12.1234 12.000000000 -> 1
+cotx620 comparetotal -12 -12.2345 -> 1
+cotx621 comparetotal -12.0 -12.2345 -> 1
+cotx622 comparetotal -12.00 -12.2345 -> 1
+cotx623 comparetotal -12.000 -12.2345 -> 1
+cotx624 comparetotal -12.0000 -12.2345 -> 1
+cotx625 comparetotal -12.00000 -12.2345 -> 1
+cotx626 comparetotal -12.000000 -12.2345 -> 1
+cotx627 comparetotal -12.0000000 -12.2345 -> 1
+cotx628 comparetotal -12.00000000 -12.2345 -> 1
+cotx629 comparetotal -12.000000000 -12.2345 -> 1
+cotx630 comparetotal -12.1234 -12 -> -1
+cotx631 comparetotal -12.1234 -12.0 -> -1
+cotx632 comparetotal -12.1234 -12.00 -> -1
+cotx633 comparetotal -12.1234 -12.000 -> -1
+cotx634 comparetotal -12.1234 -12.0000 -> -1
+cotx635 comparetotal -12.1234 -12.00000 -> -1
+cotx636 comparetotal -12.1234 -12.000000 -> -1
+cotx637 comparetotal -12.1234 -12.0000000 -> -1
+cotx638 comparetotal -12.1234 -12.00000000 -> -1
+cotx639 comparetotal -12.1234 -12.000000000 -> -1
+precision: 9
+
+-- extended zeros
+cotx640 comparetotal 0 0 -> 0
+cotx641 comparetotal 0 -0 -> 1
+cotx642 comparetotal 0 -0.0 -> 1
+cotx643 comparetotal 0 0.0 -> 1
+cotx644 comparetotal -0 0 -> -1
+cotx645 comparetotal -0 -0 -> 0
+cotx646 comparetotal -0 -0.0 -> -1
+cotx647 comparetotal -0 0.0 -> -1
+cotx648 comparetotal 0.0 0 -> -1
+cotx649 comparetotal 0.0 -0 -> 1
+cotx650 comparetotal 0.0 -0.0 -> 1
+cotx651 comparetotal 0.0 0.0 -> 0
+cotx652 comparetotal -0.0 0 -> -1
+cotx653 comparetotal -0.0 -0 -> 1
+cotx654 comparetotal -0.0 -0.0 -> 0
+cotx655 comparetotal -0.0 0.0 -> -1
+
+cotx656 comparetotal -0E1 0.0 -> -1
+cotx657 comparetotal -0E2 0.0 -> -1
+cotx658 comparetotal 0E1 0.0 -> 1
+cotx659 comparetotal 0E2 0.0 -> 1
+cotx660 comparetotal -0E1 0 -> -1
+cotx661 comparetotal -0E2 0 -> -1
+cotx662 comparetotal 0E1 0 -> 1
+cotx663 comparetotal 0E2 0 -> 1
+cotx664 comparetotal -0E1 -0E1 -> 0
+cotx665 comparetotal -0E2 -0E1 -> -1
+cotx666 comparetotal 0E1 -0E1 -> 1
+cotx667 comparetotal 0E2 -0E1 -> 1
+cotx668 comparetotal -0E1 -0E2 -> 1
+cotx669 comparetotal -0E2 -0E2 -> 0
+cotx670 comparetotal 0E1 -0E2 -> 1
+cotx671 comparetotal 0E2 -0E2 -> 1
+cotx672 comparetotal -0E1 0E1 -> -1
+cotx673 comparetotal -0E2 0E1 -> -1
+cotx674 comparetotal 0E1 0E1 -> 0
+cotx675 comparetotal 0E2 0E1 -> 1
+cotx676 comparetotal -0E1 0E2 -> -1
+cotx677 comparetotal -0E2 0E2 -> -1
+cotx678 comparetotal 0E1 0E2 -> -1
+cotx679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+precision: 20
+cotx680 comparetotal 12 12 -> 0
+cotx681 comparetotal 12 12.0 -> 1
+cotx682 comparetotal 12 12.00 -> 1
+cotx683 comparetotal 12 12.000 -> 1
+cotx684 comparetotal 12 12.0000 -> 1
+cotx685 comparetotal 12 12.00000 -> 1
+cotx686 comparetotal 12 12.000000 -> 1
+cotx687 comparetotal 12 12.0000000 -> 1
+cotx688 comparetotal 12 12.00000000 -> 1
+cotx689 comparetotal 12 12.000000000 -> 1
+cotx690 comparetotal 12 12 -> 0
+cotx691 comparetotal 12.0 12 -> -1
+cotx692 comparetotal 12.00 12 -> -1
+cotx693 comparetotal 12.000 12 -> -1
+cotx694 comparetotal 12.0000 12 -> -1
+cotx695 comparetotal 12.00000 12 -> -1
+cotx696 comparetotal 12.000000 12 -> -1
+cotx697 comparetotal 12.0000000 12 -> -1
+cotx698 comparetotal 12.00000000 12 -> -1
+cotx699 comparetotal 12.000000000 12 -> -1
+
+-- long operand checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+cotx701 comparetotal 12345678000 1 -> 1
+cotx702 comparetotal 1 12345678000 -> -1
+cotx703 comparetotal 1234567800 1 -> 1
+cotx704 comparetotal 1 1234567800 -> -1
+cotx705 comparetotal 1234567890 1 -> 1
+cotx706 comparetotal 1 1234567890 -> -1
+cotx707 comparetotal 1234567891 1 -> 1
+cotx708 comparetotal 1 1234567891 -> -1
+cotx709 comparetotal 12345678901 1 -> 1
+cotx710 comparetotal 1 12345678901 -> -1
+cotx711 comparetotal 1234567896 1 -> 1
+cotx712 comparetotal 1 1234567896 -> -1
+cotx713 comparetotal -1234567891 1 -> -1
+cotx714 comparetotal 1 -1234567891 -> 1
+cotx715 comparetotal -12345678901 1 -> -1
+cotx716 comparetotal 1 -12345678901 -> 1
+cotx717 comparetotal -1234567896 1 -> -1
+cotx718 comparetotal 1 -1234567896 -> 1
+
+precision: 15
+-- same with plenty of precision
+cotx721 comparetotal 12345678000 1 -> 1
+cotx722 comparetotal 1 12345678000 -> -1
+cotx723 comparetotal 1234567800 1 -> 1
+cotx724 comparetotal 1 1234567800 -> -1
+cotx725 comparetotal 1234567890 1 -> 1
+cotx726 comparetotal 1 1234567890 -> -1
+cotx727 comparetotal 1234567891 1 -> 1
+cotx728 comparetotal 1 1234567891 -> -1
+cotx729 comparetotal 12345678901 1 -> 1
+cotx730 comparetotal 1 12345678901 -> -1
+cotx731 comparetotal 1234567896 1 -> 1
+cotx732 comparetotal 1 1234567896 -> -1
+
+-- residue cases
+precision: 5
+cotx740 comparetotal 1 0.9999999 -> 1
+cotx741 comparetotal 1 0.999999 -> 1
+cotx742 comparetotal 1 0.99999 -> 1
+cotx743 comparetotal 1 1.0000 -> 1
+cotx744 comparetotal 1 1.00001 -> -1
+cotx745 comparetotal 1 1.000001 -> -1
+cotx746 comparetotal 1 1.0000001 -> -1
+cotx750 comparetotal 0.9999999 1 -> -1
+cotx751 comparetotal 0.999999 1 -> -1
+cotx752 comparetotal 0.99999 1 -> -1
+cotx753 comparetotal 1.0000 1 -> -1
+cotx754 comparetotal 1.00001 1 -> 1
+cotx755 comparetotal 1.000001 1 -> 1
+cotx756 comparetotal 1.0000001 1 -> 1
+
+-- a selection of longies
+cotx760 comparetotal -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> -1
+cotx761 comparetotal -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
+cotx762 comparetotal -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> -1
+cotx763 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+-- precisions above or below the difference should have no effect
+precision: 11
+cotx764 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 10
+cotx765 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 9
+cotx766 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 8
+cotx767 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 7
+cotx768 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 6
+cotx769 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 5
+cotx770 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 4
+cotx771 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 3
+cotx772 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 2
+cotx773 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+precision: 1
+cotx774 comparetotal -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> 1
+
+-- Specials
+precision: 9
+cotx780 comparetotal Inf -Inf -> 1
+cotx781 comparetotal Inf -1000 -> 1
+cotx782 comparetotal Inf -1 -> 1
+cotx783 comparetotal Inf -0 -> 1
+cotx784 comparetotal Inf 0 -> 1
+cotx785 comparetotal Inf 1 -> 1
+cotx786 comparetotal Inf 1000 -> 1
+cotx787 comparetotal Inf Inf -> 0
+cotx788 comparetotal -1000 Inf -> -1
+cotx789 comparetotal -Inf Inf -> -1
+cotx790 comparetotal -1 Inf -> -1
+cotx791 comparetotal -0 Inf -> -1
+cotx792 comparetotal 0 Inf -> -1
+cotx793 comparetotal 1 Inf -> -1
+cotx794 comparetotal 1000 Inf -> -1
+cotx795 comparetotal Inf Inf -> 0
+
+cotx800 comparetotal -Inf -Inf -> 0
+cotx801 comparetotal -Inf -1000 -> -1
+cotx802 comparetotal -Inf -1 -> -1
+cotx803 comparetotal -Inf -0 -> -1
+cotx804 comparetotal -Inf 0 -> -1
+cotx805 comparetotal -Inf 1 -> -1
+cotx806 comparetotal -Inf 1000 -> -1
+cotx807 comparetotal -Inf Inf -> -1
+cotx808 comparetotal -Inf -Inf -> 0
+cotx809 comparetotal -1000 -Inf -> 1
+cotx810 comparetotal -1 -Inf -> 1
+cotx811 comparetotal -0 -Inf -> 1
+cotx812 comparetotal 0 -Inf -> 1
+cotx813 comparetotal 1 -Inf -> 1
+cotx814 comparetotal 1000 -Inf -> 1
+cotx815 comparetotal Inf -Inf -> 1
+
+cotx821 comparetotal NaN -Inf -> 1
+cotx822 comparetotal NaN -1000 -> 1
+cotx823 comparetotal NaN -1 -> 1
+cotx824 comparetotal NaN -0 -> 1
+cotx825 comparetotal NaN 0 -> 1
+cotx826 comparetotal NaN 1 -> 1
+cotx827 comparetotal NaN 1000 -> 1
+cotx828 comparetotal NaN Inf -> 1
+cotx829 comparetotal NaN NaN -> 0
+cotx830 comparetotal -Inf NaN -> -1
+cotx831 comparetotal -1000 NaN -> -1
+cotx832 comparetotal -1 NaN -> -1
+cotx833 comparetotal -0 NaN -> -1
+cotx834 comparetotal 0 NaN -> -1
+cotx835 comparetotal 1 NaN -> -1
+cotx836 comparetotal 1000 NaN -> -1
+cotx837 comparetotal Inf NaN -> -1
+cotx838 comparetotal -NaN -NaN -> 0
+cotx839 comparetotal +NaN -NaN -> 1
+cotx840 comparetotal -NaN +NaN -> -1
+
+cotx841 comparetotal sNaN -sNaN -> 1
+cotx842 comparetotal sNaN -NaN -> 1
+cotx843 comparetotal sNaN -Inf -> 1
+cotx844 comparetotal sNaN -1000 -> 1
+cotx845 comparetotal sNaN -1 -> 1
+cotx846 comparetotal sNaN -0 -> 1
+cotx847 comparetotal sNaN 0 -> 1
+cotx848 comparetotal sNaN 1 -> 1
+cotx849 comparetotal sNaN 1000 -> 1
+cotx850 comparetotal sNaN NaN -> -1
+cotx851 comparetotal sNaN sNaN -> 0
+
+cotx852 comparetotal -sNaN sNaN -> -1
+cotx853 comparetotal -NaN sNaN -> -1
+cotx854 comparetotal -Inf sNaN -> -1
+cotx855 comparetotal -1000 sNaN -> -1
+cotx856 comparetotal -1 sNaN -> -1
+cotx857 comparetotal -0 sNaN -> -1
+cotx858 comparetotal 0 sNaN -> -1
+cotx859 comparetotal 1 sNaN -> -1
+cotx860 comparetotal 1000 sNaN -> -1
+cotx861 comparetotal Inf sNaN -> -1
+cotx862 comparetotal NaN sNaN -> 1
+cotx863 comparetotal sNaN sNaN -> 0
+
+cotx871 comparetotal -sNaN -sNaN -> 0
+cotx872 comparetotal -sNaN -NaN -> 1
+cotx873 comparetotal -sNaN -Inf -> -1
+cotx874 comparetotal -sNaN -1000 -> -1
+cotx875 comparetotal -sNaN -1 -> -1
+cotx876 comparetotal -sNaN -0 -> -1
+cotx877 comparetotal -sNaN 0 -> -1
+cotx878 comparetotal -sNaN 1 -> -1
+cotx879 comparetotal -sNaN 1000 -> -1
+cotx880 comparetotal -sNaN NaN -> -1
+cotx881 comparetotal -sNaN sNaN -> -1
+
+cotx882 comparetotal -sNaN -sNaN -> 0
+cotx883 comparetotal -NaN -sNaN -> -1
+cotx884 comparetotal -Inf -sNaN -> 1
+cotx885 comparetotal -1000 -sNaN -> 1
+cotx886 comparetotal -1 -sNaN -> 1
+cotx887 comparetotal -0 -sNaN -> 1
+cotx888 comparetotal 0 -sNaN -> 1
+cotx889 comparetotal 1 -sNaN -> 1
+cotx890 comparetotal 1000 -sNaN -> 1
+cotx891 comparetotal Inf -sNaN -> 1
+cotx892 comparetotal NaN -sNaN -> 1
+cotx893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+cotx960 comparetotal NaN9 -Inf -> 1
+cotx961 comparetotal NaN8 999 -> 1
+cotx962 comparetotal NaN77 Inf -> 1
+cotx963 comparetotal -NaN67 NaN5 -> -1
+cotx964 comparetotal -Inf -NaN4 -> 1
+cotx965 comparetotal -999 -NaN33 -> 1
+cotx966 comparetotal Inf NaN2 -> -1
+
+cotx970 comparetotal -NaN41 -NaN42 -> 1
+cotx971 comparetotal +NaN41 -NaN42 -> 1
+cotx972 comparetotal -NaN41 +NaN42 -> -1
+cotx973 comparetotal +NaN41 +NaN42 -> -1
+cotx974 comparetotal -NaN42 -NaN01 -> -1
+cotx975 comparetotal +NaN42 -NaN01 -> 1
+cotx976 comparetotal -NaN42 +NaN01 -> -1
+cotx977 comparetotal +NaN42 +NaN01 -> 1
+
+cotx980 comparetotal -sNaN771 -sNaN772 -> 1
+cotx981 comparetotal +sNaN771 -sNaN772 -> 1
+cotx982 comparetotal -sNaN771 +sNaN772 -> -1
+cotx983 comparetotal +sNaN771 +sNaN772 -> -1
+cotx984 comparetotal -sNaN772 -sNaN771 -> -1
+cotx985 comparetotal +sNaN772 -sNaN771 -> 1
+cotx986 comparetotal -sNaN772 +sNaN771 -> -1
+cotx987 comparetotal +sNaN772 +sNaN771 -> 1
+
+cotx991 comparetotal -sNaN99 -Inf -> -1
+cotx992 comparetotal sNaN98 -11 -> 1
+cotx993 comparetotal sNaN97 NaN -> -1
+cotx994 comparetotal sNaN16 sNaN94 -> -1
+cotx995 comparetotal NaN85 sNaN83 -> 1
+cotx996 comparetotal -Inf sNaN92 -> -1
+cotx997 comparetotal 088 sNaN81 -> -1
+cotx998 comparetotal Inf sNaN90 -> -1
+cotx999 comparetotal NaN -sNaN89 -> 1
+
+-- overflow and underflow tests .. subnormal results now allowed
+maxExponent: 999999999
+minexponent: -999999999
+cotx1080 comparetotal +1.23456789012345E-0 9E+999999999 -> -1
+cotx1081 comparetotal 9E+999999999 +1.23456789012345E-0 -> 1
+cotx1082 comparetotal +0.100 9E-999999999 -> 1
+cotx1083 comparetotal 9E-999999999 +0.100 -> -1
+cotx1085 comparetotal -1.23456789012345E-0 9E+999999999 -> -1
+cotx1086 comparetotal 9E+999999999 -1.23456789012345E-0 -> 1
+cotx1087 comparetotal -0.100 9E-999999999 -> -1
+cotx1088 comparetotal 9E-999999999 -0.100 -> 1
+
+cotx1089 comparetotal 1e-599999999 1e-400000001 -> -1
+cotx1090 comparetotal 1e-599999999 1e-400000000 -> -1
+cotx1091 comparetotal 1e-600000000 1e-400000000 -> -1
+cotx1092 comparetotal 9e-999999998 0.01 -> -1
+cotx1093 comparetotal 9e-999999998 0.1 -> -1
+cotx1094 comparetotal 0.01 9e-999999998 -> 1
+cotx1095 comparetotal 1e599999999 1e400000001 -> 1
+cotx1096 comparetotal 1e599999999 1e400000000 -> 1
+cotx1097 comparetotal 1e600000000 1e400000000 -> 1
+cotx1098 comparetotal 9e999999998 100 -> 1
+cotx1099 comparetotal 9e999999998 10 -> 1
+cotx1100 comparetotal 100 9e999999998 -> -1
+-- signs
+cotx1101 comparetotal 1e+777777777 1e+411111111 -> 1
+cotx1102 comparetotal 1e+777777777 -1e+411111111 -> 1
+cotx1103 comparetotal -1e+777777777 1e+411111111 -> -1
+cotx1104 comparetotal -1e+777777777 -1e+411111111 -> -1
+cotx1105 comparetotal 1e-777777777 1e-411111111 -> -1
+cotx1106 comparetotal 1e-777777777 -1e-411111111 -> 1
+cotx1107 comparetotal -1e-777777777 1e-411111111 -> -1
+cotx1108 comparetotal -1e-777777777 -1e-411111111 -> 1
+
+-- spread zeros
+cotx1110 comparetotal 0E-383 0 -> -1
+cotx1111 comparetotal 0E-383 -0 -> 1
+cotx1112 comparetotal -0E-383 0 -> -1
+cotx1113 comparetotal -0E-383 -0 -> 1
+cotx1114 comparetotal 0E-383 0E+384 -> -1
+cotx1115 comparetotal 0E-383 -0E+384 -> 1
+cotx1116 comparetotal -0E-383 0E+384 -> -1
+cotx1117 comparetotal -0E-383 -0E+384 -> 1
+cotx1118 comparetotal 0 0E+384 -> -1
+cotx1119 comparetotal 0 -0E+384 -> 1
+cotx1120 comparetotal -0 0E+384 -> -1
+cotx1121 comparetotal -0 -0E+384 -> 1
+
+cotx1130 comparetotal 0E+384 0 -> 1
+cotx1131 comparetotal 0E+384 -0 -> 1
+cotx1132 comparetotal -0E+384 0 -> -1
+cotx1133 comparetotal -0E+384 -0 -> -1
+cotx1134 comparetotal 0E+384 0E-383 -> 1
+cotx1135 comparetotal 0E+384 -0E-383 -> 1
+cotx1136 comparetotal -0E+384 0E-383 -> -1
+cotx1137 comparetotal -0E+384 -0E-383 -> -1
+cotx1138 comparetotal 0 0E-383 -> 1
+cotx1139 comparetotal 0 -0E-383 -> 1
+cotx1140 comparetotal -0 0E-383 -> -1
+cotx1141 comparetotal -0 -0E-383 -> -1
+
+-- Null tests
+cotx9990 comparetotal 10 # -> NaN Invalid_operation
+cotx9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/comparetotmag.decTest b/Lib/test/decimaltestdata/comparetotmag.decTest
index cedfdf8843a..e87c9f2dbf2 100644
--- a/Lib/test/decimaltestdata/comparetotmag.decTest
+++ b/Lib/test/decimaltestdata/comparetotmag.decTest
@@ -1,790 +1,790 @@
-------------------------------------------------------------------------
--- comparetotmag.decTest -- decimal comparison, abs. total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that it cannot be assumed that add/subtract tests cover paths
--- for this operation adequately, here, because the code might be
--- quite different (comparison cannot overflow or underflow, so
--- actual subtractions are not necessary). Similarly, comparetotal
--- will have some radically different paths than compare.
-
-extended: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- sanity checks
-ctmx001 comparetotmag -2 -2 -> 0
-ctmx002 comparetotmag -2 -1 -> 1
-ctmx003 comparetotmag -2 0 -> 1
-ctmx004 comparetotmag -2 1 -> 1
-ctmx005 comparetotmag -2 2 -> 0
-ctmx006 comparetotmag -1 -2 -> -1
-ctmx007 comparetotmag -1 -1 -> 0
-ctmx008 comparetotmag -1 0 -> 1
-ctmx009 comparetotmag -1 1 -> 0
-ctmx010 comparetotmag -1 2 -> -1
-ctmx011 comparetotmag 0 -2 -> -1
-ctmx012 comparetotmag 0 -1 -> -1
-ctmx013 comparetotmag 0 0 -> 0
-ctmx014 comparetotmag 0 1 -> -1
-ctmx015 comparetotmag 0 2 -> -1
-ctmx016 comparetotmag 1 -2 -> -1
-ctmx017 comparetotmag 1 -1 -> 0
-ctmx018 comparetotmag 1 0 -> 1
-ctmx019 comparetotmag 1 1 -> 0
-ctmx020 comparetotmag 1 2 -> -1
-ctmx021 comparetotmag 2 -2 -> 0
-ctmx022 comparetotmag 2 -1 -> 1
-ctmx023 comparetotmag 2 0 -> 1
-ctmx025 comparetotmag 2 1 -> 1
-ctmx026 comparetotmag 2 2 -> 0
-
-ctmx031 comparetotmag -20 -20 -> 0
-ctmx032 comparetotmag -20 -10 -> 1
-ctmx033 comparetotmag -20 00 -> 1
-ctmx034 comparetotmag -20 10 -> 1
-ctmx035 comparetotmag -20 20 -> 0
-ctmx036 comparetotmag -10 -20 -> -1
-ctmx037 comparetotmag -10 -10 -> 0
-ctmx038 comparetotmag -10 00 -> 1
-ctmx039 comparetotmag -10 10 -> 0
-ctmx040 comparetotmag -10 20 -> -1
-ctmx041 comparetotmag 00 -20 -> -1
-ctmx042 comparetotmag 00 -10 -> -1
-ctmx043 comparetotmag 00 00 -> 0
-ctmx044 comparetotmag 00 10 -> -1
-ctmx045 comparetotmag 00 20 -> -1
-ctmx046 comparetotmag 10 -20 -> -1
-ctmx047 comparetotmag 10 -10 -> 0
-ctmx048 comparetotmag 10 00 -> 1
-ctmx049 comparetotmag 10 10 -> 0
-ctmx050 comparetotmag 10 20 -> -1
-ctmx051 comparetotmag 20 -20 -> 0
-ctmx052 comparetotmag 20 -10 -> 1
-ctmx053 comparetotmag 20 00 -> 1
-ctmx055 comparetotmag 20 10 -> 1
-ctmx056 comparetotmag 20 20 -> 0
-
-ctmx061 comparetotmag -2.0 -2.0 -> 0
-ctmx062 comparetotmag -2.0 -1.0 -> 1
-ctmx063 comparetotmag -2.0 0.0 -> 1
-ctmx064 comparetotmag -2.0 1.0 -> 1
-ctmx065 comparetotmag -2.0 2.0 -> 0
-ctmx066 comparetotmag -1.0 -2.0 -> -1
-ctmx067 comparetotmag -1.0 -1.0 -> 0
-ctmx068 comparetotmag -1.0 0.0 -> 1
-ctmx069 comparetotmag -1.0 1.0 -> 0
-ctmx070 comparetotmag -1.0 2.0 -> -1
-ctmx071 comparetotmag 0.0 -2.0 -> -1
-ctmx072 comparetotmag 0.0 -1.0 -> -1
-ctmx073 comparetotmag 0.0 0.0 -> 0
-ctmx074 comparetotmag 0.0 1.0 -> -1
-ctmx075 comparetotmag 0.0 2.0 -> -1
-ctmx076 comparetotmag 1.0 -2.0 -> -1
-ctmx077 comparetotmag 1.0 -1.0 -> 0
-ctmx078 comparetotmag 1.0 0.0 -> 1
-ctmx079 comparetotmag 1.0 1.0 -> 0
-ctmx080 comparetotmag 1.0 2.0 -> -1
-ctmx081 comparetotmag 2.0 -2.0 -> 0
-ctmx082 comparetotmag 2.0 -1.0 -> 1
-ctmx083 comparetotmag 2.0 0.0 -> 1
-ctmx085 comparetotmag 2.0 1.0 -> 1
-ctmx086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-maxexponent: 999999999
-minexponent: -999999999
-ctmx090 comparetotmag 9.99999999E+999999999 9.99999999E+999999999 -> 0
-ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999 -> 0
-ctmx092 comparetotmag 9.99999999E+999999999 -9.99999999E+999999999 -> 0
-ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ctmx100 comparetotmag 7.0 7.0 -> 0
-ctmx101 comparetotmag 7.0 7 -> -1
-ctmx102 comparetotmag 7 7.0 -> 1
-ctmx103 comparetotmag 7E+0 7.0 -> 1
-ctmx104 comparetotmag 70E-1 7.0 -> 0
-ctmx105 comparetotmag 0.7E+1 7 -> 0
-ctmx106 comparetotmag 70E-1 7 -> -1
-ctmx107 comparetotmag 7.0 7E+0 -> -1
-ctmx108 comparetotmag 7.0 70E-1 -> 0
-ctmx109 comparetotmag 7 0.7E+1 -> 0
-ctmx110 comparetotmag 7 70E-1 -> 1
-
-ctmx120 comparetotmag 8.0 7.0 -> 1
-ctmx121 comparetotmag 8.0 7 -> 1
-ctmx122 comparetotmag 8 7.0 -> 1
-ctmx123 comparetotmag 8E+0 7.0 -> 1
-ctmx124 comparetotmag 80E-1 7.0 -> 1
-ctmx125 comparetotmag 0.8E+1 7 -> 1
-ctmx126 comparetotmag 80E-1 7 -> 1
-ctmx127 comparetotmag 8.0 7E+0 -> 1
-ctmx128 comparetotmag 8.0 70E-1 -> 1
-ctmx129 comparetotmag 8 0.7E+1 -> 1
-ctmx130 comparetotmag 8 70E-1 -> 1
-
-ctmx140 comparetotmag 8.0 9.0 -> -1
-ctmx141 comparetotmag 8.0 9 -> -1
-ctmx142 comparetotmag 8 9.0 -> -1
-ctmx143 comparetotmag 8E+0 9.0 -> -1
-ctmx144 comparetotmag 80E-1 9.0 -> -1
-ctmx145 comparetotmag 0.8E+1 9 -> -1
-ctmx146 comparetotmag 80E-1 9 -> -1
-ctmx147 comparetotmag 8.0 9E+0 -> -1
-ctmx148 comparetotmag 8.0 90E-1 -> -1
-ctmx149 comparetotmag 8 0.9E+1 -> -1
-ctmx150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ctmx200 comparetotmag -7.0 7.0 -> 0
-ctmx201 comparetotmag -7.0 7 -> -1
-ctmx202 comparetotmag -7 7.0 -> 1
-ctmx203 comparetotmag -7E+0 7.0 -> 1
-ctmx204 comparetotmag -70E-1 7.0 -> 0
-ctmx205 comparetotmag -0.7E+1 7 -> 0
-ctmx206 comparetotmag -70E-1 7 -> -1
-ctmx207 comparetotmag -7.0 7E+0 -> -1
-ctmx208 comparetotmag -7.0 70E-1 -> 0
-ctmx209 comparetotmag -7 0.7E+1 -> 0
-ctmx210 comparetotmag -7 70E-1 -> 1
-
-ctmx220 comparetotmag -8.0 7.0 -> 1
-ctmx221 comparetotmag -8.0 7 -> 1
-ctmx222 comparetotmag -8 7.0 -> 1
-ctmx223 comparetotmag -8E+0 7.0 -> 1
-ctmx224 comparetotmag -80E-1 7.0 -> 1
-ctmx225 comparetotmag -0.8E+1 7 -> 1
-ctmx226 comparetotmag -80E-1 7 -> 1
-ctmx227 comparetotmag -8.0 7E+0 -> 1
-ctmx228 comparetotmag -8.0 70E-1 -> 1
-ctmx229 comparetotmag -8 0.7E+1 -> 1
-ctmx230 comparetotmag -8 70E-1 -> 1
-
-ctmx240 comparetotmag -8.0 9.0 -> -1
-ctmx241 comparetotmag -8.0 9 -> -1
-ctmx242 comparetotmag -8 9.0 -> -1
-ctmx243 comparetotmag -8E+0 9.0 -> -1
-ctmx244 comparetotmag -80E-1 9.0 -> -1
-ctmx245 comparetotmag -0.8E+1 9 -> -1
-ctmx246 comparetotmag -80E-1 9 -> -1
-ctmx247 comparetotmag -8.0 9E+0 -> -1
-ctmx248 comparetotmag -8.0 90E-1 -> -1
-ctmx249 comparetotmag -8 0.9E+1 -> -1
-ctmx250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ctmx300 comparetotmag 7.0 -7.0 -> 0
-ctmx301 comparetotmag 7.0 -7 -> -1
-ctmx302 comparetotmag 7 -7.0 -> 1
-ctmx303 comparetotmag 7E+0 -7.0 -> 1
-ctmx304 comparetotmag 70E-1 -7.0 -> 0
-ctmx305 comparetotmag .7E+1 -7 -> 0
-ctmx306 comparetotmag 70E-1 -7 -> -1
-ctmx307 comparetotmag 7.0 -7E+0 -> -1
-ctmx308 comparetotmag 7.0 -70E-1 -> 0
-ctmx309 comparetotmag 7 -.7E+1 -> 0
-ctmx310 comparetotmag 7 -70E-1 -> 1
-
-ctmx320 comparetotmag 8.0 -7.0 -> 1
-ctmx321 comparetotmag 8.0 -7 -> 1
-ctmx322 comparetotmag 8 -7.0 -> 1
-ctmx323 comparetotmag 8E+0 -7.0 -> 1
-ctmx324 comparetotmag 80E-1 -7.0 -> 1
-ctmx325 comparetotmag .8E+1 -7 -> 1
-ctmx326 comparetotmag 80E-1 -7 -> 1
-ctmx327 comparetotmag 8.0 -7E+0 -> 1
-ctmx328 comparetotmag 8.0 -70E-1 -> 1
-ctmx329 comparetotmag 8 -.7E+1 -> 1
-ctmx330 comparetotmag 8 -70E-1 -> 1
-
-ctmx340 comparetotmag 8.0 -9.0 -> -1
-ctmx341 comparetotmag 8.0 -9 -> -1
-ctmx342 comparetotmag 8 -9.0 -> -1
-ctmx343 comparetotmag 8E+0 -9.0 -> -1
-ctmx344 comparetotmag 80E-1 -9.0 -> -1
-ctmx345 comparetotmag .8E+1 -9 -> -1
-ctmx346 comparetotmag 80E-1 -9 -> -1
-ctmx347 comparetotmag 8.0 -9E+0 -> -1
-ctmx348 comparetotmag 8.0 -90E-1 -> -1
-ctmx349 comparetotmag 8 -.9E+1 -> -1
-ctmx350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-ctmx400 comparetotmag -7.0 -7.0 -> 0
-ctmx401 comparetotmag -7.0 -7 -> -1
-ctmx402 comparetotmag -7 -7.0 -> 1
-ctmx403 comparetotmag -7E+0 -7.0 -> 1
-ctmx404 comparetotmag -70E-1 -7.0 -> 0
-ctmx405 comparetotmag -.7E+1 -7 -> 0
-ctmx406 comparetotmag -70E-1 -7 -> -1
-ctmx407 comparetotmag -7.0 -7E+0 -> -1
-ctmx408 comparetotmag -7.0 -70E-1 -> 0
-ctmx409 comparetotmag -7 -.7E+1 -> 0
-ctmx410 comparetotmag -7 -70E-1 -> 1
-
-ctmx420 comparetotmag -8.0 -7.0 -> 1
-ctmx421 comparetotmag -8.0 -7 -> 1
-ctmx422 comparetotmag -8 -7.0 -> 1
-ctmx423 comparetotmag -8E+0 -7.0 -> 1
-ctmx424 comparetotmag -80E-1 -7.0 -> 1
-ctmx425 comparetotmag -.8E+1 -7 -> 1
-ctmx426 comparetotmag -80E-1 -7 -> 1
-ctmx427 comparetotmag -8.0 -7E+0 -> 1
-ctmx428 comparetotmag -8.0 -70E-1 -> 1
-ctmx429 comparetotmag -8 -.7E+1 -> 1
-ctmx430 comparetotmag -8 -70E-1 -> 1
-
-ctmx440 comparetotmag -8.0 -9.0 -> -1
-ctmx441 comparetotmag -8.0 -9 -> -1
-ctmx442 comparetotmag -8 -9.0 -> -1
-ctmx443 comparetotmag -8E+0 -9.0 -> -1
-ctmx444 comparetotmag -80E-1 -9.0 -> -1
-ctmx445 comparetotmag -.8E+1 -9 -> -1
-ctmx446 comparetotmag -80E-1 -9 -> -1
-ctmx447 comparetotmag -8.0 -9E+0 -> -1
-ctmx448 comparetotmag -8.0 -90E-1 -> -1
-ctmx449 comparetotmag -8 -.9E+1 -> -1
-ctmx450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-precision: 40
-ctmx470 comparetotmag 123.4560000000000000E789 123.456E789 -> -1
-ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89 -> -1
-ctmx472 comparetotmag 123.45600000000000E789 123.456E789 -> -1
-ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-ctmx474 comparetotmag 123.456000000000E789 123.456E789 -> -1
-ctmx475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-ctmx476 comparetotmag 123.4560000000E789 123.456E789 -> -1
-ctmx477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-ctmx478 comparetotmag 123.45600000E789 123.456E789 -> -1
-ctmx479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-ctmx480 comparetotmag 123.456000E789 123.456E789 -> -1
-ctmx481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-ctmx482 comparetotmag 123.4560E789 123.456E789 -> -1
-ctmx483 comparetotmag 123.456E-89 123.456E-89 -> 0
-ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89 -> 1
-ctmx485 comparetotmag 123.456E789 123.456000000000000E789 -> 1
-ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89 -> 1
-ctmx487 comparetotmag 123.456E789 123.4560000000000E789 -> 1
-ctmx488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-ctmx489 comparetotmag 123.456E789 123.45600000000E789 -> 1
-ctmx490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-ctmx491 comparetotmag 123.456E789 123.456000000E789 -> 1
-ctmx492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-ctmx493 comparetotmag 123.456E789 123.4560000E789 -> 1
-ctmx494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-ctmx495 comparetotmag 123.456E789 123.45600E789 -> 1
-ctmx496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-ctmx497 comparetotmag 123.456E789 123.456E789 -> 0
-
--- wide-ranging, around precision; signs equal
-precision: 9
-ctmx500 comparetotmag 1 1E-15 -> 1
-ctmx501 comparetotmag 1 1E-14 -> 1
-ctmx502 comparetotmag 1 1E-13 -> 1
-ctmx503 comparetotmag 1 1E-12 -> 1
-ctmx504 comparetotmag 1 1E-11 -> 1
-ctmx505 comparetotmag 1 1E-10 -> 1
-ctmx506 comparetotmag 1 1E-9 -> 1
-ctmx507 comparetotmag 1 1E-8 -> 1
-ctmx508 comparetotmag 1 1E-7 -> 1
-ctmx509 comparetotmag 1 1E-6 -> 1
-ctmx510 comparetotmag 1 1E-5 -> 1
-ctmx511 comparetotmag 1 1E-4 -> 1
-ctmx512 comparetotmag 1 1E-3 -> 1
-ctmx513 comparetotmag 1 1E-2 -> 1
-ctmx514 comparetotmag 1 1E-1 -> 1
-ctmx515 comparetotmag 1 1E-0 -> 0
-ctmx516 comparetotmag 1 1E+1 -> -1
-ctmx517 comparetotmag 1 1E+2 -> -1
-ctmx518 comparetotmag 1 1E+3 -> -1
-ctmx519 comparetotmag 1 1E+4 -> -1
-ctmx521 comparetotmag 1 1E+5 -> -1
-ctmx522 comparetotmag 1 1E+6 -> -1
-ctmx523 comparetotmag 1 1E+7 -> -1
-ctmx524 comparetotmag 1 1E+8 -> -1
-ctmx525 comparetotmag 1 1E+9 -> -1
-ctmx526 comparetotmag 1 1E+10 -> -1
-ctmx527 comparetotmag 1 1E+11 -> -1
-ctmx528 comparetotmag 1 1E+12 -> -1
-ctmx529 comparetotmag 1 1E+13 -> -1
-ctmx530 comparetotmag 1 1E+14 -> -1
-ctmx531 comparetotmag 1 1E+15 -> -1
--- LR swap
-ctmx540 comparetotmag 1E-15 1 -> -1
-ctmx541 comparetotmag 1E-14 1 -> -1
-ctmx542 comparetotmag 1E-13 1 -> -1
-ctmx543 comparetotmag 1E-12 1 -> -1
-ctmx544 comparetotmag 1E-11 1 -> -1
-ctmx545 comparetotmag 1E-10 1 -> -1
-ctmx546 comparetotmag 1E-9 1 -> -1
-ctmx547 comparetotmag 1E-8 1 -> -1
-ctmx548 comparetotmag 1E-7 1 -> -1
-ctmx549 comparetotmag 1E-6 1 -> -1
-ctmx550 comparetotmag 1E-5 1 -> -1
-ctmx551 comparetotmag 1E-4 1 -> -1
-ctmx552 comparetotmag 1E-3 1 -> -1
-ctmx553 comparetotmag 1E-2 1 -> -1
-ctmx554 comparetotmag 1E-1 1 -> -1
-ctmx555 comparetotmag 1E-0 1 -> 0
-ctmx556 comparetotmag 1E+1 1 -> 1
-ctmx557 comparetotmag 1E+2 1 -> 1
-ctmx558 comparetotmag 1E+3 1 -> 1
-ctmx559 comparetotmag 1E+4 1 -> 1
-ctmx561 comparetotmag 1E+5 1 -> 1
-ctmx562 comparetotmag 1E+6 1 -> 1
-ctmx563 comparetotmag 1E+7 1 -> 1
-ctmx564 comparetotmag 1E+8 1 -> 1
-ctmx565 comparetotmag 1E+9 1 -> 1
-ctmx566 comparetotmag 1E+10 1 -> 1
-ctmx567 comparetotmag 1E+11 1 -> 1
-ctmx568 comparetotmag 1E+12 1 -> 1
-ctmx569 comparetotmag 1E+13 1 -> 1
-ctmx570 comparetotmag 1E+14 1 -> 1
-ctmx571 comparetotmag 1E+15 1 -> 1
--- similar with an useful coefficient, one side only
-ctmx580 comparetotmag 0.000000987654321 1E-15 -> 1
-ctmx581 comparetotmag 0.000000987654321 1E-14 -> 1
-ctmx582 comparetotmag 0.000000987654321 1E-13 -> 1
-ctmx583 comparetotmag 0.000000987654321 1E-12 -> 1
-ctmx584 comparetotmag 0.000000987654321 1E-11 -> 1
-ctmx585 comparetotmag 0.000000987654321 1E-10 -> 1
-ctmx586 comparetotmag 0.000000987654321 1E-9 -> 1
-ctmx587 comparetotmag 0.000000987654321 1E-8 -> 1
-ctmx588 comparetotmag 0.000000987654321 1E-7 -> 1
-ctmx589 comparetotmag 0.000000987654321 1E-6 -> -1
-ctmx590 comparetotmag 0.000000987654321 1E-5 -> -1
-ctmx591 comparetotmag 0.000000987654321 1E-4 -> -1
-ctmx592 comparetotmag 0.000000987654321 1E-3 -> -1
-ctmx593 comparetotmag 0.000000987654321 1E-2 -> -1
-ctmx594 comparetotmag 0.000000987654321 1E-1 -> -1
-ctmx595 comparetotmag 0.000000987654321 1E-0 -> -1
-ctmx596 comparetotmag 0.000000987654321 1E+1 -> -1
-ctmx597 comparetotmag 0.000000987654321 1E+2 -> -1
-ctmx598 comparetotmag 0.000000987654321 1E+3 -> -1
-ctmx599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-precision: 20
-ctmx600 comparetotmag 12 12.2345 -> -1
-ctmx601 comparetotmag 12.0 12.2345 -> -1
-ctmx602 comparetotmag 12.00 12.2345 -> -1
-ctmx603 comparetotmag 12.000 12.2345 -> -1
-ctmx604 comparetotmag 12.0000 12.2345 -> -1
-ctmx605 comparetotmag 12.00000 12.2345 -> -1
-ctmx606 comparetotmag 12.000000 12.2345 -> -1
-ctmx607 comparetotmag 12.0000000 12.2345 -> -1
-ctmx608 comparetotmag 12.00000000 12.2345 -> -1
-ctmx609 comparetotmag 12.000000000 12.2345 -> -1
-ctmx610 comparetotmag 12.1234 12 -> 1
-ctmx611 comparetotmag 12.1234 12.0 -> 1
-ctmx612 comparetotmag 12.1234 12.00 -> 1
-ctmx613 comparetotmag 12.1234 12.000 -> 1
-ctmx614 comparetotmag 12.1234 12.0000 -> 1
-ctmx615 comparetotmag 12.1234 12.00000 -> 1
-ctmx616 comparetotmag 12.1234 12.000000 -> 1
-ctmx617 comparetotmag 12.1234 12.0000000 -> 1
-ctmx618 comparetotmag 12.1234 12.00000000 -> 1
-ctmx619 comparetotmag 12.1234 12.000000000 -> 1
-ctmx620 comparetotmag -12 -12.2345 -> -1
-ctmx621 comparetotmag -12.0 -12.2345 -> -1
-ctmx622 comparetotmag -12.00 -12.2345 -> -1
-ctmx623 comparetotmag -12.000 -12.2345 -> -1
-ctmx624 comparetotmag -12.0000 -12.2345 -> -1
-ctmx625 comparetotmag -12.00000 -12.2345 -> -1
-ctmx626 comparetotmag -12.000000 -12.2345 -> -1
-ctmx627 comparetotmag -12.0000000 -12.2345 -> -1
-ctmx628 comparetotmag -12.00000000 -12.2345 -> -1
-ctmx629 comparetotmag -12.000000000 -12.2345 -> -1
-ctmx630 comparetotmag -12.1234 -12 -> 1
-ctmx631 comparetotmag -12.1234 -12.0 -> 1
-ctmx632 comparetotmag -12.1234 -12.00 -> 1
-ctmx633 comparetotmag -12.1234 -12.000 -> 1
-ctmx634 comparetotmag -12.1234 -12.0000 -> 1
-ctmx635 comparetotmag -12.1234 -12.00000 -> 1
-ctmx636 comparetotmag -12.1234 -12.000000 -> 1
-ctmx637 comparetotmag -12.1234 -12.0000000 -> 1
-ctmx638 comparetotmag -12.1234 -12.00000000 -> 1
-ctmx639 comparetotmag -12.1234 -12.000000000 -> 1
-precision: 9
-
--- extended zeros
-ctmx640 comparetotmag 0 0 -> 0
-ctmx641 comparetotmag 0 -0 -> 0
-ctmx642 comparetotmag 0 -0.0 -> 1
-ctmx643 comparetotmag 0 0.0 -> 1
-ctmx644 comparetotmag -0 0 -> 0
-ctmx645 comparetotmag -0 -0 -> 0
-ctmx646 comparetotmag -0 -0.0 -> 1
-ctmx647 comparetotmag -0 0.0 -> 1
-ctmx648 comparetotmag 0.0 0 -> -1
-ctmx649 comparetotmag 0.0 -0 -> -1
-ctmx650 comparetotmag 0.0 -0.0 -> 0
-ctmx651 comparetotmag 0.0 0.0 -> 0
-ctmx652 comparetotmag -0.0 0 -> -1
-ctmx653 comparetotmag -0.0 -0 -> -1
-ctmx654 comparetotmag -0.0 -0.0 -> 0
-ctmx655 comparetotmag -0.0 0.0 -> 0
-
-ctmx656 comparetotmag -0E1 0.0 -> 1
-ctmx657 comparetotmag -0E2 0.0 -> 1
-ctmx658 comparetotmag 0E1 0.0 -> 1
-ctmx659 comparetotmag 0E2 0.0 -> 1
-ctmx660 comparetotmag -0E1 0 -> 1
-ctmx661 comparetotmag -0E2 0 -> 1
-ctmx662 comparetotmag 0E1 0 -> 1
-ctmx663 comparetotmag 0E2 0 -> 1
-ctmx664 comparetotmag -0E1 -0E1 -> 0
-ctmx665 comparetotmag -0E2 -0E1 -> 1
-ctmx666 comparetotmag 0E1 -0E1 -> 0
-ctmx667 comparetotmag 0E2 -0E1 -> 1
-ctmx668 comparetotmag -0E1 -0E2 -> -1
-ctmx669 comparetotmag -0E2 -0E2 -> 0
-ctmx670 comparetotmag 0E1 -0E2 -> -1
-ctmx671 comparetotmag 0E2 -0E2 -> 0
-ctmx672 comparetotmag -0E1 0E1 -> 0
-ctmx673 comparetotmag -0E2 0E1 -> 1
-ctmx674 comparetotmag 0E1 0E1 -> 0
-ctmx675 comparetotmag 0E2 0E1 -> 1
-ctmx676 comparetotmag -0E1 0E2 -> -1
-ctmx677 comparetotmag -0E2 0E2 -> 0
-ctmx678 comparetotmag 0E1 0E2 -> -1
-ctmx679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-precision: 20
-ctmx680 comparetotmag 12 12 -> 0
-ctmx681 comparetotmag 12 12.0 -> 1
-ctmx682 comparetotmag 12 12.00 -> 1
-ctmx683 comparetotmag 12 12.000 -> 1
-ctmx684 comparetotmag 12 12.0000 -> 1
-ctmx685 comparetotmag 12 12.00000 -> 1
-ctmx686 comparetotmag 12 12.000000 -> 1
-ctmx687 comparetotmag 12 12.0000000 -> 1
-ctmx688 comparetotmag 12 12.00000000 -> 1
-ctmx689 comparetotmag 12 12.000000000 -> 1
-ctmx690 comparetotmag 12 12 -> 0
-ctmx691 comparetotmag 12.0 12 -> -1
-ctmx692 comparetotmag 12.00 12 -> -1
-ctmx693 comparetotmag 12.000 12 -> -1
-ctmx694 comparetotmag 12.0000 12 -> -1
-ctmx695 comparetotmag 12.00000 12 -> -1
-ctmx696 comparetotmag 12.000000 12 -> -1
-ctmx697 comparetotmag 12.0000000 12 -> -1
-ctmx698 comparetotmag 12.00000000 12 -> -1
-ctmx699 comparetotmag 12.000000000 12 -> -1
-
--- long operand checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-ctmx701 comparetotmag 12345678000 1 -> 1
-ctmx702 comparetotmag 1 12345678000 -> -1
-ctmx703 comparetotmag 1234567800 1 -> 1
-ctmx704 comparetotmag 1 1234567800 -> -1
-ctmx705 comparetotmag 1234567890 1 -> 1
-ctmx706 comparetotmag 1 1234567890 -> -1
-ctmx707 comparetotmag 1234567891 1 -> 1
-ctmx708 comparetotmag 1 1234567891 -> -1
-ctmx709 comparetotmag 12345678901 1 -> 1
-ctmx710 comparetotmag 1 12345678901 -> -1
-ctmx711 comparetotmag 1234567896 1 -> 1
-ctmx712 comparetotmag 1 1234567896 -> -1
-ctmx713 comparetotmag -1234567891 1 -> 1
-ctmx714 comparetotmag 1 -1234567891 -> -1
-ctmx715 comparetotmag -12345678901 1 -> 1
-ctmx716 comparetotmag 1 -12345678901 -> -1
-ctmx717 comparetotmag -1234567896 1 -> 1
-ctmx718 comparetotmag 1 -1234567896 -> -1
-
-precision: 15
--- same with plenty of precision
-ctmx721 comparetotmag 12345678000 1 -> 1
-ctmx722 comparetotmag 1 12345678000 -> -1
-ctmx723 comparetotmag 1234567800 1 -> 1
-ctmx724 comparetotmag 1 1234567800 -> -1
-ctmx725 comparetotmag 1234567890 1 -> 1
-ctmx726 comparetotmag 1 1234567890 -> -1
-ctmx727 comparetotmag 1234567891 1 -> 1
-ctmx728 comparetotmag 1 1234567891 -> -1
-ctmx729 comparetotmag 12345678901 1 -> 1
-ctmx730 comparetotmag 1 12345678901 -> -1
-ctmx731 comparetotmag 1234567896 1 -> 1
-ctmx732 comparetotmag 1 1234567896 -> -1
-
--- residue cases
-precision: 5
-ctmx740 comparetotmag 1 0.9999999 -> 1
-ctmx741 comparetotmag 1 0.999999 -> 1
-ctmx742 comparetotmag 1 0.99999 -> 1
-ctmx743 comparetotmag 1 1.0000 -> 1
-ctmx744 comparetotmag 1 1.00001 -> -1
-ctmx745 comparetotmag 1 1.000001 -> -1
-ctmx746 comparetotmag 1 1.0000001 -> -1
-ctmx750 comparetotmag 0.9999999 1 -> -1
-ctmx751 comparetotmag 0.999999 1 -> -1
-ctmx752 comparetotmag 0.99999 1 -> -1
-ctmx753 comparetotmag 1.0000 1 -> -1
-ctmx754 comparetotmag 1.00001 1 -> 1
-ctmx755 comparetotmag 1.000001 1 -> 1
-ctmx756 comparetotmag 1.0000001 1 -> 1
-
--- a selection of longies
-ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> 1
-ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
-ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> 1
-ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
--- precisions above or below the difference should have no effect
-precision: 11
-ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 10
-ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 9
-ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 8
-ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 7
-ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 6
-ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 5
-ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 4
-ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 3
-ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 2
-ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-precision: 1
-ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
-
--- Specials
-precision: 9
-ctmx780 comparetotmag Inf -Inf -> 0
-ctmx781 comparetotmag Inf -1000 -> 1
-ctmx782 comparetotmag Inf -1 -> 1
-ctmx783 comparetotmag Inf -0 -> 1
-ctmx784 comparetotmag Inf 0 -> 1
-ctmx785 comparetotmag Inf 1 -> 1
-ctmx786 comparetotmag Inf 1000 -> 1
-ctmx787 comparetotmag Inf Inf -> 0
-ctmx788 comparetotmag -1000 Inf -> -1
-ctmx789 comparetotmag -Inf Inf -> 0
-ctmx790 comparetotmag -1 Inf -> -1
-ctmx791 comparetotmag -0 Inf -> -1
-ctmx792 comparetotmag 0 Inf -> -1
-ctmx793 comparetotmag 1 Inf -> -1
-ctmx794 comparetotmag 1000 Inf -> -1
-ctmx795 comparetotmag Inf Inf -> 0
-
-ctmx800 comparetotmag -Inf -Inf -> 0
-ctmx801 comparetotmag -Inf -1000 -> 1
-ctmx802 comparetotmag -Inf -1 -> 1
-ctmx803 comparetotmag -Inf -0 -> 1
-ctmx804 comparetotmag -Inf 0 -> 1
-ctmx805 comparetotmag -Inf 1 -> 1
-ctmx806 comparetotmag -Inf 1000 -> 1
-ctmx807 comparetotmag -Inf Inf -> 0
-ctmx808 comparetotmag -Inf -Inf -> 0
-ctmx809 comparetotmag -1000 -Inf -> -1
-ctmx810 comparetotmag -1 -Inf -> -1
-ctmx811 comparetotmag -0 -Inf -> -1
-ctmx812 comparetotmag 0 -Inf -> -1
-ctmx813 comparetotmag 1 -Inf -> -1
-ctmx814 comparetotmag 1000 -Inf -> -1
-ctmx815 comparetotmag Inf -Inf -> 0
-
-ctmx821 comparetotmag NaN -Inf -> 1
-ctmx822 comparetotmag NaN -1000 -> 1
-ctmx823 comparetotmag NaN -1 -> 1
-ctmx824 comparetotmag NaN -0 -> 1
-ctmx825 comparetotmag NaN 0 -> 1
-ctmx826 comparetotmag NaN 1 -> 1
-ctmx827 comparetotmag NaN 1000 -> 1
-ctmx828 comparetotmag NaN Inf -> 1
-ctmx829 comparetotmag NaN NaN -> 0
-ctmx830 comparetotmag -Inf NaN -> -1
-ctmx831 comparetotmag -1000 NaN -> -1
-ctmx832 comparetotmag -1 NaN -> -1
-ctmx833 comparetotmag -0 NaN -> -1
-ctmx834 comparetotmag 0 NaN -> -1
-ctmx835 comparetotmag 1 NaN -> -1
-ctmx836 comparetotmag 1000 NaN -> -1
-ctmx837 comparetotmag Inf NaN -> -1
-ctmx838 comparetotmag -NaN -NaN -> 0
-ctmx839 comparetotmag +NaN -NaN -> 0
-ctmx840 comparetotmag -NaN +NaN -> 0
-
-ctmx841 comparetotmag sNaN -sNaN -> 0
-ctmx842 comparetotmag sNaN -NaN -> -1
-ctmx843 comparetotmag sNaN -Inf -> 1
-ctmx844 comparetotmag sNaN -1000 -> 1
-ctmx845 comparetotmag sNaN -1 -> 1
-ctmx846 comparetotmag sNaN -0 -> 1
-ctmx847 comparetotmag sNaN 0 -> 1
-ctmx848 comparetotmag sNaN 1 -> 1
-ctmx849 comparetotmag sNaN 1000 -> 1
-ctmx850 comparetotmag sNaN NaN -> -1
-ctmx851 comparetotmag sNaN sNaN -> 0
-
-ctmx852 comparetotmag -sNaN sNaN -> 0
-ctmx853 comparetotmag -NaN sNaN -> 1
-ctmx854 comparetotmag -Inf sNaN -> -1
-ctmx855 comparetotmag -1000 sNaN -> -1
-ctmx856 comparetotmag -1 sNaN -> -1
-ctmx857 comparetotmag -0 sNaN -> -1
-ctmx858 comparetotmag 0 sNaN -> -1
-ctmx859 comparetotmag 1 sNaN -> -1
-ctmx860 comparetotmag 1000 sNaN -> -1
-ctmx861 comparetotmag Inf sNaN -> -1
-ctmx862 comparetotmag NaN sNaN -> 1
-ctmx863 comparetotmag sNaN sNaN -> 0
-
-ctmx871 comparetotmag -sNaN -sNaN -> 0
-ctmx872 comparetotmag -sNaN -NaN -> -1
-ctmx873 comparetotmag -sNaN -Inf -> 1
-ctmx874 comparetotmag -sNaN -1000 -> 1
-ctmx875 comparetotmag -sNaN -1 -> 1
-ctmx876 comparetotmag -sNaN -0 -> 1
-ctmx877 comparetotmag -sNaN 0 -> 1
-ctmx878 comparetotmag -sNaN 1 -> 1
-ctmx879 comparetotmag -sNaN 1000 -> 1
-ctmx880 comparetotmag -sNaN NaN -> -1
-ctmx881 comparetotmag -sNaN sNaN -> 0
-
-ctmx882 comparetotmag -sNaN -sNaN -> 0
-ctmx883 comparetotmag -NaN -sNaN -> 1
-ctmx884 comparetotmag -Inf -sNaN -> -1
-ctmx885 comparetotmag -1000 -sNaN -> -1
-ctmx886 comparetotmag -1 -sNaN -> -1
-ctmx887 comparetotmag -0 -sNaN -> -1
-ctmx888 comparetotmag 0 -sNaN -> -1
-ctmx889 comparetotmag 1 -sNaN -> -1
-ctmx890 comparetotmag 1000 -sNaN -> -1
-ctmx891 comparetotmag Inf -sNaN -> -1
-ctmx892 comparetotmag NaN -sNaN -> 1
-ctmx893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-ctmx960 comparetotmag NaN9 -Inf -> 1
-ctmx961 comparetotmag NaN8 999 -> 1
-ctmx962 comparetotmag NaN77 Inf -> 1
-ctmx963 comparetotmag -NaN67 NaN5 -> 1
-ctmx964 comparetotmag -Inf -NaN4 -> -1
-ctmx965 comparetotmag -999 -NaN33 -> -1
-ctmx966 comparetotmag Inf NaN2 -> -1
-
-ctmx970 comparetotmag -NaN41 -NaN42 -> -1
-ctmx971 comparetotmag +NaN41 -NaN42 -> -1
-ctmx972 comparetotmag -NaN41 +NaN42 -> -1
-ctmx973 comparetotmag +NaN41 +NaN42 -> -1
-ctmx974 comparetotmag -NaN42 -NaN01 -> 1
-ctmx975 comparetotmag +NaN42 -NaN01 -> 1
-ctmx976 comparetotmag -NaN42 +NaN01 -> 1
-ctmx977 comparetotmag +NaN42 +NaN01 -> 1
-
-ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
-ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
-ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
-ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
-ctmx984 comparetotmag -sNaN772 -sNaN771 -> 1
-ctmx985 comparetotmag +sNaN772 -sNaN771 -> 1
-ctmx986 comparetotmag -sNaN772 +sNaN771 -> 1
-ctmx987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-ctmx991 comparetotmag -sNaN99 -Inf -> 1
-ctmx992 comparetotmag sNaN98 -11 -> 1
-ctmx993 comparetotmag sNaN97 NaN -> -1
-ctmx994 comparetotmag sNaN16 sNaN94 -> -1
-ctmx995 comparetotmag NaN85 sNaN83 -> 1
-ctmx996 comparetotmag -Inf sNaN92 -> -1
-ctmx997 comparetotmag 088 sNaN81 -> -1
-ctmx998 comparetotmag Inf sNaN90 -> -1
-ctmx999 comparetotmag NaN -sNaN89 -> 1
-
--- overflow and underflow tests .. subnormal results now allowed
-maxExponent: 999999999
-minexponent: -999999999
-ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999 -> -1
-ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0 -> 1
-ctmx1082 comparetotmag +0.100 9E-999999999 -> 1
-ctmx1083 comparetotmag 9E-999999999 +0.100 -> -1
-ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999 -> -1
-ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0 -> 1
-ctmx1087 comparetotmag -0.100 9E-999999999 -> 1
-ctmx1088 comparetotmag 9E-999999999 -0.100 -> -1
-
-ctmx1089 comparetotmag 1e-599999999 1e-400000001 -> -1
-ctmx1090 comparetotmag 1e-599999999 1e-400000000 -> -1
-ctmx1091 comparetotmag 1e-600000000 1e-400000000 -> -1
-ctmx1092 comparetotmag 9e-999999998 0.01 -> -1
-ctmx1093 comparetotmag 9e-999999998 0.1 -> -1
-ctmx1094 comparetotmag 0.01 9e-999999998 -> 1
-ctmx1095 comparetotmag 1e599999999 1e400000001 -> 1
-ctmx1096 comparetotmag 1e599999999 1e400000000 -> 1
-ctmx1097 comparetotmag 1e600000000 1e400000000 -> 1
-ctmx1098 comparetotmag 9e999999998 100 -> 1
-ctmx1099 comparetotmag 9e999999998 10 -> 1
-ctmx1100 comparetotmag 100 9e999999998 -> -1
--- signs
-ctmx1101 comparetotmag 1e+777777777 1e+411111111 -> 1
-ctmx1102 comparetotmag 1e+777777777 -1e+411111111 -> 1
-ctmx1103 comparetotmag -1e+777777777 1e+411111111 -> 1
-ctmx1104 comparetotmag -1e+777777777 -1e+411111111 -> 1
-ctmx1105 comparetotmag 1e-777777777 1e-411111111 -> -1
-ctmx1106 comparetotmag 1e-777777777 -1e-411111111 -> -1
-ctmx1107 comparetotmag -1e-777777777 1e-411111111 -> -1
-ctmx1108 comparetotmag -1e-777777777 -1e-411111111 -> -1
-
--- spread zeros
-ctmx1110 comparetotmag 0E-383 0 -> -1
-ctmx1111 comparetotmag 0E-383 -0 -> -1
-ctmx1112 comparetotmag -0E-383 0 -> -1
-ctmx1113 comparetotmag -0E-383 -0 -> -1
-ctmx1114 comparetotmag 0E-383 0E+384 -> -1
-ctmx1115 comparetotmag 0E-383 -0E+384 -> -1
-ctmx1116 comparetotmag -0E-383 0E+384 -> -1
-ctmx1117 comparetotmag -0E-383 -0E+384 -> -1
-ctmx1118 comparetotmag 0 0E+384 -> -1
-ctmx1119 comparetotmag 0 -0E+384 -> -1
-ctmx1120 comparetotmag -0 0E+384 -> -1
-ctmx1121 comparetotmag -0 -0E+384 -> -1
-
-ctmx1130 comparetotmag 0E+384 0 -> 1
-ctmx1131 comparetotmag 0E+384 -0 -> 1
-ctmx1132 comparetotmag -0E+384 0 -> 1
-ctmx1133 comparetotmag -0E+384 -0 -> 1
-ctmx1134 comparetotmag 0E+384 0E-383 -> 1
-ctmx1135 comparetotmag 0E+384 -0E-383 -> 1
-ctmx1136 comparetotmag -0E+384 0E-383 -> 1
-ctmx1137 comparetotmag -0E+384 -0E-383 -> 1
-ctmx1138 comparetotmag 0 0E-383 -> 1
-ctmx1139 comparetotmag 0 -0E-383 -> 1
-ctmx1140 comparetotmag -0 0E-383 -> 1
-ctmx1141 comparetotmag -0 -0E-383 -> 1
-
--- Null tests
-ctmx9990 comparetotmag 10 # -> NaN Invalid_operation
-ctmx9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- comparetotmag.decTest -- decimal comparison, abs. total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that it cannot be assumed that add/subtract tests cover paths
+-- for this operation adequately, here, because the code might be
+-- quite different (comparison cannot overflow or underflow, so
+-- actual subtractions are not necessary). Similarly, comparetotal
+-- will have some radically different paths than compare.
+
+extended: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- sanity checks
+ctmx001 comparetotmag -2 -2 -> 0
+ctmx002 comparetotmag -2 -1 -> 1
+ctmx003 comparetotmag -2 0 -> 1
+ctmx004 comparetotmag -2 1 -> 1
+ctmx005 comparetotmag -2 2 -> 0
+ctmx006 comparetotmag -1 -2 -> -1
+ctmx007 comparetotmag -1 -1 -> 0
+ctmx008 comparetotmag -1 0 -> 1
+ctmx009 comparetotmag -1 1 -> 0
+ctmx010 comparetotmag -1 2 -> -1
+ctmx011 comparetotmag 0 -2 -> -1
+ctmx012 comparetotmag 0 -1 -> -1
+ctmx013 comparetotmag 0 0 -> 0
+ctmx014 comparetotmag 0 1 -> -1
+ctmx015 comparetotmag 0 2 -> -1
+ctmx016 comparetotmag 1 -2 -> -1
+ctmx017 comparetotmag 1 -1 -> 0
+ctmx018 comparetotmag 1 0 -> 1
+ctmx019 comparetotmag 1 1 -> 0
+ctmx020 comparetotmag 1 2 -> -1
+ctmx021 comparetotmag 2 -2 -> 0
+ctmx022 comparetotmag 2 -1 -> 1
+ctmx023 comparetotmag 2 0 -> 1
+ctmx025 comparetotmag 2 1 -> 1
+ctmx026 comparetotmag 2 2 -> 0
+
+ctmx031 comparetotmag -20 -20 -> 0
+ctmx032 comparetotmag -20 -10 -> 1
+ctmx033 comparetotmag -20 00 -> 1
+ctmx034 comparetotmag -20 10 -> 1
+ctmx035 comparetotmag -20 20 -> 0
+ctmx036 comparetotmag -10 -20 -> -1
+ctmx037 comparetotmag -10 -10 -> 0
+ctmx038 comparetotmag -10 00 -> 1
+ctmx039 comparetotmag -10 10 -> 0
+ctmx040 comparetotmag -10 20 -> -1
+ctmx041 comparetotmag 00 -20 -> -1
+ctmx042 comparetotmag 00 -10 -> -1
+ctmx043 comparetotmag 00 00 -> 0
+ctmx044 comparetotmag 00 10 -> -1
+ctmx045 comparetotmag 00 20 -> -1
+ctmx046 comparetotmag 10 -20 -> -1
+ctmx047 comparetotmag 10 -10 -> 0
+ctmx048 comparetotmag 10 00 -> 1
+ctmx049 comparetotmag 10 10 -> 0
+ctmx050 comparetotmag 10 20 -> -1
+ctmx051 comparetotmag 20 -20 -> 0
+ctmx052 comparetotmag 20 -10 -> 1
+ctmx053 comparetotmag 20 00 -> 1
+ctmx055 comparetotmag 20 10 -> 1
+ctmx056 comparetotmag 20 20 -> 0
+
+ctmx061 comparetotmag -2.0 -2.0 -> 0
+ctmx062 comparetotmag -2.0 -1.0 -> 1
+ctmx063 comparetotmag -2.0 0.0 -> 1
+ctmx064 comparetotmag -2.0 1.0 -> 1
+ctmx065 comparetotmag -2.0 2.0 -> 0
+ctmx066 comparetotmag -1.0 -2.0 -> -1
+ctmx067 comparetotmag -1.0 -1.0 -> 0
+ctmx068 comparetotmag -1.0 0.0 -> 1
+ctmx069 comparetotmag -1.0 1.0 -> 0
+ctmx070 comparetotmag -1.0 2.0 -> -1
+ctmx071 comparetotmag 0.0 -2.0 -> -1
+ctmx072 comparetotmag 0.0 -1.0 -> -1
+ctmx073 comparetotmag 0.0 0.0 -> 0
+ctmx074 comparetotmag 0.0 1.0 -> -1
+ctmx075 comparetotmag 0.0 2.0 -> -1
+ctmx076 comparetotmag 1.0 -2.0 -> -1
+ctmx077 comparetotmag 1.0 -1.0 -> 0
+ctmx078 comparetotmag 1.0 0.0 -> 1
+ctmx079 comparetotmag 1.0 1.0 -> 0
+ctmx080 comparetotmag 1.0 2.0 -> -1
+ctmx081 comparetotmag 2.0 -2.0 -> 0
+ctmx082 comparetotmag 2.0 -1.0 -> 1
+ctmx083 comparetotmag 2.0 0.0 -> 1
+ctmx085 comparetotmag 2.0 1.0 -> 1
+ctmx086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+maxexponent: 999999999
+minexponent: -999999999
+ctmx090 comparetotmag 9.99999999E+999999999 9.99999999E+999999999 -> 0
+ctmx091 comparetotmag -9.99999999E+999999999 9.99999999E+999999999 -> 0
+ctmx092 comparetotmag 9.99999999E+999999999 -9.99999999E+999999999 -> 0
+ctmx093 comparetotmag -9.99999999E+999999999 -9.99999999E+999999999 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ctmx100 comparetotmag 7.0 7.0 -> 0
+ctmx101 comparetotmag 7.0 7 -> -1
+ctmx102 comparetotmag 7 7.0 -> 1
+ctmx103 comparetotmag 7E+0 7.0 -> 1
+ctmx104 comparetotmag 70E-1 7.0 -> 0
+ctmx105 comparetotmag 0.7E+1 7 -> 0
+ctmx106 comparetotmag 70E-1 7 -> -1
+ctmx107 comparetotmag 7.0 7E+0 -> -1
+ctmx108 comparetotmag 7.0 70E-1 -> 0
+ctmx109 comparetotmag 7 0.7E+1 -> 0
+ctmx110 comparetotmag 7 70E-1 -> 1
+
+ctmx120 comparetotmag 8.0 7.0 -> 1
+ctmx121 comparetotmag 8.0 7 -> 1
+ctmx122 comparetotmag 8 7.0 -> 1
+ctmx123 comparetotmag 8E+0 7.0 -> 1
+ctmx124 comparetotmag 80E-1 7.0 -> 1
+ctmx125 comparetotmag 0.8E+1 7 -> 1
+ctmx126 comparetotmag 80E-1 7 -> 1
+ctmx127 comparetotmag 8.0 7E+0 -> 1
+ctmx128 comparetotmag 8.0 70E-1 -> 1
+ctmx129 comparetotmag 8 0.7E+1 -> 1
+ctmx130 comparetotmag 8 70E-1 -> 1
+
+ctmx140 comparetotmag 8.0 9.0 -> -1
+ctmx141 comparetotmag 8.0 9 -> -1
+ctmx142 comparetotmag 8 9.0 -> -1
+ctmx143 comparetotmag 8E+0 9.0 -> -1
+ctmx144 comparetotmag 80E-1 9.0 -> -1
+ctmx145 comparetotmag 0.8E+1 9 -> -1
+ctmx146 comparetotmag 80E-1 9 -> -1
+ctmx147 comparetotmag 8.0 9E+0 -> -1
+ctmx148 comparetotmag 8.0 90E-1 -> -1
+ctmx149 comparetotmag 8 0.9E+1 -> -1
+ctmx150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ctmx200 comparetotmag -7.0 7.0 -> 0
+ctmx201 comparetotmag -7.0 7 -> -1
+ctmx202 comparetotmag -7 7.0 -> 1
+ctmx203 comparetotmag -7E+0 7.0 -> 1
+ctmx204 comparetotmag -70E-1 7.0 -> 0
+ctmx205 comparetotmag -0.7E+1 7 -> 0
+ctmx206 comparetotmag -70E-1 7 -> -1
+ctmx207 comparetotmag -7.0 7E+0 -> -1
+ctmx208 comparetotmag -7.0 70E-1 -> 0
+ctmx209 comparetotmag -7 0.7E+1 -> 0
+ctmx210 comparetotmag -7 70E-1 -> 1
+
+ctmx220 comparetotmag -8.0 7.0 -> 1
+ctmx221 comparetotmag -8.0 7 -> 1
+ctmx222 comparetotmag -8 7.0 -> 1
+ctmx223 comparetotmag -8E+0 7.0 -> 1
+ctmx224 comparetotmag -80E-1 7.0 -> 1
+ctmx225 comparetotmag -0.8E+1 7 -> 1
+ctmx226 comparetotmag -80E-1 7 -> 1
+ctmx227 comparetotmag -8.0 7E+0 -> 1
+ctmx228 comparetotmag -8.0 70E-1 -> 1
+ctmx229 comparetotmag -8 0.7E+1 -> 1
+ctmx230 comparetotmag -8 70E-1 -> 1
+
+ctmx240 comparetotmag -8.0 9.0 -> -1
+ctmx241 comparetotmag -8.0 9 -> -1
+ctmx242 comparetotmag -8 9.0 -> -1
+ctmx243 comparetotmag -8E+0 9.0 -> -1
+ctmx244 comparetotmag -80E-1 9.0 -> -1
+ctmx245 comparetotmag -0.8E+1 9 -> -1
+ctmx246 comparetotmag -80E-1 9 -> -1
+ctmx247 comparetotmag -8.0 9E+0 -> -1
+ctmx248 comparetotmag -8.0 90E-1 -> -1
+ctmx249 comparetotmag -8 0.9E+1 -> -1
+ctmx250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ctmx300 comparetotmag 7.0 -7.0 -> 0
+ctmx301 comparetotmag 7.0 -7 -> -1
+ctmx302 comparetotmag 7 -7.0 -> 1
+ctmx303 comparetotmag 7E+0 -7.0 -> 1
+ctmx304 comparetotmag 70E-1 -7.0 -> 0
+ctmx305 comparetotmag .7E+1 -7 -> 0
+ctmx306 comparetotmag 70E-1 -7 -> -1
+ctmx307 comparetotmag 7.0 -7E+0 -> -1
+ctmx308 comparetotmag 7.0 -70E-1 -> 0
+ctmx309 comparetotmag 7 -.7E+1 -> 0
+ctmx310 comparetotmag 7 -70E-1 -> 1
+
+ctmx320 comparetotmag 8.0 -7.0 -> 1
+ctmx321 comparetotmag 8.0 -7 -> 1
+ctmx322 comparetotmag 8 -7.0 -> 1
+ctmx323 comparetotmag 8E+0 -7.0 -> 1
+ctmx324 comparetotmag 80E-1 -7.0 -> 1
+ctmx325 comparetotmag .8E+1 -7 -> 1
+ctmx326 comparetotmag 80E-1 -7 -> 1
+ctmx327 comparetotmag 8.0 -7E+0 -> 1
+ctmx328 comparetotmag 8.0 -70E-1 -> 1
+ctmx329 comparetotmag 8 -.7E+1 -> 1
+ctmx330 comparetotmag 8 -70E-1 -> 1
+
+ctmx340 comparetotmag 8.0 -9.0 -> -1
+ctmx341 comparetotmag 8.0 -9 -> -1
+ctmx342 comparetotmag 8 -9.0 -> -1
+ctmx343 comparetotmag 8E+0 -9.0 -> -1
+ctmx344 comparetotmag 80E-1 -9.0 -> -1
+ctmx345 comparetotmag .8E+1 -9 -> -1
+ctmx346 comparetotmag 80E-1 -9 -> -1
+ctmx347 comparetotmag 8.0 -9E+0 -> -1
+ctmx348 comparetotmag 8.0 -90E-1 -> -1
+ctmx349 comparetotmag 8 -.9E+1 -> -1
+ctmx350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+ctmx400 comparetotmag -7.0 -7.0 -> 0
+ctmx401 comparetotmag -7.0 -7 -> -1
+ctmx402 comparetotmag -7 -7.0 -> 1
+ctmx403 comparetotmag -7E+0 -7.0 -> 1
+ctmx404 comparetotmag -70E-1 -7.0 -> 0
+ctmx405 comparetotmag -.7E+1 -7 -> 0
+ctmx406 comparetotmag -70E-1 -7 -> -1
+ctmx407 comparetotmag -7.0 -7E+0 -> -1
+ctmx408 comparetotmag -7.0 -70E-1 -> 0
+ctmx409 comparetotmag -7 -.7E+1 -> 0
+ctmx410 comparetotmag -7 -70E-1 -> 1
+
+ctmx420 comparetotmag -8.0 -7.0 -> 1
+ctmx421 comparetotmag -8.0 -7 -> 1
+ctmx422 comparetotmag -8 -7.0 -> 1
+ctmx423 comparetotmag -8E+0 -7.0 -> 1
+ctmx424 comparetotmag -80E-1 -7.0 -> 1
+ctmx425 comparetotmag -.8E+1 -7 -> 1
+ctmx426 comparetotmag -80E-1 -7 -> 1
+ctmx427 comparetotmag -8.0 -7E+0 -> 1
+ctmx428 comparetotmag -8.0 -70E-1 -> 1
+ctmx429 comparetotmag -8 -.7E+1 -> 1
+ctmx430 comparetotmag -8 -70E-1 -> 1
+
+ctmx440 comparetotmag -8.0 -9.0 -> -1
+ctmx441 comparetotmag -8.0 -9 -> -1
+ctmx442 comparetotmag -8 -9.0 -> -1
+ctmx443 comparetotmag -8E+0 -9.0 -> -1
+ctmx444 comparetotmag -80E-1 -9.0 -> -1
+ctmx445 comparetotmag -.8E+1 -9 -> -1
+ctmx446 comparetotmag -80E-1 -9 -> -1
+ctmx447 comparetotmag -8.0 -9E+0 -> -1
+ctmx448 comparetotmag -8.0 -90E-1 -> -1
+ctmx449 comparetotmag -8 -.9E+1 -> -1
+ctmx450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+precision: 40
+ctmx470 comparetotmag 123.4560000000000000E789 123.456E789 -> -1
+ctmx471 comparetotmag 123.456000000000000E-89 123.456E-89 -> -1
+ctmx472 comparetotmag 123.45600000000000E789 123.456E789 -> -1
+ctmx473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+ctmx474 comparetotmag 123.456000000000E789 123.456E789 -> -1
+ctmx475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+ctmx476 comparetotmag 123.4560000000E789 123.456E789 -> -1
+ctmx477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+ctmx478 comparetotmag 123.45600000E789 123.456E789 -> -1
+ctmx479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+ctmx480 comparetotmag 123.456000E789 123.456E789 -> -1
+ctmx481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+ctmx482 comparetotmag 123.4560E789 123.456E789 -> -1
+ctmx483 comparetotmag 123.456E-89 123.456E-89 -> 0
+ctmx484 comparetotmag 123.456E-89 123.4560000000000000E-89 -> 1
+ctmx485 comparetotmag 123.456E789 123.456000000000000E789 -> 1
+ctmx486 comparetotmag 123.456E-89 123.45600000000000E-89 -> 1
+ctmx487 comparetotmag 123.456E789 123.4560000000000E789 -> 1
+ctmx488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+ctmx489 comparetotmag 123.456E789 123.45600000000E789 -> 1
+ctmx490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+ctmx491 comparetotmag 123.456E789 123.456000000E789 -> 1
+ctmx492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+ctmx493 comparetotmag 123.456E789 123.4560000E789 -> 1
+ctmx494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+ctmx495 comparetotmag 123.456E789 123.45600E789 -> 1
+ctmx496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+ctmx497 comparetotmag 123.456E789 123.456E789 -> 0
+
+-- wide-ranging, around precision; signs equal
+precision: 9
+ctmx500 comparetotmag 1 1E-15 -> 1
+ctmx501 comparetotmag 1 1E-14 -> 1
+ctmx502 comparetotmag 1 1E-13 -> 1
+ctmx503 comparetotmag 1 1E-12 -> 1
+ctmx504 comparetotmag 1 1E-11 -> 1
+ctmx505 comparetotmag 1 1E-10 -> 1
+ctmx506 comparetotmag 1 1E-9 -> 1
+ctmx507 comparetotmag 1 1E-8 -> 1
+ctmx508 comparetotmag 1 1E-7 -> 1
+ctmx509 comparetotmag 1 1E-6 -> 1
+ctmx510 comparetotmag 1 1E-5 -> 1
+ctmx511 comparetotmag 1 1E-4 -> 1
+ctmx512 comparetotmag 1 1E-3 -> 1
+ctmx513 comparetotmag 1 1E-2 -> 1
+ctmx514 comparetotmag 1 1E-1 -> 1
+ctmx515 comparetotmag 1 1E-0 -> 0
+ctmx516 comparetotmag 1 1E+1 -> -1
+ctmx517 comparetotmag 1 1E+2 -> -1
+ctmx518 comparetotmag 1 1E+3 -> -1
+ctmx519 comparetotmag 1 1E+4 -> -1
+ctmx521 comparetotmag 1 1E+5 -> -1
+ctmx522 comparetotmag 1 1E+6 -> -1
+ctmx523 comparetotmag 1 1E+7 -> -1
+ctmx524 comparetotmag 1 1E+8 -> -1
+ctmx525 comparetotmag 1 1E+9 -> -1
+ctmx526 comparetotmag 1 1E+10 -> -1
+ctmx527 comparetotmag 1 1E+11 -> -1
+ctmx528 comparetotmag 1 1E+12 -> -1
+ctmx529 comparetotmag 1 1E+13 -> -1
+ctmx530 comparetotmag 1 1E+14 -> -1
+ctmx531 comparetotmag 1 1E+15 -> -1
+-- LR swap
+ctmx540 comparetotmag 1E-15 1 -> -1
+ctmx541 comparetotmag 1E-14 1 -> -1
+ctmx542 comparetotmag 1E-13 1 -> -1
+ctmx543 comparetotmag 1E-12 1 -> -1
+ctmx544 comparetotmag 1E-11 1 -> -1
+ctmx545 comparetotmag 1E-10 1 -> -1
+ctmx546 comparetotmag 1E-9 1 -> -1
+ctmx547 comparetotmag 1E-8 1 -> -1
+ctmx548 comparetotmag 1E-7 1 -> -1
+ctmx549 comparetotmag 1E-6 1 -> -1
+ctmx550 comparetotmag 1E-5 1 -> -1
+ctmx551 comparetotmag 1E-4 1 -> -1
+ctmx552 comparetotmag 1E-3 1 -> -1
+ctmx553 comparetotmag 1E-2 1 -> -1
+ctmx554 comparetotmag 1E-1 1 -> -1
+ctmx555 comparetotmag 1E-0 1 -> 0
+ctmx556 comparetotmag 1E+1 1 -> 1
+ctmx557 comparetotmag 1E+2 1 -> 1
+ctmx558 comparetotmag 1E+3 1 -> 1
+ctmx559 comparetotmag 1E+4 1 -> 1
+ctmx561 comparetotmag 1E+5 1 -> 1
+ctmx562 comparetotmag 1E+6 1 -> 1
+ctmx563 comparetotmag 1E+7 1 -> 1
+ctmx564 comparetotmag 1E+8 1 -> 1
+ctmx565 comparetotmag 1E+9 1 -> 1
+ctmx566 comparetotmag 1E+10 1 -> 1
+ctmx567 comparetotmag 1E+11 1 -> 1
+ctmx568 comparetotmag 1E+12 1 -> 1
+ctmx569 comparetotmag 1E+13 1 -> 1
+ctmx570 comparetotmag 1E+14 1 -> 1
+ctmx571 comparetotmag 1E+15 1 -> 1
+-- similar with an useful coefficient, one side only
+ctmx580 comparetotmag 0.000000987654321 1E-15 -> 1
+ctmx581 comparetotmag 0.000000987654321 1E-14 -> 1
+ctmx582 comparetotmag 0.000000987654321 1E-13 -> 1
+ctmx583 comparetotmag 0.000000987654321 1E-12 -> 1
+ctmx584 comparetotmag 0.000000987654321 1E-11 -> 1
+ctmx585 comparetotmag 0.000000987654321 1E-10 -> 1
+ctmx586 comparetotmag 0.000000987654321 1E-9 -> 1
+ctmx587 comparetotmag 0.000000987654321 1E-8 -> 1
+ctmx588 comparetotmag 0.000000987654321 1E-7 -> 1
+ctmx589 comparetotmag 0.000000987654321 1E-6 -> -1
+ctmx590 comparetotmag 0.000000987654321 1E-5 -> -1
+ctmx591 comparetotmag 0.000000987654321 1E-4 -> -1
+ctmx592 comparetotmag 0.000000987654321 1E-3 -> -1
+ctmx593 comparetotmag 0.000000987654321 1E-2 -> -1
+ctmx594 comparetotmag 0.000000987654321 1E-1 -> -1
+ctmx595 comparetotmag 0.000000987654321 1E-0 -> -1
+ctmx596 comparetotmag 0.000000987654321 1E+1 -> -1
+ctmx597 comparetotmag 0.000000987654321 1E+2 -> -1
+ctmx598 comparetotmag 0.000000987654321 1E+3 -> -1
+ctmx599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+precision: 20
+ctmx600 comparetotmag 12 12.2345 -> -1
+ctmx601 comparetotmag 12.0 12.2345 -> -1
+ctmx602 comparetotmag 12.00 12.2345 -> -1
+ctmx603 comparetotmag 12.000 12.2345 -> -1
+ctmx604 comparetotmag 12.0000 12.2345 -> -1
+ctmx605 comparetotmag 12.00000 12.2345 -> -1
+ctmx606 comparetotmag 12.000000 12.2345 -> -1
+ctmx607 comparetotmag 12.0000000 12.2345 -> -1
+ctmx608 comparetotmag 12.00000000 12.2345 -> -1
+ctmx609 comparetotmag 12.000000000 12.2345 -> -1
+ctmx610 comparetotmag 12.1234 12 -> 1
+ctmx611 comparetotmag 12.1234 12.0 -> 1
+ctmx612 comparetotmag 12.1234 12.00 -> 1
+ctmx613 comparetotmag 12.1234 12.000 -> 1
+ctmx614 comparetotmag 12.1234 12.0000 -> 1
+ctmx615 comparetotmag 12.1234 12.00000 -> 1
+ctmx616 comparetotmag 12.1234 12.000000 -> 1
+ctmx617 comparetotmag 12.1234 12.0000000 -> 1
+ctmx618 comparetotmag 12.1234 12.00000000 -> 1
+ctmx619 comparetotmag 12.1234 12.000000000 -> 1
+ctmx620 comparetotmag -12 -12.2345 -> -1
+ctmx621 comparetotmag -12.0 -12.2345 -> -1
+ctmx622 comparetotmag -12.00 -12.2345 -> -1
+ctmx623 comparetotmag -12.000 -12.2345 -> -1
+ctmx624 comparetotmag -12.0000 -12.2345 -> -1
+ctmx625 comparetotmag -12.00000 -12.2345 -> -1
+ctmx626 comparetotmag -12.000000 -12.2345 -> -1
+ctmx627 comparetotmag -12.0000000 -12.2345 -> -1
+ctmx628 comparetotmag -12.00000000 -12.2345 -> -1
+ctmx629 comparetotmag -12.000000000 -12.2345 -> -1
+ctmx630 comparetotmag -12.1234 -12 -> 1
+ctmx631 comparetotmag -12.1234 -12.0 -> 1
+ctmx632 comparetotmag -12.1234 -12.00 -> 1
+ctmx633 comparetotmag -12.1234 -12.000 -> 1
+ctmx634 comparetotmag -12.1234 -12.0000 -> 1
+ctmx635 comparetotmag -12.1234 -12.00000 -> 1
+ctmx636 comparetotmag -12.1234 -12.000000 -> 1
+ctmx637 comparetotmag -12.1234 -12.0000000 -> 1
+ctmx638 comparetotmag -12.1234 -12.00000000 -> 1
+ctmx639 comparetotmag -12.1234 -12.000000000 -> 1
+precision: 9
+
+-- extended zeros
+ctmx640 comparetotmag 0 0 -> 0
+ctmx641 comparetotmag 0 -0 -> 0
+ctmx642 comparetotmag 0 -0.0 -> 1
+ctmx643 comparetotmag 0 0.0 -> 1
+ctmx644 comparetotmag -0 0 -> 0
+ctmx645 comparetotmag -0 -0 -> 0
+ctmx646 comparetotmag -0 -0.0 -> 1
+ctmx647 comparetotmag -0 0.0 -> 1
+ctmx648 comparetotmag 0.0 0 -> -1
+ctmx649 comparetotmag 0.0 -0 -> -1
+ctmx650 comparetotmag 0.0 -0.0 -> 0
+ctmx651 comparetotmag 0.0 0.0 -> 0
+ctmx652 comparetotmag -0.0 0 -> -1
+ctmx653 comparetotmag -0.0 -0 -> -1
+ctmx654 comparetotmag -0.0 -0.0 -> 0
+ctmx655 comparetotmag -0.0 0.0 -> 0
+
+ctmx656 comparetotmag -0E1 0.0 -> 1
+ctmx657 comparetotmag -0E2 0.0 -> 1
+ctmx658 comparetotmag 0E1 0.0 -> 1
+ctmx659 comparetotmag 0E2 0.0 -> 1
+ctmx660 comparetotmag -0E1 0 -> 1
+ctmx661 comparetotmag -0E2 0 -> 1
+ctmx662 comparetotmag 0E1 0 -> 1
+ctmx663 comparetotmag 0E2 0 -> 1
+ctmx664 comparetotmag -0E1 -0E1 -> 0
+ctmx665 comparetotmag -0E2 -0E1 -> 1
+ctmx666 comparetotmag 0E1 -0E1 -> 0
+ctmx667 comparetotmag 0E2 -0E1 -> 1
+ctmx668 comparetotmag -0E1 -0E2 -> -1
+ctmx669 comparetotmag -0E2 -0E2 -> 0
+ctmx670 comparetotmag 0E1 -0E2 -> -1
+ctmx671 comparetotmag 0E2 -0E2 -> 0
+ctmx672 comparetotmag -0E1 0E1 -> 0
+ctmx673 comparetotmag -0E2 0E1 -> 1
+ctmx674 comparetotmag 0E1 0E1 -> 0
+ctmx675 comparetotmag 0E2 0E1 -> 1
+ctmx676 comparetotmag -0E1 0E2 -> -1
+ctmx677 comparetotmag -0E2 0E2 -> 0
+ctmx678 comparetotmag 0E1 0E2 -> -1
+ctmx679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+precision: 20
+ctmx680 comparetotmag 12 12 -> 0
+ctmx681 comparetotmag 12 12.0 -> 1
+ctmx682 comparetotmag 12 12.00 -> 1
+ctmx683 comparetotmag 12 12.000 -> 1
+ctmx684 comparetotmag 12 12.0000 -> 1
+ctmx685 comparetotmag 12 12.00000 -> 1
+ctmx686 comparetotmag 12 12.000000 -> 1
+ctmx687 comparetotmag 12 12.0000000 -> 1
+ctmx688 comparetotmag 12 12.00000000 -> 1
+ctmx689 comparetotmag 12 12.000000000 -> 1
+ctmx690 comparetotmag 12 12 -> 0
+ctmx691 comparetotmag 12.0 12 -> -1
+ctmx692 comparetotmag 12.00 12 -> -1
+ctmx693 comparetotmag 12.000 12 -> -1
+ctmx694 comparetotmag 12.0000 12 -> -1
+ctmx695 comparetotmag 12.00000 12 -> -1
+ctmx696 comparetotmag 12.000000 12 -> -1
+ctmx697 comparetotmag 12.0000000 12 -> -1
+ctmx698 comparetotmag 12.00000000 12 -> -1
+ctmx699 comparetotmag 12.000000000 12 -> -1
+
+-- long operand checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+ctmx701 comparetotmag 12345678000 1 -> 1
+ctmx702 comparetotmag 1 12345678000 -> -1
+ctmx703 comparetotmag 1234567800 1 -> 1
+ctmx704 comparetotmag 1 1234567800 -> -1
+ctmx705 comparetotmag 1234567890 1 -> 1
+ctmx706 comparetotmag 1 1234567890 -> -1
+ctmx707 comparetotmag 1234567891 1 -> 1
+ctmx708 comparetotmag 1 1234567891 -> -1
+ctmx709 comparetotmag 12345678901 1 -> 1
+ctmx710 comparetotmag 1 12345678901 -> -1
+ctmx711 comparetotmag 1234567896 1 -> 1
+ctmx712 comparetotmag 1 1234567896 -> -1
+ctmx713 comparetotmag -1234567891 1 -> 1
+ctmx714 comparetotmag 1 -1234567891 -> -1
+ctmx715 comparetotmag -12345678901 1 -> 1
+ctmx716 comparetotmag 1 -12345678901 -> -1
+ctmx717 comparetotmag -1234567896 1 -> 1
+ctmx718 comparetotmag 1 -1234567896 -> -1
+
+precision: 15
+-- same with plenty of precision
+ctmx721 comparetotmag 12345678000 1 -> 1
+ctmx722 comparetotmag 1 12345678000 -> -1
+ctmx723 comparetotmag 1234567800 1 -> 1
+ctmx724 comparetotmag 1 1234567800 -> -1
+ctmx725 comparetotmag 1234567890 1 -> 1
+ctmx726 comparetotmag 1 1234567890 -> -1
+ctmx727 comparetotmag 1234567891 1 -> 1
+ctmx728 comparetotmag 1 1234567891 -> -1
+ctmx729 comparetotmag 12345678901 1 -> 1
+ctmx730 comparetotmag 1 12345678901 -> -1
+ctmx731 comparetotmag 1234567896 1 -> 1
+ctmx732 comparetotmag 1 1234567896 -> -1
+
+-- residue cases
+precision: 5
+ctmx740 comparetotmag 1 0.9999999 -> 1
+ctmx741 comparetotmag 1 0.999999 -> 1
+ctmx742 comparetotmag 1 0.99999 -> 1
+ctmx743 comparetotmag 1 1.0000 -> 1
+ctmx744 comparetotmag 1 1.00001 -> -1
+ctmx745 comparetotmag 1 1.000001 -> -1
+ctmx746 comparetotmag 1 1.0000001 -> -1
+ctmx750 comparetotmag 0.9999999 1 -> -1
+ctmx751 comparetotmag 0.999999 1 -> -1
+ctmx752 comparetotmag 0.99999 1 -> -1
+ctmx753 comparetotmag 1.0000 1 -> -1
+ctmx754 comparetotmag 1.00001 1 -> 1
+ctmx755 comparetotmag 1.000001 1 -> 1
+ctmx756 comparetotmag 1.0000001 1 -> 1
+
+-- a selection of longies
+ctmx760 comparetotmag -36852134.84194296250843579428931 -5830629.8347085025808756560357940 -> 1
+ctmx761 comparetotmag -36852134.84194296250843579428931 -36852134.84194296250843579428931 -> 0
+ctmx762 comparetotmag -36852134.94194296250843579428931 -36852134.84194296250843579428931 -> 1
+ctmx763 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+-- precisions above or below the difference should have no effect
+precision: 11
+ctmx764 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 10
+ctmx765 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 9
+ctmx766 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 8
+ctmx767 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 7
+ctmx768 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 6
+ctmx769 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 5
+ctmx770 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 4
+ctmx771 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 3
+ctmx772 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 2
+ctmx773 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+precision: 1
+ctmx774 comparetotmag -36852134.84194296250843579428931 -36852134.94194296250843579428931 -> -1
+
+-- Specials
+precision: 9
+ctmx780 comparetotmag Inf -Inf -> 0
+ctmx781 comparetotmag Inf -1000 -> 1
+ctmx782 comparetotmag Inf -1 -> 1
+ctmx783 comparetotmag Inf -0 -> 1
+ctmx784 comparetotmag Inf 0 -> 1
+ctmx785 comparetotmag Inf 1 -> 1
+ctmx786 comparetotmag Inf 1000 -> 1
+ctmx787 comparetotmag Inf Inf -> 0
+ctmx788 comparetotmag -1000 Inf -> -1
+ctmx789 comparetotmag -Inf Inf -> 0
+ctmx790 comparetotmag -1 Inf -> -1
+ctmx791 comparetotmag -0 Inf -> -1
+ctmx792 comparetotmag 0 Inf -> -1
+ctmx793 comparetotmag 1 Inf -> -1
+ctmx794 comparetotmag 1000 Inf -> -1
+ctmx795 comparetotmag Inf Inf -> 0
+
+ctmx800 comparetotmag -Inf -Inf -> 0
+ctmx801 comparetotmag -Inf -1000 -> 1
+ctmx802 comparetotmag -Inf -1 -> 1
+ctmx803 comparetotmag -Inf -0 -> 1
+ctmx804 comparetotmag -Inf 0 -> 1
+ctmx805 comparetotmag -Inf 1 -> 1
+ctmx806 comparetotmag -Inf 1000 -> 1
+ctmx807 comparetotmag -Inf Inf -> 0
+ctmx808 comparetotmag -Inf -Inf -> 0
+ctmx809 comparetotmag -1000 -Inf -> -1
+ctmx810 comparetotmag -1 -Inf -> -1
+ctmx811 comparetotmag -0 -Inf -> -1
+ctmx812 comparetotmag 0 -Inf -> -1
+ctmx813 comparetotmag 1 -Inf -> -1
+ctmx814 comparetotmag 1000 -Inf -> -1
+ctmx815 comparetotmag Inf -Inf -> 0
+
+ctmx821 comparetotmag NaN -Inf -> 1
+ctmx822 comparetotmag NaN -1000 -> 1
+ctmx823 comparetotmag NaN -1 -> 1
+ctmx824 comparetotmag NaN -0 -> 1
+ctmx825 comparetotmag NaN 0 -> 1
+ctmx826 comparetotmag NaN 1 -> 1
+ctmx827 comparetotmag NaN 1000 -> 1
+ctmx828 comparetotmag NaN Inf -> 1
+ctmx829 comparetotmag NaN NaN -> 0
+ctmx830 comparetotmag -Inf NaN -> -1
+ctmx831 comparetotmag -1000 NaN -> -1
+ctmx832 comparetotmag -1 NaN -> -1
+ctmx833 comparetotmag -0 NaN -> -1
+ctmx834 comparetotmag 0 NaN -> -1
+ctmx835 comparetotmag 1 NaN -> -1
+ctmx836 comparetotmag 1000 NaN -> -1
+ctmx837 comparetotmag Inf NaN -> -1
+ctmx838 comparetotmag -NaN -NaN -> 0
+ctmx839 comparetotmag +NaN -NaN -> 0
+ctmx840 comparetotmag -NaN +NaN -> 0
+
+ctmx841 comparetotmag sNaN -sNaN -> 0
+ctmx842 comparetotmag sNaN -NaN -> -1
+ctmx843 comparetotmag sNaN -Inf -> 1
+ctmx844 comparetotmag sNaN -1000 -> 1
+ctmx845 comparetotmag sNaN -1 -> 1
+ctmx846 comparetotmag sNaN -0 -> 1
+ctmx847 comparetotmag sNaN 0 -> 1
+ctmx848 comparetotmag sNaN 1 -> 1
+ctmx849 comparetotmag sNaN 1000 -> 1
+ctmx850 comparetotmag sNaN NaN -> -1
+ctmx851 comparetotmag sNaN sNaN -> 0
+
+ctmx852 comparetotmag -sNaN sNaN -> 0
+ctmx853 comparetotmag -NaN sNaN -> 1
+ctmx854 comparetotmag -Inf sNaN -> -1
+ctmx855 comparetotmag -1000 sNaN -> -1
+ctmx856 comparetotmag -1 sNaN -> -1
+ctmx857 comparetotmag -0 sNaN -> -1
+ctmx858 comparetotmag 0 sNaN -> -1
+ctmx859 comparetotmag 1 sNaN -> -1
+ctmx860 comparetotmag 1000 sNaN -> -1
+ctmx861 comparetotmag Inf sNaN -> -1
+ctmx862 comparetotmag NaN sNaN -> 1
+ctmx863 comparetotmag sNaN sNaN -> 0
+
+ctmx871 comparetotmag -sNaN -sNaN -> 0
+ctmx872 comparetotmag -sNaN -NaN -> -1
+ctmx873 comparetotmag -sNaN -Inf -> 1
+ctmx874 comparetotmag -sNaN -1000 -> 1
+ctmx875 comparetotmag -sNaN -1 -> 1
+ctmx876 comparetotmag -sNaN -0 -> 1
+ctmx877 comparetotmag -sNaN 0 -> 1
+ctmx878 comparetotmag -sNaN 1 -> 1
+ctmx879 comparetotmag -sNaN 1000 -> 1
+ctmx880 comparetotmag -sNaN NaN -> -1
+ctmx881 comparetotmag -sNaN sNaN -> 0
+
+ctmx882 comparetotmag -sNaN -sNaN -> 0
+ctmx883 comparetotmag -NaN -sNaN -> 1
+ctmx884 comparetotmag -Inf -sNaN -> -1
+ctmx885 comparetotmag -1000 -sNaN -> -1
+ctmx886 comparetotmag -1 -sNaN -> -1
+ctmx887 comparetotmag -0 -sNaN -> -1
+ctmx888 comparetotmag 0 -sNaN -> -1
+ctmx889 comparetotmag 1 -sNaN -> -1
+ctmx890 comparetotmag 1000 -sNaN -> -1
+ctmx891 comparetotmag Inf -sNaN -> -1
+ctmx892 comparetotmag NaN -sNaN -> 1
+ctmx893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+ctmx960 comparetotmag NaN9 -Inf -> 1
+ctmx961 comparetotmag NaN8 999 -> 1
+ctmx962 comparetotmag NaN77 Inf -> 1
+ctmx963 comparetotmag -NaN67 NaN5 -> 1
+ctmx964 comparetotmag -Inf -NaN4 -> -1
+ctmx965 comparetotmag -999 -NaN33 -> -1
+ctmx966 comparetotmag Inf NaN2 -> -1
+
+ctmx970 comparetotmag -NaN41 -NaN42 -> -1
+ctmx971 comparetotmag +NaN41 -NaN42 -> -1
+ctmx972 comparetotmag -NaN41 +NaN42 -> -1
+ctmx973 comparetotmag +NaN41 +NaN42 -> -1
+ctmx974 comparetotmag -NaN42 -NaN01 -> 1
+ctmx975 comparetotmag +NaN42 -NaN01 -> 1
+ctmx976 comparetotmag -NaN42 +NaN01 -> 1
+ctmx977 comparetotmag +NaN42 +NaN01 -> 1
+
+ctmx980 comparetotmag -sNaN771 -sNaN772 -> -1
+ctmx981 comparetotmag +sNaN771 -sNaN772 -> -1
+ctmx982 comparetotmag -sNaN771 +sNaN772 -> -1
+ctmx983 comparetotmag +sNaN771 +sNaN772 -> -1
+ctmx984 comparetotmag -sNaN772 -sNaN771 -> 1
+ctmx985 comparetotmag +sNaN772 -sNaN771 -> 1
+ctmx986 comparetotmag -sNaN772 +sNaN771 -> 1
+ctmx987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+ctmx991 comparetotmag -sNaN99 -Inf -> 1
+ctmx992 comparetotmag sNaN98 -11 -> 1
+ctmx993 comparetotmag sNaN97 NaN -> -1
+ctmx994 comparetotmag sNaN16 sNaN94 -> -1
+ctmx995 comparetotmag NaN85 sNaN83 -> 1
+ctmx996 comparetotmag -Inf sNaN92 -> -1
+ctmx997 comparetotmag 088 sNaN81 -> -1
+ctmx998 comparetotmag Inf sNaN90 -> -1
+ctmx999 comparetotmag NaN -sNaN89 -> 1
+
+-- overflow and underflow tests .. subnormal results now allowed
+maxExponent: 999999999
+minexponent: -999999999
+ctmx1080 comparetotmag +1.23456789012345E-0 9E+999999999 -> -1
+ctmx1081 comparetotmag 9E+999999999 +1.23456789012345E-0 -> 1
+ctmx1082 comparetotmag +0.100 9E-999999999 -> 1
+ctmx1083 comparetotmag 9E-999999999 +0.100 -> -1
+ctmx1085 comparetotmag -1.23456789012345E-0 9E+999999999 -> -1
+ctmx1086 comparetotmag 9E+999999999 -1.23456789012345E-0 -> 1
+ctmx1087 comparetotmag -0.100 9E-999999999 -> 1
+ctmx1088 comparetotmag 9E-999999999 -0.100 -> -1
+
+ctmx1089 comparetotmag 1e-599999999 1e-400000001 -> -1
+ctmx1090 comparetotmag 1e-599999999 1e-400000000 -> -1
+ctmx1091 comparetotmag 1e-600000000 1e-400000000 -> -1
+ctmx1092 comparetotmag 9e-999999998 0.01 -> -1
+ctmx1093 comparetotmag 9e-999999998 0.1 -> -1
+ctmx1094 comparetotmag 0.01 9e-999999998 -> 1
+ctmx1095 comparetotmag 1e599999999 1e400000001 -> 1
+ctmx1096 comparetotmag 1e599999999 1e400000000 -> 1
+ctmx1097 comparetotmag 1e600000000 1e400000000 -> 1
+ctmx1098 comparetotmag 9e999999998 100 -> 1
+ctmx1099 comparetotmag 9e999999998 10 -> 1
+ctmx1100 comparetotmag 100 9e999999998 -> -1
+-- signs
+ctmx1101 comparetotmag 1e+777777777 1e+411111111 -> 1
+ctmx1102 comparetotmag 1e+777777777 -1e+411111111 -> 1
+ctmx1103 comparetotmag -1e+777777777 1e+411111111 -> 1
+ctmx1104 comparetotmag -1e+777777777 -1e+411111111 -> 1
+ctmx1105 comparetotmag 1e-777777777 1e-411111111 -> -1
+ctmx1106 comparetotmag 1e-777777777 -1e-411111111 -> -1
+ctmx1107 comparetotmag -1e-777777777 1e-411111111 -> -1
+ctmx1108 comparetotmag -1e-777777777 -1e-411111111 -> -1
+
+-- spread zeros
+ctmx1110 comparetotmag 0E-383 0 -> -1
+ctmx1111 comparetotmag 0E-383 -0 -> -1
+ctmx1112 comparetotmag -0E-383 0 -> -1
+ctmx1113 comparetotmag -0E-383 -0 -> -1
+ctmx1114 comparetotmag 0E-383 0E+384 -> -1
+ctmx1115 comparetotmag 0E-383 -0E+384 -> -1
+ctmx1116 comparetotmag -0E-383 0E+384 -> -1
+ctmx1117 comparetotmag -0E-383 -0E+384 -> -1
+ctmx1118 comparetotmag 0 0E+384 -> -1
+ctmx1119 comparetotmag 0 -0E+384 -> -1
+ctmx1120 comparetotmag -0 0E+384 -> -1
+ctmx1121 comparetotmag -0 -0E+384 -> -1
+
+ctmx1130 comparetotmag 0E+384 0 -> 1
+ctmx1131 comparetotmag 0E+384 -0 -> 1
+ctmx1132 comparetotmag -0E+384 0 -> 1
+ctmx1133 comparetotmag -0E+384 -0 -> 1
+ctmx1134 comparetotmag 0E+384 0E-383 -> 1
+ctmx1135 comparetotmag 0E+384 -0E-383 -> 1
+ctmx1136 comparetotmag -0E+384 0E-383 -> 1
+ctmx1137 comparetotmag -0E+384 -0E-383 -> 1
+ctmx1138 comparetotmag 0 0E-383 -> 1
+ctmx1139 comparetotmag 0 -0E-383 -> 1
+ctmx1140 comparetotmag -0 0E-383 -> 1
+ctmx1141 comparetotmag -0 -0E-383 -> 1
+
+-- Null tests
+ctmx9990 comparetotmag 10 # -> NaN Invalid_operation
+ctmx9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/copy.decTest b/Lib/test/decimaltestdata/copy.decTest
index d9f299e2273..b47e499a7bd 100644
--- a/Lib/test/decimaltestdata/copy.decTest
+++ b/Lib/test/decimaltestdata/copy.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copy.decTest -- quiet copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpyx001 copy +7.50 -> 7.50
-
--- Infinities
-cpyx011 copy Infinity -> Infinity
-cpyx012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-cpyx021 copy NaN -> NaN
-cpyx022 copy -NaN -> -NaN
-cpyx023 copy sNaN -> sNaN
-cpyx024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-cpyx031 copy NaN10 -> NaN10
-cpyx032 copy -NaN10 -> -NaN10
-cpyx033 copy sNaN10 -> sNaN10
-cpyx034 copy -sNaN10 -> -sNaN10
-cpyx035 copy NaN7 -> NaN7
-cpyx036 copy -NaN7 -> -NaN7
-cpyx037 copy sNaN101 -> sNaN101
-cpyx038 copy -sNaN101 -> -sNaN101
-
--- finites
-cpyx101 copy 7 -> 7
-cpyx102 copy -7 -> -7
-cpyx103 copy 75 -> 75
-cpyx104 copy -75 -> -75
-cpyx105 copy 7.50 -> 7.50
-cpyx106 copy -7.50 -> -7.50
-cpyx107 copy 7.500 -> 7.500
-cpyx108 copy -7.500 -> -7.500
-
--- zeros
-cpyx111 copy 0 -> 0
-cpyx112 copy -0 -> -0
-cpyx113 copy 0E+4 -> 0E+4
-cpyx114 copy -0E+4 -> -0E+4
-cpyx115 copy 0.0000 -> 0.0000
-cpyx116 copy -0.0000 -> -0.0000
-cpyx117 copy 0E-141 -> 0E-141
-cpyx118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-cpyx121 copy 268268268 -> 268268268
-cpyx122 copy -268268268 -> -268268268
-cpyx123 copy 134134134 -> 134134134
-cpyx124 copy -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-cpyx131 copy 9.99999999E+999 -> 9.99999999E+999
-cpyx132 copy 1E-999 -> 1E-999
-cpyx133 copy 1.00000000E-999 -> 1.00000000E-999
-cpyx134 copy 1E-1007 -> 1E-1007
-
-cpyx135 copy -1E-1007 -> -1E-1007
-cpyx136 copy -1.00000000E-999 -> -1.00000000E-999
-cpyx137 copy -1E-999 -> -1E-999
-cpyx138 copy -9.99999999E+999 -> -9.99999999E+999
+------------------------------------------------------------------------
+-- copy.decTest -- quiet copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpyx001 copy +7.50 -> 7.50
+
+-- Infinities
+cpyx011 copy Infinity -> Infinity
+cpyx012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+cpyx021 copy NaN -> NaN
+cpyx022 copy -NaN -> -NaN
+cpyx023 copy sNaN -> sNaN
+cpyx024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+cpyx031 copy NaN10 -> NaN10
+cpyx032 copy -NaN10 -> -NaN10
+cpyx033 copy sNaN10 -> sNaN10
+cpyx034 copy -sNaN10 -> -sNaN10
+cpyx035 copy NaN7 -> NaN7
+cpyx036 copy -NaN7 -> -NaN7
+cpyx037 copy sNaN101 -> sNaN101
+cpyx038 copy -sNaN101 -> -sNaN101
+
+-- finites
+cpyx101 copy 7 -> 7
+cpyx102 copy -7 -> -7
+cpyx103 copy 75 -> 75
+cpyx104 copy -75 -> -75
+cpyx105 copy 7.50 -> 7.50
+cpyx106 copy -7.50 -> -7.50
+cpyx107 copy 7.500 -> 7.500
+cpyx108 copy -7.500 -> -7.500
+
+-- zeros
+cpyx111 copy 0 -> 0
+cpyx112 copy -0 -> -0
+cpyx113 copy 0E+4 -> 0E+4
+cpyx114 copy -0E+4 -> -0E+4
+cpyx115 copy 0.0000 -> 0.0000
+cpyx116 copy -0.0000 -> -0.0000
+cpyx117 copy 0E-141 -> 0E-141
+cpyx118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+cpyx121 copy 268268268 -> 268268268
+cpyx122 copy -268268268 -> -268268268
+cpyx123 copy 134134134 -> 134134134
+cpyx124 copy -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+cpyx131 copy 9.99999999E+999 -> 9.99999999E+999
+cpyx132 copy 1E-999 -> 1E-999
+cpyx133 copy 1.00000000E-999 -> 1.00000000E-999
+cpyx134 copy 1E-1007 -> 1E-1007
+
+cpyx135 copy -1E-1007 -> -1E-1007
+cpyx136 copy -1.00000000E-999 -> -1.00000000E-999
+cpyx137 copy -1E-999 -> -1E-999
+cpyx138 copy -9.99999999E+999 -> -9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copyabs.decTest b/Lib/test/decimaltestdata/copyabs.decTest
index 52002dc431a..f7d0f864581 100644
--- a/Lib/test/decimaltestdata/copyabs.decTest
+++ b/Lib/test/decimaltestdata/copyabs.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copyAbs.decTest -- quiet copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpax001 copyabs +7.50 -> 7.50
-
--- Infinities
-cpax011 copyabs Infinity -> Infinity
-cpax012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-cpax021 copyabs NaN -> NaN
-cpax022 copyabs -NaN -> NaN
-cpax023 copyabs sNaN -> sNaN
-cpax024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-cpax031 copyabs NaN10 -> NaN10
-cpax032 copyabs -NaN15 -> NaN15
-cpax033 copyabs sNaN15 -> sNaN15
-cpax034 copyabs -sNaN10 -> sNaN10
-cpax035 copyabs NaN7 -> NaN7
-cpax036 copyabs -NaN7 -> NaN7
-cpax037 copyabs sNaN101 -> sNaN101
-cpax038 copyabs -sNaN101 -> sNaN101
-
--- finites
-cpax101 copyabs 7 -> 7
-cpax102 copyabs -7 -> 7
-cpax103 copyabs 75 -> 75
-cpax104 copyabs -75 -> 75
-cpax105 copyabs 7.10 -> 7.10
-cpax106 copyabs -7.10 -> 7.10
-cpax107 copyabs 7.500 -> 7.500
-cpax108 copyabs -7.500 -> 7.500
-
--- zeros
-cpax111 copyabs 0 -> 0
-cpax112 copyabs -0 -> 0
-cpax113 copyabs 0E+6 -> 0E+6
-cpax114 copyabs -0E+6 -> 0E+6
-cpax115 copyabs 0.0000 -> 0.0000
-cpax116 copyabs -0.0000 -> 0.0000
-cpax117 copyabs 0E-141 -> 0E-141
-cpax118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-cpax121 copyabs 268268268 -> 268268268
-cpax122 copyabs -268268268 -> 268268268
-cpax123 copyabs 134134134 -> 134134134
-cpax124 copyabs -134134134 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpax131 copyabs 9.99999999E+999 -> 9.99999999E+999
-cpax132 copyabs 1E-999 -> 1E-999
-cpax133 copyabs 1.00000000E-999 -> 1.00000000E-999
-cpax134 copyabs 1E-1007 -> 1E-1007
-
-cpax135 copyabs -1E-1007 -> 1E-1007
-cpax136 copyabs -1.00000000E-999 -> 1.00000000E-999
-cpax137 copyabs -1E-999 -> 1E-999
-cpax199 copyabs -9.99999999E+999 -> 9.99999999E+999
+------------------------------------------------------------------------
+-- copyAbs.decTest -- quiet copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpax001 copyabs +7.50 -> 7.50
+
+-- Infinities
+cpax011 copyabs Infinity -> Infinity
+cpax012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+cpax021 copyabs NaN -> NaN
+cpax022 copyabs -NaN -> NaN
+cpax023 copyabs sNaN -> sNaN
+cpax024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+cpax031 copyabs NaN10 -> NaN10
+cpax032 copyabs -NaN15 -> NaN15
+cpax033 copyabs sNaN15 -> sNaN15
+cpax034 copyabs -sNaN10 -> sNaN10
+cpax035 copyabs NaN7 -> NaN7
+cpax036 copyabs -NaN7 -> NaN7
+cpax037 copyabs sNaN101 -> sNaN101
+cpax038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+cpax101 copyabs 7 -> 7
+cpax102 copyabs -7 -> 7
+cpax103 copyabs 75 -> 75
+cpax104 copyabs -75 -> 75
+cpax105 copyabs 7.10 -> 7.10
+cpax106 copyabs -7.10 -> 7.10
+cpax107 copyabs 7.500 -> 7.500
+cpax108 copyabs -7.500 -> 7.500
+
+-- zeros
+cpax111 copyabs 0 -> 0
+cpax112 copyabs -0 -> 0
+cpax113 copyabs 0E+6 -> 0E+6
+cpax114 copyabs -0E+6 -> 0E+6
+cpax115 copyabs 0.0000 -> 0.0000
+cpax116 copyabs -0.0000 -> 0.0000
+cpax117 copyabs 0E-141 -> 0E-141
+cpax118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+cpax121 copyabs 268268268 -> 268268268
+cpax122 copyabs -268268268 -> 268268268
+cpax123 copyabs 134134134 -> 134134134
+cpax124 copyabs -134134134 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpax131 copyabs 9.99999999E+999 -> 9.99999999E+999
+cpax132 copyabs 1E-999 -> 1E-999
+cpax133 copyabs 1.00000000E-999 -> 1.00000000E-999
+cpax134 copyabs 1E-1007 -> 1E-1007
+
+cpax135 copyabs -1E-1007 -> 1E-1007
+cpax136 copyabs -1.00000000E-999 -> 1.00000000E-999
+cpax137 copyabs -1E-999 -> 1E-999
+cpax199 copyabs -9.99999999E+999 -> 9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copynegate.decTest b/Lib/test/decimaltestdata/copynegate.decTest
index 7f8de9d9321..38235b60f9f 100644
--- a/Lib/test/decimaltestdata/copynegate.decTest
+++ b/Lib/test/decimaltestdata/copynegate.decTest
@@ -1,86 +1,86 @@
-------------------------------------------------------------------------
--- copyNegate.decTest -- quiet copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-cpnx001 copynegate +7.50 -> -7.50
-
--- Infinities
-cpnx011 copynegate Infinity -> -Infinity
-cpnx012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-cpnx021 copynegate NaN -> -NaN
-cpnx022 copynegate -NaN -> NaN
-cpnx023 copynegate sNaN -> -sNaN
-cpnx024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-cpnx031 copynegate NaN13 -> -NaN13
-cpnx032 copynegate -NaN13 -> NaN13
-cpnx033 copynegate sNaN13 -> -sNaN13
-cpnx034 copynegate -sNaN13 -> sNaN13
-cpnx035 copynegate NaN70 -> -NaN70
-cpnx036 copynegate -NaN70 -> NaN70
-cpnx037 copynegate sNaN101 -> -sNaN101
-cpnx038 copynegate -sNaN101 -> sNaN101
-
--- finites
-cpnx101 copynegate 7 -> -7
-cpnx102 copynegate -7 -> 7
-cpnx103 copynegate 75 -> -75
-cpnx104 copynegate -75 -> 75
-cpnx105 copynegate 7.50 -> -7.50
-cpnx106 copynegate -7.50 -> 7.50
-cpnx107 copynegate 7.500 -> -7.500
-cpnx108 copynegate -7.500 -> 7.500
-
--- zeros
-cpnx111 copynegate 0 -> -0
-cpnx112 copynegate -0 -> 0
-cpnx113 copynegate 0E+4 -> -0E+4
-cpnx114 copynegate -0E+4 -> 0E+4
-cpnx115 copynegate 0.0000 -> -0.0000
-cpnx116 copynegate -0.0000 -> 0.0000
-cpnx117 copynegate 0E-141 -> -0E-141
-cpnx118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-cpnx121 copynegate 268268268 -> -268268268
-cpnx122 copynegate -268268268 -> 268268268
-cpnx123 copynegate 134134134 -> -134134134
-cpnx124 copynegate -134134134 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpnx131 copynegate 9.99999999E+999 -> -9.99999999E+999
-cpnx132 copynegate 1E-999 -> -1E-999
-cpnx133 copynegate 1.00000000E-999 -> -1.00000000E-999
-cpnx134 copynegate 1E-1007 -> -1E-1007
-
-cpnx135 copynegate -1E-1007 -> 1E-1007
-cpnx136 copynegate -1.00000000E-999 -> 1.00000000E-999
-cpnx137 copynegate -1E-999 -> 1E-999
-cpnx138 copynegate -9.99999999E+999 -> 9.99999999E+999
+------------------------------------------------------------------------
+-- copyNegate.decTest -- quiet copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+cpnx001 copynegate +7.50 -> -7.50
+
+-- Infinities
+cpnx011 copynegate Infinity -> -Infinity
+cpnx012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+cpnx021 copynegate NaN -> -NaN
+cpnx022 copynegate -NaN -> NaN
+cpnx023 copynegate sNaN -> -sNaN
+cpnx024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+cpnx031 copynegate NaN13 -> -NaN13
+cpnx032 copynegate -NaN13 -> NaN13
+cpnx033 copynegate sNaN13 -> -sNaN13
+cpnx034 copynegate -sNaN13 -> sNaN13
+cpnx035 copynegate NaN70 -> -NaN70
+cpnx036 copynegate -NaN70 -> NaN70
+cpnx037 copynegate sNaN101 -> -sNaN101
+cpnx038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+cpnx101 copynegate 7 -> -7
+cpnx102 copynegate -7 -> 7
+cpnx103 copynegate 75 -> -75
+cpnx104 copynegate -75 -> 75
+cpnx105 copynegate 7.50 -> -7.50
+cpnx106 copynegate -7.50 -> 7.50
+cpnx107 copynegate 7.500 -> -7.500
+cpnx108 copynegate -7.500 -> 7.500
+
+-- zeros
+cpnx111 copynegate 0 -> -0
+cpnx112 copynegate -0 -> 0
+cpnx113 copynegate 0E+4 -> -0E+4
+cpnx114 copynegate -0E+4 -> 0E+4
+cpnx115 copynegate 0.0000 -> -0.0000
+cpnx116 copynegate -0.0000 -> 0.0000
+cpnx117 copynegate 0E-141 -> -0E-141
+cpnx118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+cpnx121 copynegate 268268268 -> -268268268
+cpnx122 copynegate -268268268 -> 268268268
+cpnx123 copynegate 134134134 -> -134134134
+cpnx124 copynegate -134134134 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpnx131 copynegate 9.99999999E+999 -> -9.99999999E+999
+cpnx132 copynegate 1E-999 -> -1E-999
+cpnx133 copynegate 1.00000000E-999 -> -1.00000000E-999
+cpnx134 copynegate 1E-1007 -> -1E-1007
+
+cpnx135 copynegate -1E-1007 -> 1E-1007
+cpnx136 copynegate -1.00000000E-999 -> 1.00000000E-999
+cpnx137 copynegate -1E-999 -> 1E-999
+cpnx138 copynegate -9.99999999E+999 -> 9.99999999E+999
diff --git a/Lib/test/decimaltestdata/copysign.decTest b/Lib/test/decimaltestdata/copysign.decTest
index afdd670d3c1..8061a4219cc 100644
--- a/Lib/test/decimaltestdata/copysign.decTest
+++ b/Lib/test/decimaltestdata/copysign.decTest
@@ -1,177 +1,177 @@
-------------------------------------------------------------------------
--- copysign.decTest -- quiet copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check, and examples from decArith
-cpsx001 copysign +7.50 11 -> 7.50
-cpsx002 copysign '1.50' '7.33' -> 1.50
-cpsx003 copysign '-1.50' '7.33' -> 1.50
-cpsx004 copysign '1.50' '-7.33' -> -1.50
-cpsx005 copysign '-1.50' '-7.33' -> -1.50
-
--- Infinities
-cpsx011 copysign Infinity 11 -> Infinity
-cpsx012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-cpsx021 copysign NaN 11 -> NaN
-cpsx022 copysign -NaN 11 -> NaN
-cpsx023 copysign sNaN 11 -> sNaN
-cpsx024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-cpsx031 copysign NaN10 11 -> NaN10
-cpsx032 copysign -NaN10 11 -> NaN10
-cpsx033 copysign sNaN10 11 -> sNaN10
-cpsx034 copysign -sNaN10 11 -> sNaN10
-cpsx035 copysign NaN7 11 -> NaN7
-cpsx036 copysign -NaN7 11 -> NaN7
-cpsx037 copysign sNaN101 11 -> sNaN101
-cpsx038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-cpsx101 copysign 7 11 -> 7
-cpsx102 copysign -7 11 -> 7
-cpsx103 copysign 75 11 -> 75
-cpsx104 copysign -75 11 -> 75
-cpsx105 copysign 7.50 11 -> 7.50
-cpsx106 copysign -7.50 11 -> 7.50
-cpsx107 copysign 7.500 11 -> 7.500
-cpsx108 copysign -7.500 11 -> 7.500
-
--- zeros
-cpsx111 copysign 0 11 -> 0
-cpsx112 copysign -0 11 -> 0
-cpsx113 copysign 0E+4 11 -> 0E+4
-cpsx114 copysign -0E+4 11 -> 0E+4
-cpsx115 copysign 0.0000 11 -> 0.0000
-cpsx116 copysign -0.0000 11 -> 0.0000
-cpsx117 copysign 0E-141 11 -> 0E-141
-cpsx118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-cpsx121 copysign 268268268 11 -> 268268268
-cpsx122 copysign -268268268 11 -> 268268268
-cpsx123 copysign 134134134 11 -> 134134134
-cpsx124 copysign -134134134 11 -> 134134134
-
--- Nmax, Nmin, Ntiny
-cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999
-cpsx132 copysign 1E-999 11 -> 1E-999
-cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999
-cpsx134 copysign 1E-1007 11 -> 1E-1007
-
-cpsx135 copysign -1E-1007 11 -> 1E-1007
-cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999
-cpsx137 copysign -1E-999 11 -> 1E-999
-cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999
-
--- repeat with negative RHS
-
--- Infinities
-cpsx211 copysign Infinity -34 -> -Infinity
-cpsx212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-cpsx221 copysign NaN -34 -> -NaN
-cpsx222 copysign -NaN -34 -> -NaN
-cpsx223 copysign sNaN -34 -> -sNaN
-cpsx224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-cpsx231 copysign NaN10 -34 -> -NaN10
-cpsx232 copysign -NaN10 -34 -> -NaN10
-cpsx233 copysign sNaN10 -34 -> -sNaN10
-cpsx234 copysign -sNaN10 -34 -> -sNaN10
-cpsx235 copysign NaN7 -34 -> -NaN7
-cpsx236 copysign -NaN7 -34 -> -NaN7
-cpsx237 copysign sNaN101 -34 -> -sNaN101
-cpsx238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-cpsx301 copysign 7 -34 -> -7
-cpsx302 copysign -7 -34 -> -7
-cpsx303 copysign 75 -34 -> -75
-cpsx304 copysign -75 -34 -> -75
-cpsx305 copysign 7.50 -34 -> -7.50
-cpsx306 copysign -7.50 -34 -> -7.50
-cpsx307 copysign 7.500 -34 -> -7.500
-cpsx308 copysign -7.500 -34 -> -7.500
-
--- zeros
-cpsx311 copysign 0 -34 -> -0
-cpsx312 copysign -0 -34 -> -0
-cpsx313 copysign 0E+4 -34 -> -0E+4
-cpsx314 copysign -0E+4 -34 -> -0E+4
-cpsx315 copysign 0.0000 -34 -> -0.0000
-cpsx316 copysign -0.0000 -34 -> -0.0000
-cpsx317 copysign 0E-141 -34 -> -0E-141
-cpsx318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-cpsx321 copysign 268268268 -18 -> -268268268
-cpsx322 copysign -268268268 -18 -> -268268268
-cpsx323 copysign 134134134 -18 -> -134134134
-cpsx324 copysign -134134134 -18 -> -134134134
-
--- Nmax, Nmin, Ntiny
-cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999
-cpsx332 copysign 1E-999 -18 -> -1E-999
-cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999
-cpsx334 copysign 1E-1007 -18 -> -1E-1007
-
-cpsx335 copysign -1E-1007 -18 -> -1E-1007
-cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999
-cpsx337 copysign -1E-999 -18 -> -1E-999
-cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999
-
--- Other kinds of RHS
-cpsx401 copysign 701 -34 -> -701
-cpsx402 copysign -720 -34 -> -720
-cpsx403 copysign 701 -0 -> -701
-cpsx404 copysign -720 -0 -> -720
-cpsx405 copysign 701 +0 -> 701
-cpsx406 copysign -720 +0 -> 720
-cpsx407 copysign 701 +34 -> 701
-cpsx408 copysign -720 +34 -> 720
-
-cpsx413 copysign 701 -Inf -> -701
-cpsx414 copysign -720 -Inf -> -720
-cpsx415 copysign 701 +Inf -> 701
-cpsx416 copysign -720 +Inf -> 720
-
-cpsx420 copysign 701 -NaN -> -701
-cpsx421 copysign -720 -NaN -> -720
-cpsx422 copysign 701 +NaN -> 701
-cpsx423 copysign -720 +NaN -> 720
-cpsx425 copysign -720 +NaN8 -> 720
-
-cpsx426 copysign 701 -sNaN -> -701
-cpsx427 copysign -720 -sNaN -> -720
-cpsx428 copysign 701 +sNaN -> 701
-cpsx429 copysign -720 +sNaN -> 720
-cpsx430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- copysign.decTest -- quiet copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check, and examples from decArith
+cpsx001 copysign +7.50 11 -> 7.50
+cpsx002 copysign '1.50' '7.33' -> 1.50
+cpsx003 copysign '-1.50' '7.33' -> 1.50
+cpsx004 copysign '1.50' '-7.33' -> -1.50
+cpsx005 copysign '-1.50' '-7.33' -> -1.50
+
+-- Infinities
+cpsx011 copysign Infinity 11 -> Infinity
+cpsx012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+cpsx021 copysign NaN 11 -> NaN
+cpsx022 copysign -NaN 11 -> NaN
+cpsx023 copysign sNaN 11 -> sNaN
+cpsx024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+cpsx031 copysign NaN10 11 -> NaN10
+cpsx032 copysign -NaN10 11 -> NaN10
+cpsx033 copysign sNaN10 11 -> sNaN10
+cpsx034 copysign -sNaN10 11 -> sNaN10
+cpsx035 copysign NaN7 11 -> NaN7
+cpsx036 copysign -NaN7 11 -> NaN7
+cpsx037 copysign sNaN101 11 -> sNaN101
+cpsx038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+cpsx101 copysign 7 11 -> 7
+cpsx102 copysign -7 11 -> 7
+cpsx103 copysign 75 11 -> 75
+cpsx104 copysign -75 11 -> 75
+cpsx105 copysign 7.50 11 -> 7.50
+cpsx106 copysign -7.50 11 -> 7.50
+cpsx107 copysign 7.500 11 -> 7.500
+cpsx108 copysign -7.500 11 -> 7.500
+
+-- zeros
+cpsx111 copysign 0 11 -> 0
+cpsx112 copysign -0 11 -> 0
+cpsx113 copysign 0E+4 11 -> 0E+4
+cpsx114 copysign -0E+4 11 -> 0E+4
+cpsx115 copysign 0.0000 11 -> 0.0000
+cpsx116 copysign -0.0000 11 -> 0.0000
+cpsx117 copysign 0E-141 11 -> 0E-141
+cpsx118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+cpsx121 copysign 268268268 11 -> 268268268
+cpsx122 copysign -268268268 11 -> 268268268
+cpsx123 copysign 134134134 11 -> 134134134
+cpsx124 copysign -134134134 11 -> 134134134
+
+-- Nmax, Nmin, Ntiny
+cpsx131 copysign 9.99999999E+999 11 -> 9.99999999E+999
+cpsx132 copysign 1E-999 11 -> 1E-999
+cpsx133 copysign 1.00000000E-999 11 -> 1.00000000E-999
+cpsx134 copysign 1E-1007 11 -> 1E-1007
+
+cpsx135 copysign -1E-1007 11 -> 1E-1007
+cpsx136 copysign -1.00000000E-999 11 -> 1.00000000E-999
+cpsx137 copysign -1E-999 11 -> 1E-999
+cpsx138 copysign -9.99999999E+999 11 -> 9.99999999E+999
+
+-- repeat with negative RHS
+
+-- Infinities
+cpsx211 copysign Infinity -34 -> -Infinity
+cpsx212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+cpsx221 copysign NaN -34 -> -NaN
+cpsx222 copysign -NaN -34 -> -NaN
+cpsx223 copysign sNaN -34 -> -sNaN
+cpsx224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+cpsx231 copysign NaN10 -34 -> -NaN10
+cpsx232 copysign -NaN10 -34 -> -NaN10
+cpsx233 copysign sNaN10 -34 -> -sNaN10
+cpsx234 copysign -sNaN10 -34 -> -sNaN10
+cpsx235 copysign NaN7 -34 -> -NaN7
+cpsx236 copysign -NaN7 -34 -> -NaN7
+cpsx237 copysign sNaN101 -34 -> -sNaN101
+cpsx238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+cpsx301 copysign 7 -34 -> -7
+cpsx302 copysign -7 -34 -> -7
+cpsx303 copysign 75 -34 -> -75
+cpsx304 copysign -75 -34 -> -75
+cpsx305 copysign 7.50 -34 -> -7.50
+cpsx306 copysign -7.50 -34 -> -7.50
+cpsx307 copysign 7.500 -34 -> -7.500
+cpsx308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+cpsx311 copysign 0 -34 -> -0
+cpsx312 copysign -0 -34 -> -0
+cpsx313 copysign 0E+4 -34 -> -0E+4
+cpsx314 copysign -0E+4 -34 -> -0E+4
+cpsx315 copysign 0.0000 -34 -> -0.0000
+cpsx316 copysign -0.0000 -34 -> -0.0000
+cpsx317 copysign 0E-141 -34 -> -0E-141
+cpsx318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+cpsx321 copysign 268268268 -18 -> -268268268
+cpsx322 copysign -268268268 -18 -> -268268268
+cpsx323 copysign 134134134 -18 -> -134134134
+cpsx324 copysign -134134134 -18 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+cpsx331 copysign 9.99999999E+999 -18 -> -9.99999999E+999
+cpsx332 copysign 1E-999 -18 -> -1E-999
+cpsx333 copysign 1.00000000E-999 -18 -> -1.00000000E-999
+cpsx334 copysign 1E-1007 -18 -> -1E-1007
+
+cpsx335 copysign -1E-1007 -18 -> -1E-1007
+cpsx336 copysign -1.00000000E-999 -18 -> -1.00000000E-999
+cpsx337 copysign -1E-999 -18 -> -1E-999
+cpsx338 copysign -9.99999999E+999 -18 -> -9.99999999E+999
+
+-- Other kinds of RHS
+cpsx401 copysign 701 -34 -> -701
+cpsx402 copysign -720 -34 -> -720
+cpsx403 copysign 701 -0 -> -701
+cpsx404 copysign -720 -0 -> -720
+cpsx405 copysign 701 +0 -> 701
+cpsx406 copysign -720 +0 -> 720
+cpsx407 copysign 701 +34 -> 701
+cpsx408 copysign -720 +34 -> 720
+
+cpsx413 copysign 701 -Inf -> -701
+cpsx414 copysign -720 -Inf -> -720
+cpsx415 copysign 701 +Inf -> 701
+cpsx416 copysign -720 +Inf -> 720
+
+cpsx420 copysign 701 -NaN -> -701
+cpsx421 copysign -720 -NaN -> -720
+cpsx422 copysign 701 +NaN -> 701
+cpsx423 copysign -720 +NaN -> 720
+cpsx425 copysign -720 +NaN8 -> 720
+
+cpsx426 copysign 701 -sNaN -> -701
+cpsx427 copysign -720 -sNaN -> -720
+cpsx428 copysign 701 +sNaN -> 701
+cpsx429 copysign -720 +sNaN -> 720
+cpsx430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/ddAbs.decTest b/Lib/test/decimaltestdata/ddAbs.decTest
index b98d64a11aa..c6f5a7cda39 100644
--- a/Lib/test/decimaltestdata/ddAbs.decTest
+++ b/Lib/test/decimaltestdata/ddAbs.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- ddAbs.decTest -- decDouble absolute value, heeding sNaN --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddabs001 abs '1' -> '1'
-ddabs002 abs '-1' -> '1'
-ddabs003 abs '1.00' -> '1.00'
-ddabs004 abs '-1.00' -> '1.00'
-ddabs005 abs '0' -> '0'
-ddabs006 abs '0.00' -> '0.00'
-ddabs007 abs '00.0' -> '0.0'
-ddabs008 abs '00.00' -> '0.00'
-ddabs009 abs '00' -> '0'
-
-ddabs010 abs '-2' -> '2'
-ddabs011 abs '2' -> '2'
-ddabs012 abs '-2.00' -> '2.00'
-ddabs013 abs '2.00' -> '2.00'
-ddabs014 abs '-0' -> '0'
-ddabs015 abs '-0.00' -> '0.00'
-ddabs016 abs '-00.0' -> '0.0'
-ddabs017 abs '-00.00' -> '0.00'
-ddabs018 abs '-00' -> '0'
-
-ddabs020 abs '-2000000' -> '2000000'
-ddabs021 abs '2000000' -> '2000000'
-
-ddabs030 abs '+0.1' -> '0.1'
-ddabs031 abs '-0.1' -> '0.1'
-ddabs032 abs '+0.01' -> '0.01'
-ddabs033 abs '-0.01' -> '0.01'
-ddabs034 abs '+0.001' -> '0.001'
-ddabs035 abs '-0.001' -> '0.001'
-ddabs036 abs '+0.000001' -> '0.000001'
-ddabs037 abs '-0.000001' -> '0.000001'
-ddabs038 abs '+0.000000000001' -> '1E-12'
-ddabs039 abs '-0.000000000001' -> '1E-12'
-
--- examples from decArith
-ddabs040 abs '2.1' -> '2.1'
-ddabs041 abs '-100' -> '100'
-ddabs042 abs '101.5' -> '101.5'
-ddabs043 abs '-101.5' -> '101.5'
-
--- more fixed, potential LHS swaps/overlays if done by subtract 0
-ddabs060 abs '-56267E-10' -> '0.0000056267'
-ddabs061 abs '-56267E-5' -> '0.56267'
-ddabs062 abs '-56267E-2' -> '562.67'
-ddabs063 abs '-56267E-1' -> '5626.7'
-ddabs065 abs '-56267E-0' -> '56267'
-
--- subnormals and underflow
-
--- long operand tests
-ddabs321 abs 1234567890123456 -> 1234567890123456
-ddabs322 abs 12345678000 -> 12345678000
-ddabs323 abs 1234567800 -> 1234567800
-ddabs324 abs 1234567890 -> 1234567890
-ddabs325 abs 1234567891 -> 1234567891
-ddabs326 abs 12345678901 -> 12345678901
-ddabs327 abs 1234567896 -> 1234567896
-
--- zeros
-ddabs111 abs 0 -> 0
-ddabs112 abs -0 -> 0
-ddabs113 abs 0E+6 -> 0E+6
-ddabs114 abs -0E+6 -> 0E+6
-ddabs115 abs 0.0000 -> 0.0000
-ddabs116 abs -0.0000 -> 0.0000
-ddabs117 abs 0E-141 -> 0E-141
-ddabs118 abs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddabs121 abs 2682682682682682 -> 2682682682682682
-ddabs122 abs -2682682682682682 -> 2682682682682682
-ddabs123 abs 1341341341341341 -> 1341341341341341
-ddabs124 abs -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddabs131 abs 9.999999999999999E+384 -> 9.999999999999999E+384
-ddabs132 abs 1E-383 -> 1E-383
-ddabs133 abs 1.000000000000000E-383 -> 1.000000000000000E-383
-ddabs134 abs 1E-398 -> 1E-398 Subnormal
-
-ddabs135 abs -1E-398 -> 1E-398 Subnormal
-ddabs136 abs -1.000000000000000E-383 -> 1.000000000000000E-383
-ddabs137 abs -1E-383 -> 1E-383
-ddabs138 abs -9.999999999999999E+384 -> 9.999999999999999E+384
-
--- specials
-ddabs520 abs 'Inf' -> 'Infinity'
-ddabs521 abs '-Inf' -> 'Infinity'
-ddabs522 abs NaN -> NaN
-ddabs523 abs sNaN -> NaN Invalid_operation
-ddabs524 abs NaN22 -> NaN22
-ddabs525 abs sNaN33 -> NaN33 Invalid_operation
-ddabs526 abs -NaN22 -> -NaN22
-ddabs527 abs -sNaN33 -> -NaN33 Invalid_operation
-
--- Null tests
-ddabs900 abs # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddAbs.decTest -- decDouble absolute value, heeding sNaN --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddabs001 abs '1' -> '1'
+ddabs002 abs '-1' -> '1'
+ddabs003 abs '1.00' -> '1.00'
+ddabs004 abs '-1.00' -> '1.00'
+ddabs005 abs '0' -> '0'
+ddabs006 abs '0.00' -> '0.00'
+ddabs007 abs '00.0' -> '0.0'
+ddabs008 abs '00.00' -> '0.00'
+ddabs009 abs '00' -> '0'
+
+ddabs010 abs '-2' -> '2'
+ddabs011 abs '2' -> '2'
+ddabs012 abs '-2.00' -> '2.00'
+ddabs013 abs '2.00' -> '2.00'
+ddabs014 abs '-0' -> '0'
+ddabs015 abs '-0.00' -> '0.00'
+ddabs016 abs '-00.0' -> '0.0'
+ddabs017 abs '-00.00' -> '0.00'
+ddabs018 abs '-00' -> '0'
+
+ddabs020 abs '-2000000' -> '2000000'
+ddabs021 abs '2000000' -> '2000000'
+
+ddabs030 abs '+0.1' -> '0.1'
+ddabs031 abs '-0.1' -> '0.1'
+ddabs032 abs '+0.01' -> '0.01'
+ddabs033 abs '-0.01' -> '0.01'
+ddabs034 abs '+0.001' -> '0.001'
+ddabs035 abs '-0.001' -> '0.001'
+ddabs036 abs '+0.000001' -> '0.000001'
+ddabs037 abs '-0.000001' -> '0.000001'
+ddabs038 abs '+0.000000000001' -> '1E-12'
+ddabs039 abs '-0.000000000001' -> '1E-12'
+
+-- examples from decArith
+ddabs040 abs '2.1' -> '2.1'
+ddabs041 abs '-100' -> '100'
+ddabs042 abs '101.5' -> '101.5'
+ddabs043 abs '-101.5' -> '101.5'
+
+-- more fixed, potential LHS swaps/overlays if done by subtract 0
+ddabs060 abs '-56267E-10' -> '0.0000056267'
+ddabs061 abs '-56267E-5' -> '0.56267'
+ddabs062 abs '-56267E-2' -> '562.67'
+ddabs063 abs '-56267E-1' -> '5626.7'
+ddabs065 abs '-56267E-0' -> '56267'
+
+-- subnormals and underflow
+
+-- long operand tests
+ddabs321 abs 1234567890123456 -> 1234567890123456
+ddabs322 abs 12345678000 -> 12345678000
+ddabs323 abs 1234567800 -> 1234567800
+ddabs324 abs 1234567890 -> 1234567890
+ddabs325 abs 1234567891 -> 1234567891
+ddabs326 abs 12345678901 -> 12345678901
+ddabs327 abs 1234567896 -> 1234567896
+
+-- zeros
+ddabs111 abs 0 -> 0
+ddabs112 abs -0 -> 0
+ddabs113 abs 0E+6 -> 0E+6
+ddabs114 abs -0E+6 -> 0E+6
+ddabs115 abs 0.0000 -> 0.0000
+ddabs116 abs -0.0000 -> 0.0000
+ddabs117 abs 0E-141 -> 0E-141
+ddabs118 abs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddabs121 abs 2682682682682682 -> 2682682682682682
+ddabs122 abs -2682682682682682 -> 2682682682682682
+ddabs123 abs 1341341341341341 -> 1341341341341341
+ddabs124 abs -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddabs131 abs 9.999999999999999E+384 -> 9.999999999999999E+384
+ddabs132 abs 1E-383 -> 1E-383
+ddabs133 abs 1.000000000000000E-383 -> 1.000000000000000E-383
+ddabs134 abs 1E-398 -> 1E-398 Subnormal
+
+ddabs135 abs -1E-398 -> 1E-398 Subnormal
+ddabs136 abs -1.000000000000000E-383 -> 1.000000000000000E-383
+ddabs137 abs -1E-383 -> 1E-383
+ddabs138 abs -9.999999999999999E+384 -> 9.999999999999999E+384
+
+-- specials
+ddabs520 abs 'Inf' -> 'Infinity'
+ddabs521 abs '-Inf' -> 'Infinity'
+ddabs522 abs NaN -> NaN
+ddabs523 abs sNaN -> NaN Invalid_operation
+ddabs524 abs NaN22 -> NaN22
+ddabs525 abs sNaN33 -> NaN33 Invalid_operation
+ddabs526 abs -NaN22 -> -NaN22
+ddabs527 abs -sNaN33 -> -NaN33 Invalid_operation
+
+-- Null tests
+ddabs900 abs # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddAdd.decTest b/Lib/test/decimaltestdata/ddAdd.decTest
index 0f12ce44459..c0a25b34130 100644
--- a/Lib/test/decimaltestdata/ddAdd.decTest
+++ b/Lib/test/decimaltestdata/ddAdd.decTest
@@ -1,1328 +1,1328 @@
-------------------------------------------------------------------------
--- ddAdd.decTest -- decDouble addition --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- [first group are 'quick confidence check']
-ddadd001 add 1 1 -> 2
-ddadd002 add 2 3 -> 5
-ddadd003 add '5.75' '3.3' -> 9.05
-ddadd004 add '5' '-3' -> 2
-ddadd005 add '-5' '-3' -> -8
-ddadd006 add '-7' '2.5' -> -4.5
-ddadd007 add '0.7' '0.3' -> 1.0
-ddadd008 add '1.25' '1.25' -> 2.50
-ddadd009 add '1.23456789' '1.00000000' -> '2.23456789'
-ddadd010 add '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-ddadd011 add '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
-ddadd012 add '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
-ddadd013 add '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-ddadd014 add '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
-ddadd015 add '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
-ddadd016 add '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
-ddadd017 add '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
-ddadd018 add '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
-ddadd019 add '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
-ddadd020 add '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
-
-ddadd021 add 0 1 -> 1
-ddadd022 add 1 1 -> 2
-ddadd023 add 2 1 -> 3
-ddadd024 add 3 1 -> 4
-ddadd025 add 4 1 -> 5
-ddadd026 add 5 1 -> 6
-ddadd027 add 6 1 -> 7
-ddadd028 add 7 1 -> 8
-ddadd029 add 8 1 -> 9
-ddadd030 add 9 1 -> 10
-
--- some carrying effects
-ddadd031 add '0.9998' '0.0000' -> '0.9998'
-ddadd032 add '0.9998' '0.0001' -> '0.9999'
-ddadd033 add '0.9998' '0.0002' -> '1.0000'
-ddadd034 add '0.9998' '0.0003' -> '1.0001'
-
-ddadd035 add '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd036 add '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd037 add '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddadd038 add '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-ddadd039 add '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-ddadd040 add '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddadd041 add '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddadd042 add '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-ddadd044 add '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-ddadd045 add '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
--- same, without rounding
-ddadd046 add '10000e+9' '7' -> '10000000000007'
-ddadd047 add '10000e+9' '70' -> '10000000000070'
-ddadd048 add '10000e+9' '700' -> '10000000000700'
-ddadd049 add '10000e+9' '7000' -> '10000000007000'
-ddadd050 add '10000e+9' '70000' -> '10000000070000'
-ddadd051 add '10000e+9' '700000' -> '10000000700000'
-ddadd052 add '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-ddadd053 add '12' '7.00' -> '19.00'
-ddadd054 add '1.3' '-1.07' -> '0.23'
-ddadd055 add '1.3' '-1.30' -> '0.00'
-ddadd056 add '1.3' '-2.07' -> '-0.77'
-ddadd057 add '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-ddadd061 add 1 '0.0001' -> '1.0001'
-ddadd062 add 1 '0.00001' -> '1.00001'
-ddadd063 add 1 '0.000001' -> '1.000001'
-ddadd064 add 1 '0.0000001' -> '1.0000001'
-ddadd065 add 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-ddadd070 add 1 0 -> 1
-ddadd071 add 1 0. -> 1
-ddadd072 add 1 .0 -> 1.0
-ddadd073 add 1 0.0 -> 1.0
-ddadd074 add 1 0.00 -> 1.00
-ddadd075 add 0 1 -> 1
-ddadd076 add 0. 1 -> 1
-ddadd077 add .0 1 -> 1.0
-ddadd078 add 0.0 1 -> 1.0
-ddadd079 add 0.00 1 -> 1.00
-
--- some carries
-ddadd080 add 999999998 1 -> 999999999
-ddadd081 add 999999999 1 -> 1000000000
-ddadd082 add 99999999 1 -> 100000000
-ddadd083 add 9999999 1 -> 10000000
-ddadd084 add 999999 1 -> 1000000
-ddadd085 add 99999 1 -> 100000
-ddadd086 add 9999 1 -> 10000
-ddadd087 add 999 1 -> 1000
-ddadd088 add 99 1 -> 100
-ddadd089 add 9 1 -> 10
-
-
--- more LHS swaps
-ddadd090 add '-56267E-10' 0 -> '-0.0000056267'
-ddadd091 add '-56267E-6' 0 -> '-0.056267'
-ddadd092 add '-56267E-5' 0 -> '-0.56267'
-ddadd093 add '-56267E-4' 0 -> '-5.6267'
-ddadd094 add '-56267E-3' 0 -> '-56.267'
-ddadd095 add '-56267E-2' 0 -> '-562.67'
-ddadd096 add '-56267E-1' 0 -> '-5626.7'
-ddadd097 add '-56267E-0' 0 -> '-56267'
-ddadd098 add '-5E-10' 0 -> '-5E-10'
-ddadd099 add '-5E-7' 0 -> '-5E-7'
-ddadd100 add '-5E-6' 0 -> '-0.000005'
-ddadd101 add '-5E-5' 0 -> '-0.00005'
-ddadd102 add '-5E-4' 0 -> '-0.0005'
-ddadd103 add '-5E-1' 0 -> '-0.5'
-ddadd104 add '-5E0' 0 -> '-5'
-ddadd105 add '-5E1' 0 -> '-50'
-ddadd106 add '-5E5' 0 -> '-500000'
-ddadd107 add '-5E15' 0 -> '-5000000000000000'
-ddadd108 add '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddadd109 add '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddadd110 add '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddadd111 add '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-ddadd113 add 0 '-56267E-10' -> '-0.0000056267'
-ddadd114 add 0 '-56267E-6' -> '-0.056267'
-ddadd116 add 0 '-56267E-5' -> '-0.56267'
-ddadd117 add 0 '-56267E-4' -> '-5.6267'
-ddadd119 add 0 '-56267E-3' -> '-56.267'
-ddadd120 add 0 '-56267E-2' -> '-562.67'
-ddadd121 add 0 '-56267E-1' -> '-5626.7'
-ddadd122 add 0 '-56267E-0' -> '-56267'
-ddadd123 add 0 '-5E-10' -> '-5E-10'
-ddadd124 add 0 '-5E-7' -> '-5E-7'
-ddadd125 add 0 '-5E-6' -> '-0.000005'
-ddadd126 add 0 '-5E-5' -> '-0.00005'
-ddadd127 add 0 '-5E-4' -> '-0.0005'
-ddadd128 add 0 '-5E-1' -> '-0.5'
-ddadd129 add 0 '-5E0' -> '-5'
-ddadd130 add 0 '-5E1' -> '-50'
-ddadd131 add 0 '-5E5' -> '-500000'
-ddadd132 add 0 '-5E15' -> '-5000000000000000'
-ddadd133 add 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-ddadd134 add 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-ddadd135 add 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-ddadd136 add 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-ddadd137 add 1 '0E-19' -> '1.000000000000000' Rounded
-ddadd138 add -1 '0E-19' -> '-1.000000000000000' Rounded
-ddadd139 add '0E-19' 1 -> '1.000000000000000' Rounded
-ddadd140 add '0E-19' -1 -> '-1.000000000000000' Rounded
-ddadd141 add 1E+11 0.0000 -> '100000000000.0000'
-ddadd142 add 1E+11 0.00000 -> '100000000000.0000' Rounded
-ddadd143 add 0.000 1E+12 -> '1000000000000.000'
-ddadd144 add 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-ddadd146 add '00.0' 0 -> '0.0'
-ddadd147 add '0.00' 0 -> '0.00'
-ddadd148 add 0 '0.00' -> '0.00'
-ddadd149 add 0 '00.0' -> '0.0'
-ddadd150 add '00.0' '0.00' -> '0.00'
-ddadd151 add '0.00' '00.0' -> '0.00'
-ddadd152 add '3' '.3' -> '3.3'
-ddadd153 add '3.' '.3' -> '3.3'
-ddadd154 add '3.0' '.3' -> '3.3'
-ddadd155 add '3.00' '.3' -> '3.30'
-ddadd156 add '3' '3' -> '6'
-ddadd157 add '3' '+3' -> '6'
-ddadd158 add '3' '-3' -> '0'
-ddadd159 add '0.3' '-0.3' -> '0.0'
-ddadd160 add '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-ddadd161 add '1E+12' '-1' -> '999999999999'
-ddadd162 add '1E+12' '1.11' -> '1000000000001.11'
-ddadd163 add '1.11' '1E+12' -> '1000000000001.11'
-ddadd164 add '-1' '1E+12' -> '999999999999'
-ddadd165 add '7E+12' '-1' -> '6999999999999'
-ddadd166 add '7E+12' '1.11' -> '7000000000001.11'
-ddadd167 add '1.11' '7E+12' -> '7000000000001.11'
-ddadd168 add '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
--- 1.234567890123456 1234567890123456 1 234567890123456
-ddadd170 add '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
-ddadd171 add '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
-ddadd172 add '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
-ddadd173 add '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
-ddadd174 add '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
-ddadd175 add '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
-ddadd176 add '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
-ddadd177 add '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
-ddadd178 add '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
-ddadd179 add '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
-ddadd180 add '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
-ddadd181 add '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
-ddadd182 add '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
-ddadd183 add '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddadd200 add '1234560123456789' 0 -> '1234560123456789'
-ddadd201 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd202 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd203 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd204 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd205 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd206 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd207 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd208 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddadd209 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddadd210 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddadd211 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddadd212 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddadd213 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddadd214 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddadd215 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddadd216 add '1234560123456789' 1 -> '1234560123456790'
-ddadd217 add '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
-ddadd218 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd219 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
-rounding: half_even
-ddadd220 add '1234560123456789' 0 -> '1234560123456789'
-ddadd221 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd222 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd223 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd224 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd225 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd226 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd227 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd228 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddadd229 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddadd230 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddadd231 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddadd232 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddadd233 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddadd234 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddadd235 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddadd236 add '1234560123456789' 1 -> '1234560123456790'
-ddadd237 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddadd238 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd239 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
--- critical few with even bottom digit...
-ddadd240 add '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
-ddadd241 add '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
-ddadd242 add '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
-
-rounding: down
-ddadd250 add '1234560123456789' 0 -> '1234560123456789'
-ddadd251 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddadd252 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddadd253 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddadd254 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddadd255 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddadd256 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddadd257 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddadd258 add '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
-ddadd259 add '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
-ddadd260 add '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
-ddadd261 add '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
-ddadd262 add '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
-ddadd263 add '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
-ddadd264 add '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
-ddadd265 add '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
-ddadd266 add '1234560123456789' 1 -> '1234560123456790'
-ddadd267 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddadd268 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddadd269 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-ddadd301 add -1 1 -> 0
-ddadd302 add 0 1 -> 1
-ddadd303 add 1 1 -> 2
-ddadd304 add 12 1 -> 13
-ddadd305 add 98 1 -> 99
-ddadd306 add 99 1 -> 100
-ddadd307 add 100 1 -> 101
-ddadd308 add 101 1 -> 102
-ddadd309 add -1 -1 -> -2
-ddadd310 add 0 -1 -> -1
-ddadd311 add 1 -1 -> 0
-ddadd312 add 12 -1 -> 11
-ddadd313 add 98 -1 -> 97
-ddadd314 add 99 -1 -> 98
-ddadd315 add 100 -1 -> 99
-ddadd316 add 101 -1 -> 100
-
-ddadd321 add -0.01 0.01 -> 0.00
-ddadd322 add 0.00 0.01 -> 0.01
-ddadd323 add 0.01 0.01 -> 0.02
-ddadd324 add 0.12 0.01 -> 0.13
-ddadd325 add 0.98 0.01 -> 0.99
-ddadd326 add 0.99 0.01 -> 1.00
-ddadd327 add 1.00 0.01 -> 1.01
-ddadd328 add 1.01 0.01 -> 1.02
-ddadd329 add -0.01 -0.01 -> -0.02
-ddadd330 add 0.00 -0.01 -> -0.01
-ddadd331 add 0.01 -0.01 -> 0.00
-ddadd332 add 0.12 -0.01 -> 0.11
-ddadd333 add 0.98 -0.01 -> 0.97
-ddadd334 add 0.99 -0.01 -> 0.98
-ddadd335 add 1.00 -0.01 -> 0.99
-ddadd336 add 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-ddadd340 add 1E+3 0 -> 1000
-ddadd341 add 1E+15 0 -> 1000000000000000
-ddadd342 add 1E+16 0 -> 1.000000000000000E+16 Rounded
-ddadd343 add 1E+20 0 -> 1.000000000000000E+20 Rounded
--- which simply follow from these cases ...
-ddadd344 add 1E+3 1 -> 1001
-ddadd345 add 1E+15 1 -> 1000000000000001
-ddadd346 add 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-ddadd347 add 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
-ddadd348 add 1E+3 7 -> 1007
-ddadd349 add 1E+15 7 -> 1000000000000007
-ddadd350 add 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-ddadd351 add 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-ddadd360 add 0E+50 10000E+1 -> 1.0000E+5
-ddadd361 add 0E-50 10000E+1 -> 100000.0000000000 Rounded
-ddadd362 add 10000E+1 0E-50 -> 100000.0000000000 Rounded
-ddadd363 add 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-ddadd364 add 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-ddadd370 add 999999999999999 815 -> 1000000000000814
-ddadd371 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_up
-ddadd372 add 999999999999999 815 -> 1000000000000814
-ddadd373 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_even
-ddadd374 add 999999999999999 815 -> 1000000000000814
-ddadd375 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-
--- operands folded
-ddadd380 add 1E+384 1E+384 -> 2.000000000000000E+384 Clamped
-ddadd381 add 1E+380 1E+380 -> 2.00000000000E+380 Clamped
-ddadd382 add 1E+376 1E+376 -> 2.0000000E+376 Clamped
-ddadd383 add 1E+372 1E+372 -> 2.000E+372 Clamped
-ddadd384 add 1E+370 1E+370 -> 2.0E+370 Clamped
-ddadd385 add 1E+369 1E+369 -> 2E+369
-ddadd386 add 1E+368 1E+368 -> 2E+368
-
--- ulp replacement tests
-ddadd400 add 1 77e-14 -> 1.00000000000077
-ddadd401 add 1 77e-15 -> 1.000000000000077
-ddadd402 add 1 77e-16 -> 1.000000000000008 Inexact Rounded
-ddadd403 add 1 77e-17 -> 1.000000000000001 Inexact Rounded
-ddadd404 add 1 77e-18 -> 1.000000000000000 Inexact Rounded
-ddadd405 add 1 77e-19 -> 1.000000000000000 Inexact Rounded
-ddadd406 add 1 77e-299 -> 1.000000000000000 Inexact Rounded
-
-ddadd410 add 10 77e-14 -> 10.00000000000077
-ddadd411 add 10 77e-15 -> 10.00000000000008 Inexact Rounded
-ddadd412 add 10 77e-16 -> 10.00000000000001 Inexact Rounded
-ddadd413 add 10 77e-17 -> 10.00000000000000 Inexact Rounded
-ddadd414 add 10 77e-18 -> 10.00000000000000 Inexact Rounded
-ddadd415 add 10 77e-19 -> 10.00000000000000 Inexact Rounded
-ddadd416 add 10 77e-299 -> 10.00000000000000 Inexact Rounded
-
-ddadd420 add 77e-14 1 -> 1.00000000000077
-ddadd421 add 77e-15 1 -> 1.000000000000077
-ddadd422 add 77e-16 1 -> 1.000000000000008 Inexact Rounded
-ddadd423 add 77e-17 1 -> 1.000000000000001 Inexact Rounded
-ddadd424 add 77e-18 1 -> 1.000000000000000 Inexact Rounded
-ddadd425 add 77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddadd426 add 77e-299 1 -> 1.000000000000000 Inexact Rounded
-
-ddadd430 add 77e-14 10 -> 10.00000000000077
-ddadd431 add 77e-15 10 -> 10.00000000000008 Inexact Rounded
-ddadd432 add 77e-16 10 -> 10.00000000000001 Inexact Rounded
-ddadd433 add 77e-17 10 -> 10.00000000000000 Inexact Rounded
-ddadd434 add 77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddadd435 add 77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddadd436 add 77e-299 10 -> 10.00000000000000 Inexact Rounded
-
--- fastpath boundary (more in dqadd)
--- 1234567890123456
-ddadd539 add '4444444444444444' '3333333333333333' -> '7777777777777777'
-ddadd540 add '4444444444444444' '4444444444444444' -> '8888888888888888'
-ddadd541 add '4444444444444444' '5555555555555555' -> '9999999999999999'
-ddadd542 add '3333333333333333' '4444444444444444' -> '7777777777777777'
-ddadd543 add '4444444444444444' '4444444444444444' -> '8888888888888888'
-ddadd544 add '5555555555555555' '4444444444444444' -> '9999999999999999'
-ddadd545 add '3000004000000000' '3000000000000040' -> '6000004000000040'
-ddadd546 add '3000000400000000' '4000000000000400' -> '7000000400000400'
-ddadd547 add '3000000040000000' '5000000000004000' -> '8000000040004000'
-ddadd548 add '4000000004000000' '3000000000040000' -> '7000000004040000'
-ddadd549 add '4000000000400000' '4000000000400000' -> '8000000000800000'
-ddadd550 add '4000000000040000' '5000000004000000' -> '9000000004040000'
-ddadd551 add '5000000000004000' '3000000040000000' -> '8000000040004000'
-ddadd552 add '5000000000000400' '4000000400000000' -> '9000000400000400'
-ddadd553 add '5000000000000040' '5000004000000000' -> 1.000000400000004E+16 Rounded
--- check propagation
-ddadd554 add '8999999999999999' '0000000000000001' -> 9000000000000000
-ddadd555 add '0000000000000001' '8999999999999999' -> 9000000000000000
-ddadd556 add '0999999999999999' '0000000000000001' -> 1000000000000000
-ddadd557 add '0000000000000001' '0999999999999999' -> 1000000000000000
-ddadd558 add '4444444444444444' '4555555555555556' -> 9000000000000000
-ddadd559 add '4555555555555556' '4444444444444444' -> 9000000000000000
-
--- negative ulps
-ddadd6440 add 1 -77e-14 -> 0.99999999999923
-ddadd6441 add 1 -77e-15 -> 0.999999999999923
-ddadd6442 add 1 -77e-16 -> 0.9999999999999923
-ddadd6443 add 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-ddadd6444 add 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-ddadd6445 add 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-ddadd6446 add 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-ddadd6450 add 10 -77e-14 -> 9.99999999999923
-ddadd6451 add 10 -77e-15 -> 9.999999999999923
-ddadd6452 add 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-ddadd6453 add 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-ddadd6454 add 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-ddadd6455 add 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-ddadd6456 add 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-ddadd6460 add -77e-14 1 -> 0.99999999999923
-ddadd6461 add -77e-15 1 -> 0.999999999999923
-ddadd6462 add -77e-16 1 -> 0.9999999999999923
-ddadd6463 add -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-ddadd6464 add -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-ddadd6465 add -77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddadd6466 add -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-ddadd6470 add -77e-14 10 -> 9.99999999999923
-ddadd6471 add -77e-15 10 -> 9.999999999999923
-ddadd6472 add -77e-16 10 -> 9.999999999999992 Inexact Rounded
-ddadd6473 add -77e-17 10 -> 9.999999999999999 Inexact Rounded
-ddadd6474 add -77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddadd6475 add -77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddadd6476 add -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddadd6480 add -1 77e-14 -> -0.99999999999923
-ddadd6481 add -1 77e-15 -> -0.999999999999923
-ddadd6482 add -1 77e-16 -> -0.9999999999999923
-ddadd6483 add -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-ddadd6484 add -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-ddadd6485 add -1 77e-19 -> -1.000000000000000 Inexact Rounded
-ddadd6486 add -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-ddadd6490 add -10 77e-14 -> -9.99999999999923
-ddadd6491 add -10 77e-15 -> -9.999999999999923
-ddadd6492 add -10 77e-16 -> -9.999999999999992 Inexact Rounded
-ddadd6493 add -10 77e-17 -> -9.999999999999999 Inexact Rounded
-ddadd6494 add -10 77e-18 -> -10.00000000000000 Inexact Rounded
-ddadd6495 add -10 77e-19 -> -10.00000000000000 Inexact Rounded
-ddadd6496 add -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-ddadd6500 add 77e-14 -1 -> -0.99999999999923
-ddadd6501 add 77e-15 -1 -> -0.999999999999923
-ddadd6502 add 77e-16 -1 -> -0.9999999999999923
-ddadd6503 add 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-ddadd6504 add 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-ddadd6505 add 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-ddadd6506 add 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-ddadd6510 add 77e-14 -10 -> -9.99999999999923
-ddadd6511 add 77e-15 -10 -> -9.999999999999923
-ddadd6512 add 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-ddadd6513 add 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-ddadd6514 add 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-ddadd6515 add 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-ddadd6516 add 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-ddadd6540 add '6543210123456789' 0 -> '6543210123456789'
-ddadd6541 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd6542 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd6543 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd6544 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd6545 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd6546 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd6547 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd6548 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddadd6549 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddadd6550 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddadd6551 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddadd6552 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddadd6553 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddadd6554 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddadd6555 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddadd6556 add '6543210123456789' 1 -> '6543210123456790'
-ddadd6557 add '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-ddadd6558 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd6559 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-ddadd6560 add '6543210123456789' 0 -> '6543210123456789'
-ddadd6561 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd6562 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd6563 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd6564 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd6565 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd6566 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd6567 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd6568 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddadd6569 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddadd6570 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddadd6571 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddadd6572 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddadd6573 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddadd6574 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddadd6575 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddadd6576 add '6543210123456789' 1 -> '6543210123456790'
-ddadd6577 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddadd6578 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd6579 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-ddadd7540 add '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
-ddadd7541 add '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-ddadd7542 add '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-ddadd7550 add '6543210123456789' 0 -> '6543210123456789'
-ddadd7551 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddadd7552 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddadd7553 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddadd7554 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddadd7555 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddadd7556 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddadd7557 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddadd7558 add '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-ddadd7559 add '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-ddadd7560 add '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-ddadd7561 add '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-ddadd7562 add '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-ddadd7563 add '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-ddadd7564 add '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-ddadd7565 add '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
-ddadd7566 add '6543210123456789' 1 -> '6543210123456790'
-ddadd7567 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddadd7568 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddadd7569 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- verify a query
-rounding: down
-ddadd7661 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-ddadd7662 add 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-ddadd7663 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-ddadd7664 add 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-ddadd7701 add 5.00 1.00E-3 -> 5.00100
-ddadd7702 add 00.00 0.000 -> 0.000
-ddadd7703 add 00.00 0E-3 -> 0.000
-ddadd7704 add 0E-3 00.00 -> 0.000
-
-ddadd7710 add 0E+3 00.00 -> 0.00
-ddadd7711 add 0E+3 00.0 -> 0.0
-ddadd7712 add 0E+3 00. -> 0
-ddadd7713 add 0E+3 00.E+1 -> 0E+1
-ddadd7714 add 0E+3 00.E+2 -> 0E+2
-ddadd7715 add 0E+3 00.E+3 -> 0E+3
-ddadd7716 add 0E+3 00.E+4 -> 0E+3
-ddadd7717 add 0E+3 00.E+5 -> 0E+3
-ddadd7718 add 0E+3 -00.0 -> 0.0
-ddadd7719 add 0E+3 -00. -> 0
-ddadd7731 add 0E+3 -00.E+1 -> 0E+1
-
-ddadd7720 add 00.00 0E+3 -> 0.00
-ddadd7721 add 00.0 0E+3 -> 0.0
-ddadd7722 add 00. 0E+3 -> 0
-ddadd7723 add 00.E+1 0E+3 -> 0E+1
-ddadd7724 add 00.E+2 0E+3 -> 0E+2
-ddadd7725 add 00.E+3 0E+3 -> 0E+3
-ddadd7726 add 00.E+4 0E+3 -> 0E+3
-ddadd7727 add 00.E+5 0E+3 -> 0E+3
-ddadd7728 add -00.00 0E+3 -> 0.00
-ddadd7729 add -00.0 0E+3 -> 0.0
-ddadd7730 add -00. 0E+3 -> 0
-
-ddadd7732 add 0 0 -> 0
-ddadd7733 add 0 -0 -> 0
-ddadd7734 add -0 0 -> 0
-ddadd7735 add -0 -0 -> -0 -- IEEE 854 special case
-
-ddadd7736 add 1 -1 -> 0
-ddadd7737 add -1 -1 -> -2
-ddadd7738 add 1 1 -> 2
-ddadd7739 add -1 1 -> 0
-
-ddadd7741 add 0 -1 -> -1
-ddadd7742 add -0 -1 -> -1
-ddadd7743 add 0 1 -> 1
-ddadd7744 add -0 1 -> 1
-ddadd7745 add -1 0 -> -1
-ddadd7746 add -1 -0 -> -1
-ddadd7747 add 1 0 -> 1
-ddadd7748 add 1 -0 -> 1
-
-ddadd7751 add 0.0 -1 -> -1.0
-ddadd7752 add -0.0 -1 -> -1.0
-ddadd7753 add 0.0 1 -> 1.0
-ddadd7754 add -0.0 1 -> 1.0
-ddadd7755 add -1.0 0 -> -1.0
-ddadd7756 add -1.0 -0 -> -1.0
-ddadd7757 add 1.0 0 -> 1.0
-ddadd7758 add 1.0 -0 -> 1.0
-
-ddadd7761 add 0 -1.0 -> -1.0
-ddadd7762 add -0 -1.0 -> -1.0
-ddadd7763 add 0 1.0 -> 1.0
-ddadd7764 add -0 1.0 -> 1.0
-ddadd7765 add -1 0.0 -> -1.0
-ddadd7766 add -1 -0.0 -> -1.0
-ddadd7767 add 1 0.0 -> 1.0
-ddadd7768 add 1 -0.0 -> 1.0
-
-ddadd7771 add 0.0 -1.0 -> -1.0
-ddadd7772 add -0.0 -1.0 -> -1.0
-ddadd7773 add 0.0 1.0 -> 1.0
-ddadd7774 add -0.0 1.0 -> 1.0
-ddadd7775 add -1.0 0.0 -> -1.0
-ddadd7776 add -1.0 -0.0 -> -1.0
-ddadd7777 add 1.0 0.0 -> 1.0
-ddadd7778 add 1.0 -0.0 -> 1.0
-
--- Specials
-ddadd7780 add -Inf -Inf -> -Infinity
-ddadd7781 add -Inf -1000 -> -Infinity
-ddadd7782 add -Inf -1 -> -Infinity
-ddadd7783 add -Inf -0 -> -Infinity
-ddadd7784 add -Inf 0 -> -Infinity
-ddadd7785 add -Inf 1 -> -Infinity
-ddadd7786 add -Inf 1000 -> -Infinity
-ddadd7787 add -1000 -Inf -> -Infinity
-ddadd7788 add -Inf -Inf -> -Infinity
-ddadd7789 add -1 -Inf -> -Infinity
-ddadd7790 add -0 -Inf -> -Infinity
-ddadd7791 add 0 -Inf -> -Infinity
-ddadd7792 add 1 -Inf -> -Infinity
-ddadd7793 add 1000 -Inf -> -Infinity
-ddadd7794 add Inf -Inf -> NaN Invalid_operation
-
-ddadd7800 add Inf -Inf -> NaN Invalid_operation
-ddadd7801 add Inf -1000 -> Infinity
-ddadd7802 add Inf -1 -> Infinity
-ddadd7803 add Inf -0 -> Infinity
-ddadd7804 add Inf 0 -> Infinity
-ddadd7805 add Inf 1 -> Infinity
-ddadd7806 add Inf 1000 -> Infinity
-ddadd7807 add Inf Inf -> Infinity
-ddadd7808 add -1000 Inf -> Infinity
-ddadd7809 add -Inf Inf -> NaN Invalid_operation
-ddadd7810 add -1 Inf -> Infinity
-ddadd7811 add -0 Inf -> Infinity
-ddadd7812 add 0 Inf -> Infinity
-ddadd7813 add 1 Inf -> Infinity
-ddadd7814 add 1000 Inf -> Infinity
-ddadd7815 add Inf Inf -> Infinity
-
-ddadd7821 add NaN -Inf -> NaN
-ddadd7822 add NaN -1000 -> NaN
-ddadd7823 add NaN -1 -> NaN
-ddadd7824 add NaN -0 -> NaN
-ddadd7825 add NaN 0 -> NaN
-ddadd7826 add NaN 1 -> NaN
-ddadd7827 add NaN 1000 -> NaN
-ddadd7828 add NaN Inf -> NaN
-ddadd7829 add NaN NaN -> NaN
-ddadd7830 add -Inf NaN -> NaN
-ddadd7831 add -1000 NaN -> NaN
-ddadd7832 add -1 NaN -> NaN
-ddadd7833 add -0 NaN -> NaN
-ddadd7834 add 0 NaN -> NaN
-ddadd7835 add 1 NaN -> NaN
-ddadd7836 add 1000 NaN -> NaN
-ddadd7837 add Inf NaN -> NaN
-
-ddadd7841 add sNaN -Inf -> NaN Invalid_operation
-ddadd7842 add sNaN -1000 -> NaN Invalid_operation
-ddadd7843 add sNaN -1 -> NaN Invalid_operation
-ddadd7844 add sNaN -0 -> NaN Invalid_operation
-ddadd7845 add sNaN 0 -> NaN Invalid_operation
-ddadd7846 add sNaN 1 -> NaN Invalid_operation
-ddadd7847 add sNaN 1000 -> NaN Invalid_operation
-ddadd7848 add sNaN NaN -> NaN Invalid_operation
-ddadd7849 add sNaN sNaN -> NaN Invalid_operation
-ddadd7850 add NaN sNaN -> NaN Invalid_operation
-ddadd7851 add -Inf sNaN -> NaN Invalid_operation
-ddadd7852 add -1000 sNaN -> NaN Invalid_operation
-ddadd7853 add -1 sNaN -> NaN Invalid_operation
-ddadd7854 add -0 sNaN -> NaN Invalid_operation
-ddadd7855 add 0 sNaN -> NaN Invalid_operation
-ddadd7856 add 1 sNaN -> NaN Invalid_operation
-ddadd7857 add 1000 sNaN -> NaN Invalid_operation
-ddadd7858 add Inf sNaN -> NaN Invalid_operation
-ddadd7859 add NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddadd7861 add NaN1 -Inf -> NaN1
-ddadd7862 add +NaN2 -1000 -> NaN2
-ddadd7863 add NaN3 1000 -> NaN3
-ddadd7864 add NaN4 Inf -> NaN4
-ddadd7865 add NaN5 +NaN6 -> NaN5
-ddadd7866 add -Inf NaN7 -> NaN7
-ddadd7867 add -1000 NaN8 -> NaN8
-ddadd7868 add 1000 NaN9 -> NaN9
-ddadd7869 add Inf +NaN10 -> NaN10
-ddadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
-ddadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
-ddadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
-ddadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
-ddadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
-ddadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
-ddadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
-ddadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
-ddadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
-ddadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddadd7882 add -NaN26 NaN28 -> -NaN26
-ddadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddadd7884 add 1000 -NaN30 -> -NaN30
-ddadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-ddadd7575 add 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
-ddadd7576 add -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
-
--- and another curious case
-ddadd7577 add 7.000000000000E-385 -1.00000E-391 -> 6.999999000000E-385 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-ddadd7972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-ddadd7973 add 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7974 add 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7975 add 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-ddadd7976 add 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-ddadd7977 add 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-ddadd7978 add 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-ddadd7979 add 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-ddadd7980 add 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-ddadd7981 add 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7982 add 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7983 add 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddadd7984 add 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-ddadd7985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-ddadd7986 add -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7987 add -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7988 add -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-ddadd7989 add -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7990 add -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7991 add -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7992 add -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7993 add -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-ddadd7994 add -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7995 add -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7996 add -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddadd7997 add -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-ddadd71100 add 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-ddadd71101 add 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-ddadd71103 add +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-ddadd71104 add 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-ddadd71105 add 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-ddadd71106 add 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-ddadd71107 add 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-ddadd71108 add 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-ddadd71109 add 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-ddadd71110 add -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-ddadd71111 add -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-ddadd71113 add -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-ddadd71114 add -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-ddadd71115 add -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-ddadd71116 add -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-ddadd71117 add -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-ddadd71118 add -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-ddadd71119 add -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-ddadd71300 add 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71310 add 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-ddadd71311 add 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-ddadd71312 add 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-ddadd71313 add 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-ddadd71314 add 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-ddadd71315 add 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-ddadd71316 add 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-ddadd71317 add 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-ddadd71318 add 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-ddadd71319 add 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-ddadd71320 add 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-ddadd71321 add 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71322 add 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71323 add 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71324 add 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-ddadd71325 add 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71326 add 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71327 add 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71328 add 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71329 add 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71330 add 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71331 add 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71332 add 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71333 add 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71334 add 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71335 add 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71336 add 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71337 add 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71338 add 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71339 add 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-ddadd71340 add 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-ddadd71341 add 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-ddadd71349 add 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-ddadd71350 add 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-ddadd71351 add 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-ddadd71352 add 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-ddadd71353 add 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-ddadd71354 add 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-ddadd71355 add 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-ddadd71356 add 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-ddadd71357 add 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-ddadd71358 add 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-ddadd71359 add 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-ddadd71360 add 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-ddadd71361 add 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71362 add 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71363 add 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71364 add 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-ddadd71365 add 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71367 add 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71368 add 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71369 add 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71370 add 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71371 add 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71372 add 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71373 add 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71374 add 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71375 add 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71376 add 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71377 add 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71378 add 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71379 add 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71380 add 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71381 add 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71382 add 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71383 add 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71384 add 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71385 add 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71386 add 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71387 add 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71388 add 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71389 add 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71390 add 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71391 add 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71392 add 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71393 add 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71394 add 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71395 add 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-ddadd71396 add 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-ddadd71420 add 0 1.123456789012345 -> 1.123456789012345
-ddadd71421 add 0 1.123456789012345E-1 -> 0.1123456789012345
-ddadd71422 add 0 1.123456789012345E-2 -> 0.01123456789012345
-ddadd71423 add 0 1.123456789012345E-3 -> 0.001123456789012345
-ddadd71424 add 0 1.123456789012345E-4 -> 0.0001123456789012345
-ddadd71425 add 0 1.123456789012345E-5 -> 0.00001123456789012345
-ddadd71426 add 0 1.123456789012345E-6 -> 0.000001123456789012345
-ddadd71427 add 0 1.123456789012345E-7 -> 1.123456789012345E-7
-ddadd71428 add 0 1.123456789012345E-8 -> 1.123456789012345E-8
-ddadd71429 add 0 1.123456789012345E-9 -> 1.123456789012345E-9
-ddadd71430 add 0 1.123456789012345E-10 -> 1.123456789012345E-10
-ddadd71431 add 0 1.123456789012345E-11 -> 1.123456789012345E-11
-ddadd71432 add 0 1.123456789012345E-12 -> 1.123456789012345E-12
-ddadd71433 add 0 1.123456789012345E-13 -> 1.123456789012345E-13
-ddadd71434 add 0 1.123456789012345E-14 -> 1.123456789012345E-14
-ddadd71435 add 0 1.123456789012345E-15 -> 1.123456789012345E-15
-ddadd71436 add 0 1.123456789012345E-16 -> 1.123456789012345E-16
-ddadd71437 add 0 1.123456789012345E-17 -> 1.123456789012345E-17
-ddadd71438 add 0 1.123456789012345E-18 -> 1.123456789012345E-18
-ddadd71439 add 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-ddadd71440 add 1.123456789012345 0 -> 1.123456789012345
-ddadd71441 add 1.123456789012345E-1 0 -> 0.1123456789012345
-ddadd71442 add 1.123456789012345E-2 0 -> 0.01123456789012345
-ddadd71443 add 1.123456789012345E-3 0 -> 0.001123456789012345
-ddadd71444 add 1.123456789012345E-4 0 -> 0.0001123456789012345
-ddadd71445 add 1.123456789012345E-5 0 -> 0.00001123456789012345
-ddadd71446 add 1.123456789012345E-6 0 -> 0.000001123456789012345
-ddadd71447 add 1.123456789012345E-7 0 -> 1.123456789012345E-7
-ddadd71448 add 1.123456789012345E-8 0 -> 1.123456789012345E-8
-ddadd71449 add 1.123456789012345E-9 0 -> 1.123456789012345E-9
-ddadd71450 add 1.123456789012345E-10 0 -> 1.123456789012345E-10
-ddadd71451 add 1.123456789012345E-11 0 -> 1.123456789012345E-11
-ddadd71452 add 1.123456789012345E-12 0 -> 1.123456789012345E-12
-ddadd71453 add 1.123456789012345E-13 0 -> 1.123456789012345E-13
-ddadd71454 add 1.123456789012345E-14 0 -> 1.123456789012345E-14
-ddadd71455 add 1.123456789012345E-15 0 -> 1.123456789012345E-15
-ddadd71456 add 1.123456789012345E-16 0 -> 1.123456789012345E-16
-ddadd71457 add 1.123456789012345E-17 0 -> 1.123456789012345E-17
-ddadd71458 add 1.123456789012345E-18 0 -> 1.123456789012345E-18
-ddadd71459 add 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-ddadd71460 add 1.123456789012345 0E-0 -> 1.123456789012345
-ddadd71461 add 1.123456789012345 0E-1 -> 1.123456789012345
-ddadd71462 add 1.123456789012345 0E-2 -> 1.123456789012345
-ddadd71463 add 1.123456789012345 0E-3 -> 1.123456789012345
-ddadd71464 add 1.123456789012345 0E-4 -> 1.123456789012345
-ddadd71465 add 1.123456789012345 0E-5 -> 1.123456789012345
-ddadd71466 add 1.123456789012345 0E-6 -> 1.123456789012345
-ddadd71467 add 1.123456789012345 0E-7 -> 1.123456789012345
-ddadd71468 add 1.123456789012345 0E-8 -> 1.123456789012345
-ddadd71469 add 1.123456789012345 0E-9 -> 1.123456789012345
-ddadd71470 add 1.123456789012345 0E-10 -> 1.123456789012345
-ddadd71471 add 1.123456789012345 0E-11 -> 1.123456789012345
-ddadd71472 add 1.123456789012345 0E-12 -> 1.123456789012345
-ddadd71473 add 1.123456789012345 0E-13 -> 1.123456789012345
-ddadd71474 add 1.123456789012345 0E-14 -> 1.123456789012345
-ddadd71475 add 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-ddadd71476 add 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-ddadd71477 add 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-ddadd71478 add 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-ddadd71479 add 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-ddadd71500 add 0 0E-19 -> 0E-19
-ddadd71501 add -0 0E-19 -> 0E-19
-ddadd71502 add 0 -0E-19 -> 0E-19
-ddadd71503 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71511 add -11 11 -> 0
-ddadd71512 add 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-ddadd71520 add 0 0E-19 -> 0E-19
-ddadd71521 add -0 0E-19 -> 0E-19
-ddadd71522 add 0 -0E-19 -> 0E-19
-ddadd71523 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71531 add -11 11 -> 0
-ddadd71532 add 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-ddadd71540 add 0 0E-19 -> 0E-19
-ddadd71541 add -0 0E-19 -> 0E-19
-ddadd71542 add 0 -0E-19 -> 0E-19
-ddadd71543 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71551 add -11 11 -> 0
-ddadd71552 add 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-ddadd71560 add 0 0E-19 -> 0E-19
-ddadd71561 add -0 0E-19 -> 0E-19
-ddadd71562 add 0 -0E-19 -> 0E-19
-ddadd71563 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71571 add -11 11 -> 0
-ddadd71572 add 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-ddadd71580 add 0 0E-19 -> 0E-19
-ddadd71581 add -0 0E-19 -> 0E-19
-ddadd71582 add 0 -0E-19 -> 0E-19
-ddadd71583 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71591 add -11 11 -> 0
-ddadd71592 add 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-ddadd71600 add 0 0E-19 -> 0E-19
-ddadd71601 add -0 0E-19 -> 0E-19
-ddadd71602 add 0 -0E-19 -> 0E-19
-ddadd71603 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71611 add -11 11 -> 0
-ddadd71612 add 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-ddadd71620 add 0 0E-19 -> 0E-19
-ddadd71621 add -0 0E-19 -> -0E-19 -- *
-ddadd71622 add 0 -0E-19 -> -0E-19 -- *
-ddadd71623 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddadd71631 add -11 11 -> -0 -- *
-ddadd71632 add 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-ddadd71701 add 130E-2 120E-2 -> 2.50
-ddadd71702 add 130E-2 12E-1 -> 2.50
-ddadd71703 add 130E-2 1E0 -> 2.30
-ddadd71704 add 1E2 1E4 -> 1.01E+4
-ddadd71705 add 130E-2 -120E-2 -> 0.10
-ddadd71706 add 130E-2 -12E-1 -> 0.10
-ddadd71707 add 130E-2 -1E0 -> 0.30
-ddadd71708 add 1E2 -1E4 -> -9.9E+3
-
--- query from Vincent Kulandaisamy
-rounding: ceiling
-ddadd71801 add 7.8822773805862E+277 -5.1757503820663E-21 -> 7.882277380586200E+277 Inexact Rounded
-ddadd71802 add 7.882277380586200E+277 12.341 -> 7.882277380586201E+277 Inexact Rounded
-ddadd71803 add 7.882277380586201E+277 2.7270545046613E-31 -> 7.882277380586202E+277 Inexact Rounded
-
-ddadd71811 add 12.341 -5.1757503820663E-21 -> 12.34100000000000 Inexact Rounded
-ddadd71812 add 12.34100000000000 2.7270545046613E-31 -> 12.34100000000001 Inexact Rounded
-ddadd71813 add 12.34100000000001 7.8822773805862E+277 -> 7.882277380586201E+277 Inexact Rounded
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-ddadd75001 add 1234567890123456 1 -> 1234567890123457
-ddadd75002 add 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-ddadd75003 add 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-ddadd75004 add 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-ddadd75005 add 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-ddadd75006 add 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-ddadd75007 add 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-ddadd75008 add 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-ddadd75009 add 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-ddadd75010 add 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-ddadd75011 add 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-ddadd75012 add 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-ddadd75013 add 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-ddadd75014 add 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-ddadd75015 add 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-ddadd75016 add 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-ddadd75017 add 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-ddadd75018 add 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-ddadd75019 add 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-ddadd75020 add 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-ddadd75021 add 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-ddadd75030 add 12345678 1 -> 12345679
-ddadd75031 add 12345678 0.1 -> 12345678.1
-ddadd75032 add 12345678 0.12 -> 12345678.12
-ddadd75033 add 12345678 0.123 -> 12345678.123
-ddadd75034 add 12345678 0.1234 -> 12345678.1234
-ddadd75035 add 12345678 0.12345 -> 12345678.12345
-ddadd75036 add 12345678 0.123456 -> 12345678.123456
-ddadd75037 add 12345678 0.1234567 -> 12345678.1234567
-ddadd75038 add 12345678 0.12345678 -> 12345678.12345678
-ddadd75039 add 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-ddadd75040 add 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-ddadd75041 add 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-ddadd75042 add 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-ddadd75043 add 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-ddadd75044 add 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-ddadd75045 add 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-ddadd75046 add 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-ddadd75047 add 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-ddadd75048 add 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-ddadd75049 add 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-ddadd75050 add 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-ddadd75051 add 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-ddadd75052 add 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-ddadd75053 add 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-ddadd75054 add 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-ddadd75055 add 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-ddadd75056 add 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-ddadd75057 add 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-ddadd75060 add 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-ddadd75061 add 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-ddadd75062 add 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-ddadd75063 add 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-ddadd75064 add 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-ddadd75065 add 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-ddadd75066 add 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-ddadd75067 add 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-ddadd75070 add 12345678 1E-8 -> 12345678.00000001
-ddadd75071 add 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-ddadd75072 add 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-ddadd75073 add 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-ddadd75074 add 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-ddadd75075 add 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-ddadd75076 add 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-ddadd75077 add 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-ddadd75078 add 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-ddadd75079 add 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-ddadd75080 add 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-ddadd75081 add 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-ddadd75082 add 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-ddadd75083 add 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-ddadd75084 add 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-ddadd75085 add 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-ddadd75086 add 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-ddadd75087 add 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-ddadd75088 add 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-ddadd75089 add 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- Punit's
-ddadd75100 add 1.000 -200.000 -> -199.000
-
--- Rounding swathe
-rounding: half_even
-ddadd81100 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81101 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81102 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81103 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81104 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81105 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81106 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81107 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81108 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81109 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81120 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81121 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-ddadd81200 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81201 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81202 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81203 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81204 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81205 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81206 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81207 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81208 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81209 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81220 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81221 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_down
-ddadd81300 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81301 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81302 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81303 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81304 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81305 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81306 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81307 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81308 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81309 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81320 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81321 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: up
-ddadd81400 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81401 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81402 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81403 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81404 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81405 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81406 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81407 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81408 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81409 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81411 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-ddadd81420 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81421 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: down
-ddadd81500 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81501 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81502 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81503 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81504 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81505 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81506 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81507 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81508 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81509 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81511 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
-ddadd81520 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81521 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-rounding: ceiling
-ddadd81600 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81601 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81602 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81603 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81604 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81605 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81606 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
-ddadd81607 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81608 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81609 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81611 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
-ddadd81620 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
-ddadd81621 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-rounding: floor
-ddadd81700 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
-ddadd81701 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81702 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81703 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81704 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81705 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81706 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd81707 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81708 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81709 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
-ddadd81711 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-ddadd81720 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81721 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
-
-rounding: 05up
-ddadd81800 add .2000 12345678901234.00 -> 12345678901234.20 Rounded
-ddadd81801 add .2001 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81802 add .2010 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81803 add .2050 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81804 add .2051 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81807 add .2060 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81808 add .2070 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81809 add .2099 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81811 add -.2099 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
-ddadd81820 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddadd81821 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
-
-ddadd81900 add .2100 12345678901234.00 -> 12345678901234.21 Rounded
-ddadd81901 add .2101 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81902 add .2110 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81903 add .2150 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81904 add .2151 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81907 add .2160 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81908 add .2170 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81909 add .2199 12345678901234.00 -> 12345678901234.21 Inexact Rounded
-ddadd81911 add -.2199 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
-
-ddadd82000 add .2400 12345678901234.00 -> 12345678901234.24 Rounded
-ddadd82001 add .2401 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82002 add .2410 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82003 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82004 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82007 add .2460 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82008 add .2470 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82009 add .2499 12345678901234.00 -> 12345678901234.24 Inexact Rounded
-ddadd82011 add -.2499 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
-
-ddadd82100 add .2500 12345678901234.00 -> 12345678901234.25 Rounded
-ddadd82101 add .2501 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82102 add .2510 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82103 add .2550 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82104 add .2551 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82107 add .2560 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82108 add .2570 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82109 add .2599 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82111 add -.2599 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
-
-ddadd82200 add .2600 12345678901234.00 -> 12345678901234.26 Rounded
-ddadd82201 add .2601 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82202 add .2610 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82203 add .2650 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82204 add .2651 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82207 add .2660 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82208 add .2670 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82209 add .2699 12345678901234.00 -> 12345678901234.26 Inexact Rounded
-ddadd82211 add -.2699 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
-
-ddadd82300 add .2900 12345678901234.00 -> 12345678901234.29 Rounded
-ddadd82301 add .2901 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82302 add .2910 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82303 add .2950 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82304 add .2951 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82307 add .2960 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82308 add .2970 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82309 add .2999 12345678901234.00 -> 12345678901234.29 Inexact Rounded
-ddadd82311 add -.2999 -12345678901234.00 -> -12345678901234.29 Inexact Rounded
-
--- Null tests
-ddadd9990 add 10 # -> NaN Invalid_operation
-ddadd9991 add # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddAdd.decTest -- decDouble addition --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+ddadd001 add 1 1 -> 2
+ddadd002 add 2 3 -> 5
+ddadd003 add '5.75' '3.3' -> 9.05
+ddadd004 add '5' '-3' -> 2
+ddadd005 add '-5' '-3' -> -8
+ddadd006 add '-7' '2.5' -> -4.5
+ddadd007 add '0.7' '0.3' -> 1.0
+ddadd008 add '1.25' '1.25' -> 2.50
+ddadd009 add '1.23456789' '1.00000000' -> '2.23456789'
+ddadd010 add '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+ddadd011 add '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
+ddadd012 add '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
+ddadd013 add '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+ddadd014 add '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
+ddadd015 add '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
+ddadd016 add '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
+ddadd017 add '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
+ddadd018 add '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
+ddadd019 add '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
+ddadd020 add '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
+
+ddadd021 add 0 1 -> 1
+ddadd022 add 1 1 -> 2
+ddadd023 add 2 1 -> 3
+ddadd024 add 3 1 -> 4
+ddadd025 add 4 1 -> 5
+ddadd026 add 5 1 -> 6
+ddadd027 add 6 1 -> 7
+ddadd028 add 7 1 -> 8
+ddadd029 add 8 1 -> 9
+ddadd030 add 9 1 -> 10
+
+-- some carrying effects
+ddadd031 add '0.9998' '0.0000' -> '0.9998'
+ddadd032 add '0.9998' '0.0001' -> '0.9999'
+ddadd033 add '0.9998' '0.0002' -> '1.0000'
+ddadd034 add '0.9998' '0.0003' -> '1.0001'
+
+ddadd035 add '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd036 add '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd037 add '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddadd038 add '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+ddadd039 add '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+ddadd040 add '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddadd041 add '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddadd042 add '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+ddadd044 add '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+ddadd045 add '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+-- same, without rounding
+ddadd046 add '10000e+9' '7' -> '10000000000007'
+ddadd047 add '10000e+9' '70' -> '10000000000070'
+ddadd048 add '10000e+9' '700' -> '10000000000700'
+ddadd049 add '10000e+9' '7000' -> '10000000007000'
+ddadd050 add '10000e+9' '70000' -> '10000000070000'
+ddadd051 add '10000e+9' '700000' -> '10000000700000'
+ddadd052 add '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+ddadd053 add '12' '7.00' -> '19.00'
+ddadd054 add '1.3' '-1.07' -> '0.23'
+ddadd055 add '1.3' '-1.30' -> '0.00'
+ddadd056 add '1.3' '-2.07' -> '-0.77'
+ddadd057 add '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+ddadd061 add 1 '0.0001' -> '1.0001'
+ddadd062 add 1 '0.00001' -> '1.00001'
+ddadd063 add 1 '0.000001' -> '1.000001'
+ddadd064 add 1 '0.0000001' -> '1.0000001'
+ddadd065 add 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+ddadd070 add 1 0 -> 1
+ddadd071 add 1 0. -> 1
+ddadd072 add 1 .0 -> 1.0
+ddadd073 add 1 0.0 -> 1.0
+ddadd074 add 1 0.00 -> 1.00
+ddadd075 add 0 1 -> 1
+ddadd076 add 0. 1 -> 1
+ddadd077 add .0 1 -> 1.0
+ddadd078 add 0.0 1 -> 1.0
+ddadd079 add 0.00 1 -> 1.00
+
+-- some carries
+ddadd080 add 999999998 1 -> 999999999
+ddadd081 add 999999999 1 -> 1000000000
+ddadd082 add 99999999 1 -> 100000000
+ddadd083 add 9999999 1 -> 10000000
+ddadd084 add 999999 1 -> 1000000
+ddadd085 add 99999 1 -> 100000
+ddadd086 add 9999 1 -> 10000
+ddadd087 add 999 1 -> 1000
+ddadd088 add 99 1 -> 100
+ddadd089 add 9 1 -> 10
+
+
+-- more LHS swaps
+ddadd090 add '-56267E-10' 0 -> '-0.0000056267'
+ddadd091 add '-56267E-6' 0 -> '-0.056267'
+ddadd092 add '-56267E-5' 0 -> '-0.56267'
+ddadd093 add '-56267E-4' 0 -> '-5.6267'
+ddadd094 add '-56267E-3' 0 -> '-56.267'
+ddadd095 add '-56267E-2' 0 -> '-562.67'
+ddadd096 add '-56267E-1' 0 -> '-5626.7'
+ddadd097 add '-56267E-0' 0 -> '-56267'
+ddadd098 add '-5E-10' 0 -> '-5E-10'
+ddadd099 add '-5E-7' 0 -> '-5E-7'
+ddadd100 add '-5E-6' 0 -> '-0.000005'
+ddadd101 add '-5E-5' 0 -> '-0.00005'
+ddadd102 add '-5E-4' 0 -> '-0.0005'
+ddadd103 add '-5E-1' 0 -> '-0.5'
+ddadd104 add '-5E0' 0 -> '-5'
+ddadd105 add '-5E1' 0 -> '-50'
+ddadd106 add '-5E5' 0 -> '-500000'
+ddadd107 add '-5E15' 0 -> '-5000000000000000'
+ddadd108 add '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddadd109 add '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddadd110 add '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddadd111 add '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+ddadd113 add 0 '-56267E-10' -> '-0.0000056267'
+ddadd114 add 0 '-56267E-6' -> '-0.056267'
+ddadd116 add 0 '-56267E-5' -> '-0.56267'
+ddadd117 add 0 '-56267E-4' -> '-5.6267'
+ddadd119 add 0 '-56267E-3' -> '-56.267'
+ddadd120 add 0 '-56267E-2' -> '-562.67'
+ddadd121 add 0 '-56267E-1' -> '-5626.7'
+ddadd122 add 0 '-56267E-0' -> '-56267'
+ddadd123 add 0 '-5E-10' -> '-5E-10'
+ddadd124 add 0 '-5E-7' -> '-5E-7'
+ddadd125 add 0 '-5E-6' -> '-0.000005'
+ddadd126 add 0 '-5E-5' -> '-0.00005'
+ddadd127 add 0 '-5E-4' -> '-0.0005'
+ddadd128 add 0 '-5E-1' -> '-0.5'
+ddadd129 add 0 '-5E0' -> '-5'
+ddadd130 add 0 '-5E1' -> '-50'
+ddadd131 add 0 '-5E5' -> '-500000'
+ddadd132 add 0 '-5E15' -> '-5000000000000000'
+ddadd133 add 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+ddadd134 add 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+ddadd135 add 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+ddadd136 add 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+ddadd137 add 1 '0E-19' -> '1.000000000000000' Rounded
+ddadd138 add -1 '0E-19' -> '-1.000000000000000' Rounded
+ddadd139 add '0E-19' 1 -> '1.000000000000000' Rounded
+ddadd140 add '0E-19' -1 -> '-1.000000000000000' Rounded
+ddadd141 add 1E+11 0.0000 -> '100000000000.0000'
+ddadd142 add 1E+11 0.00000 -> '100000000000.0000' Rounded
+ddadd143 add 0.000 1E+12 -> '1000000000000.000'
+ddadd144 add 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+ddadd146 add '00.0' 0 -> '0.0'
+ddadd147 add '0.00' 0 -> '0.00'
+ddadd148 add 0 '0.00' -> '0.00'
+ddadd149 add 0 '00.0' -> '0.0'
+ddadd150 add '00.0' '0.00' -> '0.00'
+ddadd151 add '0.00' '00.0' -> '0.00'
+ddadd152 add '3' '.3' -> '3.3'
+ddadd153 add '3.' '.3' -> '3.3'
+ddadd154 add '3.0' '.3' -> '3.3'
+ddadd155 add '3.00' '.3' -> '3.30'
+ddadd156 add '3' '3' -> '6'
+ddadd157 add '3' '+3' -> '6'
+ddadd158 add '3' '-3' -> '0'
+ddadd159 add '0.3' '-0.3' -> '0.0'
+ddadd160 add '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+ddadd161 add '1E+12' '-1' -> '999999999999'
+ddadd162 add '1E+12' '1.11' -> '1000000000001.11'
+ddadd163 add '1.11' '1E+12' -> '1000000000001.11'
+ddadd164 add '-1' '1E+12' -> '999999999999'
+ddadd165 add '7E+12' '-1' -> '6999999999999'
+ddadd166 add '7E+12' '1.11' -> '7000000000001.11'
+ddadd167 add '1.11' '7E+12' -> '7000000000001.11'
+ddadd168 add '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+-- 1.234567890123456 1234567890123456 1 234567890123456
+ddadd170 add '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
+ddadd171 add '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
+ddadd172 add '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
+ddadd173 add '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
+ddadd174 add '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
+ddadd175 add '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
+ddadd176 add '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
+ddadd177 add '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
+ddadd178 add '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
+ddadd179 add '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
+ddadd180 add '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
+ddadd181 add '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
+ddadd182 add '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
+ddadd183 add '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddadd200 add '1234560123456789' 0 -> '1234560123456789'
+ddadd201 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd202 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd203 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd204 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd205 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd206 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd207 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd208 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddadd209 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddadd210 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddadd211 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddadd212 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddadd213 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddadd214 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddadd215 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddadd216 add '1234560123456789' 1 -> '1234560123456790'
+ddadd217 add '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
+ddadd218 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd219 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+rounding: half_even
+ddadd220 add '1234560123456789' 0 -> '1234560123456789'
+ddadd221 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd222 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd223 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd224 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd225 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd226 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd227 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd228 add '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddadd229 add '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddadd230 add '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddadd231 add '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddadd232 add '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddadd233 add '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddadd234 add '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddadd235 add '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddadd236 add '1234560123456789' 1 -> '1234560123456790'
+ddadd237 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddadd238 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd239 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+ddadd240 add '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
+ddadd241 add '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
+ddadd242 add '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
+
+rounding: down
+ddadd250 add '1234560123456789' 0 -> '1234560123456789'
+ddadd251 add '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddadd252 add '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddadd253 add '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddadd254 add '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddadd255 add '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddadd256 add '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddadd257 add '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddadd258 add '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
+ddadd259 add '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
+ddadd260 add '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
+ddadd261 add '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
+ddadd262 add '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
+ddadd263 add '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
+ddadd264 add '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
+ddadd265 add '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
+ddadd266 add '1234560123456789' 1 -> '1234560123456790'
+ddadd267 add '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddadd268 add '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddadd269 add '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+ddadd301 add -1 1 -> 0
+ddadd302 add 0 1 -> 1
+ddadd303 add 1 1 -> 2
+ddadd304 add 12 1 -> 13
+ddadd305 add 98 1 -> 99
+ddadd306 add 99 1 -> 100
+ddadd307 add 100 1 -> 101
+ddadd308 add 101 1 -> 102
+ddadd309 add -1 -1 -> -2
+ddadd310 add 0 -1 -> -1
+ddadd311 add 1 -1 -> 0
+ddadd312 add 12 -1 -> 11
+ddadd313 add 98 -1 -> 97
+ddadd314 add 99 -1 -> 98
+ddadd315 add 100 -1 -> 99
+ddadd316 add 101 -1 -> 100
+
+ddadd321 add -0.01 0.01 -> 0.00
+ddadd322 add 0.00 0.01 -> 0.01
+ddadd323 add 0.01 0.01 -> 0.02
+ddadd324 add 0.12 0.01 -> 0.13
+ddadd325 add 0.98 0.01 -> 0.99
+ddadd326 add 0.99 0.01 -> 1.00
+ddadd327 add 1.00 0.01 -> 1.01
+ddadd328 add 1.01 0.01 -> 1.02
+ddadd329 add -0.01 -0.01 -> -0.02
+ddadd330 add 0.00 -0.01 -> -0.01
+ddadd331 add 0.01 -0.01 -> 0.00
+ddadd332 add 0.12 -0.01 -> 0.11
+ddadd333 add 0.98 -0.01 -> 0.97
+ddadd334 add 0.99 -0.01 -> 0.98
+ddadd335 add 1.00 -0.01 -> 0.99
+ddadd336 add 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+ddadd340 add 1E+3 0 -> 1000
+ddadd341 add 1E+15 0 -> 1000000000000000
+ddadd342 add 1E+16 0 -> 1.000000000000000E+16 Rounded
+ddadd343 add 1E+20 0 -> 1.000000000000000E+20 Rounded
+-- which simply follow from these cases ...
+ddadd344 add 1E+3 1 -> 1001
+ddadd345 add 1E+15 1 -> 1000000000000001
+ddadd346 add 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+ddadd347 add 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
+ddadd348 add 1E+3 7 -> 1007
+ddadd349 add 1E+15 7 -> 1000000000000007
+ddadd350 add 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+ddadd351 add 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+ddadd360 add 0E+50 10000E+1 -> 1.0000E+5
+ddadd361 add 0E-50 10000E+1 -> 100000.0000000000 Rounded
+ddadd362 add 10000E+1 0E-50 -> 100000.0000000000 Rounded
+ddadd363 add 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+ddadd364 add 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+ddadd370 add 999999999999999 815 -> 1000000000000814
+ddadd371 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_up
+ddadd372 add 999999999999999 815 -> 1000000000000814
+ddadd373 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_even
+ddadd374 add 999999999999999 815 -> 1000000000000814
+ddadd375 add 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+
+-- operands folded
+ddadd380 add 1E+384 1E+384 -> 2.000000000000000E+384 Clamped
+ddadd381 add 1E+380 1E+380 -> 2.00000000000E+380 Clamped
+ddadd382 add 1E+376 1E+376 -> 2.0000000E+376 Clamped
+ddadd383 add 1E+372 1E+372 -> 2.000E+372 Clamped
+ddadd384 add 1E+370 1E+370 -> 2.0E+370 Clamped
+ddadd385 add 1E+369 1E+369 -> 2E+369
+ddadd386 add 1E+368 1E+368 -> 2E+368
+
+-- ulp replacement tests
+ddadd400 add 1 77e-14 -> 1.00000000000077
+ddadd401 add 1 77e-15 -> 1.000000000000077
+ddadd402 add 1 77e-16 -> 1.000000000000008 Inexact Rounded
+ddadd403 add 1 77e-17 -> 1.000000000000001 Inexact Rounded
+ddadd404 add 1 77e-18 -> 1.000000000000000 Inexact Rounded
+ddadd405 add 1 77e-19 -> 1.000000000000000 Inexact Rounded
+ddadd406 add 1 77e-299 -> 1.000000000000000 Inexact Rounded
+
+ddadd410 add 10 77e-14 -> 10.00000000000077
+ddadd411 add 10 77e-15 -> 10.00000000000008 Inexact Rounded
+ddadd412 add 10 77e-16 -> 10.00000000000001 Inexact Rounded
+ddadd413 add 10 77e-17 -> 10.00000000000000 Inexact Rounded
+ddadd414 add 10 77e-18 -> 10.00000000000000 Inexact Rounded
+ddadd415 add 10 77e-19 -> 10.00000000000000 Inexact Rounded
+ddadd416 add 10 77e-299 -> 10.00000000000000 Inexact Rounded
+
+ddadd420 add 77e-14 1 -> 1.00000000000077
+ddadd421 add 77e-15 1 -> 1.000000000000077
+ddadd422 add 77e-16 1 -> 1.000000000000008 Inexact Rounded
+ddadd423 add 77e-17 1 -> 1.000000000000001 Inexact Rounded
+ddadd424 add 77e-18 1 -> 1.000000000000000 Inexact Rounded
+ddadd425 add 77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddadd426 add 77e-299 1 -> 1.000000000000000 Inexact Rounded
+
+ddadd430 add 77e-14 10 -> 10.00000000000077
+ddadd431 add 77e-15 10 -> 10.00000000000008 Inexact Rounded
+ddadd432 add 77e-16 10 -> 10.00000000000001 Inexact Rounded
+ddadd433 add 77e-17 10 -> 10.00000000000000 Inexact Rounded
+ddadd434 add 77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddadd435 add 77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddadd436 add 77e-299 10 -> 10.00000000000000 Inexact Rounded
+
+-- fastpath boundary (more in dqadd)
+-- 1234567890123456
+ddadd539 add '4444444444444444' '3333333333333333' -> '7777777777777777'
+ddadd540 add '4444444444444444' '4444444444444444' -> '8888888888888888'
+ddadd541 add '4444444444444444' '5555555555555555' -> '9999999999999999'
+ddadd542 add '3333333333333333' '4444444444444444' -> '7777777777777777'
+ddadd543 add '4444444444444444' '4444444444444444' -> '8888888888888888'
+ddadd544 add '5555555555555555' '4444444444444444' -> '9999999999999999'
+ddadd545 add '3000004000000000' '3000000000000040' -> '6000004000000040'
+ddadd546 add '3000000400000000' '4000000000000400' -> '7000000400000400'
+ddadd547 add '3000000040000000' '5000000000004000' -> '8000000040004000'
+ddadd548 add '4000000004000000' '3000000000040000' -> '7000000004040000'
+ddadd549 add '4000000000400000' '4000000000400000' -> '8000000000800000'
+ddadd550 add '4000000000040000' '5000000004000000' -> '9000000004040000'
+ddadd551 add '5000000000004000' '3000000040000000' -> '8000000040004000'
+ddadd552 add '5000000000000400' '4000000400000000' -> '9000000400000400'
+ddadd553 add '5000000000000040' '5000004000000000' -> 1.000000400000004E+16 Rounded
+-- check propagation
+ddadd554 add '8999999999999999' '0000000000000001' -> 9000000000000000
+ddadd555 add '0000000000000001' '8999999999999999' -> 9000000000000000
+ddadd556 add '0999999999999999' '0000000000000001' -> 1000000000000000
+ddadd557 add '0000000000000001' '0999999999999999' -> 1000000000000000
+ddadd558 add '4444444444444444' '4555555555555556' -> 9000000000000000
+ddadd559 add '4555555555555556' '4444444444444444' -> 9000000000000000
+
+-- negative ulps
+ddadd6440 add 1 -77e-14 -> 0.99999999999923
+ddadd6441 add 1 -77e-15 -> 0.999999999999923
+ddadd6442 add 1 -77e-16 -> 0.9999999999999923
+ddadd6443 add 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+ddadd6444 add 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+ddadd6445 add 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+ddadd6446 add 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+ddadd6450 add 10 -77e-14 -> 9.99999999999923
+ddadd6451 add 10 -77e-15 -> 9.999999999999923
+ddadd6452 add 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+ddadd6453 add 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+ddadd6454 add 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+ddadd6455 add 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+ddadd6456 add 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+ddadd6460 add -77e-14 1 -> 0.99999999999923
+ddadd6461 add -77e-15 1 -> 0.999999999999923
+ddadd6462 add -77e-16 1 -> 0.9999999999999923
+ddadd6463 add -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+ddadd6464 add -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+ddadd6465 add -77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddadd6466 add -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+ddadd6470 add -77e-14 10 -> 9.99999999999923
+ddadd6471 add -77e-15 10 -> 9.999999999999923
+ddadd6472 add -77e-16 10 -> 9.999999999999992 Inexact Rounded
+ddadd6473 add -77e-17 10 -> 9.999999999999999 Inexact Rounded
+ddadd6474 add -77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddadd6475 add -77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddadd6476 add -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddadd6480 add -1 77e-14 -> -0.99999999999923
+ddadd6481 add -1 77e-15 -> -0.999999999999923
+ddadd6482 add -1 77e-16 -> -0.9999999999999923
+ddadd6483 add -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+ddadd6484 add -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+ddadd6485 add -1 77e-19 -> -1.000000000000000 Inexact Rounded
+ddadd6486 add -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+ddadd6490 add -10 77e-14 -> -9.99999999999923
+ddadd6491 add -10 77e-15 -> -9.999999999999923
+ddadd6492 add -10 77e-16 -> -9.999999999999992 Inexact Rounded
+ddadd6493 add -10 77e-17 -> -9.999999999999999 Inexact Rounded
+ddadd6494 add -10 77e-18 -> -10.00000000000000 Inexact Rounded
+ddadd6495 add -10 77e-19 -> -10.00000000000000 Inexact Rounded
+ddadd6496 add -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+ddadd6500 add 77e-14 -1 -> -0.99999999999923
+ddadd6501 add 77e-15 -1 -> -0.999999999999923
+ddadd6502 add 77e-16 -1 -> -0.9999999999999923
+ddadd6503 add 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+ddadd6504 add 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+ddadd6505 add 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+ddadd6506 add 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+ddadd6510 add 77e-14 -10 -> -9.99999999999923
+ddadd6511 add 77e-15 -10 -> -9.999999999999923
+ddadd6512 add 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+ddadd6513 add 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+ddadd6514 add 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+ddadd6515 add 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+ddadd6516 add 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+ddadd6540 add '6543210123456789' 0 -> '6543210123456789'
+ddadd6541 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd6542 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd6543 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd6544 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd6545 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd6546 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd6547 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd6548 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddadd6549 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddadd6550 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddadd6551 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddadd6552 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddadd6553 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddadd6554 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddadd6555 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddadd6556 add '6543210123456789' 1 -> '6543210123456790'
+ddadd6557 add '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+ddadd6558 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd6559 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+ddadd6560 add '6543210123456789' 0 -> '6543210123456789'
+ddadd6561 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd6562 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd6563 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd6564 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd6565 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd6566 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd6567 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd6568 add '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddadd6569 add '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddadd6570 add '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddadd6571 add '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddadd6572 add '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddadd6573 add '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddadd6574 add '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddadd6575 add '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddadd6576 add '6543210123456789' 1 -> '6543210123456790'
+ddadd6577 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddadd6578 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd6579 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+ddadd7540 add '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
+ddadd7541 add '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+ddadd7542 add '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+ddadd7550 add '6543210123456789' 0 -> '6543210123456789'
+ddadd7551 add '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddadd7552 add '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddadd7553 add '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddadd7554 add '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddadd7555 add '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddadd7556 add '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddadd7557 add '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddadd7558 add '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+ddadd7559 add '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+ddadd7560 add '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+ddadd7561 add '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+ddadd7562 add '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+ddadd7563 add '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+ddadd7564 add '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+ddadd7565 add '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
+ddadd7566 add '6543210123456789' 1 -> '6543210123456790'
+ddadd7567 add '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddadd7568 add '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddadd7569 add '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- verify a query
+rounding: down
+ddadd7661 add 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+ddadd7662 add 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+ddadd7663 add 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+ddadd7664 add 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+ddadd7701 add 5.00 1.00E-3 -> 5.00100
+ddadd7702 add 00.00 0.000 -> 0.000
+ddadd7703 add 00.00 0E-3 -> 0.000
+ddadd7704 add 0E-3 00.00 -> 0.000
+
+ddadd7710 add 0E+3 00.00 -> 0.00
+ddadd7711 add 0E+3 00.0 -> 0.0
+ddadd7712 add 0E+3 00. -> 0
+ddadd7713 add 0E+3 00.E+1 -> 0E+1
+ddadd7714 add 0E+3 00.E+2 -> 0E+2
+ddadd7715 add 0E+3 00.E+3 -> 0E+3
+ddadd7716 add 0E+3 00.E+4 -> 0E+3
+ddadd7717 add 0E+3 00.E+5 -> 0E+3
+ddadd7718 add 0E+3 -00.0 -> 0.0
+ddadd7719 add 0E+3 -00. -> 0
+ddadd7731 add 0E+3 -00.E+1 -> 0E+1
+
+ddadd7720 add 00.00 0E+3 -> 0.00
+ddadd7721 add 00.0 0E+3 -> 0.0
+ddadd7722 add 00. 0E+3 -> 0
+ddadd7723 add 00.E+1 0E+3 -> 0E+1
+ddadd7724 add 00.E+2 0E+3 -> 0E+2
+ddadd7725 add 00.E+3 0E+3 -> 0E+3
+ddadd7726 add 00.E+4 0E+3 -> 0E+3
+ddadd7727 add 00.E+5 0E+3 -> 0E+3
+ddadd7728 add -00.00 0E+3 -> 0.00
+ddadd7729 add -00.0 0E+3 -> 0.0
+ddadd7730 add -00. 0E+3 -> 0
+
+ddadd7732 add 0 0 -> 0
+ddadd7733 add 0 -0 -> 0
+ddadd7734 add -0 0 -> 0
+ddadd7735 add -0 -0 -> -0 -- IEEE 854 special case
+
+ddadd7736 add 1 -1 -> 0
+ddadd7737 add -1 -1 -> -2
+ddadd7738 add 1 1 -> 2
+ddadd7739 add -1 1 -> 0
+
+ddadd7741 add 0 -1 -> -1
+ddadd7742 add -0 -1 -> -1
+ddadd7743 add 0 1 -> 1
+ddadd7744 add -0 1 -> 1
+ddadd7745 add -1 0 -> -1
+ddadd7746 add -1 -0 -> -1
+ddadd7747 add 1 0 -> 1
+ddadd7748 add 1 -0 -> 1
+
+ddadd7751 add 0.0 -1 -> -1.0
+ddadd7752 add -0.0 -1 -> -1.0
+ddadd7753 add 0.0 1 -> 1.0
+ddadd7754 add -0.0 1 -> 1.0
+ddadd7755 add -1.0 0 -> -1.0
+ddadd7756 add -1.0 -0 -> -1.0
+ddadd7757 add 1.0 0 -> 1.0
+ddadd7758 add 1.0 -0 -> 1.0
+
+ddadd7761 add 0 -1.0 -> -1.0
+ddadd7762 add -0 -1.0 -> -1.0
+ddadd7763 add 0 1.0 -> 1.0
+ddadd7764 add -0 1.0 -> 1.0
+ddadd7765 add -1 0.0 -> -1.0
+ddadd7766 add -1 -0.0 -> -1.0
+ddadd7767 add 1 0.0 -> 1.0
+ddadd7768 add 1 -0.0 -> 1.0
+
+ddadd7771 add 0.0 -1.0 -> -1.0
+ddadd7772 add -0.0 -1.0 -> -1.0
+ddadd7773 add 0.0 1.0 -> 1.0
+ddadd7774 add -0.0 1.0 -> 1.0
+ddadd7775 add -1.0 0.0 -> -1.0
+ddadd7776 add -1.0 -0.0 -> -1.0
+ddadd7777 add 1.0 0.0 -> 1.0
+ddadd7778 add 1.0 -0.0 -> 1.0
+
+-- Specials
+ddadd7780 add -Inf -Inf -> -Infinity
+ddadd7781 add -Inf -1000 -> -Infinity
+ddadd7782 add -Inf -1 -> -Infinity
+ddadd7783 add -Inf -0 -> -Infinity
+ddadd7784 add -Inf 0 -> -Infinity
+ddadd7785 add -Inf 1 -> -Infinity
+ddadd7786 add -Inf 1000 -> -Infinity
+ddadd7787 add -1000 -Inf -> -Infinity
+ddadd7788 add -Inf -Inf -> -Infinity
+ddadd7789 add -1 -Inf -> -Infinity
+ddadd7790 add -0 -Inf -> -Infinity
+ddadd7791 add 0 -Inf -> -Infinity
+ddadd7792 add 1 -Inf -> -Infinity
+ddadd7793 add 1000 -Inf -> -Infinity
+ddadd7794 add Inf -Inf -> NaN Invalid_operation
+
+ddadd7800 add Inf -Inf -> NaN Invalid_operation
+ddadd7801 add Inf -1000 -> Infinity
+ddadd7802 add Inf -1 -> Infinity
+ddadd7803 add Inf -0 -> Infinity
+ddadd7804 add Inf 0 -> Infinity
+ddadd7805 add Inf 1 -> Infinity
+ddadd7806 add Inf 1000 -> Infinity
+ddadd7807 add Inf Inf -> Infinity
+ddadd7808 add -1000 Inf -> Infinity
+ddadd7809 add -Inf Inf -> NaN Invalid_operation
+ddadd7810 add -1 Inf -> Infinity
+ddadd7811 add -0 Inf -> Infinity
+ddadd7812 add 0 Inf -> Infinity
+ddadd7813 add 1 Inf -> Infinity
+ddadd7814 add 1000 Inf -> Infinity
+ddadd7815 add Inf Inf -> Infinity
+
+ddadd7821 add NaN -Inf -> NaN
+ddadd7822 add NaN -1000 -> NaN
+ddadd7823 add NaN -1 -> NaN
+ddadd7824 add NaN -0 -> NaN
+ddadd7825 add NaN 0 -> NaN
+ddadd7826 add NaN 1 -> NaN
+ddadd7827 add NaN 1000 -> NaN
+ddadd7828 add NaN Inf -> NaN
+ddadd7829 add NaN NaN -> NaN
+ddadd7830 add -Inf NaN -> NaN
+ddadd7831 add -1000 NaN -> NaN
+ddadd7832 add -1 NaN -> NaN
+ddadd7833 add -0 NaN -> NaN
+ddadd7834 add 0 NaN -> NaN
+ddadd7835 add 1 NaN -> NaN
+ddadd7836 add 1000 NaN -> NaN
+ddadd7837 add Inf NaN -> NaN
+
+ddadd7841 add sNaN -Inf -> NaN Invalid_operation
+ddadd7842 add sNaN -1000 -> NaN Invalid_operation
+ddadd7843 add sNaN -1 -> NaN Invalid_operation
+ddadd7844 add sNaN -0 -> NaN Invalid_operation
+ddadd7845 add sNaN 0 -> NaN Invalid_operation
+ddadd7846 add sNaN 1 -> NaN Invalid_operation
+ddadd7847 add sNaN 1000 -> NaN Invalid_operation
+ddadd7848 add sNaN NaN -> NaN Invalid_operation
+ddadd7849 add sNaN sNaN -> NaN Invalid_operation
+ddadd7850 add NaN sNaN -> NaN Invalid_operation
+ddadd7851 add -Inf sNaN -> NaN Invalid_operation
+ddadd7852 add -1000 sNaN -> NaN Invalid_operation
+ddadd7853 add -1 sNaN -> NaN Invalid_operation
+ddadd7854 add -0 sNaN -> NaN Invalid_operation
+ddadd7855 add 0 sNaN -> NaN Invalid_operation
+ddadd7856 add 1 sNaN -> NaN Invalid_operation
+ddadd7857 add 1000 sNaN -> NaN Invalid_operation
+ddadd7858 add Inf sNaN -> NaN Invalid_operation
+ddadd7859 add NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddadd7861 add NaN1 -Inf -> NaN1
+ddadd7862 add +NaN2 -1000 -> NaN2
+ddadd7863 add NaN3 1000 -> NaN3
+ddadd7864 add NaN4 Inf -> NaN4
+ddadd7865 add NaN5 +NaN6 -> NaN5
+ddadd7866 add -Inf NaN7 -> NaN7
+ddadd7867 add -1000 NaN8 -> NaN8
+ddadd7868 add 1000 NaN9 -> NaN9
+ddadd7869 add Inf +NaN10 -> NaN10
+ddadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
+ddadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
+ddadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
+ddadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
+ddadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
+ddadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
+ddadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
+ddadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
+ddadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
+ddadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddadd7882 add -NaN26 NaN28 -> -NaN26
+ddadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddadd7884 add 1000 -NaN30 -> -NaN30
+ddadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+ddadd7575 add 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
+ddadd7576 add -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
+
+-- and another curious case
+ddadd7577 add 7.000000000000E-385 -1.00000E-391 -> 6.999999000000E-385 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+ddadd7972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+ddadd7973 add 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7974 add 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7975 add 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+ddadd7976 add 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+ddadd7977 add 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+ddadd7978 add 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+ddadd7979 add 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+ddadd7980 add 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+ddadd7981 add 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7982 add 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7983 add 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddadd7984 add 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+ddadd7985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+ddadd7986 add -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7987 add -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7988 add -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+ddadd7989 add -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7990 add -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7991 add -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7992 add -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7993 add -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+ddadd7994 add -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7995 add -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7996 add -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddadd7997 add -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+ddadd71100 add 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+ddadd71101 add 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+ddadd71103 add +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+ddadd71104 add 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+ddadd71105 add 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+ddadd71106 add 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+ddadd71107 add 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+ddadd71108 add 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+ddadd71109 add 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+ddadd71110 add -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+ddadd71111 add -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+ddadd71113 add -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+ddadd71114 add -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+ddadd71115 add -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+ddadd71116 add -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+ddadd71117 add -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+ddadd71118 add -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+ddadd71119 add -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+ddadd71300 add 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71310 add 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+ddadd71311 add 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+ddadd71312 add 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+ddadd71313 add 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+ddadd71314 add 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+ddadd71315 add 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+ddadd71316 add 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+ddadd71317 add 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+ddadd71318 add 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+ddadd71319 add 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+ddadd71320 add 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+ddadd71321 add 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71322 add 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71323 add 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71324 add 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+ddadd71325 add 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71326 add 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71327 add 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71328 add 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71329 add 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71330 add 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71331 add 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71332 add 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71333 add 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71334 add 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71335 add 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71336 add 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71337 add 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71338 add 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71339 add 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+ddadd71340 add 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+ddadd71341 add 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+ddadd71349 add 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+ddadd71350 add 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+ddadd71351 add 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+ddadd71352 add 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+ddadd71353 add 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+ddadd71354 add 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+ddadd71355 add 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+ddadd71356 add 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+ddadd71357 add 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+ddadd71358 add 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+ddadd71359 add 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+ddadd71360 add 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+ddadd71361 add 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71362 add 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71363 add 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71364 add 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+ddadd71365 add 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71367 add 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71368 add 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71369 add 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71370 add 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71371 add 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71372 add 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71373 add 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71374 add 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71375 add 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71376 add 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71377 add 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71378 add 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71379 add 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71380 add 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71381 add 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71382 add 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71383 add 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71384 add 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71385 add 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71386 add 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71387 add 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71388 add 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71389 add 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71390 add 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71391 add 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71392 add 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71393 add 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71394 add 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71395 add 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+ddadd71396 add 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+ddadd71420 add 0 1.123456789012345 -> 1.123456789012345
+ddadd71421 add 0 1.123456789012345E-1 -> 0.1123456789012345
+ddadd71422 add 0 1.123456789012345E-2 -> 0.01123456789012345
+ddadd71423 add 0 1.123456789012345E-3 -> 0.001123456789012345
+ddadd71424 add 0 1.123456789012345E-4 -> 0.0001123456789012345
+ddadd71425 add 0 1.123456789012345E-5 -> 0.00001123456789012345
+ddadd71426 add 0 1.123456789012345E-6 -> 0.000001123456789012345
+ddadd71427 add 0 1.123456789012345E-7 -> 1.123456789012345E-7
+ddadd71428 add 0 1.123456789012345E-8 -> 1.123456789012345E-8
+ddadd71429 add 0 1.123456789012345E-9 -> 1.123456789012345E-9
+ddadd71430 add 0 1.123456789012345E-10 -> 1.123456789012345E-10
+ddadd71431 add 0 1.123456789012345E-11 -> 1.123456789012345E-11
+ddadd71432 add 0 1.123456789012345E-12 -> 1.123456789012345E-12
+ddadd71433 add 0 1.123456789012345E-13 -> 1.123456789012345E-13
+ddadd71434 add 0 1.123456789012345E-14 -> 1.123456789012345E-14
+ddadd71435 add 0 1.123456789012345E-15 -> 1.123456789012345E-15
+ddadd71436 add 0 1.123456789012345E-16 -> 1.123456789012345E-16
+ddadd71437 add 0 1.123456789012345E-17 -> 1.123456789012345E-17
+ddadd71438 add 0 1.123456789012345E-18 -> 1.123456789012345E-18
+ddadd71439 add 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+ddadd71440 add 1.123456789012345 0 -> 1.123456789012345
+ddadd71441 add 1.123456789012345E-1 0 -> 0.1123456789012345
+ddadd71442 add 1.123456789012345E-2 0 -> 0.01123456789012345
+ddadd71443 add 1.123456789012345E-3 0 -> 0.001123456789012345
+ddadd71444 add 1.123456789012345E-4 0 -> 0.0001123456789012345
+ddadd71445 add 1.123456789012345E-5 0 -> 0.00001123456789012345
+ddadd71446 add 1.123456789012345E-6 0 -> 0.000001123456789012345
+ddadd71447 add 1.123456789012345E-7 0 -> 1.123456789012345E-7
+ddadd71448 add 1.123456789012345E-8 0 -> 1.123456789012345E-8
+ddadd71449 add 1.123456789012345E-9 0 -> 1.123456789012345E-9
+ddadd71450 add 1.123456789012345E-10 0 -> 1.123456789012345E-10
+ddadd71451 add 1.123456789012345E-11 0 -> 1.123456789012345E-11
+ddadd71452 add 1.123456789012345E-12 0 -> 1.123456789012345E-12
+ddadd71453 add 1.123456789012345E-13 0 -> 1.123456789012345E-13
+ddadd71454 add 1.123456789012345E-14 0 -> 1.123456789012345E-14
+ddadd71455 add 1.123456789012345E-15 0 -> 1.123456789012345E-15
+ddadd71456 add 1.123456789012345E-16 0 -> 1.123456789012345E-16
+ddadd71457 add 1.123456789012345E-17 0 -> 1.123456789012345E-17
+ddadd71458 add 1.123456789012345E-18 0 -> 1.123456789012345E-18
+ddadd71459 add 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+ddadd71460 add 1.123456789012345 0E-0 -> 1.123456789012345
+ddadd71461 add 1.123456789012345 0E-1 -> 1.123456789012345
+ddadd71462 add 1.123456789012345 0E-2 -> 1.123456789012345
+ddadd71463 add 1.123456789012345 0E-3 -> 1.123456789012345
+ddadd71464 add 1.123456789012345 0E-4 -> 1.123456789012345
+ddadd71465 add 1.123456789012345 0E-5 -> 1.123456789012345
+ddadd71466 add 1.123456789012345 0E-6 -> 1.123456789012345
+ddadd71467 add 1.123456789012345 0E-7 -> 1.123456789012345
+ddadd71468 add 1.123456789012345 0E-8 -> 1.123456789012345
+ddadd71469 add 1.123456789012345 0E-9 -> 1.123456789012345
+ddadd71470 add 1.123456789012345 0E-10 -> 1.123456789012345
+ddadd71471 add 1.123456789012345 0E-11 -> 1.123456789012345
+ddadd71472 add 1.123456789012345 0E-12 -> 1.123456789012345
+ddadd71473 add 1.123456789012345 0E-13 -> 1.123456789012345
+ddadd71474 add 1.123456789012345 0E-14 -> 1.123456789012345
+ddadd71475 add 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+ddadd71476 add 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+ddadd71477 add 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+ddadd71478 add 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+ddadd71479 add 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+ddadd71500 add 0 0E-19 -> 0E-19
+ddadd71501 add -0 0E-19 -> 0E-19
+ddadd71502 add 0 -0E-19 -> 0E-19
+ddadd71503 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71511 add -11 11 -> 0
+ddadd71512 add 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+ddadd71520 add 0 0E-19 -> 0E-19
+ddadd71521 add -0 0E-19 -> 0E-19
+ddadd71522 add 0 -0E-19 -> 0E-19
+ddadd71523 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71531 add -11 11 -> 0
+ddadd71532 add 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+ddadd71540 add 0 0E-19 -> 0E-19
+ddadd71541 add -0 0E-19 -> 0E-19
+ddadd71542 add 0 -0E-19 -> 0E-19
+ddadd71543 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71551 add -11 11 -> 0
+ddadd71552 add 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+ddadd71560 add 0 0E-19 -> 0E-19
+ddadd71561 add -0 0E-19 -> 0E-19
+ddadd71562 add 0 -0E-19 -> 0E-19
+ddadd71563 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71571 add -11 11 -> 0
+ddadd71572 add 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+ddadd71580 add 0 0E-19 -> 0E-19
+ddadd71581 add -0 0E-19 -> 0E-19
+ddadd71582 add 0 -0E-19 -> 0E-19
+ddadd71583 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71591 add -11 11 -> 0
+ddadd71592 add 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+ddadd71600 add 0 0E-19 -> 0E-19
+ddadd71601 add -0 0E-19 -> 0E-19
+ddadd71602 add 0 -0E-19 -> 0E-19
+ddadd71603 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71611 add -11 11 -> 0
+ddadd71612 add 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+ddadd71620 add 0 0E-19 -> 0E-19
+ddadd71621 add -0 0E-19 -> -0E-19 -- *
+ddadd71622 add 0 -0E-19 -> -0E-19 -- *
+ddadd71623 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddadd71631 add -11 11 -> -0 -- *
+ddadd71632 add 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+ddadd71701 add 130E-2 120E-2 -> 2.50
+ddadd71702 add 130E-2 12E-1 -> 2.50
+ddadd71703 add 130E-2 1E0 -> 2.30
+ddadd71704 add 1E2 1E4 -> 1.01E+4
+ddadd71705 add 130E-2 -120E-2 -> 0.10
+ddadd71706 add 130E-2 -12E-1 -> 0.10
+ddadd71707 add 130E-2 -1E0 -> 0.30
+ddadd71708 add 1E2 -1E4 -> -9.9E+3
+
+-- query from Vincent Kulandaisamy
+rounding: ceiling
+ddadd71801 add 7.8822773805862E+277 -5.1757503820663E-21 -> 7.882277380586200E+277 Inexact Rounded
+ddadd71802 add 7.882277380586200E+277 12.341 -> 7.882277380586201E+277 Inexact Rounded
+ddadd71803 add 7.882277380586201E+277 2.7270545046613E-31 -> 7.882277380586202E+277 Inexact Rounded
+
+ddadd71811 add 12.341 -5.1757503820663E-21 -> 12.34100000000000 Inexact Rounded
+ddadd71812 add 12.34100000000000 2.7270545046613E-31 -> 12.34100000000001 Inexact Rounded
+ddadd71813 add 12.34100000000001 7.8822773805862E+277 -> 7.882277380586201E+277 Inexact Rounded
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+ddadd75001 add 1234567890123456 1 -> 1234567890123457
+ddadd75002 add 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+ddadd75003 add 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+ddadd75004 add 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+ddadd75005 add 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+ddadd75006 add 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+ddadd75007 add 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+ddadd75008 add 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+ddadd75009 add 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+ddadd75010 add 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+ddadd75011 add 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+ddadd75012 add 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+ddadd75013 add 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+ddadd75014 add 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+ddadd75015 add 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+ddadd75016 add 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+ddadd75017 add 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+ddadd75018 add 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+ddadd75019 add 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+ddadd75020 add 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+ddadd75021 add 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+ddadd75030 add 12345678 1 -> 12345679
+ddadd75031 add 12345678 0.1 -> 12345678.1
+ddadd75032 add 12345678 0.12 -> 12345678.12
+ddadd75033 add 12345678 0.123 -> 12345678.123
+ddadd75034 add 12345678 0.1234 -> 12345678.1234
+ddadd75035 add 12345678 0.12345 -> 12345678.12345
+ddadd75036 add 12345678 0.123456 -> 12345678.123456
+ddadd75037 add 12345678 0.1234567 -> 12345678.1234567
+ddadd75038 add 12345678 0.12345678 -> 12345678.12345678
+ddadd75039 add 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+ddadd75040 add 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+ddadd75041 add 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+ddadd75042 add 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+ddadd75043 add 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+ddadd75044 add 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+ddadd75045 add 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+ddadd75046 add 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+ddadd75047 add 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+ddadd75048 add 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+ddadd75049 add 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+ddadd75050 add 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+ddadd75051 add 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+ddadd75052 add 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+ddadd75053 add 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+ddadd75054 add 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+ddadd75055 add 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+ddadd75056 add 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+ddadd75057 add 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+ddadd75060 add 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+ddadd75061 add 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+ddadd75062 add 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+ddadd75063 add 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+ddadd75064 add 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+ddadd75065 add 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+ddadd75066 add 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+ddadd75067 add 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+ddadd75070 add 12345678 1E-8 -> 12345678.00000001
+ddadd75071 add 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+ddadd75072 add 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+ddadd75073 add 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+ddadd75074 add 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+ddadd75075 add 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+ddadd75076 add 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+ddadd75077 add 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+ddadd75078 add 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+ddadd75079 add 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+ddadd75080 add 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+ddadd75081 add 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+ddadd75082 add 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+ddadd75083 add 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+ddadd75084 add 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+ddadd75085 add 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+ddadd75086 add 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+ddadd75087 add 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+ddadd75088 add 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+ddadd75089 add 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- Punit's
+ddadd75100 add 1.000 -200.000 -> -199.000
+
+-- Rounding swathe
+rounding: half_even
+ddadd81100 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81101 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81102 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81103 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81104 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81105 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81106 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81107 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81108 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81109 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81120 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81121 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+ddadd81200 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81201 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81202 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81203 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81204 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81205 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81206 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81207 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81208 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81209 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81220 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81221 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_down
+ddadd81300 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81301 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81302 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81303 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81304 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81305 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81306 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81307 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81308 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81309 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81320 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81321 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: up
+ddadd81400 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81401 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81402 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81403 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81404 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81405 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81406 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81407 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81408 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81409 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81411 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+ddadd81420 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81421 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: down
+ddadd81500 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81501 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81502 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81503 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81504 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81505 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81506 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81507 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81508 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81509 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81511 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
+ddadd81520 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81521 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+rounding: ceiling
+ddadd81600 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81601 add .2301 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81602 add .2310 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81603 add .2350 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81604 add .2351 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81605 add .2450 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81606 add .2451 12345678901234.00 -> 12345678901234.25 Inexact Rounded
+ddadd81607 add .2360 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81608 add .2370 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81609 add .2399 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81611 add -.2399 -12345678901234.00 -> -12345678901234.23 Inexact Rounded
+ddadd81620 add 9999999999999999E+369 9E+369 -> Infinity Overflow Inexact Rounded
+ddadd81621 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+rounding: floor
+ddadd81700 add .2300 12345678901234.00 -> 12345678901234.23 Rounded
+ddadd81701 add .2301 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81702 add .2310 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81703 add .2350 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81704 add .2351 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81705 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81706 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd81707 add .2360 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81708 add .2370 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81709 add .2399 12345678901234.00 -> 12345678901234.23 Inexact Rounded
+ddadd81711 add -.2399 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+ddadd81720 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81721 add -9999999999999999E+369 -9E+369 -> -Infinity Overflow Inexact Rounded
+
+rounding: 05up
+ddadd81800 add .2000 12345678901234.00 -> 12345678901234.20 Rounded
+ddadd81801 add .2001 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81802 add .2010 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81803 add .2050 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81804 add .2051 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81807 add .2060 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81808 add .2070 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81809 add .2099 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81811 add -.2099 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
+ddadd81820 add 9999999999999999E+369 9E+369 -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddadd81821 add -9999999999999999E+369 -9E+369 -> -9.999999999999999E+384 Overflow Inexact Rounded
+
+ddadd81900 add .2100 12345678901234.00 -> 12345678901234.21 Rounded
+ddadd81901 add .2101 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81902 add .2110 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81903 add .2150 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81904 add .2151 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81907 add .2160 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81908 add .2170 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81909 add .2199 12345678901234.00 -> 12345678901234.21 Inexact Rounded
+ddadd81911 add -.2199 -12345678901234.00 -> -12345678901234.21 Inexact Rounded
+
+ddadd82000 add .2400 12345678901234.00 -> 12345678901234.24 Rounded
+ddadd82001 add .2401 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82002 add .2410 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82003 add .2450 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82004 add .2451 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82007 add .2460 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82008 add .2470 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82009 add .2499 12345678901234.00 -> 12345678901234.24 Inexact Rounded
+ddadd82011 add -.2499 -12345678901234.00 -> -12345678901234.24 Inexact Rounded
+
+ddadd82100 add .2500 12345678901234.00 -> 12345678901234.25 Rounded
+ddadd82101 add .2501 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82102 add .2510 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82103 add .2550 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82104 add .2551 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82107 add .2560 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82108 add .2570 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82109 add .2599 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82111 add -.2599 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
+
+ddadd82200 add .2600 12345678901234.00 -> 12345678901234.26 Rounded
+ddadd82201 add .2601 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82202 add .2610 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82203 add .2650 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82204 add .2651 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82207 add .2660 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82208 add .2670 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82209 add .2699 12345678901234.00 -> 12345678901234.26 Inexact Rounded
+ddadd82211 add -.2699 -12345678901234.00 -> -12345678901234.26 Inexact Rounded
+
+ddadd82300 add .2900 12345678901234.00 -> 12345678901234.29 Rounded
+ddadd82301 add .2901 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82302 add .2910 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82303 add .2950 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82304 add .2951 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82307 add .2960 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82308 add .2970 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82309 add .2999 12345678901234.00 -> 12345678901234.29 Inexact Rounded
+ddadd82311 add -.2999 -12345678901234.00 -> -12345678901234.29 Inexact Rounded
+
+-- Null tests
+ddadd9990 add 10 # -> NaN Invalid_operation
+ddadd9991 add # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddAnd.decTest b/Lib/test/decimaltestdata/ddAnd.decTest
index 64a9f92df9a..676517548c6 100644
--- a/Lib/test/decimaltestdata/ddAnd.decTest
+++ b/Lib/test/decimaltestdata/ddAnd.decTest
@@ -1,347 +1,347 @@
-------------------------------------------------------------------------
--- ddAnd.decTest -- digitwise logical AND for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddand001 and 0 0 -> 0
-ddand002 and 0 1 -> 0
-ddand003 and 1 0 -> 0
-ddand004 and 1 1 -> 1
-ddand005 and 1100 1010 -> 1000
--- and at msd and msd-1
--- 1234567890123456 1234567890123456 1234567890123456
-ddand006 and 0000000000000000 0000000000000000 -> 0
-ddand007 and 0000000000000000 1000000000000000 -> 0
-ddand008 and 1000000000000000 0000000000000000 -> 0
-ddand009 and 1000000000000000 1000000000000000 -> 1000000000000000
-ddand010 and 0000000000000000 0000000000000000 -> 0
-ddand011 and 0000000000000000 0100000000000000 -> 0
-ddand012 and 0100000000000000 0000000000000000 -> 0
-ddand013 and 0100000000000000 0100000000000000 -> 100000000000000
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddand021 and 1111111111111111 1111111111111111 -> 1111111111111111
-ddand024 and 1111111111111111 111111111111111 -> 111111111111111
-ddand025 and 1111111111111111 11111111111111 -> 11111111111111
-ddand026 and 1111111111111111 1111111111111 -> 1111111111111
-ddand027 and 1111111111111111 111111111111 -> 111111111111
-ddand028 and 1111111111111111 11111111111 -> 11111111111
-ddand029 and 1111111111111111 1111111111 -> 1111111111
-ddand030 and 1111111111111111 111111111 -> 111111111
-ddand031 and 1111111111111111 11111111 -> 11111111
-ddand032 and 1111111111111111 1111111 -> 1111111
-ddand033 and 1111111111111111 111111 -> 111111
-ddand034 and 1111111111111111 11111 -> 11111
-ddand035 and 1111111111111111 1111 -> 1111
-ddand036 and 1111111111111111 111 -> 111
-ddand037 and 1111111111111111 11 -> 11
-ddand038 and 1111111111111111 1 -> 1
-ddand039 and 1111111111111111 0 -> 0
-
-ddand040 and 1111111111111111 1111111111111111 -> 1111111111111111
-ddand041 and 111111111111111 1111111111111111 -> 111111111111111
-ddand042 and 111111111111111 1111111111111111 -> 111111111111111
-ddand043 and 11111111111111 1111111111111111 -> 11111111111111
-ddand044 and 1111111111111 1111111111111111 -> 1111111111111
-ddand045 and 111111111111 1111111111111111 -> 111111111111
-ddand046 and 11111111111 1111111111111111 -> 11111111111
-ddand047 and 1111111111 1111111111111111 -> 1111111111
-ddand048 and 111111111 1111111111111111 -> 111111111
-ddand049 and 11111111 1111111111111111 -> 11111111
-ddand050 and 1111111 1111111111111111 -> 1111111
-ddand051 and 111111 1111111111111111 -> 111111
-ddand052 and 11111 1111111111111111 -> 11111
-ddand053 and 1111 1111111111111111 -> 1111
-ddand054 and 111 1111111111111111 -> 111
-ddand055 and 11 1111111111111111 -> 11
-ddand056 and 1 1111111111111111 -> 1
-ddand057 and 0 1111111111111111 -> 0
-
-ddand150 and 1111111111 1 -> 1
-ddand151 and 111111111 1 -> 1
-ddand152 and 11111111 1 -> 1
-ddand153 and 1111111 1 -> 1
-ddand154 and 111111 1 -> 1
-ddand155 and 11111 1 -> 1
-ddand156 and 1111 1 -> 1
-ddand157 and 111 1 -> 1
-ddand158 and 11 1 -> 1
-ddand159 and 1 1 -> 1
-
-ddand160 and 1111111111 0 -> 0
-ddand161 and 111111111 0 -> 0
-ddand162 and 11111111 0 -> 0
-ddand163 and 1111111 0 -> 0
-ddand164 and 111111 0 -> 0
-ddand165 and 11111 0 -> 0
-ddand166 and 1111 0 -> 0
-ddand167 and 111 0 -> 0
-ddand168 and 11 0 -> 0
-ddand169 and 1 0 -> 0
-
-ddand170 and 1 1111111111 -> 1
-ddand171 and 1 111111111 -> 1
-ddand172 and 1 11111111 -> 1
-ddand173 and 1 1111111 -> 1
-ddand174 and 1 111111 -> 1
-ddand175 and 1 11111 -> 1
-ddand176 and 1 1111 -> 1
-ddand177 and 1 111 -> 1
-ddand178 and 1 11 -> 1
-ddand179 and 1 1 -> 1
-
-ddand180 and 0 1111111111 -> 0
-ddand181 and 0 111111111 -> 0
-ddand182 and 0 11111111 -> 0
-ddand183 and 0 1111111 -> 0
-ddand184 and 0 111111 -> 0
-ddand185 and 0 11111 -> 0
-ddand186 and 0 1111 -> 0
-ddand187 and 0 111 -> 0
-ddand188 and 0 11 -> 0
-ddand189 and 0 1 -> 0
-
-ddand090 and 011111111 111111111 -> 11111111
-ddand091 and 101111111 111111111 -> 101111111
-ddand092 and 110111111 111111111 -> 110111111
-ddand093 and 111011111 111111111 -> 111011111
-ddand094 and 111101111 111111111 -> 111101111
-ddand095 and 111110111 111111111 -> 111110111
-ddand096 and 111111011 111111111 -> 111111011
-ddand097 and 111111101 111111111 -> 111111101
-ddand098 and 111111110 111111111 -> 111111110
-
-ddand100 and 111111111 011111111 -> 11111111
-ddand101 and 111111111 101111111 -> 101111111
-ddand102 and 111111111 110111111 -> 110111111
-ddand103 and 111111111 111011111 -> 111011111
-ddand104 and 111111111 111101111 -> 111101111
-ddand105 and 111111111 111110111 -> 111110111
-ddand106 and 111111111 111111011 -> 111111011
-ddand107 and 111111111 111111101 -> 111111101
-ddand108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-ddand220 and 111111112 111111111 -> NaN Invalid_operation
-ddand221 and 333333333 333333333 -> NaN Invalid_operation
-ddand222 and 555555555 555555555 -> NaN Invalid_operation
-ddand223 and 777777777 777777777 -> NaN Invalid_operation
-ddand224 and 999999999 999999999 -> NaN Invalid_operation
-ddand225 and 222222222 999999999 -> NaN Invalid_operation
-ddand226 and 444444444 999999999 -> NaN Invalid_operation
-ddand227 and 666666666 999999999 -> NaN Invalid_operation
-ddand228 and 888888888 999999999 -> NaN Invalid_operation
-ddand229 and 999999999 222222222 -> NaN Invalid_operation
-ddand230 and 999999999 444444444 -> NaN Invalid_operation
-ddand231 and 999999999 666666666 -> NaN Invalid_operation
-ddand232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddand240 and 567468689 -934981942 -> NaN Invalid_operation
-ddand241 and 567367689 934981942 -> NaN Invalid_operation
-ddand242 and -631917772 -706014634 -> NaN Invalid_operation
-ddand243 and -756253257 138579234 -> NaN Invalid_operation
-ddand244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddand250 and 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand251 and 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand252 and 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand253 and 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddand254 and 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand255 and 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand256 and 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand257 and 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddand258 and 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddand259 and 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddand260 and 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddand261 and 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddand262 and 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddand263 and 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddand264 and 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddand265 and 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddand270 and 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddand271 and 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddand272 and 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddand273 and 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddand274 and 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddand275 and 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddand276 and 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddand277 and 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddand280 and 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddand281 and 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddand282 and 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddand283 and 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddand284 and 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddand285 and 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddand286 and 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddand287 and 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddand288 and 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddand289 and 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddand290 and 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddand291 and 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddand292 and 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddand293 and 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddand294 and 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddand295 and 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddand296 and -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddand297 and -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddand298 and 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddand299 and 1000000001000000 0000000011000100 -> 1000000
-
--- Nmax, Nmin, Ntiny-like
-ddand331 and 2 9.99999999E+199 -> NaN Invalid_operation
-ddand332 and 3 1E-199 -> NaN Invalid_operation
-ddand333 and 4 1.00000000E-199 -> NaN Invalid_operation
-ddand334 and 5 1E-100 -> NaN Invalid_operation
-ddand335 and 6 -1E-100 -> NaN Invalid_operation
-ddand336 and 7 -1.00000000E-199 -> NaN Invalid_operation
-ddand337 and 8 -1E-199 -> NaN Invalid_operation
-ddand338 and 9 -9.99999999E+199 -> NaN Invalid_operation
-ddand341 and 9.99999999E+199 -18 -> NaN Invalid_operation
-ddand342 and 1E-199 01 -> NaN Invalid_operation
-ddand343 and 1.00000000E-199 -18 -> NaN Invalid_operation
-ddand344 and 1E-100 18 -> NaN Invalid_operation
-ddand345 and -1E-100 -10 -> NaN Invalid_operation
-ddand346 and -1.00000000E-199 18 -> NaN Invalid_operation
-ddand347 and -1E-199 10 -> NaN Invalid_operation
-ddand348 and -9.99999999E+199 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddand361 and 1.0 1 -> NaN Invalid_operation
-ddand362 and 1E+1 1 -> NaN Invalid_operation
-ddand363 and 0.0 1 -> NaN Invalid_operation
-ddand364 and 0E+1 1 -> NaN Invalid_operation
-ddand365 and 9.9 1 -> NaN Invalid_operation
-ddand366 and 9E+1 1 -> NaN Invalid_operation
-ddand371 and 0 1.0 -> NaN Invalid_operation
-ddand372 and 0 1E+1 -> NaN Invalid_operation
-ddand373 and 0 0.0 -> NaN Invalid_operation
-ddand374 and 0 0E+1 -> NaN Invalid_operation
-ddand375 and 0 9.9 -> NaN Invalid_operation
-ddand376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddand780 and -Inf -Inf -> NaN Invalid_operation
-ddand781 and -Inf -1000 -> NaN Invalid_operation
-ddand782 and -Inf -1 -> NaN Invalid_operation
-ddand783 and -Inf -0 -> NaN Invalid_operation
-ddand784 and -Inf 0 -> NaN Invalid_operation
-ddand785 and -Inf 1 -> NaN Invalid_operation
-ddand786 and -Inf 1000 -> NaN Invalid_operation
-ddand787 and -1000 -Inf -> NaN Invalid_operation
-ddand788 and -Inf -Inf -> NaN Invalid_operation
-ddand789 and -1 -Inf -> NaN Invalid_operation
-ddand790 and -0 -Inf -> NaN Invalid_operation
-ddand791 and 0 -Inf -> NaN Invalid_operation
-ddand792 and 1 -Inf -> NaN Invalid_operation
-ddand793 and 1000 -Inf -> NaN Invalid_operation
-ddand794 and Inf -Inf -> NaN Invalid_operation
-
-ddand800 and Inf -Inf -> NaN Invalid_operation
-ddand801 and Inf -1000 -> NaN Invalid_operation
-ddand802 and Inf -1 -> NaN Invalid_operation
-ddand803 and Inf -0 -> NaN Invalid_operation
-ddand804 and Inf 0 -> NaN Invalid_operation
-ddand805 and Inf 1 -> NaN Invalid_operation
-ddand806 and Inf 1000 -> NaN Invalid_operation
-ddand807 and Inf Inf -> NaN Invalid_operation
-ddand808 and -1000 Inf -> NaN Invalid_operation
-ddand809 and -Inf Inf -> NaN Invalid_operation
-ddand810 and -1 Inf -> NaN Invalid_operation
-ddand811 and -0 Inf -> NaN Invalid_operation
-ddand812 and 0 Inf -> NaN Invalid_operation
-ddand813 and 1 Inf -> NaN Invalid_operation
-ddand814 and 1000 Inf -> NaN Invalid_operation
-ddand815 and Inf Inf -> NaN Invalid_operation
-
-ddand821 and NaN -Inf -> NaN Invalid_operation
-ddand822 and NaN -1000 -> NaN Invalid_operation
-ddand823 and NaN -1 -> NaN Invalid_operation
-ddand824 and NaN -0 -> NaN Invalid_operation
-ddand825 and NaN 0 -> NaN Invalid_operation
-ddand826 and NaN 1 -> NaN Invalid_operation
-ddand827 and NaN 1000 -> NaN Invalid_operation
-ddand828 and NaN Inf -> NaN Invalid_operation
-ddand829 and NaN NaN -> NaN Invalid_operation
-ddand830 and -Inf NaN -> NaN Invalid_operation
-ddand831 and -1000 NaN -> NaN Invalid_operation
-ddand832 and -1 NaN -> NaN Invalid_operation
-ddand833 and -0 NaN -> NaN Invalid_operation
-ddand834 and 0 NaN -> NaN Invalid_operation
-ddand835 and 1 NaN -> NaN Invalid_operation
-ddand836 and 1000 NaN -> NaN Invalid_operation
-ddand837 and Inf NaN -> NaN Invalid_operation
-
-ddand841 and sNaN -Inf -> NaN Invalid_operation
-ddand842 and sNaN -1000 -> NaN Invalid_operation
-ddand843 and sNaN -1 -> NaN Invalid_operation
-ddand844 and sNaN -0 -> NaN Invalid_operation
-ddand845 and sNaN 0 -> NaN Invalid_operation
-ddand846 and sNaN 1 -> NaN Invalid_operation
-ddand847 and sNaN 1000 -> NaN Invalid_operation
-ddand848 and sNaN NaN -> NaN Invalid_operation
-ddand849 and sNaN sNaN -> NaN Invalid_operation
-ddand850 and NaN sNaN -> NaN Invalid_operation
-ddand851 and -Inf sNaN -> NaN Invalid_operation
-ddand852 and -1000 sNaN -> NaN Invalid_operation
-ddand853 and -1 sNaN -> NaN Invalid_operation
-ddand854 and -0 sNaN -> NaN Invalid_operation
-ddand855 and 0 sNaN -> NaN Invalid_operation
-ddand856 and 1 sNaN -> NaN Invalid_operation
-ddand857 and 1000 sNaN -> NaN Invalid_operation
-ddand858 and Inf sNaN -> NaN Invalid_operation
-ddand859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddand861 and NaN1 -Inf -> NaN Invalid_operation
-ddand862 and +NaN2 -1000 -> NaN Invalid_operation
-ddand863 and NaN3 1000 -> NaN Invalid_operation
-ddand864 and NaN4 Inf -> NaN Invalid_operation
-ddand865 and NaN5 +NaN6 -> NaN Invalid_operation
-ddand866 and -Inf NaN7 -> NaN Invalid_operation
-ddand867 and -1000 NaN8 -> NaN Invalid_operation
-ddand868 and 1000 NaN9 -> NaN Invalid_operation
-ddand869 and Inf +NaN10 -> NaN Invalid_operation
-ddand871 and sNaN11 -Inf -> NaN Invalid_operation
-ddand872 and sNaN12 -1000 -> NaN Invalid_operation
-ddand873 and sNaN13 1000 -> NaN Invalid_operation
-ddand874 and sNaN14 NaN17 -> NaN Invalid_operation
-ddand875 and sNaN15 sNaN18 -> NaN Invalid_operation
-ddand876 and NaN16 sNaN19 -> NaN Invalid_operation
-ddand877 and -Inf +sNaN20 -> NaN Invalid_operation
-ddand878 and -1000 sNaN21 -> NaN Invalid_operation
-ddand879 and 1000 sNaN22 -> NaN Invalid_operation
-ddand880 and Inf sNaN23 -> NaN Invalid_operation
-ddand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-ddand882 and -NaN26 NaN28 -> NaN Invalid_operation
-ddand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-ddand884 and 1000 -NaN30 -> NaN Invalid_operation
-ddand885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddAnd.decTest -- digitwise logical AND for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddand001 and 0 0 -> 0
+ddand002 and 0 1 -> 0
+ddand003 and 1 0 -> 0
+ddand004 and 1 1 -> 1
+ddand005 and 1100 1010 -> 1000
+-- and at msd and msd-1
+-- 1234567890123456 1234567890123456 1234567890123456
+ddand006 and 0000000000000000 0000000000000000 -> 0
+ddand007 and 0000000000000000 1000000000000000 -> 0
+ddand008 and 1000000000000000 0000000000000000 -> 0
+ddand009 and 1000000000000000 1000000000000000 -> 1000000000000000
+ddand010 and 0000000000000000 0000000000000000 -> 0
+ddand011 and 0000000000000000 0100000000000000 -> 0
+ddand012 and 0100000000000000 0000000000000000 -> 0
+ddand013 and 0100000000000000 0100000000000000 -> 100000000000000
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddand021 and 1111111111111111 1111111111111111 -> 1111111111111111
+ddand024 and 1111111111111111 111111111111111 -> 111111111111111
+ddand025 and 1111111111111111 11111111111111 -> 11111111111111
+ddand026 and 1111111111111111 1111111111111 -> 1111111111111
+ddand027 and 1111111111111111 111111111111 -> 111111111111
+ddand028 and 1111111111111111 11111111111 -> 11111111111
+ddand029 and 1111111111111111 1111111111 -> 1111111111
+ddand030 and 1111111111111111 111111111 -> 111111111
+ddand031 and 1111111111111111 11111111 -> 11111111
+ddand032 and 1111111111111111 1111111 -> 1111111
+ddand033 and 1111111111111111 111111 -> 111111
+ddand034 and 1111111111111111 11111 -> 11111
+ddand035 and 1111111111111111 1111 -> 1111
+ddand036 and 1111111111111111 111 -> 111
+ddand037 and 1111111111111111 11 -> 11
+ddand038 and 1111111111111111 1 -> 1
+ddand039 and 1111111111111111 0 -> 0
+
+ddand040 and 1111111111111111 1111111111111111 -> 1111111111111111
+ddand041 and 111111111111111 1111111111111111 -> 111111111111111
+ddand042 and 111111111111111 1111111111111111 -> 111111111111111
+ddand043 and 11111111111111 1111111111111111 -> 11111111111111
+ddand044 and 1111111111111 1111111111111111 -> 1111111111111
+ddand045 and 111111111111 1111111111111111 -> 111111111111
+ddand046 and 11111111111 1111111111111111 -> 11111111111
+ddand047 and 1111111111 1111111111111111 -> 1111111111
+ddand048 and 111111111 1111111111111111 -> 111111111
+ddand049 and 11111111 1111111111111111 -> 11111111
+ddand050 and 1111111 1111111111111111 -> 1111111
+ddand051 and 111111 1111111111111111 -> 111111
+ddand052 and 11111 1111111111111111 -> 11111
+ddand053 and 1111 1111111111111111 -> 1111
+ddand054 and 111 1111111111111111 -> 111
+ddand055 and 11 1111111111111111 -> 11
+ddand056 and 1 1111111111111111 -> 1
+ddand057 and 0 1111111111111111 -> 0
+
+ddand150 and 1111111111 1 -> 1
+ddand151 and 111111111 1 -> 1
+ddand152 and 11111111 1 -> 1
+ddand153 and 1111111 1 -> 1
+ddand154 and 111111 1 -> 1
+ddand155 and 11111 1 -> 1
+ddand156 and 1111 1 -> 1
+ddand157 and 111 1 -> 1
+ddand158 and 11 1 -> 1
+ddand159 and 1 1 -> 1
+
+ddand160 and 1111111111 0 -> 0
+ddand161 and 111111111 0 -> 0
+ddand162 and 11111111 0 -> 0
+ddand163 and 1111111 0 -> 0
+ddand164 and 111111 0 -> 0
+ddand165 and 11111 0 -> 0
+ddand166 and 1111 0 -> 0
+ddand167 and 111 0 -> 0
+ddand168 and 11 0 -> 0
+ddand169 and 1 0 -> 0
+
+ddand170 and 1 1111111111 -> 1
+ddand171 and 1 111111111 -> 1
+ddand172 and 1 11111111 -> 1
+ddand173 and 1 1111111 -> 1
+ddand174 and 1 111111 -> 1
+ddand175 and 1 11111 -> 1
+ddand176 and 1 1111 -> 1
+ddand177 and 1 111 -> 1
+ddand178 and 1 11 -> 1
+ddand179 and 1 1 -> 1
+
+ddand180 and 0 1111111111 -> 0
+ddand181 and 0 111111111 -> 0
+ddand182 and 0 11111111 -> 0
+ddand183 and 0 1111111 -> 0
+ddand184 and 0 111111 -> 0
+ddand185 and 0 11111 -> 0
+ddand186 and 0 1111 -> 0
+ddand187 and 0 111 -> 0
+ddand188 and 0 11 -> 0
+ddand189 and 0 1 -> 0
+
+ddand090 and 011111111 111111111 -> 11111111
+ddand091 and 101111111 111111111 -> 101111111
+ddand092 and 110111111 111111111 -> 110111111
+ddand093 and 111011111 111111111 -> 111011111
+ddand094 and 111101111 111111111 -> 111101111
+ddand095 and 111110111 111111111 -> 111110111
+ddand096 and 111111011 111111111 -> 111111011
+ddand097 and 111111101 111111111 -> 111111101
+ddand098 and 111111110 111111111 -> 111111110
+
+ddand100 and 111111111 011111111 -> 11111111
+ddand101 and 111111111 101111111 -> 101111111
+ddand102 and 111111111 110111111 -> 110111111
+ddand103 and 111111111 111011111 -> 111011111
+ddand104 and 111111111 111101111 -> 111101111
+ddand105 and 111111111 111110111 -> 111110111
+ddand106 and 111111111 111111011 -> 111111011
+ddand107 and 111111111 111111101 -> 111111101
+ddand108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+ddand220 and 111111112 111111111 -> NaN Invalid_operation
+ddand221 and 333333333 333333333 -> NaN Invalid_operation
+ddand222 and 555555555 555555555 -> NaN Invalid_operation
+ddand223 and 777777777 777777777 -> NaN Invalid_operation
+ddand224 and 999999999 999999999 -> NaN Invalid_operation
+ddand225 and 222222222 999999999 -> NaN Invalid_operation
+ddand226 and 444444444 999999999 -> NaN Invalid_operation
+ddand227 and 666666666 999999999 -> NaN Invalid_operation
+ddand228 and 888888888 999999999 -> NaN Invalid_operation
+ddand229 and 999999999 222222222 -> NaN Invalid_operation
+ddand230 and 999999999 444444444 -> NaN Invalid_operation
+ddand231 and 999999999 666666666 -> NaN Invalid_operation
+ddand232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddand240 and 567468689 -934981942 -> NaN Invalid_operation
+ddand241 and 567367689 934981942 -> NaN Invalid_operation
+ddand242 and -631917772 -706014634 -> NaN Invalid_operation
+ddand243 and -756253257 138579234 -> NaN Invalid_operation
+ddand244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddand250 and 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand251 and 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand252 and 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand253 and 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddand254 and 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand255 and 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand256 and 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand257 and 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddand258 and 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddand259 and 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddand260 and 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddand261 and 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddand262 and 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddand263 and 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddand264 and 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddand265 and 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddand270 and 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddand271 and 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddand272 and 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddand273 and 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddand274 and 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddand275 and 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddand276 and 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddand277 and 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddand280 and 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddand281 and 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddand282 and 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddand283 and 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddand284 and 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddand285 and 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddand286 and 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddand287 and 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddand288 and 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddand289 and 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddand290 and 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddand291 and 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddand292 and 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddand293 and 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddand294 and 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddand295 and 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddand296 and -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddand297 and -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddand298 and 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddand299 and 1000000001000000 0000000011000100 -> 1000000
+
+-- Nmax, Nmin, Ntiny-like
+ddand331 and 2 9.99999999E+199 -> NaN Invalid_operation
+ddand332 and 3 1E-199 -> NaN Invalid_operation
+ddand333 and 4 1.00000000E-199 -> NaN Invalid_operation
+ddand334 and 5 1E-100 -> NaN Invalid_operation
+ddand335 and 6 -1E-100 -> NaN Invalid_operation
+ddand336 and 7 -1.00000000E-199 -> NaN Invalid_operation
+ddand337 and 8 -1E-199 -> NaN Invalid_operation
+ddand338 and 9 -9.99999999E+199 -> NaN Invalid_operation
+ddand341 and 9.99999999E+199 -18 -> NaN Invalid_operation
+ddand342 and 1E-199 01 -> NaN Invalid_operation
+ddand343 and 1.00000000E-199 -18 -> NaN Invalid_operation
+ddand344 and 1E-100 18 -> NaN Invalid_operation
+ddand345 and -1E-100 -10 -> NaN Invalid_operation
+ddand346 and -1.00000000E-199 18 -> NaN Invalid_operation
+ddand347 and -1E-199 10 -> NaN Invalid_operation
+ddand348 and -9.99999999E+199 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddand361 and 1.0 1 -> NaN Invalid_operation
+ddand362 and 1E+1 1 -> NaN Invalid_operation
+ddand363 and 0.0 1 -> NaN Invalid_operation
+ddand364 and 0E+1 1 -> NaN Invalid_operation
+ddand365 and 9.9 1 -> NaN Invalid_operation
+ddand366 and 9E+1 1 -> NaN Invalid_operation
+ddand371 and 0 1.0 -> NaN Invalid_operation
+ddand372 and 0 1E+1 -> NaN Invalid_operation
+ddand373 and 0 0.0 -> NaN Invalid_operation
+ddand374 and 0 0E+1 -> NaN Invalid_operation
+ddand375 and 0 9.9 -> NaN Invalid_operation
+ddand376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddand780 and -Inf -Inf -> NaN Invalid_operation
+ddand781 and -Inf -1000 -> NaN Invalid_operation
+ddand782 and -Inf -1 -> NaN Invalid_operation
+ddand783 and -Inf -0 -> NaN Invalid_operation
+ddand784 and -Inf 0 -> NaN Invalid_operation
+ddand785 and -Inf 1 -> NaN Invalid_operation
+ddand786 and -Inf 1000 -> NaN Invalid_operation
+ddand787 and -1000 -Inf -> NaN Invalid_operation
+ddand788 and -Inf -Inf -> NaN Invalid_operation
+ddand789 and -1 -Inf -> NaN Invalid_operation
+ddand790 and -0 -Inf -> NaN Invalid_operation
+ddand791 and 0 -Inf -> NaN Invalid_operation
+ddand792 and 1 -Inf -> NaN Invalid_operation
+ddand793 and 1000 -Inf -> NaN Invalid_operation
+ddand794 and Inf -Inf -> NaN Invalid_operation
+
+ddand800 and Inf -Inf -> NaN Invalid_operation
+ddand801 and Inf -1000 -> NaN Invalid_operation
+ddand802 and Inf -1 -> NaN Invalid_operation
+ddand803 and Inf -0 -> NaN Invalid_operation
+ddand804 and Inf 0 -> NaN Invalid_operation
+ddand805 and Inf 1 -> NaN Invalid_operation
+ddand806 and Inf 1000 -> NaN Invalid_operation
+ddand807 and Inf Inf -> NaN Invalid_operation
+ddand808 and -1000 Inf -> NaN Invalid_operation
+ddand809 and -Inf Inf -> NaN Invalid_operation
+ddand810 and -1 Inf -> NaN Invalid_operation
+ddand811 and -0 Inf -> NaN Invalid_operation
+ddand812 and 0 Inf -> NaN Invalid_operation
+ddand813 and 1 Inf -> NaN Invalid_operation
+ddand814 and 1000 Inf -> NaN Invalid_operation
+ddand815 and Inf Inf -> NaN Invalid_operation
+
+ddand821 and NaN -Inf -> NaN Invalid_operation
+ddand822 and NaN -1000 -> NaN Invalid_operation
+ddand823 and NaN -1 -> NaN Invalid_operation
+ddand824 and NaN -0 -> NaN Invalid_operation
+ddand825 and NaN 0 -> NaN Invalid_operation
+ddand826 and NaN 1 -> NaN Invalid_operation
+ddand827 and NaN 1000 -> NaN Invalid_operation
+ddand828 and NaN Inf -> NaN Invalid_operation
+ddand829 and NaN NaN -> NaN Invalid_operation
+ddand830 and -Inf NaN -> NaN Invalid_operation
+ddand831 and -1000 NaN -> NaN Invalid_operation
+ddand832 and -1 NaN -> NaN Invalid_operation
+ddand833 and -0 NaN -> NaN Invalid_operation
+ddand834 and 0 NaN -> NaN Invalid_operation
+ddand835 and 1 NaN -> NaN Invalid_operation
+ddand836 and 1000 NaN -> NaN Invalid_operation
+ddand837 and Inf NaN -> NaN Invalid_operation
+
+ddand841 and sNaN -Inf -> NaN Invalid_operation
+ddand842 and sNaN -1000 -> NaN Invalid_operation
+ddand843 and sNaN -1 -> NaN Invalid_operation
+ddand844 and sNaN -0 -> NaN Invalid_operation
+ddand845 and sNaN 0 -> NaN Invalid_operation
+ddand846 and sNaN 1 -> NaN Invalid_operation
+ddand847 and sNaN 1000 -> NaN Invalid_operation
+ddand848 and sNaN NaN -> NaN Invalid_operation
+ddand849 and sNaN sNaN -> NaN Invalid_operation
+ddand850 and NaN sNaN -> NaN Invalid_operation
+ddand851 and -Inf sNaN -> NaN Invalid_operation
+ddand852 and -1000 sNaN -> NaN Invalid_operation
+ddand853 and -1 sNaN -> NaN Invalid_operation
+ddand854 and -0 sNaN -> NaN Invalid_operation
+ddand855 and 0 sNaN -> NaN Invalid_operation
+ddand856 and 1 sNaN -> NaN Invalid_operation
+ddand857 and 1000 sNaN -> NaN Invalid_operation
+ddand858 and Inf sNaN -> NaN Invalid_operation
+ddand859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddand861 and NaN1 -Inf -> NaN Invalid_operation
+ddand862 and +NaN2 -1000 -> NaN Invalid_operation
+ddand863 and NaN3 1000 -> NaN Invalid_operation
+ddand864 and NaN4 Inf -> NaN Invalid_operation
+ddand865 and NaN5 +NaN6 -> NaN Invalid_operation
+ddand866 and -Inf NaN7 -> NaN Invalid_operation
+ddand867 and -1000 NaN8 -> NaN Invalid_operation
+ddand868 and 1000 NaN9 -> NaN Invalid_operation
+ddand869 and Inf +NaN10 -> NaN Invalid_operation
+ddand871 and sNaN11 -Inf -> NaN Invalid_operation
+ddand872 and sNaN12 -1000 -> NaN Invalid_operation
+ddand873 and sNaN13 1000 -> NaN Invalid_operation
+ddand874 and sNaN14 NaN17 -> NaN Invalid_operation
+ddand875 and sNaN15 sNaN18 -> NaN Invalid_operation
+ddand876 and NaN16 sNaN19 -> NaN Invalid_operation
+ddand877 and -Inf +sNaN20 -> NaN Invalid_operation
+ddand878 and -1000 sNaN21 -> NaN Invalid_operation
+ddand879 and 1000 sNaN22 -> NaN Invalid_operation
+ddand880 and Inf sNaN23 -> NaN Invalid_operation
+ddand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+ddand882 and -NaN26 NaN28 -> NaN Invalid_operation
+ddand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+ddand884 and 1000 -NaN30 -> NaN Invalid_operation
+ddand885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddBase.decTest b/Lib/test/decimaltestdata/ddBase.decTest
index 40febf86c5e..fbd6ccd94de 100644
--- a/Lib/test/decimaltestdata/ddBase.decTest
+++ b/Lib/test/decimaltestdata/ddBase.decTest
@@ -1,1104 +1,1104 @@
-------------------------------------------------------------------------
--- ddBase.decTest -- base decDouble <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decDouble. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddbas001 toSci 0 -> 0
-ddbas002 toSci 1 -> 1
-ddbas003 toSci 1.0 -> 1.0
-ddbas004 toSci 1.00 -> 1.00
-ddbas005 toSci 10 -> 10
-ddbas006 toSci 1000 -> 1000
-ddbas007 toSci 10.0 -> 10.0
-ddbas008 toSci 10.1 -> 10.1
-ddbas009 toSci 10.4 -> 10.4
-ddbas010 toSci 10.5 -> 10.5
-ddbas011 toSci 10.6 -> 10.6
-ddbas012 toSci 10.9 -> 10.9
-ddbas013 toSci 11.0 -> 11.0
-ddbas014 toSci 1.234 -> 1.234
-ddbas015 toSci 0.123 -> 0.123
-ddbas016 toSci 0.012 -> 0.012
-ddbas017 toSci -0 -> -0
-ddbas018 toSci -0.0 -> -0.0
-ddbas019 toSci -00.00 -> -0.00
-
-ddbas021 toSci -1 -> -1
-ddbas022 toSci -1.0 -> -1.0
-ddbas023 toSci -0.1 -> -0.1
-ddbas024 toSci -9.1 -> -9.1
-ddbas025 toSci -9.11 -> -9.11
-ddbas026 toSci -9.119 -> -9.119
-ddbas027 toSci -9.999 -> -9.999
-
-ddbas030 toSci '123456789.123456' -> '123456789.123456'
-ddbas031 toSci '123456789.000000' -> '123456789.000000'
-ddbas032 toSci '123456789123456' -> '123456789123456'
-ddbas033 toSci '0.0000123456789' -> '0.0000123456789'
-ddbas034 toSci '0.00000123456789' -> '0.00000123456789'
-ddbas035 toSci '0.000000123456789' -> '1.23456789E-7'
-ddbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
-
-ddbas037 toSci '0.123456789012344' -> '0.123456789012344'
-ddbas038 toSci '0.123456789012345' -> '0.123456789012345'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384
-ddbsn002 toSci -1E-383 -> -1E-383
-ddbsn003 toSci -1E-398 -> -1E-398 Subnormal
-ddbsn004 toSci -0 -> -0
-ddbsn005 toSci +0 -> 0
-ddbsn006 toSci +1E-398 -> 1E-398 Subnormal
-ddbsn007 toSci +1E-383 -> 1E-383
-ddbsn008 toSci +9.999999999999999E+384 -> 9.999999999999999E+384
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-ddbas040 toSci "12" -> '12'
-ddbas041 toSci "-76" -> '-76'
-ddbas042 toSci "12.76" -> '12.76'
-ddbas043 toSci "+12.76" -> '12.76'
-ddbas044 toSci "012.76" -> '12.76'
-ddbas045 toSci "+0.003" -> '0.003'
-ddbas046 toSci "17." -> '17'
-ddbas047 toSci ".5" -> '0.5'
-ddbas048 toSci "044" -> '44'
-ddbas049 toSci "0044" -> '44'
-ddbas050 toSci "0.0005" -> '0.0005'
-ddbas051 toSci "00.00005" -> '0.00005'
-ddbas052 toSci "0.000005" -> '0.000005'
-ddbas053 toSci "0.0000050" -> '0.0000050'
-ddbas054 toSci "0.0000005" -> '5E-7'
-ddbas055 toSci "0.00000005" -> '5E-8'
-ddbas056 toSci "12345678.543210" -> '12345678.543210'
-ddbas057 toSci "2345678.543210" -> '2345678.543210'
-ddbas058 toSci "345678.543210" -> '345678.543210'
-ddbas059 toSci "0345678.54321" -> '345678.54321'
-ddbas060 toSci "345678.5432" -> '345678.5432'
-ddbas061 toSci "+345678.5432" -> '345678.5432'
-ddbas062 toSci "+0345678.5432" -> '345678.5432'
-ddbas063 toSci "+00345678.5432" -> '345678.5432'
-ddbas064 toSci "-345678.5432" -> '-345678.5432'
-ddbas065 toSci "-0345678.5432" -> '-345678.5432'
-ddbas066 toSci "-00345678.5432" -> '-345678.5432'
--- examples
-ddbas067 toSci "5E-6" -> '0.000005'
-ddbas068 toSci "50E-7" -> '0.0000050'
-ddbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-ddbas071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded
-ddbas072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded
-ddbas073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded
-ddbas074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded
-ddbas075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded
-ddbas076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded
-ddbas077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded
-ddbas078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded
-ddbas079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded
-ddbas080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded
-ddbas081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded
-ddbas082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded
-ddbas083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded
-ddbas084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded
-ddbas085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded
-ddbas086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded
-ddbas087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded
-ddbas088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded
-ddbas089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded
-ddbas090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded
-
-
--- Numbers with E
-ddbas130 toSci "0.000E-1" -> '0.0000'
-ddbas131 toSci "0.000E-2" -> '0.00000'
-ddbas132 toSci "0.000E-3" -> '0.000000'
-ddbas133 toSci "0.000E-4" -> '0E-7'
-ddbas134 toSci "0.00E-2" -> '0.0000'
-ddbas135 toSci "0.00E-3" -> '0.00000'
-ddbas136 toSci "0.00E-4" -> '0.000000'
-ddbas137 toSci "0.00E-5" -> '0E-7'
-ddbas138 toSci "+0E+9" -> '0E+9'
-ddbas139 toSci "-0E+9" -> '-0E+9'
-ddbas140 toSci "1E+9" -> '1E+9'
-ddbas141 toSci "1e+09" -> '1E+9'
-ddbas142 toSci "1E+90" -> '1E+90'
-ddbas143 toSci "+1E+009" -> '1E+9'
-ddbas144 toSci "0E+9" -> '0E+9'
-ddbas145 toSci "1E+9" -> '1E+9'
-ddbas146 toSci "1E+09" -> '1E+9'
-ddbas147 toSci "1e+90" -> '1E+90'
-ddbas148 toSci "1E+009" -> '1E+9'
-ddbas149 toSci "000E+9" -> '0E+9'
-ddbas150 toSci "1E9" -> '1E+9'
-ddbas151 toSci "1e09" -> '1E+9'
-ddbas152 toSci "1E90" -> '1E+90'
-ddbas153 toSci "1E009" -> '1E+9'
-ddbas154 toSci "0E9" -> '0E+9'
-ddbas155 toSci "0.000e+0" -> '0.000'
-ddbas156 toSci "0.000E-1" -> '0.0000'
-ddbas157 toSci "4E+9" -> '4E+9'
-ddbas158 toSci "44E+9" -> '4.4E+10'
-ddbas159 toSci "0.73e-7" -> '7.3E-8'
-ddbas160 toSci "00E+9" -> '0E+9'
-ddbas161 toSci "00E-9" -> '0E-9'
-ddbas162 toSci "10E+9" -> '1.0E+10'
-ddbas163 toSci "10E+09" -> '1.0E+10'
-ddbas164 toSci "10e+90" -> '1.0E+91'
-ddbas165 toSci "10E+009" -> '1.0E+10'
-ddbas166 toSci "100e+9" -> '1.00E+11'
-ddbas167 toSci "100e+09" -> '1.00E+11'
-ddbas168 toSci "100E+90" -> '1.00E+92'
-ddbas169 toSci "100e+009" -> '1.00E+11'
-
-ddbas170 toSci "1.265" -> '1.265'
-ddbas171 toSci "1.265E-20" -> '1.265E-20'
-ddbas172 toSci "1.265E-8" -> '1.265E-8'
-ddbas173 toSci "1.265E-4" -> '0.0001265'
-ddbas174 toSci "1.265E-3" -> '0.001265'
-ddbas175 toSci "1.265E-2" -> '0.01265'
-ddbas176 toSci "1.265E-1" -> '0.1265'
-ddbas177 toSci "1.265E-0" -> '1.265'
-ddbas178 toSci "1.265E+1" -> '12.65'
-ddbas179 toSci "1.265E+2" -> '126.5'
-ddbas180 toSci "1.265E+3" -> '1265'
-ddbas181 toSci "1.265E+4" -> '1.265E+4'
-ddbas182 toSci "1.265E+8" -> '1.265E+8'
-ddbas183 toSci "1.265E+20" -> '1.265E+20'
-
-ddbas190 toSci "12.65" -> '12.65'
-ddbas191 toSci "12.65E-20" -> '1.265E-19'
-ddbas192 toSci "12.65E-8" -> '1.265E-7'
-ddbas193 toSci "12.65E-4" -> '0.001265'
-ddbas194 toSci "12.65E-3" -> '0.01265'
-ddbas195 toSci "12.65E-2" -> '0.1265'
-ddbas196 toSci "12.65E-1" -> '1.265'
-ddbas197 toSci "12.65E-0" -> '12.65'
-ddbas198 toSci "12.65E+1" -> '126.5'
-ddbas199 toSci "12.65E+2" -> '1265'
-ddbas200 toSci "12.65E+3" -> '1.265E+4'
-ddbas201 toSci "12.65E+4" -> '1.265E+5'
-ddbas202 toSci "12.65E+8" -> '1.265E+9'
-ddbas203 toSci "12.65E+20" -> '1.265E+21'
-
-ddbas210 toSci "126.5" -> '126.5'
-ddbas211 toSci "126.5E-20" -> '1.265E-18'
-ddbas212 toSci "126.5E-8" -> '0.000001265'
-ddbas213 toSci "126.5E-4" -> '0.01265'
-ddbas214 toSci "126.5E-3" -> '0.1265'
-ddbas215 toSci "126.5E-2" -> '1.265'
-ddbas216 toSci "126.5E-1" -> '12.65'
-ddbas217 toSci "126.5E-0" -> '126.5'
-ddbas218 toSci "126.5E+1" -> '1265'
-ddbas219 toSci "126.5E+2" -> '1.265E+4'
-ddbas220 toSci "126.5E+3" -> '1.265E+5'
-ddbas221 toSci "126.5E+4" -> '1.265E+6'
-ddbas222 toSci "126.5E+8" -> '1.265E+10'
-ddbas223 toSci "126.5E+20" -> '1.265E+22'
-
-ddbas230 toSci "1265" -> '1265'
-ddbas231 toSci "1265E-20" -> '1.265E-17'
-ddbas232 toSci "1265E-8" -> '0.00001265'
-ddbas233 toSci "1265E-4" -> '0.1265'
-ddbas234 toSci "1265E-3" -> '1.265'
-ddbas235 toSci "1265E-2" -> '12.65'
-ddbas236 toSci "1265E-1" -> '126.5'
-ddbas237 toSci "1265E-0" -> '1265'
-ddbas238 toSci "1265E+1" -> '1.265E+4'
-ddbas239 toSci "1265E+2" -> '1.265E+5'
-ddbas240 toSci "1265E+3" -> '1.265E+6'
-ddbas241 toSci "1265E+4" -> '1.265E+7'
-ddbas242 toSci "1265E+8" -> '1.265E+11'
-ddbas243 toSci "1265E+20" -> '1.265E+23'
-ddbas244 toSci "1265E-9" -> '0.000001265'
-ddbas245 toSci "1265E-10" -> '1.265E-7'
-ddbas246 toSci "1265E-11" -> '1.265E-8'
-ddbas247 toSci "1265E-12" -> '1.265E-9'
-
-ddbas250 toSci "0.1265" -> '0.1265'
-ddbas251 toSci "0.1265E-20" -> '1.265E-21'
-ddbas252 toSci "0.1265E-8" -> '1.265E-9'
-ddbas253 toSci "0.1265E-4" -> '0.00001265'
-ddbas254 toSci "0.1265E-3" -> '0.0001265'
-ddbas255 toSci "0.1265E-2" -> '0.001265'
-ddbas256 toSci "0.1265E-1" -> '0.01265'
-ddbas257 toSci "0.1265E-0" -> '0.1265'
-ddbas258 toSci "0.1265E+1" -> '1.265'
-ddbas259 toSci "0.1265E+2" -> '12.65'
-ddbas260 toSci "0.1265E+3" -> '126.5'
-ddbas261 toSci "0.1265E+4" -> '1265'
-ddbas262 toSci "0.1265E+8" -> '1.265E+7'
-ddbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-ddbas290 toSci "-0.000E-1" -> '-0.0000'
-ddbas291 toSci "-0.000E-2" -> '-0.00000'
-ddbas292 toSci "-0.000E-3" -> '-0.000000'
-ddbas293 toSci "-0.000E-4" -> '-0E-7'
-ddbas294 toSci "-0.00E-2" -> '-0.0000'
-ddbas295 toSci "-0.00E-3" -> '-0.00000'
-ddbas296 toSci "-0.0E-2" -> '-0.000'
-ddbas297 toSci "-0.0E-3" -> '-0.0000'
-ddbas298 toSci "-0E-2" -> '-0.00'
-ddbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-ddbas301 toSci 10e12 -> 1.0E+13
-ddbas302 toEng 10e12 -> 10E+12
-ddbas303 toSci 10e11 -> 1.0E+12
-ddbas304 toEng 10e11 -> 1.0E+12
-ddbas305 toSci 10e10 -> 1.0E+11
-ddbas306 toEng 10e10 -> 100E+9
-ddbas307 toSci 10e9 -> 1.0E+10
-ddbas308 toEng 10e9 -> 10E+9
-ddbas309 toSci 10e8 -> 1.0E+9
-ddbas310 toEng 10e8 -> 1.0E+9
-ddbas311 toSci 10e7 -> 1.0E+8
-ddbas312 toEng 10e7 -> 100E+6
-ddbas313 toSci 10e6 -> 1.0E+7
-ddbas314 toEng 10e6 -> 10E+6
-ddbas315 toSci 10e5 -> 1.0E+6
-ddbas316 toEng 10e5 -> 1.0E+6
-ddbas317 toSci 10e4 -> 1.0E+5
-ddbas318 toEng 10e4 -> 100E+3
-ddbas319 toSci 10e3 -> 1.0E+4
-ddbas320 toEng 10e3 -> 10E+3
-ddbas321 toSci 10e2 -> 1.0E+3
-ddbas322 toEng 10e2 -> 1.0E+3
-ddbas323 toSci 10e1 -> 1.0E+2
-ddbas324 toEng 10e1 -> 100
-ddbas325 toSci 10e0 -> 10
-ddbas326 toEng 10e0 -> 10
-ddbas327 toSci 10e-1 -> 1.0
-ddbas328 toEng 10e-1 -> 1.0
-ddbas329 toSci 10e-2 -> 0.10
-ddbas330 toEng 10e-2 -> 0.10
-ddbas331 toSci 10e-3 -> 0.010
-ddbas332 toEng 10e-3 -> 0.010
-ddbas333 toSci 10e-4 -> 0.0010
-ddbas334 toEng 10e-4 -> 0.0010
-ddbas335 toSci 10e-5 -> 0.00010
-ddbas336 toEng 10e-5 -> 0.00010
-ddbas337 toSci 10e-6 -> 0.000010
-ddbas338 toEng 10e-6 -> 0.000010
-ddbas339 toSci 10e-7 -> 0.0000010
-ddbas340 toEng 10e-7 -> 0.0000010
-ddbas341 toSci 10e-8 -> 1.0E-7
-ddbas342 toEng 10e-8 -> 100E-9
-ddbas343 toSci 10e-9 -> 1.0E-8
-ddbas344 toEng 10e-9 -> 10E-9
-ddbas345 toSci 10e-10 -> 1.0E-9
-ddbas346 toEng 10e-10 -> 1.0E-9
-ddbas347 toSci 10e-11 -> 1.0E-10
-ddbas348 toEng 10e-11 -> 100E-12
-ddbas349 toSci 10e-12 -> 1.0E-11
-ddbas350 toEng 10e-12 -> 10E-12
-ddbas351 toSci 10e-13 -> 1.0E-12
-ddbas352 toEng 10e-13 -> 1.0E-12
-
-ddbas361 toSci 7E12 -> 7E+12
-ddbas362 toEng 7E12 -> 7E+12
-ddbas363 toSci 7E11 -> 7E+11
-ddbas364 toEng 7E11 -> 700E+9
-ddbas365 toSci 7E10 -> 7E+10
-ddbas366 toEng 7E10 -> 70E+9
-ddbas367 toSci 7E9 -> 7E+9
-ddbas368 toEng 7E9 -> 7E+9
-ddbas369 toSci 7E8 -> 7E+8
-ddbas370 toEng 7E8 -> 700E+6
-ddbas371 toSci 7E7 -> 7E+7
-ddbas372 toEng 7E7 -> 70E+6
-ddbas373 toSci 7E6 -> 7E+6
-ddbas374 toEng 7E6 -> 7E+6
-ddbas375 toSci 7E5 -> 7E+5
-ddbas376 toEng 7E5 -> 700E+3
-ddbas377 toSci 7E4 -> 7E+4
-ddbas378 toEng 7E4 -> 70E+3
-ddbas379 toSci 7E3 -> 7E+3
-ddbas380 toEng 7E3 -> 7E+3
-ddbas381 toSci 7E2 -> 7E+2
-ddbas382 toEng 7E2 -> 700
-ddbas383 toSci 7E1 -> 7E+1
-ddbas384 toEng 7E1 -> 70
-ddbas385 toSci 7E0 -> 7
-ddbas386 toEng 7E0 -> 7
-ddbas387 toSci 7E-1 -> 0.7
-ddbas388 toEng 7E-1 -> 0.7
-ddbas389 toSci 7E-2 -> 0.07
-ddbas390 toEng 7E-2 -> 0.07
-ddbas391 toSci 7E-3 -> 0.007
-ddbas392 toEng 7E-3 -> 0.007
-ddbas393 toSci 7E-4 -> 0.0007
-ddbas394 toEng 7E-4 -> 0.0007
-ddbas395 toSci 7E-5 -> 0.00007
-ddbas396 toEng 7E-5 -> 0.00007
-ddbas397 toSci 7E-6 -> 0.000007
-ddbas398 toEng 7E-6 -> 0.000007
-ddbas399 toSci 7E-7 -> 7E-7
-ddbas400 toEng 7E-7 -> 700E-9
-ddbas401 toSci 7E-8 -> 7E-8
-ddbas402 toEng 7E-8 -> 70E-9
-ddbas403 toSci 7E-9 -> 7E-9
-ddbas404 toEng 7E-9 -> 7E-9
-ddbas405 toSci 7E-10 -> 7E-10
-ddbas406 toEng 7E-10 -> 700E-12
-ddbas407 toSci 7E-11 -> 7E-11
-ddbas408 toEng 7E-11 -> 70E-12
-ddbas409 toSci 7E-12 -> 7E-12
-ddbas410 toEng 7E-12 -> 7E-12
-ddbas411 toSci 7E-13 -> 7E-13
-ddbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-rounding: half_up
-ddbas420 toSci 100 -> 100
-ddbas421 toEng 100 -> 100
-ddbas422 toSci 1000 -> 1000
-ddbas423 toEng 1000 -> 1000
-ddbas424 toSci 999.9 -> 999.9
-ddbas425 toEng 999.9 -> 999.9
-ddbas426 toSci 1000.0 -> 1000.0
-ddbas427 toEng 1000.0 -> 1000.0
-ddbas428 toSci 1000.1 -> 1000.1
-ddbas429 toEng 1000.1 -> 1000.1
-ddbas430 toSci 10000 -> 10000
-ddbas431 toEng 10000 -> 10000
-ddbas432 toSci 100000 -> 100000
-ddbas433 toEng 100000 -> 100000
-ddbas434 toSci 1000000 -> 1000000
-ddbas435 toEng 1000000 -> 1000000
-ddbas436 toSci 10000000 -> 10000000
-ddbas437 toEng 10000000 -> 10000000
-ddbas438 toSci 100000000 -> 100000000
-ddbas439 toEng 1000000000000000 -> 1000000000000000
-ddbas440 toSci 10000000000000000 -> 1.000000000000000E+16 Rounded
-ddbas441 toEng 10000000000000000 -> 10.00000000000000E+15 Rounded
-ddbas442 toSci 10000000000000001 -> 1.000000000000000E+16 Rounded Inexact
-ddbas443 toEng 10000000000000001 -> 10.00000000000000E+15 Rounded Inexact
-ddbas444 toSci 10000000000000003 -> 1.000000000000000E+16 Rounded Inexact
-ddbas445 toEng 10000000000000003 -> 10.00000000000000E+15 Rounded Inexact
-ddbas446 toSci 10000000000000005 -> 1.000000000000001E+16 Rounded Inexact
-ddbas447 toEng 10000000000000005 -> 10.00000000000001E+15 Rounded Inexact
-ddbas448 toSci 100000000000000050 -> 1.000000000000001E+17 Rounded Inexact
-ddbas449 toEng 100000000000000050 -> 100.0000000000001E+15 Rounded Inexact
-ddbas450 toSci 10000000000000009 -> 1.000000000000001E+16 Rounded Inexact
-ddbas451 toEng 10000000000000009 -> 10.00000000000001E+15 Rounded Inexact
-ddbas452 toSci 100000000000000000 -> 1.000000000000000E+17 Rounded
-ddbas453 toEng 100000000000000000 -> 100.0000000000000E+15 Rounded
-ddbas454 toSci 100000000000000003 -> 1.000000000000000E+17 Rounded Inexact
-ddbas455 toEng 100000000000000003 -> 100.0000000000000E+15 Rounded Inexact
-ddbas456 toSci 100000000000000005 -> 1.000000000000000E+17 Rounded Inexact
-ddbas457 toEng 100000000000000005 -> 100.0000000000000E+15 Rounded Inexact
-ddbas458 toSci 100000000000000009 -> 1.000000000000000E+17 Rounded Inexact
-ddbas459 toEng 100000000000000009 -> 100.0000000000000E+15 Rounded Inexact
-ddbas460 toSci 1000000000000000000 -> 1.000000000000000E+18 Rounded
-ddbas461 toEng 1000000000000000000 -> 1.000000000000000E+18 Rounded
-ddbas462 toSci 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
-ddbas463 toEng 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
-ddbas464 toSci 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
-ddbas465 toEng 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
-ddbas466 toSci 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
-ddbas467 toEng 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
-ddbas468 toSci 10000000000000000000 -> 1.000000000000000E+19 Rounded
-ddbas469 toEng 10000000000000000000 -> 10.00000000000000E+18 Rounded
-ddbas470 toSci 10000000000000003000 -> 1.000000000000000E+19 Rounded Inexact
-ddbas471 toEng 10000000000000003000 -> 10.00000000000000E+18 Rounded Inexact
-ddbas472 toSci 10000000000000005000 -> 1.000000000000001E+19 Rounded Inexact
-ddbas473 toEng 10000000000000005000 -> 10.00000000000001E+18 Rounded Inexact
-ddbas474 toSci 10000000000000009000 -> 1.000000000000001E+19 Rounded Inexact
-ddbas475 toEng 10000000000000009000 -> 10.00000000000001E+18 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-ddbsr401 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr402 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
-ddbsr403 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr404 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: up
-ddbsr405 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr406 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
-ddbsr407 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr408 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: floor
-ddbsr410 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr411 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr412 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr413 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
-rounding: half_down
-ddbsr415 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr416 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr417 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr418 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
-ddbsr419 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: half_even
-ddbsr421 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr422 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr423 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr424 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
-ddbsr425 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
-rounding: down
-ddbsr426 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr427 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr428 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
-ddbsr429 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
-rounding: half_up
-ddbsr431 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
-ddbsr432 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
-ddbsr433 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
-ddbsr434 toSci 1.11111111111234650 -> 1.111111111112347 Rounded Inexact
-ddbsr435 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
--- negatives
-rounding: ceiling
-ddbsr501 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr502 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr503 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr504 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
-rounding: up
-ddbsr505 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr506 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
-ddbsr507 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr508 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: floor
-ddbsr510 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr511 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
-ddbsr512 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr513 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: half_down
-ddbsr515 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr516 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr517 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr518 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
-ddbsr519 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: half_even
-ddbsr521 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr522 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr523 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr524 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
-ddbsr525 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-rounding: down
-ddbsr526 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr527 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr528 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
-ddbsr529 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
-rounding: half_up
-ddbsr531 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
-ddbsr532 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
-ddbsr533 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
-ddbsr534 toSci -1.11111111111234650 -> -1.111111111112347 Rounded Inexact
-ddbsr535 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-ddbas500 toSci '1..2' -> NaN Conversion_syntax
-ddbas501 toSci '.' -> NaN Conversion_syntax
-ddbas502 toSci '..' -> NaN Conversion_syntax
-ddbas503 toSci '++1' -> NaN Conversion_syntax
-ddbas504 toSci '--1' -> NaN Conversion_syntax
-ddbas505 toSci '-+1' -> NaN Conversion_syntax
-ddbas506 toSci '+-1' -> NaN Conversion_syntax
-ddbas507 toSci '12e' -> NaN Conversion_syntax
-ddbas508 toSci '12e++' -> NaN Conversion_syntax
-ddbas509 toSci '12f4' -> NaN Conversion_syntax
-ddbas510 toSci ' +1' -> NaN Conversion_syntax
-ddbas511 toSci '+ 1' -> NaN Conversion_syntax
-ddbas512 toSci '12 ' -> NaN Conversion_syntax
-ddbas513 toSci ' + 1' -> NaN Conversion_syntax
-ddbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-ddbas515 toSci 'x' -> NaN Conversion_syntax
-ddbas516 toSci '-1-' -> NaN Conversion_syntax
-ddbas517 toSci '12-' -> NaN Conversion_syntax
-ddbas518 toSci '3+' -> NaN Conversion_syntax
-ddbas519 toSci '' -> NaN Conversion_syntax
-ddbas520 toSci '1e-' -> NaN Conversion_syntax
-ddbas521 toSci '7e99999a' -> NaN Conversion_syntax
-ddbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-ddbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-ddbas524 toSci '' -> NaN Conversion_syntax
-ddbas525 toSci 'e100' -> NaN Conversion_syntax
-ddbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-ddbas527 toSci '\u0b65' -> NaN Conversion_syntax
-ddbas528 toSci '123,65' -> NaN Conversion_syntax
-ddbas529 toSci '1.34.5' -> NaN Conversion_syntax
-ddbas530 toSci '.123.5' -> NaN Conversion_syntax
-ddbas531 toSci '01.35.' -> NaN Conversion_syntax
-ddbas532 toSci '01.35-' -> NaN Conversion_syntax
-ddbas533 toSci '0000..' -> NaN Conversion_syntax
-ddbas534 toSci '.0000.' -> NaN Conversion_syntax
-ddbas535 toSci '00..00' -> NaN Conversion_syntax
-ddbas536 toSci '111e*123' -> NaN Conversion_syntax
-ddbas537 toSci '111e123-' -> NaN Conversion_syntax
-ddbas538 toSci '111e+12+' -> NaN Conversion_syntax
-ddbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-ddbas540 toSci '111e1*23' -> NaN Conversion_syntax
-ddbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-ddbas542 toSci '1e1.0' -> NaN Conversion_syntax
-ddbas543 toSci '1e123e' -> NaN Conversion_syntax
-ddbas544 toSci 'ten' -> NaN Conversion_syntax
-ddbas545 toSci 'ONE' -> NaN Conversion_syntax
-ddbas546 toSci '1e.1' -> NaN Conversion_syntax
-ddbas547 toSci '1e1.' -> NaN Conversion_syntax
-ddbas548 toSci '1ee' -> NaN Conversion_syntax
-ddbas549 toSci 'e+1' -> NaN Conversion_syntax
-ddbas550 toSci '1.23.4' -> NaN Conversion_syntax
-ddbas551 toSci '1.2.1' -> NaN Conversion_syntax
-ddbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-ddbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-ddbas554 toSci '1E++1' -> NaN Conversion_syntax
-ddbas555 toSci '1E--1' -> NaN Conversion_syntax
-ddbas556 toSci '1E+-1' -> NaN Conversion_syntax
-ddbas557 toSci '1E-+1' -> NaN Conversion_syntax
-ddbas558 toSci '1E''1' -> NaN Conversion_syntax
-ddbas559 toSci "1E""1" -> NaN Conversion_syntax
-ddbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-ddbas561 toSci "qNaN" -> NaN Conversion_syntax
-ddbas562 toSci "NaNq" -> NaN Conversion_syntax
-ddbas563 toSci "NaNs" -> NaN Conversion_syntax
-ddbas564 toSci "Infi" -> NaN Conversion_syntax
-ddbas565 toSci "Infin" -> NaN Conversion_syntax
-ddbas566 toSci "Infini" -> NaN Conversion_syntax
-ddbas567 toSci "Infinit" -> NaN Conversion_syntax
-ddbas568 toSci "-Infinit" -> NaN Conversion_syntax
-ddbas569 toSci "0Inf" -> NaN Conversion_syntax
-ddbas570 toSci "9Inf" -> NaN Conversion_syntax
-ddbas571 toSci "-0Inf" -> NaN Conversion_syntax
-ddbas572 toSci "-9Inf" -> NaN Conversion_syntax
-ddbas573 toSci "-sNa" -> NaN Conversion_syntax
-ddbas574 toSci "xNaN" -> NaN Conversion_syntax
-ddbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-ddbas576 toSci 'e+1' -> NaN Conversion_syntax
-ddbas577 toSci '.e+1' -> NaN Conversion_syntax
-ddbas578 toSci '+.e+1' -> NaN Conversion_syntax
-ddbas579 toSci '-.e+' -> NaN Conversion_syntax
-ddbas580 toSci '-.e' -> NaN Conversion_syntax
-ddbas581 toSci 'E+1' -> NaN Conversion_syntax
-ddbas582 toSci '.E+1' -> NaN Conversion_syntax
-ddbas583 toSci '+.E+1' -> NaN Conversion_syntax
-ddbas584 toSci '-.E+' -> NaN Conversion_syntax
-ddbas585 toSci '-.E' -> NaN Conversion_syntax
-
-ddbas586 toSci '.NaN' -> NaN Conversion_syntax
-ddbas587 toSci '-.NaN' -> NaN Conversion_syntax
-ddbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-ddbas589 toSci '+.Inf' -> NaN Conversion_syntax
-ddbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-ddbas601 toSci 0.000000000 -> 0E-9
-ddbas602 toSci 0.00000000 -> 0E-8
-ddbas603 toSci 0.0000000 -> 0E-7
-ddbas604 toSci 0.000000 -> 0.000000
-ddbas605 toSci 0.00000 -> 0.00000
-ddbas606 toSci 0.0000 -> 0.0000
-ddbas607 toSci 0.000 -> 0.000
-ddbas608 toSci 0.00 -> 0.00
-ddbas609 toSci 0.0 -> 0.0
-ddbas610 toSci .0 -> 0.0
-ddbas611 toSci 0. -> 0
-ddbas612 toSci -.0 -> -0.0
-ddbas613 toSci -0. -> -0
-ddbas614 toSci -0.0 -> -0.0
-ddbas615 toSci -0.00 -> -0.00
-ddbas616 toSci -0.000 -> -0.000
-ddbas617 toSci -0.0000 -> -0.0000
-ddbas618 toSci -0.00000 -> -0.00000
-ddbas619 toSci -0.000000 -> -0.000000
-ddbas620 toSci -0.0000000 -> -0E-7
-ddbas621 toSci -0.00000000 -> -0E-8
-ddbas622 toSci -0.000000000 -> -0E-9
-
-ddbas630 toSci 0.00E+0 -> 0.00
-ddbas631 toSci 0.00E+1 -> 0.0
-ddbas632 toSci 0.00E+2 -> 0
-ddbas633 toSci 0.00E+3 -> 0E+1
-ddbas634 toSci 0.00E+4 -> 0E+2
-ddbas635 toSci 0.00E+5 -> 0E+3
-ddbas636 toSci 0.00E+6 -> 0E+4
-ddbas637 toSci 0.00E+7 -> 0E+5
-ddbas638 toSci 0.00E+8 -> 0E+6
-ddbas639 toSci 0.00E+9 -> 0E+7
-
-ddbas640 toSci 0.0E+0 -> 0.0
-ddbas641 toSci 0.0E+1 -> 0
-ddbas642 toSci 0.0E+2 -> 0E+1
-ddbas643 toSci 0.0E+3 -> 0E+2
-ddbas644 toSci 0.0E+4 -> 0E+3
-ddbas645 toSci 0.0E+5 -> 0E+4
-ddbas646 toSci 0.0E+6 -> 0E+5
-ddbas647 toSci 0.0E+7 -> 0E+6
-ddbas648 toSci 0.0E+8 -> 0E+7
-ddbas649 toSci 0.0E+9 -> 0E+8
-
-ddbas650 toSci 0E+0 -> 0
-ddbas651 toSci 0E+1 -> 0E+1
-ddbas652 toSci 0E+2 -> 0E+2
-ddbas653 toSci 0E+3 -> 0E+3
-ddbas654 toSci 0E+4 -> 0E+4
-ddbas655 toSci 0E+5 -> 0E+5
-ddbas656 toSci 0E+6 -> 0E+6
-ddbas657 toSci 0E+7 -> 0E+7
-ddbas658 toSci 0E+8 -> 0E+8
-ddbas659 toSci 0E+9 -> 0E+9
-
-ddbas660 toSci 0.0E-0 -> 0.0
-ddbas661 toSci 0.0E-1 -> 0.00
-ddbas662 toSci 0.0E-2 -> 0.000
-ddbas663 toSci 0.0E-3 -> 0.0000
-ddbas664 toSci 0.0E-4 -> 0.00000
-ddbas665 toSci 0.0E-5 -> 0.000000
-ddbas666 toSci 0.0E-6 -> 0E-7
-ddbas667 toSci 0.0E-7 -> 0E-8
-ddbas668 toSci 0.0E-8 -> 0E-9
-ddbas669 toSci 0.0E-9 -> 0E-10
-
-ddbas670 toSci 0.00E-0 -> 0.00
-ddbas671 toSci 0.00E-1 -> 0.000
-ddbas672 toSci 0.00E-2 -> 0.0000
-ddbas673 toSci 0.00E-3 -> 0.00000
-ddbas674 toSci 0.00E-4 -> 0.000000
-ddbas675 toSci 0.00E-5 -> 0E-7
-ddbas676 toSci 0.00E-6 -> 0E-8
-ddbas677 toSci 0.00E-7 -> 0E-9
-ddbas678 toSci 0.00E-8 -> 0E-10
-ddbas679 toSci 0.00E-9 -> 0E-11
-
-ddbas680 toSci 000000. -> 0
-ddbas681 toSci 00000. -> 0
-ddbas682 toSci 0000. -> 0
-ddbas683 toSci 000. -> 0
-ddbas684 toSci 00. -> 0
-ddbas685 toSci 0. -> 0
-ddbas686 toSci +00000. -> 0
-ddbas687 toSci -00000. -> -0
-ddbas688 toSci +0. -> 0
-ddbas689 toSci -0. -> -0
-
--- Specials
-ddbas700 toSci "NaN" -> NaN
-ddbas701 toSci "nan" -> NaN
-ddbas702 toSci "nAn" -> NaN
-ddbas703 toSci "NAN" -> NaN
-ddbas704 toSci "+NaN" -> NaN
-ddbas705 toSci "+nan" -> NaN
-ddbas706 toSci "+nAn" -> NaN
-ddbas707 toSci "+NAN" -> NaN
-ddbas708 toSci "-NaN" -> -NaN
-ddbas709 toSci "-nan" -> -NaN
-ddbas710 toSci "-nAn" -> -NaN
-ddbas711 toSci "-NAN" -> -NaN
-ddbas712 toSci 'NaN0' -> NaN
-ddbas713 toSci 'NaN1' -> NaN1
-ddbas714 toSci 'NaN12' -> NaN12
-ddbas715 toSci 'NaN123' -> NaN123
-ddbas716 toSci 'NaN1234' -> NaN1234
-ddbas717 toSci 'NaN01' -> NaN1
-ddbas718 toSci 'NaN012' -> NaN12
-ddbas719 toSci 'NaN0123' -> NaN123
-ddbas720 toSci 'NaN01234' -> NaN1234
-ddbas721 toSci 'NaN001' -> NaN1
-ddbas722 toSci 'NaN0012' -> NaN12
-ddbas723 toSci 'NaN00123' -> NaN123
-ddbas724 toSci 'NaN001234' -> NaN1234
-ddbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
-ddbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-ddbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-ddbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-ddbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-ddbas730 toSci "sNaN" -> sNaN
-ddbas731 toSci "snan" -> sNaN
-ddbas732 toSci "SnAn" -> sNaN
-ddbas733 toSci "SNAN" -> sNaN
-ddbas734 toSci "+sNaN" -> sNaN
-ddbas735 toSci "+snan" -> sNaN
-ddbas736 toSci "+SnAn" -> sNaN
-ddbas737 toSci "+SNAN" -> sNaN
-ddbas738 toSci "-sNaN" -> -sNaN
-ddbas739 toSci "-snan" -> -sNaN
-ddbas740 toSci "-SnAn" -> -sNaN
-ddbas741 toSci "-SNAN" -> -sNaN
-ddbas742 toSci 'sNaN0000' -> sNaN
-ddbas743 toSci 'sNaN7' -> sNaN7
-ddbas744 toSci 'sNaN007234' -> sNaN7234
-ddbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
-ddbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-ddbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-ddbas748 toSci "Inf" -> Infinity
-ddbas749 toSci "inf" -> Infinity
-ddbas750 toSci "iNf" -> Infinity
-ddbas751 toSci "INF" -> Infinity
-ddbas752 toSci "+Inf" -> Infinity
-ddbas753 toSci "+inf" -> Infinity
-ddbas754 toSci "+iNf" -> Infinity
-ddbas755 toSci "+INF" -> Infinity
-ddbas756 toSci "-Inf" -> -Infinity
-ddbas757 toSci "-inf" -> -Infinity
-ddbas758 toSci "-iNf" -> -Infinity
-ddbas759 toSci "-INF" -> -Infinity
-
-ddbas760 toSci "Infinity" -> Infinity
-ddbas761 toSci "infinity" -> Infinity
-ddbas762 toSci "iNfInItY" -> Infinity
-ddbas763 toSci "INFINITY" -> Infinity
-ddbas764 toSci "+Infinity" -> Infinity
-ddbas765 toSci "+infinity" -> Infinity
-ddbas766 toSci "+iNfInItY" -> Infinity
-ddbas767 toSci "+INFINITY" -> Infinity
-ddbas768 toSci "-Infinity" -> -Infinity
-ddbas769 toSci "-infinity" -> -Infinity
-ddbas770 toSci "-iNfInItY" -> -Infinity
-ddbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-ddbast772 toEng "NaN" -> NaN
-ddbast773 toEng "-Infinity" -> -Infinity
-ddbast774 toEng "-sNaN" -> -sNaN
-ddbast775 toEng "-NaN" -> -NaN
-ddbast776 toEng "+Infinity" -> Infinity
-ddbast778 toEng "+sNaN" -> sNaN
-ddbast779 toEng "+NaN" -> NaN
-ddbast780 toEng "INFINITY" -> Infinity
-ddbast781 toEng "SNAN" -> sNaN
-ddbast782 toEng "NAN" -> NaN
-ddbast783 toEng "infinity" -> Infinity
-ddbast784 toEng "snan" -> sNaN
-ddbast785 toEng "nan" -> NaN
-ddbast786 toEng "InFINITY" -> Infinity
-ddbast787 toEng "SnAN" -> sNaN
-ddbast788 toEng "nAN" -> NaN
-ddbast789 toEng "iNfinity" -> Infinity
-ddbast790 toEng "sNan" -> sNaN
-ddbast791 toEng "Nan" -> NaN
-ddbast792 toEng "Infinity" -> Infinity
-ddbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-ddbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-ddbast801 toEng 0.000000000 -> 0E-9
-ddbast802 toEng 0.00000000 -> 0.00E-6
-ddbast803 toEng 0.0000000 -> 0.0E-6
-ddbast804 toEng 0.000000 -> 0.000000
-ddbast805 toEng 0.00000 -> 0.00000
-ddbast806 toEng 0.0000 -> 0.0000
-ddbast807 toEng 0.000 -> 0.000
-ddbast808 toEng 0.00 -> 0.00
-ddbast809 toEng 0.0 -> 0.0
-ddbast810 toEng .0 -> 0.0
-ddbast811 toEng 0. -> 0
-ddbast812 toEng -.0 -> -0.0
-ddbast813 toEng -0. -> -0
-ddbast814 toEng -0.0 -> -0.0
-ddbast815 toEng -0.00 -> -0.00
-ddbast816 toEng -0.000 -> -0.000
-ddbast817 toEng -0.0000 -> -0.0000
-ddbast818 toEng -0.00000 -> -0.00000
-ddbast819 toEng -0.000000 -> -0.000000
-ddbast820 toEng -0.0000000 -> -0.0E-6
-ddbast821 toEng -0.00000000 -> -0.00E-6
-ddbast822 toEng -0.000000000 -> -0E-9
-
-ddbast830 toEng 0.00E+0 -> 0.00
-ddbast831 toEng 0.00E+1 -> 0.0
-ddbast832 toEng 0.00E+2 -> 0
-ddbast833 toEng 0.00E+3 -> 0.00E+3
-ddbast834 toEng 0.00E+4 -> 0.0E+3
-ddbast835 toEng 0.00E+5 -> 0E+3
-ddbast836 toEng 0.00E+6 -> 0.00E+6
-ddbast837 toEng 0.00E+7 -> 0.0E+6
-ddbast838 toEng 0.00E+8 -> 0E+6
-ddbast839 toEng 0.00E+9 -> 0.00E+9
-
-ddbast840 toEng 0.0E+0 -> 0.0
-ddbast841 toEng 0.0E+1 -> 0
-ddbast842 toEng 0.0E+2 -> 0.00E+3
-ddbast843 toEng 0.0E+3 -> 0.0E+3
-ddbast844 toEng 0.0E+4 -> 0E+3
-ddbast845 toEng 0.0E+5 -> 0.00E+6
-ddbast846 toEng 0.0E+6 -> 0.0E+6
-ddbast847 toEng 0.0E+7 -> 0E+6
-ddbast848 toEng 0.0E+8 -> 0.00E+9
-ddbast849 toEng 0.0E+9 -> 0.0E+9
-
-ddbast850 toEng 0E+0 -> 0
-ddbast851 toEng 0E+1 -> 0.00E+3
-ddbast852 toEng 0E+2 -> 0.0E+3
-ddbast853 toEng 0E+3 -> 0E+3
-ddbast854 toEng 0E+4 -> 0.00E+6
-ddbast855 toEng 0E+5 -> 0.0E+6
-ddbast856 toEng 0E+6 -> 0E+6
-ddbast857 toEng 0E+7 -> 0.00E+9
-ddbast858 toEng 0E+8 -> 0.0E+9
-ddbast859 toEng 0E+9 -> 0E+9
-
-ddbast860 toEng 0.0E-0 -> 0.0
-ddbast861 toEng 0.0E-1 -> 0.00
-ddbast862 toEng 0.0E-2 -> 0.000
-ddbast863 toEng 0.0E-3 -> 0.0000
-ddbast864 toEng 0.0E-4 -> 0.00000
-ddbast865 toEng 0.0E-5 -> 0.000000
-ddbast866 toEng 0.0E-6 -> 0.0E-6
-ddbast867 toEng 0.0E-7 -> 0.00E-6
-ddbast868 toEng 0.0E-8 -> 0E-9
-ddbast869 toEng 0.0E-9 -> 0.0E-9
-
-ddbast870 toEng 0.00E-0 -> 0.00
-ddbast871 toEng 0.00E-1 -> 0.000
-ddbast872 toEng 0.00E-2 -> 0.0000
-ddbast873 toEng 0.00E-3 -> 0.00000
-ddbast874 toEng 0.00E-4 -> 0.000000
-ddbast875 toEng 0.00E-5 -> 0.0E-6
-ddbast876 toEng 0.00E-6 -> 0.00E-6
-ddbast877 toEng 0.00E-7 -> 0E-9
-ddbast878 toEng 0.00E-8 -> 0.0E-9
-ddbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-ddbas801 tosci '01234567890123456' -> 1234567890123456
-ddbas802 tosci '001234567890123456' -> 1234567890123456
-ddbas803 tosci '0001234567890123456' -> 1234567890123456
-ddbas804 tosci '00001234567890123456' -> 1234567890123456
-ddbas805 tosci '000001234567890123456' -> 1234567890123456
-ddbas806 tosci '0000001234567890123456' -> 1234567890123456
-ddbas807 tosci '00000001234567890123456' -> 1234567890123456
-ddbas808 tosci '000000001234567890123456' -> 1234567890123456
-ddbas809 tosci '0000000001234567890123456' -> 1234567890123456
-ddbas810 tosci '00000000001234567890123456' -> 1234567890123456
-
-ddbas811 tosci '0.1234567890123456' -> 0.1234567890123456
-ddbas812 tosci '0.01234567890123456' -> 0.01234567890123456
-ddbas813 tosci '0.001234567890123456' -> 0.001234567890123456
-ddbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
-ddbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
-ddbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
-ddbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
-ddbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
-ddbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
-ddbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
-
-ddbas821 tosci '12345678901234567890' -> 1.234567890123457E+19 Inexact Rounded
-ddbas822 tosci '123456789012345678901' -> 1.234567890123457E+20 Inexact Rounded
-ddbas823 tosci '1234567890123456789012' -> 1.234567890123457E+21 Inexact Rounded
-ddbas824 tosci '12345678901234567890123' -> 1.234567890123457E+22 Inexact Rounded
-ddbas825 tosci '123456789012345678901234' -> 1.234567890123457E+23 Inexact Rounded
-ddbas826 tosci '1234567890123456789012345' -> 1.234567890123457E+24 Inexact Rounded
-ddbas827 tosci '12345678901234567890123456' -> 1.234567890123457E+25 Inexact Rounded
-ddbas828 tosci '123456789012345678901234567' -> 1.234567890123457E+26 Inexact Rounded
-ddbas829 tosci '1234567890123456789012345678' -> 1.234567890123457E+27 Inexact Rounded
-
--- subnormals and overflows
-ddbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-ddbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-ddbas908 toSci '0.9e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas909 toSci '0.09e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-ddbas911 toSci '10e-1000000000' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-ddbas913 toSci '99e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-ddbas915 toSci '1111e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas916 toSci '1111e-99999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-ddbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-ddbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-ddbas920 toSci '-0.9e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas921 toSci '-0.09e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-ddbas923 toSci '-10e-1000000000' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-ddbas925 toSci '-99e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-ddbas927 toSci '-1111e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas928 toSci '-1111e-99999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-ddbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas931 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
-rounding: up
-ddbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-ddbas934 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddbas935 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
-rounding: floor
-ddbas936 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
-ddbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-ddbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-ddbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-ddbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-ddbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-ddbem400 toSci 1.0000E-383 -> 1.0000E-383
-ddbem401 toSci 0.1E-394 -> 1E-395 Subnormal
-ddbem402 toSci 0.1000E-394 -> 1.000E-395 Subnormal
-ddbem403 toSci 0.0100E-394 -> 1.00E-396 Subnormal
-ddbem404 toSci 0.0010E-394 -> 1.0E-397 Subnormal
-ddbem405 toSci 0.0001E-394 -> 1E-398 Subnormal
-ddbem406 toSci 0.00010E-394 -> 1E-398 Subnormal Rounded
-ddbem407 toSci 0.00013E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem408 toSci 0.00015E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem409 toSci 0.00017E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem410 toSci 0.00023E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem411 toSci 0.00025E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem412 toSci 0.00027E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddbem413 toSci 0.000149E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem414 toSci 0.000150E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem415 toSci 0.000151E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem416 toSci 0.000249E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem417 toSci 0.000250E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddbem418 toSci 0.000251E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddbem419 toSci 0.00009E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem420 toSci 0.00005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem421 toSci 0.00003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem422 toSci 0.000009E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem423 toSci 0.000005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem424 toSci 0.000003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddbem425 toSci 0.001049E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem426 toSci 0.001050E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem427 toSci 0.001051E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddbem428 toSci 0.001149E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddbem429 toSci 0.001150E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
-ddbem430 toSci 0.001151E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
-
-ddbem432 toSci 0.010049E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem433 toSci 0.010050E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem434 toSci 0.010051E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddbem435 toSci 0.010149E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddbem436 toSci 0.010150E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
-ddbem437 toSci 0.010151E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
-
-ddbem440 toSci 0.10103E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem441 toSci 0.10105E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem442 toSci 0.10107E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem443 toSci 0.10113E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem444 toSci 0.10115E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
-ddbem445 toSci 0.10117E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
-
-ddbem450 toSci 1.10730E-395 -> 1.107E-395 Underflow Subnormal Inexact Rounded
-ddbem451 toSci 1.10750E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem452 toSci 1.10770E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem453 toSci 1.10830E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem454 toSci 1.10850E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
-ddbem455 toSci 1.10870E-395 -> 1.109E-395 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-ddbem456 toSci -0.10103E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem457 toSci -0.10105E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
-ddbem458 toSci -0.10107E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem459 toSci -0.10113E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
-ddbem460 toSci -0.10115E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
-ddbem461 toSci -0.10117E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-ddbem464 toSci 999999E-395 -> 9.99999E-390 Subnormal
-ddbem465 toSci 99999.0E-394 -> 9.99990E-390 Subnormal
-ddbem466 toSci 99999.E-394 -> 9.9999E-390 Subnormal
-ddbem467 toSci 9999.9E-394 -> 9.9999E-391 Subnormal
-ddbem468 toSci 999.99E-394 -> 9.9999E-392 Subnormal
-ddbem469 toSci 99.999E-394 -> 9.9999E-393 Subnormal
-ddbem470 toSci 9.9999E-394 -> 9.9999E-394 Subnormal
-ddbem471 toSci 0.99999E-394 -> 1.0000E-394 Underflow Subnormal Inexact Rounded
-ddbem472 toSci 0.099999E-394 -> 1.000E-395 Underflow Subnormal Inexact Rounded
-ddbem473 toSci 0.0099999E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
-ddbem474 toSci 0.00099999E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
-ddbem475 toSci 0.000099999E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddbem476 toSci 0.0000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem477 toSci 0.00000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbem478 toSci 0.000000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-ddbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-ddbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-ddbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-ddbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-ddbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-ddbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-ddbas1007 toSci 1e-999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1008 toSci 1e-0999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1009 toSci 1e-00999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1010 toSci 1e-000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1011 toSci 1e-000000000000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddbas1012 toSci 1e-000000000001000000007 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-ddbas1041 toSci 1.1111111111152444E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-ddbas1042 toSci 1.1111111111152445E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-ddbas1043 toSci 1.1111111111152446E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
-
--- clamped large normals
-ddbas1070 toSci 1E+369 -> 1E+369
-ddbas1071 toSci 1E+370 -> 1.0E+370 Clamped
-ddbas1072 toSci 1E+378 -> 1.000000000E+378 Clamped
-ddbas1073 toSci 1E+384 -> 1.000000000000000E+384 Clamped
-ddbas1074 toSci 1E+385 -> Infinity Overflow Inexact Rounded
-
-
--- clamped zeros [see also clamp.decTest]
-ddbas1075 toSci 0e+10000 -> 0E+369 Clamped
-ddbas1076 toSci 0e-10000 -> 0E-398 Clamped
-ddbas1077 toSci -0e+10000 -> -0E+369 Clamped
-ddbas1078 toSci -0e-10000 -> -0E-398 Clamped
-
--- extreme values from next-wider
-ddbas1101 toSci -9.99999999999999999999999999999999E+6144 -> -Infinity Overflow Inexact Rounded
-ddbas1102 toSci -1E-6143 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1103 toSci -1E-6176 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1104 toSci -0 -> -0
-ddbas1105 toSci +0 -> 0
-ddbas1106 toSci +1E-6176 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1107 toSci +1E-6173 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
-ddbas1108 toSci +9.99999999999999999999999999999999E+6144 -> Infinity Overflow Inexact Rounded
-
+------------------------------------------------------------------------
+-- ddBase.decTest -- base decDouble <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decDouble. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddbas001 toSci 0 -> 0
+ddbas002 toSci 1 -> 1
+ddbas003 toSci 1.0 -> 1.0
+ddbas004 toSci 1.00 -> 1.00
+ddbas005 toSci 10 -> 10
+ddbas006 toSci 1000 -> 1000
+ddbas007 toSci 10.0 -> 10.0
+ddbas008 toSci 10.1 -> 10.1
+ddbas009 toSci 10.4 -> 10.4
+ddbas010 toSci 10.5 -> 10.5
+ddbas011 toSci 10.6 -> 10.6
+ddbas012 toSci 10.9 -> 10.9
+ddbas013 toSci 11.0 -> 11.0
+ddbas014 toSci 1.234 -> 1.234
+ddbas015 toSci 0.123 -> 0.123
+ddbas016 toSci 0.012 -> 0.012
+ddbas017 toSci -0 -> -0
+ddbas018 toSci -0.0 -> -0.0
+ddbas019 toSci -00.00 -> -0.00
+
+ddbas021 toSci -1 -> -1
+ddbas022 toSci -1.0 -> -1.0
+ddbas023 toSci -0.1 -> -0.1
+ddbas024 toSci -9.1 -> -9.1
+ddbas025 toSci -9.11 -> -9.11
+ddbas026 toSci -9.119 -> -9.119
+ddbas027 toSci -9.999 -> -9.999
+
+ddbas030 toSci '123456789.123456' -> '123456789.123456'
+ddbas031 toSci '123456789.000000' -> '123456789.000000'
+ddbas032 toSci '123456789123456' -> '123456789123456'
+ddbas033 toSci '0.0000123456789' -> '0.0000123456789'
+ddbas034 toSci '0.00000123456789' -> '0.00000123456789'
+ddbas035 toSci '0.000000123456789' -> '1.23456789E-7'
+ddbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
+
+ddbas037 toSci '0.123456789012344' -> '0.123456789012344'
+ddbas038 toSci '0.123456789012345' -> '0.123456789012345'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+ddbsn001 toSci -9.999999999999999E+384 -> -9.999999999999999E+384
+ddbsn002 toSci -1E-383 -> -1E-383
+ddbsn003 toSci -1E-398 -> -1E-398 Subnormal
+ddbsn004 toSci -0 -> -0
+ddbsn005 toSci +0 -> 0
+ddbsn006 toSci +1E-398 -> 1E-398 Subnormal
+ddbsn007 toSci +1E-383 -> 1E-383
+ddbsn008 toSci +9.999999999999999E+384 -> 9.999999999999999E+384
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+ddbas040 toSci "12" -> '12'
+ddbas041 toSci "-76" -> '-76'
+ddbas042 toSci "12.76" -> '12.76'
+ddbas043 toSci "+12.76" -> '12.76'
+ddbas044 toSci "012.76" -> '12.76'
+ddbas045 toSci "+0.003" -> '0.003'
+ddbas046 toSci "17." -> '17'
+ddbas047 toSci ".5" -> '0.5'
+ddbas048 toSci "044" -> '44'
+ddbas049 toSci "0044" -> '44'
+ddbas050 toSci "0.0005" -> '0.0005'
+ddbas051 toSci "00.00005" -> '0.00005'
+ddbas052 toSci "0.000005" -> '0.000005'
+ddbas053 toSci "0.0000050" -> '0.0000050'
+ddbas054 toSci "0.0000005" -> '5E-7'
+ddbas055 toSci "0.00000005" -> '5E-8'
+ddbas056 toSci "12345678.543210" -> '12345678.543210'
+ddbas057 toSci "2345678.543210" -> '2345678.543210'
+ddbas058 toSci "345678.543210" -> '345678.543210'
+ddbas059 toSci "0345678.54321" -> '345678.54321'
+ddbas060 toSci "345678.5432" -> '345678.5432'
+ddbas061 toSci "+345678.5432" -> '345678.5432'
+ddbas062 toSci "+0345678.5432" -> '345678.5432'
+ddbas063 toSci "+00345678.5432" -> '345678.5432'
+ddbas064 toSci "-345678.5432" -> '-345678.5432'
+ddbas065 toSci "-0345678.5432" -> '-345678.5432'
+ddbas066 toSci "-00345678.5432" -> '-345678.5432'
+-- examples
+ddbas067 toSci "5E-6" -> '0.000005'
+ddbas068 toSci "50E-7" -> '0.0000050'
+ddbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+ddbas071 toSci .1234567890123456123 -> 0.1234567890123456 Inexact Rounded
+ddbas072 toSci 1.234567890123456123 -> 1.234567890123456 Inexact Rounded
+ddbas073 toSci 12.34567890123456123 -> 12.34567890123456 Inexact Rounded
+ddbas074 toSci 123.4567890123456123 -> 123.4567890123456 Inexact Rounded
+ddbas075 toSci 1234.567890123456123 -> 1234.567890123456 Inexact Rounded
+ddbas076 toSci 12345.67890123456123 -> 12345.67890123456 Inexact Rounded
+ddbas077 toSci 123456.7890123456123 -> 123456.7890123456 Inexact Rounded
+ddbas078 toSci 1234567.890123456123 -> 1234567.890123456 Inexact Rounded
+ddbas079 toSci 12345678.90123456123 -> 12345678.90123456 Inexact Rounded
+ddbas080 toSci 123456789.0123456123 -> 123456789.0123456 Inexact Rounded
+ddbas081 toSci 1234567890.123456123 -> 1234567890.123456 Inexact Rounded
+ddbas082 toSci 12345678901.23456123 -> 12345678901.23456 Inexact Rounded
+ddbas083 toSci 123456789012.3456123 -> 123456789012.3456 Inexact Rounded
+ddbas084 toSci 1234567890123.456123 -> 1234567890123.456 Inexact Rounded
+ddbas085 toSci 12345678901234.56123 -> 12345678901234.56 Inexact Rounded
+ddbas086 toSci 123456789012345.6123 -> 123456789012345.6 Inexact Rounded
+ddbas087 toSci 1234567890123456.123 -> 1234567890123456 Inexact Rounded
+ddbas088 toSci 12345678901234561.23 -> 1.234567890123456E+16 Inexact Rounded
+ddbas089 toSci 123456789012345612.3 -> 1.234567890123456E+17 Inexact Rounded
+ddbas090 toSci 1234567890123456123. -> 1.234567890123456E+18 Inexact Rounded
+
+
+-- Numbers with E
+ddbas130 toSci "0.000E-1" -> '0.0000'
+ddbas131 toSci "0.000E-2" -> '0.00000'
+ddbas132 toSci "0.000E-3" -> '0.000000'
+ddbas133 toSci "0.000E-4" -> '0E-7'
+ddbas134 toSci "0.00E-2" -> '0.0000'
+ddbas135 toSci "0.00E-3" -> '0.00000'
+ddbas136 toSci "0.00E-4" -> '0.000000'
+ddbas137 toSci "0.00E-5" -> '0E-7'
+ddbas138 toSci "+0E+9" -> '0E+9'
+ddbas139 toSci "-0E+9" -> '-0E+9'
+ddbas140 toSci "1E+9" -> '1E+9'
+ddbas141 toSci "1e+09" -> '1E+9'
+ddbas142 toSci "1E+90" -> '1E+90'
+ddbas143 toSci "+1E+009" -> '1E+9'
+ddbas144 toSci "0E+9" -> '0E+9'
+ddbas145 toSci "1E+9" -> '1E+9'
+ddbas146 toSci "1E+09" -> '1E+9'
+ddbas147 toSci "1e+90" -> '1E+90'
+ddbas148 toSci "1E+009" -> '1E+9'
+ddbas149 toSci "000E+9" -> '0E+9'
+ddbas150 toSci "1E9" -> '1E+9'
+ddbas151 toSci "1e09" -> '1E+9'
+ddbas152 toSci "1E90" -> '1E+90'
+ddbas153 toSci "1E009" -> '1E+9'
+ddbas154 toSci "0E9" -> '0E+9'
+ddbas155 toSci "0.000e+0" -> '0.000'
+ddbas156 toSci "0.000E-1" -> '0.0000'
+ddbas157 toSci "4E+9" -> '4E+9'
+ddbas158 toSci "44E+9" -> '4.4E+10'
+ddbas159 toSci "0.73e-7" -> '7.3E-8'
+ddbas160 toSci "00E+9" -> '0E+9'
+ddbas161 toSci "00E-9" -> '0E-9'
+ddbas162 toSci "10E+9" -> '1.0E+10'
+ddbas163 toSci "10E+09" -> '1.0E+10'
+ddbas164 toSci "10e+90" -> '1.0E+91'
+ddbas165 toSci "10E+009" -> '1.0E+10'
+ddbas166 toSci "100e+9" -> '1.00E+11'
+ddbas167 toSci "100e+09" -> '1.00E+11'
+ddbas168 toSci "100E+90" -> '1.00E+92'
+ddbas169 toSci "100e+009" -> '1.00E+11'
+
+ddbas170 toSci "1.265" -> '1.265'
+ddbas171 toSci "1.265E-20" -> '1.265E-20'
+ddbas172 toSci "1.265E-8" -> '1.265E-8'
+ddbas173 toSci "1.265E-4" -> '0.0001265'
+ddbas174 toSci "1.265E-3" -> '0.001265'
+ddbas175 toSci "1.265E-2" -> '0.01265'
+ddbas176 toSci "1.265E-1" -> '0.1265'
+ddbas177 toSci "1.265E-0" -> '1.265'
+ddbas178 toSci "1.265E+1" -> '12.65'
+ddbas179 toSci "1.265E+2" -> '126.5'
+ddbas180 toSci "1.265E+3" -> '1265'
+ddbas181 toSci "1.265E+4" -> '1.265E+4'
+ddbas182 toSci "1.265E+8" -> '1.265E+8'
+ddbas183 toSci "1.265E+20" -> '1.265E+20'
+
+ddbas190 toSci "12.65" -> '12.65'
+ddbas191 toSci "12.65E-20" -> '1.265E-19'
+ddbas192 toSci "12.65E-8" -> '1.265E-7'
+ddbas193 toSci "12.65E-4" -> '0.001265'
+ddbas194 toSci "12.65E-3" -> '0.01265'
+ddbas195 toSci "12.65E-2" -> '0.1265'
+ddbas196 toSci "12.65E-1" -> '1.265'
+ddbas197 toSci "12.65E-0" -> '12.65'
+ddbas198 toSci "12.65E+1" -> '126.5'
+ddbas199 toSci "12.65E+2" -> '1265'
+ddbas200 toSci "12.65E+3" -> '1.265E+4'
+ddbas201 toSci "12.65E+4" -> '1.265E+5'
+ddbas202 toSci "12.65E+8" -> '1.265E+9'
+ddbas203 toSci "12.65E+20" -> '1.265E+21'
+
+ddbas210 toSci "126.5" -> '126.5'
+ddbas211 toSci "126.5E-20" -> '1.265E-18'
+ddbas212 toSci "126.5E-8" -> '0.000001265'
+ddbas213 toSci "126.5E-4" -> '0.01265'
+ddbas214 toSci "126.5E-3" -> '0.1265'
+ddbas215 toSci "126.5E-2" -> '1.265'
+ddbas216 toSci "126.5E-1" -> '12.65'
+ddbas217 toSci "126.5E-0" -> '126.5'
+ddbas218 toSci "126.5E+1" -> '1265'
+ddbas219 toSci "126.5E+2" -> '1.265E+4'
+ddbas220 toSci "126.5E+3" -> '1.265E+5'
+ddbas221 toSci "126.5E+4" -> '1.265E+6'
+ddbas222 toSci "126.5E+8" -> '1.265E+10'
+ddbas223 toSci "126.5E+20" -> '1.265E+22'
+
+ddbas230 toSci "1265" -> '1265'
+ddbas231 toSci "1265E-20" -> '1.265E-17'
+ddbas232 toSci "1265E-8" -> '0.00001265'
+ddbas233 toSci "1265E-4" -> '0.1265'
+ddbas234 toSci "1265E-3" -> '1.265'
+ddbas235 toSci "1265E-2" -> '12.65'
+ddbas236 toSci "1265E-1" -> '126.5'
+ddbas237 toSci "1265E-0" -> '1265'
+ddbas238 toSci "1265E+1" -> '1.265E+4'
+ddbas239 toSci "1265E+2" -> '1.265E+5'
+ddbas240 toSci "1265E+3" -> '1.265E+6'
+ddbas241 toSci "1265E+4" -> '1.265E+7'
+ddbas242 toSci "1265E+8" -> '1.265E+11'
+ddbas243 toSci "1265E+20" -> '1.265E+23'
+ddbas244 toSci "1265E-9" -> '0.000001265'
+ddbas245 toSci "1265E-10" -> '1.265E-7'
+ddbas246 toSci "1265E-11" -> '1.265E-8'
+ddbas247 toSci "1265E-12" -> '1.265E-9'
+
+ddbas250 toSci "0.1265" -> '0.1265'
+ddbas251 toSci "0.1265E-20" -> '1.265E-21'
+ddbas252 toSci "0.1265E-8" -> '1.265E-9'
+ddbas253 toSci "0.1265E-4" -> '0.00001265'
+ddbas254 toSci "0.1265E-3" -> '0.0001265'
+ddbas255 toSci "0.1265E-2" -> '0.001265'
+ddbas256 toSci "0.1265E-1" -> '0.01265'
+ddbas257 toSci "0.1265E-0" -> '0.1265'
+ddbas258 toSci "0.1265E+1" -> '1.265'
+ddbas259 toSci "0.1265E+2" -> '12.65'
+ddbas260 toSci "0.1265E+3" -> '126.5'
+ddbas261 toSci "0.1265E+4" -> '1265'
+ddbas262 toSci "0.1265E+8" -> '1.265E+7'
+ddbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+ddbas290 toSci "-0.000E-1" -> '-0.0000'
+ddbas291 toSci "-0.000E-2" -> '-0.00000'
+ddbas292 toSci "-0.000E-3" -> '-0.000000'
+ddbas293 toSci "-0.000E-4" -> '-0E-7'
+ddbas294 toSci "-0.00E-2" -> '-0.0000'
+ddbas295 toSci "-0.00E-3" -> '-0.00000'
+ddbas296 toSci "-0.0E-2" -> '-0.000'
+ddbas297 toSci "-0.0E-3" -> '-0.0000'
+ddbas298 toSci "-0E-2" -> '-0.00'
+ddbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+ddbas301 toSci 10e12 -> 1.0E+13
+ddbas302 toEng 10e12 -> 10E+12
+ddbas303 toSci 10e11 -> 1.0E+12
+ddbas304 toEng 10e11 -> 1.0E+12
+ddbas305 toSci 10e10 -> 1.0E+11
+ddbas306 toEng 10e10 -> 100E+9
+ddbas307 toSci 10e9 -> 1.0E+10
+ddbas308 toEng 10e9 -> 10E+9
+ddbas309 toSci 10e8 -> 1.0E+9
+ddbas310 toEng 10e8 -> 1.0E+9
+ddbas311 toSci 10e7 -> 1.0E+8
+ddbas312 toEng 10e7 -> 100E+6
+ddbas313 toSci 10e6 -> 1.0E+7
+ddbas314 toEng 10e6 -> 10E+6
+ddbas315 toSci 10e5 -> 1.0E+6
+ddbas316 toEng 10e5 -> 1.0E+6
+ddbas317 toSci 10e4 -> 1.0E+5
+ddbas318 toEng 10e4 -> 100E+3
+ddbas319 toSci 10e3 -> 1.0E+4
+ddbas320 toEng 10e3 -> 10E+3
+ddbas321 toSci 10e2 -> 1.0E+3
+ddbas322 toEng 10e2 -> 1.0E+3
+ddbas323 toSci 10e1 -> 1.0E+2
+ddbas324 toEng 10e1 -> 100
+ddbas325 toSci 10e0 -> 10
+ddbas326 toEng 10e0 -> 10
+ddbas327 toSci 10e-1 -> 1.0
+ddbas328 toEng 10e-1 -> 1.0
+ddbas329 toSci 10e-2 -> 0.10
+ddbas330 toEng 10e-2 -> 0.10
+ddbas331 toSci 10e-3 -> 0.010
+ddbas332 toEng 10e-3 -> 0.010
+ddbas333 toSci 10e-4 -> 0.0010
+ddbas334 toEng 10e-4 -> 0.0010
+ddbas335 toSci 10e-5 -> 0.00010
+ddbas336 toEng 10e-5 -> 0.00010
+ddbas337 toSci 10e-6 -> 0.000010
+ddbas338 toEng 10e-6 -> 0.000010
+ddbas339 toSci 10e-7 -> 0.0000010
+ddbas340 toEng 10e-7 -> 0.0000010
+ddbas341 toSci 10e-8 -> 1.0E-7
+ddbas342 toEng 10e-8 -> 100E-9
+ddbas343 toSci 10e-9 -> 1.0E-8
+ddbas344 toEng 10e-9 -> 10E-9
+ddbas345 toSci 10e-10 -> 1.0E-9
+ddbas346 toEng 10e-10 -> 1.0E-9
+ddbas347 toSci 10e-11 -> 1.0E-10
+ddbas348 toEng 10e-11 -> 100E-12
+ddbas349 toSci 10e-12 -> 1.0E-11
+ddbas350 toEng 10e-12 -> 10E-12
+ddbas351 toSci 10e-13 -> 1.0E-12
+ddbas352 toEng 10e-13 -> 1.0E-12
+
+ddbas361 toSci 7E12 -> 7E+12
+ddbas362 toEng 7E12 -> 7E+12
+ddbas363 toSci 7E11 -> 7E+11
+ddbas364 toEng 7E11 -> 700E+9
+ddbas365 toSci 7E10 -> 7E+10
+ddbas366 toEng 7E10 -> 70E+9
+ddbas367 toSci 7E9 -> 7E+9
+ddbas368 toEng 7E9 -> 7E+9
+ddbas369 toSci 7E8 -> 7E+8
+ddbas370 toEng 7E8 -> 700E+6
+ddbas371 toSci 7E7 -> 7E+7
+ddbas372 toEng 7E7 -> 70E+6
+ddbas373 toSci 7E6 -> 7E+6
+ddbas374 toEng 7E6 -> 7E+6
+ddbas375 toSci 7E5 -> 7E+5
+ddbas376 toEng 7E5 -> 700E+3
+ddbas377 toSci 7E4 -> 7E+4
+ddbas378 toEng 7E4 -> 70E+3
+ddbas379 toSci 7E3 -> 7E+3
+ddbas380 toEng 7E3 -> 7E+3
+ddbas381 toSci 7E2 -> 7E+2
+ddbas382 toEng 7E2 -> 700
+ddbas383 toSci 7E1 -> 7E+1
+ddbas384 toEng 7E1 -> 70
+ddbas385 toSci 7E0 -> 7
+ddbas386 toEng 7E0 -> 7
+ddbas387 toSci 7E-1 -> 0.7
+ddbas388 toEng 7E-1 -> 0.7
+ddbas389 toSci 7E-2 -> 0.07
+ddbas390 toEng 7E-2 -> 0.07
+ddbas391 toSci 7E-3 -> 0.007
+ddbas392 toEng 7E-3 -> 0.007
+ddbas393 toSci 7E-4 -> 0.0007
+ddbas394 toEng 7E-4 -> 0.0007
+ddbas395 toSci 7E-5 -> 0.00007
+ddbas396 toEng 7E-5 -> 0.00007
+ddbas397 toSci 7E-6 -> 0.000007
+ddbas398 toEng 7E-6 -> 0.000007
+ddbas399 toSci 7E-7 -> 7E-7
+ddbas400 toEng 7E-7 -> 700E-9
+ddbas401 toSci 7E-8 -> 7E-8
+ddbas402 toEng 7E-8 -> 70E-9
+ddbas403 toSci 7E-9 -> 7E-9
+ddbas404 toEng 7E-9 -> 7E-9
+ddbas405 toSci 7E-10 -> 7E-10
+ddbas406 toEng 7E-10 -> 700E-12
+ddbas407 toSci 7E-11 -> 7E-11
+ddbas408 toEng 7E-11 -> 70E-12
+ddbas409 toSci 7E-12 -> 7E-12
+ddbas410 toEng 7E-12 -> 7E-12
+ddbas411 toSci 7E-13 -> 7E-13
+ddbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+rounding: half_up
+ddbas420 toSci 100 -> 100
+ddbas421 toEng 100 -> 100
+ddbas422 toSci 1000 -> 1000
+ddbas423 toEng 1000 -> 1000
+ddbas424 toSci 999.9 -> 999.9
+ddbas425 toEng 999.9 -> 999.9
+ddbas426 toSci 1000.0 -> 1000.0
+ddbas427 toEng 1000.0 -> 1000.0
+ddbas428 toSci 1000.1 -> 1000.1
+ddbas429 toEng 1000.1 -> 1000.1
+ddbas430 toSci 10000 -> 10000
+ddbas431 toEng 10000 -> 10000
+ddbas432 toSci 100000 -> 100000
+ddbas433 toEng 100000 -> 100000
+ddbas434 toSci 1000000 -> 1000000
+ddbas435 toEng 1000000 -> 1000000
+ddbas436 toSci 10000000 -> 10000000
+ddbas437 toEng 10000000 -> 10000000
+ddbas438 toSci 100000000 -> 100000000
+ddbas439 toEng 1000000000000000 -> 1000000000000000
+ddbas440 toSci 10000000000000000 -> 1.000000000000000E+16 Rounded
+ddbas441 toEng 10000000000000000 -> 10.00000000000000E+15 Rounded
+ddbas442 toSci 10000000000000001 -> 1.000000000000000E+16 Rounded Inexact
+ddbas443 toEng 10000000000000001 -> 10.00000000000000E+15 Rounded Inexact
+ddbas444 toSci 10000000000000003 -> 1.000000000000000E+16 Rounded Inexact
+ddbas445 toEng 10000000000000003 -> 10.00000000000000E+15 Rounded Inexact
+ddbas446 toSci 10000000000000005 -> 1.000000000000001E+16 Rounded Inexact
+ddbas447 toEng 10000000000000005 -> 10.00000000000001E+15 Rounded Inexact
+ddbas448 toSci 100000000000000050 -> 1.000000000000001E+17 Rounded Inexact
+ddbas449 toEng 100000000000000050 -> 100.0000000000001E+15 Rounded Inexact
+ddbas450 toSci 10000000000000009 -> 1.000000000000001E+16 Rounded Inexact
+ddbas451 toEng 10000000000000009 -> 10.00000000000001E+15 Rounded Inexact
+ddbas452 toSci 100000000000000000 -> 1.000000000000000E+17 Rounded
+ddbas453 toEng 100000000000000000 -> 100.0000000000000E+15 Rounded
+ddbas454 toSci 100000000000000003 -> 1.000000000000000E+17 Rounded Inexact
+ddbas455 toEng 100000000000000003 -> 100.0000000000000E+15 Rounded Inexact
+ddbas456 toSci 100000000000000005 -> 1.000000000000000E+17 Rounded Inexact
+ddbas457 toEng 100000000000000005 -> 100.0000000000000E+15 Rounded Inexact
+ddbas458 toSci 100000000000000009 -> 1.000000000000000E+17 Rounded Inexact
+ddbas459 toEng 100000000000000009 -> 100.0000000000000E+15 Rounded Inexact
+ddbas460 toSci 1000000000000000000 -> 1.000000000000000E+18 Rounded
+ddbas461 toEng 1000000000000000000 -> 1.000000000000000E+18 Rounded
+ddbas462 toSci 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
+ddbas463 toEng 1000000000000000300 -> 1.000000000000000E+18 Rounded Inexact
+ddbas464 toSci 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
+ddbas465 toEng 1000000000000000500 -> 1.000000000000001E+18 Rounded Inexact
+ddbas466 toSci 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
+ddbas467 toEng 1000000000000000900 -> 1.000000000000001E+18 Rounded Inexact
+ddbas468 toSci 10000000000000000000 -> 1.000000000000000E+19 Rounded
+ddbas469 toEng 10000000000000000000 -> 10.00000000000000E+18 Rounded
+ddbas470 toSci 10000000000000003000 -> 1.000000000000000E+19 Rounded Inexact
+ddbas471 toEng 10000000000000003000 -> 10.00000000000000E+18 Rounded Inexact
+ddbas472 toSci 10000000000000005000 -> 1.000000000000001E+19 Rounded Inexact
+ddbas473 toEng 10000000000000005000 -> 10.00000000000001E+18 Rounded Inexact
+ddbas474 toSci 10000000000000009000 -> 1.000000000000001E+19 Rounded Inexact
+ddbas475 toEng 10000000000000009000 -> 10.00000000000001E+18 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+ddbsr401 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr402 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
+ddbsr403 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr404 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: up
+ddbsr405 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr406 toSci 1.11111111111234549 -> 1.111111111112346 Rounded Inexact
+ddbsr407 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr408 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: floor
+ddbsr410 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr411 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr412 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr413 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
+rounding: half_down
+ddbsr415 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr416 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr417 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr418 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
+ddbsr419 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: half_even
+ddbsr421 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr422 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr423 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr424 toSci 1.11111111111234650 -> 1.111111111112346 Rounded Inexact
+ddbsr425 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+rounding: down
+ddbsr426 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr427 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr428 toSci 1.11111111111234550 -> 1.111111111112345 Rounded Inexact
+ddbsr429 toSci 1.11111111111234551 -> 1.111111111112345 Rounded Inexact
+rounding: half_up
+ddbsr431 toSci 1.1111111111123450 -> 1.111111111112345 Rounded
+ddbsr432 toSci 1.11111111111234549 -> 1.111111111112345 Rounded Inexact
+ddbsr433 toSci 1.11111111111234550 -> 1.111111111112346 Rounded Inexact
+ddbsr434 toSci 1.11111111111234650 -> 1.111111111112347 Rounded Inexact
+ddbsr435 toSci 1.11111111111234551 -> 1.111111111112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+ddbsr501 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr502 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr503 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr504 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
+rounding: up
+ddbsr505 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr506 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
+ddbsr507 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr508 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: floor
+ddbsr510 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr511 toSci -1.11111111111234549 -> -1.111111111112346 Rounded Inexact
+ddbsr512 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr513 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: half_down
+ddbsr515 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr516 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr517 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr518 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
+ddbsr519 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: half_even
+ddbsr521 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr522 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr523 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr524 toSci -1.11111111111234650 -> -1.111111111112346 Rounded Inexact
+ddbsr525 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+rounding: down
+ddbsr526 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr527 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr528 toSci -1.11111111111234550 -> -1.111111111112345 Rounded Inexact
+ddbsr529 toSci -1.11111111111234551 -> -1.111111111112345 Rounded Inexact
+rounding: half_up
+ddbsr531 toSci -1.1111111111123450 -> -1.111111111112345 Rounded
+ddbsr532 toSci -1.11111111111234549 -> -1.111111111112345 Rounded Inexact
+ddbsr533 toSci -1.11111111111234550 -> -1.111111111112346 Rounded Inexact
+ddbsr534 toSci -1.11111111111234650 -> -1.111111111112347 Rounded Inexact
+ddbsr535 toSci -1.11111111111234551 -> -1.111111111112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+ddbas500 toSci '1..2' -> NaN Conversion_syntax
+ddbas501 toSci '.' -> NaN Conversion_syntax
+ddbas502 toSci '..' -> NaN Conversion_syntax
+ddbas503 toSci '++1' -> NaN Conversion_syntax
+ddbas504 toSci '--1' -> NaN Conversion_syntax
+ddbas505 toSci '-+1' -> NaN Conversion_syntax
+ddbas506 toSci '+-1' -> NaN Conversion_syntax
+ddbas507 toSci '12e' -> NaN Conversion_syntax
+ddbas508 toSci '12e++' -> NaN Conversion_syntax
+ddbas509 toSci '12f4' -> NaN Conversion_syntax
+ddbas510 toSci ' +1' -> NaN Conversion_syntax
+ddbas511 toSci '+ 1' -> NaN Conversion_syntax
+ddbas512 toSci '12 ' -> NaN Conversion_syntax
+ddbas513 toSci ' + 1' -> NaN Conversion_syntax
+ddbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+ddbas515 toSci 'x' -> NaN Conversion_syntax
+ddbas516 toSci '-1-' -> NaN Conversion_syntax
+ddbas517 toSci '12-' -> NaN Conversion_syntax
+ddbas518 toSci '3+' -> NaN Conversion_syntax
+ddbas519 toSci '' -> NaN Conversion_syntax
+ddbas520 toSci '1e-' -> NaN Conversion_syntax
+ddbas521 toSci '7e99999a' -> NaN Conversion_syntax
+ddbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+ddbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+ddbas524 toSci '' -> NaN Conversion_syntax
+ddbas525 toSci 'e100' -> NaN Conversion_syntax
+ddbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+ddbas527 toSci '\u0b65' -> NaN Conversion_syntax
+ddbas528 toSci '123,65' -> NaN Conversion_syntax
+ddbas529 toSci '1.34.5' -> NaN Conversion_syntax
+ddbas530 toSci '.123.5' -> NaN Conversion_syntax
+ddbas531 toSci '01.35.' -> NaN Conversion_syntax
+ddbas532 toSci '01.35-' -> NaN Conversion_syntax
+ddbas533 toSci '0000..' -> NaN Conversion_syntax
+ddbas534 toSci '.0000.' -> NaN Conversion_syntax
+ddbas535 toSci '00..00' -> NaN Conversion_syntax
+ddbas536 toSci '111e*123' -> NaN Conversion_syntax
+ddbas537 toSci '111e123-' -> NaN Conversion_syntax
+ddbas538 toSci '111e+12+' -> NaN Conversion_syntax
+ddbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+ddbas540 toSci '111e1*23' -> NaN Conversion_syntax
+ddbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+ddbas542 toSci '1e1.0' -> NaN Conversion_syntax
+ddbas543 toSci '1e123e' -> NaN Conversion_syntax
+ddbas544 toSci 'ten' -> NaN Conversion_syntax
+ddbas545 toSci 'ONE' -> NaN Conversion_syntax
+ddbas546 toSci '1e.1' -> NaN Conversion_syntax
+ddbas547 toSci '1e1.' -> NaN Conversion_syntax
+ddbas548 toSci '1ee' -> NaN Conversion_syntax
+ddbas549 toSci 'e+1' -> NaN Conversion_syntax
+ddbas550 toSci '1.23.4' -> NaN Conversion_syntax
+ddbas551 toSci '1.2.1' -> NaN Conversion_syntax
+ddbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+ddbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+ddbas554 toSci '1E++1' -> NaN Conversion_syntax
+ddbas555 toSci '1E--1' -> NaN Conversion_syntax
+ddbas556 toSci '1E+-1' -> NaN Conversion_syntax
+ddbas557 toSci '1E-+1' -> NaN Conversion_syntax
+ddbas558 toSci '1E''1' -> NaN Conversion_syntax
+ddbas559 toSci "1E""1" -> NaN Conversion_syntax
+ddbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+ddbas561 toSci "qNaN" -> NaN Conversion_syntax
+ddbas562 toSci "NaNq" -> NaN Conversion_syntax
+ddbas563 toSci "NaNs" -> NaN Conversion_syntax
+ddbas564 toSci "Infi" -> NaN Conversion_syntax
+ddbas565 toSci "Infin" -> NaN Conversion_syntax
+ddbas566 toSci "Infini" -> NaN Conversion_syntax
+ddbas567 toSci "Infinit" -> NaN Conversion_syntax
+ddbas568 toSci "-Infinit" -> NaN Conversion_syntax
+ddbas569 toSci "0Inf" -> NaN Conversion_syntax
+ddbas570 toSci "9Inf" -> NaN Conversion_syntax
+ddbas571 toSci "-0Inf" -> NaN Conversion_syntax
+ddbas572 toSci "-9Inf" -> NaN Conversion_syntax
+ddbas573 toSci "-sNa" -> NaN Conversion_syntax
+ddbas574 toSci "xNaN" -> NaN Conversion_syntax
+ddbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+ddbas576 toSci 'e+1' -> NaN Conversion_syntax
+ddbas577 toSci '.e+1' -> NaN Conversion_syntax
+ddbas578 toSci '+.e+1' -> NaN Conversion_syntax
+ddbas579 toSci '-.e+' -> NaN Conversion_syntax
+ddbas580 toSci '-.e' -> NaN Conversion_syntax
+ddbas581 toSci 'E+1' -> NaN Conversion_syntax
+ddbas582 toSci '.E+1' -> NaN Conversion_syntax
+ddbas583 toSci '+.E+1' -> NaN Conversion_syntax
+ddbas584 toSci '-.E+' -> NaN Conversion_syntax
+ddbas585 toSci '-.E' -> NaN Conversion_syntax
+
+ddbas586 toSci '.NaN' -> NaN Conversion_syntax
+ddbas587 toSci '-.NaN' -> NaN Conversion_syntax
+ddbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+ddbas589 toSci '+.Inf' -> NaN Conversion_syntax
+ddbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+ddbas601 toSci 0.000000000 -> 0E-9
+ddbas602 toSci 0.00000000 -> 0E-8
+ddbas603 toSci 0.0000000 -> 0E-7
+ddbas604 toSci 0.000000 -> 0.000000
+ddbas605 toSci 0.00000 -> 0.00000
+ddbas606 toSci 0.0000 -> 0.0000
+ddbas607 toSci 0.000 -> 0.000
+ddbas608 toSci 0.00 -> 0.00
+ddbas609 toSci 0.0 -> 0.0
+ddbas610 toSci .0 -> 0.0
+ddbas611 toSci 0. -> 0
+ddbas612 toSci -.0 -> -0.0
+ddbas613 toSci -0. -> -0
+ddbas614 toSci -0.0 -> -0.0
+ddbas615 toSci -0.00 -> -0.00
+ddbas616 toSci -0.000 -> -0.000
+ddbas617 toSci -0.0000 -> -0.0000
+ddbas618 toSci -0.00000 -> -0.00000
+ddbas619 toSci -0.000000 -> -0.000000
+ddbas620 toSci -0.0000000 -> -0E-7
+ddbas621 toSci -0.00000000 -> -0E-8
+ddbas622 toSci -0.000000000 -> -0E-9
+
+ddbas630 toSci 0.00E+0 -> 0.00
+ddbas631 toSci 0.00E+1 -> 0.0
+ddbas632 toSci 0.00E+2 -> 0
+ddbas633 toSci 0.00E+3 -> 0E+1
+ddbas634 toSci 0.00E+4 -> 0E+2
+ddbas635 toSci 0.00E+5 -> 0E+3
+ddbas636 toSci 0.00E+6 -> 0E+4
+ddbas637 toSci 0.00E+7 -> 0E+5
+ddbas638 toSci 0.00E+8 -> 0E+6
+ddbas639 toSci 0.00E+9 -> 0E+7
+
+ddbas640 toSci 0.0E+0 -> 0.0
+ddbas641 toSci 0.0E+1 -> 0
+ddbas642 toSci 0.0E+2 -> 0E+1
+ddbas643 toSci 0.0E+3 -> 0E+2
+ddbas644 toSci 0.0E+4 -> 0E+3
+ddbas645 toSci 0.0E+5 -> 0E+4
+ddbas646 toSci 0.0E+6 -> 0E+5
+ddbas647 toSci 0.0E+7 -> 0E+6
+ddbas648 toSci 0.0E+8 -> 0E+7
+ddbas649 toSci 0.0E+9 -> 0E+8
+
+ddbas650 toSci 0E+0 -> 0
+ddbas651 toSci 0E+1 -> 0E+1
+ddbas652 toSci 0E+2 -> 0E+2
+ddbas653 toSci 0E+3 -> 0E+3
+ddbas654 toSci 0E+4 -> 0E+4
+ddbas655 toSci 0E+5 -> 0E+5
+ddbas656 toSci 0E+6 -> 0E+6
+ddbas657 toSci 0E+7 -> 0E+7
+ddbas658 toSci 0E+8 -> 0E+8
+ddbas659 toSci 0E+9 -> 0E+9
+
+ddbas660 toSci 0.0E-0 -> 0.0
+ddbas661 toSci 0.0E-1 -> 0.00
+ddbas662 toSci 0.0E-2 -> 0.000
+ddbas663 toSci 0.0E-3 -> 0.0000
+ddbas664 toSci 0.0E-4 -> 0.00000
+ddbas665 toSci 0.0E-5 -> 0.000000
+ddbas666 toSci 0.0E-6 -> 0E-7
+ddbas667 toSci 0.0E-7 -> 0E-8
+ddbas668 toSci 0.0E-8 -> 0E-9
+ddbas669 toSci 0.0E-9 -> 0E-10
+
+ddbas670 toSci 0.00E-0 -> 0.00
+ddbas671 toSci 0.00E-1 -> 0.000
+ddbas672 toSci 0.00E-2 -> 0.0000
+ddbas673 toSci 0.00E-3 -> 0.00000
+ddbas674 toSci 0.00E-4 -> 0.000000
+ddbas675 toSci 0.00E-5 -> 0E-7
+ddbas676 toSci 0.00E-6 -> 0E-8
+ddbas677 toSci 0.00E-7 -> 0E-9
+ddbas678 toSci 0.00E-8 -> 0E-10
+ddbas679 toSci 0.00E-9 -> 0E-11
+
+ddbas680 toSci 000000. -> 0
+ddbas681 toSci 00000. -> 0
+ddbas682 toSci 0000. -> 0
+ddbas683 toSci 000. -> 0
+ddbas684 toSci 00. -> 0
+ddbas685 toSci 0. -> 0
+ddbas686 toSci +00000. -> 0
+ddbas687 toSci -00000. -> -0
+ddbas688 toSci +0. -> 0
+ddbas689 toSci -0. -> -0
+
+-- Specials
+ddbas700 toSci "NaN" -> NaN
+ddbas701 toSci "nan" -> NaN
+ddbas702 toSci "nAn" -> NaN
+ddbas703 toSci "NAN" -> NaN
+ddbas704 toSci "+NaN" -> NaN
+ddbas705 toSci "+nan" -> NaN
+ddbas706 toSci "+nAn" -> NaN
+ddbas707 toSci "+NAN" -> NaN
+ddbas708 toSci "-NaN" -> -NaN
+ddbas709 toSci "-nan" -> -NaN
+ddbas710 toSci "-nAn" -> -NaN
+ddbas711 toSci "-NAN" -> -NaN
+ddbas712 toSci 'NaN0' -> NaN
+ddbas713 toSci 'NaN1' -> NaN1
+ddbas714 toSci 'NaN12' -> NaN12
+ddbas715 toSci 'NaN123' -> NaN123
+ddbas716 toSci 'NaN1234' -> NaN1234
+ddbas717 toSci 'NaN01' -> NaN1
+ddbas718 toSci 'NaN012' -> NaN12
+ddbas719 toSci 'NaN0123' -> NaN123
+ddbas720 toSci 'NaN01234' -> NaN1234
+ddbas721 toSci 'NaN001' -> NaN1
+ddbas722 toSci 'NaN0012' -> NaN12
+ddbas723 toSci 'NaN00123' -> NaN123
+ddbas724 toSci 'NaN001234' -> NaN1234
+ddbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
+ddbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+ddbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+ddbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+ddbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+ddbas730 toSci "sNaN" -> sNaN
+ddbas731 toSci "snan" -> sNaN
+ddbas732 toSci "SnAn" -> sNaN
+ddbas733 toSci "SNAN" -> sNaN
+ddbas734 toSci "+sNaN" -> sNaN
+ddbas735 toSci "+snan" -> sNaN
+ddbas736 toSci "+SnAn" -> sNaN
+ddbas737 toSci "+SNAN" -> sNaN
+ddbas738 toSci "-sNaN" -> -sNaN
+ddbas739 toSci "-snan" -> -sNaN
+ddbas740 toSci "-SnAn" -> -sNaN
+ddbas741 toSci "-SNAN" -> -sNaN
+ddbas742 toSci 'sNaN0000' -> sNaN
+ddbas743 toSci 'sNaN7' -> sNaN7
+ddbas744 toSci 'sNaN007234' -> sNaN7234
+ddbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
+ddbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+ddbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+ddbas748 toSci "Inf" -> Infinity
+ddbas749 toSci "inf" -> Infinity
+ddbas750 toSci "iNf" -> Infinity
+ddbas751 toSci "INF" -> Infinity
+ddbas752 toSci "+Inf" -> Infinity
+ddbas753 toSci "+inf" -> Infinity
+ddbas754 toSci "+iNf" -> Infinity
+ddbas755 toSci "+INF" -> Infinity
+ddbas756 toSci "-Inf" -> -Infinity
+ddbas757 toSci "-inf" -> -Infinity
+ddbas758 toSci "-iNf" -> -Infinity
+ddbas759 toSci "-INF" -> -Infinity
+
+ddbas760 toSci "Infinity" -> Infinity
+ddbas761 toSci "infinity" -> Infinity
+ddbas762 toSci "iNfInItY" -> Infinity
+ddbas763 toSci "INFINITY" -> Infinity
+ddbas764 toSci "+Infinity" -> Infinity
+ddbas765 toSci "+infinity" -> Infinity
+ddbas766 toSci "+iNfInItY" -> Infinity
+ddbas767 toSci "+INFINITY" -> Infinity
+ddbas768 toSci "-Infinity" -> -Infinity
+ddbas769 toSci "-infinity" -> -Infinity
+ddbas770 toSci "-iNfInItY" -> -Infinity
+ddbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+ddbast772 toEng "NaN" -> NaN
+ddbast773 toEng "-Infinity" -> -Infinity
+ddbast774 toEng "-sNaN" -> -sNaN
+ddbast775 toEng "-NaN" -> -NaN
+ddbast776 toEng "+Infinity" -> Infinity
+ddbast778 toEng "+sNaN" -> sNaN
+ddbast779 toEng "+NaN" -> NaN
+ddbast780 toEng "INFINITY" -> Infinity
+ddbast781 toEng "SNAN" -> sNaN
+ddbast782 toEng "NAN" -> NaN
+ddbast783 toEng "infinity" -> Infinity
+ddbast784 toEng "snan" -> sNaN
+ddbast785 toEng "nan" -> NaN
+ddbast786 toEng "InFINITY" -> Infinity
+ddbast787 toEng "SnAN" -> sNaN
+ddbast788 toEng "nAN" -> NaN
+ddbast789 toEng "iNfinity" -> Infinity
+ddbast790 toEng "sNan" -> sNaN
+ddbast791 toEng "Nan" -> NaN
+ddbast792 toEng "Infinity" -> Infinity
+ddbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+ddbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+ddbast801 toEng 0.000000000 -> 0E-9
+ddbast802 toEng 0.00000000 -> 0.00E-6
+ddbast803 toEng 0.0000000 -> 0.0E-6
+ddbast804 toEng 0.000000 -> 0.000000
+ddbast805 toEng 0.00000 -> 0.00000
+ddbast806 toEng 0.0000 -> 0.0000
+ddbast807 toEng 0.000 -> 0.000
+ddbast808 toEng 0.00 -> 0.00
+ddbast809 toEng 0.0 -> 0.0
+ddbast810 toEng .0 -> 0.0
+ddbast811 toEng 0. -> 0
+ddbast812 toEng -.0 -> -0.0
+ddbast813 toEng -0. -> -0
+ddbast814 toEng -0.0 -> -0.0
+ddbast815 toEng -0.00 -> -0.00
+ddbast816 toEng -0.000 -> -0.000
+ddbast817 toEng -0.0000 -> -0.0000
+ddbast818 toEng -0.00000 -> -0.00000
+ddbast819 toEng -0.000000 -> -0.000000
+ddbast820 toEng -0.0000000 -> -0.0E-6
+ddbast821 toEng -0.00000000 -> -0.00E-6
+ddbast822 toEng -0.000000000 -> -0E-9
+
+ddbast830 toEng 0.00E+0 -> 0.00
+ddbast831 toEng 0.00E+1 -> 0.0
+ddbast832 toEng 0.00E+2 -> 0
+ddbast833 toEng 0.00E+3 -> 0.00E+3
+ddbast834 toEng 0.00E+4 -> 0.0E+3
+ddbast835 toEng 0.00E+5 -> 0E+3
+ddbast836 toEng 0.00E+6 -> 0.00E+6
+ddbast837 toEng 0.00E+7 -> 0.0E+6
+ddbast838 toEng 0.00E+8 -> 0E+6
+ddbast839 toEng 0.00E+9 -> 0.00E+9
+
+ddbast840 toEng 0.0E+0 -> 0.0
+ddbast841 toEng 0.0E+1 -> 0
+ddbast842 toEng 0.0E+2 -> 0.00E+3
+ddbast843 toEng 0.0E+3 -> 0.0E+3
+ddbast844 toEng 0.0E+4 -> 0E+3
+ddbast845 toEng 0.0E+5 -> 0.00E+6
+ddbast846 toEng 0.0E+6 -> 0.0E+6
+ddbast847 toEng 0.0E+7 -> 0E+6
+ddbast848 toEng 0.0E+8 -> 0.00E+9
+ddbast849 toEng 0.0E+9 -> 0.0E+9
+
+ddbast850 toEng 0E+0 -> 0
+ddbast851 toEng 0E+1 -> 0.00E+3
+ddbast852 toEng 0E+2 -> 0.0E+3
+ddbast853 toEng 0E+3 -> 0E+3
+ddbast854 toEng 0E+4 -> 0.00E+6
+ddbast855 toEng 0E+5 -> 0.0E+6
+ddbast856 toEng 0E+6 -> 0E+6
+ddbast857 toEng 0E+7 -> 0.00E+9
+ddbast858 toEng 0E+8 -> 0.0E+9
+ddbast859 toEng 0E+9 -> 0E+9
+
+ddbast860 toEng 0.0E-0 -> 0.0
+ddbast861 toEng 0.0E-1 -> 0.00
+ddbast862 toEng 0.0E-2 -> 0.000
+ddbast863 toEng 0.0E-3 -> 0.0000
+ddbast864 toEng 0.0E-4 -> 0.00000
+ddbast865 toEng 0.0E-5 -> 0.000000
+ddbast866 toEng 0.0E-6 -> 0.0E-6
+ddbast867 toEng 0.0E-7 -> 0.00E-6
+ddbast868 toEng 0.0E-8 -> 0E-9
+ddbast869 toEng 0.0E-9 -> 0.0E-9
+
+ddbast870 toEng 0.00E-0 -> 0.00
+ddbast871 toEng 0.00E-1 -> 0.000
+ddbast872 toEng 0.00E-2 -> 0.0000
+ddbast873 toEng 0.00E-3 -> 0.00000
+ddbast874 toEng 0.00E-4 -> 0.000000
+ddbast875 toEng 0.00E-5 -> 0.0E-6
+ddbast876 toEng 0.00E-6 -> 0.00E-6
+ddbast877 toEng 0.00E-7 -> 0E-9
+ddbast878 toEng 0.00E-8 -> 0.0E-9
+ddbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+ddbas801 tosci '01234567890123456' -> 1234567890123456
+ddbas802 tosci '001234567890123456' -> 1234567890123456
+ddbas803 tosci '0001234567890123456' -> 1234567890123456
+ddbas804 tosci '00001234567890123456' -> 1234567890123456
+ddbas805 tosci '000001234567890123456' -> 1234567890123456
+ddbas806 tosci '0000001234567890123456' -> 1234567890123456
+ddbas807 tosci '00000001234567890123456' -> 1234567890123456
+ddbas808 tosci '000000001234567890123456' -> 1234567890123456
+ddbas809 tosci '0000000001234567890123456' -> 1234567890123456
+ddbas810 tosci '00000000001234567890123456' -> 1234567890123456
+
+ddbas811 tosci '0.1234567890123456' -> 0.1234567890123456
+ddbas812 tosci '0.01234567890123456' -> 0.01234567890123456
+ddbas813 tosci '0.001234567890123456' -> 0.001234567890123456
+ddbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
+ddbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
+ddbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
+ddbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
+ddbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
+ddbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
+ddbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
+
+ddbas821 tosci '12345678901234567890' -> 1.234567890123457E+19 Inexact Rounded
+ddbas822 tosci '123456789012345678901' -> 1.234567890123457E+20 Inexact Rounded
+ddbas823 tosci '1234567890123456789012' -> 1.234567890123457E+21 Inexact Rounded
+ddbas824 tosci '12345678901234567890123' -> 1.234567890123457E+22 Inexact Rounded
+ddbas825 tosci '123456789012345678901234' -> 1.234567890123457E+23 Inexact Rounded
+ddbas826 tosci '1234567890123456789012345' -> 1.234567890123457E+24 Inexact Rounded
+ddbas827 tosci '12345678901234567890123456' -> 1.234567890123457E+25 Inexact Rounded
+ddbas828 tosci '123456789012345678901234567' -> 1.234567890123457E+26 Inexact Rounded
+ddbas829 tosci '1234567890123456789012345678' -> 1.234567890123457E+27 Inexact Rounded
+
+-- subnormals and overflows
+ddbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+ddbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+ddbas908 toSci '0.9e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas909 toSci '0.09e-999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+ddbas911 toSci '10e-1000000000' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+ddbas913 toSci '99e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+ddbas915 toSci '1111e-9999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas916 toSci '1111e-99999999999' -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+ddbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+ddbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+ddbas920 toSci '-0.9e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas921 toSci '-0.09e-999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+ddbas923 toSci '-10e-1000000000' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+ddbas925 toSci '-99e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+ddbas927 toSci '-1111e-9999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas928 toSci '-1111e-99999999999' -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+ddbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas931 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
+rounding: up
+ddbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+ddbas934 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddbas935 toSci '-7e10000' -> -9.999999999999999E+384 Overflow Inexact Rounded
+rounding: floor
+ddbas936 toSci '7e10000' -> 9.999999999999999E+384 Overflow Inexact Rounded
+ddbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+ddbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+ddbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+ddbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+ddbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+ddbem400 toSci 1.0000E-383 -> 1.0000E-383
+ddbem401 toSci 0.1E-394 -> 1E-395 Subnormal
+ddbem402 toSci 0.1000E-394 -> 1.000E-395 Subnormal
+ddbem403 toSci 0.0100E-394 -> 1.00E-396 Subnormal
+ddbem404 toSci 0.0010E-394 -> 1.0E-397 Subnormal
+ddbem405 toSci 0.0001E-394 -> 1E-398 Subnormal
+ddbem406 toSci 0.00010E-394 -> 1E-398 Subnormal Rounded
+ddbem407 toSci 0.00013E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem408 toSci 0.00015E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem409 toSci 0.00017E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem410 toSci 0.00023E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem411 toSci 0.00025E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem412 toSci 0.00027E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddbem413 toSci 0.000149E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem414 toSci 0.000150E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem415 toSci 0.000151E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem416 toSci 0.000249E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem417 toSci 0.000250E-394 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddbem418 toSci 0.000251E-394 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddbem419 toSci 0.00009E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem420 toSci 0.00005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem421 toSci 0.00003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem422 toSci 0.000009E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem423 toSci 0.000005E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem424 toSci 0.000003E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddbem425 toSci 0.001049E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem426 toSci 0.001050E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem427 toSci 0.001051E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddbem428 toSci 0.001149E-394 -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddbem429 toSci 0.001150E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
+ddbem430 toSci 0.001151E-394 -> 1.2E-397 Underflow Subnormal Inexact Rounded
+
+ddbem432 toSci 0.010049E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem433 toSci 0.010050E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem434 toSci 0.010051E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddbem435 toSci 0.010149E-394 -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddbem436 toSci 0.010150E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
+ddbem437 toSci 0.010151E-394 -> 1.02E-396 Underflow Subnormal Inexact Rounded
+
+ddbem440 toSci 0.10103E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem441 toSci 0.10105E-394 -> 1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem442 toSci 0.10107E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem443 toSci 0.10113E-394 -> 1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem444 toSci 0.10115E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
+ddbem445 toSci 0.10117E-394 -> 1.012E-395 Underflow Subnormal Inexact Rounded
+
+ddbem450 toSci 1.10730E-395 -> 1.107E-395 Underflow Subnormal Inexact Rounded
+ddbem451 toSci 1.10750E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem452 toSci 1.10770E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem453 toSci 1.10830E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem454 toSci 1.10850E-395 -> 1.108E-395 Underflow Subnormal Inexact Rounded
+ddbem455 toSci 1.10870E-395 -> 1.109E-395 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+ddbem456 toSci -0.10103E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem457 toSci -0.10105E-394 -> -1.010E-395 Underflow Subnormal Inexact Rounded
+ddbem458 toSci -0.10107E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem459 toSci -0.10113E-394 -> -1.011E-395 Underflow Subnormal Inexact Rounded
+ddbem460 toSci -0.10115E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
+ddbem461 toSci -0.10117E-394 -> -1.012E-395 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+ddbem464 toSci 999999E-395 -> 9.99999E-390 Subnormal
+ddbem465 toSci 99999.0E-394 -> 9.99990E-390 Subnormal
+ddbem466 toSci 99999.E-394 -> 9.9999E-390 Subnormal
+ddbem467 toSci 9999.9E-394 -> 9.9999E-391 Subnormal
+ddbem468 toSci 999.99E-394 -> 9.9999E-392 Subnormal
+ddbem469 toSci 99.999E-394 -> 9.9999E-393 Subnormal
+ddbem470 toSci 9.9999E-394 -> 9.9999E-394 Subnormal
+ddbem471 toSci 0.99999E-394 -> 1.0000E-394 Underflow Subnormal Inexact Rounded
+ddbem472 toSci 0.099999E-394 -> 1.000E-395 Underflow Subnormal Inexact Rounded
+ddbem473 toSci 0.0099999E-394 -> 1.00E-396 Underflow Subnormal Inexact Rounded
+ddbem474 toSci 0.00099999E-394 -> 1.0E-397 Underflow Subnormal Inexact Rounded
+ddbem475 toSci 0.000099999E-394 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddbem476 toSci 0.0000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem477 toSci 0.00000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbem478 toSci 0.000000099999E-394 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+ddbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+ddbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+ddbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+ddbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+ddbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+ddbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+ddbas1007 toSci 1e-999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1008 toSci 1e-0999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1009 toSci 1e-00999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1010 toSci 1e-000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1011 toSci 1e-000000000000999999999 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddbas1012 toSci 1e-000000000001000000007 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+ddbas1041 toSci 1.1111111111152444E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+ddbas1042 toSci 1.1111111111152445E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+ddbas1043 toSci 1.1111111111152446E-384 -> 1.11111111111524E-384 Inexact Rounded Subnormal Underflow
+
+-- clamped large normals
+ddbas1070 toSci 1E+369 -> 1E+369
+ddbas1071 toSci 1E+370 -> 1.0E+370 Clamped
+ddbas1072 toSci 1E+378 -> 1.000000000E+378 Clamped
+ddbas1073 toSci 1E+384 -> 1.000000000000000E+384 Clamped
+ddbas1074 toSci 1E+385 -> Infinity Overflow Inexact Rounded
+
+
+-- clamped zeros [see also clamp.decTest]
+ddbas1075 toSci 0e+10000 -> 0E+369 Clamped
+ddbas1076 toSci 0e-10000 -> 0E-398 Clamped
+ddbas1077 toSci -0e+10000 -> -0E+369 Clamped
+ddbas1078 toSci -0e-10000 -> -0E-398 Clamped
+
+-- extreme values from next-wider
+ddbas1101 toSci -9.99999999999999999999999999999999E+6144 -> -Infinity Overflow Inexact Rounded
+ddbas1102 toSci -1E-6143 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1103 toSci -1E-6176 -> -0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1104 toSci -0 -> -0
+ddbas1105 toSci +0 -> 0
+ddbas1106 toSci +1E-6176 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1107 toSci +1E-6173 -> 0E-398 Inexact Rounded Subnormal Underflow Clamped
+ddbas1108 toSci +9.99999999999999999999999999999999E+6144 -> Infinity Overflow Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/ddCanonical.decTest b/Lib/test/decimaltestdata/ddCanonical.decTest
index b4f9e32c986..824de83aba7 100644
--- a/Lib/test/decimaltestdata/ddCanonical.decTest
+++ b/Lib/test/decimaltestdata/ddCanonical.decTest
@@ -1,357 +1,357 @@
-------------------------------------------------------------------------
--- ddCanonical.decTest -- test decDouble canonical results --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests that copy operations leave uncanonical operands
--- unchanged, and vice versa
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Uncanonical declets are: abc, where:
--- a=1,2,3
--- b=6,7,e,f
--- c=e,f
-
--- assert some standard (canonical) values; this tests that FromString
--- produces canonical results (many more in decimalNN)
-ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
-ddcan002 apply 0 -> #2238000000000000
-ddcan003 apply 1 -> #2238000000000001
-ddcan004 apply -1 -> #a238000000000001
-ddcan005 apply Infinity -> #7800000000000000
-ddcan006 apply -Infinity -> #f800000000000000
-ddcan007 apply -NaN -> #fc00000000000000
-ddcan008 apply -sNaN -> #fe00000000000000
-ddcan009 apply NaN999999999999999 -> #7c00ff3fcff3fcff
-ddcan010 apply sNaN999999999999999 -> #7e00ff3fcff3fcff
-decan011 apply 9999999999999999 -> #6e38ff3fcff3fcff
-ddcan012 apply 7.50 -> #22300000000003d0
-ddcan013 apply 9.99 -> #22300000000000ff
-
--- Base tests for canonical encodings (individual operator
--- propagation is tested later)
-
--- Finites: declets in coefficient
-ddcan021 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan022 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan023 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan024 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan025 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
-ddcan026 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
-ddcan027 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
-ddcan028 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
-ddcan030 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
-ddcan031 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
-ddcan032 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
-ddcan033 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
-ddcan035 canonical #77fcff3fdff3fcff -> #77fcff3fcff3fcff
-ddcan036 canonical #77fcff3feff3fcff -> #77fcff3fcff3fcff
-
--- NaN: declets in payload
-ddcan100 canonical NaN999999999999999 -> #7c00ff3fcff3fcff
-ddcan101 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan102 canonical #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan103 canonical #7c00ffffcff3fcff -> #7c00ff3fcff3fcff
-ddcan104 canonical #7c00ff3ffff3fcff -> #7c00ff3fcff3fcff
-ddcan105 canonical #7c00ff3fcffffcff -> #7c00ff3fcff3fcff
-ddcan106 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
-ddcan107 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan110 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan112 canonical #7d00ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan113 canonical #7c80ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan114 canonical #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan115 canonical #7c20ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan116 canonical #7c10ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan117 canonical #7c08ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan118 canonical #7c04ff3fcff3fcff -> #7c00ff3fcff3fcff
-
--- sNaN: declets in payload
-ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
-ddcan121 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan122 canonical #7e03ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan123 canonical #7e00ffffcff3fcff -> #7e00ff3fcff3fcff
-ddcan124 canonical #7e00ff3ffff3fcff -> #7e00ff3fcff3fcff
-ddcan125 canonical #7e00ff3fcffffcff -> #7e00ff3fcff3fcff
-ddcan126 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
-ddcan127 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan130 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan132 canonical #7f00ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan133 canonical #7e80ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan134 canonical #7e40ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan135 canonical #7e20ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan136 canonical #7e10ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan137 canonical #7e08ff3fcff3fcff -> #7e00ff3fcff3fcff
-ddcan138 canonical #7e04ff3fcff3fcff -> #7e00ff3fcff3fcff
-
--- Inf: exponent continuation bits
-ddcan140 canonical #7800000000000000 -> #7800000000000000
-ddcan141 canonical #7900000000000000 -> #7800000000000000
-ddcan142 canonical #7a00000000000000 -> #7800000000000000
-ddcan143 canonical #7880000000000000 -> #7800000000000000
-ddcan144 canonical #7840000000000000 -> #7800000000000000
-ddcan145 canonical #7820000000000000 -> #7800000000000000
-ddcan146 canonical #7810000000000000 -> #7800000000000000
-ddcan147 canonical #7808000000000000 -> #7800000000000000
-ddcan148 canonical #7804000000000000 -> #7800000000000000
-
--- Inf: coefficient continuation bits (first, last, and a few others)
-ddcan150 canonical #7800000000000000 -> #7800000000000000
-ddcan151 canonical #7802000000000000 -> #7800000000000000
-ddcan152 canonical #7800000000000001 -> #7800000000000000
-ddcan153 canonical #7801000000000000 -> #7800000000000000
-ddcan154 canonical #7800200000000000 -> #7800000000000000
-ddcan155 canonical #7800080000000000 -> #7800000000000000
-ddcan156 canonical #7800002000000000 -> #7800000000000000
-ddcan157 canonical #7800000400000000 -> #7800000000000000
-ddcan158 canonical #7800000040000000 -> #7800000000000000
-ddcan159 canonical #7800000008000000 -> #7800000000000000
-ddcan160 canonical #7800000000400000 -> #7800000000000000
-ddcan161 canonical #7800000000020000 -> #7800000000000000
-ddcan162 canonical #7800000000008000 -> #7800000000000000
-ddcan163 canonical #7800000000000200 -> #7800000000000000
-ddcan164 canonical #7800000000000040 -> #7800000000000000
-ddcan165 canonical #7800000000000008 -> #7800000000000000
-
-
--- Now the operators -- trying to check paths that might fail to
--- canonicalize propagated operands
-
------ Add:
--- Finites: neutral 0
-ddcan202 add 0E+384 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan203 add #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
--- tiny zero
-ddcan204 add 0E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Rounded
-ddcan205 add #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
--- tiny non zero
-ddcan206 add -1E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Inexact Rounded
-ddcan207 add #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-ddcan211 add 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan212 add #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan213 add 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan214 add #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan215 add 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan216 add #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan217 add 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan218 add #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan220 add 0 #7880000000000000 -> #7800000000000000
-ddcan221 add #7880000000000000 0 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan222 add 0 #7802000000000000 -> #7800000000000000
-ddcan223 add #7802000000000000 0 -> #7800000000000000
-ddcan224 add 0 #7800000000000001 -> #7800000000000000
-ddcan225 add #7800000000000001 0 -> #7800000000000000
-ddcan226 add 0 #7800002000000000 -> #7800000000000000
-ddcan227 add #7800002000000000 0 -> #7800000000000000
-
------ Class: [does not return encoded]
-
------ Compare:
-ddcan231 compare -Inf 1 -> #a238000000000001
-ddcan232 compare -Inf -Inf -> #2238000000000000
-ddcan233 compare 1 -Inf -> #2238000000000001
-ddcan234 compare #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff
-ddcan235 compare #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-
------ CompareSig:
-ddcan241 comparesig -Inf 1 -> #a238000000000001
-ddcan242 comparesig -Inf -Inf -> #2238000000000000
-ddcan243 comparesig 1 -Inf -> #2238000000000001
-ddcan244 comparesig #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan245 comparesig #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
-
------ Copy: [does not usually canonicalize]
--- finites
-ddcan250 copy #77ffff3fcff3fcff -> #77ffff3fcff3fcff
-ddcan251 copy #77fcff3fdff3fcff -> #77fcff3fdff3fcff
--- NaNs
-ddcan252 copy #7c03ff3fcff3fcff -> #7c03ff3fcff3fcff
-ddcan253 copy #7c00ff3fcff3ffff -> #7c00ff3fcff3ffff
-ddcan254 copy #7d00ff3fcff3fcff -> #7d00ff3fcff3fcff
-ddcan255 copy #7c04ff3fcff3fcff -> #7c04ff3fcff3fcff
--- sNaN
-ddcan256 copy #7e00ff3fcffffcff -> #7e00ff3fcffffcff
-ddcan257 copy #7e40ff3fcff3fcff -> #7e40ff3fcff3fcff
--- Inf
-ddcan258 copy #7a00000000000000 -> #7a00000000000000
-ddcan259 copy #7800200000000000 -> #7800200000000000
-
------ CopyAbs: [does not usually canonicalize]
--- finites
-ddcan260 copyabs #f7ffff3fcff3fcff -> #77ffff3fcff3fcff
-ddcan261 copyabs #f7fcff3fdff3fcff -> #77fcff3fdff3fcff
--- NaNs
-ddcan262 copyabs #fc03ff3fcff3fcff -> #7c03ff3fcff3fcff
-ddcan263 copyabs #fc00ff3fcff3ffff -> #7c00ff3fcff3ffff
-ddcan264 copyabs #fd00ff3fcff3fcff -> #7d00ff3fcff3fcff
-ddcan265 copyabs #fc04ff3fcff3fcff -> #7c04ff3fcff3fcff
--- sNaN
-ddcan266 copyabs #fe00ff3fcffffcff -> #7e00ff3fcffffcff
-ddcan267 copyabs #fe40ff3fcff3fcff -> #7e40ff3fcff3fcff
--- Inf
-ddcan268 copyabs #fa00000000000000 -> #7a00000000000000
-ddcan269 copyabs #f800200000000000 -> #7800200000000000
-
------ CopyNegate: [does not usually canonicalize]
--- finites
-ddcan270 copynegate #77ffff3fcff3fcff -> #f7ffff3fcff3fcff
-ddcan271 copynegate #77fcff3fdff3fcff -> #f7fcff3fdff3fcff
--- NaNs
-ddcan272 copynegate #7c03ff3fcff3fcff -> #fc03ff3fcff3fcff
-ddcan273 copynegate #7c00ff3fcff3ffff -> #fc00ff3fcff3ffff
-ddcan274 copynegate #7d00ff3fcff3fcff -> #fd00ff3fcff3fcff
-ddcan275 copynegate #7c04ff3fcff3fcff -> #fc04ff3fcff3fcff
--- sNaN
-ddcan276 copynegate #7e00ff3fcffffcff -> #fe00ff3fcffffcff
-ddcan277 copynegate #7e40ff3fcff3fcff -> #fe40ff3fcff3fcff
--- Inf
-ddcan278 copynegate #7a00000000000000 -> #fa00000000000000
-ddcan279 copynegate #7800200000000000 -> #f800200000000000
-
------ CopySign: [does not usually canonicalize]
--- finites
-ddcan280 copysign #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
-ddcan281 copysign #77fcff3fdff3fcff 1 -> #77fcff3fdff3fcff
--- NaNs
-ddcan282 copysign #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
-ddcan283 copysign #7c00ff3fcff3ffff 1 -> #7c00ff3fcff3ffff
-ddcan284 copysign #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
-ddcan285 copysign #7c04ff3fcff3fcff 1 -> #7c04ff3fcff3fcff
--- sNaN
-ddcan286 copysign #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
-ddcan287 copysign #7e40ff3fcff3fcff 1 -> #7e40ff3fcff3fcff
--- Inf
-ddcan288 copysign #7a00000000000000 -1 -> #fa00000000000000
-ddcan289 copysign #7800200000000000 1 -> #7800200000000000
-
------ Multiply:
--- Finites: neutral 0
-ddcan302 multiply 1 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
-ddcan303 multiply #77fcffffcff3fcff 1 -> #77fcff3fcff3fcff
--- negative
-ddcan306 multiply -1 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
-ddcan307 multiply #77fcffffcff3fcff -1 -> #f7fcff3fcff3fcff
--- NaN: declets in payload
-ddcan311 multiply 1 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan312 multiply #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan313 multiply 1 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan314 multiply #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan315 multiply 1 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan316 multiply #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan317 multiply 1 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan318 multiply #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan320 multiply 1 #7880000000000000 -> #7800000000000000
-ddcan321 multiply #7880000000000000 1 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan322 multiply 1 #7802000000000000 -> #7800000000000000
-ddcan323 multiply #7802000000000000 1 -> #7800000000000000
-ddcan324 multiply 1 #7800000000000001 -> #7800000000000000
-ddcan325 multiply #7800000000000001 1 -> #7800000000000000
-ddcan326 multiply 1 #7800002000000000 -> #7800000000000000
-ddcan327 multiply #7800002000000000 1 -> #7800000000000000
-
------ Quantize:
-ddcan401 quantize #6e38ff3ffff3fcff 1 -> #6e38ff3fcff3fcff
-ddcan402 quantize #6e38ff3fcff3fdff 0 -> #6e38ff3fcff3fcff
-ddcan403 quantize #7880000000000000 Inf -> #7800000000000000
-ddcan404 quantize #7802000000000000 -Inf -> #7800000000000000
-ddcan410 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan411 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan412 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan413 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
-ddcan414 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan415 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan416 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-ddcan417 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
-
------ Subtract:
--- Finites: neutral 0
-ddcan502 subtract 0E+384 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
-ddcan503 subtract #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
--- tiny zero
-ddcan504 subtract 0E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Rounded
-ddcan505 subtract #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
--- tiny non zero
-ddcan506 subtract -1E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Inexact Rounded
-ddcan507 subtract #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-ddcan511 subtract 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan512 subtract #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-ddcan513 subtract 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan514 subtract #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
--- sNaN: declets in payload
-ddcan515 subtract 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan516 subtract #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-ddcan517 subtract 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan518 subtract #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-ddcan520 subtract 0 #7880000000000000 -> #f800000000000000
-ddcan521 subtract #7880000000000000 0 -> #7800000000000000
--- Inf: coefficient continuation bits
-ddcan522 subtract 0 #7802000000000000 -> #f800000000000000
-ddcan523 subtract #7802000000000000 0 -> #7800000000000000
-ddcan524 subtract 0 #7800000000000001 -> #f800000000000000
-ddcan525 subtract #7800000000000001 0 -> #7800000000000000
-ddcan526 subtract 0 #7800002000000000 -> #f800000000000000
-ddcan527 subtract #7800002000000000 0 -> #7800000000000000
-
------ ToIntegral:
-ddcan601 tointegralx #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
-ddcan602 tointegralx #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
-ddcan603 tointegralx #7880000000000000 -> #7800000000000000
-ddcan604 tointegralx #7802000000000000 -> #7800000000000000
-ddcan610 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan611 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan612 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan613 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
-ddcan614 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan615 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan616 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
-ddcan617 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
--- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
-ddcan618 tointegralx #2238000000000fff -> #2238000000000cff
-ddcan619 tointegralx #2230000000000fff -> #2238000000000040 Inexact Rounded
-ddcan620 tointegralx #222c000000000fff -> #2238000000000004 Inexact Rounded
-ddcan621 tointegralx #2228000000000fff -> #2238000000000000 Inexact Rounded
-ddcan622 tointegralx #a238000000000fff -> #a238000000000cff
-ddcan623 tointegralx #a230000000000fff -> #a238000000000040 Inexact Rounded
-ddcan624 tointegralx #a22c000000000fff -> #a238000000000004 Inexact Rounded
-ddcan625 tointegralx #a228000000000fff -> #a238000000000000 Inexact Rounded
-
-
-
+------------------------------------------------------------------------
+-- ddCanonical.decTest -- test decDouble canonical results --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests that copy operations leave uncanonical operands
+-- unchanged, and vice versa
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Uncanonical declets are: abc, where:
+-- a=1,2,3
+-- b=6,7,e,f
+-- c=e,f
+
+-- assert some standard (canonical) values; this tests that FromString
+-- produces canonical results (many more in decimalNN)
+ddcan001 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
+ddcan002 apply 0 -> #2238000000000000
+ddcan003 apply 1 -> #2238000000000001
+ddcan004 apply -1 -> #a238000000000001
+ddcan005 apply Infinity -> #7800000000000000
+ddcan006 apply -Infinity -> #f800000000000000
+ddcan007 apply -NaN -> #fc00000000000000
+ddcan008 apply -sNaN -> #fe00000000000000
+ddcan009 apply NaN999999999999999 -> #7c00ff3fcff3fcff
+ddcan010 apply sNaN999999999999999 -> #7e00ff3fcff3fcff
+decan011 apply 9999999999999999 -> #6e38ff3fcff3fcff
+ddcan012 apply 7.50 -> #22300000000003d0
+ddcan013 apply 9.99 -> #22300000000000ff
+
+-- Base tests for canonical encodings (individual operator
+-- propagation is tested later)
+
+-- Finites: declets in coefficient
+ddcan021 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan022 canonical #77fcff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan023 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan024 canonical #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan025 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
+ddcan026 canonical #77fcffffcff3fcff -> #77fcff3fcff3fcff
+ddcan027 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
+ddcan028 canonical #77fcff3ffff3fcff -> #77fcff3fcff3fcff
+ddcan030 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
+ddcan031 canonical #77fcff3fcffffcff -> #77fcff3fcff3fcff
+ddcan032 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
+ddcan033 canonical #77fcff3fcff3ffff -> #77fcff3fcff3fcff
+ddcan035 canonical #77fcff3fdff3fcff -> #77fcff3fcff3fcff
+ddcan036 canonical #77fcff3feff3fcff -> #77fcff3fcff3fcff
+
+-- NaN: declets in payload
+ddcan100 canonical NaN999999999999999 -> #7c00ff3fcff3fcff
+ddcan101 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan102 canonical #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan103 canonical #7c00ffffcff3fcff -> #7c00ff3fcff3fcff
+ddcan104 canonical #7c00ff3ffff3fcff -> #7c00ff3fcff3fcff
+ddcan105 canonical #7c00ff3fcffffcff -> #7c00ff3fcff3fcff
+ddcan106 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
+ddcan107 canonical #7c00ff3fcff3ffff -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan110 canonical #7c00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan112 canonical #7d00ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan113 canonical #7c80ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan114 canonical #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan115 canonical #7c20ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan116 canonical #7c10ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan117 canonical #7c08ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan118 canonical #7c04ff3fcff3fcff -> #7c00ff3fcff3fcff
+
+-- sNaN: declets in payload
+ddcan120 canonical sNaN999999999999999 -> #7e00ff3fcff3fcff
+ddcan121 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan122 canonical #7e03ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan123 canonical #7e00ffffcff3fcff -> #7e00ff3fcff3fcff
+ddcan124 canonical #7e00ff3ffff3fcff -> #7e00ff3fcff3fcff
+ddcan125 canonical #7e00ff3fcffffcff -> #7e00ff3fcff3fcff
+ddcan126 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
+ddcan127 canonical #7e00ff3fcff3ffff -> #7e00ff3fcff3fcff
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan130 canonical #7e00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan132 canonical #7f00ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan133 canonical #7e80ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan134 canonical #7e40ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan135 canonical #7e20ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan136 canonical #7e10ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan137 canonical #7e08ff3fcff3fcff -> #7e00ff3fcff3fcff
+ddcan138 canonical #7e04ff3fcff3fcff -> #7e00ff3fcff3fcff
+
+-- Inf: exponent continuation bits
+ddcan140 canonical #7800000000000000 -> #7800000000000000
+ddcan141 canonical #7900000000000000 -> #7800000000000000
+ddcan142 canonical #7a00000000000000 -> #7800000000000000
+ddcan143 canonical #7880000000000000 -> #7800000000000000
+ddcan144 canonical #7840000000000000 -> #7800000000000000
+ddcan145 canonical #7820000000000000 -> #7800000000000000
+ddcan146 canonical #7810000000000000 -> #7800000000000000
+ddcan147 canonical #7808000000000000 -> #7800000000000000
+ddcan148 canonical #7804000000000000 -> #7800000000000000
+
+-- Inf: coefficient continuation bits (first, last, and a few others)
+ddcan150 canonical #7800000000000000 -> #7800000000000000
+ddcan151 canonical #7802000000000000 -> #7800000000000000
+ddcan152 canonical #7800000000000001 -> #7800000000000000
+ddcan153 canonical #7801000000000000 -> #7800000000000000
+ddcan154 canonical #7800200000000000 -> #7800000000000000
+ddcan155 canonical #7800080000000000 -> #7800000000000000
+ddcan156 canonical #7800002000000000 -> #7800000000000000
+ddcan157 canonical #7800000400000000 -> #7800000000000000
+ddcan158 canonical #7800000040000000 -> #7800000000000000
+ddcan159 canonical #7800000008000000 -> #7800000000000000
+ddcan160 canonical #7800000000400000 -> #7800000000000000
+ddcan161 canonical #7800000000020000 -> #7800000000000000
+ddcan162 canonical #7800000000008000 -> #7800000000000000
+ddcan163 canonical #7800000000000200 -> #7800000000000000
+ddcan164 canonical #7800000000000040 -> #7800000000000000
+ddcan165 canonical #7800000000000008 -> #7800000000000000
+
+
+-- Now the operators -- trying to check paths that might fail to
+-- canonicalize propagated operands
+
+----- Add:
+-- Finites: neutral 0
+ddcan202 add 0E+384 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan203 add #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
+-- tiny zero
+ddcan204 add 0E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Rounded
+ddcan205 add #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
+-- tiny non zero
+ddcan206 add -1E-398 #77ffff3fcff3fcff -> #77fcff3fcff3fcff Inexact Rounded
+ddcan207 add #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+ddcan211 add 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan212 add #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan213 add 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan214 add #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan215 add 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan216 add #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan217 add 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan218 add #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan220 add 0 #7880000000000000 -> #7800000000000000
+ddcan221 add #7880000000000000 0 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan222 add 0 #7802000000000000 -> #7800000000000000
+ddcan223 add #7802000000000000 0 -> #7800000000000000
+ddcan224 add 0 #7800000000000001 -> #7800000000000000
+ddcan225 add #7800000000000001 0 -> #7800000000000000
+ddcan226 add 0 #7800002000000000 -> #7800000000000000
+ddcan227 add #7800002000000000 0 -> #7800000000000000
+
+----- Class: [does not return encoded]
+
+----- Compare:
+ddcan231 compare -Inf 1 -> #a238000000000001
+ddcan232 compare -Inf -Inf -> #2238000000000000
+ddcan233 compare 1 -Inf -> #2238000000000001
+ddcan234 compare #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff
+ddcan235 compare #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- CompareSig:
+ddcan241 comparesig -Inf 1 -> #a238000000000001
+ddcan242 comparesig -Inf -Inf -> #2238000000000000
+ddcan243 comparesig 1 -Inf -> #2238000000000001
+ddcan244 comparesig #7c00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan245 comparesig #7e00ff3ffff3fcff -1000 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- Copy: [does not usually canonicalize]
+-- finites
+ddcan250 copy #77ffff3fcff3fcff -> #77ffff3fcff3fcff
+ddcan251 copy #77fcff3fdff3fcff -> #77fcff3fdff3fcff
+-- NaNs
+ddcan252 copy #7c03ff3fcff3fcff -> #7c03ff3fcff3fcff
+ddcan253 copy #7c00ff3fcff3ffff -> #7c00ff3fcff3ffff
+ddcan254 copy #7d00ff3fcff3fcff -> #7d00ff3fcff3fcff
+ddcan255 copy #7c04ff3fcff3fcff -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan256 copy #7e00ff3fcffffcff -> #7e00ff3fcffffcff
+ddcan257 copy #7e40ff3fcff3fcff -> #7e40ff3fcff3fcff
+-- Inf
+ddcan258 copy #7a00000000000000 -> #7a00000000000000
+ddcan259 copy #7800200000000000 -> #7800200000000000
+
+----- CopyAbs: [does not usually canonicalize]
+-- finites
+ddcan260 copyabs #f7ffff3fcff3fcff -> #77ffff3fcff3fcff
+ddcan261 copyabs #f7fcff3fdff3fcff -> #77fcff3fdff3fcff
+-- NaNs
+ddcan262 copyabs #fc03ff3fcff3fcff -> #7c03ff3fcff3fcff
+ddcan263 copyabs #fc00ff3fcff3ffff -> #7c00ff3fcff3ffff
+ddcan264 copyabs #fd00ff3fcff3fcff -> #7d00ff3fcff3fcff
+ddcan265 copyabs #fc04ff3fcff3fcff -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan266 copyabs #fe00ff3fcffffcff -> #7e00ff3fcffffcff
+ddcan267 copyabs #fe40ff3fcff3fcff -> #7e40ff3fcff3fcff
+-- Inf
+ddcan268 copyabs #fa00000000000000 -> #7a00000000000000
+ddcan269 copyabs #f800200000000000 -> #7800200000000000
+
+----- CopyNegate: [does not usually canonicalize]
+-- finites
+ddcan270 copynegate #77ffff3fcff3fcff -> #f7ffff3fcff3fcff
+ddcan271 copynegate #77fcff3fdff3fcff -> #f7fcff3fdff3fcff
+-- NaNs
+ddcan272 copynegate #7c03ff3fcff3fcff -> #fc03ff3fcff3fcff
+ddcan273 copynegate #7c00ff3fcff3ffff -> #fc00ff3fcff3ffff
+ddcan274 copynegate #7d00ff3fcff3fcff -> #fd00ff3fcff3fcff
+ddcan275 copynegate #7c04ff3fcff3fcff -> #fc04ff3fcff3fcff
+-- sNaN
+ddcan276 copynegate #7e00ff3fcffffcff -> #fe00ff3fcffffcff
+ddcan277 copynegate #7e40ff3fcff3fcff -> #fe40ff3fcff3fcff
+-- Inf
+ddcan278 copynegate #7a00000000000000 -> #fa00000000000000
+ddcan279 copynegate #7800200000000000 -> #f800200000000000
+
+----- CopySign: [does not usually canonicalize]
+-- finites
+ddcan280 copysign #77ffff3fcff3fcff -1 -> #f7ffff3fcff3fcff
+ddcan281 copysign #77fcff3fdff3fcff 1 -> #77fcff3fdff3fcff
+-- NaNs
+ddcan282 copysign #7c03ff3fcff3fcff -1 -> #fc03ff3fcff3fcff
+ddcan283 copysign #7c00ff3fcff3ffff 1 -> #7c00ff3fcff3ffff
+ddcan284 copysign #7d00ff3fcff3fcff -1 -> #fd00ff3fcff3fcff
+ddcan285 copysign #7c04ff3fcff3fcff 1 -> #7c04ff3fcff3fcff
+-- sNaN
+ddcan286 copysign #7e00ff3fcffffcff -1 -> #fe00ff3fcffffcff
+ddcan287 copysign #7e40ff3fcff3fcff 1 -> #7e40ff3fcff3fcff
+-- Inf
+ddcan288 copysign #7a00000000000000 -1 -> #fa00000000000000
+ddcan289 copysign #7800200000000000 1 -> #7800200000000000
+
+----- Multiply:
+-- Finites: neutral 0
+ddcan302 multiply 1 #77ffff3fcff3fcff -> #77fcff3fcff3fcff
+ddcan303 multiply #77fcffffcff3fcff 1 -> #77fcff3fcff3fcff
+-- negative
+ddcan306 multiply -1 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
+ddcan307 multiply #77fcffffcff3fcff -1 -> #f7fcff3fcff3fcff
+-- NaN: declets in payload
+ddcan311 multiply 1 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan312 multiply #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan313 multiply 1 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan314 multiply #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan315 multiply 1 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan316 multiply #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan317 multiply 1 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan318 multiply #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan320 multiply 1 #7880000000000000 -> #7800000000000000
+ddcan321 multiply #7880000000000000 1 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan322 multiply 1 #7802000000000000 -> #7800000000000000
+ddcan323 multiply #7802000000000000 1 -> #7800000000000000
+ddcan324 multiply 1 #7800000000000001 -> #7800000000000000
+ddcan325 multiply #7800000000000001 1 -> #7800000000000000
+ddcan326 multiply 1 #7800002000000000 -> #7800000000000000
+ddcan327 multiply #7800002000000000 1 -> #7800000000000000
+
+----- Quantize:
+ddcan401 quantize #6e38ff3ffff3fcff 1 -> #6e38ff3fcff3fcff
+ddcan402 quantize #6e38ff3fcff3fdff 0 -> #6e38ff3fcff3fcff
+ddcan403 quantize #7880000000000000 Inf -> #7800000000000000
+ddcan404 quantize #7802000000000000 -Inf -> #7800000000000000
+ddcan410 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan411 quantize #7c03ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan412 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan413 quantize #7c40ff3fcff3fcff 1 -> #7c00ff3fcff3fcff
+ddcan414 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan415 quantize #7e00ffffcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan416 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+ddcan417 quantize #7e80ff3fcff3fcff 1 -> #7c00ff3fcff3fcff Invalid_operation
+
+----- Subtract:
+-- Finites: neutral 0
+ddcan502 subtract 0E+384 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff
+ddcan503 subtract #77fcffffcff3fcff 0E+384 -> #77fcff3fcff3fcff
+-- tiny zero
+ddcan504 subtract 0E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Rounded
+ddcan505 subtract #77fcffffcff3fcff 0E-398 -> #77fcff3fcff3fcff Rounded
+-- tiny non zero
+ddcan506 subtract -1E-398 #77ffff3fcff3fcff -> #f7fcff3fcff3fcff Inexact Rounded
+ddcan507 subtract #77ffff3fcff3fcff -1E-398 -> #77fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+ddcan511 subtract 0 #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan512 subtract #7c03ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+ddcan513 subtract 0 #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan514 subtract #7c40ff3fcff3fcff 0 -> #7c00ff3fcff3fcff
+-- sNaN: declets in payload
+ddcan515 subtract 0 #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan516 subtract #7e00ffffcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+ddcan517 subtract 0 #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan518 subtract #7e80ff3fcff3fcff 0 -> #7c00ff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+ddcan520 subtract 0 #7880000000000000 -> #f800000000000000
+ddcan521 subtract #7880000000000000 0 -> #7800000000000000
+-- Inf: coefficient continuation bits
+ddcan522 subtract 0 #7802000000000000 -> #f800000000000000
+ddcan523 subtract #7802000000000000 0 -> #7800000000000000
+ddcan524 subtract 0 #7800000000000001 -> #f800000000000000
+ddcan525 subtract #7800000000000001 0 -> #7800000000000000
+ddcan526 subtract 0 #7800002000000000 -> #f800000000000000
+ddcan527 subtract #7800002000000000 0 -> #7800000000000000
+
+----- ToIntegral:
+ddcan601 tointegralx #6e38ff3ffff3fcff -> #6e38ff3fcff3fcff
+ddcan602 tointegralx #6e38ff3fcff3fdff -> #6e38ff3fcff3fcff
+ddcan603 tointegralx #7880000000000000 -> #7800000000000000
+ddcan604 tointegralx #7802000000000000 -> #7800000000000000
+ddcan610 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan611 tointegralx #7c03ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan612 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan613 tointegralx #7c40ff3fcff3fcff -> #7c00ff3fcff3fcff
+ddcan614 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan615 tointegralx #7e00ffffcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan616 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+ddcan617 tointegralx #7e80ff3fcff3fcff -> #7c00ff3fcff3fcff Invalid_operation
+-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
+ddcan618 tointegralx #2238000000000fff -> #2238000000000cff
+ddcan619 tointegralx #2230000000000fff -> #2238000000000040 Inexact Rounded
+ddcan620 tointegralx #222c000000000fff -> #2238000000000004 Inexact Rounded
+ddcan621 tointegralx #2228000000000fff -> #2238000000000000 Inexact Rounded
+ddcan622 tointegralx #a238000000000fff -> #a238000000000cff
+ddcan623 tointegralx #a230000000000fff -> #a238000000000040 Inexact Rounded
+ddcan624 tointegralx #a22c000000000fff -> #a238000000000004 Inexact Rounded
+ddcan625 tointegralx #a228000000000fff -> #a238000000000000 Inexact Rounded
+
+
+
diff --git a/Lib/test/decimaltestdata/ddClass.decTest b/Lib/test/decimaltestdata/ddClass.decTest
index bb34c42d4a6..a1d233b86d6 100644
--- a/Lib/test/decimaltestdata/ddClass.decTest
+++ b/Lib/test/decimaltestdata/ddClass.decTest
@@ -1,76 +1,76 @@
-------------------------------------------------------------------------
--- ddClass.decTest -- decDouble Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddcla001 class 0 -> +Zero
-ddcla002 class 0.00 -> +Zero
-ddcla003 class 0E+5 -> +Zero
-ddcla004 class 1E-396 -> +Subnormal
-ddcla005 class 0.1E-383 -> +Subnormal
-ddcla006 class 0.999999999999999E-383 -> +Subnormal
-ddcla007 class 1.000000000000000E-383 -> +Normal
-ddcla008 class 1E-383 -> +Normal
-ddcla009 class 1E-100 -> +Normal
-ddcla010 class 1E-10 -> +Normal
-ddcla012 class 1E-1 -> +Normal
-ddcla013 class 1 -> +Normal
-ddcla014 class 2.50 -> +Normal
-ddcla015 class 100.100 -> +Normal
-ddcla016 class 1E+30 -> +Normal
-ddcla017 class 1E+384 -> +Normal
-ddcla018 class 9.999999999999999E+384 -> +Normal
-ddcla019 class Inf -> +Infinity
-
-ddcla021 class -0 -> -Zero
-ddcla022 class -0.00 -> -Zero
-ddcla023 class -0E+5 -> -Zero
-ddcla024 class -1E-396 -> -Subnormal
-ddcla025 class -0.1E-383 -> -Subnormal
-ddcla026 class -0.999999999999999E-383 -> -Subnormal
-ddcla027 class -1.000000000000000E-383 -> -Normal
-ddcla028 class -1E-383 -> -Normal
-ddcla029 class -1E-100 -> -Normal
-ddcla030 class -1E-10 -> -Normal
-ddcla032 class -1E-1 -> -Normal
-ddcla033 class -1 -> -Normal
-ddcla034 class -2.50 -> -Normal
-ddcla035 class -100.100 -> -Normal
-ddcla036 class -1E+30 -> -Normal
-ddcla037 class -1E+384 -> -Normal
-ddcla038 class -9.999999999999999E+384 -> -Normal
-ddcla039 class -Inf -> -Infinity
-
-ddcla041 class NaN -> NaN
-ddcla042 class -NaN -> NaN
-ddcla043 class +NaN12345 -> NaN
-ddcla044 class sNaN -> sNaN
-ddcla045 class -sNaN -> sNaN
-ddcla046 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- ddClass.decTest -- decDouble Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddcla001 class 0 -> +Zero
+ddcla002 class 0.00 -> +Zero
+ddcla003 class 0E+5 -> +Zero
+ddcla004 class 1E-396 -> +Subnormal
+ddcla005 class 0.1E-383 -> +Subnormal
+ddcla006 class 0.999999999999999E-383 -> +Subnormal
+ddcla007 class 1.000000000000000E-383 -> +Normal
+ddcla008 class 1E-383 -> +Normal
+ddcla009 class 1E-100 -> +Normal
+ddcla010 class 1E-10 -> +Normal
+ddcla012 class 1E-1 -> +Normal
+ddcla013 class 1 -> +Normal
+ddcla014 class 2.50 -> +Normal
+ddcla015 class 100.100 -> +Normal
+ddcla016 class 1E+30 -> +Normal
+ddcla017 class 1E+384 -> +Normal
+ddcla018 class 9.999999999999999E+384 -> +Normal
+ddcla019 class Inf -> +Infinity
+
+ddcla021 class -0 -> -Zero
+ddcla022 class -0.00 -> -Zero
+ddcla023 class -0E+5 -> -Zero
+ddcla024 class -1E-396 -> -Subnormal
+ddcla025 class -0.1E-383 -> -Subnormal
+ddcla026 class -0.999999999999999E-383 -> -Subnormal
+ddcla027 class -1.000000000000000E-383 -> -Normal
+ddcla028 class -1E-383 -> -Normal
+ddcla029 class -1E-100 -> -Normal
+ddcla030 class -1E-10 -> -Normal
+ddcla032 class -1E-1 -> -Normal
+ddcla033 class -1 -> -Normal
+ddcla034 class -2.50 -> -Normal
+ddcla035 class -100.100 -> -Normal
+ddcla036 class -1E+30 -> -Normal
+ddcla037 class -1E+384 -> -Normal
+ddcla038 class -9.999999999999999E+384 -> -Normal
+ddcla039 class -Inf -> -Infinity
+
+ddcla041 class NaN -> NaN
+ddcla042 class -NaN -> NaN
+ddcla043 class +NaN12345 -> NaN
+ddcla044 class sNaN -> sNaN
+ddcla045 class -sNaN -> sNaN
+ddcla046 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/ddCompare.decTest b/Lib/test/decimaltestdata/ddCompare.decTest
index 6debfc7a138..a20ae210cc9 100644
--- a/Lib/test/decimaltestdata/ddCompare.decTest
+++ b/Lib/test/decimaltestdata/ddCompare.decTest
@@ -1,744 +1,744 @@
-------------------------------------------------------------------------
--- ddCompare.decTest -- decDouble comparison that allows quiet NaNs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcom001 compare -2 -2 -> 0
-ddcom002 compare -2 -1 -> -1
-ddcom003 compare -2 0 -> -1
-ddcom004 compare -2 1 -> -1
-ddcom005 compare -2 2 -> -1
-ddcom006 compare -1 -2 -> 1
-ddcom007 compare -1 -1 -> 0
-ddcom008 compare -1 0 -> -1
-ddcom009 compare -1 1 -> -1
-ddcom010 compare -1 2 -> -1
-ddcom011 compare 0 -2 -> 1
-ddcom012 compare 0 -1 -> 1
-ddcom013 compare 0 0 -> 0
-ddcom014 compare 0 1 -> -1
-ddcom015 compare 0 2 -> -1
-ddcom016 compare 1 -2 -> 1
-ddcom017 compare 1 -1 -> 1
-ddcom018 compare 1 0 -> 1
-ddcom019 compare 1 1 -> 0
-ddcom020 compare 1 2 -> -1
-ddcom021 compare 2 -2 -> 1
-ddcom022 compare 2 -1 -> 1
-ddcom023 compare 2 0 -> 1
-ddcom025 compare 2 1 -> 1
-ddcom026 compare 2 2 -> 0
-
-ddcom031 compare -20 -20 -> 0
-ddcom032 compare -20 -10 -> -1
-ddcom033 compare -20 00 -> -1
-ddcom034 compare -20 10 -> -1
-ddcom035 compare -20 20 -> -1
-ddcom036 compare -10 -20 -> 1
-ddcom037 compare -10 -10 -> 0
-ddcom038 compare -10 00 -> -1
-ddcom039 compare -10 10 -> -1
-ddcom040 compare -10 20 -> -1
-ddcom041 compare 00 -20 -> 1
-ddcom042 compare 00 -10 -> 1
-ddcom043 compare 00 00 -> 0
-ddcom044 compare 00 10 -> -1
-ddcom045 compare 00 20 -> -1
-ddcom046 compare 10 -20 -> 1
-ddcom047 compare 10 -10 -> 1
-ddcom048 compare 10 00 -> 1
-ddcom049 compare 10 10 -> 0
-ddcom050 compare 10 20 -> -1
-ddcom051 compare 20 -20 -> 1
-ddcom052 compare 20 -10 -> 1
-ddcom053 compare 20 00 -> 1
-ddcom055 compare 20 10 -> 1
-ddcom056 compare 20 20 -> 0
-
-ddcom061 compare -2.0 -2.0 -> 0
-ddcom062 compare -2.0 -1.0 -> -1
-ddcom063 compare -2.0 0.0 -> -1
-ddcom064 compare -2.0 1.0 -> -1
-ddcom065 compare -2.0 2.0 -> -1
-ddcom066 compare -1.0 -2.0 -> 1
-ddcom067 compare -1.0 -1.0 -> 0
-ddcom068 compare -1.0 0.0 -> -1
-ddcom069 compare -1.0 1.0 -> -1
-ddcom070 compare -1.0 2.0 -> -1
-ddcom071 compare 0.0 -2.0 -> 1
-ddcom072 compare 0.0 -1.0 -> 1
-ddcom073 compare 0.0 0.0 -> 0
-ddcom074 compare 0.0 1.0 -> -1
-ddcom075 compare 0.0 2.0 -> -1
-ddcom076 compare 1.0 -2.0 -> 1
-ddcom077 compare 1.0 -1.0 -> 1
-ddcom078 compare 1.0 0.0 -> 1
-ddcom079 compare 1.0 1.0 -> 0
-ddcom080 compare 1.0 2.0 -> -1
-ddcom081 compare 2.0 -2.0 -> 1
-ddcom082 compare 2.0 -1.0 -> 1
-ddcom083 compare 2.0 0.0 -> 1
-ddcom085 compare 2.0 1.0 -> 1
-ddcom086 compare 2.0 2.0 -> 0
-ddcom087 compare 1.0 0.1 -> 1
-ddcom088 compare 0.1 1.0 -> -1
-
--- now some cases which might overflow if subtract were used
-ddcom095 compare 9.999999999999999E+384 9.999999999999999E+384 -> 0
-ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384 -> -1
-ddcom097 compare 9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0
-
--- some differing length/exponent cases
-ddcom100 compare 7.0 7.0 -> 0
-ddcom101 compare 7.0 7 -> 0
-ddcom102 compare 7 7.0 -> 0
-ddcom103 compare 7E+0 7.0 -> 0
-ddcom104 compare 70E-1 7.0 -> 0
-ddcom105 compare 0.7E+1 7 -> 0
-ddcom106 compare 70E-1 7 -> 0
-ddcom107 compare 7.0 7E+0 -> 0
-ddcom108 compare 7.0 70E-1 -> 0
-ddcom109 compare 7 0.7E+1 -> 0
-ddcom110 compare 7 70E-1 -> 0
-
-ddcom120 compare 8.0 7.0 -> 1
-ddcom121 compare 8.0 7 -> 1
-ddcom122 compare 8 7.0 -> 1
-ddcom123 compare 8E+0 7.0 -> 1
-ddcom124 compare 80E-1 7.0 -> 1
-ddcom125 compare 0.8E+1 7 -> 1
-ddcom126 compare 80E-1 7 -> 1
-ddcom127 compare 8.0 7E+0 -> 1
-ddcom128 compare 8.0 70E-1 -> 1
-ddcom129 compare 8 0.7E+1 -> 1
-ddcom130 compare 8 70E-1 -> 1
-
-ddcom140 compare 8.0 9.0 -> -1
-ddcom141 compare 8.0 9 -> -1
-ddcom142 compare 8 9.0 -> -1
-ddcom143 compare 8E+0 9.0 -> -1
-ddcom144 compare 80E-1 9.0 -> -1
-ddcom145 compare 0.8E+1 9 -> -1
-ddcom146 compare 80E-1 9 -> -1
-ddcom147 compare 8.0 9E+0 -> -1
-ddcom148 compare 8.0 90E-1 -> -1
-ddcom149 compare 8 0.9E+1 -> -1
-ddcom150 compare 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcom200 compare -7.0 7.0 -> -1
-ddcom201 compare -7.0 7 -> -1
-ddcom202 compare -7 7.0 -> -1
-ddcom203 compare -7E+0 7.0 -> -1
-ddcom204 compare -70E-1 7.0 -> -1
-ddcom205 compare -0.7E+1 7 -> -1
-ddcom206 compare -70E-1 7 -> -1
-ddcom207 compare -7.0 7E+0 -> -1
-ddcom208 compare -7.0 70E-1 -> -1
-ddcom209 compare -7 0.7E+1 -> -1
-ddcom210 compare -7 70E-1 -> -1
-
-ddcom220 compare -8.0 7.0 -> -1
-ddcom221 compare -8.0 7 -> -1
-ddcom222 compare -8 7.0 -> -1
-ddcom223 compare -8E+0 7.0 -> -1
-ddcom224 compare -80E-1 7.0 -> -1
-ddcom225 compare -0.8E+1 7 -> -1
-ddcom226 compare -80E-1 7 -> -1
-ddcom227 compare -8.0 7E+0 -> -1
-ddcom228 compare -8.0 70E-1 -> -1
-ddcom229 compare -8 0.7E+1 -> -1
-ddcom230 compare -8 70E-1 -> -1
-
-ddcom240 compare -8.0 9.0 -> -1
-ddcom241 compare -8.0 9 -> -1
-ddcom242 compare -8 9.0 -> -1
-ddcom243 compare -8E+0 9.0 -> -1
-ddcom244 compare -80E-1 9.0 -> -1
-ddcom245 compare -0.8E+1 9 -> -1
-ddcom246 compare -80E-1 9 -> -1
-ddcom247 compare -8.0 9E+0 -> -1
-ddcom248 compare -8.0 90E-1 -> -1
-ddcom249 compare -8 0.9E+1 -> -1
-ddcom250 compare -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcom300 compare 7.0 -7.0 -> 1
-ddcom301 compare 7.0 -7 -> 1
-ddcom302 compare 7 -7.0 -> 1
-ddcom303 compare 7E+0 -7.0 -> 1
-ddcom304 compare 70E-1 -7.0 -> 1
-ddcom305 compare .7E+1 -7 -> 1
-ddcom306 compare 70E-1 -7 -> 1
-ddcom307 compare 7.0 -7E+0 -> 1
-ddcom308 compare 7.0 -70E-1 -> 1
-ddcom309 compare 7 -.7E+1 -> 1
-ddcom310 compare 7 -70E-1 -> 1
-
-ddcom320 compare 8.0 -7.0 -> 1
-ddcom321 compare 8.0 -7 -> 1
-ddcom322 compare 8 -7.0 -> 1
-ddcom323 compare 8E+0 -7.0 -> 1
-ddcom324 compare 80E-1 -7.0 -> 1
-ddcom325 compare .8E+1 -7 -> 1
-ddcom326 compare 80E-1 -7 -> 1
-ddcom327 compare 8.0 -7E+0 -> 1
-ddcom328 compare 8.0 -70E-1 -> 1
-ddcom329 compare 8 -.7E+1 -> 1
-ddcom330 compare 8 -70E-1 -> 1
-
-ddcom340 compare 8.0 -9.0 -> 1
-ddcom341 compare 8.0 -9 -> 1
-ddcom342 compare 8 -9.0 -> 1
-ddcom343 compare 8E+0 -9.0 -> 1
-ddcom344 compare 80E-1 -9.0 -> 1
-ddcom345 compare .8E+1 -9 -> 1
-ddcom346 compare 80E-1 -9 -> 1
-ddcom347 compare 8.0 -9E+0 -> 1
-ddcom348 compare 8.0 -90E-1 -> 1
-ddcom349 compare 8 -.9E+1 -> 1
-ddcom350 compare 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcom400 compare -7.0 -7.0 -> 0
-ddcom401 compare -7.0 -7 -> 0
-ddcom402 compare -7 -7.0 -> 0
-ddcom403 compare -7E+0 -7.0 -> 0
-ddcom404 compare -70E-1 -7.0 -> 0
-ddcom405 compare -.7E+1 -7 -> 0
-ddcom406 compare -70E-1 -7 -> 0
-ddcom407 compare -7.0 -7E+0 -> 0
-ddcom408 compare -7.0 -70E-1 -> 0
-ddcom409 compare -7 -.7E+1 -> 0
-ddcom410 compare -7 -70E-1 -> 0
-
-ddcom420 compare -8.0 -7.0 -> -1
-ddcom421 compare -8.0 -7 -> -1
-ddcom422 compare -8 -7.0 -> -1
-ddcom423 compare -8E+0 -7.0 -> -1
-ddcom424 compare -80E-1 -7.0 -> -1
-ddcom425 compare -.8E+1 -7 -> -1
-ddcom426 compare -80E-1 -7 -> -1
-ddcom427 compare -8.0 -7E+0 -> -1
-ddcom428 compare -8.0 -70E-1 -> -1
-ddcom429 compare -8 -.7E+1 -> -1
-ddcom430 compare -8 -70E-1 -> -1
-
-ddcom440 compare -8.0 -9.0 -> 1
-ddcom441 compare -8.0 -9 -> 1
-ddcom442 compare -8 -9.0 -> 1
-ddcom443 compare -8E+0 -9.0 -> 1
-ddcom444 compare -80E-1 -9.0 -> 1
-ddcom445 compare -.8E+1 -9 -> 1
-ddcom446 compare -80E-1 -9 -> 1
-ddcom447 compare -8.0 -9E+0 -> 1
-ddcom448 compare -8.0 -90E-1 -> 1
-ddcom449 compare -8 -.9E+1 -> 1
-ddcom450 compare -8 -90E-1 -> 1
-
--- misalignment traps for little-endian
-ddcom451 compare 1.0 0.1 -> 1
-ddcom452 compare 0.1 1.0 -> -1
-ddcom453 compare 10.0 0.1 -> 1
-ddcom454 compare 0.1 10.0 -> -1
-ddcom455 compare 100 1.0 -> 1
-ddcom456 compare 1.0 100 -> -1
-ddcom457 compare 1000 10.0 -> 1
-ddcom458 compare 10.0 1000 -> -1
-ddcom459 compare 10000 100.0 -> 1
-ddcom460 compare 100.0 10000 -> -1
-ddcom461 compare 100000 1000.0 -> 1
-ddcom462 compare 1000.0 100000 -> -1
-ddcom463 compare 1000000 10000.0 -> 1
-ddcom464 compare 10000.0 1000000 -> -1
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
-ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
-ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
-ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
-ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
-ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
-ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
-ddcom480 compare 123.456000E+89 123.456E+89 -> 0
-ddcom481 compare 123.45600E-89 123.456E-89 -> 0
-ddcom482 compare 123.4560E+89 123.456E+89 -> 0
-ddcom483 compare 123.456E-89 123.456E-89 -> 0
-ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
-ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
-ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
-ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
-ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
-ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
-ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
-ddcom494 compare 123.456E-89 123.456000E-89 -> 0
-ddcom495 compare 123.456E+89 123.45600E+89 -> 0
-ddcom496 compare 123.456E-89 123.4560E-89 -> 0
-ddcom497 compare 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcom500 compare 1 1E-15 -> 1
-ddcom501 compare 1 1E-14 -> 1
-ddcom502 compare 1 1E-13 -> 1
-ddcom503 compare 1 1E-12 -> 1
-ddcom504 compare 1 1E-11 -> 1
-ddcom505 compare 1 1E-10 -> 1
-ddcom506 compare 1 1E-9 -> 1
-ddcom507 compare 1 1E-8 -> 1
-ddcom508 compare 1 1E-7 -> 1
-ddcom509 compare 1 1E-6 -> 1
-ddcom510 compare 1 1E-5 -> 1
-ddcom511 compare 1 1E-4 -> 1
-ddcom512 compare 1 1E-3 -> 1
-ddcom513 compare 1 1E-2 -> 1
-ddcom514 compare 1 1E-1 -> 1
-ddcom515 compare 1 1E-0 -> 0
-ddcom516 compare 1 1E+1 -> -1
-ddcom517 compare 1 1E+2 -> -1
-ddcom518 compare 1 1E+3 -> -1
-ddcom519 compare 1 1E+4 -> -1
-ddcom521 compare 1 1E+5 -> -1
-ddcom522 compare 1 1E+6 -> -1
-ddcom523 compare 1 1E+7 -> -1
-ddcom524 compare 1 1E+8 -> -1
-ddcom525 compare 1 1E+9 -> -1
-ddcom526 compare 1 1E+10 -> -1
-ddcom527 compare 1 1E+11 -> -1
-ddcom528 compare 1 1E+12 -> -1
-ddcom529 compare 1 1E+13 -> -1
-ddcom530 compare 1 1E+14 -> -1
-ddcom531 compare 1 1E+15 -> -1
--- LR swap
-ddcom540 compare 1E-15 1 -> -1
-ddcom541 compare 1E-14 1 -> -1
-ddcom542 compare 1E-13 1 -> -1
-ddcom543 compare 1E-12 1 -> -1
-ddcom544 compare 1E-11 1 -> -1
-ddcom545 compare 1E-10 1 -> -1
-ddcom546 compare 1E-9 1 -> -1
-ddcom547 compare 1E-8 1 -> -1
-ddcom548 compare 1E-7 1 -> -1
-ddcom549 compare 1E-6 1 -> -1
-ddcom550 compare 1E-5 1 -> -1
-ddcom551 compare 1E-4 1 -> -1
-ddcom552 compare 1E-3 1 -> -1
-ddcom553 compare 1E-2 1 -> -1
-ddcom554 compare 1E-1 1 -> -1
-ddcom555 compare 1E-0 1 -> 0
-ddcom556 compare 1E+1 1 -> 1
-ddcom557 compare 1E+2 1 -> 1
-ddcom558 compare 1E+3 1 -> 1
-ddcom559 compare 1E+4 1 -> 1
-ddcom561 compare 1E+5 1 -> 1
-ddcom562 compare 1E+6 1 -> 1
-ddcom563 compare 1E+7 1 -> 1
-ddcom564 compare 1E+8 1 -> 1
-ddcom565 compare 1E+9 1 -> 1
-ddcom566 compare 1E+10 1 -> 1
-ddcom567 compare 1E+11 1 -> 1
-ddcom568 compare 1E+12 1 -> 1
-ddcom569 compare 1E+13 1 -> 1
-ddcom570 compare 1E+14 1 -> 1
-ddcom571 compare 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-ddcom580 compare 0.000000987654321 1E-15 -> 1
-ddcom581 compare 0.000000987654321 1E-14 -> 1
-ddcom582 compare 0.000000987654321 1E-13 -> 1
-ddcom583 compare 0.000000987654321 1E-12 -> 1
-ddcom584 compare 0.000000987654321 1E-11 -> 1
-ddcom585 compare 0.000000987654321 1E-10 -> 1
-ddcom586 compare 0.000000987654321 1E-9 -> 1
-ddcom587 compare 0.000000987654321 1E-8 -> 1
-ddcom588 compare 0.000000987654321 1E-7 -> 1
-ddcom589 compare 0.000000987654321 1E-6 -> -1
-ddcom590 compare 0.000000987654321 1E-5 -> -1
-ddcom591 compare 0.000000987654321 1E-4 -> -1
-ddcom592 compare 0.000000987654321 1E-3 -> -1
-ddcom593 compare 0.000000987654321 1E-2 -> -1
-ddcom594 compare 0.000000987654321 1E-1 -> -1
-ddcom595 compare 0.000000987654321 1E-0 -> -1
-ddcom596 compare 0.000000987654321 1E+1 -> -1
-ddcom597 compare 0.000000987654321 1E+2 -> -1
-ddcom598 compare 0.000000987654321 1E+3 -> -1
-ddcom599 compare 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcom600 compare 12 12.2345 -> -1
-ddcom601 compare 12.0 12.2345 -> -1
-ddcom602 compare 12.00 12.2345 -> -1
-ddcom603 compare 12.000 12.2345 -> -1
-ddcom604 compare 12.0000 12.2345 -> -1
-ddcom605 compare 12.00000 12.2345 -> -1
-ddcom606 compare 12.000000 12.2345 -> -1
-ddcom607 compare 12.0000000 12.2345 -> -1
-ddcom608 compare 12.00000000 12.2345 -> -1
-ddcom609 compare 12.000000000 12.2345 -> -1
-ddcom610 compare 12.1234 12 -> 1
-ddcom611 compare 12.1234 12.0 -> 1
-ddcom612 compare 12.1234 12.00 -> 1
-ddcom613 compare 12.1234 12.000 -> 1
-ddcom614 compare 12.1234 12.0000 -> 1
-ddcom615 compare 12.1234 12.00000 -> 1
-ddcom616 compare 12.1234 12.000000 -> 1
-ddcom617 compare 12.1234 12.0000000 -> 1
-ddcom618 compare 12.1234 12.00000000 -> 1
-ddcom619 compare 12.1234 12.000000000 -> 1
-ddcom620 compare -12 -12.2345 -> 1
-ddcom621 compare -12.0 -12.2345 -> 1
-ddcom622 compare -12.00 -12.2345 -> 1
-ddcom623 compare -12.000 -12.2345 -> 1
-ddcom624 compare -12.0000 -12.2345 -> 1
-ddcom625 compare -12.00000 -12.2345 -> 1
-ddcom626 compare -12.000000 -12.2345 -> 1
-ddcom627 compare -12.0000000 -12.2345 -> 1
-ddcom628 compare -12.00000000 -12.2345 -> 1
-ddcom629 compare -12.000000000 -12.2345 -> 1
-ddcom630 compare -12.1234 -12 -> -1
-ddcom631 compare -12.1234 -12.0 -> -1
-ddcom632 compare -12.1234 -12.00 -> -1
-ddcom633 compare -12.1234 -12.000 -> -1
-ddcom634 compare -12.1234 -12.0000 -> -1
-ddcom635 compare -12.1234 -12.00000 -> -1
-ddcom636 compare -12.1234 -12.000000 -> -1
-ddcom637 compare -12.1234 -12.0000000 -> -1
-ddcom638 compare -12.1234 -12.00000000 -> -1
-ddcom639 compare -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcom640 compare 0 0 -> 0
-ddcom641 compare 0 -0 -> 0
-ddcom642 compare 0 -0.0 -> 0
-ddcom643 compare 0 0.0 -> 0
-ddcom644 compare -0 0 -> 0
-ddcom645 compare -0 -0 -> 0
-ddcom646 compare -0 -0.0 -> 0
-ddcom647 compare -0 0.0 -> 0
-ddcom648 compare 0.0 0 -> 0
-ddcom649 compare 0.0 -0 -> 0
-ddcom650 compare 0.0 -0.0 -> 0
-ddcom651 compare 0.0 0.0 -> 0
-ddcom652 compare -0.0 0 -> 0
-ddcom653 compare -0.0 -0 -> 0
-ddcom654 compare -0.0 -0.0 -> 0
-ddcom655 compare -0.0 0.0 -> 0
-
-ddcom656 compare -0E1 0.0 -> 0
-ddcom657 compare -0E2 0.0 -> 0
-ddcom658 compare 0E1 0.0 -> 0
-ddcom659 compare 0E2 0.0 -> 0
-ddcom660 compare -0E1 0 -> 0
-ddcom661 compare -0E2 0 -> 0
-ddcom662 compare 0E1 0 -> 0
-ddcom663 compare 0E2 0 -> 0
-ddcom664 compare -0E1 -0E1 -> 0
-ddcom665 compare -0E2 -0E1 -> 0
-ddcom666 compare 0E1 -0E1 -> 0
-ddcom667 compare 0E2 -0E1 -> 0
-ddcom668 compare -0E1 -0E2 -> 0
-ddcom669 compare -0E2 -0E2 -> 0
-ddcom670 compare 0E1 -0E2 -> 0
-ddcom671 compare 0E2 -0E2 -> 0
-ddcom672 compare -0E1 0E1 -> 0
-ddcom673 compare -0E2 0E1 -> 0
-ddcom674 compare 0E1 0E1 -> 0
-ddcom675 compare 0E2 0E1 -> 0
-ddcom676 compare -0E1 0E2 -> 0
-ddcom677 compare -0E2 0E2 -> 0
-ddcom678 compare 0E1 0E2 -> 0
-ddcom679 compare 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcom680 compare 12 12 -> 0
-ddcom681 compare 12 12.0 -> 0
-ddcom682 compare 12 12.00 -> 0
-ddcom683 compare 12 12.000 -> 0
-ddcom684 compare 12 12.0000 -> 0
-ddcom685 compare 12 12.00000 -> 0
-ddcom686 compare 12 12.000000 -> 0
-ddcom687 compare 12 12.0000000 -> 0
-ddcom688 compare 12 12.00000000 -> 0
-ddcom689 compare 12 12.000000000 -> 0
-ddcom690 compare 12 12 -> 0
-ddcom691 compare 12.0 12 -> 0
-ddcom692 compare 12.00 12 -> 0
-ddcom693 compare 12.000 12 -> 0
-ddcom694 compare 12.0000 12 -> 0
-ddcom695 compare 12.00000 12 -> 0
-ddcom696 compare 12.000000 12 -> 0
-ddcom697 compare 12.0000000 12 -> 0
-ddcom698 compare 12.00000000 12 -> 0
-ddcom699 compare 12.000000000 12 -> 0
-
--- first, second, & last digit
-ddcom700 compare 1234567890123456 1234567890123455 -> 1
-ddcom701 compare 1234567890123456 1234567890123456 -> 0
-ddcom702 compare 1234567890123456 1234567890123457 -> -1
-ddcom703 compare 1234567890123456 0234567890123456 -> 1
-ddcom704 compare 1234567890123456 1234567890123456 -> 0
-ddcom705 compare 1234567890123456 2234567890123456 -> -1
-ddcom706 compare 1134567890123456 1034567890123456 -> 1
-ddcom707 compare 1134567890123456 1134567890123456 -> 0
-ddcom708 compare 1134567890123456 1234567890123456 -> -1
-
--- miscellaneous
-ddcom721 compare 12345678000 1 -> 1
-ddcom722 compare 1 12345678000 -> -1
-ddcom723 compare 1234567800 1 -> 1
-ddcom724 compare 1 1234567800 -> -1
-ddcom725 compare 1234567890 1 -> 1
-ddcom726 compare 1 1234567890 -> -1
-ddcom727 compare 1234567891 1 -> 1
-ddcom728 compare 1 1234567891 -> -1
-ddcom729 compare 12345678901 1 -> 1
-ddcom730 compare 1 12345678901 -> -1
-ddcom731 compare 1234567896 1 -> 1
-ddcom732 compare 1 1234567896 -> -1
-
--- residue cases at lower precision
-ddcom740 compare 1 0.9999999 -> 1
-ddcom741 compare 1 0.999999 -> 1
-ddcom742 compare 1 0.99999 -> 1
-ddcom743 compare 1 1.0000 -> 0
-ddcom744 compare 1 1.00001 -> -1
-ddcom745 compare 1 1.000001 -> -1
-ddcom746 compare 1 1.0000001 -> -1
-ddcom750 compare 0.9999999 1 -> -1
-ddcom751 compare 0.999999 1 -> -1
-ddcom752 compare 0.99999 1 -> -1
-ddcom753 compare 1.0000 1 -> 0
-ddcom754 compare 1.00001 1 -> 1
-ddcom755 compare 1.000001 1 -> 1
-ddcom756 compare 1.0000001 1 -> 1
-
--- Specials
-ddcom780 compare Inf -Inf -> 1
-ddcom781 compare Inf -1000 -> 1
-ddcom782 compare Inf -1 -> 1
-ddcom783 compare Inf -0 -> 1
-ddcom784 compare Inf 0 -> 1
-ddcom785 compare Inf 1 -> 1
-ddcom786 compare Inf 1000 -> 1
-ddcom787 compare Inf Inf -> 0
-ddcom788 compare -1000 Inf -> -1
-ddcom789 compare -Inf Inf -> -1
-ddcom790 compare -1 Inf -> -1
-ddcom791 compare -0 Inf -> -1
-ddcom792 compare 0 Inf -> -1
-ddcom793 compare 1 Inf -> -1
-ddcom794 compare 1000 Inf -> -1
-ddcom795 compare Inf Inf -> 0
-
-ddcom800 compare -Inf -Inf -> 0
-ddcom801 compare -Inf -1000 -> -1
-ddcom802 compare -Inf -1 -> -1
-ddcom803 compare -Inf -0 -> -1
-ddcom804 compare -Inf 0 -> -1
-ddcom805 compare -Inf 1 -> -1
-ddcom806 compare -Inf 1000 -> -1
-ddcom807 compare -Inf Inf -> -1
-ddcom808 compare -Inf -Inf -> 0
-ddcom809 compare -1000 -Inf -> 1
-ddcom810 compare -1 -Inf -> 1
-ddcom811 compare -0 -Inf -> 1
-ddcom812 compare 0 -Inf -> 1
-ddcom813 compare 1 -Inf -> 1
-ddcom814 compare 1000 -Inf -> 1
-ddcom815 compare Inf -Inf -> 1
-
-ddcom821 compare NaN -Inf -> NaN
-ddcom822 compare NaN -1000 -> NaN
-ddcom823 compare NaN -1 -> NaN
-ddcom824 compare NaN -0 -> NaN
-ddcom825 compare NaN 0 -> NaN
-ddcom826 compare NaN 1 -> NaN
-ddcom827 compare NaN 1000 -> NaN
-ddcom828 compare NaN Inf -> NaN
-ddcom829 compare NaN NaN -> NaN
-ddcom830 compare -Inf NaN -> NaN
-ddcom831 compare -1000 NaN -> NaN
-ddcom832 compare -1 NaN -> NaN
-ddcom833 compare -0 NaN -> NaN
-ddcom834 compare 0 NaN -> NaN
-ddcom835 compare 1 NaN -> NaN
-ddcom836 compare 1000 NaN -> NaN
-ddcom837 compare Inf NaN -> NaN
-ddcom838 compare -NaN -NaN -> -NaN
-ddcom839 compare +NaN -NaN -> NaN
-ddcom840 compare -NaN +NaN -> -NaN
-
-ddcom841 compare sNaN -Inf -> NaN Invalid_operation
-ddcom842 compare sNaN -1000 -> NaN Invalid_operation
-ddcom843 compare sNaN -1 -> NaN Invalid_operation
-ddcom844 compare sNaN -0 -> NaN Invalid_operation
-ddcom845 compare sNaN 0 -> NaN Invalid_operation
-ddcom846 compare sNaN 1 -> NaN Invalid_operation
-ddcom847 compare sNaN 1000 -> NaN Invalid_operation
-ddcom848 compare sNaN NaN -> NaN Invalid_operation
-ddcom849 compare sNaN sNaN -> NaN Invalid_operation
-ddcom850 compare NaN sNaN -> NaN Invalid_operation
-ddcom851 compare -Inf sNaN -> NaN Invalid_operation
-ddcom852 compare -1000 sNaN -> NaN Invalid_operation
-ddcom853 compare -1 sNaN -> NaN Invalid_operation
-ddcom854 compare -0 sNaN -> NaN Invalid_operation
-ddcom855 compare 0 sNaN -> NaN Invalid_operation
-ddcom856 compare 1 sNaN -> NaN Invalid_operation
-ddcom857 compare 1000 sNaN -> NaN Invalid_operation
-ddcom858 compare Inf sNaN -> NaN Invalid_operation
-ddcom859 compare NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddcom860 compare NaN9 -Inf -> NaN9
-ddcom861 compare NaN8 999 -> NaN8
-ddcom862 compare NaN77 Inf -> NaN77
-ddcom863 compare -NaN67 NaN5 -> -NaN67
-ddcom864 compare -Inf -NaN4 -> -NaN4
-ddcom865 compare -999 -NaN33 -> -NaN33
-ddcom866 compare Inf NaN2 -> NaN2
-ddcom867 compare -NaN41 -NaN42 -> -NaN41
-ddcom868 compare +NaN41 -NaN42 -> NaN41
-ddcom869 compare -NaN41 +NaN42 -> -NaN41
-ddcom870 compare +NaN41 +NaN42 -> NaN41
-
-ddcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
-ddcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
-ddcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
-ddcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
-ddcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
-ddcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
-ddcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
-ddcom881 compare 9E+384 +1.23456789012345E-0 -> 1
-ddcom882 compare +0.100 9E-383 -> 1
-ddcom883 compare 9E-383 +0.100 -> -1
-ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
-ddcom886 compare 9E+384 -1.23456789012345E-0 -> 1
-ddcom887 compare -0.100 9E-383 -> -1
-ddcom888 compare 9E-383 -0.100 -> 1
-
--- spread zeros
-ddcom900 compare 0E-383 0 -> 0
-ddcom901 compare 0E-383 -0 -> 0
-ddcom902 compare -0E-383 0 -> 0
-ddcom903 compare -0E-383 -0 -> 0
-ddcom904 compare 0E-383 0E+384 -> 0
-ddcom905 compare 0E-383 -0E+384 -> 0
-ddcom906 compare -0E-383 0E+384 -> 0
-ddcom907 compare -0E-383 -0E+384 -> 0
-ddcom908 compare 0 0E+384 -> 0
-ddcom909 compare 0 -0E+384 -> 0
-ddcom910 compare -0 0E+384 -> 0
-ddcom911 compare -0 -0E+384 -> 0
-ddcom930 compare 0E+384 0 -> 0
-ddcom931 compare 0E+384 -0 -> 0
-ddcom932 compare -0E+384 0 -> 0
-ddcom933 compare -0E+384 -0 -> 0
-ddcom934 compare 0E+384 0E-383 -> 0
-ddcom935 compare 0E+384 -0E-383 -> 0
-ddcom936 compare -0E+384 0E-383 -> 0
-ddcom937 compare -0E+384 -0E-383 -> 0
-ddcom938 compare 0 0E-383 -> 0
-ddcom939 compare 0 -0E-383 -> 0
-ddcom940 compare -0 0E-383 -> 0
-ddcom941 compare -0 -0E-383 -> 0
-
--- signs
-ddcom961 compare 1e+77 1e+11 -> 1
-ddcom962 compare 1e+77 -1e+11 -> 1
-ddcom963 compare -1e+77 1e+11 -> -1
-ddcom964 compare -1e+77 -1e+11 -> -1
-ddcom965 compare 1e-77 1e-11 -> -1
-ddcom966 compare 1e-77 -1e-11 -> 1
-ddcom967 compare -1e-77 1e-11 -> -1
-ddcom968 compare -1e-77 -1e-11 -> 1
-
--- full alignment range, both ways
-ddcomp1001 compare 1 1.000000000000000 -> 0
-ddcomp1002 compare 1 1.00000000000000 -> 0
-ddcomp1003 compare 1 1.0000000000000 -> 0
-ddcomp1004 compare 1 1.000000000000 -> 0
-ddcomp1005 compare 1 1.00000000000 -> 0
-ddcomp1006 compare 1 1.0000000000 -> 0
-ddcomp1007 compare 1 1.000000000 -> 0
-ddcomp1008 compare 1 1.00000000 -> 0
-ddcomp1009 compare 1 1.0000000 -> 0
-ddcomp1010 compare 1 1.000000 -> 0
-ddcomp1011 compare 1 1.00000 -> 0
-ddcomp1012 compare 1 1.0000 -> 0
-ddcomp1013 compare 1 1.000 -> 0
-ddcomp1014 compare 1 1.00 -> 0
-ddcomp1015 compare 1 1.0 -> 0
-ddcomp1021 compare 1.000000000000000 1 -> 0
-ddcomp1022 compare 1.00000000000000 1 -> 0
-ddcomp1023 compare 1.0000000000000 1 -> 0
-ddcomp1024 compare 1.000000000000 1 -> 0
-ddcomp1025 compare 1.00000000000 1 -> 0
-ddcomp1026 compare 1.0000000000 1 -> 0
-ddcomp1027 compare 1.000000000 1 -> 0
-ddcomp1028 compare 1.00000000 1 -> 0
-ddcomp1029 compare 1.0000000 1 -> 0
-ddcomp1030 compare 1.000000 1 -> 0
-ddcomp1031 compare 1.00000 1 -> 0
-ddcomp1032 compare 1.0000 1 -> 0
-ddcomp1033 compare 1.000 1 -> 0
-ddcomp1034 compare 1.00 1 -> 0
-ddcomp1035 compare 1.0 1 -> 0
-
--- check MSD always detected non-zero
-ddcomp1040 compare 0 0.000000000000000 -> 0
-ddcomp1041 compare 0 1.000000000000000 -> -1
-ddcomp1042 compare 0 2.000000000000000 -> -1
-ddcomp1043 compare 0 3.000000000000000 -> -1
-ddcomp1044 compare 0 4.000000000000000 -> -1
-ddcomp1045 compare 0 5.000000000000000 -> -1
-ddcomp1046 compare 0 6.000000000000000 -> -1
-ddcomp1047 compare 0 7.000000000000000 -> -1
-ddcomp1048 compare 0 8.000000000000000 -> -1
-ddcomp1049 compare 0 9.000000000000000 -> -1
-ddcomp1050 compare 0.000000000000000 0 -> 0
-ddcomp1051 compare 1.000000000000000 0 -> 1
-ddcomp1052 compare 2.000000000000000 0 -> 1
-ddcomp1053 compare 3.000000000000000 0 -> 1
-ddcomp1054 compare 4.000000000000000 0 -> 1
-ddcomp1055 compare 5.000000000000000 0 -> 1
-ddcomp1056 compare 6.000000000000000 0 -> 1
-ddcomp1057 compare 7.000000000000000 0 -> 1
-ddcomp1058 compare 8.000000000000000 0 -> 1
-ddcomp1059 compare 9.000000000000000 0 -> 1
-
--- Null tests
-ddcom9990 compare 10 # -> NaN Invalid_operation
-ddcom9991 compare # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompare.decTest -- decDouble comparison that allows quiet NaNs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcom001 compare -2 -2 -> 0
+ddcom002 compare -2 -1 -> -1
+ddcom003 compare -2 0 -> -1
+ddcom004 compare -2 1 -> -1
+ddcom005 compare -2 2 -> -1
+ddcom006 compare -1 -2 -> 1
+ddcom007 compare -1 -1 -> 0
+ddcom008 compare -1 0 -> -1
+ddcom009 compare -1 1 -> -1
+ddcom010 compare -1 2 -> -1
+ddcom011 compare 0 -2 -> 1
+ddcom012 compare 0 -1 -> 1
+ddcom013 compare 0 0 -> 0
+ddcom014 compare 0 1 -> -1
+ddcom015 compare 0 2 -> -1
+ddcom016 compare 1 -2 -> 1
+ddcom017 compare 1 -1 -> 1
+ddcom018 compare 1 0 -> 1
+ddcom019 compare 1 1 -> 0
+ddcom020 compare 1 2 -> -1
+ddcom021 compare 2 -2 -> 1
+ddcom022 compare 2 -1 -> 1
+ddcom023 compare 2 0 -> 1
+ddcom025 compare 2 1 -> 1
+ddcom026 compare 2 2 -> 0
+
+ddcom031 compare -20 -20 -> 0
+ddcom032 compare -20 -10 -> -1
+ddcom033 compare -20 00 -> -1
+ddcom034 compare -20 10 -> -1
+ddcom035 compare -20 20 -> -1
+ddcom036 compare -10 -20 -> 1
+ddcom037 compare -10 -10 -> 0
+ddcom038 compare -10 00 -> -1
+ddcom039 compare -10 10 -> -1
+ddcom040 compare -10 20 -> -1
+ddcom041 compare 00 -20 -> 1
+ddcom042 compare 00 -10 -> 1
+ddcom043 compare 00 00 -> 0
+ddcom044 compare 00 10 -> -1
+ddcom045 compare 00 20 -> -1
+ddcom046 compare 10 -20 -> 1
+ddcom047 compare 10 -10 -> 1
+ddcom048 compare 10 00 -> 1
+ddcom049 compare 10 10 -> 0
+ddcom050 compare 10 20 -> -1
+ddcom051 compare 20 -20 -> 1
+ddcom052 compare 20 -10 -> 1
+ddcom053 compare 20 00 -> 1
+ddcom055 compare 20 10 -> 1
+ddcom056 compare 20 20 -> 0
+
+ddcom061 compare -2.0 -2.0 -> 0
+ddcom062 compare -2.0 -1.0 -> -1
+ddcom063 compare -2.0 0.0 -> -1
+ddcom064 compare -2.0 1.0 -> -1
+ddcom065 compare -2.0 2.0 -> -1
+ddcom066 compare -1.0 -2.0 -> 1
+ddcom067 compare -1.0 -1.0 -> 0
+ddcom068 compare -1.0 0.0 -> -1
+ddcom069 compare -1.0 1.0 -> -1
+ddcom070 compare -1.0 2.0 -> -1
+ddcom071 compare 0.0 -2.0 -> 1
+ddcom072 compare 0.0 -1.0 -> 1
+ddcom073 compare 0.0 0.0 -> 0
+ddcom074 compare 0.0 1.0 -> -1
+ddcom075 compare 0.0 2.0 -> -1
+ddcom076 compare 1.0 -2.0 -> 1
+ddcom077 compare 1.0 -1.0 -> 1
+ddcom078 compare 1.0 0.0 -> 1
+ddcom079 compare 1.0 1.0 -> 0
+ddcom080 compare 1.0 2.0 -> -1
+ddcom081 compare 2.0 -2.0 -> 1
+ddcom082 compare 2.0 -1.0 -> 1
+ddcom083 compare 2.0 0.0 -> 1
+ddcom085 compare 2.0 1.0 -> 1
+ddcom086 compare 2.0 2.0 -> 0
+ddcom087 compare 1.0 0.1 -> 1
+ddcom088 compare 0.1 1.0 -> -1
+
+-- now some cases which might overflow if subtract were used
+ddcom095 compare 9.999999999999999E+384 9.999999999999999E+384 -> 0
+ddcom096 compare -9.999999999999999E+384 9.999999999999999E+384 -> -1
+ddcom097 compare 9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddcom098 compare -9.999999999999999E+384 -9.999999999999999E+384 -> 0
+
+-- some differing length/exponent cases
+ddcom100 compare 7.0 7.0 -> 0
+ddcom101 compare 7.0 7 -> 0
+ddcom102 compare 7 7.0 -> 0
+ddcom103 compare 7E+0 7.0 -> 0
+ddcom104 compare 70E-1 7.0 -> 0
+ddcom105 compare 0.7E+1 7 -> 0
+ddcom106 compare 70E-1 7 -> 0
+ddcom107 compare 7.0 7E+0 -> 0
+ddcom108 compare 7.0 70E-1 -> 0
+ddcom109 compare 7 0.7E+1 -> 0
+ddcom110 compare 7 70E-1 -> 0
+
+ddcom120 compare 8.0 7.0 -> 1
+ddcom121 compare 8.0 7 -> 1
+ddcom122 compare 8 7.0 -> 1
+ddcom123 compare 8E+0 7.0 -> 1
+ddcom124 compare 80E-1 7.0 -> 1
+ddcom125 compare 0.8E+1 7 -> 1
+ddcom126 compare 80E-1 7 -> 1
+ddcom127 compare 8.0 7E+0 -> 1
+ddcom128 compare 8.0 70E-1 -> 1
+ddcom129 compare 8 0.7E+1 -> 1
+ddcom130 compare 8 70E-1 -> 1
+
+ddcom140 compare 8.0 9.0 -> -1
+ddcom141 compare 8.0 9 -> -1
+ddcom142 compare 8 9.0 -> -1
+ddcom143 compare 8E+0 9.0 -> -1
+ddcom144 compare 80E-1 9.0 -> -1
+ddcom145 compare 0.8E+1 9 -> -1
+ddcom146 compare 80E-1 9 -> -1
+ddcom147 compare 8.0 9E+0 -> -1
+ddcom148 compare 8.0 90E-1 -> -1
+ddcom149 compare 8 0.9E+1 -> -1
+ddcom150 compare 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcom200 compare -7.0 7.0 -> -1
+ddcom201 compare -7.0 7 -> -1
+ddcom202 compare -7 7.0 -> -1
+ddcom203 compare -7E+0 7.0 -> -1
+ddcom204 compare -70E-1 7.0 -> -1
+ddcom205 compare -0.7E+1 7 -> -1
+ddcom206 compare -70E-1 7 -> -1
+ddcom207 compare -7.0 7E+0 -> -1
+ddcom208 compare -7.0 70E-1 -> -1
+ddcom209 compare -7 0.7E+1 -> -1
+ddcom210 compare -7 70E-1 -> -1
+
+ddcom220 compare -8.0 7.0 -> -1
+ddcom221 compare -8.0 7 -> -1
+ddcom222 compare -8 7.0 -> -1
+ddcom223 compare -8E+0 7.0 -> -1
+ddcom224 compare -80E-1 7.0 -> -1
+ddcom225 compare -0.8E+1 7 -> -1
+ddcom226 compare -80E-1 7 -> -1
+ddcom227 compare -8.0 7E+0 -> -1
+ddcom228 compare -8.0 70E-1 -> -1
+ddcom229 compare -8 0.7E+1 -> -1
+ddcom230 compare -8 70E-1 -> -1
+
+ddcom240 compare -8.0 9.0 -> -1
+ddcom241 compare -8.0 9 -> -1
+ddcom242 compare -8 9.0 -> -1
+ddcom243 compare -8E+0 9.0 -> -1
+ddcom244 compare -80E-1 9.0 -> -1
+ddcom245 compare -0.8E+1 9 -> -1
+ddcom246 compare -80E-1 9 -> -1
+ddcom247 compare -8.0 9E+0 -> -1
+ddcom248 compare -8.0 90E-1 -> -1
+ddcom249 compare -8 0.9E+1 -> -1
+ddcom250 compare -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcom300 compare 7.0 -7.0 -> 1
+ddcom301 compare 7.0 -7 -> 1
+ddcom302 compare 7 -7.0 -> 1
+ddcom303 compare 7E+0 -7.0 -> 1
+ddcom304 compare 70E-1 -7.0 -> 1
+ddcom305 compare .7E+1 -7 -> 1
+ddcom306 compare 70E-1 -7 -> 1
+ddcom307 compare 7.0 -7E+0 -> 1
+ddcom308 compare 7.0 -70E-1 -> 1
+ddcom309 compare 7 -.7E+1 -> 1
+ddcom310 compare 7 -70E-1 -> 1
+
+ddcom320 compare 8.0 -7.0 -> 1
+ddcom321 compare 8.0 -7 -> 1
+ddcom322 compare 8 -7.0 -> 1
+ddcom323 compare 8E+0 -7.0 -> 1
+ddcom324 compare 80E-1 -7.0 -> 1
+ddcom325 compare .8E+1 -7 -> 1
+ddcom326 compare 80E-1 -7 -> 1
+ddcom327 compare 8.0 -7E+0 -> 1
+ddcom328 compare 8.0 -70E-1 -> 1
+ddcom329 compare 8 -.7E+1 -> 1
+ddcom330 compare 8 -70E-1 -> 1
+
+ddcom340 compare 8.0 -9.0 -> 1
+ddcom341 compare 8.0 -9 -> 1
+ddcom342 compare 8 -9.0 -> 1
+ddcom343 compare 8E+0 -9.0 -> 1
+ddcom344 compare 80E-1 -9.0 -> 1
+ddcom345 compare .8E+1 -9 -> 1
+ddcom346 compare 80E-1 -9 -> 1
+ddcom347 compare 8.0 -9E+0 -> 1
+ddcom348 compare 8.0 -90E-1 -> 1
+ddcom349 compare 8 -.9E+1 -> 1
+ddcom350 compare 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcom400 compare -7.0 -7.0 -> 0
+ddcom401 compare -7.0 -7 -> 0
+ddcom402 compare -7 -7.0 -> 0
+ddcom403 compare -7E+0 -7.0 -> 0
+ddcom404 compare -70E-1 -7.0 -> 0
+ddcom405 compare -.7E+1 -7 -> 0
+ddcom406 compare -70E-1 -7 -> 0
+ddcom407 compare -7.0 -7E+0 -> 0
+ddcom408 compare -7.0 -70E-1 -> 0
+ddcom409 compare -7 -.7E+1 -> 0
+ddcom410 compare -7 -70E-1 -> 0
+
+ddcom420 compare -8.0 -7.0 -> -1
+ddcom421 compare -8.0 -7 -> -1
+ddcom422 compare -8 -7.0 -> -1
+ddcom423 compare -8E+0 -7.0 -> -1
+ddcom424 compare -80E-1 -7.0 -> -1
+ddcom425 compare -.8E+1 -7 -> -1
+ddcom426 compare -80E-1 -7 -> -1
+ddcom427 compare -8.0 -7E+0 -> -1
+ddcom428 compare -8.0 -70E-1 -> -1
+ddcom429 compare -8 -.7E+1 -> -1
+ddcom430 compare -8 -70E-1 -> -1
+
+ddcom440 compare -8.0 -9.0 -> 1
+ddcom441 compare -8.0 -9 -> 1
+ddcom442 compare -8 -9.0 -> 1
+ddcom443 compare -8E+0 -9.0 -> 1
+ddcom444 compare -80E-1 -9.0 -> 1
+ddcom445 compare -.8E+1 -9 -> 1
+ddcom446 compare -80E-1 -9 -> 1
+ddcom447 compare -8.0 -9E+0 -> 1
+ddcom448 compare -8.0 -90E-1 -> 1
+ddcom449 compare -8 -.9E+1 -> 1
+ddcom450 compare -8 -90E-1 -> 1
+
+-- misalignment traps for little-endian
+ddcom451 compare 1.0 0.1 -> 1
+ddcom452 compare 0.1 1.0 -> -1
+ddcom453 compare 10.0 0.1 -> 1
+ddcom454 compare 0.1 10.0 -> -1
+ddcom455 compare 100 1.0 -> 1
+ddcom456 compare 1.0 100 -> -1
+ddcom457 compare 1000 10.0 -> 1
+ddcom458 compare 10.0 1000 -> -1
+ddcom459 compare 10000 100.0 -> 1
+ddcom460 compare 100.0 10000 -> -1
+ddcom461 compare 100000 1000.0 -> 1
+ddcom462 compare 1000.0 100000 -> -1
+ddcom463 compare 1000000 10000.0 -> 1
+ddcom464 compare 10000.0 1000000 -> -1
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcom473 compare 123.4560000000000E-89 123.456E-89 -> 0
+ddcom474 compare 123.456000000000E+89 123.456E+89 -> 0
+ddcom475 compare 123.45600000000E-89 123.456E-89 -> 0
+ddcom476 compare 123.4560000000E+89 123.456E+89 -> 0
+ddcom477 compare 123.456000000E-89 123.456E-89 -> 0
+ddcom478 compare 123.45600000E+89 123.456E+89 -> 0
+ddcom479 compare 123.4560000E-89 123.456E-89 -> 0
+ddcom480 compare 123.456000E+89 123.456E+89 -> 0
+ddcom481 compare 123.45600E-89 123.456E-89 -> 0
+ddcom482 compare 123.4560E+89 123.456E+89 -> 0
+ddcom483 compare 123.456E-89 123.456E-89 -> 0
+ddcom487 compare 123.456E+89 123.4560000000000E+89 -> 0
+ddcom488 compare 123.456E-89 123.456000000000E-89 -> 0
+ddcom489 compare 123.456E+89 123.45600000000E+89 -> 0
+ddcom490 compare 123.456E-89 123.4560000000E-89 -> 0
+ddcom491 compare 123.456E+89 123.456000000E+89 -> 0
+ddcom492 compare 123.456E-89 123.45600000E-89 -> 0
+ddcom493 compare 123.456E+89 123.4560000E+89 -> 0
+ddcom494 compare 123.456E-89 123.456000E-89 -> 0
+ddcom495 compare 123.456E+89 123.45600E+89 -> 0
+ddcom496 compare 123.456E-89 123.4560E-89 -> 0
+ddcom497 compare 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcom500 compare 1 1E-15 -> 1
+ddcom501 compare 1 1E-14 -> 1
+ddcom502 compare 1 1E-13 -> 1
+ddcom503 compare 1 1E-12 -> 1
+ddcom504 compare 1 1E-11 -> 1
+ddcom505 compare 1 1E-10 -> 1
+ddcom506 compare 1 1E-9 -> 1
+ddcom507 compare 1 1E-8 -> 1
+ddcom508 compare 1 1E-7 -> 1
+ddcom509 compare 1 1E-6 -> 1
+ddcom510 compare 1 1E-5 -> 1
+ddcom511 compare 1 1E-4 -> 1
+ddcom512 compare 1 1E-3 -> 1
+ddcom513 compare 1 1E-2 -> 1
+ddcom514 compare 1 1E-1 -> 1
+ddcom515 compare 1 1E-0 -> 0
+ddcom516 compare 1 1E+1 -> -1
+ddcom517 compare 1 1E+2 -> -1
+ddcom518 compare 1 1E+3 -> -1
+ddcom519 compare 1 1E+4 -> -1
+ddcom521 compare 1 1E+5 -> -1
+ddcom522 compare 1 1E+6 -> -1
+ddcom523 compare 1 1E+7 -> -1
+ddcom524 compare 1 1E+8 -> -1
+ddcom525 compare 1 1E+9 -> -1
+ddcom526 compare 1 1E+10 -> -1
+ddcom527 compare 1 1E+11 -> -1
+ddcom528 compare 1 1E+12 -> -1
+ddcom529 compare 1 1E+13 -> -1
+ddcom530 compare 1 1E+14 -> -1
+ddcom531 compare 1 1E+15 -> -1
+-- LR swap
+ddcom540 compare 1E-15 1 -> -1
+ddcom541 compare 1E-14 1 -> -1
+ddcom542 compare 1E-13 1 -> -1
+ddcom543 compare 1E-12 1 -> -1
+ddcom544 compare 1E-11 1 -> -1
+ddcom545 compare 1E-10 1 -> -1
+ddcom546 compare 1E-9 1 -> -1
+ddcom547 compare 1E-8 1 -> -1
+ddcom548 compare 1E-7 1 -> -1
+ddcom549 compare 1E-6 1 -> -1
+ddcom550 compare 1E-5 1 -> -1
+ddcom551 compare 1E-4 1 -> -1
+ddcom552 compare 1E-3 1 -> -1
+ddcom553 compare 1E-2 1 -> -1
+ddcom554 compare 1E-1 1 -> -1
+ddcom555 compare 1E-0 1 -> 0
+ddcom556 compare 1E+1 1 -> 1
+ddcom557 compare 1E+2 1 -> 1
+ddcom558 compare 1E+3 1 -> 1
+ddcom559 compare 1E+4 1 -> 1
+ddcom561 compare 1E+5 1 -> 1
+ddcom562 compare 1E+6 1 -> 1
+ddcom563 compare 1E+7 1 -> 1
+ddcom564 compare 1E+8 1 -> 1
+ddcom565 compare 1E+9 1 -> 1
+ddcom566 compare 1E+10 1 -> 1
+ddcom567 compare 1E+11 1 -> 1
+ddcom568 compare 1E+12 1 -> 1
+ddcom569 compare 1E+13 1 -> 1
+ddcom570 compare 1E+14 1 -> 1
+ddcom571 compare 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcom580 compare 0.000000987654321 1E-15 -> 1
+ddcom581 compare 0.000000987654321 1E-14 -> 1
+ddcom582 compare 0.000000987654321 1E-13 -> 1
+ddcom583 compare 0.000000987654321 1E-12 -> 1
+ddcom584 compare 0.000000987654321 1E-11 -> 1
+ddcom585 compare 0.000000987654321 1E-10 -> 1
+ddcom586 compare 0.000000987654321 1E-9 -> 1
+ddcom587 compare 0.000000987654321 1E-8 -> 1
+ddcom588 compare 0.000000987654321 1E-7 -> 1
+ddcom589 compare 0.000000987654321 1E-6 -> -1
+ddcom590 compare 0.000000987654321 1E-5 -> -1
+ddcom591 compare 0.000000987654321 1E-4 -> -1
+ddcom592 compare 0.000000987654321 1E-3 -> -1
+ddcom593 compare 0.000000987654321 1E-2 -> -1
+ddcom594 compare 0.000000987654321 1E-1 -> -1
+ddcom595 compare 0.000000987654321 1E-0 -> -1
+ddcom596 compare 0.000000987654321 1E+1 -> -1
+ddcom597 compare 0.000000987654321 1E+2 -> -1
+ddcom598 compare 0.000000987654321 1E+3 -> -1
+ddcom599 compare 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcom600 compare 12 12.2345 -> -1
+ddcom601 compare 12.0 12.2345 -> -1
+ddcom602 compare 12.00 12.2345 -> -1
+ddcom603 compare 12.000 12.2345 -> -1
+ddcom604 compare 12.0000 12.2345 -> -1
+ddcom605 compare 12.00000 12.2345 -> -1
+ddcom606 compare 12.000000 12.2345 -> -1
+ddcom607 compare 12.0000000 12.2345 -> -1
+ddcom608 compare 12.00000000 12.2345 -> -1
+ddcom609 compare 12.000000000 12.2345 -> -1
+ddcom610 compare 12.1234 12 -> 1
+ddcom611 compare 12.1234 12.0 -> 1
+ddcom612 compare 12.1234 12.00 -> 1
+ddcom613 compare 12.1234 12.000 -> 1
+ddcom614 compare 12.1234 12.0000 -> 1
+ddcom615 compare 12.1234 12.00000 -> 1
+ddcom616 compare 12.1234 12.000000 -> 1
+ddcom617 compare 12.1234 12.0000000 -> 1
+ddcom618 compare 12.1234 12.00000000 -> 1
+ddcom619 compare 12.1234 12.000000000 -> 1
+ddcom620 compare -12 -12.2345 -> 1
+ddcom621 compare -12.0 -12.2345 -> 1
+ddcom622 compare -12.00 -12.2345 -> 1
+ddcom623 compare -12.000 -12.2345 -> 1
+ddcom624 compare -12.0000 -12.2345 -> 1
+ddcom625 compare -12.00000 -12.2345 -> 1
+ddcom626 compare -12.000000 -12.2345 -> 1
+ddcom627 compare -12.0000000 -12.2345 -> 1
+ddcom628 compare -12.00000000 -12.2345 -> 1
+ddcom629 compare -12.000000000 -12.2345 -> 1
+ddcom630 compare -12.1234 -12 -> -1
+ddcom631 compare -12.1234 -12.0 -> -1
+ddcom632 compare -12.1234 -12.00 -> -1
+ddcom633 compare -12.1234 -12.000 -> -1
+ddcom634 compare -12.1234 -12.0000 -> -1
+ddcom635 compare -12.1234 -12.00000 -> -1
+ddcom636 compare -12.1234 -12.000000 -> -1
+ddcom637 compare -12.1234 -12.0000000 -> -1
+ddcom638 compare -12.1234 -12.00000000 -> -1
+ddcom639 compare -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcom640 compare 0 0 -> 0
+ddcom641 compare 0 -0 -> 0
+ddcom642 compare 0 -0.0 -> 0
+ddcom643 compare 0 0.0 -> 0
+ddcom644 compare -0 0 -> 0
+ddcom645 compare -0 -0 -> 0
+ddcom646 compare -0 -0.0 -> 0
+ddcom647 compare -0 0.0 -> 0
+ddcom648 compare 0.0 0 -> 0
+ddcom649 compare 0.0 -0 -> 0
+ddcom650 compare 0.0 -0.0 -> 0
+ddcom651 compare 0.0 0.0 -> 0
+ddcom652 compare -0.0 0 -> 0
+ddcom653 compare -0.0 -0 -> 0
+ddcom654 compare -0.0 -0.0 -> 0
+ddcom655 compare -0.0 0.0 -> 0
+
+ddcom656 compare -0E1 0.0 -> 0
+ddcom657 compare -0E2 0.0 -> 0
+ddcom658 compare 0E1 0.0 -> 0
+ddcom659 compare 0E2 0.0 -> 0
+ddcom660 compare -0E1 0 -> 0
+ddcom661 compare -0E2 0 -> 0
+ddcom662 compare 0E1 0 -> 0
+ddcom663 compare 0E2 0 -> 0
+ddcom664 compare -0E1 -0E1 -> 0
+ddcom665 compare -0E2 -0E1 -> 0
+ddcom666 compare 0E1 -0E1 -> 0
+ddcom667 compare 0E2 -0E1 -> 0
+ddcom668 compare -0E1 -0E2 -> 0
+ddcom669 compare -0E2 -0E2 -> 0
+ddcom670 compare 0E1 -0E2 -> 0
+ddcom671 compare 0E2 -0E2 -> 0
+ddcom672 compare -0E1 0E1 -> 0
+ddcom673 compare -0E2 0E1 -> 0
+ddcom674 compare 0E1 0E1 -> 0
+ddcom675 compare 0E2 0E1 -> 0
+ddcom676 compare -0E1 0E2 -> 0
+ddcom677 compare -0E2 0E2 -> 0
+ddcom678 compare 0E1 0E2 -> 0
+ddcom679 compare 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcom680 compare 12 12 -> 0
+ddcom681 compare 12 12.0 -> 0
+ddcom682 compare 12 12.00 -> 0
+ddcom683 compare 12 12.000 -> 0
+ddcom684 compare 12 12.0000 -> 0
+ddcom685 compare 12 12.00000 -> 0
+ddcom686 compare 12 12.000000 -> 0
+ddcom687 compare 12 12.0000000 -> 0
+ddcom688 compare 12 12.00000000 -> 0
+ddcom689 compare 12 12.000000000 -> 0
+ddcom690 compare 12 12 -> 0
+ddcom691 compare 12.0 12 -> 0
+ddcom692 compare 12.00 12 -> 0
+ddcom693 compare 12.000 12 -> 0
+ddcom694 compare 12.0000 12 -> 0
+ddcom695 compare 12.00000 12 -> 0
+ddcom696 compare 12.000000 12 -> 0
+ddcom697 compare 12.0000000 12 -> 0
+ddcom698 compare 12.00000000 12 -> 0
+ddcom699 compare 12.000000000 12 -> 0
+
+-- first, second, & last digit
+ddcom700 compare 1234567890123456 1234567890123455 -> 1
+ddcom701 compare 1234567890123456 1234567890123456 -> 0
+ddcom702 compare 1234567890123456 1234567890123457 -> -1
+ddcom703 compare 1234567890123456 0234567890123456 -> 1
+ddcom704 compare 1234567890123456 1234567890123456 -> 0
+ddcom705 compare 1234567890123456 2234567890123456 -> -1
+ddcom706 compare 1134567890123456 1034567890123456 -> 1
+ddcom707 compare 1134567890123456 1134567890123456 -> 0
+ddcom708 compare 1134567890123456 1234567890123456 -> -1
+
+-- miscellaneous
+ddcom721 compare 12345678000 1 -> 1
+ddcom722 compare 1 12345678000 -> -1
+ddcom723 compare 1234567800 1 -> 1
+ddcom724 compare 1 1234567800 -> -1
+ddcom725 compare 1234567890 1 -> 1
+ddcom726 compare 1 1234567890 -> -1
+ddcom727 compare 1234567891 1 -> 1
+ddcom728 compare 1 1234567891 -> -1
+ddcom729 compare 12345678901 1 -> 1
+ddcom730 compare 1 12345678901 -> -1
+ddcom731 compare 1234567896 1 -> 1
+ddcom732 compare 1 1234567896 -> -1
+
+-- residue cases at lower precision
+ddcom740 compare 1 0.9999999 -> 1
+ddcom741 compare 1 0.999999 -> 1
+ddcom742 compare 1 0.99999 -> 1
+ddcom743 compare 1 1.0000 -> 0
+ddcom744 compare 1 1.00001 -> -1
+ddcom745 compare 1 1.000001 -> -1
+ddcom746 compare 1 1.0000001 -> -1
+ddcom750 compare 0.9999999 1 -> -1
+ddcom751 compare 0.999999 1 -> -1
+ddcom752 compare 0.99999 1 -> -1
+ddcom753 compare 1.0000 1 -> 0
+ddcom754 compare 1.00001 1 -> 1
+ddcom755 compare 1.000001 1 -> 1
+ddcom756 compare 1.0000001 1 -> 1
+
+-- Specials
+ddcom780 compare Inf -Inf -> 1
+ddcom781 compare Inf -1000 -> 1
+ddcom782 compare Inf -1 -> 1
+ddcom783 compare Inf -0 -> 1
+ddcom784 compare Inf 0 -> 1
+ddcom785 compare Inf 1 -> 1
+ddcom786 compare Inf 1000 -> 1
+ddcom787 compare Inf Inf -> 0
+ddcom788 compare -1000 Inf -> -1
+ddcom789 compare -Inf Inf -> -1
+ddcom790 compare -1 Inf -> -1
+ddcom791 compare -0 Inf -> -1
+ddcom792 compare 0 Inf -> -1
+ddcom793 compare 1 Inf -> -1
+ddcom794 compare 1000 Inf -> -1
+ddcom795 compare Inf Inf -> 0
+
+ddcom800 compare -Inf -Inf -> 0
+ddcom801 compare -Inf -1000 -> -1
+ddcom802 compare -Inf -1 -> -1
+ddcom803 compare -Inf -0 -> -1
+ddcom804 compare -Inf 0 -> -1
+ddcom805 compare -Inf 1 -> -1
+ddcom806 compare -Inf 1000 -> -1
+ddcom807 compare -Inf Inf -> -1
+ddcom808 compare -Inf -Inf -> 0
+ddcom809 compare -1000 -Inf -> 1
+ddcom810 compare -1 -Inf -> 1
+ddcom811 compare -0 -Inf -> 1
+ddcom812 compare 0 -Inf -> 1
+ddcom813 compare 1 -Inf -> 1
+ddcom814 compare 1000 -Inf -> 1
+ddcom815 compare Inf -Inf -> 1
+
+ddcom821 compare NaN -Inf -> NaN
+ddcom822 compare NaN -1000 -> NaN
+ddcom823 compare NaN -1 -> NaN
+ddcom824 compare NaN -0 -> NaN
+ddcom825 compare NaN 0 -> NaN
+ddcom826 compare NaN 1 -> NaN
+ddcom827 compare NaN 1000 -> NaN
+ddcom828 compare NaN Inf -> NaN
+ddcom829 compare NaN NaN -> NaN
+ddcom830 compare -Inf NaN -> NaN
+ddcom831 compare -1000 NaN -> NaN
+ddcom832 compare -1 NaN -> NaN
+ddcom833 compare -0 NaN -> NaN
+ddcom834 compare 0 NaN -> NaN
+ddcom835 compare 1 NaN -> NaN
+ddcom836 compare 1000 NaN -> NaN
+ddcom837 compare Inf NaN -> NaN
+ddcom838 compare -NaN -NaN -> -NaN
+ddcom839 compare +NaN -NaN -> NaN
+ddcom840 compare -NaN +NaN -> -NaN
+
+ddcom841 compare sNaN -Inf -> NaN Invalid_operation
+ddcom842 compare sNaN -1000 -> NaN Invalid_operation
+ddcom843 compare sNaN -1 -> NaN Invalid_operation
+ddcom844 compare sNaN -0 -> NaN Invalid_operation
+ddcom845 compare sNaN 0 -> NaN Invalid_operation
+ddcom846 compare sNaN 1 -> NaN Invalid_operation
+ddcom847 compare sNaN 1000 -> NaN Invalid_operation
+ddcom848 compare sNaN NaN -> NaN Invalid_operation
+ddcom849 compare sNaN sNaN -> NaN Invalid_operation
+ddcom850 compare NaN sNaN -> NaN Invalid_operation
+ddcom851 compare -Inf sNaN -> NaN Invalid_operation
+ddcom852 compare -1000 sNaN -> NaN Invalid_operation
+ddcom853 compare -1 sNaN -> NaN Invalid_operation
+ddcom854 compare -0 sNaN -> NaN Invalid_operation
+ddcom855 compare 0 sNaN -> NaN Invalid_operation
+ddcom856 compare 1 sNaN -> NaN Invalid_operation
+ddcom857 compare 1000 sNaN -> NaN Invalid_operation
+ddcom858 compare Inf sNaN -> NaN Invalid_operation
+ddcom859 compare NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddcom860 compare NaN9 -Inf -> NaN9
+ddcom861 compare NaN8 999 -> NaN8
+ddcom862 compare NaN77 Inf -> NaN77
+ddcom863 compare -NaN67 NaN5 -> -NaN67
+ddcom864 compare -Inf -NaN4 -> -NaN4
+ddcom865 compare -999 -NaN33 -> -NaN33
+ddcom866 compare Inf NaN2 -> NaN2
+ddcom867 compare -NaN41 -NaN42 -> -NaN41
+ddcom868 compare +NaN41 -NaN42 -> NaN41
+ddcom869 compare -NaN41 +NaN42 -> -NaN41
+ddcom870 compare +NaN41 +NaN42 -> NaN41
+
+ddcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
+ddcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
+ddcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
+ddcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
+ddcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
+ddcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
+ddcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+ddcom880 compare +1.23456789012345E-0 9E+384 -> -1
+ddcom881 compare 9E+384 +1.23456789012345E-0 -> 1
+ddcom882 compare +0.100 9E-383 -> 1
+ddcom883 compare 9E-383 +0.100 -> -1
+ddcom885 compare -1.23456789012345E-0 9E+384 -> -1
+ddcom886 compare 9E+384 -1.23456789012345E-0 -> 1
+ddcom887 compare -0.100 9E-383 -> -1
+ddcom888 compare 9E-383 -0.100 -> 1
+
+-- spread zeros
+ddcom900 compare 0E-383 0 -> 0
+ddcom901 compare 0E-383 -0 -> 0
+ddcom902 compare -0E-383 0 -> 0
+ddcom903 compare -0E-383 -0 -> 0
+ddcom904 compare 0E-383 0E+384 -> 0
+ddcom905 compare 0E-383 -0E+384 -> 0
+ddcom906 compare -0E-383 0E+384 -> 0
+ddcom907 compare -0E-383 -0E+384 -> 0
+ddcom908 compare 0 0E+384 -> 0
+ddcom909 compare 0 -0E+384 -> 0
+ddcom910 compare -0 0E+384 -> 0
+ddcom911 compare -0 -0E+384 -> 0
+ddcom930 compare 0E+384 0 -> 0
+ddcom931 compare 0E+384 -0 -> 0
+ddcom932 compare -0E+384 0 -> 0
+ddcom933 compare -0E+384 -0 -> 0
+ddcom934 compare 0E+384 0E-383 -> 0
+ddcom935 compare 0E+384 -0E-383 -> 0
+ddcom936 compare -0E+384 0E-383 -> 0
+ddcom937 compare -0E+384 -0E-383 -> 0
+ddcom938 compare 0 0E-383 -> 0
+ddcom939 compare 0 -0E-383 -> 0
+ddcom940 compare -0 0E-383 -> 0
+ddcom941 compare -0 -0E-383 -> 0
+
+-- signs
+ddcom961 compare 1e+77 1e+11 -> 1
+ddcom962 compare 1e+77 -1e+11 -> 1
+ddcom963 compare -1e+77 1e+11 -> -1
+ddcom964 compare -1e+77 -1e+11 -> -1
+ddcom965 compare 1e-77 1e-11 -> -1
+ddcom966 compare 1e-77 -1e-11 -> 1
+ddcom967 compare -1e-77 1e-11 -> -1
+ddcom968 compare -1e-77 -1e-11 -> 1
+
+-- full alignment range, both ways
+ddcomp1001 compare 1 1.000000000000000 -> 0
+ddcomp1002 compare 1 1.00000000000000 -> 0
+ddcomp1003 compare 1 1.0000000000000 -> 0
+ddcomp1004 compare 1 1.000000000000 -> 0
+ddcomp1005 compare 1 1.00000000000 -> 0
+ddcomp1006 compare 1 1.0000000000 -> 0
+ddcomp1007 compare 1 1.000000000 -> 0
+ddcomp1008 compare 1 1.00000000 -> 0
+ddcomp1009 compare 1 1.0000000 -> 0
+ddcomp1010 compare 1 1.000000 -> 0
+ddcomp1011 compare 1 1.00000 -> 0
+ddcomp1012 compare 1 1.0000 -> 0
+ddcomp1013 compare 1 1.000 -> 0
+ddcomp1014 compare 1 1.00 -> 0
+ddcomp1015 compare 1 1.0 -> 0
+ddcomp1021 compare 1.000000000000000 1 -> 0
+ddcomp1022 compare 1.00000000000000 1 -> 0
+ddcomp1023 compare 1.0000000000000 1 -> 0
+ddcomp1024 compare 1.000000000000 1 -> 0
+ddcomp1025 compare 1.00000000000 1 -> 0
+ddcomp1026 compare 1.0000000000 1 -> 0
+ddcomp1027 compare 1.000000000 1 -> 0
+ddcomp1028 compare 1.00000000 1 -> 0
+ddcomp1029 compare 1.0000000 1 -> 0
+ddcomp1030 compare 1.000000 1 -> 0
+ddcomp1031 compare 1.00000 1 -> 0
+ddcomp1032 compare 1.0000 1 -> 0
+ddcomp1033 compare 1.000 1 -> 0
+ddcomp1034 compare 1.00 1 -> 0
+ddcomp1035 compare 1.0 1 -> 0
+
+-- check MSD always detected non-zero
+ddcomp1040 compare 0 0.000000000000000 -> 0
+ddcomp1041 compare 0 1.000000000000000 -> -1
+ddcomp1042 compare 0 2.000000000000000 -> -1
+ddcomp1043 compare 0 3.000000000000000 -> -1
+ddcomp1044 compare 0 4.000000000000000 -> -1
+ddcomp1045 compare 0 5.000000000000000 -> -1
+ddcomp1046 compare 0 6.000000000000000 -> -1
+ddcomp1047 compare 0 7.000000000000000 -> -1
+ddcomp1048 compare 0 8.000000000000000 -> -1
+ddcomp1049 compare 0 9.000000000000000 -> -1
+ddcomp1050 compare 0.000000000000000 0 -> 0
+ddcomp1051 compare 1.000000000000000 0 -> 1
+ddcomp1052 compare 2.000000000000000 0 -> 1
+ddcomp1053 compare 3.000000000000000 0 -> 1
+ddcomp1054 compare 4.000000000000000 0 -> 1
+ddcomp1055 compare 5.000000000000000 0 -> 1
+ddcomp1056 compare 6.000000000000000 0 -> 1
+ddcomp1057 compare 7.000000000000000 0 -> 1
+ddcomp1058 compare 8.000000000000000 0 -> 1
+ddcomp1059 compare 9.000000000000000 0 -> 1
+
+-- Null tests
+ddcom9990 compare 10 # -> NaN Invalid_operation
+ddcom9991 compare # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareSig.decTest b/Lib/test/decimaltestdata/ddCompareSig.decTest
index c82ec455170..8d3fce08c7c 100644
--- a/Lib/test/decimaltestdata/ddCompareSig.decTest
+++ b/Lib/test/decimaltestdata/ddCompareSig.decTest
@@ -1,647 +1,647 @@
-------------------------------------------------------------------------
--- ddCompareSig.decTest -- decDouble comparison; all NaNs signal --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcms001 comparesig -2 -2 -> 0
-ddcms002 comparesig -2 -1 -> -1
-ddcms003 comparesig -2 0 -> -1
-ddcms004 comparesig -2 1 -> -1
-ddcms005 comparesig -2 2 -> -1
-ddcms006 comparesig -1 -2 -> 1
-ddcms007 comparesig -1 -1 -> 0
-ddcms008 comparesig -1 0 -> -1
-ddcms009 comparesig -1 1 -> -1
-ddcms010 comparesig -1 2 -> -1
-ddcms011 comparesig 0 -2 -> 1
-ddcms012 comparesig 0 -1 -> 1
-ddcms013 comparesig 0 0 -> 0
-ddcms014 comparesig 0 1 -> -1
-ddcms015 comparesig 0 2 -> -1
-ddcms016 comparesig 1 -2 -> 1
-ddcms017 comparesig 1 -1 -> 1
-ddcms018 comparesig 1 0 -> 1
-ddcms019 comparesig 1 1 -> 0
-ddcms020 comparesig 1 2 -> -1
-ddcms021 comparesig 2 -2 -> 1
-ddcms022 comparesig 2 -1 -> 1
-ddcms023 comparesig 2 0 -> 1
-ddcms025 comparesig 2 1 -> 1
-ddcms026 comparesig 2 2 -> 0
-
-ddcms031 comparesig -20 -20 -> 0
-ddcms032 comparesig -20 -10 -> -1
-ddcms033 comparesig -20 00 -> -1
-ddcms034 comparesig -20 10 -> -1
-ddcms035 comparesig -20 20 -> -1
-ddcms036 comparesig -10 -20 -> 1
-ddcms037 comparesig -10 -10 -> 0
-ddcms038 comparesig -10 00 -> -1
-ddcms039 comparesig -10 10 -> -1
-ddcms040 comparesig -10 20 -> -1
-ddcms041 comparesig 00 -20 -> 1
-ddcms042 comparesig 00 -10 -> 1
-ddcms043 comparesig 00 00 -> 0
-ddcms044 comparesig 00 10 -> -1
-ddcms045 comparesig 00 20 -> -1
-ddcms046 comparesig 10 -20 -> 1
-ddcms047 comparesig 10 -10 -> 1
-ddcms048 comparesig 10 00 -> 1
-ddcms049 comparesig 10 10 -> 0
-ddcms050 comparesig 10 20 -> -1
-ddcms051 comparesig 20 -20 -> 1
-ddcms052 comparesig 20 -10 -> 1
-ddcms053 comparesig 20 00 -> 1
-ddcms055 comparesig 20 10 -> 1
-ddcms056 comparesig 20 20 -> 0
-
-ddcms061 comparesig -2.0 -2.0 -> 0
-ddcms062 comparesig -2.0 -1.0 -> -1
-ddcms063 comparesig -2.0 0.0 -> -1
-ddcms064 comparesig -2.0 1.0 -> -1
-ddcms065 comparesig -2.0 2.0 -> -1
-ddcms066 comparesig -1.0 -2.0 -> 1
-ddcms067 comparesig -1.0 -1.0 -> 0
-ddcms068 comparesig -1.0 0.0 -> -1
-ddcms069 comparesig -1.0 1.0 -> -1
-ddcms070 comparesig -1.0 2.0 -> -1
-ddcms071 comparesig 0.0 -2.0 -> 1
-ddcms072 comparesig 0.0 -1.0 -> 1
-ddcms073 comparesig 0.0 0.0 -> 0
-ddcms074 comparesig 0.0 1.0 -> -1
-ddcms075 comparesig 0.0 2.0 -> -1
-ddcms076 comparesig 1.0 -2.0 -> 1
-ddcms077 comparesig 1.0 -1.0 -> 1
-ddcms078 comparesig 1.0 0.0 -> 1
-ddcms079 comparesig 1.0 1.0 -> 0
-ddcms080 comparesig 1.0 2.0 -> -1
-ddcms081 comparesig 2.0 -2.0 -> 1
-ddcms082 comparesig 2.0 -1.0 -> 1
-ddcms083 comparesig 2.0 0.0 -> 1
-ddcms085 comparesig 2.0 1.0 -> 1
-ddcms086 comparesig 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddcms090 comparesig 9.999999999999999E+384 9.999999999999999E+384 -> 0
-ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384 -> -1
-ddcms092 comparesig 9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0
-
--- some differing length/exponent cases
-ddcms100 comparesig 7.0 7.0 -> 0
-ddcms101 comparesig 7.0 7 -> 0
-ddcms102 comparesig 7 7.0 -> 0
-ddcms103 comparesig 7E+0 7.0 -> 0
-ddcms104 comparesig 70E-1 7.0 -> 0
-ddcms105 comparesig 0.7E+1 7 -> 0
-ddcms106 comparesig 70E-1 7 -> 0
-ddcms107 comparesig 7.0 7E+0 -> 0
-ddcms108 comparesig 7.0 70E-1 -> 0
-ddcms109 comparesig 7 0.7E+1 -> 0
-ddcms110 comparesig 7 70E-1 -> 0
-
-ddcms120 comparesig 8.0 7.0 -> 1
-ddcms121 comparesig 8.0 7 -> 1
-ddcms122 comparesig 8 7.0 -> 1
-ddcms123 comparesig 8E+0 7.0 -> 1
-ddcms124 comparesig 80E-1 7.0 -> 1
-ddcms125 comparesig 0.8E+1 7 -> 1
-ddcms126 comparesig 80E-1 7 -> 1
-ddcms127 comparesig 8.0 7E+0 -> 1
-ddcms128 comparesig 8.0 70E-1 -> 1
-ddcms129 comparesig 8 0.7E+1 -> 1
-ddcms130 comparesig 8 70E-1 -> 1
-
-ddcms140 comparesig 8.0 9.0 -> -1
-ddcms141 comparesig 8.0 9 -> -1
-ddcms142 comparesig 8 9.0 -> -1
-ddcms143 comparesig 8E+0 9.0 -> -1
-ddcms144 comparesig 80E-1 9.0 -> -1
-ddcms145 comparesig 0.8E+1 9 -> -1
-ddcms146 comparesig 80E-1 9 -> -1
-ddcms147 comparesig 8.0 9E+0 -> -1
-ddcms148 comparesig 8.0 90E-1 -> -1
-ddcms149 comparesig 8 0.9E+1 -> -1
-ddcms150 comparesig 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcms200 comparesig -7.0 7.0 -> -1
-ddcms201 comparesig -7.0 7 -> -1
-ddcms202 comparesig -7 7.0 -> -1
-ddcms203 comparesig -7E+0 7.0 -> -1
-ddcms204 comparesig -70E-1 7.0 -> -1
-ddcms205 comparesig -0.7E+1 7 -> -1
-ddcms206 comparesig -70E-1 7 -> -1
-ddcms207 comparesig -7.0 7E+0 -> -1
-ddcms208 comparesig -7.0 70E-1 -> -1
-ddcms209 comparesig -7 0.7E+1 -> -1
-ddcms210 comparesig -7 70E-1 -> -1
-
-ddcms220 comparesig -8.0 7.0 -> -1
-ddcms221 comparesig -8.0 7 -> -1
-ddcms222 comparesig -8 7.0 -> -1
-ddcms223 comparesig -8E+0 7.0 -> -1
-ddcms224 comparesig -80E-1 7.0 -> -1
-ddcms225 comparesig -0.8E+1 7 -> -1
-ddcms226 comparesig -80E-1 7 -> -1
-ddcms227 comparesig -8.0 7E+0 -> -1
-ddcms228 comparesig -8.0 70E-1 -> -1
-ddcms229 comparesig -8 0.7E+1 -> -1
-ddcms230 comparesig -8 70E-1 -> -1
-
-ddcms240 comparesig -8.0 9.0 -> -1
-ddcms241 comparesig -8.0 9 -> -1
-ddcms242 comparesig -8 9.0 -> -1
-ddcms243 comparesig -8E+0 9.0 -> -1
-ddcms244 comparesig -80E-1 9.0 -> -1
-ddcms245 comparesig -0.8E+1 9 -> -1
-ddcms246 comparesig -80E-1 9 -> -1
-ddcms247 comparesig -8.0 9E+0 -> -1
-ddcms248 comparesig -8.0 90E-1 -> -1
-ddcms249 comparesig -8 0.9E+1 -> -1
-ddcms250 comparesig -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcms300 comparesig 7.0 -7.0 -> 1
-ddcms301 comparesig 7.0 -7 -> 1
-ddcms302 comparesig 7 -7.0 -> 1
-ddcms303 comparesig 7E+0 -7.0 -> 1
-ddcms304 comparesig 70E-1 -7.0 -> 1
-ddcms305 comparesig .7E+1 -7 -> 1
-ddcms306 comparesig 70E-1 -7 -> 1
-ddcms307 comparesig 7.0 -7E+0 -> 1
-ddcms308 comparesig 7.0 -70E-1 -> 1
-ddcms309 comparesig 7 -.7E+1 -> 1
-ddcms310 comparesig 7 -70E-1 -> 1
-
-ddcms320 comparesig 8.0 -7.0 -> 1
-ddcms321 comparesig 8.0 -7 -> 1
-ddcms322 comparesig 8 -7.0 -> 1
-ddcms323 comparesig 8E+0 -7.0 -> 1
-ddcms324 comparesig 80E-1 -7.0 -> 1
-ddcms325 comparesig .8E+1 -7 -> 1
-ddcms326 comparesig 80E-1 -7 -> 1
-ddcms327 comparesig 8.0 -7E+0 -> 1
-ddcms328 comparesig 8.0 -70E-1 -> 1
-ddcms329 comparesig 8 -.7E+1 -> 1
-ddcms330 comparesig 8 -70E-1 -> 1
-
-ddcms340 comparesig 8.0 -9.0 -> 1
-ddcms341 comparesig 8.0 -9 -> 1
-ddcms342 comparesig 8 -9.0 -> 1
-ddcms343 comparesig 8E+0 -9.0 -> 1
-ddcms344 comparesig 80E-1 -9.0 -> 1
-ddcms345 comparesig .8E+1 -9 -> 1
-ddcms346 comparesig 80E-1 -9 -> 1
-ddcms347 comparesig 8.0 -9E+0 -> 1
-ddcms348 comparesig 8.0 -90E-1 -> 1
-ddcms349 comparesig 8 -.9E+1 -> 1
-ddcms350 comparesig 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcms400 comparesig -7.0 -7.0 -> 0
-ddcms401 comparesig -7.0 -7 -> 0
-ddcms402 comparesig -7 -7.0 -> 0
-ddcms403 comparesig -7E+0 -7.0 -> 0
-ddcms404 comparesig -70E-1 -7.0 -> 0
-ddcms405 comparesig -.7E+1 -7 -> 0
-ddcms406 comparesig -70E-1 -7 -> 0
-ddcms407 comparesig -7.0 -7E+0 -> 0
-ddcms408 comparesig -7.0 -70E-1 -> 0
-ddcms409 comparesig -7 -.7E+1 -> 0
-ddcms410 comparesig -7 -70E-1 -> 0
-
-ddcms420 comparesig -8.0 -7.0 -> -1
-ddcms421 comparesig -8.0 -7 -> -1
-ddcms422 comparesig -8 -7.0 -> -1
-ddcms423 comparesig -8E+0 -7.0 -> -1
-ddcms424 comparesig -80E-1 -7.0 -> -1
-ddcms425 comparesig -.8E+1 -7 -> -1
-ddcms426 comparesig -80E-1 -7 -> -1
-ddcms427 comparesig -8.0 -7E+0 -> -1
-ddcms428 comparesig -8.0 -70E-1 -> -1
-ddcms429 comparesig -8 -.7E+1 -> -1
-ddcms430 comparesig -8 -70E-1 -> -1
-
-ddcms440 comparesig -8.0 -9.0 -> 1
-ddcms441 comparesig -8.0 -9 -> 1
-ddcms442 comparesig -8 -9.0 -> 1
-ddcms443 comparesig -8E+0 -9.0 -> 1
-ddcms444 comparesig -80E-1 -9.0 -> 1
-ddcms445 comparesig -.8E+1 -9 -> 1
-ddcms446 comparesig -80E-1 -9 -> 1
-ddcms447 comparesig -8.0 -9E+0 -> 1
-ddcms448 comparesig -8.0 -90E-1 -> 1
-ddcms449 comparesig -8 -.9E+1 -> 1
-ddcms450 comparesig -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
-ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
-ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
-ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
-ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
-ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
-ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
-ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
-ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
-ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
-ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
-ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
-ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
-ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
-ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
-ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
-ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
-ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
-ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
-ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
-ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
-ddcms497 comparesig 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcms500 comparesig 1 1E-15 -> 1
-ddcms501 comparesig 1 1E-14 -> 1
-ddcms502 comparesig 1 1E-13 -> 1
-ddcms503 comparesig 1 1E-12 -> 1
-ddcms504 comparesig 1 1E-11 -> 1
-ddcms505 comparesig 1 1E-10 -> 1
-ddcms506 comparesig 1 1E-9 -> 1
-ddcms507 comparesig 1 1E-8 -> 1
-ddcms508 comparesig 1 1E-7 -> 1
-ddcms509 comparesig 1 1E-6 -> 1
-ddcms510 comparesig 1 1E-5 -> 1
-ddcms511 comparesig 1 1E-4 -> 1
-ddcms512 comparesig 1 1E-3 -> 1
-ddcms513 comparesig 1 1E-2 -> 1
-ddcms514 comparesig 1 1E-1 -> 1
-ddcms515 comparesig 1 1E-0 -> 0
-ddcms516 comparesig 1 1E+1 -> -1
-ddcms517 comparesig 1 1E+2 -> -1
-ddcms518 comparesig 1 1E+3 -> -1
-ddcms519 comparesig 1 1E+4 -> -1
-ddcms521 comparesig 1 1E+5 -> -1
-ddcms522 comparesig 1 1E+6 -> -1
-ddcms523 comparesig 1 1E+7 -> -1
-ddcms524 comparesig 1 1E+8 -> -1
-ddcms525 comparesig 1 1E+9 -> -1
-ddcms526 comparesig 1 1E+10 -> -1
-ddcms527 comparesig 1 1E+11 -> -1
-ddcms528 comparesig 1 1E+12 -> -1
-ddcms529 comparesig 1 1E+13 -> -1
-ddcms530 comparesig 1 1E+14 -> -1
-ddcms531 comparesig 1 1E+15 -> -1
--- LR swap
-ddcms540 comparesig 1E-15 1 -> -1
-ddcms541 comparesig 1E-14 1 -> -1
-ddcms542 comparesig 1E-13 1 -> -1
-ddcms543 comparesig 1E-12 1 -> -1
-ddcms544 comparesig 1E-11 1 -> -1
-ddcms545 comparesig 1E-10 1 -> -1
-ddcms546 comparesig 1E-9 1 -> -1
-ddcms547 comparesig 1E-8 1 -> -1
-ddcms548 comparesig 1E-7 1 -> -1
-ddcms549 comparesig 1E-6 1 -> -1
-ddcms550 comparesig 1E-5 1 -> -1
-ddcms551 comparesig 1E-4 1 -> -1
-ddcms552 comparesig 1E-3 1 -> -1
-ddcms553 comparesig 1E-2 1 -> -1
-ddcms554 comparesig 1E-1 1 -> -1
-ddcms555 comparesig 1E-0 1 -> 0
-ddcms556 comparesig 1E+1 1 -> 1
-ddcms557 comparesig 1E+2 1 -> 1
-ddcms558 comparesig 1E+3 1 -> 1
-ddcms559 comparesig 1E+4 1 -> 1
-ddcms561 comparesig 1E+5 1 -> 1
-ddcms562 comparesig 1E+6 1 -> 1
-ddcms563 comparesig 1E+7 1 -> 1
-ddcms564 comparesig 1E+8 1 -> 1
-ddcms565 comparesig 1E+9 1 -> 1
-ddcms566 comparesig 1E+10 1 -> 1
-ddcms567 comparesig 1E+11 1 -> 1
-ddcms568 comparesig 1E+12 1 -> 1
-ddcms569 comparesig 1E+13 1 -> 1
-ddcms570 comparesig 1E+14 1 -> 1
-ddcms571 comparesig 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-ddcms580 comparesig 0.000000987654321 1E-15 -> 1
-ddcms581 comparesig 0.000000987654321 1E-14 -> 1
-ddcms582 comparesig 0.000000987654321 1E-13 -> 1
-ddcms583 comparesig 0.000000987654321 1E-12 -> 1
-ddcms584 comparesig 0.000000987654321 1E-11 -> 1
-ddcms585 comparesig 0.000000987654321 1E-10 -> 1
-ddcms586 comparesig 0.000000987654321 1E-9 -> 1
-ddcms587 comparesig 0.000000987654321 1E-8 -> 1
-ddcms588 comparesig 0.000000987654321 1E-7 -> 1
-ddcms589 comparesig 0.000000987654321 1E-6 -> -1
-ddcms590 comparesig 0.000000987654321 1E-5 -> -1
-ddcms591 comparesig 0.000000987654321 1E-4 -> -1
-ddcms592 comparesig 0.000000987654321 1E-3 -> -1
-ddcms593 comparesig 0.000000987654321 1E-2 -> -1
-ddcms594 comparesig 0.000000987654321 1E-1 -> -1
-ddcms595 comparesig 0.000000987654321 1E-0 -> -1
-ddcms596 comparesig 0.000000987654321 1E+1 -> -1
-ddcms597 comparesig 0.000000987654321 1E+2 -> -1
-ddcms598 comparesig 0.000000987654321 1E+3 -> -1
-ddcms599 comparesig 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcms600 comparesig 12 12.2345 -> -1
-ddcms601 comparesig 12.0 12.2345 -> -1
-ddcms602 comparesig 12.00 12.2345 -> -1
-ddcms603 comparesig 12.000 12.2345 -> -1
-ddcms604 comparesig 12.0000 12.2345 -> -1
-ddcms605 comparesig 12.00000 12.2345 -> -1
-ddcms606 comparesig 12.000000 12.2345 -> -1
-ddcms607 comparesig 12.0000000 12.2345 -> -1
-ddcms608 comparesig 12.00000000 12.2345 -> -1
-ddcms609 comparesig 12.000000000 12.2345 -> -1
-ddcms610 comparesig 12.1234 12 -> 1
-ddcms611 comparesig 12.1234 12.0 -> 1
-ddcms612 comparesig 12.1234 12.00 -> 1
-ddcms613 comparesig 12.1234 12.000 -> 1
-ddcms614 comparesig 12.1234 12.0000 -> 1
-ddcms615 comparesig 12.1234 12.00000 -> 1
-ddcms616 comparesig 12.1234 12.000000 -> 1
-ddcms617 comparesig 12.1234 12.0000000 -> 1
-ddcms618 comparesig 12.1234 12.00000000 -> 1
-ddcms619 comparesig 12.1234 12.000000000 -> 1
-ddcms620 comparesig -12 -12.2345 -> 1
-ddcms621 comparesig -12.0 -12.2345 -> 1
-ddcms622 comparesig -12.00 -12.2345 -> 1
-ddcms623 comparesig -12.000 -12.2345 -> 1
-ddcms624 comparesig -12.0000 -12.2345 -> 1
-ddcms625 comparesig -12.00000 -12.2345 -> 1
-ddcms626 comparesig -12.000000 -12.2345 -> 1
-ddcms627 comparesig -12.0000000 -12.2345 -> 1
-ddcms628 comparesig -12.00000000 -12.2345 -> 1
-ddcms629 comparesig -12.000000000 -12.2345 -> 1
-ddcms630 comparesig -12.1234 -12 -> -1
-ddcms631 comparesig -12.1234 -12.0 -> -1
-ddcms632 comparesig -12.1234 -12.00 -> -1
-ddcms633 comparesig -12.1234 -12.000 -> -1
-ddcms634 comparesig -12.1234 -12.0000 -> -1
-ddcms635 comparesig -12.1234 -12.00000 -> -1
-ddcms636 comparesig -12.1234 -12.000000 -> -1
-ddcms637 comparesig -12.1234 -12.0000000 -> -1
-ddcms638 comparesig -12.1234 -12.00000000 -> -1
-ddcms639 comparesig -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcms640 comparesig 0 0 -> 0
-ddcms641 comparesig 0 -0 -> 0
-ddcms642 comparesig 0 -0.0 -> 0
-ddcms643 comparesig 0 0.0 -> 0
-ddcms644 comparesig -0 0 -> 0
-ddcms645 comparesig -0 -0 -> 0
-ddcms646 comparesig -0 -0.0 -> 0
-ddcms647 comparesig -0 0.0 -> 0
-ddcms648 comparesig 0.0 0 -> 0
-ddcms649 comparesig 0.0 -0 -> 0
-ddcms650 comparesig 0.0 -0.0 -> 0
-ddcms651 comparesig 0.0 0.0 -> 0
-ddcms652 comparesig -0.0 0 -> 0
-ddcms653 comparesig -0.0 -0 -> 0
-ddcms654 comparesig -0.0 -0.0 -> 0
-ddcms655 comparesig -0.0 0.0 -> 0
-
-ddcms656 comparesig -0E1 0.0 -> 0
-ddcms657 comparesig -0E2 0.0 -> 0
-ddcms658 comparesig 0E1 0.0 -> 0
-ddcms659 comparesig 0E2 0.0 -> 0
-ddcms660 comparesig -0E1 0 -> 0
-ddcms661 comparesig -0E2 0 -> 0
-ddcms662 comparesig 0E1 0 -> 0
-ddcms663 comparesig 0E2 0 -> 0
-ddcms664 comparesig -0E1 -0E1 -> 0
-ddcms665 comparesig -0E2 -0E1 -> 0
-ddcms666 comparesig 0E1 -0E1 -> 0
-ddcms667 comparesig 0E2 -0E1 -> 0
-ddcms668 comparesig -0E1 -0E2 -> 0
-ddcms669 comparesig -0E2 -0E2 -> 0
-ddcms670 comparesig 0E1 -0E2 -> 0
-ddcms671 comparesig 0E2 -0E2 -> 0
-ddcms672 comparesig -0E1 0E1 -> 0
-ddcms673 comparesig -0E2 0E1 -> 0
-ddcms674 comparesig 0E1 0E1 -> 0
-ddcms675 comparesig 0E2 0E1 -> 0
-ddcms676 comparesig -0E1 0E2 -> 0
-ddcms677 comparesig -0E2 0E2 -> 0
-ddcms678 comparesig 0E1 0E2 -> 0
-ddcms679 comparesig 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcms680 comparesig 12 12 -> 0
-ddcms681 comparesig 12 12.0 -> 0
-ddcms682 comparesig 12 12.00 -> 0
-ddcms683 comparesig 12 12.000 -> 0
-ddcms684 comparesig 12 12.0000 -> 0
-ddcms685 comparesig 12 12.00000 -> 0
-ddcms686 comparesig 12 12.000000 -> 0
-ddcms687 comparesig 12 12.0000000 -> 0
-ddcms688 comparesig 12 12.00000000 -> 0
-ddcms689 comparesig 12 12.000000000 -> 0
-ddcms690 comparesig 12 12 -> 0
-ddcms691 comparesig 12.0 12 -> 0
-ddcms692 comparesig 12.00 12 -> 0
-ddcms693 comparesig 12.000 12 -> 0
-ddcms694 comparesig 12.0000 12 -> 0
-ddcms695 comparesig 12.00000 12 -> 0
-ddcms696 comparesig 12.000000 12 -> 0
-ddcms697 comparesig 12.0000000 12 -> 0
-ddcms698 comparesig 12.00000000 12 -> 0
-ddcms699 comparesig 12.000000000 12 -> 0
-
--- first, second, & last digit
-ddcms700 comparesig 1234567890123456 1234567890123455 -> 1
-ddcms701 comparesig 1234567890123456 1234567890123456 -> 0
-ddcms702 comparesig 1234567890123456 1234567890123457 -> -1
-ddcms703 comparesig 1234567890123456 0234567890123456 -> 1
-ddcms704 comparesig 1234567890123456 1234567890123456 -> 0
-ddcms705 comparesig 1234567890123456 2234567890123456 -> -1
-ddcms706 comparesig 1134567890123456 1034567890123456 -> 1
-ddcms707 comparesig 1134567890123456 1134567890123456 -> 0
-ddcms708 comparesig 1134567890123456 1234567890123456 -> -1
-
--- miscellaneous
-ddcms721 comparesig 12345678000 1 -> 1
-ddcms722 comparesig 1 12345678000 -> -1
-ddcms723 comparesig 1234567800 1 -> 1
-ddcms724 comparesig 1 1234567800 -> -1
-ddcms725 comparesig 1234567890 1 -> 1
-ddcms726 comparesig 1 1234567890 -> -1
-ddcms727 comparesig 1234567891 1 -> 1
-ddcms728 comparesig 1 1234567891 -> -1
-ddcms729 comparesig 12345678901 1 -> 1
-ddcms730 comparesig 1 12345678901 -> -1
-ddcms731 comparesig 1234567896 1 -> 1
-ddcms732 comparesig 1 1234567896 -> -1
-
--- residue cases at lower precision
-ddcms740 comparesig 1 0.9999999 -> 1
-ddcms741 comparesig 1 0.999999 -> 1
-ddcms742 comparesig 1 0.99999 -> 1
-ddcms743 comparesig 1 1.0000 -> 0
-ddcms744 comparesig 1 1.00001 -> -1
-ddcms745 comparesig 1 1.000001 -> -1
-ddcms746 comparesig 1 1.0000001 -> -1
-ddcms750 comparesig 0.9999999 1 -> -1
-ddcms751 comparesig 0.999999 1 -> -1
-ddcms752 comparesig 0.99999 1 -> -1
-ddcms753 comparesig 1.0000 1 -> 0
-ddcms754 comparesig 1.00001 1 -> 1
-ddcms755 comparesig 1.000001 1 -> 1
-ddcms756 comparesig 1.0000001 1 -> 1
-
--- Specials
-ddcms780 comparesig Inf -Inf -> 1
-ddcms781 comparesig Inf -1000 -> 1
-ddcms782 comparesig Inf -1 -> 1
-ddcms783 comparesig Inf -0 -> 1
-ddcms784 comparesig Inf 0 -> 1
-ddcms785 comparesig Inf 1 -> 1
-ddcms786 comparesig Inf 1000 -> 1
-ddcms787 comparesig Inf Inf -> 0
-ddcms788 comparesig -1000 Inf -> -1
-ddcms789 comparesig -Inf Inf -> -1
-ddcms790 comparesig -1 Inf -> -1
-ddcms791 comparesig -0 Inf -> -1
-ddcms792 comparesig 0 Inf -> -1
-ddcms793 comparesig 1 Inf -> -1
-ddcms794 comparesig 1000 Inf -> -1
-ddcms795 comparesig Inf Inf -> 0
-
-ddcms800 comparesig -Inf -Inf -> 0
-ddcms801 comparesig -Inf -1000 -> -1
-ddcms802 comparesig -Inf -1 -> -1
-ddcms803 comparesig -Inf -0 -> -1
-ddcms804 comparesig -Inf 0 -> -1
-ddcms805 comparesig -Inf 1 -> -1
-ddcms806 comparesig -Inf 1000 -> -1
-ddcms807 comparesig -Inf Inf -> -1
-ddcms808 comparesig -Inf -Inf -> 0
-ddcms809 comparesig -1000 -Inf -> 1
-ddcms810 comparesig -1 -Inf -> 1
-ddcms811 comparesig -0 -Inf -> 1
-ddcms812 comparesig 0 -Inf -> 1
-ddcms813 comparesig 1 -Inf -> 1
-ddcms814 comparesig 1000 -Inf -> 1
-ddcms815 comparesig Inf -Inf -> 1
-
-ddcms821 comparesig NaN -Inf -> NaN Invalid_operation
-ddcms822 comparesig NaN -1000 -> NaN Invalid_operation
-ddcms823 comparesig NaN -1 -> NaN Invalid_operation
-ddcms824 comparesig NaN -0 -> NaN Invalid_operation
-ddcms825 comparesig NaN 0 -> NaN Invalid_operation
-ddcms826 comparesig NaN 1 -> NaN Invalid_operation
-ddcms827 comparesig NaN 1000 -> NaN Invalid_operation
-ddcms828 comparesig NaN Inf -> NaN Invalid_operation
-ddcms829 comparesig NaN NaN -> NaN Invalid_operation
-ddcms830 comparesig -Inf NaN -> NaN Invalid_operation
-ddcms831 comparesig -1000 NaN -> NaN Invalid_operation
-ddcms832 comparesig -1 NaN -> NaN Invalid_operation
-ddcms833 comparesig -0 NaN -> NaN Invalid_operation
-ddcms834 comparesig 0 NaN -> NaN Invalid_operation
-ddcms835 comparesig 1 NaN -> NaN Invalid_operation
-ddcms836 comparesig 1000 NaN -> NaN Invalid_operation
-ddcms837 comparesig Inf NaN -> NaN Invalid_operation
-ddcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
-ddcms839 comparesig +NaN -NaN -> NaN Invalid_operation
-ddcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
-
-ddcms841 comparesig sNaN -Inf -> NaN Invalid_operation
-ddcms842 comparesig sNaN -1000 -> NaN Invalid_operation
-ddcms843 comparesig sNaN -1 -> NaN Invalid_operation
-ddcms844 comparesig sNaN -0 -> NaN Invalid_operation
-ddcms845 comparesig sNaN 0 -> NaN Invalid_operation
-ddcms846 comparesig sNaN 1 -> NaN Invalid_operation
-ddcms847 comparesig sNaN 1000 -> NaN Invalid_operation
-ddcms848 comparesig sNaN NaN -> NaN Invalid_operation
-ddcms849 comparesig sNaN sNaN -> NaN Invalid_operation
-ddcms850 comparesig NaN sNaN -> NaN Invalid_operation
-ddcms851 comparesig -Inf sNaN -> NaN Invalid_operation
-ddcms852 comparesig -1000 sNaN -> NaN Invalid_operation
-ddcms853 comparesig -1 sNaN -> NaN Invalid_operation
-ddcms854 comparesig -0 sNaN -> NaN Invalid_operation
-ddcms855 comparesig 0 sNaN -> NaN Invalid_operation
-ddcms856 comparesig 1 sNaN -> NaN Invalid_operation
-ddcms857 comparesig 1000 sNaN -> NaN Invalid_operation
-ddcms858 comparesig Inf sNaN -> NaN Invalid_operation
-ddcms859 comparesig NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
-ddcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
-ddcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
-ddcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
-ddcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
-ddcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
-ddcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
-ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
-ddcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
-ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
-ddcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
-
-ddcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
-ddcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
-ddcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
-ddcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
-ddcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
-ddcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
-ddcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
-ddcms881 comparesig 9E+384 +1.23456789012345E-0 -> 1
-ddcms882 comparesig +0.100 9E-383 -> 1
-ddcms883 comparesig 9E-383 +0.100 -> -1
-ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
-ddcms886 comparesig 9E+384 -1.23456789012345E-0 -> 1
-ddcms887 comparesig -0.100 9E-383 -> -1
-ddcms888 comparesig 9E-383 -0.100 -> 1
-
--- signs
-ddcms901 comparesig 1e+77 1e+11 -> 1
-ddcms902 comparesig 1e+77 -1e+11 -> 1
-ddcms903 comparesig -1e+77 1e+11 -> -1
-ddcms904 comparesig -1e+77 -1e+11 -> -1
-ddcms905 comparesig 1e-77 1e-11 -> -1
-ddcms906 comparesig 1e-77 -1e-11 -> 1
-ddcms907 comparesig -1e-77 1e-11 -> -1
-ddcms908 comparesig -1e-77 -1e-11 -> 1
-
--- Null tests
-ddcms990 comparesig 10 # -> NaN Invalid_operation
-ddcms991 comparesig # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareSig.decTest -- decDouble comparison; all NaNs signal --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcms001 comparesig -2 -2 -> 0
+ddcms002 comparesig -2 -1 -> -1
+ddcms003 comparesig -2 0 -> -1
+ddcms004 comparesig -2 1 -> -1
+ddcms005 comparesig -2 2 -> -1
+ddcms006 comparesig -1 -2 -> 1
+ddcms007 comparesig -1 -1 -> 0
+ddcms008 comparesig -1 0 -> -1
+ddcms009 comparesig -1 1 -> -1
+ddcms010 comparesig -1 2 -> -1
+ddcms011 comparesig 0 -2 -> 1
+ddcms012 comparesig 0 -1 -> 1
+ddcms013 comparesig 0 0 -> 0
+ddcms014 comparesig 0 1 -> -1
+ddcms015 comparesig 0 2 -> -1
+ddcms016 comparesig 1 -2 -> 1
+ddcms017 comparesig 1 -1 -> 1
+ddcms018 comparesig 1 0 -> 1
+ddcms019 comparesig 1 1 -> 0
+ddcms020 comparesig 1 2 -> -1
+ddcms021 comparesig 2 -2 -> 1
+ddcms022 comparesig 2 -1 -> 1
+ddcms023 comparesig 2 0 -> 1
+ddcms025 comparesig 2 1 -> 1
+ddcms026 comparesig 2 2 -> 0
+
+ddcms031 comparesig -20 -20 -> 0
+ddcms032 comparesig -20 -10 -> -1
+ddcms033 comparesig -20 00 -> -1
+ddcms034 comparesig -20 10 -> -1
+ddcms035 comparesig -20 20 -> -1
+ddcms036 comparesig -10 -20 -> 1
+ddcms037 comparesig -10 -10 -> 0
+ddcms038 comparesig -10 00 -> -1
+ddcms039 comparesig -10 10 -> -1
+ddcms040 comparesig -10 20 -> -1
+ddcms041 comparesig 00 -20 -> 1
+ddcms042 comparesig 00 -10 -> 1
+ddcms043 comparesig 00 00 -> 0
+ddcms044 comparesig 00 10 -> -1
+ddcms045 comparesig 00 20 -> -1
+ddcms046 comparesig 10 -20 -> 1
+ddcms047 comparesig 10 -10 -> 1
+ddcms048 comparesig 10 00 -> 1
+ddcms049 comparesig 10 10 -> 0
+ddcms050 comparesig 10 20 -> -1
+ddcms051 comparesig 20 -20 -> 1
+ddcms052 comparesig 20 -10 -> 1
+ddcms053 comparesig 20 00 -> 1
+ddcms055 comparesig 20 10 -> 1
+ddcms056 comparesig 20 20 -> 0
+
+ddcms061 comparesig -2.0 -2.0 -> 0
+ddcms062 comparesig -2.0 -1.0 -> -1
+ddcms063 comparesig -2.0 0.0 -> -1
+ddcms064 comparesig -2.0 1.0 -> -1
+ddcms065 comparesig -2.0 2.0 -> -1
+ddcms066 comparesig -1.0 -2.0 -> 1
+ddcms067 comparesig -1.0 -1.0 -> 0
+ddcms068 comparesig -1.0 0.0 -> -1
+ddcms069 comparesig -1.0 1.0 -> -1
+ddcms070 comparesig -1.0 2.0 -> -1
+ddcms071 comparesig 0.0 -2.0 -> 1
+ddcms072 comparesig 0.0 -1.0 -> 1
+ddcms073 comparesig 0.0 0.0 -> 0
+ddcms074 comparesig 0.0 1.0 -> -1
+ddcms075 comparesig 0.0 2.0 -> -1
+ddcms076 comparesig 1.0 -2.0 -> 1
+ddcms077 comparesig 1.0 -1.0 -> 1
+ddcms078 comparesig 1.0 0.0 -> 1
+ddcms079 comparesig 1.0 1.0 -> 0
+ddcms080 comparesig 1.0 2.0 -> -1
+ddcms081 comparesig 2.0 -2.0 -> 1
+ddcms082 comparesig 2.0 -1.0 -> 1
+ddcms083 comparesig 2.0 0.0 -> 1
+ddcms085 comparesig 2.0 1.0 -> 1
+ddcms086 comparesig 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddcms090 comparesig 9.999999999999999E+384 9.999999999999999E+384 -> 0
+ddcms091 comparesig -9.999999999999999E+384 9.999999999999999E+384 -> -1
+ddcms092 comparesig 9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddcms093 comparesig -9.999999999999999E+384 -9.999999999999999E+384 -> 0
+
+-- some differing length/exponent cases
+ddcms100 comparesig 7.0 7.0 -> 0
+ddcms101 comparesig 7.0 7 -> 0
+ddcms102 comparesig 7 7.0 -> 0
+ddcms103 comparesig 7E+0 7.0 -> 0
+ddcms104 comparesig 70E-1 7.0 -> 0
+ddcms105 comparesig 0.7E+1 7 -> 0
+ddcms106 comparesig 70E-1 7 -> 0
+ddcms107 comparesig 7.0 7E+0 -> 0
+ddcms108 comparesig 7.0 70E-1 -> 0
+ddcms109 comparesig 7 0.7E+1 -> 0
+ddcms110 comparesig 7 70E-1 -> 0
+
+ddcms120 comparesig 8.0 7.0 -> 1
+ddcms121 comparesig 8.0 7 -> 1
+ddcms122 comparesig 8 7.0 -> 1
+ddcms123 comparesig 8E+0 7.0 -> 1
+ddcms124 comparesig 80E-1 7.0 -> 1
+ddcms125 comparesig 0.8E+1 7 -> 1
+ddcms126 comparesig 80E-1 7 -> 1
+ddcms127 comparesig 8.0 7E+0 -> 1
+ddcms128 comparesig 8.0 70E-1 -> 1
+ddcms129 comparesig 8 0.7E+1 -> 1
+ddcms130 comparesig 8 70E-1 -> 1
+
+ddcms140 comparesig 8.0 9.0 -> -1
+ddcms141 comparesig 8.0 9 -> -1
+ddcms142 comparesig 8 9.0 -> -1
+ddcms143 comparesig 8E+0 9.0 -> -1
+ddcms144 comparesig 80E-1 9.0 -> -1
+ddcms145 comparesig 0.8E+1 9 -> -1
+ddcms146 comparesig 80E-1 9 -> -1
+ddcms147 comparesig 8.0 9E+0 -> -1
+ddcms148 comparesig 8.0 90E-1 -> -1
+ddcms149 comparesig 8 0.9E+1 -> -1
+ddcms150 comparesig 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcms200 comparesig -7.0 7.0 -> -1
+ddcms201 comparesig -7.0 7 -> -1
+ddcms202 comparesig -7 7.0 -> -1
+ddcms203 comparesig -7E+0 7.0 -> -1
+ddcms204 comparesig -70E-1 7.0 -> -1
+ddcms205 comparesig -0.7E+1 7 -> -1
+ddcms206 comparesig -70E-1 7 -> -1
+ddcms207 comparesig -7.0 7E+0 -> -1
+ddcms208 comparesig -7.0 70E-1 -> -1
+ddcms209 comparesig -7 0.7E+1 -> -1
+ddcms210 comparesig -7 70E-1 -> -1
+
+ddcms220 comparesig -8.0 7.0 -> -1
+ddcms221 comparesig -8.0 7 -> -1
+ddcms222 comparesig -8 7.0 -> -1
+ddcms223 comparesig -8E+0 7.0 -> -1
+ddcms224 comparesig -80E-1 7.0 -> -1
+ddcms225 comparesig -0.8E+1 7 -> -1
+ddcms226 comparesig -80E-1 7 -> -1
+ddcms227 comparesig -8.0 7E+0 -> -1
+ddcms228 comparesig -8.0 70E-1 -> -1
+ddcms229 comparesig -8 0.7E+1 -> -1
+ddcms230 comparesig -8 70E-1 -> -1
+
+ddcms240 comparesig -8.0 9.0 -> -1
+ddcms241 comparesig -8.0 9 -> -1
+ddcms242 comparesig -8 9.0 -> -1
+ddcms243 comparesig -8E+0 9.0 -> -1
+ddcms244 comparesig -80E-1 9.0 -> -1
+ddcms245 comparesig -0.8E+1 9 -> -1
+ddcms246 comparesig -80E-1 9 -> -1
+ddcms247 comparesig -8.0 9E+0 -> -1
+ddcms248 comparesig -8.0 90E-1 -> -1
+ddcms249 comparesig -8 0.9E+1 -> -1
+ddcms250 comparesig -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcms300 comparesig 7.0 -7.0 -> 1
+ddcms301 comparesig 7.0 -7 -> 1
+ddcms302 comparesig 7 -7.0 -> 1
+ddcms303 comparesig 7E+0 -7.0 -> 1
+ddcms304 comparesig 70E-1 -7.0 -> 1
+ddcms305 comparesig .7E+1 -7 -> 1
+ddcms306 comparesig 70E-1 -7 -> 1
+ddcms307 comparesig 7.0 -7E+0 -> 1
+ddcms308 comparesig 7.0 -70E-1 -> 1
+ddcms309 comparesig 7 -.7E+1 -> 1
+ddcms310 comparesig 7 -70E-1 -> 1
+
+ddcms320 comparesig 8.0 -7.0 -> 1
+ddcms321 comparesig 8.0 -7 -> 1
+ddcms322 comparesig 8 -7.0 -> 1
+ddcms323 comparesig 8E+0 -7.0 -> 1
+ddcms324 comparesig 80E-1 -7.0 -> 1
+ddcms325 comparesig .8E+1 -7 -> 1
+ddcms326 comparesig 80E-1 -7 -> 1
+ddcms327 comparesig 8.0 -7E+0 -> 1
+ddcms328 comparesig 8.0 -70E-1 -> 1
+ddcms329 comparesig 8 -.7E+1 -> 1
+ddcms330 comparesig 8 -70E-1 -> 1
+
+ddcms340 comparesig 8.0 -9.0 -> 1
+ddcms341 comparesig 8.0 -9 -> 1
+ddcms342 comparesig 8 -9.0 -> 1
+ddcms343 comparesig 8E+0 -9.0 -> 1
+ddcms344 comparesig 80E-1 -9.0 -> 1
+ddcms345 comparesig .8E+1 -9 -> 1
+ddcms346 comparesig 80E-1 -9 -> 1
+ddcms347 comparesig 8.0 -9E+0 -> 1
+ddcms348 comparesig 8.0 -90E-1 -> 1
+ddcms349 comparesig 8 -.9E+1 -> 1
+ddcms350 comparesig 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcms400 comparesig -7.0 -7.0 -> 0
+ddcms401 comparesig -7.0 -7 -> 0
+ddcms402 comparesig -7 -7.0 -> 0
+ddcms403 comparesig -7E+0 -7.0 -> 0
+ddcms404 comparesig -70E-1 -7.0 -> 0
+ddcms405 comparesig -.7E+1 -7 -> 0
+ddcms406 comparesig -70E-1 -7 -> 0
+ddcms407 comparesig -7.0 -7E+0 -> 0
+ddcms408 comparesig -7.0 -70E-1 -> 0
+ddcms409 comparesig -7 -.7E+1 -> 0
+ddcms410 comparesig -7 -70E-1 -> 0
+
+ddcms420 comparesig -8.0 -7.0 -> -1
+ddcms421 comparesig -8.0 -7 -> -1
+ddcms422 comparesig -8 -7.0 -> -1
+ddcms423 comparesig -8E+0 -7.0 -> -1
+ddcms424 comparesig -80E-1 -7.0 -> -1
+ddcms425 comparesig -.8E+1 -7 -> -1
+ddcms426 comparesig -80E-1 -7 -> -1
+ddcms427 comparesig -8.0 -7E+0 -> -1
+ddcms428 comparesig -8.0 -70E-1 -> -1
+ddcms429 comparesig -8 -.7E+1 -> -1
+ddcms430 comparesig -8 -70E-1 -> -1
+
+ddcms440 comparesig -8.0 -9.0 -> 1
+ddcms441 comparesig -8.0 -9 -> 1
+ddcms442 comparesig -8 -9.0 -> 1
+ddcms443 comparesig -8E+0 -9.0 -> 1
+ddcms444 comparesig -80E-1 -9.0 -> 1
+ddcms445 comparesig -.8E+1 -9 -> 1
+ddcms446 comparesig -80E-1 -9 -> 1
+ddcms447 comparesig -8.0 -9E+0 -> 1
+ddcms448 comparesig -8.0 -90E-1 -> 1
+ddcms449 comparesig -8 -.9E+1 -> 1
+ddcms450 comparesig -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcms473 comparesig 123.4560000000000E-89 123.456E-89 -> 0
+ddcms474 comparesig 123.456000000000E+89 123.456E+89 -> 0
+ddcms475 comparesig 123.45600000000E-89 123.456E-89 -> 0
+ddcms476 comparesig 123.4560000000E+89 123.456E+89 -> 0
+ddcms477 comparesig 123.456000000E-89 123.456E-89 -> 0
+ddcms478 comparesig 123.45600000E+89 123.456E+89 -> 0
+ddcms479 comparesig 123.4560000E-89 123.456E-89 -> 0
+ddcms480 comparesig 123.456000E+89 123.456E+89 -> 0
+ddcms481 comparesig 123.45600E-89 123.456E-89 -> 0
+ddcms482 comparesig 123.4560E+89 123.456E+89 -> 0
+ddcms483 comparesig 123.456E-89 123.456E-89 -> 0
+ddcms487 comparesig 123.456E+89 123.4560000000000E+89 -> 0
+ddcms488 comparesig 123.456E-89 123.456000000000E-89 -> 0
+ddcms489 comparesig 123.456E+89 123.45600000000E+89 -> 0
+ddcms490 comparesig 123.456E-89 123.4560000000E-89 -> 0
+ddcms491 comparesig 123.456E+89 123.456000000E+89 -> 0
+ddcms492 comparesig 123.456E-89 123.45600000E-89 -> 0
+ddcms493 comparesig 123.456E+89 123.4560000E+89 -> 0
+ddcms494 comparesig 123.456E-89 123.456000E-89 -> 0
+ddcms495 comparesig 123.456E+89 123.45600E+89 -> 0
+ddcms496 comparesig 123.456E-89 123.4560E-89 -> 0
+ddcms497 comparesig 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcms500 comparesig 1 1E-15 -> 1
+ddcms501 comparesig 1 1E-14 -> 1
+ddcms502 comparesig 1 1E-13 -> 1
+ddcms503 comparesig 1 1E-12 -> 1
+ddcms504 comparesig 1 1E-11 -> 1
+ddcms505 comparesig 1 1E-10 -> 1
+ddcms506 comparesig 1 1E-9 -> 1
+ddcms507 comparesig 1 1E-8 -> 1
+ddcms508 comparesig 1 1E-7 -> 1
+ddcms509 comparesig 1 1E-6 -> 1
+ddcms510 comparesig 1 1E-5 -> 1
+ddcms511 comparesig 1 1E-4 -> 1
+ddcms512 comparesig 1 1E-3 -> 1
+ddcms513 comparesig 1 1E-2 -> 1
+ddcms514 comparesig 1 1E-1 -> 1
+ddcms515 comparesig 1 1E-0 -> 0
+ddcms516 comparesig 1 1E+1 -> -1
+ddcms517 comparesig 1 1E+2 -> -1
+ddcms518 comparesig 1 1E+3 -> -1
+ddcms519 comparesig 1 1E+4 -> -1
+ddcms521 comparesig 1 1E+5 -> -1
+ddcms522 comparesig 1 1E+6 -> -1
+ddcms523 comparesig 1 1E+7 -> -1
+ddcms524 comparesig 1 1E+8 -> -1
+ddcms525 comparesig 1 1E+9 -> -1
+ddcms526 comparesig 1 1E+10 -> -1
+ddcms527 comparesig 1 1E+11 -> -1
+ddcms528 comparesig 1 1E+12 -> -1
+ddcms529 comparesig 1 1E+13 -> -1
+ddcms530 comparesig 1 1E+14 -> -1
+ddcms531 comparesig 1 1E+15 -> -1
+-- LR swap
+ddcms540 comparesig 1E-15 1 -> -1
+ddcms541 comparesig 1E-14 1 -> -1
+ddcms542 comparesig 1E-13 1 -> -1
+ddcms543 comparesig 1E-12 1 -> -1
+ddcms544 comparesig 1E-11 1 -> -1
+ddcms545 comparesig 1E-10 1 -> -1
+ddcms546 comparesig 1E-9 1 -> -1
+ddcms547 comparesig 1E-8 1 -> -1
+ddcms548 comparesig 1E-7 1 -> -1
+ddcms549 comparesig 1E-6 1 -> -1
+ddcms550 comparesig 1E-5 1 -> -1
+ddcms551 comparesig 1E-4 1 -> -1
+ddcms552 comparesig 1E-3 1 -> -1
+ddcms553 comparesig 1E-2 1 -> -1
+ddcms554 comparesig 1E-1 1 -> -1
+ddcms555 comparesig 1E-0 1 -> 0
+ddcms556 comparesig 1E+1 1 -> 1
+ddcms557 comparesig 1E+2 1 -> 1
+ddcms558 comparesig 1E+3 1 -> 1
+ddcms559 comparesig 1E+4 1 -> 1
+ddcms561 comparesig 1E+5 1 -> 1
+ddcms562 comparesig 1E+6 1 -> 1
+ddcms563 comparesig 1E+7 1 -> 1
+ddcms564 comparesig 1E+8 1 -> 1
+ddcms565 comparesig 1E+9 1 -> 1
+ddcms566 comparesig 1E+10 1 -> 1
+ddcms567 comparesig 1E+11 1 -> 1
+ddcms568 comparesig 1E+12 1 -> 1
+ddcms569 comparesig 1E+13 1 -> 1
+ddcms570 comparesig 1E+14 1 -> 1
+ddcms571 comparesig 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcms580 comparesig 0.000000987654321 1E-15 -> 1
+ddcms581 comparesig 0.000000987654321 1E-14 -> 1
+ddcms582 comparesig 0.000000987654321 1E-13 -> 1
+ddcms583 comparesig 0.000000987654321 1E-12 -> 1
+ddcms584 comparesig 0.000000987654321 1E-11 -> 1
+ddcms585 comparesig 0.000000987654321 1E-10 -> 1
+ddcms586 comparesig 0.000000987654321 1E-9 -> 1
+ddcms587 comparesig 0.000000987654321 1E-8 -> 1
+ddcms588 comparesig 0.000000987654321 1E-7 -> 1
+ddcms589 comparesig 0.000000987654321 1E-6 -> -1
+ddcms590 comparesig 0.000000987654321 1E-5 -> -1
+ddcms591 comparesig 0.000000987654321 1E-4 -> -1
+ddcms592 comparesig 0.000000987654321 1E-3 -> -1
+ddcms593 comparesig 0.000000987654321 1E-2 -> -1
+ddcms594 comparesig 0.000000987654321 1E-1 -> -1
+ddcms595 comparesig 0.000000987654321 1E-0 -> -1
+ddcms596 comparesig 0.000000987654321 1E+1 -> -1
+ddcms597 comparesig 0.000000987654321 1E+2 -> -1
+ddcms598 comparesig 0.000000987654321 1E+3 -> -1
+ddcms599 comparesig 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcms600 comparesig 12 12.2345 -> -1
+ddcms601 comparesig 12.0 12.2345 -> -1
+ddcms602 comparesig 12.00 12.2345 -> -1
+ddcms603 comparesig 12.000 12.2345 -> -1
+ddcms604 comparesig 12.0000 12.2345 -> -1
+ddcms605 comparesig 12.00000 12.2345 -> -1
+ddcms606 comparesig 12.000000 12.2345 -> -1
+ddcms607 comparesig 12.0000000 12.2345 -> -1
+ddcms608 comparesig 12.00000000 12.2345 -> -1
+ddcms609 comparesig 12.000000000 12.2345 -> -1
+ddcms610 comparesig 12.1234 12 -> 1
+ddcms611 comparesig 12.1234 12.0 -> 1
+ddcms612 comparesig 12.1234 12.00 -> 1
+ddcms613 comparesig 12.1234 12.000 -> 1
+ddcms614 comparesig 12.1234 12.0000 -> 1
+ddcms615 comparesig 12.1234 12.00000 -> 1
+ddcms616 comparesig 12.1234 12.000000 -> 1
+ddcms617 comparesig 12.1234 12.0000000 -> 1
+ddcms618 comparesig 12.1234 12.00000000 -> 1
+ddcms619 comparesig 12.1234 12.000000000 -> 1
+ddcms620 comparesig -12 -12.2345 -> 1
+ddcms621 comparesig -12.0 -12.2345 -> 1
+ddcms622 comparesig -12.00 -12.2345 -> 1
+ddcms623 comparesig -12.000 -12.2345 -> 1
+ddcms624 comparesig -12.0000 -12.2345 -> 1
+ddcms625 comparesig -12.00000 -12.2345 -> 1
+ddcms626 comparesig -12.000000 -12.2345 -> 1
+ddcms627 comparesig -12.0000000 -12.2345 -> 1
+ddcms628 comparesig -12.00000000 -12.2345 -> 1
+ddcms629 comparesig -12.000000000 -12.2345 -> 1
+ddcms630 comparesig -12.1234 -12 -> -1
+ddcms631 comparesig -12.1234 -12.0 -> -1
+ddcms632 comparesig -12.1234 -12.00 -> -1
+ddcms633 comparesig -12.1234 -12.000 -> -1
+ddcms634 comparesig -12.1234 -12.0000 -> -1
+ddcms635 comparesig -12.1234 -12.00000 -> -1
+ddcms636 comparesig -12.1234 -12.000000 -> -1
+ddcms637 comparesig -12.1234 -12.0000000 -> -1
+ddcms638 comparesig -12.1234 -12.00000000 -> -1
+ddcms639 comparesig -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcms640 comparesig 0 0 -> 0
+ddcms641 comparesig 0 -0 -> 0
+ddcms642 comparesig 0 -0.0 -> 0
+ddcms643 comparesig 0 0.0 -> 0
+ddcms644 comparesig -0 0 -> 0
+ddcms645 comparesig -0 -0 -> 0
+ddcms646 comparesig -0 -0.0 -> 0
+ddcms647 comparesig -0 0.0 -> 0
+ddcms648 comparesig 0.0 0 -> 0
+ddcms649 comparesig 0.0 -0 -> 0
+ddcms650 comparesig 0.0 -0.0 -> 0
+ddcms651 comparesig 0.0 0.0 -> 0
+ddcms652 comparesig -0.0 0 -> 0
+ddcms653 comparesig -0.0 -0 -> 0
+ddcms654 comparesig -0.0 -0.0 -> 0
+ddcms655 comparesig -0.0 0.0 -> 0
+
+ddcms656 comparesig -0E1 0.0 -> 0
+ddcms657 comparesig -0E2 0.0 -> 0
+ddcms658 comparesig 0E1 0.0 -> 0
+ddcms659 comparesig 0E2 0.0 -> 0
+ddcms660 comparesig -0E1 0 -> 0
+ddcms661 comparesig -0E2 0 -> 0
+ddcms662 comparesig 0E1 0 -> 0
+ddcms663 comparesig 0E2 0 -> 0
+ddcms664 comparesig -0E1 -0E1 -> 0
+ddcms665 comparesig -0E2 -0E1 -> 0
+ddcms666 comparesig 0E1 -0E1 -> 0
+ddcms667 comparesig 0E2 -0E1 -> 0
+ddcms668 comparesig -0E1 -0E2 -> 0
+ddcms669 comparesig -0E2 -0E2 -> 0
+ddcms670 comparesig 0E1 -0E2 -> 0
+ddcms671 comparesig 0E2 -0E2 -> 0
+ddcms672 comparesig -0E1 0E1 -> 0
+ddcms673 comparesig -0E2 0E1 -> 0
+ddcms674 comparesig 0E1 0E1 -> 0
+ddcms675 comparesig 0E2 0E1 -> 0
+ddcms676 comparesig -0E1 0E2 -> 0
+ddcms677 comparesig -0E2 0E2 -> 0
+ddcms678 comparesig 0E1 0E2 -> 0
+ddcms679 comparesig 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcms680 comparesig 12 12 -> 0
+ddcms681 comparesig 12 12.0 -> 0
+ddcms682 comparesig 12 12.00 -> 0
+ddcms683 comparesig 12 12.000 -> 0
+ddcms684 comparesig 12 12.0000 -> 0
+ddcms685 comparesig 12 12.00000 -> 0
+ddcms686 comparesig 12 12.000000 -> 0
+ddcms687 comparesig 12 12.0000000 -> 0
+ddcms688 comparesig 12 12.00000000 -> 0
+ddcms689 comparesig 12 12.000000000 -> 0
+ddcms690 comparesig 12 12 -> 0
+ddcms691 comparesig 12.0 12 -> 0
+ddcms692 comparesig 12.00 12 -> 0
+ddcms693 comparesig 12.000 12 -> 0
+ddcms694 comparesig 12.0000 12 -> 0
+ddcms695 comparesig 12.00000 12 -> 0
+ddcms696 comparesig 12.000000 12 -> 0
+ddcms697 comparesig 12.0000000 12 -> 0
+ddcms698 comparesig 12.00000000 12 -> 0
+ddcms699 comparesig 12.000000000 12 -> 0
+
+-- first, second, & last digit
+ddcms700 comparesig 1234567890123456 1234567890123455 -> 1
+ddcms701 comparesig 1234567890123456 1234567890123456 -> 0
+ddcms702 comparesig 1234567890123456 1234567890123457 -> -1
+ddcms703 comparesig 1234567890123456 0234567890123456 -> 1
+ddcms704 comparesig 1234567890123456 1234567890123456 -> 0
+ddcms705 comparesig 1234567890123456 2234567890123456 -> -1
+ddcms706 comparesig 1134567890123456 1034567890123456 -> 1
+ddcms707 comparesig 1134567890123456 1134567890123456 -> 0
+ddcms708 comparesig 1134567890123456 1234567890123456 -> -1
+
+-- miscellaneous
+ddcms721 comparesig 12345678000 1 -> 1
+ddcms722 comparesig 1 12345678000 -> -1
+ddcms723 comparesig 1234567800 1 -> 1
+ddcms724 comparesig 1 1234567800 -> -1
+ddcms725 comparesig 1234567890 1 -> 1
+ddcms726 comparesig 1 1234567890 -> -1
+ddcms727 comparesig 1234567891 1 -> 1
+ddcms728 comparesig 1 1234567891 -> -1
+ddcms729 comparesig 12345678901 1 -> 1
+ddcms730 comparesig 1 12345678901 -> -1
+ddcms731 comparesig 1234567896 1 -> 1
+ddcms732 comparesig 1 1234567896 -> -1
+
+-- residue cases at lower precision
+ddcms740 comparesig 1 0.9999999 -> 1
+ddcms741 comparesig 1 0.999999 -> 1
+ddcms742 comparesig 1 0.99999 -> 1
+ddcms743 comparesig 1 1.0000 -> 0
+ddcms744 comparesig 1 1.00001 -> -1
+ddcms745 comparesig 1 1.000001 -> -1
+ddcms746 comparesig 1 1.0000001 -> -1
+ddcms750 comparesig 0.9999999 1 -> -1
+ddcms751 comparesig 0.999999 1 -> -1
+ddcms752 comparesig 0.99999 1 -> -1
+ddcms753 comparesig 1.0000 1 -> 0
+ddcms754 comparesig 1.00001 1 -> 1
+ddcms755 comparesig 1.000001 1 -> 1
+ddcms756 comparesig 1.0000001 1 -> 1
+
+-- Specials
+ddcms780 comparesig Inf -Inf -> 1
+ddcms781 comparesig Inf -1000 -> 1
+ddcms782 comparesig Inf -1 -> 1
+ddcms783 comparesig Inf -0 -> 1
+ddcms784 comparesig Inf 0 -> 1
+ddcms785 comparesig Inf 1 -> 1
+ddcms786 comparesig Inf 1000 -> 1
+ddcms787 comparesig Inf Inf -> 0
+ddcms788 comparesig -1000 Inf -> -1
+ddcms789 comparesig -Inf Inf -> -1
+ddcms790 comparesig -1 Inf -> -1
+ddcms791 comparesig -0 Inf -> -1
+ddcms792 comparesig 0 Inf -> -1
+ddcms793 comparesig 1 Inf -> -1
+ddcms794 comparesig 1000 Inf -> -1
+ddcms795 comparesig Inf Inf -> 0
+
+ddcms800 comparesig -Inf -Inf -> 0
+ddcms801 comparesig -Inf -1000 -> -1
+ddcms802 comparesig -Inf -1 -> -1
+ddcms803 comparesig -Inf -0 -> -1
+ddcms804 comparesig -Inf 0 -> -1
+ddcms805 comparesig -Inf 1 -> -1
+ddcms806 comparesig -Inf 1000 -> -1
+ddcms807 comparesig -Inf Inf -> -1
+ddcms808 comparesig -Inf -Inf -> 0
+ddcms809 comparesig -1000 -Inf -> 1
+ddcms810 comparesig -1 -Inf -> 1
+ddcms811 comparesig -0 -Inf -> 1
+ddcms812 comparesig 0 -Inf -> 1
+ddcms813 comparesig 1 -Inf -> 1
+ddcms814 comparesig 1000 -Inf -> 1
+ddcms815 comparesig Inf -Inf -> 1
+
+ddcms821 comparesig NaN -Inf -> NaN Invalid_operation
+ddcms822 comparesig NaN -1000 -> NaN Invalid_operation
+ddcms823 comparesig NaN -1 -> NaN Invalid_operation
+ddcms824 comparesig NaN -0 -> NaN Invalid_operation
+ddcms825 comparesig NaN 0 -> NaN Invalid_operation
+ddcms826 comparesig NaN 1 -> NaN Invalid_operation
+ddcms827 comparesig NaN 1000 -> NaN Invalid_operation
+ddcms828 comparesig NaN Inf -> NaN Invalid_operation
+ddcms829 comparesig NaN NaN -> NaN Invalid_operation
+ddcms830 comparesig -Inf NaN -> NaN Invalid_operation
+ddcms831 comparesig -1000 NaN -> NaN Invalid_operation
+ddcms832 comparesig -1 NaN -> NaN Invalid_operation
+ddcms833 comparesig -0 NaN -> NaN Invalid_operation
+ddcms834 comparesig 0 NaN -> NaN Invalid_operation
+ddcms835 comparesig 1 NaN -> NaN Invalid_operation
+ddcms836 comparesig 1000 NaN -> NaN Invalid_operation
+ddcms837 comparesig Inf NaN -> NaN Invalid_operation
+ddcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
+ddcms839 comparesig +NaN -NaN -> NaN Invalid_operation
+ddcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
+
+ddcms841 comparesig sNaN -Inf -> NaN Invalid_operation
+ddcms842 comparesig sNaN -1000 -> NaN Invalid_operation
+ddcms843 comparesig sNaN -1 -> NaN Invalid_operation
+ddcms844 comparesig sNaN -0 -> NaN Invalid_operation
+ddcms845 comparesig sNaN 0 -> NaN Invalid_operation
+ddcms846 comparesig sNaN 1 -> NaN Invalid_operation
+ddcms847 comparesig sNaN 1000 -> NaN Invalid_operation
+ddcms848 comparesig sNaN NaN -> NaN Invalid_operation
+ddcms849 comparesig sNaN sNaN -> NaN Invalid_operation
+ddcms850 comparesig NaN sNaN -> NaN Invalid_operation
+ddcms851 comparesig -Inf sNaN -> NaN Invalid_operation
+ddcms852 comparesig -1000 sNaN -> NaN Invalid_operation
+ddcms853 comparesig -1 sNaN -> NaN Invalid_operation
+ddcms854 comparesig -0 sNaN -> NaN Invalid_operation
+ddcms855 comparesig 0 sNaN -> NaN Invalid_operation
+ddcms856 comparesig 1 sNaN -> NaN Invalid_operation
+ddcms857 comparesig 1000 sNaN -> NaN Invalid_operation
+ddcms858 comparesig Inf sNaN -> NaN Invalid_operation
+ddcms859 comparesig NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
+ddcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
+ddcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
+ddcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
+ddcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
+ddcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
+ddcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
+ddcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
+ddcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
+ddcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
+ddcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
+
+ddcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
+ddcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
+ddcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
+ddcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
+ddcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
+ddcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
+ddcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+ddcms880 comparesig +1.23456789012345E-0 9E+384 -> -1
+ddcms881 comparesig 9E+384 +1.23456789012345E-0 -> 1
+ddcms882 comparesig +0.100 9E-383 -> 1
+ddcms883 comparesig 9E-383 +0.100 -> -1
+ddcms885 comparesig -1.23456789012345E-0 9E+384 -> -1
+ddcms886 comparesig 9E+384 -1.23456789012345E-0 -> 1
+ddcms887 comparesig -0.100 9E-383 -> -1
+ddcms888 comparesig 9E-383 -0.100 -> 1
+
+-- signs
+ddcms901 comparesig 1e+77 1e+11 -> 1
+ddcms902 comparesig 1e+77 -1e+11 -> 1
+ddcms903 comparesig -1e+77 1e+11 -> -1
+ddcms904 comparesig -1e+77 -1e+11 -> -1
+ddcms905 comparesig 1e-77 1e-11 -> -1
+ddcms906 comparesig 1e-77 -1e-11 -> 1
+ddcms907 comparesig -1e-77 1e-11 -> -1
+ddcms908 comparesig -1e-77 -1e-11 -> 1
+
+-- Null tests
+ddcms990 comparesig 10 # -> NaN Invalid_operation
+ddcms991 comparesig # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareTotal.decTest b/Lib/test/decimaltestdata/ddCompareTotal.decTest
index 10c984c7ff5..76beed5681b 100644
--- a/Lib/test/decimaltestdata/ddCompareTotal.decTest
+++ b/Lib/test/decimaltestdata/ddCompareTotal.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- ddCompareTotal.decTest -- decDouble comparison using total ordering--
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddcot001 comparetotal -2 -2 -> 0
-ddcot002 comparetotal -2 -1 -> -1
-ddcot003 comparetotal -2 0 -> -1
-ddcot004 comparetotal -2 1 -> -1
-ddcot005 comparetotal -2 2 -> -1
-ddcot006 comparetotal -1 -2 -> 1
-ddcot007 comparetotal -1 -1 -> 0
-ddcot008 comparetotal -1 0 -> -1
-ddcot009 comparetotal -1 1 -> -1
-ddcot010 comparetotal -1 2 -> -1
-ddcot011 comparetotal 0 -2 -> 1
-ddcot012 comparetotal 0 -1 -> 1
-ddcot013 comparetotal 0 0 -> 0
-ddcot014 comparetotal 0 1 -> -1
-ddcot015 comparetotal 0 2 -> -1
-ddcot016 comparetotal 1 -2 -> 1
-ddcot017 comparetotal 1 -1 -> 1
-ddcot018 comparetotal 1 0 -> 1
-ddcot019 comparetotal 1 1 -> 0
-ddcot020 comparetotal 1 2 -> -1
-ddcot021 comparetotal 2 -2 -> 1
-ddcot022 comparetotal 2 -1 -> 1
-ddcot023 comparetotal 2 0 -> 1
-ddcot025 comparetotal 2 1 -> 1
-ddcot026 comparetotal 2 2 -> 0
-
-ddcot031 comparetotal -20 -20 -> 0
-ddcot032 comparetotal -20 -10 -> -1
-ddcot033 comparetotal -20 00 -> -1
-ddcot034 comparetotal -20 10 -> -1
-ddcot035 comparetotal -20 20 -> -1
-ddcot036 comparetotal -10 -20 -> 1
-ddcot037 comparetotal -10 -10 -> 0
-ddcot038 comparetotal -10 00 -> -1
-ddcot039 comparetotal -10 10 -> -1
-ddcot040 comparetotal -10 20 -> -1
-ddcot041 comparetotal 00 -20 -> 1
-ddcot042 comparetotal 00 -10 -> 1
-ddcot043 comparetotal 00 00 -> 0
-ddcot044 comparetotal 00 10 -> -1
-ddcot045 comparetotal 00 20 -> -1
-ddcot046 comparetotal 10 -20 -> 1
-ddcot047 comparetotal 10 -10 -> 1
-ddcot048 comparetotal 10 00 -> 1
-ddcot049 comparetotal 10 10 -> 0
-ddcot050 comparetotal 10 20 -> -1
-ddcot051 comparetotal 20 -20 -> 1
-ddcot052 comparetotal 20 -10 -> 1
-ddcot053 comparetotal 20 00 -> 1
-ddcot055 comparetotal 20 10 -> 1
-ddcot056 comparetotal 20 20 -> 0
-
-ddcot061 comparetotal -2.0 -2.0 -> 0
-ddcot062 comparetotal -2.0 -1.0 -> -1
-ddcot063 comparetotal -2.0 0.0 -> -1
-ddcot064 comparetotal -2.0 1.0 -> -1
-ddcot065 comparetotal -2.0 2.0 -> -1
-ddcot066 comparetotal -1.0 -2.0 -> 1
-ddcot067 comparetotal -1.0 -1.0 -> 0
-ddcot068 comparetotal -1.0 0.0 -> -1
-ddcot069 comparetotal -1.0 1.0 -> -1
-ddcot070 comparetotal -1.0 2.0 -> -1
-ddcot071 comparetotal 0.0 -2.0 -> 1
-ddcot072 comparetotal 0.0 -1.0 -> 1
-ddcot073 comparetotal 0.0 0.0 -> 0
-ddcot074 comparetotal 0.0 1.0 -> -1
-ddcot075 comparetotal 0.0 2.0 -> -1
-ddcot076 comparetotal 1.0 -2.0 -> 1
-ddcot077 comparetotal 1.0 -1.0 -> 1
-ddcot078 comparetotal 1.0 0.0 -> 1
-ddcot079 comparetotal 1.0 1.0 -> 0
-ddcot080 comparetotal 1.0 2.0 -> -1
-ddcot081 comparetotal 2.0 -2.0 -> 1
-ddcot082 comparetotal 2.0 -1.0 -> 1
-ddcot083 comparetotal 2.0 0.0 -> 1
-ddcot085 comparetotal 2.0 1.0 -> 1
-ddcot086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddcot090 comparetotal 9.99999999E+384 9.99999999E+384 -> 0
-ddcot091 comparetotal -9.99999999E+384 9.99999999E+384 -> -1
-ddcot092 comparetotal 9.99999999E+384 -9.99999999E+384 -> 1
-ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ddcot100 comparetotal 7.0 7.0 -> 0
-ddcot101 comparetotal 7.0 7 -> -1
-ddcot102 comparetotal 7 7.0 -> 1
-ddcot103 comparetotal 7E+0 7.0 -> 1
-ddcot104 comparetotal 70E-1 7.0 -> 0
-ddcot105 comparetotal 0.7E+1 7 -> 0
-ddcot106 comparetotal 70E-1 7 -> -1
-ddcot107 comparetotal 7.0 7E+0 -> -1
-ddcot108 comparetotal 7.0 70E-1 -> 0
-ddcot109 comparetotal 7 0.7E+1 -> 0
-ddcot110 comparetotal 7 70E-1 -> 1
-
-ddcot120 comparetotal 8.0 7.0 -> 1
-ddcot121 comparetotal 8.0 7 -> 1
-ddcot122 comparetotal 8 7.0 -> 1
-ddcot123 comparetotal 8E+0 7.0 -> 1
-ddcot124 comparetotal 80E-1 7.0 -> 1
-ddcot125 comparetotal 0.8E+1 7 -> 1
-ddcot126 comparetotal 80E-1 7 -> 1
-ddcot127 comparetotal 8.0 7E+0 -> 1
-ddcot128 comparetotal 8.0 70E-1 -> 1
-ddcot129 comparetotal 8 0.7E+1 -> 1
-ddcot130 comparetotal 8 70E-1 -> 1
-
-ddcot140 comparetotal 8.0 9.0 -> -1
-ddcot141 comparetotal 8.0 9 -> -1
-ddcot142 comparetotal 8 9.0 -> -1
-ddcot143 comparetotal 8E+0 9.0 -> -1
-ddcot144 comparetotal 80E-1 9.0 -> -1
-ddcot145 comparetotal 0.8E+1 9 -> -1
-ddcot146 comparetotal 80E-1 9 -> -1
-ddcot147 comparetotal 8.0 9E+0 -> -1
-ddcot148 comparetotal 8.0 90E-1 -> -1
-ddcot149 comparetotal 8 0.9E+1 -> -1
-ddcot150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddcot200 comparetotal -7.0 7.0 -> -1
-ddcot201 comparetotal -7.0 7 -> -1
-ddcot202 comparetotal -7 7.0 -> -1
-ddcot203 comparetotal -7E+0 7.0 -> -1
-ddcot204 comparetotal -70E-1 7.0 -> -1
-ddcot205 comparetotal -0.7E+1 7 -> -1
-ddcot206 comparetotal -70E-1 7 -> -1
-ddcot207 comparetotal -7.0 7E+0 -> -1
-ddcot208 comparetotal -7.0 70E-1 -> -1
-ddcot209 comparetotal -7 0.7E+1 -> -1
-ddcot210 comparetotal -7 70E-1 -> -1
-
-ddcot220 comparetotal -8.0 7.0 -> -1
-ddcot221 comparetotal -8.0 7 -> -1
-ddcot222 comparetotal -8 7.0 -> -1
-ddcot223 comparetotal -8E+0 7.0 -> -1
-ddcot224 comparetotal -80E-1 7.0 -> -1
-ddcot225 comparetotal -0.8E+1 7 -> -1
-ddcot226 comparetotal -80E-1 7 -> -1
-ddcot227 comparetotal -8.0 7E+0 -> -1
-ddcot228 comparetotal -8.0 70E-1 -> -1
-ddcot229 comparetotal -8 0.7E+1 -> -1
-ddcot230 comparetotal -8 70E-1 -> -1
-
-ddcot240 comparetotal -8.0 9.0 -> -1
-ddcot241 comparetotal -8.0 9 -> -1
-ddcot242 comparetotal -8 9.0 -> -1
-ddcot243 comparetotal -8E+0 9.0 -> -1
-ddcot244 comparetotal -80E-1 9.0 -> -1
-ddcot245 comparetotal -0.8E+1 9 -> -1
-ddcot246 comparetotal -80E-1 9 -> -1
-ddcot247 comparetotal -8.0 9E+0 -> -1
-ddcot248 comparetotal -8.0 90E-1 -> -1
-ddcot249 comparetotal -8 0.9E+1 -> -1
-ddcot250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddcot300 comparetotal 7.0 -7.0 -> 1
-ddcot301 comparetotal 7.0 -7 -> 1
-ddcot302 comparetotal 7 -7.0 -> 1
-ddcot303 comparetotal 7E+0 -7.0 -> 1
-ddcot304 comparetotal 70E-1 -7.0 -> 1
-ddcot305 comparetotal .7E+1 -7 -> 1
-ddcot306 comparetotal 70E-1 -7 -> 1
-ddcot307 comparetotal 7.0 -7E+0 -> 1
-ddcot308 comparetotal 7.0 -70E-1 -> 1
-ddcot309 comparetotal 7 -.7E+1 -> 1
-ddcot310 comparetotal 7 -70E-1 -> 1
-
-ddcot320 comparetotal 8.0 -7.0 -> 1
-ddcot321 comparetotal 8.0 -7 -> 1
-ddcot322 comparetotal 8 -7.0 -> 1
-ddcot323 comparetotal 8E+0 -7.0 -> 1
-ddcot324 comparetotal 80E-1 -7.0 -> 1
-ddcot325 comparetotal .8E+1 -7 -> 1
-ddcot326 comparetotal 80E-1 -7 -> 1
-ddcot327 comparetotal 8.0 -7E+0 -> 1
-ddcot328 comparetotal 8.0 -70E-1 -> 1
-ddcot329 comparetotal 8 -.7E+1 -> 1
-ddcot330 comparetotal 8 -70E-1 -> 1
-
-ddcot340 comparetotal 8.0 -9.0 -> 1
-ddcot341 comparetotal 8.0 -9 -> 1
-ddcot342 comparetotal 8 -9.0 -> 1
-ddcot343 comparetotal 8E+0 -9.0 -> 1
-ddcot344 comparetotal 80E-1 -9.0 -> 1
-ddcot345 comparetotal .8E+1 -9 -> 1
-ddcot346 comparetotal 80E-1 -9 -> 1
-ddcot347 comparetotal 8.0 -9E+0 -> 1
-ddcot348 comparetotal 8.0 -90E-1 -> 1
-ddcot349 comparetotal 8 -.9E+1 -> 1
-ddcot350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-ddcot400 comparetotal -7.0 -7.0 -> 0
-ddcot401 comparetotal -7.0 -7 -> 1
-ddcot402 comparetotal -7 -7.0 -> -1
-ddcot403 comparetotal -7E+0 -7.0 -> -1
-ddcot404 comparetotal -70E-1 -7.0 -> 0
-ddcot405 comparetotal -.7E+1 -7 -> 0
-ddcot406 comparetotal -70E-1 -7 -> 1
-ddcot407 comparetotal -7.0 -7E+0 -> 1
-ddcot408 comparetotal -7.0 -70E-1 -> 0
-ddcot409 comparetotal -7 -.7E+1 -> 0
-ddcot410 comparetotal -7 -70E-1 -> -1
-
-ddcot420 comparetotal -8.0 -7.0 -> -1
-ddcot421 comparetotal -8.0 -7 -> -1
-ddcot422 comparetotal -8 -7.0 -> -1
-ddcot423 comparetotal -8E+0 -7.0 -> -1
-ddcot424 comparetotal -80E-1 -7.0 -> -1
-ddcot425 comparetotal -.8E+1 -7 -> -1
-ddcot426 comparetotal -80E-1 -7 -> -1
-ddcot427 comparetotal -8.0 -7E+0 -> -1
-ddcot428 comparetotal -8.0 -70E-1 -> -1
-ddcot429 comparetotal -8 -.7E+1 -> -1
-ddcot430 comparetotal -8 -70E-1 -> -1
-
-ddcot440 comparetotal -8.0 -9.0 -> 1
-ddcot441 comparetotal -8.0 -9 -> 1
-ddcot442 comparetotal -8 -9.0 -> 1
-ddcot443 comparetotal -8E+0 -9.0 -> 1
-ddcot444 comparetotal -80E-1 -9.0 -> 1
-ddcot445 comparetotal -.8E+1 -9 -> 1
-ddcot446 comparetotal -80E-1 -9 -> 1
-ddcot447 comparetotal -8.0 -9E+0 -> 1
-ddcot448 comparetotal -8.0 -90E-1 -> 1
-ddcot449 comparetotal -8 -.9E+1 -> 1
-ddcot450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
-ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
-ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
-ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
-ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
-ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
-ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
-ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
-ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
-ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
-ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
-ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
-ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
-ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
-ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddcot498 comparetotal 1 1E-17 -> 1
-ddcot499 comparetotal 1 1E-16 -> 1
-ddcot500 comparetotal 1 1E-15 -> 1
-ddcot501 comparetotal 1 1E-14 -> 1
-ddcot502 comparetotal 1 1E-13 -> 1
-ddcot503 comparetotal 1 1E-12 -> 1
-ddcot504 comparetotal 1 1E-11 -> 1
-ddcot505 comparetotal 1 1E-10 -> 1
-ddcot506 comparetotal 1 1E-9 -> 1
-ddcot507 comparetotal 1 1E-8 -> 1
-ddcot508 comparetotal 1 1E-7 -> 1
-ddcot509 comparetotal 1 1E-6 -> 1
-ddcot510 comparetotal 1 1E-5 -> 1
-ddcot511 comparetotal 1 1E-4 -> 1
-ddcot512 comparetotal 1 1E-3 -> 1
-ddcot513 comparetotal 1 1E-2 -> 1
-ddcot514 comparetotal 1 1E-1 -> 1
-ddcot515 comparetotal 1 1E-0 -> 0
-ddcot516 comparetotal 1 1E+1 -> -1
-ddcot517 comparetotal 1 1E+2 -> -1
-ddcot518 comparetotal 1 1E+3 -> -1
-ddcot519 comparetotal 1 1E+4 -> -1
-ddcot521 comparetotal 1 1E+5 -> -1
-ddcot522 comparetotal 1 1E+6 -> -1
-ddcot523 comparetotal 1 1E+7 -> -1
-ddcot524 comparetotal 1 1E+8 -> -1
-ddcot525 comparetotal 1 1E+9 -> -1
-ddcot526 comparetotal 1 1E+10 -> -1
-ddcot527 comparetotal 1 1E+11 -> -1
-ddcot528 comparetotal 1 1E+12 -> -1
-ddcot529 comparetotal 1 1E+13 -> -1
-ddcot530 comparetotal 1 1E+14 -> -1
-ddcot531 comparetotal 1 1E+15 -> -1
-ddcot532 comparetotal 1 1E+16 -> -1
-ddcot533 comparetotal 1 1E+17 -> -1
--- LR swap
-ddcot538 comparetotal 1E-17 1 -> -1
-ddcot539 comparetotal 1E-16 1 -> -1
-ddcot540 comparetotal 1E-15 1 -> -1
-ddcot541 comparetotal 1E-14 1 -> -1
-ddcot542 comparetotal 1E-13 1 -> -1
-ddcot543 comparetotal 1E-12 1 -> -1
-ddcot544 comparetotal 1E-11 1 -> -1
-ddcot545 comparetotal 1E-10 1 -> -1
-ddcot546 comparetotal 1E-9 1 -> -1
-ddcot547 comparetotal 1E-8 1 -> -1
-ddcot548 comparetotal 1E-7 1 -> -1
-ddcot549 comparetotal 1E-6 1 -> -1
-ddcot550 comparetotal 1E-5 1 -> -1
-ddcot551 comparetotal 1E-4 1 -> -1
-ddcot552 comparetotal 1E-3 1 -> -1
-ddcot553 comparetotal 1E-2 1 -> -1
-ddcot554 comparetotal 1E-1 1 -> -1
-ddcot555 comparetotal 1E-0 1 -> 0
-ddcot556 comparetotal 1E+1 1 -> 1
-ddcot557 comparetotal 1E+2 1 -> 1
-ddcot558 comparetotal 1E+3 1 -> 1
-ddcot559 comparetotal 1E+4 1 -> 1
-ddcot561 comparetotal 1E+5 1 -> 1
-ddcot562 comparetotal 1E+6 1 -> 1
-ddcot563 comparetotal 1E+7 1 -> 1
-ddcot564 comparetotal 1E+8 1 -> 1
-ddcot565 comparetotal 1E+9 1 -> 1
-ddcot566 comparetotal 1E+10 1 -> 1
-ddcot567 comparetotal 1E+11 1 -> 1
-ddcot568 comparetotal 1E+12 1 -> 1
-ddcot569 comparetotal 1E+13 1 -> 1
-ddcot570 comparetotal 1E+14 1 -> 1
-ddcot571 comparetotal 1E+15 1 -> 1
-ddcot572 comparetotal 1E+16 1 -> 1
-ddcot573 comparetotal 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-ddcot578 comparetotal 0.000000987654321 1E-17 -> 1
-ddcot579 comparetotal 0.000000987654321 1E-16 -> 1
-ddcot580 comparetotal 0.000000987654321 1E-15 -> 1
-ddcot581 comparetotal 0.000000987654321 1E-14 -> 1
-ddcot582 comparetotal 0.000000987654321 1E-13 -> 1
-ddcot583 comparetotal 0.000000987654321 1E-12 -> 1
-ddcot584 comparetotal 0.000000987654321 1E-11 -> 1
-ddcot585 comparetotal 0.000000987654321 1E-10 -> 1
-ddcot586 comparetotal 0.000000987654321 1E-9 -> 1
-ddcot587 comparetotal 0.000000987654321 1E-8 -> 1
-ddcot588 comparetotal 0.000000987654321 1E-7 -> 1
-ddcot589 comparetotal 0.000000987654321 1E-6 -> -1
-ddcot590 comparetotal 0.000000987654321 1E-5 -> -1
-ddcot591 comparetotal 0.000000987654321 1E-4 -> -1
-ddcot592 comparetotal 0.000000987654321 1E-3 -> -1
-ddcot593 comparetotal 0.000000987654321 1E-2 -> -1
-ddcot594 comparetotal 0.000000987654321 1E-1 -> -1
-ddcot595 comparetotal 0.000000987654321 1E-0 -> -1
-ddcot596 comparetotal 0.000000987654321 1E+1 -> -1
-ddcot597 comparetotal 0.000000987654321 1E+2 -> -1
-ddcot598 comparetotal 0.000000987654321 1E+3 -> -1
-ddcot599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddcot600 comparetotal 12 12.2345 -> -1
-ddcot601 comparetotal 12.0 12.2345 -> -1
-ddcot602 comparetotal 12.00 12.2345 -> -1
-ddcot603 comparetotal 12.000 12.2345 -> -1
-ddcot604 comparetotal 12.0000 12.2345 -> -1
-ddcot605 comparetotal 12.00000 12.2345 -> -1
-ddcot606 comparetotal 12.000000 12.2345 -> -1
-ddcot607 comparetotal 12.0000000 12.2345 -> -1
-ddcot608 comparetotal 12.00000000 12.2345 -> -1
-ddcot609 comparetotal 12.000000000 12.2345 -> -1
-ddcot610 comparetotal 12.1234 12 -> 1
-ddcot611 comparetotal 12.1234 12.0 -> 1
-ddcot612 comparetotal 12.1234 12.00 -> 1
-ddcot613 comparetotal 12.1234 12.000 -> 1
-ddcot614 comparetotal 12.1234 12.0000 -> 1
-ddcot615 comparetotal 12.1234 12.00000 -> 1
-ddcot616 comparetotal 12.1234 12.000000 -> 1
-ddcot617 comparetotal 12.1234 12.0000000 -> 1
-ddcot618 comparetotal 12.1234 12.00000000 -> 1
-ddcot619 comparetotal 12.1234 12.000000000 -> 1
-ddcot620 comparetotal -12 -12.2345 -> 1
-ddcot621 comparetotal -12.0 -12.2345 -> 1
-ddcot622 comparetotal -12.00 -12.2345 -> 1
-ddcot623 comparetotal -12.000 -12.2345 -> 1
-ddcot624 comparetotal -12.0000 -12.2345 -> 1
-ddcot625 comparetotal -12.00000 -12.2345 -> 1
-ddcot626 comparetotal -12.000000 -12.2345 -> 1
-ddcot627 comparetotal -12.0000000 -12.2345 -> 1
-ddcot628 comparetotal -12.00000000 -12.2345 -> 1
-ddcot629 comparetotal -12.000000000 -12.2345 -> 1
-ddcot630 comparetotal -12.1234 -12 -> -1
-ddcot631 comparetotal -12.1234 -12.0 -> -1
-ddcot632 comparetotal -12.1234 -12.00 -> -1
-ddcot633 comparetotal -12.1234 -12.000 -> -1
-ddcot634 comparetotal -12.1234 -12.0000 -> -1
-ddcot635 comparetotal -12.1234 -12.00000 -> -1
-ddcot636 comparetotal -12.1234 -12.000000 -> -1
-ddcot637 comparetotal -12.1234 -12.0000000 -> -1
-ddcot638 comparetotal -12.1234 -12.00000000 -> -1
-ddcot639 comparetotal -12.1234 -12.000000000 -> -1
-
--- extended zeros
-ddcot640 comparetotal 0 0 -> 0
-ddcot641 comparetotal 0 -0 -> 1
-ddcot642 comparetotal 0 -0.0 -> 1
-ddcot643 comparetotal 0 0.0 -> 1
-ddcot644 comparetotal -0 0 -> -1
-ddcot645 comparetotal -0 -0 -> 0
-ddcot646 comparetotal -0 -0.0 -> -1
-ddcot647 comparetotal -0 0.0 -> -1
-ddcot648 comparetotal 0.0 0 -> -1
-ddcot649 comparetotal 0.0 -0 -> 1
-ddcot650 comparetotal 0.0 -0.0 -> 1
-ddcot651 comparetotal 0.0 0.0 -> 0
-ddcot652 comparetotal -0.0 0 -> -1
-ddcot653 comparetotal -0.0 -0 -> 1
-ddcot654 comparetotal -0.0 -0.0 -> 0
-ddcot655 comparetotal -0.0 0.0 -> -1
-
-ddcot656 comparetotal -0E1 0.0 -> -1
-ddcot657 comparetotal -0E2 0.0 -> -1
-ddcot658 comparetotal 0E1 0.0 -> 1
-ddcot659 comparetotal 0E2 0.0 -> 1
-ddcot660 comparetotal -0E1 0 -> -1
-ddcot661 comparetotal -0E2 0 -> -1
-ddcot662 comparetotal 0E1 0 -> 1
-ddcot663 comparetotal 0E2 0 -> 1
-ddcot664 comparetotal -0E1 -0E1 -> 0
-ddcot665 comparetotal -0E2 -0E1 -> -1
-ddcot666 comparetotal 0E1 -0E1 -> 1
-ddcot667 comparetotal 0E2 -0E1 -> 1
-ddcot668 comparetotal -0E1 -0E2 -> 1
-ddcot669 comparetotal -0E2 -0E2 -> 0
-ddcot670 comparetotal 0E1 -0E2 -> 1
-ddcot671 comparetotal 0E2 -0E2 -> 1
-ddcot672 comparetotal -0E1 0E1 -> -1
-ddcot673 comparetotal -0E2 0E1 -> -1
-ddcot674 comparetotal 0E1 0E1 -> 0
-ddcot675 comparetotal 0E2 0E1 -> 1
-ddcot676 comparetotal -0E1 0E2 -> -1
-ddcot677 comparetotal -0E2 0E2 -> -1
-ddcot678 comparetotal 0E1 0E2 -> -1
-ddcot679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddcot680 comparetotal 12 12 -> 0
-ddcot681 comparetotal 12 12.0 -> 1
-ddcot682 comparetotal 12 12.00 -> 1
-ddcot683 comparetotal 12 12.000 -> 1
-ddcot684 comparetotal 12 12.0000 -> 1
-ddcot685 comparetotal 12 12.00000 -> 1
-ddcot686 comparetotal 12 12.000000 -> 1
-ddcot687 comparetotal 12 12.0000000 -> 1
-ddcot688 comparetotal 12 12.00000000 -> 1
-ddcot689 comparetotal 12 12.000000000 -> 1
-ddcot690 comparetotal 12 12 -> 0
-ddcot691 comparetotal 12.0 12 -> -1
-ddcot692 comparetotal 12.00 12 -> -1
-ddcot693 comparetotal 12.000 12 -> -1
-ddcot694 comparetotal 12.0000 12 -> -1
-ddcot695 comparetotal 12.00000 12 -> -1
-ddcot696 comparetotal 12.000000 12 -> -1
-ddcot697 comparetotal 12.0000000 12 -> -1
-ddcot698 comparetotal 12.00000000 12 -> -1
-ddcot699 comparetotal 12.000000000 12 -> -1
-
--- old long operand checks
-ddcot701 comparetotal 12345678000 1 -> 1
-ddcot702 comparetotal 1 12345678000 -> -1
-ddcot703 comparetotal 1234567800 1 -> 1
-ddcot704 comparetotal 1 1234567800 -> -1
-ddcot705 comparetotal 1234567890 1 -> 1
-ddcot706 comparetotal 1 1234567890 -> -1
-ddcot707 comparetotal 1234567891 1 -> 1
-ddcot708 comparetotal 1 1234567891 -> -1
-ddcot709 comparetotal 12345678901 1 -> 1
-ddcot710 comparetotal 1 12345678901 -> -1
-ddcot711 comparetotal 1234567896 1 -> 1
-ddcot712 comparetotal 1 1234567896 -> -1
-ddcot713 comparetotal -1234567891 1 -> -1
-ddcot714 comparetotal 1 -1234567891 -> 1
-ddcot715 comparetotal -12345678901 1 -> -1
-ddcot716 comparetotal 1 -12345678901 -> 1
-ddcot717 comparetotal -1234567896 1 -> -1
-ddcot718 comparetotal 1 -1234567896 -> 1
-
--- old residue cases
-ddcot740 comparetotal 1 0.9999999 -> 1
-ddcot741 comparetotal 1 0.999999 -> 1
-ddcot742 comparetotal 1 0.99999 -> 1
-ddcot743 comparetotal 1 1.0000 -> 1
-ddcot744 comparetotal 1 1.00001 -> -1
-ddcot745 comparetotal 1 1.000001 -> -1
-ddcot746 comparetotal 1 1.0000001 -> -1
-ddcot750 comparetotal 0.9999999 1 -> -1
-ddcot751 comparetotal 0.999999 1 -> -1
-ddcot752 comparetotal 0.99999 1 -> -1
-ddcot753 comparetotal 1.0000 1 -> -1
-ddcot754 comparetotal 1.00001 1 -> 1
-ddcot755 comparetotal 1.000001 1 -> 1
-ddcot756 comparetotal 1.0000001 1 -> 1
-
--- Specials
-ddcot780 comparetotal Inf -Inf -> 1
-ddcot781 comparetotal Inf -1000 -> 1
-ddcot782 comparetotal Inf -1 -> 1
-ddcot783 comparetotal Inf -0 -> 1
-ddcot784 comparetotal Inf 0 -> 1
-ddcot785 comparetotal Inf 1 -> 1
-ddcot786 comparetotal Inf 1000 -> 1
-ddcot787 comparetotal Inf Inf -> 0
-ddcot788 comparetotal -1000 Inf -> -1
-ddcot789 comparetotal -Inf Inf -> -1
-ddcot790 comparetotal -1 Inf -> -1
-ddcot791 comparetotal -0 Inf -> -1
-ddcot792 comparetotal 0 Inf -> -1
-ddcot793 comparetotal 1 Inf -> -1
-ddcot794 comparetotal 1000 Inf -> -1
-ddcot795 comparetotal Inf Inf -> 0
-
-ddcot800 comparetotal -Inf -Inf -> 0
-ddcot801 comparetotal -Inf -1000 -> -1
-ddcot802 comparetotal -Inf -1 -> -1
-ddcot803 comparetotal -Inf -0 -> -1
-ddcot804 comparetotal -Inf 0 -> -1
-ddcot805 comparetotal -Inf 1 -> -1
-ddcot806 comparetotal -Inf 1000 -> -1
-ddcot807 comparetotal -Inf Inf -> -1
-ddcot808 comparetotal -Inf -Inf -> 0
-ddcot809 comparetotal -1000 -Inf -> 1
-ddcot810 comparetotal -1 -Inf -> 1
-ddcot811 comparetotal -0 -Inf -> 1
-ddcot812 comparetotal 0 -Inf -> 1
-ddcot813 comparetotal 1 -Inf -> 1
-ddcot814 comparetotal 1000 -Inf -> 1
-ddcot815 comparetotal Inf -Inf -> 1
-
-ddcot821 comparetotal NaN -Inf -> 1
-ddcot822 comparetotal NaN -1000 -> 1
-ddcot823 comparetotal NaN -1 -> 1
-ddcot824 comparetotal NaN -0 -> 1
-ddcot825 comparetotal NaN 0 -> 1
-ddcot826 comparetotal NaN 1 -> 1
-ddcot827 comparetotal NaN 1000 -> 1
-ddcot828 comparetotal NaN Inf -> 1
-ddcot829 comparetotal NaN NaN -> 0
-ddcot830 comparetotal -Inf NaN -> -1
-ddcot831 comparetotal -1000 NaN -> -1
-ddcot832 comparetotal -1 NaN -> -1
-ddcot833 comparetotal -0 NaN -> -1
-ddcot834 comparetotal 0 NaN -> -1
-ddcot835 comparetotal 1 NaN -> -1
-ddcot836 comparetotal 1000 NaN -> -1
-ddcot837 comparetotal Inf NaN -> -1
-ddcot838 comparetotal -NaN -NaN -> 0
-ddcot839 comparetotal +NaN -NaN -> 1
-ddcot840 comparetotal -NaN +NaN -> -1
-
-ddcot841 comparetotal sNaN -sNaN -> 1
-ddcot842 comparetotal sNaN -NaN -> 1
-ddcot843 comparetotal sNaN -Inf -> 1
-ddcot844 comparetotal sNaN -1000 -> 1
-ddcot845 comparetotal sNaN -1 -> 1
-ddcot846 comparetotal sNaN -0 -> 1
-ddcot847 comparetotal sNaN 0 -> 1
-ddcot848 comparetotal sNaN 1 -> 1
-ddcot849 comparetotal sNaN 1000 -> 1
-ddcot850 comparetotal sNaN NaN -> -1
-ddcot851 comparetotal sNaN sNaN -> 0
-
-ddcot852 comparetotal -sNaN sNaN -> -1
-ddcot853 comparetotal -NaN sNaN -> -1
-ddcot854 comparetotal -Inf sNaN -> -1
-ddcot855 comparetotal -1000 sNaN -> -1
-ddcot856 comparetotal -1 sNaN -> -1
-ddcot857 comparetotal -0 sNaN -> -1
-ddcot858 comparetotal 0 sNaN -> -1
-ddcot859 comparetotal 1 sNaN -> -1
-ddcot860 comparetotal 1000 sNaN -> -1
-ddcot861 comparetotal Inf sNaN -> -1
-ddcot862 comparetotal NaN sNaN -> 1
-ddcot863 comparetotal sNaN sNaN -> 0
-
-ddcot871 comparetotal -sNaN -sNaN -> 0
-ddcot872 comparetotal -sNaN -NaN -> 1
-ddcot873 comparetotal -sNaN -Inf -> -1
-ddcot874 comparetotal -sNaN -1000 -> -1
-ddcot875 comparetotal -sNaN -1 -> -1
-ddcot876 comparetotal -sNaN -0 -> -1
-ddcot877 comparetotal -sNaN 0 -> -1
-ddcot878 comparetotal -sNaN 1 -> -1
-ddcot879 comparetotal -sNaN 1000 -> -1
-ddcot880 comparetotal -sNaN NaN -> -1
-ddcot881 comparetotal -sNaN sNaN -> -1
-
-ddcot882 comparetotal -sNaN -sNaN -> 0
-ddcot883 comparetotal -NaN -sNaN -> -1
-ddcot884 comparetotal -Inf -sNaN -> 1
-ddcot885 comparetotal -1000 -sNaN -> 1
-ddcot886 comparetotal -1 -sNaN -> 1
-ddcot887 comparetotal -0 -sNaN -> 1
-ddcot888 comparetotal 0 -sNaN -> 1
-ddcot889 comparetotal 1 -sNaN -> 1
-ddcot890 comparetotal 1000 -sNaN -> 1
-ddcot891 comparetotal Inf -sNaN -> 1
-ddcot892 comparetotal NaN -sNaN -> 1
-ddcot893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-ddcot960 comparetotal NaN9 -Inf -> 1
-ddcot961 comparetotal NaN8 999 -> 1
-ddcot962 comparetotal NaN77 Inf -> 1
-ddcot963 comparetotal -NaN67 NaN5 -> -1
-ddcot964 comparetotal -Inf -NaN4 -> 1
-ddcot965 comparetotal -999 -NaN33 -> 1
-ddcot966 comparetotal Inf NaN2 -> -1
-
-ddcot970 comparetotal -NaN41 -NaN42 -> 1
-ddcot971 comparetotal +NaN41 -NaN42 -> 1
-ddcot972 comparetotal -NaN41 +NaN42 -> -1
-ddcot973 comparetotal +NaN41 +NaN42 -> -1
-ddcot974 comparetotal -NaN42 -NaN01 -> -1
-ddcot975 comparetotal +NaN42 -NaN01 -> 1
-ddcot976 comparetotal -NaN42 +NaN01 -> -1
-ddcot977 comparetotal +NaN42 +NaN01 -> 1
-
-ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
-ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
-ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
-ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
-ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
-ddcot985 comparetotal +sNaN772 -sNaN771 -> 1
-ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
-ddcot987 comparetotal +sNaN772 +sNaN771 -> 1
-
-ddcot991 comparetotal -sNaN99 -Inf -> -1
-ddcot992 comparetotal sNaN98 -11 -> 1
-ddcot993 comparetotal sNaN97 NaN -> -1
-ddcot994 comparetotal sNaN16 sNaN94 -> -1
-ddcot995 comparetotal NaN85 sNaN83 -> 1
-ddcot996 comparetotal -Inf sNaN92 -> -1
-ddcot997 comparetotal 088 sNaN81 -> -1
-ddcot998 comparetotal Inf sNaN90 -> -1
-ddcot999 comparetotal NaN -sNaN89 -> 1
-
--- spread zeros
-ddcot1110 comparetotal 0E-383 0 -> -1
-ddcot1111 comparetotal 0E-383 -0 -> 1
-ddcot1112 comparetotal -0E-383 0 -> -1
-ddcot1113 comparetotal -0E-383 -0 -> 1
-ddcot1114 comparetotal 0E-383 0E+384 -> -1
-ddcot1115 comparetotal 0E-383 -0E+384 -> 1
-ddcot1116 comparetotal -0E-383 0E+384 -> -1
-ddcot1117 comparetotal -0E-383 -0E+384 -> 1
-ddcot1118 comparetotal 0 0E+384 -> -1
-ddcot1119 comparetotal 0 -0E+384 -> 1
-ddcot1120 comparetotal -0 0E+384 -> -1
-ddcot1121 comparetotal -0 -0E+384 -> 1
-
-ddcot1130 comparetotal 0E+384 0 -> 1
-ddcot1131 comparetotal 0E+384 -0 -> 1
-ddcot1132 comparetotal -0E+384 0 -> -1
-ddcot1133 comparetotal -0E+384 -0 -> -1
-ddcot1134 comparetotal 0E+384 0E-383 -> 1
-ddcot1135 comparetotal 0E+384 -0E-383 -> 1
-ddcot1136 comparetotal -0E+384 0E-383 -> -1
-ddcot1137 comparetotal -0E+384 -0E-383 -> -1
-ddcot1138 comparetotal 0 0E-383 -> 1
-ddcot1139 comparetotal 0 -0E-383 -> 1
-ddcot1140 comparetotal -0 0E-383 -> -1
-ddcot1141 comparetotal -0 -0E-383 -> -1
-
--- Null tests
-ddcot9990 comparetotal 10 # -> NaN Invalid_operation
-ddcot9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareTotal.decTest -- decDouble comparison using total ordering--
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddcot001 comparetotal -2 -2 -> 0
+ddcot002 comparetotal -2 -1 -> -1
+ddcot003 comparetotal -2 0 -> -1
+ddcot004 comparetotal -2 1 -> -1
+ddcot005 comparetotal -2 2 -> -1
+ddcot006 comparetotal -1 -2 -> 1
+ddcot007 comparetotal -1 -1 -> 0
+ddcot008 comparetotal -1 0 -> -1
+ddcot009 comparetotal -1 1 -> -1
+ddcot010 comparetotal -1 2 -> -1
+ddcot011 comparetotal 0 -2 -> 1
+ddcot012 comparetotal 0 -1 -> 1
+ddcot013 comparetotal 0 0 -> 0
+ddcot014 comparetotal 0 1 -> -1
+ddcot015 comparetotal 0 2 -> -1
+ddcot016 comparetotal 1 -2 -> 1
+ddcot017 comparetotal 1 -1 -> 1
+ddcot018 comparetotal 1 0 -> 1
+ddcot019 comparetotal 1 1 -> 0
+ddcot020 comparetotal 1 2 -> -1
+ddcot021 comparetotal 2 -2 -> 1
+ddcot022 comparetotal 2 -1 -> 1
+ddcot023 comparetotal 2 0 -> 1
+ddcot025 comparetotal 2 1 -> 1
+ddcot026 comparetotal 2 2 -> 0
+
+ddcot031 comparetotal -20 -20 -> 0
+ddcot032 comparetotal -20 -10 -> -1
+ddcot033 comparetotal -20 00 -> -1
+ddcot034 comparetotal -20 10 -> -1
+ddcot035 comparetotal -20 20 -> -1
+ddcot036 comparetotal -10 -20 -> 1
+ddcot037 comparetotal -10 -10 -> 0
+ddcot038 comparetotal -10 00 -> -1
+ddcot039 comparetotal -10 10 -> -1
+ddcot040 comparetotal -10 20 -> -1
+ddcot041 comparetotal 00 -20 -> 1
+ddcot042 comparetotal 00 -10 -> 1
+ddcot043 comparetotal 00 00 -> 0
+ddcot044 comparetotal 00 10 -> -1
+ddcot045 comparetotal 00 20 -> -1
+ddcot046 comparetotal 10 -20 -> 1
+ddcot047 comparetotal 10 -10 -> 1
+ddcot048 comparetotal 10 00 -> 1
+ddcot049 comparetotal 10 10 -> 0
+ddcot050 comparetotal 10 20 -> -1
+ddcot051 comparetotal 20 -20 -> 1
+ddcot052 comparetotal 20 -10 -> 1
+ddcot053 comparetotal 20 00 -> 1
+ddcot055 comparetotal 20 10 -> 1
+ddcot056 comparetotal 20 20 -> 0
+
+ddcot061 comparetotal -2.0 -2.0 -> 0
+ddcot062 comparetotal -2.0 -1.0 -> -1
+ddcot063 comparetotal -2.0 0.0 -> -1
+ddcot064 comparetotal -2.0 1.0 -> -1
+ddcot065 comparetotal -2.0 2.0 -> -1
+ddcot066 comparetotal -1.0 -2.0 -> 1
+ddcot067 comparetotal -1.0 -1.0 -> 0
+ddcot068 comparetotal -1.0 0.0 -> -1
+ddcot069 comparetotal -1.0 1.0 -> -1
+ddcot070 comparetotal -1.0 2.0 -> -1
+ddcot071 comparetotal 0.0 -2.0 -> 1
+ddcot072 comparetotal 0.0 -1.0 -> 1
+ddcot073 comparetotal 0.0 0.0 -> 0
+ddcot074 comparetotal 0.0 1.0 -> -1
+ddcot075 comparetotal 0.0 2.0 -> -1
+ddcot076 comparetotal 1.0 -2.0 -> 1
+ddcot077 comparetotal 1.0 -1.0 -> 1
+ddcot078 comparetotal 1.0 0.0 -> 1
+ddcot079 comparetotal 1.0 1.0 -> 0
+ddcot080 comparetotal 1.0 2.0 -> -1
+ddcot081 comparetotal 2.0 -2.0 -> 1
+ddcot082 comparetotal 2.0 -1.0 -> 1
+ddcot083 comparetotal 2.0 0.0 -> 1
+ddcot085 comparetotal 2.0 1.0 -> 1
+ddcot086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddcot090 comparetotal 9.99999999E+384 9.99999999E+384 -> 0
+ddcot091 comparetotal -9.99999999E+384 9.99999999E+384 -> -1
+ddcot092 comparetotal 9.99999999E+384 -9.99999999E+384 -> 1
+ddcot093 comparetotal -9.99999999E+384 -9.99999999E+384 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ddcot100 comparetotal 7.0 7.0 -> 0
+ddcot101 comparetotal 7.0 7 -> -1
+ddcot102 comparetotal 7 7.0 -> 1
+ddcot103 comparetotal 7E+0 7.0 -> 1
+ddcot104 comparetotal 70E-1 7.0 -> 0
+ddcot105 comparetotal 0.7E+1 7 -> 0
+ddcot106 comparetotal 70E-1 7 -> -1
+ddcot107 comparetotal 7.0 7E+0 -> -1
+ddcot108 comparetotal 7.0 70E-1 -> 0
+ddcot109 comparetotal 7 0.7E+1 -> 0
+ddcot110 comparetotal 7 70E-1 -> 1
+
+ddcot120 comparetotal 8.0 7.0 -> 1
+ddcot121 comparetotal 8.0 7 -> 1
+ddcot122 comparetotal 8 7.0 -> 1
+ddcot123 comparetotal 8E+0 7.0 -> 1
+ddcot124 comparetotal 80E-1 7.0 -> 1
+ddcot125 comparetotal 0.8E+1 7 -> 1
+ddcot126 comparetotal 80E-1 7 -> 1
+ddcot127 comparetotal 8.0 7E+0 -> 1
+ddcot128 comparetotal 8.0 70E-1 -> 1
+ddcot129 comparetotal 8 0.7E+1 -> 1
+ddcot130 comparetotal 8 70E-1 -> 1
+
+ddcot140 comparetotal 8.0 9.0 -> -1
+ddcot141 comparetotal 8.0 9 -> -1
+ddcot142 comparetotal 8 9.0 -> -1
+ddcot143 comparetotal 8E+0 9.0 -> -1
+ddcot144 comparetotal 80E-1 9.0 -> -1
+ddcot145 comparetotal 0.8E+1 9 -> -1
+ddcot146 comparetotal 80E-1 9 -> -1
+ddcot147 comparetotal 8.0 9E+0 -> -1
+ddcot148 comparetotal 8.0 90E-1 -> -1
+ddcot149 comparetotal 8 0.9E+1 -> -1
+ddcot150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddcot200 comparetotal -7.0 7.0 -> -1
+ddcot201 comparetotal -7.0 7 -> -1
+ddcot202 comparetotal -7 7.0 -> -1
+ddcot203 comparetotal -7E+0 7.0 -> -1
+ddcot204 comparetotal -70E-1 7.0 -> -1
+ddcot205 comparetotal -0.7E+1 7 -> -1
+ddcot206 comparetotal -70E-1 7 -> -1
+ddcot207 comparetotal -7.0 7E+0 -> -1
+ddcot208 comparetotal -7.0 70E-1 -> -1
+ddcot209 comparetotal -7 0.7E+1 -> -1
+ddcot210 comparetotal -7 70E-1 -> -1
+
+ddcot220 comparetotal -8.0 7.0 -> -1
+ddcot221 comparetotal -8.0 7 -> -1
+ddcot222 comparetotal -8 7.0 -> -1
+ddcot223 comparetotal -8E+0 7.0 -> -1
+ddcot224 comparetotal -80E-1 7.0 -> -1
+ddcot225 comparetotal -0.8E+1 7 -> -1
+ddcot226 comparetotal -80E-1 7 -> -1
+ddcot227 comparetotal -8.0 7E+0 -> -1
+ddcot228 comparetotal -8.0 70E-1 -> -1
+ddcot229 comparetotal -8 0.7E+1 -> -1
+ddcot230 comparetotal -8 70E-1 -> -1
+
+ddcot240 comparetotal -8.0 9.0 -> -1
+ddcot241 comparetotal -8.0 9 -> -1
+ddcot242 comparetotal -8 9.0 -> -1
+ddcot243 comparetotal -8E+0 9.0 -> -1
+ddcot244 comparetotal -80E-1 9.0 -> -1
+ddcot245 comparetotal -0.8E+1 9 -> -1
+ddcot246 comparetotal -80E-1 9 -> -1
+ddcot247 comparetotal -8.0 9E+0 -> -1
+ddcot248 comparetotal -8.0 90E-1 -> -1
+ddcot249 comparetotal -8 0.9E+1 -> -1
+ddcot250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddcot300 comparetotal 7.0 -7.0 -> 1
+ddcot301 comparetotal 7.0 -7 -> 1
+ddcot302 comparetotal 7 -7.0 -> 1
+ddcot303 comparetotal 7E+0 -7.0 -> 1
+ddcot304 comparetotal 70E-1 -7.0 -> 1
+ddcot305 comparetotal .7E+1 -7 -> 1
+ddcot306 comparetotal 70E-1 -7 -> 1
+ddcot307 comparetotal 7.0 -7E+0 -> 1
+ddcot308 comparetotal 7.0 -70E-1 -> 1
+ddcot309 comparetotal 7 -.7E+1 -> 1
+ddcot310 comparetotal 7 -70E-1 -> 1
+
+ddcot320 comparetotal 8.0 -7.0 -> 1
+ddcot321 comparetotal 8.0 -7 -> 1
+ddcot322 comparetotal 8 -7.0 -> 1
+ddcot323 comparetotal 8E+0 -7.0 -> 1
+ddcot324 comparetotal 80E-1 -7.0 -> 1
+ddcot325 comparetotal .8E+1 -7 -> 1
+ddcot326 comparetotal 80E-1 -7 -> 1
+ddcot327 comparetotal 8.0 -7E+0 -> 1
+ddcot328 comparetotal 8.0 -70E-1 -> 1
+ddcot329 comparetotal 8 -.7E+1 -> 1
+ddcot330 comparetotal 8 -70E-1 -> 1
+
+ddcot340 comparetotal 8.0 -9.0 -> 1
+ddcot341 comparetotal 8.0 -9 -> 1
+ddcot342 comparetotal 8 -9.0 -> 1
+ddcot343 comparetotal 8E+0 -9.0 -> 1
+ddcot344 comparetotal 80E-1 -9.0 -> 1
+ddcot345 comparetotal .8E+1 -9 -> 1
+ddcot346 comparetotal 80E-1 -9 -> 1
+ddcot347 comparetotal 8.0 -9E+0 -> 1
+ddcot348 comparetotal 8.0 -90E-1 -> 1
+ddcot349 comparetotal 8 -.9E+1 -> 1
+ddcot350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+ddcot400 comparetotal -7.0 -7.0 -> 0
+ddcot401 comparetotal -7.0 -7 -> 1
+ddcot402 comparetotal -7 -7.0 -> -1
+ddcot403 comparetotal -7E+0 -7.0 -> -1
+ddcot404 comparetotal -70E-1 -7.0 -> 0
+ddcot405 comparetotal -.7E+1 -7 -> 0
+ddcot406 comparetotal -70E-1 -7 -> 1
+ddcot407 comparetotal -7.0 -7E+0 -> 1
+ddcot408 comparetotal -7.0 -70E-1 -> 0
+ddcot409 comparetotal -7 -.7E+1 -> 0
+ddcot410 comparetotal -7 -70E-1 -> -1
+
+ddcot420 comparetotal -8.0 -7.0 -> -1
+ddcot421 comparetotal -8.0 -7 -> -1
+ddcot422 comparetotal -8 -7.0 -> -1
+ddcot423 comparetotal -8E+0 -7.0 -> -1
+ddcot424 comparetotal -80E-1 -7.0 -> -1
+ddcot425 comparetotal -.8E+1 -7 -> -1
+ddcot426 comparetotal -80E-1 -7 -> -1
+ddcot427 comparetotal -8.0 -7E+0 -> -1
+ddcot428 comparetotal -8.0 -70E-1 -> -1
+ddcot429 comparetotal -8 -.7E+1 -> -1
+ddcot430 comparetotal -8 -70E-1 -> -1
+
+ddcot440 comparetotal -8.0 -9.0 -> 1
+ddcot441 comparetotal -8.0 -9 -> 1
+ddcot442 comparetotal -8 -9.0 -> 1
+ddcot443 comparetotal -8E+0 -9.0 -> 1
+ddcot444 comparetotal -80E-1 -9.0 -> 1
+ddcot445 comparetotal -.8E+1 -9 -> 1
+ddcot446 comparetotal -80E-1 -9 -> 1
+ddcot447 comparetotal -8.0 -9E+0 -> 1
+ddcot448 comparetotal -8.0 -90E-1 -> 1
+ddcot449 comparetotal -8 -.9E+1 -> 1
+ddcot450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+ddcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
+ddcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+ddcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
+ddcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+ddcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
+ddcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+ddcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
+ddcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
+ddcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
+ddcot483 comparetotal 123.456E-89 123.456E-89 -> 0
+ddcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
+ddcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+ddcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
+ddcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+ddcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
+ddcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+ddcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
+ddcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
+ddcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
+ddcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
+ddcot497 comparetotal 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddcot498 comparetotal 1 1E-17 -> 1
+ddcot499 comparetotal 1 1E-16 -> 1
+ddcot500 comparetotal 1 1E-15 -> 1
+ddcot501 comparetotal 1 1E-14 -> 1
+ddcot502 comparetotal 1 1E-13 -> 1
+ddcot503 comparetotal 1 1E-12 -> 1
+ddcot504 comparetotal 1 1E-11 -> 1
+ddcot505 comparetotal 1 1E-10 -> 1
+ddcot506 comparetotal 1 1E-9 -> 1
+ddcot507 comparetotal 1 1E-8 -> 1
+ddcot508 comparetotal 1 1E-7 -> 1
+ddcot509 comparetotal 1 1E-6 -> 1
+ddcot510 comparetotal 1 1E-5 -> 1
+ddcot511 comparetotal 1 1E-4 -> 1
+ddcot512 comparetotal 1 1E-3 -> 1
+ddcot513 comparetotal 1 1E-2 -> 1
+ddcot514 comparetotal 1 1E-1 -> 1
+ddcot515 comparetotal 1 1E-0 -> 0
+ddcot516 comparetotal 1 1E+1 -> -1
+ddcot517 comparetotal 1 1E+2 -> -1
+ddcot518 comparetotal 1 1E+3 -> -1
+ddcot519 comparetotal 1 1E+4 -> -1
+ddcot521 comparetotal 1 1E+5 -> -1
+ddcot522 comparetotal 1 1E+6 -> -1
+ddcot523 comparetotal 1 1E+7 -> -1
+ddcot524 comparetotal 1 1E+8 -> -1
+ddcot525 comparetotal 1 1E+9 -> -1
+ddcot526 comparetotal 1 1E+10 -> -1
+ddcot527 comparetotal 1 1E+11 -> -1
+ddcot528 comparetotal 1 1E+12 -> -1
+ddcot529 comparetotal 1 1E+13 -> -1
+ddcot530 comparetotal 1 1E+14 -> -1
+ddcot531 comparetotal 1 1E+15 -> -1
+ddcot532 comparetotal 1 1E+16 -> -1
+ddcot533 comparetotal 1 1E+17 -> -1
+-- LR swap
+ddcot538 comparetotal 1E-17 1 -> -1
+ddcot539 comparetotal 1E-16 1 -> -1
+ddcot540 comparetotal 1E-15 1 -> -1
+ddcot541 comparetotal 1E-14 1 -> -1
+ddcot542 comparetotal 1E-13 1 -> -1
+ddcot543 comparetotal 1E-12 1 -> -1
+ddcot544 comparetotal 1E-11 1 -> -1
+ddcot545 comparetotal 1E-10 1 -> -1
+ddcot546 comparetotal 1E-9 1 -> -1
+ddcot547 comparetotal 1E-8 1 -> -1
+ddcot548 comparetotal 1E-7 1 -> -1
+ddcot549 comparetotal 1E-6 1 -> -1
+ddcot550 comparetotal 1E-5 1 -> -1
+ddcot551 comparetotal 1E-4 1 -> -1
+ddcot552 comparetotal 1E-3 1 -> -1
+ddcot553 comparetotal 1E-2 1 -> -1
+ddcot554 comparetotal 1E-1 1 -> -1
+ddcot555 comparetotal 1E-0 1 -> 0
+ddcot556 comparetotal 1E+1 1 -> 1
+ddcot557 comparetotal 1E+2 1 -> 1
+ddcot558 comparetotal 1E+3 1 -> 1
+ddcot559 comparetotal 1E+4 1 -> 1
+ddcot561 comparetotal 1E+5 1 -> 1
+ddcot562 comparetotal 1E+6 1 -> 1
+ddcot563 comparetotal 1E+7 1 -> 1
+ddcot564 comparetotal 1E+8 1 -> 1
+ddcot565 comparetotal 1E+9 1 -> 1
+ddcot566 comparetotal 1E+10 1 -> 1
+ddcot567 comparetotal 1E+11 1 -> 1
+ddcot568 comparetotal 1E+12 1 -> 1
+ddcot569 comparetotal 1E+13 1 -> 1
+ddcot570 comparetotal 1E+14 1 -> 1
+ddcot571 comparetotal 1E+15 1 -> 1
+ddcot572 comparetotal 1E+16 1 -> 1
+ddcot573 comparetotal 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+ddcot578 comparetotal 0.000000987654321 1E-17 -> 1
+ddcot579 comparetotal 0.000000987654321 1E-16 -> 1
+ddcot580 comparetotal 0.000000987654321 1E-15 -> 1
+ddcot581 comparetotal 0.000000987654321 1E-14 -> 1
+ddcot582 comparetotal 0.000000987654321 1E-13 -> 1
+ddcot583 comparetotal 0.000000987654321 1E-12 -> 1
+ddcot584 comparetotal 0.000000987654321 1E-11 -> 1
+ddcot585 comparetotal 0.000000987654321 1E-10 -> 1
+ddcot586 comparetotal 0.000000987654321 1E-9 -> 1
+ddcot587 comparetotal 0.000000987654321 1E-8 -> 1
+ddcot588 comparetotal 0.000000987654321 1E-7 -> 1
+ddcot589 comparetotal 0.000000987654321 1E-6 -> -1
+ddcot590 comparetotal 0.000000987654321 1E-5 -> -1
+ddcot591 comparetotal 0.000000987654321 1E-4 -> -1
+ddcot592 comparetotal 0.000000987654321 1E-3 -> -1
+ddcot593 comparetotal 0.000000987654321 1E-2 -> -1
+ddcot594 comparetotal 0.000000987654321 1E-1 -> -1
+ddcot595 comparetotal 0.000000987654321 1E-0 -> -1
+ddcot596 comparetotal 0.000000987654321 1E+1 -> -1
+ddcot597 comparetotal 0.000000987654321 1E+2 -> -1
+ddcot598 comparetotal 0.000000987654321 1E+3 -> -1
+ddcot599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddcot600 comparetotal 12 12.2345 -> -1
+ddcot601 comparetotal 12.0 12.2345 -> -1
+ddcot602 comparetotal 12.00 12.2345 -> -1
+ddcot603 comparetotal 12.000 12.2345 -> -1
+ddcot604 comparetotal 12.0000 12.2345 -> -1
+ddcot605 comparetotal 12.00000 12.2345 -> -1
+ddcot606 comparetotal 12.000000 12.2345 -> -1
+ddcot607 comparetotal 12.0000000 12.2345 -> -1
+ddcot608 comparetotal 12.00000000 12.2345 -> -1
+ddcot609 comparetotal 12.000000000 12.2345 -> -1
+ddcot610 comparetotal 12.1234 12 -> 1
+ddcot611 comparetotal 12.1234 12.0 -> 1
+ddcot612 comparetotal 12.1234 12.00 -> 1
+ddcot613 comparetotal 12.1234 12.000 -> 1
+ddcot614 comparetotal 12.1234 12.0000 -> 1
+ddcot615 comparetotal 12.1234 12.00000 -> 1
+ddcot616 comparetotal 12.1234 12.000000 -> 1
+ddcot617 comparetotal 12.1234 12.0000000 -> 1
+ddcot618 comparetotal 12.1234 12.00000000 -> 1
+ddcot619 comparetotal 12.1234 12.000000000 -> 1
+ddcot620 comparetotal -12 -12.2345 -> 1
+ddcot621 comparetotal -12.0 -12.2345 -> 1
+ddcot622 comparetotal -12.00 -12.2345 -> 1
+ddcot623 comparetotal -12.000 -12.2345 -> 1
+ddcot624 comparetotal -12.0000 -12.2345 -> 1
+ddcot625 comparetotal -12.00000 -12.2345 -> 1
+ddcot626 comparetotal -12.000000 -12.2345 -> 1
+ddcot627 comparetotal -12.0000000 -12.2345 -> 1
+ddcot628 comparetotal -12.00000000 -12.2345 -> 1
+ddcot629 comparetotal -12.000000000 -12.2345 -> 1
+ddcot630 comparetotal -12.1234 -12 -> -1
+ddcot631 comparetotal -12.1234 -12.0 -> -1
+ddcot632 comparetotal -12.1234 -12.00 -> -1
+ddcot633 comparetotal -12.1234 -12.000 -> -1
+ddcot634 comparetotal -12.1234 -12.0000 -> -1
+ddcot635 comparetotal -12.1234 -12.00000 -> -1
+ddcot636 comparetotal -12.1234 -12.000000 -> -1
+ddcot637 comparetotal -12.1234 -12.0000000 -> -1
+ddcot638 comparetotal -12.1234 -12.00000000 -> -1
+ddcot639 comparetotal -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+ddcot640 comparetotal 0 0 -> 0
+ddcot641 comparetotal 0 -0 -> 1
+ddcot642 comparetotal 0 -0.0 -> 1
+ddcot643 comparetotal 0 0.0 -> 1
+ddcot644 comparetotal -0 0 -> -1
+ddcot645 comparetotal -0 -0 -> 0
+ddcot646 comparetotal -0 -0.0 -> -1
+ddcot647 comparetotal -0 0.0 -> -1
+ddcot648 comparetotal 0.0 0 -> -1
+ddcot649 comparetotal 0.0 -0 -> 1
+ddcot650 comparetotal 0.0 -0.0 -> 1
+ddcot651 comparetotal 0.0 0.0 -> 0
+ddcot652 comparetotal -0.0 0 -> -1
+ddcot653 comparetotal -0.0 -0 -> 1
+ddcot654 comparetotal -0.0 -0.0 -> 0
+ddcot655 comparetotal -0.0 0.0 -> -1
+
+ddcot656 comparetotal -0E1 0.0 -> -1
+ddcot657 comparetotal -0E2 0.0 -> -1
+ddcot658 comparetotal 0E1 0.0 -> 1
+ddcot659 comparetotal 0E2 0.0 -> 1
+ddcot660 comparetotal -0E1 0 -> -1
+ddcot661 comparetotal -0E2 0 -> -1
+ddcot662 comparetotal 0E1 0 -> 1
+ddcot663 comparetotal 0E2 0 -> 1
+ddcot664 comparetotal -0E1 -0E1 -> 0
+ddcot665 comparetotal -0E2 -0E1 -> -1
+ddcot666 comparetotal 0E1 -0E1 -> 1
+ddcot667 comparetotal 0E2 -0E1 -> 1
+ddcot668 comparetotal -0E1 -0E2 -> 1
+ddcot669 comparetotal -0E2 -0E2 -> 0
+ddcot670 comparetotal 0E1 -0E2 -> 1
+ddcot671 comparetotal 0E2 -0E2 -> 1
+ddcot672 comparetotal -0E1 0E1 -> -1
+ddcot673 comparetotal -0E2 0E1 -> -1
+ddcot674 comparetotal 0E1 0E1 -> 0
+ddcot675 comparetotal 0E2 0E1 -> 1
+ddcot676 comparetotal -0E1 0E2 -> -1
+ddcot677 comparetotal -0E2 0E2 -> -1
+ddcot678 comparetotal 0E1 0E2 -> -1
+ddcot679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddcot680 comparetotal 12 12 -> 0
+ddcot681 comparetotal 12 12.0 -> 1
+ddcot682 comparetotal 12 12.00 -> 1
+ddcot683 comparetotal 12 12.000 -> 1
+ddcot684 comparetotal 12 12.0000 -> 1
+ddcot685 comparetotal 12 12.00000 -> 1
+ddcot686 comparetotal 12 12.000000 -> 1
+ddcot687 comparetotal 12 12.0000000 -> 1
+ddcot688 comparetotal 12 12.00000000 -> 1
+ddcot689 comparetotal 12 12.000000000 -> 1
+ddcot690 comparetotal 12 12 -> 0
+ddcot691 comparetotal 12.0 12 -> -1
+ddcot692 comparetotal 12.00 12 -> -1
+ddcot693 comparetotal 12.000 12 -> -1
+ddcot694 comparetotal 12.0000 12 -> -1
+ddcot695 comparetotal 12.00000 12 -> -1
+ddcot696 comparetotal 12.000000 12 -> -1
+ddcot697 comparetotal 12.0000000 12 -> -1
+ddcot698 comparetotal 12.00000000 12 -> -1
+ddcot699 comparetotal 12.000000000 12 -> -1
+
+-- old long operand checks
+ddcot701 comparetotal 12345678000 1 -> 1
+ddcot702 comparetotal 1 12345678000 -> -1
+ddcot703 comparetotal 1234567800 1 -> 1
+ddcot704 comparetotal 1 1234567800 -> -1
+ddcot705 comparetotal 1234567890 1 -> 1
+ddcot706 comparetotal 1 1234567890 -> -1
+ddcot707 comparetotal 1234567891 1 -> 1
+ddcot708 comparetotal 1 1234567891 -> -1
+ddcot709 comparetotal 12345678901 1 -> 1
+ddcot710 comparetotal 1 12345678901 -> -1
+ddcot711 comparetotal 1234567896 1 -> 1
+ddcot712 comparetotal 1 1234567896 -> -1
+ddcot713 comparetotal -1234567891 1 -> -1
+ddcot714 comparetotal 1 -1234567891 -> 1
+ddcot715 comparetotal -12345678901 1 -> -1
+ddcot716 comparetotal 1 -12345678901 -> 1
+ddcot717 comparetotal -1234567896 1 -> -1
+ddcot718 comparetotal 1 -1234567896 -> 1
+
+-- old residue cases
+ddcot740 comparetotal 1 0.9999999 -> 1
+ddcot741 comparetotal 1 0.999999 -> 1
+ddcot742 comparetotal 1 0.99999 -> 1
+ddcot743 comparetotal 1 1.0000 -> 1
+ddcot744 comparetotal 1 1.00001 -> -1
+ddcot745 comparetotal 1 1.000001 -> -1
+ddcot746 comparetotal 1 1.0000001 -> -1
+ddcot750 comparetotal 0.9999999 1 -> -1
+ddcot751 comparetotal 0.999999 1 -> -1
+ddcot752 comparetotal 0.99999 1 -> -1
+ddcot753 comparetotal 1.0000 1 -> -1
+ddcot754 comparetotal 1.00001 1 -> 1
+ddcot755 comparetotal 1.000001 1 -> 1
+ddcot756 comparetotal 1.0000001 1 -> 1
+
+-- Specials
+ddcot780 comparetotal Inf -Inf -> 1
+ddcot781 comparetotal Inf -1000 -> 1
+ddcot782 comparetotal Inf -1 -> 1
+ddcot783 comparetotal Inf -0 -> 1
+ddcot784 comparetotal Inf 0 -> 1
+ddcot785 comparetotal Inf 1 -> 1
+ddcot786 comparetotal Inf 1000 -> 1
+ddcot787 comparetotal Inf Inf -> 0
+ddcot788 comparetotal -1000 Inf -> -1
+ddcot789 comparetotal -Inf Inf -> -1
+ddcot790 comparetotal -1 Inf -> -1
+ddcot791 comparetotal -0 Inf -> -1
+ddcot792 comparetotal 0 Inf -> -1
+ddcot793 comparetotal 1 Inf -> -1
+ddcot794 comparetotal 1000 Inf -> -1
+ddcot795 comparetotal Inf Inf -> 0
+
+ddcot800 comparetotal -Inf -Inf -> 0
+ddcot801 comparetotal -Inf -1000 -> -1
+ddcot802 comparetotal -Inf -1 -> -1
+ddcot803 comparetotal -Inf -0 -> -1
+ddcot804 comparetotal -Inf 0 -> -1
+ddcot805 comparetotal -Inf 1 -> -1
+ddcot806 comparetotal -Inf 1000 -> -1
+ddcot807 comparetotal -Inf Inf -> -1
+ddcot808 comparetotal -Inf -Inf -> 0
+ddcot809 comparetotal -1000 -Inf -> 1
+ddcot810 comparetotal -1 -Inf -> 1
+ddcot811 comparetotal -0 -Inf -> 1
+ddcot812 comparetotal 0 -Inf -> 1
+ddcot813 comparetotal 1 -Inf -> 1
+ddcot814 comparetotal 1000 -Inf -> 1
+ddcot815 comparetotal Inf -Inf -> 1
+
+ddcot821 comparetotal NaN -Inf -> 1
+ddcot822 comparetotal NaN -1000 -> 1
+ddcot823 comparetotal NaN -1 -> 1
+ddcot824 comparetotal NaN -0 -> 1
+ddcot825 comparetotal NaN 0 -> 1
+ddcot826 comparetotal NaN 1 -> 1
+ddcot827 comparetotal NaN 1000 -> 1
+ddcot828 comparetotal NaN Inf -> 1
+ddcot829 comparetotal NaN NaN -> 0
+ddcot830 comparetotal -Inf NaN -> -1
+ddcot831 comparetotal -1000 NaN -> -1
+ddcot832 comparetotal -1 NaN -> -1
+ddcot833 comparetotal -0 NaN -> -1
+ddcot834 comparetotal 0 NaN -> -1
+ddcot835 comparetotal 1 NaN -> -1
+ddcot836 comparetotal 1000 NaN -> -1
+ddcot837 comparetotal Inf NaN -> -1
+ddcot838 comparetotal -NaN -NaN -> 0
+ddcot839 comparetotal +NaN -NaN -> 1
+ddcot840 comparetotal -NaN +NaN -> -1
+
+ddcot841 comparetotal sNaN -sNaN -> 1
+ddcot842 comparetotal sNaN -NaN -> 1
+ddcot843 comparetotal sNaN -Inf -> 1
+ddcot844 comparetotal sNaN -1000 -> 1
+ddcot845 comparetotal sNaN -1 -> 1
+ddcot846 comparetotal sNaN -0 -> 1
+ddcot847 comparetotal sNaN 0 -> 1
+ddcot848 comparetotal sNaN 1 -> 1
+ddcot849 comparetotal sNaN 1000 -> 1
+ddcot850 comparetotal sNaN NaN -> -1
+ddcot851 comparetotal sNaN sNaN -> 0
+
+ddcot852 comparetotal -sNaN sNaN -> -1
+ddcot853 comparetotal -NaN sNaN -> -1
+ddcot854 comparetotal -Inf sNaN -> -1
+ddcot855 comparetotal -1000 sNaN -> -1
+ddcot856 comparetotal -1 sNaN -> -1
+ddcot857 comparetotal -0 sNaN -> -1
+ddcot858 comparetotal 0 sNaN -> -1
+ddcot859 comparetotal 1 sNaN -> -1
+ddcot860 comparetotal 1000 sNaN -> -1
+ddcot861 comparetotal Inf sNaN -> -1
+ddcot862 comparetotal NaN sNaN -> 1
+ddcot863 comparetotal sNaN sNaN -> 0
+
+ddcot871 comparetotal -sNaN -sNaN -> 0
+ddcot872 comparetotal -sNaN -NaN -> 1
+ddcot873 comparetotal -sNaN -Inf -> -1
+ddcot874 comparetotal -sNaN -1000 -> -1
+ddcot875 comparetotal -sNaN -1 -> -1
+ddcot876 comparetotal -sNaN -0 -> -1
+ddcot877 comparetotal -sNaN 0 -> -1
+ddcot878 comparetotal -sNaN 1 -> -1
+ddcot879 comparetotal -sNaN 1000 -> -1
+ddcot880 comparetotal -sNaN NaN -> -1
+ddcot881 comparetotal -sNaN sNaN -> -1
+
+ddcot882 comparetotal -sNaN -sNaN -> 0
+ddcot883 comparetotal -NaN -sNaN -> -1
+ddcot884 comparetotal -Inf -sNaN -> 1
+ddcot885 comparetotal -1000 -sNaN -> 1
+ddcot886 comparetotal -1 -sNaN -> 1
+ddcot887 comparetotal -0 -sNaN -> 1
+ddcot888 comparetotal 0 -sNaN -> 1
+ddcot889 comparetotal 1 -sNaN -> 1
+ddcot890 comparetotal 1000 -sNaN -> 1
+ddcot891 comparetotal Inf -sNaN -> 1
+ddcot892 comparetotal NaN -sNaN -> 1
+ddcot893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+ddcot960 comparetotal NaN9 -Inf -> 1
+ddcot961 comparetotal NaN8 999 -> 1
+ddcot962 comparetotal NaN77 Inf -> 1
+ddcot963 comparetotal -NaN67 NaN5 -> -1
+ddcot964 comparetotal -Inf -NaN4 -> 1
+ddcot965 comparetotal -999 -NaN33 -> 1
+ddcot966 comparetotal Inf NaN2 -> -1
+
+ddcot970 comparetotal -NaN41 -NaN42 -> 1
+ddcot971 comparetotal +NaN41 -NaN42 -> 1
+ddcot972 comparetotal -NaN41 +NaN42 -> -1
+ddcot973 comparetotal +NaN41 +NaN42 -> -1
+ddcot974 comparetotal -NaN42 -NaN01 -> -1
+ddcot975 comparetotal +NaN42 -NaN01 -> 1
+ddcot976 comparetotal -NaN42 +NaN01 -> -1
+ddcot977 comparetotal +NaN42 +NaN01 -> 1
+
+ddcot980 comparetotal -sNaN771 -sNaN772 -> 1
+ddcot981 comparetotal +sNaN771 -sNaN772 -> 1
+ddcot982 comparetotal -sNaN771 +sNaN772 -> -1
+ddcot983 comparetotal +sNaN771 +sNaN772 -> -1
+ddcot984 comparetotal -sNaN772 -sNaN771 -> -1
+ddcot985 comparetotal +sNaN772 -sNaN771 -> 1
+ddcot986 comparetotal -sNaN772 +sNaN771 -> -1
+ddcot987 comparetotal +sNaN772 +sNaN771 -> 1
+
+ddcot991 comparetotal -sNaN99 -Inf -> -1
+ddcot992 comparetotal sNaN98 -11 -> 1
+ddcot993 comparetotal sNaN97 NaN -> -1
+ddcot994 comparetotal sNaN16 sNaN94 -> -1
+ddcot995 comparetotal NaN85 sNaN83 -> 1
+ddcot996 comparetotal -Inf sNaN92 -> -1
+ddcot997 comparetotal 088 sNaN81 -> -1
+ddcot998 comparetotal Inf sNaN90 -> -1
+ddcot999 comparetotal NaN -sNaN89 -> 1
+
+-- spread zeros
+ddcot1110 comparetotal 0E-383 0 -> -1
+ddcot1111 comparetotal 0E-383 -0 -> 1
+ddcot1112 comparetotal -0E-383 0 -> -1
+ddcot1113 comparetotal -0E-383 -0 -> 1
+ddcot1114 comparetotal 0E-383 0E+384 -> -1
+ddcot1115 comparetotal 0E-383 -0E+384 -> 1
+ddcot1116 comparetotal -0E-383 0E+384 -> -1
+ddcot1117 comparetotal -0E-383 -0E+384 -> 1
+ddcot1118 comparetotal 0 0E+384 -> -1
+ddcot1119 comparetotal 0 -0E+384 -> 1
+ddcot1120 comparetotal -0 0E+384 -> -1
+ddcot1121 comparetotal -0 -0E+384 -> 1
+
+ddcot1130 comparetotal 0E+384 0 -> 1
+ddcot1131 comparetotal 0E+384 -0 -> 1
+ddcot1132 comparetotal -0E+384 0 -> -1
+ddcot1133 comparetotal -0E+384 -0 -> -1
+ddcot1134 comparetotal 0E+384 0E-383 -> 1
+ddcot1135 comparetotal 0E+384 -0E-383 -> 1
+ddcot1136 comparetotal -0E+384 0E-383 -> -1
+ddcot1137 comparetotal -0E+384 -0E-383 -> -1
+ddcot1138 comparetotal 0 0E-383 -> 1
+ddcot1139 comparetotal 0 -0E-383 -> 1
+ddcot1140 comparetotal -0 0E-383 -> -1
+ddcot1141 comparetotal -0 -0E-383 -> -1
+
+-- Null tests
+ddcot9990 comparetotal 10 # -> NaN Invalid_operation
+ddcot9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCompareTotalMag.decTest b/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
index 087a092f0b0..f16537a35d7 100644
--- a/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
+++ b/Lib/test/decimaltestdata/ddCompareTotalMag.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddctm001 comparetotmag -2 -2 -> 0
-ddctm002 comparetotmag -2 -1 -> 1
-ddctm003 comparetotmag -2 0 -> 1
-ddctm004 comparetotmag -2 1 -> 1
-ddctm005 comparetotmag -2 2 -> 0
-ddctm006 comparetotmag -1 -2 -> -1
-ddctm007 comparetotmag -1 -1 -> 0
-ddctm008 comparetotmag -1 0 -> 1
-ddctm009 comparetotmag -1 1 -> 0
-ddctm010 comparetotmag -1 2 -> -1
-ddctm011 comparetotmag 0 -2 -> -1
-ddctm012 comparetotmag 0 -1 -> -1
-ddctm013 comparetotmag 0 0 -> 0
-ddctm014 comparetotmag 0 1 -> -1
-ddctm015 comparetotmag 0 2 -> -1
-ddctm016 comparetotmag 1 -2 -> -1
-ddctm017 comparetotmag 1 -1 -> 0
-ddctm018 comparetotmag 1 0 -> 1
-ddctm019 comparetotmag 1 1 -> 0
-ddctm020 comparetotmag 1 2 -> -1
-ddctm021 comparetotmag 2 -2 -> 0
-ddctm022 comparetotmag 2 -1 -> 1
-ddctm023 comparetotmag 2 0 -> 1
-ddctm025 comparetotmag 2 1 -> 1
-ddctm026 comparetotmag 2 2 -> 0
-
-ddctm031 comparetotmag -20 -20 -> 0
-ddctm032 comparetotmag -20 -10 -> 1
-ddctm033 comparetotmag -20 00 -> 1
-ddctm034 comparetotmag -20 10 -> 1
-ddctm035 comparetotmag -20 20 -> 0
-ddctm036 comparetotmag -10 -20 -> -1
-ddctm037 comparetotmag -10 -10 -> 0
-ddctm038 comparetotmag -10 00 -> 1
-ddctm039 comparetotmag -10 10 -> 0
-ddctm040 comparetotmag -10 20 -> -1
-ddctm041 comparetotmag 00 -20 -> -1
-ddctm042 comparetotmag 00 -10 -> -1
-ddctm043 comparetotmag 00 00 -> 0
-ddctm044 comparetotmag 00 10 -> -1
-ddctm045 comparetotmag 00 20 -> -1
-ddctm046 comparetotmag 10 -20 -> -1
-ddctm047 comparetotmag 10 -10 -> 0
-ddctm048 comparetotmag 10 00 -> 1
-ddctm049 comparetotmag 10 10 -> 0
-ddctm050 comparetotmag 10 20 -> -1
-ddctm051 comparetotmag 20 -20 -> 0
-ddctm052 comparetotmag 20 -10 -> 1
-ddctm053 comparetotmag 20 00 -> 1
-ddctm055 comparetotmag 20 10 -> 1
-ddctm056 comparetotmag 20 20 -> 0
-
-ddctm061 comparetotmag -2.0 -2.0 -> 0
-ddctm062 comparetotmag -2.0 -1.0 -> 1
-ddctm063 comparetotmag -2.0 0.0 -> 1
-ddctm064 comparetotmag -2.0 1.0 -> 1
-ddctm065 comparetotmag -2.0 2.0 -> 0
-ddctm066 comparetotmag -1.0 -2.0 -> -1
-ddctm067 comparetotmag -1.0 -1.0 -> 0
-ddctm068 comparetotmag -1.0 0.0 -> 1
-ddctm069 comparetotmag -1.0 1.0 -> 0
-ddctm070 comparetotmag -1.0 2.0 -> -1
-ddctm071 comparetotmag 0.0 -2.0 -> -1
-ddctm072 comparetotmag 0.0 -1.0 -> -1
-ddctm073 comparetotmag 0.0 0.0 -> 0
-ddctm074 comparetotmag 0.0 1.0 -> -1
-ddctm075 comparetotmag 0.0 2.0 -> -1
-ddctm076 comparetotmag 1.0 -2.0 -> -1
-ddctm077 comparetotmag 1.0 -1.0 -> 0
-ddctm078 comparetotmag 1.0 0.0 -> 1
-ddctm079 comparetotmag 1.0 1.0 -> 0
-ddctm080 comparetotmag 1.0 2.0 -> -1
-ddctm081 comparetotmag 2.0 -2.0 -> 0
-ddctm082 comparetotmag 2.0 -1.0 -> 1
-ddctm083 comparetotmag 2.0 0.0 -> 1
-ddctm085 comparetotmag 2.0 1.0 -> 1
-ddctm086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-ddctm090 comparetotmag 9.99999999E+384 9.99999999E+384 -> 0
-ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384 -> 0
-ddctm092 comparetotmag 9.99999999E+384 -9.99999999E+384 -> 0
-ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-ddctm100 comparetotmag 7.0 7.0 -> 0
-ddctm101 comparetotmag 7.0 7 -> -1
-ddctm102 comparetotmag 7 7.0 -> 1
-ddctm103 comparetotmag 7E+0 7.0 -> 1
-ddctm104 comparetotmag 70E-1 7.0 -> 0
-ddctm105 comparetotmag 0.7E+1 7 -> 0
-ddctm106 comparetotmag 70E-1 7 -> -1
-ddctm107 comparetotmag 7.0 7E+0 -> -1
-ddctm108 comparetotmag 7.0 70E-1 -> 0
-ddctm109 comparetotmag 7 0.7E+1 -> 0
-ddctm110 comparetotmag 7 70E-1 -> 1
-
-ddctm120 comparetotmag 8.0 7.0 -> 1
-ddctm121 comparetotmag 8.0 7 -> 1
-ddctm122 comparetotmag 8 7.0 -> 1
-ddctm123 comparetotmag 8E+0 7.0 -> 1
-ddctm124 comparetotmag 80E-1 7.0 -> 1
-ddctm125 comparetotmag 0.8E+1 7 -> 1
-ddctm126 comparetotmag 80E-1 7 -> 1
-ddctm127 comparetotmag 8.0 7E+0 -> 1
-ddctm128 comparetotmag 8.0 70E-1 -> 1
-ddctm129 comparetotmag 8 0.7E+1 -> 1
-ddctm130 comparetotmag 8 70E-1 -> 1
-
-ddctm140 comparetotmag 8.0 9.0 -> -1
-ddctm141 comparetotmag 8.0 9 -> -1
-ddctm142 comparetotmag 8 9.0 -> -1
-ddctm143 comparetotmag 8E+0 9.0 -> -1
-ddctm144 comparetotmag 80E-1 9.0 -> -1
-ddctm145 comparetotmag 0.8E+1 9 -> -1
-ddctm146 comparetotmag 80E-1 9 -> -1
-ddctm147 comparetotmag 8.0 9E+0 -> -1
-ddctm148 comparetotmag 8.0 90E-1 -> -1
-ddctm149 comparetotmag 8 0.9E+1 -> -1
-ddctm150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-ddctm200 comparetotmag -7.0 7.0 -> 0
-ddctm201 comparetotmag -7.0 7 -> -1
-ddctm202 comparetotmag -7 7.0 -> 1
-ddctm203 comparetotmag -7E+0 7.0 -> 1
-ddctm204 comparetotmag -70E-1 7.0 -> 0
-ddctm205 comparetotmag -0.7E+1 7 -> 0
-ddctm206 comparetotmag -70E-1 7 -> -1
-ddctm207 comparetotmag -7.0 7E+0 -> -1
-ddctm208 comparetotmag -7.0 70E-1 -> 0
-ddctm209 comparetotmag -7 0.7E+1 -> 0
-ddctm210 comparetotmag -7 70E-1 -> 1
-
-ddctm220 comparetotmag -8.0 7.0 -> 1
-ddctm221 comparetotmag -8.0 7 -> 1
-ddctm222 comparetotmag -8 7.0 -> 1
-ddctm223 comparetotmag -8E+0 7.0 -> 1
-ddctm224 comparetotmag -80E-1 7.0 -> 1
-ddctm225 comparetotmag -0.8E+1 7 -> 1
-ddctm226 comparetotmag -80E-1 7 -> 1
-ddctm227 comparetotmag -8.0 7E+0 -> 1
-ddctm228 comparetotmag -8.0 70E-1 -> 1
-ddctm229 comparetotmag -8 0.7E+1 -> 1
-ddctm230 comparetotmag -8 70E-1 -> 1
-
-ddctm240 comparetotmag -8.0 9.0 -> -1
-ddctm241 comparetotmag -8.0 9 -> -1
-ddctm242 comparetotmag -8 9.0 -> -1
-ddctm243 comparetotmag -8E+0 9.0 -> -1
-ddctm244 comparetotmag -80E-1 9.0 -> -1
-ddctm245 comparetotmag -0.8E+1 9 -> -1
-ddctm246 comparetotmag -80E-1 9 -> -1
-ddctm247 comparetotmag -8.0 9E+0 -> -1
-ddctm248 comparetotmag -8.0 90E-1 -> -1
-ddctm249 comparetotmag -8 0.9E+1 -> -1
-ddctm250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-ddctm300 comparetotmag 7.0 -7.0 -> 0
-ddctm301 comparetotmag 7.0 -7 -> -1
-ddctm302 comparetotmag 7 -7.0 -> 1
-ddctm303 comparetotmag 7E+0 -7.0 -> 1
-ddctm304 comparetotmag 70E-1 -7.0 -> 0
-ddctm305 comparetotmag .7E+1 -7 -> 0
-ddctm306 comparetotmag 70E-1 -7 -> -1
-ddctm307 comparetotmag 7.0 -7E+0 -> -1
-ddctm308 comparetotmag 7.0 -70E-1 -> 0
-ddctm309 comparetotmag 7 -.7E+1 -> 0
-ddctm310 comparetotmag 7 -70E-1 -> 1
-
-ddctm320 comparetotmag 8.0 -7.0 -> 1
-ddctm321 comparetotmag 8.0 -7 -> 1
-ddctm322 comparetotmag 8 -7.0 -> 1
-ddctm323 comparetotmag 8E+0 -7.0 -> 1
-ddctm324 comparetotmag 80E-1 -7.0 -> 1
-ddctm325 comparetotmag .8E+1 -7 -> 1
-ddctm326 comparetotmag 80E-1 -7 -> 1
-ddctm327 comparetotmag 8.0 -7E+0 -> 1
-ddctm328 comparetotmag 8.0 -70E-1 -> 1
-ddctm329 comparetotmag 8 -.7E+1 -> 1
-ddctm330 comparetotmag 8 -70E-1 -> 1
-
-ddctm340 comparetotmag 8.0 -9.0 -> -1
-ddctm341 comparetotmag 8.0 -9 -> -1
-ddctm342 comparetotmag 8 -9.0 -> -1
-ddctm343 comparetotmag 8E+0 -9.0 -> -1
-ddctm344 comparetotmag 80E-1 -9.0 -> -1
-ddctm345 comparetotmag .8E+1 -9 -> -1
-ddctm346 comparetotmag 80E-1 -9 -> -1
-ddctm347 comparetotmag 8.0 -9E+0 -> -1
-ddctm348 comparetotmag 8.0 -90E-1 -> -1
-ddctm349 comparetotmag 8 -.9E+1 -> -1
-ddctm350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-ddctm400 comparetotmag -7.0 -7.0 -> 0
-ddctm401 comparetotmag -7.0 -7 -> -1
-ddctm402 comparetotmag -7 -7.0 -> 1
-ddctm403 comparetotmag -7E+0 -7.0 -> 1
-ddctm404 comparetotmag -70E-1 -7.0 -> 0
-ddctm405 comparetotmag -.7E+1 -7 -> 0
-ddctm406 comparetotmag -70E-1 -7 -> -1
-ddctm407 comparetotmag -7.0 -7E+0 -> -1
-ddctm408 comparetotmag -7.0 -70E-1 -> 0
-ddctm409 comparetotmag -7 -.7E+1 -> 0
-ddctm410 comparetotmag -7 -70E-1 -> 1
-
-ddctm420 comparetotmag -8.0 -7.0 -> 1
-ddctm421 comparetotmag -8.0 -7 -> 1
-ddctm422 comparetotmag -8 -7.0 -> 1
-ddctm423 comparetotmag -8E+0 -7.0 -> 1
-ddctm424 comparetotmag -80E-1 -7.0 -> 1
-ddctm425 comparetotmag -.8E+1 -7 -> 1
-ddctm426 comparetotmag -80E-1 -7 -> 1
-ddctm427 comparetotmag -8.0 -7E+0 -> 1
-ddctm428 comparetotmag -8.0 -70E-1 -> 1
-ddctm429 comparetotmag -8 -.7E+1 -> 1
-ddctm430 comparetotmag -8 -70E-1 -> 1
-
-ddctm440 comparetotmag -8.0 -9.0 -> -1
-ddctm441 comparetotmag -8.0 -9 -> -1
-ddctm442 comparetotmag -8 -9.0 -> -1
-ddctm443 comparetotmag -8E+0 -9.0 -> -1
-ddctm444 comparetotmag -80E-1 -9.0 -> -1
-ddctm445 comparetotmag -.8E+1 -9 -> -1
-ddctm446 comparetotmag -80E-1 -9 -> -1
-ddctm447 comparetotmag -8.0 -9E+0 -> -1
-ddctm448 comparetotmag -8.0 -90E-1 -> -1
-ddctm449 comparetotmag -8 -.9E+1 -> -1
-ddctm450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-ddctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
-ddctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-ddctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
-ddctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-ddctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
-ddctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-ddctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
-ddctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-ddctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
-ddctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
-ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
-ddctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-ddctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
-ddctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-ddctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
-ddctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-ddctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
-ddctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-ddctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
-ddctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-ddctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-ddctm498 comparetotmag 1 1E-17 -> 1
-ddctm499 comparetotmag 1 1E-16 -> 1
-ddctm500 comparetotmag 1 1E-15 -> 1
-ddctm501 comparetotmag 1 1E-14 -> 1
-ddctm502 comparetotmag 1 1E-13 -> 1
-ddctm503 comparetotmag 1 1E-12 -> 1
-ddctm504 comparetotmag 1 1E-11 -> 1
-ddctm505 comparetotmag 1 1E-10 -> 1
-ddctm506 comparetotmag 1 1E-9 -> 1
-ddctm507 comparetotmag 1 1E-8 -> 1
-ddctm508 comparetotmag 1 1E-7 -> 1
-ddctm509 comparetotmag 1 1E-6 -> 1
-ddctm510 comparetotmag 1 1E-5 -> 1
-ddctm511 comparetotmag 1 1E-4 -> 1
-ddctm512 comparetotmag 1 1E-3 -> 1
-ddctm513 comparetotmag 1 1E-2 -> 1
-ddctm514 comparetotmag 1 1E-1 -> 1
-ddctm515 comparetotmag 1 1E-0 -> 0
-ddctm516 comparetotmag 1 1E+1 -> -1
-ddctm517 comparetotmag 1 1E+2 -> -1
-ddctm518 comparetotmag 1 1E+3 -> -1
-ddctm519 comparetotmag 1 1E+4 -> -1
-ddctm521 comparetotmag 1 1E+5 -> -1
-ddctm522 comparetotmag 1 1E+6 -> -1
-ddctm523 comparetotmag 1 1E+7 -> -1
-ddctm524 comparetotmag 1 1E+8 -> -1
-ddctm525 comparetotmag 1 1E+9 -> -1
-ddctm526 comparetotmag 1 1E+10 -> -1
-ddctm527 comparetotmag 1 1E+11 -> -1
-ddctm528 comparetotmag 1 1E+12 -> -1
-ddctm529 comparetotmag 1 1E+13 -> -1
-ddctm530 comparetotmag 1 1E+14 -> -1
-ddctm531 comparetotmag 1 1E+15 -> -1
-ddctm532 comparetotmag 1 1E+16 -> -1
-ddctm533 comparetotmag 1 1E+17 -> -1
--- LR swap
-ddctm538 comparetotmag 1E-17 1 -> -1
-ddctm539 comparetotmag 1E-16 1 -> -1
-ddctm540 comparetotmag 1E-15 1 -> -1
-ddctm541 comparetotmag 1E-14 1 -> -1
-ddctm542 comparetotmag 1E-13 1 -> -1
-ddctm543 comparetotmag 1E-12 1 -> -1
-ddctm544 comparetotmag 1E-11 1 -> -1
-ddctm545 comparetotmag 1E-10 1 -> -1
-ddctm546 comparetotmag 1E-9 1 -> -1
-ddctm547 comparetotmag 1E-8 1 -> -1
-ddctm548 comparetotmag 1E-7 1 -> -1
-ddctm549 comparetotmag 1E-6 1 -> -1
-ddctm550 comparetotmag 1E-5 1 -> -1
-ddctm551 comparetotmag 1E-4 1 -> -1
-ddctm552 comparetotmag 1E-3 1 -> -1
-ddctm553 comparetotmag 1E-2 1 -> -1
-ddctm554 comparetotmag 1E-1 1 -> -1
-ddctm555 comparetotmag 1E-0 1 -> 0
-ddctm556 comparetotmag 1E+1 1 -> 1
-ddctm557 comparetotmag 1E+2 1 -> 1
-ddctm558 comparetotmag 1E+3 1 -> 1
-ddctm559 comparetotmag 1E+4 1 -> 1
-ddctm561 comparetotmag 1E+5 1 -> 1
-ddctm562 comparetotmag 1E+6 1 -> 1
-ddctm563 comparetotmag 1E+7 1 -> 1
-ddctm564 comparetotmag 1E+8 1 -> 1
-ddctm565 comparetotmag 1E+9 1 -> 1
-ddctm566 comparetotmag 1E+10 1 -> 1
-ddctm567 comparetotmag 1E+11 1 -> 1
-ddctm568 comparetotmag 1E+12 1 -> 1
-ddctm569 comparetotmag 1E+13 1 -> 1
-ddctm570 comparetotmag 1E+14 1 -> 1
-ddctm571 comparetotmag 1E+15 1 -> 1
-ddctm572 comparetotmag 1E+16 1 -> 1
-ddctm573 comparetotmag 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-ddctm578 comparetotmag 0.000000987654321 1E-17 -> 1
-ddctm579 comparetotmag 0.000000987654321 1E-16 -> 1
-ddctm580 comparetotmag 0.000000987654321 1E-15 -> 1
-ddctm581 comparetotmag 0.000000987654321 1E-14 -> 1
-ddctm582 comparetotmag 0.000000987654321 1E-13 -> 1
-ddctm583 comparetotmag 0.000000987654321 1E-12 -> 1
-ddctm584 comparetotmag 0.000000987654321 1E-11 -> 1
-ddctm585 comparetotmag 0.000000987654321 1E-10 -> 1
-ddctm586 comparetotmag 0.000000987654321 1E-9 -> 1
-ddctm587 comparetotmag 0.000000987654321 1E-8 -> 1
-ddctm588 comparetotmag 0.000000987654321 1E-7 -> 1
-ddctm589 comparetotmag 0.000000987654321 1E-6 -> -1
-ddctm590 comparetotmag 0.000000987654321 1E-5 -> -1
-ddctm591 comparetotmag 0.000000987654321 1E-4 -> -1
-ddctm592 comparetotmag 0.000000987654321 1E-3 -> -1
-ddctm593 comparetotmag 0.000000987654321 1E-2 -> -1
-ddctm594 comparetotmag 0.000000987654321 1E-1 -> -1
-ddctm595 comparetotmag 0.000000987654321 1E-0 -> -1
-ddctm596 comparetotmag 0.000000987654321 1E+1 -> -1
-ddctm597 comparetotmag 0.000000987654321 1E+2 -> -1
-ddctm598 comparetotmag 0.000000987654321 1E+3 -> -1
-ddctm599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-ddctm600 comparetotmag 12 12.2345 -> -1
-ddctm601 comparetotmag 12.0 12.2345 -> -1
-ddctm602 comparetotmag 12.00 12.2345 -> -1
-ddctm603 comparetotmag 12.000 12.2345 -> -1
-ddctm604 comparetotmag 12.0000 12.2345 -> -1
-ddctm605 comparetotmag 12.00000 12.2345 -> -1
-ddctm606 comparetotmag 12.000000 12.2345 -> -1
-ddctm607 comparetotmag 12.0000000 12.2345 -> -1
-ddctm608 comparetotmag 12.00000000 12.2345 -> -1
-ddctm609 comparetotmag 12.000000000 12.2345 -> -1
-ddctm610 comparetotmag 12.1234 12 -> 1
-ddctm611 comparetotmag 12.1234 12.0 -> 1
-ddctm612 comparetotmag 12.1234 12.00 -> 1
-ddctm613 comparetotmag 12.1234 12.000 -> 1
-ddctm614 comparetotmag 12.1234 12.0000 -> 1
-ddctm615 comparetotmag 12.1234 12.00000 -> 1
-ddctm616 comparetotmag 12.1234 12.000000 -> 1
-ddctm617 comparetotmag 12.1234 12.0000000 -> 1
-ddctm618 comparetotmag 12.1234 12.00000000 -> 1
-ddctm619 comparetotmag 12.1234 12.000000000 -> 1
-ddctm620 comparetotmag -12 -12.2345 -> -1
-ddctm621 comparetotmag -12.0 -12.2345 -> -1
-ddctm622 comparetotmag -12.00 -12.2345 -> -1
-ddctm623 comparetotmag -12.000 -12.2345 -> -1
-ddctm624 comparetotmag -12.0000 -12.2345 -> -1
-ddctm625 comparetotmag -12.00000 -12.2345 -> -1
-ddctm626 comparetotmag -12.000000 -12.2345 -> -1
-ddctm627 comparetotmag -12.0000000 -12.2345 -> -1
-ddctm628 comparetotmag -12.00000000 -12.2345 -> -1
-ddctm629 comparetotmag -12.000000000 -12.2345 -> -1
-ddctm630 comparetotmag -12.1234 -12 -> 1
-ddctm631 comparetotmag -12.1234 -12.0 -> 1
-ddctm632 comparetotmag -12.1234 -12.00 -> 1
-ddctm633 comparetotmag -12.1234 -12.000 -> 1
-ddctm634 comparetotmag -12.1234 -12.0000 -> 1
-ddctm635 comparetotmag -12.1234 -12.00000 -> 1
-ddctm636 comparetotmag -12.1234 -12.000000 -> 1
-ddctm637 comparetotmag -12.1234 -12.0000000 -> 1
-ddctm638 comparetotmag -12.1234 -12.00000000 -> 1
-ddctm639 comparetotmag -12.1234 -12.000000000 -> 1
-
--- extended zeros
-ddctm640 comparetotmag 0 0 -> 0
-ddctm641 comparetotmag 0 -0 -> 0
-ddctm642 comparetotmag 0 -0.0 -> 1
-ddctm643 comparetotmag 0 0.0 -> 1
-ddctm644 comparetotmag -0 0 -> 0
-ddctm645 comparetotmag -0 -0 -> 0
-ddctm646 comparetotmag -0 -0.0 -> 1
-ddctm647 comparetotmag -0 0.0 -> 1
-ddctm648 comparetotmag 0.0 0 -> -1
-ddctm649 comparetotmag 0.0 -0 -> -1
-ddctm650 comparetotmag 0.0 -0.0 -> 0
-ddctm651 comparetotmag 0.0 0.0 -> 0
-ddctm652 comparetotmag -0.0 0 -> -1
-ddctm653 comparetotmag -0.0 -0 -> -1
-ddctm654 comparetotmag -0.0 -0.0 -> 0
-ddctm655 comparetotmag -0.0 0.0 -> 0
-
-ddctm656 comparetotmag -0E1 0.0 -> 1
-ddctm657 comparetotmag -0E2 0.0 -> 1
-ddctm658 comparetotmag 0E1 0.0 -> 1
-ddctm659 comparetotmag 0E2 0.0 -> 1
-ddctm660 comparetotmag -0E1 0 -> 1
-ddctm661 comparetotmag -0E2 0 -> 1
-ddctm662 comparetotmag 0E1 0 -> 1
-ddctm663 comparetotmag 0E2 0 -> 1
-ddctm664 comparetotmag -0E1 -0E1 -> 0
-ddctm665 comparetotmag -0E2 -0E1 -> 1
-ddctm666 comparetotmag 0E1 -0E1 -> 0
-ddctm667 comparetotmag 0E2 -0E1 -> 1
-ddctm668 comparetotmag -0E1 -0E2 -> -1
-ddctm669 comparetotmag -0E2 -0E2 -> 0
-ddctm670 comparetotmag 0E1 -0E2 -> -1
-ddctm671 comparetotmag 0E2 -0E2 -> 0
-ddctm672 comparetotmag -0E1 0E1 -> 0
-ddctm673 comparetotmag -0E2 0E1 -> 1
-ddctm674 comparetotmag 0E1 0E1 -> 0
-ddctm675 comparetotmag 0E2 0E1 -> 1
-ddctm676 comparetotmag -0E1 0E2 -> -1
-ddctm677 comparetotmag -0E2 0E2 -> 0
-ddctm678 comparetotmag 0E1 0E2 -> -1
-ddctm679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-ddctm680 comparetotmag 12 12 -> 0
-ddctm681 comparetotmag 12 12.0 -> 1
-ddctm682 comparetotmag 12 12.00 -> 1
-ddctm683 comparetotmag 12 12.000 -> 1
-ddctm684 comparetotmag 12 12.0000 -> 1
-ddctm685 comparetotmag 12 12.00000 -> 1
-ddctm686 comparetotmag 12 12.000000 -> 1
-ddctm687 comparetotmag 12 12.0000000 -> 1
-ddctm688 comparetotmag 12 12.00000000 -> 1
-ddctm689 comparetotmag 12 12.000000000 -> 1
-ddctm690 comparetotmag 12 12 -> 0
-ddctm691 comparetotmag 12.0 12 -> -1
-ddctm692 comparetotmag 12.00 12 -> -1
-ddctm693 comparetotmag 12.000 12 -> -1
-ddctm694 comparetotmag 12.0000 12 -> -1
-ddctm695 comparetotmag 12.00000 12 -> -1
-ddctm696 comparetotmag 12.000000 12 -> -1
-ddctm697 comparetotmag 12.0000000 12 -> -1
-ddctm698 comparetotmag 12.00000000 12 -> -1
-ddctm699 comparetotmag 12.000000000 12 -> -1
-
--- old long operand checks
-ddctm701 comparetotmag 12345678000 1 -> 1
-ddctm702 comparetotmag 1 12345678000 -> -1
-ddctm703 comparetotmag 1234567800 1 -> 1
-ddctm704 comparetotmag 1 1234567800 -> -1
-ddctm705 comparetotmag 1234567890 1 -> 1
-ddctm706 comparetotmag 1 1234567890 -> -1
-ddctm707 comparetotmag 1234567891 1 -> 1
-ddctm708 comparetotmag 1 1234567891 -> -1
-ddctm709 comparetotmag 12345678901 1 -> 1
-ddctm710 comparetotmag 1 12345678901 -> -1
-ddctm711 comparetotmag 1234567896 1 -> 1
-ddctm712 comparetotmag 1 1234567896 -> -1
-ddctm713 comparetotmag -1234567891 1 -> 1
-ddctm714 comparetotmag 1 -1234567891 -> -1
-ddctm715 comparetotmag -12345678901 1 -> 1
-ddctm716 comparetotmag 1 -12345678901 -> -1
-ddctm717 comparetotmag -1234567896 1 -> 1
-ddctm718 comparetotmag 1 -1234567896 -> -1
-
--- old residue cases
-ddctm740 comparetotmag 1 0.9999999 -> 1
-ddctm741 comparetotmag 1 0.999999 -> 1
-ddctm742 comparetotmag 1 0.99999 -> 1
-ddctm743 comparetotmag 1 1.0000 -> 1
-ddctm744 comparetotmag 1 1.00001 -> -1
-ddctm745 comparetotmag 1 1.000001 -> -1
-ddctm746 comparetotmag 1 1.0000001 -> -1
-ddctm750 comparetotmag 0.9999999 1 -> -1
-ddctm751 comparetotmag 0.999999 1 -> -1
-ddctm752 comparetotmag 0.99999 1 -> -1
-ddctm753 comparetotmag 1.0000 1 -> -1
-ddctm754 comparetotmag 1.00001 1 -> 1
-ddctm755 comparetotmag 1.000001 1 -> 1
-ddctm756 comparetotmag 1.0000001 1 -> 1
-
--- Specials
-ddctm780 comparetotmag Inf -Inf -> 0
-ddctm781 comparetotmag Inf -1000 -> 1
-ddctm782 comparetotmag Inf -1 -> 1
-ddctm783 comparetotmag Inf -0 -> 1
-ddctm784 comparetotmag Inf 0 -> 1
-ddctm785 comparetotmag Inf 1 -> 1
-ddctm786 comparetotmag Inf 1000 -> 1
-ddctm787 comparetotmag Inf Inf -> 0
-ddctm788 comparetotmag -1000 Inf -> -1
-ddctm789 comparetotmag -Inf Inf -> 0
-ddctm790 comparetotmag -1 Inf -> -1
-ddctm791 comparetotmag -0 Inf -> -1
-ddctm792 comparetotmag 0 Inf -> -1
-ddctm793 comparetotmag 1 Inf -> -1
-ddctm794 comparetotmag 1000 Inf -> -1
-ddctm795 comparetotmag Inf Inf -> 0
-
-ddctm800 comparetotmag -Inf -Inf -> 0
-ddctm801 comparetotmag -Inf -1000 -> 1
-ddctm802 comparetotmag -Inf -1 -> 1
-ddctm803 comparetotmag -Inf -0 -> 1
-ddctm804 comparetotmag -Inf 0 -> 1
-ddctm805 comparetotmag -Inf 1 -> 1
-ddctm806 comparetotmag -Inf 1000 -> 1
-ddctm807 comparetotmag -Inf Inf -> 0
-ddctm808 comparetotmag -Inf -Inf -> 0
-ddctm809 comparetotmag -1000 -Inf -> -1
-ddctm810 comparetotmag -1 -Inf -> -1
-ddctm811 comparetotmag -0 -Inf -> -1
-ddctm812 comparetotmag 0 -Inf -> -1
-ddctm813 comparetotmag 1 -Inf -> -1
-ddctm814 comparetotmag 1000 -Inf -> -1
-ddctm815 comparetotmag Inf -Inf -> 0
-
-ddctm821 comparetotmag NaN -Inf -> 1
-ddctm822 comparetotmag NaN -1000 -> 1
-ddctm823 comparetotmag NaN -1 -> 1
-ddctm824 comparetotmag NaN -0 -> 1
-ddctm825 comparetotmag NaN 0 -> 1
-ddctm826 comparetotmag NaN 1 -> 1
-ddctm827 comparetotmag NaN 1000 -> 1
-ddctm828 comparetotmag NaN Inf -> 1
-ddctm829 comparetotmag NaN NaN -> 0
-ddctm830 comparetotmag -Inf NaN -> -1
-ddctm831 comparetotmag -1000 NaN -> -1
-ddctm832 comparetotmag -1 NaN -> -1
-ddctm833 comparetotmag -0 NaN -> -1
-ddctm834 comparetotmag 0 NaN -> -1
-ddctm835 comparetotmag 1 NaN -> -1
-ddctm836 comparetotmag 1000 NaN -> -1
-ddctm837 comparetotmag Inf NaN -> -1
-ddctm838 comparetotmag -NaN -NaN -> 0
-ddctm839 comparetotmag +NaN -NaN -> 0
-ddctm840 comparetotmag -NaN +NaN -> 0
-
-ddctm841 comparetotmag sNaN -sNaN -> 0
-ddctm842 comparetotmag sNaN -NaN -> -1
-ddctm843 comparetotmag sNaN -Inf -> 1
-ddctm844 comparetotmag sNaN -1000 -> 1
-ddctm845 comparetotmag sNaN -1 -> 1
-ddctm846 comparetotmag sNaN -0 -> 1
-ddctm847 comparetotmag sNaN 0 -> 1
-ddctm848 comparetotmag sNaN 1 -> 1
-ddctm849 comparetotmag sNaN 1000 -> 1
-ddctm850 comparetotmag sNaN NaN -> -1
-ddctm851 comparetotmag sNaN sNaN -> 0
-
-ddctm852 comparetotmag -sNaN sNaN -> 0
-ddctm853 comparetotmag -NaN sNaN -> 1
-ddctm854 comparetotmag -Inf sNaN -> -1
-ddctm855 comparetotmag -1000 sNaN -> -1
-ddctm856 comparetotmag -1 sNaN -> -1
-ddctm857 comparetotmag -0 sNaN -> -1
-ddctm858 comparetotmag 0 sNaN -> -1
-ddctm859 comparetotmag 1 sNaN -> -1
-ddctm860 comparetotmag 1000 sNaN -> -1
-ddctm861 comparetotmag Inf sNaN -> -1
-ddctm862 comparetotmag NaN sNaN -> 1
-ddctm863 comparetotmag sNaN sNaN -> 0
-
-ddctm871 comparetotmag -sNaN -sNaN -> 0
-ddctm872 comparetotmag -sNaN -NaN -> -1
-ddctm873 comparetotmag -sNaN -Inf -> 1
-ddctm874 comparetotmag -sNaN -1000 -> 1
-ddctm875 comparetotmag -sNaN -1 -> 1
-ddctm876 comparetotmag -sNaN -0 -> 1
-ddctm877 comparetotmag -sNaN 0 -> 1
-ddctm878 comparetotmag -sNaN 1 -> 1
-ddctm879 comparetotmag -sNaN 1000 -> 1
-ddctm880 comparetotmag -sNaN NaN -> -1
-ddctm881 comparetotmag -sNaN sNaN -> 0
-
-ddctm882 comparetotmag -sNaN -sNaN -> 0
-ddctm883 comparetotmag -NaN -sNaN -> 1
-ddctm884 comparetotmag -Inf -sNaN -> -1
-ddctm885 comparetotmag -1000 -sNaN -> -1
-ddctm886 comparetotmag -1 -sNaN -> -1
-ddctm887 comparetotmag -0 -sNaN -> -1
-ddctm888 comparetotmag 0 -sNaN -> -1
-ddctm889 comparetotmag 1 -sNaN -> -1
-ddctm890 comparetotmag 1000 -sNaN -> -1
-ddctm891 comparetotmag Inf -sNaN -> -1
-ddctm892 comparetotmag NaN -sNaN -> 1
-ddctm893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-ddctm960 comparetotmag NaN9 -Inf -> 1
-ddctm961 comparetotmag NaN8 999 -> 1
-ddctm962 comparetotmag NaN77 Inf -> 1
-ddctm963 comparetotmag -NaN67 NaN5 -> 1
-ddctm964 comparetotmag -Inf -NaN4 -> -1
-ddctm965 comparetotmag -999 -NaN33 -> -1
-ddctm966 comparetotmag Inf NaN2 -> -1
-
-ddctm970 comparetotmag -NaN41 -NaN42 -> -1
-ddctm971 comparetotmag +NaN41 -NaN42 -> -1
-ddctm972 comparetotmag -NaN41 +NaN42 -> -1
-ddctm973 comparetotmag +NaN41 +NaN42 -> -1
-ddctm974 comparetotmag -NaN42 -NaN01 -> 1
-ddctm975 comparetotmag +NaN42 -NaN01 -> 1
-ddctm976 comparetotmag -NaN42 +NaN01 -> 1
-ddctm977 comparetotmag +NaN42 +NaN01 -> 1
-
-ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
-ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
-ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
-ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
-ddctm984 comparetotmag -sNaN772 -sNaN771 -> 1
-ddctm985 comparetotmag +sNaN772 -sNaN771 -> 1
-ddctm986 comparetotmag -sNaN772 +sNaN771 -> 1
-ddctm987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-ddctm991 comparetotmag -sNaN99 -Inf -> 1
-ddctm992 comparetotmag sNaN98 -11 -> 1
-ddctm993 comparetotmag sNaN97 NaN -> -1
-ddctm994 comparetotmag sNaN16 sNaN94 -> -1
-ddctm995 comparetotmag NaN85 sNaN83 -> 1
-ddctm996 comparetotmag -Inf sNaN92 -> -1
-ddctm997 comparetotmag 088 sNaN81 -> -1
-ddctm998 comparetotmag Inf sNaN90 -> -1
-ddctm999 comparetotmag NaN -sNaN89 -> 1
-
--- spread zeros
-ddctm1110 comparetotmag 0E-383 0 -> -1
-ddctm1111 comparetotmag 0E-383 -0 -> -1
-ddctm1112 comparetotmag -0E-383 0 -> -1
-ddctm1113 comparetotmag -0E-383 -0 -> -1
-ddctm1114 comparetotmag 0E-383 0E+384 -> -1
-ddctm1115 comparetotmag 0E-383 -0E+384 -> -1
-ddctm1116 comparetotmag -0E-383 0E+384 -> -1
-ddctm1117 comparetotmag -0E-383 -0E+384 -> -1
-ddctm1118 comparetotmag 0 0E+384 -> -1
-ddctm1119 comparetotmag 0 -0E+384 -> -1
-ddctm1120 comparetotmag -0 0E+384 -> -1
-ddctm1121 comparetotmag -0 -0E+384 -> -1
-
-ddctm1130 comparetotmag 0E+384 0 -> 1
-ddctm1131 comparetotmag 0E+384 -0 -> 1
-ddctm1132 comparetotmag -0E+384 0 -> 1
-ddctm1133 comparetotmag -0E+384 -0 -> 1
-ddctm1134 comparetotmag 0E+384 0E-383 -> 1
-ddctm1135 comparetotmag 0E+384 -0E-383 -> 1
-ddctm1136 comparetotmag -0E+384 0E-383 -> 1
-ddctm1137 comparetotmag -0E+384 -0E-383 -> 1
-ddctm1138 comparetotmag 0 0E-383 -> 1
-ddctm1139 comparetotmag 0 -0E-383 -> 1
-ddctm1140 comparetotmag -0 0E-383 -> 1
-ddctm1141 comparetotmag -0 -0E-383 -> 1
-
--- Null tests
-ddctm9990 comparetotmag 10 # -> NaN Invalid_operation
-ddctm9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddCompareTotalMag.decTest -- decDouble comparison; abs. total order--
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddctm001 comparetotmag -2 -2 -> 0
+ddctm002 comparetotmag -2 -1 -> 1
+ddctm003 comparetotmag -2 0 -> 1
+ddctm004 comparetotmag -2 1 -> 1
+ddctm005 comparetotmag -2 2 -> 0
+ddctm006 comparetotmag -1 -2 -> -1
+ddctm007 comparetotmag -1 -1 -> 0
+ddctm008 comparetotmag -1 0 -> 1
+ddctm009 comparetotmag -1 1 -> 0
+ddctm010 comparetotmag -1 2 -> -1
+ddctm011 comparetotmag 0 -2 -> -1
+ddctm012 comparetotmag 0 -1 -> -1
+ddctm013 comparetotmag 0 0 -> 0
+ddctm014 comparetotmag 0 1 -> -1
+ddctm015 comparetotmag 0 2 -> -1
+ddctm016 comparetotmag 1 -2 -> -1
+ddctm017 comparetotmag 1 -1 -> 0
+ddctm018 comparetotmag 1 0 -> 1
+ddctm019 comparetotmag 1 1 -> 0
+ddctm020 comparetotmag 1 2 -> -1
+ddctm021 comparetotmag 2 -2 -> 0
+ddctm022 comparetotmag 2 -1 -> 1
+ddctm023 comparetotmag 2 0 -> 1
+ddctm025 comparetotmag 2 1 -> 1
+ddctm026 comparetotmag 2 2 -> 0
+
+ddctm031 comparetotmag -20 -20 -> 0
+ddctm032 comparetotmag -20 -10 -> 1
+ddctm033 comparetotmag -20 00 -> 1
+ddctm034 comparetotmag -20 10 -> 1
+ddctm035 comparetotmag -20 20 -> 0
+ddctm036 comparetotmag -10 -20 -> -1
+ddctm037 comparetotmag -10 -10 -> 0
+ddctm038 comparetotmag -10 00 -> 1
+ddctm039 comparetotmag -10 10 -> 0
+ddctm040 comparetotmag -10 20 -> -1
+ddctm041 comparetotmag 00 -20 -> -1
+ddctm042 comparetotmag 00 -10 -> -1
+ddctm043 comparetotmag 00 00 -> 0
+ddctm044 comparetotmag 00 10 -> -1
+ddctm045 comparetotmag 00 20 -> -1
+ddctm046 comparetotmag 10 -20 -> -1
+ddctm047 comparetotmag 10 -10 -> 0
+ddctm048 comparetotmag 10 00 -> 1
+ddctm049 comparetotmag 10 10 -> 0
+ddctm050 comparetotmag 10 20 -> -1
+ddctm051 comparetotmag 20 -20 -> 0
+ddctm052 comparetotmag 20 -10 -> 1
+ddctm053 comparetotmag 20 00 -> 1
+ddctm055 comparetotmag 20 10 -> 1
+ddctm056 comparetotmag 20 20 -> 0
+
+ddctm061 comparetotmag -2.0 -2.0 -> 0
+ddctm062 comparetotmag -2.0 -1.0 -> 1
+ddctm063 comparetotmag -2.0 0.0 -> 1
+ddctm064 comparetotmag -2.0 1.0 -> 1
+ddctm065 comparetotmag -2.0 2.0 -> 0
+ddctm066 comparetotmag -1.0 -2.0 -> -1
+ddctm067 comparetotmag -1.0 -1.0 -> 0
+ddctm068 comparetotmag -1.0 0.0 -> 1
+ddctm069 comparetotmag -1.0 1.0 -> 0
+ddctm070 comparetotmag -1.0 2.0 -> -1
+ddctm071 comparetotmag 0.0 -2.0 -> -1
+ddctm072 comparetotmag 0.0 -1.0 -> -1
+ddctm073 comparetotmag 0.0 0.0 -> 0
+ddctm074 comparetotmag 0.0 1.0 -> -1
+ddctm075 comparetotmag 0.0 2.0 -> -1
+ddctm076 comparetotmag 1.0 -2.0 -> -1
+ddctm077 comparetotmag 1.0 -1.0 -> 0
+ddctm078 comparetotmag 1.0 0.0 -> 1
+ddctm079 comparetotmag 1.0 1.0 -> 0
+ddctm080 comparetotmag 1.0 2.0 -> -1
+ddctm081 comparetotmag 2.0 -2.0 -> 0
+ddctm082 comparetotmag 2.0 -1.0 -> 1
+ddctm083 comparetotmag 2.0 0.0 -> 1
+ddctm085 comparetotmag 2.0 1.0 -> 1
+ddctm086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+ddctm090 comparetotmag 9.99999999E+384 9.99999999E+384 -> 0
+ddctm091 comparetotmag -9.99999999E+384 9.99999999E+384 -> 0
+ddctm092 comparetotmag 9.99999999E+384 -9.99999999E+384 -> 0
+ddctm093 comparetotmag -9.99999999E+384 -9.99999999E+384 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+ddctm100 comparetotmag 7.0 7.0 -> 0
+ddctm101 comparetotmag 7.0 7 -> -1
+ddctm102 comparetotmag 7 7.0 -> 1
+ddctm103 comparetotmag 7E+0 7.0 -> 1
+ddctm104 comparetotmag 70E-1 7.0 -> 0
+ddctm105 comparetotmag 0.7E+1 7 -> 0
+ddctm106 comparetotmag 70E-1 7 -> -1
+ddctm107 comparetotmag 7.0 7E+0 -> -1
+ddctm108 comparetotmag 7.0 70E-1 -> 0
+ddctm109 comparetotmag 7 0.7E+1 -> 0
+ddctm110 comparetotmag 7 70E-1 -> 1
+
+ddctm120 comparetotmag 8.0 7.0 -> 1
+ddctm121 comparetotmag 8.0 7 -> 1
+ddctm122 comparetotmag 8 7.0 -> 1
+ddctm123 comparetotmag 8E+0 7.0 -> 1
+ddctm124 comparetotmag 80E-1 7.0 -> 1
+ddctm125 comparetotmag 0.8E+1 7 -> 1
+ddctm126 comparetotmag 80E-1 7 -> 1
+ddctm127 comparetotmag 8.0 7E+0 -> 1
+ddctm128 comparetotmag 8.0 70E-1 -> 1
+ddctm129 comparetotmag 8 0.7E+1 -> 1
+ddctm130 comparetotmag 8 70E-1 -> 1
+
+ddctm140 comparetotmag 8.0 9.0 -> -1
+ddctm141 comparetotmag 8.0 9 -> -1
+ddctm142 comparetotmag 8 9.0 -> -1
+ddctm143 comparetotmag 8E+0 9.0 -> -1
+ddctm144 comparetotmag 80E-1 9.0 -> -1
+ddctm145 comparetotmag 0.8E+1 9 -> -1
+ddctm146 comparetotmag 80E-1 9 -> -1
+ddctm147 comparetotmag 8.0 9E+0 -> -1
+ddctm148 comparetotmag 8.0 90E-1 -> -1
+ddctm149 comparetotmag 8 0.9E+1 -> -1
+ddctm150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+ddctm200 comparetotmag -7.0 7.0 -> 0
+ddctm201 comparetotmag -7.0 7 -> -1
+ddctm202 comparetotmag -7 7.0 -> 1
+ddctm203 comparetotmag -7E+0 7.0 -> 1
+ddctm204 comparetotmag -70E-1 7.0 -> 0
+ddctm205 comparetotmag -0.7E+1 7 -> 0
+ddctm206 comparetotmag -70E-1 7 -> -1
+ddctm207 comparetotmag -7.0 7E+0 -> -1
+ddctm208 comparetotmag -7.0 70E-1 -> 0
+ddctm209 comparetotmag -7 0.7E+1 -> 0
+ddctm210 comparetotmag -7 70E-1 -> 1
+
+ddctm220 comparetotmag -8.0 7.0 -> 1
+ddctm221 comparetotmag -8.0 7 -> 1
+ddctm222 comparetotmag -8 7.0 -> 1
+ddctm223 comparetotmag -8E+0 7.0 -> 1
+ddctm224 comparetotmag -80E-1 7.0 -> 1
+ddctm225 comparetotmag -0.8E+1 7 -> 1
+ddctm226 comparetotmag -80E-1 7 -> 1
+ddctm227 comparetotmag -8.0 7E+0 -> 1
+ddctm228 comparetotmag -8.0 70E-1 -> 1
+ddctm229 comparetotmag -8 0.7E+1 -> 1
+ddctm230 comparetotmag -8 70E-1 -> 1
+
+ddctm240 comparetotmag -8.0 9.0 -> -1
+ddctm241 comparetotmag -8.0 9 -> -1
+ddctm242 comparetotmag -8 9.0 -> -1
+ddctm243 comparetotmag -8E+0 9.0 -> -1
+ddctm244 comparetotmag -80E-1 9.0 -> -1
+ddctm245 comparetotmag -0.8E+1 9 -> -1
+ddctm246 comparetotmag -80E-1 9 -> -1
+ddctm247 comparetotmag -8.0 9E+0 -> -1
+ddctm248 comparetotmag -8.0 90E-1 -> -1
+ddctm249 comparetotmag -8 0.9E+1 -> -1
+ddctm250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+ddctm300 comparetotmag 7.0 -7.0 -> 0
+ddctm301 comparetotmag 7.0 -7 -> -1
+ddctm302 comparetotmag 7 -7.0 -> 1
+ddctm303 comparetotmag 7E+0 -7.0 -> 1
+ddctm304 comparetotmag 70E-1 -7.0 -> 0
+ddctm305 comparetotmag .7E+1 -7 -> 0
+ddctm306 comparetotmag 70E-1 -7 -> -1
+ddctm307 comparetotmag 7.0 -7E+0 -> -1
+ddctm308 comparetotmag 7.0 -70E-1 -> 0
+ddctm309 comparetotmag 7 -.7E+1 -> 0
+ddctm310 comparetotmag 7 -70E-1 -> 1
+
+ddctm320 comparetotmag 8.0 -7.0 -> 1
+ddctm321 comparetotmag 8.0 -7 -> 1
+ddctm322 comparetotmag 8 -7.0 -> 1
+ddctm323 comparetotmag 8E+0 -7.0 -> 1
+ddctm324 comparetotmag 80E-1 -7.0 -> 1
+ddctm325 comparetotmag .8E+1 -7 -> 1
+ddctm326 comparetotmag 80E-1 -7 -> 1
+ddctm327 comparetotmag 8.0 -7E+0 -> 1
+ddctm328 comparetotmag 8.0 -70E-1 -> 1
+ddctm329 comparetotmag 8 -.7E+1 -> 1
+ddctm330 comparetotmag 8 -70E-1 -> 1
+
+ddctm340 comparetotmag 8.0 -9.0 -> -1
+ddctm341 comparetotmag 8.0 -9 -> -1
+ddctm342 comparetotmag 8 -9.0 -> -1
+ddctm343 comparetotmag 8E+0 -9.0 -> -1
+ddctm344 comparetotmag 80E-1 -9.0 -> -1
+ddctm345 comparetotmag .8E+1 -9 -> -1
+ddctm346 comparetotmag 80E-1 -9 -> -1
+ddctm347 comparetotmag 8.0 -9E+0 -> -1
+ddctm348 comparetotmag 8.0 -90E-1 -> -1
+ddctm349 comparetotmag 8 -.9E+1 -> -1
+ddctm350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+ddctm400 comparetotmag -7.0 -7.0 -> 0
+ddctm401 comparetotmag -7.0 -7 -> -1
+ddctm402 comparetotmag -7 -7.0 -> 1
+ddctm403 comparetotmag -7E+0 -7.0 -> 1
+ddctm404 comparetotmag -70E-1 -7.0 -> 0
+ddctm405 comparetotmag -.7E+1 -7 -> 0
+ddctm406 comparetotmag -70E-1 -7 -> -1
+ddctm407 comparetotmag -7.0 -7E+0 -> -1
+ddctm408 comparetotmag -7.0 -70E-1 -> 0
+ddctm409 comparetotmag -7 -.7E+1 -> 0
+ddctm410 comparetotmag -7 -70E-1 -> 1
+
+ddctm420 comparetotmag -8.0 -7.0 -> 1
+ddctm421 comparetotmag -8.0 -7 -> 1
+ddctm422 comparetotmag -8 -7.0 -> 1
+ddctm423 comparetotmag -8E+0 -7.0 -> 1
+ddctm424 comparetotmag -80E-1 -7.0 -> 1
+ddctm425 comparetotmag -.8E+1 -7 -> 1
+ddctm426 comparetotmag -80E-1 -7 -> 1
+ddctm427 comparetotmag -8.0 -7E+0 -> 1
+ddctm428 comparetotmag -8.0 -70E-1 -> 1
+ddctm429 comparetotmag -8 -.7E+1 -> 1
+ddctm430 comparetotmag -8 -70E-1 -> 1
+
+ddctm440 comparetotmag -8.0 -9.0 -> -1
+ddctm441 comparetotmag -8.0 -9 -> -1
+ddctm442 comparetotmag -8 -9.0 -> -1
+ddctm443 comparetotmag -8E+0 -9.0 -> -1
+ddctm444 comparetotmag -80E-1 -9.0 -> -1
+ddctm445 comparetotmag -.8E+1 -9 -> -1
+ddctm446 comparetotmag -80E-1 -9 -> -1
+ddctm447 comparetotmag -8.0 -9E+0 -> -1
+ddctm448 comparetotmag -8.0 -90E-1 -> -1
+ddctm449 comparetotmag -8 -.9E+1 -> -1
+ddctm450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+ddctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+ddctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
+ddctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+ddctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
+ddctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+ddctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
+ddctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+ddctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
+ddctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+ddctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
+ddctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
+ddctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
+ddctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+ddctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
+ddctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+ddctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
+ddctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+ddctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
+ddctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+ddctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
+ddctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+ddctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+ddctm498 comparetotmag 1 1E-17 -> 1
+ddctm499 comparetotmag 1 1E-16 -> 1
+ddctm500 comparetotmag 1 1E-15 -> 1
+ddctm501 comparetotmag 1 1E-14 -> 1
+ddctm502 comparetotmag 1 1E-13 -> 1
+ddctm503 comparetotmag 1 1E-12 -> 1
+ddctm504 comparetotmag 1 1E-11 -> 1
+ddctm505 comparetotmag 1 1E-10 -> 1
+ddctm506 comparetotmag 1 1E-9 -> 1
+ddctm507 comparetotmag 1 1E-8 -> 1
+ddctm508 comparetotmag 1 1E-7 -> 1
+ddctm509 comparetotmag 1 1E-6 -> 1
+ddctm510 comparetotmag 1 1E-5 -> 1
+ddctm511 comparetotmag 1 1E-4 -> 1
+ddctm512 comparetotmag 1 1E-3 -> 1
+ddctm513 comparetotmag 1 1E-2 -> 1
+ddctm514 comparetotmag 1 1E-1 -> 1
+ddctm515 comparetotmag 1 1E-0 -> 0
+ddctm516 comparetotmag 1 1E+1 -> -1
+ddctm517 comparetotmag 1 1E+2 -> -1
+ddctm518 comparetotmag 1 1E+3 -> -1
+ddctm519 comparetotmag 1 1E+4 -> -1
+ddctm521 comparetotmag 1 1E+5 -> -1
+ddctm522 comparetotmag 1 1E+6 -> -1
+ddctm523 comparetotmag 1 1E+7 -> -1
+ddctm524 comparetotmag 1 1E+8 -> -1
+ddctm525 comparetotmag 1 1E+9 -> -1
+ddctm526 comparetotmag 1 1E+10 -> -1
+ddctm527 comparetotmag 1 1E+11 -> -1
+ddctm528 comparetotmag 1 1E+12 -> -1
+ddctm529 comparetotmag 1 1E+13 -> -1
+ddctm530 comparetotmag 1 1E+14 -> -1
+ddctm531 comparetotmag 1 1E+15 -> -1
+ddctm532 comparetotmag 1 1E+16 -> -1
+ddctm533 comparetotmag 1 1E+17 -> -1
+-- LR swap
+ddctm538 comparetotmag 1E-17 1 -> -1
+ddctm539 comparetotmag 1E-16 1 -> -1
+ddctm540 comparetotmag 1E-15 1 -> -1
+ddctm541 comparetotmag 1E-14 1 -> -1
+ddctm542 comparetotmag 1E-13 1 -> -1
+ddctm543 comparetotmag 1E-12 1 -> -1
+ddctm544 comparetotmag 1E-11 1 -> -1
+ddctm545 comparetotmag 1E-10 1 -> -1
+ddctm546 comparetotmag 1E-9 1 -> -1
+ddctm547 comparetotmag 1E-8 1 -> -1
+ddctm548 comparetotmag 1E-7 1 -> -1
+ddctm549 comparetotmag 1E-6 1 -> -1
+ddctm550 comparetotmag 1E-5 1 -> -1
+ddctm551 comparetotmag 1E-4 1 -> -1
+ddctm552 comparetotmag 1E-3 1 -> -1
+ddctm553 comparetotmag 1E-2 1 -> -1
+ddctm554 comparetotmag 1E-1 1 -> -1
+ddctm555 comparetotmag 1E-0 1 -> 0
+ddctm556 comparetotmag 1E+1 1 -> 1
+ddctm557 comparetotmag 1E+2 1 -> 1
+ddctm558 comparetotmag 1E+3 1 -> 1
+ddctm559 comparetotmag 1E+4 1 -> 1
+ddctm561 comparetotmag 1E+5 1 -> 1
+ddctm562 comparetotmag 1E+6 1 -> 1
+ddctm563 comparetotmag 1E+7 1 -> 1
+ddctm564 comparetotmag 1E+8 1 -> 1
+ddctm565 comparetotmag 1E+9 1 -> 1
+ddctm566 comparetotmag 1E+10 1 -> 1
+ddctm567 comparetotmag 1E+11 1 -> 1
+ddctm568 comparetotmag 1E+12 1 -> 1
+ddctm569 comparetotmag 1E+13 1 -> 1
+ddctm570 comparetotmag 1E+14 1 -> 1
+ddctm571 comparetotmag 1E+15 1 -> 1
+ddctm572 comparetotmag 1E+16 1 -> 1
+ddctm573 comparetotmag 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+ddctm578 comparetotmag 0.000000987654321 1E-17 -> 1
+ddctm579 comparetotmag 0.000000987654321 1E-16 -> 1
+ddctm580 comparetotmag 0.000000987654321 1E-15 -> 1
+ddctm581 comparetotmag 0.000000987654321 1E-14 -> 1
+ddctm582 comparetotmag 0.000000987654321 1E-13 -> 1
+ddctm583 comparetotmag 0.000000987654321 1E-12 -> 1
+ddctm584 comparetotmag 0.000000987654321 1E-11 -> 1
+ddctm585 comparetotmag 0.000000987654321 1E-10 -> 1
+ddctm586 comparetotmag 0.000000987654321 1E-9 -> 1
+ddctm587 comparetotmag 0.000000987654321 1E-8 -> 1
+ddctm588 comparetotmag 0.000000987654321 1E-7 -> 1
+ddctm589 comparetotmag 0.000000987654321 1E-6 -> -1
+ddctm590 comparetotmag 0.000000987654321 1E-5 -> -1
+ddctm591 comparetotmag 0.000000987654321 1E-4 -> -1
+ddctm592 comparetotmag 0.000000987654321 1E-3 -> -1
+ddctm593 comparetotmag 0.000000987654321 1E-2 -> -1
+ddctm594 comparetotmag 0.000000987654321 1E-1 -> -1
+ddctm595 comparetotmag 0.000000987654321 1E-0 -> -1
+ddctm596 comparetotmag 0.000000987654321 1E+1 -> -1
+ddctm597 comparetotmag 0.000000987654321 1E+2 -> -1
+ddctm598 comparetotmag 0.000000987654321 1E+3 -> -1
+ddctm599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+ddctm600 comparetotmag 12 12.2345 -> -1
+ddctm601 comparetotmag 12.0 12.2345 -> -1
+ddctm602 comparetotmag 12.00 12.2345 -> -1
+ddctm603 comparetotmag 12.000 12.2345 -> -1
+ddctm604 comparetotmag 12.0000 12.2345 -> -1
+ddctm605 comparetotmag 12.00000 12.2345 -> -1
+ddctm606 comparetotmag 12.000000 12.2345 -> -1
+ddctm607 comparetotmag 12.0000000 12.2345 -> -1
+ddctm608 comparetotmag 12.00000000 12.2345 -> -1
+ddctm609 comparetotmag 12.000000000 12.2345 -> -1
+ddctm610 comparetotmag 12.1234 12 -> 1
+ddctm611 comparetotmag 12.1234 12.0 -> 1
+ddctm612 comparetotmag 12.1234 12.00 -> 1
+ddctm613 comparetotmag 12.1234 12.000 -> 1
+ddctm614 comparetotmag 12.1234 12.0000 -> 1
+ddctm615 comparetotmag 12.1234 12.00000 -> 1
+ddctm616 comparetotmag 12.1234 12.000000 -> 1
+ddctm617 comparetotmag 12.1234 12.0000000 -> 1
+ddctm618 comparetotmag 12.1234 12.00000000 -> 1
+ddctm619 comparetotmag 12.1234 12.000000000 -> 1
+ddctm620 comparetotmag -12 -12.2345 -> -1
+ddctm621 comparetotmag -12.0 -12.2345 -> -1
+ddctm622 comparetotmag -12.00 -12.2345 -> -1
+ddctm623 comparetotmag -12.000 -12.2345 -> -1
+ddctm624 comparetotmag -12.0000 -12.2345 -> -1
+ddctm625 comparetotmag -12.00000 -12.2345 -> -1
+ddctm626 comparetotmag -12.000000 -12.2345 -> -1
+ddctm627 comparetotmag -12.0000000 -12.2345 -> -1
+ddctm628 comparetotmag -12.00000000 -12.2345 -> -1
+ddctm629 comparetotmag -12.000000000 -12.2345 -> -1
+ddctm630 comparetotmag -12.1234 -12 -> 1
+ddctm631 comparetotmag -12.1234 -12.0 -> 1
+ddctm632 comparetotmag -12.1234 -12.00 -> 1
+ddctm633 comparetotmag -12.1234 -12.000 -> 1
+ddctm634 comparetotmag -12.1234 -12.0000 -> 1
+ddctm635 comparetotmag -12.1234 -12.00000 -> 1
+ddctm636 comparetotmag -12.1234 -12.000000 -> 1
+ddctm637 comparetotmag -12.1234 -12.0000000 -> 1
+ddctm638 comparetotmag -12.1234 -12.00000000 -> 1
+ddctm639 comparetotmag -12.1234 -12.000000000 -> 1
+
+-- extended zeros
+ddctm640 comparetotmag 0 0 -> 0
+ddctm641 comparetotmag 0 -0 -> 0
+ddctm642 comparetotmag 0 -0.0 -> 1
+ddctm643 comparetotmag 0 0.0 -> 1
+ddctm644 comparetotmag -0 0 -> 0
+ddctm645 comparetotmag -0 -0 -> 0
+ddctm646 comparetotmag -0 -0.0 -> 1
+ddctm647 comparetotmag -0 0.0 -> 1
+ddctm648 comparetotmag 0.0 0 -> -1
+ddctm649 comparetotmag 0.0 -0 -> -1
+ddctm650 comparetotmag 0.0 -0.0 -> 0
+ddctm651 comparetotmag 0.0 0.0 -> 0
+ddctm652 comparetotmag -0.0 0 -> -1
+ddctm653 comparetotmag -0.0 -0 -> -1
+ddctm654 comparetotmag -0.0 -0.0 -> 0
+ddctm655 comparetotmag -0.0 0.0 -> 0
+
+ddctm656 comparetotmag -0E1 0.0 -> 1
+ddctm657 comparetotmag -0E2 0.0 -> 1
+ddctm658 comparetotmag 0E1 0.0 -> 1
+ddctm659 comparetotmag 0E2 0.0 -> 1
+ddctm660 comparetotmag -0E1 0 -> 1
+ddctm661 comparetotmag -0E2 0 -> 1
+ddctm662 comparetotmag 0E1 0 -> 1
+ddctm663 comparetotmag 0E2 0 -> 1
+ddctm664 comparetotmag -0E1 -0E1 -> 0
+ddctm665 comparetotmag -0E2 -0E1 -> 1
+ddctm666 comparetotmag 0E1 -0E1 -> 0
+ddctm667 comparetotmag 0E2 -0E1 -> 1
+ddctm668 comparetotmag -0E1 -0E2 -> -1
+ddctm669 comparetotmag -0E2 -0E2 -> 0
+ddctm670 comparetotmag 0E1 -0E2 -> -1
+ddctm671 comparetotmag 0E2 -0E2 -> 0
+ddctm672 comparetotmag -0E1 0E1 -> 0
+ddctm673 comparetotmag -0E2 0E1 -> 1
+ddctm674 comparetotmag 0E1 0E1 -> 0
+ddctm675 comparetotmag 0E2 0E1 -> 1
+ddctm676 comparetotmag -0E1 0E2 -> -1
+ddctm677 comparetotmag -0E2 0E2 -> 0
+ddctm678 comparetotmag 0E1 0E2 -> -1
+ddctm679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+ddctm680 comparetotmag 12 12 -> 0
+ddctm681 comparetotmag 12 12.0 -> 1
+ddctm682 comparetotmag 12 12.00 -> 1
+ddctm683 comparetotmag 12 12.000 -> 1
+ddctm684 comparetotmag 12 12.0000 -> 1
+ddctm685 comparetotmag 12 12.00000 -> 1
+ddctm686 comparetotmag 12 12.000000 -> 1
+ddctm687 comparetotmag 12 12.0000000 -> 1
+ddctm688 comparetotmag 12 12.00000000 -> 1
+ddctm689 comparetotmag 12 12.000000000 -> 1
+ddctm690 comparetotmag 12 12 -> 0
+ddctm691 comparetotmag 12.0 12 -> -1
+ddctm692 comparetotmag 12.00 12 -> -1
+ddctm693 comparetotmag 12.000 12 -> -1
+ddctm694 comparetotmag 12.0000 12 -> -1
+ddctm695 comparetotmag 12.00000 12 -> -1
+ddctm696 comparetotmag 12.000000 12 -> -1
+ddctm697 comparetotmag 12.0000000 12 -> -1
+ddctm698 comparetotmag 12.00000000 12 -> -1
+ddctm699 comparetotmag 12.000000000 12 -> -1
+
+-- old long operand checks
+ddctm701 comparetotmag 12345678000 1 -> 1
+ddctm702 comparetotmag 1 12345678000 -> -1
+ddctm703 comparetotmag 1234567800 1 -> 1
+ddctm704 comparetotmag 1 1234567800 -> -1
+ddctm705 comparetotmag 1234567890 1 -> 1
+ddctm706 comparetotmag 1 1234567890 -> -1
+ddctm707 comparetotmag 1234567891 1 -> 1
+ddctm708 comparetotmag 1 1234567891 -> -1
+ddctm709 comparetotmag 12345678901 1 -> 1
+ddctm710 comparetotmag 1 12345678901 -> -1
+ddctm711 comparetotmag 1234567896 1 -> 1
+ddctm712 comparetotmag 1 1234567896 -> -1
+ddctm713 comparetotmag -1234567891 1 -> 1
+ddctm714 comparetotmag 1 -1234567891 -> -1
+ddctm715 comparetotmag -12345678901 1 -> 1
+ddctm716 comparetotmag 1 -12345678901 -> -1
+ddctm717 comparetotmag -1234567896 1 -> 1
+ddctm718 comparetotmag 1 -1234567896 -> -1
+
+-- old residue cases
+ddctm740 comparetotmag 1 0.9999999 -> 1
+ddctm741 comparetotmag 1 0.999999 -> 1
+ddctm742 comparetotmag 1 0.99999 -> 1
+ddctm743 comparetotmag 1 1.0000 -> 1
+ddctm744 comparetotmag 1 1.00001 -> -1
+ddctm745 comparetotmag 1 1.000001 -> -1
+ddctm746 comparetotmag 1 1.0000001 -> -1
+ddctm750 comparetotmag 0.9999999 1 -> -1
+ddctm751 comparetotmag 0.999999 1 -> -1
+ddctm752 comparetotmag 0.99999 1 -> -1
+ddctm753 comparetotmag 1.0000 1 -> -1
+ddctm754 comparetotmag 1.00001 1 -> 1
+ddctm755 comparetotmag 1.000001 1 -> 1
+ddctm756 comparetotmag 1.0000001 1 -> 1
+
+-- Specials
+ddctm780 comparetotmag Inf -Inf -> 0
+ddctm781 comparetotmag Inf -1000 -> 1
+ddctm782 comparetotmag Inf -1 -> 1
+ddctm783 comparetotmag Inf -0 -> 1
+ddctm784 comparetotmag Inf 0 -> 1
+ddctm785 comparetotmag Inf 1 -> 1
+ddctm786 comparetotmag Inf 1000 -> 1
+ddctm787 comparetotmag Inf Inf -> 0
+ddctm788 comparetotmag -1000 Inf -> -1
+ddctm789 comparetotmag -Inf Inf -> 0
+ddctm790 comparetotmag -1 Inf -> -1
+ddctm791 comparetotmag -0 Inf -> -1
+ddctm792 comparetotmag 0 Inf -> -1
+ddctm793 comparetotmag 1 Inf -> -1
+ddctm794 comparetotmag 1000 Inf -> -1
+ddctm795 comparetotmag Inf Inf -> 0
+
+ddctm800 comparetotmag -Inf -Inf -> 0
+ddctm801 comparetotmag -Inf -1000 -> 1
+ddctm802 comparetotmag -Inf -1 -> 1
+ddctm803 comparetotmag -Inf -0 -> 1
+ddctm804 comparetotmag -Inf 0 -> 1
+ddctm805 comparetotmag -Inf 1 -> 1
+ddctm806 comparetotmag -Inf 1000 -> 1
+ddctm807 comparetotmag -Inf Inf -> 0
+ddctm808 comparetotmag -Inf -Inf -> 0
+ddctm809 comparetotmag -1000 -Inf -> -1
+ddctm810 comparetotmag -1 -Inf -> -1
+ddctm811 comparetotmag -0 -Inf -> -1
+ddctm812 comparetotmag 0 -Inf -> -1
+ddctm813 comparetotmag 1 -Inf -> -1
+ddctm814 comparetotmag 1000 -Inf -> -1
+ddctm815 comparetotmag Inf -Inf -> 0
+
+ddctm821 comparetotmag NaN -Inf -> 1
+ddctm822 comparetotmag NaN -1000 -> 1
+ddctm823 comparetotmag NaN -1 -> 1
+ddctm824 comparetotmag NaN -0 -> 1
+ddctm825 comparetotmag NaN 0 -> 1
+ddctm826 comparetotmag NaN 1 -> 1
+ddctm827 comparetotmag NaN 1000 -> 1
+ddctm828 comparetotmag NaN Inf -> 1
+ddctm829 comparetotmag NaN NaN -> 0
+ddctm830 comparetotmag -Inf NaN -> -1
+ddctm831 comparetotmag -1000 NaN -> -1
+ddctm832 comparetotmag -1 NaN -> -1
+ddctm833 comparetotmag -0 NaN -> -1
+ddctm834 comparetotmag 0 NaN -> -1
+ddctm835 comparetotmag 1 NaN -> -1
+ddctm836 comparetotmag 1000 NaN -> -1
+ddctm837 comparetotmag Inf NaN -> -1
+ddctm838 comparetotmag -NaN -NaN -> 0
+ddctm839 comparetotmag +NaN -NaN -> 0
+ddctm840 comparetotmag -NaN +NaN -> 0
+
+ddctm841 comparetotmag sNaN -sNaN -> 0
+ddctm842 comparetotmag sNaN -NaN -> -1
+ddctm843 comparetotmag sNaN -Inf -> 1
+ddctm844 comparetotmag sNaN -1000 -> 1
+ddctm845 comparetotmag sNaN -1 -> 1
+ddctm846 comparetotmag sNaN -0 -> 1
+ddctm847 comparetotmag sNaN 0 -> 1
+ddctm848 comparetotmag sNaN 1 -> 1
+ddctm849 comparetotmag sNaN 1000 -> 1
+ddctm850 comparetotmag sNaN NaN -> -1
+ddctm851 comparetotmag sNaN sNaN -> 0
+
+ddctm852 comparetotmag -sNaN sNaN -> 0
+ddctm853 comparetotmag -NaN sNaN -> 1
+ddctm854 comparetotmag -Inf sNaN -> -1
+ddctm855 comparetotmag -1000 sNaN -> -1
+ddctm856 comparetotmag -1 sNaN -> -1
+ddctm857 comparetotmag -0 sNaN -> -1
+ddctm858 comparetotmag 0 sNaN -> -1
+ddctm859 comparetotmag 1 sNaN -> -1
+ddctm860 comparetotmag 1000 sNaN -> -1
+ddctm861 comparetotmag Inf sNaN -> -1
+ddctm862 comparetotmag NaN sNaN -> 1
+ddctm863 comparetotmag sNaN sNaN -> 0
+
+ddctm871 comparetotmag -sNaN -sNaN -> 0
+ddctm872 comparetotmag -sNaN -NaN -> -1
+ddctm873 comparetotmag -sNaN -Inf -> 1
+ddctm874 comparetotmag -sNaN -1000 -> 1
+ddctm875 comparetotmag -sNaN -1 -> 1
+ddctm876 comparetotmag -sNaN -0 -> 1
+ddctm877 comparetotmag -sNaN 0 -> 1
+ddctm878 comparetotmag -sNaN 1 -> 1
+ddctm879 comparetotmag -sNaN 1000 -> 1
+ddctm880 comparetotmag -sNaN NaN -> -1
+ddctm881 comparetotmag -sNaN sNaN -> 0
+
+ddctm882 comparetotmag -sNaN -sNaN -> 0
+ddctm883 comparetotmag -NaN -sNaN -> 1
+ddctm884 comparetotmag -Inf -sNaN -> -1
+ddctm885 comparetotmag -1000 -sNaN -> -1
+ddctm886 comparetotmag -1 -sNaN -> -1
+ddctm887 comparetotmag -0 -sNaN -> -1
+ddctm888 comparetotmag 0 -sNaN -> -1
+ddctm889 comparetotmag 1 -sNaN -> -1
+ddctm890 comparetotmag 1000 -sNaN -> -1
+ddctm891 comparetotmag Inf -sNaN -> -1
+ddctm892 comparetotmag NaN -sNaN -> 1
+ddctm893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+ddctm960 comparetotmag NaN9 -Inf -> 1
+ddctm961 comparetotmag NaN8 999 -> 1
+ddctm962 comparetotmag NaN77 Inf -> 1
+ddctm963 comparetotmag -NaN67 NaN5 -> 1
+ddctm964 comparetotmag -Inf -NaN4 -> -1
+ddctm965 comparetotmag -999 -NaN33 -> -1
+ddctm966 comparetotmag Inf NaN2 -> -1
+
+ddctm970 comparetotmag -NaN41 -NaN42 -> -1
+ddctm971 comparetotmag +NaN41 -NaN42 -> -1
+ddctm972 comparetotmag -NaN41 +NaN42 -> -1
+ddctm973 comparetotmag +NaN41 +NaN42 -> -1
+ddctm974 comparetotmag -NaN42 -NaN01 -> 1
+ddctm975 comparetotmag +NaN42 -NaN01 -> 1
+ddctm976 comparetotmag -NaN42 +NaN01 -> 1
+ddctm977 comparetotmag +NaN42 +NaN01 -> 1
+
+ddctm980 comparetotmag -sNaN771 -sNaN772 -> -1
+ddctm981 comparetotmag +sNaN771 -sNaN772 -> -1
+ddctm982 comparetotmag -sNaN771 +sNaN772 -> -1
+ddctm983 comparetotmag +sNaN771 +sNaN772 -> -1
+ddctm984 comparetotmag -sNaN772 -sNaN771 -> 1
+ddctm985 comparetotmag +sNaN772 -sNaN771 -> 1
+ddctm986 comparetotmag -sNaN772 +sNaN771 -> 1
+ddctm987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+ddctm991 comparetotmag -sNaN99 -Inf -> 1
+ddctm992 comparetotmag sNaN98 -11 -> 1
+ddctm993 comparetotmag sNaN97 NaN -> -1
+ddctm994 comparetotmag sNaN16 sNaN94 -> -1
+ddctm995 comparetotmag NaN85 sNaN83 -> 1
+ddctm996 comparetotmag -Inf sNaN92 -> -1
+ddctm997 comparetotmag 088 sNaN81 -> -1
+ddctm998 comparetotmag Inf sNaN90 -> -1
+ddctm999 comparetotmag NaN -sNaN89 -> 1
+
+-- spread zeros
+ddctm1110 comparetotmag 0E-383 0 -> -1
+ddctm1111 comparetotmag 0E-383 -0 -> -1
+ddctm1112 comparetotmag -0E-383 0 -> -1
+ddctm1113 comparetotmag -0E-383 -0 -> -1
+ddctm1114 comparetotmag 0E-383 0E+384 -> -1
+ddctm1115 comparetotmag 0E-383 -0E+384 -> -1
+ddctm1116 comparetotmag -0E-383 0E+384 -> -1
+ddctm1117 comparetotmag -0E-383 -0E+384 -> -1
+ddctm1118 comparetotmag 0 0E+384 -> -1
+ddctm1119 comparetotmag 0 -0E+384 -> -1
+ddctm1120 comparetotmag -0 0E+384 -> -1
+ddctm1121 comparetotmag -0 -0E+384 -> -1
+
+ddctm1130 comparetotmag 0E+384 0 -> 1
+ddctm1131 comparetotmag 0E+384 -0 -> 1
+ddctm1132 comparetotmag -0E+384 0 -> 1
+ddctm1133 comparetotmag -0E+384 -0 -> 1
+ddctm1134 comparetotmag 0E+384 0E-383 -> 1
+ddctm1135 comparetotmag 0E+384 -0E-383 -> 1
+ddctm1136 comparetotmag -0E+384 0E-383 -> 1
+ddctm1137 comparetotmag -0E+384 -0E-383 -> 1
+ddctm1138 comparetotmag 0 0E-383 -> 1
+ddctm1139 comparetotmag 0 -0E-383 -> 1
+ddctm1140 comparetotmag -0 0E-383 -> 1
+ddctm1141 comparetotmag -0 -0E-383 -> 1
+
+-- Null tests
+ddctm9990 comparetotmag 10 # -> NaN Invalid_operation
+ddctm9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddCopy.decTest b/Lib/test/decimaltestdata/ddCopy.decTest
index 9a175c5ea75..f99d86a4267 100644
--- a/Lib/test/decimaltestdata/ddCopy.decTest
+++ b/Lib/test/decimaltestdata/ddCopy.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopy.decTest -- quiet decDouble copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpy001 copy +7.50 -> 7.50
-
--- Infinities
-ddcpy011 copy Infinity -> Infinity
-ddcpy012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddcpy021 copy NaN -> NaN
-ddcpy022 copy -NaN -> -NaN
-ddcpy023 copy sNaN -> sNaN
-ddcpy024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-ddcpy031 copy NaN10 -> NaN10
-ddcpy032 copy -NaN10 -> -NaN10
-ddcpy033 copy sNaN10 -> sNaN10
-ddcpy034 copy -sNaN10 -> -sNaN10
-ddcpy035 copy NaN7 -> NaN7
-ddcpy036 copy -NaN7 -> -NaN7
-ddcpy037 copy sNaN101 -> sNaN101
-ddcpy038 copy -sNaN101 -> -sNaN101
-
--- finites
-ddcpy101 copy 7 -> 7
-ddcpy102 copy -7 -> -7
-ddcpy103 copy 75 -> 75
-ddcpy104 copy -75 -> -75
-ddcpy105 copy 7.50 -> 7.50
-ddcpy106 copy -7.50 -> -7.50
-ddcpy107 copy 7.500 -> 7.500
-ddcpy108 copy -7.500 -> -7.500
-
--- zeros
-ddcpy111 copy 0 -> 0
-ddcpy112 copy -0 -> -0
-ddcpy113 copy 0E+4 -> 0E+4
-ddcpy114 copy -0E+4 -> -0E+4
-ddcpy115 copy 0.0000 -> 0.0000
-ddcpy116 copy -0.0000 -> -0.0000
-ddcpy117 copy 0E-141 -> 0E-141
-ddcpy118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-ddcpy121 copy 2682682682682682 -> 2682682682682682
-ddcpy122 copy -2682682682682682 -> -2682682682682682
-ddcpy123 copy 1341341341341341 -> 1341341341341341
-ddcpy124 copy -1341341341341341 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpy131 copy 9.999999999999999E+384 -> 9.999999999999999E+384
-ddcpy132 copy 1E-383 -> 1E-383
-ddcpy133 copy 1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpy134 copy 1E-398 -> 1E-398
-
-ddcpy135 copy -1E-398 -> -1E-398
-ddcpy136 copy -1.000000000000000E-383 -> -1.000000000000000E-383
-ddcpy137 copy -1E-383 -> -1E-383
-ddcpy138 copy -9.999999999999999E+384 -> -9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopy.decTest -- quiet decDouble copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpy001 copy +7.50 -> 7.50
+
+-- Infinities
+ddcpy011 copy Infinity -> Infinity
+ddcpy012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddcpy021 copy NaN -> NaN
+ddcpy022 copy -NaN -> -NaN
+ddcpy023 copy sNaN -> sNaN
+ddcpy024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+ddcpy031 copy NaN10 -> NaN10
+ddcpy032 copy -NaN10 -> -NaN10
+ddcpy033 copy sNaN10 -> sNaN10
+ddcpy034 copy -sNaN10 -> -sNaN10
+ddcpy035 copy NaN7 -> NaN7
+ddcpy036 copy -NaN7 -> -NaN7
+ddcpy037 copy sNaN101 -> sNaN101
+ddcpy038 copy -sNaN101 -> -sNaN101
+
+-- finites
+ddcpy101 copy 7 -> 7
+ddcpy102 copy -7 -> -7
+ddcpy103 copy 75 -> 75
+ddcpy104 copy -75 -> -75
+ddcpy105 copy 7.50 -> 7.50
+ddcpy106 copy -7.50 -> -7.50
+ddcpy107 copy 7.500 -> 7.500
+ddcpy108 copy -7.500 -> -7.500
+
+-- zeros
+ddcpy111 copy 0 -> 0
+ddcpy112 copy -0 -> -0
+ddcpy113 copy 0E+4 -> 0E+4
+ddcpy114 copy -0E+4 -> -0E+4
+ddcpy115 copy 0.0000 -> 0.0000
+ddcpy116 copy -0.0000 -> -0.0000
+ddcpy117 copy 0E-141 -> 0E-141
+ddcpy118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+ddcpy121 copy 2682682682682682 -> 2682682682682682
+ddcpy122 copy -2682682682682682 -> -2682682682682682
+ddcpy123 copy 1341341341341341 -> 1341341341341341
+ddcpy124 copy -1341341341341341 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpy131 copy 9.999999999999999E+384 -> 9.999999999999999E+384
+ddcpy132 copy 1E-383 -> 1E-383
+ddcpy133 copy 1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpy134 copy 1E-398 -> 1E-398
+
+ddcpy135 copy -1E-398 -> -1E-398
+ddcpy136 copy -1.000000000000000E-383 -> -1.000000000000000E-383
+ddcpy137 copy -1E-383 -> -1E-383
+ddcpy138 copy -9.999999999999999E+384 -> -9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopyAbs.decTest b/Lib/test/decimaltestdata/ddCopyAbs.decTest
index 4823cf2d771..d436a1940c1 100644
--- a/Lib/test/decimaltestdata/ddCopyAbs.decTest
+++ b/Lib/test/decimaltestdata/ddCopyAbs.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpa001 copyabs +7.50 -> 7.50
-
--- Infinities
-ddcpa011 copyabs Infinity -> Infinity
-ddcpa012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddcpa021 copyabs NaN -> NaN
-ddcpa022 copyabs -NaN -> NaN
-ddcpa023 copyabs sNaN -> sNaN
-ddcpa024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-ddcpa031 copyabs NaN10 -> NaN10
-ddcpa032 copyabs -NaN15 -> NaN15
-ddcpa033 copyabs sNaN15 -> sNaN15
-ddcpa034 copyabs -sNaN10 -> sNaN10
-ddcpa035 copyabs NaN7 -> NaN7
-ddcpa036 copyabs -NaN7 -> NaN7
-ddcpa037 copyabs sNaN101 -> sNaN101
-ddcpa038 copyabs -sNaN101 -> sNaN101
-
--- finites
-ddcpa101 copyabs 7 -> 7
-ddcpa102 copyabs -7 -> 7
-ddcpa103 copyabs 75 -> 75
-ddcpa104 copyabs -75 -> 75
-ddcpa105 copyabs 7.10 -> 7.10
-ddcpa106 copyabs -7.10 -> 7.10
-ddcpa107 copyabs 7.500 -> 7.500
-ddcpa108 copyabs -7.500 -> 7.500
-
--- zeros
-ddcpa111 copyabs 0 -> 0
-ddcpa112 copyabs -0 -> 0
-ddcpa113 copyabs 0E+6 -> 0E+6
-ddcpa114 copyabs -0E+6 -> 0E+6
-ddcpa115 copyabs 0.0000 -> 0.0000
-ddcpa116 copyabs -0.0000 -> 0.0000
-ddcpa117 copyabs 0E-141 -> 0E-141
-ddcpa118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddcpa121 copyabs 2682682682682682 -> 2682682682682682
-ddcpa122 copyabs -2682682682682682 -> 2682682682682682
-ddcpa123 copyabs 1341341341341341 -> 1341341341341341
-ddcpa124 copyabs -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpa131 copyabs 9.999999999999999E+384 -> 9.999999999999999E+384
-ddcpa132 copyabs 1E-383 -> 1E-383
-ddcpa133 copyabs 1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpa134 copyabs 1E-398 -> 1E-398
-
-ddcpa135 copyabs -1E-398 -> 1E-398
-ddcpa136 copyabs -1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpa137 copyabs -1E-383 -> 1E-383
-ddcpa138 copyabs -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopyAbs.decTest -- quiet decDouble copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpa001 copyabs +7.50 -> 7.50
+
+-- Infinities
+ddcpa011 copyabs Infinity -> Infinity
+ddcpa012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddcpa021 copyabs NaN -> NaN
+ddcpa022 copyabs -NaN -> NaN
+ddcpa023 copyabs sNaN -> sNaN
+ddcpa024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+ddcpa031 copyabs NaN10 -> NaN10
+ddcpa032 copyabs -NaN15 -> NaN15
+ddcpa033 copyabs sNaN15 -> sNaN15
+ddcpa034 copyabs -sNaN10 -> sNaN10
+ddcpa035 copyabs NaN7 -> NaN7
+ddcpa036 copyabs -NaN7 -> NaN7
+ddcpa037 copyabs sNaN101 -> sNaN101
+ddcpa038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+ddcpa101 copyabs 7 -> 7
+ddcpa102 copyabs -7 -> 7
+ddcpa103 copyabs 75 -> 75
+ddcpa104 copyabs -75 -> 75
+ddcpa105 copyabs 7.10 -> 7.10
+ddcpa106 copyabs -7.10 -> 7.10
+ddcpa107 copyabs 7.500 -> 7.500
+ddcpa108 copyabs -7.500 -> 7.500
+
+-- zeros
+ddcpa111 copyabs 0 -> 0
+ddcpa112 copyabs -0 -> 0
+ddcpa113 copyabs 0E+6 -> 0E+6
+ddcpa114 copyabs -0E+6 -> 0E+6
+ddcpa115 copyabs 0.0000 -> 0.0000
+ddcpa116 copyabs -0.0000 -> 0.0000
+ddcpa117 copyabs 0E-141 -> 0E-141
+ddcpa118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcpa121 copyabs 2682682682682682 -> 2682682682682682
+ddcpa122 copyabs -2682682682682682 -> 2682682682682682
+ddcpa123 copyabs 1341341341341341 -> 1341341341341341
+ddcpa124 copyabs -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpa131 copyabs 9.999999999999999E+384 -> 9.999999999999999E+384
+ddcpa132 copyabs 1E-383 -> 1E-383
+ddcpa133 copyabs 1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpa134 copyabs 1E-398 -> 1E-398
+
+ddcpa135 copyabs -1E-398 -> 1E-398
+ddcpa136 copyabs -1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpa137 copyabs -1E-383 -> 1E-383
+ddcpa138 copyabs -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopyNegate.decTest b/Lib/test/decimaltestdata/ddCopyNegate.decTest
index 121945c755c..a4c42743729 100644
--- a/Lib/test/decimaltestdata/ddCopyNegate.decTest
+++ b/Lib/test/decimaltestdata/ddCopyNegate.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddCopyNegate.decTest -- quiet decDouble copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcpn001 copynegate +7.50 -> -7.50
-
--- Infinities
-ddcpn011 copynegate Infinity -> -Infinity
-ddcpn012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddcpn021 copynegate NaN -> -NaN
-ddcpn022 copynegate -NaN -> NaN
-ddcpn023 copynegate sNaN -> -sNaN
-ddcpn024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-ddcpn031 copynegate NaN13 -> -NaN13
-ddcpn032 copynegate -NaN13 -> NaN13
-ddcpn033 copynegate sNaN13 -> -sNaN13
-ddcpn034 copynegate -sNaN13 -> sNaN13
-ddcpn035 copynegate NaN70 -> -NaN70
-ddcpn036 copynegate -NaN70 -> NaN70
-ddcpn037 copynegate sNaN101 -> -sNaN101
-ddcpn038 copynegate -sNaN101 -> sNaN101
-
--- finites
-ddcpn101 copynegate 7 -> -7
-ddcpn102 copynegate -7 -> 7
-ddcpn103 copynegate 75 -> -75
-ddcpn104 copynegate -75 -> 75
-ddcpn105 copynegate 7.50 -> -7.50
-ddcpn106 copynegate -7.50 -> 7.50
-ddcpn107 copynegate 7.500 -> -7.500
-ddcpn108 copynegate -7.500 -> 7.500
-
--- zeros
-ddcpn111 copynegate 0 -> -0
-ddcpn112 copynegate -0 -> 0
-ddcpn113 copynegate 0E+4 -> -0E+4
-ddcpn114 copynegate -0E+4 -> 0E+4
-ddcpn115 copynegate 0.0000 -> -0.0000
-ddcpn116 copynegate -0.0000 -> 0.0000
-ddcpn117 copynegate 0E-141 -> -0E-141
-ddcpn118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddcpn121 copynegate 2682682682682682 -> -2682682682682682
-ddcpn122 copynegate -2682682682682682 -> 2682682682682682
-ddcpn123 copynegate 1341341341341341 -> -1341341341341341
-ddcpn124 copynegate -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcpn131 copynegate 9.999999999999999E+384 -> -9.999999999999999E+384
-ddcpn132 copynegate 1E-383 -> -1E-383
-ddcpn133 copynegate 1.000000000000000E-383 -> -1.000000000000000E-383
-ddcpn134 copynegate 1E-398 -> -1E-398
-
-ddcpn135 copynegate -1E-398 -> 1E-398
-ddcpn136 copynegate -1.000000000000000E-383 -> 1.000000000000000E-383
-ddcpn137 copynegate -1E-383 -> 1E-383
-ddcpn138 copynegate -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddCopyNegate.decTest -- quiet decDouble copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcpn001 copynegate +7.50 -> -7.50
+
+-- Infinities
+ddcpn011 copynegate Infinity -> -Infinity
+ddcpn012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddcpn021 copynegate NaN -> -NaN
+ddcpn022 copynegate -NaN -> NaN
+ddcpn023 copynegate sNaN -> -sNaN
+ddcpn024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+ddcpn031 copynegate NaN13 -> -NaN13
+ddcpn032 copynegate -NaN13 -> NaN13
+ddcpn033 copynegate sNaN13 -> -sNaN13
+ddcpn034 copynegate -sNaN13 -> sNaN13
+ddcpn035 copynegate NaN70 -> -NaN70
+ddcpn036 copynegate -NaN70 -> NaN70
+ddcpn037 copynegate sNaN101 -> -sNaN101
+ddcpn038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+ddcpn101 copynegate 7 -> -7
+ddcpn102 copynegate -7 -> 7
+ddcpn103 copynegate 75 -> -75
+ddcpn104 copynegate -75 -> 75
+ddcpn105 copynegate 7.50 -> -7.50
+ddcpn106 copynegate -7.50 -> 7.50
+ddcpn107 copynegate 7.500 -> -7.500
+ddcpn108 copynegate -7.500 -> 7.500
+
+-- zeros
+ddcpn111 copynegate 0 -> -0
+ddcpn112 copynegate -0 -> 0
+ddcpn113 copynegate 0E+4 -> -0E+4
+ddcpn114 copynegate -0E+4 -> 0E+4
+ddcpn115 copynegate 0.0000 -> -0.0000
+ddcpn116 copynegate -0.0000 -> 0.0000
+ddcpn117 copynegate 0E-141 -> -0E-141
+ddcpn118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcpn121 copynegate 2682682682682682 -> -2682682682682682
+ddcpn122 copynegate -2682682682682682 -> 2682682682682682
+ddcpn123 copynegate 1341341341341341 -> -1341341341341341
+ddcpn124 copynegate -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcpn131 copynegate 9.999999999999999E+384 -> -9.999999999999999E+384
+ddcpn132 copynegate 1E-383 -> -1E-383
+ddcpn133 copynegate 1.000000000000000E-383 -> -1.000000000000000E-383
+ddcpn134 copynegate 1E-398 -> -1E-398
+
+ddcpn135 copynegate -1E-398 -> 1E-398
+ddcpn136 copynegate -1.000000000000000E-383 -> 1.000000000000000E-383
+ddcpn137 copynegate -1E-383 -> 1E-383
+ddcpn138 copynegate -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddCopySign.decTest b/Lib/test/decimaltestdata/ddCopySign.decTest
index c99544d9aba..6a78083ad55 100644
--- a/Lib/test/decimaltestdata/ddCopySign.decTest
+++ b/Lib/test/decimaltestdata/ddCopySign.decTest
@@ -1,175 +1,175 @@
-------------------------------------------------------------------------
--- ddCopySign.decTest -- quiet decDouble copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddcps001 copysign +7.50 11 -> 7.50
-
--- Infinities
-ddcps011 copysign Infinity 11 -> Infinity
-ddcps012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-ddcps021 copysign NaN 11 -> NaN
-ddcps022 copysign -NaN 11 -> NaN
-ddcps023 copysign sNaN 11 -> sNaN
-ddcps024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-ddcps031 copysign NaN10 11 -> NaN10
-ddcps032 copysign -NaN10 11 -> NaN10
-ddcps033 copysign sNaN10 11 -> sNaN10
-ddcps034 copysign -sNaN10 11 -> sNaN10
-ddcps035 copysign NaN7 11 -> NaN7
-ddcps036 copysign -NaN7 11 -> NaN7
-ddcps037 copysign sNaN101 11 -> sNaN101
-ddcps038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-ddcps101 copysign 7 11 -> 7
-ddcps102 copysign -7 11 -> 7
-ddcps103 copysign 75 11 -> 75
-ddcps104 copysign -75 11 -> 75
-ddcps105 copysign 7.50 11 -> 7.50
-ddcps106 copysign -7.50 11 -> 7.50
-ddcps107 copysign 7.500 11 -> 7.500
-ddcps108 copysign -7.500 11 -> 7.500
-
--- zeros
-ddcps111 copysign 0 11 -> 0
-ddcps112 copysign -0 11 -> 0
-ddcps113 copysign 0E+4 11 -> 0E+4
-ddcps114 copysign -0E+4 11 -> 0E+4
-ddcps115 copysign 0.0000 11 -> 0.0000
-ddcps116 copysign -0.0000 11 -> 0.0000
-ddcps117 copysign 0E-141 11 -> 0E-141
-ddcps118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-ddcps121 copysign 2682682682682682 11 -> 2682682682682682
-ddcps122 copysign -2682682682682682 11 -> 2682682682682682
-ddcps123 copysign 1341341341341341 11 -> 1341341341341341
-ddcps124 copysign -1341341341341341 11 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcps131 copysign 9.999999999999999E+384 11 -> 9.999999999999999E+384
-ddcps132 copysign 1E-383 11 -> 1E-383
-ddcps133 copysign 1.000000000000000E-383 11 -> 1.000000000000000E-383
-ddcps134 copysign 1E-398 11 -> 1E-398
-
-ddcps135 copysign -1E-398 11 -> 1E-398
-ddcps136 copysign -1.000000000000000E-383 11 -> 1.000000000000000E-383
-ddcps137 copysign -1E-383 11 -> 1E-383
-ddcps138 copysign -9.999999999999999E+384 11 -> 9.999999999999999E+384
-
--- repeat with negative RHS
-
--- Infinities
-ddcps211 copysign Infinity -34 -> -Infinity
-ddcps212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-ddcps221 copysign NaN -34 -> -NaN
-ddcps222 copysign -NaN -34 -> -NaN
-ddcps223 copysign sNaN -34 -> -sNaN
-ddcps224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-ddcps231 copysign NaN10 -34 -> -NaN10
-ddcps232 copysign -NaN10 -34 -> -NaN10
-ddcps233 copysign sNaN10 -34 -> -sNaN10
-ddcps234 copysign -sNaN10 -34 -> -sNaN10
-ddcps235 copysign NaN7 -34 -> -NaN7
-ddcps236 copysign -NaN7 -34 -> -NaN7
-ddcps237 copysign sNaN101 -34 -> -sNaN101
-ddcps238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-ddcps301 copysign 7 -34 -> -7
-ddcps302 copysign -7 -34 -> -7
-ddcps303 copysign 75 -34 -> -75
-ddcps304 copysign -75 -34 -> -75
-ddcps305 copysign 7.50 -34 -> -7.50
-ddcps306 copysign -7.50 -34 -> -7.50
-ddcps307 copysign 7.500 -34 -> -7.500
-ddcps308 copysign -7.500 -34 -> -7.500
-
--- zeros
-ddcps311 copysign 0 -34 -> -0
-ddcps312 copysign -0 -34 -> -0
-ddcps313 copysign 0E+4 -34 -> -0E+4
-ddcps314 copysign -0E+4 -34 -> -0E+4
-ddcps315 copysign 0.0000 -34 -> -0.0000
-ddcps316 copysign -0.0000 -34 -> -0.0000
-ddcps317 copysign 0E-141 -34 -> -0E-141
-ddcps318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-ddcps321 copysign 2682682682682682 -34 -> -2682682682682682
-ddcps322 copysign -2682682682682682 -34 -> -2682682682682682
-ddcps323 copysign 1341341341341341 -34 -> -1341341341341341
-ddcps324 copysign -1341341341341341 -34 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddcps331 copysign 9.999999999999999E+384 -34 -> -9.999999999999999E+384
-ddcps332 copysign 1E-383 -34 -> -1E-383
-ddcps333 copysign 1.000000000000000E-383 -34 -> -1.000000000000000E-383
-ddcps334 copysign 1E-398 -34 -> -1E-398
-
-ddcps335 copysign -1E-398 -34 -> -1E-398
-ddcps336 copysign -1.000000000000000E-383 -34 -> -1.000000000000000E-383
-ddcps337 copysign -1E-383 -34 -> -1E-383
-ddcps338 copysign -9.999999999999999E+384 -34 -> -9.999999999999999E+384
-
--- Other kinds of RHS
-ddcps401 copysign 701 -34 -> -701
-ddcps402 copysign -720 -34 -> -720
-ddcps403 copysign 701 -0 -> -701
-ddcps404 copysign -720 -0 -> -720
-ddcps405 copysign 701 +0 -> 701
-ddcps406 copysign -720 +0 -> 720
-ddcps407 copysign 701 +34 -> 701
-ddcps408 copysign -720 +34 -> 720
-
-ddcps413 copysign 701 -Inf -> -701
-ddcps414 copysign -720 -Inf -> -720
-ddcps415 copysign 701 +Inf -> 701
-ddcps416 copysign -720 +Inf -> 720
-
-ddcps420 copysign 701 -NaN -> -701
-ddcps421 copysign -720 -NaN -> -720
-ddcps422 copysign 701 +NaN -> 701
-ddcps423 copysign -720 +NaN -> 720
-ddcps425 copysign -720 +NaN8 -> 720
-
-ddcps426 copysign 701 -sNaN -> -701
-ddcps427 copysign -720 -sNaN -> -720
-ddcps428 copysign 701 +sNaN -> 701
-ddcps429 copysign -720 +sNaN -> 720
-ddcps430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- ddCopySign.decTest -- quiet decDouble copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddcps001 copysign +7.50 11 -> 7.50
+
+-- Infinities
+ddcps011 copysign Infinity 11 -> Infinity
+ddcps012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+ddcps021 copysign NaN 11 -> NaN
+ddcps022 copysign -NaN 11 -> NaN
+ddcps023 copysign sNaN 11 -> sNaN
+ddcps024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+ddcps031 copysign NaN10 11 -> NaN10
+ddcps032 copysign -NaN10 11 -> NaN10
+ddcps033 copysign sNaN10 11 -> sNaN10
+ddcps034 copysign -sNaN10 11 -> sNaN10
+ddcps035 copysign NaN7 11 -> NaN7
+ddcps036 copysign -NaN7 11 -> NaN7
+ddcps037 copysign sNaN101 11 -> sNaN101
+ddcps038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+ddcps101 copysign 7 11 -> 7
+ddcps102 copysign -7 11 -> 7
+ddcps103 copysign 75 11 -> 75
+ddcps104 copysign -75 11 -> 75
+ddcps105 copysign 7.50 11 -> 7.50
+ddcps106 copysign -7.50 11 -> 7.50
+ddcps107 copysign 7.500 11 -> 7.500
+ddcps108 copysign -7.500 11 -> 7.500
+
+-- zeros
+ddcps111 copysign 0 11 -> 0
+ddcps112 copysign -0 11 -> 0
+ddcps113 copysign 0E+4 11 -> 0E+4
+ddcps114 copysign -0E+4 11 -> 0E+4
+ddcps115 copysign 0.0000 11 -> 0.0000
+ddcps116 copysign -0.0000 11 -> 0.0000
+ddcps117 copysign 0E-141 11 -> 0E-141
+ddcps118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+ddcps121 copysign 2682682682682682 11 -> 2682682682682682
+ddcps122 copysign -2682682682682682 11 -> 2682682682682682
+ddcps123 copysign 1341341341341341 11 -> 1341341341341341
+ddcps124 copysign -1341341341341341 11 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcps131 copysign 9.999999999999999E+384 11 -> 9.999999999999999E+384
+ddcps132 copysign 1E-383 11 -> 1E-383
+ddcps133 copysign 1.000000000000000E-383 11 -> 1.000000000000000E-383
+ddcps134 copysign 1E-398 11 -> 1E-398
+
+ddcps135 copysign -1E-398 11 -> 1E-398
+ddcps136 copysign -1.000000000000000E-383 11 -> 1.000000000000000E-383
+ddcps137 copysign -1E-383 11 -> 1E-383
+ddcps138 copysign -9.999999999999999E+384 11 -> 9.999999999999999E+384
+
+-- repeat with negative RHS
+
+-- Infinities
+ddcps211 copysign Infinity -34 -> -Infinity
+ddcps212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+ddcps221 copysign NaN -34 -> -NaN
+ddcps222 copysign -NaN -34 -> -NaN
+ddcps223 copysign sNaN -34 -> -sNaN
+ddcps224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+ddcps231 copysign NaN10 -34 -> -NaN10
+ddcps232 copysign -NaN10 -34 -> -NaN10
+ddcps233 copysign sNaN10 -34 -> -sNaN10
+ddcps234 copysign -sNaN10 -34 -> -sNaN10
+ddcps235 copysign NaN7 -34 -> -NaN7
+ddcps236 copysign -NaN7 -34 -> -NaN7
+ddcps237 copysign sNaN101 -34 -> -sNaN101
+ddcps238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+ddcps301 copysign 7 -34 -> -7
+ddcps302 copysign -7 -34 -> -7
+ddcps303 copysign 75 -34 -> -75
+ddcps304 copysign -75 -34 -> -75
+ddcps305 copysign 7.50 -34 -> -7.50
+ddcps306 copysign -7.50 -34 -> -7.50
+ddcps307 copysign 7.500 -34 -> -7.500
+ddcps308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+ddcps311 copysign 0 -34 -> -0
+ddcps312 copysign -0 -34 -> -0
+ddcps313 copysign 0E+4 -34 -> -0E+4
+ddcps314 copysign -0E+4 -34 -> -0E+4
+ddcps315 copysign 0.0000 -34 -> -0.0000
+ddcps316 copysign -0.0000 -34 -> -0.0000
+ddcps317 copysign 0E-141 -34 -> -0E-141
+ddcps318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+ddcps321 copysign 2682682682682682 -34 -> -2682682682682682
+ddcps322 copysign -2682682682682682 -34 -> -2682682682682682
+ddcps323 copysign 1341341341341341 -34 -> -1341341341341341
+ddcps324 copysign -1341341341341341 -34 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddcps331 copysign 9.999999999999999E+384 -34 -> -9.999999999999999E+384
+ddcps332 copysign 1E-383 -34 -> -1E-383
+ddcps333 copysign 1.000000000000000E-383 -34 -> -1.000000000000000E-383
+ddcps334 copysign 1E-398 -34 -> -1E-398
+
+ddcps335 copysign -1E-398 -34 -> -1E-398
+ddcps336 copysign -1.000000000000000E-383 -34 -> -1.000000000000000E-383
+ddcps337 copysign -1E-383 -34 -> -1E-383
+ddcps338 copysign -9.999999999999999E+384 -34 -> -9.999999999999999E+384
+
+-- Other kinds of RHS
+ddcps401 copysign 701 -34 -> -701
+ddcps402 copysign -720 -34 -> -720
+ddcps403 copysign 701 -0 -> -701
+ddcps404 copysign -720 -0 -> -720
+ddcps405 copysign 701 +0 -> 701
+ddcps406 copysign -720 +0 -> 720
+ddcps407 copysign 701 +34 -> 701
+ddcps408 copysign -720 +34 -> 720
+
+ddcps413 copysign 701 -Inf -> -701
+ddcps414 copysign -720 -Inf -> -720
+ddcps415 copysign 701 +Inf -> 701
+ddcps416 copysign -720 +Inf -> 720
+
+ddcps420 copysign 701 -NaN -> -701
+ddcps421 copysign -720 -NaN -> -720
+ddcps422 copysign 701 +NaN -> 701
+ddcps423 copysign -720 +NaN -> 720
+ddcps425 copysign -720 +NaN8 -> 720
+
+ddcps426 copysign 701 -sNaN -> -701
+ddcps427 copysign -720 -sNaN -> -720
+ddcps428 copysign 701 +sNaN -> 701
+ddcps429 copysign -720 +sNaN -> 720
+ddcps430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/ddDivide.decTest b/Lib/test/decimaltestdata/ddDivide.decTest
index 019db228d48..5531d0e0315 100644
--- a/Lib/test/decimaltestdata/ddDivide.decTest
+++ b/Lib/test/decimaltestdata/ddDivide.decTest
@@ -1,863 +1,863 @@
-------------------------------------------------------------------------
--- ddDivide.decTest -- decDouble division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-dddiv001 divide 1 1 -> 1
-dddiv002 divide 2 1 -> 2
-dddiv003 divide 1 2 -> 0.5
-dddiv004 divide 2 2 -> 1
-dddiv005 divide 0 1 -> 0
-dddiv006 divide 0 2 -> 0
-dddiv007 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv008 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv009 divide 3 3 -> 1
-
-dddiv010 divide 2.4 1 -> 2.4
-dddiv011 divide 2.4 -1 -> -2.4
-dddiv012 divide -2.4 1 -> -2.4
-dddiv013 divide -2.4 -1 -> 2.4
-dddiv014 divide 2.40 1 -> 2.40
-dddiv015 divide 2.400 1 -> 2.400
-dddiv016 divide 2.4 2 -> 1.2
-dddiv017 divide 2.400 2 -> 1.200
-dddiv018 divide 2. 2 -> 1
-dddiv019 divide 20 20 -> 1
-
-dddiv020 divide 187 187 -> 1
-dddiv021 divide 5 2 -> 2.5
-dddiv022 divide 50 20 -> 2.5
-dddiv023 divide 500 200 -> 2.5
-dddiv024 divide 50.0 20.0 -> 2.5
-dddiv025 divide 5.00 2.00 -> 2.5
-dddiv026 divide 5 2.0 -> 2.5
-dddiv027 divide 5 2.000 -> 2.5
-dddiv028 divide 5 0.20 -> 25
-dddiv029 divide 5 0.200 -> 25
-dddiv030 divide 10 1 -> 10
-dddiv031 divide 100 1 -> 100
-dddiv032 divide 1000 1 -> 1000
-dddiv033 divide 1000 100 -> 10
-
-dddiv035 divide 1 2 -> 0.5
-dddiv036 divide 1 4 -> 0.25
-dddiv037 divide 1 8 -> 0.125
-dddiv038 divide 1 16 -> 0.0625
-dddiv039 divide 1 32 -> 0.03125
-dddiv040 divide 1 64 -> 0.015625
-dddiv041 divide 1 -2 -> -0.5
-dddiv042 divide 1 -4 -> -0.25
-dddiv043 divide 1 -8 -> -0.125
-dddiv044 divide 1 -16 -> -0.0625
-dddiv045 divide 1 -32 -> -0.03125
-dddiv046 divide 1 -64 -> -0.015625
-dddiv047 divide -1 2 -> -0.5
-dddiv048 divide -1 4 -> -0.25
-dddiv049 divide -1 8 -> -0.125
-dddiv050 divide -1 16 -> -0.0625
-dddiv051 divide -1 32 -> -0.03125
-dddiv052 divide -1 64 -> -0.015625
-dddiv053 divide -1 -2 -> 0.5
-dddiv054 divide -1 -4 -> 0.25
-dddiv055 divide -1 -8 -> 0.125
-dddiv056 divide -1 -16 -> 0.0625
-dddiv057 divide -1 -32 -> 0.03125
-dddiv058 divide -1 -64 -> 0.015625
-
--- bcdTime
-dddiv060 divide 1 7 -> 0.1428571428571429 Inexact Rounded
-dddiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717 Inexact Rounded
-
--- 1234567890123456
-dddiv071 divide 9999999999999999 1 -> 9999999999999999
-dddiv072 divide 999999999999999 1 -> 999999999999999
-dddiv073 divide 99999999999999 1 -> 99999999999999
-dddiv074 divide 9999999999999 1 -> 9999999999999
-dddiv075 divide 999999999999 1 -> 999999999999
-dddiv076 divide 99999999999 1 -> 99999999999
-dddiv077 divide 9999999999 1 -> 9999999999
-dddiv078 divide 999999999 1 -> 999999999
-dddiv079 divide 99999999 1 -> 99999999
-dddiv080 divide 9999999 1 -> 9999999
-dddiv081 divide 999999 1 -> 999999
-dddiv082 divide 99999 1 -> 99999
-dddiv083 divide 9999 1 -> 9999
-dddiv084 divide 999 1 -> 999
-dddiv085 divide 99 1 -> 99
-dddiv086 divide 9 1 -> 9
-
-dddiv090 divide 0. 1 -> 0
-dddiv091 divide .0 1 -> 0.0
-dddiv092 divide 0.00 1 -> 0.00
-dddiv093 divide 0.00E+9 1 -> 0E+7
-dddiv094 divide 0.0000E-50 1 -> 0E-54
-
-dddiv095 divide 1 1E-8 -> 1E+8
-dddiv096 divide 1 1E-9 -> 1E+9
-dddiv097 divide 1 1E-10 -> 1E+10
-dddiv098 divide 1 1E-11 -> 1E+11
-dddiv099 divide 1 1E-12 -> 1E+12
-
-dddiv100 divide 1 1 -> 1
-dddiv101 divide 1 2 -> 0.5
-dddiv102 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv103 divide 1 4 -> 0.25
-dddiv104 divide 1 5 -> 0.2
-dddiv105 divide 1 6 -> 0.1666666666666667 Inexact Rounded
-dddiv106 divide 1 7 -> 0.1428571428571429 Inexact Rounded
-dddiv107 divide 1 8 -> 0.125
-dddiv108 divide 1 9 -> 0.1111111111111111 Inexact Rounded
-dddiv109 divide 1 10 -> 0.1
-dddiv110 divide 1 1 -> 1
-dddiv111 divide 2 1 -> 2
-dddiv112 divide 3 1 -> 3
-dddiv113 divide 4 1 -> 4
-dddiv114 divide 5 1 -> 5
-dddiv115 divide 6 1 -> 6
-dddiv116 divide 7 1 -> 7
-dddiv117 divide 8 1 -> 8
-dddiv118 divide 9 1 -> 9
-dddiv119 divide 10 1 -> 10
-
-dddiv120 divide 3E+1 0.001 -> 3E+4
-dddiv121 divide 2.200 2 -> 1.100
-
-dddiv130 divide 12345 4.999 -> 2469.493898779756 Inexact Rounded
-dddiv131 divide 12345 4.99 -> 2473.947895791583 Inexact Rounded
-dddiv132 divide 12345 4.9 -> 2519.387755102041 Inexact Rounded
-dddiv133 divide 12345 5 -> 2469
-dddiv134 divide 12345 5.1 -> 2420.588235294118 Inexact Rounded
-dddiv135 divide 12345 5.01 -> 2464.071856287425 Inexact Rounded
-dddiv136 divide 12345 5.001 -> 2468.506298740252 Inexact Rounded
-
--- test possibly imprecise results
-dddiv220 divide 391 597 -> 0.6549413735343384 Inexact Rounded
-dddiv221 divide 391 -597 -> -0.6549413735343384 Inexact Rounded
-dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded
-dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded
-
--- test some cases that are close to exponent overflow, some with coefficient padding
-dddiv270 divide 1 1e384 -> 1E-384 Subnormal
-dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow
-dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow
-dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384 Rounded Inexact Subnormal Underflow
-dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped
-dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped
-dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped
-dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped
-dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped
-dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384
-
-dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped
-dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded
-dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped
-dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded
-dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped
-
-
--- Divide into 0 tests
-dddiv301 divide 0 7 -> 0
-dddiv302 divide 0 7E-5 -> 0E+5
-dddiv303 divide 0 7E-1 -> 0E+1
-dddiv304 divide 0 7E+1 -> 0.0
-dddiv305 divide 0 7E+5 -> 0.00000
-dddiv306 divide 0 7E+6 -> 0.000000
-dddiv307 divide 0 7E+7 -> 0E-7
-dddiv308 divide 0 70E-5 -> 0E+5
-dddiv309 divide 0 70E-1 -> 0E+1
-dddiv310 divide 0 70E+0 -> 0
-dddiv311 divide 0 70E+1 -> 0.0
-dddiv312 divide 0 70E+5 -> 0.00000
-dddiv313 divide 0 70E+6 -> 0.000000
-dddiv314 divide 0 70E+7 -> 0E-7
-dddiv315 divide 0 700E-5 -> 0E+5
-dddiv316 divide 0 700E-1 -> 0E+1
-dddiv317 divide 0 700E+0 -> 0
-dddiv318 divide 0 700E+1 -> 0.0
-dddiv319 divide 0 700E+5 -> 0.00000
-dddiv320 divide 0 700E+6 -> 0.000000
-dddiv321 divide 0 700E+7 -> 0E-7
-dddiv322 divide 0 700E+77 -> 0E-77
-
-dddiv331 divide 0E-3 7E-5 -> 0E+2
-dddiv332 divide 0E-3 7E-1 -> 0.00
-dddiv333 divide 0E-3 7E+1 -> 0.0000
-dddiv334 divide 0E-3 7E+5 -> 0E-8
-dddiv335 divide 0E-1 7E-5 -> 0E+4
-dddiv336 divide 0E-1 7E-1 -> 0
-dddiv337 divide 0E-1 7E+1 -> 0.00
-dddiv338 divide 0E-1 7E+5 -> 0.000000
-dddiv339 divide 0E+1 7E-5 -> 0E+6
-dddiv340 divide 0E+1 7E-1 -> 0E+2
-dddiv341 divide 0E+1 7E+1 -> 0
-dddiv342 divide 0E+1 7E+5 -> 0.0000
-dddiv343 divide 0E+3 7E-5 -> 0E+8
-dddiv344 divide 0E+3 7E-1 -> 0E+4
-dddiv345 divide 0E+3 7E+1 -> 0E+2
-dddiv346 divide 0E+3 7E+5 -> 0.00
-
--- These were 'input rounding'
-dddiv441 divide 12345678000 1 -> 12345678000
-dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
-dddiv443 divide 1234567800 1 -> 1234567800
-dddiv444 divide 1 1234567800 -> 8.100000664200054E-10 Inexact Rounded
-dddiv445 divide 1234567890 1 -> 1234567890
-dddiv446 divide 1 1234567890 -> 8.100000073710001E-10 Inexact Rounded
-dddiv447 divide 1234567891 1 -> 1234567891
-dddiv448 divide 1 1234567891 -> 8.100000067149001E-10 Inexact Rounded
-dddiv449 divide 12345678901 1 -> 12345678901
-dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
-dddiv451 divide 1234567896 1 -> 1234567896
-dddiv452 divide 1 1234567896 -> 8.100000034344000E-10 Inexact Rounded
-
--- high-lows
-dddiv453 divide 1e+1 1 -> 1E+1
-dddiv454 divide 1e+1 1.0 -> 1E+1
-dddiv455 divide 1e+1 1.00 -> 1E+1
-dddiv456 divide 1e+2 2 -> 5E+1
-dddiv457 divide 1e+2 2.0 -> 5E+1
-dddiv458 divide 1e+2 2.00 -> 5E+1
-
--- some from IEEE discussions
-dddiv460 divide 3e0 2e0 -> 1.5
-dddiv461 divide 30e-1 2e0 -> 1.5
-dddiv462 divide 300e-2 2e0 -> 1.50
-dddiv464 divide 3000e-3 2e0 -> 1.500
-dddiv465 divide 3e0 20e-1 -> 1.5
-dddiv466 divide 30e-1 20e-1 -> 1.5
-dddiv467 divide 300e-2 20e-1 -> 1.5
-dddiv468 divide 3000e-3 20e-1 -> 1.50
-dddiv469 divide 3e0 200e-2 -> 1.5
-dddiv470 divide 30e-1 200e-2 -> 1.5
-dddiv471 divide 300e-2 200e-2 -> 1.5
-dddiv472 divide 3000e-3 200e-2 -> 1.5
-dddiv473 divide 3e0 2000e-3 -> 1.5
-dddiv474 divide 30e-1 2000e-3 -> 1.5
-dddiv475 divide 300e-2 2000e-3 -> 1.5
-dddiv476 divide 3000e-3 2000e-3 -> 1.5
-
--- some reciprocals
-dddiv480 divide 1 1.0E+33 -> 1E-33
-dddiv481 divide 1 10E+33 -> 1E-34
-dddiv482 divide 1 1.0E-33 -> 1E+33
-dddiv483 divide 1 10E-33 -> 1E+32
-
--- RMS discussion table
-dddiv484 divide 0e5 1e3 -> 0E+2
-dddiv485 divide 0e5 2e3 -> 0E+2
-dddiv486 divide 0e5 10e2 -> 0E+3
-dddiv487 divide 0e5 20e2 -> 0E+3
-dddiv488 divide 0e5 100e1 -> 0E+4
-dddiv489 divide 0e5 200e1 -> 0E+4
-
-dddiv491 divide 1e5 1e3 -> 1E+2
-dddiv492 divide 1e5 2e3 -> 5E+1
-dddiv493 divide 1e5 10e2 -> 1E+2
-dddiv494 divide 1e5 20e2 -> 5E+1
-dddiv495 divide 1e5 100e1 -> 1E+2
-dddiv496 divide 1e5 200e1 -> 5E+1
-
--- tryzeros cases
-rounding: half_up
-dddiv497 divide 0E+380 1000E-13 -> 0E+369 Clamped
-dddiv498 divide 0E-390 1000E+13 -> 0E-398 Clamped
-
-rounding: half_up
-
--- focus on trailing zeros issues
-dddiv500 divide 1 9.9 -> 0.1010101010101010 Inexact Rounded
-dddiv501 divide 1 9.09 -> 0.1100110011001100 Inexact Rounded
-dddiv502 divide 1 9.009 -> 0.1110001110001110 Inexact Rounded
-
-dddiv511 divide 1 2 -> 0.5
-dddiv512 divide 1.0 2 -> 0.5
-dddiv513 divide 1.00 2 -> 0.50
-dddiv514 divide 1.000 2 -> 0.500
-dddiv515 divide 1.0000 2 -> 0.5000
-dddiv516 divide 1.00000 2 -> 0.50000
-dddiv517 divide 1.000000 2 -> 0.500000
-dddiv518 divide 1.0000000 2 -> 0.5000000
-dddiv519 divide 1.00 2.00 -> 0.5
-
-dddiv521 divide 2 1 -> 2
-dddiv522 divide 2 1.0 -> 2
-dddiv523 divide 2 1.00 -> 2
-dddiv524 divide 2 1.000 -> 2
-dddiv525 divide 2 1.0000 -> 2
-dddiv526 divide 2 1.00000 -> 2
-dddiv527 divide 2 1.000000 -> 2
-dddiv528 divide 2 1.0000000 -> 2
-dddiv529 divide 2.00 1.00 -> 2
-
-dddiv530 divide 2.40 2 -> 1.20
-dddiv531 divide 2.40 4 -> 0.60
-dddiv532 divide 2.40 10 -> 0.24
-dddiv533 divide 2.40 2.0 -> 1.2
-dddiv534 divide 2.40 4.0 -> 0.6
-dddiv535 divide 2.40 10.0 -> 0.24
-dddiv536 divide 2.40 2.00 -> 1.2
-dddiv537 divide 2.40 4.00 -> 0.6
-dddiv538 divide 2.40 10.00 -> 0.24
-dddiv539 divide 0.9 0.1 -> 9
-dddiv540 divide 0.9 0.01 -> 9E+1
-dddiv541 divide 0.9 0.001 -> 9E+2
-dddiv542 divide 5 2 -> 2.5
-dddiv543 divide 5 2.0 -> 2.5
-dddiv544 divide 5 2.00 -> 2.5
-dddiv545 divide 5 20 -> 0.25
-dddiv546 divide 5 20.0 -> 0.25
-dddiv547 divide 2.400 2 -> 1.200
-dddiv548 divide 2.400 2.0 -> 1.20
-dddiv549 divide 2.400 2.400 -> 1
-
-dddiv550 divide 240 1 -> 240
-dddiv551 divide 240 10 -> 24
-dddiv552 divide 240 100 -> 2.4
-dddiv553 divide 240 1000 -> 0.24
-dddiv554 divide 2400 1 -> 2400
-dddiv555 divide 2400 10 -> 240
-dddiv556 divide 2400 100 -> 24
-dddiv557 divide 2400 1000 -> 2.4
-
--- +ve exponent
-dddiv600 divide 2.4E+9 2 -> 1.2E+9
-dddiv601 divide 2.40E+9 2 -> 1.20E+9
-dddiv602 divide 2.400E+9 2 -> 1.200E+9
-dddiv603 divide 2.4000E+9 2 -> 1.2000E+9
-dddiv604 divide 24E+8 2 -> 1.2E+9
-dddiv605 divide 240E+7 2 -> 1.20E+9
-dddiv606 divide 2400E+6 2 -> 1.200E+9
-dddiv607 divide 24000E+5 2 -> 1.2000E+9
-
--- more zeros, etc.
-dddiv731 divide 5.00 1E-3 -> 5.00E+3
-dddiv732 divide 00.00 0.000 -> NaN Division_undefined
-dddiv733 divide 00.00 0E-3 -> NaN Division_undefined
-dddiv734 divide 0 -0 -> NaN Division_undefined
-dddiv735 divide -0 0 -> NaN Division_undefined
-dddiv736 divide -0 -0 -> NaN Division_undefined
-
-dddiv741 divide 0 -1 -> -0
-dddiv742 divide -0 -1 -> 0
-dddiv743 divide 0 1 -> 0
-dddiv744 divide -0 1 -> -0
-dddiv745 divide -1 0 -> -Infinity Division_by_zero
-dddiv746 divide -1 -0 -> Infinity Division_by_zero
-dddiv747 divide 1 0 -> Infinity Division_by_zero
-dddiv748 divide 1 -0 -> -Infinity Division_by_zero
-
-dddiv751 divide 0.0 -1 -> -0.0
-dddiv752 divide -0.0 -1 -> 0.0
-dddiv753 divide 0.0 1 -> 0.0
-dddiv754 divide -0.0 1 -> -0.0
-dddiv755 divide -1.0 0 -> -Infinity Division_by_zero
-dddiv756 divide -1.0 -0 -> Infinity Division_by_zero
-dddiv757 divide 1.0 0 -> Infinity Division_by_zero
-dddiv758 divide 1.0 -0 -> -Infinity Division_by_zero
-
-dddiv761 divide 0 -1.0 -> -0E+1
-dddiv762 divide -0 -1.0 -> 0E+1
-dddiv763 divide 0 1.0 -> 0E+1
-dddiv764 divide -0 1.0 -> -0E+1
-dddiv765 divide -1 0.0 -> -Infinity Division_by_zero
-dddiv766 divide -1 -0.0 -> Infinity Division_by_zero
-dddiv767 divide 1 0.0 -> Infinity Division_by_zero
-dddiv768 divide 1 -0.0 -> -Infinity Division_by_zero
-
-dddiv771 divide 0.0 -1.0 -> -0
-dddiv772 divide -0.0 -1.0 -> 0
-dddiv773 divide 0.0 1.0 -> 0
-dddiv774 divide -0.0 1.0 -> -0
-dddiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
-dddiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
-dddiv777 divide 1.0 0.0 -> Infinity Division_by_zero
-dddiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dddiv780 divide Inf -Inf -> NaN Invalid_operation
-dddiv781 divide Inf -1000 -> -Infinity
-dddiv782 divide Inf -1 -> -Infinity
-dddiv783 divide Inf -0 -> -Infinity
-dddiv784 divide Inf 0 -> Infinity
-dddiv785 divide Inf 1 -> Infinity
-dddiv786 divide Inf 1000 -> Infinity
-dddiv787 divide Inf Inf -> NaN Invalid_operation
-dddiv788 divide -1000 Inf -> -0E-398 Clamped
-dddiv789 divide -Inf Inf -> NaN Invalid_operation
-dddiv790 divide -1 Inf -> -0E-398 Clamped
-dddiv791 divide -0 Inf -> -0E-398 Clamped
-dddiv792 divide 0 Inf -> 0E-398 Clamped
-dddiv793 divide 1 Inf -> 0E-398 Clamped
-dddiv794 divide 1000 Inf -> 0E-398 Clamped
-dddiv795 divide Inf Inf -> NaN Invalid_operation
-
-dddiv800 divide -Inf -Inf -> NaN Invalid_operation
-dddiv801 divide -Inf -1000 -> Infinity
-dddiv802 divide -Inf -1 -> Infinity
-dddiv803 divide -Inf -0 -> Infinity
-dddiv804 divide -Inf 0 -> -Infinity
-dddiv805 divide -Inf 1 -> -Infinity
-dddiv806 divide -Inf 1000 -> -Infinity
-dddiv807 divide -Inf Inf -> NaN Invalid_operation
-dddiv808 divide -1000 Inf -> -0E-398 Clamped
-dddiv809 divide -Inf -Inf -> NaN Invalid_operation
-dddiv810 divide -1 -Inf -> 0E-398 Clamped
-dddiv811 divide -0 -Inf -> 0E-398 Clamped
-dddiv812 divide 0 -Inf -> -0E-398 Clamped
-dddiv813 divide 1 -Inf -> -0E-398 Clamped
-dddiv814 divide 1000 -Inf -> -0E-398 Clamped
-dddiv815 divide Inf -Inf -> NaN Invalid_operation
-
-dddiv821 divide NaN -Inf -> NaN
-dddiv822 divide NaN -1000 -> NaN
-dddiv823 divide NaN -1 -> NaN
-dddiv824 divide NaN -0 -> NaN
-dddiv825 divide NaN 0 -> NaN
-dddiv826 divide NaN 1 -> NaN
-dddiv827 divide NaN 1000 -> NaN
-dddiv828 divide NaN Inf -> NaN
-dddiv829 divide NaN NaN -> NaN
-dddiv830 divide -Inf NaN -> NaN
-dddiv831 divide -1000 NaN -> NaN
-dddiv832 divide -1 NaN -> NaN
-dddiv833 divide -0 NaN -> NaN
-dddiv834 divide 0 NaN -> NaN
-dddiv835 divide 1 NaN -> NaN
-dddiv836 divide 1000 NaN -> NaN
-dddiv837 divide Inf NaN -> NaN
-
-dddiv841 divide sNaN -Inf -> NaN Invalid_operation
-dddiv842 divide sNaN -1000 -> NaN Invalid_operation
-dddiv843 divide sNaN -1 -> NaN Invalid_operation
-dddiv844 divide sNaN -0 -> NaN Invalid_operation
-dddiv845 divide sNaN 0 -> NaN Invalid_operation
-dddiv846 divide sNaN 1 -> NaN Invalid_operation
-dddiv847 divide sNaN 1000 -> NaN Invalid_operation
-dddiv848 divide sNaN NaN -> NaN Invalid_operation
-dddiv849 divide sNaN sNaN -> NaN Invalid_operation
-dddiv850 divide NaN sNaN -> NaN Invalid_operation
-dddiv851 divide -Inf sNaN -> NaN Invalid_operation
-dddiv852 divide -1000 sNaN -> NaN Invalid_operation
-dddiv853 divide -1 sNaN -> NaN Invalid_operation
-dddiv854 divide -0 sNaN -> NaN Invalid_operation
-dddiv855 divide 0 sNaN -> NaN Invalid_operation
-dddiv856 divide 1 sNaN -> NaN Invalid_operation
-dddiv857 divide 1000 sNaN -> NaN Invalid_operation
-dddiv858 divide Inf sNaN -> NaN Invalid_operation
-dddiv859 divide NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dddiv861 divide NaN9 -Inf -> NaN9
-dddiv862 divide NaN8 1000 -> NaN8
-dddiv863 divide NaN7 Inf -> NaN7
-dddiv864 divide NaN6 NaN5 -> NaN6
-dddiv865 divide -Inf NaN4 -> NaN4
-dddiv866 divide -1000 NaN3 -> NaN3
-dddiv867 divide Inf NaN2 -> NaN2
-
-dddiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
-dddiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
-dddiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
-dddiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
-dddiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
-dddiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
-dddiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
-dddiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
-dddiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
-
-dddiv881 divide -NaN9 -Inf -> -NaN9
-dddiv882 divide -NaN8 1000 -> -NaN8
-dddiv883 divide -NaN7 Inf -> -NaN7
-dddiv884 divide -NaN6 -NaN5 -> -NaN6
-dddiv885 divide -Inf -NaN4 -> -NaN4
-dddiv886 divide -1000 -NaN3 -> -NaN3
-dddiv887 divide Inf -NaN2 -> -NaN2
-
-dddiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
-dddiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
-dddiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
-dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
-dddiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dddiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
-dddiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
-dddiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
-dddiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- Various flavours of divide by 0
-dddiv901 divide 0 0 -> NaN Division_undefined
-dddiv902 divide 0.0E5 0 -> NaN Division_undefined
-dddiv903 divide 0.000 0 -> NaN Division_undefined
-dddiv904 divide 0.0001 0 -> Infinity Division_by_zero
-dddiv905 divide 0.01 0 -> Infinity Division_by_zero
-dddiv906 divide 0.1 0 -> Infinity Division_by_zero
-dddiv907 divide 1 0 -> Infinity Division_by_zero
-dddiv908 divide 1 0.0 -> Infinity Division_by_zero
-dddiv909 divide 10 0.0 -> Infinity Division_by_zero
-dddiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
-dddiv911 divide 1E+100 0 -> Infinity Division_by_zero
-
-dddiv921 divide -0.0001 0 -> -Infinity Division_by_zero
-dddiv922 divide -0.01 0 -> -Infinity Division_by_zero
-dddiv923 divide -0.1 0 -> -Infinity Division_by_zero
-dddiv924 divide -1 0 -> -Infinity Division_by_zero
-dddiv925 divide -1 0.0 -> -Infinity Division_by_zero
-dddiv926 divide -10 0.0 -> -Infinity Division_by_zero
-dddiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
-dddiv928 divide -1E+100 0 -> -Infinity Division_by_zero
-
-dddiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
-dddiv932 divide 0.01 -0 -> -Infinity Division_by_zero
-dddiv933 divide 0.1 -0 -> -Infinity Division_by_zero
-dddiv934 divide 1 -0 -> -Infinity Division_by_zero
-dddiv935 divide 1 -0.0 -> -Infinity Division_by_zero
-dddiv936 divide 10 -0.0 -> -Infinity Division_by_zero
-dddiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
-dddiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
-
-dddiv941 divide -0.0001 -0 -> Infinity Division_by_zero
-dddiv942 divide -0.01 -0 -> Infinity Division_by_zero
-dddiv943 divide -0.1 -0 -> Infinity Division_by_zero
-dddiv944 divide -1 -0 -> Infinity Division_by_zero
-dddiv945 divide -1 -0.0 -> Infinity Division_by_zero
-dddiv946 divide -10 -0.0 -> Infinity Division_by_zero
-dddiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
-dddiv948 divide -1E+100 -0 -> Infinity Division_by_zero
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dddiv1021 divide 1E0 1E0 -> 1
-dddiv1022 divide 1E0 2E0 -> 0.5
-dddiv1023 divide 1E0 3E0 -> 0.3333333333333333 Inexact Rounded
-dddiv1024 divide 100E-2 1000E-3 -> 1
-dddiv1025 divide 24E-1 2E0 -> 1.2
-dddiv1026 divide 2400E-3 2E0 -> 1.200
-dddiv1027 divide 5E0 2E0 -> 2.5
-dddiv1028 divide 5E0 20E-1 -> 2.5
-dddiv1029 divide 5E0 2000E-3 -> 2.5
-dddiv1030 divide 5E0 2E-1 -> 25
-dddiv1031 divide 5E0 20E-2 -> 25
-dddiv1032 divide 480E-2 3E0 -> 1.60
-dddiv1033 divide 47E-1 2E0 -> 2.35
-
--- ECMAScript bad examples
-rounding: half_down
-dddiv1040 divide 5 9 -> 0.5555555555555556 Inexact Rounded
-rounding: half_even
-dddiv1041 divide 6 11 -> 0.5454545454545455 Inexact Rounded
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dddiv1051 divide 1e+277 1e-311 -> Infinity Overflow Inexact Rounded
-dddiv1052 divide 1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
-dddiv1053 divide -1e+277 1e-311 -> -Infinity Overflow Inexact Rounded
-dddiv1054 divide -1e+277 -1e-311 -> Infinity Overflow Inexact Rounded
-dddiv1055 divide 1e-277 1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1056 divide 1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1057 divide -1e-277 1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1058 divide -1e-277 -1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
-dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
-dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
-dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
-dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
-dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
-dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
-dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381 Clamped
-dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382 Clamped
-dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383 Clamped
-dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384 Clamped
-dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
-dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
-dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
-dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
-dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
-dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded
-
-dddiv1101 divide 1.0000E-394 1 -> 1.0000E-394 Subnormal
-dddiv1102 divide 1.000E-394 1e+1 -> 1.000E-395 Subnormal
-dddiv1103 divide 1.00E-394 1e+2 -> 1.00E-396 Subnormal
-dddiv1104 divide 1.0E-394 1e+3 -> 1.0E-397 Subnormal
-dddiv1105 divide 1.0E-394 1e+4 -> 1E-398 Subnormal Rounded
-dddiv1106 divide 1.3E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1107 divide 1.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1108 divide 1.7E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1109 divide 2.3E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1110 divide 2.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1111 divide 2.7E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
-dddiv1112 divide 1.49E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1113 divide 1.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1114 divide 1.51E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1115 divide 2.49E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1116 divide 2.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
-dddiv1117 divide 2.51E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-dddiv1118 divide 1E-394 1e+4 -> 1E-398 Subnormal
-dddiv1119 divide 3E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1120 divide 5E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1121 divide 7E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1122 divide 9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-dddiv1123 divide 9.9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-dddiv1124 divide 1E-394 -1e+4 -> -1E-398 Subnormal
-dddiv1125 divide 3E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1126 divide -5E-394 1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1127 divide 7E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1128 divide -9E-394 1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1129 divide 9.9E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
-dddiv1130 divide 3.0E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-dddiv1131 divide 1.0E-199 1e+200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-dddiv1132 divide 1.0E-199 1e+199 -> 1E-398 Subnormal Rounded
-dddiv1133 divide 1.0E-199 1e+198 -> 1.0E-397 Subnormal
-dddiv1134 divide 2.0E-199 2e+198 -> 1.0E-397 Subnormal
-dddiv1135 divide 4.0E-199 4e+198 -> 1.0E-397 Subnormal
-dddiv1136 divide 10.0E-199 10e+198 -> 1.0E-397 Subnormal
-dddiv1137 divide 30.0E-199 30e+198 -> 1.0E-397 Subnormal
-
--- randoms
-dddiv2010 divide -3.303226714900711E-35 8.796578842713183E+73 -> -3.755126594058783E-109 Inexact Rounded
-dddiv2011 divide 933153327821073.6 68782181090246.25 -> 13.56678885475763 Inexact Rounded
-dddiv2012 divide 5.04752436057906E-72 -8.179481771238642E+64 -> -6.170958627632835E-137 Inexact Rounded
-dddiv2013 divide -3707613309582318 3394911196503.048 -> -1092.109070010836 Inexact Rounded
-dddiv2014 divide 99689.0555190461 -4.735208553891464 -> -21052.72753765411 Inexact Rounded
-dddiv2015 divide -1447915775613329 269750797.8184875 -> -5367605.164925653 Inexact Rounded
-dddiv2016 divide -9.394881304225258E-19 -830585.0252671636 -> 1.131116143251358E-24 Inexact Rounded
-dddiv2017 divide -1.056283432738934 88.58754555124013 -> -0.01192361100159352 Inexact Rounded
-dddiv2018 divide 5763220933343.081 689089567025052.1 -> 0.008363529516524456 Inexact Rounded
-dddiv2019 divide 873819.122103216 9.740612494523300E-49 -> 8.970884763093948E+53 Inexact Rounded
-dddiv2020 divide 8022914.838533576 6178.566801742713 -> 1298.507420243583 Inexact Rounded
-dddiv2021 divide 203982.7605650363 -2158.283639053435 -> -94.51156320422168 Inexact Rounded
-dddiv2022 divide 803.6310547013030 7101143795399.238 -> 1.131692411611166E-10 Inexact Rounded
-dddiv2023 divide 9.251697842123399E-82 -1.342350220606119E-7 -> -6.892163982321936E-75 Inexact Rounded
-dddiv2024 divide -1.980600645637992E-53 -5.474262753214457E+77 -> 3.618022617703168E-131 Inexact Rounded
-dddiv2025 divide -210.0322996351690 -8.580951835872843E+80 -> 2.447657365434971E-79 Inexact Rounded
-dddiv2026 divide -1.821980314020370E+85 -3.018915267138165 -> 6.035215144503042E+84 Inexact Rounded
-dddiv2027 divide -772264503601.1047 5.158258271408988E-86 -> -1.497141986630614E+97 Inexact Rounded
-dddiv2028 divide -767.0532415847106 2.700027228028939E-59 -> -2.840909282772941E+61 Inexact Rounded
-dddiv2029 divide 496724.8548250093 7.32700588163100E+66 -> 6.779370220929013E-62 Inexact Rounded
-dddiv2030 divide -304232651447703.9 -108.9730808657440 -> 2791814721862.565 Inexact Rounded
-dddiv2031 divide -7.233817192699405E+42 -5711302004.149411 -> 1.266579352211430E+33 Inexact Rounded
-dddiv2032 divide -9.999221444912745E+96 4010569406446197 -> -2.493217404202250E+81 Inexact Rounded
-dddiv2033 divide -1837272.061937622 8.356322838066762 -> -219866.0939196882 Inexact Rounded
-dddiv2034 divide 2168.517555606529 209.1910258615061 -> 10.36620737756784 Inexact Rounded
-dddiv2035 divide -1.884389790576371E+88 2.95181953870583E+20 -> -6.383824505079828E+67 Inexact Rounded
-dddiv2036 divide 732263.6037438196 961222.3634446889 -> 0.7618045850698269 Inexact Rounded
-dddiv2037 divide -813461419.0348336 5.376293753809143E+84 -> -1.513052404285927E-76 Inexact Rounded
-dddiv2038 divide -45562133508108.50 -9.776843494690107E+51 -> 4.660208945029519E-39 Inexact Rounded
-dddiv2039 divide -6.489393172441016E+80 -9101965.097852113 -> 7.129661674897421E+73 Inexact Rounded
-dddiv2040 divide 3.694576237117349E+93 6683512.012622003 -> 5.527896456443912E+86 Inexact Rounded
-dddiv2041 divide -2.252877726403272E+19 -7451913256.181367 -> 3023220546.125531 Inexact Rounded
-dddiv2042 divide 518303.1989111842 50.01587020474133 -> 10362.77479107123 Inexact Rounded
-dddiv2043 divide 2.902087881880103E+24 33.32400992305702 -> 8.708699488989578E+22 Inexact Rounded
-dddiv2044 divide 549619.4559510557 1660824845196338 -> 3.309316196351104E-10 Inexact Rounded
-dddiv2045 divide -6775670774684043 8292152023.077262 -> -817118.4941891062 Inexact Rounded
-dddiv2046 divide -77.50923921524079 -5.636882655425815E+74 -> 1.375037302588405E-73 Inexact Rounded
-dddiv2047 divide -2.984889459605149E-10 -88106156784122.99 -> 3.387833005721384E-24 Inexact Rounded
-dddiv2048 divide 0.949517293997085 44767115.96450998 -> 2.121015110175589E-8 Inexact Rounded
-dddiv2049 divide -2760937211.084521 -1087015876975408 -> 0.000002539923537057024 Inexact Rounded
-dddiv2050 divide 28438351.85030536 -4.209397904088624E-47 -> -6.755919135770688E+53 Inexact Rounded
-dddiv2051 divide -85562731.6820956 -7.166045442530185E+45 -> 1.194002080621542E-38 Inexact Rounded
-dddiv2052 divide 2533802852165.25 7154.119606235955 -> 354173957.3317501 Inexact Rounded
-dddiv2053 divide -8858831346851.474 97.59734208801716 -> -90769186509.83577 Inexact Rounded
-dddiv2054 divide 176783629801387.5 840073263.3109817 -> 210438.3480848206 Inexact Rounded
-dddiv2055 divide -493506471796175.6 79733894790822.03 -> -6.189418854940746 Inexact Rounded
-dddiv2056 divide 790.1682542103445 829.9449370367435 -> 0.9520731062371214 Inexact Rounded
-dddiv2057 divide -8920459838.583164 -4767.889187899214 -> 1870945.294035581 Inexact Rounded
-dddiv2058 divide 53536687164422.1 53137.5007032689 -> 1007512330.385698 Inexact Rounded
-dddiv2059 divide 4.051532311146561E-74 -2.343089768972261E+94 -> -1.729140882606332E-168 Inexact Rounded
-dddiv2060 divide -14847758778636.88 3.062543516383807E-43 -> -4.848178874587497E+55 Inexact Rounded
-
--- Division probably has pre-rounding, so need to test rounding
--- explicitly rather than assume included through other tests;
--- tests include simple rounding and also the tricky cases of sticky
--- bits following two zeros
---
--- 1/99999 gives 0.0000100001000010000100001000010000100001
--- 1234567890123456
---
--- 1/999999 gives 0.000001000001000001000001000001000001000001
--- 1234567890123456
-
-rounding: ceiling
-dddiv3001 divide 1 3 -> 0.3333333333333334 Inexact Rounded
-dddiv3002 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3003 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
-dddiv3004 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
-rounding: floor
-dddiv3011 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3012 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3013 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3014 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: up
-dddiv3021 divide 1 3 -> 0.3333333333333334 Inexact Rounded
-dddiv3022 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3023 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
-dddiv3024 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
-rounding: down
-dddiv3031 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3032 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3033 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3034 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_up
-dddiv3041 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3042 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3043 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3044 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_down
-dddiv3051 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3052 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3053 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3054 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: half_even
-dddiv3061 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3062 divide 2 3 -> 0.6666666666666667 Inexact Rounded
-dddiv3063 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3064 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
-
-rounding: 05up
-dddiv3071 divide 1 3 -> 0.3333333333333333 Inexact Rounded
-dddiv3072 divide 2 3 -> 0.6666666666666666 Inexact Rounded
-dddiv3073 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
-dddiv3074 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
-
--- random divide tests with result near 1
-rounding: half_even
-dddiv4001 divide 3195385192916917 3195385192946695 -> 0.9999999999906809 Inexact Rounded
-dddiv4002 divide 1393723067526993 1393723067519475 -> 1.000000000005394 Inexact Rounded
-dddiv4003 divide 759985543702302 759985543674015 -> 1.000000000037220 Inexact Rounded
-dddiv4004 divide 9579158456027302 9579158456036864 -> 0.9999999999990018 Inexact Rounded
-dddiv4005 divide 7079398299143569 7079398299156904 -> 0.9999999999981164 Inexact Rounded
-dddiv4006 divide 6636169255366598 6636169255336386 -> 1.000000000004553 Inexact Rounded
-dddiv4007 divide 6964813971340090 6964813971321554 -> 1.000000000002661 Inexact Rounded
-dddiv4008 divide 4182275225480784 4182275225454009 -> 1.000000000006402 Inexact Rounded
-dddiv4009 divide 9228325124938029 9228325124918730 -> 1.000000000002091 Inexact Rounded
-dddiv4010 divide 3428346338630192 3428346338609843 -> 1.000000000005936 Inexact Rounded
-dddiv4011 divide 2143511550722893 2143511550751754 -> 0.9999999999865356 Inexact Rounded
-dddiv4012 divide 1672732924396785 1672732924401811 -> 0.9999999999969953 Inexact Rounded
-dddiv4013 divide 4190714611948216 4190714611948664 -> 0.9999999999998931 Inexact Rounded
-dddiv4014 divide 3942254800848877 3942254800814556 -> 1.000000000008706 Inexact Rounded
-dddiv4015 divide 2854459826952334 2854459826960762 -> 0.9999999999970474 Inexact Rounded
-dddiv4016 divide 2853258953664731 2853258953684471 -> 0.9999999999930816 Inexact Rounded
-dddiv4017 divide 9453512638125978 9453512638146425 -> 0.9999999999978371 Inexact Rounded
-dddiv4018 divide 339476633940369 339476633912887 -> 1.000000000080954 Inexact Rounded
-dddiv4019 divide 4542181492688467 4542181492697735 -> 0.9999999999979596 Inexact Rounded
-dddiv4020 divide 7312600192399197 7312600192395424 -> 1.000000000000516 Inexact Rounded
-dddiv4021 divide 1811674985570111 1811674985603935 -> 0.9999999999813300 Inexact Rounded
-dddiv4022 divide 1706462639003481 1706462639017740 -> 0.9999999999916441 Inexact Rounded
-dddiv4023 divide 6697052654940368 6697052654934110 -> 1.000000000000934 Inexact Rounded
-dddiv4024 divide 5015283664277539 5015283664310719 -> 0.9999999999933842 Inexact Rounded
-dddiv4025 divide 2359501561537464 2359501561502464 -> 1.000000000014834 Inexact Rounded
-dddiv4026 divide 2669850227909157 2669850227901548 -> 1.000000000002850 Inexact Rounded
-dddiv4027 divide 9329725546974648 9329725547002445 -> 0.9999999999970206 Inexact Rounded
-dddiv4028 divide 3228562867071248 3228562867106206 -> 0.9999999999891723 Inexact Rounded
-dddiv4029 divide 4862226644921175 4862226644909380 -> 1.000000000002426 Inexact Rounded
-dddiv4030 divide 1022267997054529 1022267997071329 -> 0.9999999999835660 Inexact Rounded
-dddiv4031 divide 1048777482023719 1048777482000948 -> 1.000000000021712 Inexact Rounded
-dddiv4032 divide 9980113777337098 9980113777330539 -> 1.000000000000657 Inexact Rounded
-dddiv4033 divide 7506839167963908 7506839167942901 -> 1.000000000002798 Inexact Rounded
-dddiv4034 divide 231119751977860 231119751962453 -> 1.000000000066662 Inexact Rounded
-dddiv4035 divide 4034903664762962 4034903664795526 -> 0.9999999999919294 Inexact Rounded
-dddiv4036 divide 5700122152274696 5700122152251386 -> 1.000000000004089 Inexact Rounded
-dddiv4037 divide 6869599590293110 6869599590293495 -> 0.9999999999999440 Inexact Rounded
-dddiv4038 divide 5576281960092797 5576281960105579 -> 0.9999999999977078 Inexact Rounded
-dddiv4039 divide 2304844888381318 2304844888353073 -> 1.000000000012255 Inexact Rounded
-dddiv4040 divide 3265933651656452 3265933651682779 -> 0.9999999999919389 Inexact Rounded
-dddiv4041 divide 5235714985079914 5235714985066131 -> 1.000000000002632 Inexact Rounded
-dddiv4042 divide 5578481572827551 5578481572822945 -> 1.000000000000826 Inexact Rounded
-dddiv4043 divide 4909616081396134 4909616081373076 -> 1.000000000004696 Inexact Rounded
-dddiv4044 divide 636447224349537 636447224338757 -> 1.000000000016938 Inexact Rounded
-dddiv4045 divide 1539373428396640 1539373428364727 -> 1.000000000020731 Inexact Rounded
-dddiv4046 divide 2028786707377893 2028786707378866 -> 0.9999999999995204 Inexact Rounded
-dddiv4047 divide 137643260486222 137643260487419 -> 0.9999999999913036 Inexact Rounded
-dddiv4048 divide 247451519746765 247451519752267 -> 0.9999999999777653 Inexact Rounded
-dddiv4049 divide 7877858475022054 7877858474999794 -> 1.000000000002826 Inexact Rounded
-dddiv4050 divide 7333242694766258 7333242694744628 -> 1.000000000002950 Inexact Rounded
-dddiv4051 divide 124051503698592 124051503699397 -> 0.9999999999935108 Inexact Rounded
-dddiv4052 divide 8944737432385188 8944737432406860 -> 0.9999999999975771 Inexact Rounded
-dddiv4053 divide 9883948923406874 9883948923424843 -> 0.9999999999981820 Inexact Rounded
-dddiv4054 divide 6829178741654284 6829178741671973 -> 0.9999999999974098 Inexact Rounded
-dddiv4055 divide 7342752479768122 7342752479793385 -> 0.9999999999965595 Inexact Rounded
-dddiv4056 divide 8066426579008783 8066426578977563 -> 1.000000000003870 Inexact Rounded
-dddiv4057 divide 8992775071383295 8992775071352712 -> 1.000000000003401 Inexact Rounded
-dddiv4058 divide 5485011755545641 5485011755543611 -> 1.000000000000370 Inexact Rounded
-dddiv4059 divide 5779983054353918 5779983054365300 -> 0.9999999999980308 Inexact Rounded
-dddiv4060 divide 9502265102713774 9502265102735208 -> 0.9999999999977443 Inexact Rounded
-dddiv4061 divide 2109558399130981 2109558399116281 -> 1.000000000006968 Inexact Rounded
-dddiv4062 divide 5296182636350471 5296182636351521 -> 0.9999999999998017 Inexact Rounded
-dddiv4063 divide 1440019225591883 1440019225601844 -> 0.9999999999930827 Inexact Rounded
-dddiv4064 divide 8182110791881341 8182110791847174 -> 1.000000000004176 Inexact Rounded
-dddiv4065 divide 489098235512060 489098235534516 -> 0.9999999999540869 Inexact Rounded
-dddiv4066 divide 6475687084782038 6475687084756089 -> 1.000000000004007 Inexact Rounded
-dddiv4067 divide 8094348555736948 8094348555759236 -> 0.9999999999972465 Inexact Rounded
-dddiv4068 divide 1982766816291543 1982766816309463 -> 0.9999999999909621 Inexact Rounded
-dddiv4069 divide 9277314300113251 9277314300084467 -> 1.000000000003103 Inexact Rounded
-dddiv4070 divide 4335532959318934 4335532959293167 -> 1.000000000005943 Inexact Rounded
-dddiv4071 divide 7767113032981348 7767113032968132 -> 1.000000000001702 Inexact Rounded
-dddiv4072 divide 1578548053342868 1578548053370448 -> 0.9999999999825282 Inexact Rounded
-dddiv4073 divide 3790420686666898 3790420686636315 -> 1.000000000008068 Inexact Rounded
-dddiv4074 divide 871682421955147 871682421976441 -> 0.9999999999755714 Inexact Rounded
-dddiv4075 divide 744141054479940 744141054512329 -> 0.9999999999564746 Inexact Rounded
-dddiv4076 divide 8956824183670735 8956824183641741 -> 1.000000000003237 Inexact Rounded
-dddiv4077 divide 8337291694485682 8337291694451193 -> 1.000000000004137 Inexact Rounded
-dddiv4078 divide 4107775944683669 4107775944657097 -> 1.000000000006469 Inexact Rounded
-dddiv4079 divide 8691900057964648 8691900057997555 -> 0.9999999999962141 Inexact Rounded
-dddiv4080 divide 2229528520536462 2229528520502337 -> 1.000000000015306 Inexact Rounded
-dddiv4081 divide 398442083774322 398442083746273 -> 1.000000000070397 Inexact Rounded
-dddiv4082 divide 5319819776808759 5319819776838313 -> 0.9999999999944445 Inexact Rounded
-dddiv4083 divide 7710491299066855 7710491299041858 -> 1.000000000003242 Inexact Rounded
-dddiv4084 divide 9083231296087266 9083231296058160 -> 1.000000000003204 Inexact Rounded
-dddiv4085 divide 3566873574904559 3566873574890328 -> 1.000000000003990 Inexact Rounded
-dddiv4086 divide 596343290550525 596343290555614 -> 0.9999999999914663 Inexact Rounded
-dddiv4087 divide 278227925093192 278227925068104 -> 1.000000000090171 Inexact Rounded
-dddiv4088 divide 3292902958490649 3292902958519881 -> 0.9999999999911227 Inexact Rounded
-dddiv4089 divide 5521871364245881 5521871364229536 -> 1.000000000002960 Inexact Rounded
-dddiv4090 divide 2406505602883617 2406505602857997 -> 1.000000000010646 Inexact Rounded
-dddiv4091 divide 7741146984869208 7741146984867255 -> 1.000000000000252 Inexact Rounded
-dddiv4092 divide 4576041832414909 4576041832405102 -> 1.000000000002143 Inexact Rounded
-dddiv4093 divide 9183756982878057 9183756982901934 -> 0.9999999999974001 Inexact Rounded
-dddiv4094 divide 6215736513855159 6215736513870342 -> 0.9999999999975573 Inexact Rounded
-dddiv4095 divide 248554968534533 248554968551417 -> 0.9999999999320714 Inexact Rounded
-dddiv4096 divide 376314165668645 376314165659755 -> 1.000000000023624 Inexact Rounded
-dddiv4097 divide 5513569249809718 5513569249808906 -> 1.000000000000147 Inexact Rounded
-dddiv4098 divide 3367992242167904 3367992242156228 -> 1.000000000003467 Inexact Rounded
-dddiv4099 divide 6134869538966967 6134869538985986 -> 0.9999999999968999 Inexact Rounded
-
--- Null tests
-dddiv9998 divide 10 # -> NaN Invalid_operation
-dddiv9999 divide # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddDivide.decTest -- decDouble division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+dddiv001 divide 1 1 -> 1
+dddiv002 divide 2 1 -> 2
+dddiv003 divide 1 2 -> 0.5
+dddiv004 divide 2 2 -> 1
+dddiv005 divide 0 1 -> 0
+dddiv006 divide 0 2 -> 0
+dddiv007 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv008 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv009 divide 3 3 -> 1
+
+dddiv010 divide 2.4 1 -> 2.4
+dddiv011 divide 2.4 -1 -> -2.4
+dddiv012 divide -2.4 1 -> -2.4
+dddiv013 divide -2.4 -1 -> 2.4
+dddiv014 divide 2.40 1 -> 2.40
+dddiv015 divide 2.400 1 -> 2.400
+dddiv016 divide 2.4 2 -> 1.2
+dddiv017 divide 2.400 2 -> 1.200
+dddiv018 divide 2. 2 -> 1
+dddiv019 divide 20 20 -> 1
+
+dddiv020 divide 187 187 -> 1
+dddiv021 divide 5 2 -> 2.5
+dddiv022 divide 50 20 -> 2.5
+dddiv023 divide 500 200 -> 2.5
+dddiv024 divide 50.0 20.0 -> 2.5
+dddiv025 divide 5.00 2.00 -> 2.5
+dddiv026 divide 5 2.0 -> 2.5
+dddiv027 divide 5 2.000 -> 2.5
+dddiv028 divide 5 0.20 -> 25
+dddiv029 divide 5 0.200 -> 25
+dddiv030 divide 10 1 -> 10
+dddiv031 divide 100 1 -> 100
+dddiv032 divide 1000 1 -> 1000
+dddiv033 divide 1000 100 -> 10
+
+dddiv035 divide 1 2 -> 0.5
+dddiv036 divide 1 4 -> 0.25
+dddiv037 divide 1 8 -> 0.125
+dddiv038 divide 1 16 -> 0.0625
+dddiv039 divide 1 32 -> 0.03125
+dddiv040 divide 1 64 -> 0.015625
+dddiv041 divide 1 -2 -> -0.5
+dddiv042 divide 1 -4 -> -0.25
+dddiv043 divide 1 -8 -> -0.125
+dddiv044 divide 1 -16 -> -0.0625
+dddiv045 divide 1 -32 -> -0.03125
+dddiv046 divide 1 -64 -> -0.015625
+dddiv047 divide -1 2 -> -0.5
+dddiv048 divide -1 4 -> -0.25
+dddiv049 divide -1 8 -> -0.125
+dddiv050 divide -1 16 -> -0.0625
+dddiv051 divide -1 32 -> -0.03125
+dddiv052 divide -1 64 -> -0.015625
+dddiv053 divide -1 -2 -> 0.5
+dddiv054 divide -1 -4 -> 0.25
+dddiv055 divide -1 -8 -> 0.125
+dddiv056 divide -1 -16 -> 0.0625
+dddiv057 divide -1 -32 -> 0.03125
+dddiv058 divide -1 -64 -> 0.015625
+
+-- bcdTime
+dddiv060 divide 1 7 -> 0.1428571428571429 Inexact Rounded
+dddiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717 Inexact Rounded
+
+-- 1234567890123456
+dddiv071 divide 9999999999999999 1 -> 9999999999999999
+dddiv072 divide 999999999999999 1 -> 999999999999999
+dddiv073 divide 99999999999999 1 -> 99999999999999
+dddiv074 divide 9999999999999 1 -> 9999999999999
+dddiv075 divide 999999999999 1 -> 999999999999
+dddiv076 divide 99999999999 1 -> 99999999999
+dddiv077 divide 9999999999 1 -> 9999999999
+dddiv078 divide 999999999 1 -> 999999999
+dddiv079 divide 99999999 1 -> 99999999
+dddiv080 divide 9999999 1 -> 9999999
+dddiv081 divide 999999 1 -> 999999
+dddiv082 divide 99999 1 -> 99999
+dddiv083 divide 9999 1 -> 9999
+dddiv084 divide 999 1 -> 999
+dddiv085 divide 99 1 -> 99
+dddiv086 divide 9 1 -> 9
+
+dddiv090 divide 0. 1 -> 0
+dddiv091 divide .0 1 -> 0.0
+dddiv092 divide 0.00 1 -> 0.00
+dddiv093 divide 0.00E+9 1 -> 0E+7
+dddiv094 divide 0.0000E-50 1 -> 0E-54
+
+dddiv095 divide 1 1E-8 -> 1E+8
+dddiv096 divide 1 1E-9 -> 1E+9
+dddiv097 divide 1 1E-10 -> 1E+10
+dddiv098 divide 1 1E-11 -> 1E+11
+dddiv099 divide 1 1E-12 -> 1E+12
+
+dddiv100 divide 1 1 -> 1
+dddiv101 divide 1 2 -> 0.5
+dddiv102 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv103 divide 1 4 -> 0.25
+dddiv104 divide 1 5 -> 0.2
+dddiv105 divide 1 6 -> 0.1666666666666667 Inexact Rounded
+dddiv106 divide 1 7 -> 0.1428571428571429 Inexact Rounded
+dddiv107 divide 1 8 -> 0.125
+dddiv108 divide 1 9 -> 0.1111111111111111 Inexact Rounded
+dddiv109 divide 1 10 -> 0.1
+dddiv110 divide 1 1 -> 1
+dddiv111 divide 2 1 -> 2
+dddiv112 divide 3 1 -> 3
+dddiv113 divide 4 1 -> 4
+dddiv114 divide 5 1 -> 5
+dddiv115 divide 6 1 -> 6
+dddiv116 divide 7 1 -> 7
+dddiv117 divide 8 1 -> 8
+dddiv118 divide 9 1 -> 9
+dddiv119 divide 10 1 -> 10
+
+dddiv120 divide 3E+1 0.001 -> 3E+4
+dddiv121 divide 2.200 2 -> 1.100
+
+dddiv130 divide 12345 4.999 -> 2469.493898779756 Inexact Rounded
+dddiv131 divide 12345 4.99 -> 2473.947895791583 Inexact Rounded
+dddiv132 divide 12345 4.9 -> 2519.387755102041 Inexact Rounded
+dddiv133 divide 12345 5 -> 2469
+dddiv134 divide 12345 5.1 -> 2420.588235294118 Inexact Rounded
+dddiv135 divide 12345 5.01 -> 2464.071856287425 Inexact Rounded
+dddiv136 divide 12345 5.001 -> 2468.506298740252 Inexact Rounded
+
+-- test possibly imprecise results
+dddiv220 divide 391 597 -> 0.6549413735343384 Inexact Rounded
+dddiv221 divide 391 -597 -> -0.6549413735343384 Inexact Rounded
+dddiv222 divide -391 597 -> -0.6549413735343384 Inexact Rounded
+dddiv223 divide -391 -597 -> 0.6549413735343384 Inexact Rounded
+
+-- test some cases that are close to exponent overflow, some with coefficient padding
+dddiv270 divide 1 1e384 -> 1E-384 Subnormal
+dddiv271 divide 1 0.9e384 -> 1.11111111111111E-384 Rounded Inexact Subnormal Underflow
+dddiv272 divide 1 0.99e384 -> 1.01010101010101E-384 Rounded Inexact Subnormal Underflow
+dddiv273 divide 1 0.9999999999999999e384 -> 1.00000000000000E-384 Rounded Inexact Subnormal Underflow
+dddiv274 divide 9e384 1 -> 9.000000000000000E+384 Clamped
+dddiv275 divide 9.9e384 1 -> 9.900000000000000E+384 Clamped
+dddiv276 divide 9.99e384 1 -> 9.990000000000000E+384 Clamped
+dddiv277 divide 9.9999999999999e384 1 -> 9.999999999999900E+384 Clamped
+dddiv278 divide 9.99999999999999e384 1 -> 9.999999999999990E+384 Clamped
+dddiv279 divide 9.999999999999999e384 1 -> 9.999999999999999E+384
+
+dddiv285 divide 9.9e384 1.1 -> 9.000000000000000E+384 Clamped
+dddiv286 divide 9.99e384 1.1 -> 9.081818181818182E+384 Inexact Rounded
+dddiv287 divide 9.9999999999999e384 1.1 -> 9.090909090909000E+384 Clamped
+dddiv288 divide 9.99999999999999e384 1.1 -> 9.090909090909082E+384 Inexact Rounded
+dddiv289 divide 9.999999999999999e384 1.1 -> 9.090909090909090E+384 Clamped
+
+
+-- Divide into 0 tests
+dddiv301 divide 0 7 -> 0
+dddiv302 divide 0 7E-5 -> 0E+5
+dddiv303 divide 0 7E-1 -> 0E+1
+dddiv304 divide 0 7E+1 -> 0.0
+dddiv305 divide 0 7E+5 -> 0.00000
+dddiv306 divide 0 7E+6 -> 0.000000
+dddiv307 divide 0 7E+7 -> 0E-7
+dddiv308 divide 0 70E-5 -> 0E+5
+dddiv309 divide 0 70E-1 -> 0E+1
+dddiv310 divide 0 70E+0 -> 0
+dddiv311 divide 0 70E+1 -> 0.0
+dddiv312 divide 0 70E+5 -> 0.00000
+dddiv313 divide 0 70E+6 -> 0.000000
+dddiv314 divide 0 70E+7 -> 0E-7
+dddiv315 divide 0 700E-5 -> 0E+5
+dddiv316 divide 0 700E-1 -> 0E+1
+dddiv317 divide 0 700E+0 -> 0
+dddiv318 divide 0 700E+1 -> 0.0
+dddiv319 divide 0 700E+5 -> 0.00000
+dddiv320 divide 0 700E+6 -> 0.000000
+dddiv321 divide 0 700E+7 -> 0E-7
+dddiv322 divide 0 700E+77 -> 0E-77
+
+dddiv331 divide 0E-3 7E-5 -> 0E+2
+dddiv332 divide 0E-3 7E-1 -> 0.00
+dddiv333 divide 0E-3 7E+1 -> 0.0000
+dddiv334 divide 0E-3 7E+5 -> 0E-8
+dddiv335 divide 0E-1 7E-5 -> 0E+4
+dddiv336 divide 0E-1 7E-1 -> 0
+dddiv337 divide 0E-1 7E+1 -> 0.00
+dddiv338 divide 0E-1 7E+5 -> 0.000000
+dddiv339 divide 0E+1 7E-5 -> 0E+6
+dddiv340 divide 0E+1 7E-1 -> 0E+2
+dddiv341 divide 0E+1 7E+1 -> 0
+dddiv342 divide 0E+1 7E+5 -> 0.0000
+dddiv343 divide 0E+3 7E-5 -> 0E+8
+dddiv344 divide 0E+3 7E-1 -> 0E+4
+dddiv345 divide 0E+3 7E+1 -> 0E+2
+dddiv346 divide 0E+3 7E+5 -> 0.00
+
+-- These were 'input rounding'
+dddiv441 divide 12345678000 1 -> 12345678000
+dddiv442 divide 1 12345678000 -> 8.100000664200054E-11 Inexact Rounded
+dddiv443 divide 1234567800 1 -> 1234567800
+dddiv444 divide 1 1234567800 -> 8.100000664200054E-10 Inexact Rounded
+dddiv445 divide 1234567890 1 -> 1234567890
+dddiv446 divide 1 1234567890 -> 8.100000073710001E-10 Inexact Rounded
+dddiv447 divide 1234567891 1 -> 1234567891
+dddiv448 divide 1 1234567891 -> 8.100000067149001E-10 Inexact Rounded
+dddiv449 divide 12345678901 1 -> 12345678901
+dddiv450 divide 1 12345678901 -> 8.100000073053901E-11 Inexact Rounded
+dddiv451 divide 1234567896 1 -> 1234567896
+dddiv452 divide 1 1234567896 -> 8.100000034344000E-10 Inexact Rounded
+
+-- high-lows
+dddiv453 divide 1e+1 1 -> 1E+1
+dddiv454 divide 1e+1 1.0 -> 1E+1
+dddiv455 divide 1e+1 1.00 -> 1E+1
+dddiv456 divide 1e+2 2 -> 5E+1
+dddiv457 divide 1e+2 2.0 -> 5E+1
+dddiv458 divide 1e+2 2.00 -> 5E+1
+
+-- some from IEEE discussions
+dddiv460 divide 3e0 2e0 -> 1.5
+dddiv461 divide 30e-1 2e0 -> 1.5
+dddiv462 divide 300e-2 2e0 -> 1.50
+dddiv464 divide 3000e-3 2e0 -> 1.500
+dddiv465 divide 3e0 20e-1 -> 1.5
+dddiv466 divide 30e-1 20e-1 -> 1.5
+dddiv467 divide 300e-2 20e-1 -> 1.5
+dddiv468 divide 3000e-3 20e-1 -> 1.50
+dddiv469 divide 3e0 200e-2 -> 1.5
+dddiv470 divide 30e-1 200e-2 -> 1.5
+dddiv471 divide 300e-2 200e-2 -> 1.5
+dddiv472 divide 3000e-3 200e-2 -> 1.5
+dddiv473 divide 3e0 2000e-3 -> 1.5
+dddiv474 divide 30e-1 2000e-3 -> 1.5
+dddiv475 divide 300e-2 2000e-3 -> 1.5
+dddiv476 divide 3000e-3 2000e-3 -> 1.5
+
+-- some reciprocals
+dddiv480 divide 1 1.0E+33 -> 1E-33
+dddiv481 divide 1 10E+33 -> 1E-34
+dddiv482 divide 1 1.0E-33 -> 1E+33
+dddiv483 divide 1 10E-33 -> 1E+32
+
+-- RMS discussion table
+dddiv484 divide 0e5 1e3 -> 0E+2
+dddiv485 divide 0e5 2e3 -> 0E+2
+dddiv486 divide 0e5 10e2 -> 0E+3
+dddiv487 divide 0e5 20e2 -> 0E+3
+dddiv488 divide 0e5 100e1 -> 0E+4
+dddiv489 divide 0e5 200e1 -> 0E+4
+
+dddiv491 divide 1e5 1e3 -> 1E+2
+dddiv492 divide 1e5 2e3 -> 5E+1
+dddiv493 divide 1e5 10e2 -> 1E+2
+dddiv494 divide 1e5 20e2 -> 5E+1
+dddiv495 divide 1e5 100e1 -> 1E+2
+dddiv496 divide 1e5 200e1 -> 5E+1
+
+-- tryzeros cases
+rounding: half_up
+dddiv497 divide 0E+380 1000E-13 -> 0E+369 Clamped
+dddiv498 divide 0E-390 1000E+13 -> 0E-398 Clamped
+
+rounding: half_up
+
+-- focus on trailing zeros issues
+dddiv500 divide 1 9.9 -> 0.1010101010101010 Inexact Rounded
+dddiv501 divide 1 9.09 -> 0.1100110011001100 Inexact Rounded
+dddiv502 divide 1 9.009 -> 0.1110001110001110 Inexact Rounded
+
+dddiv511 divide 1 2 -> 0.5
+dddiv512 divide 1.0 2 -> 0.5
+dddiv513 divide 1.00 2 -> 0.50
+dddiv514 divide 1.000 2 -> 0.500
+dddiv515 divide 1.0000 2 -> 0.5000
+dddiv516 divide 1.00000 2 -> 0.50000
+dddiv517 divide 1.000000 2 -> 0.500000
+dddiv518 divide 1.0000000 2 -> 0.5000000
+dddiv519 divide 1.00 2.00 -> 0.5
+
+dddiv521 divide 2 1 -> 2
+dddiv522 divide 2 1.0 -> 2
+dddiv523 divide 2 1.00 -> 2
+dddiv524 divide 2 1.000 -> 2
+dddiv525 divide 2 1.0000 -> 2
+dddiv526 divide 2 1.00000 -> 2
+dddiv527 divide 2 1.000000 -> 2
+dddiv528 divide 2 1.0000000 -> 2
+dddiv529 divide 2.00 1.00 -> 2
+
+dddiv530 divide 2.40 2 -> 1.20
+dddiv531 divide 2.40 4 -> 0.60
+dddiv532 divide 2.40 10 -> 0.24
+dddiv533 divide 2.40 2.0 -> 1.2
+dddiv534 divide 2.40 4.0 -> 0.6
+dddiv535 divide 2.40 10.0 -> 0.24
+dddiv536 divide 2.40 2.00 -> 1.2
+dddiv537 divide 2.40 4.00 -> 0.6
+dddiv538 divide 2.40 10.00 -> 0.24
+dddiv539 divide 0.9 0.1 -> 9
+dddiv540 divide 0.9 0.01 -> 9E+1
+dddiv541 divide 0.9 0.001 -> 9E+2
+dddiv542 divide 5 2 -> 2.5
+dddiv543 divide 5 2.0 -> 2.5
+dddiv544 divide 5 2.00 -> 2.5
+dddiv545 divide 5 20 -> 0.25
+dddiv546 divide 5 20.0 -> 0.25
+dddiv547 divide 2.400 2 -> 1.200
+dddiv548 divide 2.400 2.0 -> 1.20
+dddiv549 divide 2.400 2.400 -> 1
+
+dddiv550 divide 240 1 -> 240
+dddiv551 divide 240 10 -> 24
+dddiv552 divide 240 100 -> 2.4
+dddiv553 divide 240 1000 -> 0.24
+dddiv554 divide 2400 1 -> 2400
+dddiv555 divide 2400 10 -> 240
+dddiv556 divide 2400 100 -> 24
+dddiv557 divide 2400 1000 -> 2.4
+
+-- +ve exponent
+dddiv600 divide 2.4E+9 2 -> 1.2E+9
+dddiv601 divide 2.40E+9 2 -> 1.20E+9
+dddiv602 divide 2.400E+9 2 -> 1.200E+9
+dddiv603 divide 2.4000E+9 2 -> 1.2000E+9
+dddiv604 divide 24E+8 2 -> 1.2E+9
+dddiv605 divide 240E+7 2 -> 1.20E+9
+dddiv606 divide 2400E+6 2 -> 1.200E+9
+dddiv607 divide 24000E+5 2 -> 1.2000E+9
+
+-- more zeros, etc.
+dddiv731 divide 5.00 1E-3 -> 5.00E+3
+dddiv732 divide 00.00 0.000 -> NaN Division_undefined
+dddiv733 divide 00.00 0E-3 -> NaN Division_undefined
+dddiv734 divide 0 -0 -> NaN Division_undefined
+dddiv735 divide -0 0 -> NaN Division_undefined
+dddiv736 divide -0 -0 -> NaN Division_undefined
+
+dddiv741 divide 0 -1 -> -0
+dddiv742 divide -0 -1 -> 0
+dddiv743 divide 0 1 -> 0
+dddiv744 divide -0 1 -> -0
+dddiv745 divide -1 0 -> -Infinity Division_by_zero
+dddiv746 divide -1 -0 -> Infinity Division_by_zero
+dddiv747 divide 1 0 -> Infinity Division_by_zero
+dddiv748 divide 1 -0 -> -Infinity Division_by_zero
+
+dddiv751 divide 0.0 -1 -> -0.0
+dddiv752 divide -0.0 -1 -> 0.0
+dddiv753 divide 0.0 1 -> 0.0
+dddiv754 divide -0.0 1 -> -0.0
+dddiv755 divide -1.0 0 -> -Infinity Division_by_zero
+dddiv756 divide -1.0 -0 -> Infinity Division_by_zero
+dddiv757 divide 1.0 0 -> Infinity Division_by_zero
+dddiv758 divide 1.0 -0 -> -Infinity Division_by_zero
+
+dddiv761 divide 0 -1.0 -> -0E+1
+dddiv762 divide -0 -1.0 -> 0E+1
+dddiv763 divide 0 1.0 -> 0E+1
+dddiv764 divide -0 1.0 -> -0E+1
+dddiv765 divide -1 0.0 -> -Infinity Division_by_zero
+dddiv766 divide -1 -0.0 -> Infinity Division_by_zero
+dddiv767 divide 1 0.0 -> Infinity Division_by_zero
+dddiv768 divide 1 -0.0 -> -Infinity Division_by_zero
+
+dddiv771 divide 0.0 -1.0 -> -0
+dddiv772 divide -0.0 -1.0 -> 0
+dddiv773 divide 0.0 1.0 -> 0
+dddiv774 divide -0.0 1.0 -> -0
+dddiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
+dddiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
+dddiv777 divide 1.0 0.0 -> Infinity Division_by_zero
+dddiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dddiv780 divide Inf -Inf -> NaN Invalid_operation
+dddiv781 divide Inf -1000 -> -Infinity
+dddiv782 divide Inf -1 -> -Infinity
+dddiv783 divide Inf -0 -> -Infinity
+dddiv784 divide Inf 0 -> Infinity
+dddiv785 divide Inf 1 -> Infinity
+dddiv786 divide Inf 1000 -> Infinity
+dddiv787 divide Inf Inf -> NaN Invalid_operation
+dddiv788 divide -1000 Inf -> -0E-398 Clamped
+dddiv789 divide -Inf Inf -> NaN Invalid_operation
+dddiv790 divide -1 Inf -> -0E-398 Clamped
+dddiv791 divide -0 Inf -> -0E-398 Clamped
+dddiv792 divide 0 Inf -> 0E-398 Clamped
+dddiv793 divide 1 Inf -> 0E-398 Clamped
+dddiv794 divide 1000 Inf -> 0E-398 Clamped
+dddiv795 divide Inf Inf -> NaN Invalid_operation
+
+dddiv800 divide -Inf -Inf -> NaN Invalid_operation
+dddiv801 divide -Inf -1000 -> Infinity
+dddiv802 divide -Inf -1 -> Infinity
+dddiv803 divide -Inf -0 -> Infinity
+dddiv804 divide -Inf 0 -> -Infinity
+dddiv805 divide -Inf 1 -> -Infinity
+dddiv806 divide -Inf 1000 -> -Infinity
+dddiv807 divide -Inf Inf -> NaN Invalid_operation
+dddiv808 divide -1000 Inf -> -0E-398 Clamped
+dddiv809 divide -Inf -Inf -> NaN Invalid_operation
+dddiv810 divide -1 -Inf -> 0E-398 Clamped
+dddiv811 divide -0 -Inf -> 0E-398 Clamped
+dddiv812 divide 0 -Inf -> -0E-398 Clamped
+dddiv813 divide 1 -Inf -> -0E-398 Clamped
+dddiv814 divide 1000 -Inf -> -0E-398 Clamped
+dddiv815 divide Inf -Inf -> NaN Invalid_operation
+
+dddiv821 divide NaN -Inf -> NaN
+dddiv822 divide NaN -1000 -> NaN
+dddiv823 divide NaN -1 -> NaN
+dddiv824 divide NaN -0 -> NaN
+dddiv825 divide NaN 0 -> NaN
+dddiv826 divide NaN 1 -> NaN
+dddiv827 divide NaN 1000 -> NaN
+dddiv828 divide NaN Inf -> NaN
+dddiv829 divide NaN NaN -> NaN
+dddiv830 divide -Inf NaN -> NaN
+dddiv831 divide -1000 NaN -> NaN
+dddiv832 divide -1 NaN -> NaN
+dddiv833 divide -0 NaN -> NaN
+dddiv834 divide 0 NaN -> NaN
+dddiv835 divide 1 NaN -> NaN
+dddiv836 divide 1000 NaN -> NaN
+dddiv837 divide Inf NaN -> NaN
+
+dddiv841 divide sNaN -Inf -> NaN Invalid_operation
+dddiv842 divide sNaN -1000 -> NaN Invalid_operation
+dddiv843 divide sNaN -1 -> NaN Invalid_operation
+dddiv844 divide sNaN -0 -> NaN Invalid_operation
+dddiv845 divide sNaN 0 -> NaN Invalid_operation
+dddiv846 divide sNaN 1 -> NaN Invalid_operation
+dddiv847 divide sNaN 1000 -> NaN Invalid_operation
+dddiv848 divide sNaN NaN -> NaN Invalid_operation
+dddiv849 divide sNaN sNaN -> NaN Invalid_operation
+dddiv850 divide NaN sNaN -> NaN Invalid_operation
+dddiv851 divide -Inf sNaN -> NaN Invalid_operation
+dddiv852 divide -1000 sNaN -> NaN Invalid_operation
+dddiv853 divide -1 sNaN -> NaN Invalid_operation
+dddiv854 divide -0 sNaN -> NaN Invalid_operation
+dddiv855 divide 0 sNaN -> NaN Invalid_operation
+dddiv856 divide 1 sNaN -> NaN Invalid_operation
+dddiv857 divide 1000 sNaN -> NaN Invalid_operation
+dddiv858 divide Inf sNaN -> NaN Invalid_operation
+dddiv859 divide NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dddiv861 divide NaN9 -Inf -> NaN9
+dddiv862 divide NaN8 1000 -> NaN8
+dddiv863 divide NaN7 Inf -> NaN7
+dddiv864 divide NaN6 NaN5 -> NaN6
+dddiv865 divide -Inf NaN4 -> NaN4
+dddiv866 divide -1000 NaN3 -> NaN3
+dddiv867 divide Inf NaN2 -> NaN2
+
+dddiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
+dddiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
+dddiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
+dddiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
+dddiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
+dddiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
+dddiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
+dddiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
+dddiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
+
+dddiv881 divide -NaN9 -Inf -> -NaN9
+dddiv882 divide -NaN8 1000 -> -NaN8
+dddiv883 divide -NaN7 Inf -> -NaN7
+dddiv884 divide -NaN6 -NaN5 -> -NaN6
+dddiv885 divide -Inf -NaN4 -> -NaN4
+dddiv886 divide -1000 -NaN3 -> -NaN3
+dddiv887 divide Inf -NaN2 -> -NaN2
+
+dddiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
+dddiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
+dddiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
+dddiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
+dddiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dddiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
+dddiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
+dddiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
+dddiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- Various flavours of divide by 0
+dddiv901 divide 0 0 -> NaN Division_undefined
+dddiv902 divide 0.0E5 0 -> NaN Division_undefined
+dddiv903 divide 0.000 0 -> NaN Division_undefined
+dddiv904 divide 0.0001 0 -> Infinity Division_by_zero
+dddiv905 divide 0.01 0 -> Infinity Division_by_zero
+dddiv906 divide 0.1 0 -> Infinity Division_by_zero
+dddiv907 divide 1 0 -> Infinity Division_by_zero
+dddiv908 divide 1 0.0 -> Infinity Division_by_zero
+dddiv909 divide 10 0.0 -> Infinity Division_by_zero
+dddiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
+dddiv911 divide 1E+100 0 -> Infinity Division_by_zero
+
+dddiv921 divide -0.0001 0 -> -Infinity Division_by_zero
+dddiv922 divide -0.01 0 -> -Infinity Division_by_zero
+dddiv923 divide -0.1 0 -> -Infinity Division_by_zero
+dddiv924 divide -1 0 -> -Infinity Division_by_zero
+dddiv925 divide -1 0.0 -> -Infinity Division_by_zero
+dddiv926 divide -10 0.0 -> -Infinity Division_by_zero
+dddiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
+dddiv928 divide -1E+100 0 -> -Infinity Division_by_zero
+
+dddiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
+dddiv932 divide 0.01 -0 -> -Infinity Division_by_zero
+dddiv933 divide 0.1 -0 -> -Infinity Division_by_zero
+dddiv934 divide 1 -0 -> -Infinity Division_by_zero
+dddiv935 divide 1 -0.0 -> -Infinity Division_by_zero
+dddiv936 divide 10 -0.0 -> -Infinity Division_by_zero
+dddiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
+dddiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
+
+dddiv941 divide -0.0001 -0 -> Infinity Division_by_zero
+dddiv942 divide -0.01 -0 -> Infinity Division_by_zero
+dddiv943 divide -0.1 -0 -> Infinity Division_by_zero
+dddiv944 divide -1 -0 -> Infinity Division_by_zero
+dddiv945 divide -1 -0.0 -> Infinity Division_by_zero
+dddiv946 divide -10 -0.0 -> Infinity Division_by_zero
+dddiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
+dddiv948 divide -1E+100 -0 -> Infinity Division_by_zero
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dddiv1021 divide 1E0 1E0 -> 1
+dddiv1022 divide 1E0 2E0 -> 0.5
+dddiv1023 divide 1E0 3E0 -> 0.3333333333333333 Inexact Rounded
+dddiv1024 divide 100E-2 1000E-3 -> 1
+dddiv1025 divide 24E-1 2E0 -> 1.2
+dddiv1026 divide 2400E-3 2E0 -> 1.200
+dddiv1027 divide 5E0 2E0 -> 2.5
+dddiv1028 divide 5E0 20E-1 -> 2.5
+dddiv1029 divide 5E0 2000E-3 -> 2.5
+dddiv1030 divide 5E0 2E-1 -> 25
+dddiv1031 divide 5E0 20E-2 -> 25
+dddiv1032 divide 480E-2 3E0 -> 1.60
+dddiv1033 divide 47E-1 2E0 -> 2.35
+
+-- ECMAScript bad examples
+rounding: half_down
+dddiv1040 divide 5 9 -> 0.5555555555555556 Inexact Rounded
+rounding: half_even
+dddiv1041 divide 6 11 -> 0.5454545454545455 Inexact Rounded
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dddiv1051 divide 1e+277 1e-311 -> Infinity Overflow Inexact Rounded
+dddiv1052 divide 1e+277 -1e-311 -> -Infinity Overflow Inexact Rounded
+dddiv1053 divide -1e+277 1e-311 -> -Infinity Overflow Inexact Rounded
+dddiv1054 divide -1e+277 -1e-311 -> Infinity Overflow Inexact Rounded
+dddiv1055 divide 1e-277 1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1056 divide 1e-277 -1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1057 divide -1e-277 1e+311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1058 divide -1e-277 -1e+311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dddiv1060 divide 1e-291 1e+101 -> 1E-392 Subnormal
+dddiv1061 divide 1e-291 1e+102 -> 1E-393 Subnormal
+dddiv1062 divide 1e-291 1e+103 -> 1E-394 Subnormal
+dddiv1063 divide 1e-291 1e+104 -> 1E-395 Subnormal
+dddiv1064 divide 1e-291 1e+105 -> 1E-396 Subnormal
+dddiv1065 divide 1e-291 1e+106 -> 1E-397 Subnormal
+dddiv1066 divide 1e-291 1e+107 -> 1E-398 Subnormal
+dddiv1067 divide 1e-291 1e+108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1068 divide 1e-291 1e+109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1069 divide 1e-291 1e+110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dddiv1070 divide 1e+60 1e-321 -> 1.000000000000E+381 Clamped
+dddiv1071 divide 1e+60 1e-322 -> 1.0000000000000E+382 Clamped
+dddiv1072 divide 1e+60 1e-323 -> 1.00000000000000E+383 Clamped
+dddiv1073 divide 1e+60 1e-324 -> 1.000000000000000E+384 Clamped
+dddiv1074 divide 1e+60 1e-325 -> Infinity Overflow Inexact Rounded
+dddiv1075 divide 1e+60 1e-326 -> Infinity Overflow Inexact Rounded
+dddiv1076 divide 1e+60 1e-327 -> Infinity Overflow Inexact Rounded
+dddiv1077 divide 1e+60 1e-328 -> Infinity Overflow Inexact Rounded
+dddiv1078 divide 1e+60 1e-329 -> Infinity Overflow Inexact Rounded
+dddiv1079 divide 1e+60 1e-330 -> Infinity Overflow Inexact Rounded
+
+dddiv1101 divide 1.0000E-394 1 -> 1.0000E-394 Subnormal
+dddiv1102 divide 1.000E-394 1e+1 -> 1.000E-395 Subnormal
+dddiv1103 divide 1.00E-394 1e+2 -> 1.00E-396 Subnormal
+dddiv1104 divide 1.0E-394 1e+3 -> 1.0E-397 Subnormal
+dddiv1105 divide 1.0E-394 1e+4 -> 1E-398 Subnormal Rounded
+dddiv1106 divide 1.3E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1107 divide 1.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1108 divide 1.7E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1109 divide 2.3E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1110 divide 2.5E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1111 divide 2.7E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
+dddiv1112 divide 1.49E-394 1e+4 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1113 divide 1.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1114 divide 1.51E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1115 divide 2.49E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1116 divide 2.50E-394 1e+4 -> 2E-398 Underflow Subnormal Inexact Rounded
+dddiv1117 divide 2.51E-394 1e+4 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+dddiv1118 divide 1E-394 1e+4 -> 1E-398 Subnormal
+dddiv1119 divide 3E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1120 divide 5E-394 1e+5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1121 divide 7E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1122 divide 9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+dddiv1123 divide 9.9E-394 1e+5 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+dddiv1124 divide 1E-394 -1e+4 -> -1E-398 Subnormal
+dddiv1125 divide 3E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1126 divide -5E-394 1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1127 divide 7E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1128 divide -9E-394 1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1129 divide 9.9E-394 -1e+5 -> -1E-398 Underflow Subnormal Inexact Rounded
+dddiv1130 divide 3.0E-394 -1e+5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+dddiv1131 divide 1.0E-199 1e+200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+dddiv1132 divide 1.0E-199 1e+199 -> 1E-398 Subnormal Rounded
+dddiv1133 divide 1.0E-199 1e+198 -> 1.0E-397 Subnormal
+dddiv1134 divide 2.0E-199 2e+198 -> 1.0E-397 Subnormal
+dddiv1135 divide 4.0E-199 4e+198 -> 1.0E-397 Subnormal
+dddiv1136 divide 10.0E-199 10e+198 -> 1.0E-397 Subnormal
+dddiv1137 divide 30.0E-199 30e+198 -> 1.0E-397 Subnormal
+
+-- randoms
+dddiv2010 divide -3.303226714900711E-35 8.796578842713183E+73 -> -3.755126594058783E-109 Inexact Rounded
+dddiv2011 divide 933153327821073.6 68782181090246.25 -> 13.56678885475763 Inexact Rounded
+dddiv2012 divide 5.04752436057906E-72 -8.179481771238642E+64 -> -6.170958627632835E-137 Inexact Rounded
+dddiv2013 divide -3707613309582318 3394911196503.048 -> -1092.109070010836 Inexact Rounded
+dddiv2014 divide 99689.0555190461 -4.735208553891464 -> -21052.72753765411 Inexact Rounded
+dddiv2015 divide -1447915775613329 269750797.8184875 -> -5367605.164925653 Inexact Rounded
+dddiv2016 divide -9.394881304225258E-19 -830585.0252671636 -> 1.131116143251358E-24 Inexact Rounded
+dddiv2017 divide -1.056283432738934 88.58754555124013 -> -0.01192361100159352 Inexact Rounded
+dddiv2018 divide 5763220933343.081 689089567025052.1 -> 0.008363529516524456 Inexact Rounded
+dddiv2019 divide 873819.122103216 9.740612494523300E-49 -> 8.970884763093948E+53 Inexact Rounded
+dddiv2020 divide 8022914.838533576 6178.566801742713 -> 1298.507420243583 Inexact Rounded
+dddiv2021 divide 203982.7605650363 -2158.283639053435 -> -94.51156320422168 Inexact Rounded
+dddiv2022 divide 803.6310547013030 7101143795399.238 -> 1.131692411611166E-10 Inexact Rounded
+dddiv2023 divide 9.251697842123399E-82 -1.342350220606119E-7 -> -6.892163982321936E-75 Inexact Rounded
+dddiv2024 divide -1.980600645637992E-53 -5.474262753214457E+77 -> 3.618022617703168E-131 Inexact Rounded
+dddiv2025 divide -210.0322996351690 -8.580951835872843E+80 -> 2.447657365434971E-79 Inexact Rounded
+dddiv2026 divide -1.821980314020370E+85 -3.018915267138165 -> 6.035215144503042E+84 Inexact Rounded
+dddiv2027 divide -772264503601.1047 5.158258271408988E-86 -> -1.497141986630614E+97 Inexact Rounded
+dddiv2028 divide -767.0532415847106 2.700027228028939E-59 -> -2.840909282772941E+61 Inexact Rounded
+dddiv2029 divide 496724.8548250093 7.32700588163100E+66 -> 6.779370220929013E-62 Inexact Rounded
+dddiv2030 divide -304232651447703.9 -108.9730808657440 -> 2791814721862.565 Inexact Rounded
+dddiv2031 divide -7.233817192699405E+42 -5711302004.149411 -> 1.266579352211430E+33 Inexact Rounded
+dddiv2032 divide -9.999221444912745E+96 4010569406446197 -> -2.493217404202250E+81 Inexact Rounded
+dddiv2033 divide -1837272.061937622 8.356322838066762 -> -219866.0939196882 Inexact Rounded
+dddiv2034 divide 2168.517555606529 209.1910258615061 -> 10.36620737756784 Inexact Rounded
+dddiv2035 divide -1.884389790576371E+88 2.95181953870583E+20 -> -6.383824505079828E+67 Inexact Rounded
+dddiv2036 divide 732263.6037438196 961222.3634446889 -> 0.7618045850698269 Inexact Rounded
+dddiv2037 divide -813461419.0348336 5.376293753809143E+84 -> -1.513052404285927E-76 Inexact Rounded
+dddiv2038 divide -45562133508108.50 -9.776843494690107E+51 -> 4.660208945029519E-39 Inexact Rounded
+dddiv2039 divide -6.489393172441016E+80 -9101965.097852113 -> 7.129661674897421E+73 Inexact Rounded
+dddiv2040 divide 3.694576237117349E+93 6683512.012622003 -> 5.527896456443912E+86 Inexact Rounded
+dddiv2041 divide -2.252877726403272E+19 -7451913256.181367 -> 3023220546.125531 Inexact Rounded
+dddiv2042 divide 518303.1989111842 50.01587020474133 -> 10362.77479107123 Inexact Rounded
+dddiv2043 divide 2.902087881880103E+24 33.32400992305702 -> 8.708699488989578E+22 Inexact Rounded
+dddiv2044 divide 549619.4559510557 1660824845196338 -> 3.309316196351104E-10 Inexact Rounded
+dddiv2045 divide -6775670774684043 8292152023.077262 -> -817118.4941891062 Inexact Rounded
+dddiv2046 divide -77.50923921524079 -5.636882655425815E+74 -> 1.375037302588405E-73 Inexact Rounded
+dddiv2047 divide -2.984889459605149E-10 -88106156784122.99 -> 3.387833005721384E-24 Inexact Rounded
+dddiv2048 divide 0.949517293997085 44767115.96450998 -> 2.121015110175589E-8 Inexact Rounded
+dddiv2049 divide -2760937211.084521 -1087015876975408 -> 0.000002539923537057024 Inexact Rounded
+dddiv2050 divide 28438351.85030536 -4.209397904088624E-47 -> -6.755919135770688E+53 Inexact Rounded
+dddiv2051 divide -85562731.6820956 -7.166045442530185E+45 -> 1.194002080621542E-38 Inexact Rounded
+dddiv2052 divide 2533802852165.25 7154.119606235955 -> 354173957.3317501 Inexact Rounded
+dddiv2053 divide -8858831346851.474 97.59734208801716 -> -90769186509.83577 Inexact Rounded
+dddiv2054 divide 176783629801387.5 840073263.3109817 -> 210438.3480848206 Inexact Rounded
+dddiv2055 divide -493506471796175.6 79733894790822.03 -> -6.189418854940746 Inexact Rounded
+dddiv2056 divide 790.1682542103445 829.9449370367435 -> 0.9520731062371214 Inexact Rounded
+dddiv2057 divide -8920459838.583164 -4767.889187899214 -> 1870945.294035581 Inexact Rounded
+dddiv2058 divide 53536687164422.1 53137.5007032689 -> 1007512330.385698 Inexact Rounded
+dddiv2059 divide 4.051532311146561E-74 -2.343089768972261E+94 -> -1.729140882606332E-168 Inexact Rounded
+dddiv2060 divide -14847758778636.88 3.062543516383807E-43 -> -4.848178874587497E+55 Inexact Rounded
+
+-- Division probably has pre-rounding, so need to test rounding
+-- explicitly rather than assume included through other tests;
+-- tests include simple rounding and also the tricky cases of sticky
+-- bits following two zeros
+--
+-- 1/99999 gives 0.0000100001000010000100001000010000100001
+-- 1234567890123456
+--
+-- 1/999999 gives 0.000001000001000001000001000001000001000001
+-- 1234567890123456
+
+rounding: ceiling
+dddiv3001 divide 1 3 -> 0.3333333333333334 Inexact Rounded
+dddiv3002 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3003 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
+dddiv3004 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+rounding: floor
+dddiv3011 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3012 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3013 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3014 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: up
+dddiv3021 divide 1 3 -> 0.3333333333333334 Inexact Rounded
+dddiv3022 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3023 divide 1 99999 -> 0.00001000010000100002 Inexact Rounded
+dddiv3024 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+rounding: down
+dddiv3031 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3032 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3033 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3034 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_up
+dddiv3041 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3042 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3043 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3044 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_down
+dddiv3051 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3052 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3053 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3054 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: half_even
+dddiv3061 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3062 divide 2 3 -> 0.6666666666666667 Inexact Rounded
+dddiv3063 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3064 divide 1 999999 -> 0.000001000001000001000 Inexact Rounded
+
+rounding: 05up
+dddiv3071 divide 1 3 -> 0.3333333333333333 Inexact Rounded
+dddiv3072 divide 2 3 -> 0.6666666666666666 Inexact Rounded
+dddiv3073 divide 1 99999 -> 0.00001000010000100001 Inexact Rounded
+dddiv3074 divide 1 999999 -> 0.000001000001000001001 Inexact Rounded
+
+-- random divide tests with result near 1
+rounding: half_even
+dddiv4001 divide 3195385192916917 3195385192946695 -> 0.9999999999906809 Inexact Rounded
+dddiv4002 divide 1393723067526993 1393723067519475 -> 1.000000000005394 Inexact Rounded
+dddiv4003 divide 759985543702302 759985543674015 -> 1.000000000037220 Inexact Rounded
+dddiv4004 divide 9579158456027302 9579158456036864 -> 0.9999999999990018 Inexact Rounded
+dddiv4005 divide 7079398299143569 7079398299156904 -> 0.9999999999981164 Inexact Rounded
+dddiv4006 divide 6636169255366598 6636169255336386 -> 1.000000000004553 Inexact Rounded
+dddiv4007 divide 6964813971340090 6964813971321554 -> 1.000000000002661 Inexact Rounded
+dddiv4008 divide 4182275225480784 4182275225454009 -> 1.000000000006402 Inexact Rounded
+dddiv4009 divide 9228325124938029 9228325124918730 -> 1.000000000002091 Inexact Rounded
+dddiv4010 divide 3428346338630192 3428346338609843 -> 1.000000000005936 Inexact Rounded
+dddiv4011 divide 2143511550722893 2143511550751754 -> 0.9999999999865356 Inexact Rounded
+dddiv4012 divide 1672732924396785 1672732924401811 -> 0.9999999999969953 Inexact Rounded
+dddiv4013 divide 4190714611948216 4190714611948664 -> 0.9999999999998931 Inexact Rounded
+dddiv4014 divide 3942254800848877 3942254800814556 -> 1.000000000008706 Inexact Rounded
+dddiv4015 divide 2854459826952334 2854459826960762 -> 0.9999999999970474 Inexact Rounded
+dddiv4016 divide 2853258953664731 2853258953684471 -> 0.9999999999930816 Inexact Rounded
+dddiv4017 divide 9453512638125978 9453512638146425 -> 0.9999999999978371 Inexact Rounded
+dddiv4018 divide 339476633940369 339476633912887 -> 1.000000000080954 Inexact Rounded
+dddiv4019 divide 4542181492688467 4542181492697735 -> 0.9999999999979596 Inexact Rounded
+dddiv4020 divide 7312600192399197 7312600192395424 -> 1.000000000000516 Inexact Rounded
+dddiv4021 divide 1811674985570111 1811674985603935 -> 0.9999999999813300 Inexact Rounded
+dddiv4022 divide 1706462639003481 1706462639017740 -> 0.9999999999916441 Inexact Rounded
+dddiv4023 divide 6697052654940368 6697052654934110 -> 1.000000000000934 Inexact Rounded
+dddiv4024 divide 5015283664277539 5015283664310719 -> 0.9999999999933842 Inexact Rounded
+dddiv4025 divide 2359501561537464 2359501561502464 -> 1.000000000014834 Inexact Rounded
+dddiv4026 divide 2669850227909157 2669850227901548 -> 1.000000000002850 Inexact Rounded
+dddiv4027 divide 9329725546974648 9329725547002445 -> 0.9999999999970206 Inexact Rounded
+dddiv4028 divide 3228562867071248 3228562867106206 -> 0.9999999999891723 Inexact Rounded
+dddiv4029 divide 4862226644921175 4862226644909380 -> 1.000000000002426 Inexact Rounded
+dddiv4030 divide 1022267997054529 1022267997071329 -> 0.9999999999835660 Inexact Rounded
+dddiv4031 divide 1048777482023719 1048777482000948 -> 1.000000000021712 Inexact Rounded
+dddiv4032 divide 9980113777337098 9980113777330539 -> 1.000000000000657 Inexact Rounded
+dddiv4033 divide 7506839167963908 7506839167942901 -> 1.000000000002798 Inexact Rounded
+dddiv4034 divide 231119751977860 231119751962453 -> 1.000000000066662 Inexact Rounded
+dddiv4035 divide 4034903664762962 4034903664795526 -> 0.9999999999919294 Inexact Rounded
+dddiv4036 divide 5700122152274696 5700122152251386 -> 1.000000000004089 Inexact Rounded
+dddiv4037 divide 6869599590293110 6869599590293495 -> 0.9999999999999440 Inexact Rounded
+dddiv4038 divide 5576281960092797 5576281960105579 -> 0.9999999999977078 Inexact Rounded
+dddiv4039 divide 2304844888381318 2304844888353073 -> 1.000000000012255 Inexact Rounded
+dddiv4040 divide 3265933651656452 3265933651682779 -> 0.9999999999919389 Inexact Rounded
+dddiv4041 divide 5235714985079914 5235714985066131 -> 1.000000000002632 Inexact Rounded
+dddiv4042 divide 5578481572827551 5578481572822945 -> 1.000000000000826 Inexact Rounded
+dddiv4043 divide 4909616081396134 4909616081373076 -> 1.000000000004696 Inexact Rounded
+dddiv4044 divide 636447224349537 636447224338757 -> 1.000000000016938 Inexact Rounded
+dddiv4045 divide 1539373428396640 1539373428364727 -> 1.000000000020731 Inexact Rounded
+dddiv4046 divide 2028786707377893 2028786707378866 -> 0.9999999999995204 Inexact Rounded
+dddiv4047 divide 137643260486222 137643260487419 -> 0.9999999999913036 Inexact Rounded
+dddiv4048 divide 247451519746765 247451519752267 -> 0.9999999999777653 Inexact Rounded
+dddiv4049 divide 7877858475022054 7877858474999794 -> 1.000000000002826 Inexact Rounded
+dddiv4050 divide 7333242694766258 7333242694744628 -> 1.000000000002950 Inexact Rounded
+dddiv4051 divide 124051503698592 124051503699397 -> 0.9999999999935108 Inexact Rounded
+dddiv4052 divide 8944737432385188 8944737432406860 -> 0.9999999999975771 Inexact Rounded
+dddiv4053 divide 9883948923406874 9883948923424843 -> 0.9999999999981820 Inexact Rounded
+dddiv4054 divide 6829178741654284 6829178741671973 -> 0.9999999999974098 Inexact Rounded
+dddiv4055 divide 7342752479768122 7342752479793385 -> 0.9999999999965595 Inexact Rounded
+dddiv4056 divide 8066426579008783 8066426578977563 -> 1.000000000003870 Inexact Rounded
+dddiv4057 divide 8992775071383295 8992775071352712 -> 1.000000000003401 Inexact Rounded
+dddiv4058 divide 5485011755545641 5485011755543611 -> 1.000000000000370 Inexact Rounded
+dddiv4059 divide 5779983054353918 5779983054365300 -> 0.9999999999980308 Inexact Rounded
+dddiv4060 divide 9502265102713774 9502265102735208 -> 0.9999999999977443 Inexact Rounded
+dddiv4061 divide 2109558399130981 2109558399116281 -> 1.000000000006968 Inexact Rounded
+dddiv4062 divide 5296182636350471 5296182636351521 -> 0.9999999999998017 Inexact Rounded
+dddiv4063 divide 1440019225591883 1440019225601844 -> 0.9999999999930827 Inexact Rounded
+dddiv4064 divide 8182110791881341 8182110791847174 -> 1.000000000004176 Inexact Rounded
+dddiv4065 divide 489098235512060 489098235534516 -> 0.9999999999540869 Inexact Rounded
+dddiv4066 divide 6475687084782038 6475687084756089 -> 1.000000000004007 Inexact Rounded
+dddiv4067 divide 8094348555736948 8094348555759236 -> 0.9999999999972465 Inexact Rounded
+dddiv4068 divide 1982766816291543 1982766816309463 -> 0.9999999999909621 Inexact Rounded
+dddiv4069 divide 9277314300113251 9277314300084467 -> 1.000000000003103 Inexact Rounded
+dddiv4070 divide 4335532959318934 4335532959293167 -> 1.000000000005943 Inexact Rounded
+dddiv4071 divide 7767113032981348 7767113032968132 -> 1.000000000001702 Inexact Rounded
+dddiv4072 divide 1578548053342868 1578548053370448 -> 0.9999999999825282 Inexact Rounded
+dddiv4073 divide 3790420686666898 3790420686636315 -> 1.000000000008068 Inexact Rounded
+dddiv4074 divide 871682421955147 871682421976441 -> 0.9999999999755714 Inexact Rounded
+dddiv4075 divide 744141054479940 744141054512329 -> 0.9999999999564746 Inexact Rounded
+dddiv4076 divide 8956824183670735 8956824183641741 -> 1.000000000003237 Inexact Rounded
+dddiv4077 divide 8337291694485682 8337291694451193 -> 1.000000000004137 Inexact Rounded
+dddiv4078 divide 4107775944683669 4107775944657097 -> 1.000000000006469 Inexact Rounded
+dddiv4079 divide 8691900057964648 8691900057997555 -> 0.9999999999962141 Inexact Rounded
+dddiv4080 divide 2229528520536462 2229528520502337 -> 1.000000000015306 Inexact Rounded
+dddiv4081 divide 398442083774322 398442083746273 -> 1.000000000070397 Inexact Rounded
+dddiv4082 divide 5319819776808759 5319819776838313 -> 0.9999999999944445 Inexact Rounded
+dddiv4083 divide 7710491299066855 7710491299041858 -> 1.000000000003242 Inexact Rounded
+dddiv4084 divide 9083231296087266 9083231296058160 -> 1.000000000003204 Inexact Rounded
+dddiv4085 divide 3566873574904559 3566873574890328 -> 1.000000000003990 Inexact Rounded
+dddiv4086 divide 596343290550525 596343290555614 -> 0.9999999999914663 Inexact Rounded
+dddiv4087 divide 278227925093192 278227925068104 -> 1.000000000090171 Inexact Rounded
+dddiv4088 divide 3292902958490649 3292902958519881 -> 0.9999999999911227 Inexact Rounded
+dddiv4089 divide 5521871364245881 5521871364229536 -> 1.000000000002960 Inexact Rounded
+dddiv4090 divide 2406505602883617 2406505602857997 -> 1.000000000010646 Inexact Rounded
+dddiv4091 divide 7741146984869208 7741146984867255 -> 1.000000000000252 Inexact Rounded
+dddiv4092 divide 4576041832414909 4576041832405102 -> 1.000000000002143 Inexact Rounded
+dddiv4093 divide 9183756982878057 9183756982901934 -> 0.9999999999974001 Inexact Rounded
+dddiv4094 divide 6215736513855159 6215736513870342 -> 0.9999999999975573 Inexact Rounded
+dddiv4095 divide 248554968534533 248554968551417 -> 0.9999999999320714 Inexact Rounded
+dddiv4096 divide 376314165668645 376314165659755 -> 1.000000000023624 Inexact Rounded
+dddiv4097 divide 5513569249809718 5513569249808906 -> 1.000000000000147 Inexact Rounded
+dddiv4098 divide 3367992242167904 3367992242156228 -> 1.000000000003467 Inexact Rounded
+dddiv4099 divide 6134869538966967 6134869538985986 -> 0.9999999999968999 Inexact Rounded
+
+-- Null tests
+dddiv9998 divide 10 # -> NaN Invalid_operation
+dddiv9999 divide # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddDivideInt.decTest b/Lib/test/decimaltestdata/ddDivideInt.decTest
index bec567986fd..1555b4217dc 100644
--- a/Lib/test/decimaltestdata/ddDivideInt.decTest
+++ b/Lib/test/decimaltestdata/ddDivideInt.decTest
@@ -1,449 +1,449 @@
-------------------------------------------------------------------------
--- ddDivideInt.decTest -- decDouble integer division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-dddvi001 divideint 1 1 -> 1
-dddvi002 divideint 2 1 -> 2
-dddvi003 divideint 1 2 -> 0
-dddvi004 divideint 2 2 -> 1
-dddvi005 divideint 0 1 -> 0
-dddvi006 divideint 0 2 -> 0
-dddvi007 divideint 1 3 -> 0
-dddvi008 divideint 2 3 -> 0
-dddvi009 divideint 3 3 -> 1
-
-dddvi010 divideint 2.4 1 -> 2
-dddvi011 divideint 2.4 -1 -> -2
-dddvi012 divideint -2.4 1 -> -2
-dddvi013 divideint -2.4 -1 -> 2
-dddvi014 divideint 2.40 1 -> 2
-dddvi015 divideint 2.400 1 -> 2
-dddvi016 divideint 2.4 2 -> 1
-dddvi017 divideint 2.400 2 -> 1
-dddvi018 divideint 2. 2 -> 1
-dddvi019 divideint 20 20 -> 1
-
-dddvi020 divideint 187 187 -> 1
-dddvi021 divideint 5 2 -> 2
-dddvi022 divideint 5 2.0 -> 2
-dddvi023 divideint 5 2.000 -> 2
-dddvi024 divideint 5 0.200 -> 25
-dddvi025 divideint 5 0.200 -> 25
-
-dddvi030 divideint 1 2 -> 0
-dddvi031 divideint 1 4 -> 0
-dddvi032 divideint 1 8 -> 0
-dddvi033 divideint 1 16 -> 0
-dddvi034 divideint 1 32 -> 0
-dddvi035 divideint 1 64 -> 0
-dddvi040 divideint 1 -2 -> -0
-dddvi041 divideint 1 -4 -> -0
-dddvi042 divideint 1 -8 -> -0
-dddvi043 divideint 1 -16 -> -0
-dddvi044 divideint 1 -32 -> -0
-dddvi045 divideint 1 -64 -> -0
-dddvi050 divideint -1 2 -> -0
-dddvi051 divideint -1 4 -> -0
-dddvi052 divideint -1 8 -> -0
-dddvi053 divideint -1 16 -> -0
-dddvi054 divideint -1 32 -> -0
-dddvi055 divideint -1 64 -> -0
-dddvi060 divideint -1 -2 -> 0
-dddvi061 divideint -1 -4 -> 0
-dddvi062 divideint -1 -8 -> 0
-dddvi063 divideint -1 -16 -> 0
-dddvi064 divideint -1 -32 -> 0
-dddvi065 divideint -1 -64 -> 0
-
--- similar with powers of ten
-dddvi160 divideint 1 1 -> 1
-dddvi161 divideint 1 10 -> 0
-dddvi162 divideint 1 100 -> 0
-dddvi163 divideint 1 1000 -> 0
-dddvi164 divideint 1 10000 -> 0
-dddvi165 divideint 1 100000 -> 0
-dddvi166 divideint 1 1000000 -> 0
-dddvi167 divideint 1 10000000 -> 0
-dddvi168 divideint 1 100000000 -> 0
-dddvi170 divideint 1 -1 -> -1
-dddvi171 divideint 1 -10 -> -0
-dddvi172 divideint 1 -100 -> -0
-dddvi173 divideint 1 -1000 -> -0
-dddvi174 divideint 1 -10000 -> -0
-dddvi175 divideint 1 -100000 -> -0
-dddvi176 divideint 1 -1000000 -> -0
-dddvi177 divideint 1 -10000000 -> -0
-dddvi178 divideint 1 -100000000 -> -0
-dddvi180 divideint -1 1 -> -1
-dddvi181 divideint -1 10 -> -0
-dddvi182 divideint -1 100 -> -0
-dddvi183 divideint -1 1000 -> -0
-dddvi184 divideint -1 10000 -> -0
-dddvi185 divideint -1 100000 -> -0
-dddvi186 divideint -1 1000000 -> -0
-dddvi187 divideint -1 10000000 -> -0
-dddvi188 divideint -1 100000000 -> -0
-dddvi190 divideint -1 -1 -> 1
-dddvi191 divideint -1 -10 -> 0
-dddvi192 divideint -1 -100 -> 0
-dddvi193 divideint -1 -1000 -> 0
-dddvi194 divideint -1 -10000 -> 0
-dddvi195 divideint -1 -100000 -> 0
-dddvi196 divideint -1 -1000000 -> 0
-dddvi197 divideint -1 -10000000 -> 0
-dddvi198 divideint -1 -100000000 -> 0
-
--- some long operand (at p=9) cases
-dddvi070 divideint 999999999 1 -> 999999999
-dddvi071 divideint 999999999.4 1 -> 999999999
-dddvi072 divideint 999999999.5 1 -> 999999999
-dddvi073 divideint 999999999.9 1 -> 999999999
-dddvi074 divideint 999999999.999 1 -> 999999999
-
-dddvi090 divideint 0. 1 -> 0
-dddvi091 divideint .0 1 -> 0
-dddvi092 divideint 0.00 1 -> 0
-dddvi093 divideint 0.00E+9 1 -> 0
-dddvi094 divideint 0.0000E-50 1 -> 0
-
-dddvi100 divideint 1 1 -> 1
-dddvi101 divideint 1 2 -> 0
-dddvi102 divideint 1 3 -> 0
-dddvi103 divideint 1 4 -> 0
-dddvi104 divideint 1 5 -> 0
-dddvi105 divideint 1 6 -> 0
-dddvi106 divideint 1 7 -> 0
-dddvi107 divideint 1 8 -> 0
-dddvi108 divideint 1 9 -> 0
-dddvi109 divideint 1 10 -> 0
-dddvi110 divideint 1 1 -> 1
-dddvi111 divideint 2 1 -> 2
-dddvi112 divideint 3 1 -> 3
-dddvi113 divideint 4 1 -> 4
-dddvi114 divideint 5 1 -> 5
-dddvi115 divideint 6 1 -> 6
-dddvi116 divideint 7 1 -> 7
-dddvi117 divideint 8 1 -> 8
-dddvi118 divideint 9 1 -> 9
-dddvi119 divideint 10 1 -> 10
-
--- from DiagBigDecimal
-dddvi131 divideint 101.3 1 -> 101
-dddvi132 divideint 101.0 1 -> 101
-dddvi133 divideint 101.3 3 -> 33
-dddvi134 divideint 101.0 3 -> 33
-dddvi135 divideint 2.4 1 -> 2
-dddvi136 divideint 2.400 1 -> 2
-dddvi137 divideint 18 18 -> 1
-dddvi138 divideint 1120 1000 -> 1
-dddvi139 divideint 2.4 2 -> 1
-dddvi140 divideint 2.400 2 -> 1
-dddvi141 divideint 0.5 2.000 -> 0
-dddvi142 divideint 8.005 7 -> 1
-dddvi143 divideint 5 2 -> 2
-dddvi144 divideint 0 2 -> 0
-dddvi145 divideint 0.00 2 -> 0
-
--- Others
-dddvi150 divideint 12345 4.999 -> 2469
-dddvi151 divideint 12345 4.99 -> 2473
-dddvi152 divideint 12345 4.9 -> 2519
-dddvi153 divideint 12345 5 -> 2469
-dddvi154 divideint 12345 5.1 -> 2420
-dddvi155 divideint 12345 5.01 -> 2464
-dddvi156 divideint 12345 5.001 -> 2468
-dddvi157 divideint 101 7.6 -> 13
-
--- Various flavours of divideint by 0
-dddvi201 divideint 0 0 -> NaN Division_undefined
-dddvi202 divideint 0.0E5 0 -> NaN Division_undefined
-dddvi203 divideint 0.000 0 -> NaN Division_undefined
-dddvi204 divideint 0.0001 0 -> Infinity Division_by_zero
-dddvi205 divideint 0.01 0 -> Infinity Division_by_zero
-dddvi206 divideint 0.1 0 -> Infinity Division_by_zero
-dddvi207 divideint 1 0 -> Infinity Division_by_zero
-dddvi208 divideint 1 0.0 -> Infinity Division_by_zero
-dddvi209 divideint 10 0.0 -> Infinity Division_by_zero
-dddvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
-dddvi211 divideint 1E+380 0 -> Infinity Division_by_zero
-dddvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
-dddvi215 divideint -0.01 0 -> -Infinity Division_by_zero
-dddvi216 divideint -0.1 0 -> -Infinity Division_by_zero
-dddvi217 divideint -1 0 -> -Infinity Division_by_zero
-dddvi218 divideint -1 0.0 -> -Infinity Division_by_zero
-dddvi219 divideint -10 0.0 -> -Infinity Division_by_zero
-dddvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
-dddvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
-
--- test some cases that are close to exponent overflow
-dddvi270 divideint 1 1e384 -> 0
-dddvi271 divideint 1 0.9e384 -> 0
-dddvi272 divideint 1 0.99e384 -> 0
-dddvi273 divideint 1 0.9999999999999999e384 -> 0
-dddvi274 divideint 9e384 1 -> NaN Division_impossible
-dddvi275 divideint 9.9e384 1 -> NaN Division_impossible
-dddvi276 divideint 9.99e384 1 -> NaN Division_impossible
-dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
-
-dddvi280 divideint 0.1 9e-383 -> NaN Division_impossible
-dddvi281 divideint 0.1 99e-383 -> NaN Division_impossible
-dddvi282 divideint 0.1 999e-383 -> NaN Division_impossible
-dddvi283 divideint 0.1 9e-382 -> NaN Division_impossible
-dddvi284 divideint 0.1 99e-382 -> NaN Division_impossible
-
--- GD edge cases: lhs smaller than rhs but more digits
-dddvi301 divideint 0.9 2 -> 0
-dddvi302 divideint 0.9 2.0 -> 0
-dddvi303 divideint 0.9 2.1 -> 0
-dddvi304 divideint 0.9 2.00 -> 0
-dddvi305 divideint 0.9 2.01 -> 0
-dddvi306 divideint 0.12 1 -> 0
-dddvi307 divideint 0.12 1.0 -> 0
-dddvi308 divideint 0.12 1.00 -> 0
-dddvi309 divideint 0.12 1.0 -> 0
-dddvi310 divideint 0.12 1.00 -> 0
-dddvi311 divideint 0.12 2 -> 0
-dddvi312 divideint 0.12 2.0 -> 0
-dddvi313 divideint 0.12 2.1 -> 0
-dddvi314 divideint 0.12 2.00 -> 0
-dddvi315 divideint 0.12 2.01 -> 0
-
--- edge cases of impossible
-dddvi330 divideint 1234567890123456 10 -> 123456789012345
-dddvi331 divideint 1234567890123456 1 -> 1234567890123456
-dddvi332 divideint 1234567890123456 0.1 -> NaN Division_impossible
-dddvi333 divideint 1234567890123456 0.01 -> NaN Division_impossible
-
--- overflow and underflow tests [from divide]
-dddvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
-dddvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
-dddvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
-dddvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
-dddvi1055 divideint 1e-277 1e+311 -> 0
-dddvi1056 divideint 1e-277 -1e+311 -> -0
-dddvi1057 divideint -1e-277 1e+311 -> -0
-dddvi1058 divideint -1e-277 -1e+311 -> 0
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dddvi1060 divideint 1e-291 1e+101 -> 0
-dddvi1061 divideint 1e-291 1e+102 -> 0
-dddvi1062 divideint 1e-291 1e+103 -> 0
-dddvi1063 divideint 1e-291 1e+104 -> 0
-dddvi1064 divideint 1e-291 1e+105 -> 0
-dddvi1065 divideint 1e-291 1e+106 -> 0
-dddvi1066 divideint 1e-291 1e+107 -> 0
-dddvi1067 divideint 1e-291 1e+108 -> 0
-dddvi1068 divideint 1e-291 1e+109 -> 0
-dddvi1069 divideint 1e-291 1e+110 -> 0
-
-dddvi1101 divideint 1.0000E-394 1 -> 0
-dddvi1102 divideint 1.000E-394 1e+1 -> 0
-dddvi1103 divideint 1.00E-394 1e+2 -> 0
-
-dddvi1118 divideint 1E-394 1e+4 -> 0
-dddvi1119 divideint 3E-394 -1e+5 -> -0
-dddvi1120 divideint 5E-394 1e+5 -> 0
-
-dddvi1124 divideint 1E-394 -1e+4 -> -0
-dddvi1130 divideint 3.0E-394 -1e+5 -> -0
-
-dddvi1131 divideint 1.0E-199 1e+200 -> 0
-dddvi1132 divideint 1.0E-199 1e+199 -> 0
-dddvi1133 divideint 1.0E-199 1e+198 -> 0
-dddvi1134 divideint 2.0E-199 2e+198 -> 0
-dddvi1135 divideint 4.0E-199 4e+198 -> 0
-
--- long operand checks
-dddvi401 divideint 12345678000 100 -> 123456780
-dddvi402 divideint 1 12345678000 -> 0
-dddvi403 divideint 1234567800 10 -> 123456780
-dddvi404 divideint 1 1234567800 -> 0
-dddvi405 divideint 1234567890 10 -> 123456789
-dddvi406 divideint 1 1234567890 -> 0
-dddvi407 divideint 1234567891 10 -> 123456789
-dddvi408 divideint 1 1234567891 -> 0
-dddvi409 divideint 12345678901 100 -> 123456789
-dddvi410 divideint 1 12345678901 -> 0
-dddvi411 divideint 1234567896 10 -> 123456789
-dddvi412 divideint 1 1234567896 -> 0
-dddvi413 divideint 12345678948 100 -> 123456789
-dddvi414 divideint 12345678949 100 -> 123456789
-dddvi415 divideint 12345678950 100 -> 123456789
-dddvi416 divideint 12345678951 100 -> 123456789
-dddvi417 divideint 12345678999 100 -> 123456789
-dddvi441 divideint 12345678000 1 -> 12345678000
-dddvi442 divideint 1 12345678000 -> 0
-dddvi443 divideint 1234567800 1 -> 1234567800
-dddvi444 divideint 1 1234567800 -> 0
-dddvi445 divideint 1234567890 1 -> 1234567890
-dddvi446 divideint 1 1234567890 -> 0
-dddvi447 divideint 1234567891 1 -> 1234567891
-dddvi448 divideint 1 1234567891 -> 0
-dddvi449 divideint 12345678901 1 -> 12345678901
-dddvi450 divideint 1 12345678901 -> 0
-dddvi451 divideint 1234567896 1 -> 1234567896
-dddvi452 divideint 1 1234567896 -> 0
-
--- more zeros, etc.
-dddvi531 divideint 5.00 1E-3 -> 5000
-dddvi532 divideint 00.00 0.000 -> NaN Division_undefined
-dddvi533 divideint 00.00 0E-3 -> NaN Division_undefined
-dddvi534 divideint 0 -0 -> NaN Division_undefined
-dddvi535 divideint -0 0 -> NaN Division_undefined
-dddvi536 divideint -0 -0 -> NaN Division_undefined
-
-dddvi541 divideint 0 -1 -> -0
-dddvi542 divideint -0 -1 -> 0
-dddvi543 divideint 0 1 -> 0
-dddvi544 divideint -0 1 -> -0
-dddvi545 divideint -1 0 -> -Infinity Division_by_zero
-dddvi546 divideint -1 -0 -> Infinity Division_by_zero
-dddvi547 divideint 1 0 -> Infinity Division_by_zero
-dddvi548 divideint 1 -0 -> -Infinity Division_by_zero
-
-dddvi551 divideint 0.0 -1 -> -0
-dddvi552 divideint -0.0 -1 -> 0
-dddvi553 divideint 0.0 1 -> 0
-dddvi554 divideint -0.0 1 -> -0
-dddvi555 divideint -1.0 0 -> -Infinity Division_by_zero
-dddvi556 divideint -1.0 -0 -> Infinity Division_by_zero
-dddvi557 divideint 1.0 0 -> Infinity Division_by_zero
-dddvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
-
-dddvi561 divideint 0 -1.0 -> -0
-dddvi562 divideint -0 -1.0 -> 0
-dddvi563 divideint 0 1.0 -> 0
-dddvi564 divideint -0 1.0 -> -0
-dddvi565 divideint -1 0.0 -> -Infinity Division_by_zero
-dddvi566 divideint -1 -0.0 -> Infinity Division_by_zero
-dddvi567 divideint 1 0.0 -> Infinity Division_by_zero
-dddvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
-
-dddvi571 divideint 0.0 -1.0 -> -0
-dddvi572 divideint -0.0 -1.0 -> 0
-dddvi573 divideint 0.0 1.0 -> 0
-dddvi574 divideint -0.0 1.0 -> -0
-dddvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
-dddvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
-dddvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
-dddvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dddvi580 divideint Inf -Inf -> NaN Invalid_operation
-dddvi581 divideint Inf -1000 -> -Infinity
-dddvi582 divideint Inf -1 -> -Infinity
-dddvi583 divideint Inf -0 -> -Infinity
-dddvi584 divideint Inf 0 -> Infinity
-dddvi585 divideint Inf 1 -> Infinity
-dddvi586 divideint Inf 1000 -> Infinity
-dddvi587 divideint Inf Inf -> NaN Invalid_operation
-dddvi588 divideint -1000 Inf -> -0
-dddvi589 divideint -Inf Inf -> NaN Invalid_operation
-dddvi590 divideint -1 Inf -> -0
-dddvi591 divideint -0 Inf -> -0
-dddvi592 divideint 0 Inf -> 0
-dddvi593 divideint 1 Inf -> 0
-dddvi594 divideint 1000 Inf -> 0
-dddvi595 divideint Inf Inf -> NaN Invalid_operation
-
-dddvi600 divideint -Inf -Inf -> NaN Invalid_operation
-dddvi601 divideint -Inf -1000 -> Infinity
-dddvi602 divideint -Inf -1 -> Infinity
-dddvi603 divideint -Inf -0 -> Infinity
-dddvi604 divideint -Inf 0 -> -Infinity
-dddvi605 divideint -Inf 1 -> -Infinity
-dddvi606 divideint -Inf 1000 -> -Infinity
-dddvi607 divideint -Inf Inf -> NaN Invalid_operation
-dddvi608 divideint -1000 Inf -> -0
-dddvi609 divideint -Inf -Inf -> NaN Invalid_operation
-dddvi610 divideint -1 -Inf -> 0
-dddvi611 divideint -0 -Inf -> 0
-dddvi612 divideint 0 -Inf -> -0
-dddvi613 divideint 1 -Inf -> -0
-dddvi614 divideint 1000 -Inf -> -0
-dddvi615 divideint Inf -Inf -> NaN Invalid_operation
-
-dddvi621 divideint NaN -Inf -> NaN
-dddvi622 divideint NaN -1000 -> NaN
-dddvi623 divideint NaN -1 -> NaN
-dddvi624 divideint NaN -0 -> NaN
-dddvi625 divideint NaN 0 -> NaN
-dddvi626 divideint NaN 1 -> NaN
-dddvi627 divideint NaN 1000 -> NaN
-dddvi628 divideint NaN Inf -> NaN
-dddvi629 divideint NaN NaN -> NaN
-dddvi630 divideint -Inf NaN -> NaN
-dddvi631 divideint -1000 NaN -> NaN
-dddvi632 divideint -1 NaN -> NaN
-dddvi633 divideint -0 NaN -> NaN
-dddvi634 divideint 0 NaN -> NaN
-dddvi635 divideint 1 NaN -> NaN
-dddvi636 divideint 1000 NaN -> NaN
-dddvi637 divideint Inf NaN -> NaN
-
-dddvi641 divideint sNaN -Inf -> NaN Invalid_operation
-dddvi642 divideint sNaN -1000 -> NaN Invalid_operation
-dddvi643 divideint sNaN -1 -> NaN Invalid_operation
-dddvi644 divideint sNaN -0 -> NaN Invalid_operation
-dddvi645 divideint sNaN 0 -> NaN Invalid_operation
-dddvi646 divideint sNaN 1 -> NaN Invalid_operation
-dddvi647 divideint sNaN 1000 -> NaN Invalid_operation
-dddvi648 divideint sNaN NaN -> NaN Invalid_operation
-dddvi649 divideint sNaN sNaN -> NaN Invalid_operation
-dddvi650 divideint NaN sNaN -> NaN Invalid_operation
-dddvi651 divideint -Inf sNaN -> NaN Invalid_operation
-dddvi652 divideint -1000 sNaN -> NaN Invalid_operation
-dddvi653 divideint -1 sNaN -> NaN Invalid_operation
-dddvi654 divideint -0 sNaN -> NaN Invalid_operation
-dddvi655 divideint 0 sNaN -> NaN Invalid_operation
-dddvi656 divideint 1 sNaN -> NaN Invalid_operation
-dddvi657 divideint 1000 sNaN -> NaN Invalid_operation
-dddvi658 divideint Inf sNaN -> NaN Invalid_operation
-dddvi659 divideint NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dddvi661 divideint NaN9 -Inf -> NaN9
-dddvi662 divideint NaN8 1000 -> NaN8
-dddvi663 divideint NaN7 Inf -> NaN7
-dddvi664 divideint -NaN6 NaN5 -> -NaN6
-dddvi665 divideint -Inf NaN4 -> NaN4
-dddvi666 divideint -1000 NaN3 -> NaN3
-dddvi667 divideint Inf -NaN2 -> -NaN2
-
-dddvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
-dddvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
-dddvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
-dddvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
-dddvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
-dddvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
-dddvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
-dddvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
-dddvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
-
--- Null tests
-dddvi900 divideint 10 # -> NaN Invalid_operation
-dddvi901 divideint # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddDivideInt.decTest -- decDouble integer division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+dddvi001 divideint 1 1 -> 1
+dddvi002 divideint 2 1 -> 2
+dddvi003 divideint 1 2 -> 0
+dddvi004 divideint 2 2 -> 1
+dddvi005 divideint 0 1 -> 0
+dddvi006 divideint 0 2 -> 0
+dddvi007 divideint 1 3 -> 0
+dddvi008 divideint 2 3 -> 0
+dddvi009 divideint 3 3 -> 1
+
+dddvi010 divideint 2.4 1 -> 2
+dddvi011 divideint 2.4 -1 -> -2
+dddvi012 divideint -2.4 1 -> -2
+dddvi013 divideint -2.4 -1 -> 2
+dddvi014 divideint 2.40 1 -> 2
+dddvi015 divideint 2.400 1 -> 2
+dddvi016 divideint 2.4 2 -> 1
+dddvi017 divideint 2.400 2 -> 1
+dddvi018 divideint 2. 2 -> 1
+dddvi019 divideint 20 20 -> 1
+
+dddvi020 divideint 187 187 -> 1
+dddvi021 divideint 5 2 -> 2
+dddvi022 divideint 5 2.0 -> 2
+dddvi023 divideint 5 2.000 -> 2
+dddvi024 divideint 5 0.200 -> 25
+dddvi025 divideint 5 0.200 -> 25
+
+dddvi030 divideint 1 2 -> 0
+dddvi031 divideint 1 4 -> 0
+dddvi032 divideint 1 8 -> 0
+dddvi033 divideint 1 16 -> 0
+dddvi034 divideint 1 32 -> 0
+dddvi035 divideint 1 64 -> 0
+dddvi040 divideint 1 -2 -> -0
+dddvi041 divideint 1 -4 -> -0
+dddvi042 divideint 1 -8 -> -0
+dddvi043 divideint 1 -16 -> -0
+dddvi044 divideint 1 -32 -> -0
+dddvi045 divideint 1 -64 -> -0
+dddvi050 divideint -1 2 -> -0
+dddvi051 divideint -1 4 -> -0
+dddvi052 divideint -1 8 -> -0
+dddvi053 divideint -1 16 -> -0
+dddvi054 divideint -1 32 -> -0
+dddvi055 divideint -1 64 -> -0
+dddvi060 divideint -1 -2 -> 0
+dddvi061 divideint -1 -4 -> 0
+dddvi062 divideint -1 -8 -> 0
+dddvi063 divideint -1 -16 -> 0
+dddvi064 divideint -1 -32 -> 0
+dddvi065 divideint -1 -64 -> 0
+
+-- similar with powers of ten
+dddvi160 divideint 1 1 -> 1
+dddvi161 divideint 1 10 -> 0
+dddvi162 divideint 1 100 -> 0
+dddvi163 divideint 1 1000 -> 0
+dddvi164 divideint 1 10000 -> 0
+dddvi165 divideint 1 100000 -> 0
+dddvi166 divideint 1 1000000 -> 0
+dddvi167 divideint 1 10000000 -> 0
+dddvi168 divideint 1 100000000 -> 0
+dddvi170 divideint 1 -1 -> -1
+dddvi171 divideint 1 -10 -> -0
+dddvi172 divideint 1 -100 -> -0
+dddvi173 divideint 1 -1000 -> -0
+dddvi174 divideint 1 -10000 -> -0
+dddvi175 divideint 1 -100000 -> -0
+dddvi176 divideint 1 -1000000 -> -0
+dddvi177 divideint 1 -10000000 -> -0
+dddvi178 divideint 1 -100000000 -> -0
+dddvi180 divideint -1 1 -> -1
+dddvi181 divideint -1 10 -> -0
+dddvi182 divideint -1 100 -> -0
+dddvi183 divideint -1 1000 -> -0
+dddvi184 divideint -1 10000 -> -0
+dddvi185 divideint -1 100000 -> -0
+dddvi186 divideint -1 1000000 -> -0
+dddvi187 divideint -1 10000000 -> -0
+dddvi188 divideint -1 100000000 -> -0
+dddvi190 divideint -1 -1 -> 1
+dddvi191 divideint -1 -10 -> 0
+dddvi192 divideint -1 -100 -> 0
+dddvi193 divideint -1 -1000 -> 0
+dddvi194 divideint -1 -10000 -> 0
+dddvi195 divideint -1 -100000 -> 0
+dddvi196 divideint -1 -1000000 -> 0
+dddvi197 divideint -1 -10000000 -> 0
+dddvi198 divideint -1 -100000000 -> 0
+
+-- some long operand (at p=9) cases
+dddvi070 divideint 999999999 1 -> 999999999
+dddvi071 divideint 999999999.4 1 -> 999999999
+dddvi072 divideint 999999999.5 1 -> 999999999
+dddvi073 divideint 999999999.9 1 -> 999999999
+dddvi074 divideint 999999999.999 1 -> 999999999
+
+dddvi090 divideint 0. 1 -> 0
+dddvi091 divideint .0 1 -> 0
+dddvi092 divideint 0.00 1 -> 0
+dddvi093 divideint 0.00E+9 1 -> 0
+dddvi094 divideint 0.0000E-50 1 -> 0
+
+dddvi100 divideint 1 1 -> 1
+dddvi101 divideint 1 2 -> 0
+dddvi102 divideint 1 3 -> 0
+dddvi103 divideint 1 4 -> 0
+dddvi104 divideint 1 5 -> 0
+dddvi105 divideint 1 6 -> 0
+dddvi106 divideint 1 7 -> 0
+dddvi107 divideint 1 8 -> 0
+dddvi108 divideint 1 9 -> 0
+dddvi109 divideint 1 10 -> 0
+dddvi110 divideint 1 1 -> 1
+dddvi111 divideint 2 1 -> 2
+dddvi112 divideint 3 1 -> 3
+dddvi113 divideint 4 1 -> 4
+dddvi114 divideint 5 1 -> 5
+dddvi115 divideint 6 1 -> 6
+dddvi116 divideint 7 1 -> 7
+dddvi117 divideint 8 1 -> 8
+dddvi118 divideint 9 1 -> 9
+dddvi119 divideint 10 1 -> 10
+
+-- from DiagBigDecimal
+dddvi131 divideint 101.3 1 -> 101
+dddvi132 divideint 101.0 1 -> 101
+dddvi133 divideint 101.3 3 -> 33
+dddvi134 divideint 101.0 3 -> 33
+dddvi135 divideint 2.4 1 -> 2
+dddvi136 divideint 2.400 1 -> 2
+dddvi137 divideint 18 18 -> 1
+dddvi138 divideint 1120 1000 -> 1
+dddvi139 divideint 2.4 2 -> 1
+dddvi140 divideint 2.400 2 -> 1
+dddvi141 divideint 0.5 2.000 -> 0
+dddvi142 divideint 8.005 7 -> 1
+dddvi143 divideint 5 2 -> 2
+dddvi144 divideint 0 2 -> 0
+dddvi145 divideint 0.00 2 -> 0
+
+-- Others
+dddvi150 divideint 12345 4.999 -> 2469
+dddvi151 divideint 12345 4.99 -> 2473
+dddvi152 divideint 12345 4.9 -> 2519
+dddvi153 divideint 12345 5 -> 2469
+dddvi154 divideint 12345 5.1 -> 2420
+dddvi155 divideint 12345 5.01 -> 2464
+dddvi156 divideint 12345 5.001 -> 2468
+dddvi157 divideint 101 7.6 -> 13
+
+-- Various flavours of divideint by 0
+dddvi201 divideint 0 0 -> NaN Division_undefined
+dddvi202 divideint 0.0E5 0 -> NaN Division_undefined
+dddvi203 divideint 0.000 0 -> NaN Division_undefined
+dddvi204 divideint 0.0001 0 -> Infinity Division_by_zero
+dddvi205 divideint 0.01 0 -> Infinity Division_by_zero
+dddvi206 divideint 0.1 0 -> Infinity Division_by_zero
+dddvi207 divideint 1 0 -> Infinity Division_by_zero
+dddvi208 divideint 1 0.0 -> Infinity Division_by_zero
+dddvi209 divideint 10 0.0 -> Infinity Division_by_zero
+dddvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
+dddvi211 divideint 1E+380 0 -> Infinity Division_by_zero
+dddvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
+dddvi215 divideint -0.01 0 -> -Infinity Division_by_zero
+dddvi216 divideint -0.1 0 -> -Infinity Division_by_zero
+dddvi217 divideint -1 0 -> -Infinity Division_by_zero
+dddvi218 divideint -1 0.0 -> -Infinity Division_by_zero
+dddvi219 divideint -10 0.0 -> -Infinity Division_by_zero
+dddvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
+dddvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
+
+-- test some cases that are close to exponent overflow
+dddvi270 divideint 1 1e384 -> 0
+dddvi271 divideint 1 0.9e384 -> 0
+dddvi272 divideint 1 0.99e384 -> 0
+dddvi273 divideint 1 0.9999999999999999e384 -> 0
+dddvi274 divideint 9e384 1 -> NaN Division_impossible
+dddvi275 divideint 9.9e384 1 -> NaN Division_impossible
+dddvi276 divideint 9.99e384 1 -> NaN Division_impossible
+dddvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
+
+dddvi280 divideint 0.1 9e-383 -> NaN Division_impossible
+dddvi281 divideint 0.1 99e-383 -> NaN Division_impossible
+dddvi282 divideint 0.1 999e-383 -> NaN Division_impossible
+dddvi283 divideint 0.1 9e-382 -> NaN Division_impossible
+dddvi284 divideint 0.1 99e-382 -> NaN Division_impossible
+
+-- GD edge cases: lhs smaller than rhs but more digits
+dddvi301 divideint 0.9 2 -> 0
+dddvi302 divideint 0.9 2.0 -> 0
+dddvi303 divideint 0.9 2.1 -> 0
+dddvi304 divideint 0.9 2.00 -> 0
+dddvi305 divideint 0.9 2.01 -> 0
+dddvi306 divideint 0.12 1 -> 0
+dddvi307 divideint 0.12 1.0 -> 0
+dddvi308 divideint 0.12 1.00 -> 0
+dddvi309 divideint 0.12 1.0 -> 0
+dddvi310 divideint 0.12 1.00 -> 0
+dddvi311 divideint 0.12 2 -> 0
+dddvi312 divideint 0.12 2.0 -> 0
+dddvi313 divideint 0.12 2.1 -> 0
+dddvi314 divideint 0.12 2.00 -> 0
+dddvi315 divideint 0.12 2.01 -> 0
+
+-- edge cases of impossible
+dddvi330 divideint 1234567890123456 10 -> 123456789012345
+dddvi331 divideint 1234567890123456 1 -> 1234567890123456
+dddvi332 divideint 1234567890123456 0.1 -> NaN Division_impossible
+dddvi333 divideint 1234567890123456 0.01 -> NaN Division_impossible
+
+-- overflow and underflow tests [from divide]
+dddvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
+dddvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
+dddvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
+dddvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
+dddvi1055 divideint 1e-277 1e+311 -> 0
+dddvi1056 divideint 1e-277 -1e+311 -> -0
+dddvi1057 divideint -1e-277 1e+311 -> -0
+dddvi1058 divideint -1e-277 -1e+311 -> 0
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dddvi1060 divideint 1e-291 1e+101 -> 0
+dddvi1061 divideint 1e-291 1e+102 -> 0
+dddvi1062 divideint 1e-291 1e+103 -> 0
+dddvi1063 divideint 1e-291 1e+104 -> 0
+dddvi1064 divideint 1e-291 1e+105 -> 0
+dddvi1065 divideint 1e-291 1e+106 -> 0
+dddvi1066 divideint 1e-291 1e+107 -> 0
+dddvi1067 divideint 1e-291 1e+108 -> 0
+dddvi1068 divideint 1e-291 1e+109 -> 0
+dddvi1069 divideint 1e-291 1e+110 -> 0
+
+dddvi1101 divideint 1.0000E-394 1 -> 0
+dddvi1102 divideint 1.000E-394 1e+1 -> 0
+dddvi1103 divideint 1.00E-394 1e+2 -> 0
+
+dddvi1118 divideint 1E-394 1e+4 -> 0
+dddvi1119 divideint 3E-394 -1e+5 -> -0
+dddvi1120 divideint 5E-394 1e+5 -> 0
+
+dddvi1124 divideint 1E-394 -1e+4 -> -0
+dddvi1130 divideint 3.0E-394 -1e+5 -> -0
+
+dddvi1131 divideint 1.0E-199 1e+200 -> 0
+dddvi1132 divideint 1.0E-199 1e+199 -> 0
+dddvi1133 divideint 1.0E-199 1e+198 -> 0
+dddvi1134 divideint 2.0E-199 2e+198 -> 0
+dddvi1135 divideint 4.0E-199 4e+198 -> 0
+
+-- long operand checks
+dddvi401 divideint 12345678000 100 -> 123456780
+dddvi402 divideint 1 12345678000 -> 0
+dddvi403 divideint 1234567800 10 -> 123456780
+dddvi404 divideint 1 1234567800 -> 0
+dddvi405 divideint 1234567890 10 -> 123456789
+dddvi406 divideint 1 1234567890 -> 0
+dddvi407 divideint 1234567891 10 -> 123456789
+dddvi408 divideint 1 1234567891 -> 0
+dddvi409 divideint 12345678901 100 -> 123456789
+dddvi410 divideint 1 12345678901 -> 0
+dddvi411 divideint 1234567896 10 -> 123456789
+dddvi412 divideint 1 1234567896 -> 0
+dddvi413 divideint 12345678948 100 -> 123456789
+dddvi414 divideint 12345678949 100 -> 123456789
+dddvi415 divideint 12345678950 100 -> 123456789
+dddvi416 divideint 12345678951 100 -> 123456789
+dddvi417 divideint 12345678999 100 -> 123456789
+dddvi441 divideint 12345678000 1 -> 12345678000
+dddvi442 divideint 1 12345678000 -> 0
+dddvi443 divideint 1234567800 1 -> 1234567800
+dddvi444 divideint 1 1234567800 -> 0
+dddvi445 divideint 1234567890 1 -> 1234567890
+dddvi446 divideint 1 1234567890 -> 0
+dddvi447 divideint 1234567891 1 -> 1234567891
+dddvi448 divideint 1 1234567891 -> 0
+dddvi449 divideint 12345678901 1 -> 12345678901
+dddvi450 divideint 1 12345678901 -> 0
+dddvi451 divideint 1234567896 1 -> 1234567896
+dddvi452 divideint 1 1234567896 -> 0
+
+-- more zeros, etc.
+dddvi531 divideint 5.00 1E-3 -> 5000
+dddvi532 divideint 00.00 0.000 -> NaN Division_undefined
+dddvi533 divideint 00.00 0E-3 -> NaN Division_undefined
+dddvi534 divideint 0 -0 -> NaN Division_undefined
+dddvi535 divideint -0 0 -> NaN Division_undefined
+dddvi536 divideint -0 -0 -> NaN Division_undefined
+
+dddvi541 divideint 0 -1 -> -0
+dddvi542 divideint -0 -1 -> 0
+dddvi543 divideint 0 1 -> 0
+dddvi544 divideint -0 1 -> -0
+dddvi545 divideint -1 0 -> -Infinity Division_by_zero
+dddvi546 divideint -1 -0 -> Infinity Division_by_zero
+dddvi547 divideint 1 0 -> Infinity Division_by_zero
+dddvi548 divideint 1 -0 -> -Infinity Division_by_zero
+
+dddvi551 divideint 0.0 -1 -> -0
+dddvi552 divideint -0.0 -1 -> 0
+dddvi553 divideint 0.0 1 -> 0
+dddvi554 divideint -0.0 1 -> -0
+dddvi555 divideint -1.0 0 -> -Infinity Division_by_zero
+dddvi556 divideint -1.0 -0 -> Infinity Division_by_zero
+dddvi557 divideint 1.0 0 -> Infinity Division_by_zero
+dddvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
+
+dddvi561 divideint 0 -1.0 -> -0
+dddvi562 divideint -0 -1.0 -> 0
+dddvi563 divideint 0 1.0 -> 0
+dddvi564 divideint -0 1.0 -> -0
+dddvi565 divideint -1 0.0 -> -Infinity Division_by_zero
+dddvi566 divideint -1 -0.0 -> Infinity Division_by_zero
+dddvi567 divideint 1 0.0 -> Infinity Division_by_zero
+dddvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
+
+dddvi571 divideint 0.0 -1.0 -> -0
+dddvi572 divideint -0.0 -1.0 -> 0
+dddvi573 divideint 0.0 1.0 -> 0
+dddvi574 divideint -0.0 1.0 -> -0
+dddvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
+dddvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
+dddvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
+dddvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dddvi580 divideint Inf -Inf -> NaN Invalid_operation
+dddvi581 divideint Inf -1000 -> -Infinity
+dddvi582 divideint Inf -1 -> -Infinity
+dddvi583 divideint Inf -0 -> -Infinity
+dddvi584 divideint Inf 0 -> Infinity
+dddvi585 divideint Inf 1 -> Infinity
+dddvi586 divideint Inf 1000 -> Infinity
+dddvi587 divideint Inf Inf -> NaN Invalid_operation
+dddvi588 divideint -1000 Inf -> -0
+dddvi589 divideint -Inf Inf -> NaN Invalid_operation
+dddvi590 divideint -1 Inf -> -0
+dddvi591 divideint -0 Inf -> -0
+dddvi592 divideint 0 Inf -> 0
+dddvi593 divideint 1 Inf -> 0
+dddvi594 divideint 1000 Inf -> 0
+dddvi595 divideint Inf Inf -> NaN Invalid_operation
+
+dddvi600 divideint -Inf -Inf -> NaN Invalid_operation
+dddvi601 divideint -Inf -1000 -> Infinity
+dddvi602 divideint -Inf -1 -> Infinity
+dddvi603 divideint -Inf -0 -> Infinity
+dddvi604 divideint -Inf 0 -> -Infinity
+dddvi605 divideint -Inf 1 -> -Infinity
+dddvi606 divideint -Inf 1000 -> -Infinity
+dddvi607 divideint -Inf Inf -> NaN Invalid_operation
+dddvi608 divideint -1000 Inf -> -0
+dddvi609 divideint -Inf -Inf -> NaN Invalid_operation
+dddvi610 divideint -1 -Inf -> 0
+dddvi611 divideint -0 -Inf -> 0
+dddvi612 divideint 0 -Inf -> -0
+dddvi613 divideint 1 -Inf -> -0
+dddvi614 divideint 1000 -Inf -> -0
+dddvi615 divideint Inf -Inf -> NaN Invalid_operation
+
+dddvi621 divideint NaN -Inf -> NaN
+dddvi622 divideint NaN -1000 -> NaN
+dddvi623 divideint NaN -1 -> NaN
+dddvi624 divideint NaN -0 -> NaN
+dddvi625 divideint NaN 0 -> NaN
+dddvi626 divideint NaN 1 -> NaN
+dddvi627 divideint NaN 1000 -> NaN
+dddvi628 divideint NaN Inf -> NaN
+dddvi629 divideint NaN NaN -> NaN
+dddvi630 divideint -Inf NaN -> NaN
+dddvi631 divideint -1000 NaN -> NaN
+dddvi632 divideint -1 NaN -> NaN
+dddvi633 divideint -0 NaN -> NaN
+dddvi634 divideint 0 NaN -> NaN
+dddvi635 divideint 1 NaN -> NaN
+dddvi636 divideint 1000 NaN -> NaN
+dddvi637 divideint Inf NaN -> NaN
+
+dddvi641 divideint sNaN -Inf -> NaN Invalid_operation
+dddvi642 divideint sNaN -1000 -> NaN Invalid_operation
+dddvi643 divideint sNaN -1 -> NaN Invalid_operation
+dddvi644 divideint sNaN -0 -> NaN Invalid_operation
+dddvi645 divideint sNaN 0 -> NaN Invalid_operation
+dddvi646 divideint sNaN 1 -> NaN Invalid_operation
+dddvi647 divideint sNaN 1000 -> NaN Invalid_operation
+dddvi648 divideint sNaN NaN -> NaN Invalid_operation
+dddvi649 divideint sNaN sNaN -> NaN Invalid_operation
+dddvi650 divideint NaN sNaN -> NaN Invalid_operation
+dddvi651 divideint -Inf sNaN -> NaN Invalid_operation
+dddvi652 divideint -1000 sNaN -> NaN Invalid_operation
+dddvi653 divideint -1 sNaN -> NaN Invalid_operation
+dddvi654 divideint -0 sNaN -> NaN Invalid_operation
+dddvi655 divideint 0 sNaN -> NaN Invalid_operation
+dddvi656 divideint 1 sNaN -> NaN Invalid_operation
+dddvi657 divideint 1000 sNaN -> NaN Invalid_operation
+dddvi658 divideint Inf sNaN -> NaN Invalid_operation
+dddvi659 divideint NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dddvi661 divideint NaN9 -Inf -> NaN9
+dddvi662 divideint NaN8 1000 -> NaN8
+dddvi663 divideint NaN7 Inf -> NaN7
+dddvi664 divideint -NaN6 NaN5 -> -NaN6
+dddvi665 divideint -Inf NaN4 -> NaN4
+dddvi666 divideint -1000 NaN3 -> NaN3
+dddvi667 divideint Inf -NaN2 -> -NaN2
+
+dddvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
+dddvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
+dddvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
+dddvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
+dddvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
+dddvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
+dddvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
+dddvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
+dddvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
+
+-- Null tests
+dddvi900 divideint 10 # -> NaN Invalid_operation
+dddvi901 divideint # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddEncode.decTest b/Lib/test/decimaltestdata/ddEncode.decTest
index de9d31c0a6a..e91ec6143c2 100644
--- a/Lib/test/decimaltestdata/ddEncode.decTest
+++ b/Lib/test/decimaltestdata/ddEncode.decTest
@@ -1,495 +1,495 @@
-------------------------------------------------------------------------
--- ddEncode.decTest -- decimal eight-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal64.decTest]
-version: 2.59
-
--- This set of tests is for the eight-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 8 bits exponent continuation
--- 50 bits coefficient continuation
---
--- Total exponent length 10 bits
--- Total coefficient length 54 bits (16 digits)
---
--- Elimit = 767 (maximum encoded exponent)
--- Emax = 384 (largest exponent value)
--- Emin = -383 (smallest exponent value)
--- bias = 398 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-dece001 apply #A2300000000003D0 -> -7.50
-dece002 apply -7.50 -> #A2300000000003D0
--- derivative canonical plain strings
-dece003 apply #A23c0000000003D0 -> -7.50E+3
-dece004 apply -7.50E+3 -> #A23c0000000003D0
-dece005 apply #A2380000000003D0 -> -750
-dece006 apply -750 -> #A2380000000003D0
-dece007 apply #A2340000000003D0 -> -75.0
-dece008 apply -75.0 -> #A2340000000003D0
-dece009 apply #A22c0000000003D0 -> -0.750
-dece010 apply -0.750 -> #A22c0000000003D0
-dece011 apply #A2280000000003D0 -> -0.0750
-dece012 apply -0.0750 -> #A2280000000003D0
-dece013 apply #A2200000000003D0 -> -0.000750
-dece014 apply -0.000750 -> #A2200000000003D0
-dece015 apply #A2180000000003D0 -> -0.00000750
-dece016 apply -0.00000750 -> #A2180000000003D0
-dece017 apply #A2140000000003D0 -> -7.50E-7
-dece018 apply -7.50E-7 -> #A2140000000003D0
-
--- Normality
-dece020 apply 1234567890123456 -> #263934b9c1e28e56
-dece021 apply -1234567890123456 -> #a63934b9c1e28e56
-dece022 apply 1234.567890123456 -> #260934b9c1e28e56
-dece023 apply #260934b9c1e28e56 -> 1234.567890123456
-dece024 apply 1111111111111111 -> #2638912449124491
-dece025 apply 9999999999999999 -> #6e38ff3fcff3fcff
-
--- Nmax and similar
-dece031 apply 9999999999999999E+369 -> #77fcff3fcff3fcff
-dece032 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
-dece033 apply #77fcff3fcff3fcff -> 9.999999999999999E+384
-dece034 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56
-dece035 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384
--- fold-downs (more below)
-dece036 apply 1.23E+384 -> #47fd300000000000 Clamped
-dece037 apply #47fd300000000000 -> 1.230000000000000E+384
-decd038 apply 1E+384 -> #47fc000000000000 Clamped
-decd039 apply #47fc000000000000 -> 1.000000000000000E+384
-
-decd051 apply 12345 -> #22380000000049c5
-decd052 apply #22380000000049c5 -> 12345
-decd053 apply 1234 -> #2238000000000534
-decd054 apply #2238000000000534 -> 1234
-decd055 apply 123 -> #22380000000000a3
-decd056 apply #22380000000000a3 -> 123
-decd057 apply 12 -> #2238000000000012
-decd058 apply #2238000000000012 -> 12
-decd059 apply 1 -> #2238000000000001
-decd060 apply #2238000000000001 -> 1
-decd061 apply 1.23 -> #22300000000000a3
-decd062 apply #22300000000000a3 -> 1.23
-decd063 apply 123.45 -> #22300000000049c5
-decd064 apply #22300000000049c5 -> 123.45
-
--- Nmin and below
-decd071 apply 1E-383 -> #003c000000000001
-decd072 apply #003c000000000001 -> 1E-383
-decd073 apply 1.000000000000000E-383 -> #0400000000000000
-decd074 apply #0400000000000000 -> 1.000000000000000E-383
-decd075 apply 1.000000000000001E-383 -> #0400000000000001
-decd076 apply #0400000000000001 -> 1.000000000000001E-383
-
-decd077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal
-decd078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal
-decd079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal
-decd080 apply #0000000000000010 -> 1.0E-397 Subnormal
-decd081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal
-decd082 apply #0004000000000001 -> 1E-397 Subnormal
-decd083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal
-decd084 apply #0000000000000001 -> 1E-398 Subnormal
--- next is smallest all-nines
-decd085 apply 9999999999999999E-398 -> #6400ff3fcff3fcff
-decd086 apply #6400ff3fcff3fcff -> 9.999999999999999E-383
--- and a problematic divide result
-decd088 apply 1.111111111111111E-383 -> #0400912449124491
-decd089 apply #0400912449124491 -> 1.111111111111111E-383
-
--- forties
-decd090 apply 40 -> #2238000000000040
-decd091 apply 39.99 -> #2230000000000cff
-
--- underflows cannot be tested as all LHS exact
-
--- Same again, negatives
--- Nmax and similar
-decd122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff
-decd123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384
-decd124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56
-decd125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384
--- fold-downs (more below)
-decd130 apply -1.23E+384 -> #c7fd300000000000 Clamped
-decd131 apply #c7fd300000000000 -> -1.230000000000000E+384
-decd132 apply -1E+384 -> #c7fc000000000000 Clamped
-decd133 apply #c7fc000000000000 -> -1.000000000000000E+384
-
--- overflows
-decd151 apply -12345 -> #a2380000000049c5
-decd152 apply #a2380000000049c5 -> -12345
-decd153 apply -1234 -> #a238000000000534
-decd154 apply #a238000000000534 -> -1234
-decd155 apply -123 -> #a2380000000000a3
-decd156 apply #a2380000000000a3 -> -123
-decd157 apply -12 -> #a238000000000012
-decd158 apply #a238000000000012 -> -12
-decd159 apply -1 -> #a238000000000001
-decd160 apply #a238000000000001 -> -1
-decd161 apply -1.23 -> #a2300000000000a3
-decd162 apply #a2300000000000a3 -> -1.23
-decd163 apply -123.45 -> #a2300000000049c5
-decd164 apply #a2300000000049c5 -> -123.45
-
--- Nmin and below
-decd171 apply -1E-383 -> #803c000000000001
-decd172 apply #803c000000000001 -> -1E-383
-decd173 apply -1.000000000000000E-383 -> #8400000000000000
-decd174 apply #8400000000000000 -> -1.000000000000000E-383
-decd175 apply -1.000000000000001E-383 -> #8400000000000001
-decd176 apply #8400000000000001 -> -1.000000000000001E-383
-
-decd177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal
-decd178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal
-decd179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal
-decd180 apply #8000000000000010 -> -1.0E-397 Subnormal
-decd181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal
-decd182 apply #8004000000000001 -> -1E-397 Subnormal
-decd183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal
-decd184 apply #8000000000000001 -> -1E-398 Subnormal
--- next is smallest all-nines
-decd185 apply -9999999999999999E-398 -> #e400ff3fcff3fcff
-decd186 apply #e400ff3fcff3fcff -> -9.999999999999999E-383
--- and a tricky subnormal
-decd187 apply 1.11111111111524E-384 -> #00009124491246a4 Subnormal
-decd188 apply #00009124491246a4 -> 1.11111111111524E-384 Subnormal
-
--- near-underflows
-decd189 apply -1e-398 -> #8000000000000001 Subnormal
-decd190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
-
--- zeros
-decd401 apply 0E-500 -> #0000000000000000 Clamped
-decd402 apply 0E-400 -> #0000000000000000 Clamped
-decd403 apply 0E-398 -> #0000000000000000
-decd404 apply #0000000000000000 -> 0E-398
-decd405 apply 0.000000000000000E-383 -> #0000000000000000
-decd406 apply #0000000000000000 -> 0E-398
-decd407 apply 0E-2 -> #2230000000000000
-decd408 apply #2230000000000000 -> 0.00
-decd409 apply 0 -> #2238000000000000
-decd410 apply #2238000000000000 -> 0
-decd411 apply 0E+3 -> #2244000000000000
-decd412 apply #2244000000000000 -> 0E+3
-decd413 apply 0E+369 -> #43fc000000000000
-decd414 apply #43fc000000000000 -> 0E+369
--- clamped zeros...
-decd415 apply 0E+370 -> #43fc000000000000 Clamped
-decd416 apply #43fc000000000000 -> 0E+369
-decd417 apply 0E+384 -> #43fc000000000000 Clamped
-decd418 apply #43fc000000000000 -> 0E+369
-decd419 apply 0E+400 -> #43fc000000000000 Clamped
-decd420 apply #43fc000000000000 -> 0E+369
-decd421 apply 0E+500 -> #43fc000000000000 Clamped
-decd422 apply #43fc000000000000 -> 0E+369
-
--- negative zeros
-decd431 apply -0E-400 -> #8000000000000000 Clamped
-decd432 apply -0E-400 -> #8000000000000000 Clamped
-decd433 apply -0E-398 -> #8000000000000000
-decd434 apply #8000000000000000 -> -0E-398
-decd435 apply -0.000000000000000E-383 -> #8000000000000000
-decd436 apply #8000000000000000 -> -0E-398
-decd437 apply -0E-2 -> #a230000000000000
-decd438 apply #a230000000000000 -> -0.00
-decd439 apply -0 -> #a238000000000000
-decd440 apply #a238000000000000 -> -0
-decd441 apply -0E+3 -> #a244000000000000
-decd442 apply #a244000000000000 -> -0E+3
-decd443 apply -0E+369 -> #c3fc000000000000
-decd444 apply #c3fc000000000000 -> -0E+369
--- clamped zeros...
-decd445 apply -0E+370 -> #c3fc000000000000 Clamped
-decd446 apply #c3fc000000000000 -> -0E+369
-decd447 apply -0E+384 -> #c3fc000000000000 Clamped
-decd448 apply #c3fc000000000000 -> -0E+369
-decd449 apply -0E+400 -> #c3fc000000000000 Clamped
-decd450 apply #c3fc000000000000 -> -0E+369
-decd451 apply -0E+500 -> #c3fc000000000000 Clamped
-decd452 apply #c3fc000000000000 -> -0E+369
-
--- exponents
-decd460 apply #225c000000000007 -> 7E+9
-decd461 apply 7E+9 -> #225c000000000007
-decd462 apply #23c4000000000007 -> 7E+99
-decd463 apply 7E+99 -> #23c4000000000007
-
--- Specials
-decd500 apply Infinity -> #7800000000000000
-decd501 apply #7878787878787878 -> #7800000000000000
-decd502 apply #7800000000000000 -> Infinity
-decd503 apply #7979797979797979 -> #7800000000000000
-decd504 apply #7900000000000000 -> Infinity
-decd505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000
-decd506 apply #7a00000000000000 -> Infinity
-decd507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000
-decd508 apply #7b00000000000000 -> Infinity
-
-decd509 apply NaN -> #7c00000000000000
-decd510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
-decd511 apply #7c00000000000000 -> NaN
-decd512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
-decd513 apply #7d00000000000000 -> NaN
-decd514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
-decd515 apply #7e00000000000000 -> sNaN
-decd516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
-decd517 apply #7f00000000000000 -> sNaN
-decd518 apply #7fffffffffffffff -> sNaN999999999999999
-decd519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff
-
-decd520 apply -Infinity -> #f800000000000000
-decd521 apply #f878787878787878 -> #f800000000000000
-decd522 apply #f800000000000000 -> -Infinity
-decd523 apply #f979797979797979 -> #f800000000000000
-decd524 apply #f900000000000000 -> -Infinity
-decd525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000
-decd526 apply #fa00000000000000 -> -Infinity
-decd527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000
-decd528 apply #fb00000000000000 -> -Infinity
-
-decd529 apply -NaN -> #fc00000000000000
-decd530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
-decd531 apply #fc00000000000000 -> -NaN
-decd532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
-decd533 apply #fd00000000000000 -> -NaN
-decd534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
-decd535 apply #fe00000000000000 -> -sNaN
-decd536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
-decd537 apply #ff00000000000000 -> -sNaN
-decd538 apply #ffffffffffffffff -> -sNaN999999999999999
-decd539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff
-
--- diagnostic NaNs
-decd540 apply NaN -> #7c00000000000000
-decd541 apply NaN0 -> #7c00000000000000
-decd542 apply NaN1 -> #7c00000000000001
-decd543 apply NaN12 -> #7c00000000000012
-decd544 apply NaN79 -> #7c00000000000079
-decd545 apply NaN12345 -> #7c000000000049c5
-decd546 apply NaN123456 -> #7c00000000028e56
-decd547 apply NaN799799 -> #7c000000000f7fdf
-decd548 apply NaN799799799799799 -> #7c03dff7fdff7fdf
-decd549 apply NaN999999999999999 -> #7c00ff3fcff3fcff
--- too many digits
-
--- fold-down full sequence
-decd601 apply 1E+384 -> #47fc000000000000 Clamped
-decd602 apply #47fc000000000000 -> 1.000000000000000E+384
-decd603 apply 1E+383 -> #43fc800000000000 Clamped
-decd604 apply #43fc800000000000 -> 1.00000000000000E+383
-decd605 apply 1E+382 -> #43fc100000000000 Clamped
-decd606 apply #43fc100000000000 -> 1.0000000000000E+382
-decd607 apply 1E+381 -> #43fc010000000000 Clamped
-decd608 apply #43fc010000000000 -> 1.000000000000E+381
-decd609 apply 1E+380 -> #43fc002000000000 Clamped
-decd610 apply #43fc002000000000 -> 1.00000000000E+380
-decd611 apply 1E+379 -> #43fc000400000000 Clamped
-decd612 apply #43fc000400000000 -> 1.0000000000E+379
-decd613 apply 1E+378 -> #43fc000040000000 Clamped
-decd614 apply #43fc000040000000 -> 1.000000000E+378
-decd615 apply 1E+377 -> #43fc000008000000 Clamped
-decd616 apply #43fc000008000000 -> 1.00000000E+377
-decd617 apply 1E+376 -> #43fc000001000000 Clamped
-decd618 apply #43fc000001000000 -> 1.0000000E+376
-decd619 apply 1E+375 -> #43fc000000100000 Clamped
-decd620 apply #43fc000000100000 -> 1.000000E+375
-decd621 apply 1E+374 -> #43fc000000020000 Clamped
-decd622 apply #43fc000000020000 -> 1.00000E+374
-decd623 apply 1E+373 -> #43fc000000004000 Clamped
-decd624 apply #43fc000000004000 -> 1.0000E+373
-decd625 apply 1E+372 -> #43fc000000000400 Clamped
-decd626 apply #43fc000000000400 -> 1.000E+372
-decd627 apply 1E+371 -> #43fc000000000080 Clamped
-decd628 apply #43fc000000000080 -> 1.00E+371
-decd629 apply 1E+370 -> #43fc000000000010 Clamped
-decd630 apply #43fc000000000010 -> 1.0E+370
-decd631 apply 1E+369 -> #43fc000000000001
-decd632 apply #43fc000000000001 -> 1E+369
-decd633 apply 1E+368 -> #43f8000000000001
-decd634 apply #43f8000000000001 -> 1E+368
--- same with 9s
-decd641 apply 9E+384 -> #77fc000000000000 Clamped
-decd642 apply #77fc000000000000 -> 9.000000000000000E+384
-decd643 apply 9E+383 -> #43fc8c0000000000 Clamped
-decd644 apply #43fc8c0000000000 -> 9.00000000000000E+383
-decd645 apply 9E+382 -> #43fc1a0000000000 Clamped
-decd646 apply #43fc1a0000000000 -> 9.0000000000000E+382
-decd647 apply 9E+381 -> #43fc090000000000 Clamped
-decd648 apply #43fc090000000000 -> 9.000000000000E+381
-decd649 apply 9E+380 -> #43fc002300000000 Clamped
-decd650 apply #43fc002300000000 -> 9.00000000000E+380
-decd651 apply 9E+379 -> #43fc000680000000 Clamped
-decd652 apply #43fc000680000000 -> 9.0000000000E+379
-decd653 apply 9E+378 -> #43fc000240000000 Clamped
-decd654 apply #43fc000240000000 -> 9.000000000E+378
-decd655 apply 9E+377 -> #43fc000008c00000 Clamped
-decd656 apply #43fc000008c00000 -> 9.00000000E+377
-decd657 apply 9E+376 -> #43fc000001a00000 Clamped
-decd658 apply #43fc000001a00000 -> 9.0000000E+376
-decd659 apply 9E+375 -> #43fc000000900000 Clamped
-decd660 apply #43fc000000900000 -> 9.000000E+375
-decd661 apply 9E+374 -> #43fc000000023000 Clamped
-decd662 apply #43fc000000023000 -> 9.00000E+374
-decd663 apply 9E+373 -> #43fc000000006800 Clamped
-decd664 apply #43fc000000006800 -> 9.0000E+373
-decd665 apply 9E+372 -> #43fc000000002400 Clamped
-decd666 apply #43fc000000002400 -> 9.000E+372
-decd667 apply 9E+371 -> #43fc00000000008c Clamped
-decd668 apply #43fc00000000008c -> 9.00E+371
-decd669 apply 9E+370 -> #43fc00000000001a Clamped
-decd670 apply #43fc00000000001a -> 9.0E+370
-decd671 apply 9E+369 -> #43fc000000000009
-decd672 apply #43fc000000000009 -> 9E+369
-decd673 apply 9E+368 -> #43f8000000000009
-decd674 apply #43f8000000000009 -> 9E+368
-
-
--- Selected DPD codes
-decd700 apply #2238000000000000 -> 0
-decd701 apply #2238000000000009 -> 9
-decd702 apply #2238000000000010 -> 10
-decd703 apply #2238000000000019 -> 19
-decd704 apply #2238000000000020 -> 20
-decd705 apply #2238000000000029 -> 29
-decd706 apply #2238000000000030 -> 30
-decd707 apply #2238000000000039 -> 39
-decd708 apply #2238000000000040 -> 40
-decd709 apply #2238000000000049 -> 49
-decd710 apply #2238000000000050 -> 50
-decd711 apply #2238000000000059 -> 59
-decd712 apply #2238000000000060 -> 60
-decd713 apply #2238000000000069 -> 69
-decd714 apply #2238000000000070 -> 70
-decd715 apply #2238000000000071 -> 71
-decd716 apply #2238000000000072 -> 72
-decd717 apply #2238000000000073 -> 73
-decd718 apply #2238000000000074 -> 74
-decd719 apply #2238000000000075 -> 75
-decd720 apply #2238000000000076 -> 76
-decd721 apply #2238000000000077 -> 77
-decd722 apply #2238000000000078 -> 78
-decd723 apply #2238000000000079 -> 79
-
-decd725 apply #223800000000029e -> 994
-decd726 apply #223800000000029f -> 995
-decd727 apply #22380000000002a0 -> 520
-decd728 apply #22380000000002a1 -> 521
--- from telco test data
-decd730 apply #2238000000000188 -> 308
-decd731 apply #22380000000001a3 -> 323
-decd732 apply #223800000000002a -> 82
-decd733 apply #22380000000001a9 -> 329
-decd734 apply #2238000000000081 -> 101
-decd735 apply #22380000000002a2 -> 522
-
--- DPD: one of each of the huffman groups
-decd740 apply #22380000000003f7 -> 777
-decd741 apply #22380000000003f8 -> 778
-decd742 apply #22380000000003eb -> 787
-decd743 apply #223800000000037d -> 877
-decd744 apply #223800000000039f -> 997
-decd745 apply #22380000000003bf -> 979
-decd746 apply #22380000000003df -> 799
-decd747 apply #223800000000006e -> 888
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decd750 apply #223800000000006e -> 888
-decd751 apply #223800000000016e -> 888
-decd752 apply #223800000000026e -> 888
-decd753 apply #223800000000036e -> 888
-decd754 apply #223800000000006f -> 889
-decd755 apply #223800000000016f -> 889
-decd756 apply #223800000000026f -> 889
-decd757 apply #223800000000036f -> 889
-
-decd760 apply #223800000000007e -> 898
-decd761 apply #223800000000017e -> 898
-decd762 apply #223800000000027e -> 898
-decd763 apply #223800000000037e -> 898
-decd764 apply #223800000000007f -> 899
-decd765 apply #223800000000017f -> 899
-decd766 apply #223800000000027f -> 899
-decd767 apply #223800000000037f -> 899
-
-decd770 apply #22380000000000ee -> 988
-decd771 apply #22380000000001ee -> 988
-decd772 apply #22380000000002ee -> 988
-decd773 apply #22380000000003ee -> 988
-decd774 apply #22380000000000ef -> 989
-decd775 apply #22380000000001ef -> 989
-decd776 apply #22380000000002ef -> 989
-decd777 apply #22380000000003ef -> 989
-
-decd780 apply #22380000000000fe -> 998
-decd781 apply #22380000000001fe -> 998
-decd782 apply #22380000000002fe -> 998
-decd783 apply #22380000000003fe -> 998
-decd784 apply #22380000000000ff -> 999
-decd785 apply #22380000000001ff -> 999
-decd786 apply #22380000000002ff -> 999
-decd787 apply #22380000000003ff -> 999
-
--- values around [u]int32 edges (zeros done earlier)
-decd800 apply -2147483646 -> #a23800008c78af46
-decd801 apply -2147483647 -> #a23800008c78af47
-decd802 apply -2147483648 -> #a23800008c78af48
-decd803 apply -2147483649 -> #a23800008c78af49
-decd804 apply 2147483646 -> #223800008c78af46
-decd805 apply 2147483647 -> #223800008c78af47
-decd806 apply 2147483648 -> #223800008c78af48
-decd807 apply 2147483649 -> #223800008c78af49
-decd808 apply 4294967294 -> #2238000115afb55a
-decd809 apply 4294967295 -> #2238000115afb55b
-decd810 apply 4294967296 -> #2238000115afb57a
-decd811 apply 4294967297 -> #2238000115afb57b
-
-decd820 apply #a23800008c78af46 -> -2147483646
-decd821 apply #a23800008c78af47 -> -2147483647
-decd822 apply #a23800008c78af48 -> -2147483648
-decd823 apply #a23800008c78af49 -> -2147483649
-decd824 apply #223800008c78af46 -> 2147483646
-decd825 apply #223800008c78af47 -> 2147483647
-decd826 apply #223800008c78af48 -> 2147483648
-decd827 apply #223800008c78af49 -> 2147483649
-decd828 apply #2238000115afb55a -> 4294967294
-decd829 apply #2238000115afb55b -> 4294967295
-decd830 apply #2238000115afb57a -> 4294967296
-decd831 apply #2238000115afb57b -> 4294967297
-
--- for narrowing
-decd840 apply #2870000000000000 -> 2.000000000000000E-99
-
--- some miscellaneous
-decd850 apply #0004070000000000 -> 7.000000000000E-385 Subnormal
-decd851 apply #0008000000020000 -> 1.00000E-391 Subnormal
-
+------------------------------------------------------------------------
+-- ddEncode.decTest -- decimal eight-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal64.decTest]
+version: 2.59
+
+-- This set of tests is for the eight-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 8 bits exponent continuation
+-- 50 bits coefficient continuation
+--
+-- Total exponent length 10 bits
+-- Total coefficient length 54 bits (16 digits)
+--
+-- Elimit = 767 (maximum encoded exponent)
+-- Emax = 384 (largest exponent value)
+-- Emin = -383 (smallest exponent value)
+-- bias = 398 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+dece001 apply #A2300000000003D0 -> -7.50
+dece002 apply -7.50 -> #A2300000000003D0
+-- derivative canonical plain strings
+dece003 apply #A23c0000000003D0 -> -7.50E+3
+dece004 apply -7.50E+3 -> #A23c0000000003D0
+dece005 apply #A2380000000003D0 -> -750
+dece006 apply -750 -> #A2380000000003D0
+dece007 apply #A2340000000003D0 -> -75.0
+dece008 apply -75.0 -> #A2340000000003D0
+dece009 apply #A22c0000000003D0 -> -0.750
+dece010 apply -0.750 -> #A22c0000000003D0
+dece011 apply #A2280000000003D0 -> -0.0750
+dece012 apply -0.0750 -> #A2280000000003D0
+dece013 apply #A2200000000003D0 -> -0.000750
+dece014 apply -0.000750 -> #A2200000000003D0
+dece015 apply #A2180000000003D0 -> -0.00000750
+dece016 apply -0.00000750 -> #A2180000000003D0
+dece017 apply #A2140000000003D0 -> -7.50E-7
+dece018 apply -7.50E-7 -> #A2140000000003D0
+
+-- Normality
+dece020 apply 1234567890123456 -> #263934b9c1e28e56
+dece021 apply -1234567890123456 -> #a63934b9c1e28e56
+dece022 apply 1234.567890123456 -> #260934b9c1e28e56
+dece023 apply #260934b9c1e28e56 -> 1234.567890123456
+dece024 apply 1111111111111111 -> #2638912449124491
+dece025 apply 9999999999999999 -> #6e38ff3fcff3fcff
+
+-- Nmax and similar
+dece031 apply 9999999999999999E+369 -> #77fcff3fcff3fcff
+dece032 apply 9.999999999999999E+384 -> #77fcff3fcff3fcff
+dece033 apply #77fcff3fcff3fcff -> 9.999999999999999E+384
+dece034 apply 1.234567890123456E+384 -> #47fd34b9c1e28e56
+dece035 apply #47fd34b9c1e28e56 -> 1.234567890123456E+384
+-- fold-downs (more below)
+dece036 apply 1.23E+384 -> #47fd300000000000 Clamped
+dece037 apply #47fd300000000000 -> 1.230000000000000E+384
+decd038 apply 1E+384 -> #47fc000000000000 Clamped
+decd039 apply #47fc000000000000 -> 1.000000000000000E+384
+
+decd051 apply 12345 -> #22380000000049c5
+decd052 apply #22380000000049c5 -> 12345
+decd053 apply 1234 -> #2238000000000534
+decd054 apply #2238000000000534 -> 1234
+decd055 apply 123 -> #22380000000000a3
+decd056 apply #22380000000000a3 -> 123
+decd057 apply 12 -> #2238000000000012
+decd058 apply #2238000000000012 -> 12
+decd059 apply 1 -> #2238000000000001
+decd060 apply #2238000000000001 -> 1
+decd061 apply 1.23 -> #22300000000000a3
+decd062 apply #22300000000000a3 -> 1.23
+decd063 apply 123.45 -> #22300000000049c5
+decd064 apply #22300000000049c5 -> 123.45
+
+-- Nmin and below
+decd071 apply 1E-383 -> #003c000000000001
+decd072 apply #003c000000000001 -> 1E-383
+decd073 apply 1.000000000000000E-383 -> #0400000000000000
+decd074 apply #0400000000000000 -> 1.000000000000000E-383
+decd075 apply 1.000000000000001E-383 -> #0400000000000001
+decd076 apply #0400000000000001 -> 1.000000000000001E-383
+
+decd077 apply 0.100000000000000E-383 -> #0000800000000000 Subnormal
+decd078 apply #0000800000000000 -> 1.00000000000000E-384 Subnormal
+decd079 apply 0.000000000000010E-383 -> #0000000000000010 Subnormal
+decd080 apply #0000000000000010 -> 1.0E-397 Subnormal
+decd081 apply 0.00000000000001E-383 -> #0004000000000001 Subnormal
+decd082 apply #0004000000000001 -> 1E-397 Subnormal
+decd083 apply 0.000000000000001E-383 -> #0000000000000001 Subnormal
+decd084 apply #0000000000000001 -> 1E-398 Subnormal
+-- next is smallest all-nines
+decd085 apply 9999999999999999E-398 -> #6400ff3fcff3fcff
+decd086 apply #6400ff3fcff3fcff -> 9.999999999999999E-383
+-- and a problematic divide result
+decd088 apply 1.111111111111111E-383 -> #0400912449124491
+decd089 apply #0400912449124491 -> 1.111111111111111E-383
+
+-- forties
+decd090 apply 40 -> #2238000000000040
+decd091 apply 39.99 -> #2230000000000cff
+
+-- underflows cannot be tested as all LHS exact
+
+-- Same again, negatives
+-- Nmax and similar
+decd122 apply -9.999999999999999E+384 -> #f7fcff3fcff3fcff
+decd123 apply #f7fcff3fcff3fcff -> -9.999999999999999E+384
+decd124 apply -1.234567890123456E+384 -> #c7fd34b9c1e28e56
+decd125 apply #c7fd34b9c1e28e56 -> -1.234567890123456E+384
+-- fold-downs (more below)
+decd130 apply -1.23E+384 -> #c7fd300000000000 Clamped
+decd131 apply #c7fd300000000000 -> -1.230000000000000E+384
+decd132 apply -1E+384 -> #c7fc000000000000 Clamped
+decd133 apply #c7fc000000000000 -> -1.000000000000000E+384
+
+-- overflows
+decd151 apply -12345 -> #a2380000000049c5
+decd152 apply #a2380000000049c5 -> -12345
+decd153 apply -1234 -> #a238000000000534
+decd154 apply #a238000000000534 -> -1234
+decd155 apply -123 -> #a2380000000000a3
+decd156 apply #a2380000000000a3 -> -123
+decd157 apply -12 -> #a238000000000012
+decd158 apply #a238000000000012 -> -12
+decd159 apply -1 -> #a238000000000001
+decd160 apply #a238000000000001 -> -1
+decd161 apply -1.23 -> #a2300000000000a3
+decd162 apply #a2300000000000a3 -> -1.23
+decd163 apply -123.45 -> #a2300000000049c5
+decd164 apply #a2300000000049c5 -> -123.45
+
+-- Nmin and below
+decd171 apply -1E-383 -> #803c000000000001
+decd172 apply #803c000000000001 -> -1E-383
+decd173 apply -1.000000000000000E-383 -> #8400000000000000
+decd174 apply #8400000000000000 -> -1.000000000000000E-383
+decd175 apply -1.000000000000001E-383 -> #8400000000000001
+decd176 apply #8400000000000001 -> -1.000000000000001E-383
+
+decd177 apply -0.100000000000000E-383 -> #8000800000000000 Subnormal
+decd178 apply #8000800000000000 -> -1.00000000000000E-384 Subnormal
+decd179 apply -0.000000000000010E-383 -> #8000000000000010 Subnormal
+decd180 apply #8000000000000010 -> -1.0E-397 Subnormal
+decd181 apply -0.00000000000001E-383 -> #8004000000000001 Subnormal
+decd182 apply #8004000000000001 -> -1E-397 Subnormal
+decd183 apply -0.000000000000001E-383 -> #8000000000000001 Subnormal
+decd184 apply #8000000000000001 -> -1E-398 Subnormal
+-- next is smallest all-nines
+decd185 apply -9999999999999999E-398 -> #e400ff3fcff3fcff
+decd186 apply #e400ff3fcff3fcff -> -9.999999999999999E-383
+-- and a tricky subnormal
+decd187 apply 1.11111111111524E-384 -> #00009124491246a4 Subnormal
+decd188 apply #00009124491246a4 -> 1.11111111111524E-384 Subnormal
+
+-- near-underflows
+decd189 apply -1e-398 -> #8000000000000001 Subnormal
+decd190 apply -1.0e-398 -> #8000000000000001 Subnormal Rounded
+
+-- zeros
+decd401 apply 0E-500 -> #0000000000000000 Clamped
+decd402 apply 0E-400 -> #0000000000000000 Clamped
+decd403 apply 0E-398 -> #0000000000000000
+decd404 apply #0000000000000000 -> 0E-398
+decd405 apply 0.000000000000000E-383 -> #0000000000000000
+decd406 apply #0000000000000000 -> 0E-398
+decd407 apply 0E-2 -> #2230000000000000
+decd408 apply #2230000000000000 -> 0.00
+decd409 apply 0 -> #2238000000000000
+decd410 apply #2238000000000000 -> 0
+decd411 apply 0E+3 -> #2244000000000000
+decd412 apply #2244000000000000 -> 0E+3
+decd413 apply 0E+369 -> #43fc000000000000
+decd414 apply #43fc000000000000 -> 0E+369
+-- clamped zeros...
+decd415 apply 0E+370 -> #43fc000000000000 Clamped
+decd416 apply #43fc000000000000 -> 0E+369
+decd417 apply 0E+384 -> #43fc000000000000 Clamped
+decd418 apply #43fc000000000000 -> 0E+369
+decd419 apply 0E+400 -> #43fc000000000000 Clamped
+decd420 apply #43fc000000000000 -> 0E+369
+decd421 apply 0E+500 -> #43fc000000000000 Clamped
+decd422 apply #43fc000000000000 -> 0E+369
+
+-- negative zeros
+decd431 apply -0E-400 -> #8000000000000000 Clamped
+decd432 apply -0E-400 -> #8000000000000000 Clamped
+decd433 apply -0E-398 -> #8000000000000000
+decd434 apply #8000000000000000 -> -0E-398
+decd435 apply -0.000000000000000E-383 -> #8000000000000000
+decd436 apply #8000000000000000 -> -0E-398
+decd437 apply -0E-2 -> #a230000000000000
+decd438 apply #a230000000000000 -> -0.00
+decd439 apply -0 -> #a238000000000000
+decd440 apply #a238000000000000 -> -0
+decd441 apply -0E+3 -> #a244000000000000
+decd442 apply #a244000000000000 -> -0E+3
+decd443 apply -0E+369 -> #c3fc000000000000
+decd444 apply #c3fc000000000000 -> -0E+369
+-- clamped zeros...
+decd445 apply -0E+370 -> #c3fc000000000000 Clamped
+decd446 apply #c3fc000000000000 -> -0E+369
+decd447 apply -0E+384 -> #c3fc000000000000 Clamped
+decd448 apply #c3fc000000000000 -> -0E+369
+decd449 apply -0E+400 -> #c3fc000000000000 Clamped
+decd450 apply #c3fc000000000000 -> -0E+369
+decd451 apply -0E+500 -> #c3fc000000000000 Clamped
+decd452 apply #c3fc000000000000 -> -0E+369
+
+-- exponents
+decd460 apply #225c000000000007 -> 7E+9
+decd461 apply 7E+9 -> #225c000000000007
+decd462 apply #23c4000000000007 -> 7E+99
+decd463 apply 7E+99 -> #23c4000000000007
+
+-- Specials
+decd500 apply Infinity -> #7800000000000000
+decd501 apply #7878787878787878 -> #7800000000000000
+decd502 apply #7800000000000000 -> Infinity
+decd503 apply #7979797979797979 -> #7800000000000000
+decd504 apply #7900000000000000 -> Infinity
+decd505 apply #7a7a7a7a7a7a7a7a -> #7800000000000000
+decd506 apply #7a00000000000000 -> Infinity
+decd507 apply #7b7b7b7b7b7b7b7b -> #7800000000000000
+decd508 apply #7b00000000000000 -> Infinity
+
+decd509 apply NaN -> #7c00000000000000
+decd510 apply #7c7c7c7c7c7c7c7c -> #7c007c7c7c7c7c7c
+decd511 apply #7c00000000000000 -> NaN
+decd512 apply #7d7d7d7d7d7d7d7d -> #7c017d7d7d7d7d7d
+decd513 apply #7d00000000000000 -> NaN
+decd514 apply #7e7e7e7e7e7e7e7e -> #7e007e7e7e7e7c7e
+decd515 apply #7e00000000000000 -> sNaN
+decd516 apply #7f7f7f7f7f7f7f7f -> #7e007f7f7f7f7c7f
+decd517 apply #7f00000000000000 -> sNaN
+decd518 apply #7fffffffffffffff -> sNaN999999999999999
+decd519 apply #7fffffffffffffff -> #7e00ff3fcff3fcff
+
+decd520 apply -Infinity -> #f800000000000000
+decd521 apply #f878787878787878 -> #f800000000000000
+decd522 apply #f800000000000000 -> -Infinity
+decd523 apply #f979797979797979 -> #f800000000000000
+decd524 apply #f900000000000000 -> -Infinity
+decd525 apply #fa7a7a7a7a7a7a7a -> #f800000000000000
+decd526 apply #fa00000000000000 -> -Infinity
+decd527 apply #fb7b7b7b7b7b7b7b -> #f800000000000000
+decd528 apply #fb00000000000000 -> -Infinity
+
+decd529 apply -NaN -> #fc00000000000000
+decd530 apply #fc7c7c7c7c7c7c7c -> #fc007c7c7c7c7c7c
+decd531 apply #fc00000000000000 -> -NaN
+decd532 apply #fd7d7d7d7d7d7d7d -> #fc017d7d7d7d7d7d
+decd533 apply #fd00000000000000 -> -NaN
+decd534 apply #fe7e7e7e7e7e7e7e -> #fe007e7e7e7e7c7e
+decd535 apply #fe00000000000000 -> -sNaN
+decd536 apply #ff7f7f7f7f7f7f7f -> #fe007f7f7f7f7c7f
+decd537 apply #ff00000000000000 -> -sNaN
+decd538 apply #ffffffffffffffff -> -sNaN999999999999999
+decd539 apply #ffffffffffffffff -> #fe00ff3fcff3fcff
+
+-- diagnostic NaNs
+decd540 apply NaN -> #7c00000000000000
+decd541 apply NaN0 -> #7c00000000000000
+decd542 apply NaN1 -> #7c00000000000001
+decd543 apply NaN12 -> #7c00000000000012
+decd544 apply NaN79 -> #7c00000000000079
+decd545 apply NaN12345 -> #7c000000000049c5
+decd546 apply NaN123456 -> #7c00000000028e56
+decd547 apply NaN799799 -> #7c000000000f7fdf
+decd548 apply NaN799799799799799 -> #7c03dff7fdff7fdf
+decd549 apply NaN999999999999999 -> #7c00ff3fcff3fcff
+-- too many digits
+
+-- fold-down full sequence
+decd601 apply 1E+384 -> #47fc000000000000 Clamped
+decd602 apply #47fc000000000000 -> 1.000000000000000E+384
+decd603 apply 1E+383 -> #43fc800000000000 Clamped
+decd604 apply #43fc800000000000 -> 1.00000000000000E+383
+decd605 apply 1E+382 -> #43fc100000000000 Clamped
+decd606 apply #43fc100000000000 -> 1.0000000000000E+382
+decd607 apply 1E+381 -> #43fc010000000000 Clamped
+decd608 apply #43fc010000000000 -> 1.000000000000E+381
+decd609 apply 1E+380 -> #43fc002000000000 Clamped
+decd610 apply #43fc002000000000 -> 1.00000000000E+380
+decd611 apply 1E+379 -> #43fc000400000000 Clamped
+decd612 apply #43fc000400000000 -> 1.0000000000E+379
+decd613 apply 1E+378 -> #43fc000040000000 Clamped
+decd614 apply #43fc000040000000 -> 1.000000000E+378
+decd615 apply 1E+377 -> #43fc000008000000 Clamped
+decd616 apply #43fc000008000000 -> 1.00000000E+377
+decd617 apply 1E+376 -> #43fc000001000000 Clamped
+decd618 apply #43fc000001000000 -> 1.0000000E+376
+decd619 apply 1E+375 -> #43fc000000100000 Clamped
+decd620 apply #43fc000000100000 -> 1.000000E+375
+decd621 apply 1E+374 -> #43fc000000020000 Clamped
+decd622 apply #43fc000000020000 -> 1.00000E+374
+decd623 apply 1E+373 -> #43fc000000004000 Clamped
+decd624 apply #43fc000000004000 -> 1.0000E+373
+decd625 apply 1E+372 -> #43fc000000000400 Clamped
+decd626 apply #43fc000000000400 -> 1.000E+372
+decd627 apply 1E+371 -> #43fc000000000080 Clamped
+decd628 apply #43fc000000000080 -> 1.00E+371
+decd629 apply 1E+370 -> #43fc000000000010 Clamped
+decd630 apply #43fc000000000010 -> 1.0E+370
+decd631 apply 1E+369 -> #43fc000000000001
+decd632 apply #43fc000000000001 -> 1E+369
+decd633 apply 1E+368 -> #43f8000000000001
+decd634 apply #43f8000000000001 -> 1E+368
+-- same with 9s
+decd641 apply 9E+384 -> #77fc000000000000 Clamped
+decd642 apply #77fc000000000000 -> 9.000000000000000E+384
+decd643 apply 9E+383 -> #43fc8c0000000000 Clamped
+decd644 apply #43fc8c0000000000 -> 9.00000000000000E+383
+decd645 apply 9E+382 -> #43fc1a0000000000 Clamped
+decd646 apply #43fc1a0000000000 -> 9.0000000000000E+382
+decd647 apply 9E+381 -> #43fc090000000000 Clamped
+decd648 apply #43fc090000000000 -> 9.000000000000E+381
+decd649 apply 9E+380 -> #43fc002300000000 Clamped
+decd650 apply #43fc002300000000 -> 9.00000000000E+380
+decd651 apply 9E+379 -> #43fc000680000000 Clamped
+decd652 apply #43fc000680000000 -> 9.0000000000E+379
+decd653 apply 9E+378 -> #43fc000240000000 Clamped
+decd654 apply #43fc000240000000 -> 9.000000000E+378
+decd655 apply 9E+377 -> #43fc000008c00000 Clamped
+decd656 apply #43fc000008c00000 -> 9.00000000E+377
+decd657 apply 9E+376 -> #43fc000001a00000 Clamped
+decd658 apply #43fc000001a00000 -> 9.0000000E+376
+decd659 apply 9E+375 -> #43fc000000900000 Clamped
+decd660 apply #43fc000000900000 -> 9.000000E+375
+decd661 apply 9E+374 -> #43fc000000023000 Clamped
+decd662 apply #43fc000000023000 -> 9.00000E+374
+decd663 apply 9E+373 -> #43fc000000006800 Clamped
+decd664 apply #43fc000000006800 -> 9.0000E+373
+decd665 apply 9E+372 -> #43fc000000002400 Clamped
+decd666 apply #43fc000000002400 -> 9.000E+372
+decd667 apply 9E+371 -> #43fc00000000008c Clamped
+decd668 apply #43fc00000000008c -> 9.00E+371
+decd669 apply 9E+370 -> #43fc00000000001a Clamped
+decd670 apply #43fc00000000001a -> 9.0E+370
+decd671 apply 9E+369 -> #43fc000000000009
+decd672 apply #43fc000000000009 -> 9E+369
+decd673 apply 9E+368 -> #43f8000000000009
+decd674 apply #43f8000000000009 -> 9E+368
+
+
+-- Selected DPD codes
+decd700 apply #2238000000000000 -> 0
+decd701 apply #2238000000000009 -> 9
+decd702 apply #2238000000000010 -> 10
+decd703 apply #2238000000000019 -> 19
+decd704 apply #2238000000000020 -> 20
+decd705 apply #2238000000000029 -> 29
+decd706 apply #2238000000000030 -> 30
+decd707 apply #2238000000000039 -> 39
+decd708 apply #2238000000000040 -> 40
+decd709 apply #2238000000000049 -> 49
+decd710 apply #2238000000000050 -> 50
+decd711 apply #2238000000000059 -> 59
+decd712 apply #2238000000000060 -> 60
+decd713 apply #2238000000000069 -> 69
+decd714 apply #2238000000000070 -> 70
+decd715 apply #2238000000000071 -> 71
+decd716 apply #2238000000000072 -> 72
+decd717 apply #2238000000000073 -> 73
+decd718 apply #2238000000000074 -> 74
+decd719 apply #2238000000000075 -> 75
+decd720 apply #2238000000000076 -> 76
+decd721 apply #2238000000000077 -> 77
+decd722 apply #2238000000000078 -> 78
+decd723 apply #2238000000000079 -> 79
+
+decd725 apply #223800000000029e -> 994
+decd726 apply #223800000000029f -> 995
+decd727 apply #22380000000002a0 -> 520
+decd728 apply #22380000000002a1 -> 521
+-- from telco test data
+decd730 apply #2238000000000188 -> 308
+decd731 apply #22380000000001a3 -> 323
+decd732 apply #223800000000002a -> 82
+decd733 apply #22380000000001a9 -> 329
+decd734 apply #2238000000000081 -> 101
+decd735 apply #22380000000002a2 -> 522
+
+-- DPD: one of each of the huffman groups
+decd740 apply #22380000000003f7 -> 777
+decd741 apply #22380000000003f8 -> 778
+decd742 apply #22380000000003eb -> 787
+decd743 apply #223800000000037d -> 877
+decd744 apply #223800000000039f -> 997
+decd745 apply #22380000000003bf -> 979
+decd746 apply #22380000000003df -> 799
+decd747 apply #223800000000006e -> 888
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decd750 apply #223800000000006e -> 888
+decd751 apply #223800000000016e -> 888
+decd752 apply #223800000000026e -> 888
+decd753 apply #223800000000036e -> 888
+decd754 apply #223800000000006f -> 889
+decd755 apply #223800000000016f -> 889
+decd756 apply #223800000000026f -> 889
+decd757 apply #223800000000036f -> 889
+
+decd760 apply #223800000000007e -> 898
+decd761 apply #223800000000017e -> 898
+decd762 apply #223800000000027e -> 898
+decd763 apply #223800000000037e -> 898
+decd764 apply #223800000000007f -> 899
+decd765 apply #223800000000017f -> 899
+decd766 apply #223800000000027f -> 899
+decd767 apply #223800000000037f -> 899
+
+decd770 apply #22380000000000ee -> 988
+decd771 apply #22380000000001ee -> 988
+decd772 apply #22380000000002ee -> 988
+decd773 apply #22380000000003ee -> 988
+decd774 apply #22380000000000ef -> 989
+decd775 apply #22380000000001ef -> 989
+decd776 apply #22380000000002ef -> 989
+decd777 apply #22380000000003ef -> 989
+
+decd780 apply #22380000000000fe -> 998
+decd781 apply #22380000000001fe -> 998
+decd782 apply #22380000000002fe -> 998
+decd783 apply #22380000000003fe -> 998
+decd784 apply #22380000000000ff -> 999
+decd785 apply #22380000000001ff -> 999
+decd786 apply #22380000000002ff -> 999
+decd787 apply #22380000000003ff -> 999
+
+-- values around [u]int32 edges (zeros done earlier)
+decd800 apply -2147483646 -> #a23800008c78af46
+decd801 apply -2147483647 -> #a23800008c78af47
+decd802 apply -2147483648 -> #a23800008c78af48
+decd803 apply -2147483649 -> #a23800008c78af49
+decd804 apply 2147483646 -> #223800008c78af46
+decd805 apply 2147483647 -> #223800008c78af47
+decd806 apply 2147483648 -> #223800008c78af48
+decd807 apply 2147483649 -> #223800008c78af49
+decd808 apply 4294967294 -> #2238000115afb55a
+decd809 apply 4294967295 -> #2238000115afb55b
+decd810 apply 4294967296 -> #2238000115afb57a
+decd811 apply 4294967297 -> #2238000115afb57b
+
+decd820 apply #a23800008c78af46 -> -2147483646
+decd821 apply #a23800008c78af47 -> -2147483647
+decd822 apply #a23800008c78af48 -> -2147483648
+decd823 apply #a23800008c78af49 -> -2147483649
+decd824 apply #223800008c78af46 -> 2147483646
+decd825 apply #223800008c78af47 -> 2147483647
+decd826 apply #223800008c78af48 -> 2147483648
+decd827 apply #223800008c78af49 -> 2147483649
+decd828 apply #2238000115afb55a -> 4294967294
+decd829 apply #2238000115afb55b -> 4294967295
+decd830 apply #2238000115afb57a -> 4294967296
+decd831 apply #2238000115afb57b -> 4294967297
+
+-- for narrowing
+decd840 apply #2870000000000000 -> 2.000000000000000E-99
+
+-- some miscellaneous
+decd850 apply #0004070000000000 -> 7.000000000000E-385 Subnormal
+decd851 apply #0008000000020000 -> 1.00000E-391 Subnormal
+
diff --git a/Lib/test/decimaltestdata/ddFMA.decTest b/Lib/test/decimaltestdata/ddFMA.decTest
index 8ae92a7f9ac..f0acfc74d53 100644
--- a/Lib/test/decimaltestdata/ddFMA.decTest
+++ b/Lib/test/decimaltestdata/ddFMA.decTest
@@ -1,1698 +1,1698 @@
-------------------------------------------------------------------------
--- ddFMA.decTest -- decDouble Fused Multiply Add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-ddfma0001 fma 1 1 1 -> 2
-ddfma0002 fma 1 1 2 -> 3
-ddfma0003 fma 2 2 3 -> 7
-ddfma0004 fma 9 9 9 -> 90
-ddfma0005 fma -1 1 1 -> 0
-ddfma0006 fma -1 1 2 -> 1
-ddfma0007 fma -2 2 3 -> -1
-ddfma0008 fma -9 9 9 -> -72
-ddfma0011 fma 1 -1 1 -> 0
-ddfma0012 fma 1 -1 2 -> 1
-ddfma0013 fma 2 -2 3 -> -1
-ddfma0014 fma 9 -9 9 -> -72
-ddfma0015 fma 1 1 -1 -> 0
-ddfma0016 fma 1 1 -2 -> -1
-ddfma0017 fma 2 2 -3 -> 1
-ddfma0018 fma 9 9 -9 -> 72
-
--- non-integer exacts
-ddfma0100 fma 25.2 63.6 -438 -> 1164.72
-ddfma0101 fma 0.301 0.380 334 -> 334.114380
-ddfma0102 fma 49.2 -4.8 23.3 -> -212.86
-ddfma0103 fma 4.22 0.079 -94.6 -> -94.26662
-ddfma0104 fma 903 0.797 0.887 -> 720.578
-ddfma0105 fma 6.13 -161 65.9 -> -921.03
-ddfma0106 fma 28.2 727 5.45 -> 20506.85
-ddfma0107 fma 4 605 688 -> 3108
-ddfma0108 fma 93.3 0.19 0.226 -> 17.953
-ddfma0109 fma 0.169 -341 5.61 -> -52.019
-ddfma0110 fma -72.2 30 -51.2 -> -2217.2
-ddfma0111 fma -0.409 13 20.4 -> 15.083
-ddfma0112 fma 317 77.0 19.0 -> 24428.0
-ddfma0113 fma 47 6.58 1.62 -> 310.88
-ddfma0114 fma 1.36 0.984 0.493 -> 1.83124
-ddfma0115 fma 72.7 274 1.56 -> 19921.36
-ddfma0116 fma 335 847 83 -> 283828
-ddfma0117 fma 666 0.247 25.4 -> 189.902
-ddfma0118 fma -3.87 3.06 78.0 -> 66.1578
-ddfma0119 fma 0.742 192 35.6 -> 178.064
-ddfma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- -> 7.123356429257969E+16
-ddfma0201 fma 27583489.6645 2582471078.04 2593183.42371 -> 7.123356429257970E+16 Inexact Rounded
--- -> 22813275328.80506
-ddfma0208 fma 24280.355566 939577.397653 2032.013252 -> 22813275328.80507 Inexact Rounded
--- -> -2.030397734278062E+16
-ddfma0209 fma 7848976432 -2586831.2281 137903.517909 -> -2.030397734278061E+16 Inexact Rounded
--- -> 2040774094814.077
-ddfma0217 fma 56890.388731 35872030.4255 339337.123410 -> 2040774094814.078 Inexact Rounded
--- -> 2.714469575205049E+18
-ddfma0220 fma 7533543.57445 360317763928 5073392.31638 -> 2.714469575205050E+18 Inexact Rounded
--- -> 1.011676297716716E+19
-ddfma0223 fma 739945255.563 13672312784.1 -994381.53572 -> 1.011676297716715E+19 Inexact Rounded
--- -> -2.914135721455315E+23
-ddfma0224 fma -413510957218 704729988550 9234162614.0 -> -2.914135721455314E+23 Inexact Rounded
--- -> 2.620119863365786E+17
-ddfma0226 fma 437484.00601 598906432790 894450638.442 -> 2.620119863365787E+17 Inexact Rounded
--- -> 1.272647995808178E+19
-ddfma0253 fma 73287556929 173651305.784 -358312568.389 -> 1.272647995808177E+19 Inexact Rounded
--- -> -1.753769320861851E+18
-ddfma0257 fma 203258304486 -8628278.8066 153127.446727 -> -1.753769320861850E+18 Inexact Rounded
--- -> -1.550737835263346E+17
-ddfma0260 fma 42560533.1774 -3643605282.86 178277.96377 -> -1.550737835263347E+17 Inexact Rounded
--- -> 2.897624620576005E+22
-ddfma0269 fma 142656587375 203118879670 604576103991 -> 2.897624620576004E+22 Inexact Rounded
-
--- Cases where multiply would overflow or underflow if separate
-fma0300 fma 9e+384 10 0 -> Infinity Overflow Inexact Rounded
-fma0301 fma 1e+384 10 0 -> Infinity Overflow Inexact Rounded
-fma0302 fma 1e+384 10 -1e+384 -> 9.000000000000000E+384 Clamped
-fma0303 fma 1e+384 10 -9e+384 -> 1.000000000000000E+384 Clamped
--- subnormal etc.
-fma0305 fma 1e-398 0.1 0 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-fma0306 fma 1e-398 0.1 1 -> 1.000000000000000 Inexact Rounded
-fma0307 fma 1e-398 0.1 1e-398 -> 1E-398 Underflow Subnormal Inexact Rounded
-
--- Infinite combinations
-ddfma0800 fma Inf Inf Inf -> Infinity
-ddfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
-ddfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
-ddfma0803 fma Inf -Inf -Inf -> -Infinity
-ddfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
-ddfma0805 fma -Inf Inf -Inf -> -Infinity
-ddfma0806 fma -Inf -Inf Inf -> Infinity
-ddfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-
--- Triple NaN propagation
-ddfma0900 fma NaN2 NaN3 NaN5 -> NaN2
-ddfma0901 fma 0 NaN3 NaN5 -> NaN3
-ddfma0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-ddfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-ddfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-ddfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-ddfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-ddfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-ddfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
-
--- sanity checks
-ddfma2000 fma 2 2 0e+384 -> 4
-ddfma2001 fma 2 3 0e+384 -> 6
-ddfma2002 fma 5 1 0e+384 -> 5
-ddfma2003 fma 5 2 0e+384 -> 10
-ddfma2004 fma 1.20 2 0e+384 -> 2.40
-ddfma2005 fma 1.20 0 0e+384 -> 0.00
-ddfma2006 fma 1.20 -2 0e+384 -> -2.40
-ddfma2007 fma -1.20 2 0e+384 -> -2.40
-ddfma2008 fma -1.20 0 0e+384 -> 0.00
-ddfma2009 fma -1.20 -2 0e+384 -> 2.40
-ddfma2010 fma 5.09 7.1 0e+384 -> 36.139
-ddfma2011 fma 2.5 4 0e+384 -> 10.0
-ddfma2012 fma 2.50 4 0e+384 -> 10.00
-ddfma2013 fma 1.23456789 1.00000000 0e+384 -> 1.234567890000000 Rounded
-ddfma2015 fma 2.50 4 0e+384 -> 10.00
-ddfma2016 fma 9.999999999 9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
-ddfma2017 fma 9.999999999 -9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
-ddfma2018 fma -9.999999999 9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
-ddfma2019 fma -9.999999999 -9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
-
--- zeros, etc.
-ddfma2021 fma 0 0 0e+384 -> 0
-ddfma2022 fma 0 -0 0e+384 -> 0
-ddfma2023 fma -0 0 0e+384 -> 0
-ddfma2024 fma -0 -0 0e+384 -> 0
-ddfma2025 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2026 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2027 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2028 fma -0.0 -0.0 0e+384 -> 0.00
-ddfma2030 fma 5.00 1E-3 0e+384 -> 0.00500
-ddfma2031 fma 00.00 0.000 0e+384 -> 0.00000
-ddfma2032 fma 00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2033 fma 0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2034 fma -5.00 1E-3 0e+384 -> -0.00500
-ddfma2035 fma -00.00 0.000 0e+384 -> 0.00000
-ddfma2036 fma -00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2037 fma -0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2038 fma 5.00 -1E-3 0e+384 -> -0.00500
-ddfma2039 fma 00.00 -0.000 0e+384 -> 0.00000
-ddfma2040 fma 00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2041 fma 0E-3 -00.00 0e+384 -> 0.00000 -- lhs is 0
-ddfma2042 fma -5.00 -1E-3 0e+384 -> 0.00500
-ddfma2043 fma -00.00 -0.000 0e+384 -> 0.00000
-ddfma2044 fma -00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
-ddfma2045 fma -0E-3 -00.00 -0e+384 -> 0.00000 -- lhs is 0
-ddfma2046 fma -0E-3 00.00 -0e+384 -> -0.00000
-ddfma2047 fma 0E-3 -00.00 -0e+384 -> -0.00000
-ddfma2048 fma 0E-3 00.00 -0e+384 -> 0.00000
-
--- examples from decarith
-ddfma2050 fma 1.20 3 0e+384 -> 3.60
-ddfma2051 fma 7 3 0e+384 -> 21
-ddfma2052 fma 0.9 0.8 0e+384 -> 0.72
-ddfma2053 fma 0.9 -0 0e+384 -> 0.0
-ddfma2054 fma 654321 654321 0e+384 -> 428135971041
-
-ddfma2060 fma 123.45 1e7 0e+384 -> 1.2345E+9
-ddfma2061 fma 123.45 1e8 0e+384 -> 1.2345E+10
-ddfma2062 fma 123.45 1e+9 0e+384 -> 1.2345E+11
-ddfma2063 fma 123.45 1e10 0e+384 -> 1.2345E+12
-ddfma2064 fma 123.45 1e11 0e+384 -> 1.2345E+13
-ddfma2065 fma 123.45 1e12 0e+384 -> 1.2345E+14
-ddfma2066 fma 123.45 1e13 0e+384 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-ddfma2080 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
-ddfma2084 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
-ddfma2090 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
-ddfma2094 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
-
--- test some more edge cases and carries
-ddfma2101 fma 9 9 0e+384 -> 81
-ddfma2102 fma 9 90 0e+384 -> 810
-ddfma2103 fma 9 900 0e+384 -> 8100
-ddfma2104 fma 9 9000 0e+384 -> 81000
-ddfma2105 fma 9 90000 0e+384 -> 810000
-ddfma2106 fma 9 900000 0e+384 -> 8100000
-ddfma2107 fma 9 9000000 0e+384 -> 81000000
-ddfma2108 fma 9 90000000 0e+384 -> 810000000
-ddfma2109 fma 9 900000000 0e+384 -> 8100000000
-ddfma2110 fma 9 9000000000 0e+384 -> 81000000000
-ddfma2111 fma 9 90000000000 0e+384 -> 810000000000
-ddfma2112 fma 9 900000000000 0e+384 -> 8100000000000
-ddfma2113 fma 9 9000000000000 0e+384 -> 81000000000000
-ddfma2114 fma 9 90000000000000 0e+384 -> 810000000000000
-ddfma2115 fma 9 900000000000000 0e+384 -> 8100000000000000
---ddfma2116 fma 9 9000000000000000 0e+384 -> 81000000000000000
---ddfma2117 fma 9 90000000000000000 0e+384 -> 810000000000000000
---ddfma2118 fma 9 900000000000000000 0e+384 -> 8100000000000000000
---ddfma2119 fma 9 9000000000000000000 0e+384 -> 81000000000000000000
---ddfma2120 fma 9 90000000000000000000 0e+384 -> 810000000000000000000
---ddfma2121 fma 9 900000000000000000000 0e+384 -> 8100000000000000000000
---ddfma2122 fma 9 9000000000000000000000 0e+384 -> 81000000000000000000000
---ddfma2123 fma 9 90000000000000000000000 0e+384 -> 810000000000000000000000
--- test some more edge cases without carries
-ddfma2131 fma 3 3 0e+384 -> 9
-ddfma2132 fma 3 30 0e+384 -> 90
-ddfma2133 fma 3 300 0e+384 -> 900
-ddfma2134 fma 3 3000 0e+384 -> 9000
-ddfma2135 fma 3 30000 0e+384 -> 90000
-ddfma2136 fma 3 300000 0e+384 -> 900000
-ddfma2137 fma 3 3000000 0e+384 -> 9000000
-ddfma2138 fma 3 30000000 0e+384 -> 90000000
-ddfma2139 fma 3 300000000 0e+384 -> 900000000
-ddfma2140 fma 3 3000000000 0e+384 -> 9000000000
-ddfma2141 fma 3 30000000000 0e+384 -> 90000000000
-ddfma2142 fma 3 300000000000 0e+384 -> 900000000000
-ddfma2143 fma 3 3000000000000 0e+384 -> 9000000000000
-ddfma2144 fma 3 30000000000000 0e+384 -> 90000000000000
-ddfma2145 fma 3 300000000000000 0e+384 -> 900000000000000
-
--- test some edge cases with exact rounding
-ddfma2301 fma 9 9 0e+384 -> 81
-ddfma2302 fma 9 90 0e+384 -> 810
-ddfma2303 fma 9 900 0e+384 -> 8100
-ddfma2304 fma 9 9000 0e+384 -> 81000
-ddfma2305 fma 9 90000 0e+384 -> 810000
-ddfma2306 fma 9 900000 0e+384 -> 8100000
-ddfma2307 fma 9 9000000 0e+384 -> 81000000
-ddfma2308 fma 9 90000000 0e+384 -> 810000000
-ddfma2309 fma 9 900000000 0e+384 -> 8100000000
-ddfma2310 fma 9 9000000000 0e+384 -> 81000000000
-ddfma2311 fma 9 90000000000 0e+384 -> 810000000000
-ddfma2312 fma 9 900000000000 0e+384 -> 8100000000000
-ddfma2313 fma 9 9000000000000 0e+384 -> 81000000000000
-ddfma2314 fma 9 90000000000000 0e+384 -> 810000000000000
-ddfma2315 fma 9 900000000000000 0e+384 -> 8100000000000000
-ddfma2316 fma 9 9000000000000000 0e+384 -> 8.100000000000000E+16 Rounded
-ddfma2317 fma 90 9000000000000000 0e+384 -> 8.100000000000000E+17 Rounded
-ddfma2318 fma 900 9000000000000000 0e+384 -> 8.100000000000000E+18 Rounded
-ddfma2319 fma 9000 9000000000000000 0e+384 -> 8.100000000000000E+19 Rounded
-ddfma2320 fma 90000 9000000000000000 0e+384 -> 8.100000000000000E+20 Rounded
-ddfma2321 fma 900000 9000000000000000 0e+384 -> 8.100000000000000E+21 Rounded
-ddfma2322 fma 9000000 9000000000000000 0e+384 -> 8.100000000000000E+22 Rounded
-ddfma2323 fma 90000000 9000000000000000 0e+384 -> 8.100000000000000E+23 Rounded
-
--- tryzeros cases
-ddfma2504 fma 0E-260 1000E-260 0e+384 -> 0E-398 Clamped
-ddfma2505 fma 100E+260 0E+260 0e+384 -> 0E+369 Clamped
-
--- mixed with zeros
-ddfma2541 fma 0 -1 0e+384 -> 0
-ddfma2542 fma -0 -1 0e+384 -> 0
-ddfma2543 fma 0 1 0e+384 -> 0
-ddfma2544 fma -0 1 0e+384 -> 0
-ddfma2545 fma -1 0 0e+384 -> 0
-ddfma2546 fma -1 -0 0e+384 -> 0
-ddfma2547 fma 1 0 0e+384 -> 0
-ddfma2548 fma 1 -0 0e+384 -> 0
-
-ddfma2551 fma 0.0 -1 0e+384 -> 0.0
-ddfma2552 fma -0.0 -1 0e+384 -> 0.0
-ddfma2553 fma 0.0 1 0e+384 -> 0.0
-ddfma2554 fma -0.0 1 0e+384 -> 0.0
-ddfma2555 fma -1.0 0 0e+384 -> 0.0
-ddfma2556 fma -1.0 -0 0e+384 -> 0.0
-ddfma2557 fma 1.0 0 0e+384 -> 0.0
-ddfma2558 fma 1.0 -0 0e+384 -> 0.0
-
-ddfma2561 fma 0 -1.0 0e+384 -> 0.0
-ddfma2562 fma -0 -1.0 0e+384 -> 0.0
-ddfma2563 fma 0 1.0 0e+384 -> 0.0
-ddfma2564 fma -0 1.0 0e+384 -> 0.0
-ddfma2565 fma -1 0.0 0e+384 -> 0.0
-ddfma2566 fma -1 -0.0 0e+384 -> 0.0
-ddfma2567 fma 1 0.0 0e+384 -> 0.0
-ddfma2568 fma 1 -0.0 0e+384 -> 0.0
-
-ddfma2571 fma 0.0 -1.0 0e+384 -> 0.00
-ddfma2572 fma -0.0 -1.0 0e+384 -> 0.00
-ddfma2573 fma 0.0 1.0 0e+384 -> 0.00
-ddfma2574 fma -0.0 1.0 0e+384 -> 0.00
-ddfma2575 fma -1.0 0.0 0e+384 -> 0.00
-ddfma2576 fma -1.0 -0.0 0e+384 -> 0.00
-ddfma2577 fma 1.0 0.0 0e+384 -> 0.00
-ddfma2578 fma 1.0 -0.0 0e+384 -> 0.00
-
--- Specials
-ddfma2580 fma Inf -Inf 0e+384 -> -Infinity
-ddfma2581 fma Inf -1000 0e+384 -> -Infinity
-ddfma2582 fma Inf -1 0e+384 -> -Infinity
-ddfma2583 fma Inf -0 0e+384 -> NaN Invalid_operation
-ddfma2584 fma Inf 0 0e+384 -> NaN Invalid_operation
-ddfma2585 fma Inf 1 0e+384 -> Infinity
-ddfma2586 fma Inf 1000 0e+384 -> Infinity
-ddfma2587 fma Inf Inf 0e+384 -> Infinity
-ddfma2588 fma -1000 Inf 0e+384 -> -Infinity
-ddfma2589 fma -Inf Inf 0e+384 -> -Infinity
-ddfma2590 fma -1 Inf 0e+384 -> -Infinity
-ddfma2591 fma -0 Inf 0e+384 -> NaN Invalid_operation
-ddfma2592 fma 0 Inf 0e+384 -> NaN Invalid_operation
-ddfma2593 fma 1 Inf 0e+384 -> Infinity
-ddfma2594 fma 1000 Inf 0e+384 -> Infinity
-ddfma2595 fma Inf Inf 0e+384 -> Infinity
-
-ddfma2600 fma -Inf -Inf 0e+384 -> Infinity
-ddfma2601 fma -Inf -1000 0e+384 -> Infinity
-ddfma2602 fma -Inf -1 0e+384 -> Infinity
-ddfma2603 fma -Inf -0 0e+384 -> NaN Invalid_operation
-ddfma2604 fma -Inf 0 0e+384 -> NaN Invalid_operation
-ddfma2605 fma -Inf 1 0e+384 -> -Infinity
-ddfma2606 fma -Inf 1000 0e+384 -> -Infinity
-ddfma2607 fma -Inf Inf 0e+384 -> -Infinity
-ddfma2608 fma -1000 Inf 0e+384 -> -Infinity
-ddfma2609 fma -Inf -Inf 0e+384 -> Infinity
-ddfma2610 fma -1 -Inf 0e+384 -> Infinity
-ddfma2611 fma -0 -Inf 0e+384 -> NaN Invalid_operation
-ddfma2612 fma 0 -Inf 0e+384 -> NaN Invalid_operation
-ddfma2613 fma 1 -Inf 0e+384 -> -Infinity
-ddfma2614 fma 1000 -Inf 0e+384 -> -Infinity
-ddfma2615 fma Inf -Inf 0e+384 -> -Infinity
-
-ddfma2621 fma NaN -Inf 0e+384 -> NaN
-ddfma2622 fma NaN -1000 0e+384 -> NaN
-ddfma2623 fma NaN -1 0e+384 -> NaN
-ddfma2624 fma NaN -0 0e+384 -> NaN
-ddfma2625 fma NaN 0 0e+384 -> NaN
-ddfma2626 fma NaN 1 0e+384 -> NaN
-ddfma2627 fma NaN 1000 0e+384 -> NaN
-ddfma2628 fma NaN Inf 0e+384 -> NaN
-ddfma2629 fma NaN NaN 0e+384 -> NaN
-ddfma2630 fma -Inf NaN 0e+384 -> NaN
-ddfma2631 fma -1000 NaN 0e+384 -> NaN
-ddfma2632 fma -1 NaN 0e+384 -> NaN
-ddfma2633 fma -0 NaN 0e+384 -> NaN
-ddfma2634 fma 0 NaN 0e+384 -> NaN
-ddfma2635 fma 1 NaN 0e+384 -> NaN
-ddfma2636 fma 1000 NaN 0e+384 -> NaN
-ddfma2637 fma Inf NaN 0e+384 -> NaN
-
-ddfma2641 fma sNaN -Inf 0e+384 -> NaN Invalid_operation
-ddfma2642 fma sNaN -1000 0e+384 -> NaN Invalid_operation
-ddfma2643 fma sNaN -1 0e+384 -> NaN Invalid_operation
-ddfma2644 fma sNaN -0 0e+384 -> NaN Invalid_operation
-ddfma2645 fma sNaN 0 0e+384 -> NaN Invalid_operation
-ddfma2646 fma sNaN 1 0e+384 -> NaN Invalid_operation
-ddfma2647 fma sNaN 1000 0e+384 -> NaN Invalid_operation
-ddfma2648 fma sNaN NaN 0e+384 -> NaN Invalid_operation
-ddfma2649 fma sNaN sNaN 0e+384 -> NaN Invalid_operation
-ddfma2650 fma NaN sNaN 0e+384 -> NaN Invalid_operation
-ddfma2651 fma -Inf sNaN 0e+384 -> NaN Invalid_operation
-ddfma2652 fma -1000 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2653 fma -1 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2654 fma -0 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2655 fma 0 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2656 fma 1 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2657 fma 1000 sNaN 0e+384 -> NaN Invalid_operation
-ddfma2658 fma Inf sNaN 0e+384 -> NaN Invalid_operation
-ddfma2659 fma NaN sNaN 0e+384 -> NaN Invalid_operation
-
--- propagating NaNs
-ddfma2661 fma NaN9 -Inf 0e+384 -> NaN9
-ddfma2662 fma NaN8 999 0e+384 -> NaN8
-ddfma2663 fma NaN71 Inf 0e+384 -> NaN71
-ddfma2664 fma NaN6 NaN5 0e+384 -> NaN6
-ddfma2665 fma -Inf NaN4 0e+384 -> NaN4
-ddfma2666 fma -999 NaN33 0e+384 -> NaN33
-ddfma2667 fma Inf NaN2 0e+384 -> NaN2
-
-ddfma2671 fma sNaN99 -Inf 0e+384 -> NaN99 Invalid_operation
-ddfma2672 fma sNaN98 -11 0e+384 -> NaN98 Invalid_operation
-ddfma2673 fma sNaN97 NaN 0e+384 -> NaN97 Invalid_operation
-ddfma2674 fma sNaN16 sNaN94 0e+384 -> NaN16 Invalid_operation
-ddfma2675 fma NaN95 sNaN93 0e+384 -> NaN93 Invalid_operation
-ddfma2676 fma -Inf sNaN92 0e+384 -> NaN92 Invalid_operation
-ddfma2677 fma 088 sNaN91 0e+384 -> NaN91 Invalid_operation
-ddfma2678 fma Inf sNaN90 0e+384 -> NaN90 Invalid_operation
-ddfma2679 fma NaN sNaN89 0e+384 -> NaN89 Invalid_operation
-
-ddfma2681 fma -NaN9 -Inf 0e+384 -> -NaN9
-ddfma2682 fma -NaN8 999 0e+384 -> -NaN8
-ddfma2683 fma -NaN71 Inf 0e+384 -> -NaN71
-ddfma2684 fma -NaN6 -NaN5 0e+384 -> -NaN6
-ddfma2685 fma -Inf -NaN4 0e+384 -> -NaN4
-ddfma2686 fma -999 -NaN33 0e+384 -> -NaN33
-ddfma2687 fma Inf -NaN2 0e+384 -> -NaN2
-
-ddfma2691 fma -sNaN99 -Inf 0e+384 -> -NaN99 Invalid_operation
-ddfma2692 fma -sNaN98 -11 0e+384 -> -NaN98 Invalid_operation
-ddfma2693 fma -sNaN97 NaN 0e+384 -> -NaN97 Invalid_operation
-ddfma2694 fma -sNaN16 -sNaN94 0e+384 -> -NaN16 Invalid_operation
-ddfma2695 fma -NaN95 -sNaN93 0e+384 -> -NaN93 Invalid_operation
-ddfma2696 fma -Inf -sNaN92 0e+384 -> -NaN92 Invalid_operation
-ddfma2697 fma 088 -sNaN91 0e+384 -> -NaN91 Invalid_operation
-ddfma2698 fma Inf -sNaN90 0e+384 -> -NaN90 Invalid_operation
-ddfma2699 fma -NaN -sNaN89 0e+384 -> -NaN89 Invalid_operation
-
-ddfma2701 fma -NaN -Inf 0e+384 -> -NaN
-ddfma2702 fma -NaN 999 0e+384 -> -NaN
-ddfma2703 fma -NaN Inf 0e+384 -> -NaN
-ddfma2704 fma -NaN -NaN 0e+384 -> -NaN
-ddfma2705 fma -Inf -NaN0 0e+384 -> -NaN
-ddfma2706 fma -999 -NaN 0e+384 -> -NaN
-ddfma2707 fma Inf -NaN 0e+384 -> -NaN
-
-ddfma2711 fma -sNaN -Inf 0e+384 -> -NaN Invalid_operation
-ddfma2712 fma -sNaN -11 0e+384 -> -NaN Invalid_operation
-ddfma2713 fma -sNaN00 NaN 0e+384 -> -NaN Invalid_operation
-ddfma2714 fma -sNaN -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2715 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2716 fma -Inf -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2717 fma 088 -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2718 fma Inf -sNaN 0e+384 -> -NaN Invalid_operation
-ddfma2719 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-ddfma2751 fma 1e+277 1e+311 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2752 fma 1e+277 -1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
-ddfma2753 fma -1e+277 1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
-ddfma2754 fma -1e+277 -1e+311 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2755 fma 1e-277 1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2756 fma 1e-277 -1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2757 fma -1e-277 1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2758 fma -1e-277 -1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-ddfma2760 fma 1e-291 1e-101 0e+384 -> 1E-392 Subnormal
-ddfma2761 fma 1e-291 1e-102 0e+384 -> 1E-393 Subnormal
-ddfma2762 fma 1e-291 1e-103 0e+384 -> 1E-394 Subnormal
-ddfma2763 fma 1e-291 1e-104 0e+384 -> 1E-395 Subnormal
-ddfma2764 fma 1e-291 1e-105 0e+384 -> 1E-396 Subnormal
-ddfma2765 fma 1e-291 1e-106 0e+384 -> 1E-397 Subnormal
-ddfma2766 fma 1e-291 1e-107 0e+384 -> 1E-398 Subnormal
-ddfma2767 fma 1e-291 1e-108 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2768 fma 1e-291 1e-109 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2769 fma 1e-291 1e-110 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-ddfma2770 fma 1e+60 1e+321 0e+384 -> 1.000000000000E+381 Clamped
-ddfma2771 fma 1e+60 1e+322 0e+384 -> 1.0000000000000E+382 Clamped
-ddfma2772 fma 1e+60 1e+323 0e+384 -> 1.00000000000000E+383 Clamped
-ddfma2773 fma 1e+60 1e+324 0e+384 -> 1.000000000000000E+384 Clamped
-ddfma2774 fma 1e+60 1e+325 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2775 fma 1e+60 1e+326 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2776 fma 1e+60 1e+327 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2777 fma 1e+60 1e+328 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2778 fma 1e+60 1e+329 0e+384 -> Infinity Overflow Inexact Rounded
-ddfma2779 fma 1e+60 1e+330 0e+384 -> Infinity Overflow Inexact Rounded
-
-ddfma2801 fma 1.0000E-394 1 0e+384 -> 1.0000E-394 Subnormal
-ddfma2802 fma 1.000E-394 1e-1 0e+384 -> 1.000E-395 Subnormal
-ddfma2803 fma 1.00E-394 1e-2 0e+384 -> 1.00E-396 Subnormal
-ddfma2804 fma 1.0E-394 1e-3 0e+384 -> 1.0E-397 Subnormal
-ddfma2805 fma 1.0E-394 1e-4 0e+384 -> 1E-398 Subnormal Rounded
-ddfma2806 fma 1.3E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2807 fma 1.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2808 fma 1.7E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2809 fma 2.3E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2810 fma 2.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2811 fma 2.7E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddfma2812 fma 1.49E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2813 fma 1.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2814 fma 1.51E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2815 fma 2.49E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2816 fma 2.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddfma2817 fma 2.51E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-ddfma2818 fma 1E-394 1e-4 0e+384 -> 1E-398 Subnormal
-ddfma2819 fma 3E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2820 fma 5E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2821 fma 7E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2822 fma 9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddfma2823 fma 9.9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddfma2824 fma 1E-394 -1e-4 0e+384 -> -1E-398 Subnormal
-ddfma2825 fma 3E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2826 fma -5E-394 1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2827 fma 7E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2828 fma -9E-394 1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2829 fma 9.9E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddfma2830 fma 3.0E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddfma2831 fma 1.0E-199 1e-200 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddfma2832 fma 1.0E-199 1e-199 0e+384 -> 1E-398 Subnormal Rounded
-ddfma2833 fma 1.0E-199 1e-198 0e+384 -> 1.0E-397 Subnormal
-ddfma2834 fma 2.0E-199 2e-198 0e+384 -> 4.0E-397 Subnormal
-ddfma2835 fma 4.0E-199 4e-198 0e+384 -> 1.60E-396 Subnormal
-ddfma2836 fma 10.0E-199 10e-198 0e+384 -> 1.000E-395 Subnormal
-ddfma2837 fma 30.0E-199 30e-198 0e+384 -> 9.000E-395 Subnormal
-ddfma2838 fma 40.0E-199 40e-188 0e+384 -> 1.6000E-384 Subnormal
-ddfma2839 fma 40.0E-199 40e-187 0e+384 -> 1.6000E-383
-ddfma2840 fma 40.0E-199 40e-186 0e+384 -> 1.6000E-382
-
--- Long operand overflow may be a different path
-ddfma2870 fma 100 9.999E+383 0e+384 -> Infinity Inexact Overflow Rounded
-ddfma2871 fma 100 -9.999E+383 0e+384 -> -Infinity Inexact Overflow Rounded
-ddfma2872 fma 9.999E+383 100 0e+384 -> Infinity Inexact Overflow Rounded
-ddfma2873 fma -9.999E+383 100 0e+384 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-ddfma2881 fma 1.2347E-355 1.2347E-40 0e+384 -> 1.524E-395 Inexact Rounded Subnormal Underflow
-ddfma2882 fma 1.234E-355 1.234E-40 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2883 fma 1.23E-355 1.23E-40 0e+384 -> 1.513E-395 Inexact Rounded Subnormal Underflow
-ddfma2884 fma 1.2E-355 1.2E-40 0e+384 -> 1.44E-395 Subnormal
-ddfma2885 fma 1.2E-355 1.2E-41 0e+384 -> 1.44E-396 Subnormal
-ddfma2886 fma 1.2E-355 1.2E-42 0e+384 -> 1.4E-397 Subnormal Inexact Rounded Underflow
-ddfma2887 fma 1.2E-355 1.3E-42 0e+384 -> 1.6E-397 Subnormal Inexact Rounded Underflow
-ddfma2888 fma 1.3E-355 1.3E-42 0e+384 -> 1.7E-397 Subnormal Inexact Rounded Underflow
-ddfma2889 fma 1.3E-355 1.3E-43 0e+384 -> 2E-398 Subnormal Inexact Rounded Underflow
-ddfma2890 fma 1.3E-356 1.3E-43 0e+384 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
-
-ddfma2891 fma 1.2345E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddfma2892 fma 1.23456E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddfma2893 fma 1.2345E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2894 fma 1.23456E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddfma2895 fma 1.2345E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-ddfma2896 fma 1.23456E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
-ddfma2900 fma 0.3000000000E-191 0.3000000000E-191 0e+384 -> 9.00000000000000E-384 Subnormal Rounded
-ddfma2901 fma 0.3000000001E-191 0.3000000001E-191 0e+384 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-ddfma2902 fma 9.999999999999999E-383 0.0999999999999 0e+384 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-ddfma2903 fma 9.999999999999999E-383 0.09999999999999 0e+384 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-ddfma2904 fma 9.999999999999999E-383 0.099999999999999 0e+384 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-ddfma2905 fma 9.999999999999999E-383 0.0999999999999999 0e+384 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- prove operands are exact
-ddfma2906 fma 9.999999999999999E-383 1 0e+384 -> 9.999999999999999E-383
-ddfma2907 fma 1 0.09999999999999999 0e+384 -> 0.09999999999999999
--- the next rounds to Nmin
-ddfma2908 fma 9.999999999999999E-383 0.09999999999999999 0e+384 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- hugest
-ddfma2909 fma 9999999999999999 9999999999999999 0e+384 -> 9.999999999999998E+31 Inexact Rounded
-
--- Null tests
-ddfma2990 fma 10 # 0e+384 -> NaN Invalid_operation
-ddfma2991 fma # 10 0e+384 -> NaN Invalid_operation
-
-
--- ADDITION TESTS ------------------------------------------------------
-
--- [first group are 'quick confidence check']
-ddfma3001 fma 1 1 1 -> 2
-ddfma3002 fma 1 2 3 -> 5
-ddfma3003 fma 1 '5.75' '3.3' -> 9.05
-ddfma3004 fma 1 '5' '-3' -> 2
-ddfma3005 fma 1 '-5' '-3' -> -8
-ddfma3006 fma 1 '-7' '2.5' -> -4.5
-ddfma3007 fma 1 '0.7' '0.3' -> 1.0
-ddfma3008 fma 1 '1.25' '1.25' -> 2.50
-ddfma3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-ddfma3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-ddfma3011 fma 1 '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
-ddfma3012 fma 1 '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
-ddfma3013 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-ddfma3014 fma 1 '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
-ddfma3015 fma 1 '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
-ddfma3016 fma 1 '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
-ddfma3017 fma 1 '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
-ddfma3018 fma 1 '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
-ddfma3019 fma 1 '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
-ddfma3020 fma 1 '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
-
-ddfma3021 fma 1 0 1 -> 1
-ddfma3022 fma 1 1 1 -> 2
-ddfma3023 fma 1 2 1 -> 3
-ddfma3024 fma 1 3 1 -> 4
-ddfma3025 fma 1 4 1 -> 5
-ddfma3026 fma 1 5 1 -> 6
-ddfma3027 fma 1 6 1 -> 7
-ddfma3028 fma 1 7 1 -> 8
-ddfma3029 fma 1 8 1 -> 9
-ddfma3030 fma 1 9 1 -> 10
-
--- some carrying effects
-ddfma3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-ddfma3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-ddfma3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-ddfma3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-ddfma3035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-ddfma3039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-ddfma3040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-ddfma3044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-ddfma3045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
--- same, without rounding
-ddfma3046 fma 1 '10000e+9' '7' -> '10000000000007'
-ddfma3047 fma 1 '10000e+9' '70' -> '10000000000070'
-ddfma3048 fma 1 '10000e+9' '700' -> '10000000000700'
-ddfma3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-ddfma3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-ddfma3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-ddfma3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-ddfma3053 fma 1 '12' '7.00' -> '19.00'
-ddfma3054 fma 1 '1.3' '-1.07' -> '0.23'
-ddfma3055 fma 1 '1.3' '-1.30' -> '0.00'
-ddfma3056 fma 1 '1.3' '-2.07' -> '-0.77'
-ddfma3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-ddfma3061 fma 1 1 '0.0001' -> '1.0001'
-ddfma3062 fma 1 1 '0.00001' -> '1.00001'
-ddfma3063 fma 1 1 '0.000001' -> '1.000001'
-ddfma3064 fma 1 1 '0.0000001' -> '1.0000001'
-ddfma3065 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-ddfma3070 fma 1 1 0 -> 1
-ddfma3071 fma 1 1 0. -> 1
-ddfma3072 fma 1 1 .0 -> 1.0
-ddfma3073 fma 1 1 0.0 -> 1.0
-ddfma3074 fma 1 1 0.00 -> 1.00
-ddfma3075 fma 1 0 1 -> 1
-ddfma3076 fma 1 0. 1 -> 1
-ddfma3077 fma 1 .0 1 -> 1.0
-ddfma3078 fma 1 0.0 1 -> 1.0
-ddfma3079 fma 1 0.00 1 -> 1.00
-
--- some carries
-ddfma3080 fma 1 999999998 1 -> 999999999
-ddfma3081 fma 1 999999999 1 -> 1000000000
-ddfma3082 fma 1 99999999 1 -> 100000000
-ddfma3083 fma 1 9999999 1 -> 10000000
-ddfma3084 fma 1 999999 1 -> 1000000
-ddfma3085 fma 1 99999 1 -> 100000
-ddfma3086 fma 1 9999 1 -> 10000
-ddfma3087 fma 1 999 1 -> 1000
-ddfma3088 fma 1 99 1 -> 100
-ddfma3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-ddfma3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-ddfma3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-ddfma3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-ddfma3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-ddfma3094 fma 1 '-56267E-3' 0 -> '-56.267'
-ddfma3095 fma 1 '-56267E-2' 0 -> '-562.67'
-ddfma3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-ddfma3097 fma 1 '-56267E-0' 0 -> '-56267'
-ddfma3098 fma 1 '-5E-10' 0 -> '-5E-10'
-ddfma3099 fma 1 '-5E-7' 0 -> '-5E-7'
-ddfma3100 fma 1 '-5E-6' 0 -> '-0.000005'
-ddfma3101 fma 1 '-5E-5' 0 -> '-0.00005'
-ddfma3102 fma 1 '-5E-4' 0 -> '-0.0005'
-ddfma3103 fma 1 '-5E-1' 0 -> '-0.5'
-ddfma3104 fma 1 '-5E0' 0 -> '-5'
-ddfma3105 fma 1 '-5E1' 0 -> '-50'
-ddfma3106 fma 1 '-5E5' 0 -> '-500000'
-ddfma3107 fma 1 '-5E15' 0 -> '-5000000000000000'
-ddfma3108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddfma3109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddfma3110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddfma3111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-ddfma3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-ddfma3114 fma 1 0 '-56267E-6' -> '-0.056267'
-ddfma3116 fma 1 0 '-56267E-5' -> '-0.56267'
-ddfma3117 fma 1 0 '-56267E-4' -> '-5.6267'
-ddfma3119 fma 1 0 '-56267E-3' -> '-56.267'
-ddfma3120 fma 1 0 '-56267E-2' -> '-562.67'
-ddfma3121 fma 1 0 '-56267E-1' -> '-5626.7'
-ddfma3122 fma 1 0 '-56267E-0' -> '-56267'
-ddfma3123 fma 1 0 '-5E-10' -> '-5E-10'
-ddfma3124 fma 1 0 '-5E-7' -> '-5E-7'
-ddfma3125 fma 1 0 '-5E-6' -> '-0.000005'
-ddfma3126 fma 1 0 '-5E-5' -> '-0.00005'
-ddfma3127 fma 1 0 '-5E-4' -> '-0.0005'
-ddfma3128 fma 1 0 '-5E-1' -> '-0.5'
-ddfma3129 fma 1 0 '-5E0' -> '-5'
-ddfma3130 fma 1 0 '-5E1' -> '-50'
-ddfma3131 fma 1 0 '-5E5' -> '-500000'
-ddfma3132 fma 1 0 '-5E15' -> '-5000000000000000'
-ddfma3133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-ddfma3134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-ddfma3135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-ddfma3136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-ddfma3137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
-ddfma3138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
-ddfma3139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
-ddfma3140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
-ddfma3141 fma 1 1E+11 0.0000 -> '100000000000.0000'
-ddfma3142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
-ddfma3143 fma 1 0.000 1E+12 -> '1000000000000.000'
-ddfma3144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-ddfma3146 fma 1 '00.0' 0 -> '0.0'
-ddfma3147 fma 1 '0.00' 0 -> '0.00'
-ddfma3148 fma 1 0 '0.00' -> '0.00'
-ddfma3149 fma 1 0 '00.0' -> '0.0'
-ddfma3150 fma 1 '00.0' '0.00' -> '0.00'
-ddfma3151 fma 1 '0.00' '00.0' -> '0.00'
-ddfma3152 fma 1 '3' '.3' -> '3.3'
-ddfma3153 fma 1 '3.' '.3' -> '3.3'
-ddfma3154 fma 1 '3.0' '.3' -> '3.3'
-ddfma3155 fma 1 '3.00' '.3' -> '3.30'
-ddfma3156 fma 1 '3' '3' -> '6'
-ddfma3157 fma 1 '3' '+3' -> '6'
-ddfma3158 fma 1 '3' '-3' -> '0'
-ddfma3159 fma 1 '0.3' '-0.3' -> '0.0'
-ddfma3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-ddfma3161 fma 1 '1E+12' '-1' -> '999999999999'
-ddfma3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-ddfma3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-ddfma3164 fma 1 '-1' '1E+12' -> '999999999999'
-ddfma3165 fma 1 '7E+12' '-1' -> '6999999999999'
-ddfma3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-ddfma3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-ddfma3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
--- 1.234567890123456 1234567890123456 1 234567890123456
-ddfma3170 fma 1 '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
-ddfma3171 fma 1 '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
-ddfma3172 fma 1 '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
-ddfma3173 fma 1 '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
-ddfma3174 fma 1 '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
-ddfma3175 fma 1 '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
-ddfma3176 fma 1 '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
-ddfma3177 fma 1 '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
-ddfma3178 fma 1 '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
-ddfma3179 fma 1 '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
-ddfma3180 fma 1 '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
-ddfma3181 fma 1 '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
-ddfma3182 fma 1 '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
-ddfma3183 fma 1 '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddfma3200 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3201 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3202 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3203 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3204 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3205 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3206 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3207 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3208 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddfma3209 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddfma3210 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddfma3211 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddfma3212 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddfma3213 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddfma3214 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddfma3215 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddfma3216 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3217 fma 1 '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
-ddfma3218 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3219 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
-rounding: half_even
-ddfma3220 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3221 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3222 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3223 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3224 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3225 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3226 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3227 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3228 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
-ddfma3229 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
-ddfma3230 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
-ddfma3231 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
-ddfma3232 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
-ddfma3233 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
-ddfma3234 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
-ddfma3235 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
-ddfma3236 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3237 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddfma3238 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3239 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
--- critical few with even bottom digit...
-ddfma3240 fma 1 '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
-ddfma3241 fma 1 '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
-ddfma3242 fma 1 '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
-
-rounding: down
-ddfma3250 fma 1 '1234560123456789' 0 -> '1234560123456789'
-ddfma3251 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
-ddfma3252 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
-ddfma3253 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
-ddfma3254 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
-ddfma3255 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
-ddfma3256 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
-ddfma3257 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
-ddfma3258 fma 1 '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
-ddfma3259 fma 1 '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
-ddfma3260 fma 1 '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
-ddfma3261 fma 1 '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
-ddfma3262 fma 1 '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
-ddfma3263 fma 1 '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
-ddfma3264 fma 1 '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
-ddfma3265 fma 1 '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
-ddfma3266 fma 1 '1234560123456789' 1 -> '1234560123456790'
-ddfma3267 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
-ddfma3268 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
-ddfma3269 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-ddfma3301 fma 1 -1 1 -> 0
-ddfma3302 fma 1 0 1 -> 1
-ddfma3303 fma 1 1 1 -> 2
-ddfma3304 fma 1 12 1 -> 13
-ddfma3305 fma 1 98 1 -> 99
-ddfma3306 fma 1 99 1 -> 100
-ddfma3307 fma 1 100 1 -> 101
-ddfma3308 fma 1 101 1 -> 102
-ddfma3309 fma 1 -1 -1 -> -2
-ddfma3310 fma 1 0 -1 -> -1
-ddfma3311 fma 1 1 -1 -> 0
-ddfma3312 fma 1 12 -1 -> 11
-ddfma3313 fma 1 98 -1 -> 97
-ddfma3314 fma 1 99 -1 -> 98
-ddfma3315 fma 1 100 -1 -> 99
-ddfma3316 fma 1 101 -1 -> 100
-
-ddfma3321 fma 1 -0.01 0.01 -> 0.00
-ddfma3322 fma 1 0.00 0.01 -> 0.01
-ddfma3323 fma 1 0.01 0.01 -> 0.02
-ddfma3324 fma 1 0.12 0.01 -> 0.13
-ddfma3325 fma 1 0.98 0.01 -> 0.99
-ddfma3326 fma 1 0.99 0.01 -> 1.00
-ddfma3327 fma 1 1.00 0.01 -> 1.01
-ddfma3328 fma 1 1.01 0.01 -> 1.02
-ddfma3329 fma 1 -0.01 -0.01 -> -0.02
-ddfma3330 fma 1 0.00 -0.01 -> -0.01
-ddfma3331 fma 1 0.01 -0.01 -> 0.00
-ddfma3332 fma 1 0.12 -0.01 -> 0.11
-ddfma3333 fma 1 0.98 -0.01 -> 0.97
-ddfma3334 fma 1 0.99 -0.01 -> 0.98
-ddfma3335 fma 1 1.00 -0.01 -> 0.99
-ddfma3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-ddfma3340 fma 1 1E+3 0 -> 1000
-ddfma3341 fma 1 1E+15 0 -> 1000000000000000
-ddfma3342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
-ddfma3343 fma 1 1E+20 0 -> 1.000000000000000E+20 Rounded
--- which simply follow from these cases ...
-ddfma3344 fma 1 1E+3 1 -> 1001
-ddfma3345 fma 1 1E+15 1 -> 1000000000000001
-ddfma3346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-ddfma3347 fma 1 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
-ddfma3348 fma 1 1E+3 7 -> 1007
-ddfma3349 fma 1 1E+15 7 -> 1000000000000007
-ddfma3350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-ddfma3351 fma 1 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-ddfma3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
-ddfma3361 fma 1 0E-50 10000E+1 -> 100000.0000000000 Rounded
-ddfma3362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
-ddfma3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-ddfma3364 fma 1 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-ddfma3370 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3371 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_up
-ddfma3372 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3373 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-rounding: half_even
-ddfma3374 fma 1 999999999999999 815 -> 1000000000000814
-ddfma3375 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
-
--- ulp replacement tests
-ddfma3400 fma 1 1 77e-14 -> 1.00000000000077
-ddfma3401 fma 1 1 77e-15 -> 1.000000000000077
-ddfma3402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
-ddfma3403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
-ddfma3404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
-ddfma3405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
-ddfma3406 fma 1 1 77e-299 -> 1.000000000000000 Inexact Rounded
-
-ddfma3410 fma 1 10 77e-14 -> 10.00000000000077
-ddfma3411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
-ddfma3412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
-ddfma3413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
-ddfma3414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
-ddfma3415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
-ddfma3416 fma 1 10 77e-299 -> 10.00000000000000 Inexact Rounded
-
-ddfma3420 fma 1 77e-14 1 -> 1.00000000000077
-ddfma3421 fma 1 77e-15 1 -> 1.000000000000077
-ddfma3422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
-ddfma3423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
-ddfma3424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
-ddfma3425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddfma3426 fma 1 77e-299 1 -> 1.000000000000000 Inexact Rounded
-
-ddfma3430 fma 1 77e-14 10 -> 10.00000000000077
-ddfma3431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
-ddfma3432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
-ddfma3433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
-ddfma3434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddfma3435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddfma3436 fma 1 77e-299 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddfma36440 fma 1 1 -77e-14 -> 0.99999999999923
-ddfma36441 fma 1 1 -77e-15 -> 0.999999999999923
-ddfma36442 fma 1 1 -77e-16 -> 0.9999999999999923
-ddfma36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-ddfma36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-ddfma36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-ddfma36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-ddfma36450 fma 1 10 -77e-14 -> 9.99999999999923
-ddfma36451 fma 1 10 -77e-15 -> 9.999999999999923
-ddfma36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-ddfma36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-ddfma36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-ddfma36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-ddfma36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-ddfma36460 fma 1 -77e-14 1 -> 0.99999999999923
-ddfma36461 fma 1 -77e-15 1 -> 0.999999999999923
-ddfma36462 fma 1 -77e-16 1 -> 0.9999999999999923
-ddfma36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-ddfma36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-ddfma36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
-ddfma36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-ddfma36470 fma 1 -77e-14 10 -> 9.99999999999923
-ddfma36471 fma 1 -77e-15 10 -> 9.999999999999923
-ddfma36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
-ddfma36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
-ddfma36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
-ddfma36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
-ddfma36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-ddfma36480 fma 1 -1 77e-14 -> -0.99999999999923
-ddfma36481 fma 1 -1 77e-15 -> -0.999999999999923
-ddfma36482 fma 1 -1 77e-16 -> -0.9999999999999923
-ddfma36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-ddfma36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-ddfma36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
-ddfma36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-ddfma36490 fma 1 -10 77e-14 -> -9.99999999999923
-ddfma36491 fma 1 -10 77e-15 -> -9.999999999999923
-ddfma36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
-ddfma36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
-ddfma36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
-ddfma36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
-ddfma36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-ddfma36500 fma 1 77e-14 -1 -> -0.99999999999923
-ddfma36501 fma 1 77e-15 -1 -> -0.999999999999923
-ddfma36502 fma 1 77e-16 -1 -> -0.9999999999999923
-ddfma36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-ddfma36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-ddfma36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-ddfma36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-ddfma36510 fma 1 77e-14 -10 -> -9.99999999999923
-ddfma36511 fma 1 77e-15 -10 -> -9.999999999999923
-ddfma36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-ddfma36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-ddfma36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-ddfma36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-ddfma36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
--- and a couple more with longer RHS
-ddfma36520 fma 1 1 -7777e-16 -> 0.9999999999992223
-ddfma36521 fma 1 1 -7777e-17 -> 0.9999999999999222 Inexact Rounded
-ddfma36522 fma 1 1 -7777e-18 -> 0.9999999999999922 Inexact Rounded
-ddfma36523 fma 1 1 -7777e-19 -> 0.9999999999999992 Inexact Rounded
-ddfma36524 fma 1 1 -7777e-20 -> 0.9999999999999999 Inexact Rounded
-ddfma36525 fma 1 1 -7777e-21 -> 1.000000000000000 Inexact Rounded
-ddfma36526 fma 1 1 -7777e-22 -> 1.000000000000000 Inexact Rounded
-
-
--- and some more residue effects and different roundings
-rounding: half_up
-ddfma36540 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma36541 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma36542 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma36543 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma36544 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma36545 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma36546 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma36547 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma36548 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddfma36549 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddfma36550 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddfma36551 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddfma36552 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddfma36553 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddfma36554 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddfma36555 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddfma36556 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma36557 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-ddfma36558 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma36559 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-ddfma36560 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma36561 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma36562 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma36563 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma36564 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma36565 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma36566 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma36567 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma36568 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-ddfma36569 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-ddfma36570 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-ddfma36571 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-ddfma36572 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-ddfma36573 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-ddfma36574 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-ddfma36575 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
-ddfma36576 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma36577 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddfma36578 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma36579 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-ddfma37540 fma 1 '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
-ddfma37541 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-ddfma37542 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-ddfma37550 fma 1 '6543210123456789' 0 -> '6543210123456789'
-ddfma37551 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-ddfma37552 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-ddfma37553 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-ddfma37554 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-ddfma37555 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-ddfma37556 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-ddfma37557 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
-ddfma37558 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-ddfma37559 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-ddfma37560 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-ddfma37561 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-ddfma37562 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-ddfma37563 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-ddfma37564 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-ddfma37565 fma 1 '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
-ddfma37566 fma 1 '6543210123456789' 1 -> '6543210123456790'
-ddfma37567 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-ddfma37568 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-ddfma37569 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-
--- verify a query
-rounding: down
-ddfma37661 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-ddfma37662 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
-ddfma37663 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-ddfma37664 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-ddfma37701 fma 1 5.00 1.00E-3 -> 5.00100
-ddfma37702 fma 1 00.00 0.000 -> 0.000
-ddfma37703 fma 1 00.00 0E-3 -> 0.000
-ddfma37704 fma 1 0E-3 00.00 -> 0.000
-
-ddfma37710 fma 1 0E+3 00.00 -> 0.00
-ddfma37711 fma 1 0E+3 00.0 -> 0.0
-ddfma37712 fma 1 0E+3 00. -> 0
-ddfma37713 fma 1 0E+3 00.E+1 -> 0E+1
-ddfma37714 fma 1 0E+3 00.E+2 -> 0E+2
-ddfma37715 fma 1 0E+3 00.E+3 -> 0E+3
-ddfma37716 fma 1 0E+3 00.E+4 -> 0E+3
-ddfma37717 fma 1 0E+3 00.E+5 -> 0E+3
-ddfma37718 fma 1 0E+3 -00.0 -> 0.0
-ddfma37719 fma 1 0E+3 -00. -> 0
-ddfma37731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-ddfma37720 fma 1 00.00 0E+3 -> 0.00
-ddfma37721 fma 1 00.0 0E+3 -> 0.0
-ddfma37722 fma 1 00. 0E+3 -> 0
-ddfma37723 fma 1 00.E+1 0E+3 -> 0E+1
-ddfma37724 fma 1 00.E+2 0E+3 -> 0E+2
-ddfma37725 fma 1 00.E+3 0E+3 -> 0E+3
-ddfma37726 fma 1 00.E+4 0E+3 -> 0E+3
-ddfma37727 fma 1 00.E+5 0E+3 -> 0E+3
-ddfma37728 fma 1 -00.00 0E+3 -> 0.00
-ddfma37729 fma 1 -00.0 0E+3 -> 0.0
-ddfma37730 fma 1 -00. 0E+3 -> 0
-
-ddfma37732 fma 1 0 0 -> 0
-ddfma37733 fma 1 0 -0 -> 0
-ddfma37734 fma 1 -0 0 -> 0
-ddfma37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-ddfma37736 fma 1 1 -1 -> 0
-ddfma37737 fma 1 -1 -1 -> -2
-ddfma37738 fma 1 1 1 -> 2
-ddfma37739 fma 1 -1 1 -> 0
-
-ddfma37741 fma 1 0 -1 -> -1
-ddfma37742 fma 1 -0 -1 -> -1
-ddfma37743 fma 1 0 1 -> 1
-ddfma37744 fma 1 -0 1 -> 1
-ddfma37745 fma 1 -1 0 -> -1
-ddfma37746 fma 1 -1 -0 -> -1
-ddfma37747 fma 1 1 0 -> 1
-ddfma37748 fma 1 1 -0 -> 1
-
-ddfma37751 fma 1 0.0 -1 -> -1.0
-ddfma37752 fma 1 -0.0 -1 -> -1.0
-ddfma37753 fma 1 0.0 1 -> 1.0
-ddfma37754 fma 1 -0.0 1 -> 1.0
-ddfma37755 fma 1 -1.0 0 -> -1.0
-ddfma37756 fma 1 -1.0 -0 -> -1.0
-ddfma37757 fma 1 1.0 0 -> 1.0
-ddfma37758 fma 1 1.0 -0 -> 1.0
-
-ddfma37761 fma 1 0 -1.0 -> -1.0
-ddfma37762 fma 1 -0 -1.0 -> -1.0
-ddfma37763 fma 1 0 1.0 -> 1.0
-ddfma37764 fma 1 -0 1.0 -> 1.0
-ddfma37765 fma 1 -1 0.0 -> -1.0
-ddfma37766 fma 1 -1 -0.0 -> -1.0
-ddfma37767 fma 1 1 0.0 -> 1.0
-ddfma37768 fma 1 1 -0.0 -> 1.0
-
-ddfma37771 fma 1 0.0 -1.0 -> -1.0
-ddfma37772 fma 1 -0.0 -1.0 -> -1.0
-ddfma37773 fma 1 0.0 1.0 -> 1.0
-ddfma37774 fma 1 -0.0 1.0 -> 1.0
-ddfma37775 fma 1 -1.0 0.0 -> -1.0
-ddfma37776 fma 1 -1.0 -0.0 -> -1.0
-ddfma37777 fma 1 1.0 0.0 -> 1.0
-ddfma37778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-ddfma37780 fma 1 -Inf -Inf -> -Infinity
-ddfma37781 fma 1 -Inf -1000 -> -Infinity
-ddfma37782 fma 1 -Inf -1 -> -Infinity
-ddfma37783 fma 1 -Inf -0 -> -Infinity
-ddfma37784 fma 1 -Inf 0 -> -Infinity
-ddfma37785 fma 1 -Inf 1 -> -Infinity
-ddfma37786 fma 1 -Inf 1000 -> -Infinity
-ddfma37787 fma 1 -1000 -Inf -> -Infinity
-ddfma37788 fma 1 -Inf -Inf -> -Infinity
-ddfma37789 fma 1 -1 -Inf -> -Infinity
-ddfma37790 fma 1 -0 -Inf -> -Infinity
-ddfma37791 fma 1 0 -Inf -> -Infinity
-ddfma37792 fma 1 1 -Inf -> -Infinity
-ddfma37793 fma 1 1000 -Inf -> -Infinity
-ddfma37794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-ddfma37800 fma 1 Inf -Inf -> NaN Invalid_operation
-ddfma37801 fma 1 Inf -1000 -> Infinity
-ddfma37802 fma 1 Inf -1 -> Infinity
-ddfma37803 fma 1 Inf -0 -> Infinity
-ddfma37804 fma 1 Inf 0 -> Infinity
-ddfma37805 fma 1 Inf 1 -> Infinity
-ddfma37806 fma 1 Inf 1000 -> Infinity
-ddfma37807 fma 1 Inf Inf -> Infinity
-ddfma37808 fma 1 -1000 Inf -> Infinity
-ddfma37809 fma 1 -Inf Inf -> NaN Invalid_operation
-ddfma37810 fma 1 -1 Inf -> Infinity
-ddfma37811 fma 1 -0 Inf -> Infinity
-ddfma37812 fma 1 0 Inf -> Infinity
-ddfma37813 fma 1 1 Inf -> Infinity
-ddfma37814 fma 1 1000 Inf -> Infinity
-ddfma37815 fma 1 Inf Inf -> Infinity
-
-ddfma37821 fma 1 NaN -Inf -> NaN
-ddfma37822 fma 1 NaN -1000 -> NaN
-ddfma37823 fma 1 NaN -1 -> NaN
-ddfma37824 fma 1 NaN -0 -> NaN
-ddfma37825 fma 1 NaN 0 -> NaN
-ddfma37826 fma 1 NaN 1 -> NaN
-ddfma37827 fma 1 NaN 1000 -> NaN
-ddfma37828 fma 1 NaN Inf -> NaN
-ddfma37829 fma 1 NaN NaN -> NaN
-ddfma37830 fma 1 -Inf NaN -> NaN
-ddfma37831 fma 1 -1000 NaN -> NaN
-ddfma37832 fma 1 -1 NaN -> NaN
-ddfma37833 fma 1 -0 NaN -> NaN
-ddfma37834 fma 1 0 NaN -> NaN
-ddfma37835 fma 1 1 NaN -> NaN
-ddfma37836 fma 1 1000 NaN -> NaN
-ddfma37837 fma 1 Inf NaN -> NaN
-
-ddfma37841 fma 1 sNaN -Inf -> NaN Invalid_operation
-ddfma37842 fma 1 sNaN -1000 -> NaN Invalid_operation
-ddfma37843 fma 1 sNaN -1 -> NaN Invalid_operation
-ddfma37844 fma 1 sNaN -0 -> NaN Invalid_operation
-ddfma37845 fma 1 sNaN 0 -> NaN Invalid_operation
-ddfma37846 fma 1 sNaN 1 -> NaN Invalid_operation
-ddfma37847 fma 1 sNaN 1000 -> NaN Invalid_operation
-ddfma37848 fma 1 sNaN NaN -> NaN Invalid_operation
-ddfma37849 fma 1 sNaN sNaN -> NaN Invalid_operation
-ddfma37850 fma 1 NaN sNaN -> NaN Invalid_operation
-ddfma37851 fma 1 -Inf sNaN -> NaN Invalid_operation
-ddfma37852 fma 1 -1000 sNaN -> NaN Invalid_operation
-ddfma37853 fma 1 -1 sNaN -> NaN Invalid_operation
-ddfma37854 fma 1 -0 sNaN -> NaN Invalid_operation
-ddfma37855 fma 1 0 sNaN -> NaN Invalid_operation
-ddfma37856 fma 1 1 sNaN -> NaN Invalid_operation
-ddfma37857 fma 1 1000 sNaN -> NaN Invalid_operation
-ddfma37858 fma 1 Inf sNaN -> NaN Invalid_operation
-ddfma37859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddfma37861 fma 1 NaN1 -Inf -> NaN1
-ddfma37862 fma 1 +NaN2 -1000 -> NaN2
-ddfma37863 fma 1 NaN3 1000 -> NaN3
-ddfma37864 fma 1 NaN4 Inf -> NaN4
-ddfma37865 fma 1 NaN5 +NaN6 -> NaN5
-ddfma37866 fma 1 -Inf NaN7 -> NaN7
-ddfma37867 fma 1 -1000 NaN8 -> NaN8
-ddfma37868 fma 1 1000 NaN9 -> NaN9
-ddfma37869 fma 1 Inf +NaN10 -> NaN10
-ddfma37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-ddfma37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-ddfma37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-ddfma37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-ddfma37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddfma37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-ddfma37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-ddfma37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-ddfma37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-ddfma37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-ddfma37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddfma37882 fma 1 -NaN26 NaN28 -> -NaN26
-ddfma37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddfma37884 fma 1 1000 -NaN30 -> -NaN30
-ddfma37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-ddfma37575 fma 1 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
-ddfma37576 fma 1 -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-ddfma37972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-ddfma37973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-ddfma37976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-ddfma37977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-ddfma37978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-ddfma37979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-ddfma37980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-ddfma37981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-ddfma37984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-ddfma37985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-ddfma37986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-ddfma37989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-ddfma37994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-ddfma37997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-ddfma371100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-ddfma371101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-ddfma371103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-ddfma371104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-ddfma371105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-ddfma371106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-ddfma371107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-ddfma371108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-ddfma371109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-ddfma371110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-ddfma371111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-ddfma371113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-ddfma371114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-ddfma371115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-ddfma371116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-ddfma371117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-ddfma371118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-ddfma371119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-ddfma371300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-ddfma371311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-ddfma371312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-ddfma371313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-ddfma371314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-ddfma371315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-ddfma371316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-ddfma371317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-ddfma371318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-ddfma371319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-ddfma371320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-ddfma371321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-ddfma371325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-ddfma371340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-ddfma371341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-ddfma371349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-ddfma371350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-ddfma371351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-ddfma371352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-ddfma371353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-ddfma371354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-ddfma371355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-ddfma371356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-ddfma371357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-ddfma371358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-ddfma371359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-ddfma371360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-ddfma371361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-ddfma371365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-ddfma371396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-ddfma371420 fma 1 0 1.123456789012345 -> 1.123456789012345
-ddfma371421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-ddfma371422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-ddfma371423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-ddfma371424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-ddfma371425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-ddfma371426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-ddfma371427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-ddfma371428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-ddfma371429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-ddfma371430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-ddfma371431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-ddfma371432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-ddfma371433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-ddfma371434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-ddfma371435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-ddfma371436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-ddfma371437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-ddfma371438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-ddfma371439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-ddfma371440 fma 1 1.123456789012345 0 -> 1.123456789012345
-ddfma371441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-ddfma371442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-ddfma371443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-ddfma371444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-ddfma371445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-ddfma371446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-ddfma371447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-ddfma371448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-ddfma371449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-ddfma371450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-ddfma371451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-ddfma371452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-ddfma371453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-ddfma371454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-ddfma371455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-ddfma371456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-ddfma371457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-ddfma371458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-ddfma371459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-ddfma371460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-ddfma371461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-ddfma371462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-ddfma371463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-ddfma371464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-ddfma371465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-ddfma371466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-ddfma371467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-ddfma371468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-ddfma371469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-ddfma371470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-ddfma371471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-ddfma371472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-ddfma371473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-ddfma371474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-ddfma371475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-ddfma371476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-ddfma371477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-ddfma371478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-ddfma371479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-ddfma371500 fma 1 0 0E-19 -> 0E-19
-ddfma371501 fma 1 -0 0E-19 -> 0E-19
-ddfma371502 fma 1 0 -0E-19 -> 0E-19
-ddfma371503 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371511 fma 1 -11 11 -> 0
-ddfma371512 fma 1 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-ddfma371520 fma 1 0 0E-19 -> 0E-19
-ddfma371521 fma 1 -0 0E-19 -> 0E-19
-ddfma371522 fma 1 0 -0E-19 -> 0E-19
-ddfma371523 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371531 fma 1 -11 11 -> 0
-ddfma371532 fma 1 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-ddfma371540 fma 1 0 0E-19 -> 0E-19
-ddfma371541 fma 1 -0 0E-19 -> 0E-19
-ddfma371542 fma 1 0 -0E-19 -> 0E-19
-ddfma371543 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371551 fma 1 -11 11 -> 0
-ddfma371552 fma 1 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-ddfma371560 fma 1 0 0E-19 -> 0E-19
-ddfma371561 fma 1 -0 0E-19 -> 0E-19
-ddfma371562 fma 1 0 -0E-19 -> 0E-19
-ddfma371563 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371571 fma 1 -11 11 -> 0
-ddfma371572 fma 1 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-ddfma371580 fma 1 0 0E-19 -> 0E-19
-ddfma371581 fma 1 -0 0E-19 -> 0E-19
-ddfma371582 fma 1 0 -0E-19 -> 0E-19
-ddfma371583 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371591 fma 1 -11 11 -> 0
-ddfma371592 fma 1 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-ddfma371600 fma 1 0 0E-19 -> 0E-19
-ddfma371601 fma 1 -0 0E-19 -> 0E-19
-ddfma371602 fma 1 0 -0E-19 -> 0E-19
-ddfma371603 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371611 fma 1 -11 11 -> 0
-ddfma371612 fma 1 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-ddfma371620 fma 1 0 0E-19 -> 0E-19
-ddfma371621 fma 1 -0 0E-19 -> -0E-19 -- *
-ddfma371622 fma 1 0 -0E-19 -> -0E-19 -- *
-ddfma371623 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-ddfma371631 fma 1 -11 11 -> -0 -- *
-ddfma371632 fma 1 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-ddfma371701 fma 1 130E-2 120E-2 -> 2.50
-ddfma371702 fma 1 130E-2 12E-1 -> 2.50
-ddfma371703 fma 1 130E-2 1E0 -> 2.30
-ddfma371704 fma 1 1E2 1E4 -> 1.01E+4
-ddfma371705 fma 1 130E-2 -120E-2 -> 0.10
-ddfma371706 fma 1 130E-2 -12E-1 -> 0.10
-ddfma371707 fma 1 130E-2 -1E0 -> 0.30
-ddfma371708 fma 1 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-ddfma375001 fma 1 1234567890123456 1 -> 1234567890123457
-ddfma375002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-ddfma375003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-ddfma375004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-ddfma375005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-ddfma375006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-ddfma375007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-ddfma375008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-ddfma375009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-ddfma375010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-ddfma375011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-ddfma375012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-ddfma375013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-ddfma375014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-ddfma375015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-ddfma375016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-ddfma375017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-ddfma375018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-ddfma375019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-ddfma375020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-ddfma375021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-ddfma375030 fma 1 12345678 1 -> 12345679
-ddfma375031 fma 1 12345678 0.1 -> 12345678.1
-ddfma375032 fma 1 12345678 0.12 -> 12345678.12
-ddfma375033 fma 1 12345678 0.123 -> 12345678.123
-ddfma375034 fma 1 12345678 0.1234 -> 12345678.1234
-ddfma375035 fma 1 12345678 0.12345 -> 12345678.12345
-ddfma375036 fma 1 12345678 0.123456 -> 12345678.123456
-ddfma375037 fma 1 12345678 0.1234567 -> 12345678.1234567
-ddfma375038 fma 1 12345678 0.12345678 -> 12345678.12345678
-ddfma375039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-ddfma375040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-ddfma375041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-ddfma375042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-ddfma375043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-ddfma375044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-ddfma375045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-ddfma375046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-ddfma375047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-ddfma375048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-ddfma375049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-ddfma375050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-ddfma375051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-ddfma375052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-ddfma375053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-ddfma375054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-ddfma375055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-ddfma375056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-ddfma375057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-ddfma375060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-ddfma375061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-ddfma375062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-ddfma375063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-ddfma375064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-ddfma375065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-ddfma375066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-ddfma375067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-ddfma375070 fma 1 12345678 1E-8 -> 12345678.00000001
-ddfma375071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-ddfma375072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-ddfma375073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-ddfma375074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-ddfma375075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-ddfma375076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-ddfma375077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-ddfma375078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-ddfma375079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-ddfma375080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-ddfma375081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-ddfma375082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-ddfma375083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-ddfma375084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-ddfma375085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-ddfma375086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-ddfma375087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-ddfma375088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-ddfma375089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- desctructive subtraction (from remainder tests)
-
--- +++ some of these will be off-by-one remainder vs remainderNear
-
-ddfma4000 fma -1234567890123454 1.000000000000001 1234567890123456 -> 0.765432109876546
-ddfma4001 fma -1234567890123443 1.00000000000001 1234567890123456 -> 0.65432109876557
-ddfma4002 fma -1234567890123332 1.0000000000001 1234567890123456 -> 0.5432109876668
-ddfma4003 fma -308641972530863 4.000000000000001 1234567890123455 -> 2.691358027469137
-ddfma4004 fma -308641972530863 4.000000000000001 1234567890123456 -> 3.691358027469137
-ddfma4005 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
-ddfma4006 fma -246913578024691 4.99999999999999 1234567890123456 -> 3.46913578024691
-ddfma4007 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
-ddfma4008 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
-ddfma4009 fma -246913578024690 5.00000000000001 1234567890123456 -> 3.53086421975310
-ddfma4010 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
-ddfma4011 fma -1234567890123455 1.000000000000001 1234567890123456 -> -0.234567890123455
-ddfma4012 fma -1234567890123444 1.00000000000001 1234567890123456 -> -0.34567890123444
-ddfma4013 fma -1234567890123333 1.0000000000001 1234567890123456 -> -0.4567890123333
-ddfma4014 fma -308641972530864 4.000000000000001 1234567890123455 -> -1.308641972530864
-ddfma4015 fma -308641972530864 4.000000000000001 1234567890123456 -> -0.308641972530864
-ddfma4016 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
-ddfma4017 fma -246913578024692 4.99999999999999 1234567890123456 -> -1.53086421975308
-ddfma4018 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
-ddfma4019 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
-ddfma4020 fma -246913578024691 5.00000000000001 1234567890123456 -> -1.46913578024691
-ddfma4021 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
-
-
--- Null tests
-ddfma39990 fma 1 10 # -> NaN Invalid_operation
-ddfma39991 fma 1 # 10 -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ddFMA.decTest -- decDouble Fused Multiply Add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+ddfma0001 fma 1 1 1 -> 2
+ddfma0002 fma 1 1 2 -> 3
+ddfma0003 fma 2 2 3 -> 7
+ddfma0004 fma 9 9 9 -> 90
+ddfma0005 fma -1 1 1 -> 0
+ddfma0006 fma -1 1 2 -> 1
+ddfma0007 fma -2 2 3 -> -1
+ddfma0008 fma -9 9 9 -> -72
+ddfma0011 fma 1 -1 1 -> 0
+ddfma0012 fma 1 -1 2 -> 1
+ddfma0013 fma 2 -2 3 -> -1
+ddfma0014 fma 9 -9 9 -> -72
+ddfma0015 fma 1 1 -1 -> 0
+ddfma0016 fma 1 1 -2 -> -1
+ddfma0017 fma 2 2 -3 -> 1
+ddfma0018 fma 9 9 -9 -> 72
+
+-- non-integer exacts
+ddfma0100 fma 25.2 63.6 -438 -> 1164.72
+ddfma0101 fma 0.301 0.380 334 -> 334.114380
+ddfma0102 fma 49.2 -4.8 23.3 -> -212.86
+ddfma0103 fma 4.22 0.079 -94.6 -> -94.26662
+ddfma0104 fma 903 0.797 0.887 -> 720.578
+ddfma0105 fma 6.13 -161 65.9 -> -921.03
+ddfma0106 fma 28.2 727 5.45 -> 20506.85
+ddfma0107 fma 4 605 688 -> 3108
+ddfma0108 fma 93.3 0.19 0.226 -> 17.953
+ddfma0109 fma 0.169 -341 5.61 -> -52.019
+ddfma0110 fma -72.2 30 -51.2 -> -2217.2
+ddfma0111 fma -0.409 13 20.4 -> 15.083
+ddfma0112 fma 317 77.0 19.0 -> 24428.0
+ddfma0113 fma 47 6.58 1.62 -> 310.88
+ddfma0114 fma 1.36 0.984 0.493 -> 1.83124
+ddfma0115 fma 72.7 274 1.56 -> 19921.36
+ddfma0116 fma 335 847 83 -> 283828
+ddfma0117 fma 666 0.247 25.4 -> 189.902
+ddfma0118 fma -3.87 3.06 78.0 -> 66.1578
+ddfma0119 fma 0.742 192 35.6 -> 178.064
+ddfma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- -> 7.123356429257969E+16
+ddfma0201 fma 27583489.6645 2582471078.04 2593183.42371 -> 7.123356429257970E+16 Inexact Rounded
+-- -> 22813275328.80506
+ddfma0208 fma 24280.355566 939577.397653 2032.013252 -> 22813275328.80507 Inexact Rounded
+-- -> -2.030397734278062E+16
+ddfma0209 fma 7848976432 -2586831.2281 137903.517909 -> -2.030397734278061E+16 Inexact Rounded
+-- -> 2040774094814.077
+ddfma0217 fma 56890.388731 35872030.4255 339337.123410 -> 2040774094814.078 Inexact Rounded
+-- -> 2.714469575205049E+18
+ddfma0220 fma 7533543.57445 360317763928 5073392.31638 -> 2.714469575205050E+18 Inexact Rounded
+-- -> 1.011676297716716E+19
+ddfma0223 fma 739945255.563 13672312784.1 -994381.53572 -> 1.011676297716715E+19 Inexact Rounded
+-- -> -2.914135721455315E+23
+ddfma0224 fma -413510957218 704729988550 9234162614.0 -> -2.914135721455314E+23 Inexact Rounded
+-- -> 2.620119863365786E+17
+ddfma0226 fma 437484.00601 598906432790 894450638.442 -> 2.620119863365787E+17 Inexact Rounded
+-- -> 1.272647995808178E+19
+ddfma0253 fma 73287556929 173651305.784 -358312568.389 -> 1.272647995808177E+19 Inexact Rounded
+-- -> -1.753769320861851E+18
+ddfma0257 fma 203258304486 -8628278.8066 153127.446727 -> -1.753769320861850E+18 Inexact Rounded
+-- -> -1.550737835263346E+17
+ddfma0260 fma 42560533.1774 -3643605282.86 178277.96377 -> -1.550737835263347E+17 Inexact Rounded
+-- -> 2.897624620576005E+22
+ddfma0269 fma 142656587375 203118879670 604576103991 -> 2.897624620576004E+22 Inexact Rounded
+
+-- Cases where multiply would overflow or underflow if separate
+fma0300 fma 9e+384 10 0 -> Infinity Overflow Inexact Rounded
+fma0301 fma 1e+384 10 0 -> Infinity Overflow Inexact Rounded
+fma0302 fma 1e+384 10 -1e+384 -> 9.000000000000000E+384 Clamped
+fma0303 fma 1e+384 10 -9e+384 -> 1.000000000000000E+384 Clamped
+-- subnormal etc.
+fma0305 fma 1e-398 0.1 0 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+fma0306 fma 1e-398 0.1 1 -> 1.000000000000000 Inexact Rounded
+fma0307 fma 1e-398 0.1 1e-398 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+-- Infinite combinations
+ddfma0800 fma Inf Inf Inf -> Infinity
+ddfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
+ddfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
+ddfma0803 fma Inf -Inf -Inf -> -Infinity
+ddfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
+ddfma0805 fma -Inf Inf -Inf -> -Infinity
+ddfma0806 fma -Inf -Inf Inf -> Infinity
+ddfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+
+-- Triple NaN propagation
+ddfma0900 fma NaN2 NaN3 NaN5 -> NaN2
+ddfma0901 fma 0 NaN3 NaN5 -> NaN3
+ddfma0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+ddfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+ddfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+ddfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+ddfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+ddfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+ddfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+
+-- sanity checks
+ddfma2000 fma 2 2 0e+384 -> 4
+ddfma2001 fma 2 3 0e+384 -> 6
+ddfma2002 fma 5 1 0e+384 -> 5
+ddfma2003 fma 5 2 0e+384 -> 10
+ddfma2004 fma 1.20 2 0e+384 -> 2.40
+ddfma2005 fma 1.20 0 0e+384 -> 0.00
+ddfma2006 fma 1.20 -2 0e+384 -> -2.40
+ddfma2007 fma -1.20 2 0e+384 -> -2.40
+ddfma2008 fma -1.20 0 0e+384 -> 0.00
+ddfma2009 fma -1.20 -2 0e+384 -> 2.40
+ddfma2010 fma 5.09 7.1 0e+384 -> 36.139
+ddfma2011 fma 2.5 4 0e+384 -> 10.0
+ddfma2012 fma 2.50 4 0e+384 -> 10.00
+ddfma2013 fma 1.23456789 1.00000000 0e+384 -> 1.234567890000000 Rounded
+ddfma2015 fma 2.50 4 0e+384 -> 10.00
+ddfma2016 fma 9.999999999 9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
+ddfma2017 fma 9.999999999 -9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
+ddfma2018 fma -9.999999999 9.999999999 0e+384 -> -99.99999998000000 Inexact Rounded
+ddfma2019 fma -9.999999999 -9.999999999 0e+384 -> 99.99999998000000 Inexact Rounded
+
+-- zeros, etc.
+ddfma2021 fma 0 0 0e+384 -> 0
+ddfma2022 fma 0 -0 0e+384 -> 0
+ddfma2023 fma -0 0 0e+384 -> 0
+ddfma2024 fma -0 -0 0e+384 -> 0
+ddfma2025 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2026 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2027 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2028 fma -0.0 -0.0 0e+384 -> 0.00
+ddfma2030 fma 5.00 1E-3 0e+384 -> 0.00500
+ddfma2031 fma 00.00 0.000 0e+384 -> 0.00000
+ddfma2032 fma 00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2033 fma 0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2034 fma -5.00 1E-3 0e+384 -> -0.00500
+ddfma2035 fma -00.00 0.000 0e+384 -> 0.00000
+ddfma2036 fma -00.00 0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2037 fma -0E-3 00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2038 fma 5.00 -1E-3 0e+384 -> -0.00500
+ddfma2039 fma 00.00 -0.000 0e+384 -> 0.00000
+ddfma2040 fma 00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2041 fma 0E-3 -00.00 0e+384 -> 0.00000 -- lhs is 0
+ddfma2042 fma -5.00 -1E-3 0e+384 -> 0.00500
+ddfma2043 fma -00.00 -0.000 0e+384 -> 0.00000
+ddfma2044 fma -00.00 -0E-3 0e+384 -> 0.00000 -- rhs is 0
+ddfma2045 fma -0E-3 -00.00 -0e+384 -> 0.00000 -- lhs is 0
+ddfma2046 fma -0E-3 00.00 -0e+384 -> -0.00000
+ddfma2047 fma 0E-3 -00.00 -0e+384 -> -0.00000
+ddfma2048 fma 0E-3 00.00 -0e+384 -> 0.00000
+
+-- examples from decarith
+ddfma2050 fma 1.20 3 0e+384 -> 3.60
+ddfma2051 fma 7 3 0e+384 -> 21
+ddfma2052 fma 0.9 0.8 0e+384 -> 0.72
+ddfma2053 fma 0.9 -0 0e+384 -> 0.0
+ddfma2054 fma 654321 654321 0e+384 -> 428135971041
+
+ddfma2060 fma 123.45 1e7 0e+384 -> 1.2345E+9
+ddfma2061 fma 123.45 1e8 0e+384 -> 1.2345E+10
+ddfma2062 fma 123.45 1e+9 0e+384 -> 1.2345E+11
+ddfma2063 fma 123.45 1e10 0e+384 -> 1.2345E+12
+ddfma2064 fma 123.45 1e11 0e+384 -> 1.2345E+13
+ddfma2065 fma 123.45 1e12 0e+384 -> 1.2345E+14
+ddfma2066 fma 123.45 1e13 0e+384 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+ddfma2080 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
+ddfma2084 fma 0.1 1230123456456789 0e+384 -> 123012345645678.9
+ddfma2090 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
+ddfma2094 fma 1230123456456789 0.1 0e+384 -> 123012345645678.9
+
+-- test some more edge cases and carries
+ddfma2101 fma 9 9 0e+384 -> 81
+ddfma2102 fma 9 90 0e+384 -> 810
+ddfma2103 fma 9 900 0e+384 -> 8100
+ddfma2104 fma 9 9000 0e+384 -> 81000
+ddfma2105 fma 9 90000 0e+384 -> 810000
+ddfma2106 fma 9 900000 0e+384 -> 8100000
+ddfma2107 fma 9 9000000 0e+384 -> 81000000
+ddfma2108 fma 9 90000000 0e+384 -> 810000000
+ddfma2109 fma 9 900000000 0e+384 -> 8100000000
+ddfma2110 fma 9 9000000000 0e+384 -> 81000000000
+ddfma2111 fma 9 90000000000 0e+384 -> 810000000000
+ddfma2112 fma 9 900000000000 0e+384 -> 8100000000000
+ddfma2113 fma 9 9000000000000 0e+384 -> 81000000000000
+ddfma2114 fma 9 90000000000000 0e+384 -> 810000000000000
+ddfma2115 fma 9 900000000000000 0e+384 -> 8100000000000000
+--ddfma2116 fma 9 9000000000000000 0e+384 -> 81000000000000000
+--ddfma2117 fma 9 90000000000000000 0e+384 -> 810000000000000000
+--ddfma2118 fma 9 900000000000000000 0e+384 -> 8100000000000000000
+--ddfma2119 fma 9 9000000000000000000 0e+384 -> 81000000000000000000
+--ddfma2120 fma 9 90000000000000000000 0e+384 -> 810000000000000000000
+--ddfma2121 fma 9 900000000000000000000 0e+384 -> 8100000000000000000000
+--ddfma2122 fma 9 9000000000000000000000 0e+384 -> 81000000000000000000000
+--ddfma2123 fma 9 90000000000000000000000 0e+384 -> 810000000000000000000000
+-- test some more edge cases without carries
+ddfma2131 fma 3 3 0e+384 -> 9
+ddfma2132 fma 3 30 0e+384 -> 90
+ddfma2133 fma 3 300 0e+384 -> 900
+ddfma2134 fma 3 3000 0e+384 -> 9000
+ddfma2135 fma 3 30000 0e+384 -> 90000
+ddfma2136 fma 3 300000 0e+384 -> 900000
+ddfma2137 fma 3 3000000 0e+384 -> 9000000
+ddfma2138 fma 3 30000000 0e+384 -> 90000000
+ddfma2139 fma 3 300000000 0e+384 -> 900000000
+ddfma2140 fma 3 3000000000 0e+384 -> 9000000000
+ddfma2141 fma 3 30000000000 0e+384 -> 90000000000
+ddfma2142 fma 3 300000000000 0e+384 -> 900000000000
+ddfma2143 fma 3 3000000000000 0e+384 -> 9000000000000
+ddfma2144 fma 3 30000000000000 0e+384 -> 90000000000000
+ddfma2145 fma 3 300000000000000 0e+384 -> 900000000000000
+
+-- test some edge cases with exact rounding
+ddfma2301 fma 9 9 0e+384 -> 81
+ddfma2302 fma 9 90 0e+384 -> 810
+ddfma2303 fma 9 900 0e+384 -> 8100
+ddfma2304 fma 9 9000 0e+384 -> 81000
+ddfma2305 fma 9 90000 0e+384 -> 810000
+ddfma2306 fma 9 900000 0e+384 -> 8100000
+ddfma2307 fma 9 9000000 0e+384 -> 81000000
+ddfma2308 fma 9 90000000 0e+384 -> 810000000
+ddfma2309 fma 9 900000000 0e+384 -> 8100000000
+ddfma2310 fma 9 9000000000 0e+384 -> 81000000000
+ddfma2311 fma 9 90000000000 0e+384 -> 810000000000
+ddfma2312 fma 9 900000000000 0e+384 -> 8100000000000
+ddfma2313 fma 9 9000000000000 0e+384 -> 81000000000000
+ddfma2314 fma 9 90000000000000 0e+384 -> 810000000000000
+ddfma2315 fma 9 900000000000000 0e+384 -> 8100000000000000
+ddfma2316 fma 9 9000000000000000 0e+384 -> 8.100000000000000E+16 Rounded
+ddfma2317 fma 90 9000000000000000 0e+384 -> 8.100000000000000E+17 Rounded
+ddfma2318 fma 900 9000000000000000 0e+384 -> 8.100000000000000E+18 Rounded
+ddfma2319 fma 9000 9000000000000000 0e+384 -> 8.100000000000000E+19 Rounded
+ddfma2320 fma 90000 9000000000000000 0e+384 -> 8.100000000000000E+20 Rounded
+ddfma2321 fma 900000 9000000000000000 0e+384 -> 8.100000000000000E+21 Rounded
+ddfma2322 fma 9000000 9000000000000000 0e+384 -> 8.100000000000000E+22 Rounded
+ddfma2323 fma 90000000 9000000000000000 0e+384 -> 8.100000000000000E+23 Rounded
+
+-- tryzeros cases
+ddfma2504 fma 0E-260 1000E-260 0e+384 -> 0E-398 Clamped
+ddfma2505 fma 100E+260 0E+260 0e+384 -> 0E+369 Clamped
+
+-- mixed with zeros
+ddfma2541 fma 0 -1 0e+384 -> 0
+ddfma2542 fma -0 -1 0e+384 -> 0
+ddfma2543 fma 0 1 0e+384 -> 0
+ddfma2544 fma -0 1 0e+384 -> 0
+ddfma2545 fma -1 0 0e+384 -> 0
+ddfma2546 fma -1 -0 0e+384 -> 0
+ddfma2547 fma 1 0 0e+384 -> 0
+ddfma2548 fma 1 -0 0e+384 -> 0
+
+ddfma2551 fma 0.0 -1 0e+384 -> 0.0
+ddfma2552 fma -0.0 -1 0e+384 -> 0.0
+ddfma2553 fma 0.0 1 0e+384 -> 0.0
+ddfma2554 fma -0.0 1 0e+384 -> 0.0
+ddfma2555 fma -1.0 0 0e+384 -> 0.0
+ddfma2556 fma -1.0 -0 0e+384 -> 0.0
+ddfma2557 fma 1.0 0 0e+384 -> 0.0
+ddfma2558 fma 1.0 -0 0e+384 -> 0.0
+
+ddfma2561 fma 0 -1.0 0e+384 -> 0.0
+ddfma2562 fma -0 -1.0 0e+384 -> 0.0
+ddfma2563 fma 0 1.0 0e+384 -> 0.0
+ddfma2564 fma -0 1.0 0e+384 -> 0.0
+ddfma2565 fma -1 0.0 0e+384 -> 0.0
+ddfma2566 fma -1 -0.0 0e+384 -> 0.0
+ddfma2567 fma 1 0.0 0e+384 -> 0.0
+ddfma2568 fma 1 -0.0 0e+384 -> 0.0
+
+ddfma2571 fma 0.0 -1.0 0e+384 -> 0.00
+ddfma2572 fma -0.0 -1.0 0e+384 -> 0.00
+ddfma2573 fma 0.0 1.0 0e+384 -> 0.00
+ddfma2574 fma -0.0 1.0 0e+384 -> 0.00
+ddfma2575 fma -1.0 0.0 0e+384 -> 0.00
+ddfma2576 fma -1.0 -0.0 0e+384 -> 0.00
+ddfma2577 fma 1.0 0.0 0e+384 -> 0.00
+ddfma2578 fma 1.0 -0.0 0e+384 -> 0.00
+
+-- Specials
+ddfma2580 fma Inf -Inf 0e+384 -> -Infinity
+ddfma2581 fma Inf -1000 0e+384 -> -Infinity
+ddfma2582 fma Inf -1 0e+384 -> -Infinity
+ddfma2583 fma Inf -0 0e+384 -> NaN Invalid_operation
+ddfma2584 fma Inf 0 0e+384 -> NaN Invalid_operation
+ddfma2585 fma Inf 1 0e+384 -> Infinity
+ddfma2586 fma Inf 1000 0e+384 -> Infinity
+ddfma2587 fma Inf Inf 0e+384 -> Infinity
+ddfma2588 fma -1000 Inf 0e+384 -> -Infinity
+ddfma2589 fma -Inf Inf 0e+384 -> -Infinity
+ddfma2590 fma -1 Inf 0e+384 -> -Infinity
+ddfma2591 fma -0 Inf 0e+384 -> NaN Invalid_operation
+ddfma2592 fma 0 Inf 0e+384 -> NaN Invalid_operation
+ddfma2593 fma 1 Inf 0e+384 -> Infinity
+ddfma2594 fma 1000 Inf 0e+384 -> Infinity
+ddfma2595 fma Inf Inf 0e+384 -> Infinity
+
+ddfma2600 fma -Inf -Inf 0e+384 -> Infinity
+ddfma2601 fma -Inf -1000 0e+384 -> Infinity
+ddfma2602 fma -Inf -1 0e+384 -> Infinity
+ddfma2603 fma -Inf -0 0e+384 -> NaN Invalid_operation
+ddfma2604 fma -Inf 0 0e+384 -> NaN Invalid_operation
+ddfma2605 fma -Inf 1 0e+384 -> -Infinity
+ddfma2606 fma -Inf 1000 0e+384 -> -Infinity
+ddfma2607 fma -Inf Inf 0e+384 -> -Infinity
+ddfma2608 fma -1000 Inf 0e+384 -> -Infinity
+ddfma2609 fma -Inf -Inf 0e+384 -> Infinity
+ddfma2610 fma -1 -Inf 0e+384 -> Infinity
+ddfma2611 fma -0 -Inf 0e+384 -> NaN Invalid_operation
+ddfma2612 fma 0 -Inf 0e+384 -> NaN Invalid_operation
+ddfma2613 fma 1 -Inf 0e+384 -> -Infinity
+ddfma2614 fma 1000 -Inf 0e+384 -> -Infinity
+ddfma2615 fma Inf -Inf 0e+384 -> -Infinity
+
+ddfma2621 fma NaN -Inf 0e+384 -> NaN
+ddfma2622 fma NaN -1000 0e+384 -> NaN
+ddfma2623 fma NaN -1 0e+384 -> NaN
+ddfma2624 fma NaN -0 0e+384 -> NaN
+ddfma2625 fma NaN 0 0e+384 -> NaN
+ddfma2626 fma NaN 1 0e+384 -> NaN
+ddfma2627 fma NaN 1000 0e+384 -> NaN
+ddfma2628 fma NaN Inf 0e+384 -> NaN
+ddfma2629 fma NaN NaN 0e+384 -> NaN
+ddfma2630 fma -Inf NaN 0e+384 -> NaN
+ddfma2631 fma -1000 NaN 0e+384 -> NaN
+ddfma2632 fma -1 NaN 0e+384 -> NaN
+ddfma2633 fma -0 NaN 0e+384 -> NaN
+ddfma2634 fma 0 NaN 0e+384 -> NaN
+ddfma2635 fma 1 NaN 0e+384 -> NaN
+ddfma2636 fma 1000 NaN 0e+384 -> NaN
+ddfma2637 fma Inf NaN 0e+384 -> NaN
+
+ddfma2641 fma sNaN -Inf 0e+384 -> NaN Invalid_operation
+ddfma2642 fma sNaN -1000 0e+384 -> NaN Invalid_operation
+ddfma2643 fma sNaN -1 0e+384 -> NaN Invalid_operation
+ddfma2644 fma sNaN -0 0e+384 -> NaN Invalid_operation
+ddfma2645 fma sNaN 0 0e+384 -> NaN Invalid_operation
+ddfma2646 fma sNaN 1 0e+384 -> NaN Invalid_operation
+ddfma2647 fma sNaN 1000 0e+384 -> NaN Invalid_operation
+ddfma2648 fma sNaN NaN 0e+384 -> NaN Invalid_operation
+ddfma2649 fma sNaN sNaN 0e+384 -> NaN Invalid_operation
+ddfma2650 fma NaN sNaN 0e+384 -> NaN Invalid_operation
+ddfma2651 fma -Inf sNaN 0e+384 -> NaN Invalid_operation
+ddfma2652 fma -1000 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2653 fma -1 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2654 fma -0 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2655 fma 0 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2656 fma 1 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2657 fma 1000 sNaN 0e+384 -> NaN Invalid_operation
+ddfma2658 fma Inf sNaN 0e+384 -> NaN Invalid_operation
+ddfma2659 fma NaN sNaN 0e+384 -> NaN Invalid_operation
+
+-- propagating NaNs
+ddfma2661 fma NaN9 -Inf 0e+384 -> NaN9
+ddfma2662 fma NaN8 999 0e+384 -> NaN8
+ddfma2663 fma NaN71 Inf 0e+384 -> NaN71
+ddfma2664 fma NaN6 NaN5 0e+384 -> NaN6
+ddfma2665 fma -Inf NaN4 0e+384 -> NaN4
+ddfma2666 fma -999 NaN33 0e+384 -> NaN33
+ddfma2667 fma Inf NaN2 0e+384 -> NaN2
+
+ddfma2671 fma sNaN99 -Inf 0e+384 -> NaN99 Invalid_operation
+ddfma2672 fma sNaN98 -11 0e+384 -> NaN98 Invalid_operation
+ddfma2673 fma sNaN97 NaN 0e+384 -> NaN97 Invalid_operation
+ddfma2674 fma sNaN16 sNaN94 0e+384 -> NaN16 Invalid_operation
+ddfma2675 fma NaN95 sNaN93 0e+384 -> NaN93 Invalid_operation
+ddfma2676 fma -Inf sNaN92 0e+384 -> NaN92 Invalid_operation
+ddfma2677 fma 088 sNaN91 0e+384 -> NaN91 Invalid_operation
+ddfma2678 fma Inf sNaN90 0e+384 -> NaN90 Invalid_operation
+ddfma2679 fma NaN sNaN89 0e+384 -> NaN89 Invalid_operation
+
+ddfma2681 fma -NaN9 -Inf 0e+384 -> -NaN9
+ddfma2682 fma -NaN8 999 0e+384 -> -NaN8
+ddfma2683 fma -NaN71 Inf 0e+384 -> -NaN71
+ddfma2684 fma -NaN6 -NaN5 0e+384 -> -NaN6
+ddfma2685 fma -Inf -NaN4 0e+384 -> -NaN4
+ddfma2686 fma -999 -NaN33 0e+384 -> -NaN33
+ddfma2687 fma Inf -NaN2 0e+384 -> -NaN2
+
+ddfma2691 fma -sNaN99 -Inf 0e+384 -> -NaN99 Invalid_operation
+ddfma2692 fma -sNaN98 -11 0e+384 -> -NaN98 Invalid_operation
+ddfma2693 fma -sNaN97 NaN 0e+384 -> -NaN97 Invalid_operation
+ddfma2694 fma -sNaN16 -sNaN94 0e+384 -> -NaN16 Invalid_operation
+ddfma2695 fma -NaN95 -sNaN93 0e+384 -> -NaN93 Invalid_operation
+ddfma2696 fma -Inf -sNaN92 0e+384 -> -NaN92 Invalid_operation
+ddfma2697 fma 088 -sNaN91 0e+384 -> -NaN91 Invalid_operation
+ddfma2698 fma Inf -sNaN90 0e+384 -> -NaN90 Invalid_operation
+ddfma2699 fma -NaN -sNaN89 0e+384 -> -NaN89 Invalid_operation
+
+ddfma2701 fma -NaN -Inf 0e+384 -> -NaN
+ddfma2702 fma -NaN 999 0e+384 -> -NaN
+ddfma2703 fma -NaN Inf 0e+384 -> -NaN
+ddfma2704 fma -NaN -NaN 0e+384 -> -NaN
+ddfma2705 fma -Inf -NaN0 0e+384 -> -NaN
+ddfma2706 fma -999 -NaN 0e+384 -> -NaN
+ddfma2707 fma Inf -NaN 0e+384 -> -NaN
+
+ddfma2711 fma -sNaN -Inf 0e+384 -> -NaN Invalid_operation
+ddfma2712 fma -sNaN -11 0e+384 -> -NaN Invalid_operation
+ddfma2713 fma -sNaN00 NaN 0e+384 -> -NaN Invalid_operation
+ddfma2714 fma -sNaN -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2715 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2716 fma -Inf -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2717 fma 088 -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2718 fma Inf -sNaN 0e+384 -> -NaN Invalid_operation
+ddfma2719 fma -NaN -sNaN 0e+384 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+ddfma2751 fma 1e+277 1e+311 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2752 fma 1e+277 -1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
+ddfma2753 fma -1e+277 1e+311 0e+384 -> -Infinity Overflow Inexact Rounded
+ddfma2754 fma -1e+277 -1e+311 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2755 fma 1e-277 1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2756 fma 1e-277 -1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2757 fma -1e-277 1e-311 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2758 fma -1e-277 -1e-311 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+ddfma2760 fma 1e-291 1e-101 0e+384 -> 1E-392 Subnormal
+ddfma2761 fma 1e-291 1e-102 0e+384 -> 1E-393 Subnormal
+ddfma2762 fma 1e-291 1e-103 0e+384 -> 1E-394 Subnormal
+ddfma2763 fma 1e-291 1e-104 0e+384 -> 1E-395 Subnormal
+ddfma2764 fma 1e-291 1e-105 0e+384 -> 1E-396 Subnormal
+ddfma2765 fma 1e-291 1e-106 0e+384 -> 1E-397 Subnormal
+ddfma2766 fma 1e-291 1e-107 0e+384 -> 1E-398 Subnormal
+ddfma2767 fma 1e-291 1e-108 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2768 fma 1e-291 1e-109 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2769 fma 1e-291 1e-110 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+ddfma2770 fma 1e+60 1e+321 0e+384 -> 1.000000000000E+381 Clamped
+ddfma2771 fma 1e+60 1e+322 0e+384 -> 1.0000000000000E+382 Clamped
+ddfma2772 fma 1e+60 1e+323 0e+384 -> 1.00000000000000E+383 Clamped
+ddfma2773 fma 1e+60 1e+324 0e+384 -> 1.000000000000000E+384 Clamped
+ddfma2774 fma 1e+60 1e+325 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2775 fma 1e+60 1e+326 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2776 fma 1e+60 1e+327 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2777 fma 1e+60 1e+328 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2778 fma 1e+60 1e+329 0e+384 -> Infinity Overflow Inexact Rounded
+ddfma2779 fma 1e+60 1e+330 0e+384 -> Infinity Overflow Inexact Rounded
+
+ddfma2801 fma 1.0000E-394 1 0e+384 -> 1.0000E-394 Subnormal
+ddfma2802 fma 1.000E-394 1e-1 0e+384 -> 1.000E-395 Subnormal
+ddfma2803 fma 1.00E-394 1e-2 0e+384 -> 1.00E-396 Subnormal
+ddfma2804 fma 1.0E-394 1e-3 0e+384 -> 1.0E-397 Subnormal
+ddfma2805 fma 1.0E-394 1e-4 0e+384 -> 1E-398 Subnormal Rounded
+ddfma2806 fma 1.3E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2807 fma 1.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2808 fma 1.7E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2809 fma 2.3E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2810 fma 2.5E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2811 fma 2.7E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddfma2812 fma 1.49E-394 1e-4 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2813 fma 1.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2814 fma 1.51E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2815 fma 2.49E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2816 fma 2.50E-394 1e-4 0e+384 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddfma2817 fma 2.51E-394 1e-4 0e+384 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+ddfma2818 fma 1E-394 1e-4 0e+384 -> 1E-398 Subnormal
+ddfma2819 fma 3E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2820 fma 5E-394 1e-5 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2821 fma 7E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2822 fma 9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddfma2823 fma 9.9E-394 1e-5 0e+384 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddfma2824 fma 1E-394 -1e-4 0e+384 -> -1E-398 Subnormal
+ddfma2825 fma 3E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2826 fma -5E-394 1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2827 fma 7E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2828 fma -9E-394 1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2829 fma 9.9E-394 -1e-5 0e+384 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddfma2830 fma 3.0E-394 -1e-5 0e+384 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddfma2831 fma 1.0E-199 1e-200 0e+384 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddfma2832 fma 1.0E-199 1e-199 0e+384 -> 1E-398 Subnormal Rounded
+ddfma2833 fma 1.0E-199 1e-198 0e+384 -> 1.0E-397 Subnormal
+ddfma2834 fma 2.0E-199 2e-198 0e+384 -> 4.0E-397 Subnormal
+ddfma2835 fma 4.0E-199 4e-198 0e+384 -> 1.60E-396 Subnormal
+ddfma2836 fma 10.0E-199 10e-198 0e+384 -> 1.000E-395 Subnormal
+ddfma2837 fma 30.0E-199 30e-198 0e+384 -> 9.000E-395 Subnormal
+ddfma2838 fma 40.0E-199 40e-188 0e+384 -> 1.6000E-384 Subnormal
+ddfma2839 fma 40.0E-199 40e-187 0e+384 -> 1.6000E-383
+ddfma2840 fma 40.0E-199 40e-186 0e+384 -> 1.6000E-382
+
+-- Long operand overflow may be a different path
+ddfma2870 fma 100 9.999E+383 0e+384 -> Infinity Inexact Overflow Rounded
+ddfma2871 fma 100 -9.999E+383 0e+384 -> -Infinity Inexact Overflow Rounded
+ddfma2872 fma 9.999E+383 100 0e+384 -> Infinity Inexact Overflow Rounded
+ddfma2873 fma -9.999E+383 100 0e+384 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+ddfma2881 fma 1.2347E-355 1.2347E-40 0e+384 -> 1.524E-395 Inexact Rounded Subnormal Underflow
+ddfma2882 fma 1.234E-355 1.234E-40 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2883 fma 1.23E-355 1.23E-40 0e+384 -> 1.513E-395 Inexact Rounded Subnormal Underflow
+ddfma2884 fma 1.2E-355 1.2E-40 0e+384 -> 1.44E-395 Subnormal
+ddfma2885 fma 1.2E-355 1.2E-41 0e+384 -> 1.44E-396 Subnormal
+ddfma2886 fma 1.2E-355 1.2E-42 0e+384 -> 1.4E-397 Subnormal Inexact Rounded Underflow
+ddfma2887 fma 1.2E-355 1.3E-42 0e+384 -> 1.6E-397 Subnormal Inexact Rounded Underflow
+ddfma2888 fma 1.3E-355 1.3E-42 0e+384 -> 1.7E-397 Subnormal Inexact Rounded Underflow
+ddfma2889 fma 1.3E-355 1.3E-43 0e+384 -> 2E-398 Subnormal Inexact Rounded Underflow
+ddfma2890 fma 1.3E-356 1.3E-43 0e+384 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
+
+ddfma2891 fma 1.2345E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddfma2892 fma 1.23456E-39 1.234E-355 0e+384 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddfma2893 fma 1.2345E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2894 fma 1.23456E-40 1.234E-355 0e+384 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddfma2895 fma 1.2345E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+ddfma2896 fma 1.23456E-41 1.234E-355 0e+384 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+ddfma2900 fma 0.3000000000E-191 0.3000000000E-191 0e+384 -> 9.00000000000000E-384 Subnormal Rounded
+ddfma2901 fma 0.3000000001E-191 0.3000000001E-191 0e+384 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+ddfma2902 fma 9.999999999999999E-383 0.0999999999999 0e+384 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+ddfma2903 fma 9.999999999999999E-383 0.09999999999999 0e+384 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+ddfma2904 fma 9.999999999999999E-383 0.099999999999999 0e+384 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+ddfma2905 fma 9.999999999999999E-383 0.0999999999999999 0e+384 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- prove operands are exact
+ddfma2906 fma 9.999999999999999E-383 1 0e+384 -> 9.999999999999999E-383
+ddfma2907 fma 1 0.09999999999999999 0e+384 -> 0.09999999999999999
+-- the next rounds to Nmin
+ddfma2908 fma 9.999999999999999E-383 0.09999999999999999 0e+384 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- hugest
+ddfma2909 fma 9999999999999999 9999999999999999 0e+384 -> 9.999999999999998E+31 Inexact Rounded
+
+-- Null tests
+ddfma2990 fma 10 # 0e+384 -> NaN Invalid_operation
+ddfma2991 fma # 10 0e+384 -> NaN Invalid_operation
+
+
+-- ADDITION TESTS ------------------------------------------------------
+
+-- [first group are 'quick confidence check']
+ddfma3001 fma 1 1 1 -> 2
+ddfma3002 fma 1 2 3 -> 5
+ddfma3003 fma 1 '5.75' '3.3' -> 9.05
+ddfma3004 fma 1 '5' '-3' -> 2
+ddfma3005 fma 1 '-5' '-3' -> -8
+ddfma3006 fma 1 '-7' '2.5' -> -4.5
+ddfma3007 fma 1 '0.7' '0.3' -> 1.0
+ddfma3008 fma 1 '1.25' '1.25' -> 2.50
+ddfma3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+ddfma3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+ddfma3011 fma 1 '0.4444444444444446' '0.5555555555555555' -> '1.000000000000000' Inexact Rounded
+ddfma3012 fma 1 '0.4444444444444445' '0.5555555555555555' -> '1.000000000000000' Rounded
+ddfma3013 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+ddfma3014 fma 1 '4444444444444444' '0.49' -> '4444444444444444' Inexact Rounded
+ddfma3015 fma 1 '4444444444444444' '0.499' -> '4444444444444444' Inexact Rounded
+ddfma3016 fma 1 '4444444444444444' '0.4999' -> '4444444444444444' Inexact Rounded
+ddfma3017 fma 1 '4444444444444444' '0.5000' -> '4444444444444444' Inexact Rounded
+ddfma3018 fma 1 '4444444444444444' '0.5001' -> '4444444444444445' Inexact Rounded
+ddfma3019 fma 1 '4444444444444444' '0.501' -> '4444444444444445' Inexact Rounded
+ddfma3020 fma 1 '4444444444444444' '0.51' -> '4444444444444445' Inexact Rounded
+
+ddfma3021 fma 1 0 1 -> 1
+ddfma3022 fma 1 1 1 -> 2
+ddfma3023 fma 1 2 1 -> 3
+ddfma3024 fma 1 3 1 -> 4
+ddfma3025 fma 1 4 1 -> 5
+ddfma3026 fma 1 5 1 -> 6
+ddfma3027 fma 1 6 1 -> 7
+ddfma3028 fma 1 7 1 -> 8
+ddfma3029 fma 1 8 1 -> 9
+ddfma3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+ddfma3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+ddfma3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+ddfma3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+ddfma3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+ddfma3035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+ddfma3039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+ddfma3040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+ddfma3044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+ddfma3045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+-- same, without rounding
+ddfma3046 fma 1 '10000e+9' '7' -> '10000000000007'
+ddfma3047 fma 1 '10000e+9' '70' -> '10000000000070'
+ddfma3048 fma 1 '10000e+9' '700' -> '10000000000700'
+ddfma3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+ddfma3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+ddfma3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+ddfma3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+ddfma3053 fma 1 '12' '7.00' -> '19.00'
+ddfma3054 fma 1 '1.3' '-1.07' -> '0.23'
+ddfma3055 fma 1 '1.3' '-1.30' -> '0.00'
+ddfma3056 fma 1 '1.3' '-2.07' -> '-0.77'
+ddfma3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+ddfma3061 fma 1 1 '0.0001' -> '1.0001'
+ddfma3062 fma 1 1 '0.00001' -> '1.00001'
+ddfma3063 fma 1 1 '0.000001' -> '1.000001'
+ddfma3064 fma 1 1 '0.0000001' -> '1.0000001'
+ddfma3065 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+ddfma3070 fma 1 1 0 -> 1
+ddfma3071 fma 1 1 0. -> 1
+ddfma3072 fma 1 1 .0 -> 1.0
+ddfma3073 fma 1 1 0.0 -> 1.0
+ddfma3074 fma 1 1 0.00 -> 1.00
+ddfma3075 fma 1 0 1 -> 1
+ddfma3076 fma 1 0. 1 -> 1
+ddfma3077 fma 1 .0 1 -> 1.0
+ddfma3078 fma 1 0.0 1 -> 1.0
+ddfma3079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+ddfma3080 fma 1 999999998 1 -> 999999999
+ddfma3081 fma 1 999999999 1 -> 1000000000
+ddfma3082 fma 1 99999999 1 -> 100000000
+ddfma3083 fma 1 9999999 1 -> 10000000
+ddfma3084 fma 1 999999 1 -> 1000000
+ddfma3085 fma 1 99999 1 -> 100000
+ddfma3086 fma 1 9999 1 -> 10000
+ddfma3087 fma 1 999 1 -> 1000
+ddfma3088 fma 1 99 1 -> 100
+ddfma3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+ddfma3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+ddfma3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+ddfma3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+ddfma3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+ddfma3094 fma 1 '-56267E-3' 0 -> '-56.267'
+ddfma3095 fma 1 '-56267E-2' 0 -> '-562.67'
+ddfma3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+ddfma3097 fma 1 '-56267E-0' 0 -> '-56267'
+ddfma3098 fma 1 '-5E-10' 0 -> '-5E-10'
+ddfma3099 fma 1 '-5E-7' 0 -> '-5E-7'
+ddfma3100 fma 1 '-5E-6' 0 -> '-0.000005'
+ddfma3101 fma 1 '-5E-5' 0 -> '-0.00005'
+ddfma3102 fma 1 '-5E-4' 0 -> '-0.0005'
+ddfma3103 fma 1 '-5E-1' 0 -> '-0.5'
+ddfma3104 fma 1 '-5E0' 0 -> '-5'
+ddfma3105 fma 1 '-5E1' 0 -> '-50'
+ddfma3106 fma 1 '-5E5' 0 -> '-500000'
+ddfma3107 fma 1 '-5E15' 0 -> '-5000000000000000'
+ddfma3108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddfma3109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddfma3110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddfma3111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+ddfma3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+ddfma3114 fma 1 0 '-56267E-6' -> '-0.056267'
+ddfma3116 fma 1 0 '-56267E-5' -> '-0.56267'
+ddfma3117 fma 1 0 '-56267E-4' -> '-5.6267'
+ddfma3119 fma 1 0 '-56267E-3' -> '-56.267'
+ddfma3120 fma 1 0 '-56267E-2' -> '-562.67'
+ddfma3121 fma 1 0 '-56267E-1' -> '-5626.7'
+ddfma3122 fma 1 0 '-56267E-0' -> '-56267'
+ddfma3123 fma 1 0 '-5E-10' -> '-5E-10'
+ddfma3124 fma 1 0 '-5E-7' -> '-5E-7'
+ddfma3125 fma 1 0 '-5E-6' -> '-0.000005'
+ddfma3126 fma 1 0 '-5E-5' -> '-0.00005'
+ddfma3127 fma 1 0 '-5E-4' -> '-0.0005'
+ddfma3128 fma 1 0 '-5E-1' -> '-0.5'
+ddfma3129 fma 1 0 '-5E0' -> '-5'
+ddfma3130 fma 1 0 '-5E1' -> '-50'
+ddfma3131 fma 1 0 '-5E5' -> '-500000'
+ddfma3132 fma 1 0 '-5E15' -> '-5000000000000000'
+ddfma3133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+ddfma3134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+ddfma3135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+ddfma3136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+ddfma3137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
+ddfma3138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
+ddfma3139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
+ddfma3140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
+ddfma3141 fma 1 1E+11 0.0000 -> '100000000000.0000'
+ddfma3142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
+ddfma3143 fma 1 0.000 1E+12 -> '1000000000000.000'
+ddfma3144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+ddfma3146 fma 1 '00.0' 0 -> '0.0'
+ddfma3147 fma 1 '0.00' 0 -> '0.00'
+ddfma3148 fma 1 0 '0.00' -> '0.00'
+ddfma3149 fma 1 0 '00.0' -> '0.0'
+ddfma3150 fma 1 '00.0' '0.00' -> '0.00'
+ddfma3151 fma 1 '0.00' '00.0' -> '0.00'
+ddfma3152 fma 1 '3' '.3' -> '3.3'
+ddfma3153 fma 1 '3.' '.3' -> '3.3'
+ddfma3154 fma 1 '3.0' '.3' -> '3.3'
+ddfma3155 fma 1 '3.00' '.3' -> '3.30'
+ddfma3156 fma 1 '3' '3' -> '6'
+ddfma3157 fma 1 '3' '+3' -> '6'
+ddfma3158 fma 1 '3' '-3' -> '0'
+ddfma3159 fma 1 '0.3' '-0.3' -> '0.0'
+ddfma3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+ddfma3161 fma 1 '1E+12' '-1' -> '999999999999'
+ddfma3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+ddfma3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+ddfma3164 fma 1 '-1' '1E+12' -> '999999999999'
+ddfma3165 fma 1 '7E+12' '-1' -> '6999999999999'
+ddfma3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+ddfma3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+ddfma3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+-- 1.234567890123456 1234567890123456 1 234567890123456
+ddfma3170 fma 1 '4.444444444444444' '0.5555555555555567' -> '5.000000000000001' Inexact Rounded
+ddfma3171 fma 1 '4.444444444444444' '0.5555555555555566' -> '5.000000000000001' Inexact Rounded
+ddfma3172 fma 1 '4.444444444444444' '0.5555555555555565' -> '5.000000000000001' Inexact Rounded
+ddfma3173 fma 1 '4.444444444444444' '0.5555555555555564' -> '5.000000000000000' Inexact Rounded
+ddfma3174 fma 1 '4.444444444444444' '0.5555555555555553' -> '4.999999999999999' Inexact Rounded
+ddfma3175 fma 1 '4.444444444444444' '0.5555555555555552' -> '4.999999999999999' Inexact Rounded
+ddfma3176 fma 1 '4.444444444444444' '0.5555555555555551' -> '4.999999999999999' Inexact Rounded
+ddfma3177 fma 1 '4.444444444444444' '0.5555555555555550' -> '4.999999999999999' Rounded
+ddfma3178 fma 1 '4.444444444444444' '0.5555555555555545' -> '4.999999999999999' Inexact Rounded
+ddfma3179 fma 1 '4.444444444444444' '0.5555555555555544' -> '4.999999999999998' Inexact Rounded
+ddfma3180 fma 1 '4.444444444444444' '0.5555555555555543' -> '4.999999999999998' Inexact Rounded
+ddfma3181 fma 1 '4.444444444444444' '0.5555555555555542' -> '4.999999999999998' Inexact Rounded
+ddfma3182 fma 1 '4.444444444444444' '0.5555555555555541' -> '4.999999999999998' Inexact Rounded
+ddfma3183 fma 1 '4.444444444444444' '0.5555555555555540' -> '4.999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddfma3200 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3201 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3202 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3203 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3204 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3205 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3206 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3207 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3208 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddfma3209 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddfma3210 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddfma3211 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddfma3212 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddfma3213 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddfma3214 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddfma3215 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddfma3216 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3217 fma 1 '1234560123456789' 1.000000001 -> '1234560123456790' Inexact Rounded
+ddfma3218 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3219 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+rounding: half_even
+ddfma3220 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3221 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3222 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3223 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3224 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3225 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3226 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3227 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3228 fma 1 '1234560123456789' 0.5 -> '1234560123456790' Inexact Rounded
+ddfma3229 fma 1 '1234560123456789' 0.500000001 -> '1234560123456790' Inexact Rounded
+ddfma3230 fma 1 '1234560123456789' 0.500001 -> '1234560123456790' Inexact Rounded
+ddfma3231 fma 1 '1234560123456789' 0.51 -> '1234560123456790' Inexact Rounded
+ddfma3232 fma 1 '1234560123456789' 0.6 -> '1234560123456790' Inexact Rounded
+ddfma3233 fma 1 '1234560123456789' 0.9 -> '1234560123456790' Inexact Rounded
+ddfma3234 fma 1 '1234560123456789' 0.99999 -> '1234560123456790' Inexact Rounded
+ddfma3235 fma 1 '1234560123456789' 0.999999999 -> '1234560123456790' Inexact Rounded
+ddfma3236 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3237 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddfma3238 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3239 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+ddfma3240 fma 1 '1234560123456788' 0.499999999 -> '1234560123456788' Inexact Rounded
+ddfma3241 fma 1 '1234560123456788' 0.5 -> '1234560123456788' Inexact Rounded
+ddfma3242 fma 1 '1234560123456788' 0.500000001 -> '1234560123456789' Inexact Rounded
+
+rounding: down
+ddfma3250 fma 1 '1234560123456789' 0 -> '1234560123456789'
+ddfma3251 fma 1 '1234560123456789' 0.000000001 -> '1234560123456789' Inexact Rounded
+ddfma3252 fma 1 '1234560123456789' 0.000001 -> '1234560123456789' Inexact Rounded
+ddfma3253 fma 1 '1234560123456789' 0.1 -> '1234560123456789' Inexact Rounded
+ddfma3254 fma 1 '1234560123456789' 0.4 -> '1234560123456789' Inexact Rounded
+ddfma3255 fma 1 '1234560123456789' 0.49 -> '1234560123456789' Inexact Rounded
+ddfma3256 fma 1 '1234560123456789' 0.499999 -> '1234560123456789' Inexact Rounded
+ddfma3257 fma 1 '1234560123456789' 0.499999999 -> '1234560123456789' Inexact Rounded
+ddfma3258 fma 1 '1234560123456789' 0.5 -> '1234560123456789' Inexact Rounded
+ddfma3259 fma 1 '1234560123456789' 0.500000001 -> '1234560123456789' Inexact Rounded
+ddfma3260 fma 1 '1234560123456789' 0.500001 -> '1234560123456789' Inexact Rounded
+ddfma3261 fma 1 '1234560123456789' 0.51 -> '1234560123456789' Inexact Rounded
+ddfma3262 fma 1 '1234560123456789' 0.6 -> '1234560123456789' Inexact Rounded
+ddfma3263 fma 1 '1234560123456789' 0.9 -> '1234560123456789' Inexact Rounded
+ddfma3264 fma 1 '1234560123456789' 0.99999 -> '1234560123456789' Inexact Rounded
+ddfma3265 fma 1 '1234560123456789' 0.999999999 -> '1234560123456789' Inexact Rounded
+ddfma3266 fma 1 '1234560123456789' 1 -> '1234560123456790'
+ddfma3267 fma 1 '1234560123456789' 1.00000001 -> '1234560123456790' Inexact Rounded
+ddfma3268 fma 1 '1234560123456789' 1.00001 -> '1234560123456790' Inexact Rounded
+ddfma3269 fma 1 '1234560123456789' 1.1 -> '1234560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+ddfma3301 fma 1 -1 1 -> 0
+ddfma3302 fma 1 0 1 -> 1
+ddfma3303 fma 1 1 1 -> 2
+ddfma3304 fma 1 12 1 -> 13
+ddfma3305 fma 1 98 1 -> 99
+ddfma3306 fma 1 99 1 -> 100
+ddfma3307 fma 1 100 1 -> 101
+ddfma3308 fma 1 101 1 -> 102
+ddfma3309 fma 1 -1 -1 -> -2
+ddfma3310 fma 1 0 -1 -> -1
+ddfma3311 fma 1 1 -1 -> 0
+ddfma3312 fma 1 12 -1 -> 11
+ddfma3313 fma 1 98 -1 -> 97
+ddfma3314 fma 1 99 -1 -> 98
+ddfma3315 fma 1 100 -1 -> 99
+ddfma3316 fma 1 101 -1 -> 100
+
+ddfma3321 fma 1 -0.01 0.01 -> 0.00
+ddfma3322 fma 1 0.00 0.01 -> 0.01
+ddfma3323 fma 1 0.01 0.01 -> 0.02
+ddfma3324 fma 1 0.12 0.01 -> 0.13
+ddfma3325 fma 1 0.98 0.01 -> 0.99
+ddfma3326 fma 1 0.99 0.01 -> 1.00
+ddfma3327 fma 1 1.00 0.01 -> 1.01
+ddfma3328 fma 1 1.01 0.01 -> 1.02
+ddfma3329 fma 1 -0.01 -0.01 -> -0.02
+ddfma3330 fma 1 0.00 -0.01 -> -0.01
+ddfma3331 fma 1 0.01 -0.01 -> 0.00
+ddfma3332 fma 1 0.12 -0.01 -> 0.11
+ddfma3333 fma 1 0.98 -0.01 -> 0.97
+ddfma3334 fma 1 0.99 -0.01 -> 0.98
+ddfma3335 fma 1 1.00 -0.01 -> 0.99
+ddfma3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+ddfma3340 fma 1 1E+3 0 -> 1000
+ddfma3341 fma 1 1E+15 0 -> 1000000000000000
+ddfma3342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
+ddfma3343 fma 1 1E+20 0 -> 1.000000000000000E+20 Rounded
+-- which simply follow from these cases ...
+ddfma3344 fma 1 1E+3 1 -> 1001
+ddfma3345 fma 1 1E+15 1 -> 1000000000000001
+ddfma3346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+ddfma3347 fma 1 1E+20 1 -> 1.000000000000000E+20 Inexact Rounded
+ddfma3348 fma 1 1E+3 7 -> 1007
+ddfma3349 fma 1 1E+15 7 -> 1000000000000007
+ddfma3350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+ddfma3351 fma 1 1E+20 7 -> 1.000000000000000E+20 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+ddfma3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
+ddfma3361 fma 1 0E-50 10000E+1 -> 100000.0000000000 Rounded
+ddfma3362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
+ddfma3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+ddfma3364 fma 1 9.999999999999999E+384 -9.999999999999999E+384 -> 0E+369
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+ddfma3370 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3371 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_up
+ddfma3372 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3373 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+rounding: half_even
+ddfma3374 fma 1 999999999999999 815 -> 1000000000000814
+ddfma3375 fma 1 9999999999999999 815 -> 1.000000000000081E+16 Rounded Inexact
+
+-- ulp replacement tests
+ddfma3400 fma 1 1 77e-14 -> 1.00000000000077
+ddfma3401 fma 1 1 77e-15 -> 1.000000000000077
+ddfma3402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
+ddfma3403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
+ddfma3404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
+ddfma3405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
+ddfma3406 fma 1 1 77e-299 -> 1.000000000000000 Inexact Rounded
+
+ddfma3410 fma 1 10 77e-14 -> 10.00000000000077
+ddfma3411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
+ddfma3412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
+ddfma3413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
+ddfma3414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
+ddfma3415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
+ddfma3416 fma 1 10 77e-299 -> 10.00000000000000 Inexact Rounded
+
+ddfma3420 fma 1 77e-14 1 -> 1.00000000000077
+ddfma3421 fma 1 77e-15 1 -> 1.000000000000077
+ddfma3422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
+ddfma3423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
+ddfma3424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
+ddfma3425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddfma3426 fma 1 77e-299 1 -> 1.000000000000000 Inexact Rounded
+
+ddfma3430 fma 1 77e-14 10 -> 10.00000000000077
+ddfma3431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
+ddfma3432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
+ddfma3433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
+ddfma3434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddfma3435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddfma3436 fma 1 77e-299 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddfma36440 fma 1 1 -77e-14 -> 0.99999999999923
+ddfma36441 fma 1 1 -77e-15 -> 0.999999999999923
+ddfma36442 fma 1 1 -77e-16 -> 0.9999999999999923
+ddfma36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+ddfma36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+ddfma36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+ddfma36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+ddfma36450 fma 1 10 -77e-14 -> 9.99999999999923
+ddfma36451 fma 1 10 -77e-15 -> 9.999999999999923
+ddfma36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+ddfma36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+ddfma36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+ddfma36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+ddfma36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+ddfma36460 fma 1 -77e-14 1 -> 0.99999999999923
+ddfma36461 fma 1 -77e-15 1 -> 0.999999999999923
+ddfma36462 fma 1 -77e-16 1 -> 0.9999999999999923
+ddfma36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+ddfma36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+ddfma36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
+ddfma36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+ddfma36470 fma 1 -77e-14 10 -> 9.99999999999923
+ddfma36471 fma 1 -77e-15 10 -> 9.999999999999923
+ddfma36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
+ddfma36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
+ddfma36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
+ddfma36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
+ddfma36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+ddfma36480 fma 1 -1 77e-14 -> -0.99999999999923
+ddfma36481 fma 1 -1 77e-15 -> -0.999999999999923
+ddfma36482 fma 1 -1 77e-16 -> -0.9999999999999923
+ddfma36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+ddfma36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+ddfma36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
+ddfma36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+ddfma36490 fma 1 -10 77e-14 -> -9.99999999999923
+ddfma36491 fma 1 -10 77e-15 -> -9.999999999999923
+ddfma36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
+ddfma36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
+ddfma36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
+ddfma36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
+ddfma36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+ddfma36500 fma 1 77e-14 -1 -> -0.99999999999923
+ddfma36501 fma 1 77e-15 -1 -> -0.999999999999923
+ddfma36502 fma 1 77e-16 -1 -> -0.9999999999999923
+ddfma36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+ddfma36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+ddfma36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+ddfma36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+ddfma36510 fma 1 77e-14 -10 -> -9.99999999999923
+ddfma36511 fma 1 77e-15 -10 -> -9.999999999999923
+ddfma36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+ddfma36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+ddfma36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+ddfma36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+ddfma36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+-- and a couple more with longer RHS
+ddfma36520 fma 1 1 -7777e-16 -> 0.9999999999992223
+ddfma36521 fma 1 1 -7777e-17 -> 0.9999999999999222 Inexact Rounded
+ddfma36522 fma 1 1 -7777e-18 -> 0.9999999999999922 Inexact Rounded
+ddfma36523 fma 1 1 -7777e-19 -> 0.9999999999999992 Inexact Rounded
+ddfma36524 fma 1 1 -7777e-20 -> 0.9999999999999999 Inexact Rounded
+ddfma36525 fma 1 1 -7777e-21 -> 1.000000000000000 Inexact Rounded
+ddfma36526 fma 1 1 -7777e-22 -> 1.000000000000000 Inexact Rounded
+
+
+-- and some more residue effects and different roundings
+rounding: half_up
+ddfma36540 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma36541 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma36542 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma36543 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma36544 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma36545 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma36546 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma36547 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma36548 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddfma36549 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddfma36550 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddfma36551 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddfma36552 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddfma36553 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddfma36554 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddfma36555 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddfma36556 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma36557 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+ddfma36558 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma36559 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+ddfma36560 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma36561 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma36562 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma36563 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma36564 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma36565 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma36566 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma36567 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma36568 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+ddfma36569 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+ddfma36570 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+ddfma36571 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+ddfma36572 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+ddfma36573 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+ddfma36574 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+ddfma36575 fma 1 '6543210123456789' 0.999999999 -> '6543210123456790' Inexact Rounded
+ddfma36576 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma36577 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddfma36578 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma36579 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+ddfma37540 fma 1 '6543210123456788' 0.499999999 -> '6543210123456788' Inexact Rounded
+ddfma37541 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+ddfma37542 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+ddfma37550 fma 1 '6543210123456789' 0 -> '6543210123456789'
+ddfma37551 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+ddfma37552 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+ddfma37553 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+ddfma37554 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+ddfma37555 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+ddfma37556 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+ddfma37557 fma 1 '6543210123456789' 0.499999999 -> '6543210123456789' Inexact Rounded
+ddfma37558 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+ddfma37559 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+ddfma37560 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+ddfma37561 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+ddfma37562 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+ddfma37563 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+ddfma37564 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+ddfma37565 fma 1 '6543210123456789' 0.999999999 -> '6543210123456789' Inexact Rounded
+ddfma37566 fma 1 '6543210123456789' 1 -> '6543210123456790'
+ddfma37567 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+ddfma37568 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+ddfma37569 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+
+-- verify a query
+rounding: down
+ddfma37661 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+ddfma37662 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+ddfma37663 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+ddfma37664 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+ddfma37701 fma 1 5.00 1.00E-3 -> 5.00100
+ddfma37702 fma 1 00.00 0.000 -> 0.000
+ddfma37703 fma 1 00.00 0E-3 -> 0.000
+ddfma37704 fma 1 0E-3 00.00 -> 0.000
+
+ddfma37710 fma 1 0E+3 00.00 -> 0.00
+ddfma37711 fma 1 0E+3 00.0 -> 0.0
+ddfma37712 fma 1 0E+3 00. -> 0
+ddfma37713 fma 1 0E+3 00.E+1 -> 0E+1
+ddfma37714 fma 1 0E+3 00.E+2 -> 0E+2
+ddfma37715 fma 1 0E+3 00.E+3 -> 0E+3
+ddfma37716 fma 1 0E+3 00.E+4 -> 0E+3
+ddfma37717 fma 1 0E+3 00.E+5 -> 0E+3
+ddfma37718 fma 1 0E+3 -00.0 -> 0.0
+ddfma37719 fma 1 0E+3 -00. -> 0
+ddfma37731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+ddfma37720 fma 1 00.00 0E+3 -> 0.00
+ddfma37721 fma 1 00.0 0E+3 -> 0.0
+ddfma37722 fma 1 00. 0E+3 -> 0
+ddfma37723 fma 1 00.E+1 0E+3 -> 0E+1
+ddfma37724 fma 1 00.E+2 0E+3 -> 0E+2
+ddfma37725 fma 1 00.E+3 0E+3 -> 0E+3
+ddfma37726 fma 1 00.E+4 0E+3 -> 0E+3
+ddfma37727 fma 1 00.E+5 0E+3 -> 0E+3
+ddfma37728 fma 1 -00.00 0E+3 -> 0.00
+ddfma37729 fma 1 -00.0 0E+3 -> 0.0
+ddfma37730 fma 1 -00. 0E+3 -> 0
+
+ddfma37732 fma 1 0 0 -> 0
+ddfma37733 fma 1 0 -0 -> 0
+ddfma37734 fma 1 -0 0 -> 0
+ddfma37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+ddfma37736 fma 1 1 -1 -> 0
+ddfma37737 fma 1 -1 -1 -> -2
+ddfma37738 fma 1 1 1 -> 2
+ddfma37739 fma 1 -1 1 -> 0
+
+ddfma37741 fma 1 0 -1 -> -1
+ddfma37742 fma 1 -0 -1 -> -1
+ddfma37743 fma 1 0 1 -> 1
+ddfma37744 fma 1 -0 1 -> 1
+ddfma37745 fma 1 -1 0 -> -1
+ddfma37746 fma 1 -1 -0 -> -1
+ddfma37747 fma 1 1 0 -> 1
+ddfma37748 fma 1 1 -0 -> 1
+
+ddfma37751 fma 1 0.0 -1 -> -1.0
+ddfma37752 fma 1 -0.0 -1 -> -1.0
+ddfma37753 fma 1 0.0 1 -> 1.0
+ddfma37754 fma 1 -0.0 1 -> 1.0
+ddfma37755 fma 1 -1.0 0 -> -1.0
+ddfma37756 fma 1 -1.0 -0 -> -1.0
+ddfma37757 fma 1 1.0 0 -> 1.0
+ddfma37758 fma 1 1.0 -0 -> 1.0
+
+ddfma37761 fma 1 0 -1.0 -> -1.0
+ddfma37762 fma 1 -0 -1.0 -> -1.0
+ddfma37763 fma 1 0 1.0 -> 1.0
+ddfma37764 fma 1 -0 1.0 -> 1.0
+ddfma37765 fma 1 -1 0.0 -> -1.0
+ddfma37766 fma 1 -1 -0.0 -> -1.0
+ddfma37767 fma 1 1 0.0 -> 1.0
+ddfma37768 fma 1 1 -0.0 -> 1.0
+
+ddfma37771 fma 1 0.0 -1.0 -> -1.0
+ddfma37772 fma 1 -0.0 -1.0 -> -1.0
+ddfma37773 fma 1 0.0 1.0 -> 1.0
+ddfma37774 fma 1 -0.0 1.0 -> 1.0
+ddfma37775 fma 1 -1.0 0.0 -> -1.0
+ddfma37776 fma 1 -1.0 -0.0 -> -1.0
+ddfma37777 fma 1 1.0 0.0 -> 1.0
+ddfma37778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+ddfma37780 fma 1 -Inf -Inf -> -Infinity
+ddfma37781 fma 1 -Inf -1000 -> -Infinity
+ddfma37782 fma 1 -Inf -1 -> -Infinity
+ddfma37783 fma 1 -Inf -0 -> -Infinity
+ddfma37784 fma 1 -Inf 0 -> -Infinity
+ddfma37785 fma 1 -Inf 1 -> -Infinity
+ddfma37786 fma 1 -Inf 1000 -> -Infinity
+ddfma37787 fma 1 -1000 -Inf -> -Infinity
+ddfma37788 fma 1 -Inf -Inf -> -Infinity
+ddfma37789 fma 1 -1 -Inf -> -Infinity
+ddfma37790 fma 1 -0 -Inf -> -Infinity
+ddfma37791 fma 1 0 -Inf -> -Infinity
+ddfma37792 fma 1 1 -Inf -> -Infinity
+ddfma37793 fma 1 1000 -Inf -> -Infinity
+ddfma37794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+ddfma37800 fma 1 Inf -Inf -> NaN Invalid_operation
+ddfma37801 fma 1 Inf -1000 -> Infinity
+ddfma37802 fma 1 Inf -1 -> Infinity
+ddfma37803 fma 1 Inf -0 -> Infinity
+ddfma37804 fma 1 Inf 0 -> Infinity
+ddfma37805 fma 1 Inf 1 -> Infinity
+ddfma37806 fma 1 Inf 1000 -> Infinity
+ddfma37807 fma 1 Inf Inf -> Infinity
+ddfma37808 fma 1 -1000 Inf -> Infinity
+ddfma37809 fma 1 -Inf Inf -> NaN Invalid_operation
+ddfma37810 fma 1 -1 Inf -> Infinity
+ddfma37811 fma 1 -0 Inf -> Infinity
+ddfma37812 fma 1 0 Inf -> Infinity
+ddfma37813 fma 1 1 Inf -> Infinity
+ddfma37814 fma 1 1000 Inf -> Infinity
+ddfma37815 fma 1 Inf Inf -> Infinity
+
+ddfma37821 fma 1 NaN -Inf -> NaN
+ddfma37822 fma 1 NaN -1000 -> NaN
+ddfma37823 fma 1 NaN -1 -> NaN
+ddfma37824 fma 1 NaN -0 -> NaN
+ddfma37825 fma 1 NaN 0 -> NaN
+ddfma37826 fma 1 NaN 1 -> NaN
+ddfma37827 fma 1 NaN 1000 -> NaN
+ddfma37828 fma 1 NaN Inf -> NaN
+ddfma37829 fma 1 NaN NaN -> NaN
+ddfma37830 fma 1 -Inf NaN -> NaN
+ddfma37831 fma 1 -1000 NaN -> NaN
+ddfma37832 fma 1 -1 NaN -> NaN
+ddfma37833 fma 1 -0 NaN -> NaN
+ddfma37834 fma 1 0 NaN -> NaN
+ddfma37835 fma 1 1 NaN -> NaN
+ddfma37836 fma 1 1000 NaN -> NaN
+ddfma37837 fma 1 Inf NaN -> NaN
+
+ddfma37841 fma 1 sNaN -Inf -> NaN Invalid_operation
+ddfma37842 fma 1 sNaN -1000 -> NaN Invalid_operation
+ddfma37843 fma 1 sNaN -1 -> NaN Invalid_operation
+ddfma37844 fma 1 sNaN -0 -> NaN Invalid_operation
+ddfma37845 fma 1 sNaN 0 -> NaN Invalid_operation
+ddfma37846 fma 1 sNaN 1 -> NaN Invalid_operation
+ddfma37847 fma 1 sNaN 1000 -> NaN Invalid_operation
+ddfma37848 fma 1 sNaN NaN -> NaN Invalid_operation
+ddfma37849 fma 1 sNaN sNaN -> NaN Invalid_operation
+ddfma37850 fma 1 NaN sNaN -> NaN Invalid_operation
+ddfma37851 fma 1 -Inf sNaN -> NaN Invalid_operation
+ddfma37852 fma 1 -1000 sNaN -> NaN Invalid_operation
+ddfma37853 fma 1 -1 sNaN -> NaN Invalid_operation
+ddfma37854 fma 1 -0 sNaN -> NaN Invalid_operation
+ddfma37855 fma 1 0 sNaN -> NaN Invalid_operation
+ddfma37856 fma 1 1 sNaN -> NaN Invalid_operation
+ddfma37857 fma 1 1000 sNaN -> NaN Invalid_operation
+ddfma37858 fma 1 Inf sNaN -> NaN Invalid_operation
+ddfma37859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddfma37861 fma 1 NaN1 -Inf -> NaN1
+ddfma37862 fma 1 +NaN2 -1000 -> NaN2
+ddfma37863 fma 1 NaN3 1000 -> NaN3
+ddfma37864 fma 1 NaN4 Inf -> NaN4
+ddfma37865 fma 1 NaN5 +NaN6 -> NaN5
+ddfma37866 fma 1 -Inf NaN7 -> NaN7
+ddfma37867 fma 1 -1000 NaN8 -> NaN8
+ddfma37868 fma 1 1000 NaN9 -> NaN9
+ddfma37869 fma 1 Inf +NaN10 -> NaN10
+ddfma37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+ddfma37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+ddfma37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+ddfma37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+ddfma37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddfma37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+ddfma37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+ddfma37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+ddfma37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+ddfma37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+ddfma37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddfma37882 fma 1 -NaN26 NaN28 -> -NaN26
+ddfma37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddfma37884 fma 1 1000 -NaN30 -> -NaN30
+ddfma37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+ddfma37575 fma 1 1E-383 -1E-398 -> 9.99999999999999E-384 Subnormal
+ddfma37576 fma 1 -1E-383 +1E-398 -> -9.99999999999999E-384 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+ddfma37972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+ddfma37973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+ddfma37976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+ddfma37977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+ddfma37978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+ddfma37979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+ddfma37980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+ddfma37981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+ddfma37984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+ddfma37985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+ddfma37986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+ddfma37989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+ddfma37994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+ddfma37997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+ddfma371100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+ddfma371101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+ddfma371103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+ddfma371104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+ddfma371105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+ddfma371106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+ddfma371107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+ddfma371108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+ddfma371109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+ddfma371110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+ddfma371111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+ddfma371113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+ddfma371114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+ddfma371115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+ddfma371116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+ddfma371117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+ddfma371118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+ddfma371119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+ddfma371300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+ddfma371311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+ddfma371312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+ddfma371313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+ddfma371314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+ddfma371315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+ddfma371316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+ddfma371317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+ddfma371318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+ddfma371319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+ddfma371320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+ddfma371321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+ddfma371325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+ddfma371340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+ddfma371341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+ddfma371349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+ddfma371350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+ddfma371351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+ddfma371352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+ddfma371353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+ddfma371354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+ddfma371355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+ddfma371356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+ddfma371357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+ddfma371358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+ddfma371359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+ddfma371360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+ddfma371361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+ddfma371365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+ddfma371396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+ddfma371420 fma 1 0 1.123456789012345 -> 1.123456789012345
+ddfma371421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+ddfma371422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+ddfma371423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+ddfma371424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+ddfma371425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+ddfma371426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+ddfma371427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+ddfma371428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+ddfma371429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+ddfma371430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+ddfma371431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+ddfma371432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+ddfma371433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+ddfma371434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+ddfma371435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+ddfma371436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+ddfma371437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+ddfma371438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+ddfma371439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+ddfma371440 fma 1 1.123456789012345 0 -> 1.123456789012345
+ddfma371441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+ddfma371442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+ddfma371443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+ddfma371444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+ddfma371445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+ddfma371446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+ddfma371447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+ddfma371448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+ddfma371449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+ddfma371450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+ddfma371451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+ddfma371452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+ddfma371453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+ddfma371454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+ddfma371455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+ddfma371456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+ddfma371457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+ddfma371458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+ddfma371459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+ddfma371460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+ddfma371461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+ddfma371462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+ddfma371463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+ddfma371464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+ddfma371465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+ddfma371466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+ddfma371467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+ddfma371468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+ddfma371469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+ddfma371470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+ddfma371471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+ddfma371472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+ddfma371473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+ddfma371474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+ddfma371475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+ddfma371476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+ddfma371477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+ddfma371478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+ddfma371479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+ddfma371500 fma 1 0 0E-19 -> 0E-19
+ddfma371501 fma 1 -0 0E-19 -> 0E-19
+ddfma371502 fma 1 0 -0E-19 -> 0E-19
+ddfma371503 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371511 fma 1 -11 11 -> 0
+ddfma371512 fma 1 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+ddfma371520 fma 1 0 0E-19 -> 0E-19
+ddfma371521 fma 1 -0 0E-19 -> 0E-19
+ddfma371522 fma 1 0 -0E-19 -> 0E-19
+ddfma371523 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371531 fma 1 -11 11 -> 0
+ddfma371532 fma 1 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+ddfma371540 fma 1 0 0E-19 -> 0E-19
+ddfma371541 fma 1 -0 0E-19 -> 0E-19
+ddfma371542 fma 1 0 -0E-19 -> 0E-19
+ddfma371543 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371551 fma 1 -11 11 -> 0
+ddfma371552 fma 1 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+ddfma371560 fma 1 0 0E-19 -> 0E-19
+ddfma371561 fma 1 -0 0E-19 -> 0E-19
+ddfma371562 fma 1 0 -0E-19 -> 0E-19
+ddfma371563 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371571 fma 1 -11 11 -> 0
+ddfma371572 fma 1 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+ddfma371580 fma 1 0 0E-19 -> 0E-19
+ddfma371581 fma 1 -0 0E-19 -> 0E-19
+ddfma371582 fma 1 0 -0E-19 -> 0E-19
+ddfma371583 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371591 fma 1 -11 11 -> 0
+ddfma371592 fma 1 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+ddfma371600 fma 1 0 0E-19 -> 0E-19
+ddfma371601 fma 1 -0 0E-19 -> 0E-19
+ddfma371602 fma 1 0 -0E-19 -> 0E-19
+ddfma371603 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371611 fma 1 -11 11 -> 0
+ddfma371612 fma 1 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+ddfma371620 fma 1 0 0E-19 -> 0E-19
+ddfma371621 fma 1 -0 0E-19 -> -0E-19 -- *
+ddfma371622 fma 1 0 -0E-19 -> -0E-19 -- *
+ddfma371623 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+ddfma371631 fma 1 -11 11 -> -0 -- *
+ddfma371632 fma 1 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+ddfma371701 fma 1 130E-2 120E-2 -> 2.50
+ddfma371702 fma 1 130E-2 12E-1 -> 2.50
+ddfma371703 fma 1 130E-2 1E0 -> 2.30
+ddfma371704 fma 1 1E2 1E4 -> 1.01E+4
+ddfma371705 fma 1 130E-2 -120E-2 -> 0.10
+ddfma371706 fma 1 130E-2 -12E-1 -> 0.10
+ddfma371707 fma 1 130E-2 -1E0 -> 0.30
+ddfma371708 fma 1 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+ddfma375001 fma 1 1234567890123456 1 -> 1234567890123457
+ddfma375002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+ddfma375003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+ddfma375004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+ddfma375005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+ddfma375006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+ddfma375007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+ddfma375008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+ddfma375009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+ddfma375010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+ddfma375011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+ddfma375012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+ddfma375013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+ddfma375014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+ddfma375015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+ddfma375016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+ddfma375017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+ddfma375018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+ddfma375019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+ddfma375020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+ddfma375021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+ddfma375030 fma 1 12345678 1 -> 12345679
+ddfma375031 fma 1 12345678 0.1 -> 12345678.1
+ddfma375032 fma 1 12345678 0.12 -> 12345678.12
+ddfma375033 fma 1 12345678 0.123 -> 12345678.123
+ddfma375034 fma 1 12345678 0.1234 -> 12345678.1234
+ddfma375035 fma 1 12345678 0.12345 -> 12345678.12345
+ddfma375036 fma 1 12345678 0.123456 -> 12345678.123456
+ddfma375037 fma 1 12345678 0.1234567 -> 12345678.1234567
+ddfma375038 fma 1 12345678 0.12345678 -> 12345678.12345678
+ddfma375039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+ddfma375040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+ddfma375041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+ddfma375042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+ddfma375043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+ddfma375044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+ddfma375045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+ddfma375046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+ddfma375047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+ddfma375048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+ddfma375049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+ddfma375050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+ddfma375051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+ddfma375052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+ddfma375053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+ddfma375054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+ddfma375055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+ddfma375056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+ddfma375057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+ddfma375060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+ddfma375061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+ddfma375062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+ddfma375063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+ddfma375064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+ddfma375065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+ddfma375066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+ddfma375067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+ddfma375070 fma 1 12345678 1E-8 -> 12345678.00000001
+ddfma375071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+ddfma375072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+ddfma375073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+ddfma375074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+ddfma375075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+ddfma375076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+ddfma375077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+ddfma375078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+ddfma375079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+ddfma375080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+ddfma375081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+ddfma375082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+ddfma375083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+ddfma375084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+ddfma375085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+ddfma375086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+ddfma375087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+ddfma375088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+ddfma375089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- desctructive subtraction (from remainder tests)
+
+-- +++ some of these will be off-by-one remainder vs remainderNear
+
+ddfma4000 fma -1234567890123454 1.000000000000001 1234567890123456 -> 0.765432109876546
+ddfma4001 fma -1234567890123443 1.00000000000001 1234567890123456 -> 0.65432109876557
+ddfma4002 fma -1234567890123332 1.0000000000001 1234567890123456 -> 0.5432109876668
+ddfma4003 fma -308641972530863 4.000000000000001 1234567890123455 -> 2.691358027469137
+ddfma4004 fma -308641972530863 4.000000000000001 1234567890123456 -> 3.691358027469137
+ddfma4005 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
+ddfma4006 fma -246913578024691 4.99999999999999 1234567890123456 -> 3.46913578024691
+ddfma4007 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
+ddfma4008 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
+ddfma4009 fma -246913578024690 5.00000000000001 1234567890123456 -> 3.53086421975310
+ddfma4010 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
+ddfma4011 fma -1234567890123455 1.000000000000001 1234567890123456 -> -0.234567890123455
+ddfma4012 fma -1234567890123444 1.00000000000001 1234567890123456 -> -0.34567890123444
+ddfma4013 fma -1234567890123333 1.0000000000001 1234567890123456 -> -0.4567890123333
+ddfma4014 fma -308641972530864 4.000000000000001 1234567890123455 -> -1.308641972530864
+ddfma4015 fma -308641972530864 4.000000000000001 1234567890123456 -> -0.308641972530864
+ddfma4016 fma -246913578024696 4.9999999999999 1234567890123456 -> 0.6913578024696
+ddfma4017 fma -246913578024692 4.99999999999999 1234567890123456 -> -1.53086421975308
+ddfma4018 fma -246913578024691 4.999999999999999 1234567890123456 -> 1.246913578024691
+ddfma4019 fma -246913578024691 5.000000000000001 1234567890123456 -> 0.753086421975309
+ddfma4020 fma -246913578024691 5.00000000000001 1234567890123456 -> -1.46913578024691
+ddfma4021 fma -246913578024686 5.0000000000001 1234567890123456 -> 1.3086421975314
+
+
+-- Null tests
+ddfma39990 fma 1 10 # -> NaN Invalid_operation
+ddfma39991 fma 1 # 10 -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/ddInvert.decTest b/Lib/test/decimaltestdata/ddInvert.decTest
index 5d19fba829b..321e4e9ee97 100644
--- a/Lib/test/decimaltestdata/ddInvert.decTest
+++ b/Lib/test/decimaltestdata/ddInvert.decTest
@@ -1,202 +1,202 @@
-------------------------------------------------------------------------
--- ddInvert.decTest -- digitwise logical INVERT for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddinv001 invert 0 -> 1111111111111111
-ddinv002 invert 1 -> 1111111111111110
-ddinv003 invert 10 -> 1111111111111101
-ddinv004 invert 111111111 -> 1111111000000000
-ddinv005 invert 000000000 -> 1111111111111111
--- and at msd and msd-1
-ddinv007 invert 0000000000000000 -> 1111111111111111
-ddinv008 invert 1000000000000000 -> 111111111111111
-ddinv009 invert 0000000000000000 -> 1111111111111111
-ddinv010 invert 0100000000000000 -> 1011111111111111
-ddinv011 invert 0111111111111111 -> 1000000000000000
-ddinv012 invert 1111111111111111 -> 0
-ddinv013 invert 0011111111111111 -> 1100000000000000
-ddinv014 invert 0111111111111111 -> 1000000000000000
-
--- Various lengths
--- 123456789 1234567890123456
-ddinv021 invert 111111111 -> 1111111000000000
-ddinv022 invert 111111111111 -> 1111000000000000
-ddinv023 invert 11111111 -> 1111111100000000
-ddinv025 invert 1111111 -> 1111111110000000
-ddinv026 invert 111111 -> 1111111111000000
-ddinv027 invert 11111 -> 1111111111100000
-ddinv028 invert 1111 -> 1111111111110000
-ddinv029 invert 111 -> 1111111111111000
-ddinv031 invert 11 -> 1111111111111100
-ddinv032 invert 1 -> 1111111111111110
-ddinv033 invert 111111111111 -> 1111000000000000
-ddinv034 invert 11111111111 -> 1111100000000000
-ddinv035 invert 1111111111 -> 1111110000000000
-ddinv036 invert 111111111 -> 1111111000000000
-
-ddinv040 invert 011111111 -> 1111111100000000
-ddinv041 invert 101111111 -> 1111111010000000
-ddinv042 invert 110111111 -> 1111111001000000
-ddinv043 invert 111011111 -> 1111111000100000
-ddinv044 invert 111101111 -> 1111111000010000
-ddinv045 invert 111110111 -> 1111111000001000
-ddinv046 invert 111111011 -> 1111111000000100
-ddinv047 invert 111111101 -> 1111111000000010
-ddinv048 invert 111111110 -> 1111111000000001
-ddinv049 invert 011111011 -> 1111111100000100
-ddinv050 invert 101111101 -> 1111111010000010
-ddinv051 invert 110111110 -> 1111111001000001
-ddinv052 invert 111011101 -> 1111111000100010
-ddinv053 invert 111101011 -> 1111111000010100
-ddinv054 invert 111110111 -> 1111111000001000
-ddinv055 invert 111101011 -> 1111111000010100
-ddinv056 invert 111011101 -> 1111111000100010
-ddinv057 invert 110111110 -> 1111111001000001
-ddinv058 invert 101111101 -> 1111111010000010
-ddinv059 invert 011111011 -> 1111111100000100
-
-ddinv080 invert 1000000011111111 -> 111111100000000
-ddinv081 invert 0100000101111111 -> 1011111010000000
-ddinv082 invert 0010000110111111 -> 1101111001000000
-ddinv083 invert 0001000111011111 -> 1110111000100000
-ddinv084 invert 0000100111101111 -> 1111011000010000
-ddinv085 invert 0000010111110111 -> 1111101000001000
-ddinv086 invert 0000001111111011 -> 1111110000000100
-ddinv087 invert 0000010111111101 -> 1111101000000010
-ddinv088 invert 0000100111111110 -> 1111011000000001
-ddinv089 invert 0001000011111011 -> 1110111100000100
-ddinv090 invert 0010000101111101 -> 1101111010000010
-ddinv091 invert 0100000110111110 -> 1011111001000001
-ddinv092 invert 1000000111011101 -> 111111000100010
-ddinv093 invert 0100000111101011 -> 1011111000010100
-ddinv094 invert 0010000111110111 -> 1101111000001000
-ddinv095 invert 0001000111101011 -> 1110111000010100
-ddinv096 invert 0000100111011101 -> 1111011000100010
-ddinv097 invert 0000010110111110 -> 1111101001000001
-ddinv098 invert 0000001101111101 -> 1111110010000010
-ddinv099 invert 0000010011111011 -> 1111101100000100
-
--- non-0/1 should not be accepted, nor should signs
-ddinv220 invert 111111112 -> NaN Invalid_operation
-ddinv221 invert 333333333 -> NaN Invalid_operation
-ddinv222 invert 555555555 -> NaN Invalid_operation
-ddinv223 invert 777777777 -> NaN Invalid_operation
-ddinv224 invert 999999999 -> NaN Invalid_operation
-ddinv225 invert 222222222 -> NaN Invalid_operation
-ddinv226 invert 444444444 -> NaN Invalid_operation
-ddinv227 invert 666666666 -> NaN Invalid_operation
-ddinv228 invert 888888888 -> NaN Invalid_operation
-ddinv229 invert 999999999 -> NaN Invalid_operation
-ddinv230 invert 999999999 -> NaN Invalid_operation
-ddinv231 invert 999999999 -> NaN Invalid_operation
-ddinv232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-ddinv240 invert 567468689 -> NaN Invalid_operation
-ddinv241 invert 567367689 -> NaN Invalid_operation
-ddinv242 invert -631917772 -> NaN Invalid_operation
-ddinv243 invert -756253257 -> NaN Invalid_operation
-ddinv244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-ddinv250 invert 2000000000000000 -> NaN Invalid_operation
-ddinv251 invert 3000000000000000 -> NaN Invalid_operation
-ddinv252 invert 4000000000000000 -> NaN Invalid_operation
-ddinv253 invert 5000000000000000 -> NaN Invalid_operation
-ddinv254 invert 6000000000000000 -> NaN Invalid_operation
-ddinv255 invert 7000000000000000 -> NaN Invalid_operation
-ddinv256 invert 8000000000000000 -> NaN Invalid_operation
-ddinv257 invert 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddinv270 invert 0200001000000000 -> NaN Invalid_operation
-ddinv271 invert 0300000100000000 -> NaN Invalid_operation
-ddinv272 invert 0400000010000000 -> NaN Invalid_operation
-ddinv273 invert 0500000001000000 -> NaN Invalid_operation
-ddinv274 invert 1600000000100000 -> NaN Invalid_operation
-ddinv275 invert 1700000000010000 -> NaN Invalid_operation
-ddinv276 invert 1800000000001000 -> NaN Invalid_operation
-ddinv277 invert 1900000000000100 -> NaN Invalid_operation
--- test LSD
-ddinv280 invert 0010000000000002 -> NaN Invalid_operation
-ddinv281 invert 0001000000000003 -> NaN Invalid_operation
-ddinv282 invert 0000100000000004 -> NaN Invalid_operation
-ddinv283 invert 0000010000000005 -> NaN Invalid_operation
-ddinv284 invert 1000001000000006 -> NaN Invalid_operation
-ddinv285 invert 1000000100000007 -> NaN Invalid_operation
-ddinv286 invert 1000000010000008 -> NaN Invalid_operation
-ddinv287 invert 1000000001000009 -> NaN Invalid_operation
--- test Middie
-ddinv288 invert 0010000020000000 -> NaN Invalid_operation
-ddinv289 invert 0001000030000001 -> NaN Invalid_operation
-ddinv290 invert 0000100040000010 -> NaN Invalid_operation
-ddinv291 invert 0000010050000100 -> NaN Invalid_operation
-ddinv292 invert 1000001060001000 -> NaN Invalid_operation
-ddinv293 invert 1000000170010000 -> NaN Invalid_operation
-ddinv294 invert 1000000080100000 -> NaN Invalid_operation
-ddinv295 invert 1000000091000000 -> NaN Invalid_operation
--- sign
-ddinv296 invert -1000000001000000 -> NaN Invalid_operation
-ddinv299 invert 1000000001000000 -> 111111110111111
-
-
--- Nmax, Nmin, Ntiny-like
-ddinv341 invert 9.99999999E+299 -> NaN Invalid_operation
-ddinv342 invert 1E-299 -> NaN Invalid_operation
-ddinv343 invert 1.00000000E-299 -> NaN Invalid_operation
-ddinv344 invert 1E-207 -> NaN Invalid_operation
-ddinv345 invert -1E-207 -> NaN Invalid_operation
-ddinv346 invert -1.00000000E-299 -> NaN Invalid_operation
-ddinv347 invert -1E-299 -> NaN Invalid_operation
-ddinv348 invert -9.99999999E+299 -> NaN Invalid_operation
-
--- A few other non-integers
-ddinv361 invert 1.0 -> NaN Invalid_operation
-ddinv362 invert 1E+1 -> NaN Invalid_operation
-ddinv363 invert 0.0 -> NaN Invalid_operation
-ddinv364 invert 0E+1 -> NaN Invalid_operation
-ddinv365 invert 9.9 -> NaN Invalid_operation
-ddinv366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddinv788 invert -Inf -> NaN Invalid_operation
-ddinv794 invert Inf -> NaN Invalid_operation
-ddinv821 invert NaN -> NaN Invalid_operation
-ddinv841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-ddinv861 invert NaN1 -> NaN Invalid_operation
-ddinv862 invert +NaN2 -> NaN Invalid_operation
-ddinv863 invert NaN3 -> NaN Invalid_operation
-ddinv864 invert NaN4 -> NaN Invalid_operation
-ddinv865 invert NaN5 -> NaN Invalid_operation
-ddinv871 invert sNaN11 -> NaN Invalid_operation
-ddinv872 invert sNaN12 -> NaN Invalid_operation
-ddinv873 invert sNaN13 -> NaN Invalid_operation
-ddinv874 invert sNaN14 -> NaN Invalid_operation
-ddinv875 invert sNaN15 -> NaN Invalid_operation
-ddinv876 invert NaN16 -> NaN Invalid_operation
-ddinv881 invert +NaN25 -> NaN Invalid_operation
-ddinv882 invert -NaN26 -> NaN Invalid_operation
-ddinv883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddInvert.decTest -- digitwise logical INVERT for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddinv001 invert 0 -> 1111111111111111
+ddinv002 invert 1 -> 1111111111111110
+ddinv003 invert 10 -> 1111111111111101
+ddinv004 invert 111111111 -> 1111111000000000
+ddinv005 invert 000000000 -> 1111111111111111
+-- and at msd and msd-1
+ddinv007 invert 0000000000000000 -> 1111111111111111
+ddinv008 invert 1000000000000000 -> 111111111111111
+ddinv009 invert 0000000000000000 -> 1111111111111111
+ddinv010 invert 0100000000000000 -> 1011111111111111
+ddinv011 invert 0111111111111111 -> 1000000000000000
+ddinv012 invert 1111111111111111 -> 0
+ddinv013 invert 0011111111111111 -> 1100000000000000
+ddinv014 invert 0111111111111111 -> 1000000000000000
+
+-- Various lengths
+-- 123456789 1234567890123456
+ddinv021 invert 111111111 -> 1111111000000000
+ddinv022 invert 111111111111 -> 1111000000000000
+ddinv023 invert 11111111 -> 1111111100000000
+ddinv025 invert 1111111 -> 1111111110000000
+ddinv026 invert 111111 -> 1111111111000000
+ddinv027 invert 11111 -> 1111111111100000
+ddinv028 invert 1111 -> 1111111111110000
+ddinv029 invert 111 -> 1111111111111000
+ddinv031 invert 11 -> 1111111111111100
+ddinv032 invert 1 -> 1111111111111110
+ddinv033 invert 111111111111 -> 1111000000000000
+ddinv034 invert 11111111111 -> 1111100000000000
+ddinv035 invert 1111111111 -> 1111110000000000
+ddinv036 invert 111111111 -> 1111111000000000
+
+ddinv040 invert 011111111 -> 1111111100000000
+ddinv041 invert 101111111 -> 1111111010000000
+ddinv042 invert 110111111 -> 1111111001000000
+ddinv043 invert 111011111 -> 1111111000100000
+ddinv044 invert 111101111 -> 1111111000010000
+ddinv045 invert 111110111 -> 1111111000001000
+ddinv046 invert 111111011 -> 1111111000000100
+ddinv047 invert 111111101 -> 1111111000000010
+ddinv048 invert 111111110 -> 1111111000000001
+ddinv049 invert 011111011 -> 1111111100000100
+ddinv050 invert 101111101 -> 1111111010000010
+ddinv051 invert 110111110 -> 1111111001000001
+ddinv052 invert 111011101 -> 1111111000100010
+ddinv053 invert 111101011 -> 1111111000010100
+ddinv054 invert 111110111 -> 1111111000001000
+ddinv055 invert 111101011 -> 1111111000010100
+ddinv056 invert 111011101 -> 1111111000100010
+ddinv057 invert 110111110 -> 1111111001000001
+ddinv058 invert 101111101 -> 1111111010000010
+ddinv059 invert 011111011 -> 1111111100000100
+
+ddinv080 invert 1000000011111111 -> 111111100000000
+ddinv081 invert 0100000101111111 -> 1011111010000000
+ddinv082 invert 0010000110111111 -> 1101111001000000
+ddinv083 invert 0001000111011111 -> 1110111000100000
+ddinv084 invert 0000100111101111 -> 1111011000010000
+ddinv085 invert 0000010111110111 -> 1111101000001000
+ddinv086 invert 0000001111111011 -> 1111110000000100
+ddinv087 invert 0000010111111101 -> 1111101000000010
+ddinv088 invert 0000100111111110 -> 1111011000000001
+ddinv089 invert 0001000011111011 -> 1110111100000100
+ddinv090 invert 0010000101111101 -> 1101111010000010
+ddinv091 invert 0100000110111110 -> 1011111001000001
+ddinv092 invert 1000000111011101 -> 111111000100010
+ddinv093 invert 0100000111101011 -> 1011111000010100
+ddinv094 invert 0010000111110111 -> 1101111000001000
+ddinv095 invert 0001000111101011 -> 1110111000010100
+ddinv096 invert 0000100111011101 -> 1111011000100010
+ddinv097 invert 0000010110111110 -> 1111101001000001
+ddinv098 invert 0000001101111101 -> 1111110010000010
+ddinv099 invert 0000010011111011 -> 1111101100000100
+
+-- non-0/1 should not be accepted, nor should signs
+ddinv220 invert 111111112 -> NaN Invalid_operation
+ddinv221 invert 333333333 -> NaN Invalid_operation
+ddinv222 invert 555555555 -> NaN Invalid_operation
+ddinv223 invert 777777777 -> NaN Invalid_operation
+ddinv224 invert 999999999 -> NaN Invalid_operation
+ddinv225 invert 222222222 -> NaN Invalid_operation
+ddinv226 invert 444444444 -> NaN Invalid_operation
+ddinv227 invert 666666666 -> NaN Invalid_operation
+ddinv228 invert 888888888 -> NaN Invalid_operation
+ddinv229 invert 999999999 -> NaN Invalid_operation
+ddinv230 invert 999999999 -> NaN Invalid_operation
+ddinv231 invert 999999999 -> NaN Invalid_operation
+ddinv232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+ddinv240 invert 567468689 -> NaN Invalid_operation
+ddinv241 invert 567367689 -> NaN Invalid_operation
+ddinv242 invert -631917772 -> NaN Invalid_operation
+ddinv243 invert -756253257 -> NaN Invalid_operation
+ddinv244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+ddinv250 invert 2000000000000000 -> NaN Invalid_operation
+ddinv251 invert 3000000000000000 -> NaN Invalid_operation
+ddinv252 invert 4000000000000000 -> NaN Invalid_operation
+ddinv253 invert 5000000000000000 -> NaN Invalid_operation
+ddinv254 invert 6000000000000000 -> NaN Invalid_operation
+ddinv255 invert 7000000000000000 -> NaN Invalid_operation
+ddinv256 invert 8000000000000000 -> NaN Invalid_operation
+ddinv257 invert 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddinv270 invert 0200001000000000 -> NaN Invalid_operation
+ddinv271 invert 0300000100000000 -> NaN Invalid_operation
+ddinv272 invert 0400000010000000 -> NaN Invalid_operation
+ddinv273 invert 0500000001000000 -> NaN Invalid_operation
+ddinv274 invert 1600000000100000 -> NaN Invalid_operation
+ddinv275 invert 1700000000010000 -> NaN Invalid_operation
+ddinv276 invert 1800000000001000 -> NaN Invalid_operation
+ddinv277 invert 1900000000000100 -> NaN Invalid_operation
+-- test LSD
+ddinv280 invert 0010000000000002 -> NaN Invalid_operation
+ddinv281 invert 0001000000000003 -> NaN Invalid_operation
+ddinv282 invert 0000100000000004 -> NaN Invalid_operation
+ddinv283 invert 0000010000000005 -> NaN Invalid_operation
+ddinv284 invert 1000001000000006 -> NaN Invalid_operation
+ddinv285 invert 1000000100000007 -> NaN Invalid_operation
+ddinv286 invert 1000000010000008 -> NaN Invalid_operation
+ddinv287 invert 1000000001000009 -> NaN Invalid_operation
+-- test Middie
+ddinv288 invert 0010000020000000 -> NaN Invalid_operation
+ddinv289 invert 0001000030000001 -> NaN Invalid_operation
+ddinv290 invert 0000100040000010 -> NaN Invalid_operation
+ddinv291 invert 0000010050000100 -> NaN Invalid_operation
+ddinv292 invert 1000001060001000 -> NaN Invalid_operation
+ddinv293 invert 1000000170010000 -> NaN Invalid_operation
+ddinv294 invert 1000000080100000 -> NaN Invalid_operation
+ddinv295 invert 1000000091000000 -> NaN Invalid_operation
+-- sign
+ddinv296 invert -1000000001000000 -> NaN Invalid_operation
+ddinv299 invert 1000000001000000 -> 111111110111111
+
+
+-- Nmax, Nmin, Ntiny-like
+ddinv341 invert 9.99999999E+299 -> NaN Invalid_operation
+ddinv342 invert 1E-299 -> NaN Invalid_operation
+ddinv343 invert 1.00000000E-299 -> NaN Invalid_operation
+ddinv344 invert 1E-207 -> NaN Invalid_operation
+ddinv345 invert -1E-207 -> NaN Invalid_operation
+ddinv346 invert -1.00000000E-299 -> NaN Invalid_operation
+ddinv347 invert -1E-299 -> NaN Invalid_operation
+ddinv348 invert -9.99999999E+299 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddinv361 invert 1.0 -> NaN Invalid_operation
+ddinv362 invert 1E+1 -> NaN Invalid_operation
+ddinv363 invert 0.0 -> NaN Invalid_operation
+ddinv364 invert 0E+1 -> NaN Invalid_operation
+ddinv365 invert 9.9 -> NaN Invalid_operation
+ddinv366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddinv788 invert -Inf -> NaN Invalid_operation
+ddinv794 invert Inf -> NaN Invalid_operation
+ddinv821 invert NaN -> NaN Invalid_operation
+ddinv841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+ddinv861 invert NaN1 -> NaN Invalid_operation
+ddinv862 invert +NaN2 -> NaN Invalid_operation
+ddinv863 invert NaN3 -> NaN Invalid_operation
+ddinv864 invert NaN4 -> NaN Invalid_operation
+ddinv865 invert NaN5 -> NaN Invalid_operation
+ddinv871 invert sNaN11 -> NaN Invalid_operation
+ddinv872 invert sNaN12 -> NaN Invalid_operation
+ddinv873 invert sNaN13 -> NaN Invalid_operation
+ddinv874 invert sNaN14 -> NaN Invalid_operation
+ddinv875 invert sNaN15 -> NaN Invalid_operation
+ddinv876 invert NaN16 -> NaN Invalid_operation
+ddinv881 invert +NaN25 -> NaN Invalid_operation
+ddinv882 invert -NaN26 -> NaN Invalid_operation
+ddinv883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddLogB.decTest b/Lib/test/decimaltestdata/ddLogB.decTest
index de728e5968d..00589b60c35 100644
--- a/Lib/test/decimaltestdata/ddLogB.decTest
+++ b/Lib/test/decimaltestdata/ddLogB.decTest
@@ -1,159 +1,159 @@
-------------------------------------------------------------------------
--- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- basics
-ddlogb000 logb 0 -> -Infinity Division_by_zero
-ddlogb001 logb 1E-398 -> -398
-ddlogb002 logb 1E-383 -> -383
-ddlogb003 logb 0.001 -> -3
-ddlogb004 logb 0.03 -> -2
-ddlogb005 logb 1 -> 0
-ddlogb006 logb 2 -> 0
-ddlogb007 logb 2.5 -> 0
-ddlogb008 logb 2.500 -> 0
-ddlogb009 logb 10 -> 1
-ddlogb010 logb 70 -> 1
-ddlogb011 logb 100 -> 2
-ddlogb012 logb 333 -> 2
-ddlogb013 logb 9E+384 -> 384
-ddlogb014 logb +Infinity -> Infinity
-
--- negatives appear to be treated as positives
-ddlogb021 logb -0 -> -Infinity Division_by_zero
-ddlogb022 logb -1E-398 -> -398
-ddlogb023 logb -9E-383 -> -383
-ddlogb024 logb -0.001 -> -3
-ddlogb025 logb -1 -> 0
-ddlogb026 logb -2 -> 0
-ddlogb027 logb -10 -> 1
-ddlogb028 logb -70 -> 1
-ddlogb029 logb -100 -> 2
-ddlogb030 logb -9E+384 -> 384
-ddlogb031 logb -Infinity -> Infinity
-
--- zeros
-ddlogb111 logb 0 -> -Infinity Division_by_zero
-ddlogb112 logb -0 -> -Infinity Division_by_zero
-ddlogb113 logb 0E+4 -> -Infinity Division_by_zero
-ddlogb114 logb -0E+4 -> -Infinity Division_by_zero
-ddlogb115 logb 0.0000 -> -Infinity Division_by_zero
-ddlogb116 logb -0.0000 -> -Infinity Division_by_zero
-ddlogb117 logb 0E-141 -> -Infinity Division_by_zero
-ddlogb118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-ddlogb121 logb 268268268 -> 8
-ddlogb122 logb -268268268 -> 8
-ddlogb123 logb 134134134 -> 8
-ddlogb124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-ddlogb131 logb 9.999999999999999E+384 -> 384
-ddlogb132 logb 1E-383 -> -383
-ddlogb133 logb 1.000000000000000E-383 -> -383
-ddlogb134 logb 1E-398 -> -398
-
-ddlogb135 logb -1E-398 -> -398
-ddlogb136 logb -1.000000000000000E-383 -> -383
-ddlogb137 logb -1E-383 -> -383
-ddlogb138 logb -9.999999999999999E+384 -> 384
-
--- ones
-ddlogb0061 logb 1 -> 0
-ddlogb0062 logb 1.0 -> 0
-ddlogb0063 logb 1.000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-ddlogb1100 logb 1 -> 0
-ddlogb1101 logb 10 -> 1
-ddlogb1102 logb 100 -> 2
-ddlogb1103 logb 1000 -> 3
-ddlogb1104 logb 10000 -> 4
-ddlogb1105 logb 100000 -> 5
-ddlogb1106 logb 1000000 -> 6
-ddlogb1107 logb 10000000 -> 7
-ddlogb1108 logb 100000000 -> 8
-ddlogb1109 logb 1000000000 -> 9
-ddlogb1110 logb 10000000000 -> 10
-ddlogb1111 logb 100000000000 -> 11
-ddlogb1112 logb 1000000000000 -> 12
-ddlogb1113 logb 0.00000000001 -> -11
-ddlogb1114 logb 0.0000000001 -> -10
-ddlogb1115 logb 0.000000001 -> -9
-ddlogb1116 logb 0.00000001 -> -8
-ddlogb1117 logb 0.0000001 -> -7
-ddlogb1118 logb 0.000001 -> -6
-ddlogb1119 logb 0.00001 -> -5
-ddlogb1120 logb 0.0001 -> -4
-ddlogb1121 logb 0.001 -> -3
-ddlogb1122 logb 0.01 -> -2
-ddlogb1123 logb 0.1 -> -1
-ddlogb1124 logb 1E-99 -> -99
-ddlogb1125 logb 1E-100 -> -100
-ddlogb1127 logb 1E-299 -> -299
-ddlogb1126 logb 1E-383 -> -383
-
--- suggestions from Ilan Nehama
-ddlogb1400 logb 10E-3 -> -2
-ddlogb1401 logb 10E-2 -> -1
-ddlogb1402 logb 100E-2 -> 0
-ddlogb1403 logb 1000E-2 -> 1
-ddlogb1404 logb 10000E-2 -> 2
-ddlogb1405 logb 10E-1 -> 0
-ddlogb1406 logb 100E-1 -> 1
-ddlogb1407 logb 1000E-1 -> 2
-ddlogb1408 logb 10000E-1 -> 3
-ddlogb1409 logb 10E0 -> 1
-ddlogb1410 logb 100E0 -> 2
-ddlogb1411 logb 1000E0 -> 3
-ddlogb1412 logb 10000E0 -> 4
-ddlogb1413 logb 10E1 -> 2
-ddlogb1414 logb 100E1 -> 3
-ddlogb1415 logb 1000E1 -> 4
-ddlogb1416 logb 10000E1 -> 5
-ddlogb1417 logb 10E2 -> 3
-ddlogb1418 logb 100E2 -> 4
-ddlogb1419 logb 1000E2 -> 5
-ddlogb1420 logb 10000E2 -> 6
-
--- special values
-ddlogb820 logb Infinity -> Infinity
-ddlogb821 logb 0 -> -Infinity Division_by_zero
-ddlogb822 logb NaN -> NaN
-ddlogb823 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-ddlogb824 logb sNaN123 -> NaN123 Invalid_operation
-ddlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
-ddlogb826 logb NaN456 -> NaN456
-ddlogb827 logb -NaN654 -> -NaN654
-ddlogb828 logb NaN1 -> NaN1
-
--- Null test
-ddlogb900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ddLogB.decTest -- integral 754r adjusted exponent, for decDoubles --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- basics
+ddlogb000 logb 0 -> -Infinity Division_by_zero
+ddlogb001 logb 1E-398 -> -398
+ddlogb002 logb 1E-383 -> -383
+ddlogb003 logb 0.001 -> -3
+ddlogb004 logb 0.03 -> -2
+ddlogb005 logb 1 -> 0
+ddlogb006 logb 2 -> 0
+ddlogb007 logb 2.5 -> 0
+ddlogb008 logb 2.500 -> 0
+ddlogb009 logb 10 -> 1
+ddlogb010 logb 70 -> 1
+ddlogb011 logb 100 -> 2
+ddlogb012 logb 333 -> 2
+ddlogb013 logb 9E+384 -> 384
+ddlogb014 logb +Infinity -> Infinity
+
+-- negatives appear to be treated as positives
+ddlogb021 logb -0 -> -Infinity Division_by_zero
+ddlogb022 logb -1E-398 -> -398
+ddlogb023 logb -9E-383 -> -383
+ddlogb024 logb -0.001 -> -3
+ddlogb025 logb -1 -> 0
+ddlogb026 logb -2 -> 0
+ddlogb027 logb -10 -> 1
+ddlogb028 logb -70 -> 1
+ddlogb029 logb -100 -> 2
+ddlogb030 logb -9E+384 -> 384
+ddlogb031 logb -Infinity -> Infinity
+
+-- zeros
+ddlogb111 logb 0 -> -Infinity Division_by_zero
+ddlogb112 logb -0 -> -Infinity Division_by_zero
+ddlogb113 logb 0E+4 -> -Infinity Division_by_zero
+ddlogb114 logb -0E+4 -> -Infinity Division_by_zero
+ddlogb115 logb 0.0000 -> -Infinity Division_by_zero
+ddlogb116 logb -0.0000 -> -Infinity Division_by_zero
+ddlogb117 logb 0E-141 -> -Infinity Division_by_zero
+ddlogb118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+ddlogb121 logb 268268268 -> 8
+ddlogb122 logb -268268268 -> 8
+ddlogb123 logb 134134134 -> 8
+ddlogb124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+ddlogb131 logb 9.999999999999999E+384 -> 384
+ddlogb132 logb 1E-383 -> -383
+ddlogb133 logb 1.000000000000000E-383 -> -383
+ddlogb134 logb 1E-398 -> -398
+
+ddlogb135 logb -1E-398 -> -398
+ddlogb136 logb -1.000000000000000E-383 -> -383
+ddlogb137 logb -1E-383 -> -383
+ddlogb138 logb -9.999999999999999E+384 -> 384
+
+-- ones
+ddlogb0061 logb 1 -> 0
+ddlogb0062 logb 1.0 -> 0
+ddlogb0063 logb 1.000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+ddlogb1100 logb 1 -> 0
+ddlogb1101 logb 10 -> 1
+ddlogb1102 logb 100 -> 2
+ddlogb1103 logb 1000 -> 3
+ddlogb1104 logb 10000 -> 4
+ddlogb1105 logb 100000 -> 5
+ddlogb1106 logb 1000000 -> 6
+ddlogb1107 logb 10000000 -> 7
+ddlogb1108 logb 100000000 -> 8
+ddlogb1109 logb 1000000000 -> 9
+ddlogb1110 logb 10000000000 -> 10
+ddlogb1111 logb 100000000000 -> 11
+ddlogb1112 logb 1000000000000 -> 12
+ddlogb1113 logb 0.00000000001 -> -11
+ddlogb1114 logb 0.0000000001 -> -10
+ddlogb1115 logb 0.000000001 -> -9
+ddlogb1116 logb 0.00000001 -> -8
+ddlogb1117 logb 0.0000001 -> -7
+ddlogb1118 logb 0.000001 -> -6
+ddlogb1119 logb 0.00001 -> -5
+ddlogb1120 logb 0.0001 -> -4
+ddlogb1121 logb 0.001 -> -3
+ddlogb1122 logb 0.01 -> -2
+ddlogb1123 logb 0.1 -> -1
+ddlogb1124 logb 1E-99 -> -99
+ddlogb1125 logb 1E-100 -> -100
+ddlogb1127 logb 1E-299 -> -299
+ddlogb1126 logb 1E-383 -> -383
+
+-- suggestions from Ilan Nehama
+ddlogb1400 logb 10E-3 -> -2
+ddlogb1401 logb 10E-2 -> -1
+ddlogb1402 logb 100E-2 -> 0
+ddlogb1403 logb 1000E-2 -> 1
+ddlogb1404 logb 10000E-2 -> 2
+ddlogb1405 logb 10E-1 -> 0
+ddlogb1406 logb 100E-1 -> 1
+ddlogb1407 logb 1000E-1 -> 2
+ddlogb1408 logb 10000E-1 -> 3
+ddlogb1409 logb 10E0 -> 1
+ddlogb1410 logb 100E0 -> 2
+ddlogb1411 logb 1000E0 -> 3
+ddlogb1412 logb 10000E0 -> 4
+ddlogb1413 logb 10E1 -> 2
+ddlogb1414 logb 100E1 -> 3
+ddlogb1415 logb 1000E1 -> 4
+ddlogb1416 logb 10000E1 -> 5
+ddlogb1417 logb 10E2 -> 3
+ddlogb1418 logb 100E2 -> 4
+ddlogb1419 logb 1000E2 -> 5
+ddlogb1420 logb 10000E2 -> 6
+
+-- special values
+ddlogb820 logb Infinity -> Infinity
+ddlogb821 logb 0 -> -Infinity Division_by_zero
+ddlogb822 logb NaN -> NaN
+ddlogb823 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+ddlogb824 logb sNaN123 -> NaN123 Invalid_operation
+ddlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
+ddlogb826 logb NaN456 -> NaN456
+ddlogb827 logb -NaN654 -> -NaN654
+ddlogb828 logb NaN1 -> NaN1
+
+-- Null test
+ddlogb900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/ddMax.decTest b/Lib/test/decimaltestdata/ddMax.decTest
index 1ac63958b87..45ea9b4c933 100644
--- a/Lib/test/decimaltestdata/ddMax.decTest
+++ b/Lib/test/decimaltestdata/ddMax.decTest
@@ -1,322 +1,322 @@
-------------------------------------------------------------------------
--- ddMax.decTest -- decDouble maxnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmax001 max -2 -2 -> -2
-ddmax002 max -2 -1 -> -1
-ddmax003 max -2 0 -> 0
-ddmax004 max -2 1 -> 1
-ddmax005 max -2 2 -> 2
-ddmax006 max -1 -2 -> -1
-ddmax007 max -1 -1 -> -1
-ddmax008 max -1 0 -> 0
-ddmax009 max -1 1 -> 1
-ddmax010 max -1 2 -> 2
-ddmax011 max 0 -2 -> 0
-ddmax012 max 0 -1 -> 0
-ddmax013 max 0 0 -> 0
-ddmax014 max 0 1 -> 1
-ddmax015 max 0 2 -> 2
-ddmax016 max 1 -2 -> 1
-ddmax017 max 1 -1 -> 1
-ddmax018 max 1 0 -> 1
-ddmax019 max 1 1 -> 1
-ddmax020 max 1 2 -> 2
-ddmax021 max 2 -2 -> 2
-ddmax022 max 2 -1 -> 2
-ddmax023 max 2 0 -> 2
-ddmax025 max 2 1 -> 2
-ddmax026 max 2 2 -> 2
-
--- extended zeros
-ddmax030 max 0 0 -> 0
-ddmax031 max 0 -0 -> 0
-ddmax032 max 0 -0.0 -> 0
-ddmax033 max 0 0.0 -> 0
-ddmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-ddmax035 max -0 -0 -> -0
-ddmax036 max -0 -0.0 -> -0.0
-ddmax037 max -0 0.0 -> 0.0
-ddmax038 max 0.0 0 -> 0
-ddmax039 max 0.0 -0 -> 0.0
-ddmax040 max 0.0 -0.0 -> 0.0
-ddmax041 max 0.0 0.0 -> 0.0
-ddmax042 max -0.0 0 -> 0
-ddmax043 max -0.0 -0 -> -0.0
-ddmax044 max -0.0 -0.0 -> -0.0
-ddmax045 max -0.0 0.0 -> 0.0
-
-ddmax050 max -0E1 0E1 -> 0E+1
-ddmax051 max -0E2 0E2 -> 0E+2
-ddmax052 max -0E2 0E1 -> 0E+1
-ddmax053 max -0E1 0E2 -> 0E+2
-ddmax054 max 0E1 -0E1 -> 0E+1
-ddmax055 max 0E2 -0E2 -> 0E+2
-ddmax056 max 0E2 -0E1 -> 0E+2
-ddmax057 max 0E1 -0E2 -> 0E+1
-
-ddmax058 max 0E1 0E1 -> 0E+1
-ddmax059 max 0E2 0E2 -> 0E+2
-ddmax060 max 0E2 0E1 -> 0E+2
-ddmax061 max 0E1 0E2 -> 0E+2
-ddmax062 max -0E1 -0E1 -> -0E+1
-ddmax063 max -0E2 -0E2 -> -0E+2
-ddmax064 max -0E2 -0E1 -> -0E+1
-ddmax065 max -0E1 -0E2 -> -0E+1
-
--- Specials
-ddmax090 max Inf -Inf -> Infinity
-ddmax091 max Inf -1000 -> Infinity
-ddmax092 max Inf -1 -> Infinity
-ddmax093 max Inf -0 -> Infinity
-ddmax094 max Inf 0 -> Infinity
-ddmax095 max Inf 1 -> Infinity
-ddmax096 max Inf 1000 -> Infinity
-ddmax097 max Inf Inf -> Infinity
-ddmax098 max -1000 Inf -> Infinity
-ddmax099 max -Inf Inf -> Infinity
-ddmax100 max -1 Inf -> Infinity
-ddmax101 max -0 Inf -> Infinity
-ddmax102 max 0 Inf -> Infinity
-ddmax103 max 1 Inf -> Infinity
-ddmax104 max 1000 Inf -> Infinity
-ddmax105 max Inf Inf -> Infinity
-
-ddmax120 max -Inf -Inf -> -Infinity
-ddmax121 max -Inf -1000 -> -1000
-ddmax122 max -Inf -1 -> -1
-ddmax123 max -Inf -0 -> -0
-ddmax124 max -Inf 0 -> 0
-ddmax125 max -Inf 1 -> 1
-ddmax126 max -Inf 1000 -> 1000
-ddmax127 max -Inf Inf -> Infinity
-ddmax128 max -Inf -Inf -> -Infinity
-ddmax129 max -1000 -Inf -> -1000
-ddmax130 max -1 -Inf -> -1
-ddmax131 max -0 -Inf -> -0
-ddmax132 max 0 -Inf -> 0
-ddmax133 max 1 -Inf -> 1
-ddmax134 max 1000 -Inf -> 1000
-ddmax135 max Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmax141 max NaN -Inf -> -Infinity
-ddmax142 max NaN -1000 -> -1000
-ddmax143 max NaN -1 -> -1
-ddmax144 max NaN -0 -> -0
-ddmax145 max NaN 0 -> 0
-ddmax146 max NaN 1 -> 1
-ddmax147 max NaN 1000 -> 1000
-ddmax148 max NaN Inf -> Infinity
-ddmax149 max NaN NaN -> NaN
-ddmax150 max -Inf NaN -> -Infinity
-ddmax151 max -1000 NaN -> -1000
-ddmax152 max -1 NaN -> -1
-ddmax153 max -0 NaN -> -0
-ddmax154 max 0 NaN -> 0
-ddmax155 max 1 NaN -> 1
-ddmax156 max 1000 NaN -> 1000
-ddmax157 max Inf NaN -> Infinity
-
-ddmax161 max sNaN -Inf -> NaN Invalid_operation
-ddmax162 max sNaN -1000 -> NaN Invalid_operation
-ddmax163 max sNaN -1 -> NaN Invalid_operation
-ddmax164 max sNaN -0 -> NaN Invalid_operation
-ddmax165 max sNaN 0 -> NaN Invalid_operation
-ddmax166 max sNaN 1 -> NaN Invalid_operation
-ddmax167 max sNaN 1000 -> NaN Invalid_operation
-ddmax168 max sNaN NaN -> NaN Invalid_operation
-ddmax169 max sNaN sNaN -> NaN Invalid_operation
-ddmax170 max NaN sNaN -> NaN Invalid_operation
-ddmax171 max -Inf sNaN -> NaN Invalid_operation
-ddmax172 max -1000 sNaN -> NaN Invalid_operation
-ddmax173 max -1 sNaN -> NaN Invalid_operation
-ddmax174 max -0 sNaN -> NaN Invalid_operation
-ddmax175 max 0 sNaN -> NaN Invalid_operation
-ddmax176 max 1 sNaN -> NaN Invalid_operation
-ddmax177 max 1000 sNaN -> NaN Invalid_operation
-ddmax178 max Inf sNaN -> NaN Invalid_operation
-ddmax179 max NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmax181 max NaN9 -Inf -> -Infinity
-ddmax182 max NaN8 9 -> 9
-ddmax183 max -NaN7 Inf -> Infinity
-
-ddmax184 max -NaN1 NaN11 -> -NaN1
-ddmax185 max NaN2 NaN12 -> NaN2
-ddmax186 max -NaN13 -NaN7 -> -NaN13
-ddmax187 max NaN14 -NaN5 -> NaN14
-
-ddmax188 max -Inf NaN4 -> -Infinity
-ddmax189 max -9 -NaN3 -> -9
-ddmax190 max Inf NaN2 -> Infinity
-
-ddmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
-ddmax192 max sNaN98 -1 -> NaN98 Invalid_operation
-ddmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
-ddmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
-ddmax197 max 0 sNaN91 -> NaN91 Invalid_operation
-ddmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmax199 max NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-ddmax221 max 12345678000 1 -> 12345678000
-ddmax222 max 1 12345678000 -> 12345678000
-ddmax223 max 1234567800 1 -> 1234567800
-ddmax224 max 1 1234567800 -> 1234567800
-ddmax225 max 1234567890 1 -> 1234567890
-ddmax226 max 1 1234567890 -> 1234567890
-ddmax227 max 1234567891 1 -> 1234567891
-ddmax228 max 1 1234567891 -> 1234567891
-ddmax229 max 12345678901 1 -> 12345678901
-ddmax230 max 1 12345678901 -> 12345678901
-ddmax231 max 1234567896 1 -> 1234567896
-ddmax232 max 1 1234567896 -> 1234567896
-ddmax233 max -1234567891 1 -> 1
-ddmax234 max 1 -1234567891 -> 1
-ddmax235 max -12345678901 1 -> 1
-ddmax236 max 1 -12345678901 -> 1
-ddmax237 max -1234567896 1 -> 1
-ddmax238 max 1 -1234567896 -> 1
-
--- from examples
-ddmax280 max '3' '2' -> '3'
-ddmax281 max '-10' '3' -> '3'
-ddmax282 max '1.0' '1' -> '1'
-ddmax283 max '1' '1.0' -> '1'
-ddmax284 max '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmax401 max Inf 1.1 -> Infinity
-ddmax402 max 1.1 1 -> 1.1
-ddmax403 max 1 1.0 -> 1
-ddmax404 max 1.0 0.1 -> 1.0
-ddmax405 max 0.1 0.10 -> 0.1
-ddmax406 max 0.10 0.100 -> 0.10
-ddmax407 max 0.10 0 -> 0.10
-ddmax408 max 0 0.0 -> 0
-ddmax409 max 0.0 -0 -> 0.0
-ddmax410 max 0.0 -0.0 -> 0.0
-ddmax411 max 0.00 -0.0 -> 0.00
-ddmax412 max 0.0 -0.00 -> 0.0
-ddmax413 max 0 -0.0 -> 0
-ddmax414 max 0 -0 -> 0
-ddmax415 max -0.0 -0 -> -0.0
-ddmax416 max -0 -0.100 -> -0
-ddmax417 max -0.100 -0.10 -> -0.100
-ddmax418 max -0.10 -0.1 -> -0.10
-ddmax419 max -0.1 -1.0 -> -0.1
-ddmax420 max -1.0 -1 -> -1.0
-ddmax421 max -1 -1.1 -> -1
-ddmax423 max -1.1 -Inf -> -1.1
--- same with operands reversed
-ddmax431 max 1.1 Inf -> Infinity
-ddmax432 max 1 1.1 -> 1.1
-ddmax433 max 1.0 1 -> 1
-ddmax434 max 0.1 1.0 -> 1.0
-ddmax435 max 0.10 0.1 -> 0.1
-ddmax436 max 0.100 0.10 -> 0.10
-ddmax437 max 0 0.10 -> 0.10
-ddmax438 max 0.0 0 -> 0
-ddmax439 max -0 0.0 -> 0.0
-ddmax440 max -0.0 0.0 -> 0.0
-ddmax441 max -0.0 0.00 -> 0.00
-ddmax442 max -0.00 0.0 -> 0.0
-ddmax443 max -0.0 0 -> 0
-ddmax444 max -0 0 -> 0
-ddmax445 max -0 -0.0 -> -0.0
-ddmax446 max -0.100 -0 -> -0
-ddmax447 max -0.10 -0.100 -> -0.100
-ddmax448 max -0.1 -0.10 -> -0.10
-ddmax449 max -1.0 -0.1 -> -0.1
-ddmax450 max -1 -1.0 -> -1.0
-ddmax451 max -1.1 -1 -> -1
-ddmax453 max -Inf -1.1 -> -1.1
--- largies
-ddmax460 max 1000 1E+3 -> 1E+3
-ddmax461 max 1E+3 1000 -> 1E+3
-ddmax462 max 1000 -1E+3 -> 1000
-ddmax463 max 1E+3 -1000 -> 1E+3
-ddmax464 max -1000 1E+3 -> 1E+3
-ddmax465 max -1E+3 1000 -> 1000
-ddmax466 max -1000 -1E+3 -> -1000
-ddmax467 max -1E+3 -1000 -> -1000
-
--- misalignment traps for little-endian
-ddmax471 max 1.0 0.1 -> 1.0
-ddmax472 max 0.1 1.0 -> 1.0
-ddmax473 max 10.0 0.1 -> 10.0
-ddmax474 max 0.1 10.0 -> 10.0
-ddmax475 max 100 1.0 -> 100
-ddmax476 max 1.0 100 -> 100
-ddmax477 max 1000 10.0 -> 1000
-ddmax478 max 10.0 1000 -> 1000
-ddmax479 max 10000 100.0 -> 10000
-ddmax480 max 100.0 10000 -> 10000
-ddmax481 max 100000 1000.0 -> 100000
-ddmax482 max 1000.0 100000 -> 100000
-ddmax483 max 1000000 10000.0 -> 1000000
-ddmax484 max 10000.0 1000000 -> 1000000
-
--- subnormals
-ddmax510 max 1.00E-383 0 -> 1.00E-383
-ddmax511 max 0.1E-383 0 -> 1E-384 Subnormal
-ddmax512 max 0.10E-383 0 -> 1.0E-384 Subnormal
-ddmax513 max 0.100E-383 0 -> 1.00E-384 Subnormal
-ddmax514 max 0.01E-383 0 -> 1E-385 Subnormal
-ddmax515 max 0.999E-383 0 -> 9.99E-384 Subnormal
-ddmax516 max 0.099E-383 0 -> 9.9E-385 Subnormal
-ddmax517 max 0.009E-383 0 -> 9E-386 Subnormal
-ddmax518 max 0.001E-383 0 -> 1E-386 Subnormal
-ddmax519 max 0.0009E-383 0 -> 9E-387 Subnormal
-ddmax520 max 0.0001E-383 0 -> 1E-387 Subnormal
-
-ddmax530 max -1.00E-383 0 -> 0
-ddmax531 max -0.1E-383 0 -> 0
-ddmax532 max -0.10E-383 0 -> 0
-ddmax533 max -0.100E-383 0 -> 0
-ddmax534 max -0.01E-383 0 -> 0
-ddmax535 max -0.999E-383 0 -> 0
-ddmax536 max -0.099E-383 0 -> 0
-ddmax537 max -0.009E-383 0 -> 0
-ddmax538 max -0.001E-383 0 -> 0
-ddmax539 max -0.0009E-383 0 -> 0
-ddmax540 max -0.0001E-383 0 -> 0
-
--- Null tests
-ddmax900 max 10 # -> NaN Invalid_operation
-ddmax901 max # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- ddMax.decTest -- decDouble maxnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmax001 max -2 -2 -> -2
+ddmax002 max -2 -1 -> -1
+ddmax003 max -2 0 -> 0
+ddmax004 max -2 1 -> 1
+ddmax005 max -2 2 -> 2
+ddmax006 max -1 -2 -> -1
+ddmax007 max -1 -1 -> -1
+ddmax008 max -1 0 -> 0
+ddmax009 max -1 1 -> 1
+ddmax010 max -1 2 -> 2
+ddmax011 max 0 -2 -> 0
+ddmax012 max 0 -1 -> 0
+ddmax013 max 0 0 -> 0
+ddmax014 max 0 1 -> 1
+ddmax015 max 0 2 -> 2
+ddmax016 max 1 -2 -> 1
+ddmax017 max 1 -1 -> 1
+ddmax018 max 1 0 -> 1
+ddmax019 max 1 1 -> 1
+ddmax020 max 1 2 -> 2
+ddmax021 max 2 -2 -> 2
+ddmax022 max 2 -1 -> 2
+ddmax023 max 2 0 -> 2
+ddmax025 max 2 1 -> 2
+ddmax026 max 2 2 -> 2
+
+-- extended zeros
+ddmax030 max 0 0 -> 0
+ddmax031 max 0 -0 -> 0
+ddmax032 max 0 -0.0 -> 0
+ddmax033 max 0 0.0 -> 0
+ddmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+ddmax035 max -0 -0 -> -0
+ddmax036 max -0 -0.0 -> -0.0
+ddmax037 max -0 0.0 -> 0.0
+ddmax038 max 0.0 0 -> 0
+ddmax039 max 0.0 -0 -> 0.0
+ddmax040 max 0.0 -0.0 -> 0.0
+ddmax041 max 0.0 0.0 -> 0.0
+ddmax042 max -0.0 0 -> 0
+ddmax043 max -0.0 -0 -> -0.0
+ddmax044 max -0.0 -0.0 -> -0.0
+ddmax045 max -0.0 0.0 -> 0.0
+
+ddmax050 max -0E1 0E1 -> 0E+1
+ddmax051 max -0E2 0E2 -> 0E+2
+ddmax052 max -0E2 0E1 -> 0E+1
+ddmax053 max -0E1 0E2 -> 0E+2
+ddmax054 max 0E1 -0E1 -> 0E+1
+ddmax055 max 0E2 -0E2 -> 0E+2
+ddmax056 max 0E2 -0E1 -> 0E+2
+ddmax057 max 0E1 -0E2 -> 0E+1
+
+ddmax058 max 0E1 0E1 -> 0E+1
+ddmax059 max 0E2 0E2 -> 0E+2
+ddmax060 max 0E2 0E1 -> 0E+2
+ddmax061 max 0E1 0E2 -> 0E+2
+ddmax062 max -0E1 -0E1 -> -0E+1
+ddmax063 max -0E2 -0E2 -> -0E+2
+ddmax064 max -0E2 -0E1 -> -0E+1
+ddmax065 max -0E1 -0E2 -> -0E+1
+
+-- Specials
+ddmax090 max Inf -Inf -> Infinity
+ddmax091 max Inf -1000 -> Infinity
+ddmax092 max Inf -1 -> Infinity
+ddmax093 max Inf -0 -> Infinity
+ddmax094 max Inf 0 -> Infinity
+ddmax095 max Inf 1 -> Infinity
+ddmax096 max Inf 1000 -> Infinity
+ddmax097 max Inf Inf -> Infinity
+ddmax098 max -1000 Inf -> Infinity
+ddmax099 max -Inf Inf -> Infinity
+ddmax100 max -1 Inf -> Infinity
+ddmax101 max -0 Inf -> Infinity
+ddmax102 max 0 Inf -> Infinity
+ddmax103 max 1 Inf -> Infinity
+ddmax104 max 1000 Inf -> Infinity
+ddmax105 max Inf Inf -> Infinity
+
+ddmax120 max -Inf -Inf -> -Infinity
+ddmax121 max -Inf -1000 -> -1000
+ddmax122 max -Inf -1 -> -1
+ddmax123 max -Inf -0 -> -0
+ddmax124 max -Inf 0 -> 0
+ddmax125 max -Inf 1 -> 1
+ddmax126 max -Inf 1000 -> 1000
+ddmax127 max -Inf Inf -> Infinity
+ddmax128 max -Inf -Inf -> -Infinity
+ddmax129 max -1000 -Inf -> -1000
+ddmax130 max -1 -Inf -> -1
+ddmax131 max -0 -Inf -> -0
+ddmax132 max 0 -Inf -> 0
+ddmax133 max 1 -Inf -> 1
+ddmax134 max 1000 -Inf -> 1000
+ddmax135 max Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmax141 max NaN -Inf -> -Infinity
+ddmax142 max NaN -1000 -> -1000
+ddmax143 max NaN -1 -> -1
+ddmax144 max NaN -0 -> -0
+ddmax145 max NaN 0 -> 0
+ddmax146 max NaN 1 -> 1
+ddmax147 max NaN 1000 -> 1000
+ddmax148 max NaN Inf -> Infinity
+ddmax149 max NaN NaN -> NaN
+ddmax150 max -Inf NaN -> -Infinity
+ddmax151 max -1000 NaN -> -1000
+ddmax152 max -1 NaN -> -1
+ddmax153 max -0 NaN -> -0
+ddmax154 max 0 NaN -> 0
+ddmax155 max 1 NaN -> 1
+ddmax156 max 1000 NaN -> 1000
+ddmax157 max Inf NaN -> Infinity
+
+ddmax161 max sNaN -Inf -> NaN Invalid_operation
+ddmax162 max sNaN -1000 -> NaN Invalid_operation
+ddmax163 max sNaN -1 -> NaN Invalid_operation
+ddmax164 max sNaN -0 -> NaN Invalid_operation
+ddmax165 max sNaN 0 -> NaN Invalid_operation
+ddmax166 max sNaN 1 -> NaN Invalid_operation
+ddmax167 max sNaN 1000 -> NaN Invalid_operation
+ddmax168 max sNaN NaN -> NaN Invalid_operation
+ddmax169 max sNaN sNaN -> NaN Invalid_operation
+ddmax170 max NaN sNaN -> NaN Invalid_operation
+ddmax171 max -Inf sNaN -> NaN Invalid_operation
+ddmax172 max -1000 sNaN -> NaN Invalid_operation
+ddmax173 max -1 sNaN -> NaN Invalid_operation
+ddmax174 max -0 sNaN -> NaN Invalid_operation
+ddmax175 max 0 sNaN -> NaN Invalid_operation
+ddmax176 max 1 sNaN -> NaN Invalid_operation
+ddmax177 max 1000 sNaN -> NaN Invalid_operation
+ddmax178 max Inf sNaN -> NaN Invalid_operation
+ddmax179 max NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmax181 max NaN9 -Inf -> -Infinity
+ddmax182 max NaN8 9 -> 9
+ddmax183 max -NaN7 Inf -> Infinity
+
+ddmax184 max -NaN1 NaN11 -> -NaN1
+ddmax185 max NaN2 NaN12 -> NaN2
+ddmax186 max -NaN13 -NaN7 -> -NaN13
+ddmax187 max NaN14 -NaN5 -> NaN14
+
+ddmax188 max -Inf NaN4 -> -Infinity
+ddmax189 max -9 -NaN3 -> -9
+ddmax190 max Inf NaN2 -> Infinity
+
+ddmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
+ddmax192 max sNaN98 -1 -> NaN98 Invalid_operation
+ddmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
+ddmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
+ddmax197 max 0 sNaN91 -> NaN91 Invalid_operation
+ddmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmax199 max NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+ddmax221 max 12345678000 1 -> 12345678000
+ddmax222 max 1 12345678000 -> 12345678000
+ddmax223 max 1234567800 1 -> 1234567800
+ddmax224 max 1 1234567800 -> 1234567800
+ddmax225 max 1234567890 1 -> 1234567890
+ddmax226 max 1 1234567890 -> 1234567890
+ddmax227 max 1234567891 1 -> 1234567891
+ddmax228 max 1 1234567891 -> 1234567891
+ddmax229 max 12345678901 1 -> 12345678901
+ddmax230 max 1 12345678901 -> 12345678901
+ddmax231 max 1234567896 1 -> 1234567896
+ddmax232 max 1 1234567896 -> 1234567896
+ddmax233 max -1234567891 1 -> 1
+ddmax234 max 1 -1234567891 -> 1
+ddmax235 max -12345678901 1 -> 1
+ddmax236 max 1 -12345678901 -> 1
+ddmax237 max -1234567896 1 -> 1
+ddmax238 max 1 -1234567896 -> 1
+
+-- from examples
+ddmax280 max '3' '2' -> '3'
+ddmax281 max '-10' '3' -> '3'
+ddmax282 max '1.0' '1' -> '1'
+ddmax283 max '1' '1.0' -> '1'
+ddmax284 max '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmax401 max Inf 1.1 -> Infinity
+ddmax402 max 1.1 1 -> 1.1
+ddmax403 max 1 1.0 -> 1
+ddmax404 max 1.0 0.1 -> 1.0
+ddmax405 max 0.1 0.10 -> 0.1
+ddmax406 max 0.10 0.100 -> 0.10
+ddmax407 max 0.10 0 -> 0.10
+ddmax408 max 0 0.0 -> 0
+ddmax409 max 0.0 -0 -> 0.0
+ddmax410 max 0.0 -0.0 -> 0.0
+ddmax411 max 0.00 -0.0 -> 0.00
+ddmax412 max 0.0 -0.00 -> 0.0
+ddmax413 max 0 -0.0 -> 0
+ddmax414 max 0 -0 -> 0
+ddmax415 max -0.0 -0 -> -0.0
+ddmax416 max -0 -0.100 -> -0
+ddmax417 max -0.100 -0.10 -> -0.100
+ddmax418 max -0.10 -0.1 -> -0.10
+ddmax419 max -0.1 -1.0 -> -0.1
+ddmax420 max -1.0 -1 -> -1.0
+ddmax421 max -1 -1.1 -> -1
+ddmax423 max -1.1 -Inf -> -1.1
+-- same with operands reversed
+ddmax431 max 1.1 Inf -> Infinity
+ddmax432 max 1 1.1 -> 1.1
+ddmax433 max 1.0 1 -> 1
+ddmax434 max 0.1 1.0 -> 1.0
+ddmax435 max 0.10 0.1 -> 0.1
+ddmax436 max 0.100 0.10 -> 0.10
+ddmax437 max 0 0.10 -> 0.10
+ddmax438 max 0.0 0 -> 0
+ddmax439 max -0 0.0 -> 0.0
+ddmax440 max -0.0 0.0 -> 0.0
+ddmax441 max -0.0 0.00 -> 0.00
+ddmax442 max -0.00 0.0 -> 0.0
+ddmax443 max -0.0 0 -> 0
+ddmax444 max -0 0 -> 0
+ddmax445 max -0 -0.0 -> -0.0
+ddmax446 max -0.100 -0 -> -0
+ddmax447 max -0.10 -0.100 -> -0.100
+ddmax448 max -0.1 -0.10 -> -0.10
+ddmax449 max -1.0 -0.1 -> -0.1
+ddmax450 max -1 -1.0 -> -1.0
+ddmax451 max -1.1 -1 -> -1
+ddmax453 max -Inf -1.1 -> -1.1
+-- largies
+ddmax460 max 1000 1E+3 -> 1E+3
+ddmax461 max 1E+3 1000 -> 1E+3
+ddmax462 max 1000 -1E+3 -> 1000
+ddmax463 max 1E+3 -1000 -> 1E+3
+ddmax464 max -1000 1E+3 -> 1E+3
+ddmax465 max -1E+3 1000 -> 1000
+ddmax466 max -1000 -1E+3 -> -1000
+ddmax467 max -1E+3 -1000 -> -1000
+
+-- misalignment traps for little-endian
+ddmax471 max 1.0 0.1 -> 1.0
+ddmax472 max 0.1 1.0 -> 1.0
+ddmax473 max 10.0 0.1 -> 10.0
+ddmax474 max 0.1 10.0 -> 10.0
+ddmax475 max 100 1.0 -> 100
+ddmax476 max 1.0 100 -> 100
+ddmax477 max 1000 10.0 -> 1000
+ddmax478 max 10.0 1000 -> 1000
+ddmax479 max 10000 100.0 -> 10000
+ddmax480 max 100.0 10000 -> 10000
+ddmax481 max 100000 1000.0 -> 100000
+ddmax482 max 1000.0 100000 -> 100000
+ddmax483 max 1000000 10000.0 -> 1000000
+ddmax484 max 10000.0 1000000 -> 1000000
+
+-- subnormals
+ddmax510 max 1.00E-383 0 -> 1.00E-383
+ddmax511 max 0.1E-383 0 -> 1E-384 Subnormal
+ddmax512 max 0.10E-383 0 -> 1.0E-384 Subnormal
+ddmax513 max 0.100E-383 0 -> 1.00E-384 Subnormal
+ddmax514 max 0.01E-383 0 -> 1E-385 Subnormal
+ddmax515 max 0.999E-383 0 -> 9.99E-384 Subnormal
+ddmax516 max 0.099E-383 0 -> 9.9E-385 Subnormal
+ddmax517 max 0.009E-383 0 -> 9E-386 Subnormal
+ddmax518 max 0.001E-383 0 -> 1E-386 Subnormal
+ddmax519 max 0.0009E-383 0 -> 9E-387 Subnormal
+ddmax520 max 0.0001E-383 0 -> 1E-387 Subnormal
+
+ddmax530 max -1.00E-383 0 -> 0
+ddmax531 max -0.1E-383 0 -> 0
+ddmax532 max -0.10E-383 0 -> 0
+ddmax533 max -0.100E-383 0 -> 0
+ddmax534 max -0.01E-383 0 -> 0
+ddmax535 max -0.999E-383 0 -> 0
+ddmax536 max -0.099E-383 0 -> 0
+ddmax537 max -0.009E-383 0 -> 0
+ddmax538 max -0.001E-383 0 -> 0
+ddmax539 max -0.0009E-383 0 -> 0
+ddmax540 max -0.0001E-383 0 -> 0
+
+-- Null tests
+ddmax900 max 10 # -> NaN Invalid_operation
+ddmax901 max # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/ddMaxMag.decTest b/Lib/test/decimaltestdata/ddMaxMag.decTest
index 19c3e9085c2..ec2b8305411 100644
--- a/Lib/test/decimaltestdata/ddMaxMag.decTest
+++ b/Lib/test/decimaltestdata/ddMaxMag.decTest
@@ -1,304 +1,304 @@
-------------------------------------------------------------------------
--- ddMaxMag.decTest -- decDouble maxnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmxg001 maxmag -2 -2 -> -2
-ddmxg002 maxmag -2 -1 -> -2
-ddmxg003 maxmag -2 0 -> -2
-ddmxg004 maxmag -2 1 -> -2
-ddmxg005 maxmag -2 2 -> 2
-ddmxg006 maxmag -1 -2 -> -2
-ddmxg007 maxmag -1 -1 -> -1
-ddmxg008 maxmag -1 0 -> -1
-ddmxg009 maxmag -1 1 -> 1
-ddmxg010 maxmag -1 2 -> 2
-ddmxg011 maxmag 0 -2 -> -2
-ddmxg012 maxmag 0 -1 -> -1
-ddmxg013 maxmag 0 0 -> 0
-ddmxg014 maxmag 0 1 -> 1
-ddmxg015 maxmag 0 2 -> 2
-ddmxg016 maxmag 1 -2 -> -2
-ddmxg017 maxmag 1 -1 -> 1
-ddmxg018 maxmag 1 0 -> 1
-ddmxg019 maxmag 1 1 -> 1
-ddmxg020 maxmag 1 2 -> 2
-ddmxg021 maxmag 2 -2 -> 2
-ddmxg022 maxmag 2 -1 -> 2
-ddmxg023 maxmag 2 0 -> 2
-ddmxg025 maxmag 2 1 -> 2
-ddmxg026 maxmag 2 2 -> 2
-
--- extended zeros
-ddmxg030 maxmag 0 0 -> 0
-ddmxg031 maxmag 0 -0 -> 0
-ddmxg032 maxmag 0 -0.0 -> 0
-ddmxg033 maxmag 0 0.0 -> 0
-ddmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-ddmxg035 maxmag -0 -0 -> -0
-ddmxg036 maxmag -0 -0.0 -> -0.0
-ddmxg037 maxmag -0 0.0 -> 0.0
-ddmxg038 maxmag 0.0 0 -> 0
-ddmxg039 maxmag 0.0 -0 -> 0.0
-ddmxg040 maxmag 0.0 -0.0 -> 0.0
-ddmxg041 maxmag 0.0 0.0 -> 0.0
-ddmxg042 maxmag -0.0 0 -> 0
-ddmxg043 maxmag -0.0 -0 -> -0.0
-ddmxg044 maxmag -0.0 -0.0 -> -0.0
-ddmxg045 maxmag -0.0 0.0 -> 0.0
-
-ddmxg050 maxmag -0E1 0E1 -> 0E+1
-ddmxg051 maxmag -0E2 0E2 -> 0E+2
-ddmxg052 maxmag -0E2 0E1 -> 0E+1
-ddmxg053 maxmag -0E1 0E2 -> 0E+2
-ddmxg054 maxmag 0E1 -0E1 -> 0E+1
-ddmxg055 maxmag 0E2 -0E2 -> 0E+2
-ddmxg056 maxmag 0E2 -0E1 -> 0E+2
-ddmxg057 maxmag 0E1 -0E2 -> 0E+1
-
-ddmxg058 maxmag 0E1 0E1 -> 0E+1
-ddmxg059 maxmag 0E2 0E2 -> 0E+2
-ddmxg060 maxmag 0E2 0E1 -> 0E+2
-ddmxg061 maxmag 0E1 0E2 -> 0E+2
-ddmxg062 maxmag -0E1 -0E1 -> -0E+1
-ddmxg063 maxmag -0E2 -0E2 -> -0E+2
-ddmxg064 maxmag -0E2 -0E1 -> -0E+1
-ddmxg065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-ddmxg090 maxmag Inf -Inf -> Infinity
-ddmxg091 maxmag Inf -1000 -> Infinity
-ddmxg092 maxmag Inf -1 -> Infinity
-ddmxg093 maxmag Inf -0 -> Infinity
-ddmxg094 maxmag Inf 0 -> Infinity
-ddmxg095 maxmag Inf 1 -> Infinity
-ddmxg096 maxmag Inf 1000 -> Infinity
-ddmxg097 maxmag Inf Inf -> Infinity
-ddmxg098 maxmag -1000 Inf -> Infinity
-ddmxg099 maxmag -Inf Inf -> Infinity
-ddmxg100 maxmag -1 Inf -> Infinity
-ddmxg101 maxmag -0 Inf -> Infinity
-ddmxg102 maxmag 0 Inf -> Infinity
-ddmxg103 maxmag 1 Inf -> Infinity
-ddmxg104 maxmag 1000 Inf -> Infinity
-ddmxg105 maxmag Inf Inf -> Infinity
-
-ddmxg120 maxmag -Inf -Inf -> -Infinity
-ddmxg121 maxmag -Inf -1000 -> -Infinity
-ddmxg122 maxmag -Inf -1 -> -Infinity
-ddmxg123 maxmag -Inf -0 -> -Infinity
-ddmxg124 maxmag -Inf 0 -> -Infinity
-ddmxg125 maxmag -Inf 1 -> -Infinity
-ddmxg126 maxmag -Inf 1000 -> -Infinity
-ddmxg127 maxmag -Inf Inf -> Infinity
-ddmxg128 maxmag -Inf -Inf -> -Infinity
-ddmxg129 maxmag -1000 -Inf -> -Infinity
-ddmxg130 maxmag -1 -Inf -> -Infinity
-ddmxg131 maxmag -0 -Inf -> -Infinity
-ddmxg132 maxmag 0 -Inf -> -Infinity
-ddmxg133 maxmag 1 -Inf -> -Infinity
-ddmxg134 maxmag 1000 -Inf -> -Infinity
-ddmxg135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmxg141 maxmag NaN -Inf -> -Infinity
-ddmxg142 maxmag NaN -1000 -> -1000
-ddmxg143 maxmag NaN -1 -> -1
-ddmxg144 maxmag NaN -0 -> -0
-ddmxg145 maxmag NaN 0 -> 0
-ddmxg146 maxmag NaN 1 -> 1
-ddmxg147 maxmag NaN 1000 -> 1000
-ddmxg148 maxmag NaN Inf -> Infinity
-ddmxg149 maxmag NaN NaN -> NaN
-ddmxg150 maxmag -Inf NaN -> -Infinity
-ddmxg151 maxmag -1000 NaN -> -1000
-ddmxg152 maxmag -1 NaN -> -1
-ddmxg153 maxmag -0 NaN -> -0
-ddmxg154 maxmag 0 NaN -> 0
-ddmxg155 maxmag 1 NaN -> 1
-ddmxg156 maxmag 1000 NaN -> 1000
-ddmxg157 maxmag Inf NaN -> Infinity
-
-ddmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
-ddmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
-ddmxg163 maxmag sNaN -1 -> NaN Invalid_operation
-ddmxg164 maxmag sNaN -0 -> NaN Invalid_operation
-ddmxg165 maxmag sNaN 0 -> NaN Invalid_operation
-ddmxg166 maxmag sNaN 1 -> NaN Invalid_operation
-ddmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
-ddmxg168 maxmag sNaN NaN -> NaN Invalid_operation
-ddmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
-ddmxg170 maxmag NaN sNaN -> NaN Invalid_operation
-ddmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
-ddmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
-ddmxg173 maxmag -1 sNaN -> NaN Invalid_operation
-ddmxg174 maxmag -0 sNaN -> NaN Invalid_operation
-ddmxg175 maxmag 0 sNaN -> NaN Invalid_operation
-ddmxg176 maxmag 1 sNaN -> NaN Invalid_operation
-ddmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
-ddmxg178 maxmag Inf sNaN -> NaN Invalid_operation
-ddmxg179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmxg181 maxmag NaN9 -Inf -> -Infinity
-ddmxg182 maxmag NaN8 9 -> 9
-ddmxg183 maxmag -NaN7 Inf -> Infinity
-
-ddmxg184 maxmag -NaN1 NaN11 -> -NaN1
-ddmxg185 maxmag NaN2 NaN12 -> NaN2
-ddmxg186 maxmag -NaN13 -NaN7 -> -NaN13
-ddmxg187 maxmag NaN14 -NaN5 -> NaN14
-
-ddmxg188 maxmag -Inf NaN4 -> -Infinity
-ddmxg189 maxmag -9 -NaN3 -> -9
-ddmxg190 maxmag Inf NaN2 -> Infinity
-
-ddmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-ddmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-ddmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-ddmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-ddmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-ddmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-ddmxg221 maxmag 12345678000 1 -> 12345678000
-ddmxg222 maxmag 1 12345678000 -> 12345678000
-ddmxg223 maxmag 1234567800 1 -> 1234567800
-ddmxg224 maxmag 1 1234567800 -> 1234567800
-ddmxg225 maxmag 1234567890 1 -> 1234567890
-ddmxg226 maxmag 1 1234567890 -> 1234567890
-ddmxg227 maxmag 1234567891 1 -> 1234567891
-ddmxg228 maxmag 1 1234567891 -> 1234567891
-ddmxg229 maxmag 12345678901 1 -> 12345678901
-ddmxg230 maxmag 1 12345678901 -> 12345678901
-ddmxg231 maxmag 1234567896 1 -> 1234567896
-ddmxg232 maxmag 1 1234567896 -> 1234567896
-ddmxg233 maxmag -1234567891 1 -> -1234567891
-ddmxg234 maxmag 1 -1234567891 -> -1234567891
-ddmxg235 maxmag -12345678901 1 -> -12345678901
-ddmxg236 maxmag 1 -12345678901 -> -12345678901
-ddmxg237 maxmag -1234567896 1 -> -1234567896
-ddmxg238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-ddmxg280 maxmag '3' '2' -> '3'
-ddmxg281 maxmag '-10' '3' -> '-10'
-ddmxg282 maxmag '1.0' '1' -> '1'
-ddmxg283 maxmag '1' '1.0' -> '1'
-ddmxg284 maxmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmxg401 maxmag Inf 1.1 -> Infinity
-ddmxg402 maxmag 1.1 1 -> 1.1
-ddmxg403 maxmag 1 1.0 -> 1
-ddmxg404 maxmag 1.0 0.1 -> 1.0
-ddmxg405 maxmag 0.1 0.10 -> 0.1
-ddmxg406 maxmag 0.10 0.100 -> 0.10
-ddmxg407 maxmag 0.10 0 -> 0.10
-ddmxg408 maxmag 0 0.0 -> 0
-ddmxg409 maxmag 0.0 -0 -> 0.0
-ddmxg410 maxmag 0.0 -0.0 -> 0.0
-ddmxg411 maxmag 0.00 -0.0 -> 0.00
-ddmxg412 maxmag 0.0 -0.00 -> 0.0
-ddmxg413 maxmag 0 -0.0 -> 0
-ddmxg414 maxmag 0 -0 -> 0
-ddmxg415 maxmag -0.0 -0 -> -0.0
-ddmxg416 maxmag -0 -0.100 -> -0.100
-ddmxg417 maxmag -0.100 -0.10 -> -0.100
-ddmxg418 maxmag -0.10 -0.1 -> -0.10
-ddmxg419 maxmag -0.1 -1.0 -> -1.0
-ddmxg420 maxmag -1.0 -1 -> -1.0
-ddmxg421 maxmag -1 -1.1 -> -1.1
-ddmxg423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-ddmxg431 maxmag 1.1 Inf -> Infinity
-ddmxg432 maxmag 1 1.1 -> 1.1
-ddmxg433 maxmag 1.0 1 -> 1
-ddmxg434 maxmag 0.1 1.0 -> 1.0
-ddmxg435 maxmag 0.10 0.1 -> 0.1
-ddmxg436 maxmag 0.100 0.10 -> 0.10
-ddmxg437 maxmag 0 0.10 -> 0.10
-ddmxg438 maxmag 0.0 0 -> 0
-ddmxg439 maxmag -0 0.0 -> 0.0
-ddmxg440 maxmag -0.0 0.0 -> 0.0
-ddmxg441 maxmag -0.0 0.00 -> 0.00
-ddmxg442 maxmag -0.00 0.0 -> 0.0
-ddmxg443 maxmag -0.0 0 -> 0
-ddmxg444 maxmag -0 0 -> 0
-ddmxg445 maxmag -0 -0.0 -> -0.0
-ddmxg446 maxmag -0.100 -0 -> -0.100
-ddmxg447 maxmag -0.10 -0.100 -> -0.100
-ddmxg448 maxmag -0.1 -0.10 -> -0.10
-ddmxg449 maxmag -1.0 -0.1 -> -1.0
-ddmxg450 maxmag -1 -1.0 -> -1.0
-ddmxg451 maxmag -1.1 -1 -> -1.1
-ddmxg453 maxmag -Inf -1.1 -> -Infinity
--- largies
-ddmxg460 maxmag 1000 1E+3 -> 1E+3
-ddmxg461 maxmag 1E+3 1000 -> 1E+3
-ddmxg462 maxmag 1000 -1E+3 -> 1000
-ddmxg463 maxmag 1E+3 -1000 -> 1E+3
-ddmxg464 maxmag -1000 1E+3 -> 1E+3
-ddmxg465 maxmag -1E+3 1000 -> 1000
-ddmxg466 maxmag -1000 -1E+3 -> -1000
-ddmxg467 maxmag -1E+3 -1000 -> -1000
-
--- subnormals
-ddmxg510 maxmag 1.00E-383 0 -> 1.00E-383
-ddmxg511 maxmag 0.1E-383 0 -> 1E-384 Subnormal
-ddmxg512 maxmag 0.10E-383 0 -> 1.0E-384 Subnormal
-ddmxg513 maxmag 0.100E-383 0 -> 1.00E-384 Subnormal
-ddmxg514 maxmag 0.01E-383 0 -> 1E-385 Subnormal
-ddmxg515 maxmag 0.999E-383 0 -> 9.99E-384 Subnormal
-ddmxg516 maxmag 0.099E-383 0 -> 9.9E-385 Subnormal
-ddmxg517 maxmag 0.009E-383 0 -> 9E-386 Subnormal
-ddmxg518 maxmag 0.001E-383 0 -> 1E-386 Subnormal
-ddmxg519 maxmag 0.0009E-383 0 -> 9E-387 Subnormal
-ddmxg520 maxmag 0.0001E-383 0 -> 1E-387 Subnormal
-
-ddmxg530 maxmag -1.00E-383 0 -> -1.00E-383
-ddmxg531 maxmag -0.1E-383 0 -> -1E-384 Subnormal
-ddmxg532 maxmag -0.10E-383 0 -> -1.0E-384 Subnormal
-ddmxg533 maxmag -0.100E-383 0 -> -1.00E-384 Subnormal
-ddmxg534 maxmag -0.01E-383 0 -> -1E-385 Subnormal
-ddmxg535 maxmag -0.999E-383 0 -> -9.99E-384 Subnormal
-ddmxg536 maxmag -0.099E-383 0 -> -9.9E-385 Subnormal
-ddmxg537 maxmag -0.009E-383 0 -> -9E-386 Subnormal
-ddmxg538 maxmag -0.001E-383 0 -> -1E-386 Subnormal
-ddmxg539 maxmag -0.0009E-383 0 -> -9E-387 Subnormal
-ddmxg540 maxmag -0.0001E-383 0 -> -1E-387 Subnormal
-
--- Null tests
-ddmxg900 maxmag 10 # -> NaN Invalid_operation
-ddmxg901 maxmag # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddMaxMag.decTest -- decDouble maxnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmxg001 maxmag -2 -2 -> -2
+ddmxg002 maxmag -2 -1 -> -2
+ddmxg003 maxmag -2 0 -> -2
+ddmxg004 maxmag -2 1 -> -2
+ddmxg005 maxmag -2 2 -> 2
+ddmxg006 maxmag -1 -2 -> -2
+ddmxg007 maxmag -1 -1 -> -1
+ddmxg008 maxmag -1 0 -> -1
+ddmxg009 maxmag -1 1 -> 1
+ddmxg010 maxmag -1 2 -> 2
+ddmxg011 maxmag 0 -2 -> -2
+ddmxg012 maxmag 0 -1 -> -1
+ddmxg013 maxmag 0 0 -> 0
+ddmxg014 maxmag 0 1 -> 1
+ddmxg015 maxmag 0 2 -> 2
+ddmxg016 maxmag 1 -2 -> -2
+ddmxg017 maxmag 1 -1 -> 1
+ddmxg018 maxmag 1 0 -> 1
+ddmxg019 maxmag 1 1 -> 1
+ddmxg020 maxmag 1 2 -> 2
+ddmxg021 maxmag 2 -2 -> 2
+ddmxg022 maxmag 2 -1 -> 2
+ddmxg023 maxmag 2 0 -> 2
+ddmxg025 maxmag 2 1 -> 2
+ddmxg026 maxmag 2 2 -> 2
+
+-- extended zeros
+ddmxg030 maxmag 0 0 -> 0
+ddmxg031 maxmag 0 -0 -> 0
+ddmxg032 maxmag 0 -0.0 -> 0
+ddmxg033 maxmag 0 0.0 -> 0
+ddmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+ddmxg035 maxmag -0 -0 -> -0
+ddmxg036 maxmag -0 -0.0 -> -0.0
+ddmxg037 maxmag -0 0.0 -> 0.0
+ddmxg038 maxmag 0.0 0 -> 0
+ddmxg039 maxmag 0.0 -0 -> 0.0
+ddmxg040 maxmag 0.0 -0.0 -> 0.0
+ddmxg041 maxmag 0.0 0.0 -> 0.0
+ddmxg042 maxmag -0.0 0 -> 0
+ddmxg043 maxmag -0.0 -0 -> -0.0
+ddmxg044 maxmag -0.0 -0.0 -> -0.0
+ddmxg045 maxmag -0.0 0.0 -> 0.0
+
+ddmxg050 maxmag -0E1 0E1 -> 0E+1
+ddmxg051 maxmag -0E2 0E2 -> 0E+2
+ddmxg052 maxmag -0E2 0E1 -> 0E+1
+ddmxg053 maxmag -0E1 0E2 -> 0E+2
+ddmxg054 maxmag 0E1 -0E1 -> 0E+1
+ddmxg055 maxmag 0E2 -0E2 -> 0E+2
+ddmxg056 maxmag 0E2 -0E1 -> 0E+2
+ddmxg057 maxmag 0E1 -0E2 -> 0E+1
+
+ddmxg058 maxmag 0E1 0E1 -> 0E+1
+ddmxg059 maxmag 0E2 0E2 -> 0E+2
+ddmxg060 maxmag 0E2 0E1 -> 0E+2
+ddmxg061 maxmag 0E1 0E2 -> 0E+2
+ddmxg062 maxmag -0E1 -0E1 -> -0E+1
+ddmxg063 maxmag -0E2 -0E2 -> -0E+2
+ddmxg064 maxmag -0E2 -0E1 -> -0E+1
+ddmxg065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+ddmxg090 maxmag Inf -Inf -> Infinity
+ddmxg091 maxmag Inf -1000 -> Infinity
+ddmxg092 maxmag Inf -1 -> Infinity
+ddmxg093 maxmag Inf -0 -> Infinity
+ddmxg094 maxmag Inf 0 -> Infinity
+ddmxg095 maxmag Inf 1 -> Infinity
+ddmxg096 maxmag Inf 1000 -> Infinity
+ddmxg097 maxmag Inf Inf -> Infinity
+ddmxg098 maxmag -1000 Inf -> Infinity
+ddmxg099 maxmag -Inf Inf -> Infinity
+ddmxg100 maxmag -1 Inf -> Infinity
+ddmxg101 maxmag -0 Inf -> Infinity
+ddmxg102 maxmag 0 Inf -> Infinity
+ddmxg103 maxmag 1 Inf -> Infinity
+ddmxg104 maxmag 1000 Inf -> Infinity
+ddmxg105 maxmag Inf Inf -> Infinity
+
+ddmxg120 maxmag -Inf -Inf -> -Infinity
+ddmxg121 maxmag -Inf -1000 -> -Infinity
+ddmxg122 maxmag -Inf -1 -> -Infinity
+ddmxg123 maxmag -Inf -0 -> -Infinity
+ddmxg124 maxmag -Inf 0 -> -Infinity
+ddmxg125 maxmag -Inf 1 -> -Infinity
+ddmxg126 maxmag -Inf 1000 -> -Infinity
+ddmxg127 maxmag -Inf Inf -> Infinity
+ddmxg128 maxmag -Inf -Inf -> -Infinity
+ddmxg129 maxmag -1000 -Inf -> -Infinity
+ddmxg130 maxmag -1 -Inf -> -Infinity
+ddmxg131 maxmag -0 -Inf -> -Infinity
+ddmxg132 maxmag 0 -Inf -> -Infinity
+ddmxg133 maxmag 1 -Inf -> -Infinity
+ddmxg134 maxmag 1000 -Inf -> -Infinity
+ddmxg135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmxg141 maxmag NaN -Inf -> -Infinity
+ddmxg142 maxmag NaN -1000 -> -1000
+ddmxg143 maxmag NaN -1 -> -1
+ddmxg144 maxmag NaN -0 -> -0
+ddmxg145 maxmag NaN 0 -> 0
+ddmxg146 maxmag NaN 1 -> 1
+ddmxg147 maxmag NaN 1000 -> 1000
+ddmxg148 maxmag NaN Inf -> Infinity
+ddmxg149 maxmag NaN NaN -> NaN
+ddmxg150 maxmag -Inf NaN -> -Infinity
+ddmxg151 maxmag -1000 NaN -> -1000
+ddmxg152 maxmag -1 NaN -> -1
+ddmxg153 maxmag -0 NaN -> -0
+ddmxg154 maxmag 0 NaN -> 0
+ddmxg155 maxmag 1 NaN -> 1
+ddmxg156 maxmag 1000 NaN -> 1000
+ddmxg157 maxmag Inf NaN -> Infinity
+
+ddmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
+ddmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
+ddmxg163 maxmag sNaN -1 -> NaN Invalid_operation
+ddmxg164 maxmag sNaN -0 -> NaN Invalid_operation
+ddmxg165 maxmag sNaN 0 -> NaN Invalid_operation
+ddmxg166 maxmag sNaN 1 -> NaN Invalid_operation
+ddmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
+ddmxg168 maxmag sNaN NaN -> NaN Invalid_operation
+ddmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
+ddmxg170 maxmag NaN sNaN -> NaN Invalid_operation
+ddmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
+ddmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
+ddmxg173 maxmag -1 sNaN -> NaN Invalid_operation
+ddmxg174 maxmag -0 sNaN -> NaN Invalid_operation
+ddmxg175 maxmag 0 sNaN -> NaN Invalid_operation
+ddmxg176 maxmag 1 sNaN -> NaN Invalid_operation
+ddmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
+ddmxg178 maxmag Inf sNaN -> NaN Invalid_operation
+ddmxg179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmxg181 maxmag NaN9 -Inf -> -Infinity
+ddmxg182 maxmag NaN8 9 -> 9
+ddmxg183 maxmag -NaN7 Inf -> Infinity
+
+ddmxg184 maxmag -NaN1 NaN11 -> -NaN1
+ddmxg185 maxmag NaN2 NaN12 -> NaN2
+ddmxg186 maxmag -NaN13 -NaN7 -> -NaN13
+ddmxg187 maxmag NaN14 -NaN5 -> NaN14
+
+ddmxg188 maxmag -Inf NaN4 -> -Infinity
+ddmxg189 maxmag -9 -NaN3 -> -9
+ddmxg190 maxmag Inf NaN2 -> Infinity
+
+ddmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+ddmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+ddmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+ddmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+ddmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+ddmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+ddmxg221 maxmag 12345678000 1 -> 12345678000
+ddmxg222 maxmag 1 12345678000 -> 12345678000
+ddmxg223 maxmag 1234567800 1 -> 1234567800
+ddmxg224 maxmag 1 1234567800 -> 1234567800
+ddmxg225 maxmag 1234567890 1 -> 1234567890
+ddmxg226 maxmag 1 1234567890 -> 1234567890
+ddmxg227 maxmag 1234567891 1 -> 1234567891
+ddmxg228 maxmag 1 1234567891 -> 1234567891
+ddmxg229 maxmag 12345678901 1 -> 12345678901
+ddmxg230 maxmag 1 12345678901 -> 12345678901
+ddmxg231 maxmag 1234567896 1 -> 1234567896
+ddmxg232 maxmag 1 1234567896 -> 1234567896
+ddmxg233 maxmag -1234567891 1 -> -1234567891
+ddmxg234 maxmag 1 -1234567891 -> -1234567891
+ddmxg235 maxmag -12345678901 1 -> -12345678901
+ddmxg236 maxmag 1 -12345678901 -> -12345678901
+ddmxg237 maxmag -1234567896 1 -> -1234567896
+ddmxg238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+ddmxg280 maxmag '3' '2' -> '3'
+ddmxg281 maxmag '-10' '3' -> '-10'
+ddmxg282 maxmag '1.0' '1' -> '1'
+ddmxg283 maxmag '1' '1.0' -> '1'
+ddmxg284 maxmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmxg401 maxmag Inf 1.1 -> Infinity
+ddmxg402 maxmag 1.1 1 -> 1.1
+ddmxg403 maxmag 1 1.0 -> 1
+ddmxg404 maxmag 1.0 0.1 -> 1.0
+ddmxg405 maxmag 0.1 0.10 -> 0.1
+ddmxg406 maxmag 0.10 0.100 -> 0.10
+ddmxg407 maxmag 0.10 0 -> 0.10
+ddmxg408 maxmag 0 0.0 -> 0
+ddmxg409 maxmag 0.0 -0 -> 0.0
+ddmxg410 maxmag 0.0 -0.0 -> 0.0
+ddmxg411 maxmag 0.00 -0.0 -> 0.00
+ddmxg412 maxmag 0.0 -0.00 -> 0.0
+ddmxg413 maxmag 0 -0.0 -> 0
+ddmxg414 maxmag 0 -0 -> 0
+ddmxg415 maxmag -0.0 -0 -> -0.0
+ddmxg416 maxmag -0 -0.100 -> -0.100
+ddmxg417 maxmag -0.100 -0.10 -> -0.100
+ddmxg418 maxmag -0.10 -0.1 -> -0.10
+ddmxg419 maxmag -0.1 -1.0 -> -1.0
+ddmxg420 maxmag -1.0 -1 -> -1.0
+ddmxg421 maxmag -1 -1.1 -> -1.1
+ddmxg423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+ddmxg431 maxmag 1.1 Inf -> Infinity
+ddmxg432 maxmag 1 1.1 -> 1.1
+ddmxg433 maxmag 1.0 1 -> 1
+ddmxg434 maxmag 0.1 1.0 -> 1.0
+ddmxg435 maxmag 0.10 0.1 -> 0.1
+ddmxg436 maxmag 0.100 0.10 -> 0.10
+ddmxg437 maxmag 0 0.10 -> 0.10
+ddmxg438 maxmag 0.0 0 -> 0
+ddmxg439 maxmag -0 0.0 -> 0.0
+ddmxg440 maxmag -0.0 0.0 -> 0.0
+ddmxg441 maxmag -0.0 0.00 -> 0.00
+ddmxg442 maxmag -0.00 0.0 -> 0.0
+ddmxg443 maxmag -0.0 0 -> 0
+ddmxg444 maxmag -0 0 -> 0
+ddmxg445 maxmag -0 -0.0 -> -0.0
+ddmxg446 maxmag -0.100 -0 -> -0.100
+ddmxg447 maxmag -0.10 -0.100 -> -0.100
+ddmxg448 maxmag -0.1 -0.10 -> -0.10
+ddmxg449 maxmag -1.0 -0.1 -> -1.0
+ddmxg450 maxmag -1 -1.0 -> -1.0
+ddmxg451 maxmag -1.1 -1 -> -1.1
+ddmxg453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+ddmxg460 maxmag 1000 1E+3 -> 1E+3
+ddmxg461 maxmag 1E+3 1000 -> 1E+3
+ddmxg462 maxmag 1000 -1E+3 -> 1000
+ddmxg463 maxmag 1E+3 -1000 -> 1E+3
+ddmxg464 maxmag -1000 1E+3 -> 1E+3
+ddmxg465 maxmag -1E+3 1000 -> 1000
+ddmxg466 maxmag -1000 -1E+3 -> -1000
+ddmxg467 maxmag -1E+3 -1000 -> -1000
+
+-- subnormals
+ddmxg510 maxmag 1.00E-383 0 -> 1.00E-383
+ddmxg511 maxmag 0.1E-383 0 -> 1E-384 Subnormal
+ddmxg512 maxmag 0.10E-383 0 -> 1.0E-384 Subnormal
+ddmxg513 maxmag 0.100E-383 0 -> 1.00E-384 Subnormal
+ddmxg514 maxmag 0.01E-383 0 -> 1E-385 Subnormal
+ddmxg515 maxmag 0.999E-383 0 -> 9.99E-384 Subnormal
+ddmxg516 maxmag 0.099E-383 0 -> 9.9E-385 Subnormal
+ddmxg517 maxmag 0.009E-383 0 -> 9E-386 Subnormal
+ddmxg518 maxmag 0.001E-383 0 -> 1E-386 Subnormal
+ddmxg519 maxmag 0.0009E-383 0 -> 9E-387 Subnormal
+ddmxg520 maxmag 0.0001E-383 0 -> 1E-387 Subnormal
+
+ddmxg530 maxmag -1.00E-383 0 -> -1.00E-383
+ddmxg531 maxmag -0.1E-383 0 -> -1E-384 Subnormal
+ddmxg532 maxmag -0.10E-383 0 -> -1.0E-384 Subnormal
+ddmxg533 maxmag -0.100E-383 0 -> -1.00E-384 Subnormal
+ddmxg534 maxmag -0.01E-383 0 -> -1E-385 Subnormal
+ddmxg535 maxmag -0.999E-383 0 -> -9.99E-384 Subnormal
+ddmxg536 maxmag -0.099E-383 0 -> -9.9E-385 Subnormal
+ddmxg537 maxmag -0.009E-383 0 -> -9E-386 Subnormal
+ddmxg538 maxmag -0.001E-383 0 -> -1E-386 Subnormal
+ddmxg539 maxmag -0.0009E-383 0 -> -9E-387 Subnormal
+ddmxg540 maxmag -0.0001E-383 0 -> -1E-387 Subnormal
+
+-- Null tests
+ddmxg900 maxmag 10 # -> NaN Invalid_operation
+ddmxg901 maxmag # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddMin.decTest b/Lib/test/decimaltestdata/ddMin.decTest
index eb942ff1598..9ce42824638 100644
--- a/Lib/test/decimaltestdata/ddMin.decTest
+++ b/Lib/test/decimaltestdata/ddMin.decTest
@@ -1,309 +1,309 @@
-------------------------------------------------------------------------
--- ddMin.decTest -- decDouble minnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmin001 min -2 -2 -> -2
-ddmin002 min -2 -1 -> -2
-ddmin003 min -2 0 -> -2
-ddmin004 min -2 1 -> -2
-ddmin005 min -2 2 -> -2
-ddmin006 min -1 -2 -> -2
-ddmin007 min -1 -1 -> -1
-ddmin008 min -1 0 -> -1
-ddmin009 min -1 1 -> -1
-ddmin010 min -1 2 -> -1
-ddmin011 min 0 -2 -> -2
-ddmin012 min 0 -1 -> -1
-ddmin013 min 0 0 -> 0
-ddmin014 min 0 1 -> 0
-ddmin015 min 0 2 -> 0
-ddmin016 min 1 -2 -> -2
-ddmin017 min 1 -1 -> -1
-ddmin018 min 1 0 -> 0
-ddmin019 min 1 1 -> 1
-ddmin020 min 1 2 -> 1
-ddmin021 min 2 -2 -> -2
-ddmin022 min 2 -1 -> -1
-ddmin023 min 2 0 -> 0
-ddmin025 min 2 1 -> 1
-ddmin026 min 2 2 -> 2
-
--- extended zeros
-ddmin030 min 0 0 -> 0
-ddmin031 min 0 -0 -> -0
-ddmin032 min 0 -0.0 -> -0.0
-ddmin033 min 0 0.0 -> 0.0
-ddmin034 min -0 0 -> -0
-ddmin035 min -0 -0 -> -0
-ddmin036 min -0 -0.0 -> -0
-ddmin037 min -0 0.0 -> -0
-ddmin038 min 0.0 0 -> 0.0
-ddmin039 min 0.0 -0 -> -0
-ddmin040 min 0.0 -0.0 -> -0.0
-ddmin041 min 0.0 0.0 -> 0.0
-ddmin042 min -0.0 0 -> -0.0
-ddmin043 min -0.0 -0 -> -0
-ddmin044 min -0.0 -0.0 -> -0.0
-ddmin045 min -0.0 0.0 -> -0.0
-
-ddmin046 min 0E1 -0E1 -> -0E+1
-ddmin047 min -0E1 0E2 -> -0E+1
-ddmin048 min 0E2 0E1 -> 0E+1
-ddmin049 min 0E1 0E2 -> 0E+1
-ddmin050 min -0E3 -0E2 -> -0E+3
-ddmin051 min -0E2 -0E3 -> -0E+3
-
--- Specials
-ddmin090 min Inf -Inf -> -Infinity
-ddmin091 min Inf -1000 -> -1000
-ddmin092 min Inf -1 -> -1
-ddmin093 min Inf -0 -> -0
-ddmin094 min Inf 0 -> 0
-ddmin095 min Inf 1 -> 1
-ddmin096 min Inf 1000 -> 1000
-ddmin097 min Inf Inf -> Infinity
-ddmin098 min -1000 Inf -> -1000
-ddmin099 min -Inf Inf -> -Infinity
-ddmin100 min -1 Inf -> -1
-ddmin101 min -0 Inf -> -0
-ddmin102 min 0 Inf -> 0
-ddmin103 min 1 Inf -> 1
-ddmin104 min 1000 Inf -> 1000
-ddmin105 min Inf Inf -> Infinity
-
-ddmin120 min -Inf -Inf -> -Infinity
-ddmin121 min -Inf -1000 -> -Infinity
-ddmin122 min -Inf -1 -> -Infinity
-ddmin123 min -Inf -0 -> -Infinity
-ddmin124 min -Inf 0 -> -Infinity
-ddmin125 min -Inf 1 -> -Infinity
-ddmin126 min -Inf 1000 -> -Infinity
-ddmin127 min -Inf Inf -> -Infinity
-ddmin128 min -Inf -Inf -> -Infinity
-ddmin129 min -1000 -Inf -> -Infinity
-ddmin130 min -1 -Inf -> -Infinity
-ddmin131 min -0 -Inf -> -Infinity
-ddmin132 min 0 -Inf -> -Infinity
-ddmin133 min 1 -Inf -> -Infinity
-ddmin134 min 1000 -Inf -> -Infinity
-ddmin135 min Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmin141 min NaN -Inf -> -Infinity
-ddmin142 min NaN -1000 -> -1000
-ddmin143 min NaN -1 -> -1
-ddmin144 min NaN -0 -> -0
-ddmin145 min NaN 0 -> 0
-ddmin146 min NaN 1 -> 1
-ddmin147 min NaN 1000 -> 1000
-ddmin148 min NaN Inf -> Infinity
-ddmin149 min NaN NaN -> NaN
-ddmin150 min -Inf NaN -> -Infinity
-ddmin151 min -1000 NaN -> -1000
-ddmin152 min -1 -NaN -> -1
-ddmin153 min -0 NaN -> -0
-ddmin154 min 0 -NaN -> 0
-ddmin155 min 1 NaN -> 1
-ddmin156 min 1000 NaN -> 1000
-ddmin157 min Inf NaN -> Infinity
-
-ddmin161 min sNaN -Inf -> NaN Invalid_operation
-ddmin162 min sNaN -1000 -> NaN Invalid_operation
-ddmin163 min sNaN -1 -> NaN Invalid_operation
-ddmin164 min sNaN -0 -> NaN Invalid_operation
-ddmin165 min -sNaN 0 -> -NaN Invalid_operation
-ddmin166 min -sNaN 1 -> -NaN Invalid_operation
-ddmin167 min sNaN 1000 -> NaN Invalid_operation
-ddmin168 min sNaN NaN -> NaN Invalid_operation
-ddmin169 min sNaN sNaN -> NaN Invalid_operation
-ddmin170 min NaN sNaN -> NaN Invalid_operation
-ddmin171 min -Inf sNaN -> NaN Invalid_operation
-ddmin172 min -1000 sNaN -> NaN Invalid_operation
-ddmin173 min -1 sNaN -> NaN Invalid_operation
-ddmin174 min -0 sNaN -> NaN Invalid_operation
-ddmin175 min 0 sNaN -> NaN Invalid_operation
-ddmin176 min 1 sNaN -> NaN Invalid_operation
-ddmin177 min 1000 sNaN -> NaN Invalid_operation
-ddmin178 min Inf sNaN -> NaN Invalid_operation
-ddmin179 min NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmin181 min NaN9 -Inf -> -Infinity
-ddmin182 min -NaN8 9990 -> 9990
-ddmin183 min NaN71 Inf -> Infinity
-
-ddmin184 min NaN1 NaN54 -> NaN1
-ddmin185 min NaN22 -NaN53 -> NaN22
-ddmin186 min -NaN3 NaN6 -> -NaN3
-ddmin187 min -NaN44 NaN7 -> -NaN44
-
-ddmin188 min -Inf NaN41 -> -Infinity
-ddmin189 min -9999 -NaN33 -> -9999
-ddmin190 min Inf NaN2 -> Infinity
-
-ddmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
-ddmin192 min sNaN98 -11 -> NaN98 Invalid_operation
-ddmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
-ddmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
-ddmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
-ddmin197 min 088 sNaN91 -> NaN91 Invalid_operation
-ddmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmin199 min NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-ddmin221 min -12345678000 1 -> -12345678000
-ddmin222 min 1 -12345678000 -> -12345678000
-ddmin223 min -1234567800 1 -> -1234567800
-ddmin224 min 1 -1234567800 -> -1234567800
-ddmin225 min -1234567890 1 -> -1234567890
-ddmin226 min 1 -1234567890 -> -1234567890
-ddmin227 min -1234567891 1 -> -1234567891
-ddmin228 min 1 -1234567891 -> -1234567891
-ddmin229 min -12345678901 1 -> -12345678901
-ddmin230 min 1 -12345678901 -> -12345678901
-ddmin231 min -1234567896 1 -> -1234567896
-ddmin232 min 1 -1234567896 -> -1234567896
-ddmin233 min 1234567891 1 -> 1
-ddmin234 min 1 1234567891 -> 1
-ddmin235 min 12345678901 1 -> 1
-ddmin236 min 1 12345678901 -> 1
-ddmin237 min 1234567896 1 -> 1
-ddmin238 min 1 1234567896 -> 1
-
--- from examples
-ddmin280 min '3' '2' -> '2'
-ddmin281 min '-10' '3' -> '-10'
-ddmin282 min '1.0' '1' -> '1.0'
-ddmin283 min '1' '1.0' -> '1.0'
-ddmin284 min '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmin401 min Inf 1.1 -> 1.1
-ddmin402 min 1.1 1 -> 1
-ddmin403 min 1 1.0 -> 1.0
-ddmin404 min 1.0 0.1 -> 0.1
-ddmin405 min 0.1 0.10 -> 0.10
-ddmin406 min 0.10 0.100 -> 0.100
-ddmin407 min 0.10 0 -> 0
-ddmin408 min 0 0.0 -> 0.0
-ddmin409 min 0.0 -0 -> -0
-ddmin410 min 0.0 -0.0 -> -0.0
-ddmin411 min 0.00 -0.0 -> -0.0
-ddmin412 min 0.0 -0.00 -> -0.00
-ddmin413 min 0 -0.0 -> -0.0
-ddmin414 min 0 -0 -> -0
-ddmin415 min -0.0 -0 -> -0
-ddmin416 min -0 -0.100 -> -0.100
-ddmin417 min -0.100 -0.10 -> -0.10
-ddmin418 min -0.10 -0.1 -> -0.1
-ddmin419 min -0.1 -1.0 -> -1.0
-ddmin420 min -1.0 -1 -> -1
-ddmin421 min -1 -1.1 -> -1.1
-ddmin423 min -1.1 -Inf -> -Infinity
--- same with operands reversed
-ddmin431 min 1.1 Inf -> 1.1
-ddmin432 min 1 1.1 -> 1
-ddmin433 min 1.0 1 -> 1.0
-ddmin434 min 0.1 1.0 -> 0.1
-ddmin435 min 0.10 0.1 -> 0.10
-ddmin436 min 0.100 0.10 -> 0.100
-ddmin437 min 0 0.10 -> 0
-ddmin438 min 0.0 0 -> 0.0
-ddmin439 min -0 0.0 -> -0
-ddmin440 min -0.0 0.0 -> -0.0
-ddmin441 min -0.0 0.00 -> -0.0
-ddmin442 min -0.00 0.0 -> -0.00
-ddmin443 min -0.0 0 -> -0.0
-ddmin444 min -0 0 -> -0
-ddmin445 min -0 -0.0 -> -0
-ddmin446 min -0.100 -0 -> -0.100
-ddmin447 min -0.10 -0.100 -> -0.10
-ddmin448 min -0.1 -0.10 -> -0.1
-ddmin449 min -1.0 -0.1 -> -1.0
-ddmin450 min -1 -1.0 -> -1
-ddmin451 min -1.1 -1 -> -1.1
-ddmin453 min -Inf -1.1 -> -Infinity
--- largies
-ddmin460 min 1000 1E+3 -> 1000
-ddmin461 min 1E+3 1000 -> 1000
-ddmin462 min 1000 -1E+3 -> -1E+3
-ddmin463 min 1E+3 -384 -> -384
-ddmin464 min -384 1E+3 -> -384
-ddmin465 min -1E+3 1000 -> -1E+3
-ddmin466 min -384 -1E+3 -> -1E+3
-ddmin467 min -1E+3 -384 -> -1E+3
-
--- misalignment traps for little-endian
-ddmin471 min 1.0 0.1 -> 0.1
-ddmin472 min 0.1 1.0 -> 0.1
-ddmin473 min 10.0 0.1 -> 0.1
-ddmin474 min 0.1 10.0 -> 0.1
-ddmin475 min 100 1.0 -> 1.0
-ddmin476 min 1.0 100 -> 1.0
-ddmin477 min 1000 10.0 -> 10.0
-ddmin478 min 10.0 1000 -> 10.0
-ddmin479 min 10000 100.0 -> 100.0
-ddmin480 min 100.0 10000 -> 100.0
-ddmin481 min 100000 1000.0 -> 1000.0
-ddmin482 min 1000.0 100000 -> 1000.0
-ddmin483 min 1000000 10000.0 -> 10000.0
-ddmin484 min 10000.0 1000000 -> 10000.0
-
--- subnormals
-ddmin510 min 1.00E-383 0 -> 0
-ddmin511 min 0.1E-383 0 -> 0
-ddmin512 min 0.10E-383 0 -> 0
-ddmin513 min 0.100E-383 0 -> 0
-ddmin514 min 0.01E-383 0 -> 0
-ddmin515 min 0.999E-383 0 -> 0
-ddmin516 min 0.099E-383 0 -> 0
-ddmin517 min 0.009E-383 0 -> 0
-ddmin518 min 0.001E-383 0 -> 0
-ddmin519 min 0.0009E-383 0 -> 0
-ddmin520 min 0.0001E-383 0 -> 0
-
-ddmin530 min -1.00E-383 0 -> -1.00E-383
-ddmin531 min -0.1E-383 0 -> -1E-384 Subnormal
-ddmin532 min -0.10E-383 0 -> -1.0E-384 Subnormal
-ddmin533 min -0.100E-383 0 -> -1.00E-384 Subnormal
-ddmin534 min -0.01E-383 0 -> -1E-385 Subnormal
-ddmin535 min -0.999E-383 0 -> -9.99E-384 Subnormal
-ddmin536 min -0.099E-383 0 -> -9.9E-385 Subnormal
-ddmin537 min -0.009E-383 0 -> -9E-386 Subnormal
-ddmin538 min -0.001E-383 0 -> -1E-386 Subnormal
-ddmin539 min -0.0009E-383 0 -> -9E-387 Subnormal
-ddmin540 min -0.0001E-383 0 -> -1E-387 Subnormal
-
-
--- Null tests
-ddmin900 min 10 # -> NaN Invalid_operation
-ddmin901 min # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddMin.decTest -- decDouble minnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmin001 min -2 -2 -> -2
+ddmin002 min -2 -1 -> -2
+ddmin003 min -2 0 -> -2
+ddmin004 min -2 1 -> -2
+ddmin005 min -2 2 -> -2
+ddmin006 min -1 -2 -> -2
+ddmin007 min -1 -1 -> -1
+ddmin008 min -1 0 -> -1
+ddmin009 min -1 1 -> -1
+ddmin010 min -1 2 -> -1
+ddmin011 min 0 -2 -> -2
+ddmin012 min 0 -1 -> -1
+ddmin013 min 0 0 -> 0
+ddmin014 min 0 1 -> 0
+ddmin015 min 0 2 -> 0
+ddmin016 min 1 -2 -> -2
+ddmin017 min 1 -1 -> -1
+ddmin018 min 1 0 -> 0
+ddmin019 min 1 1 -> 1
+ddmin020 min 1 2 -> 1
+ddmin021 min 2 -2 -> -2
+ddmin022 min 2 -1 -> -1
+ddmin023 min 2 0 -> 0
+ddmin025 min 2 1 -> 1
+ddmin026 min 2 2 -> 2
+
+-- extended zeros
+ddmin030 min 0 0 -> 0
+ddmin031 min 0 -0 -> -0
+ddmin032 min 0 -0.0 -> -0.0
+ddmin033 min 0 0.0 -> 0.0
+ddmin034 min -0 0 -> -0
+ddmin035 min -0 -0 -> -0
+ddmin036 min -0 -0.0 -> -0
+ddmin037 min -0 0.0 -> -0
+ddmin038 min 0.0 0 -> 0.0
+ddmin039 min 0.0 -0 -> -0
+ddmin040 min 0.0 -0.0 -> -0.0
+ddmin041 min 0.0 0.0 -> 0.0
+ddmin042 min -0.0 0 -> -0.0
+ddmin043 min -0.0 -0 -> -0
+ddmin044 min -0.0 -0.0 -> -0.0
+ddmin045 min -0.0 0.0 -> -0.0
+
+ddmin046 min 0E1 -0E1 -> -0E+1
+ddmin047 min -0E1 0E2 -> -0E+1
+ddmin048 min 0E2 0E1 -> 0E+1
+ddmin049 min 0E1 0E2 -> 0E+1
+ddmin050 min -0E3 -0E2 -> -0E+3
+ddmin051 min -0E2 -0E3 -> -0E+3
+
+-- Specials
+ddmin090 min Inf -Inf -> -Infinity
+ddmin091 min Inf -1000 -> -1000
+ddmin092 min Inf -1 -> -1
+ddmin093 min Inf -0 -> -0
+ddmin094 min Inf 0 -> 0
+ddmin095 min Inf 1 -> 1
+ddmin096 min Inf 1000 -> 1000
+ddmin097 min Inf Inf -> Infinity
+ddmin098 min -1000 Inf -> -1000
+ddmin099 min -Inf Inf -> -Infinity
+ddmin100 min -1 Inf -> -1
+ddmin101 min -0 Inf -> -0
+ddmin102 min 0 Inf -> 0
+ddmin103 min 1 Inf -> 1
+ddmin104 min 1000 Inf -> 1000
+ddmin105 min Inf Inf -> Infinity
+
+ddmin120 min -Inf -Inf -> -Infinity
+ddmin121 min -Inf -1000 -> -Infinity
+ddmin122 min -Inf -1 -> -Infinity
+ddmin123 min -Inf -0 -> -Infinity
+ddmin124 min -Inf 0 -> -Infinity
+ddmin125 min -Inf 1 -> -Infinity
+ddmin126 min -Inf 1000 -> -Infinity
+ddmin127 min -Inf Inf -> -Infinity
+ddmin128 min -Inf -Inf -> -Infinity
+ddmin129 min -1000 -Inf -> -Infinity
+ddmin130 min -1 -Inf -> -Infinity
+ddmin131 min -0 -Inf -> -Infinity
+ddmin132 min 0 -Inf -> -Infinity
+ddmin133 min 1 -Inf -> -Infinity
+ddmin134 min 1000 -Inf -> -Infinity
+ddmin135 min Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmin141 min NaN -Inf -> -Infinity
+ddmin142 min NaN -1000 -> -1000
+ddmin143 min NaN -1 -> -1
+ddmin144 min NaN -0 -> -0
+ddmin145 min NaN 0 -> 0
+ddmin146 min NaN 1 -> 1
+ddmin147 min NaN 1000 -> 1000
+ddmin148 min NaN Inf -> Infinity
+ddmin149 min NaN NaN -> NaN
+ddmin150 min -Inf NaN -> -Infinity
+ddmin151 min -1000 NaN -> -1000
+ddmin152 min -1 -NaN -> -1
+ddmin153 min -0 NaN -> -0
+ddmin154 min 0 -NaN -> 0
+ddmin155 min 1 NaN -> 1
+ddmin156 min 1000 NaN -> 1000
+ddmin157 min Inf NaN -> Infinity
+
+ddmin161 min sNaN -Inf -> NaN Invalid_operation
+ddmin162 min sNaN -1000 -> NaN Invalid_operation
+ddmin163 min sNaN -1 -> NaN Invalid_operation
+ddmin164 min sNaN -0 -> NaN Invalid_operation
+ddmin165 min -sNaN 0 -> -NaN Invalid_operation
+ddmin166 min -sNaN 1 -> -NaN Invalid_operation
+ddmin167 min sNaN 1000 -> NaN Invalid_operation
+ddmin168 min sNaN NaN -> NaN Invalid_operation
+ddmin169 min sNaN sNaN -> NaN Invalid_operation
+ddmin170 min NaN sNaN -> NaN Invalid_operation
+ddmin171 min -Inf sNaN -> NaN Invalid_operation
+ddmin172 min -1000 sNaN -> NaN Invalid_operation
+ddmin173 min -1 sNaN -> NaN Invalid_operation
+ddmin174 min -0 sNaN -> NaN Invalid_operation
+ddmin175 min 0 sNaN -> NaN Invalid_operation
+ddmin176 min 1 sNaN -> NaN Invalid_operation
+ddmin177 min 1000 sNaN -> NaN Invalid_operation
+ddmin178 min Inf sNaN -> NaN Invalid_operation
+ddmin179 min NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmin181 min NaN9 -Inf -> -Infinity
+ddmin182 min -NaN8 9990 -> 9990
+ddmin183 min NaN71 Inf -> Infinity
+
+ddmin184 min NaN1 NaN54 -> NaN1
+ddmin185 min NaN22 -NaN53 -> NaN22
+ddmin186 min -NaN3 NaN6 -> -NaN3
+ddmin187 min -NaN44 NaN7 -> -NaN44
+
+ddmin188 min -Inf NaN41 -> -Infinity
+ddmin189 min -9999 -NaN33 -> -9999
+ddmin190 min Inf NaN2 -> Infinity
+
+ddmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
+ddmin192 min sNaN98 -11 -> NaN98 Invalid_operation
+ddmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
+ddmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
+ddmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
+ddmin197 min 088 sNaN91 -> NaN91 Invalid_operation
+ddmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmin199 min NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+ddmin221 min -12345678000 1 -> -12345678000
+ddmin222 min 1 -12345678000 -> -12345678000
+ddmin223 min -1234567800 1 -> -1234567800
+ddmin224 min 1 -1234567800 -> -1234567800
+ddmin225 min -1234567890 1 -> -1234567890
+ddmin226 min 1 -1234567890 -> -1234567890
+ddmin227 min -1234567891 1 -> -1234567891
+ddmin228 min 1 -1234567891 -> -1234567891
+ddmin229 min -12345678901 1 -> -12345678901
+ddmin230 min 1 -12345678901 -> -12345678901
+ddmin231 min -1234567896 1 -> -1234567896
+ddmin232 min 1 -1234567896 -> -1234567896
+ddmin233 min 1234567891 1 -> 1
+ddmin234 min 1 1234567891 -> 1
+ddmin235 min 12345678901 1 -> 1
+ddmin236 min 1 12345678901 -> 1
+ddmin237 min 1234567896 1 -> 1
+ddmin238 min 1 1234567896 -> 1
+
+-- from examples
+ddmin280 min '3' '2' -> '2'
+ddmin281 min '-10' '3' -> '-10'
+ddmin282 min '1.0' '1' -> '1.0'
+ddmin283 min '1' '1.0' -> '1.0'
+ddmin284 min '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmin401 min Inf 1.1 -> 1.1
+ddmin402 min 1.1 1 -> 1
+ddmin403 min 1 1.0 -> 1.0
+ddmin404 min 1.0 0.1 -> 0.1
+ddmin405 min 0.1 0.10 -> 0.10
+ddmin406 min 0.10 0.100 -> 0.100
+ddmin407 min 0.10 0 -> 0
+ddmin408 min 0 0.0 -> 0.0
+ddmin409 min 0.0 -0 -> -0
+ddmin410 min 0.0 -0.0 -> -0.0
+ddmin411 min 0.00 -0.0 -> -0.0
+ddmin412 min 0.0 -0.00 -> -0.00
+ddmin413 min 0 -0.0 -> -0.0
+ddmin414 min 0 -0 -> -0
+ddmin415 min -0.0 -0 -> -0
+ddmin416 min -0 -0.100 -> -0.100
+ddmin417 min -0.100 -0.10 -> -0.10
+ddmin418 min -0.10 -0.1 -> -0.1
+ddmin419 min -0.1 -1.0 -> -1.0
+ddmin420 min -1.0 -1 -> -1
+ddmin421 min -1 -1.1 -> -1.1
+ddmin423 min -1.1 -Inf -> -Infinity
+-- same with operands reversed
+ddmin431 min 1.1 Inf -> 1.1
+ddmin432 min 1 1.1 -> 1
+ddmin433 min 1.0 1 -> 1.0
+ddmin434 min 0.1 1.0 -> 0.1
+ddmin435 min 0.10 0.1 -> 0.10
+ddmin436 min 0.100 0.10 -> 0.100
+ddmin437 min 0 0.10 -> 0
+ddmin438 min 0.0 0 -> 0.0
+ddmin439 min -0 0.0 -> -0
+ddmin440 min -0.0 0.0 -> -0.0
+ddmin441 min -0.0 0.00 -> -0.0
+ddmin442 min -0.00 0.0 -> -0.00
+ddmin443 min -0.0 0 -> -0.0
+ddmin444 min -0 0 -> -0
+ddmin445 min -0 -0.0 -> -0
+ddmin446 min -0.100 -0 -> -0.100
+ddmin447 min -0.10 -0.100 -> -0.10
+ddmin448 min -0.1 -0.10 -> -0.1
+ddmin449 min -1.0 -0.1 -> -1.0
+ddmin450 min -1 -1.0 -> -1
+ddmin451 min -1.1 -1 -> -1.1
+ddmin453 min -Inf -1.1 -> -Infinity
+-- largies
+ddmin460 min 1000 1E+3 -> 1000
+ddmin461 min 1E+3 1000 -> 1000
+ddmin462 min 1000 -1E+3 -> -1E+3
+ddmin463 min 1E+3 -384 -> -384
+ddmin464 min -384 1E+3 -> -384
+ddmin465 min -1E+3 1000 -> -1E+3
+ddmin466 min -384 -1E+3 -> -1E+3
+ddmin467 min -1E+3 -384 -> -1E+3
+
+-- misalignment traps for little-endian
+ddmin471 min 1.0 0.1 -> 0.1
+ddmin472 min 0.1 1.0 -> 0.1
+ddmin473 min 10.0 0.1 -> 0.1
+ddmin474 min 0.1 10.0 -> 0.1
+ddmin475 min 100 1.0 -> 1.0
+ddmin476 min 1.0 100 -> 1.0
+ddmin477 min 1000 10.0 -> 10.0
+ddmin478 min 10.0 1000 -> 10.0
+ddmin479 min 10000 100.0 -> 100.0
+ddmin480 min 100.0 10000 -> 100.0
+ddmin481 min 100000 1000.0 -> 1000.0
+ddmin482 min 1000.0 100000 -> 1000.0
+ddmin483 min 1000000 10000.0 -> 10000.0
+ddmin484 min 10000.0 1000000 -> 10000.0
+
+-- subnormals
+ddmin510 min 1.00E-383 0 -> 0
+ddmin511 min 0.1E-383 0 -> 0
+ddmin512 min 0.10E-383 0 -> 0
+ddmin513 min 0.100E-383 0 -> 0
+ddmin514 min 0.01E-383 0 -> 0
+ddmin515 min 0.999E-383 0 -> 0
+ddmin516 min 0.099E-383 0 -> 0
+ddmin517 min 0.009E-383 0 -> 0
+ddmin518 min 0.001E-383 0 -> 0
+ddmin519 min 0.0009E-383 0 -> 0
+ddmin520 min 0.0001E-383 0 -> 0
+
+ddmin530 min -1.00E-383 0 -> -1.00E-383
+ddmin531 min -0.1E-383 0 -> -1E-384 Subnormal
+ddmin532 min -0.10E-383 0 -> -1.0E-384 Subnormal
+ddmin533 min -0.100E-383 0 -> -1.00E-384 Subnormal
+ddmin534 min -0.01E-383 0 -> -1E-385 Subnormal
+ddmin535 min -0.999E-383 0 -> -9.99E-384 Subnormal
+ddmin536 min -0.099E-383 0 -> -9.9E-385 Subnormal
+ddmin537 min -0.009E-383 0 -> -9E-386 Subnormal
+ddmin538 min -0.001E-383 0 -> -1E-386 Subnormal
+ddmin539 min -0.0009E-383 0 -> -9E-387 Subnormal
+ddmin540 min -0.0001E-383 0 -> -1E-387 Subnormal
+
+
+-- Null tests
+ddmin900 min 10 # -> NaN Invalid_operation
+ddmin901 min # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddMinMag.decTest b/Lib/test/decimaltestdata/ddMinMag.decTest
index 1012f1ec81e..5537cc8a7e4 100644
--- a/Lib/test/decimaltestdata/ddMinMag.decTest
+++ b/Lib/test/decimaltestdata/ddMinMag.decTest
@@ -1,293 +1,293 @@
-------------------------------------------------------------------------
--- ddMinMag.decTest -- decDouble minnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmng001 minmag -2 -2 -> -2
-ddmng002 minmag -2 -1 -> -1
-ddmng003 minmag -2 0 -> 0
-ddmng004 minmag -2 1 -> 1
-ddmng005 minmag -2 2 -> -2
-ddmng006 minmag -1 -2 -> -1
-ddmng007 minmag -1 -1 -> -1
-ddmng008 minmag -1 0 -> 0
-ddmng009 minmag -1 1 -> -1
-ddmng010 minmag -1 2 -> -1
-ddmng011 minmag 0 -2 -> 0
-ddmng012 minmag 0 -1 -> 0
-ddmng013 minmag 0 0 -> 0
-ddmng014 minmag 0 1 -> 0
-ddmng015 minmag 0 2 -> 0
-ddmng016 minmag 1 -2 -> 1
-ddmng017 minmag 1 -1 -> -1
-ddmng018 minmag 1 0 -> 0
-ddmng019 minmag 1 1 -> 1
-ddmng020 minmag 1 2 -> 1
-ddmng021 minmag 2 -2 -> -2
-ddmng022 minmag 2 -1 -> -1
-ddmng023 minmag 2 0 -> 0
-ddmng025 minmag 2 1 -> 1
-ddmng026 minmag 2 2 -> 2
-
--- extended zeros
-ddmng030 minmag 0 0 -> 0
-ddmng031 minmag 0 -0 -> -0
-ddmng032 minmag 0 -0.0 -> -0.0
-ddmng033 minmag 0 0.0 -> 0.0
-ddmng034 minmag -0 0 -> -0
-ddmng035 minmag -0 -0 -> -0
-ddmng036 minmag -0 -0.0 -> -0
-ddmng037 minmag -0 0.0 -> -0
-ddmng038 minmag 0.0 0 -> 0.0
-ddmng039 minmag 0.0 -0 -> -0
-ddmng040 minmag 0.0 -0.0 -> -0.0
-ddmng041 minmag 0.0 0.0 -> 0.0
-ddmng042 minmag -0.0 0 -> -0.0
-ddmng043 minmag -0.0 -0 -> -0
-ddmng044 minmag -0.0 -0.0 -> -0.0
-ddmng045 minmag -0.0 0.0 -> -0.0
-
-ddmng046 minmag 0E1 -0E1 -> -0E+1
-ddmng047 minmag -0E1 0E2 -> -0E+1
-ddmng048 minmag 0E2 0E1 -> 0E+1
-ddmng049 minmag 0E1 0E2 -> 0E+1
-ddmng050 minmag -0E3 -0E2 -> -0E+3
-ddmng051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-ddmng090 minmag Inf -Inf -> -Infinity
-ddmng091 minmag Inf -1000 -> -1000
-ddmng092 minmag Inf -1 -> -1
-ddmng093 minmag Inf -0 -> -0
-ddmng094 minmag Inf 0 -> 0
-ddmng095 minmag Inf 1 -> 1
-ddmng096 minmag Inf 1000 -> 1000
-ddmng097 minmag Inf Inf -> Infinity
-ddmng098 minmag -1000 Inf -> -1000
-ddmng099 minmag -Inf Inf -> -Infinity
-ddmng100 minmag -1 Inf -> -1
-ddmng101 minmag -0 Inf -> -0
-ddmng102 minmag 0 Inf -> 0
-ddmng103 minmag 1 Inf -> 1
-ddmng104 minmag 1000 Inf -> 1000
-ddmng105 minmag Inf Inf -> Infinity
-
-ddmng120 minmag -Inf -Inf -> -Infinity
-ddmng121 minmag -Inf -1000 -> -1000
-ddmng122 minmag -Inf -1 -> -1
-ddmng123 minmag -Inf -0 -> -0
-ddmng124 minmag -Inf 0 -> 0
-ddmng125 minmag -Inf 1 -> 1
-ddmng126 minmag -Inf 1000 -> 1000
-ddmng127 minmag -Inf Inf -> -Infinity
-ddmng128 minmag -Inf -Inf -> -Infinity
-ddmng129 minmag -1000 -Inf -> -1000
-ddmng130 minmag -1 -Inf -> -1
-ddmng131 minmag -0 -Inf -> -0
-ddmng132 minmag 0 -Inf -> 0
-ddmng133 minmag 1 -Inf -> 1
-ddmng134 minmag 1000 -Inf -> 1000
-ddmng135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-ddmng141 minmag NaN -Inf -> -Infinity
-ddmng142 minmag NaN -1000 -> -1000
-ddmng143 minmag NaN -1 -> -1
-ddmng144 minmag NaN -0 -> -0
-ddmng145 minmag NaN 0 -> 0
-ddmng146 minmag NaN 1 -> 1
-ddmng147 minmag NaN 1000 -> 1000
-ddmng148 minmag NaN Inf -> Infinity
-ddmng149 minmag NaN NaN -> NaN
-ddmng150 minmag -Inf NaN -> -Infinity
-ddmng151 minmag -1000 NaN -> -1000
-ddmng152 minmag -1 -NaN -> -1
-ddmng153 minmag -0 NaN -> -0
-ddmng154 minmag 0 -NaN -> 0
-ddmng155 minmag 1 NaN -> 1
-ddmng156 minmag 1000 NaN -> 1000
-ddmng157 minmag Inf NaN -> Infinity
-
-ddmng161 minmag sNaN -Inf -> NaN Invalid_operation
-ddmng162 minmag sNaN -1000 -> NaN Invalid_operation
-ddmng163 minmag sNaN -1 -> NaN Invalid_operation
-ddmng164 minmag sNaN -0 -> NaN Invalid_operation
-ddmng165 minmag -sNaN 0 -> -NaN Invalid_operation
-ddmng166 minmag -sNaN 1 -> -NaN Invalid_operation
-ddmng167 minmag sNaN 1000 -> NaN Invalid_operation
-ddmng168 minmag sNaN NaN -> NaN Invalid_operation
-ddmng169 minmag sNaN sNaN -> NaN Invalid_operation
-ddmng170 minmag NaN sNaN -> NaN Invalid_operation
-ddmng171 minmag -Inf sNaN -> NaN Invalid_operation
-ddmng172 minmag -1000 sNaN -> NaN Invalid_operation
-ddmng173 minmag -1 sNaN -> NaN Invalid_operation
-ddmng174 minmag -0 sNaN -> NaN Invalid_operation
-ddmng175 minmag 0 sNaN -> NaN Invalid_operation
-ddmng176 minmag 1 sNaN -> NaN Invalid_operation
-ddmng177 minmag 1000 sNaN -> NaN Invalid_operation
-ddmng178 minmag Inf sNaN -> NaN Invalid_operation
-ddmng179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmng181 minmag NaN9 -Inf -> -Infinity
-ddmng182 minmag -NaN8 9990 -> 9990
-ddmng183 minmag NaN71 Inf -> Infinity
-
-ddmng184 minmag NaN1 NaN54 -> NaN1
-ddmng185 minmag NaN22 -NaN53 -> NaN22
-ddmng186 minmag -NaN3 NaN6 -> -NaN3
-ddmng187 minmag -NaN44 NaN7 -> -NaN44
-
-ddmng188 minmag -Inf NaN41 -> -Infinity
-ddmng189 minmag -9999 -NaN33 -> -9999
-ddmng190 minmag Inf NaN2 -> Infinity
-
-ddmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-ddmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-ddmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-ddmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-ddmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-ddmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-ddmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-ddmng221 minmag -12345678000 1 -> 1
-ddmng222 minmag 1 -12345678000 -> 1
-ddmng223 minmag -1234567800 1 -> 1
-ddmng224 minmag 1 -1234567800 -> 1
-ddmng225 minmag -1234567890 1 -> 1
-ddmng226 minmag 1 -1234567890 -> 1
-ddmng227 minmag -1234567891 1 -> 1
-ddmng228 minmag 1 -1234567891 -> 1
-ddmng229 minmag -12345678901 1 -> 1
-ddmng230 minmag 1 -12345678901 -> 1
-ddmng231 minmag -1234567896 1 -> 1
-ddmng232 minmag 1 -1234567896 -> 1
-ddmng233 minmag 1234567891 1 -> 1
-ddmng234 minmag 1 1234567891 -> 1
-ddmng235 minmag 12345678901 1 -> 1
-ddmng236 minmag 1 12345678901 -> 1
-ddmng237 minmag 1234567896 1 -> 1
-ddmng238 minmag 1 1234567896 -> 1
-
--- from examples
-ddmng280 minmag '3' '2' -> '2'
-ddmng281 minmag '-10' '3' -> '3'
-ddmng282 minmag '1.0' '1' -> '1.0'
-ddmng283 minmag '1' '1.0' -> '1.0'
-ddmng284 minmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-ddmng401 minmag Inf 1.1 -> 1.1
-ddmng402 minmag 1.1 1 -> 1
-ddmng403 minmag 1 1.0 -> 1.0
-ddmng404 minmag 1.0 0.1 -> 0.1
-ddmng405 minmag 0.1 0.10 -> 0.10
-ddmng406 minmag 0.10 0.100 -> 0.100
-ddmng407 minmag 0.10 0 -> 0
-ddmng408 minmag 0 0.0 -> 0.0
-ddmng409 minmag 0.0 -0 -> -0
-ddmng410 minmag 0.0 -0.0 -> -0.0
-ddmng411 minmag 0.00 -0.0 -> -0.0
-ddmng412 minmag 0.0 -0.00 -> -0.00
-ddmng413 minmag 0 -0.0 -> -0.0
-ddmng414 minmag 0 -0 -> -0
-ddmng415 minmag -0.0 -0 -> -0
-ddmng416 minmag -0 -0.100 -> -0
-ddmng417 minmag -0.100 -0.10 -> -0.10
-ddmng418 minmag -0.10 -0.1 -> -0.1
-ddmng419 minmag -0.1 -1.0 -> -0.1
-ddmng420 minmag -1.0 -1 -> -1
-ddmng421 minmag -1 -1.1 -> -1
-ddmng423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-ddmng431 minmag 1.1 Inf -> 1.1
-ddmng432 minmag 1 1.1 -> 1
-ddmng433 minmag 1.0 1 -> 1.0
-ddmng434 minmag 0.1 1.0 -> 0.1
-ddmng435 minmag 0.10 0.1 -> 0.10
-ddmng436 minmag 0.100 0.10 -> 0.100
-ddmng437 minmag 0 0.10 -> 0
-ddmng438 minmag 0.0 0 -> 0.0
-ddmng439 minmag -0 0.0 -> -0
-ddmng440 minmag -0.0 0.0 -> -0.0
-ddmng441 minmag -0.0 0.00 -> -0.0
-ddmng442 minmag -0.00 0.0 -> -0.00
-ddmng443 minmag -0.0 0 -> -0.0
-ddmng444 minmag -0 0 -> -0
-ddmng445 minmag -0 -0.0 -> -0
-ddmng446 minmag -0.100 -0 -> -0
-ddmng447 minmag -0.10 -0.100 -> -0.10
-ddmng448 minmag -0.1 -0.10 -> -0.1
-ddmng449 minmag -1.0 -0.1 -> -0.1
-ddmng450 minmag -1 -1.0 -> -1
-ddmng451 minmag -1.1 -1 -> -1
-ddmng453 minmag -Inf -1.1 -> -1.1
--- largies
-ddmng460 minmag 1000 1E+3 -> 1000
-ddmng461 minmag 1E+3 1000 -> 1000
-ddmng462 minmag 1000 -1E+3 -> -1E+3
-ddmng463 minmag 1E+3 -384 -> -384
-ddmng464 minmag -384 1E+3 -> -384
-ddmng465 minmag -1E+3 1000 -> -1E+3
-ddmng466 minmag -384 -1E+3 -> -384
-ddmng467 minmag -1E+3 -384 -> -384
-
--- subnormals
-ddmng510 minmag 1.00E-383 0 -> 0
-ddmng511 minmag 0.1E-383 0 -> 0
-ddmng512 minmag 0.10E-383 0 -> 0
-ddmng513 minmag 0.100E-383 0 -> 0
-ddmng514 minmag 0.01E-383 0 -> 0
-ddmng515 minmag 0.999E-383 0 -> 0
-ddmng516 minmag 0.099E-383 0 -> 0
-ddmng517 minmag 0.009E-383 0 -> 0
-ddmng518 minmag 0.001E-383 0 -> 0
-ddmng519 minmag 0.0009E-383 0 -> 0
-ddmng520 minmag 0.0001E-383 0 -> 0
-
-ddmng530 minmag -1.00E-383 0 -> 0
-ddmng531 minmag -0.1E-383 0 -> 0
-ddmng532 minmag -0.10E-383 0 -> 0
-ddmng533 minmag -0.100E-383 0 -> 0
-ddmng534 minmag -0.01E-383 0 -> 0
-ddmng535 minmag -0.999E-383 0 -> 0
-ddmng536 minmag -0.099E-383 0 -> 0
-ddmng537 minmag -0.009E-383 0 -> 0
-ddmng538 minmag -0.001E-383 0 -> 0
-ddmng539 minmag -0.0009E-383 0 -> 0
-ddmng540 minmag -0.0001E-383 0 -> 0
-
-
--- Null tests
-ddmng900 minmag 10 # -> NaN Invalid_operation
-ddmng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddMinMag.decTest -- decDouble minnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmng001 minmag -2 -2 -> -2
+ddmng002 minmag -2 -1 -> -1
+ddmng003 minmag -2 0 -> 0
+ddmng004 minmag -2 1 -> 1
+ddmng005 minmag -2 2 -> -2
+ddmng006 minmag -1 -2 -> -1
+ddmng007 minmag -1 -1 -> -1
+ddmng008 minmag -1 0 -> 0
+ddmng009 minmag -1 1 -> -1
+ddmng010 minmag -1 2 -> -1
+ddmng011 minmag 0 -2 -> 0
+ddmng012 minmag 0 -1 -> 0
+ddmng013 minmag 0 0 -> 0
+ddmng014 minmag 0 1 -> 0
+ddmng015 minmag 0 2 -> 0
+ddmng016 minmag 1 -2 -> 1
+ddmng017 minmag 1 -1 -> -1
+ddmng018 minmag 1 0 -> 0
+ddmng019 minmag 1 1 -> 1
+ddmng020 minmag 1 2 -> 1
+ddmng021 minmag 2 -2 -> -2
+ddmng022 minmag 2 -1 -> -1
+ddmng023 minmag 2 0 -> 0
+ddmng025 minmag 2 1 -> 1
+ddmng026 minmag 2 2 -> 2
+
+-- extended zeros
+ddmng030 minmag 0 0 -> 0
+ddmng031 minmag 0 -0 -> -0
+ddmng032 minmag 0 -0.0 -> -0.0
+ddmng033 minmag 0 0.0 -> 0.0
+ddmng034 minmag -0 0 -> -0
+ddmng035 minmag -0 -0 -> -0
+ddmng036 minmag -0 -0.0 -> -0
+ddmng037 minmag -0 0.0 -> -0
+ddmng038 minmag 0.0 0 -> 0.0
+ddmng039 minmag 0.0 -0 -> -0
+ddmng040 minmag 0.0 -0.0 -> -0.0
+ddmng041 minmag 0.0 0.0 -> 0.0
+ddmng042 minmag -0.0 0 -> -0.0
+ddmng043 minmag -0.0 -0 -> -0
+ddmng044 minmag -0.0 -0.0 -> -0.0
+ddmng045 minmag -0.0 0.0 -> -0.0
+
+ddmng046 minmag 0E1 -0E1 -> -0E+1
+ddmng047 minmag -0E1 0E2 -> -0E+1
+ddmng048 minmag 0E2 0E1 -> 0E+1
+ddmng049 minmag 0E1 0E2 -> 0E+1
+ddmng050 minmag -0E3 -0E2 -> -0E+3
+ddmng051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+ddmng090 minmag Inf -Inf -> -Infinity
+ddmng091 minmag Inf -1000 -> -1000
+ddmng092 minmag Inf -1 -> -1
+ddmng093 minmag Inf -0 -> -0
+ddmng094 minmag Inf 0 -> 0
+ddmng095 minmag Inf 1 -> 1
+ddmng096 minmag Inf 1000 -> 1000
+ddmng097 minmag Inf Inf -> Infinity
+ddmng098 minmag -1000 Inf -> -1000
+ddmng099 minmag -Inf Inf -> -Infinity
+ddmng100 minmag -1 Inf -> -1
+ddmng101 minmag -0 Inf -> -0
+ddmng102 minmag 0 Inf -> 0
+ddmng103 minmag 1 Inf -> 1
+ddmng104 minmag 1000 Inf -> 1000
+ddmng105 minmag Inf Inf -> Infinity
+
+ddmng120 minmag -Inf -Inf -> -Infinity
+ddmng121 minmag -Inf -1000 -> -1000
+ddmng122 minmag -Inf -1 -> -1
+ddmng123 minmag -Inf -0 -> -0
+ddmng124 minmag -Inf 0 -> 0
+ddmng125 minmag -Inf 1 -> 1
+ddmng126 minmag -Inf 1000 -> 1000
+ddmng127 minmag -Inf Inf -> -Infinity
+ddmng128 minmag -Inf -Inf -> -Infinity
+ddmng129 minmag -1000 -Inf -> -1000
+ddmng130 minmag -1 -Inf -> -1
+ddmng131 minmag -0 -Inf -> -0
+ddmng132 minmag 0 -Inf -> 0
+ddmng133 minmag 1 -Inf -> 1
+ddmng134 minmag 1000 -Inf -> 1000
+ddmng135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+ddmng141 minmag NaN -Inf -> -Infinity
+ddmng142 minmag NaN -1000 -> -1000
+ddmng143 minmag NaN -1 -> -1
+ddmng144 minmag NaN -0 -> -0
+ddmng145 minmag NaN 0 -> 0
+ddmng146 minmag NaN 1 -> 1
+ddmng147 minmag NaN 1000 -> 1000
+ddmng148 minmag NaN Inf -> Infinity
+ddmng149 minmag NaN NaN -> NaN
+ddmng150 minmag -Inf NaN -> -Infinity
+ddmng151 minmag -1000 NaN -> -1000
+ddmng152 minmag -1 -NaN -> -1
+ddmng153 minmag -0 NaN -> -0
+ddmng154 minmag 0 -NaN -> 0
+ddmng155 minmag 1 NaN -> 1
+ddmng156 minmag 1000 NaN -> 1000
+ddmng157 minmag Inf NaN -> Infinity
+
+ddmng161 minmag sNaN -Inf -> NaN Invalid_operation
+ddmng162 minmag sNaN -1000 -> NaN Invalid_operation
+ddmng163 minmag sNaN -1 -> NaN Invalid_operation
+ddmng164 minmag sNaN -0 -> NaN Invalid_operation
+ddmng165 minmag -sNaN 0 -> -NaN Invalid_operation
+ddmng166 minmag -sNaN 1 -> -NaN Invalid_operation
+ddmng167 minmag sNaN 1000 -> NaN Invalid_operation
+ddmng168 minmag sNaN NaN -> NaN Invalid_operation
+ddmng169 minmag sNaN sNaN -> NaN Invalid_operation
+ddmng170 minmag NaN sNaN -> NaN Invalid_operation
+ddmng171 minmag -Inf sNaN -> NaN Invalid_operation
+ddmng172 minmag -1000 sNaN -> NaN Invalid_operation
+ddmng173 minmag -1 sNaN -> NaN Invalid_operation
+ddmng174 minmag -0 sNaN -> NaN Invalid_operation
+ddmng175 minmag 0 sNaN -> NaN Invalid_operation
+ddmng176 minmag 1 sNaN -> NaN Invalid_operation
+ddmng177 minmag 1000 sNaN -> NaN Invalid_operation
+ddmng178 minmag Inf sNaN -> NaN Invalid_operation
+ddmng179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmng181 minmag NaN9 -Inf -> -Infinity
+ddmng182 minmag -NaN8 9990 -> 9990
+ddmng183 minmag NaN71 Inf -> Infinity
+
+ddmng184 minmag NaN1 NaN54 -> NaN1
+ddmng185 minmag NaN22 -NaN53 -> NaN22
+ddmng186 minmag -NaN3 NaN6 -> -NaN3
+ddmng187 minmag -NaN44 NaN7 -> -NaN44
+
+ddmng188 minmag -Inf NaN41 -> -Infinity
+ddmng189 minmag -9999 -NaN33 -> -9999
+ddmng190 minmag Inf NaN2 -> Infinity
+
+ddmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+ddmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+ddmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+ddmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+ddmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+ddmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+ddmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+ddmng221 minmag -12345678000 1 -> 1
+ddmng222 minmag 1 -12345678000 -> 1
+ddmng223 minmag -1234567800 1 -> 1
+ddmng224 minmag 1 -1234567800 -> 1
+ddmng225 minmag -1234567890 1 -> 1
+ddmng226 minmag 1 -1234567890 -> 1
+ddmng227 minmag -1234567891 1 -> 1
+ddmng228 minmag 1 -1234567891 -> 1
+ddmng229 minmag -12345678901 1 -> 1
+ddmng230 minmag 1 -12345678901 -> 1
+ddmng231 minmag -1234567896 1 -> 1
+ddmng232 minmag 1 -1234567896 -> 1
+ddmng233 minmag 1234567891 1 -> 1
+ddmng234 minmag 1 1234567891 -> 1
+ddmng235 minmag 12345678901 1 -> 1
+ddmng236 minmag 1 12345678901 -> 1
+ddmng237 minmag 1234567896 1 -> 1
+ddmng238 minmag 1 1234567896 -> 1
+
+-- from examples
+ddmng280 minmag '3' '2' -> '2'
+ddmng281 minmag '-10' '3' -> '3'
+ddmng282 minmag '1.0' '1' -> '1.0'
+ddmng283 minmag '1' '1.0' -> '1.0'
+ddmng284 minmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+ddmng401 minmag Inf 1.1 -> 1.1
+ddmng402 minmag 1.1 1 -> 1
+ddmng403 minmag 1 1.0 -> 1.0
+ddmng404 minmag 1.0 0.1 -> 0.1
+ddmng405 minmag 0.1 0.10 -> 0.10
+ddmng406 minmag 0.10 0.100 -> 0.100
+ddmng407 minmag 0.10 0 -> 0
+ddmng408 minmag 0 0.0 -> 0.0
+ddmng409 minmag 0.0 -0 -> -0
+ddmng410 minmag 0.0 -0.0 -> -0.0
+ddmng411 minmag 0.00 -0.0 -> -0.0
+ddmng412 minmag 0.0 -0.00 -> -0.00
+ddmng413 minmag 0 -0.0 -> -0.0
+ddmng414 minmag 0 -0 -> -0
+ddmng415 minmag -0.0 -0 -> -0
+ddmng416 minmag -0 -0.100 -> -0
+ddmng417 minmag -0.100 -0.10 -> -0.10
+ddmng418 minmag -0.10 -0.1 -> -0.1
+ddmng419 minmag -0.1 -1.0 -> -0.1
+ddmng420 minmag -1.0 -1 -> -1
+ddmng421 minmag -1 -1.1 -> -1
+ddmng423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+ddmng431 minmag 1.1 Inf -> 1.1
+ddmng432 minmag 1 1.1 -> 1
+ddmng433 minmag 1.0 1 -> 1.0
+ddmng434 minmag 0.1 1.0 -> 0.1
+ddmng435 minmag 0.10 0.1 -> 0.10
+ddmng436 minmag 0.100 0.10 -> 0.100
+ddmng437 minmag 0 0.10 -> 0
+ddmng438 minmag 0.0 0 -> 0.0
+ddmng439 minmag -0 0.0 -> -0
+ddmng440 minmag -0.0 0.0 -> -0.0
+ddmng441 minmag -0.0 0.00 -> -0.0
+ddmng442 minmag -0.00 0.0 -> -0.00
+ddmng443 minmag -0.0 0 -> -0.0
+ddmng444 minmag -0 0 -> -0
+ddmng445 minmag -0 -0.0 -> -0
+ddmng446 minmag -0.100 -0 -> -0
+ddmng447 minmag -0.10 -0.100 -> -0.10
+ddmng448 minmag -0.1 -0.10 -> -0.1
+ddmng449 minmag -1.0 -0.1 -> -0.1
+ddmng450 minmag -1 -1.0 -> -1
+ddmng451 minmag -1.1 -1 -> -1
+ddmng453 minmag -Inf -1.1 -> -1.1
+-- largies
+ddmng460 minmag 1000 1E+3 -> 1000
+ddmng461 minmag 1E+3 1000 -> 1000
+ddmng462 minmag 1000 -1E+3 -> -1E+3
+ddmng463 minmag 1E+3 -384 -> -384
+ddmng464 minmag -384 1E+3 -> -384
+ddmng465 minmag -1E+3 1000 -> -1E+3
+ddmng466 minmag -384 -1E+3 -> -384
+ddmng467 minmag -1E+3 -384 -> -384
+
+-- subnormals
+ddmng510 minmag 1.00E-383 0 -> 0
+ddmng511 minmag 0.1E-383 0 -> 0
+ddmng512 minmag 0.10E-383 0 -> 0
+ddmng513 minmag 0.100E-383 0 -> 0
+ddmng514 minmag 0.01E-383 0 -> 0
+ddmng515 minmag 0.999E-383 0 -> 0
+ddmng516 minmag 0.099E-383 0 -> 0
+ddmng517 minmag 0.009E-383 0 -> 0
+ddmng518 minmag 0.001E-383 0 -> 0
+ddmng519 minmag 0.0009E-383 0 -> 0
+ddmng520 minmag 0.0001E-383 0 -> 0
+
+ddmng530 minmag -1.00E-383 0 -> 0
+ddmng531 minmag -0.1E-383 0 -> 0
+ddmng532 minmag -0.10E-383 0 -> 0
+ddmng533 minmag -0.100E-383 0 -> 0
+ddmng534 minmag -0.01E-383 0 -> 0
+ddmng535 minmag -0.999E-383 0 -> 0
+ddmng536 minmag -0.099E-383 0 -> 0
+ddmng537 minmag -0.009E-383 0 -> 0
+ddmng538 minmag -0.001E-383 0 -> 0
+ddmng539 minmag -0.0009E-383 0 -> 0
+ddmng540 minmag -0.0001E-383 0 -> 0
+
+
+-- Null tests
+ddmng900 minmag 10 # -> NaN Invalid_operation
+ddmng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddMinus.decTest b/Lib/test/decimaltestdata/ddMinus.decTest
index b7ffff7d897..2705e79ea25 100644
--- a/Lib/test/decimaltestdata/ddMinus.decTest
+++ b/Lib/test/decimaltestdata/ddMinus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddMinus.decTest -- decDouble 0-x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddmns001 minus +7.50 -> -7.50
-
--- Infinities
-ddmns011 minus Infinity -> -Infinity
-ddmns012 minus -Infinity -> Infinity
-
--- NaNs, 0 payload
-ddmns021 minus NaN -> NaN
-ddmns022 minus -NaN -> -NaN
-ddmns023 minus sNaN -> NaN Invalid_operation
-ddmns024 minus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddmns031 minus NaN13 -> NaN13
-ddmns032 minus -NaN13 -> -NaN13
-ddmns033 minus sNaN13 -> NaN13 Invalid_operation
-ddmns034 minus -sNaN13 -> -NaN13 Invalid_operation
-ddmns035 minus NaN70 -> NaN70
-ddmns036 minus -NaN70 -> -NaN70
-ddmns037 minus sNaN101 -> NaN101 Invalid_operation
-ddmns038 minus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-ddmns101 minus 7 -> -7
-ddmns102 minus -7 -> 7
-ddmns103 minus 75 -> -75
-ddmns104 minus -75 -> 75
-ddmns105 minus 7.50 -> -7.50
-ddmns106 minus -7.50 -> 7.50
-ddmns107 minus 7.500 -> -7.500
-ddmns108 minus -7.500 -> 7.500
-
--- zeros
-ddmns111 minus 0 -> 0
-ddmns112 minus -0 -> 0
-ddmns113 minus 0E+4 -> 0E+4
-ddmns114 minus -0E+4 -> 0E+4
-ddmns115 minus 0.0000 -> 0.0000
-ddmns116 minus -0.0000 -> 0.0000
-ddmns117 minus 0E-141 -> 0E-141
-ddmns118 minus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddmns121 minus 2682682682682682 -> -2682682682682682
-ddmns122 minus -2682682682682682 -> 2682682682682682
-ddmns123 minus 1341341341341341 -> -1341341341341341
-ddmns124 minus -1341341341341341 -> 1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddmns131 minus 9.999999999999999E+384 -> -9.999999999999999E+384
-ddmns132 minus 1E-383 -> -1E-383
-ddmns133 minus 1.000000000000000E-383 -> -1.000000000000000E-383
-ddmns134 minus 1E-398 -> -1E-398 Subnormal
-
-ddmns135 minus -1E-398 -> 1E-398 Subnormal
-ddmns136 minus -1.000000000000000E-383 -> 1.000000000000000E-383
-ddmns137 minus -1E-383 -> 1E-383
-ddmns138 minus -9.999999999999999E+384 -> 9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddMinus.decTest -- decDouble 0-x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddmns001 minus +7.50 -> -7.50
+
+-- Infinities
+ddmns011 minus Infinity -> -Infinity
+ddmns012 minus -Infinity -> Infinity
+
+-- NaNs, 0 payload
+ddmns021 minus NaN -> NaN
+ddmns022 minus -NaN -> -NaN
+ddmns023 minus sNaN -> NaN Invalid_operation
+ddmns024 minus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddmns031 minus NaN13 -> NaN13
+ddmns032 minus -NaN13 -> -NaN13
+ddmns033 minus sNaN13 -> NaN13 Invalid_operation
+ddmns034 minus -sNaN13 -> -NaN13 Invalid_operation
+ddmns035 minus NaN70 -> NaN70
+ddmns036 minus -NaN70 -> -NaN70
+ddmns037 minus sNaN101 -> NaN101 Invalid_operation
+ddmns038 minus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+ddmns101 minus 7 -> -7
+ddmns102 minus -7 -> 7
+ddmns103 minus 75 -> -75
+ddmns104 minus -75 -> 75
+ddmns105 minus 7.50 -> -7.50
+ddmns106 minus -7.50 -> 7.50
+ddmns107 minus 7.500 -> -7.500
+ddmns108 minus -7.500 -> 7.500
+
+-- zeros
+ddmns111 minus 0 -> 0
+ddmns112 minus -0 -> 0
+ddmns113 minus 0E+4 -> 0E+4
+ddmns114 minus -0E+4 -> 0E+4
+ddmns115 minus 0.0000 -> 0.0000
+ddmns116 minus -0.0000 -> 0.0000
+ddmns117 minus 0E-141 -> 0E-141
+ddmns118 minus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddmns121 minus 2682682682682682 -> -2682682682682682
+ddmns122 minus -2682682682682682 -> 2682682682682682
+ddmns123 minus 1341341341341341 -> -1341341341341341
+ddmns124 minus -1341341341341341 -> 1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddmns131 minus 9.999999999999999E+384 -> -9.999999999999999E+384
+ddmns132 minus 1E-383 -> -1E-383
+ddmns133 minus 1.000000000000000E-383 -> -1.000000000000000E-383
+ddmns134 minus 1E-398 -> -1E-398 Subnormal
+
+ddmns135 minus -1E-398 -> 1E-398 Subnormal
+ddmns136 minus -1.000000000000000E-383 -> 1.000000000000000E-383
+ddmns137 minus -1E-383 -> 1E-383
+ddmns138 minus -9.999999999999999E+384 -> 9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddMultiply.decTest b/Lib/test/decimaltestdata/ddMultiply.decTest
index 5873f803459..45a381dc619 100644
--- a/Lib/test/decimaltestdata/ddMultiply.decTest
+++ b/Lib/test/decimaltestdata/ddMultiply.decTest
@@ -1,553 +1,553 @@
-------------------------------------------------------------------------
--- ddMultiply.decTest -- decDouble multiplication --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddmul000 multiply 2 2 -> 4
-ddmul001 multiply 2 3 -> 6
-ddmul002 multiply 5 1 -> 5
-ddmul003 multiply 5 2 -> 10
-ddmul004 multiply 1.20 2 -> 2.40
-ddmul005 multiply 1.20 0 -> 0.00
-ddmul006 multiply 1.20 -2 -> -2.40
-ddmul007 multiply -1.20 2 -> -2.40
-ddmul008 multiply -1.20 0 -> -0.00
-ddmul009 multiply -1.20 -2 -> 2.40
-ddmul010 multiply 5.09 7.1 -> 36.139
-ddmul011 multiply 2.5 4 -> 10.0
-ddmul012 multiply 2.50 4 -> 10.00
-ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
-ddmul015 multiply 2.50 4 -> 10.00
-ddmul016 multiply 9.999999999 9.999999999 -> 99.99999998000000 Inexact Rounded
-ddmul017 multiply 9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
-ddmul018 multiply -9.999999999 9.999999999 -> -99.99999998000000 Inexact Rounded
-ddmul019 multiply -9.999999999 -9.999999999 -> 99.99999998000000 Inexact Rounded
-
--- zeros, etc.
-ddmul021 multiply 0 0 -> 0
-ddmul022 multiply 0 -0 -> -0
-ddmul023 multiply -0 0 -> -0
-ddmul024 multiply -0 -0 -> 0
-ddmul025 multiply -0.0 -0.0 -> 0.00
-ddmul026 multiply -0.0 -0.0 -> 0.00
-ddmul027 multiply -0.0 -0.0 -> 0.00
-ddmul028 multiply -0.0 -0.0 -> 0.00
-ddmul030 multiply 5.00 1E-3 -> 0.00500
-ddmul031 multiply 00.00 0.000 -> 0.00000
-ddmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
-ddmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
-ddmul034 multiply -5.00 1E-3 -> -0.00500
-ddmul035 multiply -00.00 0.000 -> -0.00000
-ddmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
-ddmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
-ddmul038 multiply 5.00 -1E-3 -> -0.00500
-ddmul039 multiply 00.00 -0.000 -> -0.00000
-ddmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
-ddmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
-ddmul042 multiply -5.00 -1E-3 -> 0.00500
-ddmul043 multiply -00.00 -0.000 -> 0.00000
-ddmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
-ddmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-ddmul050 multiply 1.20 3 -> 3.60
-ddmul051 multiply 7 3 -> 21
-ddmul052 multiply 0.9 0.8 -> 0.72
-ddmul053 multiply 0.9 -0 -> -0.0
-ddmul054 multiply 654321 654321 -> 428135971041
-
-ddmul060 multiply 123.45 1e7 -> 1.2345E+9
-ddmul061 multiply 123.45 1e8 -> 1.2345E+10
-ddmul062 multiply 123.45 1e+9 -> 1.2345E+11
-ddmul063 multiply 123.45 1e10 -> 1.2345E+12
-ddmul064 multiply 123.45 1e11 -> 1.2345E+13
-ddmul065 multiply 123.45 1e12 -> 1.2345E+14
-ddmul066 multiply 123.45 1e13 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-ddmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
-ddmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
-ddmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
-ddmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
-
--- test some more edge cases and carries
-ddmul101 multiply 9 9 -> 81
-ddmul102 multiply 9 90 -> 810
-ddmul103 multiply 9 900 -> 8100
-ddmul104 multiply 9 9000 -> 81000
-ddmul105 multiply 9 90000 -> 810000
-ddmul106 multiply 9 900000 -> 8100000
-ddmul107 multiply 9 9000000 -> 81000000
-ddmul108 multiply 9 90000000 -> 810000000
-ddmul109 multiply 9 900000000 -> 8100000000
-ddmul110 multiply 9 9000000000 -> 81000000000
-ddmul111 multiply 9 90000000000 -> 810000000000
-ddmul112 multiply 9 900000000000 -> 8100000000000
-ddmul113 multiply 9 9000000000000 -> 81000000000000
-ddmul114 multiply 9 90000000000000 -> 810000000000000
-ddmul115 multiply 9 900000000000000 -> 8100000000000000
---ddmul116 multiply 9 9000000000000000 -> 81000000000000000
---ddmul117 multiply 9 90000000000000000 -> 810000000000000000
---ddmul118 multiply 9 900000000000000000 -> 8100000000000000000
---ddmul119 multiply 9 9000000000000000000 -> 81000000000000000000
---ddmul120 multiply 9 90000000000000000000 -> 810000000000000000000
---ddmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
---ddmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
---ddmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
--- test some more edge cases without carries
-ddmul131 multiply 3 3 -> 9
-ddmul132 multiply 3 30 -> 90
-ddmul133 multiply 3 300 -> 900
-ddmul134 multiply 3 3000 -> 9000
-ddmul135 multiply 3 30000 -> 90000
-ddmul136 multiply 3 300000 -> 900000
-ddmul137 multiply 3 3000000 -> 9000000
-ddmul138 multiply 3 30000000 -> 90000000
-ddmul139 multiply 3 300000000 -> 900000000
-ddmul140 multiply 3 3000000000 -> 9000000000
-ddmul141 multiply 3 30000000000 -> 90000000000
-ddmul142 multiply 3 300000000000 -> 900000000000
-ddmul143 multiply 3 3000000000000 -> 9000000000000
-ddmul144 multiply 3 30000000000000 -> 90000000000000
-ddmul145 multiply 3 300000000000000 -> 900000000000000
-
--- test some edge cases with exact rounding
-ddmul301 multiply 9 9 -> 81
-ddmul302 multiply 9 90 -> 810
-ddmul303 multiply 9 900 -> 8100
-ddmul304 multiply 9 9000 -> 81000
-ddmul305 multiply 9 90000 -> 810000
-ddmul306 multiply 9 900000 -> 8100000
-ddmul307 multiply 9 9000000 -> 81000000
-ddmul308 multiply 9 90000000 -> 810000000
-ddmul309 multiply 9 900000000 -> 8100000000
-ddmul310 multiply 9 9000000000 -> 81000000000
-ddmul311 multiply 9 90000000000 -> 810000000000
-ddmul312 multiply 9 900000000000 -> 8100000000000
-ddmul313 multiply 9 9000000000000 -> 81000000000000
-ddmul314 multiply 9 90000000000000 -> 810000000000000
-ddmul315 multiply 9 900000000000000 -> 8100000000000000
-ddmul316 multiply 9 9000000000000000 -> 8.100000000000000E+16 Rounded
-ddmul317 multiply 90 9000000000000000 -> 8.100000000000000E+17 Rounded
-ddmul318 multiply 900 9000000000000000 -> 8.100000000000000E+18 Rounded
-ddmul319 multiply 9000 9000000000000000 -> 8.100000000000000E+19 Rounded
-ddmul320 multiply 90000 9000000000000000 -> 8.100000000000000E+20 Rounded
-ddmul321 multiply 900000 9000000000000000 -> 8.100000000000000E+21 Rounded
-ddmul322 multiply 9000000 9000000000000000 -> 8.100000000000000E+22 Rounded
-ddmul323 multiply 90000000 9000000000000000 -> 8.100000000000000E+23 Rounded
-
--- tryzeros cases
-ddmul504 multiply 0E-260 1000E-260 -> 0E-398 Clamped
-ddmul505 multiply 100E+260 0E+260 -> 0E+369 Clamped
--- 65K-1 case
-ddmul506 multiply 77.1 850 -> 65535.0
-
--- mixed with zeros
-ddmul541 multiply 0 -1 -> -0
-ddmul542 multiply -0 -1 -> 0
-ddmul543 multiply 0 1 -> 0
-ddmul544 multiply -0 1 -> -0
-ddmul545 multiply -1 0 -> -0
-ddmul546 multiply -1 -0 -> 0
-ddmul547 multiply 1 0 -> 0
-ddmul548 multiply 1 -0 -> -0
-
-ddmul551 multiply 0.0 -1 -> -0.0
-ddmul552 multiply -0.0 -1 -> 0.0
-ddmul553 multiply 0.0 1 -> 0.0
-ddmul554 multiply -0.0 1 -> -0.0
-ddmul555 multiply -1.0 0 -> -0.0
-ddmul556 multiply -1.0 -0 -> 0.0
-ddmul557 multiply 1.0 0 -> 0.0
-ddmul558 multiply 1.0 -0 -> -0.0
-
-ddmul561 multiply 0 -1.0 -> -0.0
-ddmul562 multiply -0 -1.0 -> 0.0
-ddmul563 multiply 0 1.0 -> 0.0
-ddmul564 multiply -0 1.0 -> -0.0
-ddmul565 multiply -1 0.0 -> -0.0
-ddmul566 multiply -1 -0.0 -> 0.0
-ddmul567 multiply 1 0.0 -> 0.0
-ddmul568 multiply 1 -0.0 -> -0.0
-
-ddmul571 multiply 0.0 -1.0 -> -0.00
-ddmul572 multiply -0.0 -1.0 -> 0.00
-ddmul573 multiply 0.0 1.0 -> 0.00
-ddmul574 multiply -0.0 1.0 -> -0.00
-ddmul575 multiply -1.0 0.0 -> -0.00
-ddmul576 multiply -1.0 -0.0 -> 0.00
-ddmul577 multiply 1.0 0.0 -> 0.00
-ddmul578 multiply 1.0 -0.0 -> -0.00
-
-
--- Specials
-ddmul580 multiply Inf -Inf -> -Infinity
-ddmul581 multiply Inf -1000 -> -Infinity
-ddmul582 multiply Inf -1 -> -Infinity
-ddmul583 multiply Inf -0 -> NaN Invalid_operation
-ddmul584 multiply Inf 0 -> NaN Invalid_operation
-ddmul585 multiply Inf 1 -> Infinity
-ddmul586 multiply Inf 1000 -> Infinity
-ddmul587 multiply Inf Inf -> Infinity
-ddmul588 multiply -1000 Inf -> -Infinity
-ddmul589 multiply -Inf Inf -> -Infinity
-ddmul590 multiply -1 Inf -> -Infinity
-ddmul591 multiply -0 Inf -> NaN Invalid_operation
-ddmul592 multiply 0 Inf -> NaN Invalid_operation
-ddmul593 multiply 1 Inf -> Infinity
-ddmul594 multiply 1000 Inf -> Infinity
-ddmul595 multiply Inf Inf -> Infinity
-
-ddmul600 multiply -Inf -Inf -> Infinity
-ddmul601 multiply -Inf -1000 -> Infinity
-ddmul602 multiply -Inf -1 -> Infinity
-ddmul603 multiply -Inf -0 -> NaN Invalid_operation
-ddmul604 multiply -Inf 0 -> NaN Invalid_operation
-ddmul605 multiply -Inf 1 -> -Infinity
-ddmul606 multiply -Inf 1000 -> -Infinity
-ddmul607 multiply -Inf Inf -> -Infinity
-ddmul608 multiply -1000 Inf -> -Infinity
-ddmul609 multiply -Inf -Inf -> Infinity
-ddmul610 multiply -1 -Inf -> Infinity
-ddmul611 multiply -0 -Inf -> NaN Invalid_operation
-ddmul612 multiply 0 -Inf -> NaN Invalid_operation
-ddmul613 multiply 1 -Inf -> -Infinity
-ddmul614 multiply 1000 -Inf -> -Infinity
-ddmul615 multiply Inf -Inf -> -Infinity
-
-ddmul621 multiply NaN -Inf -> NaN
-ddmul622 multiply NaN -1000 -> NaN
-ddmul623 multiply NaN -1 -> NaN
-ddmul624 multiply NaN -0 -> NaN
-ddmul625 multiply NaN 0 -> NaN
-ddmul626 multiply NaN 1 -> NaN
-ddmul627 multiply NaN 1000 -> NaN
-ddmul628 multiply NaN Inf -> NaN
-ddmul629 multiply NaN NaN -> NaN
-ddmul630 multiply -Inf NaN -> NaN
-ddmul631 multiply -1000 NaN -> NaN
-ddmul632 multiply -1 NaN -> NaN
-ddmul633 multiply -0 NaN -> NaN
-ddmul634 multiply 0 NaN -> NaN
-ddmul635 multiply 1 NaN -> NaN
-ddmul636 multiply 1000 NaN -> NaN
-ddmul637 multiply Inf NaN -> NaN
-
-ddmul641 multiply sNaN -Inf -> NaN Invalid_operation
-ddmul642 multiply sNaN -1000 -> NaN Invalid_operation
-ddmul643 multiply sNaN -1 -> NaN Invalid_operation
-ddmul644 multiply sNaN -0 -> NaN Invalid_operation
-ddmul645 multiply sNaN 0 -> NaN Invalid_operation
-ddmul646 multiply sNaN 1 -> NaN Invalid_operation
-ddmul647 multiply sNaN 1000 -> NaN Invalid_operation
-ddmul648 multiply sNaN NaN -> NaN Invalid_operation
-ddmul649 multiply sNaN sNaN -> NaN Invalid_operation
-ddmul650 multiply NaN sNaN -> NaN Invalid_operation
-ddmul651 multiply -Inf sNaN -> NaN Invalid_operation
-ddmul652 multiply -1000 sNaN -> NaN Invalid_operation
-ddmul653 multiply -1 sNaN -> NaN Invalid_operation
-ddmul654 multiply -0 sNaN -> NaN Invalid_operation
-ddmul655 multiply 0 sNaN -> NaN Invalid_operation
-ddmul656 multiply 1 sNaN -> NaN Invalid_operation
-ddmul657 multiply 1000 sNaN -> NaN Invalid_operation
-ddmul658 multiply Inf sNaN -> NaN Invalid_operation
-ddmul659 multiply NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddmul661 multiply NaN9 -Inf -> NaN9
-ddmul662 multiply NaN8 999 -> NaN8
-ddmul663 multiply NaN71 Inf -> NaN71
-ddmul664 multiply NaN6 NaN5 -> NaN6
-ddmul665 multiply -Inf NaN4 -> NaN4
-ddmul666 multiply -999 NaN33 -> NaN33
-ddmul667 multiply Inf NaN2 -> NaN2
-
-ddmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
-ddmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
-ddmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
-ddmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
-ddmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
-ddmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
-ddmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
-ddmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
-
-ddmul681 multiply -NaN9 -Inf -> -NaN9
-ddmul682 multiply -NaN8 999 -> -NaN8
-ddmul683 multiply -NaN71 Inf -> -NaN71
-ddmul684 multiply -NaN6 -NaN5 -> -NaN6
-ddmul685 multiply -Inf -NaN4 -> -NaN4
-ddmul686 multiply -999 -NaN33 -> -NaN33
-ddmul687 multiply Inf -NaN2 -> -NaN2
-
-ddmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
-ddmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
-ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
-ddmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-ddmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
-ddmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
-ddmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
-ddmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
-
-ddmul701 multiply -NaN -Inf -> -NaN
-ddmul702 multiply -NaN 999 -> -NaN
-ddmul703 multiply -NaN Inf -> -NaN
-ddmul704 multiply -NaN -NaN -> -NaN
-ddmul705 multiply -Inf -NaN0 -> -NaN
-ddmul706 multiply -999 -NaN -> -NaN
-ddmul707 multiply Inf -NaN -> -NaN
-
-ddmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
-ddmul712 multiply -sNaN -11 -> -NaN Invalid_operation
-ddmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
-ddmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
-ddmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
-ddmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
-ddmul717 multiply 088 -sNaN -> -NaN Invalid_operation
-ddmul718 multiply Inf -sNaN -> -NaN Invalid_operation
-ddmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-ddmul751 multiply 1e+277 1e+311 -> Infinity Overflow Inexact Rounded
-ddmul752 multiply 1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
-ddmul753 multiply -1e+277 1e+311 -> -Infinity Overflow Inexact Rounded
-ddmul754 multiply -1e+277 -1e+311 -> Infinity Overflow Inexact Rounded
-ddmul755 multiply 1e-277 1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul756 multiply 1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul757 multiply -1e-277 1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul758 multiply -1e-277 -1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
-ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
-ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
-ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
-ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
-ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
-ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
-ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381 Clamped
-ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382 Clamped
-ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383 Clamped
-ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384 Clamped
-ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
-ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
-ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
-ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
-ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
-ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded
-
-ddmul801 multiply 1.0000E-394 1 -> 1.0000E-394 Subnormal
-ddmul802 multiply 1.000E-394 1e-1 -> 1.000E-395 Subnormal
-ddmul803 multiply 1.00E-394 1e-2 -> 1.00E-396 Subnormal
-ddmul804 multiply 1.0E-394 1e-3 -> 1.0E-397 Subnormal
-ddmul805 multiply 1.0E-394 1e-4 -> 1E-398 Subnormal Rounded
-ddmul806 multiply 1.3E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul807 multiply 1.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul808 multiply 1.7E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul809 multiply 2.3E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul810 multiply 2.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul811 multiply 2.7E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
-ddmul812 multiply 1.49E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul813 multiply 1.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul814 multiply 1.51E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul815 multiply 2.49E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul816 multiply 2.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
-ddmul817 multiply 2.51E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
-
-ddmul818 multiply 1E-394 1e-4 -> 1E-398 Subnormal
-ddmul819 multiply 3E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul820 multiply 5E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul821 multiply 7E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul822 multiply 9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddmul823 multiply 9.9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddmul824 multiply 1E-394 -1e-4 -> -1E-398 Subnormal
-ddmul825 multiply 3E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul826 multiply -5E-394 1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul827 multiply 7E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul828 multiply -9E-394 1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul829 multiply 9.9E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddmul830 multiply 3.0E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddmul831 multiply 1.0E-199 1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddmul832 multiply 1.0E-199 1e-199 -> 1E-398 Subnormal Rounded
-ddmul833 multiply 1.0E-199 1e-198 -> 1.0E-397 Subnormal
-ddmul834 multiply 2.0E-199 2e-198 -> 4.0E-397 Subnormal
-ddmul835 multiply 4.0E-199 4e-198 -> 1.60E-396 Subnormal
-ddmul836 multiply 10.0E-199 10e-198 -> 1.000E-395 Subnormal
-ddmul837 multiply 30.0E-199 30e-198 -> 9.000E-395 Subnormal
-ddmul838 multiply 40.0E-199 40e-188 -> 1.6000E-384 Subnormal
-ddmul839 multiply 40.0E-199 40e-187 -> 1.6000E-383
-ddmul840 multiply 40.0E-199 40e-186 -> 1.6000E-382
-
--- Long operand overflow may be a different path
-ddmul870 multiply 100 9.999E+383 -> Infinity Inexact Overflow Rounded
-ddmul871 multiply 100 -9.999E+383 -> -Infinity Inexact Overflow Rounded
-ddmul872 multiply 9.999E+383 100 -> Infinity Inexact Overflow Rounded
-ddmul873 multiply -9.999E+383 100 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-ddmul881 multiply 1.2347E-355 1.2347E-40 -> 1.524E-395 Inexact Rounded Subnormal Underflow
-ddmul882 multiply 1.234E-355 1.234E-40 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul883 multiply 1.23E-355 1.23E-40 -> 1.513E-395 Inexact Rounded Subnormal Underflow
-ddmul884 multiply 1.2E-355 1.2E-40 -> 1.44E-395 Subnormal
-ddmul885 multiply 1.2E-355 1.2E-41 -> 1.44E-396 Subnormal
-ddmul886 multiply 1.2E-355 1.2E-42 -> 1.4E-397 Subnormal Inexact Rounded Underflow
-ddmul887 multiply 1.2E-355 1.3E-42 -> 1.6E-397 Subnormal Inexact Rounded Underflow
-ddmul888 multiply 1.3E-355 1.3E-42 -> 1.7E-397 Subnormal Inexact Rounded Underflow
-ddmul889 multiply 1.3E-355 1.3E-43 -> 2E-398 Subnormal Inexact Rounded Underflow
-ddmul890 multiply 1.3E-356 1.3E-43 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
-
-ddmul891 multiply 1.2345E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddmul892 multiply 1.23456E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
-ddmul893 multiply 1.2345E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul894 multiply 1.23456E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
-ddmul895 multiply 1.2345E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-ddmul896 multiply 1.23456E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- 1 234567890123456
-ddmul900 multiply 0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
-ddmul901 multiply 0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-ddmul902 multiply 9.999999999999999E-383 0.0999999999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-ddmul903 multiply 9.999999999999999E-383 0.09999999999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-ddmul904 multiply 9.999999999999999E-383 0.099999999999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-ddmul905 multiply 9.999999999999999E-383 0.0999999999999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- The next rounds to Nmin (b**emin); this is the distinguishing case
--- for detecting tininess (before or after rounding) -- if after
--- rounding then the result would be the same, but the Underflow flag
--- would not be set
-ddmul906 multiply 9.999999999999999E-383 0.09999999999999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
--- prove those operands were exact
-ddmul907 multiply 9.999999999999999E-383 1 -> 9.999999999999999E-383
-ddmul908 multiply 1 0.09999999999999999 -> 0.09999999999999999
-
--- reducing tiniest
-ddmul910 multiply 1e-398 0.99 -> 1E-398 Subnormal Inexact Rounded Underflow
-ddmul911 multiply 1e-398 0.75 -> 1E-398 Subnormal Inexact Rounded Underflow
-ddmul912 multiply 1e-398 0.5 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-ddmul913 multiply 1e-398 0.25 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-ddmul914 multiply 1e-398 0.01 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- hugest
-ddmul920 multiply 9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded
-
--- power-of-ten edge cases
-ddmul1001 multiply 1 10 -> 10
-ddmul1002 multiply 1 100 -> 100
-ddmul1003 multiply 1 1000 -> 1000
-ddmul1004 multiply 1 10000 -> 10000
-ddmul1005 multiply 1 100000 -> 100000
-ddmul1006 multiply 1 1000000 -> 1000000
-ddmul1007 multiply 1 10000000 -> 10000000
-ddmul1008 multiply 1 100000000 -> 100000000
-ddmul1009 multiply 1 1000000000 -> 1000000000
-ddmul1010 multiply 1 10000000000 -> 10000000000
-ddmul1011 multiply 1 100000000000 -> 100000000000
-ddmul1012 multiply 1 1000000000000 -> 1000000000000
-ddmul1013 multiply 1 10000000000000 -> 10000000000000
-ddmul1014 multiply 1 100000000000000 -> 100000000000000
-ddmul1015 multiply 1 1000000000000000 -> 1000000000000000
-ddmul1021 multiply 10 1 -> 10
-ddmul1022 multiply 10 10 -> 100
-ddmul1023 multiply 10 100 -> 1000
-ddmul1024 multiply 10 1000 -> 10000
-ddmul1025 multiply 10 10000 -> 100000
-ddmul1026 multiply 10 100000 -> 1000000
-ddmul1027 multiply 10 1000000 -> 10000000
-ddmul1028 multiply 10 10000000 -> 100000000
-ddmul1029 multiply 10 100000000 -> 1000000000
-ddmul1030 multiply 10 1000000000 -> 10000000000
-ddmul1031 multiply 10 10000000000 -> 100000000000
-ddmul1032 multiply 10 100000000000 -> 1000000000000
-ddmul1033 multiply 10 1000000000000 -> 10000000000000
-ddmul1034 multiply 10 10000000000000 -> 100000000000000
-ddmul1035 multiply 10 100000000000000 -> 1000000000000000
-ddmul1041 multiply 100 0.1 -> 10.0
-ddmul1042 multiply 100 1 -> 100
-ddmul1043 multiply 100 10 -> 1000
-ddmul1044 multiply 100 100 -> 10000
-ddmul1045 multiply 100 1000 -> 100000
-ddmul1046 multiply 100 10000 -> 1000000
-ddmul1047 multiply 100 100000 -> 10000000
-ddmul1048 multiply 100 1000000 -> 100000000
-ddmul1049 multiply 100 10000000 -> 1000000000
-ddmul1050 multiply 100 100000000 -> 10000000000
-ddmul1051 multiply 100 1000000000 -> 100000000000
-ddmul1052 multiply 100 10000000000 -> 1000000000000
-ddmul1053 multiply 100 100000000000 -> 10000000000000
-ddmul1054 multiply 100 1000000000000 -> 100000000000000
-ddmul1055 multiply 100 10000000000000 -> 1000000000000000
-ddmul1061 multiply 1000 0.01 -> 10.00
-ddmul1062 multiply 1000 0.1 -> 100.0
-ddmul1063 multiply 1000 1 -> 1000
-ddmul1064 multiply 1000 10 -> 10000
-ddmul1065 multiply 1000 100 -> 100000
-ddmul1066 multiply 1000 1000 -> 1000000
-ddmul1067 multiply 1000 10000 -> 10000000
-ddmul1068 multiply 1000 100000 -> 100000000
-ddmul1069 multiply 1000 1000000 -> 1000000000
-ddmul1070 multiply 1000 10000000 -> 10000000000
-ddmul1071 multiply 1000 100000000 -> 100000000000
-ddmul1072 multiply 1000 1000000000 -> 1000000000000
-ddmul1073 multiply 1000 10000000000 -> 10000000000000
-ddmul1074 multiply 1000 100000000000 -> 100000000000000
-ddmul1075 multiply 1000 1000000000000 -> 1000000000000000
-ddmul1081 multiply 10000 0.001 -> 10.000
-ddmul1082 multiply 10000 0.01 -> 100.00
-ddmul1083 multiply 10000 0.1 -> 1000.0
-ddmul1084 multiply 10000 1 -> 10000
-ddmul1085 multiply 10000 10 -> 100000
-ddmul1086 multiply 10000 100 -> 1000000
-ddmul1087 multiply 10000 1000 -> 10000000
-ddmul1088 multiply 10000 10000 -> 100000000
-ddmul1089 multiply 10000 100000 -> 1000000000
-ddmul1090 multiply 10000 1000000 -> 10000000000
-ddmul1091 multiply 10000 10000000 -> 100000000000
-ddmul1092 multiply 10000 100000000 -> 1000000000000
-ddmul1093 multiply 10000 1000000000 -> 10000000000000
-ddmul1094 multiply 10000 10000000000 -> 100000000000000
-ddmul1095 multiply 10000 100000000000 -> 1000000000000000
-
-ddmul1097 multiply 10000 99999999999 -> 999999999990000
-ddmul1098 multiply 10000 99999999999 -> 999999999990000
-
-
--- Null tests
-ddmul9990 multiply 10 # -> NaN Invalid_operation
-ddmul9991 multiply # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddMultiply.decTest -- decDouble multiplication --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddmul000 multiply 2 2 -> 4
+ddmul001 multiply 2 3 -> 6
+ddmul002 multiply 5 1 -> 5
+ddmul003 multiply 5 2 -> 10
+ddmul004 multiply 1.20 2 -> 2.40
+ddmul005 multiply 1.20 0 -> 0.00
+ddmul006 multiply 1.20 -2 -> -2.40
+ddmul007 multiply -1.20 2 -> -2.40
+ddmul008 multiply -1.20 0 -> -0.00
+ddmul009 multiply -1.20 -2 -> 2.40
+ddmul010 multiply 5.09 7.1 -> 36.139
+ddmul011 multiply 2.5 4 -> 10.0
+ddmul012 multiply 2.50 4 -> 10.00
+ddmul013 multiply 1.23456789 1.00000000 -> 1.234567890000000 Rounded
+ddmul015 multiply 2.50 4 -> 10.00
+ddmul016 multiply 9.999999999 9.999999999 -> 99.99999998000000 Inexact Rounded
+ddmul017 multiply 9.999999999 -9.999999999 -> -99.99999998000000 Inexact Rounded
+ddmul018 multiply -9.999999999 9.999999999 -> -99.99999998000000 Inexact Rounded
+ddmul019 multiply -9.999999999 -9.999999999 -> 99.99999998000000 Inexact Rounded
+
+-- zeros, etc.
+ddmul021 multiply 0 0 -> 0
+ddmul022 multiply 0 -0 -> -0
+ddmul023 multiply -0 0 -> -0
+ddmul024 multiply -0 -0 -> 0
+ddmul025 multiply -0.0 -0.0 -> 0.00
+ddmul026 multiply -0.0 -0.0 -> 0.00
+ddmul027 multiply -0.0 -0.0 -> 0.00
+ddmul028 multiply -0.0 -0.0 -> 0.00
+ddmul030 multiply 5.00 1E-3 -> 0.00500
+ddmul031 multiply 00.00 0.000 -> 0.00000
+ddmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
+ddmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
+ddmul034 multiply -5.00 1E-3 -> -0.00500
+ddmul035 multiply -00.00 0.000 -> -0.00000
+ddmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
+ddmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
+ddmul038 multiply 5.00 -1E-3 -> -0.00500
+ddmul039 multiply 00.00 -0.000 -> -0.00000
+ddmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
+ddmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
+ddmul042 multiply -5.00 -1E-3 -> 0.00500
+ddmul043 multiply -00.00 -0.000 -> 0.00000
+ddmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
+ddmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+ddmul050 multiply 1.20 3 -> 3.60
+ddmul051 multiply 7 3 -> 21
+ddmul052 multiply 0.9 0.8 -> 0.72
+ddmul053 multiply 0.9 -0 -> -0.0
+ddmul054 multiply 654321 654321 -> 428135971041
+
+ddmul060 multiply 123.45 1e7 -> 1.2345E+9
+ddmul061 multiply 123.45 1e8 -> 1.2345E+10
+ddmul062 multiply 123.45 1e+9 -> 1.2345E+11
+ddmul063 multiply 123.45 1e10 -> 1.2345E+12
+ddmul064 multiply 123.45 1e11 -> 1.2345E+13
+ddmul065 multiply 123.45 1e12 -> 1.2345E+14
+ddmul066 multiply 123.45 1e13 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+ddmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
+ddmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
+ddmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
+ddmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
+
+-- test some more edge cases and carries
+ddmul101 multiply 9 9 -> 81
+ddmul102 multiply 9 90 -> 810
+ddmul103 multiply 9 900 -> 8100
+ddmul104 multiply 9 9000 -> 81000
+ddmul105 multiply 9 90000 -> 810000
+ddmul106 multiply 9 900000 -> 8100000
+ddmul107 multiply 9 9000000 -> 81000000
+ddmul108 multiply 9 90000000 -> 810000000
+ddmul109 multiply 9 900000000 -> 8100000000
+ddmul110 multiply 9 9000000000 -> 81000000000
+ddmul111 multiply 9 90000000000 -> 810000000000
+ddmul112 multiply 9 900000000000 -> 8100000000000
+ddmul113 multiply 9 9000000000000 -> 81000000000000
+ddmul114 multiply 9 90000000000000 -> 810000000000000
+ddmul115 multiply 9 900000000000000 -> 8100000000000000
+--ddmul116 multiply 9 9000000000000000 -> 81000000000000000
+--ddmul117 multiply 9 90000000000000000 -> 810000000000000000
+--ddmul118 multiply 9 900000000000000000 -> 8100000000000000000
+--ddmul119 multiply 9 9000000000000000000 -> 81000000000000000000
+--ddmul120 multiply 9 90000000000000000000 -> 810000000000000000000
+--ddmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
+--ddmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
+--ddmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
+-- test some more edge cases without carries
+ddmul131 multiply 3 3 -> 9
+ddmul132 multiply 3 30 -> 90
+ddmul133 multiply 3 300 -> 900
+ddmul134 multiply 3 3000 -> 9000
+ddmul135 multiply 3 30000 -> 90000
+ddmul136 multiply 3 300000 -> 900000
+ddmul137 multiply 3 3000000 -> 9000000
+ddmul138 multiply 3 30000000 -> 90000000
+ddmul139 multiply 3 300000000 -> 900000000
+ddmul140 multiply 3 3000000000 -> 9000000000
+ddmul141 multiply 3 30000000000 -> 90000000000
+ddmul142 multiply 3 300000000000 -> 900000000000
+ddmul143 multiply 3 3000000000000 -> 9000000000000
+ddmul144 multiply 3 30000000000000 -> 90000000000000
+ddmul145 multiply 3 300000000000000 -> 900000000000000
+
+-- test some edge cases with exact rounding
+ddmul301 multiply 9 9 -> 81
+ddmul302 multiply 9 90 -> 810
+ddmul303 multiply 9 900 -> 8100
+ddmul304 multiply 9 9000 -> 81000
+ddmul305 multiply 9 90000 -> 810000
+ddmul306 multiply 9 900000 -> 8100000
+ddmul307 multiply 9 9000000 -> 81000000
+ddmul308 multiply 9 90000000 -> 810000000
+ddmul309 multiply 9 900000000 -> 8100000000
+ddmul310 multiply 9 9000000000 -> 81000000000
+ddmul311 multiply 9 90000000000 -> 810000000000
+ddmul312 multiply 9 900000000000 -> 8100000000000
+ddmul313 multiply 9 9000000000000 -> 81000000000000
+ddmul314 multiply 9 90000000000000 -> 810000000000000
+ddmul315 multiply 9 900000000000000 -> 8100000000000000
+ddmul316 multiply 9 9000000000000000 -> 8.100000000000000E+16 Rounded
+ddmul317 multiply 90 9000000000000000 -> 8.100000000000000E+17 Rounded
+ddmul318 multiply 900 9000000000000000 -> 8.100000000000000E+18 Rounded
+ddmul319 multiply 9000 9000000000000000 -> 8.100000000000000E+19 Rounded
+ddmul320 multiply 90000 9000000000000000 -> 8.100000000000000E+20 Rounded
+ddmul321 multiply 900000 9000000000000000 -> 8.100000000000000E+21 Rounded
+ddmul322 multiply 9000000 9000000000000000 -> 8.100000000000000E+22 Rounded
+ddmul323 multiply 90000000 9000000000000000 -> 8.100000000000000E+23 Rounded
+
+-- tryzeros cases
+ddmul504 multiply 0E-260 1000E-260 -> 0E-398 Clamped
+ddmul505 multiply 100E+260 0E+260 -> 0E+369 Clamped
+-- 65K-1 case
+ddmul506 multiply 77.1 850 -> 65535.0
+
+-- mixed with zeros
+ddmul541 multiply 0 -1 -> -0
+ddmul542 multiply -0 -1 -> 0
+ddmul543 multiply 0 1 -> 0
+ddmul544 multiply -0 1 -> -0
+ddmul545 multiply -1 0 -> -0
+ddmul546 multiply -1 -0 -> 0
+ddmul547 multiply 1 0 -> 0
+ddmul548 multiply 1 -0 -> -0
+
+ddmul551 multiply 0.0 -1 -> -0.0
+ddmul552 multiply -0.0 -1 -> 0.0
+ddmul553 multiply 0.0 1 -> 0.0
+ddmul554 multiply -0.0 1 -> -0.0
+ddmul555 multiply -1.0 0 -> -0.0
+ddmul556 multiply -1.0 -0 -> 0.0
+ddmul557 multiply 1.0 0 -> 0.0
+ddmul558 multiply 1.0 -0 -> -0.0
+
+ddmul561 multiply 0 -1.0 -> -0.0
+ddmul562 multiply -0 -1.0 -> 0.0
+ddmul563 multiply 0 1.0 -> 0.0
+ddmul564 multiply -0 1.0 -> -0.0
+ddmul565 multiply -1 0.0 -> -0.0
+ddmul566 multiply -1 -0.0 -> 0.0
+ddmul567 multiply 1 0.0 -> 0.0
+ddmul568 multiply 1 -0.0 -> -0.0
+
+ddmul571 multiply 0.0 -1.0 -> -0.00
+ddmul572 multiply -0.0 -1.0 -> 0.00
+ddmul573 multiply 0.0 1.0 -> 0.00
+ddmul574 multiply -0.0 1.0 -> -0.00
+ddmul575 multiply -1.0 0.0 -> -0.00
+ddmul576 multiply -1.0 -0.0 -> 0.00
+ddmul577 multiply 1.0 0.0 -> 0.00
+ddmul578 multiply 1.0 -0.0 -> -0.00
+
+
+-- Specials
+ddmul580 multiply Inf -Inf -> -Infinity
+ddmul581 multiply Inf -1000 -> -Infinity
+ddmul582 multiply Inf -1 -> -Infinity
+ddmul583 multiply Inf -0 -> NaN Invalid_operation
+ddmul584 multiply Inf 0 -> NaN Invalid_operation
+ddmul585 multiply Inf 1 -> Infinity
+ddmul586 multiply Inf 1000 -> Infinity
+ddmul587 multiply Inf Inf -> Infinity
+ddmul588 multiply -1000 Inf -> -Infinity
+ddmul589 multiply -Inf Inf -> -Infinity
+ddmul590 multiply -1 Inf -> -Infinity
+ddmul591 multiply -0 Inf -> NaN Invalid_operation
+ddmul592 multiply 0 Inf -> NaN Invalid_operation
+ddmul593 multiply 1 Inf -> Infinity
+ddmul594 multiply 1000 Inf -> Infinity
+ddmul595 multiply Inf Inf -> Infinity
+
+ddmul600 multiply -Inf -Inf -> Infinity
+ddmul601 multiply -Inf -1000 -> Infinity
+ddmul602 multiply -Inf -1 -> Infinity
+ddmul603 multiply -Inf -0 -> NaN Invalid_operation
+ddmul604 multiply -Inf 0 -> NaN Invalid_operation
+ddmul605 multiply -Inf 1 -> -Infinity
+ddmul606 multiply -Inf 1000 -> -Infinity
+ddmul607 multiply -Inf Inf -> -Infinity
+ddmul608 multiply -1000 Inf -> -Infinity
+ddmul609 multiply -Inf -Inf -> Infinity
+ddmul610 multiply -1 -Inf -> Infinity
+ddmul611 multiply -0 -Inf -> NaN Invalid_operation
+ddmul612 multiply 0 -Inf -> NaN Invalid_operation
+ddmul613 multiply 1 -Inf -> -Infinity
+ddmul614 multiply 1000 -Inf -> -Infinity
+ddmul615 multiply Inf -Inf -> -Infinity
+
+ddmul621 multiply NaN -Inf -> NaN
+ddmul622 multiply NaN -1000 -> NaN
+ddmul623 multiply NaN -1 -> NaN
+ddmul624 multiply NaN -0 -> NaN
+ddmul625 multiply NaN 0 -> NaN
+ddmul626 multiply NaN 1 -> NaN
+ddmul627 multiply NaN 1000 -> NaN
+ddmul628 multiply NaN Inf -> NaN
+ddmul629 multiply NaN NaN -> NaN
+ddmul630 multiply -Inf NaN -> NaN
+ddmul631 multiply -1000 NaN -> NaN
+ddmul632 multiply -1 NaN -> NaN
+ddmul633 multiply -0 NaN -> NaN
+ddmul634 multiply 0 NaN -> NaN
+ddmul635 multiply 1 NaN -> NaN
+ddmul636 multiply 1000 NaN -> NaN
+ddmul637 multiply Inf NaN -> NaN
+
+ddmul641 multiply sNaN -Inf -> NaN Invalid_operation
+ddmul642 multiply sNaN -1000 -> NaN Invalid_operation
+ddmul643 multiply sNaN -1 -> NaN Invalid_operation
+ddmul644 multiply sNaN -0 -> NaN Invalid_operation
+ddmul645 multiply sNaN 0 -> NaN Invalid_operation
+ddmul646 multiply sNaN 1 -> NaN Invalid_operation
+ddmul647 multiply sNaN 1000 -> NaN Invalid_operation
+ddmul648 multiply sNaN NaN -> NaN Invalid_operation
+ddmul649 multiply sNaN sNaN -> NaN Invalid_operation
+ddmul650 multiply NaN sNaN -> NaN Invalid_operation
+ddmul651 multiply -Inf sNaN -> NaN Invalid_operation
+ddmul652 multiply -1000 sNaN -> NaN Invalid_operation
+ddmul653 multiply -1 sNaN -> NaN Invalid_operation
+ddmul654 multiply -0 sNaN -> NaN Invalid_operation
+ddmul655 multiply 0 sNaN -> NaN Invalid_operation
+ddmul656 multiply 1 sNaN -> NaN Invalid_operation
+ddmul657 multiply 1000 sNaN -> NaN Invalid_operation
+ddmul658 multiply Inf sNaN -> NaN Invalid_operation
+ddmul659 multiply NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddmul661 multiply NaN9 -Inf -> NaN9
+ddmul662 multiply NaN8 999 -> NaN8
+ddmul663 multiply NaN71 Inf -> NaN71
+ddmul664 multiply NaN6 NaN5 -> NaN6
+ddmul665 multiply -Inf NaN4 -> NaN4
+ddmul666 multiply -999 NaN33 -> NaN33
+ddmul667 multiply Inf NaN2 -> NaN2
+
+ddmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
+ddmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
+ddmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
+ddmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
+ddmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
+ddmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
+ddmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
+ddmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
+
+ddmul681 multiply -NaN9 -Inf -> -NaN9
+ddmul682 multiply -NaN8 999 -> -NaN8
+ddmul683 multiply -NaN71 Inf -> -NaN71
+ddmul684 multiply -NaN6 -NaN5 -> -NaN6
+ddmul685 multiply -Inf -NaN4 -> -NaN4
+ddmul686 multiply -999 -NaN33 -> -NaN33
+ddmul687 multiply Inf -NaN2 -> -NaN2
+
+ddmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
+ddmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
+ddmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
+ddmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+ddmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
+ddmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
+ddmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
+ddmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+ddmul701 multiply -NaN -Inf -> -NaN
+ddmul702 multiply -NaN 999 -> -NaN
+ddmul703 multiply -NaN Inf -> -NaN
+ddmul704 multiply -NaN -NaN -> -NaN
+ddmul705 multiply -Inf -NaN0 -> -NaN
+ddmul706 multiply -999 -NaN -> -NaN
+ddmul707 multiply Inf -NaN -> -NaN
+
+ddmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
+ddmul712 multiply -sNaN -11 -> -NaN Invalid_operation
+ddmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
+ddmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
+ddmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
+ddmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
+ddmul717 multiply 088 -sNaN -> -NaN Invalid_operation
+ddmul718 multiply Inf -sNaN -> -NaN Invalid_operation
+ddmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+ddmul751 multiply 1e+277 1e+311 -> Infinity Overflow Inexact Rounded
+ddmul752 multiply 1e+277 -1e+311 -> -Infinity Overflow Inexact Rounded
+ddmul753 multiply -1e+277 1e+311 -> -Infinity Overflow Inexact Rounded
+ddmul754 multiply -1e+277 -1e+311 -> Infinity Overflow Inexact Rounded
+ddmul755 multiply 1e-277 1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul756 multiply 1e-277 -1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul757 multiply -1e-277 1e-311 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul758 multiply -1e-277 -1e-311 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+ddmul760 multiply 1e-291 1e-101 -> 1E-392 Subnormal
+ddmul761 multiply 1e-291 1e-102 -> 1E-393 Subnormal
+ddmul762 multiply 1e-291 1e-103 -> 1E-394 Subnormal
+ddmul763 multiply 1e-291 1e-104 -> 1E-395 Subnormal
+ddmul764 multiply 1e-291 1e-105 -> 1E-396 Subnormal
+ddmul765 multiply 1e-291 1e-106 -> 1E-397 Subnormal
+ddmul766 multiply 1e-291 1e-107 -> 1E-398 Subnormal
+ddmul767 multiply 1e-291 1e-108 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul768 multiply 1e-291 1e-109 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul769 multiply 1e-291 1e-110 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+ddmul770 multiply 1e+60 1e+321 -> 1.000000000000E+381 Clamped
+ddmul771 multiply 1e+60 1e+322 -> 1.0000000000000E+382 Clamped
+ddmul772 multiply 1e+60 1e+323 -> 1.00000000000000E+383 Clamped
+ddmul773 multiply 1e+60 1e+324 -> 1.000000000000000E+384 Clamped
+ddmul774 multiply 1e+60 1e+325 -> Infinity Overflow Inexact Rounded
+ddmul775 multiply 1e+60 1e+326 -> Infinity Overflow Inexact Rounded
+ddmul776 multiply 1e+60 1e+327 -> Infinity Overflow Inexact Rounded
+ddmul777 multiply 1e+60 1e+328 -> Infinity Overflow Inexact Rounded
+ddmul778 multiply 1e+60 1e+329 -> Infinity Overflow Inexact Rounded
+ddmul779 multiply 1e+60 1e+330 -> Infinity Overflow Inexact Rounded
+
+ddmul801 multiply 1.0000E-394 1 -> 1.0000E-394 Subnormal
+ddmul802 multiply 1.000E-394 1e-1 -> 1.000E-395 Subnormal
+ddmul803 multiply 1.00E-394 1e-2 -> 1.00E-396 Subnormal
+ddmul804 multiply 1.0E-394 1e-3 -> 1.0E-397 Subnormal
+ddmul805 multiply 1.0E-394 1e-4 -> 1E-398 Subnormal Rounded
+ddmul806 multiply 1.3E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul807 multiply 1.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul808 multiply 1.7E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul809 multiply 2.3E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul810 multiply 2.5E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul811 multiply 2.7E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
+ddmul812 multiply 1.49E-394 1e-4 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul813 multiply 1.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul814 multiply 1.51E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul815 multiply 2.49E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul816 multiply 2.50E-394 1e-4 -> 2E-398 Underflow Subnormal Inexact Rounded
+ddmul817 multiply 2.51E-394 1e-4 -> 3E-398 Underflow Subnormal Inexact Rounded
+
+ddmul818 multiply 1E-394 1e-4 -> 1E-398 Subnormal
+ddmul819 multiply 3E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul820 multiply 5E-394 1e-5 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul821 multiply 7E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul822 multiply 9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddmul823 multiply 9.9E-394 1e-5 -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddmul824 multiply 1E-394 -1e-4 -> -1E-398 Subnormal
+ddmul825 multiply 3E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul826 multiply -5E-394 1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul827 multiply 7E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul828 multiply -9E-394 1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul829 multiply 9.9E-394 -1e-5 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddmul830 multiply 3.0E-394 -1e-5 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddmul831 multiply 1.0E-199 1e-200 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddmul832 multiply 1.0E-199 1e-199 -> 1E-398 Subnormal Rounded
+ddmul833 multiply 1.0E-199 1e-198 -> 1.0E-397 Subnormal
+ddmul834 multiply 2.0E-199 2e-198 -> 4.0E-397 Subnormal
+ddmul835 multiply 4.0E-199 4e-198 -> 1.60E-396 Subnormal
+ddmul836 multiply 10.0E-199 10e-198 -> 1.000E-395 Subnormal
+ddmul837 multiply 30.0E-199 30e-198 -> 9.000E-395 Subnormal
+ddmul838 multiply 40.0E-199 40e-188 -> 1.6000E-384 Subnormal
+ddmul839 multiply 40.0E-199 40e-187 -> 1.6000E-383
+ddmul840 multiply 40.0E-199 40e-186 -> 1.6000E-382
+
+-- Long operand overflow may be a different path
+ddmul870 multiply 100 9.999E+383 -> Infinity Inexact Overflow Rounded
+ddmul871 multiply 100 -9.999E+383 -> -Infinity Inexact Overflow Rounded
+ddmul872 multiply 9.999E+383 100 -> Infinity Inexact Overflow Rounded
+ddmul873 multiply -9.999E+383 100 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+ddmul881 multiply 1.2347E-355 1.2347E-40 -> 1.524E-395 Inexact Rounded Subnormal Underflow
+ddmul882 multiply 1.234E-355 1.234E-40 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul883 multiply 1.23E-355 1.23E-40 -> 1.513E-395 Inexact Rounded Subnormal Underflow
+ddmul884 multiply 1.2E-355 1.2E-40 -> 1.44E-395 Subnormal
+ddmul885 multiply 1.2E-355 1.2E-41 -> 1.44E-396 Subnormal
+ddmul886 multiply 1.2E-355 1.2E-42 -> 1.4E-397 Subnormal Inexact Rounded Underflow
+ddmul887 multiply 1.2E-355 1.3E-42 -> 1.6E-397 Subnormal Inexact Rounded Underflow
+ddmul888 multiply 1.3E-355 1.3E-42 -> 1.7E-397 Subnormal Inexact Rounded Underflow
+ddmul889 multiply 1.3E-355 1.3E-43 -> 2E-398 Subnormal Inexact Rounded Underflow
+ddmul890 multiply 1.3E-356 1.3E-43 -> 0E-398 Clamped Subnormal Inexact Rounded Underflow
+
+ddmul891 multiply 1.2345E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddmul892 multiply 1.23456E-39 1.234E-355 -> 1.5234E-394 Inexact Rounded Subnormal Underflow
+ddmul893 multiply 1.2345E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul894 multiply 1.23456E-40 1.234E-355 -> 1.523E-395 Inexact Rounded Subnormal Underflow
+ddmul895 multiply 1.2345E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+ddmul896 multiply 1.23456E-41 1.234E-355 -> 1.52E-396 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- 1 234567890123456
+ddmul900 multiply 0.3000000000E-191 0.3000000000E-191 -> 9.00000000000000E-384 Subnormal Rounded
+ddmul901 multiply 0.3000000001E-191 0.3000000001E-191 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+ddmul902 multiply 9.999999999999999E-383 0.0999999999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+ddmul903 multiply 9.999999999999999E-383 0.09999999999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+ddmul904 multiply 9.999999999999999E-383 0.099999999999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+ddmul905 multiply 9.999999999999999E-383 0.0999999999999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- The next rounds to Nmin (b**emin); this is the distinguishing case
+-- for detecting tininess (before or after rounding) -- if after
+-- rounding then the result would be the same, but the Underflow flag
+-- would not be set
+ddmul906 multiply 9.999999999999999E-383 0.09999999999999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+-- prove those operands were exact
+ddmul907 multiply 9.999999999999999E-383 1 -> 9.999999999999999E-383
+ddmul908 multiply 1 0.09999999999999999 -> 0.09999999999999999
+
+-- reducing tiniest
+ddmul910 multiply 1e-398 0.99 -> 1E-398 Subnormal Inexact Rounded Underflow
+ddmul911 multiply 1e-398 0.75 -> 1E-398 Subnormal Inexact Rounded Underflow
+ddmul912 multiply 1e-398 0.5 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+ddmul913 multiply 1e-398 0.25 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+ddmul914 multiply 1e-398 0.01 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- hugest
+ddmul920 multiply 9999999999999999 9999999999999999 -> 9.999999999999998E+31 Inexact Rounded
+
+-- power-of-ten edge cases
+ddmul1001 multiply 1 10 -> 10
+ddmul1002 multiply 1 100 -> 100
+ddmul1003 multiply 1 1000 -> 1000
+ddmul1004 multiply 1 10000 -> 10000
+ddmul1005 multiply 1 100000 -> 100000
+ddmul1006 multiply 1 1000000 -> 1000000
+ddmul1007 multiply 1 10000000 -> 10000000
+ddmul1008 multiply 1 100000000 -> 100000000
+ddmul1009 multiply 1 1000000000 -> 1000000000
+ddmul1010 multiply 1 10000000000 -> 10000000000
+ddmul1011 multiply 1 100000000000 -> 100000000000
+ddmul1012 multiply 1 1000000000000 -> 1000000000000
+ddmul1013 multiply 1 10000000000000 -> 10000000000000
+ddmul1014 multiply 1 100000000000000 -> 100000000000000
+ddmul1015 multiply 1 1000000000000000 -> 1000000000000000
+ddmul1021 multiply 10 1 -> 10
+ddmul1022 multiply 10 10 -> 100
+ddmul1023 multiply 10 100 -> 1000
+ddmul1024 multiply 10 1000 -> 10000
+ddmul1025 multiply 10 10000 -> 100000
+ddmul1026 multiply 10 100000 -> 1000000
+ddmul1027 multiply 10 1000000 -> 10000000
+ddmul1028 multiply 10 10000000 -> 100000000
+ddmul1029 multiply 10 100000000 -> 1000000000
+ddmul1030 multiply 10 1000000000 -> 10000000000
+ddmul1031 multiply 10 10000000000 -> 100000000000
+ddmul1032 multiply 10 100000000000 -> 1000000000000
+ddmul1033 multiply 10 1000000000000 -> 10000000000000
+ddmul1034 multiply 10 10000000000000 -> 100000000000000
+ddmul1035 multiply 10 100000000000000 -> 1000000000000000
+ddmul1041 multiply 100 0.1 -> 10.0
+ddmul1042 multiply 100 1 -> 100
+ddmul1043 multiply 100 10 -> 1000
+ddmul1044 multiply 100 100 -> 10000
+ddmul1045 multiply 100 1000 -> 100000
+ddmul1046 multiply 100 10000 -> 1000000
+ddmul1047 multiply 100 100000 -> 10000000
+ddmul1048 multiply 100 1000000 -> 100000000
+ddmul1049 multiply 100 10000000 -> 1000000000
+ddmul1050 multiply 100 100000000 -> 10000000000
+ddmul1051 multiply 100 1000000000 -> 100000000000
+ddmul1052 multiply 100 10000000000 -> 1000000000000
+ddmul1053 multiply 100 100000000000 -> 10000000000000
+ddmul1054 multiply 100 1000000000000 -> 100000000000000
+ddmul1055 multiply 100 10000000000000 -> 1000000000000000
+ddmul1061 multiply 1000 0.01 -> 10.00
+ddmul1062 multiply 1000 0.1 -> 100.0
+ddmul1063 multiply 1000 1 -> 1000
+ddmul1064 multiply 1000 10 -> 10000
+ddmul1065 multiply 1000 100 -> 100000
+ddmul1066 multiply 1000 1000 -> 1000000
+ddmul1067 multiply 1000 10000 -> 10000000
+ddmul1068 multiply 1000 100000 -> 100000000
+ddmul1069 multiply 1000 1000000 -> 1000000000
+ddmul1070 multiply 1000 10000000 -> 10000000000
+ddmul1071 multiply 1000 100000000 -> 100000000000
+ddmul1072 multiply 1000 1000000000 -> 1000000000000
+ddmul1073 multiply 1000 10000000000 -> 10000000000000
+ddmul1074 multiply 1000 100000000000 -> 100000000000000
+ddmul1075 multiply 1000 1000000000000 -> 1000000000000000
+ddmul1081 multiply 10000 0.001 -> 10.000
+ddmul1082 multiply 10000 0.01 -> 100.00
+ddmul1083 multiply 10000 0.1 -> 1000.0
+ddmul1084 multiply 10000 1 -> 10000
+ddmul1085 multiply 10000 10 -> 100000
+ddmul1086 multiply 10000 100 -> 1000000
+ddmul1087 multiply 10000 1000 -> 10000000
+ddmul1088 multiply 10000 10000 -> 100000000
+ddmul1089 multiply 10000 100000 -> 1000000000
+ddmul1090 multiply 10000 1000000 -> 10000000000
+ddmul1091 multiply 10000 10000000 -> 100000000000
+ddmul1092 multiply 10000 100000000 -> 1000000000000
+ddmul1093 multiply 10000 1000000000 -> 10000000000000
+ddmul1094 multiply 10000 10000000000 -> 100000000000000
+ddmul1095 multiply 10000 100000000000 -> 1000000000000000
+
+ddmul1097 multiply 10000 99999999999 -> 999999999990000
+ddmul1098 multiply 10000 99999999999 -> 999999999990000
+
+
+-- Null tests
+ddmul9990 multiply 10 # -> NaN Invalid_operation
+ddmul9991 multiply # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextMinus.decTest b/Lib/test/decimaltestdata/ddNextMinus.decTest
index 39f58c14a44..f8a3c0eb329 100644
--- a/Lib/test/decimaltestdata/ddNextMinus.decTest
+++ b/Lib/test/decimaltestdata/ddNextMinus.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- ddNextMinus.decTest -- decDouble next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddnextm001 nextminus 0.9999999999999995 -> 0.9999999999999994
-ddnextm002 nextminus 0.9999999999999996 -> 0.9999999999999995
-ddnextm003 nextminus 0.9999999999999997 -> 0.9999999999999996
-ddnextm004 nextminus 0.9999999999999998 -> 0.9999999999999997
-ddnextm005 nextminus 0.9999999999999999 -> 0.9999999999999998
-ddnextm006 nextminus 1.000000000000000 -> 0.9999999999999999
-ddnextm007 nextminus 1.0 -> 0.9999999999999999
-ddnextm008 nextminus 1 -> 0.9999999999999999
-ddnextm009 nextminus 1.000000000000001 -> 1.000000000000000
-ddnextm010 nextminus 1.000000000000002 -> 1.000000000000001
-ddnextm011 nextminus 1.000000000000003 -> 1.000000000000002
-ddnextm012 nextminus 1.000000000000004 -> 1.000000000000003
-ddnextm013 nextminus 1.000000000000005 -> 1.000000000000004
-ddnextm014 nextminus 1.000000000000006 -> 1.000000000000005
-ddnextm015 nextminus 1.000000000000007 -> 1.000000000000006
-ddnextm016 nextminus 1.000000000000008 -> 1.000000000000007
-ddnextm017 nextminus 1.000000000000009 -> 1.000000000000008
-ddnextm018 nextminus 1.000000000000010 -> 1.000000000000009
-ddnextm019 nextminus 1.000000000000011 -> 1.000000000000010
-ddnextm020 nextminus 1.000000000000012 -> 1.000000000000011
-
-ddnextm021 nextminus -0.9999999999999995 -> -0.9999999999999996
-ddnextm022 nextminus -0.9999999999999996 -> -0.9999999999999997
-ddnextm023 nextminus -0.9999999999999997 -> -0.9999999999999998
-ddnextm024 nextminus -0.9999999999999998 -> -0.9999999999999999
-ddnextm025 nextminus -0.9999999999999999 -> -1.000000000000000
-ddnextm026 nextminus -1.000000000000000 -> -1.000000000000001
-ddnextm027 nextminus -1.0 -> -1.000000000000001
-ddnextm028 nextminus -1 -> -1.000000000000001
-ddnextm029 nextminus -1.000000000000001 -> -1.000000000000002
-ddnextm030 nextminus -1.000000000000002 -> -1.000000000000003
-ddnextm031 nextminus -1.000000000000003 -> -1.000000000000004
-ddnextm032 nextminus -1.000000000000004 -> -1.000000000000005
-ddnextm033 nextminus -1.000000000000005 -> -1.000000000000006
-ddnextm034 nextminus -1.000000000000006 -> -1.000000000000007
-ddnextm035 nextminus -1.000000000000007 -> -1.000000000000008
-ddnextm036 nextminus -1.000000000000008 -> -1.000000000000009
-ddnextm037 nextminus -1.000000000000009 -> -1.000000000000010
-ddnextm038 nextminus -1.000000000000010 -> -1.000000000000011
-ddnextm039 nextminus -1.000000000000011 -> -1.000000000000012
-
--- ultra-tiny inputs
-ddnextm062 nextminus 1E-398 -> 0E-398
-ddnextm065 nextminus -1E-398 -> -2E-398
-
--- Zeros
-ddnextm100 nextminus -0 -> -1E-398
-ddnextm101 nextminus 0 -> -1E-398
-ddnextm102 nextminus 0.00 -> -1E-398
-ddnextm103 nextminus -0.00 -> -1E-398
-ddnextm104 nextminus 0E-300 -> -1E-398
-ddnextm105 nextminus 0E+300 -> -1E-398
-ddnextm106 nextminus 0E+30000 -> -1E-398
-ddnextm107 nextminus -0E+30000 -> -1E-398
-
--- specials
-ddnextm150 nextminus Inf -> 9.999999999999999E+384
-ddnextm151 nextminus -Inf -> -Infinity
-ddnextm152 nextminus NaN -> NaN
-ddnextm153 nextminus sNaN -> NaN Invalid_operation
-ddnextm154 nextminus NaN77 -> NaN77
-ddnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-ddnextm156 nextminus -NaN -> -NaN
-ddnextm157 nextminus -sNaN -> -NaN Invalid_operation
-ddnextm158 nextminus -NaN77 -> -NaN77
-ddnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextm170 nextminus 9.999999999999999E+384 -> 9.999999999999998E+384
-ddnextm171 nextminus 9.999999999999998E+384 -> 9.999999999999997E+384
-ddnextm172 nextminus 1E-383 -> 9.99999999999999E-384
-ddnextm173 nextminus 1.000000000000000E-383 -> 9.99999999999999E-384
-ddnextm174 nextminus 9E-398 -> 8E-398
-ddnextm175 nextminus 9.9E-397 -> 9.8E-397
-ddnextm176 nextminus 9.99999999999E-387 -> 9.99999999998E-387
-ddnextm177 nextminus 9.99999999999999E-384 -> 9.99999999999998E-384
-ddnextm178 nextminus 9.99999999999998E-384 -> 9.99999999999997E-384
-ddnextm179 nextminus 9.99999999999997E-384 -> 9.99999999999996E-384
-ddnextm180 nextminus 0E-398 -> -1E-398
-ddnextm181 nextminus 1E-398 -> 0E-398
-ddnextm182 nextminus 2E-398 -> 1E-398
-
-ddnextm183 nextminus -0E-398 -> -1E-398
-ddnextm184 nextminus -1E-398 -> -2E-398
-ddnextm185 nextminus -2E-398 -> -3E-398
-ddnextm186 nextminus -10E-398 -> -1.1E-397
-ddnextm187 nextminus -100E-398 -> -1.01E-396
-ddnextm188 nextminus -100000E-398 -> -1.00001E-393
-ddnextm189 nextminus -1.00000000000E-383 -> -1.000000000000001E-383
-ddnextm190 nextminus -1.000000000000000E-383 -> -1.000000000000001E-383
-ddnextm191 nextminus -1E-383 -> -1.000000000000001E-383
-ddnextm192 nextminus -9.999999999999998E+384 -> -9.999999999999999E+384
-ddnextm193 nextminus -9.999999999999999E+384 -> -Infinity
-
--- Null tests
-ddnextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextMinus.decTest -- decDouble next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddnextm001 nextminus 0.9999999999999995 -> 0.9999999999999994
+ddnextm002 nextminus 0.9999999999999996 -> 0.9999999999999995
+ddnextm003 nextminus 0.9999999999999997 -> 0.9999999999999996
+ddnextm004 nextminus 0.9999999999999998 -> 0.9999999999999997
+ddnextm005 nextminus 0.9999999999999999 -> 0.9999999999999998
+ddnextm006 nextminus 1.000000000000000 -> 0.9999999999999999
+ddnextm007 nextminus 1.0 -> 0.9999999999999999
+ddnextm008 nextminus 1 -> 0.9999999999999999
+ddnextm009 nextminus 1.000000000000001 -> 1.000000000000000
+ddnextm010 nextminus 1.000000000000002 -> 1.000000000000001
+ddnextm011 nextminus 1.000000000000003 -> 1.000000000000002
+ddnextm012 nextminus 1.000000000000004 -> 1.000000000000003
+ddnextm013 nextminus 1.000000000000005 -> 1.000000000000004
+ddnextm014 nextminus 1.000000000000006 -> 1.000000000000005
+ddnextm015 nextminus 1.000000000000007 -> 1.000000000000006
+ddnextm016 nextminus 1.000000000000008 -> 1.000000000000007
+ddnextm017 nextminus 1.000000000000009 -> 1.000000000000008
+ddnextm018 nextminus 1.000000000000010 -> 1.000000000000009
+ddnextm019 nextminus 1.000000000000011 -> 1.000000000000010
+ddnextm020 nextminus 1.000000000000012 -> 1.000000000000011
+
+ddnextm021 nextminus -0.9999999999999995 -> -0.9999999999999996
+ddnextm022 nextminus -0.9999999999999996 -> -0.9999999999999997
+ddnextm023 nextminus -0.9999999999999997 -> -0.9999999999999998
+ddnextm024 nextminus -0.9999999999999998 -> -0.9999999999999999
+ddnextm025 nextminus -0.9999999999999999 -> -1.000000000000000
+ddnextm026 nextminus -1.000000000000000 -> -1.000000000000001
+ddnextm027 nextminus -1.0 -> -1.000000000000001
+ddnextm028 nextminus -1 -> -1.000000000000001
+ddnextm029 nextminus -1.000000000000001 -> -1.000000000000002
+ddnextm030 nextminus -1.000000000000002 -> -1.000000000000003
+ddnextm031 nextminus -1.000000000000003 -> -1.000000000000004
+ddnextm032 nextminus -1.000000000000004 -> -1.000000000000005
+ddnextm033 nextminus -1.000000000000005 -> -1.000000000000006
+ddnextm034 nextminus -1.000000000000006 -> -1.000000000000007
+ddnextm035 nextminus -1.000000000000007 -> -1.000000000000008
+ddnextm036 nextminus -1.000000000000008 -> -1.000000000000009
+ddnextm037 nextminus -1.000000000000009 -> -1.000000000000010
+ddnextm038 nextminus -1.000000000000010 -> -1.000000000000011
+ddnextm039 nextminus -1.000000000000011 -> -1.000000000000012
+
+-- ultra-tiny inputs
+ddnextm062 nextminus 1E-398 -> 0E-398
+ddnextm065 nextminus -1E-398 -> -2E-398
+
+-- Zeros
+ddnextm100 nextminus -0 -> -1E-398
+ddnextm101 nextminus 0 -> -1E-398
+ddnextm102 nextminus 0.00 -> -1E-398
+ddnextm103 nextminus -0.00 -> -1E-398
+ddnextm104 nextminus 0E-300 -> -1E-398
+ddnextm105 nextminus 0E+300 -> -1E-398
+ddnextm106 nextminus 0E+30000 -> -1E-398
+ddnextm107 nextminus -0E+30000 -> -1E-398
+
+-- specials
+ddnextm150 nextminus Inf -> 9.999999999999999E+384
+ddnextm151 nextminus -Inf -> -Infinity
+ddnextm152 nextminus NaN -> NaN
+ddnextm153 nextminus sNaN -> NaN Invalid_operation
+ddnextm154 nextminus NaN77 -> NaN77
+ddnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+ddnextm156 nextminus -NaN -> -NaN
+ddnextm157 nextminus -sNaN -> -NaN Invalid_operation
+ddnextm158 nextminus -NaN77 -> -NaN77
+ddnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextm170 nextminus 9.999999999999999E+384 -> 9.999999999999998E+384
+ddnextm171 nextminus 9.999999999999998E+384 -> 9.999999999999997E+384
+ddnextm172 nextminus 1E-383 -> 9.99999999999999E-384
+ddnextm173 nextminus 1.000000000000000E-383 -> 9.99999999999999E-384
+ddnextm174 nextminus 9E-398 -> 8E-398
+ddnextm175 nextminus 9.9E-397 -> 9.8E-397
+ddnextm176 nextminus 9.99999999999E-387 -> 9.99999999998E-387
+ddnextm177 nextminus 9.99999999999999E-384 -> 9.99999999999998E-384
+ddnextm178 nextminus 9.99999999999998E-384 -> 9.99999999999997E-384
+ddnextm179 nextminus 9.99999999999997E-384 -> 9.99999999999996E-384
+ddnextm180 nextminus 0E-398 -> -1E-398
+ddnextm181 nextminus 1E-398 -> 0E-398
+ddnextm182 nextminus 2E-398 -> 1E-398
+
+ddnextm183 nextminus -0E-398 -> -1E-398
+ddnextm184 nextminus -1E-398 -> -2E-398
+ddnextm185 nextminus -2E-398 -> -3E-398
+ddnextm186 nextminus -10E-398 -> -1.1E-397
+ddnextm187 nextminus -100E-398 -> -1.01E-396
+ddnextm188 nextminus -100000E-398 -> -1.00001E-393
+ddnextm189 nextminus -1.00000000000E-383 -> -1.000000000000001E-383
+ddnextm190 nextminus -1.000000000000000E-383 -> -1.000000000000001E-383
+ddnextm191 nextminus -1E-383 -> -1.000000000000001E-383
+ddnextm192 nextminus -9.999999999999998E+384 -> -9.999999999999999E+384
+ddnextm193 nextminus -9.999999999999999E+384 -> -Infinity
+
+-- Null tests
+ddnextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextPlus.decTest b/Lib/test/decimaltestdata/ddNextPlus.decTest
index d41dfbab3f7..4a749a18c9f 100644
--- a/Lib/test/decimaltestdata/ddNextPlus.decTest
+++ b/Lib/test/decimaltestdata/ddNextPlus.decTest
@@ -1,124 +1,124 @@
-------------------------------------------------------------------------
--- ddNextPlus.decTest -- decDouble next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddnextp001 nextplus 0.9999999999999995 -> 0.9999999999999996
-ddnextp002 nextplus 0.9999999999999996 -> 0.9999999999999997
-ddnextp003 nextplus 0.9999999999999997 -> 0.9999999999999998
-ddnextp004 nextplus 0.9999999999999998 -> 0.9999999999999999
-ddnextp005 nextplus 0.9999999999999999 -> 1.000000000000000
-ddnextp006 nextplus 1.000000000000000 -> 1.000000000000001
-ddnextp007 nextplus 1.0 -> 1.000000000000001
-ddnextp008 nextplus 1 -> 1.000000000000001
-ddnextp009 nextplus 1.000000000000001 -> 1.000000000000002
-ddnextp010 nextplus 1.000000000000002 -> 1.000000000000003
-ddnextp011 nextplus 1.000000000000003 -> 1.000000000000004
-ddnextp012 nextplus 1.000000000000004 -> 1.000000000000005
-ddnextp013 nextplus 1.000000000000005 -> 1.000000000000006
-ddnextp014 nextplus 1.000000000000006 -> 1.000000000000007
-ddnextp015 nextplus 1.000000000000007 -> 1.000000000000008
-ddnextp016 nextplus 1.000000000000008 -> 1.000000000000009
-ddnextp017 nextplus 1.000000000000009 -> 1.000000000000010
-ddnextp018 nextplus 1.000000000000010 -> 1.000000000000011
-ddnextp019 nextplus 1.000000000000011 -> 1.000000000000012
-
-ddnextp021 nextplus -0.9999999999999995 -> -0.9999999999999994
-ddnextp022 nextplus -0.9999999999999996 -> -0.9999999999999995
-ddnextp023 nextplus -0.9999999999999997 -> -0.9999999999999996
-ddnextp024 nextplus -0.9999999999999998 -> -0.9999999999999997
-ddnextp025 nextplus -0.9999999999999999 -> -0.9999999999999998
-ddnextp026 nextplus -1.000000000000000 -> -0.9999999999999999
-ddnextp027 nextplus -1.0 -> -0.9999999999999999
-ddnextp028 nextplus -1 -> -0.9999999999999999
-ddnextp029 nextplus -1.000000000000001 -> -1.000000000000000
-ddnextp030 nextplus -1.000000000000002 -> -1.000000000000001
-ddnextp031 nextplus -1.000000000000003 -> -1.000000000000002
-ddnextp032 nextplus -1.000000000000004 -> -1.000000000000003
-ddnextp033 nextplus -1.000000000000005 -> -1.000000000000004
-ddnextp034 nextplus -1.000000000000006 -> -1.000000000000005
-ddnextp035 nextplus -1.000000000000007 -> -1.000000000000006
-ddnextp036 nextplus -1.000000000000008 -> -1.000000000000007
-ddnextp037 nextplus -1.000000000000009 -> -1.000000000000008
-ddnextp038 nextplus -1.000000000000010 -> -1.000000000000009
-ddnextp039 nextplus -1.000000000000011 -> -1.000000000000010
-ddnextp040 nextplus -1.000000000000012 -> -1.000000000000011
-
--- Zeros
-ddnextp100 nextplus 0 -> 1E-398
-ddnextp101 nextplus 0.00 -> 1E-398
-ddnextp102 nextplus 0E-300 -> 1E-398
-ddnextp103 nextplus 0E+300 -> 1E-398
-ddnextp104 nextplus 0E+30000 -> 1E-398
-ddnextp105 nextplus -0 -> 1E-398
-ddnextp106 nextplus -0.00 -> 1E-398
-ddnextp107 nextplus -0E-300 -> 1E-398
-ddnextp108 nextplus -0E+300 -> 1E-398
-ddnextp109 nextplus -0E+30000 -> 1E-398
-
--- specials
-ddnextp150 nextplus Inf -> Infinity
-ddnextp151 nextplus -Inf -> -9.999999999999999E+384
-ddnextp152 nextplus NaN -> NaN
-ddnextp153 nextplus sNaN -> NaN Invalid_operation
-ddnextp154 nextplus NaN77 -> NaN77
-ddnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-ddnextp156 nextplus -NaN -> -NaN
-ddnextp157 nextplus -sNaN -> -NaN Invalid_operation
-ddnextp158 nextplus -NaN77 -> -NaN77
-ddnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextp170 nextplus -9.999999999999999E+384 -> -9.999999999999998E+384
-ddnextp171 nextplus -9.999999999999998E+384 -> -9.999999999999997E+384
-ddnextp172 nextplus -1E-383 -> -9.99999999999999E-384
-ddnextp173 nextplus -1.000000000000000E-383 -> -9.99999999999999E-384
-ddnextp174 nextplus -9E-398 -> -8E-398
-ddnextp175 nextplus -9.9E-397 -> -9.8E-397
-ddnextp176 nextplus -9.99999999999E-387 -> -9.99999999998E-387
-ddnextp177 nextplus -9.99999999999999E-384 -> -9.99999999999998E-384
-ddnextp178 nextplus -9.99999999999998E-384 -> -9.99999999999997E-384
-ddnextp179 nextplus -9.99999999999997E-384 -> -9.99999999999996E-384
-ddnextp180 nextplus -0E-398 -> 1E-398
-ddnextp181 nextplus -1E-398 -> -0E-398
-ddnextp182 nextplus -2E-398 -> -1E-398
-
-ddnextp183 nextplus 0E-398 -> 1E-398
-ddnextp184 nextplus 1E-398 -> 2E-398
-ddnextp185 nextplus 2E-398 -> 3E-398
-ddnextp186 nextplus 10E-398 -> 1.1E-397
-ddnextp187 nextplus 100E-398 -> 1.01E-396
-ddnextp188 nextplus 100000E-398 -> 1.00001E-393
-ddnextp189 nextplus 1.00000000000E-383 -> 1.000000000000001E-383
-ddnextp190 nextplus 1.000000000000000E-383 -> 1.000000000000001E-383
-ddnextp191 nextplus 1E-383 -> 1.000000000000001E-383
-ddnextp192 nextplus 9.999999999999998E+384 -> 9.999999999999999E+384
-ddnextp193 nextplus 9.999999999999999E+384 -> Infinity
-
--- Null tests
-ddnextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextPlus.decTest -- decDouble next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddnextp001 nextplus 0.9999999999999995 -> 0.9999999999999996
+ddnextp002 nextplus 0.9999999999999996 -> 0.9999999999999997
+ddnextp003 nextplus 0.9999999999999997 -> 0.9999999999999998
+ddnextp004 nextplus 0.9999999999999998 -> 0.9999999999999999
+ddnextp005 nextplus 0.9999999999999999 -> 1.000000000000000
+ddnextp006 nextplus 1.000000000000000 -> 1.000000000000001
+ddnextp007 nextplus 1.0 -> 1.000000000000001
+ddnextp008 nextplus 1 -> 1.000000000000001
+ddnextp009 nextplus 1.000000000000001 -> 1.000000000000002
+ddnextp010 nextplus 1.000000000000002 -> 1.000000000000003
+ddnextp011 nextplus 1.000000000000003 -> 1.000000000000004
+ddnextp012 nextplus 1.000000000000004 -> 1.000000000000005
+ddnextp013 nextplus 1.000000000000005 -> 1.000000000000006
+ddnextp014 nextplus 1.000000000000006 -> 1.000000000000007
+ddnextp015 nextplus 1.000000000000007 -> 1.000000000000008
+ddnextp016 nextplus 1.000000000000008 -> 1.000000000000009
+ddnextp017 nextplus 1.000000000000009 -> 1.000000000000010
+ddnextp018 nextplus 1.000000000000010 -> 1.000000000000011
+ddnextp019 nextplus 1.000000000000011 -> 1.000000000000012
+
+ddnextp021 nextplus -0.9999999999999995 -> -0.9999999999999994
+ddnextp022 nextplus -0.9999999999999996 -> -0.9999999999999995
+ddnextp023 nextplus -0.9999999999999997 -> -0.9999999999999996
+ddnextp024 nextplus -0.9999999999999998 -> -0.9999999999999997
+ddnextp025 nextplus -0.9999999999999999 -> -0.9999999999999998
+ddnextp026 nextplus -1.000000000000000 -> -0.9999999999999999
+ddnextp027 nextplus -1.0 -> -0.9999999999999999
+ddnextp028 nextplus -1 -> -0.9999999999999999
+ddnextp029 nextplus -1.000000000000001 -> -1.000000000000000
+ddnextp030 nextplus -1.000000000000002 -> -1.000000000000001
+ddnextp031 nextplus -1.000000000000003 -> -1.000000000000002
+ddnextp032 nextplus -1.000000000000004 -> -1.000000000000003
+ddnextp033 nextplus -1.000000000000005 -> -1.000000000000004
+ddnextp034 nextplus -1.000000000000006 -> -1.000000000000005
+ddnextp035 nextplus -1.000000000000007 -> -1.000000000000006
+ddnextp036 nextplus -1.000000000000008 -> -1.000000000000007
+ddnextp037 nextplus -1.000000000000009 -> -1.000000000000008
+ddnextp038 nextplus -1.000000000000010 -> -1.000000000000009
+ddnextp039 nextplus -1.000000000000011 -> -1.000000000000010
+ddnextp040 nextplus -1.000000000000012 -> -1.000000000000011
+
+-- Zeros
+ddnextp100 nextplus 0 -> 1E-398
+ddnextp101 nextplus 0.00 -> 1E-398
+ddnextp102 nextplus 0E-300 -> 1E-398
+ddnextp103 nextplus 0E+300 -> 1E-398
+ddnextp104 nextplus 0E+30000 -> 1E-398
+ddnextp105 nextplus -0 -> 1E-398
+ddnextp106 nextplus -0.00 -> 1E-398
+ddnextp107 nextplus -0E-300 -> 1E-398
+ddnextp108 nextplus -0E+300 -> 1E-398
+ddnextp109 nextplus -0E+30000 -> 1E-398
+
+-- specials
+ddnextp150 nextplus Inf -> Infinity
+ddnextp151 nextplus -Inf -> -9.999999999999999E+384
+ddnextp152 nextplus NaN -> NaN
+ddnextp153 nextplus sNaN -> NaN Invalid_operation
+ddnextp154 nextplus NaN77 -> NaN77
+ddnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+ddnextp156 nextplus -NaN -> -NaN
+ddnextp157 nextplus -sNaN -> -NaN Invalid_operation
+ddnextp158 nextplus -NaN77 -> -NaN77
+ddnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextp170 nextplus -9.999999999999999E+384 -> -9.999999999999998E+384
+ddnextp171 nextplus -9.999999999999998E+384 -> -9.999999999999997E+384
+ddnextp172 nextplus -1E-383 -> -9.99999999999999E-384
+ddnextp173 nextplus -1.000000000000000E-383 -> -9.99999999999999E-384
+ddnextp174 nextplus -9E-398 -> -8E-398
+ddnextp175 nextplus -9.9E-397 -> -9.8E-397
+ddnextp176 nextplus -9.99999999999E-387 -> -9.99999999998E-387
+ddnextp177 nextplus -9.99999999999999E-384 -> -9.99999999999998E-384
+ddnextp178 nextplus -9.99999999999998E-384 -> -9.99999999999997E-384
+ddnextp179 nextplus -9.99999999999997E-384 -> -9.99999999999996E-384
+ddnextp180 nextplus -0E-398 -> 1E-398
+ddnextp181 nextplus -1E-398 -> -0E-398
+ddnextp182 nextplus -2E-398 -> -1E-398
+
+ddnextp183 nextplus 0E-398 -> 1E-398
+ddnextp184 nextplus 1E-398 -> 2E-398
+ddnextp185 nextplus 2E-398 -> 3E-398
+ddnextp186 nextplus 10E-398 -> 1.1E-397
+ddnextp187 nextplus 100E-398 -> 1.01E-396
+ddnextp188 nextplus 100000E-398 -> 1.00001E-393
+ddnextp189 nextplus 1.00000000000E-383 -> 1.000000000000001E-383
+ddnextp190 nextplus 1.000000000000000E-383 -> 1.000000000000001E-383
+ddnextp191 nextplus 1E-383 -> 1.000000000000001E-383
+ddnextp192 nextplus 9.999999999999998E+384 -> 9.999999999999999E+384
+ddnextp193 nextplus 9.999999999999999E+384 -> Infinity
+
+-- Null tests
+ddnextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddNextToward.decTest b/Lib/test/decimaltestdata/ddNextToward.decTest
index f9e474d70f4..75386add312 100644
--- a/Lib/test/decimaltestdata/ddNextToward.decTest
+++ b/Lib/test/decimaltestdata/ddNextToward.decTest
@@ -1,374 +1,374 @@
-------------------------------------------------------------------------
--- ddNextToward.decTest -- decDouble next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check with a scattering of numerics
-ddnextt001 nexttoward 10 10 -> 10
-ddnextt002 nexttoward -10 -10 -> -10
-ddnextt003 nexttoward 1 10 -> 1.000000000000001
-ddnextt004 nexttoward 1 -10 -> 0.9999999999999999
-ddnextt005 nexttoward -1 10 -> -0.9999999999999999
-ddnextt006 nexttoward -1 -10 -> -1.000000000000001
-ddnextt007 nexttoward 0 10 -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt008 nexttoward 0 -10 -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt009 nexttoward 9.999999999999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
-ddnextt010 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-ddnextt011 nexttoward 9.999999999999999 10 -> 10.00000000000000
-ddnextt012 nexttoward 10 9.999999999999999 -> 9.999999999999999
-ddnextt013 nexttoward -9.999999999999999 -10 -> -10.00000000000000
-ddnextt014 nexttoward -10 -9.999999999999999 -> -9.999999999999999
-ddnextt015 nexttoward 9.999999999999998 10 -> 9.999999999999999
-ddnextt016 nexttoward 10 9.999999999999998 -> 9.999999999999999
-ddnextt017 nexttoward -9.999999999999998 -10 -> -9.999999999999999
-ddnextt018 nexttoward -10 -9.999999999999998 -> -9.999999999999999
-
-------- lhs=rhs
--- finites
-ddnextt101 nexttoward 7 7 -> 7
-ddnextt102 nexttoward -7 -7 -> -7
-ddnextt103 nexttoward 75 75 -> 75
-ddnextt104 nexttoward -75 -75 -> -75
-ddnextt105 nexttoward 7.50 7.5 -> 7.50
-ddnextt106 nexttoward -7.50 -7.50 -> -7.50
-ddnextt107 nexttoward 7.500 7.5000 -> 7.500
-ddnextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-ddnextt111 nexttoward 0 0 -> 0
-ddnextt112 nexttoward -0 -0 -> -0
-ddnextt113 nexttoward 0E+4 0 -> 0E+4
-ddnextt114 nexttoward -0E+4 -0 -> -0E+4
-ddnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
-ddnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
-ddnextt117 nexttoward 0E-141 0 -> 0E-141
-ddnextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-ddnextt121 nexttoward 268268268 268268268 -> 268268268
-ddnextt122 nexttoward -268268268 -268268268 -> -268268268
-ddnextt123 nexttoward 134134134 134134134 -> 134134134
-ddnextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-ddnextt131 nexttoward 9.999999999999999E+384 9.999999999999999E+384 -> 9.999999999999999E+384
-ddnextt132 nexttoward 1E-383 1E-383 -> 1E-383
-ddnextt133 nexttoward 1.000000000000000E-383 1.000000000000000E-383 -> 1.000000000000000E-383
-ddnextt134 nexttoward 1E-398 1E-398 -> 1E-398
-
-ddnextt135 nexttoward -1E-398 -1E-398 -> -1E-398
-ddnextt136 nexttoward -1.000000000000000E-383 -1.000000000000000E-383 -> -1.000000000000000E-383
-ddnextt137 nexttoward -1E-383 -1E-383 -> -1E-383
-ddnextt138 nexttoward -9.999999999999999E+384 -9.999999999999999E+384 -> -9.999999999999999E+384
-
-------- lhs<rhs
-ddnextt201 nexttoward 0.9999999999999995 Infinity -> 0.9999999999999996
-ddnextt202 nexttoward 0.9999999999999996 Infinity -> 0.9999999999999997
-ddnextt203 nexttoward 0.9999999999999997 Infinity -> 0.9999999999999998
-ddnextt204 nexttoward 0.9999999999999998 Infinity -> 0.9999999999999999
-ddnextt205 nexttoward 0.9999999999999999 Infinity -> 1.000000000000000
-ddnextt206 nexttoward 1.000000000000000 Infinity -> 1.000000000000001
-ddnextt207 nexttoward 1.0 Infinity -> 1.000000000000001
-ddnextt208 nexttoward 1 Infinity -> 1.000000000000001
-ddnextt209 nexttoward 1.000000000000001 Infinity -> 1.000000000000002
-ddnextt210 nexttoward 1.000000000000002 Infinity -> 1.000000000000003
-ddnextt211 nexttoward 1.000000000000003 Infinity -> 1.000000000000004
-ddnextt212 nexttoward 1.000000000000004 Infinity -> 1.000000000000005
-ddnextt213 nexttoward 1.000000000000005 Infinity -> 1.000000000000006
-ddnextt214 nexttoward 1.000000000000006 Infinity -> 1.000000000000007
-ddnextt215 nexttoward 1.000000000000007 Infinity -> 1.000000000000008
-ddnextt216 nexttoward 1.000000000000008 Infinity -> 1.000000000000009
-ddnextt217 nexttoward 1.000000000000009 Infinity -> 1.000000000000010
-ddnextt218 nexttoward 1.000000000000010 Infinity -> 1.000000000000011
-ddnextt219 nexttoward 1.000000000000011 Infinity -> 1.000000000000012
-
-ddnextt221 nexttoward -0.9999999999999995 Infinity -> -0.9999999999999994
-ddnextt222 nexttoward -0.9999999999999996 Infinity -> -0.9999999999999995
-ddnextt223 nexttoward -0.9999999999999997 Infinity -> -0.9999999999999996
-ddnextt224 nexttoward -0.9999999999999998 Infinity -> -0.9999999999999997
-ddnextt225 nexttoward -0.9999999999999999 Infinity -> -0.9999999999999998
-ddnextt226 nexttoward -1.000000000000000 Infinity -> -0.9999999999999999
-ddnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999
-ddnextt228 nexttoward -1 Infinity -> -0.9999999999999999
-ddnextt229 nexttoward -1.000000000000001 Infinity -> -1.000000000000000
-ddnextt230 nexttoward -1.000000000000002 Infinity -> -1.000000000000001
-ddnextt231 nexttoward -1.000000000000003 Infinity -> -1.000000000000002
-ddnextt232 nexttoward -1.000000000000004 Infinity -> -1.000000000000003
-ddnextt233 nexttoward -1.000000000000005 Infinity -> -1.000000000000004
-ddnextt234 nexttoward -1.000000000000006 Infinity -> -1.000000000000005
-ddnextt235 nexttoward -1.000000000000007 Infinity -> -1.000000000000006
-ddnextt236 nexttoward -1.000000000000008 Infinity -> -1.000000000000007
-ddnextt237 nexttoward -1.000000000000009 Infinity -> -1.000000000000008
-ddnextt238 nexttoward -1.000000000000010 Infinity -> -1.000000000000009
-ddnextt239 nexttoward -1.000000000000011 Infinity -> -1.000000000000010
-ddnextt240 nexttoward -1.000000000000012 Infinity -> -1.000000000000011
-
--- Zeros
-ddnextt300 nexttoward 0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt301 nexttoward 0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt302 nexttoward 0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt303 nexttoward 0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt304 nexttoward 0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt305 nexttoward -0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt306 nexttoward -0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt307 nexttoward -0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt308 nexttoward -0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt309 nexttoward -0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-
--- specials
-ddnextt350 nexttoward Inf Infinity -> Infinity
-ddnextt351 nexttoward -Inf Infinity -> -9.999999999999999E+384
-ddnextt352 nexttoward NaN Infinity -> NaN
-ddnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-ddnextt354 nexttoward NaN77 Infinity -> NaN77
-ddnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-ddnextt356 nexttoward -NaN Infinity -> -NaN
-ddnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-ddnextt358 nexttoward -NaN77 Infinity -> -NaN77
-ddnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextt370 nexttoward -9.999999999999999E+384 Infinity -> -9.999999999999998E+384
-ddnextt371 nexttoward -9.999999999999998E+384 Infinity -> -9.999999999999997E+384
-ddnextt372 nexttoward -1E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt373 nexttoward -1.000000000000000E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt374 nexttoward -9E-398 Infinity -> -8E-398 Underflow Subnormal Inexact Rounded
-ddnextt375 nexttoward -9.9E-397 Infinity -> -9.8E-397 Underflow Subnormal Inexact Rounded
-ddnextt376 nexttoward -9.99999999999E-387 Infinity -> -9.99999999998E-387 Underflow Subnormal Inexact Rounded
-ddnextt377 nexttoward -9.99999999999999E-384 Infinity -> -9.99999999999998E-384 Underflow Subnormal Inexact Rounded
-ddnextt378 nexttoward -9.99999999999998E-384 Infinity -> -9.99999999999997E-384 Underflow Subnormal Inexact Rounded
-ddnextt379 nexttoward -9.99999999999997E-384 Infinity -> -9.99999999999996E-384 Underflow Subnormal Inexact Rounded
-ddnextt380 nexttoward -0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt381 nexttoward -1E-398 Infinity -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddnextt382 nexttoward -2E-398 Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-
-ddnextt383 nexttoward 0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt384 nexttoward 1E-398 Infinity -> 2E-398 Underflow Subnormal Inexact Rounded
-ddnextt385 nexttoward 2E-398 Infinity -> 3E-398 Underflow Subnormal Inexact Rounded
-ddnextt386 nexttoward 10E-398 Infinity -> 1.1E-397 Underflow Subnormal Inexact Rounded
-ddnextt387 nexttoward 100E-398 Infinity -> 1.01E-396 Underflow Subnormal Inexact Rounded
-ddnextt388 nexttoward 100000E-398 Infinity -> 1.00001E-393 Underflow Subnormal Inexact Rounded
-ddnextt389 nexttoward 1.00000000000E-383 Infinity -> 1.000000000000001E-383
-ddnextt390 nexttoward 1.000000000000000E-383 Infinity -> 1.000000000000001E-383
-ddnextt391 nexttoward 1E-383 Infinity -> 1.000000000000001E-383
-ddnextt392 nexttoward 9.999999999999997E+384 Infinity -> 9.999999999999998E+384
-ddnextt393 nexttoward 9.999999999999998E+384 Infinity -> 9.999999999999999E+384
-ddnextt394 nexttoward 9.999999999999999E+384 Infinity -> Infinity Overflow Inexact Rounded
-
-------- lhs>rhs
-ddnextt401 nexttoward 0.9999999999999995 -Infinity -> 0.9999999999999994
-ddnextt402 nexttoward 0.9999999999999996 -Infinity -> 0.9999999999999995
-ddnextt403 nexttoward 0.9999999999999997 -Infinity -> 0.9999999999999996
-ddnextt404 nexttoward 0.9999999999999998 -Infinity -> 0.9999999999999997
-ddnextt405 nexttoward 0.9999999999999999 -Infinity -> 0.9999999999999998
-ddnextt406 nexttoward 1.000000000000000 -Infinity -> 0.9999999999999999
-ddnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999
-ddnextt408 nexttoward 1 -Infinity -> 0.9999999999999999
-ddnextt409 nexttoward 1.000000000000001 -Infinity -> 1.000000000000000
-ddnextt410 nexttoward 1.000000000000002 -Infinity -> 1.000000000000001
-ddnextt411 nexttoward 1.000000000000003 -Infinity -> 1.000000000000002
-ddnextt412 nexttoward 1.000000000000004 -Infinity -> 1.000000000000003
-ddnextt413 nexttoward 1.000000000000005 -Infinity -> 1.000000000000004
-ddnextt414 nexttoward 1.000000000000006 -Infinity -> 1.000000000000005
-ddnextt415 nexttoward 1.000000000000007 -Infinity -> 1.000000000000006
-ddnextt416 nexttoward 1.000000000000008 -Infinity -> 1.000000000000007
-ddnextt417 nexttoward 1.000000000000009 -Infinity -> 1.000000000000008
-ddnextt418 nexttoward 1.000000000000010 -Infinity -> 1.000000000000009
-ddnextt419 nexttoward 1.000000000000011 -Infinity -> 1.000000000000010
-ddnextt420 nexttoward 1.000000000000012 -Infinity -> 1.000000000000011
-
-ddnextt421 nexttoward -0.9999999999999995 -Infinity -> -0.9999999999999996
-ddnextt422 nexttoward -0.9999999999999996 -Infinity -> -0.9999999999999997
-ddnextt423 nexttoward -0.9999999999999997 -Infinity -> -0.9999999999999998
-ddnextt424 nexttoward -0.9999999999999998 -Infinity -> -0.9999999999999999
-ddnextt425 nexttoward -0.9999999999999999 -Infinity -> -1.000000000000000
-ddnextt426 nexttoward -1.000000000000000 -Infinity -> -1.000000000000001
-ddnextt427 nexttoward -1.0 -Infinity -> -1.000000000000001
-ddnextt428 nexttoward -1 -Infinity -> -1.000000000000001
-ddnextt429 nexttoward -1.000000000000001 -Infinity -> -1.000000000000002
-ddnextt430 nexttoward -1.000000000000002 -Infinity -> -1.000000000000003
-ddnextt431 nexttoward -1.000000000000003 -Infinity -> -1.000000000000004
-ddnextt432 nexttoward -1.000000000000004 -Infinity -> -1.000000000000005
-ddnextt433 nexttoward -1.000000000000005 -Infinity -> -1.000000000000006
-ddnextt434 nexttoward -1.000000000000006 -Infinity -> -1.000000000000007
-ddnextt435 nexttoward -1.000000000000007 -Infinity -> -1.000000000000008
-ddnextt436 nexttoward -1.000000000000008 -Infinity -> -1.000000000000009
-ddnextt437 nexttoward -1.000000000000009 -Infinity -> -1.000000000000010
-ddnextt438 nexttoward -1.000000000000010 -Infinity -> -1.000000000000011
-ddnextt439 nexttoward -1.000000000000011 -Infinity -> -1.000000000000012
-
--- Zeros
-ddnextt500 nexttoward -0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt501 nexttoward 0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt502 nexttoward 0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt503 nexttoward -0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt504 nexttoward 0E-300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt505 nexttoward 0E+300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt506 nexttoward 0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt507 nexttoward -0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-
--- specials
-ddnextt550 nexttoward Inf -Infinity -> 9.999999999999999E+384
-ddnextt551 nexttoward -Inf -Infinity -> -Infinity
-ddnextt552 nexttoward NaN -Infinity -> NaN
-ddnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-ddnextt554 nexttoward NaN77 -Infinity -> NaN77
-ddnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-ddnextt556 nexttoward -NaN -Infinity -> -NaN
-ddnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-ddnextt558 nexttoward -NaN77 -Infinity -> -NaN77
-ddnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-ddnextt670 nexttoward 9.999999999999999E+384 -Infinity -> 9.999999999999998E+384
-ddnextt671 nexttoward 9.999999999999998E+384 -Infinity -> 9.999999999999997E+384
-ddnextt672 nexttoward 1E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt673 nexttoward 1.000000000000000E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
-ddnextt674 nexttoward 9E-398 -Infinity -> 8E-398 Underflow Subnormal Inexact Rounded
-ddnextt675 nexttoward 9.9E-397 -Infinity -> 9.8E-397 Underflow Subnormal Inexact Rounded
-ddnextt676 nexttoward 9.99999999999E-387 -Infinity -> 9.99999999998E-387 Underflow Subnormal Inexact Rounded
-ddnextt677 nexttoward 9.99999999999999E-384 -Infinity -> 9.99999999999998E-384 Underflow Subnormal Inexact Rounded
-ddnextt678 nexttoward 9.99999999999998E-384 -Infinity -> 9.99999999999997E-384 Underflow Subnormal Inexact Rounded
-ddnextt679 nexttoward 9.99999999999997E-384 -Infinity -> 9.99999999999996E-384 Underflow Subnormal Inexact Rounded
-ddnextt680 nexttoward 0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt681 nexttoward 1E-398 -Infinity -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddnextt682 nexttoward 2E-398 -Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
-
-ddnextt683 nexttoward -0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt684 nexttoward -1E-398 -Infinity -> -2E-398 Underflow Subnormal Inexact Rounded
-ddnextt685 nexttoward -2E-398 -Infinity -> -3E-398 Underflow Subnormal Inexact Rounded
-ddnextt686 nexttoward -10E-398 -Infinity -> -1.1E-397 Underflow Subnormal Inexact Rounded
-ddnextt687 nexttoward -100E-398 -Infinity -> -1.01E-396 Underflow Subnormal Inexact Rounded
-ddnextt688 nexttoward -100000E-398 -Infinity -> -1.00001E-393 Underflow Subnormal Inexact Rounded
-ddnextt689 nexttoward -1.00000000000E-383 -Infinity -> -1.000000000000001E-383
-ddnextt690 nexttoward -1.000000000000000E-383 -Infinity -> -1.000000000000001E-383
-ddnextt691 nexttoward -1E-383 -Infinity -> -1.000000000000001E-383
-ddnextt692 nexttoward -9.999999999999998E+384 -Infinity -> -9.999999999999999E+384
-ddnextt693 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- Specials
-ddnextt780 nexttoward -Inf -Inf -> -Infinity
-ddnextt781 nexttoward -Inf -1000 -> -9.999999999999999E+384
-ddnextt782 nexttoward -Inf -1 -> -9.999999999999999E+384
-ddnextt783 nexttoward -Inf -0 -> -9.999999999999999E+384
-ddnextt784 nexttoward -Inf 0 -> -9.999999999999999E+384
-ddnextt785 nexttoward -Inf 1 -> -9.999999999999999E+384
-ddnextt786 nexttoward -Inf 1000 -> -9.999999999999999E+384
-ddnextt787 nexttoward -1000 -Inf -> -1000.000000000001
-ddnextt788 nexttoward -Inf -Inf -> -Infinity
-ddnextt789 nexttoward -1 -Inf -> -1.000000000000001
-ddnextt790 nexttoward -0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt791 nexttoward 0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
-ddnextt792 nexttoward 1 -Inf -> 0.9999999999999999
-ddnextt793 nexttoward 1000 -Inf -> 999.9999999999999
-ddnextt794 nexttoward Inf -Inf -> 9.999999999999999E+384
-
-ddnextt800 nexttoward Inf -Inf -> 9.999999999999999E+384
-ddnextt801 nexttoward Inf -1000 -> 9.999999999999999E+384
-ddnextt802 nexttoward Inf -1 -> 9.999999999999999E+384
-ddnextt803 nexttoward Inf -0 -> 9.999999999999999E+384
-ddnextt804 nexttoward Inf 0 -> 9.999999999999999E+384
-ddnextt805 nexttoward Inf 1 -> 9.999999999999999E+384
-ddnextt806 nexttoward Inf 1000 -> 9.999999999999999E+384
-ddnextt807 nexttoward Inf Inf -> Infinity
-ddnextt808 nexttoward -1000 Inf -> -999.9999999999999
-ddnextt809 nexttoward -Inf Inf -> -9.999999999999999E+384
-ddnextt810 nexttoward -1 Inf -> -0.9999999999999999
-ddnextt811 nexttoward -0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt812 nexttoward 0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
-ddnextt813 nexttoward 1 Inf -> 1.000000000000001
-ddnextt814 nexttoward 1000 Inf -> 1000.000000000001
-ddnextt815 nexttoward Inf Inf -> Infinity
-
-ddnextt821 nexttoward NaN -Inf -> NaN
-ddnextt822 nexttoward NaN -1000 -> NaN
-ddnextt823 nexttoward NaN -1 -> NaN
-ddnextt824 nexttoward NaN -0 -> NaN
-ddnextt825 nexttoward NaN 0 -> NaN
-ddnextt826 nexttoward NaN 1 -> NaN
-ddnextt827 nexttoward NaN 1000 -> NaN
-ddnextt828 nexttoward NaN Inf -> NaN
-ddnextt829 nexttoward NaN NaN -> NaN
-ddnextt830 nexttoward -Inf NaN -> NaN
-ddnextt831 nexttoward -1000 NaN -> NaN
-ddnextt832 nexttoward -1 NaN -> NaN
-ddnextt833 nexttoward -0 NaN -> NaN
-ddnextt834 nexttoward 0 NaN -> NaN
-ddnextt835 nexttoward 1 NaN -> NaN
-ddnextt836 nexttoward 1000 NaN -> NaN
-ddnextt837 nexttoward Inf NaN -> NaN
-
-ddnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-ddnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-ddnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-ddnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-ddnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-ddnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-ddnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-ddnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-ddnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-ddnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-ddnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-ddnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-ddnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-ddnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-ddnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-ddnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-ddnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-ddnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-ddnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddnextt861 nexttoward NaN1 -Inf -> NaN1
-ddnextt862 nexttoward +NaN2 -1000 -> NaN2
-ddnextt863 nexttoward NaN3 1000 -> NaN3
-ddnextt864 nexttoward NaN4 Inf -> NaN4
-ddnextt865 nexttoward NaN5 +NaN6 -> NaN5
-ddnextt866 nexttoward -Inf NaN7 -> NaN7
-ddnextt867 nexttoward -1000 NaN8 -> NaN8
-ddnextt868 nexttoward 1000 NaN9 -> NaN9
-ddnextt869 nexttoward Inf +NaN10 -> NaN10
-ddnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-ddnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-ddnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-ddnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-ddnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-ddnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-ddnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-ddnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-ddnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-ddnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddnextt882 nexttoward -NaN26 NaN28 -> -NaN26
-ddnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddnextt884 nexttoward 1000 -NaN30 -> -NaN30
-ddnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-ddnextt900 nexttoward 1 # -> NaN Invalid_operation
-ddnextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddNextToward.decTest -- decDouble next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check with a scattering of numerics
+ddnextt001 nexttoward 10 10 -> 10
+ddnextt002 nexttoward -10 -10 -> -10
+ddnextt003 nexttoward 1 10 -> 1.000000000000001
+ddnextt004 nexttoward 1 -10 -> 0.9999999999999999
+ddnextt005 nexttoward -1 10 -> -0.9999999999999999
+ddnextt006 nexttoward -1 -10 -> -1.000000000000001
+ddnextt007 nexttoward 0 10 -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt008 nexttoward 0 -10 -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt009 nexttoward 9.999999999999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
+ddnextt010 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+ddnextt011 nexttoward 9.999999999999999 10 -> 10.00000000000000
+ddnextt012 nexttoward 10 9.999999999999999 -> 9.999999999999999
+ddnextt013 nexttoward -9.999999999999999 -10 -> -10.00000000000000
+ddnextt014 nexttoward -10 -9.999999999999999 -> -9.999999999999999
+ddnextt015 nexttoward 9.999999999999998 10 -> 9.999999999999999
+ddnextt016 nexttoward 10 9.999999999999998 -> 9.999999999999999
+ddnextt017 nexttoward -9.999999999999998 -10 -> -9.999999999999999
+ddnextt018 nexttoward -10 -9.999999999999998 -> -9.999999999999999
+
+------- lhs=rhs
+-- finites
+ddnextt101 nexttoward 7 7 -> 7
+ddnextt102 nexttoward -7 -7 -> -7
+ddnextt103 nexttoward 75 75 -> 75
+ddnextt104 nexttoward -75 -75 -> -75
+ddnextt105 nexttoward 7.50 7.5 -> 7.50
+ddnextt106 nexttoward -7.50 -7.50 -> -7.50
+ddnextt107 nexttoward 7.500 7.5000 -> 7.500
+ddnextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+ddnextt111 nexttoward 0 0 -> 0
+ddnextt112 nexttoward -0 -0 -> -0
+ddnextt113 nexttoward 0E+4 0 -> 0E+4
+ddnextt114 nexttoward -0E+4 -0 -> -0E+4
+ddnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
+ddnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
+ddnextt117 nexttoward 0E-141 0 -> 0E-141
+ddnextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+ddnextt121 nexttoward 268268268 268268268 -> 268268268
+ddnextt122 nexttoward -268268268 -268268268 -> -268268268
+ddnextt123 nexttoward 134134134 134134134 -> 134134134
+ddnextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+ddnextt131 nexttoward 9.999999999999999E+384 9.999999999999999E+384 -> 9.999999999999999E+384
+ddnextt132 nexttoward 1E-383 1E-383 -> 1E-383
+ddnextt133 nexttoward 1.000000000000000E-383 1.000000000000000E-383 -> 1.000000000000000E-383
+ddnextt134 nexttoward 1E-398 1E-398 -> 1E-398
+
+ddnextt135 nexttoward -1E-398 -1E-398 -> -1E-398
+ddnextt136 nexttoward -1.000000000000000E-383 -1.000000000000000E-383 -> -1.000000000000000E-383
+ddnextt137 nexttoward -1E-383 -1E-383 -> -1E-383
+ddnextt138 nexttoward -9.999999999999999E+384 -9.999999999999999E+384 -> -9.999999999999999E+384
+
+------- lhs<rhs
+ddnextt201 nexttoward 0.9999999999999995 Infinity -> 0.9999999999999996
+ddnextt202 nexttoward 0.9999999999999996 Infinity -> 0.9999999999999997
+ddnextt203 nexttoward 0.9999999999999997 Infinity -> 0.9999999999999998
+ddnextt204 nexttoward 0.9999999999999998 Infinity -> 0.9999999999999999
+ddnextt205 nexttoward 0.9999999999999999 Infinity -> 1.000000000000000
+ddnextt206 nexttoward 1.000000000000000 Infinity -> 1.000000000000001
+ddnextt207 nexttoward 1.0 Infinity -> 1.000000000000001
+ddnextt208 nexttoward 1 Infinity -> 1.000000000000001
+ddnextt209 nexttoward 1.000000000000001 Infinity -> 1.000000000000002
+ddnextt210 nexttoward 1.000000000000002 Infinity -> 1.000000000000003
+ddnextt211 nexttoward 1.000000000000003 Infinity -> 1.000000000000004
+ddnextt212 nexttoward 1.000000000000004 Infinity -> 1.000000000000005
+ddnextt213 nexttoward 1.000000000000005 Infinity -> 1.000000000000006
+ddnextt214 nexttoward 1.000000000000006 Infinity -> 1.000000000000007
+ddnextt215 nexttoward 1.000000000000007 Infinity -> 1.000000000000008
+ddnextt216 nexttoward 1.000000000000008 Infinity -> 1.000000000000009
+ddnextt217 nexttoward 1.000000000000009 Infinity -> 1.000000000000010
+ddnextt218 nexttoward 1.000000000000010 Infinity -> 1.000000000000011
+ddnextt219 nexttoward 1.000000000000011 Infinity -> 1.000000000000012
+
+ddnextt221 nexttoward -0.9999999999999995 Infinity -> -0.9999999999999994
+ddnextt222 nexttoward -0.9999999999999996 Infinity -> -0.9999999999999995
+ddnextt223 nexttoward -0.9999999999999997 Infinity -> -0.9999999999999996
+ddnextt224 nexttoward -0.9999999999999998 Infinity -> -0.9999999999999997
+ddnextt225 nexttoward -0.9999999999999999 Infinity -> -0.9999999999999998
+ddnextt226 nexttoward -1.000000000000000 Infinity -> -0.9999999999999999
+ddnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999
+ddnextt228 nexttoward -1 Infinity -> -0.9999999999999999
+ddnextt229 nexttoward -1.000000000000001 Infinity -> -1.000000000000000
+ddnextt230 nexttoward -1.000000000000002 Infinity -> -1.000000000000001
+ddnextt231 nexttoward -1.000000000000003 Infinity -> -1.000000000000002
+ddnextt232 nexttoward -1.000000000000004 Infinity -> -1.000000000000003
+ddnextt233 nexttoward -1.000000000000005 Infinity -> -1.000000000000004
+ddnextt234 nexttoward -1.000000000000006 Infinity -> -1.000000000000005
+ddnextt235 nexttoward -1.000000000000007 Infinity -> -1.000000000000006
+ddnextt236 nexttoward -1.000000000000008 Infinity -> -1.000000000000007
+ddnextt237 nexttoward -1.000000000000009 Infinity -> -1.000000000000008
+ddnextt238 nexttoward -1.000000000000010 Infinity -> -1.000000000000009
+ddnextt239 nexttoward -1.000000000000011 Infinity -> -1.000000000000010
+ddnextt240 nexttoward -1.000000000000012 Infinity -> -1.000000000000011
+
+-- Zeros
+ddnextt300 nexttoward 0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt301 nexttoward 0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt302 nexttoward 0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt303 nexttoward 0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt304 nexttoward 0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt305 nexttoward -0 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt306 nexttoward -0.00 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt307 nexttoward -0E-300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt308 nexttoward -0E+300 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt309 nexttoward -0E+30000 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+
+-- specials
+ddnextt350 nexttoward Inf Infinity -> Infinity
+ddnextt351 nexttoward -Inf Infinity -> -9.999999999999999E+384
+ddnextt352 nexttoward NaN Infinity -> NaN
+ddnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+ddnextt354 nexttoward NaN77 Infinity -> NaN77
+ddnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+ddnextt356 nexttoward -NaN Infinity -> -NaN
+ddnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+ddnextt358 nexttoward -NaN77 Infinity -> -NaN77
+ddnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextt370 nexttoward -9.999999999999999E+384 Infinity -> -9.999999999999998E+384
+ddnextt371 nexttoward -9.999999999999998E+384 Infinity -> -9.999999999999997E+384
+ddnextt372 nexttoward -1E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt373 nexttoward -1.000000000000000E-383 Infinity -> -9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt374 nexttoward -9E-398 Infinity -> -8E-398 Underflow Subnormal Inexact Rounded
+ddnextt375 nexttoward -9.9E-397 Infinity -> -9.8E-397 Underflow Subnormal Inexact Rounded
+ddnextt376 nexttoward -9.99999999999E-387 Infinity -> -9.99999999998E-387 Underflow Subnormal Inexact Rounded
+ddnextt377 nexttoward -9.99999999999999E-384 Infinity -> -9.99999999999998E-384 Underflow Subnormal Inexact Rounded
+ddnextt378 nexttoward -9.99999999999998E-384 Infinity -> -9.99999999999997E-384 Underflow Subnormal Inexact Rounded
+ddnextt379 nexttoward -9.99999999999997E-384 Infinity -> -9.99999999999996E-384 Underflow Subnormal Inexact Rounded
+ddnextt380 nexttoward -0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt381 nexttoward -1E-398 Infinity -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddnextt382 nexttoward -2E-398 Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+
+ddnextt383 nexttoward 0E-398 Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt384 nexttoward 1E-398 Infinity -> 2E-398 Underflow Subnormal Inexact Rounded
+ddnextt385 nexttoward 2E-398 Infinity -> 3E-398 Underflow Subnormal Inexact Rounded
+ddnextt386 nexttoward 10E-398 Infinity -> 1.1E-397 Underflow Subnormal Inexact Rounded
+ddnextt387 nexttoward 100E-398 Infinity -> 1.01E-396 Underflow Subnormal Inexact Rounded
+ddnextt388 nexttoward 100000E-398 Infinity -> 1.00001E-393 Underflow Subnormal Inexact Rounded
+ddnextt389 nexttoward 1.00000000000E-383 Infinity -> 1.000000000000001E-383
+ddnextt390 nexttoward 1.000000000000000E-383 Infinity -> 1.000000000000001E-383
+ddnextt391 nexttoward 1E-383 Infinity -> 1.000000000000001E-383
+ddnextt392 nexttoward 9.999999999999997E+384 Infinity -> 9.999999999999998E+384
+ddnextt393 nexttoward 9.999999999999998E+384 Infinity -> 9.999999999999999E+384
+ddnextt394 nexttoward 9.999999999999999E+384 Infinity -> Infinity Overflow Inexact Rounded
+
+------- lhs>rhs
+ddnextt401 nexttoward 0.9999999999999995 -Infinity -> 0.9999999999999994
+ddnextt402 nexttoward 0.9999999999999996 -Infinity -> 0.9999999999999995
+ddnextt403 nexttoward 0.9999999999999997 -Infinity -> 0.9999999999999996
+ddnextt404 nexttoward 0.9999999999999998 -Infinity -> 0.9999999999999997
+ddnextt405 nexttoward 0.9999999999999999 -Infinity -> 0.9999999999999998
+ddnextt406 nexttoward 1.000000000000000 -Infinity -> 0.9999999999999999
+ddnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999
+ddnextt408 nexttoward 1 -Infinity -> 0.9999999999999999
+ddnextt409 nexttoward 1.000000000000001 -Infinity -> 1.000000000000000
+ddnextt410 nexttoward 1.000000000000002 -Infinity -> 1.000000000000001
+ddnextt411 nexttoward 1.000000000000003 -Infinity -> 1.000000000000002
+ddnextt412 nexttoward 1.000000000000004 -Infinity -> 1.000000000000003
+ddnextt413 nexttoward 1.000000000000005 -Infinity -> 1.000000000000004
+ddnextt414 nexttoward 1.000000000000006 -Infinity -> 1.000000000000005
+ddnextt415 nexttoward 1.000000000000007 -Infinity -> 1.000000000000006
+ddnextt416 nexttoward 1.000000000000008 -Infinity -> 1.000000000000007
+ddnextt417 nexttoward 1.000000000000009 -Infinity -> 1.000000000000008
+ddnextt418 nexttoward 1.000000000000010 -Infinity -> 1.000000000000009
+ddnextt419 nexttoward 1.000000000000011 -Infinity -> 1.000000000000010
+ddnextt420 nexttoward 1.000000000000012 -Infinity -> 1.000000000000011
+
+ddnextt421 nexttoward -0.9999999999999995 -Infinity -> -0.9999999999999996
+ddnextt422 nexttoward -0.9999999999999996 -Infinity -> -0.9999999999999997
+ddnextt423 nexttoward -0.9999999999999997 -Infinity -> -0.9999999999999998
+ddnextt424 nexttoward -0.9999999999999998 -Infinity -> -0.9999999999999999
+ddnextt425 nexttoward -0.9999999999999999 -Infinity -> -1.000000000000000
+ddnextt426 nexttoward -1.000000000000000 -Infinity -> -1.000000000000001
+ddnextt427 nexttoward -1.0 -Infinity -> -1.000000000000001
+ddnextt428 nexttoward -1 -Infinity -> -1.000000000000001
+ddnextt429 nexttoward -1.000000000000001 -Infinity -> -1.000000000000002
+ddnextt430 nexttoward -1.000000000000002 -Infinity -> -1.000000000000003
+ddnextt431 nexttoward -1.000000000000003 -Infinity -> -1.000000000000004
+ddnextt432 nexttoward -1.000000000000004 -Infinity -> -1.000000000000005
+ddnextt433 nexttoward -1.000000000000005 -Infinity -> -1.000000000000006
+ddnextt434 nexttoward -1.000000000000006 -Infinity -> -1.000000000000007
+ddnextt435 nexttoward -1.000000000000007 -Infinity -> -1.000000000000008
+ddnextt436 nexttoward -1.000000000000008 -Infinity -> -1.000000000000009
+ddnextt437 nexttoward -1.000000000000009 -Infinity -> -1.000000000000010
+ddnextt438 nexttoward -1.000000000000010 -Infinity -> -1.000000000000011
+ddnextt439 nexttoward -1.000000000000011 -Infinity -> -1.000000000000012
+
+-- Zeros
+ddnextt500 nexttoward -0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt501 nexttoward 0 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt502 nexttoward 0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt503 nexttoward -0.00 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt504 nexttoward 0E-300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt505 nexttoward 0E+300 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt506 nexttoward 0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt507 nexttoward -0E+30000 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+
+-- specials
+ddnextt550 nexttoward Inf -Infinity -> 9.999999999999999E+384
+ddnextt551 nexttoward -Inf -Infinity -> -Infinity
+ddnextt552 nexttoward NaN -Infinity -> NaN
+ddnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+ddnextt554 nexttoward NaN77 -Infinity -> NaN77
+ddnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+ddnextt556 nexttoward -NaN -Infinity -> -NaN
+ddnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+ddnextt558 nexttoward -NaN77 -Infinity -> -NaN77
+ddnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+ddnextt670 nexttoward 9.999999999999999E+384 -Infinity -> 9.999999999999998E+384
+ddnextt671 nexttoward 9.999999999999998E+384 -Infinity -> 9.999999999999997E+384
+ddnextt672 nexttoward 1E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt673 nexttoward 1.000000000000000E-383 -Infinity -> 9.99999999999999E-384 Underflow Subnormal Inexact Rounded
+ddnextt674 nexttoward 9E-398 -Infinity -> 8E-398 Underflow Subnormal Inexact Rounded
+ddnextt675 nexttoward 9.9E-397 -Infinity -> 9.8E-397 Underflow Subnormal Inexact Rounded
+ddnextt676 nexttoward 9.99999999999E-387 -Infinity -> 9.99999999998E-387 Underflow Subnormal Inexact Rounded
+ddnextt677 nexttoward 9.99999999999999E-384 -Infinity -> 9.99999999999998E-384 Underflow Subnormal Inexact Rounded
+ddnextt678 nexttoward 9.99999999999998E-384 -Infinity -> 9.99999999999997E-384 Underflow Subnormal Inexact Rounded
+ddnextt679 nexttoward 9.99999999999997E-384 -Infinity -> 9.99999999999996E-384 Underflow Subnormal Inexact Rounded
+ddnextt680 nexttoward 0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt681 nexttoward 1E-398 -Infinity -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddnextt682 nexttoward 2E-398 -Infinity -> 1E-398 Underflow Subnormal Inexact Rounded
+
+ddnextt683 nexttoward -0E-398 -Infinity -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt684 nexttoward -1E-398 -Infinity -> -2E-398 Underflow Subnormal Inexact Rounded
+ddnextt685 nexttoward -2E-398 -Infinity -> -3E-398 Underflow Subnormal Inexact Rounded
+ddnextt686 nexttoward -10E-398 -Infinity -> -1.1E-397 Underflow Subnormal Inexact Rounded
+ddnextt687 nexttoward -100E-398 -Infinity -> -1.01E-396 Underflow Subnormal Inexact Rounded
+ddnextt688 nexttoward -100000E-398 -Infinity -> -1.00001E-393 Underflow Subnormal Inexact Rounded
+ddnextt689 nexttoward -1.00000000000E-383 -Infinity -> -1.000000000000001E-383
+ddnextt690 nexttoward -1.000000000000000E-383 -Infinity -> -1.000000000000001E-383
+ddnextt691 nexttoward -1E-383 -Infinity -> -1.000000000000001E-383
+ddnextt692 nexttoward -9.999999999999998E+384 -Infinity -> -9.999999999999999E+384
+ddnextt693 nexttoward -9.999999999999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- Specials
+ddnextt780 nexttoward -Inf -Inf -> -Infinity
+ddnextt781 nexttoward -Inf -1000 -> -9.999999999999999E+384
+ddnextt782 nexttoward -Inf -1 -> -9.999999999999999E+384
+ddnextt783 nexttoward -Inf -0 -> -9.999999999999999E+384
+ddnextt784 nexttoward -Inf 0 -> -9.999999999999999E+384
+ddnextt785 nexttoward -Inf 1 -> -9.999999999999999E+384
+ddnextt786 nexttoward -Inf 1000 -> -9.999999999999999E+384
+ddnextt787 nexttoward -1000 -Inf -> -1000.000000000001
+ddnextt788 nexttoward -Inf -Inf -> -Infinity
+ddnextt789 nexttoward -1 -Inf -> -1.000000000000001
+ddnextt790 nexttoward -0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt791 nexttoward 0 -Inf -> -1E-398 Underflow Subnormal Inexact Rounded
+ddnextt792 nexttoward 1 -Inf -> 0.9999999999999999
+ddnextt793 nexttoward 1000 -Inf -> 999.9999999999999
+ddnextt794 nexttoward Inf -Inf -> 9.999999999999999E+384
+
+ddnextt800 nexttoward Inf -Inf -> 9.999999999999999E+384
+ddnextt801 nexttoward Inf -1000 -> 9.999999999999999E+384
+ddnextt802 nexttoward Inf -1 -> 9.999999999999999E+384
+ddnextt803 nexttoward Inf -0 -> 9.999999999999999E+384
+ddnextt804 nexttoward Inf 0 -> 9.999999999999999E+384
+ddnextt805 nexttoward Inf 1 -> 9.999999999999999E+384
+ddnextt806 nexttoward Inf 1000 -> 9.999999999999999E+384
+ddnextt807 nexttoward Inf Inf -> Infinity
+ddnextt808 nexttoward -1000 Inf -> -999.9999999999999
+ddnextt809 nexttoward -Inf Inf -> -9.999999999999999E+384
+ddnextt810 nexttoward -1 Inf -> -0.9999999999999999
+ddnextt811 nexttoward -0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt812 nexttoward 0 Inf -> 1E-398 Underflow Subnormal Inexact Rounded
+ddnextt813 nexttoward 1 Inf -> 1.000000000000001
+ddnextt814 nexttoward 1000 Inf -> 1000.000000000001
+ddnextt815 nexttoward Inf Inf -> Infinity
+
+ddnextt821 nexttoward NaN -Inf -> NaN
+ddnextt822 nexttoward NaN -1000 -> NaN
+ddnextt823 nexttoward NaN -1 -> NaN
+ddnextt824 nexttoward NaN -0 -> NaN
+ddnextt825 nexttoward NaN 0 -> NaN
+ddnextt826 nexttoward NaN 1 -> NaN
+ddnextt827 nexttoward NaN 1000 -> NaN
+ddnextt828 nexttoward NaN Inf -> NaN
+ddnextt829 nexttoward NaN NaN -> NaN
+ddnextt830 nexttoward -Inf NaN -> NaN
+ddnextt831 nexttoward -1000 NaN -> NaN
+ddnextt832 nexttoward -1 NaN -> NaN
+ddnextt833 nexttoward -0 NaN -> NaN
+ddnextt834 nexttoward 0 NaN -> NaN
+ddnextt835 nexttoward 1 NaN -> NaN
+ddnextt836 nexttoward 1000 NaN -> NaN
+ddnextt837 nexttoward Inf NaN -> NaN
+
+ddnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+ddnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+ddnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+ddnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+ddnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+ddnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+ddnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+ddnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+ddnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+ddnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+ddnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+ddnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+ddnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+ddnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+ddnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+ddnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+ddnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+ddnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+ddnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddnextt861 nexttoward NaN1 -Inf -> NaN1
+ddnextt862 nexttoward +NaN2 -1000 -> NaN2
+ddnextt863 nexttoward NaN3 1000 -> NaN3
+ddnextt864 nexttoward NaN4 Inf -> NaN4
+ddnextt865 nexttoward NaN5 +NaN6 -> NaN5
+ddnextt866 nexttoward -Inf NaN7 -> NaN7
+ddnextt867 nexttoward -1000 NaN8 -> NaN8
+ddnextt868 nexttoward 1000 NaN9 -> NaN9
+ddnextt869 nexttoward Inf +NaN10 -> NaN10
+ddnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+ddnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+ddnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+ddnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+ddnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+ddnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+ddnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+ddnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+ddnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+ddnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddnextt882 nexttoward -NaN26 NaN28 -> -NaN26
+ddnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddnextt884 nexttoward 1000 -NaN30 -> -NaN30
+ddnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+ddnextt900 nexttoward 1 # -> NaN Invalid_operation
+ddnextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddOr.decTest b/Lib/test/decimaltestdata/ddOr.decTest
index f3a702b0ef6..d36580bf667 100644
--- a/Lib/test/decimaltestdata/ddOr.decTest
+++ b/Lib/test/decimaltestdata/ddOr.decTest
@@ -1,292 +1,292 @@
-------------------------------------------------------------------------
--- ddOr.decTest -- digitwise logical OR for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddor001 or 0 0 -> 0
-ddor002 or 0 1 -> 1
-ddor003 or 1 0 -> 1
-ddor004 or 1 1 -> 1
-ddor005 or 1100 1010 -> 1110
--- and at msd and msd-1
-ddor006 or 0000000000000000 0000000000000000 -> 0
-ddor007 or 0000000000000000 1000000000000000 -> 1000000000000000
-ddor008 or 1000000000000000 0000000000000000 -> 1000000000000000
-ddor009 or 1000000000000000 1000000000000000 -> 1000000000000000
-ddor010 or 0000000000000000 0000000000000000 -> 0
-ddor011 or 0000000000000000 0100000000000000 -> 100000000000000
-ddor012 or 0100000000000000 0000000000000000 -> 100000000000000
-ddor013 or 0100000000000000 0100000000000000 -> 100000000000000
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddor020 or 1111111111111111 1111111111111111 -> 1111111111111111
-ddor021 or 111111111111111 111111111111111 -> 111111111111111
-ddor022 or 11111111111111 11111111111111 -> 11111111111111
-ddor023 or 1111111111111 1111111111111 -> 1111111111111
-ddor024 or 111111111111 111111111111 -> 111111111111
-ddor025 or 11111111111 11111111111 -> 11111111111
-ddor026 or 1111111111 1111111111 -> 1111111111
-ddor027 or 111111111 111111111 -> 111111111
-ddor028 or 11111111 11111111 -> 11111111
-ddor029 or 1111111 1111111 -> 1111111
-ddor030 or 111111 111111 -> 111111
-ddor031 or 11111 11111 -> 11111
-ddor032 or 1111 1111 -> 1111
-ddor033 or 111 111 -> 111
-ddor034 or 11 11 -> 11
-ddor035 or 1 1 -> 1
-ddor036 or 0 0 -> 0
-
-ddor042 or 111111110000000 1111111110000000 -> 1111111110000000
-ddor043 or 11111110000000 1000000100000000 -> 1011111110000000
-ddor044 or 1111110000000 1000001000000000 -> 1001111110000000
-ddor045 or 111110000000 1000010000000000 -> 1000111110000000
-ddor046 or 11110000000 1000100000000000 -> 1000111110000000
-ddor047 or 1110000000 1001000000000000 -> 1001001110000000
-ddor048 or 110000000 1010000000000000 -> 1010000110000000
-ddor049 or 10000000 1100000000000000 -> 1100000010000000
-
-ddor090 or 011111111 111101111 -> 111111111
-ddor091 or 101111111 111101111 -> 111111111
-ddor092 or 110111111 111101111 -> 111111111
-ddor093 or 111011111 111101111 -> 111111111
-ddor094 or 111101111 111101111 -> 111101111
-ddor095 or 111110111 111101111 -> 111111111
-ddor096 or 111111011 111101111 -> 111111111
-ddor097 or 111111101 111101111 -> 111111111
-ddor098 or 111111110 111101111 -> 111111111
-
-ddor100 or 111101111 011111111 -> 111111111
-ddor101 or 111101111 101111111 -> 111111111
-ddor102 or 111101111 110111111 -> 111111111
-ddor103 or 111101111 111011111 -> 111111111
-ddor104 or 111101111 111101111 -> 111101111
-ddor105 or 111101111 111110111 -> 111111111
-ddor106 or 111101111 111111011 -> 111111111
-ddor107 or 111101111 111111101 -> 111111111
-ddor108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-ddor220 or 111111112 111111111 -> NaN Invalid_operation
-ddor221 or 333333333 333333333 -> NaN Invalid_operation
-ddor222 or 555555555 555555555 -> NaN Invalid_operation
-ddor223 or 777777777 777777777 -> NaN Invalid_operation
-ddor224 or 999999999 999999999 -> NaN Invalid_operation
-ddor225 or 222222222 999999999 -> NaN Invalid_operation
-ddor226 or 444444444 999999999 -> NaN Invalid_operation
-ddor227 or 666666666 999999999 -> NaN Invalid_operation
-ddor228 or 888888888 999999999 -> NaN Invalid_operation
-ddor229 or 999999999 222222222 -> NaN Invalid_operation
-ddor230 or 999999999 444444444 -> NaN Invalid_operation
-ddor231 or 999999999 666666666 -> NaN Invalid_operation
-ddor232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddor240 or 567468689 -934981942 -> NaN Invalid_operation
-ddor241 or 567367689 934981942 -> NaN Invalid_operation
-ddor242 or -631917772 -706014634 -> NaN Invalid_operation
-ddor243 or -756253257 138579234 -> NaN Invalid_operation
-ddor244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddor250 or 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor251 or 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor252 or 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor253 or 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddor254 or 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor255 or 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor256 or 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor257 or 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddor258 or 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddor259 or 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddor260 or 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddor261 or 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddor262 or 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddor263 or 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddor264 or 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddor265 or 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddor270 or 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddor271 or 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddor272 or 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddor273 or 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddor274 or 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddor275 or 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddor276 or 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddor277 or 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddor280 or 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddor281 or 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddor282 or 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddor283 or 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddor284 or 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddor285 or 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddor286 or 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddor287 or 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddor288 or 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddor289 or 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddor290 or 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddor291 or 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddor292 or 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddor293 or 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddor294 or 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddor295 or 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddor296 or -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddor297 or -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddor298 or 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddor299 or 1000000001000000 0000000011000100 -> 1000000011000100
-
--- Nmax, Nmin, Ntiny-like
-ddor331 or 2 9.99999999E+199 -> NaN Invalid_operation
-ddor332 or 3 1E-199 -> NaN Invalid_operation
-ddor333 or 4 1.00000000E-199 -> NaN Invalid_operation
-ddor334 or 5 1E-100 -> NaN Invalid_operation
-ddor335 or 6 -1E-100 -> NaN Invalid_operation
-ddor336 or 7 -1.00000000E-199 -> NaN Invalid_operation
-ddor337 or 8 -1E-199 -> NaN Invalid_operation
-ddor338 or 9 -9.99999999E+199 -> NaN Invalid_operation
-ddor341 or 9.99999999E+299 -18 -> NaN Invalid_operation
-ddor342 or 1E-299 01 -> NaN Invalid_operation
-ddor343 or 1.00000000E-299 -18 -> NaN Invalid_operation
-ddor344 or 1E-100 18 -> NaN Invalid_operation
-ddor345 or -1E-100 -10 -> NaN Invalid_operation
-ddor346 or -1.00000000E-299 18 -> NaN Invalid_operation
-ddor347 or -1E-299 10 -> NaN Invalid_operation
-ddor348 or -9.99999999E+299 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddor361 or 1.0 1 -> NaN Invalid_operation
-ddor362 or 1E+1 1 -> NaN Invalid_operation
-ddor363 or 0.0 1 -> NaN Invalid_operation
-ddor364 or 0E+1 1 -> NaN Invalid_operation
-ddor365 or 9.9 1 -> NaN Invalid_operation
-ddor366 or 9E+1 1 -> NaN Invalid_operation
-ddor371 or 0 1.0 -> NaN Invalid_operation
-ddor372 or 0 1E+1 -> NaN Invalid_operation
-ddor373 or 0 0.0 -> NaN Invalid_operation
-ddor374 or 0 0E+1 -> NaN Invalid_operation
-ddor375 or 0 9.9 -> NaN Invalid_operation
-ddor376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddor780 or -Inf -Inf -> NaN Invalid_operation
-ddor781 or -Inf -1000 -> NaN Invalid_operation
-ddor782 or -Inf -1 -> NaN Invalid_operation
-ddor783 or -Inf -0 -> NaN Invalid_operation
-ddor784 or -Inf 0 -> NaN Invalid_operation
-ddor785 or -Inf 1 -> NaN Invalid_operation
-ddor786 or -Inf 1000 -> NaN Invalid_operation
-ddor787 or -1000 -Inf -> NaN Invalid_operation
-ddor788 or -Inf -Inf -> NaN Invalid_operation
-ddor789 or -1 -Inf -> NaN Invalid_operation
-ddor790 or -0 -Inf -> NaN Invalid_operation
-ddor791 or 0 -Inf -> NaN Invalid_operation
-ddor792 or 1 -Inf -> NaN Invalid_operation
-ddor793 or 1000 -Inf -> NaN Invalid_operation
-ddor794 or Inf -Inf -> NaN Invalid_operation
-
-ddor800 or Inf -Inf -> NaN Invalid_operation
-ddor801 or Inf -1000 -> NaN Invalid_operation
-ddor802 or Inf -1 -> NaN Invalid_operation
-ddor803 or Inf -0 -> NaN Invalid_operation
-ddor804 or Inf 0 -> NaN Invalid_operation
-ddor805 or Inf 1 -> NaN Invalid_operation
-ddor806 or Inf 1000 -> NaN Invalid_operation
-ddor807 or Inf Inf -> NaN Invalid_operation
-ddor808 or -1000 Inf -> NaN Invalid_operation
-ddor809 or -Inf Inf -> NaN Invalid_operation
-ddor810 or -1 Inf -> NaN Invalid_operation
-ddor811 or -0 Inf -> NaN Invalid_operation
-ddor812 or 0 Inf -> NaN Invalid_operation
-ddor813 or 1 Inf -> NaN Invalid_operation
-ddor814 or 1000 Inf -> NaN Invalid_operation
-ddor815 or Inf Inf -> NaN Invalid_operation
-
-ddor821 or NaN -Inf -> NaN Invalid_operation
-ddor822 or NaN -1000 -> NaN Invalid_operation
-ddor823 or NaN -1 -> NaN Invalid_operation
-ddor824 or NaN -0 -> NaN Invalid_operation
-ddor825 or NaN 0 -> NaN Invalid_operation
-ddor826 or NaN 1 -> NaN Invalid_operation
-ddor827 or NaN 1000 -> NaN Invalid_operation
-ddor828 or NaN Inf -> NaN Invalid_operation
-ddor829 or NaN NaN -> NaN Invalid_operation
-ddor830 or -Inf NaN -> NaN Invalid_operation
-ddor831 or -1000 NaN -> NaN Invalid_operation
-ddor832 or -1 NaN -> NaN Invalid_operation
-ddor833 or -0 NaN -> NaN Invalid_operation
-ddor834 or 0 NaN -> NaN Invalid_operation
-ddor835 or 1 NaN -> NaN Invalid_operation
-ddor836 or 1000 NaN -> NaN Invalid_operation
-ddor837 or Inf NaN -> NaN Invalid_operation
-
-ddor841 or sNaN -Inf -> NaN Invalid_operation
-ddor842 or sNaN -1000 -> NaN Invalid_operation
-ddor843 or sNaN -1 -> NaN Invalid_operation
-ddor844 or sNaN -0 -> NaN Invalid_operation
-ddor845 or sNaN 0 -> NaN Invalid_operation
-ddor846 or sNaN 1 -> NaN Invalid_operation
-ddor847 or sNaN 1000 -> NaN Invalid_operation
-ddor848 or sNaN NaN -> NaN Invalid_operation
-ddor849 or sNaN sNaN -> NaN Invalid_operation
-ddor850 or NaN sNaN -> NaN Invalid_operation
-ddor851 or -Inf sNaN -> NaN Invalid_operation
-ddor852 or -1000 sNaN -> NaN Invalid_operation
-ddor853 or -1 sNaN -> NaN Invalid_operation
-ddor854 or -0 sNaN -> NaN Invalid_operation
-ddor855 or 0 sNaN -> NaN Invalid_operation
-ddor856 or 1 sNaN -> NaN Invalid_operation
-ddor857 or 1000 sNaN -> NaN Invalid_operation
-ddor858 or Inf sNaN -> NaN Invalid_operation
-ddor859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddor861 or NaN1 -Inf -> NaN Invalid_operation
-ddor862 or +NaN2 -1000 -> NaN Invalid_operation
-ddor863 or NaN3 1000 -> NaN Invalid_operation
-ddor864 or NaN4 Inf -> NaN Invalid_operation
-ddor865 or NaN5 +NaN6 -> NaN Invalid_operation
-ddor866 or -Inf NaN7 -> NaN Invalid_operation
-ddor867 or -1000 NaN8 -> NaN Invalid_operation
-ddor868 or 1000 NaN9 -> NaN Invalid_operation
-ddor869 or Inf +NaN10 -> NaN Invalid_operation
-ddor871 or sNaN11 -Inf -> NaN Invalid_operation
-ddor872 or sNaN12 -1000 -> NaN Invalid_operation
-ddor873 or sNaN13 1000 -> NaN Invalid_operation
-ddor874 or sNaN14 NaN17 -> NaN Invalid_operation
-ddor875 or sNaN15 sNaN18 -> NaN Invalid_operation
-ddor876 or NaN16 sNaN19 -> NaN Invalid_operation
-ddor877 or -Inf +sNaN20 -> NaN Invalid_operation
-ddor878 or -1000 sNaN21 -> NaN Invalid_operation
-ddor879 or 1000 sNaN22 -> NaN Invalid_operation
-ddor880 or Inf sNaN23 -> NaN Invalid_operation
-ddor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-ddor882 or -NaN26 NaN28 -> NaN Invalid_operation
-ddor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-ddor884 or 1000 -NaN30 -> NaN Invalid_operation
-ddor885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddOr.decTest -- digitwise logical OR for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddor001 or 0 0 -> 0
+ddor002 or 0 1 -> 1
+ddor003 or 1 0 -> 1
+ddor004 or 1 1 -> 1
+ddor005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+ddor006 or 0000000000000000 0000000000000000 -> 0
+ddor007 or 0000000000000000 1000000000000000 -> 1000000000000000
+ddor008 or 1000000000000000 0000000000000000 -> 1000000000000000
+ddor009 or 1000000000000000 1000000000000000 -> 1000000000000000
+ddor010 or 0000000000000000 0000000000000000 -> 0
+ddor011 or 0000000000000000 0100000000000000 -> 100000000000000
+ddor012 or 0100000000000000 0000000000000000 -> 100000000000000
+ddor013 or 0100000000000000 0100000000000000 -> 100000000000000
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddor020 or 1111111111111111 1111111111111111 -> 1111111111111111
+ddor021 or 111111111111111 111111111111111 -> 111111111111111
+ddor022 or 11111111111111 11111111111111 -> 11111111111111
+ddor023 or 1111111111111 1111111111111 -> 1111111111111
+ddor024 or 111111111111 111111111111 -> 111111111111
+ddor025 or 11111111111 11111111111 -> 11111111111
+ddor026 or 1111111111 1111111111 -> 1111111111
+ddor027 or 111111111 111111111 -> 111111111
+ddor028 or 11111111 11111111 -> 11111111
+ddor029 or 1111111 1111111 -> 1111111
+ddor030 or 111111 111111 -> 111111
+ddor031 or 11111 11111 -> 11111
+ddor032 or 1111 1111 -> 1111
+ddor033 or 111 111 -> 111
+ddor034 or 11 11 -> 11
+ddor035 or 1 1 -> 1
+ddor036 or 0 0 -> 0
+
+ddor042 or 111111110000000 1111111110000000 -> 1111111110000000
+ddor043 or 11111110000000 1000000100000000 -> 1011111110000000
+ddor044 or 1111110000000 1000001000000000 -> 1001111110000000
+ddor045 or 111110000000 1000010000000000 -> 1000111110000000
+ddor046 or 11110000000 1000100000000000 -> 1000111110000000
+ddor047 or 1110000000 1001000000000000 -> 1001001110000000
+ddor048 or 110000000 1010000000000000 -> 1010000110000000
+ddor049 or 10000000 1100000000000000 -> 1100000010000000
+
+ddor090 or 011111111 111101111 -> 111111111
+ddor091 or 101111111 111101111 -> 111111111
+ddor092 or 110111111 111101111 -> 111111111
+ddor093 or 111011111 111101111 -> 111111111
+ddor094 or 111101111 111101111 -> 111101111
+ddor095 or 111110111 111101111 -> 111111111
+ddor096 or 111111011 111101111 -> 111111111
+ddor097 or 111111101 111101111 -> 111111111
+ddor098 or 111111110 111101111 -> 111111111
+
+ddor100 or 111101111 011111111 -> 111111111
+ddor101 or 111101111 101111111 -> 111111111
+ddor102 or 111101111 110111111 -> 111111111
+ddor103 or 111101111 111011111 -> 111111111
+ddor104 or 111101111 111101111 -> 111101111
+ddor105 or 111101111 111110111 -> 111111111
+ddor106 or 111101111 111111011 -> 111111111
+ddor107 or 111101111 111111101 -> 111111111
+ddor108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+ddor220 or 111111112 111111111 -> NaN Invalid_operation
+ddor221 or 333333333 333333333 -> NaN Invalid_operation
+ddor222 or 555555555 555555555 -> NaN Invalid_operation
+ddor223 or 777777777 777777777 -> NaN Invalid_operation
+ddor224 or 999999999 999999999 -> NaN Invalid_operation
+ddor225 or 222222222 999999999 -> NaN Invalid_operation
+ddor226 or 444444444 999999999 -> NaN Invalid_operation
+ddor227 or 666666666 999999999 -> NaN Invalid_operation
+ddor228 or 888888888 999999999 -> NaN Invalid_operation
+ddor229 or 999999999 222222222 -> NaN Invalid_operation
+ddor230 or 999999999 444444444 -> NaN Invalid_operation
+ddor231 or 999999999 666666666 -> NaN Invalid_operation
+ddor232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddor240 or 567468689 -934981942 -> NaN Invalid_operation
+ddor241 or 567367689 934981942 -> NaN Invalid_operation
+ddor242 or -631917772 -706014634 -> NaN Invalid_operation
+ddor243 or -756253257 138579234 -> NaN Invalid_operation
+ddor244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddor250 or 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor251 or 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor252 or 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor253 or 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddor254 or 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor255 or 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor256 or 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor257 or 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddor258 or 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddor259 or 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddor260 or 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddor261 or 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddor262 or 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddor263 or 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddor264 or 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddor265 or 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddor270 or 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddor271 or 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddor272 or 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddor273 or 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddor274 or 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddor275 or 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddor276 or 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddor277 or 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddor280 or 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddor281 or 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddor282 or 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddor283 or 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddor284 or 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddor285 or 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddor286 or 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddor287 or 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddor288 or 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddor289 or 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddor290 or 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddor291 or 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddor292 or 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddor293 or 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddor294 or 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddor295 or 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddor296 or -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddor297 or -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddor298 or 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddor299 or 1000000001000000 0000000011000100 -> 1000000011000100
+
+-- Nmax, Nmin, Ntiny-like
+ddor331 or 2 9.99999999E+199 -> NaN Invalid_operation
+ddor332 or 3 1E-199 -> NaN Invalid_operation
+ddor333 or 4 1.00000000E-199 -> NaN Invalid_operation
+ddor334 or 5 1E-100 -> NaN Invalid_operation
+ddor335 or 6 -1E-100 -> NaN Invalid_operation
+ddor336 or 7 -1.00000000E-199 -> NaN Invalid_operation
+ddor337 or 8 -1E-199 -> NaN Invalid_operation
+ddor338 or 9 -9.99999999E+199 -> NaN Invalid_operation
+ddor341 or 9.99999999E+299 -18 -> NaN Invalid_operation
+ddor342 or 1E-299 01 -> NaN Invalid_operation
+ddor343 or 1.00000000E-299 -18 -> NaN Invalid_operation
+ddor344 or 1E-100 18 -> NaN Invalid_operation
+ddor345 or -1E-100 -10 -> NaN Invalid_operation
+ddor346 or -1.00000000E-299 18 -> NaN Invalid_operation
+ddor347 or -1E-299 10 -> NaN Invalid_operation
+ddor348 or -9.99999999E+299 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddor361 or 1.0 1 -> NaN Invalid_operation
+ddor362 or 1E+1 1 -> NaN Invalid_operation
+ddor363 or 0.0 1 -> NaN Invalid_operation
+ddor364 or 0E+1 1 -> NaN Invalid_operation
+ddor365 or 9.9 1 -> NaN Invalid_operation
+ddor366 or 9E+1 1 -> NaN Invalid_operation
+ddor371 or 0 1.0 -> NaN Invalid_operation
+ddor372 or 0 1E+1 -> NaN Invalid_operation
+ddor373 or 0 0.0 -> NaN Invalid_operation
+ddor374 or 0 0E+1 -> NaN Invalid_operation
+ddor375 or 0 9.9 -> NaN Invalid_operation
+ddor376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddor780 or -Inf -Inf -> NaN Invalid_operation
+ddor781 or -Inf -1000 -> NaN Invalid_operation
+ddor782 or -Inf -1 -> NaN Invalid_operation
+ddor783 or -Inf -0 -> NaN Invalid_operation
+ddor784 or -Inf 0 -> NaN Invalid_operation
+ddor785 or -Inf 1 -> NaN Invalid_operation
+ddor786 or -Inf 1000 -> NaN Invalid_operation
+ddor787 or -1000 -Inf -> NaN Invalid_operation
+ddor788 or -Inf -Inf -> NaN Invalid_operation
+ddor789 or -1 -Inf -> NaN Invalid_operation
+ddor790 or -0 -Inf -> NaN Invalid_operation
+ddor791 or 0 -Inf -> NaN Invalid_operation
+ddor792 or 1 -Inf -> NaN Invalid_operation
+ddor793 or 1000 -Inf -> NaN Invalid_operation
+ddor794 or Inf -Inf -> NaN Invalid_operation
+
+ddor800 or Inf -Inf -> NaN Invalid_operation
+ddor801 or Inf -1000 -> NaN Invalid_operation
+ddor802 or Inf -1 -> NaN Invalid_operation
+ddor803 or Inf -0 -> NaN Invalid_operation
+ddor804 or Inf 0 -> NaN Invalid_operation
+ddor805 or Inf 1 -> NaN Invalid_operation
+ddor806 or Inf 1000 -> NaN Invalid_operation
+ddor807 or Inf Inf -> NaN Invalid_operation
+ddor808 or -1000 Inf -> NaN Invalid_operation
+ddor809 or -Inf Inf -> NaN Invalid_operation
+ddor810 or -1 Inf -> NaN Invalid_operation
+ddor811 or -0 Inf -> NaN Invalid_operation
+ddor812 or 0 Inf -> NaN Invalid_operation
+ddor813 or 1 Inf -> NaN Invalid_operation
+ddor814 or 1000 Inf -> NaN Invalid_operation
+ddor815 or Inf Inf -> NaN Invalid_operation
+
+ddor821 or NaN -Inf -> NaN Invalid_operation
+ddor822 or NaN -1000 -> NaN Invalid_operation
+ddor823 or NaN -1 -> NaN Invalid_operation
+ddor824 or NaN -0 -> NaN Invalid_operation
+ddor825 or NaN 0 -> NaN Invalid_operation
+ddor826 or NaN 1 -> NaN Invalid_operation
+ddor827 or NaN 1000 -> NaN Invalid_operation
+ddor828 or NaN Inf -> NaN Invalid_operation
+ddor829 or NaN NaN -> NaN Invalid_operation
+ddor830 or -Inf NaN -> NaN Invalid_operation
+ddor831 or -1000 NaN -> NaN Invalid_operation
+ddor832 or -1 NaN -> NaN Invalid_operation
+ddor833 or -0 NaN -> NaN Invalid_operation
+ddor834 or 0 NaN -> NaN Invalid_operation
+ddor835 or 1 NaN -> NaN Invalid_operation
+ddor836 or 1000 NaN -> NaN Invalid_operation
+ddor837 or Inf NaN -> NaN Invalid_operation
+
+ddor841 or sNaN -Inf -> NaN Invalid_operation
+ddor842 or sNaN -1000 -> NaN Invalid_operation
+ddor843 or sNaN -1 -> NaN Invalid_operation
+ddor844 or sNaN -0 -> NaN Invalid_operation
+ddor845 or sNaN 0 -> NaN Invalid_operation
+ddor846 or sNaN 1 -> NaN Invalid_operation
+ddor847 or sNaN 1000 -> NaN Invalid_operation
+ddor848 or sNaN NaN -> NaN Invalid_operation
+ddor849 or sNaN sNaN -> NaN Invalid_operation
+ddor850 or NaN sNaN -> NaN Invalid_operation
+ddor851 or -Inf sNaN -> NaN Invalid_operation
+ddor852 or -1000 sNaN -> NaN Invalid_operation
+ddor853 or -1 sNaN -> NaN Invalid_operation
+ddor854 or -0 sNaN -> NaN Invalid_operation
+ddor855 or 0 sNaN -> NaN Invalid_operation
+ddor856 or 1 sNaN -> NaN Invalid_operation
+ddor857 or 1000 sNaN -> NaN Invalid_operation
+ddor858 or Inf sNaN -> NaN Invalid_operation
+ddor859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddor861 or NaN1 -Inf -> NaN Invalid_operation
+ddor862 or +NaN2 -1000 -> NaN Invalid_operation
+ddor863 or NaN3 1000 -> NaN Invalid_operation
+ddor864 or NaN4 Inf -> NaN Invalid_operation
+ddor865 or NaN5 +NaN6 -> NaN Invalid_operation
+ddor866 or -Inf NaN7 -> NaN Invalid_operation
+ddor867 or -1000 NaN8 -> NaN Invalid_operation
+ddor868 or 1000 NaN9 -> NaN Invalid_operation
+ddor869 or Inf +NaN10 -> NaN Invalid_operation
+ddor871 or sNaN11 -Inf -> NaN Invalid_operation
+ddor872 or sNaN12 -1000 -> NaN Invalid_operation
+ddor873 or sNaN13 1000 -> NaN Invalid_operation
+ddor874 or sNaN14 NaN17 -> NaN Invalid_operation
+ddor875 or sNaN15 sNaN18 -> NaN Invalid_operation
+ddor876 or NaN16 sNaN19 -> NaN Invalid_operation
+ddor877 or -Inf +sNaN20 -> NaN Invalid_operation
+ddor878 or -1000 sNaN21 -> NaN Invalid_operation
+ddor879 or 1000 sNaN22 -> NaN Invalid_operation
+ddor880 or Inf sNaN23 -> NaN Invalid_operation
+ddor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+ddor882 or -NaN26 NaN28 -> NaN Invalid_operation
+ddor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+ddor884 or 1000 -NaN30 -> NaN Invalid_operation
+ddor885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddPlus.decTest b/Lib/test/decimaltestdata/ddPlus.decTest
index 17aa08af9f7..5191239bf71 100644
--- a/Lib/test/decimaltestdata/ddPlus.decTest
+++ b/Lib/test/decimaltestdata/ddPlus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- ddPlus.decTest -- decDouble 0+x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddpls001 plus +7.50 -> 7.50
-
--- Infinities
-ddpls011 plus Infinity -> Infinity
-ddpls012 plus -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddpls021 plus NaN -> NaN
-ddpls022 plus -NaN -> -NaN
-ddpls023 plus sNaN -> NaN Invalid_operation
-ddpls024 plus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddpls031 plus NaN13 -> NaN13
-ddpls032 plus -NaN13 -> -NaN13
-ddpls033 plus sNaN13 -> NaN13 Invalid_operation
-ddpls034 plus -sNaN13 -> -NaN13 Invalid_operation
-ddpls035 plus NaN70 -> NaN70
-ddpls036 plus -NaN70 -> -NaN70
-ddpls037 plus sNaN101 -> NaN101 Invalid_operation
-ddpls038 plus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-ddpls101 plus 7 -> 7
-ddpls102 plus -7 -> -7
-ddpls103 plus 75 -> 75
-ddpls104 plus -75 -> -75
-ddpls105 plus 7.50 -> 7.50
-ddpls106 plus -7.50 -> -7.50
-ddpls107 plus 7.500 -> 7.500
-ddpls108 plus -7.500 -> -7.500
-
--- zeros
-ddpls111 plus 0 -> 0
-ddpls112 plus -0 -> 0
-ddpls113 plus 0E+4 -> 0E+4
-ddpls114 plus -0E+4 -> 0E+4
-ddpls115 plus 0.0000 -> 0.0000
-ddpls116 plus -0.0000 -> 0.0000
-ddpls117 plus 0E-141 -> 0E-141
-ddpls118 plus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-ddpls121 plus 2682682682682682 -> 2682682682682682
-ddpls122 plus -2682682682682682 -> -2682682682682682
-ddpls123 plus 1341341341341341 -> 1341341341341341
-ddpls124 plus -1341341341341341 -> -1341341341341341
-
--- Nmax, Nmin, Ntiny
-ddpls131 plus 9.999999999999999E+384 -> 9.999999999999999E+384
-ddpls132 plus 1E-383 -> 1E-383
-ddpls133 plus 1.000000000000000E-383 -> 1.000000000000000E-383
-ddpls134 plus 1E-398 -> 1E-398 Subnormal
-
-ddpls135 plus -1E-398 -> -1E-398 Subnormal
-ddpls136 plus -1.000000000000000E-383 -> -1.000000000000000E-383
-ddpls137 plus -1E-383 -> -1E-383
-ddpls138 plus -9.999999999999999E+384 -> -9.999999999999999E+384
+------------------------------------------------------------------------
+-- ddPlus.decTest -- decDouble 0+x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddpls001 plus +7.50 -> 7.50
+
+-- Infinities
+ddpls011 plus Infinity -> Infinity
+ddpls012 plus -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddpls021 plus NaN -> NaN
+ddpls022 plus -NaN -> -NaN
+ddpls023 plus sNaN -> NaN Invalid_operation
+ddpls024 plus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddpls031 plus NaN13 -> NaN13
+ddpls032 plus -NaN13 -> -NaN13
+ddpls033 plus sNaN13 -> NaN13 Invalid_operation
+ddpls034 plus -sNaN13 -> -NaN13 Invalid_operation
+ddpls035 plus NaN70 -> NaN70
+ddpls036 plus -NaN70 -> -NaN70
+ddpls037 plus sNaN101 -> NaN101 Invalid_operation
+ddpls038 plus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+ddpls101 plus 7 -> 7
+ddpls102 plus -7 -> -7
+ddpls103 plus 75 -> 75
+ddpls104 plus -75 -> -75
+ddpls105 plus 7.50 -> 7.50
+ddpls106 plus -7.50 -> -7.50
+ddpls107 plus 7.500 -> 7.500
+ddpls108 plus -7.500 -> -7.500
+
+-- zeros
+ddpls111 plus 0 -> 0
+ddpls112 plus -0 -> 0
+ddpls113 plus 0E+4 -> 0E+4
+ddpls114 plus -0E+4 -> 0E+4
+ddpls115 plus 0.0000 -> 0.0000
+ddpls116 plus -0.0000 -> 0.0000
+ddpls117 plus 0E-141 -> 0E-141
+ddpls118 plus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+ddpls121 plus 2682682682682682 -> 2682682682682682
+ddpls122 plus -2682682682682682 -> -2682682682682682
+ddpls123 plus 1341341341341341 -> 1341341341341341
+ddpls124 plus -1341341341341341 -> -1341341341341341
+
+-- Nmax, Nmin, Ntiny
+ddpls131 plus 9.999999999999999E+384 -> 9.999999999999999E+384
+ddpls132 plus 1E-383 -> 1E-383
+ddpls133 plus 1.000000000000000E-383 -> 1.000000000000000E-383
+ddpls134 plus 1E-398 -> 1E-398 Subnormal
+
+ddpls135 plus -1E-398 -> -1E-398 Subnormal
+ddpls136 plus -1.000000000000000E-383 -> -1.000000000000000E-383
+ddpls137 plus -1E-383 -> -1E-383
+ddpls138 plus -9.999999999999999E+384 -> -9.999999999999999E+384
diff --git a/Lib/test/decimaltestdata/ddQuantize.decTest b/Lib/test/decimaltestdata/ddQuantize.decTest
index 0d19c9dcec8..91776201694 100644
--- a/Lib/test/decimaltestdata/ddQuantize.decTest
+++ b/Lib/test/decimaltestdata/ddQuantize.decTest
@@ -1,833 +1,833 @@
-------------------------------------------------------------------------
--- ddQuantize.decTest -- decDouble quantize operation --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Most of the tests here assume a "regular pattern", where the
--- sign and coefficient are +1.
--- 2004.03.15 Underflow for quantize is suppressed
--- 2005.06.08 More extensive tests for 'does not fit'
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks
-ddqua001 quantize 0 1e0 -> 0
-ddqua002 quantize 1 1e0 -> 1
-ddqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
-ddqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
-ddqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
-ddqua007 quantize 0.1 1e-1 -> 0.1
-ddqua008 quantize 0.1 1e-2 -> 0.10
-ddqua009 quantize 0.1 1e-3 -> 0.100
-ddqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
-ddqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
-ddqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
-ddqua013 quantize 0.9 1e-1 -> 0.9
-ddqua014 quantize 0.9 1e-2 -> 0.90
-ddqua015 quantize 0.9 1e-3 -> 0.900
--- negatives
-ddqua021 quantize -0 1e0 -> -0
-ddqua022 quantize -1 1e0 -> -1
-ddqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
-ddqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
-ddqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
-ddqua027 quantize -0.1 1e-1 -> -0.1
-ddqua028 quantize -0.1 1e-2 -> -0.10
-ddqua029 quantize -0.1 1e-3 -> -0.100
-ddqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-ddqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-ddqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
-ddqua033 quantize -0.9 1e-1 -> -0.9
-ddqua034 quantize -0.9 1e-2 -> -0.90
-ddqua035 quantize -0.9 1e-3 -> -0.900
-ddqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
-ddqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
-ddqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
-ddqua039 quantize -0.5 1e-1 -> -0.5
-ddqua040 quantize -0.5 1e-2 -> -0.50
-ddqua041 quantize -0.5 1e-3 -> -0.500
-ddqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-ddqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-ddqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
-ddqua045 quantize -0.9 1e-1 -> -0.9
-ddqua046 quantize -0.9 1e-2 -> -0.90
-ddqua047 quantize -0.9 1e-3 -> -0.900
-
--- examples from Specification
-ddqua060 quantize 2.17 0.001 -> 2.170
-ddqua061 quantize 2.17 0.01 -> 2.17
-ddqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
-ddqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
-ddqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
-ddqua065 quantize -Inf Inf -> -Infinity
-ddqua066 quantize 2 Inf -> NaN Invalid_operation
-ddqua067 quantize -0.1 1 -> -0 Inexact Rounded
-ddqua068 quantize -0 1e+5 -> -0E+5
-ddqua069 quantize +123456789012345.6 1e-2 -> NaN Invalid_operation
-ddqua070 quantize -987654335236450.6 1e-2 -> NaN Invalid_operation
-ddqua071 quantize 217 1e-1 -> 217.0
-ddqua072 quantize 217 1e+0 -> 217
-ddqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
-ddqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
-
--- general tests ..
-ddqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
-ddqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
-ddqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
-ddqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
-ddqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
-ddqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
-ddqua095 quantize 1.2345 1e-6 -> 1.234500
-ddqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
-ddqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
-ddqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
-ddqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
-ddqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
-
-ddqua101 quantize -1 1e0 -> -1
-ddqua102 quantize -1 1e-1 -> -1.0
-ddqua103 quantize -1 1e-2 -> -1.00
-ddqua104 quantize 0 1e0 -> 0
-ddqua105 quantize 0 1e-1 -> 0.0
-ddqua106 quantize 0 1e-2 -> 0.00
-ddqua107 quantize 0.00 1e0 -> 0
-ddqua108 quantize 0 1e+1 -> 0E+1
-ddqua109 quantize 0 1e+2 -> 0E+2
-ddqua110 quantize +1 1e0 -> 1
-ddqua111 quantize +1 1e-1 -> 1.0
-ddqua112 quantize +1 1e-2 -> 1.00
-
-ddqua120 quantize 1.04 1e-3 -> 1.040
-ddqua121 quantize 1.04 1e-2 -> 1.04
-ddqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
-ddqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
-ddqua124 quantize 1.05 1e-3 -> 1.050
-ddqua125 quantize 1.05 1e-2 -> 1.05
-ddqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
-ddqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
-ddqua132 quantize 1.06 1e-3 -> 1.060
-ddqua133 quantize 1.06 1e-2 -> 1.06
-ddqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
-ddqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
-
-ddqua140 quantize -10 1e-2 -> -10.00
-ddqua141 quantize +1 1e-2 -> 1.00
-ddqua142 quantize +10 1e-2 -> 10.00
-ddqua143 quantize 1E+17 1e-2 -> NaN Invalid_operation
-ddqua144 quantize 1E-17 1e-2 -> 0.00 Inexact Rounded
-ddqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
-ddqua146 quantize 1E-2 1e-2 -> 0.01
-ddqua147 quantize 1E-1 1e-2 -> 0.10
-ddqua148 quantize 0E-17 1e-2 -> 0.00
-
-ddqua150 quantize 1.0600 1e-5 -> 1.06000
-ddqua151 quantize 1.0600 1e-4 -> 1.0600
-ddqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
-ddqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
-ddqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
-ddqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
-
--- a couple where rounding was different in base tests
-rounding: half_up
-ddqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
-ddqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
-ddqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
-rounding: half_even
-
--- base tests with non-1 coefficients
-ddqua161 quantize 0 -9e0 -> 0
-ddqua162 quantize 1 -7e0 -> 1
-ddqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
-ddqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
-ddqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
-ddqua167 quantize 0.1 3e-1 -> 0.1
-ddqua168 quantize 0.1 44e-2 -> 0.10
-ddqua169 quantize 0.1 555e-3 -> 0.100
-ddqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
-ddqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
-ddqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
-ddqua173 quantize 0.9 -9e-1 -> 0.9
-ddqua174 quantize 0.9 0e-2 -> 0.90
-ddqua175 quantize 0.9 1.1e-3 -> 0.9000
--- negatives
-ddqua181 quantize -0 1.1e0 -> -0.0
-ddqua182 quantize -1 -1e0 -> -1
-ddqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
-ddqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
-ddqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
-ddqua187 quantize -0.1 -91e-1 -> -0.1
-ddqua188 quantize -0.1 -.1e-2 -> -0.100
-ddqua189 quantize -0.1 -1e-3 -> -0.100
-ddqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
-ddqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
-ddqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
-ddqua193 quantize -0.9 100e-1 -> -0.9
-ddqua194 quantize -0.9 999e-2 -> -0.90
-
--- +ve exponents ..
-ddqua201 quantize -1 1e+0 -> -1
-ddqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
-ddqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
-ddqua204 quantize 0 1e+0 -> 0
-ddqua205 quantize 0 1e+1 -> 0E+1
-ddqua206 quantize 0 1e+2 -> 0E+2
-ddqua207 quantize +1 1e+0 -> 1
-ddqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-ddqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
-ddqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
-ddqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
-ddqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
-ddqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-ddqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-ddqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-ddqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
-ddqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-ddqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-ddqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-ddqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
-ddqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
-ddqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
-ddqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
-ddqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
-
-ddqua240 quantize -10 1e+1 -> -1E+1 Rounded
-ddqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-ddqua242 quantize +10 1e+1 -> 1E+1 Rounded
-ddqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
-ddqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
-ddqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
-ddqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
-ddqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
-ddqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
-ddqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
-ddqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
-ddqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
--- next one tries to add 9 zeros
-ddqua252 quantize 1E+17 1e+1 -> NaN Invalid_operation
-ddqua253 quantize 1E-17 1e+1 -> 0E+1 Inexact Rounded
-ddqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
-ddqua255 quantize 0E-17 1e+1 -> 0E+1
-ddqua256 quantize -0E-17 1e+1 -> -0E+1
-ddqua257 quantize -0E-1 1e+1 -> -0E+1
-ddqua258 quantize -0 1e+1 -> -0E+1
-ddqua259 quantize -0E+1 1e+1 -> -0E+1
-
-ddqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
-ddqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-ddqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
-ddqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
-ddqua264 quantize 1E+2 1e+2 -> 1E+2
-ddqua265 quantize 1E+3 1e+2 -> 1.0E+3
-ddqua266 quantize 1E+4 1e+2 -> 1.00E+4
-ddqua267 quantize 1E+5 1e+2 -> 1.000E+5
-ddqua268 quantize 1E+6 1e+2 -> 1.0000E+6
-ddqua269 quantize 1E+7 1e+2 -> 1.00000E+7
-ddqua270 quantize 1E+8 1e+2 -> 1.000000E+8
-ddqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
-ddqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
-ddqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
-ddqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
-ddqua275 quantize 0E-10 1e+2 -> 0E+2
-
-ddqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
-ddqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
-ddqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
-ddqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
-ddqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
-ddqua285 quantize 1E+3 1e+3 -> 1E+3
-ddqua286 quantize 1E+4 1e+3 -> 1.0E+4
-ddqua287 quantize 1E+5 1e+3 -> 1.00E+5
-ddqua288 quantize 1E+6 1e+3 -> 1.000E+6
-ddqua289 quantize 1E+7 1e+3 -> 1.0000E+7
-ddqua290 quantize 1E+8 1e+3 -> 1.00000E+8
-ddqua291 quantize 1E+9 1e+3 -> 1.000000E+9
-ddqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
-ddqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
-ddqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
-ddqua295 quantize 0E-10 1e+3 -> 0E+3
-
--- round up from below [sign wrong in JIT compiler once]
-ddqua300 quantize 0.0078 1e-5 -> 0.00780
-ddqua301 quantize 0.0078 1e-4 -> 0.0078
-ddqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
-ddqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
-ddqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
-ddqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
-ddqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
-ddqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua310 quantize -0.0078 1e-5 -> -0.00780
-ddqua311 quantize -0.0078 1e-4 -> -0.0078
-ddqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
-ddqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
-ddqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
-ddqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
-ddqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
-ddqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua320 quantize 0.078 1e-5 -> 0.07800
-ddqua321 quantize 0.078 1e-4 -> 0.0780
-ddqua322 quantize 0.078 1e-3 -> 0.078
-ddqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
-ddqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
-ddqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
-ddqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
-ddqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua330 quantize -0.078 1e-5 -> -0.07800
-ddqua331 quantize -0.078 1e-4 -> -0.0780
-ddqua332 quantize -0.078 1e-3 -> -0.078
-ddqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
-ddqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
-ddqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
-ddqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
-ddqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua340 quantize 0.78 1e-5 -> 0.78000
-ddqua341 quantize 0.78 1e-4 -> 0.7800
-ddqua342 quantize 0.78 1e-3 -> 0.780
-ddqua343 quantize 0.78 1e-2 -> 0.78
-ddqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
-ddqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
-ddqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
-ddqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
-
-ddqua350 quantize -0.78 1e-5 -> -0.78000
-ddqua351 quantize -0.78 1e-4 -> -0.7800
-ddqua352 quantize -0.78 1e-3 -> -0.780
-ddqua353 quantize -0.78 1e-2 -> -0.78
-ddqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
-ddqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
-ddqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
-ddqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
-
-ddqua360 quantize 7.8 1e-5 -> 7.80000
-ddqua361 quantize 7.8 1e-4 -> 7.8000
-ddqua362 quantize 7.8 1e-3 -> 7.800
-ddqua363 quantize 7.8 1e-2 -> 7.80
-ddqua364 quantize 7.8 1e-1 -> 7.8
-ddqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
-ddqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
-ddqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
-ddqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
-
-ddqua370 quantize -7.8 1e-5 -> -7.80000
-ddqua371 quantize -7.8 1e-4 -> -7.8000
-ddqua372 quantize -7.8 1e-3 -> -7.800
-ddqua373 quantize -7.8 1e-2 -> -7.80
-ddqua374 quantize -7.8 1e-1 -> -7.8
-ddqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
-ddqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
-ddqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
-ddqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
-
--- some individuals
-ddqua380 quantize 1234567352364.506 1e-2 -> 1234567352364.51 Inexact Rounded
-ddqua381 quantize 12345673523645.06 1e-2 -> 12345673523645.06
-ddqua382 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
-ddqua383 quantize 1234567352364506 1e-2 -> NaN Invalid_operation
-ddqua384 quantize -1234567352364.506 1e-2 -> -1234567352364.51 Inexact Rounded
-ddqua385 quantize -12345673523645.06 1e-2 -> -12345673523645.06
-ddqua386 quantize -123456735236450.6 1e-2 -> NaN Invalid_operation
-ddqua387 quantize -1234567352364506 1e-2 -> NaN Invalid_operation
-
-rounding: down
-ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
--- ? should that one instead have been:
--- ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
-rounding: half_up
-
--- and a few more from e-mail discussions
-ddqua391 quantize 12345678912.34567 1e-3 -> 12345678912.346 Inexact Rounded
-ddqua392 quantize 123456789123.4567 1e-3 -> 123456789123.457 Inexact Rounded
-ddqua393 quantize 1234567891234.567 1e-3 -> 1234567891234.567
-ddqua394 quantize 12345678912345.67 1e-3 -> NaN Invalid_operation
-ddqua395 quantize 123456789123456.7 1e-3 -> NaN Invalid_operation
-ddqua396 quantize 1234567891234567. 1e-3 -> NaN Invalid_operation
-
--- some 9999 round-up cases
-ddqua400 quantize 9.999 1e-5 -> 9.99900
-ddqua401 quantize 9.999 1e-4 -> 9.9990
-ddqua402 quantize 9.999 1e-3 -> 9.999
-ddqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
-ddqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
-ddqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
-ddqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
-ddqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
-
-ddqua410 quantize 0.999 1e-5 -> 0.99900
-ddqua411 quantize 0.999 1e-4 -> 0.9990
-ddqua412 quantize 0.999 1e-3 -> 0.999
-ddqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
-ddqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
-ddqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
-ddqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua420 quantize 0.0999 1e-5 -> 0.09990
-ddqua421 quantize 0.0999 1e-4 -> 0.0999
-ddqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
-ddqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
-ddqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
-ddqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
-ddqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua430 quantize 0.00999 1e-5 -> 0.00999
-ddqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
-ddqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
-ddqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
-ddqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
-ddqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
-ddqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
-ddqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
-ddqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
-ddqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
-ddqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
-ddqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
-ddqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
-
-ddqua1001 quantize 0.000 0.001 -> 0.000
-ddqua1002 quantize 0.001 0.001 -> 0.001
-ddqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
-ddqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
-ddqua1005 quantize 0.501 0.001 -> 0.501
-ddqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
-ddqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
-ddqua1008 quantize 0.999 0.001 -> 0.999
-
-ddqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-ddqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-ddqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-ddqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-ddqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-ddqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
--- a potential double-round
-ddqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-ddqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
-ddqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-ddqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-ddqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-ddqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-ddqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-ddqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
-ddqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-ddqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
--- Zeros
-ddqua500 quantize 0 1e1 -> 0E+1
-ddqua501 quantize 0 1e0 -> 0
-ddqua502 quantize 0 1e-1 -> 0.0
-ddqua503 quantize 0.0 1e-1 -> 0.0
-ddqua504 quantize 0.0 1e0 -> 0
-ddqua505 quantize 0.0 1e+1 -> 0E+1
-ddqua506 quantize 0E+1 1e-1 -> 0.0
-ddqua507 quantize 0E+1 1e0 -> 0
-ddqua508 quantize 0E+1 1e+1 -> 0E+1
-ddqua509 quantize -0 1e1 -> -0E+1
-ddqua510 quantize -0 1e0 -> -0
-ddqua511 quantize -0 1e-1 -> -0.0
-ddqua512 quantize -0.0 1e-1 -> -0.0
-ddqua513 quantize -0.0 1e0 -> -0
-ddqua514 quantize -0.0 1e+1 -> -0E+1
-ddqua515 quantize -0E+1 1e-1 -> -0.0
-ddqua516 quantize -0E+1 1e0 -> -0
-ddqua517 quantize -0E+1 1e+1 -> -0E+1
-
--- Suspicious RHS values
-ddqua520 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-ddqua521 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
-ddqua522 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-ddqua523 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
--- next four are "won't fit" overfl
-ddqua526 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua527 quantize 123.456 1e-299 -> NaN Invalid_operation
-ddqua528 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua529 quantize 123.456 1e-299 -> NaN Invalid_operation
-
-ddqua532 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
-ddqua533 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
-ddqua534 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
-ddqua537 quantize 0 1e-299 -> 0E-299
--- next two are "won't fit" overflows
-ddqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
-ddqua539 quantize 1.234 1e-300 -> NaN Invalid_operation
--- [more below]
-
--- Specials
-ddqua580 quantize Inf -Inf -> Infinity
-ddqua581 quantize Inf 1e-299 -> NaN Invalid_operation
-ddqua582 quantize Inf 1e-1 -> NaN Invalid_operation
-ddqua583 quantize Inf 1e0 -> NaN Invalid_operation
-ddqua584 quantize Inf 1e1 -> NaN Invalid_operation
-ddqua585 quantize Inf 1e299 -> NaN Invalid_operation
-ddqua586 quantize Inf Inf -> Infinity
-ddqua587 quantize -1000 Inf -> NaN Invalid_operation
-ddqua588 quantize -Inf Inf -> -Infinity
-ddqua589 quantize -1 Inf -> NaN Invalid_operation
-ddqua590 quantize 0 Inf -> NaN Invalid_operation
-ddqua591 quantize 1 Inf -> NaN Invalid_operation
-ddqua592 quantize 1000 Inf -> NaN Invalid_operation
-ddqua593 quantize Inf Inf -> Infinity
-ddqua594 quantize Inf 1e-0 -> NaN Invalid_operation
-ddqua595 quantize -0 Inf -> NaN Invalid_operation
-
-ddqua600 quantize -Inf -Inf -> -Infinity
-ddqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
-ddqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
-ddqua603 quantize -Inf 1e0 -> NaN Invalid_operation
-ddqua604 quantize -Inf 1e1 -> NaN Invalid_operation
-ddqua605 quantize -Inf 1e299 -> NaN Invalid_operation
-ddqua606 quantize -Inf Inf -> -Infinity
-ddqua607 quantize -1000 Inf -> NaN Invalid_operation
-ddqua608 quantize -Inf -Inf -> -Infinity
-ddqua609 quantize -1 -Inf -> NaN Invalid_operation
-ddqua610 quantize 0 -Inf -> NaN Invalid_operation
-ddqua611 quantize 1 -Inf -> NaN Invalid_operation
-ddqua612 quantize 1000 -Inf -> NaN Invalid_operation
-ddqua613 quantize Inf -Inf -> Infinity
-ddqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
-ddqua615 quantize -0 -Inf -> NaN Invalid_operation
-
-ddqua621 quantize NaN -Inf -> NaN
-ddqua622 quantize NaN 1e-299 -> NaN
-ddqua623 quantize NaN 1e-1 -> NaN
-ddqua624 quantize NaN 1e0 -> NaN
-ddqua625 quantize NaN 1e1 -> NaN
-ddqua626 quantize NaN 1e299 -> NaN
-ddqua627 quantize NaN Inf -> NaN
-ddqua628 quantize NaN NaN -> NaN
-ddqua629 quantize -Inf NaN -> NaN
-ddqua630 quantize -1000 NaN -> NaN
-ddqua631 quantize -1 NaN -> NaN
-ddqua632 quantize 0 NaN -> NaN
-ddqua633 quantize 1 NaN -> NaN
-ddqua634 quantize 1000 NaN -> NaN
-ddqua635 quantize Inf NaN -> NaN
-ddqua636 quantize NaN 1e-0 -> NaN
-ddqua637 quantize -0 NaN -> NaN
-
-ddqua641 quantize sNaN -Inf -> NaN Invalid_operation
-ddqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
-ddqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
-ddqua644 quantize sNaN 1e0 -> NaN Invalid_operation
-ddqua645 quantize sNaN 1e1 -> NaN Invalid_operation
-ddqua646 quantize sNaN 1e299 -> NaN Invalid_operation
-ddqua647 quantize sNaN NaN -> NaN Invalid_operation
-ddqua648 quantize sNaN sNaN -> NaN Invalid_operation
-ddqua649 quantize NaN sNaN -> NaN Invalid_operation
-ddqua650 quantize -Inf sNaN -> NaN Invalid_operation
-ddqua651 quantize -1000 sNaN -> NaN Invalid_operation
-ddqua652 quantize -1 sNaN -> NaN Invalid_operation
-ddqua653 quantize 0 sNaN -> NaN Invalid_operation
-ddqua654 quantize 1 sNaN -> NaN Invalid_operation
-ddqua655 quantize 1000 sNaN -> NaN Invalid_operation
-ddqua656 quantize Inf sNaN -> NaN Invalid_operation
-ddqua657 quantize NaN sNaN -> NaN Invalid_operation
-ddqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
-ddqua659 quantize -0 sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddqua661 quantize NaN9 -Inf -> NaN9
-ddqua662 quantize NaN8 919 -> NaN8
-ddqua663 quantize NaN71 Inf -> NaN71
-ddqua664 quantize NaN6 NaN5 -> NaN6
-ddqua665 quantize -Inf NaN4 -> NaN4
-ddqua666 quantize -919 NaN31 -> NaN31
-ddqua667 quantize Inf NaN2 -> NaN2
-
-ddqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
-ddqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
-ddqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
-ddqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
-ddqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
-ddqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
-ddqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
-ddqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
-ddqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
-
-ddqua681 quantize -NaN9 -Inf -> -NaN9
-ddqua682 quantize -NaN8 919 -> -NaN8
-ddqua683 quantize -NaN71 Inf -> -NaN71
-ddqua684 quantize -NaN6 -NaN5 -> -NaN6
-ddqua685 quantize -Inf -NaN4 -> -NaN4
-ddqua686 quantize -919 -NaN31 -> -NaN31
-ddqua687 quantize Inf -NaN2 -> -NaN2
-
-ddqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
-ddqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
-ddqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
-ddqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
-ddqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-ddqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
-ddqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
-ddqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
-ddqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
-
--- subnormals and underflow
-ddqua710 quantize 1.00E-383 1e-383 -> 1E-383 Rounded
-ddqua711 quantize 0.1E-383 2e-384 -> 1E-384 Subnormal
-ddqua712 quantize 0.10E-383 3e-384 -> 1E-384 Subnormal Rounded
-ddqua713 quantize 0.100E-383 4e-384 -> 1E-384 Subnormal Rounded
-ddqua714 quantize 0.01E-383 5e-385 -> 1E-385 Subnormal
--- next is rounded to Emin
-ddqua715 quantize 0.999E-383 1e-383 -> 1E-383 Inexact Rounded
-ddqua716 quantize 0.099E-383 10e-384 -> 1E-384 Inexact Rounded Subnormal
-
-ddqua717 quantize 0.009E-383 1e-385 -> 1E-385 Inexact Rounded Subnormal
-ddqua718 quantize 0.001E-383 1e-385 -> 0E-385 Inexact Rounded
-ddqua719 quantize 0.0009E-383 1e-385 -> 0E-385 Inexact Rounded
-ddqua720 quantize 0.0001E-383 1e-385 -> 0E-385 Inexact Rounded
-
-ddqua730 quantize -1.00E-383 1e-383 -> -1E-383 Rounded
-ddqua731 quantize -0.1E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua732 quantize -0.10E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua733 quantize -0.100E-383 1e-383 -> -0E-383 Rounded Inexact
-ddqua734 quantize -0.01E-383 1e-383 -> -0E-383 Inexact Rounded
--- next is rounded to Emin
-ddqua735 quantize -0.999E-383 90e-383 -> -1E-383 Inexact Rounded
-ddqua736 quantize -0.099E-383 -1e-383 -> -0E-383 Inexact Rounded
-ddqua737 quantize -0.009E-383 -1e-383 -> -0E-383 Inexact Rounded
-ddqua738 quantize -0.001E-383 -0e-383 -> -0E-383 Inexact Rounded
-ddqua739 quantize -0.0001E-383 0e-383 -> -0E-383 Inexact Rounded
-
-ddqua740 quantize -1.00E-383 1e-384 -> -1.0E-383 Rounded
-ddqua741 quantize -0.1E-383 1e-384 -> -1E-384 Subnormal
-ddqua742 quantize -0.10E-383 1e-384 -> -1E-384 Subnormal Rounded
-ddqua743 quantize -0.100E-383 1e-384 -> -1E-384 Subnormal Rounded
-ddqua744 quantize -0.01E-383 1e-384 -> -0E-384 Inexact Rounded
--- next is rounded to Emin
-ddqua745 quantize -0.999E-383 1e-384 -> -1.0E-383 Inexact Rounded
-ddqua746 quantize -0.099E-383 1e-384 -> -1E-384 Inexact Rounded Subnormal
-ddqua747 quantize -0.009E-383 1e-384 -> -0E-384 Inexact Rounded
-ddqua748 quantize -0.001E-383 1e-384 -> -0E-384 Inexact Rounded
-ddqua749 quantize -0.0001E-383 1e-384 -> -0E-384 Inexact Rounded
-
-ddqua750 quantize -1.00E-383 1e-385 -> -1.00E-383
-ddqua751 quantize -0.1E-383 1e-385 -> -1.0E-384 Subnormal
-ddqua752 quantize -0.10E-383 1e-385 -> -1.0E-384 Subnormal
-ddqua753 quantize -0.100E-383 1e-385 -> -1.0E-384 Subnormal Rounded
-ddqua754 quantize -0.01E-383 1e-385 -> -1E-385 Subnormal
--- next is rounded to Emin
-ddqua755 quantize -0.999E-383 1e-385 -> -1.00E-383 Inexact Rounded
-ddqua756 quantize -0.099E-383 1e-385 -> -1.0E-384 Inexact Rounded Subnormal
-ddqua757 quantize -0.009E-383 1e-385 -> -1E-385 Inexact Rounded Subnormal
-ddqua758 quantize -0.001E-383 1e-385 -> -0E-385 Inexact Rounded
-ddqua759 quantize -0.0001E-383 1e-385 -> -0E-385 Inexact Rounded
-
-ddqua760 quantize -1.00E-383 1e-386 -> -1.000E-383
-ddqua761 quantize -0.1E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua762 quantize -0.10E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua763 quantize -0.100E-383 1e-386 -> -1.00E-384 Subnormal
-ddqua764 quantize -0.01E-383 1e-386 -> -1.0E-385 Subnormal
-ddqua765 quantize -0.999E-383 1e-386 -> -9.99E-384 Subnormal
-ddqua766 quantize -0.099E-383 1e-386 -> -9.9E-385 Subnormal
-ddqua767 quantize -0.009E-383 1e-386 -> -9E-386 Subnormal
-ddqua768 quantize -0.001E-383 1e-386 -> -1E-386 Subnormal
-ddqua769 quantize -0.0001E-383 1e-386 -> -0E-386 Inexact Rounded
-
--- More from Fung Lee
-ddqua1021 quantize 8.666666666666000E+384 1.000000000000000E+384 -> 8.666666666666000E+384
-ddqua1022 quantize -8.666666666666000E+384 1.000000000000000E+384 -> -8.666666666666000E+384
-ddqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
-ddqua1029 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
-
-
---ddqua1030 quantize 8.666666666666000E+384 1E+384 -> 9.000000000000000E+384 Rounded Inexact
---ddqua1031 quantize 8.666666666666000E+384 1E+384 -> 8.666666666666000E+384 Rounded
---ddqua1032 quantize 8.666666666666000E+384 1E+383 -> 8.666666666666000E+384 Rounded
---ddqua1033 quantize 8.666666666666000E+384 1E+382 -> 8.666666666666000E+384 Rounded
---ddqua1034 quantize 8.666666666666000E+384 1E+381 -> 8.666666666666000E+384 Rounded
---ddqua1035 quantize 8.666666666666000E+384 1E+380 -> 8.666666666666000E+384 Rounded
-
--- Int and uInt32 edge values for testing conversions
-ddqua1040 quantize -2147483646 0 -> -2147483646
-ddqua1041 quantize -2147483647 0 -> -2147483647
-ddqua1042 quantize -2147483648 0 -> -2147483648
-ddqua1043 quantize -2147483649 0 -> -2147483649
-ddqua1044 quantize 2147483646 0 -> 2147483646
-ddqua1045 quantize 2147483647 0 -> 2147483647
-ddqua1046 quantize 2147483648 0 -> 2147483648
-ddqua1047 quantize 2147483649 0 -> 2147483649
-ddqua1048 quantize 4294967294 0 -> 4294967294
-ddqua1049 quantize 4294967295 0 -> 4294967295
-ddqua1050 quantize 4294967296 0 -> 4294967296
-ddqua1051 quantize 4294967297 0 -> 4294967297
-
--- Rounding swathe
-rounding: half_even
-ddqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_up
-ddqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_down
-ddqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: up
-ddqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-ddqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-ddqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-ddqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: down
-ddqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-ddqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-ddqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-ddqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-ddqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: ceiling
-ddqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-ddqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-ddqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-ddqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-ddqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-ddqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-ddqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-ddqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-ddqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-ddqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: floor
-ddqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
-ddqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-ddqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-ddqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-ddqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-ddqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-ddqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-ddqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-ddqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: 05up
-ddqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
-ddqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
-ddqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
-ddqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
-ddqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
-ddqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
-ddqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
-ddqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
-ddqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
-
-ddqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
-ddqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
-ddqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
-ddqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
-ddqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
-ddqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
-ddqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
-ddqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
-ddqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
-
-ddqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
-ddqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
-ddqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
-ddqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-ddqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-ddqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
-ddqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
-ddqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
-ddqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
-
-ddqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
-ddqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
-ddqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
-ddqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
-ddqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
-ddqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
-ddqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
-ddqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
-ddqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
-
-ddqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
-ddqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
-ddqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
-ddqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
-ddqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
-ddqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
-ddqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
-ddqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
-ddqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
-
-ddqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
-ddqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
-ddqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
-ddqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
-ddqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
-ddqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
-ddqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
-ddqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
-ddqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
-
--- Null tests
-rounding: half_even
-ddqua998 quantize 10 # -> NaN Invalid_operation
-ddqua999 quantize # 1e10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddQuantize.decTest -- decDouble quantize operation --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Most of the tests here assume a "regular pattern", where the
+-- sign and coefficient are +1.
+-- 2004.03.15 Underflow for quantize is suppressed
+-- 2005.06.08 More extensive tests for 'does not fit'
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks
+ddqua001 quantize 0 1e0 -> 0
+ddqua002 quantize 1 1e0 -> 1
+ddqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
+ddqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
+ddqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
+ddqua007 quantize 0.1 1e-1 -> 0.1
+ddqua008 quantize 0.1 1e-2 -> 0.10
+ddqua009 quantize 0.1 1e-3 -> 0.100
+ddqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
+ddqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
+ddqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
+ddqua013 quantize 0.9 1e-1 -> 0.9
+ddqua014 quantize 0.9 1e-2 -> 0.90
+ddqua015 quantize 0.9 1e-3 -> 0.900
+-- negatives
+ddqua021 quantize -0 1e0 -> -0
+ddqua022 quantize -1 1e0 -> -1
+ddqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
+ddqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
+ddqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
+ddqua027 quantize -0.1 1e-1 -> -0.1
+ddqua028 quantize -0.1 1e-2 -> -0.10
+ddqua029 quantize -0.1 1e-3 -> -0.100
+ddqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+ddqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+ddqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
+ddqua033 quantize -0.9 1e-1 -> -0.9
+ddqua034 quantize -0.9 1e-2 -> -0.90
+ddqua035 quantize -0.9 1e-3 -> -0.900
+ddqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
+ddqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
+ddqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
+ddqua039 quantize -0.5 1e-1 -> -0.5
+ddqua040 quantize -0.5 1e-2 -> -0.50
+ddqua041 quantize -0.5 1e-3 -> -0.500
+ddqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+ddqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+ddqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
+ddqua045 quantize -0.9 1e-1 -> -0.9
+ddqua046 quantize -0.9 1e-2 -> -0.90
+ddqua047 quantize -0.9 1e-3 -> -0.900
+
+-- examples from Specification
+ddqua060 quantize 2.17 0.001 -> 2.170
+ddqua061 quantize 2.17 0.01 -> 2.17
+ddqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
+ddqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
+ddqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
+ddqua065 quantize -Inf Inf -> -Infinity
+ddqua066 quantize 2 Inf -> NaN Invalid_operation
+ddqua067 quantize -0.1 1 -> -0 Inexact Rounded
+ddqua068 quantize -0 1e+5 -> -0E+5
+ddqua069 quantize +123456789012345.6 1e-2 -> NaN Invalid_operation
+ddqua070 quantize -987654335236450.6 1e-2 -> NaN Invalid_operation
+ddqua071 quantize 217 1e-1 -> 217.0
+ddqua072 quantize 217 1e+0 -> 217
+ddqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
+ddqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
+
+-- general tests ..
+ddqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
+ddqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
+ddqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
+ddqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
+ddqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
+ddqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
+ddqua095 quantize 1.2345 1e-6 -> 1.234500
+ddqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
+ddqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
+ddqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
+ddqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
+ddqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
+
+ddqua101 quantize -1 1e0 -> -1
+ddqua102 quantize -1 1e-1 -> -1.0
+ddqua103 quantize -1 1e-2 -> -1.00
+ddqua104 quantize 0 1e0 -> 0
+ddqua105 quantize 0 1e-1 -> 0.0
+ddqua106 quantize 0 1e-2 -> 0.00
+ddqua107 quantize 0.00 1e0 -> 0
+ddqua108 quantize 0 1e+1 -> 0E+1
+ddqua109 quantize 0 1e+2 -> 0E+2
+ddqua110 quantize +1 1e0 -> 1
+ddqua111 quantize +1 1e-1 -> 1.0
+ddqua112 quantize +1 1e-2 -> 1.00
+
+ddqua120 quantize 1.04 1e-3 -> 1.040
+ddqua121 quantize 1.04 1e-2 -> 1.04
+ddqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
+ddqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
+ddqua124 quantize 1.05 1e-3 -> 1.050
+ddqua125 quantize 1.05 1e-2 -> 1.05
+ddqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
+ddqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
+ddqua132 quantize 1.06 1e-3 -> 1.060
+ddqua133 quantize 1.06 1e-2 -> 1.06
+ddqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
+ddqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
+
+ddqua140 quantize -10 1e-2 -> -10.00
+ddqua141 quantize +1 1e-2 -> 1.00
+ddqua142 quantize +10 1e-2 -> 10.00
+ddqua143 quantize 1E+17 1e-2 -> NaN Invalid_operation
+ddqua144 quantize 1E-17 1e-2 -> 0.00 Inexact Rounded
+ddqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
+ddqua146 quantize 1E-2 1e-2 -> 0.01
+ddqua147 quantize 1E-1 1e-2 -> 0.10
+ddqua148 quantize 0E-17 1e-2 -> 0.00
+
+ddqua150 quantize 1.0600 1e-5 -> 1.06000
+ddqua151 quantize 1.0600 1e-4 -> 1.0600
+ddqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
+ddqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
+ddqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
+ddqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
+
+-- a couple where rounding was different in base tests
+rounding: half_up
+ddqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
+ddqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
+ddqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
+rounding: half_even
+
+-- base tests with non-1 coefficients
+ddqua161 quantize 0 -9e0 -> 0
+ddqua162 quantize 1 -7e0 -> 1
+ddqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
+ddqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
+ddqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
+ddqua167 quantize 0.1 3e-1 -> 0.1
+ddqua168 quantize 0.1 44e-2 -> 0.10
+ddqua169 quantize 0.1 555e-3 -> 0.100
+ddqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
+ddqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
+ddqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
+ddqua173 quantize 0.9 -9e-1 -> 0.9
+ddqua174 quantize 0.9 0e-2 -> 0.90
+ddqua175 quantize 0.9 1.1e-3 -> 0.9000
+-- negatives
+ddqua181 quantize -0 1.1e0 -> -0.0
+ddqua182 quantize -1 -1e0 -> -1
+ddqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
+ddqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
+ddqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
+ddqua187 quantize -0.1 -91e-1 -> -0.1
+ddqua188 quantize -0.1 -.1e-2 -> -0.100
+ddqua189 quantize -0.1 -1e-3 -> -0.100
+ddqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
+ddqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
+ddqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
+ddqua193 quantize -0.9 100e-1 -> -0.9
+ddqua194 quantize -0.9 999e-2 -> -0.90
+
+-- +ve exponents ..
+ddqua201 quantize -1 1e+0 -> -1
+ddqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
+ddqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
+ddqua204 quantize 0 1e+0 -> 0
+ddqua205 quantize 0 1e+1 -> 0E+1
+ddqua206 quantize 0 1e+2 -> 0E+2
+ddqua207 quantize +1 1e+0 -> 1
+ddqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+ddqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
+ddqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
+ddqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
+ddqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
+ddqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+ddqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+ddqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+ddqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
+ddqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+ddqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+ddqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+ddqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
+ddqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
+ddqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
+ddqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
+ddqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
+
+ddqua240 quantize -10 1e+1 -> -1E+1 Rounded
+ddqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+ddqua242 quantize +10 1e+1 -> 1E+1 Rounded
+ddqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
+ddqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
+ddqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
+ddqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
+ddqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
+ddqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
+ddqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
+ddqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
+ddqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
+-- next one tries to add 9 zeros
+ddqua252 quantize 1E+17 1e+1 -> NaN Invalid_operation
+ddqua253 quantize 1E-17 1e+1 -> 0E+1 Inexact Rounded
+ddqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
+ddqua255 quantize 0E-17 1e+1 -> 0E+1
+ddqua256 quantize -0E-17 1e+1 -> -0E+1
+ddqua257 quantize -0E-1 1e+1 -> -0E+1
+ddqua258 quantize -0 1e+1 -> -0E+1
+ddqua259 quantize -0E+1 1e+1 -> -0E+1
+
+ddqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
+ddqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+ddqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
+ddqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
+ddqua264 quantize 1E+2 1e+2 -> 1E+2
+ddqua265 quantize 1E+3 1e+2 -> 1.0E+3
+ddqua266 quantize 1E+4 1e+2 -> 1.00E+4
+ddqua267 quantize 1E+5 1e+2 -> 1.000E+5
+ddqua268 quantize 1E+6 1e+2 -> 1.0000E+6
+ddqua269 quantize 1E+7 1e+2 -> 1.00000E+7
+ddqua270 quantize 1E+8 1e+2 -> 1.000000E+8
+ddqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
+ddqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
+ddqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
+ddqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
+ddqua275 quantize 0E-10 1e+2 -> 0E+2
+
+ddqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
+ddqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
+ddqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
+ddqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
+ddqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
+ddqua285 quantize 1E+3 1e+3 -> 1E+3
+ddqua286 quantize 1E+4 1e+3 -> 1.0E+4
+ddqua287 quantize 1E+5 1e+3 -> 1.00E+5
+ddqua288 quantize 1E+6 1e+3 -> 1.000E+6
+ddqua289 quantize 1E+7 1e+3 -> 1.0000E+7
+ddqua290 quantize 1E+8 1e+3 -> 1.00000E+8
+ddqua291 quantize 1E+9 1e+3 -> 1.000000E+9
+ddqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
+ddqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
+ddqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
+ddqua295 quantize 0E-10 1e+3 -> 0E+3
+
+-- round up from below [sign wrong in JIT compiler once]
+ddqua300 quantize 0.0078 1e-5 -> 0.00780
+ddqua301 quantize 0.0078 1e-4 -> 0.0078
+ddqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
+ddqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
+ddqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
+ddqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
+ddqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
+ddqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua310 quantize -0.0078 1e-5 -> -0.00780
+ddqua311 quantize -0.0078 1e-4 -> -0.0078
+ddqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
+ddqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
+ddqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
+ddqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
+ddqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
+ddqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua320 quantize 0.078 1e-5 -> 0.07800
+ddqua321 quantize 0.078 1e-4 -> 0.0780
+ddqua322 quantize 0.078 1e-3 -> 0.078
+ddqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
+ddqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
+ddqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
+ddqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
+ddqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua330 quantize -0.078 1e-5 -> -0.07800
+ddqua331 quantize -0.078 1e-4 -> -0.0780
+ddqua332 quantize -0.078 1e-3 -> -0.078
+ddqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
+ddqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
+ddqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
+ddqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
+ddqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua340 quantize 0.78 1e-5 -> 0.78000
+ddqua341 quantize 0.78 1e-4 -> 0.7800
+ddqua342 quantize 0.78 1e-3 -> 0.780
+ddqua343 quantize 0.78 1e-2 -> 0.78
+ddqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
+ddqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
+ddqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
+ddqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
+
+ddqua350 quantize -0.78 1e-5 -> -0.78000
+ddqua351 quantize -0.78 1e-4 -> -0.7800
+ddqua352 quantize -0.78 1e-3 -> -0.780
+ddqua353 quantize -0.78 1e-2 -> -0.78
+ddqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
+ddqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
+ddqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
+ddqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
+
+ddqua360 quantize 7.8 1e-5 -> 7.80000
+ddqua361 quantize 7.8 1e-4 -> 7.8000
+ddqua362 quantize 7.8 1e-3 -> 7.800
+ddqua363 quantize 7.8 1e-2 -> 7.80
+ddqua364 quantize 7.8 1e-1 -> 7.8
+ddqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
+ddqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
+ddqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
+ddqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
+
+ddqua370 quantize -7.8 1e-5 -> -7.80000
+ddqua371 quantize -7.8 1e-4 -> -7.8000
+ddqua372 quantize -7.8 1e-3 -> -7.800
+ddqua373 quantize -7.8 1e-2 -> -7.80
+ddqua374 quantize -7.8 1e-1 -> -7.8
+ddqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
+ddqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
+ddqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
+ddqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
+
+-- some individuals
+ddqua380 quantize 1234567352364.506 1e-2 -> 1234567352364.51 Inexact Rounded
+ddqua381 quantize 12345673523645.06 1e-2 -> 12345673523645.06
+ddqua382 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+ddqua383 quantize 1234567352364506 1e-2 -> NaN Invalid_operation
+ddqua384 quantize -1234567352364.506 1e-2 -> -1234567352364.51 Inexact Rounded
+ddqua385 quantize -12345673523645.06 1e-2 -> -12345673523645.06
+ddqua386 quantize -123456735236450.6 1e-2 -> NaN Invalid_operation
+ddqua387 quantize -1234567352364506 1e-2 -> NaN Invalid_operation
+
+rounding: down
+ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+-- ? should that one instead have been:
+-- ddqua389 quantize 123456735236450.6 1e-2 -> NaN Invalid_operation
+rounding: half_up
+
+-- and a few more from e-mail discussions
+ddqua391 quantize 12345678912.34567 1e-3 -> 12345678912.346 Inexact Rounded
+ddqua392 quantize 123456789123.4567 1e-3 -> 123456789123.457 Inexact Rounded
+ddqua393 quantize 1234567891234.567 1e-3 -> 1234567891234.567
+ddqua394 quantize 12345678912345.67 1e-3 -> NaN Invalid_operation
+ddqua395 quantize 123456789123456.7 1e-3 -> NaN Invalid_operation
+ddqua396 quantize 1234567891234567. 1e-3 -> NaN Invalid_operation
+
+-- some 9999 round-up cases
+ddqua400 quantize 9.999 1e-5 -> 9.99900
+ddqua401 quantize 9.999 1e-4 -> 9.9990
+ddqua402 quantize 9.999 1e-3 -> 9.999
+ddqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
+ddqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
+ddqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
+ddqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
+ddqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
+
+ddqua410 quantize 0.999 1e-5 -> 0.99900
+ddqua411 quantize 0.999 1e-4 -> 0.9990
+ddqua412 quantize 0.999 1e-3 -> 0.999
+ddqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
+ddqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
+ddqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
+ddqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua420 quantize 0.0999 1e-5 -> 0.09990
+ddqua421 quantize 0.0999 1e-4 -> 0.0999
+ddqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
+ddqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
+ddqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
+ddqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
+ddqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua430 quantize 0.00999 1e-5 -> 0.00999
+ddqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
+ddqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
+ddqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
+ddqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
+ddqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
+ddqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
+ddqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
+ddqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
+ddqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
+ddqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
+ddqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
+ddqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
+
+ddqua1001 quantize 0.000 0.001 -> 0.000
+ddqua1002 quantize 0.001 0.001 -> 0.001
+ddqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
+ddqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
+ddqua1005 quantize 0.501 0.001 -> 0.501
+ddqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
+ddqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
+ddqua1008 quantize 0.999 0.001 -> 0.999
+
+ddqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+ddqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+ddqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+ddqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+ddqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+ddqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+-- a potential double-round
+ddqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+ddqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+ddqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+ddqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+ddqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+ddqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+ddqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+ddqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+ddqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+ddqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+-- Zeros
+ddqua500 quantize 0 1e1 -> 0E+1
+ddqua501 quantize 0 1e0 -> 0
+ddqua502 quantize 0 1e-1 -> 0.0
+ddqua503 quantize 0.0 1e-1 -> 0.0
+ddqua504 quantize 0.0 1e0 -> 0
+ddqua505 quantize 0.0 1e+1 -> 0E+1
+ddqua506 quantize 0E+1 1e-1 -> 0.0
+ddqua507 quantize 0E+1 1e0 -> 0
+ddqua508 quantize 0E+1 1e+1 -> 0E+1
+ddqua509 quantize -0 1e1 -> -0E+1
+ddqua510 quantize -0 1e0 -> -0
+ddqua511 quantize -0 1e-1 -> -0.0
+ddqua512 quantize -0.0 1e-1 -> -0.0
+ddqua513 quantize -0.0 1e0 -> -0
+ddqua514 quantize -0.0 1e+1 -> -0E+1
+ddqua515 quantize -0E+1 1e-1 -> -0.0
+ddqua516 quantize -0E+1 1e0 -> -0
+ddqua517 quantize -0E+1 1e+1 -> -0E+1
+
+-- Suspicious RHS values
+ddqua520 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+ddqua521 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+ddqua522 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+ddqua523 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+-- next four are "won't fit" overfl
+ddqua526 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua527 quantize 123.456 1e-299 -> NaN Invalid_operation
+ddqua528 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua529 quantize 123.456 1e-299 -> NaN Invalid_operation
+
+ddqua532 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
+ddqua533 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
+ddqua534 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
+ddqua537 quantize 0 1e-299 -> 0E-299
+-- next two are "won't fit" overflows
+ddqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
+ddqua539 quantize 1.234 1e-300 -> NaN Invalid_operation
+-- [more below]
+
+-- Specials
+ddqua580 quantize Inf -Inf -> Infinity
+ddqua581 quantize Inf 1e-299 -> NaN Invalid_operation
+ddqua582 quantize Inf 1e-1 -> NaN Invalid_operation
+ddqua583 quantize Inf 1e0 -> NaN Invalid_operation
+ddqua584 quantize Inf 1e1 -> NaN Invalid_operation
+ddqua585 quantize Inf 1e299 -> NaN Invalid_operation
+ddqua586 quantize Inf Inf -> Infinity
+ddqua587 quantize -1000 Inf -> NaN Invalid_operation
+ddqua588 quantize -Inf Inf -> -Infinity
+ddqua589 quantize -1 Inf -> NaN Invalid_operation
+ddqua590 quantize 0 Inf -> NaN Invalid_operation
+ddqua591 quantize 1 Inf -> NaN Invalid_operation
+ddqua592 quantize 1000 Inf -> NaN Invalid_operation
+ddqua593 quantize Inf Inf -> Infinity
+ddqua594 quantize Inf 1e-0 -> NaN Invalid_operation
+ddqua595 quantize -0 Inf -> NaN Invalid_operation
+
+ddqua600 quantize -Inf -Inf -> -Infinity
+ddqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
+ddqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
+ddqua603 quantize -Inf 1e0 -> NaN Invalid_operation
+ddqua604 quantize -Inf 1e1 -> NaN Invalid_operation
+ddqua605 quantize -Inf 1e299 -> NaN Invalid_operation
+ddqua606 quantize -Inf Inf -> -Infinity
+ddqua607 quantize -1000 Inf -> NaN Invalid_operation
+ddqua608 quantize -Inf -Inf -> -Infinity
+ddqua609 quantize -1 -Inf -> NaN Invalid_operation
+ddqua610 quantize 0 -Inf -> NaN Invalid_operation
+ddqua611 quantize 1 -Inf -> NaN Invalid_operation
+ddqua612 quantize 1000 -Inf -> NaN Invalid_operation
+ddqua613 quantize Inf -Inf -> Infinity
+ddqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
+ddqua615 quantize -0 -Inf -> NaN Invalid_operation
+
+ddqua621 quantize NaN -Inf -> NaN
+ddqua622 quantize NaN 1e-299 -> NaN
+ddqua623 quantize NaN 1e-1 -> NaN
+ddqua624 quantize NaN 1e0 -> NaN
+ddqua625 quantize NaN 1e1 -> NaN
+ddqua626 quantize NaN 1e299 -> NaN
+ddqua627 quantize NaN Inf -> NaN
+ddqua628 quantize NaN NaN -> NaN
+ddqua629 quantize -Inf NaN -> NaN
+ddqua630 quantize -1000 NaN -> NaN
+ddqua631 quantize -1 NaN -> NaN
+ddqua632 quantize 0 NaN -> NaN
+ddqua633 quantize 1 NaN -> NaN
+ddqua634 quantize 1000 NaN -> NaN
+ddqua635 quantize Inf NaN -> NaN
+ddqua636 quantize NaN 1e-0 -> NaN
+ddqua637 quantize -0 NaN -> NaN
+
+ddqua641 quantize sNaN -Inf -> NaN Invalid_operation
+ddqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
+ddqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
+ddqua644 quantize sNaN 1e0 -> NaN Invalid_operation
+ddqua645 quantize sNaN 1e1 -> NaN Invalid_operation
+ddqua646 quantize sNaN 1e299 -> NaN Invalid_operation
+ddqua647 quantize sNaN NaN -> NaN Invalid_operation
+ddqua648 quantize sNaN sNaN -> NaN Invalid_operation
+ddqua649 quantize NaN sNaN -> NaN Invalid_operation
+ddqua650 quantize -Inf sNaN -> NaN Invalid_operation
+ddqua651 quantize -1000 sNaN -> NaN Invalid_operation
+ddqua652 quantize -1 sNaN -> NaN Invalid_operation
+ddqua653 quantize 0 sNaN -> NaN Invalid_operation
+ddqua654 quantize 1 sNaN -> NaN Invalid_operation
+ddqua655 quantize 1000 sNaN -> NaN Invalid_operation
+ddqua656 quantize Inf sNaN -> NaN Invalid_operation
+ddqua657 quantize NaN sNaN -> NaN Invalid_operation
+ddqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
+ddqua659 quantize -0 sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddqua661 quantize NaN9 -Inf -> NaN9
+ddqua662 quantize NaN8 919 -> NaN8
+ddqua663 quantize NaN71 Inf -> NaN71
+ddqua664 quantize NaN6 NaN5 -> NaN6
+ddqua665 quantize -Inf NaN4 -> NaN4
+ddqua666 quantize -919 NaN31 -> NaN31
+ddqua667 quantize Inf NaN2 -> NaN2
+
+ddqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
+ddqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
+ddqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
+ddqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
+ddqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
+ddqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
+ddqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
+ddqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
+ddqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
+
+ddqua681 quantize -NaN9 -Inf -> -NaN9
+ddqua682 quantize -NaN8 919 -> -NaN8
+ddqua683 quantize -NaN71 Inf -> -NaN71
+ddqua684 quantize -NaN6 -NaN5 -> -NaN6
+ddqua685 quantize -Inf -NaN4 -> -NaN4
+ddqua686 quantize -919 -NaN31 -> -NaN31
+ddqua687 quantize Inf -NaN2 -> -NaN2
+
+ddqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
+ddqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
+ddqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
+ddqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
+ddqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+ddqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
+ddqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
+ddqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
+ddqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
+
+-- subnormals and underflow
+ddqua710 quantize 1.00E-383 1e-383 -> 1E-383 Rounded
+ddqua711 quantize 0.1E-383 2e-384 -> 1E-384 Subnormal
+ddqua712 quantize 0.10E-383 3e-384 -> 1E-384 Subnormal Rounded
+ddqua713 quantize 0.100E-383 4e-384 -> 1E-384 Subnormal Rounded
+ddqua714 quantize 0.01E-383 5e-385 -> 1E-385 Subnormal
+-- next is rounded to Emin
+ddqua715 quantize 0.999E-383 1e-383 -> 1E-383 Inexact Rounded
+ddqua716 quantize 0.099E-383 10e-384 -> 1E-384 Inexact Rounded Subnormal
+
+ddqua717 quantize 0.009E-383 1e-385 -> 1E-385 Inexact Rounded Subnormal
+ddqua718 quantize 0.001E-383 1e-385 -> 0E-385 Inexact Rounded
+ddqua719 quantize 0.0009E-383 1e-385 -> 0E-385 Inexact Rounded
+ddqua720 quantize 0.0001E-383 1e-385 -> 0E-385 Inexact Rounded
+
+ddqua730 quantize -1.00E-383 1e-383 -> -1E-383 Rounded
+ddqua731 quantize -0.1E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua732 quantize -0.10E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua733 quantize -0.100E-383 1e-383 -> -0E-383 Rounded Inexact
+ddqua734 quantize -0.01E-383 1e-383 -> -0E-383 Inexact Rounded
+-- next is rounded to Emin
+ddqua735 quantize -0.999E-383 90e-383 -> -1E-383 Inexact Rounded
+ddqua736 quantize -0.099E-383 -1e-383 -> -0E-383 Inexact Rounded
+ddqua737 quantize -0.009E-383 -1e-383 -> -0E-383 Inexact Rounded
+ddqua738 quantize -0.001E-383 -0e-383 -> -0E-383 Inexact Rounded
+ddqua739 quantize -0.0001E-383 0e-383 -> -0E-383 Inexact Rounded
+
+ddqua740 quantize -1.00E-383 1e-384 -> -1.0E-383 Rounded
+ddqua741 quantize -0.1E-383 1e-384 -> -1E-384 Subnormal
+ddqua742 quantize -0.10E-383 1e-384 -> -1E-384 Subnormal Rounded
+ddqua743 quantize -0.100E-383 1e-384 -> -1E-384 Subnormal Rounded
+ddqua744 quantize -0.01E-383 1e-384 -> -0E-384 Inexact Rounded
+-- next is rounded to Emin
+ddqua745 quantize -0.999E-383 1e-384 -> -1.0E-383 Inexact Rounded
+ddqua746 quantize -0.099E-383 1e-384 -> -1E-384 Inexact Rounded Subnormal
+ddqua747 quantize -0.009E-383 1e-384 -> -0E-384 Inexact Rounded
+ddqua748 quantize -0.001E-383 1e-384 -> -0E-384 Inexact Rounded
+ddqua749 quantize -0.0001E-383 1e-384 -> -0E-384 Inexact Rounded
+
+ddqua750 quantize -1.00E-383 1e-385 -> -1.00E-383
+ddqua751 quantize -0.1E-383 1e-385 -> -1.0E-384 Subnormal
+ddqua752 quantize -0.10E-383 1e-385 -> -1.0E-384 Subnormal
+ddqua753 quantize -0.100E-383 1e-385 -> -1.0E-384 Subnormal Rounded
+ddqua754 quantize -0.01E-383 1e-385 -> -1E-385 Subnormal
+-- next is rounded to Emin
+ddqua755 quantize -0.999E-383 1e-385 -> -1.00E-383 Inexact Rounded
+ddqua756 quantize -0.099E-383 1e-385 -> -1.0E-384 Inexact Rounded Subnormal
+ddqua757 quantize -0.009E-383 1e-385 -> -1E-385 Inexact Rounded Subnormal
+ddqua758 quantize -0.001E-383 1e-385 -> -0E-385 Inexact Rounded
+ddqua759 quantize -0.0001E-383 1e-385 -> -0E-385 Inexact Rounded
+
+ddqua760 quantize -1.00E-383 1e-386 -> -1.000E-383
+ddqua761 quantize -0.1E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua762 quantize -0.10E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua763 quantize -0.100E-383 1e-386 -> -1.00E-384 Subnormal
+ddqua764 quantize -0.01E-383 1e-386 -> -1.0E-385 Subnormal
+ddqua765 quantize -0.999E-383 1e-386 -> -9.99E-384 Subnormal
+ddqua766 quantize -0.099E-383 1e-386 -> -9.9E-385 Subnormal
+ddqua767 quantize -0.009E-383 1e-386 -> -9E-386 Subnormal
+ddqua768 quantize -0.001E-383 1e-386 -> -1E-386 Subnormal
+ddqua769 quantize -0.0001E-383 1e-386 -> -0E-386 Inexact Rounded
+
+-- More from Fung Lee
+ddqua1021 quantize 8.666666666666000E+384 1.000000000000000E+384 -> 8.666666666666000E+384
+ddqua1022 quantize -8.666666666666000E+384 1.000000000000000E+384 -> -8.666666666666000E+384
+ddqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
+ddqua1029 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
+
+
+--ddqua1030 quantize 8.666666666666000E+384 1E+384 -> 9.000000000000000E+384 Rounded Inexact
+--ddqua1031 quantize 8.666666666666000E+384 1E+384 -> 8.666666666666000E+384 Rounded
+--ddqua1032 quantize 8.666666666666000E+384 1E+383 -> 8.666666666666000E+384 Rounded
+--ddqua1033 quantize 8.666666666666000E+384 1E+382 -> 8.666666666666000E+384 Rounded
+--ddqua1034 quantize 8.666666666666000E+384 1E+381 -> 8.666666666666000E+384 Rounded
+--ddqua1035 quantize 8.666666666666000E+384 1E+380 -> 8.666666666666000E+384 Rounded
+
+-- Int and uInt32 edge values for testing conversions
+ddqua1040 quantize -2147483646 0 -> -2147483646
+ddqua1041 quantize -2147483647 0 -> -2147483647
+ddqua1042 quantize -2147483648 0 -> -2147483648
+ddqua1043 quantize -2147483649 0 -> -2147483649
+ddqua1044 quantize 2147483646 0 -> 2147483646
+ddqua1045 quantize 2147483647 0 -> 2147483647
+ddqua1046 quantize 2147483648 0 -> 2147483648
+ddqua1047 quantize 2147483649 0 -> 2147483649
+ddqua1048 quantize 4294967294 0 -> 4294967294
+ddqua1049 quantize 4294967295 0 -> 4294967295
+ddqua1050 quantize 4294967296 0 -> 4294967296
+ddqua1051 quantize 4294967297 0 -> 4294967297
+
+-- Rounding swathe
+rounding: half_even
+ddqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_up
+ddqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_down
+ddqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: up
+ddqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+ddqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+ddqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+ddqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: down
+ddqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+ddqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+ddqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+ddqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+ddqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: ceiling
+ddqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+ddqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+ddqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+ddqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+ddqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+ddqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+ddqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+ddqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+ddqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+ddqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: floor
+ddqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
+ddqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+ddqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+ddqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+ddqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+ddqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+ddqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+ddqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+ddqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: 05up
+ddqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
+ddqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
+ddqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
+ddqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
+ddqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
+ddqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
+ddqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
+ddqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
+ddqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
+
+ddqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
+ddqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
+ddqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
+ddqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
+ddqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
+ddqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
+ddqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
+ddqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
+ddqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
+
+ddqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
+ddqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
+ddqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
+ddqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+ddqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+ddqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
+ddqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
+ddqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
+ddqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
+
+ddqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
+ddqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
+ddqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
+ddqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
+ddqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
+ddqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
+ddqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
+ddqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
+ddqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
+
+ddqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
+ddqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
+ddqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
+ddqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
+ddqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
+ddqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
+ddqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
+ddqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
+ddqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
+
+ddqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
+ddqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
+ddqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
+ddqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
+ddqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
+ddqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
+ddqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
+ddqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
+ddqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
+
+-- Null tests
+rounding: half_even
+ddqua998 quantize 10 # -> NaN Invalid_operation
+ddqua999 quantize # 1e10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddReduce.decTest b/Lib/test/decimaltestdata/ddReduce.decTest
index 9529e50a752..bdfd0604926 100644
--- a/Lib/test/decimaltestdata/ddReduce.decTest
+++ b/Lib/test/decimaltestdata/ddReduce.decTest
@@ -1,182 +1,182 @@
-------------------------------------------------------------------------
--- ddReduce.decTest -- remove trailing zeros from a decDouble --
--- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddred001 reduce '1' -> '1'
-ddred002 reduce '-1' -> '-1'
-ddred003 reduce '1.00' -> '1'
-ddred004 reduce '-1.00' -> '-1'
-ddred005 reduce '0' -> '0'
-ddred006 reduce '0.00' -> '0'
-ddred007 reduce '00.0' -> '0'
-ddred008 reduce '00.00' -> '0'
-ddred009 reduce '00' -> '0'
-ddred010 reduce '0E+1' -> '0'
-ddred011 reduce '0E+5' -> '0'
-
-ddred012 reduce '-2' -> '-2'
-ddred013 reduce '2' -> '2'
-ddred014 reduce '-2.00' -> '-2'
-ddred015 reduce '2.00' -> '2'
-ddred016 reduce '-0' -> '-0'
-ddred017 reduce '-0.00' -> '-0'
-ddred018 reduce '-00.0' -> '-0'
-ddred019 reduce '-00.00' -> '-0'
-ddred020 reduce '-00' -> '-0'
-ddred021 reduce '-0E+5' -> '-0'
-ddred022 reduce '-0E+1' -> '-0'
-
-ddred030 reduce '+0.1' -> '0.1'
-ddred031 reduce '-0.1' -> '-0.1'
-ddred032 reduce '+0.01' -> '0.01'
-ddred033 reduce '-0.01' -> '-0.01'
-ddred034 reduce '+0.001' -> '0.001'
-ddred035 reduce '-0.001' -> '-0.001'
-ddred036 reduce '+0.000001' -> '0.000001'
-ddred037 reduce '-0.000001' -> '-0.000001'
-ddred038 reduce '+0.000000000001' -> '1E-12'
-ddred039 reduce '-0.000000000001' -> '-1E-12'
-
-ddred041 reduce 1.1 -> 1.1
-ddred042 reduce 1.10 -> 1.1
-ddred043 reduce 1.100 -> 1.1
-ddred044 reduce 1.110 -> 1.11
-ddred045 reduce -1.1 -> -1.1
-ddred046 reduce -1.10 -> -1.1
-ddred047 reduce -1.100 -> -1.1
-ddred048 reduce -1.110 -> -1.11
-ddred049 reduce 9.9 -> 9.9
-ddred050 reduce 9.90 -> 9.9
-ddred051 reduce 9.900 -> 9.9
-ddred052 reduce 9.990 -> 9.99
-ddred053 reduce -9.9 -> -9.9
-ddred054 reduce -9.90 -> -9.9
-ddred055 reduce -9.900 -> -9.9
-ddred056 reduce -9.990 -> -9.99
-
--- some trailing fractional zeros with zeros in units
-ddred060 reduce 10.0 -> 1E+1
-ddred061 reduce 10.00 -> 1E+1
-ddred062 reduce 100.0 -> 1E+2
-ddred063 reduce 100.00 -> 1E+2
-ddred064 reduce 1.1000E+3 -> 1.1E+3
-ddred065 reduce 1.10000E+3 -> 1.1E+3
-ddred066 reduce -10.0 -> -1E+1
-ddred067 reduce -10.00 -> -1E+1
-ddred068 reduce -100.0 -> -1E+2
-ddred069 reduce -100.00 -> -1E+2
-ddred070 reduce -1.1000E+3 -> -1.1E+3
-ddred071 reduce -1.10000E+3 -> -1.1E+3
-
--- some insignificant trailing zeros with positive exponent
-ddred080 reduce 10E+1 -> 1E+2
-ddred081 reduce 100E+1 -> 1E+3
-ddred082 reduce 1.0E+2 -> 1E+2
-ddred083 reduce 1.0E+3 -> 1E+3
-ddred084 reduce 1.1E+3 -> 1.1E+3
-ddred085 reduce 1.00E+3 -> 1E+3
-ddred086 reduce 1.10E+3 -> 1.1E+3
-ddred087 reduce -10E+1 -> -1E+2
-ddred088 reduce -100E+1 -> -1E+3
-ddred089 reduce -1.0E+2 -> -1E+2
-ddred090 reduce -1.0E+3 -> -1E+3
-ddred091 reduce -1.1E+3 -> -1.1E+3
-ddred092 reduce -1.00E+3 -> -1E+3
-ddred093 reduce -1.10E+3 -> -1.1E+3
-
--- some significant trailing zeros, were we to be trimming
-ddred100 reduce 11 -> 11
-ddred101 reduce 10 -> 1E+1
-ddred102 reduce 10. -> 1E+1
-ddred103 reduce 1.1E+1 -> 11
-ddred104 reduce 1.0E+1 -> 1E+1
-ddred105 reduce 1.10E+2 -> 1.1E+2
-ddred106 reduce 1.00E+2 -> 1E+2
-ddred107 reduce 1.100E+3 -> 1.1E+3
-ddred108 reduce 1.000E+3 -> 1E+3
-ddred109 reduce 1.000000E+6 -> 1E+6
-ddred110 reduce -11 -> -11
-ddred111 reduce -10 -> -1E+1
-ddred112 reduce -10. -> -1E+1
-ddred113 reduce -1.1E+1 -> -11
-ddred114 reduce -1.0E+1 -> -1E+1
-ddred115 reduce -1.10E+2 -> -1.1E+2
-ddred116 reduce -1.00E+2 -> -1E+2
-ddred117 reduce -1.100E+3 -> -1.1E+3
-ddred118 reduce -1.000E+3 -> -1E+3
-ddred119 reduce -1.00000E+5 -> -1E+5
-ddred120 reduce -1.000000E+6 -> -1E+6
-ddred121 reduce -10.00000E+6 -> -1E+7
-ddred122 reduce -100.0000E+6 -> -1E+8
-ddred123 reduce -1000.000E+6 -> -1E+9
-ddred124 reduce -10000.00E+6 -> -1E+10
-ddred125 reduce -100000.0E+6 -> -1E+11
-ddred126 reduce -1000000.E+6 -> -1E+12
-
--- examples from decArith
-ddred140 reduce '2.1' -> '2.1'
-ddred141 reduce '-2.0' -> '-2'
-ddred142 reduce '1.200' -> '1.2'
-ddred143 reduce '-120' -> '-1.2E+2'
-ddred144 reduce '120.00' -> '1.2E+2'
-ddred145 reduce '0.00' -> '0'
-
--- Nmax, Nmin, Ntiny
--- note origami effect on some of these
-ddred151 reduce 9.999999999999999E+384 -> 9.999999999999999E+384
-ddred152 reduce 9.999999000000000E+380 -> 9.99999900000E+380
-ddred153 reduce 9.999999999990000E+384 -> 9.999999999990000E+384
-ddred154 reduce 1E-383 -> 1E-383
-ddred155 reduce 1.000000000000000E-383 -> 1E-383
-ddred156 reduce 2.000E-395 -> 2E-395 Subnormal
-ddred157 reduce 1E-398 -> 1E-398 Subnormal
-
-ddred161 reduce -1E-398 -> -1E-398 Subnormal
-ddred162 reduce -2.000E-395 -> -2E-395 Subnormal
-ddred163 reduce -1.000000000000000E-383 -> -1E-383
-ddred164 reduce -1E-383 -> -1E-383
-ddred165 reduce -9.999999000000000E+380 -> -9.99999900000E+380
-ddred166 reduce -9.999999999990000E+384 -> -9.999999999990000E+384
-ddred167 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
-ddred168 reduce -9.999999999999999E+384 -> -9.999999999999999E+384
-ddred169 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
-
-
--- specials (reduce does not affect payload)
-ddred820 reduce 'Inf' -> 'Infinity'
-ddred821 reduce '-Inf' -> '-Infinity'
-ddred822 reduce NaN -> NaN
-ddred823 reduce sNaN -> NaN Invalid_operation
-ddred824 reduce NaN101 -> NaN101
-ddred825 reduce sNaN010 -> NaN10 Invalid_operation
-ddred827 reduce -NaN -> -NaN
-ddred828 reduce -sNaN -> -NaN Invalid_operation
-ddred829 reduce -NaN101 -> -NaN101
-ddred830 reduce -sNaN010 -> -NaN10 Invalid_operation
-
--- Null test
-ddred900 reduce # -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddReduce.decTest -- remove trailing zeros from a decDouble --
+-- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddred001 reduce '1' -> '1'
+ddred002 reduce '-1' -> '-1'
+ddred003 reduce '1.00' -> '1'
+ddred004 reduce '-1.00' -> '-1'
+ddred005 reduce '0' -> '0'
+ddred006 reduce '0.00' -> '0'
+ddred007 reduce '00.0' -> '0'
+ddred008 reduce '00.00' -> '0'
+ddred009 reduce '00' -> '0'
+ddred010 reduce '0E+1' -> '0'
+ddred011 reduce '0E+5' -> '0'
+
+ddred012 reduce '-2' -> '-2'
+ddred013 reduce '2' -> '2'
+ddred014 reduce '-2.00' -> '-2'
+ddred015 reduce '2.00' -> '2'
+ddred016 reduce '-0' -> '-0'
+ddred017 reduce '-0.00' -> '-0'
+ddred018 reduce '-00.0' -> '-0'
+ddred019 reduce '-00.00' -> '-0'
+ddred020 reduce '-00' -> '-0'
+ddred021 reduce '-0E+5' -> '-0'
+ddred022 reduce '-0E+1' -> '-0'
+
+ddred030 reduce '+0.1' -> '0.1'
+ddred031 reduce '-0.1' -> '-0.1'
+ddred032 reduce '+0.01' -> '0.01'
+ddred033 reduce '-0.01' -> '-0.01'
+ddred034 reduce '+0.001' -> '0.001'
+ddred035 reduce '-0.001' -> '-0.001'
+ddred036 reduce '+0.000001' -> '0.000001'
+ddred037 reduce '-0.000001' -> '-0.000001'
+ddred038 reduce '+0.000000000001' -> '1E-12'
+ddred039 reduce '-0.000000000001' -> '-1E-12'
+
+ddred041 reduce 1.1 -> 1.1
+ddred042 reduce 1.10 -> 1.1
+ddred043 reduce 1.100 -> 1.1
+ddred044 reduce 1.110 -> 1.11
+ddred045 reduce -1.1 -> -1.1
+ddred046 reduce -1.10 -> -1.1
+ddred047 reduce -1.100 -> -1.1
+ddred048 reduce -1.110 -> -1.11
+ddred049 reduce 9.9 -> 9.9
+ddred050 reduce 9.90 -> 9.9
+ddred051 reduce 9.900 -> 9.9
+ddred052 reduce 9.990 -> 9.99
+ddred053 reduce -9.9 -> -9.9
+ddred054 reduce -9.90 -> -9.9
+ddred055 reduce -9.900 -> -9.9
+ddred056 reduce -9.990 -> -9.99
+
+-- some trailing fractional zeros with zeros in units
+ddred060 reduce 10.0 -> 1E+1
+ddred061 reduce 10.00 -> 1E+1
+ddred062 reduce 100.0 -> 1E+2
+ddred063 reduce 100.00 -> 1E+2
+ddred064 reduce 1.1000E+3 -> 1.1E+3
+ddred065 reduce 1.10000E+3 -> 1.1E+3
+ddred066 reduce -10.0 -> -1E+1
+ddred067 reduce -10.00 -> -1E+1
+ddred068 reduce -100.0 -> -1E+2
+ddred069 reduce -100.00 -> -1E+2
+ddred070 reduce -1.1000E+3 -> -1.1E+3
+ddred071 reduce -1.10000E+3 -> -1.1E+3
+
+-- some insignificant trailing zeros with positive exponent
+ddred080 reduce 10E+1 -> 1E+2
+ddred081 reduce 100E+1 -> 1E+3
+ddred082 reduce 1.0E+2 -> 1E+2
+ddred083 reduce 1.0E+3 -> 1E+3
+ddred084 reduce 1.1E+3 -> 1.1E+3
+ddred085 reduce 1.00E+3 -> 1E+3
+ddred086 reduce 1.10E+3 -> 1.1E+3
+ddred087 reduce -10E+1 -> -1E+2
+ddred088 reduce -100E+1 -> -1E+3
+ddred089 reduce -1.0E+2 -> -1E+2
+ddred090 reduce -1.0E+3 -> -1E+3
+ddred091 reduce -1.1E+3 -> -1.1E+3
+ddred092 reduce -1.00E+3 -> -1E+3
+ddred093 reduce -1.10E+3 -> -1.1E+3
+
+-- some significant trailing zeros, were we to be trimming
+ddred100 reduce 11 -> 11
+ddred101 reduce 10 -> 1E+1
+ddred102 reduce 10. -> 1E+1
+ddred103 reduce 1.1E+1 -> 11
+ddred104 reduce 1.0E+1 -> 1E+1
+ddred105 reduce 1.10E+2 -> 1.1E+2
+ddred106 reduce 1.00E+2 -> 1E+2
+ddred107 reduce 1.100E+3 -> 1.1E+3
+ddred108 reduce 1.000E+3 -> 1E+3
+ddred109 reduce 1.000000E+6 -> 1E+6
+ddred110 reduce -11 -> -11
+ddred111 reduce -10 -> -1E+1
+ddred112 reduce -10. -> -1E+1
+ddred113 reduce -1.1E+1 -> -11
+ddred114 reduce -1.0E+1 -> -1E+1
+ddred115 reduce -1.10E+2 -> -1.1E+2
+ddred116 reduce -1.00E+2 -> -1E+2
+ddred117 reduce -1.100E+3 -> -1.1E+3
+ddred118 reduce -1.000E+3 -> -1E+3
+ddred119 reduce -1.00000E+5 -> -1E+5
+ddred120 reduce -1.000000E+6 -> -1E+6
+ddred121 reduce -10.00000E+6 -> -1E+7
+ddred122 reduce -100.0000E+6 -> -1E+8
+ddred123 reduce -1000.000E+6 -> -1E+9
+ddred124 reduce -10000.00E+6 -> -1E+10
+ddred125 reduce -100000.0E+6 -> -1E+11
+ddred126 reduce -1000000.E+6 -> -1E+12
+
+-- examples from decArith
+ddred140 reduce '2.1' -> '2.1'
+ddred141 reduce '-2.0' -> '-2'
+ddred142 reduce '1.200' -> '1.2'
+ddred143 reduce '-120' -> '-1.2E+2'
+ddred144 reduce '120.00' -> '1.2E+2'
+ddred145 reduce '0.00' -> '0'
+
+-- Nmax, Nmin, Ntiny
+-- note origami effect on some of these
+ddred151 reduce 9.999999999999999E+384 -> 9.999999999999999E+384
+ddred152 reduce 9.999999000000000E+380 -> 9.99999900000E+380
+ddred153 reduce 9.999999999990000E+384 -> 9.999999999990000E+384
+ddred154 reduce 1E-383 -> 1E-383
+ddred155 reduce 1.000000000000000E-383 -> 1E-383
+ddred156 reduce 2.000E-395 -> 2E-395 Subnormal
+ddred157 reduce 1E-398 -> 1E-398 Subnormal
+
+ddred161 reduce -1E-398 -> -1E-398 Subnormal
+ddred162 reduce -2.000E-395 -> -2E-395 Subnormal
+ddred163 reduce -1.000000000000000E-383 -> -1E-383
+ddred164 reduce -1E-383 -> -1E-383
+ddred165 reduce -9.999999000000000E+380 -> -9.99999900000E+380
+ddred166 reduce -9.999999999990000E+384 -> -9.999999999990000E+384
+ddred167 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
+ddred168 reduce -9.999999999999999E+384 -> -9.999999999999999E+384
+ddred169 reduce -9.999999999999990E+384 -> -9.999999999999990E+384
+
+
+-- specials (reduce does not affect payload)
+ddred820 reduce 'Inf' -> 'Infinity'
+ddred821 reduce '-Inf' -> '-Infinity'
+ddred822 reduce NaN -> NaN
+ddred823 reduce sNaN -> NaN Invalid_operation
+ddred824 reduce NaN101 -> NaN101
+ddred825 reduce sNaN010 -> NaN10 Invalid_operation
+ddred827 reduce -NaN -> -NaN
+ddred828 reduce -sNaN -> -NaN Invalid_operation
+ddred829 reduce -NaN101 -> -NaN101
+ddred830 reduce -sNaN010 -> -NaN10 Invalid_operation
+
+-- Null test
+ddred900 reduce # -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddRemainder.decTest b/Lib/test/decimaltestdata/ddRemainder.decTest
index 85d86f9457e..5bd1e32d01e 100644
--- a/Lib/test/decimaltestdata/ddRemainder.decTest
+++ b/Lib/test/decimaltestdata/ddRemainder.decTest
@@ -1,600 +1,600 @@
-------------------------------------------------------------------------
--- ddRemainder.decTest -- decDouble remainder --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks (as base, above)
-ddrem001 remainder 1 1 -> 0
-ddrem002 remainder 2 1 -> 0
-ddrem003 remainder 1 2 -> 1
-ddrem004 remainder 2 2 -> 0
-ddrem005 remainder 0 1 -> 0
-ddrem006 remainder 0 2 -> 0
-ddrem007 remainder 1 3 -> 1
-ddrem008 remainder 2 3 -> 2
-ddrem009 remainder 3 3 -> 0
-
-ddrem010 remainder 2.4 1 -> 0.4
-ddrem011 remainder 2.4 -1 -> 0.4
-ddrem012 remainder -2.4 1 -> -0.4
-ddrem013 remainder -2.4 -1 -> -0.4
-ddrem014 remainder 2.40 1 -> 0.40
-ddrem015 remainder 2.400 1 -> 0.400
-ddrem016 remainder 2.4 2 -> 0.4
-ddrem017 remainder 2.400 2 -> 0.400
-ddrem018 remainder 2. 2 -> 0
-ddrem019 remainder 20 20 -> 0
-
-ddrem020 remainder 187 187 -> 0
-ddrem021 remainder 5 2 -> 1
-ddrem022 remainder 5 2.0 -> 1.0
-ddrem023 remainder 5 2.000 -> 1.000
-ddrem024 remainder 5 0.200 -> 0.000
-ddrem025 remainder 5 0.200 -> 0.000
-
-ddrem030 remainder 1 2 -> 1
-ddrem031 remainder 1 4 -> 1
-ddrem032 remainder 1 8 -> 1
-
-ddrem033 remainder 1 16 -> 1
-ddrem034 remainder 1 32 -> 1
-ddrem035 remainder 1 64 -> 1
-ddrem040 remainder 1 -2 -> 1
-ddrem041 remainder 1 -4 -> 1
-ddrem042 remainder 1 -8 -> 1
-ddrem043 remainder 1 -16 -> 1
-ddrem044 remainder 1 -32 -> 1
-ddrem045 remainder 1 -64 -> 1
-ddrem050 remainder -1 2 -> -1
-ddrem051 remainder -1 4 -> -1
-ddrem052 remainder -1 8 -> -1
-ddrem053 remainder -1 16 -> -1
-ddrem054 remainder -1 32 -> -1
-ddrem055 remainder -1 64 -> -1
-ddrem060 remainder -1 -2 -> -1
-ddrem061 remainder -1 -4 -> -1
-ddrem062 remainder -1 -8 -> -1
-ddrem063 remainder -1 -16 -> -1
-ddrem064 remainder -1 -32 -> -1
-ddrem065 remainder -1 -64 -> -1
-
-ddrem066 remainder 999999999 1 -> 0
-ddrem067 remainder 999999999.4 1 -> 0.4
-ddrem068 remainder 999999999.5 1 -> 0.5
-ddrem069 remainder 999999999.9 1 -> 0.9
-ddrem070 remainder 999999999.999 1 -> 0.999
-ddrem071 remainder 999999.999999 1 -> 0.999999
-ddrem072 remainder 9 1 -> 0
-ddrem073 remainder 9999999999999999 1 -> 0
-ddrem074 remainder 9999999999999999 2 -> 1
-ddrem075 remainder 9999999999999999 3 -> 0
-ddrem076 remainder 9999999999999999 4 -> 3
-
-ddrem080 remainder 0. 1 -> 0
-ddrem081 remainder .0 1 -> 0.0
-ddrem082 remainder 0.00 1 -> 0.00
-ddrem083 remainder 0.00E+9 1 -> 0
-ddrem084 remainder 0.00E+3 1 -> 0
-ddrem085 remainder 0.00E+2 1 -> 0
-ddrem086 remainder 0.00E+1 1 -> 0.0
-ddrem087 remainder 0.00E+0 1 -> 0.00
-ddrem088 remainder 0.00E-0 1 -> 0.00
-ddrem089 remainder 0.00E-1 1 -> 0.000
-ddrem090 remainder 0.00E-2 1 -> 0.0000
-ddrem091 remainder 0.00E-3 1 -> 0.00000
-ddrem092 remainder 0.00E-4 1 -> 0.000000
-ddrem093 remainder 0.00E-5 1 -> 0E-7
-ddrem094 remainder 0.00E-6 1 -> 0E-8
-ddrem095 remainder 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remainder by 0
-ddrem101 remainder 0 0 -> NaN Division_undefined
-ddrem102 remainder 0 -0 -> NaN Division_undefined
-ddrem103 remainder -0 0 -> NaN Division_undefined
-ddrem104 remainder -0 -0 -> NaN Division_undefined
-ddrem105 remainder 0.0E5 0 -> NaN Division_undefined
-ddrem106 remainder 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-ddrem107 remainder 0.0001 0 -> NaN Invalid_operation
-ddrem108 remainder 0.01 0 -> NaN Invalid_operation
-ddrem109 remainder 0.1 0 -> NaN Invalid_operation
-ddrem110 remainder 1 0 -> NaN Invalid_operation
-ddrem111 remainder 1 0.0 -> NaN Invalid_operation
-ddrem112 remainder 10 0.0 -> NaN Invalid_operation
-ddrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
-ddrem114 remainder 1E+380 0 -> NaN Invalid_operation
-ddrem115 remainder 0.0001 -0 -> NaN Invalid_operation
-ddrem116 remainder 0.01 -0 -> NaN Invalid_operation
-ddrem119 remainder 0.1 -0 -> NaN Invalid_operation
-ddrem120 remainder 1 -0 -> NaN Invalid_operation
-ddrem121 remainder 1 -0.0 -> NaN Invalid_operation
-ddrem122 remainder 10 -0.0 -> NaN Invalid_operation
-ddrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
-ddrem124 remainder 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-ddrem130 remainder 0 1 -> 0
-ddrem131 remainder 0 -1 -> 0
-ddrem132 remainder 0.0 1 -> 0.0
-ddrem133 remainder 0.0 -1 -> 0.0
-ddrem134 remainder -0 1 -> -0
-ddrem135 remainder -0 -1 -> -0
-ddrem136 remainder -0.0 1 -> -0.0
-ddrem137 remainder -0.0 -1 -> -0.0
-
--- 0.5ers
-ddrem143 remainder 0.5 2 -> 0.5
-ddrem144 remainder 0.5 2.1 -> 0.5
-ddrem145 remainder 0.5 2.01 -> 0.50
-ddrem146 remainder 0.5 2.001 -> 0.500
-ddrem147 remainder 0.50 2 -> 0.50
-ddrem148 remainder 0.50 2.01 -> 0.50
-ddrem149 remainder 0.50 2.001 -> 0.500
-
--- steadies
-ddrem150 remainder 1 1 -> 0
-ddrem151 remainder 1 2 -> 1
-ddrem152 remainder 1 3 -> 1
-ddrem153 remainder 1 4 -> 1
-ddrem154 remainder 1 5 -> 1
-ddrem155 remainder 1 6 -> 1
-ddrem156 remainder 1 7 -> 1
-ddrem157 remainder 1 8 -> 1
-ddrem158 remainder 1 9 -> 1
-ddrem159 remainder 1 10 -> 1
-ddrem160 remainder 1 1 -> 0
-ddrem161 remainder 2 1 -> 0
-ddrem162 remainder 3 1 -> 0
-ddrem163 remainder 4 1 -> 0
-ddrem164 remainder 5 1 -> 0
-ddrem165 remainder 6 1 -> 0
-ddrem166 remainder 7 1 -> 0
-ddrem167 remainder 8 1 -> 0
-ddrem168 remainder 9 1 -> 0
-ddrem169 remainder 10 1 -> 0
-
--- some differences from remainderNear
-ddrem171 remainder 0.4 1.020 -> 0.400
-ddrem172 remainder 0.50 1.020 -> 0.500
-ddrem173 remainder 0.51 1.020 -> 0.510
-ddrem174 remainder 0.52 1.020 -> 0.520
-ddrem175 remainder 0.6 1.020 -> 0.600
-
--- More flavours of remainder by 0
-ddrem201 remainder 0 0 -> NaN Division_undefined
-ddrem202 remainder 0.0E5 0 -> NaN Division_undefined
-ddrem203 remainder 0.000 0 -> NaN Division_undefined
-ddrem204 remainder 0.0001 0 -> NaN Invalid_operation
-ddrem205 remainder 0.01 0 -> NaN Invalid_operation
-ddrem206 remainder 0.1 0 -> NaN Invalid_operation
-ddrem207 remainder 1 0 -> NaN Invalid_operation
-ddrem208 remainder 1 0.0 -> NaN Invalid_operation
-ddrem209 remainder 10 0.0 -> NaN Invalid_operation
-ddrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
-ddrem211 remainder 1E+380 0 -> NaN Invalid_operation
-
--- some differences from remainderNear
-ddrem231 remainder -0.4 1.020 -> -0.400
-ddrem232 remainder -0.50 1.020 -> -0.500
-ddrem233 remainder -0.51 1.020 -> -0.510
-ddrem234 remainder -0.52 1.020 -> -0.520
-ddrem235 remainder -0.6 1.020 -> -0.600
-
--- high Xs
-ddrem240 remainder 1E+2 1.00 -> 0.00
-
--- ddrem3xx are from DiagBigDecimal
-ddrem301 remainder 1 3 -> 1
-ddrem302 remainder 5 5 -> 0
-ddrem303 remainder 13 10 -> 3
-ddrem304 remainder 13 50 -> 13
-ddrem305 remainder 13 100 -> 13
-ddrem306 remainder 13 1000 -> 13
-ddrem307 remainder .13 1 -> 0.13
-ddrem308 remainder 0.133 1 -> 0.133
-ddrem309 remainder 0.1033 1 -> 0.1033
-ddrem310 remainder 1.033 1 -> 0.033
-ddrem311 remainder 10.33 1 -> 0.33
-ddrem312 remainder 10.33 10 -> 0.33
-ddrem313 remainder 103.3 1 -> 0.3
-ddrem314 remainder 133 10 -> 3
-ddrem315 remainder 1033 10 -> 3
-ddrem316 remainder 1033 50 -> 33
-ddrem317 remainder 101.0 3 -> 2.0
-ddrem318 remainder 102.0 3 -> 0.0
-ddrem319 remainder 103.0 3 -> 1.0
-ddrem320 remainder 2.40 1 -> 0.40
-ddrem321 remainder 2.400 1 -> 0.400
-ddrem322 remainder 2.4 1 -> 0.4
-ddrem323 remainder 2.4 2 -> 0.4
-ddrem324 remainder 2.400 2 -> 0.400
-ddrem325 remainder 1 0.3 -> 0.1
-ddrem326 remainder 1 0.30 -> 0.10
-ddrem327 remainder 1 0.300 -> 0.100
-ddrem328 remainder 1 0.3000 -> 0.1000
-ddrem329 remainder 1.0 0.3 -> 0.1
-ddrem330 remainder 1.00 0.3 -> 0.10
-ddrem331 remainder 1.000 0.3 -> 0.100
-ddrem332 remainder 1.0000 0.3 -> 0.1000
-ddrem333 remainder 0.5 2 -> 0.5
-ddrem334 remainder 0.5 2.1 -> 0.5
-ddrem335 remainder 0.5 2.01 -> 0.50
-ddrem336 remainder 0.5 2.001 -> 0.500
-ddrem337 remainder 0.50 2 -> 0.50
-ddrem338 remainder 0.50 2.01 -> 0.50
-ddrem339 remainder 0.50 2.001 -> 0.500
-
-ddrem340 remainder 0.5 0.5000001 -> 0.5000000
-ddrem341 remainder 0.5 0.50000001 -> 0.50000000
-ddrem342 remainder 0.5 0.500000001 -> 0.500000000
-ddrem343 remainder 0.5 0.5000000001 -> 0.5000000000
-ddrem344 remainder 0.5 0.50000000001 -> 0.50000000000
-ddrem345 remainder 0.5 0.4999999 -> 1E-7
-ddrem346 remainder 0.5 0.49999999 -> 1E-8
-ddrem347 remainder 0.5 0.499999999 -> 1E-9
-ddrem348 remainder 0.5 0.4999999999 -> 1E-10
-ddrem349 remainder 0.5 0.49999999999 -> 1E-11
-ddrem350 remainder 0.5 0.499999999999 -> 1E-12
-
-ddrem351 remainder 0.03 7 -> 0.03
-ddrem352 remainder 5 2 -> 1
-ddrem353 remainder 4.1 2 -> 0.1
-ddrem354 remainder 4.01 2 -> 0.01
-ddrem355 remainder 4.001 2 -> 0.001
-ddrem356 remainder 4.0001 2 -> 0.0001
-ddrem357 remainder 4.00001 2 -> 0.00001
-ddrem358 remainder 4.000001 2 -> 0.000001
-ddrem359 remainder 4.0000001 2 -> 1E-7
-
-ddrem360 remainder 1.2 0.7345 -> 0.4655
-ddrem361 remainder 0.8 12 -> 0.8
-ddrem362 remainder 0.8 0.2 -> 0.0
-ddrem363 remainder 0.8 0.3 -> 0.2
-ddrem364 remainder 0.800 12 -> 0.800
-ddrem365 remainder 0.800 1.7 -> 0.800
-ddrem366 remainder 2.400 2 -> 0.400
-
-ddrem371 remainder 2.400 2 -> 0.400
-
-ddrem381 remainder 12345 1 -> 0
-ddrem382 remainder 12345 1.0001 -> 0.7657
-ddrem383 remainder 12345 1.001 -> 0.668
-ddrem384 remainder 12345 1.01 -> 0.78
-ddrem385 remainder 12345 1.1 -> 0.8
-ddrem386 remainder 12355 4 -> 3
-ddrem387 remainder 12345 4 -> 1
-ddrem388 remainder 12355 4.0001 -> 2.6912
-ddrem389 remainder 12345 4.0001 -> 0.6914
-ddrem390 remainder 12345 4.9 -> 1.9
-ddrem391 remainder 12345 4.99 -> 4.73
-ddrem392 remainder 12345 4.999 -> 2.469
-ddrem393 remainder 12345 4.9999 -> 0.2469
-ddrem394 remainder 12345 5 -> 0
-ddrem395 remainder 12345 5.0001 -> 4.7532
-ddrem396 remainder 12345 5.001 -> 2.532
-ddrem397 remainder 12345 5.01 -> 0.36
-ddrem398 remainder 12345 5.1 -> 3.0
-
--- the nasty division-by-1 cases
-ddrem401 remainder 0.5 1 -> 0.5
-ddrem402 remainder 0.55 1 -> 0.55
-ddrem403 remainder 0.555 1 -> 0.555
-ddrem404 remainder 0.5555 1 -> 0.5555
-ddrem405 remainder 0.55555 1 -> 0.55555
-ddrem406 remainder 0.555555 1 -> 0.555555
-ddrem407 remainder 0.5555555 1 -> 0.5555555
-ddrem408 remainder 0.55555555 1 -> 0.55555555
-ddrem409 remainder 0.555555555 1 -> 0.555555555
-
--- folddowns
-ddrem421 remainder 1E+384 1 -> NaN Division_impossible
-ddrem422 remainder 1E+384 1E+383 -> 0E+369 Clamped
-ddrem423 remainder 1E+384 2E+383 -> 0E+369 Clamped
-ddrem424 remainder 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
-ddrem425 remainder 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
-ddrem426 remainder 1E+384 5E+383 -> 0E+369 Clamped
-ddrem427 remainder 1E+384 6E+383 -> 4.00000000000000E+383 Clamped
-ddrem428 remainder 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
-ddrem429 remainder 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
-ddrem430 remainder 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
--- tinies
-ddrem431 remainder 1E-397 1E-398 -> 0E-398
-ddrem432 remainder 1E-397 2E-398 -> 0E-398
-ddrem433 remainder 1E-397 3E-398 -> 1E-398 Subnormal
-ddrem434 remainder 1E-397 4E-398 -> 2E-398 Subnormal
-ddrem435 remainder 1E-397 5E-398 -> 0E-398
-ddrem436 remainder 1E-397 6E-398 -> 4E-398 Subnormal
-ddrem437 remainder 1E-397 7E-398 -> 3E-398 Subnormal
-ddrem438 remainder 1E-397 8E-398 -> 2E-398 Subnormal
-ddrem439 remainder 1E-397 9E-398 -> 1E-398 Subnormal
-ddrem440 remainder 1E-397 10E-398 -> 0E-398
-ddrem441 remainder 1E-397 11E-398 -> 1.0E-397 Subnormal
-ddrem442 remainder 100E-397 11E-398 -> 1.0E-397 Subnormal
-ddrem443 remainder 100E-397 20E-398 -> 0E-398
-ddrem444 remainder 100E-397 21E-398 -> 1.3E-397 Subnormal
-ddrem445 remainder 100E-397 30E-398 -> 1.0E-397 Subnormal
-
--- zero signs
-ddrem650 remainder 1 1 -> 0
-ddrem651 remainder -1 1 -> -0
-ddrem652 remainder 1 -1 -> 0
-ddrem653 remainder -1 -1 -> -0
-ddrem654 remainder 0 1 -> 0
-ddrem655 remainder -0 1 -> -0
-ddrem656 remainder 0 -1 -> 0
-ddrem657 remainder -0 -1 -> -0
-ddrem658 remainder 0.00 1 -> 0.00
-ddrem659 remainder -0.00 1 -> -0.00
-
--- Specials
-ddrem680 remainder Inf -Inf -> NaN Invalid_operation
-ddrem681 remainder Inf -1000 -> NaN Invalid_operation
-ddrem682 remainder Inf -1 -> NaN Invalid_operation
-ddrem683 remainder Inf 0 -> NaN Invalid_operation
-ddrem684 remainder Inf -0 -> NaN Invalid_operation
-ddrem685 remainder Inf 1 -> NaN Invalid_operation
-ddrem686 remainder Inf 1000 -> NaN Invalid_operation
-ddrem687 remainder Inf Inf -> NaN Invalid_operation
-ddrem688 remainder -1000 Inf -> -1000
-ddrem689 remainder -Inf Inf -> NaN Invalid_operation
-ddrem691 remainder -1 Inf -> -1
-ddrem692 remainder 0 Inf -> 0
-ddrem693 remainder -0 Inf -> -0
-ddrem694 remainder 1 Inf -> 1
-ddrem695 remainder 1000 Inf -> 1000
-ddrem696 remainder Inf Inf -> NaN Invalid_operation
-
-ddrem700 remainder -Inf -Inf -> NaN Invalid_operation
-ddrem701 remainder -Inf -1000 -> NaN Invalid_operation
-ddrem702 remainder -Inf -1 -> NaN Invalid_operation
-ddrem703 remainder -Inf -0 -> NaN Invalid_operation
-ddrem704 remainder -Inf 0 -> NaN Invalid_operation
-ddrem705 remainder -Inf 1 -> NaN Invalid_operation
-ddrem706 remainder -Inf 1000 -> NaN Invalid_operation
-ddrem707 remainder -Inf Inf -> NaN Invalid_operation
-ddrem708 remainder -Inf -Inf -> NaN Invalid_operation
-ddrem709 remainder -1000 Inf -> -1000
-ddrem710 remainder -1 -Inf -> -1
-ddrem711 remainder -0 -Inf -> -0
-ddrem712 remainder 0 -Inf -> 0
-ddrem713 remainder 1 -Inf -> 1
-ddrem714 remainder 1000 -Inf -> 1000
-ddrem715 remainder Inf -Inf -> NaN Invalid_operation
-
-ddrem721 remainder NaN -Inf -> NaN
-ddrem722 remainder NaN -1000 -> NaN
-ddrem723 remainder NaN -1 -> NaN
-ddrem724 remainder NaN -0 -> NaN
-ddrem725 remainder -NaN 0 -> -NaN
-ddrem726 remainder NaN 1 -> NaN
-ddrem727 remainder NaN 1000 -> NaN
-ddrem728 remainder NaN Inf -> NaN
-ddrem729 remainder NaN -NaN -> NaN
-ddrem730 remainder -Inf NaN -> NaN
-ddrem731 remainder -1000 NaN -> NaN
-ddrem732 remainder -1 NaN -> NaN
-ddrem733 remainder -0 -NaN -> -NaN
-ddrem734 remainder 0 NaN -> NaN
-ddrem735 remainder 1 -NaN -> -NaN
-ddrem736 remainder 1000 NaN -> NaN
-ddrem737 remainder Inf NaN -> NaN
-
-ddrem741 remainder sNaN -Inf -> NaN Invalid_operation
-ddrem742 remainder sNaN -1000 -> NaN Invalid_operation
-ddrem743 remainder -sNaN -1 -> -NaN Invalid_operation
-ddrem744 remainder sNaN -0 -> NaN Invalid_operation
-ddrem745 remainder sNaN 0 -> NaN Invalid_operation
-ddrem746 remainder sNaN 1 -> NaN Invalid_operation
-ddrem747 remainder sNaN 1000 -> NaN Invalid_operation
-ddrem749 remainder sNaN NaN -> NaN Invalid_operation
-ddrem750 remainder sNaN sNaN -> NaN Invalid_operation
-ddrem751 remainder NaN sNaN -> NaN Invalid_operation
-ddrem752 remainder -Inf sNaN -> NaN Invalid_operation
-ddrem753 remainder -1000 sNaN -> NaN Invalid_operation
-ddrem754 remainder -1 sNaN -> NaN Invalid_operation
-ddrem755 remainder -0 sNaN -> NaN Invalid_operation
-ddrem756 remainder 0 sNaN -> NaN Invalid_operation
-ddrem757 remainder 1 sNaN -> NaN Invalid_operation
-ddrem758 remainder 1000 sNaN -> NaN Invalid_operation
-ddrem759 remainder Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-ddrem760 remainder NaN1 NaN7 -> NaN1
-ddrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
-ddrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
-ddrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
-ddrem764 remainder 15 NaN11 -> NaN11
-ddrem765 remainder NaN6 NaN12 -> NaN6
-ddrem766 remainder Inf NaN13 -> NaN13
-ddrem767 remainder NaN14 -Inf -> NaN14
-ddrem768 remainder 0 NaN15 -> NaN15
-ddrem769 remainder NaN16 -0 -> NaN16
-
--- edge cases of impossible
-ddrem770 remainder 1234567890123456 10 -> 6
-ddrem771 remainder 1234567890123456 1 -> 0
-ddrem772 remainder 1234567890123456 0.1 -> NaN Division_impossible
-ddrem773 remainder 1234567890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-ddrem801 remainder 12345678000 100 -> 0
-ddrem802 remainder 1 12345678000 -> 1
-ddrem803 remainder 1234567800 10 -> 0
-ddrem804 remainder 1 1234567800 -> 1
-ddrem805 remainder 1234567890 10 -> 0
-ddrem806 remainder 1 1234567890 -> 1
-ddrem807 remainder 1234567891 10 -> 1
-ddrem808 remainder 1 1234567891 -> 1
-ddrem809 remainder 12345678901 100 -> 1
-ddrem810 remainder 1 12345678901 -> 1
-ddrem811 remainder 1234567896 10 -> 6
-ddrem812 remainder 1 1234567896 -> 1
-
-ddrem821 remainder 12345678000 100 -> 0
-ddrem822 remainder 1 12345678000 -> 1
-ddrem823 remainder 1234567800 10 -> 0
-ddrem824 remainder 1 1234567800 -> 1
-ddrem825 remainder 1234567890 10 -> 0
-ddrem826 remainder 1 1234567890 -> 1
-ddrem827 remainder 1234567891 10 -> 1
-ddrem828 remainder 1 1234567891 -> 1
-ddrem829 remainder 12345678901 100 -> 1
-ddrem830 remainder 1 12345678901 -> 1
-ddrem831 remainder 1234567896 10 -> 6
-ddrem832 remainder 1 1234567896 -> 1
-
--- from divideint
-ddrem840 remainder 100000000.0 1 -> 0.0
-ddrem841 remainder 100000000.4 1 -> 0.4
-ddrem842 remainder 100000000.5 1 -> 0.5
-ddrem843 remainder 100000000.9 1 -> 0.9
-ddrem844 remainder 100000000.999 1 -> 0.999
-ddrem850 remainder 100000003 5 -> 3
-ddrem851 remainder 10000003 5 -> 3
-ddrem852 remainder 1000003 5 -> 3
-ddrem853 remainder 100003 5 -> 3
-ddrem854 remainder 10003 5 -> 3
-ddrem855 remainder 1003 5 -> 3
-ddrem856 remainder 103 5 -> 3
-ddrem857 remainder 13 5 -> 3
-ddrem858 remainder 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-ddrem860 remainder 123.0e1 1000000000000000 -> 1230
-ddrem861 remainder 1230 1000000000000000 -> 1230
-ddrem862 remainder 12.3e2 1000000000000000 -> 1230
-ddrem863 remainder 1.23e3 1000000000000000 -> 1230
-ddrem864 remainder 123e1 1000000000000000 -> 1230
-ddrem870 remainder 123e1 1000000000000000 -> 1230
-ddrem871 remainder 123e1 100000000000000 -> 1230
-ddrem872 remainder 123e1 10000000000000 -> 1230
-ddrem873 remainder 123e1 1000000000000 -> 1230
-ddrem874 remainder 123e1 100000000000 -> 1230
-ddrem875 remainder 123e1 10000000000 -> 1230
-ddrem876 remainder 123e1 1000000000 -> 1230
-ddrem877 remainder 123e1 100000000 -> 1230
-ddrem878 remainder 1230 100000000 -> 1230
-ddrem879 remainder 123e1 10000000 -> 1230
-ddrem880 remainder 123e1 1000000 -> 1230
-ddrem881 remainder 123e1 100000 -> 1230
-ddrem882 remainder 123e1 10000 -> 1230
-ddrem883 remainder 123e1 1000 -> 230
-ddrem884 remainder 123e1 100 -> 30
-ddrem885 remainder 123e1 10 -> 0
-ddrem886 remainder 123e1 1 -> 0
-
-ddrem890 remainder 123e1 2000000000000000 -> 1230
-ddrem891 remainder 123e1 200000000000000 -> 1230
-ddrem892 remainder 123e1 20000000000000 -> 1230
-ddrem893 remainder 123e1 2000000000000 -> 1230
-ddrem894 remainder 123e1 200000000000 -> 1230
-ddrem895 remainder 123e1 20000000000 -> 1230
-ddrem896 remainder 123e1 2000000000 -> 1230
-ddrem897 remainder 123e1 200000000 -> 1230
-ddrem899 remainder 123e1 20000000 -> 1230
-ddrem900 remainder 123e1 2000000 -> 1230
-ddrem901 remainder 123e1 200000 -> 1230
-ddrem902 remainder 123e1 20000 -> 1230
-ddrem903 remainder 123e1 2000 -> 1230
-ddrem904 remainder 123e1 200 -> 30
-ddrem905 remainder 123e1 20 -> 10
-ddrem906 remainder 123e1 2 -> 0
-
-ddrem910 remainder 123e1 5000000000000000 -> 1230
-ddrem911 remainder 123e1 500000000000000 -> 1230
-ddrem912 remainder 123e1 50000000000000 -> 1230
-ddrem913 remainder 123e1 5000000000000 -> 1230
-ddrem914 remainder 123e1 500000000000 -> 1230
-ddrem915 remainder 123e1 50000000000 -> 1230
-ddrem916 remainder 123e1 5000000000 -> 1230
-ddrem917 remainder 123e1 500000000 -> 1230
-ddrem919 remainder 123e1 50000000 -> 1230
-ddrem920 remainder 123e1 5000000 -> 1230
-ddrem921 remainder 123e1 500000 -> 1230
-ddrem922 remainder 123e1 50000 -> 1230
-ddrem923 remainder 123e1 5000 -> 1230
-ddrem924 remainder 123e1 500 -> 230
-ddrem925 remainder 123e1 50 -> 30
-ddrem926 remainder 123e1 5 -> 0
-
-ddrem930 remainder 123e1 9000000000000000 -> 1230
-ddrem931 remainder 123e1 900000000000000 -> 1230
-ddrem932 remainder 123e1 90000000000000 -> 1230
-ddrem933 remainder 123e1 9000000000000 -> 1230
-ddrem934 remainder 123e1 900000000000 -> 1230
-ddrem935 remainder 123e1 90000000000 -> 1230
-ddrem936 remainder 123e1 9000000000 -> 1230
-ddrem937 remainder 123e1 900000000 -> 1230
-ddrem939 remainder 123e1 90000000 -> 1230
-ddrem940 remainder 123e1 9000000 -> 1230
-ddrem941 remainder 123e1 900000 -> 1230
-ddrem942 remainder 123e1 90000 -> 1230
-ddrem943 remainder 123e1 9000 -> 1230
-ddrem944 remainder 123e1 900 -> 330
-ddrem945 remainder 123e1 90 -> 60
-ddrem946 remainder 123e1 9 -> 6
-
-ddrem950 remainder 123e1 1000000000000000 -> 1230
-ddrem961 remainder 123e1 2999999999999999 -> 1230
-ddrem962 remainder 123e1 3999999999999999 -> 1230
-ddrem963 remainder 123e1 4999999999999999 -> 1230
-ddrem964 remainder 123e1 5999999999999999 -> 1230
-ddrem965 remainder 123e1 6999999999999999 -> 1230
-ddrem966 remainder 123e1 7999999999999999 -> 1230
-ddrem967 remainder 123e1 8999999999999999 -> 1230
-ddrem968 remainder 123e1 9999999999999999 -> 1230
-ddrem969 remainder 123e1 9876543210987654 -> 1230
-
-ddrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-ddrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
-ddrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
-ddrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
-ddrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
-ddrem1055 remainder 1e-277 1e+311 -> 1E-277
-ddrem1056 remainder 1e-277 -1e+311 -> 1E-277
-ddrem1057 remainder -1e-277 1e+311 -> -1E-277
-ddrem1058 remainder -1e-277 -1e+311 -> -1E-277
-
--- destructive subtract
-ddrem1101 remainder 1234567890123456 1.000000000000001 -> 0.765432109876546
-ddrem1102 remainder 1234567890123456 1.00000000000001 -> 0.65432109876557
-ddrem1103 remainder 1234567890123456 1.0000000000001 -> 0.5432109876668
-ddrem1104 remainder 1234567890123455 4.000000000000001 -> 2.691358027469137
-ddrem1105 remainder 1234567890123456 4.000000000000001 -> 3.691358027469137
-ddrem1106 remainder 1234567890123456 4.9999999999999 -> 0.6913578024696
-ddrem1107 remainder 1234567890123456 4.99999999999999 -> 3.46913578024691
-ddrem1108 remainder 1234567890123456 4.999999999999999 -> 1.246913578024691
-ddrem1109 remainder 1234567890123456 5.000000000000001 -> 0.753086421975309
-ddrem1110 remainder 1234567890123456 5.00000000000001 -> 3.53086421975310
-ddrem1111 remainder 1234567890123456 5.0000000000001 -> 1.3086421975314
-
--- Null tests
-ddrem1000 remainder 10 # -> NaN Invalid_operation
-ddrem1001 remainder # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddRemainder.decTest -- decDouble remainder --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks (as base, above)
+ddrem001 remainder 1 1 -> 0
+ddrem002 remainder 2 1 -> 0
+ddrem003 remainder 1 2 -> 1
+ddrem004 remainder 2 2 -> 0
+ddrem005 remainder 0 1 -> 0
+ddrem006 remainder 0 2 -> 0
+ddrem007 remainder 1 3 -> 1
+ddrem008 remainder 2 3 -> 2
+ddrem009 remainder 3 3 -> 0
+
+ddrem010 remainder 2.4 1 -> 0.4
+ddrem011 remainder 2.4 -1 -> 0.4
+ddrem012 remainder -2.4 1 -> -0.4
+ddrem013 remainder -2.4 -1 -> -0.4
+ddrem014 remainder 2.40 1 -> 0.40
+ddrem015 remainder 2.400 1 -> 0.400
+ddrem016 remainder 2.4 2 -> 0.4
+ddrem017 remainder 2.400 2 -> 0.400
+ddrem018 remainder 2. 2 -> 0
+ddrem019 remainder 20 20 -> 0
+
+ddrem020 remainder 187 187 -> 0
+ddrem021 remainder 5 2 -> 1
+ddrem022 remainder 5 2.0 -> 1.0
+ddrem023 remainder 5 2.000 -> 1.000
+ddrem024 remainder 5 0.200 -> 0.000
+ddrem025 remainder 5 0.200 -> 0.000
+
+ddrem030 remainder 1 2 -> 1
+ddrem031 remainder 1 4 -> 1
+ddrem032 remainder 1 8 -> 1
+
+ddrem033 remainder 1 16 -> 1
+ddrem034 remainder 1 32 -> 1
+ddrem035 remainder 1 64 -> 1
+ddrem040 remainder 1 -2 -> 1
+ddrem041 remainder 1 -4 -> 1
+ddrem042 remainder 1 -8 -> 1
+ddrem043 remainder 1 -16 -> 1
+ddrem044 remainder 1 -32 -> 1
+ddrem045 remainder 1 -64 -> 1
+ddrem050 remainder -1 2 -> -1
+ddrem051 remainder -1 4 -> -1
+ddrem052 remainder -1 8 -> -1
+ddrem053 remainder -1 16 -> -1
+ddrem054 remainder -1 32 -> -1
+ddrem055 remainder -1 64 -> -1
+ddrem060 remainder -1 -2 -> -1
+ddrem061 remainder -1 -4 -> -1
+ddrem062 remainder -1 -8 -> -1
+ddrem063 remainder -1 -16 -> -1
+ddrem064 remainder -1 -32 -> -1
+ddrem065 remainder -1 -64 -> -1
+
+ddrem066 remainder 999999999 1 -> 0
+ddrem067 remainder 999999999.4 1 -> 0.4
+ddrem068 remainder 999999999.5 1 -> 0.5
+ddrem069 remainder 999999999.9 1 -> 0.9
+ddrem070 remainder 999999999.999 1 -> 0.999
+ddrem071 remainder 999999.999999 1 -> 0.999999
+ddrem072 remainder 9 1 -> 0
+ddrem073 remainder 9999999999999999 1 -> 0
+ddrem074 remainder 9999999999999999 2 -> 1
+ddrem075 remainder 9999999999999999 3 -> 0
+ddrem076 remainder 9999999999999999 4 -> 3
+
+ddrem080 remainder 0. 1 -> 0
+ddrem081 remainder .0 1 -> 0.0
+ddrem082 remainder 0.00 1 -> 0.00
+ddrem083 remainder 0.00E+9 1 -> 0
+ddrem084 remainder 0.00E+3 1 -> 0
+ddrem085 remainder 0.00E+2 1 -> 0
+ddrem086 remainder 0.00E+1 1 -> 0.0
+ddrem087 remainder 0.00E+0 1 -> 0.00
+ddrem088 remainder 0.00E-0 1 -> 0.00
+ddrem089 remainder 0.00E-1 1 -> 0.000
+ddrem090 remainder 0.00E-2 1 -> 0.0000
+ddrem091 remainder 0.00E-3 1 -> 0.00000
+ddrem092 remainder 0.00E-4 1 -> 0.000000
+ddrem093 remainder 0.00E-5 1 -> 0E-7
+ddrem094 remainder 0.00E-6 1 -> 0E-8
+ddrem095 remainder 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remainder by 0
+ddrem101 remainder 0 0 -> NaN Division_undefined
+ddrem102 remainder 0 -0 -> NaN Division_undefined
+ddrem103 remainder -0 0 -> NaN Division_undefined
+ddrem104 remainder -0 -0 -> NaN Division_undefined
+ddrem105 remainder 0.0E5 0 -> NaN Division_undefined
+ddrem106 remainder 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+ddrem107 remainder 0.0001 0 -> NaN Invalid_operation
+ddrem108 remainder 0.01 0 -> NaN Invalid_operation
+ddrem109 remainder 0.1 0 -> NaN Invalid_operation
+ddrem110 remainder 1 0 -> NaN Invalid_operation
+ddrem111 remainder 1 0.0 -> NaN Invalid_operation
+ddrem112 remainder 10 0.0 -> NaN Invalid_operation
+ddrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
+ddrem114 remainder 1E+380 0 -> NaN Invalid_operation
+ddrem115 remainder 0.0001 -0 -> NaN Invalid_operation
+ddrem116 remainder 0.01 -0 -> NaN Invalid_operation
+ddrem119 remainder 0.1 -0 -> NaN Invalid_operation
+ddrem120 remainder 1 -0 -> NaN Invalid_operation
+ddrem121 remainder 1 -0.0 -> NaN Invalid_operation
+ddrem122 remainder 10 -0.0 -> NaN Invalid_operation
+ddrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
+ddrem124 remainder 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+ddrem130 remainder 0 1 -> 0
+ddrem131 remainder 0 -1 -> 0
+ddrem132 remainder 0.0 1 -> 0.0
+ddrem133 remainder 0.0 -1 -> 0.0
+ddrem134 remainder -0 1 -> -0
+ddrem135 remainder -0 -1 -> -0
+ddrem136 remainder -0.0 1 -> -0.0
+ddrem137 remainder -0.0 -1 -> -0.0
+
+-- 0.5ers
+ddrem143 remainder 0.5 2 -> 0.5
+ddrem144 remainder 0.5 2.1 -> 0.5
+ddrem145 remainder 0.5 2.01 -> 0.50
+ddrem146 remainder 0.5 2.001 -> 0.500
+ddrem147 remainder 0.50 2 -> 0.50
+ddrem148 remainder 0.50 2.01 -> 0.50
+ddrem149 remainder 0.50 2.001 -> 0.500
+
+-- steadies
+ddrem150 remainder 1 1 -> 0
+ddrem151 remainder 1 2 -> 1
+ddrem152 remainder 1 3 -> 1
+ddrem153 remainder 1 4 -> 1
+ddrem154 remainder 1 5 -> 1
+ddrem155 remainder 1 6 -> 1
+ddrem156 remainder 1 7 -> 1
+ddrem157 remainder 1 8 -> 1
+ddrem158 remainder 1 9 -> 1
+ddrem159 remainder 1 10 -> 1
+ddrem160 remainder 1 1 -> 0
+ddrem161 remainder 2 1 -> 0
+ddrem162 remainder 3 1 -> 0
+ddrem163 remainder 4 1 -> 0
+ddrem164 remainder 5 1 -> 0
+ddrem165 remainder 6 1 -> 0
+ddrem166 remainder 7 1 -> 0
+ddrem167 remainder 8 1 -> 0
+ddrem168 remainder 9 1 -> 0
+ddrem169 remainder 10 1 -> 0
+
+-- some differences from remainderNear
+ddrem171 remainder 0.4 1.020 -> 0.400
+ddrem172 remainder 0.50 1.020 -> 0.500
+ddrem173 remainder 0.51 1.020 -> 0.510
+ddrem174 remainder 0.52 1.020 -> 0.520
+ddrem175 remainder 0.6 1.020 -> 0.600
+
+-- More flavours of remainder by 0
+ddrem201 remainder 0 0 -> NaN Division_undefined
+ddrem202 remainder 0.0E5 0 -> NaN Division_undefined
+ddrem203 remainder 0.000 0 -> NaN Division_undefined
+ddrem204 remainder 0.0001 0 -> NaN Invalid_operation
+ddrem205 remainder 0.01 0 -> NaN Invalid_operation
+ddrem206 remainder 0.1 0 -> NaN Invalid_operation
+ddrem207 remainder 1 0 -> NaN Invalid_operation
+ddrem208 remainder 1 0.0 -> NaN Invalid_operation
+ddrem209 remainder 10 0.0 -> NaN Invalid_operation
+ddrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
+ddrem211 remainder 1E+380 0 -> NaN Invalid_operation
+
+-- some differences from remainderNear
+ddrem231 remainder -0.4 1.020 -> -0.400
+ddrem232 remainder -0.50 1.020 -> -0.500
+ddrem233 remainder -0.51 1.020 -> -0.510
+ddrem234 remainder -0.52 1.020 -> -0.520
+ddrem235 remainder -0.6 1.020 -> -0.600
+
+-- high Xs
+ddrem240 remainder 1E+2 1.00 -> 0.00
+
+-- ddrem3xx are from DiagBigDecimal
+ddrem301 remainder 1 3 -> 1
+ddrem302 remainder 5 5 -> 0
+ddrem303 remainder 13 10 -> 3
+ddrem304 remainder 13 50 -> 13
+ddrem305 remainder 13 100 -> 13
+ddrem306 remainder 13 1000 -> 13
+ddrem307 remainder .13 1 -> 0.13
+ddrem308 remainder 0.133 1 -> 0.133
+ddrem309 remainder 0.1033 1 -> 0.1033
+ddrem310 remainder 1.033 1 -> 0.033
+ddrem311 remainder 10.33 1 -> 0.33
+ddrem312 remainder 10.33 10 -> 0.33
+ddrem313 remainder 103.3 1 -> 0.3
+ddrem314 remainder 133 10 -> 3
+ddrem315 remainder 1033 10 -> 3
+ddrem316 remainder 1033 50 -> 33
+ddrem317 remainder 101.0 3 -> 2.0
+ddrem318 remainder 102.0 3 -> 0.0
+ddrem319 remainder 103.0 3 -> 1.0
+ddrem320 remainder 2.40 1 -> 0.40
+ddrem321 remainder 2.400 1 -> 0.400
+ddrem322 remainder 2.4 1 -> 0.4
+ddrem323 remainder 2.4 2 -> 0.4
+ddrem324 remainder 2.400 2 -> 0.400
+ddrem325 remainder 1 0.3 -> 0.1
+ddrem326 remainder 1 0.30 -> 0.10
+ddrem327 remainder 1 0.300 -> 0.100
+ddrem328 remainder 1 0.3000 -> 0.1000
+ddrem329 remainder 1.0 0.3 -> 0.1
+ddrem330 remainder 1.00 0.3 -> 0.10
+ddrem331 remainder 1.000 0.3 -> 0.100
+ddrem332 remainder 1.0000 0.3 -> 0.1000
+ddrem333 remainder 0.5 2 -> 0.5
+ddrem334 remainder 0.5 2.1 -> 0.5
+ddrem335 remainder 0.5 2.01 -> 0.50
+ddrem336 remainder 0.5 2.001 -> 0.500
+ddrem337 remainder 0.50 2 -> 0.50
+ddrem338 remainder 0.50 2.01 -> 0.50
+ddrem339 remainder 0.50 2.001 -> 0.500
+
+ddrem340 remainder 0.5 0.5000001 -> 0.5000000
+ddrem341 remainder 0.5 0.50000001 -> 0.50000000
+ddrem342 remainder 0.5 0.500000001 -> 0.500000000
+ddrem343 remainder 0.5 0.5000000001 -> 0.5000000000
+ddrem344 remainder 0.5 0.50000000001 -> 0.50000000000
+ddrem345 remainder 0.5 0.4999999 -> 1E-7
+ddrem346 remainder 0.5 0.49999999 -> 1E-8
+ddrem347 remainder 0.5 0.499999999 -> 1E-9
+ddrem348 remainder 0.5 0.4999999999 -> 1E-10
+ddrem349 remainder 0.5 0.49999999999 -> 1E-11
+ddrem350 remainder 0.5 0.499999999999 -> 1E-12
+
+ddrem351 remainder 0.03 7 -> 0.03
+ddrem352 remainder 5 2 -> 1
+ddrem353 remainder 4.1 2 -> 0.1
+ddrem354 remainder 4.01 2 -> 0.01
+ddrem355 remainder 4.001 2 -> 0.001
+ddrem356 remainder 4.0001 2 -> 0.0001
+ddrem357 remainder 4.00001 2 -> 0.00001
+ddrem358 remainder 4.000001 2 -> 0.000001
+ddrem359 remainder 4.0000001 2 -> 1E-7
+
+ddrem360 remainder 1.2 0.7345 -> 0.4655
+ddrem361 remainder 0.8 12 -> 0.8
+ddrem362 remainder 0.8 0.2 -> 0.0
+ddrem363 remainder 0.8 0.3 -> 0.2
+ddrem364 remainder 0.800 12 -> 0.800
+ddrem365 remainder 0.800 1.7 -> 0.800
+ddrem366 remainder 2.400 2 -> 0.400
+
+ddrem371 remainder 2.400 2 -> 0.400
+
+ddrem381 remainder 12345 1 -> 0
+ddrem382 remainder 12345 1.0001 -> 0.7657
+ddrem383 remainder 12345 1.001 -> 0.668
+ddrem384 remainder 12345 1.01 -> 0.78
+ddrem385 remainder 12345 1.1 -> 0.8
+ddrem386 remainder 12355 4 -> 3
+ddrem387 remainder 12345 4 -> 1
+ddrem388 remainder 12355 4.0001 -> 2.6912
+ddrem389 remainder 12345 4.0001 -> 0.6914
+ddrem390 remainder 12345 4.9 -> 1.9
+ddrem391 remainder 12345 4.99 -> 4.73
+ddrem392 remainder 12345 4.999 -> 2.469
+ddrem393 remainder 12345 4.9999 -> 0.2469
+ddrem394 remainder 12345 5 -> 0
+ddrem395 remainder 12345 5.0001 -> 4.7532
+ddrem396 remainder 12345 5.001 -> 2.532
+ddrem397 remainder 12345 5.01 -> 0.36
+ddrem398 remainder 12345 5.1 -> 3.0
+
+-- the nasty division-by-1 cases
+ddrem401 remainder 0.5 1 -> 0.5
+ddrem402 remainder 0.55 1 -> 0.55
+ddrem403 remainder 0.555 1 -> 0.555
+ddrem404 remainder 0.5555 1 -> 0.5555
+ddrem405 remainder 0.55555 1 -> 0.55555
+ddrem406 remainder 0.555555 1 -> 0.555555
+ddrem407 remainder 0.5555555 1 -> 0.5555555
+ddrem408 remainder 0.55555555 1 -> 0.55555555
+ddrem409 remainder 0.555555555 1 -> 0.555555555
+
+-- folddowns
+ddrem421 remainder 1E+384 1 -> NaN Division_impossible
+ddrem422 remainder 1E+384 1E+383 -> 0E+369 Clamped
+ddrem423 remainder 1E+384 2E+383 -> 0E+369 Clamped
+ddrem424 remainder 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
+ddrem425 remainder 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
+ddrem426 remainder 1E+384 5E+383 -> 0E+369 Clamped
+ddrem427 remainder 1E+384 6E+383 -> 4.00000000000000E+383 Clamped
+ddrem428 remainder 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
+ddrem429 remainder 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
+ddrem430 remainder 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
+-- tinies
+ddrem431 remainder 1E-397 1E-398 -> 0E-398
+ddrem432 remainder 1E-397 2E-398 -> 0E-398
+ddrem433 remainder 1E-397 3E-398 -> 1E-398 Subnormal
+ddrem434 remainder 1E-397 4E-398 -> 2E-398 Subnormal
+ddrem435 remainder 1E-397 5E-398 -> 0E-398
+ddrem436 remainder 1E-397 6E-398 -> 4E-398 Subnormal
+ddrem437 remainder 1E-397 7E-398 -> 3E-398 Subnormal
+ddrem438 remainder 1E-397 8E-398 -> 2E-398 Subnormal
+ddrem439 remainder 1E-397 9E-398 -> 1E-398 Subnormal
+ddrem440 remainder 1E-397 10E-398 -> 0E-398
+ddrem441 remainder 1E-397 11E-398 -> 1.0E-397 Subnormal
+ddrem442 remainder 100E-397 11E-398 -> 1.0E-397 Subnormal
+ddrem443 remainder 100E-397 20E-398 -> 0E-398
+ddrem444 remainder 100E-397 21E-398 -> 1.3E-397 Subnormal
+ddrem445 remainder 100E-397 30E-398 -> 1.0E-397 Subnormal
+
+-- zero signs
+ddrem650 remainder 1 1 -> 0
+ddrem651 remainder -1 1 -> -0
+ddrem652 remainder 1 -1 -> 0
+ddrem653 remainder -1 -1 -> -0
+ddrem654 remainder 0 1 -> 0
+ddrem655 remainder -0 1 -> -0
+ddrem656 remainder 0 -1 -> 0
+ddrem657 remainder -0 -1 -> -0
+ddrem658 remainder 0.00 1 -> 0.00
+ddrem659 remainder -0.00 1 -> -0.00
+
+-- Specials
+ddrem680 remainder Inf -Inf -> NaN Invalid_operation
+ddrem681 remainder Inf -1000 -> NaN Invalid_operation
+ddrem682 remainder Inf -1 -> NaN Invalid_operation
+ddrem683 remainder Inf 0 -> NaN Invalid_operation
+ddrem684 remainder Inf -0 -> NaN Invalid_operation
+ddrem685 remainder Inf 1 -> NaN Invalid_operation
+ddrem686 remainder Inf 1000 -> NaN Invalid_operation
+ddrem687 remainder Inf Inf -> NaN Invalid_operation
+ddrem688 remainder -1000 Inf -> -1000
+ddrem689 remainder -Inf Inf -> NaN Invalid_operation
+ddrem691 remainder -1 Inf -> -1
+ddrem692 remainder 0 Inf -> 0
+ddrem693 remainder -0 Inf -> -0
+ddrem694 remainder 1 Inf -> 1
+ddrem695 remainder 1000 Inf -> 1000
+ddrem696 remainder Inf Inf -> NaN Invalid_operation
+
+ddrem700 remainder -Inf -Inf -> NaN Invalid_operation
+ddrem701 remainder -Inf -1000 -> NaN Invalid_operation
+ddrem702 remainder -Inf -1 -> NaN Invalid_operation
+ddrem703 remainder -Inf -0 -> NaN Invalid_operation
+ddrem704 remainder -Inf 0 -> NaN Invalid_operation
+ddrem705 remainder -Inf 1 -> NaN Invalid_operation
+ddrem706 remainder -Inf 1000 -> NaN Invalid_operation
+ddrem707 remainder -Inf Inf -> NaN Invalid_operation
+ddrem708 remainder -Inf -Inf -> NaN Invalid_operation
+ddrem709 remainder -1000 Inf -> -1000
+ddrem710 remainder -1 -Inf -> -1
+ddrem711 remainder -0 -Inf -> -0
+ddrem712 remainder 0 -Inf -> 0
+ddrem713 remainder 1 -Inf -> 1
+ddrem714 remainder 1000 -Inf -> 1000
+ddrem715 remainder Inf -Inf -> NaN Invalid_operation
+
+ddrem721 remainder NaN -Inf -> NaN
+ddrem722 remainder NaN -1000 -> NaN
+ddrem723 remainder NaN -1 -> NaN
+ddrem724 remainder NaN -0 -> NaN
+ddrem725 remainder -NaN 0 -> -NaN
+ddrem726 remainder NaN 1 -> NaN
+ddrem727 remainder NaN 1000 -> NaN
+ddrem728 remainder NaN Inf -> NaN
+ddrem729 remainder NaN -NaN -> NaN
+ddrem730 remainder -Inf NaN -> NaN
+ddrem731 remainder -1000 NaN -> NaN
+ddrem732 remainder -1 NaN -> NaN
+ddrem733 remainder -0 -NaN -> -NaN
+ddrem734 remainder 0 NaN -> NaN
+ddrem735 remainder 1 -NaN -> -NaN
+ddrem736 remainder 1000 NaN -> NaN
+ddrem737 remainder Inf NaN -> NaN
+
+ddrem741 remainder sNaN -Inf -> NaN Invalid_operation
+ddrem742 remainder sNaN -1000 -> NaN Invalid_operation
+ddrem743 remainder -sNaN -1 -> -NaN Invalid_operation
+ddrem744 remainder sNaN -0 -> NaN Invalid_operation
+ddrem745 remainder sNaN 0 -> NaN Invalid_operation
+ddrem746 remainder sNaN 1 -> NaN Invalid_operation
+ddrem747 remainder sNaN 1000 -> NaN Invalid_operation
+ddrem749 remainder sNaN NaN -> NaN Invalid_operation
+ddrem750 remainder sNaN sNaN -> NaN Invalid_operation
+ddrem751 remainder NaN sNaN -> NaN Invalid_operation
+ddrem752 remainder -Inf sNaN -> NaN Invalid_operation
+ddrem753 remainder -1000 sNaN -> NaN Invalid_operation
+ddrem754 remainder -1 sNaN -> NaN Invalid_operation
+ddrem755 remainder -0 sNaN -> NaN Invalid_operation
+ddrem756 remainder 0 sNaN -> NaN Invalid_operation
+ddrem757 remainder 1 sNaN -> NaN Invalid_operation
+ddrem758 remainder 1000 sNaN -> NaN Invalid_operation
+ddrem759 remainder Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+ddrem760 remainder NaN1 NaN7 -> NaN1
+ddrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
+ddrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
+ddrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
+ddrem764 remainder 15 NaN11 -> NaN11
+ddrem765 remainder NaN6 NaN12 -> NaN6
+ddrem766 remainder Inf NaN13 -> NaN13
+ddrem767 remainder NaN14 -Inf -> NaN14
+ddrem768 remainder 0 NaN15 -> NaN15
+ddrem769 remainder NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+ddrem770 remainder 1234567890123456 10 -> 6
+ddrem771 remainder 1234567890123456 1 -> 0
+ddrem772 remainder 1234567890123456 0.1 -> NaN Division_impossible
+ddrem773 remainder 1234567890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+ddrem801 remainder 12345678000 100 -> 0
+ddrem802 remainder 1 12345678000 -> 1
+ddrem803 remainder 1234567800 10 -> 0
+ddrem804 remainder 1 1234567800 -> 1
+ddrem805 remainder 1234567890 10 -> 0
+ddrem806 remainder 1 1234567890 -> 1
+ddrem807 remainder 1234567891 10 -> 1
+ddrem808 remainder 1 1234567891 -> 1
+ddrem809 remainder 12345678901 100 -> 1
+ddrem810 remainder 1 12345678901 -> 1
+ddrem811 remainder 1234567896 10 -> 6
+ddrem812 remainder 1 1234567896 -> 1
+
+ddrem821 remainder 12345678000 100 -> 0
+ddrem822 remainder 1 12345678000 -> 1
+ddrem823 remainder 1234567800 10 -> 0
+ddrem824 remainder 1 1234567800 -> 1
+ddrem825 remainder 1234567890 10 -> 0
+ddrem826 remainder 1 1234567890 -> 1
+ddrem827 remainder 1234567891 10 -> 1
+ddrem828 remainder 1 1234567891 -> 1
+ddrem829 remainder 12345678901 100 -> 1
+ddrem830 remainder 1 12345678901 -> 1
+ddrem831 remainder 1234567896 10 -> 6
+ddrem832 remainder 1 1234567896 -> 1
+
+-- from divideint
+ddrem840 remainder 100000000.0 1 -> 0.0
+ddrem841 remainder 100000000.4 1 -> 0.4
+ddrem842 remainder 100000000.5 1 -> 0.5
+ddrem843 remainder 100000000.9 1 -> 0.9
+ddrem844 remainder 100000000.999 1 -> 0.999
+ddrem850 remainder 100000003 5 -> 3
+ddrem851 remainder 10000003 5 -> 3
+ddrem852 remainder 1000003 5 -> 3
+ddrem853 remainder 100003 5 -> 3
+ddrem854 remainder 10003 5 -> 3
+ddrem855 remainder 1003 5 -> 3
+ddrem856 remainder 103 5 -> 3
+ddrem857 remainder 13 5 -> 3
+ddrem858 remainder 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+ddrem860 remainder 123.0e1 1000000000000000 -> 1230
+ddrem861 remainder 1230 1000000000000000 -> 1230
+ddrem862 remainder 12.3e2 1000000000000000 -> 1230
+ddrem863 remainder 1.23e3 1000000000000000 -> 1230
+ddrem864 remainder 123e1 1000000000000000 -> 1230
+ddrem870 remainder 123e1 1000000000000000 -> 1230
+ddrem871 remainder 123e1 100000000000000 -> 1230
+ddrem872 remainder 123e1 10000000000000 -> 1230
+ddrem873 remainder 123e1 1000000000000 -> 1230
+ddrem874 remainder 123e1 100000000000 -> 1230
+ddrem875 remainder 123e1 10000000000 -> 1230
+ddrem876 remainder 123e1 1000000000 -> 1230
+ddrem877 remainder 123e1 100000000 -> 1230
+ddrem878 remainder 1230 100000000 -> 1230
+ddrem879 remainder 123e1 10000000 -> 1230
+ddrem880 remainder 123e1 1000000 -> 1230
+ddrem881 remainder 123e1 100000 -> 1230
+ddrem882 remainder 123e1 10000 -> 1230
+ddrem883 remainder 123e1 1000 -> 230
+ddrem884 remainder 123e1 100 -> 30
+ddrem885 remainder 123e1 10 -> 0
+ddrem886 remainder 123e1 1 -> 0
+
+ddrem890 remainder 123e1 2000000000000000 -> 1230
+ddrem891 remainder 123e1 200000000000000 -> 1230
+ddrem892 remainder 123e1 20000000000000 -> 1230
+ddrem893 remainder 123e1 2000000000000 -> 1230
+ddrem894 remainder 123e1 200000000000 -> 1230
+ddrem895 remainder 123e1 20000000000 -> 1230
+ddrem896 remainder 123e1 2000000000 -> 1230
+ddrem897 remainder 123e1 200000000 -> 1230
+ddrem899 remainder 123e1 20000000 -> 1230
+ddrem900 remainder 123e1 2000000 -> 1230
+ddrem901 remainder 123e1 200000 -> 1230
+ddrem902 remainder 123e1 20000 -> 1230
+ddrem903 remainder 123e1 2000 -> 1230
+ddrem904 remainder 123e1 200 -> 30
+ddrem905 remainder 123e1 20 -> 10
+ddrem906 remainder 123e1 2 -> 0
+
+ddrem910 remainder 123e1 5000000000000000 -> 1230
+ddrem911 remainder 123e1 500000000000000 -> 1230
+ddrem912 remainder 123e1 50000000000000 -> 1230
+ddrem913 remainder 123e1 5000000000000 -> 1230
+ddrem914 remainder 123e1 500000000000 -> 1230
+ddrem915 remainder 123e1 50000000000 -> 1230
+ddrem916 remainder 123e1 5000000000 -> 1230
+ddrem917 remainder 123e1 500000000 -> 1230
+ddrem919 remainder 123e1 50000000 -> 1230
+ddrem920 remainder 123e1 5000000 -> 1230
+ddrem921 remainder 123e1 500000 -> 1230
+ddrem922 remainder 123e1 50000 -> 1230
+ddrem923 remainder 123e1 5000 -> 1230
+ddrem924 remainder 123e1 500 -> 230
+ddrem925 remainder 123e1 50 -> 30
+ddrem926 remainder 123e1 5 -> 0
+
+ddrem930 remainder 123e1 9000000000000000 -> 1230
+ddrem931 remainder 123e1 900000000000000 -> 1230
+ddrem932 remainder 123e1 90000000000000 -> 1230
+ddrem933 remainder 123e1 9000000000000 -> 1230
+ddrem934 remainder 123e1 900000000000 -> 1230
+ddrem935 remainder 123e1 90000000000 -> 1230
+ddrem936 remainder 123e1 9000000000 -> 1230
+ddrem937 remainder 123e1 900000000 -> 1230
+ddrem939 remainder 123e1 90000000 -> 1230
+ddrem940 remainder 123e1 9000000 -> 1230
+ddrem941 remainder 123e1 900000 -> 1230
+ddrem942 remainder 123e1 90000 -> 1230
+ddrem943 remainder 123e1 9000 -> 1230
+ddrem944 remainder 123e1 900 -> 330
+ddrem945 remainder 123e1 90 -> 60
+ddrem946 remainder 123e1 9 -> 6
+
+ddrem950 remainder 123e1 1000000000000000 -> 1230
+ddrem961 remainder 123e1 2999999999999999 -> 1230
+ddrem962 remainder 123e1 3999999999999999 -> 1230
+ddrem963 remainder 123e1 4999999999999999 -> 1230
+ddrem964 remainder 123e1 5999999999999999 -> 1230
+ddrem965 remainder 123e1 6999999999999999 -> 1230
+ddrem966 remainder 123e1 7999999999999999 -> 1230
+ddrem967 remainder 123e1 8999999999999999 -> 1230
+ddrem968 remainder 123e1 9999999999999999 -> 1230
+ddrem969 remainder 123e1 9876543210987654 -> 1230
+
+ddrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+ddrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
+ddrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
+ddrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
+ddrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
+ddrem1055 remainder 1e-277 1e+311 -> 1E-277
+ddrem1056 remainder 1e-277 -1e+311 -> 1E-277
+ddrem1057 remainder -1e-277 1e+311 -> -1E-277
+ddrem1058 remainder -1e-277 -1e+311 -> -1E-277
+
+-- destructive subtract
+ddrem1101 remainder 1234567890123456 1.000000000000001 -> 0.765432109876546
+ddrem1102 remainder 1234567890123456 1.00000000000001 -> 0.65432109876557
+ddrem1103 remainder 1234567890123456 1.0000000000001 -> 0.5432109876668
+ddrem1104 remainder 1234567890123455 4.000000000000001 -> 2.691358027469137
+ddrem1105 remainder 1234567890123456 4.000000000000001 -> 3.691358027469137
+ddrem1106 remainder 1234567890123456 4.9999999999999 -> 0.6913578024696
+ddrem1107 remainder 1234567890123456 4.99999999999999 -> 3.46913578024691
+ddrem1108 remainder 1234567890123456 4.999999999999999 -> 1.246913578024691
+ddrem1109 remainder 1234567890123456 5.000000000000001 -> 0.753086421975309
+ddrem1110 remainder 1234567890123456 5.00000000000001 -> 3.53086421975310
+ddrem1111 remainder 1234567890123456 5.0000000000001 -> 1.3086421975314
+
+-- Null tests
+ddrem1000 remainder 10 # -> NaN Invalid_operation
+ddrem1001 remainder # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddRemainderNear.decTest b/Lib/test/decimaltestdata/ddRemainderNear.decTest
index 8da9afc4c30..6ba64ebafe9 100644
--- a/Lib/test/decimaltestdata/ddRemainderNear.decTest
+++ b/Lib/test/decimaltestdata/ddRemainderNear.decTest
@@ -1,629 +1,629 @@
-------------------------------------------------------------------------
--- ddRemainderNear.decTest -- decDouble remainder-near --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- sanity checks (as base, above)
-ddrmn001 remaindernear 1 1 -> 0
-ddrmn002 remaindernear 2 1 -> 0
-ddrmn003 remaindernear 1 2 -> 1
-ddrmn004 remaindernear 2 2 -> 0
-ddrmn005 remaindernear 0 1 -> 0
-ddrmn006 remaindernear 0 2 -> 0
-ddrmn007 remaindernear 1 3 -> 1
-ddrmn008 remaindernear 2 3 -> -1
-ddrmn009 remaindernear 3 3 -> 0
-
-ddrmn010 remaindernear 2.4 1 -> 0.4
-ddrmn011 remaindernear 2.4 -1 -> 0.4
-ddrmn012 remaindernear -2.4 1 -> -0.4
-ddrmn013 remaindernear -2.4 -1 -> -0.4
-ddrmn014 remaindernear 2.40 1 -> 0.40
-ddrmn015 remaindernear 2.400 1 -> 0.400
-ddrmn016 remaindernear 2.4 2 -> 0.4
-ddrmn017 remaindernear 2.400 2 -> 0.400
-ddrmn018 remaindernear 2. 2 -> 0
-ddrmn019 remaindernear 20 20 -> 0
-
-ddrmn020 remaindernear 187 187 -> 0
-ddrmn021 remaindernear 5 2 -> 1
-ddrmn022 remaindernear 5 2.0 -> 1.0
-ddrmn023 remaindernear 5 2.000 -> 1.000
-ddrmn024 remaindernear 5 0.200 -> 0.000
-ddrmn025 remaindernear 5 0.200 -> 0.000
-
-ddrmn030 remaindernear 1 2 -> 1
-ddrmn031 remaindernear 1 4 -> 1
-ddrmn032 remaindernear 1 8 -> 1
-
-ddrmn033 remaindernear 1 16 -> 1
-ddrmn034 remaindernear 1 32 -> 1
-ddrmn035 remaindernear 1 64 -> 1
-ddrmn040 remaindernear 1 -2 -> 1
-ddrmn041 remaindernear 1 -4 -> 1
-ddrmn042 remaindernear 1 -8 -> 1
-ddrmn043 remaindernear 1 -16 -> 1
-ddrmn044 remaindernear 1 -32 -> 1
-ddrmn045 remaindernear 1 -64 -> 1
-ddrmn050 remaindernear -1 2 -> -1
-ddrmn051 remaindernear -1 4 -> -1
-ddrmn052 remaindernear -1 8 -> -1
-ddrmn053 remaindernear -1 16 -> -1
-ddrmn054 remaindernear -1 32 -> -1
-ddrmn055 remaindernear -1 64 -> -1
-ddrmn060 remaindernear -1 -2 -> -1
-ddrmn061 remaindernear -1 -4 -> -1
-ddrmn062 remaindernear -1 -8 -> -1
-ddrmn063 remaindernear -1 -16 -> -1
-ddrmn064 remaindernear -1 -32 -> -1
-ddrmn065 remaindernear -1 -64 -> -1
-
-ddrmn066 remaindernear 9.9 1 -> -0.1
-ddrmn067 remaindernear 99.7 1 -> -0.3
-ddrmn068 remaindernear 999999999 1 -> 0
-ddrmn069 remaindernear 999999999.4 1 -> 0.4
-ddrmn070 remaindernear 999999999.5 1 -> -0.5
-ddrmn071 remaindernear 999999999.9 1 -> -0.1
-ddrmn072 remaindernear 999999999.999 1 -> -0.001
-ddrmn073 remaindernear 999999.999999 1 -> -0.000001
-ddrmn074 remaindernear 9 1 -> 0
-ddrmn075 remaindernear 9999999999999999 1 -> 0
-ddrmn076 remaindernear 9999999999999999 2 -> -1
-ddrmn077 remaindernear 9999999999999999 3 -> 0
-ddrmn078 remaindernear 9999999999999999 4 -> -1
-
-ddrmn080 remaindernear 0. 1 -> 0
-ddrmn081 remaindernear .0 1 -> 0.0
-ddrmn082 remaindernear 0.00 1 -> 0.00
-ddrmn083 remaindernear 0.00E+9 1 -> 0
-ddrmn084 remaindernear 0.00E+3 1 -> 0
-ddrmn085 remaindernear 0.00E+2 1 -> 0
-ddrmn086 remaindernear 0.00E+1 1 -> 0.0
-ddrmn087 remaindernear 0.00E+0 1 -> 0.00
-ddrmn088 remaindernear 0.00E-0 1 -> 0.00
-ddrmn089 remaindernear 0.00E-1 1 -> 0.000
-ddrmn090 remaindernear 0.00E-2 1 -> 0.0000
-ddrmn091 remaindernear 0.00E-3 1 -> 0.00000
-ddrmn092 remaindernear 0.00E-4 1 -> 0.000000
-ddrmn093 remaindernear 0.00E-5 1 -> 0E-7
-ddrmn094 remaindernear 0.00E-6 1 -> 0E-8
-ddrmn095 remaindernear 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remaindernear by 0
-ddrmn101 remaindernear 0 0 -> NaN Division_undefined
-ddrmn102 remaindernear 0 -0 -> NaN Division_undefined
-ddrmn103 remaindernear -0 0 -> NaN Division_undefined
-ddrmn104 remaindernear -0 -0 -> NaN Division_undefined
-ddrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
-ddrmn106 remaindernear 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-ddrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
-ddrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
-ddrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
-ddrmn110 remaindernear 1 0 -> NaN Invalid_operation
-ddrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
-ddrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
-ddrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-ddrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
-ddrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
-ddrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
-ddrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
-ddrmn120 remaindernear 1 -0 -> NaN Invalid_operation
-ddrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
-ddrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
-ddrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
-ddrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-ddrmn130 remaindernear 0 1 -> 0
-ddrmn131 remaindernear 0 -1 -> 0
-ddrmn132 remaindernear 0.0 1 -> 0.0
-ddrmn133 remaindernear 0.0 -1 -> 0.0
-ddrmn134 remaindernear -0 1 -> -0
-ddrmn135 remaindernear -0 -1 -> -0
-ddrmn136 remaindernear -0.0 1 -> -0.0
-ddrmn137 remaindernear -0.0 -1 -> -0.0
-
--- 0.5ers
-ddrmn143 remaindernear 0.5 2 -> 0.5
-ddrmn144 remaindernear 0.5 2.1 -> 0.5
-ddrmn145 remaindernear 0.5 2.01 -> 0.50
-ddrmn146 remaindernear 0.5 2.001 -> 0.500
-ddrmn147 remaindernear 0.50 2 -> 0.50
-ddrmn148 remaindernear 0.50 2.01 -> 0.50
-ddrmn149 remaindernear 0.50 2.001 -> 0.500
-
--- steadies
-ddrmn150 remaindernear 1 1 -> 0
-ddrmn151 remaindernear 1 2 -> 1
-ddrmn152 remaindernear 1 3 -> 1
-ddrmn153 remaindernear 1 4 -> 1
-ddrmn154 remaindernear 1 5 -> 1
-ddrmn155 remaindernear 1 6 -> 1
-ddrmn156 remaindernear 1 7 -> 1
-ddrmn157 remaindernear 1 8 -> 1
-ddrmn158 remaindernear 1 9 -> 1
-ddrmn159 remaindernear 1 10 -> 1
-ddrmn160 remaindernear 1 1 -> 0
-ddrmn161 remaindernear 2 1 -> 0
-ddrmn162 remaindernear 3 1 -> 0
-ddrmn163 remaindernear 4 1 -> 0
-ddrmn164 remaindernear 5 1 -> 0
-ddrmn165 remaindernear 6 1 -> 0
-ddrmn166 remaindernear 7 1 -> 0
-ddrmn167 remaindernear 8 1 -> 0
-ddrmn168 remaindernear 9 1 -> 0
-ddrmn169 remaindernear 10 1 -> 0
-
--- some differences from remainder
-ddrmn171 remaindernear 0.4 1.020 -> 0.400
-ddrmn172 remaindernear 0.50 1.020 -> 0.500
-ddrmn173 remaindernear 0.51 1.020 -> 0.510
-ddrmn174 remaindernear 0.52 1.020 -> -0.500
-ddrmn175 remaindernear 0.6 1.020 -> -0.420
-
--- More flavours of remaindernear by 0
-ddrmn201 remaindernear 0 0 -> NaN Division_undefined
-ddrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
-ddrmn203 remaindernear 0.000 0 -> NaN Division_undefined
-ddrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
-ddrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
-ddrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
-ddrmn207 remaindernear 1 0 -> NaN Invalid_operation
-ddrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
-ddrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
-ddrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-ddrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
-
--- tests from the extended specification
-ddrmn221 remaindernear 2.1 3 -> -0.9
-ddrmn222 remaindernear 10 6 -> -2
-ddrmn223 remaindernear 10 3 -> 1
-ddrmn224 remaindernear -10 3 -> -1
-ddrmn225 remaindernear 10.2 1 -> 0.2
-ddrmn226 remaindernear 10 0.3 -> 0.1
-ddrmn227 remaindernear 3.6 1.3 -> -0.3
-
--- some differences from remainder
-ddrmn231 remaindernear -0.4 1.020 -> -0.400
-ddrmn232 remaindernear -0.50 1.020 -> -0.500
-ddrmn233 remaindernear -0.51 1.020 -> -0.510
-ddrmn234 remaindernear -0.52 1.020 -> 0.500
-ddrmn235 remaindernear -0.6 1.020 -> 0.420
-
--- high Xs
-ddrmn240 remaindernear 1E+2 1.00 -> 0.00
-
--- ddrmn3xx are from DiagBigDecimal
-ddrmn301 remaindernear 1 3 -> 1
-ddrmn302 remaindernear 5 5 -> 0
-ddrmn303 remaindernear 13 10 -> 3
-ddrmn304 remaindernear 13 50 -> 13
-ddrmn305 remaindernear 13 100 -> 13
-ddrmn306 remaindernear 13 1000 -> 13
-ddrmn307 remaindernear .13 1 -> 0.13
-ddrmn308 remaindernear 0.133 1 -> 0.133
-ddrmn309 remaindernear 0.1033 1 -> 0.1033
-ddrmn310 remaindernear 1.033 1 -> 0.033
-ddrmn311 remaindernear 10.33 1 -> 0.33
-ddrmn312 remaindernear 10.33 10 -> 0.33
-ddrmn313 remaindernear 103.3 1 -> 0.3
-ddrmn314 remaindernear 133 10 -> 3
-ddrmn315 remaindernear 1033 10 -> 3
-ddrmn316 remaindernear 1033 50 -> -17
-ddrmn317 remaindernear 101.0 3 -> -1.0
-ddrmn318 remaindernear 102.0 3 -> 0.0
-ddrmn319 remaindernear 103.0 3 -> 1.0
-ddrmn320 remaindernear 2.40 1 -> 0.40
-ddrmn321 remaindernear 2.400 1 -> 0.400
-ddrmn322 remaindernear 2.4 1 -> 0.4
-ddrmn323 remaindernear 2.4 2 -> 0.4
-ddrmn324 remaindernear 2.400 2 -> 0.400
-ddrmn325 remaindernear 1 0.3 -> 0.1
-ddrmn326 remaindernear 1 0.30 -> 0.10
-ddrmn327 remaindernear 1 0.300 -> 0.100
-ddrmn328 remaindernear 1 0.3000 -> 0.1000
-ddrmn329 remaindernear 1.0 0.3 -> 0.1
-ddrmn330 remaindernear 1.00 0.3 -> 0.10
-ddrmn331 remaindernear 1.000 0.3 -> 0.100
-ddrmn332 remaindernear 1.0000 0.3 -> 0.1000
-ddrmn333 remaindernear 0.5 2 -> 0.5
-ddrmn334 remaindernear 0.5 2.1 -> 0.5
-ddrmn335 remaindernear 0.5 2.01 -> 0.50
-ddrmn336 remaindernear 0.5 2.001 -> 0.500
-ddrmn337 remaindernear 0.50 2 -> 0.50
-ddrmn338 remaindernear 0.50 2.01 -> 0.50
-ddrmn339 remaindernear 0.50 2.001 -> 0.500
-
-ddrmn340 remaindernear 0.5 0.5000001 -> -1E-7
-ddrmn341 remaindernear 0.5 0.50000001 -> -1E-8
-ddrmn342 remaindernear 0.5 0.500000001 -> -1E-9
-ddrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
-ddrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
-ddrmn345 remaindernear 0.5 0.4999999 -> 1E-7
-ddrmn346 remaindernear 0.5 0.49999999 -> 1E-8
-ddrmn347 remaindernear 0.5 0.499999999 -> 1E-9
-ddrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
-ddrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
-ddrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
-
-ddrmn351 remaindernear 0.03 7 -> 0.03
-ddrmn352 remaindernear 5 2 -> 1
-ddrmn353 remaindernear 4.1 2 -> 0.1
-ddrmn354 remaindernear 4.01 2 -> 0.01
-ddrmn355 remaindernear 4.001 2 -> 0.001
-ddrmn356 remaindernear 4.0001 2 -> 0.0001
-ddrmn357 remaindernear 4.00001 2 -> 0.00001
-ddrmn358 remaindernear 4.000001 2 -> 0.000001
-ddrmn359 remaindernear 4.0000001 2 -> 1E-7
-
-ddrmn360 remaindernear 1.2 0.7345 -> -0.2690
-ddrmn361 remaindernear 0.8 12 -> 0.8
-ddrmn362 remaindernear 0.8 0.2 -> 0.0
-ddrmn363 remaindernear 0.8 0.3 -> -0.1
-ddrmn364 remaindernear 0.800 12 -> 0.800
-ddrmn365 remaindernear 0.800 1.7 -> 0.800
-ddrmn366 remaindernear 2.400 2 -> 0.400
-
--- round to even
-ddrmn371 remaindernear 121 2 -> 1
-ddrmn372 remaindernear 122 2 -> 0
-ddrmn373 remaindernear 123 2 -> -1
-ddrmn374 remaindernear 124 2 -> 0
-ddrmn375 remaindernear 125 2 -> 1
-ddrmn376 remaindernear 126 2 -> 0
-ddrmn377 remaindernear 127 2 -> -1
-
-ddrmn381 remaindernear 12345 1 -> 0
-ddrmn382 remaindernear 12345 1.0001 -> -0.2344
-ddrmn383 remaindernear 12345 1.001 -> -0.333
-ddrmn384 remaindernear 12345 1.01 -> -0.23
-ddrmn385 remaindernear 12345 1.1 -> -0.3
-ddrmn386 remaindernear 12355 4 -> -1
-ddrmn387 remaindernear 12345 4 -> 1
-ddrmn388 remaindernear 12355 4.0001 -> -1.3089
-ddrmn389 remaindernear 12345 4.0001 -> 0.6914
-ddrmn390 remaindernear 12345 4.9 -> 1.9
-ddrmn391 remaindernear 12345 4.99 -> -0.26
-ddrmn392 remaindernear 12345 4.999 -> 2.469
-ddrmn393 remaindernear 12345 4.9999 -> 0.2469
-ddrmn394 remaindernear 12345 5 -> 0
-ddrmn395 remaindernear 12345 5.0001 -> -0.2469
-ddrmn396 remaindernear 12345 5.001 -> -2.469
-ddrmn397 remaindernear 12345 5.01 -> 0.36
-ddrmn398 remaindernear 12345 5.1 -> -2.1
-
--- the nasty division-by-1 cases
-ddrmn401 remaindernear 0.4 1 -> 0.4
-ddrmn402 remaindernear 0.45 1 -> 0.45
-ddrmn403 remaindernear 0.455 1 -> 0.455
-ddrmn404 remaindernear 0.4555 1 -> 0.4555
-ddrmn405 remaindernear 0.45555 1 -> 0.45555
-ddrmn406 remaindernear 0.455555 1 -> 0.455555
-ddrmn407 remaindernear 0.4555555 1 -> 0.4555555
-ddrmn408 remaindernear 0.45555555 1 -> 0.45555555
-ddrmn409 remaindernear 0.455555555 1 -> 0.455555555
--- with spill... [412 exercises sticktab loop]
-ddrmn411 remaindernear 0.5 1 -> 0.5
-ddrmn412 remaindernear 0.55 1 -> -0.45
-ddrmn413 remaindernear 0.555 1 -> -0.445
-ddrmn414 remaindernear 0.5555 1 -> -0.4445
-ddrmn415 remaindernear 0.55555 1 -> -0.44445
-ddrmn416 remaindernear 0.555555 1 -> -0.444445
-ddrmn417 remaindernear 0.5555555 1 -> -0.4444445
-ddrmn418 remaindernear 0.55555555 1 -> -0.44444445
-ddrmn419 remaindernear 0.555555555 1 -> -0.444444445
-
--- folddowns
-ddrmn421 remaindernear 1E+384 1 -> NaN Division_impossible
-ddrmn422 remaindernear 1E+384 1E+383 -> 0E+369 Clamped
-ddrmn423 remaindernear 1E+384 2E+383 -> 0E+369 Clamped
-ddrmn424 remaindernear 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
-ddrmn425 remaindernear 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
-ddrmn426 remaindernear 1E+384 5E+383 -> 0E+369 Clamped
-ddrmn427 remaindernear 1E+384 6E+383 -> -2.00000000000000E+383 Clamped
-ddrmn428 remaindernear 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
-ddrmn429 remaindernear 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
-ddrmn430 remaindernear 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
--- tinies
-ddrmn431 remaindernear 1E-397 1E-398 -> 0E-398
-ddrmn432 remaindernear 1E-397 2E-398 -> 0E-398
-ddrmn433 remaindernear 1E-397 3E-398 -> 1E-398 Subnormal
-ddrmn434 remaindernear 1E-397 4E-398 -> 2E-398 Subnormal
-ddrmn435 remaindernear 1E-397 5E-398 -> 0E-398
-ddrmn436 remaindernear 1E-397 6E-398 -> -2E-398 Subnormal
-ddrmn437 remaindernear 1E-397 7E-398 -> 3E-398 Subnormal
-ddrmn438 remaindernear 1E-397 8E-398 -> 2E-398 Subnormal
-ddrmn439 remaindernear 1E-397 9E-398 -> 1E-398 Subnormal
-ddrmn440 remaindernear 1E-397 10E-398 -> 0E-398
-ddrmn441 remaindernear 1E-397 11E-398 -> -1E-398 Subnormal
-ddrmn442 remaindernear 100E-397 11E-398 -> -1E-398 Subnormal
-ddrmn443 remaindernear 100E-397 20E-398 -> 0E-398
-ddrmn444 remaindernear 100E-397 21E-398 -> -8E-398 Subnormal
-ddrmn445 remaindernear 100E-397 30E-398 -> 1.0E-397 Subnormal
-
--- zero signs
-ddrmn650 remaindernear 1 1 -> 0
-ddrmn651 remaindernear -1 1 -> -0
-ddrmn652 remaindernear 1 -1 -> 0
-ddrmn653 remaindernear -1 -1 -> -0
-ddrmn654 remaindernear 0 1 -> 0
-ddrmn655 remaindernear -0 1 -> -0
-ddrmn656 remaindernear 0 -1 -> 0
-ddrmn657 remaindernear -0 -1 -> -0
-ddrmn658 remaindernear 0.00 1 -> 0.00
-ddrmn659 remaindernear -0.00 1 -> -0.00
-
--- Specials
-ddrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
-ddrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
-ddrmn682 remaindernear Inf -1 -> NaN Invalid_operation
-ddrmn683 remaindernear Inf 0 -> NaN Invalid_operation
-ddrmn684 remaindernear Inf -0 -> NaN Invalid_operation
-ddrmn685 remaindernear Inf 1 -> NaN Invalid_operation
-ddrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
-ddrmn687 remaindernear Inf Inf -> NaN Invalid_operation
-ddrmn688 remaindernear -1000 Inf -> -1000
-ddrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
-ddrmn691 remaindernear -1 Inf -> -1
-ddrmn692 remaindernear 0 Inf -> 0
-ddrmn693 remaindernear -0 Inf -> -0
-ddrmn694 remaindernear 1 Inf -> 1
-ddrmn695 remaindernear 1000 Inf -> 1000
-ddrmn696 remaindernear Inf Inf -> NaN Invalid_operation
-
-ddrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
-ddrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
-ddrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
-ddrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
-ddrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
-ddrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
-ddrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
-ddrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
-ddrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
-ddrmn709 remaindernear -1000 Inf -> -1000
-ddrmn710 remaindernear -1 -Inf -> -1
-ddrmn711 remaindernear -0 -Inf -> -0
-ddrmn712 remaindernear 0 -Inf -> 0
-ddrmn713 remaindernear 1 -Inf -> 1
-ddrmn714 remaindernear 1000 -Inf -> 1000
-ddrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
-
-ddrmn721 remaindernear NaN -Inf -> NaN
-ddrmn722 remaindernear NaN -1000 -> NaN
-ddrmn723 remaindernear NaN -1 -> NaN
-ddrmn724 remaindernear NaN -0 -> NaN
-ddrmn725 remaindernear -NaN 0 -> -NaN
-ddrmn726 remaindernear NaN 1 -> NaN
-ddrmn727 remaindernear NaN 1000 -> NaN
-ddrmn728 remaindernear NaN Inf -> NaN
-ddrmn729 remaindernear NaN -NaN -> NaN
-ddrmn730 remaindernear -Inf NaN -> NaN
-ddrmn731 remaindernear -1000 NaN -> NaN
-ddrmn732 remaindernear -1 NaN -> NaN
-ddrmn733 remaindernear -0 -NaN -> -NaN
-ddrmn734 remaindernear 0 NaN -> NaN
-ddrmn735 remaindernear 1 -NaN -> -NaN
-ddrmn736 remaindernear 1000 NaN -> NaN
-ddrmn737 remaindernear Inf NaN -> NaN
-
-ddrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
-ddrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
-ddrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
-ddrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
-ddrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
-ddrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
-ddrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
-ddrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
-ddrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
-ddrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
-ddrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
-ddrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
-ddrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
-ddrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
-ddrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
-ddrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
-ddrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
-ddrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-ddrmn760 remaindernear NaN1 NaN7 -> NaN1
-ddrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
-ddrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
-ddrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
-ddrmn764 remaindernear 15 NaN11 -> NaN11
-ddrmn765 remaindernear NaN6 NaN12 -> NaN6
-ddrmn766 remaindernear Inf NaN13 -> NaN13
-ddrmn767 remaindernear NaN14 -Inf -> NaN14
-ddrmn768 remaindernear 0 NaN15 -> NaN15
-ddrmn769 remaindernear NaN16 -0 -> NaN16
-
--- edge cases of impossible
-ddrmn770 remaindernear 1234567890123456 10 -> -4
-ddrmn771 remaindernear 1234567890123456 1 -> 0
-ddrmn772 remaindernear 1234567890123456 0.1 -> NaN Division_impossible
-ddrmn773 remaindernear 1234567890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-ddrmn801 remaindernear 12345678000 100 -> 0
-ddrmn802 remaindernear 1 12345678000 -> 1
-ddrmn803 remaindernear 1234567800 10 -> 0
-ddrmn804 remaindernear 1 1234567800 -> 1
-ddrmn805 remaindernear 1234567890 10 -> 0
-ddrmn806 remaindernear 1 1234567890 -> 1
-ddrmn807 remaindernear 1234567891 10 -> 1
-ddrmn808 remaindernear 1 1234567891 -> 1
-ddrmn809 remaindernear 12345678901 100 -> 1
-ddrmn810 remaindernear 1 12345678901 -> 1
-ddrmn811 remaindernear 1234567896 10 -> -4
-ddrmn812 remaindernear 1 1234567896 -> 1
-
-ddrmn821 remaindernear 12345678000 100 -> 0
-ddrmn822 remaindernear 1 12345678000 -> 1
-ddrmn823 remaindernear 1234567800 10 -> 0
-ddrmn824 remaindernear 1 1234567800 -> 1
-ddrmn825 remaindernear 1234567890 10 -> 0
-ddrmn826 remaindernear 1 1234567890 -> 1
-ddrmn827 remaindernear 1234567891 10 -> 1
-ddrmn828 remaindernear 1 1234567891 -> 1
-ddrmn829 remaindernear 12345678901 100 -> 1
-ddrmn830 remaindernear 1 12345678901 -> 1
-ddrmn831 remaindernear 1234567896 10 -> -4
-ddrmn832 remaindernear 1 1234567896 -> 1
-
--- from divideint
-ddrmn840 remaindernear 100000000.0 1 -> 0.0
-ddrmn841 remaindernear 100000000.4 1 -> 0.4
-ddrmn842 remaindernear 100000000.5 1 -> 0.5
-ddrmn843 remaindernear 100000000.9 1 -> -0.1
-ddrmn844 remaindernear 100000000.999 1 -> -0.001
-ddrmn850 remaindernear 100000003 5 -> -2
-ddrmn851 remaindernear 10000003 5 -> -2
-ddrmn852 remaindernear 1000003 5 -> -2
-ddrmn853 remaindernear 100003 5 -> -2
-ddrmn854 remaindernear 10003 5 -> -2
-ddrmn855 remaindernear 1003 5 -> -2
-ddrmn856 remaindernear 103 5 -> -2
-ddrmn857 remaindernear 13 5 -> -2
-ddrmn858 remaindernear 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-ddrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
-ddrmn861 remaindernear 1230 1000000000000000 -> 1230
-ddrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
-ddrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
-ddrmn864 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn870 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn871 remaindernear 123e1 100000000000000 -> 1230
-ddrmn872 remaindernear 123e1 10000000000000 -> 1230
-ddrmn873 remaindernear 123e1 1000000000000 -> 1230
-ddrmn874 remaindernear 123e1 100000000000 -> 1230
-ddrmn875 remaindernear 123e1 10000000000 -> 1230
-ddrmn876 remaindernear 123e1 1000000000 -> 1230
-ddrmn877 remaindernear 123e1 100000000 -> 1230
-ddrmn878 remaindernear 1230 100000000 -> 1230
-ddrmn879 remaindernear 123e1 10000000 -> 1230
-ddrmn880 remaindernear 123e1 1000000 -> 1230
-ddrmn881 remaindernear 123e1 100000 -> 1230
-ddrmn882 remaindernear 123e1 10000 -> 1230
-ddrmn883 remaindernear 123e1 1000 -> 230
-ddrmn884 remaindernear 123e1 100 -> 30
-ddrmn885 remaindernear 123e1 10 -> 0
-ddrmn886 remaindernear 123e1 1 -> 0
-
-ddrmn890 remaindernear 123e1 2000000000000000 -> 1230
-ddrmn891 remaindernear 123e1 200000000000000 -> 1230
-ddrmn892 remaindernear 123e1 20000000000000 -> 1230
-ddrmn893 remaindernear 123e1 2000000000000 -> 1230
-ddrmn894 remaindernear 123e1 200000000000 -> 1230
-ddrmn895 remaindernear 123e1 20000000000 -> 1230
-ddrmn896 remaindernear 123e1 2000000000 -> 1230
-ddrmn897 remaindernear 123e1 200000000 -> 1230
-ddrmn899 remaindernear 123e1 20000000 -> 1230
-ddrmn900 remaindernear 123e1 2000000 -> 1230
-ddrmn901 remaindernear 123e1 200000 -> 1230
-ddrmn902 remaindernear 123e1 20000 -> 1230
-ddrmn903 remaindernear 123e1 2000 -> -770
-ddrmn904 remaindernear 123e1 200 -> 30
-ddrmn905 remaindernear 123e1 20 -> -10
-ddrmn906 remaindernear 123e1 2 -> 0
-
-ddrmn910 remaindernear 123e1 5000000000000000 -> 1230
-ddrmn911 remaindernear 123e1 500000000000000 -> 1230
-ddrmn912 remaindernear 123e1 50000000000000 -> 1230
-ddrmn913 remaindernear 123e1 5000000000000 -> 1230
-ddrmn914 remaindernear 123e1 500000000000 -> 1230
-ddrmn915 remaindernear 123e1 50000000000 -> 1230
-ddrmn916 remaindernear 123e1 5000000000 -> 1230
-ddrmn917 remaindernear 123e1 500000000 -> 1230
-ddrmn919 remaindernear 123e1 50000000 -> 1230
-ddrmn920 remaindernear 123e1 5000000 -> 1230
-ddrmn921 remaindernear 123e1 500000 -> 1230
-ddrmn922 remaindernear 123e1 50000 -> 1230
-ddrmn923 remaindernear 123e1 5000 -> 1230
-ddrmn924 remaindernear 123e1 500 -> 230
-ddrmn925 remaindernear 123e1 50 -> -20
-ddrmn926 remaindernear 123e1 5 -> 0
-
-ddrmn930 remaindernear 123e1 9000000000000000 -> 1230
-ddrmn931 remaindernear 123e1 900000000000000 -> 1230
-ddrmn932 remaindernear 123e1 90000000000000 -> 1230
-ddrmn933 remaindernear 123e1 9000000000000 -> 1230
-ddrmn934 remaindernear 123e1 900000000000 -> 1230
-ddrmn935 remaindernear 123e1 90000000000 -> 1230
-ddrmn936 remaindernear 123e1 9000000000 -> 1230
-ddrmn937 remaindernear 123e1 900000000 -> 1230
-ddrmn939 remaindernear 123e1 90000000 -> 1230
-ddrmn940 remaindernear 123e1 9000000 -> 1230
-ddrmn941 remaindernear 123e1 900000 -> 1230
-ddrmn942 remaindernear 123e1 90000 -> 1230
-ddrmn943 remaindernear 123e1 9000 -> 1230
-ddrmn944 remaindernear 123e1 900 -> 330
-ddrmn945 remaindernear 123e1 90 -> -30
-ddrmn946 remaindernear 123e1 9 -> -3
-
-ddrmn950 remaindernear 123e1 1000000000000000 -> 1230
-ddrmn961 remaindernear 123e1 2999999999999999 -> 1230
-ddrmn962 remaindernear 123e1 3999999999999999 -> 1230
-ddrmn963 remaindernear 123e1 4999999999999999 -> 1230
-ddrmn964 remaindernear 123e1 5999999999999999 -> 1230
-ddrmn965 remaindernear 123e1 6999999999999999 -> 1230
-ddrmn966 remaindernear 123e1 7999999999999999 -> 1230
-ddrmn967 remaindernear 123e1 8999999999999999 -> 1230
-ddrmn968 remaindernear 123e1 9999999999999999 -> 1230
-ddrmn969 remaindernear 123e1 9876543210987654 -> 1230
-
-ddrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
-
--- overflow and underflow tests [from divide]
-ddrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
-ddrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
-ddrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
-ddrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
-ddrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
-ddrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
-ddrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
-ddrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
-
--- destructive subtract
-ddrmn1100 remainderNear 1234567890123456 1.000000000000001 -> -0.234567890123455
-ddrmn1101 remainderNear 1234567890123456 1.00000000000001 -> -0.34567890123444
-ddrmn1102 remainderNear 1234567890123456 1.0000000000001 -> -0.4567890123333
-ddrmn1103 remainderNear 1234567890123455 4.000000000000001 -> -1.308641972530864
-ddrmn1104 remainderNear 1234567890123456 4.000000000000001 -> -0.308641972530864
-ddrmn1115 remainderNear 1234567890123456 4.9999999999999 -> 0.6913578024696
-ddrmn1116 remainderNear 1234567890123456 4.99999999999999 -> -1.53086421975308
-ddrmn1117 remainderNear 1234567890123456 4.999999999999999 -> 1.246913578024691
-ddrmn1118 remainderNear 1234567890123456 5.000000000000001 -> 0.753086421975309
-ddrmn1119 remainderNear 1234567890123456 5.00000000000001 -> -1.46913578024691
-ddrmn1110 remainderNear 1234567890123456 5.0000000000001 -> 1.3086421975314
-
--- Null tests
-ddrmn1000 remaindernear 10 # -> NaN Invalid_operation
-ddrmn1001 remaindernear # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- ddRemainderNear.decTest -- decDouble remainder-near --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- sanity checks (as base, above)
+ddrmn001 remaindernear 1 1 -> 0
+ddrmn002 remaindernear 2 1 -> 0
+ddrmn003 remaindernear 1 2 -> 1
+ddrmn004 remaindernear 2 2 -> 0
+ddrmn005 remaindernear 0 1 -> 0
+ddrmn006 remaindernear 0 2 -> 0
+ddrmn007 remaindernear 1 3 -> 1
+ddrmn008 remaindernear 2 3 -> -1
+ddrmn009 remaindernear 3 3 -> 0
+
+ddrmn010 remaindernear 2.4 1 -> 0.4
+ddrmn011 remaindernear 2.4 -1 -> 0.4
+ddrmn012 remaindernear -2.4 1 -> -0.4
+ddrmn013 remaindernear -2.4 -1 -> -0.4
+ddrmn014 remaindernear 2.40 1 -> 0.40
+ddrmn015 remaindernear 2.400 1 -> 0.400
+ddrmn016 remaindernear 2.4 2 -> 0.4
+ddrmn017 remaindernear 2.400 2 -> 0.400
+ddrmn018 remaindernear 2. 2 -> 0
+ddrmn019 remaindernear 20 20 -> 0
+
+ddrmn020 remaindernear 187 187 -> 0
+ddrmn021 remaindernear 5 2 -> 1
+ddrmn022 remaindernear 5 2.0 -> 1.0
+ddrmn023 remaindernear 5 2.000 -> 1.000
+ddrmn024 remaindernear 5 0.200 -> 0.000
+ddrmn025 remaindernear 5 0.200 -> 0.000
+
+ddrmn030 remaindernear 1 2 -> 1
+ddrmn031 remaindernear 1 4 -> 1
+ddrmn032 remaindernear 1 8 -> 1
+
+ddrmn033 remaindernear 1 16 -> 1
+ddrmn034 remaindernear 1 32 -> 1
+ddrmn035 remaindernear 1 64 -> 1
+ddrmn040 remaindernear 1 -2 -> 1
+ddrmn041 remaindernear 1 -4 -> 1
+ddrmn042 remaindernear 1 -8 -> 1
+ddrmn043 remaindernear 1 -16 -> 1
+ddrmn044 remaindernear 1 -32 -> 1
+ddrmn045 remaindernear 1 -64 -> 1
+ddrmn050 remaindernear -1 2 -> -1
+ddrmn051 remaindernear -1 4 -> -1
+ddrmn052 remaindernear -1 8 -> -1
+ddrmn053 remaindernear -1 16 -> -1
+ddrmn054 remaindernear -1 32 -> -1
+ddrmn055 remaindernear -1 64 -> -1
+ddrmn060 remaindernear -1 -2 -> -1
+ddrmn061 remaindernear -1 -4 -> -1
+ddrmn062 remaindernear -1 -8 -> -1
+ddrmn063 remaindernear -1 -16 -> -1
+ddrmn064 remaindernear -1 -32 -> -1
+ddrmn065 remaindernear -1 -64 -> -1
+
+ddrmn066 remaindernear 9.9 1 -> -0.1
+ddrmn067 remaindernear 99.7 1 -> -0.3
+ddrmn068 remaindernear 999999999 1 -> 0
+ddrmn069 remaindernear 999999999.4 1 -> 0.4
+ddrmn070 remaindernear 999999999.5 1 -> -0.5
+ddrmn071 remaindernear 999999999.9 1 -> -0.1
+ddrmn072 remaindernear 999999999.999 1 -> -0.001
+ddrmn073 remaindernear 999999.999999 1 -> -0.000001
+ddrmn074 remaindernear 9 1 -> 0
+ddrmn075 remaindernear 9999999999999999 1 -> 0
+ddrmn076 remaindernear 9999999999999999 2 -> -1
+ddrmn077 remaindernear 9999999999999999 3 -> 0
+ddrmn078 remaindernear 9999999999999999 4 -> -1
+
+ddrmn080 remaindernear 0. 1 -> 0
+ddrmn081 remaindernear .0 1 -> 0.0
+ddrmn082 remaindernear 0.00 1 -> 0.00
+ddrmn083 remaindernear 0.00E+9 1 -> 0
+ddrmn084 remaindernear 0.00E+3 1 -> 0
+ddrmn085 remaindernear 0.00E+2 1 -> 0
+ddrmn086 remaindernear 0.00E+1 1 -> 0.0
+ddrmn087 remaindernear 0.00E+0 1 -> 0.00
+ddrmn088 remaindernear 0.00E-0 1 -> 0.00
+ddrmn089 remaindernear 0.00E-1 1 -> 0.000
+ddrmn090 remaindernear 0.00E-2 1 -> 0.0000
+ddrmn091 remaindernear 0.00E-3 1 -> 0.00000
+ddrmn092 remaindernear 0.00E-4 1 -> 0.000000
+ddrmn093 remaindernear 0.00E-5 1 -> 0E-7
+ddrmn094 remaindernear 0.00E-6 1 -> 0E-8
+ddrmn095 remaindernear 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remaindernear by 0
+ddrmn101 remaindernear 0 0 -> NaN Division_undefined
+ddrmn102 remaindernear 0 -0 -> NaN Division_undefined
+ddrmn103 remaindernear -0 0 -> NaN Division_undefined
+ddrmn104 remaindernear -0 -0 -> NaN Division_undefined
+ddrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
+ddrmn106 remaindernear 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+ddrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
+ddrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
+ddrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
+ddrmn110 remaindernear 1 0 -> NaN Invalid_operation
+ddrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
+ddrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
+ddrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+ddrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
+ddrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
+ddrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
+ddrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
+ddrmn120 remaindernear 1 -0 -> NaN Invalid_operation
+ddrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
+ddrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
+ddrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
+ddrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+ddrmn130 remaindernear 0 1 -> 0
+ddrmn131 remaindernear 0 -1 -> 0
+ddrmn132 remaindernear 0.0 1 -> 0.0
+ddrmn133 remaindernear 0.0 -1 -> 0.0
+ddrmn134 remaindernear -0 1 -> -0
+ddrmn135 remaindernear -0 -1 -> -0
+ddrmn136 remaindernear -0.0 1 -> -0.0
+ddrmn137 remaindernear -0.0 -1 -> -0.0
+
+-- 0.5ers
+ddrmn143 remaindernear 0.5 2 -> 0.5
+ddrmn144 remaindernear 0.5 2.1 -> 0.5
+ddrmn145 remaindernear 0.5 2.01 -> 0.50
+ddrmn146 remaindernear 0.5 2.001 -> 0.500
+ddrmn147 remaindernear 0.50 2 -> 0.50
+ddrmn148 remaindernear 0.50 2.01 -> 0.50
+ddrmn149 remaindernear 0.50 2.001 -> 0.500
+
+-- steadies
+ddrmn150 remaindernear 1 1 -> 0
+ddrmn151 remaindernear 1 2 -> 1
+ddrmn152 remaindernear 1 3 -> 1
+ddrmn153 remaindernear 1 4 -> 1
+ddrmn154 remaindernear 1 5 -> 1
+ddrmn155 remaindernear 1 6 -> 1
+ddrmn156 remaindernear 1 7 -> 1
+ddrmn157 remaindernear 1 8 -> 1
+ddrmn158 remaindernear 1 9 -> 1
+ddrmn159 remaindernear 1 10 -> 1
+ddrmn160 remaindernear 1 1 -> 0
+ddrmn161 remaindernear 2 1 -> 0
+ddrmn162 remaindernear 3 1 -> 0
+ddrmn163 remaindernear 4 1 -> 0
+ddrmn164 remaindernear 5 1 -> 0
+ddrmn165 remaindernear 6 1 -> 0
+ddrmn166 remaindernear 7 1 -> 0
+ddrmn167 remaindernear 8 1 -> 0
+ddrmn168 remaindernear 9 1 -> 0
+ddrmn169 remaindernear 10 1 -> 0
+
+-- some differences from remainder
+ddrmn171 remaindernear 0.4 1.020 -> 0.400
+ddrmn172 remaindernear 0.50 1.020 -> 0.500
+ddrmn173 remaindernear 0.51 1.020 -> 0.510
+ddrmn174 remaindernear 0.52 1.020 -> -0.500
+ddrmn175 remaindernear 0.6 1.020 -> -0.420
+
+-- More flavours of remaindernear by 0
+ddrmn201 remaindernear 0 0 -> NaN Division_undefined
+ddrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
+ddrmn203 remaindernear 0.000 0 -> NaN Division_undefined
+ddrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
+ddrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
+ddrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
+ddrmn207 remaindernear 1 0 -> NaN Invalid_operation
+ddrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
+ddrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
+ddrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+ddrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
+
+-- tests from the extended specification
+ddrmn221 remaindernear 2.1 3 -> -0.9
+ddrmn222 remaindernear 10 6 -> -2
+ddrmn223 remaindernear 10 3 -> 1
+ddrmn224 remaindernear -10 3 -> -1
+ddrmn225 remaindernear 10.2 1 -> 0.2
+ddrmn226 remaindernear 10 0.3 -> 0.1
+ddrmn227 remaindernear 3.6 1.3 -> -0.3
+
+-- some differences from remainder
+ddrmn231 remaindernear -0.4 1.020 -> -0.400
+ddrmn232 remaindernear -0.50 1.020 -> -0.500
+ddrmn233 remaindernear -0.51 1.020 -> -0.510
+ddrmn234 remaindernear -0.52 1.020 -> 0.500
+ddrmn235 remaindernear -0.6 1.020 -> 0.420
+
+-- high Xs
+ddrmn240 remaindernear 1E+2 1.00 -> 0.00
+
+-- ddrmn3xx are from DiagBigDecimal
+ddrmn301 remaindernear 1 3 -> 1
+ddrmn302 remaindernear 5 5 -> 0
+ddrmn303 remaindernear 13 10 -> 3
+ddrmn304 remaindernear 13 50 -> 13
+ddrmn305 remaindernear 13 100 -> 13
+ddrmn306 remaindernear 13 1000 -> 13
+ddrmn307 remaindernear .13 1 -> 0.13
+ddrmn308 remaindernear 0.133 1 -> 0.133
+ddrmn309 remaindernear 0.1033 1 -> 0.1033
+ddrmn310 remaindernear 1.033 1 -> 0.033
+ddrmn311 remaindernear 10.33 1 -> 0.33
+ddrmn312 remaindernear 10.33 10 -> 0.33
+ddrmn313 remaindernear 103.3 1 -> 0.3
+ddrmn314 remaindernear 133 10 -> 3
+ddrmn315 remaindernear 1033 10 -> 3
+ddrmn316 remaindernear 1033 50 -> -17
+ddrmn317 remaindernear 101.0 3 -> -1.0
+ddrmn318 remaindernear 102.0 3 -> 0.0
+ddrmn319 remaindernear 103.0 3 -> 1.0
+ddrmn320 remaindernear 2.40 1 -> 0.40
+ddrmn321 remaindernear 2.400 1 -> 0.400
+ddrmn322 remaindernear 2.4 1 -> 0.4
+ddrmn323 remaindernear 2.4 2 -> 0.4
+ddrmn324 remaindernear 2.400 2 -> 0.400
+ddrmn325 remaindernear 1 0.3 -> 0.1
+ddrmn326 remaindernear 1 0.30 -> 0.10
+ddrmn327 remaindernear 1 0.300 -> 0.100
+ddrmn328 remaindernear 1 0.3000 -> 0.1000
+ddrmn329 remaindernear 1.0 0.3 -> 0.1
+ddrmn330 remaindernear 1.00 0.3 -> 0.10
+ddrmn331 remaindernear 1.000 0.3 -> 0.100
+ddrmn332 remaindernear 1.0000 0.3 -> 0.1000
+ddrmn333 remaindernear 0.5 2 -> 0.5
+ddrmn334 remaindernear 0.5 2.1 -> 0.5
+ddrmn335 remaindernear 0.5 2.01 -> 0.50
+ddrmn336 remaindernear 0.5 2.001 -> 0.500
+ddrmn337 remaindernear 0.50 2 -> 0.50
+ddrmn338 remaindernear 0.50 2.01 -> 0.50
+ddrmn339 remaindernear 0.50 2.001 -> 0.500
+
+ddrmn340 remaindernear 0.5 0.5000001 -> -1E-7
+ddrmn341 remaindernear 0.5 0.50000001 -> -1E-8
+ddrmn342 remaindernear 0.5 0.500000001 -> -1E-9
+ddrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
+ddrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
+ddrmn345 remaindernear 0.5 0.4999999 -> 1E-7
+ddrmn346 remaindernear 0.5 0.49999999 -> 1E-8
+ddrmn347 remaindernear 0.5 0.499999999 -> 1E-9
+ddrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
+ddrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
+ddrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
+
+ddrmn351 remaindernear 0.03 7 -> 0.03
+ddrmn352 remaindernear 5 2 -> 1
+ddrmn353 remaindernear 4.1 2 -> 0.1
+ddrmn354 remaindernear 4.01 2 -> 0.01
+ddrmn355 remaindernear 4.001 2 -> 0.001
+ddrmn356 remaindernear 4.0001 2 -> 0.0001
+ddrmn357 remaindernear 4.00001 2 -> 0.00001
+ddrmn358 remaindernear 4.000001 2 -> 0.000001
+ddrmn359 remaindernear 4.0000001 2 -> 1E-7
+
+ddrmn360 remaindernear 1.2 0.7345 -> -0.2690
+ddrmn361 remaindernear 0.8 12 -> 0.8
+ddrmn362 remaindernear 0.8 0.2 -> 0.0
+ddrmn363 remaindernear 0.8 0.3 -> -0.1
+ddrmn364 remaindernear 0.800 12 -> 0.800
+ddrmn365 remaindernear 0.800 1.7 -> 0.800
+ddrmn366 remaindernear 2.400 2 -> 0.400
+
+-- round to even
+ddrmn371 remaindernear 121 2 -> 1
+ddrmn372 remaindernear 122 2 -> 0
+ddrmn373 remaindernear 123 2 -> -1
+ddrmn374 remaindernear 124 2 -> 0
+ddrmn375 remaindernear 125 2 -> 1
+ddrmn376 remaindernear 126 2 -> 0
+ddrmn377 remaindernear 127 2 -> -1
+
+ddrmn381 remaindernear 12345 1 -> 0
+ddrmn382 remaindernear 12345 1.0001 -> -0.2344
+ddrmn383 remaindernear 12345 1.001 -> -0.333
+ddrmn384 remaindernear 12345 1.01 -> -0.23
+ddrmn385 remaindernear 12345 1.1 -> -0.3
+ddrmn386 remaindernear 12355 4 -> -1
+ddrmn387 remaindernear 12345 4 -> 1
+ddrmn388 remaindernear 12355 4.0001 -> -1.3089
+ddrmn389 remaindernear 12345 4.0001 -> 0.6914
+ddrmn390 remaindernear 12345 4.9 -> 1.9
+ddrmn391 remaindernear 12345 4.99 -> -0.26
+ddrmn392 remaindernear 12345 4.999 -> 2.469
+ddrmn393 remaindernear 12345 4.9999 -> 0.2469
+ddrmn394 remaindernear 12345 5 -> 0
+ddrmn395 remaindernear 12345 5.0001 -> -0.2469
+ddrmn396 remaindernear 12345 5.001 -> -2.469
+ddrmn397 remaindernear 12345 5.01 -> 0.36
+ddrmn398 remaindernear 12345 5.1 -> -2.1
+
+-- the nasty division-by-1 cases
+ddrmn401 remaindernear 0.4 1 -> 0.4
+ddrmn402 remaindernear 0.45 1 -> 0.45
+ddrmn403 remaindernear 0.455 1 -> 0.455
+ddrmn404 remaindernear 0.4555 1 -> 0.4555
+ddrmn405 remaindernear 0.45555 1 -> 0.45555
+ddrmn406 remaindernear 0.455555 1 -> 0.455555
+ddrmn407 remaindernear 0.4555555 1 -> 0.4555555
+ddrmn408 remaindernear 0.45555555 1 -> 0.45555555
+ddrmn409 remaindernear 0.455555555 1 -> 0.455555555
+-- with spill... [412 exercises sticktab loop]
+ddrmn411 remaindernear 0.5 1 -> 0.5
+ddrmn412 remaindernear 0.55 1 -> -0.45
+ddrmn413 remaindernear 0.555 1 -> -0.445
+ddrmn414 remaindernear 0.5555 1 -> -0.4445
+ddrmn415 remaindernear 0.55555 1 -> -0.44445
+ddrmn416 remaindernear 0.555555 1 -> -0.444445
+ddrmn417 remaindernear 0.5555555 1 -> -0.4444445
+ddrmn418 remaindernear 0.55555555 1 -> -0.44444445
+ddrmn419 remaindernear 0.555555555 1 -> -0.444444445
+
+-- folddowns
+ddrmn421 remaindernear 1E+384 1 -> NaN Division_impossible
+ddrmn422 remaindernear 1E+384 1E+383 -> 0E+369 Clamped
+ddrmn423 remaindernear 1E+384 2E+383 -> 0E+369 Clamped
+ddrmn424 remaindernear 1E+384 3E+383 -> 1.00000000000000E+383 Clamped
+ddrmn425 remaindernear 1E+384 4E+383 -> 2.00000000000000E+383 Clamped
+ddrmn426 remaindernear 1E+384 5E+383 -> 0E+369 Clamped
+ddrmn427 remaindernear 1E+384 6E+383 -> -2.00000000000000E+383 Clamped
+ddrmn428 remaindernear 1E+384 7E+383 -> 3.00000000000000E+383 Clamped
+ddrmn429 remaindernear 1E+384 8E+383 -> 2.00000000000000E+383 Clamped
+ddrmn430 remaindernear 1E+384 9E+383 -> 1.00000000000000E+383 Clamped
+-- tinies
+ddrmn431 remaindernear 1E-397 1E-398 -> 0E-398
+ddrmn432 remaindernear 1E-397 2E-398 -> 0E-398
+ddrmn433 remaindernear 1E-397 3E-398 -> 1E-398 Subnormal
+ddrmn434 remaindernear 1E-397 4E-398 -> 2E-398 Subnormal
+ddrmn435 remaindernear 1E-397 5E-398 -> 0E-398
+ddrmn436 remaindernear 1E-397 6E-398 -> -2E-398 Subnormal
+ddrmn437 remaindernear 1E-397 7E-398 -> 3E-398 Subnormal
+ddrmn438 remaindernear 1E-397 8E-398 -> 2E-398 Subnormal
+ddrmn439 remaindernear 1E-397 9E-398 -> 1E-398 Subnormal
+ddrmn440 remaindernear 1E-397 10E-398 -> 0E-398
+ddrmn441 remaindernear 1E-397 11E-398 -> -1E-398 Subnormal
+ddrmn442 remaindernear 100E-397 11E-398 -> -1E-398 Subnormal
+ddrmn443 remaindernear 100E-397 20E-398 -> 0E-398
+ddrmn444 remaindernear 100E-397 21E-398 -> -8E-398 Subnormal
+ddrmn445 remaindernear 100E-397 30E-398 -> 1.0E-397 Subnormal
+
+-- zero signs
+ddrmn650 remaindernear 1 1 -> 0
+ddrmn651 remaindernear -1 1 -> -0
+ddrmn652 remaindernear 1 -1 -> 0
+ddrmn653 remaindernear -1 -1 -> -0
+ddrmn654 remaindernear 0 1 -> 0
+ddrmn655 remaindernear -0 1 -> -0
+ddrmn656 remaindernear 0 -1 -> 0
+ddrmn657 remaindernear -0 -1 -> -0
+ddrmn658 remaindernear 0.00 1 -> 0.00
+ddrmn659 remaindernear -0.00 1 -> -0.00
+
+-- Specials
+ddrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
+ddrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
+ddrmn682 remaindernear Inf -1 -> NaN Invalid_operation
+ddrmn683 remaindernear Inf 0 -> NaN Invalid_operation
+ddrmn684 remaindernear Inf -0 -> NaN Invalid_operation
+ddrmn685 remaindernear Inf 1 -> NaN Invalid_operation
+ddrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
+ddrmn687 remaindernear Inf Inf -> NaN Invalid_operation
+ddrmn688 remaindernear -1000 Inf -> -1000
+ddrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
+ddrmn691 remaindernear -1 Inf -> -1
+ddrmn692 remaindernear 0 Inf -> 0
+ddrmn693 remaindernear -0 Inf -> -0
+ddrmn694 remaindernear 1 Inf -> 1
+ddrmn695 remaindernear 1000 Inf -> 1000
+ddrmn696 remaindernear Inf Inf -> NaN Invalid_operation
+
+ddrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
+ddrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
+ddrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
+ddrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
+ddrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
+ddrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
+ddrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
+ddrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
+ddrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
+ddrmn709 remaindernear -1000 Inf -> -1000
+ddrmn710 remaindernear -1 -Inf -> -1
+ddrmn711 remaindernear -0 -Inf -> -0
+ddrmn712 remaindernear 0 -Inf -> 0
+ddrmn713 remaindernear 1 -Inf -> 1
+ddrmn714 remaindernear 1000 -Inf -> 1000
+ddrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
+
+ddrmn721 remaindernear NaN -Inf -> NaN
+ddrmn722 remaindernear NaN -1000 -> NaN
+ddrmn723 remaindernear NaN -1 -> NaN
+ddrmn724 remaindernear NaN -0 -> NaN
+ddrmn725 remaindernear -NaN 0 -> -NaN
+ddrmn726 remaindernear NaN 1 -> NaN
+ddrmn727 remaindernear NaN 1000 -> NaN
+ddrmn728 remaindernear NaN Inf -> NaN
+ddrmn729 remaindernear NaN -NaN -> NaN
+ddrmn730 remaindernear -Inf NaN -> NaN
+ddrmn731 remaindernear -1000 NaN -> NaN
+ddrmn732 remaindernear -1 NaN -> NaN
+ddrmn733 remaindernear -0 -NaN -> -NaN
+ddrmn734 remaindernear 0 NaN -> NaN
+ddrmn735 remaindernear 1 -NaN -> -NaN
+ddrmn736 remaindernear 1000 NaN -> NaN
+ddrmn737 remaindernear Inf NaN -> NaN
+
+ddrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
+ddrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
+ddrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
+ddrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
+ddrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
+ddrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
+ddrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
+ddrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
+ddrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
+ddrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
+ddrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
+ddrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
+ddrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
+ddrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
+ddrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
+ddrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
+ddrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
+ddrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+ddrmn760 remaindernear NaN1 NaN7 -> NaN1
+ddrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
+ddrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
+ddrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
+ddrmn764 remaindernear 15 NaN11 -> NaN11
+ddrmn765 remaindernear NaN6 NaN12 -> NaN6
+ddrmn766 remaindernear Inf NaN13 -> NaN13
+ddrmn767 remaindernear NaN14 -Inf -> NaN14
+ddrmn768 remaindernear 0 NaN15 -> NaN15
+ddrmn769 remaindernear NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+ddrmn770 remaindernear 1234567890123456 10 -> -4
+ddrmn771 remaindernear 1234567890123456 1 -> 0
+ddrmn772 remaindernear 1234567890123456 0.1 -> NaN Division_impossible
+ddrmn773 remaindernear 1234567890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+ddrmn801 remaindernear 12345678000 100 -> 0
+ddrmn802 remaindernear 1 12345678000 -> 1
+ddrmn803 remaindernear 1234567800 10 -> 0
+ddrmn804 remaindernear 1 1234567800 -> 1
+ddrmn805 remaindernear 1234567890 10 -> 0
+ddrmn806 remaindernear 1 1234567890 -> 1
+ddrmn807 remaindernear 1234567891 10 -> 1
+ddrmn808 remaindernear 1 1234567891 -> 1
+ddrmn809 remaindernear 12345678901 100 -> 1
+ddrmn810 remaindernear 1 12345678901 -> 1
+ddrmn811 remaindernear 1234567896 10 -> -4
+ddrmn812 remaindernear 1 1234567896 -> 1
+
+ddrmn821 remaindernear 12345678000 100 -> 0
+ddrmn822 remaindernear 1 12345678000 -> 1
+ddrmn823 remaindernear 1234567800 10 -> 0
+ddrmn824 remaindernear 1 1234567800 -> 1
+ddrmn825 remaindernear 1234567890 10 -> 0
+ddrmn826 remaindernear 1 1234567890 -> 1
+ddrmn827 remaindernear 1234567891 10 -> 1
+ddrmn828 remaindernear 1 1234567891 -> 1
+ddrmn829 remaindernear 12345678901 100 -> 1
+ddrmn830 remaindernear 1 12345678901 -> 1
+ddrmn831 remaindernear 1234567896 10 -> -4
+ddrmn832 remaindernear 1 1234567896 -> 1
+
+-- from divideint
+ddrmn840 remaindernear 100000000.0 1 -> 0.0
+ddrmn841 remaindernear 100000000.4 1 -> 0.4
+ddrmn842 remaindernear 100000000.5 1 -> 0.5
+ddrmn843 remaindernear 100000000.9 1 -> -0.1
+ddrmn844 remaindernear 100000000.999 1 -> -0.001
+ddrmn850 remaindernear 100000003 5 -> -2
+ddrmn851 remaindernear 10000003 5 -> -2
+ddrmn852 remaindernear 1000003 5 -> -2
+ddrmn853 remaindernear 100003 5 -> -2
+ddrmn854 remaindernear 10003 5 -> -2
+ddrmn855 remaindernear 1003 5 -> -2
+ddrmn856 remaindernear 103 5 -> -2
+ddrmn857 remaindernear 13 5 -> -2
+ddrmn858 remaindernear 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+ddrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
+ddrmn861 remaindernear 1230 1000000000000000 -> 1230
+ddrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
+ddrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
+ddrmn864 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn870 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn871 remaindernear 123e1 100000000000000 -> 1230
+ddrmn872 remaindernear 123e1 10000000000000 -> 1230
+ddrmn873 remaindernear 123e1 1000000000000 -> 1230
+ddrmn874 remaindernear 123e1 100000000000 -> 1230
+ddrmn875 remaindernear 123e1 10000000000 -> 1230
+ddrmn876 remaindernear 123e1 1000000000 -> 1230
+ddrmn877 remaindernear 123e1 100000000 -> 1230
+ddrmn878 remaindernear 1230 100000000 -> 1230
+ddrmn879 remaindernear 123e1 10000000 -> 1230
+ddrmn880 remaindernear 123e1 1000000 -> 1230
+ddrmn881 remaindernear 123e1 100000 -> 1230
+ddrmn882 remaindernear 123e1 10000 -> 1230
+ddrmn883 remaindernear 123e1 1000 -> 230
+ddrmn884 remaindernear 123e1 100 -> 30
+ddrmn885 remaindernear 123e1 10 -> 0
+ddrmn886 remaindernear 123e1 1 -> 0
+
+ddrmn890 remaindernear 123e1 2000000000000000 -> 1230
+ddrmn891 remaindernear 123e1 200000000000000 -> 1230
+ddrmn892 remaindernear 123e1 20000000000000 -> 1230
+ddrmn893 remaindernear 123e1 2000000000000 -> 1230
+ddrmn894 remaindernear 123e1 200000000000 -> 1230
+ddrmn895 remaindernear 123e1 20000000000 -> 1230
+ddrmn896 remaindernear 123e1 2000000000 -> 1230
+ddrmn897 remaindernear 123e1 200000000 -> 1230
+ddrmn899 remaindernear 123e1 20000000 -> 1230
+ddrmn900 remaindernear 123e1 2000000 -> 1230
+ddrmn901 remaindernear 123e1 200000 -> 1230
+ddrmn902 remaindernear 123e1 20000 -> 1230
+ddrmn903 remaindernear 123e1 2000 -> -770
+ddrmn904 remaindernear 123e1 200 -> 30
+ddrmn905 remaindernear 123e1 20 -> -10
+ddrmn906 remaindernear 123e1 2 -> 0
+
+ddrmn910 remaindernear 123e1 5000000000000000 -> 1230
+ddrmn911 remaindernear 123e1 500000000000000 -> 1230
+ddrmn912 remaindernear 123e1 50000000000000 -> 1230
+ddrmn913 remaindernear 123e1 5000000000000 -> 1230
+ddrmn914 remaindernear 123e1 500000000000 -> 1230
+ddrmn915 remaindernear 123e1 50000000000 -> 1230
+ddrmn916 remaindernear 123e1 5000000000 -> 1230
+ddrmn917 remaindernear 123e1 500000000 -> 1230
+ddrmn919 remaindernear 123e1 50000000 -> 1230
+ddrmn920 remaindernear 123e1 5000000 -> 1230
+ddrmn921 remaindernear 123e1 500000 -> 1230
+ddrmn922 remaindernear 123e1 50000 -> 1230
+ddrmn923 remaindernear 123e1 5000 -> 1230
+ddrmn924 remaindernear 123e1 500 -> 230
+ddrmn925 remaindernear 123e1 50 -> -20
+ddrmn926 remaindernear 123e1 5 -> 0
+
+ddrmn930 remaindernear 123e1 9000000000000000 -> 1230
+ddrmn931 remaindernear 123e1 900000000000000 -> 1230
+ddrmn932 remaindernear 123e1 90000000000000 -> 1230
+ddrmn933 remaindernear 123e1 9000000000000 -> 1230
+ddrmn934 remaindernear 123e1 900000000000 -> 1230
+ddrmn935 remaindernear 123e1 90000000000 -> 1230
+ddrmn936 remaindernear 123e1 9000000000 -> 1230
+ddrmn937 remaindernear 123e1 900000000 -> 1230
+ddrmn939 remaindernear 123e1 90000000 -> 1230
+ddrmn940 remaindernear 123e1 9000000 -> 1230
+ddrmn941 remaindernear 123e1 900000 -> 1230
+ddrmn942 remaindernear 123e1 90000 -> 1230
+ddrmn943 remaindernear 123e1 9000 -> 1230
+ddrmn944 remaindernear 123e1 900 -> 330
+ddrmn945 remaindernear 123e1 90 -> -30
+ddrmn946 remaindernear 123e1 9 -> -3
+
+ddrmn950 remaindernear 123e1 1000000000000000 -> 1230
+ddrmn961 remaindernear 123e1 2999999999999999 -> 1230
+ddrmn962 remaindernear 123e1 3999999999999999 -> 1230
+ddrmn963 remaindernear 123e1 4999999999999999 -> 1230
+ddrmn964 remaindernear 123e1 5999999999999999 -> 1230
+ddrmn965 remaindernear 123e1 6999999999999999 -> 1230
+ddrmn966 remaindernear 123e1 7999999999999999 -> 1230
+ddrmn967 remaindernear 123e1 8999999999999999 -> 1230
+ddrmn968 remaindernear 123e1 9999999999999999 -> 1230
+ddrmn969 remaindernear 123e1 9876543210987654 -> 1230
+
+ddrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+
+-- overflow and underflow tests [from divide]
+ddrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
+ddrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
+ddrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
+ddrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
+ddrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
+ddrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
+ddrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
+ddrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
+
+-- destructive subtract
+ddrmn1100 remainderNear 1234567890123456 1.000000000000001 -> -0.234567890123455
+ddrmn1101 remainderNear 1234567890123456 1.00000000000001 -> -0.34567890123444
+ddrmn1102 remainderNear 1234567890123456 1.0000000000001 -> -0.4567890123333
+ddrmn1103 remainderNear 1234567890123455 4.000000000000001 -> -1.308641972530864
+ddrmn1104 remainderNear 1234567890123456 4.000000000000001 -> -0.308641972530864
+ddrmn1115 remainderNear 1234567890123456 4.9999999999999 -> 0.6913578024696
+ddrmn1116 remainderNear 1234567890123456 4.99999999999999 -> -1.53086421975308
+ddrmn1117 remainderNear 1234567890123456 4.999999999999999 -> 1.246913578024691
+ddrmn1118 remainderNear 1234567890123456 5.000000000000001 -> 0.753086421975309
+ddrmn1119 remainderNear 1234567890123456 5.00000000000001 -> -1.46913578024691
+ddrmn1110 remainderNear 1234567890123456 5.0000000000001 -> 1.3086421975314
+
+-- Null tests
+ddrmn1000 remaindernear 10 # -> NaN Invalid_operation
+ddrmn1001 remaindernear # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/ddRotate.decTest b/Lib/test/decimaltestdata/ddRotate.decTest
index 8b0fe2620de..87eeb1c0f1b 100644
--- a/Lib/test/decimaltestdata/ddRotate.decTest
+++ b/Lib/test/decimaltestdata/ddRotate.decTest
@@ -1,262 +1,262 @@
-------------------------------------------------------------------------
--- ddRotate.decTest -- rotate a decDouble coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddrot001 rotate 0 0 -> 0
-ddrot002 rotate 0 2 -> 0
-ddrot003 rotate 1 2 -> 100
-ddrot004 rotate 1 15 -> 1000000000000000
-ddrot005 rotate 1 16 -> 1
-ddrot006 rotate 1 -1 -> 1000000000000000
-ddrot007 rotate 0 -2 -> 0
-ddrot008 rotate 1234567890123456 -1 -> 6123456789012345
-ddrot009 rotate 1234567890123456 -15 -> 2345678901234561
-ddrot010 rotate 1234567890123456 -16 -> 1234567890123456
-ddrot011 rotate 9934567890123456 -15 -> 9345678901234569
-ddrot012 rotate 9934567890123456 -16 -> 9934567890123456
-
--- rhs must be an integer
-ddrot015 rotate 1 1.5 -> NaN Invalid_operation
-ddrot016 rotate 1 1.0 -> NaN Invalid_operation
-ddrot017 rotate 1 0.1 -> NaN Invalid_operation
-ddrot018 rotate 1 0.0 -> NaN Invalid_operation
-ddrot019 rotate 1 1E+1 -> NaN Invalid_operation
-ddrot020 rotate 1 1E+99 -> NaN Invalid_operation
-ddrot021 rotate 1 Inf -> NaN Invalid_operation
-ddrot022 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-ddrot025 rotate 1 -1000 -> NaN Invalid_operation
-ddrot026 rotate 1 -17 -> NaN Invalid_operation
-ddrot027 rotate 1 17 -> NaN Invalid_operation
-ddrot028 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-ddrot030 rotate 1234567890123456 -16 -> 1234567890123456
-ddrot031 rotate 1234567890123456 -15 -> 2345678901234561
-ddrot032 rotate 1234567890123456 -14 -> 3456789012345612
-ddrot033 rotate 1234567890123456 -13 -> 4567890123456123
-ddrot034 rotate 1234567890123456 -12 -> 5678901234561234
-ddrot035 rotate 1234567890123456 -11 -> 6789012345612345
-ddrot036 rotate 1234567890123456 -10 -> 7890123456123456
-ddrot037 rotate 1234567890123456 -9 -> 8901234561234567
-ddrot038 rotate 1234567890123456 -8 -> 9012345612345678
-ddrot039 rotate 1234567890123456 -7 -> 123456123456789
-ddrot040 rotate 1234567890123456 -6 -> 1234561234567890
-ddrot041 rotate 1234567890123456 -5 -> 2345612345678901
-ddrot042 rotate 1234567890123456 -4 -> 3456123456789012
-ddrot043 rotate 1234567890123456 -3 -> 4561234567890123
-ddrot044 rotate 1234567890123456 -2 -> 5612345678901234
-ddrot045 rotate 1234567890123456 -1 -> 6123456789012345
-ddrot046 rotate 1234567890123456 -0 -> 1234567890123456
-
-ddrot047 rotate 1234567890123456 +0 -> 1234567890123456
-ddrot048 rotate 1234567890123456 +1 -> 2345678901234561
-ddrot049 rotate 1234567890123456 +2 -> 3456789012345612
-ddrot050 rotate 1234567890123456 +3 -> 4567890123456123
-ddrot051 rotate 1234567890123456 +4 -> 5678901234561234
-ddrot052 rotate 1234567890123456 +5 -> 6789012345612345
-ddrot053 rotate 1234567890123456 +6 -> 7890123456123456
-ddrot054 rotate 1234567890123456 +7 -> 8901234561234567
-ddrot055 rotate 1234567890123456 +8 -> 9012345612345678
-ddrot056 rotate 1234567890123456 +9 -> 123456123456789
-ddrot057 rotate 1234567890123456 +10 -> 1234561234567890
-ddrot058 rotate 1234567890123456 +11 -> 2345612345678901
-ddrot059 rotate 1234567890123456 +12 -> 3456123456789012
-ddrot060 rotate 1234567890123456 +13 -> 4561234567890123
-ddrot061 rotate 1234567890123456 +14 -> 5612345678901234
-ddrot062 rotate 1234567890123456 +15 -> 6123456789012345
-ddrot063 rotate 1234567890123456 +16 -> 1234567890123456
-
--- zeros
-ddrot070 rotate 0E-10 +9 -> 0E-10
-ddrot071 rotate 0E-10 -9 -> 0E-10
-ddrot072 rotate 0.000 +9 -> 0.000
-ddrot073 rotate 0.000 -9 -> 0.000
-ddrot074 rotate 0E+10 +9 -> 0E+10
-ddrot075 rotate 0E+10 -9 -> 0E+10
-ddrot076 rotate -0E-10 +9 -> -0E-10
-ddrot077 rotate -0E-10 -9 -> -0E-10
-ddrot078 rotate -0.000 +9 -> -0.000
-ddrot079 rotate -0.000 -9 -> -0.000
-ddrot080 rotate -0E+10 +9 -> -0E+10
-ddrot081 rotate -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-ddrot141 rotate 9.999999999999999E+384 -1 -> 9.999999999999999E+384
-ddrot142 rotate 9.999999999999999E+384 -15 -> 9.999999999999999E+384
-ddrot143 rotate 9.999999999999999E+384 1 -> 9.999999999999999E+384
-ddrot144 rotate 9.999999999999999E+384 15 -> 9.999999999999999E+384
-ddrot145 rotate 1E-383 -1 -> 1.000000000000000E-368
-ddrot146 rotate 1E-383 -15 -> 1.0E-382
-ddrot147 rotate 1E-383 1 -> 1.0E-382
-ddrot148 rotate 1E-383 15 -> 1.000000000000000E-368
-ddrot151 rotate 1.000000000000000E-383 -1 -> 1.00000000000000E-384
-ddrot152 rotate 1.000000000000000E-383 -15 -> 1E-398
-ddrot153 rotate 1.000000000000000E-383 1 -> 1E-398
-ddrot154 rotate 1.000000000000000E-383 15 -> 1.00000000000000E-384
-ddrot155 rotate 9.000000000000000E-383 -1 -> 9.00000000000000E-384
-ddrot156 rotate 9.000000000000000E-383 -15 -> 9E-398
-ddrot157 rotate 9.000000000000000E-383 1 -> 9E-398
-ddrot158 rotate 9.000000000000000E-383 15 -> 9.00000000000000E-384
-ddrot160 rotate 1E-398 -1 -> 1.000000000000000E-383
-ddrot161 rotate 1E-398 -15 -> 1.0E-397
-ddrot162 rotate 1E-398 1 -> 1.0E-397
-ddrot163 rotate 1E-398 15 -> 1.000000000000000E-383
--- negatives
-ddrot171 rotate -9.999999999999999E+384 -1 -> -9.999999999999999E+384
-ddrot172 rotate -9.999999999999999E+384 -15 -> -9.999999999999999E+384
-ddrot173 rotate -9.999999999999999E+384 1 -> -9.999999999999999E+384
-ddrot174 rotate -9.999999999999999E+384 15 -> -9.999999999999999E+384
-ddrot175 rotate -1E-383 -1 -> -1.000000000000000E-368
-ddrot176 rotate -1E-383 -15 -> -1.0E-382
-ddrot177 rotate -1E-383 1 -> -1.0E-382
-ddrot178 rotate -1E-383 15 -> -1.000000000000000E-368
-ddrot181 rotate -1.000000000000000E-383 -1 -> -1.00000000000000E-384
-ddrot182 rotate -1.000000000000000E-383 -15 -> -1E-398
-ddrot183 rotate -1.000000000000000E-383 1 -> -1E-398
-ddrot184 rotate -1.000000000000000E-383 15 -> -1.00000000000000E-384
-ddrot185 rotate -9.000000000000000E-383 -1 -> -9.00000000000000E-384
-ddrot186 rotate -9.000000000000000E-383 -15 -> -9E-398
-ddrot187 rotate -9.000000000000000E-383 1 -> -9E-398
-ddrot188 rotate -9.000000000000000E-383 15 -> -9.00000000000000E-384
-ddrot190 rotate -1E-398 -1 -> -1.000000000000000E-383
-ddrot191 rotate -1E-398 -15 -> -1.0E-397
-ddrot192 rotate -1E-398 1 -> -1.0E-397
-ddrot193 rotate -1E-398 15 -> -1.000000000000000E-383
-
--- more negatives (of sanities)
-ddrot201 rotate -0 0 -> -0
-ddrot202 rotate -0 2 -> -0
-ddrot203 rotate -1 2 -> -100
-ddrot204 rotate -1 15 -> -1000000000000000
-ddrot205 rotate -1 16 -> -1
-ddrot206 rotate -1 -1 -> -1000000000000000
-ddrot207 rotate -0 -2 -> -0
-ddrot208 rotate -1234567890123456 -1 -> -6123456789012345
-ddrot209 rotate -1234567890123456 -15 -> -2345678901234561
-ddrot210 rotate -1234567890123456 -16 -> -1234567890123456
-ddrot211 rotate -9934567890123456 -15 -> -9345678901234569
-ddrot212 rotate -9934567890123456 -16 -> -9934567890123456
-
-
--- Specials; NaNs are handled as usual
-ddrot781 rotate -Inf -8 -> -Infinity
-ddrot782 rotate -Inf -1 -> -Infinity
-ddrot783 rotate -Inf -0 -> -Infinity
-ddrot784 rotate -Inf 0 -> -Infinity
-ddrot785 rotate -Inf 1 -> -Infinity
-ddrot786 rotate -Inf 8 -> -Infinity
-ddrot787 rotate -1000 -Inf -> NaN Invalid_operation
-ddrot788 rotate -Inf -Inf -> NaN Invalid_operation
-ddrot789 rotate -1 -Inf -> NaN Invalid_operation
-ddrot790 rotate -0 -Inf -> NaN Invalid_operation
-ddrot791 rotate 0 -Inf -> NaN Invalid_operation
-ddrot792 rotate 1 -Inf -> NaN Invalid_operation
-ddrot793 rotate 1000 -Inf -> NaN Invalid_operation
-ddrot794 rotate Inf -Inf -> NaN Invalid_operation
-
-ddrot800 rotate Inf -Inf -> NaN Invalid_operation
-ddrot801 rotate Inf -8 -> Infinity
-ddrot802 rotate Inf -1 -> Infinity
-ddrot803 rotate Inf -0 -> Infinity
-ddrot804 rotate Inf 0 -> Infinity
-ddrot805 rotate Inf 1 -> Infinity
-ddrot806 rotate Inf 8 -> Infinity
-ddrot807 rotate Inf Inf -> NaN Invalid_operation
-ddrot808 rotate -1000 Inf -> NaN Invalid_operation
-ddrot809 rotate -Inf Inf -> NaN Invalid_operation
-ddrot810 rotate -1 Inf -> NaN Invalid_operation
-ddrot811 rotate -0 Inf -> NaN Invalid_operation
-ddrot812 rotate 0 Inf -> NaN Invalid_operation
-ddrot813 rotate 1 Inf -> NaN Invalid_operation
-ddrot814 rotate 1000 Inf -> NaN Invalid_operation
-ddrot815 rotate Inf Inf -> NaN Invalid_operation
-
-ddrot821 rotate NaN -Inf -> NaN
-ddrot822 rotate NaN -1000 -> NaN
-ddrot823 rotate NaN -1 -> NaN
-ddrot824 rotate NaN -0 -> NaN
-ddrot825 rotate NaN 0 -> NaN
-ddrot826 rotate NaN 1 -> NaN
-ddrot827 rotate NaN 1000 -> NaN
-ddrot828 rotate NaN Inf -> NaN
-ddrot829 rotate NaN NaN -> NaN
-ddrot830 rotate -Inf NaN -> NaN
-ddrot831 rotate -1000 NaN -> NaN
-ddrot832 rotate -1 NaN -> NaN
-ddrot833 rotate -0 NaN -> NaN
-ddrot834 rotate 0 NaN -> NaN
-ddrot835 rotate 1 NaN -> NaN
-ddrot836 rotate 1000 NaN -> NaN
-ddrot837 rotate Inf NaN -> NaN
-
-ddrot841 rotate sNaN -Inf -> NaN Invalid_operation
-ddrot842 rotate sNaN -1000 -> NaN Invalid_operation
-ddrot843 rotate sNaN -1 -> NaN Invalid_operation
-ddrot844 rotate sNaN -0 -> NaN Invalid_operation
-ddrot845 rotate sNaN 0 -> NaN Invalid_operation
-ddrot846 rotate sNaN 1 -> NaN Invalid_operation
-ddrot847 rotate sNaN 1000 -> NaN Invalid_operation
-ddrot848 rotate sNaN NaN -> NaN Invalid_operation
-ddrot849 rotate sNaN sNaN -> NaN Invalid_operation
-ddrot850 rotate NaN sNaN -> NaN Invalid_operation
-ddrot851 rotate -Inf sNaN -> NaN Invalid_operation
-ddrot852 rotate -1000 sNaN -> NaN Invalid_operation
-ddrot853 rotate -1 sNaN -> NaN Invalid_operation
-ddrot854 rotate -0 sNaN -> NaN Invalid_operation
-ddrot855 rotate 0 sNaN -> NaN Invalid_operation
-ddrot856 rotate 1 sNaN -> NaN Invalid_operation
-ddrot857 rotate 1000 sNaN -> NaN Invalid_operation
-ddrot858 rotate Inf sNaN -> NaN Invalid_operation
-ddrot859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddrot861 rotate NaN1 -Inf -> NaN1
-ddrot862 rotate +NaN2 -1000 -> NaN2
-ddrot863 rotate NaN3 1000 -> NaN3
-ddrot864 rotate NaN4 Inf -> NaN4
-ddrot865 rotate NaN5 +NaN6 -> NaN5
-ddrot866 rotate -Inf NaN7 -> NaN7
-ddrot867 rotate -1000 NaN8 -> NaN8
-ddrot868 rotate 1000 NaN9 -> NaN9
-ddrot869 rotate Inf +NaN10 -> NaN10
-ddrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-ddrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-ddrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-ddrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-ddrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-ddrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-ddrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-ddrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-ddrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-ddrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddrot882 rotate -NaN26 NaN28 -> -NaN26
-ddrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddrot884 rotate 1000 -NaN30 -> -NaN30
-ddrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- ddRotate.decTest -- rotate a decDouble coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddrot001 rotate 0 0 -> 0
+ddrot002 rotate 0 2 -> 0
+ddrot003 rotate 1 2 -> 100
+ddrot004 rotate 1 15 -> 1000000000000000
+ddrot005 rotate 1 16 -> 1
+ddrot006 rotate 1 -1 -> 1000000000000000
+ddrot007 rotate 0 -2 -> 0
+ddrot008 rotate 1234567890123456 -1 -> 6123456789012345
+ddrot009 rotate 1234567890123456 -15 -> 2345678901234561
+ddrot010 rotate 1234567890123456 -16 -> 1234567890123456
+ddrot011 rotate 9934567890123456 -15 -> 9345678901234569
+ddrot012 rotate 9934567890123456 -16 -> 9934567890123456
+
+-- rhs must be an integer
+ddrot015 rotate 1 1.5 -> NaN Invalid_operation
+ddrot016 rotate 1 1.0 -> NaN Invalid_operation
+ddrot017 rotate 1 0.1 -> NaN Invalid_operation
+ddrot018 rotate 1 0.0 -> NaN Invalid_operation
+ddrot019 rotate 1 1E+1 -> NaN Invalid_operation
+ddrot020 rotate 1 1E+99 -> NaN Invalid_operation
+ddrot021 rotate 1 Inf -> NaN Invalid_operation
+ddrot022 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+ddrot025 rotate 1 -1000 -> NaN Invalid_operation
+ddrot026 rotate 1 -17 -> NaN Invalid_operation
+ddrot027 rotate 1 17 -> NaN Invalid_operation
+ddrot028 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+ddrot030 rotate 1234567890123456 -16 -> 1234567890123456
+ddrot031 rotate 1234567890123456 -15 -> 2345678901234561
+ddrot032 rotate 1234567890123456 -14 -> 3456789012345612
+ddrot033 rotate 1234567890123456 -13 -> 4567890123456123
+ddrot034 rotate 1234567890123456 -12 -> 5678901234561234
+ddrot035 rotate 1234567890123456 -11 -> 6789012345612345
+ddrot036 rotate 1234567890123456 -10 -> 7890123456123456
+ddrot037 rotate 1234567890123456 -9 -> 8901234561234567
+ddrot038 rotate 1234567890123456 -8 -> 9012345612345678
+ddrot039 rotate 1234567890123456 -7 -> 123456123456789
+ddrot040 rotate 1234567890123456 -6 -> 1234561234567890
+ddrot041 rotate 1234567890123456 -5 -> 2345612345678901
+ddrot042 rotate 1234567890123456 -4 -> 3456123456789012
+ddrot043 rotate 1234567890123456 -3 -> 4561234567890123
+ddrot044 rotate 1234567890123456 -2 -> 5612345678901234
+ddrot045 rotate 1234567890123456 -1 -> 6123456789012345
+ddrot046 rotate 1234567890123456 -0 -> 1234567890123456
+
+ddrot047 rotate 1234567890123456 +0 -> 1234567890123456
+ddrot048 rotate 1234567890123456 +1 -> 2345678901234561
+ddrot049 rotate 1234567890123456 +2 -> 3456789012345612
+ddrot050 rotate 1234567890123456 +3 -> 4567890123456123
+ddrot051 rotate 1234567890123456 +4 -> 5678901234561234
+ddrot052 rotate 1234567890123456 +5 -> 6789012345612345
+ddrot053 rotate 1234567890123456 +6 -> 7890123456123456
+ddrot054 rotate 1234567890123456 +7 -> 8901234561234567
+ddrot055 rotate 1234567890123456 +8 -> 9012345612345678
+ddrot056 rotate 1234567890123456 +9 -> 123456123456789
+ddrot057 rotate 1234567890123456 +10 -> 1234561234567890
+ddrot058 rotate 1234567890123456 +11 -> 2345612345678901
+ddrot059 rotate 1234567890123456 +12 -> 3456123456789012
+ddrot060 rotate 1234567890123456 +13 -> 4561234567890123
+ddrot061 rotate 1234567890123456 +14 -> 5612345678901234
+ddrot062 rotate 1234567890123456 +15 -> 6123456789012345
+ddrot063 rotate 1234567890123456 +16 -> 1234567890123456
+
+-- zeros
+ddrot070 rotate 0E-10 +9 -> 0E-10
+ddrot071 rotate 0E-10 -9 -> 0E-10
+ddrot072 rotate 0.000 +9 -> 0.000
+ddrot073 rotate 0.000 -9 -> 0.000
+ddrot074 rotate 0E+10 +9 -> 0E+10
+ddrot075 rotate 0E+10 -9 -> 0E+10
+ddrot076 rotate -0E-10 +9 -> -0E-10
+ddrot077 rotate -0E-10 -9 -> -0E-10
+ddrot078 rotate -0.000 +9 -> -0.000
+ddrot079 rotate -0.000 -9 -> -0.000
+ddrot080 rotate -0E+10 +9 -> -0E+10
+ddrot081 rotate -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+ddrot141 rotate 9.999999999999999E+384 -1 -> 9.999999999999999E+384
+ddrot142 rotate 9.999999999999999E+384 -15 -> 9.999999999999999E+384
+ddrot143 rotate 9.999999999999999E+384 1 -> 9.999999999999999E+384
+ddrot144 rotate 9.999999999999999E+384 15 -> 9.999999999999999E+384
+ddrot145 rotate 1E-383 -1 -> 1.000000000000000E-368
+ddrot146 rotate 1E-383 -15 -> 1.0E-382
+ddrot147 rotate 1E-383 1 -> 1.0E-382
+ddrot148 rotate 1E-383 15 -> 1.000000000000000E-368
+ddrot151 rotate 1.000000000000000E-383 -1 -> 1.00000000000000E-384
+ddrot152 rotate 1.000000000000000E-383 -15 -> 1E-398
+ddrot153 rotate 1.000000000000000E-383 1 -> 1E-398
+ddrot154 rotate 1.000000000000000E-383 15 -> 1.00000000000000E-384
+ddrot155 rotate 9.000000000000000E-383 -1 -> 9.00000000000000E-384
+ddrot156 rotate 9.000000000000000E-383 -15 -> 9E-398
+ddrot157 rotate 9.000000000000000E-383 1 -> 9E-398
+ddrot158 rotate 9.000000000000000E-383 15 -> 9.00000000000000E-384
+ddrot160 rotate 1E-398 -1 -> 1.000000000000000E-383
+ddrot161 rotate 1E-398 -15 -> 1.0E-397
+ddrot162 rotate 1E-398 1 -> 1.0E-397
+ddrot163 rotate 1E-398 15 -> 1.000000000000000E-383
+-- negatives
+ddrot171 rotate -9.999999999999999E+384 -1 -> -9.999999999999999E+384
+ddrot172 rotate -9.999999999999999E+384 -15 -> -9.999999999999999E+384
+ddrot173 rotate -9.999999999999999E+384 1 -> -9.999999999999999E+384
+ddrot174 rotate -9.999999999999999E+384 15 -> -9.999999999999999E+384
+ddrot175 rotate -1E-383 -1 -> -1.000000000000000E-368
+ddrot176 rotate -1E-383 -15 -> -1.0E-382
+ddrot177 rotate -1E-383 1 -> -1.0E-382
+ddrot178 rotate -1E-383 15 -> -1.000000000000000E-368
+ddrot181 rotate -1.000000000000000E-383 -1 -> -1.00000000000000E-384
+ddrot182 rotate -1.000000000000000E-383 -15 -> -1E-398
+ddrot183 rotate -1.000000000000000E-383 1 -> -1E-398
+ddrot184 rotate -1.000000000000000E-383 15 -> -1.00000000000000E-384
+ddrot185 rotate -9.000000000000000E-383 -1 -> -9.00000000000000E-384
+ddrot186 rotate -9.000000000000000E-383 -15 -> -9E-398
+ddrot187 rotate -9.000000000000000E-383 1 -> -9E-398
+ddrot188 rotate -9.000000000000000E-383 15 -> -9.00000000000000E-384
+ddrot190 rotate -1E-398 -1 -> -1.000000000000000E-383
+ddrot191 rotate -1E-398 -15 -> -1.0E-397
+ddrot192 rotate -1E-398 1 -> -1.0E-397
+ddrot193 rotate -1E-398 15 -> -1.000000000000000E-383
+
+-- more negatives (of sanities)
+ddrot201 rotate -0 0 -> -0
+ddrot202 rotate -0 2 -> -0
+ddrot203 rotate -1 2 -> -100
+ddrot204 rotate -1 15 -> -1000000000000000
+ddrot205 rotate -1 16 -> -1
+ddrot206 rotate -1 -1 -> -1000000000000000
+ddrot207 rotate -0 -2 -> -0
+ddrot208 rotate -1234567890123456 -1 -> -6123456789012345
+ddrot209 rotate -1234567890123456 -15 -> -2345678901234561
+ddrot210 rotate -1234567890123456 -16 -> -1234567890123456
+ddrot211 rotate -9934567890123456 -15 -> -9345678901234569
+ddrot212 rotate -9934567890123456 -16 -> -9934567890123456
+
+
+-- Specials; NaNs are handled as usual
+ddrot781 rotate -Inf -8 -> -Infinity
+ddrot782 rotate -Inf -1 -> -Infinity
+ddrot783 rotate -Inf -0 -> -Infinity
+ddrot784 rotate -Inf 0 -> -Infinity
+ddrot785 rotate -Inf 1 -> -Infinity
+ddrot786 rotate -Inf 8 -> -Infinity
+ddrot787 rotate -1000 -Inf -> NaN Invalid_operation
+ddrot788 rotate -Inf -Inf -> NaN Invalid_operation
+ddrot789 rotate -1 -Inf -> NaN Invalid_operation
+ddrot790 rotate -0 -Inf -> NaN Invalid_operation
+ddrot791 rotate 0 -Inf -> NaN Invalid_operation
+ddrot792 rotate 1 -Inf -> NaN Invalid_operation
+ddrot793 rotate 1000 -Inf -> NaN Invalid_operation
+ddrot794 rotate Inf -Inf -> NaN Invalid_operation
+
+ddrot800 rotate Inf -Inf -> NaN Invalid_operation
+ddrot801 rotate Inf -8 -> Infinity
+ddrot802 rotate Inf -1 -> Infinity
+ddrot803 rotate Inf -0 -> Infinity
+ddrot804 rotate Inf 0 -> Infinity
+ddrot805 rotate Inf 1 -> Infinity
+ddrot806 rotate Inf 8 -> Infinity
+ddrot807 rotate Inf Inf -> NaN Invalid_operation
+ddrot808 rotate -1000 Inf -> NaN Invalid_operation
+ddrot809 rotate -Inf Inf -> NaN Invalid_operation
+ddrot810 rotate -1 Inf -> NaN Invalid_operation
+ddrot811 rotate -0 Inf -> NaN Invalid_operation
+ddrot812 rotate 0 Inf -> NaN Invalid_operation
+ddrot813 rotate 1 Inf -> NaN Invalid_operation
+ddrot814 rotate 1000 Inf -> NaN Invalid_operation
+ddrot815 rotate Inf Inf -> NaN Invalid_operation
+
+ddrot821 rotate NaN -Inf -> NaN
+ddrot822 rotate NaN -1000 -> NaN
+ddrot823 rotate NaN -1 -> NaN
+ddrot824 rotate NaN -0 -> NaN
+ddrot825 rotate NaN 0 -> NaN
+ddrot826 rotate NaN 1 -> NaN
+ddrot827 rotate NaN 1000 -> NaN
+ddrot828 rotate NaN Inf -> NaN
+ddrot829 rotate NaN NaN -> NaN
+ddrot830 rotate -Inf NaN -> NaN
+ddrot831 rotate -1000 NaN -> NaN
+ddrot832 rotate -1 NaN -> NaN
+ddrot833 rotate -0 NaN -> NaN
+ddrot834 rotate 0 NaN -> NaN
+ddrot835 rotate 1 NaN -> NaN
+ddrot836 rotate 1000 NaN -> NaN
+ddrot837 rotate Inf NaN -> NaN
+
+ddrot841 rotate sNaN -Inf -> NaN Invalid_operation
+ddrot842 rotate sNaN -1000 -> NaN Invalid_operation
+ddrot843 rotate sNaN -1 -> NaN Invalid_operation
+ddrot844 rotate sNaN -0 -> NaN Invalid_operation
+ddrot845 rotate sNaN 0 -> NaN Invalid_operation
+ddrot846 rotate sNaN 1 -> NaN Invalid_operation
+ddrot847 rotate sNaN 1000 -> NaN Invalid_operation
+ddrot848 rotate sNaN NaN -> NaN Invalid_operation
+ddrot849 rotate sNaN sNaN -> NaN Invalid_operation
+ddrot850 rotate NaN sNaN -> NaN Invalid_operation
+ddrot851 rotate -Inf sNaN -> NaN Invalid_operation
+ddrot852 rotate -1000 sNaN -> NaN Invalid_operation
+ddrot853 rotate -1 sNaN -> NaN Invalid_operation
+ddrot854 rotate -0 sNaN -> NaN Invalid_operation
+ddrot855 rotate 0 sNaN -> NaN Invalid_operation
+ddrot856 rotate 1 sNaN -> NaN Invalid_operation
+ddrot857 rotate 1000 sNaN -> NaN Invalid_operation
+ddrot858 rotate Inf sNaN -> NaN Invalid_operation
+ddrot859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddrot861 rotate NaN1 -Inf -> NaN1
+ddrot862 rotate +NaN2 -1000 -> NaN2
+ddrot863 rotate NaN3 1000 -> NaN3
+ddrot864 rotate NaN4 Inf -> NaN4
+ddrot865 rotate NaN5 +NaN6 -> NaN5
+ddrot866 rotate -Inf NaN7 -> NaN7
+ddrot867 rotate -1000 NaN8 -> NaN8
+ddrot868 rotate 1000 NaN9 -> NaN9
+ddrot869 rotate Inf +NaN10 -> NaN10
+ddrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+ddrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+ddrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+ddrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+ddrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+ddrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+ddrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+ddrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+ddrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+ddrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddrot882 rotate -NaN26 NaN28 -> -NaN26
+ddrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddrot884 rotate 1000 -NaN30 -> -NaN30
+ddrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddSameQuantum.decTest b/Lib/test/decimaltestdata/ddSameQuantum.decTest
index 465b36a8581..54a763cccf3 100644
--- a/Lib/test/decimaltestdata/ddSameQuantum.decTest
+++ b/Lib/test/decimaltestdata/ddSameQuantum.decTest
@@ -1,389 +1,389 @@
-------------------------------------------------------------------------
--- ddSameQuantum.decTest -- check decDouble quantums match --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decDoubles.
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddsamq001 samequantum 0 0 -> 1
-ddsamq002 samequantum 0 1 -> 1
-ddsamq003 samequantum 1 0 -> 1
-ddsamq004 samequantum 1 1 -> 1
-
-ddsamq011 samequantum 10 1E+1 -> 0
-ddsamq012 samequantum 10E+1 10E+1 -> 1
-ddsamq013 samequantum 100 10E+1 -> 0
-ddsamq014 samequantum 100 1E+2 -> 0
-ddsamq015 samequantum 0.1 1E-2 -> 0
-ddsamq016 samequantum 0.1 1E-1 -> 1
-ddsamq017 samequantum 0.1 1E-0 -> 0
-ddsamq018 samequantum 999 999 -> 1
-ddsamq019 samequantum 999E-1 99.9 -> 1
-ddsamq020 samequantum 111E-1 22.2 -> 1
-ddsamq021 samequantum 111E-1 1234.2 -> 1
-
--- zeros
-ddsamq030 samequantum 0.0 1.1 -> 1
-ddsamq031 samequantum 0.0 1.11 -> 0
-ddsamq032 samequantum 0.0 0 -> 0
-ddsamq033 samequantum 0.0 0.0 -> 1
-ddsamq034 samequantum 0.0 0.00 -> 0
-ddsamq035 samequantum 0E+1 0E+0 -> 0
-ddsamq036 samequantum 0E+1 0E+1 -> 1
-ddsamq037 samequantum 0E+1 0E+2 -> 0
-ddsamq038 samequantum 0E-17 0E-16 -> 0
-ddsamq039 samequantum 0E-17 0E-17 -> 1
-ddsamq040 samequantum 0E-17 0E-18 -> 0
-ddsamq041 samequantum 0E-17 0.0E-15 -> 0
-ddsamq042 samequantum 0E-17 0.0E-16 -> 1
-ddsamq043 samequantum 0E-17 0.0E-17 -> 0
-ddsamq044 samequantum -0E-17 0.0E-16 -> 1
-ddsamq045 samequantum 0E-17 -0.0E-17 -> 0
-ddsamq046 samequantum 0E-17 -0.0E-16 -> 1
-ddsamq047 samequantum -0E-17 0.0E-17 -> 0
-ddsamq048 samequantum -0E-17 -0.0E-16 -> 1
-ddsamq049 samequantum -0E-17 -0.0E-17 -> 0
-
--- Nmax, Nmin, Ntiny
-ddsamq051 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
-ddsamq052 samequantum 1E-383 1E-383 -> 1
-ddsamq053 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
-ddsamq054 samequantum 1E-398 1E-398 -> 1
-ddsamq055 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
-ddsamq056 samequantum 1E-383 1E-383 -> 1
-ddsamq057 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
-ddsamq058 samequantum 1E-398 1E-398 -> 1
-
-ddsamq061 samequantum -1E-398 -1E-398 -> 1
-ddsamq062 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
-ddsamq063 samequantum -1E-383 -1E-383 -> 1
-ddsamq064 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
-ddsamq065 samequantum -1E-398 -1E-398 -> 1
-ddsamq066 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
-ddsamq067 samequantum -1E-383 -1E-383 -> 1
-ddsamq068 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
-
-ddsamq071 samequantum -4E-398 -1E-398 -> 1
-ddsamq072 samequantum -4.000000000000000E-383 -1.000040000000000E-383 -> 1
-ddsamq073 samequantum -4E-383 -1E-383 -> 1
-ddsamq074 samequantum -4.999999999999999E+384 -9.999999999949999E+384 -> 1
-ddsamq075 samequantum -4E-398 -1E-398 -> 1
-ddsamq076 samequantum -4.000000000000000E-383 -1.004000000000000E-383 -> 1
-ddsamq077 samequantum -4E-383 -1E-383 -> 1
-ddsamq078 samequantum -4.999999999999999E+384 -9.949999999999999E+384 -> 1
-
-ddsamq081 samequantum -4E-397 -1E-398 -> 0
-ddsamq082 samequantum -4.000000000000000E-383 -1.000040000000000E-336 -> 0
-ddsamq083 samequantum -4E-346 -1E-383 -> 0
-ddsamq084 samequantum -4.999999999999999E+384 -9.999499999999999E+336 -> 0
-ddsamq085 samequantum -4E-397 -1E-398 -> 0
-ddsamq086 samequantum -4.000000000000000E-383 -1.004000000000000E-336 -> 0
-ddsamq087 samequantum -4E-346 -1E-383 -> 0
-ddsamq088 samequantum -4.999999999999999E+384 -9.949999999999999E+336 -> 0
-
--- specials & combinations
-ddsamq0110 samequantum -Inf -Inf -> 1
-ddsamq0111 samequantum -Inf Inf -> 1
-ddsamq0112 samequantum -Inf NaN -> 0
-ddsamq0113 samequantum -Inf -7E+3 -> 0
-ddsamq0114 samequantum -Inf -7 -> 0
-ddsamq0115 samequantum -Inf -7E-3 -> 0
-ddsamq0116 samequantum -Inf -0E-3 -> 0
-ddsamq0117 samequantum -Inf -0 -> 0
-ddsamq0118 samequantum -Inf -0E+3 -> 0
-ddsamq0119 samequantum -Inf 0E-3 -> 0
-ddsamq0120 samequantum -Inf 0 -> 0
-ddsamq0121 samequantum -Inf 0E+3 -> 0
-ddsamq0122 samequantum -Inf 7E-3 -> 0
-ddsamq0123 samequantum -Inf 7 -> 0
-ddsamq0124 samequantum -Inf 7E+3 -> 0
-ddsamq0125 samequantum -Inf sNaN -> 0
-
-ddsamq0210 samequantum Inf -Inf -> 1
-ddsamq0211 samequantum Inf Inf -> 1
-ddsamq0212 samequantum Inf NaN -> 0
-ddsamq0213 samequantum Inf -7E+3 -> 0
-ddsamq0214 samequantum Inf -7 -> 0
-ddsamq0215 samequantum Inf -7E-3 -> 0
-ddsamq0216 samequantum Inf -0E-3 -> 0
-ddsamq0217 samequantum Inf -0 -> 0
-ddsamq0218 samequantum Inf -0E+3 -> 0
-ddsamq0219 samequantum Inf 0E-3 -> 0
-ddsamq0220 samequantum Inf 0 -> 0
-ddsamq0221 samequantum Inf 0E+3 -> 0
-ddsamq0222 samequantum Inf 7E-3 -> 0
-ddsamq0223 samequantum Inf 7 -> 0
-ddsamq0224 samequantum Inf 7E+3 -> 0
-ddsamq0225 samequantum Inf sNaN -> 0
-
-ddsamq0310 samequantum NaN -Inf -> 0
-ddsamq0311 samequantum NaN Inf -> 0
-ddsamq0312 samequantum NaN NaN -> 1
-ddsamq0313 samequantum NaN -7E+3 -> 0
-ddsamq0314 samequantum NaN -7 -> 0
-ddsamq0315 samequantum NaN -7E-3 -> 0
-ddsamq0316 samequantum NaN -0E-3 -> 0
-ddsamq0317 samequantum NaN -0 -> 0
-ddsamq0318 samequantum NaN -0E+3 -> 0
-ddsamq0319 samequantum NaN 0E-3 -> 0
-ddsamq0320 samequantum NaN 0 -> 0
-ddsamq0321 samequantum NaN 0E+3 -> 0
-ddsamq0322 samequantum NaN 7E-3 -> 0
-ddsamq0323 samequantum NaN 7 -> 0
-ddsamq0324 samequantum NaN 7E+3 -> 0
-ddsamq0325 samequantum NaN sNaN -> 1
-
-ddsamq0410 samequantum -7E+3 -Inf -> 0
-ddsamq0411 samequantum -7E+3 Inf -> 0
-ddsamq0412 samequantum -7E+3 NaN -> 0
-ddsamq0413 samequantum -7E+3 -7E+3 -> 1
-ddsamq0414 samequantum -7E+3 -7 -> 0
-ddsamq0415 samequantum -7E+3 -7E-3 -> 0
-ddsamq0416 samequantum -7E+3 -0E-3 -> 0
-ddsamq0417 samequantum -7E+3 -0 -> 0
-ddsamq0418 samequantum -7E+3 -0E+3 -> 1
-ddsamq0419 samequantum -7E+3 0E-3 -> 0
-ddsamq0420 samequantum -7E+3 0 -> 0
-ddsamq0421 samequantum -7E+3 0E+3 -> 1
-ddsamq0422 samequantum -7E+3 7E-3 -> 0
-ddsamq0423 samequantum -7E+3 7 -> 0
-ddsamq0424 samequantum -7E+3 7E+3 -> 1
-ddsamq0425 samequantum -7E+3 sNaN -> 0
-
-ddsamq0510 samequantum -7 -Inf -> 0
-ddsamq0511 samequantum -7 Inf -> 0
-ddsamq0512 samequantum -7 NaN -> 0
-ddsamq0513 samequantum -7 -7E+3 -> 0
-ddsamq0514 samequantum -7 -7 -> 1
-ddsamq0515 samequantum -7 -7E-3 -> 0
-ddsamq0516 samequantum -7 -0E-3 -> 0
-ddsamq0517 samequantum -7 -0 -> 1
-ddsamq0518 samequantum -7 -0E+3 -> 0
-ddsamq0519 samequantum -7 0E-3 -> 0
-ddsamq0520 samequantum -7 0 -> 1
-ddsamq0521 samequantum -7 0E+3 -> 0
-ddsamq0522 samequantum -7 7E-3 -> 0
-ddsamq0523 samequantum -7 7 -> 1
-ddsamq0524 samequantum -7 7E+3 -> 0
-ddsamq0525 samequantum -7 sNaN -> 0
-
-ddsamq0610 samequantum -7E-3 -Inf -> 0
-ddsamq0611 samequantum -7E-3 Inf -> 0
-ddsamq0612 samequantum -7E-3 NaN -> 0
-ddsamq0613 samequantum -7E-3 -7E+3 -> 0
-ddsamq0614 samequantum -7E-3 -7 -> 0
-ddsamq0615 samequantum -7E-3 -7E-3 -> 1
-ddsamq0616 samequantum -7E-3 -0E-3 -> 1
-ddsamq0617 samequantum -7E-3 -0 -> 0
-ddsamq0618 samequantum -7E-3 -0E+3 -> 0
-ddsamq0619 samequantum -7E-3 0E-3 -> 1
-ddsamq0620 samequantum -7E-3 0 -> 0
-ddsamq0621 samequantum -7E-3 0E+3 -> 0
-ddsamq0622 samequantum -7E-3 7E-3 -> 1
-ddsamq0623 samequantum -7E-3 7 -> 0
-ddsamq0624 samequantum -7E-3 7E+3 -> 0
-ddsamq0625 samequantum -7E-3 sNaN -> 0
-
-ddsamq0710 samequantum -0E-3 -Inf -> 0
-ddsamq0711 samequantum -0E-3 Inf -> 0
-ddsamq0712 samequantum -0E-3 NaN -> 0
-ddsamq0713 samequantum -0E-3 -7E+3 -> 0
-ddsamq0714 samequantum -0E-3 -7 -> 0
-ddsamq0715 samequantum -0E-3 -7E-3 -> 1
-ddsamq0716 samequantum -0E-3 -0E-3 -> 1
-ddsamq0717 samequantum -0E-3 -0 -> 0
-ddsamq0718 samequantum -0E-3 -0E+3 -> 0
-ddsamq0719 samequantum -0E-3 0E-3 -> 1
-ddsamq0720 samequantum -0E-3 0 -> 0
-ddsamq0721 samequantum -0E-3 0E+3 -> 0
-ddsamq0722 samequantum -0E-3 7E-3 -> 1
-ddsamq0723 samequantum -0E-3 7 -> 0
-ddsamq0724 samequantum -0E-3 7E+3 -> 0
-ddsamq0725 samequantum -0E-3 sNaN -> 0
-
-ddsamq0810 samequantum -0 -Inf -> 0
-ddsamq0811 samequantum -0 Inf -> 0
-ddsamq0812 samequantum -0 NaN -> 0
-ddsamq0813 samequantum -0 -7E+3 -> 0
-ddsamq0814 samequantum -0 -7 -> 1
-ddsamq0815 samequantum -0 -7E-3 -> 0
-ddsamq0816 samequantum -0 -0E-3 -> 0
-ddsamq0817 samequantum -0 -0 -> 1
-ddsamq0818 samequantum -0 -0E+3 -> 0
-ddsamq0819 samequantum -0 0E-3 -> 0
-ddsamq0820 samequantum -0 0 -> 1
-ddsamq0821 samequantum -0 0E+3 -> 0
-ddsamq0822 samequantum -0 7E-3 -> 0
-ddsamq0823 samequantum -0 7 -> 1
-ddsamq0824 samequantum -0 7E+3 -> 0
-ddsamq0825 samequantum -0 sNaN -> 0
-
-ddsamq0910 samequantum -0E+3 -Inf -> 0
-ddsamq0911 samequantum -0E+3 Inf -> 0
-ddsamq0912 samequantum -0E+3 NaN -> 0
-ddsamq0913 samequantum -0E+3 -7E+3 -> 1
-ddsamq0914 samequantum -0E+3 -7 -> 0
-ddsamq0915 samequantum -0E+3 -7E-3 -> 0
-ddsamq0916 samequantum -0E+3 -0E-3 -> 0
-ddsamq0917 samequantum -0E+3 -0 -> 0
-ddsamq0918 samequantum -0E+3 -0E+3 -> 1
-ddsamq0919 samequantum -0E+3 0E-3 -> 0
-ddsamq0920 samequantum -0E+3 0 -> 0
-ddsamq0921 samequantum -0E+3 0E+3 -> 1
-ddsamq0922 samequantum -0E+3 7E-3 -> 0
-ddsamq0923 samequantum -0E+3 7 -> 0
-ddsamq0924 samequantum -0E+3 7E+3 -> 1
-ddsamq0925 samequantum -0E+3 sNaN -> 0
-
-ddsamq1110 samequantum 0E-3 -Inf -> 0
-ddsamq1111 samequantum 0E-3 Inf -> 0
-ddsamq1112 samequantum 0E-3 NaN -> 0
-ddsamq1113 samequantum 0E-3 -7E+3 -> 0
-ddsamq1114 samequantum 0E-3 -7 -> 0
-ddsamq1115 samequantum 0E-3 -7E-3 -> 1
-ddsamq1116 samequantum 0E-3 -0E-3 -> 1
-ddsamq1117 samequantum 0E-3 -0 -> 0
-ddsamq1118 samequantum 0E-3 -0E+3 -> 0
-ddsamq1119 samequantum 0E-3 0E-3 -> 1
-ddsamq1120 samequantum 0E-3 0 -> 0
-ddsamq1121 samequantum 0E-3 0E+3 -> 0
-ddsamq1122 samequantum 0E-3 7E-3 -> 1
-ddsamq1123 samequantum 0E-3 7 -> 0
-ddsamq1124 samequantum 0E-3 7E+3 -> 0
-ddsamq1125 samequantum 0E-3 sNaN -> 0
-
-ddsamq1210 samequantum 0 -Inf -> 0
-ddsamq1211 samequantum 0 Inf -> 0
-ddsamq1212 samequantum 0 NaN -> 0
-ddsamq1213 samequantum 0 -7E+3 -> 0
-ddsamq1214 samequantum 0 -7 -> 1
-ddsamq1215 samequantum 0 -7E-3 -> 0
-ddsamq1216 samequantum 0 -0E-3 -> 0
-ddsamq1217 samequantum 0 -0 -> 1
-ddsamq1218 samequantum 0 -0E+3 -> 0
-ddsamq1219 samequantum 0 0E-3 -> 0
-ddsamq1220 samequantum 0 0 -> 1
-ddsamq1221 samequantum 0 0E+3 -> 0
-ddsamq1222 samequantum 0 7E-3 -> 0
-ddsamq1223 samequantum 0 7 -> 1
-ddsamq1224 samequantum 0 7E+3 -> 0
-ddsamq1225 samequantum 0 sNaN -> 0
-
-ddsamq1310 samequantum 0E+3 -Inf -> 0
-ddsamq1311 samequantum 0E+3 Inf -> 0
-ddsamq1312 samequantum 0E+3 NaN -> 0
-ddsamq1313 samequantum 0E+3 -7E+3 -> 1
-ddsamq1314 samequantum 0E+3 -7 -> 0
-ddsamq1315 samequantum 0E+3 -7E-3 -> 0
-ddsamq1316 samequantum 0E+3 -0E-3 -> 0
-ddsamq1317 samequantum 0E+3 -0 -> 0
-ddsamq1318 samequantum 0E+3 -0E+3 -> 1
-ddsamq1319 samequantum 0E+3 0E-3 -> 0
-ddsamq1320 samequantum 0E+3 0 -> 0
-ddsamq1321 samequantum 0E+3 0E+3 -> 1
-ddsamq1322 samequantum 0E+3 7E-3 -> 0
-ddsamq1323 samequantum 0E+3 7 -> 0
-ddsamq1324 samequantum 0E+3 7E+3 -> 1
-ddsamq1325 samequantum 0E+3 sNaN -> 0
-
-ddsamq1410 samequantum 7E-3 -Inf -> 0
-ddsamq1411 samequantum 7E-3 Inf -> 0
-ddsamq1412 samequantum 7E-3 NaN -> 0
-ddsamq1413 samequantum 7E-3 -7E+3 -> 0
-ddsamq1414 samequantum 7E-3 -7 -> 0
-ddsamq1415 samequantum 7E-3 -7E-3 -> 1
-ddsamq1416 samequantum 7E-3 -0E-3 -> 1
-ddsamq1417 samequantum 7E-3 -0 -> 0
-ddsamq1418 samequantum 7E-3 -0E+3 -> 0
-ddsamq1419 samequantum 7E-3 0E-3 -> 1
-ddsamq1420 samequantum 7E-3 0 -> 0
-ddsamq1421 samequantum 7E-3 0E+3 -> 0
-ddsamq1422 samequantum 7E-3 7E-3 -> 1
-ddsamq1423 samequantum 7E-3 7 -> 0
-ddsamq1424 samequantum 7E-3 7E+3 -> 0
-ddsamq1425 samequantum 7E-3 sNaN -> 0
-
-ddsamq1510 samequantum 7 -Inf -> 0
-ddsamq1511 samequantum 7 Inf -> 0
-ddsamq1512 samequantum 7 NaN -> 0
-ddsamq1513 samequantum 7 -7E+3 -> 0
-ddsamq1514 samequantum 7 -7 -> 1
-ddsamq1515 samequantum 7 -7E-3 -> 0
-ddsamq1516 samequantum 7 -0E-3 -> 0
-ddsamq1517 samequantum 7 -0 -> 1
-ddsamq1518 samequantum 7 -0E+3 -> 0
-ddsamq1519 samequantum 7 0E-3 -> 0
-ddsamq1520 samequantum 7 0 -> 1
-ddsamq1521 samequantum 7 0E+3 -> 0
-ddsamq1522 samequantum 7 7E-3 -> 0
-ddsamq1523 samequantum 7 7 -> 1
-ddsamq1524 samequantum 7 7E+3 -> 0
-ddsamq1525 samequantum 7 sNaN -> 0
-
-ddsamq1610 samequantum 7E+3 -Inf -> 0
-ddsamq1611 samequantum 7E+3 Inf -> 0
-ddsamq1612 samequantum 7E+3 NaN -> 0
-ddsamq1613 samequantum 7E+3 -7E+3 -> 1
-ddsamq1614 samequantum 7E+3 -7 -> 0
-ddsamq1615 samequantum 7E+3 -7E-3 -> 0
-ddsamq1616 samequantum 7E+3 -0E-3 -> 0
-ddsamq1617 samequantum 7E+3 -0 -> 0
-ddsamq1618 samequantum 7E+3 -0E+3 -> 1
-ddsamq1619 samequantum 7E+3 0E-3 -> 0
-ddsamq1620 samequantum 7E+3 0 -> 0
-ddsamq1621 samequantum 7E+3 0E+3 -> 1
-ddsamq1622 samequantum 7E+3 7E-3 -> 0
-ddsamq1623 samequantum 7E+3 7 -> 0
-ddsamq1624 samequantum 7E+3 7E+3 -> 1
-ddsamq1625 samequantum 7E+3 sNaN -> 0
-
-ddsamq1710 samequantum sNaN -Inf -> 0
-ddsamq1711 samequantum sNaN Inf -> 0
-ddsamq1712 samequantum sNaN NaN -> 1
-ddsamq1713 samequantum sNaN -7E+3 -> 0
-ddsamq1714 samequantum sNaN -7 -> 0
-ddsamq1715 samequantum sNaN -7E-3 -> 0
-ddsamq1716 samequantum sNaN -0E-3 -> 0
-ddsamq1717 samequantum sNaN -0 -> 0
-ddsamq1718 samequantum sNaN -0E+3 -> 0
-ddsamq1719 samequantum sNaN 0E-3 -> 0
-ddsamq1720 samequantum sNaN 0 -> 0
-ddsamq1721 samequantum sNaN 0E+3 -> 0
-ddsamq1722 samequantum sNaN 7E-3 -> 0
-ddsamq1723 samequantum sNaN 7 -> 0
-ddsamq1724 samequantum sNaN 7E+3 -> 0
-ddsamq1725 samequantum sNaN sNaN -> 1
--- noisy NaNs
-ddsamq1730 samequantum sNaN3 sNaN3 -> 1
-ddsamq1731 samequantum sNaN3 sNaN4 -> 1
-ddsamq1732 samequantum NaN3 NaN3 -> 1
-ddsamq1733 samequantum NaN3 NaN4 -> 1
-ddsamq1734 samequantum sNaN3 3 -> 0
-ddsamq1735 samequantum NaN3 3 -> 0
-ddsamq1736 samequantum 4 sNaN4 -> 0
-ddsamq1737 samequantum 3 NaN3 -> 0
-ddsamq1738 samequantum Inf sNaN4 -> 0
-ddsamq1739 samequantum -Inf NaN3 -> 0
-
+------------------------------------------------------------------------
+-- ddSameQuantum.decTest -- check decDouble quantums match --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decDoubles.
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddsamq001 samequantum 0 0 -> 1
+ddsamq002 samequantum 0 1 -> 1
+ddsamq003 samequantum 1 0 -> 1
+ddsamq004 samequantum 1 1 -> 1
+
+ddsamq011 samequantum 10 1E+1 -> 0
+ddsamq012 samequantum 10E+1 10E+1 -> 1
+ddsamq013 samequantum 100 10E+1 -> 0
+ddsamq014 samequantum 100 1E+2 -> 0
+ddsamq015 samequantum 0.1 1E-2 -> 0
+ddsamq016 samequantum 0.1 1E-1 -> 1
+ddsamq017 samequantum 0.1 1E-0 -> 0
+ddsamq018 samequantum 999 999 -> 1
+ddsamq019 samequantum 999E-1 99.9 -> 1
+ddsamq020 samequantum 111E-1 22.2 -> 1
+ddsamq021 samequantum 111E-1 1234.2 -> 1
+
+-- zeros
+ddsamq030 samequantum 0.0 1.1 -> 1
+ddsamq031 samequantum 0.0 1.11 -> 0
+ddsamq032 samequantum 0.0 0 -> 0
+ddsamq033 samequantum 0.0 0.0 -> 1
+ddsamq034 samequantum 0.0 0.00 -> 0
+ddsamq035 samequantum 0E+1 0E+0 -> 0
+ddsamq036 samequantum 0E+1 0E+1 -> 1
+ddsamq037 samequantum 0E+1 0E+2 -> 0
+ddsamq038 samequantum 0E-17 0E-16 -> 0
+ddsamq039 samequantum 0E-17 0E-17 -> 1
+ddsamq040 samequantum 0E-17 0E-18 -> 0
+ddsamq041 samequantum 0E-17 0.0E-15 -> 0
+ddsamq042 samequantum 0E-17 0.0E-16 -> 1
+ddsamq043 samequantum 0E-17 0.0E-17 -> 0
+ddsamq044 samequantum -0E-17 0.0E-16 -> 1
+ddsamq045 samequantum 0E-17 -0.0E-17 -> 0
+ddsamq046 samequantum 0E-17 -0.0E-16 -> 1
+ddsamq047 samequantum -0E-17 0.0E-17 -> 0
+ddsamq048 samequantum -0E-17 -0.0E-16 -> 1
+ddsamq049 samequantum -0E-17 -0.0E-17 -> 0
+
+-- Nmax, Nmin, Ntiny
+ddsamq051 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
+ddsamq052 samequantum 1E-383 1E-383 -> 1
+ddsamq053 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
+ddsamq054 samequantum 1E-398 1E-398 -> 1
+ddsamq055 samequantum 9.999999999999999E+384 9.999999999999999E+384 -> 1
+ddsamq056 samequantum 1E-383 1E-383 -> 1
+ddsamq057 samequantum 1.000000000000000E-383 1.000000000000000E-383 -> 1
+ddsamq058 samequantum 1E-398 1E-398 -> 1
+
+ddsamq061 samequantum -1E-398 -1E-398 -> 1
+ddsamq062 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
+ddsamq063 samequantum -1E-383 -1E-383 -> 1
+ddsamq064 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
+ddsamq065 samequantum -1E-398 -1E-398 -> 1
+ddsamq066 samequantum -1.000000000000000E-383 -1.000000000000000E-383 -> 1
+ddsamq067 samequantum -1E-383 -1E-383 -> 1
+ddsamq068 samequantum -9.999999999999999E+384 -9.999999999999999E+384 -> 1
+
+ddsamq071 samequantum -4E-398 -1E-398 -> 1
+ddsamq072 samequantum -4.000000000000000E-383 -1.000040000000000E-383 -> 1
+ddsamq073 samequantum -4E-383 -1E-383 -> 1
+ddsamq074 samequantum -4.999999999999999E+384 -9.999999999949999E+384 -> 1
+ddsamq075 samequantum -4E-398 -1E-398 -> 1
+ddsamq076 samequantum -4.000000000000000E-383 -1.004000000000000E-383 -> 1
+ddsamq077 samequantum -4E-383 -1E-383 -> 1
+ddsamq078 samequantum -4.999999999999999E+384 -9.949999999999999E+384 -> 1
+
+ddsamq081 samequantum -4E-397 -1E-398 -> 0
+ddsamq082 samequantum -4.000000000000000E-383 -1.000040000000000E-336 -> 0
+ddsamq083 samequantum -4E-346 -1E-383 -> 0
+ddsamq084 samequantum -4.999999999999999E+384 -9.999499999999999E+336 -> 0
+ddsamq085 samequantum -4E-397 -1E-398 -> 0
+ddsamq086 samequantum -4.000000000000000E-383 -1.004000000000000E-336 -> 0
+ddsamq087 samequantum -4E-346 -1E-383 -> 0
+ddsamq088 samequantum -4.999999999999999E+384 -9.949999999999999E+336 -> 0
+
+-- specials & combinations
+ddsamq0110 samequantum -Inf -Inf -> 1
+ddsamq0111 samequantum -Inf Inf -> 1
+ddsamq0112 samequantum -Inf NaN -> 0
+ddsamq0113 samequantum -Inf -7E+3 -> 0
+ddsamq0114 samequantum -Inf -7 -> 0
+ddsamq0115 samequantum -Inf -7E-3 -> 0
+ddsamq0116 samequantum -Inf -0E-3 -> 0
+ddsamq0117 samequantum -Inf -0 -> 0
+ddsamq0118 samequantum -Inf -0E+3 -> 0
+ddsamq0119 samequantum -Inf 0E-3 -> 0
+ddsamq0120 samequantum -Inf 0 -> 0
+ddsamq0121 samequantum -Inf 0E+3 -> 0
+ddsamq0122 samequantum -Inf 7E-3 -> 0
+ddsamq0123 samequantum -Inf 7 -> 0
+ddsamq0124 samequantum -Inf 7E+3 -> 0
+ddsamq0125 samequantum -Inf sNaN -> 0
+
+ddsamq0210 samequantum Inf -Inf -> 1
+ddsamq0211 samequantum Inf Inf -> 1
+ddsamq0212 samequantum Inf NaN -> 0
+ddsamq0213 samequantum Inf -7E+3 -> 0
+ddsamq0214 samequantum Inf -7 -> 0
+ddsamq0215 samequantum Inf -7E-3 -> 0
+ddsamq0216 samequantum Inf -0E-3 -> 0
+ddsamq0217 samequantum Inf -0 -> 0
+ddsamq0218 samequantum Inf -0E+3 -> 0
+ddsamq0219 samequantum Inf 0E-3 -> 0
+ddsamq0220 samequantum Inf 0 -> 0
+ddsamq0221 samequantum Inf 0E+3 -> 0
+ddsamq0222 samequantum Inf 7E-3 -> 0
+ddsamq0223 samequantum Inf 7 -> 0
+ddsamq0224 samequantum Inf 7E+3 -> 0
+ddsamq0225 samequantum Inf sNaN -> 0
+
+ddsamq0310 samequantum NaN -Inf -> 0
+ddsamq0311 samequantum NaN Inf -> 0
+ddsamq0312 samequantum NaN NaN -> 1
+ddsamq0313 samequantum NaN -7E+3 -> 0
+ddsamq0314 samequantum NaN -7 -> 0
+ddsamq0315 samequantum NaN -7E-3 -> 0
+ddsamq0316 samequantum NaN -0E-3 -> 0
+ddsamq0317 samequantum NaN -0 -> 0
+ddsamq0318 samequantum NaN -0E+3 -> 0
+ddsamq0319 samequantum NaN 0E-3 -> 0
+ddsamq0320 samequantum NaN 0 -> 0
+ddsamq0321 samequantum NaN 0E+3 -> 0
+ddsamq0322 samequantum NaN 7E-3 -> 0
+ddsamq0323 samequantum NaN 7 -> 0
+ddsamq0324 samequantum NaN 7E+3 -> 0
+ddsamq0325 samequantum NaN sNaN -> 1
+
+ddsamq0410 samequantum -7E+3 -Inf -> 0
+ddsamq0411 samequantum -7E+3 Inf -> 0
+ddsamq0412 samequantum -7E+3 NaN -> 0
+ddsamq0413 samequantum -7E+3 -7E+3 -> 1
+ddsamq0414 samequantum -7E+3 -7 -> 0
+ddsamq0415 samequantum -7E+3 -7E-3 -> 0
+ddsamq0416 samequantum -7E+3 -0E-3 -> 0
+ddsamq0417 samequantum -7E+3 -0 -> 0
+ddsamq0418 samequantum -7E+3 -0E+3 -> 1
+ddsamq0419 samequantum -7E+3 0E-3 -> 0
+ddsamq0420 samequantum -7E+3 0 -> 0
+ddsamq0421 samequantum -7E+3 0E+3 -> 1
+ddsamq0422 samequantum -7E+3 7E-3 -> 0
+ddsamq0423 samequantum -7E+3 7 -> 0
+ddsamq0424 samequantum -7E+3 7E+3 -> 1
+ddsamq0425 samequantum -7E+3 sNaN -> 0
+
+ddsamq0510 samequantum -7 -Inf -> 0
+ddsamq0511 samequantum -7 Inf -> 0
+ddsamq0512 samequantum -7 NaN -> 0
+ddsamq0513 samequantum -7 -7E+3 -> 0
+ddsamq0514 samequantum -7 -7 -> 1
+ddsamq0515 samequantum -7 -7E-3 -> 0
+ddsamq0516 samequantum -7 -0E-3 -> 0
+ddsamq0517 samequantum -7 -0 -> 1
+ddsamq0518 samequantum -7 -0E+3 -> 0
+ddsamq0519 samequantum -7 0E-3 -> 0
+ddsamq0520 samequantum -7 0 -> 1
+ddsamq0521 samequantum -7 0E+3 -> 0
+ddsamq0522 samequantum -7 7E-3 -> 0
+ddsamq0523 samequantum -7 7 -> 1
+ddsamq0524 samequantum -7 7E+3 -> 0
+ddsamq0525 samequantum -7 sNaN -> 0
+
+ddsamq0610 samequantum -7E-3 -Inf -> 0
+ddsamq0611 samequantum -7E-3 Inf -> 0
+ddsamq0612 samequantum -7E-3 NaN -> 0
+ddsamq0613 samequantum -7E-3 -7E+3 -> 0
+ddsamq0614 samequantum -7E-3 -7 -> 0
+ddsamq0615 samequantum -7E-3 -7E-3 -> 1
+ddsamq0616 samequantum -7E-3 -0E-3 -> 1
+ddsamq0617 samequantum -7E-3 -0 -> 0
+ddsamq0618 samequantum -7E-3 -0E+3 -> 0
+ddsamq0619 samequantum -7E-3 0E-3 -> 1
+ddsamq0620 samequantum -7E-3 0 -> 0
+ddsamq0621 samequantum -7E-3 0E+3 -> 0
+ddsamq0622 samequantum -7E-3 7E-3 -> 1
+ddsamq0623 samequantum -7E-3 7 -> 0
+ddsamq0624 samequantum -7E-3 7E+3 -> 0
+ddsamq0625 samequantum -7E-3 sNaN -> 0
+
+ddsamq0710 samequantum -0E-3 -Inf -> 0
+ddsamq0711 samequantum -0E-3 Inf -> 0
+ddsamq0712 samequantum -0E-3 NaN -> 0
+ddsamq0713 samequantum -0E-3 -7E+3 -> 0
+ddsamq0714 samequantum -0E-3 -7 -> 0
+ddsamq0715 samequantum -0E-3 -7E-3 -> 1
+ddsamq0716 samequantum -0E-3 -0E-3 -> 1
+ddsamq0717 samequantum -0E-3 -0 -> 0
+ddsamq0718 samequantum -0E-3 -0E+3 -> 0
+ddsamq0719 samequantum -0E-3 0E-3 -> 1
+ddsamq0720 samequantum -0E-3 0 -> 0
+ddsamq0721 samequantum -0E-3 0E+3 -> 0
+ddsamq0722 samequantum -0E-3 7E-3 -> 1
+ddsamq0723 samequantum -0E-3 7 -> 0
+ddsamq0724 samequantum -0E-3 7E+3 -> 0
+ddsamq0725 samequantum -0E-3 sNaN -> 0
+
+ddsamq0810 samequantum -0 -Inf -> 0
+ddsamq0811 samequantum -0 Inf -> 0
+ddsamq0812 samequantum -0 NaN -> 0
+ddsamq0813 samequantum -0 -7E+3 -> 0
+ddsamq0814 samequantum -0 -7 -> 1
+ddsamq0815 samequantum -0 -7E-3 -> 0
+ddsamq0816 samequantum -0 -0E-3 -> 0
+ddsamq0817 samequantum -0 -0 -> 1
+ddsamq0818 samequantum -0 -0E+3 -> 0
+ddsamq0819 samequantum -0 0E-3 -> 0
+ddsamq0820 samequantum -0 0 -> 1
+ddsamq0821 samequantum -0 0E+3 -> 0
+ddsamq0822 samequantum -0 7E-3 -> 0
+ddsamq0823 samequantum -0 7 -> 1
+ddsamq0824 samequantum -0 7E+3 -> 0
+ddsamq0825 samequantum -0 sNaN -> 0
+
+ddsamq0910 samequantum -0E+3 -Inf -> 0
+ddsamq0911 samequantum -0E+3 Inf -> 0
+ddsamq0912 samequantum -0E+3 NaN -> 0
+ddsamq0913 samequantum -0E+3 -7E+3 -> 1
+ddsamq0914 samequantum -0E+3 -7 -> 0
+ddsamq0915 samequantum -0E+3 -7E-3 -> 0
+ddsamq0916 samequantum -0E+3 -0E-3 -> 0
+ddsamq0917 samequantum -0E+3 -0 -> 0
+ddsamq0918 samequantum -0E+3 -0E+3 -> 1
+ddsamq0919 samequantum -0E+3 0E-3 -> 0
+ddsamq0920 samequantum -0E+3 0 -> 0
+ddsamq0921 samequantum -0E+3 0E+3 -> 1
+ddsamq0922 samequantum -0E+3 7E-3 -> 0
+ddsamq0923 samequantum -0E+3 7 -> 0
+ddsamq0924 samequantum -0E+3 7E+3 -> 1
+ddsamq0925 samequantum -0E+3 sNaN -> 0
+
+ddsamq1110 samequantum 0E-3 -Inf -> 0
+ddsamq1111 samequantum 0E-3 Inf -> 0
+ddsamq1112 samequantum 0E-3 NaN -> 0
+ddsamq1113 samequantum 0E-3 -7E+3 -> 0
+ddsamq1114 samequantum 0E-3 -7 -> 0
+ddsamq1115 samequantum 0E-3 -7E-3 -> 1
+ddsamq1116 samequantum 0E-3 -0E-3 -> 1
+ddsamq1117 samequantum 0E-3 -0 -> 0
+ddsamq1118 samequantum 0E-3 -0E+3 -> 0
+ddsamq1119 samequantum 0E-3 0E-3 -> 1
+ddsamq1120 samequantum 0E-3 0 -> 0
+ddsamq1121 samequantum 0E-3 0E+3 -> 0
+ddsamq1122 samequantum 0E-3 7E-3 -> 1
+ddsamq1123 samequantum 0E-3 7 -> 0
+ddsamq1124 samequantum 0E-3 7E+3 -> 0
+ddsamq1125 samequantum 0E-3 sNaN -> 0
+
+ddsamq1210 samequantum 0 -Inf -> 0
+ddsamq1211 samequantum 0 Inf -> 0
+ddsamq1212 samequantum 0 NaN -> 0
+ddsamq1213 samequantum 0 -7E+3 -> 0
+ddsamq1214 samequantum 0 -7 -> 1
+ddsamq1215 samequantum 0 -7E-3 -> 0
+ddsamq1216 samequantum 0 -0E-3 -> 0
+ddsamq1217 samequantum 0 -0 -> 1
+ddsamq1218 samequantum 0 -0E+3 -> 0
+ddsamq1219 samequantum 0 0E-3 -> 0
+ddsamq1220 samequantum 0 0 -> 1
+ddsamq1221 samequantum 0 0E+3 -> 0
+ddsamq1222 samequantum 0 7E-3 -> 0
+ddsamq1223 samequantum 0 7 -> 1
+ddsamq1224 samequantum 0 7E+3 -> 0
+ddsamq1225 samequantum 0 sNaN -> 0
+
+ddsamq1310 samequantum 0E+3 -Inf -> 0
+ddsamq1311 samequantum 0E+3 Inf -> 0
+ddsamq1312 samequantum 0E+3 NaN -> 0
+ddsamq1313 samequantum 0E+3 -7E+3 -> 1
+ddsamq1314 samequantum 0E+3 -7 -> 0
+ddsamq1315 samequantum 0E+3 -7E-3 -> 0
+ddsamq1316 samequantum 0E+3 -0E-3 -> 0
+ddsamq1317 samequantum 0E+3 -0 -> 0
+ddsamq1318 samequantum 0E+3 -0E+3 -> 1
+ddsamq1319 samequantum 0E+3 0E-3 -> 0
+ddsamq1320 samequantum 0E+3 0 -> 0
+ddsamq1321 samequantum 0E+3 0E+3 -> 1
+ddsamq1322 samequantum 0E+3 7E-3 -> 0
+ddsamq1323 samequantum 0E+3 7 -> 0
+ddsamq1324 samequantum 0E+3 7E+3 -> 1
+ddsamq1325 samequantum 0E+3 sNaN -> 0
+
+ddsamq1410 samequantum 7E-3 -Inf -> 0
+ddsamq1411 samequantum 7E-3 Inf -> 0
+ddsamq1412 samequantum 7E-3 NaN -> 0
+ddsamq1413 samequantum 7E-3 -7E+3 -> 0
+ddsamq1414 samequantum 7E-3 -7 -> 0
+ddsamq1415 samequantum 7E-3 -7E-3 -> 1
+ddsamq1416 samequantum 7E-3 -0E-3 -> 1
+ddsamq1417 samequantum 7E-3 -0 -> 0
+ddsamq1418 samequantum 7E-3 -0E+3 -> 0
+ddsamq1419 samequantum 7E-3 0E-3 -> 1
+ddsamq1420 samequantum 7E-3 0 -> 0
+ddsamq1421 samequantum 7E-3 0E+3 -> 0
+ddsamq1422 samequantum 7E-3 7E-3 -> 1
+ddsamq1423 samequantum 7E-3 7 -> 0
+ddsamq1424 samequantum 7E-3 7E+3 -> 0
+ddsamq1425 samequantum 7E-3 sNaN -> 0
+
+ddsamq1510 samequantum 7 -Inf -> 0
+ddsamq1511 samequantum 7 Inf -> 0
+ddsamq1512 samequantum 7 NaN -> 0
+ddsamq1513 samequantum 7 -7E+3 -> 0
+ddsamq1514 samequantum 7 -7 -> 1
+ddsamq1515 samequantum 7 -7E-3 -> 0
+ddsamq1516 samequantum 7 -0E-3 -> 0
+ddsamq1517 samequantum 7 -0 -> 1
+ddsamq1518 samequantum 7 -0E+3 -> 0
+ddsamq1519 samequantum 7 0E-3 -> 0
+ddsamq1520 samequantum 7 0 -> 1
+ddsamq1521 samequantum 7 0E+3 -> 0
+ddsamq1522 samequantum 7 7E-3 -> 0
+ddsamq1523 samequantum 7 7 -> 1
+ddsamq1524 samequantum 7 7E+3 -> 0
+ddsamq1525 samequantum 7 sNaN -> 0
+
+ddsamq1610 samequantum 7E+3 -Inf -> 0
+ddsamq1611 samequantum 7E+3 Inf -> 0
+ddsamq1612 samequantum 7E+3 NaN -> 0
+ddsamq1613 samequantum 7E+3 -7E+3 -> 1
+ddsamq1614 samequantum 7E+3 -7 -> 0
+ddsamq1615 samequantum 7E+3 -7E-3 -> 0
+ddsamq1616 samequantum 7E+3 -0E-3 -> 0
+ddsamq1617 samequantum 7E+3 -0 -> 0
+ddsamq1618 samequantum 7E+3 -0E+3 -> 1
+ddsamq1619 samequantum 7E+3 0E-3 -> 0
+ddsamq1620 samequantum 7E+3 0 -> 0
+ddsamq1621 samequantum 7E+3 0E+3 -> 1
+ddsamq1622 samequantum 7E+3 7E-3 -> 0
+ddsamq1623 samequantum 7E+3 7 -> 0
+ddsamq1624 samequantum 7E+3 7E+3 -> 1
+ddsamq1625 samequantum 7E+3 sNaN -> 0
+
+ddsamq1710 samequantum sNaN -Inf -> 0
+ddsamq1711 samequantum sNaN Inf -> 0
+ddsamq1712 samequantum sNaN NaN -> 1
+ddsamq1713 samequantum sNaN -7E+3 -> 0
+ddsamq1714 samequantum sNaN -7 -> 0
+ddsamq1715 samequantum sNaN -7E-3 -> 0
+ddsamq1716 samequantum sNaN -0E-3 -> 0
+ddsamq1717 samequantum sNaN -0 -> 0
+ddsamq1718 samequantum sNaN -0E+3 -> 0
+ddsamq1719 samequantum sNaN 0E-3 -> 0
+ddsamq1720 samequantum sNaN 0 -> 0
+ddsamq1721 samequantum sNaN 0E+3 -> 0
+ddsamq1722 samequantum sNaN 7E-3 -> 0
+ddsamq1723 samequantum sNaN 7 -> 0
+ddsamq1724 samequantum sNaN 7E+3 -> 0
+ddsamq1725 samequantum sNaN sNaN -> 1
+-- noisy NaNs
+ddsamq1730 samequantum sNaN3 sNaN3 -> 1
+ddsamq1731 samequantum sNaN3 sNaN4 -> 1
+ddsamq1732 samequantum NaN3 NaN3 -> 1
+ddsamq1733 samequantum NaN3 NaN4 -> 1
+ddsamq1734 samequantum sNaN3 3 -> 0
+ddsamq1735 samequantum NaN3 3 -> 0
+ddsamq1736 samequantum 4 sNaN4 -> 0
+ddsamq1737 samequantum 3 NaN3 -> 0
+ddsamq1738 samequantum Inf sNaN4 -> 0
+ddsamq1739 samequantum -Inf NaN3 -> 0
+
diff --git a/Lib/test/decimaltestdata/ddScaleB.decTest b/Lib/test/decimaltestdata/ddScaleB.decTest
index edee11bccc9..6ba3e3976f8 100644
--- a/Lib/test/decimaltestdata/ddScaleB.decTest
+++ b/Lib/test/decimaltestdata/ddScaleB.decTest
@@ -1,243 +1,243 @@
-------------------------------------------------------------------------
--- ddScalebB.decTest -- scale a decDouble by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Max |rhs| is 2*(384+16) = 800
-
--- Sanity checks
-ddscb001 scaleb 7.50 10 -> 7.50E+10
-ddscb002 scaleb 7.50 3 -> 7.50E+3
-ddscb003 scaleb 7.50 2 -> 750
-ddscb004 scaleb 7.50 1 -> 75.0
-ddscb005 scaleb 7.50 0 -> 7.50
-ddscb006 scaleb 7.50 -1 -> 0.750
-ddscb007 scaleb 7.50 -2 -> 0.0750
-ddscb008 scaleb 7.50 -10 -> 7.50E-10
-ddscb009 scaleb -7.50 3 -> -7.50E+3
-ddscb010 scaleb -7.50 2 -> -750
-ddscb011 scaleb -7.50 1 -> -75.0
-ddscb012 scaleb -7.50 0 -> -7.50
-ddscb013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-ddscb014 scaleb Infinity 1 -> Infinity
-ddscb015 scaleb -Infinity 2 -> -Infinity
-ddscb016 scaleb Infinity -1 -> Infinity
-ddscb017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-ddscb018 scaleb 10 Infinity -> NaN Invalid_operation
-ddscb019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-ddscb021 scaleb NaN 1 -> NaN
-ddscb022 scaleb -NaN -1 -> -NaN
-ddscb023 scaleb sNaN 1 -> NaN Invalid_operation
-ddscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
-ddscb025 scaleb 4 NaN -> NaN
-ddscb026 scaleb -Inf -NaN -> -NaN
-ddscb027 scaleb 4 sNaN -> NaN Invalid_operation
-ddscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-ddscb030 scaleb 1.23 1 -> 12.3
-ddscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
-ddscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
-ddscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
-ddscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
-ddscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
-ddscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-ddscb037 scaleb 1.23 -1 -> 0.123
-ddscb038 scaleb 1.23 -1.00 -> NaN Invalid_operation
-ddscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-ddscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-ddscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-ddscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-ddscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-ddscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
-ddscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-ddscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-ddscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
--- out-of range RHS
-ddscb120 scaleb 1.23 799 -> Infinity Overflow Inexact Rounded
-ddscb121 scaleb 1.23 800 -> Infinity Overflow Inexact Rounded
-ddscb122 scaleb 1.23 801 -> NaN Invalid_operation
-ddscb123 scaleb 1.23 802 -> NaN Invalid_operation
-ddscb124 scaleb 1.23 -799 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb125 scaleb 1.23 -800 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb126 scaleb 1.23 -801 -> NaN Invalid_operation
-ddscb127 scaleb 1.23 -802 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-ddscb861 scaleb NaN01 -Inf -> NaN1
-ddscb862 scaleb -NaN02 -1000 -> -NaN2
-ddscb863 scaleb NaN03 1000 -> NaN3
-ddscb864 scaleb NaN04 Inf -> NaN4
-ddscb865 scaleb NaN05 NaN61 -> NaN5
-ddscb866 scaleb -Inf -NaN71 -> -NaN71
-ddscb867 scaleb -1000 NaN81 -> NaN81
-ddscb868 scaleb 1000 NaN91 -> NaN91
-ddscb869 scaleb Inf NaN101 -> NaN101
-ddscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-ddscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-ddscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-ddscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-ddscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-ddscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-ddscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-ddscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-ddscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-ddscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-ddscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-ddscb051 scaleb 7 -2 -> 0.07
-ddscb052 scaleb -7 -2 -> -0.07
-ddscb053 scaleb 75 -2 -> 0.75
-ddscb054 scaleb -75 -2 -> -0.75
-ddscb055 scaleb 7.50 -2 -> 0.0750
-ddscb056 scaleb -7.50 -2 -> -0.0750
-ddscb057 scaleb 7.500 -2 -> 0.07500
-ddscb058 scaleb -7.500 -2 -> -0.07500
-ddscb061 scaleb 7 -1 -> 0.7
-ddscb062 scaleb -7 -1 -> -0.7
-ddscb063 scaleb 75 -1 -> 7.5
-ddscb064 scaleb -75 -1 -> -7.5
-ddscb065 scaleb 7.50 -1 -> 0.750
-ddscb066 scaleb -7.50 -1 -> -0.750
-ddscb067 scaleb 7.500 -1 -> 0.7500
-ddscb068 scaleb -7.500 -1 -> -0.7500
-ddscb071 scaleb 7 0 -> 7
-ddscb072 scaleb -7 0 -> -7
-ddscb073 scaleb 75 0 -> 75
-ddscb074 scaleb -75 0 -> -75
-ddscb075 scaleb 7.50 0 -> 7.50
-ddscb076 scaleb -7.50 0 -> -7.50
-ddscb077 scaleb 7.500 0 -> 7.500
-ddscb078 scaleb -7.500 0 -> -7.500
-ddscb081 scaleb 7 1 -> 7E+1
-ddscb082 scaleb -7 1 -> -7E+1
-ddscb083 scaleb 75 1 -> 7.5E+2
-ddscb084 scaleb -75 1 -> -7.5E+2
-ddscb085 scaleb 7.50 1 -> 75.0
-ddscb086 scaleb -7.50 1 -> -75.0
-ddscb087 scaleb 7.500 1 -> 75.00
-ddscb088 scaleb -7.500 1 -> -75.00
-ddscb091 scaleb 7 2 -> 7E+2
-ddscb092 scaleb -7 2 -> -7E+2
-ddscb093 scaleb 75 2 -> 7.5E+3
-ddscb094 scaleb -75 2 -> -7.5E+3
-ddscb095 scaleb 7.50 2 -> 750
-ddscb096 scaleb -7.50 2 -> -750
-ddscb097 scaleb 7.500 2 -> 750.0
-ddscb098 scaleb -7.500 2 -> -750.0
-
--- zeros
-ddscb111 scaleb 0 1 -> 0E+1
-ddscb112 scaleb -0 2 -> -0E+2
-ddscb113 scaleb 0E+4 3 -> 0E+7
-ddscb114 scaleb -0E+4 4 -> -0E+8
-ddscb115 scaleb 0.0000 5 -> 0E+1
-ddscb116 scaleb -0.0000 6 -> -0E+2
-ddscb117 scaleb 0E-141 7 -> 0E-134
-ddscb118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-ddscb132 scaleb 9.999999999999999E+384 +384 -> Infinity Overflow Inexact Rounded
-ddscb133 scaleb 9.999999999999999E+384 +10 -> Infinity Overflow Inexact Rounded
-ddscb134 scaleb 9.999999999999999E+384 +1 -> Infinity Overflow Inexact Rounded
-ddscb135 scaleb 9.999999999999999E+384 0 -> 9.999999999999999E+384
-ddscb136 scaleb 9.999999999999999E+384 -1 -> 9.999999999999999E+383
-ddscb137 scaleb 1E-383 +1 -> 1E-382
-ddscb138 scaleb 1E-383 -0 -> 1E-383
-ddscb139 scaleb 1E-383 -1 -> 1E-384 Subnormal
-ddscb140 scaleb 1.000000000000000E-383 +1 -> 1.000000000000000E-382
-ddscb141 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
-ddscb142 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
-ddscb143 scaleb 1E-398 +1 -> 1E-397 Subnormal
-ddscb144 scaleb 1E-398 -0 -> 1E-398 Subnormal
-ddscb145 scaleb 1E-398 -1 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
-ddscb150 scaleb -1E-398 +1 -> -1E-397 Subnormal
-ddscb151 scaleb -1E-398 -0 -> -1E-398 Subnormal
-ddscb152 scaleb -1E-398 -1 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb153 scaleb -1.000000000000000E-383 +1 -> -1.000000000000000E-382
-ddscb154 scaleb -1.000000000000000E-383 +0 -> -1.000000000000000E-383
-ddscb155 scaleb -1.000000000000000E-383 -1 -> -1.00000000000000E-384 Subnormal Rounded
-ddscb156 scaleb -1E-383 +1 -> -1E-382
-ddscb157 scaleb -1E-383 -0 -> -1E-383
-ddscb158 scaleb -1E-383 -1 -> -1E-384 Subnormal
-ddscb159 scaleb -9.999999999999999E+384 +1 -> -Infinity Overflow Inexact Rounded
-ddscb160 scaleb -9.999999999999999E+384 +0 -> -9.999999999999999E+384
-ddscb161 scaleb -9.999999999999999E+384 -1 -> -9.999999999999999E+383
-ddscb162 scaleb -9E+384 +1 -> -Infinity Overflow Inexact Rounded
-ddscb163 scaleb -1E+384 +1 -> -Infinity Overflow Inexact Rounded
-
--- some Origami
--- (these check that overflow is being done correctly)
-ddscb171 scaleb 1000E+365 +1 -> 1.000E+369
-ddscb172 scaleb 1000E+366 +1 -> 1.000E+370
-ddscb173 scaleb 1000E+367 +1 -> 1.000E+371
-ddscb174 scaleb 1000E+368 +1 -> 1.000E+372
-ddscb175 scaleb 1000E+369 +1 -> 1.0000E+373 Clamped
-ddscb176 scaleb 1000E+370 +1 -> 1.00000E+374 Clamped
-ddscb177 scaleb 1000E+371 +1 -> 1.000000E+375 Clamped
-ddscb178 scaleb 1000E+372 +1 -> 1.0000000E+376 Clamped
-ddscb179 scaleb 1000E+373 +1 -> 1.00000000E+377 Clamped
-ddscb180 scaleb 1000E+374 +1 -> 1.000000000E+378 Clamped
-ddscb181 scaleb 1000E+375 +1 -> 1.0000000000E+379 Clamped
-ddscb182 scaleb 1000E+376 +1 -> 1.00000000000E+380 Clamped
-ddscb183 scaleb 1000E+377 +1 -> 1.000000000000E+381 Clamped
-ddscb184 scaleb 1000E+378 +1 -> 1.0000000000000E+382 Clamped
-ddscb185 scaleb 1000E+379 +1 -> 1.00000000000000E+383 Clamped
-ddscb186 scaleb 1000E+380 +1 -> 1.000000000000000E+384 Clamped
-ddscb187 scaleb 1000E+381 +1 -> Infinity Overflow Inexact Rounded
-
--- and a few more subnormal truncations
--- (these check that underflow is being done correctly)
-ddscb201 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
-ddscb202 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
-ddscb203 scaleb 1.000000000000000E-383 -2 -> 1.0000000000000E-385 Subnormal Rounded
-ddscb204 scaleb 1.000000000000000E-383 -3 -> 1.000000000000E-386 Subnormal Rounded
-ddscb205 scaleb 1.000000000000000E-383 -4 -> 1.00000000000E-387 Subnormal Rounded
-ddscb206 scaleb 1.000000000000000E-383 -5 -> 1.0000000000E-388 Subnormal Rounded
-ddscb207 scaleb 1.000000000000000E-383 -6 -> 1.000000000E-389 Subnormal Rounded
-ddscb208 scaleb 1.000000000000000E-383 -7 -> 1.00000000E-390 Subnormal Rounded
-ddscb209 scaleb 1.000000000000000E-383 -8 -> 1.0000000E-391 Subnormal Rounded
-ddscb210 scaleb 1.000000000000000E-383 -9 -> 1.000000E-392 Subnormal Rounded
-ddscb211 scaleb 1.000000000000000E-383 -10 -> 1.00000E-393 Subnormal Rounded
-ddscb212 scaleb 1.000000000000000E-383 -11 -> 1.0000E-394 Subnormal Rounded
-ddscb213 scaleb 1.000000000000000E-383 -12 -> 1.000E-395 Subnormal Rounded
-ddscb214 scaleb 1.000000000000000E-383 -13 -> 1.00E-396 Subnormal Rounded
-ddscb215 scaleb 1.000000000000000E-383 -14 -> 1.0E-397 Subnormal Rounded
-ddscb216 scaleb 1.000000000000000E-383 -15 -> 1E-398 Subnormal Rounded
-ddscb217 scaleb 1.000000000000000E-383 -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-ddscb218 scaleb 1.000000000000000E-383 -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
-
+------------------------------------------------------------------------
+-- ddScalebB.decTest -- scale a decDouble by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Max |rhs| is 2*(384+16) = 800
+
+-- Sanity checks
+ddscb001 scaleb 7.50 10 -> 7.50E+10
+ddscb002 scaleb 7.50 3 -> 7.50E+3
+ddscb003 scaleb 7.50 2 -> 750
+ddscb004 scaleb 7.50 1 -> 75.0
+ddscb005 scaleb 7.50 0 -> 7.50
+ddscb006 scaleb 7.50 -1 -> 0.750
+ddscb007 scaleb 7.50 -2 -> 0.0750
+ddscb008 scaleb 7.50 -10 -> 7.50E-10
+ddscb009 scaleb -7.50 3 -> -7.50E+3
+ddscb010 scaleb -7.50 2 -> -750
+ddscb011 scaleb -7.50 1 -> -75.0
+ddscb012 scaleb -7.50 0 -> -7.50
+ddscb013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+ddscb014 scaleb Infinity 1 -> Infinity
+ddscb015 scaleb -Infinity 2 -> -Infinity
+ddscb016 scaleb Infinity -1 -> Infinity
+ddscb017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+ddscb018 scaleb 10 Infinity -> NaN Invalid_operation
+ddscb019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+ddscb021 scaleb NaN 1 -> NaN
+ddscb022 scaleb -NaN -1 -> -NaN
+ddscb023 scaleb sNaN 1 -> NaN Invalid_operation
+ddscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
+ddscb025 scaleb 4 NaN -> NaN
+ddscb026 scaleb -Inf -NaN -> -NaN
+ddscb027 scaleb 4 sNaN -> NaN Invalid_operation
+ddscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+ddscb030 scaleb 1.23 1 -> 12.3
+ddscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
+ddscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
+ddscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
+ddscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
+ddscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
+ddscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+ddscb037 scaleb 1.23 -1 -> 0.123
+ddscb038 scaleb 1.23 -1.00 -> NaN Invalid_operation
+ddscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+ddscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+ddscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+ddscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+ddscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+ddscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
+ddscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+ddscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+ddscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+-- out-of range RHS
+ddscb120 scaleb 1.23 799 -> Infinity Overflow Inexact Rounded
+ddscb121 scaleb 1.23 800 -> Infinity Overflow Inexact Rounded
+ddscb122 scaleb 1.23 801 -> NaN Invalid_operation
+ddscb123 scaleb 1.23 802 -> NaN Invalid_operation
+ddscb124 scaleb 1.23 -799 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb125 scaleb 1.23 -800 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb126 scaleb 1.23 -801 -> NaN Invalid_operation
+ddscb127 scaleb 1.23 -802 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+ddscb861 scaleb NaN01 -Inf -> NaN1
+ddscb862 scaleb -NaN02 -1000 -> -NaN2
+ddscb863 scaleb NaN03 1000 -> NaN3
+ddscb864 scaleb NaN04 Inf -> NaN4
+ddscb865 scaleb NaN05 NaN61 -> NaN5
+ddscb866 scaleb -Inf -NaN71 -> -NaN71
+ddscb867 scaleb -1000 NaN81 -> NaN81
+ddscb868 scaleb 1000 NaN91 -> NaN91
+ddscb869 scaleb Inf NaN101 -> NaN101
+ddscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+ddscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+ddscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+ddscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+ddscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+ddscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+ddscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+ddscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+ddscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+ddscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+ddscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+ddscb051 scaleb 7 -2 -> 0.07
+ddscb052 scaleb -7 -2 -> -0.07
+ddscb053 scaleb 75 -2 -> 0.75
+ddscb054 scaleb -75 -2 -> -0.75
+ddscb055 scaleb 7.50 -2 -> 0.0750
+ddscb056 scaleb -7.50 -2 -> -0.0750
+ddscb057 scaleb 7.500 -2 -> 0.07500
+ddscb058 scaleb -7.500 -2 -> -0.07500
+ddscb061 scaleb 7 -1 -> 0.7
+ddscb062 scaleb -7 -1 -> -0.7
+ddscb063 scaleb 75 -1 -> 7.5
+ddscb064 scaleb -75 -1 -> -7.5
+ddscb065 scaleb 7.50 -1 -> 0.750
+ddscb066 scaleb -7.50 -1 -> -0.750
+ddscb067 scaleb 7.500 -1 -> 0.7500
+ddscb068 scaleb -7.500 -1 -> -0.7500
+ddscb071 scaleb 7 0 -> 7
+ddscb072 scaleb -7 0 -> -7
+ddscb073 scaleb 75 0 -> 75
+ddscb074 scaleb -75 0 -> -75
+ddscb075 scaleb 7.50 0 -> 7.50
+ddscb076 scaleb -7.50 0 -> -7.50
+ddscb077 scaleb 7.500 0 -> 7.500
+ddscb078 scaleb -7.500 0 -> -7.500
+ddscb081 scaleb 7 1 -> 7E+1
+ddscb082 scaleb -7 1 -> -7E+1
+ddscb083 scaleb 75 1 -> 7.5E+2
+ddscb084 scaleb -75 1 -> -7.5E+2
+ddscb085 scaleb 7.50 1 -> 75.0
+ddscb086 scaleb -7.50 1 -> -75.0
+ddscb087 scaleb 7.500 1 -> 75.00
+ddscb088 scaleb -7.500 1 -> -75.00
+ddscb091 scaleb 7 2 -> 7E+2
+ddscb092 scaleb -7 2 -> -7E+2
+ddscb093 scaleb 75 2 -> 7.5E+3
+ddscb094 scaleb -75 2 -> -7.5E+3
+ddscb095 scaleb 7.50 2 -> 750
+ddscb096 scaleb -7.50 2 -> -750
+ddscb097 scaleb 7.500 2 -> 750.0
+ddscb098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+ddscb111 scaleb 0 1 -> 0E+1
+ddscb112 scaleb -0 2 -> -0E+2
+ddscb113 scaleb 0E+4 3 -> 0E+7
+ddscb114 scaleb -0E+4 4 -> -0E+8
+ddscb115 scaleb 0.0000 5 -> 0E+1
+ddscb116 scaleb -0.0000 6 -> -0E+2
+ddscb117 scaleb 0E-141 7 -> 0E-134
+ddscb118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+ddscb132 scaleb 9.999999999999999E+384 +384 -> Infinity Overflow Inexact Rounded
+ddscb133 scaleb 9.999999999999999E+384 +10 -> Infinity Overflow Inexact Rounded
+ddscb134 scaleb 9.999999999999999E+384 +1 -> Infinity Overflow Inexact Rounded
+ddscb135 scaleb 9.999999999999999E+384 0 -> 9.999999999999999E+384
+ddscb136 scaleb 9.999999999999999E+384 -1 -> 9.999999999999999E+383
+ddscb137 scaleb 1E-383 +1 -> 1E-382
+ddscb138 scaleb 1E-383 -0 -> 1E-383
+ddscb139 scaleb 1E-383 -1 -> 1E-384 Subnormal
+ddscb140 scaleb 1.000000000000000E-383 +1 -> 1.000000000000000E-382
+ddscb141 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
+ddscb142 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
+ddscb143 scaleb 1E-398 +1 -> 1E-397 Subnormal
+ddscb144 scaleb 1E-398 -0 -> 1E-398 Subnormal
+ddscb145 scaleb 1E-398 -1 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
+ddscb150 scaleb -1E-398 +1 -> -1E-397 Subnormal
+ddscb151 scaleb -1E-398 -0 -> -1E-398 Subnormal
+ddscb152 scaleb -1E-398 -1 -> -0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb153 scaleb -1.000000000000000E-383 +1 -> -1.000000000000000E-382
+ddscb154 scaleb -1.000000000000000E-383 +0 -> -1.000000000000000E-383
+ddscb155 scaleb -1.000000000000000E-383 -1 -> -1.00000000000000E-384 Subnormal Rounded
+ddscb156 scaleb -1E-383 +1 -> -1E-382
+ddscb157 scaleb -1E-383 -0 -> -1E-383
+ddscb158 scaleb -1E-383 -1 -> -1E-384 Subnormal
+ddscb159 scaleb -9.999999999999999E+384 +1 -> -Infinity Overflow Inexact Rounded
+ddscb160 scaleb -9.999999999999999E+384 +0 -> -9.999999999999999E+384
+ddscb161 scaleb -9.999999999999999E+384 -1 -> -9.999999999999999E+383
+ddscb162 scaleb -9E+384 +1 -> -Infinity Overflow Inexact Rounded
+ddscb163 scaleb -1E+384 +1 -> -Infinity Overflow Inexact Rounded
+
+-- some Origami
+-- (these check that overflow is being done correctly)
+ddscb171 scaleb 1000E+365 +1 -> 1.000E+369
+ddscb172 scaleb 1000E+366 +1 -> 1.000E+370
+ddscb173 scaleb 1000E+367 +1 -> 1.000E+371
+ddscb174 scaleb 1000E+368 +1 -> 1.000E+372
+ddscb175 scaleb 1000E+369 +1 -> 1.0000E+373 Clamped
+ddscb176 scaleb 1000E+370 +1 -> 1.00000E+374 Clamped
+ddscb177 scaleb 1000E+371 +1 -> 1.000000E+375 Clamped
+ddscb178 scaleb 1000E+372 +1 -> 1.0000000E+376 Clamped
+ddscb179 scaleb 1000E+373 +1 -> 1.00000000E+377 Clamped
+ddscb180 scaleb 1000E+374 +1 -> 1.000000000E+378 Clamped
+ddscb181 scaleb 1000E+375 +1 -> 1.0000000000E+379 Clamped
+ddscb182 scaleb 1000E+376 +1 -> 1.00000000000E+380 Clamped
+ddscb183 scaleb 1000E+377 +1 -> 1.000000000000E+381 Clamped
+ddscb184 scaleb 1000E+378 +1 -> 1.0000000000000E+382 Clamped
+ddscb185 scaleb 1000E+379 +1 -> 1.00000000000000E+383 Clamped
+ddscb186 scaleb 1000E+380 +1 -> 1.000000000000000E+384 Clamped
+ddscb187 scaleb 1000E+381 +1 -> Infinity Overflow Inexact Rounded
+
+-- and a few more subnormal truncations
+-- (these check that underflow is being done correctly)
+ddscb201 scaleb 1.000000000000000E-383 0 -> 1.000000000000000E-383
+ddscb202 scaleb 1.000000000000000E-383 -1 -> 1.00000000000000E-384 Subnormal Rounded
+ddscb203 scaleb 1.000000000000000E-383 -2 -> 1.0000000000000E-385 Subnormal Rounded
+ddscb204 scaleb 1.000000000000000E-383 -3 -> 1.000000000000E-386 Subnormal Rounded
+ddscb205 scaleb 1.000000000000000E-383 -4 -> 1.00000000000E-387 Subnormal Rounded
+ddscb206 scaleb 1.000000000000000E-383 -5 -> 1.0000000000E-388 Subnormal Rounded
+ddscb207 scaleb 1.000000000000000E-383 -6 -> 1.000000000E-389 Subnormal Rounded
+ddscb208 scaleb 1.000000000000000E-383 -7 -> 1.00000000E-390 Subnormal Rounded
+ddscb209 scaleb 1.000000000000000E-383 -8 -> 1.0000000E-391 Subnormal Rounded
+ddscb210 scaleb 1.000000000000000E-383 -9 -> 1.000000E-392 Subnormal Rounded
+ddscb211 scaleb 1.000000000000000E-383 -10 -> 1.00000E-393 Subnormal Rounded
+ddscb212 scaleb 1.000000000000000E-383 -11 -> 1.0000E-394 Subnormal Rounded
+ddscb213 scaleb 1.000000000000000E-383 -12 -> 1.000E-395 Subnormal Rounded
+ddscb214 scaleb 1.000000000000000E-383 -13 -> 1.00E-396 Subnormal Rounded
+ddscb215 scaleb 1.000000000000000E-383 -14 -> 1.0E-397 Subnormal Rounded
+ddscb216 scaleb 1.000000000000000E-383 -15 -> 1E-398 Subnormal Rounded
+ddscb217 scaleb 1.000000000000000E-383 -16 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+ddscb218 scaleb 1.000000000000000E-383 -17 -> 0E-398 Underflow Subnormal Inexact Rounded Clamped
+
diff --git a/Lib/test/decimaltestdata/ddShift.decTest b/Lib/test/decimaltestdata/ddShift.decTest
index f62a236b2ed..ec472403e6b 100644
--- a/Lib/test/decimaltestdata/ddShift.decTest
+++ b/Lib/test/decimaltestdata/ddShift.decTest
@@ -1,262 +1,262 @@
-------------------------------------------------------------------------
--- ddShift.decTest -- shift decDouble coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check
-ddshi001 shift 0 0 -> 0
-ddshi002 shift 0 2 -> 0
-ddshi003 shift 1 2 -> 100
-ddshi004 shift 1 15 -> 1000000000000000
-ddshi005 shift 1 16 -> 0
-ddshi006 shift 1 -1 -> 0
-ddshi007 shift 0 -2 -> 0
-ddshi008 shift 1234567890123456 -1 -> 123456789012345
-ddshi009 shift 1234567890123456 -15 -> 1
-ddshi010 shift 1234567890123456 -16 -> 0
-ddshi011 shift 9934567890123456 -15 -> 9
-ddshi012 shift 9934567890123456 -16 -> 0
-
--- rhs must be an integer
-ddshi015 shift 1 1.5 -> NaN Invalid_operation
-ddshi016 shift 1 1.0 -> NaN Invalid_operation
-ddshi017 shift 1 0.1 -> NaN Invalid_operation
-ddshi018 shift 1 0.0 -> NaN Invalid_operation
-ddshi019 shift 1 1E+1 -> NaN Invalid_operation
-ddshi020 shift 1 1E+99 -> NaN Invalid_operation
-ddshi021 shift 1 Inf -> NaN Invalid_operation
-ddshi022 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-ddshi025 shift 1 -1000 -> NaN Invalid_operation
-ddshi026 shift 1 -17 -> NaN Invalid_operation
-ddshi027 shift 1 17 -> NaN Invalid_operation
-ddshi028 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-ddshi030 shift 1234567890123456 -16 -> 0
-ddshi031 shift 1234567890123456 -15 -> 1
-ddshi032 shift 1234567890123456 -14 -> 12
-ddshi033 shift 1234567890123456 -13 -> 123
-ddshi034 shift 1234567890123456 -12 -> 1234
-ddshi035 shift 1234567890123456 -11 -> 12345
-ddshi036 shift 1234567890123456 -10 -> 123456
-ddshi037 shift 1234567890123456 -9 -> 1234567
-ddshi038 shift 1234567890123456 -8 -> 12345678
-ddshi039 shift 1234567890123456 -7 -> 123456789
-ddshi040 shift 1234567890123456 -6 -> 1234567890
-ddshi041 shift 1234567890123456 -5 -> 12345678901
-ddshi042 shift 1234567890123456 -4 -> 123456789012
-ddshi043 shift 1234567890123456 -3 -> 1234567890123
-ddshi044 shift 1234567890123456 -2 -> 12345678901234
-ddshi045 shift 1234567890123456 -1 -> 123456789012345
-ddshi046 shift 1234567890123456 -0 -> 1234567890123456
-
-ddshi047 shift 1234567890123456 +0 -> 1234567890123456
-ddshi048 shift 1234567890123456 +1 -> 2345678901234560
-ddshi049 shift 1234567890123456 +2 -> 3456789012345600
-ddshi050 shift 1234567890123456 +3 -> 4567890123456000
-ddshi051 shift 1234567890123456 +4 -> 5678901234560000
-ddshi052 shift 1234567890123456 +5 -> 6789012345600000
-ddshi053 shift 1234567890123456 +6 -> 7890123456000000
-ddshi054 shift 1234567890123456 +7 -> 8901234560000000
-ddshi055 shift 1234567890123456 +8 -> 9012345600000000
-ddshi056 shift 1234567890123456 +9 -> 123456000000000
-ddshi057 shift 1234567890123456 +10 -> 1234560000000000
-ddshi058 shift 1234567890123456 +11 -> 2345600000000000
-ddshi059 shift 1234567890123456 +12 -> 3456000000000000
-ddshi060 shift 1234567890123456 +13 -> 4560000000000000
-ddshi061 shift 1234567890123456 +14 -> 5600000000000000
-ddshi062 shift 1234567890123456 +15 -> 6000000000000000
-ddshi063 shift 1234567890123456 +16 -> 0
-
--- zeros
-ddshi070 shift 0E-10 +9 -> 0E-10
-ddshi071 shift 0E-10 -9 -> 0E-10
-ddshi072 shift 0.000 +9 -> 0.000
-ddshi073 shift 0.000 -9 -> 0.000
-ddshi074 shift 0E+10 +9 -> 0E+10
-ddshi075 shift 0E+10 -9 -> 0E+10
-ddshi076 shift -0E-10 +9 -> -0E-10
-ddshi077 shift -0E-10 -9 -> -0E-10
-ddshi078 shift -0.000 +9 -> -0.000
-ddshi079 shift -0.000 -9 -> -0.000
-ddshi080 shift -0E+10 +9 -> -0E+10
-ddshi081 shift -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-ddshi141 shift 9.999999999999999E+384 -1 -> 9.99999999999999E+383
-ddshi142 shift 9.999999999999999E+384 -15 -> 9E+369
-ddshi143 shift 9.999999999999999E+384 1 -> 9.999999999999990E+384
-ddshi144 shift 9.999999999999999E+384 15 -> 9.000000000000000E+384
-ddshi145 shift 1E-383 -1 -> 0E-383
-ddshi146 shift 1E-383 -15 -> 0E-383
-ddshi147 shift 1E-383 1 -> 1.0E-382
-ddshi148 shift 1E-383 15 -> 1.000000000000000E-368
-ddshi151 shift 1.000000000000000E-383 -1 -> 1.00000000000000E-384
-ddshi152 shift 1.000000000000000E-383 -15 -> 1E-398
-ddshi153 shift 1.000000000000000E-383 1 -> 0E-398
-ddshi154 shift 1.000000000000000E-383 15 -> 0E-398
-ddshi155 shift 9.000000000000000E-383 -1 -> 9.00000000000000E-384
-ddshi156 shift 9.000000000000000E-383 -15 -> 9E-398
-ddshi157 shift 9.000000000000000E-383 1 -> 0E-398
-ddshi158 shift 9.000000000000000E-383 15 -> 0E-398
-ddshi160 shift 1E-398 -1 -> 0E-398
-ddshi161 shift 1E-398 -15 -> 0E-398
-ddshi162 shift 1E-398 1 -> 1.0E-397
-ddshi163 shift 1E-398 15 -> 1.000000000000000E-383
--- negatives
-ddshi171 shift -9.999999999999999E+384 -1 -> -9.99999999999999E+383
-ddshi172 shift -9.999999999999999E+384 -15 -> -9E+369
-ddshi173 shift -9.999999999999999E+384 1 -> -9.999999999999990E+384
-ddshi174 shift -9.999999999999999E+384 15 -> -9.000000000000000E+384
-ddshi175 shift -1E-383 -1 -> -0E-383
-ddshi176 shift -1E-383 -15 -> -0E-383
-ddshi177 shift -1E-383 1 -> -1.0E-382
-ddshi178 shift -1E-383 15 -> -1.000000000000000E-368
-ddshi181 shift -1.000000000000000E-383 -1 -> -1.00000000000000E-384
-ddshi182 shift -1.000000000000000E-383 -15 -> -1E-398
-ddshi183 shift -1.000000000000000E-383 1 -> -0E-398
-ddshi184 shift -1.000000000000000E-383 15 -> -0E-398
-ddshi185 shift -9.000000000000000E-383 -1 -> -9.00000000000000E-384
-ddshi186 shift -9.000000000000000E-383 -15 -> -9E-398
-ddshi187 shift -9.000000000000000E-383 1 -> -0E-398
-ddshi188 shift -9.000000000000000E-383 15 -> -0E-398
-ddshi190 shift -1E-398 -1 -> -0E-398
-ddshi191 shift -1E-398 -15 -> -0E-398
-ddshi192 shift -1E-398 1 -> -1.0E-397
-ddshi193 shift -1E-398 15 -> -1.000000000000000E-383
-
--- more negatives (of sanities)
-ddshi201 shift -0 0 -> -0
-ddshi202 shift -0 2 -> -0
-ddshi203 shift -1 2 -> -100
-ddshi204 shift -1 15 -> -1000000000000000
-ddshi205 shift -1 16 -> -0
-ddshi206 shift -1 -1 -> -0
-ddshi207 shift -0 -2 -> -0
-ddshi208 shift -1234567890123456 -1 -> -123456789012345
-ddshi209 shift -1234567890123456 -15 -> -1
-ddshi210 shift -1234567890123456 -16 -> -0
-ddshi211 shift -9934567890123456 -15 -> -9
-ddshi212 shift -9934567890123456 -16 -> -0
-
-
--- Specials; NaNs are handled as usual
-ddshi781 shift -Inf -8 -> -Infinity
-ddshi782 shift -Inf -1 -> -Infinity
-ddshi783 shift -Inf -0 -> -Infinity
-ddshi784 shift -Inf 0 -> -Infinity
-ddshi785 shift -Inf 1 -> -Infinity
-ddshi786 shift -Inf 8 -> -Infinity
-ddshi787 shift -1000 -Inf -> NaN Invalid_operation
-ddshi788 shift -Inf -Inf -> NaN Invalid_operation
-ddshi789 shift -1 -Inf -> NaN Invalid_operation
-ddshi790 shift -0 -Inf -> NaN Invalid_operation
-ddshi791 shift 0 -Inf -> NaN Invalid_operation
-ddshi792 shift 1 -Inf -> NaN Invalid_operation
-ddshi793 shift 1000 -Inf -> NaN Invalid_operation
-ddshi794 shift Inf -Inf -> NaN Invalid_operation
-
-ddshi800 shift Inf -Inf -> NaN Invalid_operation
-ddshi801 shift Inf -8 -> Infinity
-ddshi802 shift Inf -1 -> Infinity
-ddshi803 shift Inf -0 -> Infinity
-ddshi804 shift Inf 0 -> Infinity
-ddshi805 shift Inf 1 -> Infinity
-ddshi806 shift Inf 8 -> Infinity
-ddshi807 shift Inf Inf -> NaN Invalid_operation
-ddshi808 shift -1000 Inf -> NaN Invalid_operation
-ddshi809 shift -Inf Inf -> NaN Invalid_operation
-ddshi810 shift -1 Inf -> NaN Invalid_operation
-ddshi811 shift -0 Inf -> NaN Invalid_operation
-ddshi812 shift 0 Inf -> NaN Invalid_operation
-ddshi813 shift 1 Inf -> NaN Invalid_operation
-ddshi814 shift 1000 Inf -> NaN Invalid_operation
-ddshi815 shift Inf Inf -> NaN Invalid_operation
-
-ddshi821 shift NaN -Inf -> NaN
-ddshi822 shift NaN -1000 -> NaN
-ddshi823 shift NaN -1 -> NaN
-ddshi824 shift NaN -0 -> NaN
-ddshi825 shift NaN 0 -> NaN
-ddshi826 shift NaN 1 -> NaN
-ddshi827 shift NaN 1000 -> NaN
-ddshi828 shift NaN Inf -> NaN
-ddshi829 shift NaN NaN -> NaN
-ddshi830 shift -Inf NaN -> NaN
-ddshi831 shift -1000 NaN -> NaN
-ddshi832 shift -1 NaN -> NaN
-ddshi833 shift -0 NaN -> NaN
-ddshi834 shift 0 NaN -> NaN
-ddshi835 shift 1 NaN -> NaN
-ddshi836 shift 1000 NaN -> NaN
-ddshi837 shift Inf NaN -> NaN
-
-ddshi841 shift sNaN -Inf -> NaN Invalid_operation
-ddshi842 shift sNaN -1000 -> NaN Invalid_operation
-ddshi843 shift sNaN -1 -> NaN Invalid_operation
-ddshi844 shift sNaN -0 -> NaN Invalid_operation
-ddshi845 shift sNaN 0 -> NaN Invalid_operation
-ddshi846 shift sNaN 1 -> NaN Invalid_operation
-ddshi847 shift sNaN 1000 -> NaN Invalid_operation
-ddshi848 shift sNaN NaN -> NaN Invalid_operation
-ddshi849 shift sNaN sNaN -> NaN Invalid_operation
-ddshi850 shift NaN sNaN -> NaN Invalid_operation
-ddshi851 shift -Inf sNaN -> NaN Invalid_operation
-ddshi852 shift -1000 sNaN -> NaN Invalid_operation
-ddshi853 shift -1 sNaN -> NaN Invalid_operation
-ddshi854 shift -0 sNaN -> NaN Invalid_operation
-ddshi855 shift 0 sNaN -> NaN Invalid_operation
-ddshi856 shift 1 sNaN -> NaN Invalid_operation
-ddshi857 shift 1000 sNaN -> NaN Invalid_operation
-ddshi858 shift Inf sNaN -> NaN Invalid_operation
-ddshi859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddshi861 shift NaN1 -Inf -> NaN1
-ddshi862 shift +NaN2 -1000 -> NaN2
-ddshi863 shift NaN3 1000 -> NaN3
-ddshi864 shift NaN4 Inf -> NaN4
-ddshi865 shift NaN5 +NaN6 -> NaN5
-ddshi866 shift -Inf NaN7 -> NaN7
-ddshi867 shift -1000 NaN8 -> NaN8
-ddshi868 shift 1000 NaN9 -> NaN9
-ddshi869 shift Inf +NaN10 -> NaN10
-ddshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-ddshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-ddshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
-ddshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-ddshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-ddshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-ddshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-ddshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-ddshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-ddshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
-ddshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-ddshi882 shift -NaN26 NaN28 -> -NaN26
-ddshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-ddshi884 shift 1000 -NaN30 -> -NaN30
-ddshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- ddShift.decTest -- shift decDouble coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check
+ddshi001 shift 0 0 -> 0
+ddshi002 shift 0 2 -> 0
+ddshi003 shift 1 2 -> 100
+ddshi004 shift 1 15 -> 1000000000000000
+ddshi005 shift 1 16 -> 0
+ddshi006 shift 1 -1 -> 0
+ddshi007 shift 0 -2 -> 0
+ddshi008 shift 1234567890123456 -1 -> 123456789012345
+ddshi009 shift 1234567890123456 -15 -> 1
+ddshi010 shift 1234567890123456 -16 -> 0
+ddshi011 shift 9934567890123456 -15 -> 9
+ddshi012 shift 9934567890123456 -16 -> 0
+
+-- rhs must be an integer
+ddshi015 shift 1 1.5 -> NaN Invalid_operation
+ddshi016 shift 1 1.0 -> NaN Invalid_operation
+ddshi017 shift 1 0.1 -> NaN Invalid_operation
+ddshi018 shift 1 0.0 -> NaN Invalid_operation
+ddshi019 shift 1 1E+1 -> NaN Invalid_operation
+ddshi020 shift 1 1E+99 -> NaN Invalid_operation
+ddshi021 shift 1 Inf -> NaN Invalid_operation
+ddshi022 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+ddshi025 shift 1 -1000 -> NaN Invalid_operation
+ddshi026 shift 1 -17 -> NaN Invalid_operation
+ddshi027 shift 1 17 -> NaN Invalid_operation
+ddshi028 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+ddshi030 shift 1234567890123456 -16 -> 0
+ddshi031 shift 1234567890123456 -15 -> 1
+ddshi032 shift 1234567890123456 -14 -> 12
+ddshi033 shift 1234567890123456 -13 -> 123
+ddshi034 shift 1234567890123456 -12 -> 1234
+ddshi035 shift 1234567890123456 -11 -> 12345
+ddshi036 shift 1234567890123456 -10 -> 123456
+ddshi037 shift 1234567890123456 -9 -> 1234567
+ddshi038 shift 1234567890123456 -8 -> 12345678
+ddshi039 shift 1234567890123456 -7 -> 123456789
+ddshi040 shift 1234567890123456 -6 -> 1234567890
+ddshi041 shift 1234567890123456 -5 -> 12345678901
+ddshi042 shift 1234567890123456 -4 -> 123456789012
+ddshi043 shift 1234567890123456 -3 -> 1234567890123
+ddshi044 shift 1234567890123456 -2 -> 12345678901234
+ddshi045 shift 1234567890123456 -1 -> 123456789012345
+ddshi046 shift 1234567890123456 -0 -> 1234567890123456
+
+ddshi047 shift 1234567890123456 +0 -> 1234567890123456
+ddshi048 shift 1234567890123456 +1 -> 2345678901234560
+ddshi049 shift 1234567890123456 +2 -> 3456789012345600
+ddshi050 shift 1234567890123456 +3 -> 4567890123456000
+ddshi051 shift 1234567890123456 +4 -> 5678901234560000
+ddshi052 shift 1234567890123456 +5 -> 6789012345600000
+ddshi053 shift 1234567890123456 +6 -> 7890123456000000
+ddshi054 shift 1234567890123456 +7 -> 8901234560000000
+ddshi055 shift 1234567890123456 +8 -> 9012345600000000
+ddshi056 shift 1234567890123456 +9 -> 123456000000000
+ddshi057 shift 1234567890123456 +10 -> 1234560000000000
+ddshi058 shift 1234567890123456 +11 -> 2345600000000000
+ddshi059 shift 1234567890123456 +12 -> 3456000000000000
+ddshi060 shift 1234567890123456 +13 -> 4560000000000000
+ddshi061 shift 1234567890123456 +14 -> 5600000000000000
+ddshi062 shift 1234567890123456 +15 -> 6000000000000000
+ddshi063 shift 1234567890123456 +16 -> 0
+
+-- zeros
+ddshi070 shift 0E-10 +9 -> 0E-10
+ddshi071 shift 0E-10 -9 -> 0E-10
+ddshi072 shift 0.000 +9 -> 0.000
+ddshi073 shift 0.000 -9 -> 0.000
+ddshi074 shift 0E+10 +9 -> 0E+10
+ddshi075 shift 0E+10 -9 -> 0E+10
+ddshi076 shift -0E-10 +9 -> -0E-10
+ddshi077 shift -0E-10 -9 -> -0E-10
+ddshi078 shift -0.000 +9 -> -0.000
+ddshi079 shift -0.000 -9 -> -0.000
+ddshi080 shift -0E+10 +9 -> -0E+10
+ddshi081 shift -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+ddshi141 shift 9.999999999999999E+384 -1 -> 9.99999999999999E+383
+ddshi142 shift 9.999999999999999E+384 -15 -> 9E+369
+ddshi143 shift 9.999999999999999E+384 1 -> 9.999999999999990E+384
+ddshi144 shift 9.999999999999999E+384 15 -> 9.000000000000000E+384
+ddshi145 shift 1E-383 -1 -> 0E-383
+ddshi146 shift 1E-383 -15 -> 0E-383
+ddshi147 shift 1E-383 1 -> 1.0E-382
+ddshi148 shift 1E-383 15 -> 1.000000000000000E-368
+ddshi151 shift 1.000000000000000E-383 -1 -> 1.00000000000000E-384
+ddshi152 shift 1.000000000000000E-383 -15 -> 1E-398
+ddshi153 shift 1.000000000000000E-383 1 -> 0E-398
+ddshi154 shift 1.000000000000000E-383 15 -> 0E-398
+ddshi155 shift 9.000000000000000E-383 -1 -> 9.00000000000000E-384
+ddshi156 shift 9.000000000000000E-383 -15 -> 9E-398
+ddshi157 shift 9.000000000000000E-383 1 -> 0E-398
+ddshi158 shift 9.000000000000000E-383 15 -> 0E-398
+ddshi160 shift 1E-398 -1 -> 0E-398
+ddshi161 shift 1E-398 -15 -> 0E-398
+ddshi162 shift 1E-398 1 -> 1.0E-397
+ddshi163 shift 1E-398 15 -> 1.000000000000000E-383
+-- negatives
+ddshi171 shift -9.999999999999999E+384 -1 -> -9.99999999999999E+383
+ddshi172 shift -9.999999999999999E+384 -15 -> -9E+369
+ddshi173 shift -9.999999999999999E+384 1 -> -9.999999999999990E+384
+ddshi174 shift -9.999999999999999E+384 15 -> -9.000000000000000E+384
+ddshi175 shift -1E-383 -1 -> -0E-383
+ddshi176 shift -1E-383 -15 -> -0E-383
+ddshi177 shift -1E-383 1 -> -1.0E-382
+ddshi178 shift -1E-383 15 -> -1.000000000000000E-368
+ddshi181 shift -1.000000000000000E-383 -1 -> -1.00000000000000E-384
+ddshi182 shift -1.000000000000000E-383 -15 -> -1E-398
+ddshi183 shift -1.000000000000000E-383 1 -> -0E-398
+ddshi184 shift -1.000000000000000E-383 15 -> -0E-398
+ddshi185 shift -9.000000000000000E-383 -1 -> -9.00000000000000E-384
+ddshi186 shift -9.000000000000000E-383 -15 -> -9E-398
+ddshi187 shift -9.000000000000000E-383 1 -> -0E-398
+ddshi188 shift -9.000000000000000E-383 15 -> -0E-398
+ddshi190 shift -1E-398 -1 -> -0E-398
+ddshi191 shift -1E-398 -15 -> -0E-398
+ddshi192 shift -1E-398 1 -> -1.0E-397
+ddshi193 shift -1E-398 15 -> -1.000000000000000E-383
+
+-- more negatives (of sanities)
+ddshi201 shift -0 0 -> -0
+ddshi202 shift -0 2 -> -0
+ddshi203 shift -1 2 -> -100
+ddshi204 shift -1 15 -> -1000000000000000
+ddshi205 shift -1 16 -> -0
+ddshi206 shift -1 -1 -> -0
+ddshi207 shift -0 -2 -> -0
+ddshi208 shift -1234567890123456 -1 -> -123456789012345
+ddshi209 shift -1234567890123456 -15 -> -1
+ddshi210 shift -1234567890123456 -16 -> -0
+ddshi211 shift -9934567890123456 -15 -> -9
+ddshi212 shift -9934567890123456 -16 -> -0
+
+
+-- Specials; NaNs are handled as usual
+ddshi781 shift -Inf -8 -> -Infinity
+ddshi782 shift -Inf -1 -> -Infinity
+ddshi783 shift -Inf -0 -> -Infinity
+ddshi784 shift -Inf 0 -> -Infinity
+ddshi785 shift -Inf 1 -> -Infinity
+ddshi786 shift -Inf 8 -> -Infinity
+ddshi787 shift -1000 -Inf -> NaN Invalid_operation
+ddshi788 shift -Inf -Inf -> NaN Invalid_operation
+ddshi789 shift -1 -Inf -> NaN Invalid_operation
+ddshi790 shift -0 -Inf -> NaN Invalid_operation
+ddshi791 shift 0 -Inf -> NaN Invalid_operation
+ddshi792 shift 1 -Inf -> NaN Invalid_operation
+ddshi793 shift 1000 -Inf -> NaN Invalid_operation
+ddshi794 shift Inf -Inf -> NaN Invalid_operation
+
+ddshi800 shift Inf -Inf -> NaN Invalid_operation
+ddshi801 shift Inf -8 -> Infinity
+ddshi802 shift Inf -1 -> Infinity
+ddshi803 shift Inf -0 -> Infinity
+ddshi804 shift Inf 0 -> Infinity
+ddshi805 shift Inf 1 -> Infinity
+ddshi806 shift Inf 8 -> Infinity
+ddshi807 shift Inf Inf -> NaN Invalid_operation
+ddshi808 shift -1000 Inf -> NaN Invalid_operation
+ddshi809 shift -Inf Inf -> NaN Invalid_operation
+ddshi810 shift -1 Inf -> NaN Invalid_operation
+ddshi811 shift -0 Inf -> NaN Invalid_operation
+ddshi812 shift 0 Inf -> NaN Invalid_operation
+ddshi813 shift 1 Inf -> NaN Invalid_operation
+ddshi814 shift 1000 Inf -> NaN Invalid_operation
+ddshi815 shift Inf Inf -> NaN Invalid_operation
+
+ddshi821 shift NaN -Inf -> NaN
+ddshi822 shift NaN -1000 -> NaN
+ddshi823 shift NaN -1 -> NaN
+ddshi824 shift NaN -0 -> NaN
+ddshi825 shift NaN 0 -> NaN
+ddshi826 shift NaN 1 -> NaN
+ddshi827 shift NaN 1000 -> NaN
+ddshi828 shift NaN Inf -> NaN
+ddshi829 shift NaN NaN -> NaN
+ddshi830 shift -Inf NaN -> NaN
+ddshi831 shift -1000 NaN -> NaN
+ddshi832 shift -1 NaN -> NaN
+ddshi833 shift -0 NaN -> NaN
+ddshi834 shift 0 NaN -> NaN
+ddshi835 shift 1 NaN -> NaN
+ddshi836 shift 1000 NaN -> NaN
+ddshi837 shift Inf NaN -> NaN
+
+ddshi841 shift sNaN -Inf -> NaN Invalid_operation
+ddshi842 shift sNaN -1000 -> NaN Invalid_operation
+ddshi843 shift sNaN -1 -> NaN Invalid_operation
+ddshi844 shift sNaN -0 -> NaN Invalid_operation
+ddshi845 shift sNaN 0 -> NaN Invalid_operation
+ddshi846 shift sNaN 1 -> NaN Invalid_operation
+ddshi847 shift sNaN 1000 -> NaN Invalid_operation
+ddshi848 shift sNaN NaN -> NaN Invalid_operation
+ddshi849 shift sNaN sNaN -> NaN Invalid_operation
+ddshi850 shift NaN sNaN -> NaN Invalid_operation
+ddshi851 shift -Inf sNaN -> NaN Invalid_operation
+ddshi852 shift -1000 sNaN -> NaN Invalid_operation
+ddshi853 shift -1 sNaN -> NaN Invalid_operation
+ddshi854 shift -0 sNaN -> NaN Invalid_operation
+ddshi855 shift 0 sNaN -> NaN Invalid_operation
+ddshi856 shift 1 sNaN -> NaN Invalid_operation
+ddshi857 shift 1000 sNaN -> NaN Invalid_operation
+ddshi858 shift Inf sNaN -> NaN Invalid_operation
+ddshi859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddshi861 shift NaN1 -Inf -> NaN1
+ddshi862 shift +NaN2 -1000 -> NaN2
+ddshi863 shift NaN3 1000 -> NaN3
+ddshi864 shift NaN4 Inf -> NaN4
+ddshi865 shift NaN5 +NaN6 -> NaN5
+ddshi866 shift -Inf NaN7 -> NaN7
+ddshi867 shift -1000 NaN8 -> NaN8
+ddshi868 shift 1000 NaN9 -> NaN9
+ddshi869 shift Inf +NaN10 -> NaN10
+ddshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+ddshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+ddshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
+ddshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+ddshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+ddshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+ddshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+ddshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+ddshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+ddshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
+ddshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+ddshi882 shift -NaN26 NaN28 -> -NaN26
+ddshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+ddshi884 shift 1000 -NaN30 -> -NaN30
+ddshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddSubtract.decTest b/Lib/test/decimaltestdata/ddSubtract.decTest
index 5ebc4878f01..15d47779eb6 100644
--- a/Lib/test/decimaltestdata/ddSubtract.decTest
+++ b/Lib/test/decimaltestdata/ddSubtract.decTest
@@ -1,629 +1,629 @@
-------------------------------------------------------------------------
--- ddSubtract.decTest -- decDouble subtraction --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decDoubles only; all arguments are
--- representable in a decDouble
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- [first group are 'quick confidence check']
-ddsub001 subtract 0 0 -> '0'
-ddsub002 subtract 1 1 -> '0'
-ddsub003 subtract 1 2 -> '-1'
-ddsub004 subtract 2 1 -> '1'
-ddsub005 subtract 2 2 -> '0'
-ddsub006 subtract 3 2 -> '1'
-ddsub007 subtract 2 3 -> '-1'
-
-ddsub011 subtract -0 0 -> '-0'
-ddsub012 subtract -1 1 -> '-2'
-ddsub013 subtract -1 2 -> '-3'
-ddsub014 subtract -2 1 -> '-3'
-ddsub015 subtract -2 2 -> '-4'
-ddsub016 subtract -3 2 -> '-5'
-ddsub017 subtract -2 3 -> '-5'
-
-ddsub021 subtract 0 -0 -> '0'
-ddsub022 subtract 1 -1 -> '2'
-ddsub023 subtract 1 -2 -> '3'
-ddsub024 subtract 2 -1 -> '3'
-ddsub025 subtract 2 -2 -> '4'
-ddsub026 subtract 3 -2 -> '5'
-ddsub027 subtract 2 -3 -> '5'
-
-ddsub030 subtract 11 1 -> 10
-ddsub031 subtract 10 1 -> 9
-ddsub032 subtract 9 1 -> 8
-ddsub033 subtract 1 1 -> 0
-ddsub034 subtract 0 1 -> -1
-ddsub035 subtract -1 1 -> -2
-ddsub036 subtract -9 1 -> -10
-ddsub037 subtract -10 1 -> -11
-ddsub038 subtract -11 1 -> -12
-
-ddsub040 subtract '5.75' '3.3' -> '2.45'
-ddsub041 subtract '5' '-3' -> '8'
-ddsub042 subtract '-5' '-3' -> '-2'
-ddsub043 subtract '-7' '2.5' -> '-9.5'
-ddsub044 subtract '0.7' '0.3' -> '0.4'
-ddsub045 subtract '1.3' '0.3' -> '1.0'
-ddsub046 subtract '1.25' '1.25' -> '0.00'
-
-ddsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
-ddsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
-
-ddsub060 subtract '70' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
-ddsub061 subtract '700' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
-ddsub062 subtract '7000' '10000e+16' -> '-9.999999999999999E+19' Inexact Rounded
-ddsub063 subtract '70000' '10000e+16' -> '-9.999999999999993E+19' Rounded
-ddsub064 subtract '700000' '10000e+16' -> '-9.999999999999930E+19' Rounded
- -- symmetry:
-ddsub065 subtract '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-ddsub066 subtract '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-ddsub067 subtract '10000e+16' '7000' -> '9.999999999999999E+19' Inexact Rounded
-ddsub068 subtract '10000e+16' '70000' -> '9.999999999999993E+19' Rounded
-ddsub069 subtract '10000e+16' '700000' -> '9.999999999999930E+19' Rounded
-
- -- some of the next group are really constructor tests
-ddsub090 subtract '00.0' '0.0' -> '0.0'
-ddsub091 subtract '00.0' '0.00' -> '0.00'
-ddsub092 subtract '0.00' '00.0' -> '0.00'
-ddsub093 subtract '00.0' '0.00' -> '0.00'
-ddsub094 subtract '0.00' '00.0' -> '0.00'
-ddsub095 subtract '3' '.3' -> '2.7'
-ddsub096 subtract '3.' '.3' -> '2.7'
-ddsub097 subtract '3.0' '.3' -> '2.7'
-ddsub098 subtract '3.00' '.3' -> '2.70'
-ddsub099 subtract '3' '3' -> '0'
-ddsub100 subtract '3' '+3' -> '0'
-ddsub101 subtract '3' '-3' -> '6'
-ddsub102 subtract '3' '0.3' -> '2.7'
-ddsub103 subtract '3.' '0.3' -> '2.7'
-ddsub104 subtract '3.0' '0.3' -> '2.7'
-ddsub105 subtract '3.00' '0.3' -> '2.70'
-ddsub106 subtract '3' '3.0' -> '0.0'
-ddsub107 subtract '3' '+3.0' -> '0.0'
-ddsub108 subtract '3' '-3.0' -> '6.0'
-
--- the above all from add; massaged and extended. Now some new ones...
--- [particularly important for comparisons]
--- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
--- with input rounding.
-ddsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
-ddsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
-ddsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
-ddsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
-ddsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
-ddsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
-ddsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
-ddsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
-ddsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
-ddsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
-ddsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
-ddsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
-ddsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
-ddsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
-ddsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
-ddsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
-ddsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
-ddsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
-ddsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
-ddsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
-ddsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
-ddsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
-ddsub142 subtract '1' '0.999999999' -> '1E-9'
-ddsub143 subtract '0.999999999' '1' -> '-1E-9'
-ddsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
-ddsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
-ddsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
-
--- additional scaled arithmetic tests [0.97 problem]
-ddsub160 subtract '0' '.1' -> '-0.1'
-ddsub161 subtract '00' '.97983' -> '-0.97983'
-ddsub162 subtract '0' '.9' -> '-0.9'
-ddsub163 subtract '0' '0.102' -> '-0.102'
-ddsub164 subtract '0' '.4' -> '-0.4'
-ddsub165 subtract '0' '.307' -> '-0.307'
-ddsub166 subtract '0' '.43822' -> '-0.43822'
-ddsub167 subtract '0' '.911' -> '-0.911'
-ddsub168 subtract '.0' '.02' -> '-0.02'
-ddsub169 subtract '00' '.392' -> '-0.392'
-ddsub170 subtract '0' '.26' -> '-0.26'
-ddsub171 subtract '0' '0.51' -> '-0.51'
-ddsub172 subtract '0' '.2234' -> '-0.2234'
-ddsub173 subtract '0' '.2' -> '-0.2'
-ddsub174 subtract '.0' '.0008' -> '-0.0008'
--- 0. on left
-ddsub180 subtract '0.0' '-.1' -> '0.1'
-ddsub181 subtract '0.00' '-.97983' -> '0.97983'
-ddsub182 subtract '0.0' '-.9' -> '0.9'
-ddsub183 subtract '0.0' '-0.102' -> '0.102'
-ddsub184 subtract '0.0' '-.4' -> '0.4'
-ddsub185 subtract '0.0' '-.307' -> '0.307'
-ddsub186 subtract '0.0' '-.43822' -> '0.43822'
-ddsub187 subtract '0.0' '-.911' -> '0.911'
-ddsub188 subtract '0.0' '-.02' -> '0.02'
-ddsub189 subtract '0.00' '-.392' -> '0.392'
-ddsub190 subtract '0.0' '-.26' -> '0.26'
-ddsub191 subtract '0.0' '-0.51' -> '0.51'
-ddsub192 subtract '0.0' '-.2234' -> '0.2234'
-ddsub193 subtract '0.0' '-.2' -> '0.2'
-ddsub194 subtract '0.0' '-.0008' -> '0.0008'
--- negatives of same
-ddsub200 subtract '0' '-.1' -> '0.1'
-ddsub201 subtract '00' '-.97983' -> '0.97983'
-ddsub202 subtract '0' '-.9' -> '0.9'
-ddsub203 subtract '0' '-0.102' -> '0.102'
-ddsub204 subtract '0' '-.4' -> '0.4'
-ddsub205 subtract '0' '-.307' -> '0.307'
-ddsub206 subtract '0' '-.43822' -> '0.43822'
-ddsub207 subtract '0' '-.911' -> '0.911'
-ddsub208 subtract '.0' '-.02' -> '0.02'
-ddsub209 subtract '00' '-.392' -> '0.392'
-ddsub210 subtract '0' '-.26' -> '0.26'
-ddsub211 subtract '0' '-0.51' -> '0.51'
-ddsub212 subtract '0' '-.2234' -> '0.2234'
-ddsub213 subtract '0' '-.2' -> '0.2'
-ddsub214 subtract '.0' '-.0008' -> '0.0008'
-
--- more fixed, LHS swaps [really the same as testcases under add]
-ddsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
-ddsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
-ddsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
-ddsub223 subtract '-56267E-9' 0 -> '-0.000056267'
-ddsub224 subtract '-56267E-8' 0 -> '-0.00056267'
-ddsub225 subtract '-56267E-7' 0 -> '-0.0056267'
-ddsub226 subtract '-56267E-6' 0 -> '-0.056267'
-ddsub227 subtract '-56267E-5' 0 -> '-0.56267'
-ddsub228 subtract '-56267E-2' 0 -> '-562.67'
-ddsub229 subtract '-56267E-1' 0 -> '-5626.7'
-ddsub230 subtract '-56267E-0' 0 -> '-56267'
--- symmetry ...
-ddsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
-ddsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
-ddsub242 subtract 0 '-56267E-10' -> '0.0000056267'
-ddsub243 subtract 0 '-56267E-9' -> '0.000056267'
-ddsub244 subtract 0 '-56267E-8' -> '0.00056267'
-ddsub245 subtract 0 '-56267E-7' -> '0.0056267'
-ddsub246 subtract 0 '-56267E-6' -> '0.056267'
-ddsub247 subtract 0 '-56267E-5' -> '0.56267'
-ddsub248 subtract 0 '-56267E-2' -> '562.67'
-ddsub249 subtract 0 '-56267E-1' -> '5626.7'
-ddsub250 subtract 0 '-56267E-0' -> '56267'
-
--- now some more from the 'new' add
-ddsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
-ddsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
-
--- some carrying effects
-ddsub321 subtract '0.9998' '0.0000' -> '0.9998'
-ddsub322 subtract '0.9998' '0.0001' -> '0.9997'
-ddsub323 subtract '0.9998' '0.0002' -> '0.9996'
-ddsub324 subtract '0.9998' '0.0003' -> '0.9995'
-ddsub325 subtract '0.9998' '-0.0000' -> '0.9998'
-ddsub326 subtract '0.9998' '-0.0001' -> '0.9999'
-ddsub327 subtract '0.9998' '-0.0002' -> '1.0000'
-ddsub328 subtract '0.9998' '-0.0003' -> '1.0001'
-
--- internal boundaries
-ddsub346 subtract '10000e+9' '7' -> '9999999999993'
-ddsub347 subtract '10000e+9' '70' -> '9999999999930'
-ddsub348 subtract '10000e+9' '700' -> '9999999999300'
-ddsub349 subtract '10000e+9' '7000' -> '9999999993000'
-ddsub350 subtract '10000e+9' '70000' -> '9999999930000'
-ddsub351 subtract '10000e+9' '700000' -> '9999999300000'
-ddsub352 subtract '7' '10000e+9' -> '-9999999999993'
-ddsub353 subtract '70' '10000e+9' -> '-9999999999930'
-ddsub354 subtract '700' '10000e+9' -> '-9999999999300'
-ddsub355 subtract '7000' '10000e+9' -> '-9999999993000'
-ddsub356 subtract '70000' '10000e+9' -> '-9999999930000'
-ddsub357 subtract '700000' '10000e+9' -> '-9999999300000'
-
--- zero preservation
-ddsub361 subtract 1 '0.0001' -> '0.9999'
-ddsub362 subtract 1 '0.00001' -> '0.99999'
-ddsub363 subtract 1 '0.000001' -> '0.999999'
-ddsub364 subtract 1 '0.0000000000000001' -> '0.9999999999999999'
-ddsub365 subtract 1 '0.00000000000000001' -> '1.000000000000000' Inexact Rounded
-ddsub366 subtract 1 '0.000000000000000001' -> '1.000000000000000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-ddsub370 subtract 1 0 -> 1
-ddsub371 subtract 1 0. -> 1
-ddsub372 subtract 1 .0 -> 1.0
-ddsub373 subtract 1 0.0 -> 1.0
-ddsub374 subtract 0 1 -> -1
-ddsub375 subtract 0. 1 -> -1
-ddsub376 subtract .0 1 -> -1.0
-ddsub377 subtract 0.0 1 -> -1.0
-
--- leading 0 digit before round
-ddsub910 subtract -103519362 -51897955.3 -> -51621406.7
-ddsub911 subtract 159579.444 89827.5229 -> 69751.9211
-
-ddsub920 subtract 333.0000000123456 33.00000001234566 -> 299.9999999999999 Inexact Rounded
-ddsub921 subtract 333.0000000123456 33.00000001234565 -> 300.0000000000000 Inexact Rounded
-ddsub922 subtract 133.0000000123456 33.00000001234565 -> 99.99999999999995
-ddsub923 subtract 133.0000000123456 33.00000001234564 -> 99.99999999999996
-ddsub924 subtract 133.0000000123456 33.00000001234540 -> 100.0000000000002 Rounded
-ddsub925 subtract 133.0000000123456 43.00000001234560 -> 90.00000000000000
-ddsub926 subtract 133.0000000123456 43.00000001234561 -> 89.99999999999999
-ddsub927 subtract 133.0000000123456 43.00000001234566 -> 89.99999999999994
-ddsub928 subtract 101.0000000123456 91.00000001234566 -> 9.99999999999994
-ddsub929 subtract 101.0000000123456 99.00000001234566 -> 1.99999999999994
-
--- more LHS swaps [were fixed]
-ddsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
-ddsub391 subtract '-56267E-6' 0 -> '-0.056267'
-ddsub392 subtract '-56267E-5' 0 -> '-0.56267'
-ddsub393 subtract '-56267E-4' 0 -> '-5.6267'
-ddsub394 subtract '-56267E-3' 0 -> '-56.267'
-ddsub395 subtract '-56267E-2' 0 -> '-562.67'
-ddsub396 subtract '-56267E-1' 0 -> '-5626.7'
-ddsub397 subtract '-56267E-0' 0 -> '-56267'
-ddsub398 subtract '-5E-10' 0 -> '-5E-10'
-ddsub399 subtract '-5E-7' 0 -> '-5E-7'
-ddsub400 subtract '-5E-6' 0 -> '-0.000005'
-ddsub401 subtract '-5E-5' 0 -> '-0.00005'
-ddsub402 subtract '-5E-4' 0 -> '-0.0005'
-ddsub403 subtract '-5E-1' 0 -> '-0.5'
-ddsub404 subtract '-5E0' 0 -> '-5'
-ddsub405 subtract '-5E1' 0 -> '-50'
-ddsub406 subtract '-5E5' 0 -> '-500000'
-ddsub407 subtract '-5E15' 0 -> '-5000000000000000'
-ddsub408 subtract '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-ddsub409 subtract '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-ddsub410 subtract '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-ddsub411 subtract '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps [were fixed]
-ddsub420 subtract 0 '-56267E-10' -> '0.0000056267'
-ddsub421 subtract 0 '-56267E-6' -> '0.056267'
-ddsub422 subtract 0 '-56267E-5' -> '0.56267'
-ddsub423 subtract 0 '-56267E-4' -> '5.6267'
-ddsub424 subtract 0 '-56267E-3' -> '56.267'
-ddsub425 subtract 0 '-56267E-2' -> '562.67'
-ddsub426 subtract 0 '-56267E-1' -> '5626.7'
-ddsub427 subtract 0 '-56267E-0' -> '56267'
-ddsub428 subtract 0 '-5E-10' -> '5E-10'
-ddsub429 subtract 0 '-5E-7' -> '5E-7'
-ddsub430 subtract 0 '-5E-6' -> '0.000005'
-ddsub431 subtract 0 '-5E-5' -> '0.00005'
-ddsub432 subtract 0 '-5E-4' -> '0.0005'
-ddsub433 subtract 0 '-5E-1' -> '0.5'
-ddsub434 subtract 0 '-5E0' -> '5'
-ddsub435 subtract 0 '-5E1' -> '50'
-ddsub436 subtract 0 '-5E5' -> '500000'
-ddsub437 subtract 0 '-5E15' -> '5000000000000000'
-ddsub438 subtract 0 '-5E16' -> '5.000000000000000E+16' Rounded
-ddsub439 subtract 0 '-5E17' -> '5.000000000000000E+17' Rounded
-ddsub440 subtract 0 '-5E18' -> '5.000000000000000E+18' Rounded
-ddsub441 subtract 0 '-5E100' -> '5.000000000000000E+100' Rounded
-
-
--- try borderline precision, with carries, etc.
-ddsub461 subtract '1E+16' '1' -> '9999999999999999'
-ddsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
-ddsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
-ddsub464 subtract '-1' '-1E+16' -> '9999999999999999'
-ddsub465 subtract '7E+15' '1' -> '6999999999999999'
-ddsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
-ddsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
-ddsub468 subtract '-1' '-7E+15' -> '6999999999999999'
-
--- 1234567890123456 1234567890123456 1 23456789012345
-ddsub470 subtract '0.4444444444444444' '-0.5555555555555563' -> '1.000000000000001' Inexact Rounded
-ddsub471 subtract '0.4444444444444444' '-0.5555555555555562' -> '1.000000000000001' Inexact Rounded
-ddsub472 subtract '0.4444444444444444' '-0.5555555555555561' -> '1.000000000000000' Inexact Rounded
-ddsub473 subtract '0.4444444444444444' '-0.5555555555555560' -> '1.000000000000000' Inexact Rounded
-ddsub474 subtract '0.4444444444444444' '-0.5555555555555559' -> '1.000000000000000' Inexact Rounded
-ddsub475 subtract '0.4444444444444444' '-0.5555555555555558' -> '1.000000000000000' Inexact Rounded
-ddsub476 subtract '0.4444444444444444' '-0.5555555555555557' -> '1.000000000000000' Inexact Rounded
-ddsub477 subtract '0.4444444444444444' '-0.5555555555555556' -> '1.000000000000000' Rounded
-ddsub478 subtract '0.4444444444444444' '-0.5555555555555555' -> '0.9999999999999999'
-ddsub479 subtract '0.4444444444444444' '-0.5555555555555554' -> '0.9999999999999998'
-ddsub480 subtract '0.4444444444444444' '-0.5555555555555553' -> '0.9999999999999997'
-ddsub481 subtract '0.4444444444444444' '-0.5555555555555552' -> '0.9999999999999996'
-ddsub482 subtract '0.4444444444444444' '-0.5555555555555551' -> '0.9999999999999995'
-ddsub483 subtract '0.4444444444444444' '-0.5555555555555550' -> '0.9999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-ddsub500 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub501 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
-ddsub502 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
-ddsub503 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
-ddsub504 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
-ddsub505 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
-ddsub506 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
-ddsub507 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
-ddsub508 subtract '1231234567456789' 0.5 -> '1231234567456789' Inexact Rounded
-ddsub509 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub510 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub511 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub512 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub513 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub514 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub515 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub516 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub517 subtract '1231234567456789' 1.000000001 -> '1231234567456788' Inexact Rounded
-ddsub518 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
-ddsub519 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
-
-rounding: half_even
-ddsub520 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub521 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
-ddsub522 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
-ddsub523 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
-ddsub524 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
-ddsub525 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
-ddsub526 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
-ddsub527 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
-ddsub528 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub529 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub530 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub531 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub532 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub533 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub534 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub535 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub536 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub537 subtract '1231234567456789' 1.00000001 -> '1231234567456788' Inexact Rounded
-ddsub538 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
-ddsub539 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
--- critical few with even bottom digit...
-ddsub540 subtract '1231234567456788' 0.499999999 -> '1231234567456788' Inexact Rounded
-ddsub541 subtract '1231234567456788' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub542 subtract '1231234567456788' 0.500000001 -> '1231234567456787' Inexact Rounded
-
-rounding: down
-ddsub550 subtract '1231234567456789' 0 -> '1231234567456789'
-ddsub551 subtract '1231234567456789' 0.000000001 -> '1231234567456788' Inexact Rounded
-ddsub552 subtract '1231234567456789' 0.000001 -> '1231234567456788' Inexact Rounded
-ddsub553 subtract '1231234567456789' 0.1 -> '1231234567456788' Inexact Rounded
-ddsub554 subtract '1231234567456789' 0.4 -> '1231234567456788' Inexact Rounded
-ddsub555 subtract '1231234567456789' 0.49 -> '1231234567456788' Inexact Rounded
-ddsub556 subtract '1231234567456789' 0.499999 -> '1231234567456788' Inexact Rounded
-ddsub557 subtract '1231234567456789' 0.499999999 -> '1231234567456788' Inexact Rounded
-ddsub558 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
-ddsub559 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
-ddsub560 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
-ddsub561 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
-ddsub562 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
-ddsub563 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
-ddsub564 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
-ddsub565 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
-ddsub566 subtract '1231234567456789' 1 -> '1231234567456788'
-ddsub567 subtract '1231234567456789' 1.00000001 -> '1231234567456787' Inexact Rounded
-ddsub568 subtract '1231234567456789' 1.00001 -> '1231234567456787' Inexact Rounded
-ddsub569 subtract '1231234567456789' 1.1 -> '1231234567456787' Inexact Rounded
-
--- symmetry...
-rounding: half_up
-ddsub600 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub601 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub602 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub603 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub604 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub605 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub606 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub607 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub608 subtract 0.5 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub609 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub610 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub611 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub612 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub613 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub614 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub615 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub616 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub617 subtract 1.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub618 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub619 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-
-rounding: half_even
-ddsub620 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub621 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub622 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub623 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub624 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub625 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub626 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub627 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
-ddsub628 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub629 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub630 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub631 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub632 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub633 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub634 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub635 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub636 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub637 subtract 1.00000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub638 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub639 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
--- critical few with even bottom digit...
-ddsub640 subtract 0.499999999 '1231234567456788' -> '-1231234567456788' Inexact Rounded
-ddsub641 subtract 0.5 '1231234567456788' -> '-1231234567456788' Inexact Rounded
-ddsub642 subtract 0.500000001 '1231234567456788' -> '-1231234567456787' Inexact Rounded
-
-rounding: down
-ddsub650 subtract 0 '1231234567456789' -> '-1231234567456789'
-ddsub651 subtract 0.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub652 subtract 0.000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub653 subtract 0.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub654 subtract 0.4 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub655 subtract 0.49 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub656 subtract 0.499999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub657 subtract 0.499999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub658 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub659 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub660 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub661 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub662 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub663 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub664 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub665 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
-ddsub666 subtract 1 '1231234567456789' -> '-1231234567456788'
-ddsub667 subtract 1.00000001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-ddsub668 subtract 1.00001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-ddsub669 subtract 1.1 '1231234567456789' -> '-1231234567456787' Inexact Rounded
-
-
--- lots of leading zeros in intermediate result, and showing effects of
--- input rounding would have affected the following
-rounding: half_up
-ddsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-rounding: half_even
-ddsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-ddsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
-ddsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
-ddsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
-ddsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
-ddsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
-
-rounding: down
-ddsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
-ddsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
-ddsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
-ddsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
-ddsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
-
--- Specials
-ddsub780 subtract -Inf Inf -> -Infinity
-ddsub781 subtract -Inf 1000 -> -Infinity
-ddsub782 subtract -Inf 1 -> -Infinity
-ddsub783 subtract -Inf -0 -> -Infinity
-ddsub784 subtract -Inf -1 -> -Infinity
-ddsub785 subtract -Inf -1000 -> -Infinity
-ddsub787 subtract -1000 Inf -> -Infinity
-ddsub788 subtract -Inf Inf -> -Infinity
-ddsub789 subtract -1 Inf -> -Infinity
-ddsub790 subtract 0 Inf -> -Infinity
-ddsub791 subtract 1 Inf -> -Infinity
-ddsub792 subtract 1000 Inf -> -Infinity
-
-ddsub800 subtract Inf Inf -> NaN Invalid_operation
-ddsub801 subtract Inf 1000 -> Infinity
-ddsub802 subtract Inf 1 -> Infinity
-ddsub803 subtract Inf 0 -> Infinity
-ddsub804 subtract Inf -0 -> Infinity
-ddsub805 subtract Inf -1 -> Infinity
-ddsub806 subtract Inf -1000 -> Infinity
-ddsub807 subtract Inf -Inf -> Infinity
-ddsub808 subtract -1000 -Inf -> Infinity
-ddsub809 subtract -Inf -Inf -> NaN Invalid_operation
-ddsub810 subtract -1 -Inf -> Infinity
-ddsub811 subtract -0 -Inf -> Infinity
-ddsub812 subtract 0 -Inf -> Infinity
-ddsub813 subtract 1 -Inf -> Infinity
-ddsub814 subtract 1000 -Inf -> Infinity
-ddsub815 subtract Inf -Inf -> Infinity
-
-ddsub821 subtract NaN Inf -> NaN
-ddsub822 subtract -NaN 1000 -> -NaN
-ddsub823 subtract NaN 1 -> NaN
-ddsub824 subtract NaN 0 -> NaN
-ddsub825 subtract NaN -0 -> NaN
-ddsub826 subtract NaN -1 -> NaN
-ddsub827 subtract NaN -1000 -> NaN
-ddsub828 subtract NaN -Inf -> NaN
-ddsub829 subtract -NaN NaN -> -NaN
-ddsub830 subtract -Inf NaN -> NaN
-ddsub831 subtract -1000 NaN -> NaN
-ddsub832 subtract -1 NaN -> NaN
-ddsub833 subtract -0 NaN -> NaN
-ddsub834 subtract 0 NaN -> NaN
-ddsub835 subtract 1 NaN -> NaN
-ddsub836 subtract 1000 -NaN -> -NaN
-ddsub837 subtract Inf NaN -> NaN
-
-ddsub841 subtract sNaN Inf -> NaN Invalid_operation
-ddsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
-ddsub843 subtract sNaN 1 -> NaN Invalid_operation
-ddsub844 subtract sNaN 0 -> NaN Invalid_operation
-ddsub845 subtract sNaN -0 -> NaN Invalid_operation
-ddsub846 subtract sNaN -1 -> NaN Invalid_operation
-ddsub847 subtract sNaN -1000 -> NaN Invalid_operation
-ddsub848 subtract sNaN NaN -> NaN Invalid_operation
-ddsub849 subtract sNaN sNaN -> NaN Invalid_operation
-ddsub850 subtract NaN sNaN -> NaN Invalid_operation
-ddsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
-ddsub852 subtract -1000 sNaN -> NaN Invalid_operation
-ddsub853 subtract -1 sNaN -> NaN Invalid_operation
-ddsub854 subtract -0 sNaN -> NaN Invalid_operation
-ddsub855 subtract 0 sNaN -> NaN Invalid_operation
-ddsub856 subtract 1 sNaN -> NaN Invalid_operation
-ddsub857 subtract 1000 sNaN -> NaN Invalid_operation
-ddsub858 subtract Inf sNaN -> NaN Invalid_operation
-ddsub859 subtract NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddsub861 subtract NaN01 -Inf -> NaN1
-ddsub862 subtract -NaN02 -1000 -> -NaN2
-ddsub863 subtract NaN03 1000 -> NaN3
-ddsub864 subtract NaN04 Inf -> NaN4
-ddsub865 subtract NaN05 NaN61 -> NaN5
-ddsub866 subtract -Inf -NaN71 -> -NaN71
-ddsub867 subtract -1000 NaN81 -> NaN81
-ddsub868 subtract 1000 NaN91 -> NaN91
-ddsub869 subtract Inf NaN101 -> NaN101
-ddsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
-ddsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
-ddsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
-ddsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
-ddsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
-ddsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
-ddsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
-ddsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
-ddsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
-ddsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
-ddsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- edge case spills
-ddsub901 subtract 2.E-3 1.002 -> -1.000
-ddsub902 subtract 2.0E-3 1.002 -> -1.0000
-ddsub903 subtract 2.00E-3 1.0020 -> -1.00000
-ddsub904 subtract 2.000E-3 1.00200 -> -1.000000
-ddsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
-ddsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
-ddsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
-ddsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
-
--- subnormals and overflows covered under Add
-
--- Null tests
-ddsub9990 subtract 10 # -> NaN Invalid_operation
-ddsub9991 subtract # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddSubtract.decTest -- decDouble subtraction --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decDoubles only; all arguments are
+-- representable in a decDouble
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+ddsub001 subtract 0 0 -> '0'
+ddsub002 subtract 1 1 -> '0'
+ddsub003 subtract 1 2 -> '-1'
+ddsub004 subtract 2 1 -> '1'
+ddsub005 subtract 2 2 -> '0'
+ddsub006 subtract 3 2 -> '1'
+ddsub007 subtract 2 3 -> '-1'
+
+ddsub011 subtract -0 0 -> '-0'
+ddsub012 subtract -1 1 -> '-2'
+ddsub013 subtract -1 2 -> '-3'
+ddsub014 subtract -2 1 -> '-3'
+ddsub015 subtract -2 2 -> '-4'
+ddsub016 subtract -3 2 -> '-5'
+ddsub017 subtract -2 3 -> '-5'
+
+ddsub021 subtract 0 -0 -> '0'
+ddsub022 subtract 1 -1 -> '2'
+ddsub023 subtract 1 -2 -> '3'
+ddsub024 subtract 2 -1 -> '3'
+ddsub025 subtract 2 -2 -> '4'
+ddsub026 subtract 3 -2 -> '5'
+ddsub027 subtract 2 -3 -> '5'
+
+ddsub030 subtract 11 1 -> 10
+ddsub031 subtract 10 1 -> 9
+ddsub032 subtract 9 1 -> 8
+ddsub033 subtract 1 1 -> 0
+ddsub034 subtract 0 1 -> -1
+ddsub035 subtract -1 1 -> -2
+ddsub036 subtract -9 1 -> -10
+ddsub037 subtract -10 1 -> -11
+ddsub038 subtract -11 1 -> -12
+
+ddsub040 subtract '5.75' '3.3' -> '2.45'
+ddsub041 subtract '5' '-3' -> '8'
+ddsub042 subtract '-5' '-3' -> '-2'
+ddsub043 subtract '-7' '2.5' -> '-9.5'
+ddsub044 subtract '0.7' '0.3' -> '0.4'
+ddsub045 subtract '1.3' '0.3' -> '1.0'
+ddsub046 subtract '1.25' '1.25' -> '0.00'
+
+ddsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
+ddsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
+
+ddsub060 subtract '70' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
+ddsub061 subtract '700' '10000e+16' -> '-1.000000000000000E+20' Inexact Rounded
+ddsub062 subtract '7000' '10000e+16' -> '-9.999999999999999E+19' Inexact Rounded
+ddsub063 subtract '70000' '10000e+16' -> '-9.999999999999993E+19' Rounded
+ddsub064 subtract '700000' '10000e+16' -> '-9.999999999999930E+19' Rounded
+ -- symmetry:
+ddsub065 subtract '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+ddsub066 subtract '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+ddsub067 subtract '10000e+16' '7000' -> '9.999999999999999E+19' Inexact Rounded
+ddsub068 subtract '10000e+16' '70000' -> '9.999999999999993E+19' Rounded
+ddsub069 subtract '10000e+16' '700000' -> '9.999999999999930E+19' Rounded
+
+ -- some of the next group are really constructor tests
+ddsub090 subtract '00.0' '0.0' -> '0.0'
+ddsub091 subtract '00.0' '0.00' -> '0.00'
+ddsub092 subtract '0.00' '00.0' -> '0.00'
+ddsub093 subtract '00.0' '0.00' -> '0.00'
+ddsub094 subtract '0.00' '00.0' -> '0.00'
+ddsub095 subtract '3' '.3' -> '2.7'
+ddsub096 subtract '3.' '.3' -> '2.7'
+ddsub097 subtract '3.0' '.3' -> '2.7'
+ddsub098 subtract '3.00' '.3' -> '2.70'
+ddsub099 subtract '3' '3' -> '0'
+ddsub100 subtract '3' '+3' -> '0'
+ddsub101 subtract '3' '-3' -> '6'
+ddsub102 subtract '3' '0.3' -> '2.7'
+ddsub103 subtract '3.' '0.3' -> '2.7'
+ddsub104 subtract '3.0' '0.3' -> '2.7'
+ddsub105 subtract '3.00' '0.3' -> '2.70'
+ddsub106 subtract '3' '3.0' -> '0.0'
+ddsub107 subtract '3' '+3.0' -> '0.0'
+ddsub108 subtract '3' '-3.0' -> '6.0'
+
+-- the above all from add; massaged and extended. Now some new ones...
+-- [particularly important for comparisons]
+-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
+-- with input rounding.
+ddsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
+ddsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
+ddsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
+ddsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
+ddsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
+ddsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
+ddsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
+ddsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
+ddsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
+ddsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
+ddsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
+ddsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
+ddsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
+ddsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
+ddsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
+ddsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
+ddsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
+ddsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
+ddsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
+ddsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
+ddsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
+ddsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
+ddsub142 subtract '1' '0.999999999' -> '1E-9'
+ddsub143 subtract '0.999999999' '1' -> '-1E-9'
+ddsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
+ddsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
+ddsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
+
+-- additional scaled arithmetic tests [0.97 problem]
+ddsub160 subtract '0' '.1' -> '-0.1'
+ddsub161 subtract '00' '.97983' -> '-0.97983'
+ddsub162 subtract '0' '.9' -> '-0.9'
+ddsub163 subtract '0' '0.102' -> '-0.102'
+ddsub164 subtract '0' '.4' -> '-0.4'
+ddsub165 subtract '0' '.307' -> '-0.307'
+ddsub166 subtract '0' '.43822' -> '-0.43822'
+ddsub167 subtract '0' '.911' -> '-0.911'
+ddsub168 subtract '.0' '.02' -> '-0.02'
+ddsub169 subtract '00' '.392' -> '-0.392'
+ddsub170 subtract '0' '.26' -> '-0.26'
+ddsub171 subtract '0' '0.51' -> '-0.51'
+ddsub172 subtract '0' '.2234' -> '-0.2234'
+ddsub173 subtract '0' '.2' -> '-0.2'
+ddsub174 subtract '.0' '.0008' -> '-0.0008'
+-- 0. on left
+ddsub180 subtract '0.0' '-.1' -> '0.1'
+ddsub181 subtract '0.00' '-.97983' -> '0.97983'
+ddsub182 subtract '0.0' '-.9' -> '0.9'
+ddsub183 subtract '0.0' '-0.102' -> '0.102'
+ddsub184 subtract '0.0' '-.4' -> '0.4'
+ddsub185 subtract '0.0' '-.307' -> '0.307'
+ddsub186 subtract '0.0' '-.43822' -> '0.43822'
+ddsub187 subtract '0.0' '-.911' -> '0.911'
+ddsub188 subtract '0.0' '-.02' -> '0.02'
+ddsub189 subtract '0.00' '-.392' -> '0.392'
+ddsub190 subtract '0.0' '-.26' -> '0.26'
+ddsub191 subtract '0.0' '-0.51' -> '0.51'
+ddsub192 subtract '0.0' '-.2234' -> '0.2234'
+ddsub193 subtract '0.0' '-.2' -> '0.2'
+ddsub194 subtract '0.0' '-.0008' -> '0.0008'
+-- negatives of same
+ddsub200 subtract '0' '-.1' -> '0.1'
+ddsub201 subtract '00' '-.97983' -> '0.97983'
+ddsub202 subtract '0' '-.9' -> '0.9'
+ddsub203 subtract '0' '-0.102' -> '0.102'
+ddsub204 subtract '0' '-.4' -> '0.4'
+ddsub205 subtract '0' '-.307' -> '0.307'
+ddsub206 subtract '0' '-.43822' -> '0.43822'
+ddsub207 subtract '0' '-.911' -> '0.911'
+ddsub208 subtract '.0' '-.02' -> '0.02'
+ddsub209 subtract '00' '-.392' -> '0.392'
+ddsub210 subtract '0' '-.26' -> '0.26'
+ddsub211 subtract '0' '-0.51' -> '0.51'
+ddsub212 subtract '0' '-.2234' -> '0.2234'
+ddsub213 subtract '0' '-.2' -> '0.2'
+ddsub214 subtract '.0' '-.0008' -> '0.0008'
+
+-- more fixed, LHS swaps [really the same as testcases under add]
+ddsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
+ddsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
+ddsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
+ddsub223 subtract '-56267E-9' 0 -> '-0.000056267'
+ddsub224 subtract '-56267E-8' 0 -> '-0.00056267'
+ddsub225 subtract '-56267E-7' 0 -> '-0.0056267'
+ddsub226 subtract '-56267E-6' 0 -> '-0.056267'
+ddsub227 subtract '-56267E-5' 0 -> '-0.56267'
+ddsub228 subtract '-56267E-2' 0 -> '-562.67'
+ddsub229 subtract '-56267E-1' 0 -> '-5626.7'
+ddsub230 subtract '-56267E-0' 0 -> '-56267'
+-- symmetry ...
+ddsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
+ddsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
+ddsub242 subtract 0 '-56267E-10' -> '0.0000056267'
+ddsub243 subtract 0 '-56267E-9' -> '0.000056267'
+ddsub244 subtract 0 '-56267E-8' -> '0.00056267'
+ddsub245 subtract 0 '-56267E-7' -> '0.0056267'
+ddsub246 subtract 0 '-56267E-6' -> '0.056267'
+ddsub247 subtract 0 '-56267E-5' -> '0.56267'
+ddsub248 subtract 0 '-56267E-2' -> '562.67'
+ddsub249 subtract 0 '-56267E-1' -> '5626.7'
+ddsub250 subtract 0 '-56267E-0' -> '56267'
+
+-- now some more from the 'new' add
+ddsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
+ddsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
+
+-- some carrying effects
+ddsub321 subtract '0.9998' '0.0000' -> '0.9998'
+ddsub322 subtract '0.9998' '0.0001' -> '0.9997'
+ddsub323 subtract '0.9998' '0.0002' -> '0.9996'
+ddsub324 subtract '0.9998' '0.0003' -> '0.9995'
+ddsub325 subtract '0.9998' '-0.0000' -> '0.9998'
+ddsub326 subtract '0.9998' '-0.0001' -> '0.9999'
+ddsub327 subtract '0.9998' '-0.0002' -> '1.0000'
+ddsub328 subtract '0.9998' '-0.0003' -> '1.0001'
+
+-- internal boundaries
+ddsub346 subtract '10000e+9' '7' -> '9999999999993'
+ddsub347 subtract '10000e+9' '70' -> '9999999999930'
+ddsub348 subtract '10000e+9' '700' -> '9999999999300'
+ddsub349 subtract '10000e+9' '7000' -> '9999999993000'
+ddsub350 subtract '10000e+9' '70000' -> '9999999930000'
+ddsub351 subtract '10000e+9' '700000' -> '9999999300000'
+ddsub352 subtract '7' '10000e+9' -> '-9999999999993'
+ddsub353 subtract '70' '10000e+9' -> '-9999999999930'
+ddsub354 subtract '700' '10000e+9' -> '-9999999999300'
+ddsub355 subtract '7000' '10000e+9' -> '-9999999993000'
+ddsub356 subtract '70000' '10000e+9' -> '-9999999930000'
+ddsub357 subtract '700000' '10000e+9' -> '-9999999300000'
+
+-- zero preservation
+ddsub361 subtract 1 '0.0001' -> '0.9999'
+ddsub362 subtract 1 '0.00001' -> '0.99999'
+ddsub363 subtract 1 '0.000001' -> '0.999999'
+ddsub364 subtract 1 '0.0000000000000001' -> '0.9999999999999999'
+ddsub365 subtract 1 '0.00000000000000001' -> '1.000000000000000' Inexact Rounded
+ddsub366 subtract 1 '0.000000000000000001' -> '1.000000000000000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+ddsub370 subtract 1 0 -> 1
+ddsub371 subtract 1 0. -> 1
+ddsub372 subtract 1 .0 -> 1.0
+ddsub373 subtract 1 0.0 -> 1.0
+ddsub374 subtract 0 1 -> -1
+ddsub375 subtract 0. 1 -> -1
+ddsub376 subtract .0 1 -> -1.0
+ddsub377 subtract 0.0 1 -> -1.0
+
+-- leading 0 digit before round
+ddsub910 subtract -103519362 -51897955.3 -> -51621406.7
+ddsub911 subtract 159579.444 89827.5229 -> 69751.9211
+
+ddsub920 subtract 333.0000000123456 33.00000001234566 -> 299.9999999999999 Inexact Rounded
+ddsub921 subtract 333.0000000123456 33.00000001234565 -> 300.0000000000000 Inexact Rounded
+ddsub922 subtract 133.0000000123456 33.00000001234565 -> 99.99999999999995
+ddsub923 subtract 133.0000000123456 33.00000001234564 -> 99.99999999999996
+ddsub924 subtract 133.0000000123456 33.00000001234540 -> 100.0000000000002 Rounded
+ddsub925 subtract 133.0000000123456 43.00000001234560 -> 90.00000000000000
+ddsub926 subtract 133.0000000123456 43.00000001234561 -> 89.99999999999999
+ddsub927 subtract 133.0000000123456 43.00000001234566 -> 89.99999999999994
+ddsub928 subtract 101.0000000123456 91.00000001234566 -> 9.99999999999994
+ddsub929 subtract 101.0000000123456 99.00000001234566 -> 1.99999999999994
+
+-- more LHS swaps [were fixed]
+ddsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
+ddsub391 subtract '-56267E-6' 0 -> '-0.056267'
+ddsub392 subtract '-56267E-5' 0 -> '-0.56267'
+ddsub393 subtract '-56267E-4' 0 -> '-5.6267'
+ddsub394 subtract '-56267E-3' 0 -> '-56.267'
+ddsub395 subtract '-56267E-2' 0 -> '-562.67'
+ddsub396 subtract '-56267E-1' 0 -> '-5626.7'
+ddsub397 subtract '-56267E-0' 0 -> '-56267'
+ddsub398 subtract '-5E-10' 0 -> '-5E-10'
+ddsub399 subtract '-5E-7' 0 -> '-5E-7'
+ddsub400 subtract '-5E-6' 0 -> '-0.000005'
+ddsub401 subtract '-5E-5' 0 -> '-0.00005'
+ddsub402 subtract '-5E-4' 0 -> '-0.0005'
+ddsub403 subtract '-5E-1' 0 -> '-0.5'
+ddsub404 subtract '-5E0' 0 -> '-5'
+ddsub405 subtract '-5E1' 0 -> '-50'
+ddsub406 subtract '-5E5' 0 -> '-500000'
+ddsub407 subtract '-5E15' 0 -> '-5000000000000000'
+ddsub408 subtract '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+ddsub409 subtract '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+ddsub410 subtract '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+ddsub411 subtract '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps [were fixed]
+ddsub420 subtract 0 '-56267E-10' -> '0.0000056267'
+ddsub421 subtract 0 '-56267E-6' -> '0.056267'
+ddsub422 subtract 0 '-56267E-5' -> '0.56267'
+ddsub423 subtract 0 '-56267E-4' -> '5.6267'
+ddsub424 subtract 0 '-56267E-3' -> '56.267'
+ddsub425 subtract 0 '-56267E-2' -> '562.67'
+ddsub426 subtract 0 '-56267E-1' -> '5626.7'
+ddsub427 subtract 0 '-56267E-0' -> '56267'
+ddsub428 subtract 0 '-5E-10' -> '5E-10'
+ddsub429 subtract 0 '-5E-7' -> '5E-7'
+ddsub430 subtract 0 '-5E-6' -> '0.000005'
+ddsub431 subtract 0 '-5E-5' -> '0.00005'
+ddsub432 subtract 0 '-5E-4' -> '0.0005'
+ddsub433 subtract 0 '-5E-1' -> '0.5'
+ddsub434 subtract 0 '-5E0' -> '5'
+ddsub435 subtract 0 '-5E1' -> '50'
+ddsub436 subtract 0 '-5E5' -> '500000'
+ddsub437 subtract 0 '-5E15' -> '5000000000000000'
+ddsub438 subtract 0 '-5E16' -> '5.000000000000000E+16' Rounded
+ddsub439 subtract 0 '-5E17' -> '5.000000000000000E+17' Rounded
+ddsub440 subtract 0 '-5E18' -> '5.000000000000000E+18' Rounded
+ddsub441 subtract 0 '-5E100' -> '5.000000000000000E+100' Rounded
+
+
+-- try borderline precision, with carries, etc.
+ddsub461 subtract '1E+16' '1' -> '9999999999999999'
+ddsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
+ddsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
+ddsub464 subtract '-1' '-1E+16' -> '9999999999999999'
+ddsub465 subtract '7E+15' '1' -> '6999999999999999'
+ddsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
+ddsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
+ddsub468 subtract '-1' '-7E+15' -> '6999999999999999'
+
+-- 1234567890123456 1234567890123456 1 23456789012345
+ddsub470 subtract '0.4444444444444444' '-0.5555555555555563' -> '1.000000000000001' Inexact Rounded
+ddsub471 subtract '0.4444444444444444' '-0.5555555555555562' -> '1.000000000000001' Inexact Rounded
+ddsub472 subtract '0.4444444444444444' '-0.5555555555555561' -> '1.000000000000000' Inexact Rounded
+ddsub473 subtract '0.4444444444444444' '-0.5555555555555560' -> '1.000000000000000' Inexact Rounded
+ddsub474 subtract '0.4444444444444444' '-0.5555555555555559' -> '1.000000000000000' Inexact Rounded
+ddsub475 subtract '0.4444444444444444' '-0.5555555555555558' -> '1.000000000000000' Inexact Rounded
+ddsub476 subtract '0.4444444444444444' '-0.5555555555555557' -> '1.000000000000000' Inexact Rounded
+ddsub477 subtract '0.4444444444444444' '-0.5555555555555556' -> '1.000000000000000' Rounded
+ddsub478 subtract '0.4444444444444444' '-0.5555555555555555' -> '0.9999999999999999'
+ddsub479 subtract '0.4444444444444444' '-0.5555555555555554' -> '0.9999999999999998'
+ddsub480 subtract '0.4444444444444444' '-0.5555555555555553' -> '0.9999999999999997'
+ddsub481 subtract '0.4444444444444444' '-0.5555555555555552' -> '0.9999999999999996'
+ddsub482 subtract '0.4444444444444444' '-0.5555555555555551' -> '0.9999999999999995'
+ddsub483 subtract '0.4444444444444444' '-0.5555555555555550' -> '0.9999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+ddsub500 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub501 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
+ddsub502 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
+ddsub503 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
+ddsub504 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
+ddsub505 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
+ddsub506 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
+ddsub507 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
+ddsub508 subtract '1231234567456789' 0.5 -> '1231234567456789' Inexact Rounded
+ddsub509 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub510 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub511 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub512 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub513 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub514 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub515 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub516 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub517 subtract '1231234567456789' 1.000000001 -> '1231234567456788' Inexact Rounded
+ddsub518 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
+ddsub519 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
+
+rounding: half_even
+ddsub520 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub521 subtract '1231234567456789' 0.000000001 -> '1231234567456789' Inexact Rounded
+ddsub522 subtract '1231234567456789' 0.000001 -> '1231234567456789' Inexact Rounded
+ddsub523 subtract '1231234567456789' 0.1 -> '1231234567456789' Inexact Rounded
+ddsub524 subtract '1231234567456789' 0.4 -> '1231234567456789' Inexact Rounded
+ddsub525 subtract '1231234567456789' 0.49 -> '1231234567456789' Inexact Rounded
+ddsub526 subtract '1231234567456789' 0.499999 -> '1231234567456789' Inexact Rounded
+ddsub527 subtract '1231234567456789' 0.499999999 -> '1231234567456789' Inexact Rounded
+ddsub528 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub529 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub530 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub531 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub532 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub533 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub534 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub535 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub536 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub537 subtract '1231234567456789' 1.00000001 -> '1231234567456788' Inexact Rounded
+ddsub538 subtract '1231234567456789' 1.00001 -> '1231234567456788' Inexact Rounded
+ddsub539 subtract '1231234567456789' 1.1 -> '1231234567456788' Inexact Rounded
+-- critical few with even bottom digit...
+ddsub540 subtract '1231234567456788' 0.499999999 -> '1231234567456788' Inexact Rounded
+ddsub541 subtract '1231234567456788' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub542 subtract '1231234567456788' 0.500000001 -> '1231234567456787' Inexact Rounded
+
+rounding: down
+ddsub550 subtract '1231234567456789' 0 -> '1231234567456789'
+ddsub551 subtract '1231234567456789' 0.000000001 -> '1231234567456788' Inexact Rounded
+ddsub552 subtract '1231234567456789' 0.000001 -> '1231234567456788' Inexact Rounded
+ddsub553 subtract '1231234567456789' 0.1 -> '1231234567456788' Inexact Rounded
+ddsub554 subtract '1231234567456789' 0.4 -> '1231234567456788' Inexact Rounded
+ddsub555 subtract '1231234567456789' 0.49 -> '1231234567456788' Inexact Rounded
+ddsub556 subtract '1231234567456789' 0.499999 -> '1231234567456788' Inexact Rounded
+ddsub557 subtract '1231234567456789' 0.499999999 -> '1231234567456788' Inexact Rounded
+ddsub558 subtract '1231234567456789' 0.5 -> '1231234567456788' Inexact Rounded
+ddsub559 subtract '1231234567456789' 0.500000001 -> '1231234567456788' Inexact Rounded
+ddsub560 subtract '1231234567456789' 0.500001 -> '1231234567456788' Inexact Rounded
+ddsub561 subtract '1231234567456789' 0.51 -> '1231234567456788' Inexact Rounded
+ddsub562 subtract '1231234567456789' 0.6 -> '1231234567456788' Inexact Rounded
+ddsub563 subtract '1231234567456789' 0.9 -> '1231234567456788' Inexact Rounded
+ddsub564 subtract '1231234567456789' 0.99999 -> '1231234567456788' Inexact Rounded
+ddsub565 subtract '1231234567456789' 0.999999999 -> '1231234567456788' Inexact Rounded
+ddsub566 subtract '1231234567456789' 1 -> '1231234567456788'
+ddsub567 subtract '1231234567456789' 1.00000001 -> '1231234567456787' Inexact Rounded
+ddsub568 subtract '1231234567456789' 1.00001 -> '1231234567456787' Inexact Rounded
+ddsub569 subtract '1231234567456789' 1.1 -> '1231234567456787' Inexact Rounded
+
+-- symmetry...
+rounding: half_up
+ddsub600 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub601 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub602 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub603 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub604 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub605 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub606 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub607 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub608 subtract 0.5 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub609 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub610 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub611 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub612 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub613 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub614 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub615 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub616 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub617 subtract 1.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub618 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub619 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+
+rounding: half_even
+ddsub620 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub621 subtract 0.000000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub622 subtract 0.000001 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub623 subtract 0.1 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub624 subtract 0.4 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub625 subtract 0.49 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub626 subtract 0.499999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub627 subtract 0.499999999 '1231234567456789' -> '-1231234567456789' Inexact Rounded
+ddsub628 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub629 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub630 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub631 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub632 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub633 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub634 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub635 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub636 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub637 subtract 1.00000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub638 subtract 1.00001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub639 subtract 1.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+-- critical few with even bottom digit...
+ddsub640 subtract 0.499999999 '1231234567456788' -> '-1231234567456788' Inexact Rounded
+ddsub641 subtract 0.5 '1231234567456788' -> '-1231234567456788' Inexact Rounded
+ddsub642 subtract 0.500000001 '1231234567456788' -> '-1231234567456787' Inexact Rounded
+
+rounding: down
+ddsub650 subtract 0 '1231234567456789' -> '-1231234567456789'
+ddsub651 subtract 0.000000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub652 subtract 0.000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub653 subtract 0.1 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub654 subtract 0.4 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub655 subtract 0.49 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub656 subtract 0.499999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub657 subtract 0.499999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub658 subtract 0.5 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub659 subtract 0.500000001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub660 subtract 0.500001 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub661 subtract 0.51 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub662 subtract 0.6 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub663 subtract 0.9 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub664 subtract 0.99999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub665 subtract 0.999999999 '1231234567456789' -> '-1231234567456788' Inexact Rounded
+ddsub666 subtract 1 '1231234567456789' -> '-1231234567456788'
+ddsub667 subtract 1.00000001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+ddsub668 subtract 1.00001 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+ddsub669 subtract 1.1 '1231234567456789' -> '-1231234567456787' Inexact Rounded
+
+
+-- lots of leading zeros in intermediate result, and showing effects of
+-- input rounding would have affected the following
+rounding: half_up
+ddsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+rounding: half_even
+ddsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+ddsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
+ddsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
+ddsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
+ddsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
+ddsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
+
+rounding: down
+ddsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
+ddsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
+ddsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
+ddsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
+ddsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+-- Specials
+ddsub780 subtract -Inf Inf -> -Infinity
+ddsub781 subtract -Inf 1000 -> -Infinity
+ddsub782 subtract -Inf 1 -> -Infinity
+ddsub783 subtract -Inf -0 -> -Infinity
+ddsub784 subtract -Inf -1 -> -Infinity
+ddsub785 subtract -Inf -1000 -> -Infinity
+ddsub787 subtract -1000 Inf -> -Infinity
+ddsub788 subtract -Inf Inf -> -Infinity
+ddsub789 subtract -1 Inf -> -Infinity
+ddsub790 subtract 0 Inf -> -Infinity
+ddsub791 subtract 1 Inf -> -Infinity
+ddsub792 subtract 1000 Inf -> -Infinity
+
+ddsub800 subtract Inf Inf -> NaN Invalid_operation
+ddsub801 subtract Inf 1000 -> Infinity
+ddsub802 subtract Inf 1 -> Infinity
+ddsub803 subtract Inf 0 -> Infinity
+ddsub804 subtract Inf -0 -> Infinity
+ddsub805 subtract Inf -1 -> Infinity
+ddsub806 subtract Inf -1000 -> Infinity
+ddsub807 subtract Inf -Inf -> Infinity
+ddsub808 subtract -1000 -Inf -> Infinity
+ddsub809 subtract -Inf -Inf -> NaN Invalid_operation
+ddsub810 subtract -1 -Inf -> Infinity
+ddsub811 subtract -0 -Inf -> Infinity
+ddsub812 subtract 0 -Inf -> Infinity
+ddsub813 subtract 1 -Inf -> Infinity
+ddsub814 subtract 1000 -Inf -> Infinity
+ddsub815 subtract Inf -Inf -> Infinity
+
+ddsub821 subtract NaN Inf -> NaN
+ddsub822 subtract -NaN 1000 -> -NaN
+ddsub823 subtract NaN 1 -> NaN
+ddsub824 subtract NaN 0 -> NaN
+ddsub825 subtract NaN -0 -> NaN
+ddsub826 subtract NaN -1 -> NaN
+ddsub827 subtract NaN -1000 -> NaN
+ddsub828 subtract NaN -Inf -> NaN
+ddsub829 subtract -NaN NaN -> -NaN
+ddsub830 subtract -Inf NaN -> NaN
+ddsub831 subtract -1000 NaN -> NaN
+ddsub832 subtract -1 NaN -> NaN
+ddsub833 subtract -0 NaN -> NaN
+ddsub834 subtract 0 NaN -> NaN
+ddsub835 subtract 1 NaN -> NaN
+ddsub836 subtract 1000 -NaN -> -NaN
+ddsub837 subtract Inf NaN -> NaN
+
+ddsub841 subtract sNaN Inf -> NaN Invalid_operation
+ddsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
+ddsub843 subtract sNaN 1 -> NaN Invalid_operation
+ddsub844 subtract sNaN 0 -> NaN Invalid_operation
+ddsub845 subtract sNaN -0 -> NaN Invalid_operation
+ddsub846 subtract sNaN -1 -> NaN Invalid_operation
+ddsub847 subtract sNaN -1000 -> NaN Invalid_operation
+ddsub848 subtract sNaN NaN -> NaN Invalid_operation
+ddsub849 subtract sNaN sNaN -> NaN Invalid_operation
+ddsub850 subtract NaN sNaN -> NaN Invalid_operation
+ddsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
+ddsub852 subtract -1000 sNaN -> NaN Invalid_operation
+ddsub853 subtract -1 sNaN -> NaN Invalid_operation
+ddsub854 subtract -0 sNaN -> NaN Invalid_operation
+ddsub855 subtract 0 sNaN -> NaN Invalid_operation
+ddsub856 subtract 1 sNaN -> NaN Invalid_operation
+ddsub857 subtract 1000 sNaN -> NaN Invalid_operation
+ddsub858 subtract Inf sNaN -> NaN Invalid_operation
+ddsub859 subtract NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddsub861 subtract NaN01 -Inf -> NaN1
+ddsub862 subtract -NaN02 -1000 -> -NaN2
+ddsub863 subtract NaN03 1000 -> NaN3
+ddsub864 subtract NaN04 Inf -> NaN4
+ddsub865 subtract NaN05 NaN61 -> NaN5
+ddsub866 subtract -Inf -NaN71 -> -NaN71
+ddsub867 subtract -1000 NaN81 -> NaN81
+ddsub868 subtract 1000 NaN91 -> NaN91
+ddsub869 subtract Inf NaN101 -> NaN101
+ddsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
+ddsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
+ddsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
+ddsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
+ddsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
+ddsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
+ddsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
+ddsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
+ddsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
+ddsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
+ddsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- edge case spills
+ddsub901 subtract 2.E-3 1.002 -> -1.000
+ddsub902 subtract 2.0E-3 1.002 -> -1.0000
+ddsub903 subtract 2.00E-3 1.0020 -> -1.00000
+ddsub904 subtract 2.000E-3 1.00200 -> -1.000000
+ddsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
+ddsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
+ddsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
+ddsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
+
+-- subnormals and overflows covered under Add
+
+-- Null tests
+ddsub9990 subtract 10 # -> NaN Invalid_operation
+ddsub9991 subtract # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ddToIntegral.decTest b/Lib/test/decimaltestdata/ddToIntegral.decTest
index bf6d61fa563..900bd4ac3a8 100644
--- a/Lib/test/decimaltestdata/ddToIntegral.decTest
+++ b/Lib/test/decimaltestdata/ddToIntegral.decTest
@@ -1,257 +1,257 @@
-------------------------------------------------------------------------
--- ddToIntegral.decTest -- round Double to integral value --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value-exact' operations (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested extensively
--- elsewhere; the tests here are for integrity, rounding mode, etc.
--- Also, it is assumed the test harness will use these tests for both
--- ToIntegralExact (which does set Inexact) and the fixed-name
--- functions (which do not set Inexact).
-
--- Note that decNumber implements an earlier definition of toIntegral
--- which never sets Inexact; the decTest operator for that is called
--- 'tointegral' instead of 'tointegralx'.
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
-ddintx001 tointegralx 0 -> 0
-ddintx002 tointegralx 0.0 -> 0
-ddintx003 tointegralx 0.1 -> 0 Inexact Rounded
-ddintx004 tointegralx 0.2 -> 0 Inexact Rounded
-ddintx005 tointegralx 0.3 -> 0 Inexact Rounded
-ddintx006 tointegralx 0.4 -> 0 Inexact Rounded
-ddintx007 tointegralx 0.5 -> 0 Inexact Rounded
-ddintx008 tointegralx 0.6 -> 1 Inexact Rounded
-ddintx009 tointegralx 0.7 -> 1 Inexact Rounded
-ddintx010 tointegralx 0.8 -> 1 Inexact Rounded
-ddintx011 tointegralx 0.9 -> 1 Inexact Rounded
-ddintx012 tointegralx 1 -> 1
-ddintx013 tointegralx 1.0 -> 1 Rounded
-ddintx014 tointegralx 1.1 -> 1 Inexact Rounded
-ddintx015 tointegralx 1.2 -> 1 Inexact Rounded
-ddintx016 tointegralx 1.3 -> 1 Inexact Rounded
-ddintx017 tointegralx 1.4 -> 1 Inexact Rounded
-ddintx018 tointegralx 1.5 -> 2 Inexact Rounded
-ddintx019 tointegralx 1.6 -> 2 Inexact Rounded
-ddintx020 tointegralx 1.7 -> 2 Inexact Rounded
-ddintx021 tointegralx 1.8 -> 2 Inexact Rounded
-ddintx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-ddintx031 tointegralx -0 -> -0
-ddintx032 tointegralx -0.0 -> -0
-ddintx033 tointegralx -0.1 -> -0 Inexact Rounded
-ddintx034 tointegralx -0.2 -> -0 Inexact Rounded
-ddintx035 tointegralx -0.3 -> -0 Inexact Rounded
-ddintx036 tointegralx -0.4 -> -0 Inexact Rounded
-ddintx037 tointegralx -0.5 -> -0 Inexact Rounded
-ddintx038 tointegralx -0.6 -> -1 Inexact Rounded
-ddintx039 tointegralx -0.7 -> -1 Inexact Rounded
-ddintx040 tointegralx -0.8 -> -1 Inexact Rounded
-ddintx041 tointegralx -0.9 -> -1 Inexact Rounded
-ddintx042 tointegralx -1 -> -1
-ddintx043 tointegralx -1.0 -> -1 Rounded
-ddintx044 tointegralx -1.1 -> -1 Inexact Rounded
-ddintx045 tointegralx -1.2 -> -1 Inexact Rounded
-ddintx046 tointegralx -1.3 -> -1 Inexact Rounded
-ddintx047 tointegralx -1.4 -> -1 Inexact Rounded
-ddintx048 tointegralx -1.5 -> -2 Inexact Rounded
-ddintx049 tointegralx -1.6 -> -2 Inexact Rounded
-ddintx050 tointegralx -1.7 -> -2 Inexact Rounded
-ddintx051 tointegralx -1.8 -> -2 Inexact Rounded
-ddintx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-ddintx053 tointegralx 10E+60 -> 1.0E+61
-ddintx054 tointegralx -10E+60 -> -1.0E+61
-
--- numbers around precision
-ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
-ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-ddintx065 tointegralx '56267E-0' -> '56267'
-ddintx066 tointegralx '56267E+0' -> '56267'
-ddintx067 tointegralx '56267E+1' -> '5.6267E+5'
-ddintx068 tointegralx '56267E+9' -> '5.6267E+13'
-ddintx069 tointegralx '56267E+10' -> '5.6267E+14'
-ddintx070 tointegralx '56267E+11' -> '5.6267E+15'
-ddintx071 tointegralx '56267E+12' -> '5.6267E+16'
-ddintx072 tointegralx '56267E+13' -> '5.6267E+17'
-ddintx073 tointegralx '1.23E+96' -> '1.23E+96'
-ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped
-
-ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-ddintx085 tointegralx '-56267E-0' -> '-56267'
-ddintx086 tointegralx '-56267E+0' -> '-56267'
-ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
-ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
-ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
-ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
-ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
-ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped
-
--- subnormal inputs
-ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded
-ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
-ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
-ddintx103 tointegralx 0E-299 -> 0
-
--- specials and zeros
-ddintx120 tointegralx 'Inf' -> Infinity
-ddintx121 tointegralx '-Inf' -> -Infinity
-ddintx122 tointegralx NaN -> NaN
-ddintx123 tointegralx sNaN -> NaN Invalid_operation
-ddintx124 tointegralx 0 -> 0
-ddintx125 tointegralx -0 -> -0
-ddintx126 tointegralx 0.000 -> 0
-ddintx127 tointegralx 0.00 -> 0
-ddintx128 tointegralx 0.0 -> 0
-ddintx129 tointegralx 0 -> 0
-ddintx130 tointegralx 0E-3 -> 0
-ddintx131 tointegralx 0E-2 -> 0
-ddintx132 tointegralx 0E-1 -> 0
-ddintx133 tointegralx 0E-0 -> 0
-ddintx134 tointegralx 0E+1 -> 0E+1
-ddintx135 tointegralx 0E+2 -> 0E+2
-ddintx136 tointegralx 0E+3 -> 0E+3
-ddintx137 tointegralx 0E+4 -> 0E+4
-ddintx138 tointegralx 0E+5 -> 0E+5
-ddintx139 tointegralx -0.000 -> -0
-ddintx140 tointegralx -0.00 -> -0
-ddintx141 tointegralx -0.0 -> -0
-ddintx142 tointegralx -0 -> -0
-ddintx143 tointegralx -0E-3 -> -0
-ddintx144 tointegralx -0E-2 -> -0
-ddintx145 tointegralx -0E-1 -> -0
-ddintx146 tointegralx -0E-0 -> -0
-ddintx147 tointegralx -0E+1 -> -0E+1
-ddintx148 tointegralx -0E+2 -> -0E+2
-ddintx149 tointegralx -0E+3 -> -0E+3
-ddintx150 tointegralx -0E+4 -> -0E+4
-ddintx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-ddintx152 tointegralx NaN808 -> NaN808
-ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-ddintx154 tointegralx -NaN808 -> -NaN808
-ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-ddintx156 tointegralx -NaN -> -NaN
-ddintx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-ddintx200 tointegralx 2.1 -> 2 Inexact Rounded
-ddintx201 tointegralx 100 -> 100
-ddintx202 tointegralx 100.0 -> 100 Rounded
-ddintx203 tointegralx 101.5 -> 102 Inexact Rounded
-ddintx204 tointegralx -101.5 -> -102 Inexact Rounded
-ddintx205 tointegralx 10E+5 -> 1.0E+6
-ddintx206 tointegralx 7.89E+77 -> 7.89E+77
-ddintx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-ddintx210 tointegralx 55.5 -> 56 Inexact Rounded
-ddintx211 tointegralx 56.5 -> 56 Inexact Rounded
-ddintx212 tointegralx 57.5 -> 58 Inexact Rounded
-ddintx213 tointegralx -55.5 -> -56 Inexact Rounded
-ddintx214 tointegralx -56.5 -> -56 Inexact Rounded
-ddintx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-ddintx220 tointegralx 55.5 -> 56 Inexact Rounded
-ddintx221 tointegralx 56.5 -> 57 Inexact Rounded
-ddintx222 tointegralx 57.5 -> 58 Inexact Rounded
-ddintx223 tointegralx -55.5 -> -56 Inexact Rounded
-ddintx224 tointegralx -56.5 -> -57 Inexact Rounded
-ddintx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-ddintx230 tointegralx 55.5 -> 55 Inexact Rounded
-ddintx231 tointegralx 56.5 -> 56 Inexact Rounded
-ddintx232 tointegralx 57.5 -> 57 Inexact Rounded
-ddintx233 tointegralx -55.5 -> -55 Inexact Rounded
-ddintx234 tointegralx -56.5 -> -56 Inexact Rounded
-ddintx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-ddintx240 tointegralx 55.3 -> 56 Inexact Rounded
-ddintx241 tointegralx 56.3 -> 57 Inexact Rounded
-ddintx242 tointegralx 57.3 -> 58 Inexact Rounded
-ddintx243 tointegralx -55.3 -> -56 Inexact Rounded
-ddintx244 tointegralx -56.3 -> -57 Inexact Rounded
-ddintx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-ddintx250 tointegralx 55.7 -> 55 Inexact Rounded
-ddintx251 tointegralx 56.7 -> 56 Inexact Rounded
-ddintx252 tointegralx 57.7 -> 57 Inexact Rounded
-ddintx253 tointegralx -55.7 -> -55 Inexact Rounded
-ddintx254 tointegralx -56.7 -> -56 Inexact Rounded
-ddintx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-ddintx260 tointegralx 55.3 -> 56 Inexact Rounded
-ddintx261 tointegralx 56.3 -> 57 Inexact Rounded
-ddintx262 tointegralx 57.3 -> 58 Inexact Rounded
-ddintx263 tointegralx -55.3 -> -55 Inexact Rounded
-ddintx264 tointegralx -56.3 -> -56 Inexact Rounded
-ddintx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-ddintx270 tointegralx 55.7 -> 55 Inexact Rounded
-ddintx271 tointegralx 56.7 -> 56 Inexact Rounded
-ddintx272 tointegralx 57.7 -> 57 Inexact Rounded
-ddintx273 tointegralx -55.7 -> -56 Inexact Rounded
-ddintx274 tointegralx -56.7 -> -57 Inexact Rounded
-ddintx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-ddintx300 tointegralx -2147483646 -> -2147483646
-ddintx301 tointegralx -2147483647 -> -2147483647
-ddintx302 tointegralx -2147483648 -> -2147483648
-ddintx303 tointegralx -2147483649 -> -2147483649
-ddintx304 tointegralx 2147483646 -> 2147483646
-ddintx305 tointegralx 2147483647 -> 2147483647
-ddintx306 tointegralx 2147483648 -> 2147483648
-ddintx307 tointegralx 2147483649 -> 2147483649
-ddintx308 tointegralx 4294967294 -> 4294967294
-ddintx309 tointegralx 4294967295 -> 4294967295
-ddintx310 tointegralx 4294967296 -> 4294967296
-ddintx311 tointegralx 4294967297 -> 4294967297
-
+------------------------------------------------------------------------
+-- ddToIntegral.decTest -- round Double to integral value --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value-exact' operations (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested extensively
+-- elsewhere; the tests here are for integrity, rounding mode, etc.
+-- Also, it is assumed the test harness will use these tests for both
+-- ToIntegralExact (which does set Inexact) and the fixed-name
+-- functions (which do not set Inexact).
+
+-- Note that decNumber implements an earlier definition of toIntegral
+-- which never sets Inexact; the decTest operator for that is called
+-- 'tointegral' instead of 'tointegralx'.
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+ddintx001 tointegralx 0 -> 0
+ddintx002 tointegralx 0.0 -> 0
+ddintx003 tointegralx 0.1 -> 0 Inexact Rounded
+ddintx004 tointegralx 0.2 -> 0 Inexact Rounded
+ddintx005 tointegralx 0.3 -> 0 Inexact Rounded
+ddintx006 tointegralx 0.4 -> 0 Inexact Rounded
+ddintx007 tointegralx 0.5 -> 0 Inexact Rounded
+ddintx008 tointegralx 0.6 -> 1 Inexact Rounded
+ddintx009 tointegralx 0.7 -> 1 Inexact Rounded
+ddintx010 tointegralx 0.8 -> 1 Inexact Rounded
+ddintx011 tointegralx 0.9 -> 1 Inexact Rounded
+ddintx012 tointegralx 1 -> 1
+ddintx013 tointegralx 1.0 -> 1 Rounded
+ddintx014 tointegralx 1.1 -> 1 Inexact Rounded
+ddintx015 tointegralx 1.2 -> 1 Inexact Rounded
+ddintx016 tointegralx 1.3 -> 1 Inexact Rounded
+ddintx017 tointegralx 1.4 -> 1 Inexact Rounded
+ddintx018 tointegralx 1.5 -> 2 Inexact Rounded
+ddintx019 tointegralx 1.6 -> 2 Inexact Rounded
+ddintx020 tointegralx 1.7 -> 2 Inexact Rounded
+ddintx021 tointegralx 1.8 -> 2 Inexact Rounded
+ddintx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+ddintx031 tointegralx -0 -> -0
+ddintx032 tointegralx -0.0 -> -0
+ddintx033 tointegralx -0.1 -> -0 Inexact Rounded
+ddintx034 tointegralx -0.2 -> -0 Inexact Rounded
+ddintx035 tointegralx -0.3 -> -0 Inexact Rounded
+ddintx036 tointegralx -0.4 -> -0 Inexact Rounded
+ddintx037 tointegralx -0.5 -> -0 Inexact Rounded
+ddintx038 tointegralx -0.6 -> -1 Inexact Rounded
+ddintx039 tointegralx -0.7 -> -1 Inexact Rounded
+ddintx040 tointegralx -0.8 -> -1 Inexact Rounded
+ddintx041 tointegralx -0.9 -> -1 Inexact Rounded
+ddintx042 tointegralx -1 -> -1
+ddintx043 tointegralx -1.0 -> -1 Rounded
+ddintx044 tointegralx -1.1 -> -1 Inexact Rounded
+ddintx045 tointegralx -1.2 -> -1 Inexact Rounded
+ddintx046 tointegralx -1.3 -> -1 Inexact Rounded
+ddintx047 tointegralx -1.4 -> -1 Inexact Rounded
+ddintx048 tointegralx -1.5 -> -2 Inexact Rounded
+ddintx049 tointegralx -1.6 -> -2 Inexact Rounded
+ddintx050 tointegralx -1.7 -> -2 Inexact Rounded
+ddintx051 tointegralx -1.8 -> -2 Inexact Rounded
+ddintx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+ddintx053 tointegralx 10E+60 -> 1.0E+61
+ddintx054 tointegralx -10E+60 -> -1.0E+61
+
+-- numbers around precision
+ddintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
+ddintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+ddintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+ddintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+ddintx065 tointegralx '56267E-0' -> '56267'
+ddintx066 tointegralx '56267E+0' -> '56267'
+ddintx067 tointegralx '56267E+1' -> '5.6267E+5'
+ddintx068 tointegralx '56267E+9' -> '5.6267E+13'
+ddintx069 tointegralx '56267E+10' -> '5.6267E+14'
+ddintx070 tointegralx '56267E+11' -> '5.6267E+15'
+ddintx071 tointegralx '56267E+12' -> '5.6267E+16'
+ddintx072 tointegralx '56267E+13' -> '5.6267E+17'
+ddintx073 tointegralx '1.23E+96' -> '1.23E+96'
+ddintx074 tointegralx '1.23E+384' -> #47fd300000000000 Clamped
+
+ddintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+ddintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+ddintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+ddintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+ddintx085 tointegralx '-56267E-0' -> '-56267'
+ddintx086 tointegralx '-56267E+0' -> '-56267'
+ddintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+ddintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
+ddintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
+ddintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
+ddintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
+ddintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
+ddintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+ddintx094 tointegralx '-1.23E+384' -> #c7fd300000000000 Clamped
+
+-- subnormal inputs
+ddintx100 tointegralx 1E-299 -> 0 Inexact Rounded
+ddintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
+ddintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
+ddintx103 tointegralx 0E-299 -> 0
+
+-- specials and zeros
+ddintx120 tointegralx 'Inf' -> Infinity
+ddintx121 tointegralx '-Inf' -> -Infinity
+ddintx122 tointegralx NaN -> NaN
+ddintx123 tointegralx sNaN -> NaN Invalid_operation
+ddintx124 tointegralx 0 -> 0
+ddintx125 tointegralx -0 -> -0
+ddintx126 tointegralx 0.000 -> 0
+ddintx127 tointegralx 0.00 -> 0
+ddintx128 tointegralx 0.0 -> 0
+ddintx129 tointegralx 0 -> 0
+ddintx130 tointegralx 0E-3 -> 0
+ddintx131 tointegralx 0E-2 -> 0
+ddintx132 tointegralx 0E-1 -> 0
+ddintx133 tointegralx 0E-0 -> 0
+ddintx134 tointegralx 0E+1 -> 0E+1
+ddintx135 tointegralx 0E+2 -> 0E+2
+ddintx136 tointegralx 0E+3 -> 0E+3
+ddintx137 tointegralx 0E+4 -> 0E+4
+ddintx138 tointegralx 0E+5 -> 0E+5
+ddintx139 tointegralx -0.000 -> -0
+ddintx140 tointegralx -0.00 -> -0
+ddintx141 tointegralx -0.0 -> -0
+ddintx142 tointegralx -0 -> -0
+ddintx143 tointegralx -0E-3 -> -0
+ddintx144 tointegralx -0E-2 -> -0
+ddintx145 tointegralx -0E-1 -> -0
+ddintx146 tointegralx -0E-0 -> -0
+ddintx147 tointegralx -0E+1 -> -0E+1
+ddintx148 tointegralx -0E+2 -> -0E+2
+ddintx149 tointegralx -0E+3 -> -0E+3
+ddintx150 tointegralx -0E+4 -> -0E+4
+ddintx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+ddintx152 tointegralx NaN808 -> NaN808
+ddintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+ddintx154 tointegralx -NaN808 -> -NaN808
+ddintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+ddintx156 tointegralx -NaN -> -NaN
+ddintx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+ddintx200 tointegralx 2.1 -> 2 Inexact Rounded
+ddintx201 tointegralx 100 -> 100
+ddintx202 tointegralx 100.0 -> 100 Rounded
+ddintx203 tointegralx 101.5 -> 102 Inexact Rounded
+ddintx204 tointegralx -101.5 -> -102 Inexact Rounded
+ddintx205 tointegralx 10E+5 -> 1.0E+6
+ddintx206 tointegralx 7.89E+77 -> 7.89E+77
+ddintx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+ddintx210 tointegralx 55.5 -> 56 Inexact Rounded
+ddintx211 tointegralx 56.5 -> 56 Inexact Rounded
+ddintx212 tointegralx 57.5 -> 58 Inexact Rounded
+ddintx213 tointegralx -55.5 -> -56 Inexact Rounded
+ddintx214 tointegralx -56.5 -> -56 Inexact Rounded
+ddintx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+ddintx220 tointegralx 55.5 -> 56 Inexact Rounded
+ddintx221 tointegralx 56.5 -> 57 Inexact Rounded
+ddintx222 tointegralx 57.5 -> 58 Inexact Rounded
+ddintx223 tointegralx -55.5 -> -56 Inexact Rounded
+ddintx224 tointegralx -56.5 -> -57 Inexact Rounded
+ddintx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+ddintx230 tointegralx 55.5 -> 55 Inexact Rounded
+ddintx231 tointegralx 56.5 -> 56 Inexact Rounded
+ddintx232 tointegralx 57.5 -> 57 Inexact Rounded
+ddintx233 tointegralx -55.5 -> -55 Inexact Rounded
+ddintx234 tointegralx -56.5 -> -56 Inexact Rounded
+ddintx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+ddintx240 tointegralx 55.3 -> 56 Inexact Rounded
+ddintx241 tointegralx 56.3 -> 57 Inexact Rounded
+ddintx242 tointegralx 57.3 -> 58 Inexact Rounded
+ddintx243 tointegralx -55.3 -> -56 Inexact Rounded
+ddintx244 tointegralx -56.3 -> -57 Inexact Rounded
+ddintx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+ddintx250 tointegralx 55.7 -> 55 Inexact Rounded
+ddintx251 tointegralx 56.7 -> 56 Inexact Rounded
+ddintx252 tointegralx 57.7 -> 57 Inexact Rounded
+ddintx253 tointegralx -55.7 -> -55 Inexact Rounded
+ddintx254 tointegralx -56.7 -> -56 Inexact Rounded
+ddintx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+ddintx260 tointegralx 55.3 -> 56 Inexact Rounded
+ddintx261 tointegralx 56.3 -> 57 Inexact Rounded
+ddintx262 tointegralx 57.3 -> 58 Inexact Rounded
+ddintx263 tointegralx -55.3 -> -55 Inexact Rounded
+ddintx264 tointegralx -56.3 -> -56 Inexact Rounded
+ddintx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+ddintx270 tointegralx 55.7 -> 55 Inexact Rounded
+ddintx271 tointegralx 56.7 -> 56 Inexact Rounded
+ddintx272 tointegralx 57.7 -> 57 Inexact Rounded
+ddintx273 tointegralx -55.7 -> -56 Inexact Rounded
+ddintx274 tointegralx -56.7 -> -57 Inexact Rounded
+ddintx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+ddintx300 tointegralx -2147483646 -> -2147483646
+ddintx301 tointegralx -2147483647 -> -2147483647
+ddintx302 tointegralx -2147483648 -> -2147483648
+ddintx303 tointegralx -2147483649 -> -2147483649
+ddintx304 tointegralx 2147483646 -> 2147483646
+ddintx305 tointegralx 2147483647 -> 2147483647
+ddintx306 tointegralx 2147483648 -> 2147483648
+ddintx307 tointegralx 2147483649 -> 2147483649
+ddintx308 tointegralx 4294967294 -> 4294967294
+ddintx309 tointegralx 4294967295 -> 4294967295
+ddintx310 tointegralx 4294967296 -> 4294967296
+ddintx311 tointegralx 4294967297 -> 4294967297
+
diff --git a/Lib/test/decimaltestdata/ddXor.decTest b/Lib/test/decimaltestdata/ddXor.decTest
index 131c7eb4b0b..3c55548e5ec 100644
--- a/Lib/test/decimaltestdata/ddXor.decTest
+++ b/Lib/test/decimaltestdata/ddXor.decTest
@@ -1,337 +1,337 @@
-------------------------------------------------------------------------
--- ddXor.decTest -- digitwise logical XOR for decDoubles --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-precision: 16
-maxExponent: 384
-minExponent: -383
-extended: 1
-clamp: 1
-rounding: half_even
-
--- Sanity check (truth table)
-ddxor001 xor 0 0 -> 0
-ddxor002 xor 0 1 -> 1
-ddxor003 xor 1 0 -> 1
-ddxor004 xor 1 1 -> 0
-ddxor005 xor 1100 1010 -> 110
--- and at msd and msd-1
-ddxor006 xor 0000000000000000 0000000000000000 -> 0
-ddxor007 xor 0000000000000000 1000000000000000 -> 1000000000000000
-ddxor008 xor 1000000000000000 0000000000000000 -> 1000000000000000
-ddxor009 xor 1000000000000000 1000000000000000 -> 0
-ddxor010 xor 0000000000000000 0000000000000000 -> 0
-ddxor011 xor 0000000000000000 0100000000000000 -> 100000000000000
-ddxor012 xor 0100000000000000 0000000000000000 -> 100000000000000
-ddxor013 xor 0100000000000000 0100000000000000 -> 0
-
--- Various lengths
--- 1234567890123456 1234567890123456 1234567890123456
-ddxor021 xor 1111111110000000 1111111110000000 -> 0
-ddxor022 xor 111111110000000 111111110000000 -> 0
-ddxor023 xor 11111110000000 11111110000000 -> 0
-ddxor024 xor 1111110000000 1111110000000 -> 0
-ddxor025 xor 111110000000 111110000000 -> 0
-ddxor026 xor 11110000000 11110000000 -> 0
-ddxor027 xor 1110000000 1110000000 -> 0
-ddxor028 xor 110000000 110000000 -> 0
-ddxor029 xor 10000000 10000000 -> 0
-ddxor030 xor 1000000 1000000 -> 0
-ddxor031 xor 100000 100000 -> 0
-ddxor032 xor 10000 10000 -> 0
-ddxor033 xor 1000 1000 -> 0
-ddxor034 xor 100 100 -> 0
-ddxor035 xor 10 10 -> 0
-ddxor036 xor 1 1 -> 0
-
-ddxor040 xor 111111111 111111111111 -> 111000000000
-ddxor041 xor 11111111 111111111111 -> 111100000000
-ddxor042 xor 11111111 111111111 -> 100000000
-ddxor043 xor 1111111 100000010 -> 101111101
-ddxor044 xor 111111 100000100 -> 100111011
-ddxor045 xor 11111 100001000 -> 100010111
-ddxor046 xor 1111 100010000 -> 100011111
-ddxor047 xor 111 100100000 -> 100100111
-ddxor048 xor 11 101000000 -> 101000011
-ddxor049 xor 1 110000000 -> 110000001
-
-ddxor050 xor 1111111111 1 -> 1111111110
-ddxor051 xor 111111111 1 -> 111111110
-ddxor052 xor 11111111 1 -> 11111110
-ddxor053 xor 1111111 1 -> 1111110
-ddxor054 xor 111111 1 -> 111110
-ddxor055 xor 11111 1 -> 11110
-ddxor056 xor 1111 1 -> 1110
-ddxor057 xor 111 1 -> 110
-ddxor058 xor 11 1 -> 10
-ddxor059 xor 1 1 -> 0
-
-ddxor060 xor 1111111111 0 -> 1111111111
-ddxor061 xor 111111111 0 -> 111111111
-ddxor062 xor 11111111 0 -> 11111111
-ddxor063 xor 1111111 0 -> 1111111
-ddxor064 xor 111111 0 -> 111111
-ddxor065 xor 11111 0 -> 11111
-ddxor066 xor 1111 0 -> 1111
-ddxor067 xor 111 0 -> 111
-ddxor068 xor 11 0 -> 11
-ddxor069 xor 1 0 -> 1
-
-ddxor070 xor 1 1111111111 -> 1111111110
-ddxor071 xor 1 111111111 -> 111111110
-ddxor072 xor 1 11111111 -> 11111110
-ddxor073 xor 1 1111111 -> 1111110
-ddxor074 xor 1 111111 -> 111110
-ddxor075 xor 1 11111 -> 11110
-ddxor076 xor 1 1111 -> 1110
-ddxor077 xor 1 111 -> 110
-ddxor078 xor 1 11 -> 10
-ddxor079 xor 1 1 -> 0
-
-ddxor080 xor 0 1111111111 -> 1111111111
-ddxor081 xor 0 111111111 -> 111111111
-ddxor082 xor 0 11111111 -> 11111111
-ddxor083 xor 0 1111111 -> 1111111
-ddxor084 xor 0 111111 -> 111111
-ddxor085 xor 0 11111 -> 11111
-ddxor086 xor 0 1111 -> 1111
-ddxor087 xor 0 111 -> 111
-ddxor088 xor 0 11 -> 11
-ddxor089 xor 0 1 -> 1
-
-ddxor090 xor 011111111 111101111 -> 100010000
-ddxor091 xor 101111111 111101111 -> 10010000
-ddxor092 xor 110111111 111101111 -> 1010000
-ddxor093 xor 111011111 111101111 -> 110000
-ddxor094 xor 111101111 111101111 -> 0
-ddxor095 xor 111110111 111101111 -> 11000
-ddxor096 xor 111111011 111101111 -> 10100
-ddxor097 xor 111111101 111101111 -> 10010
-ddxor098 xor 111111110 111101111 -> 10001
-
-ddxor100 xor 111101111 011111111 -> 100010000
-ddxor101 xor 111101111 101111111 -> 10010000
-ddxor102 xor 111101111 110111111 -> 1010000
-ddxor103 xor 111101111 111011111 -> 110000
-ddxor104 xor 111101111 111101111 -> 0
-ddxor105 xor 111101111 111110111 -> 11000
-ddxor106 xor 111101111 111111011 -> 10100
-ddxor107 xor 111101111 111111101 -> 10010
-ddxor108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-ddxor220 xor 111111112 111111111 -> NaN Invalid_operation
-ddxor221 xor 333333333 333333333 -> NaN Invalid_operation
-ddxor222 xor 555555555 555555555 -> NaN Invalid_operation
-ddxor223 xor 777777777 777777777 -> NaN Invalid_operation
-ddxor224 xor 999999999 999999999 -> NaN Invalid_operation
-ddxor225 xor 222222222 999999999 -> NaN Invalid_operation
-ddxor226 xor 444444444 999999999 -> NaN Invalid_operation
-ddxor227 xor 666666666 999999999 -> NaN Invalid_operation
-ddxor228 xor 888888888 999999999 -> NaN Invalid_operation
-ddxor229 xor 999999999 222222222 -> NaN Invalid_operation
-ddxor230 xor 999999999 444444444 -> NaN Invalid_operation
-ddxor231 xor 999999999 666666666 -> NaN Invalid_operation
-ddxor232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-ddxor240 xor 567468689 -934981942 -> NaN Invalid_operation
-ddxor241 xor 567367689 934981942 -> NaN Invalid_operation
-ddxor242 xor -631917772 -706014634 -> NaN Invalid_operation
-ddxor243 xor -756253257 138579234 -> NaN Invalid_operation
-ddxor244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-ddxor250 xor 2000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor251 xor 7000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor252 xor 8000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor253 xor 9000000000000000 1000000000000000 -> NaN Invalid_operation
-ddxor254 xor 2000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor255 xor 7000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor256 xor 8000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor257 xor 9000000000000000 0000000000000000 -> NaN Invalid_operation
-ddxor258 xor 1000000000000000 2000000000000000 -> NaN Invalid_operation
-ddxor259 xor 1000000000000000 7000000000000000 -> NaN Invalid_operation
-ddxor260 xor 1000000000000000 8000000000000000 -> NaN Invalid_operation
-ddxor261 xor 1000000000000000 9000000000000000 -> NaN Invalid_operation
-ddxor262 xor 0000000000000000 2000000000000000 -> NaN Invalid_operation
-ddxor263 xor 0000000000000000 7000000000000000 -> NaN Invalid_operation
-ddxor264 xor 0000000000000000 8000000000000000 -> NaN Invalid_operation
-ddxor265 xor 0000000000000000 9000000000000000 -> NaN Invalid_operation
--- test MSD-1
-ddxor270 xor 0200001000000000 1000100000000010 -> NaN Invalid_operation
-ddxor271 xor 0700000100000000 1000010000000100 -> NaN Invalid_operation
-ddxor272 xor 0800000010000000 1000001000001000 -> NaN Invalid_operation
-ddxor273 xor 0900000001000000 1000000100010000 -> NaN Invalid_operation
-ddxor274 xor 1000000000100000 0200000010100000 -> NaN Invalid_operation
-ddxor275 xor 1000000000010000 0700000001000000 -> NaN Invalid_operation
-ddxor276 xor 1000000000001000 0800000010100000 -> NaN Invalid_operation
-ddxor277 xor 1000000000000100 0900000000010000 -> NaN Invalid_operation
--- test LSD
-ddxor280 xor 0010000000000002 1000000100000001 -> NaN Invalid_operation
-ddxor281 xor 0001000000000007 1000001000000011 -> NaN Invalid_operation
-ddxor282 xor 0000100000000008 1000010000000001 -> NaN Invalid_operation
-ddxor283 xor 0000010000000009 1000100000000001 -> NaN Invalid_operation
-ddxor284 xor 1000001000000000 0001000000000002 -> NaN Invalid_operation
-ddxor285 xor 1000000100000000 0010000000000007 -> NaN Invalid_operation
-ddxor286 xor 1000000010000000 0100000000000008 -> NaN Invalid_operation
-ddxor287 xor 1000000001000000 1000000000000009 -> NaN Invalid_operation
--- test Middie
-ddxor288 xor 0010000020000000 1000001000000000 -> NaN Invalid_operation
-ddxor289 xor 0001000070000001 1000000100000000 -> NaN Invalid_operation
-ddxor290 xor 0000100080000010 1000000010000000 -> NaN Invalid_operation
-ddxor291 xor 0000010090000100 1000000001000000 -> NaN Invalid_operation
-ddxor292 xor 1000001000001000 0000000020100000 -> NaN Invalid_operation
-ddxor293 xor 1000000100010000 0000000070010000 -> NaN Invalid_operation
-ddxor294 xor 1000000010100000 0000000080001000 -> NaN Invalid_operation
-ddxor295 xor 1000000001000000 0000000090000100 -> NaN Invalid_operation
--- signs
-ddxor296 xor -1000000001000000 -0000010000000100 -> NaN Invalid_operation
-ddxor297 xor -1000000001000000 0000000010000100 -> NaN Invalid_operation
-ddxor298 xor 1000000001000000 -0000001000000100 -> NaN Invalid_operation
-ddxor299 xor 1000000001000000 0000000011000100 -> 1000000010000100
-
--- Nmax, Nmin, Ntiny-like
-ddxor331 xor 2 9.99999999E+299 -> NaN Invalid_operation
-ddxor332 xor 3 1E-299 -> NaN Invalid_operation
-ddxor333 xor 4 1.00000000E-299 -> NaN Invalid_operation
-ddxor334 xor 5 1E-200 -> NaN Invalid_operation
-ddxor335 xor 6 -1E-200 -> NaN Invalid_operation
-ddxor336 xor 7 -1.00000000E-299 -> NaN Invalid_operation
-ddxor337 xor 8 -1E-299 -> NaN Invalid_operation
-ddxor338 xor 9 -9.99999999E+299 -> NaN Invalid_operation
-ddxor341 xor 9.99999999E+299 -18 -> NaN Invalid_operation
-ddxor342 xor 1E-299 01 -> NaN Invalid_operation
-ddxor343 xor 1.00000000E-299 -18 -> NaN Invalid_operation
-ddxor344 xor 1E-208 18 -> NaN Invalid_operation
-ddxor345 xor -1E-207 -10 -> NaN Invalid_operation
-ddxor346 xor -1.00000000E-299 18 -> NaN Invalid_operation
-ddxor347 xor -1E-299 10 -> NaN Invalid_operation
-ddxor348 xor -9.99999999E+299 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-ddxor361 xor 1.0 1 -> NaN Invalid_operation
-ddxor362 xor 1E+1 1 -> NaN Invalid_operation
-ddxor363 xor 0.0 1 -> NaN Invalid_operation
-ddxor364 xor 0E+1 1 -> NaN Invalid_operation
-ddxor365 xor 9.9 1 -> NaN Invalid_operation
-ddxor366 xor 9E+1 1 -> NaN Invalid_operation
-ddxor371 xor 0 1.0 -> NaN Invalid_operation
-ddxor372 xor 0 1E+1 -> NaN Invalid_operation
-ddxor373 xor 0 0.0 -> NaN Invalid_operation
-ddxor374 xor 0 0E+1 -> NaN Invalid_operation
-ddxor375 xor 0 9.9 -> NaN Invalid_operation
-ddxor376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-ddxor780 xor -Inf -Inf -> NaN Invalid_operation
-ddxor781 xor -Inf -1000 -> NaN Invalid_operation
-ddxor782 xor -Inf -1 -> NaN Invalid_operation
-ddxor783 xor -Inf -0 -> NaN Invalid_operation
-ddxor784 xor -Inf 0 -> NaN Invalid_operation
-ddxor785 xor -Inf 1 -> NaN Invalid_operation
-ddxor786 xor -Inf 1000 -> NaN Invalid_operation
-ddxor787 xor -1000 -Inf -> NaN Invalid_operation
-ddxor788 xor -Inf -Inf -> NaN Invalid_operation
-ddxor789 xor -1 -Inf -> NaN Invalid_operation
-ddxor790 xor -0 -Inf -> NaN Invalid_operation
-ddxor791 xor 0 -Inf -> NaN Invalid_operation
-ddxor792 xor 1 -Inf -> NaN Invalid_operation
-ddxor793 xor 1000 -Inf -> NaN Invalid_operation
-ddxor794 xor Inf -Inf -> NaN Invalid_operation
-
-ddxor800 xor Inf -Inf -> NaN Invalid_operation
-ddxor801 xor Inf -1000 -> NaN Invalid_operation
-ddxor802 xor Inf -1 -> NaN Invalid_operation
-ddxor803 xor Inf -0 -> NaN Invalid_operation
-ddxor804 xor Inf 0 -> NaN Invalid_operation
-ddxor805 xor Inf 1 -> NaN Invalid_operation
-ddxor806 xor Inf 1000 -> NaN Invalid_operation
-ddxor807 xor Inf Inf -> NaN Invalid_operation
-ddxor808 xor -1000 Inf -> NaN Invalid_operation
-ddxor809 xor -Inf Inf -> NaN Invalid_operation
-ddxor810 xor -1 Inf -> NaN Invalid_operation
-ddxor811 xor -0 Inf -> NaN Invalid_operation
-ddxor812 xor 0 Inf -> NaN Invalid_operation
-ddxor813 xor 1 Inf -> NaN Invalid_operation
-ddxor814 xor 1000 Inf -> NaN Invalid_operation
-ddxor815 xor Inf Inf -> NaN Invalid_operation
-
-ddxor821 xor NaN -Inf -> NaN Invalid_operation
-ddxor822 xor NaN -1000 -> NaN Invalid_operation
-ddxor823 xor NaN -1 -> NaN Invalid_operation
-ddxor824 xor NaN -0 -> NaN Invalid_operation
-ddxor825 xor NaN 0 -> NaN Invalid_operation
-ddxor826 xor NaN 1 -> NaN Invalid_operation
-ddxor827 xor NaN 1000 -> NaN Invalid_operation
-ddxor828 xor NaN Inf -> NaN Invalid_operation
-ddxor829 xor NaN NaN -> NaN Invalid_operation
-ddxor830 xor -Inf NaN -> NaN Invalid_operation
-ddxor831 xor -1000 NaN -> NaN Invalid_operation
-ddxor832 xor -1 NaN -> NaN Invalid_operation
-ddxor833 xor -0 NaN -> NaN Invalid_operation
-ddxor834 xor 0 NaN -> NaN Invalid_operation
-ddxor835 xor 1 NaN -> NaN Invalid_operation
-ddxor836 xor 1000 NaN -> NaN Invalid_operation
-ddxor837 xor Inf NaN -> NaN Invalid_operation
-
-ddxor841 xor sNaN -Inf -> NaN Invalid_operation
-ddxor842 xor sNaN -1000 -> NaN Invalid_operation
-ddxor843 xor sNaN -1 -> NaN Invalid_operation
-ddxor844 xor sNaN -0 -> NaN Invalid_operation
-ddxor845 xor sNaN 0 -> NaN Invalid_operation
-ddxor846 xor sNaN 1 -> NaN Invalid_operation
-ddxor847 xor sNaN 1000 -> NaN Invalid_operation
-ddxor848 xor sNaN NaN -> NaN Invalid_operation
-ddxor849 xor sNaN sNaN -> NaN Invalid_operation
-ddxor850 xor NaN sNaN -> NaN Invalid_operation
-ddxor851 xor -Inf sNaN -> NaN Invalid_operation
-ddxor852 xor -1000 sNaN -> NaN Invalid_operation
-ddxor853 xor -1 sNaN -> NaN Invalid_operation
-ddxor854 xor -0 sNaN -> NaN Invalid_operation
-ddxor855 xor 0 sNaN -> NaN Invalid_operation
-ddxor856 xor 1 sNaN -> NaN Invalid_operation
-ddxor857 xor 1000 sNaN -> NaN Invalid_operation
-ddxor858 xor Inf sNaN -> NaN Invalid_operation
-ddxor859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-ddxor861 xor NaN1 -Inf -> NaN Invalid_operation
-ddxor862 xor +NaN2 -1000 -> NaN Invalid_operation
-ddxor863 xor NaN3 1000 -> NaN Invalid_operation
-ddxor864 xor NaN4 Inf -> NaN Invalid_operation
-ddxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
-ddxor866 xor -Inf NaN7 -> NaN Invalid_operation
-ddxor867 xor -1000 NaN8 -> NaN Invalid_operation
-ddxor868 xor 1000 NaN9 -> NaN Invalid_operation
-ddxor869 xor Inf +NaN10 -> NaN Invalid_operation
-ddxor871 xor sNaN11 -Inf -> NaN Invalid_operation
-ddxor872 xor sNaN12 -1000 -> NaN Invalid_operation
-ddxor873 xor sNaN13 1000 -> NaN Invalid_operation
-ddxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
-ddxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-ddxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
-ddxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
-ddxor878 xor -1000 sNaN21 -> NaN Invalid_operation
-ddxor879 xor 1000 sNaN22 -> NaN Invalid_operation
-ddxor880 xor Inf sNaN23 -> NaN Invalid_operation
-ddxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-ddxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
-ddxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-ddxor884 xor 1000 -NaN30 -> NaN Invalid_operation
-ddxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- ddXor.decTest -- digitwise logical XOR for decDoubles --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+precision: 16
+maxExponent: 384
+minExponent: -383
+extended: 1
+clamp: 1
+rounding: half_even
+
+-- Sanity check (truth table)
+ddxor001 xor 0 0 -> 0
+ddxor002 xor 0 1 -> 1
+ddxor003 xor 1 0 -> 1
+ddxor004 xor 1 1 -> 0
+ddxor005 xor 1100 1010 -> 110
+-- and at msd and msd-1
+ddxor006 xor 0000000000000000 0000000000000000 -> 0
+ddxor007 xor 0000000000000000 1000000000000000 -> 1000000000000000
+ddxor008 xor 1000000000000000 0000000000000000 -> 1000000000000000
+ddxor009 xor 1000000000000000 1000000000000000 -> 0
+ddxor010 xor 0000000000000000 0000000000000000 -> 0
+ddxor011 xor 0000000000000000 0100000000000000 -> 100000000000000
+ddxor012 xor 0100000000000000 0000000000000000 -> 100000000000000
+ddxor013 xor 0100000000000000 0100000000000000 -> 0
+
+-- Various lengths
+-- 1234567890123456 1234567890123456 1234567890123456
+ddxor021 xor 1111111110000000 1111111110000000 -> 0
+ddxor022 xor 111111110000000 111111110000000 -> 0
+ddxor023 xor 11111110000000 11111110000000 -> 0
+ddxor024 xor 1111110000000 1111110000000 -> 0
+ddxor025 xor 111110000000 111110000000 -> 0
+ddxor026 xor 11110000000 11110000000 -> 0
+ddxor027 xor 1110000000 1110000000 -> 0
+ddxor028 xor 110000000 110000000 -> 0
+ddxor029 xor 10000000 10000000 -> 0
+ddxor030 xor 1000000 1000000 -> 0
+ddxor031 xor 100000 100000 -> 0
+ddxor032 xor 10000 10000 -> 0
+ddxor033 xor 1000 1000 -> 0
+ddxor034 xor 100 100 -> 0
+ddxor035 xor 10 10 -> 0
+ddxor036 xor 1 1 -> 0
+
+ddxor040 xor 111111111 111111111111 -> 111000000000
+ddxor041 xor 11111111 111111111111 -> 111100000000
+ddxor042 xor 11111111 111111111 -> 100000000
+ddxor043 xor 1111111 100000010 -> 101111101
+ddxor044 xor 111111 100000100 -> 100111011
+ddxor045 xor 11111 100001000 -> 100010111
+ddxor046 xor 1111 100010000 -> 100011111
+ddxor047 xor 111 100100000 -> 100100111
+ddxor048 xor 11 101000000 -> 101000011
+ddxor049 xor 1 110000000 -> 110000001
+
+ddxor050 xor 1111111111 1 -> 1111111110
+ddxor051 xor 111111111 1 -> 111111110
+ddxor052 xor 11111111 1 -> 11111110
+ddxor053 xor 1111111 1 -> 1111110
+ddxor054 xor 111111 1 -> 111110
+ddxor055 xor 11111 1 -> 11110
+ddxor056 xor 1111 1 -> 1110
+ddxor057 xor 111 1 -> 110
+ddxor058 xor 11 1 -> 10
+ddxor059 xor 1 1 -> 0
+
+ddxor060 xor 1111111111 0 -> 1111111111
+ddxor061 xor 111111111 0 -> 111111111
+ddxor062 xor 11111111 0 -> 11111111
+ddxor063 xor 1111111 0 -> 1111111
+ddxor064 xor 111111 0 -> 111111
+ddxor065 xor 11111 0 -> 11111
+ddxor066 xor 1111 0 -> 1111
+ddxor067 xor 111 0 -> 111
+ddxor068 xor 11 0 -> 11
+ddxor069 xor 1 0 -> 1
+
+ddxor070 xor 1 1111111111 -> 1111111110
+ddxor071 xor 1 111111111 -> 111111110
+ddxor072 xor 1 11111111 -> 11111110
+ddxor073 xor 1 1111111 -> 1111110
+ddxor074 xor 1 111111 -> 111110
+ddxor075 xor 1 11111 -> 11110
+ddxor076 xor 1 1111 -> 1110
+ddxor077 xor 1 111 -> 110
+ddxor078 xor 1 11 -> 10
+ddxor079 xor 1 1 -> 0
+
+ddxor080 xor 0 1111111111 -> 1111111111
+ddxor081 xor 0 111111111 -> 111111111
+ddxor082 xor 0 11111111 -> 11111111
+ddxor083 xor 0 1111111 -> 1111111
+ddxor084 xor 0 111111 -> 111111
+ddxor085 xor 0 11111 -> 11111
+ddxor086 xor 0 1111 -> 1111
+ddxor087 xor 0 111 -> 111
+ddxor088 xor 0 11 -> 11
+ddxor089 xor 0 1 -> 1
+
+ddxor090 xor 011111111 111101111 -> 100010000
+ddxor091 xor 101111111 111101111 -> 10010000
+ddxor092 xor 110111111 111101111 -> 1010000
+ddxor093 xor 111011111 111101111 -> 110000
+ddxor094 xor 111101111 111101111 -> 0
+ddxor095 xor 111110111 111101111 -> 11000
+ddxor096 xor 111111011 111101111 -> 10100
+ddxor097 xor 111111101 111101111 -> 10010
+ddxor098 xor 111111110 111101111 -> 10001
+
+ddxor100 xor 111101111 011111111 -> 100010000
+ddxor101 xor 111101111 101111111 -> 10010000
+ddxor102 xor 111101111 110111111 -> 1010000
+ddxor103 xor 111101111 111011111 -> 110000
+ddxor104 xor 111101111 111101111 -> 0
+ddxor105 xor 111101111 111110111 -> 11000
+ddxor106 xor 111101111 111111011 -> 10100
+ddxor107 xor 111101111 111111101 -> 10010
+ddxor108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+ddxor220 xor 111111112 111111111 -> NaN Invalid_operation
+ddxor221 xor 333333333 333333333 -> NaN Invalid_operation
+ddxor222 xor 555555555 555555555 -> NaN Invalid_operation
+ddxor223 xor 777777777 777777777 -> NaN Invalid_operation
+ddxor224 xor 999999999 999999999 -> NaN Invalid_operation
+ddxor225 xor 222222222 999999999 -> NaN Invalid_operation
+ddxor226 xor 444444444 999999999 -> NaN Invalid_operation
+ddxor227 xor 666666666 999999999 -> NaN Invalid_operation
+ddxor228 xor 888888888 999999999 -> NaN Invalid_operation
+ddxor229 xor 999999999 222222222 -> NaN Invalid_operation
+ddxor230 xor 999999999 444444444 -> NaN Invalid_operation
+ddxor231 xor 999999999 666666666 -> NaN Invalid_operation
+ddxor232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+ddxor240 xor 567468689 -934981942 -> NaN Invalid_operation
+ddxor241 xor 567367689 934981942 -> NaN Invalid_operation
+ddxor242 xor -631917772 -706014634 -> NaN Invalid_operation
+ddxor243 xor -756253257 138579234 -> NaN Invalid_operation
+ddxor244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+ddxor250 xor 2000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor251 xor 7000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor252 xor 8000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor253 xor 9000000000000000 1000000000000000 -> NaN Invalid_operation
+ddxor254 xor 2000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor255 xor 7000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor256 xor 8000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor257 xor 9000000000000000 0000000000000000 -> NaN Invalid_operation
+ddxor258 xor 1000000000000000 2000000000000000 -> NaN Invalid_operation
+ddxor259 xor 1000000000000000 7000000000000000 -> NaN Invalid_operation
+ddxor260 xor 1000000000000000 8000000000000000 -> NaN Invalid_operation
+ddxor261 xor 1000000000000000 9000000000000000 -> NaN Invalid_operation
+ddxor262 xor 0000000000000000 2000000000000000 -> NaN Invalid_operation
+ddxor263 xor 0000000000000000 7000000000000000 -> NaN Invalid_operation
+ddxor264 xor 0000000000000000 8000000000000000 -> NaN Invalid_operation
+ddxor265 xor 0000000000000000 9000000000000000 -> NaN Invalid_operation
+-- test MSD-1
+ddxor270 xor 0200001000000000 1000100000000010 -> NaN Invalid_operation
+ddxor271 xor 0700000100000000 1000010000000100 -> NaN Invalid_operation
+ddxor272 xor 0800000010000000 1000001000001000 -> NaN Invalid_operation
+ddxor273 xor 0900000001000000 1000000100010000 -> NaN Invalid_operation
+ddxor274 xor 1000000000100000 0200000010100000 -> NaN Invalid_operation
+ddxor275 xor 1000000000010000 0700000001000000 -> NaN Invalid_operation
+ddxor276 xor 1000000000001000 0800000010100000 -> NaN Invalid_operation
+ddxor277 xor 1000000000000100 0900000000010000 -> NaN Invalid_operation
+-- test LSD
+ddxor280 xor 0010000000000002 1000000100000001 -> NaN Invalid_operation
+ddxor281 xor 0001000000000007 1000001000000011 -> NaN Invalid_operation
+ddxor282 xor 0000100000000008 1000010000000001 -> NaN Invalid_operation
+ddxor283 xor 0000010000000009 1000100000000001 -> NaN Invalid_operation
+ddxor284 xor 1000001000000000 0001000000000002 -> NaN Invalid_operation
+ddxor285 xor 1000000100000000 0010000000000007 -> NaN Invalid_operation
+ddxor286 xor 1000000010000000 0100000000000008 -> NaN Invalid_operation
+ddxor287 xor 1000000001000000 1000000000000009 -> NaN Invalid_operation
+-- test Middie
+ddxor288 xor 0010000020000000 1000001000000000 -> NaN Invalid_operation
+ddxor289 xor 0001000070000001 1000000100000000 -> NaN Invalid_operation
+ddxor290 xor 0000100080000010 1000000010000000 -> NaN Invalid_operation
+ddxor291 xor 0000010090000100 1000000001000000 -> NaN Invalid_operation
+ddxor292 xor 1000001000001000 0000000020100000 -> NaN Invalid_operation
+ddxor293 xor 1000000100010000 0000000070010000 -> NaN Invalid_operation
+ddxor294 xor 1000000010100000 0000000080001000 -> NaN Invalid_operation
+ddxor295 xor 1000000001000000 0000000090000100 -> NaN Invalid_operation
+-- signs
+ddxor296 xor -1000000001000000 -0000010000000100 -> NaN Invalid_operation
+ddxor297 xor -1000000001000000 0000000010000100 -> NaN Invalid_operation
+ddxor298 xor 1000000001000000 -0000001000000100 -> NaN Invalid_operation
+ddxor299 xor 1000000001000000 0000000011000100 -> 1000000010000100
+
+-- Nmax, Nmin, Ntiny-like
+ddxor331 xor 2 9.99999999E+299 -> NaN Invalid_operation
+ddxor332 xor 3 1E-299 -> NaN Invalid_operation
+ddxor333 xor 4 1.00000000E-299 -> NaN Invalid_operation
+ddxor334 xor 5 1E-200 -> NaN Invalid_operation
+ddxor335 xor 6 -1E-200 -> NaN Invalid_operation
+ddxor336 xor 7 -1.00000000E-299 -> NaN Invalid_operation
+ddxor337 xor 8 -1E-299 -> NaN Invalid_operation
+ddxor338 xor 9 -9.99999999E+299 -> NaN Invalid_operation
+ddxor341 xor 9.99999999E+299 -18 -> NaN Invalid_operation
+ddxor342 xor 1E-299 01 -> NaN Invalid_operation
+ddxor343 xor 1.00000000E-299 -18 -> NaN Invalid_operation
+ddxor344 xor 1E-208 18 -> NaN Invalid_operation
+ddxor345 xor -1E-207 -10 -> NaN Invalid_operation
+ddxor346 xor -1.00000000E-299 18 -> NaN Invalid_operation
+ddxor347 xor -1E-299 10 -> NaN Invalid_operation
+ddxor348 xor -9.99999999E+299 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+ddxor361 xor 1.0 1 -> NaN Invalid_operation
+ddxor362 xor 1E+1 1 -> NaN Invalid_operation
+ddxor363 xor 0.0 1 -> NaN Invalid_operation
+ddxor364 xor 0E+1 1 -> NaN Invalid_operation
+ddxor365 xor 9.9 1 -> NaN Invalid_operation
+ddxor366 xor 9E+1 1 -> NaN Invalid_operation
+ddxor371 xor 0 1.0 -> NaN Invalid_operation
+ddxor372 xor 0 1E+1 -> NaN Invalid_operation
+ddxor373 xor 0 0.0 -> NaN Invalid_operation
+ddxor374 xor 0 0E+1 -> NaN Invalid_operation
+ddxor375 xor 0 9.9 -> NaN Invalid_operation
+ddxor376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+ddxor780 xor -Inf -Inf -> NaN Invalid_operation
+ddxor781 xor -Inf -1000 -> NaN Invalid_operation
+ddxor782 xor -Inf -1 -> NaN Invalid_operation
+ddxor783 xor -Inf -0 -> NaN Invalid_operation
+ddxor784 xor -Inf 0 -> NaN Invalid_operation
+ddxor785 xor -Inf 1 -> NaN Invalid_operation
+ddxor786 xor -Inf 1000 -> NaN Invalid_operation
+ddxor787 xor -1000 -Inf -> NaN Invalid_operation
+ddxor788 xor -Inf -Inf -> NaN Invalid_operation
+ddxor789 xor -1 -Inf -> NaN Invalid_operation
+ddxor790 xor -0 -Inf -> NaN Invalid_operation
+ddxor791 xor 0 -Inf -> NaN Invalid_operation
+ddxor792 xor 1 -Inf -> NaN Invalid_operation
+ddxor793 xor 1000 -Inf -> NaN Invalid_operation
+ddxor794 xor Inf -Inf -> NaN Invalid_operation
+
+ddxor800 xor Inf -Inf -> NaN Invalid_operation
+ddxor801 xor Inf -1000 -> NaN Invalid_operation
+ddxor802 xor Inf -1 -> NaN Invalid_operation
+ddxor803 xor Inf -0 -> NaN Invalid_operation
+ddxor804 xor Inf 0 -> NaN Invalid_operation
+ddxor805 xor Inf 1 -> NaN Invalid_operation
+ddxor806 xor Inf 1000 -> NaN Invalid_operation
+ddxor807 xor Inf Inf -> NaN Invalid_operation
+ddxor808 xor -1000 Inf -> NaN Invalid_operation
+ddxor809 xor -Inf Inf -> NaN Invalid_operation
+ddxor810 xor -1 Inf -> NaN Invalid_operation
+ddxor811 xor -0 Inf -> NaN Invalid_operation
+ddxor812 xor 0 Inf -> NaN Invalid_operation
+ddxor813 xor 1 Inf -> NaN Invalid_operation
+ddxor814 xor 1000 Inf -> NaN Invalid_operation
+ddxor815 xor Inf Inf -> NaN Invalid_operation
+
+ddxor821 xor NaN -Inf -> NaN Invalid_operation
+ddxor822 xor NaN -1000 -> NaN Invalid_operation
+ddxor823 xor NaN -1 -> NaN Invalid_operation
+ddxor824 xor NaN -0 -> NaN Invalid_operation
+ddxor825 xor NaN 0 -> NaN Invalid_operation
+ddxor826 xor NaN 1 -> NaN Invalid_operation
+ddxor827 xor NaN 1000 -> NaN Invalid_operation
+ddxor828 xor NaN Inf -> NaN Invalid_operation
+ddxor829 xor NaN NaN -> NaN Invalid_operation
+ddxor830 xor -Inf NaN -> NaN Invalid_operation
+ddxor831 xor -1000 NaN -> NaN Invalid_operation
+ddxor832 xor -1 NaN -> NaN Invalid_operation
+ddxor833 xor -0 NaN -> NaN Invalid_operation
+ddxor834 xor 0 NaN -> NaN Invalid_operation
+ddxor835 xor 1 NaN -> NaN Invalid_operation
+ddxor836 xor 1000 NaN -> NaN Invalid_operation
+ddxor837 xor Inf NaN -> NaN Invalid_operation
+
+ddxor841 xor sNaN -Inf -> NaN Invalid_operation
+ddxor842 xor sNaN -1000 -> NaN Invalid_operation
+ddxor843 xor sNaN -1 -> NaN Invalid_operation
+ddxor844 xor sNaN -0 -> NaN Invalid_operation
+ddxor845 xor sNaN 0 -> NaN Invalid_operation
+ddxor846 xor sNaN 1 -> NaN Invalid_operation
+ddxor847 xor sNaN 1000 -> NaN Invalid_operation
+ddxor848 xor sNaN NaN -> NaN Invalid_operation
+ddxor849 xor sNaN sNaN -> NaN Invalid_operation
+ddxor850 xor NaN sNaN -> NaN Invalid_operation
+ddxor851 xor -Inf sNaN -> NaN Invalid_operation
+ddxor852 xor -1000 sNaN -> NaN Invalid_operation
+ddxor853 xor -1 sNaN -> NaN Invalid_operation
+ddxor854 xor -0 sNaN -> NaN Invalid_operation
+ddxor855 xor 0 sNaN -> NaN Invalid_operation
+ddxor856 xor 1 sNaN -> NaN Invalid_operation
+ddxor857 xor 1000 sNaN -> NaN Invalid_operation
+ddxor858 xor Inf sNaN -> NaN Invalid_operation
+ddxor859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+ddxor861 xor NaN1 -Inf -> NaN Invalid_operation
+ddxor862 xor +NaN2 -1000 -> NaN Invalid_operation
+ddxor863 xor NaN3 1000 -> NaN Invalid_operation
+ddxor864 xor NaN4 Inf -> NaN Invalid_operation
+ddxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
+ddxor866 xor -Inf NaN7 -> NaN Invalid_operation
+ddxor867 xor -1000 NaN8 -> NaN Invalid_operation
+ddxor868 xor 1000 NaN9 -> NaN Invalid_operation
+ddxor869 xor Inf +NaN10 -> NaN Invalid_operation
+ddxor871 xor sNaN11 -Inf -> NaN Invalid_operation
+ddxor872 xor sNaN12 -1000 -> NaN Invalid_operation
+ddxor873 xor sNaN13 1000 -> NaN Invalid_operation
+ddxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
+ddxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+ddxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
+ddxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
+ddxor878 xor -1000 sNaN21 -> NaN Invalid_operation
+ddxor879 xor 1000 sNaN22 -> NaN Invalid_operation
+ddxor880 xor Inf sNaN23 -> NaN Invalid_operation
+ddxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+ddxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
+ddxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+ddxor884 xor 1000 -NaN30 -> NaN Invalid_operation
+ddxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqAbs.decTest b/Lib/test/decimaltestdata/dqAbs.decTest
index baaa063bbc8..f9119a9e79c 100644
--- a/Lib/test/decimaltestdata/dqAbs.decTest
+++ b/Lib/test/decimaltestdata/dqAbs.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- dqAbs.decTest -- decQuad absolute value, heeding sNaN --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqabs001 abs '1' -> '1'
-dqabs002 abs '-1' -> '1'
-dqabs003 abs '1.00' -> '1.00'
-dqabs004 abs '-1.00' -> '1.00'
-dqabs005 abs '0' -> '0'
-dqabs006 abs '0.00' -> '0.00'
-dqabs007 abs '00.0' -> '0.0'
-dqabs008 abs '00.00' -> '0.00'
-dqabs009 abs '00' -> '0'
-
-dqabs010 abs '-2' -> '2'
-dqabs011 abs '2' -> '2'
-dqabs012 abs '-2.00' -> '2.00'
-dqabs013 abs '2.00' -> '2.00'
-dqabs014 abs '-0' -> '0'
-dqabs015 abs '-0.00' -> '0.00'
-dqabs016 abs '-00.0' -> '0.0'
-dqabs017 abs '-00.00' -> '0.00'
-dqabs018 abs '-00' -> '0'
-
-dqabs020 abs '-2000000' -> '2000000'
-dqabs021 abs '2000000' -> '2000000'
-
-dqabs030 abs '+0.1' -> '0.1'
-dqabs031 abs '-0.1' -> '0.1'
-dqabs032 abs '+0.01' -> '0.01'
-dqabs033 abs '-0.01' -> '0.01'
-dqabs034 abs '+0.001' -> '0.001'
-dqabs035 abs '-0.001' -> '0.001'
-dqabs036 abs '+0.000001' -> '0.000001'
-dqabs037 abs '-0.000001' -> '0.000001'
-dqabs038 abs '+0.000000000001' -> '1E-12'
-dqabs039 abs '-0.000000000001' -> '1E-12'
-
--- examples from decArith
-dqabs040 abs '2.1' -> '2.1'
-dqabs041 abs '-100' -> '100'
-dqabs042 abs '101.5' -> '101.5'
-dqabs043 abs '-101.5' -> '101.5'
-
--- more fixed, potential LHS swaps/overlays if done by subtract 0
-dqabs060 abs '-56267E-10' -> '0.0000056267'
-dqabs061 abs '-56267E-5' -> '0.56267'
-dqabs062 abs '-56267E-2' -> '562.67'
-dqabs063 abs '-56267E-1' -> '5626.7'
-dqabs065 abs '-56267E-0' -> '56267'
-
--- subnormals and underflow
-
--- long operand tests
-dqabs321 abs 1234567890123456 -> 1234567890123456
-dqabs322 abs 12345678000 -> 12345678000
-dqabs323 abs 1234567800 -> 1234567800
-dqabs324 abs 1234567890 -> 1234567890
-dqabs325 abs 1234567891 -> 1234567891
-dqabs326 abs 12345678901 -> 12345678901
-dqabs327 abs 1234567896 -> 1234567896
-
--- zeros
-dqabs111 abs 0 -> 0
-dqabs112 abs -0 -> 0
-dqabs113 abs 0E+6 -> 0E+6
-dqabs114 abs -0E+6 -> 0E+6
-dqabs115 abs 0.0000 -> 0.0000
-dqabs116 abs -0.0000 -> 0.0000
-dqabs117 abs 0E-141 -> 0E-141
-dqabs118 abs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqabs121 abs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqabs122 abs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqabs123 abs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqabs124 abs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqabs131 abs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqabs132 abs 1E-6143 -> 1E-6143
-dqabs133 abs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqabs134 abs 1E-6176 -> 1E-6176 Subnormal
-
-dqabs135 abs -1E-6176 -> 1E-6176 Subnormal
-dqabs136 abs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqabs137 abs -1E-6143 -> 1E-6143
-dqabs138 abs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-
--- specials
-dqabs520 abs 'Inf' -> 'Infinity'
-dqabs521 abs '-Inf' -> 'Infinity'
-dqabs522 abs NaN -> NaN
-dqabs523 abs sNaN -> NaN Invalid_operation
-dqabs524 abs NaN22 -> NaN22
-dqabs525 abs sNaN33 -> NaN33 Invalid_operation
-dqabs526 abs -NaN22 -> -NaN22
-dqabs527 abs -sNaN33 -> -NaN33 Invalid_operation
-
--- Null tests
-dqabs900 abs # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqAbs.decTest -- decQuad absolute value, heeding sNaN --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqabs001 abs '1' -> '1'
+dqabs002 abs '-1' -> '1'
+dqabs003 abs '1.00' -> '1.00'
+dqabs004 abs '-1.00' -> '1.00'
+dqabs005 abs '0' -> '0'
+dqabs006 abs '0.00' -> '0.00'
+dqabs007 abs '00.0' -> '0.0'
+dqabs008 abs '00.00' -> '0.00'
+dqabs009 abs '00' -> '0'
+
+dqabs010 abs '-2' -> '2'
+dqabs011 abs '2' -> '2'
+dqabs012 abs '-2.00' -> '2.00'
+dqabs013 abs '2.00' -> '2.00'
+dqabs014 abs '-0' -> '0'
+dqabs015 abs '-0.00' -> '0.00'
+dqabs016 abs '-00.0' -> '0.0'
+dqabs017 abs '-00.00' -> '0.00'
+dqabs018 abs '-00' -> '0'
+
+dqabs020 abs '-2000000' -> '2000000'
+dqabs021 abs '2000000' -> '2000000'
+
+dqabs030 abs '+0.1' -> '0.1'
+dqabs031 abs '-0.1' -> '0.1'
+dqabs032 abs '+0.01' -> '0.01'
+dqabs033 abs '-0.01' -> '0.01'
+dqabs034 abs '+0.001' -> '0.001'
+dqabs035 abs '-0.001' -> '0.001'
+dqabs036 abs '+0.000001' -> '0.000001'
+dqabs037 abs '-0.000001' -> '0.000001'
+dqabs038 abs '+0.000000000001' -> '1E-12'
+dqabs039 abs '-0.000000000001' -> '1E-12'
+
+-- examples from decArith
+dqabs040 abs '2.1' -> '2.1'
+dqabs041 abs '-100' -> '100'
+dqabs042 abs '101.5' -> '101.5'
+dqabs043 abs '-101.5' -> '101.5'
+
+-- more fixed, potential LHS swaps/overlays if done by subtract 0
+dqabs060 abs '-56267E-10' -> '0.0000056267'
+dqabs061 abs '-56267E-5' -> '0.56267'
+dqabs062 abs '-56267E-2' -> '562.67'
+dqabs063 abs '-56267E-1' -> '5626.7'
+dqabs065 abs '-56267E-0' -> '56267'
+
+-- subnormals and underflow
+
+-- long operand tests
+dqabs321 abs 1234567890123456 -> 1234567890123456
+dqabs322 abs 12345678000 -> 12345678000
+dqabs323 abs 1234567800 -> 1234567800
+dqabs324 abs 1234567890 -> 1234567890
+dqabs325 abs 1234567891 -> 1234567891
+dqabs326 abs 12345678901 -> 12345678901
+dqabs327 abs 1234567896 -> 1234567896
+
+-- zeros
+dqabs111 abs 0 -> 0
+dqabs112 abs -0 -> 0
+dqabs113 abs 0E+6 -> 0E+6
+dqabs114 abs -0E+6 -> 0E+6
+dqabs115 abs 0.0000 -> 0.0000
+dqabs116 abs -0.0000 -> 0.0000
+dqabs117 abs 0E-141 -> 0E-141
+dqabs118 abs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqabs121 abs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqabs122 abs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqabs123 abs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqabs124 abs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqabs131 abs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqabs132 abs 1E-6143 -> 1E-6143
+dqabs133 abs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqabs134 abs 1E-6176 -> 1E-6176 Subnormal
+
+dqabs135 abs -1E-6176 -> 1E-6176 Subnormal
+dqabs136 abs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqabs137 abs -1E-6143 -> 1E-6143
+dqabs138 abs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+
+-- specials
+dqabs520 abs 'Inf' -> 'Infinity'
+dqabs521 abs '-Inf' -> 'Infinity'
+dqabs522 abs NaN -> NaN
+dqabs523 abs sNaN -> NaN Invalid_operation
+dqabs524 abs NaN22 -> NaN22
+dqabs525 abs sNaN33 -> NaN33 Invalid_operation
+dqabs526 abs -NaN22 -> -NaN22
+dqabs527 abs -sNaN33 -> -NaN33 Invalid_operation
+
+-- Null tests
+dqabs900 abs # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqAdd.decTest b/Lib/test/decimaltestdata/dqAdd.decTest
index b1df77abc67..b3ad892bc1d 100644
--- a/Lib/test/decimaltestdata/dqAdd.decTest
+++ b/Lib/test/decimaltestdata/dqAdd.decTest
@@ -1,1215 +1,1215 @@
-------------------------------------------------------------------------
--- dqAdd.decTest -- decQuad addition --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqadd001 add 1 1 -> 2
-dqadd002 add 2 3 -> 5
-dqadd003 add '5.75' '3.3' -> 9.05
-dqadd004 add '5' '-3' -> 2
-dqadd005 add '-5' '-3' -> -8
-dqadd006 add '-7' '2.5' -> -4.5
-dqadd007 add '0.7' '0.3' -> 1.0
-dqadd008 add '1.25' '1.25' -> 2.50
-dqadd009 add '1.23456789' '1.00000000' -> '2.23456789'
-dqadd010 add '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-dqadd011 add '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqadd012 add '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
-dqadd013 add '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqadd014 add '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd015 add '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd016 add '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd017 add '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd018 add '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd019 add '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd020 add '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
-
-dqadd021 add 0 1 -> 1
-dqadd022 add 1 1 -> 2
-dqadd023 add 2 1 -> 3
-dqadd024 add 3 1 -> 4
-dqadd025 add 4 1 -> 5
-dqadd026 add 5 1 -> 6
-dqadd027 add 6 1 -> 7
-dqadd028 add 7 1 -> 8
-dqadd029 add 8 1 -> 9
-dqadd030 add 9 1 -> 10
-
--- some carrying effects
-dqadd031 add '0.9998' '0.0000' -> '0.9998'
-dqadd032 add '0.9998' '0.0001' -> '0.9999'
-dqadd033 add '0.9998' '0.0002' -> '1.0000'
-dqadd034 add '0.9998' '0.0003' -> '1.0001'
-
-dqadd035 add '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd036 add '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd037 add '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd038 add '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd039 add '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- symmetry:
-dqadd040 add '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd041 add '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd042 add '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd044 add '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd045 add '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- same, without rounding
-dqadd046 add '10000e+9' '7' -> '10000000000007'
-dqadd047 add '10000e+9' '70' -> '10000000000070'
-dqadd048 add '10000e+9' '700' -> '10000000000700'
-dqadd049 add '10000e+9' '7000' -> '10000000007000'
-dqadd050 add '10000e+9' '70000' -> '10000000070000'
-dqadd051 add '10000e+9' '700000' -> '10000000700000'
-dqadd052 add '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-dqadd053 add '12' '7.00' -> '19.00'
-dqadd054 add '1.3' '-1.07' -> '0.23'
-dqadd055 add '1.3' '-1.30' -> '0.00'
-dqadd056 add '1.3' '-2.07' -> '-0.77'
-dqadd057 add '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-dqadd061 add 1 '0.0001' -> '1.0001'
-dqadd062 add 1 '0.00001' -> '1.00001'
-dqadd063 add 1 '0.000001' -> '1.000001'
-dqadd064 add 1 '0.0000001' -> '1.0000001'
-dqadd065 add 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-dqadd070 add 1 0 -> 1
-dqadd071 add 1 0. -> 1
-dqadd072 add 1 .0 -> 1.0
-dqadd073 add 1 0.0 -> 1.0
-dqadd074 add 1 0.00 -> 1.00
-dqadd075 add 0 1 -> 1
-dqadd076 add 0. 1 -> 1
-dqadd077 add .0 1 -> 1.0
-dqadd078 add 0.0 1 -> 1.0
-dqadd079 add 0.00 1 -> 1.00
-
--- some carries
-dqadd080 add 999999998 1 -> 999999999
-dqadd081 add 999999999 1 -> 1000000000
-dqadd082 add 99999999 1 -> 100000000
-dqadd083 add 9999999 1 -> 10000000
-dqadd084 add 999999 1 -> 1000000
-dqadd085 add 99999 1 -> 100000
-dqadd086 add 9999 1 -> 10000
-dqadd087 add 999 1 -> 1000
-dqadd088 add 99 1 -> 100
-dqadd089 add 9 1 -> 10
-
-
--- more LHS swaps
-dqadd090 add '-56267E-10' 0 -> '-0.0000056267'
-dqadd091 add '-56267E-6' 0 -> '-0.056267'
-dqadd092 add '-56267E-5' 0 -> '-0.56267'
-dqadd093 add '-56267E-4' 0 -> '-5.6267'
-dqadd094 add '-56267E-3' 0 -> '-56.267'
-dqadd095 add '-56267E-2' 0 -> '-562.67'
-dqadd096 add '-56267E-1' 0 -> '-5626.7'
-dqadd097 add '-56267E-0' 0 -> '-56267'
-dqadd098 add '-5E-10' 0 -> '-5E-10'
-dqadd099 add '-5E-7' 0 -> '-5E-7'
-dqadd100 add '-5E-6' 0 -> '-0.000005'
-dqadd101 add '-5E-5' 0 -> '-0.00005'
-dqadd102 add '-5E-4' 0 -> '-0.0005'
-dqadd103 add '-5E-1' 0 -> '-0.5'
-dqadd104 add '-5E0' 0 -> '-5'
-dqadd105 add '-5E1' 0 -> '-50'
-dqadd106 add '-5E5' 0 -> '-500000'
-dqadd107 add '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqadd108 add '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd109 add '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd110 add '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd111 add '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps
-dqadd113 add 0 '-56267E-10' -> '-0.0000056267'
-dqadd114 add 0 '-56267E-6' -> '-0.056267'
-dqadd116 add 0 '-56267E-5' -> '-0.56267'
-dqadd117 add 0 '-56267E-4' -> '-5.6267'
-dqadd119 add 0 '-56267E-3' -> '-56.267'
-dqadd120 add 0 '-56267E-2' -> '-562.67'
-dqadd121 add 0 '-56267E-1' -> '-5626.7'
-dqadd122 add 0 '-56267E-0' -> '-56267'
-dqadd123 add 0 '-5E-10' -> '-5E-10'
-dqadd124 add 0 '-5E-7' -> '-5E-7'
-dqadd125 add 0 '-5E-6' -> '-0.000005'
-dqadd126 add 0 '-5E-5' -> '-0.00005'
-dqadd127 add 0 '-5E-4' -> '-0.0005'
-dqadd128 add 0 '-5E-1' -> '-0.5'
-dqadd129 add 0 '-5E0' -> '-5'
-dqadd130 add 0 '-5E1' -> '-50'
-dqadd131 add 0 '-5E5' -> '-500000'
-dqadd132 add 0 '-5E33' -> '-5000000000000000000000000000000000'
-dqadd133 add 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd134 add 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd135 add 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd136 add 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- related
-dqadd137 add 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
-dqadd138 add -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
-dqadd139 add '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
-dqadd140 add '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
-dqadd141 add 1E+29 0.0000 -> '100000000000000000000000000000.0000'
-dqadd142 add 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
-dqadd143 add 0.000 1E+30 -> '1000000000000000000000000000000.000'
-dqadd144 add 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-dqadd146 add '00.0' 0 -> '0.0'
-dqadd147 add '0.00' 0 -> '0.00'
-dqadd148 add 0 '0.00' -> '0.00'
-dqadd149 add 0 '00.0' -> '0.0'
-dqadd150 add '00.0' '0.00' -> '0.00'
-dqadd151 add '0.00' '00.0' -> '0.00'
-dqadd152 add '3' '.3' -> '3.3'
-dqadd153 add '3.' '.3' -> '3.3'
-dqadd154 add '3.0' '.3' -> '3.3'
-dqadd155 add '3.00' '.3' -> '3.30'
-dqadd156 add '3' '3' -> '6'
-dqadd157 add '3' '+3' -> '6'
-dqadd158 add '3' '-3' -> '0'
-dqadd159 add '0.3' '-0.3' -> '0.0'
-dqadd160 add '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-dqadd161 add '1E+12' '-1' -> '999999999999'
-dqadd162 add '1E+12' '1.11' -> '1000000000001.11'
-dqadd163 add '1.11' '1E+12' -> '1000000000001.11'
-dqadd164 add '-1' '1E+12' -> '999999999999'
-dqadd165 add '7E+12' '-1' -> '6999999999999'
-dqadd166 add '7E+12' '1.11' -> '7000000000001.11'
-dqadd167 add '1.11' '7E+12' -> '7000000000001.11'
-dqadd168 add '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
-dqadd170 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd171 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd172 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd173 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
-dqadd174 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd175 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd176 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd177 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
-dqadd178 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd179 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd180 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd181 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd182 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd183 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqadd200 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd201 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd202 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd203 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd204 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd205 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd206 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd207 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd208 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd209 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd210 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd211 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd212 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd213 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd214 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd215 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd216 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd217 add '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd218 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd219 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
-rounding: half_even
-dqadd220 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd221 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd222 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd223 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd224 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd225 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd226 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd227 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd228 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd229 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd230 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd231 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd232 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd233 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd234 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd235 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd236 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd237 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd238 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd239 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
--- critical few with even bottom digit...
-dqadd240 add '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd241 add '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd242 add '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-
-rounding: down
-dqadd250 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd251 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd252 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd253 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd254 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd255 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd256 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd257 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd258 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd259 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd260 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd261 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd262 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd263 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd264 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd265 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd266 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd267 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd268 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd269 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-dqadd301 add -1 1 -> 0
-dqadd302 add 0 1 -> 1
-dqadd303 add 1 1 -> 2
-dqadd304 add 12 1 -> 13
-dqadd305 add 98 1 -> 99
-dqadd306 add 99 1 -> 100
-dqadd307 add 100 1 -> 101
-dqadd308 add 101 1 -> 102
-dqadd309 add -1 -1 -> -2
-dqadd310 add 0 -1 -> -1
-dqadd311 add 1 -1 -> 0
-dqadd312 add 12 -1 -> 11
-dqadd313 add 98 -1 -> 97
-dqadd314 add 99 -1 -> 98
-dqadd315 add 100 -1 -> 99
-dqadd316 add 101 -1 -> 100
-
-dqadd321 add -0.01 0.01 -> 0.00
-dqadd322 add 0.00 0.01 -> 0.01
-dqadd323 add 0.01 0.01 -> 0.02
-dqadd324 add 0.12 0.01 -> 0.13
-dqadd325 add 0.98 0.01 -> 0.99
-dqadd326 add 0.99 0.01 -> 1.00
-dqadd327 add 1.00 0.01 -> 1.01
-dqadd328 add 1.01 0.01 -> 1.02
-dqadd329 add -0.01 -0.01 -> -0.02
-dqadd330 add 0.00 -0.01 -> -0.01
-dqadd331 add 0.01 -0.01 -> 0.00
-dqadd332 add 0.12 -0.01 -> 0.11
-dqadd333 add 0.98 -0.01 -> 0.97
-dqadd334 add 0.99 -0.01 -> 0.98
-dqadd335 add 1.00 -0.01 -> 0.99
-dqadd336 add 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-dqadd340 add 1E+3 0 -> 1000
-dqadd341 add 1E+33 0 -> 1000000000000000000000000000000000
-dqadd342 add 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
-dqadd343 add 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
--- which simply follow from these cases ...
-dqadd344 add 1E+3 1 -> 1001
-dqadd345 add 1E+33 1 -> 1000000000000000000000000000000001
-dqadd346 add 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd347 add 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-dqadd348 add 1E+3 7 -> 1007
-dqadd349 add 1E+33 7 -> 1000000000000000000000000000000007
-dqadd350 add 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
-dqadd351 add 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-dqadd360 add 0E+50 10000E+1 -> 1.0000E+5
-dqadd361 add 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
-dqadd362 add 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
-dqadd363 add 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
-dqadd364 add 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--- 1 234567890123456789012345678901234
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-dqadd370 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd371 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_up
-dqadd372 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd373 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_even
-dqadd374 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd375 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-
--- ulp replacement tests
-dqadd400 add 1 77e-32 -> 1.00000000000000000000000000000077
-dqadd401 add 1 77e-33 -> 1.000000000000000000000000000000077
-dqadd402 add 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd403 add 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd404 add 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd405 add 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd406 add 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd410 add 10 77e-32 -> 10.00000000000000000000000000000077
-dqadd411 add 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd412 add 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd413 add 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd414 add 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd415 add 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd416 add 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd420 add 77e-32 1 -> 1.00000000000000000000000000000077
-dqadd421 add 77e-33 1 -> 1.000000000000000000000000000000077
-dqadd422 add 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd423 add 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd424 add 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd425 add 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd426 add 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd430 add 77e-32 10 -> 10.00000000000000000000000000000077
-dqadd431 add 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd432 add 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd433 add 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd434 add 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd435 add 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd436 add 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- fastpath boundaries
--- 1234567890123456789012345678901234
-dqadd501 add '4444444444444444444444444444444444' '5555555555555555555555555555555555' -> '9999999999999999999999999999999999'
-dqadd502 add '4444444444444444444444444444444444' '4555555555555555555555555555555555' -> '8999999999999999999999999999999999'
-dqadd503 add '4444444444444444444444444444444444' '3555555555555555555055555555555555' -> '7999999999999999999499999999999999'
-dqadd504 add '4444444444444444444444444444444444' '3955555555555555555555555555555555' -> '8399999999999999999999999999999999'
-dqadd505 add '4444444444444444444444444444444444' '4955555555555555555555555555555555' -> '9399999999999999999999999999999999'
-dqadd506 add '4444444444444444444444444444444444' '5955555555555555555555555555555555' -> 1.040000000000000000000000000000000E+34 Inexact Rounded
-dqadd511 add '344444444444444444444444444444444' '555555555555555555555555555555555' -> '899999999999999999999999999999999'
-dqadd512 add '34444444444444444444444444444444' '55555555555555555555555555555555' -> '89999999999999999999999999999999'
-dqadd513 add '3444444444444444444444444444444' '5555555555555555555555555555555' -> '8999999999999999999999999999999'
-dqadd514 add '344444444444444444444444444444' '555555555555555555555555555555' -> '899999999999999999999999999999'
-dqadd515 add '34444444444444444444444444444' '55555555555555555555555555555' -> '89999999999999999999999999999'
-dqadd516 add '3444444444444444444444444444' '5555555555555555555555555555' -> '8999999999999999999999999999'
-dqadd517 add '344444444444444444444444444' '555555555555555555555555555' -> '899999999999999999999999999'
-dqadd518 add '34444444444444444444444444' '55555555555555555555555555' -> '89999999999999999999999999'
-dqadd519 add '3444444444444444444444444' '5555555555555555555555555' -> '8999999999999999999999999'
-dqadd520 add '344444444444444444444444' '555555555555555555555555' -> '899999999999999999999999'
-dqadd521 add '34444444444444444444444' '55555555555555555555555' -> '89999999999999999999999'
-dqadd522 add '3444444444444444444444' '5555555555555555555555' -> '8999999999999999999999'
-dqadd523 add '4444444444444444444444' '3333333333333333333333' -> '7777777777777777777777'
-dqadd524 add '344444444444444444444' '555555555555555555555' -> '899999999999999999999'
-dqadd525 add '34444444444444444444' '55555555555555555555' -> '89999999999999999999'
-dqadd526 add '3444444444444444444' '5555555555555555555' -> '8999999999999999999'
-dqadd527 add '344444444444444444' '555555555555555555' -> '899999999999999999'
-dqadd528 add '34444444444444444' '55555555555555555' -> '89999999999999999'
-dqadd529 add '3444444444444444' '5555555555555555' -> '8999999999999999'
-dqadd530 add '344444444444444' '555555555555555' -> '899999999999999'
-dqadd531 add '34444444444444' '55555555555555' -> '89999999999999'
-dqadd532 add '3444444444444' '5555555555555' -> '8999999999999'
-dqadd533 add '344444444444' '555555555555' -> '899999999999'
-dqadd534 add '34444444444' '55555555555' -> '89999999999'
-dqadd535 add '3444444444' '5555555555' -> '8999999999'
-dqadd536 add '344444444' '555555555' -> '899999999'
-dqadd537 add '34444444' '55555555' -> '89999999'
-dqadd538 add '3444444' '5555555' -> '8999999'
-dqadd539 add '344444' '555555' -> '899999'
-dqadd540 add '34444' '55555' -> '89999'
-dqadd541 add '3444' '5555' -> '8999'
-dqadd542 add '344' '555' -> '899'
-dqadd543 add '34' '55' -> '89'
-dqadd544 add '3' '5' -> '8'
-
-dqadd545 add '3000004000000000000000000000000000' '3000000000000040000000000000000000' -> '6000004000000040000000000000000000'
-dqadd546 add '3000000400000000000000000000000000' '4000000000000400000000000000000000' -> '7000000400000400000000000000000000'
-dqadd547 add '3000000040000000000000000000000000' '5000000000004000000000000000000000' -> '8000000040004000000000000000000000'
-dqadd548 add '4000000004000000000000000000000000' '3000000000040000000000000000000000' -> '7000000004040000000000000000000000'
-dqadd549 add '4000000000400000000000000000000000' '4000000000400000000000000000000000' -> '8000000000800000000000000000000000'
-dqadd550 add '4000000000040000000000000000000000' '5000000004000000000000000000000000' -> '9000000004040000000000000000000000'
-dqadd551 add '5000000000004000000000000000000000' '3000000040000000000000000000000000' -> '8000000040004000000000000000000000'
-dqadd552 add '5000000000000400000000000000000000' '4000000400000000000000000000000000' -> '9000000400000400000000000000000000'
-dqadd553 add '5000000000000040000000000000000000' '5000004000000000000000000000000000' -> 1.000000400000004000000000000000000E+34 Rounded
--- check propagation
-dqadd554 add '8999999999999999999999999999999999' '0000000000000000000000000000000001' -> 9000000000000000000000000000000000
-dqadd555 add '0000000000000000000000000000000001' '8999999999999999999999999999999999' -> 9000000000000000000000000000000000
-dqadd556 add '4444444444444444444444444444444444' '4555555555555555555555555555555556' -> 9000000000000000000000000000000000
-dqadd557 add '4555555555555555555555555555555556' '4444444444444444444444444444444444' -> 9000000000000000000000000000000000
-
--- negative ulps
-dqadd6440 add 1 -77e-32 -> 0.99999999999999999999999999999923
-dqadd6441 add 1 -77e-33 -> 0.999999999999999999999999999999923
-dqadd6442 add 1 -77e-34 -> 0.9999999999999999999999999999999923
-dqadd6443 add 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6444 add 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6445 add 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd6446 add 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6450 add 10 -77e-32 -> 9.99999999999999999999999999999923
-dqadd6451 add 10 -77e-33 -> 9.999999999999999999999999999999923
-dqadd6452 add 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd6453 add 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd6454 add 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6455 add 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6456 add 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd6460 add -77e-32 1 -> 0.99999999999999999999999999999923
-dqadd6461 add -77e-33 1 -> 0.999999999999999999999999999999923
-dqadd6462 add -77e-34 1 -> 0.9999999999999999999999999999999923
-dqadd6463 add -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6464 add -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6465 add -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd6466 add -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6470 add -77e-32 10 -> 9.99999999999999999999999999999923
-dqadd6471 add -77e-33 10 -> 9.999999999999999999999999999999923
-dqadd6472 add -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd6473 add -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd6474 add -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6475 add -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd6476 add -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd6480 add -1 77e-32 -> -0.99999999999999999999999999999923
-dqadd6481 add -1 77e-33 -> -0.999999999999999999999999999999923
-dqadd6482 add -1 77e-34 -> -0.9999999999999999999999999999999923
-dqadd6483 add -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6484 add -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6485 add -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd6486 add -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6490 add -10 77e-32 -> -9.99999999999999999999999999999923
-dqadd6491 add -10 77e-33 -> -9.999999999999999999999999999999923
-dqadd6492 add -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd6493 add -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd6494 add -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6495 add -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6496 add -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd6500 add 77e-32 -1 -> -0.99999999999999999999999999999923
-dqadd6501 add 77e-33 -1 -> -0.999999999999999999999999999999923
-dqadd6502 add 77e-34 -1 -> -0.9999999999999999999999999999999923
-dqadd6503 add 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd6504 add 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd6505 add 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd6506 add 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd6510 add 77e-32 -10 -> -9.99999999999999999999999999999923
-dqadd6511 add 77e-33 -10 -> -9.999999999999999999999999999999923
-dqadd6512 add 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd6513 add 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd6514 add 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6515 add 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd6516 add 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-dqadd6540 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd6541 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6542 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6543 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6544 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6545 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6546 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6547 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6548 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6549 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6550 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6551 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6552 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6553 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6554 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6555 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6556 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd6557 add '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6558 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6559 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
-rounding: half_even
-dqadd6560 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd6561 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6562 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6563 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6564 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6565 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6566 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6567 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd6568 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6569 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6570 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6571 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6572 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6573 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6574 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6575 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6576 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd6577 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6578 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd6579 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-dqadd7540 add '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd7541 add '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd7542 add '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-
-rounding: down
-dqadd7550 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd7551 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7552 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7553 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7554 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7555 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7556 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7557 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7558 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7559 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7560 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7561 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7562 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7563 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7564 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7565 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd7566 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd7567 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd7568 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd7569 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-dqadd7701 add 5.00 1.00E-3 -> 5.00100
-dqadd7702 add 00.00 0.000 -> 0.000
-dqadd7703 add 00.00 0E-3 -> 0.000
-dqadd7704 add 0E-3 00.00 -> 0.000
-
-dqadd7710 add 0E+3 00.00 -> 0.00
-dqadd7711 add 0E+3 00.0 -> 0.0
-dqadd7712 add 0E+3 00. -> 0
-dqadd7713 add 0E+3 00.E+1 -> 0E+1
-dqadd7714 add 0E+3 00.E+2 -> 0E+2
-dqadd7715 add 0E+3 00.E+3 -> 0E+3
-dqadd7716 add 0E+3 00.E+4 -> 0E+3
-dqadd7717 add 0E+3 00.E+5 -> 0E+3
-dqadd7718 add 0E+3 -00.0 -> 0.0
-dqadd7719 add 0E+3 -00. -> 0
-dqadd7731 add 0E+3 -00.E+1 -> 0E+1
-
-dqadd7720 add 00.00 0E+3 -> 0.00
-dqadd7721 add 00.0 0E+3 -> 0.0
-dqadd7722 add 00. 0E+3 -> 0
-dqadd7723 add 00.E+1 0E+3 -> 0E+1
-dqadd7724 add 00.E+2 0E+3 -> 0E+2
-dqadd7725 add 00.E+3 0E+3 -> 0E+3
-dqadd7726 add 00.E+4 0E+3 -> 0E+3
-dqadd7727 add 00.E+5 0E+3 -> 0E+3
-dqadd7728 add -00.00 0E+3 -> 0.00
-dqadd7729 add -00.0 0E+3 -> 0.0
-dqadd7730 add -00. 0E+3 -> 0
-
-dqadd7732 add 0 0 -> 0
-dqadd7733 add 0 -0 -> 0
-dqadd7734 add -0 0 -> 0
-dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case
-
-dqadd7736 add 1 -1 -> 0
-dqadd7737 add -1 -1 -> -2
-dqadd7738 add 1 1 -> 2
-dqadd7739 add -1 1 -> 0
-
-dqadd7741 add 0 -1 -> -1
-dqadd7742 add -0 -1 -> -1
-dqadd7743 add 0 1 -> 1
-dqadd7744 add -0 1 -> 1
-dqadd7745 add -1 0 -> -1
-dqadd7746 add -1 -0 -> -1
-dqadd7747 add 1 0 -> 1
-dqadd7748 add 1 -0 -> 1
-
-dqadd7751 add 0.0 -1 -> -1.0
-dqadd7752 add -0.0 -1 -> -1.0
-dqadd7753 add 0.0 1 -> 1.0
-dqadd7754 add -0.0 1 -> 1.0
-dqadd7755 add -1.0 0 -> -1.0
-dqadd7756 add -1.0 -0 -> -1.0
-dqadd7757 add 1.0 0 -> 1.0
-dqadd7758 add 1.0 -0 -> 1.0
-
-dqadd7761 add 0 -1.0 -> -1.0
-dqadd7762 add -0 -1.0 -> -1.0
-dqadd7763 add 0 1.0 -> 1.0
-dqadd7764 add -0 1.0 -> 1.0
-dqadd7765 add -1 0.0 -> -1.0
-dqadd7766 add -1 -0.0 -> -1.0
-dqadd7767 add 1 0.0 -> 1.0
-dqadd7768 add 1 -0.0 -> 1.0
-
-dqadd7771 add 0.0 -1.0 -> -1.0
-dqadd7772 add -0.0 -1.0 -> -1.0
-dqadd7773 add 0.0 1.0 -> 1.0
-dqadd7774 add -0.0 1.0 -> 1.0
-dqadd7775 add -1.0 0.0 -> -1.0
-dqadd7776 add -1.0 -0.0 -> -1.0
-dqadd7777 add 1.0 0.0 -> 1.0
-dqadd7778 add 1.0 -0.0 -> 1.0
-
--- Specials
-dqadd7780 add -Inf -Inf -> -Infinity
-dqadd7781 add -Inf -1000 -> -Infinity
-dqadd7782 add -Inf -1 -> -Infinity
-dqadd7783 add -Inf -0 -> -Infinity
-dqadd7784 add -Inf 0 -> -Infinity
-dqadd7785 add -Inf 1 -> -Infinity
-dqadd7786 add -Inf 1000 -> -Infinity
-dqadd7787 add -1000 -Inf -> -Infinity
-dqadd7788 add -Inf -Inf -> -Infinity
-dqadd7789 add -1 -Inf -> -Infinity
-dqadd7790 add -0 -Inf -> -Infinity
-dqadd7791 add 0 -Inf -> -Infinity
-dqadd7792 add 1 -Inf -> -Infinity
-dqadd7793 add 1000 -Inf -> -Infinity
-dqadd7794 add Inf -Inf -> NaN Invalid_operation
-
-dqadd7800 add Inf -Inf -> NaN Invalid_operation
-dqadd7801 add Inf -1000 -> Infinity
-dqadd7802 add Inf -1 -> Infinity
-dqadd7803 add Inf -0 -> Infinity
-dqadd7804 add Inf 0 -> Infinity
-dqadd7805 add Inf 1 -> Infinity
-dqadd7806 add Inf 1000 -> Infinity
-dqadd7807 add Inf Inf -> Infinity
-dqadd7808 add -1000 Inf -> Infinity
-dqadd7809 add -Inf Inf -> NaN Invalid_operation
-dqadd7810 add -1 Inf -> Infinity
-dqadd7811 add -0 Inf -> Infinity
-dqadd7812 add 0 Inf -> Infinity
-dqadd7813 add 1 Inf -> Infinity
-dqadd7814 add 1000 Inf -> Infinity
-dqadd7815 add Inf Inf -> Infinity
-
-dqadd7821 add NaN -Inf -> NaN
-dqadd7822 add NaN -1000 -> NaN
-dqadd7823 add NaN -1 -> NaN
-dqadd7824 add NaN -0 -> NaN
-dqadd7825 add NaN 0 -> NaN
-dqadd7826 add NaN 1 -> NaN
-dqadd7827 add NaN 1000 -> NaN
-dqadd7828 add NaN Inf -> NaN
-dqadd7829 add NaN NaN -> NaN
-dqadd7830 add -Inf NaN -> NaN
-dqadd7831 add -1000 NaN -> NaN
-dqadd7832 add -1 NaN -> NaN
-dqadd7833 add -0 NaN -> NaN
-dqadd7834 add 0 NaN -> NaN
-dqadd7835 add 1 NaN -> NaN
-dqadd7836 add 1000 NaN -> NaN
-dqadd7837 add Inf NaN -> NaN
-
-dqadd7841 add sNaN -Inf -> NaN Invalid_operation
-dqadd7842 add sNaN -1000 -> NaN Invalid_operation
-dqadd7843 add sNaN -1 -> NaN Invalid_operation
-dqadd7844 add sNaN -0 -> NaN Invalid_operation
-dqadd7845 add sNaN 0 -> NaN Invalid_operation
-dqadd7846 add sNaN 1 -> NaN Invalid_operation
-dqadd7847 add sNaN 1000 -> NaN Invalid_operation
-dqadd7848 add sNaN NaN -> NaN Invalid_operation
-dqadd7849 add sNaN sNaN -> NaN Invalid_operation
-dqadd7850 add NaN sNaN -> NaN Invalid_operation
-dqadd7851 add -Inf sNaN -> NaN Invalid_operation
-dqadd7852 add -1000 sNaN -> NaN Invalid_operation
-dqadd7853 add -1 sNaN -> NaN Invalid_operation
-dqadd7854 add -0 sNaN -> NaN Invalid_operation
-dqadd7855 add 0 sNaN -> NaN Invalid_operation
-dqadd7856 add 1 sNaN -> NaN Invalid_operation
-dqadd7857 add 1000 sNaN -> NaN Invalid_operation
-dqadd7858 add Inf sNaN -> NaN Invalid_operation
-dqadd7859 add NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqadd7861 add NaN1 -Inf -> NaN1
-dqadd7862 add +NaN2 -1000 -> NaN2
-dqadd7863 add NaN3 1000 -> NaN3
-dqadd7864 add NaN4 Inf -> NaN4
-dqadd7865 add NaN5 +NaN6 -> NaN5
-dqadd7866 add -Inf NaN7 -> NaN7
-dqadd7867 add -1000 NaN8 -> NaN8
-dqadd7868 add 1000 NaN9 -> NaN9
-dqadd7869 add Inf +NaN10 -> NaN10
-dqadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
-dqadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
-dqadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
-dqadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
-dqadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
-dqadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
-dqadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
-dqadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
-dqadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
-dqadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqadd7882 add -NaN26 NaN28 -> -NaN26
-dqadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqadd7884 add 1000 -NaN30 -> -NaN30
-dqadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-dqadd7575 add 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
-dqadd7576 add -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-dqadd7972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqadd7973 add 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7974 add 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7975 add 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
-dqadd7976 add 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7977 add 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7978 add 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7979 add 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7980 add 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
-dqadd7981 add 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7982 add 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7983 add 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7984 add 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-
-dqadd7985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqadd7986 add -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7987 add -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7988 add -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
-dqadd7989 add -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7990 add -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7991 add -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7992 add -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7993 add -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd7994 add -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7995 add -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7996 add -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd7997 add -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-dqadd71100 add 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
-dqadd71101 add 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
-dqadd71103 add +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
-dqadd71104 add 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
-dqadd71105 add 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
-dqadd71106 add 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd71107 add 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd71108 add 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd71109 add 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-dqadd71110 add -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
-dqadd71111 add -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
-dqadd71113 add -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
-dqadd71114 add -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
-dqadd71115 add -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
-dqadd71116 add -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd71117 add -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd71118 add -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd71119 add -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-dqadd71300 add 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71310 add 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71311 add 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71312 add 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71313 add 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71314 add 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71315 add 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71316 add 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71317 add 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71318 add 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71319 add 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71320 add 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71321 add 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71322 add 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71323 add 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71324 add 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71325 add 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71326 add 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71327 add 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71328 add 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71329 add 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71330 add 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71331 add 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71332 add 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71333 add 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71334 add 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71335 add 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71336 add 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71337 add 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71338 add 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71339 add 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
-dqadd71340 add 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
-dqadd71341 add 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
-
-dqadd71349 add 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71350 add 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71351 add 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71352 add 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71353 add 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71354 add 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71355 add 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71356 add 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71357 add 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71358 add 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71359 add 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71360 add 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71361 add 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71362 add 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71363 add 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71364 add 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd71365 add 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71367 add 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71368 add 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71369 add 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71370 add 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71371 add 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71372 add 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71373 add 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71374 add 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71375 add 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71376 add 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71377 add 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71378 add 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71379 add 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71380 add 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71381 add 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71382 add 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71383 add 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71384 add 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71385 add 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71386 add 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71387 add 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71388 add 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71389 add 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71390 add 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71391 add 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71392 add 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71393 add 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71394 add 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71395 add 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd71396 add 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-dqadd71420 add 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
-dqadd71421 add 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
-dqadd71422 add 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
-dqadd71423 add 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
-dqadd71424 add 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
-dqadd71425 add 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
-dqadd71426 add 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
-dqadd71427 add 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
-dqadd71428 add 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
-dqadd71429 add 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
-dqadd71430 add 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
-dqadd71431 add 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
-dqadd71432 add 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
-dqadd71433 add 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
-dqadd71434 add 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
-dqadd71435 add 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
-dqadd71436 add 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
-dqadd71437 add 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
-dqadd71438 add 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
-dqadd71439 add 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
-dqadd71440 add 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
-dqadd71441 add 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
-dqadd71442 add 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
-dqadd71443 add 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
-dqadd71444 add 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
-dqadd71445 add 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
-dqadd71446 add 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
-dqadd71447 add 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
-dqadd71448 add 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
-dqadd71449 add 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
-dqadd71450 add 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
-dqadd71451 add 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
-dqadd71452 add 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
-dqadd71453 add 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
-dqadd71454 add 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
-dqadd71455 add 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
-dqadd71456 add 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
-
--- same, reversed 0
-dqadd71460 add 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
-dqadd71461 add 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
-dqadd71462 add 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
-dqadd71463 add 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
-dqadd71464 add 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
-dqadd71465 add 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
-dqadd71466 add 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
-dqadd71467 add 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
-dqadd71468 add 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
-dqadd71469 add 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
-dqadd71470 add 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
-dqadd71471 add 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
-dqadd71472 add 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
-dqadd71473 add 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
-dqadd71474 add 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
-dqadd71475 add 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
-dqadd71476 add 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
-dqadd71477 add 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
-dqadd71478 add 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
-dqadd71479 add 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
-dqadd71480 add 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
-dqadd71481 add 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
-dqadd71482 add 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
-dqadd71483 add 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
-dqadd71484 add 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
-dqadd71485 add 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
-dqadd71486 add 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
-dqadd71487 add 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
-dqadd71488 add 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
-dqadd71489 add 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
-dqadd71490 add 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
-dqadd71491 add 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
-dqadd71492 add 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
-dqadd71493 add 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
-dqadd71494 add 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
-dqadd71495 add 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
-dqadd71496 add 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
-
--- same, Es on the 0
-dqadd71500 add 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
-dqadd71501 add 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
-dqadd71502 add 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
-dqadd71503 add 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
-dqadd71504 add 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
-dqadd71505 add 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
-dqadd71506 add 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
-dqadd71507 add 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
-dqadd71508 add 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
-dqadd71509 add 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
-dqadd71510 add 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
-dqadd71511 add 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
-dqadd71512 add 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
-dqadd71513 add 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
-dqadd71514 add 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
-dqadd71515 add 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
-dqadd71516 add 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
-dqadd71517 add 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
-dqadd71518 add 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
-dqadd71519 add 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
-dqadd71520 add 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
-dqadd71521 add 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
-dqadd71522 add 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
-dqadd71523 add 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
-dqadd71524 add 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
-dqadd71525 add 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
-dqadd71526 add 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
-dqadd71527 add 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
-dqadd71528 add 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
-dqadd71529 add 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
-dqadd71530 add 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
-dqadd71531 add 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
-dqadd71532 add 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
-dqadd71533 add 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
--- next four flag Rounded because the 0 extends the result
-dqadd71534 add 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
-dqadd71535 add 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
-dqadd71536 add 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
-dqadd71537 add 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-dqadd71600 add 0 0E-19 -> 0E-19
-dqadd71601 add -0 0E-19 -> 0E-19
-dqadd71602 add 0 -0E-19 -> 0E-19
-dqadd71603 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71611 add -11 11 -> 0
-dqadd71612 add 11 -11 -> 0
-
-rounding: half_down
--- exact zeros from zeros
-dqadd71620 add 0 0E-19 -> 0E-19
-dqadd71621 add -0 0E-19 -> 0E-19
-dqadd71622 add 0 -0E-19 -> 0E-19
-dqadd71623 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71631 add -11 11 -> 0
-dqadd71632 add 11 -11 -> 0
-
-rounding: half_even
--- exact zeros from zeros
-dqadd71640 add 0 0E-19 -> 0E-19
-dqadd71641 add -0 0E-19 -> 0E-19
-dqadd71642 add 0 -0E-19 -> 0E-19
-dqadd71643 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71651 add -11 11 -> 0
-dqadd71652 add 11 -11 -> 0
-
-rounding: up
--- exact zeros from zeros
-dqadd71660 add 0 0E-19 -> 0E-19
-dqadd71661 add -0 0E-19 -> 0E-19
-dqadd71662 add 0 -0E-19 -> 0E-19
-dqadd71663 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71671 add -11 11 -> 0
-dqadd71672 add 11 -11 -> 0
-
-rounding: down
--- exact zeros from zeros
-dqadd71680 add 0 0E-19 -> 0E-19
-dqadd71681 add -0 0E-19 -> 0E-19
-dqadd71682 add 0 -0E-19 -> 0E-19
-dqadd71683 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71691 add -11 11 -> 0
-dqadd71692 add 11 -11 -> 0
-
-rounding: ceiling
--- exact zeros from zeros
-dqadd71700 add 0 0E-19 -> 0E-19
-dqadd71701 add -0 0E-19 -> 0E-19
-dqadd71702 add 0 -0E-19 -> 0E-19
-dqadd71703 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71711 add -11 11 -> 0
-dqadd71712 add 11 -11 -> 0
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-dqadd71720 add 0 0E-19 -> 0E-19
-dqadd71721 add -0 0E-19 -> -0E-19 -- *
-dqadd71722 add 0 -0E-19 -> -0E-19 -- *
-dqadd71723 add -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd71731 add -11 11 -> -0 -- *
-dqadd71732 add 11 -11 -> -0 -- *
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqadd71741 add 130E-2 120E-2 -> 2.50
-dqadd71742 add 130E-2 12E-1 -> 2.50
-dqadd71743 add 130E-2 1E0 -> 2.30
-dqadd71744 add 1E2 1E4 -> 1.01E+4
-dqadd71745 add 130E-2 -120E-2 -> 0.10
-dqadd71746 add 130E-2 -12E-1 -> 0.10
-dqadd71747 add 130E-2 -1E0 -> 0.30
-dqadd71748 add 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-dqadd75001 add 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
-dqadd75002 add 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
-dqadd75003 add 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75004 add 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75005 add 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75006 add 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75007 add 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75008 add 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75009 add 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75010 add 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75011 add 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75012 add 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75013 add 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75014 add 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75015 add 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75016 add 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75017 add 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75018 add 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75019 add 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75020 add 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd75021 add 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
-
--- widening second argument at gap
-dqadd75030 add 12398765432112345678945678 1 -> 12398765432112345678945679
-dqadd75031 add 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
-dqadd75032 add 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
-dqadd75033 add 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
-dqadd75034 add 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
-dqadd75035 add 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
-dqadd75036 add 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
-dqadd75037 add 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
-dqadd75038 add 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
-dqadd75039 add 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75040 add 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd75041 add 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd75042 add 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75043 add 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75044 add 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75045 add 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75046 add 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75047 add 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75048 add 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd75049 add 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-dqadd75050 add 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd75051 add 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd75052 add 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd75053 add 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd75054 add 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd75055 add 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd75056 add 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd75057 add 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
-dqadd75060 add 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd75061 add 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd75062 add 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd75063 add 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd75064 add 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd75065 add 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd75066 add 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd75067 add 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-dqadd75070 add 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
-dqadd75071 add 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75072 add 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75073 add 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75074 add 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75075 add 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75076 add 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75077 add 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75078 add 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75079 add 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75080 add 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75081 add 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75082 add 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75083 add 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75084 add 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75085 add 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75086 add 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75087 add 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75088 add 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd75089 add 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
-
--- Null tests
-dqadd9990 add 10 # -> NaN Invalid_operation
-dqadd9991 add # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqAdd.decTest -- decQuad addition --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqadd001 add 1 1 -> 2
+dqadd002 add 2 3 -> 5
+dqadd003 add '5.75' '3.3' -> 9.05
+dqadd004 add '5' '-3' -> 2
+dqadd005 add '-5' '-3' -> -8
+dqadd006 add '-7' '2.5' -> -4.5
+dqadd007 add '0.7' '0.3' -> 1.0
+dqadd008 add '1.25' '1.25' -> 2.50
+dqadd009 add '1.23456789' '1.00000000' -> '2.23456789'
+dqadd010 add '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+dqadd011 add '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqadd012 add '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
+dqadd013 add '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqadd014 add '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd015 add '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd016 add '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd017 add '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd018 add '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd019 add '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd020 add '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
+
+dqadd021 add 0 1 -> 1
+dqadd022 add 1 1 -> 2
+dqadd023 add 2 1 -> 3
+dqadd024 add 3 1 -> 4
+dqadd025 add 4 1 -> 5
+dqadd026 add 5 1 -> 6
+dqadd027 add 6 1 -> 7
+dqadd028 add 7 1 -> 8
+dqadd029 add 8 1 -> 9
+dqadd030 add 9 1 -> 10
+
+-- some carrying effects
+dqadd031 add '0.9998' '0.0000' -> '0.9998'
+dqadd032 add '0.9998' '0.0001' -> '0.9999'
+dqadd033 add '0.9998' '0.0002' -> '1.0000'
+dqadd034 add '0.9998' '0.0003' -> '1.0001'
+
+dqadd035 add '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd036 add '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd037 add '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd038 add '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd039 add '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- symmetry:
+dqadd040 add '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd041 add '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd042 add '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd044 add '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd045 add '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- same, without rounding
+dqadd046 add '10000e+9' '7' -> '10000000000007'
+dqadd047 add '10000e+9' '70' -> '10000000000070'
+dqadd048 add '10000e+9' '700' -> '10000000000700'
+dqadd049 add '10000e+9' '7000' -> '10000000007000'
+dqadd050 add '10000e+9' '70000' -> '10000000070000'
+dqadd051 add '10000e+9' '700000' -> '10000000700000'
+dqadd052 add '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+dqadd053 add '12' '7.00' -> '19.00'
+dqadd054 add '1.3' '-1.07' -> '0.23'
+dqadd055 add '1.3' '-1.30' -> '0.00'
+dqadd056 add '1.3' '-2.07' -> '-0.77'
+dqadd057 add '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+dqadd061 add 1 '0.0001' -> '1.0001'
+dqadd062 add 1 '0.00001' -> '1.00001'
+dqadd063 add 1 '0.000001' -> '1.000001'
+dqadd064 add 1 '0.0000001' -> '1.0000001'
+dqadd065 add 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+dqadd070 add 1 0 -> 1
+dqadd071 add 1 0. -> 1
+dqadd072 add 1 .0 -> 1.0
+dqadd073 add 1 0.0 -> 1.0
+dqadd074 add 1 0.00 -> 1.00
+dqadd075 add 0 1 -> 1
+dqadd076 add 0. 1 -> 1
+dqadd077 add .0 1 -> 1.0
+dqadd078 add 0.0 1 -> 1.0
+dqadd079 add 0.00 1 -> 1.00
+
+-- some carries
+dqadd080 add 999999998 1 -> 999999999
+dqadd081 add 999999999 1 -> 1000000000
+dqadd082 add 99999999 1 -> 100000000
+dqadd083 add 9999999 1 -> 10000000
+dqadd084 add 999999 1 -> 1000000
+dqadd085 add 99999 1 -> 100000
+dqadd086 add 9999 1 -> 10000
+dqadd087 add 999 1 -> 1000
+dqadd088 add 99 1 -> 100
+dqadd089 add 9 1 -> 10
+
+
+-- more LHS swaps
+dqadd090 add '-56267E-10' 0 -> '-0.0000056267'
+dqadd091 add '-56267E-6' 0 -> '-0.056267'
+dqadd092 add '-56267E-5' 0 -> '-0.56267'
+dqadd093 add '-56267E-4' 0 -> '-5.6267'
+dqadd094 add '-56267E-3' 0 -> '-56.267'
+dqadd095 add '-56267E-2' 0 -> '-562.67'
+dqadd096 add '-56267E-1' 0 -> '-5626.7'
+dqadd097 add '-56267E-0' 0 -> '-56267'
+dqadd098 add '-5E-10' 0 -> '-5E-10'
+dqadd099 add '-5E-7' 0 -> '-5E-7'
+dqadd100 add '-5E-6' 0 -> '-0.000005'
+dqadd101 add '-5E-5' 0 -> '-0.00005'
+dqadd102 add '-5E-4' 0 -> '-0.0005'
+dqadd103 add '-5E-1' 0 -> '-0.5'
+dqadd104 add '-5E0' 0 -> '-5'
+dqadd105 add '-5E1' 0 -> '-50'
+dqadd106 add '-5E5' 0 -> '-500000'
+dqadd107 add '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqadd108 add '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd109 add '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd110 add '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd111 add '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps
+dqadd113 add 0 '-56267E-10' -> '-0.0000056267'
+dqadd114 add 0 '-56267E-6' -> '-0.056267'
+dqadd116 add 0 '-56267E-5' -> '-0.56267'
+dqadd117 add 0 '-56267E-4' -> '-5.6267'
+dqadd119 add 0 '-56267E-3' -> '-56.267'
+dqadd120 add 0 '-56267E-2' -> '-562.67'
+dqadd121 add 0 '-56267E-1' -> '-5626.7'
+dqadd122 add 0 '-56267E-0' -> '-56267'
+dqadd123 add 0 '-5E-10' -> '-5E-10'
+dqadd124 add 0 '-5E-7' -> '-5E-7'
+dqadd125 add 0 '-5E-6' -> '-0.000005'
+dqadd126 add 0 '-5E-5' -> '-0.00005'
+dqadd127 add 0 '-5E-4' -> '-0.0005'
+dqadd128 add 0 '-5E-1' -> '-0.5'
+dqadd129 add 0 '-5E0' -> '-5'
+dqadd130 add 0 '-5E1' -> '-50'
+dqadd131 add 0 '-5E5' -> '-500000'
+dqadd132 add 0 '-5E33' -> '-5000000000000000000000000000000000'
+dqadd133 add 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd134 add 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd135 add 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd136 add 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- related
+dqadd137 add 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
+dqadd138 add -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
+dqadd139 add '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
+dqadd140 add '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
+dqadd141 add 1E+29 0.0000 -> '100000000000000000000000000000.0000'
+dqadd142 add 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
+dqadd143 add 0.000 1E+30 -> '1000000000000000000000000000000.000'
+dqadd144 add 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+dqadd146 add '00.0' 0 -> '0.0'
+dqadd147 add '0.00' 0 -> '0.00'
+dqadd148 add 0 '0.00' -> '0.00'
+dqadd149 add 0 '00.0' -> '0.0'
+dqadd150 add '00.0' '0.00' -> '0.00'
+dqadd151 add '0.00' '00.0' -> '0.00'
+dqadd152 add '3' '.3' -> '3.3'
+dqadd153 add '3.' '.3' -> '3.3'
+dqadd154 add '3.0' '.3' -> '3.3'
+dqadd155 add '3.00' '.3' -> '3.30'
+dqadd156 add '3' '3' -> '6'
+dqadd157 add '3' '+3' -> '6'
+dqadd158 add '3' '-3' -> '0'
+dqadd159 add '0.3' '-0.3' -> '0.0'
+dqadd160 add '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+dqadd161 add '1E+12' '-1' -> '999999999999'
+dqadd162 add '1E+12' '1.11' -> '1000000000001.11'
+dqadd163 add '1.11' '1E+12' -> '1000000000001.11'
+dqadd164 add '-1' '1E+12' -> '999999999999'
+dqadd165 add '7E+12' '-1' -> '6999999999999'
+dqadd166 add '7E+12' '1.11' -> '7000000000001.11'
+dqadd167 add '1.11' '7E+12' -> '7000000000001.11'
+dqadd168 add '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+dqadd170 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd171 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd172 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd173 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
+dqadd174 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd175 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd176 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd177 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
+dqadd178 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd179 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd180 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd181 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd182 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd183 add '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqadd200 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd201 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd202 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd203 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd204 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd205 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd206 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd207 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd208 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd209 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd210 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd211 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd212 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd213 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd214 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd215 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd216 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd217 add '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd218 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd219 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+rounding: half_even
+dqadd220 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd221 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd222 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd223 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd224 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd225 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd226 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd227 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd228 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd229 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd230 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd231 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd232 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd233 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd234 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd235 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd236 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd237 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd238 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd239 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+dqadd240 add '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd241 add '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd242 add '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+
+rounding: down
+dqadd250 add '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd251 add '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd252 add '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd253 add '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd254 add '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd255 add '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd256 add '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd257 add '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd258 add '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd259 add '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd260 add '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd261 add '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd262 add '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd263 add '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd264 add '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd265 add '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd266 add '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd267 add '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd268 add '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd269 add '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+dqadd301 add -1 1 -> 0
+dqadd302 add 0 1 -> 1
+dqadd303 add 1 1 -> 2
+dqadd304 add 12 1 -> 13
+dqadd305 add 98 1 -> 99
+dqadd306 add 99 1 -> 100
+dqadd307 add 100 1 -> 101
+dqadd308 add 101 1 -> 102
+dqadd309 add -1 -1 -> -2
+dqadd310 add 0 -1 -> -1
+dqadd311 add 1 -1 -> 0
+dqadd312 add 12 -1 -> 11
+dqadd313 add 98 -1 -> 97
+dqadd314 add 99 -1 -> 98
+dqadd315 add 100 -1 -> 99
+dqadd316 add 101 -1 -> 100
+
+dqadd321 add -0.01 0.01 -> 0.00
+dqadd322 add 0.00 0.01 -> 0.01
+dqadd323 add 0.01 0.01 -> 0.02
+dqadd324 add 0.12 0.01 -> 0.13
+dqadd325 add 0.98 0.01 -> 0.99
+dqadd326 add 0.99 0.01 -> 1.00
+dqadd327 add 1.00 0.01 -> 1.01
+dqadd328 add 1.01 0.01 -> 1.02
+dqadd329 add -0.01 -0.01 -> -0.02
+dqadd330 add 0.00 -0.01 -> -0.01
+dqadd331 add 0.01 -0.01 -> 0.00
+dqadd332 add 0.12 -0.01 -> 0.11
+dqadd333 add 0.98 -0.01 -> 0.97
+dqadd334 add 0.99 -0.01 -> 0.98
+dqadd335 add 1.00 -0.01 -> 0.99
+dqadd336 add 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+dqadd340 add 1E+3 0 -> 1000
+dqadd341 add 1E+33 0 -> 1000000000000000000000000000000000
+dqadd342 add 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
+dqadd343 add 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
+-- which simply follow from these cases ...
+dqadd344 add 1E+3 1 -> 1001
+dqadd345 add 1E+33 1 -> 1000000000000000000000000000000001
+dqadd346 add 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd347 add 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+dqadd348 add 1E+3 7 -> 1007
+dqadd349 add 1E+33 7 -> 1000000000000000000000000000000007
+dqadd350 add 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
+dqadd351 add 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+dqadd360 add 0E+50 10000E+1 -> 1.0000E+5
+dqadd361 add 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
+dqadd362 add 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
+dqadd363 add 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
+dqadd364 add 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
+-- 1 234567890123456789012345678901234
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+dqadd370 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd371 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_up
+dqadd372 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd373 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_even
+dqadd374 add 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd375 add 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+
+-- ulp replacement tests
+dqadd400 add 1 77e-32 -> 1.00000000000000000000000000000077
+dqadd401 add 1 77e-33 -> 1.000000000000000000000000000000077
+dqadd402 add 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd403 add 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd404 add 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd405 add 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd406 add 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd410 add 10 77e-32 -> 10.00000000000000000000000000000077
+dqadd411 add 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd412 add 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd413 add 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd414 add 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd415 add 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd416 add 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd420 add 77e-32 1 -> 1.00000000000000000000000000000077
+dqadd421 add 77e-33 1 -> 1.000000000000000000000000000000077
+dqadd422 add 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd423 add 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd424 add 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd425 add 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd426 add 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd430 add 77e-32 10 -> 10.00000000000000000000000000000077
+dqadd431 add 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd432 add 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd433 add 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd434 add 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd435 add 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd436 add 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- fastpath boundaries
+-- 1234567890123456789012345678901234
+dqadd501 add '4444444444444444444444444444444444' '5555555555555555555555555555555555' -> '9999999999999999999999999999999999'
+dqadd502 add '4444444444444444444444444444444444' '4555555555555555555555555555555555' -> '8999999999999999999999999999999999'
+dqadd503 add '4444444444444444444444444444444444' '3555555555555555555055555555555555' -> '7999999999999999999499999999999999'
+dqadd504 add '4444444444444444444444444444444444' '3955555555555555555555555555555555' -> '8399999999999999999999999999999999'
+dqadd505 add '4444444444444444444444444444444444' '4955555555555555555555555555555555' -> '9399999999999999999999999999999999'
+dqadd506 add '4444444444444444444444444444444444' '5955555555555555555555555555555555' -> 1.040000000000000000000000000000000E+34 Inexact Rounded
+dqadd511 add '344444444444444444444444444444444' '555555555555555555555555555555555' -> '899999999999999999999999999999999'
+dqadd512 add '34444444444444444444444444444444' '55555555555555555555555555555555' -> '89999999999999999999999999999999'
+dqadd513 add '3444444444444444444444444444444' '5555555555555555555555555555555' -> '8999999999999999999999999999999'
+dqadd514 add '344444444444444444444444444444' '555555555555555555555555555555' -> '899999999999999999999999999999'
+dqadd515 add '34444444444444444444444444444' '55555555555555555555555555555' -> '89999999999999999999999999999'
+dqadd516 add '3444444444444444444444444444' '5555555555555555555555555555' -> '8999999999999999999999999999'
+dqadd517 add '344444444444444444444444444' '555555555555555555555555555' -> '899999999999999999999999999'
+dqadd518 add '34444444444444444444444444' '55555555555555555555555555' -> '89999999999999999999999999'
+dqadd519 add '3444444444444444444444444' '5555555555555555555555555' -> '8999999999999999999999999'
+dqadd520 add '344444444444444444444444' '555555555555555555555555' -> '899999999999999999999999'
+dqadd521 add '34444444444444444444444' '55555555555555555555555' -> '89999999999999999999999'
+dqadd522 add '3444444444444444444444' '5555555555555555555555' -> '8999999999999999999999'
+dqadd523 add '4444444444444444444444' '3333333333333333333333' -> '7777777777777777777777'
+dqadd524 add '344444444444444444444' '555555555555555555555' -> '899999999999999999999'
+dqadd525 add '34444444444444444444' '55555555555555555555' -> '89999999999999999999'
+dqadd526 add '3444444444444444444' '5555555555555555555' -> '8999999999999999999'
+dqadd527 add '344444444444444444' '555555555555555555' -> '899999999999999999'
+dqadd528 add '34444444444444444' '55555555555555555' -> '89999999999999999'
+dqadd529 add '3444444444444444' '5555555555555555' -> '8999999999999999'
+dqadd530 add '344444444444444' '555555555555555' -> '899999999999999'
+dqadd531 add '34444444444444' '55555555555555' -> '89999999999999'
+dqadd532 add '3444444444444' '5555555555555' -> '8999999999999'
+dqadd533 add '344444444444' '555555555555' -> '899999999999'
+dqadd534 add '34444444444' '55555555555' -> '89999999999'
+dqadd535 add '3444444444' '5555555555' -> '8999999999'
+dqadd536 add '344444444' '555555555' -> '899999999'
+dqadd537 add '34444444' '55555555' -> '89999999'
+dqadd538 add '3444444' '5555555' -> '8999999'
+dqadd539 add '344444' '555555' -> '899999'
+dqadd540 add '34444' '55555' -> '89999'
+dqadd541 add '3444' '5555' -> '8999'
+dqadd542 add '344' '555' -> '899'
+dqadd543 add '34' '55' -> '89'
+dqadd544 add '3' '5' -> '8'
+
+dqadd545 add '3000004000000000000000000000000000' '3000000000000040000000000000000000' -> '6000004000000040000000000000000000'
+dqadd546 add '3000000400000000000000000000000000' '4000000000000400000000000000000000' -> '7000000400000400000000000000000000'
+dqadd547 add '3000000040000000000000000000000000' '5000000000004000000000000000000000' -> '8000000040004000000000000000000000'
+dqadd548 add '4000000004000000000000000000000000' '3000000000040000000000000000000000' -> '7000000004040000000000000000000000'
+dqadd549 add '4000000000400000000000000000000000' '4000000000400000000000000000000000' -> '8000000000800000000000000000000000'
+dqadd550 add '4000000000040000000000000000000000' '5000000004000000000000000000000000' -> '9000000004040000000000000000000000'
+dqadd551 add '5000000000004000000000000000000000' '3000000040000000000000000000000000' -> '8000000040004000000000000000000000'
+dqadd552 add '5000000000000400000000000000000000' '4000000400000000000000000000000000' -> '9000000400000400000000000000000000'
+dqadd553 add '5000000000000040000000000000000000' '5000004000000000000000000000000000' -> 1.000000400000004000000000000000000E+34 Rounded
+-- check propagation
+dqadd554 add '8999999999999999999999999999999999' '0000000000000000000000000000000001' -> 9000000000000000000000000000000000
+dqadd555 add '0000000000000000000000000000000001' '8999999999999999999999999999999999' -> 9000000000000000000000000000000000
+dqadd556 add '4444444444444444444444444444444444' '4555555555555555555555555555555556' -> 9000000000000000000000000000000000
+dqadd557 add '4555555555555555555555555555555556' '4444444444444444444444444444444444' -> 9000000000000000000000000000000000
+
+-- negative ulps
+dqadd6440 add 1 -77e-32 -> 0.99999999999999999999999999999923
+dqadd6441 add 1 -77e-33 -> 0.999999999999999999999999999999923
+dqadd6442 add 1 -77e-34 -> 0.9999999999999999999999999999999923
+dqadd6443 add 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6444 add 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6445 add 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd6446 add 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6450 add 10 -77e-32 -> 9.99999999999999999999999999999923
+dqadd6451 add 10 -77e-33 -> 9.999999999999999999999999999999923
+dqadd6452 add 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd6453 add 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd6454 add 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6455 add 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6456 add 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd6460 add -77e-32 1 -> 0.99999999999999999999999999999923
+dqadd6461 add -77e-33 1 -> 0.999999999999999999999999999999923
+dqadd6462 add -77e-34 1 -> 0.9999999999999999999999999999999923
+dqadd6463 add -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6464 add -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6465 add -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd6466 add -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6470 add -77e-32 10 -> 9.99999999999999999999999999999923
+dqadd6471 add -77e-33 10 -> 9.999999999999999999999999999999923
+dqadd6472 add -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd6473 add -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd6474 add -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6475 add -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd6476 add -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd6480 add -1 77e-32 -> -0.99999999999999999999999999999923
+dqadd6481 add -1 77e-33 -> -0.999999999999999999999999999999923
+dqadd6482 add -1 77e-34 -> -0.9999999999999999999999999999999923
+dqadd6483 add -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6484 add -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6485 add -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd6486 add -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6490 add -10 77e-32 -> -9.99999999999999999999999999999923
+dqadd6491 add -10 77e-33 -> -9.999999999999999999999999999999923
+dqadd6492 add -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd6493 add -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd6494 add -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6495 add -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6496 add -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd6500 add 77e-32 -1 -> -0.99999999999999999999999999999923
+dqadd6501 add 77e-33 -1 -> -0.999999999999999999999999999999923
+dqadd6502 add 77e-34 -1 -> -0.9999999999999999999999999999999923
+dqadd6503 add 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd6504 add 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd6505 add 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd6506 add 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd6510 add 77e-32 -10 -> -9.99999999999999999999999999999923
+dqadd6511 add 77e-33 -10 -> -9.999999999999999999999999999999923
+dqadd6512 add 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd6513 add 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd6514 add 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6515 add 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd6516 add 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+dqadd6540 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd6541 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6542 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6543 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6544 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6545 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6546 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6547 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6548 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6549 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6550 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6551 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6552 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6553 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6554 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6555 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6556 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd6557 add '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6558 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6559 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+rounding: half_even
+dqadd6560 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd6561 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6562 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6563 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6564 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6565 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6566 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6567 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd6568 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6569 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6570 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6571 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6572 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6573 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6574 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6575 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6576 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd6577 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6578 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd6579 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+dqadd7540 add '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd7541 add '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd7542 add '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+
+rounding: down
+dqadd7550 add '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd7551 add '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7552 add '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7553 add '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7554 add '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7555 add '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7556 add '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7557 add '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7558 add '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7559 add '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7560 add '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7561 add '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7562 add '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7563 add '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7564 add '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7565 add '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd7566 add '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd7567 add '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd7568 add '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd7569 add '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+dqadd7701 add 5.00 1.00E-3 -> 5.00100
+dqadd7702 add 00.00 0.000 -> 0.000
+dqadd7703 add 00.00 0E-3 -> 0.000
+dqadd7704 add 0E-3 00.00 -> 0.000
+
+dqadd7710 add 0E+3 00.00 -> 0.00
+dqadd7711 add 0E+3 00.0 -> 0.0
+dqadd7712 add 0E+3 00. -> 0
+dqadd7713 add 0E+3 00.E+1 -> 0E+1
+dqadd7714 add 0E+3 00.E+2 -> 0E+2
+dqadd7715 add 0E+3 00.E+3 -> 0E+3
+dqadd7716 add 0E+3 00.E+4 -> 0E+3
+dqadd7717 add 0E+3 00.E+5 -> 0E+3
+dqadd7718 add 0E+3 -00.0 -> 0.0
+dqadd7719 add 0E+3 -00. -> 0
+dqadd7731 add 0E+3 -00.E+1 -> 0E+1
+
+dqadd7720 add 00.00 0E+3 -> 0.00
+dqadd7721 add 00.0 0E+3 -> 0.0
+dqadd7722 add 00. 0E+3 -> 0
+dqadd7723 add 00.E+1 0E+3 -> 0E+1
+dqadd7724 add 00.E+2 0E+3 -> 0E+2
+dqadd7725 add 00.E+3 0E+3 -> 0E+3
+dqadd7726 add 00.E+4 0E+3 -> 0E+3
+dqadd7727 add 00.E+5 0E+3 -> 0E+3
+dqadd7728 add -00.00 0E+3 -> 0.00
+dqadd7729 add -00.0 0E+3 -> 0.0
+dqadd7730 add -00. 0E+3 -> 0
+
+dqadd7732 add 0 0 -> 0
+dqadd7733 add 0 -0 -> 0
+dqadd7734 add -0 0 -> 0
+dqadd7735 add -0 -0 -> -0 -- IEEE 754 special case
+
+dqadd7736 add 1 -1 -> 0
+dqadd7737 add -1 -1 -> -2
+dqadd7738 add 1 1 -> 2
+dqadd7739 add -1 1 -> 0
+
+dqadd7741 add 0 -1 -> -1
+dqadd7742 add -0 -1 -> -1
+dqadd7743 add 0 1 -> 1
+dqadd7744 add -0 1 -> 1
+dqadd7745 add -1 0 -> -1
+dqadd7746 add -1 -0 -> -1
+dqadd7747 add 1 0 -> 1
+dqadd7748 add 1 -0 -> 1
+
+dqadd7751 add 0.0 -1 -> -1.0
+dqadd7752 add -0.0 -1 -> -1.0
+dqadd7753 add 0.0 1 -> 1.0
+dqadd7754 add -0.0 1 -> 1.0
+dqadd7755 add -1.0 0 -> -1.0
+dqadd7756 add -1.0 -0 -> -1.0
+dqadd7757 add 1.0 0 -> 1.0
+dqadd7758 add 1.0 -0 -> 1.0
+
+dqadd7761 add 0 -1.0 -> -1.0
+dqadd7762 add -0 -1.0 -> -1.0
+dqadd7763 add 0 1.0 -> 1.0
+dqadd7764 add -0 1.0 -> 1.0
+dqadd7765 add -1 0.0 -> -1.0
+dqadd7766 add -1 -0.0 -> -1.0
+dqadd7767 add 1 0.0 -> 1.0
+dqadd7768 add 1 -0.0 -> 1.0
+
+dqadd7771 add 0.0 -1.0 -> -1.0
+dqadd7772 add -0.0 -1.0 -> -1.0
+dqadd7773 add 0.0 1.0 -> 1.0
+dqadd7774 add -0.0 1.0 -> 1.0
+dqadd7775 add -1.0 0.0 -> -1.0
+dqadd7776 add -1.0 -0.0 -> -1.0
+dqadd7777 add 1.0 0.0 -> 1.0
+dqadd7778 add 1.0 -0.0 -> 1.0
+
+-- Specials
+dqadd7780 add -Inf -Inf -> -Infinity
+dqadd7781 add -Inf -1000 -> -Infinity
+dqadd7782 add -Inf -1 -> -Infinity
+dqadd7783 add -Inf -0 -> -Infinity
+dqadd7784 add -Inf 0 -> -Infinity
+dqadd7785 add -Inf 1 -> -Infinity
+dqadd7786 add -Inf 1000 -> -Infinity
+dqadd7787 add -1000 -Inf -> -Infinity
+dqadd7788 add -Inf -Inf -> -Infinity
+dqadd7789 add -1 -Inf -> -Infinity
+dqadd7790 add -0 -Inf -> -Infinity
+dqadd7791 add 0 -Inf -> -Infinity
+dqadd7792 add 1 -Inf -> -Infinity
+dqadd7793 add 1000 -Inf -> -Infinity
+dqadd7794 add Inf -Inf -> NaN Invalid_operation
+
+dqadd7800 add Inf -Inf -> NaN Invalid_operation
+dqadd7801 add Inf -1000 -> Infinity
+dqadd7802 add Inf -1 -> Infinity
+dqadd7803 add Inf -0 -> Infinity
+dqadd7804 add Inf 0 -> Infinity
+dqadd7805 add Inf 1 -> Infinity
+dqadd7806 add Inf 1000 -> Infinity
+dqadd7807 add Inf Inf -> Infinity
+dqadd7808 add -1000 Inf -> Infinity
+dqadd7809 add -Inf Inf -> NaN Invalid_operation
+dqadd7810 add -1 Inf -> Infinity
+dqadd7811 add -0 Inf -> Infinity
+dqadd7812 add 0 Inf -> Infinity
+dqadd7813 add 1 Inf -> Infinity
+dqadd7814 add 1000 Inf -> Infinity
+dqadd7815 add Inf Inf -> Infinity
+
+dqadd7821 add NaN -Inf -> NaN
+dqadd7822 add NaN -1000 -> NaN
+dqadd7823 add NaN -1 -> NaN
+dqadd7824 add NaN -0 -> NaN
+dqadd7825 add NaN 0 -> NaN
+dqadd7826 add NaN 1 -> NaN
+dqadd7827 add NaN 1000 -> NaN
+dqadd7828 add NaN Inf -> NaN
+dqadd7829 add NaN NaN -> NaN
+dqadd7830 add -Inf NaN -> NaN
+dqadd7831 add -1000 NaN -> NaN
+dqadd7832 add -1 NaN -> NaN
+dqadd7833 add -0 NaN -> NaN
+dqadd7834 add 0 NaN -> NaN
+dqadd7835 add 1 NaN -> NaN
+dqadd7836 add 1000 NaN -> NaN
+dqadd7837 add Inf NaN -> NaN
+
+dqadd7841 add sNaN -Inf -> NaN Invalid_operation
+dqadd7842 add sNaN -1000 -> NaN Invalid_operation
+dqadd7843 add sNaN -1 -> NaN Invalid_operation
+dqadd7844 add sNaN -0 -> NaN Invalid_operation
+dqadd7845 add sNaN 0 -> NaN Invalid_operation
+dqadd7846 add sNaN 1 -> NaN Invalid_operation
+dqadd7847 add sNaN 1000 -> NaN Invalid_operation
+dqadd7848 add sNaN NaN -> NaN Invalid_operation
+dqadd7849 add sNaN sNaN -> NaN Invalid_operation
+dqadd7850 add NaN sNaN -> NaN Invalid_operation
+dqadd7851 add -Inf sNaN -> NaN Invalid_operation
+dqadd7852 add -1000 sNaN -> NaN Invalid_operation
+dqadd7853 add -1 sNaN -> NaN Invalid_operation
+dqadd7854 add -0 sNaN -> NaN Invalid_operation
+dqadd7855 add 0 sNaN -> NaN Invalid_operation
+dqadd7856 add 1 sNaN -> NaN Invalid_operation
+dqadd7857 add 1000 sNaN -> NaN Invalid_operation
+dqadd7858 add Inf sNaN -> NaN Invalid_operation
+dqadd7859 add NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqadd7861 add NaN1 -Inf -> NaN1
+dqadd7862 add +NaN2 -1000 -> NaN2
+dqadd7863 add NaN3 1000 -> NaN3
+dqadd7864 add NaN4 Inf -> NaN4
+dqadd7865 add NaN5 +NaN6 -> NaN5
+dqadd7866 add -Inf NaN7 -> NaN7
+dqadd7867 add -1000 NaN8 -> NaN8
+dqadd7868 add 1000 NaN9 -> NaN9
+dqadd7869 add Inf +NaN10 -> NaN10
+dqadd7871 add sNaN11 -Inf -> NaN11 Invalid_operation
+dqadd7872 add sNaN12 -1000 -> NaN12 Invalid_operation
+dqadd7873 add sNaN13 1000 -> NaN13 Invalid_operation
+dqadd7874 add sNaN14 NaN17 -> NaN14 Invalid_operation
+dqadd7875 add sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqadd7876 add NaN16 sNaN19 -> NaN19 Invalid_operation
+dqadd7877 add -Inf +sNaN20 -> NaN20 Invalid_operation
+dqadd7878 add -1000 sNaN21 -> NaN21 Invalid_operation
+dqadd7879 add 1000 sNaN22 -> NaN22 Invalid_operation
+dqadd7880 add Inf sNaN23 -> NaN23 Invalid_operation
+dqadd7881 add +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqadd7882 add -NaN26 NaN28 -> -NaN26
+dqadd7883 add -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqadd7884 add 1000 -NaN30 -> -NaN30
+dqadd7885 add 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+dqadd7575 add 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
+dqadd7576 add -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+dqadd7972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqadd7973 add 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7974 add 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7975 add 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
+dqadd7976 add 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7977 add 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7978 add 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7979 add 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7980 add 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
+dqadd7981 add 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7982 add 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7983 add 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7984 add 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+dqadd7985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqadd7986 add -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7987 add -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7988 add -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
+dqadd7989 add -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7990 add -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7991 add -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7992 add -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7993 add -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd7994 add -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7995 add -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7996 add -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd7997 add -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+dqadd71100 add 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
+dqadd71101 add 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
+dqadd71103 add +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
+dqadd71104 add 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
+dqadd71105 add 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
+dqadd71106 add 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd71107 add 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd71108 add 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd71109 add 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+dqadd71110 add -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
+dqadd71111 add -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
+dqadd71113 add -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
+dqadd71114 add -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
+dqadd71115 add -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
+dqadd71116 add -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd71117 add -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd71118 add -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd71119 add -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+dqadd71300 add 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71310 add 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71311 add 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71312 add 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71313 add 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71314 add 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71315 add 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71316 add 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71317 add 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71318 add 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71319 add 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71320 add 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71321 add 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71322 add 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71323 add 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71324 add 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71325 add 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71326 add 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71327 add 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71328 add 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71329 add 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71330 add 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71331 add 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71332 add 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71333 add 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71334 add 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71335 add 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71336 add 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71337 add 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71338 add 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71339 add 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+dqadd71340 add 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
+dqadd71341 add 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
+
+dqadd71349 add 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71350 add 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71351 add 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71352 add 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71353 add 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71354 add 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71355 add 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71356 add 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71357 add 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71358 add 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71359 add 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71360 add 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71361 add 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71362 add 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71363 add 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71364 add 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd71365 add 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71367 add 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71368 add 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71369 add 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71370 add 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71371 add 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71372 add 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71373 add 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71374 add 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71375 add 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71376 add 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71377 add 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71378 add 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71379 add 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71380 add 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71381 add 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71382 add 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71383 add 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71384 add 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71385 add 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71386 add 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71387 add 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71388 add 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71389 add 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71390 add 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71391 add 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71392 add 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71393 add 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71394 add 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71395 add 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd71396 add 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+dqadd71420 add 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
+dqadd71421 add 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
+dqadd71422 add 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
+dqadd71423 add 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
+dqadd71424 add 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
+dqadd71425 add 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
+dqadd71426 add 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
+dqadd71427 add 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
+dqadd71428 add 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
+dqadd71429 add 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
+dqadd71430 add 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
+dqadd71431 add 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
+dqadd71432 add 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
+dqadd71433 add 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
+dqadd71434 add 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
+dqadd71435 add 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
+dqadd71436 add 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
+dqadd71437 add 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
+dqadd71438 add 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
+dqadd71439 add 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
+dqadd71440 add 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
+dqadd71441 add 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
+dqadd71442 add 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
+dqadd71443 add 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
+dqadd71444 add 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
+dqadd71445 add 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
+dqadd71446 add 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
+dqadd71447 add 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
+dqadd71448 add 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
+dqadd71449 add 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
+dqadd71450 add 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
+dqadd71451 add 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
+dqadd71452 add 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
+dqadd71453 add 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
+dqadd71454 add 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
+dqadd71455 add 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
+dqadd71456 add 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
+
+-- same, reversed 0
+dqadd71460 add 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
+dqadd71461 add 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
+dqadd71462 add 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
+dqadd71463 add 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
+dqadd71464 add 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
+dqadd71465 add 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
+dqadd71466 add 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
+dqadd71467 add 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
+dqadd71468 add 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
+dqadd71469 add 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
+dqadd71470 add 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
+dqadd71471 add 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
+dqadd71472 add 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
+dqadd71473 add 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
+dqadd71474 add 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
+dqadd71475 add 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
+dqadd71476 add 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
+dqadd71477 add 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
+dqadd71478 add 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
+dqadd71479 add 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
+dqadd71480 add 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
+dqadd71481 add 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
+dqadd71482 add 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
+dqadd71483 add 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
+dqadd71484 add 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
+dqadd71485 add 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
+dqadd71486 add 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
+dqadd71487 add 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
+dqadd71488 add 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
+dqadd71489 add 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
+dqadd71490 add 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
+dqadd71491 add 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
+dqadd71492 add 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
+dqadd71493 add 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
+dqadd71494 add 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
+dqadd71495 add 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
+dqadd71496 add 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
+
+-- same, Es on the 0
+dqadd71500 add 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
+dqadd71501 add 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
+dqadd71502 add 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
+dqadd71503 add 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
+dqadd71504 add 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
+dqadd71505 add 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
+dqadd71506 add 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
+dqadd71507 add 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
+dqadd71508 add 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
+dqadd71509 add 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
+dqadd71510 add 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
+dqadd71511 add 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
+dqadd71512 add 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
+dqadd71513 add 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
+dqadd71514 add 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
+dqadd71515 add 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
+dqadd71516 add 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
+dqadd71517 add 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
+dqadd71518 add 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
+dqadd71519 add 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
+dqadd71520 add 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
+dqadd71521 add 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
+dqadd71522 add 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
+dqadd71523 add 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
+dqadd71524 add 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
+dqadd71525 add 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
+dqadd71526 add 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
+dqadd71527 add 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
+dqadd71528 add 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
+dqadd71529 add 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
+dqadd71530 add 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
+dqadd71531 add 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
+dqadd71532 add 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
+dqadd71533 add 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
+-- next four flag Rounded because the 0 extends the result
+dqadd71534 add 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
+dqadd71535 add 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
+dqadd71536 add 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
+dqadd71537 add 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+dqadd71600 add 0 0E-19 -> 0E-19
+dqadd71601 add -0 0E-19 -> 0E-19
+dqadd71602 add 0 -0E-19 -> 0E-19
+dqadd71603 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71611 add -11 11 -> 0
+dqadd71612 add 11 -11 -> 0
+
+rounding: half_down
+-- exact zeros from zeros
+dqadd71620 add 0 0E-19 -> 0E-19
+dqadd71621 add -0 0E-19 -> 0E-19
+dqadd71622 add 0 -0E-19 -> 0E-19
+dqadd71623 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71631 add -11 11 -> 0
+dqadd71632 add 11 -11 -> 0
+
+rounding: half_even
+-- exact zeros from zeros
+dqadd71640 add 0 0E-19 -> 0E-19
+dqadd71641 add -0 0E-19 -> 0E-19
+dqadd71642 add 0 -0E-19 -> 0E-19
+dqadd71643 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71651 add -11 11 -> 0
+dqadd71652 add 11 -11 -> 0
+
+rounding: up
+-- exact zeros from zeros
+dqadd71660 add 0 0E-19 -> 0E-19
+dqadd71661 add -0 0E-19 -> 0E-19
+dqadd71662 add 0 -0E-19 -> 0E-19
+dqadd71663 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71671 add -11 11 -> 0
+dqadd71672 add 11 -11 -> 0
+
+rounding: down
+-- exact zeros from zeros
+dqadd71680 add 0 0E-19 -> 0E-19
+dqadd71681 add -0 0E-19 -> 0E-19
+dqadd71682 add 0 -0E-19 -> 0E-19
+dqadd71683 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71691 add -11 11 -> 0
+dqadd71692 add 11 -11 -> 0
+
+rounding: ceiling
+-- exact zeros from zeros
+dqadd71700 add 0 0E-19 -> 0E-19
+dqadd71701 add -0 0E-19 -> 0E-19
+dqadd71702 add 0 -0E-19 -> 0E-19
+dqadd71703 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71711 add -11 11 -> 0
+dqadd71712 add 11 -11 -> 0
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+dqadd71720 add 0 0E-19 -> 0E-19
+dqadd71721 add -0 0E-19 -> -0E-19 -- *
+dqadd71722 add 0 -0E-19 -> -0E-19 -- *
+dqadd71723 add -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd71731 add -11 11 -> -0 -- *
+dqadd71732 add 11 -11 -> -0 -- *
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqadd71741 add 130E-2 120E-2 -> 2.50
+dqadd71742 add 130E-2 12E-1 -> 2.50
+dqadd71743 add 130E-2 1E0 -> 2.30
+dqadd71744 add 1E2 1E4 -> 1.01E+4
+dqadd71745 add 130E-2 -120E-2 -> 0.10
+dqadd71746 add 130E-2 -12E-1 -> 0.10
+dqadd71747 add 130E-2 -1E0 -> 0.30
+dqadd71748 add 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+dqadd75001 add 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
+dqadd75002 add 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
+dqadd75003 add 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75004 add 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75005 add 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75006 add 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75007 add 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75008 add 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75009 add 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75010 add 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75011 add 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75012 add 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75013 add 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75014 add 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75015 add 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75016 add 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75017 add 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75018 add 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75019 add 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75020 add 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd75021 add 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
+
+-- widening second argument at gap
+dqadd75030 add 12398765432112345678945678 1 -> 12398765432112345678945679
+dqadd75031 add 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
+dqadd75032 add 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
+dqadd75033 add 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
+dqadd75034 add 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
+dqadd75035 add 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
+dqadd75036 add 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
+dqadd75037 add 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
+dqadd75038 add 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
+dqadd75039 add 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75040 add 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd75041 add 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd75042 add 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75043 add 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75044 add 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75045 add 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75046 add 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75047 add 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75048 add 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd75049 add 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+dqadd75050 add 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd75051 add 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd75052 add 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd75053 add 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd75054 add 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd75055 add 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd75056 add 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd75057 add 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
+dqadd75060 add 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd75061 add 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd75062 add 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd75063 add 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd75064 add 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd75065 add 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd75066 add 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd75067 add 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+dqadd75070 add 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
+dqadd75071 add 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75072 add 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75073 add 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75074 add 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75075 add 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75076 add 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75077 add 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75078 add 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75079 add 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75080 add 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75081 add 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75082 add 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75083 add 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75084 add 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75085 add 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75086 add 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75087 add 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75088 add 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd75089 add 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
+
+-- Null tests
+dqadd9990 add 10 # -> NaN Invalid_operation
+dqadd9991 add # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqAnd.decTest b/Lib/test/decimaltestdata/dqAnd.decTest
index d609bc1c3bb..57c416b48ca 100644
--- a/Lib/test/decimaltestdata/dqAnd.decTest
+++ b/Lib/test/decimaltestdata/dqAnd.decTest
@@ -1,420 +1,420 @@
-------------------------------------------------------------------------
--- dqAnd.decTest -- digitwise logical AND for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqand001 and 0 0 -> 0
-dqand002 and 0 1 -> 0
-dqand003 and 1 0 -> 0
-dqand004 and 1 1 -> 1
-dqand005 and 1100 1010 -> 1000
--- and at msd and msd-1
--- 1234567890123456789012345678901234
-dqand006 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand007 and 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
-dqand008 and 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand009 and 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqand010 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand011 and 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 0
-dqand012 and 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqand013 and 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-
--- Various lengths
--- 1234567890123456789012345678901234
-
-dqand601 and 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 111111111111111111111111111111111
-dqand602 and 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 1011111111111111111111111111111111
-dqand603 and 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 1101111111111111111111111111111111
-dqand604 and 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1110111111111111111111111111111111
-dqand605 and 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 1111011111111111111111111111111111
-dqand606 and 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 1111101111111111111111111111111111
-dqand607 and 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1111110111111111111111111111111111
-dqand608 and 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 1111111011111111111111111111111111
-dqand609 and 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 1111111101111111111111111111111111
-dqand610 and 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1111111110111111111111111111111111
-dqand611 and 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 1111111111011111111111111111111111
-dqand612 and 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 1111111111101111111111111111111111
-dqand613 and 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1111111111110111111111111111111111
-dqand614 and 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 1111111111111011111111111111111111
-dqand615 and 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 1111111111111101111111111111111111
-dqand616 and 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1111111111111110111111111111111111
-dqand617 and 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 1111111111111111011111111111111111
-dqand618 and 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 1111111111111111101111111111111111
-dqand619 and 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1111111111111111110111111111111111
-dqand620 and 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 1111111111111111111011111111111111
-dqand621 and 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 1111111111111111111101111111111111
-dqand622 and 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1111111111111111111110111111111111
-dqand623 and 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 1111111111111111111111011111111111
-dqand624 and 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 1111111111111111111111101111111111
-dqand625 and 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1111111111111111111111110111111111
-dqand626 and 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 1111111111111111111111111011111111
-dqand627 and 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 1111111111111111111111111101111111
-dqand628 and 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1111111111111111111111111110111111
-dqand629 and 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 1111111111111111111111111111011111
-dqand630 and 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 1111111111111111111111111111101111
-dqand631 and 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1111111111111111111111111111110111
-dqand632 and 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 1111111111111111111111111111111011
-dqand633 and 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 1111111111111111111111111111111101
-dqand634 and 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1111111111111111111111111111111110
-
-dqand641 and 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 111111111111111111111111111111111
-dqand642 and 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 1011111111111111111111111111111111
-dqand643 and 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 1101111111111111111111111111111111
-dqand644 and 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1110111111111111111111111111111111
-dqand645 and 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 1111011111111111111111111111111111
-dqand646 and 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 1111101111111111111111111111111111
-dqand647 and 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1111110111111111111111111111111111
-dqand648 and 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 1111111011111111111111111111111111
-dqand649 and 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 1111111101111111111111111111111111
-dqand650 and 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1111111110111111111111111111111111
-dqand651 and 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 1111111111011111111111111111111111
-dqand652 and 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 1111111111101111111111111111111111
-dqand653 and 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1111111111110111111111111111111111
-dqand654 and 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 1111111111111011111111111111111111
-dqand655 and 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 1111111111111101111111111111111111
-dqand656 and 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1111111111111110111111111111111111
-dqand657 and 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 1111111111111111011111111111111111
-dqand658 and 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 1111111111111111101111111111111111
-dqand659 and 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1111111111111111110111111111111111
-dqand660 and 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111011111111111111
-dqand661 and 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111101111111111111
-dqand662 and 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111110111111111111
-dqand663 and 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111011111111111
-dqand664 and 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111101111111111
-dqand665 and 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111110111111111
-dqand666 and 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111011111111
-dqand667 and 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111101111111
-dqand668 and 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111110111111
-dqand669 and 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111011111
-dqand670 and 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111101111
-dqand671 and 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111110111
-dqand672 and 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111011
-dqand673 and 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111101
-dqand674 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-dqand675 and 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 111111111111111111111111111111110
-dqand676 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-
-dqand021 and 1111111111111111 1111111111111111 -> 1111111111111111
-dqand024 and 1111111111111111 111111111111111 -> 111111111111111
-dqand025 and 1111111111111111 11111111111111 -> 11111111111111
-dqand026 and 1111111111111111 1111111111111 -> 1111111111111
-dqand027 and 1111111111111111 111111111111 -> 111111111111
-dqand028 and 1111111111111111 11111111111 -> 11111111111
-dqand029 and 1111111111111111 1111111111 -> 1111111111
-dqand030 and 1111111111111111 111111111 -> 111111111
-dqand031 and 1111111111111111 11111111 -> 11111111
-dqand032 and 1111111111111111 1111111 -> 1111111
-dqand033 and 1111111111111111 111111 -> 111111
-dqand034 and 1111111111111111 11111 -> 11111
-dqand035 and 1111111111111111 1111 -> 1111
-dqand036 and 1111111111111111 111 -> 111
-dqand037 and 1111111111111111 11 -> 11
-dqand038 and 1111111111111111 1 -> 1
-dqand039 and 1111111111111111 0 -> 0
-
-dqand040 and 1111111111111111 1111111111111111 -> 1111111111111111
-dqand041 and 111111111111111 1111111111111111 -> 111111111111111
-dqand042 and 111111111111111 1111111111111111 -> 111111111111111
-dqand043 and 11111111111111 1111111111111111 -> 11111111111111
-dqand044 and 1111111111111 1111111111111111 -> 1111111111111
-dqand045 and 111111111111 1111111111111111 -> 111111111111
-dqand046 and 11111111111 1111111111111111 -> 11111111111
-dqand047 and 1111111111 1111111111111111 -> 1111111111
-dqand048 and 111111111 1111111111111111 -> 111111111
-dqand049 and 11111111 1111111111111111 -> 11111111
-dqand050 and 1111111 1111111111111111 -> 1111111
-dqand051 and 111111 1111111111111111 -> 111111
-dqand052 and 11111 1111111111111111 -> 11111
-dqand053 and 1111 1111111111111111 -> 1111
-dqand054 and 111 1111111111111111 -> 111
-dqand055 and 11 1111111111111111 -> 11
-dqand056 and 1 1111111111111111 -> 1
-dqand057 and 0 1111111111111111 -> 0
-
-dqand150 and 1111111111 1 -> 1
-dqand151 and 111111111 1 -> 1
-dqand152 and 11111111 1 -> 1
-dqand153 and 1111111 1 -> 1
-dqand154 and 111111 1 -> 1
-dqand155 and 11111 1 -> 1
-dqand156 and 1111 1 -> 1
-dqand157 and 111 1 -> 1
-dqand158 and 11 1 -> 1
-dqand159 and 1 1 -> 1
-
-dqand160 and 1111111111 0 -> 0
-dqand161 and 111111111 0 -> 0
-dqand162 and 11111111 0 -> 0
-dqand163 and 1111111 0 -> 0
-dqand164 and 111111 0 -> 0
-dqand165 and 11111 0 -> 0
-dqand166 and 1111 0 -> 0
-dqand167 and 111 0 -> 0
-dqand168 and 11 0 -> 0
-dqand169 and 1 0 -> 0
-
-dqand170 and 1 1111111111 -> 1
-dqand171 and 1 111111111 -> 1
-dqand172 and 1 11111111 -> 1
-dqand173 and 1 1111111 -> 1
-dqand174 and 1 111111 -> 1
-dqand175 and 1 11111 -> 1
-dqand176 and 1 1111 -> 1
-dqand177 and 1 111 -> 1
-dqand178 and 1 11 -> 1
-dqand179 and 1 1 -> 1
-
-dqand180 and 0 1111111111 -> 0
-dqand181 and 0 111111111 -> 0
-dqand182 and 0 11111111 -> 0
-dqand183 and 0 1111111 -> 0
-dqand184 and 0 111111 -> 0
-dqand185 and 0 11111 -> 0
-dqand186 and 0 1111 -> 0
-dqand187 and 0 111 -> 0
-dqand188 and 0 11 -> 0
-dqand189 and 0 1 -> 0
-
-dqand090 and 011111111 111111111 -> 11111111
-dqand091 and 101111111 111111111 -> 101111111
-dqand092 and 110111111 111111111 -> 110111111
-dqand093 and 111011111 111111111 -> 111011111
-dqand094 and 111101111 111111111 -> 111101111
-dqand095 and 111110111 111111111 -> 111110111
-dqand096 and 111111011 111111111 -> 111111011
-dqand097 and 111111101 111111111 -> 111111101
-dqand098 and 111111110 111111111 -> 111111110
-
-dqand100 and 111111111 011111111 -> 11111111
-dqand101 and 111111111 101111111 -> 101111111
-dqand102 and 111111111 110111111 -> 110111111
-dqand103 and 111111111 111011111 -> 111011111
-dqand104 and 111111111 111101111 -> 111101111
-dqand105 and 111111111 111110111 -> 111110111
-dqand106 and 111111111 111111011 -> 111111011
-dqand107 and 111111111 111111101 -> 111111101
-dqand108 and 111111111 111111110 -> 111111110
-
--- non-0/1 should not be accepted, nor should signs
-dqand220 and 111111112 111111111 -> NaN Invalid_operation
-dqand221 and 333333333 333333333 -> NaN Invalid_operation
-dqand222 and 555555555 555555555 -> NaN Invalid_operation
-dqand223 and 777777777 777777777 -> NaN Invalid_operation
-dqand224 and 999999999 999999999 -> NaN Invalid_operation
-dqand225 and 222222222 999999999 -> NaN Invalid_operation
-dqand226 and 444444444 999999999 -> NaN Invalid_operation
-dqand227 and 666666666 999999999 -> NaN Invalid_operation
-dqand228 and 888888888 999999999 -> NaN Invalid_operation
-dqand229 and 999999999 222222222 -> NaN Invalid_operation
-dqand230 and 999999999 444444444 -> NaN Invalid_operation
-dqand231 and 999999999 666666666 -> NaN Invalid_operation
-dqand232 and 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqand240 and 567468689 -934981942 -> NaN Invalid_operation
-dqand241 and 567367689 934981942 -> NaN Invalid_operation
-dqand242 and -631917772 -706014634 -> NaN Invalid_operation
-dqand243 and -756253257 138579234 -> NaN Invalid_operation
-dqand244 and 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqand250 and 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand251 and 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand252 and 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand253 and 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqand254 and 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand255 and 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand256 and 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand257 and 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqand258 and 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqand259 and 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqand260 and 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqand261 and 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqand262 and 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqand263 and 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqand264 and 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqand265 and 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqand270 and 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqand271 and 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqand272 and 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqand273 and 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqand274 and 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqand275 and 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqand276 and 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqand277 and 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqand280 and 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqand281 and 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqand282 and 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqand283 and 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqand284 and 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqand285 and 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqand286 and 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqand287 and 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqand288 and 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqand289 and 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqand290 and 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqand291 and 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqand292 and 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqand293 and 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqand294 and 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqand295 and 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqand296 and -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqand297 and -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqand298 and 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqand299 and 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 110000110000110000001000000
-
--- Nmax, Nmin, Ntiny-like
-dqand331 and 2 9.99999999E+999 -> NaN Invalid_operation
-dqand332 and 3 1E-999 -> NaN Invalid_operation
-dqand333 and 4 1.00000000E-999 -> NaN Invalid_operation
-dqand334 and 5 1E-900 -> NaN Invalid_operation
-dqand335 and 6 -1E-900 -> NaN Invalid_operation
-dqand336 and 7 -1.00000000E-999 -> NaN Invalid_operation
-dqand337 and 8 -1E-999 -> NaN Invalid_operation
-dqand338 and 9 -9.99999999E+999 -> NaN Invalid_operation
-dqand341 and 9.99999999E+999 -18 -> NaN Invalid_operation
-dqand342 and 1E-999 01 -> NaN Invalid_operation
-dqand343 and 1.00000000E-999 -18 -> NaN Invalid_operation
-dqand344 and 1E-900 18 -> NaN Invalid_operation
-dqand345 and -1E-900 -10 -> NaN Invalid_operation
-dqand346 and -1.00000000E-999 18 -> NaN Invalid_operation
-dqand347 and -1E-999 10 -> NaN Invalid_operation
-dqand348 and -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqand361 and 1.0 1 -> NaN Invalid_operation
-dqand362 and 1E+1 1 -> NaN Invalid_operation
-dqand363 and 0.0 1 -> NaN Invalid_operation
-dqand364 and 0E+1 1 -> NaN Invalid_operation
-dqand365 and 9.9 1 -> NaN Invalid_operation
-dqand366 and 9E+1 1 -> NaN Invalid_operation
-dqand371 and 0 1.0 -> NaN Invalid_operation
-dqand372 and 0 1E+1 -> NaN Invalid_operation
-dqand373 and 0 0.0 -> NaN Invalid_operation
-dqand374 and 0 0E+1 -> NaN Invalid_operation
-dqand375 and 0 9.9 -> NaN Invalid_operation
-dqand376 and 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqand780 and -Inf -Inf -> NaN Invalid_operation
-dqand781 and -Inf -1000 -> NaN Invalid_operation
-dqand782 and -Inf -1 -> NaN Invalid_operation
-dqand783 and -Inf -0 -> NaN Invalid_operation
-dqand784 and -Inf 0 -> NaN Invalid_operation
-dqand785 and -Inf 1 -> NaN Invalid_operation
-dqand786 and -Inf 1000 -> NaN Invalid_operation
-dqand787 and -1000 -Inf -> NaN Invalid_operation
-dqand788 and -Inf -Inf -> NaN Invalid_operation
-dqand789 and -1 -Inf -> NaN Invalid_operation
-dqand790 and -0 -Inf -> NaN Invalid_operation
-dqand791 and 0 -Inf -> NaN Invalid_operation
-dqand792 and 1 -Inf -> NaN Invalid_operation
-dqand793 and 1000 -Inf -> NaN Invalid_operation
-dqand794 and Inf -Inf -> NaN Invalid_operation
-
-dqand800 and Inf -Inf -> NaN Invalid_operation
-dqand801 and Inf -1000 -> NaN Invalid_operation
-dqand802 and Inf -1 -> NaN Invalid_operation
-dqand803 and Inf -0 -> NaN Invalid_operation
-dqand804 and Inf 0 -> NaN Invalid_operation
-dqand805 and Inf 1 -> NaN Invalid_operation
-dqand806 and Inf 1000 -> NaN Invalid_operation
-dqand807 and Inf Inf -> NaN Invalid_operation
-dqand808 and -1000 Inf -> NaN Invalid_operation
-dqand809 and -Inf Inf -> NaN Invalid_operation
-dqand810 and -1 Inf -> NaN Invalid_operation
-dqand811 and -0 Inf -> NaN Invalid_operation
-dqand812 and 0 Inf -> NaN Invalid_operation
-dqand813 and 1 Inf -> NaN Invalid_operation
-dqand814 and 1000 Inf -> NaN Invalid_operation
-dqand815 and Inf Inf -> NaN Invalid_operation
-
-dqand821 and NaN -Inf -> NaN Invalid_operation
-dqand822 and NaN -1000 -> NaN Invalid_operation
-dqand823 and NaN -1 -> NaN Invalid_operation
-dqand824 and NaN -0 -> NaN Invalid_operation
-dqand825 and NaN 0 -> NaN Invalid_operation
-dqand826 and NaN 1 -> NaN Invalid_operation
-dqand827 and NaN 1000 -> NaN Invalid_operation
-dqand828 and NaN Inf -> NaN Invalid_operation
-dqand829 and NaN NaN -> NaN Invalid_operation
-dqand830 and -Inf NaN -> NaN Invalid_operation
-dqand831 and -1000 NaN -> NaN Invalid_operation
-dqand832 and -1 NaN -> NaN Invalid_operation
-dqand833 and -0 NaN -> NaN Invalid_operation
-dqand834 and 0 NaN -> NaN Invalid_operation
-dqand835 and 1 NaN -> NaN Invalid_operation
-dqand836 and 1000 NaN -> NaN Invalid_operation
-dqand837 and Inf NaN -> NaN Invalid_operation
-
-dqand841 and sNaN -Inf -> NaN Invalid_operation
-dqand842 and sNaN -1000 -> NaN Invalid_operation
-dqand843 and sNaN -1 -> NaN Invalid_operation
-dqand844 and sNaN -0 -> NaN Invalid_operation
-dqand845 and sNaN 0 -> NaN Invalid_operation
-dqand846 and sNaN 1 -> NaN Invalid_operation
-dqand847 and sNaN 1000 -> NaN Invalid_operation
-dqand848 and sNaN NaN -> NaN Invalid_operation
-dqand849 and sNaN sNaN -> NaN Invalid_operation
-dqand850 and NaN sNaN -> NaN Invalid_operation
-dqand851 and -Inf sNaN -> NaN Invalid_operation
-dqand852 and -1000 sNaN -> NaN Invalid_operation
-dqand853 and -1 sNaN -> NaN Invalid_operation
-dqand854 and -0 sNaN -> NaN Invalid_operation
-dqand855 and 0 sNaN -> NaN Invalid_operation
-dqand856 and 1 sNaN -> NaN Invalid_operation
-dqand857 and 1000 sNaN -> NaN Invalid_operation
-dqand858 and Inf sNaN -> NaN Invalid_operation
-dqand859 and NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqand861 and NaN1 -Inf -> NaN Invalid_operation
-dqand862 and +NaN2 -1000 -> NaN Invalid_operation
-dqand863 and NaN3 1000 -> NaN Invalid_operation
-dqand864 and NaN4 Inf -> NaN Invalid_operation
-dqand865 and NaN5 +NaN6 -> NaN Invalid_operation
-dqand866 and -Inf NaN7 -> NaN Invalid_operation
-dqand867 and -1000 NaN8 -> NaN Invalid_operation
-dqand868 and 1000 NaN9 -> NaN Invalid_operation
-dqand869 and Inf +NaN10 -> NaN Invalid_operation
-dqand871 and sNaN11 -Inf -> NaN Invalid_operation
-dqand872 and sNaN12 -1000 -> NaN Invalid_operation
-dqand873 and sNaN13 1000 -> NaN Invalid_operation
-dqand874 and sNaN14 NaN17 -> NaN Invalid_operation
-dqand875 and sNaN15 sNaN18 -> NaN Invalid_operation
-dqand876 and NaN16 sNaN19 -> NaN Invalid_operation
-dqand877 and -Inf +sNaN20 -> NaN Invalid_operation
-dqand878 and -1000 sNaN21 -> NaN Invalid_operation
-dqand879 and 1000 sNaN22 -> NaN Invalid_operation
-dqand880 and Inf sNaN23 -> NaN Invalid_operation
-dqand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
-dqand882 and -NaN26 NaN28 -> NaN Invalid_operation
-dqand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
-dqand884 and 1000 -NaN30 -> NaN Invalid_operation
-dqand885 and 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqAnd.decTest -- digitwise logical AND for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqand001 and 0 0 -> 0
+dqand002 and 0 1 -> 0
+dqand003 and 1 0 -> 0
+dqand004 and 1 1 -> 1
+dqand005 and 1100 1010 -> 1000
+-- and at msd and msd-1
+-- 1234567890123456789012345678901234
+dqand006 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand007 and 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
+dqand008 and 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand009 and 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqand010 and 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand011 and 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 0
+dqand012 and 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqand013 and 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+
+-- Various lengths
+-- 1234567890123456789012345678901234
+
+dqand601 and 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 111111111111111111111111111111111
+dqand602 and 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 1011111111111111111111111111111111
+dqand603 and 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 1101111111111111111111111111111111
+dqand604 and 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1110111111111111111111111111111111
+dqand605 and 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 1111011111111111111111111111111111
+dqand606 and 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 1111101111111111111111111111111111
+dqand607 and 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1111110111111111111111111111111111
+dqand608 and 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 1111111011111111111111111111111111
+dqand609 and 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 1111111101111111111111111111111111
+dqand610 and 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1111111110111111111111111111111111
+dqand611 and 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 1111111111011111111111111111111111
+dqand612 and 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 1111111111101111111111111111111111
+dqand613 and 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1111111111110111111111111111111111
+dqand614 and 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 1111111111111011111111111111111111
+dqand615 and 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 1111111111111101111111111111111111
+dqand616 and 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1111111111111110111111111111111111
+dqand617 and 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 1111111111111111011111111111111111
+dqand618 and 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 1111111111111111101111111111111111
+dqand619 and 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1111111111111111110111111111111111
+dqand620 and 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 1111111111111111111011111111111111
+dqand621 and 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 1111111111111111111101111111111111
+dqand622 and 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1111111111111111111110111111111111
+dqand623 and 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 1111111111111111111111011111111111
+dqand624 and 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 1111111111111111111111101111111111
+dqand625 and 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1111111111111111111111110111111111
+dqand626 and 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 1111111111111111111111111011111111
+dqand627 and 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 1111111111111111111111111101111111
+dqand628 and 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1111111111111111111111111110111111
+dqand629 and 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 1111111111111111111111111111011111
+dqand630 and 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 1111111111111111111111111111101111
+dqand631 and 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1111111111111111111111111111110111
+dqand632 and 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 1111111111111111111111111111111011
+dqand633 and 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 1111111111111111111111111111111101
+dqand634 and 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1111111111111111111111111111111110
+
+dqand641 and 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 111111111111111111111111111111111
+dqand642 and 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 1011111111111111111111111111111111
+dqand643 and 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 1101111111111111111111111111111111
+dqand644 and 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1110111111111111111111111111111111
+dqand645 and 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 1111011111111111111111111111111111
+dqand646 and 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 1111101111111111111111111111111111
+dqand647 and 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1111110111111111111111111111111111
+dqand648 and 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 1111111011111111111111111111111111
+dqand649 and 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 1111111101111111111111111111111111
+dqand650 and 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1111111110111111111111111111111111
+dqand651 and 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 1111111111011111111111111111111111
+dqand652 and 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 1111111111101111111111111111111111
+dqand653 and 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1111111111110111111111111111111111
+dqand654 and 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 1111111111111011111111111111111111
+dqand655 and 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 1111111111111101111111111111111111
+dqand656 and 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1111111111111110111111111111111111
+dqand657 and 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 1111111111111111011111111111111111
+dqand658 and 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 1111111111111111101111111111111111
+dqand659 and 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1111111111111111110111111111111111
+dqand660 and 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111011111111111111
+dqand661 and 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111101111111111111
+dqand662 and 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111110111111111111
+dqand663 and 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111011111111111
+dqand664 and 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111101111111111
+dqand665 and 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111110111111111
+dqand666 and 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111011111111
+dqand667 and 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111101111111
+dqand668 and 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111110111111
+dqand669 and 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111011111
+dqand670 and 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111101111
+dqand671 and 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111110111
+dqand672 and 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111011
+dqand673 and 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111101
+dqand674 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+dqand675 and 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 111111111111111111111111111111110
+dqand676 and 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+
+dqand021 and 1111111111111111 1111111111111111 -> 1111111111111111
+dqand024 and 1111111111111111 111111111111111 -> 111111111111111
+dqand025 and 1111111111111111 11111111111111 -> 11111111111111
+dqand026 and 1111111111111111 1111111111111 -> 1111111111111
+dqand027 and 1111111111111111 111111111111 -> 111111111111
+dqand028 and 1111111111111111 11111111111 -> 11111111111
+dqand029 and 1111111111111111 1111111111 -> 1111111111
+dqand030 and 1111111111111111 111111111 -> 111111111
+dqand031 and 1111111111111111 11111111 -> 11111111
+dqand032 and 1111111111111111 1111111 -> 1111111
+dqand033 and 1111111111111111 111111 -> 111111
+dqand034 and 1111111111111111 11111 -> 11111
+dqand035 and 1111111111111111 1111 -> 1111
+dqand036 and 1111111111111111 111 -> 111
+dqand037 and 1111111111111111 11 -> 11
+dqand038 and 1111111111111111 1 -> 1
+dqand039 and 1111111111111111 0 -> 0
+
+dqand040 and 1111111111111111 1111111111111111 -> 1111111111111111
+dqand041 and 111111111111111 1111111111111111 -> 111111111111111
+dqand042 and 111111111111111 1111111111111111 -> 111111111111111
+dqand043 and 11111111111111 1111111111111111 -> 11111111111111
+dqand044 and 1111111111111 1111111111111111 -> 1111111111111
+dqand045 and 111111111111 1111111111111111 -> 111111111111
+dqand046 and 11111111111 1111111111111111 -> 11111111111
+dqand047 and 1111111111 1111111111111111 -> 1111111111
+dqand048 and 111111111 1111111111111111 -> 111111111
+dqand049 and 11111111 1111111111111111 -> 11111111
+dqand050 and 1111111 1111111111111111 -> 1111111
+dqand051 and 111111 1111111111111111 -> 111111
+dqand052 and 11111 1111111111111111 -> 11111
+dqand053 and 1111 1111111111111111 -> 1111
+dqand054 and 111 1111111111111111 -> 111
+dqand055 and 11 1111111111111111 -> 11
+dqand056 and 1 1111111111111111 -> 1
+dqand057 and 0 1111111111111111 -> 0
+
+dqand150 and 1111111111 1 -> 1
+dqand151 and 111111111 1 -> 1
+dqand152 and 11111111 1 -> 1
+dqand153 and 1111111 1 -> 1
+dqand154 and 111111 1 -> 1
+dqand155 and 11111 1 -> 1
+dqand156 and 1111 1 -> 1
+dqand157 and 111 1 -> 1
+dqand158 and 11 1 -> 1
+dqand159 and 1 1 -> 1
+
+dqand160 and 1111111111 0 -> 0
+dqand161 and 111111111 0 -> 0
+dqand162 and 11111111 0 -> 0
+dqand163 and 1111111 0 -> 0
+dqand164 and 111111 0 -> 0
+dqand165 and 11111 0 -> 0
+dqand166 and 1111 0 -> 0
+dqand167 and 111 0 -> 0
+dqand168 and 11 0 -> 0
+dqand169 and 1 0 -> 0
+
+dqand170 and 1 1111111111 -> 1
+dqand171 and 1 111111111 -> 1
+dqand172 and 1 11111111 -> 1
+dqand173 and 1 1111111 -> 1
+dqand174 and 1 111111 -> 1
+dqand175 and 1 11111 -> 1
+dqand176 and 1 1111 -> 1
+dqand177 and 1 111 -> 1
+dqand178 and 1 11 -> 1
+dqand179 and 1 1 -> 1
+
+dqand180 and 0 1111111111 -> 0
+dqand181 and 0 111111111 -> 0
+dqand182 and 0 11111111 -> 0
+dqand183 and 0 1111111 -> 0
+dqand184 and 0 111111 -> 0
+dqand185 and 0 11111 -> 0
+dqand186 and 0 1111 -> 0
+dqand187 and 0 111 -> 0
+dqand188 and 0 11 -> 0
+dqand189 and 0 1 -> 0
+
+dqand090 and 011111111 111111111 -> 11111111
+dqand091 and 101111111 111111111 -> 101111111
+dqand092 and 110111111 111111111 -> 110111111
+dqand093 and 111011111 111111111 -> 111011111
+dqand094 and 111101111 111111111 -> 111101111
+dqand095 and 111110111 111111111 -> 111110111
+dqand096 and 111111011 111111111 -> 111111011
+dqand097 and 111111101 111111111 -> 111111101
+dqand098 and 111111110 111111111 -> 111111110
+
+dqand100 and 111111111 011111111 -> 11111111
+dqand101 and 111111111 101111111 -> 101111111
+dqand102 and 111111111 110111111 -> 110111111
+dqand103 and 111111111 111011111 -> 111011111
+dqand104 and 111111111 111101111 -> 111101111
+dqand105 and 111111111 111110111 -> 111110111
+dqand106 and 111111111 111111011 -> 111111011
+dqand107 and 111111111 111111101 -> 111111101
+dqand108 and 111111111 111111110 -> 111111110
+
+-- non-0/1 should not be accepted, nor should signs
+dqand220 and 111111112 111111111 -> NaN Invalid_operation
+dqand221 and 333333333 333333333 -> NaN Invalid_operation
+dqand222 and 555555555 555555555 -> NaN Invalid_operation
+dqand223 and 777777777 777777777 -> NaN Invalid_operation
+dqand224 and 999999999 999999999 -> NaN Invalid_operation
+dqand225 and 222222222 999999999 -> NaN Invalid_operation
+dqand226 and 444444444 999999999 -> NaN Invalid_operation
+dqand227 and 666666666 999999999 -> NaN Invalid_operation
+dqand228 and 888888888 999999999 -> NaN Invalid_operation
+dqand229 and 999999999 222222222 -> NaN Invalid_operation
+dqand230 and 999999999 444444444 -> NaN Invalid_operation
+dqand231 and 999999999 666666666 -> NaN Invalid_operation
+dqand232 and 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqand240 and 567468689 -934981942 -> NaN Invalid_operation
+dqand241 and 567367689 934981942 -> NaN Invalid_operation
+dqand242 and -631917772 -706014634 -> NaN Invalid_operation
+dqand243 and -756253257 138579234 -> NaN Invalid_operation
+dqand244 and 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqand250 and 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand251 and 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand252 and 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand253 and 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqand254 and 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand255 and 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand256 and 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand257 and 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqand258 and 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqand259 and 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqand260 and 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqand261 and 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqand262 and 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqand263 and 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqand264 and 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqand265 and 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqand270 and 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqand271 and 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqand272 and 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqand273 and 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqand274 and 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqand275 and 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqand276 and 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqand277 and 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqand280 and 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqand281 and 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqand282 and 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqand283 and 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqand284 and 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqand285 and 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqand286 and 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqand287 and 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqand288 and 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqand289 and 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqand290 and 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqand291 and 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqand292 and 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqand293 and 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqand294 and 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqand295 and 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqand296 and -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqand297 and -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqand298 and 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqand299 and 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 110000110000110000001000000
+
+-- Nmax, Nmin, Ntiny-like
+dqand331 and 2 9.99999999E+999 -> NaN Invalid_operation
+dqand332 and 3 1E-999 -> NaN Invalid_operation
+dqand333 and 4 1.00000000E-999 -> NaN Invalid_operation
+dqand334 and 5 1E-900 -> NaN Invalid_operation
+dqand335 and 6 -1E-900 -> NaN Invalid_operation
+dqand336 and 7 -1.00000000E-999 -> NaN Invalid_operation
+dqand337 and 8 -1E-999 -> NaN Invalid_operation
+dqand338 and 9 -9.99999999E+999 -> NaN Invalid_operation
+dqand341 and 9.99999999E+999 -18 -> NaN Invalid_operation
+dqand342 and 1E-999 01 -> NaN Invalid_operation
+dqand343 and 1.00000000E-999 -18 -> NaN Invalid_operation
+dqand344 and 1E-900 18 -> NaN Invalid_operation
+dqand345 and -1E-900 -10 -> NaN Invalid_operation
+dqand346 and -1.00000000E-999 18 -> NaN Invalid_operation
+dqand347 and -1E-999 10 -> NaN Invalid_operation
+dqand348 and -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqand361 and 1.0 1 -> NaN Invalid_operation
+dqand362 and 1E+1 1 -> NaN Invalid_operation
+dqand363 and 0.0 1 -> NaN Invalid_operation
+dqand364 and 0E+1 1 -> NaN Invalid_operation
+dqand365 and 9.9 1 -> NaN Invalid_operation
+dqand366 and 9E+1 1 -> NaN Invalid_operation
+dqand371 and 0 1.0 -> NaN Invalid_operation
+dqand372 and 0 1E+1 -> NaN Invalid_operation
+dqand373 and 0 0.0 -> NaN Invalid_operation
+dqand374 and 0 0E+1 -> NaN Invalid_operation
+dqand375 and 0 9.9 -> NaN Invalid_operation
+dqand376 and 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqand780 and -Inf -Inf -> NaN Invalid_operation
+dqand781 and -Inf -1000 -> NaN Invalid_operation
+dqand782 and -Inf -1 -> NaN Invalid_operation
+dqand783 and -Inf -0 -> NaN Invalid_operation
+dqand784 and -Inf 0 -> NaN Invalid_operation
+dqand785 and -Inf 1 -> NaN Invalid_operation
+dqand786 and -Inf 1000 -> NaN Invalid_operation
+dqand787 and -1000 -Inf -> NaN Invalid_operation
+dqand788 and -Inf -Inf -> NaN Invalid_operation
+dqand789 and -1 -Inf -> NaN Invalid_operation
+dqand790 and -0 -Inf -> NaN Invalid_operation
+dqand791 and 0 -Inf -> NaN Invalid_operation
+dqand792 and 1 -Inf -> NaN Invalid_operation
+dqand793 and 1000 -Inf -> NaN Invalid_operation
+dqand794 and Inf -Inf -> NaN Invalid_operation
+
+dqand800 and Inf -Inf -> NaN Invalid_operation
+dqand801 and Inf -1000 -> NaN Invalid_operation
+dqand802 and Inf -1 -> NaN Invalid_operation
+dqand803 and Inf -0 -> NaN Invalid_operation
+dqand804 and Inf 0 -> NaN Invalid_operation
+dqand805 and Inf 1 -> NaN Invalid_operation
+dqand806 and Inf 1000 -> NaN Invalid_operation
+dqand807 and Inf Inf -> NaN Invalid_operation
+dqand808 and -1000 Inf -> NaN Invalid_operation
+dqand809 and -Inf Inf -> NaN Invalid_operation
+dqand810 and -1 Inf -> NaN Invalid_operation
+dqand811 and -0 Inf -> NaN Invalid_operation
+dqand812 and 0 Inf -> NaN Invalid_operation
+dqand813 and 1 Inf -> NaN Invalid_operation
+dqand814 and 1000 Inf -> NaN Invalid_operation
+dqand815 and Inf Inf -> NaN Invalid_operation
+
+dqand821 and NaN -Inf -> NaN Invalid_operation
+dqand822 and NaN -1000 -> NaN Invalid_operation
+dqand823 and NaN -1 -> NaN Invalid_operation
+dqand824 and NaN -0 -> NaN Invalid_operation
+dqand825 and NaN 0 -> NaN Invalid_operation
+dqand826 and NaN 1 -> NaN Invalid_operation
+dqand827 and NaN 1000 -> NaN Invalid_operation
+dqand828 and NaN Inf -> NaN Invalid_operation
+dqand829 and NaN NaN -> NaN Invalid_operation
+dqand830 and -Inf NaN -> NaN Invalid_operation
+dqand831 and -1000 NaN -> NaN Invalid_operation
+dqand832 and -1 NaN -> NaN Invalid_operation
+dqand833 and -0 NaN -> NaN Invalid_operation
+dqand834 and 0 NaN -> NaN Invalid_operation
+dqand835 and 1 NaN -> NaN Invalid_operation
+dqand836 and 1000 NaN -> NaN Invalid_operation
+dqand837 and Inf NaN -> NaN Invalid_operation
+
+dqand841 and sNaN -Inf -> NaN Invalid_operation
+dqand842 and sNaN -1000 -> NaN Invalid_operation
+dqand843 and sNaN -1 -> NaN Invalid_operation
+dqand844 and sNaN -0 -> NaN Invalid_operation
+dqand845 and sNaN 0 -> NaN Invalid_operation
+dqand846 and sNaN 1 -> NaN Invalid_operation
+dqand847 and sNaN 1000 -> NaN Invalid_operation
+dqand848 and sNaN NaN -> NaN Invalid_operation
+dqand849 and sNaN sNaN -> NaN Invalid_operation
+dqand850 and NaN sNaN -> NaN Invalid_operation
+dqand851 and -Inf sNaN -> NaN Invalid_operation
+dqand852 and -1000 sNaN -> NaN Invalid_operation
+dqand853 and -1 sNaN -> NaN Invalid_operation
+dqand854 and -0 sNaN -> NaN Invalid_operation
+dqand855 and 0 sNaN -> NaN Invalid_operation
+dqand856 and 1 sNaN -> NaN Invalid_operation
+dqand857 and 1000 sNaN -> NaN Invalid_operation
+dqand858 and Inf sNaN -> NaN Invalid_operation
+dqand859 and NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqand861 and NaN1 -Inf -> NaN Invalid_operation
+dqand862 and +NaN2 -1000 -> NaN Invalid_operation
+dqand863 and NaN3 1000 -> NaN Invalid_operation
+dqand864 and NaN4 Inf -> NaN Invalid_operation
+dqand865 and NaN5 +NaN6 -> NaN Invalid_operation
+dqand866 and -Inf NaN7 -> NaN Invalid_operation
+dqand867 and -1000 NaN8 -> NaN Invalid_operation
+dqand868 and 1000 NaN9 -> NaN Invalid_operation
+dqand869 and Inf +NaN10 -> NaN Invalid_operation
+dqand871 and sNaN11 -Inf -> NaN Invalid_operation
+dqand872 and sNaN12 -1000 -> NaN Invalid_operation
+dqand873 and sNaN13 1000 -> NaN Invalid_operation
+dqand874 and sNaN14 NaN17 -> NaN Invalid_operation
+dqand875 and sNaN15 sNaN18 -> NaN Invalid_operation
+dqand876 and NaN16 sNaN19 -> NaN Invalid_operation
+dqand877 and -Inf +sNaN20 -> NaN Invalid_operation
+dqand878 and -1000 sNaN21 -> NaN Invalid_operation
+dqand879 and 1000 sNaN22 -> NaN Invalid_operation
+dqand880 and Inf sNaN23 -> NaN Invalid_operation
+dqand881 and +NaN25 +sNaN24 -> NaN Invalid_operation
+dqand882 and -NaN26 NaN28 -> NaN Invalid_operation
+dqand883 and -sNaN27 sNaN29 -> NaN Invalid_operation
+dqand884 and 1000 -NaN30 -> NaN Invalid_operation
+dqand885 and 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqBase.decTest b/Lib/test/decimaltestdata/dqBase.decTest
index d09c6bf02cc..6bb463388e1 100644
--- a/Lib/test/decimaltestdata/dqBase.decTest
+++ b/Lib/test/decimaltestdata/dqBase.decTest
@@ -1,1081 +1,1081 @@
-------------------------------------------------------------------------
--- dqBase.decTest -- base decQuad <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decQuad. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqbas001 toSci 0 -> 0
-dqbas002 toSci 1 -> 1
-dqbas003 toSci 1.0 -> 1.0
-dqbas004 toSci 1.00 -> 1.00
-dqbas005 toSci 10 -> 10
-dqbas006 toSci 1000 -> 1000
-dqbas007 toSci 10.0 -> 10.0
-dqbas008 toSci 10.1 -> 10.1
-dqbas009 toSci 10.4 -> 10.4
-dqbas010 toSci 10.5 -> 10.5
-dqbas011 toSci 10.6 -> 10.6
-dqbas012 toSci 10.9 -> 10.9
-dqbas013 toSci 11.0 -> 11.0
-dqbas014 toSci 1.234 -> 1.234
-dqbas015 toSci 0.123 -> 0.123
-dqbas016 toSci 0.012 -> 0.012
-dqbas017 toSci -0 -> -0
-dqbas018 toSci -0.0 -> -0.0
-dqbas019 toSci -00.00 -> -0.00
-
-dqbas021 toSci -1 -> -1
-dqbas022 toSci -1.0 -> -1.0
-dqbas023 toSci -0.1 -> -0.1
-dqbas024 toSci -9.1 -> -9.1
-dqbas025 toSci -9.11 -> -9.11
-dqbas026 toSci -9.119 -> -9.119
-dqbas027 toSci -9.999 -> -9.999
-
-dqbas030 toSci '123456789.123456' -> '123456789.123456'
-dqbas031 toSci '123456789.000000' -> '123456789.000000'
-dqbas032 toSci '123456789123456' -> '123456789123456'
-dqbas033 toSci '0.0000123456789' -> '0.0000123456789'
-dqbas034 toSci '0.00000123456789' -> '0.00000123456789'
-dqbas035 toSci '0.000000123456789' -> '1.23456789E-7'
-dqbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
-
-dqbas037 toSci '0.123456789012344' -> '0.123456789012344'
-dqbas038 toSci '0.123456789012345' -> '0.123456789012345'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqbsn002 toSci -1E-6143 -> -1E-6143
-dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal
-dqbsn004 toSci -0 -> -0
-dqbsn005 toSci +0 -> 0
-dqbsn006 toSci +1E-6176 -> 1E-6176 Subnormal
-dqbsn007 toSci +1E-6143 -> 1E-6143
-dqbsn008 toSci +9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-dqbas040 toSci "12" -> '12'
-dqbas041 toSci "-76" -> '-76'
-dqbas042 toSci "12.76" -> '12.76'
-dqbas043 toSci "+12.76" -> '12.76'
-dqbas044 toSci "012.76" -> '12.76'
-dqbas045 toSci "+0.003" -> '0.003'
-dqbas046 toSci "17." -> '17'
-dqbas047 toSci ".5" -> '0.5'
-dqbas048 toSci "044" -> '44'
-dqbas049 toSci "0044" -> '44'
-dqbas050 toSci "0.0005" -> '0.0005'
-dqbas051 toSci "00.00005" -> '0.00005'
-dqbas052 toSci "0.000005" -> '0.000005'
-dqbas053 toSci "0.0000050" -> '0.0000050'
-dqbas054 toSci "0.0000005" -> '5E-7'
-dqbas055 toSci "0.00000005" -> '5E-8'
-dqbas056 toSci "12345678.543210" -> '12345678.543210'
-dqbas057 toSci "2345678.543210" -> '2345678.543210'
-dqbas058 toSci "345678.543210" -> '345678.543210'
-dqbas059 toSci "0345678.54321" -> '345678.54321'
-dqbas060 toSci "345678.5432" -> '345678.5432'
-dqbas061 toSci "+345678.5432" -> '345678.5432'
-dqbas062 toSci "+0345678.5432" -> '345678.5432'
-dqbas063 toSci "+00345678.5432" -> '345678.5432'
-dqbas064 toSci "-345678.5432" -> '-345678.5432'
-dqbas065 toSci "-0345678.5432" -> '-345678.5432'
-dqbas066 toSci "-00345678.5432" -> '-345678.5432'
--- examples
-dqbas067 toSci "5E-6" -> '0.000005'
-dqbas068 toSci "50E-7" -> '0.0000050'
-dqbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-dqbas071 toSci .1234567891234567890123456780123456123 -> 0.1234567891234567890123456780123456 Inexact Rounded
-dqbas072 toSci 1.234567891234567890123456780123456123 -> 1.234567891234567890123456780123456 Inexact Rounded
-dqbas073 toSci 12.34567891234567890123456780123456123 -> 12.34567891234567890123456780123456 Inexact Rounded
-dqbas074 toSci 123.4567891234567890123456780123456123 -> 123.4567891234567890123456780123456 Inexact Rounded
-dqbas075 toSci 1234.567891234567890123456780123456123 -> 1234.567891234567890123456780123456 Inexact Rounded
-dqbas076 toSci 12345.67891234567890123456780123456123 -> 12345.67891234567890123456780123456 Inexact Rounded
-dqbas077 toSci 123456.7891234567890123456780123456123 -> 123456.7891234567890123456780123456 Inexact Rounded
-dqbas078 toSci 1234567.891234567890123456780123456123 -> 1234567.891234567890123456780123456 Inexact Rounded
-dqbas079 toSci 12345678.91234567890123456780123456123 -> 12345678.91234567890123456780123456 Inexact Rounded
-dqbas080 toSci 123456789.1234567890123456780123456123 -> 123456789.1234567890123456780123456 Inexact Rounded
-dqbas081 toSci 1234567891.234567890123456780123456123 -> 1234567891.234567890123456780123456 Inexact Rounded
-dqbas082 toSci 12345678912.34567890123456780123456123 -> 12345678912.34567890123456780123456 Inexact Rounded
-dqbas083 toSci 123456789123.4567890123456780123456123 -> 123456789123.4567890123456780123456 Inexact Rounded
-dqbas084 toSci 1234567891234.567890123456780123456123 -> 1234567891234.567890123456780123456 Inexact Rounded
-dqbas085 toSci 12345678912345.67890123456780123456123 -> 12345678912345.67890123456780123456 Inexact Rounded
-dqbas086 toSci 123456789123456.7890123456780123456123 -> 123456789123456.7890123456780123456 Inexact Rounded
-dqbas087 toSci 1234567891234567.890123456780123456123 -> 1234567891234567.890123456780123456 Inexact Rounded
-dqbas088 toSci 12345678912345678.90123456780123456123 -> 12345678912345678.90123456780123456 Inexact Rounded
-dqbas089 toSci 123456789123456789.0123456780123456123 -> 123456789123456789.0123456780123456 Inexact Rounded
-dqbas090 toSci 1234567891234567890.123456780123456123 -> 1234567891234567890.123456780123456 Inexact Rounded
-dqbas091 toSci 12345678912345678901.23456780123456123 -> 12345678912345678901.23456780123456 Inexact Rounded
-dqbas092 toSci 123456789123456789012.3456780123456123 -> 123456789123456789012.3456780123456 Inexact Rounded
-dqbas093 toSci 1234567891234567890123.456780123456123 -> 1234567891234567890123.456780123456 Inexact Rounded
-dqbas094 toSci 12345678912345678901234.56780123456123 -> 12345678912345678901234.56780123456 Inexact Rounded
-dqbas095 toSci 123456789123456789012345.6780123456123 -> 123456789123456789012345.6780123456 Inexact Rounded
-dqbas096 toSci 1234567891234567890123456.780123456123 -> 1234567891234567890123456.780123456 Inexact Rounded
-dqbas097 toSci 12345678912345678901234567.80123456123 -> 12345678912345678901234567.80123456 Inexact Rounded
-dqbas098 toSci 123456789123456789012345678.0123456123 -> 123456789123456789012345678.0123456 Inexact Rounded
-dqbas099 toSci 1234567891234567890123456780.123456123 -> 1234567891234567890123456780.123456 Inexact Rounded
-dqbas100 toSci 12345678912345678901234567801.23456123 -> 12345678912345678901234567801.23456 Inexact Rounded
-dqbas101 toSci 123456789123456789012345678012.3456123 -> 123456789123456789012345678012.3456 Inexact Rounded
-dqbas102 toSci 1234567891234567890123456780123.456123 -> 1234567891234567890123456780123.456 Inexact Rounded
-dqbas103 toSci 12345678912345678901234567801234.56123 -> 12345678912345678901234567801234.56 Inexact Rounded
-dqbas104 toSci 123456789123456789012345678012345.6123 -> 123456789123456789012345678012345.6 Inexact Rounded
-dqbas105 toSci 1234567891234567890123456780123456.123 -> 1234567891234567890123456780123456 Inexact Rounded
-dqbas106 toSci 12345678912345678901234567801234561.23 -> 1.234567891234567890123456780123456E+34 Inexact Rounded
-dqbas107 toSci 123456789123456789012345678012345612.3 -> 1.234567891234567890123456780123456E+35 Inexact Rounded
-dqbas108 toSci 1234567891234567890123456780123456123. -> 1.234567891234567890123456780123456E+36 Inexact Rounded
--- 123456789012345678
-
--- Numbers with E
-dqbas130 toSci "0.000E-1" -> '0.0000'
-dqbas131 toSci "0.000E-2" -> '0.00000'
-dqbas132 toSci "0.000E-3" -> '0.000000'
-dqbas133 toSci "0.000E-4" -> '0E-7'
-dqbas134 toSci "0.00E-2" -> '0.0000'
-dqbas135 toSci "0.00E-3" -> '0.00000'
-dqbas136 toSci "0.00E-4" -> '0.000000'
-dqbas137 toSci "0.00E-5" -> '0E-7'
-dqbas138 toSci "+0E+9" -> '0E+9'
-dqbas139 toSci "-0E+9" -> '-0E+9'
-dqbas140 toSci "1E+9" -> '1E+9'
-dqbas141 toSci "1e+09" -> '1E+9'
-dqbas142 toSci "1E+90" -> '1E+90'
-dqbas143 toSci "+1E+009" -> '1E+9'
-dqbas144 toSci "0E+9" -> '0E+9'
-dqbas145 toSci "1E+9" -> '1E+9'
-dqbas146 toSci "1E+09" -> '1E+9'
-dqbas147 toSci "1e+90" -> '1E+90'
-dqbas148 toSci "1E+009" -> '1E+9'
-dqbas149 toSci "000E+9" -> '0E+9'
-dqbas150 toSci "1E9" -> '1E+9'
-dqbas151 toSci "1e09" -> '1E+9'
-dqbas152 toSci "1E90" -> '1E+90'
-dqbas153 toSci "1E009" -> '1E+9'
-dqbas154 toSci "0E9" -> '0E+9'
-dqbas155 toSci "0.000e+0" -> '0.000'
-dqbas156 toSci "0.000E-1" -> '0.0000'
-dqbas157 toSci "4E+9" -> '4E+9'
-dqbas158 toSci "44E+9" -> '4.4E+10'
-dqbas159 toSci "0.73e-7" -> '7.3E-8'
-dqbas160 toSci "00E+9" -> '0E+9'
-dqbas161 toSci "00E-9" -> '0E-9'
-dqbas162 toSci "10E+9" -> '1.0E+10'
-dqbas163 toSci "10E+09" -> '1.0E+10'
-dqbas164 toSci "10e+90" -> '1.0E+91'
-dqbas165 toSci "10E+009" -> '1.0E+10'
-dqbas166 toSci "100e+9" -> '1.00E+11'
-dqbas167 toSci "100e+09" -> '1.00E+11'
-dqbas168 toSci "100E+90" -> '1.00E+92'
-dqbas169 toSci "100e+009" -> '1.00E+11'
-
-dqbas170 toSci "1.265" -> '1.265'
-dqbas171 toSci "1.265E-20" -> '1.265E-20'
-dqbas172 toSci "1.265E-8" -> '1.265E-8'
-dqbas173 toSci "1.265E-4" -> '0.0001265'
-dqbas174 toSci "1.265E-3" -> '0.001265'
-dqbas175 toSci "1.265E-2" -> '0.01265'
-dqbas176 toSci "1.265E-1" -> '0.1265'
-dqbas177 toSci "1.265E-0" -> '1.265'
-dqbas178 toSci "1.265E+1" -> '12.65'
-dqbas179 toSci "1.265E+2" -> '126.5'
-dqbas180 toSci "1.265E+3" -> '1265'
-dqbas181 toSci "1.265E+4" -> '1.265E+4'
-dqbas182 toSci "1.265E+8" -> '1.265E+8'
-dqbas183 toSci "1.265E+20" -> '1.265E+20'
-
-dqbas190 toSci "12.65" -> '12.65'
-dqbas191 toSci "12.65E-20" -> '1.265E-19'
-dqbas192 toSci "12.65E-8" -> '1.265E-7'
-dqbas193 toSci "12.65E-4" -> '0.001265'
-dqbas194 toSci "12.65E-3" -> '0.01265'
-dqbas195 toSci "12.65E-2" -> '0.1265'
-dqbas196 toSci "12.65E-1" -> '1.265'
-dqbas197 toSci "12.65E-0" -> '12.65'
-dqbas198 toSci "12.65E+1" -> '126.5'
-dqbas199 toSci "12.65E+2" -> '1265'
-dqbas200 toSci "12.65E+3" -> '1.265E+4'
-dqbas201 toSci "12.65E+4" -> '1.265E+5'
-dqbas202 toSci "12.65E+8" -> '1.265E+9'
-dqbas203 toSci "12.65E+20" -> '1.265E+21'
-
-dqbas210 toSci "126.5" -> '126.5'
-dqbas211 toSci "126.5E-20" -> '1.265E-18'
-dqbas212 toSci "126.5E-8" -> '0.000001265'
-dqbas213 toSci "126.5E-4" -> '0.01265'
-dqbas214 toSci "126.5E-3" -> '0.1265'
-dqbas215 toSci "126.5E-2" -> '1.265'
-dqbas216 toSci "126.5E-1" -> '12.65'
-dqbas217 toSci "126.5E-0" -> '126.5'
-dqbas218 toSci "126.5E+1" -> '1265'
-dqbas219 toSci "126.5E+2" -> '1.265E+4'
-dqbas220 toSci "126.5E+3" -> '1.265E+5'
-dqbas221 toSci "126.5E+4" -> '1.265E+6'
-dqbas222 toSci "126.5E+8" -> '1.265E+10'
-dqbas223 toSci "126.5E+20" -> '1.265E+22'
-
-dqbas230 toSci "1265" -> '1265'
-dqbas231 toSci "1265E-20" -> '1.265E-17'
-dqbas232 toSci "1265E-8" -> '0.00001265'
-dqbas233 toSci "1265E-4" -> '0.1265'
-dqbas234 toSci "1265E-3" -> '1.265'
-dqbas235 toSci "1265E-2" -> '12.65'
-dqbas236 toSci "1265E-1" -> '126.5'
-dqbas237 toSci "1265E-0" -> '1265'
-dqbas238 toSci "1265E+1" -> '1.265E+4'
-dqbas239 toSci "1265E+2" -> '1.265E+5'
-dqbas240 toSci "1265E+3" -> '1.265E+6'
-dqbas241 toSci "1265E+4" -> '1.265E+7'
-dqbas242 toSci "1265E+8" -> '1.265E+11'
-dqbas243 toSci "1265E+20" -> '1.265E+23'
-
-dqbas250 toSci "0.1265" -> '0.1265'
-dqbas251 toSci "0.1265E-20" -> '1.265E-21'
-dqbas252 toSci "0.1265E-8" -> '1.265E-9'
-dqbas253 toSci "0.1265E-4" -> '0.00001265'
-dqbas254 toSci "0.1265E-3" -> '0.0001265'
-dqbas255 toSci "0.1265E-2" -> '0.001265'
-dqbas256 toSci "0.1265E-1" -> '0.01265'
-dqbas257 toSci "0.1265E-0" -> '0.1265'
-dqbas258 toSci "0.1265E+1" -> '1.265'
-dqbas259 toSci "0.1265E+2" -> '12.65'
-dqbas260 toSci "0.1265E+3" -> '126.5'
-dqbas261 toSci "0.1265E+4" -> '1265'
-dqbas262 toSci "0.1265E+8" -> '1.265E+7'
-dqbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-dqbas290 toSci "-0.000E-1" -> '-0.0000'
-dqbas291 toSci "-0.000E-2" -> '-0.00000'
-dqbas292 toSci "-0.000E-3" -> '-0.000000'
-dqbas293 toSci "-0.000E-4" -> '-0E-7'
-dqbas294 toSci "-0.00E-2" -> '-0.0000'
-dqbas295 toSci "-0.00E-3" -> '-0.00000'
-dqbas296 toSci "-0.0E-2" -> '-0.000'
-dqbas297 toSci "-0.0E-3" -> '-0.0000'
-dqbas298 toSci "-0E-2" -> '-0.00'
-dqbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-dqbas301 toSci 10e12 -> 1.0E+13
-dqbas302 toEng 10e12 -> 10E+12
-dqbas303 toSci 10e11 -> 1.0E+12
-dqbas304 toEng 10e11 -> 1.0E+12
-dqbas305 toSci 10e10 -> 1.0E+11
-dqbas306 toEng 10e10 -> 100E+9
-dqbas307 toSci 10e9 -> 1.0E+10
-dqbas308 toEng 10e9 -> 10E+9
-dqbas309 toSci 10e8 -> 1.0E+9
-dqbas310 toEng 10e8 -> 1.0E+9
-dqbas311 toSci 10e7 -> 1.0E+8
-dqbas312 toEng 10e7 -> 100E+6
-dqbas313 toSci 10e6 -> 1.0E+7
-dqbas314 toEng 10e6 -> 10E+6
-dqbas315 toSci 10e5 -> 1.0E+6
-dqbas316 toEng 10e5 -> 1.0E+6
-dqbas317 toSci 10e4 -> 1.0E+5
-dqbas318 toEng 10e4 -> 100E+3
-dqbas319 toSci 10e3 -> 1.0E+4
-dqbas320 toEng 10e3 -> 10E+3
-dqbas321 toSci 10e2 -> 1.0E+3
-dqbas322 toEng 10e2 -> 1.0E+3
-dqbas323 toSci 10e1 -> 1.0E+2
-dqbas324 toEng 10e1 -> 100
-dqbas325 toSci 10e0 -> 10
-dqbas326 toEng 10e0 -> 10
-dqbas327 toSci 10e-1 -> 1.0
-dqbas328 toEng 10e-1 -> 1.0
-dqbas329 toSci 10e-2 -> 0.10
-dqbas330 toEng 10e-2 -> 0.10
-dqbas331 toSci 10e-3 -> 0.010
-dqbas332 toEng 10e-3 -> 0.010
-dqbas333 toSci 10e-4 -> 0.0010
-dqbas334 toEng 10e-4 -> 0.0010
-dqbas335 toSci 10e-5 -> 0.00010
-dqbas336 toEng 10e-5 -> 0.00010
-dqbas337 toSci 10e-6 -> 0.000010
-dqbas338 toEng 10e-6 -> 0.000010
-dqbas339 toSci 10e-7 -> 0.0000010
-dqbas340 toEng 10e-7 -> 0.0000010
-dqbas341 toSci 10e-8 -> 1.0E-7
-dqbas342 toEng 10e-8 -> 100E-9
-dqbas343 toSci 10e-9 -> 1.0E-8
-dqbas344 toEng 10e-9 -> 10E-9
-dqbas345 toSci 10e-10 -> 1.0E-9
-dqbas346 toEng 10e-10 -> 1.0E-9
-dqbas347 toSci 10e-11 -> 1.0E-10
-dqbas348 toEng 10e-11 -> 100E-12
-dqbas349 toSci 10e-12 -> 1.0E-11
-dqbas350 toEng 10e-12 -> 10E-12
-dqbas351 toSci 10e-13 -> 1.0E-12
-dqbas352 toEng 10e-13 -> 1.0E-12
-
-dqbas361 toSci 7E12 -> 7E+12
-dqbas362 toEng 7E12 -> 7E+12
-dqbas363 toSci 7E11 -> 7E+11
-dqbas364 toEng 7E11 -> 700E+9
-dqbas365 toSci 7E10 -> 7E+10
-dqbas366 toEng 7E10 -> 70E+9
-dqbas367 toSci 7E9 -> 7E+9
-dqbas368 toEng 7E9 -> 7E+9
-dqbas369 toSci 7E8 -> 7E+8
-dqbas370 toEng 7E8 -> 700E+6
-dqbas371 toSci 7E7 -> 7E+7
-dqbas372 toEng 7E7 -> 70E+6
-dqbas373 toSci 7E6 -> 7E+6
-dqbas374 toEng 7E6 -> 7E+6
-dqbas375 toSci 7E5 -> 7E+5
-dqbas376 toEng 7E5 -> 700E+3
-dqbas377 toSci 7E4 -> 7E+4
-dqbas378 toEng 7E4 -> 70E+3
-dqbas379 toSci 7E3 -> 7E+3
-dqbas380 toEng 7E3 -> 7E+3
-dqbas381 toSci 7E2 -> 7E+2
-dqbas382 toEng 7E2 -> 700
-dqbas383 toSci 7E1 -> 7E+1
-dqbas384 toEng 7E1 -> 70
-dqbas385 toSci 7E0 -> 7
-dqbas386 toEng 7E0 -> 7
-dqbas387 toSci 7E-1 -> 0.7
-dqbas388 toEng 7E-1 -> 0.7
-dqbas389 toSci 7E-2 -> 0.07
-dqbas390 toEng 7E-2 -> 0.07
-dqbas391 toSci 7E-3 -> 0.007
-dqbas392 toEng 7E-3 -> 0.007
-dqbas393 toSci 7E-4 -> 0.0007
-dqbas394 toEng 7E-4 -> 0.0007
-dqbas395 toSci 7E-5 -> 0.00007
-dqbas396 toEng 7E-5 -> 0.00007
-dqbas397 toSci 7E-6 -> 0.000007
-dqbas398 toEng 7E-6 -> 0.000007
-dqbas399 toSci 7E-7 -> 7E-7
-dqbas400 toEng 7E-7 -> 700E-9
-dqbas401 toSci 7E-8 -> 7E-8
-dqbas402 toEng 7E-8 -> 70E-9
-dqbas403 toSci 7E-9 -> 7E-9
-dqbas404 toEng 7E-9 -> 7E-9
-dqbas405 toSci 7E-10 -> 7E-10
-dqbas406 toEng 7E-10 -> 700E-12
-dqbas407 toSci 7E-11 -> 7E-11
-dqbas408 toEng 7E-11 -> 70E-12
-dqbas409 toSci 7E-12 -> 7E-12
-dqbas410 toEng 7E-12 -> 7E-12
-dqbas411 toSci 7E-13 -> 7E-13
-dqbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-dqbas420 toSci 100 -> 100
-dqbas422 toSci 1000 -> 1000
-dqbas424 toSci 999.9 -> 999.9
-dqbas426 toSci 1000.0 -> 1000.0
-dqbas428 toSci 1000.1 -> 1000.1
-dqbas430 toSci 10000 -> 10000
-dqbas432 toSci 1000000000000000000000000000000 -> 1000000000000000000000000000000
-dqbas434 toSci 10000000000000000000000000000000 -> 10000000000000000000000000000000
-dqbas436 toSci 100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqbas438 toSci 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqbas440 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
-dqbas442 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
-dqbas444 toSci 10000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
-dqbas446 toSci 10000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
-dqbas448 toSci 100000000000000000000000000000000050 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas450 toSci 10000000000000000000000000000000009 -> 1.000000000000000000000000000000001E+34 Rounded Inexact
-dqbas452 toSci 100000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+35 Rounded
-dqbas454 toSci 100000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas456 toSci 100000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas458 toSci 100000000000000000000000000000000009 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
-dqbas460 toSci 1000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+36 Rounded
-dqbas462 toSci 1000000000000000000000000000000000300 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
-dqbas464 toSci 1000000000000000000000000000000000500 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
-dqbas466 toSci 1000000000000000000000000000000000900 -> 1.000000000000000000000000000000001E+36 Rounded Inexact
-dqbas468 toSci 10000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+37 Rounded
-dqbas470 toSci 10000000000000000000000000000000003000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
-dqbas472 toSci 10000000000000000000000000000000005000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
-dqbas474 toSci 10000000000000000000000000000000009000 -> 1.000000000000000000000000000000001E+37 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-dqbsr401 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr402 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr403 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr404 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: up
-dqbsr405 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr406 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr407 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr408 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: floor
-dqbsr410 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr411 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr412 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr413 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_down
-dqbsr415 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr416 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr417 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr418 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr419 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_even
-dqbsr421 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr422 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr423 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr424 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr425 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
-rounding: down
-dqbsr426 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr427 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr428 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr429 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_up
-dqbsr431 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
-dqbsr432 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
-dqbsr433 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
-dqbsr434 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112347 Rounded Inexact
-dqbsr435 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
--- negatives
-rounding: ceiling
-dqbsr501 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr502 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr503 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr504 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
-rounding: up
-dqbsr505 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr506 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr507 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr508 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: floor
-dqbsr510 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr511 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr512 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr513 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_down
-dqbsr515 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr516 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr517 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr518 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr519 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: half_even
-dqbsr521 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr522 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr523 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr524 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr525 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-rounding: down
-dqbsr526 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr527 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr528 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr529 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
-rounding: half_up
-dqbsr531 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
-dqbsr532 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
-dqbsr533 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
-dqbsr534 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112347 Rounded Inexact
-dqbsr535 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-dqbas500 toSci '1..2' -> NaN Conversion_syntax
-dqbas501 toSci '.' -> NaN Conversion_syntax
-dqbas502 toSci '..' -> NaN Conversion_syntax
-dqbas503 toSci '++1' -> NaN Conversion_syntax
-dqbas504 toSci '--1' -> NaN Conversion_syntax
-dqbas505 toSci '-+1' -> NaN Conversion_syntax
-dqbas506 toSci '+-1' -> NaN Conversion_syntax
-dqbas507 toSci '12e' -> NaN Conversion_syntax
-dqbas508 toSci '12e++' -> NaN Conversion_syntax
-dqbas509 toSci '12f4' -> NaN Conversion_syntax
-dqbas510 toSci ' +1' -> NaN Conversion_syntax
-dqbas511 toSci '+ 1' -> NaN Conversion_syntax
-dqbas512 toSci '12 ' -> NaN Conversion_syntax
-dqbas513 toSci ' + 1' -> NaN Conversion_syntax
-dqbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-dqbas515 toSci 'x' -> NaN Conversion_syntax
-dqbas516 toSci '-1-' -> NaN Conversion_syntax
-dqbas517 toSci '12-' -> NaN Conversion_syntax
-dqbas518 toSci '3+' -> NaN Conversion_syntax
-dqbas519 toSci '' -> NaN Conversion_syntax
-dqbas520 toSci '1e-' -> NaN Conversion_syntax
-dqbas521 toSci '7e99999a' -> NaN Conversion_syntax
-dqbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-dqbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-dqbas524 toSci '' -> NaN Conversion_syntax
-dqbas525 toSci 'e100' -> NaN Conversion_syntax
-dqbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-dqbas527 toSci '\u0b65' -> NaN Conversion_syntax
-dqbas528 toSci '123,65' -> NaN Conversion_syntax
-dqbas529 toSci '1.34.5' -> NaN Conversion_syntax
-dqbas530 toSci '.123.5' -> NaN Conversion_syntax
-dqbas531 toSci '01.35.' -> NaN Conversion_syntax
-dqbas532 toSci '01.35-' -> NaN Conversion_syntax
-dqbas533 toSci '0000..' -> NaN Conversion_syntax
-dqbas534 toSci '.0000.' -> NaN Conversion_syntax
-dqbas535 toSci '00..00' -> NaN Conversion_syntax
-dqbas536 toSci '111e*123' -> NaN Conversion_syntax
-dqbas537 toSci '111e123-' -> NaN Conversion_syntax
-dqbas538 toSci '111e+12+' -> NaN Conversion_syntax
-dqbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-dqbas540 toSci '111e1*23' -> NaN Conversion_syntax
-dqbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-dqbas542 toSci '1e1.0' -> NaN Conversion_syntax
-dqbas543 toSci '1e123e' -> NaN Conversion_syntax
-dqbas544 toSci 'ten' -> NaN Conversion_syntax
-dqbas545 toSci 'ONE' -> NaN Conversion_syntax
-dqbas546 toSci '1e.1' -> NaN Conversion_syntax
-dqbas547 toSci '1e1.' -> NaN Conversion_syntax
-dqbas548 toSci '1ee' -> NaN Conversion_syntax
-dqbas549 toSci 'e+1' -> NaN Conversion_syntax
-dqbas550 toSci '1.23.4' -> NaN Conversion_syntax
-dqbas551 toSci '1.2.1' -> NaN Conversion_syntax
-dqbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-dqbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-dqbas554 toSci '1E++1' -> NaN Conversion_syntax
-dqbas555 toSci '1E--1' -> NaN Conversion_syntax
-dqbas556 toSci '1E+-1' -> NaN Conversion_syntax
-dqbas557 toSci '1E-+1' -> NaN Conversion_syntax
-dqbas558 toSci '1E''1' -> NaN Conversion_syntax
-dqbas559 toSci "1E""1" -> NaN Conversion_syntax
-dqbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-dqbas561 toSci "qNaN" -> NaN Conversion_syntax
-dqbas562 toSci "NaNq" -> NaN Conversion_syntax
-dqbas563 toSci "NaNs" -> NaN Conversion_syntax
-dqbas564 toSci "Infi" -> NaN Conversion_syntax
-dqbas565 toSci "Infin" -> NaN Conversion_syntax
-dqbas566 toSci "Infini" -> NaN Conversion_syntax
-dqbas567 toSci "Infinit" -> NaN Conversion_syntax
-dqbas568 toSci "-Infinit" -> NaN Conversion_syntax
-dqbas569 toSci "0Inf" -> NaN Conversion_syntax
-dqbas570 toSci "9Inf" -> NaN Conversion_syntax
-dqbas571 toSci "-0Inf" -> NaN Conversion_syntax
-dqbas572 toSci "-9Inf" -> NaN Conversion_syntax
-dqbas573 toSci "-sNa" -> NaN Conversion_syntax
-dqbas574 toSci "xNaN" -> NaN Conversion_syntax
-dqbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-dqbas576 toSci 'e+1' -> NaN Conversion_syntax
-dqbas577 toSci '.e+1' -> NaN Conversion_syntax
-dqbas578 toSci '+.e+1' -> NaN Conversion_syntax
-dqbas579 toSci '-.e+' -> NaN Conversion_syntax
-dqbas580 toSci '-.e' -> NaN Conversion_syntax
-dqbas581 toSci 'E+1' -> NaN Conversion_syntax
-dqbas582 toSci '.E+1' -> NaN Conversion_syntax
-dqbas583 toSci '+.E+1' -> NaN Conversion_syntax
-dqbas584 toSci '-.E+' -> NaN Conversion_syntax
-dqbas585 toSci '-.E' -> NaN Conversion_syntax
-
-dqbas586 toSci '.NaN' -> NaN Conversion_syntax
-dqbas587 toSci '-.NaN' -> NaN Conversion_syntax
-dqbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-dqbas589 toSci '+.Inf' -> NaN Conversion_syntax
-dqbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-dqbas601 toSci 0.000000000 -> 0E-9
-dqbas602 toSci 0.00000000 -> 0E-8
-dqbas603 toSci 0.0000000 -> 0E-7
-dqbas604 toSci 0.000000 -> 0.000000
-dqbas605 toSci 0.00000 -> 0.00000
-dqbas606 toSci 0.0000 -> 0.0000
-dqbas607 toSci 0.000 -> 0.000
-dqbas608 toSci 0.00 -> 0.00
-dqbas609 toSci 0.0 -> 0.0
-dqbas610 toSci .0 -> 0.0
-dqbas611 toSci 0. -> 0
-dqbas612 toSci -.0 -> -0.0
-dqbas613 toSci -0. -> -0
-dqbas614 toSci -0.0 -> -0.0
-dqbas615 toSci -0.00 -> -0.00
-dqbas616 toSci -0.000 -> -0.000
-dqbas617 toSci -0.0000 -> -0.0000
-dqbas618 toSci -0.00000 -> -0.00000
-dqbas619 toSci -0.000000 -> -0.000000
-dqbas620 toSci -0.0000000 -> -0E-7
-dqbas621 toSci -0.00000000 -> -0E-8
-dqbas622 toSci -0.000000000 -> -0E-9
-
-dqbas630 toSci 0.00E+0 -> 0.00
-dqbas631 toSci 0.00E+1 -> 0.0
-dqbas632 toSci 0.00E+2 -> 0
-dqbas633 toSci 0.00E+3 -> 0E+1
-dqbas634 toSci 0.00E+4 -> 0E+2
-dqbas635 toSci 0.00E+5 -> 0E+3
-dqbas636 toSci 0.00E+6 -> 0E+4
-dqbas637 toSci 0.00E+7 -> 0E+5
-dqbas638 toSci 0.00E+8 -> 0E+6
-dqbas639 toSci 0.00E+9 -> 0E+7
-
-dqbas640 toSci 0.0E+0 -> 0.0
-dqbas641 toSci 0.0E+1 -> 0
-dqbas642 toSci 0.0E+2 -> 0E+1
-dqbas643 toSci 0.0E+3 -> 0E+2
-dqbas644 toSci 0.0E+4 -> 0E+3
-dqbas645 toSci 0.0E+5 -> 0E+4
-dqbas646 toSci 0.0E+6 -> 0E+5
-dqbas647 toSci 0.0E+7 -> 0E+6
-dqbas648 toSci 0.0E+8 -> 0E+7
-dqbas649 toSci 0.0E+9 -> 0E+8
-
-dqbas650 toSci 0E+0 -> 0
-dqbas651 toSci 0E+1 -> 0E+1
-dqbas652 toSci 0E+2 -> 0E+2
-dqbas653 toSci 0E+3 -> 0E+3
-dqbas654 toSci 0E+4 -> 0E+4
-dqbas655 toSci 0E+5 -> 0E+5
-dqbas656 toSci 0E+6 -> 0E+6
-dqbas657 toSci 0E+7 -> 0E+7
-dqbas658 toSci 0E+8 -> 0E+8
-dqbas659 toSci 0E+9 -> 0E+9
-
-dqbas660 toSci 0.0E-0 -> 0.0
-dqbas661 toSci 0.0E-1 -> 0.00
-dqbas662 toSci 0.0E-2 -> 0.000
-dqbas663 toSci 0.0E-3 -> 0.0000
-dqbas664 toSci 0.0E-4 -> 0.00000
-dqbas665 toSci 0.0E-5 -> 0.000000
-dqbas666 toSci 0.0E-6 -> 0E-7
-dqbas667 toSci 0.0E-7 -> 0E-8
-dqbas668 toSci 0.0E-8 -> 0E-9
-dqbas669 toSci 0.0E-9 -> 0E-10
-
-dqbas670 toSci 0.00E-0 -> 0.00
-dqbas671 toSci 0.00E-1 -> 0.000
-dqbas672 toSci 0.00E-2 -> 0.0000
-dqbas673 toSci 0.00E-3 -> 0.00000
-dqbas674 toSci 0.00E-4 -> 0.000000
-dqbas675 toSci 0.00E-5 -> 0E-7
-dqbas676 toSci 0.00E-6 -> 0E-8
-dqbas677 toSci 0.00E-7 -> 0E-9
-dqbas678 toSci 0.00E-8 -> 0E-10
-dqbas679 toSci 0.00E-9 -> 0E-11
-
-dqbas680 toSci 000000. -> 0
-dqbas681 toSci 00000. -> 0
-dqbas682 toSci 0000. -> 0
-dqbas683 toSci 000. -> 0
-dqbas684 toSci 00. -> 0
-dqbas685 toSci 0. -> 0
-dqbas686 toSci +00000. -> 0
-dqbas687 toSci -00000. -> -0
-dqbas688 toSci +0. -> 0
-dqbas689 toSci -0. -> -0
-
--- Specials
-dqbas700 toSci "NaN" -> NaN
-dqbas701 toSci "nan" -> NaN
-dqbas702 toSci "nAn" -> NaN
-dqbas703 toSci "NAN" -> NaN
-dqbas704 toSci "+NaN" -> NaN
-dqbas705 toSci "+nan" -> NaN
-dqbas706 toSci "+nAn" -> NaN
-dqbas707 toSci "+NAN" -> NaN
-dqbas708 toSci "-NaN" -> -NaN
-dqbas709 toSci "-nan" -> -NaN
-dqbas710 toSci "-nAn" -> -NaN
-dqbas711 toSci "-NAN" -> -NaN
-dqbas712 toSci 'NaN0' -> NaN
-dqbas713 toSci 'NaN1' -> NaN1
-dqbas714 toSci 'NaN12' -> NaN12
-dqbas715 toSci 'NaN123' -> NaN123
-dqbas716 toSci 'NaN1234' -> NaN1234
-dqbas717 toSci 'NaN01' -> NaN1
-dqbas718 toSci 'NaN012' -> NaN12
-dqbas719 toSci 'NaN0123' -> NaN123
-dqbas720 toSci 'NaN01234' -> NaN1234
-dqbas721 toSci 'NaN001' -> NaN1
-dqbas722 toSci 'NaN0012' -> NaN12
-dqbas723 toSci 'NaN00123' -> NaN123
-dqbas724 toSci 'NaN001234' -> NaN1234
-dqbas725 toSci 'NaN1234567890123456781234567890123456' -> NaN Conversion_syntax
-dqbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-dqbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-dqbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-dqbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-dqbas730 toSci "sNaN" -> sNaN
-dqbas731 toSci "snan" -> sNaN
-dqbas732 toSci "SnAn" -> sNaN
-dqbas733 toSci "SNAN" -> sNaN
-dqbas734 toSci "+sNaN" -> sNaN
-dqbas735 toSci "+snan" -> sNaN
-dqbas736 toSci "+SnAn" -> sNaN
-dqbas737 toSci "+SNAN" -> sNaN
-dqbas738 toSci "-sNaN" -> -sNaN
-dqbas739 toSci "-snan" -> -sNaN
-dqbas740 toSci "-SnAn" -> -sNaN
-dqbas741 toSci "-SNAN" -> -sNaN
-dqbas742 toSci 'sNaN0000' -> sNaN
-dqbas743 toSci 'sNaN7' -> sNaN7
-dqbas744 toSci 'sNaN007234' -> sNaN7234
-dqbas745 toSci 'sNaN1234567890123456787234561234567890' -> NaN Conversion_syntax
-dqbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-dqbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-dqbas748 toSci "Inf" -> Infinity
-dqbas749 toSci "inf" -> Infinity
-dqbas750 toSci "iNf" -> Infinity
-dqbas751 toSci "INF" -> Infinity
-dqbas752 toSci "+Inf" -> Infinity
-dqbas753 toSci "+inf" -> Infinity
-dqbas754 toSci "+iNf" -> Infinity
-dqbas755 toSci "+INF" -> Infinity
-dqbas756 toSci "-Inf" -> -Infinity
-dqbas757 toSci "-inf" -> -Infinity
-dqbas758 toSci "-iNf" -> -Infinity
-dqbas759 toSci "-INF" -> -Infinity
-
-dqbas760 toSci "Infinity" -> Infinity
-dqbas761 toSci "infinity" -> Infinity
-dqbas762 toSci "iNfInItY" -> Infinity
-dqbas763 toSci "INFINITY" -> Infinity
-dqbas764 toSci "+Infinity" -> Infinity
-dqbas765 toSci "+infinity" -> Infinity
-dqbas766 toSci "+iNfInItY" -> Infinity
-dqbas767 toSci "+INFINITY" -> Infinity
-dqbas768 toSci "-Infinity" -> -Infinity
-dqbas769 toSci "-infinity" -> -Infinity
-dqbas770 toSci "-iNfInItY" -> -Infinity
-dqbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-dqbast772 toEng "NaN" -> NaN
-dqbast773 toEng "-Infinity" -> -Infinity
-dqbast774 toEng "-sNaN" -> -sNaN
-dqbast775 toEng "-NaN" -> -NaN
-dqbast776 toEng "+Infinity" -> Infinity
-dqbast778 toEng "+sNaN" -> sNaN
-dqbast779 toEng "+NaN" -> NaN
-dqbast780 toEng "INFINITY" -> Infinity
-dqbast781 toEng "SNAN" -> sNaN
-dqbast782 toEng "NAN" -> NaN
-dqbast783 toEng "infinity" -> Infinity
-dqbast784 toEng "snan" -> sNaN
-dqbast785 toEng "nan" -> NaN
-dqbast786 toEng "InFINITY" -> Infinity
-dqbast787 toEng "SnAN" -> sNaN
-dqbast788 toEng "nAN" -> NaN
-dqbast789 toEng "iNfinity" -> Infinity
-dqbast790 toEng "sNan" -> sNaN
-dqbast791 toEng "Nan" -> NaN
-dqbast792 toEng "Infinity" -> Infinity
-dqbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-dqbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-dqbast801 toEng 0.000000000 -> 0E-9
-dqbast802 toEng 0.00000000 -> 0.00E-6
-dqbast803 toEng 0.0000000 -> 0.0E-6
-dqbast804 toEng 0.000000 -> 0.000000
-dqbast805 toEng 0.00000 -> 0.00000
-dqbast806 toEng 0.0000 -> 0.0000
-dqbast807 toEng 0.000 -> 0.000
-dqbast808 toEng 0.00 -> 0.00
-dqbast809 toEng 0.0 -> 0.0
-dqbast810 toEng .0 -> 0.0
-dqbast811 toEng 0. -> 0
-dqbast812 toEng -.0 -> -0.0
-dqbast813 toEng -0. -> -0
-dqbast814 toEng -0.0 -> -0.0
-dqbast815 toEng -0.00 -> -0.00
-dqbast816 toEng -0.000 -> -0.000
-dqbast817 toEng -0.0000 -> -0.0000
-dqbast818 toEng -0.00000 -> -0.00000
-dqbast819 toEng -0.000000 -> -0.000000
-dqbast820 toEng -0.0000000 -> -0.0E-6
-dqbast821 toEng -0.00000000 -> -0.00E-6
-dqbast822 toEng -0.000000000 -> -0E-9
-
-dqbast830 toEng 0.00E+0 -> 0.00
-dqbast831 toEng 0.00E+1 -> 0.0
-dqbast832 toEng 0.00E+2 -> 0
-dqbast833 toEng 0.00E+3 -> 0.00E+3
-dqbast834 toEng 0.00E+4 -> 0.0E+3
-dqbast835 toEng 0.00E+5 -> 0E+3
-dqbast836 toEng 0.00E+6 -> 0.00E+6
-dqbast837 toEng 0.00E+7 -> 0.0E+6
-dqbast838 toEng 0.00E+8 -> 0E+6
-dqbast839 toEng 0.00E+9 -> 0.00E+9
-
-dqbast840 toEng 0.0E+0 -> 0.0
-dqbast841 toEng 0.0E+1 -> 0
-dqbast842 toEng 0.0E+2 -> 0.00E+3
-dqbast843 toEng 0.0E+3 -> 0.0E+3
-dqbast844 toEng 0.0E+4 -> 0E+3
-dqbast845 toEng 0.0E+5 -> 0.00E+6
-dqbast846 toEng 0.0E+6 -> 0.0E+6
-dqbast847 toEng 0.0E+7 -> 0E+6
-dqbast848 toEng 0.0E+8 -> 0.00E+9
-dqbast849 toEng 0.0E+9 -> 0.0E+9
-
-dqbast850 toEng 0E+0 -> 0
-dqbast851 toEng 0E+1 -> 0.00E+3
-dqbast852 toEng 0E+2 -> 0.0E+3
-dqbast853 toEng 0E+3 -> 0E+3
-dqbast854 toEng 0E+4 -> 0.00E+6
-dqbast855 toEng 0E+5 -> 0.0E+6
-dqbast856 toEng 0E+6 -> 0E+6
-dqbast857 toEng 0E+7 -> 0.00E+9
-dqbast858 toEng 0E+8 -> 0.0E+9
-dqbast859 toEng 0E+9 -> 0E+9
-
-dqbast860 toEng 0.0E-0 -> 0.0
-dqbast861 toEng 0.0E-1 -> 0.00
-dqbast862 toEng 0.0E-2 -> 0.000
-dqbast863 toEng 0.0E-3 -> 0.0000
-dqbast864 toEng 0.0E-4 -> 0.00000
-dqbast865 toEng 0.0E-5 -> 0.000000
-dqbast866 toEng 0.0E-6 -> 0.0E-6
-dqbast867 toEng 0.0E-7 -> 0.00E-6
-dqbast868 toEng 0.0E-8 -> 0E-9
-dqbast869 toEng 0.0E-9 -> 0.0E-9
-
-dqbast870 toEng 0.00E-0 -> 0.00
-dqbast871 toEng 0.00E-1 -> 0.000
-dqbast872 toEng 0.00E-2 -> 0.0000
-dqbast873 toEng 0.00E-3 -> 0.00000
-dqbast874 toEng 0.00E-4 -> 0.000000
-dqbast875 toEng 0.00E-5 -> 0.0E-6
-dqbast876 toEng 0.00E-6 -> 0.00E-6
-dqbast877 toEng 0.00E-7 -> 0E-9
-dqbast878 toEng 0.00E-8 -> 0.0E-9
-dqbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-dqbas801 tosci '01234567890123456' -> 1234567890123456
-dqbas802 tosci '001234567890123456' -> 1234567890123456
-dqbas803 tosci '0001234567890123456' -> 1234567890123456
-dqbas804 tosci '00001234567890123456' -> 1234567890123456
-dqbas805 tosci '000001234567890123456' -> 1234567890123456
-dqbas806 tosci '0000001234567890123456' -> 1234567890123456
-dqbas807 tosci '00000001234567890123456' -> 1234567890123456
-dqbas808 tosci '000000001234567890123456' -> 1234567890123456
-dqbas809 tosci '0000000001234567890123456' -> 1234567890123456
-dqbas810 tosci '00000000001234567890123456' -> 1234567890123456
-
-dqbas811 tosci '0.1234567890123456' -> 0.1234567890123456
-dqbas812 tosci '0.01234567890123456' -> 0.01234567890123456
-dqbas813 tosci '0.001234567890123456' -> 0.001234567890123456
-dqbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
-dqbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
-dqbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
-dqbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
-dqbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
-dqbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
-dqbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
-
-dqbas821 tosci '12345678912345678901234567801234567890' -> 1.234567891234567890123456780123457E+37 Inexact Rounded
-dqbas822 tosci '123456789123456789012345678012345678901' -> 1.234567891234567890123456780123457E+38 Inexact Rounded
-dqbas823 tosci '1234567891234567890123456780123456789012' -> 1.234567891234567890123456780123457E+39 Inexact Rounded
-dqbas824 tosci '12345678912345678901234567801234567890123' -> 1.234567891234567890123456780123457E+40 Inexact Rounded
-dqbas825 tosci '123456789123456789012345678012345678901234' -> 1.234567891234567890123456780123457E+41 Inexact Rounded
-dqbas826 tosci '1234567891234567890123456780123456789012345' -> 1.234567891234567890123456780123457E+42 Inexact Rounded
-dqbas827 tosci '12345678912345678901234567801234567890123456' -> 1.234567891234567890123456780123457E+43 Inexact Rounded
-dqbas828 tosci '123456789123456789012345678012345678901234567' -> 1.234567891234567890123456780123457E+44 Inexact Rounded
-dqbas829 tosci '1234567891234567890123456780123456789012345678' -> 1.234567891234567890123456780123457E+45 Inexact Rounded
-
--- subnormals and overflows
-dqbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-dqbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-dqbas908 toSci '0.9e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas909 toSci '0.09e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-dqbas911 toSci '10e-1000000000' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-dqbas913 toSci '99e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-dqbas915 toSci '1111e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas916 toSci '1111e-99999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-dqbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-dqbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-dqbas920 toSci '-0.9e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas921 toSci '-0.09e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-dqbas923 toSci '-10e-1000000000' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-dqbas925 toSci '-99e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-dqbas927 toSci '-1111e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas928 toSci '-1111e-99999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-dqbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas931 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-rounding: up
-dqbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-dqbas934 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqbas935 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-rounding: floor
-dqbas936 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-dqbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-dqbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-dqbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dqbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-dqbem400 toSci 1.0000E-383 -> 1.0000E-383
-dqbem401 toSci 0.1E-6172 -> 1E-6173 Subnormal
-dqbem402 toSci 0.1000E-6172 -> 1.000E-6173 Subnormal
-dqbem403 toSci 0.0100E-6172 -> 1.00E-6174 Subnormal
-dqbem404 toSci 0.0010E-6172 -> 1.0E-6175 Subnormal
-dqbem405 toSci 0.0001E-6172 -> 1E-6176 Subnormal
-dqbem406 toSci 0.00010E-6172 -> 1E-6176 Subnormal Rounded
-dqbem407 toSci 0.00013E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem408 toSci 0.00015E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem409 toSci 0.00017E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem410 toSci 0.00023E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem411 toSci 0.00025E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem412 toSci 0.00027E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqbem413 toSci 0.000149E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem414 toSci 0.000150E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem415 toSci 0.000151E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem416 toSci 0.000249E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem417 toSci 0.000250E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqbem418 toSci 0.000251E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqbem419 toSci 0.00009E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem420 toSci 0.00005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem421 toSci 0.00003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem422 toSci 0.000009E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem423 toSci 0.000005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem424 toSci 0.000003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqbem425 toSci 0.001049E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem426 toSci 0.001050E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem427 toSci 0.001051E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqbem428 toSci 0.001149E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqbem429 toSci 0.001150E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
-dqbem430 toSci 0.001151E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
-
-dqbem432 toSci 0.010049E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem433 toSci 0.010050E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem434 toSci 0.010051E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqbem435 toSci 0.010149E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqbem436 toSci 0.010150E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
-dqbem437 toSci 0.010151E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
-
-dqbem440 toSci 0.10103E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem441 toSci 0.10105E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem442 toSci 0.10107E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem443 toSci 0.10113E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem444 toSci 0.10115E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
-dqbem445 toSci 0.10117E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
-
-dqbem450 toSci 1.10730E-6173 -> 1.107E-6173 Underflow Subnormal Inexact Rounded
-dqbem451 toSci 1.10750E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem452 toSci 1.10770E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem453 toSci 1.10830E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem454 toSci 1.10850E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
-dqbem455 toSci 1.10870E-6173 -> 1.109E-6173 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-dqbem456 toSci -0.10103E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem457 toSci -0.10105E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
-dqbem458 toSci -0.10107E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem459 toSci -0.10113E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
-dqbem460 toSci -0.10115E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
-dqbem461 toSci -0.10117E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-dqbem464 toSci 999999E-6173 -> 9.99999E-6168 Subnormal
-dqbem465 toSci 99999.0E-6172 -> 9.99990E-6168 Subnormal
-dqbem466 toSci 99999.E-6172 -> 9.9999E-6168 Subnormal
-dqbem467 toSci 9999.9E-6172 -> 9.9999E-6169 Subnormal
-dqbem468 toSci 999.99E-6172 -> 9.9999E-6170 Subnormal
-dqbem469 toSci 99.999E-6172 -> 9.9999E-6171 Subnormal
-dqbem470 toSci 9.9999E-6172 -> 9.9999E-6172 Subnormal
-dqbem471 toSci 0.99999E-6172 -> 1.0000E-6172 Underflow Subnormal Inexact Rounded
-dqbem472 toSci 0.099999E-6172 -> 1.000E-6173 Underflow Subnormal Inexact Rounded
-dqbem473 toSci 0.0099999E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
-dqbem474 toSci 0.00099999E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
-dqbem475 toSci 0.000099999E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqbem476 toSci 0.0000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem477 toSci 0.00000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbem478 toSci 0.000000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-dqbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-dqbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-dqbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-dqbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-dqbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-dqbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-dqbas1007 toSci 1e-999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1008 toSci 1e-0999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1009 toSci 1e-00999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1010 toSci 1e-000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1011 toSci 1e-000000000000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqbas1012 toSci 1e-000000000001000000007 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-dqbas1041 toSci 1.1111111111111111111111111111152444E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-dqbas1042 toSci 1.1111111111111111111111111111152445E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-dqbas1043 toSci 1.1111111111111111111111111111152446E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
-
--- clamped zeros [see also clamp.decTest]
-dqbas1075 toSci 0e+10000 -> 0E+6111 Clamped
-dqbas1076 toSci 0e-10000 -> 0E-6176 Clamped
-dqbas1077 toSci -0e+10000 -> -0E+6111 Clamped
-dqbas1078 toSci -0e-10000 -> -0E-6176 Clamped
-
--- extreme values from next-wider
-dqbas1101 toSci -9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> -Infinity Overflow Inexact Rounded
-dqbas1102 toSci -1E-1572863 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1103 toSci -1E-1572932 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1104 toSci -0 -> -0
-dqbas1105 toSci +0 -> 0
-dqbas1106 toSci +1E-1572932 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1107 toSci +1E-1572863 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
-dqbas1108 toSci +9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> Infinity Overflow Inexact Rounded
-
+------------------------------------------------------------------------
+-- dqBase.decTest -- base decQuad <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decQuad. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqbas001 toSci 0 -> 0
+dqbas002 toSci 1 -> 1
+dqbas003 toSci 1.0 -> 1.0
+dqbas004 toSci 1.00 -> 1.00
+dqbas005 toSci 10 -> 10
+dqbas006 toSci 1000 -> 1000
+dqbas007 toSci 10.0 -> 10.0
+dqbas008 toSci 10.1 -> 10.1
+dqbas009 toSci 10.4 -> 10.4
+dqbas010 toSci 10.5 -> 10.5
+dqbas011 toSci 10.6 -> 10.6
+dqbas012 toSci 10.9 -> 10.9
+dqbas013 toSci 11.0 -> 11.0
+dqbas014 toSci 1.234 -> 1.234
+dqbas015 toSci 0.123 -> 0.123
+dqbas016 toSci 0.012 -> 0.012
+dqbas017 toSci -0 -> -0
+dqbas018 toSci -0.0 -> -0.0
+dqbas019 toSci -00.00 -> -0.00
+
+dqbas021 toSci -1 -> -1
+dqbas022 toSci -1.0 -> -1.0
+dqbas023 toSci -0.1 -> -0.1
+dqbas024 toSci -9.1 -> -9.1
+dqbas025 toSci -9.11 -> -9.11
+dqbas026 toSci -9.119 -> -9.119
+dqbas027 toSci -9.999 -> -9.999
+
+dqbas030 toSci '123456789.123456' -> '123456789.123456'
+dqbas031 toSci '123456789.000000' -> '123456789.000000'
+dqbas032 toSci '123456789123456' -> '123456789123456'
+dqbas033 toSci '0.0000123456789' -> '0.0000123456789'
+dqbas034 toSci '0.00000123456789' -> '0.00000123456789'
+dqbas035 toSci '0.000000123456789' -> '1.23456789E-7'
+dqbas036 toSci '0.0000000123456789' -> '1.23456789E-8'
+
+dqbas037 toSci '0.123456789012344' -> '0.123456789012344'
+dqbas038 toSci '0.123456789012345' -> '0.123456789012345'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+dqbsn001 toSci -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqbsn002 toSci -1E-6143 -> -1E-6143
+dqbsn003 toSci -1E-6176 -> -1E-6176 Subnormal
+dqbsn004 toSci -0 -> -0
+dqbsn005 toSci +0 -> 0
+dqbsn006 toSci +1E-6176 -> 1E-6176 Subnormal
+dqbsn007 toSci +1E-6143 -> 1E-6143
+dqbsn008 toSci +9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+dqbas040 toSci "12" -> '12'
+dqbas041 toSci "-76" -> '-76'
+dqbas042 toSci "12.76" -> '12.76'
+dqbas043 toSci "+12.76" -> '12.76'
+dqbas044 toSci "012.76" -> '12.76'
+dqbas045 toSci "+0.003" -> '0.003'
+dqbas046 toSci "17." -> '17'
+dqbas047 toSci ".5" -> '0.5'
+dqbas048 toSci "044" -> '44'
+dqbas049 toSci "0044" -> '44'
+dqbas050 toSci "0.0005" -> '0.0005'
+dqbas051 toSci "00.00005" -> '0.00005'
+dqbas052 toSci "0.000005" -> '0.000005'
+dqbas053 toSci "0.0000050" -> '0.0000050'
+dqbas054 toSci "0.0000005" -> '5E-7'
+dqbas055 toSci "0.00000005" -> '5E-8'
+dqbas056 toSci "12345678.543210" -> '12345678.543210'
+dqbas057 toSci "2345678.543210" -> '2345678.543210'
+dqbas058 toSci "345678.543210" -> '345678.543210'
+dqbas059 toSci "0345678.54321" -> '345678.54321'
+dqbas060 toSci "345678.5432" -> '345678.5432'
+dqbas061 toSci "+345678.5432" -> '345678.5432'
+dqbas062 toSci "+0345678.5432" -> '345678.5432'
+dqbas063 toSci "+00345678.5432" -> '345678.5432'
+dqbas064 toSci "-345678.5432" -> '-345678.5432'
+dqbas065 toSci "-0345678.5432" -> '-345678.5432'
+dqbas066 toSci "-00345678.5432" -> '-345678.5432'
+-- examples
+dqbas067 toSci "5E-6" -> '0.000005'
+dqbas068 toSci "50E-7" -> '0.0000050'
+dqbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+dqbas071 toSci .1234567891234567890123456780123456123 -> 0.1234567891234567890123456780123456 Inexact Rounded
+dqbas072 toSci 1.234567891234567890123456780123456123 -> 1.234567891234567890123456780123456 Inexact Rounded
+dqbas073 toSci 12.34567891234567890123456780123456123 -> 12.34567891234567890123456780123456 Inexact Rounded
+dqbas074 toSci 123.4567891234567890123456780123456123 -> 123.4567891234567890123456780123456 Inexact Rounded
+dqbas075 toSci 1234.567891234567890123456780123456123 -> 1234.567891234567890123456780123456 Inexact Rounded
+dqbas076 toSci 12345.67891234567890123456780123456123 -> 12345.67891234567890123456780123456 Inexact Rounded
+dqbas077 toSci 123456.7891234567890123456780123456123 -> 123456.7891234567890123456780123456 Inexact Rounded
+dqbas078 toSci 1234567.891234567890123456780123456123 -> 1234567.891234567890123456780123456 Inexact Rounded
+dqbas079 toSci 12345678.91234567890123456780123456123 -> 12345678.91234567890123456780123456 Inexact Rounded
+dqbas080 toSci 123456789.1234567890123456780123456123 -> 123456789.1234567890123456780123456 Inexact Rounded
+dqbas081 toSci 1234567891.234567890123456780123456123 -> 1234567891.234567890123456780123456 Inexact Rounded
+dqbas082 toSci 12345678912.34567890123456780123456123 -> 12345678912.34567890123456780123456 Inexact Rounded
+dqbas083 toSci 123456789123.4567890123456780123456123 -> 123456789123.4567890123456780123456 Inexact Rounded
+dqbas084 toSci 1234567891234.567890123456780123456123 -> 1234567891234.567890123456780123456 Inexact Rounded
+dqbas085 toSci 12345678912345.67890123456780123456123 -> 12345678912345.67890123456780123456 Inexact Rounded
+dqbas086 toSci 123456789123456.7890123456780123456123 -> 123456789123456.7890123456780123456 Inexact Rounded
+dqbas087 toSci 1234567891234567.890123456780123456123 -> 1234567891234567.890123456780123456 Inexact Rounded
+dqbas088 toSci 12345678912345678.90123456780123456123 -> 12345678912345678.90123456780123456 Inexact Rounded
+dqbas089 toSci 123456789123456789.0123456780123456123 -> 123456789123456789.0123456780123456 Inexact Rounded
+dqbas090 toSci 1234567891234567890.123456780123456123 -> 1234567891234567890.123456780123456 Inexact Rounded
+dqbas091 toSci 12345678912345678901.23456780123456123 -> 12345678912345678901.23456780123456 Inexact Rounded
+dqbas092 toSci 123456789123456789012.3456780123456123 -> 123456789123456789012.3456780123456 Inexact Rounded
+dqbas093 toSci 1234567891234567890123.456780123456123 -> 1234567891234567890123.456780123456 Inexact Rounded
+dqbas094 toSci 12345678912345678901234.56780123456123 -> 12345678912345678901234.56780123456 Inexact Rounded
+dqbas095 toSci 123456789123456789012345.6780123456123 -> 123456789123456789012345.6780123456 Inexact Rounded
+dqbas096 toSci 1234567891234567890123456.780123456123 -> 1234567891234567890123456.780123456 Inexact Rounded
+dqbas097 toSci 12345678912345678901234567.80123456123 -> 12345678912345678901234567.80123456 Inexact Rounded
+dqbas098 toSci 123456789123456789012345678.0123456123 -> 123456789123456789012345678.0123456 Inexact Rounded
+dqbas099 toSci 1234567891234567890123456780.123456123 -> 1234567891234567890123456780.123456 Inexact Rounded
+dqbas100 toSci 12345678912345678901234567801.23456123 -> 12345678912345678901234567801.23456 Inexact Rounded
+dqbas101 toSci 123456789123456789012345678012.3456123 -> 123456789123456789012345678012.3456 Inexact Rounded
+dqbas102 toSci 1234567891234567890123456780123.456123 -> 1234567891234567890123456780123.456 Inexact Rounded
+dqbas103 toSci 12345678912345678901234567801234.56123 -> 12345678912345678901234567801234.56 Inexact Rounded
+dqbas104 toSci 123456789123456789012345678012345.6123 -> 123456789123456789012345678012345.6 Inexact Rounded
+dqbas105 toSci 1234567891234567890123456780123456.123 -> 1234567891234567890123456780123456 Inexact Rounded
+dqbas106 toSci 12345678912345678901234567801234561.23 -> 1.234567891234567890123456780123456E+34 Inexact Rounded
+dqbas107 toSci 123456789123456789012345678012345612.3 -> 1.234567891234567890123456780123456E+35 Inexact Rounded
+dqbas108 toSci 1234567891234567890123456780123456123. -> 1.234567891234567890123456780123456E+36 Inexact Rounded
+-- 123456789012345678
+
+-- Numbers with E
+dqbas130 toSci "0.000E-1" -> '0.0000'
+dqbas131 toSci "0.000E-2" -> '0.00000'
+dqbas132 toSci "0.000E-3" -> '0.000000'
+dqbas133 toSci "0.000E-4" -> '0E-7'
+dqbas134 toSci "0.00E-2" -> '0.0000'
+dqbas135 toSci "0.00E-3" -> '0.00000'
+dqbas136 toSci "0.00E-4" -> '0.000000'
+dqbas137 toSci "0.00E-5" -> '0E-7'
+dqbas138 toSci "+0E+9" -> '0E+9'
+dqbas139 toSci "-0E+9" -> '-0E+9'
+dqbas140 toSci "1E+9" -> '1E+9'
+dqbas141 toSci "1e+09" -> '1E+9'
+dqbas142 toSci "1E+90" -> '1E+90'
+dqbas143 toSci "+1E+009" -> '1E+9'
+dqbas144 toSci "0E+9" -> '0E+9'
+dqbas145 toSci "1E+9" -> '1E+9'
+dqbas146 toSci "1E+09" -> '1E+9'
+dqbas147 toSci "1e+90" -> '1E+90'
+dqbas148 toSci "1E+009" -> '1E+9'
+dqbas149 toSci "000E+9" -> '0E+9'
+dqbas150 toSci "1E9" -> '1E+9'
+dqbas151 toSci "1e09" -> '1E+9'
+dqbas152 toSci "1E90" -> '1E+90'
+dqbas153 toSci "1E009" -> '1E+9'
+dqbas154 toSci "0E9" -> '0E+9'
+dqbas155 toSci "0.000e+0" -> '0.000'
+dqbas156 toSci "0.000E-1" -> '0.0000'
+dqbas157 toSci "4E+9" -> '4E+9'
+dqbas158 toSci "44E+9" -> '4.4E+10'
+dqbas159 toSci "0.73e-7" -> '7.3E-8'
+dqbas160 toSci "00E+9" -> '0E+9'
+dqbas161 toSci "00E-9" -> '0E-9'
+dqbas162 toSci "10E+9" -> '1.0E+10'
+dqbas163 toSci "10E+09" -> '1.0E+10'
+dqbas164 toSci "10e+90" -> '1.0E+91'
+dqbas165 toSci "10E+009" -> '1.0E+10'
+dqbas166 toSci "100e+9" -> '1.00E+11'
+dqbas167 toSci "100e+09" -> '1.00E+11'
+dqbas168 toSci "100E+90" -> '1.00E+92'
+dqbas169 toSci "100e+009" -> '1.00E+11'
+
+dqbas170 toSci "1.265" -> '1.265'
+dqbas171 toSci "1.265E-20" -> '1.265E-20'
+dqbas172 toSci "1.265E-8" -> '1.265E-8'
+dqbas173 toSci "1.265E-4" -> '0.0001265'
+dqbas174 toSci "1.265E-3" -> '0.001265'
+dqbas175 toSci "1.265E-2" -> '0.01265'
+dqbas176 toSci "1.265E-1" -> '0.1265'
+dqbas177 toSci "1.265E-0" -> '1.265'
+dqbas178 toSci "1.265E+1" -> '12.65'
+dqbas179 toSci "1.265E+2" -> '126.5'
+dqbas180 toSci "1.265E+3" -> '1265'
+dqbas181 toSci "1.265E+4" -> '1.265E+4'
+dqbas182 toSci "1.265E+8" -> '1.265E+8'
+dqbas183 toSci "1.265E+20" -> '1.265E+20'
+
+dqbas190 toSci "12.65" -> '12.65'
+dqbas191 toSci "12.65E-20" -> '1.265E-19'
+dqbas192 toSci "12.65E-8" -> '1.265E-7'
+dqbas193 toSci "12.65E-4" -> '0.001265'
+dqbas194 toSci "12.65E-3" -> '0.01265'
+dqbas195 toSci "12.65E-2" -> '0.1265'
+dqbas196 toSci "12.65E-1" -> '1.265'
+dqbas197 toSci "12.65E-0" -> '12.65'
+dqbas198 toSci "12.65E+1" -> '126.5'
+dqbas199 toSci "12.65E+2" -> '1265'
+dqbas200 toSci "12.65E+3" -> '1.265E+4'
+dqbas201 toSci "12.65E+4" -> '1.265E+5'
+dqbas202 toSci "12.65E+8" -> '1.265E+9'
+dqbas203 toSci "12.65E+20" -> '1.265E+21'
+
+dqbas210 toSci "126.5" -> '126.5'
+dqbas211 toSci "126.5E-20" -> '1.265E-18'
+dqbas212 toSci "126.5E-8" -> '0.000001265'
+dqbas213 toSci "126.5E-4" -> '0.01265'
+dqbas214 toSci "126.5E-3" -> '0.1265'
+dqbas215 toSci "126.5E-2" -> '1.265'
+dqbas216 toSci "126.5E-1" -> '12.65'
+dqbas217 toSci "126.5E-0" -> '126.5'
+dqbas218 toSci "126.5E+1" -> '1265'
+dqbas219 toSci "126.5E+2" -> '1.265E+4'
+dqbas220 toSci "126.5E+3" -> '1.265E+5'
+dqbas221 toSci "126.5E+4" -> '1.265E+6'
+dqbas222 toSci "126.5E+8" -> '1.265E+10'
+dqbas223 toSci "126.5E+20" -> '1.265E+22'
+
+dqbas230 toSci "1265" -> '1265'
+dqbas231 toSci "1265E-20" -> '1.265E-17'
+dqbas232 toSci "1265E-8" -> '0.00001265'
+dqbas233 toSci "1265E-4" -> '0.1265'
+dqbas234 toSci "1265E-3" -> '1.265'
+dqbas235 toSci "1265E-2" -> '12.65'
+dqbas236 toSci "1265E-1" -> '126.5'
+dqbas237 toSci "1265E-0" -> '1265'
+dqbas238 toSci "1265E+1" -> '1.265E+4'
+dqbas239 toSci "1265E+2" -> '1.265E+5'
+dqbas240 toSci "1265E+3" -> '1.265E+6'
+dqbas241 toSci "1265E+4" -> '1.265E+7'
+dqbas242 toSci "1265E+8" -> '1.265E+11'
+dqbas243 toSci "1265E+20" -> '1.265E+23'
+
+dqbas250 toSci "0.1265" -> '0.1265'
+dqbas251 toSci "0.1265E-20" -> '1.265E-21'
+dqbas252 toSci "0.1265E-8" -> '1.265E-9'
+dqbas253 toSci "0.1265E-4" -> '0.00001265'
+dqbas254 toSci "0.1265E-3" -> '0.0001265'
+dqbas255 toSci "0.1265E-2" -> '0.001265'
+dqbas256 toSci "0.1265E-1" -> '0.01265'
+dqbas257 toSci "0.1265E-0" -> '0.1265'
+dqbas258 toSci "0.1265E+1" -> '1.265'
+dqbas259 toSci "0.1265E+2" -> '12.65'
+dqbas260 toSci "0.1265E+3" -> '126.5'
+dqbas261 toSci "0.1265E+4" -> '1265'
+dqbas262 toSci "0.1265E+8" -> '1.265E+7'
+dqbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+dqbas290 toSci "-0.000E-1" -> '-0.0000'
+dqbas291 toSci "-0.000E-2" -> '-0.00000'
+dqbas292 toSci "-0.000E-3" -> '-0.000000'
+dqbas293 toSci "-0.000E-4" -> '-0E-7'
+dqbas294 toSci "-0.00E-2" -> '-0.0000'
+dqbas295 toSci "-0.00E-3" -> '-0.00000'
+dqbas296 toSci "-0.0E-2" -> '-0.000'
+dqbas297 toSci "-0.0E-3" -> '-0.0000'
+dqbas298 toSci "-0E-2" -> '-0.00'
+dqbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+dqbas301 toSci 10e12 -> 1.0E+13
+dqbas302 toEng 10e12 -> 10E+12
+dqbas303 toSci 10e11 -> 1.0E+12
+dqbas304 toEng 10e11 -> 1.0E+12
+dqbas305 toSci 10e10 -> 1.0E+11
+dqbas306 toEng 10e10 -> 100E+9
+dqbas307 toSci 10e9 -> 1.0E+10
+dqbas308 toEng 10e9 -> 10E+9
+dqbas309 toSci 10e8 -> 1.0E+9
+dqbas310 toEng 10e8 -> 1.0E+9
+dqbas311 toSci 10e7 -> 1.0E+8
+dqbas312 toEng 10e7 -> 100E+6
+dqbas313 toSci 10e6 -> 1.0E+7
+dqbas314 toEng 10e6 -> 10E+6
+dqbas315 toSci 10e5 -> 1.0E+6
+dqbas316 toEng 10e5 -> 1.0E+6
+dqbas317 toSci 10e4 -> 1.0E+5
+dqbas318 toEng 10e4 -> 100E+3
+dqbas319 toSci 10e3 -> 1.0E+4
+dqbas320 toEng 10e3 -> 10E+3
+dqbas321 toSci 10e2 -> 1.0E+3
+dqbas322 toEng 10e2 -> 1.0E+3
+dqbas323 toSci 10e1 -> 1.0E+2
+dqbas324 toEng 10e1 -> 100
+dqbas325 toSci 10e0 -> 10
+dqbas326 toEng 10e0 -> 10
+dqbas327 toSci 10e-1 -> 1.0
+dqbas328 toEng 10e-1 -> 1.0
+dqbas329 toSci 10e-2 -> 0.10
+dqbas330 toEng 10e-2 -> 0.10
+dqbas331 toSci 10e-3 -> 0.010
+dqbas332 toEng 10e-3 -> 0.010
+dqbas333 toSci 10e-4 -> 0.0010
+dqbas334 toEng 10e-4 -> 0.0010
+dqbas335 toSci 10e-5 -> 0.00010
+dqbas336 toEng 10e-5 -> 0.00010
+dqbas337 toSci 10e-6 -> 0.000010
+dqbas338 toEng 10e-6 -> 0.000010
+dqbas339 toSci 10e-7 -> 0.0000010
+dqbas340 toEng 10e-7 -> 0.0000010
+dqbas341 toSci 10e-8 -> 1.0E-7
+dqbas342 toEng 10e-8 -> 100E-9
+dqbas343 toSci 10e-9 -> 1.0E-8
+dqbas344 toEng 10e-9 -> 10E-9
+dqbas345 toSci 10e-10 -> 1.0E-9
+dqbas346 toEng 10e-10 -> 1.0E-9
+dqbas347 toSci 10e-11 -> 1.0E-10
+dqbas348 toEng 10e-11 -> 100E-12
+dqbas349 toSci 10e-12 -> 1.0E-11
+dqbas350 toEng 10e-12 -> 10E-12
+dqbas351 toSci 10e-13 -> 1.0E-12
+dqbas352 toEng 10e-13 -> 1.0E-12
+
+dqbas361 toSci 7E12 -> 7E+12
+dqbas362 toEng 7E12 -> 7E+12
+dqbas363 toSci 7E11 -> 7E+11
+dqbas364 toEng 7E11 -> 700E+9
+dqbas365 toSci 7E10 -> 7E+10
+dqbas366 toEng 7E10 -> 70E+9
+dqbas367 toSci 7E9 -> 7E+9
+dqbas368 toEng 7E9 -> 7E+9
+dqbas369 toSci 7E8 -> 7E+8
+dqbas370 toEng 7E8 -> 700E+6
+dqbas371 toSci 7E7 -> 7E+7
+dqbas372 toEng 7E7 -> 70E+6
+dqbas373 toSci 7E6 -> 7E+6
+dqbas374 toEng 7E6 -> 7E+6
+dqbas375 toSci 7E5 -> 7E+5
+dqbas376 toEng 7E5 -> 700E+3
+dqbas377 toSci 7E4 -> 7E+4
+dqbas378 toEng 7E4 -> 70E+3
+dqbas379 toSci 7E3 -> 7E+3
+dqbas380 toEng 7E3 -> 7E+3
+dqbas381 toSci 7E2 -> 7E+2
+dqbas382 toEng 7E2 -> 700
+dqbas383 toSci 7E1 -> 7E+1
+dqbas384 toEng 7E1 -> 70
+dqbas385 toSci 7E0 -> 7
+dqbas386 toEng 7E0 -> 7
+dqbas387 toSci 7E-1 -> 0.7
+dqbas388 toEng 7E-1 -> 0.7
+dqbas389 toSci 7E-2 -> 0.07
+dqbas390 toEng 7E-2 -> 0.07
+dqbas391 toSci 7E-3 -> 0.007
+dqbas392 toEng 7E-3 -> 0.007
+dqbas393 toSci 7E-4 -> 0.0007
+dqbas394 toEng 7E-4 -> 0.0007
+dqbas395 toSci 7E-5 -> 0.00007
+dqbas396 toEng 7E-5 -> 0.00007
+dqbas397 toSci 7E-6 -> 0.000007
+dqbas398 toEng 7E-6 -> 0.000007
+dqbas399 toSci 7E-7 -> 7E-7
+dqbas400 toEng 7E-7 -> 700E-9
+dqbas401 toSci 7E-8 -> 7E-8
+dqbas402 toEng 7E-8 -> 70E-9
+dqbas403 toSci 7E-9 -> 7E-9
+dqbas404 toEng 7E-9 -> 7E-9
+dqbas405 toSci 7E-10 -> 7E-10
+dqbas406 toEng 7E-10 -> 700E-12
+dqbas407 toSci 7E-11 -> 7E-11
+dqbas408 toEng 7E-11 -> 70E-12
+dqbas409 toSci 7E-12 -> 7E-12
+dqbas410 toEng 7E-12 -> 7E-12
+dqbas411 toSci 7E-13 -> 7E-13
+dqbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+dqbas420 toSci 100 -> 100
+dqbas422 toSci 1000 -> 1000
+dqbas424 toSci 999.9 -> 999.9
+dqbas426 toSci 1000.0 -> 1000.0
+dqbas428 toSci 1000.1 -> 1000.1
+dqbas430 toSci 10000 -> 10000
+dqbas432 toSci 1000000000000000000000000000000 -> 1000000000000000000000000000000
+dqbas434 toSci 10000000000000000000000000000000 -> 10000000000000000000000000000000
+dqbas436 toSci 100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqbas438 toSci 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqbas440 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
+dqbas442 toSci 10000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+34 Rounded
+dqbas444 toSci 10000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
+dqbas446 toSci 10000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+34 Rounded Inexact
+dqbas448 toSci 100000000000000000000000000000000050 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas450 toSci 10000000000000000000000000000000009 -> 1.000000000000000000000000000000001E+34 Rounded Inexact
+dqbas452 toSci 100000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+35 Rounded
+dqbas454 toSci 100000000000000000000000000000000003 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas456 toSci 100000000000000000000000000000000005 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas458 toSci 100000000000000000000000000000000009 -> 1.000000000000000000000000000000000E+35 Rounded Inexact
+dqbas460 toSci 1000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+36 Rounded
+dqbas462 toSci 1000000000000000000000000000000000300 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
+dqbas464 toSci 1000000000000000000000000000000000500 -> 1.000000000000000000000000000000000E+36 Rounded Inexact
+dqbas466 toSci 1000000000000000000000000000000000900 -> 1.000000000000000000000000000000001E+36 Rounded Inexact
+dqbas468 toSci 10000000000000000000000000000000000000 -> 1.000000000000000000000000000000000E+37 Rounded
+dqbas470 toSci 10000000000000000000000000000000003000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
+dqbas472 toSci 10000000000000000000000000000000005000 -> 1.000000000000000000000000000000000E+37 Rounded Inexact
+dqbas474 toSci 10000000000000000000000000000000009000 -> 1.000000000000000000000000000000001E+37 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+dqbsr401 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr402 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr403 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr404 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: up
+dqbsr405 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr406 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr407 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr408 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: floor
+dqbsr410 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr411 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr412 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr413 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_down
+dqbsr415 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr416 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr417 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr418 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr419 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_even
+dqbsr421 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr422 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr423 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr424 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr425 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+rounding: down
+dqbsr426 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr427 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr428 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr429 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_up
+dqbsr431 toSci 1.1111111111111111111111111111123450 -> 1.111111111111111111111111111112345 Rounded
+dqbsr432 toSci 1.11111111111111111111111111111234549 -> 1.111111111111111111111111111112345 Rounded Inexact
+dqbsr433 toSci 1.11111111111111111111111111111234550 -> 1.111111111111111111111111111112346 Rounded Inexact
+dqbsr434 toSci 1.11111111111111111111111111111234650 -> 1.111111111111111111111111111112347 Rounded Inexact
+dqbsr435 toSci 1.11111111111111111111111111111234551 -> 1.111111111111111111111111111112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+dqbsr501 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr502 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr503 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr504 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
+rounding: up
+dqbsr505 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr506 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr507 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr508 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: floor
+dqbsr510 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr511 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr512 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr513 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_down
+dqbsr515 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr516 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr517 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr518 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr519 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: half_even
+dqbsr521 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr522 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr523 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr524 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr525 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+rounding: down
+dqbsr526 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr527 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr528 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr529 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112345 Rounded Inexact
+rounding: half_up
+dqbsr531 toSci -1.1111111111111111111111111111123450 -> -1.111111111111111111111111111112345 Rounded
+dqbsr532 toSci -1.11111111111111111111111111111234549 -> -1.111111111111111111111111111112345 Rounded Inexact
+dqbsr533 toSci -1.11111111111111111111111111111234550 -> -1.111111111111111111111111111112346 Rounded Inexact
+dqbsr534 toSci -1.11111111111111111111111111111234650 -> -1.111111111111111111111111111112347 Rounded Inexact
+dqbsr535 toSci -1.11111111111111111111111111111234551 -> -1.111111111111111111111111111112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+dqbas500 toSci '1..2' -> NaN Conversion_syntax
+dqbas501 toSci '.' -> NaN Conversion_syntax
+dqbas502 toSci '..' -> NaN Conversion_syntax
+dqbas503 toSci '++1' -> NaN Conversion_syntax
+dqbas504 toSci '--1' -> NaN Conversion_syntax
+dqbas505 toSci '-+1' -> NaN Conversion_syntax
+dqbas506 toSci '+-1' -> NaN Conversion_syntax
+dqbas507 toSci '12e' -> NaN Conversion_syntax
+dqbas508 toSci '12e++' -> NaN Conversion_syntax
+dqbas509 toSci '12f4' -> NaN Conversion_syntax
+dqbas510 toSci ' +1' -> NaN Conversion_syntax
+dqbas511 toSci '+ 1' -> NaN Conversion_syntax
+dqbas512 toSci '12 ' -> NaN Conversion_syntax
+dqbas513 toSci ' + 1' -> NaN Conversion_syntax
+dqbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+dqbas515 toSci 'x' -> NaN Conversion_syntax
+dqbas516 toSci '-1-' -> NaN Conversion_syntax
+dqbas517 toSci '12-' -> NaN Conversion_syntax
+dqbas518 toSci '3+' -> NaN Conversion_syntax
+dqbas519 toSci '' -> NaN Conversion_syntax
+dqbas520 toSci '1e-' -> NaN Conversion_syntax
+dqbas521 toSci '7e99999a' -> NaN Conversion_syntax
+dqbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+dqbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+dqbas524 toSci '' -> NaN Conversion_syntax
+dqbas525 toSci 'e100' -> NaN Conversion_syntax
+dqbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+dqbas527 toSci '\u0b65' -> NaN Conversion_syntax
+dqbas528 toSci '123,65' -> NaN Conversion_syntax
+dqbas529 toSci '1.34.5' -> NaN Conversion_syntax
+dqbas530 toSci '.123.5' -> NaN Conversion_syntax
+dqbas531 toSci '01.35.' -> NaN Conversion_syntax
+dqbas532 toSci '01.35-' -> NaN Conversion_syntax
+dqbas533 toSci '0000..' -> NaN Conversion_syntax
+dqbas534 toSci '.0000.' -> NaN Conversion_syntax
+dqbas535 toSci '00..00' -> NaN Conversion_syntax
+dqbas536 toSci '111e*123' -> NaN Conversion_syntax
+dqbas537 toSci '111e123-' -> NaN Conversion_syntax
+dqbas538 toSci '111e+12+' -> NaN Conversion_syntax
+dqbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+dqbas540 toSci '111e1*23' -> NaN Conversion_syntax
+dqbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+dqbas542 toSci '1e1.0' -> NaN Conversion_syntax
+dqbas543 toSci '1e123e' -> NaN Conversion_syntax
+dqbas544 toSci 'ten' -> NaN Conversion_syntax
+dqbas545 toSci 'ONE' -> NaN Conversion_syntax
+dqbas546 toSci '1e.1' -> NaN Conversion_syntax
+dqbas547 toSci '1e1.' -> NaN Conversion_syntax
+dqbas548 toSci '1ee' -> NaN Conversion_syntax
+dqbas549 toSci 'e+1' -> NaN Conversion_syntax
+dqbas550 toSci '1.23.4' -> NaN Conversion_syntax
+dqbas551 toSci '1.2.1' -> NaN Conversion_syntax
+dqbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+dqbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+dqbas554 toSci '1E++1' -> NaN Conversion_syntax
+dqbas555 toSci '1E--1' -> NaN Conversion_syntax
+dqbas556 toSci '1E+-1' -> NaN Conversion_syntax
+dqbas557 toSci '1E-+1' -> NaN Conversion_syntax
+dqbas558 toSci '1E''1' -> NaN Conversion_syntax
+dqbas559 toSci "1E""1" -> NaN Conversion_syntax
+dqbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+dqbas561 toSci "qNaN" -> NaN Conversion_syntax
+dqbas562 toSci "NaNq" -> NaN Conversion_syntax
+dqbas563 toSci "NaNs" -> NaN Conversion_syntax
+dqbas564 toSci "Infi" -> NaN Conversion_syntax
+dqbas565 toSci "Infin" -> NaN Conversion_syntax
+dqbas566 toSci "Infini" -> NaN Conversion_syntax
+dqbas567 toSci "Infinit" -> NaN Conversion_syntax
+dqbas568 toSci "-Infinit" -> NaN Conversion_syntax
+dqbas569 toSci "0Inf" -> NaN Conversion_syntax
+dqbas570 toSci "9Inf" -> NaN Conversion_syntax
+dqbas571 toSci "-0Inf" -> NaN Conversion_syntax
+dqbas572 toSci "-9Inf" -> NaN Conversion_syntax
+dqbas573 toSci "-sNa" -> NaN Conversion_syntax
+dqbas574 toSci "xNaN" -> NaN Conversion_syntax
+dqbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+dqbas576 toSci 'e+1' -> NaN Conversion_syntax
+dqbas577 toSci '.e+1' -> NaN Conversion_syntax
+dqbas578 toSci '+.e+1' -> NaN Conversion_syntax
+dqbas579 toSci '-.e+' -> NaN Conversion_syntax
+dqbas580 toSci '-.e' -> NaN Conversion_syntax
+dqbas581 toSci 'E+1' -> NaN Conversion_syntax
+dqbas582 toSci '.E+1' -> NaN Conversion_syntax
+dqbas583 toSci '+.E+1' -> NaN Conversion_syntax
+dqbas584 toSci '-.E+' -> NaN Conversion_syntax
+dqbas585 toSci '-.E' -> NaN Conversion_syntax
+
+dqbas586 toSci '.NaN' -> NaN Conversion_syntax
+dqbas587 toSci '-.NaN' -> NaN Conversion_syntax
+dqbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+dqbas589 toSci '+.Inf' -> NaN Conversion_syntax
+dqbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+dqbas601 toSci 0.000000000 -> 0E-9
+dqbas602 toSci 0.00000000 -> 0E-8
+dqbas603 toSci 0.0000000 -> 0E-7
+dqbas604 toSci 0.000000 -> 0.000000
+dqbas605 toSci 0.00000 -> 0.00000
+dqbas606 toSci 0.0000 -> 0.0000
+dqbas607 toSci 0.000 -> 0.000
+dqbas608 toSci 0.00 -> 0.00
+dqbas609 toSci 0.0 -> 0.0
+dqbas610 toSci .0 -> 0.0
+dqbas611 toSci 0. -> 0
+dqbas612 toSci -.0 -> -0.0
+dqbas613 toSci -0. -> -0
+dqbas614 toSci -0.0 -> -0.0
+dqbas615 toSci -0.00 -> -0.00
+dqbas616 toSci -0.000 -> -0.000
+dqbas617 toSci -0.0000 -> -0.0000
+dqbas618 toSci -0.00000 -> -0.00000
+dqbas619 toSci -0.000000 -> -0.000000
+dqbas620 toSci -0.0000000 -> -0E-7
+dqbas621 toSci -0.00000000 -> -0E-8
+dqbas622 toSci -0.000000000 -> -0E-9
+
+dqbas630 toSci 0.00E+0 -> 0.00
+dqbas631 toSci 0.00E+1 -> 0.0
+dqbas632 toSci 0.00E+2 -> 0
+dqbas633 toSci 0.00E+3 -> 0E+1
+dqbas634 toSci 0.00E+4 -> 0E+2
+dqbas635 toSci 0.00E+5 -> 0E+3
+dqbas636 toSci 0.00E+6 -> 0E+4
+dqbas637 toSci 0.00E+7 -> 0E+5
+dqbas638 toSci 0.00E+8 -> 0E+6
+dqbas639 toSci 0.00E+9 -> 0E+7
+
+dqbas640 toSci 0.0E+0 -> 0.0
+dqbas641 toSci 0.0E+1 -> 0
+dqbas642 toSci 0.0E+2 -> 0E+1
+dqbas643 toSci 0.0E+3 -> 0E+2
+dqbas644 toSci 0.0E+4 -> 0E+3
+dqbas645 toSci 0.0E+5 -> 0E+4
+dqbas646 toSci 0.0E+6 -> 0E+5
+dqbas647 toSci 0.0E+7 -> 0E+6
+dqbas648 toSci 0.0E+8 -> 0E+7
+dqbas649 toSci 0.0E+9 -> 0E+8
+
+dqbas650 toSci 0E+0 -> 0
+dqbas651 toSci 0E+1 -> 0E+1
+dqbas652 toSci 0E+2 -> 0E+2
+dqbas653 toSci 0E+3 -> 0E+3
+dqbas654 toSci 0E+4 -> 0E+4
+dqbas655 toSci 0E+5 -> 0E+5
+dqbas656 toSci 0E+6 -> 0E+6
+dqbas657 toSci 0E+7 -> 0E+7
+dqbas658 toSci 0E+8 -> 0E+8
+dqbas659 toSci 0E+9 -> 0E+9
+
+dqbas660 toSci 0.0E-0 -> 0.0
+dqbas661 toSci 0.0E-1 -> 0.00
+dqbas662 toSci 0.0E-2 -> 0.000
+dqbas663 toSci 0.0E-3 -> 0.0000
+dqbas664 toSci 0.0E-4 -> 0.00000
+dqbas665 toSci 0.0E-5 -> 0.000000
+dqbas666 toSci 0.0E-6 -> 0E-7
+dqbas667 toSci 0.0E-7 -> 0E-8
+dqbas668 toSci 0.0E-8 -> 0E-9
+dqbas669 toSci 0.0E-9 -> 0E-10
+
+dqbas670 toSci 0.00E-0 -> 0.00
+dqbas671 toSci 0.00E-1 -> 0.000
+dqbas672 toSci 0.00E-2 -> 0.0000
+dqbas673 toSci 0.00E-3 -> 0.00000
+dqbas674 toSci 0.00E-4 -> 0.000000
+dqbas675 toSci 0.00E-5 -> 0E-7
+dqbas676 toSci 0.00E-6 -> 0E-8
+dqbas677 toSci 0.00E-7 -> 0E-9
+dqbas678 toSci 0.00E-8 -> 0E-10
+dqbas679 toSci 0.00E-9 -> 0E-11
+
+dqbas680 toSci 000000. -> 0
+dqbas681 toSci 00000. -> 0
+dqbas682 toSci 0000. -> 0
+dqbas683 toSci 000. -> 0
+dqbas684 toSci 00. -> 0
+dqbas685 toSci 0. -> 0
+dqbas686 toSci +00000. -> 0
+dqbas687 toSci -00000. -> -0
+dqbas688 toSci +0. -> 0
+dqbas689 toSci -0. -> -0
+
+-- Specials
+dqbas700 toSci "NaN" -> NaN
+dqbas701 toSci "nan" -> NaN
+dqbas702 toSci "nAn" -> NaN
+dqbas703 toSci "NAN" -> NaN
+dqbas704 toSci "+NaN" -> NaN
+dqbas705 toSci "+nan" -> NaN
+dqbas706 toSci "+nAn" -> NaN
+dqbas707 toSci "+NAN" -> NaN
+dqbas708 toSci "-NaN" -> -NaN
+dqbas709 toSci "-nan" -> -NaN
+dqbas710 toSci "-nAn" -> -NaN
+dqbas711 toSci "-NAN" -> -NaN
+dqbas712 toSci 'NaN0' -> NaN
+dqbas713 toSci 'NaN1' -> NaN1
+dqbas714 toSci 'NaN12' -> NaN12
+dqbas715 toSci 'NaN123' -> NaN123
+dqbas716 toSci 'NaN1234' -> NaN1234
+dqbas717 toSci 'NaN01' -> NaN1
+dqbas718 toSci 'NaN012' -> NaN12
+dqbas719 toSci 'NaN0123' -> NaN123
+dqbas720 toSci 'NaN01234' -> NaN1234
+dqbas721 toSci 'NaN001' -> NaN1
+dqbas722 toSci 'NaN0012' -> NaN12
+dqbas723 toSci 'NaN00123' -> NaN123
+dqbas724 toSci 'NaN001234' -> NaN1234
+dqbas725 toSci 'NaN1234567890123456781234567890123456' -> NaN Conversion_syntax
+dqbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+dqbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+dqbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+dqbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+dqbas730 toSci "sNaN" -> sNaN
+dqbas731 toSci "snan" -> sNaN
+dqbas732 toSci "SnAn" -> sNaN
+dqbas733 toSci "SNAN" -> sNaN
+dqbas734 toSci "+sNaN" -> sNaN
+dqbas735 toSci "+snan" -> sNaN
+dqbas736 toSci "+SnAn" -> sNaN
+dqbas737 toSci "+SNAN" -> sNaN
+dqbas738 toSci "-sNaN" -> -sNaN
+dqbas739 toSci "-snan" -> -sNaN
+dqbas740 toSci "-SnAn" -> -sNaN
+dqbas741 toSci "-SNAN" -> -sNaN
+dqbas742 toSci 'sNaN0000' -> sNaN
+dqbas743 toSci 'sNaN7' -> sNaN7
+dqbas744 toSci 'sNaN007234' -> sNaN7234
+dqbas745 toSci 'sNaN1234567890123456787234561234567890' -> NaN Conversion_syntax
+dqbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+dqbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+dqbas748 toSci "Inf" -> Infinity
+dqbas749 toSci "inf" -> Infinity
+dqbas750 toSci "iNf" -> Infinity
+dqbas751 toSci "INF" -> Infinity
+dqbas752 toSci "+Inf" -> Infinity
+dqbas753 toSci "+inf" -> Infinity
+dqbas754 toSci "+iNf" -> Infinity
+dqbas755 toSci "+INF" -> Infinity
+dqbas756 toSci "-Inf" -> -Infinity
+dqbas757 toSci "-inf" -> -Infinity
+dqbas758 toSci "-iNf" -> -Infinity
+dqbas759 toSci "-INF" -> -Infinity
+
+dqbas760 toSci "Infinity" -> Infinity
+dqbas761 toSci "infinity" -> Infinity
+dqbas762 toSci "iNfInItY" -> Infinity
+dqbas763 toSci "INFINITY" -> Infinity
+dqbas764 toSci "+Infinity" -> Infinity
+dqbas765 toSci "+infinity" -> Infinity
+dqbas766 toSci "+iNfInItY" -> Infinity
+dqbas767 toSci "+INFINITY" -> Infinity
+dqbas768 toSci "-Infinity" -> -Infinity
+dqbas769 toSci "-infinity" -> -Infinity
+dqbas770 toSci "-iNfInItY" -> -Infinity
+dqbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+dqbast772 toEng "NaN" -> NaN
+dqbast773 toEng "-Infinity" -> -Infinity
+dqbast774 toEng "-sNaN" -> -sNaN
+dqbast775 toEng "-NaN" -> -NaN
+dqbast776 toEng "+Infinity" -> Infinity
+dqbast778 toEng "+sNaN" -> sNaN
+dqbast779 toEng "+NaN" -> NaN
+dqbast780 toEng "INFINITY" -> Infinity
+dqbast781 toEng "SNAN" -> sNaN
+dqbast782 toEng "NAN" -> NaN
+dqbast783 toEng "infinity" -> Infinity
+dqbast784 toEng "snan" -> sNaN
+dqbast785 toEng "nan" -> NaN
+dqbast786 toEng "InFINITY" -> Infinity
+dqbast787 toEng "SnAN" -> sNaN
+dqbast788 toEng "nAN" -> NaN
+dqbast789 toEng "iNfinity" -> Infinity
+dqbast790 toEng "sNan" -> sNaN
+dqbast791 toEng "Nan" -> NaN
+dqbast792 toEng "Infinity" -> Infinity
+dqbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+dqbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+dqbast801 toEng 0.000000000 -> 0E-9
+dqbast802 toEng 0.00000000 -> 0.00E-6
+dqbast803 toEng 0.0000000 -> 0.0E-6
+dqbast804 toEng 0.000000 -> 0.000000
+dqbast805 toEng 0.00000 -> 0.00000
+dqbast806 toEng 0.0000 -> 0.0000
+dqbast807 toEng 0.000 -> 0.000
+dqbast808 toEng 0.00 -> 0.00
+dqbast809 toEng 0.0 -> 0.0
+dqbast810 toEng .0 -> 0.0
+dqbast811 toEng 0. -> 0
+dqbast812 toEng -.0 -> -0.0
+dqbast813 toEng -0. -> -0
+dqbast814 toEng -0.0 -> -0.0
+dqbast815 toEng -0.00 -> -0.00
+dqbast816 toEng -0.000 -> -0.000
+dqbast817 toEng -0.0000 -> -0.0000
+dqbast818 toEng -0.00000 -> -0.00000
+dqbast819 toEng -0.000000 -> -0.000000
+dqbast820 toEng -0.0000000 -> -0.0E-6
+dqbast821 toEng -0.00000000 -> -0.00E-6
+dqbast822 toEng -0.000000000 -> -0E-9
+
+dqbast830 toEng 0.00E+0 -> 0.00
+dqbast831 toEng 0.00E+1 -> 0.0
+dqbast832 toEng 0.00E+2 -> 0
+dqbast833 toEng 0.00E+3 -> 0.00E+3
+dqbast834 toEng 0.00E+4 -> 0.0E+3
+dqbast835 toEng 0.00E+5 -> 0E+3
+dqbast836 toEng 0.00E+6 -> 0.00E+6
+dqbast837 toEng 0.00E+7 -> 0.0E+6
+dqbast838 toEng 0.00E+8 -> 0E+6
+dqbast839 toEng 0.00E+9 -> 0.00E+9
+
+dqbast840 toEng 0.0E+0 -> 0.0
+dqbast841 toEng 0.0E+1 -> 0
+dqbast842 toEng 0.0E+2 -> 0.00E+3
+dqbast843 toEng 0.0E+3 -> 0.0E+3
+dqbast844 toEng 0.0E+4 -> 0E+3
+dqbast845 toEng 0.0E+5 -> 0.00E+6
+dqbast846 toEng 0.0E+6 -> 0.0E+6
+dqbast847 toEng 0.0E+7 -> 0E+6
+dqbast848 toEng 0.0E+8 -> 0.00E+9
+dqbast849 toEng 0.0E+9 -> 0.0E+9
+
+dqbast850 toEng 0E+0 -> 0
+dqbast851 toEng 0E+1 -> 0.00E+3
+dqbast852 toEng 0E+2 -> 0.0E+3
+dqbast853 toEng 0E+3 -> 0E+3
+dqbast854 toEng 0E+4 -> 0.00E+6
+dqbast855 toEng 0E+5 -> 0.0E+6
+dqbast856 toEng 0E+6 -> 0E+6
+dqbast857 toEng 0E+7 -> 0.00E+9
+dqbast858 toEng 0E+8 -> 0.0E+9
+dqbast859 toEng 0E+9 -> 0E+9
+
+dqbast860 toEng 0.0E-0 -> 0.0
+dqbast861 toEng 0.0E-1 -> 0.00
+dqbast862 toEng 0.0E-2 -> 0.000
+dqbast863 toEng 0.0E-3 -> 0.0000
+dqbast864 toEng 0.0E-4 -> 0.00000
+dqbast865 toEng 0.0E-5 -> 0.000000
+dqbast866 toEng 0.0E-6 -> 0.0E-6
+dqbast867 toEng 0.0E-7 -> 0.00E-6
+dqbast868 toEng 0.0E-8 -> 0E-9
+dqbast869 toEng 0.0E-9 -> 0.0E-9
+
+dqbast870 toEng 0.00E-0 -> 0.00
+dqbast871 toEng 0.00E-1 -> 0.000
+dqbast872 toEng 0.00E-2 -> 0.0000
+dqbast873 toEng 0.00E-3 -> 0.00000
+dqbast874 toEng 0.00E-4 -> 0.000000
+dqbast875 toEng 0.00E-5 -> 0.0E-6
+dqbast876 toEng 0.00E-6 -> 0.00E-6
+dqbast877 toEng 0.00E-7 -> 0E-9
+dqbast878 toEng 0.00E-8 -> 0.0E-9
+dqbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+dqbas801 tosci '01234567890123456' -> 1234567890123456
+dqbas802 tosci '001234567890123456' -> 1234567890123456
+dqbas803 tosci '0001234567890123456' -> 1234567890123456
+dqbas804 tosci '00001234567890123456' -> 1234567890123456
+dqbas805 tosci '000001234567890123456' -> 1234567890123456
+dqbas806 tosci '0000001234567890123456' -> 1234567890123456
+dqbas807 tosci '00000001234567890123456' -> 1234567890123456
+dqbas808 tosci '000000001234567890123456' -> 1234567890123456
+dqbas809 tosci '0000000001234567890123456' -> 1234567890123456
+dqbas810 tosci '00000000001234567890123456' -> 1234567890123456
+
+dqbas811 tosci '0.1234567890123456' -> 0.1234567890123456
+dqbas812 tosci '0.01234567890123456' -> 0.01234567890123456
+dqbas813 tosci '0.001234567890123456' -> 0.001234567890123456
+dqbas814 tosci '0.0001234567890123456' -> 0.0001234567890123456
+dqbas815 tosci '0.00001234567890123456' -> 0.00001234567890123456
+dqbas816 tosci '0.000001234567890123456' -> 0.000001234567890123456
+dqbas817 tosci '0.0000001234567890123456' -> 1.234567890123456E-7
+dqbas818 tosci '0.00000001234567890123456' -> 1.234567890123456E-8
+dqbas819 tosci '0.000000001234567890123456' -> 1.234567890123456E-9
+dqbas820 tosci '0.0000000001234567890123456' -> 1.234567890123456E-10
+
+dqbas821 tosci '12345678912345678901234567801234567890' -> 1.234567891234567890123456780123457E+37 Inexact Rounded
+dqbas822 tosci '123456789123456789012345678012345678901' -> 1.234567891234567890123456780123457E+38 Inexact Rounded
+dqbas823 tosci '1234567891234567890123456780123456789012' -> 1.234567891234567890123456780123457E+39 Inexact Rounded
+dqbas824 tosci '12345678912345678901234567801234567890123' -> 1.234567891234567890123456780123457E+40 Inexact Rounded
+dqbas825 tosci '123456789123456789012345678012345678901234' -> 1.234567891234567890123456780123457E+41 Inexact Rounded
+dqbas826 tosci '1234567891234567890123456780123456789012345' -> 1.234567891234567890123456780123457E+42 Inexact Rounded
+dqbas827 tosci '12345678912345678901234567801234567890123456' -> 1.234567891234567890123456780123457E+43 Inexact Rounded
+dqbas828 tosci '123456789123456789012345678012345678901234567' -> 1.234567891234567890123456780123457E+44 Inexact Rounded
+dqbas829 tosci '1234567891234567890123456780123456789012345678' -> 1.234567891234567890123456780123457E+45 Inexact Rounded
+
+-- subnormals and overflows
+dqbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+dqbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+dqbas908 toSci '0.9e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas909 toSci '0.09e-999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+dqbas911 toSci '10e-1000000000' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+dqbas913 toSci '99e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+dqbas915 toSci '1111e-9999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas916 toSci '1111e-99999999999' -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+dqbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+dqbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+dqbas920 toSci '-0.9e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas921 toSci '-0.09e-999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+dqbas923 toSci '-10e-1000000000' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+dqbas925 toSci '-99e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+dqbas927 toSci '-1111e-9999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas928 toSci '-1111e-99999999999' -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+dqbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas931 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+rounding: up
+dqbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+dqbas934 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqbas935 toSci '-7e10000' -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+rounding: floor
+dqbas936 toSci '7e10000' -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+dqbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+dqbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+dqbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dqbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+dqbem400 toSci 1.0000E-383 -> 1.0000E-383
+dqbem401 toSci 0.1E-6172 -> 1E-6173 Subnormal
+dqbem402 toSci 0.1000E-6172 -> 1.000E-6173 Subnormal
+dqbem403 toSci 0.0100E-6172 -> 1.00E-6174 Subnormal
+dqbem404 toSci 0.0010E-6172 -> 1.0E-6175 Subnormal
+dqbem405 toSci 0.0001E-6172 -> 1E-6176 Subnormal
+dqbem406 toSci 0.00010E-6172 -> 1E-6176 Subnormal Rounded
+dqbem407 toSci 0.00013E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem408 toSci 0.00015E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem409 toSci 0.00017E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem410 toSci 0.00023E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem411 toSci 0.00025E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem412 toSci 0.00027E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqbem413 toSci 0.000149E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem414 toSci 0.000150E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem415 toSci 0.000151E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem416 toSci 0.000249E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem417 toSci 0.000250E-6172 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqbem418 toSci 0.000251E-6172 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqbem419 toSci 0.00009E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem420 toSci 0.00005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem421 toSci 0.00003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem422 toSci 0.000009E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem423 toSci 0.000005E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem424 toSci 0.000003E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqbem425 toSci 0.001049E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem426 toSci 0.001050E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem427 toSci 0.001051E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqbem428 toSci 0.001149E-6172 -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqbem429 toSci 0.001150E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
+dqbem430 toSci 0.001151E-6172 -> 1.2E-6175 Underflow Subnormal Inexact Rounded
+
+dqbem432 toSci 0.010049E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem433 toSci 0.010050E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem434 toSci 0.010051E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqbem435 toSci 0.010149E-6172 -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqbem436 toSci 0.010150E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
+dqbem437 toSci 0.010151E-6172 -> 1.02E-6174 Underflow Subnormal Inexact Rounded
+
+dqbem440 toSci 0.10103E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem441 toSci 0.10105E-6172 -> 1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem442 toSci 0.10107E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem443 toSci 0.10113E-6172 -> 1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem444 toSci 0.10115E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
+dqbem445 toSci 0.10117E-6172 -> 1.012E-6173 Underflow Subnormal Inexact Rounded
+
+dqbem450 toSci 1.10730E-6173 -> 1.107E-6173 Underflow Subnormal Inexact Rounded
+dqbem451 toSci 1.10750E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem452 toSci 1.10770E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem453 toSci 1.10830E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem454 toSci 1.10850E-6173 -> 1.108E-6173 Underflow Subnormal Inexact Rounded
+dqbem455 toSci 1.10870E-6173 -> 1.109E-6173 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+dqbem456 toSci -0.10103E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem457 toSci -0.10105E-6172 -> -1.010E-6173 Underflow Subnormal Inexact Rounded
+dqbem458 toSci -0.10107E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem459 toSci -0.10113E-6172 -> -1.011E-6173 Underflow Subnormal Inexact Rounded
+dqbem460 toSci -0.10115E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
+dqbem461 toSci -0.10117E-6172 -> -1.012E-6173 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+dqbem464 toSci 999999E-6173 -> 9.99999E-6168 Subnormal
+dqbem465 toSci 99999.0E-6172 -> 9.99990E-6168 Subnormal
+dqbem466 toSci 99999.E-6172 -> 9.9999E-6168 Subnormal
+dqbem467 toSci 9999.9E-6172 -> 9.9999E-6169 Subnormal
+dqbem468 toSci 999.99E-6172 -> 9.9999E-6170 Subnormal
+dqbem469 toSci 99.999E-6172 -> 9.9999E-6171 Subnormal
+dqbem470 toSci 9.9999E-6172 -> 9.9999E-6172 Subnormal
+dqbem471 toSci 0.99999E-6172 -> 1.0000E-6172 Underflow Subnormal Inexact Rounded
+dqbem472 toSci 0.099999E-6172 -> 1.000E-6173 Underflow Subnormal Inexact Rounded
+dqbem473 toSci 0.0099999E-6172 -> 1.00E-6174 Underflow Subnormal Inexact Rounded
+dqbem474 toSci 0.00099999E-6172 -> 1.0E-6175 Underflow Subnormal Inexact Rounded
+dqbem475 toSci 0.000099999E-6172 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqbem476 toSci 0.0000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem477 toSci 0.00000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbem478 toSci 0.000000099999E-6172 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+dqbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+dqbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+dqbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+dqbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+dqbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+dqbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+dqbas1007 toSci 1e-999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1008 toSci 1e-0999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1009 toSci 1e-00999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1010 toSci 1e-000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1011 toSci 1e-000000000000999999999 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqbas1012 toSci 1e-000000000001000000007 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+dqbas1041 toSci 1.1111111111111111111111111111152444E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+dqbas1042 toSci 1.1111111111111111111111111111152445E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+dqbas1043 toSci 1.1111111111111111111111111111152446E-6144 -> 1.11111111111111111111111111111524E-6144 Inexact Rounded Subnormal Underflow
+
+-- clamped zeros [see also clamp.decTest]
+dqbas1075 toSci 0e+10000 -> 0E+6111 Clamped
+dqbas1076 toSci 0e-10000 -> 0E-6176 Clamped
+dqbas1077 toSci -0e+10000 -> -0E+6111 Clamped
+dqbas1078 toSci -0e-10000 -> -0E-6176 Clamped
+
+-- extreme values from next-wider
+dqbas1101 toSci -9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> -Infinity Overflow Inexact Rounded
+dqbas1102 toSci -1E-1572863 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1103 toSci -1E-1572932 -> -0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1104 toSci -0 -> -0
+dqbas1105 toSci +0 -> 0
+dqbas1106 toSci +1E-1572932 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1107 toSci +1E-1572863 -> 0E-6176 Inexact Rounded Subnormal Underflow Clamped
+dqbas1108 toSci +9.9999999999999999999999999999999999999999999999999999999999999999999E+1572864 -> Infinity Overflow Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/dqCanonical.decTest b/Lib/test/decimaltestdata/dqCanonical.decTest
index 006db8595ca..3ddf6eab2da 100644
--- a/Lib/test/decimaltestdata/dqCanonical.decTest
+++ b/Lib/test/decimaltestdata/dqCanonical.decTest
@@ -1,372 +1,372 @@
-------------------------------------------------------------------------
--- dqCanonical.decTest -- test decQuad canonical results --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests that copy operations leave uncanonical operands
--- unchanged, and vice versa
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Uncanonical declets are: abc, where:
--- a=1,2,3
--- b=6,7,e,f
--- c=e,f
-
--- assert some standard (canonical) values; this tests that FromString
--- produces canonical results (many more in decimalNN)
-dqcan001 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan002 apply 0 -> #22080000000000000000000000000000
-dqcan003 apply 1 -> #22080000000000000000000000000001
-dqcan004 apply -1 -> #a2080000000000000000000000000001
-dqcan005 apply Infinity -> #78000000000000000000000000000000
-dqcan006 apply -Infinity -> #f8000000000000000000000000000000
-dqcan007 apply -NaN -> #fc000000000000000000000000000000
-dqcan008 apply -sNaN -> #fe000000000000000000000000000000
-dqcan009 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan010 apply sNaN999999999999999999999999999999999 -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-decan011 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-dqcan012 apply 7.50 -> #220780000000000000000000000003d0
-dqcan013 apply 9.99 -> #220780000000000000000000000000ff
-
--- Base tests for canonical encodings (individual operator
--- propagation is tested later)
-
--- Finites: declets in coefficient
-dqcan021 canonical #77ffcff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan022 canonical #77fffff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan023 canonical #77ffcffffcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan024 canonical #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan025 canonical #77ffcff3fcffffcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan026 canonical #77ffcff3fcff3ffff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan027 canonical #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan028 canonical #77ffcff3fcff3fcff3ffff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan029 canonical #77ffcff3fcff3fcff3fcffffcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan030 canonical #77ffcff3fcff3fcff3fcff3ffff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan031 canonical #77ffcff3fcff3fcff3fcff3fcffffcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan032 canonical #77ffcff3fcff3fcff3fcff3fcff3ffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-
--- NaN: declets in payload
-dqcan061 canonical #7c000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan062 canonical #7c000ffffcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan063 canonical #7c000ff3ffff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan064 canonical #7c000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan065 canonical #7c000ff3fcff3ffff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan066 canonical #7c000ff3fcff3fcffffcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan067 canonical #7c000ff3fcff3fcff3ffff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan068 canonical #7c000ff3fcff3fcff3fcffffcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan069 canonical #7c000ff3fcff3fcff3fcff3ffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan070 canonical #7c000ff3fcff3fcff3fcff3fcffffcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan071 canonical #7c000ff3fcff3fcff3fcff3fcff3ffff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan081 canonical #7d000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan082 canonical #7c800ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan083 canonical #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan084 canonical #7c200ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan085 canonical #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan086 canonical #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan087 canonical #7c040ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan088 canonical #7c020ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan089 canonical #7c010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan090 canonical #7c008ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan091 canonical #7c004ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-
--- sNaN: declets in payload
-dqcan101 canonical #7e000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan102 canonical #7e000ffffcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan103 canonical #7e000ff3ffff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan104 canonical #7e000ff3fcffffcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan105 canonical #7e000ff3fcff3ffff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan106 canonical #7e000ff3fcff3fcffffcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan107 canonical #7e000ff3fcff3fcff3ffff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan108 canonical #7e000ff3fcff3fcff3fcffffcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan109 canonical #7e000ff3fcff3fcff3fcff3ffff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan100 canonical #7e000ff3fcff3fcff3fcff3fcffffcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan111 canonical #7e000ff3fcff3fcff3fcff3fcff3ffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan121 canonical #7f000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan122 canonical #7e800ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan123 canonical #7e400ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan124 canonical #7e200ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan125 canonical #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan126 canonical #7e080ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan127 canonical #7e040ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan128 canonical #7e020ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan129 canonical #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan130 canonical #7e008ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-dqcan131 canonical #7e004ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-
--- Inf: exponent continuation bits
-dqcan137 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan138 canonical #79000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan139 canonical #7a000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan140 canonical #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan141 canonical #78400000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan142 canonical #78200000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan143 canonical #78100000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan144 canonical #78080000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan145 canonical #78040000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan146 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan147 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan148 canonical #78008000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan149 canonical #78004000000000000000000000000000 -> #78000000000000000000000000000000
-
--- Inf: coefficient continuation bits (first, last, and a few others)
-dqcan150 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan151 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan152 canonical #78000000000000000000000000000001 -> #78000000000000000000000000000000
-dqcan153 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan154 canonical #78002000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan155 canonical #78000800000000000000000000000000 -> #78000000000000000000000000000000
-dqcan156 canonical #78000020000000000000000000000000 -> #78000000000000000000000000000000
-dqcan157 canonical #78000004000000000000000000000000 -> #78000000000000000000000000000000
-dqcan158 canonical #78000000400000000000000000000000 -> #78000000000000000000000000000000
-dqcan159 canonical #78000000080000000000000000000000 -> #78000000000000000000000000000000
-dqcan160 canonical #78000000004000000000000000000000 -> #78000000000000000000000000000000
-dqcan161 canonical #78000000000200000000000000000000 -> #78000000000000000000000000000000
-dqcan162 canonical #78000000000080000000000000000000 -> #78000000000000000000000000000000
-dqcan163 canonical #78000000000002000000000000000000 -> #78000000000000000000000000000000
-dqcan164 canonical #78000000000000400000000000000000 -> #78000000000000000000000000000000
-dqcan165 canonical #78000000000000080000000000000000 -> #78000000000000000000000000000000
-dqcan166 canonical #78000000000000001000000000000000 -> #78000000000000000000000000000000
-dqcan167 canonical #78000000000000000200000000000000 -> #78000000000000000000000000000000
-dqcan168 canonical #78000000000000000080000000000000 -> #78000000000000000000000000000000
-dqcan169 canonical #78000000000000000004000000000000 -> #78000000000000000000000000000000
-dqcan170 canonical #78000000000000000000400000000000 -> #78000000000000000000000000000000
-dqcan171 canonical #78000000000000000000010000000000 -> #78000000000000000000000000000000
-dqcan172 canonical #78000000000000000000002000000000 -> #78000000000000000000000000000000
-dqcan173 canonical #78000000000000000000000400000000 -> #78000000000000000000000000000000
-dqcan174 canonical #78000000000000000000000080000000 -> #78000000000000000000000000000000
-dqcan175 canonical #78000000000000000000000002000000 -> #78000000000000000000000000000000
-dqcan176 canonical #78000000000000000000000000400000 -> #78000000000000000000000000000000
-dqcan177 canonical #78000000000000000000000000020000 -> #78000000000000000000000000000000
-dqcan178 canonical #78000000000000000000000000001000 -> #78000000000000000000000000000000
-dqcan179 canonical #78000000000000000000000000000400 -> #78000000000000000000000000000000
-dqcan180 canonical #78000000000000000000000000000020 -> #78000000000000000000000000000000
-dqcan181 canonical #78000000000000000000000000000008 -> #78000000000000000000000000000000
-
-
--- Now the operators -- trying to check paths that might fail to
--- canonicalize propagated operands
-
------ Add:
--- Finites: neutral 0
-dqcan202 add 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan203 add #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
--- tiny zero
-dqcan204 add 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-dqcan205 add #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
--- tiny non zero
-dqcan206 add -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-dqcan207 add #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-dqcan211 add 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan212 add #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan213 add 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan214 add #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: declets in payload
-dqcan215 add 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan216 add #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan217 add 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan218 add #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-dqcan220 add 0 #78010000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan221 add #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan222 add 0 #78002000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan223 add #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
-dqcan224 add 0 #78000002000000000000000000000000 -> #78000000000000000000000000000000
-dqcan225 add #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
-dqcan226 add 0 #78000000000000000005000000000000 -> #78000000000000000000000000000000
-dqcan227 add #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
-
------ Class: [does not return encoded]
-
------ Compare:
-dqcan231 compare -Inf 1 -> #a2080000000000000000000000000001
-dqcan232 compare -Inf -Inf -> #22080000000000000000000000000000
-dqcan233 compare 1 -Inf -> #22080000000000000000000000000001
-dqcan234 compare #7c010ff3fcff3fcff3fcff3ffffffcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan235 compare #7e004ff3fcff3fcff3ffffffcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ CompareSig:
-dqcan241 comparesig -Inf 1 -> #a2080000000000000000000000000001
-dqcan242 comparesig -Inf -Inf -> #22080000000000000000000000000000
-dqcan243 comparesig 1 -Inf -> #22080000000000000000000000000001
-dqcan244 comparesig #7c400ff3ffff3fcff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan245 comparesig #7e050ff3fcfffffff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ Copy: [does not usually canonicalize]
--- finites
-dqcan250 copy #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
-dqcan251 copy #ee080ff3fcff3ffff3fcff3ffff3fcff -> #ee080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan252 copy #7c000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
-dqcan253 copy #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan254 copy #7e003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
-dqcan255 copy #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan258 copy #78002000000000000000000000000000 -> #78002000000000000000000000000000
-dqcan259 copy #78000000000010000000000000100000 -> #78000000000010000000000000100000
-
------ CopyAbs: [does not usually canonicalize]
--- finites
-dqcan260 copyabs #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
-dqcan261 copyabs #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan262 copyabs #fc000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
-dqcan263 copyabs #fc080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan264 copyabs #fe003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
-dqcan265 copyabs #fe100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan268 copyabs #f8002000000000000000000000000000 -> #78002000000000000000000000000000
-dqcan269 copyabs #f8000000000000700700700000000000 -> #78000000000000700700700000000000
-
------ CopyNegate: [does not usually canonicalize]
--- finites
-dqcan270 copynegate #6e080ff3fcff3fcfffffff3fcfffffff -> #ee080ff3fcff3fcfffffff3fcfffffff
-dqcan271 copynegate #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan272 copynegate #7c000ff3fcffffffffffff3fcff3fcff -> #fc000ff3fcffffffffffff3fcff3fcff
-dqcan273 copynegate #7c080ff3fcff3fcff3fcff3fcff3fcff -> #fc080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan274 copynegate #7e003ff3fcffffffffffffffcff3fcff -> #fe003ff3fcffffffffffffffcff3fcff
-dqcan275 copynegate #7e100ff3fcff3fcff3fcff3fcff3fcff -> #fe100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan278 copynegate #78002000000000000000000000000000 -> #f8002000000000000000000000000000
-dqcan279 copynegate #78000000000010000000000000100000 -> #f8000000000010000000000000100000
-
------ CopySign: [does not usually canonicalize]
--- finites
-dqcan280 copysign #6e080ff3fcff3fcfffffff3fcfffffff -1 -> #ee080ff3fcff3fcfffffff3fcfffffff
-dqcan281 copysign #ee080ff3fcff3ffff3fcff3ffff3fcff 1 -> #6e080ff3fcff3ffff3fcff3ffff3fcff
--- NaNs
-dqcan282 copysign #7c000ff3fcffffffffffffffcff3fcff -1 -> #fc000ff3fcffffffffffffffcff3fcff
-dqcan283 copysign #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c080ff3fcff3fcff3fcff3fcff3fcff
--- sNaN
-dqcan284 copysign #7e003ff3fcffffffffffffffcff3fcff -1 -> #fe003ff3fcffffffffffffffcff3fcff
-dqcan285 copysign #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7e100ff3fcff3fcff3fcff3fcff3fcff
--- Inf
-dqcan288 copysign #78002000000000000000000000000000 -1 -> #f8002000000000000000000000000000
-dqcan289 copysign #78000000000010000000000000100000 1 -> #78000000000010000000000000100000
-
------ Multiply:
--- Finites: neutral 0
-dqcan302 multiply 1 #77ffff3fcff3fcff0000000000000000 -> #77ffff3fcff3fcff0000000000000000
-dqcan303 multiply #77fcffffcff3fcff0000000000000000 1 -> #77fccfffcff3fcff0000000000000000
--- negative
-dqcan306 multiply -1 #77ffff3fcff3fcff0000000000000000 -> #f7ffff3fcff3fcff0000000000000000
-dqcan307 multiply #77fcffffcff3fcff0000000000000000 -1 -> #f7fccfffcff3fcff0000000000000000
--- NaN: declets in payload
-dqcan311 multiply 1 #7c03ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
-dqcan312 multiply #7c03ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan313 multiply 1 #7c40ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
-dqcan314 multiply #7c40ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
--- sNaN: declets in payload
-dqcan315 multiply 1 #7e00ffffcff3fcff0000000000000000 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
-dqcan316 multiply #7e00ffffcff3fcff0000000000000000 1 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan317 multiply 1 #7e80ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
-dqcan318 multiply #7e80ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
--- Inf: exponent continuation bits
-dqcan320 multiply 1 #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan321 multiply #78800000000000000000000000000000 1 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan322 multiply 1 #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan323 multiply #78020000000000000000000000000000 1 -> #78000000000000000000000000000000
-dqcan324 multiply 1 #78000000000000010000000000000000 -> #78000000000000000000000000000000
-dqcan325 multiply #78000000000000010000000000000000 1 -> #78000000000000000000000000000000
-dqcan326 multiply 1 #78000020000000000000000000000000 -> #78000000000000000000000000000000
-dqcan327 multiply #78000020000000000000000000000000 1 -> #78000000000000000000000000000000
-
------ Quantize:
-dqcan401 quantize #ee080ff3fcff3fcff3fffffffff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan402 quantize #ee080ff3fffffffffffcff3fcff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan403 quantize #78800000000000000000000000000000 Inf -> #78000000000000000000000000000000
-dqcan404 quantize #78020000000000000000000000000000 -Inf -> #78000000000000000000000000000000
-dqcan410 quantize #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan411 quantize #fc000ff3fcfffffff3fcff3fcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff
-dqcan412 quantize #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan413 quantize #fe000ff3fcff3fcff3ffffffcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-
------ Subtract:
--- Finites: neutral 0
-dqcan502 subtract 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
-dqcan503 subtract #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
--- tiny zero
-dqcan504 subtract 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Rounded
-dqcan505 subtract #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
--- tiny non zero
-dqcan506 subtract -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
-dqcan507 subtract #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
--- NaN: declets in payload
-dqcan511 subtract 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan512 subtract #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- NaN: exponent continuation bits [excluding sNaN selector]
-dqcan513 subtract 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan514 subtract #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
--- sNaN: declets in payload
-dqcan515 subtract 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan516 subtract #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- sNaN: exponent continuation bits [excluding sNaN selector]
-dqcan517 subtract 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan518 subtract #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- Inf: exponent continuation bits
-dqcan520 subtract 0 #78010000000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan521 subtract #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
--- Inf: coefficient continuation bits
-dqcan522 subtract 0 #78002000000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan523 subtract #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
-dqcan524 subtract 0 #78000002000000000000000000000000 -> #f8000000000000000000000000000000
-dqcan525 subtract #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
-dqcan526 subtract 0 #78000000000000000005000000000000 -> #f8000000000000000000000000000000
-dqcan527 subtract #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
-
------ ToIntegral:
-dqcan601 tointegralx #6e080ff3fdff3fcff3fcff3fcff3fcff -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-dqcan602 tointegralx #ee080ff3fcff3ffff3fcff3fcff3fcff -> #ee080ff3fcff3fcff3fcff3fcff3fcff
-dqcan603 tointegralx #78800000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan604 tointegralx #78020000000000000000000000000000 -> #78000000000000000000000000000000
-dqcan614 tointegralx #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-dqcan615 tointegralx #fc000ff3fcff3fcff3fcffffcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff
-dqcan616 tointegralx #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
-dqcan617 tointegralx #fe000ff3fcff3fcff3fdff3fcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
--- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
-dqcan618 tointegralx #22080000000000000000000000000fff -> #22080000000000000000000000000cff
-dqcan619 tointegralx #22078000000000000000000000000fff -> #22080000000000000000000000000040 Inexact Rounded
-dqcan620 tointegralx #22074000000000000000000000000fff -> #22080000000000000000000000000004 Inexact Rounded
-dqcan621 tointegralx #22070000000000000000000000000fff -> #22080000000000000000000000000000 Inexact Rounded
-dqcan622 tointegralx #a2080000000000000000000000000fff -> #a2080000000000000000000000000cff
-dqcan623 tointegralx #a2078000000000000000000000000fff -> #a2080000000000000000000000000040 Inexact Rounded
-dqcan624 tointegralx #a2074000000000000000000000000fff -> #a2080000000000000000000000000004 Inexact Rounded
-dqcan625 tointegralx #a2070000000000000000000000000fff -> #a2080000000000000000000000000000 Inexact Rounded
-
-
-
+------------------------------------------------------------------------
+-- dqCanonical.decTest -- test decQuad canonical results --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests that copy operations leave uncanonical operands
+-- unchanged, and vice versa
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Uncanonical declets are: abc, where:
+-- a=1,2,3
+-- b=6,7,e,f
+-- c=e,f
+
+-- assert some standard (canonical) values; this tests that FromString
+-- produces canonical results (many more in decimalNN)
+dqcan001 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan002 apply 0 -> #22080000000000000000000000000000
+dqcan003 apply 1 -> #22080000000000000000000000000001
+dqcan004 apply -1 -> #a2080000000000000000000000000001
+dqcan005 apply Infinity -> #78000000000000000000000000000000
+dqcan006 apply -Infinity -> #f8000000000000000000000000000000
+dqcan007 apply -NaN -> #fc000000000000000000000000000000
+dqcan008 apply -sNaN -> #fe000000000000000000000000000000
+dqcan009 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan010 apply sNaN999999999999999999999999999999999 -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+decan011 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+dqcan012 apply 7.50 -> #220780000000000000000000000003d0
+dqcan013 apply 9.99 -> #220780000000000000000000000000ff
+
+-- Base tests for canonical encodings (individual operator
+-- propagation is tested later)
+
+-- Finites: declets in coefficient
+dqcan021 canonical #77ffcff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan022 canonical #77fffff3fcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan023 canonical #77ffcffffcff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan024 canonical #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan025 canonical #77ffcff3fcffffcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan026 canonical #77ffcff3fcff3ffff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan027 canonical #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan028 canonical #77ffcff3fcff3fcff3ffff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan029 canonical #77ffcff3fcff3fcff3fcffffcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan030 canonical #77ffcff3fcff3fcff3fcff3ffff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan031 canonical #77ffcff3fcff3fcff3fcff3fcffffcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan032 canonical #77ffcff3fcff3fcff3fcff3fcff3ffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+
+-- NaN: declets in payload
+dqcan061 canonical #7c000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan062 canonical #7c000ffffcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan063 canonical #7c000ff3ffff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan064 canonical #7c000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan065 canonical #7c000ff3fcff3ffff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan066 canonical #7c000ff3fcff3fcffffcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan067 canonical #7c000ff3fcff3fcff3ffff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan068 canonical #7c000ff3fcff3fcff3fcffffcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan069 canonical #7c000ff3fcff3fcff3fcff3ffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan070 canonical #7c000ff3fcff3fcff3fcff3fcffffcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan071 canonical #7c000ff3fcff3fcff3fcff3fcff3ffff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan081 canonical #7d000ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan082 canonical #7c800ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan083 canonical #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan084 canonical #7c200ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan085 canonical #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan086 canonical #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan087 canonical #7c040ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan088 canonical #7c020ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan089 canonical #7c010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan090 canonical #7c008ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan091 canonical #7c004ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+
+-- sNaN: declets in payload
+dqcan101 canonical #7e000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan102 canonical #7e000ffffcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan103 canonical #7e000ff3ffff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan104 canonical #7e000ff3fcffffcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan105 canonical #7e000ff3fcff3ffff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan106 canonical #7e000ff3fcff3fcffffcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan107 canonical #7e000ff3fcff3fcff3ffff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan108 canonical #7e000ff3fcff3fcff3fcffffcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan109 canonical #7e000ff3fcff3fcff3fcff3ffff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan100 canonical #7e000ff3fcff3fcff3fcff3fcffffcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan111 canonical #7e000ff3fcff3fcff3fcff3fcff3ffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan121 canonical #7f000ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan122 canonical #7e800ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan123 canonical #7e400ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan124 canonical #7e200ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan125 canonical #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan126 canonical #7e080ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan127 canonical #7e040ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan128 canonical #7e020ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan129 canonical #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan130 canonical #7e008ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+dqcan131 canonical #7e004ff3fcff3fcff3fcff3fcff3fcff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+
+-- Inf: exponent continuation bits
+dqcan137 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan138 canonical #79000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan139 canonical #7a000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan140 canonical #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan141 canonical #78400000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan142 canonical #78200000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan143 canonical #78100000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan144 canonical #78080000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan145 canonical #78040000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan146 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan147 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan148 canonical #78008000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan149 canonical #78004000000000000000000000000000 -> #78000000000000000000000000000000
+
+-- Inf: coefficient continuation bits (first, last, and a few others)
+dqcan150 canonical #78000000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan151 canonical #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan152 canonical #78000000000000000000000000000001 -> #78000000000000000000000000000000
+dqcan153 canonical #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan154 canonical #78002000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan155 canonical #78000800000000000000000000000000 -> #78000000000000000000000000000000
+dqcan156 canonical #78000020000000000000000000000000 -> #78000000000000000000000000000000
+dqcan157 canonical #78000004000000000000000000000000 -> #78000000000000000000000000000000
+dqcan158 canonical #78000000400000000000000000000000 -> #78000000000000000000000000000000
+dqcan159 canonical #78000000080000000000000000000000 -> #78000000000000000000000000000000
+dqcan160 canonical #78000000004000000000000000000000 -> #78000000000000000000000000000000
+dqcan161 canonical #78000000000200000000000000000000 -> #78000000000000000000000000000000
+dqcan162 canonical #78000000000080000000000000000000 -> #78000000000000000000000000000000
+dqcan163 canonical #78000000000002000000000000000000 -> #78000000000000000000000000000000
+dqcan164 canonical #78000000000000400000000000000000 -> #78000000000000000000000000000000
+dqcan165 canonical #78000000000000080000000000000000 -> #78000000000000000000000000000000
+dqcan166 canonical #78000000000000001000000000000000 -> #78000000000000000000000000000000
+dqcan167 canonical #78000000000000000200000000000000 -> #78000000000000000000000000000000
+dqcan168 canonical #78000000000000000080000000000000 -> #78000000000000000000000000000000
+dqcan169 canonical #78000000000000000004000000000000 -> #78000000000000000000000000000000
+dqcan170 canonical #78000000000000000000400000000000 -> #78000000000000000000000000000000
+dqcan171 canonical #78000000000000000000010000000000 -> #78000000000000000000000000000000
+dqcan172 canonical #78000000000000000000002000000000 -> #78000000000000000000000000000000
+dqcan173 canonical #78000000000000000000000400000000 -> #78000000000000000000000000000000
+dqcan174 canonical #78000000000000000000000080000000 -> #78000000000000000000000000000000
+dqcan175 canonical #78000000000000000000000002000000 -> #78000000000000000000000000000000
+dqcan176 canonical #78000000000000000000000000400000 -> #78000000000000000000000000000000
+dqcan177 canonical #78000000000000000000000000020000 -> #78000000000000000000000000000000
+dqcan178 canonical #78000000000000000000000000001000 -> #78000000000000000000000000000000
+dqcan179 canonical #78000000000000000000000000000400 -> #78000000000000000000000000000000
+dqcan180 canonical #78000000000000000000000000000020 -> #78000000000000000000000000000000
+dqcan181 canonical #78000000000000000000000000000008 -> #78000000000000000000000000000000
+
+
+-- Now the operators -- trying to check paths that might fail to
+-- canonicalize propagated operands
+
+----- Add:
+-- Finites: neutral 0
+dqcan202 add 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan203 add #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+-- tiny zero
+dqcan204 add 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+dqcan205 add #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+-- tiny non zero
+dqcan206 add -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+dqcan207 add #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+dqcan211 add 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan212 add #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan213 add 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan214 add #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: declets in payload
+dqcan215 add 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan216 add #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan217 add 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan218 add #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+dqcan220 add 0 #78010000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan221 add #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan222 add 0 #78002000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan223 add #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
+dqcan224 add 0 #78000002000000000000000000000000 -> #78000000000000000000000000000000
+dqcan225 add #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
+dqcan226 add 0 #78000000000000000005000000000000 -> #78000000000000000000000000000000
+dqcan227 add #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
+
+----- Class: [does not return encoded]
+
+----- Compare:
+dqcan231 compare -Inf 1 -> #a2080000000000000000000000000001
+dqcan232 compare -Inf -Inf -> #22080000000000000000000000000000
+dqcan233 compare 1 -Inf -> #22080000000000000000000000000001
+dqcan234 compare #7c010ff3fcff3fcff3fcff3ffffffcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan235 compare #7e004ff3fcff3fcff3ffffffcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- CompareSig:
+dqcan241 comparesig -Inf 1 -> #a2080000000000000000000000000001
+dqcan242 comparesig -Inf -Inf -> #22080000000000000000000000000000
+dqcan243 comparesig 1 -Inf -> #22080000000000000000000000000001
+dqcan244 comparesig #7c400ff3ffff3fcff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan245 comparesig #7e050ff3fcfffffff3fcff3fcff3fcff -1000 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- Copy: [does not usually canonicalize]
+-- finites
+dqcan250 copy #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
+dqcan251 copy #ee080ff3fcff3ffff3fcff3ffff3fcff -> #ee080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan252 copy #7c000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
+dqcan253 copy #7c080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan254 copy #7e003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
+dqcan255 copy #7e100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan258 copy #78002000000000000000000000000000 -> #78002000000000000000000000000000
+dqcan259 copy #78000000000010000000000000100000 -> #78000000000010000000000000100000
+
+----- CopyAbs: [does not usually canonicalize]
+-- finites
+dqcan260 copyabs #6e080ff3fcff3fcfffffff3fcfffffff -> #6e080ff3fcff3fcfffffff3fcfffffff
+dqcan261 copyabs #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan262 copyabs #fc000ff3fcffffffffffffffcff3fcff -> #7c000ff3fcffffffffffffffcff3fcff
+dqcan263 copyabs #fc080ff3fcff3fcff3fcff3fcff3fcff -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan264 copyabs #fe003ff3fcffffffffffffffcff3fcff -> #7e003ff3fcffffffffffffffcff3fcff
+dqcan265 copyabs #fe100ff3fcff3fcff3fcff3fcff3fcff -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan268 copyabs #f8002000000000000000000000000000 -> #78002000000000000000000000000000
+dqcan269 copyabs #f8000000000000700700700000000000 -> #78000000000000700700700000000000
+
+----- CopyNegate: [does not usually canonicalize]
+-- finites
+dqcan270 copynegate #6e080ff3fcff3fcfffffff3fcfffffff -> #ee080ff3fcff3fcfffffff3fcfffffff
+dqcan271 copynegate #ee080ff3fcff3ffff3fcff3ffff3fcff -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan272 copynegate #7c000ff3fcffffffffffff3fcff3fcff -> #fc000ff3fcffffffffffff3fcff3fcff
+dqcan273 copynegate #7c080ff3fcff3fcff3fcff3fcff3fcff -> #fc080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan274 copynegate #7e003ff3fcffffffffffffffcff3fcff -> #fe003ff3fcffffffffffffffcff3fcff
+dqcan275 copynegate #7e100ff3fcff3fcff3fcff3fcff3fcff -> #fe100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan278 copynegate #78002000000000000000000000000000 -> #f8002000000000000000000000000000
+dqcan279 copynegate #78000000000010000000000000100000 -> #f8000000000010000000000000100000
+
+----- CopySign: [does not usually canonicalize]
+-- finites
+dqcan280 copysign #6e080ff3fcff3fcfffffff3fcfffffff -1 -> #ee080ff3fcff3fcfffffff3fcfffffff
+dqcan281 copysign #ee080ff3fcff3ffff3fcff3ffff3fcff 1 -> #6e080ff3fcff3ffff3fcff3ffff3fcff
+-- NaNs
+dqcan282 copysign #7c000ff3fcffffffffffffffcff3fcff -1 -> #fc000ff3fcffffffffffffffcff3fcff
+dqcan283 copysign #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c080ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN
+dqcan284 copysign #7e003ff3fcffffffffffffffcff3fcff -1 -> #fe003ff3fcffffffffffffffcff3fcff
+dqcan285 copysign #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7e100ff3fcff3fcff3fcff3fcff3fcff
+-- Inf
+dqcan288 copysign #78002000000000000000000000000000 -1 -> #f8002000000000000000000000000000
+dqcan289 copysign #78000000000010000000000000100000 1 -> #78000000000010000000000000100000
+
+----- Multiply:
+-- Finites: neutral 0
+dqcan302 multiply 1 #77ffff3fcff3fcff0000000000000000 -> #77ffff3fcff3fcff0000000000000000
+dqcan303 multiply #77fcffffcff3fcff0000000000000000 1 -> #77fccfffcff3fcff0000000000000000
+-- negative
+dqcan306 multiply -1 #77ffff3fcff3fcff0000000000000000 -> #f7ffff3fcff3fcff0000000000000000
+dqcan307 multiply #77fcffffcff3fcff0000000000000000 -1 -> #f7fccfffcff3fcff0000000000000000
+-- NaN: declets in payload
+dqcan311 multiply 1 #7c03ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
+dqcan312 multiply #7c03ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan313 multiply 1 #7c40ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000
+dqcan314 multiply #7c40ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000
+-- sNaN: declets in payload
+dqcan315 multiply 1 #7e00ffffcff3fcff0000000000000000 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
+dqcan316 multiply #7e00ffffcff3fcff0000000000000000 1 -> #7c000fffcff3fcff0000000000000000 Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan317 multiply 1 #7e80ff3fcff3fcff0000000000000000 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
+dqcan318 multiply #7e80ff3fcff3fcff0000000000000000 1 -> #7c003f3fcff3fcff0000000000000000 Invalid_operation
+-- Inf: exponent continuation bits
+dqcan320 multiply 1 #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan321 multiply #78800000000000000000000000000000 1 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan322 multiply 1 #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan323 multiply #78020000000000000000000000000000 1 -> #78000000000000000000000000000000
+dqcan324 multiply 1 #78000000000000010000000000000000 -> #78000000000000000000000000000000
+dqcan325 multiply #78000000000000010000000000000000 1 -> #78000000000000000000000000000000
+dqcan326 multiply 1 #78000020000000000000000000000000 -> #78000000000000000000000000000000
+dqcan327 multiply #78000020000000000000000000000000 1 -> #78000000000000000000000000000000
+
+----- Quantize:
+dqcan401 quantize #ee080ff3fcff3fcff3fffffffff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan402 quantize #ee080ff3fffffffffffcff3fcff3fcff 0 -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan403 quantize #78800000000000000000000000000000 Inf -> #78000000000000000000000000000000
+dqcan404 quantize #78020000000000000000000000000000 -Inf -> #78000000000000000000000000000000
+dqcan410 quantize #7c080ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan411 quantize #fc000ff3fcfffffff3fcff3fcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff
+dqcan412 quantize #7e100ff3fcff3fcff3fcff3fcff3fcff 1 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan413 quantize #fe000ff3fcff3fcff3ffffffcff3fcff 1 -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+
+----- Subtract:
+-- Finites: neutral 0
+dqcan502 subtract 0E+6144 #77ffcff3fcff3fcffffcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
+dqcan503 subtract #77ffcff3fcff3fcff3fcff3ffff3fcff 0E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+-- tiny zero
+dqcan504 subtract 0E-6176 #77ffcff3ffff3fcff3fcff3fcff3fcff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+dqcan505 subtract #77ffcff3fcff3fcff3fcff3fcff3ffff 0E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Rounded
+-- tiny non zero
+dqcan506 subtract -1E-6176 #77ffcff3fcff3fcff3fcff3fcfffffff -> #f7ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+dqcan507 subtract #77ffcffffffffffffffffffffff3fcff -1E-6176 -> #77ffcff3fcff3fcff3fcff3fcff3fcff Inexact Rounded
+-- NaN: declets in payload
+dqcan511 subtract 0 #7c000ff3fcff3fcff3fcfffffff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan512 subtract #7c000ff3fcff3fcfffffff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- NaN: exponent continuation bits [excluding sNaN selector]
+dqcan513 subtract 0 #7c400ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan514 subtract #7c020ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+-- sNaN: declets in payload
+dqcan515 subtract 0 #7e000ff3fcffffcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan516 subtract #7e003ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- sNaN: exponent continuation bits [excluding sNaN selector]
+dqcan517 subtract 0 #7e500ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan518 subtract #7e0e0ff3fcff3fcff3fcff3fcff3fcff 0 -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- Inf: exponent continuation bits
+dqcan520 subtract 0 #78010000000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan521 subtract #78680000000000000000000000000000 0 -> #78000000000000000000000000000000
+-- Inf: coefficient continuation bits
+dqcan522 subtract 0 #78002000000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan523 subtract #78000000000000000000000000000001 0 -> #78000000000000000000000000000000
+dqcan524 subtract 0 #78000002000000000000000000000000 -> #f8000000000000000000000000000000
+dqcan525 subtract #780000000000f0000000000000000000 0 -> #78000000000000000000000000000000
+dqcan526 subtract 0 #78000000000000000005000000000000 -> #f8000000000000000000000000000000
+dqcan527 subtract #780000000000000000000000000a0000 0 -> #78000000000000000000000000000000
+
+----- ToIntegral:
+dqcan601 tointegralx #6e080ff3fdff3fcff3fcff3fcff3fcff -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+dqcan602 tointegralx #ee080ff3fcff3ffff3fcff3fcff3fcff -> #ee080ff3fcff3fcff3fcff3fcff3fcff
+dqcan603 tointegralx #78800000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan604 tointegralx #78020000000000000000000000000000 -> #78000000000000000000000000000000
+dqcan614 tointegralx #7c100ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+dqcan615 tointegralx #fc000ff3fcff3fcff3fcffffcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff
+dqcan616 tointegralx #7e010ff3fcff3fcff3fcff3fcff3fcff -> #7c000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+dqcan617 tointegralx #fe000ff3fcff3fcff3fdff3fcff3fcff -> #fc000ff3fcff3fcff3fcff3fcff3fcff Invalid_operation
+-- uncanonical 3999, 39.99, 3.99, 0.399, and negatives
+dqcan618 tointegralx #22080000000000000000000000000fff -> #22080000000000000000000000000cff
+dqcan619 tointegralx #22078000000000000000000000000fff -> #22080000000000000000000000000040 Inexact Rounded
+dqcan620 tointegralx #22074000000000000000000000000fff -> #22080000000000000000000000000004 Inexact Rounded
+dqcan621 tointegralx #22070000000000000000000000000fff -> #22080000000000000000000000000000 Inexact Rounded
+dqcan622 tointegralx #a2080000000000000000000000000fff -> #a2080000000000000000000000000cff
+dqcan623 tointegralx #a2078000000000000000000000000fff -> #a2080000000000000000000000000040 Inexact Rounded
+dqcan624 tointegralx #a2074000000000000000000000000fff -> #a2080000000000000000000000000004 Inexact Rounded
+dqcan625 tointegralx #a2070000000000000000000000000fff -> #a2080000000000000000000000000000 Inexact Rounded
+
+
+
diff --git a/Lib/test/decimaltestdata/dqClass.decTest b/Lib/test/decimaltestdata/dqClass.decTest
index d7e19b3829a..f341933878e 100644
--- a/Lib/test/decimaltestdata/dqClass.decTest
+++ b/Lib/test/decimaltestdata/dqClass.decTest
@@ -1,77 +1,77 @@
-------------------------------------------------------------------------
--- dqClass.decTest -- decQuad Class operations --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- [New 2006.11.27]
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqcla001 class 0 -> +Zero
-dqcla002 class 0.00 -> +Zero
-dqcla003 class 0E+5 -> +Zero
-dqcla004 class 1E-6176 -> +Subnormal
-dqcla005 class 0.1E-6143 -> +Subnormal
-dqcla006 class 0.99999999999999999999999999999999E-6143 -> +Subnormal
-dqcla007 class 1.00000000000000000000000000000000E-6143 -> +Normal
-dqcla008 class 1E-6143 -> +Normal
-dqcla009 class 1E-100 -> +Normal
-dqcla010 class 1E-10 -> +Normal
-dqcla012 class 1E-1 -> +Normal
-dqcla013 class 1 -> +Normal
-dqcla014 class 2.50 -> +Normal
-dqcla015 class 100.100 -> +Normal
-dqcla016 class 1E+30 -> +Normal
-dqcla017 class 1E+6144 -> +Normal
-dqcla018 class 9.99999999999999999999999999999999E+6144 -> +Normal
-dqcla019 class Inf -> +Infinity
-
-dqcla021 class -0 -> -Zero
-dqcla022 class -0.00 -> -Zero
-dqcla023 class -0E+5 -> -Zero
-dqcla024 class -1E-6176 -> -Subnormal
-dqcla025 class -0.1E-6143 -> -Subnormal
-dqcla026 class -0.99999999999999999999999999999999E-6143 -> -Subnormal
-dqcla027 class -1.00000000000000000000000000000000E-6143 -> -Normal
-dqcla028 class -1E-6143 -> -Normal
-dqcla029 class -1E-100 -> -Normal
-dqcla030 class -1E-10 -> -Normal
-dqcla032 class -1E-1 -> -Normal
-dqcla033 class -1 -> -Normal
-dqcla034 class -2.50 -> -Normal
-dqcla035 class -100.100 -> -Normal
-dqcla036 class -1E+30 -> -Normal
-dqcla037 class -1E+6144 -> -Normal
-dqcla0614 class -9.99999999999999999999999999999999E+6144 -> -Normal
-dqcla039 class -Inf -> -Infinity
-
-dqcla041 class NaN -> NaN
-dqcla042 class -NaN -> NaN
-dqcla043 class +NaN12345 -> NaN
-dqcla044 class sNaN -> sNaN
-dqcla045 class -sNaN -> sNaN
-dqcla046 class +sNaN12345 -> sNaN
-
-
-
+------------------------------------------------------------------------
+-- dqClass.decTest -- decQuad Class operations --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- [New 2006.11.27]
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqcla001 class 0 -> +Zero
+dqcla002 class 0.00 -> +Zero
+dqcla003 class 0E+5 -> +Zero
+dqcla004 class 1E-6176 -> +Subnormal
+dqcla005 class 0.1E-6143 -> +Subnormal
+dqcla006 class 0.99999999999999999999999999999999E-6143 -> +Subnormal
+dqcla007 class 1.00000000000000000000000000000000E-6143 -> +Normal
+dqcla008 class 1E-6143 -> +Normal
+dqcla009 class 1E-100 -> +Normal
+dqcla010 class 1E-10 -> +Normal
+dqcla012 class 1E-1 -> +Normal
+dqcla013 class 1 -> +Normal
+dqcla014 class 2.50 -> +Normal
+dqcla015 class 100.100 -> +Normal
+dqcla016 class 1E+30 -> +Normal
+dqcla017 class 1E+6144 -> +Normal
+dqcla018 class 9.99999999999999999999999999999999E+6144 -> +Normal
+dqcla019 class Inf -> +Infinity
+
+dqcla021 class -0 -> -Zero
+dqcla022 class -0.00 -> -Zero
+dqcla023 class -0E+5 -> -Zero
+dqcla024 class -1E-6176 -> -Subnormal
+dqcla025 class -0.1E-6143 -> -Subnormal
+dqcla026 class -0.99999999999999999999999999999999E-6143 -> -Subnormal
+dqcla027 class -1.00000000000000000000000000000000E-6143 -> -Normal
+dqcla028 class -1E-6143 -> -Normal
+dqcla029 class -1E-100 -> -Normal
+dqcla030 class -1E-10 -> -Normal
+dqcla032 class -1E-1 -> -Normal
+dqcla033 class -1 -> -Normal
+dqcla034 class -2.50 -> -Normal
+dqcla035 class -100.100 -> -Normal
+dqcla036 class -1E+30 -> -Normal
+dqcla037 class -1E+6144 -> -Normal
+dqcla0614 class -9.99999999999999999999999999999999E+6144 -> -Normal
+dqcla039 class -Inf -> -Infinity
+
+dqcla041 class NaN -> NaN
+dqcla042 class -NaN -> NaN
+dqcla043 class +NaN12345 -> NaN
+dqcla044 class sNaN -> sNaN
+dqcla045 class -sNaN -> sNaN
+dqcla046 class +sNaN12345 -> sNaN
+
+
+
diff --git a/Lib/test/decimaltestdata/dqCompare.decTest b/Lib/test/decimaltestdata/dqCompare.decTest
index b7b5ee6b8e5..a617ad110a4 100644
--- a/Lib/test/decimaltestdata/dqCompare.decTest
+++ b/Lib/test/decimaltestdata/dqCompare.decTest
@@ -1,753 +1,753 @@
-------------------------------------------------------------------------
--- dqCompare.decTest -- decQuad comparison that allows quiet NaNs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcom001 compare -2 -2 -> 0
-dqcom002 compare -2 -1 -> -1
-dqcom003 compare -2 0 -> -1
-dqcom004 compare -2 1 -> -1
-dqcom005 compare -2 2 -> -1
-dqcom006 compare -1 -2 -> 1
-dqcom007 compare -1 -1 -> 0
-dqcom008 compare -1 0 -> -1
-dqcom009 compare -1 1 -> -1
-dqcom010 compare -1 2 -> -1
-dqcom011 compare 0 -2 -> 1
-dqcom012 compare 0 -1 -> 1
-dqcom013 compare 0 0 -> 0
-dqcom014 compare 0 1 -> -1
-dqcom015 compare 0 2 -> -1
-dqcom016 compare 1 -2 -> 1
-dqcom017 compare 1 -1 -> 1
-dqcom018 compare 1 0 -> 1
-dqcom019 compare 1 1 -> 0
-dqcom020 compare 1 2 -> -1
-dqcom021 compare 2 -2 -> 1
-dqcom022 compare 2 -1 -> 1
-dqcom023 compare 2 0 -> 1
-dqcom025 compare 2 1 -> 1
-dqcom026 compare 2 2 -> 0
-
-dqcom031 compare -20 -20 -> 0
-dqcom032 compare -20 -10 -> -1
-dqcom033 compare -20 00 -> -1
-dqcom034 compare -20 10 -> -1
-dqcom035 compare -20 20 -> -1
-dqcom036 compare -10 -20 -> 1
-dqcom037 compare -10 -10 -> 0
-dqcom038 compare -10 00 -> -1
-dqcom039 compare -10 10 -> -1
-dqcom040 compare -10 20 -> -1
-dqcom041 compare 00 -20 -> 1
-dqcom042 compare 00 -10 -> 1
-dqcom043 compare 00 00 -> 0
-dqcom044 compare 00 10 -> -1
-dqcom045 compare 00 20 -> -1
-dqcom046 compare 10 -20 -> 1
-dqcom047 compare 10 -10 -> 1
-dqcom048 compare 10 00 -> 1
-dqcom049 compare 10 10 -> 0
-dqcom050 compare 10 20 -> -1
-dqcom051 compare 20 -20 -> 1
-dqcom052 compare 20 -10 -> 1
-dqcom053 compare 20 00 -> 1
-dqcom055 compare 20 10 -> 1
-dqcom056 compare 20 20 -> 0
-
-dqcom061 compare -2.0 -2.0 -> 0
-dqcom062 compare -2.0 -1.0 -> -1
-dqcom063 compare -2.0 0.0 -> -1
-dqcom064 compare -2.0 1.0 -> -1
-dqcom065 compare -2.0 2.0 -> -1
-dqcom066 compare -1.0 -2.0 -> 1
-dqcom067 compare -1.0 -1.0 -> 0
-dqcom068 compare -1.0 0.0 -> -1
-dqcom069 compare -1.0 1.0 -> -1
-dqcom070 compare -1.0 2.0 -> -1
-dqcom071 compare 0.0 -2.0 -> 1
-dqcom072 compare 0.0 -1.0 -> 1
-dqcom073 compare 0.0 0.0 -> 0
-dqcom074 compare 0.0 1.0 -> -1
-dqcom075 compare 0.0 2.0 -> -1
-dqcom076 compare 1.0 -2.0 -> 1
-dqcom077 compare 1.0 -1.0 -> 1
-dqcom078 compare 1.0 0.0 -> 1
-dqcom079 compare 1.0 1.0 -> 0
-dqcom080 compare 1.0 2.0 -> -1
-dqcom081 compare 2.0 -2.0 -> 1
-dqcom082 compare 2.0 -1.0 -> 1
-dqcom083 compare 2.0 0.0 -> 1
-dqcom085 compare 2.0 1.0 -> 1
-dqcom086 compare 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcom090 compare 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
-dqcom091 compare -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
-dqcom092 compare 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
-dqcom093 compare -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
-dqcom100 compare 7.0 7.0 -> 0
-dqcom101 compare 7.0 7 -> 0
-dqcom102 compare 7 7.0 -> 0
-dqcom103 compare 7E+0 7.0 -> 0
-dqcom104 compare 70E-1 7.0 -> 0
-dqcom105 compare 0.7E+1 7 -> 0
-dqcom106 compare 70E-1 7 -> 0
-dqcom107 compare 7.0 7E+0 -> 0
-dqcom108 compare 7.0 70E-1 -> 0
-dqcom109 compare 7 0.7E+1 -> 0
-dqcom110 compare 7 70E-1 -> 0
-
-dqcom120 compare 8.0 7.0 -> 1
-dqcom121 compare 8.0 7 -> 1
-dqcom122 compare 8 7.0 -> 1
-dqcom123 compare 8E+0 7.0 -> 1
-dqcom124 compare 80E-1 7.0 -> 1
-dqcom125 compare 0.8E+1 7 -> 1
-dqcom126 compare 80E-1 7 -> 1
-dqcom127 compare 8.0 7E+0 -> 1
-dqcom128 compare 8.0 70E-1 -> 1
-dqcom129 compare 8 0.7E+1 -> 1
-dqcom130 compare 8 70E-1 -> 1
-
-dqcom140 compare 8.0 9.0 -> -1
-dqcom141 compare 8.0 9 -> -1
-dqcom142 compare 8 9.0 -> -1
-dqcom143 compare 8E+0 9.0 -> -1
-dqcom144 compare 80E-1 9.0 -> -1
-dqcom145 compare 0.8E+1 9 -> -1
-dqcom146 compare 80E-1 9 -> -1
-dqcom147 compare 8.0 9E+0 -> -1
-dqcom148 compare 8.0 90E-1 -> -1
-dqcom149 compare 8 0.9E+1 -> -1
-dqcom150 compare 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcom200 compare -7.0 7.0 -> -1
-dqcom201 compare -7.0 7 -> -1
-dqcom202 compare -7 7.0 -> -1
-dqcom203 compare -7E+0 7.0 -> -1
-dqcom204 compare -70E-1 7.0 -> -1
-dqcom205 compare -0.7E+1 7 -> -1
-dqcom206 compare -70E-1 7 -> -1
-dqcom207 compare -7.0 7E+0 -> -1
-dqcom208 compare -7.0 70E-1 -> -1
-dqcom209 compare -7 0.7E+1 -> -1
-dqcom210 compare -7 70E-1 -> -1
-
-dqcom220 compare -8.0 7.0 -> -1
-dqcom221 compare -8.0 7 -> -1
-dqcom222 compare -8 7.0 -> -1
-dqcom223 compare -8E+0 7.0 -> -1
-dqcom224 compare -80E-1 7.0 -> -1
-dqcom225 compare -0.8E+1 7 -> -1
-dqcom226 compare -80E-1 7 -> -1
-dqcom227 compare -8.0 7E+0 -> -1
-dqcom228 compare -8.0 70E-1 -> -1
-dqcom229 compare -8 0.7E+1 -> -1
-dqcom230 compare -8 70E-1 -> -1
-
-dqcom240 compare -8.0 9.0 -> -1
-dqcom241 compare -8.0 9 -> -1
-dqcom242 compare -8 9.0 -> -1
-dqcom243 compare -8E+0 9.0 -> -1
-dqcom244 compare -80E-1 9.0 -> -1
-dqcom245 compare -0.8E+1 9 -> -1
-dqcom246 compare -80E-1 9 -> -1
-dqcom247 compare -8.0 9E+0 -> -1
-dqcom248 compare -8.0 90E-1 -> -1
-dqcom249 compare -8 0.9E+1 -> -1
-dqcom250 compare -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcom300 compare 7.0 -7.0 -> 1
-dqcom301 compare 7.0 -7 -> 1
-dqcom302 compare 7 -7.0 -> 1
-dqcom303 compare 7E+0 -7.0 -> 1
-dqcom304 compare 70E-1 -7.0 -> 1
-dqcom305 compare .7E+1 -7 -> 1
-dqcom306 compare 70E-1 -7 -> 1
-dqcom307 compare 7.0 -7E+0 -> 1
-dqcom308 compare 7.0 -70E-1 -> 1
-dqcom309 compare 7 -.7E+1 -> 1
-dqcom310 compare 7 -70E-1 -> 1
-
-dqcom320 compare 8.0 -7.0 -> 1
-dqcom321 compare 8.0 -7 -> 1
-dqcom322 compare 8 -7.0 -> 1
-dqcom323 compare 8E+0 -7.0 -> 1
-dqcom324 compare 80E-1 -7.0 -> 1
-dqcom325 compare .8E+1 -7 -> 1
-dqcom326 compare 80E-1 -7 -> 1
-dqcom327 compare 8.0 -7E+0 -> 1
-dqcom328 compare 8.0 -70E-1 -> 1
-dqcom329 compare 8 -.7E+1 -> 1
-dqcom330 compare 8 -70E-1 -> 1
-
-dqcom340 compare 8.0 -9.0 -> 1
-dqcom341 compare 8.0 -9 -> 1
-dqcom342 compare 8 -9.0 -> 1
-dqcom343 compare 8E+0 -9.0 -> 1
-dqcom344 compare 80E-1 -9.0 -> 1
-dqcom345 compare .8E+1 -9 -> 1
-dqcom346 compare 80E-1 -9 -> 1
-dqcom347 compare 8.0 -9E+0 -> 1
-dqcom348 compare 8.0 -90E-1 -> 1
-dqcom349 compare 8 -.9E+1 -> 1
-dqcom350 compare 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcom400 compare -7.0 -7.0 -> 0
-dqcom401 compare -7.0 -7 -> 0
-dqcom402 compare -7 -7.0 -> 0
-dqcom403 compare -7E+0 -7.0 -> 0
-dqcom404 compare -70E-1 -7.0 -> 0
-dqcom405 compare -.7E+1 -7 -> 0
-dqcom406 compare -70E-1 -7 -> 0
-dqcom407 compare -7.0 -7E+0 -> 0
-dqcom408 compare -7.0 -70E-1 -> 0
-dqcom409 compare -7 -.7E+1 -> 0
-dqcom410 compare -7 -70E-1 -> 0
-
-dqcom420 compare -8.0 -7.0 -> -1
-dqcom421 compare -8.0 -7 -> -1
-dqcom422 compare -8 -7.0 -> -1
-dqcom423 compare -8E+0 -7.0 -> -1
-dqcom424 compare -80E-1 -7.0 -> -1
-dqcom425 compare -.8E+1 -7 -> -1
-dqcom426 compare -80E-1 -7 -> -1
-dqcom427 compare -8.0 -7E+0 -> -1
-dqcom428 compare -8.0 -70E-1 -> -1
-dqcom429 compare -8 -.7E+1 -> -1
-dqcom430 compare -8 -70E-1 -> -1
-
-dqcom440 compare -8.0 -9.0 -> 1
-dqcom441 compare -8.0 -9 -> 1
-dqcom442 compare -8 -9.0 -> 1
-dqcom443 compare -8E+0 -9.0 -> 1
-dqcom444 compare -80E-1 -9.0 -> 1
-dqcom445 compare -.8E+1 -9 -> 1
-dqcom446 compare -80E-1 -9 -> 1
-dqcom447 compare -8.0 -9E+0 -> 1
-dqcom448 compare -8.0 -90E-1 -> 1
-dqcom449 compare -8 -.9E+1 -> 1
-dqcom450 compare -8 -90E-1 -> 1
-
--- misalignment traps for little-endian
-dqcom451 compare 1.0 0.1 -> 1
-dqcom452 compare 0.1 1.0 -> -1
-dqcom453 compare 10.0 0.1 -> 1
-dqcom454 compare 0.1 10.0 -> -1
-dqcom455 compare 100 1.0 -> 1
-dqcom456 compare 1.0 100 -> -1
-dqcom457 compare 1000 10.0 -> 1
-dqcom458 compare 10.0 1000 -> -1
-dqcom459 compare 10000 100.0 -> 1
-dqcom460 compare 100.0 10000 -> -1
-dqcom461 compare 100000 1000.0 -> 1
-dqcom462 compare 1000.0 100000 -> -1
-dqcom463 compare 1000000 10000.0 -> 1
-dqcom464 compare 10000.0 1000000 -> -1
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcom473 compare 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
-dqcom474 compare 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
-dqcom475 compare 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
-dqcom476 compare 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
-dqcom477 compare 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
-dqcom478 compare 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
-dqcom479 compare 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
-dqcom480 compare 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
-dqcom481 compare 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
-dqcom482 compare 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
-dqcom483 compare 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
-dqcom487 compare 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
-dqcom488 compare 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
-dqcom489 compare 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
-dqcom490 compare 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
-dqcom491 compare 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
-dqcom492 compare 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
-dqcom493 compare 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
-dqcom494 compare 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
-dqcom495 compare 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
-dqcom496 compare 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
-dqcom497 compare 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcom500 compare 1 1E-15 -> 1
-dqcom501 compare 1 1E-14 -> 1
-dqcom502 compare 1 1E-13 -> 1
-dqcom503 compare 1 1E-12 -> 1
-dqcom504 compare 1 1E-11 -> 1
-dqcom505 compare 1 1E-10 -> 1
-dqcom506 compare 1 1E-9 -> 1
-dqcom507 compare 1 1E-8 -> 1
-dqcom508 compare 1 1E-7 -> 1
-dqcom509 compare 1 1E-6 -> 1
-dqcom510 compare 1 1E-5 -> 1
-dqcom511 compare 1 1E-4 -> 1
-dqcom512 compare 1 1E-3 -> 1
-dqcom513 compare 1 1E-2 -> 1
-dqcom514 compare 1 1E-1 -> 1
-dqcom515 compare 1 1E-0 -> 0
-dqcom516 compare 1 1E+1 -> -1
-dqcom517 compare 1 1E+2 -> -1
-dqcom518 compare 1 1E+3 -> -1
-dqcom519 compare 1 1E+4 -> -1
-dqcom521 compare 1 1E+5 -> -1
-dqcom522 compare 1 1E+6 -> -1
-dqcom523 compare 1 1E+7 -> -1
-dqcom524 compare 1 1E+8 -> -1
-dqcom525 compare 1 1E+9 -> -1
-dqcom526 compare 1 1E+10 -> -1
-dqcom527 compare 1 1E+11 -> -1
-dqcom528 compare 1 1E+12 -> -1
-dqcom529 compare 1 1E+13 -> -1
-dqcom530 compare 1 1E+14 -> -1
-dqcom531 compare 1 1E+15 -> -1
--- LR swap
-dqcom540 compare 1E-15 1 -> -1
-dqcom541 compare 1E-14 1 -> -1
-dqcom542 compare 1E-13 1 -> -1
-dqcom543 compare 1E-12 1 -> -1
-dqcom544 compare 1E-11 1 -> -1
-dqcom545 compare 1E-10 1 -> -1
-dqcom546 compare 1E-9 1 -> -1
-dqcom547 compare 1E-8 1 -> -1
-dqcom548 compare 1E-7 1 -> -1
-dqcom549 compare 1E-6 1 -> -1
-dqcom550 compare 1E-5 1 -> -1
-dqcom551 compare 1E-4 1 -> -1
-dqcom552 compare 1E-3 1 -> -1
-dqcom553 compare 1E-2 1 -> -1
-dqcom554 compare 1E-1 1 -> -1
-dqcom555 compare 1E-0 1 -> 0
-dqcom556 compare 1E+1 1 -> 1
-dqcom557 compare 1E+2 1 -> 1
-dqcom558 compare 1E+3 1 -> 1
-dqcom559 compare 1E+4 1 -> 1
-dqcom561 compare 1E+5 1 -> 1
-dqcom562 compare 1E+6 1 -> 1
-dqcom563 compare 1E+7 1 -> 1
-dqcom564 compare 1E+8 1 -> 1
-dqcom565 compare 1E+9 1 -> 1
-dqcom566 compare 1E+10 1 -> 1
-dqcom567 compare 1E+11 1 -> 1
-dqcom568 compare 1E+12 1 -> 1
-dqcom569 compare 1E+13 1 -> 1
-dqcom570 compare 1E+14 1 -> 1
-dqcom571 compare 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-dqcom580 compare 0.000000987654321 1E-15 -> 1
-dqcom581 compare 0.000000987654321 1E-14 -> 1
-dqcom582 compare 0.000000987654321 1E-13 -> 1
-dqcom583 compare 0.000000987654321 1E-12 -> 1
-dqcom584 compare 0.000000987654321 1E-11 -> 1
-dqcom585 compare 0.000000987654321 1E-10 -> 1
-dqcom586 compare 0.000000987654321 1E-9 -> 1
-dqcom587 compare 0.000000987654321 1E-8 -> 1
-dqcom588 compare 0.000000987654321 1E-7 -> 1
-dqcom589 compare 0.000000987654321 1E-6 -> -1
-dqcom590 compare 0.000000987654321 1E-5 -> -1
-dqcom591 compare 0.000000987654321 1E-4 -> -1
-dqcom592 compare 0.000000987654321 1E-3 -> -1
-dqcom593 compare 0.000000987654321 1E-2 -> -1
-dqcom594 compare 0.000000987654321 1E-1 -> -1
-dqcom595 compare 0.000000987654321 1E-0 -> -1
-dqcom596 compare 0.000000987654321 1E+1 -> -1
-dqcom597 compare 0.000000987654321 1E+2 -> -1
-dqcom598 compare 0.000000987654321 1E+3 -> -1
-dqcom599 compare 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcom600 compare 12 12.2345 -> -1
-dqcom601 compare 12.0 12.2345 -> -1
-dqcom602 compare 12.00 12.2345 -> -1
-dqcom603 compare 12.000 12.2345 -> -1
-dqcom604 compare 12.0000 12.2345 -> -1
-dqcom605 compare 12.00000 12.2345 -> -1
-dqcom606 compare 12.000000 12.2345 -> -1
-dqcom607 compare 12.0000000 12.2345 -> -1
-dqcom608 compare 12.00000000 12.2345 -> -1
-dqcom609 compare 12.000000000 12.2345 -> -1
-dqcom610 compare 12.1234 12 -> 1
-dqcom611 compare 12.1234 12.0 -> 1
-dqcom612 compare 12.1234 12.00 -> 1
-dqcom613 compare 12.1234 12.000 -> 1
-dqcom614 compare 12.1234 12.0000 -> 1
-dqcom615 compare 12.1234 12.00000 -> 1
-dqcom616 compare 12.1234 12.000000 -> 1
-dqcom617 compare 12.1234 12.0000000 -> 1
-dqcom618 compare 12.1234 12.00000000 -> 1
-dqcom619 compare 12.1234 12.000000000 -> 1
-dqcom620 compare -12 -12.2345 -> 1
-dqcom621 compare -12.0 -12.2345 -> 1
-dqcom622 compare -12.00 -12.2345 -> 1
-dqcom623 compare -12.000 -12.2345 -> 1
-dqcom624 compare -12.0000 -12.2345 -> 1
-dqcom625 compare -12.00000 -12.2345 -> 1
-dqcom626 compare -12.000000 -12.2345 -> 1
-dqcom627 compare -12.0000000 -12.2345 -> 1
-dqcom628 compare -12.00000000 -12.2345 -> 1
-dqcom629 compare -12.000000000 -12.2345 -> 1
-dqcom630 compare -12.1234 -12 -> -1
-dqcom631 compare -12.1234 -12.0 -> -1
-dqcom632 compare -12.1234 -12.00 -> -1
-dqcom633 compare -12.1234 -12.000 -> -1
-dqcom634 compare -12.1234 -12.0000 -> -1
-dqcom635 compare -12.1234 -12.00000 -> -1
-dqcom636 compare -12.1234 -12.000000 -> -1
-dqcom637 compare -12.1234 -12.0000000 -> -1
-dqcom638 compare -12.1234 -12.00000000 -> -1
-dqcom639 compare -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcom640 compare 0 0 -> 0
-dqcom641 compare 0 -0 -> 0
-dqcom642 compare 0 -0.0 -> 0
-dqcom643 compare 0 0.0 -> 0
-dqcom644 compare -0 0 -> 0
-dqcom645 compare -0 -0 -> 0
-dqcom646 compare -0 -0.0 -> 0
-dqcom647 compare -0 0.0 -> 0
-dqcom648 compare 0.0 0 -> 0
-dqcom649 compare 0.0 -0 -> 0
-dqcom650 compare 0.0 -0.0 -> 0
-dqcom651 compare 0.0 0.0 -> 0
-dqcom652 compare -0.0 0 -> 0
-dqcom653 compare -0.0 -0 -> 0
-dqcom654 compare -0.0 -0.0 -> 0
-dqcom655 compare -0.0 0.0 -> 0
-
-dqcom656 compare -0E1 0.0 -> 0
-dqcom657 compare -0E2 0.0 -> 0
-dqcom658 compare 0E1 0.0 -> 0
-dqcom659 compare 0E2 0.0 -> 0
-dqcom660 compare -0E1 0 -> 0
-dqcom661 compare -0E2 0 -> 0
-dqcom662 compare 0E1 0 -> 0
-dqcom663 compare 0E2 0 -> 0
-dqcom664 compare -0E1 -0E1 -> 0
-dqcom665 compare -0E2 -0E1 -> 0
-dqcom666 compare 0E1 -0E1 -> 0
-dqcom667 compare 0E2 -0E1 -> 0
-dqcom668 compare -0E1 -0E2 -> 0
-dqcom669 compare -0E2 -0E2 -> 0
-dqcom670 compare 0E1 -0E2 -> 0
-dqcom671 compare 0E2 -0E2 -> 0
-dqcom672 compare -0E1 0E1 -> 0
-dqcom673 compare -0E2 0E1 -> 0
-dqcom674 compare 0E1 0E1 -> 0
-dqcom675 compare 0E2 0E1 -> 0
-dqcom676 compare -0E1 0E2 -> 0
-dqcom677 compare -0E2 0E2 -> 0
-dqcom678 compare 0E1 0E2 -> 0
-dqcom679 compare 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcom680 compare 12 12 -> 0
-dqcom681 compare 12 12.0 -> 0
-dqcom682 compare 12 12.00 -> 0
-dqcom683 compare 12 12.000 -> 0
-dqcom684 compare 12 12.0000 -> 0
-dqcom685 compare 12 12.00000 -> 0
-dqcom686 compare 12 12.000000 -> 0
-dqcom687 compare 12 12.0000000 -> 0
-dqcom688 compare 12 12.00000000 -> 0
-dqcom689 compare 12 12.000000000 -> 0
-dqcom690 compare 12 12 -> 0
-dqcom691 compare 12.0 12 -> 0
-dqcom692 compare 12.00 12 -> 0
-dqcom693 compare 12.000 12 -> 0
-dqcom694 compare 12.0000 12 -> 0
-dqcom695 compare 12.00000 12 -> 0
-dqcom696 compare 12.000000 12 -> 0
-dqcom697 compare 12.0000000 12 -> 0
-dqcom698 compare 12.00000000 12 -> 0
-dqcom699 compare 12.000000000 12 -> 0
-
--- first, second, & last digit
-dqcom700 compare 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
-dqcom701 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcom702 compare 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
-dqcom703 compare 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
-dqcom704 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcom705 compare 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
-dqcom706 compare 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
-dqcom707 compare 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
-dqcom708 compare 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
-
--- miscellaneous
-dqcom721 compare 12345678000 1 -> 1
-dqcom722 compare 1 12345678000 -> -1
-dqcom723 compare 1234567800 1 -> 1
-dqcom724 compare 1 1234567800 -> -1
-dqcom725 compare 1234567890 1 -> 1
-dqcom726 compare 1 1234567890 -> -1
-dqcom727 compare 1234567891 1 -> 1
-dqcom728 compare 1 1234567891 -> -1
-dqcom729 compare 12345678901 1 -> 1
-dqcom730 compare 1 12345678901 -> -1
-dqcom731 compare 1234567896 1 -> 1
-dqcom732 compare 1 1234567896 -> -1
-
--- residue cases at lower precision
-dqcom740 compare 1 0.9999999 -> 1
-dqcom741 compare 1 0.999999 -> 1
-dqcom742 compare 1 0.99999 -> 1
-dqcom743 compare 1 1.0000 -> 0
-dqcom744 compare 1 1.00001 -> -1
-dqcom745 compare 1 1.000001 -> -1
-dqcom746 compare 1 1.0000001 -> -1
-dqcom750 compare 0.9999999 1 -> -1
-dqcom751 compare 0.999999 1 -> -1
-dqcom752 compare 0.99999 1 -> -1
-dqcom753 compare 1.0000 1 -> 0
-dqcom754 compare 1.00001 1 -> 1
-dqcom755 compare 1.000001 1 -> 1
-dqcom756 compare 1.0000001 1 -> 1
-
--- Specials
-dqcom780 compare Inf -Inf -> 1
-dqcom781 compare Inf -1000 -> 1
-dqcom782 compare Inf -1 -> 1
-dqcom783 compare Inf -0 -> 1
-dqcom784 compare Inf 0 -> 1
-dqcom785 compare Inf 1 -> 1
-dqcom786 compare Inf 1000 -> 1
-dqcom787 compare Inf Inf -> 0
-dqcom788 compare -1000 Inf -> -1
-dqcom789 compare -Inf Inf -> -1
-dqcom790 compare -1 Inf -> -1
-dqcom791 compare -0 Inf -> -1
-dqcom792 compare 0 Inf -> -1
-dqcom793 compare 1 Inf -> -1
-dqcom794 compare 1000 Inf -> -1
-dqcom795 compare Inf Inf -> 0
-
-dqcom800 compare -Inf -Inf -> 0
-dqcom801 compare -Inf -1000 -> -1
-dqcom802 compare -Inf -1 -> -1
-dqcom803 compare -Inf -0 -> -1
-dqcom804 compare -Inf 0 -> -1
-dqcom805 compare -Inf 1 -> -1
-dqcom806 compare -Inf 1000 -> -1
-dqcom807 compare -Inf Inf -> -1
-dqcom808 compare -Inf -Inf -> 0
-dqcom809 compare -1000 -Inf -> 1
-dqcom810 compare -1 -Inf -> 1
-dqcom811 compare -0 -Inf -> 1
-dqcom812 compare 0 -Inf -> 1
-dqcom813 compare 1 -Inf -> 1
-dqcom814 compare 1000 -Inf -> 1
-dqcom815 compare Inf -Inf -> 1
-
-dqcom821 compare NaN -Inf -> NaN
-dqcom822 compare NaN -1000 -> NaN
-dqcom823 compare NaN -1 -> NaN
-dqcom824 compare NaN -0 -> NaN
-dqcom825 compare NaN 0 -> NaN
-dqcom826 compare NaN 1 -> NaN
-dqcom827 compare NaN 1000 -> NaN
-dqcom828 compare NaN Inf -> NaN
-dqcom829 compare NaN NaN -> NaN
-dqcom830 compare -Inf NaN -> NaN
-dqcom831 compare -1000 NaN -> NaN
-dqcom832 compare -1 NaN -> NaN
-dqcom833 compare -0 NaN -> NaN
-dqcom834 compare 0 NaN -> NaN
-dqcom835 compare 1 NaN -> NaN
-dqcom836 compare 1000 NaN -> NaN
-dqcom837 compare Inf NaN -> NaN
-dqcom838 compare -NaN -NaN -> -NaN
-dqcom839 compare +NaN -NaN -> NaN
-dqcom840 compare -NaN +NaN -> -NaN
-
-dqcom841 compare sNaN -Inf -> NaN Invalid_operation
-dqcom842 compare sNaN -1000 -> NaN Invalid_operation
-dqcom843 compare sNaN -1 -> NaN Invalid_operation
-dqcom844 compare sNaN -0 -> NaN Invalid_operation
-dqcom845 compare sNaN 0 -> NaN Invalid_operation
-dqcom846 compare sNaN 1 -> NaN Invalid_operation
-dqcom847 compare sNaN 1000 -> NaN Invalid_operation
-dqcom848 compare sNaN NaN -> NaN Invalid_operation
-dqcom849 compare sNaN sNaN -> NaN Invalid_operation
-dqcom850 compare NaN sNaN -> NaN Invalid_operation
-dqcom851 compare -Inf sNaN -> NaN Invalid_operation
-dqcom852 compare -1000 sNaN -> NaN Invalid_operation
-dqcom853 compare -1 sNaN -> NaN Invalid_operation
-dqcom854 compare -0 sNaN -> NaN Invalid_operation
-dqcom855 compare 0 sNaN -> NaN Invalid_operation
-dqcom856 compare 1 sNaN -> NaN Invalid_operation
-dqcom857 compare 1000 sNaN -> NaN Invalid_operation
-dqcom858 compare Inf sNaN -> NaN Invalid_operation
-dqcom859 compare NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqcom860 compare NaN9 -Inf -> NaN9
-dqcom861 compare NaN8 999 -> NaN8
-dqcom862 compare NaN77 Inf -> NaN77
-dqcom863 compare -NaN67 NaN5 -> -NaN67
-dqcom864 compare -Inf -NaN4 -> -NaN4
-dqcom865 compare -999 -NaN33 -> -NaN33
-dqcom866 compare Inf NaN2 -> NaN2
-dqcom867 compare -NaN41 -NaN42 -> -NaN41
-dqcom868 compare +NaN41 -NaN42 -> NaN41
-dqcom869 compare -NaN41 +NaN42 -> -NaN41
-dqcom870 compare +NaN41 +NaN42 -> NaN41
-
-dqcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
-dqcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
-dqcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
-dqcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
-dqcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
-dqcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
-dqcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-dqcom880 compare +1.23456789012345E-0 9E+6144 -> -1
-dqcom881 compare 9E+6144 +1.23456789012345E-0 -> 1
-dqcom882 compare +0.100 9E-6143 -> 1
-dqcom883 compare 9E-6143 +0.100 -> -1
-dqcom885 compare -1.23456789012345E-0 9E+6144 -> -1
-dqcom886 compare 9E+6144 -1.23456789012345E-0 -> 1
-dqcom887 compare -0.100 9E-6143 -> -1
-dqcom888 compare 9E-6143 -0.100 -> 1
-
--- signs
-dqcom901 compare 1e+77 1e+11 -> 1
-dqcom902 compare 1e+77 -1e+11 -> 1
-dqcom903 compare -1e+77 1e+11 -> -1
-dqcom904 compare -1e+77 -1e+11 -> -1
-dqcom905 compare 1e-77 1e-11 -> -1
-dqcom906 compare 1e-77 -1e-11 -> 1
-dqcom907 compare -1e-77 1e-11 -> -1
-dqcom908 compare -1e-77 -1e-11 -> 1
-
--- full alignment range, both ways
-dqcomp1001 compare 1 1.000000000000000000000000000000000 -> 0
-dqcomp1002 compare 1 1.00000000000000000000000000000000 -> 0
-dqcomp1003 compare 1 1.0000000000000000000000000000000 -> 0
-dqcomp1004 compare 1 1.000000000000000000000000000000 -> 0
-dqcomp1005 compare 1 1.00000000000000000000000000000 -> 0
-dqcomp1006 compare 1 1.0000000000000000000000000000 -> 0
-dqcomp1007 compare 1 1.000000000000000000000000000 -> 0
-dqcomp1008 compare 1 1.00000000000000000000000000 -> 0
-dqcomp1009 compare 1 1.0000000000000000000000000 -> 0
-dqcomp1010 compare 1 1.000000000000000000000000 -> 0
-dqcomp1011 compare 1 1.00000000000000000000000 -> 0
-dqcomp1012 compare 1 1.0000000000000000000000 -> 0
-dqcomp1013 compare 1 1.000000000000000000000 -> 0
-dqcomp1014 compare 1 1.00000000000000000000 -> 0
-dqcomp1015 compare 1 1.0000000000000000000 -> 0
-dqcomp1016 compare 1 1.000000000000000000 -> 0
-dqcomp1017 compare 1 1.00000000000000000 -> 0
-dqcomp1018 compare 1 1.0000000000000000 -> 0
-dqcomp1019 compare 1 1.000000000000000 -> 0
-dqcomp1020 compare 1 1.00000000000000 -> 0
-dqcomp1021 compare 1 1.0000000000000 -> 0
-dqcomp1022 compare 1 1.000000000000 -> 0
-dqcomp1023 compare 1 1.00000000000 -> 0
-dqcomp1024 compare 1 1.0000000000 -> 0
-dqcomp1025 compare 1 1.000000000 -> 0
-dqcomp1026 compare 1 1.00000000 -> 0
-dqcomp1027 compare 1 1.0000000 -> 0
-dqcomp1028 compare 1 1.000000 -> 0
-dqcomp1029 compare 1 1.00000 -> 0
-dqcomp1030 compare 1 1.0000 -> 0
-dqcomp1031 compare 1 1.000 -> 0
-dqcomp1032 compare 1 1.00 -> 0
-dqcomp1033 compare 1 1.0 -> 0
-
-dqcomp1041 compare 1.000000000000000000000000000000000 1 -> 0
-dqcomp1042 compare 1.00000000000000000000000000000000 1 -> 0
-dqcomp1043 compare 1.0000000000000000000000000000000 1 -> 0
-dqcomp1044 compare 1.000000000000000000000000000000 1 -> 0
-dqcomp1045 compare 1.00000000000000000000000000000 1 -> 0
-dqcomp1046 compare 1.0000000000000000000000000000 1 -> 0
-dqcomp1047 compare 1.000000000000000000000000000 1 -> 0
-dqcomp1048 compare 1.00000000000000000000000000 1 -> 0
-dqcomp1049 compare 1.0000000000000000000000000 1 -> 0
-dqcomp1050 compare 1.000000000000000000000000 1 -> 0
-dqcomp1051 compare 1.00000000000000000000000 1 -> 0
-dqcomp1052 compare 1.0000000000000000000000 1 -> 0
-dqcomp1053 compare 1.000000000000000000000 1 -> 0
-dqcomp1054 compare 1.00000000000000000000 1 -> 0
-dqcomp1055 compare 1.0000000000000000000 1 -> 0
-dqcomp1056 compare 1.000000000000000000 1 -> 0
-dqcomp1057 compare 1.00000000000000000 1 -> 0
-dqcomp1058 compare 1.0000000000000000 1 -> 0
-dqcomp1059 compare 1.000000000000000 1 -> 0
-dqcomp1060 compare 1.00000000000000 1 -> 0
-dqcomp1061 compare 1.0000000000000 1 -> 0
-dqcomp1062 compare 1.000000000000 1 -> 0
-dqcomp1063 compare 1.00000000000 1 -> 0
-dqcomp1064 compare 1.0000000000 1 -> 0
-dqcomp1065 compare 1.000000000 1 -> 0
-dqcomp1066 compare 1.00000000 1 -> 0
-dqcomp1067 compare 1.0000000 1 -> 0
-dqcomp1068 compare 1.000000 1 -> 0
-dqcomp1069 compare 1.00000 1 -> 0
-dqcomp1070 compare 1.0000 1 -> 0
-dqcomp1071 compare 1.000 1 -> 0
-dqcomp1072 compare 1.00 1 -> 0
-dqcomp1073 compare 1.0 1 -> 0
-
--- check MSD always detected non-zero
-dqcomp1080 compare 0 0.000000000000000000000000000000000 -> 0
-dqcomp1081 compare 0 1.000000000000000000000000000000000 -> -1
-dqcomp1082 compare 0 2.000000000000000000000000000000000 -> -1
-dqcomp1083 compare 0 3.000000000000000000000000000000000 -> -1
-dqcomp1084 compare 0 4.000000000000000000000000000000000 -> -1
-dqcomp1085 compare 0 5.000000000000000000000000000000000 -> -1
-dqcomp1086 compare 0 6.000000000000000000000000000000000 -> -1
-dqcomp1087 compare 0 7.000000000000000000000000000000000 -> -1
-dqcomp1088 compare 0 8.000000000000000000000000000000000 -> -1
-dqcomp1089 compare 0 9.000000000000000000000000000000000 -> -1
-dqcomp1090 compare 0.000000000000000000000000000000000 0 -> 0
-dqcomp1091 compare 1.000000000000000000000000000000000 0 -> 1
-dqcomp1092 compare 2.000000000000000000000000000000000 0 -> 1
-dqcomp1093 compare 3.000000000000000000000000000000000 0 -> 1
-dqcomp1094 compare 4.000000000000000000000000000000000 0 -> 1
-dqcomp1095 compare 5.000000000000000000000000000000000 0 -> 1
-dqcomp1096 compare 6.000000000000000000000000000000000 0 -> 1
-dqcomp1097 compare 7.000000000000000000000000000000000 0 -> 1
-dqcomp1098 compare 8.000000000000000000000000000000000 0 -> 1
-dqcomp1099 compare 9.000000000000000000000000000000000 0 -> 1
-
--- Null tests
-dqcom990 compare 10 # -> NaN Invalid_operation
-dqcom991 compare # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompare.decTest -- decQuad comparison that allows quiet NaNs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcom001 compare -2 -2 -> 0
+dqcom002 compare -2 -1 -> -1
+dqcom003 compare -2 0 -> -1
+dqcom004 compare -2 1 -> -1
+dqcom005 compare -2 2 -> -1
+dqcom006 compare -1 -2 -> 1
+dqcom007 compare -1 -1 -> 0
+dqcom008 compare -1 0 -> -1
+dqcom009 compare -1 1 -> -1
+dqcom010 compare -1 2 -> -1
+dqcom011 compare 0 -2 -> 1
+dqcom012 compare 0 -1 -> 1
+dqcom013 compare 0 0 -> 0
+dqcom014 compare 0 1 -> -1
+dqcom015 compare 0 2 -> -1
+dqcom016 compare 1 -2 -> 1
+dqcom017 compare 1 -1 -> 1
+dqcom018 compare 1 0 -> 1
+dqcom019 compare 1 1 -> 0
+dqcom020 compare 1 2 -> -1
+dqcom021 compare 2 -2 -> 1
+dqcom022 compare 2 -1 -> 1
+dqcom023 compare 2 0 -> 1
+dqcom025 compare 2 1 -> 1
+dqcom026 compare 2 2 -> 0
+
+dqcom031 compare -20 -20 -> 0
+dqcom032 compare -20 -10 -> -1
+dqcom033 compare -20 00 -> -1
+dqcom034 compare -20 10 -> -1
+dqcom035 compare -20 20 -> -1
+dqcom036 compare -10 -20 -> 1
+dqcom037 compare -10 -10 -> 0
+dqcom038 compare -10 00 -> -1
+dqcom039 compare -10 10 -> -1
+dqcom040 compare -10 20 -> -1
+dqcom041 compare 00 -20 -> 1
+dqcom042 compare 00 -10 -> 1
+dqcom043 compare 00 00 -> 0
+dqcom044 compare 00 10 -> -1
+dqcom045 compare 00 20 -> -1
+dqcom046 compare 10 -20 -> 1
+dqcom047 compare 10 -10 -> 1
+dqcom048 compare 10 00 -> 1
+dqcom049 compare 10 10 -> 0
+dqcom050 compare 10 20 -> -1
+dqcom051 compare 20 -20 -> 1
+dqcom052 compare 20 -10 -> 1
+dqcom053 compare 20 00 -> 1
+dqcom055 compare 20 10 -> 1
+dqcom056 compare 20 20 -> 0
+
+dqcom061 compare -2.0 -2.0 -> 0
+dqcom062 compare -2.0 -1.0 -> -1
+dqcom063 compare -2.0 0.0 -> -1
+dqcom064 compare -2.0 1.0 -> -1
+dqcom065 compare -2.0 2.0 -> -1
+dqcom066 compare -1.0 -2.0 -> 1
+dqcom067 compare -1.0 -1.0 -> 0
+dqcom068 compare -1.0 0.0 -> -1
+dqcom069 compare -1.0 1.0 -> -1
+dqcom070 compare -1.0 2.0 -> -1
+dqcom071 compare 0.0 -2.0 -> 1
+dqcom072 compare 0.0 -1.0 -> 1
+dqcom073 compare 0.0 0.0 -> 0
+dqcom074 compare 0.0 1.0 -> -1
+dqcom075 compare 0.0 2.0 -> -1
+dqcom076 compare 1.0 -2.0 -> 1
+dqcom077 compare 1.0 -1.0 -> 1
+dqcom078 compare 1.0 0.0 -> 1
+dqcom079 compare 1.0 1.0 -> 0
+dqcom080 compare 1.0 2.0 -> -1
+dqcom081 compare 2.0 -2.0 -> 1
+dqcom082 compare 2.0 -1.0 -> 1
+dqcom083 compare 2.0 0.0 -> 1
+dqcom085 compare 2.0 1.0 -> 1
+dqcom086 compare 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcom090 compare 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
+dqcom091 compare -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
+dqcom092 compare 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
+dqcom093 compare -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+dqcom100 compare 7.0 7.0 -> 0
+dqcom101 compare 7.0 7 -> 0
+dqcom102 compare 7 7.0 -> 0
+dqcom103 compare 7E+0 7.0 -> 0
+dqcom104 compare 70E-1 7.0 -> 0
+dqcom105 compare 0.7E+1 7 -> 0
+dqcom106 compare 70E-1 7 -> 0
+dqcom107 compare 7.0 7E+0 -> 0
+dqcom108 compare 7.0 70E-1 -> 0
+dqcom109 compare 7 0.7E+1 -> 0
+dqcom110 compare 7 70E-1 -> 0
+
+dqcom120 compare 8.0 7.0 -> 1
+dqcom121 compare 8.0 7 -> 1
+dqcom122 compare 8 7.0 -> 1
+dqcom123 compare 8E+0 7.0 -> 1
+dqcom124 compare 80E-1 7.0 -> 1
+dqcom125 compare 0.8E+1 7 -> 1
+dqcom126 compare 80E-1 7 -> 1
+dqcom127 compare 8.0 7E+0 -> 1
+dqcom128 compare 8.0 70E-1 -> 1
+dqcom129 compare 8 0.7E+1 -> 1
+dqcom130 compare 8 70E-1 -> 1
+
+dqcom140 compare 8.0 9.0 -> -1
+dqcom141 compare 8.0 9 -> -1
+dqcom142 compare 8 9.0 -> -1
+dqcom143 compare 8E+0 9.0 -> -1
+dqcom144 compare 80E-1 9.0 -> -1
+dqcom145 compare 0.8E+1 9 -> -1
+dqcom146 compare 80E-1 9 -> -1
+dqcom147 compare 8.0 9E+0 -> -1
+dqcom148 compare 8.0 90E-1 -> -1
+dqcom149 compare 8 0.9E+1 -> -1
+dqcom150 compare 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcom200 compare -7.0 7.0 -> -1
+dqcom201 compare -7.0 7 -> -1
+dqcom202 compare -7 7.0 -> -1
+dqcom203 compare -7E+0 7.0 -> -1
+dqcom204 compare -70E-1 7.0 -> -1
+dqcom205 compare -0.7E+1 7 -> -1
+dqcom206 compare -70E-1 7 -> -1
+dqcom207 compare -7.0 7E+0 -> -1
+dqcom208 compare -7.0 70E-1 -> -1
+dqcom209 compare -7 0.7E+1 -> -1
+dqcom210 compare -7 70E-1 -> -1
+
+dqcom220 compare -8.0 7.0 -> -1
+dqcom221 compare -8.0 7 -> -1
+dqcom222 compare -8 7.0 -> -1
+dqcom223 compare -8E+0 7.0 -> -1
+dqcom224 compare -80E-1 7.0 -> -1
+dqcom225 compare -0.8E+1 7 -> -1
+dqcom226 compare -80E-1 7 -> -1
+dqcom227 compare -8.0 7E+0 -> -1
+dqcom228 compare -8.0 70E-1 -> -1
+dqcom229 compare -8 0.7E+1 -> -1
+dqcom230 compare -8 70E-1 -> -1
+
+dqcom240 compare -8.0 9.0 -> -1
+dqcom241 compare -8.0 9 -> -1
+dqcom242 compare -8 9.0 -> -1
+dqcom243 compare -8E+0 9.0 -> -1
+dqcom244 compare -80E-1 9.0 -> -1
+dqcom245 compare -0.8E+1 9 -> -1
+dqcom246 compare -80E-1 9 -> -1
+dqcom247 compare -8.0 9E+0 -> -1
+dqcom248 compare -8.0 90E-1 -> -1
+dqcom249 compare -8 0.9E+1 -> -1
+dqcom250 compare -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcom300 compare 7.0 -7.0 -> 1
+dqcom301 compare 7.0 -7 -> 1
+dqcom302 compare 7 -7.0 -> 1
+dqcom303 compare 7E+0 -7.0 -> 1
+dqcom304 compare 70E-1 -7.0 -> 1
+dqcom305 compare .7E+1 -7 -> 1
+dqcom306 compare 70E-1 -7 -> 1
+dqcom307 compare 7.0 -7E+0 -> 1
+dqcom308 compare 7.0 -70E-1 -> 1
+dqcom309 compare 7 -.7E+1 -> 1
+dqcom310 compare 7 -70E-1 -> 1
+
+dqcom320 compare 8.0 -7.0 -> 1
+dqcom321 compare 8.0 -7 -> 1
+dqcom322 compare 8 -7.0 -> 1
+dqcom323 compare 8E+0 -7.0 -> 1
+dqcom324 compare 80E-1 -7.0 -> 1
+dqcom325 compare .8E+1 -7 -> 1
+dqcom326 compare 80E-1 -7 -> 1
+dqcom327 compare 8.0 -7E+0 -> 1
+dqcom328 compare 8.0 -70E-1 -> 1
+dqcom329 compare 8 -.7E+1 -> 1
+dqcom330 compare 8 -70E-1 -> 1
+
+dqcom340 compare 8.0 -9.0 -> 1
+dqcom341 compare 8.0 -9 -> 1
+dqcom342 compare 8 -9.0 -> 1
+dqcom343 compare 8E+0 -9.0 -> 1
+dqcom344 compare 80E-1 -9.0 -> 1
+dqcom345 compare .8E+1 -9 -> 1
+dqcom346 compare 80E-1 -9 -> 1
+dqcom347 compare 8.0 -9E+0 -> 1
+dqcom348 compare 8.0 -90E-1 -> 1
+dqcom349 compare 8 -.9E+1 -> 1
+dqcom350 compare 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcom400 compare -7.0 -7.0 -> 0
+dqcom401 compare -7.0 -7 -> 0
+dqcom402 compare -7 -7.0 -> 0
+dqcom403 compare -7E+0 -7.0 -> 0
+dqcom404 compare -70E-1 -7.0 -> 0
+dqcom405 compare -.7E+1 -7 -> 0
+dqcom406 compare -70E-1 -7 -> 0
+dqcom407 compare -7.0 -7E+0 -> 0
+dqcom408 compare -7.0 -70E-1 -> 0
+dqcom409 compare -7 -.7E+1 -> 0
+dqcom410 compare -7 -70E-1 -> 0
+
+dqcom420 compare -8.0 -7.0 -> -1
+dqcom421 compare -8.0 -7 -> -1
+dqcom422 compare -8 -7.0 -> -1
+dqcom423 compare -8E+0 -7.0 -> -1
+dqcom424 compare -80E-1 -7.0 -> -1
+dqcom425 compare -.8E+1 -7 -> -1
+dqcom426 compare -80E-1 -7 -> -1
+dqcom427 compare -8.0 -7E+0 -> -1
+dqcom428 compare -8.0 -70E-1 -> -1
+dqcom429 compare -8 -.7E+1 -> -1
+dqcom430 compare -8 -70E-1 -> -1
+
+dqcom440 compare -8.0 -9.0 -> 1
+dqcom441 compare -8.0 -9 -> 1
+dqcom442 compare -8 -9.0 -> 1
+dqcom443 compare -8E+0 -9.0 -> 1
+dqcom444 compare -80E-1 -9.0 -> 1
+dqcom445 compare -.8E+1 -9 -> 1
+dqcom446 compare -80E-1 -9 -> 1
+dqcom447 compare -8.0 -9E+0 -> 1
+dqcom448 compare -8.0 -90E-1 -> 1
+dqcom449 compare -8 -.9E+1 -> 1
+dqcom450 compare -8 -90E-1 -> 1
+
+-- misalignment traps for little-endian
+dqcom451 compare 1.0 0.1 -> 1
+dqcom452 compare 0.1 1.0 -> -1
+dqcom453 compare 10.0 0.1 -> 1
+dqcom454 compare 0.1 10.0 -> -1
+dqcom455 compare 100 1.0 -> 1
+dqcom456 compare 1.0 100 -> -1
+dqcom457 compare 1000 10.0 -> 1
+dqcom458 compare 10.0 1000 -> -1
+dqcom459 compare 10000 100.0 -> 1
+dqcom460 compare 100.0 10000 -> -1
+dqcom461 compare 100000 1000.0 -> 1
+dqcom462 compare 1000.0 100000 -> -1
+dqcom463 compare 1000000 10000.0 -> 1
+dqcom464 compare 10000.0 1000000 -> -1
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcom473 compare 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
+dqcom474 compare 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
+dqcom475 compare 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
+dqcom476 compare 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
+dqcom477 compare 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
+dqcom478 compare 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
+dqcom479 compare 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
+dqcom480 compare 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
+dqcom481 compare 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
+dqcom482 compare 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
+dqcom483 compare 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
+dqcom487 compare 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
+dqcom488 compare 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
+dqcom489 compare 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
+dqcom490 compare 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
+dqcom491 compare 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
+dqcom492 compare 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
+dqcom493 compare 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
+dqcom494 compare 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
+dqcom495 compare 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
+dqcom496 compare 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
+dqcom497 compare 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcom500 compare 1 1E-15 -> 1
+dqcom501 compare 1 1E-14 -> 1
+dqcom502 compare 1 1E-13 -> 1
+dqcom503 compare 1 1E-12 -> 1
+dqcom504 compare 1 1E-11 -> 1
+dqcom505 compare 1 1E-10 -> 1
+dqcom506 compare 1 1E-9 -> 1
+dqcom507 compare 1 1E-8 -> 1
+dqcom508 compare 1 1E-7 -> 1
+dqcom509 compare 1 1E-6 -> 1
+dqcom510 compare 1 1E-5 -> 1
+dqcom511 compare 1 1E-4 -> 1
+dqcom512 compare 1 1E-3 -> 1
+dqcom513 compare 1 1E-2 -> 1
+dqcom514 compare 1 1E-1 -> 1
+dqcom515 compare 1 1E-0 -> 0
+dqcom516 compare 1 1E+1 -> -1
+dqcom517 compare 1 1E+2 -> -1
+dqcom518 compare 1 1E+3 -> -1
+dqcom519 compare 1 1E+4 -> -1
+dqcom521 compare 1 1E+5 -> -1
+dqcom522 compare 1 1E+6 -> -1
+dqcom523 compare 1 1E+7 -> -1
+dqcom524 compare 1 1E+8 -> -1
+dqcom525 compare 1 1E+9 -> -1
+dqcom526 compare 1 1E+10 -> -1
+dqcom527 compare 1 1E+11 -> -1
+dqcom528 compare 1 1E+12 -> -1
+dqcom529 compare 1 1E+13 -> -1
+dqcom530 compare 1 1E+14 -> -1
+dqcom531 compare 1 1E+15 -> -1
+-- LR swap
+dqcom540 compare 1E-15 1 -> -1
+dqcom541 compare 1E-14 1 -> -1
+dqcom542 compare 1E-13 1 -> -1
+dqcom543 compare 1E-12 1 -> -1
+dqcom544 compare 1E-11 1 -> -1
+dqcom545 compare 1E-10 1 -> -1
+dqcom546 compare 1E-9 1 -> -1
+dqcom547 compare 1E-8 1 -> -1
+dqcom548 compare 1E-7 1 -> -1
+dqcom549 compare 1E-6 1 -> -1
+dqcom550 compare 1E-5 1 -> -1
+dqcom551 compare 1E-4 1 -> -1
+dqcom552 compare 1E-3 1 -> -1
+dqcom553 compare 1E-2 1 -> -1
+dqcom554 compare 1E-1 1 -> -1
+dqcom555 compare 1E-0 1 -> 0
+dqcom556 compare 1E+1 1 -> 1
+dqcom557 compare 1E+2 1 -> 1
+dqcom558 compare 1E+3 1 -> 1
+dqcom559 compare 1E+4 1 -> 1
+dqcom561 compare 1E+5 1 -> 1
+dqcom562 compare 1E+6 1 -> 1
+dqcom563 compare 1E+7 1 -> 1
+dqcom564 compare 1E+8 1 -> 1
+dqcom565 compare 1E+9 1 -> 1
+dqcom566 compare 1E+10 1 -> 1
+dqcom567 compare 1E+11 1 -> 1
+dqcom568 compare 1E+12 1 -> 1
+dqcom569 compare 1E+13 1 -> 1
+dqcom570 compare 1E+14 1 -> 1
+dqcom571 compare 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcom580 compare 0.000000987654321 1E-15 -> 1
+dqcom581 compare 0.000000987654321 1E-14 -> 1
+dqcom582 compare 0.000000987654321 1E-13 -> 1
+dqcom583 compare 0.000000987654321 1E-12 -> 1
+dqcom584 compare 0.000000987654321 1E-11 -> 1
+dqcom585 compare 0.000000987654321 1E-10 -> 1
+dqcom586 compare 0.000000987654321 1E-9 -> 1
+dqcom587 compare 0.000000987654321 1E-8 -> 1
+dqcom588 compare 0.000000987654321 1E-7 -> 1
+dqcom589 compare 0.000000987654321 1E-6 -> -1
+dqcom590 compare 0.000000987654321 1E-5 -> -1
+dqcom591 compare 0.000000987654321 1E-4 -> -1
+dqcom592 compare 0.000000987654321 1E-3 -> -1
+dqcom593 compare 0.000000987654321 1E-2 -> -1
+dqcom594 compare 0.000000987654321 1E-1 -> -1
+dqcom595 compare 0.000000987654321 1E-0 -> -1
+dqcom596 compare 0.000000987654321 1E+1 -> -1
+dqcom597 compare 0.000000987654321 1E+2 -> -1
+dqcom598 compare 0.000000987654321 1E+3 -> -1
+dqcom599 compare 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcom600 compare 12 12.2345 -> -1
+dqcom601 compare 12.0 12.2345 -> -1
+dqcom602 compare 12.00 12.2345 -> -1
+dqcom603 compare 12.000 12.2345 -> -1
+dqcom604 compare 12.0000 12.2345 -> -1
+dqcom605 compare 12.00000 12.2345 -> -1
+dqcom606 compare 12.000000 12.2345 -> -1
+dqcom607 compare 12.0000000 12.2345 -> -1
+dqcom608 compare 12.00000000 12.2345 -> -1
+dqcom609 compare 12.000000000 12.2345 -> -1
+dqcom610 compare 12.1234 12 -> 1
+dqcom611 compare 12.1234 12.0 -> 1
+dqcom612 compare 12.1234 12.00 -> 1
+dqcom613 compare 12.1234 12.000 -> 1
+dqcom614 compare 12.1234 12.0000 -> 1
+dqcom615 compare 12.1234 12.00000 -> 1
+dqcom616 compare 12.1234 12.000000 -> 1
+dqcom617 compare 12.1234 12.0000000 -> 1
+dqcom618 compare 12.1234 12.00000000 -> 1
+dqcom619 compare 12.1234 12.000000000 -> 1
+dqcom620 compare -12 -12.2345 -> 1
+dqcom621 compare -12.0 -12.2345 -> 1
+dqcom622 compare -12.00 -12.2345 -> 1
+dqcom623 compare -12.000 -12.2345 -> 1
+dqcom624 compare -12.0000 -12.2345 -> 1
+dqcom625 compare -12.00000 -12.2345 -> 1
+dqcom626 compare -12.000000 -12.2345 -> 1
+dqcom627 compare -12.0000000 -12.2345 -> 1
+dqcom628 compare -12.00000000 -12.2345 -> 1
+dqcom629 compare -12.000000000 -12.2345 -> 1
+dqcom630 compare -12.1234 -12 -> -1
+dqcom631 compare -12.1234 -12.0 -> -1
+dqcom632 compare -12.1234 -12.00 -> -1
+dqcom633 compare -12.1234 -12.000 -> -1
+dqcom634 compare -12.1234 -12.0000 -> -1
+dqcom635 compare -12.1234 -12.00000 -> -1
+dqcom636 compare -12.1234 -12.000000 -> -1
+dqcom637 compare -12.1234 -12.0000000 -> -1
+dqcom638 compare -12.1234 -12.00000000 -> -1
+dqcom639 compare -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcom640 compare 0 0 -> 0
+dqcom641 compare 0 -0 -> 0
+dqcom642 compare 0 -0.0 -> 0
+dqcom643 compare 0 0.0 -> 0
+dqcom644 compare -0 0 -> 0
+dqcom645 compare -0 -0 -> 0
+dqcom646 compare -0 -0.0 -> 0
+dqcom647 compare -0 0.0 -> 0
+dqcom648 compare 0.0 0 -> 0
+dqcom649 compare 0.0 -0 -> 0
+dqcom650 compare 0.0 -0.0 -> 0
+dqcom651 compare 0.0 0.0 -> 0
+dqcom652 compare -0.0 0 -> 0
+dqcom653 compare -0.0 -0 -> 0
+dqcom654 compare -0.0 -0.0 -> 0
+dqcom655 compare -0.0 0.0 -> 0
+
+dqcom656 compare -0E1 0.0 -> 0
+dqcom657 compare -0E2 0.0 -> 0
+dqcom658 compare 0E1 0.0 -> 0
+dqcom659 compare 0E2 0.0 -> 0
+dqcom660 compare -0E1 0 -> 0
+dqcom661 compare -0E2 0 -> 0
+dqcom662 compare 0E1 0 -> 0
+dqcom663 compare 0E2 0 -> 0
+dqcom664 compare -0E1 -0E1 -> 0
+dqcom665 compare -0E2 -0E1 -> 0
+dqcom666 compare 0E1 -0E1 -> 0
+dqcom667 compare 0E2 -0E1 -> 0
+dqcom668 compare -0E1 -0E2 -> 0
+dqcom669 compare -0E2 -0E2 -> 0
+dqcom670 compare 0E1 -0E2 -> 0
+dqcom671 compare 0E2 -0E2 -> 0
+dqcom672 compare -0E1 0E1 -> 0
+dqcom673 compare -0E2 0E1 -> 0
+dqcom674 compare 0E1 0E1 -> 0
+dqcom675 compare 0E2 0E1 -> 0
+dqcom676 compare -0E1 0E2 -> 0
+dqcom677 compare -0E2 0E2 -> 0
+dqcom678 compare 0E1 0E2 -> 0
+dqcom679 compare 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcom680 compare 12 12 -> 0
+dqcom681 compare 12 12.0 -> 0
+dqcom682 compare 12 12.00 -> 0
+dqcom683 compare 12 12.000 -> 0
+dqcom684 compare 12 12.0000 -> 0
+dqcom685 compare 12 12.00000 -> 0
+dqcom686 compare 12 12.000000 -> 0
+dqcom687 compare 12 12.0000000 -> 0
+dqcom688 compare 12 12.00000000 -> 0
+dqcom689 compare 12 12.000000000 -> 0
+dqcom690 compare 12 12 -> 0
+dqcom691 compare 12.0 12 -> 0
+dqcom692 compare 12.00 12 -> 0
+dqcom693 compare 12.000 12 -> 0
+dqcom694 compare 12.0000 12 -> 0
+dqcom695 compare 12.00000 12 -> 0
+dqcom696 compare 12.000000 12 -> 0
+dqcom697 compare 12.0000000 12 -> 0
+dqcom698 compare 12.00000000 12 -> 0
+dqcom699 compare 12.000000000 12 -> 0
+
+-- first, second, & last digit
+dqcom700 compare 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
+dqcom701 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcom702 compare 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
+dqcom703 compare 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
+dqcom704 compare 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcom705 compare 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
+dqcom706 compare 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
+dqcom707 compare 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
+dqcom708 compare 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
+
+-- miscellaneous
+dqcom721 compare 12345678000 1 -> 1
+dqcom722 compare 1 12345678000 -> -1
+dqcom723 compare 1234567800 1 -> 1
+dqcom724 compare 1 1234567800 -> -1
+dqcom725 compare 1234567890 1 -> 1
+dqcom726 compare 1 1234567890 -> -1
+dqcom727 compare 1234567891 1 -> 1
+dqcom728 compare 1 1234567891 -> -1
+dqcom729 compare 12345678901 1 -> 1
+dqcom730 compare 1 12345678901 -> -1
+dqcom731 compare 1234567896 1 -> 1
+dqcom732 compare 1 1234567896 -> -1
+
+-- residue cases at lower precision
+dqcom740 compare 1 0.9999999 -> 1
+dqcom741 compare 1 0.999999 -> 1
+dqcom742 compare 1 0.99999 -> 1
+dqcom743 compare 1 1.0000 -> 0
+dqcom744 compare 1 1.00001 -> -1
+dqcom745 compare 1 1.000001 -> -1
+dqcom746 compare 1 1.0000001 -> -1
+dqcom750 compare 0.9999999 1 -> -1
+dqcom751 compare 0.999999 1 -> -1
+dqcom752 compare 0.99999 1 -> -1
+dqcom753 compare 1.0000 1 -> 0
+dqcom754 compare 1.00001 1 -> 1
+dqcom755 compare 1.000001 1 -> 1
+dqcom756 compare 1.0000001 1 -> 1
+
+-- Specials
+dqcom780 compare Inf -Inf -> 1
+dqcom781 compare Inf -1000 -> 1
+dqcom782 compare Inf -1 -> 1
+dqcom783 compare Inf -0 -> 1
+dqcom784 compare Inf 0 -> 1
+dqcom785 compare Inf 1 -> 1
+dqcom786 compare Inf 1000 -> 1
+dqcom787 compare Inf Inf -> 0
+dqcom788 compare -1000 Inf -> -1
+dqcom789 compare -Inf Inf -> -1
+dqcom790 compare -1 Inf -> -1
+dqcom791 compare -0 Inf -> -1
+dqcom792 compare 0 Inf -> -1
+dqcom793 compare 1 Inf -> -1
+dqcom794 compare 1000 Inf -> -1
+dqcom795 compare Inf Inf -> 0
+
+dqcom800 compare -Inf -Inf -> 0
+dqcom801 compare -Inf -1000 -> -1
+dqcom802 compare -Inf -1 -> -1
+dqcom803 compare -Inf -0 -> -1
+dqcom804 compare -Inf 0 -> -1
+dqcom805 compare -Inf 1 -> -1
+dqcom806 compare -Inf 1000 -> -1
+dqcom807 compare -Inf Inf -> -1
+dqcom808 compare -Inf -Inf -> 0
+dqcom809 compare -1000 -Inf -> 1
+dqcom810 compare -1 -Inf -> 1
+dqcom811 compare -0 -Inf -> 1
+dqcom812 compare 0 -Inf -> 1
+dqcom813 compare 1 -Inf -> 1
+dqcom814 compare 1000 -Inf -> 1
+dqcom815 compare Inf -Inf -> 1
+
+dqcom821 compare NaN -Inf -> NaN
+dqcom822 compare NaN -1000 -> NaN
+dqcom823 compare NaN -1 -> NaN
+dqcom824 compare NaN -0 -> NaN
+dqcom825 compare NaN 0 -> NaN
+dqcom826 compare NaN 1 -> NaN
+dqcom827 compare NaN 1000 -> NaN
+dqcom828 compare NaN Inf -> NaN
+dqcom829 compare NaN NaN -> NaN
+dqcom830 compare -Inf NaN -> NaN
+dqcom831 compare -1000 NaN -> NaN
+dqcom832 compare -1 NaN -> NaN
+dqcom833 compare -0 NaN -> NaN
+dqcom834 compare 0 NaN -> NaN
+dqcom835 compare 1 NaN -> NaN
+dqcom836 compare 1000 NaN -> NaN
+dqcom837 compare Inf NaN -> NaN
+dqcom838 compare -NaN -NaN -> -NaN
+dqcom839 compare +NaN -NaN -> NaN
+dqcom840 compare -NaN +NaN -> -NaN
+
+dqcom841 compare sNaN -Inf -> NaN Invalid_operation
+dqcom842 compare sNaN -1000 -> NaN Invalid_operation
+dqcom843 compare sNaN -1 -> NaN Invalid_operation
+dqcom844 compare sNaN -0 -> NaN Invalid_operation
+dqcom845 compare sNaN 0 -> NaN Invalid_operation
+dqcom846 compare sNaN 1 -> NaN Invalid_operation
+dqcom847 compare sNaN 1000 -> NaN Invalid_operation
+dqcom848 compare sNaN NaN -> NaN Invalid_operation
+dqcom849 compare sNaN sNaN -> NaN Invalid_operation
+dqcom850 compare NaN sNaN -> NaN Invalid_operation
+dqcom851 compare -Inf sNaN -> NaN Invalid_operation
+dqcom852 compare -1000 sNaN -> NaN Invalid_operation
+dqcom853 compare -1 sNaN -> NaN Invalid_operation
+dqcom854 compare -0 sNaN -> NaN Invalid_operation
+dqcom855 compare 0 sNaN -> NaN Invalid_operation
+dqcom856 compare 1 sNaN -> NaN Invalid_operation
+dqcom857 compare 1000 sNaN -> NaN Invalid_operation
+dqcom858 compare Inf sNaN -> NaN Invalid_operation
+dqcom859 compare NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqcom860 compare NaN9 -Inf -> NaN9
+dqcom861 compare NaN8 999 -> NaN8
+dqcom862 compare NaN77 Inf -> NaN77
+dqcom863 compare -NaN67 NaN5 -> -NaN67
+dqcom864 compare -Inf -NaN4 -> -NaN4
+dqcom865 compare -999 -NaN33 -> -NaN33
+dqcom866 compare Inf NaN2 -> NaN2
+dqcom867 compare -NaN41 -NaN42 -> -NaN41
+dqcom868 compare +NaN41 -NaN42 -> NaN41
+dqcom869 compare -NaN41 +NaN42 -> -NaN41
+dqcom870 compare +NaN41 +NaN42 -> NaN41
+
+dqcom871 compare -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqcom872 compare sNaN98 -11 -> NaN98 Invalid_operation
+dqcom873 compare sNaN97 NaN -> NaN97 Invalid_operation
+dqcom874 compare sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqcom875 compare NaN85 sNaN83 -> NaN83 Invalid_operation
+dqcom876 compare -Inf sNaN92 -> NaN92 Invalid_operation
+dqcom877 compare 088 sNaN81 -> NaN81 Invalid_operation
+dqcom878 compare Inf sNaN90 -> NaN90 Invalid_operation
+dqcom879 compare NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+dqcom880 compare +1.23456789012345E-0 9E+6144 -> -1
+dqcom881 compare 9E+6144 +1.23456789012345E-0 -> 1
+dqcom882 compare +0.100 9E-6143 -> 1
+dqcom883 compare 9E-6143 +0.100 -> -1
+dqcom885 compare -1.23456789012345E-0 9E+6144 -> -1
+dqcom886 compare 9E+6144 -1.23456789012345E-0 -> 1
+dqcom887 compare -0.100 9E-6143 -> -1
+dqcom888 compare 9E-6143 -0.100 -> 1
+
+-- signs
+dqcom901 compare 1e+77 1e+11 -> 1
+dqcom902 compare 1e+77 -1e+11 -> 1
+dqcom903 compare -1e+77 1e+11 -> -1
+dqcom904 compare -1e+77 -1e+11 -> -1
+dqcom905 compare 1e-77 1e-11 -> -1
+dqcom906 compare 1e-77 -1e-11 -> 1
+dqcom907 compare -1e-77 1e-11 -> -1
+dqcom908 compare -1e-77 -1e-11 -> 1
+
+-- full alignment range, both ways
+dqcomp1001 compare 1 1.000000000000000000000000000000000 -> 0
+dqcomp1002 compare 1 1.00000000000000000000000000000000 -> 0
+dqcomp1003 compare 1 1.0000000000000000000000000000000 -> 0
+dqcomp1004 compare 1 1.000000000000000000000000000000 -> 0
+dqcomp1005 compare 1 1.00000000000000000000000000000 -> 0
+dqcomp1006 compare 1 1.0000000000000000000000000000 -> 0
+dqcomp1007 compare 1 1.000000000000000000000000000 -> 0
+dqcomp1008 compare 1 1.00000000000000000000000000 -> 0
+dqcomp1009 compare 1 1.0000000000000000000000000 -> 0
+dqcomp1010 compare 1 1.000000000000000000000000 -> 0
+dqcomp1011 compare 1 1.00000000000000000000000 -> 0
+dqcomp1012 compare 1 1.0000000000000000000000 -> 0
+dqcomp1013 compare 1 1.000000000000000000000 -> 0
+dqcomp1014 compare 1 1.00000000000000000000 -> 0
+dqcomp1015 compare 1 1.0000000000000000000 -> 0
+dqcomp1016 compare 1 1.000000000000000000 -> 0
+dqcomp1017 compare 1 1.00000000000000000 -> 0
+dqcomp1018 compare 1 1.0000000000000000 -> 0
+dqcomp1019 compare 1 1.000000000000000 -> 0
+dqcomp1020 compare 1 1.00000000000000 -> 0
+dqcomp1021 compare 1 1.0000000000000 -> 0
+dqcomp1022 compare 1 1.000000000000 -> 0
+dqcomp1023 compare 1 1.00000000000 -> 0
+dqcomp1024 compare 1 1.0000000000 -> 0
+dqcomp1025 compare 1 1.000000000 -> 0
+dqcomp1026 compare 1 1.00000000 -> 0
+dqcomp1027 compare 1 1.0000000 -> 0
+dqcomp1028 compare 1 1.000000 -> 0
+dqcomp1029 compare 1 1.00000 -> 0
+dqcomp1030 compare 1 1.0000 -> 0
+dqcomp1031 compare 1 1.000 -> 0
+dqcomp1032 compare 1 1.00 -> 0
+dqcomp1033 compare 1 1.0 -> 0
+
+dqcomp1041 compare 1.000000000000000000000000000000000 1 -> 0
+dqcomp1042 compare 1.00000000000000000000000000000000 1 -> 0
+dqcomp1043 compare 1.0000000000000000000000000000000 1 -> 0
+dqcomp1044 compare 1.000000000000000000000000000000 1 -> 0
+dqcomp1045 compare 1.00000000000000000000000000000 1 -> 0
+dqcomp1046 compare 1.0000000000000000000000000000 1 -> 0
+dqcomp1047 compare 1.000000000000000000000000000 1 -> 0
+dqcomp1048 compare 1.00000000000000000000000000 1 -> 0
+dqcomp1049 compare 1.0000000000000000000000000 1 -> 0
+dqcomp1050 compare 1.000000000000000000000000 1 -> 0
+dqcomp1051 compare 1.00000000000000000000000 1 -> 0
+dqcomp1052 compare 1.0000000000000000000000 1 -> 0
+dqcomp1053 compare 1.000000000000000000000 1 -> 0
+dqcomp1054 compare 1.00000000000000000000 1 -> 0
+dqcomp1055 compare 1.0000000000000000000 1 -> 0
+dqcomp1056 compare 1.000000000000000000 1 -> 0
+dqcomp1057 compare 1.00000000000000000 1 -> 0
+dqcomp1058 compare 1.0000000000000000 1 -> 0
+dqcomp1059 compare 1.000000000000000 1 -> 0
+dqcomp1060 compare 1.00000000000000 1 -> 0
+dqcomp1061 compare 1.0000000000000 1 -> 0
+dqcomp1062 compare 1.000000000000 1 -> 0
+dqcomp1063 compare 1.00000000000 1 -> 0
+dqcomp1064 compare 1.0000000000 1 -> 0
+dqcomp1065 compare 1.000000000 1 -> 0
+dqcomp1066 compare 1.00000000 1 -> 0
+dqcomp1067 compare 1.0000000 1 -> 0
+dqcomp1068 compare 1.000000 1 -> 0
+dqcomp1069 compare 1.00000 1 -> 0
+dqcomp1070 compare 1.0000 1 -> 0
+dqcomp1071 compare 1.000 1 -> 0
+dqcomp1072 compare 1.00 1 -> 0
+dqcomp1073 compare 1.0 1 -> 0
+
+-- check MSD always detected non-zero
+dqcomp1080 compare 0 0.000000000000000000000000000000000 -> 0
+dqcomp1081 compare 0 1.000000000000000000000000000000000 -> -1
+dqcomp1082 compare 0 2.000000000000000000000000000000000 -> -1
+dqcomp1083 compare 0 3.000000000000000000000000000000000 -> -1
+dqcomp1084 compare 0 4.000000000000000000000000000000000 -> -1
+dqcomp1085 compare 0 5.000000000000000000000000000000000 -> -1
+dqcomp1086 compare 0 6.000000000000000000000000000000000 -> -1
+dqcomp1087 compare 0 7.000000000000000000000000000000000 -> -1
+dqcomp1088 compare 0 8.000000000000000000000000000000000 -> -1
+dqcomp1089 compare 0 9.000000000000000000000000000000000 -> -1
+dqcomp1090 compare 0.000000000000000000000000000000000 0 -> 0
+dqcomp1091 compare 1.000000000000000000000000000000000 0 -> 1
+dqcomp1092 compare 2.000000000000000000000000000000000 0 -> 1
+dqcomp1093 compare 3.000000000000000000000000000000000 0 -> 1
+dqcomp1094 compare 4.000000000000000000000000000000000 0 -> 1
+dqcomp1095 compare 5.000000000000000000000000000000000 0 -> 1
+dqcomp1096 compare 6.000000000000000000000000000000000 0 -> 1
+dqcomp1097 compare 7.000000000000000000000000000000000 0 -> 1
+dqcomp1098 compare 8.000000000000000000000000000000000 0 -> 1
+dqcomp1099 compare 9.000000000000000000000000000000000 0 -> 1
+
+-- Null tests
+dqcom990 compare 10 # -> NaN Invalid_operation
+dqcom991 compare # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareSig.decTest b/Lib/test/decimaltestdata/dqCompareSig.decTest
index 795f0916dde..c068d471c1b 100644
--- a/Lib/test/decimaltestdata/dqCompareSig.decTest
+++ b/Lib/test/decimaltestdata/dqCompareSig.decTest
@@ -1,647 +1,647 @@
-------------------------------------------------------------------------
--- dqCompareSig.decTest -- decQuad comparison; all NaNs signal --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcms001 comparesig -2 -2 -> 0
-dqcms002 comparesig -2 -1 -> -1
-dqcms003 comparesig -2 0 -> -1
-dqcms004 comparesig -2 1 -> -1
-dqcms005 comparesig -2 2 -> -1
-dqcms006 comparesig -1 -2 -> 1
-dqcms007 comparesig -1 -1 -> 0
-dqcms008 comparesig -1 0 -> -1
-dqcms009 comparesig -1 1 -> -1
-dqcms010 comparesig -1 2 -> -1
-dqcms011 comparesig 0 -2 -> 1
-dqcms012 comparesig 0 -1 -> 1
-dqcms013 comparesig 0 0 -> 0
-dqcms014 comparesig 0 1 -> -1
-dqcms015 comparesig 0 2 -> -1
-dqcms016 comparesig 1 -2 -> 1
-dqcms017 comparesig 1 -1 -> 1
-dqcms018 comparesig 1 0 -> 1
-dqcms019 comparesig 1 1 -> 0
-dqcms020 comparesig 1 2 -> -1
-dqcms021 comparesig 2 -2 -> 1
-dqcms022 comparesig 2 -1 -> 1
-dqcms023 comparesig 2 0 -> 1
-dqcms025 comparesig 2 1 -> 1
-dqcms026 comparesig 2 2 -> 0
-
-dqcms031 comparesig -20 -20 -> 0
-dqcms032 comparesig -20 -10 -> -1
-dqcms033 comparesig -20 00 -> -1
-dqcms034 comparesig -20 10 -> -1
-dqcms035 comparesig -20 20 -> -1
-dqcms036 comparesig -10 -20 -> 1
-dqcms037 comparesig -10 -10 -> 0
-dqcms038 comparesig -10 00 -> -1
-dqcms039 comparesig -10 10 -> -1
-dqcms040 comparesig -10 20 -> -1
-dqcms041 comparesig 00 -20 -> 1
-dqcms042 comparesig 00 -10 -> 1
-dqcms043 comparesig 00 00 -> 0
-dqcms044 comparesig 00 10 -> -1
-dqcms045 comparesig 00 20 -> -1
-dqcms046 comparesig 10 -20 -> 1
-dqcms047 comparesig 10 -10 -> 1
-dqcms048 comparesig 10 00 -> 1
-dqcms049 comparesig 10 10 -> 0
-dqcms050 comparesig 10 20 -> -1
-dqcms051 comparesig 20 -20 -> 1
-dqcms052 comparesig 20 -10 -> 1
-dqcms053 comparesig 20 00 -> 1
-dqcms055 comparesig 20 10 -> 1
-dqcms056 comparesig 20 20 -> 0
-
-dqcms061 comparesig -2.0 -2.0 -> 0
-dqcms062 comparesig -2.0 -1.0 -> -1
-dqcms063 comparesig -2.0 0.0 -> -1
-dqcms064 comparesig -2.0 1.0 -> -1
-dqcms065 comparesig -2.0 2.0 -> -1
-dqcms066 comparesig -1.0 -2.0 -> 1
-dqcms067 comparesig -1.0 -1.0 -> 0
-dqcms068 comparesig -1.0 0.0 -> -1
-dqcms069 comparesig -1.0 1.0 -> -1
-dqcms070 comparesig -1.0 2.0 -> -1
-dqcms071 comparesig 0.0 -2.0 -> 1
-dqcms072 comparesig 0.0 -1.0 -> 1
-dqcms073 comparesig 0.0 0.0 -> 0
-dqcms074 comparesig 0.0 1.0 -> -1
-dqcms075 comparesig 0.0 2.0 -> -1
-dqcms076 comparesig 1.0 -2.0 -> 1
-dqcms077 comparesig 1.0 -1.0 -> 1
-dqcms078 comparesig 1.0 0.0 -> 1
-dqcms079 comparesig 1.0 1.0 -> 0
-dqcms080 comparesig 1.0 2.0 -> -1
-dqcms081 comparesig 2.0 -2.0 -> 1
-dqcms082 comparesig 2.0 -1.0 -> 1
-dqcms083 comparesig 2.0 0.0 -> 1
-dqcms085 comparesig 2.0 1.0 -> 1
-dqcms086 comparesig 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcms090 comparesig 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
-dqcms091 comparesig -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
-dqcms092 comparesig 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
-dqcms093 comparesig -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
-dqcms100 comparesig 7.0 7.0 -> 0
-dqcms101 comparesig 7.0 7 -> 0
-dqcms102 comparesig 7 7.0 -> 0
-dqcms103 comparesig 7E+0 7.0 -> 0
-dqcms104 comparesig 70E-1 7.0 -> 0
-dqcms105 comparesig 0.7E+1 7 -> 0
-dqcms106 comparesig 70E-1 7 -> 0
-dqcms107 comparesig 7.0 7E+0 -> 0
-dqcms108 comparesig 7.0 70E-1 -> 0
-dqcms109 comparesig 7 0.7E+1 -> 0
-dqcms110 comparesig 7 70E-1 -> 0
-
-dqcms120 comparesig 8.0 7.0 -> 1
-dqcms121 comparesig 8.0 7 -> 1
-dqcms122 comparesig 8 7.0 -> 1
-dqcms123 comparesig 8E+0 7.0 -> 1
-dqcms124 comparesig 80E-1 7.0 -> 1
-dqcms125 comparesig 0.8E+1 7 -> 1
-dqcms126 comparesig 80E-1 7 -> 1
-dqcms127 comparesig 8.0 7E+0 -> 1
-dqcms128 comparesig 8.0 70E-1 -> 1
-dqcms129 comparesig 8 0.7E+1 -> 1
-dqcms130 comparesig 8 70E-1 -> 1
-
-dqcms140 comparesig 8.0 9.0 -> -1
-dqcms141 comparesig 8.0 9 -> -1
-dqcms142 comparesig 8 9.0 -> -1
-dqcms143 comparesig 8E+0 9.0 -> -1
-dqcms144 comparesig 80E-1 9.0 -> -1
-dqcms145 comparesig 0.8E+1 9 -> -1
-dqcms146 comparesig 80E-1 9 -> -1
-dqcms147 comparesig 8.0 9E+0 -> -1
-dqcms148 comparesig 8.0 90E-1 -> -1
-dqcms149 comparesig 8 0.9E+1 -> -1
-dqcms150 comparesig 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcms200 comparesig -7.0 7.0 -> -1
-dqcms201 comparesig -7.0 7 -> -1
-dqcms202 comparesig -7 7.0 -> -1
-dqcms203 comparesig -7E+0 7.0 -> -1
-dqcms204 comparesig -70E-1 7.0 -> -1
-dqcms205 comparesig -0.7E+1 7 -> -1
-dqcms206 comparesig -70E-1 7 -> -1
-dqcms207 comparesig -7.0 7E+0 -> -1
-dqcms208 comparesig -7.0 70E-1 -> -1
-dqcms209 comparesig -7 0.7E+1 -> -1
-dqcms210 comparesig -7 70E-1 -> -1
-
-dqcms220 comparesig -8.0 7.0 -> -1
-dqcms221 comparesig -8.0 7 -> -1
-dqcms222 comparesig -8 7.0 -> -1
-dqcms223 comparesig -8E+0 7.0 -> -1
-dqcms224 comparesig -80E-1 7.0 -> -1
-dqcms225 comparesig -0.8E+1 7 -> -1
-dqcms226 comparesig -80E-1 7 -> -1
-dqcms227 comparesig -8.0 7E+0 -> -1
-dqcms228 comparesig -8.0 70E-1 -> -1
-dqcms229 comparesig -8 0.7E+1 -> -1
-dqcms230 comparesig -8 70E-1 -> -1
-
-dqcms240 comparesig -8.0 9.0 -> -1
-dqcms241 comparesig -8.0 9 -> -1
-dqcms242 comparesig -8 9.0 -> -1
-dqcms243 comparesig -8E+0 9.0 -> -1
-dqcms244 comparesig -80E-1 9.0 -> -1
-dqcms245 comparesig -0.8E+1 9 -> -1
-dqcms246 comparesig -80E-1 9 -> -1
-dqcms247 comparesig -8.0 9E+0 -> -1
-dqcms248 comparesig -8.0 90E-1 -> -1
-dqcms249 comparesig -8 0.9E+1 -> -1
-dqcms250 comparesig -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcms300 comparesig 7.0 -7.0 -> 1
-dqcms301 comparesig 7.0 -7 -> 1
-dqcms302 comparesig 7 -7.0 -> 1
-dqcms303 comparesig 7E+0 -7.0 -> 1
-dqcms304 comparesig 70E-1 -7.0 -> 1
-dqcms305 comparesig .7E+1 -7 -> 1
-dqcms306 comparesig 70E-1 -7 -> 1
-dqcms307 comparesig 7.0 -7E+0 -> 1
-dqcms308 comparesig 7.0 -70E-1 -> 1
-dqcms309 comparesig 7 -.7E+1 -> 1
-dqcms310 comparesig 7 -70E-1 -> 1
-
-dqcms320 comparesig 8.0 -7.0 -> 1
-dqcms321 comparesig 8.0 -7 -> 1
-dqcms322 comparesig 8 -7.0 -> 1
-dqcms323 comparesig 8E+0 -7.0 -> 1
-dqcms324 comparesig 80E-1 -7.0 -> 1
-dqcms325 comparesig .8E+1 -7 -> 1
-dqcms326 comparesig 80E-1 -7 -> 1
-dqcms327 comparesig 8.0 -7E+0 -> 1
-dqcms328 comparesig 8.0 -70E-1 -> 1
-dqcms329 comparesig 8 -.7E+1 -> 1
-dqcms330 comparesig 8 -70E-1 -> 1
-
-dqcms340 comparesig 8.0 -9.0 -> 1
-dqcms341 comparesig 8.0 -9 -> 1
-dqcms342 comparesig 8 -9.0 -> 1
-dqcms343 comparesig 8E+0 -9.0 -> 1
-dqcms344 comparesig 80E-1 -9.0 -> 1
-dqcms345 comparesig .8E+1 -9 -> 1
-dqcms346 comparesig 80E-1 -9 -> 1
-dqcms347 comparesig 8.0 -9E+0 -> 1
-dqcms348 comparesig 8.0 -90E-1 -> 1
-dqcms349 comparesig 8 -.9E+1 -> 1
-dqcms350 comparesig 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcms400 comparesig -7.0 -7.0 -> 0
-dqcms401 comparesig -7.0 -7 -> 0
-dqcms402 comparesig -7 -7.0 -> 0
-dqcms403 comparesig -7E+0 -7.0 -> 0
-dqcms404 comparesig -70E-1 -7.0 -> 0
-dqcms405 comparesig -.7E+1 -7 -> 0
-dqcms406 comparesig -70E-1 -7 -> 0
-dqcms407 comparesig -7.0 -7E+0 -> 0
-dqcms408 comparesig -7.0 -70E-1 -> 0
-dqcms409 comparesig -7 -.7E+1 -> 0
-dqcms410 comparesig -7 -70E-1 -> 0
-
-dqcms420 comparesig -8.0 -7.0 -> -1
-dqcms421 comparesig -8.0 -7 -> -1
-dqcms422 comparesig -8 -7.0 -> -1
-dqcms423 comparesig -8E+0 -7.0 -> -1
-dqcms424 comparesig -80E-1 -7.0 -> -1
-dqcms425 comparesig -.8E+1 -7 -> -1
-dqcms426 comparesig -80E-1 -7 -> -1
-dqcms427 comparesig -8.0 -7E+0 -> -1
-dqcms428 comparesig -8.0 -70E-1 -> -1
-dqcms429 comparesig -8 -.7E+1 -> -1
-dqcms430 comparesig -8 -70E-1 -> -1
-
-dqcms440 comparesig -8.0 -9.0 -> 1
-dqcms441 comparesig -8.0 -9 -> 1
-dqcms442 comparesig -8 -9.0 -> 1
-dqcms443 comparesig -8E+0 -9.0 -> 1
-dqcms444 comparesig -80E-1 -9.0 -> 1
-dqcms445 comparesig -.8E+1 -9 -> 1
-dqcms446 comparesig -80E-1 -9 -> 1
-dqcms447 comparesig -8.0 -9E+0 -> 1
-dqcms448 comparesig -8.0 -90E-1 -> 1
-dqcms449 comparesig -8 -.9E+1 -> 1
-dqcms450 comparesig -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcms473 comparesig 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
-dqcms474 comparesig 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
-dqcms475 comparesig 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
-dqcms476 comparesig 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
-dqcms477 comparesig 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
-dqcms478 comparesig 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
-dqcms479 comparesig 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
-dqcms480 comparesig 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
-dqcms481 comparesig 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
-dqcms482 comparesig 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
-dqcms483 comparesig 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
-dqcms487 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
-dqcms488 comparesig 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
-dqcms489 comparesig 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
-dqcms490 comparesig 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
-dqcms491 comparesig 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
-dqcms492 comparesig 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
-dqcms493 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
-dqcms494 comparesig 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
-dqcms495 comparesig 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
-dqcms496 comparesig 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
-dqcms497 comparesig 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcms500 comparesig 1 1E-15 -> 1
-dqcms501 comparesig 1 1E-14 -> 1
-dqcms502 comparesig 1 1E-13 -> 1
-dqcms503 comparesig 1 1E-12 -> 1
-dqcms504 comparesig 1 1E-11 -> 1
-dqcms505 comparesig 1 1E-10 -> 1
-dqcms506 comparesig 1 1E-9 -> 1
-dqcms507 comparesig 1 1E-8 -> 1
-dqcms508 comparesig 1 1E-7 -> 1
-dqcms509 comparesig 1 1E-6 -> 1
-dqcms510 comparesig 1 1E-5 -> 1
-dqcms511 comparesig 1 1E-4 -> 1
-dqcms512 comparesig 1 1E-3 -> 1
-dqcms513 comparesig 1 1E-2 -> 1
-dqcms514 comparesig 1 1E-1 -> 1
-dqcms515 comparesig 1 1E-0 -> 0
-dqcms516 comparesig 1 1E+1 -> -1
-dqcms517 comparesig 1 1E+2 -> -1
-dqcms518 comparesig 1 1E+3 -> -1
-dqcms519 comparesig 1 1E+4 -> -1
-dqcms521 comparesig 1 1E+5 -> -1
-dqcms522 comparesig 1 1E+6 -> -1
-dqcms523 comparesig 1 1E+7 -> -1
-dqcms524 comparesig 1 1E+8 -> -1
-dqcms525 comparesig 1 1E+9 -> -1
-dqcms526 comparesig 1 1E+10 -> -1
-dqcms527 comparesig 1 1E+11 -> -1
-dqcms528 comparesig 1 1E+12 -> -1
-dqcms529 comparesig 1 1E+13 -> -1
-dqcms530 comparesig 1 1E+14 -> -1
-dqcms531 comparesig 1 1E+15 -> -1
--- LR swap
-dqcms540 comparesig 1E-15 1 -> -1
-dqcms541 comparesig 1E-14 1 -> -1
-dqcms542 comparesig 1E-13 1 -> -1
-dqcms543 comparesig 1E-12 1 -> -1
-dqcms544 comparesig 1E-11 1 -> -1
-dqcms545 comparesig 1E-10 1 -> -1
-dqcms546 comparesig 1E-9 1 -> -1
-dqcms547 comparesig 1E-8 1 -> -1
-dqcms548 comparesig 1E-7 1 -> -1
-dqcms549 comparesig 1E-6 1 -> -1
-dqcms550 comparesig 1E-5 1 -> -1
-dqcms551 comparesig 1E-4 1 -> -1
-dqcms552 comparesig 1E-3 1 -> -1
-dqcms553 comparesig 1E-2 1 -> -1
-dqcms554 comparesig 1E-1 1 -> -1
-dqcms555 comparesig 1E-0 1 -> 0
-dqcms556 comparesig 1E+1 1 -> 1
-dqcms557 comparesig 1E+2 1 -> 1
-dqcms558 comparesig 1E+3 1 -> 1
-dqcms559 comparesig 1E+4 1 -> 1
-dqcms561 comparesig 1E+5 1 -> 1
-dqcms562 comparesig 1E+6 1 -> 1
-dqcms563 comparesig 1E+7 1 -> 1
-dqcms564 comparesig 1E+8 1 -> 1
-dqcms565 comparesig 1E+9 1 -> 1
-dqcms566 comparesig 1E+10 1 -> 1
-dqcms567 comparesig 1E+11 1 -> 1
-dqcms568 comparesig 1E+12 1 -> 1
-dqcms569 comparesig 1E+13 1 -> 1
-dqcms570 comparesig 1E+14 1 -> 1
-dqcms571 comparesig 1E+15 1 -> 1
--- similar with a useful coefficient, one side only
-dqcms580 comparesig 0.000000987654321 1E-15 -> 1
-dqcms581 comparesig 0.000000987654321 1E-14 -> 1
-dqcms582 comparesig 0.000000987654321 1E-13 -> 1
-dqcms583 comparesig 0.000000987654321 1E-12 -> 1
-dqcms584 comparesig 0.000000987654321 1E-11 -> 1
-dqcms585 comparesig 0.000000987654321 1E-10 -> 1
-dqcms586 comparesig 0.000000987654321 1E-9 -> 1
-dqcms587 comparesig 0.000000987654321 1E-8 -> 1
-dqcms588 comparesig 0.000000987654321 1E-7 -> 1
-dqcms589 comparesig 0.000000987654321 1E-6 -> -1
-dqcms590 comparesig 0.000000987654321 1E-5 -> -1
-dqcms591 comparesig 0.000000987654321 1E-4 -> -1
-dqcms592 comparesig 0.000000987654321 1E-3 -> -1
-dqcms593 comparesig 0.000000987654321 1E-2 -> -1
-dqcms594 comparesig 0.000000987654321 1E-1 -> -1
-dqcms595 comparesig 0.000000987654321 1E-0 -> -1
-dqcms596 comparesig 0.000000987654321 1E+1 -> -1
-dqcms597 comparesig 0.000000987654321 1E+2 -> -1
-dqcms598 comparesig 0.000000987654321 1E+3 -> -1
-dqcms599 comparesig 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcms600 comparesig 12 12.2345 -> -1
-dqcms601 comparesig 12.0 12.2345 -> -1
-dqcms602 comparesig 12.00 12.2345 -> -1
-dqcms603 comparesig 12.000 12.2345 -> -1
-dqcms604 comparesig 12.0000 12.2345 -> -1
-dqcms605 comparesig 12.00000 12.2345 -> -1
-dqcms606 comparesig 12.000000 12.2345 -> -1
-dqcms607 comparesig 12.0000000 12.2345 -> -1
-dqcms608 comparesig 12.00000000 12.2345 -> -1
-dqcms609 comparesig 12.000000000 12.2345 -> -1
-dqcms610 comparesig 12.1234 12 -> 1
-dqcms611 comparesig 12.1234 12.0 -> 1
-dqcms612 comparesig 12.1234 12.00 -> 1
-dqcms613 comparesig 12.1234 12.000 -> 1
-dqcms614 comparesig 12.1234 12.0000 -> 1
-dqcms615 comparesig 12.1234 12.00000 -> 1
-dqcms616 comparesig 12.1234 12.000000 -> 1
-dqcms617 comparesig 12.1234 12.0000000 -> 1
-dqcms618 comparesig 12.1234 12.00000000 -> 1
-dqcms619 comparesig 12.1234 12.000000000 -> 1
-dqcms620 comparesig -12 -12.2345 -> 1
-dqcms621 comparesig -12.0 -12.2345 -> 1
-dqcms622 comparesig -12.00 -12.2345 -> 1
-dqcms623 comparesig -12.000 -12.2345 -> 1
-dqcms624 comparesig -12.0000 -12.2345 -> 1
-dqcms625 comparesig -12.00000 -12.2345 -> 1
-dqcms626 comparesig -12.000000 -12.2345 -> 1
-dqcms627 comparesig -12.0000000 -12.2345 -> 1
-dqcms628 comparesig -12.00000000 -12.2345 -> 1
-dqcms629 comparesig -12.000000000 -12.2345 -> 1
-dqcms630 comparesig -12.1234 -12 -> -1
-dqcms631 comparesig -12.1234 -12.0 -> -1
-dqcms632 comparesig -12.1234 -12.00 -> -1
-dqcms633 comparesig -12.1234 -12.000 -> -1
-dqcms634 comparesig -12.1234 -12.0000 -> -1
-dqcms635 comparesig -12.1234 -12.00000 -> -1
-dqcms636 comparesig -12.1234 -12.000000 -> -1
-dqcms637 comparesig -12.1234 -12.0000000 -> -1
-dqcms638 comparesig -12.1234 -12.00000000 -> -1
-dqcms639 comparesig -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcms640 comparesig 0 0 -> 0
-dqcms641 comparesig 0 -0 -> 0
-dqcms642 comparesig 0 -0.0 -> 0
-dqcms643 comparesig 0 0.0 -> 0
-dqcms644 comparesig -0 0 -> 0
-dqcms645 comparesig -0 -0 -> 0
-dqcms646 comparesig -0 -0.0 -> 0
-dqcms647 comparesig -0 0.0 -> 0
-dqcms648 comparesig 0.0 0 -> 0
-dqcms649 comparesig 0.0 -0 -> 0
-dqcms650 comparesig 0.0 -0.0 -> 0
-dqcms651 comparesig 0.0 0.0 -> 0
-dqcms652 comparesig -0.0 0 -> 0
-dqcms653 comparesig -0.0 -0 -> 0
-dqcms654 comparesig -0.0 -0.0 -> 0
-dqcms655 comparesig -0.0 0.0 -> 0
-
-dqcms656 comparesig -0E1 0.0 -> 0
-dqcms657 comparesig -0E2 0.0 -> 0
-dqcms658 comparesig 0E1 0.0 -> 0
-dqcms659 comparesig 0E2 0.0 -> 0
-dqcms660 comparesig -0E1 0 -> 0
-dqcms661 comparesig -0E2 0 -> 0
-dqcms662 comparesig 0E1 0 -> 0
-dqcms663 comparesig 0E2 0 -> 0
-dqcms664 comparesig -0E1 -0E1 -> 0
-dqcms665 comparesig -0E2 -0E1 -> 0
-dqcms666 comparesig 0E1 -0E1 -> 0
-dqcms667 comparesig 0E2 -0E1 -> 0
-dqcms668 comparesig -0E1 -0E2 -> 0
-dqcms669 comparesig -0E2 -0E2 -> 0
-dqcms670 comparesig 0E1 -0E2 -> 0
-dqcms671 comparesig 0E2 -0E2 -> 0
-dqcms672 comparesig -0E1 0E1 -> 0
-dqcms673 comparesig -0E2 0E1 -> 0
-dqcms674 comparesig 0E1 0E1 -> 0
-dqcms675 comparesig 0E2 0E1 -> 0
-dqcms676 comparesig -0E1 0E2 -> 0
-dqcms677 comparesig -0E2 0E2 -> 0
-dqcms678 comparesig 0E1 0E2 -> 0
-dqcms679 comparesig 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcms680 comparesig 12 12 -> 0
-dqcms681 comparesig 12 12.0 -> 0
-dqcms682 comparesig 12 12.00 -> 0
-dqcms683 comparesig 12 12.000 -> 0
-dqcms684 comparesig 12 12.0000 -> 0
-dqcms685 comparesig 12 12.00000 -> 0
-dqcms686 comparesig 12 12.000000 -> 0
-dqcms687 comparesig 12 12.0000000 -> 0
-dqcms688 comparesig 12 12.00000000 -> 0
-dqcms689 comparesig 12 12.000000000 -> 0
-dqcms690 comparesig 12 12 -> 0
-dqcms691 comparesig 12.0 12 -> 0
-dqcms692 comparesig 12.00 12 -> 0
-dqcms693 comparesig 12.000 12 -> 0
-dqcms694 comparesig 12.0000 12 -> 0
-dqcms695 comparesig 12.00000 12 -> 0
-dqcms696 comparesig 12.000000 12 -> 0
-dqcms697 comparesig 12.0000000 12 -> 0
-dqcms698 comparesig 12.00000000 12 -> 0
-dqcms699 comparesig 12.000000000 12 -> 0
-
--- first, second, & last digit
-dqcms700 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
-dqcms701 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcms702 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
-dqcms703 comparesig 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
-dqcms704 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
-dqcms705 comparesig 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
-dqcms706 comparesig 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
-dqcms707 comparesig 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
-dqcms708 comparesig 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
-
--- miscellaneous
-dqcms721 comparesig 12345678000 1 -> 1
-dqcms722 comparesig 1 12345678000 -> -1
-dqcms723 comparesig 1234567800 1 -> 1
-dqcms724 comparesig 1 1234567800 -> -1
-dqcms725 comparesig 1234567890 1 -> 1
-dqcms726 comparesig 1 1234567890 -> -1
-dqcms727 comparesig 1234567891 1 -> 1
-dqcms728 comparesig 1 1234567891 -> -1
-dqcms729 comparesig 12345678901 1 -> 1
-dqcms730 comparesig 1 12345678901 -> -1
-dqcms731 comparesig 1234567896 1 -> 1
-dqcms732 comparesig 1 1234567896 -> -1
-
--- residue cases at lower precision
-dqcms740 comparesig 1 0.9999999 -> 1
-dqcms741 comparesig 1 0.999999 -> 1
-dqcms742 comparesig 1 0.99999 -> 1
-dqcms743 comparesig 1 1.0000 -> 0
-dqcms744 comparesig 1 1.00001 -> -1
-dqcms745 comparesig 1 1.000001 -> -1
-dqcms746 comparesig 1 1.0000001 -> -1
-dqcms750 comparesig 0.9999999 1 -> -1
-dqcms751 comparesig 0.999999 1 -> -1
-dqcms752 comparesig 0.99999 1 -> -1
-dqcms753 comparesig 1.0000 1 -> 0
-dqcms754 comparesig 1.00001 1 -> 1
-dqcms755 comparesig 1.000001 1 -> 1
-dqcms756 comparesig 1.0000001 1 -> 1
-
--- Specials
-dqcms780 comparesig Inf -Inf -> 1
-dqcms781 comparesig Inf -1000 -> 1
-dqcms782 comparesig Inf -1 -> 1
-dqcms783 comparesig Inf -0 -> 1
-dqcms784 comparesig Inf 0 -> 1
-dqcms785 comparesig Inf 1 -> 1
-dqcms786 comparesig Inf 1000 -> 1
-dqcms787 comparesig Inf Inf -> 0
-dqcms788 comparesig -1000 Inf -> -1
-dqcms789 comparesig -Inf Inf -> -1
-dqcms790 comparesig -1 Inf -> -1
-dqcms791 comparesig -0 Inf -> -1
-dqcms792 comparesig 0 Inf -> -1
-dqcms793 comparesig 1 Inf -> -1
-dqcms794 comparesig 1000 Inf -> -1
-dqcms795 comparesig Inf Inf -> 0
-
-dqcms800 comparesig -Inf -Inf -> 0
-dqcms801 comparesig -Inf -1000 -> -1
-dqcms802 comparesig -Inf -1 -> -1
-dqcms803 comparesig -Inf -0 -> -1
-dqcms804 comparesig -Inf 0 -> -1
-dqcms805 comparesig -Inf 1 -> -1
-dqcms806 comparesig -Inf 1000 -> -1
-dqcms807 comparesig -Inf Inf -> -1
-dqcms808 comparesig -Inf -Inf -> 0
-dqcms809 comparesig -1000 -Inf -> 1
-dqcms810 comparesig -1 -Inf -> 1
-dqcms811 comparesig -0 -Inf -> 1
-dqcms812 comparesig 0 -Inf -> 1
-dqcms813 comparesig 1 -Inf -> 1
-dqcms814 comparesig 1000 -Inf -> 1
-dqcms815 comparesig Inf -Inf -> 1
-
-dqcms821 comparesig NaN -Inf -> NaN Invalid_operation
-dqcms822 comparesig NaN -1000 -> NaN Invalid_operation
-dqcms823 comparesig NaN -1 -> NaN Invalid_operation
-dqcms824 comparesig NaN -0 -> NaN Invalid_operation
-dqcms825 comparesig NaN 0 -> NaN Invalid_operation
-dqcms826 comparesig NaN 1 -> NaN Invalid_operation
-dqcms827 comparesig NaN 1000 -> NaN Invalid_operation
-dqcms828 comparesig NaN Inf -> NaN Invalid_operation
-dqcms829 comparesig NaN NaN -> NaN Invalid_operation
-dqcms830 comparesig -Inf NaN -> NaN Invalid_operation
-dqcms831 comparesig -1000 NaN -> NaN Invalid_operation
-dqcms832 comparesig -1 NaN -> NaN Invalid_operation
-dqcms833 comparesig -0 NaN -> NaN Invalid_operation
-dqcms834 comparesig 0 NaN -> NaN Invalid_operation
-dqcms835 comparesig 1 NaN -> NaN Invalid_operation
-dqcms836 comparesig 1000 NaN -> NaN Invalid_operation
-dqcms837 comparesig Inf NaN -> NaN Invalid_operation
-dqcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
-dqcms839 comparesig +NaN -NaN -> NaN Invalid_operation
-dqcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
-
-dqcms841 comparesig sNaN -Inf -> NaN Invalid_operation
-dqcms842 comparesig sNaN -1000 -> NaN Invalid_operation
-dqcms843 comparesig sNaN -1 -> NaN Invalid_operation
-dqcms844 comparesig sNaN -0 -> NaN Invalid_operation
-dqcms845 comparesig sNaN 0 -> NaN Invalid_operation
-dqcms846 comparesig sNaN 1 -> NaN Invalid_operation
-dqcms847 comparesig sNaN 1000 -> NaN Invalid_operation
-dqcms848 comparesig sNaN NaN -> NaN Invalid_operation
-dqcms849 comparesig sNaN sNaN -> NaN Invalid_operation
-dqcms850 comparesig NaN sNaN -> NaN Invalid_operation
-dqcms851 comparesig -Inf sNaN -> NaN Invalid_operation
-dqcms852 comparesig -1000 sNaN -> NaN Invalid_operation
-dqcms853 comparesig -1 sNaN -> NaN Invalid_operation
-dqcms854 comparesig -0 sNaN -> NaN Invalid_operation
-dqcms855 comparesig 0 sNaN -> NaN Invalid_operation
-dqcms856 comparesig 1 sNaN -> NaN Invalid_operation
-dqcms857 comparesig 1000 sNaN -> NaN Invalid_operation
-dqcms858 comparesig Inf sNaN -> NaN Invalid_operation
-dqcms859 comparesig NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
-dqcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
-dqcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
-dqcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
-dqcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
-dqcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
-dqcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
-dqcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
-dqcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
-dqcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
-dqcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
-
-dqcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
-dqcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
-dqcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
-dqcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
-dqcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
-dqcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
-dqcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- wide range
-dqcms880 comparesig +1.23456789012345E-0 9E+6144 -> -1
-dqcms881 comparesig 9E+6144 +1.23456789012345E-0 -> 1
-dqcms882 comparesig +0.100 9E-6143 -> 1
-dqcms883 comparesig 9E-6143 +0.100 -> -1
-dqcms885 comparesig -1.23456789012345E-0 9E+6144 -> -1
-dqcms886 comparesig 9E+6144 -1.23456789012345E-0 -> 1
-dqcms887 comparesig -0.100 9E-6143 -> -1
-dqcms888 comparesig 9E-6143 -0.100 -> 1
-
--- signs
-dqcms901 comparesig 1e+77 1e+11 -> 1
-dqcms902 comparesig 1e+77 -1e+11 -> 1
-dqcms903 comparesig -1e+77 1e+11 -> -1
-dqcms904 comparesig -1e+77 -1e+11 -> -1
-dqcms905 comparesig 1e-77 1e-11 -> -1
-dqcms906 comparesig 1e-77 -1e-11 -> 1
-dqcms907 comparesig -1e-77 1e-11 -> -1
-dqcms908 comparesig -1e-77 -1e-11 -> 1
-
--- Null tests
-dqcms990 comparesig 10 # -> NaN Invalid_operation
-dqcms991 comparesig # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareSig.decTest -- decQuad comparison; all NaNs signal --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcms001 comparesig -2 -2 -> 0
+dqcms002 comparesig -2 -1 -> -1
+dqcms003 comparesig -2 0 -> -1
+dqcms004 comparesig -2 1 -> -1
+dqcms005 comparesig -2 2 -> -1
+dqcms006 comparesig -1 -2 -> 1
+dqcms007 comparesig -1 -1 -> 0
+dqcms008 comparesig -1 0 -> -1
+dqcms009 comparesig -1 1 -> -1
+dqcms010 comparesig -1 2 -> -1
+dqcms011 comparesig 0 -2 -> 1
+dqcms012 comparesig 0 -1 -> 1
+dqcms013 comparesig 0 0 -> 0
+dqcms014 comparesig 0 1 -> -1
+dqcms015 comparesig 0 2 -> -1
+dqcms016 comparesig 1 -2 -> 1
+dqcms017 comparesig 1 -1 -> 1
+dqcms018 comparesig 1 0 -> 1
+dqcms019 comparesig 1 1 -> 0
+dqcms020 comparesig 1 2 -> -1
+dqcms021 comparesig 2 -2 -> 1
+dqcms022 comparesig 2 -1 -> 1
+dqcms023 comparesig 2 0 -> 1
+dqcms025 comparesig 2 1 -> 1
+dqcms026 comparesig 2 2 -> 0
+
+dqcms031 comparesig -20 -20 -> 0
+dqcms032 comparesig -20 -10 -> -1
+dqcms033 comparesig -20 00 -> -1
+dqcms034 comparesig -20 10 -> -1
+dqcms035 comparesig -20 20 -> -1
+dqcms036 comparesig -10 -20 -> 1
+dqcms037 comparesig -10 -10 -> 0
+dqcms038 comparesig -10 00 -> -1
+dqcms039 comparesig -10 10 -> -1
+dqcms040 comparesig -10 20 -> -1
+dqcms041 comparesig 00 -20 -> 1
+dqcms042 comparesig 00 -10 -> 1
+dqcms043 comparesig 00 00 -> 0
+dqcms044 comparesig 00 10 -> -1
+dqcms045 comparesig 00 20 -> -1
+dqcms046 comparesig 10 -20 -> 1
+dqcms047 comparesig 10 -10 -> 1
+dqcms048 comparesig 10 00 -> 1
+dqcms049 comparesig 10 10 -> 0
+dqcms050 comparesig 10 20 -> -1
+dqcms051 comparesig 20 -20 -> 1
+dqcms052 comparesig 20 -10 -> 1
+dqcms053 comparesig 20 00 -> 1
+dqcms055 comparesig 20 10 -> 1
+dqcms056 comparesig 20 20 -> 0
+
+dqcms061 comparesig -2.0 -2.0 -> 0
+dqcms062 comparesig -2.0 -1.0 -> -1
+dqcms063 comparesig -2.0 0.0 -> -1
+dqcms064 comparesig -2.0 1.0 -> -1
+dqcms065 comparesig -2.0 2.0 -> -1
+dqcms066 comparesig -1.0 -2.0 -> 1
+dqcms067 comparesig -1.0 -1.0 -> 0
+dqcms068 comparesig -1.0 0.0 -> -1
+dqcms069 comparesig -1.0 1.0 -> -1
+dqcms070 comparesig -1.0 2.0 -> -1
+dqcms071 comparesig 0.0 -2.0 -> 1
+dqcms072 comparesig 0.0 -1.0 -> 1
+dqcms073 comparesig 0.0 0.0 -> 0
+dqcms074 comparesig 0.0 1.0 -> -1
+dqcms075 comparesig 0.0 2.0 -> -1
+dqcms076 comparesig 1.0 -2.0 -> 1
+dqcms077 comparesig 1.0 -1.0 -> 1
+dqcms078 comparesig 1.0 0.0 -> 1
+dqcms079 comparesig 1.0 1.0 -> 0
+dqcms080 comparesig 1.0 2.0 -> -1
+dqcms081 comparesig 2.0 -2.0 -> 1
+dqcms082 comparesig 2.0 -1.0 -> 1
+dqcms083 comparesig 2.0 0.0 -> 1
+dqcms085 comparesig 2.0 1.0 -> 1
+dqcms086 comparesig 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcms090 comparesig 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 0
+dqcms091 comparesig -9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> -1
+dqcms092 comparesig 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 1
+dqcms093 comparesig -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+dqcms100 comparesig 7.0 7.0 -> 0
+dqcms101 comparesig 7.0 7 -> 0
+dqcms102 comparesig 7 7.0 -> 0
+dqcms103 comparesig 7E+0 7.0 -> 0
+dqcms104 comparesig 70E-1 7.0 -> 0
+dqcms105 comparesig 0.7E+1 7 -> 0
+dqcms106 comparesig 70E-1 7 -> 0
+dqcms107 comparesig 7.0 7E+0 -> 0
+dqcms108 comparesig 7.0 70E-1 -> 0
+dqcms109 comparesig 7 0.7E+1 -> 0
+dqcms110 comparesig 7 70E-1 -> 0
+
+dqcms120 comparesig 8.0 7.0 -> 1
+dqcms121 comparesig 8.0 7 -> 1
+dqcms122 comparesig 8 7.0 -> 1
+dqcms123 comparesig 8E+0 7.0 -> 1
+dqcms124 comparesig 80E-1 7.0 -> 1
+dqcms125 comparesig 0.8E+1 7 -> 1
+dqcms126 comparesig 80E-1 7 -> 1
+dqcms127 comparesig 8.0 7E+0 -> 1
+dqcms128 comparesig 8.0 70E-1 -> 1
+dqcms129 comparesig 8 0.7E+1 -> 1
+dqcms130 comparesig 8 70E-1 -> 1
+
+dqcms140 comparesig 8.0 9.0 -> -1
+dqcms141 comparesig 8.0 9 -> -1
+dqcms142 comparesig 8 9.0 -> -1
+dqcms143 comparesig 8E+0 9.0 -> -1
+dqcms144 comparesig 80E-1 9.0 -> -1
+dqcms145 comparesig 0.8E+1 9 -> -1
+dqcms146 comparesig 80E-1 9 -> -1
+dqcms147 comparesig 8.0 9E+0 -> -1
+dqcms148 comparesig 8.0 90E-1 -> -1
+dqcms149 comparesig 8 0.9E+1 -> -1
+dqcms150 comparesig 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcms200 comparesig -7.0 7.0 -> -1
+dqcms201 comparesig -7.0 7 -> -1
+dqcms202 comparesig -7 7.0 -> -1
+dqcms203 comparesig -7E+0 7.0 -> -1
+dqcms204 comparesig -70E-1 7.0 -> -1
+dqcms205 comparesig -0.7E+1 7 -> -1
+dqcms206 comparesig -70E-1 7 -> -1
+dqcms207 comparesig -7.0 7E+0 -> -1
+dqcms208 comparesig -7.0 70E-1 -> -1
+dqcms209 comparesig -7 0.7E+1 -> -1
+dqcms210 comparesig -7 70E-1 -> -1
+
+dqcms220 comparesig -8.0 7.0 -> -1
+dqcms221 comparesig -8.0 7 -> -1
+dqcms222 comparesig -8 7.0 -> -1
+dqcms223 comparesig -8E+0 7.0 -> -1
+dqcms224 comparesig -80E-1 7.0 -> -1
+dqcms225 comparesig -0.8E+1 7 -> -1
+dqcms226 comparesig -80E-1 7 -> -1
+dqcms227 comparesig -8.0 7E+0 -> -1
+dqcms228 comparesig -8.0 70E-1 -> -1
+dqcms229 comparesig -8 0.7E+1 -> -1
+dqcms230 comparesig -8 70E-1 -> -1
+
+dqcms240 comparesig -8.0 9.0 -> -1
+dqcms241 comparesig -8.0 9 -> -1
+dqcms242 comparesig -8 9.0 -> -1
+dqcms243 comparesig -8E+0 9.0 -> -1
+dqcms244 comparesig -80E-1 9.0 -> -1
+dqcms245 comparesig -0.8E+1 9 -> -1
+dqcms246 comparesig -80E-1 9 -> -1
+dqcms247 comparesig -8.0 9E+0 -> -1
+dqcms248 comparesig -8.0 90E-1 -> -1
+dqcms249 comparesig -8 0.9E+1 -> -1
+dqcms250 comparesig -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcms300 comparesig 7.0 -7.0 -> 1
+dqcms301 comparesig 7.0 -7 -> 1
+dqcms302 comparesig 7 -7.0 -> 1
+dqcms303 comparesig 7E+0 -7.0 -> 1
+dqcms304 comparesig 70E-1 -7.0 -> 1
+dqcms305 comparesig .7E+1 -7 -> 1
+dqcms306 comparesig 70E-1 -7 -> 1
+dqcms307 comparesig 7.0 -7E+0 -> 1
+dqcms308 comparesig 7.0 -70E-1 -> 1
+dqcms309 comparesig 7 -.7E+1 -> 1
+dqcms310 comparesig 7 -70E-1 -> 1
+
+dqcms320 comparesig 8.0 -7.0 -> 1
+dqcms321 comparesig 8.0 -7 -> 1
+dqcms322 comparesig 8 -7.0 -> 1
+dqcms323 comparesig 8E+0 -7.0 -> 1
+dqcms324 comparesig 80E-1 -7.0 -> 1
+dqcms325 comparesig .8E+1 -7 -> 1
+dqcms326 comparesig 80E-1 -7 -> 1
+dqcms327 comparesig 8.0 -7E+0 -> 1
+dqcms328 comparesig 8.0 -70E-1 -> 1
+dqcms329 comparesig 8 -.7E+1 -> 1
+dqcms330 comparesig 8 -70E-1 -> 1
+
+dqcms340 comparesig 8.0 -9.0 -> 1
+dqcms341 comparesig 8.0 -9 -> 1
+dqcms342 comparesig 8 -9.0 -> 1
+dqcms343 comparesig 8E+0 -9.0 -> 1
+dqcms344 comparesig 80E-1 -9.0 -> 1
+dqcms345 comparesig .8E+1 -9 -> 1
+dqcms346 comparesig 80E-1 -9 -> 1
+dqcms347 comparesig 8.0 -9E+0 -> 1
+dqcms348 comparesig 8.0 -90E-1 -> 1
+dqcms349 comparesig 8 -.9E+1 -> 1
+dqcms350 comparesig 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcms400 comparesig -7.0 -7.0 -> 0
+dqcms401 comparesig -7.0 -7 -> 0
+dqcms402 comparesig -7 -7.0 -> 0
+dqcms403 comparesig -7E+0 -7.0 -> 0
+dqcms404 comparesig -70E-1 -7.0 -> 0
+dqcms405 comparesig -.7E+1 -7 -> 0
+dqcms406 comparesig -70E-1 -7 -> 0
+dqcms407 comparesig -7.0 -7E+0 -> 0
+dqcms408 comparesig -7.0 -70E-1 -> 0
+dqcms409 comparesig -7 -.7E+1 -> 0
+dqcms410 comparesig -7 -70E-1 -> 0
+
+dqcms420 comparesig -8.0 -7.0 -> -1
+dqcms421 comparesig -8.0 -7 -> -1
+dqcms422 comparesig -8 -7.0 -> -1
+dqcms423 comparesig -8E+0 -7.0 -> -1
+dqcms424 comparesig -80E-1 -7.0 -> -1
+dqcms425 comparesig -.8E+1 -7 -> -1
+dqcms426 comparesig -80E-1 -7 -> -1
+dqcms427 comparesig -8.0 -7E+0 -> -1
+dqcms428 comparesig -8.0 -70E-1 -> -1
+dqcms429 comparesig -8 -.7E+1 -> -1
+dqcms430 comparesig -8 -70E-1 -> -1
+
+dqcms440 comparesig -8.0 -9.0 -> 1
+dqcms441 comparesig -8.0 -9 -> 1
+dqcms442 comparesig -8 -9.0 -> 1
+dqcms443 comparesig -8E+0 -9.0 -> 1
+dqcms444 comparesig -80E-1 -9.0 -> 1
+dqcms445 comparesig -.8E+1 -9 -> 1
+dqcms446 comparesig -80E-1 -9 -> 1
+dqcms447 comparesig -8.0 -9E+0 -> 1
+dqcms448 comparesig -8.0 -90E-1 -> 1
+dqcms449 comparesig -8 -.9E+1 -> 1
+dqcms450 comparesig -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcms473 comparesig 123.9999999999999999994560000000000E-89 123.999999999999999999456E-89 -> 0
+dqcms474 comparesig 123.999999999999999999456000000000E+89 123.999999999999999999456E+89 -> 0
+dqcms475 comparesig 123.99999999999999999945600000000E-89 123.999999999999999999456E-89 -> 0
+dqcms476 comparesig 123.9999999999999999994560000000E+89 123.999999999999999999456E+89 -> 0
+dqcms477 comparesig 123.999999999999999999456000000E-89 123.999999999999999999456E-89 -> 0
+dqcms478 comparesig 123.99999999999999999945600000E+89 123.999999999999999999456E+89 -> 0
+dqcms479 comparesig 123.9999999999999999994560000E-89 123.999999999999999999456E-89 -> 0
+dqcms480 comparesig 123.999999999999999999456000E+89 123.999999999999999999456E+89 -> 0
+dqcms481 comparesig 123.99999999999999999945600E-89 123.999999999999999999456E-89 -> 0
+dqcms482 comparesig 123.9999999999999999994560E+89 123.999999999999999999456E+89 -> 0
+dqcms483 comparesig 123.999999999999999999456E-89 123.999999999999999999456E-89 -> 0
+dqcms487 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000000000E+89 -> 0
+dqcms488 comparesig 123.999999999999999999456E-89 123.999999999999999999456000000000E-89 -> 0
+dqcms489 comparesig 123.999999999999999999456E+89 123.99999999999999999945600000000E+89 -> 0
+dqcms490 comparesig 123.999999999999999999456E-89 123.9999999999999999994560000000E-89 -> 0
+dqcms491 comparesig 123.999999999999999999456E+89 123.999999999999999999456000000E+89 -> 0
+dqcms492 comparesig 123.999999999999999999456E-89 123.99999999999999999945600000E-89 -> 0
+dqcms493 comparesig 123.999999999999999999456E+89 123.9999999999999999994560000E+89 -> 0
+dqcms494 comparesig 123.999999999999999999456E-89 123.999999999999999999456000E-89 -> 0
+dqcms495 comparesig 123.999999999999999999456E+89 123.99999999999999999945600E+89 -> 0
+dqcms496 comparesig 123.999999999999999999456E-89 123.9999999999999999994560E-89 -> 0
+dqcms497 comparesig 123.999999999999999999456E+89 123.999999999999999999456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcms500 comparesig 1 1E-15 -> 1
+dqcms501 comparesig 1 1E-14 -> 1
+dqcms502 comparesig 1 1E-13 -> 1
+dqcms503 comparesig 1 1E-12 -> 1
+dqcms504 comparesig 1 1E-11 -> 1
+dqcms505 comparesig 1 1E-10 -> 1
+dqcms506 comparesig 1 1E-9 -> 1
+dqcms507 comparesig 1 1E-8 -> 1
+dqcms508 comparesig 1 1E-7 -> 1
+dqcms509 comparesig 1 1E-6 -> 1
+dqcms510 comparesig 1 1E-5 -> 1
+dqcms511 comparesig 1 1E-4 -> 1
+dqcms512 comparesig 1 1E-3 -> 1
+dqcms513 comparesig 1 1E-2 -> 1
+dqcms514 comparesig 1 1E-1 -> 1
+dqcms515 comparesig 1 1E-0 -> 0
+dqcms516 comparesig 1 1E+1 -> -1
+dqcms517 comparesig 1 1E+2 -> -1
+dqcms518 comparesig 1 1E+3 -> -1
+dqcms519 comparesig 1 1E+4 -> -1
+dqcms521 comparesig 1 1E+5 -> -1
+dqcms522 comparesig 1 1E+6 -> -1
+dqcms523 comparesig 1 1E+7 -> -1
+dqcms524 comparesig 1 1E+8 -> -1
+dqcms525 comparesig 1 1E+9 -> -1
+dqcms526 comparesig 1 1E+10 -> -1
+dqcms527 comparesig 1 1E+11 -> -1
+dqcms528 comparesig 1 1E+12 -> -1
+dqcms529 comparesig 1 1E+13 -> -1
+dqcms530 comparesig 1 1E+14 -> -1
+dqcms531 comparesig 1 1E+15 -> -1
+-- LR swap
+dqcms540 comparesig 1E-15 1 -> -1
+dqcms541 comparesig 1E-14 1 -> -1
+dqcms542 comparesig 1E-13 1 -> -1
+dqcms543 comparesig 1E-12 1 -> -1
+dqcms544 comparesig 1E-11 1 -> -1
+dqcms545 comparesig 1E-10 1 -> -1
+dqcms546 comparesig 1E-9 1 -> -1
+dqcms547 comparesig 1E-8 1 -> -1
+dqcms548 comparesig 1E-7 1 -> -1
+dqcms549 comparesig 1E-6 1 -> -1
+dqcms550 comparesig 1E-5 1 -> -1
+dqcms551 comparesig 1E-4 1 -> -1
+dqcms552 comparesig 1E-3 1 -> -1
+dqcms553 comparesig 1E-2 1 -> -1
+dqcms554 comparesig 1E-1 1 -> -1
+dqcms555 comparesig 1E-0 1 -> 0
+dqcms556 comparesig 1E+1 1 -> 1
+dqcms557 comparesig 1E+2 1 -> 1
+dqcms558 comparesig 1E+3 1 -> 1
+dqcms559 comparesig 1E+4 1 -> 1
+dqcms561 comparesig 1E+5 1 -> 1
+dqcms562 comparesig 1E+6 1 -> 1
+dqcms563 comparesig 1E+7 1 -> 1
+dqcms564 comparesig 1E+8 1 -> 1
+dqcms565 comparesig 1E+9 1 -> 1
+dqcms566 comparesig 1E+10 1 -> 1
+dqcms567 comparesig 1E+11 1 -> 1
+dqcms568 comparesig 1E+12 1 -> 1
+dqcms569 comparesig 1E+13 1 -> 1
+dqcms570 comparesig 1E+14 1 -> 1
+dqcms571 comparesig 1E+15 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcms580 comparesig 0.000000987654321 1E-15 -> 1
+dqcms581 comparesig 0.000000987654321 1E-14 -> 1
+dqcms582 comparesig 0.000000987654321 1E-13 -> 1
+dqcms583 comparesig 0.000000987654321 1E-12 -> 1
+dqcms584 comparesig 0.000000987654321 1E-11 -> 1
+dqcms585 comparesig 0.000000987654321 1E-10 -> 1
+dqcms586 comparesig 0.000000987654321 1E-9 -> 1
+dqcms587 comparesig 0.000000987654321 1E-8 -> 1
+dqcms588 comparesig 0.000000987654321 1E-7 -> 1
+dqcms589 comparesig 0.000000987654321 1E-6 -> -1
+dqcms590 comparesig 0.000000987654321 1E-5 -> -1
+dqcms591 comparesig 0.000000987654321 1E-4 -> -1
+dqcms592 comparesig 0.000000987654321 1E-3 -> -1
+dqcms593 comparesig 0.000000987654321 1E-2 -> -1
+dqcms594 comparesig 0.000000987654321 1E-1 -> -1
+dqcms595 comparesig 0.000000987654321 1E-0 -> -1
+dqcms596 comparesig 0.000000987654321 1E+1 -> -1
+dqcms597 comparesig 0.000000987654321 1E+2 -> -1
+dqcms598 comparesig 0.000000987654321 1E+3 -> -1
+dqcms599 comparesig 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcms600 comparesig 12 12.2345 -> -1
+dqcms601 comparesig 12.0 12.2345 -> -1
+dqcms602 comparesig 12.00 12.2345 -> -1
+dqcms603 comparesig 12.000 12.2345 -> -1
+dqcms604 comparesig 12.0000 12.2345 -> -1
+dqcms605 comparesig 12.00000 12.2345 -> -1
+dqcms606 comparesig 12.000000 12.2345 -> -1
+dqcms607 comparesig 12.0000000 12.2345 -> -1
+dqcms608 comparesig 12.00000000 12.2345 -> -1
+dqcms609 comparesig 12.000000000 12.2345 -> -1
+dqcms610 comparesig 12.1234 12 -> 1
+dqcms611 comparesig 12.1234 12.0 -> 1
+dqcms612 comparesig 12.1234 12.00 -> 1
+dqcms613 comparesig 12.1234 12.000 -> 1
+dqcms614 comparesig 12.1234 12.0000 -> 1
+dqcms615 comparesig 12.1234 12.00000 -> 1
+dqcms616 comparesig 12.1234 12.000000 -> 1
+dqcms617 comparesig 12.1234 12.0000000 -> 1
+dqcms618 comparesig 12.1234 12.00000000 -> 1
+dqcms619 comparesig 12.1234 12.000000000 -> 1
+dqcms620 comparesig -12 -12.2345 -> 1
+dqcms621 comparesig -12.0 -12.2345 -> 1
+dqcms622 comparesig -12.00 -12.2345 -> 1
+dqcms623 comparesig -12.000 -12.2345 -> 1
+dqcms624 comparesig -12.0000 -12.2345 -> 1
+dqcms625 comparesig -12.00000 -12.2345 -> 1
+dqcms626 comparesig -12.000000 -12.2345 -> 1
+dqcms627 comparesig -12.0000000 -12.2345 -> 1
+dqcms628 comparesig -12.00000000 -12.2345 -> 1
+dqcms629 comparesig -12.000000000 -12.2345 -> 1
+dqcms630 comparesig -12.1234 -12 -> -1
+dqcms631 comparesig -12.1234 -12.0 -> -1
+dqcms632 comparesig -12.1234 -12.00 -> -1
+dqcms633 comparesig -12.1234 -12.000 -> -1
+dqcms634 comparesig -12.1234 -12.0000 -> -1
+dqcms635 comparesig -12.1234 -12.00000 -> -1
+dqcms636 comparesig -12.1234 -12.000000 -> -1
+dqcms637 comparesig -12.1234 -12.0000000 -> -1
+dqcms638 comparesig -12.1234 -12.00000000 -> -1
+dqcms639 comparesig -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcms640 comparesig 0 0 -> 0
+dqcms641 comparesig 0 -0 -> 0
+dqcms642 comparesig 0 -0.0 -> 0
+dqcms643 comparesig 0 0.0 -> 0
+dqcms644 comparesig -0 0 -> 0
+dqcms645 comparesig -0 -0 -> 0
+dqcms646 comparesig -0 -0.0 -> 0
+dqcms647 comparesig -0 0.0 -> 0
+dqcms648 comparesig 0.0 0 -> 0
+dqcms649 comparesig 0.0 -0 -> 0
+dqcms650 comparesig 0.0 -0.0 -> 0
+dqcms651 comparesig 0.0 0.0 -> 0
+dqcms652 comparesig -0.0 0 -> 0
+dqcms653 comparesig -0.0 -0 -> 0
+dqcms654 comparesig -0.0 -0.0 -> 0
+dqcms655 comparesig -0.0 0.0 -> 0
+
+dqcms656 comparesig -0E1 0.0 -> 0
+dqcms657 comparesig -0E2 0.0 -> 0
+dqcms658 comparesig 0E1 0.0 -> 0
+dqcms659 comparesig 0E2 0.0 -> 0
+dqcms660 comparesig -0E1 0 -> 0
+dqcms661 comparesig -0E2 0 -> 0
+dqcms662 comparesig 0E1 0 -> 0
+dqcms663 comparesig 0E2 0 -> 0
+dqcms664 comparesig -0E1 -0E1 -> 0
+dqcms665 comparesig -0E2 -0E1 -> 0
+dqcms666 comparesig 0E1 -0E1 -> 0
+dqcms667 comparesig 0E2 -0E1 -> 0
+dqcms668 comparesig -0E1 -0E2 -> 0
+dqcms669 comparesig -0E2 -0E2 -> 0
+dqcms670 comparesig 0E1 -0E2 -> 0
+dqcms671 comparesig 0E2 -0E2 -> 0
+dqcms672 comparesig -0E1 0E1 -> 0
+dqcms673 comparesig -0E2 0E1 -> 0
+dqcms674 comparesig 0E1 0E1 -> 0
+dqcms675 comparesig 0E2 0E1 -> 0
+dqcms676 comparesig -0E1 0E2 -> 0
+dqcms677 comparesig -0E2 0E2 -> 0
+dqcms678 comparesig 0E1 0E2 -> 0
+dqcms679 comparesig 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcms680 comparesig 12 12 -> 0
+dqcms681 comparesig 12 12.0 -> 0
+dqcms682 comparesig 12 12.00 -> 0
+dqcms683 comparesig 12 12.000 -> 0
+dqcms684 comparesig 12 12.0000 -> 0
+dqcms685 comparesig 12 12.00000 -> 0
+dqcms686 comparesig 12 12.000000 -> 0
+dqcms687 comparesig 12 12.0000000 -> 0
+dqcms688 comparesig 12 12.00000000 -> 0
+dqcms689 comparesig 12 12.000000000 -> 0
+dqcms690 comparesig 12 12 -> 0
+dqcms691 comparesig 12.0 12 -> 0
+dqcms692 comparesig 12.00 12 -> 0
+dqcms693 comparesig 12.000 12 -> 0
+dqcms694 comparesig 12.0000 12 -> 0
+dqcms695 comparesig 12.00000 12 -> 0
+dqcms696 comparesig 12.000000 12 -> 0
+dqcms697 comparesig 12.0000000 12 -> 0
+dqcms698 comparesig 12.00000000 12 -> 0
+dqcms699 comparesig 12.000000000 12 -> 0
+
+-- first, second, & last digit
+dqcms700 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123455 -> 1
+dqcms701 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcms702 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123457 -> -1
+dqcms703 comparesig 1234567899999999999999999990123456 0234567899999999999999999990123456 -> 1
+dqcms704 comparesig 1234567899999999999999999990123456 1234567899999999999999999990123456 -> 0
+dqcms705 comparesig 1234567899999999999999999990123456 2234567899999999999999999990123456 -> -1
+dqcms706 comparesig 1134567899999999999999999990123456 1034567899999999999999999990123456 -> 1
+dqcms707 comparesig 1134567899999999999999999990123456 1134567899999999999999999990123456 -> 0
+dqcms708 comparesig 1134567899999999999999999990123456 1234567899999999999999999990123456 -> -1
+
+-- miscellaneous
+dqcms721 comparesig 12345678000 1 -> 1
+dqcms722 comparesig 1 12345678000 -> -1
+dqcms723 comparesig 1234567800 1 -> 1
+dqcms724 comparesig 1 1234567800 -> -1
+dqcms725 comparesig 1234567890 1 -> 1
+dqcms726 comparesig 1 1234567890 -> -1
+dqcms727 comparesig 1234567891 1 -> 1
+dqcms728 comparesig 1 1234567891 -> -1
+dqcms729 comparesig 12345678901 1 -> 1
+dqcms730 comparesig 1 12345678901 -> -1
+dqcms731 comparesig 1234567896 1 -> 1
+dqcms732 comparesig 1 1234567896 -> -1
+
+-- residue cases at lower precision
+dqcms740 comparesig 1 0.9999999 -> 1
+dqcms741 comparesig 1 0.999999 -> 1
+dqcms742 comparesig 1 0.99999 -> 1
+dqcms743 comparesig 1 1.0000 -> 0
+dqcms744 comparesig 1 1.00001 -> -1
+dqcms745 comparesig 1 1.000001 -> -1
+dqcms746 comparesig 1 1.0000001 -> -1
+dqcms750 comparesig 0.9999999 1 -> -1
+dqcms751 comparesig 0.999999 1 -> -1
+dqcms752 comparesig 0.99999 1 -> -1
+dqcms753 comparesig 1.0000 1 -> 0
+dqcms754 comparesig 1.00001 1 -> 1
+dqcms755 comparesig 1.000001 1 -> 1
+dqcms756 comparesig 1.0000001 1 -> 1
+
+-- Specials
+dqcms780 comparesig Inf -Inf -> 1
+dqcms781 comparesig Inf -1000 -> 1
+dqcms782 comparesig Inf -1 -> 1
+dqcms783 comparesig Inf -0 -> 1
+dqcms784 comparesig Inf 0 -> 1
+dqcms785 comparesig Inf 1 -> 1
+dqcms786 comparesig Inf 1000 -> 1
+dqcms787 comparesig Inf Inf -> 0
+dqcms788 comparesig -1000 Inf -> -1
+dqcms789 comparesig -Inf Inf -> -1
+dqcms790 comparesig -1 Inf -> -1
+dqcms791 comparesig -0 Inf -> -1
+dqcms792 comparesig 0 Inf -> -1
+dqcms793 comparesig 1 Inf -> -1
+dqcms794 comparesig 1000 Inf -> -1
+dqcms795 comparesig Inf Inf -> 0
+
+dqcms800 comparesig -Inf -Inf -> 0
+dqcms801 comparesig -Inf -1000 -> -1
+dqcms802 comparesig -Inf -1 -> -1
+dqcms803 comparesig -Inf -0 -> -1
+dqcms804 comparesig -Inf 0 -> -1
+dqcms805 comparesig -Inf 1 -> -1
+dqcms806 comparesig -Inf 1000 -> -1
+dqcms807 comparesig -Inf Inf -> -1
+dqcms808 comparesig -Inf -Inf -> 0
+dqcms809 comparesig -1000 -Inf -> 1
+dqcms810 comparesig -1 -Inf -> 1
+dqcms811 comparesig -0 -Inf -> 1
+dqcms812 comparesig 0 -Inf -> 1
+dqcms813 comparesig 1 -Inf -> 1
+dqcms814 comparesig 1000 -Inf -> 1
+dqcms815 comparesig Inf -Inf -> 1
+
+dqcms821 comparesig NaN -Inf -> NaN Invalid_operation
+dqcms822 comparesig NaN -1000 -> NaN Invalid_operation
+dqcms823 comparesig NaN -1 -> NaN Invalid_operation
+dqcms824 comparesig NaN -0 -> NaN Invalid_operation
+dqcms825 comparesig NaN 0 -> NaN Invalid_operation
+dqcms826 comparesig NaN 1 -> NaN Invalid_operation
+dqcms827 comparesig NaN 1000 -> NaN Invalid_operation
+dqcms828 comparesig NaN Inf -> NaN Invalid_operation
+dqcms829 comparesig NaN NaN -> NaN Invalid_operation
+dqcms830 comparesig -Inf NaN -> NaN Invalid_operation
+dqcms831 comparesig -1000 NaN -> NaN Invalid_operation
+dqcms832 comparesig -1 NaN -> NaN Invalid_operation
+dqcms833 comparesig -0 NaN -> NaN Invalid_operation
+dqcms834 comparesig 0 NaN -> NaN Invalid_operation
+dqcms835 comparesig 1 NaN -> NaN Invalid_operation
+dqcms836 comparesig 1000 NaN -> NaN Invalid_operation
+dqcms837 comparesig Inf NaN -> NaN Invalid_operation
+dqcms838 comparesig -NaN -NaN -> -NaN Invalid_operation
+dqcms839 comparesig +NaN -NaN -> NaN Invalid_operation
+dqcms840 comparesig -NaN +NaN -> -NaN Invalid_operation
+
+dqcms841 comparesig sNaN -Inf -> NaN Invalid_operation
+dqcms842 comparesig sNaN -1000 -> NaN Invalid_operation
+dqcms843 comparesig sNaN -1 -> NaN Invalid_operation
+dqcms844 comparesig sNaN -0 -> NaN Invalid_operation
+dqcms845 comparesig sNaN 0 -> NaN Invalid_operation
+dqcms846 comparesig sNaN 1 -> NaN Invalid_operation
+dqcms847 comparesig sNaN 1000 -> NaN Invalid_operation
+dqcms848 comparesig sNaN NaN -> NaN Invalid_operation
+dqcms849 comparesig sNaN sNaN -> NaN Invalid_operation
+dqcms850 comparesig NaN sNaN -> NaN Invalid_operation
+dqcms851 comparesig -Inf sNaN -> NaN Invalid_operation
+dqcms852 comparesig -1000 sNaN -> NaN Invalid_operation
+dqcms853 comparesig -1 sNaN -> NaN Invalid_operation
+dqcms854 comparesig -0 sNaN -> NaN Invalid_operation
+dqcms855 comparesig 0 sNaN -> NaN Invalid_operation
+dqcms856 comparesig 1 sNaN -> NaN Invalid_operation
+dqcms857 comparesig 1000 sNaN -> NaN Invalid_operation
+dqcms858 comparesig Inf sNaN -> NaN Invalid_operation
+dqcms859 comparesig NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqcms860 comparesig NaN9 -Inf -> NaN9 Invalid_operation
+dqcms861 comparesig NaN8 999 -> NaN8 Invalid_operation
+dqcms862 comparesig NaN77 Inf -> NaN77 Invalid_operation
+dqcms863 comparesig -NaN67 NaN5 -> -NaN67 Invalid_operation
+dqcms864 comparesig -Inf -NaN4 -> -NaN4 Invalid_operation
+dqcms865 comparesig -999 -NaN33 -> -NaN33 Invalid_operation
+dqcms866 comparesig Inf NaN2 -> NaN2 Invalid_operation
+dqcms867 comparesig -NaN41 -NaN42 -> -NaN41 Invalid_operation
+dqcms868 comparesig +NaN41 -NaN42 -> NaN41 Invalid_operation
+dqcms869 comparesig -NaN41 +NaN42 -> -NaN41 Invalid_operation
+dqcms870 comparesig +NaN41 +NaN42 -> NaN41 Invalid_operation
+
+dqcms871 comparesig -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqcms872 comparesig sNaN98 -11 -> NaN98 Invalid_operation
+dqcms873 comparesig sNaN97 NaN -> NaN97 Invalid_operation
+dqcms874 comparesig sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqcms875 comparesig NaN85 sNaN83 -> NaN83 Invalid_operation
+dqcms876 comparesig -Inf sNaN92 -> NaN92 Invalid_operation
+dqcms877 comparesig 088 sNaN81 -> NaN81 Invalid_operation
+dqcms878 comparesig Inf sNaN90 -> NaN90 Invalid_operation
+dqcms879 comparesig NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- wide range
+dqcms880 comparesig +1.23456789012345E-0 9E+6144 -> -1
+dqcms881 comparesig 9E+6144 +1.23456789012345E-0 -> 1
+dqcms882 comparesig +0.100 9E-6143 -> 1
+dqcms883 comparesig 9E-6143 +0.100 -> -1
+dqcms885 comparesig -1.23456789012345E-0 9E+6144 -> -1
+dqcms886 comparesig 9E+6144 -1.23456789012345E-0 -> 1
+dqcms887 comparesig -0.100 9E-6143 -> -1
+dqcms888 comparesig 9E-6143 -0.100 -> 1
+
+-- signs
+dqcms901 comparesig 1e+77 1e+11 -> 1
+dqcms902 comparesig 1e+77 -1e+11 -> 1
+dqcms903 comparesig -1e+77 1e+11 -> -1
+dqcms904 comparesig -1e+77 -1e+11 -> -1
+dqcms905 comparesig 1e-77 1e-11 -> -1
+dqcms906 comparesig 1e-77 -1e-11 -> 1
+dqcms907 comparesig -1e-77 1e-11 -> -1
+dqcms908 comparesig -1e-77 -1e-11 -> 1
+
+-- Null tests
+dqcms990 comparesig 10 # -> NaN Invalid_operation
+dqcms991 comparesig # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareTotal.decTest b/Lib/test/decimaltestdata/dqCompareTotal.decTest
index 13701ccb577..bae3761909a 100644
--- a/Lib/test/decimaltestdata/dqCompareTotal.decTest
+++ b/Lib/test/decimaltestdata/dqCompareTotal.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- dqCompareTotal.decTest -- decQuad comparison using total ordering --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqcot001 comparetotal -2 -2 -> 0
-dqcot002 comparetotal -2 -1 -> -1
-dqcot003 comparetotal -2 0 -> -1
-dqcot004 comparetotal -2 1 -> -1
-dqcot005 comparetotal -2 2 -> -1
-dqcot006 comparetotal -1 -2 -> 1
-dqcot007 comparetotal -1 -1 -> 0
-dqcot008 comparetotal -1 0 -> -1
-dqcot009 comparetotal -1 1 -> -1
-dqcot010 comparetotal -1 2 -> -1
-dqcot011 comparetotal 0 -2 -> 1
-dqcot012 comparetotal 0 -1 -> 1
-dqcot013 comparetotal 0 0 -> 0
-dqcot014 comparetotal 0 1 -> -1
-dqcot015 comparetotal 0 2 -> -1
-dqcot016 comparetotal 1 -2 -> 1
-dqcot017 comparetotal 1 -1 -> 1
-dqcot018 comparetotal 1 0 -> 1
-dqcot019 comparetotal 1 1 -> 0
-dqcot020 comparetotal 1 2 -> -1
-dqcot021 comparetotal 2 -2 -> 1
-dqcot022 comparetotal 2 -1 -> 1
-dqcot023 comparetotal 2 0 -> 1
-dqcot025 comparetotal 2 1 -> 1
-dqcot026 comparetotal 2 2 -> 0
-
-dqcot031 comparetotal -20 -20 -> 0
-dqcot032 comparetotal -20 -10 -> -1
-dqcot033 comparetotal -20 00 -> -1
-dqcot034 comparetotal -20 10 -> -1
-dqcot035 comparetotal -20 20 -> -1
-dqcot036 comparetotal -10 -20 -> 1
-dqcot037 comparetotal -10 -10 -> 0
-dqcot038 comparetotal -10 00 -> -1
-dqcot039 comparetotal -10 10 -> -1
-dqcot040 comparetotal -10 20 -> -1
-dqcot041 comparetotal 00 -20 -> 1
-dqcot042 comparetotal 00 -10 -> 1
-dqcot043 comparetotal 00 00 -> 0
-dqcot044 comparetotal 00 10 -> -1
-dqcot045 comparetotal 00 20 -> -1
-dqcot046 comparetotal 10 -20 -> 1
-dqcot047 comparetotal 10 -10 -> 1
-dqcot048 comparetotal 10 00 -> 1
-dqcot049 comparetotal 10 10 -> 0
-dqcot050 comparetotal 10 20 -> -1
-dqcot051 comparetotal 20 -20 -> 1
-dqcot052 comparetotal 20 -10 -> 1
-dqcot053 comparetotal 20 00 -> 1
-dqcot055 comparetotal 20 10 -> 1
-dqcot056 comparetotal 20 20 -> 0
-
-dqcot061 comparetotal -2.0 -2.0 -> 0
-dqcot062 comparetotal -2.0 -1.0 -> -1
-dqcot063 comparetotal -2.0 0.0 -> -1
-dqcot064 comparetotal -2.0 1.0 -> -1
-dqcot065 comparetotal -2.0 2.0 -> -1
-dqcot066 comparetotal -1.0 -2.0 -> 1
-dqcot067 comparetotal -1.0 -1.0 -> 0
-dqcot068 comparetotal -1.0 0.0 -> -1
-dqcot069 comparetotal -1.0 1.0 -> -1
-dqcot070 comparetotal -1.0 2.0 -> -1
-dqcot071 comparetotal 0.0 -2.0 -> 1
-dqcot072 comparetotal 0.0 -1.0 -> 1
-dqcot073 comparetotal 0.0 0.0 -> 0
-dqcot074 comparetotal 0.0 1.0 -> -1
-dqcot075 comparetotal 0.0 2.0 -> -1
-dqcot076 comparetotal 1.0 -2.0 -> 1
-dqcot077 comparetotal 1.0 -1.0 -> 1
-dqcot078 comparetotal 1.0 0.0 -> 1
-dqcot079 comparetotal 1.0 1.0 -> 0
-dqcot080 comparetotal 1.0 2.0 -> -1
-dqcot081 comparetotal 2.0 -2.0 -> 1
-dqcot082 comparetotal 2.0 -1.0 -> 1
-dqcot083 comparetotal 2.0 0.0 -> 1
-dqcot085 comparetotal 2.0 1.0 -> 1
-dqcot086 comparetotal 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqcot090 comparetotal 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqcot091 comparetotal -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> -1
-dqcot092 comparetotal 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 1
-dqcot093 comparetotal -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-dqcot100 comparetotal 7.0 7.0 -> 0
-dqcot101 comparetotal 7.0 7 -> -1
-dqcot102 comparetotal 7 7.0 -> 1
-dqcot103 comparetotal 7E+0 7.0 -> 1
-dqcot104 comparetotal 70E-1 7.0 -> 0
-dqcot105 comparetotal 0.7E+1 7 -> 0
-dqcot106 comparetotal 70E-1 7 -> -1
-dqcot107 comparetotal 7.0 7E+0 -> -1
-dqcot108 comparetotal 7.0 70E-1 -> 0
-dqcot109 comparetotal 7 0.7E+1 -> 0
-dqcot110 comparetotal 7 70E-1 -> 1
-
-dqcot120 comparetotal 8.0 7.0 -> 1
-dqcot121 comparetotal 8.0 7 -> 1
-dqcot122 comparetotal 8 7.0 -> 1
-dqcot123 comparetotal 8E+0 7.0 -> 1
-dqcot124 comparetotal 80E-1 7.0 -> 1
-dqcot125 comparetotal 0.8E+1 7 -> 1
-dqcot126 comparetotal 80E-1 7 -> 1
-dqcot127 comparetotal 8.0 7E+0 -> 1
-dqcot128 comparetotal 8.0 70E-1 -> 1
-dqcot129 comparetotal 8 0.7E+1 -> 1
-dqcot130 comparetotal 8 70E-1 -> 1
-
-dqcot140 comparetotal 8.0 9.0 -> -1
-dqcot141 comparetotal 8.0 9 -> -1
-dqcot142 comparetotal 8 9.0 -> -1
-dqcot143 comparetotal 8E+0 9.0 -> -1
-dqcot144 comparetotal 80E-1 9.0 -> -1
-dqcot145 comparetotal 0.8E+1 9 -> -1
-dqcot146 comparetotal 80E-1 9 -> -1
-dqcot147 comparetotal 8.0 9E+0 -> -1
-dqcot148 comparetotal 8.0 90E-1 -> -1
-dqcot149 comparetotal 8 0.9E+1 -> -1
-dqcot150 comparetotal 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqcot200 comparetotal -7.0 7.0 -> -1
-dqcot201 comparetotal -7.0 7 -> -1
-dqcot202 comparetotal -7 7.0 -> -1
-dqcot203 comparetotal -7E+0 7.0 -> -1
-dqcot204 comparetotal -70E-1 7.0 -> -1
-dqcot205 comparetotal -0.7E+1 7 -> -1
-dqcot206 comparetotal -70E-1 7 -> -1
-dqcot207 comparetotal -7.0 7E+0 -> -1
-dqcot208 comparetotal -7.0 70E-1 -> -1
-dqcot209 comparetotal -7 0.7E+1 -> -1
-dqcot210 comparetotal -7 70E-1 -> -1
-
-dqcot220 comparetotal -8.0 7.0 -> -1
-dqcot221 comparetotal -8.0 7 -> -1
-dqcot222 comparetotal -8 7.0 -> -1
-dqcot223 comparetotal -8E+0 7.0 -> -1
-dqcot224 comparetotal -80E-1 7.0 -> -1
-dqcot225 comparetotal -0.8E+1 7 -> -1
-dqcot226 comparetotal -80E-1 7 -> -1
-dqcot227 comparetotal -8.0 7E+0 -> -1
-dqcot228 comparetotal -8.0 70E-1 -> -1
-dqcot229 comparetotal -8 0.7E+1 -> -1
-dqcot230 comparetotal -8 70E-1 -> -1
-
-dqcot240 comparetotal -8.0 9.0 -> -1
-dqcot241 comparetotal -8.0 9 -> -1
-dqcot242 comparetotal -8 9.0 -> -1
-dqcot243 comparetotal -8E+0 9.0 -> -1
-dqcot244 comparetotal -80E-1 9.0 -> -1
-dqcot245 comparetotal -0.8E+1 9 -> -1
-dqcot246 comparetotal -80E-1 9 -> -1
-dqcot247 comparetotal -8.0 9E+0 -> -1
-dqcot248 comparetotal -8.0 90E-1 -> -1
-dqcot249 comparetotal -8 0.9E+1 -> -1
-dqcot250 comparetotal -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqcot300 comparetotal 7.0 -7.0 -> 1
-dqcot301 comparetotal 7.0 -7 -> 1
-dqcot302 comparetotal 7 -7.0 -> 1
-dqcot303 comparetotal 7E+0 -7.0 -> 1
-dqcot304 comparetotal 70E-1 -7.0 -> 1
-dqcot305 comparetotal .7E+1 -7 -> 1
-dqcot306 comparetotal 70E-1 -7 -> 1
-dqcot307 comparetotal 7.0 -7E+0 -> 1
-dqcot308 comparetotal 7.0 -70E-1 -> 1
-dqcot309 comparetotal 7 -.7E+1 -> 1
-dqcot310 comparetotal 7 -70E-1 -> 1
-
-dqcot320 comparetotal 8.0 -7.0 -> 1
-dqcot321 comparetotal 8.0 -7 -> 1
-dqcot322 comparetotal 8 -7.0 -> 1
-dqcot323 comparetotal 8E+0 -7.0 -> 1
-dqcot324 comparetotal 80E-1 -7.0 -> 1
-dqcot325 comparetotal .8E+1 -7 -> 1
-dqcot326 comparetotal 80E-1 -7 -> 1
-dqcot327 comparetotal 8.0 -7E+0 -> 1
-dqcot328 comparetotal 8.0 -70E-1 -> 1
-dqcot329 comparetotal 8 -.7E+1 -> 1
-dqcot330 comparetotal 8 -70E-1 -> 1
-
-dqcot340 comparetotal 8.0 -9.0 -> 1
-dqcot341 comparetotal 8.0 -9 -> 1
-dqcot342 comparetotal 8 -9.0 -> 1
-dqcot343 comparetotal 8E+0 -9.0 -> 1
-dqcot344 comparetotal 80E-1 -9.0 -> 1
-dqcot345 comparetotal .8E+1 -9 -> 1
-dqcot346 comparetotal 80E-1 -9 -> 1
-dqcot347 comparetotal 8.0 -9E+0 -> 1
-dqcot348 comparetotal 8.0 -90E-1 -> 1
-dqcot349 comparetotal 8 -.9E+1 -> 1
-dqcot350 comparetotal 8 -90E-1 -> 1
-
--- and again, with sign changes -- ..
-dqcot400 comparetotal -7.0 -7.0 -> 0
-dqcot401 comparetotal -7.0 -7 -> 1
-dqcot402 comparetotal -7 -7.0 -> -1
-dqcot403 comparetotal -7E+0 -7.0 -> -1
-dqcot404 comparetotal -70E-1 -7.0 -> 0
-dqcot405 comparetotal -.7E+1 -7 -> 0
-dqcot406 comparetotal -70E-1 -7 -> 1
-dqcot407 comparetotal -7.0 -7E+0 -> 1
-dqcot408 comparetotal -7.0 -70E-1 -> 0
-dqcot409 comparetotal -7 -.7E+1 -> 0
-dqcot410 comparetotal -7 -70E-1 -> -1
-
-dqcot420 comparetotal -8.0 -7.0 -> -1
-dqcot421 comparetotal -8.0 -7 -> -1
-dqcot422 comparetotal -8 -7.0 -> -1
-dqcot423 comparetotal -8E+0 -7.0 -> -1
-dqcot424 comparetotal -80E-1 -7.0 -> -1
-dqcot425 comparetotal -.8E+1 -7 -> -1
-dqcot426 comparetotal -80E-1 -7 -> -1
-dqcot427 comparetotal -8.0 -7E+0 -> -1
-dqcot428 comparetotal -8.0 -70E-1 -> -1
-dqcot429 comparetotal -8 -.7E+1 -> -1
-dqcot430 comparetotal -8 -70E-1 -> -1
-
-dqcot440 comparetotal -8.0 -9.0 -> 1
-dqcot441 comparetotal -8.0 -9 -> 1
-dqcot442 comparetotal -8 -9.0 -> 1
-dqcot443 comparetotal -8E+0 -9.0 -> 1
-dqcot444 comparetotal -80E-1 -9.0 -> 1
-dqcot445 comparetotal -.8E+1 -9 -> 1
-dqcot446 comparetotal -80E-1 -9 -> 1
-dqcot447 comparetotal -8.0 -9E+0 -> 1
-dqcot448 comparetotal -8.0 -90E-1 -> 1
-dqcot449 comparetotal -8 -.9E+1 -> 1
-dqcot450 comparetotal -8 -90E-1 -> 1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
-dqcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
-dqcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
-dqcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
-dqcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
-dqcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
-dqcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
-dqcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
-dqcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
-dqcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
-dqcot483 comparetotal 123.456E-89 123.456E-89 -> 0
-dqcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
-dqcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
-dqcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
-dqcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
-dqcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
-dqcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
-dqcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
-dqcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
-dqcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
-dqcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
-dqcot497 comparetotal 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqcot498 comparetotal 1 1E-17 -> 1
-dqcot499 comparetotal 1 1E-16 -> 1
-dqcot500 comparetotal 1 1E-15 -> 1
-dqcot501 comparetotal 1 1E-14 -> 1
-dqcot502 comparetotal 1 1E-13 -> 1
-dqcot503 comparetotal 1 1E-12 -> 1
-dqcot504 comparetotal 1 1E-11 -> 1
-dqcot505 comparetotal 1 1E-10 -> 1
-dqcot506 comparetotal 1 1E-9 -> 1
-dqcot507 comparetotal 1 1E-8 -> 1
-dqcot508 comparetotal 1 1E-7 -> 1
-dqcot509 comparetotal 1 1E-6 -> 1
-dqcot510 comparetotal 1 1E-5 -> 1
-dqcot511 comparetotal 1 1E-4 -> 1
-dqcot512 comparetotal 1 1E-3 -> 1
-dqcot513 comparetotal 1 1E-2 -> 1
-dqcot514 comparetotal 1 1E-1 -> 1
-dqcot515 comparetotal 1 1E-0 -> 0
-dqcot516 comparetotal 1 1E+1 -> -1
-dqcot517 comparetotal 1 1E+2 -> -1
-dqcot518 comparetotal 1 1E+3 -> -1
-dqcot519 comparetotal 1 1E+4 -> -1
-dqcot521 comparetotal 1 1E+5 -> -1
-dqcot522 comparetotal 1 1E+6 -> -1
-dqcot523 comparetotal 1 1E+7 -> -1
-dqcot524 comparetotal 1 1E+8 -> -1
-dqcot525 comparetotal 1 1E+9 -> -1
-dqcot526 comparetotal 1 1E+10 -> -1
-dqcot527 comparetotal 1 1E+11 -> -1
-dqcot528 comparetotal 1 1E+12 -> -1
-dqcot529 comparetotal 1 1E+13 -> -1
-dqcot530 comparetotal 1 1E+14 -> -1
-dqcot531 comparetotal 1 1E+15 -> -1
-dqcot532 comparetotal 1 1E+16 -> -1
-dqcot533 comparetotal 1 1E+17 -> -1
--- LR swap
-dqcot538 comparetotal 1E-17 1 -> -1
-dqcot539 comparetotal 1E-16 1 -> -1
-dqcot540 comparetotal 1E-15 1 -> -1
-dqcot541 comparetotal 1E-14 1 -> -1
-dqcot542 comparetotal 1E-13 1 -> -1
-dqcot543 comparetotal 1E-12 1 -> -1
-dqcot544 comparetotal 1E-11 1 -> -1
-dqcot545 comparetotal 1E-10 1 -> -1
-dqcot546 comparetotal 1E-9 1 -> -1
-dqcot547 comparetotal 1E-8 1 -> -1
-dqcot548 comparetotal 1E-7 1 -> -1
-dqcot549 comparetotal 1E-6 1 -> -1
-dqcot550 comparetotal 1E-5 1 -> -1
-dqcot551 comparetotal 1E-4 1 -> -1
-dqcot552 comparetotal 1E-3 1 -> -1
-dqcot553 comparetotal 1E-2 1 -> -1
-dqcot554 comparetotal 1E-1 1 -> -1
-dqcot555 comparetotal 1E-0 1 -> 0
-dqcot556 comparetotal 1E+1 1 -> 1
-dqcot557 comparetotal 1E+2 1 -> 1
-dqcot558 comparetotal 1E+3 1 -> 1
-dqcot559 comparetotal 1E+4 1 -> 1
-dqcot561 comparetotal 1E+5 1 -> 1
-dqcot562 comparetotal 1E+6 1 -> 1
-dqcot563 comparetotal 1E+7 1 -> 1
-dqcot564 comparetotal 1E+8 1 -> 1
-dqcot565 comparetotal 1E+9 1 -> 1
-dqcot566 comparetotal 1E+10 1 -> 1
-dqcot567 comparetotal 1E+11 1 -> 1
-dqcot568 comparetotal 1E+12 1 -> 1
-dqcot569 comparetotal 1E+13 1 -> 1
-dqcot570 comparetotal 1E+14 1 -> 1
-dqcot571 comparetotal 1E+15 1 -> 1
-dqcot572 comparetotal 1E+16 1 -> 1
-dqcot573 comparetotal 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-dqcot578 comparetotal 0.000000987654321 1E-17 -> 1
-dqcot579 comparetotal 0.000000987654321 1E-16 -> 1
-dqcot580 comparetotal 0.000000987654321 1E-15 -> 1
-dqcot581 comparetotal 0.000000987654321 1E-14 -> 1
-dqcot582 comparetotal 0.000000987654321 1E-13 -> 1
-dqcot583 comparetotal 0.000000987654321 1E-12 -> 1
-dqcot584 comparetotal 0.000000987654321 1E-11 -> 1
-dqcot585 comparetotal 0.000000987654321 1E-10 -> 1
-dqcot586 comparetotal 0.000000987654321 1E-9 -> 1
-dqcot587 comparetotal 0.000000987654321 1E-8 -> 1
-dqcot588 comparetotal 0.000000987654321 1E-7 -> 1
-dqcot589 comparetotal 0.000000987654321 1E-6 -> -1
-dqcot590 comparetotal 0.000000987654321 1E-5 -> -1
-dqcot591 comparetotal 0.000000987654321 1E-4 -> -1
-dqcot592 comparetotal 0.000000987654321 1E-3 -> -1
-dqcot593 comparetotal 0.000000987654321 1E-2 -> -1
-dqcot594 comparetotal 0.000000987654321 1E-1 -> -1
-dqcot595 comparetotal 0.000000987654321 1E-0 -> -1
-dqcot596 comparetotal 0.000000987654321 1E+1 -> -1
-dqcot597 comparetotal 0.000000987654321 1E+2 -> -1
-dqcot598 comparetotal 0.000000987654321 1E+3 -> -1
-dqcot599 comparetotal 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqcot600 comparetotal 12 12.2345 -> -1
-dqcot601 comparetotal 12.0 12.2345 -> -1
-dqcot602 comparetotal 12.00 12.2345 -> -1
-dqcot603 comparetotal 12.000 12.2345 -> -1
-dqcot604 comparetotal 12.0000 12.2345 -> -1
-dqcot605 comparetotal 12.00000 12.2345 -> -1
-dqcot606 comparetotal 12.000000 12.2345 -> -1
-dqcot607 comparetotal 12.0000000 12.2345 -> -1
-dqcot608 comparetotal 12.00000000 12.2345 -> -1
-dqcot609 comparetotal 12.000000000 12.2345 -> -1
-dqcot610 comparetotal 12.1234 12 -> 1
-dqcot611 comparetotal 12.1234 12.0 -> 1
-dqcot612 comparetotal 12.1234 12.00 -> 1
-dqcot613 comparetotal 12.1234 12.000 -> 1
-dqcot614 comparetotal 12.1234 12.0000 -> 1
-dqcot615 comparetotal 12.1234 12.00000 -> 1
-dqcot616 comparetotal 12.1234 12.000000 -> 1
-dqcot617 comparetotal 12.1234 12.0000000 -> 1
-dqcot618 comparetotal 12.1234 12.00000000 -> 1
-dqcot619 comparetotal 12.1234 12.000000000 -> 1
-dqcot620 comparetotal -12 -12.2345 -> 1
-dqcot621 comparetotal -12.0 -12.2345 -> 1
-dqcot622 comparetotal -12.00 -12.2345 -> 1
-dqcot623 comparetotal -12.000 -12.2345 -> 1
-dqcot624 comparetotal -12.0000 -12.2345 -> 1
-dqcot625 comparetotal -12.00000 -12.2345 -> 1
-dqcot626 comparetotal -12.000000 -12.2345 -> 1
-dqcot627 comparetotal -12.0000000 -12.2345 -> 1
-dqcot628 comparetotal -12.00000000 -12.2345 -> 1
-dqcot629 comparetotal -12.000000000 -12.2345 -> 1
-dqcot630 comparetotal -12.1234 -12 -> -1
-dqcot631 comparetotal -12.1234 -12.0 -> -1
-dqcot632 comparetotal -12.1234 -12.00 -> -1
-dqcot633 comparetotal -12.1234 -12.000 -> -1
-dqcot634 comparetotal -12.1234 -12.0000 -> -1
-dqcot635 comparetotal -12.1234 -12.00000 -> -1
-dqcot636 comparetotal -12.1234 -12.000000 -> -1
-dqcot637 comparetotal -12.1234 -12.0000000 -> -1
-dqcot638 comparetotal -12.1234 -12.00000000 -> -1
-dqcot639 comparetotal -12.1234 -12.000000000 -> -1
-
--- extended zeros
-dqcot640 comparetotal 0 0 -> 0
-dqcot641 comparetotal 0 -0 -> 1
-dqcot642 comparetotal 0 -0.0 -> 1
-dqcot643 comparetotal 0 0.0 -> 1
-dqcot644 comparetotal -0 0 -> -1
-dqcot645 comparetotal -0 -0 -> 0
-dqcot646 comparetotal -0 -0.0 -> -1
-dqcot647 comparetotal -0 0.0 -> -1
-dqcot648 comparetotal 0.0 0 -> -1
-dqcot649 comparetotal 0.0 -0 -> 1
-dqcot650 comparetotal 0.0 -0.0 -> 1
-dqcot651 comparetotal 0.0 0.0 -> 0
-dqcot652 comparetotal -0.0 0 -> -1
-dqcot653 comparetotal -0.0 -0 -> 1
-dqcot654 comparetotal -0.0 -0.0 -> 0
-dqcot655 comparetotal -0.0 0.0 -> -1
-
-dqcot656 comparetotal -0E1 0.0 -> -1
-dqcot657 comparetotal -0E2 0.0 -> -1
-dqcot658 comparetotal 0E1 0.0 -> 1
-dqcot659 comparetotal 0E2 0.0 -> 1
-dqcot660 comparetotal -0E1 0 -> -1
-dqcot661 comparetotal -0E2 0 -> -1
-dqcot662 comparetotal 0E1 0 -> 1
-dqcot663 comparetotal 0E2 0 -> 1
-dqcot664 comparetotal -0E1 -0E1 -> 0
-dqcot665 comparetotal -0E2 -0E1 -> -1
-dqcot666 comparetotal 0E1 -0E1 -> 1
-dqcot667 comparetotal 0E2 -0E1 -> 1
-dqcot668 comparetotal -0E1 -0E2 -> 1
-dqcot669 comparetotal -0E2 -0E2 -> 0
-dqcot670 comparetotal 0E1 -0E2 -> 1
-dqcot671 comparetotal 0E2 -0E2 -> 1
-dqcot672 comparetotal -0E1 0E1 -> -1
-dqcot673 comparetotal -0E2 0E1 -> -1
-dqcot674 comparetotal 0E1 0E1 -> 0
-dqcot675 comparetotal 0E2 0E1 -> 1
-dqcot676 comparetotal -0E1 0E2 -> -1
-dqcot677 comparetotal -0E2 0E2 -> -1
-dqcot678 comparetotal 0E1 0E2 -> -1
-dqcot679 comparetotal 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqcot680 comparetotal 12 12 -> 0
-dqcot681 comparetotal 12 12.0 -> 1
-dqcot682 comparetotal 12 12.00 -> 1
-dqcot683 comparetotal 12 12.000 -> 1
-dqcot684 comparetotal 12 12.0000 -> 1
-dqcot685 comparetotal 12 12.00000 -> 1
-dqcot686 comparetotal 12 12.000000 -> 1
-dqcot687 comparetotal 12 12.0000000 -> 1
-dqcot688 comparetotal 12 12.00000000 -> 1
-dqcot689 comparetotal 12 12.000000000 -> 1
-dqcot690 comparetotal 12 12 -> 0
-dqcot691 comparetotal 12.0 12 -> -1
-dqcot692 comparetotal 12.00 12 -> -1
-dqcot693 comparetotal 12.000 12 -> -1
-dqcot694 comparetotal 12.0000 12 -> -1
-dqcot695 comparetotal 12.00000 12 -> -1
-dqcot696 comparetotal 12.000000 12 -> -1
-dqcot697 comparetotal 12.0000000 12 -> -1
-dqcot698 comparetotal 12.00000000 12 -> -1
-dqcot699 comparetotal 12.000000000 12 -> -1
-
--- old long operand checks
-dqcot701 comparetotal 12345678000 1 -> 1
-dqcot702 comparetotal 1 12345678000 -> -1
-dqcot703 comparetotal 1234567800 1 -> 1
-dqcot704 comparetotal 1 1234567800 -> -1
-dqcot705 comparetotal 1234567890 1 -> 1
-dqcot706 comparetotal 1 1234567890 -> -1
-dqcot707 comparetotal 1234567891 1 -> 1
-dqcot708 comparetotal 1 1234567891 -> -1
-dqcot709 comparetotal 12345678901 1 -> 1
-dqcot710 comparetotal 1 12345678901 -> -1
-dqcot711 comparetotal 1234567896 1 -> 1
-dqcot712 comparetotal 1 1234567896 -> -1
-dqcot713 comparetotal -1234567891 1 -> -1
-dqcot714 comparetotal 1 -1234567891 -> 1
-dqcot715 comparetotal -12345678901 1 -> -1
-dqcot716 comparetotal 1 -12345678901 -> 1
-dqcot717 comparetotal -1234567896 1 -> -1
-dqcot718 comparetotal 1 -1234567896 -> 1
-
--- old residue cases
-dqcot740 comparetotal 1 0.9999999 -> 1
-dqcot741 comparetotal 1 0.999999 -> 1
-dqcot742 comparetotal 1 0.99999 -> 1
-dqcot743 comparetotal 1 1.0000 -> 1
-dqcot744 comparetotal 1 1.00001 -> -1
-dqcot745 comparetotal 1 1.000001 -> -1
-dqcot746 comparetotal 1 1.0000001 -> -1
-dqcot750 comparetotal 0.9999999 1 -> -1
-dqcot751 comparetotal 0.999999 1 -> -1
-dqcot752 comparetotal 0.99999 1 -> -1
-dqcot753 comparetotal 1.0000 1 -> -1
-dqcot754 comparetotal 1.00001 1 -> 1
-dqcot755 comparetotal 1.000001 1 -> 1
-dqcot756 comparetotal 1.0000001 1 -> 1
-
--- Specials
-dqcot780 comparetotal Inf -Inf -> 1
-dqcot781 comparetotal Inf -1000 -> 1
-dqcot782 comparetotal Inf -1 -> 1
-dqcot783 comparetotal Inf -0 -> 1
-dqcot784 comparetotal Inf 0 -> 1
-dqcot785 comparetotal Inf 1 -> 1
-dqcot786 comparetotal Inf 1000 -> 1
-dqcot787 comparetotal Inf Inf -> 0
-dqcot788 comparetotal -1000 Inf -> -1
-dqcot789 comparetotal -Inf Inf -> -1
-dqcot790 comparetotal -1 Inf -> -1
-dqcot791 comparetotal -0 Inf -> -1
-dqcot792 comparetotal 0 Inf -> -1
-dqcot793 comparetotal 1 Inf -> -1
-dqcot794 comparetotal 1000 Inf -> -1
-dqcot795 comparetotal Inf Inf -> 0
-
-dqcot800 comparetotal -Inf -Inf -> 0
-dqcot801 comparetotal -Inf -1000 -> -1
-dqcot802 comparetotal -Inf -1 -> -1
-dqcot803 comparetotal -Inf -0 -> -1
-dqcot804 comparetotal -Inf 0 -> -1
-dqcot805 comparetotal -Inf 1 -> -1
-dqcot806 comparetotal -Inf 1000 -> -1
-dqcot807 comparetotal -Inf Inf -> -1
-dqcot808 comparetotal -Inf -Inf -> 0
-dqcot809 comparetotal -1000 -Inf -> 1
-dqcot810 comparetotal -1 -Inf -> 1
-dqcot811 comparetotal -0 -Inf -> 1
-dqcot812 comparetotal 0 -Inf -> 1
-dqcot813 comparetotal 1 -Inf -> 1
-dqcot814 comparetotal 1000 -Inf -> 1
-dqcot815 comparetotal Inf -Inf -> 1
-
-dqcot821 comparetotal NaN -Inf -> 1
-dqcot822 comparetotal NaN -1000 -> 1
-dqcot823 comparetotal NaN -1 -> 1
-dqcot824 comparetotal NaN -0 -> 1
-dqcot825 comparetotal NaN 0 -> 1
-dqcot826 comparetotal NaN 1 -> 1
-dqcot827 comparetotal NaN 1000 -> 1
-dqcot828 comparetotal NaN Inf -> 1
-dqcot829 comparetotal NaN NaN -> 0
-dqcot830 comparetotal -Inf NaN -> -1
-dqcot831 comparetotal -1000 NaN -> -1
-dqcot832 comparetotal -1 NaN -> -1
-dqcot833 comparetotal -0 NaN -> -1
-dqcot834 comparetotal 0 NaN -> -1
-dqcot835 comparetotal 1 NaN -> -1
-dqcot836 comparetotal 1000 NaN -> -1
-dqcot837 comparetotal Inf NaN -> -1
-dqcot838 comparetotal -NaN -NaN -> 0
-dqcot839 comparetotal +NaN -NaN -> 1
-dqcot840 comparetotal -NaN +NaN -> -1
-
-dqcot841 comparetotal sNaN -sNaN -> 1
-dqcot842 comparetotal sNaN -NaN -> 1
-dqcot843 comparetotal sNaN -Inf -> 1
-dqcot844 comparetotal sNaN -1000 -> 1
-dqcot845 comparetotal sNaN -1 -> 1
-dqcot846 comparetotal sNaN -0 -> 1
-dqcot847 comparetotal sNaN 0 -> 1
-dqcot848 comparetotal sNaN 1 -> 1
-dqcot849 comparetotal sNaN 1000 -> 1
-dqcot850 comparetotal sNaN NaN -> -1
-dqcot851 comparetotal sNaN sNaN -> 0
-
-dqcot852 comparetotal -sNaN sNaN -> -1
-dqcot853 comparetotal -NaN sNaN -> -1
-dqcot854 comparetotal -Inf sNaN -> -1
-dqcot855 comparetotal -1000 sNaN -> -1
-dqcot856 comparetotal -1 sNaN -> -1
-dqcot857 comparetotal -0 sNaN -> -1
-dqcot858 comparetotal 0 sNaN -> -1
-dqcot859 comparetotal 1 sNaN -> -1
-dqcot860 comparetotal 1000 sNaN -> -1
-dqcot861 comparetotal Inf sNaN -> -1
-dqcot862 comparetotal NaN sNaN -> 1
-dqcot863 comparetotal sNaN sNaN -> 0
-
-dqcot871 comparetotal -sNaN -sNaN -> 0
-dqcot872 comparetotal -sNaN -NaN -> 1
-dqcot873 comparetotal -sNaN -Inf -> -1
-dqcot874 comparetotal -sNaN -1000 -> -1
-dqcot875 comparetotal -sNaN -1 -> -1
-dqcot876 comparetotal -sNaN -0 -> -1
-dqcot877 comparetotal -sNaN 0 -> -1
-dqcot878 comparetotal -sNaN 1 -> -1
-dqcot879 comparetotal -sNaN 1000 -> -1
-dqcot880 comparetotal -sNaN NaN -> -1
-dqcot881 comparetotal -sNaN sNaN -> -1
-
-dqcot882 comparetotal -sNaN -sNaN -> 0
-dqcot883 comparetotal -NaN -sNaN -> -1
-dqcot884 comparetotal -Inf -sNaN -> 1
-dqcot885 comparetotal -1000 -sNaN -> 1
-dqcot886 comparetotal -1 -sNaN -> 1
-dqcot887 comparetotal -0 -sNaN -> 1
-dqcot888 comparetotal 0 -sNaN -> 1
-dqcot889 comparetotal 1 -sNaN -> 1
-dqcot890 comparetotal 1000 -sNaN -> 1
-dqcot891 comparetotal Inf -sNaN -> 1
-dqcot892 comparetotal NaN -sNaN -> 1
-dqcot893 comparetotal sNaN -sNaN -> 1
-
--- NaNs with payload
-dqcot960 comparetotal NaN9 -Inf -> 1
-dqcot961 comparetotal NaN8 999 -> 1
-dqcot962 comparetotal NaN77 Inf -> 1
-dqcot963 comparetotal -NaN67 NaN5 -> -1
-dqcot964 comparetotal -Inf -NaN4 -> 1
-dqcot965 comparetotal -999 -NaN33 -> 1
-dqcot966 comparetotal Inf NaN2 -> -1
-
-dqcot970 comparetotal -NaN41 -NaN42 -> 1
-dqcot971 comparetotal +NaN41 -NaN42 -> 1
-dqcot972 comparetotal -NaN41 +NaN42 -> -1
-dqcot973 comparetotal +NaN41 +NaN42 -> -1
-dqcot974 comparetotal -NaN42 -NaN01 -> -1
-dqcot975 comparetotal +NaN42 -NaN01 -> 1
-dqcot976 comparetotal -NaN42 +NaN01 -> -1
-dqcot977 comparetotal +NaN42 +NaN01 -> 1
-
-dqcot980 comparetotal -sNaN771 -sNaN772 -> 1
-dqcot981 comparetotal +sNaN771 -sNaN772 -> 1
-dqcot982 comparetotal -sNaN771 +sNaN772 -> -1
-dqcot983 comparetotal +sNaN771 +sNaN772 -> -1
-dqcot984 comparetotal -sNaN772 -sNaN771 -> -1
-dqcot985 comparetotal +sNaN772 -sNaN771 -> 1
-dqcot986 comparetotal -sNaN772 +sNaN771 -> -1
-dqcot987 comparetotal +sNaN772 +sNaN771 -> 1
-
-dqcot991 comparetotal -sNaN99 -Inf -> -1
-dqcot992 comparetotal sNaN98 -11 -> 1
-dqcot993 comparetotal sNaN97 NaN -> -1
-dqcot994 comparetotal sNaN16 sNaN94 -> -1
-dqcot995 comparetotal NaN85 sNaN83 -> 1
-dqcot996 comparetotal -Inf sNaN92 -> -1
-dqcot997 comparetotal 088 sNaN81 -> -1
-dqcot998 comparetotal Inf sNaN90 -> -1
-dqcot999 comparetotal NaN -sNaN89 -> 1
-
--- spread zeros
-dqcot1110 comparetotal 0E-6143 0 -> -1
-dqcot1111 comparetotal 0E-6143 -0 -> 1
-dqcot1112 comparetotal -0E-6143 0 -> -1
-dqcot1113 comparetotal -0E-6143 -0 -> 1
-dqcot1114 comparetotal 0E-6143 0E+6144 -> -1
-dqcot1115 comparetotal 0E-6143 -0E+6144 -> 1
-dqcot1116 comparetotal -0E-6143 0E+6144 -> -1
-dqcot1117 comparetotal -0E-6143 -0E+6144 -> 1
-dqcot1118 comparetotal 0 0E+6144 -> -1
-dqcot1119 comparetotal 0 -0E+6144 -> 1
-dqcot1120 comparetotal -0 0E+6144 -> -1
-dqcot1121 comparetotal -0 -0E+6144 -> 1
-
-dqcot1130 comparetotal 0E+6144 0 -> 1
-dqcot1131 comparetotal 0E+6144 -0 -> 1
-dqcot1132 comparetotal -0E+6144 0 -> -1
-dqcot1133 comparetotal -0E+6144 -0 -> -1
-dqcot1134 comparetotal 0E+6144 0E-6143 -> 1
-dqcot1135 comparetotal 0E+6144 -0E-6143 -> 1
-dqcot1136 comparetotal -0E+6144 0E-6143 -> -1
-dqcot1137 comparetotal -0E+6144 -0E-6143 -> -1
-dqcot1138 comparetotal 0 0E-6143 -> 1
-dqcot1139 comparetotal 0 -0E-6143 -> 1
-dqcot1140 comparetotal -0 0E-6143 -> -1
-dqcot1141 comparetotal -0 -0E-6143 -> -1
-
--- Null tests
-dqcot9990 comparetotal 10 # -> NaN Invalid_operation
-dqcot9991 comparetotal # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareTotal.decTest -- decQuad comparison using total ordering --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqcot001 comparetotal -2 -2 -> 0
+dqcot002 comparetotal -2 -1 -> -1
+dqcot003 comparetotal -2 0 -> -1
+dqcot004 comparetotal -2 1 -> -1
+dqcot005 comparetotal -2 2 -> -1
+dqcot006 comparetotal -1 -2 -> 1
+dqcot007 comparetotal -1 -1 -> 0
+dqcot008 comparetotal -1 0 -> -1
+dqcot009 comparetotal -1 1 -> -1
+dqcot010 comparetotal -1 2 -> -1
+dqcot011 comparetotal 0 -2 -> 1
+dqcot012 comparetotal 0 -1 -> 1
+dqcot013 comparetotal 0 0 -> 0
+dqcot014 comparetotal 0 1 -> -1
+dqcot015 comparetotal 0 2 -> -1
+dqcot016 comparetotal 1 -2 -> 1
+dqcot017 comparetotal 1 -1 -> 1
+dqcot018 comparetotal 1 0 -> 1
+dqcot019 comparetotal 1 1 -> 0
+dqcot020 comparetotal 1 2 -> -1
+dqcot021 comparetotal 2 -2 -> 1
+dqcot022 comparetotal 2 -1 -> 1
+dqcot023 comparetotal 2 0 -> 1
+dqcot025 comparetotal 2 1 -> 1
+dqcot026 comparetotal 2 2 -> 0
+
+dqcot031 comparetotal -20 -20 -> 0
+dqcot032 comparetotal -20 -10 -> -1
+dqcot033 comparetotal -20 00 -> -1
+dqcot034 comparetotal -20 10 -> -1
+dqcot035 comparetotal -20 20 -> -1
+dqcot036 comparetotal -10 -20 -> 1
+dqcot037 comparetotal -10 -10 -> 0
+dqcot038 comparetotal -10 00 -> -1
+dqcot039 comparetotal -10 10 -> -1
+dqcot040 comparetotal -10 20 -> -1
+dqcot041 comparetotal 00 -20 -> 1
+dqcot042 comparetotal 00 -10 -> 1
+dqcot043 comparetotal 00 00 -> 0
+dqcot044 comparetotal 00 10 -> -1
+dqcot045 comparetotal 00 20 -> -1
+dqcot046 comparetotal 10 -20 -> 1
+dqcot047 comparetotal 10 -10 -> 1
+dqcot048 comparetotal 10 00 -> 1
+dqcot049 comparetotal 10 10 -> 0
+dqcot050 comparetotal 10 20 -> -1
+dqcot051 comparetotal 20 -20 -> 1
+dqcot052 comparetotal 20 -10 -> 1
+dqcot053 comparetotal 20 00 -> 1
+dqcot055 comparetotal 20 10 -> 1
+dqcot056 comparetotal 20 20 -> 0
+
+dqcot061 comparetotal -2.0 -2.0 -> 0
+dqcot062 comparetotal -2.0 -1.0 -> -1
+dqcot063 comparetotal -2.0 0.0 -> -1
+dqcot064 comparetotal -2.0 1.0 -> -1
+dqcot065 comparetotal -2.0 2.0 -> -1
+dqcot066 comparetotal -1.0 -2.0 -> 1
+dqcot067 comparetotal -1.0 -1.0 -> 0
+dqcot068 comparetotal -1.0 0.0 -> -1
+dqcot069 comparetotal -1.0 1.0 -> -1
+dqcot070 comparetotal -1.0 2.0 -> -1
+dqcot071 comparetotal 0.0 -2.0 -> 1
+dqcot072 comparetotal 0.0 -1.0 -> 1
+dqcot073 comparetotal 0.0 0.0 -> 0
+dqcot074 comparetotal 0.0 1.0 -> -1
+dqcot075 comparetotal 0.0 2.0 -> -1
+dqcot076 comparetotal 1.0 -2.0 -> 1
+dqcot077 comparetotal 1.0 -1.0 -> 1
+dqcot078 comparetotal 1.0 0.0 -> 1
+dqcot079 comparetotal 1.0 1.0 -> 0
+dqcot080 comparetotal 1.0 2.0 -> -1
+dqcot081 comparetotal 2.0 -2.0 -> 1
+dqcot082 comparetotal 2.0 -1.0 -> 1
+dqcot083 comparetotal 2.0 0.0 -> 1
+dqcot085 comparetotal 2.0 1.0 -> 1
+dqcot086 comparetotal 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqcot090 comparetotal 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqcot091 comparetotal -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> -1
+dqcot092 comparetotal 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 1
+dqcot093 comparetotal -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+dqcot100 comparetotal 7.0 7.0 -> 0
+dqcot101 comparetotal 7.0 7 -> -1
+dqcot102 comparetotal 7 7.0 -> 1
+dqcot103 comparetotal 7E+0 7.0 -> 1
+dqcot104 comparetotal 70E-1 7.0 -> 0
+dqcot105 comparetotal 0.7E+1 7 -> 0
+dqcot106 comparetotal 70E-1 7 -> -1
+dqcot107 comparetotal 7.0 7E+0 -> -1
+dqcot108 comparetotal 7.0 70E-1 -> 0
+dqcot109 comparetotal 7 0.7E+1 -> 0
+dqcot110 comparetotal 7 70E-1 -> 1
+
+dqcot120 comparetotal 8.0 7.0 -> 1
+dqcot121 comparetotal 8.0 7 -> 1
+dqcot122 comparetotal 8 7.0 -> 1
+dqcot123 comparetotal 8E+0 7.0 -> 1
+dqcot124 comparetotal 80E-1 7.0 -> 1
+dqcot125 comparetotal 0.8E+1 7 -> 1
+dqcot126 comparetotal 80E-1 7 -> 1
+dqcot127 comparetotal 8.0 7E+0 -> 1
+dqcot128 comparetotal 8.0 70E-1 -> 1
+dqcot129 comparetotal 8 0.7E+1 -> 1
+dqcot130 comparetotal 8 70E-1 -> 1
+
+dqcot140 comparetotal 8.0 9.0 -> -1
+dqcot141 comparetotal 8.0 9 -> -1
+dqcot142 comparetotal 8 9.0 -> -1
+dqcot143 comparetotal 8E+0 9.0 -> -1
+dqcot144 comparetotal 80E-1 9.0 -> -1
+dqcot145 comparetotal 0.8E+1 9 -> -1
+dqcot146 comparetotal 80E-1 9 -> -1
+dqcot147 comparetotal 8.0 9E+0 -> -1
+dqcot148 comparetotal 8.0 90E-1 -> -1
+dqcot149 comparetotal 8 0.9E+1 -> -1
+dqcot150 comparetotal 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqcot200 comparetotal -7.0 7.0 -> -1
+dqcot201 comparetotal -7.0 7 -> -1
+dqcot202 comparetotal -7 7.0 -> -1
+dqcot203 comparetotal -7E+0 7.0 -> -1
+dqcot204 comparetotal -70E-1 7.0 -> -1
+dqcot205 comparetotal -0.7E+1 7 -> -1
+dqcot206 comparetotal -70E-1 7 -> -1
+dqcot207 comparetotal -7.0 7E+0 -> -1
+dqcot208 comparetotal -7.0 70E-1 -> -1
+dqcot209 comparetotal -7 0.7E+1 -> -1
+dqcot210 comparetotal -7 70E-1 -> -1
+
+dqcot220 comparetotal -8.0 7.0 -> -1
+dqcot221 comparetotal -8.0 7 -> -1
+dqcot222 comparetotal -8 7.0 -> -1
+dqcot223 comparetotal -8E+0 7.0 -> -1
+dqcot224 comparetotal -80E-1 7.0 -> -1
+dqcot225 comparetotal -0.8E+1 7 -> -1
+dqcot226 comparetotal -80E-1 7 -> -1
+dqcot227 comparetotal -8.0 7E+0 -> -1
+dqcot228 comparetotal -8.0 70E-1 -> -1
+dqcot229 comparetotal -8 0.7E+1 -> -1
+dqcot230 comparetotal -8 70E-1 -> -1
+
+dqcot240 comparetotal -8.0 9.0 -> -1
+dqcot241 comparetotal -8.0 9 -> -1
+dqcot242 comparetotal -8 9.0 -> -1
+dqcot243 comparetotal -8E+0 9.0 -> -1
+dqcot244 comparetotal -80E-1 9.0 -> -1
+dqcot245 comparetotal -0.8E+1 9 -> -1
+dqcot246 comparetotal -80E-1 9 -> -1
+dqcot247 comparetotal -8.0 9E+0 -> -1
+dqcot248 comparetotal -8.0 90E-1 -> -1
+dqcot249 comparetotal -8 0.9E+1 -> -1
+dqcot250 comparetotal -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqcot300 comparetotal 7.0 -7.0 -> 1
+dqcot301 comparetotal 7.0 -7 -> 1
+dqcot302 comparetotal 7 -7.0 -> 1
+dqcot303 comparetotal 7E+0 -7.0 -> 1
+dqcot304 comparetotal 70E-1 -7.0 -> 1
+dqcot305 comparetotal .7E+1 -7 -> 1
+dqcot306 comparetotal 70E-1 -7 -> 1
+dqcot307 comparetotal 7.0 -7E+0 -> 1
+dqcot308 comparetotal 7.0 -70E-1 -> 1
+dqcot309 comparetotal 7 -.7E+1 -> 1
+dqcot310 comparetotal 7 -70E-1 -> 1
+
+dqcot320 comparetotal 8.0 -7.0 -> 1
+dqcot321 comparetotal 8.0 -7 -> 1
+dqcot322 comparetotal 8 -7.0 -> 1
+dqcot323 comparetotal 8E+0 -7.0 -> 1
+dqcot324 comparetotal 80E-1 -7.0 -> 1
+dqcot325 comparetotal .8E+1 -7 -> 1
+dqcot326 comparetotal 80E-1 -7 -> 1
+dqcot327 comparetotal 8.0 -7E+0 -> 1
+dqcot328 comparetotal 8.0 -70E-1 -> 1
+dqcot329 comparetotal 8 -.7E+1 -> 1
+dqcot330 comparetotal 8 -70E-1 -> 1
+
+dqcot340 comparetotal 8.0 -9.0 -> 1
+dqcot341 comparetotal 8.0 -9 -> 1
+dqcot342 comparetotal 8 -9.0 -> 1
+dqcot343 comparetotal 8E+0 -9.0 -> 1
+dqcot344 comparetotal 80E-1 -9.0 -> 1
+dqcot345 comparetotal .8E+1 -9 -> 1
+dqcot346 comparetotal 80E-1 -9 -> 1
+dqcot347 comparetotal 8.0 -9E+0 -> 1
+dqcot348 comparetotal 8.0 -90E-1 -> 1
+dqcot349 comparetotal 8 -.9E+1 -> 1
+dqcot350 comparetotal 8 -90E-1 -> 1
+
+-- and again, with sign changes -- ..
+dqcot400 comparetotal -7.0 -7.0 -> 0
+dqcot401 comparetotal -7.0 -7 -> 1
+dqcot402 comparetotal -7 -7.0 -> -1
+dqcot403 comparetotal -7E+0 -7.0 -> -1
+dqcot404 comparetotal -70E-1 -7.0 -> 0
+dqcot405 comparetotal -.7E+1 -7 -> 0
+dqcot406 comparetotal -70E-1 -7 -> 1
+dqcot407 comparetotal -7.0 -7E+0 -> 1
+dqcot408 comparetotal -7.0 -70E-1 -> 0
+dqcot409 comparetotal -7 -.7E+1 -> 0
+dqcot410 comparetotal -7 -70E-1 -> -1
+
+dqcot420 comparetotal -8.0 -7.0 -> -1
+dqcot421 comparetotal -8.0 -7 -> -1
+dqcot422 comparetotal -8 -7.0 -> -1
+dqcot423 comparetotal -8E+0 -7.0 -> -1
+dqcot424 comparetotal -80E-1 -7.0 -> -1
+dqcot425 comparetotal -.8E+1 -7 -> -1
+dqcot426 comparetotal -80E-1 -7 -> -1
+dqcot427 comparetotal -8.0 -7E+0 -> -1
+dqcot428 comparetotal -8.0 -70E-1 -> -1
+dqcot429 comparetotal -8 -.7E+1 -> -1
+dqcot430 comparetotal -8 -70E-1 -> -1
+
+dqcot440 comparetotal -8.0 -9.0 -> 1
+dqcot441 comparetotal -8.0 -9 -> 1
+dqcot442 comparetotal -8 -9.0 -> 1
+dqcot443 comparetotal -8E+0 -9.0 -> 1
+dqcot444 comparetotal -80E-1 -9.0 -> 1
+dqcot445 comparetotal -.8E+1 -9 -> 1
+dqcot446 comparetotal -80E-1 -9 -> 1
+dqcot447 comparetotal -8.0 -9E+0 -> 1
+dqcot448 comparetotal -8.0 -90E-1 -> 1
+dqcot449 comparetotal -8 -.9E+1 -> 1
+dqcot450 comparetotal -8 -90E-1 -> 1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqcot473 comparetotal 123.4560000000000E-89 123.456E-89 -> -1
+dqcot474 comparetotal 123.456000000000E+89 123.456E+89 -> -1
+dqcot475 comparetotal 123.45600000000E-89 123.456E-89 -> -1
+dqcot476 comparetotal 123.4560000000E+89 123.456E+89 -> -1
+dqcot477 comparetotal 123.456000000E-89 123.456E-89 -> -1
+dqcot478 comparetotal 123.45600000E+89 123.456E+89 -> -1
+dqcot479 comparetotal 123.4560000E-89 123.456E-89 -> -1
+dqcot480 comparetotal 123.456000E+89 123.456E+89 -> -1
+dqcot481 comparetotal 123.45600E-89 123.456E-89 -> -1
+dqcot482 comparetotal 123.4560E+89 123.456E+89 -> -1
+dqcot483 comparetotal 123.456E-89 123.456E-89 -> 0
+dqcot487 comparetotal 123.456E+89 123.4560000000000E+89 -> 1
+dqcot488 comparetotal 123.456E-89 123.456000000000E-89 -> 1
+dqcot489 comparetotal 123.456E+89 123.45600000000E+89 -> 1
+dqcot490 comparetotal 123.456E-89 123.4560000000E-89 -> 1
+dqcot491 comparetotal 123.456E+89 123.456000000E+89 -> 1
+dqcot492 comparetotal 123.456E-89 123.45600000E-89 -> 1
+dqcot493 comparetotal 123.456E+89 123.4560000E+89 -> 1
+dqcot494 comparetotal 123.456E-89 123.456000E-89 -> 1
+dqcot495 comparetotal 123.456E+89 123.45600E+89 -> 1
+dqcot496 comparetotal 123.456E-89 123.4560E-89 -> 1
+dqcot497 comparetotal 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqcot498 comparetotal 1 1E-17 -> 1
+dqcot499 comparetotal 1 1E-16 -> 1
+dqcot500 comparetotal 1 1E-15 -> 1
+dqcot501 comparetotal 1 1E-14 -> 1
+dqcot502 comparetotal 1 1E-13 -> 1
+dqcot503 comparetotal 1 1E-12 -> 1
+dqcot504 comparetotal 1 1E-11 -> 1
+dqcot505 comparetotal 1 1E-10 -> 1
+dqcot506 comparetotal 1 1E-9 -> 1
+dqcot507 comparetotal 1 1E-8 -> 1
+dqcot508 comparetotal 1 1E-7 -> 1
+dqcot509 comparetotal 1 1E-6 -> 1
+dqcot510 comparetotal 1 1E-5 -> 1
+dqcot511 comparetotal 1 1E-4 -> 1
+dqcot512 comparetotal 1 1E-3 -> 1
+dqcot513 comparetotal 1 1E-2 -> 1
+dqcot514 comparetotal 1 1E-1 -> 1
+dqcot515 comparetotal 1 1E-0 -> 0
+dqcot516 comparetotal 1 1E+1 -> -1
+dqcot517 comparetotal 1 1E+2 -> -1
+dqcot518 comparetotal 1 1E+3 -> -1
+dqcot519 comparetotal 1 1E+4 -> -1
+dqcot521 comparetotal 1 1E+5 -> -1
+dqcot522 comparetotal 1 1E+6 -> -1
+dqcot523 comparetotal 1 1E+7 -> -1
+dqcot524 comparetotal 1 1E+8 -> -1
+dqcot525 comparetotal 1 1E+9 -> -1
+dqcot526 comparetotal 1 1E+10 -> -1
+dqcot527 comparetotal 1 1E+11 -> -1
+dqcot528 comparetotal 1 1E+12 -> -1
+dqcot529 comparetotal 1 1E+13 -> -1
+dqcot530 comparetotal 1 1E+14 -> -1
+dqcot531 comparetotal 1 1E+15 -> -1
+dqcot532 comparetotal 1 1E+16 -> -1
+dqcot533 comparetotal 1 1E+17 -> -1
+-- LR swap
+dqcot538 comparetotal 1E-17 1 -> -1
+dqcot539 comparetotal 1E-16 1 -> -1
+dqcot540 comparetotal 1E-15 1 -> -1
+dqcot541 comparetotal 1E-14 1 -> -1
+dqcot542 comparetotal 1E-13 1 -> -1
+dqcot543 comparetotal 1E-12 1 -> -1
+dqcot544 comparetotal 1E-11 1 -> -1
+dqcot545 comparetotal 1E-10 1 -> -1
+dqcot546 comparetotal 1E-9 1 -> -1
+dqcot547 comparetotal 1E-8 1 -> -1
+dqcot548 comparetotal 1E-7 1 -> -1
+dqcot549 comparetotal 1E-6 1 -> -1
+dqcot550 comparetotal 1E-5 1 -> -1
+dqcot551 comparetotal 1E-4 1 -> -1
+dqcot552 comparetotal 1E-3 1 -> -1
+dqcot553 comparetotal 1E-2 1 -> -1
+dqcot554 comparetotal 1E-1 1 -> -1
+dqcot555 comparetotal 1E-0 1 -> 0
+dqcot556 comparetotal 1E+1 1 -> 1
+dqcot557 comparetotal 1E+2 1 -> 1
+dqcot558 comparetotal 1E+3 1 -> 1
+dqcot559 comparetotal 1E+4 1 -> 1
+dqcot561 comparetotal 1E+5 1 -> 1
+dqcot562 comparetotal 1E+6 1 -> 1
+dqcot563 comparetotal 1E+7 1 -> 1
+dqcot564 comparetotal 1E+8 1 -> 1
+dqcot565 comparetotal 1E+9 1 -> 1
+dqcot566 comparetotal 1E+10 1 -> 1
+dqcot567 comparetotal 1E+11 1 -> 1
+dqcot568 comparetotal 1E+12 1 -> 1
+dqcot569 comparetotal 1E+13 1 -> 1
+dqcot570 comparetotal 1E+14 1 -> 1
+dqcot571 comparetotal 1E+15 1 -> 1
+dqcot572 comparetotal 1E+16 1 -> 1
+dqcot573 comparetotal 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+dqcot578 comparetotal 0.000000987654321 1E-17 -> 1
+dqcot579 comparetotal 0.000000987654321 1E-16 -> 1
+dqcot580 comparetotal 0.000000987654321 1E-15 -> 1
+dqcot581 comparetotal 0.000000987654321 1E-14 -> 1
+dqcot582 comparetotal 0.000000987654321 1E-13 -> 1
+dqcot583 comparetotal 0.000000987654321 1E-12 -> 1
+dqcot584 comparetotal 0.000000987654321 1E-11 -> 1
+dqcot585 comparetotal 0.000000987654321 1E-10 -> 1
+dqcot586 comparetotal 0.000000987654321 1E-9 -> 1
+dqcot587 comparetotal 0.000000987654321 1E-8 -> 1
+dqcot588 comparetotal 0.000000987654321 1E-7 -> 1
+dqcot589 comparetotal 0.000000987654321 1E-6 -> -1
+dqcot590 comparetotal 0.000000987654321 1E-5 -> -1
+dqcot591 comparetotal 0.000000987654321 1E-4 -> -1
+dqcot592 comparetotal 0.000000987654321 1E-3 -> -1
+dqcot593 comparetotal 0.000000987654321 1E-2 -> -1
+dqcot594 comparetotal 0.000000987654321 1E-1 -> -1
+dqcot595 comparetotal 0.000000987654321 1E-0 -> -1
+dqcot596 comparetotal 0.000000987654321 1E+1 -> -1
+dqcot597 comparetotal 0.000000987654321 1E+2 -> -1
+dqcot598 comparetotal 0.000000987654321 1E+3 -> -1
+dqcot599 comparetotal 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqcot600 comparetotal 12 12.2345 -> -1
+dqcot601 comparetotal 12.0 12.2345 -> -1
+dqcot602 comparetotal 12.00 12.2345 -> -1
+dqcot603 comparetotal 12.000 12.2345 -> -1
+dqcot604 comparetotal 12.0000 12.2345 -> -1
+dqcot605 comparetotal 12.00000 12.2345 -> -1
+dqcot606 comparetotal 12.000000 12.2345 -> -1
+dqcot607 comparetotal 12.0000000 12.2345 -> -1
+dqcot608 comparetotal 12.00000000 12.2345 -> -1
+dqcot609 comparetotal 12.000000000 12.2345 -> -1
+dqcot610 comparetotal 12.1234 12 -> 1
+dqcot611 comparetotal 12.1234 12.0 -> 1
+dqcot612 comparetotal 12.1234 12.00 -> 1
+dqcot613 comparetotal 12.1234 12.000 -> 1
+dqcot614 comparetotal 12.1234 12.0000 -> 1
+dqcot615 comparetotal 12.1234 12.00000 -> 1
+dqcot616 comparetotal 12.1234 12.000000 -> 1
+dqcot617 comparetotal 12.1234 12.0000000 -> 1
+dqcot618 comparetotal 12.1234 12.00000000 -> 1
+dqcot619 comparetotal 12.1234 12.000000000 -> 1
+dqcot620 comparetotal -12 -12.2345 -> 1
+dqcot621 comparetotal -12.0 -12.2345 -> 1
+dqcot622 comparetotal -12.00 -12.2345 -> 1
+dqcot623 comparetotal -12.000 -12.2345 -> 1
+dqcot624 comparetotal -12.0000 -12.2345 -> 1
+dqcot625 comparetotal -12.00000 -12.2345 -> 1
+dqcot626 comparetotal -12.000000 -12.2345 -> 1
+dqcot627 comparetotal -12.0000000 -12.2345 -> 1
+dqcot628 comparetotal -12.00000000 -12.2345 -> 1
+dqcot629 comparetotal -12.000000000 -12.2345 -> 1
+dqcot630 comparetotal -12.1234 -12 -> -1
+dqcot631 comparetotal -12.1234 -12.0 -> -1
+dqcot632 comparetotal -12.1234 -12.00 -> -1
+dqcot633 comparetotal -12.1234 -12.000 -> -1
+dqcot634 comparetotal -12.1234 -12.0000 -> -1
+dqcot635 comparetotal -12.1234 -12.00000 -> -1
+dqcot636 comparetotal -12.1234 -12.000000 -> -1
+dqcot637 comparetotal -12.1234 -12.0000000 -> -1
+dqcot638 comparetotal -12.1234 -12.00000000 -> -1
+dqcot639 comparetotal -12.1234 -12.000000000 -> -1
+
+-- extended zeros
+dqcot640 comparetotal 0 0 -> 0
+dqcot641 comparetotal 0 -0 -> 1
+dqcot642 comparetotal 0 -0.0 -> 1
+dqcot643 comparetotal 0 0.0 -> 1
+dqcot644 comparetotal -0 0 -> -1
+dqcot645 comparetotal -0 -0 -> 0
+dqcot646 comparetotal -0 -0.0 -> -1
+dqcot647 comparetotal -0 0.0 -> -1
+dqcot648 comparetotal 0.0 0 -> -1
+dqcot649 comparetotal 0.0 -0 -> 1
+dqcot650 comparetotal 0.0 -0.0 -> 1
+dqcot651 comparetotal 0.0 0.0 -> 0
+dqcot652 comparetotal -0.0 0 -> -1
+dqcot653 comparetotal -0.0 -0 -> 1
+dqcot654 comparetotal -0.0 -0.0 -> 0
+dqcot655 comparetotal -0.0 0.0 -> -1
+
+dqcot656 comparetotal -0E1 0.0 -> -1
+dqcot657 comparetotal -0E2 0.0 -> -1
+dqcot658 comparetotal 0E1 0.0 -> 1
+dqcot659 comparetotal 0E2 0.0 -> 1
+dqcot660 comparetotal -0E1 0 -> -1
+dqcot661 comparetotal -0E2 0 -> -1
+dqcot662 comparetotal 0E1 0 -> 1
+dqcot663 comparetotal 0E2 0 -> 1
+dqcot664 comparetotal -0E1 -0E1 -> 0
+dqcot665 comparetotal -0E2 -0E1 -> -1
+dqcot666 comparetotal 0E1 -0E1 -> 1
+dqcot667 comparetotal 0E2 -0E1 -> 1
+dqcot668 comparetotal -0E1 -0E2 -> 1
+dqcot669 comparetotal -0E2 -0E2 -> 0
+dqcot670 comparetotal 0E1 -0E2 -> 1
+dqcot671 comparetotal 0E2 -0E2 -> 1
+dqcot672 comparetotal -0E1 0E1 -> -1
+dqcot673 comparetotal -0E2 0E1 -> -1
+dqcot674 comparetotal 0E1 0E1 -> 0
+dqcot675 comparetotal 0E2 0E1 -> 1
+dqcot676 comparetotal -0E1 0E2 -> -1
+dqcot677 comparetotal -0E2 0E2 -> -1
+dqcot678 comparetotal 0E1 0E2 -> -1
+dqcot679 comparetotal 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqcot680 comparetotal 12 12 -> 0
+dqcot681 comparetotal 12 12.0 -> 1
+dqcot682 comparetotal 12 12.00 -> 1
+dqcot683 comparetotal 12 12.000 -> 1
+dqcot684 comparetotal 12 12.0000 -> 1
+dqcot685 comparetotal 12 12.00000 -> 1
+dqcot686 comparetotal 12 12.000000 -> 1
+dqcot687 comparetotal 12 12.0000000 -> 1
+dqcot688 comparetotal 12 12.00000000 -> 1
+dqcot689 comparetotal 12 12.000000000 -> 1
+dqcot690 comparetotal 12 12 -> 0
+dqcot691 comparetotal 12.0 12 -> -1
+dqcot692 comparetotal 12.00 12 -> -1
+dqcot693 comparetotal 12.000 12 -> -1
+dqcot694 comparetotal 12.0000 12 -> -1
+dqcot695 comparetotal 12.00000 12 -> -1
+dqcot696 comparetotal 12.000000 12 -> -1
+dqcot697 comparetotal 12.0000000 12 -> -1
+dqcot698 comparetotal 12.00000000 12 -> -1
+dqcot699 comparetotal 12.000000000 12 -> -1
+
+-- old long operand checks
+dqcot701 comparetotal 12345678000 1 -> 1
+dqcot702 comparetotal 1 12345678000 -> -1
+dqcot703 comparetotal 1234567800 1 -> 1
+dqcot704 comparetotal 1 1234567800 -> -1
+dqcot705 comparetotal 1234567890 1 -> 1
+dqcot706 comparetotal 1 1234567890 -> -1
+dqcot707 comparetotal 1234567891 1 -> 1
+dqcot708 comparetotal 1 1234567891 -> -1
+dqcot709 comparetotal 12345678901 1 -> 1
+dqcot710 comparetotal 1 12345678901 -> -1
+dqcot711 comparetotal 1234567896 1 -> 1
+dqcot712 comparetotal 1 1234567896 -> -1
+dqcot713 comparetotal -1234567891 1 -> -1
+dqcot714 comparetotal 1 -1234567891 -> 1
+dqcot715 comparetotal -12345678901 1 -> -1
+dqcot716 comparetotal 1 -12345678901 -> 1
+dqcot717 comparetotal -1234567896 1 -> -1
+dqcot718 comparetotal 1 -1234567896 -> 1
+
+-- old residue cases
+dqcot740 comparetotal 1 0.9999999 -> 1
+dqcot741 comparetotal 1 0.999999 -> 1
+dqcot742 comparetotal 1 0.99999 -> 1
+dqcot743 comparetotal 1 1.0000 -> 1
+dqcot744 comparetotal 1 1.00001 -> -1
+dqcot745 comparetotal 1 1.000001 -> -1
+dqcot746 comparetotal 1 1.0000001 -> -1
+dqcot750 comparetotal 0.9999999 1 -> -1
+dqcot751 comparetotal 0.999999 1 -> -1
+dqcot752 comparetotal 0.99999 1 -> -1
+dqcot753 comparetotal 1.0000 1 -> -1
+dqcot754 comparetotal 1.00001 1 -> 1
+dqcot755 comparetotal 1.000001 1 -> 1
+dqcot756 comparetotal 1.0000001 1 -> 1
+
+-- Specials
+dqcot780 comparetotal Inf -Inf -> 1
+dqcot781 comparetotal Inf -1000 -> 1
+dqcot782 comparetotal Inf -1 -> 1
+dqcot783 comparetotal Inf -0 -> 1
+dqcot784 comparetotal Inf 0 -> 1
+dqcot785 comparetotal Inf 1 -> 1
+dqcot786 comparetotal Inf 1000 -> 1
+dqcot787 comparetotal Inf Inf -> 0
+dqcot788 comparetotal -1000 Inf -> -1
+dqcot789 comparetotal -Inf Inf -> -1
+dqcot790 comparetotal -1 Inf -> -1
+dqcot791 comparetotal -0 Inf -> -1
+dqcot792 comparetotal 0 Inf -> -1
+dqcot793 comparetotal 1 Inf -> -1
+dqcot794 comparetotal 1000 Inf -> -1
+dqcot795 comparetotal Inf Inf -> 0
+
+dqcot800 comparetotal -Inf -Inf -> 0
+dqcot801 comparetotal -Inf -1000 -> -1
+dqcot802 comparetotal -Inf -1 -> -1
+dqcot803 comparetotal -Inf -0 -> -1
+dqcot804 comparetotal -Inf 0 -> -1
+dqcot805 comparetotal -Inf 1 -> -1
+dqcot806 comparetotal -Inf 1000 -> -1
+dqcot807 comparetotal -Inf Inf -> -1
+dqcot808 comparetotal -Inf -Inf -> 0
+dqcot809 comparetotal -1000 -Inf -> 1
+dqcot810 comparetotal -1 -Inf -> 1
+dqcot811 comparetotal -0 -Inf -> 1
+dqcot812 comparetotal 0 -Inf -> 1
+dqcot813 comparetotal 1 -Inf -> 1
+dqcot814 comparetotal 1000 -Inf -> 1
+dqcot815 comparetotal Inf -Inf -> 1
+
+dqcot821 comparetotal NaN -Inf -> 1
+dqcot822 comparetotal NaN -1000 -> 1
+dqcot823 comparetotal NaN -1 -> 1
+dqcot824 comparetotal NaN -0 -> 1
+dqcot825 comparetotal NaN 0 -> 1
+dqcot826 comparetotal NaN 1 -> 1
+dqcot827 comparetotal NaN 1000 -> 1
+dqcot828 comparetotal NaN Inf -> 1
+dqcot829 comparetotal NaN NaN -> 0
+dqcot830 comparetotal -Inf NaN -> -1
+dqcot831 comparetotal -1000 NaN -> -1
+dqcot832 comparetotal -1 NaN -> -1
+dqcot833 comparetotal -0 NaN -> -1
+dqcot834 comparetotal 0 NaN -> -1
+dqcot835 comparetotal 1 NaN -> -1
+dqcot836 comparetotal 1000 NaN -> -1
+dqcot837 comparetotal Inf NaN -> -1
+dqcot838 comparetotal -NaN -NaN -> 0
+dqcot839 comparetotal +NaN -NaN -> 1
+dqcot840 comparetotal -NaN +NaN -> -1
+
+dqcot841 comparetotal sNaN -sNaN -> 1
+dqcot842 comparetotal sNaN -NaN -> 1
+dqcot843 comparetotal sNaN -Inf -> 1
+dqcot844 comparetotal sNaN -1000 -> 1
+dqcot845 comparetotal sNaN -1 -> 1
+dqcot846 comparetotal sNaN -0 -> 1
+dqcot847 comparetotal sNaN 0 -> 1
+dqcot848 comparetotal sNaN 1 -> 1
+dqcot849 comparetotal sNaN 1000 -> 1
+dqcot850 comparetotal sNaN NaN -> -1
+dqcot851 comparetotal sNaN sNaN -> 0
+
+dqcot852 comparetotal -sNaN sNaN -> -1
+dqcot853 comparetotal -NaN sNaN -> -1
+dqcot854 comparetotal -Inf sNaN -> -1
+dqcot855 comparetotal -1000 sNaN -> -1
+dqcot856 comparetotal -1 sNaN -> -1
+dqcot857 comparetotal -0 sNaN -> -1
+dqcot858 comparetotal 0 sNaN -> -1
+dqcot859 comparetotal 1 sNaN -> -1
+dqcot860 comparetotal 1000 sNaN -> -1
+dqcot861 comparetotal Inf sNaN -> -1
+dqcot862 comparetotal NaN sNaN -> 1
+dqcot863 comparetotal sNaN sNaN -> 0
+
+dqcot871 comparetotal -sNaN -sNaN -> 0
+dqcot872 comparetotal -sNaN -NaN -> 1
+dqcot873 comparetotal -sNaN -Inf -> -1
+dqcot874 comparetotal -sNaN -1000 -> -1
+dqcot875 comparetotal -sNaN -1 -> -1
+dqcot876 comparetotal -sNaN -0 -> -1
+dqcot877 comparetotal -sNaN 0 -> -1
+dqcot878 comparetotal -sNaN 1 -> -1
+dqcot879 comparetotal -sNaN 1000 -> -1
+dqcot880 comparetotal -sNaN NaN -> -1
+dqcot881 comparetotal -sNaN sNaN -> -1
+
+dqcot882 comparetotal -sNaN -sNaN -> 0
+dqcot883 comparetotal -NaN -sNaN -> -1
+dqcot884 comparetotal -Inf -sNaN -> 1
+dqcot885 comparetotal -1000 -sNaN -> 1
+dqcot886 comparetotal -1 -sNaN -> 1
+dqcot887 comparetotal -0 -sNaN -> 1
+dqcot888 comparetotal 0 -sNaN -> 1
+dqcot889 comparetotal 1 -sNaN -> 1
+dqcot890 comparetotal 1000 -sNaN -> 1
+dqcot891 comparetotal Inf -sNaN -> 1
+dqcot892 comparetotal NaN -sNaN -> 1
+dqcot893 comparetotal sNaN -sNaN -> 1
+
+-- NaNs with payload
+dqcot960 comparetotal NaN9 -Inf -> 1
+dqcot961 comparetotal NaN8 999 -> 1
+dqcot962 comparetotal NaN77 Inf -> 1
+dqcot963 comparetotal -NaN67 NaN5 -> -1
+dqcot964 comparetotal -Inf -NaN4 -> 1
+dqcot965 comparetotal -999 -NaN33 -> 1
+dqcot966 comparetotal Inf NaN2 -> -1
+
+dqcot970 comparetotal -NaN41 -NaN42 -> 1
+dqcot971 comparetotal +NaN41 -NaN42 -> 1
+dqcot972 comparetotal -NaN41 +NaN42 -> -1
+dqcot973 comparetotal +NaN41 +NaN42 -> -1
+dqcot974 comparetotal -NaN42 -NaN01 -> -1
+dqcot975 comparetotal +NaN42 -NaN01 -> 1
+dqcot976 comparetotal -NaN42 +NaN01 -> -1
+dqcot977 comparetotal +NaN42 +NaN01 -> 1
+
+dqcot980 comparetotal -sNaN771 -sNaN772 -> 1
+dqcot981 comparetotal +sNaN771 -sNaN772 -> 1
+dqcot982 comparetotal -sNaN771 +sNaN772 -> -1
+dqcot983 comparetotal +sNaN771 +sNaN772 -> -1
+dqcot984 comparetotal -sNaN772 -sNaN771 -> -1
+dqcot985 comparetotal +sNaN772 -sNaN771 -> 1
+dqcot986 comparetotal -sNaN772 +sNaN771 -> -1
+dqcot987 comparetotal +sNaN772 +sNaN771 -> 1
+
+dqcot991 comparetotal -sNaN99 -Inf -> -1
+dqcot992 comparetotal sNaN98 -11 -> 1
+dqcot993 comparetotal sNaN97 NaN -> -1
+dqcot994 comparetotal sNaN16 sNaN94 -> -1
+dqcot995 comparetotal NaN85 sNaN83 -> 1
+dqcot996 comparetotal -Inf sNaN92 -> -1
+dqcot997 comparetotal 088 sNaN81 -> -1
+dqcot998 comparetotal Inf sNaN90 -> -1
+dqcot999 comparetotal NaN -sNaN89 -> 1
+
+-- spread zeros
+dqcot1110 comparetotal 0E-6143 0 -> -1
+dqcot1111 comparetotal 0E-6143 -0 -> 1
+dqcot1112 comparetotal -0E-6143 0 -> -1
+dqcot1113 comparetotal -0E-6143 -0 -> 1
+dqcot1114 comparetotal 0E-6143 0E+6144 -> -1
+dqcot1115 comparetotal 0E-6143 -0E+6144 -> 1
+dqcot1116 comparetotal -0E-6143 0E+6144 -> -1
+dqcot1117 comparetotal -0E-6143 -0E+6144 -> 1
+dqcot1118 comparetotal 0 0E+6144 -> -1
+dqcot1119 comparetotal 0 -0E+6144 -> 1
+dqcot1120 comparetotal -0 0E+6144 -> -1
+dqcot1121 comparetotal -0 -0E+6144 -> 1
+
+dqcot1130 comparetotal 0E+6144 0 -> 1
+dqcot1131 comparetotal 0E+6144 -0 -> 1
+dqcot1132 comparetotal -0E+6144 0 -> -1
+dqcot1133 comparetotal -0E+6144 -0 -> -1
+dqcot1134 comparetotal 0E+6144 0E-6143 -> 1
+dqcot1135 comparetotal 0E+6144 -0E-6143 -> 1
+dqcot1136 comparetotal -0E+6144 0E-6143 -> -1
+dqcot1137 comparetotal -0E+6144 -0E-6143 -> -1
+dqcot1138 comparetotal 0 0E-6143 -> 1
+dqcot1139 comparetotal 0 -0E-6143 -> 1
+dqcot1140 comparetotal -0 0E-6143 -> -1
+dqcot1141 comparetotal -0 -0E-6143 -> -1
+
+-- Null tests
+dqcot9990 comparetotal 10 # -> NaN Invalid_operation
+dqcot9991 comparetotal # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCompareTotalMag.decTest b/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
index 0b81bfbc242..48b3e086b1b 100644
--- a/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
+++ b/Lib/test/decimaltestdata/dqCompareTotalMag.decTest
@@ -1,706 +1,706 @@
-------------------------------------------------------------------------
--- dqCompareTotalMag.decTest -- decQuad comparison; abs. total order --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Note that we cannot assume add/subtract tests cover paths adequately,
--- here, because the code might be quite different (comparison cannot
--- overflow or underflow, so actual subtractions are not necessary).
--- Similarly, comparetotal will have some radically different paths
--- than compare.
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqctm001 comparetotmag -2 -2 -> 0
-dqctm002 comparetotmag -2 -1 -> 1
-dqctm003 comparetotmag -2 0 -> 1
-dqctm004 comparetotmag -2 1 -> 1
-dqctm005 comparetotmag -2 2 -> 0
-dqctm006 comparetotmag -1 -2 -> -1
-dqctm007 comparetotmag -1 -1 -> 0
-dqctm008 comparetotmag -1 0 -> 1
-dqctm009 comparetotmag -1 1 -> 0
-dqctm010 comparetotmag -1 2 -> -1
-dqctm011 comparetotmag 0 -2 -> -1
-dqctm012 comparetotmag 0 -1 -> -1
-dqctm013 comparetotmag 0 0 -> 0
-dqctm014 comparetotmag 0 1 -> -1
-dqctm015 comparetotmag 0 2 -> -1
-dqctm016 comparetotmag 1 -2 -> -1
-dqctm017 comparetotmag 1 -1 -> 0
-dqctm018 comparetotmag 1 0 -> 1
-dqctm019 comparetotmag 1 1 -> 0
-dqctm020 comparetotmag 1 2 -> -1
-dqctm021 comparetotmag 2 -2 -> 0
-dqctm022 comparetotmag 2 -1 -> 1
-dqctm023 comparetotmag 2 0 -> 1
-dqctm025 comparetotmag 2 1 -> 1
-dqctm026 comparetotmag 2 2 -> 0
-
-dqctm031 comparetotmag -20 -20 -> 0
-dqctm032 comparetotmag -20 -10 -> 1
-dqctm033 comparetotmag -20 00 -> 1
-dqctm034 comparetotmag -20 10 -> 1
-dqctm035 comparetotmag -20 20 -> 0
-dqctm036 comparetotmag -10 -20 -> -1
-dqctm037 comparetotmag -10 -10 -> 0
-dqctm038 comparetotmag -10 00 -> 1
-dqctm039 comparetotmag -10 10 -> 0
-dqctm040 comparetotmag -10 20 -> -1
-dqctm041 comparetotmag 00 -20 -> -1
-dqctm042 comparetotmag 00 -10 -> -1
-dqctm043 comparetotmag 00 00 -> 0
-dqctm044 comparetotmag 00 10 -> -1
-dqctm045 comparetotmag 00 20 -> -1
-dqctm046 comparetotmag 10 -20 -> -1
-dqctm047 comparetotmag 10 -10 -> 0
-dqctm048 comparetotmag 10 00 -> 1
-dqctm049 comparetotmag 10 10 -> 0
-dqctm050 comparetotmag 10 20 -> -1
-dqctm051 comparetotmag 20 -20 -> 0
-dqctm052 comparetotmag 20 -10 -> 1
-dqctm053 comparetotmag 20 00 -> 1
-dqctm055 comparetotmag 20 10 -> 1
-dqctm056 comparetotmag 20 20 -> 0
-
-dqctm061 comparetotmag -2.0 -2.0 -> 0
-dqctm062 comparetotmag -2.0 -1.0 -> 1
-dqctm063 comparetotmag -2.0 0.0 -> 1
-dqctm064 comparetotmag -2.0 1.0 -> 1
-dqctm065 comparetotmag -2.0 2.0 -> 0
-dqctm066 comparetotmag -1.0 -2.0 -> -1
-dqctm067 comparetotmag -1.0 -1.0 -> 0
-dqctm068 comparetotmag -1.0 0.0 -> 1
-dqctm069 comparetotmag -1.0 1.0 -> 0
-dqctm070 comparetotmag -1.0 2.0 -> -1
-dqctm071 comparetotmag 0.0 -2.0 -> -1
-dqctm072 comparetotmag 0.0 -1.0 -> -1
-dqctm073 comparetotmag 0.0 0.0 -> 0
-dqctm074 comparetotmag 0.0 1.0 -> -1
-dqctm075 comparetotmag 0.0 2.0 -> -1
-dqctm076 comparetotmag 1.0 -2.0 -> -1
-dqctm077 comparetotmag 1.0 -1.0 -> 0
-dqctm078 comparetotmag 1.0 0.0 -> 1
-dqctm079 comparetotmag 1.0 1.0 -> 0
-dqctm080 comparetotmag 1.0 2.0 -> -1
-dqctm081 comparetotmag 2.0 -2.0 -> 0
-dqctm082 comparetotmag 2.0 -1.0 -> 1
-dqctm083 comparetotmag 2.0 0.0 -> 1
-dqctm085 comparetotmag 2.0 1.0 -> 1
-dqctm086 comparetotmag 2.0 2.0 -> 0
-
--- now some cases which might overflow if subtract were used
-dqctm090 comparetotmag 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqctm091 comparetotmag -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
-dqctm092 comparetotmag 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-dqctm093 comparetotmag -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
-
--- some differing length/exponent cases
--- in this first group, compare would compare all equal
-dqctm100 comparetotmag 7.0 7.0 -> 0
-dqctm101 comparetotmag 7.0 7 -> -1
-dqctm102 comparetotmag 7 7.0 -> 1
-dqctm103 comparetotmag 7E+0 7.0 -> 1
-dqctm104 comparetotmag 70E-1 7.0 -> 0
-dqctm105 comparetotmag 0.7E+1 7 -> 0
-dqctm106 comparetotmag 70E-1 7 -> -1
-dqctm107 comparetotmag 7.0 7E+0 -> -1
-dqctm108 comparetotmag 7.0 70E-1 -> 0
-dqctm109 comparetotmag 7 0.7E+1 -> 0
-dqctm110 comparetotmag 7 70E-1 -> 1
-
-dqctm120 comparetotmag 8.0 7.0 -> 1
-dqctm121 comparetotmag 8.0 7 -> 1
-dqctm122 comparetotmag 8 7.0 -> 1
-dqctm123 comparetotmag 8E+0 7.0 -> 1
-dqctm124 comparetotmag 80E-1 7.0 -> 1
-dqctm125 comparetotmag 0.8E+1 7 -> 1
-dqctm126 comparetotmag 80E-1 7 -> 1
-dqctm127 comparetotmag 8.0 7E+0 -> 1
-dqctm128 comparetotmag 8.0 70E-1 -> 1
-dqctm129 comparetotmag 8 0.7E+1 -> 1
-dqctm130 comparetotmag 8 70E-1 -> 1
-
-dqctm140 comparetotmag 8.0 9.0 -> -1
-dqctm141 comparetotmag 8.0 9 -> -1
-dqctm142 comparetotmag 8 9.0 -> -1
-dqctm143 comparetotmag 8E+0 9.0 -> -1
-dqctm144 comparetotmag 80E-1 9.0 -> -1
-dqctm145 comparetotmag 0.8E+1 9 -> -1
-dqctm146 comparetotmag 80E-1 9 -> -1
-dqctm147 comparetotmag 8.0 9E+0 -> -1
-dqctm148 comparetotmag 8.0 90E-1 -> -1
-dqctm149 comparetotmag 8 0.9E+1 -> -1
-dqctm150 comparetotmag 8 90E-1 -> -1
-
--- and again, with sign changes -+ ..
-dqctm200 comparetotmag -7.0 7.0 -> 0
-dqctm201 comparetotmag -7.0 7 -> -1
-dqctm202 comparetotmag -7 7.0 -> 1
-dqctm203 comparetotmag -7E+0 7.0 -> 1
-dqctm204 comparetotmag -70E-1 7.0 -> 0
-dqctm205 comparetotmag -0.7E+1 7 -> 0
-dqctm206 comparetotmag -70E-1 7 -> -1
-dqctm207 comparetotmag -7.0 7E+0 -> -1
-dqctm208 comparetotmag -7.0 70E-1 -> 0
-dqctm209 comparetotmag -7 0.7E+1 -> 0
-dqctm210 comparetotmag -7 70E-1 -> 1
-
-dqctm220 comparetotmag -8.0 7.0 -> 1
-dqctm221 comparetotmag -8.0 7 -> 1
-dqctm222 comparetotmag -8 7.0 -> 1
-dqctm223 comparetotmag -8E+0 7.0 -> 1
-dqctm224 comparetotmag -80E-1 7.0 -> 1
-dqctm225 comparetotmag -0.8E+1 7 -> 1
-dqctm226 comparetotmag -80E-1 7 -> 1
-dqctm227 comparetotmag -8.0 7E+0 -> 1
-dqctm228 comparetotmag -8.0 70E-1 -> 1
-dqctm229 comparetotmag -8 0.7E+1 -> 1
-dqctm230 comparetotmag -8 70E-1 -> 1
-
-dqctm240 comparetotmag -8.0 9.0 -> -1
-dqctm241 comparetotmag -8.0 9 -> -1
-dqctm242 comparetotmag -8 9.0 -> -1
-dqctm243 comparetotmag -8E+0 9.0 -> -1
-dqctm244 comparetotmag -80E-1 9.0 -> -1
-dqctm245 comparetotmag -0.8E+1 9 -> -1
-dqctm246 comparetotmag -80E-1 9 -> -1
-dqctm247 comparetotmag -8.0 9E+0 -> -1
-dqctm248 comparetotmag -8.0 90E-1 -> -1
-dqctm249 comparetotmag -8 0.9E+1 -> -1
-dqctm250 comparetotmag -8 90E-1 -> -1
-
--- and again, with sign changes +- ..
-dqctm300 comparetotmag 7.0 -7.0 -> 0
-dqctm301 comparetotmag 7.0 -7 -> -1
-dqctm302 comparetotmag 7 -7.0 -> 1
-dqctm303 comparetotmag 7E+0 -7.0 -> 1
-dqctm304 comparetotmag 70E-1 -7.0 -> 0
-dqctm305 comparetotmag .7E+1 -7 -> 0
-dqctm306 comparetotmag 70E-1 -7 -> -1
-dqctm307 comparetotmag 7.0 -7E+0 -> -1
-dqctm308 comparetotmag 7.0 -70E-1 -> 0
-dqctm309 comparetotmag 7 -.7E+1 -> 0
-dqctm310 comparetotmag 7 -70E-1 -> 1
-
-dqctm320 comparetotmag 8.0 -7.0 -> 1
-dqctm321 comparetotmag 8.0 -7 -> 1
-dqctm322 comparetotmag 8 -7.0 -> 1
-dqctm323 comparetotmag 8E+0 -7.0 -> 1
-dqctm324 comparetotmag 80E-1 -7.0 -> 1
-dqctm325 comparetotmag .8E+1 -7 -> 1
-dqctm326 comparetotmag 80E-1 -7 -> 1
-dqctm327 comparetotmag 8.0 -7E+0 -> 1
-dqctm328 comparetotmag 8.0 -70E-1 -> 1
-dqctm329 comparetotmag 8 -.7E+1 -> 1
-dqctm330 comparetotmag 8 -70E-1 -> 1
-
-dqctm340 comparetotmag 8.0 -9.0 -> -1
-dqctm341 comparetotmag 8.0 -9 -> -1
-dqctm342 comparetotmag 8 -9.0 -> -1
-dqctm343 comparetotmag 8E+0 -9.0 -> -1
-dqctm344 comparetotmag 80E-1 -9.0 -> -1
-dqctm345 comparetotmag .8E+1 -9 -> -1
-dqctm346 comparetotmag 80E-1 -9 -> -1
-dqctm347 comparetotmag 8.0 -9E+0 -> -1
-dqctm348 comparetotmag 8.0 -90E-1 -> -1
-dqctm349 comparetotmag 8 -.9E+1 -> -1
-dqctm350 comparetotmag 8 -90E-1 -> -1
-
--- and again, with sign changes -- ..
-dqctm400 comparetotmag -7.0 -7.0 -> 0
-dqctm401 comparetotmag -7.0 -7 -> -1
-dqctm402 comparetotmag -7 -7.0 -> 1
-dqctm403 comparetotmag -7E+0 -7.0 -> 1
-dqctm404 comparetotmag -70E-1 -7.0 -> 0
-dqctm405 comparetotmag -.7E+1 -7 -> 0
-dqctm406 comparetotmag -70E-1 -7 -> -1
-dqctm407 comparetotmag -7.0 -7E+0 -> -1
-dqctm408 comparetotmag -7.0 -70E-1 -> 0
-dqctm409 comparetotmag -7 -.7E+1 -> 0
-dqctm410 comparetotmag -7 -70E-1 -> 1
-
-dqctm420 comparetotmag -8.0 -7.0 -> 1
-dqctm421 comparetotmag -8.0 -7 -> 1
-dqctm422 comparetotmag -8 -7.0 -> 1
-dqctm423 comparetotmag -8E+0 -7.0 -> 1
-dqctm424 comparetotmag -80E-1 -7.0 -> 1
-dqctm425 comparetotmag -.8E+1 -7 -> 1
-dqctm426 comparetotmag -80E-1 -7 -> 1
-dqctm427 comparetotmag -8.0 -7E+0 -> 1
-dqctm428 comparetotmag -8.0 -70E-1 -> 1
-dqctm429 comparetotmag -8 -.7E+1 -> 1
-dqctm430 comparetotmag -8 -70E-1 -> 1
-
-dqctm440 comparetotmag -8.0 -9.0 -> -1
-dqctm441 comparetotmag -8.0 -9 -> -1
-dqctm442 comparetotmag -8 -9.0 -> -1
-dqctm443 comparetotmag -8E+0 -9.0 -> -1
-dqctm444 comparetotmag -80E-1 -9.0 -> -1
-dqctm445 comparetotmag -.8E+1 -9 -> -1
-dqctm446 comparetotmag -80E-1 -9 -> -1
-dqctm447 comparetotmag -8.0 -9E+0 -> -1
-dqctm448 comparetotmag -8.0 -90E-1 -> -1
-dqctm449 comparetotmag -8 -.9E+1 -> -1
-dqctm450 comparetotmag -8 -90E-1 -> -1
-
-
--- testcases that subtract to lots of zeros at boundaries [pgr]
-dqctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
-dqctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
-dqctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
-dqctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
-dqctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
-dqctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
-dqctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
-dqctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
-dqctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
-dqctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
-dqctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
-dqctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
-dqctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
-dqctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
-dqctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
-dqctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
-dqctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
-dqctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
-dqctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
-dqctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
-dqctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
-dqctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
-
--- wide-ranging, around precision; signs equal
-dqctm498 comparetotmag 1 1E-17 -> 1
-dqctm499 comparetotmag 1 1E-16 -> 1
-dqctm500 comparetotmag 1 1E-15 -> 1
-dqctm501 comparetotmag 1 1E-14 -> 1
-dqctm502 comparetotmag 1 1E-13 -> 1
-dqctm503 comparetotmag 1 1E-12 -> 1
-dqctm504 comparetotmag 1 1E-11 -> 1
-dqctm505 comparetotmag 1 1E-10 -> 1
-dqctm506 comparetotmag 1 1E-9 -> 1
-dqctm507 comparetotmag 1 1E-8 -> 1
-dqctm508 comparetotmag 1 1E-7 -> 1
-dqctm509 comparetotmag 1 1E-6 -> 1
-dqctm510 comparetotmag 1 1E-5 -> 1
-dqctm511 comparetotmag 1 1E-4 -> 1
-dqctm512 comparetotmag 1 1E-3 -> 1
-dqctm513 comparetotmag 1 1E-2 -> 1
-dqctm514 comparetotmag 1 1E-1 -> 1
-dqctm515 comparetotmag 1 1E-0 -> 0
-dqctm516 comparetotmag 1 1E+1 -> -1
-dqctm517 comparetotmag 1 1E+2 -> -1
-dqctm518 comparetotmag 1 1E+3 -> -1
-dqctm519 comparetotmag 1 1E+4 -> -1
-dqctm521 comparetotmag 1 1E+5 -> -1
-dqctm522 comparetotmag 1 1E+6 -> -1
-dqctm523 comparetotmag 1 1E+7 -> -1
-dqctm524 comparetotmag 1 1E+8 -> -1
-dqctm525 comparetotmag 1 1E+9 -> -1
-dqctm526 comparetotmag 1 1E+10 -> -1
-dqctm527 comparetotmag 1 1E+11 -> -1
-dqctm528 comparetotmag 1 1E+12 -> -1
-dqctm529 comparetotmag 1 1E+13 -> -1
-dqctm530 comparetotmag 1 1E+14 -> -1
-dqctm531 comparetotmag 1 1E+15 -> -1
-dqctm532 comparetotmag 1 1E+16 -> -1
-dqctm533 comparetotmag 1 1E+17 -> -1
--- LR swap
-dqctm538 comparetotmag 1E-17 1 -> -1
-dqctm539 comparetotmag 1E-16 1 -> -1
-dqctm540 comparetotmag 1E-15 1 -> -1
-dqctm541 comparetotmag 1E-14 1 -> -1
-dqctm542 comparetotmag 1E-13 1 -> -1
-dqctm543 comparetotmag 1E-12 1 -> -1
-dqctm544 comparetotmag 1E-11 1 -> -1
-dqctm545 comparetotmag 1E-10 1 -> -1
-dqctm546 comparetotmag 1E-9 1 -> -1
-dqctm547 comparetotmag 1E-8 1 -> -1
-dqctm548 comparetotmag 1E-7 1 -> -1
-dqctm549 comparetotmag 1E-6 1 -> -1
-dqctm550 comparetotmag 1E-5 1 -> -1
-dqctm551 comparetotmag 1E-4 1 -> -1
-dqctm552 comparetotmag 1E-3 1 -> -1
-dqctm553 comparetotmag 1E-2 1 -> -1
-dqctm554 comparetotmag 1E-1 1 -> -1
-dqctm555 comparetotmag 1E-0 1 -> 0
-dqctm556 comparetotmag 1E+1 1 -> 1
-dqctm557 comparetotmag 1E+2 1 -> 1
-dqctm558 comparetotmag 1E+3 1 -> 1
-dqctm559 comparetotmag 1E+4 1 -> 1
-dqctm561 comparetotmag 1E+5 1 -> 1
-dqctm562 comparetotmag 1E+6 1 -> 1
-dqctm563 comparetotmag 1E+7 1 -> 1
-dqctm564 comparetotmag 1E+8 1 -> 1
-dqctm565 comparetotmag 1E+9 1 -> 1
-dqctm566 comparetotmag 1E+10 1 -> 1
-dqctm567 comparetotmag 1E+11 1 -> 1
-dqctm568 comparetotmag 1E+12 1 -> 1
-dqctm569 comparetotmag 1E+13 1 -> 1
-dqctm570 comparetotmag 1E+14 1 -> 1
-dqctm571 comparetotmag 1E+15 1 -> 1
-dqctm572 comparetotmag 1E+16 1 -> 1
-dqctm573 comparetotmag 1E+17 1 -> 1
--- similar with a useful coefficient, one side only
-dqctm578 comparetotmag 0.000000987654321 1E-17 -> 1
-dqctm579 comparetotmag 0.000000987654321 1E-16 -> 1
-dqctm580 comparetotmag 0.000000987654321 1E-15 -> 1
-dqctm581 comparetotmag 0.000000987654321 1E-14 -> 1
-dqctm582 comparetotmag 0.000000987654321 1E-13 -> 1
-dqctm583 comparetotmag 0.000000987654321 1E-12 -> 1
-dqctm584 comparetotmag 0.000000987654321 1E-11 -> 1
-dqctm585 comparetotmag 0.000000987654321 1E-10 -> 1
-dqctm586 comparetotmag 0.000000987654321 1E-9 -> 1
-dqctm587 comparetotmag 0.000000987654321 1E-8 -> 1
-dqctm588 comparetotmag 0.000000987654321 1E-7 -> 1
-dqctm589 comparetotmag 0.000000987654321 1E-6 -> -1
-dqctm590 comparetotmag 0.000000987654321 1E-5 -> -1
-dqctm591 comparetotmag 0.000000987654321 1E-4 -> -1
-dqctm592 comparetotmag 0.000000987654321 1E-3 -> -1
-dqctm593 comparetotmag 0.000000987654321 1E-2 -> -1
-dqctm594 comparetotmag 0.000000987654321 1E-1 -> -1
-dqctm595 comparetotmag 0.000000987654321 1E-0 -> -1
-dqctm596 comparetotmag 0.000000987654321 1E+1 -> -1
-dqctm597 comparetotmag 0.000000987654321 1E+2 -> -1
-dqctm598 comparetotmag 0.000000987654321 1E+3 -> -1
-dqctm599 comparetotmag 0.000000987654321 1E+4 -> -1
-
--- check some unit-y traps
-dqctm600 comparetotmag 12 12.2345 -> -1
-dqctm601 comparetotmag 12.0 12.2345 -> -1
-dqctm602 comparetotmag 12.00 12.2345 -> -1
-dqctm603 comparetotmag 12.000 12.2345 -> -1
-dqctm604 comparetotmag 12.0000 12.2345 -> -1
-dqctm605 comparetotmag 12.00000 12.2345 -> -1
-dqctm606 comparetotmag 12.000000 12.2345 -> -1
-dqctm607 comparetotmag 12.0000000 12.2345 -> -1
-dqctm608 comparetotmag 12.00000000 12.2345 -> -1
-dqctm609 comparetotmag 12.000000000 12.2345 -> -1
-dqctm610 comparetotmag 12.1234 12 -> 1
-dqctm611 comparetotmag 12.1234 12.0 -> 1
-dqctm612 comparetotmag 12.1234 12.00 -> 1
-dqctm613 comparetotmag 12.1234 12.000 -> 1
-dqctm614 comparetotmag 12.1234 12.0000 -> 1
-dqctm615 comparetotmag 12.1234 12.00000 -> 1
-dqctm616 comparetotmag 12.1234 12.000000 -> 1
-dqctm617 comparetotmag 12.1234 12.0000000 -> 1
-dqctm618 comparetotmag 12.1234 12.00000000 -> 1
-dqctm619 comparetotmag 12.1234 12.000000000 -> 1
-dqctm620 comparetotmag -12 -12.2345 -> -1
-dqctm621 comparetotmag -12.0 -12.2345 -> -1
-dqctm622 comparetotmag -12.00 -12.2345 -> -1
-dqctm623 comparetotmag -12.000 -12.2345 -> -1
-dqctm624 comparetotmag -12.0000 -12.2345 -> -1
-dqctm625 comparetotmag -12.00000 -12.2345 -> -1
-dqctm626 comparetotmag -12.000000 -12.2345 -> -1
-dqctm627 comparetotmag -12.0000000 -12.2345 -> -1
-dqctm628 comparetotmag -12.00000000 -12.2345 -> -1
-dqctm629 comparetotmag -12.000000000 -12.2345 -> -1
-dqctm630 comparetotmag -12.1234 -12 -> 1
-dqctm631 comparetotmag -12.1234 -12.0 -> 1
-dqctm632 comparetotmag -12.1234 -12.00 -> 1
-dqctm633 comparetotmag -12.1234 -12.000 -> 1
-dqctm634 comparetotmag -12.1234 -12.0000 -> 1
-dqctm635 comparetotmag -12.1234 -12.00000 -> 1
-dqctm636 comparetotmag -12.1234 -12.000000 -> 1
-dqctm637 comparetotmag -12.1234 -12.0000000 -> 1
-dqctm638 comparetotmag -12.1234 -12.00000000 -> 1
-dqctm639 comparetotmag -12.1234 -12.000000000 -> 1
-
--- extended zeros
-dqctm640 comparetotmag 0 0 -> 0
-dqctm641 comparetotmag 0 -0 -> 0
-dqctm642 comparetotmag 0 -0.0 -> 1
-dqctm643 comparetotmag 0 0.0 -> 1
-dqctm644 comparetotmag -0 0 -> 0
-dqctm645 comparetotmag -0 -0 -> 0
-dqctm646 comparetotmag -0 -0.0 -> 1
-dqctm647 comparetotmag -0 0.0 -> 1
-dqctm648 comparetotmag 0.0 0 -> -1
-dqctm649 comparetotmag 0.0 -0 -> -1
-dqctm650 comparetotmag 0.0 -0.0 -> 0
-dqctm651 comparetotmag 0.0 0.0 -> 0
-dqctm652 comparetotmag -0.0 0 -> -1
-dqctm653 comparetotmag -0.0 -0 -> -1
-dqctm654 comparetotmag -0.0 -0.0 -> 0
-dqctm655 comparetotmag -0.0 0.0 -> 0
-
-dqctm656 comparetotmag -0E1 0.0 -> 1
-dqctm657 comparetotmag -0E2 0.0 -> 1
-dqctm658 comparetotmag 0E1 0.0 -> 1
-dqctm659 comparetotmag 0E2 0.0 -> 1
-dqctm660 comparetotmag -0E1 0 -> 1
-dqctm661 comparetotmag -0E2 0 -> 1
-dqctm662 comparetotmag 0E1 0 -> 1
-dqctm663 comparetotmag 0E2 0 -> 1
-dqctm664 comparetotmag -0E1 -0E1 -> 0
-dqctm665 comparetotmag -0E2 -0E1 -> 1
-dqctm666 comparetotmag 0E1 -0E1 -> 0
-dqctm667 comparetotmag 0E2 -0E1 -> 1
-dqctm668 comparetotmag -0E1 -0E2 -> -1
-dqctm669 comparetotmag -0E2 -0E2 -> 0
-dqctm670 comparetotmag 0E1 -0E2 -> -1
-dqctm671 comparetotmag 0E2 -0E2 -> 0
-dqctm672 comparetotmag -0E1 0E1 -> 0
-dqctm673 comparetotmag -0E2 0E1 -> 1
-dqctm674 comparetotmag 0E1 0E1 -> 0
-dqctm675 comparetotmag 0E2 0E1 -> 1
-dqctm676 comparetotmag -0E1 0E2 -> -1
-dqctm677 comparetotmag -0E2 0E2 -> 0
-dqctm678 comparetotmag 0E1 0E2 -> -1
-dqctm679 comparetotmag 0E2 0E2 -> 0
-
--- trailing zeros; unit-y
-dqctm680 comparetotmag 12 12 -> 0
-dqctm681 comparetotmag 12 12.0 -> 1
-dqctm682 comparetotmag 12 12.00 -> 1
-dqctm683 comparetotmag 12 12.000 -> 1
-dqctm684 comparetotmag 12 12.0000 -> 1
-dqctm685 comparetotmag 12 12.00000 -> 1
-dqctm686 comparetotmag 12 12.000000 -> 1
-dqctm687 comparetotmag 12 12.0000000 -> 1
-dqctm688 comparetotmag 12 12.00000000 -> 1
-dqctm689 comparetotmag 12 12.000000000 -> 1
-dqctm690 comparetotmag 12 12 -> 0
-dqctm691 comparetotmag 12.0 12 -> -1
-dqctm692 comparetotmag 12.00 12 -> -1
-dqctm693 comparetotmag 12.000 12 -> -1
-dqctm694 comparetotmag 12.0000 12 -> -1
-dqctm695 comparetotmag 12.00000 12 -> -1
-dqctm696 comparetotmag 12.000000 12 -> -1
-dqctm697 comparetotmag 12.0000000 12 -> -1
-dqctm698 comparetotmag 12.00000000 12 -> -1
-dqctm699 comparetotmag 12.000000000 12 -> -1
-
--- old long operand checks
-dqctm701 comparetotmag 12345678000 1 -> 1
-dqctm702 comparetotmag 1 12345678000 -> -1
-dqctm703 comparetotmag 1234567800 1 -> 1
-dqctm704 comparetotmag 1 1234567800 -> -1
-dqctm705 comparetotmag 1234567890 1 -> 1
-dqctm706 comparetotmag 1 1234567890 -> -1
-dqctm707 comparetotmag 1234567891 1 -> 1
-dqctm708 comparetotmag 1 1234567891 -> -1
-dqctm709 comparetotmag 12345678901 1 -> 1
-dqctm710 comparetotmag 1 12345678901 -> -1
-dqctm711 comparetotmag 1234567896 1 -> 1
-dqctm712 comparetotmag 1 1234567896 -> -1
-dqctm713 comparetotmag -1234567891 1 -> 1
-dqctm714 comparetotmag 1 -1234567891 -> -1
-dqctm715 comparetotmag -12345678901 1 -> 1
-dqctm716 comparetotmag 1 -12345678901 -> -1
-dqctm717 comparetotmag -1234567896 1 -> 1
-dqctm718 comparetotmag 1 -1234567896 -> -1
-
--- old residue cases
-dqctm740 comparetotmag 1 0.9999999 -> 1
-dqctm741 comparetotmag 1 0.999999 -> 1
-dqctm742 comparetotmag 1 0.99999 -> 1
-dqctm743 comparetotmag 1 1.0000 -> 1
-dqctm744 comparetotmag 1 1.00001 -> -1
-dqctm745 comparetotmag 1 1.000001 -> -1
-dqctm746 comparetotmag 1 1.0000001 -> -1
-dqctm750 comparetotmag 0.9999999 1 -> -1
-dqctm751 comparetotmag 0.999999 1 -> -1
-dqctm752 comparetotmag 0.99999 1 -> -1
-dqctm753 comparetotmag 1.0000 1 -> -1
-dqctm754 comparetotmag 1.00001 1 -> 1
-dqctm755 comparetotmag 1.000001 1 -> 1
-dqctm756 comparetotmag 1.0000001 1 -> 1
-
--- Specials
-dqctm780 comparetotmag Inf -Inf -> 0
-dqctm781 comparetotmag Inf -1000 -> 1
-dqctm782 comparetotmag Inf -1 -> 1
-dqctm783 comparetotmag Inf -0 -> 1
-dqctm784 comparetotmag Inf 0 -> 1
-dqctm785 comparetotmag Inf 1 -> 1
-dqctm786 comparetotmag Inf 1000 -> 1
-dqctm787 comparetotmag Inf Inf -> 0
-dqctm788 comparetotmag -1000 Inf -> -1
-dqctm789 comparetotmag -Inf Inf -> 0
-dqctm790 comparetotmag -1 Inf -> -1
-dqctm791 comparetotmag -0 Inf -> -1
-dqctm792 comparetotmag 0 Inf -> -1
-dqctm793 comparetotmag 1 Inf -> -1
-dqctm794 comparetotmag 1000 Inf -> -1
-dqctm795 comparetotmag Inf Inf -> 0
-
-dqctm800 comparetotmag -Inf -Inf -> 0
-dqctm801 comparetotmag -Inf -1000 -> 1
-dqctm802 comparetotmag -Inf -1 -> 1
-dqctm803 comparetotmag -Inf -0 -> 1
-dqctm804 comparetotmag -Inf 0 -> 1
-dqctm805 comparetotmag -Inf 1 -> 1
-dqctm806 comparetotmag -Inf 1000 -> 1
-dqctm807 comparetotmag -Inf Inf -> 0
-dqctm808 comparetotmag -Inf -Inf -> 0
-dqctm809 comparetotmag -1000 -Inf -> -1
-dqctm810 comparetotmag -1 -Inf -> -1
-dqctm811 comparetotmag -0 -Inf -> -1
-dqctm812 comparetotmag 0 -Inf -> -1
-dqctm813 comparetotmag 1 -Inf -> -1
-dqctm814 comparetotmag 1000 -Inf -> -1
-dqctm815 comparetotmag Inf -Inf -> 0
-
-dqctm821 comparetotmag NaN -Inf -> 1
-dqctm822 comparetotmag NaN -1000 -> 1
-dqctm823 comparetotmag NaN -1 -> 1
-dqctm824 comparetotmag NaN -0 -> 1
-dqctm825 comparetotmag NaN 0 -> 1
-dqctm826 comparetotmag NaN 1 -> 1
-dqctm827 comparetotmag NaN 1000 -> 1
-dqctm828 comparetotmag NaN Inf -> 1
-dqctm829 comparetotmag NaN NaN -> 0
-dqctm830 comparetotmag -Inf NaN -> -1
-dqctm831 comparetotmag -1000 NaN -> -1
-dqctm832 comparetotmag -1 NaN -> -1
-dqctm833 comparetotmag -0 NaN -> -1
-dqctm834 comparetotmag 0 NaN -> -1
-dqctm835 comparetotmag 1 NaN -> -1
-dqctm836 comparetotmag 1000 NaN -> -1
-dqctm837 comparetotmag Inf NaN -> -1
-dqctm838 comparetotmag -NaN -NaN -> 0
-dqctm839 comparetotmag +NaN -NaN -> 0
-dqctm840 comparetotmag -NaN +NaN -> 0
-
-dqctm841 comparetotmag sNaN -sNaN -> 0
-dqctm842 comparetotmag sNaN -NaN -> -1
-dqctm843 comparetotmag sNaN -Inf -> 1
-dqctm844 comparetotmag sNaN -1000 -> 1
-dqctm845 comparetotmag sNaN -1 -> 1
-dqctm846 comparetotmag sNaN -0 -> 1
-dqctm847 comparetotmag sNaN 0 -> 1
-dqctm848 comparetotmag sNaN 1 -> 1
-dqctm849 comparetotmag sNaN 1000 -> 1
-dqctm850 comparetotmag sNaN NaN -> -1
-dqctm851 comparetotmag sNaN sNaN -> 0
-
-dqctm852 comparetotmag -sNaN sNaN -> 0
-dqctm853 comparetotmag -NaN sNaN -> 1
-dqctm854 comparetotmag -Inf sNaN -> -1
-dqctm855 comparetotmag -1000 sNaN -> -1
-dqctm856 comparetotmag -1 sNaN -> -1
-dqctm857 comparetotmag -0 sNaN -> -1
-dqctm858 comparetotmag 0 sNaN -> -1
-dqctm859 comparetotmag 1 sNaN -> -1
-dqctm860 comparetotmag 1000 sNaN -> -1
-dqctm861 comparetotmag Inf sNaN -> -1
-dqctm862 comparetotmag NaN sNaN -> 1
-dqctm863 comparetotmag sNaN sNaN -> 0
-
-dqctm871 comparetotmag -sNaN -sNaN -> 0
-dqctm872 comparetotmag -sNaN -NaN -> -1
-dqctm873 comparetotmag -sNaN -Inf -> 1
-dqctm874 comparetotmag -sNaN -1000 -> 1
-dqctm875 comparetotmag -sNaN -1 -> 1
-dqctm876 comparetotmag -sNaN -0 -> 1
-dqctm877 comparetotmag -sNaN 0 -> 1
-dqctm878 comparetotmag -sNaN 1 -> 1
-dqctm879 comparetotmag -sNaN 1000 -> 1
-dqctm880 comparetotmag -sNaN NaN -> -1
-dqctm881 comparetotmag -sNaN sNaN -> 0
-
-dqctm882 comparetotmag -sNaN -sNaN -> 0
-dqctm883 comparetotmag -NaN -sNaN -> 1
-dqctm884 comparetotmag -Inf -sNaN -> -1
-dqctm885 comparetotmag -1000 -sNaN -> -1
-dqctm886 comparetotmag -1 -sNaN -> -1
-dqctm887 comparetotmag -0 -sNaN -> -1
-dqctm888 comparetotmag 0 -sNaN -> -1
-dqctm889 comparetotmag 1 -sNaN -> -1
-dqctm890 comparetotmag 1000 -sNaN -> -1
-dqctm891 comparetotmag Inf -sNaN -> -1
-dqctm892 comparetotmag NaN -sNaN -> 1
-dqctm893 comparetotmag sNaN -sNaN -> 0
-
--- NaNs with payload
-dqctm960 comparetotmag NaN9 -Inf -> 1
-dqctm961 comparetotmag NaN8 999 -> 1
-dqctm962 comparetotmag NaN77 Inf -> 1
-dqctm963 comparetotmag -NaN67 NaN5 -> 1
-dqctm964 comparetotmag -Inf -NaN4 -> -1
-dqctm965 comparetotmag -999 -NaN33 -> -1
-dqctm966 comparetotmag Inf NaN2 -> -1
-
-dqctm970 comparetotmag -NaN41 -NaN42 -> -1
-dqctm971 comparetotmag +NaN41 -NaN42 -> -1
-dqctm972 comparetotmag -NaN41 +NaN42 -> -1
-dqctm973 comparetotmag +NaN41 +NaN42 -> -1
-dqctm974 comparetotmag -NaN42 -NaN01 -> 1
-dqctm975 comparetotmag +NaN42 -NaN01 -> 1
-dqctm976 comparetotmag -NaN42 +NaN01 -> 1
-dqctm977 comparetotmag +NaN42 +NaN01 -> 1
-
-dqctm980 comparetotmag -sNaN771 -sNaN772 -> -1
-dqctm981 comparetotmag +sNaN771 -sNaN772 -> -1
-dqctm982 comparetotmag -sNaN771 +sNaN772 -> -1
-dqctm983 comparetotmag +sNaN771 +sNaN772 -> -1
-dqctm984 comparetotmag -sNaN772 -sNaN771 -> 1
-dqctm985 comparetotmag +sNaN772 -sNaN771 -> 1
-dqctm986 comparetotmag -sNaN772 +sNaN771 -> 1
-dqctm987 comparetotmag +sNaN772 +sNaN771 -> 1
-
-dqctm991 comparetotmag -sNaN99 -Inf -> 1
-dqctm992 comparetotmag sNaN98 -11 -> 1
-dqctm993 comparetotmag sNaN97 NaN -> -1
-dqctm994 comparetotmag sNaN16 sNaN94 -> -1
-dqctm995 comparetotmag NaN85 sNaN83 -> 1
-dqctm996 comparetotmag -Inf sNaN92 -> -1
-dqctm997 comparetotmag 088 sNaN81 -> -1
-dqctm998 comparetotmag Inf sNaN90 -> -1
-dqctm999 comparetotmag NaN -sNaN89 -> 1
-
--- spread zeros
-dqctm1110 comparetotmag 0E-6143 0 -> -1
-dqctm1111 comparetotmag 0E-6143 -0 -> -1
-dqctm1112 comparetotmag -0E-6143 0 -> -1
-dqctm1113 comparetotmag -0E-6143 -0 -> -1
-dqctm1114 comparetotmag 0E-6143 0E+6144 -> -1
-dqctm1115 comparetotmag 0E-6143 -0E+6144 -> -1
-dqctm1116 comparetotmag -0E-6143 0E+6144 -> -1
-dqctm1117 comparetotmag -0E-6143 -0E+6144 -> -1
-dqctm1118 comparetotmag 0 0E+6144 -> -1
-dqctm1119 comparetotmag 0 -0E+6144 -> -1
-dqctm1120 comparetotmag -0 0E+6144 -> -1
-dqctm1121 comparetotmag -0 -0E+6144 -> -1
-
-dqctm1130 comparetotmag 0E+6144 0 -> 1
-dqctm1131 comparetotmag 0E+6144 -0 -> 1
-dqctm1132 comparetotmag -0E+6144 0 -> 1
-dqctm1133 comparetotmag -0E+6144 -0 -> 1
-dqctm1134 comparetotmag 0E+6144 0E-6143 -> 1
-dqctm1135 comparetotmag 0E+6144 -0E-6143 -> 1
-dqctm1136 comparetotmag -0E+6144 0E-6143 -> 1
-dqctm1137 comparetotmag -0E+6144 -0E-6143 -> 1
-dqctm1138 comparetotmag 0 0E-6143 -> 1
-dqctm1139 comparetotmag 0 -0E-6143 -> 1
-dqctm1140 comparetotmag -0 0E-6143 -> 1
-dqctm1141 comparetotmag -0 -0E-6143 -> 1
-
--- Null tests
-dqctm9990 comparetotmag 10 # -> NaN Invalid_operation
-dqctm9991 comparetotmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqCompareTotalMag.decTest -- decQuad comparison; abs. total order --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Note that we cannot assume add/subtract tests cover paths adequately,
+-- here, because the code might be quite different (comparison cannot
+-- overflow or underflow, so actual subtractions are not necessary).
+-- Similarly, comparetotal will have some radically different paths
+-- than compare.
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqctm001 comparetotmag -2 -2 -> 0
+dqctm002 comparetotmag -2 -1 -> 1
+dqctm003 comparetotmag -2 0 -> 1
+dqctm004 comparetotmag -2 1 -> 1
+dqctm005 comparetotmag -2 2 -> 0
+dqctm006 comparetotmag -1 -2 -> -1
+dqctm007 comparetotmag -1 -1 -> 0
+dqctm008 comparetotmag -1 0 -> 1
+dqctm009 comparetotmag -1 1 -> 0
+dqctm010 comparetotmag -1 2 -> -1
+dqctm011 comparetotmag 0 -2 -> -1
+dqctm012 comparetotmag 0 -1 -> -1
+dqctm013 comparetotmag 0 0 -> 0
+dqctm014 comparetotmag 0 1 -> -1
+dqctm015 comparetotmag 0 2 -> -1
+dqctm016 comparetotmag 1 -2 -> -1
+dqctm017 comparetotmag 1 -1 -> 0
+dqctm018 comparetotmag 1 0 -> 1
+dqctm019 comparetotmag 1 1 -> 0
+dqctm020 comparetotmag 1 2 -> -1
+dqctm021 comparetotmag 2 -2 -> 0
+dqctm022 comparetotmag 2 -1 -> 1
+dqctm023 comparetotmag 2 0 -> 1
+dqctm025 comparetotmag 2 1 -> 1
+dqctm026 comparetotmag 2 2 -> 0
+
+dqctm031 comparetotmag -20 -20 -> 0
+dqctm032 comparetotmag -20 -10 -> 1
+dqctm033 comparetotmag -20 00 -> 1
+dqctm034 comparetotmag -20 10 -> 1
+dqctm035 comparetotmag -20 20 -> 0
+dqctm036 comparetotmag -10 -20 -> -1
+dqctm037 comparetotmag -10 -10 -> 0
+dqctm038 comparetotmag -10 00 -> 1
+dqctm039 comparetotmag -10 10 -> 0
+dqctm040 comparetotmag -10 20 -> -1
+dqctm041 comparetotmag 00 -20 -> -1
+dqctm042 comparetotmag 00 -10 -> -1
+dqctm043 comparetotmag 00 00 -> 0
+dqctm044 comparetotmag 00 10 -> -1
+dqctm045 comparetotmag 00 20 -> -1
+dqctm046 comparetotmag 10 -20 -> -1
+dqctm047 comparetotmag 10 -10 -> 0
+dqctm048 comparetotmag 10 00 -> 1
+dqctm049 comparetotmag 10 10 -> 0
+dqctm050 comparetotmag 10 20 -> -1
+dqctm051 comparetotmag 20 -20 -> 0
+dqctm052 comparetotmag 20 -10 -> 1
+dqctm053 comparetotmag 20 00 -> 1
+dqctm055 comparetotmag 20 10 -> 1
+dqctm056 comparetotmag 20 20 -> 0
+
+dqctm061 comparetotmag -2.0 -2.0 -> 0
+dqctm062 comparetotmag -2.0 -1.0 -> 1
+dqctm063 comparetotmag -2.0 0.0 -> 1
+dqctm064 comparetotmag -2.0 1.0 -> 1
+dqctm065 comparetotmag -2.0 2.0 -> 0
+dqctm066 comparetotmag -1.0 -2.0 -> -1
+dqctm067 comparetotmag -1.0 -1.0 -> 0
+dqctm068 comparetotmag -1.0 0.0 -> 1
+dqctm069 comparetotmag -1.0 1.0 -> 0
+dqctm070 comparetotmag -1.0 2.0 -> -1
+dqctm071 comparetotmag 0.0 -2.0 -> -1
+dqctm072 comparetotmag 0.0 -1.0 -> -1
+dqctm073 comparetotmag 0.0 0.0 -> 0
+dqctm074 comparetotmag 0.0 1.0 -> -1
+dqctm075 comparetotmag 0.0 2.0 -> -1
+dqctm076 comparetotmag 1.0 -2.0 -> -1
+dqctm077 comparetotmag 1.0 -1.0 -> 0
+dqctm078 comparetotmag 1.0 0.0 -> 1
+dqctm079 comparetotmag 1.0 1.0 -> 0
+dqctm080 comparetotmag 1.0 2.0 -> -1
+dqctm081 comparetotmag 2.0 -2.0 -> 0
+dqctm082 comparetotmag 2.0 -1.0 -> 1
+dqctm083 comparetotmag 2.0 0.0 -> 1
+dqctm085 comparetotmag 2.0 1.0 -> 1
+dqctm086 comparetotmag 2.0 2.0 -> 0
+
+-- now some cases which might overflow if subtract were used
+dqctm090 comparetotmag 9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqctm091 comparetotmag -9.99999999999999999999999999999E+6144 9.99999999999999999999999999999E+6144 -> 0
+dqctm092 comparetotmag 9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+dqctm093 comparetotmag -9.99999999999999999999999999999E+6144 -9.99999999999999999999999999999E+6144 -> 0
+
+-- some differing length/exponent cases
+-- in this first group, compare would compare all equal
+dqctm100 comparetotmag 7.0 7.0 -> 0
+dqctm101 comparetotmag 7.0 7 -> -1
+dqctm102 comparetotmag 7 7.0 -> 1
+dqctm103 comparetotmag 7E+0 7.0 -> 1
+dqctm104 comparetotmag 70E-1 7.0 -> 0
+dqctm105 comparetotmag 0.7E+1 7 -> 0
+dqctm106 comparetotmag 70E-1 7 -> -1
+dqctm107 comparetotmag 7.0 7E+0 -> -1
+dqctm108 comparetotmag 7.0 70E-1 -> 0
+dqctm109 comparetotmag 7 0.7E+1 -> 0
+dqctm110 comparetotmag 7 70E-1 -> 1
+
+dqctm120 comparetotmag 8.0 7.0 -> 1
+dqctm121 comparetotmag 8.0 7 -> 1
+dqctm122 comparetotmag 8 7.0 -> 1
+dqctm123 comparetotmag 8E+0 7.0 -> 1
+dqctm124 comparetotmag 80E-1 7.0 -> 1
+dqctm125 comparetotmag 0.8E+1 7 -> 1
+dqctm126 comparetotmag 80E-1 7 -> 1
+dqctm127 comparetotmag 8.0 7E+0 -> 1
+dqctm128 comparetotmag 8.0 70E-1 -> 1
+dqctm129 comparetotmag 8 0.7E+1 -> 1
+dqctm130 comparetotmag 8 70E-1 -> 1
+
+dqctm140 comparetotmag 8.0 9.0 -> -1
+dqctm141 comparetotmag 8.0 9 -> -1
+dqctm142 comparetotmag 8 9.0 -> -1
+dqctm143 comparetotmag 8E+0 9.0 -> -1
+dqctm144 comparetotmag 80E-1 9.0 -> -1
+dqctm145 comparetotmag 0.8E+1 9 -> -1
+dqctm146 comparetotmag 80E-1 9 -> -1
+dqctm147 comparetotmag 8.0 9E+0 -> -1
+dqctm148 comparetotmag 8.0 90E-1 -> -1
+dqctm149 comparetotmag 8 0.9E+1 -> -1
+dqctm150 comparetotmag 8 90E-1 -> -1
+
+-- and again, with sign changes -+ ..
+dqctm200 comparetotmag -7.0 7.0 -> 0
+dqctm201 comparetotmag -7.0 7 -> -1
+dqctm202 comparetotmag -7 7.0 -> 1
+dqctm203 comparetotmag -7E+0 7.0 -> 1
+dqctm204 comparetotmag -70E-1 7.0 -> 0
+dqctm205 comparetotmag -0.7E+1 7 -> 0
+dqctm206 comparetotmag -70E-1 7 -> -1
+dqctm207 comparetotmag -7.0 7E+0 -> -1
+dqctm208 comparetotmag -7.0 70E-1 -> 0
+dqctm209 comparetotmag -7 0.7E+1 -> 0
+dqctm210 comparetotmag -7 70E-1 -> 1
+
+dqctm220 comparetotmag -8.0 7.0 -> 1
+dqctm221 comparetotmag -8.0 7 -> 1
+dqctm222 comparetotmag -8 7.0 -> 1
+dqctm223 comparetotmag -8E+0 7.0 -> 1
+dqctm224 comparetotmag -80E-1 7.0 -> 1
+dqctm225 comparetotmag -0.8E+1 7 -> 1
+dqctm226 comparetotmag -80E-1 7 -> 1
+dqctm227 comparetotmag -8.0 7E+0 -> 1
+dqctm228 comparetotmag -8.0 70E-1 -> 1
+dqctm229 comparetotmag -8 0.7E+1 -> 1
+dqctm230 comparetotmag -8 70E-1 -> 1
+
+dqctm240 comparetotmag -8.0 9.0 -> -1
+dqctm241 comparetotmag -8.0 9 -> -1
+dqctm242 comparetotmag -8 9.0 -> -1
+dqctm243 comparetotmag -8E+0 9.0 -> -1
+dqctm244 comparetotmag -80E-1 9.0 -> -1
+dqctm245 comparetotmag -0.8E+1 9 -> -1
+dqctm246 comparetotmag -80E-1 9 -> -1
+dqctm247 comparetotmag -8.0 9E+0 -> -1
+dqctm248 comparetotmag -8.0 90E-1 -> -1
+dqctm249 comparetotmag -8 0.9E+1 -> -1
+dqctm250 comparetotmag -8 90E-1 -> -1
+
+-- and again, with sign changes +- ..
+dqctm300 comparetotmag 7.0 -7.0 -> 0
+dqctm301 comparetotmag 7.0 -7 -> -1
+dqctm302 comparetotmag 7 -7.0 -> 1
+dqctm303 comparetotmag 7E+0 -7.0 -> 1
+dqctm304 comparetotmag 70E-1 -7.0 -> 0
+dqctm305 comparetotmag .7E+1 -7 -> 0
+dqctm306 comparetotmag 70E-1 -7 -> -1
+dqctm307 comparetotmag 7.0 -7E+0 -> -1
+dqctm308 comparetotmag 7.0 -70E-1 -> 0
+dqctm309 comparetotmag 7 -.7E+1 -> 0
+dqctm310 comparetotmag 7 -70E-1 -> 1
+
+dqctm320 comparetotmag 8.0 -7.0 -> 1
+dqctm321 comparetotmag 8.0 -7 -> 1
+dqctm322 comparetotmag 8 -7.0 -> 1
+dqctm323 comparetotmag 8E+0 -7.0 -> 1
+dqctm324 comparetotmag 80E-1 -7.0 -> 1
+dqctm325 comparetotmag .8E+1 -7 -> 1
+dqctm326 comparetotmag 80E-1 -7 -> 1
+dqctm327 comparetotmag 8.0 -7E+0 -> 1
+dqctm328 comparetotmag 8.0 -70E-1 -> 1
+dqctm329 comparetotmag 8 -.7E+1 -> 1
+dqctm330 comparetotmag 8 -70E-1 -> 1
+
+dqctm340 comparetotmag 8.0 -9.0 -> -1
+dqctm341 comparetotmag 8.0 -9 -> -1
+dqctm342 comparetotmag 8 -9.0 -> -1
+dqctm343 comparetotmag 8E+0 -9.0 -> -1
+dqctm344 comparetotmag 80E-1 -9.0 -> -1
+dqctm345 comparetotmag .8E+1 -9 -> -1
+dqctm346 comparetotmag 80E-1 -9 -> -1
+dqctm347 comparetotmag 8.0 -9E+0 -> -1
+dqctm348 comparetotmag 8.0 -90E-1 -> -1
+dqctm349 comparetotmag 8 -.9E+1 -> -1
+dqctm350 comparetotmag 8 -90E-1 -> -1
+
+-- and again, with sign changes -- ..
+dqctm400 comparetotmag -7.0 -7.0 -> 0
+dqctm401 comparetotmag -7.0 -7 -> -1
+dqctm402 comparetotmag -7 -7.0 -> 1
+dqctm403 comparetotmag -7E+0 -7.0 -> 1
+dqctm404 comparetotmag -70E-1 -7.0 -> 0
+dqctm405 comparetotmag -.7E+1 -7 -> 0
+dqctm406 comparetotmag -70E-1 -7 -> -1
+dqctm407 comparetotmag -7.0 -7E+0 -> -1
+dqctm408 comparetotmag -7.0 -70E-1 -> 0
+dqctm409 comparetotmag -7 -.7E+1 -> 0
+dqctm410 comparetotmag -7 -70E-1 -> 1
+
+dqctm420 comparetotmag -8.0 -7.0 -> 1
+dqctm421 comparetotmag -8.0 -7 -> 1
+dqctm422 comparetotmag -8 -7.0 -> 1
+dqctm423 comparetotmag -8E+0 -7.0 -> 1
+dqctm424 comparetotmag -80E-1 -7.0 -> 1
+dqctm425 comparetotmag -.8E+1 -7 -> 1
+dqctm426 comparetotmag -80E-1 -7 -> 1
+dqctm427 comparetotmag -8.0 -7E+0 -> 1
+dqctm428 comparetotmag -8.0 -70E-1 -> 1
+dqctm429 comparetotmag -8 -.7E+1 -> 1
+dqctm430 comparetotmag -8 -70E-1 -> 1
+
+dqctm440 comparetotmag -8.0 -9.0 -> -1
+dqctm441 comparetotmag -8.0 -9 -> -1
+dqctm442 comparetotmag -8 -9.0 -> -1
+dqctm443 comparetotmag -8E+0 -9.0 -> -1
+dqctm444 comparetotmag -80E-1 -9.0 -> -1
+dqctm445 comparetotmag -.8E+1 -9 -> -1
+dqctm446 comparetotmag -80E-1 -9 -> -1
+dqctm447 comparetotmag -8.0 -9E+0 -> -1
+dqctm448 comparetotmag -8.0 -90E-1 -> -1
+dqctm449 comparetotmag -8 -.9E+1 -> -1
+dqctm450 comparetotmag -8 -90E-1 -> -1
+
+
+-- testcases that subtract to lots of zeros at boundaries [pgr]
+dqctm473 comparetotmag 123.4560000000000E-89 123.456E-89 -> -1
+dqctm474 comparetotmag 123.456000000000E+89 123.456E+89 -> -1
+dqctm475 comparetotmag 123.45600000000E-89 123.456E-89 -> -1
+dqctm476 comparetotmag 123.4560000000E+89 123.456E+89 -> -1
+dqctm477 comparetotmag 123.456000000E-89 123.456E-89 -> -1
+dqctm478 comparetotmag 123.45600000E+89 123.456E+89 -> -1
+dqctm479 comparetotmag 123.4560000E-89 123.456E-89 -> -1
+dqctm480 comparetotmag 123.456000E+89 123.456E+89 -> -1
+dqctm481 comparetotmag 123.45600E-89 123.456E-89 -> -1
+dqctm482 comparetotmag 123.4560E+89 123.456E+89 -> -1
+dqctm483 comparetotmag 123.456E-89 123.456E-89 -> 0
+dqctm487 comparetotmag 123.456E+89 123.4560000000000E+89 -> 1
+dqctm488 comparetotmag 123.456E-89 123.456000000000E-89 -> 1
+dqctm489 comparetotmag 123.456E+89 123.45600000000E+89 -> 1
+dqctm490 comparetotmag 123.456E-89 123.4560000000E-89 -> 1
+dqctm491 comparetotmag 123.456E+89 123.456000000E+89 -> 1
+dqctm492 comparetotmag 123.456E-89 123.45600000E-89 -> 1
+dqctm493 comparetotmag 123.456E+89 123.4560000E+89 -> 1
+dqctm494 comparetotmag 123.456E-89 123.456000E-89 -> 1
+dqctm495 comparetotmag 123.456E+89 123.45600E+89 -> 1
+dqctm496 comparetotmag 123.456E-89 123.4560E-89 -> 1
+dqctm497 comparetotmag 123.456E+89 123.456E+89 -> 0
+
+-- wide-ranging, around precision; signs equal
+dqctm498 comparetotmag 1 1E-17 -> 1
+dqctm499 comparetotmag 1 1E-16 -> 1
+dqctm500 comparetotmag 1 1E-15 -> 1
+dqctm501 comparetotmag 1 1E-14 -> 1
+dqctm502 comparetotmag 1 1E-13 -> 1
+dqctm503 comparetotmag 1 1E-12 -> 1
+dqctm504 comparetotmag 1 1E-11 -> 1
+dqctm505 comparetotmag 1 1E-10 -> 1
+dqctm506 comparetotmag 1 1E-9 -> 1
+dqctm507 comparetotmag 1 1E-8 -> 1
+dqctm508 comparetotmag 1 1E-7 -> 1
+dqctm509 comparetotmag 1 1E-6 -> 1
+dqctm510 comparetotmag 1 1E-5 -> 1
+dqctm511 comparetotmag 1 1E-4 -> 1
+dqctm512 comparetotmag 1 1E-3 -> 1
+dqctm513 comparetotmag 1 1E-2 -> 1
+dqctm514 comparetotmag 1 1E-1 -> 1
+dqctm515 comparetotmag 1 1E-0 -> 0
+dqctm516 comparetotmag 1 1E+1 -> -1
+dqctm517 comparetotmag 1 1E+2 -> -1
+dqctm518 comparetotmag 1 1E+3 -> -1
+dqctm519 comparetotmag 1 1E+4 -> -1
+dqctm521 comparetotmag 1 1E+5 -> -1
+dqctm522 comparetotmag 1 1E+6 -> -1
+dqctm523 comparetotmag 1 1E+7 -> -1
+dqctm524 comparetotmag 1 1E+8 -> -1
+dqctm525 comparetotmag 1 1E+9 -> -1
+dqctm526 comparetotmag 1 1E+10 -> -1
+dqctm527 comparetotmag 1 1E+11 -> -1
+dqctm528 comparetotmag 1 1E+12 -> -1
+dqctm529 comparetotmag 1 1E+13 -> -1
+dqctm530 comparetotmag 1 1E+14 -> -1
+dqctm531 comparetotmag 1 1E+15 -> -1
+dqctm532 comparetotmag 1 1E+16 -> -1
+dqctm533 comparetotmag 1 1E+17 -> -1
+-- LR swap
+dqctm538 comparetotmag 1E-17 1 -> -1
+dqctm539 comparetotmag 1E-16 1 -> -1
+dqctm540 comparetotmag 1E-15 1 -> -1
+dqctm541 comparetotmag 1E-14 1 -> -1
+dqctm542 comparetotmag 1E-13 1 -> -1
+dqctm543 comparetotmag 1E-12 1 -> -1
+dqctm544 comparetotmag 1E-11 1 -> -1
+dqctm545 comparetotmag 1E-10 1 -> -1
+dqctm546 comparetotmag 1E-9 1 -> -1
+dqctm547 comparetotmag 1E-8 1 -> -1
+dqctm548 comparetotmag 1E-7 1 -> -1
+dqctm549 comparetotmag 1E-6 1 -> -1
+dqctm550 comparetotmag 1E-5 1 -> -1
+dqctm551 comparetotmag 1E-4 1 -> -1
+dqctm552 comparetotmag 1E-3 1 -> -1
+dqctm553 comparetotmag 1E-2 1 -> -1
+dqctm554 comparetotmag 1E-1 1 -> -1
+dqctm555 comparetotmag 1E-0 1 -> 0
+dqctm556 comparetotmag 1E+1 1 -> 1
+dqctm557 comparetotmag 1E+2 1 -> 1
+dqctm558 comparetotmag 1E+3 1 -> 1
+dqctm559 comparetotmag 1E+4 1 -> 1
+dqctm561 comparetotmag 1E+5 1 -> 1
+dqctm562 comparetotmag 1E+6 1 -> 1
+dqctm563 comparetotmag 1E+7 1 -> 1
+dqctm564 comparetotmag 1E+8 1 -> 1
+dqctm565 comparetotmag 1E+9 1 -> 1
+dqctm566 comparetotmag 1E+10 1 -> 1
+dqctm567 comparetotmag 1E+11 1 -> 1
+dqctm568 comparetotmag 1E+12 1 -> 1
+dqctm569 comparetotmag 1E+13 1 -> 1
+dqctm570 comparetotmag 1E+14 1 -> 1
+dqctm571 comparetotmag 1E+15 1 -> 1
+dqctm572 comparetotmag 1E+16 1 -> 1
+dqctm573 comparetotmag 1E+17 1 -> 1
+-- similar with a useful coefficient, one side only
+dqctm578 comparetotmag 0.000000987654321 1E-17 -> 1
+dqctm579 comparetotmag 0.000000987654321 1E-16 -> 1
+dqctm580 comparetotmag 0.000000987654321 1E-15 -> 1
+dqctm581 comparetotmag 0.000000987654321 1E-14 -> 1
+dqctm582 comparetotmag 0.000000987654321 1E-13 -> 1
+dqctm583 comparetotmag 0.000000987654321 1E-12 -> 1
+dqctm584 comparetotmag 0.000000987654321 1E-11 -> 1
+dqctm585 comparetotmag 0.000000987654321 1E-10 -> 1
+dqctm586 comparetotmag 0.000000987654321 1E-9 -> 1
+dqctm587 comparetotmag 0.000000987654321 1E-8 -> 1
+dqctm588 comparetotmag 0.000000987654321 1E-7 -> 1
+dqctm589 comparetotmag 0.000000987654321 1E-6 -> -1
+dqctm590 comparetotmag 0.000000987654321 1E-5 -> -1
+dqctm591 comparetotmag 0.000000987654321 1E-4 -> -1
+dqctm592 comparetotmag 0.000000987654321 1E-3 -> -1
+dqctm593 comparetotmag 0.000000987654321 1E-2 -> -1
+dqctm594 comparetotmag 0.000000987654321 1E-1 -> -1
+dqctm595 comparetotmag 0.000000987654321 1E-0 -> -1
+dqctm596 comparetotmag 0.000000987654321 1E+1 -> -1
+dqctm597 comparetotmag 0.000000987654321 1E+2 -> -1
+dqctm598 comparetotmag 0.000000987654321 1E+3 -> -1
+dqctm599 comparetotmag 0.000000987654321 1E+4 -> -1
+
+-- check some unit-y traps
+dqctm600 comparetotmag 12 12.2345 -> -1
+dqctm601 comparetotmag 12.0 12.2345 -> -1
+dqctm602 comparetotmag 12.00 12.2345 -> -1
+dqctm603 comparetotmag 12.000 12.2345 -> -1
+dqctm604 comparetotmag 12.0000 12.2345 -> -1
+dqctm605 comparetotmag 12.00000 12.2345 -> -1
+dqctm606 comparetotmag 12.000000 12.2345 -> -1
+dqctm607 comparetotmag 12.0000000 12.2345 -> -1
+dqctm608 comparetotmag 12.00000000 12.2345 -> -1
+dqctm609 comparetotmag 12.000000000 12.2345 -> -1
+dqctm610 comparetotmag 12.1234 12 -> 1
+dqctm611 comparetotmag 12.1234 12.0 -> 1
+dqctm612 comparetotmag 12.1234 12.00 -> 1
+dqctm613 comparetotmag 12.1234 12.000 -> 1
+dqctm614 comparetotmag 12.1234 12.0000 -> 1
+dqctm615 comparetotmag 12.1234 12.00000 -> 1
+dqctm616 comparetotmag 12.1234 12.000000 -> 1
+dqctm617 comparetotmag 12.1234 12.0000000 -> 1
+dqctm618 comparetotmag 12.1234 12.00000000 -> 1
+dqctm619 comparetotmag 12.1234 12.000000000 -> 1
+dqctm620 comparetotmag -12 -12.2345 -> -1
+dqctm621 comparetotmag -12.0 -12.2345 -> -1
+dqctm622 comparetotmag -12.00 -12.2345 -> -1
+dqctm623 comparetotmag -12.000 -12.2345 -> -1
+dqctm624 comparetotmag -12.0000 -12.2345 -> -1
+dqctm625 comparetotmag -12.00000 -12.2345 -> -1
+dqctm626 comparetotmag -12.000000 -12.2345 -> -1
+dqctm627 comparetotmag -12.0000000 -12.2345 -> -1
+dqctm628 comparetotmag -12.00000000 -12.2345 -> -1
+dqctm629 comparetotmag -12.000000000 -12.2345 -> -1
+dqctm630 comparetotmag -12.1234 -12 -> 1
+dqctm631 comparetotmag -12.1234 -12.0 -> 1
+dqctm632 comparetotmag -12.1234 -12.00 -> 1
+dqctm633 comparetotmag -12.1234 -12.000 -> 1
+dqctm634 comparetotmag -12.1234 -12.0000 -> 1
+dqctm635 comparetotmag -12.1234 -12.00000 -> 1
+dqctm636 comparetotmag -12.1234 -12.000000 -> 1
+dqctm637 comparetotmag -12.1234 -12.0000000 -> 1
+dqctm638 comparetotmag -12.1234 -12.00000000 -> 1
+dqctm639 comparetotmag -12.1234 -12.000000000 -> 1
+
+-- extended zeros
+dqctm640 comparetotmag 0 0 -> 0
+dqctm641 comparetotmag 0 -0 -> 0
+dqctm642 comparetotmag 0 -0.0 -> 1
+dqctm643 comparetotmag 0 0.0 -> 1
+dqctm644 comparetotmag -0 0 -> 0
+dqctm645 comparetotmag -0 -0 -> 0
+dqctm646 comparetotmag -0 -0.0 -> 1
+dqctm647 comparetotmag -0 0.0 -> 1
+dqctm648 comparetotmag 0.0 0 -> -1
+dqctm649 comparetotmag 0.0 -0 -> -1
+dqctm650 comparetotmag 0.0 -0.0 -> 0
+dqctm651 comparetotmag 0.0 0.0 -> 0
+dqctm652 comparetotmag -0.0 0 -> -1
+dqctm653 comparetotmag -0.0 -0 -> -1
+dqctm654 comparetotmag -0.0 -0.0 -> 0
+dqctm655 comparetotmag -0.0 0.0 -> 0
+
+dqctm656 comparetotmag -0E1 0.0 -> 1
+dqctm657 comparetotmag -0E2 0.0 -> 1
+dqctm658 comparetotmag 0E1 0.0 -> 1
+dqctm659 comparetotmag 0E2 0.0 -> 1
+dqctm660 comparetotmag -0E1 0 -> 1
+dqctm661 comparetotmag -0E2 0 -> 1
+dqctm662 comparetotmag 0E1 0 -> 1
+dqctm663 comparetotmag 0E2 0 -> 1
+dqctm664 comparetotmag -0E1 -0E1 -> 0
+dqctm665 comparetotmag -0E2 -0E1 -> 1
+dqctm666 comparetotmag 0E1 -0E1 -> 0
+dqctm667 comparetotmag 0E2 -0E1 -> 1
+dqctm668 comparetotmag -0E1 -0E2 -> -1
+dqctm669 comparetotmag -0E2 -0E2 -> 0
+dqctm670 comparetotmag 0E1 -0E2 -> -1
+dqctm671 comparetotmag 0E2 -0E2 -> 0
+dqctm672 comparetotmag -0E1 0E1 -> 0
+dqctm673 comparetotmag -0E2 0E1 -> 1
+dqctm674 comparetotmag 0E1 0E1 -> 0
+dqctm675 comparetotmag 0E2 0E1 -> 1
+dqctm676 comparetotmag -0E1 0E2 -> -1
+dqctm677 comparetotmag -0E2 0E2 -> 0
+dqctm678 comparetotmag 0E1 0E2 -> -1
+dqctm679 comparetotmag 0E2 0E2 -> 0
+
+-- trailing zeros; unit-y
+dqctm680 comparetotmag 12 12 -> 0
+dqctm681 comparetotmag 12 12.0 -> 1
+dqctm682 comparetotmag 12 12.00 -> 1
+dqctm683 comparetotmag 12 12.000 -> 1
+dqctm684 comparetotmag 12 12.0000 -> 1
+dqctm685 comparetotmag 12 12.00000 -> 1
+dqctm686 comparetotmag 12 12.000000 -> 1
+dqctm687 comparetotmag 12 12.0000000 -> 1
+dqctm688 comparetotmag 12 12.00000000 -> 1
+dqctm689 comparetotmag 12 12.000000000 -> 1
+dqctm690 comparetotmag 12 12 -> 0
+dqctm691 comparetotmag 12.0 12 -> -1
+dqctm692 comparetotmag 12.00 12 -> -1
+dqctm693 comparetotmag 12.000 12 -> -1
+dqctm694 comparetotmag 12.0000 12 -> -1
+dqctm695 comparetotmag 12.00000 12 -> -1
+dqctm696 comparetotmag 12.000000 12 -> -1
+dqctm697 comparetotmag 12.0000000 12 -> -1
+dqctm698 comparetotmag 12.00000000 12 -> -1
+dqctm699 comparetotmag 12.000000000 12 -> -1
+
+-- old long operand checks
+dqctm701 comparetotmag 12345678000 1 -> 1
+dqctm702 comparetotmag 1 12345678000 -> -1
+dqctm703 comparetotmag 1234567800 1 -> 1
+dqctm704 comparetotmag 1 1234567800 -> -1
+dqctm705 comparetotmag 1234567890 1 -> 1
+dqctm706 comparetotmag 1 1234567890 -> -1
+dqctm707 comparetotmag 1234567891 1 -> 1
+dqctm708 comparetotmag 1 1234567891 -> -1
+dqctm709 comparetotmag 12345678901 1 -> 1
+dqctm710 comparetotmag 1 12345678901 -> -1
+dqctm711 comparetotmag 1234567896 1 -> 1
+dqctm712 comparetotmag 1 1234567896 -> -1
+dqctm713 comparetotmag -1234567891 1 -> 1
+dqctm714 comparetotmag 1 -1234567891 -> -1
+dqctm715 comparetotmag -12345678901 1 -> 1
+dqctm716 comparetotmag 1 -12345678901 -> -1
+dqctm717 comparetotmag -1234567896 1 -> 1
+dqctm718 comparetotmag 1 -1234567896 -> -1
+
+-- old residue cases
+dqctm740 comparetotmag 1 0.9999999 -> 1
+dqctm741 comparetotmag 1 0.999999 -> 1
+dqctm742 comparetotmag 1 0.99999 -> 1
+dqctm743 comparetotmag 1 1.0000 -> 1
+dqctm744 comparetotmag 1 1.00001 -> -1
+dqctm745 comparetotmag 1 1.000001 -> -1
+dqctm746 comparetotmag 1 1.0000001 -> -1
+dqctm750 comparetotmag 0.9999999 1 -> -1
+dqctm751 comparetotmag 0.999999 1 -> -1
+dqctm752 comparetotmag 0.99999 1 -> -1
+dqctm753 comparetotmag 1.0000 1 -> -1
+dqctm754 comparetotmag 1.00001 1 -> 1
+dqctm755 comparetotmag 1.000001 1 -> 1
+dqctm756 comparetotmag 1.0000001 1 -> 1
+
+-- Specials
+dqctm780 comparetotmag Inf -Inf -> 0
+dqctm781 comparetotmag Inf -1000 -> 1
+dqctm782 comparetotmag Inf -1 -> 1
+dqctm783 comparetotmag Inf -0 -> 1
+dqctm784 comparetotmag Inf 0 -> 1
+dqctm785 comparetotmag Inf 1 -> 1
+dqctm786 comparetotmag Inf 1000 -> 1
+dqctm787 comparetotmag Inf Inf -> 0
+dqctm788 comparetotmag -1000 Inf -> -1
+dqctm789 comparetotmag -Inf Inf -> 0
+dqctm790 comparetotmag -1 Inf -> -1
+dqctm791 comparetotmag -0 Inf -> -1
+dqctm792 comparetotmag 0 Inf -> -1
+dqctm793 comparetotmag 1 Inf -> -1
+dqctm794 comparetotmag 1000 Inf -> -1
+dqctm795 comparetotmag Inf Inf -> 0
+
+dqctm800 comparetotmag -Inf -Inf -> 0
+dqctm801 comparetotmag -Inf -1000 -> 1
+dqctm802 comparetotmag -Inf -1 -> 1
+dqctm803 comparetotmag -Inf -0 -> 1
+dqctm804 comparetotmag -Inf 0 -> 1
+dqctm805 comparetotmag -Inf 1 -> 1
+dqctm806 comparetotmag -Inf 1000 -> 1
+dqctm807 comparetotmag -Inf Inf -> 0
+dqctm808 comparetotmag -Inf -Inf -> 0
+dqctm809 comparetotmag -1000 -Inf -> -1
+dqctm810 comparetotmag -1 -Inf -> -1
+dqctm811 comparetotmag -0 -Inf -> -1
+dqctm812 comparetotmag 0 -Inf -> -1
+dqctm813 comparetotmag 1 -Inf -> -1
+dqctm814 comparetotmag 1000 -Inf -> -1
+dqctm815 comparetotmag Inf -Inf -> 0
+
+dqctm821 comparetotmag NaN -Inf -> 1
+dqctm822 comparetotmag NaN -1000 -> 1
+dqctm823 comparetotmag NaN -1 -> 1
+dqctm824 comparetotmag NaN -0 -> 1
+dqctm825 comparetotmag NaN 0 -> 1
+dqctm826 comparetotmag NaN 1 -> 1
+dqctm827 comparetotmag NaN 1000 -> 1
+dqctm828 comparetotmag NaN Inf -> 1
+dqctm829 comparetotmag NaN NaN -> 0
+dqctm830 comparetotmag -Inf NaN -> -1
+dqctm831 comparetotmag -1000 NaN -> -1
+dqctm832 comparetotmag -1 NaN -> -1
+dqctm833 comparetotmag -0 NaN -> -1
+dqctm834 comparetotmag 0 NaN -> -1
+dqctm835 comparetotmag 1 NaN -> -1
+dqctm836 comparetotmag 1000 NaN -> -1
+dqctm837 comparetotmag Inf NaN -> -1
+dqctm838 comparetotmag -NaN -NaN -> 0
+dqctm839 comparetotmag +NaN -NaN -> 0
+dqctm840 comparetotmag -NaN +NaN -> 0
+
+dqctm841 comparetotmag sNaN -sNaN -> 0
+dqctm842 comparetotmag sNaN -NaN -> -1
+dqctm843 comparetotmag sNaN -Inf -> 1
+dqctm844 comparetotmag sNaN -1000 -> 1
+dqctm845 comparetotmag sNaN -1 -> 1
+dqctm846 comparetotmag sNaN -0 -> 1
+dqctm847 comparetotmag sNaN 0 -> 1
+dqctm848 comparetotmag sNaN 1 -> 1
+dqctm849 comparetotmag sNaN 1000 -> 1
+dqctm850 comparetotmag sNaN NaN -> -1
+dqctm851 comparetotmag sNaN sNaN -> 0
+
+dqctm852 comparetotmag -sNaN sNaN -> 0
+dqctm853 comparetotmag -NaN sNaN -> 1
+dqctm854 comparetotmag -Inf sNaN -> -1
+dqctm855 comparetotmag -1000 sNaN -> -1
+dqctm856 comparetotmag -1 sNaN -> -1
+dqctm857 comparetotmag -0 sNaN -> -1
+dqctm858 comparetotmag 0 sNaN -> -1
+dqctm859 comparetotmag 1 sNaN -> -1
+dqctm860 comparetotmag 1000 sNaN -> -1
+dqctm861 comparetotmag Inf sNaN -> -1
+dqctm862 comparetotmag NaN sNaN -> 1
+dqctm863 comparetotmag sNaN sNaN -> 0
+
+dqctm871 comparetotmag -sNaN -sNaN -> 0
+dqctm872 comparetotmag -sNaN -NaN -> -1
+dqctm873 comparetotmag -sNaN -Inf -> 1
+dqctm874 comparetotmag -sNaN -1000 -> 1
+dqctm875 comparetotmag -sNaN -1 -> 1
+dqctm876 comparetotmag -sNaN -0 -> 1
+dqctm877 comparetotmag -sNaN 0 -> 1
+dqctm878 comparetotmag -sNaN 1 -> 1
+dqctm879 comparetotmag -sNaN 1000 -> 1
+dqctm880 comparetotmag -sNaN NaN -> -1
+dqctm881 comparetotmag -sNaN sNaN -> 0
+
+dqctm882 comparetotmag -sNaN -sNaN -> 0
+dqctm883 comparetotmag -NaN -sNaN -> 1
+dqctm884 comparetotmag -Inf -sNaN -> -1
+dqctm885 comparetotmag -1000 -sNaN -> -1
+dqctm886 comparetotmag -1 -sNaN -> -1
+dqctm887 comparetotmag -0 -sNaN -> -1
+dqctm888 comparetotmag 0 -sNaN -> -1
+dqctm889 comparetotmag 1 -sNaN -> -1
+dqctm890 comparetotmag 1000 -sNaN -> -1
+dqctm891 comparetotmag Inf -sNaN -> -1
+dqctm892 comparetotmag NaN -sNaN -> 1
+dqctm893 comparetotmag sNaN -sNaN -> 0
+
+-- NaNs with payload
+dqctm960 comparetotmag NaN9 -Inf -> 1
+dqctm961 comparetotmag NaN8 999 -> 1
+dqctm962 comparetotmag NaN77 Inf -> 1
+dqctm963 comparetotmag -NaN67 NaN5 -> 1
+dqctm964 comparetotmag -Inf -NaN4 -> -1
+dqctm965 comparetotmag -999 -NaN33 -> -1
+dqctm966 comparetotmag Inf NaN2 -> -1
+
+dqctm970 comparetotmag -NaN41 -NaN42 -> -1
+dqctm971 comparetotmag +NaN41 -NaN42 -> -1
+dqctm972 comparetotmag -NaN41 +NaN42 -> -1
+dqctm973 comparetotmag +NaN41 +NaN42 -> -1
+dqctm974 comparetotmag -NaN42 -NaN01 -> 1
+dqctm975 comparetotmag +NaN42 -NaN01 -> 1
+dqctm976 comparetotmag -NaN42 +NaN01 -> 1
+dqctm977 comparetotmag +NaN42 +NaN01 -> 1
+
+dqctm980 comparetotmag -sNaN771 -sNaN772 -> -1
+dqctm981 comparetotmag +sNaN771 -sNaN772 -> -1
+dqctm982 comparetotmag -sNaN771 +sNaN772 -> -1
+dqctm983 comparetotmag +sNaN771 +sNaN772 -> -1
+dqctm984 comparetotmag -sNaN772 -sNaN771 -> 1
+dqctm985 comparetotmag +sNaN772 -sNaN771 -> 1
+dqctm986 comparetotmag -sNaN772 +sNaN771 -> 1
+dqctm987 comparetotmag +sNaN772 +sNaN771 -> 1
+
+dqctm991 comparetotmag -sNaN99 -Inf -> 1
+dqctm992 comparetotmag sNaN98 -11 -> 1
+dqctm993 comparetotmag sNaN97 NaN -> -1
+dqctm994 comparetotmag sNaN16 sNaN94 -> -1
+dqctm995 comparetotmag NaN85 sNaN83 -> 1
+dqctm996 comparetotmag -Inf sNaN92 -> -1
+dqctm997 comparetotmag 088 sNaN81 -> -1
+dqctm998 comparetotmag Inf sNaN90 -> -1
+dqctm999 comparetotmag NaN -sNaN89 -> 1
+
+-- spread zeros
+dqctm1110 comparetotmag 0E-6143 0 -> -1
+dqctm1111 comparetotmag 0E-6143 -0 -> -1
+dqctm1112 comparetotmag -0E-6143 0 -> -1
+dqctm1113 comparetotmag -0E-6143 -0 -> -1
+dqctm1114 comparetotmag 0E-6143 0E+6144 -> -1
+dqctm1115 comparetotmag 0E-6143 -0E+6144 -> -1
+dqctm1116 comparetotmag -0E-6143 0E+6144 -> -1
+dqctm1117 comparetotmag -0E-6143 -0E+6144 -> -1
+dqctm1118 comparetotmag 0 0E+6144 -> -1
+dqctm1119 comparetotmag 0 -0E+6144 -> -1
+dqctm1120 comparetotmag -0 0E+6144 -> -1
+dqctm1121 comparetotmag -0 -0E+6144 -> -1
+
+dqctm1130 comparetotmag 0E+6144 0 -> 1
+dqctm1131 comparetotmag 0E+6144 -0 -> 1
+dqctm1132 comparetotmag -0E+6144 0 -> 1
+dqctm1133 comparetotmag -0E+6144 -0 -> 1
+dqctm1134 comparetotmag 0E+6144 0E-6143 -> 1
+dqctm1135 comparetotmag 0E+6144 -0E-6143 -> 1
+dqctm1136 comparetotmag -0E+6144 0E-6143 -> 1
+dqctm1137 comparetotmag -0E+6144 -0E-6143 -> 1
+dqctm1138 comparetotmag 0 0E-6143 -> 1
+dqctm1139 comparetotmag 0 -0E-6143 -> 1
+dqctm1140 comparetotmag -0 0E-6143 -> 1
+dqctm1141 comparetotmag -0 -0E-6143 -> 1
+
+-- Null tests
+dqctm9990 comparetotmag 10 # -> NaN Invalid_operation
+dqctm9991 comparetotmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqCopy.decTest b/Lib/test/decimaltestdata/dqCopy.decTest
index 0c6243158f2..7254d68bb7e 100644
--- a/Lib/test/decimaltestdata/dqCopy.decTest
+++ b/Lib/test/decimaltestdata/dqCopy.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopy.decTest -- quiet decQuad copy --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpy001 copy +7.50 -> 7.50
-
--- Infinities
-dqcpy011 copy Infinity -> Infinity
-dqcpy012 copy -Infinity -> -Infinity
-
--- NaNs, 0 payload
-dqcpy021 copy NaN -> NaN
-dqcpy022 copy -NaN -> -NaN
-dqcpy023 copy sNaN -> sNaN
-dqcpy024 copy -sNaN -> -sNaN
-
--- NaNs, non-0 payload
-dqcpy031 copy NaN10 -> NaN10
-dqcpy032 copy -NaN10 -> -NaN10
-dqcpy033 copy sNaN10 -> sNaN10
-dqcpy034 copy -sNaN10 -> -sNaN10
-dqcpy035 copy NaN7 -> NaN7
-dqcpy036 copy -NaN7 -> -NaN7
-dqcpy037 copy sNaN101 -> sNaN101
-dqcpy038 copy -sNaN101 -> -sNaN101
-
--- finites
-dqcpy101 copy 7 -> 7
-dqcpy102 copy -7 -> -7
-dqcpy103 copy 75 -> 75
-dqcpy104 copy -75 -> -75
-dqcpy105 copy 7.50 -> 7.50
-dqcpy106 copy -7.50 -> -7.50
-dqcpy107 copy 7.500 -> 7.500
-dqcpy108 copy -7.500 -> -7.500
-
--- zeros
-dqcpy111 copy 0 -> 0
-dqcpy112 copy -0 -> -0
-dqcpy113 copy 0E+4 -> 0E+4
-dqcpy114 copy -0E+4 -> -0E+4
-dqcpy115 copy 0.0000 -> 0.0000
-dqcpy116 copy -0.0000 -> -0.0000
-dqcpy117 copy 0E-141 -> 0E-141
-dqcpy118 copy -0E-141 -> -0E-141
-
--- full coefficients, alternating bits
-dqcpy121 copy 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpy122 copy -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqcpy123 copy 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqcpy124 copy -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpy131 copy 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqcpy132 copy 1E-6143 -> 1E-6143
-dqcpy133 copy 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpy134 copy 1E-6176 -> 1E-6176
-
-dqcpy135 copy -1E-6176 -> -1E-6176
-dqcpy136 copy -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqcpy137 copy -1E-6143 -> -1E-6143
-dqcpy138 copy -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopy.decTest -- quiet decQuad copy --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpy001 copy +7.50 -> 7.50
+
+-- Infinities
+dqcpy011 copy Infinity -> Infinity
+dqcpy012 copy -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+dqcpy021 copy NaN -> NaN
+dqcpy022 copy -NaN -> -NaN
+dqcpy023 copy sNaN -> sNaN
+dqcpy024 copy -sNaN -> -sNaN
+
+-- NaNs, non-0 payload
+dqcpy031 copy NaN10 -> NaN10
+dqcpy032 copy -NaN10 -> -NaN10
+dqcpy033 copy sNaN10 -> sNaN10
+dqcpy034 copy -sNaN10 -> -sNaN10
+dqcpy035 copy NaN7 -> NaN7
+dqcpy036 copy -NaN7 -> -NaN7
+dqcpy037 copy sNaN101 -> sNaN101
+dqcpy038 copy -sNaN101 -> -sNaN101
+
+-- finites
+dqcpy101 copy 7 -> 7
+dqcpy102 copy -7 -> -7
+dqcpy103 copy 75 -> 75
+dqcpy104 copy -75 -> -75
+dqcpy105 copy 7.50 -> 7.50
+dqcpy106 copy -7.50 -> -7.50
+dqcpy107 copy 7.500 -> 7.500
+dqcpy108 copy -7.500 -> -7.500
+
+-- zeros
+dqcpy111 copy 0 -> 0
+dqcpy112 copy -0 -> -0
+dqcpy113 copy 0E+4 -> 0E+4
+dqcpy114 copy -0E+4 -> -0E+4
+dqcpy115 copy 0.0000 -> 0.0000
+dqcpy116 copy -0.0000 -> -0.0000
+dqcpy117 copy 0E-141 -> 0E-141
+dqcpy118 copy -0E-141 -> -0E-141
+
+-- full coefficients, alternating bits
+dqcpy121 copy 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpy122 copy -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqcpy123 copy 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqcpy124 copy -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpy131 copy 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqcpy132 copy 1E-6143 -> 1E-6143
+dqcpy133 copy 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpy134 copy 1E-6176 -> 1E-6176
+
+dqcpy135 copy -1E-6176 -> -1E-6176
+dqcpy136 copy -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqcpy137 copy -1E-6143 -> -1E-6143
+dqcpy138 copy -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopyAbs.decTest b/Lib/test/decimaltestdata/dqCopyAbs.decTest
index 16bcb4eaedb..bdec0206dee 100644
--- a/Lib/test/decimaltestdata/dqCopyAbs.decTest
+++ b/Lib/test/decimaltestdata/dqCopyAbs.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopyAbs.decTest -- quiet decQuad copy and set sign to zero --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpa001 copyabs +7.50 -> 7.50
-
--- Infinities
-dqcpa011 copyabs Infinity -> Infinity
-dqcpa012 copyabs -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqcpa021 copyabs NaN -> NaN
-dqcpa022 copyabs -NaN -> NaN
-dqcpa023 copyabs sNaN -> sNaN
-dqcpa024 copyabs -sNaN -> sNaN
-
--- NaNs, non-0 payload
-dqcpa031 copyabs NaN10 -> NaN10
-dqcpa032 copyabs -NaN15 -> NaN15
-dqcpa033 copyabs sNaN15 -> sNaN15
-dqcpa034 copyabs -sNaN10 -> sNaN10
-dqcpa035 copyabs NaN7 -> NaN7
-dqcpa036 copyabs -NaN7 -> NaN7
-dqcpa037 copyabs sNaN101 -> sNaN101
-dqcpa038 copyabs -sNaN101 -> sNaN101
-
--- finites
-dqcpa101 copyabs 7 -> 7
-dqcpa102 copyabs -7 -> 7
-dqcpa103 copyabs 75 -> 75
-dqcpa104 copyabs -75 -> 75
-dqcpa105 copyabs 7.10 -> 7.10
-dqcpa106 copyabs -7.10 -> 7.10
-dqcpa107 copyabs 7.500 -> 7.500
-dqcpa108 copyabs -7.500 -> 7.500
-
--- zeros
-dqcpa111 copyabs 0 -> 0
-dqcpa112 copyabs -0 -> 0
-dqcpa113 copyabs 0E+6 -> 0E+6
-dqcpa114 copyabs -0E+6 -> 0E+6
-dqcpa115 copyabs 0.0000 -> 0.0000
-dqcpa116 copyabs -0.0000 -> 0.0000
-dqcpa117 copyabs 0E-141 -> 0E-141
-dqcpa118 copyabs -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqcpa121 copyabs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpa122 copyabs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpa123 copyabs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqcpa124 copyabs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpa131 copyabs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqcpa132 copyabs 1E-6143 -> 1E-6143
-dqcpa133 copyabs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpa134 copyabs 1E-6176 -> 1E-6176
-
-dqcpa135 copyabs -1E-6176 -> 1E-6176
-dqcpa136 copyabs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpa137 copyabs -1E-6143 -> 1E-6143
-dqcpa138 copyabs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopyAbs.decTest -- quiet decQuad copy and set sign to zero --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpa001 copyabs +7.50 -> 7.50
+
+-- Infinities
+dqcpa011 copyabs Infinity -> Infinity
+dqcpa012 copyabs -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqcpa021 copyabs NaN -> NaN
+dqcpa022 copyabs -NaN -> NaN
+dqcpa023 copyabs sNaN -> sNaN
+dqcpa024 copyabs -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+dqcpa031 copyabs NaN10 -> NaN10
+dqcpa032 copyabs -NaN15 -> NaN15
+dqcpa033 copyabs sNaN15 -> sNaN15
+dqcpa034 copyabs -sNaN10 -> sNaN10
+dqcpa035 copyabs NaN7 -> NaN7
+dqcpa036 copyabs -NaN7 -> NaN7
+dqcpa037 copyabs sNaN101 -> sNaN101
+dqcpa038 copyabs -sNaN101 -> sNaN101
+
+-- finites
+dqcpa101 copyabs 7 -> 7
+dqcpa102 copyabs -7 -> 7
+dqcpa103 copyabs 75 -> 75
+dqcpa104 copyabs -75 -> 75
+dqcpa105 copyabs 7.10 -> 7.10
+dqcpa106 copyabs -7.10 -> 7.10
+dqcpa107 copyabs 7.500 -> 7.500
+dqcpa108 copyabs -7.500 -> 7.500
+
+-- zeros
+dqcpa111 copyabs 0 -> 0
+dqcpa112 copyabs -0 -> 0
+dqcpa113 copyabs 0E+6 -> 0E+6
+dqcpa114 copyabs -0E+6 -> 0E+6
+dqcpa115 copyabs 0.0000 -> 0.0000
+dqcpa116 copyabs -0.0000 -> 0.0000
+dqcpa117 copyabs 0E-141 -> 0E-141
+dqcpa118 copyabs -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcpa121 copyabs 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpa122 copyabs -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpa123 copyabs 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqcpa124 copyabs -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpa131 copyabs 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqcpa132 copyabs 1E-6143 -> 1E-6143
+dqcpa133 copyabs 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpa134 copyabs 1E-6176 -> 1E-6176
+
+dqcpa135 copyabs -1E-6176 -> 1E-6176
+dqcpa136 copyabs -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpa137 copyabs -1E-6143 -> 1E-6143
+dqcpa138 copyabs -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopyNegate.decTest b/Lib/test/decimaltestdata/dqCopyNegate.decTest
index 6253f5a3558..ea008557724 100644
--- a/Lib/test/decimaltestdata/dqCopyNegate.decTest
+++ b/Lib/test/decimaltestdata/dqCopyNegate.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqCopyNegate.decTest -- quiet decQuad copy and negate --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcpn001 copynegate +7.50 -> -7.50
-
--- Infinities
-dqcpn011 copynegate Infinity -> -Infinity
-dqcpn012 copynegate -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqcpn021 copynegate NaN -> -NaN
-dqcpn022 copynegate -NaN -> NaN
-dqcpn023 copynegate sNaN -> -sNaN
-dqcpn024 copynegate -sNaN -> sNaN
-
--- NaNs, non-0 payload
-dqcpn031 copynegate NaN13 -> -NaN13
-dqcpn032 copynegate -NaN13 -> NaN13
-dqcpn033 copynegate sNaN13 -> -sNaN13
-dqcpn034 copynegate -sNaN13 -> sNaN13
-dqcpn035 copynegate NaN70 -> -NaN70
-dqcpn036 copynegate -NaN70 -> NaN70
-dqcpn037 copynegate sNaN101 -> -sNaN101
-dqcpn038 copynegate -sNaN101 -> sNaN101
-
--- finites
-dqcpn101 copynegate 7 -> -7
-dqcpn102 copynegate -7 -> 7
-dqcpn103 copynegate 75 -> -75
-dqcpn104 copynegate -75 -> 75
-dqcpn105 copynegate 7.50 -> -7.50
-dqcpn106 copynegate -7.50 -> 7.50
-dqcpn107 copynegate 7.500 -> -7.500
-dqcpn108 copynegate -7.500 -> 7.500
-
--- zeros
-dqcpn111 copynegate 0 -> -0
-dqcpn112 copynegate -0 -> 0
-dqcpn113 copynegate 0E+4 -> -0E+4
-dqcpn114 copynegate -0E+4 -> 0E+4
-dqcpn115 copynegate 0.0000 -> -0.0000
-dqcpn116 copynegate -0.0000 -> 0.0000
-dqcpn117 copynegate 0E-141 -> -0E-141
-dqcpn118 copynegate -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqcpn121 copynegate 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqcpn122 copynegate -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqcpn123 copynegate 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-dqcpn124 copynegate -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcpn131 copynegate 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqcpn132 copynegate 1E-6143 -> -1E-6143
-dqcpn133 copynegate 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqcpn134 copynegate 1E-6176 -> -1E-6176
-
-dqcpn135 copynegate -1E-6176 -> 1E-6176
-dqcpn136 copynegate -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqcpn137 copynegate -1E-6143 -> 1E-6143
-dqcpn138 copynegate -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqCopyNegate.decTest -- quiet decQuad copy and negate --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcpn001 copynegate +7.50 -> -7.50
+
+-- Infinities
+dqcpn011 copynegate Infinity -> -Infinity
+dqcpn012 copynegate -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqcpn021 copynegate NaN -> -NaN
+dqcpn022 copynegate -NaN -> NaN
+dqcpn023 copynegate sNaN -> -sNaN
+dqcpn024 copynegate -sNaN -> sNaN
+
+-- NaNs, non-0 payload
+dqcpn031 copynegate NaN13 -> -NaN13
+dqcpn032 copynegate -NaN13 -> NaN13
+dqcpn033 copynegate sNaN13 -> -sNaN13
+dqcpn034 copynegate -sNaN13 -> sNaN13
+dqcpn035 copynegate NaN70 -> -NaN70
+dqcpn036 copynegate -NaN70 -> NaN70
+dqcpn037 copynegate sNaN101 -> -sNaN101
+dqcpn038 copynegate -sNaN101 -> sNaN101
+
+-- finites
+dqcpn101 copynegate 7 -> -7
+dqcpn102 copynegate -7 -> 7
+dqcpn103 copynegate 75 -> -75
+dqcpn104 copynegate -75 -> 75
+dqcpn105 copynegate 7.50 -> -7.50
+dqcpn106 copynegate -7.50 -> 7.50
+dqcpn107 copynegate 7.500 -> -7.500
+dqcpn108 copynegate -7.500 -> 7.500
+
+-- zeros
+dqcpn111 copynegate 0 -> -0
+dqcpn112 copynegate -0 -> 0
+dqcpn113 copynegate 0E+4 -> -0E+4
+dqcpn114 copynegate -0E+4 -> 0E+4
+dqcpn115 copynegate 0.0000 -> -0.0000
+dqcpn116 copynegate -0.0000 -> 0.0000
+dqcpn117 copynegate 0E-141 -> -0E-141
+dqcpn118 copynegate -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcpn121 copynegate 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqcpn122 copynegate -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqcpn123 copynegate 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+dqcpn124 copynegate -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcpn131 copynegate 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqcpn132 copynegate 1E-6143 -> -1E-6143
+dqcpn133 copynegate 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqcpn134 copynegate 1E-6176 -> -1E-6176
+
+dqcpn135 copynegate -1E-6176 -> 1E-6176
+dqcpn136 copynegate -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqcpn137 copynegate -1E-6143 -> 1E-6143
+dqcpn138 copynegate -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqCopySign.decTest b/Lib/test/decimaltestdata/dqCopySign.decTest
index 97b5e6e955e..ce794b7c35c 100644
--- a/Lib/test/decimaltestdata/dqCopySign.decTest
+++ b/Lib/test/decimaltestdata/dqCopySign.decTest
@@ -1,175 +1,175 @@
-------------------------------------------------------------------------
--- dqCopySign.decTest -- quiet decQuad copy with sign from rhs --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqcps001 copysign +7.50 11 -> 7.50
-
--- Infinities
-dqcps011 copysign Infinity 11 -> Infinity
-dqcps012 copysign -Infinity 11 -> Infinity
-
--- NaNs, 0 payload
-dqcps021 copysign NaN 11 -> NaN
-dqcps022 copysign -NaN 11 -> NaN
-dqcps023 copysign sNaN 11 -> sNaN
-dqcps024 copysign -sNaN 11 -> sNaN
-
--- NaNs, non-0 payload
-dqcps031 copysign NaN10 11 -> NaN10
-dqcps032 copysign -NaN10 11 -> NaN10
-dqcps033 copysign sNaN10 11 -> sNaN10
-dqcps034 copysign -sNaN10 11 -> sNaN10
-dqcps035 copysign NaN7 11 -> NaN7
-dqcps036 copysign -NaN7 11 -> NaN7
-dqcps037 copysign sNaN101 11 -> sNaN101
-dqcps038 copysign -sNaN101 11 -> sNaN101
-
--- finites
-dqcps101 copysign 7 11 -> 7
-dqcps102 copysign -7 11 -> 7
-dqcps103 copysign 75 11 -> 75
-dqcps104 copysign -75 11 -> 75
-dqcps105 copysign 7.50 11 -> 7.50
-dqcps106 copysign -7.50 11 -> 7.50
-dqcps107 copysign 7.500 11 -> 7.500
-dqcps108 copysign -7.500 11 -> 7.500
-
--- zeros
-dqcps111 copysign 0 11 -> 0
-dqcps112 copysign -0 11 -> 0
-dqcps113 copysign 0E+4 11 -> 0E+4
-dqcps114 copysign -0E+4 11 -> 0E+4
-dqcps115 copysign 0.0000 11 -> 0.0000
-dqcps116 copysign -0.0000 11 -> 0.0000
-dqcps117 copysign 0E-141 11 -> 0E-141
-dqcps118 copysign -0E-141 11 -> 0E-141
-
--- full coefficients, alternating bits
-dqcps121 copysign 2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
-dqcps122 copysign -2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
-dqcps123 copysign 1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
-dqcps124 copysign -1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcps131 copysign 9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
-dqcps132 copysign 1E-6143 8 -> 1E-6143
-dqcps133 copysign 1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
-dqcps134 copysign 1E-6176 8 -> 1E-6176
-
-dqcps135 copysign -1E-6176 8 -> 1E-6176
-dqcps136 copysign -1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
-dqcps137 copysign -1E-6143 8 -> 1E-6143
-dqcps138 copysign -9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
-
--- repeat with negative RHS
-
--- Infinities
-dqcps211 copysign Infinity -34 -> -Infinity
-dqcps212 copysign -Infinity -34 -> -Infinity
-
--- NaNs, 0 payload
-dqcps221 copysign NaN -34 -> -NaN
-dqcps222 copysign -NaN -34 -> -NaN
-dqcps223 copysign sNaN -34 -> -sNaN
-dqcps224 copysign -sNaN -34 -> -sNaN
-
--- NaNs, non-0 payload
-dqcps231 copysign NaN10 -34 -> -NaN10
-dqcps232 copysign -NaN10 -34 -> -NaN10
-dqcps233 copysign sNaN10 -34 -> -sNaN10
-dqcps234 copysign -sNaN10 -34 -> -sNaN10
-dqcps235 copysign NaN7 -34 -> -NaN7
-dqcps236 copysign -NaN7 -34 -> -NaN7
-dqcps237 copysign sNaN101 -34 -> -sNaN101
-dqcps238 copysign -sNaN101 -34 -> -sNaN101
-
--- finites
-dqcps301 copysign 7 -34 -> -7
-dqcps302 copysign -7 -34 -> -7
-dqcps303 copysign 75 -34 -> -75
-dqcps304 copysign -75 -34 -> -75
-dqcps305 copysign 7.50 -34 -> -7.50
-dqcps306 copysign -7.50 -34 -> -7.50
-dqcps307 copysign 7.500 -34 -> -7.500
-dqcps308 copysign -7.500 -34 -> -7.500
-
--- zeros
-dqcps311 copysign 0 -34 -> -0
-dqcps312 copysign -0 -34 -> -0
-dqcps313 copysign 0E+4 -34 -> -0E+4
-dqcps314 copysign -0E+4 -34 -> -0E+4
-dqcps315 copysign 0.0000 -34 -> -0.0000
-dqcps316 copysign -0.0000 -34 -> -0.0000
-dqcps317 copysign 0E-141 -34 -> -0E-141
-dqcps318 copysign -0E-141 -34 -> -0E-141
-
--- full coefficients, alternating bits
-dqcps321 copysign 2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
-dqcps322 copysign -2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
-dqcps323 copysign 1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
-dqcps324 copysign -1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqcps331 copysign 9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
-dqcps332 copysign 1E-6143 -1 -> -1E-6143
-dqcps333 copysign 1.000000000000000000000000000000000E-6143 -1 -> -1.000000000000000000000000000000000E-6143
-dqcps334 copysign 1E-6176 -1 -> -1E-6176
-
-dqcps335 copysign -1E-6176 -3 -> -1E-6176
-dqcps336 copysign -1.000000000000000000000000000000000E-6143 -3 -> -1.000000000000000000000000000000000E-6143
-dqcps337 copysign -1E-6143 -3 -> -1E-6143
-dqcps338 copysign -9.999999999999999999999999999999999E+6144 -3 -> -9.999999999999999999999999999999999E+6144
-
--- Other kinds of RHS
-dqcps401 copysign 701 -34 -> -701
-dqcps402 copysign -720 -34 -> -720
-dqcps403 copysign 701 -0 -> -701
-dqcps404 copysign -720 -0 -> -720
-dqcps405 copysign 701 +0 -> 701
-dqcps406 copysign -720 +0 -> 720
-dqcps407 copysign 701 +34 -> 701
-dqcps408 copysign -720 +34 -> 720
-
-dqcps413 copysign 701 -Inf -> -701
-dqcps414 copysign -720 -Inf -> -720
-dqcps415 copysign 701 +Inf -> 701
-dqcps416 copysign -720 +Inf -> 720
-
-dqcps420 copysign 701 -NaN -> -701
-dqcps421 copysign -720 -NaN -> -720
-dqcps422 copysign 701 +NaN -> 701
-dqcps423 copysign -720 +NaN -> 720
-dqcps425 copysign -720 +NaN8 -> 720
-
-dqcps426 copysign 701 -sNaN -> -701
-dqcps427 copysign -720 -sNaN -> -720
-dqcps428 copysign 701 +sNaN -> 701
-dqcps429 copysign -720 +sNaN -> 720
-dqcps430 copysign -720 +sNaN3 -> 720
-
+------------------------------------------------------------------------
+-- dqCopySign.decTest -- quiet decQuad copy with sign from rhs --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqcps001 copysign +7.50 11 -> 7.50
+
+-- Infinities
+dqcps011 copysign Infinity 11 -> Infinity
+dqcps012 copysign -Infinity 11 -> Infinity
+
+-- NaNs, 0 payload
+dqcps021 copysign NaN 11 -> NaN
+dqcps022 copysign -NaN 11 -> NaN
+dqcps023 copysign sNaN 11 -> sNaN
+dqcps024 copysign -sNaN 11 -> sNaN
+
+-- NaNs, non-0 payload
+dqcps031 copysign NaN10 11 -> NaN10
+dqcps032 copysign -NaN10 11 -> NaN10
+dqcps033 copysign sNaN10 11 -> sNaN10
+dqcps034 copysign -sNaN10 11 -> sNaN10
+dqcps035 copysign NaN7 11 -> NaN7
+dqcps036 copysign -NaN7 11 -> NaN7
+dqcps037 copysign sNaN101 11 -> sNaN101
+dqcps038 copysign -sNaN101 11 -> sNaN101
+
+-- finites
+dqcps101 copysign 7 11 -> 7
+dqcps102 copysign -7 11 -> 7
+dqcps103 copysign 75 11 -> 75
+dqcps104 copysign -75 11 -> 75
+dqcps105 copysign 7.50 11 -> 7.50
+dqcps106 copysign -7.50 11 -> 7.50
+dqcps107 copysign 7.500 11 -> 7.500
+dqcps108 copysign -7.500 11 -> 7.500
+
+-- zeros
+dqcps111 copysign 0 11 -> 0
+dqcps112 copysign -0 11 -> 0
+dqcps113 copysign 0E+4 11 -> 0E+4
+dqcps114 copysign -0E+4 11 -> 0E+4
+dqcps115 copysign 0.0000 11 -> 0.0000
+dqcps116 copysign -0.0000 11 -> 0.0000
+dqcps117 copysign 0E-141 11 -> 0E-141
+dqcps118 copysign -0E-141 11 -> 0E-141
+
+-- full coefficients, alternating bits
+dqcps121 copysign 2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
+dqcps122 copysign -2682682682682682682682682682682682 8 -> 2682682682682682682682682682682682
+dqcps123 copysign 1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
+dqcps124 copysign -1341341341341341341341341341341341 8 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcps131 copysign 9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
+dqcps132 copysign 1E-6143 8 -> 1E-6143
+dqcps133 copysign 1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
+dqcps134 copysign 1E-6176 8 -> 1E-6176
+
+dqcps135 copysign -1E-6176 8 -> 1E-6176
+dqcps136 copysign -1.000000000000000000000000000000000E-6143 8 -> 1.000000000000000000000000000000000E-6143
+dqcps137 copysign -1E-6143 8 -> 1E-6143
+dqcps138 copysign -9.999999999999999999999999999999999E+6144 8 -> 9.999999999999999999999999999999999E+6144
+
+-- repeat with negative RHS
+
+-- Infinities
+dqcps211 copysign Infinity -34 -> -Infinity
+dqcps212 copysign -Infinity -34 -> -Infinity
+
+-- NaNs, 0 payload
+dqcps221 copysign NaN -34 -> -NaN
+dqcps222 copysign -NaN -34 -> -NaN
+dqcps223 copysign sNaN -34 -> -sNaN
+dqcps224 copysign -sNaN -34 -> -sNaN
+
+-- NaNs, non-0 payload
+dqcps231 copysign NaN10 -34 -> -NaN10
+dqcps232 copysign -NaN10 -34 -> -NaN10
+dqcps233 copysign sNaN10 -34 -> -sNaN10
+dqcps234 copysign -sNaN10 -34 -> -sNaN10
+dqcps235 copysign NaN7 -34 -> -NaN7
+dqcps236 copysign -NaN7 -34 -> -NaN7
+dqcps237 copysign sNaN101 -34 -> -sNaN101
+dqcps238 copysign -sNaN101 -34 -> -sNaN101
+
+-- finites
+dqcps301 copysign 7 -34 -> -7
+dqcps302 copysign -7 -34 -> -7
+dqcps303 copysign 75 -34 -> -75
+dqcps304 copysign -75 -34 -> -75
+dqcps305 copysign 7.50 -34 -> -7.50
+dqcps306 copysign -7.50 -34 -> -7.50
+dqcps307 copysign 7.500 -34 -> -7.500
+dqcps308 copysign -7.500 -34 -> -7.500
+
+-- zeros
+dqcps311 copysign 0 -34 -> -0
+dqcps312 copysign -0 -34 -> -0
+dqcps313 copysign 0E+4 -34 -> -0E+4
+dqcps314 copysign -0E+4 -34 -> -0E+4
+dqcps315 copysign 0.0000 -34 -> -0.0000
+dqcps316 copysign -0.0000 -34 -> -0.0000
+dqcps317 copysign 0E-141 -34 -> -0E-141
+dqcps318 copysign -0E-141 -34 -> -0E-141
+
+-- full coefficients, alternating bits
+dqcps321 copysign 2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
+dqcps322 copysign -2682682682682682682682682682682682 -9 -> -2682682682682682682682682682682682
+dqcps323 copysign 1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
+dqcps324 copysign -1341341341341341341341341341341341 -9 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqcps331 copysign 9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
+dqcps332 copysign 1E-6143 -1 -> -1E-6143
+dqcps333 copysign 1.000000000000000000000000000000000E-6143 -1 -> -1.000000000000000000000000000000000E-6143
+dqcps334 copysign 1E-6176 -1 -> -1E-6176
+
+dqcps335 copysign -1E-6176 -3 -> -1E-6176
+dqcps336 copysign -1.000000000000000000000000000000000E-6143 -3 -> -1.000000000000000000000000000000000E-6143
+dqcps337 copysign -1E-6143 -3 -> -1E-6143
+dqcps338 copysign -9.999999999999999999999999999999999E+6144 -3 -> -9.999999999999999999999999999999999E+6144
+
+-- Other kinds of RHS
+dqcps401 copysign 701 -34 -> -701
+dqcps402 copysign -720 -34 -> -720
+dqcps403 copysign 701 -0 -> -701
+dqcps404 copysign -720 -0 -> -720
+dqcps405 copysign 701 +0 -> 701
+dqcps406 copysign -720 +0 -> 720
+dqcps407 copysign 701 +34 -> 701
+dqcps408 copysign -720 +34 -> 720
+
+dqcps413 copysign 701 -Inf -> -701
+dqcps414 copysign -720 -Inf -> -720
+dqcps415 copysign 701 +Inf -> 701
+dqcps416 copysign -720 +Inf -> 720
+
+dqcps420 copysign 701 -NaN -> -701
+dqcps421 copysign -720 -NaN -> -720
+dqcps422 copysign 701 +NaN -> 701
+dqcps423 copysign -720 +NaN -> 720
+dqcps425 copysign -720 +NaN8 -> 720
+
+dqcps426 copysign 701 -sNaN -> -701
+dqcps427 copysign -720 -sNaN -> -720
+dqcps428 copysign 701 +sNaN -> 701
+dqcps429 copysign -720 +sNaN -> 720
+dqcps430 copysign -720 +sNaN3 -> 720
+
diff --git a/Lib/test/decimaltestdata/dqDivide.decTest b/Lib/test/decimaltestdata/dqDivide.decTest
index 2abb939d54f..3cf60c60241 100644
--- a/Lib/test/decimaltestdata/dqDivide.decTest
+++ b/Lib/test/decimaltestdata/dqDivide.decTest
@@ -1,808 +1,808 @@
-------------------------------------------------------------------------
--- dqDivide.decTest -- decQuad division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqdiv001 divide 1 1 -> 1
-dqdiv002 divide 2 1 -> 2
-dqdiv003 divide 1 2 -> 0.5
-dqdiv004 divide 2 2 -> 1
-dqdiv005 divide 0 1 -> 0
-dqdiv006 divide 0 2 -> 0
-dqdiv007 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv008 divide 2 3 -> 0.6666666666666666666666666666666667 Inexact Rounded
-dqdiv009 divide 3 3 -> 1
-
-dqdiv010 divide 2.4 1 -> 2.4
-dqdiv011 divide 2.4 -1 -> -2.4
-dqdiv012 divide -2.4 1 -> -2.4
-dqdiv013 divide -2.4 -1 -> 2.4
-dqdiv014 divide 2.40 1 -> 2.40
-dqdiv015 divide 2.400 1 -> 2.400
-dqdiv016 divide 2.4 2 -> 1.2
-dqdiv017 divide 2.400 2 -> 1.200
-dqdiv018 divide 2. 2 -> 1
-dqdiv019 divide 20 20 -> 1
-
-dqdiv020 divide 187 187 -> 1
-dqdiv021 divide 5 2 -> 2.5
-dqdiv022 divide 50 20 -> 2.5
-dqdiv023 divide 500 200 -> 2.5
-dqdiv024 divide 50.0 20.0 -> 2.5
-dqdiv025 divide 5.00 2.00 -> 2.5
-dqdiv026 divide 5 2.0 -> 2.5
-dqdiv027 divide 5 2.000 -> 2.5
-dqdiv028 divide 5 0.20 -> 25
-dqdiv029 divide 5 0.200 -> 25
-dqdiv030 divide 10 1 -> 10
-dqdiv031 divide 100 1 -> 100
-dqdiv032 divide 1000 1 -> 1000
-dqdiv033 divide 1000 100 -> 10
-
-dqdiv035 divide 1 2 -> 0.5
-dqdiv036 divide 1 4 -> 0.25
-dqdiv037 divide 1 8 -> 0.125
-dqdiv038 divide 1 16 -> 0.0625
-dqdiv039 divide 1 32 -> 0.03125
-dqdiv040 divide 1 64 -> 0.015625
-dqdiv041 divide 1 -2 -> -0.5
-dqdiv042 divide 1 -4 -> -0.25
-dqdiv043 divide 1 -8 -> -0.125
-dqdiv044 divide 1 -16 -> -0.0625
-dqdiv045 divide 1 -32 -> -0.03125
-dqdiv046 divide 1 -64 -> -0.015625
-dqdiv047 divide -1 2 -> -0.5
-dqdiv048 divide -1 4 -> -0.25
-dqdiv049 divide -1 8 -> -0.125
-dqdiv050 divide -1 16 -> -0.0625
-dqdiv051 divide -1 32 -> -0.03125
-dqdiv052 divide -1 64 -> -0.015625
-dqdiv053 divide -1 -2 -> 0.5
-dqdiv054 divide -1 -4 -> 0.25
-dqdiv055 divide -1 -8 -> 0.125
-dqdiv056 divide -1 -16 -> 0.0625
-dqdiv057 divide -1 -32 -> 0.03125
-dqdiv058 divide -1 -64 -> 0.015625
-
--- bcdTime
-dqdiv060 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
-dqdiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717123193907511985359 Inexact Rounded
-
--- 1234567890123456
-dqdiv067 divide 9999999999999999999999999999999999 1 -> 9999999999999999999999999999999999
-dqdiv068 divide 999999999999999999999999999999999 1 -> 999999999999999999999999999999999
-dqdiv069 divide 99999999999999999999999999999999 1 -> 99999999999999999999999999999999
-dqdiv070 divide 99999999999999999 1 -> 99999999999999999
-dqdiv071 divide 9999999999999999 1 -> 9999999999999999
-dqdiv072 divide 999999999999999 1 -> 999999999999999
-dqdiv073 divide 99999999999999 1 -> 99999999999999
-dqdiv074 divide 9999999999999 1 -> 9999999999999
-dqdiv075 divide 999999999999 1 -> 999999999999
-dqdiv076 divide 99999999999 1 -> 99999999999
-dqdiv077 divide 9999999999 1 -> 9999999999
-dqdiv078 divide 999999999 1 -> 999999999
-dqdiv079 divide 99999999 1 -> 99999999
-dqdiv080 divide 9999999 1 -> 9999999
-dqdiv081 divide 999999 1 -> 999999
-dqdiv082 divide 99999 1 -> 99999
-dqdiv083 divide 9999 1 -> 9999
-dqdiv084 divide 999 1 -> 999
-dqdiv085 divide 99 1 -> 99
-dqdiv086 divide 9 1 -> 9
-
-dqdiv090 divide 0. 1 -> 0
-dqdiv091 divide .0 1 -> 0.0
-dqdiv092 divide 0.00 1 -> 0.00
-dqdiv093 divide 0.00E+9 1 -> 0E+7
-dqdiv094 divide 0.0000E-50 1 -> 0E-54
-
-dqdiv095 divide 1 1E-8 -> 1E+8
-dqdiv096 divide 1 1E-9 -> 1E+9
-dqdiv097 divide 1 1E-10 -> 1E+10
-dqdiv098 divide 1 1E-11 -> 1E+11
-dqdiv099 divide 1 1E-12 -> 1E+12
-
-dqdiv100 divide 1 1 -> 1
-dqdiv101 divide 1 2 -> 0.5
-dqdiv102 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv103 divide 1 4 -> 0.25
-dqdiv104 divide 1 5 -> 0.2
-dqdiv105 divide 1 6 -> 0.1666666666666666666666666666666667 Inexact Rounded
-dqdiv106 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
-dqdiv107 divide 1 8 -> 0.125
-dqdiv108 divide 1 9 -> 0.1111111111111111111111111111111111 Inexact Rounded
-dqdiv109 divide 1 10 -> 0.1
-dqdiv110 divide 1 1 -> 1
-dqdiv111 divide 2 1 -> 2
-dqdiv112 divide 3 1 -> 3
-dqdiv113 divide 4 1 -> 4
-dqdiv114 divide 5 1 -> 5
-dqdiv115 divide 6 1 -> 6
-dqdiv116 divide 7 1 -> 7
-dqdiv117 divide 8 1 -> 8
-dqdiv118 divide 9 1 -> 9
-dqdiv119 divide 10 1 -> 10
-
-dqdiv120 divide 3E+1 0.001 -> 3E+4
-dqdiv121 divide 2.200 2 -> 1.100
-
-dqdiv130 divide 12345 4.999 -> 2469.493898779755951190238047609522 Inexact Rounded
-dqdiv131 divide 12345 4.99 -> 2473.947895791583166332665330661323 Inexact Rounded
-dqdiv132 divide 12345 4.9 -> 2519.387755102040816326530612244898 Inexact Rounded
-dqdiv133 divide 12345 5 -> 2469
-dqdiv134 divide 12345 5.1 -> 2420.588235294117647058823529411765 Inexact Rounded
-dqdiv135 divide 12345 5.01 -> 2464.071856287425149700598802395210 Inexact Rounded
-dqdiv136 divide 12345 5.001 -> 2468.506298740251949610077984403119 Inexact Rounded
-
--- test possibly imprecise results
-dqdiv220 divide 391 597 -> 0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv221 divide 391 -597 -> -0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv222 divide -391 597 -> -0.6549413735343383584589614740368509 Inexact Rounded
-dqdiv223 divide -391 -597 -> 0.6549413735343383584589614740368509 Inexact Rounded
-
--- test some cases that are close to exponent overflow
-dqdiv270 divide 1 1e6144 -> 1E-6144 Subnormal
-dqdiv271 divide 1 0.9e6144 -> 1.11111111111111111111111111111111E-6144 Rounded Inexact Subnormal Underflow
-dqdiv272 divide 1 0.99e6144 -> 1.01010101010101010101010101010101E-6144 Rounded Inexact Subnormal Underflow
-dqdiv273 divide 1 0.9999999999999999e6144 -> 1.00000000000000010000000000000001E-6144 Rounded Inexact Subnormal Underflow
-dqdiv274 divide 9e6144 1 -> 9.000000000000000000000000000000000E+6144 Clamped
-dqdiv275 divide 9.9e6144 1 -> 9.900000000000000000000000000000000E+6144 Clamped
-dqdiv276 divide 9.99e6144 1 -> 9.990000000000000000000000000000000E+6144 Clamped
-dqdiv277 divide 9.999999999999999e6144 1 -> 9.999999999999999000000000000000000E+6144 Clamped
-
-dqdiv278 divide 1 0.9999999999999999999999999999999999e6144 -> 1.00000000000000000000000000000000E-6144 Rounded Inexact Subnormal Underflow
-dqdiv279 divide 9.999999999999999999999999999999999e6144 1 -> 9.999999999999999999999999999999999E+6144
-
--- Divide into 0 tests
-dqdiv301 divide 0 7 -> 0
-dqdiv302 divide 0 7E-5 -> 0E+5
-dqdiv303 divide 0 7E-1 -> 0E+1
-dqdiv304 divide 0 7E+1 -> 0.0
-dqdiv305 divide 0 7E+5 -> 0.00000
-dqdiv306 divide 0 7E+6 -> 0.000000
-dqdiv307 divide 0 7E+7 -> 0E-7
-dqdiv308 divide 0 70E-5 -> 0E+5
-dqdiv309 divide 0 70E-1 -> 0E+1
-dqdiv310 divide 0 70E+0 -> 0
-dqdiv311 divide 0 70E+1 -> 0.0
-dqdiv312 divide 0 70E+5 -> 0.00000
-dqdiv313 divide 0 70E+6 -> 0.000000
-dqdiv314 divide 0 70E+7 -> 0E-7
-dqdiv315 divide 0 700E-5 -> 0E+5
-dqdiv316 divide 0 700E-1 -> 0E+1
-dqdiv317 divide 0 700E+0 -> 0
-dqdiv318 divide 0 700E+1 -> 0.0
-dqdiv319 divide 0 700E+5 -> 0.00000
-dqdiv320 divide 0 700E+6 -> 0.000000
-dqdiv321 divide 0 700E+7 -> 0E-7
-dqdiv322 divide 0 700E+77 -> 0E-77
-
-dqdiv331 divide 0E-3 7E-5 -> 0E+2
-dqdiv332 divide 0E-3 7E-1 -> 0.00
-dqdiv333 divide 0E-3 7E+1 -> 0.0000
-dqdiv334 divide 0E-3 7E+5 -> 0E-8
-dqdiv335 divide 0E-1 7E-5 -> 0E+4
-dqdiv336 divide 0E-1 7E-1 -> 0
-dqdiv337 divide 0E-1 7E+1 -> 0.00
-dqdiv338 divide 0E-1 7E+5 -> 0.000000
-dqdiv339 divide 0E+1 7E-5 -> 0E+6
-dqdiv340 divide 0E+1 7E-1 -> 0E+2
-dqdiv341 divide 0E+1 7E+1 -> 0
-dqdiv342 divide 0E+1 7E+5 -> 0.0000
-dqdiv343 divide 0E+3 7E-5 -> 0E+8
-dqdiv344 divide 0E+3 7E-1 -> 0E+4
-dqdiv345 divide 0E+3 7E+1 -> 0E+2
-dqdiv346 divide 0E+3 7E+5 -> 0.00
-
--- These were 'input rounding'
-dqdiv441 divide 12345678000 1 -> 12345678000
-dqdiv442 divide 1 12345678000 -> 8.100000664200054464404466081166219E-11 Inexact Rounded
-dqdiv443 divide 1234567800 1 -> 1234567800
-dqdiv444 divide 1 1234567800 -> 8.100000664200054464404466081166219E-10 Inexact Rounded
-dqdiv445 divide 1234567890 1 -> 1234567890
-dqdiv446 divide 1 1234567890 -> 8.100000073710000670761006103925156E-10 Inexact Rounded
-dqdiv447 divide 1234567891 1 -> 1234567891
-dqdiv448 divide 1 1234567891 -> 8.100000067149000556665214614754629E-10 Inexact Rounded
-dqdiv449 divide 12345678901 1 -> 12345678901
-dqdiv450 divide 1 12345678901 -> 8.100000073053900658873130042376760E-11 Inexact Rounded
-dqdiv451 divide 1234567896 1 -> 1234567896
-dqdiv452 divide 1 1234567896 -> 8.100000034344000145618560617422697E-10 Inexact Rounded
-
--- high-lows
-dqdiv453 divide 1e+1 1 -> 1E+1
-dqdiv454 divide 1e+1 1.0 -> 1E+1
-dqdiv455 divide 1e+1 1.00 -> 1E+1
-dqdiv456 divide 1e+2 2 -> 5E+1
-dqdiv457 divide 1e+2 2.0 -> 5E+1
-dqdiv458 divide 1e+2 2.00 -> 5E+1
-
--- some from IEEE discussions
-dqdiv460 divide 3e0 2e0 -> 1.5
-dqdiv461 divide 30e-1 2e0 -> 1.5
-dqdiv462 divide 300e-2 2e0 -> 1.50
-dqdiv464 divide 3000e-3 2e0 -> 1.500
-dqdiv465 divide 3e0 20e-1 -> 1.5
-dqdiv466 divide 30e-1 20e-1 -> 1.5
-dqdiv467 divide 300e-2 20e-1 -> 1.5
-dqdiv468 divide 3000e-3 20e-1 -> 1.50
-dqdiv469 divide 3e0 200e-2 -> 1.5
-dqdiv470 divide 30e-1 200e-2 -> 1.5
-dqdiv471 divide 300e-2 200e-2 -> 1.5
-dqdiv472 divide 3000e-3 200e-2 -> 1.5
-dqdiv473 divide 3e0 2000e-3 -> 1.5
-dqdiv474 divide 30e-1 2000e-3 -> 1.5
-dqdiv475 divide 300e-2 2000e-3 -> 1.5
-dqdiv476 divide 3000e-3 2000e-3 -> 1.5
-
--- some reciprocals
-dqdiv480 divide 1 1.0E+33 -> 1E-33
-dqdiv481 divide 1 10E+33 -> 1E-34
-dqdiv482 divide 1 1.0E-33 -> 1E+33
-dqdiv483 divide 1 10E-33 -> 1E+32
-
--- RMS discussion table
-dqdiv484 divide 0e5 1e3 -> 0E+2
-dqdiv485 divide 0e5 2e3 -> 0E+2
-dqdiv486 divide 0e5 10e2 -> 0E+3
-dqdiv487 divide 0e5 20e2 -> 0E+3
-dqdiv488 divide 0e5 100e1 -> 0E+4
-dqdiv489 divide 0e5 200e1 -> 0E+4
-
-dqdiv491 divide 1e5 1e3 -> 1E+2
-dqdiv492 divide 1e5 2e3 -> 5E+1
-dqdiv493 divide 1e5 10e2 -> 1E+2
-dqdiv494 divide 1e5 20e2 -> 5E+1
-dqdiv495 divide 1e5 100e1 -> 1E+2
-dqdiv496 divide 1e5 200e1 -> 5E+1
-
--- tryzeros cases
-rounding: half_up
-dqdiv497 divide 0E+6108 1000E-33 -> 0E+6111 Clamped
-dqdiv498 divide 0E-6170 1000E+33 -> 0E-6176 Clamped
-
-rounding: half_up
-
--- focus on trailing zeros issues
-dqdiv500 divide 1 9.9 -> 0.1010101010101010101010101010101010 Inexact Rounded
-dqdiv501 divide 1 9.09 -> 0.1100110011001100110011001100110011 Inexact Rounded
-dqdiv502 divide 1 9.009 -> 0.1110001110001110001110001110001110 Inexact Rounded
-
-dqdiv511 divide 1 2 -> 0.5
-dqdiv512 divide 1.0 2 -> 0.5
-dqdiv513 divide 1.00 2 -> 0.50
-dqdiv514 divide 1.000 2 -> 0.500
-dqdiv515 divide 1.0000 2 -> 0.5000
-dqdiv516 divide 1.00000 2 -> 0.50000
-dqdiv517 divide 1.000000 2 -> 0.500000
-dqdiv518 divide 1.0000000 2 -> 0.5000000
-dqdiv519 divide 1.00 2.00 -> 0.5
-
-dqdiv521 divide 2 1 -> 2
-dqdiv522 divide 2 1.0 -> 2
-dqdiv523 divide 2 1.00 -> 2
-dqdiv524 divide 2 1.000 -> 2
-dqdiv525 divide 2 1.0000 -> 2
-dqdiv526 divide 2 1.00000 -> 2
-dqdiv527 divide 2 1.000000 -> 2
-dqdiv528 divide 2 1.0000000 -> 2
-dqdiv529 divide 2.00 1.00 -> 2
-
-dqdiv530 divide 2.40 2 -> 1.20
-dqdiv531 divide 2.40 4 -> 0.60
-dqdiv532 divide 2.40 10 -> 0.24
-dqdiv533 divide 2.40 2.0 -> 1.2
-dqdiv534 divide 2.40 4.0 -> 0.6
-dqdiv535 divide 2.40 10.0 -> 0.24
-dqdiv536 divide 2.40 2.00 -> 1.2
-dqdiv537 divide 2.40 4.00 -> 0.6
-dqdiv538 divide 2.40 10.00 -> 0.24
-dqdiv539 divide 0.9 0.1 -> 9
-dqdiv540 divide 0.9 0.01 -> 9E+1
-dqdiv541 divide 0.9 0.001 -> 9E+2
-dqdiv542 divide 5 2 -> 2.5
-dqdiv543 divide 5 2.0 -> 2.5
-dqdiv544 divide 5 2.00 -> 2.5
-dqdiv545 divide 5 20 -> 0.25
-dqdiv546 divide 5 20.0 -> 0.25
-dqdiv547 divide 2.400 2 -> 1.200
-dqdiv548 divide 2.400 2.0 -> 1.20
-dqdiv549 divide 2.400 2.400 -> 1
-
-dqdiv550 divide 240 1 -> 240
-dqdiv551 divide 240 10 -> 24
-dqdiv552 divide 240 100 -> 2.4
-dqdiv553 divide 240 1000 -> 0.24
-dqdiv554 divide 2400 1 -> 2400
-dqdiv555 divide 2400 10 -> 240
-dqdiv556 divide 2400 100 -> 24
-dqdiv557 divide 2400 1000 -> 2.4
-
--- +ve exponent
-dqdiv600 divide 2.4E+9 2 -> 1.2E+9
-dqdiv601 divide 2.40E+9 2 -> 1.20E+9
-dqdiv602 divide 2.400E+9 2 -> 1.200E+9
-dqdiv603 divide 2.4000E+9 2 -> 1.2000E+9
-dqdiv604 divide 24E+8 2 -> 1.2E+9
-dqdiv605 divide 240E+7 2 -> 1.20E+9
-dqdiv606 divide 2400E+6 2 -> 1.200E+9
-dqdiv607 divide 24000E+5 2 -> 1.2000E+9
-
--- more zeros, etc.
-dqdiv731 divide 5.00 1E-3 -> 5.00E+3
-dqdiv732 divide 00.00 0.000 -> NaN Division_undefined
-dqdiv733 divide 00.00 0E-3 -> NaN Division_undefined
-dqdiv734 divide 0 -0 -> NaN Division_undefined
-dqdiv735 divide -0 0 -> NaN Division_undefined
-dqdiv736 divide -0 -0 -> NaN Division_undefined
-
-dqdiv741 divide 0 -1 -> -0
-dqdiv742 divide -0 -1 -> 0
-dqdiv743 divide 0 1 -> 0
-dqdiv744 divide -0 1 -> -0
-dqdiv745 divide -1 0 -> -Infinity Division_by_zero
-dqdiv746 divide -1 -0 -> Infinity Division_by_zero
-dqdiv747 divide 1 0 -> Infinity Division_by_zero
-dqdiv748 divide 1 -0 -> -Infinity Division_by_zero
-
-dqdiv751 divide 0.0 -1 -> -0.0
-dqdiv752 divide -0.0 -1 -> 0.0
-dqdiv753 divide 0.0 1 -> 0.0
-dqdiv754 divide -0.0 1 -> -0.0
-dqdiv755 divide -1.0 0 -> -Infinity Division_by_zero
-dqdiv756 divide -1.0 -0 -> Infinity Division_by_zero
-dqdiv757 divide 1.0 0 -> Infinity Division_by_zero
-dqdiv758 divide 1.0 -0 -> -Infinity Division_by_zero
-
-dqdiv761 divide 0 -1.0 -> -0E+1
-dqdiv762 divide -0 -1.0 -> 0E+1
-dqdiv763 divide 0 1.0 -> 0E+1
-dqdiv764 divide -0 1.0 -> -0E+1
-dqdiv765 divide -1 0.0 -> -Infinity Division_by_zero
-dqdiv766 divide -1 -0.0 -> Infinity Division_by_zero
-dqdiv767 divide 1 0.0 -> Infinity Division_by_zero
-dqdiv768 divide 1 -0.0 -> -Infinity Division_by_zero
-
-dqdiv771 divide 0.0 -1.0 -> -0
-dqdiv772 divide -0.0 -1.0 -> 0
-dqdiv773 divide 0.0 1.0 -> 0
-dqdiv774 divide -0.0 1.0 -> -0
-dqdiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
-dqdiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
-dqdiv777 divide 1.0 0.0 -> Infinity Division_by_zero
-dqdiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dqdiv780 divide Inf -Inf -> NaN Invalid_operation
-dqdiv781 divide Inf -1000 -> -Infinity
-dqdiv782 divide Inf -1 -> -Infinity
-dqdiv783 divide Inf -0 -> -Infinity
-dqdiv784 divide Inf 0 -> Infinity
-dqdiv785 divide Inf 1 -> Infinity
-dqdiv786 divide Inf 1000 -> Infinity
-dqdiv787 divide Inf Inf -> NaN Invalid_operation
-dqdiv788 divide -1000 Inf -> -0E-6176 Clamped
-dqdiv789 divide -Inf Inf -> NaN Invalid_operation
-dqdiv790 divide -1 Inf -> -0E-6176 Clamped
-dqdiv791 divide -0 Inf -> -0E-6176 Clamped
-dqdiv792 divide 0 Inf -> 0E-6176 Clamped
-dqdiv793 divide 1 Inf -> 0E-6176 Clamped
-dqdiv794 divide 1000 Inf -> 0E-6176 Clamped
-dqdiv795 divide Inf Inf -> NaN Invalid_operation
-
-dqdiv800 divide -Inf -Inf -> NaN Invalid_operation
-dqdiv801 divide -Inf -1000 -> Infinity
-dqdiv802 divide -Inf -1 -> Infinity
-dqdiv803 divide -Inf -0 -> Infinity
-dqdiv804 divide -Inf 0 -> -Infinity
-dqdiv805 divide -Inf 1 -> -Infinity
-dqdiv806 divide -Inf 1000 -> -Infinity
-dqdiv807 divide -Inf Inf -> NaN Invalid_operation
-dqdiv808 divide -1000 Inf -> -0E-6176 Clamped
-dqdiv809 divide -Inf -Inf -> NaN Invalid_operation
-dqdiv810 divide -1 -Inf -> 0E-6176 Clamped
-dqdiv811 divide -0 -Inf -> 0E-6176 Clamped
-dqdiv812 divide 0 -Inf -> -0E-6176 Clamped
-dqdiv813 divide 1 -Inf -> -0E-6176 Clamped
-dqdiv814 divide 1000 -Inf -> -0E-6176 Clamped
-dqdiv815 divide Inf -Inf -> NaN Invalid_operation
-
-dqdiv821 divide NaN -Inf -> NaN
-dqdiv822 divide NaN -1000 -> NaN
-dqdiv823 divide NaN -1 -> NaN
-dqdiv824 divide NaN -0 -> NaN
-dqdiv825 divide NaN 0 -> NaN
-dqdiv826 divide NaN 1 -> NaN
-dqdiv827 divide NaN 1000 -> NaN
-dqdiv828 divide NaN Inf -> NaN
-dqdiv829 divide NaN NaN -> NaN
-dqdiv830 divide -Inf NaN -> NaN
-dqdiv831 divide -1000 NaN -> NaN
-dqdiv832 divide -1 NaN -> NaN
-dqdiv833 divide -0 NaN -> NaN
-dqdiv834 divide 0 NaN -> NaN
-dqdiv835 divide 1 NaN -> NaN
-dqdiv836 divide 1000 NaN -> NaN
-dqdiv837 divide Inf NaN -> NaN
-
-dqdiv841 divide sNaN -Inf -> NaN Invalid_operation
-dqdiv842 divide sNaN -1000 -> NaN Invalid_operation
-dqdiv843 divide sNaN -1 -> NaN Invalid_operation
-dqdiv844 divide sNaN -0 -> NaN Invalid_operation
-dqdiv845 divide sNaN 0 -> NaN Invalid_operation
-dqdiv846 divide sNaN 1 -> NaN Invalid_operation
-dqdiv847 divide sNaN 1000 -> NaN Invalid_operation
-dqdiv848 divide sNaN NaN -> NaN Invalid_operation
-dqdiv849 divide sNaN sNaN -> NaN Invalid_operation
-dqdiv850 divide NaN sNaN -> NaN Invalid_operation
-dqdiv851 divide -Inf sNaN -> NaN Invalid_operation
-dqdiv852 divide -1000 sNaN -> NaN Invalid_operation
-dqdiv853 divide -1 sNaN -> NaN Invalid_operation
-dqdiv854 divide -0 sNaN -> NaN Invalid_operation
-dqdiv855 divide 0 sNaN -> NaN Invalid_operation
-dqdiv856 divide 1 sNaN -> NaN Invalid_operation
-dqdiv857 divide 1000 sNaN -> NaN Invalid_operation
-dqdiv858 divide Inf sNaN -> NaN Invalid_operation
-dqdiv859 divide NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqdiv861 divide NaN9 -Inf -> NaN9
-dqdiv862 divide NaN8 1000 -> NaN8
-dqdiv863 divide NaN7 Inf -> NaN7
-dqdiv864 divide NaN6 NaN5 -> NaN6
-dqdiv865 divide -Inf NaN4 -> NaN4
-dqdiv866 divide -1000 NaN3 -> NaN3
-dqdiv867 divide Inf NaN2 -> NaN2
-
-dqdiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
-dqdiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
-dqdiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
-dqdiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqdiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
-dqdiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
-dqdiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
-dqdiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
-dqdiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
-
-dqdiv881 divide -NaN9 -Inf -> -NaN9
-dqdiv882 divide -NaN8 1000 -> -NaN8
-dqdiv883 divide -NaN7 Inf -> -NaN7
-dqdiv884 divide -NaN6 -NaN5 -> -NaN6
-dqdiv885 divide -Inf -NaN4 -> -NaN4
-dqdiv886 divide -1000 -NaN3 -> -NaN3
-dqdiv887 divide Inf -NaN2 -> -NaN2
-
-dqdiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqdiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
-dqdiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
-dqdiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
-dqdiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqdiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqdiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
-dqdiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
-dqdiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
-
--- Various flavours of divide by 0
-dqdiv901 divide 0 0 -> NaN Division_undefined
-dqdiv902 divide 0.0E5 0 -> NaN Division_undefined
-dqdiv903 divide 0.000 0 -> NaN Division_undefined
-dqdiv904 divide 0.0001 0 -> Infinity Division_by_zero
-dqdiv905 divide 0.01 0 -> Infinity Division_by_zero
-dqdiv906 divide 0.1 0 -> Infinity Division_by_zero
-dqdiv907 divide 1 0 -> Infinity Division_by_zero
-dqdiv908 divide 1 0.0 -> Infinity Division_by_zero
-dqdiv909 divide 10 0.0 -> Infinity Division_by_zero
-dqdiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
-dqdiv911 divide 1E+100 0 -> Infinity Division_by_zero
-
-dqdiv921 divide -0.0001 0 -> -Infinity Division_by_zero
-dqdiv922 divide -0.01 0 -> -Infinity Division_by_zero
-dqdiv923 divide -0.1 0 -> -Infinity Division_by_zero
-dqdiv924 divide -1 0 -> -Infinity Division_by_zero
-dqdiv925 divide -1 0.0 -> -Infinity Division_by_zero
-dqdiv926 divide -10 0.0 -> -Infinity Division_by_zero
-dqdiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
-dqdiv928 divide -1E+100 0 -> -Infinity Division_by_zero
-
-dqdiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
-dqdiv932 divide 0.01 -0 -> -Infinity Division_by_zero
-dqdiv933 divide 0.1 -0 -> -Infinity Division_by_zero
-dqdiv934 divide 1 -0 -> -Infinity Division_by_zero
-dqdiv935 divide 1 -0.0 -> -Infinity Division_by_zero
-dqdiv936 divide 10 -0.0 -> -Infinity Division_by_zero
-dqdiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
-dqdiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
-
-dqdiv941 divide -0.0001 -0 -> Infinity Division_by_zero
-dqdiv942 divide -0.01 -0 -> Infinity Division_by_zero
-dqdiv943 divide -0.1 -0 -> Infinity Division_by_zero
-dqdiv944 divide -1 -0 -> Infinity Division_by_zero
-dqdiv945 divide -1 -0.0 -> Infinity Division_by_zero
-dqdiv946 divide -10 -0.0 -> Infinity Division_by_zero
-dqdiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
-dqdiv948 divide -1E+100 -0 -> Infinity Division_by_zero
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqdiv1021 divide 1E0 1E0 -> 1
-dqdiv1022 divide 1E0 2E0 -> 0.5
-dqdiv1023 divide 1E0 3E0 -> 0.3333333333333333333333333333333333 Inexact Rounded
-dqdiv1024 divide 100E-2 1000E-3 -> 1
-dqdiv1025 divide 24E-1 2E0 -> 1.2
-dqdiv1026 divide 2400E-3 2E0 -> 1.200
-dqdiv1027 divide 5E0 2E0 -> 2.5
-dqdiv1028 divide 5E0 20E-1 -> 2.5
-dqdiv1029 divide 5E0 2000E-3 -> 2.5
-dqdiv1030 divide 5E0 2E-1 -> 25
-dqdiv1031 divide 5E0 20E-2 -> 25
-dqdiv1032 divide 480E-2 3E0 -> 1.60
-dqdiv1033 divide 47E-1 2E0 -> 2.35
-
--- ECMAScript bad examples
-rounding: half_down
-dqdiv1040 divide 5 9 -> 0.5555555555555555555555555555555556 Inexact Rounded
-rounding: half_even
-dqdiv1041 divide 6 11 -> 0.5454545454545454545454545454545455 Inexact Rounded
-
--- Gyuris example
-dqdiv1050 divide 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0.9999999999999999999999999999991254 Inexact Rounded
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqdiv1751 divide 1e+4277 1e-3311 -> Infinity Overflow Inexact Rounded
-dqdiv1752 divide 1e+4277 -1e-3311 -> -Infinity Overflow Inexact Rounded
-dqdiv1753 divide -1e+4277 1e-3311 -> -Infinity Overflow Inexact Rounded
-dqdiv1754 divide -1e+4277 -1e-3311 -> Infinity Overflow Inexact Rounded
-dqdiv1755 divide 1e-4277 1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1756 divide 1e-4277 -1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1757 divide -1e-4277 1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1758 divide -1e-4277 -1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqdiv1760 divide 1e-6069 1e+101 -> 1E-6170 Subnormal
-dqdiv1761 divide 1e-6069 1e+102 -> 1E-6171 Subnormal
-dqdiv1762 divide 1e-6069 1e+103 -> 1E-6172 Subnormal
-dqdiv1763 divide 1e-6069 1e+104 -> 1E-6173 Subnormal
-dqdiv1764 divide 1e-6069 1e+105 -> 1E-6174 Subnormal
-dqdiv1765 divide 1e-6069 1e+106 -> 1E-6175 Subnormal
-dqdiv1766 divide 1e-6069 1e+107 -> 1E-6176 Subnormal
-dqdiv1767 divide 1e-6069 1e+108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1768 divide 1e-6069 1e+109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1769 divide 1e-6069 1e+110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqdiv1770 divide 1e+40 1e-6101 -> 1.000000000000000000000000000000E+6141 Clamped
-dqdiv1771 divide 1e+40 1e-6102 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqdiv1772 divide 1e+40 1e-6103 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqdiv1773 divide 1e+40 1e-6104 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqdiv1774 divide 1e+40 1e-6105 -> Infinity Overflow Inexact Rounded
-dqdiv1775 divide 1e+40 1e-6106 -> Infinity Overflow Inexact Rounded
-dqdiv1776 divide 1e+40 1e-6107 -> Infinity Overflow Inexact Rounded
-dqdiv1777 divide 1e+40 1e-6108 -> Infinity Overflow Inexact Rounded
-dqdiv1778 divide 1e+40 1e-6109 -> Infinity Overflow Inexact Rounded
-dqdiv1779 divide 1e+40 1e-6110 -> Infinity Overflow Inexact Rounded
-
-dqdiv1801 divide 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
-dqdiv1802 divide 1.000E-6172 1e+1 -> 1.000E-6173 Subnormal
-dqdiv1803 divide 1.00E-6172 1e+2 -> 1.00E-6174 Subnormal
-dqdiv1804 divide 1.0E-6172 1e+3 -> 1.0E-6175 Subnormal
-dqdiv1805 divide 1.0E-6172 1e+4 -> 1E-6176 Subnormal Rounded
-dqdiv1806 divide 1.3E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1807 divide 1.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1808 divide 1.7E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1809 divide 2.3E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1810 divide 2.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1811 divide 2.7E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1812 divide 1.49E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1813 divide 1.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1814 divide 1.51E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1815 divide 2.49E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1816 divide 2.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1817 divide 2.51E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqdiv1818 divide 1E-6172 1e+4 -> 1E-6176 Subnormal
-dqdiv1819 divide 3E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1820 divide 5E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1821 divide 7E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1822 divide 9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1823 divide 9.9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqdiv1824 divide 1E-6172 -1e+4 -> -1E-6176 Subnormal
-dqdiv1825 divide 3E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1826 divide -5E-6172 1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1827 divide 7E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1828 divide -9E-6172 1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1829 divide 9.9E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqdiv1830 divide 3.0E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqdiv1831 divide 1.0E-5977 1e+200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqdiv1832 divide 1.0E-5977 1e+199 -> 1E-6176 Subnormal Rounded
-dqdiv1833 divide 1.0E-5977 1e+198 -> 1.0E-6175 Subnormal
-dqdiv1834 divide 2.0E-5977 2e+198 -> 1.0E-6175 Subnormal
-dqdiv1835 divide 4.0E-5977 4e+198 -> 1.0E-6175 Subnormal
-dqdiv1836 divide 10.0E-5977 10e+198 -> 1.0E-6175 Subnormal
-dqdiv1837 divide 30.0E-5977 30e+198 -> 1.0E-6175 Subnormal
-dqdiv1838 divide 40.0E-5982 40e+166 -> 1.0E-6148 Subnormal
-dqdiv1839 divide 40.0E-5982 40e+165 -> 1.0E-6147 Subnormal
-dqdiv1840 divide 40.0E-5982 40e+164 -> 1.0E-6146 Subnormal
-
--- randoms
-rounding: half_even
-dqdiv2010 divide -5231195652931651968034356117118850 -7243718664422548573203260970.34995 -> 722169.9095831284624736051460550680 Inexact Rounded
-dqdiv2011 divide -89584669773927.82711237350022515352 -42077943728529635884.21142627532985 -> 0.000002129017291146471565928125887527266 Inexact Rounded
-dqdiv2012 divide -2.828201693360723203806974891946180E-232 812596541221823960386384403089240.9 -> -3.480450075640521320040055759125120E-265 Inexact Rounded
-dqdiv2013 divide -6442775372761069267502937539408720 24904085056.69185465145182606089196 -> -258703556388226463687701.4884719589 Inexact Rounded
-dqdiv2014 divide 5.535520011272625629610079879714705 -44343664650.57203052003068113531208 -> -1.248322630728089308975940533493562E-10 Inexact Rounded
-dqdiv2015 divide 65919273712517865964325.99419625010 -314733354141381737378622515.7789054 -> -0.0002094448295521490616379784758911632 Inexact Rounded
-dqdiv2016 divide -7.779172568193197107115275140431129E+759 -140453015639.3988987652895178782143 -> 5.538629792161641534962774244238115E+748 Inexact Rounded
-dqdiv2017 divide 644314832597569.0181226067518178797 -115024585257425.1635759521565201075 -> -5.601540150356479257367687450922795 Inexact Rounded
-dqdiv2018 divide 6.898640941579611450676592553286870E-47 -11272429881407851485163914999.25943 -> -6.119923578285338689371137648319280E-75 Inexact Rounded
-dqdiv2019 divide -3591344544888727133.30819750163254 5329395.423792795661446561090331037 -> -673874662941.1968525589460533725290 Inexact Rounded
-dqdiv2020 divide -7.682356781384631313156462724425838E+747 -6.60375855512219057281922141809940E+703 -> 1.163330960279556016678379128875149E+44 Inexact Rounded
-dqdiv2021 divide -4511495596596941820863224.274679699 3365395017.263329795449661616090724 -> -1340554548115304.904166888018346299 Inexact Rounded
-dqdiv2022 divide 5.211164127840931517263639608151299 164.5566381356276567012533847006453 -> 0.03166790587655228864478260157156510 Inexact Rounded
-dqdiv2023 divide -49891.2243893458830384077684620383 -47179.9312961860747554053371171530 -> 1.057467084386767291602189656430268 Inexact Rounded
-dqdiv2024 divide 15065477.47214268488077415462413353 4366211.120892953261309529740552596 -> 3.450469309661227984244545513441359 Inexact Rounded
-dqdiv2025 divide 1.575670269440761846109602429612644E+370 653199649324740300.006185482643439 -> 2.412233795700359170904588548041481E+352 Inexact Rounded
-dqdiv2026 divide -2112422311733448924573432192.620145 -80067206.03590693153848215848613406 -> 26383115089417660175.20102646756574 Inexact Rounded
-dqdiv2027 divide -67096536051279809.32218611548721839 -869685412881941081664251990181.1049 -> 7.715035236584805921278566365231168E-14 Inexact Rounded
-dqdiv2028 divide -58612908548962047.21866913425488972 -978449597531.3873665583475633831644 -> 59903.86085991703091236507859837023 Inexact Rounded
-dqdiv2029 divide -133032412010942.1476864138213319796 -7.882059293498670705446528648201359E-428 -> 1.687787506504433064549515681693715E+441 Inexact Rounded
-dqdiv2030 divide 1.83746698338966029492299716360513E+977 -9.897926608979649951672839879128603E+154 -> -1.856416051542212552042390218062458E+822 Inexact Rounded
-dqdiv2031 divide -113742475841399236307128962.1507063 8298602.203049834732657567965262989 -> -13706221006665137826.16557393919929 Inexact Rounded
-dqdiv2032 divide 196.4787574650754152995941808331862 929.6553388472318094427422117172394 -> 0.2113458066176526651006917922814018 Inexact Rounded
-dqdiv2033 divide 71931221465.43867996282803628130350 3838685934206426257090718.402248853 -> 1.873850132527423413607199513324021E-14 Inexact Rounded
-dqdiv2034 divide 488.4282502289651653783596246312885 -80.68940956806634280078706577953188 -> -6.053189047280693318844801899473272 Inexact Rounded
-dqdiv2035 divide 9.001764344963921754981762913247394E-162 -8.585540973667205753734967645386919E-729 -> -1.048479574271827326396012573232934E+567 Inexact Rounded
-dqdiv2036 divide -7.404133959409894743706402857145471E-828 -51.38159929460289711134684843086265 -> 1.441008855516029461032061785219773E-829 Inexact Rounded
-dqdiv2037 divide 2.967520235574419794048994436040717E-613 -6252513855.91394894949879262731889 -> -4.746123405656409127572998751885338E-623 Inexact Rounded
-dqdiv2038 divide -18826852654824040505.83920366765051 -6336924877942437992590557460147340 -> 2.970976146546494669807886278519194E-15 Inexact Rounded
-dqdiv2039 divide -8.101406784809197604949584001735949E+561 4.823300306948942821076681658771635E+361 -> -1.679639721610839204738445747238987E+200 Inexact Rounded
-dqdiv2040 divide -6.11981977773094052331062585191723E+295 1.507610253755339328302779005586534E+238 -> -4.059285058911577244044418416044763E+57 Inexact Rounded
-dqdiv2041 divide 6.472638850046815880599220534274055E-596 -4.475233712083047516933911786159972 -> -1.446324207062261745520496475778879E-596 Inexact Rounded
-dqdiv2042 divide -84438593330.71277839631144509397112 -586684596204401664208947.4054879633 -> 1.439250218550041228759983937772504E-13 Inexact Rounded
-dqdiv2043 divide 9.354533233294022616695815656704369E-24 405.500390626135304252144163591746 -> 2.306911028827774549740571229736198E-26 Inexact Rounded
-dqdiv2044 divide 985606423350210.7374876650149957881 -36811563697.41925681866694859828794 -> -26774.36990864119445335813354717711 Inexact Rounded
-dqdiv2045 divide -8.187280774177715706278002247766311E-123 -38784124393.91212870828430001300068 -> 2.110987653356139147357240727794365E-133 Inexact Rounded
-dqdiv2046 divide -4.612203126350070903459245798371657E+912 7.971562182727956290901984736800519E+64 -> -5.785820922708683237098826662769748E+847 Inexact Rounded
-dqdiv2047 divide 4.661015909421485298247928967977089E+888 -6.360911253323922338737311563845581E+388 -> -7.327591478321365980156654539638836E+499 Inexact Rounded
-dqdiv2048 divide 9156078172903.257500003260710833030 7.189796653262147139071634237964074E-90 -> 1.273482215766000994365201545096026E+102 Inexact Rounded
-dqdiv2049 divide -1.710722303327476586373477781276586E-311 -3167561628260156837329323.729380695 -> 5.400754599578613984875752958645655E-336 Inexact Rounded
-dqdiv2050 divide -4.647935210881806238321616345413021E-878 209388.5431867744648177308460639582 -> -2.219765771394593733140494297388140E-883 Inexact Rounded
-dqdiv2051 divide 5958.694728395760992719084781582700 4.541510156564315632536353171846096E-746 -> 1.312051393253638664947852693005480E+749 Inexact Rounded
-dqdiv2052 divide -7.935732544649702175256699886872093E-489 -7.433329073664793138998765647467971E+360 -> 1.067587949626076917672271619664656E-849 Inexact Rounded
-dqdiv2053 divide -2746650864601157.863589959939901350 7.016684945507647528907184694359598E+548 -> -3.914456593009309529351254950429932E-534 Inexact Rounded
-dqdiv2054 divide 3605149408631197365447953.994569178 -75614025825649082.78264864428237833 -> -47678315.88472693507060063188020532 Inexact Rounded
-dqdiv2055 divide 788194320921798404906375214.196349 -6.222718148433247384932573401976337E-418 -> -1.266639918634671803982222244977287E+444 Inexact Rounded
-dqdiv2056 divide 5620722730534752.758208943447603211 6.843552841168538319123000917657759E-139 -> 8.213164800485434666629970443739554E+153 Inexact Rounded
-dqdiv2057 divide 7304534676713703938102.403949019402 -576169.3685010935108153023803590835 -> -12677756014201995.31969237144394772 Inexact Rounded
-dqdiv2058 divide 8067918762.134621639254916786945547 -8.774771480055536009105596163864758E+954 -> -9.194448858836332156766764605125245E-946 Inexact Rounded
-dqdiv2059 divide 8.702093454123046507578256899537563E-324 -5.875399733016018404580201176576293E-401 -> -1.481106622452052581470443526957335E+77 Inexact Rounded
-dqdiv2060 divide -41426.01662518451861386352415092356 90.00146621684478300510769802013464 -> -460.2815750287318692732067709176200 Inexact Rounded
-
--- random divide tests with result near 1
-dqdiv4001 divide 2003100352770753969878925664524900 2003100352770753969878925664497824 -> 1.000000000000000000000000000013517 Inexact Rounded
-dqdiv4002 divide 4817785793916490652579552318371645 4817785793916490652579552318362097 -> 1.000000000000000000000000000001982 Inexact Rounded
-dqdiv4003 divide 8299187410920067325648068439560282 8299187410920067325648068439591159 -> 0.9999999999999999999999999999962795 Inexact Rounded
-dqdiv4004 divide 5641088455897407044544461785365899 5641088455897407044544461785389965 -> 0.9999999999999999999999999999957338 Inexact Rounded
-dqdiv4005 divide 5752274694706545359326361313490424 5752274694706545359326361313502723 -> 0.9999999999999999999999999999978619 Inexact Rounded
-dqdiv4006 divide 6762079477373670594829319346099665 6762079477373670594829319346132579 -> 0.9999999999999999999999999999951326 Inexact Rounded
-dqdiv4007 divide 7286425153691890341633023222602916 7286425153691890341633023222606556 -> 0.9999999999999999999999999999995004 Inexact Rounded
-dqdiv4008 divide 9481233991901305727648306421946655 9481233991901305727648306421919124 -> 1.000000000000000000000000000002904 Inexact Rounded
-dqdiv4009 divide 4282053941893951742029444065614311 4282053941893951742029444065583077 -> 1.000000000000000000000000000007294 Inexact Rounded
-dqdiv4010 divide 626888225441250639741781850338695 626888225441250639741781850327299 -> 1.000000000000000000000000000018179 Inexact Rounded
-dqdiv4011 divide 3860973649222028009456598604468547 3860973649222028009456598604476849 -> 0.9999999999999999999999999999978498 Inexact Rounded
-dqdiv4012 divide 4753157080127468127908060607821839 4753157080127468127908060607788379 -> 1.000000000000000000000000000007040 Inexact Rounded
-dqdiv4013 divide 552448546203754062805706277880419 552448546203754062805706277881903 -> 0.9999999999999999999999999999973138 Inexact Rounded
-dqdiv4014 divide 8405954527952158455323713728917395 8405954527952158455323713728933866 -> 0.9999999999999999999999999999980406 Inexact Rounded
-dqdiv4015 divide 7554096502235321142555802238016116 7554096502235321142555802238026546 -> 0.9999999999999999999999999999986193 Inexact Rounded
-dqdiv4016 divide 4053257674127518606871054934746782 4053257674127518606871054934767355 -> 0.9999999999999999999999999999949243 Inexact Rounded
-dqdiv4017 divide 7112419420755090454716888844011582 7112419420755090454716888844038105 -> 0.9999999999999999999999999999962709 Inexact Rounded
-dqdiv4018 divide 3132302137520072728164549730911846 3132302137520072728164549730908416 -> 1.000000000000000000000000000001095 Inexact Rounded
-dqdiv4019 divide 4788374045841416355706715048161013 4788374045841416355706715048190077 -> 0.9999999999999999999999999999939303 Inexact Rounded
-dqdiv4020 divide 9466021636047630218238075099510597 9466021636047630218238075099484053 -> 1.000000000000000000000000000002804 Inexact Rounded
-dqdiv4021 divide 912742745646765625597399692138650 912742745646765625597399692139042 -> 0.9999999999999999999999999999995705 Inexact Rounded
-dqdiv4022 divide 9508402742933643208806264897188504 9508402742933643208806264897195973 -> 0.9999999999999999999999999999992145 Inexact Rounded
-dqdiv4023 divide 1186956795727233704962361914360895 1186956795727233704962361914329577 -> 1.000000000000000000000000000026385 Inexact Rounded
-dqdiv4024 divide 5972210268839014812696916170967938 5972210268839014812696916170954974 -> 1.000000000000000000000000000002171 Inexact Rounded
-dqdiv4025 divide 2303801625521619930894460139793140 2303801625521619930894460139799643 -> 0.9999999999999999999999999999971773 Inexact Rounded
-dqdiv4026 divide 6022231560002898264777393473966595 6022231560002898264777393473947198 -> 1.000000000000000000000000000003221 Inexact Rounded
-dqdiv4027 divide 8426148335801396199969346032210893 8426148335801396199969346032203179 -> 1.000000000000000000000000000000915 Inexact Rounded
-dqdiv4028 divide 8812278947028784637382847098411749 8812278947028784637382847098385317 -> 1.000000000000000000000000000002999 Inexact Rounded
-dqdiv4029 divide 8145282002348367383264197170116146 8145282002348367383264197170083988 -> 1.000000000000000000000000000003948 Inexact Rounded
-dqdiv4030 divide 6821577571876840153123510107387026 6821577571876840153123510107418008 -> 0.9999999999999999999999999999954582 Inexact Rounded
-dqdiv4031 divide 9018555319518966970480565482023720 9018555319518966970480565482013346 -> 1.000000000000000000000000000001150 Inexact Rounded
-dqdiv4032 divide 4602155712998228449640717252788864 4602155712998228449640717252818502 -> 0.9999999999999999999999999999935600 Inexact Rounded
-dqdiv4033 divide 6675607481522785614506828292264472 6675607481522785614506828292277100 -> 0.9999999999999999999999999999981083 Inexact Rounded
-dqdiv4034 divide 4015881516871833897766945836264472 4015881516871833897766945836262645 -> 1.000000000000000000000000000000455 Inexact Rounded
-dqdiv4035 divide 1415580205933411837595459716910365 1415580205933411837595459716880139 -> 1.000000000000000000000000000021352 Inexact Rounded
-dqdiv4036 divide 9432968297069542816752035276361552 9432968297069542816752035276353054 -> 1.000000000000000000000000000000901 Inexact Rounded
-dqdiv4037 divide 4799319591303848500532766682140658 4799319591303848500532766682172655 -> 0.9999999999999999999999999999933330 Inexact Rounded
-dqdiv4038 divide 316854270732839529790584284987472 316854270732839529790584285004832 -> 0.9999999999999999999999999999452114 Inexact Rounded
-dqdiv4039 divide 3598981300592490427826027975697415 3598981300592490427826027975686712 -> 1.000000000000000000000000000002974 Inexact Rounded
-dqdiv4040 divide 1664315435694461371155800682196520 1664315435694461371155800682195617 -> 1.000000000000000000000000000000543 Inexact Rounded
-dqdiv4041 divide 1680872316531128890102855316510581 1680872316531128890102855316495545 -> 1.000000000000000000000000000008945 Inexact Rounded
-dqdiv4042 divide 9881274879566405475755499281644730 9881274879566405475755499281615743 -> 1.000000000000000000000000000002934 Inexact Rounded
-dqdiv4043 divide 4737225957717466960447204232279216 4737225957717466960447204232277452 -> 1.000000000000000000000000000000372 Inexact Rounded
-dqdiv4044 divide 2482097379414867061213319346418288 2482097379414867061213319346387936 -> 1.000000000000000000000000000012228 Inexact Rounded
-dqdiv4045 divide 7406977595233762723576434122161868 7406977595233762723576434122189042 -> 0.9999999999999999999999999999963313 Inexact Rounded
-dqdiv4046 divide 228782057757566047086593281773577 228782057757566047086593281769727 -> 1.000000000000000000000000000016828 Inexact Rounded
-dqdiv4047 divide 2956594270240579648823270540367653 2956594270240579648823270540368556 -> 0.9999999999999999999999999999996946 Inexact Rounded
-dqdiv4048 divide 6326964098897620620534136767634340 6326964098897620620534136767619339 -> 1.000000000000000000000000000002371 Inexact Rounded
-dqdiv4049 divide 414586440456590215247002678327800 414586440456590215247002678316922 -> 1.000000000000000000000000000026238 Inexact Rounded
-dqdiv4050 divide 7364552208570039386220505636779125 7364552208570039386220505636803548 -> 0.9999999999999999999999999999966837 Inexact Rounded
-dqdiv4051 divide 5626266749902369710022824950590056 5626266749902369710022824950591008 -> 0.9999999999999999999999999999998308 Inexact Rounded
-dqdiv4052 divide 4863278293916197454987481343460484 4863278293916197454987481343442522 -> 1.000000000000000000000000000003693 Inexact Rounded
-dqdiv4053 divide 1170713582030637359713249796835483 1170713582030637359713249796823345 -> 1.000000000000000000000000000010368 Inexact Rounded
-dqdiv4054 divide 9838062494725965667776326556052931 9838062494725965667776326556061002 -> 0.9999999999999999999999999999991796 Inexact Rounded
-dqdiv4055 divide 4071388731298861093005687091498922 4071388731298861093005687091498278 -> 1.000000000000000000000000000000158 Inexact Rounded
-dqdiv4056 divide 8753155722324706795855038590272526 8753155722324706795855038590276656 -> 0.9999999999999999999999999999995282 Inexact Rounded
-dqdiv4057 divide 4399941911533273418844742658240485 4399941911533273418844742658219891 -> 1.000000000000000000000000000004681 Inexact Rounded
-dqdiv4058 divide 4127884159949503677776430620050269 4127884159949503677776430620026091 -> 1.000000000000000000000000000005857 Inexact Rounded
-dqdiv4059 divide 5536160822360800067042528317438808 5536160822360800067042528317450687 -> 0.9999999999999999999999999999978543 Inexact Rounded
-dqdiv4060 divide 3973234998468664936671088237710246 3973234998468664936671088237741886 -> 0.9999999999999999999999999999920367 Inexact Rounded
-dqdiv4061 divide 9824855935638263593410444142327358 9824855935638263593410444142328576 -> 0.9999999999999999999999999999998760 Inexact Rounded
-dqdiv4062 divide 5917078517340218131867327300814867 5917078517340218131867327300788701 -> 1.000000000000000000000000000004422 Inexact Rounded
-dqdiv4063 divide 4354236601830544882286139612521362 4354236601830544882286139612543223 -> 0.9999999999999999999999999999949794 Inexact Rounded
-dqdiv4064 divide 8058474772375259017342110013891294 8058474772375259017342110013906792 -> 0.9999999999999999999999999999980768 Inexact Rounded
-dqdiv4065 divide 5519604020981748170517093746166328 5519604020981748170517093746181763 -> 0.9999999999999999999999999999972036 Inexact Rounded
-dqdiv4066 divide 1502130966879805458831323782443139 1502130966879805458831323782412213 -> 1.000000000000000000000000000020588 Inexact Rounded
-dqdiv4067 divide 562795633719481212915159787980270 562795633719481212915159788007066 -> 0.9999999999999999999999999999523877 Inexact Rounded
-dqdiv4068 divide 6584743324494664273941281557268878 6584743324494664273941281557258945 -> 1.000000000000000000000000000001508 Inexact Rounded
-dqdiv4069 divide 3632000327285743997976431109416500 3632000327285743997976431109408107 -> 1.000000000000000000000000000002311 Inexact Rounded
-dqdiv4070 divide 1145827237315430089388953838561450 1145827237315430089388953838527332 -> 1.000000000000000000000000000029776 Inexact Rounded
-dqdiv4071 divide 8874431010357691869725372317350380 8874431010357691869725372317316472 -> 1.000000000000000000000000000003821 Inexact Rounded
-dqdiv4072 divide 992948718902804648119753141202196 992948718902804648119753141235222 -> 0.9999999999999999999999999999667395 Inexact Rounded
-dqdiv4073 divide 2522735183374218505142417265439989 2522735183374218505142417265453779 -> 0.9999999999999999999999999999945337 Inexact Rounded
-dqdiv4074 divide 2668419161912936508006872303501052 2668419161912936508006872303471036 -> 1.000000000000000000000000000011249 Inexact Rounded
-dqdiv4075 divide 3036169085665186712590941111775092 3036169085665186712590941111808846 -> 0.9999999999999999999999999999888827 Inexact Rounded
-dqdiv4076 divide 9441634604917231638508898934006147 9441634604917231638508898934000288 -> 1.000000000000000000000000000000621 Inexact Rounded
-dqdiv4077 divide 2677301353164377091111458811839190 2677301353164377091111458811867722 -> 0.9999999999999999999999999999893430 Inexact Rounded
-dqdiv4078 divide 6844979203112066166583765857171426 6844979203112066166583765857189682 -> 0.9999999999999999999999999999973329 Inexact Rounded
-dqdiv4079 divide 2220337435141796724323783960231661 2220337435141796724323783960208778 -> 1.000000000000000000000000000010306 Inexact Rounded
-dqdiv4080 divide 6447424700019783931569996989561380 6447424700019783931569996989572454 -> 0.9999999999999999999999999999982824 Inexact Rounded
-dqdiv4081 divide 7512856762696607119847092195587180 7512856762696607119847092195557346 -> 1.000000000000000000000000000003971 Inexact Rounded
-dqdiv4082 divide 7395261981193960399087819077237482 7395261981193960399087819077242487 -> 0.9999999999999999999999999999993232 Inexact Rounded
-dqdiv4083 divide 2253442467682584035792724884376735 2253442467682584035792724884407178 -> 0.9999999999999999999999999999864904 Inexact Rounded
-dqdiv4084 divide 8153138680300213135577336466190997 8153138680300213135577336466220607 -> 0.9999999999999999999999999999963683 Inexact Rounded
-dqdiv4085 divide 4668731252254148074041022681801390 4668731252254148074041022681778101 -> 1.000000000000000000000000000004988 Inexact Rounded
-dqdiv4086 divide 6078404557993669696040425501815056 6078404557993669696040425501797612 -> 1.000000000000000000000000000002870 Inexact Rounded
-dqdiv4087 divide 2306352359874261623223356878316278 2306352359874261623223356878335612 -> 0.9999999999999999999999999999916171 Inexact Rounded
-dqdiv4088 divide 3264842186668480362900909564091908 3264842186668480362900909564058658 -> 1.000000000000000000000000000010184 Inexact Rounded
-dqdiv4089 divide 6971985047279636878957959608612204 6971985047279636878957959608615088 -> 0.9999999999999999999999999999995863 Inexact Rounded
-dqdiv4090 divide 5262810889952721235466445973816257 5262810889952721235466445973783077 -> 1.000000000000000000000000000006305 Inexact Rounded
-dqdiv4091 divide 7947944731035267178548357070080288 7947944731035267178548357070061339 -> 1.000000000000000000000000000002384 Inexact Rounded
-dqdiv4092 divide 5071808908395375108383035800443229 5071808908395375108383035800412429 -> 1.000000000000000000000000000006073 Inexact Rounded
-dqdiv4093 divide 2043146542084503655511507209262969 2043146542084503655511507209249263 -> 1.000000000000000000000000000006708 Inexact Rounded
-dqdiv4094 divide 4097632735384534181661959731264802 4097632735384534181661959731234499 -> 1.000000000000000000000000000007395 Inexact Rounded
-dqdiv4095 divide 3061477642831387489729464587044430 3061477642831387489729464587059452 -> 0.9999999999999999999999999999950932 Inexact Rounded
-dqdiv4096 divide 3429854941039776159498802936252638 3429854941039776159498802936246415 -> 1.000000000000000000000000000001814 Inexact Rounded
-dqdiv4097 divide 4874324979578599700024133278284545 4874324979578599700024133278262131 -> 1.000000000000000000000000000004598 Inexact Rounded
-dqdiv4098 divide 5701652369691833541455978515820882 5701652369691833541455978515834854 -> 0.9999999999999999999999999999975495 Inexact Rounded
-dqdiv4099 divide 2928205728402945266953255632343113 2928205728402945266953255632373794 -> 0.9999999999999999999999999999895223 Inexact Rounded
-
--- Null tests
-dqdiv9998 divide 10 # -> NaN Invalid_operation
-dqdiv9999 divide # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqDivide.decTest -- decQuad division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqdiv001 divide 1 1 -> 1
+dqdiv002 divide 2 1 -> 2
+dqdiv003 divide 1 2 -> 0.5
+dqdiv004 divide 2 2 -> 1
+dqdiv005 divide 0 1 -> 0
+dqdiv006 divide 0 2 -> 0
+dqdiv007 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv008 divide 2 3 -> 0.6666666666666666666666666666666667 Inexact Rounded
+dqdiv009 divide 3 3 -> 1
+
+dqdiv010 divide 2.4 1 -> 2.4
+dqdiv011 divide 2.4 -1 -> -2.4
+dqdiv012 divide -2.4 1 -> -2.4
+dqdiv013 divide -2.4 -1 -> 2.4
+dqdiv014 divide 2.40 1 -> 2.40
+dqdiv015 divide 2.400 1 -> 2.400
+dqdiv016 divide 2.4 2 -> 1.2
+dqdiv017 divide 2.400 2 -> 1.200
+dqdiv018 divide 2. 2 -> 1
+dqdiv019 divide 20 20 -> 1
+
+dqdiv020 divide 187 187 -> 1
+dqdiv021 divide 5 2 -> 2.5
+dqdiv022 divide 50 20 -> 2.5
+dqdiv023 divide 500 200 -> 2.5
+dqdiv024 divide 50.0 20.0 -> 2.5
+dqdiv025 divide 5.00 2.00 -> 2.5
+dqdiv026 divide 5 2.0 -> 2.5
+dqdiv027 divide 5 2.000 -> 2.5
+dqdiv028 divide 5 0.20 -> 25
+dqdiv029 divide 5 0.200 -> 25
+dqdiv030 divide 10 1 -> 10
+dqdiv031 divide 100 1 -> 100
+dqdiv032 divide 1000 1 -> 1000
+dqdiv033 divide 1000 100 -> 10
+
+dqdiv035 divide 1 2 -> 0.5
+dqdiv036 divide 1 4 -> 0.25
+dqdiv037 divide 1 8 -> 0.125
+dqdiv038 divide 1 16 -> 0.0625
+dqdiv039 divide 1 32 -> 0.03125
+dqdiv040 divide 1 64 -> 0.015625
+dqdiv041 divide 1 -2 -> -0.5
+dqdiv042 divide 1 -4 -> -0.25
+dqdiv043 divide 1 -8 -> -0.125
+dqdiv044 divide 1 -16 -> -0.0625
+dqdiv045 divide 1 -32 -> -0.03125
+dqdiv046 divide 1 -64 -> -0.015625
+dqdiv047 divide -1 2 -> -0.5
+dqdiv048 divide -1 4 -> -0.25
+dqdiv049 divide -1 8 -> -0.125
+dqdiv050 divide -1 16 -> -0.0625
+dqdiv051 divide -1 32 -> -0.03125
+dqdiv052 divide -1 64 -> -0.015625
+dqdiv053 divide -1 -2 -> 0.5
+dqdiv054 divide -1 -4 -> 0.25
+dqdiv055 divide -1 -8 -> 0.125
+dqdiv056 divide -1 -16 -> 0.0625
+dqdiv057 divide -1 -32 -> 0.03125
+dqdiv058 divide -1 -64 -> 0.015625
+
+-- bcdTime
+dqdiv060 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
+dqdiv061 divide 1.2345678 1.9876543 -> 0.6211179680490717123193907511985359 Inexact Rounded
+
+-- 1234567890123456
+dqdiv067 divide 9999999999999999999999999999999999 1 -> 9999999999999999999999999999999999
+dqdiv068 divide 999999999999999999999999999999999 1 -> 999999999999999999999999999999999
+dqdiv069 divide 99999999999999999999999999999999 1 -> 99999999999999999999999999999999
+dqdiv070 divide 99999999999999999 1 -> 99999999999999999
+dqdiv071 divide 9999999999999999 1 -> 9999999999999999
+dqdiv072 divide 999999999999999 1 -> 999999999999999
+dqdiv073 divide 99999999999999 1 -> 99999999999999
+dqdiv074 divide 9999999999999 1 -> 9999999999999
+dqdiv075 divide 999999999999 1 -> 999999999999
+dqdiv076 divide 99999999999 1 -> 99999999999
+dqdiv077 divide 9999999999 1 -> 9999999999
+dqdiv078 divide 999999999 1 -> 999999999
+dqdiv079 divide 99999999 1 -> 99999999
+dqdiv080 divide 9999999 1 -> 9999999
+dqdiv081 divide 999999 1 -> 999999
+dqdiv082 divide 99999 1 -> 99999
+dqdiv083 divide 9999 1 -> 9999
+dqdiv084 divide 999 1 -> 999
+dqdiv085 divide 99 1 -> 99
+dqdiv086 divide 9 1 -> 9
+
+dqdiv090 divide 0. 1 -> 0
+dqdiv091 divide .0 1 -> 0.0
+dqdiv092 divide 0.00 1 -> 0.00
+dqdiv093 divide 0.00E+9 1 -> 0E+7
+dqdiv094 divide 0.0000E-50 1 -> 0E-54
+
+dqdiv095 divide 1 1E-8 -> 1E+8
+dqdiv096 divide 1 1E-9 -> 1E+9
+dqdiv097 divide 1 1E-10 -> 1E+10
+dqdiv098 divide 1 1E-11 -> 1E+11
+dqdiv099 divide 1 1E-12 -> 1E+12
+
+dqdiv100 divide 1 1 -> 1
+dqdiv101 divide 1 2 -> 0.5
+dqdiv102 divide 1 3 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv103 divide 1 4 -> 0.25
+dqdiv104 divide 1 5 -> 0.2
+dqdiv105 divide 1 6 -> 0.1666666666666666666666666666666667 Inexact Rounded
+dqdiv106 divide 1 7 -> 0.1428571428571428571428571428571429 Inexact Rounded
+dqdiv107 divide 1 8 -> 0.125
+dqdiv108 divide 1 9 -> 0.1111111111111111111111111111111111 Inexact Rounded
+dqdiv109 divide 1 10 -> 0.1
+dqdiv110 divide 1 1 -> 1
+dqdiv111 divide 2 1 -> 2
+dqdiv112 divide 3 1 -> 3
+dqdiv113 divide 4 1 -> 4
+dqdiv114 divide 5 1 -> 5
+dqdiv115 divide 6 1 -> 6
+dqdiv116 divide 7 1 -> 7
+dqdiv117 divide 8 1 -> 8
+dqdiv118 divide 9 1 -> 9
+dqdiv119 divide 10 1 -> 10
+
+dqdiv120 divide 3E+1 0.001 -> 3E+4
+dqdiv121 divide 2.200 2 -> 1.100
+
+dqdiv130 divide 12345 4.999 -> 2469.493898779755951190238047609522 Inexact Rounded
+dqdiv131 divide 12345 4.99 -> 2473.947895791583166332665330661323 Inexact Rounded
+dqdiv132 divide 12345 4.9 -> 2519.387755102040816326530612244898 Inexact Rounded
+dqdiv133 divide 12345 5 -> 2469
+dqdiv134 divide 12345 5.1 -> 2420.588235294117647058823529411765 Inexact Rounded
+dqdiv135 divide 12345 5.01 -> 2464.071856287425149700598802395210 Inexact Rounded
+dqdiv136 divide 12345 5.001 -> 2468.506298740251949610077984403119 Inexact Rounded
+
+-- test possibly imprecise results
+dqdiv220 divide 391 597 -> 0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv221 divide 391 -597 -> -0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv222 divide -391 597 -> -0.6549413735343383584589614740368509 Inexact Rounded
+dqdiv223 divide -391 -597 -> 0.6549413735343383584589614740368509 Inexact Rounded
+
+-- test some cases that are close to exponent overflow
+dqdiv270 divide 1 1e6144 -> 1E-6144 Subnormal
+dqdiv271 divide 1 0.9e6144 -> 1.11111111111111111111111111111111E-6144 Rounded Inexact Subnormal Underflow
+dqdiv272 divide 1 0.99e6144 -> 1.01010101010101010101010101010101E-6144 Rounded Inexact Subnormal Underflow
+dqdiv273 divide 1 0.9999999999999999e6144 -> 1.00000000000000010000000000000001E-6144 Rounded Inexact Subnormal Underflow
+dqdiv274 divide 9e6144 1 -> 9.000000000000000000000000000000000E+6144 Clamped
+dqdiv275 divide 9.9e6144 1 -> 9.900000000000000000000000000000000E+6144 Clamped
+dqdiv276 divide 9.99e6144 1 -> 9.990000000000000000000000000000000E+6144 Clamped
+dqdiv277 divide 9.999999999999999e6144 1 -> 9.999999999999999000000000000000000E+6144 Clamped
+
+dqdiv278 divide 1 0.9999999999999999999999999999999999e6144 -> 1.00000000000000000000000000000000E-6144 Rounded Inexact Subnormal Underflow
+dqdiv279 divide 9.999999999999999999999999999999999e6144 1 -> 9.999999999999999999999999999999999E+6144
+
+-- Divide into 0 tests
+dqdiv301 divide 0 7 -> 0
+dqdiv302 divide 0 7E-5 -> 0E+5
+dqdiv303 divide 0 7E-1 -> 0E+1
+dqdiv304 divide 0 7E+1 -> 0.0
+dqdiv305 divide 0 7E+5 -> 0.00000
+dqdiv306 divide 0 7E+6 -> 0.000000
+dqdiv307 divide 0 7E+7 -> 0E-7
+dqdiv308 divide 0 70E-5 -> 0E+5
+dqdiv309 divide 0 70E-1 -> 0E+1
+dqdiv310 divide 0 70E+0 -> 0
+dqdiv311 divide 0 70E+1 -> 0.0
+dqdiv312 divide 0 70E+5 -> 0.00000
+dqdiv313 divide 0 70E+6 -> 0.000000
+dqdiv314 divide 0 70E+7 -> 0E-7
+dqdiv315 divide 0 700E-5 -> 0E+5
+dqdiv316 divide 0 700E-1 -> 0E+1
+dqdiv317 divide 0 700E+0 -> 0
+dqdiv318 divide 0 700E+1 -> 0.0
+dqdiv319 divide 0 700E+5 -> 0.00000
+dqdiv320 divide 0 700E+6 -> 0.000000
+dqdiv321 divide 0 700E+7 -> 0E-7
+dqdiv322 divide 0 700E+77 -> 0E-77
+
+dqdiv331 divide 0E-3 7E-5 -> 0E+2
+dqdiv332 divide 0E-3 7E-1 -> 0.00
+dqdiv333 divide 0E-3 7E+1 -> 0.0000
+dqdiv334 divide 0E-3 7E+5 -> 0E-8
+dqdiv335 divide 0E-1 7E-5 -> 0E+4
+dqdiv336 divide 0E-1 7E-1 -> 0
+dqdiv337 divide 0E-1 7E+1 -> 0.00
+dqdiv338 divide 0E-1 7E+5 -> 0.000000
+dqdiv339 divide 0E+1 7E-5 -> 0E+6
+dqdiv340 divide 0E+1 7E-1 -> 0E+2
+dqdiv341 divide 0E+1 7E+1 -> 0
+dqdiv342 divide 0E+1 7E+5 -> 0.0000
+dqdiv343 divide 0E+3 7E-5 -> 0E+8
+dqdiv344 divide 0E+3 7E-1 -> 0E+4
+dqdiv345 divide 0E+3 7E+1 -> 0E+2
+dqdiv346 divide 0E+3 7E+5 -> 0.00
+
+-- These were 'input rounding'
+dqdiv441 divide 12345678000 1 -> 12345678000
+dqdiv442 divide 1 12345678000 -> 8.100000664200054464404466081166219E-11 Inexact Rounded
+dqdiv443 divide 1234567800 1 -> 1234567800
+dqdiv444 divide 1 1234567800 -> 8.100000664200054464404466081166219E-10 Inexact Rounded
+dqdiv445 divide 1234567890 1 -> 1234567890
+dqdiv446 divide 1 1234567890 -> 8.100000073710000670761006103925156E-10 Inexact Rounded
+dqdiv447 divide 1234567891 1 -> 1234567891
+dqdiv448 divide 1 1234567891 -> 8.100000067149000556665214614754629E-10 Inexact Rounded
+dqdiv449 divide 12345678901 1 -> 12345678901
+dqdiv450 divide 1 12345678901 -> 8.100000073053900658873130042376760E-11 Inexact Rounded
+dqdiv451 divide 1234567896 1 -> 1234567896
+dqdiv452 divide 1 1234567896 -> 8.100000034344000145618560617422697E-10 Inexact Rounded
+
+-- high-lows
+dqdiv453 divide 1e+1 1 -> 1E+1
+dqdiv454 divide 1e+1 1.0 -> 1E+1
+dqdiv455 divide 1e+1 1.00 -> 1E+1
+dqdiv456 divide 1e+2 2 -> 5E+1
+dqdiv457 divide 1e+2 2.0 -> 5E+1
+dqdiv458 divide 1e+2 2.00 -> 5E+1
+
+-- some from IEEE discussions
+dqdiv460 divide 3e0 2e0 -> 1.5
+dqdiv461 divide 30e-1 2e0 -> 1.5
+dqdiv462 divide 300e-2 2e0 -> 1.50
+dqdiv464 divide 3000e-3 2e0 -> 1.500
+dqdiv465 divide 3e0 20e-1 -> 1.5
+dqdiv466 divide 30e-1 20e-1 -> 1.5
+dqdiv467 divide 300e-2 20e-1 -> 1.5
+dqdiv468 divide 3000e-3 20e-1 -> 1.50
+dqdiv469 divide 3e0 200e-2 -> 1.5
+dqdiv470 divide 30e-1 200e-2 -> 1.5
+dqdiv471 divide 300e-2 200e-2 -> 1.5
+dqdiv472 divide 3000e-3 200e-2 -> 1.5
+dqdiv473 divide 3e0 2000e-3 -> 1.5
+dqdiv474 divide 30e-1 2000e-3 -> 1.5
+dqdiv475 divide 300e-2 2000e-3 -> 1.5
+dqdiv476 divide 3000e-3 2000e-3 -> 1.5
+
+-- some reciprocals
+dqdiv480 divide 1 1.0E+33 -> 1E-33
+dqdiv481 divide 1 10E+33 -> 1E-34
+dqdiv482 divide 1 1.0E-33 -> 1E+33
+dqdiv483 divide 1 10E-33 -> 1E+32
+
+-- RMS discussion table
+dqdiv484 divide 0e5 1e3 -> 0E+2
+dqdiv485 divide 0e5 2e3 -> 0E+2
+dqdiv486 divide 0e5 10e2 -> 0E+3
+dqdiv487 divide 0e5 20e2 -> 0E+3
+dqdiv488 divide 0e5 100e1 -> 0E+4
+dqdiv489 divide 0e5 200e1 -> 0E+4
+
+dqdiv491 divide 1e5 1e3 -> 1E+2
+dqdiv492 divide 1e5 2e3 -> 5E+1
+dqdiv493 divide 1e5 10e2 -> 1E+2
+dqdiv494 divide 1e5 20e2 -> 5E+1
+dqdiv495 divide 1e5 100e1 -> 1E+2
+dqdiv496 divide 1e5 200e1 -> 5E+1
+
+-- tryzeros cases
+rounding: half_up
+dqdiv497 divide 0E+6108 1000E-33 -> 0E+6111 Clamped
+dqdiv498 divide 0E-6170 1000E+33 -> 0E-6176 Clamped
+
+rounding: half_up
+
+-- focus on trailing zeros issues
+dqdiv500 divide 1 9.9 -> 0.1010101010101010101010101010101010 Inexact Rounded
+dqdiv501 divide 1 9.09 -> 0.1100110011001100110011001100110011 Inexact Rounded
+dqdiv502 divide 1 9.009 -> 0.1110001110001110001110001110001110 Inexact Rounded
+
+dqdiv511 divide 1 2 -> 0.5
+dqdiv512 divide 1.0 2 -> 0.5
+dqdiv513 divide 1.00 2 -> 0.50
+dqdiv514 divide 1.000 2 -> 0.500
+dqdiv515 divide 1.0000 2 -> 0.5000
+dqdiv516 divide 1.00000 2 -> 0.50000
+dqdiv517 divide 1.000000 2 -> 0.500000
+dqdiv518 divide 1.0000000 2 -> 0.5000000
+dqdiv519 divide 1.00 2.00 -> 0.5
+
+dqdiv521 divide 2 1 -> 2
+dqdiv522 divide 2 1.0 -> 2
+dqdiv523 divide 2 1.00 -> 2
+dqdiv524 divide 2 1.000 -> 2
+dqdiv525 divide 2 1.0000 -> 2
+dqdiv526 divide 2 1.00000 -> 2
+dqdiv527 divide 2 1.000000 -> 2
+dqdiv528 divide 2 1.0000000 -> 2
+dqdiv529 divide 2.00 1.00 -> 2
+
+dqdiv530 divide 2.40 2 -> 1.20
+dqdiv531 divide 2.40 4 -> 0.60
+dqdiv532 divide 2.40 10 -> 0.24
+dqdiv533 divide 2.40 2.0 -> 1.2
+dqdiv534 divide 2.40 4.0 -> 0.6
+dqdiv535 divide 2.40 10.0 -> 0.24
+dqdiv536 divide 2.40 2.00 -> 1.2
+dqdiv537 divide 2.40 4.00 -> 0.6
+dqdiv538 divide 2.40 10.00 -> 0.24
+dqdiv539 divide 0.9 0.1 -> 9
+dqdiv540 divide 0.9 0.01 -> 9E+1
+dqdiv541 divide 0.9 0.001 -> 9E+2
+dqdiv542 divide 5 2 -> 2.5
+dqdiv543 divide 5 2.0 -> 2.5
+dqdiv544 divide 5 2.00 -> 2.5
+dqdiv545 divide 5 20 -> 0.25
+dqdiv546 divide 5 20.0 -> 0.25
+dqdiv547 divide 2.400 2 -> 1.200
+dqdiv548 divide 2.400 2.0 -> 1.20
+dqdiv549 divide 2.400 2.400 -> 1
+
+dqdiv550 divide 240 1 -> 240
+dqdiv551 divide 240 10 -> 24
+dqdiv552 divide 240 100 -> 2.4
+dqdiv553 divide 240 1000 -> 0.24
+dqdiv554 divide 2400 1 -> 2400
+dqdiv555 divide 2400 10 -> 240
+dqdiv556 divide 2400 100 -> 24
+dqdiv557 divide 2400 1000 -> 2.4
+
+-- +ve exponent
+dqdiv600 divide 2.4E+9 2 -> 1.2E+9
+dqdiv601 divide 2.40E+9 2 -> 1.20E+9
+dqdiv602 divide 2.400E+9 2 -> 1.200E+9
+dqdiv603 divide 2.4000E+9 2 -> 1.2000E+9
+dqdiv604 divide 24E+8 2 -> 1.2E+9
+dqdiv605 divide 240E+7 2 -> 1.20E+9
+dqdiv606 divide 2400E+6 2 -> 1.200E+9
+dqdiv607 divide 24000E+5 2 -> 1.2000E+9
+
+-- more zeros, etc.
+dqdiv731 divide 5.00 1E-3 -> 5.00E+3
+dqdiv732 divide 00.00 0.000 -> NaN Division_undefined
+dqdiv733 divide 00.00 0E-3 -> NaN Division_undefined
+dqdiv734 divide 0 -0 -> NaN Division_undefined
+dqdiv735 divide -0 0 -> NaN Division_undefined
+dqdiv736 divide -0 -0 -> NaN Division_undefined
+
+dqdiv741 divide 0 -1 -> -0
+dqdiv742 divide -0 -1 -> 0
+dqdiv743 divide 0 1 -> 0
+dqdiv744 divide -0 1 -> -0
+dqdiv745 divide -1 0 -> -Infinity Division_by_zero
+dqdiv746 divide -1 -0 -> Infinity Division_by_zero
+dqdiv747 divide 1 0 -> Infinity Division_by_zero
+dqdiv748 divide 1 -0 -> -Infinity Division_by_zero
+
+dqdiv751 divide 0.0 -1 -> -0.0
+dqdiv752 divide -0.0 -1 -> 0.0
+dqdiv753 divide 0.0 1 -> 0.0
+dqdiv754 divide -0.0 1 -> -0.0
+dqdiv755 divide -1.0 0 -> -Infinity Division_by_zero
+dqdiv756 divide -1.0 -0 -> Infinity Division_by_zero
+dqdiv757 divide 1.0 0 -> Infinity Division_by_zero
+dqdiv758 divide 1.0 -0 -> -Infinity Division_by_zero
+
+dqdiv761 divide 0 -1.0 -> -0E+1
+dqdiv762 divide -0 -1.0 -> 0E+1
+dqdiv763 divide 0 1.0 -> 0E+1
+dqdiv764 divide -0 1.0 -> -0E+1
+dqdiv765 divide -1 0.0 -> -Infinity Division_by_zero
+dqdiv766 divide -1 -0.0 -> Infinity Division_by_zero
+dqdiv767 divide 1 0.0 -> Infinity Division_by_zero
+dqdiv768 divide 1 -0.0 -> -Infinity Division_by_zero
+
+dqdiv771 divide 0.0 -1.0 -> -0
+dqdiv772 divide -0.0 -1.0 -> 0
+dqdiv773 divide 0.0 1.0 -> 0
+dqdiv774 divide -0.0 1.0 -> -0
+dqdiv775 divide -1.0 0.0 -> -Infinity Division_by_zero
+dqdiv776 divide -1.0 -0.0 -> Infinity Division_by_zero
+dqdiv777 divide 1.0 0.0 -> Infinity Division_by_zero
+dqdiv778 divide 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dqdiv780 divide Inf -Inf -> NaN Invalid_operation
+dqdiv781 divide Inf -1000 -> -Infinity
+dqdiv782 divide Inf -1 -> -Infinity
+dqdiv783 divide Inf -0 -> -Infinity
+dqdiv784 divide Inf 0 -> Infinity
+dqdiv785 divide Inf 1 -> Infinity
+dqdiv786 divide Inf 1000 -> Infinity
+dqdiv787 divide Inf Inf -> NaN Invalid_operation
+dqdiv788 divide -1000 Inf -> -0E-6176 Clamped
+dqdiv789 divide -Inf Inf -> NaN Invalid_operation
+dqdiv790 divide -1 Inf -> -0E-6176 Clamped
+dqdiv791 divide -0 Inf -> -0E-6176 Clamped
+dqdiv792 divide 0 Inf -> 0E-6176 Clamped
+dqdiv793 divide 1 Inf -> 0E-6176 Clamped
+dqdiv794 divide 1000 Inf -> 0E-6176 Clamped
+dqdiv795 divide Inf Inf -> NaN Invalid_operation
+
+dqdiv800 divide -Inf -Inf -> NaN Invalid_operation
+dqdiv801 divide -Inf -1000 -> Infinity
+dqdiv802 divide -Inf -1 -> Infinity
+dqdiv803 divide -Inf -0 -> Infinity
+dqdiv804 divide -Inf 0 -> -Infinity
+dqdiv805 divide -Inf 1 -> -Infinity
+dqdiv806 divide -Inf 1000 -> -Infinity
+dqdiv807 divide -Inf Inf -> NaN Invalid_operation
+dqdiv808 divide -1000 Inf -> -0E-6176 Clamped
+dqdiv809 divide -Inf -Inf -> NaN Invalid_operation
+dqdiv810 divide -1 -Inf -> 0E-6176 Clamped
+dqdiv811 divide -0 -Inf -> 0E-6176 Clamped
+dqdiv812 divide 0 -Inf -> -0E-6176 Clamped
+dqdiv813 divide 1 -Inf -> -0E-6176 Clamped
+dqdiv814 divide 1000 -Inf -> -0E-6176 Clamped
+dqdiv815 divide Inf -Inf -> NaN Invalid_operation
+
+dqdiv821 divide NaN -Inf -> NaN
+dqdiv822 divide NaN -1000 -> NaN
+dqdiv823 divide NaN -1 -> NaN
+dqdiv824 divide NaN -0 -> NaN
+dqdiv825 divide NaN 0 -> NaN
+dqdiv826 divide NaN 1 -> NaN
+dqdiv827 divide NaN 1000 -> NaN
+dqdiv828 divide NaN Inf -> NaN
+dqdiv829 divide NaN NaN -> NaN
+dqdiv830 divide -Inf NaN -> NaN
+dqdiv831 divide -1000 NaN -> NaN
+dqdiv832 divide -1 NaN -> NaN
+dqdiv833 divide -0 NaN -> NaN
+dqdiv834 divide 0 NaN -> NaN
+dqdiv835 divide 1 NaN -> NaN
+dqdiv836 divide 1000 NaN -> NaN
+dqdiv837 divide Inf NaN -> NaN
+
+dqdiv841 divide sNaN -Inf -> NaN Invalid_operation
+dqdiv842 divide sNaN -1000 -> NaN Invalid_operation
+dqdiv843 divide sNaN -1 -> NaN Invalid_operation
+dqdiv844 divide sNaN -0 -> NaN Invalid_operation
+dqdiv845 divide sNaN 0 -> NaN Invalid_operation
+dqdiv846 divide sNaN 1 -> NaN Invalid_operation
+dqdiv847 divide sNaN 1000 -> NaN Invalid_operation
+dqdiv848 divide sNaN NaN -> NaN Invalid_operation
+dqdiv849 divide sNaN sNaN -> NaN Invalid_operation
+dqdiv850 divide NaN sNaN -> NaN Invalid_operation
+dqdiv851 divide -Inf sNaN -> NaN Invalid_operation
+dqdiv852 divide -1000 sNaN -> NaN Invalid_operation
+dqdiv853 divide -1 sNaN -> NaN Invalid_operation
+dqdiv854 divide -0 sNaN -> NaN Invalid_operation
+dqdiv855 divide 0 sNaN -> NaN Invalid_operation
+dqdiv856 divide 1 sNaN -> NaN Invalid_operation
+dqdiv857 divide 1000 sNaN -> NaN Invalid_operation
+dqdiv858 divide Inf sNaN -> NaN Invalid_operation
+dqdiv859 divide NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqdiv861 divide NaN9 -Inf -> NaN9
+dqdiv862 divide NaN8 1000 -> NaN8
+dqdiv863 divide NaN7 Inf -> NaN7
+dqdiv864 divide NaN6 NaN5 -> NaN6
+dqdiv865 divide -Inf NaN4 -> NaN4
+dqdiv866 divide -1000 NaN3 -> NaN3
+dqdiv867 divide Inf NaN2 -> NaN2
+
+dqdiv871 divide sNaN99 -Inf -> NaN99 Invalid_operation
+dqdiv872 divide sNaN98 -1 -> NaN98 Invalid_operation
+dqdiv873 divide sNaN97 NaN -> NaN97 Invalid_operation
+dqdiv874 divide sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqdiv875 divide NaN95 sNaN93 -> NaN93 Invalid_operation
+dqdiv876 divide -Inf sNaN92 -> NaN92 Invalid_operation
+dqdiv877 divide 0 sNaN91 -> NaN91 Invalid_operation
+dqdiv878 divide Inf sNaN90 -> NaN90 Invalid_operation
+dqdiv879 divide NaN sNaN89 -> NaN89 Invalid_operation
+
+dqdiv881 divide -NaN9 -Inf -> -NaN9
+dqdiv882 divide -NaN8 1000 -> -NaN8
+dqdiv883 divide -NaN7 Inf -> -NaN7
+dqdiv884 divide -NaN6 -NaN5 -> -NaN6
+dqdiv885 divide -Inf -NaN4 -> -NaN4
+dqdiv886 divide -1000 -NaN3 -> -NaN3
+dqdiv887 divide Inf -NaN2 -> -NaN2
+
+dqdiv891 divide -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqdiv892 divide -sNaN98 -1 -> -NaN98 Invalid_operation
+dqdiv893 divide -sNaN97 NaN -> -NaN97 Invalid_operation
+dqdiv894 divide -sNaN96 -sNaN94 -> -NaN96 Invalid_operation
+dqdiv895 divide -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqdiv896 divide -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqdiv897 divide 0 -sNaN91 -> -NaN91 Invalid_operation
+dqdiv898 divide Inf -sNaN90 -> -NaN90 Invalid_operation
+dqdiv899 divide -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+-- Various flavours of divide by 0
+dqdiv901 divide 0 0 -> NaN Division_undefined
+dqdiv902 divide 0.0E5 0 -> NaN Division_undefined
+dqdiv903 divide 0.000 0 -> NaN Division_undefined
+dqdiv904 divide 0.0001 0 -> Infinity Division_by_zero
+dqdiv905 divide 0.01 0 -> Infinity Division_by_zero
+dqdiv906 divide 0.1 0 -> Infinity Division_by_zero
+dqdiv907 divide 1 0 -> Infinity Division_by_zero
+dqdiv908 divide 1 0.0 -> Infinity Division_by_zero
+dqdiv909 divide 10 0.0 -> Infinity Division_by_zero
+dqdiv910 divide 1E+100 0.0 -> Infinity Division_by_zero
+dqdiv911 divide 1E+100 0 -> Infinity Division_by_zero
+
+dqdiv921 divide -0.0001 0 -> -Infinity Division_by_zero
+dqdiv922 divide -0.01 0 -> -Infinity Division_by_zero
+dqdiv923 divide -0.1 0 -> -Infinity Division_by_zero
+dqdiv924 divide -1 0 -> -Infinity Division_by_zero
+dqdiv925 divide -1 0.0 -> -Infinity Division_by_zero
+dqdiv926 divide -10 0.0 -> -Infinity Division_by_zero
+dqdiv927 divide -1E+100 0.0 -> -Infinity Division_by_zero
+dqdiv928 divide -1E+100 0 -> -Infinity Division_by_zero
+
+dqdiv931 divide 0.0001 -0 -> -Infinity Division_by_zero
+dqdiv932 divide 0.01 -0 -> -Infinity Division_by_zero
+dqdiv933 divide 0.1 -0 -> -Infinity Division_by_zero
+dqdiv934 divide 1 -0 -> -Infinity Division_by_zero
+dqdiv935 divide 1 -0.0 -> -Infinity Division_by_zero
+dqdiv936 divide 10 -0.0 -> -Infinity Division_by_zero
+dqdiv937 divide 1E+100 -0.0 -> -Infinity Division_by_zero
+dqdiv938 divide 1E+100 -0 -> -Infinity Division_by_zero
+
+dqdiv941 divide -0.0001 -0 -> Infinity Division_by_zero
+dqdiv942 divide -0.01 -0 -> Infinity Division_by_zero
+dqdiv943 divide -0.1 -0 -> Infinity Division_by_zero
+dqdiv944 divide -1 -0 -> Infinity Division_by_zero
+dqdiv945 divide -1 -0.0 -> Infinity Division_by_zero
+dqdiv946 divide -10 -0.0 -> Infinity Division_by_zero
+dqdiv947 divide -1E+100 -0.0 -> Infinity Division_by_zero
+dqdiv948 divide -1E+100 -0 -> Infinity Division_by_zero
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqdiv1021 divide 1E0 1E0 -> 1
+dqdiv1022 divide 1E0 2E0 -> 0.5
+dqdiv1023 divide 1E0 3E0 -> 0.3333333333333333333333333333333333 Inexact Rounded
+dqdiv1024 divide 100E-2 1000E-3 -> 1
+dqdiv1025 divide 24E-1 2E0 -> 1.2
+dqdiv1026 divide 2400E-3 2E0 -> 1.200
+dqdiv1027 divide 5E0 2E0 -> 2.5
+dqdiv1028 divide 5E0 20E-1 -> 2.5
+dqdiv1029 divide 5E0 2000E-3 -> 2.5
+dqdiv1030 divide 5E0 2E-1 -> 25
+dqdiv1031 divide 5E0 20E-2 -> 25
+dqdiv1032 divide 480E-2 3E0 -> 1.60
+dqdiv1033 divide 47E-1 2E0 -> 2.35
+
+-- ECMAScript bad examples
+rounding: half_down
+dqdiv1040 divide 5 9 -> 0.5555555555555555555555555555555556 Inexact Rounded
+rounding: half_even
+dqdiv1041 divide 6 11 -> 0.5454545454545454545454545454545455 Inexact Rounded
+
+-- Gyuris example
+dqdiv1050 divide 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0.9999999999999999999999999999991254 Inexact Rounded
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqdiv1751 divide 1e+4277 1e-3311 -> Infinity Overflow Inexact Rounded
+dqdiv1752 divide 1e+4277 -1e-3311 -> -Infinity Overflow Inexact Rounded
+dqdiv1753 divide -1e+4277 1e-3311 -> -Infinity Overflow Inexact Rounded
+dqdiv1754 divide -1e+4277 -1e-3311 -> Infinity Overflow Inexact Rounded
+dqdiv1755 divide 1e-4277 1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1756 divide 1e-4277 -1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1757 divide -1e-4277 1e+3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1758 divide -1e-4277 -1e+3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqdiv1760 divide 1e-6069 1e+101 -> 1E-6170 Subnormal
+dqdiv1761 divide 1e-6069 1e+102 -> 1E-6171 Subnormal
+dqdiv1762 divide 1e-6069 1e+103 -> 1E-6172 Subnormal
+dqdiv1763 divide 1e-6069 1e+104 -> 1E-6173 Subnormal
+dqdiv1764 divide 1e-6069 1e+105 -> 1E-6174 Subnormal
+dqdiv1765 divide 1e-6069 1e+106 -> 1E-6175 Subnormal
+dqdiv1766 divide 1e-6069 1e+107 -> 1E-6176 Subnormal
+dqdiv1767 divide 1e-6069 1e+108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1768 divide 1e-6069 1e+109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1769 divide 1e-6069 1e+110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqdiv1770 divide 1e+40 1e-6101 -> 1.000000000000000000000000000000E+6141 Clamped
+dqdiv1771 divide 1e+40 1e-6102 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqdiv1772 divide 1e+40 1e-6103 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqdiv1773 divide 1e+40 1e-6104 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqdiv1774 divide 1e+40 1e-6105 -> Infinity Overflow Inexact Rounded
+dqdiv1775 divide 1e+40 1e-6106 -> Infinity Overflow Inexact Rounded
+dqdiv1776 divide 1e+40 1e-6107 -> Infinity Overflow Inexact Rounded
+dqdiv1777 divide 1e+40 1e-6108 -> Infinity Overflow Inexact Rounded
+dqdiv1778 divide 1e+40 1e-6109 -> Infinity Overflow Inexact Rounded
+dqdiv1779 divide 1e+40 1e-6110 -> Infinity Overflow Inexact Rounded
+
+dqdiv1801 divide 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
+dqdiv1802 divide 1.000E-6172 1e+1 -> 1.000E-6173 Subnormal
+dqdiv1803 divide 1.00E-6172 1e+2 -> 1.00E-6174 Subnormal
+dqdiv1804 divide 1.0E-6172 1e+3 -> 1.0E-6175 Subnormal
+dqdiv1805 divide 1.0E-6172 1e+4 -> 1E-6176 Subnormal Rounded
+dqdiv1806 divide 1.3E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1807 divide 1.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1808 divide 1.7E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1809 divide 2.3E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1810 divide 2.5E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1811 divide 2.7E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1812 divide 1.49E-6172 1e+4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1813 divide 1.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1814 divide 1.51E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1815 divide 2.49E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1816 divide 2.50E-6172 1e+4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1817 divide 2.51E-6172 1e+4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqdiv1818 divide 1E-6172 1e+4 -> 1E-6176 Subnormal
+dqdiv1819 divide 3E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1820 divide 5E-6172 1e+5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1821 divide 7E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1822 divide 9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1823 divide 9.9E-6172 1e+5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqdiv1824 divide 1E-6172 -1e+4 -> -1E-6176 Subnormal
+dqdiv1825 divide 3E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1826 divide -5E-6172 1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1827 divide 7E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1828 divide -9E-6172 1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1829 divide 9.9E-6172 -1e+5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqdiv1830 divide 3.0E-6172 -1e+5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqdiv1831 divide 1.0E-5977 1e+200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqdiv1832 divide 1.0E-5977 1e+199 -> 1E-6176 Subnormal Rounded
+dqdiv1833 divide 1.0E-5977 1e+198 -> 1.0E-6175 Subnormal
+dqdiv1834 divide 2.0E-5977 2e+198 -> 1.0E-6175 Subnormal
+dqdiv1835 divide 4.0E-5977 4e+198 -> 1.0E-6175 Subnormal
+dqdiv1836 divide 10.0E-5977 10e+198 -> 1.0E-6175 Subnormal
+dqdiv1837 divide 30.0E-5977 30e+198 -> 1.0E-6175 Subnormal
+dqdiv1838 divide 40.0E-5982 40e+166 -> 1.0E-6148 Subnormal
+dqdiv1839 divide 40.0E-5982 40e+165 -> 1.0E-6147 Subnormal
+dqdiv1840 divide 40.0E-5982 40e+164 -> 1.0E-6146 Subnormal
+
+-- randoms
+rounding: half_even
+dqdiv2010 divide -5231195652931651968034356117118850 -7243718664422548573203260970.34995 -> 722169.9095831284624736051460550680 Inexact Rounded
+dqdiv2011 divide -89584669773927.82711237350022515352 -42077943728529635884.21142627532985 -> 0.000002129017291146471565928125887527266 Inexact Rounded
+dqdiv2012 divide -2.828201693360723203806974891946180E-232 812596541221823960386384403089240.9 -> -3.480450075640521320040055759125120E-265 Inexact Rounded
+dqdiv2013 divide -6442775372761069267502937539408720 24904085056.69185465145182606089196 -> -258703556388226463687701.4884719589 Inexact Rounded
+dqdiv2014 divide 5.535520011272625629610079879714705 -44343664650.57203052003068113531208 -> -1.248322630728089308975940533493562E-10 Inexact Rounded
+dqdiv2015 divide 65919273712517865964325.99419625010 -314733354141381737378622515.7789054 -> -0.0002094448295521490616379784758911632 Inexact Rounded
+dqdiv2016 divide -7.779172568193197107115275140431129E+759 -140453015639.3988987652895178782143 -> 5.538629792161641534962774244238115E+748 Inexact Rounded
+dqdiv2017 divide 644314832597569.0181226067518178797 -115024585257425.1635759521565201075 -> -5.601540150356479257367687450922795 Inexact Rounded
+dqdiv2018 divide 6.898640941579611450676592553286870E-47 -11272429881407851485163914999.25943 -> -6.119923578285338689371137648319280E-75 Inexact Rounded
+dqdiv2019 divide -3591344544888727133.30819750163254 5329395.423792795661446561090331037 -> -673874662941.1968525589460533725290 Inexact Rounded
+dqdiv2020 divide -7.682356781384631313156462724425838E+747 -6.60375855512219057281922141809940E+703 -> 1.163330960279556016678379128875149E+44 Inexact Rounded
+dqdiv2021 divide -4511495596596941820863224.274679699 3365395017.263329795449661616090724 -> -1340554548115304.904166888018346299 Inexact Rounded
+dqdiv2022 divide 5.211164127840931517263639608151299 164.5566381356276567012533847006453 -> 0.03166790587655228864478260157156510 Inexact Rounded
+dqdiv2023 divide -49891.2243893458830384077684620383 -47179.9312961860747554053371171530 -> 1.057467084386767291602189656430268 Inexact Rounded
+dqdiv2024 divide 15065477.47214268488077415462413353 4366211.120892953261309529740552596 -> 3.450469309661227984244545513441359 Inexact Rounded
+dqdiv2025 divide 1.575670269440761846109602429612644E+370 653199649324740300.006185482643439 -> 2.412233795700359170904588548041481E+352 Inexact Rounded
+dqdiv2026 divide -2112422311733448924573432192.620145 -80067206.03590693153848215848613406 -> 26383115089417660175.20102646756574 Inexact Rounded
+dqdiv2027 divide -67096536051279809.32218611548721839 -869685412881941081664251990181.1049 -> 7.715035236584805921278566365231168E-14 Inexact Rounded
+dqdiv2028 divide -58612908548962047.21866913425488972 -978449597531.3873665583475633831644 -> 59903.86085991703091236507859837023 Inexact Rounded
+dqdiv2029 divide -133032412010942.1476864138213319796 -7.882059293498670705446528648201359E-428 -> 1.687787506504433064549515681693715E+441 Inexact Rounded
+dqdiv2030 divide 1.83746698338966029492299716360513E+977 -9.897926608979649951672839879128603E+154 -> -1.856416051542212552042390218062458E+822 Inexact Rounded
+dqdiv2031 divide -113742475841399236307128962.1507063 8298602.203049834732657567965262989 -> -13706221006665137826.16557393919929 Inexact Rounded
+dqdiv2032 divide 196.4787574650754152995941808331862 929.6553388472318094427422117172394 -> 0.2113458066176526651006917922814018 Inexact Rounded
+dqdiv2033 divide 71931221465.43867996282803628130350 3838685934206426257090718.402248853 -> 1.873850132527423413607199513324021E-14 Inexact Rounded
+dqdiv2034 divide 488.4282502289651653783596246312885 -80.68940956806634280078706577953188 -> -6.053189047280693318844801899473272 Inexact Rounded
+dqdiv2035 divide 9.001764344963921754981762913247394E-162 -8.585540973667205753734967645386919E-729 -> -1.048479574271827326396012573232934E+567 Inexact Rounded
+dqdiv2036 divide -7.404133959409894743706402857145471E-828 -51.38159929460289711134684843086265 -> 1.441008855516029461032061785219773E-829 Inexact Rounded
+dqdiv2037 divide 2.967520235574419794048994436040717E-613 -6252513855.91394894949879262731889 -> -4.746123405656409127572998751885338E-623 Inexact Rounded
+dqdiv2038 divide -18826852654824040505.83920366765051 -6336924877942437992590557460147340 -> 2.970976146546494669807886278519194E-15 Inexact Rounded
+dqdiv2039 divide -8.101406784809197604949584001735949E+561 4.823300306948942821076681658771635E+361 -> -1.679639721610839204738445747238987E+200 Inexact Rounded
+dqdiv2040 divide -6.11981977773094052331062585191723E+295 1.507610253755339328302779005586534E+238 -> -4.059285058911577244044418416044763E+57 Inexact Rounded
+dqdiv2041 divide 6.472638850046815880599220534274055E-596 -4.475233712083047516933911786159972 -> -1.446324207062261745520496475778879E-596 Inexact Rounded
+dqdiv2042 divide -84438593330.71277839631144509397112 -586684596204401664208947.4054879633 -> 1.439250218550041228759983937772504E-13 Inexact Rounded
+dqdiv2043 divide 9.354533233294022616695815656704369E-24 405.500390626135304252144163591746 -> 2.306911028827774549740571229736198E-26 Inexact Rounded
+dqdiv2044 divide 985606423350210.7374876650149957881 -36811563697.41925681866694859828794 -> -26774.36990864119445335813354717711 Inexact Rounded
+dqdiv2045 divide -8.187280774177715706278002247766311E-123 -38784124393.91212870828430001300068 -> 2.110987653356139147357240727794365E-133 Inexact Rounded
+dqdiv2046 divide -4.612203126350070903459245798371657E+912 7.971562182727956290901984736800519E+64 -> -5.785820922708683237098826662769748E+847 Inexact Rounded
+dqdiv2047 divide 4.661015909421485298247928967977089E+888 -6.360911253323922338737311563845581E+388 -> -7.327591478321365980156654539638836E+499 Inexact Rounded
+dqdiv2048 divide 9156078172903.257500003260710833030 7.189796653262147139071634237964074E-90 -> 1.273482215766000994365201545096026E+102 Inexact Rounded
+dqdiv2049 divide -1.710722303327476586373477781276586E-311 -3167561628260156837329323.729380695 -> 5.400754599578613984875752958645655E-336 Inexact Rounded
+dqdiv2050 divide -4.647935210881806238321616345413021E-878 209388.5431867744648177308460639582 -> -2.219765771394593733140494297388140E-883 Inexact Rounded
+dqdiv2051 divide 5958.694728395760992719084781582700 4.541510156564315632536353171846096E-746 -> 1.312051393253638664947852693005480E+749 Inexact Rounded
+dqdiv2052 divide -7.935732544649702175256699886872093E-489 -7.433329073664793138998765647467971E+360 -> 1.067587949626076917672271619664656E-849 Inexact Rounded
+dqdiv2053 divide -2746650864601157.863589959939901350 7.016684945507647528907184694359598E+548 -> -3.914456593009309529351254950429932E-534 Inexact Rounded
+dqdiv2054 divide 3605149408631197365447953.994569178 -75614025825649082.78264864428237833 -> -47678315.88472693507060063188020532 Inexact Rounded
+dqdiv2055 divide 788194320921798404906375214.196349 -6.222718148433247384932573401976337E-418 -> -1.266639918634671803982222244977287E+444 Inexact Rounded
+dqdiv2056 divide 5620722730534752.758208943447603211 6.843552841168538319123000917657759E-139 -> 8.213164800485434666629970443739554E+153 Inexact Rounded
+dqdiv2057 divide 7304534676713703938102.403949019402 -576169.3685010935108153023803590835 -> -12677756014201995.31969237144394772 Inexact Rounded
+dqdiv2058 divide 8067918762.134621639254916786945547 -8.774771480055536009105596163864758E+954 -> -9.194448858836332156766764605125245E-946 Inexact Rounded
+dqdiv2059 divide 8.702093454123046507578256899537563E-324 -5.875399733016018404580201176576293E-401 -> -1.481106622452052581470443526957335E+77 Inexact Rounded
+dqdiv2060 divide -41426.01662518451861386352415092356 90.00146621684478300510769802013464 -> -460.2815750287318692732067709176200 Inexact Rounded
+
+-- random divide tests with result near 1
+dqdiv4001 divide 2003100352770753969878925664524900 2003100352770753969878925664497824 -> 1.000000000000000000000000000013517 Inexact Rounded
+dqdiv4002 divide 4817785793916490652579552318371645 4817785793916490652579552318362097 -> 1.000000000000000000000000000001982 Inexact Rounded
+dqdiv4003 divide 8299187410920067325648068439560282 8299187410920067325648068439591159 -> 0.9999999999999999999999999999962795 Inexact Rounded
+dqdiv4004 divide 5641088455897407044544461785365899 5641088455897407044544461785389965 -> 0.9999999999999999999999999999957338 Inexact Rounded
+dqdiv4005 divide 5752274694706545359326361313490424 5752274694706545359326361313502723 -> 0.9999999999999999999999999999978619 Inexact Rounded
+dqdiv4006 divide 6762079477373670594829319346099665 6762079477373670594829319346132579 -> 0.9999999999999999999999999999951326 Inexact Rounded
+dqdiv4007 divide 7286425153691890341633023222602916 7286425153691890341633023222606556 -> 0.9999999999999999999999999999995004 Inexact Rounded
+dqdiv4008 divide 9481233991901305727648306421946655 9481233991901305727648306421919124 -> 1.000000000000000000000000000002904 Inexact Rounded
+dqdiv4009 divide 4282053941893951742029444065614311 4282053941893951742029444065583077 -> 1.000000000000000000000000000007294 Inexact Rounded
+dqdiv4010 divide 626888225441250639741781850338695 626888225441250639741781850327299 -> 1.000000000000000000000000000018179 Inexact Rounded
+dqdiv4011 divide 3860973649222028009456598604468547 3860973649222028009456598604476849 -> 0.9999999999999999999999999999978498 Inexact Rounded
+dqdiv4012 divide 4753157080127468127908060607821839 4753157080127468127908060607788379 -> 1.000000000000000000000000000007040 Inexact Rounded
+dqdiv4013 divide 552448546203754062805706277880419 552448546203754062805706277881903 -> 0.9999999999999999999999999999973138 Inexact Rounded
+dqdiv4014 divide 8405954527952158455323713728917395 8405954527952158455323713728933866 -> 0.9999999999999999999999999999980406 Inexact Rounded
+dqdiv4015 divide 7554096502235321142555802238016116 7554096502235321142555802238026546 -> 0.9999999999999999999999999999986193 Inexact Rounded
+dqdiv4016 divide 4053257674127518606871054934746782 4053257674127518606871054934767355 -> 0.9999999999999999999999999999949243 Inexact Rounded
+dqdiv4017 divide 7112419420755090454716888844011582 7112419420755090454716888844038105 -> 0.9999999999999999999999999999962709 Inexact Rounded
+dqdiv4018 divide 3132302137520072728164549730911846 3132302137520072728164549730908416 -> 1.000000000000000000000000000001095 Inexact Rounded
+dqdiv4019 divide 4788374045841416355706715048161013 4788374045841416355706715048190077 -> 0.9999999999999999999999999999939303 Inexact Rounded
+dqdiv4020 divide 9466021636047630218238075099510597 9466021636047630218238075099484053 -> 1.000000000000000000000000000002804 Inexact Rounded
+dqdiv4021 divide 912742745646765625597399692138650 912742745646765625597399692139042 -> 0.9999999999999999999999999999995705 Inexact Rounded
+dqdiv4022 divide 9508402742933643208806264897188504 9508402742933643208806264897195973 -> 0.9999999999999999999999999999992145 Inexact Rounded
+dqdiv4023 divide 1186956795727233704962361914360895 1186956795727233704962361914329577 -> 1.000000000000000000000000000026385 Inexact Rounded
+dqdiv4024 divide 5972210268839014812696916170967938 5972210268839014812696916170954974 -> 1.000000000000000000000000000002171 Inexact Rounded
+dqdiv4025 divide 2303801625521619930894460139793140 2303801625521619930894460139799643 -> 0.9999999999999999999999999999971773 Inexact Rounded
+dqdiv4026 divide 6022231560002898264777393473966595 6022231560002898264777393473947198 -> 1.000000000000000000000000000003221 Inexact Rounded
+dqdiv4027 divide 8426148335801396199969346032210893 8426148335801396199969346032203179 -> 1.000000000000000000000000000000915 Inexact Rounded
+dqdiv4028 divide 8812278947028784637382847098411749 8812278947028784637382847098385317 -> 1.000000000000000000000000000002999 Inexact Rounded
+dqdiv4029 divide 8145282002348367383264197170116146 8145282002348367383264197170083988 -> 1.000000000000000000000000000003948 Inexact Rounded
+dqdiv4030 divide 6821577571876840153123510107387026 6821577571876840153123510107418008 -> 0.9999999999999999999999999999954582 Inexact Rounded
+dqdiv4031 divide 9018555319518966970480565482023720 9018555319518966970480565482013346 -> 1.000000000000000000000000000001150 Inexact Rounded
+dqdiv4032 divide 4602155712998228449640717252788864 4602155712998228449640717252818502 -> 0.9999999999999999999999999999935600 Inexact Rounded
+dqdiv4033 divide 6675607481522785614506828292264472 6675607481522785614506828292277100 -> 0.9999999999999999999999999999981083 Inexact Rounded
+dqdiv4034 divide 4015881516871833897766945836264472 4015881516871833897766945836262645 -> 1.000000000000000000000000000000455 Inexact Rounded
+dqdiv4035 divide 1415580205933411837595459716910365 1415580205933411837595459716880139 -> 1.000000000000000000000000000021352 Inexact Rounded
+dqdiv4036 divide 9432968297069542816752035276361552 9432968297069542816752035276353054 -> 1.000000000000000000000000000000901 Inexact Rounded
+dqdiv4037 divide 4799319591303848500532766682140658 4799319591303848500532766682172655 -> 0.9999999999999999999999999999933330 Inexact Rounded
+dqdiv4038 divide 316854270732839529790584284987472 316854270732839529790584285004832 -> 0.9999999999999999999999999999452114 Inexact Rounded
+dqdiv4039 divide 3598981300592490427826027975697415 3598981300592490427826027975686712 -> 1.000000000000000000000000000002974 Inexact Rounded
+dqdiv4040 divide 1664315435694461371155800682196520 1664315435694461371155800682195617 -> 1.000000000000000000000000000000543 Inexact Rounded
+dqdiv4041 divide 1680872316531128890102855316510581 1680872316531128890102855316495545 -> 1.000000000000000000000000000008945 Inexact Rounded
+dqdiv4042 divide 9881274879566405475755499281644730 9881274879566405475755499281615743 -> 1.000000000000000000000000000002934 Inexact Rounded
+dqdiv4043 divide 4737225957717466960447204232279216 4737225957717466960447204232277452 -> 1.000000000000000000000000000000372 Inexact Rounded
+dqdiv4044 divide 2482097379414867061213319346418288 2482097379414867061213319346387936 -> 1.000000000000000000000000000012228 Inexact Rounded
+dqdiv4045 divide 7406977595233762723576434122161868 7406977595233762723576434122189042 -> 0.9999999999999999999999999999963313 Inexact Rounded
+dqdiv4046 divide 228782057757566047086593281773577 228782057757566047086593281769727 -> 1.000000000000000000000000000016828 Inexact Rounded
+dqdiv4047 divide 2956594270240579648823270540367653 2956594270240579648823270540368556 -> 0.9999999999999999999999999999996946 Inexact Rounded
+dqdiv4048 divide 6326964098897620620534136767634340 6326964098897620620534136767619339 -> 1.000000000000000000000000000002371 Inexact Rounded
+dqdiv4049 divide 414586440456590215247002678327800 414586440456590215247002678316922 -> 1.000000000000000000000000000026238 Inexact Rounded
+dqdiv4050 divide 7364552208570039386220505636779125 7364552208570039386220505636803548 -> 0.9999999999999999999999999999966837 Inexact Rounded
+dqdiv4051 divide 5626266749902369710022824950590056 5626266749902369710022824950591008 -> 0.9999999999999999999999999999998308 Inexact Rounded
+dqdiv4052 divide 4863278293916197454987481343460484 4863278293916197454987481343442522 -> 1.000000000000000000000000000003693 Inexact Rounded
+dqdiv4053 divide 1170713582030637359713249796835483 1170713582030637359713249796823345 -> 1.000000000000000000000000000010368 Inexact Rounded
+dqdiv4054 divide 9838062494725965667776326556052931 9838062494725965667776326556061002 -> 0.9999999999999999999999999999991796 Inexact Rounded
+dqdiv4055 divide 4071388731298861093005687091498922 4071388731298861093005687091498278 -> 1.000000000000000000000000000000158 Inexact Rounded
+dqdiv4056 divide 8753155722324706795855038590272526 8753155722324706795855038590276656 -> 0.9999999999999999999999999999995282 Inexact Rounded
+dqdiv4057 divide 4399941911533273418844742658240485 4399941911533273418844742658219891 -> 1.000000000000000000000000000004681 Inexact Rounded
+dqdiv4058 divide 4127884159949503677776430620050269 4127884159949503677776430620026091 -> 1.000000000000000000000000000005857 Inexact Rounded
+dqdiv4059 divide 5536160822360800067042528317438808 5536160822360800067042528317450687 -> 0.9999999999999999999999999999978543 Inexact Rounded
+dqdiv4060 divide 3973234998468664936671088237710246 3973234998468664936671088237741886 -> 0.9999999999999999999999999999920367 Inexact Rounded
+dqdiv4061 divide 9824855935638263593410444142327358 9824855935638263593410444142328576 -> 0.9999999999999999999999999999998760 Inexact Rounded
+dqdiv4062 divide 5917078517340218131867327300814867 5917078517340218131867327300788701 -> 1.000000000000000000000000000004422 Inexact Rounded
+dqdiv4063 divide 4354236601830544882286139612521362 4354236601830544882286139612543223 -> 0.9999999999999999999999999999949794 Inexact Rounded
+dqdiv4064 divide 8058474772375259017342110013891294 8058474772375259017342110013906792 -> 0.9999999999999999999999999999980768 Inexact Rounded
+dqdiv4065 divide 5519604020981748170517093746166328 5519604020981748170517093746181763 -> 0.9999999999999999999999999999972036 Inexact Rounded
+dqdiv4066 divide 1502130966879805458831323782443139 1502130966879805458831323782412213 -> 1.000000000000000000000000000020588 Inexact Rounded
+dqdiv4067 divide 562795633719481212915159787980270 562795633719481212915159788007066 -> 0.9999999999999999999999999999523877 Inexact Rounded
+dqdiv4068 divide 6584743324494664273941281557268878 6584743324494664273941281557258945 -> 1.000000000000000000000000000001508 Inexact Rounded
+dqdiv4069 divide 3632000327285743997976431109416500 3632000327285743997976431109408107 -> 1.000000000000000000000000000002311 Inexact Rounded
+dqdiv4070 divide 1145827237315430089388953838561450 1145827237315430089388953838527332 -> 1.000000000000000000000000000029776 Inexact Rounded
+dqdiv4071 divide 8874431010357691869725372317350380 8874431010357691869725372317316472 -> 1.000000000000000000000000000003821 Inexact Rounded
+dqdiv4072 divide 992948718902804648119753141202196 992948718902804648119753141235222 -> 0.9999999999999999999999999999667395 Inexact Rounded
+dqdiv4073 divide 2522735183374218505142417265439989 2522735183374218505142417265453779 -> 0.9999999999999999999999999999945337 Inexact Rounded
+dqdiv4074 divide 2668419161912936508006872303501052 2668419161912936508006872303471036 -> 1.000000000000000000000000000011249 Inexact Rounded
+dqdiv4075 divide 3036169085665186712590941111775092 3036169085665186712590941111808846 -> 0.9999999999999999999999999999888827 Inexact Rounded
+dqdiv4076 divide 9441634604917231638508898934006147 9441634604917231638508898934000288 -> 1.000000000000000000000000000000621 Inexact Rounded
+dqdiv4077 divide 2677301353164377091111458811839190 2677301353164377091111458811867722 -> 0.9999999999999999999999999999893430 Inexact Rounded
+dqdiv4078 divide 6844979203112066166583765857171426 6844979203112066166583765857189682 -> 0.9999999999999999999999999999973329 Inexact Rounded
+dqdiv4079 divide 2220337435141796724323783960231661 2220337435141796724323783960208778 -> 1.000000000000000000000000000010306 Inexact Rounded
+dqdiv4080 divide 6447424700019783931569996989561380 6447424700019783931569996989572454 -> 0.9999999999999999999999999999982824 Inexact Rounded
+dqdiv4081 divide 7512856762696607119847092195587180 7512856762696607119847092195557346 -> 1.000000000000000000000000000003971 Inexact Rounded
+dqdiv4082 divide 7395261981193960399087819077237482 7395261981193960399087819077242487 -> 0.9999999999999999999999999999993232 Inexact Rounded
+dqdiv4083 divide 2253442467682584035792724884376735 2253442467682584035792724884407178 -> 0.9999999999999999999999999999864904 Inexact Rounded
+dqdiv4084 divide 8153138680300213135577336466190997 8153138680300213135577336466220607 -> 0.9999999999999999999999999999963683 Inexact Rounded
+dqdiv4085 divide 4668731252254148074041022681801390 4668731252254148074041022681778101 -> 1.000000000000000000000000000004988 Inexact Rounded
+dqdiv4086 divide 6078404557993669696040425501815056 6078404557993669696040425501797612 -> 1.000000000000000000000000000002870 Inexact Rounded
+dqdiv4087 divide 2306352359874261623223356878316278 2306352359874261623223356878335612 -> 0.9999999999999999999999999999916171 Inexact Rounded
+dqdiv4088 divide 3264842186668480362900909564091908 3264842186668480362900909564058658 -> 1.000000000000000000000000000010184 Inexact Rounded
+dqdiv4089 divide 6971985047279636878957959608612204 6971985047279636878957959608615088 -> 0.9999999999999999999999999999995863 Inexact Rounded
+dqdiv4090 divide 5262810889952721235466445973816257 5262810889952721235466445973783077 -> 1.000000000000000000000000000006305 Inexact Rounded
+dqdiv4091 divide 7947944731035267178548357070080288 7947944731035267178548357070061339 -> 1.000000000000000000000000000002384 Inexact Rounded
+dqdiv4092 divide 5071808908395375108383035800443229 5071808908395375108383035800412429 -> 1.000000000000000000000000000006073 Inexact Rounded
+dqdiv4093 divide 2043146542084503655511507209262969 2043146542084503655511507209249263 -> 1.000000000000000000000000000006708 Inexact Rounded
+dqdiv4094 divide 4097632735384534181661959731264802 4097632735384534181661959731234499 -> 1.000000000000000000000000000007395 Inexact Rounded
+dqdiv4095 divide 3061477642831387489729464587044430 3061477642831387489729464587059452 -> 0.9999999999999999999999999999950932 Inexact Rounded
+dqdiv4096 divide 3429854941039776159498802936252638 3429854941039776159498802936246415 -> 1.000000000000000000000000000001814 Inexact Rounded
+dqdiv4097 divide 4874324979578599700024133278284545 4874324979578599700024133278262131 -> 1.000000000000000000000000000004598 Inexact Rounded
+dqdiv4098 divide 5701652369691833541455978515820882 5701652369691833541455978515834854 -> 0.9999999999999999999999999999975495 Inexact Rounded
+dqdiv4099 divide 2928205728402945266953255632343113 2928205728402945266953255632373794 -> 0.9999999999999999999999999999895223 Inexact Rounded
+
+-- Null tests
+dqdiv9998 divide 10 # -> NaN Invalid_operation
+dqdiv9999 divide # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqDivideInt.decTest b/Lib/test/decimaltestdata/dqDivideInt.decTest
index c29035119fb..3fec6dbaa37 100644
--- a/Lib/test/decimaltestdata/dqDivideInt.decTest
+++ b/Lib/test/decimaltestdata/dqDivideInt.decTest
@@ -1,453 +1,453 @@
-------------------------------------------------------------------------
--- dqDivideInt.decTest -- decQuad integer division --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-
-dqdvi001 divideint 1 1 -> 1
-dqdvi002 divideint 2 1 -> 2
-dqdvi003 divideint 1 2 -> 0
-dqdvi004 divideint 2 2 -> 1
-dqdvi005 divideint 0 1 -> 0
-dqdvi006 divideint 0 2 -> 0
-dqdvi007 divideint 1 3 -> 0
-dqdvi008 divideint 2 3 -> 0
-dqdvi009 divideint 3 3 -> 1
-
-dqdvi010 divideint 2.4 1 -> 2
-dqdvi011 divideint 2.4 -1 -> -2
-dqdvi012 divideint -2.4 1 -> -2
-dqdvi013 divideint -2.4 -1 -> 2
-dqdvi014 divideint 2.40 1 -> 2
-dqdvi015 divideint 2.400 1 -> 2
-dqdvi016 divideint 2.4 2 -> 1
-dqdvi017 divideint 2.400 2 -> 1
-dqdvi018 divideint 2. 2 -> 1
-dqdvi019 divideint 20 20 -> 1
-
-dqdvi020 divideint 187 187 -> 1
-dqdvi021 divideint 5 2 -> 2
-dqdvi022 divideint 5 2.0 -> 2
-dqdvi023 divideint 5 2.000 -> 2
-dqdvi024 divideint 5 0.200 -> 25
-dqdvi025 divideint 5 0.200 -> 25
-
-dqdvi030 divideint 1 2 -> 0
-dqdvi031 divideint 1 4 -> 0
-dqdvi032 divideint 1 8 -> 0
-dqdvi033 divideint 1 16 -> 0
-dqdvi034 divideint 1 32 -> 0
-dqdvi035 divideint 1 64 -> 0
-dqdvi040 divideint 1 -2 -> -0
-dqdvi041 divideint 1 -4 -> -0
-dqdvi042 divideint 1 -8 -> -0
-dqdvi043 divideint 1 -16 -> -0
-dqdvi044 divideint 1 -32 -> -0
-dqdvi045 divideint 1 -64 -> -0
-dqdvi050 divideint -1 2 -> -0
-dqdvi051 divideint -1 4 -> -0
-dqdvi052 divideint -1 8 -> -0
-dqdvi053 divideint -1 16 -> -0
-dqdvi054 divideint -1 32 -> -0
-dqdvi055 divideint -1 64 -> -0
-dqdvi060 divideint -1 -2 -> 0
-dqdvi061 divideint -1 -4 -> 0
-dqdvi062 divideint -1 -8 -> 0
-dqdvi063 divideint -1 -16 -> 0
-dqdvi064 divideint -1 -32 -> 0
-dqdvi065 divideint -1 -64 -> 0
-
--- similar with powers of ten
-dqdvi160 divideint 1 1 -> 1
-dqdvi161 divideint 1 10 -> 0
-dqdvi162 divideint 1 100 -> 0
-dqdvi163 divideint 1 1000 -> 0
-dqdvi164 divideint 1 10000 -> 0
-dqdvi165 divideint 1 100000 -> 0
-dqdvi166 divideint 1 1000000 -> 0
-dqdvi167 divideint 1 10000000 -> 0
-dqdvi168 divideint 1 100000000 -> 0
-dqdvi170 divideint 1 -1 -> -1
-dqdvi171 divideint 1 -10 -> -0
-dqdvi172 divideint 1 -100 -> -0
-dqdvi173 divideint 1 -1000 -> -0
-dqdvi174 divideint 1 -10000 -> -0
-dqdvi175 divideint 1 -100000 -> -0
-dqdvi176 divideint 1 -1000000 -> -0
-dqdvi177 divideint 1 -10000000 -> -0
-dqdvi178 divideint 1 -100000000 -> -0
-dqdvi180 divideint -1 1 -> -1
-dqdvi181 divideint -1 10 -> -0
-dqdvi182 divideint -1 100 -> -0
-dqdvi183 divideint -1 1000 -> -0
-dqdvi184 divideint -1 10000 -> -0
-dqdvi185 divideint -1 100000 -> -0
-dqdvi186 divideint -1 1000000 -> -0
-dqdvi187 divideint -1 10000000 -> -0
-dqdvi188 divideint -1 100000000 -> -0
-dqdvi190 divideint -1 -1 -> 1
-dqdvi191 divideint -1 -10 -> 0
-dqdvi192 divideint -1 -100 -> 0
-dqdvi193 divideint -1 -1000 -> 0
-dqdvi194 divideint -1 -10000 -> 0
-dqdvi195 divideint -1 -100000 -> 0
-dqdvi196 divideint -1 -1000000 -> 0
-dqdvi197 divideint -1 -10000000 -> 0
-dqdvi198 divideint -1 -100000000 -> 0
-
--- some long operand (at p=9) cases
-dqdvi070 divideint 999999999 1 -> 999999999
-dqdvi071 divideint 999999999.4 1 -> 999999999
-dqdvi072 divideint 999999999.5 1 -> 999999999
-dqdvi073 divideint 999999999.9 1 -> 999999999
-dqdvi074 divideint 999999999.999 1 -> 999999999
-
-dqdvi090 divideint 0. 1 -> 0
-dqdvi091 divideint .0 1 -> 0
-dqdvi092 divideint 0.00 1 -> 0
-dqdvi093 divideint 0.00E+9 1 -> 0
-dqdvi094 divideint 0.0000E-50 1 -> 0
-
-dqdvi100 divideint 1 1 -> 1
-dqdvi101 divideint 1 2 -> 0
-dqdvi102 divideint 1 3 -> 0
-dqdvi103 divideint 1 4 -> 0
-dqdvi104 divideint 1 5 -> 0
-dqdvi105 divideint 1 6 -> 0
-dqdvi106 divideint 1 7 -> 0
-dqdvi107 divideint 1 8 -> 0
-dqdvi108 divideint 1 9 -> 0
-dqdvi109 divideint 1 10 -> 0
-dqdvi110 divideint 1 1 -> 1
-dqdvi111 divideint 2 1 -> 2
-dqdvi112 divideint 3 1 -> 3
-dqdvi113 divideint 4 1 -> 4
-dqdvi114 divideint 5 1 -> 5
-dqdvi115 divideint 6 1 -> 6
-dqdvi116 divideint 7 1 -> 7
-dqdvi117 divideint 8 1 -> 8
-dqdvi118 divideint 9 1 -> 9
-dqdvi119 divideint 10 1 -> 10
-
--- from DiagBigDecimal
-dqdvi131 divideint 101.3 1 -> 101
-dqdvi132 divideint 101.0 1 -> 101
-dqdvi133 divideint 101.3 3 -> 33
-dqdvi134 divideint 101.0 3 -> 33
-dqdvi135 divideint 2.4 1 -> 2
-dqdvi136 divideint 2.400 1 -> 2
-dqdvi137 divideint 18 18 -> 1
-dqdvi138 divideint 1120 1000 -> 1
-dqdvi139 divideint 2.4 2 -> 1
-dqdvi140 divideint 2.400 2 -> 1
-dqdvi141 divideint 0.5 2.000 -> 0
-dqdvi142 divideint 8.005 7 -> 1
-dqdvi143 divideint 5 2 -> 2
-dqdvi144 divideint 0 2 -> 0
-dqdvi145 divideint 0.00 2 -> 0
-
--- Others
-dqdvi150 divideint 12345 4.999 -> 2469
-dqdvi151 divideint 12345 4.99 -> 2473
-dqdvi152 divideint 12345 4.9 -> 2519
-dqdvi153 divideint 12345 5 -> 2469
-dqdvi154 divideint 12345 5.1 -> 2420
-dqdvi155 divideint 12345 5.01 -> 2464
-dqdvi156 divideint 12345 5.001 -> 2468
-dqdvi157 divideint 101 7.6 -> 13
-
--- Various flavours of divideint by 0
-dqdvi201 divideint 0 0 -> NaN Division_undefined
-dqdvi202 divideint 0.0E5 0 -> NaN Division_undefined
-dqdvi203 divideint 0.000 0 -> NaN Division_undefined
-dqdvi204 divideint 0.0001 0 -> Infinity Division_by_zero
-dqdvi205 divideint 0.01 0 -> Infinity Division_by_zero
-dqdvi206 divideint 0.1 0 -> Infinity Division_by_zero
-dqdvi207 divideint 1 0 -> Infinity Division_by_zero
-dqdvi208 divideint 1 0.0 -> Infinity Division_by_zero
-dqdvi209 divideint 10 0.0 -> Infinity Division_by_zero
-dqdvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
-dqdvi211 divideint 1E+380 0 -> Infinity Division_by_zero
-dqdvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
-dqdvi215 divideint -0.01 0 -> -Infinity Division_by_zero
-dqdvi216 divideint -0.1 0 -> -Infinity Division_by_zero
-dqdvi217 divideint -1 0 -> -Infinity Division_by_zero
-dqdvi218 divideint -1 0.0 -> -Infinity Division_by_zero
-dqdvi219 divideint -10 0.0 -> -Infinity Division_by_zero
-dqdvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
-dqdvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
-
--- test some cases that are close to exponent overflow
-dqdvi270 divideint 1 1e384 -> 0
-dqdvi271 divideint 1 0.9e384 -> 0
-dqdvi272 divideint 1 0.99e384 -> 0
-dqdvi273 divideint 1 0.9999999999999999e384 -> 0
-dqdvi274 divideint 9e384 1 -> NaN Division_impossible
-dqdvi275 divideint 9.9e384 1 -> NaN Division_impossible
-dqdvi276 divideint 9.99e384 1 -> NaN Division_impossible
-dqdvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
-
-dqdvi280 divideint 0.1 9e-383 -> NaN Division_impossible
-dqdvi281 divideint 0.1 99e-383 -> NaN Division_impossible
-dqdvi282 divideint 0.1 999e-383 -> NaN Division_impossible
-dqdvi283 divideint 0.1 9e-382 -> NaN Division_impossible
-dqdvi284 divideint 0.1 99e-382 -> NaN Division_impossible
-
--- GD edge cases: lhs smaller than rhs but more digits
-dqdvi301 divideint 0.9 2 -> 0
-dqdvi302 divideint 0.9 2.0 -> 0
-dqdvi303 divideint 0.9 2.1 -> 0
-dqdvi304 divideint 0.9 2.00 -> 0
-dqdvi305 divideint 0.9 2.01 -> 0
-dqdvi306 divideint 0.12 1 -> 0
-dqdvi307 divideint 0.12 1.0 -> 0
-dqdvi308 divideint 0.12 1.00 -> 0
-dqdvi309 divideint 0.12 1.0 -> 0
-dqdvi310 divideint 0.12 1.00 -> 0
-dqdvi311 divideint 0.12 2 -> 0
-dqdvi312 divideint 0.12 2.0 -> 0
-dqdvi313 divideint 0.12 2.1 -> 0
-dqdvi314 divideint 0.12 2.00 -> 0
-dqdvi315 divideint 0.12 2.01 -> 0
-
--- edge cases of impossible
-dqdvi330 divideint 1234567987654321987654321890123456 10 -> 123456798765432198765432189012345
-dqdvi331 divideint 1234567987654321987654321890123456 1 -> 1234567987654321987654321890123456
-dqdvi332 divideint 1234567987654321987654321890123456 0.1 -> NaN Division_impossible
-dqdvi333 divideint 1234567987654321987654321890123456 0.01 -> NaN Division_impossible
-
--- overflow and underflow tests [from divide]
-dqdvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
-dqdvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
-dqdvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
-dqdvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
-dqdvi1055 divideint 1e-277 1e+311 -> 0
-dqdvi1056 divideint 1e-277 -1e+311 -> -0
-dqdvi1057 divideint -1e-277 1e+311 -> -0
-dqdvi1058 divideint -1e-277 -1e+311 -> 0
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqdvi1060 divideint 1e-291 1e+101 -> 0
-dqdvi1061 divideint 1e-291 1e+102 -> 0
-dqdvi1062 divideint 1e-291 1e+103 -> 0
-dqdvi1063 divideint 1e-291 1e+104 -> 0
-dqdvi1064 divideint 1e-291 1e+105 -> 0
-dqdvi1065 divideint 1e-291 1e+106 -> 0
-dqdvi1066 divideint 1e-291 1e+107 -> 0
-dqdvi1067 divideint 1e-291 1e+108 -> 0
-dqdvi1068 divideint 1e-291 1e+109 -> 0
-dqdvi1069 divideint 1e-291 1e+110 -> 0
-
-dqdvi1101 divideint 1.0000E-394 1 -> 0
-dqdvi1102 divideint 1.000E-394 1e+1 -> 0
-dqdvi1103 divideint 1.00E-394 1e+2 -> 0
-
-dqdvi1118 divideint 1E-394 1e+4 -> 0
-dqdvi1119 divideint 3E-394 -1e+5 -> -0
-dqdvi1120 divideint 5E-394 1e+5 -> 0
-
-dqdvi1124 divideint 1E-394 -1e+4 -> -0
-dqdvi1130 divideint 3.0E-394 -1e+5 -> -0
-
-dqdvi1131 divideint 1.0E-199 1e+200 -> 0
-dqdvi1132 divideint 1.0E-199 1e+199 -> 0
-dqdvi1133 divideint 1.0E-199 1e+198 -> 0
-dqdvi1134 divideint 2.0E-199 2e+198 -> 0
-dqdvi1135 divideint 4.0E-199 4e+198 -> 0
-
--- long operand checks
-dqdvi401 divideint 12345678000 100 -> 123456780
-dqdvi402 divideint 1 12345678000 -> 0
-dqdvi403 divideint 1234567800 10 -> 123456780
-dqdvi404 divideint 1 1234567800 -> 0
-dqdvi405 divideint 1234567890 10 -> 123456789
-dqdvi406 divideint 1 1234567890 -> 0
-dqdvi407 divideint 1234567891 10 -> 123456789
-dqdvi408 divideint 1 1234567891 -> 0
-dqdvi409 divideint 12345678901 100 -> 123456789
-dqdvi410 divideint 1 12345678901 -> 0
-dqdvi411 divideint 1234567896 10 -> 123456789
-dqdvi412 divideint 1 1234567896 -> 0
-dqdvi413 divideint 12345678948 100 -> 123456789
-dqdvi414 divideint 12345678949 100 -> 123456789
-dqdvi415 divideint 12345678950 100 -> 123456789
-dqdvi416 divideint 12345678951 100 -> 123456789
-dqdvi417 divideint 12345678999 100 -> 123456789
-dqdvi441 divideint 12345678000 1 -> 12345678000
-dqdvi442 divideint 1 12345678000 -> 0
-dqdvi443 divideint 1234567800 1 -> 1234567800
-dqdvi444 divideint 1 1234567800 -> 0
-dqdvi445 divideint 1234567890 1 -> 1234567890
-dqdvi446 divideint 1 1234567890 -> 0
-dqdvi447 divideint 1234567891 1 -> 1234567891
-dqdvi448 divideint 1 1234567891 -> 0
-dqdvi449 divideint 12345678901 1 -> 12345678901
-dqdvi450 divideint 1 12345678901 -> 0
-dqdvi451 divideint 1234567896 1 -> 1234567896
-dqdvi452 divideint 1 1234567896 -> 0
-
--- more zeros, etc.
-dqdvi531 divideint 5.00 1E-3 -> 5000
-dqdvi532 divideint 00.00 0.000 -> NaN Division_undefined
-dqdvi533 divideint 00.00 0E-3 -> NaN Division_undefined
-dqdvi534 divideint 0 -0 -> NaN Division_undefined
-dqdvi535 divideint -0 0 -> NaN Division_undefined
-dqdvi536 divideint -0 -0 -> NaN Division_undefined
-
-dqdvi541 divideint 0 -1 -> -0
-dqdvi542 divideint -0 -1 -> 0
-dqdvi543 divideint 0 1 -> 0
-dqdvi544 divideint -0 1 -> -0
-dqdvi545 divideint -1 0 -> -Infinity Division_by_zero
-dqdvi546 divideint -1 -0 -> Infinity Division_by_zero
-dqdvi547 divideint 1 0 -> Infinity Division_by_zero
-dqdvi548 divideint 1 -0 -> -Infinity Division_by_zero
-
-dqdvi551 divideint 0.0 -1 -> -0
-dqdvi552 divideint -0.0 -1 -> 0
-dqdvi553 divideint 0.0 1 -> 0
-dqdvi554 divideint -0.0 1 -> -0
-dqdvi555 divideint -1.0 0 -> -Infinity Division_by_zero
-dqdvi556 divideint -1.0 -0 -> Infinity Division_by_zero
-dqdvi557 divideint 1.0 0 -> Infinity Division_by_zero
-dqdvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
-
-dqdvi561 divideint 0 -1.0 -> -0
-dqdvi562 divideint -0 -1.0 -> 0
-dqdvi563 divideint 0 1.0 -> 0
-dqdvi564 divideint -0 1.0 -> -0
-dqdvi565 divideint -1 0.0 -> -Infinity Division_by_zero
-dqdvi566 divideint -1 -0.0 -> Infinity Division_by_zero
-dqdvi567 divideint 1 0.0 -> Infinity Division_by_zero
-dqdvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
-
-dqdvi571 divideint 0.0 -1.0 -> -0
-dqdvi572 divideint -0.0 -1.0 -> 0
-dqdvi573 divideint 0.0 1.0 -> 0
-dqdvi574 divideint -0.0 1.0 -> -0
-dqdvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
-dqdvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
-dqdvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
-dqdvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
-
--- Specials
-dqdvi580 divideint Inf -Inf -> NaN Invalid_operation
-dqdvi581 divideint Inf -1000 -> -Infinity
-dqdvi582 divideint Inf -1 -> -Infinity
-dqdvi583 divideint Inf -0 -> -Infinity
-dqdvi584 divideint Inf 0 -> Infinity
-dqdvi585 divideint Inf 1 -> Infinity
-dqdvi586 divideint Inf 1000 -> Infinity
-dqdvi587 divideint Inf Inf -> NaN Invalid_operation
-dqdvi588 divideint -1000 Inf -> -0
-dqdvi589 divideint -Inf Inf -> NaN Invalid_operation
-dqdvi590 divideint -1 Inf -> -0
-dqdvi591 divideint -0 Inf -> -0
-dqdvi592 divideint 0 Inf -> 0
-dqdvi593 divideint 1 Inf -> 0
-dqdvi594 divideint 1000 Inf -> 0
-dqdvi595 divideint Inf Inf -> NaN Invalid_operation
-
-dqdvi600 divideint -Inf -Inf -> NaN Invalid_operation
-dqdvi601 divideint -Inf -1000 -> Infinity
-dqdvi602 divideint -Inf -1 -> Infinity
-dqdvi603 divideint -Inf -0 -> Infinity
-dqdvi604 divideint -Inf 0 -> -Infinity
-dqdvi605 divideint -Inf 1 -> -Infinity
-dqdvi606 divideint -Inf 1000 -> -Infinity
-dqdvi607 divideint -Inf Inf -> NaN Invalid_operation
-dqdvi608 divideint -1000 Inf -> -0
-dqdvi609 divideint -Inf -Inf -> NaN Invalid_operation
-dqdvi610 divideint -1 -Inf -> 0
-dqdvi611 divideint -0 -Inf -> 0
-dqdvi612 divideint 0 -Inf -> -0
-dqdvi613 divideint 1 -Inf -> -0
-dqdvi614 divideint 1000 -Inf -> -0
-dqdvi615 divideint Inf -Inf -> NaN Invalid_operation
-
-dqdvi621 divideint NaN -Inf -> NaN
-dqdvi622 divideint NaN -1000 -> NaN
-dqdvi623 divideint NaN -1 -> NaN
-dqdvi624 divideint NaN -0 -> NaN
-dqdvi625 divideint NaN 0 -> NaN
-dqdvi626 divideint NaN 1 -> NaN
-dqdvi627 divideint NaN 1000 -> NaN
-dqdvi628 divideint NaN Inf -> NaN
-dqdvi629 divideint NaN NaN -> NaN
-dqdvi630 divideint -Inf NaN -> NaN
-dqdvi631 divideint -1000 NaN -> NaN
-dqdvi632 divideint -1 NaN -> NaN
-dqdvi633 divideint -0 NaN -> NaN
-dqdvi634 divideint 0 NaN -> NaN
-dqdvi635 divideint 1 NaN -> NaN
-dqdvi636 divideint 1000 NaN -> NaN
-dqdvi637 divideint Inf NaN -> NaN
-
-dqdvi641 divideint sNaN -Inf -> NaN Invalid_operation
-dqdvi642 divideint sNaN -1000 -> NaN Invalid_operation
-dqdvi643 divideint sNaN -1 -> NaN Invalid_operation
-dqdvi644 divideint sNaN -0 -> NaN Invalid_operation
-dqdvi645 divideint sNaN 0 -> NaN Invalid_operation
-dqdvi646 divideint sNaN 1 -> NaN Invalid_operation
-dqdvi647 divideint sNaN 1000 -> NaN Invalid_operation
-dqdvi648 divideint sNaN NaN -> NaN Invalid_operation
-dqdvi649 divideint sNaN sNaN -> NaN Invalid_operation
-dqdvi650 divideint NaN sNaN -> NaN Invalid_operation
-dqdvi651 divideint -Inf sNaN -> NaN Invalid_operation
-dqdvi652 divideint -1000 sNaN -> NaN Invalid_operation
-dqdvi653 divideint -1 sNaN -> NaN Invalid_operation
-dqdvi654 divideint -0 sNaN -> NaN Invalid_operation
-dqdvi655 divideint 0 sNaN -> NaN Invalid_operation
-dqdvi656 divideint 1 sNaN -> NaN Invalid_operation
-dqdvi657 divideint 1000 sNaN -> NaN Invalid_operation
-dqdvi658 divideint Inf sNaN -> NaN Invalid_operation
-dqdvi659 divideint NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqdvi661 divideint NaN9 -Inf -> NaN9
-dqdvi662 divideint NaN8 1000 -> NaN8
-dqdvi663 divideint NaN7 Inf -> NaN7
-dqdvi664 divideint -NaN6 NaN5 -> -NaN6
-dqdvi665 divideint -Inf NaN4 -> NaN4
-dqdvi666 divideint -1000 NaN3 -> NaN3
-dqdvi667 divideint Inf -NaN2 -> -NaN2
-
-dqdvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqdvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
-dqdvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
-dqdvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqdvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
-dqdvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
-dqdvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
-dqdvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
-dqdvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
-
--- Gyuris example
-dqdvi700 divideint 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0
-
--- Null tests
-dqdvi900 divideint 10 # -> NaN Invalid_operation
-dqdvi901 divideint # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqDivideInt.decTest -- decQuad integer division --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+
+dqdvi001 divideint 1 1 -> 1
+dqdvi002 divideint 2 1 -> 2
+dqdvi003 divideint 1 2 -> 0
+dqdvi004 divideint 2 2 -> 1
+dqdvi005 divideint 0 1 -> 0
+dqdvi006 divideint 0 2 -> 0
+dqdvi007 divideint 1 3 -> 0
+dqdvi008 divideint 2 3 -> 0
+dqdvi009 divideint 3 3 -> 1
+
+dqdvi010 divideint 2.4 1 -> 2
+dqdvi011 divideint 2.4 -1 -> -2
+dqdvi012 divideint -2.4 1 -> -2
+dqdvi013 divideint -2.4 -1 -> 2
+dqdvi014 divideint 2.40 1 -> 2
+dqdvi015 divideint 2.400 1 -> 2
+dqdvi016 divideint 2.4 2 -> 1
+dqdvi017 divideint 2.400 2 -> 1
+dqdvi018 divideint 2. 2 -> 1
+dqdvi019 divideint 20 20 -> 1
+
+dqdvi020 divideint 187 187 -> 1
+dqdvi021 divideint 5 2 -> 2
+dqdvi022 divideint 5 2.0 -> 2
+dqdvi023 divideint 5 2.000 -> 2
+dqdvi024 divideint 5 0.200 -> 25
+dqdvi025 divideint 5 0.200 -> 25
+
+dqdvi030 divideint 1 2 -> 0
+dqdvi031 divideint 1 4 -> 0
+dqdvi032 divideint 1 8 -> 0
+dqdvi033 divideint 1 16 -> 0
+dqdvi034 divideint 1 32 -> 0
+dqdvi035 divideint 1 64 -> 0
+dqdvi040 divideint 1 -2 -> -0
+dqdvi041 divideint 1 -4 -> -0
+dqdvi042 divideint 1 -8 -> -0
+dqdvi043 divideint 1 -16 -> -0
+dqdvi044 divideint 1 -32 -> -0
+dqdvi045 divideint 1 -64 -> -0
+dqdvi050 divideint -1 2 -> -0
+dqdvi051 divideint -1 4 -> -0
+dqdvi052 divideint -1 8 -> -0
+dqdvi053 divideint -1 16 -> -0
+dqdvi054 divideint -1 32 -> -0
+dqdvi055 divideint -1 64 -> -0
+dqdvi060 divideint -1 -2 -> 0
+dqdvi061 divideint -1 -4 -> 0
+dqdvi062 divideint -1 -8 -> 0
+dqdvi063 divideint -1 -16 -> 0
+dqdvi064 divideint -1 -32 -> 0
+dqdvi065 divideint -1 -64 -> 0
+
+-- similar with powers of ten
+dqdvi160 divideint 1 1 -> 1
+dqdvi161 divideint 1 10 -> 0
+dqdvi162 divideint 1 100 -> 0
+dqdvi163 divideint 1 1000 -> 0
+dqdvi164 divideint 1 10000 -> 0
+dqdvi165 divideint 1 100000 -> 0
+dqdvi166 divideint 1 1000000 -> 0
+dqdvi167 divideint 1 10000000 -> 0
+dqdvi168 divideint 1 100000000 -> 0
+dqdvi170 divideint 1 -1 -> -1
+dqdvi171 divideint 1 -10 -> -0
+dqdvi172 divideint 1 -100 -> -0
+dqdvi173 divideint 1 -1000 -> -0
+dqdvi174 divideint 1 -10000 -> -0
+dqdvi175 divideint 1 -100000 -> -0
+dqdvi176 divideint 1 -1000000 -> -0
+dqdvi177 divideint 1 -10000000 -> -0
+dqdvi178 divideint 1 -100000000 -> -0
+dqdvi180 divideint -1 1 -> -1
+dqdvi181 divideint -1 10 -> -0
+dqdvi182 divideint -1 100 -> -0
+dqdvi183 divideint -1 1000 -> -0
+dqdvi184 divideint -1 10000 -> -0
+dqdvi185 divideint -1 100000 -> -0
+dqdvi186 divideint -1 1000000 -> -0
+dqdvi187 divideint -1 10000000 -> -0
+dqdvi188 divideint -1 100000000 -> -0
+dqdvi190 divideint -1 -1 -> 1
+dqdvi191 divideint -1 -10 -> 0
+dqdvi192 divideint -1 -100 -> 0
+dqdvi193 divideint -1 -1000 -> 0
+dqdvi194 divideint -1 -10000 -> 0
+dqdvi195 divideint -1 -100000 -> 0
+dqdvi196 divideint -1 -1000000 -> 0
+dqdvi197 divideint -1 -10000000 -> 0
+dqdvi198 divideint -1 -100000000 -> 0
+
+-- some long operand (at p=9) cases
+dqdvi070 divideint 999999999 1 -> 999999999
+dqdvi071 divideint 999999999.4 1 -> 999999999
+dqdvi072 divideint 999999999.5 1 -> 999999999
+dqdvi073 divideint 999999999.9 1 -> 999999999
+dqdvi074 divideint 999999999.999 1 -> 999999999
+
+dqdvi090 divideint 0. 1 -> 0
+dqdvi091 divideint .0 1 -> 0
+dqdvi092 divideint 0.00 1 -> 0
+dqdvi093 divideint 0.00E+9 1 -> 0
+dqdvi094 divideint 0.0000E-50 1 -> 0
+
+dqdvi100 divideint 1 1 -> 1
+dqdvi101 divideint 1 2 -> 0
+dqdvi102 divideint 1 3 -> 0
+dqdvi103 divideint 1 4 -> 0
+dqdvi104 divideint 1 5 -> 0
+dqdvi105 divideint 1 6 -> 0
+dqdvi106 divideint 1 7 -> 0
+dqdvi107 divideint 1 8 -> 0
+dqdvi108 divideint 1 9 -> 0
+dqdvi109 divideint 1 10 -> 0
+dqdvi110 divideint 1 1 -> 1
+dqdvi111 divideint 2 1 -> 2
+dqdvi112 divideint 3 1 -> 3
+dqdvi113 divideint 4 1 -> 4
+dqdvi114 divideint 5 1 -> 5
+dqdvi115 divideint 6 1 -> 6
+dqdvi116 divideint 7 1 -> 7
+dqdvi117 divideint 8 1 -> 8
+dqdvi118 divideint 9 1 -> 9
+dqdvi119 divideint 10 1 -> 10
+
+-- from DiagBigDecimal
+dqdvi131 divideint 101.3 1 -> 101
+dqdvi132 divideint 101.0 1 -> 101
+dqdvi133 divideint 101.3 3 -> 33
+dqdvi134 divideint 101.0 3 -> 33
+dqdvi135 divideint 2.4 1 -> 2
+dqdvi136 divideint 2.400 1 -> 2
+dqdvi137 divideint 18 18 -> 1
+dqdvi138 divideint 1120 1000 -> 1
+dqdvi139 divideint 2.4 2 -> 1
+dqdvi140 divideint 2.400 2 -> 1
+dqdvi141 divideint 0.5 2.000 -> 0
+dqdvi142 divideint 8.005 7 -> 1
+dqdvi143 divideint 5 2 -> 2
+dqdvi144 divideint 0 2 -> 0
+dqdvi145 divideint 0.00 2 -> 0
+
+-- Others
+dqdvi150 divideint 12345 4.999 -> 2469
+dqdvi151 divideint 12345 4.99 -> 2473
+dqdvi152 divideint 12345 4.9 -> 2519
+dqdvi153 divideint 12345 5 -> 2469
+dqdvi154 divideint 12345 5.1 -> 2420
+dqdvi155 divideint 12345 5.01 -> 2464
+dqdvi156 divideint 12345 5.001 -> 2468
+dqdvi157 divideint 101 7.6 -> 13
+
+-- Various flavours of divideint by 0
+dqdvi201 divideint 0 0 -> NaN Division_undefined
+dqdvi202 divideint 0.0E5 0 -> NaN Division_undefined
+dqdvi203 divideint 0.000 0 -> NaN Division_undefined
+dqdvi204 divideint 0.0001 0 -> Infinity Division_by_zero
+dqdvi205 divideint 0.01 0 -> Infinity Division_by_zero
+dqdvi206 divideint 0.1 0 -> Infinity Division_by_zero
+dqdvi207 divideint 1 0 -> Infinity Division_by_zero
+dqdvi208 divideint 1 0.0 -> Infinity Division_by_zero
+dqdvi209 divideint 10 0.0 -> Infinity Division_by_zero
+dqdvi210 divideint 1E+100 0.0 -> Infinity Division_by_zero
+dqdvi211 divideint 1E+380 0 -> Infinity Division_by_zero
+dqdvi214 divideint -0.0001 0 -> -Infinity Division_by_zero
+dqdvi215 divideint -0.01 0 -> -Infinity Division_by_zero
+dqdvi216 divideint -0.1 0 -> -Infinity Division_by_zero
+dqdvi217 divideint -1 0 -> -Infinity Division_by_zero
+dqdvi218 divideint -1 0.0 -> -Infinity Division_by_zero
+dqdvi219 divideint -10 0.0 -> -Infinity Division_by_zero
+dqdvi220 divideint -1E+100 0.0 -> -Infinity Division_by_zero
+dqdvi221 divideint -1E+380 0 -> -Infinity Division_by_zero
+
+-- test some cases that are close to exponent overflow
+dqdvi270 divideint 1 1e384 -> 0
+dqdvi271 divideint 1 0.9e384 -> 0
+dqdvi272 divideint 1 0.99e384 -> 0
+dqdvi273 divideint 1 0.9999999999999999e384 -> 0
+dqdvi274 divideint 9e384 1 -> NaN Division_impossible
+dqdvi275 divideint 9.9e384 1 -> NaN Division_impossible
+dqdvi276 divideint 9.99e384 1 -> NaN Division_impossible
+dqdvi277 divideint 9.999999999999999e384 1 -> NaN Division_impossible
+
+dqdvi280 divideint 0.1 9e-383 -> NaN Division_impossible
+dqdvi281 divideint 0.1 99e-383 -> NaN Division_impossible
+dqdvi282 divideint 0.1 999e-383 -> NaN Division_impossible
+dqdvi283 divideint 0.1 9e-382 -> NaN Division_impossible
+dqdvi284 divideint 0.1 99e-382 -> NaN Division_impossible
+
+-- GD edge cases: lhs smaller than rhs but more digits
+dqdvi301 divideint 0.9 2 -> 0
+dqdvi302 divideint 0.9 2.0 -> 0
+dqdvi303 divideint 0.9 2.1 -> 0
+dqdvi304 divideint 0.9 2.00 -> 0
+dqdvi305 divideint 0.9 2.01 -> 0
+dqdvi306 divideint 0.12 1 -> 0
+dqdvi307 divideint 0.12 1.0 -> 0
+dqdvi308 divideint 0.12 1.00 -> 0
+dqdvi309 divideint 0.12 1.0 -> 0
+dqdvi310 divideint 0.12 1.00 -> 0
+dqdvi311 divideint 0.12 2 -> 0
+dqdvi312 divideint 0.12 2.0 -> 0
+dqdvi313 divideint 0.12 2.1 -> 0
+dqdvi314 divideint 0.12 2.00 -> 0
+dqdvi315 divideint 0.12 2.01 -> 0
+
+-- edge cases of impossible
+dqdvi330 divideint 1234567987654321987654321890123456 10 -> 123456798765432198765432189012345
+dqdvi331 divideint 1234567987654321987654321890123456 1 -> 1234567987654321987654321890123456
+dqdvi332 divideint 1234567987654321987654321890123456 0.1 -> NaN Division_impossible
+dqdvi333 divideint 1234567987654321987654321890123456 0.01 -> NaN Division_impossible
+
+-- overflow and underflow tests [from divide]
+dqdvi1051 divideint 1e+277 1e-311 -> NaN Division_impossible
+dqdvi1052 divideint 1e+277 -1e-311 -> NaN Division_impossible
+dqdvi1053 divideint -1e+277 1e-311 -> NaN Division_impossible
+dqdvi1054 divideint -1e+277 -1e-311 -> NaN Division_impossible
+dqdvi1055 divideint 1e-277 1e+311 -> 0
+dqdvi1056 divideint 1e-277 -1e+311 -> -0
+dqdvi1057 divideint -1e-277 1e+311 -> -0
+dqdvi1058 divideint -1e-277 -1e+311 -> 0
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqdvi1060 divideint 1e-291 1e+101 -> 0
+dqdvi1061 divideint 1e-291 1e+102 -> 0
+dqdvi1062 divideint 1e-291 1e+103 -> 0
+dqdvi1063 divideint 1e-291 1e+104 -> 0
+dqdvi1064 divideint 1e-291 1e+105 -> 0
+dqdvi1065 divideint 1e-291 1e+106 -> 0
+dqdvi1066 divideint 1e-291 1e+107 -> 0
+dqdvi1067 divideint 1e-291 1e+108 -> 0
+dqdvi1068 divideint 1e-291 1e+109 -> 0
+dqdvi1069 divideint 1e-291 1e+110 -> 0
+
+dqdvi1101 divideint 1.0000E-394 1 -> 0
+dqdvi1102 divideint 1.000E-394 1e+1 -> 0
+dqdvi1103 divideint 1.00E-394 1e+2 -> 0
+
+dqdvi1118 divideint 1E-394 1e+4 -> 0
+dqdvi1119 divideint 3E-394 -1e+5 -> -0
+dqdvi1120 divideint 5E-394 1e+5 -> 0
+
+dqdvi1124 divideint 1E-394 -1e+4 -> -0
+dqdvi1130 divideint 3.0E-394 -1e+5 -> -0
+
+dqdvi1131 divideint 1.0E-199 1e+200 -> 0
+dqdvi1132 divideint 1.0E-199 1e+199 -> 0
+dqdvi1133 divideint 1.0E-199 1e+198 -> 0
+dqdvi1134 divideint 2.0E-199 2e+198 -> 0
+dqdvi1135 divideint 4.0E-199 4e+198 -> 0
+
+-- long operand checks
+dqdvi401 divideint 12345678000 100 -> 123456780
+dqdvi402 divideint 1 12345678000 -> 0
+dqdvi403 divideint 1234567800 10 -> 123456780
+dqdvi404 divideint 1 1234567800 -> 0
+dqdvi405 divideint 1234567890 10 -> 123456789
+dqdvi406 divideint 1 1234567890 -> 0
+dqdvi407 divideint 1234567891 10 -> 123456789
+dqdvi408 divideint 1 1234567891 -> 0
+dqdvi409 divideint 12345678901 100 -> 123456789
+dqdvi410 divideint 1 12345678901 -> 0
+dqdvi411 divideint 1234567896 10 -> 123456789
+dqdvi412 divideint 1 1234567896 -> 0
+dqdvi413 divideint 12345678948 100 -> 123456789
+dqdvi414 divideint 12345678949 100 -> 123456789
+dqdvi415 divideint 12345678950 100 -> 123456789
+dqdvi416 divideint 12345678951 100 -> 123456789
+dqdvi417 divideint 12345678999 100 -> 123456789
+dqdvi441 divideint 12345678000 1 -> 12345678000
+dqdvi442 divideint 1 12345678000 -> 0
+dqdvi443 divideint 1234567800 1 -> 1234567800
+dqdvi444 divideint 1 1234567800 -> 0
+dqdvi445 divideint 1234567890 1 -> 1234567890
+dqdvi446 divideint 1 1234567890 -> 0
+dqdvi447 divideint 1234567891 1 -> 1234567891
+dqdvi448 divideint 1 1234567891 -> 0
+dqdvi449 divideint 12345678901 1 -> 12345678901
+dqdvi450 divideint 1 12345678901 -> 0
+dqdvi451 divideint 1234567896 1 -> 1234567896
+dqdvi452 divideint 1 1234567896 -> 0
+
+-- more zeros, etc.
+dqdvi531 divideint 5.00 1E-3 -> 5000
+dqdvi532 divideint 00.00 0.000 -> NaN Division_undefined
+dqdvi533 divideint 00.00 0E-3 -> NaN Division_undefined
+dqdvi534 divideint 0 -0 -> NaN Division_undefined
+dqdvi535 divideint -0 0 -> NaN Division_undefined
+dqdvi536 divideint -0 -0 -> NaN Division_undefined
+
+dqdvi541 divideint 0 -1 -> -0
+dqdvi542 divideint -0 -1 -> 0
+dqdvi543 divideint 0 1 -> 0
+dqdvi544 divideint -0 1 -> -0
+dqdvi545 divideint -1 0 -> -Infinity Division_by_zero
+dqdvi546 divideint -1 -0 -> Infinity Division_by_zero
+dqdvi547 divideint 1 0 -> Infinity Division_by_zero
+dqdvi548 divideint 1 -0 -> -Infinity Division_by_zero
+
+dqdvi551 divideint 0.0 -1 -> -0
+dqdvi552 divideint -0.0 -1 -> 0
+dqdvi553 divideint 0.0 1 -> 0
+dqdvi554 divideint -0.0 1 -> -0
+dqdvi555 divideint -1.0 0 -> -Infinity Division_by_zero
+dqdvi556 divideint -1.0 -0 -> Infinity Division_by_zero
+dqdvi557 divideint 1.0 0 -> Infinity Division_by_zero
+dqdvi558 divideint 1.0 -0 -> -Infinity Division_by_zero
+
+dqdvi561 divideint 0 -1.0 -> -0
+dqdvi562 divideint -0 -1.0 -> 0
+dqdvi563 divideint 0 1.0 -> 0
+dqdvi564 divideint -0 1.0 -> -0
+dqdvi565 divideint -1 0.0 -> -Infinity Division_by_zero
+dqdvi566 divideint -1 -0.0 -> Infinity Division_by_zero
+dqdvi567 divideint 1 0.0 -> Infinity Division_by_zero
+dqdvi568 divideint 1 -0.0 -> -Infinity Division_by_zero
+
+dqdvi571 divideint 0.0 -1.0 -> -0
+dqdvi572 divideint -0.0 -1.0 -> 0
+dqdvi573 divideint 0.0 1.0 -> 0
+dqdvi574 divideint -0.0 1.0 -> -0
+dqdvi575 divideint -1.0 0.0 -> -Infinity Division_by_zero
+dqdvi576 divideint -1.0 -0.0 -> Infinity Division_by_zero
+dqdvi577 divideint 1.0 0.0 -> Infinity Division_by_zero
+dqdvi578 divideint 1.0 -0.0 -> -Infinity Division_by_zero
+
+-- Specials
+dqdvi580 divideint Inf -Inf -> NaN Invalid_operation
+dqdvi581 divideint Inf -1000 -> -Infinity
+dqdvi582 divideint Inf -1 -> -Infinity
+dqdvi583 divideint Inf -0 -> -Infinity
+dqdvi584 divideint Inf 0 -> Infinity
+dqdvi585 divideint Inf 1 -> Infinity
+dqdvi586 divideint Inf 1000 -> Infinity
+dqdvi587 divideint Inf Inf -> NaN Invalid_operation
+dqdvi588 divideint -1000 Inf -> -0
+dqdvi589 divideint -Inf Inf -> NaN Invalid_operation
+dqdvi590 divideint -1 Inf -> -0
+dqdvi591 divideint -0 Inf -> -0
+dqdvi592 divideint 0 Inf -> 0
+dqdvi593 divideint 1 Inf -> 0
+dqdvi594 divideint 1000 Inf -> 0
+dqdvi595 divideint Inf Inf -> NaN Invalid_operation
+
+dqdvi600 divideint -Inf -Inf -> NaN Invalid_operation
+dqdvi601 divideint -Inf -1000 -> Infinity
+dqdvi602 divideint -Inf -1 -> Infinity
+dqdvi603 divideint -Inf -0 -> Infinity
+dqdvi604 divideint -Inf 0 -> -Infinity
+dqdvi605 divideint -Inf 1 -> -Infinity
+dqdvi606 divideint -Inf 1000 -> -Infinity
+dqdvi607 divideint -Inf Inf -> NaN Invalid_operation
+dqdvi608 divideint -1000 Inf -> -0
+dqdvi609 divideint -Inf -Inf -> NaN Invalid_operation
+dqdvi610 divideint -1 -Inf -> 0
+dqdvi611 divideint -0 -Inf -> 0
+dqdvi612 divideint 0 -Inf -> -0
+dqdvi613 divideint 1 -Inf -> -0
+dqdvi614 divideint 1000 -Inf -> -0
+dqdvi615 divideint Inf -Inf -> NaN Invalid_operation
+
+dqdvi621 divideint NaN -Inf -> NaN
+dqdvi622 divideint NaN -1000 -> NaN
+dqdvi623 divideint NaN -1 -> NaN
+dqdvi624 divideint NaN -0 -> NaN
+dqdvi625 divideint NaN 0 -> NaN
+dqdvi626 divideint NaN 1 -> NaN
+dqdvi627 divideint NaN 1000 -> NaN
+dqdvi628 divideint NaN Inf -> NaN
+dqdvi629 divideint NaN NaN -> NaN
+dqdvi630 divideint -Inf NaN -> NaN
+dqdvi631 divideint -1000 NaN -> NaN
+dqdvi632 divideint -1 NaN -> NaN
+dqdvi633 divideint -0 NaN -> NaN
+dqdvi634 divideint 0 NaN -> NaN
+dqdvi635 divideint 1 NaN -> NaN
+dqdvi636 divideint 1000 NaN -> NaN
+dqdvi637 divideint Inf NaN -> NaN
+
+dqdvi641 divideint sNaN -Inf -> NaN Invalid_operation
+dqdvi642 divideint sNaN -1000 -> NaN Invalid_operation
+dqdvi643 divideint sNaN -1 -> NaN Invalid_operation
+dqdvi644 divideint sNaN -0 -> NaN Invalid_operation
+dqdvi645 divideint sNaN 0 -> NaN Invalid_operation
+dqdvi646 divideint sNaN 1 -> NaN Invalid_operation
+dqdvi647 divideint sNaN 1000 -> NaN Invalid_operation
+dqdvi648 divideint sNaN NaN -> NaN Invalid_operation
+dqdvi649 divideint sNaN sNaN -> NaN Invalid_operation
+dqdvi650 divideint NaN sNaN -> NaN Invalid_operation
+dqdvi651 divideint -Inf sNaN -> NaN Invalid_operation
+dqdvi652 divideint -1000 sNaN -> NaN Invalid_operation
+dqdvi653 divideint -1 sNaN -> NaN Invalid_operation
+dqdvi654 divideint -0 sNaN -> NaN Invalid_operation
+dqdvi655 divideint 0 sNaN -> NaN Invalid_operation
+dqdvi656 divideint 1 sNaN -> NaN Invalid_operation
+dqdvi657 divideint 1000 sNaN -> NaN Invalid_operation
+dqdvi658 divideint Inf sNaN -> NaN Invalid_operation
+dqdvi659 divideint NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqdvi661 divideint NaN9 -Inf -> NaN9
+dqdvi662 divideint NaN8 1000 -> NaN8
+dqdvi663 divideint NaN7 Inf -> NaN7
+dqdvi664 divideint -NaN6 NaN5 -> -NaN6
+dqdvi665 divideint -Inf NaN4 -> NaN4
+dqdvi666 divideint -1000 NaN3 -> NaN3
+dqdvi667 divideint Inf -NaN2 -> -NaN2
+
+dqdvi671 divideint -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqdvi672 divideint sNaN98 -1 -> NaN98 Invalid_operation
+dqdvi673 divideint sNaN97 NaN -> NaN97 Invalid_operation
+dqdvi674 divideint sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqdvi675 divideint NaN95 sNaN93 -> NaN93 Invalid_operation
+dqdvi676 divideint -Inf sNaN92 -> NaN92 Invalid_operation
+dqdvi677 divideint 0 sNaN91 -> NaN91 Invalid_operation
+dqdvi678 divideint Inf -sNaN90 -> -NaN90 Invalid_operation
+dqdvi679 divideint NaN sNaN89 -> NaN89 Invalid_operation
+
+-- Gyuris example
+dqdvi700 divideint 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 0
+
+-- Null tests
+dqdvi900 divideint 10 # -> NaN Invalid_operation
+dqdvi901 divideint # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqEncode.decTest b/Lib/test/decimaltestdata/dqEncode.decTest
index 49edf5b2805..8c5d7b9b303 100644
--- a/Lib/test/decimaltestdata/dqEncode.decTest
+++ b/Lib/test/decimaltestdata/dqEncode.decTest
@@ -1,477 +1,477 @@
-------------------------------------------------------------------------
--- dqEncode.decTest -- decimal sixteen-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal128.decTest]
-version: 2.59
-
--- This set of tests is for the sixteen-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 12 bits exponent continuation
--- 110 bits coefficient continuation
---
--- Total exponent length 14 bits
--- Total coefficient length 114 bits (34 digits)
---
--- Elimit = 12287 (maximum encoded exponent)
--- Emax = 6144 (largest exponent value)
--- Emin = -6143 (smallest exponent value)
--- bias = 6176 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-decq001 apply #A20780000000000000000000000003D0 -> -7.50
-decq002 apply -7.50 -> #A20780000000000000000000000003D0
--- derivative canonical plain strings
-decq003 apply #A20840000000000000000000000003D0 -> -7.50E+3
-decq004 apply -7.50E+3 -> #A20840000000000000000000000003D0
-decq005 apply #A20800000000000000000000000003D0 -> -750
-decq006 apply -750 -> #A20800000000000000000000000003D0
-decq007 apply #A207c0000000000000000000000003D0 -> -75.0
-decq008 apply -75.0 -> #A207c0000000000000000000000003D0
-decq009 apply #A20740000000000000000000000003D0 -> -0.750
-decq010 apply -0.750 -> #A20740000000000000000000000003D0
-decq011 apply #A20700000000000000000000000003D0 -> -0.0750
-decq012 apply -0.0750 -> #A20700000000000000000000000003D0
-decq013 apply #A20680000000000000000000000003D0 -> -0.000750
-decq014 apply -0.000750 -> #A20680000000000000000000000003D0
-decq015 apply #A20600000000000000000000000003D0 -> -0.00000750
-decq016 apply -0.00000750 -> #A20600000000000000000000000003D0
-decq017 apply #A205c0000000000000000000000003D0 -> -7.50E-7
-decq018 apply -7.50E-7 -> #A205c0000000000000000000000003D0
-
--- Normality
-decq020 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534
-decq021 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534
-decq022 apply 1111111111111111111111111111111111 -> #26080912449124491244912449124491
-
--- Nmax and similar
-decq031 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
-decq032 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
-decq033 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
-decq034 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
--- fold-downs (more below)
-decq035 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped
-decq036 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144
-decq037 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
-decq038 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
-
-decq051 apply 12345 -> #220800000000000000000000000049c5
-decq052 apply #220800000000000000000000000049c5 -> 12345
-decq053 apply 1234 -> #22080000000000000000000000000534
-decq054 apply #22080000000000000000000000000534 -> 1234
-decq055 apply 123 -> #220800000000000000000000000000a3
-decq056 apply #220800000000000000000000000000a3 -> 123
-decq057 apply 12 -> #22080000000000000000000000000012
-decq058 apply #22080000000000000000000000000012 -> 12
-decq059 apply 1 -> #22080000000000000000000000000001
-decq060 apply #22080000000000000000000000000001 -> 1
-decq061 apply 1.23 -> #220780000000000000000000000000a3
-decq062 apply #220780000000000000000000000000a3 -> 1.23
-decq063 apply 123.45 -> #220780000000000000000000000049c5
-decq064 apply #220780000000000000000000000049c5 -> 123.45
-
--- Nmin and below
-decq071 apply 1E-6143 -> #00084000000000000000000000000001
-decq072 apply #00084000000000000000000000000001 -> 1E-6143
-decq073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000
-decq074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143
-decq075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001
-decq076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143
-
-decq077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal
-decq078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal
-decq079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal
-decq080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal
-decq081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal
-decq082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal
-decq083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal
-decq084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal
-
--- underflows cannot be tested for simple copies, check edge cases
-decq090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal
-decq100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal
-
--- same again, negatives
--- Nmax and similar
-decq122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
-decq123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
-decq124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
-decq125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
--- fold-downs (more below)
-decq130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped
-decq131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144
-decq132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped
-decq133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144
-
-decq151 apply -12345 -> #a20800000000000000000000000049c5
-decq152 apply #a20800000000000000000000000049c5 -> -12345
-decq153 apply -1234 -> #a2080000000000000000000000000534
-decq154 apply #a2080000000000000000000000000534 -> -1234
-decq155 apply -123 -> #a20800000000000000000000000000a3
-decq156 apply #a20800000000000000000000000000a3 -> -123
-decq157 apply -12 -> #a2080000000000000000000000000012
-decq158 apply #a2080000000000000000000000000012 -> -12
-decq159 apply -1 -> #a2080000000000000000000000000001
-decq160 apply #a2080000000000000000000000000001 -> -1
-decq161 apply -1.23 -> #a20780000000000000000000000000a3
-decq162 apply #a20780000000000000000000000000a3 -> -1.23
-decq163 apply -123.45 -> #a20780000000000000000000000049c5
-decq164 apply #a20780000000000000000000000049c5 -> -123.45
-
--- Nmin and below
-decq171 apply -1E-6143 -> #80084000000000000000000000000001
-decq172 apply #80084000000000000000000000000001 -> -1E-6143
-decq173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000
-decq174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143
-decq175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001
-decq176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143
-
-decq177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal
-decq178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal
-decq179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal
-decq180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal
-decq181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal
-decq182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal
-decq183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal
-decq184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal
-
--- underflow edge cases
-decq190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal
-decq200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal
-
--- zeros
-decq400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped
-decq401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped
-decq402 apply 0E-6176 -> #00000000000000000000000000000000
-decq403 apply #00000000000000000000000000000000 -> 0E-6176
-decq404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000
-decq405 apply #00000000000000000000000000000000 -> 0E-6176
-decq406 apply 0E-2 -> #22078000000000000000000000000000
-decq407 apply #22078000000000000000000000000000 -> 0.00
-decq408 apply 0 -> #22080000000000000000000000000000
-decq409 apply #22080000000000000000000000000000 -> 0
-decq410 apply 0E+3 -> #2208c000000000000000000000000000
-decq411 apply #2208c000000000000000000000000000 -> 0E+3
-decq412 apply 0E+6111 -> #43ffc000000000000000000000000000
-decq413 apply #43ffc000000000000000000000000000 -> 0E+6111
--- clamped zeros...
-decq414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped
-decq415 apply #43ffc000000000000000000000000000 -> 0E+6111
-decq416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped
-decq417 apply #43ffc000000000000000000000000000 -> 0E+6111
-decq418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped
-decq419 apply #43ffc000000000000000000000000000 -> 0E+6111
-
--- negative zeros
-decq420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped
-decq421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped
-decq422 apply -0E-6176 -> #80000000000000000000000000000000
-decq423 apply #80000000000000000000000000000000 -> -0E-6176
-decq424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000
-decq425 apply #80000000000000000000000000000000 -> -0E-6176
-decq426 apply -0E-2 -> #a2078000000000000000000000000000
-decq427 apply #a2078000000000000000000000000000 -> -0.00
-decq428 apply -0 -> #a2080000000000000000000000000000
-decq429 apply #a2080000000000000000000000000000 -> -0
-decq430 apply -0E+3 -> #a208c000000000000000000000000000
-decq431 apply #a208c000000000000000000000000000 -> -0E+3
-decq432 apply -0E+6111 -> #c3ffc000000000000000000000000000
-decq433 apply #c3ffc000000000000000000000000000 -> -0E+6111
--- clamped zeros...
-decq434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped
-decq435 apply #c3ffc000000000000000000000000000 -> -0E+6111
-decq436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped
-decq437 apply #c3ffc000000000000000000000000000 -> -0E+6111
-decq438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped
-decq439 apply #c3ffc000000000000000000000000000 -> -0E+6111
-
--- exponent lengths
-decq440 apply #22080000000000000000000000000007 -> 7
-decq441 apply 7 -> #22080000000000000000000000000007
-decq442 apply #220a4000000000000000000000000007 -> 7E+9
-decq443 apply 7E+9 -> #220a4000000000000000000000000007
-decq444 apply #2220c000000000000000000000000007 -> 7E+99
-decq445 apply 7E+99 -> #2220c000000000000000000000000007
-decq446 apply #2301c000000000000000000000000007 -> 7E+999
-decq447 apply 7E+999 -> #2301c000000000000000000000000007
-decq448 apply #43e3c000000000000000000000000007 -> 7E+5999
-decq449 apply 7E+5999 -> #43e3c000000000000000000000000007
-
--- Specials
-decq500 apply Infinity -> #78000000000000000000000000000000
-decq501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000
-decq502 apply #78000000000000000000000000000000 -> Infinity
-decq503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000
-decq504 apply #79000000000000000000000000000000 -> Infinity
-decq505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
-decq506 apply #7a000000000000000000000000000000 -> Infinity
-decq507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
-decq508 apply #7b000000000000000000000000000000 -> Infinity
-
-decq509 apply NaN -> #7c000000000000000000000000000000
-decq510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
-decq511 apply #7c000000000000000000000000000000 -> NaN
-decq512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
-decq513 apply #7d000000000000000000000000000000 -> NaN
-decq514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
-decq515 apply #7e000000000000000000000000000000 -> sNaN
-decq516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
-decq517 apply #7f000000000000000000000000000000 -> sNaN
-decq518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
-decq519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
-
-decq520 apply -Infinity -> #f8000000000000000000000000000000
-decq521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
-decq522 apply #f8000000000000000000000000000000 -> -Infinity
-decq523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
-decq524 apply #f9000000000000000000000000000000 -> -Infinity
-decq525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
-decq526 apply #fa000000000000000000000000000000 -> -Infinity
-decq527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
-decq528 apply #fb000000000000000000000000000000 -> -Infinity
-
-decq529 apply -NaN -> #fc000000000000000000000000000000
-decq530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
-decq531 apply #fc000000000000000000000000000000 -> -NaN
-decq532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
-decq533 apply #fd000000000000000000000000000000 -> -NaN
-decq534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
-decq535 apply #fe000000000000000000000000000000 -> -sNaN
-decq536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
-decq537 apply #ff000000000000000000000000000000 -> -sNaN
-decq538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
-decq539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff
-
-decq540 apply NaN -> #7c000000000000000000000000000000
-decq541 apply NaN0 -> #7c000000000000000000000000000000
-decq542 apply NaN1 -> #7c000000000000000000000000000001
-decq543 apply NaN12 -> #7c000000000000000000000000000012
-decq544 apply NaN79 -> #7c000000000000000000000000000079
-decq545 apply NaN12345 -> #7c0000000000000000000000000049c5
-decq546 apply NaN123456 -> #7c000000000000000000000000028e56
-decq547 apply NaN799799 -> #7c0000000000000000000000000f7fdf
-decq548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf
-decq549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
-decq550 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
-
--- fold-down full sequence
-decq601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
-decq602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
-decq603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped
-decq604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143
-decq605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped
-decq606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142
-decq607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped
-decq608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141
-decq609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped
-decq610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140
-decq611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped
-decq612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139
-decq613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped
-decq614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138
-decq615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped
-decq616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137
-decq617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped
-decq618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136
-decq619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped
-decq620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135
-decq621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped
-decq622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134
-decq623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped
-decq624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133
-decq625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped
-decq626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132
-decq627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped
-decq628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131
-decq629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped
-decq630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130
-decq631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped
-decq632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129
-decq633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped
-decq634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128
-decq635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped
-decq636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127
-decq637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped
-decq638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126
-decq639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped
-decq640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125
-decq641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped
-decq642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124
-decq643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped
-decq644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123
-decq645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped
-decq646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122
-decq647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped
-decq648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121
-decq649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped
-decq650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120
-decq651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped
-decq652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119
-decq653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped
-decq654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118
-decq655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped
-decq656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117
-decq657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped
-decq658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116
-decq659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped
-decq660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115
-decq661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped
-decq662 apply #43ffc000000000000000000000000400 -> 1.000E+6114
-decq663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped
-decq664 apply #43ffc000000000000000000000000080 -> 1.00E+6113
-decq665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped
-decq666 apply #43ffc000000000000000000000000010 -> 1.0E+6112
-decq667 apply 1E+6111 -> #43ffc000000000000000000000000001
-decq668 apply #43ffc000000000000000000000000001 -> 1E+6111
-decq669 apply 1E+6110 -> #43ff8000000000000000000000000001
-decq670 apply #43ff8000000000000000000000000001 -> 1E+6110
-
--- Selected DPD codes
-decq700 apply #22080000000000000000000000000000 -> 0
-decq701 apply #22080000000000000000000000000009 -> 9
-decq702 apply #22080000000000000000000000000010 -> 10
-decq703 apply #22080000000000000000000000000019 -> 19
-decq704 apply #22080000000000000000000000000020 -> 20
-decq705 apply #22080000000000000000000000000029 -> 29
-decq706 apply #22080000000000000000000000000030 -> 30
-decq707 apply #22080000000000000000000000000039 -> 39
-decq708 apply #22080000000000000000000000000040 -> 40
-decq709 apply #22080000000000000000000000000049 -> 49
-decq710 apply #22080000000000000000000000000050 -> 50
-decq711 apply #22080000000000000000000000000059 -> 59
-decq712 apply #22080000000000000000000000000060 -> 60
-decq713 apply #22080000000000000000000000000069 -> 69
-decq714 apply #22080000000000000000000000000070 -> 70
-decq715 apply #22080000000000000000000000000071 -> 71
-decq716 apply #22080000000000000000000000000072 -> 72
-decq717 apply #22080000000000000000000000000073 -> 73
-decq718 apply #22080000000000000000000000000074 -> 74
-decq719 apply #22080000000000000000000000000075 -> 75
-decq720 apply #22080000000000000000000000000076 -> 76
-decq721 apply #22080000000000000000000000000077 -> 77
-decq722 apply #22080000000000000000000000000078 -> 78
-decq723 apply #22080000000000000000000000000079 -> 79
-
-decq730 apply #2208000000000000000000000000029e -> 994
-decq731 apply #2208000000000000000000000000029f -> 995
-decq732 apply #220800000000000000000000000002a0 -> 520
-decq733 apply #220800000000000000000000000002a1 -> 521
-
--- DPD: one of each of the huffman groups
-decq740 apply #220800000000000000000000000003f7 -> 777
-decq741 apply #220800000000000000000000000003f8 -> 778
-decq742 apply #220800000000000000000000000003eb -> 787
-decq743 apply #2208000000000000000000000000037d -> 877
-decq744 apply #2208000000000000000000000000039f -> 997
-decq745 apply #220800000000000000000000000003bf -> 979
-decq746 apply #220800000000000000000000000003df -> 799
-decq747 apply #2208000000000000000000000000006e -> 888
-
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decq750 apply #2208000000000000000000000000006e -> 888
-decq751 apply #2208000000000000000000000000016e -> 888
-decq752 apply #2208000000000000000000000000026e -> 888
-decq753 apply #2208000000000000000000000000036e -> 888
-decq754 apply #2208000000000000000000000000006f -> 889
-decq755 apply #2208000000000000000000000000016f -> 889
-decq756 apply #2208000000000000000000000000026f -> 889
-decq757 apply #2208000000000000000000000000036f -> 889
-
-decq760 apply #2208000000000000000000000000007e -> 898
-decq761 apply #2208000000000000000000000000017e -> 898
-decq762 apply #2208000000000000000000000000027e -> 898
-decq763 apply #2208000000000000000000000000037e -> 898
-decq764 apply #2208000000000000000000000000007f -> 899
-decq765 apply #2208000000000000000000000000017f -> 899
-decq766 apply #2208000000000000000000000000027f -> 899
-decq767 apply #2208000000000000000000000000037f -> 899
-
-decq770 apply #220800000000000000000000000000ee -> 988
-decq771 apply #220800000000000000000000000001ee -> 988
-decq772 apply #220800000000000000000000000002ee -> 988
-decq773 apply #220800000000000000000000000003ee -> 988
-decq774 apply #220800000000000000000000000000ef -> 989
-decq775 apply #220800000000000000000000000001ef -> 989
-decq776 apply #220800000000000000000000000002ef -> 989
-decq777 apply #220800000000000000000000000003ef -> 989
-
-decq780 apply #220800000000000000000000000000fe -> 998
-decq781 apply #220800000000000000000000000001fe -> 998
-decq782 apply #220800000000000000000000000002fe -> 998
-decq783 apply #220800000000000000000000000003fe -> 998
-decq784 apply #220800000000000000000000000000ff -> 999
-decq785 apply #220800000000000000000000000001ff -> 999
-decq786 apply #220800000000000000000000000002ff -> 999
-decq787 apply #220800000000000000000000000003ff -> 999
-
--- Miscellaneous (testers' queries, etc.)
-
-decq790 apply #2208000000000000000000000000c000 -> 30000
-decq791 apply #22080000000000000000000000007800 -> 890000
-decq792 apply 30000 -> #2208000000000000000000000000c000
-decq793 apply 890000 -> #22080000000000000000000000007800
-
--- values around [u]int32 edges (zeros done earlier)
-decq800 apply -2147483646 -> #a208000000000000000000008c78af46
-decq801 apply -2147483647 -> #a208000000000000000000008c78af47
-decq802 apply -2147483648 -> #a208000000000000000000008c78af48
-decq803 apply -2147483649 -> #a208000000000000000000008c78af49
-decq804 apply 2147483646 -> #2208000000000000000000008c78af46
-decq805 apply 2147483647 -> #2208000000000000000000008c78af47
-decq806 apply 2147483648 -> #2208000000000000000000008c78af48
-decq807 apply 2147483649 -> #2208000000000000000000008c78af49
-decq808 apply 4294967294 -> #22080000000000000000000115afb55a
-decq809 apply 4294967295 -> #22080000000000000000000115afb55b
-decq810 apply 4294967296 -> #22080000000000000000000115afb57a
-decq811 apply 4294967297 -> #22080000000000000000000115afb57b
-
-decq820 apply #a208000000000000000000008c78af46 -> -2147483646
-decq821 apply #a208000000000000000000008c78af47 -> -2147483647
-decq822 apply #a208000000000000000000008c78af48 -> -2147483648
-decq823 apply #a208000000000000000000008c78af49 -> -2147483649
-decq824 apply #2208000000000000000000008c78af46 -> 2147483646
-decq825 apply #2208000000000000000000008c78af47 -> 2147483647
-decq826 apply #2208000000000000000000008c78af48 -> 2147483648
-decq827 apply #2208000000000000000000008c78af49 -> 2147483649
-decq828 apply #22080000000000000000000115afb55a -> 4294967294
-decq829 apply #22080000000000000000000115afb55b -> 4294967295
-decq830 apply #22080000000000000000000115afb57a -> 4294967296
-decq831 apply #22080000000000000000000115afb57b -> 4294967297
-
--- VG testcase
-decq840 apply #2080000000000000F294000000172636 -> 8.81125000000001349436E-1548
-decq841 apply #20800000000000008000000000000000 -> 8.000000000000000000E-1550
-decq842 apply #1EF98490000000010F6E4E0000000000 -> 7.049000000000010795488000000000000E-3097
-decq843 multiply #20800000000000008000000000000000 #2080000000000000F294000000172636 -> #1EF98490000000010F6E4E0000000000 Rounded
-
+------------------------------------------------------------------------
+-- dqEncode.decTest -- decimal sixteen-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal128.decTest]
+version: 2.59
+
+-- This set of tests is for the sixteen-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 12 bits exponent continuation
+-- 110 bits coefficient continuation
+--
+-- Total exponent length 14 bits
+-- Total coefficient length 114 bits (34 digits)
+--
+-- Elimit = 12287 (maximum encoded exponent)
+-- Emax = 6144 (largest exponent value)
+-- Emin = -6143 (smallest exponent value)
+-- bias = 6176 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+decq001 apply #A20780000000000000000000000003D0 -> -7.50
+decq002 apply -7.50 -> #A20780000000000000000000000003D0
+-- derivative canonical plain strings
+decq003 apply #A20840000000000000000000000003D0 -> -7.50E+3
+decq004 apply -7.50E+3 -> #A20840000000000000000000000003D0
+decq005 apply #A20800000000000000000000000003D0 -> -750
+decq006 apply -750 -> #A20800000000000000000000000003D0
+decq007 apply #A207c0000000000000000000000003D0 -> -75.0
+decq008 apply -75.0 -> #A207c0000000000000000000000003D0
+decq009 apply #A20740000000000000000000000003D0 -> -0.750
+decq010 apply -0.750 -> #A20740000000000000000000000003D0
+decq011 apply #A20700000000000000000000000003D0 -> -0.0750
+decq012 apply -0.0750 -> #A20700000000000000000000000003D0
+decq013 apply #A20680000000000000000000000003D0 -> -0.000750
+decq014 apply -0.000750 -> #A20680000000000000000000000003D0
+decq015 apply #A20600000000000000000000000003D0 -> -0.00000750
+decq016 apply -0.00000750 -> #A20600000000000000000000000003D0
+decq017 apply #A205c0000000000000000000000003D0 -> -7.50E-7
+decq018 apply -7.50E-7 -> #A205c0000000000000000000000003D0
+
+-- Normality
+decq020 apply 1234567890123456789012345678901234 -> #2608134b9c1e28e56f3c127177823534
+decq021 apply -1234567890123456789012345678901234 -> #a608134b9c1e28e56f3c127177823534
+decq022 apply 1111111111111111111111111111111111 -> #26080912449124491244912449124491
+
+-- Nmax and similar
+decq031 apply 9.999999999999999999999999999999999E+6144 -> #77ffcff3fcff3fcff3fcff3fcff3fcff
+decq032 apply #77ffcff3fcff3fcff3fcff3fcff3fcff -> 9.999999999999999999999999999999999E+6144
+decq033 apply 1.234567890123456789012345678901234E+6144 -> #47ffd34b9c1e28e56f3c127177823534
+decq034 apply #47ffd34b9c1e28e56f3c127177823534 -> 1.234567890123456789012345678901234E+6144
+-- fold-downs (more below)
+decq035 apply 1.23E+6144 -> #47ffd300000000000000000000000000 Clamped
+decq036 apply #47ffd300000000000000000000000000 -> 1.230000000000000000000000000000000E+6144
+decq037 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
+decq038 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
+
+decq051 apply 12345 -> #220800000000000000000000000049c5
+decq052 apply #220800000000000000000000000049c5 -> 12345
+decq053 apply 1234 -> #22080000000000000000000000000534
+decq054 apply #22080000000000000000000000000534 -> 1234
+decq055 apply 123 -> #220800000000000000000000000000a3
+decq056 apply #220800000000000000000000000000a3 -> 123
+decq057 apply 12 -> #22080000000000000000000000000012
+decq058 apply #22080000000000000000000000000012 -> 12
+decq059 apply 1 -> #22080000000000000000000000000001
+decq060 apply #22080000000000000000000000000001 -> 1
+decq061 apply 1.23 -> #220780000000000000000000000000a3
+decq062 apply #220780000000000000000000000000a3 -> 1.23
+decq063 apply 123.45 -> #220780000000000000000000000049c5
+decq064 apply #220780000000000000000000000049c5 -> 123.45
+
+-- Nmin and below
+decq071 apply 1E-6143 -> #00084000000000000000000000000001
+decq072 apply #00084000000000000000000000000001 -> 1E-6143
+decq073 apply 1.000000000000000000000000000000000E-6143 -> #04000000000000000000000000000000
+decq074 apply #04000000000000000000000000000000 -> 1.000000000000000000000000000000000E-6143
+decq075 apply 1.000000000000000000000000000000001E-6143 -> #04000000000000000000000000000001
+decq076 apply #04000000000000000000000000000001 -> 1.000000000000000000000000000000001E-6143
+
+decq077 apply 0.100000000000000000000000000000000E-6143 -> #00000800000000000000000000000000 Subnormal
+decq078 apply #00000800000000000000000000000000 -> 1.00000000000000000000000000000000E-6144 Subnormal
+decq079 apply 0.000000000000000000000000000000010E-6143 -> #00000000000000000000000000000010 Subnormal
+decq080 apply #00000000000000000000000000000010 -> 1.0E-6175 Subnormal
+decq081 apply 0.00000000000000000000000000000001E-6143 -> #00004000000000000000000000000001 Subnormal
+decq082 apply #00004000000000000000000000000001 -> 1E-6175 Subnormal
+decq083 apply 0.000000000000000000000000000000001E-6143 -> #00000000000000000000000000000001 Subnormal
+decq084 apply #00000000000000000000000000000001 -> 1E-6176 Subnormal
+
+-- underflows cannot be tested for simple copies, check edge cases
+decq090 apply 1e-6176 -> #00000000000000000000000000000001 Subnormal
+decq100 apply 999999999999999999999999999999999e-6176 -> #00000ff3fcff3fcff3fcff3fcff3fcff Subnormal
+
+-- same again, negatives
+-- Nmax and similar
+decq122 apply -9.999999999999999999999999999999999E+6144 -> #f7ffcff3fcff3fcff3fcff3fcff3fcff
+decq123 apply #f7ffcff3fcff3fcff3fcff3fcff3fcff -> -9.999999999999999999999999999999999E+6144
+decq124 apply -1.234567890123456789012345678901234E+6144 -> #c7ffd34b9c1e28e56f3c127177823534
+decq125 apply #c7ffd34b9c1e28e56f3c127177823534 -> -1.234567890123456789012345678901234E+6144
+-- fold-downs (more below)
+decq130 apply -1.23E+6144 -> #c7ffd300000000000000000000000000 Clamped
+decq131 apply #c7ffd300000000000000000000000000 -> -1.230000000000000000000000000000000E+6144
+decq132 apply -1E+6144 -> #c7ffc000000000000000000000000000 Clamped
+decq133 apply #c7ffc000000000000000000000000000 -> -1.000000000000000000000000000000000E+6144
+
+decq151 apply -12345 -> #a20800000000000000000000000049c5
+decq152 apply #a20800000000000000000000000049c5 -> -12345
+decq153 apply -1234 -> #a2080000000000000000000000000534
+decq154 apply #a2080000000000000000000000000534 -> -1234
+decq155 apply -123 -> #a20800000000000000000000000000a3
+decq156 apply #a20800000000000000000000000000a3 -> -123
+decq157 apply -12 -> #a2080000000000000000000000000012
+decq158 apply #a2080000000000000000000000000012 -> -12
+decq159 apply -1 -> #a2080000000000000000000000000001
+decq160 apply #a2080000000000000000000000000001 -> -1
+decq161 apply -1.23 -> #a20780000000000000000000000000a3
+decq162 apply #a20780000000000000000000000000a3 -> -1.23
+decq163 apply -123.45 -> #a20780000000000000000000000049c5
+decq164 apply #a20780000000000000000000000049c5 -> -123.45
+
+-- Nmin and below
+decq171 apply -1E-6143 -> #80084000000000000000000000000001
+decq172 apply #80084000000000000000000000000001 -> -1E-6143
+decq173 apply -1.000000000000000000000000000000000E-6143 -> #84000000000000000000000000000000
+decq174 apply #84000000000000000000000000000000 -> -1.000000000000000000000000000000000E-6143
+decq175 apply -1.000000000000000000000000000000001E-6143 -> #84000000000000000000000000000001
+decq176 apply #84000000000000000000000000000001 -> -1.000000000000000000000000000000001E-6143
+
+decq177 apply -0.100000000000000000000000000000000E-6143 -> #80000800000000000000000000000000 Subnormal
+decq178 apply #80000800000000000000000000000000 -> -1.00000000000000000000000000000000E-6144 Subnormal
+decq179 apply -0.000000000000000000000000000000010E-6143 -> #80000000000000000000000000000010 Subnormal
+decq180 apply #80000000000000000000000000000010 -> -1.0E-6175 Subnormal
+decq181 apply -0.00000000000000000000000000000001E-6143 -> #80004000000000000000000000000001 Subnormal
+decq182 apply #80004000000000000000000000000001 -> -1E-6175 Subnormal
+decq183 apply -0.000000000000000000000000000000001E-6143 -> #80000000000000000000000000000001 Subnormal
+decq184 apply #80000000000000000000000000000001 -> -1E-6176 Subnormal
+
+-- underflow edge cases
+decq190 apply -1e-6176 -> #80000000000000000000000000000001 Subnormal
+decq200 apply -999999999999999999999999999999999e-6176 -> #80000ff3fcff3fcff3fcff3fcff3fcff Subnormal
+
+-- zeros
+decq400 apply 0E-8000 -> #00000000000000000000000000000000 Clamped
+decq401 apply 0E-6177 -> #00000000000000000000000000000000 Clamped
+decq402 apply 0E-6176 -> #00000000000000000000000000000000
+decq403 apply #00000000000000000000000000000000 -> 0E-6176
+decq404 apply 0.000000000000000000000000000000000E-6143 -> #00000000000000000000000000000000
+decq405 apply #00000000000000000000000000000000 -> 0E-6176
+decq406 apply 0E-2 -> #22078000000000000000000000000000
+decq407 apply #22078000000000000000000000000000 -> 0.00
+decq408 apply 0 -> #22080000000000000000000000000000
+decq409 apply #22080000000000000000000000000000 -> 0
+decq410 apply 0E+3 -> #2208c000000000000000000000000000
+decq411 apply #2208c000000000000000000000000000 -> 0E+3
+decq412 apply 0E+6111 -> #43ffc000000000000000000000000000
+decq413 apply #43ffc000000000000000000000000000 -> 0E+6111
+-- clamped zeros...
+decq414 apply 0E+6112 -> #43ffc000000000000000000000000000 Clamped
+decq415 apply #43ffc000000000000000000000000000 -> 0E+6111
+decq416 apply 0E+6144 -> #43ffc000000000000000000000000000 Clamped
+decq417 apply #43ffc000000000000000000000000000 -> 0E+6111
+decq418 apply 0E+8000 -> #43ffc000000000000000000000000000 Clamped
+decq419 apply #43ffc000000000000000000000000000 -> 0E+6111
+
+-- negative zeros
+decq420 apply -0E-8000 -> #80000000000000000000000000000000 Clamped
+decq421 apply -0E-6177 -> #80000000000000000000000000000000 Clamped
+decq422 apply -0E-6176 -> #80000000000000000000000000000000
+decq423 apply #80000000000000000000000000000000 -> -0E-6176
+decq424 apply -0.000000000000000000000000000000000E-6143 -> #80000000000000000000000000000000
+decq425 apply #80000000000000000000000000000000 -> -0E-6176
+decq426 apply -0E-2 -> #a2078000000000000000000000000000
+decq427 apply #a2078000000000000000000000000000 -> -0.00
+decq428 apply -0 -> #a2080000000000000000000000000000
+decq429 apply #a2080000000000000000000000000000 -> -0
+decq430 apply -0E+3 -> #a208c000000000000000000000000000
+decq431 apply #a208c000000000000000000000000000 -> -0E+3
+decq432 apply -0E+6111 -> #c3ffc000000000000000000000000000
+decq433 apply #c3ffc000000000000000000000000000 -> -0E+6111
+-- clamped zeros...
+decq434 apply -0E+6112 -> #c3ffc000000000000000000000000000 Clamped
+decq435 apply #c3ffc000000000000000000000000000 -> -0E+6111
+decq436 apply -0E+6144 -> #c3ffc000000000000000000000000000 Clamped
+decq437 apply #c3ffc000000000000000000000000000 -> -0E+6111
+decq438 apply -0E+8000 -> #c3ffc000000000000000000000000000 Clamped
+decq439 apply #c3ffc000000000000000000000000000 -> -0E+6111
+
+-- exponent lengths
+decq440 apply #22080000000000000000000000000007 -> 7
+decq441 apply 7 -> #22080000000000000000000000000007
+decq442 apply #220a4000000000000000000000000007 -> 7E+9
+decq443 apply 7E+9 -> #220a4000000000000000000000000007
+decq444 apply #2220c000000000000000000000000007 -> 7E+99
+decq445 apply 7E+99 -> #2220c000000000000000000000000007
+decq446 apply #2301c000000000000000000000000007 -> 7E+999
+decq447 apply 7E+999 -> #2301c000000000000000000000000007
+decq448 apply #43e3c000000000000000000000000007 -> 7E+5999
+decq449 apply 7E+5999 -> #43e3c000000000000000000000000007
+
+-- Specials
+decq500 apply Infinity -> #78000000000000000000000000000000
+decq501 apply #78787878787878787878787878787878 -> #78000000000000000000000000000000
+decq502 apply #78000000000000000000000000000000 -> Infinity
+decq503 apply #79797979797979797979797979797979 -> #78000000000000000000000000000000
+decq504 apply #79000000000000000000000000000000 -> Infinity
+decq505 apply #7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #78000000000000000000000000000000
+decq506 apply #7a000000000000000000000000000000 -> Infinity
+decq507 apply #7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #78000000000000000000000000000000
+decq508 apply #7b000000000000000000000000000000 -> Infinity
+
+decq509 apply NaN -> #7c000000000000000000000000000000
+decq510 apply #7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #7c003c7c7c7c7c7c7c7c7c7c7c7c7c7c
+decq511 apply #7c000000000000000000000000000000 -> NaN
+decq512 apply #7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #7c003d7d7d7d7d7d7d7d7d7d7d7d7d7d
+decq513 apply #7d000000000000000000000000000000 -> NaN
+decq514 apply #7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #7e003e7e7c7e7e7e7e7c7e7e7e7e7c7e
+decq515 apply #7e000000000000000000000000000000 -> sNaN
+decq516 apply #7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #7e003f7f7c7f7f7f7f7c7f7f7f7f7c7f
+decq517 apply #7f000000000000000000000000000000 -> sNaN
+decq518 apply #7fffffffffffffffffffffffffffffff -> sNaN999999999999999999999999999999999
+decq519 apply #7fffffffffffffffffffffffffffffff -> #7e000ff3fcff3fcff3fcff3fcff3fcff
+
+decq520 apply -Infinity -> #f8000000000000000000000000000000
+decq521 apply #f8787878787878787878787878787878 -> #f8000000000000000000000000000000
+decq522 apply #f8000000000000000000000000000000 -> -Infinity
+decq523 apply #f9797979797979797979797979797979 -> #f8000000000000000000000000000000
+decq524 apply #f9000000000000000000000000000000 -> -Infinity
+decq525 apply #fa7a7a7a7a7a7a7a7a7a7a7a7a7a7a7a -> #f8000000000000000000000000000000
+decq526 apply #fa000000000000000000000000000000 -> -Infinity
+decq527 apply #fb7b7b7b7b7b7b7b7b7b7b7b7b7b7b7b -> #f8000000000000000000000000000000
+decq528 apply #fb000000000000000000000000000000 -> -Infinity
+
+decq529 apply -NaN -> #fc000000000000000000000000000000
+decq530 apply #fc7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c -> #fc003c7c7c7c7c7c7c7c7c7c7c7c7c7c
+decq531 apply #fc000000000000000000000000000000 -> -NaN
+decq532 apply #fd7d7d7d7d7d7d7d7d7d7d7d7d7d7d7d -> #fc003d7d7d7d7d7d7d7d7d7d7d7d7d7d
+decq533 apply #fd000000000000000000000000000000 -> -NaN
+decq534 apply #fe7e7e7e7e7e7e7e7e7e7e7e7e7e7e7e -> #fe003e7e7c7e7e7e7e7c7e7e7e7e7c7e
+decq535 apply #fe000000000000000000000000000000 -> -sNaN
+decq536 apply #ff7f7f7f7f7f7f7f7f7f7f7f7f7f7f7f -> #fe003f7f7c7f7f7f7f7c7f7f7f7f7c7f
+decq537 apply #ff000000000000000000000000000000 -> -sNaN
+decq538 apply #ffffffffffffffffffffffffffffffff -> -sNaN999999999999999999999999999999999
+decq539 apply #ffffffffffffffffffffffffffffffff -> #fe000ff3fcff3fcff3fcff3fcff3fcff
+
+decq540 apply NaN -> #7c000000000000000000000000000000
+decq541 apply NaN0 -> #7c000000000000000000000000000000
+decq542 apply NaN1 -> #7c000000000000000000000000000001
+decq543 apply NaN12 -> #7c000000000000000000000000000012
+decq544 apply NaN79 -> #7c000000000000000000000000000079
+decq545 apply NaN12345 -> #7c0000000000000000000000000049c5
+decq546 apply NaN123456 -> #7c000000000000000000000000028e56
+decq547 apply NaN799799 -> #7c0000000000000000000000000f7fdf
+decq548 apply NaN799799799799799799799799799799799 -> #7c003dff7fdff7fdff7fdff7fdff7fdf
+decq549 apply NaN999999999999999999999999999999999 -> #7c000ff3fcff3fcff3fcff3fcff3fcff
+decq550 apply 9999999999999999999999999999999999 -> #6e080ff3fcff3fcff3fcff3fcff3fcff
+
+-- fold-down full sequence
+decq601 apply 1E+6144 -> #47ffc000000000000000000000000000 Clamped
+decq602 apply #47ffc000000000000000000000000000 -> 1.000000000000000000000000000000000E+6144
+decq603 apply 1E+6143 -> #43ffc800000000000000000000000000 Clamped
+decq604 apply #43ffc800000000000000000000000000 -> 1.00000000000000000000000000000000E+6143
+decq605 apply 1E+6142 -> #43ffc100000000000000000000000000 Clamped
+decq606 apply #43ffc100000000000000000000000000 -> 1.0000000000000000000000000000000E+6142
+decq607 apply 1E+6141 -> #43ffc010000000000000000000000000 Clamped
+decq608 apply #43ffc010000000000000000000000000 -> 1.000000000000000000000000000000E+6141
+decq609 apply 1E+6140 -> #43ffc002000000000000000000000000 Clamped
+decq610 apply #43ffc002000000000000000000000000 -> 1.00000000000000000000000000000E+6140
+decq611 apply 1E+6139 -> #43ffc000400000000000000000000000 Clamped
+decq612 apply #43ffc000400000000000000000000000 -> 1.0000000000000000000000000000E+6139
+decq613 apply 1E+6138 -> #43ffc000040000000000000000000000 Clamped
+decq614 apply #43ffc000040000000000000000000000 -> 1.000000000000000000000000000E+6138
+decq615 apply 1E+6137 -> #43ffc000008000000000000000000000 Clamped
+decq616 apply #43ffc000008000000000000000000000 -> 1.00000000000000000000000000E+6137
+decq617 apply 1E+6136 -> #43ffc000001000000000000000000000 Clamped
+decq618 apply #43ffc000001000000000000000000000 -> 1.0000000000000000000000000E+6136
+decq619 apply 1E+6135 -> #43ffc000000100000000000000000000 Clamped
+decq620 apply #43ffc000000100000000000000000000 -> 1.000000000000000000000000E+6135
+decq621 apply 1E+6134 -> #43ffc000000020000000000000000000 Clamped
+decq622 apply #43ffc000000020000000000000000000 -> 1.00000000000000000000000E+6134
+decq623 apply 1E+6133 -> #43ffc000000004000000000000000000 Clamped
+decq624 apply #43ffc000000004000000000000000000 -> 1.0000000000000000000000E+6133
+decq625 apply 1E+6132 -> #43ffc000000000400000000000000000 Clamped
+decq626 apply #43ffc000000000400000000000000000 -> 1.000000000000000000000E+6132
+decq627 apply 1E+6131 -> #43ffc000000000080000000000000000 Clamped
+decq628 apply #43ffc000000000080000000000000000 -> 1.00000000000000000000E+6131
+decq629 apply 1E+6130 -> #43ffc000000000010000000000000000 Clamped
+decq630 apply #43ffc000000000010000000000000000 -> 1.0000000000000000000E+6130
+decq631 apply 1E+6129 -> #43ffc000000000001000000000000000 Clamped
+decq632 apply #43ffc000000000001000000000000000 -> 1.000000000000000000E+6129
+decq633 apply 1E+6128 -> #43ffc000000000000200000000000000 Clamped
+decq634 apply #43ffc000000000000200000000000000 -> 1.00000000000000000E+6128
+decq635 apply 1E+6127 -> #43ffc000000000000040000000000000 Clamped
+decq636 apply #43ffc000000000000040000000000000 -> 1.0000000000000000E+6127
+decq637 apply 1E+6126 -> #43ffc000000000000004000000000000 Clamped
+decq638 apply #43ffc000000000000004000000000000 -> 1.000000000000000E+6126
+decq639 apply 1E+6125 -> #43ffc000000000000000800000000000 Clamped
+decq640 apply #43ffc000000000000000800000000000 -> 1.00000000000000E+6125
+decq641 apply 1E+6124 -> #43ffc000000000000000100000000000 Clamped
+decq642 apply #43ffc000000000000000100000000000 -> 1.0000000000000E+6124
+decq643 apply 1E+6123 -> #43ffc000000000000000010000000000 Clamped
+decq644 apply #43ffc000000000000000010000000000 -> 1.000000000000E+6123
+decq645 apply 1E+6122 -> #43ffc000000000000000002000000000 Clamped
+decq646 apply #43ffc000000000000000002000000000 -> 1.00000000000E+6122
+decq647 apply 1E+6121 -> #43ffc000000000000000000400000000 Clamped
+decq648 apply #43ffc000000000000000000400000000 -> 1.0000000000E+6121
+decq649 apply 1E+6120 -> #43ffc000000000000000000040000000 Clamped
+decq650 apply #43ffc000000000000000000040000000 -> 1.000000000E+6120
+decq651 apply 1E+6119 -> #43ffc000000000000000000008000000 Clamped
+decq652 apply #43ffc000000000000000000008000000 -> 1.00000000E+6119
+decq653 apply 1E+6118 -> #43ffc000000000000000000001000000 Clamped
+decq654 apply #43ffc000000000000000000001000000 -> 1.0000000E+6118
+decq655 apply 1E+6117 -> #43ffc000000000000000000000100000 Clamped
+decq656 apply #43ffc000000000000000000000100000 -> 1.000000E+6117
+decq657 apply 1E+6116 -> #43ffc000000000000000000000020000 Clamped
+decq658 apply #43ffc000000000000000000000020000 -> 1.00000E+6116
+decq659 apply 1E+6115 -> #43ffc000000000000000000000004000 Clamped
+decq660 apply #43ffc000000000000000000000004000 -> 1.0000E+6115
+decq661 apply 1E+6114 -> #43ffc000000000000000000000000400 Clamped
+decq662 apply #43ffc000000000000000000000000400 -> 1.000E+6114
+decq663 apply 1E+6113 -> #43ffc000000000000000000000000080 Clamped
+decq664 apply #43ffc000000000000000000000000080 -> 1.00E+6113
+decq665 apply 1E+6112 -> #43ffc000000000000000000000000010 Clamped
+decq666 apply #43ffc000000000000000000000000010 -> 1.0E+6112
+decq667 apply 1E+6111 -> #43ffc000000000000000000000000001
+decq668 apply #43ffc000000000000000000000000001 -> 1E+6111
+decq669 apply 1E+6110 -> #43ff8000000000000000000000000001
+decq670 apply #43ff8000000000000000000000000001 -> 1E+6110
+
+-- Selected DPD codes
+decq700 apply #22080000000000000000000000000000 -> 0
+decq701 apply #22080000000000000000000000000009 -> 9
+decq702 apply #22080000000000000000000000000010 -> 10
+decq703 apply #22080000000000000000000000000019 -> 19
+decq704 apply #22080000000000000000000000000020 -> 20
+decq705 apply #22080000000000000000000000000029 -> 29
+decq706 apply #22080000000000000000000000000030 -> 30
+decq707 apply #22080000000000000000000000000039 -> 39
+decq708 apply #22080000000000000000000000000040 -> 40
+decq709 apply #22080000000000000000000000000049 -> 49
+decq710 apply #22080000000000000000000000000050 -> 50
+decq711 apply #22080000000000000000000000000059 -> 59
+decq712 apply #22080000000000000000000000000060 -> 60
+decq713 apply #22080000000000000000000000000069 -> 69
+decq714 apply #22080000000000000000000000000070 -> 70
+decq715 apply #22080000000000000000000000000071 -> 71
+decq716 apply #22080000000000000000000000000072 -> 72
+decq717 apply #22080000000000000000000000000073 -> 73
+decq718 apply #22080000000000000000000000000074 -> 74
+decq719 apply #22080000000000000000000000000075 -> 75
+decq720 apply #22080000000000000000000000000076 -> 76
+decq721 apply #22080000000000000000000000000077 -> 77
+decq722 apply #22080000000000000000000000000078 -> 78
+decq723 apply #22080000000000000000000000000079 -> 79
+
+decq730 apply #2208000000000000000000000000029e -> 994
+decq731 apply #2208000000000000000000000000029f -> 995
+decq732 apply #220800000000000000000000000002a0 -> 520
+decq733 apply #220800000000000000000000000002a1 -> 521
+
+-- DPD: one of each of the huffman groups
+decq740 apply #220800000000000000000000000003f7 -> 777
+decq741 apply #220800000000000000000000000003f8 -> 778
+decq742 apply #220800000000000000000000000003eb -> 787
+decq743 apply #2208000000000000000000000000037d -> 877
+decq744 apply #2208000000000000000000000000039f -> 997
+decq745 apply #220800000000000000000000000003bf -> 979
+decq746 apply #220800000000000000000000000003df -> 799
+decq747 apply #2208000000000000000000000000006e -> 888
+
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decq750 apply #2208000000000000000000000000006e -> 888
+decq751 apply #2208000000000000000000000000016e -> 888
+decq752 apply #2208000000000000000000000000026e -> 888
+decq753 apply #2208000000000000000000000000036e -> 888
+decq754 apply #2208000000000000000000000000006f -> 889
+decq755 apply #2208000000000000000000000000016f -> 889
+decq756 apply #2208000000000000000000000000026f -> 889
+decq757 apply #2208000000000000000000000000036f -> 889
+
+decq760 apply #2208000000000000000000000000007e -> 898
+decq761 apply #2208000000000000000000000000017e -> 898
+decq762 apply #2208000000000000000000000000027e -> 898
+decq763 apply #2208000000000000000000000000037e -> 898
+decq764 apply #2208000000000000000000000000007f -> 899
+decq765 apply #2208000000000000000000000000017f -> 899
+decq766 apply #2208000000000000000000000000027f -> 899
+decq767 apply #2208000000000000000000000000037f -> 899
+
+decq770 apply #220800000000000000000000000000ee -> 988
+decq771 apply #220800000000000000000000000001ee -> 988
+decq772 apply #220800000000000000000000000002ee -> 988
+decq773 apply #220800000000000000000000000003ee -> 988
+decq774 apply #220800000000000000000000000000ef -> 989
+decq775 apply #220800000000000000000000000001ef -> 989
+decq776 apply #220800000000000000000000000002ef -> 989
+decq777 apply #220800000000000000000000000003ef -> 989
+
+decq780 apply #220800000000000000000000000000fe -> 998
+decq781 apply #220800000000000000000000000001fe -> 998
+decq782 apply #220800000000000000000000000002fe -> 998
+decq783 apply #220800000000000000000000000003fe -> 998
+decq784 apply #220800000000000000000000000000ff -> 999
+decq785 apply #220800000000000000000000000001ff -> 999
+decq786 apply #220800000000000000000000000002ff -> 999
+decq787 apply #220800000000000000000000000003ff -> 999
+
+-- Miscellaneous (testers' queries, etc.)
+
+decq790 apply #2208000000000000000000000000c000 -> 30000
+decq791 apply #22080000000000000000000000007800 -> 890000
+decq792 apply 30000 -> #2208000000000000000000000000c000
+decq793 apply 890000 -> #22080000000000000000000000007800
+
+-- values around [u]int32 edges (zeros done earlier)
+decq800 apply -2147483646 -> #a208000000000000000000008c78af46
+decq801 apply -2147483647 -> #a208000000000000000000008c78af47
+decq802 apply -2147483648 -> #a208000000000000000000008c78af48
+decq803 apply -2147483649 -> #a208000000000000000000008c78af49
+decq804 apply 2147483646 -> #2208000000000000000000008c78af46
+decq805 apply 2147483647 -> #2208000000000000000000008c78af47
+decq806 apply 2147483648 -> #2208000000000000000000008c78af48
+decq807 apply 2147483649 -> #2208000000000000000000008c78af49
+decq808 apply 4294967294 -> #22080000000000000000000115afb55a
+decq809 apply 4294967295 -> #22080000000000000000000115afb55b
+decq810 apply 4294967296 -> #22080000000000000000000115afb57a
+decq811 apply 4294967297 -> #22080000000000000000000115afb57b
+
+decq820 apply #a208000000000000000000008c78af46 -> -2147483646
+decq821 apply #a208000000000000000000008c78af47 -> -2147483647
+decq822 apply #a208000000000000000000008c78af48 -> -2147483648
+decq823 apply #a208000000000000000000008c78af49 -> -2147483649
+decq824 apply #2208000000000000000000008c78af46 -> 2147483646
+decq825 apply #2208000000000000000000008c78af47 -> 2147483647
+decq826 apply #2208000000000000000000008c78af48 -> 2147483648
+decq827 apply #2208000000000000000000008c78af49 -> 2147483649
+decq828 apply #22080000000000000000000115afb55a -> 4294967294
+decq829 apply #22080000000000000000000115afb55b -> 4294967295
+decq830 apply #22080000000000000000000115afb57a -> 4294967296
+decq831 apply #22080000000000000000000115afb57b -> 4294967297
+
+-- VG testcase
+decq840 apply #2080000000000000F294000000172636 -> 8.81125000000001349436E-1548
+decq841 apply #20800000000000008000000000000000 -> 8.000000000000000000E-1550
+decq842 apply #1EF98490000000010F6E4E0000000000 -> 7.049000000000010795488000000000000E-3097
+decq843 multiply #20800000000000008000000000000000 #2080000000000000F294000000172636 -> #1EF98490000000010F6E4E0000000000 Rounded
+
diff --git a/Lib/test/decimaltestdata/dqFMA.decTest b/Lib/test/decimaltestdata/dqFMA.decTest
index d884553b8a9..2353f2fa2cb 100644
--- a/Lib/test/decimaltestdata/dqFMA.decTest
+++ b/Lib/test/decimaltestdata/dqFMA.decTest
@@ -1,1786 +1,1786 @@
-------------------------------------------------------------------------
--- dqFMA.decTest -- decQuad Fused Multiply Add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-dqfma0001 fma 1 1 1 -> 2
-dqfma0002 fma 1 1 2 -> 3
-dqfma0003 fma 2 2 3 -> 7
-dqfma0004 fma 9 9 9 -> 90
-dqfma0005 fma -1 1 1 -> 0
-dqfma0006 fma -1 1 2 -> 1
-dqfma0007 fma -2 2 3 -> -1
-dqfma0008 fma -9 9 9 -> -72
-dqfma0011 fma 1 -1 1 -> 0
-dqfma0012 fma 1 -1 2 -> 1
-dqfma0013 fma 2 -2 3 -> -1
-dqfma0014 fma 9 -9 9 -> -72
-dqfma0015 fma 1 1 -1 -> 0
-dqfma0016 fma 1 1 -2 -> -1
-dqfma0017 fma 2 2 -3 -> 1
-dqfma0018 fma 9 9 -9 -> 72
-
--- non-integer exacts
-dqfma0100 fma 25.2 63.6 -438 -> 1164.72
-dqfma0101 fma 0.301 0.380 334 -> 334.114380
-dqfma0102 fma 49.2 -4.8 23.3 -> -212.86
-dqfma0103 fma 4.22 0.079 -94.6 -> -94.26662
-dqfma0104 fma 903 0.797 0.887 -> 720.578
-dqfma0105 fma 6.13 -161 65.9 -> -921.03
-dqfma0106 fma 28.2 727 5.45 -> 20506.85
-dqfma0107 fma 4 605 688 -> 3108
-dqfma0108 fma 93.3 0.19 0.226 -> 17.953
-dqfma0109 fma 0.169 -341 5.61 -> -52.019
-dqfma0110 fma -72.2 30 -51.2 -> -2217.2
-dqfma0111 fma -0.409 13 20.4 -> 15.083
-dqfma0112 fma 317 77.0 19.0 -> 24428.0
-dqfma0113 fma 47 6.58 1.62 -> 310.88
-dqfma0114 fma 1.36 0.984 0.493 -> 1.83124
-dqfma0115 fma 72.7 274 1.56 -> 19921.36
-dqfma0116 fma 335 847 83 -> 283828
-dqfma0117 fma 666 0.247 25.4 -> 189.902
-dqfma0118 fma -3.87 3.06 78.0 -> 66.1578
-dqfma0119 fma 0.742 192 35.6 -> 178.064
-dqfma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- -> 4.500119002100000209469729375698778E+38
-dqfma0202 fma 68537985861355864457.5694 6565875762972086605.85969 35892634447236753.172812 -> 4.500119002100000209469729375698779E+38 Inexact Rounded
--- -> 5.996248469584594346858881620185514E+41
-dqfma0208 fma 89261822344727628571.9 6717595845654131383336.89 5061036497288796076266.11 -> 5.996248469584594346858881620185513E+41 Inexact Rounded
--- -> 1.899242968678256924021594770874070E+34
-dqfma0210 fma 320506237232448685.495971 59257597764017967.984448 3205615239077711589912.85 -> 1.899242968678256924021594770874071E+34 Inexact Rounded
--- -> 7.078596978842809537929699954860309E+37
-dqfma0215 fma 220247843259112263.17995 321392340287987979002.80 47533279819997167655440 -> 7.078596978842809537929699954860308E+37 Inexact Rounded
--- -> 1.224955667581427559754106862350743E+37
-dqfma0226 fma 23880729790368880412.1449 512947333827064719.55407 217117438419590824502.963 -> 1.224955667581427559754106862350744E+37 Inexact Rounded
--- -> -2.530094043253148806272276368579144E+42
-dqfma0229 fma 2539892357016099706.4126 -996142232667504817717435 53682082598315949425.937 -> -2.530094043253148806272276368579143E+42 Inexact Rounded
--- -> 1.713387085759711954319391412788454E+37
-dqfma0233 fma 4546339491341624464.0804 3768717864169205581 83578980278690395184.620 -> 1.713387085759711954319391412788453E+37 Inexact Rounded
--- -> 4.062275663405823716411579117771547E+35
-dqfma0235 fma 409242119433816131.42253 992633815166741501.477249 70179636544416756129546 -> 4.062275663405823716411579117771548E+35 Inexact Rounded
--- -> 6.002604327732568490562249875306823E+47
-dqfma0258 fma 817941336593541742159684 733867339769310729266598 78563844650942419311830.8 -> 6.002604327732568490562249875306822E+47 Inexact Rounded
--- -> -2.027022514381452197510103395283874E+39
-dqfma0264 fma 387617310169161270.737532 -5229442703414956061216.62 57665666816652967150473.5 -> -2.027022514381452197510103395283873E+39 Inexact Rounded
--- -> -7.856525039803554001144089842730361E+37
-dqfma0267 fma -847655845720565274701.210 92685316564117739.83984 22780950041376424429.5686 -> -7.856525039803554001144089842730360E+37 Inexact Rounded
--- -> 1.695515562011520746125607502237559E+38
-dqfma0268 fma 21590290365127685.3675 7853139227576541379426.8 -3275859437236180.761544 -> 1.695515562011520746125607502237558E+38 Inexact Rounded
--- -> -8.448422935783289219748115038014710E+38
-dqfma0269 fma -974320636272862697.971586 867109103641860247440.756 -9775170775902454762.98 -> -8.448422935783289219748115038014709E+38 Inexact Rounded
-
--- Cases where multiply would overflow or underflow if separate
-dqfma0300 fma 9e+6144 10 0 -> Infinity Overflow Inexact Rounded
-dqfma0301 fma 1e+6144 10 0 -> Infinity Overflow Inexact Rounded
-dqfma0302 fma 1e+6144 10 -1e+6144 -> 9.000000000000000000000000000000000E+6144 Clamped
-dqfma0303 fma 1e+6144 10 -9e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
--- subnormal etc.
-dqfma0305 fma 1e-6176 0.1 0 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma0306 fma 1e-6176 0.1 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqfma0307 fma 1e-6176 0.1 1e-6176 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
--- Infinite combinations
-dqfma0800 fma Inf Inf Inf -> Infinity
-dqfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
-dqfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
-dqfma0803 fma Inf -Inf -Inf -> -Infinity
-dqfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
-dqfma0805 fma -Inf Inf -Inf -> -Infinity
-dqfma0806 fma -Inf -Inf Inf -> Infinity
-dqfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-
--- Triple NaN propagation
-dqfma0900 fma NaN2 NaN3 NaN5 -> NaN2
-dqfma0901 fma 0 NaN3 NaN5 -> NaN3
-dqfma0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-dqfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-dqfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-dqfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-dqfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-dqfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-dqfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
-rounding: half_even
-
--- sanity checks
-dqfma2000 fma 2 2 0e+6144 -> 4
-dqfma2001 fma 2 3 0e+6144 -> 6
-dqfma2002 fma 5 1 0e+6144 -> 5
-dqfma2003 fma 5 2 0e+6144 -> 10
-dqfma2004 fma 1.20 2 0e+6144 -> 2.40
-dqfma2005 fma 1.20 0 0e+6144 -> 0.00
-dqfma2006 fma 1.20 -2 0e+6144 -> -2.40
-dqfma2007 fma -1.20 2 0e+6144 -> -2.40
-dqfma2008 fma -1.20 0 0e+6144 -> 0.00
-dqfma2009 fma -1.20 -2 0e+6144 -> 2.40
-dqfma2010 fma 5.09 7.1 0e+6144 -> 36.139
-dqfma2011 fma 2.5 4 0e+6144 -> 10.0
-dqfma2012 fma 2.50 4 0e+6144 -> 10.00
-dqfma2013 fma 1.23456789 1.0000000000000000000000000000 0e+6144 -> 1.234567890000000000000000000000000 Rounded
-dqfma2015 fma 2.50 4 0e+6144 -> 10.00
-dqfma2016 fma 9.99999999999999999 9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
-dqfma2017 fma 9.99999999999999999 -9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqfma2018 fma -9.99999999999999999 9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqfma2019 fma -9.99999999999999999 -9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
-
--- zeros, etc.
-dqfma2021 fma 0 0 0e+6144 -> 0
-dqfma2022 fma 0 -0 0e+6144 -> 0
-dqfma2023 fma -0 0 0e+6144 -> 0
-dqfma2024 fma -0 -0 0e+6144 -> 0
-dqfma2025 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2026 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2027 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2028 fma -0.0 -0.0 0e+6144 -> 0.00
-dqfma2030 fma 5.00 1E-3 0e+6144 -> 0.00500
-dqfma2031 fma 00.00 0.000 0e+6144 -> 0.00000
-dqfma2032 fma 00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2033 fma 0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2034 fma -5.00 1E-3 0e+6144 -> -0.00500
-dqfma2035 fma -00.00 0.000 0e+6144 -> 0.00000
-dqfma2036 fma -00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2037 fma -0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2038 fma 5.00 -1E-3 0e+6144 -> -0.00500
-dqfma2039 fma 00.00 -0.000 0e+6144 -> 0.00000
-dqfma2040 fma 00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2041 fma 0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
-dqfma2042 fma -5.00 -1E-3 0e+6144 -> 0.00500
-dqfma2043 fma -00.00 -0.000 0e+6144 -> 0.00000
-dqfma2044 fma -00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
-dqfma2045 fma -0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-dqfma2050 fma 1.20 3 0e+6144 -> 3.60
-dqfma2051 fma 7 3 0e+6144 -> 21
-dqfma2052 fma 0.9 0.8 0e+6144 -> 0.72
-dqfma2053 fma 0.9 -0 0e+6144 -> 0.0
-dqfma2054 fma 654321 654321 0e+6144 -> 428135971041
-
-dqfma2060 fma 123.45 1e7 0e+6144 -> 1.2345E+9
-dqfma2061 fma 123.45 1e8 0e+6144 -> 1.2345E+10
-dqfma2062 fma 123.45 1e+9 0e+6144 -> 1.2345E+11
-dqfma2063 fma 123.45 1e10 0e+6144 -> 1.2345E+12
-dqfma2064 fma 123.45 1e11 0e+6144 -> 1.2345E+13
-dqfma2065 fma 123.45 1e12 0e+6144 -> 1.2345E+14
-dqfma2066 fma 123.45 1e13 0e+6144 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-dqfma2080 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
-dqfma2084 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
-dqfma2090 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
-dqfma2094 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
-
--- test some more edge cases and carries
-dqfma2101 fma 9 9 0e+6144 -> 81
-dqfma2102 fma 9 90 0e+6144 -> 810
-dqfma2103 fma 9 900 0e+6144 -> 8100
-dqfma2104 fma 9 9000 0e+6144 -> 81000
-dqfma2105 fma 9 90000 0e+6144 -> 810000
-dqfma2106 fma 9 900000 0e+6144 -> 8100000
-dqfma2107 fma 9 9000000 0e+6144 -> 81000000
-dqfma2108 fma 9 90000000 0e+6144 -> 810000000
-dqfma2109 fma 9 900000000 0e+6144 -> 8100000000
-dqfma2110 fma 9 9000000000 0e+6144 -> 81000000000
-dqfma2111 fma 9 90000000000 0e+6144 -> 810000000000
-dqfma2112 fma 9 900000000000 0e+6144 -> 8100000000000
-dqfma2113 fma 9 9000000000000 0e+6144 -> 81000000000000
-dqfma2114 fma 9 90000000000000 0e+6144 -> 810000000000000
-dqfma2115 fma 9 900000000000000 0e+6144 -> 8100000000000000
---dqfma2116 fma 9 9000000000000000 0e+6144 -> 81000000000000000
---dqfma2117 fma 9 90000000000000000 0e+6144 -> 810000000000000000
---dqfma2118 fma 9 900000000000000000 0e+6144 -> 8100000000000000000
---dqfma2119 fma 9 9000000000000000000 0e+6144 -> 81000000000000000000
---dqfma2120 fma 9 90000000000000000000 0e+6144 -> 810000000000000000000
---dqfma2121 fma 9 900000000000000000000 0e+6144 -> 8100000000000000000000
---dqfma2122 fma 9 9000000000000000000000 0e+6144 -> 81000000000000000000000
---dqfma2123 fma 9 90000000000000000000000 0e+6144 -> 810000000000000000000000
--- test some more edge cases without carries
-dqfma2131 fma 3 3 0e+6144 -> 9
-dqfma2132 fma 3 30 0e+6144 -> 90
-dqfma2133 fma 3 300 0e+6144 -> 900
-dqfma2134 fma 3 3000 0e+6144 -> 9000
-dqfma2135 fma 3 30000 0e+6144 -> 90000
-dqfma2136 fma 3 300000 0e+6144 -> 900000
-dqfma2137 fma 3 3000000 0e+6144 -> 9000000
-dqfma2138 fma 3 30000000 0e+6144 -> 90000000
-dqfma2139 fma 3 300000000 0e+6144 -> 900000000
-dqfma2140 fma 3 3000000000 0e+6144 -> 9000000000
-dqfma2141 fma 3 30000000000 0e+6144 -> 90000000000
-dqfma2142 fma 3 300000000000 0e+6144 -> 900000000000
-dqfma2143 fma 3 3000000000000 0e+6144 -> 9000000000000
-dqfma2144 fma 3 30000000000000 0e+6144 -> 90000000000000
-dqfma2145 fma 3 300000000000000 0e+6144 -> 900000000000000
-dqfma2146 fma 3 3000000000000000 0e+6144 -> 9000000000000000
-dqfma2147 fma 3 30000000000000000 0e+6144 -> 90000000000000000
-dqfma2148 fma 3 300000000000000000 0e+6144 -> 900000000000000000
-dqfma2149 fma 3 3000000000000000000 0e+6144 -> 9000000000000000000
-dqfma2150 fma 3 30000000000000000000 0e+6144 -> 90000000000000000000
-dqfma2151 fma 3 300000000000000000000 0e+6144 -> 900000000000000000000
-dqfma2152 fma 3 3000000000000000000000 0e+6144 -> 9000000000000000000000
-dqfma2153 fma 3 30000000000000000000000 0e+6144 -> 90000000000000000000000
-
-dqfma2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0e+6144 -> 145433.2908011933696719165119928296 Inexact Rounded
-
--- test some edge cases with exact rounding
-dqfma2301 fma 900000000000000000 9 0e+6144 -> 8100000000000000000
-dqfma2302 fma 900000000000000000 90 0e+6144 -> 81000000000000000000
-dqfma2303 fma 900000000000000000 900 0e+6144 -> 810000000000000000000
-dqfma2304 fma 900000000000000000 9000 0e+6144 -> 8100000000000000000000
-dqfma2305 fma 900000000000000000 90000 0e+6144 -> 81000000000000000000000
-dqfma2306 fma 900000000000000000 900000 0e+6144 -> 810000000000000000000000
-dqfma2307 fma 900000000000000000 9000000 0e+6144 -> 8100000000000000000000000
-dqfma2308 fma 900000000000000000 90000000 0e+6144 -> 81000000000000000000000000
-dqfma2309 fma 900000000000000000 900000000 0e+6144 -> 810000000000000000000000000
-dqfma2310 fma 900000000000000000 9000000000 0e+6144 -> 8100000000000000000000000000
-dqfma2311 fma 900000000000000000 90000000000 0e+6144 -> 81000000000000000000000000000
-dqfma2312 fma 900000000000000000 900000000000 0e+6144 -> 810000000000000000000000000000
-dqfma2313 fma 900000000000000000 9000000000000 0e+6144 -> 8100000000000000000000000000000
-dqfma2314 fma 900000000000000000 90000000000000 0e+6144 -> 81000000000000000000000000000000
-dqfma2315 fma 900000000000000000 900000000000000 0e+6144 -> 810000000000000000000000000000000
-dqfma2316 fma 900000000000000000 9000000000000000 0e+6144 -> 8100000000000000000000000000000000
-dqfma2317 fma 9000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+34 Rounded
-dqfma2318 fma 90000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+35 Rounded
-dqfma2319 fma 900000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+36 Rounded
-dqfma2320 fma 9000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+37 Rounded
-dqfma2321 fma 90000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+38 Rounded
-dqfma2322 fma 900000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+39 Rounded
-dqfma2323 fma 9000000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+40 Rounded
-
--- tryzeros cases
-dqfma2504 fma 0E-4260 1000E-4260 0e+6144 -> 0E-6176 Clamped
-dqfma2505 fma 100E+4260 0E+4260 0e+6144 -> 0E+6111 Clamped
-
--- mixed with zeros
-dqfma2541 fma 0 -1 0e+6144 -> 0
-dqfma2542 fma -0 -1 0e+6144 -> 0
-dqfma2543 fma 0 1 0e+6144 -> 0
-dqfma2544 fma -0 1 0e+6144 -> 0
-dqfma2545 fma -1 0 0e+6144 -> 0
-dqfma2546 fma -1 -0 0e+6144 -> 0
-dqfma2547 fma 1 0 0e+6144 -> 0
-dqfma2548 fma 1 -0 0e+6144 -> 0
-
-dqfma2551 fma 0.0 -1 0e+6144 -> 0.0
-dqfma2552 fma -0.0 -1 0e+6144 -> 0.0
-dqfma2553 fma 0.0 1 0e+6144 -> 0.0
-dqfma2554 fma -0.0 1 0e+6144 -> 0.0
-dqfma2555 fma -1.0 0 0e+6144 -> 0.0
-dqfma2556 fma -1.0 -0 0e+6144 -> 0.0
-dqfma2557 fma 1.0 0 0e+6144 -> 0.0
-dqfma2558 fma 1.0 -0 0e+6144 -> 0.0
-
-dqfma2561 fma 0 -1.0 0e+6144 -> 0.0
-dqfma2562 fma -0 -1.0 0e+6144 -> 0.0
-dqfma2563 fma 0 1.0 0e+6144 -> 0.0
-dqfma2564 fma -0 1.0 0e+6144 -> 0.0
-dqfma2565 fma -1 0.0 0e+6144 -> 0.0
-dqfma2566 fma -1 -0.0 0e+6144 -> 0.0
-dqfma2567 fma 1 0.0 0e+6144 -> 0.0
-dqfma2568 fma 1 -0.0 0e+6144 -> 0.0
-
-dqfma2571 fma 0.0 -1.0 0e+6144 -> 0.00
-dqfma2572 fma -0.0 -1.0 0e+6144 -> 0.00
-dqfma2573 fma 0.0 1.0 0e+6144 -> 0.00
-dqfma2574 fma -0.0 1.0 0e+6144 -> 0.00
-dqfma2575 fma -1.0 0.0 0e+6144 -> 0.00
-dqfma2576 fma -1.0 -0.0 0e+6144 -> 0.00
-dqfma2577 fma 1.0 0.0 0e+6144 -> 0.00
-dqfma2578 fma 1.0 -0.0 0e+6144 -> 0.00
-dqfma2579 fma 1.0 0.0 0e+6144 -> 0.00
-dqfma2530 fma -1.0 -0.0 0e+6144 -> 0.00
-dqfma2531 fma -1.0 0.0 0e+6144 -> 0.00
-dqfma2532 fma 1.0 -0.0 -0e+6144 -> -0.00
-dqfma2533 fma 1.0 0.0 -0e+6144 -> 0.00
-dqfma2534 fma -1.0 -0.0 -0e+6144 -> 0.00
-dqfma2535 fma -1.0 0.0 -0e+6144 -> -0.00
-
-
--- Specials
-dqfma2580 fma Inf -Inf 0e+6144 -> -Infinity
-dqfma2581 fma Inf -1000 0e+6144 -> -Infinity
-dqfma2582 fma Inf -1 0e+6144 -> -Infinity
-dqfma2583 fma Inf -0 0e+6144 -> NaN Invalid_operation
-dqfma2584 fma Inf 0 0e+6144 -> NaN Invalid_operation
-dqfma2585 fma Inf 1 0e+6144 -> Infinity
-dqfma2586 fma Inf 1000 0e+6144 -> Infinity
-dqfma2587 fma Inf Inf 0e+6144 -> Infinity
-dqfma2588 fma -1000 Inf 0e+6144 -> -Infinity
-dqfma2589 fma -Inf Inf 0e+6144 -> -Infinity
-dqfma2590 fma -1 Inf 0e+6144 -> -Infinity
-dqfma2591 fma -0 Inf 0e+6144 -> NaN Invalid_operation
-dqfma2592 fma 0 Inf 0e+6144 -> NaN Invalid_operation
-dqfma2593 fma 1 Inf 0e+6144 -> Infinity
-dqfma2594 fma 1000 Inf 0e+6144 -> Infinity
-dqfma2595 fma Inf Inf 0e+6144 -> Infinity
-
-dqfma2600 fma -Inf -Inf 0e+6144 -> Infinity
-dqfma2601 fma -Inf -1000 0e+6144 -> Infinity
-dqfma2602 fma -Inf -1 0e+6144 -> Infinity
-dqfma2603 fma -Inf -0 0e+6144 -> NaN Invalid_operation
-dqfma2604 fma -Inf 0 0e+6144 -> NaN Invalid_operation
-dqfma2605 fma -Inf 1 0e+6144 -> -Infinity
-dqfma2606 fma -Inf 1000 0e+6144 -> -Infinity
-dqfma2607 fma -Inf Inf 0e+6144 -> -Infinity
-dqfma2608 fma -1000 Inf 0e+6144 -> -Infinity
-dqfma2609 fma -Inf -Inf 0e+6144 -> Infinity
-dqfma2610 fma -1 -Inf 0e+6144 -> Infinity
-dqfma2611 fma -0 -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2612 fma 0 -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2613 fma 1 -Inf 0e+6144 -> -Infinity
-dqfma2614 fma 1000 -Inf 0e+6144 -> -Infinity
-dqfma2615 fma Inf -Inf 0e+6144 -> -Infinity
-
-dqfma2621 fma NaN -Inf 0e+6144 -> NaN
-dqfma2622 fma NaN -1000 0e+6144 -> NaN
-dqfma2623 fma NaN -1 0e+6144 -> NaN
-dqfma2624 fma NaN -0 0e+6144 -> NaN
-dqfma2625 fma NaN 0 0e+6144 -> NaN
-dqfma2626 fma NaN 1 0e+6144 -> NaN
-dqfma2627 fma NaN 1000 0e+6144 -> NaN
-dqfma2628 fma NaN Inf 0e+6144 -> NaN
-dqfma2629 fma NaN NaN 0e+6144 -> NaN
-dqfma2630 fma -Inf NaN 0e+6144 -> NaN
-dqfma2631 fma -1000 NaN 0e+6144 -> NaN
-dqfma2632 fma -1 NaN 0e+6144 -> NaN
-dqfma2633 fma -0 NaN 0e+6144 -> NaN
-dqfma2634 fma 0 NaN 0e+6144 -> NaN
-dqfma2635 fma 1 NaN 0e+6144 -> NaN
-dqfma2636 fma 1000 NaN 0e+6144 -> NaN
-dqfma2637 fma Inf NaN 0e+6144 -> NaN
-
-dqfma2641 fma sNaN -Inf 0e+6144 -> NaN Invalid_operation
-dqfma2642 fma sNaN -1000 0e+6144 -> NaN Invalid_operation
-dqfma2643 fma sNaN -1 0e+6144 -> NaN Invalid_operation
-dqfma2644 fma sNaN -0 0e+6144 -> NaN Invalid_operation
-dqfma2645 fma sNaN 0 0e+6144 -> NaN Invalid_operation
-dqfma2646 fma sNaN 1 0e+6144 -> NaN Invalid_operation
-dqfma2647 fma sNaN 1000 0e+6144 -> NaN Invalid_operation
-dqfma2648 fma sNaN NaN 0e+6144 -> NaN Invalid_operation
-dqfma2649 fma sNaN sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2650 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2651 fma -Inf sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2652 fma -1000 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2653 fma -1 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2654 fma -0 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2655 fma 0 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2656 fma 1 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2657 fma 1000 sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2658 fma Inf sNaN 0e+6144 -> NaN Invalid_operation
-dqfma2659 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
-
--- propagating NaNs
-dqfma2661 fma NaN9 -Inf 0e+6144 -> NaN9
-dqfma2662 fma NaN8 999 0e+6144 -> NaN8
-dqfma2663 fma NaN71 Inf 0e+6144 -> NaN71
-dqfma2664 fma NaN6 NaN5 0e+6144 -> NaN6
-dqfma2665 fma -Inf NaN4 0e+6144 -> NaN4
-dqfma2666 fma -999 NaN33 0e+6144 -> NaN33
-dqfma2667 fma Inf NaN2 0e+6144 -> NaN2
-
-dqfma2671 fma sNaN99 -Inf 0e+6144 -> NaN99 Invalid_operation
-dqfma2672 fma sNaN98 -11 0e+6144 -> NaN98 Invalid_operation
-dqfma2673 fma sNaN97 NaN 0e+6144 -> NaN97 Invalid_operation
-dqfma2674 fma sNaN16 sNaN94 0e+6144 -> NaN16 Invalid_operation
-dqfma2675 fma NaN95 sNaN93 0e+6144 -> NaN93 Invalid_operation
-dqfma2676 fma -Inf sNaN92 0e+6144 -> NaN92 Invalid_operation
-dqfma2677 fma 088 sNaN91 0e+6144 -> NaN91 Invalid_operation
-dqfma2678 fma Inf sNaN90 0e+6144 -> NaN90 Invalid_operation
-dqfma2679 fma NaN sNaN89 0e+6144 -> NaN89 Invalid_operation
-
-dqfma2681 fma -NaN9 -Inf 0e+6144 -> -NaN9
-dqfma2682 fma -NaN8 999 0e+6144 -> -NaN8
-dqfma2683 fma -NaN71 Inf 0e+6144 -> -NaN71
-dqfma2684 fma -NaN6 -NaN5 0e+6144 -> -NaN6
-dqfma2685 fma -Inf -NaN4 0e+6144 -> -NaN4
-dqfma2686 fma -999 -NaN33 0e+6144 -> -NaN33
-dqfma2687 fma Inf -NaN2 0e+6144 -> -NaN2
-
-dqfma2691 fma -sNaN99 -Inf 0e+6144 -> -NaN99 Invalid_operation
-dqfma2692 fma -sNaN98 -11 0e+6144 -> -NaN98 Invalid_operation
-dqfma2693 fma -sNaN97 NaN 0e+6144 -> -NaN97 Invalid_operation
-dqfma2694 fma -sNaN16 -sNaN94 0e+6144 -> -NaN16 Invalid_operation
-dqfma2695 fma -NaN95 -sNaN93 0e+6144 -> -NaN93 Invalid_operation
-dqfma2696 fma -Inf -sNaN92 0e+6144 -> -NaN92 Invalid_operation
-dqfma2697 fma 088 -sNaN91 0e+6144 -> -NaN91 Invalid_operation
-dqfma2698 fma Inf -sNaN90 0e+6144 -> -NaN90 Invalid_operation
-dqfma2699 fma -NaN -sNaN89 0e+6144 -> -NaN89 Invalid_operation
-
-dqfma2701 fma -NaN -Inf 0e+6144 -> -NaN
-dqfma2702 fma -NaN 999 0e+6144 -> -NaN
-dqfma2703 fma -NaN Inf 0e+6144 -> -NaN
-dqfma2704 fma -NaN -NaN 0e+6144 -> -NaN
-dqfma2705 fma -Inf -NaN0 0e+6144 -> -NaN
-dqfma2706 fma -999 -NaN 0e+6144 -> -NaN
-dqfma2707 fma Inf -NaN 0e+6144 -> -NaN
-
-dqfma2711 fma -sNaN -Inf 0e+6144 -> -NaN Invalid_operation
-dqfma2712 fma -sNaN -11 0e+6144 -> -NaN Invalid_operation
-dqfma2713 fma -sNaN00 NaN 0e+6144 -> -NaN Invalid_operation
-dqfma2714 fma -sNaN -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2715 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2716 fma -Inf -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2717 fma 088 -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2718 fma Inf -sNaN 0e+6144 -> -NaN Invalid_operation
-dqfma2719 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqfma2751 fma 1e+4277 1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2752 fma 1e+4277 -1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
-dqfma2753 fma -1e+4277 1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
-dqfma2754 fma -1e+4277 -1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2755 fma 1e-4277 1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2756 fma 1e-4277 -1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2757 fma -1e-4277 1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2758 fma -1e-4277 -1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqfma2760 fma 1e-6069 1e-101 0e+6144 -> 1E-6170 Subnormal
-dqfma2761 fma 1e-6069 1e-102 0e+6144 -> 1E-6171 Subnormal
-dqfma2762 fma 1e-6069 1e-103 0e+6144 -> 1E-6172 Subnormal
-dqfma2763 fma 1e-6069 1e-104 0e+6144 -> 1E-6173 Subnormal
-dqfma2764 fma 1e-6069 1e-105 0e+6144 -> 1E-6174 Subnormal
-dqfma2765 fma 1e-6069 1e-106 0e+6144 -> 1E-6175 Subnormal
-dqfma2766 fma 1e-6069 1e-107 0e+6144 -> 1E-6176 Subnormal
-dqfma2767 fma 1e-6069 1e-108 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2768 fma 1e-6069 1e-109 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2769 fma 1e-6069 1e-110 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqfma2770 fma 1e+40 1e+6101 0e+6144 -> 1.000000000000000000000000000000E+6141 Clamped
-dqfma2771 fma 1e+40 1e+6102 0e+6144 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqfma2772 fma 1e+40 1e+6103 0e+6144 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqfma2773 fma 1e+40 1e+6104 0e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqfma2774 fma 1e+40 1e+6105 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2775 fma 1e+40 1e+6106 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2776 fma 1e+40 1e+6107 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2777 fma 1e+40 1e+6108 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2778 fma 1e+40 1e+6109 0e+6144 -> Infinity Overflow Inexact Rounded
-dqfma2779 fma 1e+40 1e+6110 0e+6144 -> Infinity Overflow Inexact Rounded
-
-dqfma2801 fma 1.0000E-6172 1 0e+6144 -> 1.0000E-6172 Subnormal
-dqfma2802 fma 1.000E-6172 1e-1 0e+6144 -> 1.000E-6173 Subnormal
-dqfma2803 fma 1.00E-6172 1e-2 0e+6144 -> 1.00E-6174 Subnormal
-dqfma2804 fma 1.0E-6172 1e-3 0e+6144 -> 1.0E-6175 Subnormal
-dqfma2805 fma 1.0E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal Rounded
-dqfma2806 fma 1.3E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2807 fma 1.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2808 fma 1.7E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2809 fma 2.3E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2810 fma 2.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2811 fma 2.7E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqfma2812 fma 1.49E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2813 fma 1.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2814 fma 1.51E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2815 fma 2.49E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2816 fma 2.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqfma2817 fma 2.51E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqfma2818 fma 1E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal
-dqfma2819 fma 3E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2820 fma 5E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2821 fma 7E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2822 fma 9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2823 fma 9.9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqfma2824 fma 1E-6172 -1e-4 0e+6144 -> -1E-6176 Subnormal
-dqfma2825 fma 3E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2826 fma -5E-6172 1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2827 fma 7E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2828 fma -9E-6172 1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2829 fma 9.9E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqfma2830 fma 3.0E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqfma2831 fma 1.0E-5977 1e-200 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqfma2832 fma 1.0E-5977 1e-199 0e+6144 -> 1E-6176 Subnormal Rounded
-dqfma2833 fma 1.0E-5977 1e-198 0e+6144 -> 1.0E-6175 Subnormal
-dqfma2834 fma 2.0E-5977 2e-198 0e+6144 -> 4.0E-6175 Subnormal
-dqfma2835 fma 4.0E-5977 4e-198 0e+6144 -> 1.60E-6174 Subnormal
-dqfma2836 fma 10.0E-5977 10e-198 0e+6144 -> 1.000E-6173 Subnormal
-dqfma2837 fma 30.0E-5977 30e-198 0e+6144 -> 9.000E-6173 Subnormal
-dqfma2838 fma 40.0E-5982 40e-166 0e+6144 -> 1.6000E-6145 Subnormal
-dqfma2839 fma 40.0E-5982 40e-165 0e+6144 -> 1.6000E-6144 Subnormal
-dqfma2840 fma 40.0E-5982 40e-164 0e+6144 -> 1.6000E-6143
-
--- Long operand overflow may be a different path
-dqfma2870 fma 100 9.999E+6143 0e+6144 -> Infinity Inexact Overflow Rounded
-dqfma2871 fma 100 -9.999E+6143 0e+6144 -> -Infinity Inexact Overflow Rounded
-dqfma2872 fma 9.999E+6143 100 0e+6144 -> Infinity Inexact Overflow Rounded
-dqfma2873 fma -9.999E+6143 100 0e+6144 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-dqfma2881 fma 1.2347E-6133 1.2347E-40 0e+6144 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
-dqfma2882 fma 1.234E-6133 1.234E-40 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2883 fma 1.23E-6133 1.23E-40 0e+6144 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
-dqfma2884 fma 1.2E-6133 1.2E-40 0e+6144 -> 1.44E-6173 Subnormal
-dqfma2885 fma 1.2E-6133 1.2E-41 0e+6144 -> 1.44E-6174 Subnormal
-dqfma2886 fma 1.2E-6133 1.2E-42 0e+6144 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
-dqfma2887 fma 1.2E-6133 1.3E-42 0e+6144 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
-dqfma2888 fma 1.3E-6133 1.3E-42 0e+6144 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
-dqfma2889 fma 1.3E-6133 1.3E-43 0e+6144 -> 2E-6176 Subnormal Inexact Rounded Underflow
-dqfma2890 fma 1.3E-6134 1.3E-43 0e+6144 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
-
-dqfma2891 fma 1.2345E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqfma2892 fma 1.23456E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqfma2893 fma 1.2345E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2894 fma 1.23456E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqfma2895 fma 1.2345E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-dqfma2896 fma 1.23456E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- prove operands are exact
-dqfma2906 fma 9.999999999999999999999999999999999E-6143 1 0e+6144 -> 9.999999999999999999999999999999999E-6143
-dqfma2907 fma 1 0.09999999999999999999999999999999999 0e+6144 -> 0.09999999999999999999999999999999999
--- the next rounds to Nmin
-dqfma2908 fma 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 0e+6144 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
-
--- hugest
-dqfma2909 fma 9999999999999999999999999999999999 9999999999999999999999999999999999 0e+6144 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-dqfma21001 fma 130E-2 120E-2 0e+6144 -> 1.5600
-dqfma21002 fma 130E-2 12E-1 0e+6144 -> 1.560
-dqfma21003 fma 130E-2 1E0 0e+6144 -> 1.30
-dqfma21004 fma 1E2 1E4 0e+6144 -> 1E+6
-
--- Null tests
-dqfma2990 fma 10 # 0e+6144 -> NaN Invalid_operation
-dqfma2991 fma # 10 0e+6144 -> NaN Invalid_operation
-
-
--- ADDITION TESTS ------------------------------------------------------
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqadd3001 fma 1 1 1 -> 2
-dqadd3002 fma 1 2 3 -> 5
-dqadd3003 fma 1 '5.75' '3.3' -> 9.05
-dqadd3004 fma 1 '5' '-3' -> 2
-dqadd3005 fma 1 '-5' '-3' -> -8
-dqadd3006 fma 1 '-7' '2.5' -> -4.5
-dqadd3007 fma 1 '0.7' '0.3' -> 1.0
-dqadd3008 fma 1 '1.25' '1.25' -> 2.50
-dqadd3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-dqadd3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
--- 1234567890123456 1234567890123456
-dqadd3011 fma 1 '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqadd3012 fma 1 '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
-dqadd3013 fma 1 '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqadd3014 fma 1 '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3015 fma 1 '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3016 fma 1 '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3017 fma 1 '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
-dqadd3018 fma 1 '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd3019 fma 1 '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
-dqadd3020 fma 1 '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
-
-dqadd3021 fma 1 0 1 -> 1
-dqadd3022 fma 1 1 1 -> 2
-dqadd3023 fma 1 2 1 -> 3
-dqadd3024 fma 1 3 1 -> 4
-dqadd3025 fma 1 4 1 -> 5
-dqadd3026 fma 1 5 1 -> 6
-dqadd3027 fma 1 6 1 -> 7
-dqadd3028 fma 1 7 1 -> 8
-dqadd3029 fma 1 8 1 -> 9
-dqadd3030 fma 1 9 1 -> 10
-
--- some carrying effects
-dqadd3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-dqadd3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-dqadd3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-dqadd3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-dqadd3035 fma 1 '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3036 fma 1 '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3037 fma 1 '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3038 fma 1 '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd3039 fma 1 '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- symmetry:
-dqadd3040 fma 1 '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3041 fma 1 '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3042 fma 1 '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqadd3044 fma 1 '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
-dqadd3045 fma 1 '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
-
--- same, without rounding
-dqadd3046 fma 1 '10000e+9' '7' -> '10000000000007'
-dqadd3047 fma 1 '10000e+9' '70' -> '10000000000070'
-dqadd3048 fma 1 '10000e+9' '700' -> '10000000000700'
-dqadd3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-dqadd3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-dqadd3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-dqadd3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-dqadd3053 fma 1 '12' '7.00' -> '19.00'
-dqadd3054 fma 1 '1.3' '-1.07' -> '0.23'
-dqadd3055 fma 1 '1.3' '-1.30' -> '0.00'
-dqadd3056 fma 1 '1.3' '-2.07' -> '-0.77'
-dqadd3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- leading zero preservation
-dqadd3061 fma 1 1 '0.0001' -> '1.0001'
-dqadd3062 fma 1 1 '0.00001' -> '1.00001'
-dqadd3063 fma 1 1 '0.000001' -> '1.000001'
-dqadd3064 fma 1 1 '0.0000001' -> '1.0000001'
-dqadd3065 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-dqadd3070 fma 1 1 0 -> 1
-dqadd3071 fma 1 1 0. -> 1
-dqadd3072 fma 1 1 .0 -> 1.0
-dqadd3073 fma 1 1 0.0 -> 1.0
-dqadd3074 fma 1 1 0.00 -> 1.00
-dqadd3075 fma 1 0 1 -> 1
-dqadd3076 fma 1 0. 1 -> 1
-dqadd3077 fma 1 .0 1 -> 1.0
-dqadd3078 fma 1 0.0 1 -> 1.0
-dqadd3079 fma 1 0.00 1 -> 1.00
-
--- some carries
-dqadd3080 fma 1 999999998 1 -> 999999999
-dqadd3081 fma 1 999999999 1 -> 1000000000
-dqadd3082 fma 1 99999999 1 -> 100000000
-dqadd3083 fma 1 9999999 1 -> 10000000
-dqadd3084 fma 1 999999 1 -> 1000000
-dqadd3085 fma 1 99999 1 -> 100000
-dqadd3086 fma 1 9999 1 -> 10000
-dqadd3087 fma 1 999 1 -> 1000
-dqadd3088 fma 1 99 1 -> 100
-dqadd3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-dqadd3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-dqadd3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-dqadd3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-dqadd3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-dqadd3094 fma 1 '-56267E-3' 0 -> '-56.267'
-dqadd3095 fma 1 '-56267E-2' 0 -> '-562.67'
-dqadd3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-dqadd3097 fma 1 '-56267E-0' 0 -> '-56267'
-dqadd3098 fma 1 '-5E-10' 0 -> '-5E-10'
-dqadd3099 fma 1 '-5E-7' 0 -> '-5E-7'
-dqadd3100 fma 1 '-5E-6' 0 -> '-0.000005'
-dqadd3101 fma 1 '-5E-5' 0 -> '-0.00005'
-dqadd3102 fma 1 '-5E-4' 0 -> '-0.0005'
-dqadd3103 fma 1 '-5E-1' 0 -> '-0.5'
-dqadd3104 fma 1 '-5E0' 0 -> '-5'
-dqadd3105 fma 1 '-5E1' 0 -> '-50'
-dqadd3106 fma 1 '-5E5' 0 -> '-500000'
-dqadd3107 fma 1 '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqadd3108 fma 1 '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd3109 fma 1 '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd3110 fma 1 '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd3111 fma 1 '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps
-dqadd3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-dqadd3114 fma 1 0 '-56267E-6' -> '-0.056267'
-dqadd3116 fma 1 0 '-56267E-5' -> '-0.56267'
-dqadd3117 fma 1 0 '-56267E-4' -> '-5.6267'
-dqadd3119 fma 1 0 '-56267E-3' -> '-56.267'
-dqadd3120 fma 1 0 '-56267E-2' -> '-562.67'
-dqadd3121 fma 1 0 '-56267E-1' -> '-5626.7'
-dqadd3122 fma 1 0 '-56267E-0' -> '-56267'
-dqadd3123 fma 1 0 '-5E-10' -> '-5E-10'
-dqadd3124 fma 1 0 '-5E-7' -> '-5E-7'
-dqadd3125 fma 1 0 '-5E-6' -> '-0.000005'
-dqadd3126 fma 1 0 '-5E-5' -> '-0.00005'
-dqadd3127 fma 1 0 '-5E-4' -> '-0.0005'
-dqadd3128 fma 1 0 '-5E-1' -> '-0.5'
-dqadd3129 fma 1 0 '-5E0' -> '-5'
-dqadd3130 fma 1 0 '-5E1' -> '-50'
-dqadd3131 fma 1 0 '-5E5' -> '-500000'
-dqadd3132 fma 1 0 '-5E33' -> '-5000000000000000000000000000000000'
-dqadd3133 fma 1 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
-dqadd3134 fma 1 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
-dqadd3135 fma 1 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
-dqadd3136 fma 1 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- related
-dqadd3137 fma 1 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
-dqadd3138 fma 1 -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
-dqadd3139 fma 1 '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
-dqadd3140 fma 1 '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
-dqadd3141 fma 1 1E+29 0.0000 -> '100000000000000000000000000000.0000'
-dqadd3142 fma 1 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
-dqadd3143 fma 1 0.000 1E+30 -> '1000000000000000000000000000000.000'
-dqadd3144 fma 1 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-dqadd3146 fma 1 '00.0' 0 -> '0.0'
-dqadd3147 fma 1 '0.00' 0 -> '0.00'
-dqadd3148 fma 1 0 '0.00' -> '0.00'
-dqadd3149 fma 1 0 '00.0' -> '0.0'
-dqadd3150 fma 1 '00.0' '0.00' -> '0.00'
-dqadd3151 fma 1 '0.00' '00.0' -> '0.00'
-dqadd3152 fma 1 '3' '.3' -> '3.3'
-dqadd3153 fma 1 '3.' '.3' -> '3.3'
-dqadd3154 fma 1 '3.0' '.3' -> '3.3'
-dqadd3155 fma 1 '3.00' '.3' -> '3.30'
-dqadd3156 fma 1 '3' '3' -> '6'
-dqadd3157 fma 1 '3' '+3' -> '6'
-dqadd3158 fma 1 '3' '-3' -> '0'
-dqadd3159 fma 1 '0.3' '-0.3' -> '0.0'
-dqadd3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-dqadd3161 fma 1 '1E+12' '-1' -> '999999999999'
-dqadd3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-dqadd3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-dqadd3164 fma 1 '-1' '1E+12' -> '999999999999'
-dqadd3165 fma 1 '7E+12' '-1' -> '6999999999999'
-dqadd3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-dqadd3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-dqadd3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
-rounding: half_up
-dqadd3170 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3171 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3172 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
-dqadd3173 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
-dqadd3174 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3175 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3176 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3177 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
-dqadd3178 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
-dqadd3179 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3180 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3181 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3182 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
-dqadd3183 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqadd3200 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3201 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3202 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3203 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3204 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3205 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3206 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3207 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3208 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3209 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3210 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3211 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3212 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3213 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3214 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3215 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3216 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3217 fma 1 '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3218 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3219 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
-rounding: half_even
-dqadd3220 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3221 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3222 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3223 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3224 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3225 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3226 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3227 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3228 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3229 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3230 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3231 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3232 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3233 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3234 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3235 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3236 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3237 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3238 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3239 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
--- critical few with even bottom digit...
-dqadd3240 fma 1 '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd3241 fma 1 '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
-dqadd3242 fma 1 '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-
-rounding: down
-dqadd3250 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
-dqadd3251 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3252 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3253 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3254 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3255 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3256 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3257 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3258 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3259 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3260 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3261 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3262 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3263 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3264 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3265 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
-dqadd3266 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
-dqadd3267 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3268 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
-dqadd3269 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-dqadd3301 fma 1 -1 1 -> 0
-dqadd3302 fma 1 0 1 -> 1
-dqadd3303 fma 1 1 1 -> 2
-dqadd3304 fma 1 12 1 -> 13
-dqadd3305 fma 1 98 1 -> 99
-dqadd3306 fma 1 99 1 -> 100
-dqadd3307 fma 1 100 1 -> 101
-dqadd3308 fma 1 101 1 -> 102
-dqadd3309 fma 1 -1 -1 -> -2
-dqadd3310 fma 1 0 -1 -> -1
-dqadd3311 fma 1 1 -1 -> 0
-dqadd3312 fma 1 12 -1 -> 11
-dqadd3313 fma 1 98 -1 -> 97
-dqadd3314 fma 1 99 -1 -> 98
-dqadd3315 fma 1 100 -1 -> 99
-dqadd3316 fma 1 101 -1 -> 100
-
-dqadd3321 fma 1 -0.01 0.01 -> 0.00
-dqadd3322 fma 1 0.00 0.01 -> 0.01
-dqadd3323 fma 1 0.01 0.01 -> 0.02
-dqadd3324 fma 1 0.12 0.01 -> 0.13
-dqadd3325 fma 1 0.98 0.01 -> 0.99
-dqadd3326 fma 1 0.99 0.01 -> 1.00
-dqadd3327 fma 1 1.00 0.01 -> 1.01
-dqadd3328 fma 1 1.01 0.01 -> 1.02
-dqadd3329 fma 1 -0.01 -0.01 -> -0.02
-dqadd3330 fma 1 0.00 -0.01 -> -0.01
-dqadd3331 fma 1 0.01 -0.01 -> 0.00
-dqadd3332 fma 1 0.12 -0.01 -> 0.11
-dqadd3333 fma 1 0.98 -0.01 -> 0.97
-dqadd3334 fma 1 0.99 -0.01 -> 0.98
-dqadd3335 fma 1 1.00 -0.01 -> 0.99
-dqadd3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where adding 0 affects the coefficient
-dqadd3340 fma 1 1E+3 0 -> 1000
-dqadd3341 fma 1 1E+33 0 -> 1000000000000000000000000000000000
-dqadd3342 fma 1 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
-dqadd3343 fma 1 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
--- which simply follow from these cases ...
-dqadd3344 fma 1 1E+3 1 -> 1001
-dqadd3345 fma 1 1E+33 1 -> 1000000000000000000000000000000001
-dqadd3346 fma 1 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd3347 fma 1 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-dqadd3348 fma 1 1E+3 7 -> 1007
-dqadd3349 fma 1 1E+33 7 -> 1000000000000000000000000000000007
-dqadd3350 fma 1 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
-dqadd3351 fma 1 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
-
--- tryzeros cases
-rounding: half_up
-dqadd3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
-dqadd3361 fma 1 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
-dqadd3362 fma 1 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
-dqadd3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
-dqadd3364 fma 1 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
--- 1 234567890123456789012345678901234
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-dqadd3370 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3371 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_up
-dqadd3372 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3373 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-rounding: half_even
-dqadd3374 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
-dqadd3375 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
-
--- ulp replacement tests
-dqadd3400 fma 1 1 77e-32 -> 1.00000000000000000000000000000077
-dqadd3401 fma 1 1 77e-33 -> 1.000000000000000000000000000000077
-dqadd3402 fma 1 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd3403 fma 1 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd3404 fma 1 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3405 fma 1 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3406 fma 1 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd3410 fma 1 10 77e-32 -> 10.00000000000000000000000000000077
-dqadd3411 fma 1 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd3412 fma 1 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd3413 fma 1 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3414 fma 1 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3415 fma 1 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3416 fma 1 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd3420 fma 1 77e-32 1 -> 1.00000000000000000000000000000077
-dqadd3421 fma 1 77e-33 1 -> 1.000000000000000000000000000000077
-dqadd3422 fma 1 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
-dqadd3423 fma 1 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
-dqadd3424 fma 1 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3425 fma 1 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd3426 fma 1 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd3430 fma 1 77e-32 10 -> 10.00000000000000000000000000000077
-dqadd3431 fma 1 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
-dqadd3432 fma 1 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
-dqadd3433 fma 1 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3434 fma 1 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3435 fma 1 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd3436 fma 1 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd36440 fma 1 1 -77e-32 -> 0.99999999999999999999999999999923
-dqadd36441 fma 1 1 -77e-33 -> 0.999999999999999999999999999999923
-dqadd36442 fma 1 1 -77e-34 -> 0.9999999999999999999999999999999923
-dqadd36443 fma 1 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36444 fma 1 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36445 fma 1 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd36446 fma 1 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36450 fma 1 10 -77e-32 -> 9.99999999999999999999999999999923
-dqadd36451 fma 1 10 -77e-33 -> 9.999999999999999999999999999999923
-dqadd36452 fma 1 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd36453 fma 1 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd36454 fma 1 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36455 fma 1 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36456 fma 1 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd36460 fma 1 -77e-32 1 -> 0.99999999999999999999999999999923
-dqadd36461 fma 1 -77e-33 1 -> 0.999999999999999999999999999999923
-dqadd36462 fma 1 -77e-34 1 -> 0.9999999999999999999999999999999923
-dqadd36463 fma 1 -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36464 fma 1 -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36465 fma 1 -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-dqadd36466 fma 1 -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36470 fma 1 -77e-32 10 -> 9.99999999999999999999999999999923
-dqadd36471 fma 1 -77e-33 10 -> 9.999999999999999999999999999999923
-dqadd36472 fma 1 -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
-dqadd36473 fma 1 -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
-dqadd36474 fma 1 -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36475 fma 1 -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-dqadd36476 fma 1 -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
-
--- negative ulps
-dqadd36480 fma 1 -1 77e-32 -> -0.99999999999999999999999999999923
-dqadd36481 fma 1 -1 77e-33 -> -0.999999999999999999999999999999923
-dqadd36482 fma 1 -1 77e-34 -> -0.9999999999999999999999999999999923
-dqadd36483 fma 1 -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36484 fma 1 -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36485 fma 1 -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd36486 fma 1 -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36490 fma 1 -10 77e-32 -> -9.99999999999999999999999999999923
-dqadd36491 fma 1 -10 77e-33 -> -9.999999999999999999999999999999923
-dqadd36492 fma 1 -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd36493 fma 1 -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd36494 fma 1 -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36495 fma 1 -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36496 fma 1 -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
-
-dqadd36500 fma 1 77e-32 -1 -> -0.99999999999999999999999999999923
-dqadd36501 fma 1 77e-33 -1 -> -0.999999999999999999999999999999923
-dqadd36502 fma 1 77e-34 -1 -> -0.9999999999999999999999999999999923
-dqadd36503 fma 1 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
-dqadd36504 fma 1 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
-dqadd36505 fma 1 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-dqadd36506 fma 1 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
-
-dqadd36510 fma 1 77e-32 -10 -> -9.99999999999999999999999999999923
-dqadd36511 fma 1 77e-33 -10 -> -9.999999999999999999999999999999923
-dqadd36512 fma 1 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
-dqadd36513 fma 1 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
-dqadd36514 fma 1 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36515 fma 1 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-dqadd36516 fma 1 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
-
--- and some more residue effects and different roundings
-rounding: half_up
-dqadd36540 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd36541 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36542 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36543 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36544 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36545 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36546 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36547 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36548 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36549 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36550 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36551 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36552 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36553 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36554 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36555 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36556 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd36557 fma 1 '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36558 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36559 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
-rounding: half_even
-dqadd36560 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd36561 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36562 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36563 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36564 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36565 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36566 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36567 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd36568 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36569 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36570 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36571 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36572 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36573 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36574 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36575 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36576 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd36577 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36578 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd36579 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- critical few with even bottom digit...
-dqadd37540 fma 1 '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd37541 fma 1 '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
-dqadd37542 fma 1 '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-
-rounding: down
-dqadd37550 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
-dqadd37551 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37552 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37553 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37554 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37555 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37556 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37557 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37558 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37559 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37560 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37561 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37562 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37563 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37564 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37565 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
-dqadd37566 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
-dqadd37567 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd37568 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
-dqadd37569 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-dqadd37701 fma 1 5.00 1.00E-3 -> 5.00100
-dqadd37702 fma 1 00.00 0.000 -> 0.000
-dqadd37703 fma 1 00.00 0E-3 -> 0.000
-dqadd37704 fma 1 0E-3 00.00 -> 0.000
-
-dqadd37710 fma 1 0E+3 00.00 -> 0.00
-dqadd37711 fma 1 0E+3 00.0 -> 0.0
-dqadd37712 fma 1 0E+3 00. -> 0
-dqadd37713 fma 1 0E+3 00.E+1 -> 0E+1
-dqadd37714 fma 1 0E+3 00.E+2 -> 0E+2
-dqadd37715 fma 1 0E+3 00.E+3 -> 0E+3
-dqadd37716 fma 1 0E+3 00.E+4 -> 0E+3
-dqadd37717 fma 1 0E+3 00.E+5 -> 0E+3
-dqadd37718 fma 1 0E+3 -00.0 -> 0.0
-dqadd37719 fma 1 0E+3 -00. -> 0
-dqadd37731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-dqadd37720 fma 1 00.00 0E+3 -> 0.00
-dqadd37721 fma 1 00.0 0E+3 -> 0.0
-dqadd37722 fma 1 00. 0E+3 -> 0
-dqadd37723 fma 1 00.E+1 0E+3 -> 0E+1
-dqadd37724 fma 1 00.E+2 0E+3 -> 0E+2
-dqadd37725 fma 1 00.E+3 0E+3 -> 0E+3
-dqadd37726 fma 1 00.E+4 0E+3 -> 0E+3
-dqadd37727 fma 1 00.E+5 0E+3 -> 0E+3
-dqadd37728 fma 1 -00.00 0E+3 -> 0.00
-dqadd37729 fma 1 -00.0 0E+3 -> 0.0
-dqadd37730 fma 1 -00. 0E+3 -> 0
-
-dqadd37732 fma 1 0 0 -> 0
-dqadd37733 fma 1 0 -0 -> 0
-dqadd37734 fma 1 -0 0 -> 0
-dqadd37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-dqadd37736 fma 1 1 -1 -> 0
-dqadd37737 fma 1 -1 -1 -> -2
-dqadd37738 fma 1 1 1 -> 2
-dqadd37739 fma 1 -1 1 -> 0
-
-dqadd37741 fma 1 0 -1 -> -1
-dqadd37742 fma 1 -0 -1 -> -1
-dqadd37743 fma 1 0 1 -> 1
-dqadd37744 fma 1 -0 1 -> 1
-dqadd37745 fma 1 -1 0 -> -1
-dqadd37746 fma 1 -1 -0 -> -1
-dqadd37747 fma 1 1 0 -> 1
-dqadd37748 fma 1 1 -0 -> 1
-
-dqadd37751 fma 1 0.0 -1 -> -1.0
-dqadd37752 fma 1 -0.0 -1 -> -1.0
-dqadd37753 fma 1 0.0 1 -> 1.0
-dqadd37754 fma 1 -0.0 1 -> 1.0
-dqadd37755 fma 1 -1.0 0 -> -1.0
-dqadd37756 fma 1 -1.0 -0 -> -1.0
-dqadd37757 fma 1 1.0 0 -> 1.0
-dqadd37758 fma 1 1.0 -0 -> 1.0
-
-dqadd37761 fma 1 0 -1.0 -> -1.0
-dqadd37762 fma 1 -0 -1.0 -> -1.0
-dqadd37763 fma 1 0 1.0 -> 1.0
-dqadd37764 fma 1 -0 1.0 -> 1.0
-dqadd37765 fma 1 -1 0.0 -> -1.0
-dqadd37766 fma 1 -1 -0.0 -> -1.0
-dqadd37767 fma 1 1 0.0 -> 1.0
-dqadd37768 fma 1 1 -0.0 -> 1.0
-
-dqadd37771 fma 1 0.0 -1.0 -> -1.0
-dqadd37772 fma 1 -0.0 -1.0 -> -1.0
-dqadd37773 fma 1 0.0 1.0 -> 1.0
-dqadd37774 fma 1 -0.0 1.0 -> 1.0
-dqadd37775 fma 1 -1.0 0.0 -> -1.0
-dqadd37776 fma 1 -1.0 -0.0 -> -1.0
-dqadd37777 fma 1 1.0 0.0 -> 1.0
-dqadd37778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-dqadd37780 fma 1 -Inf -Inf -> -Infinity
-dqadd37781 fma 1 -Inf -1000 -> -Infinity
-dqadd37782 fma 1 -Inf -1 -> -Infinity
-dqadd37783 fma 1 -Inf -0 -> -Infinity
-dqadd37784 fma 1 -Inf 0 -> -Infinity
-dqadd37785 fma 1 -Inf 1 -> -Infinity
-dqadd37786 fma 1 -Inf 1000 -> -Infinity
-dqadd37787 fma 1 -1000 -Inf -> -Infinity
-dqadd37788 fma 1 -Inf -Inf -> -Infinity
-dqadd37789 fma 1 -1 -Inf -> -Infinity
-dqadd37790 fma 1 -0 -Inf -> -Infinity
-dqadd37791 fma 1 0 -Inf -> -Infinity
-dqadd37792 fma 1 1 -Inf -> -Infinity
-dqadd37793 fma 1 1000 -Inf -> -Infinity
-dqadd37794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-dqadd37800 fma 1 Inf -Inf -> NaN Invalid_operation
-dqadd37801 fma 1 Inf -1000 -> Infinity
-dqadd37802 fma 1 Inf -1 -> Infinity
-dqadd37803 fma 1 Inf -0 -> Infinity
-dqadd37804 fma 1 Inf 0 -> Infinity
-dqadd37805 fma 1 Inf 1 -> Infinity
-dqadd37806 fma 1 Inf 1000 -> Infinity
-dqadd37807 fma 1 Inf Inf -> Infinity
-dqadd37808 fma 1 -1000 Inf -> Infinity
-dqadd37809 fma 1 -Inf Inf -> NaN Invalid_operation
-dqadd37810 fma 1 -1 Inf -> Infinity
-dqadd37811 fma 1 -0 Inf -> Infinity
-dqadd37812 fma 1 0 Inf -> Infinity
-dqadd37813 fma 1 1 Inf -> Infinity
-dqadd37814 fma 1 1000 Inf -> Infinity
-dqadd37815 fma 1 Inf Inf -> Infinity
-
-dqadd37821 fma 1 NaN -Inf -> NaN
-dqadd37822 fma 1 NaN -1000 -> NaN
-dqadd37823 fma 1 NaN -1 -> NaN
-dqadd37824 fma 1 NaN -0 -> NaN
-dqadd37825 fma 1 NaN 0 -> NaN
-dqadd37826 fma 1 NaN 1 -> NaN
-dqadd37827 fma 1 NaN 1000 -> NaN
-dqadd37828 fma 1 NaN Inf -> NaN
-dqadd37829 fma 1 NaN NaN -> NaN
-dqadd37830 fma 1 -Inf NaN -> NaN
-dqadd37831 fma 1 -1000 NaN -> NaN
-dqadd37832 fma 1 -1 NaN -> NaN
-dqadd37833 fma 1 -0 NaN -> NaN
-dqadd37834 fma 1 0 NaN -> NaN
-dqadd37835 fma 1 1 NaN -> NaN
-dqadd37836 fma 1 1000 NaN -> NaN
-dqadd37837 fma 1 Inf NaN -> NaN
-
-dqadd37841 fma 1 sNaN -Inf -> NaN Invalid_operation
-dqadd37842 fma 1 sNaN -1000 -> NaN Invalid_operation
-dqadd37843 fma 1 sNaN -1 -> NaN Invalid_operation
-dqadd37844 fma 1 sNaN -0 -> NaN Invalid_operation
-dqadd37845 fma 1 sNaN 0 -> NaN Invalid_operation
-dqadd37846 fma 1 sNaN 1 -> NaN Invalid_operation
-dqadd37847 fma 1 sNaN 1000 -> NaN Invalid_operation
-dqadd37848 fma 1 sNaN NaN -> NaN Invalid_operation
-dqadd37849 fma 1 sNaN sNaN -> NaN Invalid_operation
-dqadd37850 fma 1 NaN sNaN -> NaN Invalid_operation
-dqadd37851 fma 1 -Inf sNaN -> NaN Invalid_operation
-dqadd37852 fma 1 -1000 sNaN -> NaN Invalid_operation
-dqadd37853 fma 1 -1 sNaN -> NaN Invalid_operation
-dqadd37854 fma 1 -0 sNaN -> NaN Invalid_operation
-dqadd37855 fma 1 0 sNaN -> NaN Invalid_operation
-dqadd37856 fma 1 1 sNaN -> NaN Invalid_operation
-dqadd37857 fma 1 1000 sNaN -> NaN Invalid_operation
-dqadd37858 fma 1 Inf sNaN -> NaN Invalid_operation
-dqadd37859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqadd37861 fma 1 NaN1 -Inf -> NaN1
-dqadd37862 fma 1 +NaN2 -1000 -> NaN2
-dqadd37863 fma 1 NaN3 1000 -> NaN3
-dqadd37864 fma 1 NaN4 Inf -> NaN4
-dqadd37865 fma 1 NaN5 +NaN6 -> NaN5
-dqadd37866 fma 1 -Inf NaN7 -> NaN7
-dqadd37867 fma 1 -1000 NaN8 -> NaN8
-dqadd37868 fma 1 1000 NaN9 -> NaN9
-dqadd37869 fma 1 Inf +NaN10 -> NaN10
-dqadd37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-dqadd37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-dqadd37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-dqadd37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-dqadd37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqadd37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-dqadd37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-dqadd37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-dqadd37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-dqadd37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-dqadd37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqadd37882 fma 1 -NaN26 NaN28 -> -NaN26
-dqadd37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqadd37884 fma 1 1000 -NaN30 -> -NaN30
-dqadd37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Here we explore near the boundary of rounding a subnormal to Nmin
-dqadd37575 fma 1 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
-dqadd37576 fma 1 -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
-
--- check overflow edge case
--- 1234567890123456
-dqadd37972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqadd37973 fma 1 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37974 fma 1 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37975 fma 1 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
-dqadd37976 fma 1 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37977 fma 1 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37978 fma 1 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37979 fma 1 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37980 fma 1 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
-dqadd37981 fma 1 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37982 fma 1 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37983 fma 1 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37984 fma 1 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
-
-dqadd37985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqadd37986 fma 1 -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37987 fma 1 -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37988 fma 1 -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
-dqadd37989 fma 1 -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37990 fma 1 -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37991 fma 1 -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37992 fma 1 -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37993 fma 1 -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
-dqadd37994 fma 1 -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37995 fma 1 -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37996 fma 1 -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-dqadd37997 fma 1 -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-dqadd371100 fma 1 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
-dqadd371101 fma 1 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
-dqadd371103 fma 1 +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
-dqadd371104 fma 1 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
-dqadd371105 fma 1 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
-dqadd371106 fma 1 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd371107 fma 1 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd371108 fma 1 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd371109 fma 1 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-dqadd371110 fma 1 -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
-dqadd371111 fma 1 -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
-dqadd371113 fma 1 -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
-dqadd371114 fma 1 -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
-dqadd371115 fma 1 -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
-dqadd371116 fma 1 -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
-dqadd371117 fma 1 -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
-dqadd371118 fma 1 -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
-dqadd371119 fma 1 -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-dqadd371300 fma 1 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371310 fma 1 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371311 fma 1 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371312 fma 1 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371313 fma 1 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371314 fma 1 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371315 fma 1 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371316 fma 1 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371317 fma 1 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371318 fma 1 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371319 fma 1 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371320 fma 1 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371321 fma 1 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371322 fma 1 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371323 fma 1 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371324 fma 1 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371325 fma 1 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371326 fma 1 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371327 fma 1 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371328 fma 1 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371329 fma 1 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371330 fma 1 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371331 fma 1 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371332 fma 1 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371333 fma 1 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371334 fma 1 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371335 fma 1 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371336 fma 1 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371337 fma 1 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371338 fma 1 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371339 fma 1 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
-dqadd371340 fma 1 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
-dqadd371341 fma 1 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
-
-dqadd371349 fma 1 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371350 fma 1 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371351 fma 1 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371352 fma 1 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371353 fma 1 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371354 fma 1 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371355 fma 1 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371356 fma 1 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371357 fma 1 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371358 fma 1 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371359 fma 1 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371360 fma 1 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371361 fma 1 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371362 fma 1 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371363 fma 1 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371364 fma 1 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
-dqadd371365 fma 1 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371367 fma 1 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371368 fma 1 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371369 fma 1 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371370 fma 1 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371371 fma 1 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371372 fma 1 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371373 fma 1 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371374 fma 1 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371375 fma 1 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371376 fma 1 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371377 fma 1 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371378 fma 1 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371379 fma 1 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371380 fma 1 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371381 fma 1 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371382 fma 1 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371383 fma 1 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371384 fma 1 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371385 fma 1 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371386 fma 1 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371387 fma 1 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371388 fma 1 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371389 fma 1 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371390 fma 1 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371391 fma 1 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371392 fma 1 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371393 fma 1 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371394 fma 1 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371395 fma 1 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-dqadd371396 fma 1 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-dqadd371420 fma 1 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
-dqadd371421 fma 1 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
-dqadd371422 fma 1 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
-dqadd371423 fma 1 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
-dqadd371424 fma 1 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
-dqadd371425 fma 1 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
-dqadd371426 fma 1 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
-dqadd371427 fma 1 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
-dqadd371428 fma 1 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
-dqadd371429 fma 1 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
-dqadd371430 fma 1 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
-dqadd371431 fma 1 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
-dqadd371432 fma 1 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
-dqadd371433 fma 1 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
-dqadd371434 fma 1 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
-dqadd371435 fma 1 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
-dqadd371436 fma 1 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
-dqadd371437 fma 1 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
-dqadd371438 fma 1 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
-dqadd371439 fma 1 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
-dqadd371440 fma 1 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
-dqadd371441 fma 1 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
-dqadd371442 fma 1 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
-dqadd371443 fma 1 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
-dqadd371444 fma 1 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
-dqadd371445 fma 1 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
-dqadd371446 fma 1 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
-dqadd371447 fma 1 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
-dqadd371448 fma 1 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
-dqadd371449 fma 1 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
-dqadd371450 fma 1 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
-dqadd371451 fma 1 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
-dqadd371452 fma 1 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
-dqadd371453 fma 1 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
-dqadd371454 fma 1 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
-dqadd371455 fma 1 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
-dqadd371456 fma 1 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
-
--- same, reversed 0
-dqadd371460 fma 1 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
-dqadd371461 fma 1 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
-dqadd371462 fma 1 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
-dqadd371463 fma 1 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
-dqadd371464 fma 1 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
-dqadd371465 fma 1 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
-dqadd371466 fma 1 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
-dqadd371467 fma 1 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
-dqadd371468 fma 1 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
-dqadd371469 fma 1 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
-dqadd371470 fma 1 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
-dqadd371471 fma 1 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
-dqadd371472 fma 1 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
-dqadd371473 fma 1 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
-dqadd371474 fma 1 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
-dqadd371475 fma 1 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
-dqadd371476 fma 1 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
-dqadd371477 fma 1 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
-dqadd371478 fma 1 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
-dqadd371479 fma 1 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
-dqadd371480 fma 1 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
-dqadd371481 fma 1 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
-dqadd371482 fma 1 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
-dqadd371483 fma 1 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
-dqadd371484 fma 1 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
-dqadd371485 fma 1 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
-dqadd371486 fma 1 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
-dqadd371487 fma 1 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
-dqadd371488 fma 1 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
-dqadd371489 fma 1 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
-dqadd371490 fma 1 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
-dqadd371491 fma 1 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
-dqadd371492 fma 1 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
-dqadd371493 fma 1 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
-dqadd371494 fma 1 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
-dqadd371495 fma 1 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
-dqadd371496 fma 1 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
-
--- same, Es on the 0
-dqadd371500 fma 1 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
-dqadd371501 fma 1 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
-dqadd371502 fma 1 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
-dqadd371503 fma 1 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
-dqadd371504 fma 1 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
-dqadd371505 fma 1 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
-dqadd371506 fma 1 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
-dqadd371507 fma 1 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
-dqadd371508 fma 1 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
-dqadd371509 fma 1 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
-dqadd371510 fma 1 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
-dqadd371511 fma 1 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
-dqadd371512 fma 1 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
-dqadd371513 fma 1 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
-dqadd371514 fma 1 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
-dqadd371515 fma 1 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
-dqadd371516 fma 1 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
-dqadd371517 fma 1 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
-dqadd371518 fma 1 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
-dqadd371519 fma 1 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
-dqadd371520 fma 1 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
-dqadd371521 fma 1 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
-dqadd371522 fma 1 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
-dqadd371523 fma 1 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
-dqadd371524 fma 1 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
-dqadd371525 fma 1 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
-dqadd371526 fma 1 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
-dqadd371527 fma 1 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
-dqadd371528 fma 1 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
-dqadd371529 fma 1 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
-dqadd371530 fma 1 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
-dqadd371531 fma 1 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
-dqadd371532 fma 1 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
-dqadd371533 fma 1 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
--- next four flag Rounded because the 0 extends the result
-dqadd371534 fma 1 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
-dqadd371535 fma 1 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
-dqadd371536 fma 1 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
-dqadd371537 fma 1 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-dqadd371600 fma 1 0 0E-19 -> 0E-19
-dqadd371601 fma 1 -0 0E-19 -> 0E-19
-dqadd371602 fma 1 0 -0E-19 -> 0E-19
-dqadd371603 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371611 fma 1 -11 11 -> 0
-dqadd371612 fma 1 11 -11 -> 0
--- overflow
-dqadd371613 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371614 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_down
--- exact zeros from zeros
-dqadd371620 fma 1 0 0E-19 -> 0E-19
-dqadd371621 fma 1 -0 0E-19 -> 0E-19
-dqadd371622 fma 1 0 -0E-19 -> 0E-19
-dqadd371623 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371631 fma 1 -11 11 -> 0
-dqadd371632 fma 1 11 -11 -> 0
--- overflow
-dqadd371633 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371634 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
--- exact zeros from zeros
-dqadd371640 fma 1 0 0E-19 -> 0E-19
-dqadd371641 fma 1 -0 0E-19 -> 0E-19
-dqadd371642 fma 1 0 -0E-19 -> 0E-19
-dqadd371643 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371651 fma 1 -11 11 -> 0
-dqadd371652 fma 1 11 -11 -> 0
--- overflow
-dqadd371653 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371654 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: up
--- exact zeros from zeros
-dqadd371660 fma 1 0 0E-19 -> 0E-19
-dqadd371661 fma 1 -0 0E-19 -> 0E-19
-dqadd371662 fma 1 0 -0E-19 -> 0E-19
-dqadd371663 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371671 fma 1 -11 11 -> 0
-dqadd371672 fma 1 11 -11 -> 0
--- overflow
-dqadd371673 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371674 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: down
--- exact zeros from zeros
-dqadd371680 fma 1 0 0E-19 -> 0E-19
-dqadd371681 fma 1 -0 0E-19 -> 0E-19
-dqadd371682 fma 1 0 -0E-19 -> 0E-19
-dqadd371683 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371691 fma 1 -11 11 -> 0
-dqadd371692 fma 1 11 -11 -> 0
--- overflow
-dqadd371693 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371694 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
-rounding: ceiling
--- exact zeros from zeros
-dqadd371700 fma 1 0 0E-19 -> 0E-19
-dqadd371701 fma 1 -0 0E-19 -> 0E-19
-dqadd371702 fma 1 0 -0E-19 -> 0E-19
-dqadd371703 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371711 fma 1 -11 11 -> 0
-dqadd371712 fma 1 11 -11 -> 0
--- overflow
-dqadd371713 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
-dqadd371714 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-dqadd371720 fma 1 0 0E-19 -> 0E-19
-dqadd371721 fma 1 -0 0E-19 -> -0E-19 -- *
-dqadd371722 fma 1 0 -0E-19 -> -0E-19 -- *
-dqadd371723 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371731 fma 1 -11 11 -> -0 -- *
-dqadd371732 fma 1 11 -11 -> -0 -- *
--- overflow
-dqadd371733 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371734 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
-
-rounding: 05up
--- exact zeros from zeros
-dqadd371740 fma 1 0 0E-19 -> 0E-19
-dqadd371741 fma 1 -0 0E-19 -> 0E-19
-dqadd371742 fma 1 0 -0E-19 -> 0E-19
-dqadd371743 fma 1 -0 -0E-19 -> -0E-19
--- exact zeros from non-zeros
-dqadd371751 fma 1 -11 11 -> 0
-dqadd371752 fma 1 11 -11 -> 0
--- overflow
-dqadd371753 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-dqadd371754 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqadd371761 fma 1 130E-2 120E-2 -> 2.50
-dqadd371762 fma 1 130E-2 12E-1 -> 2.50
-dqadd371763 fma 1 130E-2 1E0 -> 2.30
-dqadd371764 fma 1 1E2 1E4 -> 1.01E+4
-dqadd371765 fma 1 130E-2 -120E-2 -> 0.10
-dqadd371766 fma 1 130E-2 -12E-1 -> 0.10
-dqadd371767 fma 1 130E-2 -1E0 -> 0.30
-dqadd371768 fma 1 1E2 -1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-dqadd375001 fma 1 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
-dqadd375002 fma 1 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
-dqadd375003 fma 1 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375004 fma 1 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375005 fma 1 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375006 fma 1 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375007 fma 1 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375008 fma 1 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375009 fma 1 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375010 fma 1 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375011 fma 1 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375012 fma 1 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375013 fma 1 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375014 fma 1 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375015 fma 1 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375016 fma 1 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375017 fma 1 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375018 fma 1 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375019 fma 1 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375020 fma 1 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
-dqadd375021 fma 1 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
-
--- widening second argument at gap
-dqadd375030 fma 1 12398765432112345678945678 1 -> 12398765432112345678945679
-dqadd375031 fma 1 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
-dqadd375032 fma 1 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
-dqadd375033 fma 1 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
-dqadd375034 fma 1 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
-dqadd375035 fma 1 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
-dqadd375036 fma 1 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
-dqadd375037 fma 1 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
-dqadd375038 fma 1 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
-dqadd375039 fma 1 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375040 fma 1 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd375041 fma 1 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
-dqadd375042 fma 1 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375043 fma 1 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375044 fma 1 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375045 fma 1 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375046 fma 1 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375047 fma 1 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375048 fma 1 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
-dqadd375049 fma 1 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-dqadd375050 fma 1 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd375051 fma 1 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd375052 fma 1 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd375053 fma 1 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd375054 fma 1 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd375055 fma 1 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd375056 fma 1 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd375057 fma 1 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
-dqadd375060 fma 1 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
-dqadd375061 fma 1 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
-dqadd375062 fma 1 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
-dqadd375063 fma 1 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
-dqadd375064 fma 1 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
-dqadd375065 fma 1 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
-dqadd375066 fma 1 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
-dqadd375067 fma 1 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-dqadd375070 fma 1 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
-dqadd375071 fma 1 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375072 fma 1 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375073 fma 1 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375074 fma 1 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375075 fma 1 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375076 fma 1 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375077 fma 1 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375078 fma 1 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375079 fma 1 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375080 fma 1 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375081 fma 1 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375082 fma 1 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375083 fma 1 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375084 fma 1 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375085 fma 1 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375086 fma 1 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375087 fma 1 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375088 fma 1 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
-dqadd375089 fma 1 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
-
--- Destructive subtract (from remainder tests)
-
--- +++ some of these will be off-by-one remainder vs remainderNear
-
-dqfma4000 fma -1234567890123456789012345678901233 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> -0.234567890123456789012345678901233
-dqfma4001 fma -1234567890123456789012345678901222 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> -0.34567890123456789012345678901222
-dqfma4002 fma -1234567890123456789012345678901111 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.4567890123456789012345678901111
-dqfma4003 fma -308641972530864197253086419725314 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> -1.308641972530864197253086419725314
-dqfma4004 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
-dqfma4005 fma -246913578024691357802469135780252 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> -1.3086421975308642197530864219748
-dqfma4006 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
-dqfma4007 fma -246913578024691357802469135780247 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> -0.753086421975308642197530864219753
-dqfma4008 fma -246913578024691357802469135780247 5.000000000000000000000000000000001 1234567890123456789012345678901234 -> -1.246913578024691357802469135780247
-dqfma4009 fma -246913578024691357802469135780246 5.00000000000000000000000000000001 1234567890123456789012345678901234 -> 1.53086421975308642197530864219754
-dqfma4010 fma -246913578024691357802469135780242 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.6913578024691357802469135780242
-dqfma4011 fma -1234567890123456789012345678901232 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> 0.765432109876543210987654321098768
-dqfma4012 fma -1234567890123456789012345678901221 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> 0.65432109876543210987654321098779
-dqfma4013 fma -1234567890123456789012345678901110 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> 0.5432109876543210987654321098890
-dqfma4014 fma -308641972530864197253086419725313 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> 2.691358027469135802746913580274687
-dqfma4015 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
-dqfma4016 fma -246913578024691357802469135780251 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> 3.6913578024691357802469135780251
-dqfma4017 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
-dqfma4018 fma -246913578024691357802469135780246 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> 4.246913578024691357802469135780246
-dqfma4019 fma -246913578024691357802469135780241 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> 4.3086421975308642197530864219759
-
--- Null tests
-dqadd39990 fma 1 10 # -> NaN Invalid_operation
-dqadd39991 fma 1 # 10 -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- dqFMA.decTest -- decQuad Fused Multiply Add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+dqfma0001 fma 1 1 1 -> 2
+dqfma0002 fma 1 1 2 -> 3
+dqfma0003 fma 2 2 3 -> 7
+dqfma0004 fma 9 9 9 -> 90
+dqfma0005 fma -1 1 1 -> 0
+dqfma0006 fma -1 1 2 -> 1
+dqfma0007 fma -2 2 3 -> -1
+dqfma0008 fma -9 9 9 -> -72
+dqfma0011 fma 1 -1 1 -> 0
+dqfma0012 fma 1 -1 2 -> 1
+dqfma0013 fma 2 -2 3 -> -1
+dqfma0014 fma 9 -9 9 -> -72
+dqfma0015 fma 1 1 -1 -> 0
+dqfma0016 fma 1 1 -2 -> -1
+dqfma0017 fma 2 2 -3 -> 1
+dqfma0018 fma 9 9 -9 -> 72
+
+-- non-integer exacts
+dqfma0100 fma 25.2 63.6 -438 -> 1164.72
+dqfma0101 fma 0.301 0.380 334 -> 334.114380
+dqfma0102 fma 49.2 -4.8 23.3 -> -212.86
+dqfma0103 fma 4.22 0.079 -94.6 -> -94.26662
+dqfma0104 fma 903 0.797 0.887 -> 720.578
+dqfma0105 fma 6.13 -161 65.9 -> -921.03
+dqfma0106 fma 28.2 727 5.45 -> 20506.85
+dqfma0107 fma 4 605 688 -> 3108
+dqfma0108 fma 93.3 0.19 0.226 -> 17.953
+dqfma0109 fma 0.169 -341 5.61 -> -52.019
+dqfma0110 fma -72.2 30 -51.2 -> -2217.2
+dqfma0111 fma -0.409 13 20.4 -> 15.083
+dqfma0112 fma 317 77.0 19.0 -> 24428.0
+dqfma0113 fma 47 6.58 1.62 -> 310.88
+dqfma0114 fma 1.36 0.984 0.493 -> 1.83124
+dqfma0115 fma 72.7 274 1.56 -> 19921.36
+dqfma0116 fma 335 847 83 -> 283828
+dqfma0117 fma 666 0.247 25.4 -> 189.902
+dqfma0118 fma -3.87 3.06 78.0 -> 66.1578
+dqfma0119 fma 0.742 192 35.6 -> 178.064
+dqfma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- -> 4.500119002100000209469729375698778E+38
+dqfma0202 fma 68537985861355864457.5694 6565875762972086605.85969 35892634447236753.172812 -> 4.500119002100000209469729375698779E+38 Inexact Rounded
+-- -> 5.996248469584594346858881620185514E+41
+dqfma0208 fma 89261822344727628571.9 6717595845654131383336.89 5061036497288796076266.11 -> 5.996248469584594346858881620185513E+41 Inexact Rounded
+-- -> 1.899242968678256924021594770874070E+34
+dqfma0210 fma 320506237232448685.495971 59257597764017967.984448 3205615239077711589912.85 -> 1.899242968678256924021594770874071E+34 Inexact Rounded
+-- -> 7.078596978842809537929699954860309E+37
+dqfma0215 fma 220247843259112263.17995 321392340287987979002.80 47533279819997167655440 -> 7.078596978842809537929699954860308E+37 Inexact Rounded
+-- -> 1.224955667581427559754106862350743E+37
+dqfma0226 fma 23880729790368880412.1449 512947333827064719.55407 217117438419590824502.963 -> 1.224955667581427559754106862350744E+37 Inexact Rounded
+-- -> -2.530094043253148806272276368579144E+42
+dqfma0229 fma 2539892357016099706.4126 -996142232667504817717435 53682082598315949425.937 -> -2.530094043253148806272276368579143E+42 Inexact Rounded
+-- -> 1.713387085759711954319391412788454E+37
+dqfma0233 fma 4546339491341624464.0804 3768717864169205581 83578980278690395184.620 -> 1.713387085759711954319391412788453E+37 Inexact Rounded
+-- -> 4.062275663405823716411579117771547E+35
+dqfma0235 fma 409242119433816131.42253 992633815166741501.477249 70179636544416756129546 -> 4.062275663405823716411579117771548E+35 Inexact Rounded
+-- -> 6.002604327732568490562249875306823E+47
+dqfma0258 fma 817941336593541742159684 733867339769310729266598 78563844650942419311830.8 -> 6.002604327732568490562249875306822E+47 Inexact Rounded
+-- -> -2.027022514381452197510103395283874E+39
+dqfma0264 fma 387617310169161270.737532 -5229442703414956061216.62 57665666816652967150473.5 -> -2.027022514381452197510103395283873E+39 Inexact Rounded
+-- -> -7.856525039803554001144089842730361E+37
+dqfma0267 fma -847655845720565274701.210 92685316564117739.83984 22780950041376424429.5686 -> -7.856525039803554001144089842730360E+37 Inexact Rounded
+-- -> 1.695515562011520746125607502237559E+38
+dqfma0268 fma 21590290365127685.3675 7853139227576541379426.8 -3275859437236180.761544 -> 1.695515562011520746125607502237558E+38 Inexact Rounded
+-- -> -8.448422935783289219748115038014710E+38
+dqfma0269 fma -974320636272862697.971586 867109103641860247440.756 -9775170775902454762.98 -> -8.448422935783289219748115038014709E+38 Inexact Rounded
+
+-- Cases where multiply would overflow or underflow if separate
+dqfma0300 fma 9e+6144 10 0 -> Infinity Overflow Inexact Rounded
+dqfma0301 fma 1e+6144 10 0 -> Infinity Overflow Inexact Rounded
+dqfma0302 fma 1e+6144 10 -1e+6144 -> 9.000000000000000000000000000000000E+6144 Clamped
+dqfma0303 fma 1e+6144 10 -9e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
+-- subnormal etc.
+dqfma0305 fma 1e-6176 0.1 0 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma0306 fma 1e-6176 0.1 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqfma0307 fma 1e-6176 0.1 1e-6176 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+-- Infinite combinations
+dqfma0800 fma Inf Inf Inf -> Infinity
+dqfma0801 fma Inf Inf -Inf -> NaN Invalid_operation
+dqfma0802 fma Inf -Inf Inf -> NaN Invalid_operation
+dqfma0803 fma Inf -Inf -Inf -> -Infinity
+dqfma0804 fma -Inf Inf Inf -> NaN Invalid_operation
+dqfma0805 fma -Inf Inf -Inf -> -Infinity
+dqfma0806 fma -Inf -Inf Inf -> Infinity
+dqfma0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+
+-- Triple NaN propagation
+dqfma0900 fma NaN2 NaN3 NaN5 -> NaN2
+dqfma0901 fma 0 NaN3 NaN5 -> NaN3
+dqfma0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+dqfma0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+dqfma0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+dqfma0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+dqfma0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+dqfma0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+dqfma0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+rounding: half_even
+
+-- sanity checks
+dqfma2000 fma 2 2 0e+6144 -> 4
+dqfma2001 fma 2 3 0e+6144 -> 6
+dqfma2002 fma 5 1 0e+6144 -> 5
+dqfma2003 fma 5 2 0e+6144 -> 10
+dqfma2004 fma 1.20 2 0e+6144 -> 2.40
+dqfma2005 fma 1.20 0 0e+6144 -> 0.00
+dqfma2006 fma 1.20 -2 0e+6144 -> -2.40
+dqfma2007 fma -1.20 2 0e+6144 -> -2.40
+dqfma2008 fma -1.20 0 0e+6144 -> 0.00
+dqfma2009 fma -1.20 -2 0e+6144 -> 2.40
+dqfma2010 fma 5.09 7.1 0e+6144 -> 36.139
+dqfma2011 fma 2.5 4 0e+6144 -> 10.0
+dqfma2012 fma 2.50 4 0e+6144 -> 10.00
+dqfma2013 fma 1.23456789 1.0000000000000000000000000000 0e+6144 -> 1.234567890000000000000000000000000 Rounded
+dqfma2015 fma 2.50 4 0e+6144 -> 10.00
+dqfma2016 fma 9.99999999999999999 9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
+dqfma2017 fma 9.99999999999999999 -9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqfma2018 fma -9.99999999999999999 9.99999999999999999 0e+6144 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqfma2019 fma -9.99999999999999999 -9.99999999999999999 0e+6144 -> 99.99999999999999980000000000000000 Inexact Rounded
+
+-- zeros, etc.
+dqfma2021 fma 0 0 0e+6144 -> 0
+dqfma2022 fma 0 -0 0e+6144 -> 0
+dqfma2023 fma -0 0 0e+6144 -> 0
+dqfma2024 fma -0 -0 0e+6144 -> 0
+dqfma2025 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2026 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2027 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2028 fma -0.0 -0.0 0e+6144 -> 0.00
+dqfma2030 fma 5.00 1E-3 0e+6144 -> 0.00500
+dqfma2031 fma 00.00 0.000 0e+6144 -> 0.00000
+dqfma2032 fma 00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2033 fma 0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2034 fma -5.00 1E-3 0e+6144 -> -0.00500
+dqfma2035 fma -00.00 0.000 0e+6144 -> 0.00000
+dqfma2036 fma -00.00 0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2037 fma -0E-3 00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2038 fma 5.00 -1E-3 0e+6144 -> -0.00500
+dqfma2039 fma 00.00 -0.000 0e+6144 -> 0.00000
+dqfma2040 fma 00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2041 fma 0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
+dqfma2042 fma -5.00 -1E-3 0e+6144 -> 0.00500
+dqfma2043 fma -00.00 -0.000 0e+6144 -> 0.00000
+dqfma2044 fma -00.00 -0E-3 0e+6144 -> 0.00000 -- rhs is 0
+dqfma2045 fma -0E-3 -00.00 0e+6144 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+dqfma2050 fma 1.20 3 0e+6144 -> 3.60
+dqfma2051 fma 7 3 0e+6144 -> 21
+dqfma2052 fma 0.9 0.8 0e+6144 -> 0.72
+dqfma2053 fma 0.9 -0 0e+6144 -> 0.0
+dqfma2054 fma 654321 654321 0e+6144 -> 428135971041
+
+dqfma2060 fma 123.45 1e7 0e+6144 -> 1.2345E+9
+dqfma2061 fma 123.45 1e8 0e+6144 -> 1.2345E+10
+dqfma2062 fma 123.45 1e+9 0e+6144 -> 1.2345E+11
+dqfma2063 fma 123.45 1e10 0e+6144 -> 1.2345E+12
+dqfma2064 fma 123.45 1e11 0e+6144 -> 1.2345E+13
+dqfma2065 fma 123.45 1e12 0e+6144 -> 1.2345E+14
+dqfma2066 fma 123.45 1e13 0e+6144 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+dqfma2080 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
+dqfma2084 fma 0.1 1230123456456789 0e+6144 -> 123012345645678.9
+dqfma2090 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
+dqfma2094 fma 1230123456456789 0.1 0e+6144 -> 123012345645678.9
+
+-- test some more edge cases and carries
+dqfma2101 fma 9 9 0e+6144 -> 81
+dqfma2102 fma 9 90 0e+6144 -> 810
+dqfma2103 fma 9 900 0e+6144 -> 8100
+dqfma2104 fma 9 9000 0e+6144 -> 81000
+dqfma2105 fma 9 90000 0e+6144 -> 810000
+dqfma2106 fma 9 900000 0e+6144 -> 8100000
+dqfma2107 fma 9 9000000 0e+6144 -> 81000000
+dqfma2108 fma 9 90000000 0e+6144 -> 810000000
+dqfma2109 fma 9 900000000 0e+6144 -> 8100000000
+dqfma2110 fma 9 9000000000 0e+6144 -> 81000000000
+dqfma2111 fma 9 90000000000 0e+6144 -> 810000000000
+dqfma2112 fma 9 900000000000 0e+6144 -> 8100000000000
+dqfma2113 fma 9 9000000000000 0e+6144 -> 81000000000000
+dqfma2114 fma 9 90000000000000 0e+6144 -> 810000000000000
+dqfma2115 fma 9 900000000000000 0e+6144 -> 8100000000000000
+--dqfma2116 fma 9 9000000000000000 0e+6144 -> 81000000000000000
+--dqfma2117 fma 9 90000000000000000 0e+6144 -> 810000000000000000
+--dqfma2118 fma 9 900000000000000000 0e+6144 -> 8100000000000000000
+--dqfma2119 fma 9 9000000000000000000 0e+6144 -> 81000000000000000000
+--dqfma2120 fma 9 90000000000000000000 0e+6144 -> 810000000000000000000
+--dqfma2121 fma 9 900000000000000000000 0e+6144 -> 8100000000000000000000
+--dqfma2122 fma 9 9000000000000000000000 0e+6144 -> 81000000000000000000000
+--dqfma2123 fma 9 90000000000000000000000 0e+6144 -> 810000000000000000000000
+-- test some more edge cases without carries
+dqfma2131 fma 3 3 0e+6144 -> 9
+dqfma2132 fma 3 30 0e+6144 -> 90
+dqfma2133 fma 3 300 0e+6144 -> 900
+dqfma2134 fma 3 3000 0e+6144 -> 9000
+dqfma2135 fma 3 30000 0e+6144 -> 90000
+dqfma2136 fma 3 300000 0e+6144 -> 900000
+dqfma2137 fma 3 3000000 0e+6144 -> 9000000
+dqfma2138 fma 3 30000000 0e+6144 -> 90000000
+dqfma2139 fma 3 300000000 0e+6144 -> 900000000
+dqfma2140 fma 3 3000000000 0e+6144 -> 9000000000
+dqfma2141 fma 3 30000000000 0e+6144 -> 90000000000
+dqfma2142 fma 3 300000000000 0e+6144 -> 900000000000
+dqfma2143 fma 3 3000000000000 0e+6144 -> 9000000000000
+dqfma2144 fma 3 30000000000000 0e+6144 -> 90000000000000
+dqfma2145 fma 3 300000000000000 0e+6144 -> 900000000000000
+dqfma2146 fma 3 3000000000000000 0e+6144 -> 9000000000000000
+dqfma2147 fma 3 30000000000000000 0e+6144 -> 90000000000000000
+dqfma2148 fma 3 300000000000000000 0e+6144 -> 900000000000000000
+dqfma2149 fma 3 3000000000000000000 0e+6144 -> 9000000000000000000
+dqfma2150 fma 3 30000000000000000000 0e+6144 -> 90000000000000000000
+dqfma2151 fma 3 300000000000000000000 0e+6144 -> 900000000000000000000
+dqfma2152 fma 3 3000000000000000000000 0e+6144 -> 9000000000000000000000
+dqfma2153 fma 3 30000000000000000000000 0e+6144 -> 90000000000000000000000
+
+dqfma2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0e+6144 -> 145433.2908011933696719165119928296 Inexact Rounded
+
+-- test some edge cases with exact rounding
+dqfma2301 fma 900000000000000000 9 0e+6144 -> 8100000000000000000
+dqfma2302 fma 900000000000000000 90 0e+6144 -> 81000000000000000000
+dqfma2303 fma 900000000000000000 900 0e+6144 -> 810000000000000000000
+dqfma2304 fma 900000000000000000 9000 0e+6144 -> 8100000000000000000000
+dqfma2305 fma 900000000000000000 90000 0e+6144 -> 81000000000000000000000
+dqfma2306 fma 900000000000000000 900000 0e+6144 -> 810000000000000000000000
+dqfma2307 fma 900000000000000000 9000000 0e+6144 -> 8100000000000000000000000
+dqfma2308 fma 900000000000000000 90000000 0e+6144 -> 81000000000000000000000000
+dqfma2309 fma 900000000000000000 900000000 0e+6144 -> 810000000000000000000000000
+dqfma2310 fma 900000000000000000 9000000000 0e+6144 -> 8100000000000000000000000000
+dqfma2311 fma 900000000000000000 90000000000 0e+6144 -> 81000000000000000000000000000
+dqfma2312 fma 900000000000000000 900000000000 0e+6144 -> 810000000000000000000000000000
+dqfma2313 fma 900000000000000000 9000000000000 0e+6144 -> 8100000000000000000000000000000
+dqfma2314 fma 900000000000000000 90000000000000 0e+6144 -> 81000000000000000000000000000000
+dqfma2315 fma 900000000000000000 900000000000000 0e+6144 -> 810000000000000000000000000000000
+dqfma2316 fma 900000000000000000 9000000000000000 0e+6144 -> 8100000000000000000000000000000000
+dqfma2317 fma 9000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+34 Rounded
+dqfma2318 fma 90000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+35 Rounded
+dqfma2319 fma 900000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+36 Rounded
+dqfma2320 fma 9000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+37 Rounded
+dqfma2321 fma 90000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+38 Rounded
+dqfma2322 fma 900000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+39 Rounded
+dqfma2323 fma 9000000000000000000000000 9000000000000000 0e+6144 -> 8.100000000000000000000000000000000E+40 Rounded
+
+-- tryzeros cases
+dqfma2504 fma 0E-4260 1000E-4260 0e+6144 -> 0E-6176 Clamped
+dqfma2505 fma 100E+4260 0E+4260 0e+6144 -> 0E+6111 Clamped
+
+-- mixed with zeros
+dqfma2541 fma 0 -1 0e+6144 -> 0
+dqfma2542 fma -0 -1 0e+6144 -> 0
+dqfma2543 fma 0 1 0e+6144 -> 0
+dqfma2544 fma -0 1 0e+6144 -> 0
+dqfma2545 fma -1 0 0e+6144 -> 0
+dqfma2546 fma -1 -0 0e+6144 -> 0
+dqfma2547 fma 1 0 0e+6144 -> 0
+dqfma2548 fma 1 -0 0e+6144 -> 0
+
+dqfma2551 fma 0.0 -1 0e+6144 -> 0.0
+dqfma2552 fma -0.0 -1 0e+6144 -> 0.0
+dqfma2553 fma 0.0 1 0e+6144 -> 0.0
+dqfma2554 fma -0.0 1 0e+6144 -> 0.0
+dqfma2555 fma -1.0 0 0e+6144 -> 0.0
+dqfma2556 fma -1.0 -0 0e+6144 -> 0.0
+dqfma2557 fma 1.0 0 0e+6144 -> 0.0
+dqfma2558 fma 1.0 -0 0e+6144 -> 0.0
+
+dqfma2561 fma 0 -1.0 0e+6144 -> 0.0
+dqfma2562 fma -0 -1.0 0e+6144 -> 0.0
+dqfma2563 fma 0 1.0 0e+6144 -> 0.0
+dqfma2564 fma -0 1.0 0e+6144 -> 0.0
+dqfma2565 fma -1 0.0 0e+6144 -> 0.0
+dqfma2566 fma -1 -0.0 0e+6144 -> 0.0
+dqfma2567 fma 1 0.0 0e+6144 -> 0.0
+dqfma2568 fma 1 -0.0 0e+6144 -> 0.0
+
+dqfma2571 fma 0.0 -1.0 0e+6144 -> 0.00
+dqfma2572 fma -0.0 -1.0 0e+6144 -> 0.00
+dqfma2573 fma 0.0 1.0 0e+6144 -> 0.00
+dqfma2574 fma -0.0 1.0 0e+6144 -> 0.00
+dqfma2575 fma -1.0 0.0 0e+6144 -> 0.00
+dqfma2576 fma -1.0 -0.0 0e+6144 -> 0.00
+dqfma2577 fma 1.0 0.0 0e+6144 -> 0.00
+dqfma2578 fma 1.0 -0.0 0e+6144 -> 0.00
+dqfma2579 fma 1.0 0.0 0e+6144 -> 0.00
+dqfma2530 fma -1.0 -0.0 0e+6144 -> 0.00
+dqfma2531 fma -1.0 0.0 0e+6144 -> 0.00
+dqfma2532 fma 1.0 -0.0 -0e+6144 -> -0.00
+dqfma2533 fma 1.0 0.0 -0e+6144 -> 0.00
+dqfma2534 fma -1.0 -0.0 -0e+6144 -> 0.00
+dqfma2535 fma -1.0 0.0 -0e+6144 -> -0.00
+
+
+-- Specials
+dqfma2580 fma Inf -Inf 0e+6144 -> -Infinity
+dqfma2581 fma Inf -1000 0e+6144 -> -Infinity
+dqfma2582 fma Inf -1 0e+6144 -> -Infinity
+dqfma2583 fma Inf -0 0e+6144 -> NaN Invalid_operation
+dqfma2584 fma Inf 0 0e+6144 -> NaN Invalid_operation
+dqfma2585 fma Inf 1 0e+6144 -> Infinity
+dqfma2586 fma Inf 1000 0e+6144 -> Infinity
+dqfma2587 fma Inf Inf 0e+6144 -> Infinity
+dqfma2588 fma -1000 Inf 0e+6144 -> -Infinity
+dqfma2589 fma -Inf Inf 0e+6144 -> -Infinity
+dqfma2590 fma -1 Inf 0e+6144 -> -Infinity
+dqfma2591 fma -0 Inf 0e+6144 -> NaN Invalid_operation
+dqfma2592 fma 0 Inf 0e+6144 -> NaN Invalid_operation
+dqfma2593 fma 1 Inf 0e+6144 -> Infinity
+dqfma2594 fma 1000 Inf 0e+6144 -> Infinity
+dqfma2595 fma Inf Inf 0e+6144 -> Infinity
+
+dqfma2600 fma -Inf -Inf 0e+6144 -> Infinity
+dqfma2601 fma -Inf -1000 0e+6144 -> Infinity
+dqfma2602 fma -Inf -1 0e+6144 -> Infinity
+dqfma2603 fma -Inf -0 0e+6144 -> NaN Invalid_operation
+dqfma2604 fma -Inf 0 0e+6144 -> NaN Invalid_operation
+dqfma2605 fma -Inf 1 0e+6144 -> -Infinity
+dqfma2606 fma -Inf 1000 0e+6144 -> -Infinity
+dqfma2607 fma -Inf Inf 0e+6144 -> -Infinity
+dqfma2608 fma -1000 Inf 0e+6144 -> -Infinity
+dqfma2609 fma -Inf -Inf 0e+6144 -> Infinity
+dqfma2610 fma -1 -Inf 0e+6144 -> Infinity
+dqfma2611 fma -0 -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2612 fma 0 -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2613 fma 1 -Inf 0e+6144 -> -Infinity
+dqfma2614 fma 1000 -Inf 0e+6144 -> -Infinity
+dqfma2615 fma Inf -Inf 0e+6144 -> -Infinity
+
+dqfma2621 fma NaN -Inf 0e+6144 -> NaN
+dqfma2622 fma NaN -1000 0e+6144 -> NaN
+dqfma2623 fma NaN -1 0e+6144 -> NaN
+dqfma2624 fma NaN -0 0e+6144 -> NaN
+dqfma2625 fma NaN 0 0e+6144 -> NaN
+dqfma2626 fma NaN 1 0e+6144 -> NaN
+dqfma2627 fma NaN 1000 0e+6144 -> NaN
+dqfma2628 fma NaN Inf 0e+6144 -> NaN
+dqfma2629 fma NaN NaN 0e+6144 -> NaN
+dqfma2630 fma -Inf NaN 0e+6144 -> NaN
+dqfma2631 fma -1000 NaN 0e+6144 -> NaN
+dqfma2632 fma -1 NaN 0e+6144 -> NaN
+dqfma2633 fma -0 NaN 0e+6144 -> NaN
+dqfma2634 fma 0 NaN 0e+6144 -> NaN
+dqfma2635 fma 1 NaN 0e+6144 -> NaN
+dqfma2636 fma 1000 NaN 0e+6144 -> NaN
+dqfma2637 fma Inf NaN 0e+6144 -> NaN
+
+dqfma2641 fma sNaN -Inf 0e+6144 -> NaN Invalid_operation
+dqfma2642 fma sNaN -1000 0e+6144 -> NaN Invalid_operation
+dqfma2643 fma sNaN -1 0e+6144 -> NaN Invalid_operation
+dqfma2644 fma sNaN -0 0e+6144 -> NaN Invalid_operation
+dqfma2645 fma sNaN 0 0e+6144 -> NaN Invalid_operation
+dqfma2646 fma sNaN 1 0e+6144 -> NaN Invalid_operation
+dqfma2647 fma sNaN 1000 0e+6144 -> NaN Invalid_operation
+dqfma2648 fma sNaN NaN 0e+6144 -> NaN Invalid_operation
+dqfma2649 fma sNaN sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2650 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2651 fma -Inf sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2652 fma -1000 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2653 fma -1 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2654 fma -0 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2655 fma 0 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2656 fma 1 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2657 fma 1000 sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2658 fma Inf sNaN 0e+6144 -> NaN Invalid_operation
+dqfma2659 fma NaN sNaN 0e+6144 -> NaN Invalid_operation
+
+-- propagating NaNs
+dqfma2661 fma NaN9 -Inf 0e+6144 -> NaN9
+dqfma2662 fma NaN8 999 0e+6144 -> NaN8
+dqfma2663 fma NaN71 Inf 0e+6144 -> NaN71
+dqfma2664 fma NaN6 NaN5 0e+6144 -> NaN6
+dqfma2665 fma -Inf NaN4 0e+6144 -> NaN4
+dqfma2666 fma -999 NaN33 0e+6144 -> NaN33
+dqfma2667 fma Inf NaN2 0e+6144 -> NaN2
+
+dqfma2671 fma sNaN99 -Inf 0e+6144 -> NaN99 Invalid_operation
+dqfma2672 fma sNaN98 -11 0e+6144 -> NaN98 Invalid_operation
+dqfma2673 fma sNaN97 NaN 0e+6144 -> NaN97 Invalid_operation
+dqfma2674 fma sNaN16 sNaN94 0e+6144 -> NaN16 Invalid_operation
+dqfma2675 fma NaN95 sNaN93 0e+6144 -> NaN93 Invalid_operation
+dqfma2676 fma -Inf sNaN92 0e+6144 -> NaN92 Invalid_operation
+dqfma2677 fma 088 sNaN91 0e+6144 -> NaN91 Invalid_operation
+dqfma2678 fma Inf sNaN90 0e+6144 -> NaN90 Invalid_operation
+dqfma2679 fma NaN sNaN89 0e+6144 -> NaN89 Invalid_operation
+
+dqfma2681 fma -NaN9 -Inf 0e+6144 -> -NaN9
+dqfma2682 fma -NaN8 999 0e+6144 -> -NaN8
+dqfma2683 fma -NaN71 Inf 0e+6144 -> -NaN71
+dqfma2684 fma -NaN6 -NaN5 0e+6144 -> -NaN6
+dqfma2685 fma -Inf -NaN4 0e+6144 -> -NaN4
+dqfma2686 fma -999 -NaN33 0e+6144 -> -NaN33
+dqfma2687 fma Inf -NaN2 0e+6144 -> -NaN2
+
+dqfma2691 fma -sNaN99 -Inf 0e+6144 -> -NaN99 Invalid_operation
+dqfma2692 fma -sNaN98 -11 0e+6144 -> -NaN98 Invalid_operation
+dqfma2693 fma -sNaN97 NaN 0e+6144 -> -NaN97 Invalid_operation
+dqfma2694 fma -sNaN16 -sNaN94 0e+6144 -> -NaN16 Invalid_operation
+dqfma2695 fma -NaN95 -sNaN93 0e+6144 -> -NaN93 Invalid_operation
+dqfma2696 fma -Inf -sNaN92 0e+6144 -> -NaN92 Invalid_operation
+dqfma2697 fma 088 -sNaN91 0e+6144 -> -NaN91 Invalid_operation
+dqfma2698 fma Inf -sNaN90 0e+6144 -> -NaN90 Invalid_operation
+dqfma2699 fma -NaN -sNaN89 0e+6144 -> -NaN89 Invalid_operation
+
+dqfma2701 fma -NaN -Inf 0e+6144 -> -NaN
+dqfma2702 fma -NaN 999 0e+6144 -> -NaN
+dqfma2703 fma -NaN Inf 0e+6144 -> -NaN
+dqfma2704 fma -NaN -NaN 0e+6144 -> -NaN
+dqfma2705 fma -Inf -NaN0 0e+6144 -> -NaN
+dqfma2706 fma -999 -NaN 0e+6144 -> -NaN
+dqfma2707 fma Inf -NaN 0e+6144 -> -NaN
+
+dqfma2711 fma -sNaN -Inf 0e+6144 -> -NaN Invalid_operation
+dqfma2712 fma -sNaN -11 0e+6144 -> -NaN Invalid_operation
+dqfma2713 fma -sNaN00 NaN 0e+6144 -> -NaN Invalid_operation
+dqfma2714 fma -sNaN -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2715 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2716 fma -Inf -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2717 fma 088 -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2718 fma Inf -sNaN 0e+6144 -> -NaN Invalid_operation
+dqfma2719 fma -NaN -sNaN 0e+6144 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqfma2751 fma 1e+4277 1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2752 fma 1e+4277 -1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
+dqfma2753 fma -1e+4277 1e+3311 0e+6144 -> -Infinity Overflow Inexact Rounded
+dqfma2754 fma -1e+4277 -1e+3311 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2755 fma 1e-4277 1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2756 fma 1e-4277 -1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2757 fma -1e-4277 1e-3311 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2758 fma -1e-4277 -1e-3311 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqfma2760 fma 1e-6069 1e-101 0e+6144 -> 1E-6170 Subnormal
+dqfma2761 fma 1e-6069 1e-102 0e+6144 -> 1E-6171 Subnormal
+dqfma2762 fma 1e-6069 1e-103 0e+6144 -> 1E-6172 Subnormal
+dqfma2763 fma 1e-6069 1e-104 0e+6144 -> 1E-6173 Subnormal
+dqfma2764 fma 1e-6069 1e-105 0e+6144 -> 1E-6174 Subnormal
+dqfma2765 fma 1e-6069 1e-106 0e+6144 -> 1E-6175 Subnormal
+dqfma2766 fma 1e-6069 1e-107 0e+6144 -> 1E-6176 Subnormal
+dqfma2767 fma 1e-6069 1e-108 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2768 fma 1e-6069 1e-109 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2769 fma 1e-6069 1e-110 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqfma2770 fma 1e+40 1e+6101 0e+6144 -> 1.000000000000000000000000000000E+6141 Clamped
+dqfma2771 fma 1e+40 1e+6102 0e+6144 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqfma2772 fma 1e+40 1e+6103 0e+6144 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqfma2773 fma 1e+40 1e+6104 0e+6144 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqfma2774 fma 1e+40 1e+6105 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2775 fma 1e+40 1e+6106 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2776 fma 1e+40 1e+6107 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2777 fma 1e+40 1e+6108 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2778 fma 1e+40 1e+6109 0e+6144 -> Infinity Overflow Inexact Rounded
+dqfma2779 fma 1e+40 1e+6110 0e+6144 -> Infinity Overflow Inexact Rounded
+
+dqfma2801 fma 1.0000E-6172 1 0e+6144 -> 1.0000E-6172 Subnormal
+dqfma2802 fma 1.000E-6172 1e-1 0e+6144 -> 1.000E-6173 Subnormal
+dqfma2803 fma 1.00E-6172 1e-2 0e+6144 -> 1.00E-6174 Subnormal
+dqfma2804 fma 1.0E-6172 1e-3 0e+6144 -> 1.0E-6175 Subnormal
+dqfma2805 fma 1.0E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal Rounded
+dqfma2806 fma 1.3E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2807 fma 1.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2808 fma 1.7E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2809 fma 2.3E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2810 fma 2.5E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2811 fma 2.7E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqfma2812 fma 1.49E-6172 1e-4 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2813 fma 1.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2814 fma 1.51E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2815 fma 2.49E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2816 fma 2.50E-6172 1e-4 0e+6144 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqfma2817 fma 2.51E-6172 1e-4 0e+6144 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqfma2818 fma 1E-6172 1e-4 0e+6144 -> 1E-6176 Subnormal
+dqfma2819 fma 3E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2820 fma 5E-6172 1e-5 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2821 fma 7E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2822 fma 9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2823 fma 9.9E-6172 1e-5 0e+6144 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqfma2824 fma 1E-6172 -1e-4 0e+6144 -> -1E-6176 Subnormal
+dqfma2825 fma 3E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2826 fma -5E-6172 1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2827 fma 7E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2828 fma -9E-6172 1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2829 fma 9.9E-6172 -1e-5 0e+6144 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqfma2830 fma 3.0E-6172 -1e-5 0e+6144 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqfma2831 fma 1.0E-5977 1e-200 0e+6144 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqfma2832 fma 1.0E-5977 1e-199 0e+6144 -> 1E-6176 Subnormal Rounded
+dqfma2833 fma 1.0E-5977 1e-198 0e+6144 -> 1.0E-6175 Subnormal
+dqfma2834 fma 2.0E-5977 2e-198 0e+6144 -> 4.0E-6175 Subnormal
+dqfma2835 fma 4.0E-5977 4e-198 0e+6144 -> 1.60E-6174 Subnormal
+dqfma2836 fma 10.0E-5977 10e-198 0e+6144 -> 1.000E-6173 Subnormal
+dqfma2837 fma 30.0E-5977 30e-198 0e+6144 -> 9.000E-6173 Subnormal
+dqfma2838 fma 40.0E-5982 40e-166 0e+6144 -> 1.6000E-6145 Subnormal
+dqfma2839 fma 40.0E-5982 40e-165 0e+6144 -> 1.6000E-6144 Subnormal
+dqfma2840 fma 40.0E-5982 40e-164 0e+6144 -> 1.6000E-6143
+
+-- Long operand overflow may be a different path
+dqfma2870 fma 100 9.999E+6143 0e+6144 -> Infinity Inexact Overflow Rounded
+dqfma2871 fma 100 -9.999E+6143 0e+6144 -> -Infinity Inexact Overflow Rounded
+dqfma2872 fma 9.999E+6143 100 0e+6144 -> Infinity Inexact Overflow Rounded
+dqfma2873 fma -9.999E+6143 100 0e+6144 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+dqfma2881 fma 1.2347E-6133 1.2347E-40 0e+6144 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
+dqfma2882 fma 1.234E-6133 1.234E-40 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2883 fma 1.23E-6133 1.23E-40 0e+6144 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
+dqfma2884 fma 1.2E-6133 1.2E-40 0e+6144 -> 1.44E-6173 Subnormal
+dqfma2885 fma 1.2E-6133 1.2E-41 0e+6144 -> 1.44E-6174 Subnormal
+dqfma2886 fma 1.2E-6133 1.2E-42 0e+6144 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
+dqfma2887 fma 1.2E-6133 1.3E-42 0e+6144 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
+dqfma2888 fma 1.3E-6133 1.3E-42 0e+6144 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
+dqfma2889 fma 1.3E-6133 1.3E-43 0e+6144 -> 2E-6176 Subnormal Inexact Rounded Underflow
+dqfma2890 fma 1.3E-6134 1.3E-43 0e+6144 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
+
+dqfma2891 fma 1.2345E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqfma2892 fma 1.23456E-39 1.234E-6133 0e+6144 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqfma2893 fma 1.2345E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2894 fma 1.23456E-40 1.234E-6133 0e+6144 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqfma2895 fma 1.2345E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+dqfma2896 fma 1.23456E-41 1.234E-6133 0e+6144 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- prove operands are exact
+dqfma2906 fma 9.999999999999999999999999999999999E-6143 1 0e+6144 -> 9.999999999999999999999999999999999E-6143
+dqfma2907 fma 1 0.09999999999999999999999999999999999 0e+6144 -> 0.09999999999999999999999999999999999
+-- the next rounds to Nmin
+dqfma2908 fma 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 0e+6144 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
+
+-- hugest
+dqfma2909 fma 9999999999999999999999999999999999 9999999999999999999999999999999999 0e+6144 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+dqfma21001 fma 130E-2 120E-2 0e+6144 -> 1.5600
+dqfma21002 fma 130E-2 12E-1 0e+6144 -> 1.560
+dqfma21003 fma 130E-2 1E0 0e+6144 -> 1.30
+dqfma21004 fma 1E2 1E4 0e+6144 -> 1E+6
+
+-- Null tests
+dqfma2990 fma 10 # 0e+6144 -> NaN Invalid_operation
+dqfma2991 fma # 10 0e+6144 -> NaN Invalid_operation
+
+
+-- ADDITION TESTS ------------------------------------------------------
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqadd3001 fma 1 1 1 -> 2
+dqadd3002 fma 1 2 3 -> 5
+dqadd3003 fma 1 '5.75' '3.3' -> 9.05
+dqadd3004 fma 1 '5' '-3' -> 2
+dqadd3005 fma 1 '-5' '-3' -> -8
+dqadd3006 fma 1 '-7' '2.5' -> -4.5
+dqadd3007 fma 1 '0.7' '0.3' -> 1.0
+dqadd3008 fma 1 '1.25' '1.25' -> 2.50
+dqadd3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+dqadd3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+-- 1234567890123456 1234567890123456
+dqadd3011 fma 1 '0.4444444444444444444444444444444446' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqadd3012 fma 1 '0.4444444444444444444444444444444445' '0.5555555555555555555555555555555555' -> '1.000000000000000000000000000000000' Rounded
+dqadd3013 fma 1 '0.4444444444444444444444444444444444' '0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqadd3014 fma 1 '4444444444444444444444444444444444' '0.49' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3015 fma 1 '4444444444444444444444444444444444' '0.499' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3016 fma 1 '4444444444444444444444444444444444' '0.4999' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3017 fma 1 '4444444444444444444444444444444444' '0.5000' -> '4444444444444444444444444444444444' Inexact Rounded
+dqadd3018 fma 1 '4444444444444444444444444444444444' '0.5001' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd3019 fma 1 '4444444444444444444444444444444444' '0.501' -> '4444444444444444444444444444444445' Inexact Rounded
+dqadd3020 fma 1 '4444444444444444444444444444444444' '0.51' -> '4444444444444444444444444444444445' Inexact Rounded
+
+dqadd3021 fma 1 0 1 -> 1
+dqadd3022 fma 1 1 1 -> 2
+dqadd3023 fma 1 2 1 -> 3
+dqadd3024 fma 1 3 1 -> 4
+dqadd3025 fma 1 4 1 -> 5
+dqadd3026 fma 1 5 1 -> 6
+dqadd3027 fma 1 6 1 -> 7
+dqadd3028 fma 1 7 1 -> 8
+dqadd3029 fma 1 8 1 -> 9
+dqadd3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+dqadd3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+dqadd3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+dqadd3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+dqadd3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+dqadd3035 fma 1 '70' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3036 fma 1 '700' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3037 fma 1 '7000' '10000e+34' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3038 fma 1 '70000' '10000e+34' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd3039 fma 1 '700000' '10000e+34' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- symmetry:
+dqadd3040 fma 1 '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3041 fma 1 '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3042 fma 1 '10000e+34' '7000' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqadd3044 fma 1 '10000e+34' '70000' -> '1.000000000000000000000000000000001E+38' Inexact Rounded
+dqadd3045 fma 1 '10000e+34' '700000' -> '1.000000000000000000000000000000007E+38' Rounded
+
+-- same, without rounding
+dqadd3046 fma 1 '10000e+9' '7' -> '10000000000007'
+dqadd3047 fma 1 '10000e+9' '70' -> '10000000000070'
+dqadd3048 fma 1 '10000e+9' '700' -> '10000000000700'
+dqadd3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+dqadd3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+dqadd3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+dqadd3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+dqadd3053 fma 1 '12' '7.00' -> '19.00'
+dqadd3054 fma 1 '1.3' '-1.07' -> '0.23'
+dqadd3055 fma 1 '1.3' '-1.30' -> '0.00'
+dqadd3056 fma 1 '1.3' '-2.07' -> '-0.77'
+dqadd3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- leading zero preservation
+dqadd3061 fma 1 1 '0.0001' -> '1.0001'
+dqadd3062 fma 1 1 '0.00001' -> '1.00001'
+dqadd3063 fma 1 1 '0.000001' -> '1.000001'
+dqadd3064 fma 1 1 '0.0000001' -> '1.0000001'
+dqadd3065 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+dqadd3070 fma 1 1 0 -> 1
+dqadd3071 fma 1 1 0. -> 1
+dqadd3072 fma 1 1 .0 -> 1.0
+dqadd3073 fma 1 1 0.0 -> 1.0
+dqadd3074 fma 1 1 0.00 -> 1.00
+dqadd3075 fma 1 0 1 -> 1
+dqadd3076 fma 1 0. 1 -> 1
+dqadd3077 fma 1 .0 1 -> 1.0
+dqadd3078 fma 1 0.0 1 -> 1.0
+dqadd3079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+dqadd3080 fma 1 999999998 1 -> 999999999
+dqadd3081 fma 1 999999999 1 -> 1000000000
+dqadd3082 fma 1 99999999 1 -> 100000000
+dqadd3083 fma 1 9999999 1 -> 10000000
+dqadd3084 fma 1 999999 1 -> 1000000
+dqadd3085 fma 1 99999 1 -> 100000
+dqadd3086 fma 1 9999 1 -> 10000
+dqadd3087 fma 1 999 1 -> 1000
+dqadd3088 fma 1 99 1 -> 100
+dqadd3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+dqadd3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+dqadd3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+dqadd3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+dqadd3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+dqadd3094 fma 1 '-56267E-3' 0 -> '-56.267'
+dqadd3095 fma 1 '-56267E-2' 0 -> '-562.67'
+dqadd3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+dqadd3097 fma 1 '-56267E-0' 0 -> '-56267'
+dqadd3098 fma 1 '-5E-10' 0 -> '-5E-10'
+dqadd3099 fma 1 '-5E-7' 0 -> '-5E-7'
+dqadd3100 fma 1 '-5E-6' 0 -> '-0.000005'
+dqadd3101 fma 1 '-5E-5' 0 -> '-0.00005'
+dqadd3102 fma 1 '-5E-4' 0 -> '-0.0005'
+dqadd3103 fma 1 '-5E-1' 0 -> '-0.5'
+dqadd3104 fma 1 '-5E0' 0 -> '-5'
+dqadd3105 fma 1 '-5E1' 0 -> '-50'
+dqadd3106 fma 1 '-5E5' 0 -> '-500000'
+dqadd3107 fma 1 '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqadd3108 fma 1 '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd3109 fma 1 '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd3110 fma 1 '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd3111 fma 1 '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps
+dqadd3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+dqadd3114 fma 1 0 '-56267E-6' -> '-0.056267'
+dqadd3116 fma 1 0 '-56267E-5' -> '-0.56267'
+dqadd3117 fma 1 0 '-56267E-4' -> '-5.6267'
+dqadd3119 fma 1 0 '-56267E-3' -> '-56.267'
+dqadd3120 fma 1 0 '-56267E-2' -> '-562.67'
+dqadd3121 fma 1 0 '-56267E-1' -> '-5626.7'
+dqadd3122 fma 1 0 '-56267E-0' -> '-56267'
+dqadd3123 fma 1 0 '-5E-10' -> '-5E-10'
+dqadd3124 fma 1 0 '-5E-7' -> '-5E-7'
+dqadd3125 fma 1 0 '-5E-6' -> '-0.000005'
+dqadd3126 fma 1 0 '-5E-5' -> '-0.00005'
+dqadd3127 fma 1 0 '-5E-4' -> '-0.0005'
+dqadd3128 fma 1 0 '-5E-1' -> '-0.5'
+dqadd3129 fma 1 0 '-5E0' -> '-5'
+dqadd3130 fma 1 0 '-5E1' -> '-50'
+dqadd3131 fma 1 0 '-5E5' -> '-500000'
+dqadd3132 fma 1 0 '-5E33' -> '-5000000000000000000000000000000000'
+dqadd3133 fma 1 0 '-5E34' -> '-5.000000000000000000000000000000000E+34' Rounded
+dqadd3134 fma 1 0 '-5E35' -> '-5.000000000000000000000000000000000E+35' Rounded
+dqadd3135 fma 1 0 '-5E36' -> '-5.000000000000000000000000000000000E+36' Rounded
+dqadd3136 fma 1 0 '-5E100' -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- related
+dqadd3137 fma 1 1 '0E-39' -> '1.000000000000000000000000000000000' Rounded
+dqadd3138 fma 1 -1 '0E-39' -> '-1.000000000000000000000000000000000' Rounded
+dqadd3139 fma 1 '0E-39' 1 -> '1.000000000000000000000000000000000' Rounded
+dqadd3140 fma 1 '0E-39' -1 -> '-1.000000000000000000000000000000000' Rounded
+dqadd3141 fma 1 1E+29 0.0000 -> '100000000000000000000000000000.0000'
+dqadd3142 fma 1 1E+29 0.00000 -> '100000000000000000000000000000.0000' Rounded
+dqadd3143 fma 1 0.000 1E+30 -> '1000000000000000000000000000000.000'
+dqadd3144 fma 1 0.0000 1E+30 -> '1000000000000000000000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+dqadd3146 fma 1 '00.0' 0 -> '0.0'
+dqadd3147 fma 1 '0.00' 0 -> '0.00'
+dqadd3148 fma 1 0 '0.00' -> '0.00'
+dqadd3149 fma 1 0 '00.0' -> '0.0'
+dqadd3150 fma 1 '00.0' '0.00' -> '0.00'
+dqadd3151 fma 1 '0.00' '00.0' -> '0.00'
+dqadd3152 fma 1 '3' '.3' -> '3.3'
+dqadd3153 fma 1 '3.' '.3' -> '3.3'
+dqadd3154 fma 1 '3.0' '.3' -> '3.3'
+dqadd3155 fma 1 '3.00' '.3' -> '3.30'
+dqadd3156 fma 1 '3' '3' -> '6'
+dqadd3157 fma 1 '3' '+3' -> '6'
+dqadd3158 fma 1 '3' '-3' -> '0'
+dqadd3159 fma 1 '0.3' '-0.3' -> '0.0'
+dqadd3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+dqadd3161 fma 1 '1E+12' '-1' -> '999999999999'
+dqadd3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+dqadd3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+dqadd3164 fma 1 '-1' '1E+12' -> '999999999999'
+dqadd3165 fma 1 '7E+12' '-1' -> '6999999999999'
+dqadd3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+dqadd3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+dqadd3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+rounding: half_up
+dqadd3170 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555567' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3171 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555566' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3172 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555565' -> '5.000000000000000000000000000000001' Inexact Rounded
+dqadd3173 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555564' -> '5.000000000000000000000000000000000' Inexact Rounded
+dqadd3174 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555553' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3175 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555552' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3176 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555551' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3177 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555550' -> '4.999999999999999999999999999999999' Rounded
+dqadd3178 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555545' -> '4.999999999999999999999999999999999' Inexact Rounded
+dqadd3179 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555544' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3180 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555543' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3181 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555542' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3182 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555541' -> '4.999999999999999999999999999999998' Inexact Rounded
+dqadd3183 fma 1 '4.444444444444444444444444444444444' '0.5555555555555555555555555555555540' -> '4.999999999999999999999999999999998' Rounded
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqadd3200 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3201 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3202 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3203 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3204 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3205 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3206 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3207 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3208 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3209 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3210 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3211 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3212 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3213 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3214 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3215 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3216 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3217 fma 1 '1231234567890123456784560123456789' 1.000000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3218 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3219 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+rounding: half_even
+dqadd3220 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3221 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3222 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3223 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3224 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3225 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3226 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3227 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3228 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3229 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3230 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3231 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3232 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3233 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3234 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3235 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3236 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3237 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3238 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3239 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+-- critical few with even bottom digit...
+dqadd3240 fma 1 '1231234567890123456784560123456788' 0.499999999 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd3241 fma 1 '1231234567890123456784560123456788' 0.5 -> '1231234567890123456784560123456788' Inexact Rounded
+dqadd3242 fma 1 '1231234567890123456784560123456788' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+
+rounding: down
+dqadd3250 fma 1 '1231234567890123456784560123456789' 0 -> '1231234567890123456784560123456789'
+dqadd3251 fma 1 '1231234567890123456784560123456789' 0.000000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3252 fma 1 '1231234567890123456784560123456789' 0.000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3253 fma 1 '1231234567890123456784560123456789' 0.1 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3254 fma 1 '1231234567890123456784560123456789' 0.4 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3255 fma 1 '1231234567890123456784560123456789' 0.49 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3256 fma 1 '1231234567890123456784560123456789' 0.499999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3257 fma 1 '1231234567890123456784560123456789' 0.499999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3258 fma 1 '1231234567890123456784560123456789' 0.5 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3259 fma 1 '1231234567890123456784560123456789' 0.500000001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3260 fma 1 '1231234567890123456784560123456789' 0.500001 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3261 fma 1 '1231234567890123456784560123456789' 0.51 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3262 fma 1 '1231234567890123456784560123456789' 0.6 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3263 fma 1 '1231234567890123456784560123456789' 0.9 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3264 fma 1 '1231234567890123456784560123456789' 0.99999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3265 fma 1 '1231234567890123456784560123456789' 0.999999999 -> '1231234567890123456784560123456789' Inexact Rounded
+dqadd3266 fma 1 '1231234567890123456784560123456789' 1 -> '1231234567890123456784560123456790'
+dqadd3267 fma 1 '1231234567890123456784560123456789' 1.00000001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3268 fma 1 '1231234567890123456784560123456789' 1.00001 -> '1231234567890123456784560123456790' Inexact Rounded
+dqadd3269 fma 1 '1231234567890123456784560123456789' 1.1 -> '1231234567890123456784560123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+dqadd3301 fma 1 -1 1 -> 0
+dqadd3302 fma 1 0 1 -> 1
+dqadd3303 fma 1 1 1 -> 2
+dqadd3304 fma 1 12 1 -> 13
+dqadd3305 fma 1 98 1 -> 99
+dqadd3306 fma 1 99 1 -> 100
+dqadd3307 fma 1 100 1 -> 101
+dqadd3308 fma 1 101 1 -> 102
+dqadd3309 fma 1 -1 -1 -> -2
+dqadd3310 fma 1 0 -1 -> -1
+dqadd3311 fma 1 1 -1 -> 0
+dqadd3312 fma 1 12 -1 -> 11
+dqadd3313 fma 1 98 -1 -> 97
+dqadd3314 fma 1 99 -1 -> 98
+dqadd3315 fma 1 100 -1 -> 99
+dqadd3316 fma 1 101 -1 -> 100
+
+dqadd3321 fma 1 -0.01 0.01 -> 0.00
+dqadd3322 fma 1 0.00 0.01 -> 0.01
+dqadd3323 fma 1 0.01 0.01 -> 0.02
+dqadd3324 fma 1 0.12 0.01 -> 0.13
+dqadd3325 fma 1 0.98 0.01 -> 0.99
+dqadd3326 fma 1 0.99 0.01 -> 1.00
+dqadd3327 fma 1 1.00 0.01 -> 1.01
+dqadd3328 fma 1 1.01 0.01 -> 1.02
+dqadd3329 fma 1 -0.01 -0.01 -> -0.02
+dqadd3330 fma 1 0.00 -0.01 -> -0.01
+dqadd3331 fma 1 0.01 -0.01 -> 0.00
+dqadd3332 fma 1 0.12 -0.01 -> 0.11
+dqadd3333 fma 1 0.98 -0.01 -> 0.97
+dqadd3334 fma 1 0.99 -0.01 -> 0.98
+dqadd3335 fma 1 1.00 -0.01 -> 0.99
+dqadd3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where adding 0 affects the coefficient
+dqadd3340 fma 1 1E+3 0 -> 1000
+dqadd3341 fma 1 1E+33 0 -> 1000000000000000000000000000000000
+dqadd3342 fma 1 1E+34 0 -> 1.000000000000000000000000000000000E+34 Rounded
+dqadd3343 fma 1 1E+35 0 -> 1.000000000000000000000000000000000E+35 Rounded
+-- which simply follow from these cases ...
+dqadd3344 fma 1 1E+3 1 -> 1001
+dqadd3345 fma 1 1E+33 1 -> 1000000000000000000000000000000001
+dqadd3346 fma 1 1E+34 1 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd3347 fma 1 1E+35 1 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+dqadd3348 fma 1 1E+3 7 -> 1007
+dqadd3349 fma 1 1E+33 7 -> 1000000000000000000000000000000007
+dqadd3350 fma 1 1E+34 7 -> 1.000000000000000000000000000000001E+34 Inexact Rounded
+dqadd3351 fma 1 1E+35 7 -> 1.000000000000000000000000000000000E+35 Inexact Rounded
+
+-- tryzeros cases
+rounding: half_up
+dqadd3360 fma 1 0E+50 10000E+1 -> 1.0000E+5
+dqadd3361 fma 1 0E-50 10000E+1 -> 100000.0000000000000000000000000000 Rounded
+dqadd3362 fma 1 10000E+1 0E-50 -> 100000.0000000000000000000000000000 Rounded
+dqadd3363 fma 1 10000E+1 10000E-50 -> 100000.0000000000000000000000000000 Rounded Inexact
+dqadd3364 fma 1 9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> 0E+6111
+-- 1 234567890123456789012345678901234
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+dqadd3370 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3371 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_up
+dqadd3372 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3373 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+rounding: half_even
+dqadd3374 fma 1 999999999999999999999999999999999 815 -> 1000000000000000000000000000000814
+dqadd3375 fma 1 9999999999999999999999999999999999 815 -> 1.000000000000000000000000000000081E+34 Rounded Inexact
+
+-- ulp replacement tests
+dqadd3400 fma 1 1 77e-32 -> 1.00000000000000000000000000000077
+dqadd3401 fma 1 1 77e-33 -> 1.000000000000000000000000000000077
+dqadd3402 fma 1 1 77e-34 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd3403 fma 1 1 77e-35 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd3404 fma 1 1 77e-36 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3405 fma 1 1 77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3406 fma 1 1 77e-299 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd3410 fma 1 10 77e-32 -> 10.00000000000000000000000000000077
+dqadd3411 fma 1 10 77e-33 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd3412 fma 1 10 77e-34 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd3413 fma 1 10 77e-35 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3414 fma 1 10 77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3415 fma 1 10 77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3416 fma 1 10 77e-299 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd3420 fma 1 77e-32 1 -> 1.00000000000000000000000000000077
+dqadd3421 fma 1 77e-33 1 -> 1.000000000000000000000000000000077
+dqadd3422 fma 1 77e-34 1 -> 1.000000000000000000000000000000008 Inexact Rounded
+dqadd3423 fma 1 77e-35 1 -> 1.000000000000000000000000000000001 Inexact Rounded
+dqadd3424 fma 1 77e-36 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3425 fma 1 77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd3426 fma 1 77e-299 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd3430 fma 1 77e-32 10 -> 10.00000000000000000000000000000077
+dqadd3431 fma 1 77e-33 10 -> 10.00000000000000000000000000000008 Inexact Rounded
+dqadd3432 fma 1 77e-34 10 -> 10.00000000000000000000000000000001 Inexact Rounded
+dqadd3433 fma 1 77e-35 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3434 fma 1 77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3435 fma 1 77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd3436 fma 1 77e-299 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd36440 fma 1 1 -77e-32 -> 0.99999999999999999999999999999923
+dqadd36441 fma 1 1 -77e-33 -> 0.999999999999999999999999999999923
+dqadd36442 fma 1 1 -77e-34 -> 0.9999999999999999999999999999999923
+dqadd36443 fma 1 1 -77e-35 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36444 fma 1 1 -77e-36 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36445 fma 1 1 -77e-37 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd36446 fma 1 1 -77e-99 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36450 fma 1 10 -77e-32 -> 9.99999999999999999999999999999923
+dqadd36451 fma 1 10 -77e-33 -> 9.999999999999999999999999999999923
+dqadd36452 fma 1 10 -77e-34 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd36453 fma 1 10 -77e-35 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd36454 fma 1 10 -77e-36 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36455 fma 1 10 -77e-37 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36456 fma 1 10 -77e-99 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd36460 fma 1 -77e-32 1 -> 0.99999999999999999999999999999923
+dqadd36461 fma 1 -77e-33 1 -> 0.999999999999999999999999999999923
+dqadd36462 fma 1 -77e-34 1 -> 0.9999999999999999999999999999999923
+dqadd36463 fma 1 -77e-35 1 -> 0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36464 fma 1 -77e-36 1 -> 0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36465 fma 1 -77e-37 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+dqadd36466 fma 1 -77e-99 1 -> 1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36470 fma 1 -77e-32 10 -> 9.99999999999999999999999999999923
+dqadd36471 fma 1 -77e-33 10 -> 9.999999999999999999999999999999923
+dqadd36472 fma 1 -77e-34 10 -> 9.999999999999999999999999999999992 Inexact Rounded
+dqadd36473 fma 1 -77e-35 10 -> 9.999999999999999999999999999999999 Inexact Rounded
+dqadd36474 fma 1 -77e-36 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36475 fma 1 -77e-37 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+dqadd36476 fma 1 -77e-99 10 -> 10.00000000000000000000000000000000 Inexact Rounded
+
+-- negative ulps
+dqadd36480 fma 1 -1 77e-32 -> -0.99999999999999999999999999999923
+dqadd36481 fma 1 -1 77e-33 -> -0.999999999999999999999999999999923
+dqadd36482 fma 1 -1 77e-34 -> -0.9999999999999999999999999999999923
+dqadd36483 fma 1 -1 77e-35 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36484 fma 1 -1 77e-36 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36485 fma 1 -1 77e-37 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd36486 fma 1 -1 77e-99 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36490 fma 1 -10 77e-32 -> -9.99999999999999999999999999999923
+dqadd36491 fma 1 -10 77e-33 -> -9.999999999999999999999999999999923
+dqadd36492 fma 1 -10 77e-34 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd36493 fma 1 -10 77e-35 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd36494 fma 1 -10 77e-36 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36495 fma 1 -10 77e-37 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36496 fma 1 -10 77e-99 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+dqadd36500 fma 1 77e-32 -1 -> -0.99999999999999999999999999999923
+dqadd36501 fma 1 77e-33 -1 -> -0.999999999999999999999999999999923
+dqadd36502 fma 1 77e-34 -1 -> -0.9999999999999999999999999999999923
+dqadd36503 fma 1 77e-35 -1 -> -0.9999999999999999999999999999999992 Inexact Rounded
+dqadd36504 fma 1 77e-36 -1 -> -0.9999999999999999999999999999999999 Inexact Rounded
+dqadd36505 fma 1 77e-37 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+dqadd36506 fma 1 77e-99 -1 -> -1.000000000000000000000000000000000 Inexact Rounded
+
+dqadd36510 fma 1 77e-32 -10 -> -9.99999999999999999999999999999923
+dqadd36511 fma 1 77e-33 -10 -> -9.999999999999999999999999999999923
+dqadd36512 fma 1 77e-34 -10 -> -9.999999999999999999999999999999992 Inexact Rounded
+dqadd36513 fma 1 77e-35 -10 -> -9.999999999999999999999999999999999 Inexact Rounded
+dqadd36514 fma 1 77e-36 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36515 fma 1 77e-37 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+dqadd36516 fma 1 77e-99 -10 -> -10.00000000000000000000000000000000 Inexact Rounded
+
+-- and some more residue effects and different roundings
+rounding: half_up
+dqadd36540 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd36541 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36542 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36543 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36544 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36545 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36546 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36547 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36548 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36549 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36550 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36551 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36552 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36553 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36554 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36555 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36556 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd36557 fma 1 '9876543219876543216543210123456789' 1.000000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36558 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36559 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+rounding: half_even
+dqadd36560 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd36561 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36562 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36563 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36564 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36565 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36566 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36567 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd36568 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36569 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36570 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36571 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36572 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36573 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36574 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36575 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36576 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd36577 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36578 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd36579 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- critical few with even bottom digit...
+dqadd37540 fma 1 '9876543219876543216543210123456788' 0.499999999 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd37541 fma 1 '9876543219876543216543210123456788' 0.5 -> '9876543219876543216543210123456788' Inexact Rounded
+dqadd37542 fma 1 '9876543219876543216543210123456788' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+
+rounding: down
+dqadd37550 fma 1 '9876543219876543216543210123456789' 0 -> '9876543219876543216543210123456789'
+dqadd37551 fma 1 '9876543219876543216543210123456789' 0.000000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37552 fma 1 '9876543219876543216543210123456789' 0.000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37553 fma 1 '9876543219876543216543210123456789' 0.1 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37554 fma 1 '9876543219876543216543210123456789' 0.4 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37555 fma 1 '9876543219876543216543210123456789' 0.49 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37556 fma 1 '9876543219876543216543210123456789' 0.499999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37557 fma 1 '9876543219876543216543210123456789' 0.499999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37558 fma 1 '9876543219876543216543210123456789' 0.5 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37559 fma 1 '9876543219876543216543210123456789' 0.500000001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37560 fma 1 '9876543219876543216543210123456789' 0.500001 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37561 fma 1 '9876543219876543216543210123456789' 0.51 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37562 fma 1 '9876543219876543216543210123456789' 0.6 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37563 fma 1 '9876543219876543216543210123456789' 0.9 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37564 fma 1 '9876543219876543216543210123456789' 0.99999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37565 fma 1 '9876543219876543216543210123456789' 0.999999999 -> '9876543219876543216543210123456789' Inexact Rounded
+dqadd37566 fma 1 '9876543219876543216543210123456789' 1 -> '9876543219876543216543210123456790'
+dqadd37567 fma 1 '9876543219876543216543210123456789' 1.00000001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd37568 fma 1 '9876543219876543216543210123456789' 1.00001 -> '9876543219876543216543210123456790' Inexact Rounded
+dqadd37569 fma 1 '9876543219876543216543210123456789' 1.1 -> '9876543219876543216543210123456790' Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+dqadd37701 fma 1 5.00 1.00E-3 -> 5.00100
+dqadd37702 fma 1 00.00 0.000 -> 0.000
+dqadd37703 fma 1 00.00 0E-3 -> 0.000
+dqadd37704 fma 1 0E-3 00.00 -> 0.000
+
+dqadd37710 fma 1 0E+3 00.00 -> 0.00
+dqadd37711 fma 1 0E+3 00.0 -> 0.0
+dqadd37712 fma 1 0E+3 00. -> 0
+dqadd37713 fma 1 0E+3 00.E+1 -> 0E+1
+dqadd37714 fma 1 0E+3 00.E+2 -> 0E+2
+dqadd37715 fma 1 0E+3 00.E+3 -> 0E+3
+dqadd37716 fma 1 0E+3 00.E+4 -> 0E+3
+dqadd37717 fma 1 0E+3 00.E+5 -> 0E+3
+dqadd37718 fma 1 0E+3 -00.0 -> 0.0
+dqadd37719 fma 1 0E+3 -00. -> 0
+dqadd37731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+dqadd37720 fma 1 00.00 0E+3 -> 0.00
+dqadd37721 fma 1 00.0 0E+3 -> 0.0
+dqadd37722 fma 1 00. 0E+3 -> 0
+dqadd37723 fma 1 00.E+1 0E+3 -> 0E+1
+dqadd37724 fma 1 00.E+2 0E+3 -> 0E+2
+dqadd37725 fma 1 00.E+3 0E+3 -> 0E+3
+dqadd37726 fma 1 00.E+4 0E+3 -> 0E+3
+dqadd37727 fma 1 00.E+5 0E+3 -> 0E+3
+dqadd37728 fma 1 -00.00 0E+3 -> 0.00
+dqadd37729 fma 1 -00.0 0E+3 -> 0.0
+dqadd37730 fma 1 -00. 0E+3 -> 0
+
+dqadd37732 fma 1 0 0 -> 0
+dqadd37733 fma 1 0 -0 -> 0
+dqadd37734 fma 1 -0 0 -> 0
+dqadd37735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+dqadd37736 fma 1 1 -1 -> 0
+dqadd37737 fma 1 -1 -1 -> -2
+dqadd37738 fma 1 1 1 -> 2
+dqadd37739 fma 1 -1 1 -> 0
+
+dqadd37741 fma 1 0 -1 -> -1
+dqadd37742 fma 1 -0 -1 -> -1
+dqadd37743 fma 1 0 1 -> 1
+dqadd37744 fma 1 -0 1 -> 1
+dqadd37745 fma 1 -1 0 -> -1
+dqadd37746 fma 1 -1 -0 -> -1
+dqadd37747 fma 1 1 0 -> 1
+dqadd37748 fma 1 1 -0 -> 1
+
+dqadd37751 fma 1 0.0 -1 -> -1.0
+dqadd37752 fma 1 -0.0 -1 -> -1.0
+dqadd37753 fma 1 0.0 1 -> 1.0
+dqadd37754 fma 1 -0.0 1 -> 1.0
+dqadd37755 fma 1 -1.0 0 -> -1.0
+dqadd37756 fma 1 -1.0 -0 -> -1.0
+dqadd37757 fma 1 1.0 0 -> 1.0
+dqadd37758 fma 1 1.0 -0 -> 1.0
+
+dqadd37761 fma 1 0 -1.0 -> -1.0
+dqadd37762 fma 1 -0 -1.0 -> -1.0
+dqadd37763 fma 1 0 1.0 -> 1.0
+dqadd37764 fma 1 -0 1.0 -> 1.0
+dqadd37765 fma 1 -1 0.0 -> -1.0
+dqadd37766 fma 1 -1 -0.0 -> -1.0
+dqadd37767 fma 1 1 0.0 -> 1.0
+dqadd37768 fma 1 1 -0.0 -> 1.0
+
+dqadd37771 fma 1 0.0 -1.0 -> -1.0
+dqadd37772 fma 1 -0.0 -1.0 -> -1.0
+dqadd37773 fma 1 0.0 1.0 -> 1.0
+dqadd37774 fma 1 -0.0 1.0 -> 1.0
+dqadd37775 fma 1 -1.0 0.0 -> -1.0
+dqadd37776 fma 1 -1.0 -0.0 -> -1.0
+dqadd37777 fma 1 1.0 0.0 -> 1.0
+dqadd37778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+dqadd37780 fma 1 -Inf -Inf -> -Infinity
+dqadd37781 fma 1 -Inf -1000 -> -Infinity
+dqadd37782 fma 1 -Inf -1 -> -Infinity
+dqadd37783 fma 1 -Inf -0 -> -Infinity
+dqadd37784 fma 1 -Inf 0 -> -Infinity
+dqadd37785 fma 1 -Inf 1 -> -Infinity
+dqadd37786 fma 1 -Inf 1000 -> -Infinity
+dqadd37787 fma 1 -1000 -Inf -> -Infinity
+dqadd37788 fma 1 -Inf -Inf -> -Infinity
+dqadd37789 fma 1 -1 -Inf -> -Infinity
+dqadd37790 fma 1 -0 -Inf -> -Infinity
+dqadd37791 fma 1 0 -Inf -> -Infinity
+dqadd37792 fma 1 1 -Inf -> -Infinity
+dqadd37793 fma 1 1000 -Inf -> -Infinity
+dqadd37794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+dqadd37800 fma 1 Inf -Inf -> NaN Invalid_operation
+dqadd37801 fma 1 Inf -1000 -> Infinity
+dqadd37802 fma 1 Inf -1 -> Infinity
+dqadd37803 fma 1 Inf -0 -> Infinity
+dqadd37804 fma 1 Inf 0 -> Infinity
+dqadd37805 fma 1 Inf 1 -> Infinity
+dqadd37806 fma 1 Inf 1000 -> Infinity
+dqadd37807 fma 1 Inf Inf -> Infinity
+dqadd37808 fma 1 -1000 Inf -> Infinity
+dqadd37809 fma 1 -Inf Inf -> NaN Invalid_operation
+dqadd37810 fma 1 -1 Inf -> Infinity
+dqadd37811 fma 1 -0 Inf -> Infinity
+dqadd37812 fma 1 0 Inf -> Infinity
+dqadd37813 fma 1 1 Inf -> Infinity
+dqadd37814 fma 1 1000 Inf -> Infinity
+dqadd37815 fma 1 Inf Inf -> Infinity
+
+dqadd37821 fma 1 NaN -Inf -> NaN
+dqadd37822 fma 1 NaN -1000 -> NaN
+dqadd37823 fma 1 NaN -1 -> NaN
+dqadd37824 fma 1 NaN -0 -> NaN
+dqadd37825 fma 1 NaN 0 -> NaN
+dqadd37826 fma 1 NaN 1 -> NaN
+dqadd37827 fma 1 NaN 1000 -> NaN
+dqadd37828 fma 1 NaN Inf -> NaN
+dqadd37829 fma 1 NaN NaN -> NaN
+dqadd37830 fma 1 -Inf NaN -> NaN
+dqadd37831 fma 1 -1000 NaN -> NaN
+dqadd37832 fma 1 -1 NaN -> NaN
+dqadd37833 fma 1 -0 NaN -> NaN
+dqadd37834 fma 1 0 NaN -> NaN
+dqadd37835 fma 1 1 NaN -> NaN
+dqadd37836 fma 1 1000 NaN -> NaN
+dqadd37837 fma 1 Inf NaN -> NaN
+
+dqadd37841 fma 1 sNaN -Inf -> NaN Invalid_operation
+dqadd37842 fma 1 sNaN -1000 -> NaN Invalid_operation
+dqadd37843 fma 1 sNaN -1 -> NaN Invalid_operation
+dqadd37844 fma 1 sNaN -0 -> NaN Invalid_operation
+dqadd37845 fma 1 sNaN 0 -> NaN Invalid_operation
+dqadd37846 fma 1 sNaN 1 -> NaN Invalid_operation
+dqadd37847 fma 1 sNaN 1000 -> NaN Invalid_operation
+dqadd37848 fma 1 sNaN NaN -> NaN Invalid_operation
+dqadd37849 fma 1 sNaN sNaN -> NaN Invalid_operation
+dqadd37850 fma 1 NaN sNaN -> NaN Invalid_operation
+dqadd37851 fma 1 -Inf sNaN -> NaN Invalid_operation
+dqadd37852 fma 1 -1000 sNaN -> NaN Invalid_operation
+dqadd37853 fma 1 -1 sNaN -> NaN Invalid_operation
+dqadd37854 fma 1 -0 sNaN -> NaN Invalid_operation
+dqadd37855 fma 1 0 sNaN -> NaN Invalid_operation
+dqadd37856 fma 1 1 sNaN -> NaN Invalid_operation
+dqadd37857 fma 1 1000 sNaN -> NaN Invalid_operation
+dqadd37858 fma 1 Inf sNaN -> NaN Invalid_operation
+dqadd37859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqadd37861 fma 1 NaN1 -Inf -> NaN1
+dqadd37862 fma 1 +NaN2 -1000 -> NaN2
+dqadd37863 fma 1 NaN3 1000 -> NaN3
+dqadd37864 fma 1 NaN4 Inf -> NaN4
+dqadd37865 fma 1 NaN5 +NaN6 -> NaN5
+dqadd37866 fma 1 -Inf NaN7 -> NaN7
+dqadd37867 fma 1 -1000 NaN8 -> NaN8
+dqadd37868 fma 1 1000 NaN9 -> NaN9
+dqadd37869 fma 1 Inf +NaN10 -> NaN10
+dqadd37871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+dqadd37872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+dqadd37873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+dqadd37874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+dqadd37875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqadd37876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+dqadd37877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+dqadd37878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+dqadd37879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+dqadd37880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+dqadd37881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqadd37882 fma 1 -NaN26 NaN28 -> -NaN26
+dqadd37883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqadd37884 fma 1 1000 -NaN30 -> -NaN30
+dqadd37885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Here we explore near the boundary of rounding a subnormal to Nmin
+dqadd37575 fma 1 1E-6143 -1E-6176 -> 9.99999999999999999999999999999999E-6144 Subnormal
+dqadd37576 fma 1 -1E-6143 +1E-6176 -> -9.99999999999999999999999999999999E-6144 Subnormal
+
+-- check overflow edge case
+-- 1234567890123456
+dqadd37972 apply 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqadd37973 fma 1 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37974 fma 1 9999999999999999999999999999999999E+6111 1 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37975 fma 1 9999999999999999999999999999999999E+6111 1E+6111 -> Infinity Overflow Inexact Rounded
+dqadd37976 fma 1 9999999999999999999999999999999999E+6111 9E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37977 fma 1 9999999999999999999999999999999999E+6111 8E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37978 fma 1 9999999999999999999999999999999999E+6111 7E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37979 fma 1 9999999999999999999999999999999999E+6111 6E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37980 fma 1 9999999999999999999999999999999999E+6111 5E+6110 -> Infinity Overflow Inexact Rounded
+dqadd37981 fma 1 9999999999999999999999999999999999E+6111 4E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37982 fma 1 9999999999999999999999999999999999E+6111 3E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37983 fma 1 9999999999999999999999999999999999E+6111 2E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37984 fma 1 9999999999999999999999999999999999E+6111 1E+6110 -> 9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+dqadd37985 apply -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqadd37986 fma 1 -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37987 fma 1 -9999999999999999999999999999999999E+6111 -1 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37988 fma 1 -9999999999999999999999999999999999E+6111 -1E+6111 -> -Infinity Overflow Inexact Rounded
+dqadd37989 fma 1 -9999999999999999999999999999999999E+6111 -9E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37990 fma 1 -9999999999999999999999999999999999E+6111 -8E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37991 fma 1 -9999999999999999999999999999999999E+6111 -7E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37992 fma 1 -9999999999999999999999999999999999E+6111 -6E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37993 fma 1 -9999999999999999999999999999999999E+6111 -5E+6110 -> -Infinity Overflow Inexact Rounded
+dqadd37994 fma 1 -9999999999999999999999999999999999E+6111 -4E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37995 fma 1 -9999999999999999999999999999999999E+6111 -3E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37996 fma 1 -9999999999999999999999999999999999E+6111 -2E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+dqadd37997 fma 1 -9999999999999999999999999999999999E+6111 -1E+6110 -> -9.999999999999999999999999999999999E+6144 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+dqadd371100 fma 1 1e+2 -1e-6143 -> 99.99999999999999999999999999999999 Rounded Inexact
+dqadd371101 fma 1 1e+1 -1e-6143 -> 9.999999999999999999999999999999999 Rounded Inexact
+dqadd371103 fma 1 +1 -1e-6143 -> 0.9999999999999999999999999999999999 Rounded Inexact
+dqadd371104 fma 1 1e-1 -1e-6143 -> 0.09999999999999999999999999999999999 Rounded Inexact
+dqadd371105 fma 1 1e-2 -1e-6143 -> 0.009999999999999999999999999999999999 Rounded Inexact
+dqadd371106 fma 1 1e-3 -1e-6143 -> 0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd371107 fma 1 1e-4 -1e-6143 -> 0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd371108 fma 1 1e-5 -1e-6143 -> 0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd371109 fma 1 1e-6 -1e-6143 -> 9.999999999999999999999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+dqadd371110 fma 1 -1e+2 +1e-6143 -> -99.99999999999999999999999999999999 Rounded Inexact
+dqadd371111 fma 1 -1e+1 +1e-6143 -> -9.999999999999999999999999999999999 Rounded Inexact
+dqadd371113 fma 1 -1 +1e-6143 -> -0.9999999999999999999999999999999999 Rounded Inexact
+dqadd371114 fma 1 -1e-1 +1e-6143 -> -0.09999999999999999999999999999999999 Rounded Inexact
+dqadd371115 fma 1 -1e-2 +1e-6143 -> -0.009999999999999999999999999999999999 Rounded Inexact
+dqadd371116 fma 1 -1e-3 +1e-6143 -> -0.0009999999999999999999999999999999999 Rounded Inexact
+dqadd371117 fma 1 -1e-4 +1e-6143 -> -0.00009999999999999999999999999999999999 Rounded Inexact
+dqadd371118 fma 1 -1e-5 +1e-6143 -> -0.000009999999999999999999999999999999999 Rounded Inexact
+dqadd371119 fma 1 -1e-6 +1e-6143 -> -9.999999999999999999999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+dqadd371300 fma 1 1E34 -0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371310 fma 1 1E34 -0.51 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371311 fma 1 1E34 -0.501 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371312 fma 1 1E34 -0.5001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371313 fma 1 1E34 -0.50001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371314 fma 1 1E34 -0.500001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371315 fma 1 1E34 -0.5000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371316 fma 1 1E34 -0.50000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371317 fma 1 1E34 -0.500000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371318 fma 1 1E34 -0.5000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371319 fma 1 1E34 -0.50000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371320 fma 1 1E34 -0.500000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371321 fma 1 1E34 -0.5000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371322 fma 1 1E34 -0.50000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371323 fma 1 1E34 -0.500000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371324 fma 1 1E34 -0.5000000000000001 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371325 fma 1 1E34 -0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371326 fma 1 1E34 -0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371327 fma 1 1E34 -0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371328 fma 1 1E34 -0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371329 fma 1 1E34 -0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371330 fma 1 1E34 -0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371331 fma 1 1E34 -0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371332 fma 1 1E34 -0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371333 fma 1 1E34 -0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371334 fma 1 1E34 -0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371335 fma 1 1E34 -0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371336 fma 1 1E34 -0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371337 fma 1 1E34 -0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371338 fma 1 1E34 -0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371339 fma 1 1E34 -0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+dqadd371340 fma 1 1E34 -5000000.000010001 -> 9999999999999999999999999995000000 Inexact Rounded
+dqadd371341 fma 1 1E34 -5000000.000000001 -> 9999999999999999999999999995000000 Inexact Rounded
+
+dqadd371349 fma 1 9999999999999999999999999999999999 0.4 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371350 fma 1 9999999999999999999999999999999999 0.49 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371351 fma 1 9999999999999999999999999999999999 0.499 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371352 fma 1 9999999999999999999999999999999999 0.4999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371353 fma 1 9999999999999999999999999999999999 0.49999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371354 fma 1 9999999999999999999999999999999999 0.499999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371355 fma 1 9999999999999999999999999999999999 0.4999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371356 fma 1 9999999999999999999999999999999999 0.49999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371357 fma 1 9999999999999999999999999999999999 0.499999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371358 fma 1 9999999999999999999999999999999999 0.4999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371359 fma 1 9999999999999999999999999999999999 0.49999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371360 fma 1 9999999999999999999999999999999999 0.499999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371361 fma 1 9999999999999999999999999999999999 0.4999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371362 fma 1 9999999999999999999999999999999999 0.49999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371363 fma 1 9999999999999999999999999999999999 0.499999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371364 fma 1 9999999999999999999999999999999999 0.4999999999999999 -> 9999999999999999999999999999999999 Inexact Rounded
+dqadd371365 fma 1 9999999999999999999999999999999999 0.5000000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371367 fma 1 9999999999999999999999999999999999 0.500000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371368 fma 1 9999999999999999999999999999999999 0.50000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371369 fma 1 9999999999999999999999999999999999 0.5000000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371370 fma 1 9999999999999999999999999999999999 0.500000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371371 fma 1 9999999999999999999999999999999999 0.50000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371372 fma 1 9999999999999999999999999999999999 0.5000000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371373 fma 1 9999999999999999999999999999999999 0.500000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371374 fma 1 9999999999999999999999999999999999 0.50000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371375 fma 1 9999999999999999999999999999999999 0.5000000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371376 fma 1 9999999999999999999999999999999999 0.500000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371377 fma 1 9999999999999999999999999999999999 0.50000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371378 fma 1 9999999999999999999999999999999999 0.5000 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371379 fma 1 9999999999999999999999999999999999 0.500 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371380 fma 1 9999999999999999999999999999999999 0.50 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371381 fma 1 9999999999999999999999999999999999 0.5 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371382 fma 1 9999999999999999999999999999999999 0.5000000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371383 fma 1 9999999999999999999999999999999999 0.500000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371384 fma 1 9999999999999999999999999999999999 0.50000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371385 fma 1 9999999999999999999999999999999999 0.5000000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371386 fma 1 9999999999999999999999999999999999 0.500000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371387 fma 1 9999999999999999999999999999999999 0.50000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371388 fma 1 9999999999999999999999999999999999 0.5000000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371389 fma 1 9999999999999999999999999999999999 0.500000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371390 fma 1 9999999999999999999999999999999999 0.50000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371391 fma 1 9999999999999999999999999999999999 0.5000001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371392 fma 1 9999999999999999999999999999999999 0.500001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371393 fma 1 9999999999999999999999999999999999 0.50001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371394 fma 1 9999999999999999999999999999999999 0.5001 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371395 fma 1 9999999999999999999999999999999999 0.501 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+dqadd371396 fma 1 9999999999999999999999999999999999 0.51 -> 1.000000000000000000000000000000000E+34 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+dqadd371420 fma 1 0 1.123456789987654321123456789012345 -> 1.123456789987654321123456789012345
+dqadd371421 fma 1 0 1.123456789987654321123456789012345E-1 -> 0.1123456789987654321123456789012345
+dqadd371422 fma 1 0 1.123456789987654321123456789012345E-2 -> 0.01123456789987654321123456789012345
+dqadd371423 fma 1 0 1.123456789987654321123456789012345E-3 -> 0.001123456789987654321123456789012345
+dqadd371424 fma 1 0 1.123456789987654321123456789012345E-4 -> 0.0001123456789987654321123456789012345
+dqadd371425 fma 1 0 1.123456789987654321123456789012345E-5 -> 0.00001123456789987654321123456789012345
+dqadd371426 fma 1 0 1.123456789987654321123456789012345E-6 -> 0.000001123456789987654321123456789012345
+dqadd371427 fma 1 0 1.123456789987654321123456789012345E-7 -> 1.123456789987654321123456789012345E-7
+dqadd371428 fma 1 0 1.123456789987654321123456789012345E-8 -> 1.123456789987654321123456789012345E-8
+dqadd371429 fma 1 0 1.123456789987654321123456789012345E-9 -> 1.123456789987654321123456789012345E-9
+dqadd371430 fma 1 0 1.123456789987654321123456789012345E-10 -> 1.123456789987654321123456789012345E-10
+dqadd371431 fma 1 0 1.123456789987654321123456789012345E-11 -> 1.123456789987654321123456789012345E-11
+dqadd371432 fma 1 0 1.123456789987654321123456789012345E-12 -> 1.123456789987654321123456789012345E-12
+dqadd371433 fma 1 0 1.123456789987654321123456789012345E-13 -> 1.123456789987654321123456789012345E-13
+dqadd371434 fma 1 0 1.123456789987654321123456789012345E-14 -> 1.123456789987654321123456789012345E-14
+dqadd371435 fma 1 0 1.123456789987654321123456789012345E-15 -> 1.123456789987654321123456789012345E-15
+dqadd371436 fma 1 0 1.123456789987654321123456789012345E-16 -> 1.123456789987654321123456789012345E-16
+dqadd371437 fma 1 0 1.123456789987654321123456789012345E-17 -> 1.123456789987654321123456789012345E-17
+dqadd371438 fma 1 0 1.123456789987654321123456789012345E-18 -> 1.123456789987654321123456789012345E-18
+dqadd371439 fma 1 0 1.123456789987654321123456789012345E-19 -> 1.123456789987654321123456789012345E-19
+dqadd371440 fma 1 0 1.123456789987654321123456789012345E-20 -> 1.123456789987654321123456789012345E-20
+dqadd371441 fma 1 0 1.123456789987654321123456789012345E-21 -> 1.123456789987654321123456789012345E-21
+dqadd371442 fma 1 0 1.123456789987654321123456789012345E-22 -> 1.123456789987654321123456789012345E-22
+dqadd371443 fma 1 0 1.123456789987654321123456789012345E-23 -> 1.123456789987654321123456789012345E-23
+dqadd371444 fma 1 0 1.123456789987654321123456789012345E-24 -> 1.123456789987654321123456789012345E-24
+dqadd371445 fma 1 0 1.123456789987654321123456789012345E-25 -> 1.123456789987654321123456789012345E-25
+dqadd371446 fma 1 0 1.123456789987654321123456789012345E-26 -> 1.123456789987654321123456789012345E-26
+dqadd371447 fma 1 0 1.123456789987654321123456789012345E-27 -> 1.123456789987654321123456789012345E-27
+dqadd371448 fma 1 0 1.123456789987654321123456789012345E-28 -> 1.123456789987654321123456789012345E-28
+dqadd371449 fma 1 0 1.123456789987654321123456789012345E-29 -> 1.123456789987654321123456789012345E-29
+dqadd371450 fma 1 0 1.123456789987654321123456789012345E-30 -> 1.123456789987654321123456789012345E-30
+dqadd371451 fma 1 0 1.123456789987654321123456789012345E-31 -> 1.123456789987654321123456789012345E-31
+dqadd371452 fma 1 0 1.123456789987654321123456789012345E-32 -> 1.123456789987654321123456789012345E-32
+dqadd371453 fma 1 0 1.123456789987654321123456789012345E-33 -> 1.123456789987654321123456789012345E-33
+dqadd371454 fma 1 0 1.123456789987654321123456789012345E-34 -> 1.123456789987654321123456789012345E-34
+dqadd371455 fma 1 0 1.123456789987654321123456789012345E-35 -> 1.123456789987654321123456789012345E-35
+dqadd371456 fma 1 0 1.123456789987654321123456789012345E-36 -> 1.123456789987654321123456789012345E-36
+
+-- same, reversed 0
+dqadd371460 fma 1 1.123456789987654321123456789012345 0 -> 1.123456789987654321123456789012345
+dqadd371461 fma 1 1.123456789987654321123456789012345E-1 0 -> 0.1123456789987654321123456789012345
+dqadd371462 fma 1 1.123456789987654321123456789012345E-2 0 -> 0.01123456789987654321123456789012345
+dqadd371463 fma 1 1.123456789987654321123456789012345E-3 0 -> 0.001123456789987654321123456789012345
+dqadd371464 fma 1 1.123456789987654321123456789012345E-4 0 -> 0.0001123456789987654321123456789012345
+dqadd371465 fma 1 1.123456789987654321123456789012345E-5 0 -> 0.00001123456789987654321123456789012345
+dqadd371466 fma 1 1.123456789987654321123456789012345E-6 0 -> 0.000001123456789987654321123456789012345
+dqadd371467 fma 1 1.123456789987654321123456789012345E-7 0 -> 1.123456789987654321123456789012345E-7
+dqadd371468 fma 1 1.123456789987654321123456789012345E-8 0 -> 1.123456789987654321123456789012345E-8
+dqadd371469 fma 1 1.123456789987654321123456789012345E-9 0 -> 1.123456789987654321123456789012345E-9
+dqadd371470 fma 1 1.123456789987654321123456789012345E-10 0 -> 1.123456789987654321123456789012345E-10
+dqadd371471 fma 1 1.123456789987654321123456789012345E-11 0 -> 1.123456789987654321123456789012345E-11
+dqadd371472 fma 1 1.123456789987654321123456789012345E-12 0 -> 1.123456789987654321123456789012345E-12
+dqadd371473 fma 1 1.123456789987654321123456789012345E-13 0 -> 1.123456789987654321123456789012345E-13
+dqadd371474 fma 1 1.123456789987654321123456789012345E-14 0 -> 1.123456789987654321123456789012345E-14
+dqadd371475 fma 1 1.123456789987654321123456789012345E-15 0 -> 1.123456789987654321123456789012345E-15
+dqadd371476 fma 1 1.123456789987654321123456789012345E-16 0 -> 1.123456789987654321123456789012345E-16
+dqadd371477 fma 1 1.123456789987654321123456789012345E-17 0 -> 1.123456789987654321123456789012345E-17
+dqadd371478 fma 1 1.123456789987654321123456789012345E-18 0 -> 1.123456789987654321123456789012345E-18
+dqadd371479 fma 1 1.123456789987654321123456789012345E-19 0 -> 1.123456789987654321123456789012345E-19
+dqadd371480 fma 1 1.123456789987654321123456789012345E-20 0 -> 1.123456789987654321123456789012345E-20
+dqadd371481 fma 1 1.123456789987654321123456789012345E-21 0 -> 1.123456789987654321123456789012345E-21
+dqadd371482 fma 1 1.123456789987654321123456789012345E-22 0 -> 1.123456789987654321123456789012345E-22
+dqadd371483 fma 1 1.123456789987654321123456789012345E-23 0 -> 1.123456789987654321123456789012345E-23
+dqadd371484 fma 1 1.123456789987654321123456789012345E-24 0 -> 1.123456789987654321123456789012345E-24
+dqadd371485 fma 1 1.123456789987654321123456789012345E-25 0 -> 1.123456789987654321123456789012345E-25
+dqadd371486 fma 1 1.123456789987654321123456789012345E-26 0 -> 1.123456789987654321123456789012345E-26
+dqadd371487 fma 1 1.123456789987654321123456789012345E-27 0 -> 1.123456789987654321123456789012345E-27
+dqadd371488 fma 1 1.123456789987654321123456789012345E-28 0 -> 1.123456789987654321123456789012345E-28
+dqadd371489 fma 1 1.123456789987654321123456789012345E-29 0 -> 1.123456789987654321123456789012345E-29
+dqadd371490 fma 1 1.123456789987654321123456789012345E-30 0 -> 1.123456789987654321123456789012345E-30
+dqadd371491 fma 1 1.123456789987654321123456789012345E-31 0 -> 1.123456789987654321123456789012345E-31
+dqadd371492 fma 1 1.123456789987654321123456789012345E-32 0 -> 1.123456789987654321123456789012345E-32
+dqadd371493 fma 1 1.123456789987654321123456789012345E-33 0 -> 1.123456789987654321123456789012345E-33
+dqadd371494 fma 1 1.123456789987654321123456789012345E-34 0 -> 1.123456789987654321123456789012345E-34
+dqadd371495 fma 1 1.123456789987654321123456789012345E-35 0 -> 1.123456789987654321123456789012345E-35
+dqadd371496 fma 1 1.123456789987654321123456789012345E-36 0 -> 1.123456789987654321123456789012345E-36
+
+-- same, Es on the 0
+dqadd371500 fma 1 1.123456789987654321123456789012345 0E-0 -> 1.123456789987654321123456789012345
+dqadd371501 fma 1 1.123456789987654321123456789012345 0E-1 -> 1.123456789987654321123456789012345
+dqadd371502 fma 1 1.123456789987654321123456789012345 0E-2 -> 1.123456789987654321123456789012345
+dqadd371503 fma 1 1.123456789987654321123456789012345 0E-3 -> 1.123456789987654321123456789012345
+dqadd371504 fma 1 1.123456789987654321123456789012345 0E-4 -> 1.123456789987654321123456789012345
+dqadd371505 fma 1 1.123456789987654321123456789012345 0E-5 -> 1.123456789987654321123456789012345
+dqadd371506 fma 1 1.123456789987654321123456789012345 0E-6 -> 1.123456789987654321123456789012345
+dqadd371507 fma 1 1.123456789987654321123456789012345 0E-7 -> 1.123456789987654321123456789012345
+dqadd371508 fma 1 1.123456789987654321123456789012345 0E-8 -> 1.123456789987654321123456789012345
+dqadd371509 fma 1 1.123456789987654321123456789012345 0E-9 -> 1.123456789987654321123456789012345
+dqadd371510 fma 1 1.123456789987654321123456789012345 0E-10 -> 1.123456789987654321123456789012345
+dqadd371511 fma 1 1.123456789987654321123456789012345 0E-11 -> 1.123456789987654321123456789012345
+dqadd371512 fma 1 1.123456789987654321123456789012345 0E-12 -> 1.123456789987654321123456789012345
+dqadd371513 fma 1 1.123456789987654321123456789012345 0E-13 -> 1.123456789987654321123456789012345
+dqadd371514 fma 1 1.123456789987654321123456789012345 0E-14 -> 1.123456789987654321123456789012345
+dqadd371515 fma 1 1.123456789987654321123456789012345 0E-15 -> 1.123456789987654321123456789012345
+dqadd371516 fma 1 1.123456789987654321123456789012345 0E-16 -> 1.123456789987654321123456789012345
+dqadd371517 fma 1 1.123456789987654321123456789012345 0E-17 -> 1.123456789987654321123456789012345
+dqadd371518 fma 1 1.123456789987654321123456789012345 0E-18 -> 1.123456789987654321123456789012345
+dqadd371519 fma 1 1.123456789987654321123456789012345 0E-19 -> 1.123456789987654321123456789012345
+dqadd371520 fma 1 1.123456789987654321123456789012345 0E-20 -> 1.123456789987654321123456789012345
+dqadd371521 fma 1 1.123456789987654321123456789012345 0E-21 -> 1.123456789987654321123456789012345
+dqadd371522 fma 1 1.123456789987654321123456789012345 0E-22 -> 1.123456789987654321123456789012345
+dqadd371523 fma 1 1.123456789987654321123456789012345 0E-23 -> 1.123456789987654321123456789012345
+dqadd371524 fma 1 1.123456789987654321123456789012345 0E-24 -> 1.123456789987654321123456789012345
+dqadd371525 fma 1 1.123456789987654321123456789012345 0E-25 -> 1.123456789987654321123456789012345
+dqadd371526 fma 1 1.123456789987654321123456789012345 0E-26 -> 1.123456789987654321123456789012345
+dqadd371527 fma 1 1.123456789987654321123456789012345 0E-27 -> 1.123456789987654321123456789012345
+dqadd371528 fma 1 1.123456789987654321123456789012345 0E-28 -> 1.123456789987654321123456789012345
+dqadd371529 fma 1 1.123456789987654321123456789012345 0E-29 -> 1.123456789987654321123456789012345
+dqadd371530 fma 1 1.123456789987654321123456789012345 0E-30 -> 1.123456789987654321123456789012345
+dqadd371531 fma 1 1.123456789987654321123456789012345 0E-31 -> 1.123456789987654321123456789012345
+dqadd371532 fma 1 1.123456789987654321123456789012345 0E-32 -> 1.123456789987654321123456789012345
+dqadd371533 fma 1 1.123456789987654321123456789012345 0E-33 -> 1.123456789987654321123456789012345
+-- next four flag Rounded because the 0 extends the result
+dqadd371534 fma 1 1.123456789987654321123456789012345 0E-34 -> 1.123456789987654321123456789012345 Rounded
+dqadd371535 fma 1 1.123456789987654321123456789012345 0E-35 -> 1.123456789987654321123456789012345 Rounded
+dqadd371536 fma 1 1.123456789987654321123456789012345 0E-36 -> 1.123456789987654321123456789012345 Rounded
+dqadd371537 fma 1 1.123456789987654321123456789012345 0E-37 -> 1.123456789987654321123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+dqadd371600 fma 1 0 0E-19 -> 0E-19
+dqadd371601 fma 1 -0 0E-19 -> 0E-19
+dqadd371602 fma 1 0 -0E-19 -> 0E-19
+dqadd371603 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371611 fma 1 -11 11 -> 0
+dqadd371612 fma 1 11 -11 -> 0
+-- overflow
+dqadd371613 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371614 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_down
+-- exact zeros from zeros
+dqadd371620 fma 1 0 0E-19 -> 0E-19
+dqadd371621 fma 1 -0 0E-19 -> 0E-19
+dqadd371622 fma 1 0 -0E-19 -> 0E-19
+dqadd371623 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371631 fma 1 -11 11 -> 0
+dqadd371632 fma 1 11 -11 -> 0
+-- overflow
+dqadd371633 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371634 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+-- exact zeros from zeros
+dqadd371640 fma 1 0 0E-19 -> 0E-19
+dqadd371641 fma 1 -0 0E-19 -> 0E-19
+dqadd371642 fma 1 0 -0E-19 -> 0E-19
+dqadd371643 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371651 fma 1 -11 11 -> 0
+dqadd371652 fma 1 11 -11 -> 0
+-- overflow
+dqadd371653 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371654 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: up
+-- exact zeros from zeros
+dqadd371660 fma 1 0 0E-19 -> 0E-19
+dqadd371661 fma 1 -0 0E-19 -> 0E-19
+dqadd371662 fma 1 0 -0E-19 -> 0E-19
+dqadd371663 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371671 fma 1 -11 11 -> 0
+dqadd371672 fma 1 11 -11 -> 0
+-- overflow
+dqadd371673 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371674 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: down
+-- exact zeros from zeros
+dqadd371680 fma 1 0 0E-19 -> 0E-19
+dqadd371681 fma 1 -0 0E-19 -> 0E-19
+dqadd371682 fma 1 0 -0E-19 -> 0E-19
+dqadd371683 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371691 fma 1 -11 11 -> 0
+dqadd371692 fma 1 11 -11 -> 0
+-- overflow
+dqadd371693 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371694 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+rounding: ceiling
+-- exact zeros from zeros
+dqadd371700 fma 1 0 0E-19 -> 0E-19
+dqadd371701 fma 1 -0 0E-19 -> 0E-19
+dqadd371702 fma 1 0 -0E-19 -> 0E-19
+dqadd371703 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371711 fma 1 -11 11 -> 0
+dqadd371712 fma 1 11 -11 -> 0
+-- overflow
+dqadd371713 fma 9E6144 10 1 -> Infinity Overflow Inexact Rounded
+dqadd371714 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+dqadd371720 fma 1 0 0E-19 -> 0E-19
+dqadd371721 fma 1 -0 0E-19 -> -0E-19 -- *
+dqadd371722 fma 1 0 -0E-19 -> -0E-19 -- *
+dqadd371723 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371731 fma 1 -11 11 -> -0 -- *
+dqadd371732 fma 1 11 -11 -> -0 -- *
+-- overflow
+dqadd371733 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371734 fma -9E6144 10 1 -> -Infinity Overflow Inexact Rounded
+
+rounding: 05up
+-- exact zeros from zeros
+dqadd371740 fma 1 0 0E-19 -> 0E-19
+dqadd371741 fma 1 -0 0E-19 -> 0E-19
+dqadd371742 fma 1 0 -0E-19 -> 0E-19
+dqadd371743 fma 1 -0 -0E-19 -> -0E-19
+-- exact zeros from non-zeros
+dqadd371751 fma 1 -11 11 -> 0
+dqadd371752 fma 1 11 -11 -> 0
+-- overflow
+dqadd371753 fma 9E6144 10 1 -> 9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+dqadd371754 fma -9E6144 10 1 -> -9.999999999999999999999999999999999E+6144 Overflow Inexact Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqadd371761 fma 1 130E-2 120E-2 -> 2.50
+dqadd371762 fma 1 130E-2 12E-1 -> 2.50
+dqadd371763 fma 1 130E-2 1E0 -> 2.30
+dqadd371764 fma 1 1E2 1E4 -> 1.01E+4
+dqadd371765 fma 1 130E-2 -120E-2 -> 0.10
+dqadd371766 fma 1 130E-2 -12E-1 -> 0.10
+dqadd371767 fma 1 130E-2 -1E0 -> 0.30
+dqadd371768 fma 1 1E2 -1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+dqadd375001 fma 1 1239876543211234567894567890123456 1 -> 1239876543211234567894567890123457
+dqadd375002 fma 1 1239876543211234567894567890123456 0.6 -> 1239876543211234567894567890123457 Inexact Rounded
+dqadd375003 fma 1 1239876543211234567894567890123456 0.06 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375004 fma 1 1239876543211234567894567890123456 6E-3 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375005 fma 1 1239876543211234567894567890123456 6E-4 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375006 fma 1 1239876543211234567894567890123456 6E-5 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375007 fma 1 1239876543211234567894567890123456 6E-6 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375008 fma 1 1239876543211234567894567890123456 6E-7 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375009 fma 1 1239876543211234567894567890123456 6E-8 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375010 fma 1 1239876543211234567894567890123456 6E-9 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375011 fma 1 1239876543211234567894567890123456 6E-10 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375012 fma 1 1239876543211234567894567890123456 6E-11 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375013 fma 1 1239876543211234567894567890123456 6E-12 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375014 fma 1 1239876543211234567894567890123456 6E-13 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375015 fma 1 1239876543211234567894567890123456 6E-14 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375016 fma 1 1239876543211234567894567890123456 6E-15 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375017 fma 1 1239876543211234567894567890123456 6E-16 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375018 fma 1 1239876543211234567894567890123456 6E-17 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375019 fma 1 1239876543211234567894567890123456 6E-18 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375020 fma 1 1239876543211234567894567890123456 6E-19 -> 1239876543211234567894567890123456 Inexact Rounded
+dqadd375021 fma 1 1239876543211234567894567890123456 6E-20 -> 1239876543211234567894567890123456 Inexact Rounded
+
+-- widening second argument at gap
+dqadd375030 fma 1 12398765432112345678945678 1 -> 12398765432112345678945679
+dqadd375031 fma 1 12398765432112345678945678 0.1 -> 12398765432112345678945678.1
+dqadd375032 fma 1 12398765432112345678945678 0.12 -> 12398765432112345678945678.12
+dqadd375033 fma 1 12398765432112345678945678 0.123 -> 12398765432112345678945678.123
+dqadd375034 fma 1 12398765432112345678945678 0.1234 -> 12398765432112345678945678.1234
+dqadd375035 fma 1 12398765432112345678945678 0.12345 -> 12398765432112345678945678.12345
+dqadd375036 fma 1 12398765432112345678945678 0.123456 -> 12398765432112345678945678.123456
+dqadd375037 fma 1 12398765432112345678945678 0.1234567 -> 12398765432112345678945678.1234567
+dqadd375038 fma 1 12398765432112345678945678 0.12345678 -> 12398765432112345678945678.12345678
+dqadd375039 fma 1 12398765432112345678945678 0.123456789 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375040 fma 1 12398765432112345678945678 0.123456785 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd375041 fma 1 12398765432112345678945678 0.1234567850 -> 12398765432112345678945678.12345678 Inexact Rounded
+dqadd375042 fma 1 12398765432112345678945678 0.1234567851 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375043 fma 1 12398765432112345678945678 0.12345678501 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375044 fma 1 12398765432112345678945678 0.123456785001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375045 fma 1 12398765432112345678945678 0.1234567850001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375046 fma 1 12398765432112345678945678 0.12345678500001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375047 fma 1 12398765432112345678945678 0.123456785000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375048 fma 1 12398765432112345678945678 0.1234567850000001 -> 12398765432112345678945678.12345679 Inexact Rounded
+dqadd375049 fma 1 12398765432112345678945678 0.1234567850000000 -> 12398765432112345678945678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+dqadd375050 fma 1 12398765432112345678945678 0.0234567750000000 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd375051 fma 1 12398765432112345678945678 0.0034567750000000 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd375052 fma 1 12398765432112345678945678 0.0004567750000000 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd375053 fma 1 12398765432112345678945678 0.0000567750000000 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd375054 fma 1 12398765432112345678945678 0.0000067750000000 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd375055 fma 1 12398765432112345678945678 0.0000007750000000 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd375056 fma 1 12398765432112345678945678 0.0000000750000000 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd375057 fma 1 12398765432112345678945678 0.0000000050000000 -> 12398765432112345678945678.00000000 Inexact Rounded
+dqadd375060 fma 1 12398765432112345678945678 0.0234567750000001 -> 12398765432112345678945678.02345678 Inexact Rounded
+dqadd375061 fma 1 12398765432112345678945678 0.0034567750000001 -> 12398765432112345678945678.00345678 Inexact Rounded
+dqadd375062 fma 1 12398765432112345678945678 0.0004567750000001 -> 12398765432112345678945678.00045678 Inexact Rounded
+dqadd375063 fma 1 12398765432112345678945678 0.0000567750000001 -> 12398765432112345678945678.00005678 Inexact Rounded
+dqadd375064 fma 1 12398765432112345678945678 0.0000067750000001 -> 12398765432112345678945678.00000678 Inexact Rounded
+dqadd375065 fma 1 12398765432112345678945678 0.0000007750000001 -> 12398765432112345678945678.00000078 Inexact Rounded
+dqadd375066 fma 1 12398765432112345678945678 0.0000000750000001 -> 12398765432112345678945678.00000008 Inexact Rounded
+dqadd375067 fma 1 12398765432112345678945678 0.0000000050000001 -> 12398765432112345678945678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+dqadd375070 fma 1 12398765432112345678945678 1E-8 -> 12398765432112345678945678.00000001
+dqadd375071 fma 1 12398765432112345678945678 1E-9 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375072 fma 1 12398765432112345678945678 1E-10 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375073 fma 1 12398765432112345678945678 1E-11 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375074 fma 1 12398765432112345678945678 1E-12 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375075 fma 1 12398765432112345678945678 1E-13 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375076 fma 1 12398765432112345678945678 1E-14 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375077 fma 1 12398765432112345678945678 1E-15 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375078 fma 1 12398765432112345678945678 1E-16 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375079 fma 1 12398765432112345678945678 1E-17 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375080 fma 1 12398765432112345678945678 1E-18 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375081 fma 1 12398765432112345678945678 1E-19 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375082 fma 1 12398765432112345678945678 1E-20 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375083 fma 1 12398765432112345678945678 1E-25 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375084 fma 1 12398765432112345678945678 1E-30 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375085 fma 1 12398765432112345678945678 1E-31 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375086 fma 1 12398765432112345678945678 1E-32 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375087 fma 1 12398765432112345678945678 1E-33 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375088 fma 1 12398765432112345678945678 1E-34 -> 12398765432112345678945678.00000001 Inexact Rounded
+dqadd375089 fma 1 12398765432112345678945678 1E-35 -> 12398765432112345678945678.00000001 Inexact Rounded
+
+-- Destructive subtract (from remainder tests)
+
+-- +++ some of these will be off-by-one remainder vs remainderNear
+
+dqfma4000 fma -1234567890123456789012345678901233 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> -0.234567890123456789012345678901233
+dqfma4001 fma -1234567890123456789012345678901222 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> -0.34567890123456789012345678901222
+dqfma4002 fma -1234567890123456789012345678901111 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.4567890123456789012345678901111
+dqfma4003 fma -308641972530864197253086419725314 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> -1.308641972530864197253086419725314
+dqfma4004 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
+dqfma4005 fma -246913578024691357802469135780252 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> -1.3086421975308642197530864219748
+dqfma4006 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
+dqfma4007 fma -246913578024691357802469135780247 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> -0.753086421975308642197530864219753
+dqfma4008 fma -246913578024691357802469135780247 5.000000000000000000000000000000001 1234567890123456789012345678901234 -> -1.246913578024691357802469135780247
+dqfma4009 fma -246913578024691357802469135780246 5.00000000000000000000000000000001 1234567890123456789012345678901234 -> 1.53086421975308642197530864219754
+dqfma4010 fma -246913578024691357802469135780242 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> -0.6913578024691357802469135780242
+dqfma4011 fma -1234567890123456789012345678901232 1.000000000000000000000000000000001 1234567890123456789012345678901234 -> 0.765432109876543210987654321098768
+dqfma4012 fma -1234567890123456789012345678901221 1.00000000000000000000000000000001 1234567890123456789012345678901234 -> 0.65432109876543210987654321098779
+dqfma4013 fma -1234567890123456789012345678901110 1.0000000000000000000000000000001 1234567890123456789012345678901234 -> 0.5432109876543210987654321098890
+dqfma4014 fma -308641972530864197253086419725313 4.000000000000000000000000000000001 1234567890123456789012345678901255 -> 2.691358027469135802746913580274687
+dqfma4015 fma -308641972530864197253086419725308 4.000000000000000000000000000000001 1234567890123456789012345678901234 -> 1.691358027469135802746913580274692
+dqfma4016 fma -246913578024691357802469135780251 4.9999999999999999999999999999999 1234567890123456789012345678901234 -> 3.6913578024691357802469135780251
+dqfma4017 fma -246913578024691357802469135780247 4.99999999999999999999999999999999 1234567890123456789012345678901234 -> 1.46913578024691357802469135780247
+dqfma4018 fma -246913578024691357802469135780246 4.999999999999999999999999999999999 1234567890123456789012345678901234 -> 4.246913578024691357802469135780246
+dqfma4019 fma -246913578024691357802469135780241 5.0000000000000000000000000000001 1234567890123456789012345678901234 -> 4.3086421975308642197530864219759
+
+-- Null tests
+dqadd39990 fma 1 10 # -> NaN Invalid_operation
+dqadd39991 fma 1 # 10 -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/dqInvert.decTest b/Lib/test/decimaltestdata/dqInvert.decTest
index 522cfc80f02..3a1e29e21da 100644
--- a/Lib/test/decimaltestdata/dqInvert.decTest
+++ b/Lib/test/decimaltestdata/dqInvert.decTest
@@ -1,245 +1,245 @@
-------------------------------------------------------------------------
--- dqInvert.decTest -- digitwise logical INVERT for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqinv001 invert 0 -> 1111111111111111111111111111111111
-dqinv002 invert 1 -> 1111111111111111111111111111111110
-dqinv003 invert 10 -> 1111111111111111111111111111111101
-dqinv004 invert 111111111 -> 1111111111111111111111111000000000
-dqinv005 invert 000000000 -> 1111111111111111111111111111111111
--- and at msd and msd-1
-dqinv007 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
-dqinv008 invert 1000000000000000000000000000000000 -> 111111111111111111111111111111111
-dqinv009 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
-dqinv010 invert 0100000000000000000000000000000000 -> 1011111111111111111111111111111111
-dqinv011 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqinv012 invert 1111111111111111111111111111111111 -> 0
-dqinv013 invert 0011111111111111111111111111111111 -> 1100000000000000000000000000000000
-dqinv014 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-
--- Various lengths
-dqinv600 invert 0111111111111111111011111111111111 -> 1000000000000000000100000000000000
-dqinv601 invert 0011111111111111110101111111111111 -> 1100000000000000001010000000000000
-dqinv602 invert 0101111111111111101110111111111111 -> 1010000000000000010001000000000000
-dqinv603 invert 0110111111111111011111011111111111 -> 1001000000000000100000100000000000
-dqinv604 invert 0111011111111110111111101111111111 -> 1000100000000001000000010000000000
-dqinv605 invert 0111101111111101111111110111111111 -> 1000010000000010000000001000000000
-dqinv606 invert 0111110111111011111111111011111111 -> 1000001000000100000000000100000000
-dqinv607 invert 0111111011110111111111111101111111 -> 1000000100001000000000000010000000
-dqinv608 invert 0111111101101111111111111110111111 -> 1000000010010000000000000001000000
-dqinv609 invert 0111111110011111111111111111011111 -> 1000000001100000000000000000100000
-dqinv610 invert 0111111110011111111111111111101111 -> 1000000001100000000000000000010000
-dqinv611 invert 0111111101101111111111111111110111 -> 1000000010010000000000000000001000
-dqinv612 invert 0111111011110111111111111111111011 -> 1000000100001000000000000000000100
-dqinv613 invert 0111110111111011111111111111111101 -> 1000001000000100000000000000000010
-dqinv614 invert 0111101111111101111111111111111110 -> 1000010000000010000000000000000001
-dqinv615 invert 0111011111111110111111111111111111 -> 1000100000000001000000000000000000
-dqinv616 invert 0110111111111111011111111111111110 -> 1001000000000000100000000000000001
-dqinv617 invert 0101111111111111101111111111111101 -> 1010000000000000010000000000000010
-dqinv618 invert 0011111111111111110111111111111011 -> 1100000000000000001000000000000100
-dqinv619 invert 0101111111111111111011111111110111 -> 1010000000000000000100000000001000
-dqinv620 invert 0110111111111111111101111111101111 -> 1001000000000000000010000000010000
-dqinv621 invert 0111011111111111111110111111011111 -> 1000100000000000000001000000100000
-dqinv622 invert 0111101111111111111111011110111111 -> 1000010000000000000000100001000000
-dqinv623 invert 0111110111111111111111101101111111 -> 1000001000000000000000010010000000
-dqinv624 invert 0111111011111111111111110011111111 -> 1000000100000000000000001100000000
-dqinv625 invert 0111111101111111111111110011111111 -> 1000000010000000000000001100000000
-dqinv626 invert 0111111110111111111111101101111111 -> 1000000001000000000000010010000000
-dqinv627 invert 0111111111011111111111011110111111 -> 1000000000100000000000100001000000
-dqinv628 invert 0111111111101111111110111111011111 -> 1000000000010000000001000000100000
-dqinv629 invert 0111111111110111111101111111101111 -> 1000000000001000000010000000010000
-dqinv630 invert 0111111111111011111011111111110111 -> 1000000000000100000100000000001000
-dqinv631 invert 0111111111111101110111111111111011 -> 1000000000000010001000000000000100
-dqinv632 invert 0111111111111110101111111111111101 -> 1000000000000001010000000000000010
-dqinv633 invert 0111111111111111011111111111111110 -> 1000000000000000100000000000000001
-
-dqinv021 invert 111111111 -> 1111111111111111111111111000000000
-dqinv022 invert 111111111111 -> 1111111111111111111111000000000000
-dqinv023 invert 11111111 -> 1111111111111111111111111100000000
-dqinv025 invert 1111111 -> 1111111111111111111111111110000000
-dqinv026 invert 111111 -> 1111111111111111111111111111000000
-dqinv027 invert 11111 -> 1111111111111111111111111111100000
-dqinv028 invert 1111 -> 1111111111111111111111111111110000
-dqinv029 invert 111 -> 1111111111111111111111111111111000
-dqinv031 invert 11 -> 1111111111111111111111111111111100
-dqinv032 invert 1 -> 1111111111111111111111111111111110
-dqinv033 invert 111111111111 -> 1111111111111111111111000000000000
-dqinv034 invert 11111111111 -> 1111111111111111111111100000000000
-dqinv035 invert 1111111111 -> 1111111111111111111111110000000000
-dqinv036 invert 111111111 -> 1111111111111111111111111000000000
-
-dqinv040 invert 011111111 -> 1111111111111111111111111100000000
-dqinv041 invert 101111111 -> 1111111111111111111111111010000000
-dqinv042 invert 110111111 -> 1111111111111111111111111001000000
-dqinv043 invert 111011111 -> 1111111111111111111111111000100000
-dqinv044 invert 111101111 -> 1111111111111111111111111000010000
-dqinv045 invert 111110111 -> 1111111111111111111111111000001000
-dqinv046 invert 111111011 -> 1111111111111111111111111000000100
-dqinv047 invert 111111101 -> 1111111111111111111111111000000010
-dqinv048 invert 111111110 -> 1111111111111111111111111000000001
-dqinv049 invert 011111011 -> 1111111111111111111111111100000100
-dqinv050 invert 101111101 -> 1111111111111111111111111010000010
-dqinv051 invert 110111110 -> 1111111111111111111111111001000001
-dqinv052 invert 111011101 -> 1111111111111111111111111000100010
-dqinv053 invert 111101011 -> 1111111111111111111111111000010100
-dqinv054 invert 111110111 -> 1111111111111111111111111000001000
-dqinv055 invert 111101011 -> 1111111111111111111111111000010100
-dqinv056 invert 111011101 -> 1111111111111111111111111000100010
-dqinv057 invert 110111110 -> 1111111111111111111111111001000001
-dqinv058 invert 101111101 -> 1111111111111111111111111010000010
-dqinv059 invert 011111011 -> 1111111111111111111111111100000100
-
-dqinv080 invert 1000000011111111 -> 1111111111111111110111111100000000
-dqinv081 invert 0100000101111111 -> 1111111111111111111011111010000000
-dqinv082 invert 0010000110111111 -> 1111111111111111111101111001000000
-dqinv083 invert 0001000111011111 -> 1111111111111111111110111000100000
-dqinv084 invert 0000100111101111 -> 1111111111111111111111011000010000
-dqinv085 invert 0000010111110111 -> 1111111111111111111111101000001000
-dqinv086 invert 0000001111111011 -> 1111111111111111111111110000000100
-dqinv087 invert 0000010111111101 -> 1111111111111111111111101000000010
-dqinv088 invert 0000100111111110 -> 1111111111111111111111011000000001
-dqinv089 invert 0001000011111011 -> 1111111111111111111110111100000100
-dqinv090 invert 0010000101111101 -> 1111111111111111111101111010000010
-dqinv091 invert 0100000110111110 -> 1111111111111111111011111001000001
-dqinv092 invert 1000000111011101 -> 1111111111111111110111111000100010
-dqinv093 invert 0100000111101011 -> 1111111111111111111011111000010100
-dqinv094 invert 0010000111110111 -> 1111111111111111111101111000001000
-dqinv095 invert 0001000111101011 -> 1111111111111111111110111000010100
-dqinv096 invert 0000100111011101 -> 1111111111111111111111011000100010
-dqinv097 invert 0000010110111110 -> 1111111111111111111111101001000001
-dqinv098 invert 0000001101111101 -> 1111111111111111111111110010000010
-dqinv099 invert 0000010011111011 -> 1111111111111111111111101100000100
-
--- and more thorough MSD/LSD tests [8 and 9 mght be encoded differently...]
-dqinv151 invert 1111111111111111111111111111111110 -> 1
-dqinv152 invert 1111111111111111110000000000000000 -> 1111111111111111
-dqinv153 invert 1000000000000000001111111111111111 -> 111111111111111110000000000000000
-dqinv154 invert 1111111111111111111000000000000000 -> 111111111111111
-dqinv155 invert 0100000000000000000111111111111111 -> 1011111111111111111000000000000000
-dqinv156 invert 1011111111111111110100000000000000 -> 100000000000000001011111111111111
-dqinv157 invert 1101111111111111110111111111111111 -> 10000000000000001000000000000000
-dqinv158 invert 1110111111111111110011111111111111 -> 1000000000000001100000000000000
-
--- non-0/1 should not be accepted, nor should signs
-dqinv220 invert 111111112 -> NaN Invalid_operation
-dqinv221 invert 333333333 -> NaN Invalid_operation
-dqinv222 invert 555555555 -> NaN Invalid_operation
-dqinv223 invert 777777777 -> NaN Invalid_operation
-dqinv224 invert 999999999 -> NaN Invalid_operation
-dqinv225 invert 222222222 -> NaN Invalid_operation
-dqinv226 invert 444444444 -> NaN Invalid_operation
-dqinv227 invert 666666666 -> NaN Invalid_operation
-dqinv228 invert 888888888 -> NaN Invalid_operation
-dqinv229 invert 999999999 -> NaN Invalid_operation
-dqinv230 invert 999999999 -> NaN Invalid_operation
-dqinv231 invert 999999999 -> NaN Invalid_operation
-dqinv232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-dqinv240 invert 567468689 -> NaN Invalid_operation
-dqinv241 invert 567367689 -> NaN Invalid_operation
-dqinv242 invert -631917772 -> NaN Invalid_operation
-dqinv243 invert -756253257 -> NaN Invalid_operation
-dqinv244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-dqinv250 invert 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv251 invert 3000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv252 invert 4000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv253 invert 5000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv254 invert 6000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv255 invert 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv256 invert 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqinv257 invert 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqinv270 invert 0200000111000111000111001000000000 -> NaN Invalid_operation
-dqinv271 invert 0300000111000111000111000100000000 -> NaN Invalid_operation
-dqinv272 invert 0400000111000111000111000010000000 -> NaN Invalid_operation
-dqinv273 invert 0500000111000111000111000001000000 -> NaN Invalid_operation
-dqinv274 invert 1600000111000111000111000000100000 -> NaN Invalid_operation
-dqinv275 invert 1700000111000111000111000000010000 -> NaN Invalid_operation
-dqinv276 invert 1800000111000111000111000000001000 -> NaN Invalid_operation
-dqinv277 invert 1900000111000111000111000000000100 -> NaN Invalid_operation
--- test LSD
-dqinv280 invert 0010000111000111000111000000000002 -> NaN Invalid_operation
-dqinv281 invert 0001000111000111000111000000000003 -> NaN Invalid_operation
-dqinv282 invert 0000000111000111000111100000000004 -> NaN Invalid_operation
-dqinv283 invert 0000000111000111000111010000000005 -> NaN Invalid_operation
-dqinv284 invert 1000000111000111000111001000000006 -> NaN Invalid_operation
-dqinv285 invert 1000000111000111000111000100000007 -> NaN Invalid_operation
-dqinv286 invert 1000000111000111000111000010000008 -> NaN Invalid_operation
-dqinv287 invert 1000000111000111000111000001000009 -> NaN Invalid_operation
--- test Middie
-dqinv288 invert 0010000111000111000111000020000000 -> NaN Invalid_operation
-dqinv289 invert 0001000111000111000111000030000001 -> NaN Invalid_operation
-dqinv290 invert 0000000111000111000111100040000010 -> NaN Invalid_operation
-dqinv291 invert 0000000111000111000111010050000100 -> NaN Invalid_operation
-dqinv292 invert 1000000111000111000111001060001000 -> NaN Invalid_operation
-dqinv293 invert 1000000111000111000111000170010000 -> NaN Invalid_operation
-dqinv294 invert 1000000111000111000111000080100000 -> NaN Invalid_operation
-dqinv295 invert 1000000111000111000111000091000000 -> NaN Invalid_operation
--- signs
-dqinv296 invert -1000000111000111000111000001000000 -> NaN Invalid_operation
-dqinv299 invert 1000000111000111000111000001000000 -> 111111000111000111000111110111111
-
--- Nmax, Nmin, Ntiny-like
-dqinv341 invert 9.99999999E+2998 -> NaN Invalid_operation
-dqinv342 invert 1E-2998 -> NaN Invalid_operation
-dqinv343 invert 1.00000000E-2998 -> NaN Invalid_operation
-dqinv344 invert 1E-2078 -> NaN Invalid_operation
-dqinv345 invert -1E-2078 -> NaN Invalid_operation
-dqinv346 invert -1.00000000E-2998 -> NaN Invalid_operation
-dqinv347 invert -1E-2998 -> NaN Invalid_operation
-dqinv348 invert -9.99999999E+2998 -> NaN Invalid_operation
-
--- A few other non-integers
-dqinv361 invert 1.0 -> NaN Invalid_operation
-dqinv362 invert 1E+1 -> NaN Invalid_operation
-dqinv363 invert 0.0 -> NaN Invalid_operation
-dqinv364 invert 0E+1 -> NaN Invalid_operation
-dqinv365 invert 9.9 -> NaN Invalid_operation
-dqinv366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqinv788 invert -Inf -> NaN Invalid_operation
-dqinv794 invert Inf -> NaN Invalid_operation
-dqinv821 invert NaN -> NaN Invalid_operation
-dqinv841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-dqinv861 invert NaN1 -> NaN Invalid_operation
-dqinv862 invert +NaN2 -> NaN Invalid_operation
-dqinv863 invert NaN3 -> NaN Invalid_operation
-dqinv864 invert NaN4 -> NaN Invalid_operation
-dqinv865 invert NaN5 -> NaN Invalid_operation
-dqinv871 invert sNaN11 -> NaN Invalid_operation
-dqinv872 invert sNaN12 -> NaN Invalid_operation
-dqinv873 invert sNaN13 -> NaN Invalid_operation
-dqinv874 invert sNaN14 -> NaN Invalid_operation
-dqinv875 invert sNaN15 -> NaN Invalid_operation
-dqinv876 invert NaN16 -> NaN Invalid_operation
-dqinv881 invert +NaN25 -> NaN Invalid_operation
-dqinv882 invert -NaN26 -> NaN Invalid_operation
-dqinv883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqInvert.decTest -- digitwise logical INVERT for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqinv001 invert 0 -> 1111111111111111111111111111111111
+dqinv002 invert 1 -> 1111111111111111111111111111111110
+dqinv003 invert 10 -> 1111111111111111111111111111111101
+dqinv004 invert 111111111 -> 1111111111111111111111111000000000
+dqinv005 invert 000000000 -> 1111111111111111111111111111111111
+-- and at msd and msd-1
+dqinv007 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
+dqinv008 invert 1000000000000000000000000000000000 -> 111111111111111111111111111111111
+dqinv009 invert 0000000000000000000000000000000000 -> 1111111111111111111111111111111111
+dqinv010 invert 0100000000000000000000000000000000 -> 1011111111111111111111111111111111
+dqinv011 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqinv012 invert 1111111111111111111111111111111111 -> 0
+dqinv013 invert 0011111111111111111111111111111111 -> 1100000000000000000000000000000000
+dqinv014 invert 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+
+-- Various lengths
+dqinv600 invert 0111111111111111111011111111111111 -> 1000000000000000000100000000000000
+dqinv601 invert 0011111111111111110101111111111111 -> 1100000000000000001010000000000000
+dqinv602 invert 0101111111111111101110111111111111 -> 1010000000000000010001000000000000
+dqinv603 invert 0110111111111111011111011111111111 -> 1001000000000000100000100000000000
+dqinv604 invert 0111011111111110111111101111111111 -> 1000100000000001000000010000000000
+dqinv605 invert 0111101111111101111111110111111111 -> 1000010000000010000000001000000000
+dqinv606 invert 0111110111111011111111111011111111 -> 1000001000000100000000000100000000
+dqinv607 invert 0111111011110111111111111101111111 -> 1000000100001000000000000010000000
+dqinv608 invert 0111111101101111111111111110111111 -> 1000000010010000000000000001000000
+dqinv609 invert 0111111110011111111111111111011111 -> 1000000001100000000000000000100000
+dqinv610 invert 0111111110011111111111111111101111 -> 1000000001100000000000000000010000
+dqinv611 invert 0111111101101111111111111111110111 -> 1000000010010000000000000000001000
+dqinv612 invert 0111111011110111111111111111111011 -> 1000000100001000000000000000000100
+dqinv613 invert 0111110111111011111111111111111101 -> 1000001000000100000000000000000010
+dqinv614 invert 0111101111111101111111111111111110 -> 1000010000000010000000000000000001
+dqinv615 invert 0111011111111110111111111111111111 -> 1000100000000001000000000000000000
+dqinv616 invert 0110111111111111011111111111111110 -> 1001000000000000100000000000000001
+dqinv617 invert 0101111111111111101111111111111101 -> 1010000000000000010000000000000010
+dqinv618 invert 0011111111111111110111111111111011 -> 1100000000000000001000000000000100
+dqinv619 invert 0101111111111111111011111111110111 -> 1010000000000000000100000000001000
+dqinv620 invert 0110111111111111111101111111101111 -> 1001000000000000000010000000010000
+dqinv621 invert 0111011111111111111110111111011111 -> 1000100000000000000001000000100000
+dqinv622 invert 0111101111111111111111011110111111 -> 1000010000000000000000100001000000
+dqinv623 invert 0111110111111111111111101101111111 -> 1000001000000000000000010010000000
+dqinv624 invert 0111111011111111111111110011111111 -> 1000000100000000000000001100000000
+dqinv625 invert 0111111101111111111111110011111111 -> 1000000010000000000000001100000000
+dqinv626 invert 0111111110111111111111101101111111 -> 1000000001000000000000010010000000
+dqinv627 invert 0111111111011111111111011110111111 -> 1000000000100000000000100001000000
+dqinv628 invert 0111111111101111111110111111011111 -> 1000000000010000000001000000100000
+dqinv629 invert 0111111111110111111101111111101111 -> 1000000000001000000010000000010000
+dqinv630 invert 0111111111111011111011111111110111 -> 1000000000000100000100000000001000
+dqinv631 invert 0111111111111101110111111111111011 -> 1000000000000010001000000000000100
+dqinv632 invert 0111111111111110101111111111111101 -> 1000000000000001010000000000000010
+dqinv633 invert 0111111111111111011111111111111110 -> 1000000000000000100000000000000001
+
+dqinv021 invert 111111111 -> 1111111111111111111111111000000000
+dqinv022 invert 111111111111 -> 1111111111111111111111000000000000
+dqinv023 invert 11111111 -> 1111111111111111111111111100000000
+dqinv025 invert 1111111 -> 1111111111111111111111111110000000
+dqinv026 invert 111111 -> 1111111111111111111111111111000000
+dqinv027 invert 11111 -> 1111111111111111111111111111100000
+dqinv028 invert 1111 -> 1111111111111111111111111111110000
+dqinv029 invert 111 -> 1111111111111111111111111111111000
+dqinv031 invert 11 -> 1111111111111111111111111111111100
+dqinv032 invert 1 -> 1111111111111111111111111111111110
+dqinv033 invert 111111111111 -> 1111111111111111111111000000000000
+dqinv034 invert 11111111111 -> 1111111111111111111111100000000000
+dqinv035 invert 1111111111 -> 1111111111111111111111110000000000
+dqinv036 invert 111111111 -> 1111111111111111111111111000000000
+
+dqinv040 invert 011111111 -> 1111111111111111111111111100000000
+dqinv041 invert 101111111 -> 1111111111111111111111111010000000
+dqinv042 invert 110111111 -> 1111111111111111111111111001000000
+dqinv043 invert 111011111 -> 1111111111111111111111111000100000
+dqinv044 invert 111101111 -> 1111111111111111111111111000010000
+dqinv045 invert 111110111 -> 1111111111111111111111111000001000
+dqinv046 invert 111111011 -> 1111111111111111111111111000000100
+dqinv047 invert 111111101 -> 1111111111111111111111111000000010
+dqinv048 invert 111111110 -> 1111111111111111111111111000000001
+dqinv049 invert 011111011 -> 1111111111111111111111111100000100
+dqinv050 invert 101111101 -> 1111111111111111111111111010000010
+dqinv051 invert 110111110 -> 1111111111111111111111111001000001
+dqinv052 invert 111011101 -> 1111111111111111111111111000100010
+dqinv053 invert 111101011 -> 1111111111111111111111111000010100
+dqinv054 invert 111110111 -> 1111111111111111111111111000001000
+dqinv055 invert 111101011 -> 1111111111111111111111111000010100
+dqinv056 invert 111011101 -> 1111111111111111111111111000100010
+dqinv057 invert 110111110 -> 1111111111111111111111111001000001
+dqinv058 invert 101111101 -> 1111111111111111111111111010000010
+dqinv059 invert 011111011 -> 1111111111111111111111111100000100
+
+dqinv080 invert 1000000011111111 -> 1111111111111111110111111100000000
+dqinv081 invert 0100000101111111 -> 1111111111111111111011111010000000
+dqinv082 invert 0010000110111111 -> 1111111111111111111101111001000000
+dqinv083 invert 0001000111011111 -> 1111111111111111111110111000100000
+dqinv084 invert 0000100111101111 -> 1111111111111111111111011000010000
+dqinv085 invert 0000010111110111 -> 1111111111111111111111101000001000
+dqinv086 invert 0000001111111011 -> 1111111111111111111111110000000100
+dqinv087 invert 0000010111111101 -> 1111111111111111111111101000000010
+dqinv088 invert 0000100111111110 -> 1111111111111111111111011000000001
+dqinv089 invert 0001000011111011 -> 1111111111111111111110111100000100
+dqinv090 invert 0010000101111101 -> 1111111111111111111101111010000010
+dqinv091 invert 0100000110111110 -> 1111111111111111111011111001000001
+dqinv092 invert 1000000111011101 -> 1111111111111111110111111000100010
+dqinv093 invert 0100000111101011 -> 1111111111111111111011111000010100
+dqinv094 invert 0010000111110111 -> 1111111111111111111101111000001000
+dqinv095 invert 0001000111101011 -> 1111111111111111111110111000010100
+dqinv096 invert 0000100111011101 -> 1111111111111111111111011000100010
+dqinv097 invert 0000010110111110 -> 1111111111111111111111101001000001
+dqinv098 invert 0000001101111101 -> 1111111111111111111111110010000010
+dqinv099 invert 0000010011111011 -> 1111111111111111111111101100000100
+
+-- and more thorough MSD/LSD tests [8 and 9 mght be encoded differently...]
+dqinv151 invert 1111111111111111111111111111111110 -> 1
+dqinv152 invert 1111111111111111110000000000000000 -> 1111111111111111
+dqinv153 invert 1000000000000000001111111111111111 -> 111111111111111110000000000000000
+dqinv154 invert 1111111111111111111000000000000000 -> 111111111111111
+dqinv155 invert 0100000000000000000111111111111111 -> 1011111111111111111000000000000000
+dqinv156 invert 1011111111111111110100000000000000 -> 100000000000000001011111111111111
+dqinv157 invert 1101111111111111110111111111111111 -> 10000000000000001000000000000000
+dqinv158 invert 1110111111111111110011111111111111 -> 1000000000000001100000000000000
+
+-- non-0/1 should not be accepted, nor should signs
+dqinv220 invert 111111112 -> NaN Invalid_operation
+dqinv221 invert 333333333 -> NaN Invalid_operation
+dqinv222 invert 555555555 -> NaN Invalid_operation
+dqinv223 invert 777777777 -> NaN Invalid_operation
+dqinv224 invert 999999999 -> NaN Invalid_operation
+dqinv225 invert 222222222 -> NaN Invalid_operation
+dqinv226 invert 444444444 -> NaN Invalid_operation
+dqinv227 invert 666666666 -> NaN Invalid_operation
+dqinv228 invert 888888888 -> NaN Invalid_operation
+dqinv229 invert 999999999 -> NaN Invalid_operation
+dqinv230 invert 999999999 -> NaN Invalid_operation
+dqinv231 invert 999999999 -> NaN Invalid_operation
+dqinv232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+dqinv240 invert 567468689 -> NaN Invalid_operation
+dqinv241 invert 567367689 -> NaN Invalid_operation
+dqinv242 invert -631917772 -> NaN Invalid_operation
+dqinv243 invert -756253257 -> NaN Invalid_operation
+dqinv244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+dqinv250 invert 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv251 invert 3000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv252 invert 4000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv253 invert 5000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv254 invert 6000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv255 invert 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv256 invert 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqinv257 invert 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqinv270 invert 0200000111000111000111001000000000 -> NaN Invalid_operation
+dqinv271 invert 0300000111000111000111000100000000 -> NaN Invalid_operation
+dqinv272 invert 0400000111000111000111000010000000 -> NaN Invalid_operation
+dqinv273 invert 0500000111000111000111000001000000 -> NaN Invalid_operation
+dqinv274 invert 1600000111000111000111000000100000 -> NaN Invalid_operation
+dqinv275 invert 1700000111000111000111000000010000 -> NaN Invalid_operation
+dqinv276 invert 1800000111000111000111000000001000 -> NaN Invalid_operation
+dqinv277 invert 1900000111000111000111000000000100 -> NaN Invalid_operation
+-- test LSD
+dqinv280 invert 0010000111000111000111000000000002 -> NaN Invalid_operation
+dqinv281 invert 0001000111000111000111000000000003 -> NaN Invalid_operation
+dqinv282 invert 0000000111000111000111100000000004 -> NaN Invalid_operation
+dqinv283 invert 0000000111000111000111010000000005 -> NaN Invalid_operation
+dqinv284 invert 1000000111000111000111001000000006 -> NaN Invalid_operation
+dqinv285 invert 1000000111000111000111000100000007 -> NaN Invalid_operation
+dqinv286 invert 1000000111000111000111000010000008 -> NaN Invalid_operation
+dqinv287 invert 1000000111000111000111000001000009 -> NaN Invalid_operation
+-- test Middie
+dqinv288 invert 0010000111000111000111000020000000 -> NaN Invalid_operation
+dqinv289 invert 0001000111000111000111000030000001 -> NaN Invalid_operation
+dqinv290 invert 0000000111000111000111100040000010 -> NaN Invalid_operation
+dqinv291 invert 0000000111000111000111010050000100 -> NaN Invalid_operation
+dqinv292 invert 1000000111000111000111001060001000 -> NaN Invalid_operation
+dqinv293 invert 1000000111000111000111000170010000 -> NaN Invalid_operation
+dqinv294 invert 1000000111000111000111000080100000 -> NaN Invalid_operation
+dqinv295 invert 1000000111000111000111000091000000 -> NaN Invalid_operation
+-- signs
+dqinv296 invert -1000000111000111000111000001000000 -> NaN Invalid_operation
+dqinv299 invert 1000000111000111000111000001000000 -> 111111000111000111000111110111111
+
+-- Nmax, Nmin, Ntiny-like
+dqinv341 invert 9.99999999E+2998 -> NaN Invalid_operation
+dqinv342 invert 1E-2998 -> NaN Invalid_operation
+dqinv343 invert 1.00000000E-2998 -> NaN Invalid_operation
+dqinv344 invert 1E-2078 -> NaN Invalid_operation
+dqinv345 invert -1E-2078 -> NaN Invalid_operation
+dqinv346 invert -1.00000000E-2998 -> NaN Invalid_operation
+dqinv347 invert -1E-2998 -> NaN Invalid_operation
+dqinv348 invert -9.99999999E+2998 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqinv361 invert 1.0 -> NaN Invalid_operation
+dqinv362 invert 1E+1 -> NaN Invalid_operation
+dqinv363 invert 0.0 -> NaN Invalid_operation
+dqinv364 invert 0E+1 -> NaN Invalid_operation
+dqinv365 invert 9.9 -> NaN Invalid_operation
+dqinv366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqinv788 invert -Inf -> NaN Invalid_operation
+dqinv794 invert Inf -> NaN Invalid_operation
+dqinv821 invert NaN -> NaN Invalid_operation
+dqinv841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+dqinv861 invert NaN1 -> NaN Invalid_operation
+dqinv862 invert +NaN2 -> NaN Invalid_operation
+dqinv863 invert NaN3 -> NaN Invalid_operation
+dqinv864 invert NaN4 -> NaN Invalid_operation
+dqinv865 invert NaN5 -> NaN Invalid_operation
+dqinv871 invert sNaN11 -> NaN Invalid_operation
+dqinv872 invert sNaN12 -> NaN Invalid_operation
+dqinv873 invert sNaN13 -> NaN Invalid_operation
+dqinv874 invert sNaN14 -> NaN Invalid_operation
+dqinv875 invert sNaN15 -> NaN Invalid_operation
+dqinv876 invert NaN16 -> NaN Invalid_operation
+dqinv881 invert +NaN25 -> NaN Invalid_operation
+dqinv882 invert -NaN26 -> NaN Invalid_operation
+dqinv883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqLogB.decTest b/Lib/test/decimaltestdata/dqLogB.decTest
index 449f3dcb8de..a18313dc012 100644
--- a/Lib/test/decimaltestdata/dqLogB.decTest
+++ b/Lib/test/decimaltestdata/dqLogB.decTest
@@ -1,160 +1,160 @@
-------------------------------------------------------------------------
--- dqLogB.decTest -- integral 754r adjusted exponent, for decQuads --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- basics
-dqlogb000 logb 0 -> -Infinity Division_by_zero
-dqlogb001 logb 1E-6176 -> -6176
-dqlogb002 logb 1E-6143 -> -6143
-dqlogb003 logb 0.001 -> -3
-dqlogb004 logb 0.03 -> -2
-dqlogb005 logb 1 -> 0
-dqlogb006 logb 2 -> 0
-dqlogb007 logb 2.5 -> 0
-dqlogb008 logb 2.50 -> 0
-dqlogb009 logb 2.500 -> 0
-dqlogb010 logb 10 -> 1
-dqlogb011 logb 70 -> 1
-dqlogb012 logb 100 -> 2
-dqlogb013 logb 250 -> 2
-dqlogb014 logb 9E+6144 -> 6144
-dqlogb015 logb +Infinity -> Infinity
-
--- negatives appear to be treated as positives
-dqlogb021 logb -0 -> -Infinity Division_by_zero
-dqlogb022 logb -1E-6176 -> -6176
-dqlogb023 logb -9E-6143 -> -6143
-dqlogb024 logb -0.001 -> -3
-dqlogb025 logb -1 -> 0
-dqlogb026 logb -2 -> 0
-dqlogb027 logb -10 -> 1
-dqlogb028 logb -70 -> 1
-dqlogb029 logb -100 -> 2
-dqlogb030 logb -9E+6144 -> 6144
-dqlogb031 logb -Infinity -> Infinity
-
--- zeros
-dqlogb111 logb 0 -> -Infinity Division_by_zero
-dqlogb112 logb -0 -> -Infinity Division_by_zero
-dqlogb113 logb 0E+4 -> -Infinity Division_by_zero
-dqlogb114 logb -0E+4 -> -Infinity Division_by_zero
-dqlogb115 logb 0.0000 -> -Infinity Division_by_zero
-dqlogb116 logb -0.0000 -> -Infinity Division_by_zero
-dqlogb117 logb 0E-141 -> -Infinity Division_by_zero
-dqlogb118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-dqlogb121 logb 268268268 -> 8
-dqlogb122 logb -268268268 -> 8
-dqlogb123 logb 134134134 -> 8
-dqlogb124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-dqlogb131 logb 9.999999999999999999999999999999999E+6144 -> 6144
-dqlogb132 logb 1E-6143 -> -6143
-dqlogb133 logb 1.000000000000000000000000000000000E-6143 -> -6143
-dqlogb134 logb 1E-6176 -> -6176
-
-dqlogb135 logb -1E-6176 -> -6176
-dqlogb136 logb -1.000000000000000000000000000000000E-6143 -> -6143
-dqlogb137 logb -1E-6143 -> -6143
-dqlogb1614 logb -9.999999999999999999999999999999999E+6144 -> 6144
-
--- ones
-dqlogb0061 logb 1 -> 0
-dqlogb0062 logb 1.0 -> 0
-dqlogb0063 logb 1.000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-dqlogb1100 logb 1 -> 0
-dqlogb1101 logb 10 -> 1
-dqlogb1102 logb 100 -> 2
-dqlogb1103 logb 1000 -> 3
-dqlogb1104 logb 10000 -> 4
-dqlogb1105 logb 100000 -> 5
-dqlogb1106 logb 1000000 -> 6
-dqlogb1107 logb 10000000 -> 7
-dqlogb1108 logb 100000000 -> 8
-dqlogb1109 logb 1000000000 -> 9
-dqlogb1110 logb 10000000000 -> 10
-dqlogb1111 logb 100000000000 -> 11
-dqlogb1112 logb 1000000000000 -> 12
-dqlogb1113 logb 0.00000000001 -> -11
-dqlogb1114 logb 0.0000000001 -> -10
-dqlogb1115 logb 0.000000001 -> -9
-dqlogb1116 logb 0.00000001 -> -8
-dqlogb1117 logb 0.0000001 -> -7
-dqlogb1118 logb 0.000001 -> -6
-dqlogb1119 logb 0.00001 -> -5
-dqlogb1120 logb 0.0001 -> -4
-dqlogb1121 logb 0.001 -> -3
-dqlogb1122 logb 0.01 -> -2
-dqlogb1123 logb 0.1 -> -1
-dqlogb1124 logb 1E-99 -> -99
-dqlogb1125 logb 1E-100 -> -100
-dqlogb1127 logb 1E-299 -> -299
-dqlogb1126 logb 1E-6143 -> -6143
-
--- suggestions from Ilan Nehama
-dqlogb1400 logb 10E-3 -> -2
-dqlogb1401 logb 10E-2 -> -1
-dqlogb1402 logb 100E-2 -> 0
-dqlogb1403 logb 1000E-2 -> 1
-dqlogb1404 logb 10000E-2 -> 2
-dqlogb1405 logb 10E-1 -> 0
-dqlogb1406 logb 100E-1 -> 1
-dqlogb1407 logb 1000E-1 -> 2
-dqlogb1408 logb 10000E-1 -> 3
-dqlogb1409 logb 10E0 -> 1
-dqlogb1410 logb 100E0 -> 2
-dqlogb1411 logb 1000E0 -> 3
-dqlogb1412 logb 10000E0 -> 4
-dqlogb1413 logb 10E1 -> 2
-dqlogb1414 logb 100E1 -> 3
-dqlogb1415 logb 1000E1 -> 4
-dqlogb1416 logb 10000E1 -> 5
-dqlogb1417 logb 10E2 -> 3
-dqlogb1418 logb 100E2 -> 4
-dqlogb1419 logb 1000E2 -> 5
-dqlogb1420 logb 10000E2 -> 6
-
--- special values
-dqlogb820 logb Infinity -> Infinity
-dqlogb821 logb 0 -> -Infinity Division_by_zero
-dqlogb822 logb NaN -> NaN
-dqlogb823 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-dqlogb824 logb sNaN123 -> NaN123 Invalid_operation
-dqlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
-dqlogb826 logb NaN456 -> NaN456
-dqlogb827 logb -NaN654 -> -NaN654
-dqlogb828 logb NaN1 -> NaN1
-
--- Null test
-dqlogb900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- dqLogB.decTest -- integral 754r adjusted exponent, for decQuads --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- basics
+dqlogb000 logb 0 -> -Infinity Division_by_zero
+dqlogb001 logb 1E-6176 -> -6176
+dqlogb002 logb 1E-6143 -> -6143
+dqlogb003 logb 0.001 -> -3
+dqlogb004 logb 0.03 -> -2
+dqlogb005 logb 1 -> 0
+dqlogb006 logb 2 -> 0
+dqlogb007 logb 2.5 -> 0
+dqlogb008 logb 2.50 -> 0
+dqlogb009 logb 2.500 -> 0
+dqlogb010 logb 10 -> 1
+dqlogb011 logb 70 -> 1
+dqlogb012 logb 100 -> 2
+dqlogb013 logb 250 -> 2
+dqlogb014 logb 9E+6144 -> 6144
+dqlogb015 logb +Infinity -> Infinity
+
+-- negatives appear to be treated as positives
+dqlogb021 logb -0 -> -Infinity Division_by_zero
+dqlogb022 logb -1E-6176 -> -6176
+dqlogb023 logb -9E-6143 -> -6143
+dqlogb024 logb -0.001 -> -3
+dqlogb025 logb -1 -> 0
+dqlogb026 logb -2 -> 0
+dqlogb027 logb -10 -> 1
+dqlogb028 logb -70 -> 1
+dqlogb029 logb -100 -> 2
+dqlogb030 logb -9E+6144 -> 6144
+dqlogb031 logb -Infinity -> Infinity
+
+-- zeros
+dqlogb111 logb 0 -> -Infinity Division_by_zero
+dqlogb112 logb -0 -> -Infinity Division_by_zero
+dqlogb113 logb 0E+4 -> -Infinity Division_by_zero
+dqlogb114 logb -0E+4 -> -Infinity Division_by_zero
+dqlogb115 logb 0.0000 -> -Infinity Division_by_zero
+dqlogb116 logb -0.0000 -> -Infinity Division_by_zero
+dqlogb117 logb 0E-141 -> -Infinity Division_by_zero
+dqlogb118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+dqlogb121 logb 268268268 -> 8
+dqlogb122 logb -268268268 -> 8
+dqlogb123 logb 134134134 -> 8
+dqlogb124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+dqlogb131 logb 9.999999999999999999999999999999999E+6144 -> 6144
+dqlogb132 logb 1E-6143 -> -6143
+dqlogb133 logb 1.000000000000000000000000000000000E-6143 -> -6143
+dqlogb134 logb 1E-6176 -> -6176
+
+dqlogb135 logb -1E-6176 -> -6176
+dqlogb136 logb -1.000000000000000000000000000000000E-6143 -> -6143
+dqlogb137 logb -1E-6143 -> -6143
+dqlogb1614 logb -9.999999999999999999999999999999999E+6144 -> 6144
+
+-- ones
+dqlogb0061 logb 1 -> 0
+dqlogb0062 logb 1.0 -> 0
+dqlogb0063 logb 1.000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+dqlogb1100 logb 1 -> 0
+dqlogb1101 logb 10 -> 1
+dqlogb1102 logb 100 -> 2
+dqlogb1103 logb 1000 -> 3
+dqlogb1104 logb 10000 -> 4
+dqlogb1105 logb 100000 -> 5
+dqlogb1106 logb 1000000 -> 6
+dqlogb1107 logb 10000000 -> 7
+dqlogb1108 logb 100000000 -> 8
+dqlogb1109 logb 1000000000 -> 9
+dqlogb1110 logb 10000000000 -> 10
+dqlogb1111 logb 100000000000 -> 11
+dqlogb1112 logb 1000000000000 -> 12
+dqlogb1113 logb 0.00000000001 -> -11
+dqlogb1114 logb 0.0000000001 -> -10
+dqlogb1115 logb 0.000000001 -> -9
+dqlogb1116 logb 0.00000001 -> -8
+dqlogb1117 logb 0.0000001 -> -7
+dqlogb1118 logb 0.000001 -> -6
+dqlogb1119 logb 0.00001 -> -5
+dqlogb1120 logb 0.0001 -> -4
+dqlogb1121 logb 0.001 -> -3
+dqlogb1122 logb 0.01 -> -2
+dqlogb1123 logb 0.1 -> -1
+dqlogb1124 logb 1E-99 -> -99
+dqlogb1125 logb 1E-100 -> -100
+dqlogb1127 logb 1E-299 -> -299
+dqlogb1126 logb 1E-6143 -> -6143
+
+-- suggestions from Ilan Nehama
+dqlogb1400 logb 10E-3 -> -2
+dqlogb1401 logb 10E-2 -> -1
+dqlogb1402 logb 100E-2 -> 0
+dqlogb1403 logb 1000E-2 -> 1
+dqlogb1404 logb 10000E-2 -> 2
+dqlogb1405 logb 10E-1 -> 0
+dqlogb1406 logb 100E-1 -> 1
+dqlogb1407 logb 1000E-1 -> 2
+dqlogb1408 logb 10000E-1 -> 3
+dqlogb1409 logb 10E0 -> 1
+dqlogb1410 logb 100E0 -> 2
+dqlogb1411 logb 1000E0 -> 3
+dqlogb1412 logb 10000E0 -> 4
+dqlogb1413 logb 10E1 -> 2
+dqlogb1414 logb 100E1 -> 3
+dqlogb1415 logb 1000E1 -> 4
+dqlogb1416 logb 10000E1 -> 5
+dqlogb1417 logb 10E2 -> 3
+dqlogb1418 logb 100E2 -> 4
+dqlogb1419 logb 1000E2 -> 5
+dqlogb1420 logb 10000E2 -> 6
+
+-- special values
+dqlogb820 logb Infinity -> Infinity
+dqlogb821 logb 0 -> -Infinity Division_by_zero
+dqlogb822 logb NaN -> NaN
+dqlogb823 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+dqlogb824 logb sNaN123 -> NaN123 Invalid_operation
+dqlogb825 logb -sNaN321 -> -NaN321 Invalid_operation
+dqlogb826 logb NaN456 -> NaN456
+dqlogb827 logb -NaN654 -> -NaN654
+dqlogb828 logb NaN1 -> NaN1
+
+-- Null test
+dqlogb900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/dqMax.decTest b/Lib/test/decimaltestdata/dqMax.decTest
index 162d4bda3d9..dc6a1ab8f8e 100644
--- a/Lib/test/decimaltestdata/dqMax.decTest
+++ b/Lib/test/decimaltestdata/dqMax.decTest
@@ -1,322 +1,322 @@
-------------------------------------------------------------------------
--- dqMax.decTest -- decQuad maxnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmax001 max -2 -2 -> -2
-dqmax002 max -2 -1 -> -1
-dqmax003 max -2 0 -> 0
-dqmax004 max -2 1 -> 1
-dqmax005 max -2 2 -> 2
-dqmax006 max -1 -2 -> -1
-dqmax007 max -1 -1 -> -1
-dqmax008 max -1 0 -> 0
-dqmax009 max -1 1 -> 1
-dqmax010 max -1 2 -> 2
-dqmax011 max 0 -2 -> 0
-dqmax012 max 0 -1 -> 0
-dqmax013 max 0 0 -> 0
-dqmax014 max 0 1 -> 1
-dqmax015 max 0 2 -> 2
-dqmax016 max 1 -2 -> 1
-dqmax017 max 1 -1 -> 1
-dqmax018 max 1 0 -> 1
-dqmax019 max 1 1 -> 1
-dqmax020 max 1 2 -> 2
-dqmax021 max 2 -2 -> 2
-dqmax022 max 2 -1 -> 2
-dqmax023 max 2 0 -> 2
-dqmax025 max 2 1 -> 2
-dqmax026 max 2 2 -> 2
-
--- extended zeros
-dqmax030 max 0 0 -> 0
-dqmax031 max 0 -0 -> 0
-dqmax032 max 0 -0.0 -> 0
-dqmax033 max 0 0.0 -> 0
-dqmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-dqmax035 max -0 -0 -> -0
-dqmax036 max -0 -0.0 -> -0.0
-dqmax037 max -0 0.0 -> 0.0
-dqmax038 max 0.0 0 -> 0
-dqmax039 max 0.0 -0 -> 0.0
-dqmax040 max 0.0 -0.0 -> 0.0
-dqmax041 max 0.0 0.0 -> 0.0
-dqmax042 max -0.0 0 -> 0
-dqmax043 max -0.0 -0 -> -0.0
-dqmax044 max -0.0 -0.0 -> -0.0
-dqmax045 max -0.0 0.0 -> 0.0
-
-dqmax050 max -0E1 0E1 -> 0E+1
-dqmax051 max -0E2 0E2 -> 0E+2
-dqmax052 max -0E2 0E1 -> 0E+1
-dqmax053 max -0E1 0E2 -> 0E+2
-dqmax054 max 0E1 -0E1 -> 0E+1
-dqmax055 max 0E2 -0E2 -> 0E+2
-dqmax056 max 0E2 -0E1 -> 0E+2
-dqmax057 max 0E1 -0E2 -> 0E+1
-
-dqmax058 max 0E1 0E1 -> 0E+1
-dqmax059 max 0E2 0E2 -> 0E+2
-dqmax060 max 0E2 0E1 -> 0E+2
-dqmax061 max 0E1 0E2 -> 0E+2
-dqmax062 max -0E1 -0E1 -> -0E+1
-dqmax063 max -0E2 -0E2 -> -0E+2
-dqmax064 max -0E2 -0E1 -> -0E+1
-dqmax065 max -0E1 -0E2 -> -0E+1
-
--- Specials
-dqmax090 max Inf -Inf -> Infinity
-dqmax091 max Inf -1000 -> Infinity
-dqmax092 max Inf -1 -> Infinity
-dqmax093 max Inf -0 -> Infinity
-dqmax094 max Inf 0 -> Infinity
-dqmax095 max Inf 1 -> Infinity
-dqmax096 max Inf 1000 -> Infinity
-dqmax097 max Inf Inf -> Infinity
-dqmax098 max -1000 Inf -> Infinity
-dqmax099 max -Inf Inf -> Infinity
-dqmax100 max -1 Inf -> Infinity
-dqmax101 max -0 Inf -> Infinity
-dqmax102 max 0 Inf -> Infinity
-dqmax103 max 1 Inf -> Infinity
-dqmax104 max 1000 Inf -> Infinity
-dqmax105 max Inf Inf -> Infinity
-
-dqmax120 max -Inf -Inf -> -Infinity
-dqmax121 max -Inf -1000 -> -1000
-dqmax122 max -Inf -1 -> -1
-dqmax123 max -Inf -0 -> -0
-dqmax124 max -Inf 0 -> 0
-dqmax125 max -Inf 1 -> 1
-dqmax126 max -Inf 1000 -> 1000
-dqmax127 max -Inf Inf -> Infinity
-dqmax128 max -Inf -Inf -> -Infinity
-dqmax129 max -1000 -Inf -> -1000
-dqmax130 max -1 -Inf -> -1
-dqmax131 max -0 -Inf -> -0
-dqmax132 max 0 -Inf -> 0
-dqmax133 max 1 -Inf -> 1
-dqmax134 max 1000 -Inf -> 1000
-dqmax135 max Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmax141 max NaN -Inf -> -Infinity
-dqmax142 max NaN -1000 -> -1000
-dqmax143 max NaN -1 -> -1
-dqmax144 max NaN -0 -> -0
-dqmax145 max NaN 0 -> 0
-dqmax146 max NaN 1 -> 1
-dqmax147 max NaN 1000 -> 1000
-dqmax148 max NaN Inf -> Infinity
-dqmax149 max NaN NaN -> NaN
-dqmax150 max -Inf NaN -> -Infinity
-dqmax151 max -1000 NaN -> -1000
-dqmax152 max -1 NaN -> -1
-dqmax153 max -0 NaN -> -0
-dqmax154 max 0 NaN -> 0
-dqmax155 max 1 NaN -> 1
-dqmax156 max 1000 NaN -> 1000
-dqmax157 max Inf NaN -> Infinity
-
-dqmax161 max sNaN -Inf -> NaN Invalid_operation
-dqmax162 max sNaN -1000 -> NaN Invalid_operation
-dqmax163 max sNaN -1 -> NaN Invalid_operation
-dqmax164 max sNaN -0 -> NaN Invalid_operation
-dqmax165 max sNaN 0 -> NaN Invalid_operation
-dqmax166 max sNaN 1 -> NaN Invalid_operation
-dqmax167 max sNaN 1000 -> NaN Invalid_operation
-dqmax168 max sNaN NaN -> NaN Invalid_operation
-dqmax169 max sNaN sNaN -> NaN Invalid_operation
-dqmax170 max NaN sNaN -> NaN Invalid_operation
-dqmax171 max -Inf sNaN -> NaN Invalid_operation
-dqmax172 max -1000 sNaN -> NaN Invalid_operation
-dqmax173 max -1 sNaN -> NaN Invalid_operation
-dqmax174 max -0 sNaN -> NaN Invalid_operation
-dqmax175 max 0 sNaN -> NaN Invalid_operation
-dqmax176 max 1 sNaN -> NaN Invalid_operation
-dqmax177 max 1000 sNaN -> NaN Invalid_operation
-dqmax178 max Inf sNaN -> NaN Invalid_operation
-dqmax179 max NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmax181 max NaN9 -Inf -> -Infinity
-dqmax182 max NaN8 9 -> 9
-dqmax183 max -NaN7 Inf -> Infinity
-
-dqmax184 max -NaN1 NaN11 -> -NaN1
-dqmax185 max NaN2 NaN12 -> NaN2
-dqmax186 max -NaN13 -NaN7 -> -NaN13
-dqmax187 max NaN14 -NaN5 -> NaN14
-
-dqmax188 max -Inf NaN4 -> -Infinity
-dqmax189 max -9 -NaN3 -> -9
-dqmax190 max Inf NaN2 -> Infinity
-
-dqmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
-dqmax192 max sNaN98 -1 -> NaN98 Invalid_operation
-dqmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
-dqmax197 max 0 sNaN91 -> NaN91 Invalid_operation
-dqmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmax199 max NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-dqmax221 max 12345678000 1 -> 12345678000
-dqmax222 max 1 12345678000 -> 12345678000
-dqmax223 max 1234567800 1 -> 1234567800
-dqmax224 max 1 1234567800 -> 1234567800
-dqmax225 max 1234567890 1 -> 1234567890
-dqmax226 max 1 1234567890 -> 1234567890
-dqmax227 max 1234567891 1 -> 1234567891
-dqmax228 max 1 1234567891 -> 1234567891
-dqmax229 max 12345678901 1 -> 12345678901
-dqmax230 max 1 12345678901 -> 12345678901
-dqmax231 max 1234567896 1 -> 1234567896
-dqmax232 max 1 1234567896 -> 1234567896
-dqmax233 max -1234567891 1 -> 1
-dqmax234 max 1 -1234567891 -> 1
-dqmax235 max -12345678901 1 -> 1
-dqmax236 max 1 -12345678901 -> 1
-dqmax237 max -1234567896 1 -> 1
-dqmax238 max 1 -1234567896 -> 1
-
--- from examples
-dqmax280 max '3' '2' -> '3'
-dqmax281 max '-10' '3' -> '3'
-dqmax282 max '1.0' '1' -> '1'
-dqmax283 max '1' '1.0' -> '1'
-dqmax284 max '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmax401 max Inf 1.1 -> Infinity
-dqmax402 max 1.1 1 -> 1.1
-dqmax403 max 1 1.0 -> 1
-dqmax404 max 1.0 0.1 -> 1.0
-dqmax405 max 0.1 0.10 -> 0.1
-dqmax406 max 0.10 0.100 -> 0.10
-dqmax407 max 0.10 0 -> 0.10
-dqmax408 max 0 0.0 -> 0
-dqmax409 max 0.0 -0 -> 0.0
-dqmax410 max 0.0 -0.0 -> 0.0
-dqmax411 max 0.00 -0.0 -> 0.00
-dqmax412 max 0.0 -0.00 -> 0.0
-dqmax413 max 0 -0.0 -> 0
-dqmax414 max 0 -0 -> 0
-dqmax415 max -0.0 -0 -> -0.0
-dqmax416 max -0 -0.100 -> -0
-dqmax417 max -0.100 -0.10 -> -0.100
-dqmax418 max -0.10 -0.1 -> -0.10
-dqmax419 max -0.1 -1.0 -> -0.1
-dqmax420 max -1.0 -1 -> -1.0
-dqmax421 max -1 -1.1 -> -1
-dqmax423 max -1.1 -Inf -> -1.1
--- same with operands reversed
-dqmax431 max 1.1 Inf -> Infinity
-dqmax432 max 1 1.1 -> 1.1
-dqmax433 max 1.0 1 -> 1
-dqmax434 max 0.1 1.0 -> 1.0
-dqmax435 max 0.10 0.1 -> 0.1
-dqmax436 max 0.100 0.10 -> 0.10
-dqmax437 max 0 0.10 -> 0.10
-dqmax438 max 0.0 0 -> 0
-dqmax439 max -0 0.0 -> 0.0
-dqmax440 max -0.0 0.0 -> 0.0
-dqmax441 max -0.0 0.00 -> 0.00
-dqmax442 max -0.00 0.0 -> 0.0
-dqmax443 max -0.0 0 -> 0
-dqmax444 max -0 0 -> 0
-dqmax445 max -0 -0.0 -> -0.0
-dqmax446 max -0.100 -0 -> -0
-dqmax447 max -0.10 -0.100 -> -0.100
-dqmax448 max -0.1 -0.10 -> -0.10
-dqmax449 max -1.0 -0.1 -> -0.1
-dqmax450 max -1 -1.0 -> -1.0
-dqmax451 max -1.1 -1 -> -1
-dqmax453 max -Inf -1.1 -> -1.1
--- largies
-dqmax460 max 1000 1E+3 -> 1E+3
-dqmax461 max 1E+3 1000 -> 1E+3
-dqmax462 max 1000 -1E+3 -> 1000
-dqmax463 max 1E+3 -1000 -> 1E+3
-dqmax464 max -1000 1E+3 -> 1E+3
-dqmax465 max -1E+3 1000 -> 1000
-dqmax466 max -1000 -1E+3 -> -1000
-dqmax467 max -1E+3 -1000 -> -1000
-
--- misalignment traps for little-endian
-dqmax471 max 1.0 0.1 -> 1.0
-dqmax472 max 0.1 1.0 -> 1.0
-dqmax473 max 10.0 0.1 -> 10.0
-dqmax474 max 0.1 10.0 -> 10.0
-dqmax475 max 100 1.0 -> 100
-dqmax476 max 1.0 100 -> 100
-dqmax477 max 1000 10.0 -> 1000
-dqmax478 max 10.0 1000 -> 1000
-dqmax479 max 10000 100.0 -> 10000
-dqmax480 max 100.0 10000 -> 10000
-dqmax481 max 100000 1000.0 -> 100000
-dqmax482 max 1000.0 100000 -> 100000
-dqmax483 max 1000000 10000.0 -> 1000000
-dqmax484 max 10000.0 1000000 -> 1000000
-
--- subnormals
-dqmax510 max 1.00E-6143 0 -> 1.00E-6143
-dqmax511 max 0.1E-6143 0 -> 1E-6144 Subnormal
-dqmax512 max 0.10E-6143 0 -> 1.0E-6144 Subnormal
-dqmax513 max 0.100E-6143 0 -> 1.00E-6144 Subnormal
-dqmax514 max 0.01E-6143 0 -> 1E-6145 Subnormal
-dqmax515 max 0.999E-6143 0 -> 9.99E-6144 Subnormal
-dqmax516 max 0.099E-6143 0 -> 9.9E-6145 Subnormal
-dqmax517 max 0.009E-6143 0 -> 9E-6146 Subnormal
-dqmax518 max 0.001E-6143 0 -> 1E-6146 Subnormal
-dqmax519 max 0.0009E-6143 0 -> 9E-6147 Subnormal
-dqmax520 max 0.0001E-6143 0 -> 1E-6147 Subnormal
-
-dqmax530 max -1.00E-6143 0 -> 0
-dqmax531 max -0.1E-6143 0 -> 0
-dqmax532 max -0.10E-6143 0 -> 0
-dqmax533 max -0.100E-6143 0 -> 0
-dqmax534 max -0.01E-6143 0 -> 0
-dqmax535 max -0.999E-6143 0 -> 0
-dqmax536 max -0.099E-6143 0 -> 0
-dqmax537 max -0.009E-6143 0 -> 0
-dqmax538 max -0.001E-6143 0 -> 0
-dqmax539 max -0.0009E-6143 0 -> 0
-dqmax540 max -0.0001E-6143 0 -> 0
-
--- Null tests
-dqmax900 max 10 # -> NaN Invalid_operation
-dqmax901 max # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- dqMax.decTest -- decQuad maxnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmax001 max -2 -2 -> -2
+dqmax002 max -2 -1 -> -1
+dqmax003 max -2 0 -> 0
+dqmax004 max -2 1 -> 1
+dqmax005 max -2 2 -> 2
+dqmax006 max -1 -2 -> -1
+dqmax007 max -1 -1 -> -1
+dqmax008 max -1 0 -> 0
+dqmax009 max -1 1 -> 1
+dqmax010 max -1 2 -> 2
+dqmax011 max 0 -2 -> 0
+dqmax012 max 0 -1 -> 0
+dqmax013 max 0 0 -> 0
+dqmax014 max 0 1 -> 1
+dqmax015 max 0 2 -> 2
+dqmax016 max 1 -2 -> 1
+dqmax017 max 1 -1 -> 1
+dqmax018 max 1 0 -> 1
+dqmax019 max 1 1 -> 1
+dqmax020 max 1 2 -> 2
+dqmax021 max 2 -2 -> 2
+dqmax022 max 2 -1 -> 2
+dqmax023 max 2 0 -> 2
+dqmax025 max 2 1 -> 2
+dqmax026 max 2 2 -> 2
+
+-- extended zeros
+dqmax030 max 0 0 -> 0
+dqmax031 max 0 -0 -> 0
+dqmax032 max 0 -0.0 -> 0
+dqmax033 max 0 0.0 -> 0
+dqmax034 max -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+dqmax035 max -0 -0 -> -0
+dqmax036 max -0 -0.0 -> -0.0
+dqmax037 max -0 0.0 -> 0.0
+dqmax038 max 0.0 0 -> 0
+dqmax039 max 0.0 -0 -> 0.0
+dqmax040 max 0.0 -0.0 -> 0.0
+dqmax041 max 0.0 0.0 -> 0.0
+dqmax042 max -0.0 0 -> 0
+dqmax043 max -0.0 -0 -> -0.0
+dqmax044 max -0.0 -0.0 -> -0.0
+dqmax045 max -0.0 0.0 -> 0.0
+
+dqmax050 max -0E1 0E1 -> 0E+1
+dqmax051 max -0E2 0E2 -> 0E+2
+dqmax052 max -0E2 0E1 -> 0E+1
+dqmax053 max -0E1 0E2 -> 0E+2
+dqmax054 max 0E1 -0E1 -> 0E+1
+dqmax055 max 0E2 -0E2 -> 0E+2
+dqmax056 max 0E2 -0E1 -> 0E+2
+dqmax057 max 0E1 -0E2 -> 0E+1
+
+dqmax058 max 0E1 0E1 -> 0E+1
+dqmax059 max 0E2 0E2 -> 0E+2
+dqmax060 max 0E2 0E1 -> 0E+2
+dqmax061 max 0E1 0E2 -> 0E+2
+dqmax062 max -0E1 -0E1 -> -0E+1
+dqmax063 max -0E2 -0E2 -> -0E+2
+dqmax064 max -0E2 -0E1 -> -0E+1
+dqmax065 max -0E1 -0E2 -> -0E+1
+
+-- Specials
+dqmax090 max Inf -Inf -> Infinity
+dqmax091 max Inf -1000 -> Infinity
+dqmax092 max Inf -1 -> Infinity
+dqmax093 max Inf -0 -> Infinity
+dqmax094 max Inf 0 -> Infinity
+dqmax095 max Inf 1 -> Infinity
+dqmax096 max Inf 1000 -> Infinity
+dqmax097 max Inf Inf -> Infinity
+dqmax098 max -1000 Inf -> Infinity
+dqmax099 max -Inf Inf -> Infinity
+dqmax100 max -1 Inf -> Infinity
+dqmax101 max -0 Inf -> Infinity
+dqmax102 max 0 Inf -> Infinity
+dqmax103 max 1 Inf -> Infinity
+dqmax104 max 1000 Inf -> Infinity
+dqmax105 max Inf Inf -> Infinity
+
+dqmax120 max -Inf -Inf -> -Infinity
+dqmax121 max -Inf -1000 -> -1000
+dqmax122 max -Inf -1 -> -1
+dqmax123 max -Inf -0 -> -0
+dqmax124 max -Inf 0 -> 0
+dqmax125 max -Inf 1 -> 1
+dqmax126 max -Inf 1000 -> 1000
+dqmax127 max -Inf Inf -> Infinity
+dqmax128 max -Inf -Inf -> -Infinity
+dqmax129 max -1000 -Inf -> -1000
+dqmax130 max -1 -Inf -> -1
+dqmax131 max -0 -Inf -> -0
+dqmax132 max 0 -Inf -> 0
+dqmax133 max 1 -Inf -> 1
+dqmax134 max 1000 -Inf -> 1000
+dqmax135 max Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmax141 max NaN -Inf -> -Infinity
+dqmax142 max NaN -1000 -> -1000
+dqmax143 max NaN -1 -> -1
+dqmax144 max NaN -0 -> -0
+dqmax145 max NaN 0 -> 0
+dqmax146 max NaN 1 -> 1
+dqmax147 max NaN 1000 -> 1000
+dqmax148 max NaN Inf -> Infinity
+dqmax149 max NaN NaN -> NaN
+dqmax150 max -Inf NaN -> -Infinity
+dqmax151 max -1000 NaN -> -1000
+dqmax152 max -1 NaN -> -1
+dqmax153 max -0 NaN -> -0
+dqmax154 max 0 NaN -> 0
+dqmax155 max 1 NaN -> 1
+dqmax156 max 1000 NaN -> 1000
+dqmax157 max Inf NaN -> Infinity
+
+dqmax161 max sNaN -Inf -> NaN Invalid_operation
+dqmax162 max sNaN -1000 -> NaN Invalid_operation
+dqmax163 max sNaN -1 -> NaN Invalid_operation
+dqmax164 max sNaN -0 -> NaN Invalid_operation
+dqmax165 max sNaN 0 -> NaN Invalid_operation
+dqmax166 max sNaN 1 -> NaN Invalid_operation
+dqmax167 max sNaN 1000 -> NaN Invalid_operation
+dqmax168 max sNaN NaN -> NaN Invalid_operation
+dqmax169 max sNaN sNaN -> NaN Invalid_operation
+dqmax170 max NaN sNaN -> NaN Invalid_operation
+dqmax171 max -Inf sNaN -> NaN Invalid_operation
+dqmax172 max -1000 sNaN -> NaN Invalid_operation
+dqmax173 max -1 sNaN -> NaN Invalid_operation
+dqmax174 max -0 sNaN -> NaN Invalid_operation
+dqmax175 max 0 sNaN -> NaN Invalid_operation
+dqmax176 max 1 sNaN -> NaN Invalid_operation
+dqmax177 max 1000 sNaN -> NaN Invalid_operation
+dqmax178 max Inf sNaN -> NaN Invalid_operation
+dqmax179 max NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmax181 max NaN9 -Inf -> -Infinity
+dqmax182 max NaN8 9 -> 9
+dqmax183 max -NaN7 Inf -> Infinity
+
+dqmax184 max -NaN1 NaN11 -> -NaN1
+dqmax185 max NaN2 NaN12 -> NaN2
+dqmax186 max -NaN13 -NaN7 -> -NaN13
+dqmax187 max NaN14 -NaN5 -> NaN14
+
+dqmax188 max -Inf NaN4 -> -Infinity
+dqmax189 max -9 -NaN3 -> -9
+dqmax190 max Inf NaN2 -> Infinity
+
+dqmax191 max sNaN99 -Inf -> NaN99 Invalid_operation
+dqmax192 max sNaN98 -1 -> NaN98 Invalid_operation
+dqmax193 max -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmax194 max sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqmax195 max NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmax196 max -Inf sNaN92 -> NaN92 Invalid_operation
+dqmax197 max 0 sNaN91 -> NaN91 Invalid_operation
+dqmax198 max Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmax199 max NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+dqmax221 max 12345678000 1 -> 12345678000
+dqmax222 max 1 12345678000 -> 12345678000
+dqmax223 max 1234567800 1 -> 1234567800
+dqmax224 max 1 1234567800 -> 1234567800
+dqmax225 max 1234567890 1 -> 1234567890
+dqmax226 max 1 1234567890 -> 1234567890
+dqmax227 max 1234567891 1 -> 1234567891
+dqmax228 max 1 1234567891 -> 1234567891
+dqmax229 max 12345678901 1 -> 12345678901
+dqmax230 max 1 12345678901 -> 12345678901
+dqmax231 max 1234567896 1 -> 1234567896
+dqmax232 max 1 1234567896 -> 1234567896
+dqmax233 max -1234567891 1 -> 1
+dqmax234 max 1 -1234567891 -> 1
+dqmax235 max -12345678901 1 -> 1
+dqmax236 max 1 -12345678901 -> 1
+dqmax237 max -1234567896 1 -> 1
+dqmax238 max 1 -1234567896 -> 1
+
+-- from examples
+dqmax280 max '3' '2' -> '3'
+dqmax281 max '-10' '3' -> '3'
+dqmax282 max '1.0' '1' -> '1'
+dqmax283 max '1' '1.0' -> '1'
+dqmax284 max '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmax401 max Inf 1.1 -> Infinity
+dqmax402 max 1.1 1 -> 1.1
+dqmax403 max 1 1.0 -> 1
+dqmax404 max 1.0 0.1 -> 1.0
+dqmax405 max 0.1 0.10 -> 0.1
+dqmax406 max 0.10 0.100 -> 0.10
+dqmax407 max 0.10 0 -> 0.10
+dqmax408 max 0 0.0 -> 0
+dqmax409 max 0.0 -0 -> 0.0
+dqmax410 max 0.0 -0.0 -> 0.0
+dqmax411 max 0.00 -0.0 -> 0.00
+dqmax412 max 0.0 -0.00 -> 0.0
+dqmax413 max 0 -0.0 -> 0
+dqmax414 max 0 -0 -> 0
+dqmax415 max -0.0 -0 -> -0.0
+dqmax416 max -0 -0.100 -> -0
+dqmax417 max -0.100 -0.10 -> -0.100
+dqmax418 max -0.10 -0.1 -> -0.10
+dqmax419 max -0.1 -1.0 -> -0.1
+dqmax420 max -1.0 -1 -> -1.0
+dqmax421 max -1 -1.1 -> -1
+dqmax423 max -1.1 -Inf -> -1.1
+-- same with operands reversed
+dqmax431 max 1.1 Inf -> Infinity
+dqmax432 max 1 1.1 -> 1.1
+dqmax433 max 1.0 1 -> 1
+dqmax434 max 0.1 1.0 -> 1.0
+dqmax435 max 0.10 0.1 -> 0.1
+dqmax436 max 0.100 0.10 -> 0.10
+dqmax437 max 0 0.10 -> 0.10
+dqmax438 max 0.0 0 -> 0
+dqmax439 max -0 0.0 -> 0.0
+dqmax440 max -0.0 0.0 -> 0.0
+dqmax441 max -0.0 0.00 -> 0.00
+dqmax442 max -0.00 0.0 -> 0.0
+dqmax443 max -0.0 0 -> 0
+dqmax444 max -0 0 -> 0
+dqmax445 max -0 -0.0 -> -0.0
+dqmax446 max -0.100 -0 -> -0
+dqmax447 max -0.10 -0.100 -> -0.100
+dqmax448 max -0.1 -0.10 -> -0.10
+dqmax449 max -1.0 -0.1 -> -0.1
+dqmax450 max -1 -1.0 -> -1.0
+dqmax451 max -1.1 -1 -> -1
+dqmax453 max -Inf -1.1 -> -1.1
+-- largies
+dqmax460 max 1000 1E+3 -> 1E+3
+dqmax461 max 1E+3 1000 -> 1E+3
+dqmax462 max 1000 -1E+3 -> 1000
+dqmax463 max 1E+3 -1000 -> 1E+3
+dqmax464 max -1000 1E+3 -> 1E+3
+dqmax465 max -1E+3 1000 -> 1000
+dqmax466 max -1000 -1E+3 -> -1000
+dqmax467 max -1E+3 -1000 -> -1000
+
+-- misalignment traps for little-endian
+dqmax471 max 1.0 0.1 -> 1.0
+dqmax472 max 0.1 1.0 -> 1.0
+dqmax473 max 10.0 0.1 -> 10.0
+dqmax474 max 0.1 10.0 -> 10.0
+dqmax475 max 100 1.0 -> 100
+dqmax476 max 1.0 100 -> 100
+dqmax477 max 1000 10.0 -> 1000
+dqmax478 max 10.0 1000 -> 1000
+dqmax479 max 10000 100.0 -> 10000
+dqmax480 max 100.0 10000 -> 10000
+dqmax481 max 100000 1000.0 -> 100000
+dqmax482 max 1000.0 100000 -> 100000
+dqmax483 max 1000000 10000.0 -> 1000000
+dqmax484 max 10000.0 1000000 -> 1000000
+
+-- subnormals
+dqmax510 max 1.00E-6143 0 -> 1.00E-6143
+dqmax511 max 0.1E-6143 0 -> 1E-6144 Subnormal
+dqmax512 max 0.10E-6143 0 -> 1.0E-6144 Subnormal
+dqmax513 max 0.100E-6143 0 -> 1.00E-6144 Subnormal
+dqmax514 max 0.01E-6143 0 -> 1E-6145 Subnormal
+dqmax515 max 0.999E-6143 0 -> 9.99E-6144 Subnormal
+dqmax516 max 0.099E-6143 0 -> 9.9E-6145 Subnormal
+dqmax517 max 0.009E-6143 0 -> 9E-6146 Subnormal
+dqmax518 max 0.001E-6143 0 -> 1E-6146 Subnormal
+dqmax519 max 0.0009E-6143 0 -> 9E-6147 Subnormal
+dqmax520 max 0.0001E-6143 0 -> 1E-6147 Subnormal
+
+dqmax530 max -1.00E-6143 0 -> 0
+dqmax531 max -0.1E-6143 0 -> 0
+dqmax532 max -0.10E-6143 0 -> 0
+dqmax533 max -0.100E-6143 0 -> 0
+dqmax534 max -0.01E-6143 0 -> 0
+dqmax535 max -0.999E-6143 0 -> 0
+dqmax536 max -0.099E-6143 0 -> 0
+dqmax537 max -0.009E-6143 0 -> 0
+dqmax538 max -0.001E-6143 0 -> 0
+dqmax539 max -0.0009E-6143 0 -> 0
+dqmax540 max -0.0001E-6143 0 -> 0
+
+-- Null tests
+dqmax900 max 10 # -> NaN Invalid_operation
+dqmax901 max # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/dqMaxMag.decTest b/Lib/test/decimaltestdata/dqMaxMag.decTest
index 6621e80d92b..6f5be246097 100644
--- a/Lib/test/decimaltestdata/dqMaxMag.decTest
+++ b/Lib/test/decimaltestdata/dqMaxMag.decTest
@@ -1,304 +1,304 @@
-------------------------------------------------------------------------
--- dqMaxMag.decTest -- decQuad maxnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmxg001 maxmag -2 -2 -> -2
-dqmxg002 maxmag -2 -1 -> -2
-dqmxg003 maxmag -2 0 -> -2
-dqmxg004 maxmag -2 1 -> -2
-dqmxg005 maxmag -2 2 -> 2
-dqmxg006 maxmag -1 -2 -> -2
-dqmxg007 maxmag -1 -1 -> -1
-dqmxg008 maxmag -1 0 -> -1
-dqmxg009 maxmag -1 1 -> 1
-dqmxg010 maxmag -1 2 -> 2
-dqmxg011 maxmag 0 -2 -> -2
-dqmxg012 maxmag 0 -1 -> -1
-dqmxg013 maxmag 0 0 -> 0
-dqmxg014 maxmag 0 1 -> 1
-dqmxg015 maxmag 0 2 -> 2
-dqmxg016 maxmag 1 -2 -> -2
-dqmxg017 maxmag 1 -1 -> 1
-dqmxg018 maxmag 1 0 -> 1
-dqmxg019 maxmag 1 1 -> 1
-dqmxg020 maxmag 1 2 -> 2
-dqmxg021 maxmag 2 -2 -> 2
-dqmxg022 maxmag 2 -1 -> 2
-dqmxg023 maxmag 2 0 -> 2
-dqmxg025 maxmag 2 1 -> 2
-dqmxg026 maxmag 2 2 -> 2
-
--- extended zeros
-dqmxg030 maxmag 0 0 -> 0
-dqmxg031 maxmag 0 -0 -> 0
-dqmxg032 maxmag 0 -0.0 -> 0
-dqmxg033 maxmag 0 0.0 -> 0
-dqmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-dqmxg035 maxmag -0 -0 -> -0
-dqmxg036 maxmag -0 -0.0 -> -0.0
-dqmxg037 maxmag -0 0.0 -> 0.0
-dqmxg038 maxmag 0.0 0 -> 0
-dqmxg039 maxmag 0.0 -0 -> 0.0
-dqmxg040 maxmag 0.0 -0.0 -> 0.0
-dqmxg041 maxmag 0.0 0.0 -> 0.0
-dqmxg042 maxmag -0.0 0 -> 0
-dqmxg043 maxmag -0.0 -0 -> -0.0
-dqmxg044 maxmag -0.0 -0.0 -> -0.0
-dqmxg045 maxmag -0.0 0.0 -> 0.0
-
-dqmxg050 maxmag -0E1 0E1 -> 0E+1
-dqmxg051 maxmag -0E2 0E2 -> 0E+2
-dqmxg052 maxmag -0E2 0E1 -> 0E+1
-dqmxg053 maxmag -0E1 0E2 -> 0E+2
-dqmxg054 maxmag 0E1 -0E1 -> 0E+1
-dqmxg055 maxmag 0E2 -0E2 -> 0E+2
-dqmxg056 maxmag 0E2 -0E1 -> 0E+2
-dqmxg057 maxmag 0E1 -0E2 -> 0E+1
-
-dqmxg058 maxmag 0E1 0E1 -> 0E+1
-dqmxg059 maxmag 0E2 0E2 -> 0E+2
-dqmxg060 maxmag 0E2 0E1 -> 0E+2
-dqmxg061 maxmag 0E1 0E2 -> 0E+2
-dqmxg062 maxmag -0E1 -0E1 -> -0E+1
-dqmxg063 maxmag -0E2 -0E2 -> -0E+2
-dqmxg064 maxmag -0E2 -0E1 -> -0E+1
-dqmxg065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-dqmxg090 maxmag Inf -Inf -> Infinity
-dqmxg091 maxmag Inf -1000 -> Infinity
-dqmxg092 maxmag Inf -1 -> Infinity
-dqmxg093 maxmag Inf -0 -> Infinity
-dqmxg094 maxmag Inf 0 -> Infinity
-dqmxg095 maxmag Inf 1 -> Infinity
-dqmxg096 maxmag Inf 1000 -> Infinity
-dqmxg097 maxmag Inf Inf -> Infinity
-dqmxg098 maxmag -1000 Inf -> Infinity
-dqmxg099 maxmag -Inf Inf -> Infinity
-dqmxg100 maxmag -1 Inf -> Infinity
-dqmxg101 maxmag -0 Inf -> Infinity
-dqmxg102 maxmag 0 Inf -> Infinity
-dqmxg103 maxmag 1 Inf -> Infinity
-dqmxg104 maxmag 1000 Inf -> Infinity
-dqmxg105 maxmag Inf Inf -> Infinity
-
-dqmxg120 maxmag -Inf -Inf -> -Infinity
-dqmxg121 maxmag -Inf -1000 -> -Infinity
-dqmxg122 maxmag -Inf -1 -> -Infinity
-dqmxg123 maxmag -Inf -0 -> -Infinity
-dqmxg124 maxmag -Inf 0 -> -Infinity
-dqmxg125 maxmag -Inf 1 -> -Infinity
-dqmxg126 maxmag -Inf 1000 -> -Infinity
-dqmxg127 maxmag -Inf Inf -> Infinity
-dqmxg128 maxmag -Inf -Inf -> -Infinity
-dqmxg129 maxmag -1000 -Inf -> -Infinity
-dqmxg130 maxmag -1 -Inf -> -Infinity
-dqmxg131 maxmag -0 -Inf -> -Infinity
-dqmxg132 maxmag 0 -Inf -> -Infinity
-dqmxg133 maxmag 1 -Inf -> -Infinity
-dqmxg134 maxmag 1000 -Inf -> -Infinity
-dqmxg135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmxg141 maxmag NaN -Inf -> -Infinity
-dqmxg142 maxmag NaN -1000 -> -1000
-dqmxg143 maxmag NaN -1 -> -1
-dqmxg144 maxmag NaN -0 -> -0
-dqmxg145 maxmag NaN 0 -> 0
-dqmxg146 maxmag NaN 1 -> 1
-dqmxg147 maxmag NaN 1000 -> 1000
-dqmxg148 maxmag NaN Inf -> Infinity
-dqmxg149 maxmag NaN NaN -> NaN
-dqmxg150 maxmag -Inf NaN -> -Infinity
-dqmxg151 maxmag -1000 NaN -> -1000
-dqmxg152 maxmag -1 NaN -> -1
-dqmxg153 maxmag -0 NaN -> -0
-dqmxg154 maxmag 0 NaN -> 0
-dqmxg155 maxmag 1 NaN -> 1
-dqmxg156 maxmag 1000 NaN -> 1000
-dqmxg157 maxmag Inf NaN -> Infinity
-
-dqmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
-dqmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
-dqmxg163 maxmag sNaN -1 -> NaN Invalid_operation
-dqmxg164 maxmag sNaN -0 -> NaN Invalid_operation
-dqmxg165 maxmag sNaN 0 -> NaN Invalid_operation
-dqmxg166 maxmag sNaN 1 -> NaN Invalid_operation
-dqmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
-dqmxg168 maxmag sNaN NaN -> NaN Invalid_operation
-dqmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
-dqmxg170 maxmag NaN sNaN -> NaN Invalid_operation
-dqmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
-dqmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
-dqmxg173 maxmag -1 sNaN -> NaN Invalid_operation
-dqmxg174 maxmag -0 sNaN -> NaN Invalid_operation
-dqmxg175 maxmag 0 sNaN -> NaN Invalid_operation
-dqmxg176 maxmag 1 sNaN -> NaN Invalid_operation
-dqmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
-dqmxg178 maxmag Inf sNaN -> NaN Invalid_operation
-dqmxg179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmxg181 maxmag NaN9 -Inf -> -Infinity
-dqmxg182 maxmag NaN8 9 -> 9
-dqmxg183 maxmag -NaN7 Inf -> Infinity
-
-dqmxg184 maxmag -NaN1 NaN11 -> -NaN1
-dqmxg185 maxmag NaN2 NaN12 -> NaN2
-dqmxg186 maxmag -NaN13 -NaN7 -> -NaN13
-dqmxg187 maxmag NaN14 -NaN5 -> NaN14
-
-dqmxg188 maxmag -Inf NaN4 -> -Infinity
-dqmxg189 maxmag -9 -NaN3 -> -9
-dqmxg190 maxmag Inf NaN2 -> Infinity
-
-dqmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-dqmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-dqmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-dqmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-dqmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-dqmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- old rounding checks
-dqmxg221 maxmag 12345678000 1 -> 12345678000
-dqmxg222 maxmag 1 12345678000 -> 12345678000
-dqmxg223 maxmag 1234567800 1 -> 1234567800
-dqmxg224 maxmag 1 1234567800 -> 1234567800
-dqmxg225 maxmag 1234567890 1 -> 1234567890
-dqmxg226 maxmag 1 1234567890 -> 1234567890
-dqmxg227 maxmag 1234567891 1 -> 1234567891
-dqmxg228 maxmag 1 1234567891 -> 1234567891
-dqmxg229 maxmag 12345678901 1 -> 12345678901
-dqmxg230 maxmag 1 12345678901 -> 12345678901
-dqmxg231 maxmag 1234567896 1 -> 1234567896
-dqmxg232 maxmag 1 1234567896 -> 1234567896
-dqmxg233 maxmag -1234567891 1 -> -1234567891
-dqmxg234 maxmag 1 -1234567891 -> -1234567891
-dqmxg235 maxmag -12345678901 1 -> -12345678901
-dqmxg236 maxmag 1 -12345678901 -> -12345678901
-dqmxg237 maxmag -1234567896 1 -> -1234567896
-dqmxg238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-dqmxg280 maxmag '3' '2' -> '3'
-dqmxg281 maxmag '-10' '3' -> '-10'
-dqmxg282 maxmag '1.0' '1' -> '1'
-dqmxg283 maxmag '1' '1.0' -> '1'
-dqmxg284 maxmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmxg401 maxmag Inf 1.1 -> Infinity
-dqmxg402 maxmag 1.1 1 -> 1.1
-dqmxg403 maxmag 1 1.0 -> 1
-dqmxg404 maxmag 1.0 0.1 -> 1.0
-dqmxg405 maxmag 0.1 0.10 -> 0.1
-dqmxg406 maxmag 0.10 0.100 -> 0.10
-dqmxg407 maxmag 0.10 0 -> 0.10
-dqmxg408 maxmag 0 0.0 -> 0
-dqmxg409 maxmag 0.0 -0 -> 0.0
-dqmxg410 maxmag 0.0 -0.0 -> 0.0
-dqmxg411 maxmag 0.00 -0.0 -> 0.00
-dqmxg412 maxmag 0.0 -0.00 -> 0.0
-dqmxg413 maxmag 0 -0.0 -> 0
-dqmxg414 maxmag 0 -0 -> 0
-dqmxg415 maxmag -0.0 -0 -> -0.0
-dqmxg416 maxmag -0 -0.100 -> -0.100
-dqmxg417 maxmag -0.100 -0.10 -> -0.100
-dqmxg418 maxmag -0.10 -0.1 -> -0.10
-dqmxg419 maxmag -0.1 -1.0 -> -1.0
-dqmxg420 maxmag -1.0 -1 -> -1.0
-dqmxg421 maxmag -1 -1.1 -> -1.1
-dqmxg423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-dqmxg431 maxmag 1.1 Inf -> Infinity
-dqmxg432 maxmag 1 1.1 -> 1.1
-dqmxg433 maxmag 1.0 1 -> 1
-dqmxg434 maxmag 0.1 1.0 -> 1.0
-dqmxg435 maxmag 0.10 0.1 -> 0.1
-dqmxg436 maxmag 0.100 0.10 -> 0.10
-dqmxg437 maxmag 0 0.10 -> 0.10
-dqmxg438 maxmag 0.0 0 -> 0
-dqmxg439 maxmag -0 0.0 -> 0.0
-dqmxg440 maxmag -0.0 0.0 -> 0.0
-dqmxg441 maxmag -0.0 0.00 -> 0.00
-dqmxg442 maxmag -0.00 0.0 -> 0.0
-dqmxg443 maxmag -0.0 0 -> 0
-dqmxg444 maxmag -0 0 -> 0
-dqmxg445 maxmag -0 -0.0 -> -0.0
-dqmxg446 maxmag -0.100 -0 -> -0.100
-dqmxg447 maxmag -0.10 -0.100 -> -0.100
-dqmxg448 maxmag -0.1 -0.10 -> -0.10
-dqmxg449 maxmag -1.0 -0.1 -> -1.0
-dqmxg450 maxmag -1 -1.0 -> -1.0
-dqmxg451 maxmag -1.1 -1 -> -1.1
-dqmxg453 maxmag -Inf -1.1 -> -Infinity
--- largies
-dqmxg460 maxmag 1000 1E+3 -> 1E+3
-dqmxg461 maxmag 1E+3 1000 -> 1E+3
-dqmxg462 maxmag 1000 -1E+3 -> 1000
-dqmxg463 maxmag 1E+3 -1000 -> 1E+3
-dqmxg464 maxmag -1000 1E+3 -> 1E+3
-dqmxg465 maxmag -1E+3 1000 -> 1000
-dqmxg466 maxmag -1000 -1E+3 -> -1000
-dqmxg467 maxmag -1E+3 -1000 -> -1000
-
--- subnormals
-dqmxg510 maxmag 1.00E-6143 0 -> 1.00E-6143
-dqmxg511 maxmag 0.1E-6143 0 -> 1E-6144 Subnormal
-dqmxg512 maxmag 0.10E-6143 0 -> 1.0E-6144 Subnormal
-dqmxg513 maxmag 0.100E-6143 0 -> 1.00E-6144 Subnormal
-dqmxg514 maxmag 0.01E-6143 0 -> 1E-6145 Subnormal
-dqmxg515 maxmag 0.999E-6143 0 -> 9.99E-6144 Subnormal
-dqmxg516 maxmag 0.099E-6143 0 -> 9.9E-6145 Subnormal
-dqmxg517 maxmag 0.009E-6143 0 -> 9E-6146 Subnormal
-dqmxg518 maxmag 0.001E-6143 0 -> 1E-6146 Subnormal
-dqmxg519 maxmag 0.0009E-6143 0 -> 9E-6147 Subnormal
-dqmxg520 maxmag 0.0001E-6143 0 -> 1E-6147 Subnormal
-
-dqmxg530 maxmag -1.00E-6143 0 -> -1.00E-6143
-dqmxg531 maxmag -0.1E-6143 0 -> -1E-6144 Subnormal
-dqmxg532 maxmag -0.10E-6143 0 -> -1.0E-6144 Subnormal
-dqmxg533 maxmag -0.100E-6143 0 -> -1.00E-6144 Subnormal
-dqmxg534 maxmag -0.01E-6143 0 -> -1E-6145 Subnormal
-dqmxg535 maxmag -0.999E-6143 0 -> -9.99E-6144 Subnormal
-dqmxg536 maxmag -0.099E-6143 0 -> -9.9E-6145 Subnormal
-dqmxg537 maxmag -0.009E-6143 0 -> -9E-6146 Subnormal
-dqmxg538 maxmag -0.001E-6143 0 -> -1E-6146 Subnormal
-dqmxg539 maxmag -0.0009E-6143 0 -> -9E-6147 Subnormal
-dqmxg540 maxmag -0.0001E-6143 0 -> -1E-6147 Subnormal
-
--- Null tests
-dqmxg900 maxmag 10 # -> NaN Invalid_operation
-dqmxg901 maxmag # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqMaxMag.decTest -- decQuad maxnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmxg001 maxmag -2 -2 -> -2
+dqmxg002 maxmag -2 -1 -> -2
+dqmxg003 maxmag -2 0 -> -2
+dqmxg004 maxmag -2 1 -> -2
+dqmxg005 maxmag -2 2 -> 2
+dqmxg006 maxmag -1 -2 -> -2
+dqmxg007 maxmag -1 -1 -> -1
+dqmxg008 maxmag -1 0 -> -1
+dqmxg009 maxmag -1 1 -> 1
+dqmxg010 maxmag -1 2 -> 2
+dqmxg011 maxmag 0 -2 -> -2
+dqmxg012 maxmag 0 -1 -> -1
+dqmxg013 maxmag 0 0 -> 0
+dqmxg014 maxmag 0 1 -> 1
+dqmxg015 maxmag 0 2 -> 2
+dqmxg016 maxmag 1 -2 -> -2
+dqmxg017 maxmag 1 -1 -> 1
+dqmxg018 maxmag 1 0 -> 1
+dqmxg019 maxmag 1 1 -> 1
+dqmxg020 maxmag 1 2 -> 2
+dqmxg021 maxmag 2 -2 -> 2
+dqmxg022 maxmag 2 -1 -> 2
+dqmxg023 maxmag 2 0 -> 2
+dqmxg025 maxmag 2 1 -> 2
+dqmxg026 maxmag 2 2 -> 2
+
+-- extended zeros
+dqmxg030 maxmag 0 0 -> 0
+dqmxg031 maxmag 0 -0 -> 0
+dqmxg032 maxmag 0 -0.0 -> 0
+dqmxg033 maxmag 0 0.0 -> 0
+dqmxg034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+dqmxg035 maxmag -0 -0 -> -0
+dqmxg036 maxmag -0 -0.0 -> -0.0
+dqmxg037 maxmag -0 0.0 -> 0.0
+dqmxg038 maxmag 0.0 0 -> 0
+dqmxg039 maxmag 0.0 -0 -> 0.0
+dqmxg040 maxmag 0.0 -0.0 -> 0.0
+dqmxg041 maxmag 0.0 0.0 -> 0.0
+dqmxg042 maxmag -0.0 0 -> 0
+dqmxg043 maxmag -0.0 -0 -> -0.0
+dqmxg044 maxmag -0.0 -0.0 -> -0.0
+dqmxg045 maxmag -0.0 0.0 -> 0.0
+
+dqmxg050 maxmag -0E1 0E1 -> 0E+1
+dqmxg051 maxmag -0E2 0E2 -> 0E+2
+dqmxg052 maxmag -0E2 0E1 -> 0E+1
+dqmxg053 maxmag -0E1 0E2 -> 0E+2
+dqmxg054 maxmag 0E1 -0E1 -> 0E+1
+dqmxg055 maxmag 0E2 -0E2 -> 0E+2
+dqmxg056 maxmag 0E2 -0E1 -> 0E+2
+dqmxg057 maxmag 0E1 -0E2 -> 0E+1
+
+dqmxg058 maxmag 0E1 0E1 -> 0E+1
+dqmxg059 maxmag 0E2 0E2 -> 0E+2
+dqmxg060 maxmag 0E2 0E1 -> 0E+2
+dqmxg061 maxmag 0E1 0E2 -> 0E+2
+dqmxg062 maxmag -0E1 -0E1 -> -0E+1
+dqmxg063 maxmag -0E2 -0E2 -> -0E+2
+dqmxg064 maxmag -0E2 -0E1 -> -0E+1
+dqmxg065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+dqmxg090 maxmag Inf -Inf -> Infinity
+dqmxg091 maxmag Inf -1000 -> Infinity
+dqmxg092 maxmag Inf -1 -> Infinity
+dqmxg093 maxmag Inf -0 -> Infinity
+dqmxg094 maxmag Inf 0 -> Infinity
+dqmxg095 maxmag Inf 1 -> Infinity
+dqmxg096 maxmag Inf 1000 -> Infinity
+dqmxg097 maxmag Inf Inf -> Infinity
+dqmxg098 maxmag -1000 Inf -> Infinity
+dqmxg099 maxmag -Inf Inf -> Infinity
+dqmxg100 maxmag -1 Inf -> Infinity
+dqmxg101 maxmag -0 Inf -> Infinity
+dqmxg102 maxmag 0 Inf -> Infinity
+dqmxg103 maxmag 1 Inf -> Infinity
+dqmxg104 maxmag 1000 Inf -> Infinity
+dqmxg105 maxmag Inf Inf -> Infinity
+
+dqmxg120 maxmag -Inf -Inf -> -Infinity
+dqmxg121 maxmag -Inf -1000 -> -Infinity
+dqmxg122 maxmag -Inf -1 -> -Infinity
+dqmxg123 maxmag -Inf -0 -> -Infinity
+dqmxg124 maxmag -Inf 0 -> -Infinity
+dqmxg125 maxmag -Inf 1 -> -Infinity
+dqmxg126 maxmag -Inf 1000 -> -Infinity
+dqmxg127 maxmag -Inf Inf -> Infinity
+dqmxg128 maxmag -Inf -Inf -> -Infinity
+dqmxg129 maxmag -1000 -Inf -> -Infinity
+dqmxg130 maxmag -1 -Inf -> -Infinity
+dqmxg131 maxmag -0 -Inf -> -Infinity
+dqmxg132 maxmag 0 -Inf -> -Infinity
+dqmxg133 maxmag 1 -Inf -> -Infinity
+dqmxg134 maxmag 1000 -Inf -> -Infinity
+dqmxg135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmxg141 maxmag NaN -Inf -> -Infinity
+dqmxg142 maxmag NaN -1000 -> -1000
+dqmxg143 maxmag NaN -1 -> -1
+dqmxg144 maxmag NaN -0 -> -0
+dqmxg145 maxmag NaN 0 -> 0
+dqmxg146 maxmag NaN 1 -> 1
+dqmxg147 maxmag NaN 1000 -> 1000
+dqmxg148 maxmag NaN Inf -> Infinity
+dqmxg149 maxmag NaN NaN -> NaN
+dqmxg150 maxmag -Inf NaN -> -Infinity
+dqmxg151 maxmag -1000 NaN -> -1000
+dqmxg152 maxmag -1 NaN -> -1
+dqmxg153 maxmag -0 NaN -> -0
+dqmxg154 maxmag 0 NaN -> 0
+dqmxg155 maxmag 1 NaN -> 1
+dqmxg156 maxmag 1000 NaN -> 1000
+dqmxg157 maxmag Inf NaN -> Infinity
+
+dqmxg161 maxmag sNaN -Inf -> NaN Invalid_operation
+dqmxg162 maxmag sNaN -1000 -> NaN Invalid_operation
+dqmxg163 maxmag sNaN -1 -> NaN Invalid_operation
+dqmxg164 maxmag sNaN -0 -> NaN Invalid_operation
+dqmxg165 maxmag sNaN 0 -> NaN Invalid_operation
+dqmxg166 maxmag sNaN 1 -> NaN Invalid_operation
+dqmxg167 maxmag sNaN 1000 -> NaN Invalid_operation
+dqmxg168 maxmag sNaN NaN -> NaN Invalid_operation
+dqmxg169 maxmag sNaN sNaN -> NaN Invalid_operation
+dqmxg170 maxmag NaN sNaN -> NaN Invalid_operation
+dqmxg171 maxmag -Inf sNaN -> NaN Invalid_operation
+dqmxg172 maxmag -1000 sNaN -> NaN Invalid_operation
+dqmxg173 maxmag -1 sNaN -> NaN Invalid_operation
+dqmxg174 maxmag -0 sNaN -> NaN Invalid_operation
+dqmxg175 maxmag 0 sNaN -> NaN Invalid_operation
+dqmxg176 maxmag 1 sNaN -> NaN Invalid_operation
+dqmxg177 maxmag 1000 sNaN -> NaN Invalid_operation
+dqmxg178 maxmag Inf sNaN -> NaN Invalid_operation
+dqmxg179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmxg181 maxmag NaN9 -Inf -> -Infinity
+dqmxg182 maxmag NaN8 9 -> 9
+dqmxg183 maxmag -NaN7 Inf -> Infinity
+
+dqmxg184 maxmag -NaN1 NaN11 -> -NaN1
+dqmxg185 maxmag NaN2 NaN12 -> NaN2
+dqmxg186 maxmag -NaN13 -NaN7 -> -NaN13
+dqmxg187 maxmag NaN14 -NaN5 -> NaN14
+
+dqmxg188 maxmag -Inf NaN4 -> -Infinity
+dqmxg189 maxmag -9 -NaN3 -> -9
+dqmxg190 maxmag Inf NaN2 -> Infinity
+
+dqmxg191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+dqmxg192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+dqmxg193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmxg194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+dqmxg195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmxg196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+dqmxg197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+dqmxg198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmxg199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- old rounding checks
+dqmxg221 maxmag 12345678000 1 -> 12345678000
+dqmxg222 maxmag 1 12345678000 -> 12345678000
+dqmxg223 maxmag 1234567800 1 -> 1234567800
+dqmxg224 maxmag 1 1234567800 -> 1234567800
+dqmxg225 maxmag 1234567890 1 -> 1234567890
+dqmxg226 maxmag 1 1234567890 -> 1234567890
+dqmxg227 maxmag 1234567891 1 -> 1234567891
+dqmxg228 maxmag 1 1234567891 -> 1234567891
+dqmxg229 maxmag 12345678901 1 -> 12345678901
+dqmxg230 maxmag 1 12345678901 -> 12345678901
+dqmxg231 maxmag 1234567896 1 -> 1234567896
+dqmxg232 maxmag 1 1234567896 -> 1234567896
+dqmxg233 maxmag -1234567891 1 -> -1234567891
+dqmxg234 maxmag 1 -1234567891 -> -1234567891
+dqmxg235 maxmag -12345678901 1 -> -12345678901
+dqmxg236 maxmag 1 -12345678901 -> -12345678901
+dqmxg237 maxmag -1234567896 1 -> -1234567896
+dqmxg238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+dqmxg280 maxmag '3' '2' -> '3'
+dqmxg281 maxmag '-10' '3' -> '-10'
+dqmxg282 maxmag '1.0' '1' -> '1'
+dqmxg283 maxmag '1' '1.0' -> '1'
+dqmxg284 maxmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmxg401 maxmag Inf 1.1 -> Infinity
+dqmxg402 maxmag 1.1 1 -> 1.1
+dqmxg403 maxmag 1 1.0 -> 1
+dqmxg404 maxmag 1.0 0.1 -> 1.0
+dqmxg405 maxmag 0.1 0.10 -> 0.1
+dqmxg406 maxmag 0.10 0.100 -> 0.10
+dqmxg407 maxmag 0.10 0 -> 0.10
+dqmxg408 maxmag 0 0.0 -> 0
+dqmxg409 maxmag 0.0 -0 -> 0.0
+dqmxg410 maxmag 0.0 -0.0 -> 0.0
+dqmxg411 maxmag 0.00 -0.0 -> 0.00
+dqmxg412 maxmag 0.0 -0.00 -> 0.0
+dqmxg413 maxmag 0 -0.0 -> 0
+dqmxg414 maxmag 0 -0 -> 0
+dqmxg415 maxmag -0.0 -0 -> -0.0
+dqmxg416 maxmag -0 -0.100 -> -0.100
+dqmxg417 maxmag -0.100 -0.10 -> -0.100
+dqmxg418 maxmag -0.10 -0.1 -> -0.10
+dqmxg419 maxmag -0.1 -1.0 -> -1.0
+dqmxg420 maxmag -1.0 -1 -> -1.0
+dqmxg421 maxmag -1 -1.1 -> -1.1
+dqmxg423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+dqmxg431 maxmag 1.1 Inf -> Infinity
+dqmxg432 maxmag 1 1.1 -> 1.1
+dqmxg433 maxmag 1.0 1 -> 1
+dqmxg434 maxmag 0.1 1.0 -> 1.0
+dqmxg435 maxmag 0.10 0.1 -> 0.1
+dqmxg436 maxmag 0.100 0.10 -> 0.10
+dqmxg437 maxmag 0 0.10 -> 0.10
+dqmxg438 maxmag 0.0 0 -> 0
+dqmxg439 maxmag -0 0.0 -> 0.0
+dqmxg440 maxmag -0.0 0.0 -> 0.0
+dqmxg441 maxmag -0.0 0.00 -> 0.00
+dqmxg442 maxmag -0.00 0.0 -> 0.0
+dqmxg443 maxmag -0.0 0 -> 0
+dqmxg444 maxmag -0 0 -> 0
+dqmxg445 maxmag -0 -0.0 -> -0.0
+dqmxg446 maxmag -0.100 -0 -> -0.100
+dqmxg447 maxmag -0.10 -0.100 -> -0.100
+dqmxg448 maxmag -0.1 -0.10 -> -0.10
+dqmxg449 maxmag -1.0 -0.1 -> -1.0
+dqmxg450 maxmag -1 -1.0 -> -1.0
+dqmxg451 maxmag -1.1 -1 -> -1.1
+dqmxg453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+dqmxg460 maxmag 1000 1E+3 -> 1E+3
+dqmxg461 maxmag 1E+3 1000 -> 1E+3
+dqmxg462 maxmag 1000 -1E+3 -> 1000
+dqmxg463 maxmag 1E+3 -1000 -> 1E+3
+dqmxg464 maxmag -1000 1E+3 -> 1E+3
+dqmxg465 maxmag -1E+3 1000 -> 1000
+dqmxg466 maxmag -1000 -1E+3 -> -1000
+dqmxg467 maxmag -1E+3 -1000 -> -1000
+
+-- subnormals
+dqmxg510 maxmag 1.00E-6143 0 -> 1.00E-6143
+dqmxg511 maxmag 0.1E-6143 0 -> 1E-6144 Subnormal
+dqmxg512 maxmag 0.10E-6143 0 -> 1.0E-6144 Subnormal
+dqmxg513 maxmag 0.100E-6143 0 -> 1.00E-6144 Subnormal
+dqmxg514 maxmag 0.01E-6143 0 -> 1E-6145 Subnormal
+dqmxg515 maxmag 0.999E-6143 0 -> 9.99E-6144 Subnormal
+dqmxg516 maxmag 0.099E-6143 0 -> 9.9E-6145 Subnormal
+dqmxg517 maxmag 0.009E-6143 0 -> 9E-6146 Subnormal
+dqmxg518 maxmag 0.001E-6143 0 -> 1E-6146 Subnormal
+dqmxg519 maxmag 0.0009E-6143 0 -> 9E-6147 Subnormal
+dqmxg520 maxmag 0.0001E-6143 0 -> 1E-6147 Subnormal
+
+dqmxg530 maxmag -1.00E-6143 0 -> -1.00E-6143
+dqmxg531 maxmag -0.1E-6143 0 -> -1E-6144 Subnormal
+dqmxg532 maxmag -0.10E-6143 0 -> -1.0E-6144 Subnormal
+dqmxg533 maxmag -0.100E-6143 0 -> -1.00E-6144 Subnormal
+dqmxg534 maxmag -0.01E-6143 0 -> -1E-6145 Subnormal
+dqmxg535 maxmag -0.999E-6143 0 -> -9.99E-6144 Subnormal
+dqmxg536 maxmag -0.099E-6143 0 -> -9.9E-6145 Subnormal
+dqmxg537 maxmag -0.009E-6143 0 -> -9E-6146 Subnormal
+dqmxg538 maxmag -0.001E-6143 0 -> -1E-6146 Subnormal
+dqmxg539 maxmag -0.0009E-6143 0 -> -9E-6147 Subnormal
+dqmxg540 maxmag -0.0001E-6143 0 -> -1E-6147 Subnormal
+
+-- Null tests
+dqmxg900 maxmag 10 # -> NaN Invalid_operation
+dqmxg901 maxmag # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqMin.decTest b/Lib/test/decimaltestdata/dqMin.decTest
index c87f4c54edc..53020398c59 100644
--- a/Lib/test/decimaltestdata/dqMin.decTest
+++ b/Lib/test/decimaltestdata/dqMin.decTest
@@ -1,309 +1,309 @@
-------------------------------------------------------------------------
--- dqMin.decTest -- decQuad minnum --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmin001 min -2 -2 -> -2
-dqmin002 min -2 -1 -> -2
-dqmin003 min -2 0 -> -2
-dqmin004 min -2 1 -> -2
-dqmin005 min -2 2 -> -2
-dqmin006 min -1 -2 -> -2
-dqmin007 min -1 -1 -> -1
-dqmin008 min -1 0 -> -1
-dqmin009 min -1 1 -> -1
-dqmin010 min -1 2 -> -1
-dqmin011 min 0 -2 -> -2
-dqmin012 min 0 -1 -> -1
-dqmin013 min 0 0 -> 0
-dqmin014 min 0 1 -> 0
-dqmin015 min 0 2 -> 0
-dqmin016 min 1 -2 -> -2
-dqmin017 min 1 -1 -> -1
-dqmin018 min 1 0 -> 0
-dqmin019 min 1 1 -> 1
-dqmin020 min 1 2 -> 1
-dqmin021 min 2 -2 -> -2
-dqmin022 min 2 -1 -> -1
-dqmin023 min 2 0 -> 0
-dqmin025 min 2 1 -> 1
-dqmin026 min 2 2 -> 2
-
--- extended zeros
-dqmin030 min 0 0 -> 0
-dqmin031 min 0 -0 -> -0
-dqmin032 min 0 -0.0 -> -0.0
-dqmin033 min 0 0.0 -> 0.0
-dqmin034 min -0 0 -> -0
-dqmin035 min -0 -0 -> -0
-dqmin036 min -0 -0.0 -> -0
-dqmin037 min -0 0.0 -> -0
-dqmin038 min 0.0 0 -> 0.0
-dqmin039 min 0.0 -0 -> -0
-dqmin040 min 0.0 -0.0 -> -0.0
-dqmin041 min 0.0 0.0 -> 0.0
-dqmin042 min -0.0 0 -> -0.0
-dqmin043 min -0.0 -0 -> -0
-dqmin044 min -0.0 -0.0 -> -0.0
-dqmin045 min -0.0 0.0 -> -0.0
-
-dqmin046 min 0E1 -0E1 -> -0E+1
-dqmin047 min -0E1 0E2 -> -0E+1
-dqmin048 min 0E2 0E1 -> 0E+1
-dqmin049 min 0E1 0E2 -> 0E+1
-dqmin050 min -0E3 -0E2 -> -0E+3
-dqmin051 min -0E2 -0E3 -> -0E+3
-
--- Specials
-dqmin090 min Inf -Inf -> -Infinity
-dqmin091 min Inf -1000 -> -1000
-dqmin092 min Inf -1 -> -1
-dqmin093 min Inf -0 -> -0
-dqmin094 min Inf 0 -> 0
-dqmin095 min Inf 1 -> 1
-dqmin096 min Inf 1000 -> 1000
-dqmin097 min Inf Inf -> Infinity
-dqmin098 min -1000 Inf -> -1000
-dqmin099 min -Inf Inf -> -Infinity
-dqmin100 min -1 Inf -> -1
-dqmin101 min -0 Inf -> -0
-dqmin102 min 0 Inf -> 0
-dqmin103 min 1 Inf -> 1
-dqmin104 min 1000 Inf -> 1000
-dqmin105 min Inf Inf -> Infinity
-
-dqmin120 min -Inf -Inf -> -Infinity
-dqmin121 min -Inf -1000 -> -Infinity
-dqmin122 min -Inf -1 -> -Infinity
-dqmin123 min -Inf -0 -> -Infinity
-dqmin124 min -Inf 0 -> -Infinity
-dqmin125 min -Inf 1 -> -Infinity
-dqmin126 min -Inf 1000 -> -Infinity
-dqmin127 min -Inf Inf -> -Infinity
-dqmin128 min -Inf -Inf -> -Infinity
-dqmin129 min -1000 -Inf -> -Infinity
-dqmin130 min -1 -Inf -> -Infinity
-dqmin131 min -0 -Inf -> -Infinity
-dqmin132 min 0 -Inf -> -Infinity
-dqmin133 min 1 -Inf -> -Infinity
-dqmin134 min 1000 -Inf -> -Infinity
-dqmin135 min Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmin141 min NaN -Inf -> -Infinity
-dqmin142 min NaN -1000 -> -1000
-dqmin143 min NaN -1 -> -1
-dqmin144 min NaN -0 -> -0
-dqmin145 min NaN 0 -> 0
-dqmin146 min NaN 1 -> 1
-dqmin147 min NaN 1000 -> 1000
-dqmin148 min NaN Inf -> Infinity
-dqmin149 min NaN NaN -> NaN
-dqmin150 min -Inf NaN -> -Infinity
-dqmin151 min -1000 NaN -> -1000
-dqmin152 min -1 -NaN -> -1
-dqmin153 min -0 NaN -> -0
-dqmin154 min 0 -NaN -> 0
-dqmin155 min 1 NaN -> 1
-dqmin156 min 1000 NaN -> 1000
-dqmin157 min Inf NaN -> Infinity
-
-dqmin161 min sNaN -Inf -> NaN Invalid_operation
-dqmin162 min sNaN -1000 -> NaN Invalid_operation
-dqmin163 min sNaN -1 -> NaN Invalid_operation
-dqmin164 min sNaN -0 -> NaN Invalid_operation
-dqmin165 min -sNaN 0 -> -NaN Invalid_operation
-dqmin166 min -sNaN 1 -> -NaN Invalid_operation
-dqmin167 min sNaN 1000 -> NaN Invalid_operation
-dqmin168 min sNaN NaN -> NaN Invalid_operation
-dqmin169 min sNaN sNaN -> NaN Invalid_operation
-dqmin170 min NaN sNaN -> NaN Invalid_operation
-dqmin171 min -Inf sNaN -> NaN Invalid_operation
-dqmin172 min -1000 sNaN -> NaN Invalid_operation
-dqmin173 min -1 sNaN -> NaN Invalid_operation
-dqmin174 min -0 sNaN -> NaN Invalid_operation
-dqmin175 min 0 sNaN -> NaN Invalid_operation
-dqmin176 min 1 sNaN -> NaN Invalid_operation
-dqmin177 min 1000 sNaN -> NaN Invalid_operation
-dqmin178 min Inf sNaN -> NaN Invalid_operation
-dqmin179 min NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmin181 min NaN9 -Inf -> -Infinity
-dqmin182 min -NaN8 9990 -> 9990
-dqmin183 min NaN71 Inf -> Infinity
-
-dqmin184 min NaN1 NaN54 -> NaN1
-dqmin185 min NaN22 -NaN53 -> NaN22
-dqmin186 min -NaN3 NaN6 -> -NaN3
-dqmin187 min -NaN44 NaN7 -> -NaN44
-
-dqmin188 min -Inf NaN41 -> -Infinity
-dqmin189 min -9999 -NaN33 -> -9999
-dqmin190 min Inf NaN2 -> Infinity
-
-dqmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
-dqmin192 min sNaN98 -11 -> NaN98 Invalid_operation
-dqmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
-dqmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
-dqmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
-dqmin197 min 088 sNaN91 -> NaN91 Invalid_operation
-dqmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmin199 min NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-dqmin221 min -12345678000 1 -> -12345678000
-dqmin222 min 1 -12345678000 -> -12345678000
-dqmin223 min -1234567800 1 -> -1234567800
-dqmin224 min 1 -1234567800 -> -1234567800
-dqmin225 min -1234567890 1 -> -1234567890
-dqmin226 min 1 -1234567890 -> -1234567890
-dqmin227 min -1234567891 1 -> -1234567891
-dqmin228 min 1 -1234567891 -> -1234567891
-dqmin229 min -12345678901 1 -> -12345678901
-dqmin230 min 1 -12345678901 -> -12345678901
-dqmin231 min -1234567896 1 -> -1234567896
-dqmin232 min 1 -1234567896 -> -1234567896
-dqmin233 min 1234567891 1 -> 1
-dqmin234 min 1 1234567891 -> 1
-dqmin235 min 12345678901 1 -> 1
-dqmin236 min 1 12345678901 -> 1
-dqmin237 min 1234567896 1 -> 1
-dqmin238 min 1 1234567896 -> 1
-
--- from examples
-dqmin280 min '3' '2' -> '2'
-dqmin281 min '-10' '3' -> '-10'
-dqmin282 min '1.0' '1' -> '1.0'
-dqmin283 min '1' '1.0' -> '1.0'
-dqmin284 min '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmin401 min Inf 1.1 -> 1.1
-dqmin402 min 1.1 1 -> 1
-dqmin403 min 1 1.0 -> 1.0
-dqmin404 min 1.0 0.1 -> 0.1
-dqmin405 min 0.1 0.10 -> 0.10
-dqmin406 min 0.10 0.100 -> 0.100
-dqmin407 min 0.10 0 -> 0
-dqmin408 min 0 0.0 -> 0.0
-dqmin409 min 0.0 -0 -> -0
-dqmin410 min 0.0 -0.0 -> -0.0
-dqmin411 min 0.00 -0.0 -> -0.0
-dqmin412 min 0.0 -0.00 -> -0.00
-dqmin413 min 0 -0.0 -> -0.0
-dqmin414 min 0 -0 -> -0
-dqmin415 min -0.0 -0 -> -0
-dqmin416 min -0 -0.100 -> -0.100
-dqmin417 min -0.100 -0.10 -> -0.10
-dqmin418 min -0.10 -0.1 -> -0.1
-dqmin419 min -0.1 -1.0 -> -1.0
-dqmin420 min -1.0 -1 -> -1
-dqmin421 min -1 -1.1 -> -1.1
-dqmin423 min -1.1 -Inf -> -Infinity
--- same with operands reversed
-dqmin431 min 1.1 Inf -> 1.1
-dqmin432 min 1 1.1 -> 1
-dqmin433 min 1.0 1 -> 1.0
-dqmin434 min 0.1 1.0 -> 0.1
-dqmin435 min 0.10 0.1 -> 0.10
-dqmin436 min 0.100 0.10 -> 0.100
-dqmin437 min 0 0.10 -> 0
-dqmin438 min 0.0 0 -> 0.0
-dqmin439 min -0 0.0 -> -0
-dqmin440 min -0.0 0.0 -> -0.0
-dqmin441 min -0.0 0.00 -> -0.0
-dqmin442 min -0.00 0.0 -> -0.00
-dqmin443 min -0.0 0 -> -0.0
-dqmin444 min -0 0 -> -0
-dqmin445 min -0 -0.0 -> -0
-dqmin446 min -0.100 -0 -> -0.100
-dqmin447 min -0.10 -0.100 -> -0.10
-dqmin448 min -0.1 -0.10 -> -0.1
-dqmin449 min -1.0 -0.1 -> -1.0
-dqmin450 min -1 -1.0 -> -1
-dqmin451 min -1.1 -1 -> -1.1
-dqmin453 min -Inf -1.1 -> -Infinity
--- largies
-dqmin460 min 1000 1E+3 -> 1000
-dqmin461 min 1E+3 1000 -> 1000
-dqmin462 min 1000 -1E+3 -> -1E+3
-dqmin463 min 1E+3 -384 -> -384
-dqmin464 min -384 1E+3 -> -384
-dqmin465 min -1E+3 1000 -> -1E+3
-dqmin466 min -384 -1E+3 -> -1E+3
-dqmin467 min -1E+3 -384 -> -1E+3
-
--- misalignment traps for little-endian
-dqmin471 min 1.0 0.1 -> 0.1
-dqmin472 min 0.1 1.0 -> 0.1
-dqmin473 min 10.0 0.1 -> 0.1
-dqmin474 min 0.1 10.0 -> 0.1
-dqmin475 min 100 1.0 -> 1.0
-dqmin476 min 1.0 100 -> 1.0
-dqmin477 min 1000 10.0 -> 10.0
-dqmin478 min 10.0 1000 -> 10.0
-dqmin479 min 10000 100.0 -> 100.0
-dqmin480 min 100.0 10000 -> 100.0
-dqmin481 min 100000 1000.0 -> 1000.0
-dqmin482 min 1000.0 100000 -> 1000.0
-dqmin483 min 1000000 10000.0 -> 10000.0
-dqmin484 min 10000.0 1000000 -> 10000.0
-
--- subnormals
-dqmin510 min 1.00E-6143 0 -> 0
-dqmin511 min 0.1E-6143 0 -> 0
-dqmin512 min 0.10E-6143 0 -> 0
-dqmin513 min 0.100E-6143 0 -> 0
-dqmin514 min 0.01E-6143 0 -> 0
-dqmin515 min 0.999E-6143 0 -> 0
-dqmin516 min 0.099E-6143 0 -> 0
-dqmin517 min 0.009E-6143 0 -> 0
-dqmin518 min 0.001E-6143 0 -> 0
-dqmin519 min 0.0009E-6143 0 -> 0
-dqmin520 min 0.0001E-6143 0 -> 0
-
-dqmin530 min -1.00E-6143 0 -> -1.00E-6143
-dqmin531 min -0.1E-6143 0 -> -1E-6144 Subnormal
-dqmin532 min -0.10E-6143 0 -> -1.0E-6144 Subnormal
-dqmin533 min -0.100E-6143 0 -> -1.00E-6144 Subnormal
-dqmin534 min -0.01E-6143 0 -> -1E-6145 Subnormal
-dqmin535 min -0.999E-6143 0 -> -9.99E-6144 Subnormal
-dqmin536 min -0.099E-6143 0 -> -9.9E-6145 Subnormal
-dqmin537 min -0.009E-6143 0 -> -9E-6146 Subnormal
-dqmin538 min -0.001E-6143 0 -> -1E-6146 Subnormal
-dqmin539 min -0.0009E-6143 0 -> -9E-6147 Subnormal
-dqmin540 min -0.0001E-6143 0 -> -1E-6147 Subnormal
-
-
--- Null tests
-dqmin900 min 10 # -> NaN Invalid_operation
-dqmin901 min # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqMin.decTest -- decQuad minnum --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmin001 min -2 -2 -> -2
+dqmin002 min -2 -1 -> -2
+dqmin003 min -2 0 -> -2
+dqmin004 min -2 1 -> -2
+dqmin005 min -2 2 -> -2
+dqmin006 min -1 -2 -> -2
+dqmin007 min -1 -1 -> -1
+dqmin008 min -1 0 -> -1
+dqmin009 min -1 1 -> -1
+dqmin010 min -1 2 -> -1
+dqmin011 min 0 -2 -> -2
+dqmin012 min 0 -1 -> -1
+dqmin013 min 0 0 -> 0
+dqmin014 min 0 1 -> 0
+dqmin015 min 0 2 -> 0
+dqmin016 min 1 -2 -> -2
+dqmin017 min 1 -1 -> -1
+dqmin018 min 1 0 -> 0
+dqmin019 min 1 1 -> 1
+dqmin020 min 1 2 -> 1
+dqmin021 min 2 -2 -> -2
+dqmin022 min 2 -1 -> -1
+dqmin023 min 2 0 -> 0
+dqmin025 min 2 1 -> 1
+dqmin026 min 2 2 -> 2
+
+-- extended zeros
+dqmin030 min 0 0 -> 0
+dqmin031 min 0 -0 -> -0
+dqmin032 min 0 -0.0 -> -0.0
+dqmin033 min 0 0.0 -> 0.0
+dqmin034 min -0 0 -> -0
+dqmin035 min -0 -0 -> -0
+dqmin036 min -0 -0.0 -> -0
+dqmin037 min -0 0.0 -> -0
+dqmin038 min 0.0 0 -> 0.0
+dqmin039 min 0.0 -0 -> -0
+dqmin040 min 0.0 -0.0 -> -0.0
+dqmin041 min 0.0 0.0 -> 0.0
+dqmin042 min -0.0 0 -> -0.0
+dqmin043 min -0.0 -0 -> -0
+dqmin044 min -0.0 -0.0 -> -0.0
+dqmin045 min -0.0 0.0 -> -0.0
+
+dqmin046 min 0E1 -0E1 -> -0E+1
+dqmin047 min -0E1 0E2 -> -0E+1
+dqmin048 min 0E2 0E1 -> 0E+1
+dqmin049 min 0E1 0E2 -> 0E+1
+dqmin050 min -0E3 -0E2 -> -0E+3
+dqmin051 min -0E2 -0E3 -> -0E+3
+
+-- Specials
+dqmin090 min Inf -Inf -> -Infinity
+dqmin091 min Inf -1000 -> -1000
+dqmin092 min Inf -1 -> -1
+dqmin093 min Inf -0 -> -0
+dqmin094 min Inf 0 -> 0
+dqmin095 min Inf 1 -> 1
+dqmin096 min Inf 1000 -> 1000
+dqmin097 min Inf Inf -> Infinity
+dqmin098 min -1000 Inf -> -1000
+dqmin099 min -Inf Inf -> -Infinity
+dqmin100 min -1 Inf -> -1
+dqmin101 min -0 Inf -> -0
+dqmin102 min 0 Inf -> 0
+dqmin103 min 1 Inf -> 1
+dqmin104 min 1000 Inf -> 1000
+dqmin105 min Inf Inf -> Infinity
+
+dqmin120 min -Inf -Inf -> -Infinity
+dqmin121 min -Inf -1000 -> -Infinity
+dqmin122 min -Inf -1 -> -Infinity
+dqmin123 min -Inf -0 -> -Infinity
+dqmin124 min -Inf 0 -> -Infinity
+dqmin125 min -Inf 1 -> -Infinity
+dqmin126 min -Inf 1000 -> -Infinity
+dqmin127 min -Inf Inf -> -Infinity
+dqmin128 min -Inf -Inf -> -Infinity
+dqmin129 min -1000 -Inf -> -Infinity
+dqmin130 min -1 -Inf -> -Infinity
+dqmin131 min -0 -Inf -> -Infinity
+dqmin132 min 0 -Inf -> -Infinity
+dqmin133 min 1 -Inf -> -Infinity
+dqmin134 min 1000 -Inf -> -Infinity
+dqmin135 min Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmin141 min NaN -Inf -> -Infinity
+dqmin142 min NaN -1000 -> -1000
+dqmin143 min NaN -1 -> -1
+dqmin144 min NaN -0 -> -0
+dqmin145 min NaN 0 -> 0
+dqmin146 min NaN 1 -> 1
+dqmin147 min NaN 1000 -> 1000
+dqmin148 min NaN Inf -> Infinity
+dqmin149 min NaN NaN -> NaN
+dqmin150 min -Inf NaN -> -Infinity
+dqmin151 min -1000 NaN -> -1000
+dqmin152 min -1 -NaN -> -1
+dqmin153 min -0 NaN -> -0
+dqmin154 min 0 -NaN -> 0
+dqmin155 min 1 NaN -> 1
+dqmin156 min 1000 NaN -> 1000
+dqmin157 min Inf NaN -> Infinity
+
+dqmin161 min sNaN -Inf -> NaN Invalid_operation
+dqmin162 min sNaN -1000 -> NaN Invalid_operation
+dqmin163 min sNaN -1 -> NaN Invalid_operation
+dqmin164 min sNaN -0 -> NaN Invalid_operation
+dqmin165 min -sNaN 0 -> -NaN Invalid_operation
+dqmin166 min -sNaN 1 -> -NaN Invalid_operation
+dqmin167 min sNaN 1000 -> NaN Invalid_operation
+dqmin168 min sNaN NaN -> NaN Invalid_operation
+dqmin169 min sNaN sNaN -> NaN Invalid_operation
+dqmin170 min NaN sNaN -> NaN Invalid_operation
+dqmin171 min -Inf sNaN -> NaN Invalid_operation
+dqmin172 min -1000 sNaN -> NaN Invalid_operation
+dqmin173 min -1 sNaN -> NaN Invalid_operation
+dqmin174 min -0 sNaN -> NaN Invalid_operation
+dqmin175 min 0 sNaN -> NaN Invalid_operation
+dqmin176 min 1 sNaN -> NaN Invalid_operation
+dqmin177 min 1000 sNaN -> NaN Invalid_operation
+dqmin178 min Inf sNaN -> NaN Invalid_operation
+dqmin179 min NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmin181 min NaN9 -Inf -> -Infinity
+dqmin182 min -NaN8 9990 -> 9990
+dqmin183 min NaN71 Inf -> Infinity
+
+dqmin184 min NaN1 NaN54 -> NaN1
+dqmin185 min NaN22 -NaN53 -> NaN22
+dqmin186 min -NaN3 NaN6 -> -NaN3
+dqmin187 min -NaN44 NaN7 -> -NaN44
+
+dqmin188 min -Inf NaN41 -> -Infinity
+dqmin189 min -9999 -NaN33 -> -9999
+dqmin190 min Inf NaN2 -> Infinity
+
+dqmin191 min sNaN99 -Inf -> NaN99 Invalid_operation
+dqmin192 min sNaN98 -11 -> NaN98 Invalid_operation
+dqmin193 min -sNaN97 NaN8 -> -NaN97 Invalid_operation
+dqmin194 min sNaN69 sNaN94 -> NaN69 Invalid_operation
+dqmin195 min NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmin196 min -Inf sNaN92 -> NaN92 Invalid_operation
+dqmin197 min 088 sNaN91 -> NaN91 Invalid_operation
+dqmin198 min Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmin199 min NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+dqmin221 min -12345678000 1 -> -12345678000
+dqmin222 min 1 -12345678000 -> -12345678000
+dqmin223 min -1234567800 1 -> -1234567800
+dqmin224 min 1 -1234567800 -> -1234567800
+dqmin225 min -1234567890 1 -> -1234567890
+dqmin226 min 1 -1234567890 -> -1234567890
+dqmin227 min -1234567891 1 -> -1234567891
+dqmin228 min 1 -1234567891 -> -1234567891
+dqmin229 min -12345678901 1 -> -12345678901
+dqmin230 min 1 -12345678901 -> -12345678901
+dqmin231 min -1234567896 1 -> -1234567896
+dqmin232 min 1 -1234567896 -> -1234567896
+dqmin233 min 1234567891 1 -> 1
+dqmin234 min 1 1234567891 -> 1
+dqmin235 min 12345678901 1 -> 1
+dqmin236 min 1 12345678901 -> 1
+dqmin237 min 1234567896 1 -> 1
+dqmin238 min 1 1234567896 -> 1
+
+-- from examples
+dqmin280 min '3' '2' -> '2'
+dqmin281 min '-10' '3' -> '-10'
+dqmin282 min '1.0' '1' -> '1.0'
+dqmin283 min '1' '1.0' -> '1.0'
+dqmin284 min '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmin401 min Inf 1.1 -> 1.1
+dqmin402 min 1.1 1 -> 1
+dqmin403 min 1 1.0 -> 1.0
+dqmin404 min 1.0 0.1 -> 0.1
+dqmin405 min 0.1 0.10 -> 0.10
+dqmin406 min 0.10 0.100 -> 0.100
+dqmin407 min 0.10 0 -> 0
+dqmin408 min 0 0.0 -> 0.0
+dqmin409 min 0.0 -0 -> -0
+dqmin410 min 0.0 -0.0 -> -0.0
+dqmin411 min 0.00 -0.0 -> -0.0
+dqmin412 min 0.0 -0.00 -> -0.00
+dqmin413 min 0 -0.0 -> -0.0
+dqmin414 min 0 -0 -> -0
+dqmin415 min -0.0 -0 -> -0
+dqmin416 min -0 -0.100 -> -0.100
+dqmin417 min -0.100 -0.10 -> -0.10
+dqmin418 min -0.10 -0.1 -> -0.1
+dqmin419 min -0.1 -1.0 -> -1.0
+dqmin420 min -1.0 -1 -> -1
+dqmin421 min -1 -1.1 -> -1.1
+dqmin423 min -1.1 -Inf -> -Infinity
+-- same with operands reversed
+dqmin431 min 1.1 Inf -> 1.1
+dqmin432 min 1 1.1 -> 1
+dqmin433 min 1.0 1 -> 1.0
+dqmin434 min 0.1 1.0 -> 0.1
+dqmin435 min 0.10 0.1 -> 0.10
+dqmin436 min 0.100 0.10 -> 0.100
+dqmin437 min 0 0.10 -> 0
+dqmin438 min 0.0 0 -> 0.0
+dqmin439 min -0 0.0 -> -0
+dqmin440 min -0.0 0.0 -> -0.0
+dqmin441 min -0.0 0.00 -> -0.0
+dqmin442 min -0.00 0.0 -> -0.00
+dqmin443 min -0.0 0 -> -0.0
+dqmin444 min -0 0 -> -0
+dqmin445 min -0 -0.0 -> -0
+dqmin446 min -0.100 -0 -> -0.100
+dqmin447 min -0.10 -0.100 -> -0.10
+dqmin448 min -0.1 -0.10 -> -0.1
+dqmin449 min -1.0 -0.1 -> -1.0
+dqmin450 min -1 -1.0 -> -1
+dqmin451 min -1.1 -1 -> -1.1
+dqmin453 min -Inf -1.1 -> -Infinity
+-- largies
+dqmin460 min 1000 1E+3 -> 1000
+dqmin461 min 1E+3 1000 -> 1000
+dqmin462 min 1000 -1E+3 -> -1E+3
+dqmin463 min 1E+3 -384 -> -384
+dqmin464 min -384 1E+3 -> -384
+dqmin465 min -1E+3 1000 -> -1E+3
+dqmin466 min -384 -1E+3 -> -1E+3
+dqmin467 min -1E+3 -384 -> -1E+3
+
+-- misalignment traps for little-endian
+dqmin471 min 1.0 0.1 -> 0.1
+dqmin472 min 0.1 1.0 -> 0.1
+dqmin473 min 10.0 0.1 -> 0.1
+dqmin474 min 0.1 10.0 -> 0.1
+dqmin475 min 100 1.0 -> 1.0
+dqmin476 min 1.0 100 -> 1.0
+dqmin477 min 1000 10.0 -> 10.0
+dqmin478 min 10.0 1000 -> 10.0
+dqmin479 min 10000 100.0 -> 100.0
+dqmin480 min 100.0 10000 -> 100.0
+dqmin481 min 100000 1000.0 -> 1000.0
+dqmin482 min 1000.0 100000 -> 1000.0
+dqmin483 min 1000000 10000.0 -> 10000.0
+dqmin484 min 10000.0 1000000 -> 10000.0
+
+-- subnormals
+dqmin510 min 1.00E-6143 0 -> 0
+dqmin511 min 0.1E-6143 0 -> 0
+dqmin512 min 0.10E-6143 0 -> 0
+dqmin513 min 0.100E-6143 0 -> 0
+dqmin514 min 0.01E-6143 0 -> 0
+dqmin515 min 0.999E-6143 0 -> 0
+dqmin516 min 0.099E-6143 0 -> 0
+dqmin517 min 0.009E-6143 0 -> 0
+dqmin518 min 0.001E-6143 0 -> 0
+dqmin519 min 0.0009E-6143 0 -> 0
+dqmin520 min 0.0001E-6143 0 -> 0
+
+dqmin530 min -1.00E-6143 0 -> -1.00E-6143
+dqmin531 min -0.1E-6143 0 -> -1E-6144 Subnormal
+dqmin532 min -0.10E-6143 0 -> -1.0E-6144 Subnormal
+dqmin533 min -0.100E-6143 0 -> -1.00E-6144 Subnormal
+dqmin534 min -0.01E-6143 0 -> -1E-6145 Subnormal
+dqmin535 min -0.999E-6143 0 -> -9.99E-6144 Subnormal
+dqmin536 min -0.099E-6143 0 -> -9.9E-6145 Subnormal
+dqmin537 min -0.009E-6143 0 -> -9E-6146 Subnormal
+dqmin538 min -0.001E-6143 0 -> -1E-6146 Subnormal
+dqmin539 min -0.0009E-6143 0 -> -9E-6147 Subnormal
+dqmin540 min -0.0001E-6143 0 -> -1E-6147 Subnormal
+
+
+-- Null tests
+dqmin900 min 10 # -> NaN Invalid_operation
+dqmin901 min # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqMinMag.decTest b/Lib/test/decimaltestdata/dqMinMag.decTest
index edc2e476ace..71b886fb588 100644
--- a/Lib/test/decimaltestdata/dqMinMag.decTest
+++ b/Lib/test/decimaltestdata/dqMinMag.decTest
@@ -1,293 +1,293 @@
-------------------------------------------------------------------------
--- dqMinMag.decTest -- decQuad minnummag --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmng001 minmag -2 -2 -> -2
-dqmng002 minmag -2 -1 -> -1
-dqmng003 minmag -2 0 -> 0
-dqmng004 minmag -2 1 -> 1
-dqmng005 minmag -2 2 -> -2
-dqmng006 minmag -1 -2 -> -1
-dqmng007 minmag -1 -1 -> -1
-dqmng008 minmag -1 0 -> 0
-dqmng009 minmag -1 1 -> -1
-dqmng010 minmag -1 2 -> -1
-dqmng011 minmag 0 -2 -> 0
-dqmng012 minmag 0 -1 -> 0
-dqmng013 minmag 0 0 -> 0
-dqmng014 minmag 0 1 -> 0
-dqmng015 minmag 0 2 -> 0
-dqmng016 minmag 1 -2 -> 1
-dqmng017 minmag 1 -1 -> -1
-dqmng018 minmag 1 0 -> 0
-dqmng019 minmag 1 1 -> 1
-dqmng020 minmag 1 2 -> 1
-dqmng021 minmag 2 -2 -> -2
-dqmng022 minmag 2 -1 -> -1
-dqmng023 minmag 2 0 -> 0
-dqmng025 minmag 2 1 -> 1
-dqmng026 minmag 2 2 -> 2
-
--- extended zeros
-dqmng030 minmag 0 0 -> 0
-dqmng031 minmag 0 -0 -> -0
-dqmng032 minmag 0 -0.0 -> -0.0
-dqmng033 minmag 0 0.0 -> 0.0
-dqmng034 minmag -0 0 -> -0
-dqmng035 minmag -0 -0 -> -0
-dqmng036 minmag -0 -0.0 -> -0
-dqmng037 minmag -0 0.0 -> -0
-dqmng038 minmag 0.0 0 -> 0.0
-dqmng039 minmag 0.0 -0 -> -0
-dqmng040 minmag 0.0 -0.0 -> -0.0
-dqmng041 minmag 0.0 0.0 -> 0.0
-dqmng042 minmag -0.0 0 -> -0.0
-dqmng043 minmag -0.0 -0 -> -0
-dqmng044 minmag -0.0 -0.0 -> -0.0
-dqmng045 minmag -0.0 0.0 -> -0.0
-
-dqmng046 minmag 0E1 -0E1 -> -0E+1
-dqmng047 minmag -0E1 0E2 -> -0E+1
-dqmng048 minmag 0E2 0E1 -> 0E+1
-dqmng049 minmag 0E1 0E2 -> 0E+1
-dqmng050 minmag -0E3 -0E2 -> -0E+3
-dqmng051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-dqmng090 minmag Inf -Inf -> -Infinity
-dqmng091 minmag Inf -1000 -> -1000
-dqmng092 minmag Inf -1 -> -1
-dqmng093 minmag Inf -0 -> -0
-dqmng094 minmag Inf 0 -> 0
-dqmng095 minmag Inf 1 -> 1
-dqmng096 minmag Inf 1000 -> 1000
-dqmng097 minmag Inf Inf -> Infinity
-dqmng098 minmag -1000 Inf -> -1000
-dqmng099 minmag -Inf Inf -> -Infinity
-dqmng100 minmag -1 Inf -> -1
-dqmng101 minmag -0 Inf -> -0
-dqmng102 minmag 0 Inf -> 0
-dqmng103 minmag 1 Inf -> 1
-dqmng104 minmag 1000 Inf -> 1000
-dqmng105 minmag Inf Inf -> Infinity
-
-dqmng120 minmag -Inf -Inf -> -Infinity
-dqmng121 minmag -Inf -1000 -> -1000
-dqmng122 minmag -Inf -1 -> -1
-dqmng123 minmag -Inf -0 -> -0
-dqmng124 minmag -Inf 0 -> 0
-dqmng125 minmag -Inf 1 -> 1
-dqmng126 minmag -Inf 1000 -> 1000
-dqmng127 minmag -Inf Inf -> -Infinity
-dqmng128 minmag -Inf -Inf -> -Infinity
-dqmng129 minmag -1000 -Inf -> -1000
-dqmng130 minmag -1 -Inf -> -1
-dqmng131 minmag -0 -Inf -> -0
-dqmng132 minmag 0 -Inf -> 0
-dqmng133 minmag 1 -Inf -> 1
-dqmng134 minmag 1000 -Inf -> 1000
-dqmng135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-dqmng141 minmag NaN -Inf -> -Infinity
-dqmng142 minmag NaN -1000 -> -1000
-dqmng143 minmag NaN -1 -> -1
-dqmng144 minmag NaN -0 -> -0
-dqmng145 minmag NaN 0 -> 0
-dqmng146 minmag NaN 1 -> 1
-dqmng147 minmag NaN 1000 -> 1000
-dqmng148 minmag NaN Inf -> Infinity
-dqmng149 minmag NaN NaN -> NaN
-dqmng150 minmag -Inf NaN -> -Infinity
-dqmng151 minmag -1000 NaN -> -1000
-dqmng152 minmag -1 -NaN -> -1
-dqmng153 minmag -0 NaN -> -0
-dqmng154 minmag 0 -NaN -> 0
-dqmng155 minmag 1 NaN -> 1
-dqmng156 minmag 1000 NaN -> 1000
-dqmng157 minmag Inf NaN -> Infinity
-
-dqmng161 minmag sNaN -Inf -> NaN Invalid_operation
-dqmng162 minmag sNaN -1000 -> NaN Invalid_operation
-dqmng163 minmag sNaN -1 -> NaN Invalid_operation
-dqmng164 minmag sNaN -0 -> NaN Invalid_operation
-dqmng165 minmag -sNaN 0 -> -NaN Invalid_operation
-dqmng166 minmag -sNaN 1 -> -NaN Invalid_operation
-dqmng167 minmag sNaN 1000 -> NaN Invalid_operation
-dqmng168 minmag sNaN NaN -> NaN Invalid_operation
-dqmng169 minmag sNaN sNaN -> NaN Invalid_operation
-dqmng170 minmag NaN sNaN -> NaN Invalid_operation
-dqmng171 minmag -Inf sNaN -> NaN Invalid_operation
-dqmng172 minmag -1000 sNaN -> NaN Invalid_operation
-dqmng173 minmag -1 sNaN -> NaN Invalid_operation
-dqmng174 minmag -0 sNaN -> NaN Invalid_operation
-dqmng175 minmag 0 sNaN -> NaN Invalid_operation
-dqmng176 minmag 1 sNaN -> NaN Invalid_operation
-dqmng177 minmag 1000 sNaN -> NaN Invalid_operation
-dqmng178 minmag Inf sNaN -> NaN Invalid_operation
-dqmng179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmng181 minmag NaN9 -Inf -> -Infinity
-dqmng182 minmag -NaN8 9990 -> 9990
-dqmng183 minmag NaN71 Inf -> Infinity
-
-dqmng184 minmag NaN1 NaN54 -> NaN1
-dqmng185 minmag NaN22 -NaN53 -> NaN22
-dqmng186 minmag -NaN3 NaN6 -> -NaN3
-dqmng187 minmag -NaN44 NaN7 -> -NaN44
-
-dqmng188 minmag -Inf NaN41 -> -Infinity
-dqmng189 minmag -9999 -NaN33 -> -9999
-dqmng190 minmag Inf NaN2 -> Infinity
-
-dqmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-dqmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-dqmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-dqmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-dqmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-dqmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-dqmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- old rounding checks
-dqmng221 minmag -12345678000 1 -> 1
-dqmng222 minmag 1 -12345678000 -> 1
-dqmng223 minmag -1234567800 1 -> 1
-dqmng224 minmag 1 -1234567800 -> 1
-dqmng225 minmag -1234567890 1 -> 1
-dqmng226 minmag 1 -1234567890 -> 1
-dqmng227 minmag -1234567891 1 -> 1
-dqmng228 minmag 1 -1234567891 -> 1
-dqmng229 minmag -12345678901 1 -> 1
-dqmng230 minmag 1 -12345678901 -> 1
-dqmng231 minmag -1234567896 1 -> 1
-dqmng232 minmag 1 -1234567896 -> 1
-dqmng233 minmag 1234567891 1 -> 1
-dqmng234 minmag 1 1234567891 -> 1
-dqmng235 minmag 12345678901 1 -> 1
-dqmng236 minmag 1 12345678901 -> 1
-dqmng237 minmag 1234567896 1 -> 1
-dqmng238 minmag 1 1234567896 -> 1
-
--- from examples
-dqmng280 minmag '3' '2' -> '2'
-dqmng281 minmag '-10' '3' -> '3'
-dqmng282 minmag '1.0' '1' -> '1.0'
-dqmng283 minmag '1' '1.0' -> '1.0'
-dqmng284 minmag '7' 'NaN' -> '7'
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-dqmng401 minmag Inf 1.1 -> 1.1
-dqmng402 minmag 1.1 1 -> 1
-dqmng403 minmag 1 1.0 -> 1.0
-dqmng404 minmag 1.0 0.1 -> 0.1
-dqmng405 minmag 0.1 0.10 -> 0.10
-dqmng406 minmag 0.10 0.100 -> 0.100
-dqmng407 minmag 0.10 0 -> 0
-dqmng408 minmag 0 0.0 -> 0.0
-dqmng409 minmag 0.0 -0 -> -0
-dqmng410 minmag 0.0 -0.0 -> -0.0
-dqmng411 minmag 0.00 -0.0 -> -0.0
-dqmng412 minmag 0.0 -0.00 -> -0.00
-dqmng413 minmag 0 -0.0 -> -0.0
-dqmng414 minmag 0 -0 -> -0
-dqmng415 minmag -0.0 -0 -> -0
-dqmng416 minmag -0 -0.100 -> -0
-dqmng417 minmag -0.100 -0.10 -> -0.10
-dqmng418 minmag -0.10 -0.1 -> -0.1
-dqmng419 minmag -0.1 -1.0 -> -0.1
-dqmng420 minmag -1.0 -1 -> -1
-dqmng421 minmag -1 -1.1 -> -1
-dqmng423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-dqmng431 minmag 1.1 Inf -> 1.1
-dqmng432 minmag 1 1.1 -> 1
-dqmng433 minmag 1.0 1 -> 1.0
-dqmng434 minmag 0.1 1.0 -> 0.1
-dqmng435 minmag 0.10 0.1 -> 0.10
-dqmng436 minmag 0.100 0.10 -> 0.100
-dqmng437 minmag 0 0.10 -> 0
-dqmng438 minmag 0.0 0 -> 0.0
-dqmng439 minmag -0 0.0 -> -0
-dqmng440 minmag -0.0 0.0 -> -0.0
-dqmng441 minmag -0.0 0.00 -> -0.0
-dqmng442 minmag -0.00 0.0 -> -0.00
-dqmng443 minmag -0.0 0 -> -0.0
-dqmng444 minmag -0 0 -> -0
-dqmng445 minmag -0 -0.0 -> -0
-dqmng446 minmag -0.100 -0 -> -0
-dqmng447 minmag -0.10 -0.100 -> -0.10
-dqmng448 minmag -0.1 -0.10 -> -0.1
-dqmng449 minmag -1.0 -0.1 -> -0.1
-dqmng450 minmag -1 -1.0 -> -1
-dqmng451 minmag -1.1 -1 -> -1
-dqmng453 minmag -Inf -1.1 -> -1.1
--- largies
-dqmng460 minmag 1000 1E+3 -> 1000
-dqmng461 minmag 1E+3 1000 -> 1000
-dqmng462 minmag 1000 -1E+3 -> -1E+3
-dqmng463 minmag 1E+3 -384 -> -384
-dqmng464 minmag -384 1E+3 -> -384
-dqmng465 minmag -1E+3 1000 -> -1E+3
-dqmng466 minmag -384 -1E+3 -> -384
-dqmng467 minmag -1E+3 -384 -> -384
-
--- subnormals
-dqmng510 minmag 1.00E-6143 0 -> 0
-dqmng511 minmag 0.1E-6143 0 -> 0
-dqmng512 minmag 0.10E-6143 0 -> 0
-dqmng513 minmag 0.100E-6143 0 -> 0
-dqmng514 minmag 0.01E-6143 0 -> 0
-dqmng515 minmag 0.999E-6143 0 -> 0
-dqmng516 minmag 0.099E-6143 0 -> 0
-dqmng517 minmag 0.009E-6143 0 -> 0
-dqmng518 minmag 0.001E-6143 0 -> 0
-dqmng519 minmag 0.0009E-6143 0 -> 0
-dqmng520 minmag 0.0001E-6143 0 -> 0
-
-dqmng530 minmag -1.00E-6143 0 -> 0
-dqmng531 minmag -0.1E-6143 0 -> 0
-dqmng532 minmag -0.10E-6143 0 -> 0
-dqmng533 minmag -0.100E-6143 0 -> 0
-dqmng534 minmag -0.01E-6143 0 -> 0
-dqmng535 minmag -0.999E-6143 0 -> 0
-dqmng536 minmag -0.099E-6143 0 -> 0
-dqmng537 minmag -0.009E-6143 0 -> 0
-dqmng538 minmag -0.001E-6143 0 -> 0
-dqmng539 minmag -0.0009E-6143 0 -> 0
-dqmng540 minmag -0.0001E-6143 0 -> 0
-
-
--- Null tests
-dqmng900 minmag 10 # -> NaN Invalid_operation
-dqmng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqMinMag.decTest -- decQuad minnummag --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmng001 minmag -2 -2 -> -2
+dqmng002 minmag -2 -1 -> -1
+dqmng003 minmag -2 0 -> 0
+dqmng004 minmag -2 1 -> 1
+dqmng005 minmag -2 2 -> -2
+dqmng006 minmag -1 -2 -> -1
+dqmng007 minmag -1 -1 -> -1
+dqmng008 minmag -1 0 -> 0
+dqmng009 minmag -1 1 -> -1
+dqmng010 minmag -1 2 -> -1
+dqmng011 minmag 0 -2 -> 0
+dqmng012 minmag 0 -1 -> 0
+dqmng013 minmag 0 0 -> 0
+dqmng014 minmag 0 1 -> 0
+dqmng015 minmag 0 2 -> 0
+dqmng016 minmag 1 -2 -> 1
+dqmng017 minmag 1 -1 -> -1
+dqmng018 minmag 1 0 -> 0
+dqmng019 minmag 1 1 -> 1
+dqmng020 minmag 1 2 -> 1
+dqmng021 minmag 2 -2 -> -2
+dqmng022 minmag 2 -1 -> -1
+dqmng023 minmag 2 0 -> 0
+dqmng025 minmag 2 1 -> 1
+dqmng026 minmag 2 2 -> 2
+
+-- extended zeros
+dqmng030 minmag 0 0 -> 0
+dqmng031 minmag 0 -0 -> -0
+dqmng032 minmag 0 -0.0 -> -0.0
+dqmng033 minmag 0 0.0 -> 0.0
+dqmng034 minmag -0 0 -> -0
+dqmng035 minmag -0 -0 -> -0
+dqmng036 minmag -0 -0.0 -> -0
+dqmng037 minmag -0 0.0 -> -0
+dqmng038 minmag 0.0 0 -> 0.0
+dqmng039 minmag 0.0 -0 -> -0
+dqmng040 minmag 0.0 -0.0 -> -0.0
+dqmng041 minmag 0.0 0.0 -> 0.0
+dqmng042 minmag -0.0 0 -> -0.0
+dqmng043 minmag -0.0 -0 -> -0
+dqmng044 minmag -0.0 -0.0 -> -0.0
+dqmng045 minmag -0.0 0.0 -> -0.0
+
+dqmng046 minmag 0E1 -0E1 -> -0E+1
+dqmng047 minmag -0E1 0E2 -> -0E+1
+dqmng048 minmag 0E2 0E1 -> 0E+1
+dqmng049 minmag 0E1 0E2 -> 0E+1
+dqmng050 minmag -0E3 -0E2 -> -0E+3
+dqmng051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+dqmng090 minmag Inf -Inf -> -Infinity
+dqmng091 minmag Inf -1000 -> -1000
+dqmng092 minmag Inf -1 -> -1
+dqmng093 minmag Inf -0 -> -0
+dqmng094 minmag Inf 0 -> 0
+dqmng095 minmag Inf 1 -> 1
+dqmng096 minmag Inf 1000 -> 1000
+dqmng097 minmag Inf Inf -> Infinity
+dqmng098 minmag -1000 Inf -> -1000
+dqmng099 minmag -Inf Inf -> -Infinity
+dqmng100 minmag -1 Inf -> -1
+dqmng101 minmag -0 Inf -> -0
+dqmng102 minmag 0 Inf -> 0
+dqmng103 minmag 1 Inf -> 1
+dqmng104 minmag 1000 Inf -> 1000
+dqmng105 minmag Inf Inf -> Infinity
+
+dqmng120 minmag -Inf -Inf -> -Infinity
+dqmng121 minmag -Inf -1000 -> -1000
+dqmng122 minmag -Inf -1 -> -1
+dqmng123 minmag -Inf -0 -> -0
+dqmng124 minmag -Inf 0 -> 0
+dqmng125 minmag -Inf 1 -> 1
+dqmng126 minmag -Inf 1000 -> 1000
+dqmng127 minmag -Inf Inf -> -Infinity
+dqmng128 minmag -Inf -Inf -> -Infinity
+dqmng129 minmag -1000 -Inf -> -1000
+dqmng130 minmag -1 -Inf -> -1
+dqmng131 minmag -0 -Inf -> -0
+dqmng132 minmag 0 -Inf -> 0
+dqmng133 minmag 1 -Inf -> 1
+dqmng134 minmag 1000 -Inf -> 1000
+dqmng135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+dqmng141 minmag NaN -Inf -> -Infinity
+dqmng142 minmag NaN -1000 -> -1000
+dqmng143 minmag NaN -1 -> -1
+dqmng144 minmag NaN -0 -> -0
+dqmng145 minmag NaN 0 -> 0
+dqmng146 minmag NaN 1 -> 1
+dqmng147 minmag NaN 1000 -> 1000
+dqmng148 minmag NaN Inf -> Infinity
+dqmng149 minmag NaN NaN -> NaN
+dqmng150 minmag -Inf NaN -> -Infinity
+dqmng151 minmag -1000 NaN -> -1000
+dqmng152 minmag -1 -NaN -> -1
+dqmng153 minmag -0 NaN -> -0
+dqmng154 minmag 0 -NaN -> 0
+dqmng155 minmag 1 NaN -> 1
+dqmng156 minmag 1000 NaN -> 1000
+dqmng157 minmag Inf NaN -> Infinity
+
+dqmng161 minmag sNaN -Inf -> NaN Invalid_operation
+dqmng162 minmag sNaN -1000 -> NaN Invalid_operation
+dqmng163 minmag sNaN -1 -> NaN Invalid_operation
+dqmng164 minmag sNaN -0 -> NaN Invalid_operation
+dqmng165 minmag -sNaN 0 -> -NaN Invalid_operation
+dqmng166 minmag -sNaN 1 -> -NaN Invalid_operation
+dqmng167 minmag sNaN 1000 -> NaN Invalid_operation
+dqmng168 minmag sNaN NaN -> NaN Invalid_operation
+dqmng169 minmag sNaN sNaN -> NaN Invalid_operation
+dqmng170 minmag NaN sNaN -> NaN Invalid_operation
+dqmng171 minmag -Inf sNaN -> NaN Invalid_operation
+dqmng172 minmag -1000 sNaN -> NaN Invalid_operation
+dqmng173 minmag -1 sNaN -> NaN Invalid_operation
+dqmng174 minmag -0 sNaN -> NaN Invalid_operation
+dqmng175 minmag 0 sNaN -> NaN Invalid_operation
+dqmng176 minmag 1 sNaN -> NaN Invalid_operation
+dqmng177 minmag 1000 sNaN -> NaN Invalid_operation
+dqmng178 minmag Inf sNaN -> NaN Invalid_operation
+dqmng179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmng181 minmag NaN9 -Inf -> -Infinity
+dqmng182 minmag -NaN8 9990 -> 9990
+dqmng183 minmag NaN71 Inf -> Infinity
+
+dqmng184 minmag NaN1 NaN54 -> NaN1
+dqmng185 minmag NaN22 -NaN53 -> NaN22
+dqmng186 minmag -NaN3 NaN6 -> -NaN3
+dqmng187 minmag -NaN44 NaN7 -> -NaN44
+
+dqmng188 minmag -Inf NaN41 -> -Infinity
+dqmng189 minmag -9999 -NaN33 -> -9999
+dqmng190 minmag Inf NaN2 -> Infinity
+
+dqmng191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+dqmng192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+dqmng193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+dqmng194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+dqmng195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmng196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+dqmng197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+dqmng198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmng199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- old rounding checks
+dqmng221 minmag -12345678000 1 -> 1
+dqmng222 minmag 1 -12345678000 -> 1
+dqmng223 minmag -1234567800 1 -> 1
+dqmng224 minmag 1 -1234567800 -> 1
+dqmng225 minmag -1234567890 1 -> 1
+dqmng226 minmag 1 -1234567890 -> 1
+dqmng227 minmag -1234567891 1 -> 1
+dqmng228 minmag 1 -1234567891 -> 1
+dqmng229 minmag -12345678901 1 -> 1
+dqmng230 minmag 1 -12345678901 -> 1
+dqmng231 minmag -1234567896 1 -> 1
+dqmng232 minmag 1 -1234567896 -> 1
+dqmng233 minmag 1234567891 1 -> 1
+dqmng234 minmag 1 1234567891 -> 1
+dqmng235 minmag 12345678901 1 -> 1
+dqmng236 minmag 1 12345678901 -> 1
+dqmng237 minmag 1234567896 1 -> 1
+dqmng238 minmag 1 1234567896 -> 1
+
+-- from examples
+dqmng280 minmag '3' '2' -> '2'
+dqmng281 minmag '-10' '3' -> '3'
+dqmng282 minmag '1.0' '1' -> '1.0'
+dqmng283 minmag '1' '1.0' -> '1.0'
+dqmng284 minmag '7' 'NaN' -> '7'
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+dqmng401 minmag Inf 1.1 -> 1.1
+dqmng402 minmag 1.1 1 -> 1
+dqmng403 minmag 1 1.0 -> 1.0
+dqmng404 minmag 1.0 0.1 -> 0.1
+dqmng405 minmag 0.1 0.10 -> 0.10
+dqmng406 minmag 0.10 0.100 -> 0.100
+dqmng407 minmag 0.10 0 -> 0
+dqmng408 minmag 0 0.0 -> 0.0
+dqmng409 minmag 0.0 -0 -> -0
+dqmng410 minmag 0.0 -0.0 -> -0.0
+dqmng411 minmag 0.00 -0.0 -> -0.0
+dqmng412 minmag 0.0 -0.00 -> -0.00
+dqmng413 minmag 0 -0.0 -> -0.0
+dqmng414 minmag 0 -0 -> -0
+dqmng415 minmag -0.0 -0 -> -0
+dqmng416 minmag -0 -0.100 -> -0
+dqmng417 minmag -0.100 -0.10 -> -0.10
+dqmng418 minmag -0.10 -0.1 -> -0.1
+dqmng419 minmag -0.1 -1.0 -> -0.1
+dqmng420 minmag -1.0 -1 -> -1
+dqmng421 minmag -1 -1.1 -> -1
+dqmng423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+dqmng431 minmag 1.1 Inf -> 1.1
+dqmng432 minmag 1 1.1 -> 1
+dqmng433 minmag 1.0 1 -> 1.0
+dqmng434 minmag 0.1 1.0 -> 0.1
+dqmng435 minmag 0.10 0.1 -> 0.10
+dqmng436 minmag 0.100 0.10 -> 0.100
+dqmng437 minmag 0 0.10 -> 0
+dqmng438 minmag 0.0 0 -> 0.0
+dqmng439 minmag -0 0.0 -> -0
+dqmng440 minmag -0.0 0.0 -> -0.0
+dqmng441 minmag -0.0 0.00 -> -0.0
+dqmng442 minmag -0.00 0.0 -> -0.00
+dqmng443 minmag -0.0 0 -> -0.0
+dqmng444 minmag -0 0 -> -0
+dqmng445 minmag -0 -0.0 -> -0
+dqmng446 minmag -0.100 -0 -> -0
+dqmng447 minmag -0.10 -0.100 -> -0.10
+dqmng448 minmag -0.1 -0.10 -> -0.1
+dqmng449 minmag -1.0 -0.1 -> -0.1
+dqmng450 minmag -1 -1.0 -> -1
+dqmng451 minmag -1.1 -1 -> -1
+dqmng453 minmag -Inf -1.1 -> -1.1
+-- largies
+dqmng460 minmag 1000 1E+3 -> 1000
+dqmng461 minmag 1E+3 1000 -> 1000
+dqmng462 minmag 1000 -1E+3 -> -1E+3
+dqmng463 minmag 1E+3 -384 -> -384
+dqmng464 minmag -384 1E+3 -> -384
+dqmng465 minmag -1E+3 1000 -> -1E+3
+dqmng466 minmag -384 -1E+3 -> -384
+dqmng467 minmag -1E+3 -384 -> -384
+
+-- subnormals
+dqmng510 minmag 1.00E-6143 0 -> 0
+dqmng511 minmag 0.1E-6143 0 -> 0
+dqmng512 minmag 0.10E-6143 0 -> 0
+dqmng513 minmag 0.100E-6143 0 -> 0
+dqmng514 minmag 0.01E-6143 0 -> 0
+dqmng515 minmag 0.999E-6143 0 -> 0
+dqmng516 minmag 0.099E-6143 0 -> 0
+dqmng517 minmag 0.009E-6143 0 -> 0
+dqmng518 minmag 0.001E-6143 0 -> 0
+dqmng519 minmag 0.0009E-6143 0 -> 0
+dqmng520 minmag 0.0001E-6143 0 -> 0
+
+dqmng530 minmag -1.00E-6143 0 -> 0
+dqmng531 minmag -0.1E-6143 0 -> 0
+dqmng532 minmag -0.10E-6143 0 -> 0
+dqmng533 minmag -0.100E-6143 0 -> 0
+dqmng534 minmag -0.01E-6143 0 -> 0
+dqmng535 minmag -0.999E-6143 0 -> 0
+dqmng536 minmag -0.099E-6143 0 -> 0
+dqmng537 minmag -0.009E-6143 0 -> 0
+dqmng538 minmag -0.001E-6143 0 -> 0
+dqmng539 minmag -0.0009E-6143 0 -> 0
+dqmng540 minmag -0.0001E-6143 0 -> 0
+
+
+-- Null tests
+dqmng900 minmag 10 # -> NaN Invalid_operation
+dqmng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqMinus.decTest b/Lib/test/decimaltestdata/dqMinus.decTest
index 02e462e0bee..7a007791bfe 100644
--- a/Lib/test/decimaltestdata/dqMinus.decTest
+++ b/Lib/test/decimaltestdata/dqMinus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqMinus.decTest -- decQuad 0-x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqmns001 minus +7.50 -> -7.50
-
--- Infinities
-dqmns011 minus Infinity -> -Infinity
-dqmns012 minus -Infinity -> Infinity
-
--- NaNs, 0 payload
-dqmns021 minus NaN -> NaN
-dqmns022 minus -NaN -> -NaN
-dqmns023 minus sNaN -> NaN Invalid_operation
-dqmns024 minus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-dqmns031 minus NaN13 -> NaN13
-dqmns032 minus -NaN13 -> -NaN13
-dqmns033 minus sNaN13 -> NaN13 Invalid_operation
-dqmns034 minus -sNaN13 -> -NaN13 Invalid_operation
-dqmns035 minus NaN70 -> NaN70
-dqmns036 minus -NaN70 -> -NaN70
-dqmns037 minus sNaN101 -> NaN101 Invalid_operation
-dqmns038 minus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-dqmns101 minus 7 -> -7
-dqmns102 minus -7 -> 7
-dqmns103 minus 75 -> -75
-dqmns104 minus -75 -> 75
-dqmns105 minus 7.50 -> -7.50
-dqmns106 minus -7.50 -> 7.50
-dqmns107 minus 7.500 -> -7.500
-dqmns108 minus -7.500 -> 7.500
-
--- zeros
-dqmns111 minus 0 -> 0
-dqmns112 minus -0 -> 0
-dqmns113 minus 0E+4 -> 0E+4
-dqmns114 minus -0E+4 -> 0E+4
-dqmns115 minus 0.0000 -> 0.0000
-dqmns116 minus -0.0000 -> 0.0000
-dqmns117 minus 0E-141 -> 0E-141
-dqmns118 minus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqmns121 minus 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqmns122 minus -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqmns123 minus 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-dqmns124 minus -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqmns131 minus 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqmns132 minus 1E-6143 -> -1E-6143
-dqmns133 minus 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqmns134 minus 1E-6176 -> -1E-6176 Subnormal
-
-dqmns135 minus -1E-6176 -> 1E-6176 Subnormal
-dqmns136 minus -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqmns137 minus -1E-6143 -> 1E-6143
-dqmns138 minus -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqMinus.decTest -- decQuad 0-x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqmns001 minus +7.50 -> -7.50
+
+-- Infinities
+dqmns011 minus Infinity -> -Infinity
+dqmns012 minus -Infinity -> Infinity
+
+-- NaNs, 0 payload
+dqmns021 minus NaN -> NaN
+dqmns022 minus -NaN -> -NaN
+dqmns023 minus sNaN -> NaN Invalid_operation
+dqmns024 minus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+dqmns031 minus NaN13 -> NaN13
+dqmns032 minus -NaN13 -> -NaN13
+dqmns033 minus sNaN13 -> NaN13 Invalid_operation
+dqmns034 minus -sNaN13 -> -NaN13 Invalid_operation
+dqmns035 minus NaN70 -> NaN70
+dqmns036 minus -NaN70 -> -NaN70
+dqmns037 minus sNaN101 -> NaN101 Invalid_operation
+dqmns038 minus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+dqmns101 minus 7 -> -7
+dqmns102 minus -7 -> 7
+dqmns103 minus 75 -> -75
+dqmns104 minus -75 -> 75
+dqmns105 minus 7.50 -> -7.50
+dqmns106 minus -7.50 -> 7.50
+dqmns107 minus 7.500 -> -7.500
+dqmns108 minus -7.500 -> 7.500
+
+-- zeros
+dqmns111 minus 0 -> 0
+dqmns112 minus -0 -> 0
+dqmns113 minus 0E+4 -> 0E+4
+dqmns114 minus -0E+4 -> 0E+4
+dqmns115 minus 0.0000 -> 0.0000
+dqmns116 minus -0.0000 -> 0.0000
+dqmns117 minus 0E-141 -> 0E-141
+dqmns118 minus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqmns121 minus 2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqmns122 minus -2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqmns123 minus 1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+dqmns124 minus -1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqmns131 minus 9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqmns132 minus 1E-6143 -> -1E-6143
+dqmns133 minus 1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqmns134 minus 1E-6176 -> -1E-6176 Subnormal
+
+dqmns135 minus -1E-6176 -> 1E-6176 Subnormal
+dqmns136 minus -1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqmns137 minus -1E-6143 -> 1E-6143
+dqmns138 minus -9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqMultiply.decTest b/Lib/test/decimaltestdata/dqMultiply.decTest
index 8387a858d36..676c1f5ea44 100644
--- a/Lib/test/decimaltestdata/dqMultiply.decTest
+++ b/Lib/test/decimaltestdata/dqMultiply.decTest
@@ -1,589 +1,589 @@
-------------------------------------------------------------------------
--- dqMultiply.decTest -- decQuad multiplication --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqmul000 multiply 2 2 -> 4
-dqmul001 multiply 2 3 -> 6
-dqmul002 multiply 5 1 -> 5
-dqmul003 multiply 5 2 -> 10
-dqmul004 multiply 1.20 2 -> 2.40
-dqmul005 multiply 1.20 0 -> 0.00
-dqmul006 multiply 1.20 -2 -> -2.40
-dqmul007 multiply -1.20 2 -> -2.40
-dqmul008 multiply -1.20 0 -> -0.00
-dqmul009 multiply -1.20 -2 -> 2.40
-dqmul010 multiply 5.09 7.1 -> 36.139
-dqmul011 multiply 2.5 4 -> 10.0
-dqmul012 multiply 2.50 4 -> 10.00
-dqmul013 multiply 1.23456789 1.0000000000000000000000000000 -> 1.234567890000000000000000000000000 Rounded
-dqmul015 multiply 2.50 4 -> 10.00
-dqmul016 multiply 9.99999999999999999 9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
-dqmul017 multiply 9.99999999999999999 -9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqmul018 multiply -9.99999999999999999 9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
-dqmul019 multiply -9.99999999999999999 -9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
-
--- zeros, etc.
-dqmul021 multiply 0 0 -> 0
-dqmul022 multiply 0 -0 -> -0
-dqmul023 multiply -0 0 -> -0
-dqmul024 multiply -0 -0 -> 0
-dqmul025 multiply -0.0 -0.0 -> 0.00
-dqmul026 multiply -0.0 -0.0 -> 0.00
-dqmul027 multiply -0.0 -0.0 -> 0.00
-dqmul028 multiply -0.0 -0.0 -> 0.00
-dqmul030 multiply 5.00 1E-3 -> 0.00500
-dqmul031 multiply 00.00 0.000 -> 0.00000
-dqmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
-dqmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
-dqmul034 multiply -5.00 1E-3 -> -0.00500
-dqmul035 multiply -00.00 0.000 -> -0.00000
-dqmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
-dqmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
-dqmul038 multiply 5.00 -1E-3 -> -0.00500
-dqmul039 multiply 00.00 -0.000 -> -0.00000
-dqmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
-dqmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
-dqmul042 multiply -5.00 -1E-3 -> 0.00500
-dqmul043 multiply -00.00 -0.000 -> 0.00000
-dqmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
-dqmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
-
--- examples from decarith
-dqmul050 multiply 1.20 3 -> 3.60
-dqmul051 multiply 7 3 -> 21
-dqmul052 multiply 0.9 0.8 -> 0.72
-dqmul053 multiply 0.9 -0 -> -0.0
-dqmul054 multiply 654321 654321 -> 428135971041
-
-dqmul060 multiply 123.45 1e7 -> 1.2345E+9
-dqmul061 multiply 123.45 1e8 -> 1.2345E+10
-dqmul062 multiply 123.45 1e+9 -> 1.2345E+11
-dqmul063 multiply 123.45 1e10 -> 1.2345E+12
-dqmul064 multiply 123.45 1e11 -> 1.2345E+13
-dqmul065 multiply 123.45 1e12 -> 1.2345E+14
-dqmul066 multiply 123.45 1e13 -> 1.2345E+15
-
-
--- test some intermediate lengths
--- 1234567890123456
-dqmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
-dqmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
-dqmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
-dqmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
-
--- test some more edge cases and carries
-dqmul101 multiply 9 9 -> 81
-dqmul102 multiply 9 90 -> 810
-dqmul103 multiply 9 900 -> 8100
-dqmul104 multiply 9 9000 -> 81000
-dqmul105 multiply 9 90000 -> 810000
-dqmul106 multiply 9 900000 -> 8100000
-dqmul107 multiply 9 9000000 -> 81000000
-dqmul108 multiply 9 90000000 -> 810000000
-dqmul109 multiply 9 900000000 -> 8100000000
-dqmul110 multiply 9 9000000000 -> 81000000000
-dqmul111 multiply 9 90000000000 -> 810000000000
-dqmul112 multiply 9 900000000000 -> 8100000000000
-dqmul113 multiply 9 9000000000000 -> 81000000000000
-dqmul114 multiply 9 90000000000000 -> 810000000000000
-dqmul115 multiply 9 900000000000000 -> 8100000000000000
---dqmul116 multiply 9 9000000000000000 -> 81000000000000000
---dqmul117 multiply 9 90000000000000000 -> 810000000000000000
---dqmul118 multiply 9 900000000000000000 -> 8100000000000000000
---dqmul119 multiply 9 9000000000000000000 -> 81000000000000000000
---dqmul120 multiply 9 90000000000000000000 -> 810000000000000000000
---dqmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
---dqmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
---dqmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
--- test some more edge cases without carries
-dqmul131 multiply 3 3 -> 9
-dqmul132 multiply 3 30 -> 90
-dqmul133 multiply 3 300 -> 900
-dqmul134 multiply 3 3000 -> 9000
-dqmul135 multiply 3 30000 -> 90000
-dqmul136 multiply 3 300000 -> 900000
-dqmul137 multiply 3 3000000 -> 9000000
-dqmul138 multiply 3 30000000 -> 90000000
-dqmul139 multiply 3 300000000 -> 900000000
-dqmul140 multiply 3 3000000000 -> 9000000000
-dqmul141 multiply 3 30000000000 -> 90000000000
-dqmul142 multiply 3 300000000000 -> 900000000000
-dqmul143 multiply 3 3000000000000 -> 9000000000000
-dqmul144 multiply 3 30000000000000 -> 90000000000000
-dqmul145 multiply 3 300000000000000 -> 900000000000000
-dqmul146 multiply 3 3000000000000000 -> 9000000000000000
-dqmul147 multiply 3 30000000000000000 -> 90000000000000000
-dqmul148 multiply 3 300000000000000000 -> 900000000000000000
-dqmul149 multiply 3 3000000000000000000 -> 9000000000000000000
-dqmul150 multiply 3 30000000000000000000 -> 90000000000000000000
-dqmul151 multiply 3 300000000000000000000 -> 900000000000000000000
-dqmul152 multiply 3 3000000000000000000000 -> 9000000000000000000000
-dqmul153 multiply 3 30000000000000000000000 -> 90000000000000000000000
-
-dqmul263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928296 Inexact Rounded
-
--- test some edge cases with exact rounding
-dqmul301 multiply 900000000000000000 9 -> 8100000000000000000
-dqmul302 multiply 900000000000000000 90 -> 81000000000000000000
-dqmul303 multiply 900000000000000000 900 -> 810000000000000000000
-dqmul304 multiply 900000000000000000 9000 -> 8100000000000000000000
-dqmul305 multiply 900000000000000000 90000 -> 81000000000000000000000
-dqmul306 multiply 900000000000000000 900000 -> 810000000000000000000000
-dqmul307 multiply 900000000000000000 9000000 -> 8100000000000000000000000
-dqmul308 multiply 900000000000000000 90000000 -> 81000000000000000000000000
-dqmul309 multiply 900000000000000000 900000000 -> 810000000000000000000000000
-dqmul310 multiply 900000000000000000 9000000000 -> 8100000000000000000000000000
-dqmul311 multiply 900000000000000000 90000000000 -> 81000000000000000000000000000
-dqmul312 multiply 900000000000000000 900000000000 -> 810000000000000000000000000000
-dqmul313 multiply 900000000000000000 9000000000000 -> 8100000000000000000000000000000
-dqmul314 multiply 900000000000000000 90000000000000 -> 81000000000000000000000000000000
-dqmul315 multiply 900000000000000000 900000000000000 -> 810000000000000000000000000000000
-dqmul316 multiply 900000000000000000 9000000000000000 -> 8100000000000000000000000000000000
-dqmul317 multiply 9000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+34 Rounded
-dqmul318 multiply 90000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+35 Rounded
-dqmul319 multiply 900000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+36 Rounded
-dqmul320 multiply 9000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+37 Rounded
-dqmul321 multiply 90000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+38 Rounded
-dqmul322 multiply 900000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+39 Rounded
-dqmul323 multiply 9000000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+40 Rounded
-
--- tryzeros cases
-dqmul504 multiply 0E-4260 1000E-4260 -> 0E-6176 Clamped
-dqmul505 multiply 100E+4260 0E+4260 -> 0E+6111 Clamped
-
--- mixed with zeros
-dqmul541 multiply 0 -1 -> -0
-dqmul542 multiply -0 -1 -> 0
-dqmul543 multiply 0 1 -> 0
-dqmul544 multiply -0 1 -> -0
-dqmul545 multiply -1 0 -> -0
-dqmul546 multiply -1 -0 -> 0
-dqmul547 multiply 1 0 -> 0
-dqmul548 multiply 1 -0 -> -0
-
-dqmul551 multiply 0.0 -1 -> -0.0
-dqmul552 multiply -0.0 -1 -> 0.0
-dqmul553 multiply 0.0 1 -> 0.0
-dqmul554 multiply -0.0 1 -> -0.0
-dqmul555 multiply -1.0 0 -> -0.0
-dqmul556 multiply -1.0 -0 -> 0.0
-dqmul557 multiply 1.0 0 -> 0.0
-dqmul558 multiply 1.0 -0 -> -0.0
-
-dqmul561 multiply 0 -1.0 -> -0.0
-dqmul562 multiply -0 -1.0 -> 0.0
-dqmul563 multiply 0 1.0 -> 0.0
-dqmul564 multiply -0 1.0 -> -0.0
-dqmul565 multiply -1 0.0 -> -0.0
-dqmul566 multiply -1 -0.0 -> 0.0
-dqmul567 multiply 1 0.0 -> 0.0
-dqmul568 multiply 1 -0.0 -> -0.0
-
-dqmul571 multiply 0.0 -1.0 -> -0.00
-dqmul572 multiply -0.0 -1.0 -> 0.00
-dqmul573 multiply 0.0 1.0 -> 0.00
-dqmul574 multiply -0.0 1.0 -> -0.00
-dqmul575 multiply -1.0 0.0 -> -0.00
-dqmul576 multiply -1.0 -0.0 -> 0.00
-dqmul577 multiply 1.0 0.0 -> 0.00
-dqmul578 multiply 1.0 -0.0 -> -0.00
-
-
--- Specials
-dqmul580 multiply Inf -Inf -> -Infinity
-dqmul581 multiply Inf -1000 -> -Infinity
-dqmul582 multiply Inf -1 -> -Infinity
-dqmul583 multiply Inf -0 -> NaN Invalid_operation
-dqmul584 multiply Inf 0 -> NaN Invalid_operation
-dqmul585 multiply Inf 1 -> Infinity
-dqmul586 multiply Inf 1000 -> Infinity
-dqmul587 multiply Inf Inf -> Infinity
-dqmul588 multiply -1000 Inf -> -Infinity
-dqmul589 multiply -Inf Inf -> -Infinity
-dqmul590 multiply -1 Inf -> -Infinity
-dqmul591 multiply -0 Inf -> NaN Invalid_operation
-dqmul592 multiply 0 Inf -> NaN Invalid_operation
-dqmul593 multiply 1 Inf -> Infinity
-dqmul594 multiply 1000 Inf -> Infinity
-dqmul595 multiply Inf Inf -> Infinity
-
-dqmul600 multiply -Inf -Inf -> Infinity
-dqmul601 multiply -Inf -1000 -> Infinity
-dqmul602 multiply -Inf -1 -> Infinity
-dqmul603 multiply -Inf -0 -> NaN Invalid_operation
-dqmul604 multiply -Inf 0 -> NaN Invalid_operation
-dqmul605 multiply -Inf 1 -> -Infinity
-dqmul606 multiply -Inf 1000 -> -Infinity
-dqmul607 multiply -Inf Inf -> -Infinity
-dqmul608 multiply -1000 Inf -> -Infinity
-dqmul609 multiply -Inf -Inf -> Infinity
-dqmul610 multiply -1 -Inf -> Infinity
-dqmul611 multiply -0 -Inf -> NaN Invalid_operation
-dqmul612 multiply 0 -Inf -> NaN Invalid_operation
-dqmul613 multiply 1 -Inf -> -Infinity
-dqmul614 multiply 1000 -Inf -> -Infinity
-dqmul615 multiply Inf -Inf -> -Infinity
-
-dqmul621 multiply NaN -Inf -> NaN
-dqmul622 multiply NaN -1000 -> NaN
-dqmul623 multiply NaN -1 -> NaN
-dqmul624 multiply NaN -0 -> NaN
-dqmul625 multiply NaN 0 -> NaN
-dqmul626 multiply NaN 1 -> NaN
-dqmul627 multiply NaN 1000 -> NaN
-dqmul628 multiply NaN Inf -> NaN
-dqmul629 multiply NaN NaN -> NaN
-dqmul630 multiply -Inf NaN -> NaN
-dqmul631 multiply -1000 NaN -> NaN
-dqmul632 multiply -1 NaN -> NaN
-dqmul633 multiply -0 NaN -> NaN
-dqmul634 multiply 0 NaN -> NaN
-dqmul635 multiply 1 NaN -> NaN
-dqmul636 multiply 1000 NaN -> NaN
-dqmul637 multiply Inf NaN -> NaN
-
-dqmul641 multiply sNaN -Inf -> NaN Invalid_operation
-dqmul642 multiply sNaN -1000 -> NaN Invalid_operation
-dqmul643 multiply sNaN -1 -> NaN Invalid_operation
-dqmul644 multiply sNaN -0 -> NaN Invalid_operation
-dqmul645 multiply sNaN 0 -> NaN Invalid_operation
-dqmul646 multiply sNaN 1 -> NaN Invalid_operation
-dqmul647 multiply sNaN 1000 -> NaN Invalid_operation
-dqmul648 multiply sNaN NaN -> NaN Invalid_operation
-dqmul649 multiply sNaN sNaN -> NaN Invalid_operation
-dqmul650 multiply NaN sNaN -> NaN Invalid_operation
-dqmul651 multiply -Inf sNaN -> NaN Invalid_operation
-dqmul652 multiply -1000 sNaN -> NaN Invalid_operation
-dqmul653 multiply -1 sNaN -> NaN Invalid_operation
-dqmul654 multiply -0 sNaN -> NaN Invalid_operation
-dqmul655 multiply 0 sNaN -> NaN Invalid_operation
-dqmul656 multiply 1 sNaN -> NaN Invalid_operation
-dqmul657 multiply 1000 sNaN -> NaN Invalid_operation
-dqmul658 multiply Inf sNaN -> NaN Invalid_operation
-dqmul659 multiply NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqmul661 multiply NaN9 -Inf -> NaN9
-dqmul662 multiply NaN8 999 -> NaN8
-dqmul663 multiply NaN71 Inf -> NaN71
-dqmul664 multiply NaN6 NaN5 -> NaN6
-dqmul665 multiply -Inf NaN4 -> NaN4
-dqmul666 multiply -999 NaN33 -> NaN33
-dqmul667 multiply Inf NaN2 -> NaN2
-
-dqmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
-dqmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
-dqmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
-dqmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
-dqmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
-dqmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
-dqmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
-dqmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
-
-dqmul681 multiply -NaN9 -Inf -> -NaN9
-dqmul682 multiply -NaN8 999 -> -NaN8
-dqmul683 multiply -NaN71 Inf -> -NaN71
-dqmul684 multiply -NaN6 -NaN5 -> -NaN6
-dqmul685 multiply -Inf -NaN4 -> -NaN4
-dqmul686 multiply -999 -NaN33 -> -NaN33
-dqmul687 multiply Inf -NaN2 -> -NaN2
-
-dqmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
-dqmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
-dqmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
-dqmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
-dqmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
-dqmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
-
-dqmul701 multiply -NaN -Inf -> -NaN
-dqmul702 multiply -NaN 999 -> -NaN
-dqmul703 multiply -NaN Inf -> -NaN
-dqmul704 multiply -NaN -NaN -> -NaN
-dqmul705 multiply -Inf -NaN0 -> -NaN
-dqmul706 multiply -999 -NaN -> -NaN
-dqmul707 multiply Inf -NaN -> -NaN
-
-dqmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
-dqmul712 multiply -sNaN -11 -> -NaN Invalid_operation
-dqmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
-dqmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
-dqmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
-dqmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
-dqmul717 multiply 088 -sNaN -> -NaN Invalid_operation
-dqmul718 multiply Inf -sNaN -> -NaN Invalid_operation
-dqmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
--- signs
-dqmul751 multiply 1e+4277 1e+3311 -> Infinity Overflow Inexact Rounded
-dqmul752 multiply 1e+4277 -1e+3311 -> -Infinity Overflow Inexact Rounded
-dqmul753 multiply -1e+4277 1e+3311 -> -Infinity Overflow Inexact Rounded
-dqmul754 multiply -1e+4277 -1e+3311 -> Infinity Overflow Inexact Rounded
-dqmul755 multiply 1e-4277 1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul756 multiply 1e-4277 -1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul757 multiply -1e-4277 1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul758 multiply -1e-4277 -1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-dqmul760 multiply 1e-6069 1e-101 -> 1E-6170 Subnormal
-dqmul761 multiply 1e-6069 1e-102 -> 1E-6171 Subnormal
-dqmul762 multiply 1e-6069 1e-103 -> 1E-6172 Subnormal
-dqmul763 multiply 1e-6069 1e-104 -> 1E-6173 Subnormal
-dqmul764 multiply 1e-6069 1e-105 -> 1E-6174 Subnormal
-dqmul765 multiply 1e-6069 1e-106 -> 1E-6175 Subnormal
-dqmul766 multiply 1e-6069 1e-107 -> 1E-6176 Subnormal
-dqmul767 multiply 1e-6069 1e-108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul768 multiply 1e-6069 1e-109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul769 multiply 1e-6069 1e-110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-dqmul770 multiply 1e+40 1e+6101 -> 1.000000000000000000000000000000E+6141 Clamped
-dqmul771 multiply 1e+40 1e+6102 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqmul772 multiply 1e+40 1e+6103 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqmul773 multiply 1e+40 1e+6104 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqmul774 multiply 1e+40 1e+6105 -> Infinity Overflow Inexact Rounded
-dqmul775 multiply 1e+40 1e+6106 -> Infinity Overflow Inexact Rounded
-dqmul776 multiply 1e+40 1e+6107 -> Infinity Overflow Inexact Rounded
-dqmul777 multiply 1e+40 1e+6108 -> Infinity Overflow Inexact Rounded
-dqmul778 multiply 1e+40 1e+6109 -> Infinity Overflow Inexact Rounded
-dqmul779 multiply 1e+40 1e+6110 -> Infinity Overflow Inexact Rounded
-
-dqmul801 multiply 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
-dqmul802 multiply 1.000E-6172 1e-1 -> 1.000E-6173 Subnormal
-dqmul803 multiply 1.00E-6172 1e-2 -> 1.00E-6174 Subnormal
-dqmul804 multiply 1.0E-6172 1e-3 -> 1.0E-6175 Subnormal
-dqmul805 multiply 1.0E-6172 1e-4 -> 1E-6176 Subnormal Rounded
-dqmul806 multiply 1.3E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul807 multiply 1.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul808 multiply 1.7E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul809 multiply 2.3E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul810 multiply 2.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul811 multiply 2.7E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqmul812 multiply 1.49E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul813 multiply 1.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul814 multiply 1.51E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul815 multiply 2.49E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul816 multiply 2.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqmul817 multiply 2.51E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
-
-dqmul818 multiply 1E-6172 1e-4 -> 1E-6176 Subnormal
-dqmul819 multiply 3E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul820 multiply 5E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul821 multiply 7E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul822 multiply 9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqmul823 multiply 9.9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqmul824 multiply 1E-6172 -1e-4 -> -1E-6176 Subnormal
-dqmul825 multiply 3E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul826 multiply -5E-6172 1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul827 multiply 7E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul828 multiply -9E-6172 1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul829 multiply 9.9E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqmul830 multiply 3.0E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqmul831 multiply 1.0E-5977 1e-200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqmul832 multiply 1.0E-5977 1e-199 -> 1E-6176 Subnormal Rounded
-dqmul833 multiply 1.0E-5977 1e-198 -> 1.0E-6175 Subnormal
-dqmul834 multiply 2.0E-5977 2e-198 -> 4.0E-6175 Subnormal
-dqmul835 multiply 4.0E-5977 4e-198 -> 1.60E-6174 Subnormal
-dqmul836 multiply 10.0E-5977 10e-198 -> 1.000E-6173 Subnormal
-dqmul837 multiply 30.0E-5977 30e-198 -> 9.000E-6173 Subnormal
-dqmul838 multiply 40.0E-5982 40e-166 -> 1.6000E-6145 Subnormal
-dqmul839 multiply 40.0E-5982 40e-165 -> 1.6000E-6144 Subnormal
-dqmul840 multiply 40.0E-5982 40e-164 -> 1.6000E-6143
-
--- Long operand overflow may be a different path
-dqmul870 multiply 100 9.999E+6143 -> Infinity Inexact Overflow Rounded
-dqmul871 multiply 100 -9.999E+6143 -> -Infinity Inexact Overflow Rounded
-dqmul872 multiply 9.999E+6143 100 -> Infinity Inexact Overflow Rounded
-dqmul873 multiply -9.999E+6143 100 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-dqmul881 multiply 1.2347E-6133 1.2347E-40 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
-dqmul882 multiply 1.234E-6133 1.234E-40 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul883 multiply 1.23E-6133 1.23E-40 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
-dqmul884 multiply 1.2E-6133 1.2E-40 -> 1.44E-6173 Subnormal
-dqmul885 multiply 1.2E-6133 1.2E-41 -> 1.44E-6174 Subnormal
-dqmul886 multiply 1.2E-6133 1.2E-42 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
-dqmul887 multiply 1.2E-6133 1.3E-42 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
-dqmul888 multiply 1.3E-6133 1.3E-42 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
-dqmul889 multiply 1.3E-6133 1.3E-43 -> 2E-6176 Subnormal Inexact Rounded Underflow
-dqmul890 multiply 1.3E-6134 1.3E-43 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
-
-dqmul891 multiply 1.2345E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqmul892 multiply 1.23456E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
-dqmul893 multiply 1.2345E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul894 multiply 1.23456E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
-dqmul895 multiply 1.2345E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-dqmul896 multiply 1.23456E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
--- prove operands are exact
-dqmul906 multiply 9.999999999999999999999999999999999E-6143 1 -> 9.999999999999999999999999999999999E-6143
-dqmul907 multiply 1 0.09999999999999999999999999999999999 -> 0.09999999999999999999999999999999999
--- the next rounds to Nmin
-dqmul908 multiply 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
-
--- hugest
-dqmul909 multiply 9999999999999999999999999999999999 9999999999999999999999999999999999 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
--- VG case
-dqmul910 multiply 8.81125000000001349436E-1548 8.000000000000000000E-1550 -> 7.049000000000010795488000000000000E-3097 Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-dqmul911 multiply 130E-2 120E-2 -> 1.5600
-dqmul912 multiply 130E-2 12E-1 -> 1.560
-dqmul913 multiply 130E-2 1E0 -> 1.30
-dqmul914 multiply 1E2 1E4 -> 1E+6
-
--- power-of-ten edge cases
-dqmul1001 multiply 1 10 -> 10
-dqmul1002 multiply 1 100 -> 100
-dqmul1003 multiply 1 1000 -> 1000
-dqmul1004 multiply 1 10000 -> 10000
-dqmul1005 multiply 1 100000 -> 100000
-dqmul1006 multiply 1 1000000 -> 1000000
-dqmul1007 multiply 1 10000000 -> 10000000
-dqmul1008 multiply 1 100000000 -> 100000000
-dqmul1009 multiply 1 1000000000 -> 1000000000
-dqmul1010 multiply 1 10000000000 -> 10000000000
-dqmul1011 multiply 1 100000000000 -> 100000000000
-dqmul1012 multiply 1 1000000000000 -> 1000000000000
-dqmul1013 multiply 1 10000000000000 -> 10000000000000
-dqmul1014 multiply 1 100000000000000 -> 100000000000000
-dqmul1015 multiply 1 1000000000000000 -> 1000000000000000
-
-dqmul1016 multiply 1 1000000000000000000 -> 1000000000000000000
-dqmul1017 multiply 1 100000000000000000000000000 -> 100000000000000000000000000
-dqmul1018 multiply 1 1000000000000000000000000000 -> 1000000000000000000000000000
-dqmul1019 multiply 1 10000000000000000000000000000 -> 10000000000000000000000000000
-dqmul1020 multiply 1 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1021 multiply 10 1 -> 10
-dqmul1022 multiply 10 10 -> 100
-dqmul1023 multiply 10 100 -> 1000
-dqmul1024 multiply 10 1000 -> 10000
-dqmul1025 multiply 10 10000 -> 100000
-dqmul1026 multiply 10 100000 -> 1000000
-dqmul1027 multiply 10 1000000 -> 10000000
-dqmul1028 multiply 10 10000000 -> 100000000
-dqmul1029 multiply 10 100000000 -> 1000000000
-dqmul1030 multiply 10 1000000000 -> 10000000000
-dqmul1031 multiply 10 10000000000 -> 100000000000
-dqmul1032 multiply 10 100000000000 -> 1000000000000
-dqmul1033 multiply 10 1000000000000 -> 10000000000000
-dqmul1034 multiply 10 10000000000000 -> 100000000000000
-dqmul1035 multiply 10 100000000000000 -> 1000000000000000
-
-dqmul1036 multiply 10 100000000000000000 -> 1000000000000000000
-dqmul1037 multiply 10 10000000000000000000000000 -> 100000000000000000000000000
-dqmul1038 multiply 10 100000000000000000000000000 -> 1000000000000000000000000000
-dqmul1039 multiply 10 1000000000000000000000000000 -> 10000000000000000000000000000
-dqmul1040 multiply 10 100000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1041 multiply 100 0.1 -> 10.0
-dqmul1042 multiply 100 1 -> 100
-dqmul1043 multiply 100 10 -> 1000
-dqmul1044 multiply 100 100 -> 10000
-dqmul1045 multiply 100 1000 -> 100000
-dqmul1046 multiply 100 10000 -> 1000000
-dqmul1047 multiply 100 100000 -> 10000000
-dqmul1048 multiply 100 1000000 -> 100000000
-dqmul1049 multiply 100 10000000 -> 1000000000
-dqmul1050 multiply 100 100000000 -> 10000000000
-dqmul1051 multiply 100 1000000000 -> 100000000000
-dqmul1052 multiply 100 10000000000 -> 1000000000000
-dqmul1053 multiply 100 100000000000 -> 10000000000000
-dqmul1054 multiply 100 1000000000000 -> 100000000000000
-dqmul1055 multiply 100 10000000000000 -> 1000000000000000
-
-dqmul1056 multiply 100 10000000000000000 -> 1000000000000000000
-dqmul1057 multiply 100 1000000000000000000000000 -> 100000000000000000000000000
-dqmul1058 multiply 100 10000000000000000000000000 -> 1000000000000000000000000000
-dqmul1059 multiply 100 100000000000000000000000000 -> 10000000000000000000000000000
-dqmul1060 multiply 100 10000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1061 multiply 1000 0.01 -> 10.00
-dqmul1062 multiply 1000 0.1 -> 100.0
-dqmul1063 multiply 1000 1 -> 1000
-dqmul1064 multiply 1000 10 -> 10000
-dqmul1065 multiply 1000 100 -> 100000
-dqmul1066 multiply 1000 1000 -> 1000000
-dqmul1067 multiply 1000 10000 -> 10000000
-dqmul1068 multiply 1000 100000 -> 100000000
-dqmul1069 multiply 1000 1000000 -> 1000000000
-dqmul1070 multiply 1000 10000000 -> 10000000000
-dqmul1071 multiply 1000 100000000 -> 100000000000
-dqmul1072 multiply 1000 1000000000 -> 1000000000000
-dqmul1073 multiply 1000 10000000000 -> 10000000000000
-dqmul1074 multiply 1000 100000000000 -> 100000000000000
-dqmul1075 multiply 1000 1000000000000 -> 1000000000000000
-
-dqmul1076 multiply 1000 1000000000000000 -> 1000000000000000000
-dqmul1077 multiply 1000 100000000000000000000000 -> 100000000000000000000000000
-dqmul1078 multiply 1000 1000000000000000000000000 -> 1000000000000000000000000000
-dqmul1079 multiply 1000 10000000000000000000000000 -> 10000000000000000000000000000
-dqmul1080 multiply 1000 1000000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1081 multiply 10000 0.001 -> 10.000
-dqmul1082 multiply 10000 0.01 -> 100.00
-dqmul1083 multiply 10000 0.1 -> 1000.0
-dqmul1084 multiply 10000 1 -> 10000
-dqmul1085 multiply 10000 10 -> 100000
-dqmul1086 multiply 10000 100 -> 1000000
-dqmul1087 multiply 10000 1000 -> 10000000
-dqmul1088 multiply 10000 10000 -> 100000000
-dqmul1089 multiply 10000 100000 -> 1000000000
-dqmul1090 multiply 10000 1000000 -> 10000000000
-dqmul1091 multiply 10000 10000000 -> 100000000000
-dqmul1092 multiply 10000 100000000 -> 1000000000000
-dqmul1093 multiply 10000 1000000000 -> 10000000000000
-dqmul1094 multiply 10000 10000000000 -> 100000000000000
-dqmul1095 multiply 10000 100000000000 -> 1000000000000000
-
-dqmul1096 multiply 10000 100000000000000 -> 1000000000000000000
-dqmul1097 multiply 10000 10000000000000000000000 -> 100000000000000000000000000
-dqmul1098 multiply 10000 100000000000000000000000 -> 1000000000000000000000000000
-dqmul1099 multiply 10000 1000000000000000000000000 -> 10000000000000000000000000000
-dqmul1100 multiply 10000 100000000000000000000000000000 -> 1000000000000000000000000000000000
-
-dqmul1107 multiply 10000 99999999999 -> 999999999990000
-dqmul1108 multiply 10000 99999999999 -> 999999999990000
-
--- Null tests
-dqmul9990 multiply 10 # -> NaN Invalid_operation
-dqmul9991 multiply # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqMultiply.decTest -- decQuad multiplication --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqmul000 multiply 2 2 -> 4
+dqmul001 multiply 2 3 -> 6
+dqmul002 multiply 5 1 -> 5
+dqmul003 multiply 5 2 -> 10
+dqmul004 multiply 1.20 2 -> 2.40
+dqmul005 multiply 1.20 0 -> 0.00
+dqmul006 multiply 1.20 -2 -> -2.40
+dqmul007 multiply -1.20 2 -> -2.40
+dqmul008 multiply -1.20 0 -> -0.00
+dqmul009 multiply -1.20 -2 -> 2.40
+dqmul010 multiply 5.09 7.1 -> 36.139
+dqmul011 multiply 2.5 4 -> 10.0
+dqmul012 multiply 2.50 4 -> 10.00
+dqmul013 multiply 1.23456789 1.0000000000000000000000000000 -> 1.234567890000000000000000000000000 Rounded
+dqmul015 multiply 2.50 4 -> 10.00
+dqmul016 multiply 9.99999999999999999 9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
+dqmul017 multiply 9.99999999999999999 -9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqmul018 multiply -9.99999999999999999 9.99999999999999999 -> -99.99999999999999980000000000000000 Inexact Rounded
+dqmul019 multiply -9.99999999999999999 -9.99999999999999999 -> 99.99999999999999980000000000000000 Inexact Rounded
+
+-- zeros, etc.
+dqmul021 multiply 0 0 -> 0
+dqmul022 multiply 0 -0 -> -0
+dqmul023 multiply -0 0 -> -0
+dqmul024 multiply -0 -0 -> 0
+dqmul025 multiply -0.0 -0.0 -> 0.00
+dqmul026 multiply -0.0 -0.0 -> 0.00
+dqmul027 multiply -0.0 -0.0 -> 0.00
+dqmul028 multiply -0.0 -0.0 -> 0.00
+dqmul030 multiply 5.00 1E-3 -> 0.00500
+dqmul031 multiply 00.00 0.000 -> 0.00000
+dqmul032 multiply 00.00 0E-3 -> 0.00000 -- rhs is 0
+dqmul033 multiply 0E-3 00.00 -> 0.00000 -- lhs is 0
+dqmul034 multiply -5.00 1E-3 -> -0.00500
+dqmul035 multiply -00.00 0.000 -> -0.00000
+dqmul036 multiply -00.00 0E-3 -> -0.00000 -- rhs is 0
+dqmul037 multiply -0E-3 00.00 -> -0.00000 -- lhs is 0
+dqmul038 multiply 5.00 -1E-3 -> -0.00500
+dqmul039 multiply 00.00 -0.000 -> -0.00000
+dqmul040 multiply 00.00 -0E-3 -> -0.00000 -- rhs is 0
+dqmul041 multiply 0E-3 -00.00 -> -0.00000 -- lhs is 0
+dqmul042 multiply -5.00 -1E-3 -> 0.00500
+dqmul043 multiply -00.00 -0.000 -> 0.00000
+dqmul044 multiply -00.00 -0E-3 -> 0.00000 -- rhs is 0
+dqmul045 multiply -0E-3 -00.00 -> 0.00000 -- lhs is 0
+
+-- examples from decarith
+dqmul050 multiply 1.20 3 -> 3.60
+dqmul051 multiply 7 3 -> 21
+dqmul052 multiply 0.9 0.8 -> 0.72
+dqmul053 multiply 0.9 -0 -> -0.0
+dqmul054 multiply 654321 654321 -> 428135971041
+
+dqmul060 multiply 123.45 1e7 -> 1.2345E+9
+dqmul061 multiply 123.45 1e8 -> 1.2345E+10
+dqmul062 multiply 123.45 1e+9 -> 1.2345E+11
+dqmul063 multiply 123.45 1e10 -> 1.2345E+12
+dqmul064 multiply 123.45 1e11 -> 1.2345E+13
+dqmul065 multiply 123.45 1e12 -> 1.2345E+14
+dqmul066 multiply 123.45 1e13 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+-- 1234567890123456
+dqmul080 multiply 0.1 1230123456456789 -> 123012345645678.9
+dqmul084 multiply 0.1 1230123456456789 -> 123012345645678.9
+dqmul090 multiply 1230123456456789 0.1 -> 123012345645678.9
+dqmul094 multiply 1230123456456789 0.1 -> 123012345645678.9
+
+-- test some more edge cases and carries
+dqmul101 multiply 9 9 -> 81
+dqmul102 multiply 9 90 -> 810
+dqmul103 multiply 9 900 -> 8100
+dqmul104 multiply 9 9000 -> 81000
+dqmul105 multiply 9 90000 -> 810000
+dqmul106 multiply 9 900000 -> 8100000
+dqmul107 multiply 9 9000000 -> 81000000
+dqmul108 multiply 9 90000000 -> 810000000
+dqmul109 multiply 9 900000000 -> 8100000000
+dqmul110 multiply 9 9000000000 -> 81000000000
+dqmul111 multiply 9 90000000000 -> 810000000000
+dqmul112 multiply 9 900000000000 -> 8100000000000
+dqmul113 multiply 9 9000000000000 -> 81000000000000
+dqmul114 multiply 9 90000000000000 -> 810000000000000
+dqmul115 multiply 9 900000000000000 -> 8100000000000000
+--dqmul116 multiply 9 9000000000000000 -> 81000000000000000
+--dqmul117 multiply 9 90000000000000000 -> 810000000000000000
+--dqmul118 multiply 9 900000000000000000 -> 8100000000000000000
+--dqmul119 multiply 9 9000000000000000000 -> 81000000000000000000
+--dqmul120 multiply 9 90000000000000000000 -> 810000000000000000000
+--dqmul121 multiply 9 900000000000000000000 -> 8100000000000000000000
+--dqmul122 multiply 9 9000000000000000000000 -> 81000000000000000000000
+--dqmul123 multiply 9 90000000000000000000000 -> 810000000000000000000000
+-- test some more edge cases without carries
+dqmul131 multiply 3 3 -> 9
+dqmul132 multiply 3 30 -> 90
+dqmul133 multiply 3 300 -> 900
+dqmul134 multiply 3 3000 -> 9000
+dqmul135 multiply 3 30000 -> 90000
+dqmul136 multiply 3 300000 -> 900000
+dqmul137 multiply 3 3000000 -> 9000000
+dqmul138 multiply 3 30000000 -> 90000000
+dqmul139 multiply 3 300000000 -> 900000000
+dqmul140 multiply 3 3000000000 -> 9000000000
+dqmul141 multiply 3 30000000000 -> 90000000000
+dqmul142 multiply 3 300000000000 -> 900000000000
+dqmul143 multiply 3 3000000000000 -> 9000000000000
+dqmul144 multiply 3 30000000000000 -> 90000000000000
+dqmul145 multiply 3 300000000000000 -> 900000000000000
+dqmul146 multiply 3 3000000000000000 -> 9000000000000000
+dqmul147 multiply 3 30000000000000000 -> 90000000000000000
+dqmul148 multiply 3 300000000000000000 -> 900000000000000000
+dqmul149 multiply 3 3000000000000000000 -> 9000000000000000000
+dqmul150 multiply 3 30000000000000000000 -> 90000000000000000000
+dqmul151 multiply 3 300000000000000000000 -> 900000000000000000000
+dqmul152 multiply 3 3000000000000000000000 -> 9000000000000000000000
+dqmul153 multiply 3 30000000000000000000000 -> 90000000000000000000000
+
+dqmul263 multiply 30269.587755640502150977251770554 4.8046009735990873395936309640543 -> 145433.2908011933696719165119928296 Inexact Rounded
+
+-- test some edge cases with exact rounding
+dqmul301 multiply 900000000000000000 9 -> 8100000000000000000
+dqmul302 multiply 900000000000000000 90 -> 81000000000000000000
+dqmul303 multiply 900000000000000000 900 -> 810000000000000000000
+dqmul304 multiply 900000000000000000 9000 -> 8100000000000000000000
+dqmul305 multiply 900000000000000000 90000 -> 81000000000000000000000
+dqmul306 multiply 900000000000000000 900000 -> 810000000000000000000000
+dqmul307 multiply 900000000000000000 9000000 -> 8100000000000000000000000
+dqmul308 multiply 900000000000000000 90000000 -> 81000000000000000000000000
+dqmul309 multiply 900000000000000000 900000000 -> 810000000000000000000000000
+dqmul310 multiply 900000000000000000 9000000000 -> 8100000000000000000000000000
+dqmul311 multiply 900000000000000000 90000000000 -> 81000000000000000000000000000
+dqmul312 multiply 900000000000000000 900000000000 -> 810000000000000000000000000000
+dqmul313 multiply 900000000000000000 9000000000000 -> 8100000000000000000000000000000
+dqmul314 multiply 900000000000000000 90000000000000 -> 81000000000000000000000000000000
+dqmul315 multiply 900000000000000000 900000000000000 -> 810000000000000000000000000000000
+dqmul316 multiply 900000000000000000 9000000000000000 -> 8100000000000000000000000000000000
+dqmul317 multiply 9000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+34 Rounded
+dqmul318 multiply 90000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+35 Rounded
+dqmul319 multiply 900000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+36 Rounded
+dqmul320 multiply 9000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+37 Rounded
+dqmul321 multiply 90000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+38 Rounded
+dqmul322 multiply 900000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+39 Rounded
+dqmul323 multiply 9000000000000000000000000 9000000000000000 -> 8.100000000000000000000000000000000E+40 Rounded
+
+-- tryzeros cases
+dqmul504 multiply 0E-4260 1000E-4260 -> 0E-6176 Clamped
+dqmul505 multiply 100E+4260 0E+4260 -> 0E+6111 Clamped
+
+-- mixed with zeros
+dqmul541 multiply 0 -1 -> -0
+dqmul542 multiply -0 -1 -> 0
+dqmul543 multiply 0 1 -> 0
+dqmul544 multiply -0 1 -> -0
+dqmul545 multiply -1 0 -> -0
+dqmul546 multiply -1 -0 -> 0
+dqmul547 multiply 1 0 -> 0
+dqmul548 multiply 1 -0 -> -0
+
+dqmul551 multiply 0.0 -1 -> -0.0
+dqmul552 multiply -0.0 -1 -> 0.0
+dqmul553 multiply 0.0 1 -> 0.0
+dqmul554 multiply -0.0 1 -> -0.0
+dqmul555 multiply -1.0 0 -> -0.0
+dqmul556 multiply -1.0 -0 -> 0.0
+dqmul557 multiply 1.0 0 -> 0.0
+dqmul558 multiply 1.0 -0 -> -0.0
+
+dqmul561 multiply 0 -1.0 -> -0.0
+dqmul562 multiply -0 -1.0 -> 0.0
+dqmul563 multiply 0 1.0 -> 0.0
+dqmul564 multiply -0 1.0 -> -0.0
+dqmul565 multiply -1 0.0 -> -0.0
+dqmul566 multiply -1 -0.0 -> 0.0
+dqmul567 multiply 1 0.0 -> 0.0
+dqmul568 multiply 1 -0.0 -> -0.0
+
+dqmul571 multiply 0.0 -1.0 -> -0.00
+dqmul572 multiply -0.0 -1.0 -> 0.00
+dqmul573 multiply 0.0 1.0 -> 0.00
+dqmul574 multiply -0.0 1.0 -> -0.00
+dqmul575 multiply -1.0 0.0 -> -0.00
+dqmul576 multiply -1.0 -0.0 -> 0.00
+dqmul577 multiply 1.0 0.0 -> 0.00
+dqmul578 multiply 1.0 -0.0 -> -0.00
+
+
+-- Specials
+dqmul580 multiply Inf -Inf -> -Infinity
+dqmul581 multiply Inf -1000 -> -Infinity
+dqmul582 multiply Inf -1 -> -Infinity
+dqmul583 multiply Inf -0 -> NaN Invalid_operation
+dqmul584 multiply Inf 0 -> NaN Invalid_operation
+dqmul585 multiply Inf 1 -> Infinity
+dqmul586 multiply Inf 1000 -> Infinity
+dqmul587 multiply Inf Inf -> Infinity
+dqmul588 multiply -1000 Inf -> -Infinity
+dqmul589 multiply -Inf Inf -> -Infinity
+dqmul590 multiply -1 Inf -> -Infinity
+dqmul591 multiply -0 Inf -> NaN Invalid_operation
+dqmul592 multiply 0 Inf -> NaN Invalid_operation
+dqmul593 multiply 1 Inf -> Infinity
+dqmul594 multiply 1000 Inf -> Infinity
+dqmul595 multiply Inf Inf -> Infinity
+
+dqmul600 multiply -Inf -Inf -> Infinity
+dqmul601 multiply -Inf -1000 -> Infinity
+dqmul602 multiply -Inf -1 -> Infinity
+dqmul603 multiply -Inf -0 -> NaN Invalid_operation
+dqmul604 multiply -Inf 0 -> NaN Invalid_operation
+dqmul605 multiply -Inf 1 -> -Infinity
+dqmul606 multiply -Inf 1000 -> -Infinity
+dqmul607 multiply -Inf Inf -> -Infinity
+dqmul608 multiply -1000 Inf -> -Infinity
+dqmul609 multiply -Inf -Inf -> Infinity
+dqmul610 multiply -1 -Inf -> Infinity
+dqmul611 multiply -0 -Inf -> NaN Invalid_operation
+dqmul612 multiply 0 -Inf -> NaN Invalid_operation
+dqmul613 multiply 1 -Inf -> -Infinity
+dqmul614 multiply 1000 -Inf -> -Infinity
+dqmul615 multiply Inf -Inf -> -Infinity
+
+dqmul621 multiply NaN -Inf -> NaN
+dqmul622 multiply NaN -1000 -> NaN
+dqmul623 multiply NaN -1 -> NaN
+dqmul624 multiply NaN -0 -> NaN
+dqmul625 multiply NaN 0 -> NaN
+dqmul626 multiply NaN 1 -> NaN
+dqmul627 multiply NaN 1000 -> NaN
+dqmul628 multiply NaN Inf -> NaN
+dqmul629 multiply NaN NaN -> NaN
+dqmul630 multiply -Inf NaN -> NaN
+dqmul631 multiply -1000 NaN -> NaN
+dqmul632 multiply -1 NaN -> NaN
+dqmul633 multiply -0 NaN -> NaN
+dqmul634 multiply 0 NaN -> NaN
+dqmul635 multiply 1 NaN -> NaN
+dqmul636 multiply 1000 NaN -> NaN
+dqmul637 multiply Inf NaN -> NaN
+
+dqmul641 multiply sNaN -Inf -> NaN Invalid_operation
+dqmul642 multiply sNaN -1000 -> NaN Invalid_operation
+dqmul643 multiply sNaN -1 -> NaN Invalid_operation
+dqmul644 multiply sNaN -0 -> NaN Invalid_operation
+dqmul645 multiply sNaN 0 -> NaN Invalid_operation
+dqmul646 multiply sNaN 1 -> NaN Invalid_operation
+dqmul647 multiply sNaN 1000 -> NaN Invalid_operation
+dqmul648 multiply sNaN NaN -> NaN Invalid_operation
+dqmul649 multiply sNaN sNaN -> NaN Invalid_operation
+dqmul650 multiply NaN sNaN -> NaN Invalid_operation
+dqmul651 multiply -Inf sNaN -> NaN Invalid_operation
+dqmul652 multiply -1000 sNaN -> NaN Invalid_operation
+dqmul653 multiply -1 sNaN -> NaN Invalid_operation
+dqmul654 multiply -0 sNaN -> NaN Invalid_operation
+dqmul655 multiply 0 sNaN -> NaN Invalid_operation
+dqmul656 multiply 1 sNaN -> NaN Invalid_operation
+dqmul657 multiply 1000 sNaN -> NaN Invalid_operation
+dqmul658 multiply Inf sNaN -> NaN Invalid_operation
+dqmul659 multiply NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqmul661 multiply NaN9 -Inf -> NaN9
+dqmul662 multiply NaN8 999 -> NaN8
+dqmul663 multiply NaN71 Inf -> NaN71
+dqmul664 multiply NaN6 NaN5 -> NaN6
+dqmul665 multiply -Inf NaN4 -> NaN4
+dqmul666 multiply -999 NaN33 -> NaN33
+dqmul667 multiply Inf NaN2 -> NaN2
+
+dqmul671 multiply sNaN99 -Inf -> NaN99 Invalid_operation
+dqmul672 multiply sNaN98 -11 -> NaN98 Invalid_operation
+dqmul673 multiply sNaN97 NaN -> NaN97 Invalid_operation
+dqmul674 multiply sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqmul675 multiply NaN95 sNaN93 -> NaN93 Invalid_operation
+dqmul676 multiply -Inf sNaN92 -> NaN92 Invalid_operation
+dqmul677 multiply 088 sNaN91 -> NaN91 Invalid_operation
+dqmul678 multiply Inf sNaN90 -> NaN90 Invalid_operation
+dqmul679 multiply NaN sNaN89 -> NaN89 Invalid_operation
+
+dqmul681 multiply -NaN9 -Inf -> -NaN9
+dqmul682 multiply -NaN8 999 -> -NaN8
+dqmul683 multiply -NaN71 Inf -> -NaN71
+dqmul684 multiply -NaN6 -NaN5 -> -NaN6
+dqmul685 multiply -Inf -NaN4 -> -NaN4
+dqmul686 multiply -999 -NaN33 -> -NaN33
+dqmul687 multiply Inf -NaN2 -> -NaN2
+
+dqmul691 multiply -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqmul692 multiply -sNaN98 -11 -> -NaN98 Invalid_operation
+dqmul693 multiply -sNaN97 NaN -> -NaN97 Invalid_operation
+dqmul694 multiply -sNaN16 -sNaN94 -> -NaN16 Invalid_operation
+dqmul695 multiply -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqmul696 multiply -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqmul697 multiply 088 -sNaN91 -> -NaN91 Invalid_operation
+dqmul698 multiply Inf -sNaN90 -> -NaN90 Invalid_operation
+dqmul699 multiply -NaN -sNaN89 -> -NaN89 Invalid_operation
+
+dqmul701 multiply -NaN -Inf -> -NaN
+dqmul702 multiply -NaN 999 -> -NaN
+dqmul703 multiply -NaN Inf -> -NaN
+dqmul704 multiply -NaN -NaN -> -NaN
+dqmul705 multiply -Inf -NaN0 -> -NaN
+dqmul706 multiply -999 -NaN -> -NaN
+dqmul707 multiply Inf -NaN -> -NaN
+
+dqmul711 multiply -sNaN -Inf -> -NaN Invalid_operation
+dqmul712 multiply -sNaN -11 -> -NaN Invalid_operation
+dqmul713 multiply -sNaN00 NaN -> -NaN Invalid_operation
+dqmul714 multiply -sNaN -sNaN -> -NaN Invalid_operation
+dqmul715 multiply -NaN -sNaN -> -NaN Invalid_operation
+dqmul716 multiply -Inf -sNaN -> -NaN Invalid_operation
+dqmul717 multiply 088 -sNaN -> -NaN Invalid_operation
+dqmul718 multiply Inf -sNaN -> -NaN Invalid_operation
+dqmul719 multiply -NaN -sNaN -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+-- signs
+dqmul751 multiply 1e+4277 1e+3311 -> Infinity Overflow Inexact Rounded
+dqmul752 multiply 1e+4277 -1e+3311 -> -Infinity Overflow Inexact Rounded
+dqmul753 multiply -1e+4277 1e+3311 -> -Infinity Overflow Inexact Rounded
+dqmul754 multiply -1e+4277 -1e+3311 -> Infinity Overflow Inexact Rounded
+dqmul755 multiply 1e-4277 1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul756 multiply 1e-4277 -1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul757 multiply -1e-4277 1e-3311 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul758 multiply -1e-4277 -1e-3311 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+dqmul760 multiply 1e-6069 1e-101 -> 1E-6170 Subnormal
+dqmul761 multiply 1e-6069 1e-102 -> 1E-6171 Subnormal
+dqmul762 multiply 1e-6069 1e-103 -> 1E-6172 Subnormal
+dqmul763 multiply 1e-6069 1e-104 -> 1E-6173 Subnormal
+dqmul764 multiply 1e-6069 1e-105 -> 1E-6174 Subnormal
+dqmul765 multiply 1e-6069 1e-106 -> 1E-6175 Subnormal
+dqmul766 multiply 1e-6069 1e-107 -> 1E-6176 Subnormal
+dqmul767 multiply 1e-6069 1e-108 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul768 multiply 1e-6069 1e-109 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul769 multiply 1e-6069 1e-110 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+dqmul770 multiply 1e+40 1e+6101 -> 1.000000000000000000000000000000E+6141 Clamped
+dqmul771 multiply 1e+40 1e+6102 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqmul772 multiply 1e+40 1e+6103 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqmul773 multiply 1e+40 1e+6104 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqmul774 multiply 1e+40 1e+6105 -> Infinity Overflow Inexact Rounded
+dqmul775 multiply 1e+40 1e+6106 -> Infinity Overflow Inexact Rounded
+dqmul776 multiply 1e+40 1e+6107 -> Infinity Overflow Inexact Rounded
+dqmul777 multiply 1e+40 1e+6108 -> Infinity Overflow Inexact Rounded
+dqmul778 multiply 1e+40 1e+6109 -> Infinity Overflow Inexact Rounded
+dqmul779 multiply 1e+40 1e+6110 -> Infinity Overflow Inexact Rounded
+
+dqmul801 multiply 1.0000E-6172 1 -> 1.0000E-6172 Subnormal
+dqmul802 multiply 1.000E-6172 1e-1 -> 1.000E-6173 Subnormal
+dqmul803 multiply 1.00E-6172 1e-2 -> 1.00E-6174 Subnormal
+dqmul804 multiply 1.0E-6172 1e-3 -> 1.0E-6175 Subnormal
+dqmul805 multiply 1.0E-6172 1e-4 -> 1E-6176 Subnormal Rounded
+dqmul806 multiply 1.3E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul807 multiply 1.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul808 multiply 1.7E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul809 multiply 2.3E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul810 multiply 2.5E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul811 multiply 2.7E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqmul812 multiply 1.49E-6172 1e-4 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul813 multiply 1.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul814 multiply 1.51E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul815 multiply 2.49E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul816 multiply 2.50E-6172 1e-4 -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqmul817 multiply 2.51E-6172 1e-4 -> 3E-6176 Underflow Subnormal Inexact Rounded
+
+dqmul818 multiply 1E-6172 1e-4 -> 1E-6176 Subnormal
+dqmul819 multiply 3E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul820 multiply 5E-6172 1e-5 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul821 multiply 7E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul822 multiply 9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqmul823 multiply 9.9E-6172 1e-5 -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqmul824 multiply 1E-6172 -1e-4 -> -1E-6176 Subnormal
+dqmul825 multiply 3E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul826 multiply -5E-6172 1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul827 multiply 7E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul828 multiply -9E-6172 1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul829 multiply 9.9E-6172 -1e-5 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqmul830 multiply 3.0E-6172 -1e-5 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqmul831 multiply 1.0E-5977 1e-200 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqmul832 multiply 1.0E-5977 1e-199 -> 1E-6176 Subnormal Rounded
+dqmul833 multiply 1.0E-5977 1e-198 -> 1.0E-6175 Subnormal
+dqmul834 multiply 2.0E-5977 2e-198 -> 4.0E-6175 Subnormal
+dqmul835 multiply 4.0E-5977 4e-198 -> 1.60E-6174 Subnormal
+dqmul836 multiply 10.0E-5977 10e-198 -> 1.000E-6173 Subnormal
+dqmul837 multiply 30.0E-5977 30e-198 -> 9.000E-6173 Subnormal
+dqmul838 multiply 40.0E-5982 40e-166 -> 1.6000E-6145 Subnormal
+dqmul839 multiply 40.0E-5982 40e-165 -> 1.6000E-6144 Subnormal
+dqmul840 multiply 40.0E-5982 40e-164 -> 1.6000E-6143
+
+-- Long operand overflow may be a different path
+dqmul870 multiply 100 9.999E+6143 -> Infinity Inexact Overflow Rounded
+dqmul871 multiply 100 -9.999E+6143 -> -Infinity Inexact Overflow Rounded
+dqmul872 multiply 9.999E+6143 100 -> Infinity Inexact Overflow Rounded
+dqmul873 multiply -9.999E+6143 100 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+dqmul881 multiply 1.2347E-6133 1.2347E-40 -> 1.524E-6173 Inexact Rounded Subnormal Underflow
+dqmul882 multiply 1.234E-6133 1.234E-40 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul883 multiply 1.23E-6133 1.23E-40 -> 1.513E-6173 Inexact Rounded Subnormal Underflow
+dqmul884 multiply 1.2E-6133 1.2E-40 -> 1.44E-6173 Subnormal
+dqmul885 multiply 1.2E-6133 1.2E-41 -> 1.44E-6174 Subnormal
+dqmul886 multiply 1.2E-6133 1.2E-42 -> 1.4E-6175 Subnormal Inexact Rounded Underflow
+dqmul887 multiply 1.2E-6133 1.3E-42 -> 1.6E-6175 Subnormal Inexact Rounded Underflow
+dqmul888 multiply 1.3E-6133 1.3E-42 -> 1.7E-6175 Subnormal Inexact Rounded Underflow
+dqmul889 multiply 1.3E-6133 1.3E-43 -> 2E-6176 Subnormal Inexact Rounded Underflow
+dqmul890 multiply 1.3E-6134 1.3E-43 -> 0E-6176 Clamped Subnormal Inexact Rounded Underflow
+
+dqmul891 multiply 1.2345E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqmul892 multiply 1.23456E-39 1.234E-6133 -> 1.5234E-6172 Inexact Rounded Subnormal Underflow
+dqmul893 multiply 1.2345E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul894 multiply 1.23456E-40 1.234E-6133 -> 1.523E-6173 Inexact Rounded Subnormal Underflow
+dqmul895 multiply 1.2345E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+dqmul896 multiply 1.23456E-41 1.234E-6133 -> 1.52E-6174 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+-- prove operands are exact
+dqmul906 multiply 9.999999999999999999999999999999999E-6143 1 -> 9.999999999999999999999999999999999E-6143
+dqmul907 multiply 1 0.09999999999999999999999999999999999 -> 0.09999999999999999999999999999999999
+-- the next rounds to Nmin
+dqmul908 multiply 9.999999999999999999999999999999999E-6143 0.09999999999999999999999999999999999 -> 1.000000000000000000000000000000000E-6143 Underflow Inexact Subnormal Rounded
+
+-- hugest
+dqmul909 multiply 9999999999999999999999999999999999 9999999999999999999999999999999999 -> 9.999999999999999999999999999999998E+67 Inexact Rounded
+-- VG case
+dqmul910 multiply 8.81125000000001349436E-1548 8.000000000000000000E-1550 -> 7.049000000000010795488000000000000E-3097 Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+dqmul911 multiply 130E-2 120E-2 -> 1.5600
+dqmul912 multiply 130E-2 12E-1 -> 1.560
+dqmul913 multiply 130E-2 1E0 -> 1.30
+dqmul914 multiply 1E2 1E4 -> 1E+6
+
+-- power-of-ten edge cases
+dqmul1001 multiply 1 10 -> 10
+dqmul1002 multiply 1 100 -> 100
+dqmul1003 multiply 1 1000 -> 1000
+dqmul1004 multiply 1 10000 -> 10000
+dqmul1005 multiply 1 100000 -> 100000
+dqmul1006 multiply 1 1000000 -> 1000000
+dqmul1007 multiply 1 10000000 -> 10000000
+dqmul1008 multiply 1 100000000 -> 100000000
+dqmul1009 multiply 1 1000000000 -> 1000000000
+dqmul1010 multiply 1 10000000000 -> 10000000000
+dqmul1011 multiply 1 100000000000 -> 100000000000
+dqmul1012 multiply 1 1000000000000 -> 1000000000000
+dqmul1013 multiply 1 10000000000000 -> 10000000000000
+dqmul1014 multiply 1 100000000000000 -> 100000000000000
+dqmul1015 multiply 1 1000000000000000 -> 1000000000000000
+
+dqmul1016 multiply 1 1000000000000000000 -> 1000000000000000000
+dqmul1017 multiply 1 100000000000000000000000000 -> 100000000000000000000000000
+dqmul1018 multiply 1 1000000000000000000000000000 -> 1000000000000000000000000000
+dqmul1019 multiply 1 10000000000000000000000000000 -> 10000000000000000000000000000
+dqmul1020 multiply 1 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1021 multiply 10 1 -> 10
+dqmul1022 multiply 10 10 -> 100
+dqmul1023 multiply 10 100 -> 1000
+dqmul1024 multiply 10 1000 -> 10000
+dqmul1025 multiply 10 10000 -> 100000
+dqmul1026 multiply 10 100000 -> 1000000
+dqmul1027 multiply 10 1000000 -> 10000000
+dqmul1028 multiply 10 10000000 -> 100000000
+dqmul1029 multiply 10 100000000 -> 1000000000
+dqmul1030 multiply 10 1000000000 -> 10000000000
+dqmul1031 multiply 10 10000000000 -> 100000000000
+dqmul1032 multiply 10 100000000000 -> 1000000000000
+dqmul1033 multiply 10 1000000000000 -> 10000000000000
+dqmul1034 multiply 10 10000000000000 -> 100000000000000
+dqmul1035 multiply 10 100000000000000 -> 1000000000000000
+
+dqmul1036 multiply 10 100000000000000000 -> 1000000000000000000
+dqmul1037 multiply 10 10000000000000000000000000 -> 100000000000000000000000000
+dqmul1038 multiply 10 100000000000000000000000000 -> 1000000000000000000000000000
+dqmul1039 multiply 10 1000000000000000000000000000 -> 10000000000000000000000000000
+dqmul1040 multiply 10 100000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1041 multiply 100 0.1 -> 10.0
+dqmul1042 multiply 100 1 -> 100
+dqmul1043 multiply 100 10 -> 1000
+dqmul1044 multiply 100 100 -> 10000
+dqmul1045 multiply 100 1000 -> 100000
+dqmul1046 multiply 100 10000 -> 1000000
+dqmul1047 multiply 100 100000 -> 10000000
+dqmul1048 multiply 100 1000000 -> 100000000
+dqmul1049 multiply 100 10000000 -> 1000000000
+dqmul1050 multiply 100 100000000 -> 10000000000
+dqmul1051 multiply 100 1000000000 -> 100000000000
+dqmul1052 multiply 100 10000000000 -> 1000000000000
+dqmul1053 multiply 100 100000000000 -> 10000000000000
+dqmul1054 multiply 100 1000000000000 -> 100000000000000
+dqmul1055 multiply 100 10000000000000 -> 1000000000000000
+
+dqmul1056 multiply 100 10000000000000000 -> 1000000000000000000
+dqmul1057 multiply 100 1000000000000000000000000 -> 100000000000000000000000000
+dqmul1058 multiply 100 10000000000000000000000000 -> 1000000000000000000000000000
+dqmul1059 multiply 100 100000000000000000000000000 -> 10000000000000000000000000000
+dqmul1060 multiply 100 10000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1061 multiply 1000 0.01 -> 10.00
+dqmul1062 multiply 1000 0.1 -> 100.0
+dqmul1063 multiply 1000 1 -> 1000
+dqmul1064 multiply 1000 10 -> 10000
+dqmul1065 multiply 1000 100 -> 100000
+dqmul1066 multiply 1000 1000 -> 1000000
+dqmul1067 multiply 1000 10000 -> 10000000
+dqmul1068 multiply 1000 100000 -> 100000000
+dqmul1069 multiply 1000 1000000 -> 1000000000
+dqmul1070 multiply 1000 10000000 -> 10000000000
+dqmul1071 multiply 1000 100000000 -> 100000000000
+dqmul1072 multiply 1000 1000000000 -> 1000000000000
+dqmul1073 multiply 1000 10000000000 -> 10000000000000
+dqmul1074 multiply 1000 100000000000 -> 100000000000000
+dqmul1075 multiply 1000 1000000000000 -> 1000000000000000
+
+dqmul1076 multiply 1000 1000000000000000 -> 1000000000000000000
+dqmul1077 multiply 1000 100000000000000000000000 -> 100000000000000000000000000
+dqmul1078 multiply 1000 1000000000000000000000000 -> 1000000000000000000000000000
+dqmul1079 multiply 1000 10000000000000000000000000 -> 10000000000000000000000000000
+dqmul1080 multiply 1000 1000000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1081 multiply 10000 0.001 -> 10.000
+dqmul1082 multiply 10000 0.01 -> 100.00
+dqmul1083 multiply 10000 0.1 -> 1000.0
+dqmul1084 multiply 10000 1 -> 10000
+dqmul1085 multiply 10000 10 -> 100000
+dqmul1086 multiply 10000 100 -> 1000000
+dqmul1087 multiply 10000 1000 -> 10000000
+dqmul1088 multiply 10000 10000 -> 100000000
+dqmul1089 multiply 10000 100000 -> 1000000000
+dqmul1090 multiply 10000 1000000 -> 10000000000
+dqmul1091 multiply 10000 10000000 -> 100000000000
+dqmul1092 multiply 10000 100000000 -> 1000000000000
+dqmul1093 multiply 10000 1000000000 -> 10000000000000
+dqmul1094 multiply 10000 10000000000 -> 100000000000000
+dqmul1095 multiply 10000 100000000000 -> 1000000000000000
+
+dqmul1096 multiply 10000 100000000000000 -> 1000000000000000000
+dqmul1097 multiply 10000 10000000000000000000000 -> 100000000000000000000000000
+dqmul1098 multiply 10000 100000000000000000000000 -> 1000000000000000000000000000
+dqmul1099 multiply 10000 1000000000000000000000000 -> 10000000000000000000000000000
+dqmul1100 multiply 10000 100000000000000000000000000000 -> 1000000000000000000000000000000000
+
+dqmul1107 multiply 10000 99999999999 -> 999999999990000
+dqmul1108 multiply 10000 99999999999 -> 999999999990000
+
+-- Null tests
+dqmul9990 multiply 10 # -> NaN Invalid_operation
+dqmul9991 multiply # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextMinus.decTest b/Lib/test/decimaltestdata/dqNextMinus.decTest
index 8177b58c6d4..34f39581c3d 100644
--- a/Lib/test/decimaltestdata/dqNextMinus.decTest
+++ b/Lib/test/decimaltestdata/dqNextMinus.decTest
@@ -1,126 +1,126 @@
-------------------------------------------------------------------------
--- dqNextMinus.decTest -- decQuad next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqnextm001 nextminus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999994
-dqnextm002 nextminus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999995
-dqnextm003 nextminus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999996
-dqnextm004 nextminus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999997
-dqnextm005 nextminus 0.9999999999999999999999999999999999 -> 0.9999999999999999999999999999999998
-dqnextm006 nextminus 1.000000000000000000000000000000000 -> 0.9999999999999999999999999999999999
-dqnextm007 nextminus 1.0 -> 0.9999999999999999999999999999999999
-dqnextm008 nextminus 1 -> 0.9999999999999999999999999999999999
-dqnextm009 nextminus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000000
-dqnextm010 nextminus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000001
-dqnextm011 nextminus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000002
-dqnextm012 nextminus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000003
-dqnextm013 nextminus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000004
-dqnextm014 nextminus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000005
-dqnextm015 nextminus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000006
-dqnextm016 nextminus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000007
-dqnextm017 nextminus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000008
-dqnextm018 nextminus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000009
-dqnextm019 nextminus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000010
-dqnextm020 nextminus 1.000000000000000000000000000000012 -> 1.000000000000000000000000000000011
-
-dqnextm021 nextminus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999996
-dqnextm022 nextminus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999997
-dqnextm023 nextminus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999998
-dqnextm024 nextminus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999999
-dqnextm025 nextminus -0.9999999999999999999999999999999999 -> -1.000000000000000000000000000000000
-dqnextm026 nextminus -1.000000000000000000000000000000000 -> -1.000000000000000000000000000000001
-dqnextm027 nextminus -1.0 -> -1.000000000000000000000000000000001
-dqnextm028 nextminus -1 -> -1.000000000000000000000000000000001
-dqnextm029 nextminus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000002
-dqnextm030 nextminus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000003
-dqnextm031 nextminus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000004
-dqnextm032 nextminus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000005
-dqnextm033 nextminus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000006
-dqnextm034 nextminus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000007
-dqnextm035 nextminus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000008
-dqnextm036 nextminus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000009
-dqnextm037 nextminus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000010
-dqnextm038 nextminus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000011
-dqnextm039 nextminus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000012
-
--- ultra-tiny inputs
-dqnextm062 nextminus 1E-6176 -> 0E-6176
-dqnextm065 nextminus -1E-6176 -> -2E-6176
-
--- Zeros
-dqnextm100 nextminus -0 -> -1E-6176
-dqnextm101 nextminus 0 -> -1E-6176
-dqnextm102 nextminus 0.00 -> -1E-6176
-dqnextm103 nextminus -0.00 -> -1E-6176
-dqnextm104 nextminus 0E-300 -> -1E-6176
-dqnextm105 nextminus 0E+300 -> -1E-6176
-dqnextm106 nextminus 0E+30000 -> -1E-6176
-dqnextm107 nextminus -0E+30000 -> -1E-6176
-
--- specials
-dqnextm150 nextminus Inf -> 9.999999999999999999999999999999999E+6144
-dqnextm151 nextminus -Inf -> -Infinity
-dqnextm152 nextminus NaN -> NaN
-dqnextm153 nextminus sNaN -> NaN Invalid_operation
-dqnextm154 nextminus NaN77 -> NaN77
-dqnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-dqnextm156 nextminus -NaN -> -NaN
-dqnextm157 nextminus -sNaN -> -NaN Invalid_operation
-dqnextm158 nextminus -NaN77 -> -NaN77
-dqnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextm170 nextminus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999998E+6144
-dqnextm171 nextminus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999997E+6144
-dqnextm172 nextminus 1E-6143 -> 9.99999999999999999999999999999999E-6144
-dqnextm173 nextminus 1.000000000000000000000000000000000E-6143 -> 9.99999999999999999999999999999999E-6144
-dqnextm174 nextminus 9E-6176 -> 8E-6176
-dqnextm175 nextminus 9.9E-6175 -> 9.8E-6175
-dqnextm176 nextminus 9.99999999999999999999999999999E-6147 -> 9.99999999999999999999999999998E-6147
-dqnextm177 nextminus 9.99999999999999999999999999999999E-6144 -> 9.99999999999999999999999999999998E-6144
-dqnextm178 nextminus 9.99999999999999999999999999999998E-6144 -> 9.99999999999999999999999999999997E-6144
-dqnextm179 nextminus 9.99999999999999999999999999999997E-6144 -> 9.99999999999999999999999999999996E-6144
-dqnextm180 nextminus 0E-6176 -> -1E-6176
-dqnextm181 nextminus 1E-6176 -> 0E-6176
-dqnextm182 nextminus 2E-6176 -> 1E-6176
-
-dqnextm183 nextminus -0E-6176 -> -1E-6176
-dqnextm184 nextminus -1E-6176 -> -2E-6176
-dqnextm185 nextminus -2E-6176 -> -3E-6176
-dqnextm186 nextminus -10E-6176 -> -1.1E-6175
-dqnextm187 nextminus -100E-6176 -> -1.01E-6174
-dqnextm188 nextminus -100000E-6176 -> -1.00001E-6171
-dqnextm189 nextminus -1.00000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm190 nextminus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm191 nextminus -1E-6143 -> -1.000000000000000000000000000000001E-6143
-dqnextm192 nextminus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999999E+6144
-dqnextm193 nextminus -9.999999999999999999999999999999999E+6144 -> -Infinity
-
--- Null tests
-dqnextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextMinus.decTest -- decQuad next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqnextm001 nextminus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999994
+dqnextm002 nextminus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999995
+dqnextm003 nextminus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999996
+dqnextm004 nextminus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999997
+dqnextm005 nextminus 0.9999999999999999999999999999999999 -> 0.9999999999999999999999999999999998
+dqnextm006 nextminus 1.000000000000000000000000000000000 -> 0.9999999999999999999999999999999999
+dqnextm007 nextminus 1.0 -> 0.9999999999999999999999999999999999
+dqnextm008 nextminus 1 -> 0.9999999999999999999999999999999999
+dqnextm009 nextminus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000000
+dqnextm010 nextminus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000001
+dqnextm011 nextminus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000002
+dqnextm012 nextminus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000003
+dqnextm013 nextminus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000004
+dqnextm014 nextminus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000005
+dqnextm015 nextminus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000006
+dqnextm016 nextminus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000007
+dqnextm017 nextminus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000008
+dqnextm018 nextminus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000009
+dqnextm019 nextminus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000010
+dqnextm020 nextminus 1.000000000000000000000000000000012 -> 1.000000000000000000000000000000011
+
+dqnextm021 nextminus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999996
+dqnextm022 nextminus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999997
+dqnextm023 nextminus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999998
+dqnextm024 nextminus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999999
+dqnextm025 nextminus -0.9999999999999999999999999999999999 -> -1.000000000000000000000000000000000
+dqnextm026 nextminus -1.000000000000000000000000000000000 -> -1.000000000000000000000000000000001
+dqnextm027 nextminus -1.0 -> -1.000000000000000000000000000000001
+dqnextm028 nextminus -1 -> -1.000000000000000000000000000000001
+dqnextm029 nextminus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000002
+dqnextm030 nextminus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000003
+dqnextm031 nextminus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000004
+dqnextm032 nextminus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000005
+dqnextm033 nextminus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000006
+dqnextm034 nextminus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000007
+dqnextm035 nextminus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000008
+dqnextm036 nextminus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000009
+dqnextm037 nextminus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000010
+dqnextm038 nextminus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000011
+dqnextm039 nextminus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000012
+
+-- ultra-tiny inputs
+dqnextm062 nextminus 1E-6176 -> 0E-6176
+dqnextm065 nextminus -1E-6176 -> -2E-6176
+
+-- Zeros
+dqnextm100 nextminus -0 -> -1E-6176
+dqnextm101 nextminus 0 -> -1E-6176
+dqnextm102 nextminus 0.00 -> -1E-6176
+dqnextm103 nextminus -0.00 -> -1E-6176
+dqnextm104 nextminus 0E-300 -> -1E-6176
+dqnextm105 nextminus 0E+300 -> -1E-6176
+dqnextm106 nextminus 0E+30000 -> -1E-6176
+dqnextm107 nextminus -0E+30000 -> -1E-6176
+
+-- specials
+dqnextm150 nextminus Inf -> 9.999999999999999999999999999999999E+6144
+dqnextm151 nextminus -Inf -> -Infinity
+dqnextm152 nextminus NaN -> NaN
+dqnextm153 nextminus sNaN -> NaN Invalid_operation
+dqnextm154 nextminus NaN77 -> NaN77
+dqnextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+dqnextm156 nextminus -NaN -> -NaN
+dqnextm157 nextminus -sNaN -> -NaN Invalid_operation
+dqnextm158 nextminus -NaN77 -> -NaN77
+dqnextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextm170 nextminus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999998E+6144
+dqnextm171 nextminus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999997E+6144
+dqnextm172 nextminus 1E-6143 -> 9.99999999999999999999999999999999E-6144
+dqnextm173 nextminus 1.000000000000000000000000000000000E-6143 -> 9.99999999999999999999999999999999E-6144
+dqnextm174 nextminus 9E-6176 -> 8E-6176
+dqnextm175 nextminus 9.9E-6175 -> 9.8E-6175
+dqnextm176 nextminus 9.99999999999999999999999999999E-6147 -> 9.99999999999999999999999999998E-6147
+dqnextm177 nextminus 9.99999999999999999999999999999999E-6144 -> 9.99999999999999999999999999999998E-6144
+dqnextm178 nextminus 9.99999999999999999999999999999998E-6144 -> 9.99999999999999999999999999999997E-6144
+dqnextm179 nextminus 9.99999999999999999999999999999997E-6144 -> 9.99999999999999999999999999999996E-6144
+dqnextm180 nextminus 0E-6176 -> -1E-6176
+dqnextm181 nextminus 1E-6176 -> 0E-6176
+dqnextm182 nextminus 2E-6176 -> 1E-6176
+
+dqnextm183 nextminus -0E-6176 -> -1E-6176
+dqnextm184 nextminus -1E-6176 -> -2E-6176
+dqnextm185 nextminus -2E-6176 -> -3E-6176
+dqnextm186 nextminus -10E-6176 -> -1.1E-6175
+dqnextm187 nextminus -100E-6176 -> -1.01E-6174
+dqnextm188 nextminus -100000E-6176 -> -1.00001E-6171
+dqnextm189 nextminus -1.00000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm190 nextminus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm191 nextminus -1E-6143 -> -1.000000000000000000000000000000001E-6143
+dqnextm192 nextminus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999999E+6144
+dqnextm193 nextminus -9.999999999999999999999999999999999E+6144 -> -Infinity
+
+-- Null tests
+dqnextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextPlus.decTest b/Lib/test/decimaltestdata/dqNextPlus.decTest
index 8c8e9cd2e79..ac3f04e69b7 100644
--- a/Lib/test/decimaltestdata/dqNextPlus.decTest
+++ b/Lib/test/decimaltestdata/dqNextPlus.decTest
@@ -1,124 +1,124 @@
-------------------------------------------------------------------------
--- dqNextPlus.decTest -- decQuad next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqnextp001 nextplus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999996
-dqnextp002 nextplus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999997
-dqnextp003 nextplus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999998
-dqnextp004 nextplus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999999
-dqnextp005 nextplus 0.9999999999999999999999999999999999 -> 1.000000000000000000000000000000000
-dqnextp006 nextplus 1.000000000000000000000000000000000 -> 1.000000000000000000000000000000001
-dqnextp007 nextplus 1.0 -> 1.000000000000000000000000000000001
-dqnextp008 nextplus 1 -> 1.000000000000000000000000000000001
-dqnextp009 nextplus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000002
-dqnextp010 nextplus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000003
-dqnextp011 nextplus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000004
-dqnextp012 nextplus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000005
-dqnextp013 nextplus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000006
-dqnextp014 nextplus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000007
-dqnextp015 nextplus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000008
-dqnextp016 nextplus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000009
-dqnextp017 nextplus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000010
-dqnextp018 nextplus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000011
-dqnextp019 nextplus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000012
-
-dqnextp021 nextplus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999994
-dqnextp022 nextplus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999995
-dqnextp023 nextplus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999996
-dqnextp024 nextplus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999997
-dqnextp025 nextplus -0.9999999999999999999999999999999999 -> -0.9999999999999999999999999999999998
-dqnextp026 nextplus -1.000000000000000000000000000000000 -> -0.9999999999999999999999999999999999
-dqnextp027 nextplus -1.0 -> -0.9999999999999999999999999999999999
-dqnextp028 nextplus -1 -> -0.9999999999999999999999999999999999
-dqnextp029 nextplus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000000
-dqnextp030 nextplus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000001
-dqnextp031 nextplus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000002
-dqnextp032 nextplus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000003
-dqnextp033 nextplus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000004
-dqnextp034 nextplus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000005
-dqnextp035 nextplus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000006
-dqnextp036 nextplus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000007
-dqnextp037 nextplus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000008
-dqnextp038 nextplus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000009
-dqnextp039 nextplus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000010
-dqnextp040 nextplus -1.000000000000000000000000000000012 -> -1.000000000000000000000000000000011
-
--- Zeros
-dqnextp100 nextplus 0 -> 1E-6176
-dqnextp101 nextplus 0.00 -> 1E-6176
-dqnextp102 nextplus 0E-300 -> 1E-6176
-dqnextp103 nextplus 0E+300 -> 1E-6176
-dqnextp104 nextplus 0E+30000 -> 1E-6176
-dqnextp105 nextplus -0 -> 1E-6176
-dqnextp106 nextplus -0.00 -> 1E-6176
-dqnextp107 nextplus -0E-300 -> 1E-6176
-dqnextp108 nextplus -0E+300 -> 1E-6176
-dqnextp109 nextplus -0E+30000 -> 1E-6176
-
--- specials
-dqnextp150 nextplus Inf -> Infinity
-dqnextp151 nextplus -Inf -> -9.999999999999999999999999999999999E+6144
-dqnextp152 nextplus NaN -> NaN
-dqnextp153 nextplus sNaN -> NaN Invalid_operation
-dqnextp154 nextplus NaN77 -> NaN77
-dqnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-dqnextp156 nextplus -NaN -> -NaN
-dqnextp157 nextplus -sNaN -> -NaN Invalid_operation
-dqnextp158 nextplus -NaN77 -> -NaN77
-dqnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextp170 nextplus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999998E+6144
-dqnextp171 nextplus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999997E+6144
-dqnextp172 nextplus -1E-6143 -> -9.99999999999999999999999999999999E-6144
-dqnextp173 nextplus -1.000000000000000E-6143 -> -9.99999999999999999999999999999999E-6144
-dqnextp174 nextplus -9E-6176 -> -8E-6176
-dqnextp175 nextplus -9.9E-6175 -> -9.8E-6175
-dqnextp176 nextplus -9.99999999999999999999999999999E-6147 -> -9.99999999999999999999999999998E-6147
-dqnextp177 nextplus -9.99999999999999999999999999999999E-6144 -> -9.99999999999999999999999999999998E-6144
-dqnextp178 nextplus -9.99999999999999999999999999999998E-6144 -> -9.99999999999999999999999999999997E-6144
-dqnextp179 nextplus -9.99999999999999999999999999999997E-6144 -> -9.99999999999999999999999999999996E-6144
-dqnextp180 nextplus -0E-6176 -> 1E-6176
-dqnextp181 nextplus -1E-6176 -> -0E-6176
-dqnextp182 nextplus -2E-6176 -> -1E-6176
-
-dqnextp183 nextplus 0E-6176 -> 1E-6176
-dqnextp184 nextplus 1E-6176 -> 2E-6176
-dqnextp185 nextplus 2E-6176 -> 3E-6176
-dqnextp186 nextplus 10E-6176 -> 1.1E-6175
-dqnextp187 nextplus 100E-6176 -> 1.01E-6174
-dqnextp188 nextplus 100000E-6176 -> 1.00001E-6171
-dqnextp189 nextplus 1.00000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp190 nextplus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp191 nextplus 1E-6143 -> 1.000000000000000000000000000000001E-6143
-dqnextp192 nextplus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999999E+6144
-dqnextp193 nextplus 9.999999999999999999999999999999999E+6144 -> Infinity
-
--- Null tests
-dqnextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextPlus.decTest -- decQuad next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqnextp001 nextplus 0.9999999999999999999999999999999995 -> 0.9999999999999999999999999999999996
+dqnextp002 nextplus 0.9999999999999999999999999999999996 -> 0.9999999999999999999999999999999997
+dqnextp003 nextplus 0.9999999999999999999999999999999997 -> 0.9999999999999999999999999999999998
+dqnextp004 nextplus 0.9999999999999999999999999999999998 -> 0.9999999999999999999999999999999999
+dqnextp005 nextplus 0.9999999999999999999999999999999999 -> 1.000000000000000000000000000000000
+dqnextp006 nextplus 1.000000000000000000000000000000000 -> 1.000000000000000000000000000000001
+dqnextp007 nextplus 1.0 -> 1.000000000000000000000000000000001
+dqnextp008 nextplus 1 -> 1.000000000000000000000000000000001
+dqnextp009 nextplus 1.000000000000000000000000000000001 -> 1.000000000000000000000000000000002
+dqnextp010 nextplus 1.000000000000000000000000000000002 -> 1.000000000000000000000000000000003
+dqnextp011 nextplus 1.000000000000000000000000000000003 -> 1.000000000000000000000000000000004
+dqnextp012 nextplus 1.000000000000000000000000000000004 -> 1.000000000000000000000000000000005
+dqnextp013 nextplus 1.000000000000000000000000000000005 -> 1.000000000000000000000000000000006
+dqnextp014 nextplus 1.000000000000000000000000000000006 -> 1.000000000000000000000000000000007
+dqnextp015 nextplus 1.000000000000000000000000000000007 -> 1.000000000000000000000000000000008
+dqnextp016 nextplus 1.000000000000000000000000000000008 -> 1.000000000000000000000000000000009
+dqnextp017 nextplus 1.000000000000000000000000000000009 -> 1.000000000000000000000000000000010
+dqnextp018 nextplus 1.000000000000000000000000000000010 -> 1.000000000000000000000000000000011
+dqnextp019 nextplus 1.000000000000000000000000000000011 -> 1.000000000000000000000000000000012
+
+dqnextp021 nextplus -0.9999999999999999999999999999999995 -> -0.9999999999999999999999999999999994
+dqnextp022 nextplus -0.9999999999999999999999999999999996 -> -0.9999999999999999999999999999999995
+dqnextp023 nextplus -0.9999999999999999999999999999999997 -> -0.9999999999999999999999999999999996
+dqnextp024 nextplus -0.9999999999999999999999999999999998 -> -0.9999999999999999999999999999999997
+dqnextp025 nextplus -0.9999999999999999999999999999999999 -> -0.9999999999999999999999999999999998
+dqnextp026 nextplus -1.000000000000000000000000000000000 -> -0.9999999999999999999999999999999999
+dqnextp027 nextplus -1.0 -> -0.9999999999999999999999999999999999
+dqnextp028 nextplus -1 -> -0.9999999999999999999999999999999999
+dqnextp029 nextplus -1.000000000000000000000000000000001 -> -1.000000000000000000000000000000000
+dqnextp030 nextplus -1.000000000000000000000000000000002 -> -1.000000000000000000000000000000001
+dqnextp031 nextplus -1.000000000000000000000000000000003 -> -1.000000000000000000000000000000002
+dqnextp032 nextplus -1.000000000000000000000000000000004 -> -1.000000000000000000000000000000003
+dqnextp033 nextplus -1.000000000000000000000000000000005 -> -1.000000000000000000000000000000004
+dqnextp034 nextplus -1.000000000000000000000000000000006 -> -1.000000000000000000000000000000005
+dqnextp035 nextplus -1.000000000000000000000000000000007 -> -1.000000000000000000000000000000006
+dqnextp036 nextplus -1.000000000000000000000000000000008 -> -1.000000000000000000000000000000007
+dqnextp037 nextplus -1.000000000000000000000000000000009 -> -1.000000000000000000000000000000008
+dqnextp038 nextplus -1.000000000000000000000000000000010 -> -1.000000000000000000000000000000009
+dqnextp039 nextplus -1.000000000000000000000000000000011 -> -1.000000000000000000000000000000010
+dqnextp040 nextplus -1.000000000000000000000000000000012 -> -1.000000000000000000000000000000011
+
+-- Zeros
+dqnextp100 nextplus 0 -> 1E-6176
+dqnextp101 nextplus 0.00 -> 1E-6176
+dqnextp102 nextplus 0E-300 -> 1E-6176
+dqnextp103 nextplus 0E+300 -> 1E-6176
+dqnextp104 nextplus 0E+30000 -> 1E-6176
+dqnextp105 nextplus -0 -> 1E-6176
+dqnextp106 nextplus -0.00 -> 1E-6176
+dqnextp107 nextplus -0E-300 -> 1E-6176
+dqnextp108 nextplus -0E+300 -> 1E-6176
+dqnextp109 nextplus -0E+30000 -> 1E-6176
+
+-- specials
+dqnextp150 nextplus Inf -> Infinity
+dqnextp151 nextplus -Inf -> -9.999999999999999999999999999999999E+6144
+dqnextp152 nextplus NaN -> NaN
+dqnextp153 nextplus sNaN -> NaN Invalid_operation
+dqnextp154 nextplus NaN77 -> NaN77
+dqnextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+dqnextp156 nextplus -NaN -> -NaN
+dqnextp157 nextplus -sNaN -> -NaN Invalid_operation
+dqnextp158 nextplus -NaN77 -> -NaN77
+dqnextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextp170 nextplus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999998E+6144
+dqnextp171 nextplus -9.999999999999999999999999999999998E+6144 -> -9.999999999999999999999999999999997E+6144
+dqnextp172 nextplus -1E-6143 -> -9.99999999999999999999999999999999E-6144
+dqnextp173 nextplus -1.000000000000000E-6143 -> -9.99999999999999999999999999999999E-6144
+dqnextp174 nextplus -9E-6176 -> -8E-6176
+dqnextp175 nextplus -9.9E-6175 -> -9.8E-6175
+dqnextp176 nextplus -9.99999999999999999999999999999E-6147 -> -9.99999999999999999999999999998E-6147
+dqnextp177 nextplus -9.99999999999999999999999999999999E-6144 -> -9.99999999999999999999999999999998E-6144
+dqnextp178 nextplus -9.99999999999999999999999999999998E-6144 -> -9.99999999999999999999999999999997E-6144
+dqnextp179 nextplus -9.99999999999999999999999999999997E-6144 -> -9.99999999999999999999999999999996E-6144
+dqnextp180 nextplus -0E-6176 -> 1E-6176
+dqnextp181 nextplus -1E-6176 -> -0E-6176
+dqnextp182 nextplus -2E-6176 -> -1E-6176
+
+dqnextp183 nextplus 0E-6176 -> 1E-6176
+dqnextp184 nextplus 1E-6176 -> 2E-6176
+dqnextp185 nextplus 2E-6176 -> 3E-6176
+dqnextp186 nextplus 10E-6176 -> 1.1E-6175
+dqnextp187 nextplus 100E-6176 -> 1.01E-6174
+dqnextp188 nextplus 100000E-6176 -> 1.00001E-6171
+dqnextp189 nextplus 1.00000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp190 nextplus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp191 nextplus 1E-6143 -> 1.000000000000000000000000000000001E-6143
+dqnextp192 nextplus 9.999999999999999999999999999999998E+6144 -> 9.999999999999999999999999999999999E+6144
+dqnextp193 nextplus 9.999999999999999999999999999999999E+6144 -> Infinity
+
+-- Null tests
+dqnextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqNextToward.decTest b/Lib/test/decimaltestdata/dqNextToward.decTest
index 107e7f5c50f..e6d1e0befb2 100644
--- a/Lib/test/decimaltestdata/dqNextToward.decTest
+++ b/Lib/test/decimaltestdata/dqNextToward.decTest
@@ -1,375 +1,375 @@
-------------------------------------------------------------------------
--- dqNextToward.decTest -- decQuad next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-
--- Sanity check with a scattering of numerics
-dqnextt001 nexttoward 10 10 -> 10
-dqnextt002 nexttoward -10 -10 -> -10
-dqnextt003 nexttoward 1 10 -> 1.000000000000000000000000000000001
-dqnextt004 nexttoward 1 -10 -> 0.9999999999999999999999999999999999
-dqnextt005 nexttoward -1 10 -> -0.9999999999999999999999999999999999
-dqnextt006 nexttoward -1 -10 -> -1.000000000000000000000000000000001
-dqnextt007 nexttoward 0 10 -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt008 nexttoward 0 -10 -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt009 nexttoward 9.999999999999999999999999999999999E+6144 +Infinity -> Infinity Overflow Inexact Rounded
-dqnextt010 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
-dqnextt011 nexttoward 9.999999999999999999999999999999999 10 -> 10.00000000000000000000000000000000
-dqnextt012 nexttoward 10 9.999999999999999999999999999999999 -> 9.999999999999999999999999999999999
-dqnextt013 nexttoward -9.999999999999999999999999999999999 -10 -> -10.00000000000000000000000000000000
-dqnextt014 nexttoward -10 -9.999999999999999999999999999999999 -> -9.999999999999999999999999999999999
-dqnextt015 nexttoward 9.999999999999999999999999999999998 10 -> 9.999999999999999999999999999999999
-dqnextt016 nexttoward 10 9.999999999999999999999999999999998 -> 9.999999999999999999999999999999999
-dqnextt017 nexttoward -9.999999999999999999999999999999998 -10 -> -9.999999999999999999999999999999999
-dqnextt018 nexttoward -10 -9.999999999999999999999999999999998 -> -9.999999999999999999999999999999999
-
-------- lhs=rhs
--- finites
-dqnextt101 nexttoward 7 7 -> 7
-dqnextt102 nexttoward -7 -7 -> -7
-dqnextt103 nexttoward 75 75 -> 75
-dqnextt104 nexttoward -75 -75 -> -75
-dqnextt105 nexttoward 7.50 7.5 -> 7.50
-dqnextt106 nexttoward -7.50 -7.50 -> -7.50
-dqnextt107 nexttoward 7.500 7.5000 -> 7.500
-dqnextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-dqnextt111 nexttoward 0 0 -> 0
-dqnextt112 nexttoward -0 -0 -> -0
-dqnextt113 nexttoward 0E+4 0 -> 0E+4
-dqnextt114 nexttoward -0E+4 -0 -> -0E+4
-dqnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
-dqnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
-dqnextt117 nexttoward 0E-141 0 -> 0E-141
-dqnextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-dqnextt121 nexttoward 268268268 268268268 -> 268268268
-dqnextt122 nexttoward -268268268 -268268268 -> -268268268
-dqnextt123 nexttoward 134134134 134134134 -> 134134134
-dqnextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-dqnextt131 nexttoward 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqnextt132 nexttoward 1E-6143 1E-6143 -> 1E-6143
-dqnextt133 nexttoward 1.000000000000000000000000000000000E-6143 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqnextt134 nexttoward 1E-6176 1E-6176 -> 1E-6176
-
-dqnextt135 nexttoward -1E-6176 -1E-6176 -> -1E-6176
-dqnextt136 nexttoward -1.000000000000000000000000000000000E-6143 -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqnextt137 nexttoward -1E-6143 -1E-6143 -> -1E-6143
-dqnextt138 nexttoward -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-
-------- lhs<rhs
-dqnextt201 nexttoward 0.9999999999999999999999999999999995 Infinity -> 0.9999999999999999999999999999999996
-dqnextt202 nexttoward 0.9999999999999999999999999999999996 Infinity -> 0.9999999999999999999999999999999997
-dqnextt203 nexttoward 0.9999999999999999999999999999999997 Infinity -> 0.9999999999999999999999999999999998
-dqnextt204 nexttoward 0.9999999999999999999999999999999998 Infinity -> 0.9999999999999999999999999999999999
-dqnextt205 nexttoward 0.9999999999999999999999999999999999 Infinity -> 1.000000000000000000000000000000000
-dqnextt206 nexttoward 1.000000000000000000000000000000000 Infinity -> 1.000000000000000000000000000000001
-dqnextt207 nexttoward 1.0 Infinity -> 1.000000000000000000000000000000001
-dqnextt208 nexttoward 1 Infinity -> 1.000000000000000000000000000000001
-dqnextt209 nexttoward 1.000000000000000000000000000000001 Infinity -> 1.000000000000000000000000000000002
-dqnextt210 nexttoward 1.000000000000000000000000000000002 Infinity -> 1.000000000000000000000000000000003
-dqnextt211 nexttoward 1.000000000000000000000000000000003 Infinity -> 1.000000000000000000000000000000004
-dqnextt212 nexttoward 1.000000000000000000000000000000004 Infinity -> 1.000000000000000000000000000000005
-dqnextt213 nexttoward 1.000000000000000000000000000000005 Infinity -> 1.000000000000000000000000000000006
-dqnextt214 nexttoward 1.000000000000000000000000000000006 Infinity -> 1.000000000000000000000000000000007
-dqnextt215 nexttoward 1.000000000000000000000000000000007 Infinity -> 1.000000000000000000000000000000008
-dqnextt216 nexttoward 1.000000000000000000000000000000008 Infinity -> 1.000000000000000000000000000000009
-dqnextt217 nexttoward 1.000000000000000000000000000000009 Infinity -> 1.000000000000000000000000000000010
-dqnextt218 nexttoward 1.000000000000000000000000000000010 Infinity -> 1.000000000000000000000000000000011
-dqnextt219 nexttoward 1.000000000000000000000000000000011 Infinity -> 1.000000000000000000000000000000012
-
-dqnextt221 nexttoward -0.9999999999999999999999999999999995 Infinity -> -0.9999999999999999999999999999999994
-dqnextt222 nexttoward -0.9999999999999999999999999999999996 Infinity -> -0.9999999999999999999999999999999995
-dqnextt223 nexttoward -0.9999999999999999999999999999999997 Infinity -> -0.9999999999999999999999999999999996
-dqnextt224 nexttoward -0.9999999999999999999999999999999998 Infinity -> -0.9999999999999999999999999999999997
-dqnextt225 nexttoward -0.9999999999999999999999999999999999 Infinity -> -0.9999999999999999999999999999999998
-dqnextt226 nexttoward -1.000000000000000000000000000000000 Infinity -> -0.9999999999999999999999999999999999
-dqnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999999999999999999999
-dqnextt228 nexttoward -1 Infinity -> -0.9999999999999999999999999999999999
-dqnextt229 nexttoward -1.000000000000000000000000000000001 Infinity -> -1.000000000000000000000000000000000
-dqnextt230 nexttoward -1.000000000000000000000000000000002 Infinity -> -1.000000000000000000000000000000001
-dqnextt231 nexttoward -1.000000000000000000000000000000003 Infinity -> -1.000000000000000000000000000000002
-dqnextt232 nexttoward -1.000000000000000000000000000000004 Infinity -> -1.000000000000000000000000000000003
-dqnextt233 nexttoward -1.000000000000000000000000000000005 Infinity -> -1.000000000000000000000000000000004
-dqnextt234 nexttoward -1.000000000000000000000000000000006 Infinity -> -1.000000000000000000000000000000005
-dqnextt235 nexttoward -1.000000000000000000000000000000007 Infinity -> -1.000000000000000000000000000000006
-dqnextt236 nexttoward -1.000000000000000000000000000000008 Infinity -> -1.000000000000000000000000000000007
-dqnextt237 nexttoward -1.000000000000000000000000000000009 Infinity -> -1.000000000000000000000000000000008
-dqnextt238 nexttoward -1.000000000000000000000000000000010 Infinity -> -1.000000000000000000000000000000009
-dqnextt239 nexttoward -1.000000000000000000000000000000011 Infinity -> -1.000000000000000000000000000000010
-dqnextt240 nexttoward -1.000000000000000000000000000000012 Infinity -> -1.000000000000000000000000000000011
-
--- Zeros
-dqnextt300 nexttoward 0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt301 nexttoward 0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt302 nexttoward 0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt303 nexttoward 0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt304 nexttoward 0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt305 nexttoward -0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt306 nexttoward -0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt307 nexttoward -0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt308 nexttoward -0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt309 nexttoward -0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-
--- specials
-dqnextt350 nexttoward Inf Infinity -> Infinity
-dqnextt351 nexttoward -Inf Infinity -> -9.999999999999999999999999999999999E+6144
-dqnextt352 nexttoward NaN Infinity -> NaN
-dqnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-dqnextt354 nexttoward NaN77 Infinity -> NaN77
-dqnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-dqnextt356 nexttoward -NaN Infinity -> -NaN
-dqnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-dqnextt358 nexttoward -NaN77 Infinity -> -NaN77
-dqnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextt370 nexttoward -9.999999999999999999999999999999999E+6144 Infinity -> -9.999999999999999999999999999999998E+6144
-dqnextt371 nexttoward -9.999999999999999999999999999999998E+6144 Infinity -> -9.999999999999999999999999999999997E+6144
-dqnextt372 nexttoward -1E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt373 nexttoward -1.000000000000000E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt374 nexttoward -9E-6176 Infinity -> -8E-6176 Underflow Subnormal Inexact Rounded
-dqnextt375 nexttoward -9.9E-6175 Infinity -> -9.8E-6175 Underflow Subnormal Inexact Rounded
-dqnextt376 nexttoward -9.99999999999999999999999999999E-6147 Infinity -> -9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
-dqnextt377 nexttoward -9.99999999999999999999999999999999E-6144 Infinity -> -9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
-dqnextt378 nexttoward -9.99999999999999999999999999999998E-6144 Infinity -> -9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
-dqnextt379 nexttoward -9.99999999999999999999999999999997E-6144 Infinity -> -9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
-dqnextt380 nexttoward -0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt381 nexttoward -1E-6176 Infinity -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqnextt382 nexttoward -2E-6176 Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-
-dqnextt383 nexttoward 0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt384 nexttoward 1E-6176 Infinity -> 2E-6176 Underflow Subnormal Inexact Rounded
-dqnextt385 nexttoward 2E-6176 Infinity -> 3E-6176 Underflow Subnormal Inexact Rounded
-dqnextt386 nexttoward 10E-6176 Infinity -> 1.1E-6175 Underflow Subnormal Inexact Rounded
-dqnextt387 nexttoward 100E-6176 Infinity -> 1.01E-6174 Underflow Subnormal Inexact Rounded
-dqnextt388 nexttoward 100000E-6176 Infinity -> 1.00001E-6171 Underflow Subnormal Inexact Rounded
-dqnextt389 nexttoward 1.00000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt390 nexttoward 1.000000000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt391 nexttoward 1E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
-dqnextt392 nexttoward 9.999999999999999999999999999999997E+6144 Infinity -> 9.999999999999999999999999999999998E+6144
-dqnextt393 nexttoward 9.999999999999999999999999999999998E+6144 Infinity -> 9.999999999999999999999999999999999E+6144
-dqnextt394 nexttoward 9.999999999999999999999999999999999E+6144 Infinity -> Infinity Overflow Inexact Rounded
-
-------- lhs>rhs
-dqnextt401 nexttoward 0.9999999999999999999999999999999995 -Infinity -> 0.9999999999999999999999999999999994
-dqnextt402 nexttoward 0.9999999999999999999999999999999996 -Infinity -> 0.9999999999999999999999999999999995
-dqnextt403 nexttoward 0.9999999999999999999999999999999997 -Infinity -> 0.9999999999999999999999999999999996
-dqnextt404 nexttoward 0.9999999999999999999999999999999998 -Infinity -> 0.9999999999999999999999999999999997
-dqnextt405 nexttoward 0.9999999999999999999999999999999999 -Infinity -> 0.9999999999999999999999999999999998
-dqnextt406 nexttoward 1.000000000000000000000000000000000 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt408 nexttoward 1 -Infinity -> 0.9999999999999999999999999999999999
-dqnextt409 nexttoward 1.000000000000000000000000000000001 -Infinity -> 1.000000000000000000000000000000000
-dqnextt410 nexttoward 1.000000000000000000000000000000002 -Infinity -> 1.000000000000000000000000000000001
-dqnextt411 nexttoward 1.000000000000000000000000000000003 -Infinity -> 1.000000000000000000000000000000002
-dqnextt412 nexttoward 1.000000000000000000000000000000004 -Infinity -> 1.000000000000000000000000000000003
-dqnextt413 nexttoward 1.000000000000000000000000000000005 -Infinity -> 1.000000000000000000000000000000004
-dqnextt414 nexttoward 1.000000000000000000000000000000006 -Infinity -> 1.000000000000000000000000000000005
-dqnextt415 nexttoward 1.000000000000000000000000000000007 -Infinity -> 1.000000000000000000000000000000006
-dqnextt416 nexttoward 1.000000000000000000000000000000008 -Infinity -> 1.000000000000000000000000000000007
-dqnextt417 nexttoward 1.000000000000000000000000000000009 -Infinity -> 1.000000000000000000000000000000008
-dqnextt418 nexttoward 1.000000000000000000000000000000010 -Infinity -> 1.000000000000000000000000000000009
-dqnextt419 nexttoward 1.000000000000000000000000000000011 -Infinity -> 1.000000000000000000000000000000010
-dqnextt420 nexttoward 1.000000000000000000000000000000012 -Infinity -> 1.000000000000000000000000000000011
-
-dqnextt421 nexttoward -0.9999999999999999999999999999999995 -Infinity -> -0.9999999999999999999999999999999996
-dqnextt422 nexttoward -0.9999999999999999999999999999999996 -Infinity -> -0.9999999999999999999999999999999997
-dqnextt423 nexttoward -0.9999999999999999999999999999999997 -Infinity -> -0.9999999999999999999999999999999998
-dqnextt424 nexttoward -0.9999999999999999999999999999999998 -Infinity -> -0.9999999999999999999999999999999999
-dqnextt425 nexttoward -0.9999999999999999999999999999999999 -Infinity -> -1.000000000000000000000000000000000
-dqnextt426 nexttoward -1.000000000000000000000000000000000 -Infinity -> -1.000000000000000000000000000000001
-dqnextt427 nexttoward -1.0 -Infinity -> -1.000000000000000000000000000000001
-dqnextt428 nexttoward -1 -Infinity -> -1.000000000000000000000000000000001
-dqnextt429 nexttoward -1.000000000000000000000000000000001 -Infinity -> -1.000000000000000000000000000000002
-dqnextt430 nexttoward -1.000000000000000000000000000000002 -Infinity -> -1.000000000000000000000000000000003
-dqnextt431 nexttoward -1.000000000000000000000000000000003 -Infinity -> -1.000000000000000000000000000000004
-dqnextt432 nexttoward -1.000000000000000000000000000000004 -Infinity -> -1.000000000000000000000000000000005
-dqnextt433 nexttoward -1.000000000000000000000000000000005 -Infinity -> -1.000000000000000000000000000000006
-dqnextt434 nexttoward -1.000000000000000000000000000000006 -Infinity -> -1.000000000000000000000000000000007
-dqnextt435 nexttoward -1.000000000000000000000000000000007 -Infinity -> -1.000000000000000000000000000000008
-dqnextt436 nexttoward -1.000000000000000000000000000000008 -Infinity -> -1.000000000000000000000000000000009
-dqnextt437 nexttoward -1.000000000000000000000000000000009 -Infinity -> -1.000000000000000000000000000000010
-dqnextt438 nexttoward -1.000000000000000000000000000000010 -Infinity -> -1.000000000000000000000000000000011
-dqnextt439 nexttoward -1.000000000000000000000000000000011 -Infinity -> -1.000000000000000000000000000000012
-
--- Zeros
-dqnextt500 nexttoward -0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt501 nexttoward 0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt502 nexttoward 0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt503 nexttoward -0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt504 nexttoward 0E-300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt505 nexttoward 0E+300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt506 nexttoward 0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt507 nexttoward -0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-
--- specials
-dqnextt550 nexttoward Inf -Infinity -> 9.999999999999999999999999999999999E+6144
-dqnextt551 nexttoward -Inf -Infinity -> -Infinity
-dqnextt552 nexttoward NaN -Infinity -> NaN
-dqnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-dqnextt554 nexttoward NaN77 -Infinity -> NaN77
-dqnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-dqnextt556 nexttoward -NaN -Infinity -> -NaN
-dqnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-dqnextt558 nexttoward -NaN77 -Infinity -> -NaN77
-dqnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-dqnextt670 nexttoward 9.999999999999999999999999999999999E+6144 -Infinity -> 9.999999999999999999999999999999998E+6144
-dqnextt671 nexttoward 9.999999999999999999999999999999998E+6144 -Infinity -> 9.999999999999999999999999999999997E+6144
-dqnextt672 nexttoward 1E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt673 nexttoward 1.000000000000000000000000000000000E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
-dqnextt674 nexttoward 9E-6176 -Infinity -> 8E-6176 Underflow Subnormal Inexact Rounded
-dqnextt675 nexttoward 9.9E-6175 -Infinity -> 9.8E-6175 Underflow Subnormal Inexact Rounded
-dqnextt676 nexttoward 9.99999999999999999999999999999E-6147 -Infinity -> 9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
-dqnextt677 nexttoward 9.99999999999999999999999999999999E-6144 -Infinity -> 9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
-dqnextt678 nexttoward 9.99999999999999999999999999999998E-6144 -Infinity -> 9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
-dqnextt679 nexttoward 9.99999999999999999999999999999997E-6144 -Infinity -> 9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
-dqnextt680 nexttoward 0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt681 nexttoward 1E-6176 -Infinity -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqnextt682 nexttoward 2E-6176 -Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
-
-dqnextt683 nexttoward -0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt684 nexttoward -1E-6176 -Infinity -> -2E-6176 Underflow Subnormal Inexact Rounded
-dqnextt685 nexttoward -2E-6176 -Infinity -> -3E-6176 Underflow Subnormal Inexact Rounded
-dqnextt686 nexttoward -10E-6176 -Infinity -> -1.1E-6175 Underflow Subnormal Inexact Rounded
-dqnextt687 nexttoward -100E-6176 -Infinity -> -1.01E-6174 Underflow Subnormal Inexact Rounded
-dqnextt688 nexttoward -100000E-6176 -Infinity -> -1.00001E-6171 Underflow Subnormal Inexact Rounded
-dqnextt689 nexttoward -1.00000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt690 nexttoward -1.000000000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt691 nexttoward -1E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
-dqnextt692 nexttoward -9.999999999999999999999999999999998E+6144 -Infinity -> -9.999999999999999999999999999999999E+6144
-dqnextt693 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- Specials
-dqnextt780 nexttoward -Inf -Inf -> -Infinity
-dqnextt781 nexttoward -Inf -1000 -> -9.999999999999999999999999999999999E+6144
-dqnextt782 nexttoward -Inf -1 -> -9.999999999999999999999999999999999E+6144
-dqnextt783 nexttoward -Inf -0 -> -9.999999999999999999999999999999999E+6144
-dqnextt784 nexttoward -Inf 0 -> -9.999999999999999999999999999999999E+6144
-dqnextt785 nexttoward -Inf 1 -> -9.999999999999999999999999999999999E+6144
-dqnextt786 nexttoward -Inf 1000 -> -9.999999999999999999999999999999999E+6144
-dqnextt787 nexttoward -1000 -Inf -> -1000.000000000000000000000000000001
-dqnextt788 nexttoward -Inf -Inf -> -Infinity
-dqnextt789 nexttoward -1 -Inf -> -1.000000000000000000000000000000001
-dqnextt790 nexttoward -0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt791 nexttoward 0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt792 nexttoward 1 -Inf -> 0.9999999999999999999999999999999999
-dqnextt793 nexttoward 1000 -Inf -> 999.9999999999999999999999999999999
-dqnextt794 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
-
-dqnextt800 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
-dqnextt801 nexttoward Inf -1000 -> 9.999999999999999999999999999999999E+6144
-dqnextt802 nexttoward Inf -1 -> 9.999999999999999999999999999999999E+6144
-dqnextt803 nexttoward Inf -0 -> 9.999999999999999999999999999999999E+6144
-dqnextt804 nexttoward Inf 0 -> 9.999999999999999999999999999999999E+6144
-dqnextt805 nexttoward Inf 1 -> 9.999999999999999999999999999999999E+6144
-dqnextt806 nexttoward Inf 1000 -> 9.999999999999999999999999999999999E+6144
-dqnextt807 nexttoward Inf Inf -> Infinity
-dqnextt808 nexttoward -1000 Inf -> -999.9999999999999999999999999999999
-dqnextt809 nexttoward -Inf Inf -> -9.999999999999999999999999999999999E+6144
-dqnextt810 nexttoward -1 Inf -> -0.9999999999999999999999999999999999
-dqnextt811 nexttoward -0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt812 nexttoward 0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
-dqnextt813 nexttoward 1 Inf -> 1.000000000000000000000000000000001
-dqnextt814 nexttoward 1000 Inf -> 1000.000000000000000000000000000001
-dqnextt815 nexttoward Inf Inf -> Infinity
-
-dqnextt821 nexttoward NaN -Inf -> NaN
-dqnextt822 nexttoward NaN -1000 -> NaN
-dqnextt823 nexttoward NaN -1 -> NaN
-dqnextt824 nexttoward NaN -0 -> NaN
-dqnextt825 nexttoward NaN 0 -> NaN
-dqnextt826 nexttoward NaN 1 -> NaN
-dqnextt827 nexttoward NaN 1000 -> NaN
-dqnextt828 nexttoward NaN Inf -> NaN
-dqnextt829 nexttoward NaN NaN -> NaN
-dqnextt830 nexttoward -Inf NaN -> NaN
-dqnextt831 nexttoward -1000 NaN -> NaN
-dqnextt832 nexttoward -1 NaN -> NaN
-dqnextt833 nexttoward -0 NaN -> NaN
-dqnextt834 nexttoward 0 NaN -> NaN
-dqnextt835 nexttoward 1 NaN -> NaN
-dqnextt836 nexttoward 1000 NaN -> NaN
-dqnextt837 nexttoward Inf NaN -> NaN
-
-dqnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-dqnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-dqnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-dqnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-dqnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-dqnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-dqnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-dqnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-dqnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-dqnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-dqnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-dqnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-dqnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-dqnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-dqnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-dqnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-dqnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-dqnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-dqnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqnextt861 nexttoward NaN1 -Inf -> NaN1
-dqnextt862 nexttoward +NaN2 -1000 -> NaN2
-dqnextt863 nexttoward NaN3 1000 -> NaN3
-dqnextt864 nexttoward NaN4 Inf -> NaN4
-dqnextt865 nexttoward NaN5 +NaN6 -> NaN5
-dqnextt866 nexttoward -Inf NaN7 -> NaN7
-dqnextt867 nexttoward -1000 NaN8 -> NaN8
-dqnextt868 nexttoward 1000 NaN9 -> NaN9
-dqnextt869 nexttoward Inf +NaN10 -> NaN10
-dqnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-dqnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-dqnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-dqnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-dqnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-dqnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-dqnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-dqnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-dqnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-dqnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqnextt882 nexttoward -NaN26 NaN28 -> -NaN26
-dqnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqnextt884 nexttoward 1000 -NaN30 -> -NaN30
-dqnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-dqnextt900 nexttoward 1 # -> NaN Invalid_operation
-dqnextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqNextToward.decTest -- decQuad next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+
+-- Sanity check with a scattering of numerics
+dqnextt001 nexttoward 10 10 -> 10
+dqnextt002 nexttoward -10 -10 -> -10
+dqnextt003 nexttoward 1 10 -> 1.000000000000000000000000000000001
+dqnextt004 nexttoward 1 -10 -> 0.9999999999999999999999999999999999
+dqnextt005 nexttoward -1 10 -> -0.9999999999999999999999999999999999
+dqnextt006 nexttoward -1 -10 -> -1.000000000000000000000000000000001
+dqnextt007 nexttoward 0 10 -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt008 nexttoward 0 -10 -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt009 nexttoward 9.999999999999999999999999999999999E+6144 +Infinity -> Infinity Overflow Inexact Rounded
+dqnextt010 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
+dqnextt011 nexttoward 9.999999999999999999999999999999999 10 -> 10.00000000000000000000000000000000
+dqnextt012 nexttoward 10 9.999999999999999999999999999999999 -> 9.999999999999999999999999999999999
+dqnextt013 nexttoward -9.999999999999999999999999999999999 -10 -> -10.00000000000000000000000000000000
+dqnextt014 nexttoward -10 -9.999999999999999999999999999999999 -> -9.999999999999999999999999999999999
+dqnextt015 nexttoward 9.999999999999999999999999999999998 10 -> 9.999999999999999999999999999999999
+dqnextt016 nexttoward 10 9.999999999999999999999999999999998 -> 9.999999999999999999999999999999999
+dqnextt017 nexttoward -9.999999999999999999999999999999998 -10 -> -9.999999999999999999999999999999999
+dqnextt018 nexttoward -10 -9.999999999999999999999999999999998 -> -9.999999999999999999999999999999999
+
+------- lhs=rhs
+-- finites
+dqnextt101 nexttoward 7 7 -> 7
+dqnextt102 nexttoward -7 -7 -> -7
+dqnextt103 nexttoward 75 75 -> 75
+dqnextt104 nexttoward -75 -75 -> -75
+dqnextt105 nexttoward 7.50 7.5 -> 7.50
+dqnextt106 nexttoward -7.50 -7.50 -> -7.50
+dqnextt107 nexttoward 7.500 7.5000 -> 7.500
+dqnextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+dqnextt111 nexttoward 0 0 -> 0
+dqnextt112 nexttoward -0 -0 -> -0
+dqnextt113 nexttoward 0E+4 0 -> 0E+4
+dqnextt114 nexttoward -0E+4 -0 -> -0E+4
+dqnextt115 nexttoward 0.00000000000 0.000000000000 -> 0E-11
+dqnextt116 nexttoward -0.00000000000 -0.00 -> -0E-11
+dqnextt117 nexttoward 0E-141 0 -> 0E-141
+dqnextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+dqnextt121 nexttoward 268268268 268268268 -> 268268268
+dqnextt122 nexttoward -268268268 -268268268 -> -268268268
+dqnextt123 nexttoward 134134134 134134134 -> 134134134
+dqnextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+dqnextt131 nexttoward 9.999999999999999999999999999999999E+6144 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqnextt132 nexttoward 1E-6143 1E-6143 -> 1E-6143
+dqnextt133 nexttoward 1.000000000000000000000000000000000E-6143 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqnextt134 nexttoward 1E-6176 1E-6176 -> 1E-6176
+
+dqnextt135 nexttoward -1E-6176 -1E-6176 -> -1E-6176
+dqnextt136 nexttoward -1.000000000000000000000000000000000E-6143 -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqnextt137 nexttoward -1E-6143 -1E-6143 -> -1E-6143
+dqnextt138 nexttoward -9.999999999999999999999999999999999E+6144 -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+
+------- lhs<rhs
+dqnextt201 nexttoward 0.9999999999999999999999999999999995 Infinity -> 0.9999999999999999999999999999999996
+dqnextt202 nexttoward 0.9999999999999999999999999999999996 Infinity -> 0.9999999999999999999999999999999997
+dqnextt203 nexttoward 0.9999999999999999999999999999999997 Infinity -> 0.9999999999999999999999999999999998
+dqnextt204 nexttoward 0.9999999999999999999999999999999998 Infinity -> 0.9999999999999999999999999999999999
+dqnextt205 nexttoward 0.9999999999999999999999999999999999 Infinity -> 1.000000000000000000000000000000000
+dqnextt206 nexttoward 1.000000000000000000000000000000000 Infinity -> 1.000000000000000000000000000000001
+dqnextt207 nexttoward 1.0 Infinity -> 1.000000000000000000000000000000001
+dqnextt208 nexttoward 1 Infinity -> 1.000000000000000000000000000000001
+dqnextt209 nexttoward 1.000000000000000000000000000000001 Infinity -> 1.000000000000000000000000000000002
+dqnextt210 nexttoward 1.000000000000000000000000000000002 Infinity -> 1.000000000000000000000000000000003
+dqnextt211 nexttoward 1.000000000000000000000000000000003 Infinity -> 1.000000000000000000000000000000004
+dqnextt212 nexttoward 1.000000000000000000000000000000004 Infinity -> 1.000000000000000000000000000000005
+dqnextt213 nexttoward 1.000000000000000000000000000000005 Infinity -> 1.000000000000000000000000000000006
+dqnextt214 nexttoward 1.000000000000000000000000000000006 Infinity -> 1.000000000000000000000000000000007
+dqnextt215 nexttoward 1.000000000000000000000000000000007 Infinity -> 1.000000000000000000000000000000008
+dqnextt216 nexttoward 1.000000000000000000000000000000008 Infinity -> 1.000000000000000000000000000000009
+dqnextt217 nexttoward 1.000000000000000000000000000000009 Infinity -> 1.000000000000000000000000000000010
+dqnextt218 nexttoward 1.000000000000000000000000000000010 Infinity -> 1.000000000000000000000000000000011
+dqnextt219 nexttoward 1.000000000000000000000000000000011 Infinity -> 1.000000000000000000000000000000012
+
+dqnextt221 nexttoward -0.9999999999999999999999999999999995 Infinity -> -0.9999999999999999999999999999999994
+dqnextt222 nexttoward -0.9999999999999999999999999999999996 Infinity -> -0.9999999999999999999999999999999995
+dqnextt223 nexttoward -0.9999999999999999999999999999999997 Infinity -> -0.9999999999999999999999999999999996
+dqnextt224 nexttoward -0.9999999999999999999999999999999998 Infinity -> -0.9999999999999999999999999999999997
+dqnextt225 nexttoward -0.9999999999999999999999999999999999 Infinity -> -0.9999999999999999999999999999999998
+dqnextt226 nexttoward -1.000000000000000000000000000000000 Infinity -> -0.9999999999999999999999999999999999
+dqnextt227 nexttoward -1.0 Infinity -> -0.9999999999999999999999999999999999
+dqnextt228 nexttoward -1 Infinity -> -0.9999999999999999999999999999999999
+dqnextt229 nexttoward -1.000000000000000000000000000000001 Infinity -> -1.000000000000000000000000000000000
+dqnextt230 nexttoward -1.000000000000000000000000000000002 Infinity -> -1.000000000000000000000000000000001
+dqnextt231 nexttoward -1.000000000000000000000000000000003 Infinity -> -1.000000000000000000000000000000002
+dqnextt232 nexttoward -1.000000000000000000000000000000004 Infinity -> -1.000000000000000000000000000000003
+dqnextt233 nexttoward -1.000000000000000000000000000000005 Infinity -> -1.000000000000000000000000000000004
+dqnextt234 nexttoward -1.000000000000000000000000000000006 Infinity -> -1.000000000000000000000000000000005
+dqnextt235 nexttoward -1.000000000000000000000000000000007 Infinity -> -1.000000000000000000000000000000006
+dqnextt236 nexttoward -1.000000000000000000000000000000008 Infinity -> -1.000000000000000000000000000000007
+dqnextt237 nexttoward -1.000000000000000000000000000000009 Infinity -> -1.000000000000000000000000000000008
+dqnextt238 nexttoward -1.000000000000000000000000000000010 Infinity -> -1.000000000000000000000000000000009
+dqnextt239 nexttoward -1.000000000000000000000000000000011 Infinity -> -1.000000000000000000000000000000010
+dqnextt240 nexttoward -1.000000000000000000000000000000012 Infinity -> -1.000000000000000000000000000000011
+
+-- Zeros
+dqnextt300 nexttoward 0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt301 nexttoward 0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt302 nexttoward 0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt303 nexttoward 0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt304 nexttoward 0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt305 nexttoward -0 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt306 nexttoward -0.00 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt307 nexttoward -0E-300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt308 nexttoward -0E+300 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt309 nexttoward -0E+30000 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+-- specials
+dqnextt350 nexttoward Inf Infinity -> Infinity
+dqnextt351 nexttoward -Inf Infinity -> -9.999999999999999999999999999999999E+6144
+dqnextt352 nexttoward NaN Infinity -> NaN
+dqnextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+dqnextt354 nexttoward NaN77 Infinity -> NaN77
+dqnextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+dqnextt356 nexttoward -NaN Infinity -> -NaN
+dqnextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+dqnextt358 nexttoward -NaN77 Infinity -> -NaN77
+dqnextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextt370 nexttoward -9.999999999999999999999999999999999E+6144 Infinity -> -9.999999999999999999999999999999998E+6144
+dqnextt371 nexttoward -9.999999999999999999999999999999998E+6144 Infinity -> -9.999999999999999999999999999999997E+6144
+dqnextt372 nexttoward -1E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt373 nexttoward -1.000000000000000E-6143 Infinity -> -9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt374 nexttoward -9E-6176 Infinity -> -8E-6176 Underflow Subnormal Inexact Rounded
+dqnextt375 nexttoward -9.9E-6175 Infinity -> -9.8E-6175 Underflow Subnormal Inexact Rounded
+dqnextt376 nexttoward -9.99999999999999999999999999999E-6147 Infinity -> -9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
+dqnextt377 nexttoward -9.99999999999999999999999999999999E-6144 Infinity -> -9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
+dqnextt378 nexttoward -9.99999999999999999999999999999998E-6144 Infinity -> -9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
+dqnextt379 nexttoward -9.99999999999999999999999999999997E-6144 Infinity -> -9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
+dqnextt380 nexttoward -0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt381 nexttoward -1E-6176 Infinity -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqnextt382 nexttoward -2E-6176 Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+
+dqnextt383 nexttoward 0E-6176 Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt384 nexttoward 1E-6176 Infinity -> 2E-6176 Underflow Subnormal Inexact Rounded
+dqnextt385 nexttoward 2E-6176 Infinity -> 3E-6176 Underflow Subnormal Inexact Rounded
+dqnextt386 nexttoward 10E-6176 Infinity -> 1.1E-6175 Underflow Subnormal Inexact Rounded
+dqnextt387 nexttoward 100E-6176 Infinity -> 1.01E-6174 Underflow Subnormal Inexact Rounded
+dqnextt388 nexttoward 100000E-6176 Infinity -> 1.00001E-6171 Underflow Subnormal Inexact Rounded
+dqnextt389 nexttoward 1.00000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt390 nexttoward 1.000000000000000000000000000000000E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt391 nexttoward 1E-6143 Infinity -> 1.000000000000000000000000000000001E-6143
+dqnextt392 nexttoward 9.999999999999999999999999999999997E+6144 Infinity -> 9.999999999999999999999999999999998E+6144
+dqnextt393 nexttoward 9.999999999999999999999999999999998E+6144 Infinity -> 9.999999999999999999999999999999999E+6144
+dqnextt394 nexttoward 9.999999999999999999999999999999999E+6144 Infinity -> Infinity Overflow Inexact Rounded
+
+------- lhs>rhs
+dqnextt401 nexttoward 0.9999999999999999999999999999999995 -Infinity -> 0.9999999999999999999999999999999994
+dqnextt402 nexttoward 0.9999999999999999999999999999999996 -Infinity -> 0.9999999999999999999999999999999995
+dqnextt403 nexttoward 0.9999999999999999999999999999999997 -Infinity -> 0.9999999999999999999999999999999996
+dqnextt404 nexttoward 0.9999999999999999999999999999999998 -Infinity -> 0.9999999999999999999999999999999997
+dqnextt405 nexttoward 0.9999999999999999999999999999999999 -Infinity -> 0.9999999999999999999999999999999998
+dqnextt406 nexttoward 1.000000000000000000000000000000000 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt407 nexttoward 1.0 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt408 nexttoward 1 -Infinity -> 0.9999999999999999999999999999999999
+dqnextt409 nexttoward 1.000000000000000000000000000000001 -Infinity -> 1.000000000000000000000000000000000
+dqnextt410 nexttoward 1.000000000000000000000000000000002 -Infinity -> 1.000000000000000000000000000000001
+dqnextt411 nexttoward 1.000000000000000000000000000000003 -Infinity -> 1.000000000000000000000000000000002
+dqnextt412 nexttoward 1.000000000000000000000000000000004 -Infinity -> 1.000000000000000000000000000000003
+dqnextt413 nexttoward 1.000000000000000000000000000000005 -Infinity -> 1.000000000000000000000000000000004
+dqnextt414 nexttoward 1.000000000000000000000000000000006 -Infinity -> 1.000000000000000000000000000000005
+dqnextt415 nexttoward 1.000000000000000000000000000000007 -Infinity -> 1.000000000000000000000000000000006
+dqnextt416 nexttoward 1.000000000000000000000000000000008 -Infinity -> 1.000000000000000000000000000000007
+dqnextt417 nexttoward 1.000000000000000000000000000000009 -Infinity -> 1.000000000000000000000000000000008
+dqnextt418 nexttoward 1.000000000000000000000000000000010 -Infinity -> 1.000000000000000000000000000000009
+dqnextt419 nexttoward 1.000000000000000000000000000000011 -Infinity -> 1.000000000000000000000000000000010
+dqnextt420 nexttoward 1.000000000000000000000000000000012 -Infinity -> 1.000000000000000000000000000000011
+
+dqnextt421 nexttoward -0.9999999999999999999999999999999995 -Infinity -> -0.9999999999999999999999999999999996
+dqnextt422 nexttoward -0.9999999999999999999999999999999996 -Infinity -> -0.9999999999999999999999999999999997
+dqnextt423 nexttoward -0.9999999999999999999999999999999997 -Infinity -> -0.9999999999999999999999999999999998
+dqnextt424 nexttoward -0.9999999999999999999999999999999998 -Infinity -> -0.9999999999999999999999999999999999
+dqnextt425 nexttoward -0.9999999999999999999999999999999999 -Infinity -> -1.000000000000000000000000000000000
+dqnextt426 nexttoward -1.000000000000000000000000000000000 -Infinity -> -1.000000000000000000000000000000001
+dqnextt427 nexttoward -1.0 -Infinity -> -1.000000000000000000000000000000001
+dqnextt428 nexttoward -1 -Infinity -> -1.000000000000000000000000000000001
+dqnextt429 nexttoward -1.000000000000000000000000000000001 -Infinity -> -1.000000000000000000000000000000002
+dqnextt430 nexttoward -1.000000000000000000000000000000002 -Infinity -> -1.000000000000000000000000000000003
+dqnextt431 nexttoward -1.000000000000000000000000000000003 -Infinity -> -1.000000000000000000000000000000004
+dqnextt432 nexttoward -1.000000000000000000000000000000004 -Infinity -> -1.000000000000000000000000000000005
+dqnextt433 nexttoward -1.000000000000000000000000000000005 -Infinity -> -1.000000000000000000000000000000006
+dqnextt434 nexttoward -1.000000000000000000000000000000006 -Infinity -> -1.000000000000000000000000000000007
+dqnextt435 nexttoward -1.000000000000000000000000000000007 -Infinity -> -1.000000000000000000000000000000008
+dqnextt436 nexttoward -1.000000000000000000000000000000008 -Infinity -> -1.000000000000000000000000000000009
+dqnextt437 nexttoward -1.000000000000000000000000000000009 -Infinity -> -1.000000000000000000000000000000010
+dqnextt438 nexttoward -1.000000000000000000000000000000010 -Infinity -> -1.000000000000000000000000000000011
+dqnextt439 nexttoward -1.000000000000000000000000000000011 -Infinity -> -1.000000000000000000000000000000012
+
+-- Zeros
+dqnextt500 nexttoward -0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt501 nexttoward 0 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt502 nexttoward 0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt503 nexttoward -0.00 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt504 nexttoward 0E-300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt505 nexttoward 0E+300 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt506 nexttoward 0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt507 nexttoward -0E+30000 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+
+-- specials
+dqnextt550 nexttoward Inf -Infinity -> 9.999999999999999999999999999999999E+6144
+dqnextt551 nexttoward -Inf -Infinity -> -Infinity
+dqnextt552 nexttoward NaN -Infinity -> NaN
+dqnextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+dqnextt554 nexttoward NaN77 -Infinity -> NaN77
+dqnextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+dqnextt556 nexttoward -NaN -Infinity -> -NaN
+dqnextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+dqnextt558 nexttoward -NaN77 -Infinity -> -NaN77
+dqnextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+dqnextt670 nexttoward 9.999999999999999999999999999999999E+6144 -Infinity -> 9.999999999999999999999999999999998E+6144
+dqnextt671 nexttoward 9.999999999999999999999999999999998E+6144 -Infinity -> 9.999999999999999999999999999999997E+6144
+dqnextt672 nexttoward 1E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt673 nexttoward 1.000000000000000000000000000000000E-6143 -Infinity -> 9.99999999999999999999999999999999E-6144 Underflow Subnormal Inexact Rounded
+dqnextt674 nexttoward 9E-6176 -Infinity -> 8E-6176 Underflow Subnormal Inexact Rounded
+dqnextt675 nexttoward 9.9E-6175 -Infinity -> 9.8E-6175 Underflow Subnormal Inexact Rounded
+dqnextt676 nexttoward 9.99999999999999999999999999999E-6147 -Infinity -> 9.99999999999999999999999999998E-6147 Underflow Subnormal Inexact Rounded
+dqnextt677 nexttoward 9.99999999999999999999999999999999E-6144 -Infinity -> 9.99999999999999999999999999999998E-6144 Underflow Subnormal Inexact Rounded
+dqnextt678 nexttoward 9.99999999999999999999999999999998E-6144 -Infinity -> 9.99999999999999999999999999999997E-6144 Underflow Subnormal Inexact Rounded
+dqnextt679 nexttoward 9.99999999999999999999999999999997E-6144 -Infinity -> 9.99999999999999999999999999999996E-6144 Underflow Subnormal Inexact Rounded
+dqnextt680 nexttoward 0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt681 nexttoward 1E-6176 -Infinity -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqnextt682 nexttoward 2E-6176 -Infinity -> 1E-6176 Underflow Subnormal Inexact Rounded
+
+dqnextt683 nexttoward -0E-6176 -Infinity -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt684 nexttoward -1E-6176 -Infinity -> -2E-6176 Underflow Subnormal Inexact Rounded
+dqnextt685 nexttoward -2E-6176 -Infinity -> -3E-6176 Underflow Subnormal Inexact Rounded
+dqnextt686 nexttoward -10E-6176 -Infinity -> -1.1E-6175 Underflow Subnormal Inexact Rounded
+dqnextt687 nexttoward -100E-6176 -Infinity -> -1.01E-6174 Underflow Subnormal Inexact Rounded
+dqnextt688 nexttoward -100000E-6176 -Infinity -> -1.00001E-6171 Underflow Subnormal Inexact Rounded
+dqnextt689 nexttoward -1.00000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt690 nexttoward -1.000000000000000000000000000000000E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt691 nexttoward -1E-6143 -Infinity -> -1.000000000000000000000000000000001E-6143
+dqnextt692 nexttoward -9.999999999999999999999999999999998E+6144 -Infinity -> -9.999999999999999999999999999999999E+6144
+dqnextt693 nexttoward -9.999999999999999999999999999999999E+6144 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- Specials
+dqnextt780 nexttoward -Inf -Inf -> -Infinity
+dqnextt781 nexttoward -Inf -1000 -> -9.999999999999999999999999999999999E+6144
+dqnextt782 nexttoward -Inf -1 -> -9.999999999999999999999999999999999E+6144
+dqnextt783 nexttoward -Inf -0 -> -9.999999999999999999999999999999999E+6144
+dqnextt784 nexttoward -Inf 0 -> -9.999999999999999999999999999999999E+6144
+dqnextt785 nexttoward -Inf 1 -> -9.999999999999999999999999999999999E+6144
+dqnextt786 nexttoward -Inf 1000 -> -9.999999999999999999999999999999999E+6144
+dqnextt787 nexttoward -1000 -Inf -> -1000.000000000000000000000000000001
+dqnextt788 nexttoward -Inf -Inf -> -Infinity
+dqnextt789 nexttoward -1 -Inf -> -1.000000000000000000000000000000001
+dqnextt790 nexttoward -0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt791 nexttoward 0 -Inf -> -1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt792 nexttoward 1 -Inf -> 0.9999999999999999999999999999999999
+dqnextt793 nexttoward 1000 -Inf -> 999.9999999999999999999999999999999
+dqnextt794 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
+
+dqnextt800 nexttoward Inf -Inf -> 9.999999999999999999999999999999999E+6144
+dqnextt801 nexttoward Inf -1000 -> 9.999999999999999999999999999999999E+6144
+dqnextt802 nexttoward Inf -1 -> 9.999999999999999999999999999999999E+6144
+dqnextt803 nexttoward Inf -0 -> 9.999999999999999999999999999999999E+6144
+dqnextt804 nexttoward Inf 0 -> 9.999999999999999999999999999999999E+6144
+dqnextt805 nexttoward Inf 1 -> 9.999999999999999999999999999999999E+6144
+dqnextt806 nexttoward Inf 1000 -> 9.999999999999999999999999999999999E+6144
+dqnextt807 nexttoward Inf Inf -> Infinity
+dqnextt808 nexttoward -1000 Inf -> -999.9999999999999999999999999999999
+dqnextt809 nexttoward -Inf Inf -> -9.999999999999999999999999999999999E+6144
+dqnextt810 nexttoward -1 Inf -> -0.9999999999999999999999999999999999
+dqnextt811 nexttoward -0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt812 nexttoward 0 Inf -> 1E-6176 Underflow Subnormal Inexact Rounded
+dqnextt813 nexttoward 1 Inf -> 1.000000000000000000000000000000001
+dqnextt814 nexttoward 1000 Inf -> 1000.000000000000000000000000000001
+dqnextt815 nexttoward Inf Inf -> Infinity
+
+dqnextt821 nexttoward NaN -Inf -> NaN
+dqnextt822 nexttoward NaN -1000 -> NaN
+dqnextt823 nexttoward NaN -1 -> NaN
+dqnextt824 nexttoward NaN -0 -> NaN
+dqnextt825 nexttoward NaN 0 -> NaN
+dqnextt826 nexttoward NaN 1 -> NaN
+dqnextt827 nexttoward NaN 1000 -> NaN
+dqnextt828 nexttoward NaN Inf -> NaN
+dqnextt829 nexttoward NaN NaN -> NaN
+dqnextt830 nexttoward -Inf NaN -> NaN
+dqnextt831 nexttoward -1000 NaN -> NaN
+dqnextt832 nexttoward -1 NaN -> NaN
+dqnextt833 nexttoward -0 NaN -> NaN
+dqnextt834 nexttoward 0 NaN -> NaN
+dqnextt835 nexttoward 1 NaN -> NaN
+dqnextt836 nexttoward 1000 NaN -> NaN
+dqnextt837 nexttoward Inf NaN -> NaN
+
+dqnextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+dqnextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+dqnextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+dqnextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+dqnextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+dqnextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+dqnextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+dqnextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+dqnextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+dqnextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+dqnextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+dqnextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+dqnextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+dqnextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+dqnextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+dqnextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+dqnextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+dqnextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+dqnextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqnextt861 nexttoward NaN1 -Inf -> NaN1
+dqnextt862 nexttoward +NaN2 -1000 -> NaN2
+dqnextt863 nexttoward NaN3 1000 -> NaN3
+dqnextt864 nexttoward NaN4 Inf -> NaN4
+dqnextt865 nexttoward NaN5 +NaN6 -> NaN5
+dqnextt866 nexttoward -Inf NaN7 -> NaN7
+dqnextt867 nexttoward -1000 NaN8 -> NaN8
+dqnextt868 nexttoward 1000 NaN9 -> NaN9
+dqnextt869 nexttoward Inf +NaN10 -> NaN10
+dqnextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+dqnextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+dqnextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+dqnextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+dqnextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqnextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+dqnextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+dqnextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+dqnextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+dqnextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+dqnextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqnextt882 nexttoward -NaN26 NaN28 -> -NaN26
+dqnextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqnextt884 nexttoward 1000 -NaN30 -> -NaN30
+dqnextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+dqnextt900 nexttoward 1 # -> NaN Invalid_operation
+dqnextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqOr.decTest b/Lib/test/decimaltestdata/dqOr.decTest
index 1fd34b2b35a..daa3c860942 100644
--- a/Lib/test/decimaltestdata/dqOr.decTest
+++ b/Lib/test/decimaltestdata/dqOr.decTest
@@ -1,401 +1,401 @@
-------------------------------------------------------------------------
--- dqOr.decTest -- digitwise logical OR for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqor001 or 0 0 -> 0
-dqor002 or 0 1 -> 1
-dqor003 or 1 0 -> 1
-dqor004 or 1 1 -> 1
-dqor005 or 1100 1010 -> 1110
--- and at msd and msd-1
-dqor006 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqor007 or 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor008 or 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor009 or 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqor010 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqor011 or 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqor012 or 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
-dqor013 or 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-
--- Various lengths
-dqor601 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
-dqor602 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
-dqor603 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
-dqor604 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
-dqor605 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
-dqor606 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
-dqor607 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
-dqor608 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
-dqor609 or 1111111101111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111111111111
-dqor610 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
-dqor611 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
-dqor612 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
-dqor613 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
-dqor614 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
-dqor615 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
-dqor616 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
-dqor617 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
-dqor618 or 1111111111111111101111111111111111 1111111111111111011111111111111111 -> 1111111111111111111111111111111111
-dqor619 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
-dqor620 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
-dqor621 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
-dqor622 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
-dqor623 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
-dqor624 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
-dqor625 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
-dqor626 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
-dqor627 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
-dqor628 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor629 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor630 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor631 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor632 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor633 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor634 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
-
-dqor641 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor642 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor643 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor644 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor645 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor646 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor647 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
-dqor648 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
-dqor649 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
-dqor650 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
-dqor651 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
-dqor652 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
-dqor653 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
-dqor654 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
-dqor655 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
-dqor656 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
-dqor657 or 1010101010101010101010101010101010 1010101010101010001010101010101010 -> 1010101010101010101010101010101010
-dqor658 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
-dqor659 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
-dqor660 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
-dqor661 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
-dqor662 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
-dqor663 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
-dqor664 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
-dqor665 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
-dqor666 or 0101010101010101010101010101010101 0101010101010101010101010001010101 -> 101010101010101010101010101010101
-dqor667 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
-dqor668 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
-dqor669 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
-dqor670 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
-dqor671 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
-dqor672 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
-dqor673 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
-dqor674 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
-dqor675 or 0111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-dqor676 or 1111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
-
-dqor681 or 0111111111111111111111111111111111 0111111111011111111111111111111110 -> 111111111111111111111111111111111
-dqor682 or 1011111111111111111111111111111111 1011111110101111111111111111111101 -> 1011111111111111111111111111111111
-dqor683 or 1101111111111111111111111111111111 1101111101110111111111111111111011 -> 1101111111111111111111111111111111
-dqor684 or 1110111111111111111111111111111111 1110111011111011111111111111110111 -> 1110111111111111111111111111111111
-dqor685 or 1111011111111111111111111111111111 1111010111111101111111111111101111 -> 1111011111111111111111111111111111
-dqor686 or 1111101111111111111111111111111111 1111101111111110111111111111011111 -> 1111101111111111111111111111111111
-dqor687 or 1111110111111111111111111111111111 1111010111111111011111111110111111 -> 1111110111111111111111111111111111
-dqor688 or 1111111011111111111111111111111111 1110111011111111101111111101111111 -> 1111111011111111111111111111111111
-dqor689 or 1111111101111111111111111111111111 1101111101111111110111111011111111 -> 1111111101111111111111111111111111
-dqor690 or 1111111110111111111111111111111111 1011111110111111111011110111111110 -> 1111111110111111111111111111111111
-dqor691 or 1111111111011111111111111111111111 0111111111011111111101101111111101 -> 1111111111011111111111111111111111
-dqor692 or 1111111111101111111111111111111111 1111111111101111111110011111111011 -> 1111111111101111111111111111111111
-dqor693 or 1111111111110111111111111111111111 1111111111110111111110011111110111 -> 1111111111110111111111111111111111
-dqor694 or 1111111111111011111111111111111111 1111111111111011111101101111101111 -> 1111111111111011111111111111111111
-dqor695 or 1111111111111101111111111111111111 1111111111111101111011110111011111 -> 1111111111111101111111111111111111
-dqor696 or 1111111111111110111111111111111111 1111111111111110110111111010111111 -> 1111111111111110111111111111111111
-dqor697 or 1111111111111111011111111111111111 1111111111111111001111111101111111 -> 1111111111111111011111111111111111
-dqor698 or 1111111111111111101111111111111111 1111111111111111001111111010111111 -> 1111111111111111101111111111111111
-dqor699 or 1111111111111111110111111111111111 1111111111111110110111110111011111 -> 1111111111111111110111111111111111
-dqor700 or 1111111111111111111011111111111111 1111111111111101111011101111101111 -> 1111111111111111111011111111111111
-dqor701 or 1111111111111111111101111111111111 1111111111111011111101011111110111 -> 1111111111111111111101111111111111
-dqor702 or 1111111111111111111110111111111111 1111111111110111111110111111111011 -> 1111111111111111111110111111111111
-dqor703 or 1111111111111111111111011111111111 1111111111101111111101011111111101 -> 1111111111111111111111011111111111
-dqor704 or 1111111111111111111111101111111111 1111111111011111111011101111111110 -> 1111111111111111111111101111111111
-dqor705 or 1111111111111111111111110111111111 0111111110111111110111110111111111 -> 1111111111111111111111110111111111
-dqor706 or 1111111111111111111111111011111111 1011111101111111101111111011111111 -> 1111111111111111111111111011111111
-dqor707 or 1111111111111111111111111101111111 1101111011111111011111111101111111 -> 1111111111111111111111111101111111
-dqor708 or 1111111111111111111111111110111111 1110110111111110111111111110111111 -> 1111111111111111111111111110111111
-dqor709 or 1111111111111111111111111111011111 1111001111111101111111111111011111 -> 1111111111111111111111111111011111
-dqor710 or 1111111111111111111111111111101111 1111001111111011111111111111101111 -> 1111111111111111111111111111101111
-dqor711 or 1111111111111111111111111111110111 1110110111110111111111111111110111 -> 1111111111111111111111111111110111
-dqor712 or 1111111111111111111111111111111011 1101111011101111111111111111111011 -> 1111111111111111111111111111111011
-dqor713 or 1111111111111111111111111111111101 1011111101011111111111111111111101 -> 1111111111111111111111111111111101
-dqor714 or 1111111111111111111111111111111110 0111111110111111111111111111111110 -> 1111111111111111111111111111111110
-
-
-
--- 1234567890123456 1234567890123456 1234567890123456
-dqor020 or 1111111111111111 1111111111111111 -> 1111111111111111
-dqor021 or 111111111111111 111111111111111 -> 111111111111111
-dqor022 or 11111111111111 11111111111111 -> 11111111111111
-dqor023 or 1111111111111 1111111111111 -> 1111111111111
-dqor024 or 111111111111 111111111111 -> 111111111111
-dqor025 or 11111111111 11111111111 -> 11111111111
-dqor026 or 1111111111 1111111111 -> 1111111111
-dqor027 or 111111111 111111111 -> 111111111
-dqor028 or 11111111 11111111 -> 11111111
-dqor029 or 1111111 1111111 -> 1111111
-dqor030 or 111111 111111 -> 111111
-dqor031 or 11111 11111 -> 11111
-dqor032 or 1111 1111 -> 1111
-dqor033 or 111 111 -> 111
-dqor034 or 11 11 -> 11
-dqor035 or 1 1 -> 1
-dqor036 or 0 0 -> 0
-
-dqor042 or 111111110000000 1111111110000000 -> 1111111110000000
-dqor043 or 11111110000000 1000000100000000 -> 1011111110000000
-dqor044 or 1111110000000 1000001000000000 -> 1001111110000000
-dqor045 or 111110000000 1000010000000000 -> 1000111110000000
-dqor046 or 11110000000 1000100000000000 -> 1000111110000000
-dqor047 or 1110000000 1001000000000000 -> 1001001110000000
-dqor048 or 110000000 1010000000000000 -> 1010000110000000
-dqor049 or 10000000 1100000000000000 -> 1100000010000000
-
-dqor090 or 011111111 111101111 -> 111111111
-dqor091 or 101111111 111101111 -> 111111111
-dqor092 or 110111111 111101111 -> 111111111
-dqor093 or 111011111 111101111 -> 111111111
-dqor094 or 111101111 111101111 -> 111101111
-dqor095 or 111110111 111101111 -> 111111111
-dqor096 or 111111011 111101111 -> 111111111
-dqor097 or 111111101 111101111 -> 111111111
-dqor098 or 111111110 111101111 -> 111111111
-
-dqor100 or 111101111 011111111 -> 111111111
-dqor101 or 111101111 101111111 -> 111111111
-dqor102 or 111101111 110111111 -> 111111111
-dqor103 or 111101111 111011111 -> 111111111
-dqor104 or 111101111 111101111 -> 111101111
-dqor105 or 111101111 111110111 -> 111111111
-dqor106 or 111101111 111111011 -> 111111111
-dqor107 or 111101111 111111101 -> 111111111
-dqor108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-dqor220 or 111111112 111111111 -> NaN Invalid_operation
-dqor221 or 333333333 333333333 -> NaN Invalid_operation
-dqor222 or 555555555 555555555 -> NaN Invalid_operation
-dqor223 or 777777777 777777777 -> NaN Invalid_operation
-dqor224 or 999999999 999999999 -> NaN Invalid_operation
-dqor225 or 222222222 999999999 -> NaN Invalid_operation
-dqor226 or 444444444 999999999 -> NaN Invalid_operation
-dqor227 or 666666666 999999999 -> NaN Invalid_operation
-dqor228 or 888888888 999999999 -> NaN Invalid_operation
-dqor229 or 999999999 222222222 -> NaN Invalid_operation
-dqor230 or 999999999 444444444 -> NaN Invalid_operation
-dqor231 or 999999999 666666666 -> NaN Invalid_operation
-dqor232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqor240 or 567468689 -934981942 -> NaN Invalid_operation
-dqor241 or 567367689 934981942 -> NaN Invalid_operation
-dqor242 or -631917772 -706014634 -> NaN Invalid_operation
-dqor243 or -756253257 138579234 -> NaN Invalid_operation
-dqor244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqor250 or 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor251 or 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor252 or 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor253 or 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqor254 or 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor255 or 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor256 or 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor257 or 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqor258 or 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqor259 or 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqor260 or 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqor261 or 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqor262 or 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqor263 or 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqor264 or 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqor265 or 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqor270 or 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqor271 or 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqor272 or 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqor273 or 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqor274 or 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqor275 or 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqor276 or 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqor277 or 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqor280 or 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqor281 or 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqor282 or 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqor283 or 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqor284 or 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqor285 or 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqor286 or 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqor287 or 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqor288 or 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqor289 or 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqor290 or 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqor291 or 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqor292 or 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqor293 or 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqor294 or 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqor295 or 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqor296 or -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqor297 or -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqor298 or 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqor299 or 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001111001111001111000011000100
-
--- Nmax, Nmin, Ntiny-like
-dqor331 or 2 9.99999999E+1999 -> NaN Invalid_operation
-dqor332 or 3 1E-1999 -> NaN Invalid_operation
-dqor333 or 4 1.00000000E-1999 -> NaN Invalid_operation
-dqor334 or 5 1E-1009 -> NaN Invalid_operation
-dqor335 or 6 -1E-1009 -> NaN Invalid_operation
-dqor336 or 7 -1.00000000E-1999 -> NaN Invalid_operation
-dqor337 or 8 -1E-1999 -> NaN Invalid_operation
-dqor338 or 9 -9.99999999E+1999 -> NaN Invalid_operation
-dqor341 or 9.99999999E+2999 -18 -> NaN Invalid_operation
-dqor342 or 1E-2999 01 -> NaN Invalid_operation
-dqor343 or 1.00000000E-2999 -18 -> NaN Invalid_operation
-dqor344 or 1E-1009 18 -> NaN Invalid_operation
-dqor345 or -1E-1009 -10 -> NaN Invalid_operation
-dqor346 or -1.00000000E-2999 18 -> NaN Invalid_operation
-dqor347 or -1E-2999 10 -> NaN Invalid_operation
-dqor348 or -9.99999999E+2999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqor361 or 1.0 1 -> NaN Invalid_operation
-dqor362 or 1E+1 1 -> NaN Invalid_operation
-dqor363 or 0.0 1 -> NaN Invalid_operation
-dqor364 or 0E+1 1 -> NaN Invalid_operation
-dqor365 or 9.9 1 -> NaN Invalid_operation
-dqor366 or 9E+1 1 -> NaN Invalid_operation
-dqor371 or 0 1.0 -> NaN Invalid_operation
-dqor372 or 0 1E+1 -> NaN Invalid_operation
-dqor373 or 0 0.0 -> NaN Invalid_operation
-dqor374 or 0 0E+1 -> NaN Invalid_operation
-dqor375 or 0 9.9 -> NaN Invalid_operation
-dqor376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqor780 or -Inf -Inf -> NaN Invalid_operation
-dqor781 or -Inf -1000 -> NaN Invalid_operation
-dqor782 or -Inf -1 -> NaN Invalid_operation
-dqor783 or -Inf -0 -> NaN Invalid_operation
-dqor784 or -Inf 0 -> NaN Invalid_operation
-dqor785 or -Inf 1 -> NaN Invalid_operation
-dqor786 or -Inf 1000 -> NaN Invalid_operation
-dqor787 or -1000 -Inf -> NaN Invalid_operation
-dqor788 or -Inf -Inf -> NaN Invalid_operation
-dqor789 or -1 -Inf -> NaN Invalid_operation
-dqor790 or -0 -Inf -> NaN Invalid_operation
-dqor791 or 0 -Inf -> NaN Invalid_operation
-dqor792 or 1 -Inf -> NaN Invalid_operation
-dqor793 or 1000 -Inf -> NaN Invalid_operation
-dqor794 or Inf -Inf -> NaN Invalid_operation
-
-dqor800 or Inf -Inf -> NaN Invalid_operation
-dqor801 or Inf -1000 -> NaN Invalid_operation
-dqor802 or Inf -1 -> NaN Invalid_operation
-dqor803 or Inf -0 -> NaN Invalid_operation
-dqor804 or Inf 0 -> NaN Invalid_operation
-dqor805 or Inf 1 -> NaN Invalid_operation
-dqor806 or Inf 1000 -> NaN Invalid_operation
-dqor807 or Inf Inf -> NaN Invalid_operation
-dqor808 or -1000 Inf -> NaN Invalid_operation
-dqor809 or -Inf Inf -> NaN Invalid_operation
-dqor810 or -1 Inf -> NaN Invalid_operation
-dqor811 or -0 Inf -> NaN Invalid_operation
-dqor812 or 0 Inf -> NaN Invalid_operation
-dqor813 or 1 Inf -> NaN Invalid_operation
-dqor814 or 1000 Inf -> NaN Invalid_operation
-dqor815 or Inf Inf -> NaN Invalid_operation
-
-dqor821 or NaN -Inf -> NaN Invalid_operation
-dqor822 or NaN -1000 -> NaN Invalid_operation
-dqor823 or NaN -1 -> NaN Invalid_operation
-dqor824 or NaN -0 -> NaN Invalid_operation
-dqor825 or NaN 0 -> NaN Invalid_operation
-dqor826 or NaN 1 -> NaN Invalid_operation
-dqor827 or NaN 1000 -> NaN Invalid_operation
-dqor828 or NaN Inf -> NaN Invalid_operation
-dqor829 or NaN NaN -> NaN Invalid_operation
-dqor830 or -Inf NaN -> NaN Invalid_operation
-dqor831 or -1000 NaN -> NaN Invalid_operation
-dqor832 or -1 NaN -> NaN Invalid_operation
-dqor833 or -0 NaN -> NaN Invalid_operation
-dqor834 or 0 NaN -> NaN Invalid_operation
-dqor835 or 1 NaN -> NaN Invalid_operation
-dqor836 or 1000 NaN -> NaN Invalid_operation
-dqor837 or Inf NaN -> NaN Invalid_operation
-
-dqor841 or sNaN -Inf -> NaN Invalid_operation
-dqor842 or sNaN -1000 -> NaN Invalid_operation
-dqor843 or sNaN -1 -> NaN Invalid_operation
-dqor844 or sNaN -0 -> NaN Invalid_operation
-dqor845 or sNaN 0 -> NaN Invalid_operation
-dqor846 or sNaN 1 -> NaN Invalid_operation
-dqor847 or sNaN 1000 -> NaN Invalid_operation
-dqor848 or sNaN NaN -> NaN Invalid_operation
-dqor849 or sNaN sNaN -> NaN Invalid_operation
-dqor850 or NaN sNaN -> NaN Invalid_operation
-dqor851 or -Inf sNaN -> NaN Invalid_operation
-dqor852 or -1000 sNaN -> NaN Invalid_operation
-dqor853 or -1 sNaN -> NaN Invalid_operation
-dqor854 or -0 sNaN -> NaN Invalid_operation
-dqor855 or 0 sNaN -> NaN Invalid_operation
-dqor856 or 1 sNaN -> NaN Invalid_operation
-dqor857 or 1000 sNaN -> NaN Invalid_operation
-dqor858 or Inf sNaN -> NaN Invalid_operation
-dqor859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqor861 or NaN1 -Inf -> NaN Invalid_operation
-dqor862 or +NaN2 -1000 -> NaN Invalid_operation
-dqor863 or NaN3 1000 -> NaN Invalid_operation
-dqor864 or NaN4 Inf -> NaN Invalid_operation
-dqor865 or NaN5 +NaN6 -> NaN Invalid_operation
-dqor866 or -Inf NaN7 -> NaN Invalid_operation
-dqor867 or -1000 NaN8 -> NaN Invalid_operation
-dqor868 or 1000 NaN9 -> NaN Invalid_operation
-dqor869 or Inf +NaN10 -> NaN Invalid_operation
-dqor871 or sNaN11 -Inf -> NaN Invalid_operation
-dqor872 or sNaN12 -1000 -> NaN Invalid_operation
-dqor873 or sNaN13 1000 -> NaN Invalid_operation
-dqor874 or sNaN14 NaN17 -> NaN Invalid_operation
-dqor875 or sNaN15 sNaN18 -> NaN Invalid_operation
-dqor876 or NaN16 sNaN19 -> NaN Invalid_operation
-dqor877 or -Inf +sNaN20 -> NaN Invalid_operation
-dqor878 or -1000 sNaN21 -> NaN Invalid_operation
-dqor879 or 1000 sNaN22 -> NaN Invalid_operation
-dqor880 or Inf sNaN23 -> NaN Invalid_operation
-dqor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-dqor882 or -NaN26 NaN28 -> NaN Invalid_operation
-dqor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-dqor884 or 1000 -NaN30 -> NaN Invalid_operation
-dqor885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqOr.decTest -- digitwise logical OR for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqor001 or 0 0 -> 0
+dqor002 or 0 1 -> 1
+dqor003 or 1 0 -> 1
+dqor004 or 1 1 -> 1
+dqor005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+dqor006 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqor007 or 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor008 or 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor009 or 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqor010 or 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqor011 or 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqor012 or 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
+dqor013 or 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+
+-- Various lengths
+dqor601 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
+dqor602 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
+dqor603 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
+dqor604 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
+dqor605 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
+dqor606 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
+dqor607 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
+dqor608 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
+dqor609 or 1111111101111111111111111111111111 1111111111111111111111111011111111 -> 1111111111111111111111111111111111
+dqor610 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
+dqor611 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
+dqor612 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
+dqor613 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
+dqor614 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
+dqor615 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
+dqor616 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
+dqor617 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
+dqor618 or 1111111111111111101111111111111111 1111111111111111011111111111111111 -> 1111111111111111111111111111111111
+dqor619 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
+dqor620 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
+dqor621 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
+dqor622 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
+dqor623 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
+dqor624 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
+dqor625 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
+dqor626 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
+dqor627 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
+dqor628 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor629 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor630 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor631 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor632 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor633 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor634 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
+
+dqor641 or 1111111111111111111111111111111110 0111111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor642 or 1111111111111111111111111111111101 1011111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor643 or 1111111111111111111111111111111011 1101111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor644 or 1111111111111111111111111111110111 1110111111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor645 or 1111111111111111111111111111101111 1111011111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor646 or 1111111111111111111111111111011111 1111101111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor647 or 1111111111111111111111111110111111 1111110111111111111111111111111111 -> 1111111111111111111111111111111111
+dqor648 or 1111111111111111111111111101111111 1111111011111111111111111111111111 -> 1111111111111111111111111111111111
+dqor649 or 1111111111111111111111111011111111 1111111101111111111111111111111111 -> 1111111111111111111111111111111111
+dqor650 or 1111111111111111111111110111111111 1111111110111111111111111111111111 -> 1111111111111111111111111111111111
+dqor651 or 1111111111111111111111101111111111 1111111111011111111111111111111111 -> 1111111111111111111111111111111111
+dqor652 or 1111111111111111111111011111111111 1111111111101111111111111111111111 -> 1111111111111111111111111111111111
+dqor653 or 1111111111111111111110111111111111 1111111111110111111111111111111111 -> 1111111111111111111111111111111111
+dqor654 or 1111111111111111111101111111111111 1111111111111011111111111111111111 -> 1111111111111111111111111111111111
+dqor655 or 1111111111111111111011111111111111 1111111111111101111111111111111111 -> 1111111111111111111111111111111111
+dqor656 or 1111111111111111110111111111111111 1111111111111110111111111111111111 -> 1111111111111111111111111111111111
+dqor657 or 1010101010101010101010101010101010 1010101010101010001010101010101010 -> 1010101010101010101010101010101010
+dqor658 or 1111111111111111011111111111111111 1111111111111111101111111111111111 -> 1111111111111111111111111111111111
+dqor659 or 1111111111111110111111111111111111 1111111111111111110111111111111111 -> 1111111111111111111111111111111111
+dqor660 or 1111111111111101111111111111111111 1111111111111111111011111111111111 -> 1111111111111111111111111111111111
+dqor661 or 1111111111111011111111111111111111 1111111111111111111101111111111111 -> 1111111111111111111111111111111111
+dqor662 or 1111111111110111111111111111111111 1111111111111111111110111111111111 -> 1111111111111111111111111111111111
+dqor663 or 1111111111101111111111111111111111 1111111111111111111111011111111111 -> 1111111111111111111111111111111111
+dqor664 or 1111111111011111111111111111111111 1111111111111111111111101111111111 -> 1111111111111111111111111111111111
+dqor665 or 1111111110111111111111111111111111 1111111111111111111111110111111111 -> 1111111111111111111111111111111111
+dqor666 or 0101010101010101010101010101010101 0101010101010101010101010001010101 -> 101010101010101010101010101010101
+dqor667 or 1111111011111111111111111111111111 1111111111111111111111111101111111 -> 1111111111111111111111111111111111
+dqor668 or 1111110111111111111111111111111111 1111111111111111111111111110111111 -> 1111111111111111111111111111111111
+dqor669 or 1111101111111111111111111111111111 1111111111111111111111111111011111 -> 1111111111111111111111111111111111
+dqor670 or 1111011111111111111111111111111111 1111111111111111111111111111101111 -> 1111111111111111111111111111111111
+dqor671 or 1110111111111111111111111111111111 1111111111111111111111111111110111 -> 1111111111111111111111111111111111
+dqor672 or 1101111111111111111111111111111111 1111111111111111111111111111111011 -> 1111111111111111111111111111111111
+dqor673 or 1011111111111111111111111111111111 1111111111111111111111111111111101 -> 1111111111111111111111111111111111
+dqor674 or 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1111111111111111111111111111111111
+dqor675 or 0111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+dqor676 or 1111111111111111111111111111111110 1111111111111111111111111111111110 -> 1111111111111111111111111111111110
+
+dqor681 or 0111111111111111111111111111111111 0111111111011111111111111111111110 -> 111111111111111111111111111111111
+dqor682 or 1011111111111111111111111111111111 1011111110101111111111111111111101 -> 1011111111111111111111111111111111
+dqor683 or 1101111111111111111111111111111111 1101111101110111111111111111111011 -> 1101111111111111111111111111111111
+dqor684 or 1110111111111111111111111111111111 1110111011111011111111111111110111 -> 1110111111111111111111111111111111
+dqor685 or 1111011111111111111111111111111111 1111010111111101111111111111101111 -> 1111011111111111111111111111111111
+dqor686 or 1111101111111111111111111111111111 1111101111111110111111111111011111 -> 1111101111111111111111111111111111
+dqor687 or 1111110111111111111111111111111111 1111010111111111011111111110111111 -> 1111110111111111111111111111111111
+dqor688 or 1111111011111111111111111111111111 1110111011111111101111111101111111 -> 1111111011111111111111111111111111
+dqor689 or 1111111101111111111111111111111111 1101111101111111110111111011111111 -> 1111111101111111111111111111111111
+dqor690 or 1111111110111111111111111111111111 1011111110111111111011110111111110 -> 1111111110111111111111111111111111
+dqor691 or 1111111111011111111111111111111111 0111111111011111111101101111111101 -> 1111111111011111111111111111111111
+dqor692 or 1111111111101111111111111111111111 1111111111101111111110011111111011 -> 1111111111101111111111111111111111
+dqor693 or 1111111111110111111111111111111111 1111111111110111111110011111110111 -> 1111111111110111111111111111111111
+dqor694 or 1111111111111011111111111111111111 1111111111111011111101101111101111 -> 1111111111111011111111111111111111
+dqor695 or 1111111111111101111111111111111111 1111111111111101111011110111011111 -> 1111111111111101111111111111111111
+dqor696 or 1111111111111110111111111111111111 1111111111111110110111111010111111 -> 1111111111111110111111111111111111
+dqor697 or 1111111111111111011111111111111111 1111111111111111001111111101111111 -> 1111111111111111011111111111111111
+dqor698 or 1111111111111111101111111111111111 1111111111111111001111111010111111 -> 1111111111111111101111111111111111
+dqor699 or 1111111111111111110111111111111111 1111111111111110110111110111011111 -> 1111111111111111110111111111111111
+dqor700 or 1111111111111111111011111111111111 1111111111111101111011101111101111 -> 1111111111111111111011111111111111
+dqor701 or 1111111111111111111101111111111111 1111111111111011111101011111110111 -> 1111111111111111111101111111111111
+dqor702 or 1111111111111111111110111111111111 1111111111110111111110111111111011 -> 1111111111111111111110111111111111
+dqor703 or 1111111111111111111111011111111111 1111111111101111111101011111111101 -> 1111111111111111111111011111111111
+dqor704 or 1111111111111111111111101111111111 1111111111011111111011101111111110 -> 1111111111111111111111101111111111
+dqor705 or 1111111111111111111111110111111111 0111111110111111110111110111111111 -> 1111111111111111111111110111111111
+dqor706 or 1111111111111111111111111011111111 1011111101111111101111111011111111 -> 1111111111111111111111111011111111
+dqor707 or 1111111111111111111111111101111111 1101111011111111011111111101111111 -> 1111111111111111111111111101111111
+dqor708 or 1111111111111111111111111110111111 1110110111111110111111111110111111 -> 1111111111111111111111111110111111
+dqor709 or 1111111111111111111111111111011111 1111001111111101111111111111011111 -> 1111111111111111111111111111011111
+dqor710 or 1111111111111111111111111111101111 1111001111111011111111111111101111 -> 1111111111111111111111111111101111
+dqor711 or 1111111111111111111111111111110111 1110110111110111111111111111110111 -> 1111111111111111111111111111110111
+dqor712 or 1111111111111111111111111111111011 1101111011101111111111111111111011 -> 1111111111111111111111111111111011
+dqor713 or 1111111111111111111111111111111101 1011111101011111111111111111111101 -> 1111111111111111111111111111111101
+dqor714 or 1111111111111111111111111111111110 0111111110111111111111111111111110 -> 1111111111111111111111111111111110
+
+
+
+-- 1234567890123456 1234567890123456 1234567890123456
+dqor020 or 1111111111111111 1111111111111111 -> 1111111111111111
+dqor021 or 111111111111111 111111111111111 -> 111111111111111
+dqor022 or 11111111111111 11111111111111 -> 11111111111111
+dqor023 or 1111111111111 1111111111111 -> 1111111111111
+dqor024 or 111111111111 111111111111 -> 111111111111
+dqor025 or 11111111111 11111111111 -> 11111111111
+dqor026 or 1111111111 1111111111 -> 1111111111
+dqor027 or 111111111 111111111 -> 111111111
+dqor028 or 11111111 11111111 -> 11111111
+dqor029 or 1111111 1111111 -> 1111111
+dqor030 or 111111 111111 -> 111111
+dqor031 or 11111 11111 -> 11111
+dqor032 or 1111 1111 -> 1111
+dqor033 or 111 111 -> 111
+dqor034 or 11 11 -> 11
+dqor035 or 1 1 -> 1
+dqor036 or 0 0 -> 0
+
+dqor042 or 111111110000000 1111111110000000 -> 1111111110000000
+dqor043 or 11111110000000 1000000100000000 -> 1011111110000000
+dqor044 or 1111110000000 1000001000000000 -> 1001111110000000
+dqor045 or 111110000000 1000010000000000 -> 1000111110000000
+dqor046 or 11110000000 1000100000000000 -> 1000111110000000
+dqor047 or 1110000000 1001000000000000 -> 1001001110000000
+dqor048 or 110000000 1010000000000000 -> 1010000110000000
+dqor049 or 10000000 1100000000000000 -> 1100000010000000
+
+dqor090 or 011111111 111101111 -> 111111111
+dqor091 or 101111111 111101111 -> 111111111
+dqor092 or 110111111 111101111 -> 111111111
+dqor093 or 111011111 111101111 -> 111111111
+dqor094 or 111101111 111101111 -> 111101111
+dqor095 or 111110111 111101111 -> 111111111
+dqor096 or 111111011 111101111 -> 111111111
+dqor097 or 111111101 111101111 -> 111111111
+dqor098 or 111111110 111101111 -> 111111111
+
+dqor100 or 111101111 011111111 -> 111111111
+dqor101 or 111101111 101111111 -> 111111111
+dqor102 or 111101111 110111111 -> 111111111
+dqor103 or 111101111 111011111 -> 111111111
+dqor104 or 111101111 111101111 -> 111101111
+dqor105 or 111101111 111110111 -> 111111111
+dqor106 or 111101111 111111011 -> 111111111
+dqor107 or 111101111 111111101 -> 111111111
+dqor108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+dqor220 or 111111112 111111111 -> NaN Invalid_operation
+dqor221 or 333333333 333333333 -> NaN Invalid_operation
+dqor222 or 555555555 555555555 -> NaN Invalid_operation
+dqor223 or 777777777 777777777 -> NaN Invalid_operation
+dqor224 or 999999999 999999999 -> NaN Invalid_operation
+dqor225 or 222222222 999999999 -> NaN Invalid_operation
+dqor226 or 444444444 999999999 -> NaN Invalid_operation
+dqor227 or 666666666 999999999 -> NaN Invalid_operation
+dqor228 or 888888888 999999999 -> NaN Invalid_operation
+dqor229 or 999999999 222222222 -> NaN Invalid_operation
+dqor230 or 999999999 444444444 -> NaN Invalid_operation
+dqor231 or 999999999 666666666 -> NaN Invalid_operation
+dqor232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqor240 or 567468689 -934981942 -> NaN Invalid_operation
+dqor241 or 567367689 934981942 -> NaN Invalid_operation
+dqor242 or -631917772 -706014634 -> NaN Invalid_operation
+dqor243 or -756253257 138579234 -> NaN Invalid_operation
+dqor244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqor250 or 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor251 or 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor252 or 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor253 or 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqor254 or 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor255 or 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor256 or 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor257 or 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqor258 or 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqor259 or 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqor260 or 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqor261 or 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqor262 or 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqor263 or 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqor264 or 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqor265 or 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqor270 or 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqor271 or 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqor272 or 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqor273 or 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqor274 or 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqor275 or 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqor276 or 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqor277 or 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqor280 or 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqor281 or 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqor282 or 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqor283 or 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqor284 or 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqor285 or 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqor286 or 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqor287 or 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqor288 or 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqor289 or 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqor290 or 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqor291 or 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqor292 or 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqor293 or 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqor294 or 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqor295 or 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqor296 or -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqor297 or -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqor298 or 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqor299 or 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001111001111001111000011000100
+
+-- Nmax, Nmin, Ntiny-like
+dqor331 or 2 9.99999999E+1999 -> NaN Invalid_operation
+dqor332 or 3 1E-1999 -> NaN Invalid_operation
+dqor333 or 4 1.00000000E-1999 -> NaN Invalid_operation
+dqor334 or 5 1E-1009 -> NaN Invalid_operation
+dqor335 or 6 -1E-1009 -> NaN Invalid_operation
+dqor336 or 7 -1.00000000E-1999 -> NaN Invalid_operation
+dqor337 or 8 -1E-1999 -> NaN Invalid_operation
+dqor338 or 9 -9.99999999E+1999 -> NaN Invalid_operation
+dqor341 or 9.99999999E+2999 -18 -> NaN Invalid_operation
+dqor342 or 1E-2999 01 -> NaN Invalid_operation
+dqor343 or 1.00000000E-2999 -18 -> NaN Invalid_operation
+dqor344 or 1E-1009 18 -> NaN Invalid_operation
+dqor345 or -1E-1009 -10 -> NaN Invalid_operation
+dqor346 or -1.00000000E-2999 18 -> NaN Invalid_operation
+dqor347 or -1E-2999 10 -> NaN Invalid_operation
+dqor348 or -9.99999999E+2999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqor361 or 1.0 1 -> NaN Invalid_operation
+dqor362 or 1E+1 1 -> NaN Invalid_operation
+dqor363 or 0.0 1 -> NaN Invalid_operation
+dqor364 or 0E+1 1 -> NaN Invalid_operation
+dqor365 or 9.9 1 -> NaN Invalid_operation
+dqor366 or 9E+1 1 -> NaN Invalid_operation
+dqor371 or 0 1.0 -> NaN Invalid_operation
+dqor372 or 0 1E+1 -> NaN Invalid_operation
+dqor373 or 0 0.0 -> NaN Invalid_operation
+dqor374 or 0 0E+1 -> NaN Invalid_operation
+dqor375 or 0 9.9 -> NaN Invalid_operation
+dqor376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqor780 or -Inf -Inf -> NaN Invalid_operation
+dqor781 or -Inf -1000 -> NaN Invalid_operation
+dqor782 or -Inf -1 -> NaN Invalid_operation
+dqor783 or -Inf -0 -> NaN Invalid_operation
+dqor784 or -Inf 0 -> NaN Invalid_operation
+dqor785 or -Inf 1 -> NaN Invalid_operation
+dqor786 or -Inf 1000 -> NaN Invalid_operation
+dqor787 or -1000 -Inf -> NaN Invalid_operation
+dqor788 or -Inf -Inf -> NaN Invalid_operation
+dqor789 or -1 -Inf -> NaN Invalid_operation
+dqor790 or -0 -Inf -> NaN Invalid_operation
+dqor791 or 0 -Inf -> NaN Invalid_operation
+dqor792 or 1 -Inf -> NaN Invalid_operation
+dqor793 or 1000 -Inf -> NaN Invalid_operation
+dqor794 or Inf -Inf -> NaN Invalid_operation
+
+dqor800 or Inf -Inf -> NaN Invalid_operation
+dqor801 or Inf -1000 -> NaN Invalid_operation
+dqor802 or Inf -1 -> NaN Invalid_operation
+dqor803 or Inf -0 -> NaN Invalid_operation
+dqor804 or Inf 0 -> NaN Invalid_operation
+dqor805 or Inf 1 -> NaN Invalid_operation
+dqor806 or Inf 1000 -> NaN Invalid_operation
+dqor807 or Inf Inf -> NaN Invalid_operation
+dqor808 or -1000 Inf -> NaN Invalid_operation
+dqor809 or -Inf Inf -> NaN Invalid_operation
+dqor810 or -1 Inf -> NaN Invalid_operation
+dqor811 or -0 Inf -> NaN Invalid_operation
+dqor812 or 0 Inf -> NaN Invalid_operation
+dqor813 or 1 Inf -> NaN Invalid_operation
+dqor814 or 1000 Inf -> NaN Invalid_operation
+dqor815 or Inf Inf -> NaN Invalid_operation
+
+dqor821 or NaN -Inf -> NaN Invalid_operation
+dqor822 or NaN -1000 -> NaN Invalid_operation
+dqor823 or NaN -1 -> NaN Invalid_operation
+dqor824 or NaN -0 -> NaN Invalid_operation
+dqor825 or NaN 0 -> NaN Invalid_operation
+dqor826 or NaN 1 -> NaN Invalid_operation
+dqor827 or NaN 1000 -> NaN Invalid_operation
+dqor828 or NaN Inf -> NaN Invalid_operation
+dqor829 or NaN NaN -> NaN Invalid_operation
+dqor830 or -Inf NaN -> NaN Invalid_operation
+dqor831 or -1000 NaN -> NaN Invalid_operation
+dqor832 or -1 NaN -> NaN Invalid_operation
+dqor833 or -0 NaN -> NaN Invalid_operation
+dqor834 or 0 NaN -> NaN Invalid_operation
+dqor835 or 1 NaN -> NaN Invalid_operation
+dqor836 or 1000 NaN -> NaN Invalid_operation
+dqor837 or Inf NaN -> NaN Invalid_operation
+
+dqor841 or sNaN -Inf -> NaN Invalid_operation
+dqor842 or sNaN -1000 -> NaN Invalid_operation
+dqor843 or sNaN -1 -> NaN Invalid_operation
+dqor844 or sNaN -0 -> NaN Invalid_operation
+dqor845 or sNaN 0 -> NaN Invalid_operation
+dqor846 or sNaN 1 -> NaN Invalid_operation
+dqor847 or sNaN 1000 -> NaN Invalid_operation
+dqor848 or sNaN NaN -> NaN Invalid_operation
+dqor849 or sNaN sNaN -> NaN Invalid_operation
+dqor850 or NaN sNaN -> NaN Invalid_operation
+dqor851 or -Inf sNaN -> NaN Invalid_operation
+dqor852 or -1000 sNaN -> NaN Invalid_operation
+dqor853 or -1 sNaN -> NaN Invalid_operation
+dqor854 or -0 sNaN -> NaN Invalid_operation
+dqor855 or 0 sNaN -> NaN Invalid_operation
+dqor856 or 1 sNaN -> NaN Invalid_operation
+dqor857 or 1000 sNaN -> NaN Invalid_operation
+dqor858 or Inf sNaN -> NaN Invalid_operation
+dqor859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqor861 or NaN1 -Inf -> NaN Invalid_operation
+dqor862 or +NaN2 -1000 -> NaN Invalid_operation
+dqor863 or NaN3 1000 -> NaN Invalid_operation
+dqor864 or NaN4 Inf -> NaN Invalid_operation
+dqor865 or NaN5 +NaN6 -> NaN Invalid_operation
+dqor866 or -Inf NaN7 -> NaN Invalid_operation
+dqor867 or -1000 NaN8 -> NaN Invalid_operation
+dqor868 or 1000 NaN9 -> NaN Invalid_operation
+dqor869 or Inf +NaN10 -> NaN Invalid_operation
+dqor871 or sNaN11 -Inf -> NaN Invalid_operation
+dqor872 or sNaN12 -1000 -> NaN Invalid_operation
+dqor873 or sNaN13 1000 -> NaN Invalid_operation
+dqor874 or sNaN14 NaN17 -> NaN Invalid_operation
+dqor875 or sNaN15 sNaN18 -> NaN Invalid_operation
+dqor876 or NaN16 sNaN19 -> NaN Invalid_operation
+dqor877 or -Inf +sNaN20 -> NaN Invalid_operation
+dqor878 or -1000 sNaN21 -> NaN Invalid_operation
+dqor879 or 1000 sNaN22 -> NaN Invalid_operation
+dqor880 or Inf sNaN23 -> NaN Invalid_operation
+dqor881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+dqor882 or -NaN26 NaN28 -> NaN Invalid_operation
+dqor883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+dqor884 or 1000 -NaN30 -> NaN Invalid_operation
+dqor885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqPlus.decTest b/Lib/test/decimaltestdata/dqPlus.decTest
index 8aecaab796b..df1a15ca7fd 100644
--- a/Lib/test/decimaltestdata/dqPlus.decTest
+++ b/Lib/test/decimaltestdata/dqPlus.decTest
@@ -1,88 +1,88 @@
-------------------------------------------------------------------------
--- dqPlus.decTest -- decQuad 0+x --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqpls001 plus +7.50 -> 7.50
-
--- Infinities
-dqpls011 plus Infinity -> Infinity
-dqpls012 plus -Infinity -> -Infinity
-
--- NaNs, 0 payload
-ddqls021 plus NaN -> NaN
-ddqls022 plus -NaN -> -NaN
-ddqls023 plus sNaN -> NaN Invalid_operation
-ddqls024 plus -sNaN -> -NaN Invalid_operation
-
--- NaNs, non-0 payload
-ddqls031 plus NaN13 -> NaN13
-ddqls032 plus -NaN13 -> -NaN13
-ddqls033 plus sNaN13 -> NaN13 Invalid_operation
-ddqls034 plus -sNaN13 -> -NaN13 Invalid_operation
-ddqls035 plus NaN70 -> NaN70
-ddqls036 plus -NaN70 -> -NaN70
-ddqls037 plus sNaN101 -> NaN101 Invalid_operation
-ddqls038 plus -sNaN101 -> -NaN101 Invalid_operation
-
--- finites
-dqpls101 plus 7 -> 7
-dqpls102 plus -7 -> -7
-dqpls103 plus 75 -> 75
-dqpls104 plus -75 -> -75
-dqpls105 plus 7.50 -> 7.50
-dqpls106 plus -7.50 -> -7.50
-dqpls107 plus 7.500 -> 7.500
-dqpls108 plus -7.500 -> -7.500
-
--- zeros
-dqpls111 plus 0 -> 0
-dqpls112 plus -0 -> 0
-dqpls113 plus 0E+4 -> 0E+4
-dqpls114 plus -0E+4 -> 0E+4
-dqpls115 plus 0.0000 -> 0.0000
-dqpls116 plus -0.0000 -> 0.0000
-dqpls117 plus 0E-141 -> 0E-141
-dqpls118 plus -0E-141 -> 0E-141
-
--- full coefficients, alternating bits
-dqpls121 plus 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
-dqpls122 plus -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
-dqpls123 plus 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
-dqpls124 plus -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
-
--- Nmax, Nmin, Ntiny
-dqpls131 plus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqpls132 plus 1E-6143 -> 1E-6143
-dqpls133 plus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
-dqpls134 plus 1E-6176 -> 1E-6176 Subnormal
-
-dqpls135 plus -1E-6176 -> -1E-6176 Subnormal
-dqpls136 plus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
-dqpls137 plus -1E-6143 -> -1E-6143
-dqpls138 plus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+------------------------------------------------------------------------
+-- dqPlus.decTest -- decQuad 0+x --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqpls001 plus +7.50 -> 7.50
+
+-- Infinities
+dqpls011 plus Infinity -> Infinity
+dqpls012 plus -Infinity -> -Infinity
+
+-- NaNs, 0 payload
+ddqls021 plus NaN -> NaN
+ddqls022 plus -NaN -> -NaN
+ddqls023 plus sNaN -> NaN Invalid_operation
+ddqls024 plus -sNaN -> -NaN Invalid_operation
+
+-- NaNs, non-0 payload
+ddqls031 plus NaN13 -> NaN13
+ddqls032 plus -NaN13 -> -NaN13
+ddqls033 plus sNaN13 -> NaN13 Invalid_operation
+ddqls034 plus -sNaN13 -> -NaN13 Invalid_operation
+ddqls035 plus NaN70 -> NaN70
+ddqls036 plus -NaN70 -> -NaN70
+ddqls037 plus sNaN101 -> NaN101 Invalid_operation
+ddqls038 plus -sNaN101 -> -NaN101 Invalid_operation
+
+-- finites
+dqpls101 plus 7 -> 7
+dqpls102 plus -7 -> -7
+dqpls103 plus 75 -> 75
+dqpls104 plus -75 -> -75
+dqpls105 plus 7.50 -> 7.50
+dqpls106 plus -7.50 -> -7.50
+dqpls107 plus 7.500 -> 7.500
+dqpls108 plus -7.500 -> -7.500
+
+-- zeros
+dqpls111 plus 0 -> 0
+dqpls112 plus -0 -> 0
+dqpls113 plus 0E+4 -> 0E+4
+dqpls114 plus -0E+4 -> 0E+4
+dqpls115 plus 0.0000 -> 0.0000
+dqpls116 plus -0.0000 -> 0.0000
+dqpls117 plus 0E-141 -> 0E-141
+dqpls118 plus -0E-141 -> 0E-141
+
+-- full coefficients, alternating bits
+dqpls121 plus 2682682682682682682682682682682682 -> 2682682682682682682682682682682682
+dqpls122 plus -2682682682682682682682682682682682 -> -2682682682682682682682682682682682
+dqpls123 plus 1341341341341341341341341341341341 -> 1341341341341341341341341341341341
+dqpls124 plus -1341341341341341341341341341341341 -> -1341341341341341341341341341341341
+
+-- Nmax, Nmin, Ntiny
+dqpls131 plus 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqpls132 plus 1E-6143 -> 1E-6143
+dqpls133 plus 1.000000000000000000000000000000000E-6143 -> 1.000000000000000000000000000000000E-6143
+dqpls134 plus 1E-6176 -> 1E-6176 Subnormal
+
+dqpls135 plus -1E-6176 -> -1E-6176 Subnormal
+dqpls136 plus -1.000000000000000000000000000000000E-6143 -> -1.000000000000000000000000000000000E-6143
+dqpls137 plus -1E-6143 -> -1E-6143
+dqpls138 plus -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
diff --git a/Lib/test/decimaltestdata/dqQuantize.decTest b/Lib/test/decimaltestdata/dqQuantize.decTest
index 51471c2626b..4ed39b45c47 100644
--- a/Lib/test/decimaltestdata/dqQuantize.decTest
+++ b/Lib/test/decimaltestdata/dqQuantize.decTest
@@ -1,836 +1,836 @@
-------------------------------------------------------------------------
--- dqQuantize.decTest -- decQuad quantize operation --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Most of the tests here assume a "regular pattern", where the
--- sign and coefficient are +1.
--- 2004.03.15 Underflow for quantize is suppressed
--- 2005.06.08 More extensive tests for 'does not fit'
--- [Forked from quantize.decTest 2006.11.25]
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks
-dqqua001 quantize 0 1e0 -> 0
-dqqua002 quantize 1 1e0 -> 1
-dqqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
-dqqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
-dqqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
-dqqua007 quantize 0.1 1e-1 -> 0.1
-dqqua008 quantize 0.1 1e-2 -> 0.10
-dqqua009 quantize 0.1 1e-3 -> 0.100
-dqqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
-dqqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
-dqqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
-dqqua013 quantize 0.9 1e-1 -> 0.9
-dqqua014 quantize 0.9 1e-2 -> 0.90
-dqqua015 quantize 0.9 1e-3 -> 0.900
--- negatives
-dqqua021 quantize -0 1e0 -> -0
-dqqua022 quantize -1 1e0 -> -1
-dqqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
-dqqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
-dqqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
-dqqua027 quantize -0.1 1e-1 -> -0.1
-dqqua028 quantize -0.1 1e-2 -> -0.10
-dqqua029 quantize -0.1 1e-3 -> -0.100
-dqqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-dqqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-dqqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
-dqqua033 quantize -0.9 1e-1 -> -0.9
-dqqua034 quantize -0.9 1e-2 -> -0.90
-dqqua035 quantize -0.9 1e-3 -> -0.900
-dqqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
-dqqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
-dqqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
-dqqua039 quantize -0.5 1e-1 -> -0.5
-dqqua040 quantize -0.5 1e-2 -> -0.50
-dqqua041 quantize -0.5 1e-3 -> -0.500
-dqqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
-dqqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
-dqqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
-dqqua045 quantize -0.9 1e-1 -> -0.9
-dqqua046 quantize -0.9 1e-2 -> -0.90
-dqqua047 quantize -0.9 1e-3 -> -0.900
-
--- examples from Specification
-dqqua060 quantize 2.17 0.001 -> 2.170
-dqqua061 quantize 2.17 0.01 -> 2.17
-dqqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
-dqqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
-dqqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
-dqqua065 quantize -Inf Inf -> -Infinity
-dqqua066 quantize 2 Inf -> NaN Invalid_operation
-dqqua067 quantize -0.1 1 -> -0 Inexact Rounded
-dqqua068 quantize -0 1e+5 -> -0E+5
-dqqua069 quantize +123451234567899876543216789012345.6 1e-2 -> NaN Invalid_operation
-dqqua070 quantize -987651234567899876543214335236450.6 1e-2 -> NaN Invalid_operation
-dqqua071 quantize 217 1e-1 -> 217.0
-dqqua072 quantize 217 1e+0 -> 217
-dqqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
-dqqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
-
--- general tests ..
-dqqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
-dqqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
-dqqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
-dqqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
-dqqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
-dqqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
-dqqua095 quantize 1.2345 1e-6 -> 1.234500
-dqqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
-dqqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
-dqqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
-dqqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
-dqqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
-
-dqqua101 quantize -1 1e0 -> -1
-dqqua102 quantize -1 1e-1 -> -1.0
-dqqua103 quantize -1 1e-2 -> -1.00
-dqqua104 quantize 0 1e0 -> 0
-dqqua105 quantize 0 1e-1 -> 0.0
-dqqua106 quantize 0 1e-2 -> 0.00
-dqqua107 quantize 0.00 1e0 -> 0
-dqqua108 quantize 0 1e+1 -> 0E+1
-dqqua109 quantize 0 1e+2 -> 0E+2
-dqqua110 quantize +1 1e0 -> 1
-dqqua111 quantize +1 1e-1 -> 1.0
-dqqua112 quantize +1 1e-2 -> 1.00
-
-dqqua120 quantize 1.04 1e-3 -> 1.040
-dqqua121 quantize 1.04 1e-2 -> 1.04
-dqqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
-dqqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
-dqqua124 quantize 1.05 1e-3 -> 1.050
-dqqua125 quantize 1.05 1e-2 -> 1.05
-dqqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
-dqqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
-dqqua132 quantize 1.06 1e-3 -> 1.060
-dqqua133 quantize 1.06 1e-2 -> 1.06
-dqqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
-dqqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
-
-dqqua140 quantize -10 1e-2 -> -10.00
-dqqua141 quantize +1 1e-2 -> 1.00
-dqqua142 quantize +10 1e-2 -> 10.00
-dqqua143 quantize 1E+37 1e-2 -> NaN Invalid_operation
-dqqua144 quantize 1E-37 1e-2 -> 0.00 Inexact Rounded
-dqqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
-dqqua146 quantize 1E-2 1e-2 -> 0.01
-dqqua147 quantize 1E-1 1e-2 -> 0.10
-dqqua148 quantize 0E-37 1e-2 -> 0.00
-
-dqqua150 quantize 1.0600 1e-5 -> 1.06000
-dqqua151 quantize 1.0600 1e-4 -> 1.0600
-dqqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
-dqqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
-dqqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
-dqqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
-
--- a couple where rounding was different in base tests
-rounding: half_up
-dqqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
-dqqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
-dqqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
-rounding: half_even
-
--- base tests with non-1 coefficients
-dqqua161 quantize 0 -9e0 -> 0
-dqqua162 quantize 1 -7e0 -> 1
-dqqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
-dqqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
-dqqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
-dqqua167 quantize 0.1 3e-1 -> 0.1
-dqqua168 quantize 0.1 44e-2 -> 0.10
-dqqua169 quantize 0.1 555e-3 -> 0.100
-dqqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
-dqqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
-dqqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
-dqqua173 quantize 0.9 -9e-1 -> 0.9
-dqqua174 quantize 0.9 0e-2 -> 0.90
-dqqua175 quantize 0.9 1.1e-3 -> 0.9000
--- negatives
-dqqua181 quantize -0 1.1e0 -> -0.0
-dqqua182 quantize -1 -1e0 -> -1
-dqqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
-dqqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
-dqqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
-dqqua187 quantize -0.1 -91e-1 -> -0.1
-dqqua188 quantize -0.1 -.1e-2 -> -0.100
-dqqua189 quantize -0.1 -1e-3 -> -0.100
-dqqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
-dqqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
-dqqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
-dqqua193 quantize -0.9 100e-1 -> -0.9
-dqqua194 quantize -0.9 999e-2 -> -0.90
-
--- +ve exponents ..
-dqqua201 quantize -1 1e+0 -> -1
-dqqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
-dqqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
-dqqua204 quantize 0 1e+0 -> 0
-dqqua205 quantize 0 1e+1 -> 0E+1
-dqqua206 quantize 0 1e+2 -> 0E+2
-dqqua207 quantize +1 1e+0 -> 1
-dqqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-dqqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
-dqqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
-dqqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
-dqqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
-dqqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-dqqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-dqqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-dqqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
-dqqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
-dqqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
-dqqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
-dqqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
-dqqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
-dqqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
-dqqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
-dqqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
-
-dqqua240 quantize -10 1e+1 -> -1E+1 Rounded
-dqqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
-dqqua242 quantize +10 1e+1 -> 1E+1 Rounded
-dqqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
-dqqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
-dqqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
-dqqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
-dqqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
-dqqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
-dqqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
-dqqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
-dqqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
--- next one tries to add 9 zeros
-dqqua252 quantize 1E+37 1e+1 -> NaN Invalid_operation
-dqqua253 quantize 1E-37 1e+1 -> 0E+1 Inexact Rounded
-dqqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
-dqqua255 quantize 0E-37 1e+1 -> 0E+1
-dqqua256 quantize -0E-37 1e+1 -> -0E+1
-dqqua257 quantize -0E-1 1e+1 -> -0E+1
-dqqua258 quantize -0 1e+1 -> -0E+1
-dqqua259 quantize -0E+1 1e+1 -> -0E+1
-
-dqqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
-dqqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
-dqqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
-dqqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
-dqqua264 quantize 1E+2 1e+2 -> 1E+2
-dqqua265 quantize 1E+3 1e+2 -> 1.0E+3
-dqqua266 quantize 1E+4 1e+2 -> 1.00E+4
-dqqua267 quantize 1E+5 1e+2 -> 1.000E+5
-dqqua268 quantize 1E+6 1e+2 -> 1.0000E+6
-dqqua269 quantize 1E+7 1e+2 -> 1.00000E+7
-dqqua270 quantize 1E+8 1e+2 -> 1.000000E+8
-dqqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
-dqqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
-dqqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
-dqqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
-dqqua275 quantize 0E-10 1e+2 -> 0E+2
-
-dqqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
-dqqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
-dqqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
-dqqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
-dqqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
-dqqua285 quantize 1E+3 1e+3 -> 1E+3
-dqqua286 quantize 1E+4 1e+3 -> 1.0E+4
-dqqua287 quantize 1E+5 1e+3 -> 1.00E+5
-dqqua288 quantize 1E+6 1e+3 -> 1.000E+6
-dqqua289 quantize 1E+7 1e+3 -> 1.0000E+7
-dqqua290 quantize 1E+8 1e+3 -> 1.00000E+8
-dqqua291 quantize 1E+9 1e+3 -> 1.000000E+9
-dqqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
-dqqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
-dqqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
-dqqua295 quantize 0E-10 1e+3 -> 0E+3
-
--- round up from below [sign wrong in JIT compiler once]
-dqqua300 quantize 0.0078 1e-5 -> 0.00780
-dqqua301 quantize 0.0078 1e-4 -> 0.0078
-dqqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
-dqqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
-dqqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
-dqqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
-dqqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
-dqqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua310 quantize -0.0078 1e-5 -> -0.00780
-dqqua311 quantize -0.0078 1e-4 -> -0.0078
-dqqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
-dqqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
-dqqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
-dqqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
-dqqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
-dqqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua320 quantize 0.078 1e-5 -> 0.07800
-dqqua321 quantize 0.078 1e-4 -> 0.0780
-dqqua322 quantize 0.078 1e-3 -> 0.078
-dqqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
-dqqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
-dqqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
-dqqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
-dqqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua330 quantize -0.078 1e-5 -> -0.07800
-dqqua331 quantize -0.078 1e-4 -> -0.0780
-dqqua332 quantize -0.078 1e-3 -> -0.078
-dqqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
-dqqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
-dqqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
-dqqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
-dqqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua340 quantize 0.78 1e-5 -> 0.78000
-dqqua341 quantize 0.78 1e-4 -> 0.7800
-dqqua342 quantize 0.78 1e-3 -> 0.780
-dqqua343 quantize 0.78 1e-2 -> 0.78
-dqqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
-dqqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
-dqqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
-dqqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
-
-dqqua350 quantize -0.78 1e-5 -> -0.78000
-dqqua351 quantize -0.78 1e-4 -> -0.7800
-dqqua352 quantize -0.78 1e-3 -> -0.780
-dqqua353 quantize -0.78 1e-2 -> -0.78
-dqqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
-dqqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
-dqqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
-dqqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
-
-dqqua360 quantize 7.8 1e-5 -> 7.80000
-dqqua361 quantize 7.8 1e-4 -> 7.8000
-dqqua362 quantize 7.8 1e-3 -> 7.800
-dqqua363 quantize 7.8 1e-2 -> 7.80
-dqqua364 quantize 7.8 1e-1 -> 7.8
-dqqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
-dqqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
-dqqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
-dqqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
-
-dqqua370 quantize -7.8 1e-5 -> -7.80000
-dqqua371 quantize -7.8 1e-4 -> -7.8000
-dqqua372 quantize -7.8 1e-3 -> -7.800
-dqqua373 quantize -7.8 1e-2 -> -7.80
-dqqua374 quantize -7.8 1e-1 -> -7.8
-dqqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
-dqqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
-dqqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
-dqqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
-
--- some individuals
-dqqua380 quantize 1122334455667788991234567352364.506 1e-2 -> 1122334455667788991234567352364.51 Inexact Rounded
-dqqua381 quantize 11223344556677889912345673523645.06 1e-2 -> 11223344556677889912345673523645.06
-dqqua382 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-dqqua383 quantize 1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
-dqqua384 quantize -1122334455667788991234567352364.506 1e-2 -> -1122334455667788991234567352364.51 Inexact Rounded
-dqqua385 quantize -11223344556677889912345673523645.06 1e-2 -> -11223344556677889912345673523645.06
-dqqua386 quantize -112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-dqqua387 quantize -1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
-
-rounding: down
-dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
-rounding: half_up
-
--- and a few more from e-mail discussions
-dqqua391 quantize 11223344556677889912345678912.34567 1e-3 -> 11223344556677889912345678912.346 Inexact Rounded
-dqqua392 quantize 112233445566778899123456789123.4567 1e-3 -> 112233445566778899123456789123.457 Inexact Rounded
-dqqua393 quantize 1122334455667788991234567891234567. 1e-3 -> NaN Invalid_operation
-
--- some 9999 round-up cases
-dqqua400 quantize 9.999 1e-5 -> 9.99900
-dqqua401 quantize 9.999 1e-4 -> 9.9990
-dqqua402 quantize 9.999 1e-3 -> 9.999
-dqqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
-dqqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
-dqqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
-dqqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
-dqqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
-
-dqqua410 quantize 0.999 1e-5 -> 0.99900
-dqqua411 quantize 0.999 1e-4 -> 0.9990
-dqqua412 quantize 0.999 1e-3 -> 0.999
-dqqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
-dqqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
-dqqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
-dqqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua420 quantize 0.0999 1e-5 -> 0.09990
-dqqua421 quantize 0.0999 1e-4 -> 0.0999
-dqqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
-dqqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
-dqqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
-dqqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
-dqqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua430 quantize 0.00999 1e-5 -> 0.00999
-dqqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
-dqqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
-dqqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
-dqqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
-dqqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
-dqqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
-dqqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
-dqqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
-dqqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
-dqqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
-dqqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
-dqqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
-
-dqqua1001 quantize 0.000 0.001 -> 0.000
-dqqua1002 quantize 0.001 0.001 -> 0.001
-dqqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
-dqqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
-dqqua1005 quantize 0.501 0.001 -> 0.501
-dqqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
-dqqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
-dqqua1008 quantize 0.999 0.001 -> 0.999
-
-dqqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-dqqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-dqqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-dqqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-dqqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-dqqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
--- a potential double-round
-dqqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-dqqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
-dqqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
-dqqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
-dqqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
-dqqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
-dqqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
-dqqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
-dqqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
-dqqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
-
--- Zeros
-dqqua500 quantize 0 1e1 -> 0E+1
-dqqua501 quantize 0 1e0 -> 0
-dqqua502 quantize 0 1e-1 -> 0.0
-dqqua503 quantize 0.0 1e-1 -> 0.0
-dqqua504 quantize 0.0 1e0 -> 0
-dqqua505 quantize 0.0 1e+1 -> 0E+1
-dqqua506 quantize 0E+1 1e-1 -> 0.0
-dqqua507 quantize 0E+1 1e0 -> 0
-dqqua508 quantize 0E+1 1e+1 -> 0E+1
-dqqua509 quantize -0 1e1 -> -0E+1
-dqqua510 quantize -0 1e0 -> -0
-dqqua511 quantize -0 1e-1 -> -0.0
-dqqua512 quantize -0.0 1e-1 -> -0.0
-dqqua513 quantize -0.0 1e0 -> -0
-dqqua514 quantize -0.0 1e+1 -> -0E+1
-dqqua515 quantize -0E+1 1e-1 -> -0.0
-dqqua516 quantize -0E+1 1e0 -> -0
-dqqua517 quantize -0E+1 1e+1 -> -0E+1
--- #519 here once a problem
-dqqua518 quantize 0 0E-3 -> 0.000
-dqqua519 quantize 0 0E-33 -> 0E-33
-dqqua520 quantize 0.00000000000000000000000000000000 0E-33 -> 0E-33
-dqqua521 quantize 0.000000000000000000000000000000000 0E-33 -> 0E-33
-
--- Some non-zeros with lots of padding on the right
-dqqua523 quantize 1 0E-33 -> 1.000000000000000000000000000000000
-dqqua524 quantize 12 0E-32 -> 12.00000000000000000000000000000000
-dqqua525 quantize 123 0E-31 -> 123.0000000000000000000000000000000
-dqqua526 quantize 123 0E-32 -> NaN Invalid_operation
-dqqua527 quantize 123.4 0E-31 -> 123.4000000000000000000000000000000
-dqqua528 quantize 123.4 0E-32 -> NaN Invalid_operation
-
--- Suspicious RHS values
-dqqua530 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-dqqua531 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
-dqqua532 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
-dqqua533 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
--- next four are "won't fit" overflows
-dqqua536 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua537 quantize 123.456 1e-299 -> NaN Invalid_operation
-dqqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua539 quantize 123.456 1e-299 -> NaN Invalid_operation
-
-dqqua542 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
-dqqua543 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
-dqqua544 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
-dqqua547 quantize 0 1e-299 -> 0E-299
--- next two are "won't fit" overflows
-dqqua548 quantize 1.234 1e-299 -> NaN Invalid_operation
-dqqua549 quantize 1.234 1e-300 -> NaN Invalid_operation
--- [more below]
-
--- Specials
-dqqua580 quantize Inf -Inf -> Infinity
-dqqua581 quantize Inf 1e-299 -> NaN Invalid_operation
-dqqua582 quantize Inf 1e-1 -> NaN Invalid_operation
-dqqua583 quantize Inf 1e0 -> NaN Invalid_operation
-dqqua584 quantize Inf 1e1 -> NaN Invalid_operation
-dqqua585 quantize Inf 1e299 -> NaN Invalid_operation
-dqqua586 quantize Inf Inf -> Infinity
-dqqua587 quantize -1000 Inf -> NaN Invalid_operation
-dqqua588 quantize -Inf Inf -> -Infinity
-dqqua589 quantize -1 Inf -> NaN Invalid_operation
-dqqua590 quantize 0 Inf -> NaN Invalid_operation
-dqqua591 quantize 1 Inf -> NaN Invalid_operation
-dqqua592 quantize 1000 Inf -> NaN Invalid_operation
-dqqua593 quantize Inf Inf -> Infinity
-dqqua594 quantize Inf 1e-0 -> NaN Invalid_operation
-dqqua595 quantize -0 Inf -> NaN Invalid_operation
-
-dqqua600 quantize -Inf -Inf -> -Infinity
-dqqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
-dqqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
-dqqua603 quantize -Inf 1e0 -> NaN Invalid_operation
-dqqua604 quantize -Inf 1e1 -> NaN Invalid_operation
-dqqua605 quantize -Inf 1e299 -> NaN Invalid_operation
-dqqua606 quantize -Inf Inf -> -Infinity
-dqqua607 quantize -1000 Inf -> NaN Invalid_operation
-dqqua608 quantize -Inf -Inf -> -Infinity
-dqqua609 quantize -1 -Inf -> NaN Invalid_operation
-dqqua610 quantize 0 -Inf -> NaN Invalid_operation
-dqqua611 quantize 1 -Inf -> NaN Invalid_operation
-dqqua612 quantize 1000 -Inf -> NaN Invalid_operation
-dqqua613 quantize Inf -Inf -> Infinity
-dqqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
-dqqua615 quantize -0 -Inf -> NaN Invalid_operation
-
-dqqua621 quantize NaN -Inf -> NaN
-dqqua622 quantize NaN 1e-299 -> NaN
-dqqua623 quantize NaN 1e-1 -> NaN
-dqqua624 quantize NaN 1e0 -> NaN
-dqqua625 quantize NaN 1e1 -> NaN
-dqqua626 quantize NaN 1e299 -> NaN
-dqqua627 quantize NaN Inf -> NaN
-dqqua628 quantize NaN NaN -> NaN
-dqqua629 quantize -Inf NaN -> NaN
-dqqua630 quantize -1000 NaN -> NaN
-dqqua631 quantize -1 NaN -> NaN
-dqqua632 quantize 0 NaN -> NaN
-dqqua633 quantize 1 NaN -> NaN
-dqqua634 quantize 1000 NaN -> NaN
-dqqua635 quantize Inf NaN -> NaN
-dqqua636 quantize NaN 1e-0 -> NaN
-dqqua637 quantize -0 NaN -> NaN
-
-dqqua641 quantize sNaN -Inf -> NaN Invalid_operation
-dqqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
-dqqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
-dqqua644 quantize sNaN 1e0 -> NaN Invalid_operation
-dqqua645 quantize sNaN 1e1 -> NaN Invalid_operation
-dqqua646 quantize sNaN 1e299 -> NaN Invalid_operation
-dqqua647 quantize sNaN NaN -> NaN Invalid_operation
-dqqua648 quantize sNaN sNaN -> NaN Invalid_operation
-dqqua649 quantize NaN sNaN -> NaN Invalid_operation
-dqqua650 quantize -Inf sNaN -> NaN Invalid_operation
-dqqua651 quantize -1000 sNaN -> NaN Invalid_operation
-dqqua652 quantize -1 sNaN -> NaN Invalid_operation
-dqqua653 quantize 0 sNaN -> NaN Invalid_operation
-dqqua654 quantize 1 sNaN -> NaN Invalid_operation
-dqqua655 quantize 1000 sNaN -> NaN Invalid_operation
-dqqua656 quantize Inf sNaN -> NaN Invalid_operation
-dqqua657 quantize NaN sNaN -> NaN Invalid_operation
-dqqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
-dqqua659 quantize -0 sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqqua661 quantize NaN9 -Inf -> NaN9
-dqqua662 quantize NaN8 919 -> NaN8
-dqqua663 quantize NaN71 Inf -> NaN71
-dqqua664 quantize NaN6 NaN5 -> NaN6
-dqqua665 quantize -Inf NaN4 -> NaN4
-dqqua666 quantize -919 NaN31 -> NaN31
-dqqua667 quantize Inf NaN2 -> NaN2
-
-dqqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
-dqqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
-dqqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
-dqqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
-dqqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
-dqqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
-dqqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
-dqqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
-dqqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
-
-dqqua681 quantize -NaN9 -Inf -> -NaN9
-dqqua682 quantize -NaN8 919 -> -NaN8
-dqqua683 quantize -NaN71 Inf -> -NaN71
-dqqua684 quantize -NaN6 -NaN5 -> -NaN6
-dqqua685 quantize -Inf -NaN4 -> -NaN4
-dqqua686 quantize -919 -NaN31 -> -NaN31
-dqqua687 quantize Inf -NaN2 -> -NaN2
-
-dqqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
-dqqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
-dqqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
-dqqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
-dqqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
-dqqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
-dqqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
-dqqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
-dqqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
-
--- subnormals and underflow
-dqqua710 quantize 1.00E-6143 1e-6143 -> 1E-6143 Rounded
-dqqua711 quantize 0.1E-6143 2e-6144 -> 1E-6144 Subnormal
-dqqua712 quantize 0.10E-6143 3e-6144 -> 1E-6144 Subnormal Rounded
-dqqua713 quantize 0.100E-6143 4e-6144 -> 1E-6144 Subnormal Rounded
-dqqua714 quantize 0.01E-6143 5e-6145 -> 1E-6145 Subnormal
--- next is rounded to Emin
-dqqua715 quantize 0.999E-6143 1e-6143 -> 1E-6143 Inexact Rounded
-dqqua716 quantize 0.099E-6143 10e-6144 -> 1E-6144 Inexact Rounded Subnormal
-
-dqqua717 quantize 0.009E-6143 1e-6145 -> 1E-6145 Inexact Rounded Subnormal
-dqqua718 quantize 0.001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-dqqua719 quantize 0.0009E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-dqqua720 quantize 0.0001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
-
-dqqua730 quantize -1.00E-6143 1e-6143 -> -1E-6143 Rounded
-dqqua731 quantize -0.1E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua732 quantize -0.10E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua733 quantize -0.100E-6143 1e-6143 -> -0E-6143 Rounded Inexact
-dqqua734 quantize -0.01E-6143 1e-6143 -> -0E-6143 Inexact Rounded
--- next is rounded to Emin
-dqqua735 quantize -0.999E-6143 90e-6143 -> -1E-6143 Inexact Rounded
-dqqua736 quantize -0.099E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
-dqqua737 quantize -0.009E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
-dqqua738 quantize -0.001E-6143 -0e-6143 -> -0E-6143 Inexact Rounded
-dqqua739 quantize -0.0001E-6143 0e-6143 -> -0E-6143 Inexact Rounded
-
-dqqua740 quantize -1.00E-6143 1e-6144 -> -1.0E-6143 Rounded
-dqqua741 quantize -0.1E-6143 1e-6144 -> -1E-6144 Subnormal
-dqqua742 quantize -0.10E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
-dqqua743 quantize -0.100E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
-dqqua744 quantize -0.01E-6143 1e-6144 -> -0E-6144 Inexact Rounded
--- next is rounded to Emin
-dqqua745 quantize -0.999E-6143 1e-6144 -> -1.0E-6143 Inexact Rounded
-dqqua746 quantize -0.099E-6143 1e-6144 -> -1E-6144 Inexact Rounded Subnormal
-dqqua747 quantize -0.009E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-dqqua748 quantize -0.001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-dqqua749 quantize -0.0001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
-
-dqqua750 quantize -1.00E-6143 1e-6145 -> -1.00E-6143
-dqqua751 quantize -0.1E-6143 1e-6145 -> -1.0E-6144 Subnormal
-dqqua752 quantize -0.10E-6143 1e-6145 -> -1.0E-6144 Subnormal
-dqqua753 quantize -0.100E-6143 1e-6145 -> -1.0E-6144 Subnormal Rounded
-dqqua754 quantize -0.01E-6143 1e-6145 -> -1E-6145 Subnormal
--- next is rounded to Emin
-dqqua755 quantize -0.999E-6143 1e-6145 -> -1.00E-6143 Inexact Rounded
-dqqua756 quantize -0.099E-6143 1e-6145 -> -1.0E-6144 Inexact Rounded Subnormal
-dqqua757 quantize -0.009E-6143 1e-6145 -> -1E-6145 Inexact Rounded Subnormal
-dqqua758 quantize -0.001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
-dqqua759 quantize -0.0001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
-
-dqqua760 quantize -1.00E-6143 1e-6146 -> -1.000E-6143
-dqqua761 quantize -0.1E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua762 quantize -0.10E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua763 quantize -0.100E-6143 1e-6146 -> -1.00E-6144 Subnormal
-dqqua764 quantize -0.01E-6143 1e-6146 -> -1.0E-6145 Subnormal
-dqqua765 quantize -0.999E-6143 1e-6146 -> -9.99E-6144 Subnormal
-dqqua766 quantize -0.099E-6143 1e-6146 -> -9.9E-6145 Subnormal
-dqqua767 quantize -0.009E-6143 1e-6146 -> -9E-6146 Subnormal
-dqqua768 quantize -0.001E-6143 1e-6146 -> -1E-6146 Subnormal
-dqqua769 quantize -0.0001E-6143 1e-6146 -> -0E-6146 Inexact Rounded
-
--- More from Fung Lee
--- the next four would appear to be in error, but they are misleading (the
--- operands will be clamped to a lower exponent) and so are omitted
--- dqqua1021 quantize 8.666666666666000E+6144 1.000000000000000E+6144 -> 8.666666666666000000000000000000000E+6144 Clamped
--- dqqua1022 quantize -8.666666666666000E+6144 1.000000000000000E+6144 -> -8.666666666666000000000000000000000E+6144 Clamped
--- dqqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
--- dqqua1030 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-dqqua1040 quantize -2147483646 0 -> -2147483646
-dqqua1041 quantize -2147483647 0 -> -2147483647
-dqqua1042 quantize -2147483648 0 -> -2147483648
-dqqua1043 quantize -2147483649 0 -> -2147483649
-dqqua1044 quantize 2147483646 0 -> 2147483646
-dqqua1045 quantize 2147483647 0 -> 2147483647
-dqqua1046 quantize 2147483648 0 -> 2147483648
-dqqua1047 quantize 2147483649 0 -> 2147483649
-dqqua1048 quantize 4294967294 0 -> 4294967294
-dqqua1049 quantize 4294967295 0 -> 4294967295
-dqqua1050 quantize 4294967296 0 -> 4294967296
-dqqua1051 quantize 4294967297 0 -> 4294967297
-
--- Rounding swathe
-rounding: half_even
-dqqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_up
-dqqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: half_down
-dqqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-
-rounding: up
-dqqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-dqqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-dqqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-dqqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: down
-dqqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-dqqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-dqqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-dqqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-dqqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: ceiling
-dqqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
-dqqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
-dqqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
-dqqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
-dqqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
-dqqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
-dqqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
-dqqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
-dqqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
-dqqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
-
-rounding: floor
-dqqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
-dqqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
-dqqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
-dqqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
-dqqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
-dqqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
-dqqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
-dqqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
-dqqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
-
-rounding: 05up
-dqqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
-dqqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
-dqqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
-dqqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
-dqqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
-dqqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
-dqqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
-dqqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
-dqqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
-
-dqqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
-dqqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
-dqqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
-dqqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
-dqqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
-dqqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
-dqqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
-dqqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
-dqqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
-
-dqqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
-dqqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
-dqqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
-dqqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
-dqqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
-dqqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
-dqqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
-dqqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
-dqqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
-
-dqqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
-dqqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
-dqqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
-dqqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
-dqqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
-dqqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
-dqqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
-dqqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
-dqqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
-
-dqqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
-dqqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
-dqqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
-dqqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
-dqqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
-dqqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
-dqqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
-dqqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
-dqqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
-
-dqqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
-dqqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
-dqqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
-dqqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
-dqqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
-dqqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
-dqqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
-dqqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
-dqqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
-
--- Null tests
-dqqua998 quantize 10 # -> NaN Invalid_operation
-dqqua999 quantize # 1e10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqQuantize.decTest -- decQuad quantize operation --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Most of the tests here assume a "regular pattern", where the
+-- sign and coefficient are +1.
+-- 2004.03.15 Underflow for quantize is suppressed
+-- 2005.06.08 More extensive tests for 'does not fit'
+-- [Forked from quantize.decTest 2006.11.25]
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks
+dqqua001 quantize 0 1e0 -> 0
+dqqua002 quantize 1 1e0 -> 1
+dqqua003 quantize 0.1 1e+2 -> 0E+2 Inexact Rounded
+dqqua005 quantize 0.1 1e+1 -> 0E+1 Inexact Rounded
+dqqua006 quantize 0.1 1e0 -> 0 Inexact Rounded
+dqqua007 quantize 0.1 1e-1 -> 0.1
+dqqua008 quantize 0.1 1e-2 -> 0.10
+dqqua009 quantize 0.1 1e-3 -> 0.100
+dqqua010 quantize 0.9 1e+2 -> 0E+2 Inexact Rounded
+dqqua011 quantize 0.9 1e+1 -> 0E+1 Inexact Rounded
+dqqua012 quantize 0.9 1e+0 -> 1 Inexact Rounded
+dqqua013 quantize 0.9 1e-1 -> 0.9
+dqqua014 quantize 0.9 1e-2 -> 0.90
+dqqua015 quantize 0.9 1e-3 -> 0.900
+-- negatives
+dqqua021 quantize -0 1e0 -> -0
+dqqua022 quantize -1 1e0 -> -1
+dqqua023 quantize -0.1 1e+2 -> -0E+2 Inexact Rounded
+dqqua025 quantize -0.1 1e+1 -> -0E+1 Inexact Rounded
+dqqua026 quantize -0.1 1e0 -> -0 Inexact Rounded
+dqqua027 quantize -0.1 1e-1 -> -0.1
+dqqua028 quantize -0.1 1e-2 -> -0.10
+dqqua029 quantize -0.1 1e-3 -> -0.100
+dqqua030 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+dqqua031 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+dqqua032 quantize -0.9 1e+0 -> -1 Inexact Rounded
+dqqua033 quantize -0.9 1e-1 -> -0.9
+dqqua034 quantize -0.9 1e-2 -> -0.90
+dqqua035 quantize -0.9 1e-3 -> -0.900
+dqqua036 quantize -0.5 1e+2 -> -0E+2 Inexact Rounded
+dqqua037 quantize -0.5 1e+1 -> -0E+1 Inexact Rounded
+dqqua038 quantize -0.5 1e+0 -> -0 Inexact Rounded
+dqqua039 quantize -0.5 1e-1 -> -0.5
+dqqua040 quantize -0.5 1e-2 -> -0.50
+dqqua041 quantize -0.5 1e-3 -> -0.500
+dqqua042 quantize -0.9 1e+2 -> -0E+2 Inexact Rounded
+dqqua043 quantize -0.9 1e+1 -> -0E+1 Inexact Rounded
+dqqua044 quantize -0.9 1e+0 -> -1 Inexact Rounded
+dqqua045 quantize -0.9 1e-1 -> -0.9
+dqqua046 quantize -0.9 1e-2 -> -0.90
+dqqua047 quantize -0.9 1e-3 -> -0.900
+
+-- examples from Specification
+dqqua060 quantize 2.17 0.001 -> 2.170
+dqqua061 quantize 2.17 0.01 -> 2.17
+dqqua062 quantize 2.17 0.1 -> 2.2 Inexact Rounded
+dqqua063 quantize 2.17 1e+0 -> 2 Inexact Rounded
+dqqua064 quantize 2.17 1e+1 -> 0E+1 Inexact Rounded
+dqqua065 quantize -Inf Inf -> -Infinity
+dqqua066 quantize 2 Inf -> NaN Invalid_operation
+dqqua067 quantize -0.1 1 -> -0 Inexact Rounded
+dqqua068 quantize -0 1e+5 -> -0E+5
+dqqua069 quantize +123451234567899876543216789012345.6 1e-2 -> NaN Invalid_operation
+dqqua070 quantize -987651234567899876543214335236450.6 1e-2 -> NaN Invalid_operation
+dqqua071 quantize 217 1e-1 -> 217.0
+dqqua072 quantize 217 1e+0 -> 217
+dqqua073 quantize 217 1e+1 -> 2.2E+2 Inexact Rounded
+dqqua074 quantize 217 1e+2 -> 2E+2 Inexact Rounded
+
+-- general tests ..
+dqqua089 quantize 12 1e+4 -> 0E+4 Inexact Rounded
+dqqua090 quantize 12 1e+3 -> 0E+3 Inexact Rounded
+dqqua091 quantize 12 1e+2 -> 0E+2 Inexact Rounded
+dqqua092 quantize 12 1e+1 -> 1E+1 Inexact Rounded
+dqqua093 quantize 1.2345 1e-2 -> 1.23 Inexact Rounded
+dqqua094 quantize 1.2355 1e-2 -> 1.24 Inexact Rounded
+dqqua095 quantize 1.2345 1e-6 -> 1.234500
+dqqua096 quantize 9.9999 1e-2 -> 10.00 Inexact Rounded
+dqqua097 quantize 0.0001 1e-2 -> 0.00 Inexact Rounded
+dqqua098 quantize 0.001 1e-2 -> 0.00 Inexact Rounded
+dqqua099 quantize 0.009 1e-2 -> 0.01 Inexact Rounded
+dqqua100 quantize 92 1e+2 -> 1E+2 Inexact Rounded
+
+dqqua101 quantize -1 1e0 -> -1
+dqqua102 quantize -1 1e-1 -> -1.0
+dqqua103 quantize -1 1e-2 -> -1.00
+dqqua104 quantize 0 1e0 -> 0
+dqqua105 quantize 0 1e-1 -> 0.0
+dqqua106 quantize 0 1e-2 -> 0.00
+dqqua107 quantize 0.00 1e0 -> 0
+dqqua108 quantize 0 1e+1 -> 0E+1
+dqqua109 quantize 0 1e+2 -> 0E+2
+dqqua110 quantize +1 1e0 -> 1
+dqqua111 quantize +1 1e-1 -> 1.0
+dqqua112 quantize +1 1e-2 -> 1.00
+
+dqqua120 quantize 1.04 1e-3 -> 1.040
+dqqua121 quantize 1.04 1e-2 -> 1.04
+dqqua122 quantize 1.04 1e-1 -> 1.0 Inexact Rounded
+dqqua123 quantize 1.04 1e0 -> 1 Inexact Rounded
+dqqua124 quantize 1.05 1e-3 -> 1.050
+dqqua125 quantize 1.05 1e-2 -> 1.05
+dqqua126 quantize 1.05 1e-1 -> 1.0 Inexact Rounded
+dqqua131 quantize 1.05 1e0 -> 1 Inexact Rounded
+dqqua132 quantize 1.06 1e-3 -> 1.060
+dqqua133 quantize 1.06 1e-2 -> 1.06
+dqqua134 quantize 1.06 1e-1 -> 1.1 Inexact Rounded
+dqqua135 quantize 1.06 1e0 -> 1 Inexact Rounded
+
+dqqua140 quantize -10 1e-2 -> -10.00
+dqqua141 quantize +1 1e-2 -> 1.00
+dqqua142 quantize +10 1e-2 -> 10.00
+dqqua143 quantize 1E+37 1e-2 -> NaN Invalid_operation
+dqqua144 quantize 1E-37 1e-2 -> 0.00 Inexact Rounded
+dqqua145 quantize 1E-3 1e-2 -> 0.00 Inexact Rounded
+dqqua146 quantize 1E-2 1e-2 -> 0.01
+dqqua147 quantize 1E-1 1e-2 -> 0.10
+dqqua148 quantize 0E-37 1e-2 -> 0.00
+
+dqqua150 quantize 1.0600 1e-5 -> 1.06000
+dqqua151 quantize 1.0600 1e-4 -> 1.0600
+dqqua152 quantize 1.0600 1e-3 -> 1.060 Rounded
+dqqua153 quantize 1.0600 1e-2 -> 1.06 Rounded
+dqqua154 quantize 1.0600 1e-1 -> 1.1 Inexact Rounded
+dqqua155 quantize 1.0600 1e0 -> 1 Inexact Rounded
+
+-- a couple where rounding was different in base tests
+rounding: half_up
+dqqua157 quantize -0.5 1e+0 -> -1 Inexact Rounded
+dqqua158 quantize 1.05 1e-1 -> 1.1 Inexact Rounded
+dqqua159 quantize 1.06 1e0 -> 1 Inexact Rounded
+rounding: half_even
+
+-- base tests with non-1 coefficients
+dqqua161 quantize 0 -9e0 -> 0
+dqqua162 quantize 1 -7e0 -> 1
+dqqua163 quantize 0.1 -1e+2 -> 0E+2 Inexact Rounded
+dqqua165 quantize 0.1 0e+1 -> 0E+1 Inexact Rounded
+dqqua166 quantize 0.1 2e0 -> 0 Inexact Rounded
+dqqua167 quantize 0.1 3e-1 -> 0.1
+dqqua168 quantize 0.1 44e-2 -> 0.10
+dqqua169 quantize 0.1 555e-3 -> 0.100
+dqqua170 quantize 0.9 6666e+2 -> 0E+2 Inexact Rounded
+dqqua171 quantize 0.9 -777e+1 -> 0E+1 Inexact Rounded
+dqqua172 quantize 0.9 -88e+0 -> 1 Inexact Rounded
+dqqua173 quantize 0.9 -9e-1 -> 0.9
+dqqua174 quantize 0.9 0e-2 -> 0.90
+dqqua175 quantize 0.9 1.1e-3 -> 0.9000
+-- negatives
+dqqua181 quantize -0 1.1e0 -> -0.0
+dqqua182 quantize -1 -1e0 -> -1
+dqqua183 quantize -0.1 11e+2 -> -0E+2 Inexact Rounded
+dqqua185 quantize -0.1 111e+1 -> -0E+1 Inexact Rounded
+dqqua186 quantize -0.1 71e0 -> -0 Inexact Rounded
+dqqua187 quantize -0.1 -91e-1 -> -0.1
+dqqua188 quantize -0.1 -.1e-2 -> -0.100
+dqqua189 quantize -0.1 -1e-3 -> -0.100
+dqqua190 quantize -0.9 0e+2 -> -0E+2 Inexact Rounded
+dqqua191 quantize -0.9 -0e+1 -> -0E+1 Inexact Rounded
+dqqua192 quantize -0.9 -10e+0 -> -1 Inexact Rounded
+dqqua193 quantize -0.9 100e-1 -> -0.9
+dqqua194 quantize -0.9 999e-2 -> -0.90
+
+-- +ve exponents ..
+dqqua201 quantize -1 1e+0 -> -1
+dqqua202 quantize -1 1e+1 -> -0E+1 Inexact Rounded
+dqqua203 quantize -1 1e+2 -> -0E+2 Inexact Rounded
+dqqua204 quantize 0 1e+0 -> 0
+dqqua205 quantize 0 1e+1 -> 0E+1
+dqqua206 quantize 0 1e+2 -> 0E+2
+dqqua207 quantize +1 1e+0 -> 1
+dqqua208 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+dqqua209 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua220 quantize 1.04 1e+3 -> 0E+3 Inexact Rounded
+dqqua221 quantize 1.04 1e+2 -> 0E+2 Inexact Rounded
+dqqua222 quantize 1.04 1e+1 -> 0E+1 Inexact Rounded
+dqqua223 quantize 1.04 1e+0 -> 1 Inexact Rounded
+dqqua224 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+dqqua225 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+dqqua226 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+dqqua227 quantize 1.05 1e+0 -> 1 Inexact Rounded
+dqqua228 quantize 1.05 1e+3 -> 0E+3 Inexact Rounded
+dqqua229 quantize 1.05 1e+2 -> 0E+2 Inexact Rounded
+dqqua230 quantize 1.05 1e+1 -> 0E+1 Inexact Rounded
+dqqua231 quantize 1.05 1e+0 -> 1 Inexact Rounded
+dqqua232 quantize 1.06 1e+3 -> 0E+3 Inexact Rounded
+dqqua233 quantize 1.06 1e+2 -> 0E+2 Inexact Rounded
+dqqua234 quantize 1.06 1e+1 -> 0E+1 Inexact Rounded
+dqqua235 quantize 1.06 1e+0 -> 1 Inexact Rounded
+
+dqqua240 quantize -10 1e+1 -> -1E+1 Rounded
+dqqua241 quantize +1 1e+1 -> 0E+1 Inexact Rounded
+dqqua242 quantize +10 1e+1 -> 1E+1 Rounded
+dqqua243 quantize 1E+1 1e+1 -> 1E+1 -- underneath this is E+1
+dqqua244 quantize 1E+2 1e+1 -> 1.0E+2 -- underneath this is E+1
+dqqua245 quantize 1E+3 1e+1 -> 1.00E+3 -- underneath this is E+1
+dqqua246 quantize 1E+4 1e+1 -> 1.000E+4 -- underneath this is E+1
+dqqua247 quantize 1E+5 1e+1 -> 1.0000E+5 -- underneath this is E+1
+dqqua248 quantize 1E+6 1e+1 -> 1.00000E+6 -- underneath this is E+1
+dqqua249 quantize 1E+7 1e+1 -> 1.000000E+7 -- underneath this is E+1
+dqqua250 quantize 1E+8 1e+1 -> 1.0000000E+8 -- underneath this is E+1
+dqqua251 quantize 1E+9 1e+1 -> 1.00000000E+9 -- underneath this is E+1
+-- next one tries to add 9 zeros
+dqqua252 quantize 1E+37 1e+1 -> NaN Invalid_operation
+dqqua253 quantize 1E-37 1e+1 -> 0E+1 Inexact Rounded
+dqqua254 quantize 1E-2 1e+1 -> 0E+1 Inexact Rounded
+dqqua255 quantize 0E-37 1e+1 -> 0E+1
+dqqua256 quantize -0E-37 1e+1 -> -0E+1
+dqqua257 quantize -0E-1 1e+1 -> -0E+1
+dqqua258 quantize -0 1e+1 -> -0E+1
+dqqua259 quantize -0E+1 1e+1 -> -0E+1
+
+dqqua260 quantize -10 1e+2 -> -0E+2 Inexact Rounded
+dqqua261 quantize +1 1e+2 -> 0E+2 Inexact Rounded
+dqqua262 quantize +10 1e+2 -> 0E+2 Inexact Rounded
+dqqua263 quantize 1E+1 1e+2 -> 0E+2 Inexact Rounded
+dqqua264 quantize 1E+2 1e+2 -> 1E+2
+dqqua265 quantize 1E+3 1e+2 -> 1.0E+3
+dqqua266 quantize 1E+4 1e+2 -> 1.00E+4
+dqqua267 quantize 1E+5 1e+2 -> 1.000E+5
+dqqua268 quantize 1E+6 1e+2 -> 1.0000E+6
+dqqua269 quantize 1E+7 1e+2 -> 1.00000E+7
+dqqua270 quantize 1E+8 1e+2 -> 1.000000E+8
+dqqua271 quantize 1E+9 1e+2 -> 1.0000000E+9
+dqqua272 quantize 1E+10 1e+2 -> 1.00000000E+10
+dqqua273 quantize 1E-10 1e+2 -> 0E+2 Inexact Rounded
+dqqua274 quantize 1E-2 1e+2 -> 0E+2 Inexact Rounded
+dqqua275 quantize 0E-10 1e+2 -> 0E+2
+
+dqqua280 quantize -10 1e+3 -> -0E+3 Inexact Rounded
+dqqua281 quantize +1 1e+3 -> 0E+3 Inexact Rounded
+dqqua282 quantize +10 1e+3 -> 0E+3 Inexact Rounded
+dqqua283 quantize 1E+1 1e+3 -> 0E+3 Inexact Rounded
+dqqua284 quantize 1E+2 1e+3 -> 0E+3 Inexact Rounded
+dqqua285 quantize 1E+3 1e+3 -> 1E+3
+dqqua286 quantize 1E+4 1e+3 -> 1.0E+4
+dqqua287 quantize 1E+5 1e+3 -> 1.00E+5
+dqqua288 quantize 1E+6 1e+3 -> 1.000E+6
+dqqua289 quantize 1E+7 1e+3 -> 1.0000E+7
+dqqua290 quantize 1E+8 1e+3 -> 1.00000E+8
+dqqua291 quantize 1E+9 1e+3 -> 1.000000E+9
+dqqua292 quantize 1E+10 1e+3 -> 1.0000000E+10
+dqqua293 quantize 1E-10 1e+3 -> 0E+3 Inexact Rounded
+dqqua294 quantize 1E-2 1e+3 -> 0E+3 Inexact Rounded
+dqqua295 quantize 0E-10 1e+3 -> 0E+3
+
+-- round up from below [sign wrong in JIT compiler once]
+dqqua300 quantize 0.0078 1e-5 -> 0.00780
+dqqua301 quantize 0.0078 1e-4 -> 0.0078
+dqqua302 quantize 0.0078 1e-3 -> 0.008 Inexact Rounded
+dqqua303 quantize 0.0078 1e-2 -> 0.01 Inexact Rounded
+dqqua304 quantize 0.0078 1e-1 -> 0.0 Inexact Rounded
+dqqua305 quantize 0.0078 1e0 -> 0 Inexact Rounded
+dqqua306 quantize 0.0078 1e+1 -> 0E+1 Inexact Rounded
+dqqua307 quantize 0.0078 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua310 quantize -0.0078 1e-5 -> -0.00780
+dqqua311 quantize -0.0078 1e-4 -> -0.0078
+dqqua312 quantize -0.0078 1e-3 -> -0.008 Inexact Rounded
+dqqua313 quantize -0.0078 1e-2 -> -0.01 Inexact Rounded
+dqqua314 quantize -0.0078 1e-1 -> -0.0 Inexact Rounded
+dqqua315 quantize -0.0078 1e0 -> -0 Inexact Rounded
+dqqua316 quantize -0.0078 1e+1 -> -0E+1 Inexact Rounded
+dqqua317 quantize -0.0078 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua320 quantize 0.078 1e-5 -> 0.07800
+dqqua321 quantize 0.078 1e-4 -> 0.0780
+dqqua322 quantize 0.078 1e-3 -> 0.078
+dqqua323 quantize 0.078 1e-2 -> 0.08 Inexact Rounded
+dqqua324 quantize 0.078 1e-1 -> 0.1 Inexact Rounded
+dqqua325 quantize 0.078 1e0 -> 0 Inexact Rounded
+dqqua326 quantize 0.078 1e+1 -> 0E+1 Inexact Rounded
+dqqua327 quantize 0.078 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua330 quantize -0.078 1e-5 -> -0.07800
+dqqua331 quantize -0.078 1e-4 -> -0.0780
+dqqua332 quantize -0.078 1e-3 -> -0.078
+dqqua333 quantize -0.078 1e-2 -> -0.08 Inexact Rounded
+dqqua334 quantize -0.078 1e-1 -> -0.1 Inexact Rounded
+dqqua335 quantize -0.078 1e0 -> -0 Inexact Rounded
+dqqua336 quantize -0.078 1e+1 -> -0E+1 Inexact Rounded
+dqqua337 quantize -0.078 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua340 quantize 0.78 1e-5 -> 0.78000
+dqqua341 quantize 0.78 1e-4 -> 0.7800
+dqqua342 quantize 0.78 1e-3 -> 0.780
+dqqua343 quantize 0.78 1e-2 -> 0.78
+dqqua344 quantize 0.78 1e-1 -> 0.8 Inexact Rounded
+dqqua345 quantize 0.78 1e0 -> 1 Inexact Rounded
+dqqua346 quantize 0.78 1e+1 -> 0E+1 Inexact Rounded
+dqqua347 quantize 0.78 1e+2 -> 0E+2 Inexact Rounded
+
+dqqua350 quantize -0.78 1e-5 -> -0.78000
+dqqua351 quantize -0.78 1e-4 -> -0.7800
+dqqua352 quantize -0.78 1e-3 -> -0.780
+dqqua353 quantize -0.78 1e-2 -> -0.78
+dqqua354 quantize -0.78 1e-1 -> -0.8 Inexact Rounded
+dqqua355 quantize -0.78 1e0 -> -1 Inexact Rounded
+dqqua356 quantize -0.78 1e+1 -> -0E+1 Inexact Rounded
+dqqua357 quantize -0.78 1e+2 -> -0E+2 Inexact Rounded
+
+dqqua360 quantize 7.8 1e-5 -> 7.80000
+dqqua361 quantize 7.8 1e-4 -> 7.8000
+dqqua362 quantize 7.8 1e-3 -> 7.800
+dqqua363 quantize 7.8 1e-2 -> 7.80
+dqqua364 quantize 7.8 1e-1 -> 7.8
+dqqua365 quantize 7.8 1e0 -> 8 Inexact Rounded
+dqqua366 quantize 7.8 1e+1 -> 1E+1 Inexact Rounded
+dqqua367 quantize 7.8 1e+2 -> 0E+2 Inexact Rounded
+dqqua368 quantize 7.8 1e+3 -> 0E+3 Inexact Rounded
+
+dqqua370 quantize -7.8 1e-5 -> -7.80000
+dqqua371 quantize -7.8 1e-4 -> -7.8000
+dqqua372 quantize -7.8 1e-3 -> -7.800
+dqqua373 quantize -7.8 1e-2 -> -7.80
+dqqua374 quantize -7.8 1e-1 -> -7.8
+dqqua375 quantize -7.8 1e0 -> -8 Inexact Rounded
+dqqua376 quantize -7.8 1e+1 -> -1E+1 Inexact Rounded
+dqqua377 quantize -7.8 1e+2 -> -0E+2 Inexact Rounded
+dqqua378 quantize -7.8 1e+3 -> -0E+3 Inexact Rounded
+
+-- some individuals
+dqqua380 quantize 1122334455667788991234567352364.506 1e-2 -> 1122334455667788991234567352364.51 Inexact Rounded
+dqqua381 quantize 11223344556677889912345673523645.06 1e-2 -> 11223344556677889912345673523645.06
+dqqua382 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+dqqua383 quantize 1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
+dqqua384 quantize -1122334455667788991234567352364.506 1e-2 -> -1122334455667788991234567352364.51 Inexact Rounded
+dqqua385 quantize -11223344556677889912345673523645.06 1e-2 -> -11223344556677889912345673523645.06
+dqqua386 quantize -112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+dqqua387 quantize -1122334455667788991234567352364506 1e-2 -> NaN Invalid_operation
+
+rounding: down
+dqqua389 quantize 112233445566778899123456735236450.6 1e-2 -> NaN Invalid_operation
+rounding: half_up
+
+-- and a few more from e-mail discussions
+dqqua391 quantize 11223344556677889912345678912.34567 1e-3 -> 11223344556677889912345678912.346 Inexact Rounded
+dqqua392 quantize 112233445566778899123456789123.4567 1e-3 -> 112233445566778899123456789123.457 Inexact Rounded
+dqqua393 quantize 1122334455667788991234567891234567. 1e-3 -> NaN Invalid_operation
+
+-- some 9999 round-up cases
+dqqua400 quantize 9.999 1e-5 -> 9.99900
+dqqua401 quantize 9.999 1e-4 -> 9.9990
+dqqua402 quantize 9.999 1e-3 -> 9.999
+dqqua403 quantize 9.999 1e-2 -> 10.00 Inexact Rounded
+dqqua404 quantize 9.999 1e-1 -> 10.0 Inexact Rounded
+dqqua405 quantize 9.999 1e0 -> 10 Inexact Rounded
+dqqua406 quantize 9.999 1e1 -> 1E+1 Inexact Rounded
+dqqua407 quantize 9.999 1e2 -> 0E+2 Inexact Rounded
+
+dqqua410 quantize 0.999 1e-5 -> 0.99900
+dqqua411 quantize 0.999 1e-4 -> 0.9990
+dqqua412 quantize 0.999 1e-3 -> 0.999
+dqqua413 quantize 0.999 1e-2 -> 1.00 Inexact Rounded
+dqqua414 quantize 0.999 1e-1 -> 1.0 Inexact Rounded
+dqqua415 quantize 0.999 1e0 -> 1 Inexact Rounded
+dqqua416 quantize 0.999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua420 quantize 0.0999 1e-5 -> 0.09990
+dqqua421 quantize 0.0999 1e-4 -> 0.0999
+dqqua422 quantize 0.0999 1e-3 -> 0.100 Inexact Rounded
+dqqua423 quantize 0.0999 1e-2 -> 0.10 Inexact Rounded
+dqqua424 quantize 0.0999 1e-1 -> 0.1 Inexact Rounded
+dqqua425 quantize 0.0999 1e0 -> 0 Inexact Rounded
+dqqua426 quantize 0.0999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua430 quantize 0.00999 1e-5 -> 0.00999
+dqqua431 quantize 0.00999 1e-4 -> 0.0100 Inexact Rounded
+dqqua432 quantize 0.00999 1e-3 -> 0.010 Inexact Rounded
+dqqua433 quantize 0.00999 1e-2 -> 0.01 Inexact Rounded
+dqqua434 quantize 0.00999 1e-1 -> 0.0 Inexact Rounded
+dqqua435 quantize 0.00999 1e0 -> 0 Inexact Rounded
+dqqua436 quantize 0.00999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua440 quantize 0.000999 1e-5 -> 0.00100 Inexact Rounded
+dqqua441 quantize 0.000999 1e-4 -> 0.0010 Inexact Rounded
+dqqua442 quantize 0.000999 1e-3 -> 0.001 Inexact Rounded
+dqqua443 quantize 0.000999 1e-2 -> 0.00 Inexact Rounded
+dqqua444 quantize 0.000999 1e-1 -> 0.0 Inexact Rounded
+dqqua445 quantize 0.000999 1e0 -> 0 Inexact Rounded
+dqqua446 quantize 0.000999 1e1 -> 0E+1 Inexact Rounded
+
+dqqua1001 quantize 0.000 0.001 -> 0.000
+dqqua1002 quantize 0.001 0.001 -> 0.001
+dqqua1003 quantize 0.0012 0.001 -> 0.001 Inexact Rounded
+dqqua1004 quantize 0.0018 0.001 -> 0.002 Inexact Rounded
+dqqua1005 quantize 0.501 0.001 -> 0.501
+dqqua1006 quantize 0.5012 0.001 -> 0.501 Inexact Rounded
+dqqua1007 quantize 0.5018 0.001 -> 0.502 Inexact Rounded
+dqqua1008 quantize 0.999 0.001 -> 0.999
+
+dqqua481 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+dqqua482 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+dqqua483 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+dqqua484 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+dqqua485 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+dqqua486 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+-- a potential double-round
+dqqua487 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+dqqua488 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+dqqua491 quantize 12345678000 1e+3 -> 1.2345678E+10 Rounded
+dqqua492 quantize 1234567800 1e+1 -> 1.23456780E+9 Rounded
+dqqua493 quantize 1234567890 1e+1 -> 1.23456789E+9 Rounded
+dqqua494 quantize 1234567891 1e+1 -> 1.23456789E+9 Inexact Rounded
+dqqua495 quantize 12345678901 1e+2 -> 1.23456789E+10 Inexact Rounded
+dqqua496 quantize 1234567896 1e+1 -> 1.23456790E+9 Inexact Rounded
+dqqua497 quantize 1234.987643 1e-4 -> 1234.9876 Inexact Rounded
+dqqua498 quantize 1234.987647 1e-4 -> 1234.9876 Inexact Rounded
+
+-- Zeros
+dqqua500 quantize 0 1e1 -> 0E+1
+dqqua501 quantize 0 1e0 -> 0
+dqqua502 quantize 0 1e-1 -> 0.0
+dqqua503 quantize 0.0 1e-1 -> 0.0
+dqqua504 quantize 0.0 1e0 -> 0
+dqqua505 quantize 0.0 1e+1 -> 0E+1
+dqqua506 quantize 0E+1 1e-1 -> 0.0
+dqqua507 quantize 0E+1 1e0 -> 0
+dqqua508 quantize 0E+1 1e+1 -> 0E+1
+dqqua509 quantize -0 1e1 -> -0E+1
+dqqua510 quantize -0 1e0 -> -0
+dqqua511 quantize -0 1e-1 -> -0.0
+dqqua512 quantize -0.0 1e-1 -> -0.0
+dqqua513 quantize -0.0 1e0 -> -0
+dqqua514 quantize -0.0 1e+1 -> -0E+1
+dqqua515 quantize -0E+1 1e-1 -> -0.0
+dqqua516 quantize -0E+1 1e0 -> -0
+dqqua517 quantize -0E+1 1e+1 -> -0E+1
+-- #519 here once a problem
+dqqua518 quantize 0 0E-3 -> 0.000
+dqqua519 quantize 0 0E-33 -> 0E-33
+dqqua520 quantize 0.00000000000000000000000000000000 0E-33 -> 0E-33
+dqqua521 quantize 0.000000000000000000000000000000000 0E-33 -> 0E-33
+
+-- Some non-zeros with lots of padding on the right
+dqqua523 quantize 1 0E-33 -> 1.000000000000000000000000000000000
+dqqua524 quantize 12 0E-32 -> 12.00000000000000000000000000000000
+dqqua525 quantize 123 0E-31 -> 123.0000000000000000000000000000000
+dqqua526 quantize 123 0E-32 -> NaN Invalid_operation
+dqqua527 quantize 123.4 0E-31 -> 123.4000000000000000000000000000000
+dqqua528 quantize 123.4 0E-32 -> NaN Invalid_operation
+
+-- Suspicious RHS values
+dqqua530 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+dqqua531 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+dqqua532 quantize 1.234 1e359 -> 0E+359 Inexact Rounded
+dqqua533 quantize 123.456 1e359 -> 0E+359 Inexact Rounded
+-- next four are "won't fit" overflows
+dqqua536 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua537 quantize 123.456 1e-299 -> NaN Invalid_operation
+dqqua538 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua539 quantize 123.456 1e-299 -> NaN Invalid_operation
+
+dqqua542 quantize 1.234E+299 1e299 -> 1E+299 Inexact Rounded
+dqqua543 quantize 1.234E+298 1e299 -> 0E+299 Inexact Rounded
+dqqua544 quantize 1.234 1e299 -> 0E+299 Inexact Rounded
+dqqua547 quantize 0 1e-299 -> 0E-299
+-- next two are "won't fit" overflows
+dqqua548 quantize 1.234 1e-299 -> NaN Invalid_operation
+dqqua549 quantize 1.234 1e-300 -> NaN Invalid_operation
+-- [more below]
+
+-- Specials
+dqqua580 quantize Inf -Inf -> Infinity
+dqqua581 quantize Inf 1e-299 -> NaN Invalid_operation
+dqqua582 quantize Inf 1e-1 -> NaN Invalid_operation
+dqqua583 quantize Inf 1e0 -> NaN Invalid_operation
+dqqua584 quantize Inf 1e1 -> NaN Invalid_operation
+dqqua585 quantize Inf 1e299 -> NaN Invalid_operation
+dqqua586 quantize Inf Inf -> Infinity
+dqqua587 quantize -1000 Inf -> NaN Invalid_operation
+dqqua588 quantize -Inf Inf -> -Infinity
+dqqua589 quantize -1 Inf -> NaN Invalid_operation
+dqqua590 quantize 0 Inf -> NaN Invalid_operation
+dqqua591 quantize 1 Inf -> NaN Invalid_operation
+dqqua592 quantize 1000 Inf -> NaN Invalid_operation
+dqqua593 quantize Inf Inf -> Infinity
+dqqua594 quantize Inf 1e-0 -> NaN Invalid_operation
+dqqua595 quantize -0 Inf -> NaN Invalid_operation
+
+dqqua600 quantize -Inf -Inf -> -Infinity
+dqqua601 quantize -Inf 1e-299 -> NaN Invalid_operation
+dqqua602 quantize -Inf 1e-1 -> NaN Invalid_operation
+dqqua603 quantize -Inf 1e0 -> NaN Invalid_operation
+dqqua604 quantize -Inf 1e1 -> NaN Invalid_operation
+dqqua605 quantize -Inf 1e299 -> NaN Invalid_operation
+dqqua606 quantize -Inf Inf -> -Infinity
+dqqua607 quantize -1000 Inf -> NaN Invalid_operation
+dqqua608 quantize -Inf -Inf -> -Infinity
+dqqua609 quantize -1 -Inf -> NaN Invalid_operation
+dqqua610 quantize 0 -Inf -> NaN Invalid_operation
+dqqua611 quantize 1 -Inf -> NaN Invalid_operation
+dqqua612 quantize 1000 -Inf -> NaN Invalid_operation
+dqqua613 quantize Inf -Inf -> Infinity
+dqqua614 quantize -Inf 1e-0 -> NaN Invalid_operation
+dqqua615 quantize -0 -Inf -> NaN Invalid_operation
+
+dqqua621 quantize NaN -Inf -> NaN
+dqqua622 quantize NaN 1e-299 -> NaN
+dqqua623 quantize NaN 1e-1 -> NaN
+dqqua624 quantize NaN 1e0 -> NaN
+dqqua625 quantize NaN 1e1 -> NaN
+dqqua626 quantize NaN 1e299 -> NaN
+dqqua627 quantize NaN Inf -> NaN
+dqqua628 quantize NaN NaN -> NaN
+dqqua629 quantize -Inf NaN -> NaN
+dqqua630 quantize -1000 NaN -> NaN
+dqqua631 quantize -1 NaN -> NaN
+dqqua632 quantize 0 NaN -> NaN
+dqqua633 quantize 1 NaN -> NaN
+dqqua634 quantize 1000 NaN -> NaN
+dqqua635 quantize Inf NaN -> NaN
+dqqua636 quantize NaN 1e-0 -> NaN
+dqqua637 quantize -0 NaN -> NaN
+
+dqqua641 quantize sNaN -Inf -> NaN Invalid_operation
+dqqua642 quantize sNaN 1e-299 -> NaN Invalid_operation
+dqqua643 quantize sNaN 1e-1 -> NaN Invalid_operation
+dqqua644 quantize sNaN 1e0 -> NaN Invalid_operation
+dqqua645 quantize sNaN 1e1 -> NaN Invalid_operation
+dqqua646 quantize sNaN 1e299 -> NaN Invalid_operation
+dqqua647 quantize sNaN NaN -> NaN Invalid_operation
+dqqua648 quantize sNaN sNaN -> NaN Invalid_operation
+dqqua649 quantize NaN sNaN -> NaN Invalid_operation
+dqqua650 quantize -Inf sNaN -> NaN Invalid_operation
+dqqua651 quantize -1000 sNaN -> NaN Invalid_operation
+dqqua652 quantize -1 sNaN -> NaN Invalid_operation
+dqqua653 quantize 0 sNaN -> NaN Invalid_operation
+dqqua654 quantize 1 sNaN -> NaN Invalid_operation
+dqqua655 quantize 1000 sNaN -> NaN Invalid_operation
+dqqua656 quantize Inf sNaN -> NaN Invalid_operation
+dqqua657 quantize NaN sNaN -> NaN Invalid_operation
+dqqua658 quantize sNaN 1e-0 -> NaN Invalid_operation
+dqqua659 quantize -0 sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqqua661 quantize NaN9 -Inf -> NaN9
+dqqua662 quantize NaN8 919 -> NaN8
+dqqua663 quantize NaN71 Inf -> NaN71
+dqqua664 quantize NaN6 NaN5 -> NaN6
+dqqua665 quantize -Inf NaN4 -> NaN4
+dqqua666 quantize -919 NaN31 -> NaN31
+dqqua667 quantize Inf NaN2 -> NaN2
+
+dqqua671 quantize sNaN99 -Inf -> NaN99 Invalid_operation
+dqqua672 quantize sNaN98 -11 -> NaN98 Invalid_operation
+dqqua673 quantize sNaN97 NaN -> NaN97 Invalid_operation
+dqqua674 quantize sNaN16 sNaN94 -> NaN16 Invalid_operation
+dqqua675 quantize NaN95 sNaN93 -> NaN93 Invalid_operation
+dqqua676 quantize -Inf sNaN92 -> NaN92 Invalid_operation
+dqqua677 quantize 088 sNaN91 -> NaN91 Invalid_operation
+dqqua678 quantize Inf sNaN90 -> NaN90 Invalid_operation
+dqqua679 quantize NaN sNaN88 -> NaN88 Invalid_operation
+
+dqqua681 quantize -NaN9 -Inf -> -NaN9
+dqqua682 quantize -NaN8 919 -> -NaN8
+dqqua683 quantize -NaN71 Inf -> -NaN71
+dqqua684 quantize -NaN6 -NaN5 -> -NaN6
+dqqua685 quantize -Inf -NaN4 -> -NaN4
+dqqua686 quantize -919 -NaN31 -> -NaN31
+dqqua687 quantize Inf -NaN2 -> -NaN2
+
+dqqua691 quantize -sNaN99 -Inf -> -NaN99 Invalid_operation
+dqqua692 quantize -sNaN98 -11 -> -NaN98 Invalid_operation
+dqqua693 quantize -sNaN97 NaN -> -NaN97 Invalid_operation
+dqqua694 quantize -sNaN16 sNaN94 -> -NaN16 Invalid_operation
+dqqua695 quantize -NaN95 -sNaN93 -> -NaN93 Invalid_operation
+dqqua696 quantize -Inf -sNaN92 -> -NaN92 Invalid_operation
+dqqua697 quantize 088 -sNaN91 -> -NaN91 Invalid_operation
+dqqua698 quantize Inf -sNaN90 -> -NaN90 Invalid_operation
+dqqua699 quantize NaN -sNaN88 -> -NaN88 Invalid_operation
+
+-- subnormals and underflow
+dqqua710 quantize 1.00E-6143 1e-6143 -> 1E-6143 Rounded
+dqqua711 quantize 0.1E-6143 2e-6144 -> 1E-6144 Subnormal
+dqqua712 quantize 0.10E-6143 3e-6144 -> 1E-6144 Subnormal Rounded
+dqqua713 quantize 0.100E-6143 4e-6144 -> 1E-6144 Subnormal Rounded
+dqqua714 quantize 0.01E-6143 5e-6145 -> 1E-6145 Subnormal
+-- next is rounded to Emin
+dqqua715 quantize 0.999E-6143 1e-6143 -> 1E-6143 Inexact Rounded
+dqqua716 quantize 0.099E-6143 10e-6144 -> 1E-6144 Inexact Rounded Subnormal
+
+dqqua717 quantize 0.009E-6143 1e-6145 -> 1E-6145 Inexact Rounded Subnormal
+dqqua718 quantize 0.001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+dqqua719 quantize 0.0009E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+dqqua720 quantize 0.0001E-6143 1e-6145 -> 0E-6145 Inexact Rounded
+
+dqqua730 quantize -1.00E-6143 1e-6143 -> -1E-6143 Rounded
+dqqua731 quantize -0.1E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua732 quantize -0.10E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua733 quantize -0.100E-6143 1e-6143 -> -0E-6143 Rounded Inexact
+dqqua734 quantize -0.01E-6143 1e-6143 -> -0E-6143 Inexact Rounded
+-- next is rounded to Emin
+dqqua735 quantize -0.999E-6143 90e-6143 -> -1E-6143 Inexact Rounded
+dqqua736 quantize -0.099E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
+dqqua737 quantize -0.009E-6143 -1e-6143 -> -0E-6143 Inexact Rounded
+dqqua738 quantize -0.001E-6143 -0e-6143 -> -0E-6143 Inexact Rounded
+dqqua739 quantize -0.0001E-6143 0e-6143 -> -0E-6143 Inexact Rounded
+
+dqqua740 quantize -1.00E-6143 1e-6144 -> -1.0E-6143 Rounded
+dqqua741 quantize -0.1E-6143 1e-6144 -> -1E-6144 Subnormal
+dqqua742 quantize -0.10E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
+dqqua743 quantize -0.100E-6143 1e-6144 -> -1E-6144 Subnormal Rounded
+dqqua744 quantize -0.01E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+-- next is rounded to Emin
+dqqua745 quantize -0.999E-6143 1e-6144 -> -1.0E-6143 Inexact Rounded
+dqqua746 quantize -0.099E-6143 1e-6144 -> -1E-6144 Inexact Rounded Subnormal
+dqqua747 quantize -0.009E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+dqqua748 quantize -0.001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+dqqua749 quantize -0.0001E-6143 1e-6144 -> -0E-6144 Inexact Rounded
+
+dqqua750 quantize -1.00E-6143 1e-6145 -> -1.00E-6143
+dqqua751 quantize -0.1E-6143 1e-6145 -> -1.0E-6144 Subnormal
+dqqua752 quantize -0.10E-6143 1e-6145 -> -1.0E-6144 Subnormal
+dqqua753 quantize -0.100E-6143 1e-6145 -> -1.0E-6144 Subnormal Rounded
+dqqua754 quantize -0.01E-6143 1e-6145 -> -1E-6145 Subnormal
+-- next is rounded to Emin
+dqqua755 quantize -0.999E-6143 1e-6145 -> -1.00E-6143 Inexact Rounded
+dqqua756 quantize -0.099E-6143 1e-6145 -> -1.0E-6144 Inexact Rounded Subnormal
+dqqua757 quantize -0.009E-6143 1e-6145 -> -1E-6145 Inexact Rounded Subnormal
+dqqua758 quantize -0.001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
+dqqua759 quantize -0.0001E-6143 1e-6145 -> -0E-6145 Inexact Rounded
+
+dqqua760 quantize -1.00E-6143 1e-6146 -> -1.000E-6143
+dqqua761 quantize -0.1E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua762 quantize -0.10E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua763 quantize -0.100E-6143 1e-6146 -> -1.00E-6144 Subnormal
+dqqua764 quantize -0.01E-6143 1e-6146 -> -1.0E-6145 Subnormal
+dqqua765 quantize -0.999E-6143 1e-6146 -> -9.99E-6144 Subnormal
+dqqua766 quantize -0.099E-6143 1e-6146 -> -9.9E-6145 Subnormal
+dqqua767 quantize -0.009E-6143 1e-6146 -> -9E-6146 Subnormal
+dqqua768 quantize -0.001E-6143 1e-6146 -> -1E-6146 Subnormal
+dqqua769 quantize -0.0001E-6143 1e-6146 -> -0E-6146 Inexact Rounded
+
+-- More from Fung Lee
+-- the next four would appear to be in error, but they are misleading (the
+-- operands will be clamped to a lower exponent) and so are omitted
+-- dqqua1021 quantize 8.666666666666000E+6144 1.000000000000000E+6144 -> 8.666666666666000000000000000000000E+6144 Clamped
+-- dqqua1022 quantize -8.666666666666000E+6144 1.000000000000000E+6144 -> -8.666666666666000000000000000000000E+6144 Clamped
+-- dqqua1027 quantize 8.666666666666000E+323 1E+31 -> NaN Invalid_operation
+-- dqqua1030 quantize 8.66666666E+3 1E+3 -> 9E+3 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+dqqua1040 quantize -2147483646 0 -> -2147483646
+dqqua1041 quantize -2147483647 0 -> -2147483647
+dqqua1042 quantize -2147483648 0 -> -2147483648
+dqqua1043 quantize -2147483649 0 -> -2147483649
+dqqua1044 quantize 2147483646 0 -> 2147483646
+dqqua1045 quantize 2147483647 0 -> 2147483647
+dqqua1046 quantize 2147483648 0 -> 2147483648
+dqqua1047 quantize 2147483649 0 -> 2147483649
+dqqua1048 quantize 4294967294 0 -> 4294967294
+dqqua1049 quantize 4294967295 0 -> 4294967295
+dqqua1050 quantize 4294967296 0 -> 4294967296
+dqqua1051 quantize 4294967297 0 -> 4294967297
+
+-- Rounding swathe
+rounding: half_even
+dqqua1100 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1101 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1102 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1103 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1104 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1105 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1106 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1107 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1108 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1109 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_up
+dqqua1200 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1201 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1202 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1203 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1204 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1205 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1206 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1207 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1208 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1209 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: half_down
+dqqua1300 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1301 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1302 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1303 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1304 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1305 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1306 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1307 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1308 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1309 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+
+rounding: up
+dqqua1400 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1401 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+dqqua1402 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+dqqua1403 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1404 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1405 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1406 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1407 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1408 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1409 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+dqqua1411 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: down
+dqqua1500 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1501 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1502 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1503 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1504 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+dqqua1505 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1506 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua1507 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+dqqua1508 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+dqqua1509 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+dqqua1511 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: ceiling
+dqqua1600 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1601 quantize 1.2301 1.00 -> 1.24 Inexact Rounded
+dqqua1602 quantize 1.2310 1.00 -> 1.24 Inexact Rounded
+dqqua1603 quantize 1.2350 1.00 -> 1.24 Inexact Rounded
+dqqua1604 quantize 1.2351 1.00 -> 1.24 Inexact Rounded
+dqqua1605 quantize 1.2450 1.00 -> 1.25 Inexact Rounded
+dqqua1606 quantize 1.2451 1.00 -> 1.25 Inexact Rounded
+dqqua1607 quantize 1.2360 1.00 -> 1.24 Inexact Rounded
+dqqua1608 quantize 1.2370 1.00 -> 1.24 Inexact Rounded
+dqqua1609 quantize 1.2399 1.00 -> 1.24 Inexact Rounded
+dqqua1611 quantize -1.2399 1.00 -> -1.23 Inexact Rounded
+
+rounding: floor
+dqqua1700 quantize 1.2300 1.00 -> 1.23 Rounded
+dqqua1701 quantize 1.2301 1.00 -> 1.23 Inexact Rounded
+dqqua1702 quantize 1.2310 1.00 -> 1.23 Inexact Rounded
+dqqua1703 quantize 1.2350 1.00 -> 1.23 Inexact Rounded
+dqqua1704 quantize 1.2351 1.00 -> 1.23 Inexact Rounded
+dqqua1705 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua1706 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua1707 quantize 1.2360 1.00 -> 1.23 Inexact Rounded
+dqqua1708 quantize 1.2370 1.00 -> 1.23 Inexact Rounded
+dqqua1709 quantize 1.2399 1.00 -> 1.23 Inexact Rounded
+dqqua1711 quantize -1.2399 1.00 -> -1.24 Inexact Rounded
+
+rounding: 05up
+dqqua1800 quantize 1.2000 1.00 -> 1.20 Rounded
+dqqua1801 quantize 1.2001 1.00 -> 1.21 Inexact Rounded
+dqqua1802 quantize 1.2010 1.00 -> 1.21 Inexact Rounded
+dqqua1803 quantize 1.2050 1.00 -> 1.21 Inexact Rounded
+dqqua1804 quantize 1.2051 1.00 -> 1.21 Inexact Rounded
+dqqua1807 quantize 1.2060 1.00 -> 1.21 Inexact Rounded
+dqqua1808 quantize 1.2070 1.00 -> 1.21 Inexact Rounded
+dqqua1809 quantize 1.2099 1.00 -> 1.21 Inexact Rounded
+dqqua1811 quantize -1.2099 1.00 -> -1.21 Inexact Rounded
+
+dqqua1900 quantize 1.2100 1.00 -> 1.21 Rounded
+dqqua1901 quantize 1.2101 1.00 -> 1.21 Inexact Rounded
+dqqua1902 quantize 1.2110 1.00 -> 1.21 Inexact Rounded
+dqqua1903 quantize 1.2150 1.00 -> 1.21 Inexact Rounded
+dqqua1904 quantize 1.2151 1.00 -> 1.21 Inexact Rounded
+dqqua1907 quantize 1.2160 1.00 -> 1.21 Inexact Rounded
+dqqua1908 quantize 1.2170 1.00 -> 1.21 Inexact Rounded
+dqqua1909 quantize 1.2199 1.00 -> 1.21 Inexact Rounded
+dqqua1911 quantize -1.2199 1.00 -> -1.21 Inexact Rounded
+
+dqqua2000 quantize 1.2400 1.00 -> 1.24 Rounded
+dqqua2001 quantize 1.2401 1.00 -> 1.24 Inexact Rounded
+dqqua2002 quantize 1.2410 1.00 -> 1.24 Inexact Rounded
+dqqua2003 quantize 1.2450 1.00 -> 1.24 Inexact Rounded
+dqqua2004 quantize 1.2451 1.00 -> 1.24 Inexact Rounded
+dqqua2007 quantize 1.2460 1.00 -> 1.24 Inexact Rounded
+dqqua2008 quantize 1.2470 1.00 -> 1.24 Inexact Rounded
+dqqua2009 quantize 1.2499 1.00 -> 1.24 Inexact Rounded
+dqqua2011 quantize -1.2499 1.00 -> -1.24 Inexact Rounded
+
+dqqua2100 quantize 1.2500 1.00 -> 1.25 Rounded
+dqqua2101 quantize 1.2501 1.00 -> 1.26 Inexact Rounded
+dqqua2102 quantize 1.2510 1.00 -> 1.26 Inexact Rounded
+dqqua2103 quantize 1.2550 1.00 -> 1.26 Inexact Rounded
+dqqua2104 quantize 1.2551 1.00 -> 1.26 Inexact Rounded
+dqqua2107 quantize 1.2560 1.00 -> 1.26 Inexact Rounded
+dqqua2108 quantize 1.2570 1.00 -> 1.26 Inexact Rounded
+dqqua2109 quantize 1.2599 1.00 -> 1.26 Inexact Rounded
+dqqua2111 quantize -1.2599 1.00 -> -1.26 Inexact Rounded
+
+dqqua2200 quantize 1.2600 1.00 -> 1.26 Rounded
+dqqua2201 quantize 1.2601 1.00 -> 1.26 Inexact Rounded
+dqqua2202 quantize 1.2610 1.00 -> 1.26 Inexact Rounded
+dqqua2203 quantize 1.2650 1.00 -> 1.26 Inexact Rounded
+dqqua2204 quantize 1.2651 1.00 -> 1.26 Inexact Rounded
+dqqua2207 quantize 1.2660 1.00 -> 1.26 Inexact Rounded
+dqqua2208 quantize 1.2670 1.00 -> 1.26 Inexact Rounded
+dqqua2209 quantize 1.2699 1.00 -> 1.26 Inexact Rounded
+dqqua2211 quantize -1.2699 1.00 -> -1.26 Inexact Rounded
+
+dqqua2300 quantize 1.2900 1.00 -> 1.29 Rounded
+dqqua2301 quantize 1.2901 1.00 -> 1.29 Inexact Rounded
+dqqua2302 quantize 1.2910 1.00 -> 1.29 Inexact Rounded
+dqqua2303 quantize 1.2950 1.00 -> 1.29 Inexact Rounded
+dqqua2304 quantize 1.2951 1.00 -> 1.29 Inexact Rounded
+dqqua2307 quantize 1.2960 1.00 -> 1.29 Inexact Rounded
+dqqua2308 quantize 1.2970 1.00 -> 1.29 Inexact Rounded
+dqqua2309 quantize 1.2999 1.00 -> 1.29 Inexact Rounded
+dqqua2311 quantize -1.2999 1.00 -> -1.29 Inexact Rounded
+
+-- Null tests
+dqqua998 quantize 10 # -> NaN Invalid_operation
+dqqua999 quantize # 1e10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqReduce.decTest b/Lib/test/decimaltestdata/dqReduce.decTest
index 5635e6b70f3..236574f4c7a 100644
--- a/Lib/test/decimaltestdata/dqReduce.decTest
+++ b/Lib/test/decimaltestdata/dqReduce.decTest
@@ -1,183 +1,183 @@
-------------------------------------------------------------------------
--- dqReduce.decTest -- remove trailing zeros from a decQuad --
--- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqred001 reduce '1' -> '1'
-dqred002 reduce '-1' -> '-1'
-dqred003 reduce '1.00' -> '1'
-dqred004 reduce '-1.00' -> '-1'
-dqred005 reduce '0' -> '0'
-dqred006 reduce '0.00' -> '0'
-dqred007 reduce '00.0' -> '0'
-dqred008 reduce '00.00' -> '0'
-dqred009 reduce '00' -> '0'
-dqred010 reduce '0E+1' -> '0'
-dqred011 reduce '0E+5' -> '0'
-
-dqred012 reduce '-2' -> '-2'
-dqred013 reduce '2' -> '2'
-dqred014 reduce '-2.00' -> '-2'
-dqred015 reduce '2.00' -> '2'
-dqred016 reduce '-0' -> '-0'
-dqred017 reduce '-0.00' -> '-0'
-dqred018 reduce '-00.0' -> '-0'
-dqred019 reduce '-00.00' -> '-0'
-dqred020 reduce '-00' -> '-0'
-dqred021 reduce '-0E+5' -> '-0'
-dqred022 reduce '-0E+1' -> '-0'
-
-dqred030 reduce '+0.1' -> '0.1'
-dqred031 reduce '-0.1' -> '-0.1'
-dqred032 reduce '+0.01' -> '0.01'
-dqred033 reduce '-0.01' -> '-0.01'
-dqred034 reduce '+0.001' -> '0.001'
-dqred035 reduce '-0.001' -> '-0.001'
-dqred036 reduce '+0.000001' -> '0.000001'
-dqred037 reduce '-0.000001' -> '-0.000001'
-dqred038 reduce '+0.000000000001' -> '1E-12'
-dqred039 reduce '-0.000000000001' -> '-1E-12'
-
-dqred041 reduce 1.1 -> 1.1
-dqred042 reduce 1.10 -> 1.1
-dqred043 reduce 1.100 -> 1.1
-dqred044 reduce 1.110 -> 1.11
-dqred045 reduce -1.1 -> -1.1
-dqred046 reduce -1.10 -> -1.1
-dqred047 reduce -1.100 -> -1.1
-dqred048 reduce -1.110 -> -1.11
-dqred049 reduce 9.9 -> 9.9
-dqred050 reduce 9.90 -> 9.9
-dqred051 reduce 9.900 -> 9.9
-dqred052 reduce 9.990 -> 9.99
-dqred053 reduce -9.9 -> -9.9
-dqred054 reduce -9.90 -> -9.9
-dqred055 reduce -9.900 -> -9.9
-dqred056 reduce -9.990 -> -9.99
-
--- some trailing fractional zeros with zeros in units
-dqred060 reduce 10.0 -> 1E+1
-dqred061 reduce 10.00 -> 1E+1
-dqred062 reduce 100.0 -> 1E+2
-dqred063 reduce 100.00 -> 1E+2
-dqred064 reduce 1.1000E+3 -> 1.1E+3
-dqred065 reduce 1.10000E+3 -> 1.1E+3
-dqred066 reduce -10.0 -> -1E+1
-dqred067 reduce -10.00 -> -1E+1
-dqred068 reduce -100.0 -> -1E+2
-dqred069 reduce -100.00 -> -1E+2
-dqred070 reduce -1.1000E+3 -> -1.1E+3
-dqred071 reduce -1.10000E+3 -> -1.1E+3
-
--- some insignificant trailing zeros with positive exponent
-dqred080 reduce 10E+1 -> 1E+2
-dqred081 reduce 100E+1 -> 1E+3
-dqred082 reduce 1.0E+2 -> 1E+2
-dqred083 reduce 1.0E+3 -> 1E+3
-dqred084 reduce 1.1E+3 -> 1.1E+3
-dqred085 reduce 1.00E+3 -> 1E+3
-dqred086 reduce 1.10E+3 -> 1.1E+3
-dqred087 reduce -10E+1 -> -1E+2
-dqred088 reduce -100E+1 -> -1E+3
-dqred089 reduce -1.0E+2 -> -1E+2
-dqred090 reduce -1.0E+3 -> -1E+3
-dqred091 reduce -1.1E+3 -> -1.1E+3
-dqred092 reduce -1.00E+3 -> -1E+3
-dqred093 reduce -1.10E+3 -> -1.1E+3
-
--- some significant trailing zeros, were we to be trimming
-dqred100 reduce 11 -> 11
-dqred101 reduce 10 -> 1E+1
-dqred102 reduce 10. -> 1E+1
-dqred103 reduce 1.1E+1 -> 11
-dqred104 reduce 1.0E+1 -> 1E+1
-dqred105 reduce 1.10E+2 -> 1.1E+2
-dqred106 reduce 1.00E+2 -> 1E+2
-dqred107 reduce 1.100E+3 -> 1.1E+3
-dqred108 reduce 1.000E+3 -> 1E+3
-dqred109 reduce 1.000000E+6 -> 1E+6
-dqred110 reduce -11 -> -11
-dqred111 reduce -10 -> -1E+1
-dqred112 reduce -10. -> -1E+1
-dqred113 reduce -1.1E+1 -> -11
-dqred114 reduce -1.0E+1 -> -1E+1
-dqred115 reduce -1.10E+2 -> -1.1E+2
-dqred116 reduce -1.00E+2 -> -1E+2
-dqred117 reduce -1.100E+3 -> -1.1E+3
-dqred118 reduce -1.000E+3 -> -1E+3
-dqred119 reduce -1.00000E+5 -> -1E+5
-dqred120 reduce -1.000000E+6 -> -1E+6
-dqred121 reduce -10.00000E+6 -> -1E+7
-dqred122 reduce -100.0000E+6 -> -1E+8
-dqred123 reduce -1000.000E+6 -> -1E+9
-dqred124 reduce -10000.00E+6 -> -1E+10
-dqred125 reduce -100000.0E+6 -> -1E+11
-dqred126 reduce -1000000.E+6 -> -1E+12
-
--- examples from decArith
-dqred140 reduce '2.1' -> '2.1'
-dqred141 reduce '-2.0' -> '-2'
-dqred142 reduce '1.200' -> '1.2'
-dqred143 reduce '-120' -> '-1.2E+2'
-dqred144 reduce '120.00' -> '1.2E+2'
-dqred145 reduce '0.00' -> '0'
-
--- Nmax, Nmin, Ntiny
--- note origami effect on some of these
-dqred151 reduce 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
-dqred152 reduce 9.999999999999999999999999000000000E+6140 -> 9.99999999999999999999999900000E+6140
-dqred153 reduce 9.999999999999999999999999999990000E+6144 -> 9.999999999999999999999999999990000E+6144
-dqred154 reduce 1E-6143 -> 1E-6143
-dqred155 reduce 1.000000000000000000000000000000000E-6143 -> 1E-6143
-dqred156 reduce 2.000E-6173 -> 2E-6173 Subnormal
-dqred157 reduce 1E-6176 -> 1E-6176 Subnormal
-
-dqred161 reduce -1E-6176 -> -1E-6176 Subnormal
-dqred162 reduce -2.000E-6173 -> -2E-6173 Subnormal
-dqred163 reduce -1.000000000000000000000000000000000E-6143 -> -1E-6143
-dqred164 reduce -1E-6143 -> -1E-6143
-dqred165 reduce -9.999999999999999999999999000000000E+6140 -> -9.99999999999999999999999900000E+6140
-dqred166 reduce -9.999999999999999999999999999990000E+6144 -> -9.999999999999999999999999999990000E+6144
-dqred167 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
-dqred168 reduce -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
-dqred169 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
-
-
--- specials (reduce does not affect payload)
-dqred820 reduce 'Inf' -> 'Infinity'
-dqred821 reduce '-Inf' -> '-Infinity'
-dqred822 reduce NaN -> NaN
-dqred823 reduce sNaN -> NaN Invalid_operation
-dqred824 reduce NaN101 -> NaN101
-dqred825 reduce sNaN010 -> NaN10 Invalid_operation
-dqred827 reduce -NaN -> -NaN
-dqred828 reduce -sNaN -> -NaN Invalid_operation
-dqred829 reduce -NaN101 -> -NaN101
-dqred830 reduce -sNaN010 -> -NaN10 Invalid_operation
-
--- Null test
-dqred900 reduce # -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqReduce.decTest -- remove trailing zeros from a decQuad --
+-- Copyright (c) IBM Corporation, 2003, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqred001 reduce '1' -> '1'
+dqred002 reduce '-1' -> '-1'
+dqred003 reduce '1.00' -> '1'
+dqred004 reduce '-1.00' -> '-1'
+dqred005 reduce '0' -> '0'
+dqred006 reduce '0.00' -> '0'
+dqred007 reduce '00.0' -> '0'
+dqred008 reduce '00.00' -> '0'
+dqred009 reduce '00' -> '0'
+dqred010 reduce '0E+1' -> '0'
+dqred011 reduce '0E+5' -> '0'
+
+dqred012 reduce '-2' -> '-2'
+dqred013 reduce '2' -> '2'
+dqred014 reduce '-2.00' -> '-2'
+dqred015 reduce '2.00' -> '2'
+dqred016 reduce '-0' -> '-0'
+dqred017 reduce '-0.00' -> '-0'
+dqred018 reduce '-00.0' -> '-0'
+dqred019 reduce '-00.00' -> '-0'
+dqred020 reduce '-00' -> '-0'
+dqred021 reduce '-0E+5' -> '-0'
+dqred022 reduce '-0E+1' -> '-0'
+
+dqred030 reduce '+0.1' -> '0.1'
+dqred031 reduce '-0.1' -> '-0.1'
+dqred032 reduce '+0.01' -> '0.01'
+dqred033 reduce '-0.01' -> '-0.01'
+dqred034 reduce '+0.001' -> '0.001'
+dqred035 reduce '-0.001' -> '-0.001'
+dqred036 reduce '+0.000001' -> '0.000001'
+dqred037 reduce '-0.000001' -> '-0.000001'
+dqred038 reduce '+0.000000000001' -> '1E-12'
+dqred039 reduce '-0.000000000001' -> '-1E-12'
+
+dqred041 reduce 1.1 -> 1.1
+dqred042 reduce 1.10 -> 1.1
+dqred043 reduce 1.100 -> 1.1
+dqred044 reduce 1.110 -> 1.11
+dqred045 reduce -1.1 -> -1.1
+dqred046 reduce -1.10 -> -1.1
+dqred047 reduce -1.100 -> -1.1
+dqred048 reduce -1.110 -> -1.11
+dqred049 reduce 9.9 -> 9.9
+dqred050 reduce 9.90 -> 9.9
+dqred051 reduce 9.900 -> 9.9
+dqred052 reduce 9.990 -> 9.99
+dqred053 reduce -9.9 -> -9.9
+dqred054 reduce -9.90 -> -9.9
+dqred055 reduce -9.900 -> -9.9
+dqred056 reduce -9.990 -> -9.99
+
+-- some trailing fractional zeros with zeros in units
+dqred060 reduce 10.0 -> 1E+1
+dqred061 reduce 10.00 -> 1E+1
+dqred062 reduce 100.0 -> 1E+2
+dqred063 reduce 100.00 -> 1E+2
+dqred064 reduce 1.1000E+3 -> 1.1E+3
+dqred065 reduce 1.10000E+3 -> 1.1E+3
+dqred066 reduce -10.0 -> -1E+1
+dqred067 reduce -10.00 -> -1E+1
+dqred068 reduce -100.0 -> -1E+2
+dqred069 reduce -100.00 -> -1E+2
+dqred070 reduce -1.1000E+3 -> -1.1E+3
+dqred071 reduce -1.10000E+3 -> -1.1E+3
+
+-- some insignificant trailing zeros with positive exponent
+dqred080 reduce 10E+1 -> 1E+2
+dqred081 reduce 100E+1 -> 1E+3
+dqred082 reduce 1.0E+2 -> 1E+2
+dqred083 reduce 1.0E+3 -> 1E+3
+dqred084 reduce 1.1E+3 -> 1.1E+3
+dqred085 reduce 1.00E+3 -> 1E+3
+dqred086 reduce 1.10E+3 -> 1.1E+3
+dqred087 reduce -10E+1 -> -1E+2
+dqred088 reduce -100E+1 -> -1E+3
+dqred089 reduce -1.0E+2 -> -1E+2
+dqred090 reduce -1.0E+3 -> -1E+3
+dqred091 reduce -1.1E+3 -> -1.1E+3
+dqred092 reduce -1.00E+3 -> -1E+3
+dqred093 reduce -1.10E+3 -> -1.1E+3
+
+-- some significant trailing zeros, were we to be trimming
+dqred100 reduce 11 -> 11
+dqred101 reduce 10 -> 1E+1
+dqred102 reduce 10. -> 1E+1
+dqred103 reduce 1.1E+1 -> 11
+dqred104 reduce 1.0E+1 -> 1E+1
+dqred105 reduce 1.10E+2 -> 1.1E+2
+dqred106 reduce 1.00E+2 -> 1E+2
+dqred107 reduce 1.100E+3 -> 1.1E+3
+dqred108 reduce 1.000E+3 -> 1E+3
+dqred109 reduce 1.000000E+6 -> 1E+6
+dqred110 reduce -11 -> -11
+dqred111 reduce -10 -> -1E+1
+dqred112 reduce -10. -> -1E+1
+dqred113 reduce -1.1E+1 -> -11
+dqred114 reduce -1.0E+1 -> -1E+1
+dqred115 reduce -1.10E+2 -> -1.1E+2
+dqred116 reduce -1.00E+2 -> -1E+2
+dqred117 reduce -1.100E+3 -> -1.1E+3
+dqred118 reduce -1.000E+3 -> -1E+3
+dqred119 reduce -1.00000E+5 -> -1E+5
+dqred120 reduce -1.000000E+6 -> -1E+6
+dqred121 reduce -10.00000E+6 -> -1E+7
+dqred122 reduce -100.0000E+6 -> -1E+8
+dqred123 reduce -1000.000E+6 -> -1E+9
+dqred124 reduce -10000.00E+6 -> -1E+10
+dqred125 reduce -100000.0E+6 -> -1E+11
+dqred126 reduce -1000000.E+6 -> -1E+12
+
+-- examples from decArith
+dqred140 reduce '2.1' -> '2.1'
+dqred141 reduce '-2.0' -> '-2'
+dqred142 reduce '1.200' -> '1.2'
+dqred143 reduce '-120' -> '-1.2E+2'
+dqred144 reduce '120.00' -> '1.2E+2'
+dqred145 reduce '0.00' -> '0'
+
+-- Nmax, Nmin, Ntiny
+-- note origami effect on some of these
+dqred151 reduce 9.999999999999999999999999999999999E+6144 -> 9.999999999999999999999999999999999E+6144
+dqred152 reduce 9.999999999999999999999999000000000E+6140 -> 9.99999999999999999999999900000E+6140
+dqred153 reduce 9.999999999999999999999999999990000E+6144 -> 9.999999999999999999999999999990000E+6144
+dqred154 reduce 1E-6143 -> 1E-6143
+dqred155 reduce 1.000000000000000000000000000000000E-6143 -> 1E-6143
+dqred156 reduce 2.000E-6173 -> 2E-6173 Subnormal
+dqred157 reduce 1E-6176 -> 1E-6176 Subnormal
+
+dqred161 reduce -1E-6176 -> -1E-6176 Subnormal
+dqred162 reduce -2.000E-6173 -> -2E-6173 Subnormal
+dqred163 reduce -1.000000000000000000000000000000000E-6143 -> -1E-6143
+dqred164 reduce -1E-6143 -> -1E-6143
+dqred165 reduce -9.999999999999999999999999000000000E+6140 -> -9.99999999999999999999999900000E+6140
+dqred166 reduce -9.999999999999999999999999999990000E+6144 -> -9.999999999999999999999999999990000E+6144
+dqred167 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
+dqred168 reduce -9.999999999999999999999999999999999E+6144 -> -9.999999999999999999999999999999999E+6144
+dqred169 reduce -9.999999999999999999999999999999990E+6144 -> -9.999999999999999999999999999999990E+6144
+
+
+-- specials (reduce does not affect payload)
+dqred820 reduce 'Inf' -> 'Infinity'
+dqred821 reduce '-Inf' -> '-Infinity'
+dqred822 reduce NaN -> NaN
+dqred823 reduce sNaN -> NaN Invalid_operation
+dqred824 reduce NaN101 -> NaN101
+dqred825 reduce sNaN010 -> NaN10 Invalid_operation
+dqred827 reduce -NaN -> -NaN
+dqred828 reduce -sNaN -> -NaN Invalid_operation
+dqred829 reduce -NaN101 -> -NaN101
+dqred830 reduce -sNaN010 -> -NaN10 Invalid_operation
+
+-- Null test
+dqred900 reduce # -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqRemainder.decTest b/Lib/test/decimaltestdata/dqRemainder.decTest
index 090d3cf559c..bae8eae5269 100644
--- a/Lib/test/decimaltestdata/dqRemainder.decTest
+++ b/Lib/test/decimaltestdata/dqRemainder.decTest
@@ -1,597 +1,597 @@
-------------------------------------------------------------------------
--- dqRemainder.decTest -- decQuad remainder --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks (as base, above)
-dqrem001 remainder 1 1 -> 0
-dqrem002 remainder 2 1 -> 0
-dqrem003 remainder 1 2 -> 1
-dqrem004 remainder 2 2 -> 0
-dqrem005 remainder 0 1 -> 0
-dqrem006 remainder 0 2 -> 0
-dqrem007 remainder 1 3 -> 1
-dqrem008 remainder 2 3 -> 2
-dqrem009 remainder 3 3 -> 0
-
-dqrem010 remainder 2.4 1 -> 0.4
-dqrem011 remainder 2.4 -1 -> 0.4
-dqrem012 remainder -2.4 1 -> -0.4
-dqrem013 remainder -2.4 -1 -> -0.4
-dqrem014 remainder 2.40 1 -> 0.40
-dqrem015 remainder 2.400 1 -> 0.400
-dqrem016 remainder 2.4 2 -> 0.4
-dqrem017 remainder 2.400 2 -> 0.400
-dqrem018 remainder 2. 2 -> 0
-dqrem019 remainder 20 20 -> 0
-
-dqrem020 remainder 187 187 -> 0
-dqrem021 remainder 5 2 -> 1
-dqrem022 remainder 5 2.0 -> 1.0
-dqrem023 remainder 5 2.000 -> 1.000
-dqrem024 remainder 5 0.200 -> 0.000
-dqrem025 remainder 5 0.200 -> 0.000
-
-dqrem030 remainder 1 2 -> 1
-dqrem031 remainder 1 4 -> 1
-dqrem032 remainder 1 8 -> 1
-
-dqrem033 remainder 1 16 -> 1
-dqrem034 remainder 1 32 -> 1
-dqrem035 remainder 1 64 -> 1
-dqrem040 remainder 1 -2 -> 1
-dqrem041 remainder 1 -4 -> 1
-dqrem042 remainder 1 -8 -> 1
-dqrem043 remainder 1 -16 -> 1
-dqrem044 remainder 1 -32 -> 1
-dqrem045 remainder 1 -64 -> 1
-dqrem050 remainder -1 2 -> -1
-dqrem051 remainder -1 4 -> -1
-dqrem052 remainder -1 8 -> -1
-dqrem053 remainder -1 16 -> -1
-dqrem054 remainder -1 32 -> -1
-dqrem055 remainder -1 64 -> -1
-dqrem060 remainder -1 -2 -> -1
-dqrem061 remainder -1 -4 -> -1
-dqrem062 remainder -1 -8 -> -1
-dqrem063 remainder -1 -16 -> -1
-dqrem064 remainder -1 -32 -> -1
-dqrem065 remainder -1 -64 -> -1
-
-dqrem066 remainder 999999999 1 -> 0
-dqrem067 remainder 999999999.4 1 -> 0.4
-dqrem068 remainder 999999999.5 1 -> 0.5
-dqrem069 remainder 999999999.9 1 -> 0.9
-dqrem070 remainder 999999999.999 1 -> 0.999
-dqrem071 remainder 999999.999999 1 -> 0.999999
-dqrem072 remainder 9 1 -> 0
-
-dqrem080 remainder 0. 1 -> 0
-dqrem081 remainder .0 1 -> 0.0
-dqrem082 remainder 0.00 1 -> 0.00
-dqrem083 remainder 0.00E+9 1 -> 0
-dqrem084 remainder 0.00E+3 1 -> 0
-dqrem085 remainder 0.00E+2 1 -> 0
-dqrem086 remainder 0.00E+1 1 -> 0.0
-dqrem087 remainder 0.00E+0 1 -> 0.00
-dqrem088 remainder 0.00E-0 1 -> 0.00
-dqrem089 remainder 0.00E-1 1 -> 0.000
-dqrem090 remainder 0.00E-2 1 -> 0.0000
-dqrem091 remainder 0.00E-3 1 -> 0.00000
-dqrem092 remainder 0.00E-4 1 -> 0.000000
-dqrem093 remainder 0.00E-5 1 -> 0E-7
-dqrem094 remainder 0.00E-6 1 -> 0E-8
-dqrem095 remainder 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remainder by 0
-dqrem101 remainder 0 0 -> NaN Division_undefined
-dqrem102 remainder 0 -0 -> NaN Division_undefined
-dqrem103 remainder -0 0 -> NaN Division_undefined
-dqrem104 remainder -0 -0 -> NaN Division_undefined
-dqrem105 remainder 0.0E5 0 -> NaN Division_undefined
-dqrem106 remainder 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-dqrem107 remainder 0.0001 0 -> NaN Invalid_operation
-dqrem108 remainder 0.01 0 -> NaN Invalid_operation
-dqrem109 remainder 0.1 0 -> NaN Invalid_operation
-dqrem110 remainder 1 0 -> NaN Invalid_operation
-dqrem111 remainder 1 0.0 -> NaN Invalid_operation
-dqrem112 remainder 10 0.0 -> NaN Invalid_operation
-dqrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
-dqrem114 remainder 1E+380 0 -> NaN Invalid_operation
-dqrem115 remainder 0.0001 -0 -> NaN Invalid_operation
-dqrem116 remainder 0.01 -0 -> NaN Invalid_operation
-dqrem119 remainder 0.1 -0 -> NaN Invalid_operation
-dqrem120 remainder 1 -0 -> NaN Invalid_operation
-dqrem121 remainder 1 -0.0 -> NaN Invalid_operation
-dqrem122 remainder 10 -0.0 -> NaN Invalid_operation
-dqrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
-dqrem124 remainder 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-dqrem130 remainder 0 1 -> 0
-dqrem131 remainder 0 -1 -> 0
-dqrem132 remainder 0.0 1 -> 0.0
-dqrem133 remainder 0.0 -1 -> 0.0
-dqrem134 remainder -0 1 -> -0
-dqrem135 remainder -0 -1 -> -0
-dqrem136 remainder -0.0 1 -> -0.0
-dqrem137 remainder -0.0 -1 -> -0.0
-
--- 0.5ers
-dqrem143 remainder 0.5 2 -> 0.5
-dqrem144 remainder 0.5 2.1 -> 0.5
-dqrem145 remainder 0.5 2.01 -> 0.50
-dqrem146 remainder 0.5 2.001 -> 0.500
-dqrem147 remainder 0.50 2 -> 0.50
-dqrem148 remainder 0.50 2.01 -> 0.50
-dqrem149 remainder 0.50 2.001 -> 0.500
-
--- steadies
-dqrem150 remainder 1 1 -> 0
-dqrem151 remainder 1 2 -> 1
-dqrem152 remainder 1 3 -> 1
-dqrem153 remainder 1 4 -> 1
-dqrem154 remainder 1 5 -> 1
-dqrem155 remainder 1 6 -> 1
-dqrem156 remainder 1 7 -> 1
-dqrem157 remainder 1 8 -> 1
-dqrem158 remainder 1 9 -> 1
-dqrem159 remainder 1 10 -> 1
-dqrem160 remainder 1 1 -> 0
-dqrem161 remainder 2 1 -> 0
-dqrem162 remainder 3 1 -> 0
-dqrem163 remainder 4 1 -> 0
-dqrem164 remainder 5 1 -> 0
-dqrem165 remainder 6 1 -> 0
-dqrem166 remainder 7 1 -> 0
-dqrem167 remainder 8 1 -> 0
-dqrem168 remainder 9 1 -> 0
-dqrem169 remainder 10 1 -> 0
-
--- some differences from remainderNear
-dqrem171 remainder 0.4 1.020 -> 0.400
-dqrem172 remainder 0.50 1.020 -> 0.500
-dqrem173 remainder 0.51 1.020 -> 0.510
-dqrem174 remainder 0.52 1.020 -> 0.520
-dqrem175 remainder 0.6 1.020 -> 0.600
-
--- More flavours of remainder by 0
-dqrem201 remainder 0 0 -> NaN Division_undefined
-dqrem202 remainder 0.0E5 0 -> NaN Division_undefined
-dqrem203 remainder 0.000 0 -> NaN Division_undefined
-dqrem204 remainder 0.0001 0 -> NaN Invalid_operation
-dqrem205 remainder 0.01 0 -> NaN Invalid_operation
-dqrem206 remainder 0.1 0 -> NaN Invalid_operation
-dqrem207 remainder 1 0 -> NaN Invalid_operation
-dqrem208 remainder 1 0.0 -> NaN Invalid_operation
-dqrem209 remainder 10 0.0 -> NaN Invalid_operation
-dqrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
-dqrem211 remainder 1E+380 0 -> NaN Invalid_operation
-
--- some differences from remainderNear
-dqrem231 remainder -0.4 1.020 -> -0.400
-dqrem232 remainder -0.50 1.020 -> -0.500
-dqrem233 remainder -0.51 1.020 -> -0.510
-dqrem234 remainder -0.52 1.020 -> -0.520
-dqrem235 remainder -0.6 1.020 -> -0.600
-
--- high Xs
-dqrem240 remainder 1E+2 1.00 -> 0.00
-
--- dqrem3xx are from DiagBigDecimal
-dqrem301 remainder 1 3 -> 1
-dqrem302 remainder 5 5 -> 0
-dqrem303 remainder 13 10 -> 3
-dqrem304 remainder 13 50 -> 13
-dqrem305 remainder 13 100 -> 13
-dqrem306 remainder 13 1000 -> 13
-dqrem307 remainder .13 1 -> 0.13
-dqrem308 remainder 0.133 1 -> 0.133
-dqrem309 remainder 0.1033 1 -> 0.1033
-dqrem310 remainder 1.033 1 -> 0.033
-dqrem311 remainder 10.33 1 -> 0.33
-dqrem312 remainder 10.33 10 -> 0.33
-dqrem313 remainder 103.3 1 -> 0.3
-dqrem314 remainder 133 10 -> 3
-dqrem315 remainder 1033 10 -> 3
-dqrem316 remainder 1033 50 -> 33
-dqrem317 remainder 101.0 3 -> 2.0
-dqrem318 remainder 102.0 3 -> 0.0
-dqrem319 remainder 103.0 3 -> 1.0
-dqrem320 remainder 2.40 1 -> 0.40
-dqrem321 remainder 2.400 1 -> 0.400
-dqrem322 remainder 2.4 1 -> 0.4
-dqrem323 remainder 2.4 2 -> 0.4
-dqrem324 remainder 2.400 2 -> 0.400
-dqrem325 remainder 1 0.3 -> 0.1
-dqrem326 remainder 1 0.30 -> 0.10
-dqrem327 remainder 1 0.300 -> 0.100
-dqrem328 remainder 1 0.3000 -> 0.1000
-dqrem329 remainder 1.0 0.3 -> 0.1
-dqrem330 remainder 1.00 0.3 -> 0.10
-dqrem331 remainder 1.000 0.3 -> 0.100
-dqrem332 remainder 1.0000 0.3 -> 0.1000
-dqrem333 remainder 0.5 2 -> 0.5
-dqrem334 remainder 0.5 2.1 -> 0.5
-dqrem335 remainder 0.5 2.01 -> 0.50
-dqrem336 remainder 0.5 2.001 -> 0.500
-dqrem337 remainder 0.50 2 -> 0.50
-dqrem338 remainder 0.50 2.01 -> 0.50
-dqrem339 remainder 0.50 2.001 -> 0.500
-
-dqrem340 remainder 0.5 0.5000001 -> 0.5000000
-dqrem341 remainder 0.5 0.50000001 -> 0.50000000
-dqrem342 remainder 0.5 0.500000001 -> 0.500000000
-dqrem343 remainder 0.5 0.5000000001 -> 0.5000000000
-dqrem344 remainder 0.5 0.50000000001 -> 0.50000000000
-dqrem345 remainder 0.5 0.4999999 -> 1E-7
-dqrem346 remainder 0.5 0.49999999 -> 1E-8
-dqrem347 remainder 0.5 0.499999999 -> 1E-9
-dqrem348 remainder 0.5 0.4999999999 -> 1E-10
-dqrem349 remainder 0.5 0.49999999999 -> 1E-11
-dqrem350 remainder 0.5 0.499999999999 -> 1E-12
-
-dqrem351 remainder 0.03 7 -> 0.03
-dqrem352 remainder 5 2 -> 1
-dqrem353 remainder 4.1 2 -> 0.1
-dqrem354 remainder 4.01 2 -> 0.01
-dqrem355 remainder 4.001 2 -> 0.001
-dqrem356 remainder 4.0001 2 -> 0.0001
-dqrem357 remainder 4.00001 2 -> 0.00001
-dqrem358 remainder 4.000001 2 -> 0.000001
-dqrem359 remainder 4.0000001 2 -> 1E-7
-
-dqrem360 remainder 1.2 0.7345 -> 0.4655
-dqrem361 remainder 0.8 12 -> 0.8
-dqrem362 remainder 0.8 0.2 -> 0.0
-dqrem363 remainder 0.8 0.3 -> 0.2
-dqrem364 remainder 0.800 12 -> 0.800
-dqrem365 remainder 0.800 1.7 -> 0.800
-dqrem366 remainder 2.400 2 -> 0.400
-
-dqrem371 remainder 2.400 2 -> 0.400
-
-dqrem381 remainder 12345 1 -> 0
-dqrem382 remainder 12345 1.0001 -> 0.7657
-dqrem383 remainder 12345 1.001 -> 0.668
-dqrem384 remainder 12345 1.01 -> 0.78
-dqrem385 remainder 12345 1.1 -> 0.8
-dqrem386 remainder 12355 4 -> 3
-dqrem387 remainder 12345 4 -> 1
-dqrem388 remainder 12355 4.0001 -> 2.6912
-dqrem389 remainder 12345 4.0001 -> 0.6914
-dqrem390 remainder 12345 4.9 -> 1.9
-dqrem391 remainder 12345 4.99 -> 4.73
-dqrem392 remainder 12345 4.999 -> 2.469
-dqrem393 remainder 12345 4.9999 -> 0.2469
-dqrem394 remainder 12345 5 -> 0
-dqrem395 remainder 12345 5.0001 -> 4.7532
-dqrem396 remainder 12345 5.001 -> 2.532
-dqrem397 remainder 12345 5.01 -> 0.36
-dqrem398 remainder 12345 5.1 -> 3.0
-
--- the nasty division-by-1 cases
-dqrem401 remainder 0.5 1 -> 0.5
-dqrem402 remainder 0.55 1 -> 0.55
-dqrem403 remainder 0.555 1 -> 0.555
-dqrem404 remainder 0.5555 1 -> 0.5555
-dqrem405 remainder 0.55555 1 -> 0.55555
-dqrem406 remainder 0.555555 1 -> 0.555555
-dqrem407 remainder 0.5555555 1 -> 0.5555555
-dqrem408 remainder 0.55555555 1 -> 0.55555555
-dqrem409 remainder 0.555555555 1 -> 0.555555555
-
--- folddowns
-dqrem421 remainder 1E+6144 1 -> NaN Division_impossible
-dqrem422 remainder 1E+6144 1E+6143 -> 0E+6111 Clamped
-dqrem423 remainder 1E+6144 2E+6143 -> 0E+6111 Clamped
-dqrem424 remainder 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqrem425 remainder 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrem426 remainder 1E+6144 5E+6143 -> 0E+6111 Clamped
-dqrem427 remainder 1E+6144 6E+6143 -> 4.00000000000000000000000000000000E+6143 Clamped
-dqrem428 remainder 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
-dqrem429 remainder 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrem430 remainder 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
--- tinies
-dqrem431 remainder 1E-6175 1E-6176 -> 0E-6176
-dqrem432 remainder 1E-6175 2E-6176 -> 0E-6176
-dqrem433 remainder 1E-6175 3E-6176 -> 1E-6176 Subnormal
-dqrem434 remainder 1E-6175 4E-6176 -> 2E-6176 Subnormal
-dqrem435 remainder 1E-6175 5E-6176 -> 0E-6176
-dqrem436 remainder 1E-6175 6E-6176 -> 4E-6176 Subnormal
-dqrem437 remainder 1E-6175 7E-6176 -> 3E-6176 Subnormal
-dqrem438 remainder 1E-6175 8E-6176 -> 2E-6176 Subnormal
-dqrem439 remainder 1E-6175 9E-6176 -> 1E-6176 Subnormal
-dqrem440 remainder 1E-6175 10E-6176 -> 0E-6176
-dqrem441 remainder 1E-6175 11E-6176 -> 1.0E-6175 Subnormal
-dqrem442 remainder 100E-6175 11E-6176 -> 1.0E-6175 Subnormal
-dqrem443 remainder 100E-6175 20E-6176 -> 0E-6176
-dqrem444 remainder 100E-6175 21E-6176 -> 1.3E-6175 Subnormal
-dqrem445 remainder 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
-
--- zero signs
-dqrem650 remainder 1 1 -> 0
-dqrem651 remainder -1 1 -> -0
-dqrem652 remainder 1 -1 -> 0
-dqrem653 remainder -1 -1 -> -0
-dqrem654 remainder 0 1 -> 0
-dqrem655 remainder -0 1 -> -0
-dqrem656 remainder 0 -1 -> 0
-dqrem657 remainder -0 -1 -> -0
-dqrem658 remainder 0.00 1 -> 0.00
-dqrem659 remainder -0.00 1 -> -0.00
-
--- Specials
-dqrem680 remainder Inf -Inf -> NaN Invalid_operation
-dqrem681 remainder Inf -1000 -> NaN Invalid_operation
-dqrem682 remainder Inf -1 -> NaN Invalid_operation
-dqrem683 remainder Inf 0 -> NaN Invalid_operation
-dqrem684 remainder Inf -0 -> NaN Invalid_operation
-dqrem685 remainder Inf 1 -> NaN Invalid_operation
-dqrem686 remainder Inf 1000 -> NaN Invalid_operation
-dqrem687 remainder Inf Inf -> NaN Invalid_operation
-dqrem688 remainder -1000 Inf -> -1000
-dqrem689 remainder -Inf Inf -> NaN Invalid_operation
-dqrem691 remainder -1 Inf -> -1
-dqrem692 remainder 0 Inf -> 0
-dqrem693 remainder -0 Inf -> -0
-dqrem694 remainder 1 Inf -> 1
-dqrem695 remainder 1000 Inf -> 1000
-dqrem696 remainder Inf Inf -> NaN Invalid_operation
-
-dqrem700 remainder -Inf -Inf -> NaN Invalid_operation
-dqrem701 remainder -Inf -1000 -> NaN Invalid_operation
-dqrem702 remainder -Inf -1 -> NaN Invalid_operation
-dqrem703 remainder -Inf -0 -> NaN Invalid_operation
-dqrem704 remainder -Inf 0 -> NaN Invalid_operation
-dqrem705 remainder -Inf 1 -> NaN Invalid_operation
-dqrem706 remainder -Inf 1000 -> NaN Invalid_operation
-dqrem707 remainder -Inf Inf -> NaN Invalid_operation
-dqrem708 remainder -Inf -Inf -> NaN Invalid_operation
-dqrem709 remainder -1000 Inf -> -1000
-dqrem710 remainder -1 -Inf -> -1
-dqrem711 remainder -0 -Inf -> -0
-dqrem712 remainder 0 -Inf -> 0
-dqrem713 remainder 1 -Inf -> 1
-dqrem714 remainder 1000 -Inf -> 1000
-dqrem715 remainder Inf -Inf -> NaN Invalid_operation
-
-dqrem721 remainder NaN -Inf -> NaN
-dqrem722 remainder NaN -1000 -> NaN
-dqrem723 remainder NaN -1 -> NaN
-dqrem724 remainder NaN -0 -> NaN
-dqrem725 remainder -NaN 0 -> -NaN
-dqrem726 remainder NaN 1 -> NaN
-dqrem727 remainder NaN 1000 -> NaN
-dqrem728 remainder NaN Inf -> NaN
-dqrem729 remainder NaN -NaN -> NaN
-dqrem730 remainder -Inf NaN -> NaN
-dqrem731 remainder -1000 NaN -> NaN
-dqrem732 remainder -1 NaN -> NaN
-dqrem733 remainder -0 -NaN -> -NaN
-dqrem734 remainder 0 NaN -> NaN
-dqrem735 remainder 1 -NaN -> -NaN
-dqrem736 remainder 1000 NaN -> NaN
-dqrem737 remainder Inf NaN -> NaN
-
-dqrem741 remainder sNaN -Inf -> NaN Invalid_operation
-dqrem742 remainder sNaN -1000 -> NaN Invalid_operation
-dqrem743 remainder -sNaN -1 -> -NaN Invalid_operation
-dqrem744 remainder sNaN -0 -> NaN Invalid_operation
-dqrem745 remainder sNaN 0 -> NaN Invalid_operation
-dqrem746 remainder sNaN 1 -> NaN Invalid_operation
-dqrem747 remainder sNaN 1000 -> NaN Invalid_operation
-dqrem749 remainder sNaN NaN -> NaN Invalid_operation
-dqrem750 remainder sNaN sNaN -> NaN Invalid_operation
-dqrem751 remainder NaN sNaN -> NaN Invalid_operation
-dqrem752 remainder -Inf sNaN -> NaN Invalid_operation
-dqrem753 remainder -1000 sNaN -> NaN Invalid_operation
-dqrem754 remainder -1 sNaN -> NaN Invalid_operation
-dqrem755 remainder -0 sNaN -> NaN Invalid_operation
-dqrem756 remainder 0 sNaN -> NaN Invalid_operation
-dqrem757 remainder 1 sNaN -> NaN Invalid_operation
-dqrem758 remainder 1000 sNaN -> NaN Invalid_operation
-dqrem759 remainder Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-dqrem760 remainder NaN1 NaN7 -> NaN1
-dqrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
-dqrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
-dqrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
-dqrem764 remainder 15 NaN11 -> NaN11
-dqrem765 remainder NaN6 NaN12 -> NaN6
-dqrem766 remainder Inf NaN13 -> NaN13
-dqrem767 remainder NaN14 -Inf -> NaN14
-dqrem768 remainder 0 NaN15 -> NaN15
-dqrem769 remainder NaN16 -0 -> NaN16
-
--- edge cases of impossible
-dqrem770 remainder 1234568888888887777777777890123456 10 -> 6
-dqrem771 remainder 1234568888888887777777777890123456 1 -> 0
-dqrem772 remainder 1234568888888887777777777890123456 0.1 -> NaN Division_impossible
-dqrem773 remainder 1234568888888887777777777890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-dqrem801 remainder 12345678000 100 -> 0
-dqrem802 remainder 1 12345678000 -> 1
-dqrem803 remainder 1234567800 10 -> 0
-dqrem804 remainder 1 1234567800 -> 1
-dqrem805 remainder 1234567890 10 -> 0
-dqrem806 remainder 1 1234567890 -> 1
-dqrem807 remainder 1234567891 10 -> 1
-dqrem808 remainder 1 1234567891 -> 1
-dqrem809 remainder 12345678901 100 -> 1
-dqrem810 remainder 1 12345678901 -> 1
-dqrem811 remainder 1234567896 10 -> 6
-dqrem812 remainder 1 1234567896 -> 1
-
-dqrem821 remainder 12345678000 100 -> 0
-dqrem822 remainder 1 12345678000 -> 1
-dqrem823 remainder 1234567800 10 -> 0
-dqrem824 remainder 1 1234567800 -> 1
-dqrem825 remainder 1234567890 10 -> 0
-dqrem826 remainder 1 1234567890 -> 1
-dqrem827 remainder 1234567891 10 -> 1
-dqrem828 remainder 1 1234567891 -> 1
-dqrem829 remainder 12345678901 100 -> 1
-dqrem830 remainder 1 12345678901 -> 1
-dqrem831 remainder 1234567896 10 -> 6
-dqrem832 remainder 1 1234567896 -> 1
-
--- from divideint
-dqrem840 remainder 100000000.0 1 -> 0.0
-dqrem841 remainder 100000000.4 1 -> 0.4
-dqrem842 remainder 100000000.5 1 -> 0.5
-dqrem843 remainder 100000000.9 1 -> 0.9
-dqrem844 remainder 100000000.999 1 -> 0.999
-dqrem850 remainder 100000003 5 -> 3
-dqrem851 remainder 10000003 5 -> 3
-dqrem852 remainder 1000003 5 -> 3
-dqrem853 remainder 100003 5 -> 3
-dqrem854 remainder 10003 5 -> 3
-dqrem855 remainder 1003 5 -> 3
-dqrem856 remainder 103 5 -> 3
-dqrem857 remainder 13 5 -> 3
-dqrem858 remainder 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-dqrem860 remainder 123.0e1 1000000000000000 -> 1230
-dqrem861 remainder 1230 1000000000000000 -> 1230
-dqrem862 remainder 12.3e2 1000000000000000 -> 1230
-dqrem863 remainder 1.23e3 1000000000000000 -> 1230
-dqrem864 remainder 123e1 1000000000000000 -> 1230
-dqrem870 remainder 123e1 1000000000000000 -> 1230
-dqrem871 remainder 123e1 100000000000000 -> 1230
-dqrem872 remainder 123e1 10000000000000 -> 1230
-dqrem873 remainder 123e1 1000000000000 -> 1230
-dqrem874 remainder 123e1 100000000000 -> 1230
-dqrem875 remainder 123e1 10000000000 -> 1230
-dqrem876 remainder 123e1 1000000000 -> 1230
-dqrem877 remainder 123e1 100000000 -> 1230
-dqrem878 remainder 1230 100000000 -> 1230
-dqrem879 remainder 123e1 10000000 -> 1230
-dqrem880 remainder 123e1 1000000 -> 1230
-dqrem881 remainder 123e1 100000 -> 1230
-dqrem882 remainder 123e1 10000 -> 1230
-dqrem883 remainder 123e1 1000 -> 230
-dqrem884 remainder 123e1 100 -> 30
-dqrem885 remainder 123e1 10 -> 0
-dqrem886 remainder 123e1 1 -> 0
-
-dqrem890 remainder 123e1 2000000000000000 -> 1230
-dqrem891 remainder 123e1 200000000000000 -> 1230
-dqrem892 remainder 123e1 20000000000000 -> 1230
-dqrem893 remainder 123e1 2000000000000 -> 1230
-dqrem894 remainder 123e1 200000000000 -> 1230
-dqrem895 remainder 123e1 20000000000 -> 1230
-dqrem896 remainder 123e1 2000000000 -> 1230
-dqrem897 remainder 123e1 200000000 -> 1230
-dqrem899 remainder 123e1 20000000 -> 1230
-dqrem900 remainder 123e1 2000000 -> 1230
-dqrem901 remainder 123e1 200000 -> 1230
-dqrem902 remainder 123e1 20000 -> 1230
-dqrem903 remainder 123e1 2000 -> 1230
-dqrem904 remainder 123e1 200 -> 30
-dqrem905 remainder 123e1 20 -> 10
-dqrem906 remainder 123e1 2 -> 0
-
-dqrem910 remainder 123e1 5000000000000000 -> 1230
-dqrem911 remainder 123e1 500000000000000 -> 1230
-dqrem912 remainder 123e1 50000000000000 -> 1230
-dqrem913 remainder 123e1 5000000000000 -> 1230
-dqrem914 remainder 123e1 500000000000 -> 1230
-dqrem915 remainder 123e1 50000000000 -> 1230
-dqrem916 remainder 123e1 5000000000 -> 1230
-dqrem917 remainder 123e1 500000000 -> 1230
-dqrem919 remainder 123e1 50000000 -> 1230
-dqrem920 remainder 123e1 5000000 -> 1230
-dqrem921 remainder 123e1 500000 -> 1230
-dqrem922 remainder 123e1 50000 -> 1230
-dqrem923 remainder 123e1 5000 -> 1230
-dqrem924 remainder 123e1 500 -> 230
-dqrem925 remainder 123e1 50 -> 30
-dqrem926 remainder 123e1 5 -> 0
-
-dqrem930 remainder 123e1 9000000000000000 -> 1230
-dqrem931 remainder 123e1 900000000000000 -> 1230
-dqrem932 remainder 123e1 90000000000000 -> 1230
-dqrem933 remainder 123e1 9000000000000 -> 1230
-dqrem934 remainder 123e1 900000000000 -> 1230
-dqrem935 remainder 123e1 90000000000 -> 1230
-dqrem936 remainder 123e1 9000000000 -> 1230
-dqrem937 remainder 123e1 900000000 -> 1230
-dqrem939 remainder 123e1 90000000 -> 1230
-dqrem940 remainder 123e1 9000000 -> 1230
-dqrem941 remainder 123e1 900000 -> 1230
-dqrem942 remainder 123e1 90000 -> 1230
-dqrem943 remainder 123e1 9000 -> 1230
-dqrem944 remainder 123e1 900 -> 330
-dqrem945 remainder 123e1 90 -> 60
-dqrem946 remainder 123e1 9 -> 6
-
-dqrem950 remainder 123e1 1000000000000000 -> 1230
-dqrem961 remainder 123e1 2999999999999999 -> 1230
-dqrem962 remainder 123e1 3999999999999999 -> 1230
-dqrem963 remainder 123e1 4999999999999999 -> 1230
-dqrem964 remainder 123e1 5999999999999999 -> 1230
-dqrem965 remainder 123e1 6999999999999999 -> 1230
-dqrem966 remainder 123e1 7999999999999999 -> 1230
-dqrem967 remainder 123e1 8999999999999999 -> 1230
-dqrem968 remainder 123e1 9999999999999999 -> 1230
-dqrem969 remainder 123e1 9876543210987654 -> 1230
-
-dqrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-dqrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
-dqrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
-dqrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
-dqrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
-dqrem1055 remainder 1e-277 1e+311 -> 1E-277
-dqrem1056 remainder 1e-277 -1e+311 -> 1E-277
-dqrem1057 remainder -1e-277 1e+311 -> -1E-277
-dqrem1058 remainder -1e-277 -1e+311 -> -1E-277
-
--- Gyuris example
-dqrem1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
-
--- destructive subtract
-dqrem1120 remainder 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> 0.765432109876543210987654321098768
-dqrem1121 remainder 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> 0.65432109876543210987654321098779
-dqrem1122 remainder 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> 0.5432109876543210987654321098890
-dqrem1123 remainder 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> 2.691358027469135802746913580274687
-dqrem1124 remainder 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
-dqrem1125 remainder 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> 3.6913578024691357802469135780251
-dqrem1126 remainder 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
-dqrem1127 remainder 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> 4.246913578024691357802469135780246
-dqrem1128 remainder 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> 4.3086421975308642197530864219759
-
--- Null tests
-dqrem1000 remainder 10 # -> NaN Invalid_operation
-dqrem1001 remainder # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqRemainder.decTest -- decQuad remainder --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks (as base, above)
+dqrem001 remainder 1 1 -> 0
+dqrem002 remainder 2 1 -> 0
+dqrem003 remainder 1 2 -> 1
+dqrem004 remainder 2 2 -> 0
+dqrem005 remainder 0 1 -> 0
+dqrem006 remainder 0 2 -> 0
+dqrem007 remainder 1 3 -> 1
+dqrem008 remainder 2 3 -> 2
+dqrem009 remainder 3 3 -> 0
+
+dqrem010 remainder 2.4 1 -> 0.4
+dqrem011 remainder 2.4 -1 -> 0.4
+dqrem012 remainder -2.4 1 -> -0.4
+dqrem013 remainder -2.4 -1 -> -0.4
+dqrem014 remainder 2.40 1 -> 0.40
+dqrem015 remainder 2.400 1 -> 0.400
+dqrem016 remainder 2.4 2 -> 0.4
+dqrem017 remainder 2.400 2 -> 0.400
+dqrem018 remainder 2. 2 -> 0
+dqrem019 remainder 20 20 -> 0
+
+dqrem020 remainder 187 187 -> 0
+dqrem021 remainder 5 2 -> 1
+dqrem022 remainder 5 2.0 -> 1.0
+dqrem023 remainder 5 2.000 -> 1.000
+dqrem024 remainder 5 0.200 -> 0.000
+dqrem025 remainder 5 0.200 -> 0.000
+
+dqrem030 remainder 1 2 -> 1
+dqrem031 remainder 1 4 -> 1
+dqrem032 remainder 1 8 -> 1
+
+dqrem033 remainder 1 16 -> 1
+dqrem034 remainder 1 32 -> 1
+dqrem035 remainder 1 64 -> 1
+dqrem040 remainder 1 -2 -> 1
+dqrem041 remainder 1 -4 -> 1
+dqrem042 remainder 1 -8 -> 1
+dqrem043 remainder 1 -16 -> 1
+dqrem044 remainder 1 -32 -> 1
+dqrem045 remainder 1 -64 -> 1
+dqrem050 remainder -1 2 -> -1
+dqrem051 remainder -1 4 -> -1
+dqrem052 remainder -1 8 -> -1
+dqrem053 remainder -1 16 -> -1
+dqrem054 remainder -1 32 -> -1
+dqrem055 remainder -1 64 -> -1
+dqrem060 remainder -1 -2 -> -1
+dqrem061 remainder -1 -4 -> -1
+dqrem062 remainder -1 -8 -> -1
+dqrem063 remainder -1 -16 -> -1
+dqrem064 remainder -1 -32 -> -1
+dqrem065 remainder -1 -64 -> -1
+
+dqrem066 remainder 999999999 1 -> 0
+dqrem067 remainder 999999999.4 1 -> 0.4
+dqrem068 remainder 999999999.5 1 -> 0.5
+dqrem069 remainder 999999999.9 1 -> 0.9
+dqrem070 remainder 999999999.999 1 -> 0.999
+dqrem071 remainder 999999.999999 1 -> 0.999999
+dqrem072 remainder 9 1 -> 0
+
+dqrem080 remainder 0. 1 -> 0
+dqrem081 remainder .0 1 -> 0.0
+dqrem082 remainder 0.00 1 -> 0.00
+dqrem083 remainder 0.00E+9 1 -> 0
+dqrem084 remainder 0.00E+3 1 -> 0
+dqrem085 remainder 0.00E+2 1 -> 0
+dqrem086 remainder 0.00E+1 1 -> 0.0
+dqrem087 remainder 0.00E+0 1 -> 0.00
+dqrem088 remainder 0.00E-0 1 -> 0.00
+dqrem089 remainder 0.00E-1 1 -> 0.000
+dqrem090 remainder 0.00E-2 1 -> 0.0000
+dqrem091 remainder 0.00E-3 1 -> 0.00000
+dqrem092 remainder 0.00E-4 1 -> 0.000000
+dqrem093 remainder 0.00E-5 1 -> 0E-7
+dqrem094 remainder 0.00E-6 1 -> 0E-8
+dqrem095 remainder 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remainder by 0
+dqrem101 remainder 0 0 -> NaN Division_undefined
+dqrem102 remainder 0 -0 -> NaN Division_undefined
+dqrem103 remainder -0 0 -> NaN Division_undefined
+dqrem104 remainder -0 -0 -> NaN Division_undefined
+dqrem105 remainder 0.0E5 0 -> NaN Division_undefined
+dqrem106 remainder 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+dqrem107 remainder 0.0001 0 -> NaN Invalid_operation
+dqrem108 remainder 0.01 0 -> NaN Invalid_operation
+dqrem109 remainder 0.1 0 -> NaN Invalid_operation
+dqrem110 remainder 1 0 -> NaN Invalid_operation
+dqrem111 remainder 1 0.0 -> NaN Invalid_operation
+dqrem112 remainder 10 0.0 -> NaN Invalid_operation
+dqrem113 remainder 1E+100 0.0 -> NaN Invalid_operation
+dqrem114 remainder 1E+380 0 -> NaN Invalid_operation
+dqrem115 remainder 0.0001 -0 -> NaN Invalid_operation
+dqrem116 remainder 0.01 -0 -> NaN Invalid_operation
+dqrem119 remainder 0.1 -0 -> NaN Invalid_operation
+dqrem120 remainder 1 -0 -> NaN Invalid_operation
+dqrem121 remainder 1 -0.0 -> NaN Invalid_operation
+dqrem122 remainder 10 -0.0 -> NaN Invalid_operation
+dqrem123 remainder 1E+100 -0.0 -> NaN Invalid_operation
+dqrem124 remainder 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+dqrem130 remainder 0 1 -> 0
+dqrem131 remainder 0 -1 -> 0
+dqrem132 remainder 0.0 1 -> 0.0
+dqrem133 remainder 0.0 -1 -> 0.0
+dqrem134 remainder -0 1 -> -0
+dqrem135 remainder -0 -1 -> -0
+dqrem136 remainder -0.0 1 -> -0.0
+dqrem137 remainder -0.0 -1 -> -0.0
+
+-- 0.5ers
+dqrem143 remainder 0.5 2 -> 0.5
+dqrem144 remainder 0.5 2.1 -> 0.5
+dqrem145 remainder 0.5 2.01 -> 0.50
+dqrem146 remainder 0.5 2.001 -> 0.500
+dqrem147 remainder 0.50 2 -> 0.50
+dqrem148 remainder 0.50 2.01 -> 0.50
+dqrem149 remainder 0.50 2.001 -> 0.500
+
+-- steadies
+dqrem150 remainder 1 1 -> 0
+dqrem151 remainder 1 2 -> 1
+dqrem152 remainder 1 3 -> 1
+dqrem153 remainder 1 4 -> 1
+dqrem154 remainder 1 5 -> 1
+dqrem155 remainder 1 6 -> 1
+dqrem156 remainder 1 7 -> 1
+dqrem157 remainder 1 8 -> 1
+dqrem158 remainder 1 9 -> 1
+dqrem159 remainder 1 10 -> 1
+dqrem160 remainder 1 1 -> 0
+dqrem161 remainder 2 1 -> 0
+dqrem162 remainder 3 1 -> 0
+dqrem163 remainder 4 1 -> 0
+dqrem164 remainder 5 1 -> 0
+dqrem165 remainder 6 1 -> 0
+dqrem166 remainder 7 1 -> 0
+dqrem167 remainder 8 1 -> 0
+dqrem168 remainder 9 1 -> 0
+dqrem169 remainder 10 1 -> 0
+
+-- some differences from remainderNear
+dqrem171 remainder 0.4 1.020 -> 0.400
+dqrem172 remainder 0.50 1.020 -> 0.500
+dqrem173 remainder 0.51 1.020 -> 0.510
+dqrem174 remainder 0.52 1.020 -> 0.520
+dqrem175 remainder 0.6 1.020 -> 0.600
+
+-- More flavours of remainder by 0
+dqrem201 remainder 0 0 -> NaN Division_undefined
+dqrem202 remainder 0.0E5 0 -> NaN Division_undefined
+dqrem203 remainder 0.000 0 -> NaN Division_undefined
+dqrem204 remainder 0.0001 0 -> NaN Invalid_operation
+dqrem205 remainder 0.01 0 -> NaN Invalid_operation
+dqrem206 remainder 0.1 0 -> NaN Invalid_operation
+dqrem207 remainder 1 0 -> NaN Invalid_operation
+dqrem208 remainder 1 0.0 -> NaN Invalid_operation
+dqrem209 remainder 10 0.0 -> NaN Invalid_operation
+dqrem210 remainder 1E+100 0.0 -> NaN Invalid_operation
+dqrem211 remainder 1E+380 0 -> NaN Invalid_operation
+
+-- some differences from remainderNear
+dqrem231 remainder -0.4 1.020 -> -0.400
+dqrem232 remainder -0.50 1.020 -> -0.500
+dqrem233 remainder -0.51 1.020 -> -0.510
+dqrem234 remainder -0.52 1.020 -> -0.520
+dqrem235 remainder -0.6 1.020 -> -0.600
+
+-- high Xs
+dqrem240 remainder 1E+2 1.00 -> 0.00
+
+-- dqrem3xx are from DiagBigDecimal
+dqrem301 remainder 1 3 -> 1
+dqrem302 remainder 5 5 -> 0
+dqrem303 remainder 13 10 -> 3
+dqrem304 remainder 13 50 -> 13
+dqrem305 remainder 13 100 -> 13
+dqrem306 remainder 13 1000 -> 13
+dqrem307 remainder .13 1 -> 0.13
+dqrem308 remainder 0.133 1 -> 0.133
+dqrem309 remainder 0.1033 1 -> 0.1033
+dqrem310 remainder 1.033 1 -> 0.033
+dqrem311 remainder 10.33 1 -> 0.33
+dqrem312 remainder 10.33 10 -> 0.33
+dqrem313 remainder 103.3 1 -> 0.3
+dqrem314 remainder 133 10 -> 3
+dqrem315 remainder 1033 10 -> 3
+dqrem316 remainder 1033 50 -> 33
+dqrem317 remainder 101.0 3 -> 2.0
+dqrem318 remainder 102.0 3 -> 0.0
+dqrem319 remainder 103.0 3 -> 1.0
+dqrem320 remainder 2.40 1 -> 0.40
+dqrem321 remainder 2.400 1 -> 0.400
+dqrem322 remainder 2.4 1 -> 0.4
+dqrem323 remainder 2.4 2 -> 0.4
+dqrem324 remainder 2.400 2 -> 0.400
+dqrem325 remainder 1 0.3 -> 0.1
+dqrem326 remainder 1 0.30 -> 0.10
+dqrem327 remainder 1 0.300 -> 0.100
+dqrem328 remainder 1 0.3000 -> 0.1000
+dqrem329 remainder 1.0 0.3 -> 0.1
+dqrem330 remainder 1.00 0.3 -> 0.10
+dqrem331 remainder 1.000 0.3 -> 0.100
+dqrem332 remainder 1.0000 0.3 -> 0.1000
+dqrem333 remainder 0.5 2 -> 0.5
+dqrem334 remainder 0.5 2.1 -> 0.5
+dqrem335 remainder 0.5 2.01 -> 0.50
+dqrem336 remainder 0.5 2.001 -> 0.500
+dqrem337 remainder 0.50 2 -> 0.50
+dqrem338 remainder 0.50 2.01 -> 0.50
+dqrem339 remainder 0.50 2.001 -> 0.500
+
+dqrem340 remainder 0.5 0.5000001 -> 0.5000000
+dqrem341 remainder 0.5 0.50000001 -> 0.50000000
+dqrem342 remainder 0.5 0.500000001 -> 0.500000000
+dqrem343 remainder 0.5 0.5000000001 -> 0.5000000000
+dqrem344 remainder 0.5 0.50000000001 -> 0.50000000000
+dqrem345 remainder 0.5 0.4999999 -> 1E-7
+dqrem346 remainder 0.5 0.49999999 -> 1E-8
+dqrem347 remainder 0.5 0.499999999 -> 1E-9
+dqrem348 remainder 0.5 0.4999999999 -> 1E-10
+dqrem349 remainder 0.5 0.49999999999 -> 1E-11
+dqrem350 remainder 0.5 0.499999999999 -> 1E-12
+
+dqrem351 remainder 0.03 7 -> 0.03
+dqrem352 remainder 5 2 -> 1
+dqrem353 remainder 4.1 2 -> 0.1
+dqrem354 remainder 4.01 2 -> 0.01
+dqrem355 remainder 4.001 2 -> 0.001
+dqrem356 remainder 4.0001 2 -> 0.0001
+dqrem357 remainder 4.00001 2 -> 0.00001
+dqrem358 remainder 4.000001 2 -> 0.000001
+dqrem359 remainder 4.0000001 2 -> 1E-7
+
+dqrem360 remainder 1.2 0.7345 -> 0.4655
+dqrem361 remainder 0.8 12 -> 0.8
+dqrem362 remainder 0.8 0.2 -> 0.0
+dqrem363 remainder 0.8 0.3 -> 0.2
+dqrem364 remainder 0.800 12 -> 0.800
+dqrem365 remainder 0.800 1.7 -> 0.800
+dqrem366 remainder 2.400 2 -> 0.400
+
+dqrem371 remainder 2.400 2 -> 0.400
+
+dqrem381 remainder 12345 1 -> 0
+dqrem382 remainder 12345 1.0001 -> 0.7657
+dqrem383 remainder 12345 1.001 -> 0.668
+dqrem384 remainder 12345 1.01 -> 0.78
+dqrem385 remainder 12345 1.1 -> 0.8
+dqrem386 remainder 12355 4 -> 3
+dqrem387 remainder 12345 4 -> 1
+dqrem388 remainder 12355 4.0001 -> 2.6912
+dqrem389 remainder 12345 4.0001 -> 0.6914
+dqrem390 remainder 12345 4.9 -> 1.9
+dqrem391 remainder 12345 4.99 -> 4.73
+dqrem392 remainder 12345 4.999 -> 2.469
+dqrem393 remainder 12345 4.9999 -> 0.2469
+dqrem394 remainder 12345 5 -> 0
+dqrem395 remainder 12345 5.0001 -> 4.7532
+dqrem396 remainder 12345 5.001 -> 2.532
+dqrem397 remainder 12345 5.01 -> 0.36
+dqrem398 remainder 12345 5.1 -> 3.0
+
+-- the nasty division-by-1 cases
+dqrem401 remainder 0.5 1 -> 0.5
+dqrem402 remainder 0.55 1 -> 0.55
+dqrem403 remainder 0.555 1 -> 0.555
+dqrem404 remainder 0.5555 1 -> 0.5555
+dqrem405 remainder 0.55555 1 -> 0.55555
+dqrem406 remainder 0.555555 1 -> 0.555555
+dqrem407 remainder 0.5555555 1 -> 0.5555555
+dqrem408 remainder 0.55555555 1 -> 0.55555555
+dqrem409 remainder 0.555555555 1 -> 0.555555555
+
+-- folddowns
+dqrem421 remainder 1E+6144 1 -> NaN Division_impossible
+dqrem422 remainder 1E+6144 1E+6143 -> 0E+6111 Clamped
+dqrem423 remainder 1E+6144 2E+6143 -> 0E+6111 Clamped
+dqrem424 remainder 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqrem425 remainder 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrem426 remainder 1E+6144 5E+6143 -> 0E+6111 Clamped
+dqrem427 remainder 1E+6144 6E+6143 -> 4.00000000000000000000000000000000E+6143 Clamped
+dqrem428 remainder 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
+dqrem429 remainder 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrem430 remainder 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+-- tinies
+dqrem431 remainder 1E-6175 1E-6176 -> 0E-6176
+dqrem432 remainder 1E-6175 2E-6176 -> 0E-6176
+dqrem433 remainder 1E-6175 3E-6176 -> 1E-6176 Subnormal
+dqrem434 remainder 1E-6175 4E-6176 -> 2E-6176 Subnormal
+dqrem435 remainder 1E-6175 5E-6176 -> 0E-6176
+dqrem436 remainder 1E-6175 6E-6176 -> 4E-6176 Subnormal
+dqrem437 remainder 1E-6175 7E-6176 -> 3E-6176 Subnormal
+dqrem438 remainder 1E-6175 8E-6176 -> 2E-6176 Subnormal
+dqrem439 remainder 1E-6175 9E-6176 -> 1E-6176 Subnormal
+dqrem440 remainder 1E-6175 10E-6176 -> 0E-6176
+dqrem441 remainder 1E-6175 11E-6176 -> 1.0E-6175 Subnormal
+dqrem442 remainder 100E-6175 11E-6176 -> 1.0E-6175 Subnormal
+dqrem443 remainder 100E-6175 20E-6176 -> 0E-6176
+dqrem444 remainder 100E-6175 21E-6176 -> 1.3E-6175 Subnormal
+dqrem445 remainder 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
+
+-- zero signs
+dqrem650 remainder 1 1 -> 0
+dqrem651 remainder -1 1 -> -0
+dqrem652 remainder 1 -1 -> 0
+dqrem653 remainder -1 -1 -> -0
+dqrem654 remainder 0 1 -> 0
+dqrem655 remainder -0 1 -> -0
+dqrem656 remainder 0 -1 -> 0
+dqrem657 remainder -0 -1 -> -0
+dqrem658 remainder 0.00 1 -> 0.00
+dqrem659 remainder -0.00 1 -> -0.00
+
+-- Specials
+dqrem680 remainder Inf -Inf -> NaN Invalid_operation
+dqrem681 remainder Inf -1000 -> NaN Invalid_operation
+dqrem682 remainder Inf -1 -> NaN Invalid_operation
+dqrem683 remainder Inf 0 -> NaN Invalid_operation
+dqrem684 remainder Inf -0 -> NaN Invalid_operation
+dqrem685 remainder Inf 1 -> NaN Invalid_operation
+dqrem686 remainder Inf 1000 -> NaN Invalid_operation
+dqrem687 remainder Inf Inf -> NaN Invalid_operation
+dqrem688 remainder -1000 Inf -> -1000
+dqrem689 remainder -Inf Inf -> NaN Invalid_operation
+dqrem691 remainder -1 Inf -> -1
+dqrem692 remainder 0 Inf -> 0
+dqrem693 remainder -0 Inf -> -0
+dqrem694 remainder 1 Inf -> 1
+dqrem695 remainder 1000 Inf -> 1000
+dqrem696 remainder Inf Inf -> NaN Invalid_operation
+
+dqrem700 remainder -Inf -Inf -> NaN Invalid_operation
+dqrem701 remainder -Inf -1000 -> NaN Invalid_operation
+dqrem702 remainder -Inf -1 -> NaN Invalid_operation
+dqrem703 remainder -Inf -0 -> NaN Invalid_operation
+dqrem704 remainder -Inf 0 -> NaN Invalid_operation
+dqrem705 remainder -Inf 1 -> NaN Invalid_operation
+dqrem706 remainder -Inf 1000 -> NaN Invalid_operation
+dqrem707 remainder -Inf Inf -> NaN Invalid_operation
+dqrem708 remainder -Inf -Inf -> NaN Invalid_operation
+dqrem709 remainder -1000 Inf -> -1000
+dqrem710 remainder -1 -Inf -> -1
+dqrem711 remainder -0 -Inf -> -0
+dqrem712 remainder 0 -Inf -> 0
+dqrem713 remainder 1 -Inf -> 1
+dqrem714 remainder 1000 -Inf -> 1000
+dqrem715 remainder Inf -Inf -> NaN Invalid_operation
+
+dqrem721 remainder NaN -Inf -> NaN
+dqrem722 remainder NaN -1000 -> NaN
+dqrem723 remainder NaN -1 -> NaN
+dqrem724 remainder NaN -0 -> NaN
+dqrem725 remainder -NaN 0 -> -NaN
+dqrem726 remainder NaN 1 -> NaN
+dqrem727 remainder NaN 1000 -> NaN
+dqrem728 remainder NaN Inf -> NaN
+dqrem729 remainder NaN -NaN -> NaN
+dqrem730 remainder -Inf NaN -> NaN
+dqrem731 remainder -1000 NaN -> NaN
+dqrem732 remainder -1 NaN -> NaN
+dqrem733 remainder -0 -NaN -> -NaN
+dqrem734 remainder 0 NaN -> NaN
+dqrem735 remainder 1 -NaN -> -NaN
+dqrem736 remainder 1000 NaN -> NaN
+dqrem737 remainder Inf NaN -> NaN
+
+dqrem741 remainder sNaN -Inf -> NaN Invalid_operation
+dqrem742 remainder sNaN -1000 -> NaN Invalid_operation
+dqrem743 remainder -sNaN -1 -> -NaN Invalid_operation
+dqrem744 remainder sNaN -0 -> NaN Invalid_operation
+dqrem745 remainder sNaN 0 -> NaN Invalid_operation
+dqrem746 remainder sNaN 1 -> NaN Invalid_operation
+dqrem747 remainder sNaN 1000 -> NaN Invalid_operation
+dqrem749 remainder sNaN NaN -> NaN Invalid_operation
+dqrem750 remainder sNaN sNaN -> NaN Invalid_operation
+dqrem751 remainder NaN sNaN -> NaN Invalid_operation
+dqrem752 remainder -Inf sNaN -> NaN Invalid_operation
+dqrem753 remainder -1000 sNaN -> NaN Invalid_operation
+dqrem754 remainder -1 sNaN -> NaN Invalid_operation
+dqrem755 remainder -0 sNaN -> NaN Invalid_operation
+dqrem756 remainder 0 sNaN -> NaN Invalid_operation
+dqrem757 remainder 1 sNaN -> NaN Invalid_operation
+dqrem758 remainder 1000 sNaN -> NaN Invalid_operation
+dqrem759 remainder Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+dqrem760 remainder NaN1 NaN7 -> NaN1
+dqrem761 remainder sNaN2 NaN8 -> NaN2 Invalid_operation
+dqrem762 remainder NaN3 sNaN9 -> NaN9 Invalid_operation
+dqrem763 remainder sNaN4 sNaN10 -> NaN4 Invalid_operation
+dqrem764 remainder 15 NaN11 -> NaN11
+dqrem765 remainder NaN6 NaN12 -> NaN6
+dqrem766 remainder Inf NaN13 -> NaN13
+dqrem767 remainder NaN14 -Inf -> NaN14
+dqrem768 remainder 0 NaN15 -> NaN15
+dqrem769 remainder NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+dqrem770 remainder 1234568888888887777777777890123456 10 -> 6
+dqrem771 remainder 1234568888888887777777777890123456 1 -> 0
+dqrem772 remainder 1234568888888887777777777890123456 0.1 -> NaN Division_impossible
+dqrem773 remainder 1234568888888887777777777890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+dqrem801 remainder 12345678000 100 -> 0
+dqrem802 remainder 1 12345678000 -> 1
+dqrem803 remainder 1234567800 10 -> 0
+dqrem804 remainder 1 1234567800 -> 1
+dqrem805 remainder 1234567890 10 -> 0
+dqrem806 remainder 1 1234567890 -> 1
+dqrem807 remainder 1234567891 10 -> 1
+dqrem808 remainder 1 1234567891 -> 1
+dqrem809 remainder 12345678901 100 -> 1
+dqrem810 remainder 1 12345678901 -> 1
+dqrem811 remainder 1234567896 10 -> 6
+dqrem812 remainder 1 1234567896 -> 1
+
+dqrem821 remainder 12345678000 100 -> 0
+dqrem822 remainder 1 12345678000 -> 1
+dqrem823 remainder 1234567800 10 -> 0
+dqrem824 remainder 1 1234567800 -> 1
+dqrem825 remainder 1234567890 10 -> 0
+dqrem826 remainder 1 1234567890 -> 1
+dqrem827 remainder 1234567891 10 -> 1
+dqrem828 remainder 1 1234567891 -> 1
+dqrem829 remainder 12345678901 100 -> 1
+dqrem830 remainder 1 12345678901 -> 1
+dqrem831 remainder 1234567896 10 -> 6
+dqrem832 remainder 1 1234567896 -> 1
+
+-- from divideint
+dqrem840 remainder 100000000.0 1 -> 0.0
+dqrem841 remainder 100000000.4 1 -> 0.4
+dqrem842 remainder 100000000.5 1 -> 0.5
+dqrem843 remainder 100000000.9 1 -> 0.9
+dqrem844 remainder 100000000.999 1 -> 0.999
+dqrem850 remainder 100000003 5 -> 3
+dqrem851 remainder 10000003 5 -> 3
+dqrem852 remainder 1000003 5 -> 3
+dqrem853 remainder 100003 5 -> 3
+dqrem854 remainder 10003 5 -> 3
+dqrem855 remainder 1003 5 -> 3
+dqrem856 remainder 103 5 -> 3
+dqrem857 remainder 13 5 -> 3
+dqrem858 remainder 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+dqrem860 remainder 123.0e1 1000000000000000 -> 1230
+dqrem861 remainder 1230 1000000000000000 -> 1230
+dqrem862 remainder 12.3e2 1000000000000000 -> 1230
+dqrem863 remainder 1.23e3 1000000000000000 -> 1230
+dqrem864 remainder 123e1 1000000000000000 -> 1230
+dqrem870 remainder 123e1 1000000000000000 -> 1230
+dqrem871 remainder 123e1 100000000000000 -> 1230
+dqrem872 remainder 123e1 10000000000000 -> 1230
+dqrem873 remainder 123e1 1000000000000 -> 1230
+dqrem874 remainder 123e1 100000000000 -> 1230
+dqrem875 remainder 123e1 10000000000 -> 1230
+dqrem876 remainder 123e1 1000000000 -> 1230
+dqrem877 remainder 123e1 100000000 -> 1230
+dqrem878 remainder 1230 100000000 -> 1230
+dqrem879 remainder 123e1 10000000 -> 1230
+dqrem880 remainder 123e1 1000000 -> 1230
+dqrem881 remainder 123e1 100000 -> 1230
+dqrem882 remainder 123e1 10000 -> 1230
+dqrem883 remainder 123e1 1000 -> 230
+dqrem884 remainder 123e1 100 -> 30
+dqrem885 remainder 123e1 10 -> 0
+dqrem886 remainder 123e1 1 -> 0
+
+dqrem890 remainder 123e1 2000000000000000 -> 1230
+dqrem891 remainder 123e1 200000000000000 -> 1230
+dqrem892 remainder 123e1 20000000000000 -> 1230
+dqrem893 remainder 123e1 2000000000000 -> 1230
+dqrem894 remainder 123e1 200000000000 -> 1230
+dqrem895 remainder 123e1 20000000000 -> 1230
+dqrem896 remainder 123e1 2000000000 -> 1230
+dqrem897 remainder 123e1 200000000 -> 1230
+dqrem899 remainder 123e1 20000000 -> 1230
+dqrem900 remainder 123e1 2000000 -> 1230
+dqrem901 remainder 123e1 200000 -> 1230
+dqrem902 remainder 123e1 20000 -> 1230
+dqrem903 remainder 123e1 2000 -> 1230
+dqrem904 remainder 123e1 200 -> 30
+dqrem905 remainder 123e1 20 -> 10
+dqrem906 remainder 123e1 2 -> 0
+
+dqrem910 remainder 123e1 5000000000000000 -> 1230
+dqrem911 remainder 123e1 500000000000000 -> 1230
+dqrem912 remainder 123e1 50000000000000 -> 1230
+dqrem913 remainder 123e1 5000000000000 -> 1230
+dqrem914 remainder 123e1 500000000000 -> 1230
+dqrem915 remainder 123e1 50000000000 -> 1230
+dqrem916 remainder 123e1 5000000000 -> 1230
+dqrem917 remainder 123e1 500000000 -> 1230
+dqrem919 remainder 123e1 50000000 -> 1230
+dqrem920 remainder 123e1 5000000 -> 1230
+dqrem921 remainder 123e1 500000 -> 1230
+dqrem922 remainder 123e1 50000 -> 1230
+dqrem923 remainder 123e1 5000 -> 1230
+dqrem924 remainder 123e1 500 -> 230
+dqrem925 remainder 123e1 50 -> 30
+dqrem926 remainder 123e1 5 -> 0
+
+dqrem930 remainder 123e1 9000000000000000 -> 1230
+dqrem931 remainder 123e1 900000000000000 -> 1230
+dqrem932 remainder 123e1 90000000000000 -> 1230
+dqrem933 remainder 123e1 9000000000000 -> 1230
+dqrem934 remainder 123e1 900000000000 -> 1230
+dqrem935 remainder 123e1 90000000000 -> 1230
+dqrem936 remainder 123e1 9000000000 -> 1230
+dqrem937 remainder 123e1 900000000 -> 1230
+dqrem939 remainder 123e1 90000000 -> 1230
+dqrem940 remainder 123e1 9000000 -> 1230
+dqrem941 remainder 123e1 900000 -> 1230
+dqrem942 remainder 123e1 90000 -> 1230
+dqrem943 remainder 123e1 9000 -> 1230
+dqrem944 remainder 123e1 900 -> 330
+dqrem945 remainder 123e1 90 -> 60
+dqrem946 remainder 123e1 9 -> 6
+
+dqrem950 remainder 123e1 1000000000000000 -> 1230
+dqrem961 remainder 123e1 2999999999999999 -> 1230
+dqrem962 remainder 123e1 3999999999999999 -> 1230
+dqrem963 remainder 123e1 4999999999999999 -> 1230
+dqrem964 remainder 123e1 5999999999999999 -> 1230
+dqrem965 remainder 123e1 6999999999999999 -> 1230
+dqrem966 remainder 123e1 7999999999999999 -> 1230
+dqrem967 remainder 123e1 8999999999999999 -> 1230
+dqrem968 remainder 123e1 9999999999999999 -> 1230
+dqrem969 remainder 123e1 9876543210987654 -> 1230
+
+dqrem980 remainder 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+dqrem1051 remainder 1e+277 1e-311 -> NaN Division_impossible
+dqrem1052 remainder 1e+277 -1e-311 -> NaN Division_impossible
+dqrem1053 remainder -1e+277 1e-311 -> NaN Division_impossible
+dqrem1054 remainder -1e+277 -1e-311 -> NaN Division_impossible
+dqrem1055 remainder 1e-277 1e+311 -> 1E-277
+dqrem1056 remainder 1e-277 -1e+311 -> 1E-277
+dqrem1057 remainder -1e-277 1e+311 -> -1E-277
+dqrem1058 remainder -1e-277 -1e+311 -> -1E-277
+
+-- Gyuris example
+dqrem1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
+
+-- destructive subtract
+dqrem1120 remainder 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> 0.765432109876543210987654321098768
+dqrem1121 remainder 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> 0.65432109876543210987654321098779
+dqrem1122 remainder 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> 0.5432109876543210987654321098890
+dqrem1123 remainder 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> 2.691358027469135802746913580274687
+dqrem1124 remainder 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
+dqrem1125 remainder 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> 3.6913578024691357802469135780251
+dqrem1126 remainder 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
+dqrem1127 remainder 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> 4.246913578024691357802469135780246
+dqrem1128 remainder 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> 4.3086421975308642197530864219759
+
+-- Null tests
+dqrem1000 remainder 10 # -> NaN Invalid_operation
+dqrem1001 remainder # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqRemainderNear.decTest b/Lib/test/decimaltestdata/dqRemainderNear.decTest
index 0dd273fe38b..b850626fe4e 100644
--- a/Lib/test/decimaltestdata/dqRemainderNear.decTest
+++ b/Lib/test/decimaltestdata/dqRemainderNear.decTest
@@ -1,631 +1,631 @@
-------------------------------------------------------------------------
--- dqRemainderNear.decTest -- decQuad remainder-near --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- sanity checks (as base, above)
-dqrmn001 remaindernear 1 1 -> 0
-dqrmn002 remaindernear 2 1 -> 0
-dqrmn003 remaindernear 1 2 -> 1
-dqrmn004 remaindernear 2 2 -> 0
-dqrmn005 remaindernear 0 1 -> 0
-dqrmn006 remaindernear 0 2 -> 0
-dqrmn007 remaindernear 1 3 -> 1
-dqrmn008 remaindernear 2 3 -> -1
-dqrmn009 remaindernear 3 3 -> 0
-
-dqrmn010 remaindernear 2.4 1 -> 0.4
-dqrmn011 remaindernear 2.4 -1 -> 0.4
-dqrmn012 remaindernear -2.4 1 -> -0.4
-dqrmn013 remaindernear -2.4 -1 -> -0.4
-dqrmn014 remaindernear 2.40 1 -> 0.40
-dqrmn015 remaindernear 2.400 1 -> 0.400
-dqrmn016 remaindernear 2.4 2 -> 0.4
-dqrmn017 remaindernear 2.400 2 -> 0.400
-dqrmn018 remaindernear 2. 2 -> 0
-dqrmn019 remaindernear 20 20 -> 0
-
-dqrmn020 remaindernear 187 187 -> 0
-dqrmn021 remaindernear 5 2 -> 1
-dqrmn022 remaindernear 5 2.0 -> 1.0
-dqrmn023 remaindernear 5 2.000 -> 1.000
-dqrmn024 remaindernear 5 0.200 -> 0.000
-dqrmn025 remaindernear 5 0.200 -> 0.000
-
-dqrmn030 remaindernear 1 2 -> 1
-dqrmn031 remaindernear 1 4 -> 1
-dqrmn032 remaindernear 1 8 -> 1
-
-dqrmn033 remaindernear 1 16 -> 1
-dqrmn034 remaindernear 1 32 -> 1
-dqrmn035 remaindernear 1 64 -> 1
-dqrmn040 remaindernear 1 -2 -> 1
-dqrmn041 remaindernear 1 -4 -> 1
-dqrmn042 remaindernear 1 -8 -> 1
-dqrmn043 remaindernear 1 -16 -> 1
-dqrmn044 remaindernear 1 -32 -> 1
-dqrmn045 remaindernear 1 -64 -> 1
-dqrmn050 remaindernear -1 2 -> -1
-dqrmn051 remaindernear -1 4 -> -1
-dqrmn052 remaindernear -1 8 -> -1
-dqrmn053 remaindernear -1 16 -> -1
-dqrmn054 remaindernear -1 32 -> -1
-dqrmn055 remaindernear -1 64 -> -1
-dqrmn060 remaindernear -1 -2 -> -1
-dqrmn061 remaindernear -1 -4 -> -1
-dqrmn062 remaindernear -1 -8 -> -1
-dqrmn063 remaindernear -1 -16 -> -1
-dqrmn064 remaindernear -1 -32 -> -1
-dqrmn065 remaindernear -1 -64 -> -1
-
-dqrmn066 remaindernear 9.9 1 -> -0.1
-dqrmn067 remaindernear 99.7 1 -> -0.3
-dqrmn068 remaindernear 999999999 1 -> 0
-dqrmn069 remaindernear 999999999.4 1 -> 0.4
-dqrmn070 remaindernear 999999999.5 1 -> -0.5
-dqrmn071 remaindernear 999999999.9 1 -> -0.1
-dqrmn072 remaindernear 999999999.999 1 -> -0.001
-dqrmn073 remaindernear 999999.999999 1 -> -0.000001
-dqrmn074 remaindernear 9 1 -> 0
-dqrmn075 remaindernear 9999999999999999 1 -> 0
-dqrmn076 remaindernear 9999999999999999 2 -> -1
-dqrmn077 remaindernear 9999999999999999 3 -> 0
-dqrmn078 remaindernear 9999999999999999 4 -> -1
-
-dqrmn080 remaindernear 0. 1 -> 0
-dqrmn081 remaindernear .0 1 -> 0.0
-dqrmn082 remaindernear 0.00 1 -> 0.00
-dqrmn083 remaindernear 0.00E+9 1 -> 0
-dqrmn084 remaindernear 0.00E+3 1 -> 0
-dqrmn085 remaindernear 0.00E+2 1 -> 0
-dqrmn086 remaindernear 0.00E+1 1 -> 0.0
-dqrmn087 remaindernear 0.00E+0 1 -> 0.00
-dqrmn088 remaindernear 0.00E-0 1 -> 0.00
-dqrmn089 remaindernear 0.00E-1 1 -> 0.000
-dqrmn090 remaindernear 0.00E-2 1 -> 0.0000
-dqrmn091 remaindernear 0.00E-3 1 -> 0.00000
-dqrmn092 remaindernear 0.00E-4 1 -> 0.000000
-dqrmn093 remaindernear 0.00E-5 1 -> 0E-7
-dqrmn094 remaindernear 0.00E-6 1 -> 0E-8
-dqrmn095 remaindernear 0.0000E-50 1 -> 0E-54
-
--- Various flavours of remaindernear by 0
-dqrmn101 remaindernear 0 0 -> NaN Division_undefined
-dqrmn102 remaindernear 0 -0 -> NaN Division_undefined
-dqrmn103 remaindernear -0 0 -> NaN Division_undefined
-dqrmn104 remaindernear -0 -0 -> NaN Division_undefined
-dqrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
-dqrmn106 remaindernear 0.000 0 -> NaN Division_undefined
--- [Some think this next group should be Division_by_zero exception, but
--- IEEE 854 is explicit that it is Invalid operation .. for
--- remainder-near, anyway]
-dqrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
-dqrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
-dqrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
-dqrmn110 remaindernear 1 0 -> NaN Invalid_operation
-dqrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
-dqrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
-dqrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-dqrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
-dqrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
-dqrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
-dqrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
-dqrmn120 remaindernear 1 -0 -> NaN Invalid_operation
-dqrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
-dqrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
-dqrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
-dqrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
--- and zeros on left
-dqrmn130 remaindernear 0 1 -> 0
-dqrmn131 remaindernear 0 -1 -> 0
-dqrmn132 remaindernear 0.0 1 -> 0.0
-dqrmn133 remaindernear 0.0 -1 -> 0.0
-dqrmn134 remaindernear -0 1 -> -0
-dqrmn135 remaindernear -0 -1 -> -0
-dqrmn136 remaindernear -0.0 1 -> -0.0
-dqrmn137 remaindernear -0.0 -1 -> -0.0
-
--- 0.5ers
-dqrmn143 remaindernear 0.5 2 -> 0.5
-dqrmn144 remaindernear 0.5 2.1 -> 0.5
-dqrmn145 remaindernear 0.5 2.01 -> 0.50
-dqrmn146 remaindernear 0.5 2.001 -> 0.500
-dqrmn147 remaindernear 0.50 2 -> 0.50
-dqrmn148 remaindernear 0.50 2.01 -> 0.50
-dqrmn149 remaindernear 0.50 2.001 -> 0.500
-
--- steadies
-dqrmn150 remaindernear 1 1 -> 0
-dqrmn151 remaindernear 1 2 -> 1
-dqrmn152 remaindernear 1 3 -> 1
-dqrmn153 remaindernear 1 4 -> 1
-dqrmn154 remaindernear 1 5 -> 1
-dqrmn155 remaindernear 1 6 -> 1
-dqrmn156 remaindernear 1 7 -> 1
-dqrmn157 remaindernear 1 8 -> 1
-dqrmn158 remaindernear 1 9 -> 1
-dqrmn159 remaindernear 1 10 -> 1
-dqrmn160 remaindernear 1 1 -> 0
-dqrmn161 remaindernear 2 1 -> 0
-dqrmn162 remaindernear 3 1 -> 0
-dqrmn163 remaindernear 4 1 -> 0
-dqrmn164 remaindernear 5 1 -> 0
-dqrmn165 remaindernear 6 1 -> 0
-dqrmn166 remaindernear 7 1 -> 0
-dqrmn167 remaindernear 8 1 -> 0
-dqrmn168 remaindernear 9 1 -> 0
-dqrmn169 remaindernear 10 1 -> 0
-
--- some differences from remainder
-dqrmn171 remaindernear 0.4 1.020 -> 0.400
-dqrmn172 remaindernear 0.50 1.020 -> 0.500
-dqrmn173 remaindernear 0.51 1.020 -> 0.510
-dqrmn174 remaindernear 0.52 1.020 -> -0.500
-dqrmn175 remaindernear 0.6 1.020 -> -0.420
-
--- More flavours of remaindernear by 0
-dqrmn201 remaindernear 0 0 -> NaN Division_undefined
-dqrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
-dqrmn203 remaindernear 0.000 0 -> NaN Division_undefined
-dqrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
-dqrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
-dqrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
-dqrmn207 remaindernear 1 0 -> NaN Invalid_operation
-dqrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
-dqrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
-dqrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
-dqrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
-
--- tests from the extended specification
-dqrmn221 remaindernear 2.1 3 -> -0.9
-dqrmn222 remaindernear 10 6 -> -2
-dqrmn223 remaindernear 10 3 -> 1
-dqrmn224 remaindernear -10 3 -> -1
-dqrmn225 remaindernear 10.2 1 -> 0.2
-dqrmn226 remaindernear 10 0.3 -> 0.1
-dqrmn227 remaindernear 3.6 1.3 -> -0.3
-
--- some differences from remainder
-dqrmn231 remaindernear -0.4 1.020 -> -0.400
-dqrmn232 remaindernear -0.50 1.020 -> -0.500
-dqrmn233 remaindernear -0.51 1.020 -> -0.510
-dqrmn234 remaindernear -0.52 1.020 -> 0.500
-dqrmn235 remaindernear -0.6 1.020 -> 0.420
-
--- high Xs
-dqrmn240 remaindernear 1E+2 1.00 -> 0.00
-
--- dqrmn3xx are from DiagBigDecimal
-dqrmn301 remaindernear 1 3 -> 1
-dqrmn302 remaindernear 5 5 -> 0
-dqrmn303 remaindernear 13 10 -> 3
-dqrmn304 remaindernear 13 50 -> 13
-dqrmn305 remaindernear 13 100 -> 13
-dqrmn306 remaindernear 13 1000 -> 13
-dqrmn307 remaindernear .13 1 -> 0.13
-dqrmn308 remaindernear 0.133 1 -> 0.133
-dqrmn309 remaindernear 0.1033 1 -> 0.1033
-dqrmn310 remaindernear 1.033 1 -> 0.033
-dqrmn311 remaindernear 10.33 1 -> 0.33
-dqrmn312 remaindernear 10.33 10 -> 0.33
-dqrmn313 remaindernear 103.3 1 -> 0.3
-dqrmn314 remaindernear 133 10 -> 3
-dqrmn315 remaindernear 1033 10 -> 3
-dqrmn316 remaindernear 1033 50 -> -17
-dqrmn317 remaindernear 101.0 3 -> -1.0
-dqrmn318 remaindernear 102.0 3 -> 0.0
-dqrmn319 remaindernear 103.0 3 -> 1.0
-dqrmn320 remaindernear 2.40 1 -> 0.40
-dqrmn321 remaindernear 2.400 1 -> 0.400
-dqrmn322 remaindernear 2.4 1 -> 0.4
-dqrmn323 remaindernear 2.4 2 -> 0.4
-dqrmn324 remaindernear 2.400 2 -> 0.400
-dqrmn325 remaindernear 1 0.3 -> 0.1
-dqrmn326 remaindernear 1 0.30 -> 0.10
-dqrmn327 remaindernear 1 0.300 -> 0.100
-dqrmn328 remaindernear 1 0.3000 -> 0.1000
-dqrmn329 remaindernear 1.0 0.3 -> 0.1
-dqrmn330 remaindernear 1.00 0.3 -> 0.10
-dqrmn331 remaindernear 1.000 0.3 -> 0.100
-dqrmn332 remaindernear 1.0000 0.3 -> 0.1000
-dqrmn333 remaindernear 0.5 2 -> 0.5
-dqrmn334 remaindernear 0.5 2.1 -> 0.5
-dqrmn335 remaindernear 0.5 2.01 -> 0.50
-dqrmn336 remaindernear 0.5 2.001 -> 0.500
-dqrmn337 remaindernear 0.50 2 -> 0.50
-dqrmn338 remaindernear 0.50 2.01 -> 0.50
-dqrmn339 remaindernear 0.50 2.001 -> 0.500
-
-dqrmn340 remaindernear 0.5 0.5000001 -> -1E-7
-dqrmn341 remaindernear 0.5 0.50000001 -> -1E-8
-dqrmn342 remaindernear 0.5 0.500000001 -> -1E-9
-dqrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
-dqrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
-dqrmn345 remaindernear 0.5 0.4999999 -> 1E-7
-dqrmn346 remaindernear 0.5 0.49999999 -> 1E-8
-dqrmn347 remaindernear 0.5 0.499999999 -> 1E-9
-dqrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
-dqrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
-dqrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
-
-dqrmn351 remaindernear 0.03 7 -> 0.03
-dqrmn352 remaindernear 5 2 -> 1
-dqrmn353 remaindernear 4.1 2 -> 0.1
-dqrmn354 remaindernear 4.01 2 -> 0.01
-dqrmn355 remaindernear 4.001 2 -> 0.001
-dqrmn356 remaindernear 4.0001 2 -> 0.0001
-dqrmn357 remaindernear 4.00001 2 -> 0.00001
-dqrmn358 remaindernear 4.000001 2 -> 0.000001
-dqrmn359 remaindernear 4.0000001 2 -> 1E-7
-
-dqrmn360 remaindernear 1.2 0.7345 -> -0.2690
-dqrmn361 remaindernear 0.8 12 -> 0.8
-dqrmn362 remaindernear 0.8 0.2 -> 0.0
-dqrmn363 remaindernear 0.8 0.3 -> -0.1
-dqrmn364 remaindernear 0.800 12 -> 0.800
-dqrmn365 remaindernear 0.800 1.7 -> 0.800
-dqrmn366 remaindernear 2.400 2 -> 0.400
-
--- round to even
-dqrmn371 remaindernear 121 2 -> 1
-dqrmn372 remaindernear 122 2 -> 0
-dqrmn373 remaindernear 123 2 -> -1
-dqrmn374 remaindernear 124 2 -> 0
-dqrmn375 remaindernear 125 2 -> 1
-dqrmn376 remaindernear 126 2 -> 0
-dqrmn377 remaindernear 127 2 -> -1
-
-dqrmn381 remaindernear 12345 1 -> 0
-dqrmn382 remaindernear 12345 1.0001 -> -0.2344
-dqrmn383 remaindernear 12345 1.001 -> -0.333
-dqrmn384 remaindernear 12345 1.01 -> -0.23
-dqrmn385 remaindernear 12345 1.1 -> -0.3
-dqrmn386 remaindernear 12355 4 -> -1
-dqrmn387 remaindernear 12345 4 -> 1
-dqrmn388 remaindernear 12355 4.0001 -> -1.3089
-dqrmn389 remaindernear 12345 4.0001 -> 0.6914
-dqrmn390 remaindernear 12345 4.9 -> 1.9
-dqrmn391 remaindernear 12345 4.99 -> -0.26
-dqrmn392 remaindernear 12345 4.999 -> 2.469
-dqrmn393 remaindernear 12345 4.9999 -> 0.2469
-dqrmn394 remaindernear 12345 5 -> 0
-dqrmn395 remaindernear 12345 5.0001 -> -0.2469
-dqrmn396 remaindernear 12345 5.001 -> -2.469
-dqrmn397 remaindernear 12345 5.01 -> 0.36
-dqrmn398 remaindernear 12345 5.1 -> -2.1
-
--- the nasty division-by-1 cases
-dqrmn401 remaindernear 0.4 1 -> 0.4
-dqrmn402 remaindernear 0.45 1 -> 0.45
-dqrmn403 remaindernear 0.455 1 -> 0.455
-dqrmn404 remaindernear 0.4555 1 -> 0.4555
-dqrmn405 remaindernear 0.45555 1 -> 0.45555
-dqrmn406 remaindernear 0.455555 1 -> 0.455555
-dqrmn407 remaindernear 0.4555555 1 -> 0.4555555
-dqrmn408 remaindernear 0.45555555 1 -> 0.45555555
-dqrmn409 remaindernear 0.455555555 1 -> 0.455555555
--- with spill... [412 exercises sticktab loop]
-dqrmn411 remaindernear 0.5 1 -> 0.5
-dqrmn412 remaindernear 0.55 1 -> -0.45
-dqrmn413 remaindernear 0.555 1 -> -0.445
-dqrmn414 remaindernear 0.5555 1 -> -0.4445
-dqrmn415 remaindernear 0.55555 1 -> -0.44445
-dqrmn416 remaindernear 0.555555 1 -> -0.444445
-dqrmn417 remaindernear 0.5555555 1 -> -0.4444445
-dqrmn418 remaindernear 0.55555555 1 -> -0.44444445
-dqrmn419 remaindernear 0.555555555 1 -> -0.444444445
-
--- folddowns
-dqrmn421 remaindernear 1E+6144 1 -> NaN Division_impossible
-dqrmn422 remaindernear 1E+6144 1E+6143 -> 0E+6111 Clamped
-dqrmn423 remaindernear 1E+6144 2E+6143 -> 0E+6111 Clamped
-dqrmn424 remaindernear 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqrmn425 remaindernear 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrmn426 remaindernear 1E+6144 5E+6143 -> 0E+6111 Clamped
-dqrmn427 remaindernear 1E+6144 6E+6143 -> -2.00000000000000000000000000000000E+6143 Clamped
-dqrmn428 remaindernear 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
-dqrmn429 remaindernear 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
-dqrmn430 remaindernear 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
--- tinies
-dqrmn431 remaindernear 1E-6175 1E-6176 -> 0E-6176
-dqrmn432 remaindernear 1E-6175 2E-6176 -> 0E-6176
-dqrmn433 remaindernear 1E-6175 3E-6176 -> 1E-6176 Subnormal
-dqrmn434 remaindernear 1E-6175 4E-6176 -> 2E-6176 Subnormal
-dqrmn435 remaindernear 1E-6175 5E-6176 -> 0E-6176
-dqrmn436 remaindernear 1E-6175 6E-6176 -> -2E-6176 Subnormal
-dqrmn437 remaindernear 1E-6175 7E-6176 -> 3E-6176 Subnormal
-dqrmn438 remaindernear 1E-6175 8E-6176 -> 2E-6176 Subnormal
-dqrmn439 remaindernear 1E-6175 9E-6176 -> 1E-6176 Subnormal
-dqrmn440 remaindernear 1E-6175 10E-6176 -> 0E-6176
-dqrmn441 remaindernear 1E-6175 11E-6176 -> -1E-6176 Subnormal
-dqrmn442 remaindernear 100E-6175 11E-6176 -> -1E-6176 Subnormal
-dqrmn443 remaindernear 100E-6175 20E-6176 -> 0E-6176
-dqrmn444 remaindernear 100E-6175 21E-6176 -> -8E-6176 Subnormal
-dqrmn445 remaindernear 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
-
--- zero signs
-dqrmn650 remaindernear 1 1 -> 0
-dqrmn651 remaindernear -1 1 -> -0
-dqrmn652 remaindernear 1 -1 -> 0
-dqrmn653 remaindernear -1 -1 -> -0
-dqrmn654 remaindernear 0 1 -> 0
-dqrmn655 remaindernear -0 1 -> -0
-dqrmn656 remaindernear 0 -1 -> 0
-dqrmn657 remaindernear -0 -1 -> -0
-dqrmn658 remaindernear 0.00 1 -> 0.00
-dqrmn659 remaindernear -0.00 1 -> -0.00
-
--- Specials
-dqrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
-dqrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
-dqrmn682 remaindernear Inf -1 -> NaN Invalid_operation
-dqrmn683 remaindernear Inf 0 -> NaN Invalid_operation
-dqrmn684 remaindernear Inf -0 -> NaN Invalid_operation
-dqrmn685 remaindernear Inf 1 -> NaN Invalid_operation
-dqrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
-dqrmn687 remaindernear Inf Inf -> NaN Invalid_operation
-dqrmn688 remaindernear -1000 Inf -> -1000
-dqrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
-dqrmn691 remaindernear -1 Inf -> -1
-dqrmn692 remaindernear 0 Inf -> 0
-dqrmn693 remaindernear -0 Inf -> -0
-dqrmn694 remaindernear 1 Inf -> 1
-dqrmn695 remaindernear 1000 Inf -> 1000
-dqrmn696 remaindernear Inf Inf -> NaN Invalid_operation
-
-dqrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
-dqrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
-dqrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
-dqrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
-dqrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
-dqrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
-dqrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
-dqrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
-dqrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
-dqrmn709 remaindernear -1000 Inf -> -1000
-dqrmn710 remaindernear -1 -Inf -> -1
-dqrmn711 remaindernear -0 -Inf -> -0
-dqrmn712 remaindernear 0 -Inf -> 0
-dqrmn713 remaindernear 1 -Inf -> 1
-dqrmn714 remaindernear 1000 -Inf -> 1000
-dqrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
-
-dqrmn721 remaindernear NaN -Inf -> NaN
-dqrmn722 remaindernear NaN -1000 -> NaN
-dqrmn723 remaindernear NaN -1 -> NaN
-dqrmn724 remaindernear NaN -0 -> NaN
-dqrmn725 remaindernear -NaN 0 -> -NaN
-dqrmn726 remaindernear NaN 1 -> NaN
-dqrmn727 remaindernear NaN 1000 -> NaN
-dqrmn728 remaindernear NaN Inf -> NaN
-dqrmn729 remaindernear NaN -NaN -> NaN
-dqrmn730 remaindernear -Inf NaN -> NaN
-dqrmn731 remaindernear -1000 NaN -> NaN
-dqrmn732 remaindernear -1 NaN -> NaN
-dqrmn733 remaindernear -0 -NaN -> -NaN
-dqrmn734 remaindernear 0 NaN -> NaN
-dqrmn735 remaindernear 1 -NaN -> -NaN
-dqrmn736 remaindernear 1000 NaN -> NaN
-dqrmn737 remaindernear Inf NaN -> NaN
-
-dqrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
-dqrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
-dqrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
-dqrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
-dqrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
-dqrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
-dqrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
-dqrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
-dqrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
-dqrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
-dqrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
-dqrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
-dqrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
-dqrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
-dqrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
-dqrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
-dqrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
-dqrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
-
--- propaging NaNs
-dqrmn760 remaindernear NaN1 NaN7 -> NaN1
-dqrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
-dqrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
-dqrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
-dqrmn764 remaindernear 15 NaN11 -> NaN11
-dqrmn765 remaindernear NaN6 NaN12 -> NaN6
-dqrmn766 remaindernear Inf NaN13 -> NaN13
-dqrmn767 remaindernear NaN14 -Inf -> NaN14
-dqrmn768 remaindernear 0 NaN15 -> NaN15
-dqrmn769 remaindernear NaN16 -0 -> NaN16
-
--- edge cases of impossible
-dqrmn770 remaindernear 1234500000000000000000067890123456 10 -> -4
-dqrmn771 remaindernear 1234500000000000000000067890123456 1 -> 0
-dqrmn772 remaindernear 1234500000000000000000067890123456 0.1 -> NaN Division_impossible
-dqrmn773 remaindernear 1234500000000000000000067890123456 0.01 -> NaN Division_impossible
-
--- long operand checks
-dqrmn801 remaindernear 12345678000 100 -> 0
-dqrmn802 remaindernear 1 12345678000 -> 1
-dqrmn803 remaindernear 1234567800 10 -> 0
-dqrmn804 remaindernear 1 1234567800 -> 1
-dqrmn805 remaindernear 1234567890 10 -> 0
-dqrmn806 remaindernear 1 1234567890 -> 1
-dqrmn807 remaindernear 1234567891 10 -> 1
-dqrmn808 remaindernear 1 1234567891 -> 1
-dqrmn809 remaindernear 12345678901 100 -> 1
-dqrmn810 remaindernear 1 12345678901 -> 1
-dqrmn811 remaindernear 1234567896 10 -> -4
-dqrmn812 remaindernear 1 1234567896 -> 1
-
-dqrmn821 remaindernear 12345678000 100 -> 0
-dqrmn822 remaindernear 1 12345678000 -> 1
-dqrmn823 remaindernear 1234567800 10 -> 0
-dqrmn824 remaindernear 1 1234567800 -> 1
-dqrmn825 remaindernear 1234567890 10 -> 0
-dqrmn826 remaindernear 1 1234567890 -> 1
-dqrmn827 remaindernear 1234567891 10 -> 1
-dqrmn828 remaindernear 1 1234567891 -> 1
-dqrmn829 remaindernear 12345678901 100 -> 1
-dqrmn830 remaindernear 1 12345678901 -> 1
-dqrmn831 remaindernear 1234567896 10 -> -4
-dqrmn832 remaindernear 1 1234567896 -> 1
-
--- from divideint
-dqrmn840 remaindernear 100000000.0 1 -> 0.0
-dqrmn841 remaindernear 100000000.4 1 -> 0.4
-dqrmn842 remaindernear 100000000.5 1 -> 0.5
-dqrmn843 remaindernear 100000000.9 1 -> -0.1
-dqrmn844 remaindernear 100000000.999 1 -> -0.001
-dqrmn850 remaindernear 100000003 5 -> -2
-dqrmn851 remaindernear 10000003 5 -> -2
-dqrmn852 remaindernear 1000003 5 -> -2
-dqrmn853 remaindernear 100003 5 -> -2
-dqrmn854 remaindernear 10003 5 -> -2
-dqrmn855 remaindernear 1003 5 -> -2
-dqrmn856 remaindernear 103 5 -> -2
-dqrmn857 remaindernear 13 5 -> -2
-dqrmn858 remaindernear 1 5 -> 1
-
--- Vladimir's cases 1234567890123456
-dqrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
-dqrmn861 remaindernear 1230 1000000000000000 -> 1230
-dqrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
-dqrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
-dqrmn864 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn870 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn871 remaindernear 123e1 100000000000000 -> 1230
-dqrmn872 remaindernear 123e1 10000000000000 -> 1230
-dqrmn873 remaindernear 123e1 1000000000000 -> 1230
-dqrmn874 remaindernear 123e1 100000000000 -> 1230
-dqrmn875 remaindernear 123e1 10000000000 -> 1230
-dqrmn876 remaindernear 123e1 1000000000 -> 1230
-dqrmn877 remaindernear 123e1 100000000 -> 1230
-dqrmn878 remaindernear 1230 100000000 -> 1230
-dqrmn879 remaindernear 123e1 10000000 -> 1230
-dqrmn880 remaindernear 123e1 1000000 -> 1230
-dqrmn881 remaindernear 123e1 100000 -> 1230
-dqrmn882 remaindernear 123e1 10000 -> 1230
-dqrmn883 remaindernear 123e1 1000 -> 230
-dqrmn884 remaindernear 123e1 100 -> 30
-dqrmn885 remaindernear 123e1 10 -> 0
-dqrmn886 remaindernear 123e1 1 -> 0
-
-dqrmn890 remaindernear 123e1 2000000000000000 -> 1230
-dqrmn891 remaindernear 123e1 200000000000000 -> 1230
-dqrmn892 remaindernear 123e1 20000000000000 -> 1230
-dqrmn893 remaindernear 123e1 2000000000000 -> 1230
-dqrmn894 remaindernear 123e1 200000000000 -> 1230
-dqrmn895 remaindernear 123e1 20000000000 -> 1230
-dqrmn896 remaindernear 123e1 2000000000 -> 1230
-dqrmn897 remaindernear 123e1 200000000 -> 1230
-dqrmn899 remaindernear 123e1 20000000 -> 1230
-dqrmn900 remaindernear 123e1 2000000 -> 1230
-dqrmn901 remaindernear 123e1 200000 -> 1230
-dqrmn902 remaindernear 123e1 20000 -> 1230
-dqrmn903 remaindernear 123e1 2000 -> -770
-dqrmn904 remaindernear 123e1 200 -> 30
-dqrmn905 remaindernear 123e1 20 -> -10
-dqrmn906 remaindernear 123e1 2 -> 0
-
-dqrmn910 remaindernear 123e1 5000000000000000 -> 1230
-dqrmn911 remaindernear 123e1 500000000000000 -> 1230
-dqrmn912 remaindernear 123e1 50000000000000 -> 1230
-dqrmn913 remaindernear 123e1 5000000000000 -> 1230
-dqrmn914 remaindernear 123e1 500000000000 -> 1230
-dqrmn915 remaindernear 123e1 50000000000 -> 1230
-dqrmn916 remaindernear 123e1 5000000000 -> 1230
-dqrmn917 remaindernear 123e1 500000000 -> 1230
-dqrmn919 remaindernear 123e1 50000000 -> 1230
-dqrmn920 remaindernear 123e1 5000000 -> 1230
-dqrmn921 remaindernear 123e1 500000 -> 1230
-dqrmn922 remaindernear 123e1 50000 -> 1230
-dqrmn923 remaindernear 123e1 5000 -> 1230
-dqrmn924 remaindernear 123e1 500 -> 230
-dqrmn925 remaindernear 123e1 50 -> -20
-dqrmn926 remaindernear 123e1 5 -> 0
-
-dqrmn930 remaindernear 123e1 9000000000000000 -> 1230
-dqrmn931 remaindernear 123e1 900000000000000 -> 1230
-dqrmn932 remaindernear 123e1 90000000000000 -> 1230
-dqrmn933 remaindernear 123e1 9000000000000 -> 1230
-dqrmn934 remaindernear 123e1 900000000000 -> 1230
-dqrmn935 remaindernear 123e1 90000000000 -> 1230
-dqrmn936 remaindernear 123e1 9000000000 -> 1230
-dqrmn937 remaindernear 123e1 900000000 -> 1230
-dqrmn939 remaindernear 123e1 90000000 -> 1230
-dqrmn940 remaindernear 123e1 9000000 -> 1230
-dqrmn941 remaindernear 123e1 900000 -> 1230
-dqrmn942 remaindernear 123e1 90000 -> 1230
-dqrmn943 remaindernear 123e1 9000 -> 1230
-dqrmn944 remaindernear 123e1 900 -> 330
-dqrmn945 remaindernear 123e1 90 -> -30
-dqrmn946 remaindernear 123e1 9 -> -3
-
-dqrmn950 remaindernear 123e1 1000000000000000 -> 1230
-dqrmn961 remaindernear 123e1 2999999999999999 -> 1230
-dqrmn962 remaindernear 123e1 3999999999999999 -> 1230
-dqrmn963 remaindernear 123e1 4999999999999999 -> 1230
-dqrmn964 remaindernear 123e1 5999999999999999 -> 1230
-dqrmn965 remaindernear 123e1 6999999999999999 -> 1230
-dqrmn966 remaindernear 123e1 7999999999999999 -> 1230
-dqrmn967 remaindernear 123e1 8999999999999999 -> 1230
-dqrmn968 remaindernear 123e1 9999999999999999 -> 1230
-dqrmn969 remaindernear 123e1 9876543210987654 -> 1230
-
-dqrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
-
--- overflow and underflow tests [from divide]
-dqrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
-dqrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
-dqrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
-dqrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
-dqrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
-dqrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
-dqrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
-dqrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
-
--- Gyuris example
-dqrmn1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
-
--- destructive subtract
-dqrmn1101 remaindernear 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> -0.234567890123456789012345678901233
-dqrmn1102 remaindernear 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> -0.34567890123456789012345678901222
-dqrmn1103 remaindernear 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> -0.4567890123456789012345678901111
-dqrmn1104 remaindernear 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> -1.308641972530864197253086419725314
-dqrmn1105 remaindernear 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
-dqrmn1106 remaindernear 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> -1.3086421975308642197530864219748
-dqrmn1107 remaindernear 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
-dqrmn1108 remaindernear 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> -0.753086421975308642197530864219753
-dqrmn1109 remaindernear 1234567890123456789012345678901234 5.000000000000000000000000000000001 -> -1.246913578024691357802469135780247
-dqrmn1110 remaindernear 1234567890123456789012345678901234 5.00000000000000000000000000000001 -> 1.53086421975308642197530864219754
-dqrmn1111 remaindernear 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> -0.6913578024691357802469135780242
-
--- Null tests
-dqrmn1000 remaindernear 10 # -> NaN Invalid_operation
-dqrmn1001 remaindernear # 10 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- dqRemainderNear.decTest -- decQuad remainder-near --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- sanity checks (as base, above)
+dqrmn001 remaindernear 1 1 -> 0
+dqrmn002 remaindernear 2 1 -> 0
+dqrmn003 remaindernear 1 2 -> 1
+dqrmn004 remaindernear 2 2 -> 0
+dqrmn005 remaindernear 0 1 -> 0
+dqrmn006 remaindernear 0 2 -> 0
+dqrmn007 remaindernear 1 3 -> 1
+dqrmn008 remaindernear 2 3 -> -1
+dqrmn009 remaindernear 3 3 -> 0
+
+dqrmn010 remaindernear 2.4 1 -> 0.4
+dqrmn011 remaindernear 2.4 -1 -> 0.4
+dqrmn012 remaindernear -2.4 1 -> -0.4
+dqrmn013 remaindernear -2.4 -1 -> -0.4
+dqrmn014 remaindernear 2.40 1 -> 0.40
+dqrmn015 remaindernear 2.400 1 -> 0.400
+dqrmn016 remaindernear 2.4 2 -> 0.4
+dqrmn017 remaindernear 2.400 2 -> 0.400
+dqrmn018 remaindernear 2. 2 -> 0
+dqrmn019 remaindernear 20 20 -> 0
+
+dqrmn020 remaindernear 187 187 -> 0
+dqrmn021 remaindernear 5 2 -> 1
+dqrmn022 remaindernear 5 2.0 -> 1.0
+dqrmn023 remaindernear 5 2.000 -> 1.000
+dqrmn024 remaindernear 5 0.200 -> 0.000
+dqrmn025 remaindernear 5 0.200 -> 0.000
+
+dqrmn030 remaindernear 1 2 -> 1
+dqrmn031 remaindernear 1 4 -> 1
+dqrmn032 remaindernear 1 8 -> 1
+
+dqrmn033 remaindernear 1 16 -> 1
+dqrmn034 remaindernear 1 32 -> 1
+dqrmn035 remaindernear 1 64 -> 1
+dqrmn040 remaindernear 1 -2 -> 1
+dqrmn041 remaindernear 1 -4 -> 1
+dqrmn042 remaindernear 1 -8 -> 1
+dqrmn043 remaindernear 1 -16 -> 1
+dqrmn044 remaindernear 1 -32 -> 1
+dqrmn045 remaindernear 1 -64 -> 1
+dqrmn050 remaindernear -1 2 -> -1
+dqrmn051 remaindernear -1 4 -> -1
+dqrmn052 remaindernear -1 8 -> -1
+dqrmn053 remaindernear -1 16 -> -1
+dqrmn054 remaindernear -1 32 -> -1
+dqrmn055 remaindernear -1 64 -> -1
+dqrmn060 remaindernear -1 -2 -> -1
+dqrmn061 remaindernear -1 -4 -> -1
+dqrmn062 remaindernear -1 -8 -> -1
+dqrmn063 remaindernear -1 -16 -> -1
+dqrmn064 remaindernear -1 -32 -> -1
+dqrmn065 remaindernear -1 -64 -> -1
+
+dqrmn066 remaindernear 9.9 1 -> -0.1
+dqrmn067 remaindernear 99.7 1 -> -0.3
+dqrmn068 remaindernear 999999999 1 -> 0
+dqrmn069 remaindernear 999999999.4 1 -> 0.4
+dqrmn070 remaindernear 999999999.5 1 -> -0.5
+dqrmn071 remaindernear 999999999.9 1 -> -0.1
+dqrmn072 remaindernear 999999999.999 1 -> -0.001
+dqrmn073 remaindernear 999999.999999 1 -> -0.000001
+dqrmn074 remaindernear 9 1 -> 0
+dqrmn075 remaindernear 9999999999999999 1 -> 0
+dqrmn076 remaindernear 9999999999999999 2 -> -1
+dqrmn077 remaindernear 9999999999999999 3 -> 0
+dqrmn078 remaindernear 9999999999999999 4 -> -1
+
+dqrmn080 remaindernear 0. 1 -> 0
+dqrmn081 remaindernear .0 1 -> 0.0
+dqrmn082 remaindernear 0.00 1 -> 0.00
+dqrmn083 remaindernear 0.00E+9 1 -> 0
+dqrmn084 remaindernear 0.00E+3 1 -> 0
+dqrmn085 remaindernear 0.00E+2 1 -> 0
+dqrmn086 remaindernear 0.00E+1 1 -> 0.0
+dqrmn087 remaindernear 0.00E+0 1 -> 0.00
+dqrmn088 remaindernear 0.00E-0 1 -> 0.00
+dqrmn089 remaindernear 0.00E-1 1 -> 0.000
+dqrmn090 remaindernear 0.00E-2 1 -> 0.0000
+dqrmn091 remaindernear 0.00E-3 1 -> 0.00000
+dqrmn092 remaindernear 0.00E-4 1 -> 0.000000
+dqrmn093 remaindernear 0.00E-5 1 -> 0E-7
+dqrmn094 remaindernear 0.00E-6 1 -> 0E-8
+dqrmn095 remaindernear 0.0000E-50 1 -> 0E-54
+
+-- Various flavours of remaindernear by 0
+dqrmn101 remaindernear 0 0 -> NaN Division_undefined
+dqrmn102 remaindernear 0 -0 -> NaN Division_undefined
+dqrmn103 remaindernear -0 0 -> NaN Division_undefined
+dqrmn104 remaindernear -0 -0 -> NaN Division_undefined
+dqrmn105 remaindernear 0.0E5 0 -> NaN Division_undefined
+dqrmn106 remaindernear 0.000 0 -> NaN Division_undefined
+-- [Some think this next group should be Division_by_zero exception, but
+-- IEEE 854 is explicit that it is Invalid operation .. for
+-- remainder-near, anyway]
+dqrmn107 remaindernear 0.0001 0 -> NaN Invalid_operation
+dqrmn108 remaindernear 0.01 0 -> NaN Invalid_operation
+dqrmn109 remaindernear 0.1 0 -> NaN Invalid_operation
+dqrmn110 remaindernear 1 0 -> NaN Invalid_operation
+dqrmn111 remaindernear 1 0.0 -> NaN Invalid_operation
+dqrmn112 remaindernear 10 0.0 -> NaN Invalid_operation
+dqrmn113 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+dqrmn114 remaindernear 1E+380 0 -> NaN Invalid_operation
+dqrmn115 remaindernear 0.0001 -0 -> NaN Invalid_operation
+dqrmn116 remaindernear 0.01 -0 -> NaN Invalid_operation
+dqrmn119 remaindernear 0.1 -0 -> NaN Invalid_operation
+dqrmn120 remaindernear 1 -0 -> NaN Invalid_operation
+dqrmn121 remaindernear 1 -0.0 -> NaN Invalid_operation
+dqrmn122 remaindernear 10 -0.0 -> NaN Invalid_operation
+dqrmn123 remaindernear 1E+100 -0.0 -> NaN Invalid_operation
+dqrmn124 remaindernear 1E+384 -0 -> NaN Invalid_operation
+-- and zeros on left
+dqrmn130 remaindernear 0 1 -> 0
+dqrmn131 remaindernear 0 -1 -> 0
+dqrmn132 remaindernear 0.0 1 -> 0.0
+dqrmn133 remaindernear 0.0 -1 -> 0.0
+dqrmn134 remaindernear -0 1 -> -0
+dqrmn135 remaindernear -0 -1 -> -0
+dqrmn136 remaindernear -0.0 1 -> -0.0
+dqrmn137 remaindernear -0.0 -1 -> -0.0
+
+-- 0.5ers
+dqrmn143 remaindernear 0.5 2 -> 0.5
+dqrmn144 remaindernear 0.5 2.1 -> 0.5
+dqrmn145 remaindernear 0.5 2.01 -> 0.50
+dqrmn146 remaindernear 0.5 2.001 -> 0.500
+dqrmn147 remaindernear 0.50 2 -> 0.50
+dqrmn148 remaindernear 0.50 2.01 -> 0.50
+dqrmn149 remaindernear 0.50 2.001 -> 0.500
+
+-- steadies
+dqrmn150 remaindernear 1 1 -> 0
+dqrmn151 remaindernear 1 2 -> 1
+dqrmn152 remaindernear 1 3 -> 1
+dqrmn153 remaindernear 1 4 -> 1
+dqrmn154 remaindernear 1 5 -> 1
+dqrmn155 remaindernear 1 6 -> 1
+dqrmn156 remaindernear 1 7 -> 1
+dqrmn157 remaindernear 1 8 -> 1
+dqrmn158 remaindernear 1 9 -> 1
+dqrmn159 remaindernear 1 10 -> 1
+dqrmn160 remaindernear 1 1 -> 0
+dqrmn161 remaindernear 2 1 -> 0
+dqrmn162 remaindernear 3 1 -> 0
+dqrmn163 remaindernear 4 1 -> 0
+dqrmn164 remaindernear 5 1 -> 0
+dqrmn165 remaindernear 6 1 -> 0
+dqrmn166 remaindernear 7 1 -> 0
+dqrmn167 remaindernear 8 1 -> 0
+dqrmn168 remaindernear 9 1 -> 0
+dqrmn169 remaindernear 10 1 -> 0
+
+-- some differences from remainder
+dqrmn171 remaindernear 0.4 1.020 -> 0.400
+dqrmn172 remaindernear 0.50 1.020 -> 0.500
+dqrmn173 remaindernear 0.51 1.020 -> 0.510
+dqrmn174 remaindernear 0.52 1.020 -> -0.500
+dqrmn175 remaindernear 0.6 1.020 -> -0.420
+
+-- More flavours of remaindernear by 0
+dqrmn201 remaindernear 0 0 -> NaN Division_undefined
+dqrmn202 remaindernear 0.0E5 0 -> NaN Division_undefined
+dqrmn203 remaindernear 0.000 0 -> NaN Division_undefined
+dqrmn204 remaindernear 0.0001 0 -> NaN Invalid_operation
+dqrmn205 remaindernear 0.01 0 -> NaN Invalid_operation
+dqrmn206 remaindernear 0.1 0 -> NaN Invalid_operation
+dqrmn207 remaindernear 1 0 -> NaN Invalid_operation
+dqrmn208 remaindernear 1 0.0 -> NaN Invalid_operation
+dqrmn209 remaindernear 10 0.0 -> NaN Invalid_operation
+dqrmn210 remaindernear 1E+100 0.0 -> NaN Invalid_operation
+dqrmn211 remaindernear 1E+380 0 -> NaN Invalid_operation
+
+-- tests from the extended specification
+dqrmn221 remaindernear 2.1 3 -> -0.9
+dqrmn222 remaindernear 10 6 -> -2
+dqrmn223 remaindernear 10 3 -> 1
+dqrmn224 remaindernear -10 3 -> -1
+dqrmn225 remaindernear 10.2 1 -> 0.2
+dqrmn226 remaindernear 10 0.3 -> 0.1
+dqrmn227 remaindernear 3.6 1.3 -> -0.3
+
+-- some differences from remainder
+dqrmn231 remaindernear -0.4 1.020 -> -0.400
+dqrmn232 remaindernear -0.50 1.020 -> -0.500
+dqrmn233 remaindernear -0.51 1.020 -> -0.510
+dqrmn234 remaindernear -0.52 1.020 -> 0.500
+dqrmn235 remaindernear -0.6 1.020 -> 0.420
+
+-- high Xs
+dqrmn240 remaindernear 1E+2 1.00 -> 0.00
+
+-- dqrmn3xx are from DiagBigDecimal
+dqrmn301 remaindernear 1 3 -> 1
+dqrmn302 remaindernear 5 5 -> 0
+dqrmn303 remaindernear 13 10 -> 3
+dqrmn304 remaindernear 13 50 -> 13
+dqrmn305 remaindernear 13 100 -> 13
+dqrmn306 remaindernear 13 1000 -> 13
+dqrmn307 remaindernear .13 1 -> 0.13
+dqrmn308 remaindernear 0.133 1 -> 0.133
+dqrmn309 remaindernear 0.1033 1 -> 0.1033
+dqrmn310 remaindernear 1.033 1 -> 0.033
+dqrmn311 remaindernear 10.33 1 -> 0.33
+dqrmn312 remaindernear 10.33 10 -> 0.33
+dqrmn313 remaindernear 103.3 1 -> 0.3
+dqrmn314 remaindernear 133 10 -> 3
+dqrmn315 remaindernear 1033 10 -> 3
+dqrmn316 remaindernear 1033 50 -> -17
+dqrmn317 remaindernear 101.0 3 -> -1.0
+dqrmn318 remaindernear 102.0 3 -> 0.0
+dqrmn319 remaindernear 103.0 3 -> 1.0
+dqrmn320 remaindernear 2.40 1 -> 0.40
+dqrmn321 remaindernear 2.400 1 -> 0.400
+dqrmn322 remaindernear 2.4 1 -> 0.4
+dqrmn323 remaindernear 2.4 2 -> 0.4
+dqrmn324 remaindernear 2.400 2 -> 0.400
+dqrmn325 remaindernear 1 0.3 -> 0.1
+dqrmn326 remaindernear 1 0.30 -> 0.10
+dqrmn327 remaindernear 1 0.300 -> 0.100
+dqrmn328 remaindernear 1 0.3000 -> 0.1000
+dqrmn329 remaindernear 1.0 0.3 -> 0.1
+dqrmn330 remaindernear 1.00 0.3 -> 0.10
+dqrmn331 remaindernear 1.000 0.3 -> 0.100
+dqrmn332 remaindernear 1.0000 0.3 -> 0.1000
+dqrmn333 remaindernear 0.5 2 -> 0.5
+dqrmn334 remaindernear 0.5 2.1 -> 0.5
+dqrmn335 remaindernear 0.5 2.01 -> 0.50
+dqrmn336 remaindernear 0.5 2.001 -> 0.500
+dqrmn337 remaindernear 0.50 2 -> 0.50
+dqrmn338 remaindernear 0.50 2.01 -> 0.50
+dqrmn339 remaindernear 0.50 2.001 -> 0.500
+
+dqrmn340 remaindernear 0.5 0.5000001 -> -1E-7
+dqrmn341 remaindernear 0.5 0.50000001 -> -1E-8
+dqrmn342 remaindernear 0.5 0.500000001 -> -1E-9
+dqrmn343 remaindernear 0.5 0.5000000001 -> -1E-10
+dqrmn344 remaindernear 0.5 0.50000000001 -> -1E-11
+dqrmn345 remaindernear 0.5 0.4999999 -> 1E-7
+dqrmn346 remaindernear 0.5 0.49999999 -> 1E-8
+dqrmn347 remaindernear 0.5 0.499999999 -> 1E-9
+dqrmn348 remaindernear 0.5 0.4999999999 -> 1E-10
+dqrmn349 remaindernear 0.5 0.49999999999 -> 1E-11
+dqrmn350 remaindernear 0.5 0.499999999999 -> 1E-12
+
+dqrmn351 remaindernear 0.03 7 -> 0.03
+dqrmn352 remaindernear 5 2 -> 1
+dqrmn353 remaindernear 4.1 2 -> 0.1
+dqrmn354 remaindernear 4.01 2 -> 0.01
+dqrmn355 remaindernear 4.001 2 -> 0.001
+dqrmn356 remaindernear 4.0001 2 -> 0.0001
+dqrmn357 remaindernear 4.00001 2 -> 0.00001
+dqrmn358 remaindernear 4.000001 2 -> 0.000001
+dqrmn359 remaindernear 4.0000001 2 -> 1E-7
+
+dqrmn360 remaindernear 1.2 0.7345 -> -0.2690
+dqrmn361 remaindernear 0.8 12 -> 0.8
+dqrmn362 remaindernear 0.8 0.2 -> 0.0
+dqrmn363 remaindernear 0.8 0.3 -> -0.1
+dqrmn364 remaindernear 0.800 12 -> 0.800
+dqrmn365 remaindernear 0.800 1.7 -> 0.800
+dqrmn366 remaindernear 2.400 2 -> 0.400
+
+-- round to even
+dqrmn371 remaindernear 121 2 -> 1
+dqrmn372 remaindernear 122 2 -> 0
+dqrmn373 remaindernear 123 2 -> -1
+dqrmn374 remaindernear 124 2 -> 0
+dqrmn375 remaindernear 125 2 -> 1
+dqrmn376 remaindernear 126 2 -> 0
+dqrmn377 remaindernear 127 2 -> -1
+
+dqrmn381 remaindernear 12345 1 -> 0
+dqrmn382 remaindernear 12345 1.0001 -> -0.2344
+dqrmn383 remaindernear 12345 1.001 -> -0.333
+dqrmn384 remaindernear 12345 1.01 -> -0.23
+dqrmn385 remaindernear 12345 1.1 -> -0.3
+dqrmn386 remaindernear 12355 4 -> -1
+dqrmn387 remaindernear 12345 4 -> 1
+dqrmn388 remaindernear 12355 4.0001 -> -1.3089
+dqrmn389 remaindernear 12345 4.0001 -> 0.6914
+dqrmn390 remaindernear 12345 4.9 -> 1.9
+dqrmn391 remaindernear 12345 4.99 -> -0.26
+dqrmn392 remaindernear 12345 4.999 -> 2.469
+dqrmn393 remaindernear 12345 4.9999 -> 0.2469
+dqrmn394 remaindernear 12345 5 -> 0
+dqrmn395 remaindernear 12345 5.0001 -> -0.2469
+dqrmn396 remaindernear 12345 5.001 -> -2.469
+dqrmn397 remaindernear 12345 5.01 -> 0.36
+dqrmn398 remaindernear 12345 5.1 -> -2.1
+
+-- the nasty division-by-1 cases
+dqrmn401 remaindernear 0.4 1 -> 0.4
+dqrmn402 remaindernear 0.45 1 -> 0.45
+dqrmn403 remaindernear 0.455 1 -> 0.455
+dqrmn404 remaindernear 0.4555 1 -> 0.4555
+dqrmn405 remaindernear 0.45555 1 -> 0.45555
+dqrmn406 remaindernear 0.455555 1 -> 0.455555
+dqrmn407 remaindernear 0.4555555 1 -> 0.4555555
+dqrmn408 remaindernear 0.45555555 1 -> 0.45555555
+dqrmn409 remaindernear 0.455555555 1 -> 0.455555555
+-- with spill... [412 exercises sticktab loop]
+dqrmn411 remaindernear 0.5 1 -> 0.5
+dqrmn412 remaindernear 0.55 1 -> -0.45
+dqrmn413 remaindernear 0.555 1 -> -0.445
+dqrmn414 remaindernear 0.5555 1 -> -0.4445
+dqrmn415 remaindernear 0.55555 1 -> -0.44445
+dqrmn416 remaindernear 0.555555 1 -> -0.444445
+dqrmn417 remaindernear 0.5555555 1 -> -0.4444445
+dqrmn418 remaindernear 0.55555555 1 -> -0.44444445
+dqrmn419 remaindernear 0.555555555 1 -> -0.444444445
+
+-- folddowns
+dqrmn421 remaindernear 1E+6144 1 -> NaN Division_impossible
+dqrmn422 remaindernear 1E+6144 1E+6143 -> 0E+6111 Clamped
+dqrmn423 remaindernear 1E+6144 2E+6143 -> 0E+6111 Clamped
+dqrmn424 remaindernear 1E+6144 3E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqrmn425 remaindernear 1E+6144 4E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrmn426 remaindernear 1E+6144 5E+6143 -> 0E+6111 Clamped
+dqrmn427 remaindernear 1E+6144 6E+6143 -> -2.00000000000000000000000000000000E+6143 Clamped
+dqrmn428 remaindernear 1E+6144 7E+6143 -> 3.00000000000000000000000000000000E+6143 Clamped
+dqrmn429 remaindernear 1E+6144 8E+6143 -> 2.00000000000000000000000000000000E+6143 Clamped
+dqrmn430 remaindernear 1E+6144 9E+6143 -> 1.00000000000000000000000000000000E+6143 Clamped
+-- tinies
+dqrmn431 remaindernear 1E-6175 1E-6176 -> 0E-6176
+dqrmn432 remaindernear 1E-6175 2E-6176 -> 0E-6176
+dqrmn433 remaindernear 1E-6175 3E-6176 -> 1E-6176 Subnormal
+dqrmn434 remaindernear 1E-6175 4E-6176 -> 2E-6176 Subnormal
+dqrmn435 remaindernear 1E-6175 5E-6176 -> 0E-6176
+dqrmn436 remaindernear 1E-6175 6E-6176 -> -2E-6176 Subnormal
+dqrmn437 remaindernear 1E-6175 7E-6176 -> 3E-6176 Subnormal
+dqrmn438 remaindernear 1E-6175 8E-6176 -> 2E-6176 Subnormal
+dqrmn439 remaindernear 1E-6175 9E-6176 -> 1E-6176 Subnormal
+dqrmn440 remaindernear 1E-6175 10E-6176 -> 0E-6176
+dqrmn441 remaindernear 1E-6175 11E-6176 -> -1E-6176 Subnormal
+dqrmn442 remaindernear 100E-6175 11E-6176 -> -1E-6176 Subnormal
+dqrmn443 remaindernear 100E-6175 20E-6176 -> 0E-6176
+dqrmn444 remaindernear 100E-6175 21E-6176 -> -8E-6176 Subnormal
+dqrmn445 remaindernear 100E-6175 30E-6176 -> 1.0E-6175 Subnormal
+
+-- zero signs
+dqrmn650 remaindernear 1 1 -> 0
+dqrmn651 remaindernear -1 1 -> -0
+dqrmn652 remaindernear 1 -1 -> 0
+dqrmn653 remaindernear -1 -1 -> -0
+dqrmn654 remaindernear 0 1 -> 0
+dqrmn655 remaindernear -0 1 -> -0
+dqrmn656 remaindernear 0 -1 -> 0
+dqrmn657 remaindernear -0 -1 -> -0
+dqrmn658 remaindernear 0.00 1 -> 0.00
+dqrmn659 remaindernear -0.00 1 -> -0.00
+
+-- Specials
+dqrmn680 remaindernear Inf -Inf -> NaN Invalid_operation
+dqrmn681 remaindernear Inf -1000 -> NaN Invalid_operation
+dqrmn682 remaindernear Inf -1 -> NaN Invalid_operation
+dqrmn683 remaindernear Inf 0 -> NaN Invalid_operation
+dqrmn684 remaindernear Inf -0 -> NaN Invalid_operation
+dqrmn685 remaindernear Inf 1 -> NaN Invalid_operation
+dqrmn686 remaindernear Inf 1000 -> NaN Invalid_operation
+dqrmn687 remaindernear Inf Inf -> NaN Invalid_operation
+dqrmn688 remaindernear -1000 Inf -> -1000
+dqrmn689 remaindernear -Inf Inf -> NaN Invalid_operation
+dqrmn691 remaindernear -1 Inf -> -1
+dqrmn692 remaindernear 0 Inf -> 0
+dqrmn693 remaindernear -0 Inf -> -0
+dqrmn694 remaindernear 1 Inf -> 1
+dqrmn695 remaindernear 1000 Inf -> 1000
+dqrmn696 remaindernear Inf Inf -> NaN Invalid_operation
+
+dqrmn700 remaindernear -Inf -Inf -> NaN Invalid_operation
+dqrmn701 remaindernear -Inf -1000 -> NaN Invalid_operation
+dqrmn702 remaindernear -Inf -1 -> NaN Invalid_operation
+dqrmn703 remaindernear -Inf -0 -> NaN Invalid_operation
+dqrmn704 remaindernear -Inf 0 -> NaN Invalid_operation
+dqrmn705 remaindernear -Inf 1 -> NaN Invalid_operation
+dqrmn706 remaindernear -Inf 1000 -> NaN Invalid_operation
+dqrmn707 remaindernear -Inf Inf -> NaN Invalid_operation
+dqrmn708 remaindernear -Inf -Inf -> NaN Invalid_operation
+dqrmn709 remaindernear -1000 Inf -> -1000
+dqrmn710 remaindernear -1 -Inf -> -1
+dqrmn711 remaindernear -0 -Inf -> -0
+dqrmn712 remaindernear 0 -Inf -> 0
+dqrmn713 remaindernear 1 -Inf -> 1
+dqrmn714 remaindernear 1000 -Inf -> 1000
+dqrmn715 remaindernear Inf -Inf -> NaN Invalid_operation
+
+dqrmn721 remaindernear NaN -Inf -> NaN
+dqrmn722 remaindernear NaN -1000 -> NaN
+dqrmn723 remaindernear NaN -1 -> NaN
+dqrmn724 remaindernear NaN -0 -> NaN
+dqrmn725 remaindernear -NaN 0 -> -NaN
+dqrmn726 remaindernear NaN 1 -> NaN
+dqrmn727 remaindernear NaN 1000 -> NaN
+dqrmn728 remaindernear NaN Inf -> NaN
+dqrmn729 remaindernear NaN -NaN -> NaN
+dqrmn730 remaindernear -Inf NaN -> NaN
+dqrmn731 remaindernear -1000 NaN -> NaN
+dqrmn732 remaindernear -1 NaN -> NaN
+dqrmn733 remaindernear -0 -NaN -> -NaN
+dqrmn734 remaindernear 0 NaN -> NaN
+dqrmn735 remaindernear 1 -NaN -> -NaN
+dqrmn736 remaindernear 1000 NaN -> NaN
+dqrmn737 remaindernear Inf NaN -> NaN
+
+dqrmn741 remaindernear sNaN -Inf -> NaN Invalid_operation
+dqrmn742 remaindernear sNaN -1000 -> NaN Invalid_operation
+dqrmn743 remaindernear -sNaN -1 -> -NaN Invalid_operation
+dqrmn744 remaindernear sNaN -0 -> NaN Invalid_operation
+dqrmn745 remaindernear sNaN 0 -> NaN Invalid_operation
+dqrmn746 remaindernear sNaN 1 -> NaN Invalid_operation
+dqrmn747 remaindernear sNaN 1000 -> NaN Invalid_operation
+dqrmn749 remaindernear sNaN NaN -> NaN Invalid_operation
+dqrmn750 remaindernear sNaN sNaN -> NaN Invalid_operation
+dqrmn751 remaindernear NaN sNaN -> NaN Invalid_operation
+dqrmn752 remaindernear -Inf sNaN -> NaN Invalid_operation
+dqrmn753 remaindernear -1000 sNaN -> NaN Invalid_operation
+dqrmn754 remaindernear -1 sNaN -> NaN Invalid_operation
+dqrmn755 remaindernear -0 sNaN -> NaN Invalid_operation
+dqrmn756 remaindernear 0 sNaN -> NaN Invalid_operation
+dqrmn757 remaindernear 1 sNaN -> NaN Invalid_operation
+dqrmn758 remaindernear 1000 sNaN -> NaN Invalid_operation
+dqrmn759 remaindernear Inf -sNaN -> -NaN Invalid_operation
+
+-- propaging NaNs
+dqrmn760 remaindernear NaN1 NaN7 -> NaN1
+dqrmn761 remaindernear sNaN2 NaN8 -> NaN2 Invalid_operation
+dqrmn762 remaindernear NaN3 sNaN9 -> NaN9 Invalid_operation
+dqrmn763 remaindernear sNaN4 sNaN10 -> NaN4 Invalid_operation
+dqrmn764 remaindernear 15 NaN11 -> NaN11
+dqrmn765 remaindernear NaN6 NaN12 -> NaN6
+dqrmn766 remaindernear Inf NaN13 -> NaN13
+dqrmn767 remaindernear NaN14 -Inf -> NaN14
+dqrmn768 remaindernear 0 NaN15 -> NaN15
+dqrmn769 remaindernear NaN16 -0 -> NaN16
+
+-- edge cases of impossible
+dqrmn770 remaindernear 1234500000000000000000067890123456 10 -> -4
+dqrmn771 remaindernear 1234500000000000000000067890123456 1 -> 0
+dqrmn772 remaindernear 1234500000000000000000067890123456 0.1 -> NaN Division_impossible
+dqrmn773 remaindernear 1234500000000000000000067890123456 0.01 -> NaN Division_impossible
+
+-- long operand checks
+dqrmn801 remaindernear 12345678000 100 -> 0
+dqrmn802 remaindernear 1 12345678000 -> 1
+dqrmn803 remaindernear 1234567800 10 -> 0
+dqrmn804 remaindernear 1 1234567800 -> 1
+dqrmn805 remaindernear 1234567890 10 -> 0
+dqrmn806 remaindernear 1 1234567890 -> 1
+dqrmn807 remaindernear 1234567891 10 -> 1
+dqrmn808 remaindernear 1 1234567891 -> 1
+dqrmn809 remaindernear 12345678901 100 -> 1
+dqrmn810 remaindernear 1 12345678901 -> 1
+dqrmn811 remaindernear 1234567896 10 -> -4
+dqrmn812 remaindernear 1 1234567896 -> 1
+
+dqrmn821 remaindernear 12345678000 100 -> 0
+dqrmn822 remaindernear 1 12345678000 -> 1
+dqrmn823 remaindernear 1234567800 10 -> 0
+dqrmn824 remaindernear 1 1234567800 -> 1
+dqrmn825 remaindernear 1234567890 10 -> 0
+dqrmn826 remaindernear 1 1234567890 -> 1
+dqrmn827 remaindernear 1234567891 10 -> 1
+dqrmn828 remaindernear 1 1234567891 -> 1
+dqrmn829 remaindernear 12345678901 100 -> 1
+dqrmn830 remaindernear 1 12345678901 -> 1
+dqrmn831 remaindernear 1234567896 10 -> -4
+dqrmn832 remaindernear 1 1234567896 -> 1
+
+-- from divideint
+dqrmn840 remaindernear 100000000.0 1 -> 0.0
+dqrmn841 remaindernear 100000000.4 1 -> 0.4
+dqrmn842 remaindernear 100000000.5 1 -> 0.5
+dqrmn843 remaindernear 100000000.9 1 -> -0.1
+dqrmn844 remaindernear 100000000.999 1 -> -0.001
+dqrmn850 remaindernear 100000003 5 -> -2
+dqrmn851 remaindernear 10000003 5 -> -2
+dqrmn852 remaindernear 1000003 5 -> -2
+dqrmn853 remaindernear 100003 5 -> -2
+dqrmn854 remaindernear 10003 5 -> -2
+dqrmn855 remaindernear 1003 5 -> -2
+dqrmn856 remaindernear 103 5 -> -2
+dqrmn857 remaindernear 13 5 -> -2
+dqrmn858 remaindernear 1 5 -> 1
+
+-- Vladimir's cases 1234567890123456
+dqrmn860 remaindernear 123.0e1 1000000000000000 -> 1230
+dqrmn861 remaindernear 1230 1000000000000000 -> 1230
+dqrmn862 remaindernear 12.3e2 1000000000000000 -> 1230
+dqrmn863 remaindernear 1.23e3 1000000000000000 -> 1230
+dqrmn864 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn870 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn871 remaindernear 123e1 100000000000000 -> 1230
+dqrmn872 remaindernear 123e1 10000000000000 -> 1230
+dqrmn873 remaindernear 123e1 1000000000000 -> 1230
+dqrmn874 remaindernear 123e1 100000000000 -> 1230
+dqrmn875 remaindernear 123e1 10000000000 -> 1230
+dqrmn876 remaindernear 123e1 1000000000 -> 1230
+dqrmn877 remaindernear 123e1 100000000 -> 1230
+dqrmn878 remaindernear 1230 100000000 -> 1230
+dqrmn879 remaindernear 123e1 10000000 -> 1230
+dqrmn880 remaindernear 123e1 1000000 -> 1230
+dqrmn881 remaindernear 123e1 100000 -> 1230
+dqrmn882 remaindernear 123e1 10000 -> 1230
+dqrmn883 remaindernear 123e1 1000 -> 230
+dqrmn884 remaindernear 123e1 100 -> 30
+dqrmn885 remaindernear 123e1 10 -> 0
+dqrmn886 remaindernear 123e1 1 -> 0
+
+dqrmn890 remaindernear 123e1 2000000000000000 -> 1230
+dqrmn891 remaindernear 123e1 200000000000000 -> 1230
+dqrmn892 remaindernear 123e1 20000000000000 -> 1230
+dqrmn893 remaindernear 123e1 2000000000000 -> 1230
+dqrmn894 remaindernear 123e1 200000000000 -> 1230
+dqrmn895 remaindernear 123e1 20000000000 -> 1230
+dqrmn896 remaindernear 123e1 2000000000 -> 1230
+dqrmn897 remaindernear 123e1 200000000 -> 1230
+dqrmn899 remaindernear 123e1 20000000 -> 1230
+dqrmn900 remaindernear 123e1 2000000 -> 1230
+dqrmn901 remaindernear 123e1 200000 -> 1230
+dqrmn902 remaindernear 123e1 20000 -> 1230
+dqrmn903 remaindernear 123e1 2000 -> -770
+dqrmn904 remaindernear 123e1 200 -> 30
+dqrmn905 remaindernear 123e1 20 -> -10
+dqrmn906 remaindernear 123e1 2 -> 0
+
+dqrmn910 remaindernear 123e1 5000000000000000 -> 1230
+dqrmn911 remaindernear 123e1 500000000000000 -> 1230
+dqrmn912 remaindernear 123e1 50000000000000 -> 1230
+dqrmn913 remaindernear 123e1 5000000000000 -> 1230
+dqrmn914 remaindernear 123e1 500000000000 -> 1230
+dqrmn915 remaindernear 123e1 50000000000 -> 1230
+dqrmn916 remaindernear 123e1 5000000000 -> 1230
+dqrmn917 remaindernear 123e1 500000000 -> 1230
+dqrmn919 remaindernear 123e1 50000000 -> 1230
+dqrmn920 remaindernear 123e1 5000000 -> 1230
+dqrmn921 remaindernear 123e1 500000 -> 1230
+dqrmn922 remaindernear 123e1 50000 -> 1230
+dqrmn923 remaindernear 123e1 5000 -> 1230
+dqrmn924 remaindernear 123e1 500 -> 230
+dqrmn925 remaindernear 123e1 50 -> -20
+dqrmn926 remaindernear 123e1 5 -> 0
+
+dqrmn930 remaindernear 123e1 9000000000000000 -> 1230
+dqrmn931 remaindernear 123e1 900000000000000 -> 1230
+dqrmn932 remaindernear 123e1 90000000000000 -> 1230
+dqrmn933 remaindernear 123e1 9000000000000 -> 1230
+dqrmn934 remaindernear 123e1 900000000000 -> 1230
+dqrmn935 remaindernear 123e1 90000000000 -> 1230
+dqrmn936 remaindernear 123e1 9000000000 -> 1230
+dqrmn937 remaindernear 123e1 900000000 -> 1230
+dqrmn939 remaindernear 123e1 90000000 -> 1230
+dqrmn940 remaindernear 123e1 9000000 -> 1230
+dqrmn941 remaindernear 123e1 900000 -> 1230
+dqrmn942 remaindernear 123e1 90000 -> 1230
+dqrmn943 remaindernear 123e1 9000 -> 1230
+dqrmn944 remaindernear 123e1 900 -> 330
+dqrmn945 remaindernear 123e1 90 -> -30
+dqrmn946 remaindernear 123e1 9 -> -3
+
+dqrmn950 remaindernear 123e1 1000000000000000 -> 1230
+dqrmn961 remaindernear 123e1 2999999999999999 -> 1230
+dqrmn962 remaindernear 123e1 3999999999999999 -> 1230
+dqrmn963 remaindernear 123e1 4999999999999999 -> 1230
+dqrmn964 remaindernear 123e1 5999999999999999 -> 1230
+dqrmn965 remaindernear 123e1 6999999999999999 -> 1230
+dqrmn966 remaindernear 123e1 7999999999999999 -> 1230
+dqrmn967 remaindernear 123e1 8999999999999999 -> 1230
+dqrmn968 remaindernear 123e1 9999999999999999 -> 1230
+dqrmn969 remaindernear 123e1 9876543210987654 -> 1230
+
+dqrmn980 remaindernear 123e1 1000E299 -> 1.23E+3 -- 123E+1 internally
+
+-- overflow and underflow tests [from divide]
+dqrmn1051 remaindernear 1e+277 1e-311 -> NaN Division_impossible
+dqrmn1052 remaindernear 1e+277 -1e-311 -> NaN Division_impossible
+dqrmn1053 remaindernear -1e+277 1e-311 -> NaN Division_impossible
+dqrmn1054 remaindernear -1e+277 -1e-311 -> NaN Division_impossible
+dqrmn1055 remaindernear 1e-277 1e+311 -> 1E-277
+dqrmn1056 remaindernear 1e-277 -1e+311 -> 1E-277
+dqrmn1057 remaindernear -1e-277 1e+311 -> -1E-277
+dqrmn1058 remaindernear -1e-277 -1e+311 -> -1E-277
+
+-- Gyuris example
+dqrmn1070 remainder 8.336804418094040989630006819881709E-6143 8.336804418094040989630006819889000E-6143 -> 8.336804418094040989630006819881709E-6143
+
+-- destructive subtract
+dqrmn1101 remaindernear 1234567890123456789012345678901234 1.000000000000000000000000000000001 -> -0.234567890123456789012345678901233
+dqrmn1102 remaindernear 1234567890123456789012345678901234 1.00000000000000000000000000000001 -> -0.34567890123456789012345678901222
+dqrmn1103 remaindernear 1234567890123456789012345678901234 1.0000000000000000000000000000001 -> -0.4567890123456789012345678901111
+dqrmn1104 remaindernear 1234567890123456789012345678901255 4.000000000000000000000000000000001 -> -1.308641972530864197253086419725314
+dqrmn1105 remaindernear 1234567890123456789012345678901234 4.000000000000000000000000000000001 -> 1.691358027469135802746913580274692
+dqrmn1106 remaindernear 1234567890123456789012345678901234 4.9999999999999999999999999999999 -> -1.3086421975308642197530864219748
+dqrmn1107 remaindernear 1234567890123456789012345678901234 4.99999999999999999999999999999999 -> 1.46913578024691357802469135780247
+dqrmn1108 remaindernear 1234567890123456789012345678901234 4.999999999999999999999999999999999 -> -0.753086421975308642197530864219753
+dqrmn1109 remaindernear 1234567890123456789012345678901234 5.000000000000000000000000000000001 -> -1.246913578024691357802469135780247
+dqrmn1110 remaindernear 1234567890123456789012345678901234 5.00000000000000000000000000000001 -> 1.53086421975308642197530864219754
+dqrmn1111 remaindernear 1234567890123456789012345678901234 5.0000000000000000000000000000001 -> -0.6913578024691357802469135780242
+
+-- Null tests
+dqrmn1000 remaindernear 10 # -> NaN Invalid_operation
+dqrmn1001 remaindernear # 10 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/dqRotate.decTest b/Lib/test/decimaltestdata/dqRotate.decTest
index edcf9eed23f..858b823e088 100644
--- a/Lib/test/decimaltestdata/dqRotate.decTest
+++ b/Lib/test/decimaltestdata/dqRotate.decTest
@@ -1,298 +1,298 @@
-------------------------------------------------------------------------
--- dqRotate.decTest -- rotate decQuad coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqrot001 rotate 0 0 -> 0
-dqrot002 rotate 0 2 -> 0
-dqrot003 rotate 1 2 -> 100
-dqrot004 rotate 1 33 -> 1000000000000000000000000000000000
-dqrot005 rotate 1 34 -> 1
-dqrot006 rotate 1 -1 -> 1000000000000000000000000000000000
-dqrot007 rotate 0 -2 -> 0
-dqrot008 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
-dqrot009 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
-dqrot010 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
-dqrot011 rotate 9934567890123456789012345678901234 -33 -> 9345678901234567890123456789012349
-dqrot012 rotate 9934567890123456789012345678901234 -34 -> 9934567890123456789012345678901234
-
--- rhs must be an integer
-dqrot015 rotate 1 1.5 -> NaN Invalid_operation
-dqrot016 rotate 1 1.0 -> NaN Invalid_operation
-dqrot017 rotate 1 0.1 -> NaN Invalid_operation
-dqrot018 rotate 1 0.0 -> NaN Invalid_operation
-dqrot019 rotate 1 1E+1 -> NaN Invalid_operation
-dqrot020 rotate 1 1E+99 -> NaN Invalid_operation
-dqrot021 rotate 1 Inf -> NaN Invalid_operation
-dqrot022 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-dqrot025 rotate 1 -1000 -> NaN Invalid_operation
-dqrot026 rotate 1 -35 -> NaN Invalid_operation
-dqrot027 rotate 1 35 -> NaN Invalid_operation
-dqrot028 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-dqrot030 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
-dqrot031 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
-dqrot032 rotate 1234567890123456789012345678901234 -32 -> 3456789012345678901234567890123412
-dqrot033 rotate 1234567890123456789012345678901234 -31 -> 4567890123456789012345678901234123
-dqrot034 rotate 1234567890123456789012345678901234 -30 -> 5678901234567890123456789012341234
-dqrot035 rotate 1234567890123456789012345678901234 -29 -> 6789012345678901234567890123412345
-dqrot036 rotate 1234567890123456789012345678901234 -28 -> 7890123456789012345678901234123456
-dqrot037 rotate 1234567890123456789012345678901234 -27 -> 8901234567890123456789012341234567
-dqrot038 rotate 1234567890123456789012345678901234 -26 -> 9012345678901234567890123412345678
-dqrot039 rotate 1234567890123456789012345678901234 -25 -> 123456789012345678901234123456789
-dqrot040 rotate 1234567890123456789012345678901234 -24 -> 1234567890123456789012341234567890
-dqrot041 rotate 1234567890123456789012345678901234 -23 -> 2345678901234567890123412345678901
-dqrot042 rotate 1234567890123456789012345678901234 -22 -> 3456789012345678901234123456789012
-dqrot043 rotate 1234567890123456789012345678901234 -21 -> 4567890123456789012341234567890123
-dqrot044 rotate 1234567890123456789012345678901234 -20 -> 5678901234567890123412345678901234
-dqrot045 rotate 1234567890123456789012345678901234 -19 -> 6789012345678901234123456789012345
-dqrot047 rotate 1234567890123456789012345678901234 -18 -> 7890123456789012341234567890123456
-dqrot048 rotate 1234567890123456789012345678901234 -17 -> 8901234567890123412345678901234567
-dqrot049 rotate 1234567890123456789012345678901234 -16 -> 9012345678901234123456789012345678
-dqrot050 rotate 1234567890123456789012345678901234 -15 -> 123456789012341234567890123456789
-dqrot051 rotate 1234567890123456789012345678901234 -14 -> 1234567890123412345678901234567890
-dqrot052 rotate 1234567890123456789012345678901234 -13 -> 2345678901234123456789012345678901
-dqrot053 rotate 1234567890123456789012345678901234 -12 -> 3456789012341234567890123456789012
-dqrot054 rotate 1234567890123456789012345678901234 -11 -> 4567890123412345678901234567890123
-dqrot055 rotate 1234567890123456789012345678901234 -10 -> 5678901234123456789012345678901234
-dqrot056 rotate 1234567890123456789012345678901234 -9 -> 6789012341234567890123456789012345
-dqrot057 rotate 1234567890123456789012345678901234 -8 -> 7890123412345678901234567890123456
-dqrot058 rotate 1234567890123456789012345678901234 -7 -> 8901234123456789012345678901234567
-dqrot059 rotate 1234567890123456789012345678901234 -6 -> 9012341234567890123456789012345678
-dqrot060 rotate 1234567890123456789012345678901234 -5 -> 123412345678901234567890123456789
-dqrot061 rotate 1234567890123456789012345678901234 -4 -> 1234123456789012345678901234567890
-dqrot062 rotate 1234567890123456789012345678901234 -3 -> 2341234567890123456789012345678901
-dqrot063 rotate 1234567890123456789012345678901234 -2 -> 3412345678901234567890123456789012
-dqrot064 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
-dqrot065 rotate 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
-
-dqrot066 rotate 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
-dqrot067 rotate 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012341
-dqrot068 rotate 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123412
-dqrot069 rotate 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234123
-dqrot070 rotate 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012341234
-dqrot071 rotate 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123412345
-dqrot072 rotate 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234123456
-dqrot073 rotate 1234567890123456789012345678901234 +7 -> 8901234567890123456789012341234567
-dqrot074 rotate 1234567890123456789012345678901234 +8 -> 9012345678901234567890123412345678
-dqrot075 rotate 1234567890123456789012345678901234 +9 -> 123456789012345678901234123456789
-dqrot076 rotate 1234567890123456789012345678901234 +10 -> 1234567890123456789012341234567890
-dqrot077 rotate 1234567890123456789012345678901234 +11 -> 2345678901234567890123412345678901
-dqrot078 rotate 1234567890123456789012345678901234 +12 -> 3456789012345678901234123456789012
-dqrot079 rotate 1234567890123456789012345678901234 +13 -> 4567890123456789012341234567890123
-dqrot080 rotate 1234567890123456789012345678901234 +14 -> 5678901234567890123412345678901234
-dqrot081 rotate 1234567890123456789012345678901234 +15 -> 6789012345678901234123456789012345
-dqrot082 rotate 1234567890123456789012345678901234 +16 -> 7890123456789012341234567890123456
-dqrot083 rotate 1234567890123456789012345678901234 +17 -> 8901234567890123412345678901234567
-dqrot084 rotate 1234567890123456789012345678901234 +18 -> 9012345678901234123456789012345678
-dqrot085 rotate 1234567890123456789012345678901234 +19 -> 123456789012341234567890123456789
-dqrot086 rotate 1234567890123456789012345678901234 +20 -> 1234567890123412345678901234567890
-dqrot087 rotate 1234567890123456789012345678901234 +21 -> 2345678901234123456789012345678901
-dqrot088 rotate 1234567890123456789012345678901234 +22 -> 3456789012341234567890123456789012
-dqrot089 rotate 1234567890123456789012345678901234 +23 -> 4567890123412345678901234567890123
-dqrot090 rotate 1234567890123456789012345678901234 +24 -> 5678901234123456789012345678901234
-dqrot091 rotate 1234567890123456789012345678901234 +25 -> 6789012341234567890123456789012345
-dqrot092 rotate 1234567890123456789012345678901234 +26 -> 7890123412345678901234567890123456
-dqrot093 rotate 1234567890123456789012345678901234 +27 -> 8901234123456789012345678901234567
-dqrot094 rotate 1234567890123456789012345678901234 +28 -> 9012341234567890123456789012345678
-dqrot095 rotate 1234567890123456789012345678901234 +29 -> 123412345678901234567890123456789
-dqrot096 rotate 1234567890123456789012345678901234 +30 -> 1234123456789012345678901234567890
-dqrot097 rotate 1234567890123456789012345678901234 +31 -> 2341234567890123456789012345678901
-dqrot098 rotate 1234567890123456789012345678901234 +32 -> 3412345678901234567890123456789012
-dqrot099 rotate 1234567890123456789012345678901234 +33 -> 4123456789012345678901234567890123
-dqrot100 rotate 1234567890123456789012345678901234 +34 -> 1234567890123456789012345678901234
-
--- zeros
-dqrot270 rotate 0E-10 +29 -> 0E-10
-dqrot271 rotate 0E-10 -29 -> 0E-10
-dqrot272 rotate 0.000 +29 -> 0.000
-dqrot273 rotate 0.000 -29 -> 0.000
-dqrot274 rotate 0E+10 +29 -> 0E+10
-dqrot275 rotate 0E+10 -29 -> 0E+10
-dqrot276 rotate -0E-10 +29 -> -0E-10
-dqrot277 rotate -0E-10 -29 -> -0E-10
-dqrot278 rotate -0.000 +29 -> -0.000
-dqrot279 rotate -0.000 -29 -> -0.000
-dqrot280 rotate -0E+10 +29 -> -0E+10
-dqrot281 rotate -0E+10 -29 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-dqrot141 rotate 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6144
-dqrot142 rotate 9.999999999999999999999999999999999E+6144 -33 -> 9.999999999999999999999999999999999E+6144
-dqrot143 rotate 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144
-dqrot144 rotate 9.999999999999999999999999999999999E+6144 33 -> 9.999999999999999999999999999999999E+6144
-dqrot145 rotate 1E-6143 -1 -> 1.000000000000000000000000000000000E-6110
-dqrot146 rotate 1E-6143 -33 -> 1.0E-6142
-dqrot147 rotate 1E-6143 1 -> 1.0E-6142
-dqrot148 rotate 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
-dqrot151 rotate 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
-dqrot152 rotate 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
-dqrot153 rotate 1.000000000000000000000000000000000E-6143 1 -> 1E-6176
-dqrot154 rotate 1.000000000000000000000000000000000E-6143 33 -> 1.00000000000000000000000000000000E-6144
-dqrot155 rotate 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
-dqrot156 rotate 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
-dqrot157 rotate 9.000000000000000000000000000000000E-6143 1 -> 9E-6176
-dqrot158 rotate 9.000000000000000000000000000000000E-6143 33 -> 9.00000000000000000000000000000000E-6144
-dqrot160 rotate 1E-6176 -1 -> 1.000000000000000000000000000000000E-6143
-dqrot161 rotate 1E-6176 -33 -> 1.0E-6175
-dqrot162 rotate 1E-6176 1 -> 1.0E-6175
-dqrot163 rotate 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
--- negatives
-dqrot171 rotate -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
-dqrot172 rotate -9.999999999999999999999999999999999E+6144 -33 -> -9.999999999999999999999999999999999E+6144
-dqrot173 rotate -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999999E+6144
-dqrot174 rotate -9.999999999999999999999999999999999E+6144 33 -> -9.999999999999999999999999999999999E+6144
-dqrot175 rotate -1E-6143 -1 -> -1.000000000000000000000000000000000E-6110
-dqrot176 rotate -1E-6143 -33 -> -1.0E-6142
-dqrot177 rotate -1E-6143 1 -> -1.0E-6142
-dqrot178 rotate -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
-dqrot181 rotate -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
-dqrot182 rotate -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
-dqrot183 rotate -1.000000000000000000000000000000000E-6143 1 -> -1E-6176
-dqrot184 rotate -1.000000000000000000000000000000000E-6143 33 -> -1.00000000000000000000000000000000E-6144
-dqrot185 rotate -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
-dqrot186 rotate -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
-dqrot187 rotate -9.000000000000000000000000000000000E-6143 1 -> -9E-6176
-dqrot188 rotate -9.000000000000000000000000000000000E-6143 33 -> -9.00000000000000000000000000000000E-6144
-dqrot190 rotate -1E-6176 -1 -> -1.000000000000000000000000000000000E-6143
-dqrot191 rotate -1E-6176 -33 -> -1.0E-6175
-dqrot192 rotate -1E-6176 1 -> -1.0E-6175
-dqrot193 rotate -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
-
--- more negatives (of sanities)
-dqrot201 rotate -0 0 -> -0
-dqrot202 rotate -0 2 -> -0
-dqrot203 rotate -1 2 -> -100
-dqrot204 rotate -1 33 -> -1000000000000000000000000000000000
-dqrot205 rotate -1 34 -> -1
-dqrot206 rotate -1 -1 -> -1000000000000000000000000000000000
-dqrot207 rotate -0 -2 -> -0
-dqrot208 rotate -1234567890123456789012345678901234 -1 -> -4123456789012345678901234567890123
-dqrot209 rotate -1234567890123456789012345678901234 -33 -> -2345678901234567890123456789012341
-dqrot210 rotate -1234567890123456789012345678901234 -34 -> -1234567890123456789012345678901234
-dqrot211 rotate -9934567890123456789012345678901234 -33 -> -9345678901234567890123456789012349
-dqrot212 rotate -9934567890123456789012345678901234 -34 -> -9934567890123456789012345678901234
-
-
--- Specials; NaNs are handled as usual
-dqrot781 rotate -Inf -8 -> -Infinity
-dqrot782 rotate -Inf -1 -> -Infinity
-dqrot783 rotate -Inf -0 -> -Infinity
-dqrot784 rotate -Inf 0 -> -Infinity
-dqrot785 rotate -Inf 1 -> -Infinity
-dqrot786 rotate -Inf 8 -> -Infinity
-dqrot787 rotate -1000 -Inf -> NaN Invalid_operation
-dqrot788 rotate -Inf -Inf -> NaN Invalid_operation
-dqrot789 rotate -1 -Inf -> NaN Invalid_operation
-dqrot790 rotate -0 -Inf -> NaN Invalid_operation
-dqrot791 rotate 0 -Inf -> NaN Invalid_operation
-dqrot792 rotate 1 -Inf -> NaN Invalid_operation
-dqrot793 rotate 1000 -Inf -> NaN Invalid_operation
-dqrot794 rotate Inf -Inf -> NaN Invalid_operation
-
-dqrot800 rotate Inf -Inf -> NaN Invalid_operation
-dqrot801 rotate Inf -8 -> Infinity
-dqrot802 rotate Inf -1 -> Infinity
-dqrot803 rotate Inf -0 -> Infinity
-dqrot804 rotate Inf 0 -> Infinity
-dqrot805 rotate Inf 1 -> Infinity
-dqrot806 rotate Inf 8 -> Infinity
-dqrot807 rotate Inf Inf -> NaN Invalid_operation
-dqrot808 rotate -1000 Inf -> NaN Invalid_operation
-dqrot809 rotate -Inf Inf -> NaN Invalid_operation
-dqrot810 rotate -1 Inf -> NaN Invalid_operation
-dqrot811 rotate -0 Inf -> NaN Invalid_operation
-dqrot812 rotate 0 Inf -> NaN Invalid_operation
-dqrot813 rotate 1 Inf -> NaN Invalid_operation
-dqrot814 rotate 1000 Inf -> NaN Invalid_operation
-dqrot815 rotate Inf Inf -> NaN Invalid_operation
-
-dqrot821 rotate NaN -Inf -> NaN
-dqrot822 rotate NaN -1000 -> NaN
-dqrot823 rotate NaN -1 -> NaN
-dqrot824 rotate NaN -0 -> NaN
-dqrot825 rotate NaN 0 -> NaN
-dqrot826 rotate NaN 1 -> NaN
-dqrot827 rotate NaN 1000 -> NaN
-dqrot828 rotate NaN Inf -> NaN
-dqrot829 rotate NaN NaN -> NaN
-dqrot830 rotate -Inf NaN -> NaN
-dqrot831 rotate -1000 NaN -> NaN
-dqrot832 rotate -1 NaN -> NaN
-dqrot833 rotate -0 NaN -> NaN
-dqrot834 rotate 0 NaN -> NaN
-dqrot835 rotate 1 NaN -> NaN
-dqrot836 rotate 1000 NaN -> NaN
-dqrot837 rotate Inf NaN -> NaN
-
-dqrot841 rotate sNaN -Inf -> NaN Invalid_operation
-dqrot842 rotate sNaN -1000 -> NaN Invalid_operation
-dqrot843 rotate sNaN -1 -> NaN Invalid_operation
-dqrot844 rotate sNaN -0 -> NaN Invalid_operation
-dqrot845 rotate sNaN 0 -> NaN Invalid_operation
-dqrot846 rotate sNaN 1 -> NaN Invalid_operation
-dqrot847 rotate sNaN 1000 -> NaN Invalid_operation
-dqrot848 rotate sNaN NaN -> NaN Invalid_operation
-dqrot849 rotate sNaN sNaN -> NaN Invalid_operation
-dqrot850 rotate NaN sNaN -> NaN Invalid_operation
-dqrot851 rotate -Inf sNaN -> NaN Invalid_operation
-dqrot852 rotate -1000 sNaN -> NaN Invalid_operation
-dqrot853 rotate -1 sNaN -> NaN Invalid_operation
-dqrot854 rotate -0 sNaN -> NaN Invalid_operation
-dqrot855 rotate 0 sNaN -> NaN Invalid_operation
-dqrot856 rotate 1 sNaN -> NaN Invalid_operation
-dqrot857 rotate 1000 sNaN -> NaN Invalid_operation
-dqrot858 rotate Inf sNaN -> NaN Invalid_operation
-dqrot859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqrot861 rotate NaN1 -Inf -> NaN1
-dqrot862 rotate +NaN2 -1000 -> NaN2
-dqrot863 rotate NaN3 1000 -> NaN3
-dqrot864 rotate NaN4 Inf -> NaN4
-dqrot865 rotate NaN5 +NaN6 -> NaN5
-dqrot866 rotate -Inf NaN7 -> NaN7
-dqrot867 rotate -1000 NaN8 -> NaN8
-dqrot868 rotate 1000 NaN9 -> NaN9
-dqrot869 rotate Inf +NaN10 -> NaN10
-dqrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-dqrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-dqrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-dqrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-dqrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-dqrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-dqrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-dqrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-dqrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-dqrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqrot882 rotate -NaN26 NaN28 -> -NaN26
-dqrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqrot884 rotate 1000 -NaN30 -> -NaN30
-dqrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- dqRotate.decTest -- rotate decQuad coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqrot001 rotate 0 0 -> 0
+dqrot002 rotate 0 2 -> 0
+dqrot003 rotate 1 2 -> 100
+dqrot004 rotate 1 33 -> 1000000000000000000000000000000000
+dqrot005 rotate 1 34 -> 1
+dqrot006 rotate 1 -1 -> 1000000000000000000000000000000000
+dqrot007 rotate 0 -2 -> 0
+dqrot008 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
+dqrot009 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
+dqrot010 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
+dqrot011 rotate 9934567890123456789012345678901234 -33 -> 9345678901234567890123456789012349
+dqrot012 rotate 9934567890123456789012345678901234 -34 -> 9934567890123456789012345678901234
+
+-- rhs must be an integer
+dqrot015 rotate 1 1.5 -> NaN Invalid_operation
+dqrot016 rotate 1 1.0 -> NaN Invalid_operation
+dqrot017 rotate 1 0.1 -> NaN Invalid_operation
+dqrot018 rotate 1 0.0 -> NaN Invalid_operation
+dqrot019 rotate 1 1E+1 -> NaN Invalid_operation
+dqrot020 rotate 1 1E+99 -> NaN Invalid_operation
+dqrot021 rotate 1 Inf -> NaN Invalid_operation
+dqrot022 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+dqrot025 rotate 1 -1000 -> NaN Invalid_operation
+dqrot026 rotate 1 -35 -> NaN Invalid_operation
+dqrot027 rotate 1 35 -> NaN Invalid_operation
+dqrot028 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+dqrot030 rotate 1234567890123456789012345678901234 -34 -> 1234567890123456789012345678901234
+dqrot031 rotate 1234567890123456789012345678901234 -33 -> 2345678901234567890123456789012341
+dqrot032 rotate 1234567890123456789012345678901234 -32 -> 3456789012345678901234567890123412
+dqrot033 rotate 1234567890123456789012345678901234 -31 -> 4567890123456789012345678901234123
+dqrot034 rotate 1234567890123456789012345678901234 -30 -> 5678901234567890123456789012341234
+dqrot035 rotate 1234567890123456789012345678901234 -29 -> 6789012345678901234567890123412345
+dqrot036 rotate 1234567890123456789012345678901234 -28 -> 7890123456789012345678901234123456
+dqrot037 rotate 1234567890123456789012345678901234 -27 -> 8901234567890123456789012341234567
+dqrot038 rotate 1234567890123456789012345678901234 -26 -> 9012345678901234567890123412345678
+dqrot039 rotate 1234567890123456789012345678901234 -25 -> 123456789012345678901234123456789
+dqrot040 rotate 1234567890123456789012345678901234 -24 -> 1234567890123456789012341234567890
+dqrot041 rotate 1234567890123456789012345678901234 -23 -> 2345678901234567890123412345678901
+dqrot042 rotate 1234567890123456789012345678901234 -22 -> 3456789012345678901234123456789012
+dqrot043 rotate 1234567890123456789012345678901234 -21 -> 4567890123456789012341234567890123
+dqrot044 rotate 1234567890123456789012345678901234 -20 -> 5678901234567890123412345678901234
+dqrot045 rotate 1234567890123456789012345678901234 -19 -> 6789012345678901234123456789012345
+dqrot047 rotate 1234567890123456789012345678901234 -18 -> 7890123456789012341234567890123456
+dqrot048 rotate 1234567890123456789012345678901234 -17 -> 8901234567890123412345678901234567
+dqrot049 rotate 1234567890123456789012345678901234 -16 -> 9012345678901234123456789012345678
+dqrot050 rotate 1234567890123456789012345678901234 -15 -> 123456789012341234567890123456789
+dqrot051 rotate 1234567890123456789012345678901234 -14 -> 1234567890123412345678901234567890
+dqrot052 rotate 1234567890123456789012345678901234 -13 -> 2345678901234123456789012345678901
+dqrot053 rotate 1234567890123456789012345678901234 -12 -> 3456789012341234567890123456789012
+dqrot054 rotate 1234567890123456789012345678901234 -11 -> 4567890123412345678901234567890123
+dqrot055 rotate 1234567890123456789012345678901234 -10 -> 5678901234123456789012345678901234
+dqrot056 rotate 1234567890123456789012345678901234 -9 -> 6789012341234567890123456789012345
+dqrot057 rotate 1234567890123456789012345678901234 -8 -> 7890123412345678901234567890123456
+dqrot058 rotate 1234567890123456789012345678901234 -7 -> 8901234123456789012345678901234567
+dqrot059 rotate 1234567890123456789012345678901234 -6 -> 9012341234567890123456789012345678
+dqrot060 rotate 1234567890123456789012345678901234 -5 -> 123412345678901234567890123456789
+dqrot061 rotate 1234567890123456789012345678901234 -4 -> 1234123456789012345678901234567890
+dqrot062 rotate 1234567890123456789012345678901234 -3 -> 2341234567890123456789012345678901
+dqrot063 rotate 1234567890123456789012345678901234 -2 -> 3412345678901234567890123456789012
+dqrot064 rotate 1234567890123456789012345678901234 -1 -> 4123456789012345678901234567890123
+dqrot065 rotate 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
+
+dqrot066 rotate 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
+dqrot067 rotate 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012341
+dqrot068 rotate 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123412
+dqrot069 rotate 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234123
+dqrot070 rotate 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012341234
+dqrot071 rotate 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123412345
+dqrot072 rotate 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234123456
+dqrot073 rotate 1234567890123456789012345678901234 +7 -> 8901234567890123456789012341234567
+dqrot074 rotate 1234567890123456789012345678901234 +8 -> 9012345678901234567890123412345678
+dqrot075 rotate 1234567890123456789012345678901234 +9 -> 123456789012345678901234123456789
+dqrot076 rotate 1234567890123456789012345678901234 +10 -> 1234567890123456789012341234567890
+dqrot077 rotate 1234567890123456789012345678901234 +11 -> 2345678901234567890123412345678901
+dqrot078 rotate 1234567890123456789012345678901234 +12 -> 3456789012345678901234123456789012
+dqrot079 rotate 1234567890123456789012345678901234 +13 -> 4567890123456789012341234567890123
+dqrot080 rotate 1234567890123456789012345678901234 +14 -> 5678901234567890123412345678901234
+dqrot081 rotate 1234567890123456789012345678901234 +15 -> 6789012345678901234123456789012345
+dqrot082 rotate 1234567890123456789012345678901234 +16 -> 7890123456789012341234567890123456
+dqrot083 rotate 1234567890123456789012345678901234 +17 -> 8901234567890123412345678901234567
+dqrot084 rotate 1234567890123456789012345678901234 +18 -> 9012345678901234123456789012345678
+dqrot085 rotate 1234567890123456789012345678901234 +19 -> 123456789012341234567890123456789
+dqrot086 rotate 1234567890123456789012345678901234 +20 -> 1234567890123412345678901234567890
+dqrot087 rotate 1234567890123456789012345678901234 +21 -> 2345678901234123456789012345678901
+dqrot088 rotate 1234567890123456789012345678901234 +22 -> 3456789012341234567890123456789012
+dqrot089 rotate 1234567890123456789012345678901234 +23 -> 4567890123412345678901234567890123
+dqrot090 rotate 1234567890123456789012345678901234 +24 -> 5678901234123456789012345678901234
+dqrot091 rotate 1234567890123456789012345678901234 +25 -> 6789012341234567890123456789012345
+dqrot092 rotate 1234567890123456789012345678901234 +26 -> 7890123412345678901234567890123456
+dqrot093 rotate 1234567890123456789012345678901234 +27 -> 8901234123456789012345678901234567
+dqrot094 rotate 1234567890123456789012345678901234 +28 -> 9012341234567890123456789012345678
+dqrot095 rotate 1234567890123456789012345678901234 +29 -> 123412345678901234567890123456789
+dqrot096 rotate 1234567890123456789012345678901234 +30 -> 1234123456789012345678901234567890
+dqrot097 rotate 1234567890123456789012345678901234 +31 -> 2341234567890123456789012345678901
+dqrot098 rotate 1234567890123456789012345678901234 +32 -> 3412345678901234567890123456789012
+dqrot099 rotate 1234567890123456789012345678901234 +33 -> 4123456789012345678901234567890123
+dqrot100 rotate 1234567890123456789012345678901234 +34 -> 1234567890123456789012345678901234
+
+-- zeros
+dqrot270 rotate 0E-10 +29 -> 0E-10
+dqrot271 rotate 0E-10 -29 -> 0E-10
+dqrot272 rotate 0.000 +29 -> 0.000
+dqrot273 rotate 0.000 -29 -> 0.000
+dqrot274 rotate 0E+10 +29 -> 0E+10
+dqrot275 rotate 0E+10 -29 -> 0E+10
+dqrot276 rotate -0E-10 +29 -> -0E-10
+dqrot277 rotate -0E-10 -29 -> -0E-10
+dqrot278 rotate -0.000 +29 -> -0.000
+dqrot279 rotate -0.000 -29 -> -0.000
+dqrot280 rotate -0E+10 +29 -> -0E+10
+dqrot281 rotate -0E+10 -29 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+dqrot141 rotate 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6144
+dqrot142 rotate 9.999999999999999999999999999999999E+6144 -33 -> 9.999999999999999999999999999999999E+6144
+dqrot143 rotate 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999999E+6144
+dqrot144 rotate 9.999999999999999999999999999999999E+6144 33 -> 9.999999999999999999999999999999999E+6144
+dqrot145 rotate 1E-6143 -1 -> 1.000000000000000000000000000000000E-6110
+dqrot146 rotate 1E-6143 -33 -> 1.0E-6142
+dqrot147 rotate 1E-6143 1 -> 1.0E-6142
+dqrot148 rotate 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
+dqrot151 rotate 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
+dqrot152 rotate 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
+dqrot153 rotate 1.000000000000000000000000000000000E-6143 1 -> 1E-6176
+dqrot154 rotate 1.000000000000000000000000000000000E-6143 33 -> 1.00000000000000000000000000000000E-6144
+dqrot155 rotate 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
+dqrot156 rotate 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
+dqrot157 rotate 9.000000000000000000000000000000000E-6143 1 -> 9E-6176
+dqrot158 rotate 9.000000000000000000000000000000000E-6143 33 -> 9.00000000000000000000000000000000E-6144
+dqrot160 rotate 1E-6176 -1 -> 1.000000000000000000000000000000000E-6143
+dqrot161 rotate 1E-6176 -33 -> 1.0E-6175
+dqrot162 rotate 1E-6176 1 -> 1.0E-6175
+dqrot163 rotate 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
+-- negatives
+dqrot171 rotate -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6144
+dqrot172 rotate -9.999999999999999999999999999999999E+6144 -33 -> -9.999999999999999999999999999999999E+6144
+dqrot173 rotate -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999999E+6144
+dqrot174 rotate -9.999999999999999999999999999999999E+6144 33 -> -9.999999999999999999999999999999999E+6144
+dqrot175 rotate -1E-6143 -1 -> -1.000000000000000000000000000000000E-6110
+dqrot176 rotate -1E-6143 -33 -> -1.0E-6142
+dqrot177 rotate -1E-6143 1 -> -1.0E-6142
+dqrot178 rotate -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
+dqrot181 rotate -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
+dqrot182 rotate -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
+dqrot183 rotate -1.000000000000000000000000000000000E-6143 1 -> -1E-6176
+dqrot184 rotate -1.000000000000000000000000000000000E-6143 33 -> -1.00000000000000000000000000000000E-6144
+dqrot185 rotate -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
+dqrot186 rotate -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
+dqrot187 rotate -9.000000000000000000000000000000000E-6143 1 -> -9E-6176
+dqrot188 rotate -9.000000000000000000000000000000000E-6143 33 -> -9.00000000000000000000000000000000E-6144
+dqrot190 rotate -1E-6176 -1 -> -1.000000000000000000000000000000000E-6143
+dqrot191 rotate -1E-6176 -33 -> -1.0E-6175
+dqrot192 rotate -1E-6176 1 -> -1.0E-6175
+dqrot193 rotate -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
+
+-- more negatives (of sanities)
+dqrot201 rotate -0 0 -> -0
+dqrot202 rotate -0 2 -> -0
+dqrot203 rotate -1 2 -> -100
+dqrot204 rotate -1 33 -> -1000000000000000000000000000000000
+dqrot205 rotate -1 34 -> -1
+dqrot206 rotate -1 -1 -> -1000000000000000000000000000000000
+dqrot207 rotate -0 -2 -> -0
+dqrot208 rotate -1234567890123456789012345678901234 -1 -> -4123456789012345678901234567890123
+dqrot209 rotate -1234567890123456789012345678901234 -33 -> -2345678901234567890123456789012341
+dqrot210 rotate -1234567890123456789012345678901234 -34 -> -1234567890123456789012345678901234
+dqrot211 rotate -9934567890123456789012345678901234 -33 -> -9345678901234567890123456789012349
+dqrot212 rotate -9934567890123456789012345678901234 -34 -> -9934567890123456789012345678901234
+
+
+-- Specials; NaNs are handled as usual
+dqrot781 rotate -Inf -8 -> -Infinity
+dqrot782 rotate -Inf -1 -> -Infinity
+dqrot783 rotate -Inf -0 -> -Infinity
+dqrot784 rotate -Inf 0 -> -Infinity
+dqrot785 rotate -Inf 1 -> -Infinity
+dqrot786 rotate -Inf 8 -> -Infinity
+dqrot787 rotate -1000 -Inf -> NaN Invalid_operation
+dqrot788 rotate -Inf -Inf -> NaN Invalid_operation
+dqrot789 rotate -1 -Inf -> NaN Invalid_operation
+dqrot790 rotate -0 -Inf -> NaN Invalid_operation
+dqrot791 rotate 0 -Inf -> NaN Invalid_operation
+dqrot792 rotate 1 -Inf -> NaN Invalid_operation
+dqrot793 rotate 1000 -Inf -> NaN Invalid_operation
+dqrot794 rotate Inf -Inf -> NaN Invalid_operation
+
+dqrot800 rotate Inf -Inf -> NaN Invalid_operation
+dqrot801 rotate Inf -8 -> Infinity
+dqrot802 rotate Inf -1 -> Infinity
+dqrot803 rotate Inf -0 -> Infinity
+dqrot804 rotate Inf 0 -> Infinity
+dqrot805 rotate Inf 1 -> Infinity
+dqrot806 rotate Inf 8 -> Infinity
+dqrot807 rotate Inf Inf -> NaN Invalid_operation
+dqrot808 rotate -1000 Inf -> NaN Invalid_operation
+dqrot809 rotate -Inf Inf -> NaN Invalid_operation
+dqrot810 rotate -1 Inf -> NaN Invalid_operation
+dqrot811 rotate -0 Inf -> NaN Invalid_operation
+dqrot812 rotate 0 Inf -> NaN Invalid_operation
+dqrot813 rotate 1 Inf -> NaN Invalid_operation
+dqrot814 rotate 1000 Inf -> NaN Invalid_operation
+dqrot815 rotate Inf Inf -> NaN Invalid_operation
+
+dqrot821 rotate NaN -Inf -> NaN
+dqrot822 rotate NaN -1000 -> NaN
+dqrot823 rotate NaN -1 -> NaN
+dqrot824 rotate NaN -0 -> NaN
+dqrot825 rotate NaN 0 -> NaN
+dqrot826 rotate NaN 1 -> NaN
+dqrot827 rotate NaN 1000 -> NaN
+dqrot828 rotate NaN Inf -> NaN
+dqrot829 rotate NaN NaN -> NaN
+dqrot830 rotate -Inf NaN -> NaN
+dqrot831 rotate -1000 NaN -> NaN
+dqrot832 rotate -1 NaN -> NaN
+dqrot833 rotate -0 NaN -> NaN
+dqrot834 rotate 0 NaN -> NaN
+dqrot835 rotate 1 NaN -> NaN
+dqrot836 rotate 1000 NaN -> NaN
+dqrot837 rotate Inf NaN -> NaN
+
+dqrot841 rotate sNaN -Inf -> NaN Invalid_operation
+dqrot842 rotate sNaN -1000 -> NaN Invalid_operation
+dqrot843 rotate sNaN -1 -> NaN Invalid_operation
+dqrot844 rotate sNaN -0 -> NaN Invalid_operation
+dqrot845 rotate sNaN 0 -> NaN Invalid_operation
+dqrot846 rotate sNaN 1 -> NaN Invalid_operation
+dqrot847 rotate sNaN 1000 -> NaN Invalid_operation
+dqrot848 rotate sNaN NaN -> NaN Invalid_operation
+dqrot849 rotate sNaN sNaN -> NaN Invalid_operation
+dqrot850 rotate NaN sNaN -> NaN Invalid_operation
+dqrot851 rotate -Inf sNaN -> NaN Invalid_operation
+dqrot852 rotate -1000 sNaN -> NaN Invalid_operation
+dqrot853 rotate -1 sNaN -> NaN Invalid_operation
+dqrot854 rotate -0 sNaN -> NaN Invalid_operation
+dqrot855 rotate 0 sNaN -> NaN Invalid_operation
+dqrot856 rotate 1 sNaN -> NaN Invalid_operation
+dqrot857 rotate 1000 sNaN -> NaN Invalid_operation
+dqrot858 rotate Inf sNaN -> NaN Invalid_operation
+dqrot859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqrot861 rotate NaN1 -Inf -> NaN1
+dqrot862 rotate +NaN2 -1000 -> NaN2
+dqrot863 rotate NaN3 1000 -> NaN3
+dqrot864 rotate NaN4 Inf -> NaN4
+dqrot865 rotate NaN5 +NaN6 -> NaN5
+dqrot866 rotate -Inf NaN7 -> NaN7
+dqrot867 rotate -1000 NaN8 -> NaN8
+dqrot868 rotate 1000 NaN9 -> NaN9
+dqrot869 rotate Inf +NaN10 -> NaN10
+dqrot871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+dqrot872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+dqrot873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+dqrot874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+dqrot875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqrot876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+dqrot877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+dqrot878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+dqrot879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+dqrot880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+dqrot881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqrot882 rotate -NaN26 NaN28 -> -NaN26
+dqrot883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqrot884 rotate 1000 -NaN30 -> -NaN30
+dqrot885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqSameQuantum.decTest b/Lib/test/decimaltestdata/dqSameQuantum.decTest
index 257cda802d5..2f356bbae91 100644
--- a/Lib/test/decimaltestdata/dqSameQuantum.decTest
+++ b/Lib/test/decimaltestdata/dqSameQuantum.decTest
@@ -1,389 +1,389 @@
-------------------------------------------------------------------------
--- dqSameQuantum.decTest -- check decQuad quantums match --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- All operands and results are decQuads.
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqsamq001 samequantum 0 0 -> 1
-dqsamq002 samequantum 0 1 -> 1
-dqsamq003 samequantum 1 0 -> 1
-dqsamq004 samequantum 1 1 -> 1
-
-dqsamq011 samequantum 10 1E+1 -> 0
-dqsamq012 samequantum 10E+1 10E+1 -> 1
-dqsamq013 samequantum 100 10E+1 -> 0
-dqsamq014 samequantum 100 1E+2 -> 0
-dqsamq015 samequantum 0.1 1E-2 -> 0
-dqsamq016 samequantum 0.1 1E-1 -> 1
-dqsamq017 samequantum 0.1 1E-0 -> 0
-dqsamq018 samequantum 999 999 -> 1
-dqsamq019 samequantum 999E-1 99.9 -> 1
-dqsamq020 samequantum 111E-1 22.2 -> 1
-dqsamq021 samequantum 111E-1 1234.2 -> 1
-
--- zeros
-dqsamq030 samequantum 0.0 1.1 -> 1
-dqsamq031 samequantum 0.0 1.11 -> 0
-dqsamq032 samequantum 0.0 0 -> 0
-dqsamq033 samequantum 0.0 0.0 -> 1
-dqsamq034 samequantum 0.0 0.00 -> 0
-dqsamq035 samequantum 0E+1 0E+0 -> 0
-dqsamq036 samequantum 0E+1 0E+1 -> 1
-dqsamq037 samequantum 0E+1 0E+2 -> 0
-dqsamq038 samequantum 0E-17 0E-16 -> 0
-dqsamq039 samequantum 0E-17 0E-17 -> 1
-dqsamq040 samequantum 0E-17 0E-18 -> 0
-dqsamq041 samequantum 0E-17 0.0E-15 -> 0
-dqsamq042 samequantum 0E-17 0.0E-16 -> 1
-dqsamq043 samequantum 0E-17 0.0E-17 -> 0
-dqsamq044 samequantum -0E-17 0.0E-16 -> 1
-dqsamq045 samequantum 0E-17 -0.0E-17 -> 0
-dqsamq046 samequantum 0E-17 -0.0E-16 -> 1
-dqsamq047 samequantum -0E-17 0.0E-17 -> 0
-dqsamq048 samequantum -0E-17 -0.0E-16 -> 1
-dqsamq049 samequantum -0E-17 -0.0E-17 -> 0
-
--- Nmax, Nmin, Ntiny
-dqsamq051 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
-dqsamq052 samequantum 1E-6143 1E-6143 -> 1
-dqsamq053 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
-dqsamq054 samequantum 1E-6176 1E-6176 -> 1
-dqsamq055 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
-dqsamq056 samequantum 1E-6143 1E-6143 -> 1
-dqsamq057 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
-dqsamq058 samequantum 1E-6176 1E-6176 -> 1
-
-dqsamq061 samequantum -1E-6176 -1E-6176 -> 1
-dqsamq062 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
-dqsamq063 samequantum -1E-6143 -1E-6143 -> 1
-dqsamq064 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
-dqsamq065 samequantum -1E-6176 -1E-6176 -> 1
-dqsamq066 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
-dqsamq067 samequantum -1E-6143 -1E-6143 -> 1
-dqsamq068 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
-
-dqsamq071 samequantum -4E-6176 -1E-6176 -> 1
-dqsamq072 samequantum -4.00000000000000000000000000000000E-6143 -1.00000000000000000000000000004000E-6143 -> 1
-dqsamq073 samequantum -4E-6143 -1E-6143 -> 1
-dqsamq074 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6144 -> 1
-dqsamq075 samequantum -4E-6176 -1E-6176 -> 1
-dqsamq076 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6143 -> 1
-dqsamq077 samequantum -4E-6143 -1E-6143 -> 1
-dqsamq078 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6144 -> 1
-
-dqsamq081 samequantum -4E-1006 -1E-6176 -> 0
-dqsamq082 samequantum -4.00000000000000000000000000000000E-6143 -1.00004000000000000000000000000000E-6136 -> 0
-dqsamq083 samequantum -4E-6140 -1E-6143 -> 0
-dqsamq084 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6136 -> 0
-dqsamq085 samequantum -4E-1006 -1E-6176 -> 0
-dqsamq086 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6136 -> 0
-dqsamq087 samequantum -4E-6133 -1E-6143 -> 0
-dqsamq088 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6136 -> 0
-
--- specials & combinations
-dqsamq0110 samequantum -Inf -Inf -> 1
-dqsamq0111 samequantum -Inf Inf -> 1
-dqsamq0112 samequantum -Inf NaN -> 0
-dqsamq0113 samequantum -Inf -7E+3 -> 0
-dqsamq0114 samequantum -Inf -7 -> 0
-dqsamq0115 samequantum -Inf -7E-3 -> 0
-dqsamq0116 samequantum -Inf -0E-3 -> 0
-dqsamq0117 samequantum -Inf -0 -> 0
-dqsamq0118 samequantum -Inf -0E+3 -> 0
-dqsamq0119 samequantum -Inf 0E-3 -> 0
-dqsamq0120 samequantum -Inf 0 -> 0
-dqsamq0121 samequantum -Inf 0E+3 -> 0
-dqsamq0122 samequantum -Inf 7E-3 -> 0
-dqsamq0123 samequantum -Inf 7 -> 0
-dqsamq0124 samequantum -Inf 7E+3 -> 0
-dqsamq0125 samequantum -Inf sNaN -> 0
-
-dqsamq0210 samequantum Inf -Inf -> 1
-dqsamq0211 samequantum Inf Inf -> 1
-dqsamq0212 samequantum Inf NaN -> 0
-dqsamq0213 samequantum Inf -7E+3 -> 0
-dqsamq0214 samequantum Inf -7 -> 0
-dqsamq0215 samequantum Inf -7E-3 -> 0
-dqsamq0216 samequantum Inf -0E-3 -> 0
-dqsamq0217 samequantum Inf -0 -> 0
-dqsamq0218 samequantum Inf -0E+3 -> 0
-dqsamq0219 samequantum Inf 0E-3 -> 0
-dqsamq0220 samequantum Inf 0 -> 0
-dqsamq0221 samequantum Inf 0E+3 -> 0
-dqsamq0222 samequantum Inf 7E-3 -> 0
-dqsamq0223 samequantum Inf 7 -> 0
-dqsamq0224 samequantum Inf 7E+3 -> 0
-dqsamq0225 samequantum Inf sNaN -> 0
-
-dqsamq0310 samequantum NaN -Inf -> 0
-dqsamq0311 samequantum NaN Inf -> 0
-dqsamq0312 samequantum NaN NaN -> 1
-dqsamq0313 samequantum NaN -7E+3 -> 0
-dqsamq0314 samequantum NaN -7 -> 0
-dqsamq0315 samequantum NaN -7E-3 -> 0
-dqsamq0316 samequantum NaN -0E-3 -> 0
-dqsamq0317 samequantum NaN -0 -> 0
-dqsamq0318 samequantum NaN -0E+3 -> 0
-dqsamq0319 samequantum NaN 0E-3 -> 0
-dqsamq0320 samequantum NaN 0 -> 0
-dqsamq0321 samequantum NaN 0E+3 -> 0
-dqsamq0322 samequantum NaN 7E-3 -> 0
-dqsamq0323 samequantum NaN 7 -> 0
-dqsamq0324 samequantum NaN 7E+3 -> 0
-dqsamq0325 samequantum NaN sNaN -> 1
-
-dqsamq0410 samequantum -7E+3 -Inf -> 0
-dqsamq0411 samequantum -7E+3 Inf -> 0
-dqsamq0412 samequantum -7E+3 NaN -> 0
-dqsamq0413 samequantum -7E+3 -7E+3 -> 1
-dqsamq0414 samequantum -7E+3 -7 -> 0
-dqsamq0415 samequantum -7E+3 -7E-3 -> 0
-dqsamq0416 samequantum -7E+3 -0E-3 -> 0
-dqsamq0417 samequantum -7E+3 -0 -> 0
-dqsamq0418 samequantum -7E+3 -0E+3 -> 1
-dqsamq0419 samequantum -7E+3 0E-3 -> 0
-dqsamq0420 samequantum -7E+3 0 -> 0
-dqsamq0421 samequantum -7E+3 0E+3 -> 1
-dqsamq0422 samequantum -7E+3 7E-3 -> 0
-dqsamq0423 samequantum -7E+3 7 -> 0
-dqsamq0424 samequantum -7E+3 7E+3 -> 1
-dqsamq0425 samequantum -7E+3 sNaN -> 0
-
-dqsamq0510 samequantum -7 -Inf -> 0
-dqsamq0511 samequantum -7 Inf -> 0
-dqsamq0512 samequantum -7 NaN -> 0
-dqsamq0513 samequantum -7 -7E+3 -> 0
-dqsamq0514 samequantum -7 -7 -> 1
-dqsamq0515 samequantum -7 -7E-3 -> 0
-dqsamq0516 samequantum -7 -0E-3 -> 0
-dqsamq0517 samequantum -7 -0 -> 1
-dqsamq0518 samequantum -7 -0E+3 -> 0
-dqsamq0519 samequantum -7 0E-3 -> 0
-dqsamq0520 samequantum -7 0 -> 1
-dqsamq0521 samequantum -7 0E+3 -> 0
-dqsamq0522 samequantum -7 7E-3 -> 0
-dqsamq0523 samequantum -7 7 -> 1
-dqsamq0524 samequantum -7 7E+3 -> 0
-dqsamq0525 samequantum -7 sNaN -> 0
-
-dqsamq0610 samequantum -7E-3 -Inf -> 0
-dqsamq0611 samequantum -7E-3 Inf -> 0
-dqsamq0612 samequantum -7E-3 NaN -> 0
-dqsamq0613 samequantum -7E-3 -7E+3 -> 0
-dqsamq0614 samequantum -7E-3 -7 -> 0
-dqsamq0615 samequantum -7E-3 -7E-3 -> 1
-dqsamq0616 samequantum -7E-3 -0E-3 -> 1
-dqsamq0617 samequantum -7E-3 -0 -> 0
-dqsamq0618 samequantum -7E-3 -0E+3 -> 0
-dqsamq0619 samequantum -7E-3 0E-3 -> 1
-dqsamq0620 samequantum -7E-3 0 -> 0
-dqsamq0621 samequantum -7E-3 0E+3 -> 0
-dqsamq0622 samequantum -7E-3 7E-3 -> 1
-dqsamq0623 samequantum -7E-3 7 -> 0
-dqsamq0624 samequantum -7E-3 7E+3 -> 0
-dqsamq0625 samequantum -7E-3 sNaN -> 0
-
-dqsamq0710 samequantum -0E-3 -Inf -> 0
-dqsamq0711 samequantum -0E-3 Inf -> 0
-dqsamq0712 samequantum -0E-3 NaN -> 0
-dqsamq0713 samequantum -0E-3 -7E+3 -> 0
-dqsamq0714 samequantum -0E-3 -7 -> 0
-dqsamq0715 samequantum -0E-3 -7E-3 -> 1
-dqsamq0716 samequantum -0E-3 -0E-3 -> 1
-dqsamq0717 samequantum -0E-3 -0 -> 0
-dqsamq0718 samequantum -0E-3 -0E+3 -> 0
-dqsamq0719 samequantum -0E-3 0E-3 -> 1
-dqsamq0720 samequantum -0E-3 0 -> 0
-dqsamq0721 samequantum -0E-3 0E+3 -> 0
-dqsamq0722 samequantum -0E-3 7E-3 -> 1
-dqsamq0723 samequantum -0E-3 7 -> 0
-dqsamq0724 samequantum -0E-3 7E+3 -> 0
-dqsamq0725 samequantum -0E-3 sNaN -> 0
-
-dqsamq0810 samequantum -0 -Inf -> 0
-dqsamq0811 samequantum -0 Inf -> 0
-dqsamq0812 samequantum -0 NaN -> 0
-dqsamq0813 samequantum -0 -7E+3 -> 0
-dqsamq0814 samequantum -0 -7 -> 1
-dqsamq0815 samequantum -0 -7E-3 -> 0
-dqsamq0816 samequantum -0 -0E-3 -> 0
-dqsamq0817 samequantum -0 -0 -> 1
-dqsamq0818 samequantum -0 -0E+3 -> 0
-dqsamq0819 samequantum -0 0E-3 -> 0
-dqsamq0820 samequantum -0 0 -> 1
-dqsamq0821 samequantum -0 0E+3 -> 0
-dqsamq0822 samequantum -0 7E-3 -> 0
-dqsamq0823 samequantum -0 7 -> 1
-dqsamq0824 samequantum -0 7E+3 -> 0
-dqsamq0825 samequantum -0 sNaN -> 0
-
-dqsamq0910 samequantum -0E+3 -Inf -> 0
-dqsamq0911 samequantum -0E+3 Inf -> 0
-dqsamq0912 samequantum -0E+3 NaN -> 0
-dqsamq0913 samequantum -0E+3 -7E+3 -> 1
-dqsamq0914 samequantum -0E+3 -7 -> 0
-dqsamq0915 samequantum -0E+3 -7E-3 -> 0
-dqsamq0916 samequantum -0E+3 -0E-3 -> 0
-dqsamq0917 samequantum -0E+3 -0 -> 0
-dqsamq0918 samequantum -0E+3 -0E+3 -> 1
-dqsamq0919 samequantum -0E+3 0E-3 -> 0
-dqsamq0920 samequantum -0E+3 0 -> 0
-dqsamq0921 samequantum -0E+3 0E+3 -> 1
-dqsamq0922 samequantum -0E+3 7E-3 -> 0
-dqsamq0923 samequantum -0E+3 7 -> 0
-dqsamq0924 samequantum -0E+3 7E+3 -> 1
-dqsamq0925 samequantum -0E+3 sNaN -> 0
-
-dqsamq1110 samequantum 0E-3 -Inf -> 0
-dqsamq1111 samequantum 0E-3 Inf -> 0
-dqsamq1112 samequantum 0E-3 NaN -> 0
-dqsamq1113 samequantum 0E-3 -7E+3 -> 0
-dqsamq1114 samequantum 0E-3 -7 -> 0
-dqsamq1115 samequantum 0E-3 -7E-3 -> 1
-dqsamq1116 samequantum 0E-3 -0E-3 -> 1
-dqsamq1117 samequantum 0E-3 -0 -> 0
-dqsamq1118 samequantum 0E-3 -0E+3 -> 0
-dqsamq1119 samequantum 0E-3 0E-3 -> 1
-dqsamq1120 samequantum 0E-3 0 -> 0
-dqsamq1121 samequantum 0E-3 0E+3 -> 0
-dqsamq1122 samequantum 0E-3 7E-3 -> 1
-dqsamq1123 samequantum 0E-3 7 -> 0
-dqsamq1124 samequantum 0E-3 7E+3 -> 0
-dqsamq1125 samequantum 0E-3 sNaN -> 0
-
-dqsamq1210 samequantum 0 -Inf -> 0
-dqsamq1211 samequantum 0 Inf -> 0
-dqsamq1212 samequantum 0 NaN -> 0
-dqsamq1213 samequantum 0 -7E+3 -> 0
-dqsamq1214 samequantum 0 -7 -> 1
-dqsamq1215 samequantum 0 -7E-3 -> 0
-dqsamq1216 samequantum 0 -0E-3 -> 0
-dqsamq1217 samequantum 0 -0 -> 1
-dqsamq1218 samequantum 0 -0E+3 -> 0
-dqsamq1219 samequantum 0 0E-3 -> 0
-dqsamq1220 samequantum 0 0 -> 1
-dqsamq1221 samequantum 0 0E+3 -> 0
-dqsamq1222 samequantum 0 7E-3 -> 0
-dqsamq1223 samequantum 0 7 -> 1
-dqsamq1224 samequantum 0 7E+3 -> 0
-dqsamq1225 samequantum 0 sNaN -> 0
-
-dqsamq1310 samequantum 0E+3 -Inf -> 0
-dqsamq1311 samequantum 0E+3 Inf -> 0
-dqsamq1312 samequantum 0E+3 NaN -> 0
-dqsamq1313 samequantum 0E+3 -7E+3 -> 1
-dqsamq1314 samequantum 0E+3 -7 -> 0
-dqsamq1315 samequantum 0E+3 -7E-3 -> 0
-dqsamq1316 samequantum 0E+3 -0E-3 -> 0
-dqsamq1317 samequantum 0E+3 -0 -> 0
-dqsamq1318 samequantum 0E+3 -0E+3 -> 1
-dqsamq1319 samequantum 0E+3 0E-3 -> 0
-dqsamq1320 samequantum 0E+3 0 -> 0
-dqsamq1321 samequantum 0E+3 0E+3 -> 1
-dqsamq1322 samequantum 0E+3 7E-3 -> 0
-dqsamq1323 samequantum 0E+3 7 -> 0
-dqsamq1324 samequantum 0E+3 7E+3 -> 1
-dqsamq1325 samequantum 0E+3 sNaN -> 0
-
-dqsamq1410 samequantum 7E-3 -Inf -> 0
-dqsamq1411 samequantum 7E-3 Inf -> 0
-dqsamq1412 samequantum 7E-3 NaN -> 0
-dqsamq1413 samequantum 7E-3 -7E+3 -> 0
-dqsamq1414 samequantum 7E-3 -7 -> 0
-dqsamq1415 samequantum 7E-3 -7E-3 -> 1
-dqsamq1416 samequantum 7E-3 -0E-3 -> 1
-dqsamq1417 samequantum 7E-3 -0 -> 0
-dqsamq1418 samequantum 7E-3 -0E+3 -> 0
-dqsamq1419 samequantum 7E-3 0E-3 -> 1
-dqsamq1420 samequantum 7E-3 0 -> 0
-dqsamq1421 samequantum 7E-3 0E+3 -> 0
-dqsamq1422 samequantum 7E-3 7E-3 -> 1
-dqsamq1423 samequantum 7E-3 7 -> 0
-dqsamq1424 samequantum 7E-3 7E+3 -> 0
-dqsamq1425 samequantum 7E-3 sNaN -> 0
-
-dqsamq1510 samequantum 7 -Inf -> 0
-dqsamq1511 samequantum 7 Inf -> 0
-dqsamq1512 samequantum 7 NaN -> 0
-dqsamq1513 samequantum 7 -7E+3 -> 0
-dqsamq1514 samequantum 7 -7 -> 1
-dqsamq1515 samequantum 7 -7E-3 -> 0
-dqsamq1516 samequantum 7 -0E-3 -> 0
-dqsamq1517 samequantum 7 -0 -> 1
-dqsamq1518 samequantum 7 -0E+3 -> 0
-dqsamq1519 samequantum 7 0E-3 -> 0
-dqsamq1520 samequantum 7 0 -> 1
-dqsamq1521 samequantum 7 0E+3 -> 0
-dqsamq1522 samequantum 7 7E-3 -> 0
-dqsamq1523 samequantum 7 7 -> 1
-dqsamq1524 samequantum 7 7E+3 -> 0
-dqsamq1525 samequantum 7 sNaN -> 0
-
-dqsamq1610 samequantum 7E+3 -Inf -> 0
-dqsamq1611 samequantum 7E+3 Inf -> 0
-dqsamq1612 samequantum 7E+3 NaN -> 0
-dqsamq1613 samequantum 7E+3 -7E+3 -> 1
-dqsamq1614 samequantum 7E+3 -7 -> 0
-dqsamq1615 samequantum 7E+3 -7E-3 -> 0
-dqsamq1616 samequantum 7E+3 -0E-3 -> 0
-dqsamq1617 samequantum 7E+3 -0 -> 0
-dqsamq1618 samequantum 7E+3 -0E+3 -> 1
-dqsamq1619 samequantum 7E+3 0E-3 -> 0
-dqsamq1620 samequantum 7E+3 0 -> 0
-dqsamq1621 samequantum 7E+3 0E+3 -> 1
-dqsamq1622 samequantum 7E+3 7E-3 -> 0
-dqsamq1623 samequantum 7E+3 7 -> 0
-dqsamq1624 samequantum 7E+3 7E+3 -> 1
-dqsamq1625 samequantum 7E+3 sNaN -> 0
-
-dqsamq1710 samequantum sNaN -Inf -> 0
-dqsamq1711 samequantum sNaN Inf -> 0
-dqsamq1712 samequantum sNaN NaN -> 1
-dqsamq1713 samequantum sNaN -7E+3 -> 0
-dqsamq1714 samequantum sNaN -7 -> 0
-dqsamq1715 samequantum sNaN -7E-3 -> 0
-dqsamq1716 samequantum sNaN -0E-3 -> 0
-dqsamq1717 samequantum sNaN -0 -> 0
-dqsamq1718 samequantum sNaN -0E+3 -> 0
-dqsamq1719 samequantum sNaN 0E-3 -> 0
-dqsamq1720 samequantum sNaN 0 -> 0
-dqsamq1721 samequantum sNaN 0E+3 -> 0
-dqsamq1722 samequantum sNaN 7E-3 -> 0
-dqsamq1723 samequantum sNaN 7 -> 0
-dqsamq1724 samequantum sNaN 7E+3 -> 0
-dqsamq1725 samequantum sNaN sNaN -> 1
--- noisy NaNs
-dqsamq1730 samequantum sNaN3 sNaN3 -> 1
-dqsamq1731 samequantum sNaN3 sNaN4 -> 1
-dqsamq1732 samequantum NaN3 NaN3 -> 1
-dqsamq1733 samequantum NaN3 NaN4 -> 1
-dqsamq1734 samequantum sNaN3 3 -> 0
-dqsamq1735 samequantum NaN3 3 -> 0
-dqsamq1736 samequantum 4 sNaN4 -> 0
-dqsamq1737 samequantum 3 NaN3 -> 0
-dqsamq1738 samequantum Inf sNaN4 -> 0
-dqsamq1739 samequantum -Inf NaN3 -> 0
-
+------------------------------------------------------------------------
+-- dqSameQuantum.decTest -- check decQuad quantums match --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- All operands and results are decQuads.
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqsamq001 samequantum 0 0 -> 1
+dqsamq002 samequantum 0 1 -> 1
+dqsamq003 samequantum 1 0 -> 1
+dqsamq004 samequantum 1 1 -> 1
+
+dqsamq011 samequantum 10 1E+1 -> 0
+dqsamq012 samequantum 10E+1 10E+1 -> 1
+dqsamq013 samequantum 100 10E+1 -> 0
+dqsamq014 samequantum 100 1E+2 -> 0
+dqsamq015 samequantum 0.1 1E-2 -> 0
+dqsamq016 samequantum 0.1 1E-1 -> 1
+dqsamq017 samequantum 0.1 1E-0 -> 0
+dqsamq018 samequantum 999 999 -> 1
+dqsamq019 samequantum 999E-1 99.9 -> 1
+dqsamq020 samequantum 111E-1 22.2 -> 1
+dqsamq021 samequantum 111E-1 1234.2 -> 1
+
+-- zeros
+dqsamq030 samequantum 0.0 1.1 -> 1
+dqsamq031 samequantum 0.0 1.11 -> 0
+dqsamq032 samequantum 0.0 0 -> 0
+dqsamq033 samequantum 0.0 0.0 -> 1
+dqsamq034 samequantum 0.0 0.00 -> 0
+dqsamq035 samequantum 0E+1 0E+0 -> 0
+dqsamq036 samequantum 0E+1 0E+1 -> 1
+dqsamq037 samequantum 0E+1 0E+2 -> 0
+dqsamq038 samequantum 0E-17 0E-16 -> 0
+dqsamq039 samequantum 0E-17 0E-17 -> 1
+dqsamq040 samequantum 0E-17 0E-18 -> 0
+dqsamq041 samequantum 0E-17 0.0E-15 -> 0
+dqsamq042 samequantum 0E-17 0.0E-16 -> 1
+dqsamq043 samequantum 0E-17 0.0E-17 -> 0
+dqsamq044 samequantum -0E-17 0.0E-16 -> 1
+dqsamq045 samequantum 0E-17 -0.0E-17 -> 0
+dqsamq046 samequantum 0E-17 -0.0E-16 -> 1
+dqsamq047 samequantum -0E-17 0.0E-17 -> 0
+dqsamq048 samequantum -0E-17 -0.0E-16 -> 1
+dqsamq049 samequantum -0E-17 -0.0E-17 -> 0
+
+-- Nmax, Nmin, Ntiny
+dqsamq051 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
+dqsamq052 samequantum 1E-6143 1E-6143 -> 1
+dqsamq053 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
+dqsamq054 samequantum 1E-6176 1E-6176 -> 1
+dqsamq055 samequantum 9.99999999999999999999999999999999E+6144 9.99999999999999999999999999999999E+6144 -> 1
+dqsamq056 samequantum 1E-6143 1E-6143 -> 1
+dqsamq057 samequantum 1.00000000000000000000000000000000E-6143 1.00000000000000000000000000000000E-6143 -> 1
+dqsamq058 samequantum 1E-6176 1E-6176 -> 1
+
+dqsamq061 samequantum -1E-6176 -1E-6176 -> 1
+dqsamq062 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
+dqsamq063 samequantum -1E-6143 -1E-6143 -> 1
+dqsamq064 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
+dqsamq065 samequantum -1E-6176 -1E-6176 -> 1
+dqsamq066 samequantum -1.00000000000000000000000000000000E-6143 -1.00000000000000000000000000000000E-6143 -> 1
+dqsamq067 samequantum -1E-6143 -1E-6143 -> 1
+dqsamq068 samequantum -9.99999999999999999999999999999999E+6144 -9.99999999999999999999999999999999E+6144 -> 1
+
+dqsamq071 samequantum -4E-6176 -1E-6176 -> 1
+dqsamq072 samequantum -4.00000000000000000000000000000000E-6143 -1.00000000000000000000000000004000E-6143 -> 1
+dqsamq073 samequantum -4E-6143 -1E-6143 -> 1
+dqsamq074 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6144 -> 1
+dqsamq075 samequantum -4E-6176 -1E-6176 -> 1
+dqsamq076 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6143 -> 1
+dqsamq077 samequantum -4E-6143 -1E-6143 -> 1
+dqsamq078 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6144 -> 1
+
+dqsamq081 samequantum -4E-1006 -1E-6176 -> 0
+dqsamq082 samequantum -4.00000000000000000000000000000000E-6143 -1.00004000000000000000000000000000E-6136 -> 0
+dqsamq083 samequantum -4E-6140 -1E-6143 -> 0
+dqsamq084 samequantum -4.99999999999999999999999999999999E+6144 -9.99949999999999999999999999999999E+6136 -> 0
+dqsamq085 samequantum -4E-1006 -1E-6176 -> 0
+dqsamq086 samequantum -4.00000000000000000000000000000000E-6143 -1.00400000000000000000000000000000E-6136 -> 0
+dqsamq087 samequantum -4E-6133 -1E-6143 -> 0
+dqsamq088 samequantum -4.99999999999999999999999999999999E+6144 -9.94999999999999999999999999999999E+6136 -> 0
+
+-- specials & combinations
+dqsamq0110 samequantum -Inf -Inf -> 1
+dqsamq0111 samequantum -Inf Inf -> 1
+dqsamq0112 samequantum -Inf NaN -> 0
+dqsamq0113 samequantum -Inf -7E+3 -> 0
+dqsamq0114 samequantum -Inf -7 -> 0
+dqsamq0115 samequantum -Inf -7E-3 -> 0
+dqsamq0116 samequantum -Inf -0E-3 -> 0
+dqsamq0117 samequantum -Inf -0 -> 0
+dqsamq0118 samequantum -Inf -0E+3 -> 0
+dqsamq0119 samequantum -Inf 0E-3 -> 0
+dqsamq0120 samequantum -Inf 0 -> 0
+dqsamq0121 samequantum -Inf 0E+3 -> 0
+dqsamq0122 samequantum -Inf 7E-3 -> 0
+dqsamq0123 samequantum -Inf 7 -> 0
+dqsamq0124 samequantum -Inf 7E+3 -> 0
+dqsamq0125 samequantum -Inf sNaN -> 0
+
+dqsamq0210 samequantum Inf -Inf -> 1
+dqsamq0211 samequantum Inf Inf -> 1
+dqsamq0212 samequantum Inf NaN -> 0
+dqsamq0213 samequantum Inf -7E+3 -> 0
+dqsamq0214 samequantum Inf -7 -> 0
+dqsamq0215 samequantum Inf -7E-3 -> 0
+dqsamq0216 samequantum Inf -0E-3 -> 0
+dqsamq0217 samequantum Inf -0 -> 0
+dqsamq0218 samequantum Inf -0E+3 -> 0
+dqsamq0219 samequantum Inf 0E-3 -> 0
+dqsamq0220 samequantum Inf 0 -> 0
+dqsamq0221 samequantum Inf 0E+3 -> 0
+dqsamq0222 samequantum Inf 7E-3 -> 0
+dqsamq0223 samequantum Inf 7 -> 0
+dqsamq0224 samequantum Inf 7E+3 -> 0
+dqsamq0225 samequantum Inf sNaN -> 0
+
+dqsamq0310 samequantum NaN -Inf -> 0
+dqsamq0311 samequantum NaN Inf -> 0
+dqsamq0312 samequantum NaN NaN -> 1
+dqsamq0313 samequantum NaN -7E+3 -> 0
+dqsamq0314 samequantum NaN -7 -> 0
+dqsamq0315 samequantum NaN -7E-3 -> 0
+dqsamq0316 samequantum NaN -0E-3 -> 0
+dqsamq0317 samequantum NaN -0 -> 0
+dqsamq0318 samequantum NaN -0E+3 -> 0
+dqsamq0319 samequantum NaN 0E-3 -> 0
+dqsamq0320 samequantum NaN 0 -> 0
+dqsamq0321 samequantum NaN 0E+3 -> 0
+dqsamq0322 samequantum NaN 7E-3 -> 0
+dqsamq0323 samequantum NaN 7 -> 0
+dqsamq0324 samequantum NaN 7E+3 -> 0
+dqsamq0325 samequantum NaN sNaN -> 1
+
+dqsamq0410 samequantum -7E+3 -Inf -> 0
+dqsamq0411 samequantum -7E+3 Inf -> 0
+dqsamq0412 samequantum -7E+3 NaN -> 0
+dqsamq0413 samequantum -7E+3 -7E+3 -> 1
+dqsamq0414 samequantum -7E+3 -7 -> 0
+dqsamq0415 samequantum -7E+3 -7E-3 -> 0
+dqsamq0416 samequantum -7E+3 -0E-3 -> 0
+dqsamq0417 samequantum -7E+3 -0 -> 0
+dqsamq0418 samequantum -7E+3 -0E+3 -> 1
+dqsamq0419 samequantum -7E+3 0E-3 -> 0
+dqsamq0420 samequantum -7E+3 0 -> 0
+dqsamq0421 samequantum -7E+3 0E+3 -> 1
+dqsamq0422 samequantum -7E+3 7E-3 -> 0
+dqsamq0423 samequantum -7E+3 7 -> 0
+dqsamq0424 samequantum -7E+3 7E+3 -> 1
+dqsamq0425 samequantum -7E+3 sNaN -> 0
+
+dqsamq0510 samequantum -7 -Inf -> 0
+dqsamq0511 samequantum -7 Inf -> 0
+dqsamq0512 samequantum -7 NaN -> 0
+dqsamq0513 samequantum -7 -7E+3 -> 0
+dqsamq0514 samequantum -7 -7 -> 1
+dqsamq0515 samequantum -7 -7E-3 -> 0
+dqsamq0516 samequantum -7 -0E-3 -> 0
+dqsamq0517 samequantum -7 -0 -> 1
+dqsamq0518 samequantum -7 -0E+3 -> 0
+dqsamq0519 samequantum -7 0E-3 -> 0
+dqsamq0520 samequantum -7 0 -> 1
+dqsamq0521 samequantum -7 0E+3 -> 0
+dqsamq0522 samequantum -7 7E-3 -> 0
+dqsamq0523 samequantum -7 7 -> 1
+dqsamq0524 samequantum -7 7E+3 -> 0
+dqsamq0525 samequantum -7 sNaN -> 0
+
+dqsamq0610 samequantum -7E-3 -Inf -> 0
+dqsamq0611 samequantum -7E-3 Inf -> 0
+dqsamq0612 samequantum -7E-3 NaN -> 0
+dqsamq0613 samequantum -7E-3 -7E+3 -> 0
+dqsamq0614 samequantum -7E-3 -7 -> 0
+dqsamq0615 samequantum -7E-3 -7E-3 -> 1
+dqsamq0616 samequantum -7E-3 -0E-3 -> 1
+dqsamq0617 samequantum -7E-3 -0 -> 0
+dqsamq0618 samequantum -7E-3 -0E+3 -> 0
+dqsamq0619 samequantum -7E-3 0E-3 -> 1
+dqsamq0620 samequantum -7E-3 0 -> 0
+dqsamq0621 samequantum -7E-3 0E+3 -> 0
+dqsamq0622 samequantum -7E-3 7E-3 -> 1
+dqsamq0623 samequantum -7E-3 7 -> 0
+dqsamq0624 samequantum -7E-3 7E+3 -> 0
+dqsamq0625 samequantum -7E-3 sNaN -> 0
+
+dqsamq0710 samequantum -0E-3 -Inf -> 0
+dqsamq0711 samequantum -0E-3 Inf -> 0
+dqsamq0712 samequantum -0E-3 NaN -> 0
+dqsamq0713 samequantum -0E-3 -7E+3 -> 0
+dqsamq0714 samequantum -0E-3 -7 -> 0
+dqsamq0715 samequantum -0E-3 -7E-3 -> 1
+dqsamq0716 samequantum -0E-3 -0E-3 -> 1
+dqsamq0717 samequantum -0E-3 -0 -> 0
+dqsamq0718 samequantum -0E-3 -0E+3 -> 0
+dqsamq0719 samequantum -0E-3 0E-3 -> 1
+dqsamq0720 samequantum -0E-3 0 -> 0
+dqsamq0721 samequantum -0E-3 0E+3 -> 0
+dqsamq0722 samequantum -0E-3 7E-3 -> 1
+dqsamq0723 samequantum -0E-3 7 -> 0
+dqsamq0724 samequantum -0E-3 7E+3 -> 0
+dqsamq0725 samequantum -0E-3 sNaN -> 0
+
+dqsamq0810 samequantum -0 -Inf -> 0
+dqsamq0811 samequantum -0 Inf -> 0
+dqsamq0812 samequantum -0 NaN -> 0
+dqsamq0813 samequantum -0 -7E+3 -> 0
+dqsamq0814 samequantum -0 -7 -> 1
+dqsamq0815 samequantum -0 -7E-3 -> 0
+dqsamq0816 samequantum -0 -0E-3 -> 0
+dqsamq0817 samequantum -0 -0 -> 1
+dqsamq0818 samequantum -0 -0E+3 -> 0
+dqsamq0819 samequantum -0 0E-3 -> 0
+dqsamq0820 samequantum -0 0 -> 1
+dqsamq0821 samequantum -0 0E+3 -> 0
+dqsamq0822 samequantum -0 7E-3 -> 0
+dqsamq0823 samequantum -0 7 -> 1
+dqsamq0824 samequantum -0 7E+3 -> 0
+dqsamq0825 samequantum -0 sNaN -> 0
+
+dqsamq0910 samequantum -0E+3 -Inf -> 0
+dqsamq0911 samequantum -0E+3 Inf -> 0
+dqsamq0912 samequantum -0E+3 NaN -> 0
+dqsamq0913 samequantum -0E+3 -7E+3 -> 1
+dqsamq0914 samequantum -0E+3 -7 -> 0
+dqsamq0915 samequantum -0E+3 -7E-3 -> 0
+dqsamq0916 samequantum -0E+3 -0E-3 -> 0
+dqsamq0917 samequantum -0E+3 -0 -> 0
+dqsamq0918 samequantum -0E+3 -0E+3 -> 1
+dqsamq0919 samequantum -0E+3 0E-3 -> 0
+dqsamq0920 samequantum -0E+3 0 -> 0
+dqsamq0921 samequantum -0E+3 0E+3 -> 1
+dqsamq0922 samequantum -0E+3 7E-3 -> 0
+dqsamq0923 samequantum -0E+3 7 -> 0
+dqsamq0924 samequantum -0E+3 7E+3 -> 1
+dqsamq0925 samequantum -0E+3 sNaN -> 0
+
+dqsamq1110 samequantum 0E-3 -Inf -> 0
+dqsamq1111 samequantum 0E-3 Inf -> 0
+dqsamq1112 samequantum 0E-3 NaN -> 0
+dqsamq1113 samequantum 0E-3 -7E+3 -> 0
+dqsamq1114 samequantum 0E-3 -7 -> 0
+dqsamq1115 samequantum 0E-3 -7E-3 -> 1
+dqsamq1116 samequantum 0E-3 -0E-3 -> 1
+dqsamq1117 samequantum 0E-3 -0 -> 0
+dqsamq1118 samequantum 0E-3 -0E+3 -> 0
+dqsamq1119 samequantum 0E-3 0E-3 -> 1
+dqsamq1120 samequantum 0E-3 0 -> 0
+dqsamq1121 samequantum 0E-3 0E+3 -> 0
+dqsamq1122 samequantum 0E-3 7E-3 -> 1
+dqsamq1123 samequantum 0E-3 7 -> 0
+dqsamq1124 samequantum 0E-3 7E+3 -> 0
+dqsamq1125 samequantum 0E-3 sNaN -> 0
+
+dqsamq1210 samequantum 0 -Inf -> 0
+dqsamq1211 samequantum 0 Inf -> 0
+dqsamq1212 samequantum 0 NaN -> 0
+dqsamq1213 samequantum 0 -7E+3 -> 0
+dqsamq1214 samequantum 0 -7 -> 1
+dqsamq1215 samequantum 0 -7E-3 -> 0
+dqsamq1216 samequantum 0 -0E-3 -> 0
+dqsamq1217 samequantum 0 -0 -> 1
+dqsamq1218 samequantum 0 -0E+3 -> 0
+dqsamq1219 samequantum 0 0E-3 -> 0
+dqsamq1220 samequantum 0 0 -> 1
+dqsamq1221 samequantum 0 0E+3 -> 0
+dqsamq1222 samequantum 0 7E-3 -> 0
+dqsamq1223 samequantum 0 7 -> 1
+dqsamq1224 samequantum 0 7E+3 -> 0
+dqsamq1225 samequantum 0 sNaN -> 0
+
+dqsamq1310 samequantum 0E+3 -Inf -> 0
+dqsamq1311 samequantum 0E+3 Inf -> 0
+dqsamq1312 samequantum 0E+3 NaN -> 0
+dqsamq1313 samequantum 0E+3 -7E+3 -> 1
+dqsamq1314 samequantum 0E+3 -7 -> 0
+dqsamq1315 samequantum 0E+3 -7E-3 -> 0
+dqsamq1316 samequantum 0E+3 -0E-3 -> 0
+dqsamq1317 samequantum 0E+3 -0 -> 0
+dqsamq1318 samequantum 0E+3 -0E+3 -> 1
+dqsamq1319 samequantum 0E+3 0E-3 -> 0
+dqsamq1320 samequantum 0E+3 0 -> 0
+dqsamq1321 samequantum 0E+3 0E+3 -> 1
+dqsamq1322 samequantum 0E+3 7E-3 -> 0
+dqsamq1323 samequantum 0E+3 7 -> 0
+dqsamq1324 samequantum 0E+3 7E+3 -> 1
+dqsamq1325 samequantum 0E+3 sNaN -> 0
+
+dqsamq1410 samequantum 7E-3 -Inf -> 0
+dqsamq1411 samequantum 7E-3 Inf -> 0
+dqsamq1412 samequantum 7E-3 NaN -> 0
+dqsamq1413 samequantum 7E-3 -7E+3 -> 0
+dqsamq1414 samequantum 7E-3 -7 -> 0
+dqsamq1415 samequantum 7E-3 -7E-3 -> 1
+dqsamq1416 samequantum 7E-3 -0E-3 -> 1
+dqsamq1417 samequantum 7E-3 -0 -> 0
+dqsamq1418 samequantum 7E-3 -0E+3 -> 0
+dqsamq1419 samequantum 7E-3 0E-3 -> 1
+dqsamq1420 samequantum 7E-3 0 -> 0
+dqsamq1421 samequantum 7E-3 0E+3 -> 0
+dqsamq1422 samequantum 7E-3 7E-3 -> 1
+dqsamq1423 samequantum 7E-3 7 -> 0
+dqsamq1424 samequantum 7E-3 7E+3 -> 0
+dqsamq1425 samequantum 7E-3 sNaN -> 0
+
+dqsamq1510 samequantum 7 -Inf -> 0
+dqsamq1511 samequantum 7 Inf -> 0
+dqsamq1512 samequantum 7 NaN -> 0
+dqsamq1513 samequantum 7 -7E+3 -> 0
+dqsamq1514 samequantum 7 -7 -> 1
+dqsamq1515 samequantum 7 -7E-3 -> 0
+dqsamq1516 samequantum 7 -0E-3 -> 0
+dqsamq1517 samequantum 7 -0 -> 1
+dqsamq1518 samequantum 7 -0E+3 -> 0
+dqsamq1519 samequantum 7 0E-3 -> 0
+dqsamq1520 samequantum 7 0 -> 1
+dqsamq1521 samequantum 7 0E+3 -> 0
+dqsamq1522 samequantum 7 7E-3 -> 0
+dqsamq1523 samequantum 7 7 -> 1
+dqsamq1524 samequantum 7 7E+3 -> 0
+dqsamq1525 samequantum 7 sNaN -> 0
+
+dqsamq1610 samequantum 7E+3 -Inf -> 0
+dqsamq1611 samequantum 7E+3 Inf -> 0
+dqsamq1612 samequantum 7E+3 NaN -> 0
+dqsamq1613 samequantum 7E+3 -7E+3 -> 1
+dqsamq1614 samequantum 7E+3 -7 -> 0
+dqsamq1615 samequantum 7E+3 -7E-3 -> 0
+dqsamq1616 samequantum 7E+3 -0E-3 -> 0
+dqsamq1617 samequantum 7E+3 -0 -> 0
+dqsamq1618 samequantum 7E+3 -0E+3 -> 1
+dqsamq1619 samequantum 7E+3 0E-3 -> 0
+dqsamq1620 samequantum 7E+3 0 -> 0
+dqsamq1621 samequantum 7E+3 0E+3 -> 1
+dqsamq1622 samequantum 7E+3 7E-3 -> 0
+dqsamq1623 samequantum 7E+3 7 -> 0
+dqsamq1624 samequantum 7E+3 7E+3 -> 1
+dqsamq1625 samequantum 7E+3 sNaN -> 0
+
+dqsamq1710 samequantum sNaN -Inf -> 0
+dqsamq1711 samequantum sNaN Inf -> 0
+dqsamq1712 samequantum sNaN NaN -> 1
+dqsamq1713 samequantum sNaN -7E+3 -> 0
+dqsamq1714 samequantum sNaN -7 -> 0
+dqsamq1715 samequantum sNaN -7E-3 -> 0
+dqsamq1716 samequantum sNaN -0E-3 -> 0
+dqsamq1717 samequantum sNaN -0 -> 0
+dqsamq1718 samequantum sNaN -0E+3 -> 0
+dqsamq1719 samequantum sNaN 0E-3 -> 0
+dqsamq1720 samequantum sNaN 0 -> 0
+dqsamq1721 samequantum sNaN 0E+3 -> 0
+dqsamq1722 samequantum sNaN 7E-3 -> 0
+dqsamq1723 samequantum sNaN 7 -> 0
+dqsamq1724 samequantum sNaN 7E+3 -> 0
+dqsamq1725 samequantum sNaN sNaN -> 1
+-- noisy NaNs
+dqsamq1730 samequantum sNaN3 sNaN3 -> 1
+dqsamq1731 samequantum sNaN3 sNaN4 -> 1
+dqsamq1732 samequantum NaN3 NaN3 -> 1
+dqsamq1733 samequantum NaN3 NaN4 -> 1
+dqsamq1734 samequantum sNaN3 3 -> 0
+dqsamq1735 samequantum NaN3 3 -> 0
+dqsamq1736 samequantum 4 sNaN4 -> 0
+dqsamq1737 samequantum 3 NaN3 -> 0
+dqsamq1738 samequantum Inf sNaN4 -> 0
+dqsamq1739 samequantum -Inf NaN3 -> 0
+
diff --git a/Lib/test/decimaltestdata/dqScaleB.decTest b/Lib/test/decimaltestdata/dqScaleB.decTest
index 045dc58d82b..01e1191963c 100644
--- a/Lib/test/decimaltestdata/dqScaleB.decTest
+++ b/Lib/test/decimaltestdata/dqScaleB.decTest
@@ -1,260 +1,260 @@
-------------------------------------------------------------------------
--- dqScalebB.decTest -- scale a decQuad by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Max |rhs| is 2*(6144+34) = 12356
-
--- Sanity checks
-dqscb001 scaleb 7.50 10 -> 7.50E+10
-dqscb002 scaleb 7.50 3 -> 7.50E+3
-dqscb003 scaleb 7.50 2 -> 750
-dqscb004 scaleb 7.50 1 -> 75.0
-dqscb005 scaleb 7.50 0 -> 7.50
-dqscb006 scaleb 7.50 -1 -> 0.750
-dqscb007 scaleb 7.50 -2 -> 0.0750
-dqscb008 scaleb 7.50 -10 -> 7.50E-10
-dqscb009 scaleb -7.50 3 -> -7.50E+3
-dqscb010 scaleb -7.50 2 -> -750
-dqscb011 scaleb -7.50 1 -> -75.0
-dqscb012 scaleb -7.50 0 -> -7.50
-dqscb013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-dqscb014 scaleb Infinity 1 -> Infinity
-dqscb015 scaleb -Infinity 2 -> -Infinity
-dqscb016 scaleb Infinity -1 -> Infinity
-dqscb017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-dqscb018 scaleb 10 Infinity -> NaN Invalid_operation
-dqscb019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-dqscb021 scaleb NaN 1 -> NaN
-dqscb022 scaleb -NaN -1 -> -NaN
-dqscb023 scaleb sNaN 1 -> NaN Invalid_operation
-dqscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
-dqscb025 scaleb 4 NaN -> NaN
-dqscb026 scaleb -Inf -NaN -> -NaN
-dqscb027 scaleb 4 sNaN -> NaN Invalid_operation
-dqscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-dqscb030 scaleb 1.23 1 -> 12.3
-dqscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
-dqscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
-dqscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
-dqscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
-dqscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
-dqscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-dqscb037 scaleb 1.23 -1 -> 0.123
-dqscb0614 scaleb 1.23 -1.00 -> NaN Invalid_operation
-dqscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-dqscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-dqscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-dqscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-dqscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-dqscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
-dqscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-dqscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-dqscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
--- out-of range RHS
-dqscb120 scaleb 1.23 12355 -> Infinity Overflow Inexact Rounded
-dqscb121 scaleb 1.23 12356 -> Infinity Overflow Inexact Rounded
-dqscb122 scaleb 1.23 12357 -> NaN Invalid_operation
-dqscb123 scaleb 1.23 12358 -> NaN Invalid_operation
-dqscb124 scaleb 1.23 -12355 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb125 scaleb 1.23 -12356 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb126 scaleb 1.23 -12357 -> NaN Invalid_operation
-dqscb127 scaleb 1.23 -12358 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-dqscb861 scaleb NaN01 -Inf -> NaN1
-dqscb862 scaleb -NaN02 -1000 -> -NaN2
-dqscb863 scaleb NaN03 1000 -> NaN3
-dqscb864 scaleb NaN04 Inf -> NaN4
-dqscb865 scaleb NaN05 NaN61 -> NaN5
-dqscb866 scaleb -Inf -NaN71 -> -NaN71
-dqscb867 scaleb -1000 NaN81 -> NaN81
-dqscb868 scaleb 1000 NaN91 -> NaN91
-dqscb869 scaleb Inf NaN101 -> NaN101
-dqscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-dqscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-dqscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-dqscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-dqscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-dqscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-dqscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-dqscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-dqscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-dqscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-dqscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-dqscb051 scaleb 7 -2 -> 0.07
-dqscb052 scaleb -7 -2 -> -0.07
-dqscb053 scaleb 75 -2 -> 0.75
-dqscb054 scaleb -75 -2 -> -0.75
-dqscb055 scaleb 7.50 -2 -> 0.0750
-dqscb056 scaleb -7.50 -2 -> -0.0750
-dqscb057 scaleb 7.500 -2 -> 0.07500
-dqscb058 scaleb -7.500 -2 -> -0.07500
-dqscb061 scaleb 7 -1 -> 0.7
-dqscb062 scaleb -7 -1 -> -0.7
-dqscb063 scaleb 75 -1 -> 7.5
-dqscb064 scaleb -75 -1 -> -7.5
-dqscb065 scaleb 7.50 -1 -> 0.750
-dqscb066 scaleb -7.50 -1 -> -0.750
-dqscb067 scaleb 7.500 -1 -> 0.7500
-dqscb068 scaleb -7.500 -1 -> -0.7500
-dqscb071 scaleb 7 0 -> 7
-dqscb072 scaleb -7 0 -> -7
-dqscb073 scaleb 75 0 -> 75
-dqscb074 scaleb -75 0 -> -75
-dqscb075 scaleb 7.50 0 -> 7.50
-dqscb076 scaleb -7.50 0 -> -7.50
-dqscb077 scaleb 7.500 0 -> 7.500
-dqscb078 scaleb -7.500 0 -> -7.500
-dqscb081 scaleb 7 1 -> 7E+1
-dqscb082 scaleb -7 1 -> -7E+1
-dqscb083 scaleb 75 1 -> 7.5E+2
-dqscb084 scaleb -75 1 -> -7.5E+2
-dqscb085 scaleb 7.50 1 -> 75.0
-dqscb086 scaleb -7.50 1 -> -75.0
-dqscb087 scaleb 7.500 1 -> 75.00
-dqscb088 scaleb -7.500 1 -> -75.00
-dqscb091 scaleb 7 2 -> 7E+2
-dqscb092 scaleb -7 2 -> -7E+2
-dqscb093 scaleb 75 2 -> 7.5E+3
-dqscb094 scaleb -75 2 -> -7.5E+3
-dqscb095 scaleb 7.50 2 -> 750
-dqscb096 scaleb -7.50 2 -> -750
-dqscb097 scaleb 7.500 2 -> 750.0
-dqscb098 scaleb -7.500 2 -> -750.0
-
--- zeros
-dqscb111 scaleb 0 1 -> 0E+1
-dqscb112 scaleb -0 2 -> -0E+2
-dqscb113 scaleb 0E+4 3 -> 0E+7
-dqscb114 scaleb -0E+4 4 -> -0E+8
-dqscb115 scaleb 0.0000 5 -> 0E+1
-dqscb116 scaleb -0.0000 6 -> -0E+2
-dqscb117 scaleb 0E-141 7 -> 0E-134
-dqscb118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-dqscb132 scaleb 9.999999999999999999999999999999999E+6144 +6144 -> Infinity Overflow Inexact Rounded
-dqscb133 scaleb 9.999999999999999999999999999999999E+6144 +10 -> Infinity Overflow Inexact Rounded
-dqscb134 scaleb 9.999999999999999999999999999999999E+6144 +1 -> Infinity Overflow Inexact Rounded
-dqscb135 scaleb 9.999999999999999999999999999999999E+6144 0 -> 9.999999999999999999999999999999999E+6144
-dqscb136 scaleb 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6143
-dqscb137 scaleb 1E-6143 +1 -> 1E-6142
-dqscb1614 scaleb 1E-6143 -0 -> 1E-6143
-dqscb139 scaleb 1E-6143 -1 -> 1E-6144 Subnormal
-dqscb140 scaleb 1.000000000000000000000000000000000E-6143 +1 -> 1.000000000000000000000000000000000E-6142
-dqscb141 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
-dqscb142 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb143 scaleb 1E-6176 +1 -> 1E-6175 Subnormal
-dqscb144 scaleb 1E-6176 -0 -> 1E-6176 Subnormal
-dqscb145 scaleb 1E-6176 -1 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-
-dqscb150 scaleb -1E-6176 +1 -> -1E-6175 Subnormal
-dqscb151 scaleb -1E-6176 -0 -> -1E-6176 Subnormal
-dqscb152 scaleb -1E-6176 -1 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb153 scaleb -1.000000000000000000000000000000000E-6143 +1 -> -1.000000000000000000000000000000000E-6142
-dqscb154 scaleb -1.000000000000000000000000000000000E-6143 +0 -> -1.000000000000000000000000000000000E-6143
-dqscb155 scaleb -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb156 scaleb -1E-6143 +1 -> -1E-6142
-dqscb157 scaleb -1E-6143 -0 -> -1E-6143
-dqscb158 scaleb -1E-6143 -1 -> -1E-6144 Subnormal
-dqscb159 scaleb -9.999999999999999999999999999999999E+6144 +1 -> -Infinity Overflow Inexact Rounded
-dqscb160 scaleb -9.999999999999999999999999999999999E+6144 +0 -> -9.999999999999999999999999999999999E+6144
-dqscb161 scaleb -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6143
-dqscb162 scaleb -9E+6144 +1 -> -Infinity Overflow Inexact Rounded
-dqscb163 scaleb -1E+6144 +1 -> -Infinity Overflow Inexact Rounded
-
--- some Origami
--- (these check that overflow is being done correctly)
-dqscb171 scaleb 1000E+6109 +1 -> 1.000E+6113
-dqscb172 scaleb 1000E+6110 +1 -> 1.000E+6114
-dqscb173 scaleb 1000E+6111 +1 -> 1.0000E+6115 Clamped
-dqscb174 scaleb 1000E+6112 +1 -> 1.00000E+6116 Clamped
-dqscb175 scaleb 1000E+6113 +1 -> 1.000000E+6117 Clamped
-dqscb176 scaleb 1000E+6114 +1 -> 1.0000000E+6118 Clamped
-dqscb177 scaleb 1000E+6131 +1 -> 1.000000000000000000000000E+6135 Clamped
-dqscb178 scaleb 1000E+6132 +1 -> 1.0000000000000000000000000E+6136 Clamped
-dqscb179 scaleb 1000E+6133 +1 -> 1.00000000000000000000000000E+6137 Clamped
-dqscb180 scaleb 1000E+6134 +1 -> 1.000000000000000000000000000E+6138 Clamped
-dqscb181 scaleb 1000E+6135 +1 -> 1.0000000000000000000000000000E+6139 Clamped
-dqscb182 scaleb 1000E+6136 +1 -> 1.00000000000000000000000000000E+6140 Clamped
-dqscb183 scaleb 1000E+6137 +1 -> 1.000000000000000000000000000000E+6141 Clamped
-dqscb184 scaleb 1000E+6138 +1 -> 1.0000000000000000000000000000000E+6142 Clamped
-dqscb185 scaleb 1000E+6139 +1 -> 1.00000000000000000000000000000000E+6143 Clamped
-dqscb186 scaleb 1000E+6140 +1 -> 1.000000000000000000000000000000000E+6144 Clamped
-dqscb187 scaleb 1000E+6141 +1 -> Infinity Overflow Inexact Rounded
-
--- and a few more subnormal truncations
--- (these check that underflow is being done correctly)
-dqscb221 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
-dqscb222 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
-dqscb223 scaleb 1.000000000000000000000000000000000E-6143 -2 -> 1.0000000000000000000000000000000E-6145 Subnormal Rounded
-dqscb224 scaleb 1.000000000000000000000000000000000E-6143 -3 -> 1.000000000000000000000000000000E-6146 Subnormal Rounded
-dqscb225 scaleb 1.000000000000000000000000000000000E-6143 -4 -> 1.00000000000000000000000000000E-6147 Subnormal Rounded
-dqscb226 scaleb 1.000000000000000000000000000000000E-6143 -5 -> 1.0000000000000000000000000000E-6148 Subnormal Rounded
-dqscb227 scaleb 1.000000000000000000000000000000000E-6143 -6 -> 1.000000000000000000000000000E-6149 Subnormal Rounded
-dqscb228 scaleb 1.000000000000000000000000000000000E-6143 -7 -> 1.00000000000000000000000000E-6150 Subnormal Rounded
-dqscb229 scaleb 1.000000000000000000000000000000000E-6143 -8 -> 1.0000000000000000000000000E-6151 Subnormal Rounded
-dqscb230 scaleb 1.000000000000000000000000000000000E-6143 -9 -> 1.000000000000000000000000E-6152 Subnormal Rounded
-dqscb231 scaleb 1.000000000000000000000000000000000E-6143 -10 -> 1.00000000000000000000000E-6153 Subnormal Rounded
-dqscb232 scaleb 1.000000000000000000000000000000000E-6143 -11 -> 1.0000000000000000000000E-6154 Subnormal Rounded
-dqscb233 scaleb 1.000000000000000000000000000000000E-6143 -12 -> 1.000000000000000000000E-6155 Subnormal Rounded
-dqscb234 scaleb 1.000000000000000000000000000000000E-6143 -13 -> 1.00000000000000000000E-6156 Subnormal Rounded
-dqscb235 scaleb 1.000000000000000000000000000000000E-6143 -14 -> 1.0000000000000000000E-6157 Subnormal Rounded
-dqscb236 scaleb 1.000000000000000000000000000000000E-6143 -15 -> 1.000000000000000000E-6158 Subnormal Rounded
-dqscb237 scaleb 1.000000000000000000000000000000000E-6143 -16 -> 1.00000000000000000E-6159 Subnormal Rounded
-dqscb238 scaleb 1.000000000000000000000000000000000E-6143 -17 -> 1.0000000000000000E-6160 Subnormal Rounded
-dqscb239 scaleb 1.000000000000000000000000000000000E-6143 -18 -> 1.000000000000000E-6161 Subnormal Rounded
-dqscb202 scaleb 1.000000000000000000000000000000000E-6143 -19 -> 1.00000000000000E-6162 Subnormal Rounded
-dqscb203 scaleb 1.000000000000000000000000000000000E-6143 -20 -> 1.0000000000000E-6163 Subnormal Rounded
-dqscb204 scaleb 1.000000000000000000000000000000000E-6143 -21 -> 1.000000000000E-6164 Subnormal Rounded
-dqscb205 scaleb 1.000000000000000000000000000000000E-6143 -22 -> 1.00000000000E-6165 Subnormal Rounded
-dqscb206 scaleb 1.000000000000000000000000000000000E-6143 -23 -> 1.0000000000E-6166 Subnormal Rounded
-dqscb207 scaleb 1.000000000000000000000000000000000E-6143 -24 -> 1.000000000E-6167 Subnormal Rounded
-dqscb208 scaleb 1.000000000000000000000000000000000E-6143 -25 -> 1.00000000E-6168 Subnormal Rounded
-dqscb209 scaleb 1.000000000000000000000000000000000E-6143 -26 -> 1.0000000E-6169 Subnormal Rounded
-dqscb210 scaleb 1.000000000000000000000000000000000E-6143 -27 -> 1.000000E-6170 Subnormal Rounded
-dqscb211 scaleb 1.000000000000000000000000000000000E-6143 -28 -> 1.00000E-6171 Subnormal Rounded
-dqscb212 scaleb 1.000000000000000000000000000000000E-6143 -29 -> 1.0000E-6172 Subnormal Rounded
-dqscb213 scaleb 1.000000000000000000000000000000000E-6143 -30 -> 1.000E-6173 Subnormal Rounded
-dqscb214 scaleb 1.000000000000000000000000000000000E-6143 -31 -> 1.00E-6174 Subnormal Rounded
-dqscb215 scaleb 1.000000000000000000000000000000000E-6143 -32 -> 1.0E-6175 Subnormal Rounded
-dqscb216 scaleb 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176 Subnormal Rounded
-dqscb217 scaleb 1.000000000000000000000000000000000E-6143 -34 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
-dqscb218 scaleb 1.000000000000000000000000000000000E-6143 -35 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+------------------------------------------------------------------------
+-- dqScalebB.decTest -- scale a decQuad by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Max |rhs| is 2*(6144+34) = 12356
+
+-- Sanity checks
+dqscb001 scaleb 7.50 10 -> 7.50E+10
+dqscb002 scaleb 7.50 3 -> 7.50E+3
+dqscb003 scaleb 7.50 2 -> 750
+dqscb004 scaleb 7.50 1 -> 75.0
+dqscb005 scaleb 7.50 0 -> 7.50
+dqscb006 scaleb 7.50 -1 -> 0.750
+dqscb007 scaleb 7.50 -2 -> 0.0750
+dqscb008 scaleb 7.50 -10 -> 7.50E-10
+dqscb009 scaleb -7.50 3 -> -7.50E+3
+dqscb010 scaleb -7.50 2 -> -750
+dqscb011 scaleb -7.50 1 -> -75.0
+dqscb012 scaleb -7.50 0 -> -7.50
+dqscb013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+dqscb014 scaleb Infinity 1 -> Infinity
+dqscb015 scaleb -Infinity 2 -> -Infinity
+dqscb016 scaleb Infinity -1 -> Infinity
+dqscb017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+dqscb018 scaleb 10 Infinity -> NaN Invalid_operation
+dqscb019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+dqscb021 scaleb NaN 1 -> NaN
+dqscb022 scaleb -NaN -1 -> -NaN
+dqscb023 scaleb sNaN 1 -> NaN Invalid_operation
+dqscb024 scaleb -sNaN 1 -> -NaN Invalid_operation
+dqscb025 scaleb 4 NaN -> NaN
+dqscb026 scaleb -Inf -NaN -> -NaN
+dqscb027 scaleb 4 sNaN -> NaN Invalid_operation
+dqscb028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+dqscb030 scaleb 1.23 1 -> 12.3
+dqscb031 scaleb 1.23 1.00 -> NaN Invalid_operation
+dqscb032 scaleb 1.23 1.1 -> NaN Invalid_operation
+dqscb033 scaleb 1.23 1.01 -> NaN Invalid_operation
+dqscb034 scaleb 1.23 0.01 -> NaN Invalid_operation
+dqscb035 scaleb 1.23 0.11 -> NaN Invalid_operation
+dqscb036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+dqscb037 scaleb 1.23 -1 -> 0.123
+dqscb0614 scaleb 1.23 -1.00 -> NaN Invalid_operation
+dqscb039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+dqscb040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+dqscb041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+dqscb042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+dqscb043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+dqscb044 scaleb 1.23 0.1 -> NaN Invalid_operation
+dqscb045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+dqscb046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+dqscb047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+-- out-of range RHS
+dqscb120 scaleb 1.23 12355 -> Infinity Overflow Inexact Rounded
+dqscb121 scaleb 1.23 12356 -> Infinity Overflow Inexact Rounded
+dqscb122 scaleb 1.23 12357 -> NaN Invalid_operation
+dqscb123 scaleb 1.23 12358 -> NaN Invalid_operation
+dqscb124 scaleb 1.23 -12355 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb125 scaleb 1.23 -12356 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb126 scaleb 1.23 -12357 -> NaN Invalid_operation
+dqscb127 scaleb 1.23 -12358 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+dqscb861 scaleb NaN01 -Inf -> NaN1
+dqscb862 scaleb -NaN02 -1000 -> -NaN2
+dqscb863 scaleb NaN03 1000 -> NaN3
+dqscb864 scaleb NaN04 Inf -> NaN4
+dqscb865 scaleb NaN05 NaN61 -> NaN5
+dqscb866 scaleb -Inf -NaN71 -> -NaN71
+dqscb867 scaleb -1000 NaN81 -> NaN81
+dqscb868 scaleb 1000 NaN91 -> NaN91
+dqscb869 scaleb Inf NaN101 -> NaN101
+dqscb871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+dqscb872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+dqscb873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+dqscb874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+dqscb875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+dqscb876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+dqscb877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+dqscb878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+dqscb879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+dqscb880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+dqscb881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+dqscb051 scaleb 7 -2 -> 0.07
+dqscb052 scaleb -7 -2 -> -0.07
+dqscb053 scaleb 75 -2 -> 0.75
+dqscb054 scaleb -75 -2 -> -0.75
+dqscb055 scaleb 7.50 -2 -> 0.0750
+dqscb056 scaleb -7.50 -2 -> -0.0750
+dqscb057 scaleb 7.500 -2 -> 0.07500
+dqscb058 scaleb -7.500 -2 -> -0.07500
+dqscb061 scaleb 7 -1 -> 0.7
+dqscb062 scaleb -7 -1 -> -0.7
+dqscb063 scaleb 75 -1 -> 7.5
+dqscb064 scaleb -75 -1 -> -7.5
+dqscb065 scaleb 7.50 -1 -> 0.750
+dqscb066 scaleb -7.50 -1 -> -0.750
+dqscb067 scaleb 7.500 -1 -> 0.7500
+dqscb068 scaleb -7.500 -1 -> -0.7500
+dqscb071 scaleb 7 0 -> 7
+dqscb072 scaleb -7 0 -> -7
+dqscb073 scaleb 75 0 -> 75
+dqscb074 scaleb -75 0 -> -75
+dqscb075 scaleb 7.50 0 -> 7.50
+dqscb076 scaleb -7.50 0 -> -7.50
+dqscb077 scaleb 7.500 0 -> 7.500
+dqscb078 scaleb -7.500 0 -> -7.500
+dqscb081 scaleb 7 1 -> 7E+1
+dqscb082 scaleb -7 1 -> -7E+1
+dqscb083 scaleb 75 1 -> 7.5E+2
+dqscb084 scaleb -75 1 -> -7.5E+2
+dqscb085 scaleb 7.50 1 -> 75.0
+dqscb086 scaleb -7.50 1 -> -75.0
+dqscb087 scaleb 7.500 1 -> 75.00
+dqscb088 scaleb -7.500 1 -> -75.00
+dqscb091 scaleb 7 2 -> 7E+2
+dqscb092 scaleb -7 2 -> -7E+2
+dqscb093 scaleb 75 2 -> 7.5E+3
+dqscb094 scaleb -75 2 -> -7.5E+3
+dqscb095 scaleb 7.50 2 -> 750
+dqscb096 scaleb -7.50 2 -> -750
+dqscb097 scaleb 7.500 2 -> 750.0
+dqscb098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+dqscb111 scaleb 0 1 -> 0E+1
+dqscb112 scaleb -0 2 -> -0E+2
+dqscb113 scaleb 0E+4 3 -> 0E+7
+dqscb114 scaleb -0E+4 4 -> -0E+8
+dqscb115 scaleb 0.0000 5 -> 0E+1
+dqscb116 scaleb -0.0000 6 -> -0E+2
+dqscb117 scaleb 0E-141 7 -> 0E-134
+dqscb118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+dqscb132 scaleb 9.999999999999999999999999999999999E+6144 +6144 -> Infinity Overflow Inexact Rounded
+dqscb133 scaleb 9.999999999999999999999999999999999E+6144 +10 -> Infinity Overflow Inexact Rounded
+dqscb134 scaleb 9.999999999999999999999999999999999E+6144 +1 -> Infinity Overflow Inexact Rounded
+dqscb135 scaleb 9.999999999999999999999999999999999E+6144 0 -> 9.999999999999999999999999999999999E+6144
+dqscb136 scaleb 9.999999999999999999999999999999999E+6144 -1 -> 9.999999999999999999999999999999999E+6143
+dqscb137 scaleb 1E-6143 +1 -> 1E-6142
+dqscb1614 scaleb 1E-6143 -0 -> 1E-6143
+dqscb139 scaleb 1E-6143 -1 -> 1E-6144 Subnormal
+dqscb140 scaleb 1.000000000000000000000000000000000E-6143 +1 -> 1.000000000000000000000000000000000E-6142
+dqscb141 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
+dqscb142 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb143 scaleb 1E-6176 +1 -> 1E-6175 Subnormal
+dqscb144 scaleb 1E-6176 -0 -> 1E-6176 Subnormal
+dqscb145 scaleb 1E-6176 -1 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+
+dqscb150 scaleb -1E-6176 +1 -> -1E-6175 Subnormal
+dqscb151 scaleb -1E-6176 -0 -> -1E-6176 Subnormal
+dqscb152 scaleb -1E-6176 -1 -> -0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb153 scaleb -1.000000000000000000000000000000000E-6143 +1 -> -1.000000000000000000000000000000000E-6142
+dqscb154 scaleb -1.000000000000000000000000000000000E-6143 +0 -> -1.000000000000000000000000000000000E-6143
+dqscb155 scaleb -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb156 scaleb -1E-6143 +1 -> -1E-6142
+dqscb157 scaleb -1E-6143 -0 -> -1E-6143
+dqscb158 scaleb -1E-6143 -1 -> -1E-6144 Subnormal
+dqscb159 scaleb -9.999999999999999999999999999999999E+6144 +1 -> -Infinity Overflow Inexact Rounded
+dqscb160 scaleb -9.999999999999999999999999999999999E+6144 +0 -> -9.999999999999999999999999999999999E+6144
+dqscb161 scaleb -9.999999999999999999999999999999999E+6144 -1 -> -9.999999999999999999999999999999999E+6143
+dqscb162 scaleb -9E+6144 +1 -> -Infinity Overflow Inexact Rounded
+dqscb163 scaleb -1E+6144 +1 -> -Infinity Overflow Inexact Rounded
+
+-- some Origami
+-- (these check that overflow is being done correctly)
+dqscb171 scaleb 1000E+6109 +1 -> 1.000E+6113
+dqscb172 scaleb 1000E+6110 +1 -> 1.000E+6114
+dqscb173 scaleb 1000E+6111 +1 -> 1.0000E+6115 Clamped
+dqscb174 scaleb 1000E+6112 +1 -> 1.00000E+6116 Clamped
+dqscb175 scaleb 1000E+6113 +1 -> 1.000000E+6117 Clamped
+dqscb176 scaleb 1000E+6114 +1 -> 1.0000000E+6118 Clamped
+dqscb177 scaleb 1000E+6131 +1 -> 1.000000000000000000000000E+6135 Clamped
+dqscb178 scaleb 1000E+6132 +1 -> 1.0000000000000000000000000E+6136 Clamped
+dqscb179 scaleb 1000E+6133 +1 -> 1.00000000000000000000000000E+6137 Clamped
+dqscb180 scaleb 1000E+6134 +1 -> 1.000000000000000000000000000E+6138 Clamped
+dqscb181 scaleb 1000E+6135 +1 -> 1.0000000000000000000000000000E+6139 Clamped
+dqscb182 scaleb 1000E+6136 +1 -> 1.00000000000000000000000000000E+6140 Clamped
+dqscb183 scaleb 1000E+6137 +1 -> 1.000000000000000000000000000000E+6141 Clamped
+dqscb184 scaleb 1000E+6138 +1 -> 1.0000000000000000000000000000000E+6142 Clamped
+dqscb185 scaleb 1000E+6139 +1 -> 1.00000000000000000000000000000000E+6143 Clamped
+dqscb186 scaleb 1000E+6140 +1 -> 1.000000000000000000000000000000000E+6144 Clamped
+dqscb187 scaleb 1000E+6141 +1 -> Infinity Overflow Inexact Rounded
+
+-- and a few more subnormal truncations
+-- (these check that underflow is being done correctly)
+dqscb221 scaleb 1.000000000000000000000000000000000E-6143 0 -> 1.000000000000000000000000000000000E-6143
+dqscb222 scaleb 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144 Subnormal Rounded
+dqscb223 scaleb 1.000000000000000000000000000000000E-6143 -2 -> 1.0000000000000000000000000000000E-6145 Subnormal Rounded
+dqscb224 scaleb 1.000000000000000000000000000000000E-6143 -3 -> 1.000000000000000000000000000000E-6146 Subnormal Rounded
+dqscb225 scaleb 1.000000000000000000000000000000000E-6143 -4 -> 1.00000000000000000000000000000E-6147 Subnormal Rounded
+dqscb226 scaleb 1.000000000000000000000000000000000E-6143 -5 -> 1.0000000000000000000000000000E-6148 Subnormal Rounded
+dqscb227 scaleb 1.000000000000000000000000000000000E-6143 -6 -> 1.000000000000000000000000000E-6149 Subnormal Rounded
+dqscb228 scaleb 1.000000000000000000000000000000000E-6143 -7 -> 1.00000000000000000000000000E-6150 Subnormal Rounded
+dqscb229 scaleb 1.000000000000000000000000000000000E-6143 -8 -> 1.0000000000000000000000000E-6151 Subnormal Rounded
+dqscb230 scaleb 1.000000000000000000000000000000000E-6143 -9 -> 1.000000000000000000000000E-6152 Subnormal Rounded
+dqscb231 scaleb 1.000000000000000000000000000000000E-6143 -10 -> 1.00000000000000000000000E-6153 Subnormal Rounded
+dqscb232 scaleb 1.000000000000000000000000000000000E-6143 -11 -> 1.0000000000000000000000E-6154 Subnormal Rounded
+dqscb233 scaleb 1.000000000000000000000000000000000E-6143 -12 -> 1.000000000000000000000E-6155 Subnormal Rounded
+dqscb234 scaleb 1.000000000000000000000000000000000E-6143 -13 -> 1.00000000000000000000E-6156 Subnormal Rounded
+dqscb235 scaleb 1.000000000000000000000000000000000E-6143 -14 -> 1.0000000000000000000E-6157 Subnormal Rounded
+dqscb236 scaleb 1.000000000000000000000000000000000E-6143 -15 -> 1.000000000000000000E-6158 Subnormal Rounded
+dqscb237 scaleb 1.000000000000000000000000000000000E-6143 -16 -> 1.00000000000000000E-6159 Subnormal Rounded
+dqscb238 scaleb 1.000000000000000000000000000000000E-6143 -17 -> 1.0000000000000000E-6160 Subnormal Rounded
+dqscb239 scaleb 1.000000000000000000000000000000000E-6143 -18 -> 1.000000000000000E-6161 Subnormal Rounded
+dqscb202 scaleb 1.000000000000000000000000000000000E-6143 -19 -> 1.00000000000000E-6162 Subnormal Rounded
+dqscb203 scaleb 1.000000000000000000000000000000000E-6143 -20 -> 1.0000000000000E-6163 Subnormal Rounded
+dqscb204 scaleb 1.000000000000000000000000000000000E-6143 -21 -> 1.000000000000E-6164 Subnormal Rounded
+dqscb205 scaleb 1.000000000000000000000000000000000E-6143 -22 -> 1.00000000000E-6165 Subnormal Rounded
+dqscb206 scaleb 1.000000000000000000000000000000000E-6143 -23 -> 1.0000000000E-6166 Subnormal Rounded
+dqscb207 scaleb 1.000000000000000000000000000000000E-6143 -24 -> 1.000000000E-6167 Subnormal Rounded
+dqscb208 scaleb 1.000000000000000000000000000000000E-6143 -25 -> 1.00000000E-6168 Subnormal Rounded
+dqscb209 scaleb 1.000000000000000000000000000000000E-6143 -26 -> 1.0000000E-6169 Subnormal Rounded
+dqscb210 scaleb 1.000000000000000000000000000000000E-6143 -27 -> 1.000000E-6170 Subnormal Rounded
+dqscb211 scaleb 1.000000000000000000000000000000000E-6143 -28 -> 1.00000E-6171 Subnormal Rounded
+dqscb212 scaleb 1.000000000000000000000000000000000E-6143 -29 -> 1.0000E-6172 Subnormal Rounded
+dqscb213 scaleb 1.000000000000000000000000000000000E-6143 -30 -> 1.000E-6173 Subnormal Rounded
+dqscb214 scaleb 1.000000000000000000000000000000000E-6143 -31 -> 1.00E-6174 Subnormal Rounded
+dqscb215 scaleb 1.000000000000000000000000000000000E-6143 -32 -> 1.0E-6175 Subnormal Rounded
+dqscb216 scaleb 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176 Subnormal Rounded
+dqscb217 scaleb 1.000000000000000000000000000000000E-6143 -34 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
+dqscb218 scaleb 1.000000000000000000000000000000000E-6143 -35 -> 0E-6176 Underflow Subnormal Inexact Rounded Clamped
diff --git a/Lib/test/decimaltestdata/dqShift.decTest b/Lib/test/decimaltestdata/dqShift.decTest
index 6d692134551..4ee836eb48c 100644
--- a/Lib/test/decimaltestdata/dqShift.decTest
+++ b/Lib/test/decimaltestdata/dqShift.decTest
@@ -1,298 +1,298 @@
-------------------------------------------------------------------------
--- dqShift.decTest -- shift decQuad coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check
-dqshi001 shift 0 0 -> 0
-dqshi002 shift 0 2 -> 0
-dqshi003 shift 1 2 -> 100
-dqshi004 shift 1 33 -> 1000000000000000000000000000000000
-dqshi005 shift 1 34 -> 0
-dqshi006 shift 1 -1 -> 0
-dqshi007 shift 0 -2 -> 0
-dqshi008 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
-dqshi009 shift 1234567890123456789012345678901234 -33 -> 1
-dqshi010 shift 1234567890123456789012345678901234 -34 -> 0
-dqshi011 shift 9934567890123456789012345678901234 -33 -> 9
-dqshi012 shift 9934567890123456789012345678901234 -34 -> 0
-
--- rhs must be an integer
-dqshi015 shift 1 1.5 -> NaN Invalid_operation
-dqshi016 shift 1 1.0 -> NaN Invalid_operation
-dqshi017 shift 1 0.1 -> NaN Invalid_operation
-dqshi018 shift 1 0.0 -> NaN Invalid_operation
-dqshi019 shift 1 1E+1 -> NaN Invalid_operation
-dqshi020 shift 1 1E+99 -> NaN Invalid_operation
-dqshi021 shift 1 Inf -> NaN Invalid_operation
-dqshi022 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-dqshi025 shift 1 -1000 -> NaN Invalid_operation
-dqshi026 shift 1 -35 -> NaN Invalid_operation
-dqshi027 shift 1 35 -> NaN Invalid_operation
-dqshi028 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-dqshi030 shift 1234567890123456789012345678901234 -34 -> 0
-dqshi031 shift 1234567890123456789012345678901234 -33 -> 1
-dqshi032 shift 1234567890123456789012345678901234 -32 -> 12
-dqshi033 shift 1234567890123456789012345678901234 -31 -> 123
-dqshi034 shift 1234567890123456789012345678901234 -30 -> 1234
-dqshi035 shift 1234567890123456789012345678901234 -29 -> 12345
-dqshi036 shift 1234567890123456789012345678901234 -28 -> 123456
-dqshi037 shift 1234567890123456789012345678901234 -27 -> 1234567
-dqshi038 shift 1234567890123456789012345678901234 -26 -> 12345678
-dqshi039 shift 1234567890123456789012345678901234 -25 -> 123456789
-dqshi040 shift 1234567890123456789012345678901234 -24 -> 1234567890
-dqshi041 shift 1234567890123456789012345678901234 -23 -> 12345678901
-dqshi042 shift 1234567890123456789012345678901234 -22 -> 123456789012
-dqshi043 shift 1234567890123456789012345678901234 -21 -> 1234567890123
-dqshi044 shift 1234567890123456789012345678901234 -20 -> 12345678901234
-dqshi045 shift 1234567890123456789012345678901234 -19 -> 123456789012345
-dqshi047 shift 1234567890123456789012345678901234 -18 -> 1234567890123456
-dqshi048 shift 1234567890123456789012345678901234 -17 -> 12345678901234567
-dqshi049 shift 1234567890123456789012345678901234 -16 -> 123456789012345678
-dqshi050 shift 1234567890123456789012345678901234 -15 -> 1234567890123456789
-dqshi051 shift 1234567890123456789012345678901234 -14 -> 12345678901234567890
-dqshi052 shift 1234567890123456789012345678901234 -13 -> 123456789012345678901
-dqshi053 shift 1234567890123456789012345678901234 -12 -> 1234567890123456789012
-dqshi054 shift 1234567890123456789012345678901234 -11 -> 12345678901234567890123
-dqshi055 shift 1234567890123456789012345678901234 -10 -> 123456789012345678901234
-dqshi056 shift 1234567890123456789012345678901234 -9 -> 1234567890123456789012345
-dqshi057 shift 1234567890123456789012345678901234 -8 -> 12345678901234567890123456
-dqshi058 shift 1234567890123456789012345678901234 -7 -> 123456789012345678901234567
-dqshi059 shift 1234567890123456789012345678901234 -6 -> 1234567890123456789012345678
-dqshi060 shift 1234567890123456789012345678901234 -5 -> 12345678901234567890123456789
-dqshi061 shift 1234567890123456789012345678901234 -4 -> 123456789012345678901234567890
-dqshi062 shift 1234567890123456789012345678901234 -3 -> 1234567890123456789012345678901
-dqshi063 shift 1234567890123456789012345678901234 -2 -> 12345678901234567890123456789012
-dqshi064 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
-dqshi065 shift 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
-
-dqshi066 shift 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
-dqshi067 shift 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012340
-dqshi068 shift 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123400
-dqshi069 shift 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234000
-dqshi070 shift 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012340000
-dqshi071 shift 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123400000
-dqshi072 shift 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234000000
-dqshi073 shift 1234567890123456789012345678901234 +7 -> 8901234567890123456789012340000000
-dqshi074 shift 1234567890123456789012345678901234 +8 -> 9012345678901234567890123400000000
-dqshi075 shift 1234567890123456789012345678901234 +9 -> 123456789012345678901234000000000
-dqshi076 shift 1234567890123456789012345678901234 +10 -> 1234567890123456789012340000000000
-dqshi077 shift 1234567890123456789012345678901234 +11 -> 2345678901234567890123400000000000
-dqshi078 shift 1234567890123456789012345678901234 +12 -> 3456789012345678901234000000000000
-dqshi079 shift 1234567890123456789012345678901234 +13 -> 4567890123456789012340000000000000
-dqshi080 shift 1234567890123456789012345678901234 +14 -> 5678901234567890123400000000000000
-dqshi081 shift 1234567890123456789012345678901234 +15 -> 6789012345678901234000000000000000
-dqshi082 shift 1234567890123456789012345678901234 +16 -> 7890123456789012340000000000000000
-dqshi083 shift 1234567890123456789012345678901234 +17 -> 8901234567890123400000000000000000
-dqshi084 shift 1234567890123456789012345678901234 +18 -> 9012345678901234000000000000000000
-dqshi085 shift 1234567890123456789012345678901234 +19 -> 123456789012340000000000000000000
-dqshi086 shift 1234567890123456789012345678901234 +20 -> 1234567890123400000000000000000000
-dqshi087 shift 1234567890123456789012345678901234 +21 -> 2345678901234000000000000000000000
-dqshi088 shift 1234567890123456789012345678901234 +22 -> 3456789012340000000000000000000000
-dqshi089 shift 1234567890123456789012345678901234 +23 -> 4567890123400000000000000000000000
-dqshi090 shift 1234567890123456789012345678901234 +24 -> 5678901234000000000000000000000000
-dqshi091 shift 1234567890123456789012345678901234 +25 -> 6789012340000000000000000000000000
-dqshi092 shift 1234567890123456789012345678901234 +26 -> 7890123400000000000000000000000000
-dqshi093 shift 1234567890123456789012345678901234 +27 -> 8901234000000000000000000000000000
-dqshi094 shift 1234567890123456789012345678901234 +28 -> 9012340000000000000000000000000000
-dqshi095 shift 1234567890123456789012345678901234 +29 -> 123400000000000000000000000000000
-dqshi096 shift 1234567890123456789012345678901234 +30 -> 1234000000000000000000000000000000
-dqshi097 shift 1234567890123456789012345678901234 +31 -> 2340000000000000000000000000000000
-dqshi098 shift 1234567890123456789012345678901234 +32 -> 3400000000000000000000000000000000
-dqshi099 shift 1234567890123456789012345678901234 +33 -> 4000000000000000000000000000000000
-dqshi100 shift 1234567890123456789012345678901234 +34 -> 0
-
--- zeros
-dqshi270 shift 0E-10 +29 -> 0E-10
-dqshi271 shift 0E-10 -29 -> 0E-10
-dqshi272 shift 0.000 +29 -> 0.000
-dqshi273 shift 0.000 -29 -> 0.000
-dqshi274 shift 0E+10 +29 -> 0E+10
-dqshi275 shift 0E+10 -29 -> 0E+10
-dqshi276 shift -0E-10 +29 -> -0E-10
-dqshi277 shift -0E-10 -29 -> -0E-10
-dqshi278 shift -0.000 +29 -> -0.000
-dqshi279 shift -0.000 -29 -> -0.000
-dqshi280 shift -0E+10 +29 -> -0E+10
-dqshi281 shift -0E+10 -29 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-dqshi141 shift 9.999999999999999999999999999999999E+6144 -1 -> 9.99999999999999999999999999999999E+6143
-dqshi142 shift 9.999999999999999999999999999999999E+6144 -33 -> 9E+6111
-dqshi143 shift 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999990E+6144
-dqshi144 shift 9.999999999999999999999999999999999E+6144 33 -> 9.000000000000000000000000000000000E+6144
-dqshi145 shift 1E-6143 -1 -> 0E-6143
-dqshi146 shift 1E-6143 -33 -> 0E-6143
-dqshi147 shift 1E-6143 1 -> 1.0E-6142
-dqshi148 shift 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
-dqshi151 shift 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
-dqshi152 shift 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
-dqshi153 shift 1.000000000000000000000000000000000E-6143 1 -> 0E-6176
-dqshi154 shift 1.000000000000000000000000000000000E-6143 33 -> 0E-6176
-dqshi155 shift 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
-dqshi156 shift 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
-dqshi157 shift 9.000000000000000000000000000000000E-6143 1 -> 0E-6176
-dqshi158 shift 9.000000000000000000000000000000000E-6143 33 -> 0E-6176
-dqshi160 shift 1E-6176 -1 -> 0E-6176
-dqshi161 shift 1E-6176 -33 -> 0E-6176
-dqshi162 shift 1E-6176 1 -> 1.0E-6175
-dqshi163 shift 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
--- negatives
-dqshi171 shift -9.999999999999999999999999999999999E+6144 -1 -> -9.99999999999999999999999999999999E+6143
-dqshi172 shift -9.999999999999999999999999999999999E+6144 -33 -> -9E+6111
-dqshi173 shift -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999990E+6144
-dqshi174 shift -9.999999999999999999999999999999999E+6144 33 -> -9.000000000000000000000000000000000E+6144
-dqshi175 shift -1E-6143 -1 -> -0E-6143
-dqshi176 shift -1E-6143 -33 -> -0E-6143
-dqshi177 shift -1E-6143 1 -> -1.0E-6142
-dqshi178 shift -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
-dqshi181 shift -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
-dqshi182 shift -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
-dqshi183 shift -1.000000000000000000000000000000000E-6143 1 -> -0E-6176
-dqshi184 shift -1.000000000000000000000000000000000E-6143 33 -> -0E-6176
-dqshi185 shift -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
-dqshi186 shift -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
-dqshi187 shift -9.000000000000000000000000000000000E-6143 1 -> -0E-6176
-dqshi188 shift -9.000000000000000000000000000000000E-6143 33 -> -0E-6176
-dqshi190 shift -1E-6176 -1 -> -0E-6176
-dqshi191 shift -1E-6176 -33 -> -0E-6176
-dqshi192 shift -1E-6176 1 -> -1.0E-6175
-dqshi193 shift -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
-
--- more negatives (of sanities)
-dqshi201 shift -0 0 -> -0
-dqshi202 shift -0 2 -> -0
-dqshi203 shift -1 2 -> -100
-dqshi204 shift -1 33 -> -1000000000000000000000000000000000
-dqshi205 shift -1 34 -> -0
-dqshi206 shift -1 -1 -> -0
-dqshi207 shift -0 -2 -> -0
-dqshi208 shift -1234567890123456789012345678901234 -1 -> -123456789012345678901234567890123
-dqshi209 shift -1234567890123456789012345678901234 -33 -> -1
-dqshi210 shift -1234567890123456789012345678901234 -34 -> -0
-dqshi211 shift -9934567890123456789012345678901234 -33 -> -9
-dqshi212 shift -9934567890123456789012345678901234 -34 -> -0
-
-
--- Specials; NaNs are handled as usual
-dqshi781 shift -Inf -8 -> -Infinity
-dqshi782 shift -Inf -1 -> -Infinity
-dqshi783 shift -Inf -0 -> -Infinity
-dqshi784 shift -Inf 0 -> -Infinity
-dqshi785 shift -Inf 1 -> -Infinity
-dqshi786 shift -Inf 8 -> -Infinity
-dqshi787 shift -1000 -Inf -> NaN Invalid_operation
-dqshi788 shift -Inf -Inf -> NaN Invalid_operation
-dqshi789 shift -1 -Inf -> NaN Invalid_operation
-dqshi790 shift -0 -Inf -> NaN Invalid_operation
-dqshi791 shift 0 -Inf -> NaN Invalid_operation
-dqshi792 shift 1 -Inf -> NaN Invalid_operation
-dqshi793 shift 1000 -Inf -> NaN Invalid_operation
-dqshi794 shift Inf -Inf -> NaN Invalid_operation
-
-dqshi800 shift Inf -Inf -> NaN Invalid_operation
-dqshi801 shift Inf -8 -> Infinity
-dqshi802 shift Inf -1 -> Infinity
-dqshi803 shift Inf -0 -> Infinity
-dqshi804 shift Inf 0 -> Infinity
-dqshi805 shift Inf 1 -> Infinity
-dqshi806 shift Inf 8 -> Infinity
-dqshi807 shift Inf Inf -> NaN Invalid_operation
-dqshi808 shift -1000 Inf -> NaN Invalid_operation
-dqshi809 shift -Inf Inf -> NaN Invalid_operation
-dqshi810 shift -1 Inf -> NaN Invalid_operation
-dqshi811 shift -0 Inf -> NaN Invalid_operation
-dqshi812 shift 0 Inf -> NaN Invalid_operation
-dqshi813 shift 1 Inf -> NaN Invalid_operation
-dqshi814 shift 1000 Inf -> NaN Invalid_operation
-dqshi815 shift Inf Inf -> NaN Invalid_operation
-
-dqshi821 shift NaN -Inf -> NaN
-dqshi822 shift NaN -1000 -> NaN
-dqshi823 shift NaN -1 -> NaN
-dqshi824 shift NaN -0 -> NaN
-dqshi825 shift NaN 0 -> NaN
-dqshi826 shift NaN 1 -> NaN
-dqshi827 shift NaN 1000 -> NaN
-dqshi828 shift NaN Inf -> NaN
-dqshi829 shift NaN NaN -> NaN
-dqshi830 shift -Inf NaN -> NaN
-dqshi831 shift -1000 NaN -> NaN
-dqshi832 shift -1 NaN -> NaN
-dqshi833 shift -0 NaN -> NaN
-dqshi834 shift 0 NaN -> NaN
-dqshi835 shift 1 NaN -> NaN
-dqshi836 shift 1000 NaN -> NaN
-dqshi837 shift Inf NaN -> NaN
-
-dqshi841 shift sNaN -Inf -> NaN Invalid_operation
-dqshi842 shift sNaN -1000 -> NaN Invalid_operation
-dqshi843 shift sNaN -1 -> NaN Invalid_operation
-dqshi844 shift sNaN -0 -> NaN Invalid_operation
-dqshi845 shift sNaN 0 -> NaN Invalid_operation
-dqshi846 shift sNaN 1 -> NaN Invalid_operation
-dqshi847 shift sNaN 1000 -> NaN Invalid_operation
-dqshi848 shift sNaN NaN -> NaN Invalid_operation
-dqshi849 shift sNaN sNaN -> NaN Invalid_operation
-dqshi850 shift NaN sNaN -> NaN Invalid_operation
-dqshi851 shift -Inf sNaN -> NaN Invalid_operation
-dqshi852 shift -1000 sNaN -> NaN Invalid_operation
-dqshi853 shift -1 sNaN -> NaN Invalid_operation
-dqshi854 shift -0 sNaN -> NaN Invalid_operation
-dqshi855 shift 0 sNaN -> NaN Invalid_operation
-dqshi856 shift 1 sNaN -> NaN Invalid_operation
-dqshi857 shift 1000 sNaN -> NaN Invalid_operation
-dqshi858 shift Inf sNaN -> NaN Invalid_operation
-dqshi859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqshi861 shift NaN1 -Inf -> NaN1
-dqshi862 shift +NaN2 -1000 -> NaN2
-dqshi863 shift NaN3 1000 -> NaN3
-dqshi864 shift NaN4 Inf -> NaN4
-dqshi865 shift NaN5 +NaN6 -> NaN5
-dqshi866 shift -Inf NaN7 -> NaN7
-dqshi867 shift -1000 NaN8 -> NaN8
-dqshi868 shift 1000 NaN9 -> NaN9
-dqshi869 shift Inf +NaN10 -> NaN10
-dqshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-dqshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-dqshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
-dqshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-dqshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-dqshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-dqshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-dqshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-dqshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-dqshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
-dqshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-dqshi882 shift -NaN26 NaN28 -> -NaN26
-dqshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-dqshi884 shift 1000 -NaN30 -> -NaN30
-dqshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- dqShift.decTest -- shift decQuad coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check
+dqshi001 shift 0 0 -> 0
+dqshi002 shift 0 2 -> 0
+dqshi003 shift 1 2 -> 100
+dqshi004 shift 1 33 -> 1000000000000000000000000000000000
+dqshi005 shift 1 34 -> 0
+dqshi006 shift 1 -1 -> 0
+dqshi007 shift 0 -2 -> 0
+dqshi008 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
+dqshi009 shift 1234567890123456789012345678901234 -33 -> 1
+dqshi010 shift 1234567890123456789012345678901234 -34 -> 0
+dqshi011 shift 9934567890123456789012345678901234 -33 -> 9
+dqshi012 shift 9934567890123456789012345678901234 -34 -> 0
+
+-- rhs must be an integer
+dqshi015 shift 1 1.5 -> NaN Invalid_operation
+dqshi016 shift 1 1.0 -> NaN Invalid_operation
+dqshi017 shift 1 0.1 -> NaN Invalid_operation
+dqshi018 shift 1 0.0 -> NaN Invalid_operation
+dqshi019 shift 1 1E+1 -> NaN Invalid_operation
+dqshi020 shift 1 1E+99 -> NaN Invalid_operation
+dqshi021 shift 1 Inf -> NaN Invalid_operation
+dqshi022 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+dqshi025 shift 1 -1000 -> NaN Invalid_operation
+dqshi026 shift 1 -35 -> NaN Invalid_operation
+dqshi027 shift 1 35 -> NaN Invalid_operation
+dqshi028 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+dqshi030 shift 1234567890123456789012345678901234 -34 -> 0
+dqshi031 shift 1234567890123456789012345678901234 -33 -> 1
+dqshi032 shift 1234567890123456789012345678901234 -32 -> 12
+dqshi033 shift 1234567890123456789012345678901234 -31 -> 123
+dqshi034 shift 1234567890123456789012345678901234 -30 -> 1234
+dqshi035 shift 1234567890123456789012345678901234 -29 -> 12345
+dqshi036 shift 1234567890123456789012345678901234 -28 -> 123456
+dqshi037 shift 1234567890123456789012345678901234 -27 -> 1234567
+dqshi038 shift 1234567890123456789012345678901234 -26 -> 12345678
+dqshi039 shift 1234567890123456789012345678901234 -25 -> 123456789
+dqshi040 shift 1234567890123456789012345678901234 -24 -> 1234567890
+dqshi041 shift 1234567890123456789012345678901234 -23 -> 12345678901
+dqshi042 shift 1234567890123456789012345678901234 -22 -> 123456789012
+dqshi043 shift 1234567890123456789012345678901234 -21 -> 1234567890123
+dqshi044 shift 1234567890123456789012345678901234 -20 -> 12345678901234
+dqshi045 shift 1234567890123456789012345678901234 -19 -> 123456789012345
+dqshi047 shift 1234567890123456789012345678901234 -18 -> 1234567890123456
+dqshi048 shift 1234567890123456789012345678901234 -17 -> 12345678901234567
+dqshi049 shift 1234567890123456789012345678901234 -16 -> 123456789012345678
+dqshi050 shift 1234567890123456789012345678901234 -15 -> 1234567890123456789
+dqshi051 shift 1234567890123456789012345678901234 -14 -> 12345678901234567890
+dqshi052 shift 1234567890123456789012345678901234 -13 -> 123456789012345678901
+dqshi053 shift 1234567890123456789012345678901234 -12 -> 1234567890123456789012
+dqshi054 shift 1234567890123456789012345678901234 -11 -> 12345678901234567890123
+dqshi055 shift 1234567890123456789012345678901234 -10 -> 123456789012345678901234
+dqshi056 shift 1234567890123456789012345678901234 -9 -> 1234567890123456789012345
+dqshi057 shift 1234567890123456789012345678901234 -8 -> 12345678901234567890123456
+dqshi058 shift 1234567890123456789012345678901234 -7 -> 123456789012345678901234567
+dqshi059 shift 1234567890123456789012345678901234 -6 -> 1234567890123456789012345678
+dqshi060 shift 1234567890123456789012345678901234 -5 -> 12345678901234567890123456789
+dqshi061 shift 1234567890123456789012345678901234 -4 -> 123456789012345678901234567890
+dqshi062 shift 1234567890123456789012345678901234 -3 -> 1234567890123456789012345678901
+dqshi063 shift 1234567890123456789012345678901234 -2 -> 12345678901234567890123456789012
+dqshi064 shift 1234567890123456789012345678901234 -1 -> 123456789012345678901234567890123
+dqshi065 shift 1234567890123456789012345678901234 -0 -> 1234567890123456789012345678901234
+
+dqshi066 shift 1234567890123456789012345678901234 +0 -> 1234567890123456789012345678901234
+dqshi067 shift 1234567890123456789012345678901234 +1 -> 2345678901234567890123456789012340
+dqshi068 shift 1234567890123456789012345678901234 +2 -> 3456789012345678901234567890123400
+dqshi069 shift 1234567890123456789012345678901234 +3 -> 4567890123456789012345678901234000
+dqshi070 shift 1234567890123456789012345678901234 +4 -> 5678901234567890123456789012340000
+dqshi071 shift 1234567890123456789012345678901234 +5 -> 6789012345678901234567890123400000
+dqshi072 shift 1234567890123456789012345678901234 +6 -> 7890123456789012345678901234000000
+dqshi073 shift 1234567890123456789012345678901234 +7 -> 8901234567890123456789012340000000
+dqshi074 shift 1234567890123456789012345678901234 +8 -> 9012345678901234567890123400000000
+dqshi075 shift 1234567890123456789012345678901234 +9 -> 123456789012345678901234000000000
+dqshi076 shift 1234567890123456789012345678901234 +10 -> 1234567890123456789012340000000000
+dqshi077 shift 1234567890123456789012345678901234 +11 -> 2345678901234567890123400000000000
+dqshi078 shift 1234567890123456789012345678901234 +12 -> 3456789012345678901234000000000000
+dqshi079 shift 1234567890123456789012345678901234 +13 -> 4567890123456789012340000000000000
+dqshi080 shift 1234567890123456789012345678901234 +14 -> 5678901234567890123400000000000000
+dqshi081 shift 1234567890123456789012345678901234 +15 -> 6789012345678901234000000000000000
+dqshi082 shift 1234567890123456789012345678901234 +16 -> 7890123456789012340000000000000000
+dqshi083 shift 1234567890123456789012345678901234 +17 -> 8901234567890123400000000000000000
+dqshi084 shift 1234567890123456789012345678901234 +18 -> 9012345678901234000000000000000000
+dqshi085 shift 1234567890123456789012345678901234 +19 -> 123456789012340000000000000000000
+dqshi086 shift 1234567890123456789012345678901234 +20 -> 1234567890123400000000000000000000
+dqshi087 shift 1234567890123456789012345678901234 +21 -> 2345678901234000000000000000000000
+dqshi088 shift 1234567890123456789012345678901234 +22 -> 3456789012340000000000000000000000
+dqshi089 shift 1234567890123456789012345678901234 +23 -> 4567890123400000000000000000000000
+dqshi090 shift 1234567890123456789012345678901234 +24 -> 5678901234000000000000000000000000
+dqshi091 shift 1234567890123456789012345678901234 +25 -> 6789012340000000000000000000000000
+dqshi092 shift 1234567890123456789012345678901234 +26 -> 7890123400000000000000000000000000
+dqshi093 shift 1234567890123456789012345678901234 +27 -> 8901234000000000000000000000000000
+dqshi094 shift 1234567890123456789012345678901234 +28 -> 9012340000000000000000000000000000
+dqshi095 shift 1234567890123456789012345678901234 +29 -> 123400000000000000000000000000000
+dqshi096 shift 1234567890123456789012345678901234 +30 -> 1234000000000000000000000000000000
+dqshi097 shift 1234567890123456789012345678901234 +31 -> 2340000000000000000000000000000000
+dqshi098 shift 1234567890123456789012345678901234 +32 -> 3400000000000000000000000000000000
+dqshi099 shift 1234567890123456789012345678901234 +33 -> 4000000000000000000000000000000000
+dqshi100 shift 1234567890123456789012345678901234 +34 -> 0
+
+-- zeros
+dqshi270 shift 0E-10 +29 -> 0E-10
+dqshi271 shift 0E-10 -29 -> 0E-10
+dqshi272 shift 0.000 +29 -> 0.000
+dqshi273 shift 0.000 -29 -> 0.000
+dqshi274 shift 0E+10 +29 -> 0E+10
+dqshi275 shift 0E+10 -29 -> 0E+10
+dqshi276 shift -0E-10 +29 -> -0E-10
+dqshi277 shift -0E-10 -29 -> -0E-10
+dqshi278 shift -0.000 +29 -> -0.000
+dqshi279 shift -0.000 -29 -> -0.000
+dqshi280 shift -0E+10 +29 -> -0E+10
+dqshi281 shift -0E+10 -29 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+dqshi141 shift 9.999999999999999999999999999999999E+6144 -1 -> 9.99999999999999999999999999999999E+6143
+dqshi142 shift 9.999999999999999999999999999999999E+6144 -33 -> 9E+6111
+dqshi143 shift 9.999999999999999999999999999999999E+6144 1 -> 9.999999999999999999999999999999990E+6144
+dqshi144 shift 9.999999999999999999999999999999999E+6144 33 -> 9.000000000000000000000000000000000E+6144
+dqshi145 shift 1E-6143 -1 -> 0E-6143
+dqshi146 shift 1E-6143 -33 -> 0E-6143
+dqshi147 shift 1E-6143 1 -> 1.0E-6142
+dqshi148 shift 1E-6143 33 -> 1.000000000000000000000000000000000E-6110
+dqshi151 shift 1.000000000000000000000000000000000E-6143 -1 -> 1.00000000000000000000000000000000E-6144
+dqshi152 shift 1.000000000000000000000000000000000E-6143 -33 -> 1E-6176
+dqshi153 shift 1.000000000000000000000000000000000E-6143 1 -> 0E-6176
+dqshi154 shift 1.000000000000000000000000000000000E-6143 33 -> 0E-6176
+dqshi155 shift 9.000000000000000000000000000000000E-6143 -1 -> 9.00000000000000000000000000000000E-6144
+dqshi156 shift 9.000000000000000000000000000000000E-6143 -33 -> 9E-6176
+dqshi157 shift 9.000000000000000000000000000000000E-6143 1 -> 0E-6176
+dqshi158 shift 9.000000000000000000000000000000000E-6143 33 -> 0E-6176
+dqshi160 shift 1E-6176 -1 -> 0E-6176
+dqshi161 shift 1E-6176 -33 -> 0E-6176
+dqshi162 shift 1E-6176 1 -> 1.0E-6175
+dqshi163 shift 1E-6176 33 -> 1.000000000000000000000000000000000E-6143
+-- negatives
+dqshi171 shift -9.999999999999999999999999999999999E+6144 -1 -> -9.99999999999999999999999999999999E+6143
+dqshi172 shift -9.999999999999999999999999999999999E+6144 -33 -> -9E+6111
+dqshi173 shift -9.999999999999999999999999999999999E+6144 1 -> -9.999999999999999999999999999999990E+6144
+dqshi174 shift -9.999999999999999999999999999999999E+6144 33 -> -9.000000000000000000000000000000000E+6144
+dqshi175 shift -1E-6143 -1 -> -0E-6143
+dqshi176 shift -1E-6143 -33 -> -0E-6143
+dqshi177 shift -1E-6143 1 -> -1.0E-6142
+dqshi178 shift -1E-6143 33 -> -1.000000000000000000000000000000000E-6110
+dqshi181 shift -1.000000000000000000000000000000000E-6143 -1 -> -1.00000000000000000000000000000000E-6144
+dqshi182 shift -1.000000000000000000000000000000000E-6143 -33 -> -1E-6176
+dqshi183 shift -1.000000000000000000000000000000000E-6143 1 -> -0E-6176
+dqshi184 shift -1.000000000000000000000000000000000E-6143 33 -> -0E-6176
+dqshi185 shift -9.000000000000000000000000000000000E-6143 -1 -> -9.00000000000000000000000000000000E-6144
+dqshi186 shift -9.000000000000000000000000000000000E-6143 -33 -> -9E-6176
+dqshi187 shift -9.000000000000000000000000000000000E-6143 1 -> -0E-6176
+dqshi188 shift -9.000000000000000000000000000000000E-6143 33 -> -0E-6176
+dqshi190 shift -1E-6176 -1 -> -0E-6176
+dqshi191 shift -1E-6176 -33 -> -0E-6176
+dqshi192 shift -1E-6176 1 -> -1.0E-6175
+dqshi193 shift -1E-6176 33 -> -1.000000000000000000000000000000000E-6143
+
+-- more negatives (of sanities)
+dqshi201 shift -0 0 -> -0
+dqshi202 shift -0 2 -> -0
+dqshi203 shift -1 2 -> -100
+dqshi204 shift -1 33 -> -1000000000000000000000000000000000
+dqshi205 shift -1 34 -> -0
+dqshi206 shift -1 -1 -> -0
+dqshi207 shift -0 -2 -> -0
+dqshi208 shift -1234567890123456789012345678901234 -1 -> -123456789012345678901234567890123
+dqshi209 shift -1234567890123456789012345678901234 -33 -> -1
+dqshi210 shift -1234567890123456789012345678901234 -34 -> -0
+dqshi211 shift -9934567890123456789012345678901234 -33 -> -9
+dqshi212 shift -9934567890123456789012345678901234 -34 -> -0
+
+
+-- Specials; NaNs are handled as usual
+dqshi781 shift -Inf -8 -> -Infinity
+dqshi782 shift -Inf -1 -> -Infinity
+dqshi783 shift -Inf -0 -> -Infinity
+dqshi784 shift -Inf 0 -> -Infinity
+dqshi785 shift -Inf 1 -> -Infinity
+dqshi786 shift -Inf 8 -> -Infinity
+dqshi787 shift -1000 -Inf -> NaN Invalid_operation
+dqshi788 shift -Inf -Inf -> NaN Invalid_operation
+dqshi789 shift -1 -Inf -> NaN Invalid_operation
+dqshi790 shift -0 -Inf -> NaN Invalid_operation
+dqshi791 shift 0 -Inf -> NaN Invalid_operation
+dqshi792 shift 1 -Inf -> NaN Invalid_operation
+dqshi793 shift 1000 -Inf -> NaN Invalid_operation
+dqshi794 shift Inf -Inf -> NaN Invalid_operation
+
+dqshi800 shift Inf -Inf -> NaN Invalid_operation
+dqshi801 shift Inf -8 -> Infinity
+dqshi802 shift Inf -1 -> Infinity
+dqshi803 shift Inf -0 -> Infinity
+dqshi804 shift Inf 0 -> Infinity
+dqshi805 shift Inf 1 -> Infinity
+dqshi806 shift Inf 8 -> Infinity
+dqshi807 shift Inf Inf -> NaN Invalid_operation
+dqshi808 shift -1000 Inf -> NaN Invalid_operation
+dqshi809 shift -Inf Inf -> NaN Invalid_operation
+dqshi810 shift -1 Inf -> NaN Invalid_operation
+dqshi811 shift -0 Inf -> NaN Invalid_operation
+dqshi812 shift 0 Inf -> NaN Invalid_operation
+dqshi813 shift 1 Inf -> NaN Invalid_operation
+dqshi814 shift 1000 Inf -> NaN Invalid_operation
+dqshi815 shift Inf Inf -> NaN Invalid_operation
+
+dqshi821 shift NaN -Inf -> NaN
+dqshi822 shift NaN -1000 -> NaN
+dqshi823 shift NaN -1 -> NaN
+dqshi824 shift NaN -0 -> NaN
+dqshi825 shift NaN 0 -> NaN
+dqshi826 shift NaN 1 -> NaN
+dqshi827 shift NaN 1000 -> NaN
+dqshi828 shift NaN Inf -> NaN
+dqshi829 shift NaN NaN -> NaN
+dqshi830 shift -Inf NaN -> NaN
+dqshi831 shift -1000 NaN -> NaN
+dqshi832 shift -1 NaN -> NaN
+dqshi833 shift -0 NaN -> NaN
+dqshi834 shift 0 NaN -> NaN
+dqshi835 shift 1 NaN -> NaN
+dqshi836 shift 1000 NaN -> NaN
+dqshi837 shift Inf NaN -> NaN
+
+dqshi841 shift sNaN -Inf -> NaN Invalid_operation
+dqshi842 shift sNaN -1000 -> NaN Invalid_operation
+dqshi843 shift sNaN -1 -> NaN Invalid_operation
+dqshi844 shift sNaN -0 -> NaN Invalid_operation
+dqshi845 shift sNaN 0 -> NaN Invalid_operation
+dqshi846 shift sNaN 1 -> NaN Invalid_operation
+dqshi847 shift sNaN 1000 -> NaN Invalid_operation
+dqshi848 shift sNaN NaN -> NaN Invalid_operation
+dqshi849 shift sNaN sNaN -> NaN Invalid_operation
+dqshi850 shift NaN sNaN -> NaN Invalid_operation
+dqshi851 shift -Inf sNaN -> NaN Invalid_operation
+dqshi852 shift -1000 sNaN -> NaN Invalid_operation
+dqshi853 shift -1 sNaN -> NaN Invalid_operation
+dqshi854 shift -0 sNaN -> NaN Invalid_operation
+dqshi855 shift 0 sNaN -> NaN Invalid_operation
+dqshi856 shift 1 sNaN -> NaN Invalid_operation
+dqshi857 shift 1000 sNaN -> NaN Invalid_operation
+dqshi858 shift Inf sNaN -> NaN Invalid_operation
+dqshi859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqshi861 shift NaN1 -Inf -> NaN1
+dqshi862 shift +NaN2 -1000 -> NaN2
+dqshi863 shift NaN3 1000 -> NaN3
+dqshi864 shift NaN4 Inf -> NaN4
+dqshi865 shift NaN5 +NaN6 -> NaN5
+dqshi866 shift -Inf NaN7 -> NaN7
+dqshi867 shift -1000 NaN8 -> NaN8
+dqshi868 shift 1000 NaN9 -> NaN9
+dqshi869 shift Inf +NaN10 -> NaN10
+dqshi871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+dqshi872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+dqshi873 shift sNaN13 1000 -> NaN13 Invalid_operation
+dqshi874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+dqshi875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+dqshi876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+dqshi877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+dqshi878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+dqshi879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+dqshi880 shift Inf sNaN23 -> NaN23 Invalid_operation
+dqshi881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+dqshi882 shift -NaN26 NaN28 -> -NaN26
+dqshi883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+dqshi884 shift 1000 -NaN30 -> -NaN30
+dqshi885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqSubtract.decTest b/Lib/test/decimaltestdata/dqSubtract.decTest
index 34572f69d5c..f3b92270f9e 100644
--- a/Lib/test/decimaltestdata/dqSubtract.decTest
+++ b/Lib/test/decimaltestdata/dqSubtract.decTest
@@ -1,635 +1,635 @@
-------------------------------------------------------------------------
--- dqSubtract.decTest -- decQuad subtraction --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests are for decQuads only; all arguments are
--- representable in a decQuad
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- [first group are 'quick confidence check']
-dqsub001 subtract 0 0 -> '0'
-dqsub002 subtract 1 1 -> '0'
-dqsub003 subtract 1 2 -> '-1'
-dqsub004 subtract 2 1 -> '1'
-dqsub005 subtract 2 2 -> '0'
-dqsub006 subtract 3 2 -> '1'
-dqsub007 subtract 2 3 -> '-1'
-
-dqsub011 subtract -0 0 -> '-0'
-dqsub012 subtract -1 1 -> '-2'
-dqsub013 subtract -1 2 -> '-3'
-dqsub014 subtract -2 1 -> '-3'
-dqsub015 subtract -2 2 -> '-4'
-dqsub016 subtract -3 2 -> '-5'
-dqsub017 subtract -2 3 -> '-5'
-
-dqsub021 subtract 0 -0 -> '0'
-dqsub022 subtract 1 -1 -> '2'
-dqsub023 subtract 1 -2 -> '3'
-dqsub024 subtract 2 -1 -> '3'
-dqsub025 subtract 2 -2 -> '4'
-dqsub026 subtract 3 -2 -> '5'
-dqsub027 subtract 2 -3 -> '5'
-
-dqsub030 subtract 11 1 -> 10
-dqsub031 subtract 10 1 -> 9
-dqsub032 subtract 9 1 -> 8
-dqsub033 subtract 1 1 -> 0
-dqsub034 subtract 0 1 -> -1
-dqsub035 subtract -1 1 -> -2
-dqsub036 subtract -9 1 -> -10
-dqsub037 subtract -10 1 -> -11
-dqsub038 subtract -11 1 -> -12
-
-dqsub040 subtract '5.75' '3.3' -> '2.45'
-dqsub041 subtract '5' '-3' -> '8'
-dqsub042 subtract '-5' '-3' -> '-2'
-dqsub043 subtract '-7' '2.5' -> '-9.5'
-dqsub044 subtract '0.7' '0.3' -> '0.4'
-dqsub045 subtract '1.3' '0.3' -> '1.0'
-dqsub046 subtract '1.25' '1.25' -> '0.00'
-
-dqsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
-dqsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
-
-dqsub060 subtract '70' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub061 subtract '700' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub062 subtract '7000' '10000e+34' -> '-9.999999999999999999999999999999999E+37' Inexact Rounded
-dqsub063 subtract '70000' '10000e+34' -> '-9.999999999999999999999999999999993E+37' Rounded
-dqsub064 subtract '700000' '10000e+34' -> '-9.999999999999999999999999999999930E+37' Rounded
- -- symmetry:
-dqsub065 subtract '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub066 subtract '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
-dqsub067 subtract '10000e+34' '7000' -> '9.999999999999999999999999999999999E+37' Inexact Rounded
-dqsub068 subtract '10000e+34' '70000' -> '9.999999999999999999999999999999993E+37' Rounded
-dqsub069 subtract '10000e+34' '700000' -> '9.999999999999999999999999999999930E+37' Rounded
-
- -- some of the next group are really constructor tests
-dqsub090 subtract '00.0' '0.0' -> '0.0'
-dqsub091 subtract '00.0' '0.00' -> '0.00'
-dqsub092 subtract '0.00' '00.0' -> '0.00'
-dqsub093 subtract '00.0' '0.00' -> '0.00'
-dqsub094 subtract '0.00' '00.0' -> '0.00'
-dqsub095 subtract '3' '.3' -> '2.7'
-dqsub096 subtract '3.' '.3' -> '2.7'
-dqsub097 subtract '3.0' '.3' -> '2.7'
-dqsub098 subtract '3.00' '.3' -> '2.70'
-dqsub099 subtract '3' '3' -> '0'
-dqsub100 subtract '3' '+3' -> '0'
-dqsub101 subtract '3' '-3' -> '6'
-dqsub102 subtract '3' '0.3' -> '2.7'
-dqsub103 subtract '3.' '0.3' -> '2.7'
-dqsub104 subtract '3.0' '0.3' -> '2.7'
-dqsub105 subtract '3.00' '0.3' -> '2.70'
-dqsub106 subtract '3' '3.0' -> '0.0'
-dqsub107 subtract '3' '+3.0' -> '0.0'
-dqsub108 subtract '3' '-3.0' -> '6.0'
-
--- the above all from add; massaged and extended. Now some new ones...
--- [particularly important for comparisons]
--- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
--- with input rounding.
-dqsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
-dqsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
-dqsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
-dqsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
-dqsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
-dqsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
-dqsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
-dqsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
-dqsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
-dqsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
-dqsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
-dqsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
-dqsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
-dqsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
-dqsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
-dqsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
-dqsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
-dqsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
-dqsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
-dqsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
-dqsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
-dqsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
-dqsub142 subtract '1' '0.999999999' -> '1E-9'
-dqsub143 subtract '0.999999999' '1' -> '-1E-9'
-dqsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
-dqsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
-dqsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
-
--- additional scaled arithmetic tests [0.97 problem]
-dqsub160 subtract '0' '.1' -> '-0.1'
-dqsub161 subtract '00' '.97983' -> '-0.97983'
-dqsub162 subtract '0' '.9' -> '-0.9'
-dqsub163 subtract '0' '0.102' -> '-0.102'
-dqsub164 subtract '0' '.4' -> '-0.4'
-dqsub165 subtract '0' '.307' -> '-0.307'
-dqsub166 subtract '0' '.43822' -> '-0.43822'
-dqsub167 subtract '0' '.911' -> '-0.911'
-dqsub168 subtract '.0' '.02' -> '-0.02'
-dqsub169 subtract '00' '.392' -> '-0.392'
-dqsub170 subtract '0' '.26' -> '-0.26'
-dqsub171 subtract '0' '0.51' -> '-0.51'
-dqsub172 subtract '0' '.2234' -> '-0.2234'
-dqsub173 subtract '0' '.2' -> '-0.2'
-dqsub174 subtract '.0' '.0008' -> '-0.0008'
--- 0. on left
-dqsub180 subtract '0.0' '-.1' -> '0.1'
-dqsub181 subtract '0.00' '-.97983' -> '0.97983'
-dqsub182 subtract '0.0' '-.9' -> '0.9'
-dqsub183 subtract '0.0' '-0.102' -> '0.102'
-dqsub184 subtract '0.0' '-.4' -> '0.4'
-dqsub185 subtract '0.0' '-.307' -> '0.307'
-dqsub186 subtract '0.0' '-.43822' -> '0.43822'
-dqsub187 subtract '0.0' '-.911' -> '0.911'
-dqsub188 subtract '0.0' '-.02' -> '0.02'
-dqsub189 subtract '0.00' '-.392' -> '0.392'
-dqsub190 subtract '0.0' '-.26' -> '0.26'
-dqsub191 subtract '0.0' '-0.51' -> '0.51'
-dqsub192 subtract '0.0' '-.2234' -> '0.2234'
-dqsub193 subtract '0.0' '-.2' -> '0.2'
-dqsub194 subtract '0.0' '-.0008' -> '0.0008'
--- negatives of same
-dqsub200 subtract '0' '-.1' -> '0.1'
-dqsub201 subtract '00' '-.97983' -> '0.97983'
-dqsub202 subtract '0' '-.9' -> '0.9'
-dqsub203 subtract '0' '-0.102' -> '0.102'
-dqsub204 subtract '0' '-.4' -> '0.4'
-dqsub205 subtract '0' '-.307' -> '0.307'
-dqsub206 subtract '0' '-.43822' -> '0.43822'
-dqsub207 subtract '0' '-.911' -> '0.911'
-dqsub208 subtract '.0' '-.02' -> '0.02'
-dqsub209 subtract '00' '-.392' -> '0.392'
-dqsub210 subtract '0' '-.26' -> '0.26'
-dqsub211 subtract '0' '-0.51' -> '0.51'
-dqsub212 subtract '0' '-.2234' -> '0.2234'
-dqsub213 subtract '0' '-.2' -> '0.2'
-dqsub214 subtract '.0' '-.0008' -> '0.0008'
-
--- more fixed, LHS swaps [really the same as testcases under add]
-dqsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
-dqsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
-dqsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
-dqsub223 subtract '-56267E-9' 0 -> '-0.000056267'
-dqsub224 subtract '-56267E-8' 0 -> '-0.00056267'
-dqsub225 subtract '-56267E-7' 0 -> '-0.0056267'
-dqsub226 subtract '-56267E-6' 0 -> '-0.056267'
-dqsub227 subtract '-56267E-5' 0 -> '-0.56267'
-dqsub228 subtract '-56267E-2' 0 -> '-562.67'
-dqsub229 subtract '-56267E-1' 0 -> '-5626.7'
-dqsub230 subtract '-56267E-0' 0 -> '-56267'
--- symmetry ...
-dqsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
-dqsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
-dqsub242 subtract 0 '-56267E-10' -> '0.0000056267'
-dqsub243 subtract 0 '-56267E-9' -> '0.000056267'
-dqsub244 subtract 0 '-56267E-8' -> '0.00056267'
-dqsub245 subtract 0 '-56267E-7' -> '0.0056267'
-dqsub246 subtract 0 '-56267E-6' -> '0.056267'
-dqsub247 subtract 0 '-56267E-5' -> '0.56267'
-dqsub248 subtract 0 '-56267E-2' -> '562.67'
-dqsub249 subtract 0 '-56267E-1' -> '5626.7'
-dqsub250 subtract 0 '-56267E-0' -> '56267'
-
--- now some more from the 'new' add
-dqsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
-dqsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
-
--- some carrying effects
-dqsub321 subtract '0.9998' '0.0000' -> '0.9998'
-dqsub322 subtract '0.9998' '0.0001' -> '0.9997'
-dqsub323 subtract '0.9998' '0.0002' -> '0.9996'
-dqsub324 subtract '0.9998' '0.0003' -> '0.9995'
-dqsub325 subtract '0.9998' '-0.0000' -> '0.9998'
-dqsub326 subtract '0.9998' '-0.0001' -> '0.9999'
-dqsub327 subtract '0.9998' '-0.0002' -> '1.0000'
-dqsub328 subtract '0.9998' '-0.0003' -> '1.0001'
-
--- internal boundaries
-dqsub346 subtract '10000e+9' '7' -> '9999999999993'
-dqsub347 subtract '10000e+9' '70' -> '9999999999930'
-dqsub348 subtract '10000e+9' '700' -> '9999999999300'
-dqsub349 subtract '10000e+9' '7000' -> '9999999993000'
-dqsub350 subtract '10000e+9' '70000' -> '9999999930000'
-dqsub351 subtract '10000e+9' '700000' -> '9999999300000'
-dqsub352 subtract '7' '10000e+9' -> '-9999999999993'
-dqsub353 subtract '70' '10000e+9' -> '-9999999999930'
-dqsub354 subtract '700' '10000e+9' -> '-9999999999300'
-dqsub355 subtract '7000' '10000e+9' -> '-9999999993000'
-dqsub356 subtract '70000' '10000e+9' -> '-9999999930000'
-dqsub357 subtract '700000' '10000e+9' -> '-9999999300000'
-
--- zero preservation
-dqsub361 subtract 1 '0.0001' -> '0.9999'
-dqsub362 subtract 1 '0.00001' -> '0.99999'
-dqsub363 subtract 1 '0.000001' -> '0.999999'
-dqsub364 subtract 1 '0.0000000000000000000000000000000001' -> '0.9999999999999999999999999999999999'
-dqsub365 subtract 1 '0.00000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub366 subtract 1 '0.000000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-dqsub370 subtract 1 0 -> 1
-dqsub371 subtract 1 0. -> 1
-dqsub372 subtract 1 .0 -> 1.0
-dqsub373 subtract 1 0.0 -> 1.0
-dqsub374 subtract 0 1 -> -1
-dqsub375 subtract 0. 1 -> -1
-dqsub376 subtract .0 1 -> -1.0
-dqsub377 subtract 0.0 1 -> -1.0
-
--- leading 0 digit before round
-dqsub910 subtract -103519362 -51897955.3 -> -51621406.7
-dqsub911 subtract 159579.444 89827.5229 -> 69751.9211
-
-dqsub920 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234566 -> 299.9999999999999999999999999999999 Inexact Rounded
-dqsub921 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 300.0000000000000000000000000000000 Inexact Rounded
-dqsub922 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 99.99999999999999999999999999999995
-dqsub923 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234564 -> 99.99999999999999999999999999999996
-dqsub924 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234540 -> 100.0000000000000000000000000000002 Rounded
-dqsub925 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234560 -> 90.00000000000000000000000000000000
-dqsub926 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234561 -> 89.99999999999999999999999999999999
-dqsub927 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234566 -> 89.99999999999999999999999999999994
-dqsub928 subtract 101.0000000000000000000000000123456 91.00000000000000000000000001234566 -> 9.99999999999999999999999999999994
-dqsub929 subtract 101.0000000000000000000000000123456 99.00000000000000000000000001234566 -> 1.99999999999999999999999999999994
-
--- more LHS swaps [were fixed]
-dqsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
-dqsub391 subtract '-56267E-6' 0 -> '-0.056267'
-dqsub392 subtract '-56267E-5' 0 -> '-0.56267'
-dqsub393 subtract '-56267E-4' 0 -> '-5.6267'
-dqsub394 subtract '-56267E-3' 0 -> '-56.267'
-dqsub395 subtract '-56267E-2' 0 -> '-562.67'
-dqsub396 subtract '-56267E-1' 0 -> '-5626.7'
-dqsub397 subtract '-56267E-0' 0 -> '-56267'
-dqsub398 subtract '-5E-10' 0 -> '-5E-10'
-dqsub399 subtract '-5E-7' 0 -> '-5E-7'
-dqsub400 subtract '-5E-6' 0 -> '-0.000005'
-dqsub401 subtract '-5E-5' 0 -> '-0.00005'
-dqsub402 subtract '-5E-4' 0 -> '-0.0005'
-dqsub403 subtract '-5E-1' 0 -> '-0.5'
-dqsub404 subtract '-5E0' 0 -> '-5'
-dqsub405 subtract '-5E1' 0 -> '-50'
-dqsub406 subtract '-5E5' 0 -> '-500000'
-dqsub407 subtract '-5E33' 0 -> '-5000000000000000000000000000000000'
-dqsub408 subtract '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
-dqsub409 subtract '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
-dqsub410 subtract '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
-dqsub411 subtract '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
-
--- more RHS swaps [were fixed]
-dqsub420 subtract 0 '-56267E-10' -> '0.0000056267'
-dqsub421 subtract 0 '-56267E-6' -> '0.056267'
-dqsub422 subtract 0 '-56267E-5' -> '0.56267'
-dqsub423 subtract 0 '-56267E-4' -> '5.6267'
-dqsub424 subtract 0 '-56267E-3' -> '56.267'
-dqsub425 subtract 0 '-56267E-2' -> '562.67'
-dqsub426 subtract 0 '-56267E-1' -> '5626.7'
-dqsub427 subtract 0 '-56267E-0' -> '56267'
-dqsub428 subtract 0 '-5E-10' -> '5E-10'
-dqsub429 subtract 0 '-5E-7' -> '5E-7'
-dqsub430 subtract 0 '-5E-6' -> '0.000005'
-dqsub431 subtract 0 '-5E-5' -> '0.00005'
-dqsub432 subtract 0 '-5E-4' -> '0.0005'
-dqsub433 subtract 0 '-5E-1' -> '0.5'
-dqsub434 subtract 0 '-5E0' -> '5'
-dqsub435 subtract 0 '-5E1' -> '50'
-dqsub436 subtract 0 '-5E5' -> '500000'
-dqsub437 subtract 0 '-5E33' -> '5000000000000000000000000000000000'
-dqsub438 subtract 0 '-5E34' -> '5.000000000000000000000000000000000E+34' Rounded
-dqsub439 subtract 0 '-5E35' -> '5.000000000000000000000000000000000E+35' Rounded
-dqsub440 subtract 0 '-5E36' -> '5.000000000000000000000000000000000E+36' Rounded
-dqsub441 subtract 0 '-5E100' -> '5.000000000000000000000000000000000E+100' Rounded
-
-
--- try borderline precision, with carries, etc.
-dqsub461 subtract '1E+16' '1' -> '9999999999999999'
-dqsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
-dqsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
-dqsub464 subtract '-1' '-1E+16' -> '9999999999999999'
-dqsub465 subtract '7E+15' '1' -> '6999999999999999'
-dqsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
-dqsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
-dqsub468 subtract '-1' '-7E+15' -> '6999999999999999'
-
--- 1234567890123456 1234567890123456 1 23456789012345
-dqsub470 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555563' -> '1.000000000000000000000000000000001' Inexact Rounded
-dqsub471 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555562' -> '1.000000000000000000000000000000001' Inexact Rounded
-dqsub472 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555561' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub473 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555560' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub474 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555559' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub475 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555558' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub476 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555557' -> '1.000000000000000000000000000000000' Inexact Rounded
-dqsub477 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555556' -> '1.000000000000000000000000000000000' Rounded
-dqsub478 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
-dqsub479 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555554' -> '0.9999999999999999999999999999999998'
-dqsub480 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555553' -> '0.9999999999999999999999999999999997'
-dqsub481 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555552' -> '0.9999999999999999999999999999999996'
-dqsub482 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555551' -> '0.9999999999999999999999999999999995'
-dqsub483 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555550' -> '0.9999999999999999999999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-dqsub500 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub501 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub502 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub503 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub504 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub505 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub506 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub507 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub508 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub509 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub510 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub511 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub512 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub513 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub514 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub515 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub516 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub517 subtract '1231234555555555555555555567456789' 1.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub518 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub519 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
-
-rounding: half_even
-dqsub520 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub521 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub522 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub523 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub524 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub525 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub526 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub527 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
-dqsub528 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub529 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub530 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub531 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub532 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub533 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub534 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub535 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub536 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub537 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub538 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub539 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
--- critical few with even bottom digit...
-dqsub540 subtract '1231234555555555555555555567456788' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub541 subtract '1231234555555555555555555567456788' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub542 subtract '1231234555555555555555555567456788' 0.500000001 -> '1231234555555555555555555567456787' Inexact Rounded
-
-rounding: down
-dqsub550 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
-dqsub551 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub552 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub553 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub554 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub555 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub556 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub557 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub558 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub559 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub560 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub561 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub562 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub563 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub564 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub565 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
-dqsub566 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
-dqsub567 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456787' Inexact Rounded
-dqsub568 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456787' Inexact Rounded
-dqsub569 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456787' Inexact Rounded
-
--- symmetry...
-rounding: half_up
-dqsub600 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub601 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub602 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub603 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub604 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub605 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub606 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub607 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub608 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub609 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub610 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub611 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub612 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub613 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub614 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub615 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub616 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub617 subtract 1.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub618 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub619 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-
-rounding: half_even
-dqsub620 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub621 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub622 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub623 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub624 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub625 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub626 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub627 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
-dqsub628 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub629 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub630 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub631 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub632 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub633 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub634 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub635 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub636 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub637 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub638 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub639 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
--- critical few with even bottom digit...
-dqsub640 subtract 0.499999999 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub641 subtract 0.5 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub642 subtract 0.500000001 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456787' Inexact Rounded
-
-rounding: down
-dqsub650 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
-dqsub651 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub652 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub653 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub654 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub655 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub656 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub657 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub658 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub659 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub660 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub661 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub662 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub663 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub664 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub665 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
-dqsub666 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
-dqsub667 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-dqsub668 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-dqsub669 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
-
-
--- lots of leading zeros in intermediate result, and showing effects of
--- input rounding would have affected the following
-rounding: half_up
-dqsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-rounding: half_even
-dqsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
-
-dqsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
-dqsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
-dqsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
-dqsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
-dqsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
-
-rounding: down
-dqsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
-dqsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
-dqsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
-dqsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
-dqsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
-
--- Specials
-dqsub780 subtract -Inf Inf -> -Infinity
-dqsub781 subtract -Inf 1000 -> -Infinity
-dqsub782 subtract -Inf 1 -> -Infinity
-dqsub783 subtract -Inf -0 -> -Infinity
-dqsub784 subtract -Inf -1 -> -Infinity
-dqsub785 subtract -Inf -1000 -> -Infinity
-dqsub787 subtract -1000 Inf -> -Infinity
-dqsub788 subtract -Inf Inf -> -Infinity
-dqsub789 subtract -1 Inf -> -Infinity
-dqsub790 subtract 0 Inf -> -Infinity
-dqsub791 subtract 1 Inf -> -Infinity
-dqsub792 subtract 1000 Inf -> -Infinity
-
-dqsub800 subtract Inf Inf -> NaN Invalid_operation
-dqsub801 subtract Inf 1000 -> Infinity
-dqsub802 subtract Inf 1 -> Infinity
-dqsub803 subtract Inf 0 -> Infinity
-dqsub804 subtract Inf -0 -> Infinity
-dqsub805 subtract Inf -1 -> Infinity
-dqsub806 subtract Inf -1000 -> Infinity
-dqsub807 subtract Inf -Inf -> Infinity
-dqsub808 subtract -1000 -Inf -> Infinity
-dqsub809 subtract -Inf -Inf -> NaN Invalid_operation
-dqsub810 subtract -1 -Inf -> Infinity
-dqsub811 subtract -0 -Inf -> Infinity
-dqsub812 subtract 0 -Inf -> Infinity
-dqsub813 subtract 1 -Inf -> Infinity
-dqsub814 subtract 1000 -Inf -> Infinity
-dqsub815 subtract Inf -Inf -> Infinity
-
-dqsub821 subtract NaN Inf -> NaN
-dqsub822 subtract -NaN 1000 -> -NaN
-dqsub823 subtract NaN 1 -> NaN
-dqsub824 subtract NaN 0 -> NaN
-dqsub825 subtract NaN -0 -> NaN
-dqsub826 subtract NaN -1 -> NaN
-dqsub827 subtract NaN -1000 -> NaN
-dqsub828 subtract NaN -Inf -> NaN
-dqsub829 subtract -NaN NaN -> -NaN
-dqsub830 subtract -Inf NaN -> NaN
-dqsub831 subtract -1000 NaN -> NaN
-dqsub832 subtract -1 NaN -> NaN
-dqsub833 subtract -0 NaN -> NaN
-dqsub834 subtract 0 NaN -> NaN
-dqsub835 subtract 1 NaN -> NaN
-dqsub836 subtract 1000 -NaN -> -NaN
-dqsub837 subtract Inf NaN -> NaN
-
-dqsub841 subtract sNaN Inf -> NaN Invalid_operation
-dqsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
-dqsub843 subtract sNaN 1 -> NaN Invalid_operation
-dqsub844 subtract sNaN 0 -> NaN Invalid_operation
-dqsub845 subtract sNaN -0 -> NaN Invalid_operation
-dqsub846 subtract sNaN -1 -> NaN Invalid_operation
-dqsub847 subtract sNaN -1000 -> NaN Invalid_operation
-dqsub848 subtract sNaN NaN -> NaN Invalid_operation
-dqsub849 subtract sNaN sNaN -> NaN Invalid_operation
-dqsub850 subtract NaN sNaN -> NaN Invalid_operation
-dqsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
-dqsub852 subtract -1000 sNaN -> NaN Invalid_operation
-dqsub853 subtract -1 sNaN -> NaN Invalid_operation
-dqsub854 subtract -0 sNaN -> NaN Invalid_operation
-dqsub855 subtract 0 sNaN -> NaN Invalid_operation
-dqsub856 subtract 1 sNaN -> NaN Invalid_operation
-dqsub857 subtract 1000 sNaN -> NaN Invalid_operation
-dqsub858 subtract Inf sNaN -> NaN Invalid_operation
-dqsub859 subtract NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqsub861 subtract NaN01 -Inf -> NaN1
-dqsub862 subtract -NaN02 -1000 -> -NaN2
-dqsub863 subtract NaN03 1000 -> NaN3
-dqsub864 subtract NaN04 Inf -> NaN4
-dqsub865 subtract NaN05 NaN61 -> NaN5
-dqsub866 subtract -Inf -NaN71 -> -NaN71
-dqsub867 subtract -1000 NaN81 -> NaN81
-dqsub868 subtract 1000 NaN91 -> NaN91
-dqsub869 subtract Inf NaN101 -> NaN101
-dqsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
-dqsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
-dqsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
-dqsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
-dqsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
-dqsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
-dqsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
-dqsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
-dqsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
-dqsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
-dqsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- edge case spills
-dqsub901 subtract 2.E-3 1.002 -> -1.000
-dqsub902 subtract 2.0E-3 1.002 -> -1.0000
-dqsub903 subtract 2.00E-3 1.0020 -> -1.00000
-dqsub904 subtract 2.000E-3 1.00200 -> -1.000000
-dqsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
-dqsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
-dqsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
-dqsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
-
--- subnormals and overflows covered under Add
-
--- Examples from SQL proposal (Krishna Kulkarni)
-dqsub1125 subtract 130E-2 120E-2 -> 0.10
-dqsub1126 subtract 130E-2 12E-1 -> 0.10
-dqsub1127 subtract 130E-2 1E0 -> 0.30
-dqsub1128 subtract 1E2 1E4 -> -9.9E+3
-
--- Null tests
-dqsub9990 subtract 10 # -> NaN Invalid_operation
-dqsub9991 subtract # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqSubtract.decTest -- decQuad subtraction --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests are for decQuads only; all arguments are
+-- representable in a decQuad
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- [first group are 'quick confidence check']
+dqsub001 subtract 0 0 -> '0'
+dqsub002 subtract 1 1 -> '0'
+dqsub003 subtract 1 2 -> '-1'
+dqsub004 subtract 2 1 -> '1'
+dqsub005 subtract 2 2 -> '0'
+dqsub006 subtract 3 2 -> '1'
+dqsub007 subtract 2 3 -> '-1'
+
+dqsub011 subtract -0 0 -> '-0'
+dqsub012 subtract -1 1 -> '-2'
+dqsub013 subtract -1 2 -> '-3'
+dqsub014 subtract -2 1 -> '-3'
+dqsub015 subtract -2 2 -> '-4'
+dqsub016 subtract -3 2 -> '-5'
+dqsub017 subtract -2 3 -> '-5'
+
+dqsub021 subtract 0 -0 -> '0'
+dqsub022 subtract 1 -1 -> '2'
+dqsub023 subtract 1 -2 -> '3'
+dqsub024 subtract 2 -1 -> '3'
+dqsub025 subtract 2 -2 -> '4'
+dqsub026 subtract 3 -2 -> '5'
+dqsub027 subtract 2 -3 -> '5'
+
+dqsub030 subtract 11 1 -> 10
+dqsub031 subtract 10 1 -> 9
+dqsub032 subtract 9 1 -> 8
+dqsub033 subtract 1 1 -> 0
+dqsub034 subtract 0 1 -> -1
+dqsub035 subtract -1 1 -> -2
+dqsub036 subtract -9 1 -> -10
+dqsub037 subtract -10 1 -> -11
+dqsub038 subtract -11 1 -> -12
+
+dqsub040 subtract '5.75' '3.3' -> '2.45'
+dqsub041 subtract '5' '-3' -> '8'
+dqsub042 subtract '-5' '-3' -> '-2'
+dqsub043 subtract '-7' '2.5' -> '-9.5'
+dqsub044 subtract '0.7' '0.3' -> '0.4'
+dqsub045 subtract '1.3' '0.3' -> '1.0'
+dqsub046 subtract '1.25' '1.25' -> '0.00'
+
+dqsub050 subtract '1.23456789' '1.00000000' -> '0.23456789'
+dqsub051 subtract '1.23456789' '1.00000089' -> '0.23456700'
+
+dqsub060 subtract '70' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub061 subtract '700' '10000e+34' -> '-1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub062 subtract '7000' '10000e+34' -> '-9.999999999999999999999999999999999E+37' Inexact Rounded
+dqsub063 subtract '70000' '10000e+34' -> '-9.999999999999999999999999999999993E+37' Rounded
+dqsub064 subtract '700000' '10000e+34' -> '-9.999999999999999999999999999999930E+37' Rounded
+ -- symmetry:
+dqsub065 subtract '10000e+34' '70' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub066 subtract '10000e+34' '700' -> '1.000000000000000000000000000000000E+38' Inexact Rounded
+dqsub067 subtract '10000e+34' '7000' -> '9.999999999999999999999999999999999E+37' Inexact Rounded
+dqsub068 subtract '10000e+34' '70000' -> '9.999999999999999999999999999999993E+37' Rounded
+dqsub069 subtract '10000e+34' '700000' -> '9.999999999999999999999999999999930E+37' Rounded
+
+ -- some of the next group are really constructor tests
+dqsub090 subtract '00.0' '0.0' -> '0.0'
+dqsub091 subtract '00.0' '0.00' -> '0.00'
+dqsub092 subtract '0.00' '00.0' -> '0.00'
+dqsub093 subtract '00.0' '0.00' -> '0.00'
+dqsub094 subtract '0.00' '00.0' -> '0.00'
+dqsub095 subtract '3' '.3' -> '2.7'
+dqsub096 subtract '3.' '.3' -> '2.7'
+dqsub097 subtract '3.0' '.3' -> '2.7'
+dqsub098 subtract '3.00' '.3' -> '2.70'
+dqsub099 subtract '3' '3' -> '0'
+dqsub100 subtract '3' '+3' -> '0'
+dqsub101 subtract '3' '-3' -> '6'
+dqsub102 subtract '3' '0.3' -> '2.7'
+dqsub103 subtract '3.' '0.3' -> '2.7'
+dqsub104 subtract '3.0' '0.3' -> '2.7'
+dqsub105 subtract '3.00' '0.3' -> '2.70'
+dqsub106 subtract '3' '3.0' -> '0.0'
+dqsub107 subtract '3' '+3.0' -> '0.0'
+dqsub108 subtract '3' '-3.0' -> '6.0'
+
+-- the above all from add; massaged and extended. Now some new ones...
+-- [particularly important for comparisons]
+-- NB: -xE-8 below were non-exponents pre-ANSI X3-274, and -1E-7 or 0E-7
+-- with input rounding.
+dqsub120 subtract '10.23456784' '10.23456789' -> '-5E-8'
+dqsub121 subtract '10.23456785' '10.23456789' -> '-4E-8'
+dqsub122 subtract '10.23456786' '10.23456789' -> '-3E-8'
+dqsub123 subtract '10.23456787' '10.23456789' -> '-2E-8'
+dqsub124 subtract '10.23456788' '10.23456789' -> '-1E-8'
+dqsub125 subtract '10.23456789' '10.23456789' -> '0E-8'
+dqsub126 subtract '10.23456790' '10.23456789' -> '1E-8'
+dqsub127 subtract '10.23456791' '10.23456789' -> '2E-8'
+dqsub128 subtract '10.23456792' '10.23456789' -> '3E-8'
+dqsub129 subtract '10.23456793' '10.23456789' -> '4E-8'
+dqsub130 subtract '10.23456794' '10.23456789' -> '5E-8'
+dqsub131 subtract '10.23456781' '10.23456786' -> '-5E-8'
+dqsub132 subtract '10.23456782' '10.23456786' -> '-4E-8'
+dqsub133 subtract '10.23456783' '10.23456786' -> '-3E-8'
+dqsub134 subtract '10.23456784' '10.23456786' -> '-2E-8'
+dqsub135 subtract '10.23456785' '10.23456786' -> '-1E-8'
+dqsub136 subtract '10.23456786' '10.23456786' -> '0E-8'
+dqsub137 subtract '10.23456787' '10.23456786' -> '1E-8'
+dqsub138 subtract '10.23456788' '10.23456786' -> '2E-8'
+dqsub139 subtract '10.23456789' '10.23456786' -> '3E-8'
+dqsub140 subtract '10.23456790' '10.23456786' -> '4E-8'
+dqsub141 subtract '10.23456791' '10.23456786' -> '5E-8'
+dqsub142 subtract '1' '0.999999999' -> '1E-9'
+dqsub143 subtract '0.999999999' '1' -> '-1E-9'
+dqsub144 subtract '-10.23456780' '-10.23456786' -> '6E-8'
+dqsub145 subtract '-10.23456790' '-10.23456786' -> '-4E-8'
+dqsub146 subtract '-10.23456791' '-10.23456786' -> '-5E-8'
+
+-- additional scaled arithmetic tests [0.97 problem]
+dqsub160 subtract '0' '.1' -> '-0.1'
+dqsub161 subtract '00' '.97983' -> '-0.97983'
+dqsub162 subtract '0' '.9' -> '-0.9'
+dqsub163 subtract '0' '0.102' -> '-0.102'
+dqsub164 subtract '0' '.4' -> '-0.4'
+dqsub165 subtract '0' '.307' -> '-0.307'
+dqsub166 subtract '0' '.43822' -> '-0.43822'
+dqsub167 subtract '0' '.911' -> '-0.911'
+dqsub168 subtract '.0' '.02' -> '-0.02'
+dqsub169 subtract '00' '.392' -> '-0.392'
+dqsub170 subtract '0' '.26' -> '-0.26'
+dqsub171 subtract '0' '0.51' -> '-0.51'
+dqsub172 subtract '0' '.2234' -> '-0.2234'
+dqsub173 subtract '0' '.2' -> '-0.2'
+dqsub174 subtract '.0' '.0008' -> '-0.0008'
+-- 0. on left
+dqsub180 subtract '0.0' '-.1' -> '0.1'
+dqsub181 subtract '0.00' '-.97983' -> '0.97983'
+dqsub182 subtract '0.0' '-.9' -> '0.9'
+dqsub183 subtract '0.0' '-0.102' -> '0.102'
+dqsub184 subtract '0.0' '-.4' -> '0.4'
+dqsub185 subtract '0.0' '-.307' -> '0.307'
+dqsub186 subtract '0.0' '-.43822' -> '0.43822'
+dqsub187 subtract '0.0' '-.911' -> '0.911'
+dqsub188 subtract '0.0' '-.02' -> '0.02'
+dqsub189 subtract '0.00' '-.392' -> '0.392'
+dqsub190 subtract '0.0' '-.26' -> '0.26'
+dqsub191 subtract '0.0' '-0.51' -> '0.51'
+dqsub192 subtract '0.0' '-.2234' -> '0.2234'
+dqsub193 subtract '0.0' '-.2' -> '0.2'
+dqsub194 subtract '0.0' '-.0008' -> '0.0008'
+-- negatives of same
+dqsub200 subtract '0' '-.1' -> '0.1'
+dqsub201 subtract '00' '-.97983' -> '0.97983'
+dqsub202 subtract '0' '-.9' -> '0.9'
+dqsub203 subtract '0' '-0.102' -> '0.102'
+dqsub204 subtract '0' '-.4' -> '0.4'
+dqsub205 subtract '0' '-.307' -> '0.307'
+dqsub206 subtract '0' '-.43822' -> '0.43822'
+dqsub207 subtract '0' '-.911' -> '0.911'
+dqsub208 subtract '.0' '-.02' -> '0.02'
+dqsub209 subtract '00' '-.392' -> '0.392'
+dqsub210 subtract '0' '-.26' -> '0.26'
+dqsub211 subtract '0' '-0.51' -> '0.51'
+dqsub212 subtract '0' '-.2234' -> '0.2234'
+dqsub213 subtract '0' '-.2' -> '0.2'
+dqsub214 subtract '.0' '-.0008' -> '0.0008'
+
+-- more fixed, LHS swaps [really the same as testcases under add]
+dqsub220 subtract '-56267E-12' 0 -> '-5.6267E-8'
+dqsub221 subtract '-56267E-11' 0 -> '-5.6267E-7'
+dqsub222 subtract '-56267E-10' 0 -> '-0.0000056267'
+dqsub223 subtract '-56267E-9' 0 -> '-0.000056267'
+dqsub224 subtract '-56267E-8' 0 -> '-0.00056267'
+dqsub225 subtract '-56267E-7' 0 -> '-0.0056267'
+dqsub226 subtract '-56267E-6' 0 -> '-0.056267'
+dqsub227 subtract '-56267E-5' 0 -> '-0.56267'
+dqsub228 subtract '-56267E-2' 0 -> '-562.67'
+dqsub229 subtract '-56267E-1' 0 -> '-5626.7'
+dqsub230 subtract '-56267E-0' 0 -> '-56267'
+-- symmetry ...
+dqsub240 subtract 0 '-56267E-12' -> '5.6267E-8'
+dqsub241 subtract 0 '-56267E-11' -> '5.6267E-7'
+dqsub242 subtract 0 '-56267E-10' -> '0.0000056267'
+dqsub243 subtract 0 '-56267E-9' -> '0.000056267'
+dqsub244 subtract 0 '-56267E-8' -> '0.00056267'
+dqsub245 subtract 0 '-56267E-7' -> '0.0056267'
+dqsub246 subtract 0 '-56267E-6' -> '0.056267'
+dqsub247 subtract 0 '-56267E-5' -> '0.56267'
+dqsub248 subtract 0 '-56267E-2' -> '562.67'
+dqsub249 subtract 0 '-56267E-1' -> '5626.7'
+dqsub250 subtract 0 '-56267E-0' -> '56267'
+
+-- now some more from the 'new' add
+dqsub301 subtract '1.23456789' '1.00000000' -> '0.23456789'
+dqsub302 subtract '1.23456789' '1.00000011' -> '0.23456778'
+
+-- some carrying effects
+dqsub321 subtract '0.9998' '0.0000' -> '0.9998'
+dqsub322 subtract '0.9998' '0.0001' -> '0.9997'
+dqsub323 subtract '0.9998' '0.0002' -> '0.9996'
+dqsub324 subtract '0.9998' '0.0003' -> '0.9995'
+dqsub325 subtract '0.9998' '-0.0000' -> '0.9998'
+dqsub326 subtract '0.9998' '-0.0001' -> '0.9999'
+dqsub327 subtract '0.9998' '-0.0002' -> '1.0000'
+dqsub328 subtract '0.9998' '-0.0003' -> '1.0001'
+
+-- internal boundaries
+dqsub346 subtract '10000e+9' '7' -> '9999999999993'
+dqsub347 subtract '10000e+9' '70' -> '9999999999930'
+dqsub348 subtract '10000e+9' '700' -> '9999999999300'
+dqsub349 subtract '10000e+9' '7000' -> '9999999993000'
+dqsub350 subtract '10000e+9' '70000' -> '9999999930000'
+dqsub351 subtract '10000e+9' '700000' -> '9999999300000'
+dqsub352 subtract '7' '10000e+9' -> '-9999999999993'
+dqsub353 subtract '70' '10000e+9' -> '-9999999999930'
+dqsub354 subtract '700' '10000e+9' -> '-9999999999300'
+dqsub355 subtract '7000' '10000e+9' -> '-9999999993000'
+dqsub356 subtract '70000' '10000e+9' -> '-9999999930000'
+dqsub357 subtract '700000' '10000e+9' -> '-9999999300000'
+
+-- zero preservation
+dqsub361 subtract 1 '0.0001' -> '0.9999'
+dqsub362 subtract 1 '0.00001' -> '0.99999'
+dqsub363 subtract 1 '0.000001' -> '0.999999'
+dqsub364 subtract 1 '0.0000000000000000000000000000000001' -> '0.9999999999999999999999999999999999'
+dqsub365 subtract 1 '0.00000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub366 subtract 1 '0.000000000000000000000000000000000001' -> '1.000000000000000000000000000000000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+dqsub370 subtract 1 0 -> 1
+dqsub371 subtract 1 0. -> 1
+dqsub372 subtract 1 .0 -> 1.0
+dqsub373 subtract 1 0.0 -> 1.0
+dqsub374 subtract 0 1 -> -1
+dqsub375 subtract 0. 1 -> -1
+dqsub376 subtract .0 1 -> -1.0
+dqsub377 subtract 0.0 1 -> -1.0
+
+-- leading 0 digit before round
+dqsub910 subtract -103519362 -51897955.3 -> -51621406.7
+dqsub911 subtract 159579.444 89827.5229 -> 69751.9211
+
+dqsub920 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234566 -> 299.9999999999999999999999999999999 Inexact Rounded
+dqsub921 subtract 333.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 300.0000000000000000000000000000000 Inexact Rounded
+dqsub922 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234565 -> 99.99999999999999999999999999999995
+dqsub923 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234564 -> 99.99999999999999999999999999999996
+dqsub924 subtract 133.0000000000000000000000000123456 33.00000000000000000000000001234540 -> 100.0000000000000000000000000000002 Rounded
+dqsub925 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234560 -> 90.00000000000000000000000000000000
+dqsub926 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234561 -> 89.99999999999999999999999999999999
+dqsub927 subtract 133.0000000000000000000000000123456 43.00000000000000000000000001234566 -> 89.99999999999999999999999999999994
+dqsub928 subtract 101.0000000000000000000000000123456 91.00000000000000000000000001234566 -> 9.99999999999999999999999999999994
+dqsub929 subtract 101.0000000000000000000000000123456 99.00000000000000000000000001234566 -> 1.99999999999999999999999999999994
+
+-- more LHS swaps [were fixed]
+dqsub390 subtract '-56267E-10' 0 -> '-0.0000056267'
+dqsub391 subtract '-56267E-6' 0 -> '-0.056267'
+dqsub392 subtract '-56267E-5' 0 -> '-0.56267'
+dqsub393 subtract '-56267E-4' 0 -> '-5.6267'
+dqsub394 subtract '-56267E-3' 0 -> '-56.267'
+dqsub395 subtract '-56267E-2' 0 -> '-562.67'
+dqsub396 subtract '-56267E-1' 0 -> '-5626.7'
+dqsub397 subtract '-56267E-0' 0 -> '-56267'
+dqsub398 subtract '-5E-10' 0 -> '-5E-10'
+dqsub399 subtract '-5E-7' 0 -> '-5E-7'
+dqsub400 subtract '-5E-6' 0 -> '-0.000005'
+dqsub401 subtract '-5E-5' 0 -> '-0.00005'
+dqsub402 subtract '-5E-4' 0 -> '-0.0005'
+dqsub403 subtract '-5E-1' 0 -> '-0.5'
+dqsub404 subtract '-5E0' 0 -> '-5'
+dqsub405 subtract '-5E1' 0 -> '-50'
+dqsub406 subtract '-5E5' 0 -> '-500000'
+dqsub407 subtract '-5E33' 0 -> '-5000000000000000000000000000000000'
+dqsub408 subtract '-5E34' 0 -> '-5.000000000000000000000000000000000E+34' Rounded
+dqsub409 subtract '-5E35' 0 -> '-5.000000000000000000000000000000000E+35' Rounded
+dqsub410 subtract '-5E36' 0 -> '-5.000000000000000000000000000000000E+36' Rounded
+dqsub411 subtract '-5E100' 0 -> '-5.000000000000000000000000000000000E+100' Rounded
+
+-- more RHS swaps [were fixed]
+dqsub420 subtract 0 '-56267E-10' -> '0.0000056267'
+dqsub421 subtract 0 '-56267E-6' -> '0.056267'
+dqsub422 subtract 0 '-56267E-5' -> '0.56267'
+dqsub423 subtract 0 '-56267E-4' -> '5.6267'
+dqsub424 subtract 0 '-56267E-3' -> '56.267'
+dqsub425 subtract 0 '-56267E-2' -> '562.67'
+dqsub426 subtract 0 '-56267E-1' -> '5626.7'
+dqsub427 subtract 0 '-56267E-0' -> '56267'
+dqsub428 subtract 0 '-5E-10' -> '5E-10'
+dqsub429 subtract 0 '-5E-7' -> '5E-7'
+dqsub430 subtract 0 '-5E-6' -> '0.000005'
+dqsub431 subtract 0 '-5E-5' -> '0.00005'
+dqsub432 subtract 0 '-5E-4' -> '0.0005'
+dqsub433 subtract 0 '-5E-1' -> '0.5'
+dqsub434 subtract 0 '-5E0' -> '5'
+dqsub435 subtract 0 '-5E1' -> '50'
+dqsub436 subtract 0 '-5E5' -> '500000'
+dqsub437 subtract 0 '-5E33' -> '5000000000000000000000000000000000'
+dqsub438 subtract 0 '-5E34' -> '5.000000000000000000000000000000000E+34' Rounded
+dqsub439 subtract 0 '-5E35' -> '5.000000000000000000000000000000000E+35' Rounded
+dqsub440 subtract 0 '-5E36' -> '5.000000000000000000000000000000000E+36' Rounded
+dqsub441 subtract 0 '-5E100' -> '5.000000000000000000000000000000000E+100' Rounded
+
+
+-- try borderline precision, with carries, etc.
+dqsub461 subtract '1E+16' '1' -> '9999999999999999'
+dqsub462 subtract '1E+12' '-1.111' -> '1000000000001.111'
+dqsub463 subtract '1.111' '-1E+12' -> '1000000000001.111'
+dqsub464 subtract '-1' '-1E+16' -> '9999999999999999'
+dqsub465 subtract '7E+15' '1' -> '6999999999999999'
+dqsub466 subtract '7E+12' '-1.111' -> '7000000000001.111'
+dqsub467 subtract '1.111' '-7E+12' -> '7000000000001.111'
+dqsub468 subtract '-1' '-7E+15' -> '6999999999999999'
+
+-- 1234567890123456 1234567890123456 1 23456789012345
+dqsub470 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555563' -> '1.000000000000000000000000000000001' Inexact Rounded
+dqsub471 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555562' -> '1.000000000000000000000000000000001' Inexact Rounded
+dqsub472 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555561' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub473 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555560' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub474 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555559' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub475 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555558' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub476 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555557' -> '1.000000000000000000000000000000000' Inexact Rounded
+dqsub477 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555556' -> '1.000000000000000000000000000000000' Rounded
+dqsub478 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555555' -> '0.9999999999999999999999999999999999'
+dqsub479 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555554' -> '0.9999999999999999999999999999999998'
+dqsub480 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555553' -> '0.9999999999999999999999999999999997'
+dqsub481 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555552' -> '0.9999999999999999999999999999999996'
+dqsub482 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555551' -> '0.9999999999999999999999999999999995'
+dqsub483 subtract '0.4444444444444444444444444444444444' '-0.5555555555555555555555555555555550' -> '0.9999999999999999999999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+dqsub500 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub501 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub502 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub503 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub504 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub505 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub506 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub507 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub508 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub509 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub510 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub511 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub512 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub513 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub514 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub515 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub516 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub517 subtract '1231234555555555555555555567456789' 1.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub518 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub519 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
+
+rounding: half_even
+dqsub520 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub521 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub522 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub523 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub524 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub525 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub526 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub527 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456789' Inexact Rounded
+dqsub528 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub529 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub530 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub531 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub532 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub533 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub534 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub535 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub536 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub537 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub538 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub539 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456788' Inexact Rounded
+-- critical few with even bottom digit...
+dqsub540 subtract '1231234555555555555555555567456788' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub541 subtract '1231234555555555555555555567456788' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub542 subtract '1231234555555555555555555567456788' 0.500000001 -> '1231234555555555555555555567456787' Inexact Rounded
+
+rounding: down
+dqsub550 subtract '1231234555555555555555555567456789' 0 -> '1231234555555555555555555567456789'
+dqsub551 subtract '1231234555555555555555555567456789' 0.000000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub552 subtract '1231234555555555555555555567456789' 0.000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub553 subtract '1231234555555555555555555567456789' 0.1 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub554 subtract '1231234555555555555555555567456789' 0.4 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub555 subtract '1231234555555555555555555567456789' 0.49 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub556 subtract '1231234555555555555555555567456789' 0.499999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub557 subtract '1231234555555555555555555567456789' 0.499999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub558 subtract '1231234555555555555555555567456789' 0.5 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub559 subtract '1231234555555555555555555567456789' 0.500000001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub560 subtract '1231234555555555555555555567456789' 0.500001 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub561 subtract '1231234555555555555555555567456789' 0.51 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub562 subtract '1231234555555555555555555567456789' 0.6 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub563 subtract '1231234555555555555555555567456789' 0.9 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub564 subtract '1231234555555555555555555567456789' 0.99999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub565 subtract '1231234555555555555555555567456789' 0.999999999 -> '1231234555555555555555555567456788' Inexact Rounded
+dqsub566 subtract '1231234555555555555555555567456789' 1 -> '1231234555555555555555555567456788'
+dqsub567 subtract '1231234555555555555555555567456789' 1.00000001 -> '1231234555555555555555555567456787' Inexact Rounded
+dqsub568 subtract '1231234555555555555555555567456789' 1.00001 -> '1231234555555555555555555567456787' Inexact Rounded
+dqsub569 subtract '1231234555555555555555555567456789' 1.1 -> '1231234555555555555555555567456787' Inexact Rounded
+
+-- symmetry...
+rounding: half_up
+dqsub600 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub601 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub602 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub603 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub604 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub605 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub606 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub607 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub608 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub609 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub610 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub611 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub612 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub613 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub614 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub615 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub616 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub617 subtract 1.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub618 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub619 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+
+rounding: half_even
+dqsub620 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub621 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub622 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub623 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub624 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub625 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub626 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub627 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789' Inexact Rounded
+dqsub628 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub629 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub630 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub631 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub632 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub633 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub634 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub635 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub636 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub637 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub638 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub639 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+-- critical few with even bottom digit...
+dqsub640 subtract 0.499999999 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub641 subtract 0.5 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub642 subtract 0.500000001 '1231234555555555555555555567456788' -> '-1231234555555555555555555567456787' Inexact Rounded
+
+rounding: down
+dqsub650 subtract 0 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456789'
+dqsub651 subtract 0.000000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub652 subtract 0.000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub653 subtract 0.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub654 subtract 0.4 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub655 subtract 0.49 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub656 subtract 0.499999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub657 subtract 0.499999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub658 subtract 0.5 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub659 subtract 0.500000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub660 subtract 0.500001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub661 subtract 0.51 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub662 subtract 0.6 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub663 subtract 0.9 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub664 subtract 0.99999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub665 subtract 0.999999999 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788' Inexact Rounded
+dqsub666 subtract 1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456788'
+dqsub667 subtract 1.00000001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+dqsub668 subtract 1.00001 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+dqsub669 subtract 1.1 '1231234555555555555555555567456789' -> '-1231234555555555555555555567456787' Inexact Rounded
+
+
+-- lots of leading zeros in intermediate result, and showing effects of
+-- input rounding would have affected the following
+rounding: half_up
+dqsub670 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub671 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub672 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub673 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub674 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+rounding: half_even
+dqsub680 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub681 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub682 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub683 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub684 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+dqsub685 subtract '1234567456788' '1234567456787.1' -> 0.9
+dqsub686 subtract '1234567456788' '1234567456787.9' -> 0.1
+dqsub687 subtract '1234567456788' '1234567456788.1' -> -0.1
+dqsub688 subtract '1234567456788' '1234567456788.5' -> -0.5
+dqsub689 subtract '1234567456788' '1234567456788.9' -> -0.9
+
+rounding: down
+dqsub690 subtract '1234567456789' '1234567456788.1' -> 0.9
+dqsub691 subtract '1234567456789' '1234567456788.9' -> 0.1
+dqsub692 subtract '1234567456789' '1234567456789.1' -> -0.1
+dqsub693 subtract '1234567456789' '1234567456789.5' -> -0.5
+dqsub694 subtract '1234567456789' '1234567456789.9' -> -0.9
+
+-- Specials
+dqsub780 subtract -Inf Inf -> -Infinity
+dqsub781 subtract -Inf 1000 -> -Infinity
+dqsub782 subtract -Inf 1 -> -Infinity
+dqsub783 subtract -Inf -0 -> -Infinity
+dqsub784 subtract -Inf -1 -> -Infinity
+dqsub785 subtract -Inf -1000 -> -Infinity
+dqsub787 subtract -1000 Inf -> -Infinity
+dqsub788 subtract -Inf Inf -> -Infinity
+dqsub789 subtract -1 Inf -> -Infinity
+dqsub790 subtract 0 Inf -> -Infinity
+dqsub791 subtract 1 Inf -> -Infinity
+dqsub792 subtract 1000 Inf -> -Infinity
+
+dqsub800 subtract Inf Inf -> NaN Invalid_operation
+dqsub801 subtract Inf 1000 -> Infinity
+dqsub802 subtract Inf 1 -> Infinity
+dqsub803 subtract Inf 0 -> Infinity
+dqsub804 subtract Inf -0 -> Infinity
+dqsub805 subtract Inf -1 -> Infinity
+dqsub806 subtract Inf -1000 -> Infinity
+dqsub807 subtract Inf -Inf -> Infinity
+dqsub808 subtract -1000 -Inf -> Infinity
+dqsub809 subtract -Inf -Inf -> NaN Invalid_operation
+dqsub810 subtract -1 -Inf -> Infinity
+dqsub811 subtract -0 -Inf -> Infinity
+dqsub812 subtract 0 -Inf -> Infinity
+dqsub813 subtract 1 -Inf -> Infinity
+dqsub814 subtract 1000 -Inf -> Infinity
+dqsub815 subtract Inf -Inf -> Infinity
+
+dqsub821 subtract NaN Inf -> NaN
+dqsub822 subtract -NaN 1000 -> -NaN
+dqsub823 subtract NaN 1 -> NaN
+dqsub824 subtract NaN 0 -> NaN
+dqsub825 subtract NaN -0 -> NaN
+dqsub826 subtract NaN -1 -> NaN
+dqsub827 subtract NaN -1000 -> NaN
+dqsub828 subtract NaN -Inf -> NaN
+dqsub829 subtract -NaN NaN -> -NaN
+dqsub830 subtract -Inf NaN -> NaN
+dqsub831 subtract -1000 NaN -> NaN
+dqsub832 subtract -1 NaN -> NaN
+dqsub833 subtract -0 NaN -> NaN
+dqsub834 subtract 0 NaN -> NaN
+dqsub835 subtract 1 NaN -> NaN
+dqsub836 subtract 1000 -NaN -> -NaN
+dqsub837 subtract Inf NaN -> NaN
+
+dqsub841 subtract sNaN Inf -> NaN Invalid_operation
+dqsub842 subtract -sNaN 1000 -> -NaN Invalid_operation
+dqsub843 subtract sNaN 1 -> NaN Invalid_operation
+dqsub844 subtract sNaN 0 -> NaN Invalid_operation
+dqsub845 subtract sNaN -0 -> NaN Invalid_operation
+dqsub846 subtract sNaN -1 -> NaN Invalid_operation
+dqsub847 subtract sNaN -1000 -> NaN Invalid_operation
+dqsub848 subtract sNaN NaN -> NaN Invalid_operation
+dqsub849 subtract sNaN sNaN -> NaN Invalid_operation
+dqsub850 subtract NaN sNaN -> NaN Invalid_operation
+dqsub851 subtract -Inf -sNaN -> -NaN Invalid_operation
+dqsub852 subtract -1000 sNaN -> NaN Invalid_operation
+dqsub853 subtract -1 sNaN -> NaN Invalid_operation
+dqsub854 subtract -0 sNaN -> NaN Invalid_operation
+dqsub855 subtract 0 sNaN -> NaN Invalid_operation
+dqsub856 subtract 1 sNaN -> NaN Invalid_operation
+dqsub857 subtract 1000 sNaN -> NaN Invalid_operation
+dqsub858 subtract Inf sNaN -> NaN Invalid_operation
+dqsub859 subtract NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqsub861 subtract NaN01 -Inf -> NaN1
+dqsub862 subtract -NaN02 -1000 -> -NaN2
+dqsub863 subtract NaN03 1000 -> NaN3
+dqsub864 subtract NaN04 Inf -> NaN4
+dqsub865 subtract NaN05 NaN61 -> NaN5
+dqsub866 subtract -Inf -NaN71 -> -NaN71
+dqsub867 subtract -1000 NaN81 -> NaN81
+dqsub868 subtract 1000 NaN91 -> NaN91
+dqsub869 subtract Inf NaN101 -> NaN101
+dqsub871 subtract sNaN011 -Inf -> NaN11 Invalid_operation
+dqsub872 subtract sNaN012 -1000 -> NaN12 Invalid_operation
+dqsub873 subtract -sNaN013 1000 -> -NaN13 Invalid_operation
+dqsub874 subtract sNaN014 NaN171 -> NaN14 Invalid_operation
+dqsub875 subtract sNaN015 sNaN181 -> NaN15 Invalid_operation
+dqsub876 subtract NaN016 sNaN191 -> NaN191 Invalid_operation
+dqsub877 subtract -Inf sNaN201 -> NaN201 Invalid_operation
+dqsub878 subtract -1000 sNaN211 -> NaN211 Invalid_operation
+dqsub879 subtract 1000 -sNaN221 -> -NaN221 Invalid_operation
+dqsub880 subtract Inf sNaN231 -> NaN231 Invalid_operation
+dqsub881 subtract NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- edge case spills
+dqsub901 subtract 2.E-3 1.002 -> -1.000
+dqsub902 subtract 2.0E-3 1.002 -> -1.0000
+dqsub903 subtract 2.00E-3 1.0020 -> -1.00000
+dqsub904 subtract 2.000E-3 1.00200 -> -1.000000
+dqsub905 subtract 2.0000E-3 1.002000 -> -1.0000000
+dqsub906 subtract 2.00000E-3 1.0020000 -> -1.00000000
+dqsub907 subtract 2.000000E-3 1.00200000 -> -1.000000000
+dqsub908 subtract 2.0000000E-3 1.002000000 -> -1.0000000000
+
+-- subnormals and overflows covered under Add
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+dqsub1125 subtract 130E-2 120E-2 -> 0.10
+dqsub1126 subtract 130E-2 12E-1 -> 0.10
+dqsub1127 subtract 130E-2 1E0 -> 0.30
+dqsub1128 subtract 1E2 1E4 -> -9.9E+3
+
+-- Null tests
+dqsub9990 subtract 10 # -> NaN Invalid_operation
+dqsub9991 subtract # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dqToIntegral.decTest b/Lib/test/decimaltestdata/dqToIntegral.decTest
index 3055de572d1..eb12387eab7 100644
--- a/Lib/test/decimaltestdata/dqToIntegral.decTest
+++ b/Lib/test/decimaltestdata/dqToIntegral.decTest
@@ -1,257 +1,257 @@
-------------------------------------------------------------------------
--- dqToIntegral.decTest -- round Quad to integral value --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value-exact' operations (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested extensively
--- elsewhere; the tests here are for integrity, rounding mode, etc.
--- Also, it is assumed the test harness will use these tests for both
--- ToIntegralExact (which does set Inexact) and the fixed-name
--- functions (which do not set Inexact).
-
--- Note that decNumber implements an earlier definition of toIntegral
--- which never sets Inexact; the decTest operator for that is called
--- 'tointegral' instead of 'tointegralx'.
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
-dqintx001 tointegralx 0 -> 0
-dqintx002 tointegralx 0.0 -> 0
-dqintx003 tointegralx 0.1 -> 0 Inexact Rounded
-dqintx004 tointegralx 0.2 -> 0 Inexact Rounded
-dqintx005 tointegralx 0.3 -> 0 Inexact Rounded
-dqintx006 tointegralx 0.4 -> 0 Inexact Rounded
-dqintx007 tointegralx 0.5 -> 0 Inexact Rounded
-dqintx008 tointegralx 0.6 -> 1 Inexact Rounded
-dqintx009 tointegralx 0.7 -> 1 Inexact Rounded
-dqintx010 tointegralx 0.8 -> 1 Inexact Rounded
-dqintx011 tointegralx 0.9 -> 1 Inexact Rounded
-dqintx012 tointegralx 1 -> 1
-dqintx013 tointegralx 1.0 -> 1 Rounded
-dqintx014 tointegralx 1.1 -> 1 Inexact Rounded
-dqintx015 tointegralx 1.2 -> 1 Inexact Rounded
-dqintx016 tointegralx 1.3 -> 1 Inexact Rounded
-dqintx017 tointegralx 1.4 -> 1 Inexact Rounded
-dqintx018 tointegralx 1.5 -> 2 Inexact Rounded
-dqintx019 tointegralx 1.6 -> 2 Inexact Rounded
-dqintx020 tointegralx 1.7 -> 2 Inexact Rounded
-dqintx021 tointegralx 1.8 -> 2 Inexact Rounded
-dqintx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-dqintx031 tointegralx -0 -> -0
-dqintx032 tointegralx -0.0 -> -0
-dqintx033 tointegralx -0.1 -> -0 Inexact Rounded
-dqintx034 tointegralx -0.2 -> -0 Inexact Rounded
-dqintx035 tointegralx -0.3 -> -0 Inexact Rounded
-dqintx036 tointegralx -0.4 -> -0 Inexact Rounded
-dqintx037 tointegralx -0.5 -> -0 Inexact Rounded
-dqintx038 tointegralx -0.6 -> -1 Inexact Rounded
-dqintx039 tointegralx -0.7 -> -1 Inexact Rounded
-dqintx040 tointegralx -0.8 -> -1 Inexact Rounded
-dqintx041 tointegralx -0.9 -> -1 Inexact Rounded
-dqintx042 tointegralx -1 -> -1
-dqintx043 tointegralx -1.0 -> -1 Rounded
-dqintx044 tointegralx -1.1 -> -1 Inexact Rounded
-dqintx045 tointegralx -1.2 -> -1 Inexact Rounded
-dqintx046 tointegralx -1.3 -> -1 Inexact Rounded
-dqintx047 tointegralx -1.4 -> -1 Inexact Rounded
-dqintx048 tointegralx -1.5 -> -2 Inexact Rounded
-dqintx049 tointegralx -1.6 -> -2 Inexact Rounded
-dqintx050 tointegralx -1.7 -> -2 Inexact Rounded
-dqintx051 tointegralx -1.8 -> -2 Inexact Rounded
-dqintx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-dqintx053 tointegralx 10E+60 -> 1.0E+61
-dqintx054 tointegralx -10E+60 -> -1.0E+61
-
--- numbers around precision
-dqintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
-dqintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-dqintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-dqintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-dqintx065 tointegralx '56267E-0' -> '56267'
-dqintx066 tointegralx '56267E+0' -> '56267'
-dqintx067 tointegralx '56267E+1' -> '5.6267E+5'
-dqintx068 tointegralx '56267E+9' -> '5.6267E+13'
-dqintx069 tointegralx '56267E+10' -> '5.6267E+14'
-dqintx070 tointegralx '56267E+11' -> '5.6267E+15'
-dqintx071 tointegralx '56267E+12' -> '5.6267E+16'
-dqintx072 tointegralx '56267E+13' -> '5.6267E+17'
-dqintx073 tointegralx '1.23E+96' -> '1.23E+96'
-dqintx074 tointegralx '1.23E+6144' -> #47ffd300000000000000000000000000 Clamped
-
-dqintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-dqintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-dqintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-dqintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-dqintx085 tointegralx '-56267E-0' -> '-56267'
-dqintx086 tointegralx '-56267E+0' -> '-56267'
-dqintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-dqintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
-dqintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
-dqintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
-dqintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
-dqintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
-dqintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped
-
--- subnormal inputs
-dqintx100 tointegralx 1E-299 -> 0 Inexact Rounded
-dqintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
-dqintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
-dqintx103 tointegralx 0E-299 -> 0
-
--- specials and zeros
-dqintx120 tointegralx 'Inf' -> Infinity
-dqintx121 tointegralx '-Inf' -> -Infinity
-dqintx122 tointegralx NaN -> NaN
-dqintx123 tointegralx sNaN -> NaN Invalid_operation
-dqintx124 tointegralx 0 -> 0
-dqintx125 tointegralx -0 -> -0
-dqintx126 tointegralx 0.000 -> 0
-dqintx127 tointegralx 0.00 -> 0
-dqintx128 tointegralx 0.0 -> 0
-dqintx129 tointegralx 0 -> 0
-dqintx130 tointegralx 0E-3 -> 0
-dqintx131 tointegralx 0E-2 -> 0
-dqintx132 tointegralx 0E-1 -> 0
-dqintx133 tointegralx 0E-0 -> 0
-dqintx134 tointegralx 0E+1 -> 0E+1
-dqintx135 tointegralx 0E+2 -> 0E+2
-dqintx136 tointegralx 0E+3 -> 0E+3
-dqintx137 tointegralx 0E+4 -> 0E+4
-dqintx138 tointegralx 0E+5 -> 0E+5
-dqintx139 tointegralx -0.000 -> -0
-dqintx140 tointegralx -0.00 -> -0
-dqintx141 tointegralx -0.0 -> -0
-dqintx142 tointegralx -0 -> -0
-dqintx143 tointegralx -0E-3 -> -0
-dqintx144 tointegralx -0E-2 -> -0
-dqintx145 tointegralx -0E-1 -> -0
-dqintx146 tointegralx -0E-0 -> -0
-dqintx147 tointegralx -0E+1 -> -0E+1
-dqintx148 tointegralx -0E+2 -> -0E+2
-dqintx149 tointegralx -0E+3 -> -0E+3
-dqintx150 tointegralx -0E+4 -> -0E+4
-dqintx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-dqintx152 tointegralx NaN808 -> NaN808
-dqintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-dqintx154 tointegralx -NaN808 -> -NaN808
-dqintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-dqintx156 tointegralx -NaN -> -NaN
-dqintx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-dqintx200 tointegralx 2.1 -> 2 Inexact Rounded
-dqintx201 tointegralx 100 -> 100
-dqintx202 tointegralx 100.0 -> 100 Rounded
-dqintx203 tointegralx 101.5 -> 102 Inexact Rounded
-dqintx204 tointegralx -101.5 -> -102 Inexact Rounded
-dqintx205 tointegralx 10E+5 -> 1.0E+6
-dqintx206 tointegralx 7.89E+77 -> 7.89E+77
-dqintx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-dqintx210 tointegralx 55.5 -> 56 Inexact Rounded
-dqintx211 tointegralx 56.5 -> 56 Inexact Rounded
-dqintx212 tointegralx 57.5 -> 58 Inexact Rounded
-dqintx213 tointegralx -55.5 -> -56 Inexact Rounded
-dqintx214 tointegralx -56.5 -> -56 Inexact Rounded
-dqintx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-dqintx220 tointegralx 55.5 -> 56 Inexact Rounded
-dqintx221 tointegralx 56.5 -> 57 Inexact Rounded
-dqintx222 tointegralx 57.5 -> 58 Inexact Rounded
-dqintx223 tointegralx -55.5 -> -56 Inexact Rounded
-dqintx224 tointegralx -56.5 -> -57 Inexact Rounded
-dqintx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-dqintx230 tointegralx 55.5 -> 55 Inexact Rounded
-dqintx231 tointegralx 56.5 -> 56 Inexact Rounded
-dqintx232 tointegralx 57.5 -> 57 Inexact Rounded
-dqintx233 tointegralx -55.5 -> -55 Inexact Rounded
-dqintx234 tointegralx -56.5 -> -56 Inexact Rounded
-dqintx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-dqintx240 tointegralx 55.3 -> 56 Inexact Rounded
-dqintx241 tointegralx 56.3 -> 57 Inexact Rounded
-dqintx242 tointegralx 57.3 -> 58 Inexact Rounded
-dqintx243 tointegralx -55.3 -> -56 Inexact Rounded
-dqintx244 tointegralx -56.3 -> -57 Inexact Rounded
-dqintx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-dqintx250 tointegralx 55.7 -> 55 Inexact Rounded
-dqintx251 tointegralx 56.7 -> 56 Inexact Rounded
-dqintx252 tointegralx 57.7 -> 57 Inexact Rounded
-dqintx253 tointegralx -55.7 -> -55 Inexact Rounded
-dqintx254 tointegralx -56.7 -> -56 Inexact Rounded
-dqintx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-dqintx260 tointegralx 55.3 -> 56 Inexact Rounded
-dqintx261 tointegralx 56.3 -> 57 Inexact Rounded
-dqintx262 tointegralx 57.3 -> 58 Inexact Rounded
-dqintx263 tointegralx -55.3 -> -55 Inexact Rounded
-dqintx264 tointegralx -56.3 -> -56 Inexact Rounded
-dqintx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-dqintx270 tointegralx 55.7 -> 55 Inexact Rounded
-dqintx271 tointegralx 56.7 -> 56 Inexact Rounded
-dqintx272 tointegralx 57.7 -> 57 Inexact Rounded
-dqintx273 tointegralx -55.7 -> -56 Inexact Rounded
-dqintx274 tointegralx -56.7 -> -57 Inexact Rounded
-dqintx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-dqintx300 tointegralx -2147483646 -> -2147483646
-dqintx301 tointegralx -2147483647 -> -2147483647
-dqintx302 tointegralx -2147483648 -> -2147483648
-dqintx303 tointegralx -2147483649 -> -2147483649
-dqintx304 tointegralx 2147483646 -> 2147483646
-dqintx305 tointegralx 2147483647 -> 2147483647
-dqintx306 tointegralx 2147483648 -> 2147483648
-dqintx307 tointegralx 2147483649 -> 2147483649
-dqintx308 tointegralx 4294967294 -> 4294967294
-dqintx309 tointegralx 4294967295 -> 4294967295
-dqintx310 tointegralx 4294967296 -> 4294967296
-dqintx311 tointegralx 4294967297 -> 4294967297
-
+------------------------------------------------------------------------
+-- dqToIntegral.decTest -- round Quad to integral value --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value-exact' operations (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested extensively
+-- elsewhere; the tests here are for integrity, rounding mode, etc.
+-- Also, it is assumed the test harness will use these tests for both
+-- ToIntegralExact (which does set Inexact) and the fixed-name
+-- functions (which do not set Inexact).
+
+-- Note that decNumber implements an earlier definition of toIntegral
+-- which never sets Inexact; the decTest operator for that is called
+-- 'tointegral' instead of 'tointegralx'.
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+dqintx001 tointegralx 0 -> 0
+dqintx002 tointegralx 0.0 -> 0
+dqintx003 tointegralx 0.1 -> 0 Inexact Rounded
+dqintx004 tointegralx 0.2 -> 0 Inexact Rounded
+dqintx005 tointegralx 0.3 -> 0 Inexact Rounded
+dqintx006 tointegralx 0.4 -> 0 Inexact Rounded
+dqintx007 tointegralx 0.5 -> 0 Inexact Rounded
+dqintx008 tointegralx 0.6 -> 1 Inexact Rounded
+dqintx009 tointegralx 0.7 -> 1 Inexact Rounded
+dqintx010 tointegralx 0.8 -> 1 Inexact Rounded
+dqintx011 tointegralx 0.9 -> 1 Inexact Rounded
+dqintx012 tointegralx 1 -> 1
+dqintx013 tointegralx 1.0 -> 1 Rounded
+dqintx014 tointegralx 1.1 -> 1 Inexact Rounded
+dqintx015 tointegralx 1.2 -> 1 Inexact Rounded
+dqintx016 tointegralx 1.3 -> 1 Inexact Rounded
+dqintx017 tointegralx 1.4 -> 1 Inexact Rounded
+dqintx018 tointegralx 1.5 -> 2 Inexact Rounded
+dqintx019 tointegralx 1.6 -> 2 Inexact Rounded
+dqintx020 tointegralx 1.7 -> 2 Inexact Rounded
+dqintx021 tointegralx 1.8 -> 2 Inexact Rounded
+dqintx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+dqintx031 tointegralx -0 -> -0
+dqintx032 tointegralx -0.0 -> -0
+dqintx033 tointegralx -0.1 -> -0 Inexact Rounded
+dqintx034 tointegralx -0.2 -> -0 Inexact Rounded
+dqintx035 tointegralx -0.3 -> -0 Inexact Rounded
+dqintx036 tointegralx -0.4 -> -0 Inexact Rounded
+dqintx037 tointegralx -0.5 -> -0 Inexact Rounded
+dqintx038 tointegralx -0.6 -> -1 Inexact Rounded
+dqintx039 tointegralx -0.7 -> -1 Inexact Rounded
+dqintx040 tointegralx -0.8 -> -1 Inexact Rounded
+dqintx041 tointegralx -0.9 -> -1 Inexact Rounded
+dqintx042 tointegralx -1 -> -1
+dqintx043 tointegralx -1.0 -> -1 Rounded
+dqintx044 tointegralx -1.1 -> -1 Inexact Rounded
+dqintx045 tointegralx -1.2 -> -1 Inexact Rounded
+dqintx046 tointegralx -1.3 -> -1 Inexact Rounded
+dqintx047 tointegralx -1.4 -> -1 Inexact Rounded
+dqintx048 tointegralx -1.5 -> -2 Inexact Rounded
+dqintx049 tointegralx -1.6 -> -2 Inexact Rounded
+dqintx050 tointegralx -1.7 -> -2 Inexact Rounded
+dqintx051 tointegralx -1.8 -> -2 Inexact Rounded
+dqintx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+dqintx053 tointegralx 10E+60 -> 1.0E+61
+dqintx054 tointegralx -10E+60 -> -1.0E+61
+
+-- numbers around precision
+dqintx060 tointegralx '56267E-17' -> '0' Inexact Rounded
+dqintx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+dqintx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+dqintx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+dqintx065 tointegralx '56267E-0' -> '56267'
+dqintx066 tointegralx '56267E+0' -> '56267'
+dqintx067 tointegralx '56267E+1' -> '5.6267E+5'
+dqintx068 tointegralx '56267E+9' -> '5.6267E+13'
+dqintx069 tointegralx '56267E+10' -> '5.6267E+14'
+dqintx070 tointegralx '56267E+11' -> '5.6267E+15'
+dqintx071 tointegralx '56267E+12' -> '5.6267E+16'
+dqintx072 tointegralx '56267E+13' -> '5.6267E+17'
+dqintx073 tointegralx '1.23E+96' -> '1.23E+96'
+dqintx074 tointegralx '1.23E+6144' -> #47ffd300000000000000000000000000 Clamped
+
+dqintx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+dqintx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+dqintx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+dqintx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+dqintx085 tointegralx '-56267E-0' -> '-56267'
+dqintx086 tointegralx '-56267E+0' -> '-56267'
+dqintx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+dqintx088 tointegralx '-56267E+9' -> '-5.6267E+13'
+dqintx089 tointegralx '-56267E+10' -> '-5.6267E+14'
+dqintx090 tointegralx '-56267E+11' -> '-5.6267E+15'
+dqintx091 tointegralx '-56267E+12' -> '-5.6267E+16'
+dqintx092 tointegralx '-56267E+13' -> '-5.6267E+17'
+dqintx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+dqintx094 tointegralx '-1.23E+6144' -> #c7ffd300000000000000000000000000 Clamped
+
+-- subnormal inputs
+dqintx100 tointegralx 1E-299 -> 0 Inexact Rounded
+dqintx101 tointegralx 0.1E-299 -> 0 Inexact Rounded
+dqintx102 tointegralx 0.01E-299 -> 0 Inexact Rounded
+dqintx103 tointegralx 0E-299 -> 0
+
+-- specials and zeros
+dqintx120 tointegralx 'Inf' -> Infinity
+dqintx121 tointegralx '-Inf' -> -Infinity
+dqintx122 tointegralx NaN -> NaN
+dqintx123 tointegralx sNaN -> NaN Invalid_operation
+dqintx124 tointegralx 0 -> 0
+dqintx125 tointegralx -0 -> -0
+dqintx126 tointegralx 0.000 -> 0
+dqintx127 tointegralx 0.00 -> 0
+dqintx128 tointegralx 0.0 -> 0
+dqintx129 tointegralx 0 -> 0
+dqintx130 tointegralx 0E-3 -> 0
+dqintx131 tointegralx 0E-2 -> 0
+dqintx132 tointegralx 0E-1 -> 0
+dqintx133 tointegralx 0E-0 -> 0
+dqintx134 tointegralx 0E+1 -> 0E+1
+dqintx135 tointegralx 0E+2 -> 0E+2
+dqintx136 tointegralx 0E+3 -> 0E+3
+dqintx137 tointegralx 0E+4 -> 0E+4
+dqintx138 tointegralx 0E+5 -> 0E+5
+dqintx139 tointegralx -0.000 -> -0
+dqintx140 tointegralx -0.00 -> -0
+dqintx141 tointegralx -0.0 -> -0
+dqintx142 tointegralx -0 -> -0
+dqintx143 tointegralx -0E-3 -> -0
+dqintx144 tointegralx -0E-2 -> -0
+dqintx145 tointegralx -0E-1 -> -0
+dqintx146 tointegralx -0E-0 -> -0
+dqintx147 tointegralx -0E+1 -> -0E+1
+dqintx148 tointegralx -0E+2 -> -0E+2
+dqintx149 tointegralx -0E+3 -> -0E+3
+dqintx150 tointegralx -0E+4 -> -0E+4
+dqintx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+dqintx152 tointegralx NaN808 -> NaN808
+dqintx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+dqintx154 tointegralx -NaN808 -> -NaN808
+dqintx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+dqintx156 tointegralx -NaN -> -NaN
+dqintx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+dqintx200 tointegralx 2.1 -> 2 Inexact Rounded
+dqintx201 tointegralx 100 -> 100
+dqintx202 tointegralx 100.0 -> 100 Rounded
+dqintx203 tointegralx 101.5 -> 102 Inexact Rounded
+dqintx204 tointegralx -101.5 -> -102 Inexact Rounded
+dqintx205 tointegralx 10E+5 -> 1.0E+6
+dqintx206 tointegralx 7.89E+77 -> 7.89E+77
+dqintx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+dqintx210 tointegralx 55.5 -> 56 Inexact Rounded
+dqintx211 tointegralx 56.5 -> 56 Inexact Rounded
+dqintx212 tointegralx 57.5 -> 58 Inexact Rounded
+dqintx213 tointegralx -55.5 -> -56 Inexact Rounded
+dqintx214 tointegralx -56.5 -> -56 Inexact Rounded
+dqintx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+dqintx220 tointegralx 55.5 -> 56 Inexact Rounded
+dqintx221 tointegralx 56.5 -> 57 Inexact Rounded
+dqintx222 tointegralx 57.5 -> 58 Inexact Rounded
+dqintx223 tointegralx -55.5 -> -56 Inexact Rounded
+dqintx224 tointegralx -56.5 -> -57 Inexact Rounded
+dqintx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+dqintx230 tointegralx 55.5 -> 55 Inexact Rounded
+dqintx231 tointegralx 56.5 -> 56 Inexact Rounded
+dqintx232 tointegralx 57.5 -> 57 Inexact Rounded
+dqintx233 tointegralx -55.5 -> -55 Inexact Rounded
+dqintx234 tointegralx -56.5 -> -56 Inexact Rounded
+dqintx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+dqintx240 tointegralx 55.3 -> 56 Inexact Rounded
+dqintx241 tointegralx 56.3 -> 57 Inexact Rounded
+dqintx242 tointegralx 57.3 -> 58 Inexact Rounded
+dqintx243 tointegralx -55.3 -> -56 Inexact Rounded
+dqintx244 tointegralx -56.3 -> -57 Inexact Rounded
+dqintx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+dqintx250 tointegralx 55.7 -> 55 Inexact Rounded
+dqintx251 tointegralx 56.7 -> 56 Inexact Rounded
+dqintx252 tointegralx 57.7 -> 57 Inexact Rounded
+dqintx253 tointegralx -55.7 -> -55 Inexact Rounded
+dqintx254 tointegralx -56.7 -> -56 Inexact Rounded
+dqintx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+dqintx260 tointegralx 55.3 -> 56 Inexact Rounded
+dqintx261 tointegralx 56.3 -> 57 Inexact Rounded
+dqintx262 tointegralx 57.3 -> 58 Inexact Rounded
+dqintx263 tointegralx -55.3 -> -55 Inexact Rounded
+dqintx264 tointegralx -56.3 -> -56 Inexact Rounded
+dqintx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+dqintx270 tointegralx 55.7 -> 55 Inexact Rounded
+dqintx271 tointegralx 56.7 -> 56 Inexact Rounded
+dqintx272 tointegralx 57.7 -> 57 Inexact Rounded
+dqintx273 tointegralx -55.7 -> -56 Inexact Rounded
+dqintx274 tointegralx -56.7 -> -57 Inexact Rounded
+dqintx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+dqintx300 tointegralx -2147483646 -> -2147483646
+dqintx301 tointegralx -2147483647 -> -2147483647
+dqintx302 tointegralx -2147483648 -> -2147483648
+dqintx303 tointegralx -2147483649 -> -2147483649
+dqintx304 tointegralx 2147483646 -> 2147483646
+dqintx305 tointegralx 2147483647 -> 2147483647
+dqintx306 tointegralx 2147483648 -> 2147483648
+dqintx307 tointegralx 2147483649 -> 2147483649
+dqintx308 tointegralx 4294967294 -> 4294967294
+dqintx309 tointegralx 4294967295 -> 4294967295
+dqintx310 tointegralx 4294967296 -> 4294967296
+dqintx311 tointegralx 4294967297 -> 4294967297
+
diff --git a/Lib/test/decimaltestdata/dqXor.decTest b/Lib/test/decimaltestdata/dqXor.decTest
index 2216e9ebf8e..fbb32e441bc 100644
--- a/Lib/test/decimaltestdata/dqXor.decTest
+++ b/Lib/test/decimaltestdata/dqXor.decTest
@@ -1,410 +1,410 @@
-------------------------------------------------------------------------
--- dqXor.decTest -- digitwise logical XOR for decQuads --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-clamp: 1
-precision: 34
-maxExponent: 6144
-minExponent: -6143
-rounding: half_even
-
--- Sanity check (truth table)
-dqxor001 xor 0 0 -> 0
-dqxor002 xor 0 1 -> 1
-dqxor003 xor 1 0 -> 1
-dqxor004 xor 1 1 -> 0
-dqxor005 xor 1100 1010 -> 110
--- and at msd and msd-1
-dqxor006 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqxor007 xor 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqxor008 xor 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
-dqxor009 xor 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
-dqxor010 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
-dqxor011 xor 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
-dqxor012 xor 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
-dqxor013 xor 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 0
-
--- Various lengths
--- 1234567890123456789012345678901234
-dqxor601 xor 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqxor602 xor 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000000
-dqxor603 xor 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000000
-dqxor604 xor 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000
-dqxor605 xor 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000
-dqxor606 xor 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000
-dqxor607 xor 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000
-dqxor608 xor 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000
-dqxor609 xor 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000
-dqxor610 xor 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000
-dqxor611 xor 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000
-dqxor612 xor 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000
-dqxor613 xor 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000
-dqxor614 xor 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000
-dqxor615 xor 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000
-dqxor616 xor 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000
-dqxor617 xor 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 100000000000000000
-dqxor618 xor 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 10000000000000000
-dqxor619 xor 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1000000000000000
-dqxor620 xor 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 100000000000000
-dqxor621 xor 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 10000000000000
-dqxor622 xor 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1000000000000
-dqxor623 xor 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 100000000000
-dqxor624 xor 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 10000000000
-dqxor625 xor 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1000000000
-dqxor626 xor 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 100000000
-dqxor627 xor 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 10000000
-dqxor628 xor 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1000000
-dqxor629 xor 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 100000
-dqxor630 xor 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 10000
-dqxor631 xor 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1000
-dqxor632 xor 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 100
-dqxor633 xor 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 10
-dqxor634 xor 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1
-
-dqxor641 xor 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
-dqxor642 xor 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 100000000000000000000000000000000
-dqxor643 xor 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 10000000000000000000000000000000
-dqxor644 xor 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1000000000000000000000000000000
-dqxor645 xor 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 100000000000000000000000000000
-dqxor646 xor 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 10000000000000000000000000000
-dqxor647 xor 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1000000000000000000000000000
-dqxor648 xor 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 100000000000000000000000000
-dqxor649 xor 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 10000000000000000000000000
-dqxor650 xor 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1000000000000000000000000
-dqxor651 xor 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 100000000000000000000000
-dqxor652 xor 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 10000000000000000000000
-dqxor653 xor 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1000000000000000000000
-dqxor654 xor 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 100000000000000000000
-dqxor655 xor 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 10000000000000000000
-dqxor656 xor 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1000000000000000000
-dqxor657 xor 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 100000000000000000
-dqxor658 xor 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 10000000000000000
-dqxor659 xor 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1000000000000000
-dqxor660 xor 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 100000000000000
-dqxor661 xor 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 10000000000000
-dqxor662 xor 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1000000000000
-dqxor663 xor 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 100000000000
-dqxor664 xor 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 10000000000
-dqxor665 xor 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1000000000
-dqxor666 xor 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 100000000
-dqxor667 xor 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 10000000
-dqxor668 xor 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1000000
-dqxor669 xor 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 100000
-dqxor670 xor 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 10000
-dqxor671 xor 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1000
-dqxor672 xor 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 100
-dqxor673 xor 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 10
-dqxor674 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
-dqxor675 xor 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1000000000000000000000000000000001
-dqxor676 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
-
-
-dqxor021 xor 1111111110000000 1111111110000000 -> 0
-dqxor022 xor 111111110000000 111111110000000 -> 0
-dqxor023 xor 11111110000000 11111110000000 -> 0
-dqxor024 xor 1111110000000 1111110000000 -> 0
-dqxor025 xor 111110000000 111110000000 -> 0
-dqxor026 xor 11110000000 11110000000 -> 0
-dqxor027 xor 1110000000 1110000000 -> 0
-dqxor028 xor 110000000 110000000 -> 0
-dqxor029 xor 10000000 10000000 -> 0
-dqxor030 xor 1000000 1000000 -> 0
-dqxor031 xor 100000 100000 -> 0
-dqxor032 xor 10000 10000 -> 0
-dqxor033 xor 1000 1000 -> 0
-dqxor034 xor 100 100 -> 0
-dqxor035 xor 10 10 -> 0
-dqxor036 xor 1 1 -> 0
-
-dqxor040 xor 111111111 111111111111 -> 111000000000
-dqxor041 xor 11111111 111111111111 -> 111100000000
-dqxor042 xor 11111111 111111111 -> 100000000
-dqxor043 xor 1111111 100000010 -> 101111101
-dqxor044 xor 111111 100000100 -> 100111011
-dqxor045 xor 11111 100001000 -> 100010111
-dqxor046 xor 1111 100010000 -> 100011111
-dqxor047 xor 111 100100000 -> 100100111
-dqxor048 xor 11 101000000 -> 101000011
-dqxor049 xor 1 110000000 -> 110000001
-
-dqxor050 xor 1111111111 1 -> 1111111110
-dqxor051 xor 111111111 1 -> 111111110
-dqxor052 xor 11111111 1 -> 11111110
-dqxor053 xor 1111111 1 -> 1111110
-dqxor054 xor 111111 1 -> 111110
-dqxor055 xor 11111 1 -> 11110
-dqxor056 xor 1111 1 -> 1110
-dqxor057 xor 111 1 -> 110
-dqxor058 xor 11 1 -> 10
-dqxor059 xor 1 1 -> 0
-
-dqxor060 xor 1111111111 0 -> 1111111111
-dqxor061 xor 111111111 0 -> 111111111
-dqxor062 xor 11111111 0 -> 11111111
-dqxor063 xor 1111111 0 -> 1111111
-dqxor064 xor 111111 0 -> 111111
-dqxor065 xor 11111 0 -> 11111
-dqxor066 xor 1111 0 -> 1111
-dqxor067 xor 111 0 -> 111
-dqxor068 xor 11 0 -> 11
-dqxor069 xor 1 0 -> 1
-
-dqxor070 xor 1 1111111111 -> 1111111110
-dqxor071 xor 1 111111111 -> 111111110
-dqxor072 xor 1 11111111 -> 11111110
-dqxor073 xor 1 1111111 -> 1111110
-dqxor074 xor 1 111111 -> 111110
-dqxor075 xor 1 11111 -> 11110
-dqxor076 xor 1 1111 -> 1110
-dqxor077 xor 1 111 -> 110
-dqxor078 xor 1 11 -> 10
-dqxor079 xor 1 1 -> 0
-
-dqxor080 xor 0 1111111111 -> 1111111111
-dqxor081 xor 0 111111111 -> 111111111
-dqxor082 xor 0 11111111 -> 11111111
-dqxor083 xor 0 1111111 -> 1111111
-dqxor084 xor 0 111111 -> 111111
-dqxor085 xor 0 11111 -> 11111
-dqxor086 xor 0 1111 -> 1111
-dqxor087 xor 0 111 -> 111
-dqxor088 xor 0 11 -> 11
-dqxor089 xor 0 1 -> 1
-
-dqxor090 xor 011111111 111101111 -> 100010000
-dqxor091 xor 101111111 111101111 -> 10010000
-dqxor092 xor 110111111 111101111 -> 1010000
-dqxor093 xor 111011111 111101111 -> 110000
-dqxor094 xor 111101111 111101111 -> 0
-dqxor095 xor 111110111 111101111 -> 11000
-dqxor096 xor 111111011 111101111 -> 10100
-dqxor097 xor 111111101 111101111 -> 10010
-dqxor098 xor 111111110 111101111 -> 10001
-
-dqxor100 xor 111101111 011111111 -> 100010000
-dqxor101 xor 111101111 101111111 -> 10010000
-dqxor102 xor 111101111 110111111 -> 1010000
-dqxor103 xor 111101111 111011111 -> 110000
-dqxor104 xor 111101111 111101111 -> 0
-dqxor105 xor 111101111 111110111 -> 11000
-dqxor106 xor 111101111 111111011 -> 10100
-dqxor107 xor 111101111 111111101 -> 10010
-dqxor108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-dqxor220 xor 111111112 111111111 -> NaN Invalid_operation
-dqxor221 xor 333333333 333333333 -> NaN Invalid_operation
-dqxor222 xor 555555555 555555555 -> NaN Invalid_operation
-dqxor223 xor 777777777 777777777 -> NaN Invalid_operation
-dqxor224 xor 999999999 999999999 -> NaN Invalid_operation
-dqxor225 xor 222222222 999999999 -> NaN Invalid_operation
-dqxor226 xor 444444444 999999999 -> NaN Invalid_operation
-dqxor227 xor 666666666 999999999 -> NaN Invalid_operation
-dqxor228 xor 888888888 999999999 -> NaN Invalid_operation
-dqxor229 xor 999999999 222222222 -> NaN Invalid_operation
-dqxor230 xor 999999999 444444444 -> NaN Invalid_operation
-dqxor231 xor 999999999 666666666 -> NaN Invalid_operation
-dqxor232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-dqxor240 xor 567468689 -934981942 -> NaN Invalid_operation
-dqxor241 xor 567367689 934981942 -> NaN Invalid_operation
-dqxor242 xor -631917772 -706014634 -> NaN Invalid_operation
-dqxor243 xor -756253257 138579234 -> NaN Invalid_operation
-dqxor244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-dqxor250 xor 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor251 xor 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor252 xor 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor253 xor 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor254 xor 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor255 xor 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor256 xor 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor257 xor 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor258 xor 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor259 xor 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor260 xor 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor261 xor 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor262 xor 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor263 xor 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor264 xor 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
-dqxor265 xor 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
--- test MSD-1
-dqxor270 xor 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
-dqxor271 xor 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
-dqxor272 xor 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
-dqxor273 xor 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
-dqxor274 xor 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
-dqxor275 xor 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
-dqxor276 xor 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
-dqxor277 xor 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
--- test LSD
-dqxor280 xor 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
-dqxor281 xor 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
-dqxor282 xor 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
-dqxor283 xor 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
-dqxor284 xor 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
-dqxor285 xor 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
-dqxor286 xor 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
-dqxor287 xor 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
--- test Middie
-dqxor288 xor 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
-dqxor289 xor 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
-dqxor290 xor 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
-dqxor291 xor 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
-dqxor292 xor 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
-dqxor293 xor 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
-dqxor294 xor 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
-dqxor295 xor 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
--- signs
-dqxor296 xor -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
-dqxor297 xor -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
-dqxor298 xor 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
-dqxor299 xor 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001001001001001001000010000100
-
--- Nmax, Nmin, Ntiny-like
-dqxor331 xor 2 9.99999999E+999 -> NaN Invalid_operation
-dqxor332 xor 3 1E-999 -> NaN Invalid_operation
-dqxor333 xor 4 1.00000000E-2821 -> NaN Invalid_operation
-dqxor334 xor 5 1E-900 -> NaN Invalid_operation
-dqxor335 xor 6 -1E-900 -> NaN Invalid_operation
-dqxor336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
-dqxor337 xor 8 -1E-999 -> NaN Invalid_operation
-dqxor338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
-dqxor341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
-dqxor342 xor 1E-999 01 -> NaN Invalid_operation
-dqxor343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
-dqxor344 xor 1E-908 18 -> NaN Invalid_operation
-dqxor345 xor -1E-907 -10 -> NaN Invalid_operation
-dqxor346 xor -1.00000000E-999 18 -> NaN Invalid_operation
-dqxor347 xor -1E-999 10 -> NaN Invalid_operation
-dqxor348 xor -9.99999999E+2991 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-dqxor361 xor 1.0 1 -> NaN Invalid_operation
-dqxor362 xor 1E+1 1 -> NaN Invalid_operation
-dqxor363 xor 0.0 1 -> NaN Invalid_operation
-dqxor364 xor 0E+1 1 -> NaN Invalid_operation
-dqxor365 xor 9.9 1 -> NaN Invalid_operation
-dqxor366 xor 9E+1 1 -> NaN Invalid_operation
-dqxor371 xor 0 1.0 -> NaN Invalid_operation
-dqxor372 xor 0 1E+1 -> NaN Invalid_operation
-dqxor373 xor 0 0.0 -> NaN Invalid_operation
-dqxor374 xor 0 0E+1 -> NaN Invalid_operation
-dqxor375 xor 0 9.9 -> NaN Invalid_operation
-dqxor376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-dqxor780 xor -Inf -Inf -> NaN Invalid_operation
-dqxor781 xor -Inf -1000 -> NaN Invalid_operation
-dqxor782 xor -Inf -1 -> NaN Invalid_operation
-dqxor783 xor -Inf -0 -> NaN Invalid_operation
-dqxor784 xor -Inf 0 -> NaN Invalid_operation
-dqxor785 xor -Inf 1 -> NaN Invalid_operation
-dqxor786 xor -Inf 1000 -> NaN Invalid_operation
-dqxor787 xor -1000 -Inf -> NaN Invalid_operation
-dqxor788 xor -Inf -Inf -> NaN Invalid_operation
-dqxor789 xor -1 -Inf -> NaN Invalid_operation
-dqxor790 xor -0 -Inf -> NaN Invalid_operation
-dqxor791 xor 0 -Inf -> NaN Invalid_operation
-dqxor792 xor 1 -Inf -> NaN Invalid_operation
-dqxor793 xor 1000 -Inf -> NaN Invalid_operation
-dqxor794 xor Inf -Inf -> NaN Invalid_operation
-
-dqxor800 xor Inf -Inf -> NaN Invalid_operation
-dqxor801 xor Inf -1000 -> NaN Invalid_operation
-dqxor802 xor Inf -1 -> NaN Invalid_operation
-dqxor803 xor Inf -0 -> NaN Invalid_operation
-dqxor804 xor Inf 0 -> NaN Invalid_operation
-dqxor805 xor Inf 1 -> NaN Invalid_operation
-dqxor806 xor Inf 1000 -> NaN Invalid_operation
-dqxor807 xor Inf Inf -> NaN Invalid_operation
-dqxor808 xor -1000 Inf -> NaN Invalid_operation
-dqxor809 xor -Inf Inf -> NaN Invalid_operation
-dqxor810 xor -1 Inf -> NaN Invalid_operation
-dqxor811 xor -0 Inf -> NaN Invalid_operation
-dqxor812 xor 0 Inf -> NaN Invalid_operation
-dqxor813 xor 1 Inf -> NaN Invalid_operation
-dqxor814 xor 1000 Inf -> NaN Invalid_operation
-dqxor815 xor Inf Inf -> NaN Invalid_operation
-
-dqxor821 xor NaN -Inf -> NaN Invalid_operation
-dqxor822 xor NaN -1000 -> NaN Invalid_operation
-dqxor823 xor NaN -1 -> NaN Invalid_operation
-dqxor824 xor NaN -0 -> NaN Invalid_operation
-dqxor825 xor NaN 0 -> NaN Invalid_operation
-dqxor826 xor NaN 1 -> NaN Invalid_operation
-dqxor827 xor NaN 1000 -> NaN Invalid_operation
-dqxor828 xor NaN Inf -> NaN Invalid_operation
-dqxor829 xor NaN NaN -> NaN Invalid_operation
-dqxor830 xor -Inf NaN -> NaN Invalid_operation
-dqxor831 xor -1000 NaN -> NaN Invalid_operation
-dqxor832 xor -1 NaN -> NaN Invalid_operation
-dqxor833 xor -0 NaN -> NaN Invalid_operation
-dqxor834 xor 0 NaN -> NaN Invalid_operation
-dqxor835 xor 1 NaN -> NaN Invalid_operation
-dqxor836 xor 1000 NaN -> NaN Invalid_operation
-dqxor837 xor Inf NaN -> NaN Invalid_operation
-
-dqxor841 xor sNaN -Inf -> NaN Invalid_operation
-dqxor842 xor sNaN -1000 -> NaN Invalid_operation
-dqxor843 xor sNaN -1 -> NaN Invalid_operation
-dqxor844 xor sNaN -0 -> NaN Invalid_operation
-dqxor845 xor sNaN 0 -> NaN Invalid_operation
-dqxor846 xor sNaN 1 -> NaN Invalid_operation
-dqxor847 xor sNaN 1000 -> NaN Invalid_operation
-dqxor848 xor sNaN NaN -> NaN Invalid_operation
-dqxor849 xor sNaN sNaN -> NaN Invalid_operation
-dqxor850 xor NaN sNaN -> NaN Invalid_operation
-dqxor851 xor -Inf sNaN -> NaN Invalid_operation
-dqxor852 xor -1000 sNaN -> NaN Invalid_operation
-dqxor853 xor -1 sNaN -> NaN Invalid_operation
-dqxor854 xor -0 sNaN -> NaN Invalid_operation
-dqxor855 xor 0 sNaN -> NaN Invalid_operation
-dqxor856 xor 1 sNaN -> NaN Invalid_operation
-dqxor857 xor 1000 sNaN -> NaN Invalid_operation
-dqxor858 xor Inf sNaN -> NaN Invalid_operation
-dqxor859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-dqxor861 xor NaN1 -Inf -> NaN Invalid_operation
-dqxor862 xor +NaN2 -1000 -> NaN Invalid_operation
-dqxor863 xor NaN3 1000 -> NaN Invalid_operation
-dqxor864 xor NaN4 Inf -> NaN Invalid_operation
-dqxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
-dqxor866 xor -Inf NaN7 -> NaN Invalid_operation
-dqxor867 xor -1000 NaN8 -> NaN Invalid_operation
-dqxor868 xor 1000 NaN9 -> NaN Invalid_operation
-dqxor869 xor Inf +NaN10 -> NaN Invalid_operation
-dqxor871 xor sNaN11 -Inf -> NaN Invalid_operation
-dqxor872 xor sNaN12 -1000 -> NaN Invalid_operation
-dqxor873 xor sNaN13 1000 -> NaN Invalid_operation
-dqxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
-dqxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-dqxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
-dqxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
-dqxor878 xor -1000 sNaN21 -> NaN Invalid_operation
-dqxor879 xor 1000 sNaN22 -> NaN Invalid_operation
-dqxor880 xor Inf sNaN23 -> NaN Invalid_operation
-dqxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-dqxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
-dqxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-dqxor884 xor 1000 -NaN30 -> NaN Invalid_operation
-dqxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- dqXor.decTest -- digitwise logical XOR for decQuads --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+clamp: 1
+precision: 34
+maxExponent: 6144
+minExponent: -6143
+rounding: half_even
+
+-- Sanity check (truth table)
+dqxor001 xor 0 0 -> 0
+dqxor002 xor 0 1 -> 1
+dqxor003 xor 1 0 -> 1
+dqxor004 xor 1 1 -> 0
+dqxor005 xor 1100 1010 -> 110
+-- and at msd and msd-1
+dqxor006 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqxor007 xor 0000000000000000000000000000000000 1000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqxor008 xor 1000000000000000000000000000000000 0000000000000000000000000000000000 -> 1000000000000000000000000000000000
+dqxor009 xor 1000000000000000000000000000000000 1000000000000000000000000000000000 -> 0
+dqxor010 xor 0000000000000000000000000000000000 0000000000000000000000000000000000 -> 0
+dqxor011 xor 0000000000000000000000000000000000 0100000000000000000000000000000000 -> 100000000000000000000000000000000
+dqxor012 xor 0100000000000000000000000000000000 0000000000000000000000000000000000 -> 100000000000000000000000000000000
+dqxor013 xor 0100000000000000000000000000000000 0100000000000000000000000000000000 -> 0
+
+-- Various lengths
+-- 1234567890123456789012345678901234
+dqxor601 xor 0111111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqxor602 xor 1011111111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000000
+dqxor603 xor 1101111111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000000
+dqxor604 xor 1110111111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000000
+dqxor605 xor 1111011111111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000000
+dqxor606 xor 1111101111111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000000
+dqxor607 xor 1111110111111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000000
+dqxor608 xor 1111111011111111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000000
+dqxor609 xor 1111111101111111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000000
+dqxor610 xor 1111111110111111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000000
+dqxor611 xor 1111111111011111111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000000
+dqxor612 xor 1111111111101111111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000000
+dqxor613 xor 1111111111110111111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000000
+dqxor614 xor 1111111111111011111111111111111111 1111111111111111111111111111111111 -> 100000000000000000000
+dqxor615 xor 1111111111111101111111111111111111 1111111111111111111111111111111111 -> 10000000000000000000
+dqxor616 xor 1111111111111110111111111111111111 1111111111111111111111111111111111 -> 1000000000000000000
+dqxor617 xor 1111111111111111011111111111111111 1111111111111111111111111111111111 -> 100000000000000000
+dqxor618 xor 1111111111111111101111111111111111 1111111111111111111111111111111111 -> 10000000000000000
+dqxor619 xor 1111111111111111110111111111111111 1111111111111111111111111111111111 -> 1000000000000000
+dqxor620 xor 1111111111111111111011111111111111 1111111111111111111111111111111111 -> 100000000000000
+dqxor621 xor 1111111111111111111101111111111111 1111111111111111111111111111111111 -> 10000000000000
+dqxor622 xor 1111111111111111111110111111111111 1111111111111111111111111111111111 -> 1000000000000
+dqxor623 xor 1111111111111111111111011111111111 1111111111111111111111111111111111 -> 100000000000
+dqxor624 xor 1111111111111111111111101111111111 1111111111111111111111111111111111 -> 10000000000
+dqxor625 xor 1111111111111111111111110111111111 1111111111111111111111111111111111 -> 1000000000
+dqxor626 xor 1111111111111111111111111011111111 1111111111111111111111111111111111 -> 100000000
+dqxor627 xor 1111111111111111111111111101111111 1111111111111111111111111111111111 -> 10000000
+dqxor628 xor 1111111111111111111111111110111111 1111111111111111111111111111111111 -> 1000000
+dqxor629 xor 1111111111111111111111111111011111 1111111111111111111111111111111111 -> 100000
+dqxor630 xor 1111111111111111111111111111101111 1111111111111111111111111111111111 -> 10000
+dqxor631 xor 1111111111111111111111111111110111 1111111111111111111111111111111111 -> 1000
+dqxor632 xor 1111111111111111111111111111111011 1111111111111111111111111111111111 -> 100
+dqxor633 xor 1111111111111111111111111111111101 1111111111111111111111111111111111 -> 10
+dqxor634 xor 1111111111111111111111111111111110 1111111111111111111111111111111111 -> 1
+
+dqxor641 xor 1111111111111111111111111111111111 0111111111111111111111111111111111 -> 1000000000000000000000000000000000
+dqxor642 xor 1111111111111111111111111111111111 1011111111111111111111111111111111 -> 100000000000000000000000000000000
+dqxor643 xor 1111111111111111111111111111111111 1101111111111111111111111111111111 -> 10000000000000000000000000000000
+dqxor644 xor 1111111111111111111111111111111111 1110111111111111111111111111111111 -> 1000000000000000000000000000000
+dqxor645 xor 1111111111111111111111111111111111 1111011111111111111111111111111111 -> 100000000000000000000000000000
+dqxor646 xor 1111111111111111111111111111111111 1111101111111111111111111111111111 -> 10000000000000000000000000000
+dqxor647 xor 1111111111111111111111111111111111 1111110111111111111111111111111111 -> 1000000000000000000000000000
+dqxor648 xor 1111111111111111111111111111111111 1111111011111111111111111111111111 -> 100000000000000000000000000
+dqxor649 xor 1111111111111111111111111111111111 1111111101111111111111111111111111 -> 10000000000000000000000000
+dqxor650 xor 1111111111111111111111111111111111 1111111110111111111111111111111111 -> 1000000000000000000000000
+dqxor651 xor 1111111111111111111111111111111111 1111111111011111111111111111111111 -> 100000000000000000000000
+dqxor652 xor 1111111111111111111111111111111111 1111111111101111111111111111111111 -> 10000000000000000000000
+dqxor653 xor 1111111111111111111111111111111111 1111111111110111111111111111111111 -> 1000000000000000000000
+dqxor654 xor 1111111111111111111111111111111111 1111111111111011111111111111111111 -> 100000000000000000000
+dqxor655 xor 1111111111111111111111111111111111 1111111111111101111111111111111111 -> 10000000000000000000
+dqxor656 xor 1111111111111111111111111111111111 1111111111111110111111111111111111 -> 1000000000000000000
+dqxor657 xor 1111111111111111111111111111111111 1111111111111111011111111111111111 -> 100000000000000000
+dqxor658 xor 1111111111111111111111111111111111 1111111111111111101111111111111111 -> 10000000000000000
+dqxor659 xor 1111111111111111111111111111111111 1111111111111111110111111111111111 -> 1000000000000000
+dqxor660 xor 1111111111111111111111111111111111 1111111111111111111011111111111111 -> 100000000000000
+dqxor661 xor 1111111111111111111111111111111111 1111111111111111111101111111111111 -> 10000000000000
+dqxor662 xor 1111111111111111111111111111111111 1111111111111111111110111111111111 -> 1000000000000
+dqxor663 xor 1111111111111111111111111111111111 1111111111111111111111011111111111 -> 100000000000
+dqxor664 xor 1111111111111111111111111111111111 1111111111111111111111101111111111 -> 10000000000
+dqxor665 xor 1111111111111111111111111111111111 1111111111111111111111110111111111 -> 1000000000
+dqxor666 xor 1111111111111111111111111111111111 1111111111111111111111111011111111 -> 100000000
+dqxor667 xor 1111111111111111111111111111111111 1111111111111111111111111101111111 -> 10000000
+dqxor668 xor 1111111111111111111111111111111111 1111111111111111111111111110111111 -> 1000000
+dqxor669 xor 1111111111111111111111111111111111 1111111111111111111111111111011111 -> 100000
+dqxor670 xor 1111111111111111111111111111111111 1111111111111111111111111111101111 -> 10000
+dqxor671 xor 1111111111111111111111111111111111 1111111111111111111111111111110111 -> 1000
+dqxor672 xor 1111111111111111111111111111111111 1111111111111111111111111111111011 -> 100
+dqxor673 xor 1111111111111111111111111111111111 1111111111111111111111111111111101 -> 10
+dqxor674 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
+dqxor675 xor 0111111111111111111111111111111111 1111111111111111111111111111111110 -> 1000000000000000000000000000000001
+dqxor676 xor 1111111111111111111111111111111111 1111111111111111111111111111111110 -> 1
+
+
+dqxor021 xor 1111111110000000 1111111110000000 -> 0
+dqxor022 xor 111111110000000 111111110000000 -> 0
+dqxor023 xor 11111110000000 11111110000000 -> 0
+dqxor024 xor 1111110000000 1111110000000 -> 0
+dqxor025 xor 111110000000 111110000000 -> 0
+dqxor026 xor 11110000000 11110000000 -> 0
+dqxor027 xor 1110000000 1110000000 -> 0
+dqxor028 xor 110000000 110000000 -> 0
+dqxor029 xor 10000000 10000000 -> 0
+dqxor030 xor 1000000 1000000 -> 0
+dqxor031 xor 100000 100000 -> 0
+dqxor032 xor 10000 10000 -> 0
+dqxor033 xor 1000 1000 -> 0
+dqxor034 xor 100 100 -> 0
+dqxor035 xor 10 10 -> 0
+dqxor036 xor 1 1 -> 0
+
+dqxor040 xor 111111111 111111111111 -> 111000000000
+dqxor041 xor 11111111 111111111111 -> 111100000000
+dqxor042 xor 11111111 111111111 -> 100000000
+dqxor043 xor 1111111 100000010 -> 101111101
+dqxor044 xor 111111 100000100 -> 100111011
+dqxor045 xor 11111 100001000 -> 100010111
+dqxor046 xor 1111 100010000 -> 100011111
+dqxor047 xor 111 100100000 -> 100100111
+dqxor048 xor 11 101000000 -> 101000011
+dqxor049 xor 1 110000000 -> 110000001
+
+dqxor050 xor 1111111111 1 -> 1111111110
+dqxor051 xor 111111111 1 -> 111111110
+dqxor052 xor 11111111 1 -> 11111110
+dqxor053 xor 1111111 1 -> 1111110
+dqxor054 xor 111111 1 -> 111110
+dqxor055 xor 11111 1 -> 11110
+dqxor056 xor 1111 1 -> 1110
+dqxor057 xor 111 1 -> 110
+dqxor058 xor 11 1 -> 10
+dqxor059 xor 1 1 -> 0
+
+dqxor060 xor 1111111111 0 -> 1111111111
+dqxor061 xor 111111111 0 -> 111111111
+dqxor062 xor 11111111 0 -> 11111111
+dqxor063 xor 1111111 0 -> 1111111
+dqxor064 xor 111111 0 -> 111111
+dqxor065 xor 11111 0 -> 11111
+dqxor066 xor 1111 0 -> 1111
+dqxor067 xor 111 0 -> 111
+dqxor068 xor 11 0 -> 11
+dqxor069 xor 1 0 -> 1
+
+dqxor070 xor 1 1111111111 -> 1111111110
+dqxor071 xor 1 111111111 -> 111111110
+dqxor072 xor 1 11111111 -> 11111110
+dqxor073 xor 1 1111111 -> 1111110
+dqxor074 xor 1 111111 -> 111110
+dqxor075 xor 1 11111 -> 11110
+dqxor076 xor 1 1111 -> 1110
+dqxor077 xor 1 111 -> 110
+dqxor078 xor 1 11 -> 10
+dqxor079 xor 1 1 -> 0
+
+dqxor080 xor 0 1111111111 -> 1111111111
+dqxor081 xor 0 111111111 -> 111111111
+dqxor082 xor 0 11111111 -> 11111111
+dqxor083 xor 0 1111111 -> 1111111
+dqxor084 xor 0 111111 -> 111111
+dqxor085 xor 0 11111 -> 11111
+dqxor086 xor 0 1111 -> 1111
+dqxor087 xor 0 111 -> 111
+dqxor088 xor 0 11 -> 11
+dqxor089 xor 0 1 -> 1
+
+dqxor090 xor 011111111 111101111 -> 100010000
+dqxor091 xor 101111111 111101111 -> 10010000
+dqxor092 xor 110111111 111101111 -> 1010000
+dqxor093 xor 111011111 111101111 -> 110000
+dqxor094 xor 111101111 111101111 -> 0
+dqxor095 xor 111110111 111101111 -> 11000
+dqxor096 xor 111111011 111101111 -> 10100
+dqxor097 xor 111111101 111101111 -> 10010
+dqxor098 xor 111111110 111101111 -> 10001
+
+dqxor100 xor 111101111 011111111 -> 100010000
+dqxor101 xor 111101111 101111111 -> 10010000
+dqxor102 xor 111101111 110111111 -> 1010000
+dqxor103 xor 111101111 111011111 -> 110000
+dqxor104 xor 111101111 111101111 -> 0
+dqxor105 xor 111101111 111110111 -> 11000
+dqxor106 xor 111101111 111111011 -> 10100
+dqxor107 xor 111101111 111111101 -> 10010
+dqxor108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+dqxor220 xor 111111112 111111111 -> NaN Invalid_operation
+dqxor221 xor 333333333 333333333 -> NaN Invalid_operation
+dqxor222 xor 555555555 555555555 -> NaN Invalid_operation
+dqxor223 xor 777777777 777777777 -> NaN Invalid_operation
+dqxor224 xor 999999999 999999999 -> NaN Invalid_operation
+dqxor225 xor 222222222 999999999 -> NaN Invalid_operation
+dqxor226 xor 444444444 999999999 -> NaN Invalid_operation
+dqxor227 xor 666666666 999999999 -> NaN Invalid_operation
+dqxor228 xor 888888888 999999999 -> NaN Invalid_operation
+dqxor229 xor 999999999 222222222 -> NaN Invalid_operation
+dqxor230 xor 999999999 444444444 -> NaN Invalid_operation
+dqxor231 xor 999999999 666666666 -> NaN Invalid_operation
+dqxor232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+dqxor240 xor 567468689 -934981942 -> NaN Invalid_operation
+dqxor241 xor 567367689 934981942 -> NaN Invalid_operation
+dqxor242 xor -631917772 -706014634 -> NaN Invalid_operation
+dqxor243 xor -756253257 138579234 -> NaN Invalid_operation
+dqxor244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+dqxor250 xor 2000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor251 xor 7000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor252 xor 8000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor253 xor 9000000111000111000111000000000000 1000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor254 xor 2000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor255 xor 7000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor256 xor 8000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor257 xor 9000000111000111000111000000000000 0000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor258 xor 1000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor259 xor 1000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor260 xor 1000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor261 xor 1000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor262 xor 0000000111000111000111000000000000 2000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor263 xor 0000000111000111000111000000000000 7000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor264 xor 0000000111000111000111000000000000 8000000111000111000111000000000000 -> NaN Invalid_operation
+dqxor265 xor 0000000111000111000111000000000000 9000000111000111000111000000000000 -> NaN Invalid_operation
+-- test MSD-1
+dqxor270 xor 0200000111000111000111001000000000 1000000111000111000111100000000010 -> NaN Invalid_operation
+dqxor271 xor 0700000111000111000111000100000000 1000000111000111000111010000000100 -> NaN Invalid_operation
+dqxor272 xor 0800000111000111000111000010000000 1000000111000111000111001000001000 -> NaN Invalid_operation
+dqxor273 xor 0900000111000111000111000001000000 1000000111000111000111000100010000 -> NaN Invalid_operation
+dqxor274 xor 1000000111000111000111000000100000 0200000111000111000111000010100000 -> NaN Invalid_operation
+dqxor275 xor 1000000111000111000111000000010000 0700000111000111000111000001000000 -> NaN Invalid_operation
+dqxor276 xor 1000000111000111000111000000001000 0800000111000111000111000010100000 -> NaN Invalid_operation
+dqxor277 xor 1000000111000111000111000000000100 0900000111000111000111000000010000 -> NaN Invalid_operation
+-- test LSD
+dqxor280 xor 0010000111000111000111000000000002 1000000111000111000111000100000001 -> NaN Invalid_operation
+dqxor281 xor 0001000111000111000111000000000007 1000000111000111000111001000000011 -> NaN Invalid_operation
+dqxor282 xor 0000000111000111000111100000000008 1000000111000111000111010000000001 -> NaN Invalid_operation
+dqxor283 xor 0000000111000111000111010000000009 1000000111000111000111100000000001 -> NaN Invalid_operation
+dqxor284 xor 1000000111000111000111001000000000 0001000111000111000111000000000002 -> NaN Invalid_operation
+dqxor285 xor 1000000111000111000111000100000000 0010000111000111000111000000000007 -> NaN Invalid_operation
+dqxor286 xor 1000000111000111000111000010000000 0100000111000111000111000000000008 -> NaN Invalid_operation
+dqxor287 xor 1000000111000111000111000001000000 1000000111000111000111000000000009 -> NaN Invalid_operation
+-- test Middie
+dqxor288 xor 0010000111000111000111000020000000 1000000111000111000111001000000000 -> NaN Invalid_operation
+dqxor289 xor 0001000111000111000111000070000001 1000000111000111000111000100000000 -> NaN Invalid_operation
+dqxor290 xor 0000000111000111000111100080000010 1000000111000111000111000010000000 -> NaN Invalid_operation
+dqxor291 xor 0000000111000111000111010090000100 1000000111000111000111000001000000 -> NaN Invalid_operation
+dqxor292 xor 1000000111000111000111001000001000 0000000111000111000111000020100000 -> NaN Invalid_operation
+dqxor293 xor 1000000111000111000111000100010000 0000000111000111000111000070010000 -> NaN Invalid_operation
+dqxor294 xor 1000000111000111000111000010100000 0000000111000111000111000080001000 -> NaN Invalid_operation
+dqxor295 xor 1000000111000111000111000001000000 0000000111000111000111000090000100 -> NaN Invalid_operation
+-- signs
+dqxor296 xor -1000000111000111000111000001000000 -0000001110001110001110010000000100 -> NaN Invalid_operation
+dqxor297 xor -1000000111000111000111000001000000 0000001110001110001110000010000100 -> NaN Invalid_operation
+dqxor298 xor 1000000111000111000111000001000000 -0000001110001110001110001000000100 -> NaN Invalid_operation
+dqxor299 xor 1000000111000111000111000001000000 0000001110001110001110000011000100 -> 1000001001001001001001000010000100
+
+-- Nmax, Nmin, Ntiny-like
+dqxor331 xor 2 9.99999999E+999 -> NaN Invalid_operation
+dqxor332 xor 3 1E-999 -> NaN Invalid_operation
+dqxor333 xor 4 1.00000000E-2821 -> NaN Invalid_operation
+dqxor334 xor 5 1E-900 -> NaN Invalid_operation
+dqxor335 xor 6 -1E-900 -> NaN Invalid_operation
+dqxor336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
+dqxor337 xor 8 -1E-999 -> NaN Invalid_operation
+dqxor338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
+dqxor341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
+dqxor342 xor 1E-999 01 -> NaN Invalid_operation
+dqxor343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
+dqxor344 xor 1E-908 18 -> NaN Invalid_operation
+dqxor345 xor -1E-907 -10 -> NaN Invalid_operation
+dqxor346 xor -1.00000000E-999 18 -> NaN Invalid_operation
+dqxor347 xor -1E-999 10 -> NaN Invalid_operation
+dqxor348 xor -9.99999999E+2991 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+dqxor361 xor 1.0 1 -> NaN Invalid_operation
+dqxor362 xor 1E+1 1 -> NaN Invalid_operation
+dqxor363 xor 0.0 1 -> NaN Invalid_operation
+dqxor364 xor 0E+1 1 -> NaN Invalid_operation
+dqxor365 xor 9.9 1 -> NaN Invalid_operation
+dqxor366 xor 9E+1 1 -> NaN Invalid_operation
+dqxor371 xor 0 1.0 -> NaN Invalid_operation
+dqxor372 xor 0 1E+1 -> NaN Invalid_operation
+dqxor373 xor 0 0.0 -> NaN Invalid_operation
+dqxor374 xor 0 0E+1 -> NaN Invalid_operation
+dqxor375 xor 0 9.9 -> NaN Invalid_operation
+dqxor376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+dqxor780 xor -Inf -Inf -> NaN Invalid_operation
+dqxor781 xor -Inf -1000 -> NaN Invalid_operation
+dqxor782 xor -Inf -1 -> NaN Invalid_operation
+dqxor783 xor -Inf -0 -> NaN Invalid_operation
+dqxor784 xor -Inf 0 -> NaN Invalid_operation
+dqxor785 xor -Inf 1 -> NaN Invalid_operation
+dqxor786 xor -Inf 1000 -> NaN Invalid_operation
+dqxor787 xor -1000 -Inf -> NaN Invalid_operation
+dqxor788 xor -Inf -Inf -> NaN Invalid_operation
+dqxor789 xor -1 -Inf -> NaN Invalid_operation
+dqxor790 xor -0 -Inf -> NaN Invalid_operation
+dqxor791 xor 0 -Inf -> NaN Invalid_operation
+dqxor792 xor 1 -Inf -> NaN Invalid_operation
+dqxor793 xor 1000 -Inf -> NaN Invalid_operation
+dqxor794 xor Inf -Inf -> NaN Invalid_operation
+
+dqxor800 xor Inf -Inf -> NaN Invalid_operation
+dqxor801 xor Inf -1000 -> NaN Invalid_operation
+dqxor802 xor Inf -1 -> NaN Invalid_operation
+dqxor803 xor Inf -0 -> NaN Invalid_operation
+dqxor804 xor Inf 0 -> NaN Invalid_operation
+dqxor805 xor Inf 1 -> NaN Invalid_operation
+dqxor806 xor Inf 1000 -> NaN Invalid_operation
+dqxor807 xor Inf Inf -> NaN Invalid_operation
+dqxor808 xor -1000 Inf -> NaN Invalid_operation
+dqxor809 xor -Inf Inf -> NaN Invalid_operation
+dqxor810 xor -1 Inf -> NaN Invalid_operation
+dqxor811 xor -0 Inf -> NaN Invalid_operation
+dqxor812 xor 0 Inf -> NaN Invalid_operation
+dqxor813 xor 1 Inf -> NaN Invalid_operation
+dqxor814 xor 1000 Inf -> NaN Invalid_operation
+dqxor815 xor Inf Inf -> NaN Invalid_operation
+
+dqxor821 xor NaN -Inf -> NaN Invalid_operation
+dqxor822 xor NaN -1000 -> NaN Invalid_operation
+dqxor823 xor NaN -1 -> NaN Invalid_operation
+dqxor824 xor NaN -0 -> NaN Invalid_operation
+dqxor825 xor NaN 0 -> NaN Invalid_operation
+dqxor826 xor NaN 1 -> NaN Invalid_operation
+dqxor827 xor NaN 1000 -> NaN Invalid_operation
+dqxor828 xor NaN Inf -> NaN Invalid_operation
+dqxor829 xor NaN NaN -> NaN Invalid_operation
+dqxor830 xor -Inf NaN -> NaN Invalid_operation
+dqxor831 xor -1000 NaN -> NaN Invalid_operation
+dqxor832 xor -1 NaN -> NaN Invalid_operation
+dqxor833 xor -0 NaN -> NaN Invalid_operation
+dqxor834 xor 0 NaN -> NaN Invalid_operation
+dqxor835 xor 1 NaN -> NaN Invalid_operation
+dqxor836 xor 1000 NaN -> NaN Invalid_operation
+dqxor837 xor Inf NaN -> NaN Invalid_operation
+
+dqxor841 xor sNaN -Inf -> NaN Invalid_operation
+dqxor842 xor sNaN -1000 -> NaN Invalid_operation
+dqxor843 xor sNaN -1 -> NaN Invalid_operation
+dqxor844 xor sNaN -0 -> NaN Invalid_operation
+dqxor845 xor sNaN 0 -> NaN Invalid_operation
+dqxor846 xor sNaN 1 -> NaN Invalid_operation
+dqxor847 xor sNaN 1000 -> NaN Invalid_operation
+dqxor848 xor sNaN NaN -> NaN Invalid_operation
+dqxor849 xor sNaN sNaN -> NaN Invalid_operation
+dqxor850 xor NaN sNaN -> NaN Invalid_operation
+dqxor851 xor -Inf sNaN -> NaN Invalid_operation
+dqxor852 xor -1000 sNaN -> NaN Invalid_operation
+dqxor853 xor -1 sNaN -> NaN Invalid_operation
+dqxor854 xor -0 sNaN -> NaN Invalid_operation
+dqxor855 xor 0 sNaN -> NaN Invalid_operation
+dqxor856 xor 1 sNaN -> NaN Invalid_operation
+dqxor857 xor 1000 sNaN -> NaN Invalid_operation
+dqxor858 xor Inf sNaN -> NaN Invalid_operation
+dqxor859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+dqxor861 xor NaN1 -Inf -> NaN Invalid_operation
+dqxor862 xor +NaN2 -1000 -> NaN Invalid_operation
+dqxor863 xor NaN3 1000 -> NaN Invalid_operation
+dqxor864 xor NaN4 Inf -> NaN Invalid_operation
+dqxor865 xor NaN5 +NaN6 -> NaN Invalid_operation
+dqxor866 xor -Inf NaN7 -> NaN Invalid_operation
+dqxor867 xor -1000 NaN8 -> NaN Invalid_operation
+dqxor868 xor 1000 NaN9 -> NaN Invalid_operation
+dqxor869 xor Inf +NaN10 -> NaN Invalid_operation
+dqxor871 xor sNaN11 -Inf -> NaN Invalid_operation
+dqxor872 xor sNaN12 -1000 -> NaN Invalid_operation
+dqxor873 xor sNaN13 1000 -> NaN Invalid_operation
+dqxor874 xor sNaN14 NaN17 -> NaN Invalid_operation
+dqxor875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+dqxor876 xor NaN16 sNaN19 -> NaN Invalid_operation
+dqxor877 xor -Inf +sNaN20 -> NaN Invalid_operation
+dqxor878 xor -1000 sNaN21 -> NaN Invalid_operation
+dqxor879 xor 1000 sNaN22 -> NaN Invalid_operation
+dqxor880 xor Inf sNaN23 -> NaN Invalid_operation
+dqxor881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+dqxor882 xor -NaN26 NaN28 -> NaN Invalid_operation
+dqxor883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+dqxor884 xor 1000 -NaN30 -> NaN Invalid_operation
+dqxor885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/dsBase.decTest b/Lib/test/decimaltestdata/dsBase.decTest
index 5e5e5a5d91c..8ac45fc5521 100644
--- a/Lib/test/decimaltestdata/dsBase.decTest
+++ b/Lib/test/decimaltestdata/dsBase.decTest
@@ -1,1062 +1,1062 @@
-------------------------------------------------------------------------
--- dsBase.decTest -- base decSingle <--> string conversions --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This file tests base conversions from string to a decimal number
--- and back to a string (in Scientific form)
-
--- Note that unlike other operations the operand is subject to rounding
--- to conform to emax and precision settings (that is, numbers will
--- conform to rules and exponent will be in permitted range). The
--- 'left hand side', therefore, may have numbers that cannot be
--- represented in a decSingle. Some testcases go to the limit of the
--- next-wider format, and hence these testcases may also be used to
--- test narrowing and widening operations.
-
-extended: 1
-clamp: 1
-precision: 7
-maxExponent: 96
-minExponent: -95
-rounding: half_even
-
-dsbas001 toSci 0 -> 0
-dsbas002 toSci 1 -> 1
-dsbas003 toSci 1.0 -> 1.0
-dsbas004 toSci 1.00 -> 1.00
-dsbas005 toSci 10 -> 10
-dsbas006 toSci 1000 -> 1000
-dsbas007 toSci 10.0 -> 10.0
-dsbas008 toSci 10.1 -> 10.1
-dsbas009 toSci 10.4 -> 10.4
-dsbas010 toSci 10.5 -> 10.5
-dsbas011 toSci 10.6 -> 10.6
-dsbas012 toSci 10.9 -> 10.9
-dsbas013 toSci 11.0 -> 11.0
-dsbas014 toSci 1.234 -> 1.234
-dsbas015 toSci 0.123 -> 0.123
-dsbas016 toSci 0.012 -> 0.012
-dsbas017 toSci -0 -> -0
-dsbas018 toSci -0.0 -> -0.0
-dsbas019 toSci -00.00 -> -0.00
-
-dsbas021 toSci -1 -> -1
-dsbas022 toSci -1.0 -> -1.0
-dsbas023 toSci -0.1 -> -0.1
-dsbas024 toSci -9.1 -> -9.1
-dsbas025 toSci -9.11 -> -9.11
-dsbas026 toSci -9.119 -> -9.119
-dsbas027 toSci -9.999 -> -9.999
-
-dsbas030 toSci '1234.567' -> '1234.567'
-dsbas031 toSci '1234.000' -> '1234.000'
-dsbas032 toSci '1234912' -> '1234912'
-dsbas033 toSci '0.00001234567' -> '0.00001234567'
-dsbas034 toSci '0.000001234567' -> '0.000001234567'
-dsbas035 toSci '0.0000001234567' -> '1.234567E-7'
-dsbas036 toSci '0.00000001234567' -> '1.234567E-8'
-
-dsbas037 toSci '0.1234564' -> '0.1234564'
-dsbas038 toSci '0.1234565' -> '0.1234565'
-
--- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
-dsbsn001 toSci -9.999999E+96 -> -9.999999E+96
-dsbsn002 toSci -1E-95 -> -1E-95
-dsbsn003 toSci -1E-101 -> -1E-101 Subnormal
-dsbsn004 toSci -0 -> -0
-dsbsn005 toSci +0 -> 0
-dsbsn006 toSci +1E-101 -> 1E-101 Subnormal
-dsbsn007 toSci +1E-95 -> 1E-95
-dsbsn008 toSci +9.999999E+96 -> 9.999999E+96
-
--- String [many more examples are implicitly tested elsewhere]
--- strings without E cannot generate E in result
-dsbas040 toSci "12" -> '12'
-dsbas041 toSci "-76" -> '-76'
-dsbas042 toSci "12.76" -> '12.76'
-dsbas043 toSci "+12.76" -> '12.76'
-dsbas044 toSci "012.76" -> '12.76'
-dsbas045 toSci "+0.003" -> '0.003'
-dsbas046 toSci "17." -> '17'
-dsbas047 toSci ".5" -> '0.5'
-dsbas048 toSci "044" -> '44'
-dsbas049 toSci "0044" -> '44'
-dsbas050 toSci "0.0005" -> '0.0005'
-dsbas051 toSci "00.00005" -> '0.00005'
-dsbas052 toSci "0.000005" -> '0.000005'
-dsbas053 toSci "0.0000050" -> '0.0000050'
-dsbas054 toSci "0.0000005" -> '5E-7'
-dsbas055 toSci "0.00000005" -> '5E-8'
-dsbas056 toSci "12678.54" -> '12678.54'
-dsbas057 toSci "2678.543" -> '2678.543'
-dsbas058 toSci "345678.5" -> '345678.5'
-dsbas059 toSci "0678.5432" -> '678.5432'
-dsbas060 toSci "678.5432" -> '678.5432'
-dsbas061 toSci "+678.5432" -> '678.5432'
-dsbas062 toSci "+0678.5432" -> '678.5432'
-dsbas063 toSci "+00678.5432" -> '678.5432'
-dsbas064 toSci "-678.5432" -> '-678.5432'
-dsbas065 toSci "-0678.5432" -> '-678.5432'
-dsbas066 toSci "-00678.5432" -> '-678.5432'
--- examples
-dsbas067 toSci "5E-6" -> '0.000005'
-dsbas068 toSci "50E-7" -> '0.0000050'
-dsbas069 toSci "5E-7" -> '5E-7'
-
--- [No exotics as no Unicode]
-
--- rounded with dots in all (including edge) places
-dsbas071 toSci .1234567890123456 -> 0.1234568 Inexact Rounded
-dsbas072 toSci 1.234567890123456 -> 1.234568 Inexact Rounded
-dsbas073 toSci 12.34567890123456 -> 12.34568 Inexact Rounded
-dsbas074 toSci 123.4567890123456 -> 123.4568 Inexact Rounded
-dsbas075 toSci 1234.567890123456 -> 1234.568 Inexact Rounded
-dsbas076 toSci 12345.67890123456 -> 12345.68 Inexact Rounded
-dsbas077 toSci 123456.7890123456 -> 123456.8 Inexact Rounded
-dsbas078 toSci 1234567.890123456 -> 1234568 Inexact Rounded
-dsbas079 toSci 12345678.90123456 -> 1.234568E+7 Inexact Rounded
-dsbas080 toSci 123456789.0123456 -> 1.234568E+8 Inexact Rounded
-dsbas081 toSci 1234567890.123456 -> 1.234568E+9 Inexact Rounded
-dsbas082 toSci 12345678901.23456 -> 1.234568E+10 Inexact Rounded
-dsbas083 toSci 123456789012.3456 -> 1.234568E+11 Inexact Rounded
-dsbas084 toSci 1234567890123.456 -> 1.234568E+12 Inexact Rounded
-dsbas085 toSci 12345678901234.56 -> 1.234568E+13 Inexact Rounded
-dsbas086 toSci 123456789012345.6 -> 1.234568E+14 Inexact Rounded
-dsbas087 toSci 1234567890123456. -> 1.234568E+15 Inexact Rounded
-dsbas088 toSci 1234567890123456 -> 1.234568E+15 Inexact Rounded
-
--- Numbers with E
-dsbas130 toSci "0.000E-1" -> '0.0000'
-dsbas131 toSci "0.000E-2" -> '0.00000'
-dsbas132 toSci "0.000E-3" -> '0.000000'
-dsbas133 toSci "0.000E-4" -> '0E-7'
-dsbas134 toSci "0.00E-2" -> '0.0000'
-dsbas135 toSci "0.00E-3" -> '0.00000'
-dsbas136 toSci "0.00E-4" -> '0.000000'
-dsbas137 toSci "0.00E-5" -> '0E-7'
-dsbas138 toSci "+0E+9" -> '0E+9'
-dsbas139 toSci "-0E+9" -> '-0E+9'
-dsbas140 toSci "1E+9" -> '1E+9'
-dsbas141 toSci "1e+09" -> '1E+9'
-dsbas142 toSci "1E+90" -> '1E+90'
-dsbas143 toSci "+1E+009" -> '1E+9'
-dsbas144 toSci "0E+9" -> '0E+9'
-dsbas145 toSci "1E+9" -> '1E+9'
-dsbas146 toSci "1E+09" -> '1E+9'
-dsbas147 toSci "1e+90" -> '1E+90'
-dsbas148 toSci "1E+009" -> '1E+9'
-dsbas149 toSci "000E+9" -> '0E+9'
-dsbas150 toSci "1E9" -> '1E+9'
-dsbas151 toSci "1e09" -> '1E+9'
-dsbas152 toSci "1E90" -> '1E+90'
-dsbas153 toSci "1E009" -> '1E+9'
-dsbas154 toSci "0E9" -> '0E+9'
-dsbas155 toSci "0.000e+0" -> '0.000'
-dsbas156 toSci "0.000E-1" -> '0.0000'
-dsbas157 toSci "4E+9" -> '4E+9'
-dsbas158 toSci "44E+9" -> '4.4E+10'
-dsbas159 toSci "0.73e-7" -> '7.3E-8'
-dsbas160 toSci "00E+9" -> '0E+9'
-dsbas161 toSci "00E-9" -> '0E-9'
-dsbas162 toSci "10E+9" -> '1.0E+10'
-dsbas163 toSci "10E+09" -> '1.0E+10'
-dsbas164 toSci "10e+90" -> '1.0E+91'
-dsbas165 toSci "10E+009" -> '1.0E+10'
-dsbas166 toSci "100e+9" -> '1.00E+11'
-dsbas167 toSci "100e+09" -> '1.00E+11'
-dsbas168 toSci "100E+90" -> '1.00E+92'
-dsbas169 toSci "100e+009" -> '1.00E+11'
-
-dsbas170 toSci "1.265" -> '1.265'
-dsbas171 toSci "1.265E-20" -> '1.265E-20'
-dsbas172 toSci "1.265E-8" -> '1.265E-8'
-dsbas173 toSci "1.265E-4" -> '0.0001265'
-dsbas174 toSci "1.265E-3" -> '0.001265'
-dsbas175 toSci "1.265E-2" -> '0.01265'
-dsbas176 toSci "1.265E-1" -> '0.1265'
-dsbas177 toSci "1.265E-0" -> '1.265'
-dsbas178 toSci "1.265E+1" -> '12.65'
-dsbas179 toSci "1.265E+2" -> '126.5'
-dsbas180 toSci "1.265E+3" -> '1265'
-dsbas181 toSci "1.265E+4" -> '1.265E+4'
-dsbas182 toSci "1.265E+8" -> '1.265E+8'
-dsbas183 toSci "1.265E+20" -> '1.265E+20'
-
-dsbas190 toSci "12.65" -> '12.65'
-dsbas191 toSci "12.65E-20" -> '1.265E-19'
-dsbas192 toSci "12.65E-8" -> '1.265E-7'
-dsbas193 toSci "12.65E-4" -> '0.001265'
-dsbas194 toSci "12.65E-3" -> '0.01265'
-dsbas195 toSci "12.65E-2" -> '0.1265'
-dsbas196 toSci "12.65E-1" -> '1.265'
-dsbas197 toSci "12.65E-0" -> '12.65'
-dsbas198 toSci "12.65E+1" -> '126.5'
-dsbas199 toSci "12.65E+2" -> '1265'
-dsbas200 toSci "12.65E+3" -> '1.265E+4'
-dsbas201 toSci "12.65E+4" -> '1.265E+5'
-dsbas202 toSci "12.65E+8" -> '1.265E+9'
-dsbas203 toSci "12.65E+20" -> '1.265E+21'
-
-dsbas210 toSci "126.5" -> '126.5'
-dsbas211 toSci "126.5E-20" -> '1.265E-18'
-dsbas212 toSci "126.5E-8" -> '0.000001265'
-dsbas213 toSci "126.5E-4" -> '0.01265'
-dsbas214 toSci "126.5E-3" -> '0.1265'
-dsbas215 toSci "126.5E-2" -> '1.265'
-dsbas216 toSci "126.5E-1" -> '12.65'
-dsbas217 toSci "126.5E-0" -> '126.5'
-dsbas218 toSci "126.5E+1" -> '1265'
-dsbas219 toSci "126.5E+2" -> '1.265E+4'
-dsbas220 toSci "126.5E+3" -> '1.265E+5'
-dsbas221 toSci "126.5E+4" -> '1.265E+6'
-dsbas222 toSci "126.5E+8" -> '1.265E+10'
-dsbas223 toSci "126.5E+20" -> '1.265E+22'
-
-dsbas230 toSci "1265" -> '1265'
-dsbas231 toSci "1265E-20" -> '1.265E-17'
-dsbas232 toSci "1265E-8" -> '0.00001265'
-dsbas233 toSci "1265E-4" -> '0.1265'
-dsbas234 toSci "1265E-3" -> '1.265'
-dsbas235 toSci "1265E-2" -> '12.65'
-dsbas236 toSci "1265E-1" -> '126.5'
-dsbas237 toSci "1265E-0" -> '1265'
-dsbas238 toSci "1265E+1" -> '1.265E+4'
-dsbas239 toSci "1265E+2" -> '1.265E+5'
-dsbas240 toSci "1265E+3" -> '1.265E+6'
-dsbas241 toSci "1265E+4" -> '1.265E+7'
-dsbas242 toSci "1265E+8" -> '1.265E+11'
-dsbas243 toSci "1265E+20" -> '1.265E+23'
-
-dsbas250 toSci "0.1265" -> '0.1265'
-dsbas251 toSci "0.1265E-20" -> '1.265E-21'
-dsbas252 toSci "0.1265E-8" -> '1.265E-9'
-dsbas253 toSci "0.1265E-4" -> '0.00001265'
-dsbas254 toSci "0.1265E-3" -> '0.0001265'
-dsbas255 toSci "0.1265E-2" -> '0.001265'
-dsbas256 toSci "0.1265E-1" -> '0.01265'
-dsbas257 toSci "0.1265E-0" -> '0.1265'
-dsbas258 toSci "0.1265E+1" -> '1.265'
-dsbas259 toSci "0.1265E+2" -> '12.65'
-dsbas260 toSci "0.1265E+3" -> '126.5'
-dsbas261 toSci "0.1265E+4" -> '1265'
-dsbas262 toSci "0.1265E+8" -> '1.265E+7'
-dsbas263 toSci "0.1265E+20" -> '1.265E+19'
-
--- some more negative zeros [systematic tests below]
-dsbas290 toSci "-0.000E-1" -> '-0.0000'
-dsbas291 toSci "-0.000E-2" -> '-0.00000'
-dsbas292 toSci "-0.000E-3" -> '-0.000000'
-dsbas293 toSci "-0.000E-4" -> '-0E-7'
-dsbas294 toSci "-0.00E-2" -> '-0.0000'
-dsbas295 toSci "-0.00E-3" -> '-0.00000'
-dsbas296 toSci "-0.0E-2" -> '-0.000'
-dsbas297 toSci "-0.0E-3" -> '-0.0000'
-dsbas298 toSci "-0E-2" -> '-0.00'
-dsbas299 toSci "-0E-3" -> '-0.000'
-
--- Engineering notation tests
-dsbas301 toSci 10e12 -> 1.0E+13
-dsbas302 toEng 10e12 -> 10E+12
-dsbas303 toSci 10e11 -> 1.0E+12
-dsbas304 toEng 10e11 -> 1.0E+12
-dsbas305 toSci 10e10 -> 1.0E+11
-dsbas306 toEng 10e10 -> 100E+9
-dsbas307 toSci 10e9 -> 1.0E+10
-dsbas308 toEng 10e9 -> 10E+9
-dsbas309 toSci 10e8 -> 1.0E+9
-dsbas310 toEng 10e8 -> 1.0E+9
-dsbas311 toSci 10e7 -> 1.0E+8
-dsbas312 toEng 10e7 -> 100E+6
-dsbas313 toSci 10e6 -> 1.0E+7
-dsbas314 toEng 10e6 -> 10E+6
-dsbas315 toSci 10e5 -> 1.0E+6
-dsbas316 toEng 10e5 -> 1.0E+6
-dsbas317 toSci 10e4 -> 1.0E+5
-dsbas318 toEng 10e4 -> 100E+3
-dsbas319 toSci 10e3 -> 1.0E+4
-dsbas320 toEng 10e3 -> 10E+3
-dsbas321 toSci 10e2 -> 1.0E+3
-dsbas322 toEng 10e2 -> 1.0E+3
-dsbas323 toSci 10e1 -> 1.0E+2
-dsbas324 toEng 10e1 -> 100
-dsbas325 toSci 10e0 -> 10
-dsbas326 toEng 10e0 -> 10
-dsbas327 toSci 10e-1 -> 1.0
-dsbas328 toEng 10e-1 -> 1.0
-dsbas329 toSci 10e-2 -> 0.10
-dsbas330 toEng 10e-2 -> 0.10
-dsbas331 toSci 10e-3 -> 0.010
-dsbas332 toEng 10e-3 -> 0.010
-dsbas333 toSci 10e-4 -> 0.0010
-dsbas334 toEng 10e-4 -> 0.0010
-dsbas335 toSci 10e-5 -> 0.00010
-dsbas336 toEng 10e-5 -> 0.00010
-dsbas337 toSci 10e-6 -> 0.000010
-dsbas338 toEng 10e-6 -> 0.000010
-dsbas339 toSci 10e-7 -> 0.0000010
-dsbas340 toEng 10e-7 -> 0.0000010
-dsbas341 toSci 10e-8 -> 1.0E-7
-dsbas342 toEng 10e-8 -> 100E-9
-dsbas343 toSci 10e-9 -> 1.0E-8
-dsbas344 toEng 10e-9 -> 10E-9
-dsbas345 toSci 10e-10 -> 1.0E-9
-dsbas346 toEng 10e-10 -> 1.0E-9
-dsbas347 toSci 10e-11 -> 1.0E-10
-dsbas348 toEng 10e-11 -> 100E-12
-dsbas349 toSci 10e-12 -> 1.0E-11
-dsbas350 toEng 10e-12 -> 10E-12
-dsbas351 toSci 10e-13 -> 1.0E-12
-dsbas352 toEng 10e-13 -> 1.0E-12
-
-dsbas361 toSci 7E12 -> 7E+12
-dsbas362 toEng 7E12 -> 7E+12
-dsbas363 toSci 7E11 -> 7E+11
-dsbas364 toEng 7E11 -> 700E+9
-dsbas365 toSci 7E10 -> 7E+10
-dsbas366 toEng 7E10 -> 70E+9
-dsbas367 toSci 7E9 -> 7E+9
-dsbas368 toEng 7E9 -> 7E+9
-dsbas369 toSci 7E8 -> 7E+8
-dsbas370 toEng 7E8 -> 700E+6
-dsbas371 toSci 7E7 -> 7E+7
-dsbas372 toEng 7E7 -> 70E+6
-dsbas373 toSci 7E6 -> 7E+6
-dsbas374 toEng 7E6 -> 7E+6
-dsbas375 toSci 7E5 -> 7E+5
-dsbas376 toEng 7E5 -> 700E+3
-dsbas377 toSci 7E4 -> 7E+4
-dsbas378 toEng 7E4 -> 70E+3
-dsbas379 toSci 7E3 -> 7E+3
-dsbas380 toEng 7E3 -> 7E+3
-dsbas381 toSci 7E2 -> 7E+2
-dsbas382 toEng 7E2 -> 700
-dsbas383 toSci 7E1 -> 7E+1
-dsbas384 toEng 7E1 -> 70
-dsbas385 toSci 7E0 -> 7
-dsbas386 toEng 7E0 -> 7
-dsbas387 toSci 7E-1 -> 0.7
-dsbas388 toEng 7E-1 -> 0.7
-dsbas389 toSci 7E-2 -> 0.07
-dsbas390 toEng 7E-2 -> 0.07
-dsbas391 toSci 7E-3 -> 0.007
-dsbas392 toEng 7E-3 -> 0.007
-dsbas393 toSci 7E-4 -> 0.0007
-dsbas394 toEng 7E-4 -> 0.0007
-dsbas395 toSci 7E-5 -> 0.00007
-dsbas396 toEng 7E-5 -> 0.00007
-dsbas397 toSci 7E-6 -> 0.000007
-dsbas398 toEng 7E-6 -> 0.000007
-dsbas399 toSci 7E-7 -> 7E-7
-dsbas400 toEng 7E-7 -> 700E-9
-dsbas401 toSci 7E-8 -> 7E-8
-dsbas402 toEng 7E-8 -> 70E-9
-dsbas403 toSci 7E-9 -> 7E-9
-dsbas404 toEng 7E-9 -> 7E-9
-dsbas405 toSci 7E-10 -> 7E-10
-dsbas406 toEng 7E-10 -> 700E-12
-dsbas407 toSci 7E-11 -> 7E-11
-dsbas408 toEng 7E-11 -> 70E-12
-dsbas409 toSci 7E-12 -> 7E-12
-dsbas410 toEng 7E-12 -> 7E-12
-dsbas411 toSci 7E-13 -> 7E-13
-dsbas412 toEng 7E-13 -> 700E-15
-
--- Exacts remain exact up to precision ..
-dsbas420 toSci 100 -> 100
-dsbas422 toSci 1000 -> 1000
-dsbas424 toSci 999.9 -> 999.9
-dsbas426 toSci 1000.0 -> 1000.0
-dsbas428 toSci 1000.1 -> 1000.1
-dsbas430 toSci 10000 -> 10000
-dsbas432 toSci 1000 -> 1000
-dsbas434 toSci 10000 -> 10000
-dsbas436 toSci 100000 -> 100000
-dsbas438 toSci 1000000 -> 1000000
-dsbas440 toSci 10000000 -> 1.000000E+7 Rounded
-dsbas442 toSci 10000000 -> 1.000000E+7 Rounded
-dsbas444 toSci 10000003 -> 1.000000E+7 Rounded Inexact
-dsbas446 toSci 10000005 -> 1.000000E+7 Rounded Inexact
-dsbas448 toSci 100000050 -> 1.000000E+8 Rounded Inexact
-dsbas450 toSci 10000009 -> 1.000001E+7 Rounded Inexact
-dsbas452 toSci 100000000 -> 1.000000E+8 Rounded
-dsbas454 toSci 100000003 -> 1.000000E+8 Rounded Inexact
-dsbas456 toSci 100000005 -> 1.000000E+8 Rounded Inexact
-dsbas458 toSci 100000009 -> 1.000000E+8 Rounded Inexact
-dsbas460 toSci 1000000000 -> 1.000000E+9 Rounded
-dsbas462 toSci 1000000300 -> 1.000000E+9 Rounded Inexact
-dsbas464 toSci 1000000500 -> 1.000000E+9 Rounded Inexact
-dsbas466 toSci 1000000900 -> 1.000001E+9 Rounded Inexact
-dsbas468 toSci 10000000000 -> 1.000000E+10 Rounded
-dsbas470 toSci 10000003000 -> 1.000000E+10 Rounded Inexact
-dsbas472 toSci 10000005000 -> 1.000000E+10 Rounded Inexact
-dsbas474 toSci 10000009000 -> 1.000001E+10 Rounded Inexact
-
--- check rounding modes heeded
-rounding: ceiling
-dsbsr401 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr402 toSci 1.11234549 -> 1.112346 Rounded Inexact
-dsbsr403 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr404 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: up
-dsbsr405 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr406 toSci 1.11234549 -> 1.112346 Rounded Inexact
-dsbsr407 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr408 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: floor
-dsbsr410 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr411 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr412 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr413 toSci 1.11234551 -> 1.112345 Rounded Inexact
-rounding: half_down
-dsbsr415 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr416 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr417 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr418 toSci 1.11234650 -> 1.112346 Rounded Inexact
-dsbsr419 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: half_even
-dsbsr421 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr422 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr423 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr424 toSci 1.11234650 -> 1.112346 Rounded Inexact
-dsbsr425 toSci 1.11234551 -> 1.112346 Rounded Inexact
-rounding: down
-dsbsr426 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr427 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr428 toSci 1.11234550 -> 1.112345 Rounded Inexact
-dsbsr429 toSci 1.11234551 -> 1.112345 Rounded Inexact
-rounding: half_up
-dsbsr431 toSci 1.1123450 -> 1.112345 Rounded
-dsbsr432 toSci 1.11234549 -> 1.112345 Rounded Inexact
-dsbsr433 toSci 1.11234550 -> 1.112346 Rounded Inexact
-dsbsr434 toSci 1.11234650 -> 1.112347 Rounded Inexact
-dsbsr435 toSci 1.11234551 -> 1.112346 Rounded Inexact
--- negatives
-rounding: ceiling
-dsbsr501 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr502 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr503 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr504 toSci -1.11234551 -> -1.112345 Rounded Inexact
-rounding: up
-dsbsr505 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr506 toSci -1.11234549 -> -1.112346 Rounded Inexact
-dsbsr507 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr508 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: floor
-dsbsr510 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr511 toSci -1.11234549 -> -1.112346 Rounded Inexact
-dsbsr512 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr513 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: half_down
-dsbsr515 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr516 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr517 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr518 toSci -1.11234650 -> -1.112346 Rounded Inexact
-dsbsr519 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: half_even
-dsbsr521 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr522 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr523 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr524 toSci -1.11234650 -> -1.112346 Rounded Inexact
-dsbsr525 toSci -1.11234551 -> -1.112346 Rounded Inexact
-rounding: down
-dsbsr526 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr527 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr528 toSci -1.11234550 -> -1.112345 Rounded Inexact
-dsbsr529 toSci -1.11234551 -> -1.112345 Rounded Inexact
-rounding: half_up
-dsbsr531 toSci -1.1123450 -> -1.112345 Rounded
-dsbsr532 toSci -1.11234549 -> -1.112345 Rounded Inexact
-dsbsr533 toSci -1.11234550 -> -1.112346 Rounded Inexact
-dsbsr534 toSci -1.11234650 -> -1.112347 Rounded Inexact
-dsbsr535 toSci -1.11234551 -> -1.112346 Rounded Inexact
-
-rounding: half_even
-
--- The 'baddies' tests from DiagBigDecimal, plus some new ones
-dsbas500 toSci '1..2' -> NaN Conversion_syntax
-dsbas501 toSci '.' -> NaN Conversion_syntax
-dsbas502 toSci '..' -> NaN Conversion_syntax
-dsbas503 toSci '++1' -> NaN Conversion_syntax
-dsbas504 toSci '--1' -> NaN Conversion_syntax
-dsbas505 toSci '-+1' -> NaN Conversion_syntax
-dsbas506 toSci '+-1' -> NaN Conversion_syntax
-dsbas507 toSci '12e' -> NaN Conversion_syntax
-dsbas508 toSci '12e++' -> NaN Conversion_syntax
-dsbas509 toSci '12f4' -> NaN Conversion_syntax
-dsbas510 toSci ' +1' -> NaN Conversion_syntax
-dsbas511 toSci '+ 1' -> NaN Conversion_syntax
-dsbas512 toSci '12 ' -> NaN Conversion_syntax
-dsbas513 toSci ' + 1' -> NaN Conversion_syntax
-dsbas514 toSci ' - 1 ' -> NaN Conversion_syntax
-dsbas515 toSci 'x' -> NaN Conversion_syntax
-dsbas516 toSci '-1-' -> NaN Conversion_syntax
-dsbas517 toSci '12-' -> NaN Conversion_syntax
-dsbas518 toSci '3+' -> NaN Conversion_syntax
-dsbas519 toSci '' -> NaN Conversion_syntax
-dsbas520 toSci '1e-' -> NaN Conversion_syntax
-dsbas521 toSci '7e99999a' -> NaN Conversion_syntax
-dsbas522 toSci '7e123567890x' -> NaN Conversion_syntax
-dsbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
-dsbas524 toSci '' -> NaN Conversion_syntax
-dsbas525 toSci 'e100' -> NaN Conversion_syntax
-dsbas526 toSci '\u0e5a' -> NaN Conversion_syntax
-dsbas527 toSci '\u0b65' -> NaN Conversion_syntax
-dsbas528 toSci '123,65' -> NaN Conversion_syntax
-dsbas529 toSci '1.34.5' -> NaN Conversion_syntax
-dsbas530 toSci '.123.5' -> NaN Conversion_syntax
-dsbas531 toSci '01.35.' -> NaN Conversion_syntax
-dsbas532 toSci '01.35-' -> NaN Conversion_syntax
-dsbas533 toSci '0000..' -> NaN Conversion_syntax
-dsbas534 toSci '.0000.' -> NaN Conversion_syntax
-dsbas535 toSci '00..00' -> NaN Conversion_syntax
-dsbas536 toSci '111e*123' -> NaN Conversion_syntax
-dsbas537 toSci '111e123-' -> NaN Conversion_syntax
-dsbas538 toSci '111e+12+' -> NaN Conversion_syntax
-dsbas539 toSci '111e1-3-' -> NaN Conversion_syntax
-dsbas540 toSci '111e1*23' -> NaN Conversion_syntax
-dsbas541 toSci '111e1e+3' -> NaN Conversion_syntax
-dsbas542 toSci '1e1.0' -> NaN Conversion_syntax
-dsbas543 toSci '1e123e' -> NaN Conversion_syntax
-dsbas544 toSci 'ten' -> NaN Conversion_syntax
-dsbas545 toSci 'ONE' -> NaN Conversion_syntax
-dsbas546 toSci '1e.1' -> NaN Conversion_syntax
-dsbas547 toSci '1e1.' -> NaN Conversion_syntax
-dsbas548 toSci '1ee' -> NaN Conversion_syntax
-dsbas549 toSci 'e+1' -> NaN Conversion_syntax
-dsbas550 toSci '1.23.4' -> NaN Conversion_syntax
-dsbas551 toSci '1.2.1' -> NaN Conversion_syntax
-dsbas552 toSci '1E+1.2' -> NaN Conversion_syntax
-dsbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
-dsbas554 toSci '1E++1' -> NaN Conversion_syntax
-dsbas555 toSci '1E--1' -> NaN Conversion_syntax
-dsbas556 toSci '1E+-1' -> NaN Conversion_syntax
-dsbas557 toSci '1E-+1' -> NaN Conversion_syntax
-dsbas558 toSci '1E''1' -> NaN Conversion_syntax
-dsbas559 toSci "1E""1" -> NaN Conversion_syntax
-dsbas560 toSci "1E""""" -> NaN Conversion_syntax
--- Near-specials
-dsbas561 toSci "qNaN" -> NaN Conversion_syntax
-dsbas562 toSci "NaNq" -> NaN Conversion_syntax
-dsbas563 toSci "NaNs" -> NaN Conversion_syntax
-dsbas564 toSci "Infi" -> NaN Conversion_syntax
-dsbas565 toSci "Infin" -> NaN Conversion_syntax
-dsbas566 toSci "Infini" -> NaN Conversion_syntax
-dsbas567 toSci "Infinit" -> NaN Conversion_syntax
-dsbas568 toSci "-Infinit" -> NaN Conversion_syntax
-dsbas569 toSci "0Inf" -> NaN Conversion_syntax
-dsbas570 toSci "9Inf" -> NaN Conversion_syntax
-dsbas571 toSci "-0Inf" -> NaN Conversion_syntax
-dsbas572 toSci "-9Inf" -> NaN Conversion_syntax
-dsbas573 toSci "-sNa" -> NaN Conversion_syntax
-dsbas574 toSci "xNaN" -> NaN Conversion_syntax
-dsbas575 toSci "0sNaN" -> NaN Conversion_syntax
-
--- some baddies with dots and Es and dots and specials
-dsbas576 toSci 'e+1' -> NaN Conversion_syntax
-dsbas577 toSci '.e+1' -> NaN Conversion_syntax
-dsbas578 toSci '+.e+1' -> NaN Conversion_syntax
-dsbas579 toSci '-.e+' -> NaN Conversion_syntax
-dsbas580 toSci '-.e' -> NaN Conversion_syntax
-dsbas581 toSci 'E+1' -> NaN Conversion_syntax
-dsbas582 toSci '.E+1' -> NaN Conversion_syntax
-dsbas583 toSci '+.E+1' -> NaN Conversion_syntax
-dsbas584 toSci '-.E+' -> NaN Conversion_syntax
-dsbas585 toSci '-.E' -> NaN Conversion_syntax
-
-dsbas586 toSci '.NaN' -> NaN Conversion_syntax
-dsbas587 toSci '-.NaN' -> NaN Conversion_syntax
-dsbas588 toSci '+.sNaN' -> NaN Conversion_syntax
-dsbas589 toSci '+.Inf' -> NaN Conversion_syntax
-dsbas590 toSci '.Infinity' -> NaN Conversion_syntax
-
--- Zeros
-dsbas601 toSci 0.000000000 -> 0E-9
-dsbas602 toSci 0.00000000 -> 0E-8
-dsbas603 toSci 0.0000000 -> 0E-7
-dsbas604 toSci 0.000000 -> 0.000000
-dsbas605 toSci 0.00000 -> 0.00000
-dsbas606 toSci 0.0000 -> 0.0000
-dsbas607 toSci 0.000 -> 0.000
-dsbas608 toSci 0.00 -> 0.00
-dsbas609 toSci 0.0 -> 0.0
-dsbas610 toSci .0 -> 0.0
-dsbas611 toSci 0. -> 0
-dsbas612 toSci -.0 -> -0.0
-dsbas613 toSci -0. -> -0
-dsbas614 toSci -0.0 -> -0.0
-dsbas615 toSci -0.00 -> -0.00
-dsbas616 toSci -0.000 -> -0.000
-dsbas617 toSci -0.0000 -> -0.0000
-dsbas618 toSci -0.00000 -> -0.00000
-dsbas619 toSci -0.000000 -> -0.000000
-dsbas620 toSci -0.0000000 -> -0E-7
-dsbas621 toSci -0.00000000 -> -0E-8
-dsbas622 toSci -0.000000000 -> -0E-9
-
-dsbas630 toSci 0.00E+0 -> 0.00
-dsbas631 toSci 0.00E+1 -> 0.0
-dsbas632 toSci 0.00E+2 -> 0
-dsbas633 toSci 0.00E+3 -> 0E+1
-dsbas634 toSci 0.00E+4 -> 0E+2
-dsbas635 toSci 0.00E+5 -> 0E+3
-dsbas636 toSci 0.00E+6 -> 0E+4
-dsbas637 toSci 0.00E+7 -> 0E+5
-dsbas638 toSci 0.00E+8 -> 0E+6
-dsbas639 toSci 0.00E+9 -> 0E+7
-
-dsbas640 toSci 0.0E+0 -> 0.0
-dsbas641 toSci 0.0E+1 -> 0
-dsbas642 toSci 0.0E+2 -> 0E+1
-dsbas643 toSci 0.0E+3 -> 0E+2
-dsbas644 toSci 0.0E+4 -> 0E+3
-dsbas645 toSci 0.0E+5 -> 0E+4
-dsbas646 toSci 0.0E+6 -> 0E+5
-dsbas647 toSci 0.0E+7 -> 0E+6
-dsbas648 toSci 0.0E+8 -> 0E+7
-dsbas649 toSci 0.0E+9 -> 0E+8
-
-dsbas650 toSci 0E+0 -> 0
-dsbas651 toSci 0E+1 -> 0E+1
-dsbas652 toSci 0E+2 -> 0E+2
-dsbas653 toSci 0E+3 -> 0E+3
-dsbas654 toSci 0E+4 -> 0E+4
-dsbas655 toSci 0E+5 -> 0E+5
-dsbas656 toSci 0E+6 -> 0E+6
-dsbas657 toSci 0E+7 -> 0E+7
-dsbas658 toSci 0E+8 -> 0E+8
-dsbas659 toSci 0E+9 -> 0E+9
-
-dsbas660 toSci 0.0E-0 -> 0.0
-dsbas661 toSci 0.0E-1 -> 0.00
-dsbas662 toSci 0.0E-2 -> 0.000
-dsbas663 toSci 0.0E-3 -> 0.0000
-dsbas664 toSci 0.0E-4 -> 0.00000
-dsbas665 toSci 0.0E-5 -> 0.000000
-dsbas666 toSci 0.0E-6 -> 0E-7
-dsbas667 toSci 0.0E-7 -> 0E-8
-dsbas668 toSci 0.0E-8 -> 0E-9
-dsbas669 toSci 0.0E-9 -> 0E-10
-
-dsbas670 toSci 0.00E-0 -> 0.00
-dsbas671 toSci 0.00E-1 -> 0.000
-dsbas672 toSci 0.00E-2 -> 0.0000
-dsbas673 toSci 0.00E-3 -> 0.00000
-dsbas674 toSci 0.00E-4 -> 0.000000
-dsbas675 toSci 0.00E-5 -> 0E-7
-dsbas676 toSci 0.00E-6 -> 0E-8
-dsbas677 toSci 0.00E-7 -> 0E-9
-dsbas678 toSci 0.00E-8 -> 0E-10
-dsbas679 toSci 0.00E-9 -> 0E-11
-
-dsbas680 toSci 000000. -> 0
-dsbas681 toSci 00000. -> 0
-dsbas682 toSci 0000. -> 0
-dsbas683 toSci 000. -> 0
-dsbas684 toSci 00. -> 0
-dsbas685 toSci 0. -> 0
-dsbas686 toSci +00000. -> 0
-dsbas687 toSci -00000. -> -0
-dsbas688 toSci +0. -> 0
-dsbas689 toSci -0. -> -0
-
--- Specials
-dsbas700 toSci "NaN" -> NaN
-dsbas701 toSci "nan" -> NaN
-dsbas702 toSci "nAn" -> NaN
-dsbas703 toSci "NAN" -> NaN
-dsbas704 toSci "+NaN" -> NaN
-dsbas705 toSci "+nan" -> NaN
-dsbas706 toSci "+nAn" -> NaN
-dsbas707 toSci "+NAN" -> NaN
-dsbas708 toSci "-NaN" -> -NaN
-dsbas709 toSci "-nan" -> -NaN
-dsbas710 toSci "-nAn" -> -NaN
-dsbas711 toSci "-NAN" -> -NaN
-dsbas712 toSci 'NaN0' -> NaN
-dsbas713 toSci 'NaN1' -> NaN1
-dsbas714 toSci 'NaN12' -> NaN12
-dsbas715 toSci 'NaN123' -> NaN123
-dsbas716 toSci 'NaN1234' -> NaN1234
-dsbas717 toSci 'NaN01' -> NaN1
-dsbas718 toSci 'NaN012' -> NaN12
-dsbas719 toSci 'NaN0123' -> NaN123
-dsbas720 toSci 'NaN01234' -> NaN1234
-dsbas721 toSci 'NaN001' -> NaN1
-dsbas722 toSci 'NaN0012' -> NaN12
-dsbas723 toSci 'NaN00123' -> NaN123
-dsbas724 toSci 'NaN001234' -> NaN1234
-dsbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
-dsbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
-dsbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
-dsbas728 toSci 'NaN-12' -> NaN Conversion_syntax
-dsbas729 toSci 'NaN+12' -> NaN Conversion_syntax
-
-dsbas730 toSci "sNaN" -> sNaN
-dsbas731 toSci "snan" -> sNaN
-dsbas732 toSci "SnAn" -> sNaN
-dsbas733 toSci "SNAN" -> sNaN
-dsbas734 toSci "+sNaN" -> sNaN
-dsbas735 toSci "+snan" -> sNaN
-dsbas736 toSci "+SnAn" -> sNaN
-dsbas737 toSci "+SNAN" -> sNaN
-dsbas738 toSci "-sNaN" -> -sNaN
-dsbas739 toSci "-snan" -> -sNaN
-dsbas740 toSci "-SnAn" -> -sNaN
-dsbas741 toSci "-SNAN" -> -sNaN
-dsbas742 toSci 'sNaN0000' -> sNaN
-dsbas743 toSci 'sNaN7' -> sNaN7
-dsbas744 toSci 'sNaN007234' -> sNaN7234
-dsbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
-dsbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
-dsbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
-
-dsbas748 toSci "Inf" -> Infinity
-dsbas749 toSci "inf" -> Infinity
-dsbas750 toSci "iNf" -> Infinity
-dsbas751 toSci "INF" -> Infinity
-dsbas752 toSci "+Inf" -> Infinity
-dsbas753 toSci "+inf" -> Infinity
-dsbas754 toSci "+iNf" -> Infinity
-dsbas755 toSci "+INF" -> Infinity
-dsbas756 toSci "-Inf" -> -Infinity
-dsbas757 toSci "-inf" -> -Infinity
-dsbas758 toSci "-iNf" -> -Infinity
-dsbas759 toSci "-INF" -> -Infinity
-
-dsbas760 toSci "Infinity" -> Infinity
-dsbas761 toSci "infinity" -> Infinity
-dsbas762 toSci "iNfInItY" -> Infinity
-dsbas763 toSci "INFINITY" -> Infinity
-dsbas764 toSci "+Infinity" -> Infinity
-dsbas765 toSci "+infinity" -> Infinity
-dsbas766 toSci "+iNfInItY" -> Infinity
-dsbas767 toSci "+INFINITY" -> Infinity
-dsbas768 toSci "-Infinity" -> -Infinity
-dsbas769 toSci "-infinity" -> -Infinity
-dsbas770 toSci "-iNfInItY" -> -Infinity
-dsbas771 toSci "-INFINITY" -> -Infinity
-
--- Specials and zeros for toEng
-dsbast772 toEng "NaN" -> NaN
-dsbast773 toEng "-Infinity" -> -Infinity
-dsbast774 toEng "-sNaN" -> -sNaN
-dsbast775 toEng "-NaN" -> -NaN
-dsbast776 toEng "+Infinity" -> Infinity
-dsbast778 toEng "+sNaN" -> sNaN
-dsbast779 toEng "+NaN" -> NaN
-dsbast780 toEng "INFINITY" -> Infinity
-dsbast781 toEng "SNAN" -> sNaN
-dsbast782 toEng "NAN" -> NaN
-dsbast783 toEng "infinity" -> Infinity
-dsbast784 toEng "snan" -> sNaN
-dsbast785 toEng "nan" -> NaN
-dsbast786 toEng "InFINITY" -> Infinity
-dsbast787 toEng "SnAN" -> sNaN
-dsbast788 toEng "nAN" -> NaN
-dsbast789 toEng "iNfinity" -> Infinity
-dsbast790 toEng "sNan" -> sNaN
-dsbast791 toEng "Nan" -> NaN
-dsbast792 toEng "Infinity" -> Infinity
-dsbast793 toEng "sNaN" -> sNaN
-
--- Zero toEng, etc.
-dsbast800 toEng 0e+1 -> "0.00E+3" -- doc example
-
-dsbast801 toEng 0.000000000 -> 0E-9
-dsbast802 toEng 0.00000000 -> 0.00E-6
-dsbast803 toEng 0.0000000 -> 0.0E-6
-dsbast804 toEng 0.000000 -> 0.000000
-dsbast805 toEng 0.00000 -> 0.00000
-dsbast806 toEng 0.0000 -> 0.0000
-dsbast807 toEng 0.000 -> 0.000
-dsbast808 toEng 0.00 -> 0.00
-dsbast809 toEng 0.0 -> 0.0
-dsbast810 toEng .0 -> 0.0
-dsbast811 toEng 0. -> 0
-dsbast812 toEng -.0 -> -0.0
-dsbast813 toEng -0. -> -0
-dsbast814 toEng -0.0 -> -0.0
-dsbast815 toEng -0.00 -> -0.00
-dsbast816 toEng -0.000 -> -0.000
-dsbast817 toEng -0.0000 -> -0.0000
-dsbast818 toEng -0.00000 -> -0.00000
-dsbast819 toEng -0.000000 -> -0.000000
-dsbast820 toEng -0.0000000 -> -0.0E-6
-dsbast821 toEng -0.00000000 -> -0.00E-6
-dsbast822 toEng -0.000000000 -> -0E-9
-
-dsbast830 toEng 0.00E+0 -> 0.00
-dsbast831 toEng 0.00E+1 -> 0.0
-dsbast832 toEng 0.00E+2 -> 0
-dsbast833 toEng 0.00E+3 -> 0.00E+3
-dsbast834 toEng 0.00E+4 -> 0.0E+3
-dsbast835 toEng 0.00E+5 -> 0E+3
-dsbast836 toEng 0.00E+6 -> 0.00E+6
-dsbast837 toEng 0.00E+7 -> 0.0E+6
-dsbast838 toEng 0.00E+8 -> 0E+6
-dsbast839 toEng 0.00E+9 -> 0.00E+9
-
-dsbast840 toEng 0.0E+0 -> 0.0
-dsbast841 toEng 0.0E+1 -> 0
-dsbast842 toEng 0.0E+2 -> 0.00E+3
-dsbast843 toEng 0.0E+3 -> 0.0E+3
-dsbast844 toEng 0.0E+4 -> 0E+3
-dsbast845 toEng 0.0E+5 -> 0.00E+6
-dsbast846 toEng 0.0E+6 -> 0.0E+6
-dsbast847 toEng 0.0E+7 -> 0E+6
-dsbast848 toEng 0.0E+8 -> 0.00E+9
-dsbast849 toEng 0.0E+9 -> 0.0E+9
-
-dsbast850 toEng 0E+0 -> 0
-dsbast851 toEng 0E+1 -> 0.00E+3
-dsbast852 toEng 0E+2 -> 0.0E+3
-dsbast853 toEng 0E+3 -> 0E+3
-dsbast854 toEng 0E+4 -> 0.00E+6
-dsbast855 toEng 0E+5 -> 0.0E+6
-dsbast856 toEng 0E+6 -> 0E+6
-dsbast857 toEng 0E+7 -> 0.00E+9
-dsbast858 toEng 0E+8 -> 0.0E+9
-dsbast859 toEng 0E+9 -> 0E+9
-
-dsbast860 toEng 0.0E-0 -> 0.0
-dsbast861 toEng 0.0E-1 -> 0.00
-dsbast862 toEng 0.0E-2 -> 0.000
-dsbast863 toEng 0.0E-3 -> 0.0000
-dsbast864 toEng 0.0E-4 -> 0.00000
-dsbast865 toEng 0.0E-5 -> 0.000000
-dsbast866 toEng 0.0E-6 -> 0.0E-6
-dsbast867 toEng 0.0E-7 -> 0.00E-6
-dsbast868 toEng 0.0E-8 -> 0E-9
-dsbast869 toEng 0.0E-9 -> 0.0E-9
-
-dsbast870 toEng 0.00E-0 -> 0.00
-dsbast871 toEng 0.00E-1 -> 0.000
-dsbast872 toEng 0.00E-2 -> 0.0000
-dsbast873 toEng 0.00E-3 -> 0.00000
-dsbast874 toEng 0.00E-4 -> 0.000000
-dsbast875 toEng 0.00E-5 -> 0.0E-6
-dsbast876 toEng 0.00E-6 -> 0.00E-6
-dsbast877 toEng 0.00E-7 -> 0E-9
-dsbast878 toEng 0.00E-8 -> 0.0E-9
-dsbast879 toEng 0.00E-9 -> 0.00E-9
-
--- long input strings
-dsbas801 tosci '01234567' -> 1234567
-dsbas802 tosci '001234567' -> 1234567
-dsbas803 tosci '0001234567' -> 1234567
-dsbas804 tosci '00001234567' -> 1234567
-dsbas805 tosci '000001234567' -> 1234567
-dsbas806 tosci '0000001234567' -> 1234567
-dsbas807 tosci '00000001234567' -> 1234567
-dsbas808 tosci '000000001234567' -> 1234567
-dsbas809 tosci '0000000001234567' -> 1234567
-dsbas810 tosci '00000000001234567' -> 1234567
-
-dsbas811 tosci '0.1234567' -> 0.1234567
-dsbas812 tosci '0.01234567' -> 0.01234567
-dsbas813 tosci '0.001234567' -> 0.001234567
-dsbas814 tosci '0.0001234567' -> 0.0001234567
-dsbas815 tosci '0.00001234567' -> 0.00001234567
-dsbas816 tosci '0.000001234567' -> 0.000001234567
-dsbas817 tosci '0.0000001234567' -> 1.234567E-7
-dsbas818 tosci '0.00000001234567' -> 1.234567E-8
-dsbas819 tosci '0.000000001234567' -> 1.234567E-9
-dsbas820 tosci '0.0000000001234567' -> 1.234567E-10
-
-dsbas821 tosci '123456790' -> 1.234568E+8 Inexact Rounded
-dsbas822 tosci '1234567901' -> 1.234568E+9 Inexact Rounded
-dsbas823 tosci '12345679012' -> 1.234568E+10 Inexact Rounded
-dsbas824 tosci '123456790123' -> 1.234568E+11 Inexact Rounded
-dsbas825 tosci '1234567901234' -> 1.234568E+12 Inexact Rounded
-dsbas826 tosci '12345679012345' -> 1.234568E+13 Inexact Rounded
-dsbas827 tosci '123456790123456' -> 1.234568E+14 Inexact Rounded
-dsbas828 tosci '1234567901234567' -> 1.234568E+15 Inexact Rounded
-dsbas829 tosci '1234567890123456' -> 1.234568E+15 Inexact Rounded
-
--- subnormals and overflows
-dsbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
-dsbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
-dsbas908 toSci '0.9e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas909 toSci '0.09e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
-dsbas911 toSci '10e-1000000000' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
-dsbas913 toSci '99e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
-dsbas915 toSci '1111e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas916 toSci '1111e-99999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
--- negatives the same
-dsbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
-dsbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
-dsbas920 toSci '-0.9e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas921 toSci '-0.09e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
-dsbas923 toSci '-10e-1000000000' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
-dsbas925 toSci '-99e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
-dsbas927 toSci '-1111e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas928 toSci '-1111e-99999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
-
--- overflow results at different rounding modes
-rounding: ceiling
-dsbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas931 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
-rounding: up
-dsbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: down
-dsbas934 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
-dsbas935 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
-rounding: floor
-dsbas936 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
-dsbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_up
-dsbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_even
-dsbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-rounding: half_down
-dsbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
-dsbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
-
-rounding: half_even
-
--- Now check 854/754r some subnormals and underflow to 0
-dsbem400 toSci 1.0000E-86 -> 1.0000E-86
-dsbem401 toSci 0.1E-97 -> 1E-98 Subnormal
-dsbem402 toSci 0.1000E-97 -> 1.000E-98 Subnormal
-dsbem403 toSci 0.0100E-97 -> 1.00E-99 Subnormal
-dsbem404 toSci 0.0010E-97 -> 1.0E-100 Subnormal
-dsbem405 toSci 0.0001E-97 -> 1E-101 Subnormal
-dsbem406 toSci 0.00010E-97 -> 1E-101 Subnormal Rounded
-dsbem407 toSci 0.00013E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem408 toSci 0.00015E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem409 toSci 0.00017E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem410 toSci 0.00023E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem411 toSci 0.00025E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem412 toSci 0.00027E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
-dsbem413 toSci 0.000149E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem414 toSci 0.000150E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem415 toSci 0.000151E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem416 toSci 0.000249E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem417 toSci 0.000250E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
-dsbem418 toSci 0.000251E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
-dsbem419 toSci 0.00009E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem420 toSci 0.00005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem421 toSci 0.00003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem422 toSci 0.000009E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem423 toSci 0.000005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem424 toSci 0.000003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
-dsbem425 toSci 0.001049E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem426 toSci 0.001050E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem427 toSci 0.001051E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
-dsbem428 toSci 0.001149E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
-dsbem429 toSci 0.001150E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
-dsbem430 toSci 0.001151E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
-
-dsbem432 toSci 0.010049E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem433 toSci 0.010050E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem434 toSci 0.010051E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
-dsbem435 toSci 0.010149E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
-dsbem436 toSci 0.010150E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
-dsbem437 toSci 0.010151E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
-
-dsbem440 toSci 0.10103E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem441 toSci 0.10105E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem442 toSci 0.10107E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem443 toSci 0.10113E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem444 toSci 0.10115E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
-dsbem445 toSci 0.10117E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
-
-dsbem450 toSci 1.10730E-98 -> 1.107E-98 Underflow Subnormal Inexact Rounded
-dsbem451 toSci 1.10750E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem452 toSci 1.10770E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem453 toSci 1.10830E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem454 toSci 1.10850E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
-dsbem455 toSci 1.10870E-98 -> 1.109E-98 Underflow Subnormal Inexact Rounded
-
--- make sure sign OK
-dsbem456 toSci -0.10103E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem457 toSci -0.10105E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
-dsbem458 toSci -0.10107E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem459 toSci -0.10113E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
-dsbem460 toSci -0.10115E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
-dsbem461 toSci -0.10117E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
-
--- '999s' cases
-dsbem464 toSci 999999E-98 -> 9.99999E-93
-dsbem465 toSci 99999.0E-97 -> 9.99990E-93
-dsbem466 toSci 99999.E-97 -> 9.9999E-93
-dsbem467 toSci 9999.9E-97 -> 9.9999E-94
-dsbem468 toSci 999.99E-97 -> 9.9999E-95
-dsbem469 toSci 99.999E-97 -> 9.9999E-96 Subnormal
-dsbem470 toSci 9.9999E-97 -> 9.9999E-97 Subnormal
-dsbem471 toSci 0.99999E-97 -> 1.0000E-97 Underflow Subnormal Inexact Rounded
-dsbem472 toSci 0.099999E-97 -> 1.000E-98 Underflow Subnormal Inexact Rounded
-dsbem473 toSci 0.0099999E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
-dsbem474 toSci 0.00099999E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
-dsbem475 toSci 0.000099999E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
-dsbem476 toSci 0.0000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem477 toSci 0.00000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbem478 toSci 0.000000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
--- Exponents with insignificant leading zeros
-dsbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
-dsbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
-dsbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
-dsbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
-dsbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
-dsbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
-dsbas1007 toSci 1e-999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1008 toSci 1e-0999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1009 toSci 1e-00999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1010 toSci 1e-000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1011 toSci 1e-000000000000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-dsbas1012 toSci 1e-000000000001000000007 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
-
--- check for double-rounded subnormals
-dsbas1041 toSci 1.1152444E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-dsbas1042 toSci 1.1152445E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-dsbas1043 toSci 1.1152446E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
-
--- clamped zeros [see also clamp.decTest]
-dsbas1075 toSci 0e+10000 -> 0E+90 Clamped
-dsbas1076 toSci 0e-10000 -> 0E-101 Clamped
-dsbas1077 toSci -0e+10000 -> -0E+90 Clamped
-dsbas1078 toSci -0e-10000 -> -0E-101 Clamped
-
--- extreme values from next-wider
-dsbas1101 toSci -9.999999999999999E+384 -> -Infinity Overflow Inexact Rounded
-dsbas1102 toSci -1E-383 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1103 toSci -1E-398 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1104 toSci -0 -> -0
-dsbas1105 toSci +0 -> 0
-dsbas1106 toSci +1E-398 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1107 toSci +1E-383 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
-dsbas1108 toSci +9.999999999999999E+384 -> Infinity Overflow Inexact Rounded
-
--- narrowing case
-dsbas1110 toSci 2.000000000000000E-99 -> 2.00E-99 Rounded Subnormal
+------------------------------------------------------------------------
+-- dsBase.decTest -- base decSingle <--> string conversions --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This file tests base conversions from string to a decimal number
+-- and back to a string (in Scientific form)
+
+-- Note that unlike other operations the operand is subject to rounding
+-- to conform to emax and precision settings (that is, numbers will
+-- conform to rules and exponent will be in permitted range). The
+-- 'left hand side', therefore, may have numbers that cannot be
+-- represented in a decSingle. Some testcases go to the limit of the
+-- next-wider format, and hence these testcases may also be used to
+-- test narrowing and widening operations.
+
+extended: 1
+clamp: 1
+precision: 7
+maxExponent: 96
+minExponent: -95
+rounding: half_even
+
+dsbas001 toSci 0 -> 0
+dsbas002 toSci 1 -> 1
+dsbas003 toSci 1.0 -> 1.0
+dsbas004 toSci 1.00 -> 1.00
+dsbas005 toSci 10 -> 10
+dsbas006 toSci 1000 -> 1000
+dsbas007 toSci 10.0 -> 10.0
+dsbas008 toSci 10.1 -> 10.1
+dsbas009 toSci 10.4 -> 10.4
+dsbas010 toSci 10.5 -> 10.5
+dsbas011 toSci 10.6 -> 10.6
+dsbas012 toSci 10.9 -> 10.9
+dsbas013 toSci 11.0 -> 11.0
+dsbas014 toSci 1.234 -> 1.234
+dsbas015 toSci 0.123 -> 0.123
+dsbas016 toSci 0.012 -> 0.012
+dsbas017 toSci -0 -> -0
+dsbas018 toSci -0.0 -> -0.0
+dsbas019 toSci -00.00 -> -0.00
+
+dsbas021 toSci -1 -> -1
+dsbas022 toSci -1.0 -> -1.0
+dsbas023 toSci -0.1 -> -0.1
+dsbas024 toSci -9.1 -> -9.1
+dsbas025 toSci -9.11 -> -9.11
+dsbas026 toSci -9.119 -> -9.119
+dsbas027 toSci -9.999 -> -9.999
+
+dsbas030 toSci '1234.567' -> '1234.567'
+dsbas031 toSci '1234.000' -> '1234.000'
+dsbas032 toSci '1234912' -> '1234912'
+dsbas033 toSci '0.00001234567' -> '0.00001234567'
+dsbas034 toSci '0.000001234567' -> '0.000001234567'
+dsbas035 toSci '0.0000001234567' -> '1.234567E-7'
+dsbas036 toSci '0.00000001234567' -> '1.234567E-8'
+
+dsbas037 toSci '0.1234564' -> '0.1234564'
+dsbas038 toSci '0.1234565' -> '0.1234565'
+
+-- test finite bounds (Negs of, then 0, Ntiny, Nmin, other, Nmax)
+dsbsn001 toSci -9.999999E+96 -> -9.999999E+96
+dsbsn002 toSci -1E-95 -> -1E-95
+dsbsn003 toSci -1E-101 -> -1E-101 Subnormal
+dsbsn004 toSci -0 -> -0
+dsbsn005 toSci +0 -> 0
+dsbsn006 toSci +1E-101 -> 1E-101 Subnormal
+dsbsn007 toSci +1E-95 -> 1E-95
+dsbsn008 toSci +9.999999E+96 -> 9.999999E+96
+
+-- String [many more examples are implicitly tested elsewhere]
+-- strings without E cannot generate E in result
+dsbas040 toSci "12" -> '12'
+dsbas041 toSci "-76" -> '-76'
+dsbas042 toSci "12.76" -> '12.76'
+dsbas043 toSci "+12.76" -> '12.76'
+dsbas044 toSci "012.76" -> '12.76'
+dsbas045 toSci "+0.003" -> '0.003'
+dsbas046 toSci "17." -> '17'
+dsbas047 toSci ".5" -> '0.5'
+dsbas048 toSci "044" -> '44'
+dsbas049 toSci "0044" -> '44'
+dsbas050 toSci "0.0005" -> '0.0005'
+dsbas051 toSci "00.00005" -> '0.00005'
+dsbas052 toSci "0.000005" -> '0.000005'
+dsbas053 toSci "0.0000050" -> '0.0000050'
+dsbas054 toSci "0.0000005" -> '5E-7'
+dsbas055 toSci "0.00000005" -> '5E-8'
+dsbas056 toSci "12678.54" -> '12678.54'
+dsbas057 toSci "2678.543" -> '2678.543'
+dsbas058 toSci "345678.5" -> '345678.5'
+dsbas059 toSci "0678.5432" -> '678.5432'
+dsbas060 toSci "678.5432" -> '678.5432'
+dsbas061 toSci "+678.5432" -> '678.5432'
+dsbas062 toSci "+0678.5432" -> '678.5432'
+dsbas063 toSci "+00678.5432" -> '678.5432'
+dsbas064 toSci "-678.5432" -> '-678.5432'
+dsbas065 toSci "-0678.5432" -> '-678.5432'
+dsbas066 toSci "-00678.5432" -> '-678.5432'
+-- examples
+dsbas067 toSci "5E-6" -> '0.000005'
+dsbas068 toSci "50E-7" -> '0.0000050'
+dsbas069 toSci "5E-7" -> '5E-7'
+
+-- [No exotics as no Unicode]
+
+-- rounded with dots in all (including edge) places
+dsbas071 toSci .1234567890123456 -> 0.1234568 Inexact Rounded
+dsbas072 toSci 1.234567890123456 -> 1.234568 Inexact Rounded
+dsbas073 toSci 12.34567890123456 -> 12.34568 Inexact Rounded
+dsbas074 toSci 123.4567890123456 -> 123.4568 Inexact Rounded
+dsbas075 toSci 1234.567890123456 -> 1234.568 Inexact Rounded
+dsbas076 toSci 12345.67890123456 -> 12345.68 Inexact Rounded
+dsbas077 toSci 123456.7890123456 -> 123456.8 Inexact Rounded
+dsbas078 toSci 1234567.890123456 -> 1234568 Inexact Rounded
+dsbas079 toSci 12345678.90123456 -> 1.234568E+7 Inexact Rounded
+dsbas080 toSci 123456789.0123456 -> 1.234568E+8 Inexact Rounded
+dsbas081 toSci 1234567890.123456 -> 1.234568E+9 Inexact Rounded
+dsbas082 toSci 12345678901.23456 -> 1.234568E+10 Inexact Rounded
+dsbas083 toSci 123456789012.3456 -> 1.234568E+11 Inexact Rounded
+dsbas084 toSci 1234567890123.456 -> 1.234568E+12 Inexact Rounded
+dsbas085 toSci 12345678901234.56 -> 1.234568E+13 Inexact Rounded
+dsbas086 toSci 123456789012345.6 -> 1.234568E+14 Inexact Rounded
+dsbas087 toSci 1234567890123456. -> 1.234568E+15 Inexact Rounded
+dsbas088 toSci 1234567890123456 -> 1.234568E+15 Inexact Rounded
+
+-- Numbers with E
+dsbas130 toSci "0.000E-1" -> '0.0000'
+dsbas131 toSci "0.000E-2" -> '0.00000'
+dsbas132 toSci "0.000E-3" -> '0.000000'
+dsbas133 toSci "0.000E-4" -> '0E-7'
+dsbas134 toSci "0.00E-2" -> '0.0000'
+dsbas135 toSci "0.00E-3" -> '0.00000'
+dsbas136 toSci "0.00E-4" -> '0.000000'
+dsbas137 toSci "0.00E-5" -> '0E-7'
+dsbas138 toSci "+0E+9" -> '0E+9'
+dsbas139 toSci "-0E+9" -> '-0E+9'
+dsbas140 toSci "1E+9" -> '1E+9'
+dsbas141 toSci "1e+09" -> '1E+9'
+dsbas142 toSci "1E+90" -> '1E+90'
+dsbas143 toSci "+1E+009" -> '1E+9'
+dsbas144 toSci "0E+9" -> '0E+9'
+dsbas145 toSci "1E+9" -> '1E+9'
+dsbas146 toSci "1E+09" -> '1E+9'
+dsbas147 toSci "1e+90" -> '1E+90'
+dsbas148 toSci "1E+009" -> '1E+9'
+dsbas149 toSci "000E+9" -> '0E+9'
+dsbas150 toSci "1E9" -> '1E+9'
+dsbas151 toSci "1e09" -> '1E+9'
+dsbas152 toSci "1E90" -> '1E+90'
+dsbas153 toSci "1E009" -> '1E+9'
+dsbas154 toSci "0E9" -> '0E+9'
+dsbas155 toSci "0.000e+0" -> '0.000'
+dsbas156 toSci "0.000E-1" -> '0.0000'
+dsbas157 toSci "4E+9" -> '4E+9'
+dsbas158 toSci "44E+9" -> '4.4E+10'
+dsbas159 toSci "0.73e-7" -> '7.3E-8'
+dsbas160 toSci "00E+9" -> '0E+9'
+dsbas161 toSci "00E-9" -> '0E-9'
+dsbas162 toSci "10E+9" -> '1.0E+10'
+dsbas163 toSci "10E+09" -> '1.0E+10'
+dsbas164 toSci "10e+90" -> '1.0E+91'
+dsbas165 toSci "10E+009" -> '1.0E+10'
+dsbas166 toSci "100e+9" -> '1.00E+11'
+dsbas167 toSci "100e+09" -> '1.00E+11'
+dsbas168 toSci "100E+90" -> '1.00E+92'
+dsbas169 toSci "100e+009" -> '1.00E+11'
+
+dsbas170 toSci "1.265" -> '1.265'
+dsbas171 toSci "1.265E-20" -> '1.265E-20'
+dsbas172 toSci "1.265E-8" -> '1.265E-8'
+dsbas173 toSci "1.265E-4" -> '0.0001265'
+dsbas174 toSci "1.265E-3" -> '0.001265'
+dsbas175 toSci "1.265E-2" -> '0.01265'
+dsbas176 toSci "1.265E-1" -> '0.1265'
+dsbas177 toSci "1.265E-0" -> '1.265'
+dsbas178 toSci "1.265E+1" -> '12.65'
+dsbas179 toSci "1.265E+2" -> '126.5'
+dsbas180 toSci "1.265E+3" -> '1265'
+dsbas181 toSci "1.265E+4" -> '1.265E+4'
+dsbas182 toSci "1.265E+8" -> '1.265E+8'
+dsbas183 toSci "1.265E+20" -> '1.265E+20'
+
+dsbas190 toSci "12.65" -> '12.65'
+dsbas191 toSci "12.65E-20" -> '1.265E-19'
+dsbas192 toSci "12.65E-8" -> '1.265E-7'
+dsbas193 toSci "12.65E-4" -> '0.001265'
+dsbas194 toSci "12.65E-3" -> '0.01265'
+dsbas195 toSci "12.65E-2" -> '0.1265'
+dsbas196 toSci "12.65E-1" -> '1.265'
+dsbas197 toSci "12.65E-0" -> '12.65'
+dsbas198 toSci "12.65E+1" -> '126.5'
+dsbas199 toSci "12.65E+2" -> '1265'
+dsbas200 toSci "12.65E+3" -> '1.265E+4'
+dsbas201 toSci "12.65E+4" -> '1.265E+5'
+dsbas202 toSci "12.65E+8" -> '1.265E+9'
+dsbas203 toSci "12.65E+20" -> '1.265E+21'
+
+dsbas210 toSci "126.5" -> '126.5'
+dsbas211 toSci "126.5E-20" -> '1.265E-18'
+dsbas212 toSci "126.5E-8" -> '0.000001265'
+dsbas213 toSci "126.5E-4" -> '0.01265'
+dsbas214 toSci "126.5E-3" -> '0.1265'
+dsbas215 toSci "126.5E-2" -> '1.265'
+dsbas216 toSci "126.5E-1" -> '12.65'
+dsbas217 toSci "126.5E-0" -> '126.5'
+dsbas218 toSci "126.5E+1" -> '1265'
+dsbas219 toSci "126.5E+2" -> '1.265E+4'
+dsbas220 toSci "126.5E+3" -> '1.265E+5'
+dsbas221 toSci "126.5E+4" -> '1.265E+6'
+dsbas222 toSci "126.5E+8" -> '1.265E+10'
+dsbas223 toSci "126.5E+20" -> '1.265E+22'
+
+dsbas230 toSci "1265" -> '1265'
+dsbas231 toSci "1265E-20" -> '1.265E-17'
+dsbas232 toSci "1265E-8" -> '0.00001265'
+dsbas233 toSci "1265E-4" -> '0.1265'
+dsbas234 toSci "1265E-3" -> '1.265'
+dsbas235 toSci "1265E-2" -> '12.65'
+dsbas236 toSci "1265E-1" -> '126.5'
+dsbas237 toSci "1265E-0" -> '1265'
+dsbas238 toSci "1265E+1" -> '1.265E+4'
+dsbas239 toSci "1265E+2" -> '1.265E+5'
+dsbas240 toSci "1265E+3" -> '1.265E+6'
+dsbas241 toSci "1265E+4" -> '1.265E+7'
+dsbas242 toSci "1265E+8" -> '1.265E+11'
+dsbas243 toSci "1265E+20" -> '1.265E+23'
+
+dsbas250 toSci "0.1265" -> '0.1265'
+dsbas251 toSci "0.1265E-20" -> '1.265E-21'
+dsbas252 toSci "0.1265E-8" -> '1.265E-9'
+dsbas253 toSci "0.1265E-4" -> '0.00001265'
+dsbas254 toSci "0.1265E-3" -> '0.0001265'
+dsbas255 toSci "0.1265E-2" -> '0.001265'
+dsbas256 toSci "0.1265E-1" -> '0.01265'
+dsbas257 toSci "0.1265E-0" -> '0.1265'
+dsbas258 toSci "0.1265E+1" -> '1.265'
+dsbas259 toSci "0.1265E+2" -> '12.65'
+dsbas260 toSci "0.1265E+3" -> '126.5'
+dsbas261 toSci "0.1265E+4" -> '1265'
+dsbas262 toSci "0.1265E+8" -> '1.265E+7'
+dsbas263 toSci "0.1265E+20" -> '1.265E+19'
+
+-- some more negative zeros [systematic tests below]
+dsbas290 toSci "-0.000E-1" -> '-0.0000'
+dsbas291 toSci "-0.000E-2" -> '-0.00000'
+dsbas292 toSci "-0.000E-3" -> '-0.000000'
+dsbas293 toSci "-0.000E-4" -> '-0E-7'
+dsbas294 toSci "-0.00E-2" -> '-0.0000'
+dsbas295 toSci "-0.00E-3" -> '-0.00000'
+dsbas296 toSci "-0.0E-2" -> '-0.000'
+dsbas297 toSci "-0.0E-3" -> '-0.0000'
+dsbas298 toSci "-0E-2" -> '-0.00'
+dsbas299 toSci "-0E-3" -> '-0.000'
+
+-- Engineering notation tests
+dsbas301 toSci 10e12 -> 1.0E+13
+dsbas302 toEng 10e12 -> 10E+12
+dsbas303 toSci 10e11 -> 1.0E+12
+dsbas304 toEng 10e11 -> 1.0E+12
+dsbas305 toSci 10e10 -> 1.0E+11
+dsbas306 toEng 10e10 -> 100E+9
+dsbas307 toSci 10e9 -> 1.0E+10
+dsbas308 toEng 10e9 -> 10E+9
+dsbas309 toSci 10e8 -> 1.0E+9
+dsbas310 toEng 10e8 -> 1.0E+9
+dsbas311 toSci 10e7 -> 1.0E+8
+dsbas312 toEng 10e7 -> 100E+6
+dsbas313 toSci 10e6 -> 1.0E+7
+dsbas314 toEng 10e6 -> 10E+6
+dsbas315 toSci 10e5 -> 1.0E+6
+dsbas316 toEng 10e5 -> 1.0E+6
+dsbas317 toSci 10e4 -> 1.0E+5
+dsbas318 toEng 10e4 -> 100E+3
+dsbas319 toSci 10e3 -> 1.0E+4
+dsbas320 toEng 10e3 -> 10E+3
+dsbas321 toSci 10e2 -> 1.0E+3
+dsbas322 toEng 10e2 -> 1.0E+3
+dsbas323 toSci 10e1 -> 1.0E+2
+dsbas324 toEng 10e1 -> 100
+dsbas325 toSci 10e0 -> 10
+dsbas326 toEng 10e0 -> 10
+dsbas327 toSci 10e-1 -> 1.0
+dsbas328 toEng 10e-1 -> 1.0
+dsbas329 toSci 10e-2 -> 0.10
+dsbas330 toEng 10e-2 -> 0.10
+dsbas331 toSci 10e-3 -> 0.010
+dsbas332 toEng 10e-3 -> 0.010
+dsbas333 toSci 10e-4 -> 0.0010
+dsbas334 toEng 10e-4 -> 0.0010
+dsbas335 toSci 10e-5 -> 0.00010
+dsbas336 toEng 10e-5 -> 0.00010
+dsbas337 toSci 10e-6 -> 0.000010
+dsbas338 toEng 10e-6 -> 0.000010
+dsbas339 toSci 10e-7 -> 0.0000010
+dsbas340 toEng 10e-7 -> 0.0000010
+dsbas341 toSci 10e-8 -> 1.0E-7
+dsbas342 toEng 10e-8 -> 100E-9
+dsbas343 toSci 10e-9 -> 1.0E-8
+dsbas344 toEng 10e-9 -> 10E-9
+dsbas345 toSci 10e-10 -> 1.0E-9
+dsbas346 toEng 10e-10 -> 1.0E-9
+dsbas347 toSci 10e-11 -> 1.0E-10
+dsbas348 toEng 10e-11 -> 100E-12
+dsbas349 toSci 10e-12 -> 1.0E-11
+dsbas350 toEng 10e-12 -> 10E-12
+dsbas351 toSci 10e-13 -> 1.0E-12
+dsbas352 toEng 10e-13 -> 1.0E-12
+
+dsbas361 toSci 7E12 -> 7E+12
+dsbas362 toEng 7E12 -> 7E+12
+dsbas363 toSci 7E11 -> 7E+11
+dsbas364 toEng 7E11 -> 700E+9
+dsbas365 toSci 7E10 -> 7E+10
+dsbas366 toEng 7E10 -> 70E+9
+dsbas367 toSci 7E9 -> 7E+9
+dsbas368 toEng 7E9 -> 7E+9
+dsbas369 toSci 7E8 -> 7E+8
+dsbas370 toEng 7E8 -> 700E+6
+dsbas371 toSci 7E7 -> 7E+7
+dsbas372 toEng 7E7 -> 70E+6
+dsbas373 toSci 7E6 -> 7E+6
+dsbas374 toEng 7E6 -> 7E+6
+dsbas375 toSci 7E5 -> 7E+5
+dsbas376 toEng 7E5 -> 700E+3
+dsbas377 toSci 7E4 -> 7E+4
+dsbas378 toEng 7E4 -> 70E+3
+dsbas379 toSci 7E3 -> 7E+3
+dsbas380 toEng 7E3 -> 7E+3
+dsbas381 toSci 7E2 -> 7E+2
+dsbas382 toEng 7E2 -> 700
+dsbas383 toSci 7E1 -> 7E+1
+dsbas384 toEng 7E1 -> 70
+dsbas385 toSci 7E0 -> 7
+dsbas386 toEng 7E0 -> 7
+dsbas387 toSci 7E-1 -> 0.7
+dsbas388 toEng 7E-1 -> 0.7
+dsbas389 toSci 7E-2 -> 0.07
+dsbas390 toEng 7E-2 -> 0.07
+dsbas391 toSci 7E-3 -> 0.007
+dsbas392 toEng 7E-3 -> 0.007
+dsbas393 toSci 7E-4 -> 0.0007
+dsbas394 toEng 7E-4 -> 0.0007
+dsbas395 toSci 7E-5 -> 0.00007
+dsbas396 toEng 7E-5 -> 0.00007
+dsbas397 toSci 7E-6 -> 0.000007
+dsbas398 toEng 7E-6 -> 0.000007
+dsbas399 toSci 7E-7 -> 7E-7
+dsbas400 toEng 7E-7 -> 700E-9
+dsbas401 toSci 7E-8 -> 7E-8
+dsbas402 toEng 7E-8 -> 70E-9
+dsbas403 toSci 7E-9 -> 7E-9
+dsbas404 toEng 7E-9 -> 7E-9
+dsbas405 toSci 7E-10 -> 7E-10
+dsbas406 toEng 7E-10 -> 700E-12
+dsbas407 toSci 7E-11 -> 7E-11
+dsbas408 toEng 7E-11 -> 70E-12
+dsbas409 toSci 7E-12 -> 7E-12
+dsbas410 toEng 7E-12 -> 7E-12
+dsbas411 toSci 7E-13 -> 7E-13
+dsbas412 toEng 7E-13 -> 700E-15
+
+-- Exacts remain exact up to precision ..
+dsbas420 toSci 100 -> 100
+dsbas422 toSci 1000 -> 1000
+dsbas424 toSci 999.9 -> 999.9
+dsbas426 toSci 1000.0 -> 1000.0
+dsbas428 toSci 1000.1 -> 1000.1
+dsbas430 toSci 10000 -> 10000
+dsbas432 toSci 1000 -> 1000
+dsbas434 toSci 10000 -> 10000
+dsbas436 toSci 100000 -> 100000
+dsbas438 toSci 1000000 -> 1000000
+dsbas440 toSci 10000000 -> 1.000000E+7 Rounded
+dsbas442 toSci 10000000 -> 1.000000E+7 Rounded
+dsbas444 toSci 10000003 -> 1.000000E+7 Rounded Inexact
+dsbas446 toSci 10000005 -> 1.000000E+7 Rounded Inexact
+dsbas448 toSci 100000050 -> 1.000000E+8 Rounded Inexact
+dsbas450 toSci 10000009 -> 1.000001E+7 Rounded Inexact
+dsbas452 toSci 100000000 -> 1.000000E+8 Rounded
+dsbas454 toSci 100000003 -> 1.000000E+8 Rounded Inexact
+dsbas456 toSci 100000005 -> 1.000000E+8 Rounded Inexact
+dsbas458 toSci 100000009 -> 1.000000E+8 Rounded Inexact
+dsbas460 toSci 1000000000 -> 1.000000E+9 Rounded
+dsbas462 toSci 1000000300 -> 1.000000E+9 Rounded Inexact
+dsbas464 toSci 1000000500 -> 1.000000E+9 Rounded Inexact
+dsbas466 toSci 1000000900 -> 1.000001E+9 Rounded Inexact
+dsbas468 toSci 10000000000 -> 1.000000E+10 Rounded
+dsbas470 toSci 10000003000 -> 1.000000E+10 Rounded Inexact
+dsbas472 toSci 10000005000 -> 1.000000E+10 Rounded Inexact
+dsbas474 toSci 10000009000 -> 1.000001E+10 Rounded Inexact
+
+-- check rounding modes heeded
+rounding: ceiling
+dsbsr401 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr402 toSci 1.11234549 -> 1.112346 Rounded Inexact
+dsbsr403 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr404 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: up
+dsbsr405 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr406 toSci 1.11234549 -> 1.112346 Rounded Inexact
+dsbsr407 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr408 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: floor
+dsbsr410 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr411 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr412 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr413 toSci 1.11234551 -> 1.112345 Rounded Inexact
+rounding: half_down
+dsbsr415 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr416 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr417 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr418 toSci 1.11234650 -> 1.112346 Rounded Inexact
+dsbsr419 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: half_even
+dsbsr421 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr422 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr423 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr424 toSci 1.11234650 -> 1.112346 Rounded Inexact
+dsbsr425 toSci 1.11234551 -> 1.112346 Rounded Inexact
+rounding: down
+dsbsr426 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr427 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr428 toSci 1.11234550 -> 1.112345 Rounded Inexact
+dsbsr429 toSci 1.11234551 -> 1.112345 Rounded Inexact
+rounding: half_up
+dsbsr431 toSci 1.1123450 -> 1.112345 Rounded
+dsbsr432 toSci 1.11234549 -> 1.112345 Rounded Inexact
+dsbsr433 toSci 1.11234550 -> 1.112346 Rounded Inexact
+dsbsr434 toSci 1.11234650 -> 1.112347 Rounded Inexact
+dsbsr435 toSci 1.11234551 -> 1.112346 Rounded Inexact
+-- negatives
+rounding: ceiling
+dsbsr501 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr502 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr503 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr504 toSci -1.11234551 -> -1.112345 Rounded Inexact
+rounding: up
+dsbsr505 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr506 toSci -1.11234549 -> -1.112346 Rounded Inexact
+dsbsr507 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr508 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: floor
+dsbsr510 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr511 toSci -1.11234549 -> -1.112346 Rounded Inexact
+dsbsr512 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr513 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: half_down
+dsbsr515 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr516 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr517 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr518 toSci -1.11234650 -> -1.112346 Rounded Inexact
+dsbsr519 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: half_even
+dsbsr521 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr522 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr523 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr524 toSci -1.11234650 -> -1.112346 Rounded Inexact
+dsbsr525 toSci -1.11234551 -> -1.112346 Rounded Inexact
+rounding: down
+dsbsr526 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr527 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr528 toSci -1.11234550 -> -1.112345 Rounded Inexact
+dsbsr529 toSci -1.11234551 -> -1.112345 Rounded Inexact
+rounding: half_up
+dsbsr531 toSci -1.1123450 -> -1.112345 Rounded
+dsbsr532 toSci -1.11234549 -> -1.112345 Rounded Inexact
+dsbsr533 toSci -1.11234550 -> -1.112346 Rounded Inexact
+dsbsr534 toSci -1.11234650 -> -1.112347 Rounded Inexact
+dsbsr535 toSci -1.11234551 -> -1.112346 Rounded Inexact
+
+rounding: half_even
+
+-- The 'baddies' tests from DiagBigDecimal, plus some new ones
+dsbas500 toSci '1..2' -> NaN Conversion_syntax
+dsbas501 toSci '.' -> NaN Conversion_syntax
+dsbas502 toSci '..' -> NaN Conversion_syntax
+dsbas503 toSci '++1' -> NaN Conversion_syntax
+dsbas504 toSci '--1' -> NaN Conversion_syntax
+dsbas505 toSci '-+1' -> NaN Conversion_syntax
+dsbas506 toSci '+-1' -> NaN Conversion_syntax
+dsbas507 toSci '12e' -> NaN Conversion_syntax
+dsbas508 toSci '12e++' -> NaN Conversion_syntax
+dsbas509 toSci '12f4' -> NaN Conversion_syntax
+dsbas510 toSci ' +1' -> NaN Conversion_syntax
+dsbas511 toSci '+ 1' -> NaN Conversion_syntax
+dsbas512 toSci '12 ' -> NaN Conversion_syntax
+dsbas513 toSci ' + 1' -> NaN Conversion_syntax
+dsbas514 toSci ' - 1 ' -> NaN Conversion_syntax
+dsbas515 toSci 'x' -> NaN Conversion_syntax
+dsbas516 toSci '-1-' -> NaN Conversion_syntax
+dsbas517 toSci '12-' -> NaN Conversion_syntax
+dsbas518 toSci '3+' -> NaN Conversion_syntax
+dsbas519 toSci '' -> NaN Conversion_syntax
+dsbas520 toSci '1e-' -> NaN Conversion_syntax
+dsbas521 toSci '7e99999a' -> NaN Conversion_syntax
+dsbas522 toSci '7e123567890x' -> NaN Conversion_syntax
+dsbas523 toSci '7e12356789012x' -> NaN Conversion_syntax
+dsbas524 toSci '' -> NaN Conversion_syntax
+dsbas525 toSci 'e100' -> NaN Conversion_syntax
+dsbas526 toSci '\u0e5a' -> NaN Conversion_syntax
+dsbas527 toSci '\u0b65' -> NaN Conversion_syntax
+dsbas528 toSci '123,65' -> NaN Conversion_syntax
+dsbas529 toSci '1.34.5' -> NaN Conversion_syntax
+dsbas530 toSci '.123.5' -> NaN Conversion_syntax
+dsbas531 toSci '01.35.' -> NaN Conversion_syntax
+dsbas532 toSci '01.35-' -> NaN Conversion_syntax
+dsbas533 toSci '0000..' -> NaN Conversion_syntax
+dsbas534 toSci '.0000.' -> NaN Conversion_syntax
+dsbas535 toSci '00..00' -> NaN Conversion_syntax
+dsbas536 toSci '111e*123' -> NaN Conversion_syntax
+dsbas537 toSci '111e123-' -> NaN Conversion_syntax
+dsbas538 toSci '111e+12+' -> NaN Conversion_syntax
+dsbas539 toSci '111e1-3-' -> NaN Conversion_syntax
+dsbas540 toSci '111e1*23' -> NaN Conversion_syntax
+dsbas541 toSci '111e1e+3' -> NaN Conversion_syntax
+dsbas542 toSci '1e1.0' -> NaN Conversion_syntax
+dsbas543 toSci '1e123e' -> NaN Conversion_syntax
+dsbas544 toSci 'ten' -> NaN Conversion_syntax
+dsbas545 toSci 'ONE' -> NaN Conversion_syntax
+dsbas546 toSci '1e.1' -> NaN Conversion_syntax
+dsbas547 toSci '1e1.' -> NaN Conversion_syntax
+dsbas548 toSci '1ee' -> NaN Conversion_syntax
+dsbas549 toSci 'e+1' -> NaN Conversion_syntax
+dsbas550 toSci '1.23.4' -> NaN Conversion_syntax
+dsbas551 toSci '1.2.1' -> NaN Conversion_syntax
+dsbas552 toSci '1E+1.2' -> NaN Conversion_syntax
+dsbas553 toSci '1E+1.2.3' -> NaN Conversion_syntax
+dsbas554 toSci '1E++1' -> NaN Conversion_syntax
+dsbas555 toSci '1E--1' -> NaN Conversion_syntax
+dsbas556 toSci '1E+-1' -> NaN Conversion_syntax
+dsbas557 toSci '1E-+1' -> NaN Conversion_syntax
+dsbas558 toSci '1E''1' -> NaN Conversion_syntax
+dsbas559 toSci "1E""1" -> NaN Conversion_syntax
+dsbas560 toSci "1E""""" -> NaN Conversion_syntax
+-- Near-specials
+dsbas561 toSci "qNaN" -> NaN Conversion_syntax
+dsbas562 toSci "NaNq" -> NaN Conversion_syntax
+dsbas563 toSci "NaNs" -> NaN Conversion_syntax
+dsbas564 toSci "Infi" -> NaN Conversion_syntax
+dsbas565 toSci "Infin" -> NaN Conversion_syntax
+dsbas566 toSci "Infini" -> NaN Conversion_syntax
+dsbas567 toSci "Infinit" -> NaN Conversion_syntax
+dsbas568 toSci "-Infinit" -> NaN Conversion_syntax
+dsbas569 toSci "0Inf" -> NaN Conversion_syntax
+dsbas570 toSci "9Inf" -> NaN Conversion_syntax
+dsbas571 toSci "-0Inf" -> NaN Conversion_syntax
+dsbas572 toSci "-9Inf" -> NaN Conversion_syntax
+dsbas573 toSci "-sNa" -> NaN Conversion_syntax
+dsbas574 toSci "xNaN" -> NaN Conversion_syntax
+dsbas575 toSci "0sNaN" -> NaN Conversion_syntax
+
+-- some baddies with dots and Es and dots and specials
+dsbas576 toSci 'e+1' -> NaN Conversion_syntax
+dsbas577 toSci '.e+1' -> NaN Conversion_syntax
+dsbas578 toSci '+.e+1' -> NaN Conversion_syntax
+dsbas579 toSci '-.e+' -> NaN Conversion_syntax
+dsbas580 toSci '-.e' -> NaN Conversion_syntax
+dsbas581 toSci 'E+1' -> NaN Conversion_syntax
+dsbas582 toSci '.E+1' -> NaN Conversion_syntax
+dsbas583 toSci '+.E+1' -> NaN Conversion_syntax
+dsbas584 toSci '-.E+' -> NaN Conversion_syntax
+dsbas585 toSci '-.E' -> NaN Conversion_syntax
+
+dsbas586 toSci '.NaN' -> NaN Conversion_syntax
+dsbas587 toSci '-.NaN' -> NaN Conversion_syntax
+dsbas588 toSci '+.sNaN' -> NaN Conversion_syntax
+dsbas589 toSci '+.Inf' -> NaN Conversion_syntax
+dsbas590 toSci '.Infinity' -> NaN Conversion_syntax
+
+-- Zeros
+dsbas601 toSci 0.000000000 -> 0E-9
+dsbas602 toSci 0.00000000 -> 0E-8
+dsbas603 toSci 0.0000000 -> 0E-7
+dsbas604 toSci 0.000000 -> 0.000000
+dsbas605 toSci 0.00000 -> 0.00000
+dsbas606 toSci 0.0000 -> 0.0000
+dsbas607 toSci 0.000 -> 0.000
+dsbas608 toSci 0.00 -> 0.00
+dsbas609 toSci 0.0 -> 0.0
+dsbas610 toSci .0 -> 0.0
+dsbas611 toSci 0. -> 0
+dsbas612 toSci -.0 -> -0.0
+dsbas613 toSci -0. -> -0
+dsbas614 toSci -0.0 -> -0.0
+dsbas615 toSci -0.00 -> -0.00
+dsbas616 toSci -0.000 -> -0.000
+dsbas617 toSci -0.0000 -> -0.0000
+dsbas618 toSci -0.00000 -> -0.00000
+dsbas619 toSci -0.000000 -> -0.000000
+dsbas620 toSci -0.0000000 -> -0E-7
+dsbas621 toSci -0.00000000 -> -0E-8
+dsbas622 toSci -0.000000000 -> -0E-9
+
+dsbas630 toSci 0.00E+0 -> 0.00
+dsbas631 toSci 0.00E+1 -> 0.0
+dsbas632 toSci 0.00E+2 -> 0
+dsbas633 toSci 0.00E+3 -> 0E+1
+dsbas634 toSci 0.00E+4 -> 0E+2
+dsbas635 toSci 0.00E+5 -> 0E+3
+dsbas636 toSci 0.00E+6 -> 0E+4
+dsbas637 toSci 0.00E+7 -> 0E+5
+dsbas638 toSci 0.00E+8 -> 0E+6
+dsbas639 toSci 0.00E+9 -> 0E+7
+
+dsbas640 toSci 0.0E+0 -> 0.0
+dsbas641 toSci 0.0E+1 -> 0
+dsbas642 toSci 0.0E+2 -> 0E+1
+dsbas643 toSci 0.0E+3 -> 0E+2
+dsbas644 toSci 0.0E+4 -> 0E+3
+dsbas645 toSci 0.0E+5 -> 0E+4
+dsbas646 toSci 0.0E+6 -> 0E+5
+dsbas647 toSci 0.0E+7 -> 0E+6
+dsbas648 toSci 0.0E+8 -> 0E+7
+dsbas649 toSci 0.0E+9 -> 0E+8
+
+dsbas650 toSci 0E+0 -> 0
+dsbas651 toSci 0E+1 -> 0E+1
+dsbas652 toSci 0E+2 -> 0E+2
+dsbas653 toSci 0E+3 -> 0E+3
+dsbas654 toSci 0E+4 -> 0E+4
+dsbas655 toSci 0E+5 -> 0E+5
+dsbas656 toSci 0E+6 -> 0E+6
+dsbas657 toSci 0E+7 -> 0E+7
+dsbas658 toSci 0E+8 -> 0E+8
+dsbas659 toSci 0E+9 -> 0E+9
+
+dsbas660 toSci 0.0E-0 -> 0.0
+dsbas661 toSci 0.0E-1 -> 0.00
+dsbas662 toSci 0.0E-2 -> 0.000
+dsbas663 toSci 0.0E-3 -> 0.0000
+dsbas664 toSci 0.0E-4 -> 0.00000
+dsbas665 toSci 0.0E-5 -> 0.000000
+dsbas666 toSci 0.0E-6 -> 0E-7
+dsbas667 toSci 0.0E-7 -> 0E-8
+dsbas668 toSci 0.0E-8 -> 0E-9
+dsbas669 toSci 0.0E-9 -> 0E-10
+
+dsbas670 toSci 0.00E-0 -> 0.00
+dsbas671 toSci 0.00E-1 -> 0.000
+dsbas672 toSci 0.00E-2 -> 0.0000
+dsbas673 toSci 0.00E-3 -> 0.00000
+dsbas674 toSci 0.00E-4 -> 0.000000
+dsbas675 toSci 0.00E-5 -> 0E-7
+dsbas676 toSci 0.00E-6 -> 0E-8
+dsbas677 toSci 0.00E-7 -> 0E-9
+dsbas678 toSci 0.00E-8 -> 0E-10
+dsbas679 toSci 0.00E-9 -> 0E-11
+
+dsbas680 toSci 000000. -> 0
+dsbas681 toSci 00000. -> 0
+dsbas682 toSci 0000. -> 0
+dsbas683 toSci 000. -> 0
+dsbas684 toSci 00. -> 0
+dsbas685 toSci 0. -> 0
+dsbas686 toSci +00000. -> 0
+dsbas687 toSci -00000. -> -0
+dsbas688 toSci +0. -> 0
+dsbas689 toSci -0. -> -0
+
+-- Specials
+dsbas700 toSci "NaN" -> NaN
+dsbas701 toSci "nan" -> NaN
+dsbas702 toSci "nAn" -> NaN
+dsbas703 toSci "NAN" -> NaN
+dsbas704 toSci "+NaN" -> NaN
+dsbas705 toSci "+nan" -> NaN
+dsbas706 toSci "+nAn" -> NaN
+dsbas707 toSci "+NAN" -> NaN
+dsbas708 toSci "-NaN" -> -NaN
+dsbas709 toSci "-nan" -> -NaN
+dsbas710 toSci "-nAn" -> -NaN
+dsbas711 toSci "-NAN" -> -NaN
+dsbas712 toSci 'NaN0' -> NaN
+dsbas713 toSci 'NaN1' -> NaN1
+dsbas714 toSci 'NaN12' -> NaN12
+dsbas715 toSci 'NaN123' -> NaN123
+dsbas716 toSci 'NaN1234' -> NaN1234
+dsbas717 toSci 'NaN01' -> NaN1
+dsbas718 toSci 'NaN012' -> NaN12
+dsbas719 toSci 'NaN0123' -> NaN123
+dsbas720 toSci 'NaN01234' -> NaN1234
+dsbas721 toSci 'NaN001' -> NaN1
+dsbas722 toSci 'NaN0012' -> NaN12
+dsbas723 toSci 'NaN00123' -> NaN123
+dsbas724 toSci 'NaN001234' -> NaN1234
+dsbas725 toSci 'NaN1234567890123456' -> NaN Conversion_syntax
+dsbas726 toSci 'NaN123e+1' -> NaN Conversion_syntax
+dsbas727 toSci 'NaN12.45' -> NaN Conversion_syntax
+dsbas728 toSci 'NaN-12' -> NaN Conversion_syntax
+dsbas729 toSci 'NaN+12' -> NaN Conversion_syntax
+
+dsbas730 toSci "sNaN" -> sNaN
+dsbas731 toSci "snan" -> sNaN
+dsbas732 toSci "SnAn" -> sNaN
+dsbas733 toSci "SNAN" -> sNaN
+dsbas734 toSci "+sNaN" -> sNaN
+dsbas735 toSci "+snan" -> sNaN
+dsbas736 toSci "+SnAn" -> sNaN
+dsbas737 toSci "+SNAN" -> sNaN
+dsbas738 toSci "-sNaN" -> -sNaN
+dsbas739 toSci "-snan" -> -sNaN
+dsbas740 toSci "-SnAn" -> -sNaN
+dsbas741 toSci "-SNAN" -> -sNaN
+dsbas742 toSci 'sNaN0000' -> sNaN
+dsbas743 toSci 'sNaN7' -> sNaN7
+dsbas744 toSci 'sNaN007234' -> sNaN7234
+dsbas745 toSci 'sNaN7234561234567890' -> NaN Conversion_syntax
+dsbas746 toSci 'sNaN72.45' -> NaN Conversion_syntax
+dsbas747 toSci 'sNaN-72' -> NaN Conversion_syntax
+
+dsbas748 toSci "Inf" -> Infinity
+dsbas749 toSci "inf" -> Infinity
+dsbas750 toSci "iNf" -> Infinity
+dsbas751 toSci "INF" -> Infinity
+dsbas752 toSci "+Inf" -> Infinity
+dsbas753 toSci "+inf" -> Infinity
+dsbas754 toSci "+iNf" -> Infinity
+dsbas755 toSci "+INF" -> Infinity
+dsbas756 toSci "-Inf" -> -Infinity
+dsbas757 toSci "-inf" -> -Infinity
+dsbas758 toSci "-iNf" -> -Infinity
+dsbas759 toSci "-INF" -> -Infinity
+
+dsbas760 toSci "Infinity" -> Infinity
+dsbas761 toSci "infinity" -> Infinity
+dsbas762 toSci "iNfInItY" -> Infinity
+dsbas763 toSci "INFINITY" -> Infinity
+dsbas764 toSci "+Infinity" -> Infinity
+dsbas765 toSci "+infinity" -> Infinity
+dsbas766 toSci "+iNfInItY" -> Infinity
+dsbas767 toSci "+INFINITY" -> Infinity
+dsbas768 toSci "-Infinity" -> -Infinity
+dsbas769 toSci "-infinity" -> -Infinity
+dsbas770 toSci "-iNfInItY" -> -Infinity
+dsbas771 toSci "-INFINITY" -> -Infinity
+
+-- Specials and zeros for toEng
+dsbast772 toEng "NaN" -> NaN
+dsbast773 toEng "-Infinity" -> -Infinity
+dsbast774 toEng "-sNaN" -> -sNaN
+dsbast775 toEng "-NaN" -> -NaN
+dsbast776 toEng "+Infinity" -> Infinity
+dsbast778 toEng "+sNaN" -> sNaN
+dsbast779 toEng "+NaN" -> NaN
+dsbast780 toEng "INFINITY" -> Infinity
+dsbast781 toEng "SNAN" -> sNaN
+dsbast782 toEng "NAN" -> NaN
+dsbast783 toEng "infinity" -> Infinity
+dsbast784 toEng "snan" -> sNaN
+dsbast785 toEng "nan" -> NaN
+dsbast786 toEng "InFINITY" -> Infinity
+dsbast787 toEng "SnAN" -> sNaN
+dsbast788 toEng "nAN" -> NaN
+dsbast789 toEng "iNfinity" -> Infinity
+dsbast790 toEng "sNan" -> sNaN
+dsbast791 toEng "Nan" -> NaN
+dsbast792 toEng "Infinity" -> Infinity
+dsbast793 toEng "sNaN" -> sNaN
+
+-- Zero toEng, etc.
+dsbast800 toEng 0e+1 -> "0.00E+3" -- doc example
+
+dsbast801 toEng 0.000000000 -> 0E-9
+dsbast802 toEng 0.00000000 -> 0.00E-6
+dsbast803 toEng 0.0000000 -> 0.0E-6
+dsbast804 toEng 0.000000 -> 0.000000
+dsbast805 toEng 0.00000 -> 0.00000
+dsbast806 toEng 0.0000 -> 0.0000
+dsbast807 toEng 0.000 -> 0.000
+dsbast808 toEng 0.00 -> 0.00
+dsbast809 toEng 0.0 -> 0.0
+dsbast810 toEng .0 -> 0.0
+dsbast811 toEng 0. -> 0
+dsbast812 toEng -.0 -> -0.0
+dsbast813 toEng -0. -> -0
+dsbast814 toEng -0.0 -> -0.0
+dsbast815 toEng -0.00 -> -0.00
+dsbast816 toEng -0.000 -> -0.000
+dsbast817 toEng -0.0000 -> -0.0000
+dsbast818 toEng -0.00000 -> -0.00000
+dsbast819 toEng -0.000000 -> -0.000000
+dsbast820 toEng -0.0000000 -> -0.0E-6
+dsbast821 toEng -0.00000000 -> -0.00E-6
+dsbast822 toEng -0.000000000 -> -0E-9
+
+dsbast830 toEng 0.00E+0 -> 0.00
+dsbast831 toEng 0.00E+1 -> 0.0
+dsbast832 toEng 0.00E+2 -> 0
+dsbast833 toEng 0.00E+3 -> 0.00E+3
+dsbast834 toEng 0.00E+4 -> 0.0E+3
+dsbast835 toEng 0.00E+5 -> 0E+3
+dsbast836 toEng 0.00E+6 -> 0.00E+6
+dsbast837 toEng 0.00E+7 -> 0.0E+6
+dsbast838 toEng 0.00E+8 -> 0E+6
+dsbast839 toEng 0.00E+9 -> 0.00E+9
+
+dsbast840 toEng 0.0E+0 -> 0.0
+dsbast841 toEng 0.0E+1 -> 0
+dsbast842 toEng 0.0E+2 -> 0.00E+3
+dsbast843 toEng 0.0E+3 -> 0.0E+3
+dsbast844 toEng 0.0E+4 -> 0E+3
+dsbast845 toEng 0.0E+5 -> 0.00E+6
+dsbast846 toEng 0.0E+6 -> 0.0E+6
+dsbast847 toEng 0.0E+7 -> 0E+6
+dsbast848 toEng 0.0E+8 -> 0.00E+9
+dsbast849 toEng 0.0E+9 -> 0.0E+9
+
+dsbast850 toEng 0E+0 -> 0
+dsbast851 toEng 0E+1 -> 0.00E+3
+dsbast852 toEng 0E+2 -> 0.0E+3
+dsbast853 toEng 0E+3 -> 0E+3
+dsbast854 toEng 0E+4 -> 0.00E+6
+dsbast855 toEng 0E+5 -> 0.0E+6
+dsbast856 toEng 0E+6 -> 0E+6
+dsbast857 toEng 0E+7 -> 0.00E+9
+dsbast858 toEng 0E+8 -> 0.0E+9
+dsbast859 toEng 0E+9 -> 0E+9
+
+dsbast860 toEng 0.0E-0 -> 0.0
+dsbast861 toEng 0.0E-1 -> 0.00
+dsbast862 toEng 0.0E-2 -> 0.000
+dsbast863 toEng 0.0E-3 -> 0.0000
+dsbast864 toEng 0.0E-4 -> 0.00000
+dsbast865 toEng 0.0E-5 -> 0.000000
+dsbast866 toEng 0.0E-6 -> 0.0E-6
+dsbast867 toEng 0.0E-7 -> 0.00E-6
+dsbast868 toEng 0.0E-8 -> 0E-9
+dsbast869 toEng 0.0E-9 -> 0.0E-9
+
+dsbast870 toEng 0.00E-0 -> 0.00
+dsbast871 toEng 0.00E-1 -> 0.000
+dsbast872 toEng 0.00E-2 -> 0.0000
+dsbast873 toEng 0.00E-3 -> 0.00000
+dsbast874 toEng 0.00E-4 -> 0.000000
+dsbast875 toEng 0.00E-5 -> 0.0E-6
+dsbast876 toEng 0.00E-6 -> 0.00E-6
+dsbast877 toEng 0.00E-7 -> 0E-9
+dsbast878 toEng 0.00E-8 -> 0.0E-9
+dsbast879 toEng 0.00E-9 -> 0.00E-9
+
+-- long input strings
+dsbas801 tosci '01234567' -> 1234567
+dsbas802 tosci '001234567' -> 1234567
+dsbas803 tosci '0001234567' -> 1234567
+dsbas804 tosci '00001234567' -> 1234567
+dsbas805 tosci '000001234567' -> 1234567
+dsbas806 tosci '0000001234567' -> 1234567
+dsbas807 tosci '00000001234567' -> 1234567
+dsbas808 tosci '000000001234567' -> 1234567
+dsbas809 tosci '0000000001234567' -> 1234567
+dsbas810 tosci '00000000001234567' -> 1234567
+
+dsbas811 tosci '0.1234567' -> 0.1234567
+dsbas812 tosci '0.01234567' -> 0.01234567
+dsbas813 tosci '0.001234567' -> 0.001234567
+dsbas814 tosci '0.0001234567' -> 0.0001234567
+dsbas815 tosci '0.00001234567' -> 0.00001234567
+dsbas816 tosci '0.000001234567' -> 0.000001234567
+dsbas817 tosci '0.0000001234567' -> 1.234567E-7
+dsbas818 tosci '0.00000001234567' -> 1.234567E-8
+dsbas819 tosci '0.000000001234567' -> 1.234567E-9
+dsbas820 tosci '0.0000000001234567' -> 1.234567E-10
+
+dsbas821 tosci '123456790' -> 1.234568E+8 Inexact Rounded
+dsbas822 tosci '1234567901' -> 1.234568E+9 Inexact Rounded
+dsbas823 tosci '12345679012' -> 1.234568E+10 Inexact Rounded
+dsbas824 tosci '123456790123' -> 1.234568E+11 Inexact Rounded
+dsbas825 tosci '1234567901234' -> 1.234568E+12 Inexact Rounded
+dsbas826 tosci '12345679012345' -> 1.234568E+13 Inexact Rounded
+dsbas827 tosci '123456790123456' -> 1.234568E+14 Inexact Rounded
+dsbas828 tosci '1234567901234567' -> 1.234568E+15 Inexact Rounded
+dsbas829 tosci '1234567890123456' -> 1.234568E+15 Inexact Rounded
+
+-- subnormals and overflows
+dsbas906 toSci '99e999999999' -> Infinity Overflow Inexact Rounded
+dsbas907 toSci '999e999999999' -> Infinity Overflow Inexact Rounded
+dsbas908 toSci '0.9e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas909 toSci '0.09e-999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas910 toSci '0.1e1000000000' -> Infinity Overflow Inexact Rounded
+dsbas911 toSci '10e-1000000000' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas912 toSci '0.9e9999999999' -> Infinity Overflow Inexact Rounded
+dsbas913 toSci '99e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas914 toSci '111e9999999999' -> Infinity Overflow Inexact Rounded
+dsbas915 toSci '1111e-9999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas916 toSci '1111e-99999999999' -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas917 toSci '7e1000000000' -> Infinity Overflow Inexact Rounded
+-- negatives the same
+dsbas918 toSci '-99e999999999' -> -Infinity Overflow Inexact Rounded
+dsbas919 toSci '-999e999999999' -> -Infinity Overflow Inexact Rounded
+dsbas920 toSci '-0.9e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas921 toSci '-0.09e-999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas922 toSci '-0.1e1000000000' -> -Infinity Overflow Inexact Rounded
+dsbas923 toSci '-10e-1000000000' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas924 toSci '-0.9e9999999999' -> -Infinity Overflow Inexact Rounded
+dsbas925 toSci '-99e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas926 toSci '-111e9999999999' -> -Infinity Overflow Inexact Rounded
+dsbas927 toSci '-1111e-9999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas928 toSci '-1111e-99999999999' -> -0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas929 toSci '-7e1000000000' -> -Infinity Overflow Inexact Rounded
+
+-- overflow results at different rounding modes
+rounding: ceiling
+dsbas930 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas931 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
+rounding: up
+dsbas932 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas933 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: down
+dsbas934 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
+dsbas935 toSci '-7e10000' -> -9.999999E+96 Overflow Inexact Rounded
+rounding: floor
+dsbas936 toSci '7e10000' -> 9.999999E+96 Overflow Inexact Rounded
+dsbas937 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_up
+dsbas938 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas939 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_even
+dsbas940 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas941 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+rounding: half_down
+dsbas942 toSci '7e10000' -> Infinity Overflow Inexact Rounded
+dsbas943 toSci '-7e10000' -> -Infinity Overflow Inexact Rounded
+
+rounding: half_even
+
+-- Now check 854/754r some subnormals and underflow to 0
+dsbem400 toSci 1.0000E-86 -> 1.0000E-86
+dsbem401 toSci 0.1E-97 -> 1E-98 Subnormal
+dsbem402 toSci 0.1000E-97 -> 1.000E-98 Subnormal
+dsbem403 toSci 0.0100E-97 -> 1.00E-99 Subnormal
+dsbem404 toSci 0.0010E-97 -> 1.0E-100 Subnormal
+dsbem405 toSci 0.0001E-97 -> 1E-101 Subnormal
+dsbem406 toSci 0.00010E-97 -> 1E-101 Subnormal Rounded
+dsbem407 toSci 0.00013E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem408 toSci 0.00015E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem409 toSci 0.00017E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem410 toSci 0.00023E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem411 toSci 0.00025E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem412 toSci 0.00027E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
+dsbem413 toSci 0.000149E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem414 toSci 0.000150E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem415 toSci 0.000151E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem416 toSci 0.000249E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem417 toSci 0.000250E-97 -> 2E-101 Underflow Subnormal Inexact Rounded
+dsbem418 toSci 0.000251E-97 -> 3E-101 Underflow Subnormal Inexact Rounded
+dsbem419 toSci 0.00009E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem420 toSci 0.00005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem421 toSci 0.00003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem422 toSci 0.000009E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem423 toSci 0.000005E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem424 toSci 0.000003E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+dsbem425 toSci 0.001049E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem426 toSci 0.001050E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem427 toSci 0.001051E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
+dsbem428 toSci 0.001149E-97 -> 1.1E-100 Underflow Subnormal Inexact Rounded
+dsbem429 toSci 0.001150E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
+dsbem430 toSci 0.001151E-97 -> 1.2E-100 Underflow Subnormal Inexact Rounded
+
+dsbem432 toSci 0.010049E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem433 toSci 0.010050E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem434 toSci 0.010051E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
+dsbem435 toSci 0.010149E-97 -> 1.01E-99 Underflow Subnormal Inexact Rounded
+dsbem436 toSci 0.010150E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
+dsbem437 toSci 0.010151E-97 -> 1.02E-99 Underflow Subnormal Inexact Rounded
+
+dsbem440 toSci 0.10103E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem441 toSci 0.10105E-97 -> 1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem442 toSci 0.10107E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem443 toSci 0.10113E-97 -> 1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem444 toSci 0.10115E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
+dsbem445 toSci 0.10117E-97 -> 1.012E-98 Underflow Subnormal Inexact Rounded
+
+dsbem450 toSci 1.10730E-98 -> 1.107E-98 Underflow Subnormal Inexact Rounded
+dsbem451 toSci 1.10750E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem452 toSci 1.10770E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem453 toSci 1.10830E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem454 toSci 1.10850E-98 -> 1.108E-98 Underflow Subnormal Inexact Rounded
+dsbem455 toSci 1.10870E-98 -> 1.109E-98 Underflow Subnormal Inexact Rounded
+
+-- make sure sign OK
+dsbem456 toSci -0.10103E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem457 toSci -0.10105E-97 -> -1.010E-98 Underflow Subnormal Inexact Rounded
+dsbem458 toSci -0.10107E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem459 toSci -0.10113E-97 -> -1.011E-98 Underflow Subnormal Inexact Rounded
+dsbem460 toSci -0.10115E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
+dsbem461 toSci -0.10117E-97 -> -1.012E-98 Underflow Subnormal Inexact Rounded
+
+-- '999s' cases
+dsbem464 toSci 999999E-98 -> 9.99999E-93
+dsbem465 toSci 99999.0E-97 -> 9.99990E-93
+dsbem466 toSci 99999.E-97 -> 9.9999E-93
+dsbem467 toSci 9999.9E-97 -> 9.9999E-94
+dsbem468 toSci 999.99E-97 -> 9.9999E-95
+dsbem469 toSci 99.999E-97 -> 9.9999E-96 Subnormal
+dsbem470 toSci 9.9999E-97 -> 9.9999E-97 Subnormal
+dsbem471 toSci 0.99999E-97 -> 1.0000E-97 Underflow Subnormal Inexact Rounded
+dsbem472 toSci 0.099999E-97 -> 1.000E-98 Underflow Subnormal Inexact Rounded
+dsbem473 toSci 0.0099999E-97 -> 1.00E-99 Underflow Subnormal Inexact Rounded
+dsbem474 toSci 0.00099999E-97 -> 1.0E-100 Underflow Subnormal Inexact Rounded
+dsbem475 toSci 0.000099999E-97 -> 1E-101 Underflow Subnormal Inexact Rounded
+dsbem476 toSci 0.0000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem477 toSci 0.00000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbem478 toSci 0.000000099999E-97 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+-- Exponents with insignificant leading zeros
+dsbas1001 toSci 1e999999999 -> Infinity Overflow Inexact Rounded
+dsbas1002 toSci 1e0999999999 -> Infinity Overflow Inexact Rounded
+dsbas1003 toSci 1e00999999999 -> Infinity Overflow Inexact Rounded
+dsbas1004 toSci 1e000999999999 -> Infinity Overflow Inexact Rounded
+dsbas1005 toSci 1e000000000000999999999 -> Infinity Overflow Inexact Rounded
+dsbas1006 toSci 1e000000000001000000007 -> Infinity Overflow Inexact Rounded
+dsbas1007 toSci 1e-999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1008 toSci 1e-0999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1009 toSci 1e-00999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1010 toSci 1e-000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1011 toSci 1e-000000000000999999999 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+dsbas1012 toSci 1e-000000000001000000007 -> 0E-101 Underflow Subnormal Inexact Rounded Clamped
+
+-- check for double-rounded subnormals
+dsbas1041 toSci 1.1152444E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+dsbas1042 toSci 1.1152445E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+dsbas1043 toSci 1.1152446E-96 -> 1.11524E-96 Inexact Rounded Subnormal Underflow
+
+-- clamped zeros [see also clamp.decTest]
+dsbas1075 toSci 0e+10000 -> 0E+90 Clamped
+dsbas1076 toSci 0e-10000 -> 0E-101 Clamped
+dsbas1077 toSci -0e+10000 -> -0E+90 Clamped
+dsbas1078 toSci -0e-10000 -> -0E-101 Clamped
+
+-- extreme values from next-wider
+dsbas1101 toSci -9.999999999999999E+384 -> -Infinity Overflow Inexact Rounded
+dsbas1102 toSci -1E-383 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1103 toSci -1E-398 -> -0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1104 toSci -0 -> -0
+dsbas1105 toSci +0 -> 0
+dsbas1106 toSci +1E-398 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1107 toSci +1E-383 -> 0E-101 Inexact Rounded Subnormal Underflow Clamped
+dsbas1108 toSci +9.999999999999999E+384 -> Infinity Overflow Inexact Rounded
+
+-- narrowing case
+dsbas1110 toSci 2.000000000000000E-99 -> 2.00E-99 Rounded Subnormal
diff --git a/Lib/test/decimaltestdata/dsEncode.decTest b/Lib/test/decimaltestdata/dsEncode.decTest
index 818578b1794..72647487595 100644
--- a/Lib/test/decimaltestdata/dsEncode.decTest
+++ b/Lib/test/decimaltestdata/dsEncode.decTest
@@ -1,372 +1,372 @@
-------------------------------------------------------------------------
--- dsEncode.decTest -- decimal four-byte format testcases --
--- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
--- [Previously called decimal32.decTest]
-version: 2.59
-
--- This set of tests is for the four-byte concrete representation.
--- Its characteristics are:
---
--- 1 bit sign
--- 5 bits combination field
--- 6 bits exponent continuation
--- 20 bits coefficient continuation
---
--- Total exponent length 8 bits
--- Total coefficient length 24 bits (7 digits)
---
--- Elimit = 191 (maximum encoded exponent)
--- Emax = 96 (largest exponent value)
--- Emin = -95 (smallest exponent value)
--- bias = 101 (subtracted from encoded exponent) = -Etiny
-
--- The testcases here have only exactly representable data on the
--- 'left-hand-side'; rounding from strings is tested in 'base'
--- testcase groups.
-
-extended: 1
-clamp: 1
-precision: 7
-rounding: half_up
-maxExponent: 96
-minExponent: -95
-
--- General testcases
--- (mostly derived from the Strawman 4 document and examples)
-decs001 apply #A23003D0 -> -7.50
-decs002 apply -7.50 -> #A23003D0
--- derivative canonical plain strings
-decs003 apply #A26003D0 -> -7.50E+3
-decs004 apply -7.50E+3 -> #A26003D0
-decs005 apply #A25003D0 -> -750
-decs006 apply -750 -> #A25003D0
-decs007 apply #A24003D0 -> -75.0
-decs008 apply -75.0 -> #A24003D0
-decs009 apply #A22003D0 -> -0.750
-decs010 apply -0.750 -> #A22003D0
-decs011 apply #A21003D0 -> -0.0750
-decs012 apply -0.0750 -> #A21003D0
-decs013 apply #A1f003D0 -> -0.000750
-decs014 apply -0.000750 -> #A1f003D0
-decs015 apply #A1d003D0 -> -0.00000750
-decs016 apply -0.00000750 -> #A1d003D0
-decs017 apply #A1c003D0 -> -7.50E-7
-decs018 apply -7.50E-7 -> #A1c003D0
-
--- Normality
-decs020 apply 1234567 -> #2654d2e7
-decs021 apply -1234567 -> #a654d2e7
-decs022 apply 1111111 -> #26524491
-
--- Nmax and similar
-decs031 apply 9.999999E+96 -> #77f3fcff
-decs032 apply #77f3fcff -> 9.999999E+96
-decs033 apply 1.234567E+96 -> #47f4d2e7
-decs034 apply #47f4d2e7 -> 1.234567E+96
--- fold-downs (more below)
-decs035 apply 1.23E+96 -> #47f4c000 Clamped
-decs036 apply #47f4c000 -> 1.230000E+96
-decs037 apply 1E+96 -> #47f00000 Clamped
-decs038 apply #47f00000 -> 1.000000E+96
-
-decs051 apply 12345 -> #225049c5
-decs052 apply #225049c5 -> 12345
-decs053 apply 1234 -> #22500534
-decs054 apply #22500534 -> 1234
-decs055 apply 123 -> #225000a3
-decs056 apply #225000a3 -> 123
-decs057 apply 12 -> #22500012
-decs058 apply #22500012 -> 12
-decs059 apply 1 -> #22500001
-decs060 apply #22500001 -> 1
-decs061 apply 1.23 -> #223000a3
-decs062 apply #223000a3 -> 1.23
-decs063 apply 123.45 -> #223049c5
-decs064 apply #223049c5 -> 123.45
-
--- Nmin and below
-decs071 apply 1E-95 -> #00600001
-decs072 apply #00600001 -> 1E-95
-decs073 apply 1.000000E-95 -> #04000000
-decs074 apply #04000000 -> 1.000000E-95
-decs075 apply 1.000001E-95 -> #04000001
-decs076 apply #04000001 -> 1.000001E-95
-
-decs077 apply 0.100000E-95 -> #00020000 Subnormal
-decs07x apply 1.00000E-96 -> 1.00000E-96 Subnormal
-decs078 apply #00020000 -> 1.00000E-96 Subnormal
-decs079 apply 0.000010E-95 -> #00000010 Subnormal
-decs080 apply #00000010 -> 1.0E-100 Subnormal
-decs081 apply 0.000001E-95 -> #00000001 Subnormal
-decs082 apply #00000001 -> 1E-101 Subnormal
-decs083 apply 1e-101 -> #00000001 Subnormal
-decs084 apply #00000001 -> 1E-101 Subnormal
-decs08x apply 1e-101 -> 1E-101 Subnormal
-
--- underflows cannot be tested; just check edge case
-decs090 apply 1e-101 -> #00000001 Subnormal
-
--- same again, negatives --
-
--- Nmax and similar
-decs122 apply -9.999999E+96 -> #f7f3fcff
-decs123 apply #f7f3fcff -> -9.999999E+96
-decs124 apply -1.234567E+96 -> #c7f4d2e7
-decs125 apply #c7f4d2e7 -> -1.234567E+96
--- fold-downs (more below)
-decs130 apply -1.23E+96 -> #c7f4c000 Clamped
-decs131 apply #c7f4c000 -> -1.230000E+96
-decs132 apply -1E+96 -> #c7f00000 Clamped
-decs133 apply #c7f00000 -> -1.000000E+96
-
-decs151 apply -12345 -> #a25049c5
-decs152 apply #a25049c5 -> -12345
-decs153 apply -1234 -> #a2500534
-decs154 apply #a2500534 -> -1234
-decs155 apply -123 -> #a25000a3
-decs156 apply #a25000a3 -> -123
-decs157 apply -12 -> #a2500012
-decs158 apply #a2500012 -> -12
-decs159 apply -1 -> #a2500001
-decs160 apply #a2500001 -> -1
-decs161 apply -1.23 -> #a23000a3
-decs162 apply #a23000a3 -> -1.23
-decs163 apply -123.45 -> #a23049c5
-decs164 apply #a23049c5 -> -123.45
-
--- Nmin and below
-decs171 apply -1E-95 -> #80600001
-decs172 apply #80600001 -> -1E-95
-decs173 apply -1.000000E-95 -> #84000000
-decs174 apply #84000000 -> -1.000000E-95
-decs175 apply -1.000001E-95 -> #84000001
-decs176 apply #84000001 -> -1.000001E-95
-
-decs177 apply -0.100000E-95 -> #80020000 Subnormal
-decs178 apply #80020000 -> -1.00000E-96 Subnormal
-decs179 apply -0.000010E-95 -> #80000010 Subnormal
-decs180 apply #80000010 -> -1.0E-100 Subnormal
-decs181 apply -0.000001E-95 -> #80000001 Subnormal
-decs182 apply #80000001 -> -1E-101 Subnormal
-decs183 apply -1e-101 -> #80000001 Subnormal
-decs184 apply #80000001 -> -1E-101 Subnormal
-
--- underflow edge case
-decs190 apply -1e-101 -> #80000001 Subnormal
-
--- zeros
-decs400 apply 0E-400 -> #00000000 Clamped
-decs401 apply 0E-101 -> #00000000
-decs402 apply #00000000 -> 0E-101
-decs403 apply 0.000000E-95 -> #00000000
-decs404 apply #00000000 -> 0E-101
-decs405 apply 0E-2 -> #22300000
-decs406 apply #22300000 -> 0.00
-decs407 apply 0 -> #22500000
-decs408 apply #22500000 -> 0
-decs409 apply 0E+3 -> #22800000
-decs410 apply #22800000 -> 0E+3
-decs411 apply 0E+90 -> #43f00000
-decs412 apply #43f00000 -> 0E+90
--- clamped zeros...
-decs413 apply 0E+91 -> #43f00000 Clamped
-decs414 apply #43f00000 -> 0E+90
-decs415 apply 0E+96 -> #43f00000 Clamped
-decs416 apply #43f00000 -> 0E+90
-decs417 apply 0E+400 -> #43f00000 Clamped
-decs418 apply #43f00000 -> 0E+90
-
--- negative zeros
-decs420 apply -0E-400 -> #80000000 Clamped
-decs421 apply -0E-101 -> #80000000
-decs422 apply #80000000 -> -0E-101
-decs423 apply -0.000000E-95 -> #80000000
-decs424 apply #80000000 -> -0E-101
-decs425 apply -0E-2 -> #a2300000
-decs426 apply #a2300000 -> -0.00
-decs427 apply -0 -> #a2500000
-decs428 apply #a2500000 -> -0
-decs429 apply -0E+3 -> #a2800000
-decs430 apply #a2800000 -> -0E+3
-decs431 apply -0E+90 -> #c3f00000
-decs432 apply #c3f00000 -> -0E+90
--- clamped zeros...
-decs433 apply -0E+91 -> #c3f00000 Clamped
-decs434 apply #c3f00000 -> -0E+90
-decs435 apply -0E+96 -> #c3f00000 Clamped
-decs436 apply #c3f00000 -> -0E+90
-decs437 apply -0E+400 -> #c3f00000 Clamped
-decs438 apply #c3f00000 -> -0E+90
-
--- Specials
-decs500 apply Infinity -> #78000000
-decs501 apply #78787878 -> #78000000
-decs502 apply #78000000 -> Infinity
-decs503 apply #79797979 -> #78000000
-decs504 apply #79000000 -> Infinity
-decs505 apply #7a7a7a7a -> #78000000
-decs506 apply #7a000000 -> Infinity
-decs507 apply #7b7b7b7b -> #78000000
-decs508 apply #7b000000 -> Infinity
-decs509 apply #7c7c7c7c -> #7c0c7c7c
-
-decs510 apply NaN -> #7c000000
-decs511 apply #7c000000 -> NaN
-decs512 apply #7d7d7d7d -> #7c0d7d7d
-decs513 apply #7d000000 -> NaN
-decs514 apply #7e7e7e7e -> #7e0e7c7e
-decs515 apply #7e000000 -> sNaN
-decs516 apply #7f7f7f7f -> #7e0f7c7f
-decs517 apply #7f000000 -> sNaN
-decs518 apply #7fffffff -> sNaN999999
-decs519 apply #7fffffff -> #7e03fcff
-
-decs520 apply -Infinity -> #f8000000
-decs521 apply #f8787878 -> #f8000000
-decs522 apply #f8000000 -> -Infinity
-decs523 apply #f9797979 -> #f8000000
-decs524 apply #f9000000 -> -Infinity
-decs525 apply #fa7a7a7a -> #f8000000
-decs526 apply #fa000000 -> -Infinity
-decs527 apply #fb7b7b7b -> #f8000000
-decs528 apply #fb000000 -> -Infinity
-
-decs529 apply -NaN -> #fc000000
-decs530 apply #fc7c7c7c -> #fc0c7c7c
-decs531 apply #fc000000 -> -NaN
-decs532 apply #fd7d7d7d -> #fc0d7d7d
-decs533 apply #fd000000 -> -NaN
-decs534 apply #fe7e7e7e -> #fe0e7c7e
-decs535 apply #fe000000 -> -sNaN
-decs536 apply #ff7f7f7f -> #fe0f7c7f
-decs537 apply #ff000000 -> -sNaN
-decs538 apply #ffffffff -> -sNaN999999
-decs539 apply #ffffffff -> #fe03fcff
-
--- diagnostic NaNs
-decs540 apply NaN -> #7c000000
-decs541 apply NaN0 -> #7c000000
-decs542 apply NaN1 -> #7c000001
-decs543 apply NaN12 -> #7c000012
-decs544 apply NaN79 -> #7c000079
-decs545 apply NaN12345 -> #7c0049c5
-decs546 apply NaN123456 -> #7c028e56
-decs547 apply NaN799799 -> #7c0f7fdf
-decs548 apply NaN999999 -> #7c03fcff
-
-
--- fold-down full sequence
-decs601 apply 1E+96 -> #47f00000 Clamped
-decs602 apply #47f00000 -> 1.000000E+96
-decs603 apply 1E+95 -> #43f20000 Clamped
-decs604 apply #43f20000 -> 1.00000E+95
-decs605 apply 1E+94 -> #43f04000 Clamped
-decs606 apply #43f04000 -> 1.0000E+94
-decs607 apply 1E+93 -> #43f00400 Clamped
-decs608 apply #43f00400 -> 1.000E+93
-decs609 apply 1E+92 -> #43f00080 Clamped
-decs610 apply #43f00080 -> 1.00E+92
-decs611 apply 1E+91 -> #43f00010 Clamped
-decs612 apply #43f00010 -> 1.0E+91
-decs613 apply 1E+90 -> #43f00001
-decs614 apply #43f00001 -> 1E+90
-
-
--- Selected DPD codes
-decs700 apply #22500000 -> 0
-decs701 apply #22500009 -> 9
-decs702 apply #22500010 -> 10
-decs703 apply #22500019 -> 19
-decs704 apply #22500020 -> 20
-decs705 apply #22500029 -> 29
-decs706 apply #22500030 -> 30
-decs707 apply #22500039 -> 39
-decs708 apply #22500040 -> 40
-decs709 apply #22500049 -> 49
-decs710 apply #22500050 -> 50
-decs711 apply #22500059 -> 59
-decs712 apply #22500060 -> 60
-decs713 apply #22500069 -> 69
-decs714 apply #22500070 -> 70
-decs715 apply #22500071 -> 71
-decs716 apply #22500072 -> 72
-decs717 apply #22500073 -> 73
-decs718 apply #22500074 -> 74
-decs719 apply #22500075 -> 75
-decs720 apply #22500076 -> 76
-decs721 apply #22500077 -> 77
-decs722 apply #22500078 -> 78
-decs723 apply #22500079 -> 79
-
-decs730 apply #2250029e -> 994
-decs731 apply #2250029f -> 995
-decs732 apply #225002a0 -> 520
-decs733 apply #225002a1 -> 521
-
--- DPD: one of each of the huffman groups
-decs740 apply #225003f7 -> 777
-decs741 apply #225003f8 -> 778
-decs742 apply #225003eb -> 787
-decs743 apply #2250037d -> 877
-decs744 apply #2250039f -> 997
-decs745 apply #225003bf -> 979
-decs746 apply #225003df -> 799
-decs747 apply #2250006e -> 888
-
-
--- DPD all-highs cases (includes the 24 redundant codes)
-decs750 apply #2250006e -> 888
-decs751 apply #2250016e -> 888
-decs752 apply #2250026e -> 888
-decs753 apply #2250036e -> 888
-decs754 apply #2250006f -> 889
-decs755 apply #2250016f -> 889
-decs756 apply #2250026f -> 889
-decs757 apply #2250036f -> 889
-
-decs760 apply #2250007e -> 898
-decs761 apply #2250017e -> 898
-decs762 apply #2250027e -> 898
-decs763 apply #2250037e -> 898
-decs764 apply #2250007f -> 899
-decs765 apply #2250017f -> 899
-decs766 apply #2250027f -> 899
-decs767 apply #2250037f -> 899
-
-decs770 apply #225000ee -> 988
-decs771 apply #225001ee -> 988
-decs772 apply #225002ee -> 988
-decs773 apply #225003ee -> 988
-decs774 apply #225000ef -> 989
-decs775 apply #225001ef -> 989
-decs776 apply #225002ef -> 989
-decs777 apply #225003ef -> 989
-
-decs780 apply #225000fe -> 998
-decs781 apply #225001fe -> 998
-decs782 apply #225002fe -> 998
-decs783 apply #225003fe -> 998
-decs784 apply #225000ff -> 999
-decs785 apply #225001ff -> 999
-decs786 apply #225002ff -> 999
-decs787 apply #225003ff -> 999
-
--- narrowing case
-decs790 apply 2.00E-99 -> #00000100 Subnormal
-decs791 apply #00000100 -> 2.00E-99 Subnormal
+------------------------------------------------------------------------
+-- dsEncode.decTest -- decimal four-byte format testcases --
+-- Copyright (c) IBM Corporation, 2000, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+-- [Previously called decimal32.decTest]
+version: 2.59
+
+-- This set of tests is for the four-byte concrete representation.
+-- Its characteristics are:
+--
+-- 1 bit sign
+-- 5 bits combination field
+-- 6 bits exponent continuation
+-- 20 bits coefficient continuation
+--
+-- Total exponent length 8 bits
+-- Total coefficient length 24 bits (7 digits)
+--
+-- Elimit = 191 (maximum encoded exponent)
+-- Emax = 96 (largest exponent value)
+-- Emin = -95 (smallest exponent value)
+-- bias = 101 (subtracted from encoded exponent) = -Etiny
+
+-- The testcases here have only exactly representable data on the
+-- 'left-hand-side'; rounding from strings is tested in 'base'
+-- testcase groups.
+
+extended: 1
+clamp: 1
+precision: 7
+rounding: half_up
+maxExponent: 96
+minExponent: -95
+
+-- General testcases
+-- (mostly derived from the Strawman 4 document and examples)
+decs001 apply #A23003D0 -> -7.50
+decs002 apply -7.50 -> #A23003D0
+-- derivative canonical plain strings
+decs003 apply #A26003D0 -> -7.50E+3
+decs004 apply -7.50E+3 -> #A26003D0
+decs005 apply #A25003D0 -> -750
+decs006 apply -750 -> #A25003D0
+decs007 apply #A24003D0 -> -75.0
+decs008 apply -75.0 -> #A24003D0
+decs009 apply #A22003D0 -> -0.750
+decs010 apply -0.750 -> #A22003D0
+decs011 apply #A21003D0 -> -0.0750
+decs012 apply -0.0750 -> #A21003D0
+decs013 apply #A1f003D0 -> -0.000750
+decs014 apply -0.000750 -> #A1f003D0
+decs015 apply #A1d003D0 -> -0.00000750
+decs016 apply -0.00000750 -> #A1d003D0
+decs017 apply #A1c003D0 -> -7.50E-7
+decs018 apply -7.50E-7 -> #A1c003D0
+
+-- Normality
+decs020 apply 1234567 -> #2654d2e7
+decs021 apply -1234567 -> #a654d2e7
+decs022 apply 1111111 -> #26524491
+
+-- Nmax and similar
+decs031 apply 9.999999E+96 -> #77f3fcff
+decs032 apply #77f3fcff -> 9.999999E+96
+decs033 apply 1.234567E+96 -> #47f4d2e7
+decs034 apply #47f4d2e7 -> 1.234567E+96
+-- fold-downs (more below)
+decs035 apply 1.23E+96 -> #47f4c000 Clamped
+decs036 apply #47f4c000 -> 1.230000E+96
+decs037 apply 1E+96 -> #47f00000 Clamped
+decs038 apply #47f00000 -> 1.000000E+96
+
+decs051 apply 12345 -> #225049c5
+decs052 apply #225049c5 -> 12345
+decs053 apply 1234 -> #22500534
+decs054 apply #22500534 -> 1234
+decs055 apply 123 -> #225000a3
+decs056 apply #225000a3 -> 123
+decs057 apply 12 -> #22500012
+decs058 apply #22500012 -> 12
+decs059 apply 1 -> #22500001
+decs060 apply #22500001 -> 1
+decs061 apply 1.23 -> #223000a3
+decs062 apply #223000a3 -> 1.23
+decs063 apply 123.45 -> #223049c5
+decs064 apply #223049c5 -> 123.45
+
+-- Nmin and below
+decs071 apply 1E-95 -> #00600001
+decs072 apply #00600001 -> 1E-95
+decs073 apply 1.000000E-95 -> #04000000
+decs074 apply #04000000 -> 1.000000E-95
+decs075 apply 1.000001E-95 -> #04000001
+decs076 apply #04000001 -> 1.000001E-95
+
+decs077 apply 0.100000E-95 -> #00020000 Subnormal
+decs07x apply 1.00000E-96 -> 1.00000E-96 Subnormal
+decs078 apply #00020000 -> 1.00000E-96 Subnormal
+decs079 apply 0.000010E-95 -> #00000010 Subnormal
+decs080 apply #00000010 -> 1.0E-100 Subnormal
+decs081 apply 0.000001E-95 -> #00000001 Subnormal
+decs082 apply #00000001 -> 1E-101 Subnormal
+decs083 apply 1e-101 -> #00000001 Subnormal
+decs084 apply #00000001 -> 1E-101 Subnormal
+decs08x apply 1e-101 -> 1E-101 Subnormal
+
+-- underflows cannot be tested; just check edge case
+decs090 apply 1e-101 -> #00000001 Subnormal
+
+-- same again, negatives --
+
+-- Nmax and similar
+decs122 apply -9.999999E+96 -> #f7f3fcff
+decs123 apply #f7f3fcff -> -9.999999E+96
+decs124 apply -1.234567E+96 -> #c7f4d2e7
+decs125 apply #c7f4d2e7 -> -1.234567E+96
+-- fold-downs (more below)
+decs130 apply -1.23E+96 -> #c7f4c000 Clamped
+decs131 apply #c7f4c000 -> -1.230000E+96
+decs132 apply -1E+96 -> #c7f00000 Clamped
+decs133 apply #c7f00000 -> -1.000000E+96
+
+decs151 apply -12345 -> #a25049c5
+decs152 apply #a25049c5 -> -12345
+decs153 apply -1234 -> #a2500534
+decs154 apply #a2500534 -> -1234
+decs155 apply -123 -> #a25000a3
+decs156 apply #a25000a3 -> -123
+decs157 apply -12 -> #a2500012
+decs158 apply #a2500012 -> -12
+decs159 apply -1 -> #a2500001
+decs160 apply #a2500001 -> -1
+decs161 apply -1.23 -> #a23000a3
+decs162 apply #a23000a3 -> -1.23
+decs163 apply -123.45 -> #a23049c5
+decs164 apply #a23049c5 -> -123.45
+
+-- Nmin and below
+decs171 apply -1E-95 -> #80600001
+decs172 apply #80600001 -> -1E-95
+decs173 apply -1.000000E-95 -> #84000000
+decs174 apply #84000000 -> -1.000000E-95
+decs175 apply -1.000001E-95 -> #84000001
+decs176 apply #84000001 -> -1.000001E-95
+
+decs177 apply -0.100000E-95 -> #80020000 Subnormal
+decs178 apply #80020000 -> -1.00000E-96 Subnormal
+decs179 apply -0.000010E-95 -> #80000010 Subnormal
+decs180 apply #80000010 -> -1.0E-100 Subnormal
+decs181 apply -0.000001E-95 -> #80000001 Subnormal
+decs182 apply #80000001 -> -1E-101 Subnormal
+decs183 apply -1e-101 -> #80000001 Subnormal
+decs184 apply #80000001 -> -1E-101 Subnormal
+
+-- underflow edge case
+decs190 apply -1e-101 -> #80000001 Subnormal
+
+-- zeros
+decs400 apply 0E-400 -> #00000000 Clamped
+decs401 apply 0E-101 -> #00000000
+decs402 apply #00000000 -> 0E-101
+decs403 apply 0.000000E-95 -> #00000000
+decs404 apply #00000000 -> 0E-101
+decs405 apply 0E-2 -> #22300000
+decs406 apply #22300000 -> 0.00
+decs407 apply 0 -> #22500000
+decs408 apply #22500000 -> 0
+decs409 apply 0E+3 -> #22800000
+decs410 apply #22800000 -> 0E+3
+decs411 apply 0E+90 -> #43f00000
+decs412 apply #43f00000 -> 0E+90
+-- clamped zeros...
+decs413 apply 0E+91 -> #43f00000 Clamped
+decs414 apply #43f00000 -> 0E+90
+decs415 apply 0E+96 -> #43f00000 Clamped
+decs416 apply #43f00000 -> 0E+90
+decs417 apply 0E+400 -> #43f00000 Clamped
+decs418 apply #43f00000 -> 0E+90
+
+-- negative zeros
+decs420 apply -0E-400 -> #80000000 Clamped
+decs421 apply -0E-101 -> #80000000
+decs422 apply #80000000 -> -0E-101
+decs423 apply -0.000000E-95 -> #80000000
+decs424 apply #80000000 -> -0E-101
+decs425 apply -0E-2 -> #a2300000
+decs426 apply #a2300000 -> -0.00
+decs427 apply -0 -> #a2500000
+decs428 apply #a2500000 -> -0
+decs429 apply -0E+3 -> #a2800000
+decs430 apply #a2800000 -> -0E+3
+decs431 apply -0E+90 -> #c3f00000
+decs432 apply #c3f00000 -> -0E+90
+-- clamped zeros...
+decs433 apply -0E+91 -> #c3f00000 Clamped
+decs434 apply #c3f00000 -> -0E+90
+decs435 apply -0E+96 -> #c3f00000 Clamped
+decs436 apply #c3f00000 -> -0E+90
+decs437 apply -0E+400 -> #c3f00000 Clamped
+decs438 apply #c3f00000 -> -0E+90
+
+-- Specials
+decs500 apply Infinity -> #78000000
+decs501 apply #78787878 -> #78000000
+decs502 apply #78000000 -> Infinity
+decs503 apply #79797979 -> #78000000
+decs504 apply #79000000 -> Infinity
+decs505 apply #7a7a7a7a -> #78000000
+decs506 apply #7a000000 -> Infinity
+decs507 apply #7b7b7b7b -> #78000000
+decs508 apply #7b000000 -> Infinity
+decs509 apply #7c7c7c7c -> #7c0c7c7c
+
+decs510 apply NaN -> #7c000000
+decs511 apply #7c000000 -> NaN
+decs512 apply #7d7d7d7d -> #7c0d7d7d
+decs513 apply #7d000000 -> NaN
+decs514 apply #7e7e7e7e -> #7e0e7c7e
+decs515 apply #7e000000 -> sNaN
+decs516 apply #7f7f7f7f -> #7e0f7c7f
+decs517 apply #7f000000 -> sNaN
+decs518 apply #7fffffff -> sNaN999999
+decs519 apply #7fffffff -> #7e03fcff
+
+decs520 apply -Infinity -> #f8000000
+decs521 apply #f8787878 -> #f8000000
+decs522 apply #f8000000 -> -Infinity
+decs523 apply #f9797979 -> #f8000000
+decs524 apply #f9000000 -> -Infinity
+decs525 apply #fa7a7a7a -> #f8000000
+decs526 apply #fa000000 -> -Infinity
+decs527 apply #fb7b7b7b -> #f8000000
+decs528 apply #fb000000 -> -Infinity
+
+decs529 apply -NaN -> #fc000000
+decs530 apply #fc7c7c7c -> #fc0c7c7c
+decs531 apply #fc000000 -> -NaN
+decs532 apply #fd7d7d7d -> #fc0d7d7d
+decs533 apply #fd000000 -> -NaN
+decs534 apply #fe7e7e7e -> #fe0e7c7e
+decs535 apply #fe000000 -> -sNaN
+decs536 apply #ff7f7f7f -> #fe0f7c7f
+decs537 apply #ff000000 -> -sNaN
+decs538 apply #ffffffff -> -sNaN999999
+decs539 apply #ffffffff -> #fe03fcff
+
+-- diagnostic NaNs
+decs540 apply NaN -> #7c000000
+decs541 apply NaN0 -> #7c000000
+decs542 apply NaN1 -> #7c000001
+decs543 apply NaN12 -> #7c000012
+decs544 apply NaN79 -> #7c000079
+decs545 apply NaN12345 -> #7c0049c5
+decs546 apply NaN123456 -> #7c028e56
+decs547 apply NaN799799 -> #7c0f7fdf
+decs548 apply NaN999999 -> #7c03fcff
+
+
+-- fold-down full sequence
+decs601 apply 1E+96 -> #47f00000 Clamped
+decs602 apply #47f00000 -> 1.000000E+96
+decs603 apply 1E+95 -> #43f20000 Clamped
+decs604 apply #43f20000 -> 1.00000E+95
+decs605 apply 1E+94 -> #43f04000 Clamped
+decs606 apply #43f04000 -> 1.0000E+94
+decs607 apply 1E+93 -> #43f00400 Clamped
+decs608 apply #43f00400 -> 1.000E+93
+decs609 apply 1E+92 -> #43f00080 Clamped
+decs610 apply #43f00080 -> 1.00E+92
+decs611 apply 1E+91 -> #43f00010 Clamped
+decs612 apply #43f00010 -> 1.0E+91
+decs613 apply 1E+90 -> #43f00001
+decs614 apply #43f00001 -> 1E+90
+
+
+-- Selected DPD codes
+decs700 apply #22500000 -> 0
+decs701 apply #22500009 -> 9
+decs702 apply #22500010 -> 10
+decs703 apply #22500019 -> 19
+decs704 apply #22500020 -> 20
+decs705 apply #22500029 -> 29
+decs706 apply #22500030 -> 30
+decs707 apply #22500039 -> 39
+decs708 apply #22500040 -> 40
+decs709 apply #22500049 -> 49
+decs710 apply #22500050 -> 50
+decs711 apply #22500059 -> 59
+decs712 apply #22500060 -> 60
+decs713 apply #22500069 -> 69
+decs714 apply #22500070 -> 70
+decs715 apply #22500071 -> 71
+decs716 apply #22500072 -> 72
+decs717 apply #22500073 -> 73
+decs718 apply #22500074 -> 74
+decs719 apply #22500075 -> 75
+decs720 apply #22500076 -> 76
+decs721 apply #22500077 -> 77
+decs722 apply #22500078 -> 78
+decs723 apply #22500079 -> 79
+
+decs730 apply #2250029e -> 994
+decs731 apply #2250029f -> 995
+decs732 apply #225002a0 -> 520
+decs733 apply #225002a1 -> 521
+
+-- DPD: one of each of the huffman groups
+decs740 apply #225003f7 -> 777
+decs741 apply #225003f8 -> 778
+decs742 apply #225003eb -> 787
+decs743 apply #2250037d -> 877
+decs744 apply #2250039f -> 997
+decs745 apply #225003bf -> 979
+decs746 apply #225003df -> 799
+decs747 apply #2250006e -> 888
+
+
+-- DPD all-highs cases (includes the 24 redundant codes)
+decs750 apply #2250006e -> 888
+decs751 apply #2250016e -> 888
+decs752 apply #2250026e -> 888
+decs753 apply #2250036e -> 888
+decs754 apply #2250006f -> 889
+decs755 apply #2250016f -> 889
+decs756 apply #2250026f -> 889
+decs757 apply #2250036f -> 889
+
+decs760 apply #2250007e -> 898
+decs761 apply #2250017e -> 898
+decs762 apply #2250027e -> 898
+decs763 apply #2250037e -> 898
+decs764 apply #2250007f -> 899
+decs765 apply #2250017f -> 899
+decs766 apply #2250027f -> 899
+decs767 apply #2250037f -> 899
+
+decs770 apply #225000ee -> 988
+decs771 apply #225001ee -> 988
+decs772 apply #225002ee -> 988
+decs773 apply #225003ee -> 988
+decs774 apply #225000ef -> 989
+decs775 apply #225001ef -> 989
+decs776 apply #225002ef -> 989
+decs777 apply #225003ef -> 989
+
+decs780 apply #225000fe -> 998
+decs781 apply #225001fe -> 998
+decs782 apply #225002fe -> 998
+decs783 apply #225003fe -> 998
+decs784 apply #225000ff -> 999
+decs785 apply #225001ff -> 999
+decs786 apply #225002ff -> 999
+decs787 apply #225003ff -> 999
+
+-- narrowing case
+decs790 apply 2.00E-99 -> #00000100 Subnormal
+decs791 apply #00000100 -> 2.00E-99 Subnormal
diff --git a/Lib/test/decimaltestdata/exp.decTest b/Lib/test/decimaltestdata/exp.decTest
index eab990d3ef0..021b478ac2e 100644
--- a/Lib/test/decimaltestdata/exp.decTest
+++ b/Lib/test/decimaltestdata/exp.decTest
@@ -1,674 +1,674 @@
-------------------------------------------------------------------------
--- exp.decTest -- decimal natural exponentiation --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- Tests of the exponential funtion. Currently all testcases here
--- show results which are correctly rounded (within <= 0.5 ulp).
-
-extended: 1
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics (examples in specificiation, etc.)
-expx001 exp -Infinity -> 0
-expx002 exp -10 -> 0.0000453999298 Inexact Rounded
-expx003 exp -1 -> 0.367879441 Inexact Rounded
-expx004 exp 0 -> 1
-expx005 exp -0 -> 1
-expx006 exp 1 -> 2.71828183 Inexact Rounded
-expx007 exp 0.693147181 -> 2.00000000 Inexact Rounded
-expx008 exp 10 -> 22026.4658 Inexact Rounded
-expx009 exp +Infinity -> Infinity
-
--- tiny edge cases
-precision: 7
-expx011 exp 0.1 -> 1.105171 Inexact Rounded
-expx012 exp 0.01 -> 1.010050 Inexact Rounded
-expx013 exp 0.001 -> 1.001001 Inexact Rounded
-expx014 exp 0.0001 -> 1.000100 Inexact Rounded
-expx015 exp 0.00001 -> 1.000010 Inexact Rounded
-expx016 exp 0.000001 -> 1.000001 Inexact Rounded
-expx017 exp 0.0000001 -> 1.000000 Inexact Rounded
-expx018 exp 0.0000003 -> 1.000000 Inexact Rounded
-expx019 exp 0.0000004 -> 1.000000 Inexact Rounded
-expx020 exp 0.0000005 -> 1.000001 Inexact Rounded
-expx021 exp 0.0000008 -> 1.000001 Inexact Rounded
-expx022 exp 0.0000009 -> 1.000001 Inexact Rounded
-expx023 exp 0.0000010 -> 1.000001 Inexact Rounded
-expx024 exp 0.0000011 -> 1.000001 Inexact Rounded
-expx025 exp 0.00000009 -> 1.000000 Inexact Rounded
-expx026 exp 0.00000005 -> 1.000000 Inexact Rounded
-expx027 exp 0.00000004 -> 1.000000 Inexact Rounded
-expx028 exp 0.00000001 -> 1.000000 Inexact Rounded
-
--- and some more zeros
-expx030 exp 0.00000000 -> 1
-expx031 exp 0E+100 -> 1
-expx032 exp 0E-100 -> 1
-expx033 exp -0.00000000 -> 1
-expx034 exp -0E+100 -> 1
-expx035 exp -0E-100 -> 1
-
--- basic e=0, e=1, e=2, e=4, e>=8 cases
-precision: 7
-expx041 exp 1 -> 2.718282 Inexact Rounded
-expx042 exp -1 -> 0.3678794 Inexact Rounded
-expx043 exp 10 -> 22026.47 Inexact Rounded
-expx044 exp -10 -> 0.00004539993 Inexact Rounded
-expx045 exp 100 -> 2.688117E+43 Inexact Rounded
-expx046 exp -100 -> 3.720076E-44 Inexact Rounded
-expx047 exp 1000 -> Infinity Overflow Inexact Rounded
-expx048 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx049 exp 100000000 -> Infinity Overflow Inexact Rounded
-expx050 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-
--- miscellanea
--- similar to 'VF bug' test, at 17, but with last digit corrected for decimal
-precision: 16
-expx055 exp -5.42410311287441459172E+2 -> 2.717658486884572E-236 Inexact Rounded
--- result from NetRexx/Java prototype -> 2.7176584868845721117677929628617246054459644711108E-236
--- result from Rexx (series) version -> 2.717658486884572111767792962861724605446E-236
-precision: 17
-expx056 exp -5.42410311287441459172E+2 -> 2.7176584868845721E-236 Inexact Rounded
-precision: 18
-expx057 exp -5.42410311287441459172E+2 -> 2.71765848688457211E-236 Inexact Rounded
-precision: 19
-expx058 exp -5.42410311287441459172E+2 -> 2.717658486884572112E-236 Inexact Rounded
-precision: 20
-expx059 exp -5.42410311287441459172E+2 -> 2.7176584868845721118E-236 Inexact Rounded
-
--- rounding in areas of ..500.., ..499.., ..100.., ..999.. sequences
-precision: 50
-expx101 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
-precision: 31
-expx102 exp -9E-8 -> 0.9999999100000040499998785000027 Inexact Rounded
-precision: 30
-expx103 exp -9E-8 -> 0.999999910000004049999878500003 Inexact Rounded
-precision: 29
-expx104 exp -9E-8 -> 0.99999991000000404999987850000 Inexact Rounded
-precision: 28
-expx105 exp -9E-8 -> 0.9999999100000040499998785000 Inexact Rounded
-precision: 27
-expx106 exp -9E-8 -> 0.999999910000004049999878500 Inexact Rounded
-precision: 26
-expx107 exp -9E-8 -> 0.99999991000000404999987850 Inexact Rounded
-precision: 25
-expx108 exp -9E-8 -> 0.9999999100000040499998785 Inexact Rounded
-precision: 24
-expx109 exp -9E-8 -> 0.999999910000004049999879 Inexact Rounded
-precision: 23
-expx110 exp -9E-8 -> 0.99999991000000404999988 Inexact Rounded
-precision: 22
-expx111 exp -9E-8 -> 0.9999999100000040499999 Inexact Rounded
-precision: 21
-expx112 exp -9E-8 -> 0.999999910000004050000 Inexact Rounded
-precision: 20
-expx113 exp -9E-8 -> 0.99999991000000405000 Inexact Rounded
-precision: 19
-expx114 exp -9E-8 -> 0.9999999100000040500 Inexact Rounded
-precision: 18
-expx115 exp -9E-8 -> 0.999999910000004050 Inexact Rounded
-precision: 17
-expx116 exp -9E-8 -> 0.99999991000000405 Inexact Rounded
-precision: 16
-expx117 exp -9E-8 -> 0.9999999100000040 Inexact Rounded
-precision: 15
-expx118 exp -9E-8 -> 0.999999910000004 Inexact Rounded
-precision: 14
-expx119 exp -9E-8 -> 0.99999991000000 Inexact Rounded
-precision: 13
-expx120 exp -9E-8 -> 0.9999999100000 Inexact Rounded
-precision: 12
-expx121 exp -9E-8 -> 0.999999910000 Inexact Rounded
-precision: 11
-expx122 exp -9E-8 -> 0.99999991000 Inexact Rounded
-precision: 10
-expx123 exp -9E-8 -> 0.9999999100 Inexact Rounded
-precision: 9
-expx124 exp -9E-8 -> 0.999999910 Inexact Rounded
-precision: 8
-expx125 exp -9E-8 -> 0.99999991 Inexact Rounded
-precision: 7
-expx126 exp -9E-8 -> 0.9999999 Inexact Rounded
-precision: 6
-expx127 exp -9E-8 -> 1.00000 Inexact Rounded
-precision: 5
-expx128 exp -9E-8 -> 1.0000 Inexact Rounded
-precision: 4
-expx129 exp -9E-8 -> 1.000 Inexact Rounded
-precision: 3
-expx130 exp -9E-8 -> 1.00 Inexact Rounded
-precision: 2
-expx131 exp -9E-8 -> 1.0 Inexact Rounded
-precision: 1
-expx132 exp -9E-8 -> 1 Inexact Rounded
-
-
--- sanity checks, with iteration counts [normalized so 0<=|x|<1]
-precision: 50
-
-expx210 exp 0 -> 1
--- iterations: 2
-expx211 exp -1E-40 -> 0.99999999999999999999999999999999999999990000000000 Inexact Rounded
--- iterations: 8
-expx212 exp -9E-7 -> 0.99999910000040499987850002733749507925073811240510 Inexact Rounded
--- iterations: 6
-expx213 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
--- iterations: 15
-expx214 exp -0.003 -> 0.99700449550337297601206623409756091074177480489845 Inexact Rounded
--- iterations: 14
-expx215 exp -0.001 -> 0.99900049983337499166805535716765597470235590236008 Inexact Rounded
--- iterations: 26
-expx216 exp -0.1 -> 0.90483741803595957316424905944643662119470536098040 Inexact Rounded
--- iterations: 39
-expx217 exp -0.7 -> 0.49658530379140951470480009339752896170766716571182 Inexact Rounded
--- iterations: 41
-expx218 exp -0.9 -> 0.40656965974059911188345423964562598783370337617038 Inexact Rounded
--- iterations: 43
-expx219 exp -0.99 -> 0.37157669102204569053152411990820138691802885490501 Inexact Rounded
--- iterations: 26
-expx220 exp -1 -> 0.36787944117144232159552377016146086744581113103177 Inexact Rounded
--- iterations: 26
-expx221 exp -1.01 -> 0.36421897957152331975704629563734548959589139192482 Inexact Rounded
--- iterations: 27
-expx222 exp -1.1 -> 0.33287108369807955328884690643131552161247952156921 Inexact Rounded
--- iterations: 28
-expx223 exp -1.5 -> 0.22313016014842982893328047076401252134217162936108 Inexact Rounded
--- iterations: 30
-expx224 exp -2 -> 0.13533528323661269189399949497248440340763154590958 Inexact Rounded
--- iterations: 36
-expx225 exp -5 -> 0.0067379469990854670966360484231484242488495850273551 Inexact Rounded
--- iterations: 26
-expx226 exp -10 -> 0.000045399929762484851535591515560550610237918088866565 Inexact Rounded
--- iterations: 28
-expx227 exp -14 -> 8.3152871910356788406398514256526229460765836498457E-7 Inexact Rounded
--- iterations: 29
-expx228 exp -15 -> 3.0590232050182578837147949770228963937082078081856E-7 Inexact Rounded
--- iterations: 30
-expx233 exp 0 -> 1
--- iterations: 2
-expx234 exp 1E-40 -> 1.0000000000000000000000000000000000000001000000000 Inexact Rounded
--- iterations: 7
-expx235 exp 9E-7 -> 1.0000009000004050001215000273375049207507381125949 Inexact Rounded
--- iterations: 6
-expx236 exp 9E-8 -> 1.0000000900000040500001215000027337500492075007381 Inexact Rounded
--- iterations: 15
-expx237 exp 0.003 -> 1.0030045045033770260129340913489002053318727195619 Inexact Rounded
--- iterations: 13
-expx238 exp 0.001 -> 1.0010005001667083416680557539930583115630762005807 Inexact Rounded
--- iterations: 25
-expx239 exp 0.1 -> 1.1051709180756476248117078264902466682245471947375 Inexact Rounded
--- iterations: 38
-expx240 exp 0.7 -> 2.0137527074704765216245493885830652700175423941459 Inexact Rounded
--- iterations: 41
-expx241 exp 0.9 -> 2.4596031111569496638001265636024706954217723064401 Inexact Rounded
--- iterations: 42
-expx242 exp 0.99 -> 2.6912344723492622890998794040710139721802931841030 Inexact Rounded
--- iterations: 26
-expx243 exp 1 -> 2.7182818284590452353602874713526624977572470937000 Inexact Rounded
--- iterations: 26
-expx244 exp 1.01 -> 2.7456010150169164939897763166603876240737508195960 Inexact Rounded
--- iterations: 26
-expx245 exp 1.1 -> 3.0041660239464331120584079535886723932826810260163 Inexact Rounded
--- iterations: 28
-expx246 exp 1.5 -> 4.4816890703380648226020554601192758190057498683697 Inexact Rounded
--- iterations: 29
-expx247 exp 2 -> 7.3890560989306502272304274605750078131803155705518 Inexact Rounded
--- iterations: 36
-expx248 exp 5 -> 148.41315910257660342111558004055227962348766759388 Inexact Rounded
--- iterations: 26
-expx249 exp 10 -> 22026.465794806716516957900645284244366353512618557 Inexact Rounded
--- iterations: 28
-expx250 exp 14 -> 1202604.2841647767777492367707678594494124865433761 Inexact Rounded
--- iterations: 28
-expx251 exp 15 -> 3269017.3724721106393018550460917213155057385438200 Inexact Rounded
--- iterations: 29
-
--- a biggie [result verified 3 ways]
-precision: 250
-expx260 exp 1 -> 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668 Inexact Rounded
-
--- extreme range boundaries
-precision: 16
-maxExponent: 999999
-minExponent: -999999
--- Ntiny boundary
-expx290 exp -2302618.022332529 -> 0E-1000014 Underflow Subnormal Inexact Rounded Clamped
-expx291 exp -2302618.022332528 -> 1E-1000014 Underflow Subnormal Inexact Rounded
--- Nmax/10 and Nmax boundary
-expx292 exp 2302582.790408952 -> 9.999999993100277E+999998 Inexact Rounded
-expx293 exp 2302582.790408953 -> 1.000000000310028E+999999 Inexact Rounded
-expx294 exp 2302585.092993946 -> 9.999999003159870E+999999 Inexact Rounded
-expx295 exp 2302585.092994036 -> 9.999999903159821E+999999 Inexact Rounded
-expx296 exp 2302585.092994045 -> 9.999999993159820E+999999 Inexact Rounded
-expx297 exp 2302585.092994046 -> Infinity Overflow Inexact Rounded
-
--- 0<-x<<1 effects
-precision: 30
-expx320 exp -4.9999999999999E-8 -> 0.999999950000001250000979166617 Inexact Rounded
-expx321 exp -5.0000000000000E-8 -> 0.999999950000001249999979166667 Inexact Rounded
-expx322 exp -5.0000000000001E-8 -> 0.999999950000001249998979166717 Inexact Rounded
-precision: 20
-expx323 exp -4.9999999999999E-8 -> 0.99999995000000125000 Inexact Rounded
-expx324 exp -5.0000000000000E-8 -> 0.99999995000000125000 Inexact Rounded
-expx325 exp -5.0000000000001E-8 -> 0.99999995000000125000 Inexact Rounded
-precision: 14
-expx326 exp -4.9999999999999E-8 -> 0.99999995000000 Inexact Rounded
-expx327 exp -5.0000000000000E-8 -> 0.99999995000000 Inexact Rounded
-expx328 exp -5.0000000000001E-8 -> 0.99999995000000 Inexact Rounded
--- overprecise and 0<-x<<1
-precision: 8
-expx330 exp -4.9999999999999E-8 -> 0.99999995 Inexact Rounded
-expx331 exp -5.0000000000000E-8 -> 0.99999995 Inexact Rounded
-expx332 exp -5.0000000000001E-8 -> 0.99999995 Inexact Rounded
-precision: 7
-expx333 exp -4.9999999999999E-8 -> 1.000000 Inexact Rounded
-expx334 exp -5.0000000000000E-8 -> 1.000000 Inexact Rounded
-expx335 exp -5.0000000000001E-8 -> 1.000000 Inexact Rounded
-precision: 3
-expx336 exp -4.9999999999999E-8 -> 1.00 Inexact Rounded
-expx337 exp -5.0000000000000E-8 -> 1.00 Inexact Rounded
-expx338 exp -5.0000000000001E-8 -> 1.00 Inexact Rounded
-
--- 0<x<<1 effects
-precision: 30
-expx340 exp 4.9999999999999E-8 -> 1.00000005000000124999902083328 Inexact Rounded
-expx341 exp 5.0000000000000E-8 -> 1.00000005000000125000002083333 Inexact Rounded
-expx342 exp 5.0000000000001E-8 -> 1.00000005000000125000102083338 Inexact Rounded
-precision: 20
-expx343 exp 4.9999999999999E-8 -> 1.0000000500000012500 Inexact Rounded
-expx344 exp 5.0000000000000E-8 -> 1.0000000500000012500 Inexact Rounded
-expx345 exp 5.0000000000001E-8 -> 1.0000000500000012500 Inexact Rounded
-precision: 14
-expx346 exp 4.9999999999999E-8 -> 1.0000000500000 Inexact Rounded
-expx347 exp 5.0000000000000E-8 -> 1.0000000500000 Inexact Rounded
-expx348 exp 5.0000000000001E-8 -> 1.0000000500000 Inexact Rounded
--- overprecise and 0<x<<1
-precision: 8
-expx350 exp 4.9999999999999E-8 -> 1.0000001 Inexact Rounded
-expx351 exp 5.0000000000000E-8 -> 1.0000001 Inexact Rounded
-expx352 exp 5.0000000000001E-8 -> 1.0000001 Inexact Rounded
-precision: 7
-expx353 exp 4.9999999999999E-8 -> 1.000000 Inexact Rounded
-expx354 exp 5.0000000000000E-8 -> 1.000000 Inexact Rounded
-expx355 exp 5.0000000000001E-8 -> 1.000000 Inexact Rounded
-precision: 3
-expx356 exp 4.9999999999999E-8 -> 1.00 Inexact Rounded
-expx357 exp 5.0000000000000E-8 -> 1.00 Inexact Rounded
-expx358 exp 5.0000000000001E-8 -> 1.00 Inexact Rounded
-
--- cases near 1 -- 1 2345678901234567890
-precision: 20
-expx401 exp 0.99999999999996 -> 2.7182818284589365041 Inexact Rounded
-expx402 exp 0.99999999999997 -> 2.7182818284589636869 Inexact Rounded
-expx403 exp 0.99999999999998 -> 2.7182818284589908697 Inexact Rounded
-expx404 exp 0.99999999999999 -> 2.7182818284590180525 Inexact Rounded
-expx405 exp 1.0000000000000 -> 2.7182818284590452354 Inexact Rounded
-expx406 exp 1.0000000000001 -> 2.7182818284593170635 Inexact Rounded
-expx407 exp 1.0000000000002 -> 2.7182818284595888917 Inexact Rounded
-precision: 14
-expx411 exp 0.99999999999996 -> 2.7182818284589 Inexact Rounded
-expx412 exp 0.99999999999997 -> 2.7182818284590 Inexact Rounded
-expx413 exp 0.99999999999998 -> 2.7182818284590 Inexact Rounded
-expx414 exp 0.99999999999999 -> 2.7182818284590 Inexact Rounded
-expx415 exp 1.0000000000000 -> 2.7182818284590 Inexact Rounded
-expx416 exp 1.0000000000001 -> 2.7182818284593 Inexact Rounded
-expx417 exp 1.0000000000002 -> 2.7182818284596 Inexact Rounded
--- overprecise...
-precision: 7
-expx421 exp 0.99999999999996 -> 2.718282 Inexact Rounded
-expx422 exp 0.99999999999997 -> 2.718282 Inexact Rounded
-expx423 exp 0.99999999999998 -> 2.718282 Inexact Rounded
-expx424 exp 0.99999999999999 -> 2.718282 Inexact Rounded
-expx425 exp 1.0000000000001 -> 2.718282 Inexact Rounded
-expx426 exp 1.0000000000002 -> 2.718282 Inexact Rounded
-expx427 exp 1.0000000000003 -> 2.718282 Inexact Rounded
-precision: 2
-expx431 exp 0.99999999999996 -> 2.7 Inexact Rounded
-expx432 exp 0.99999999999997 -> 2.7 Inexact Rounded
-expx433 exp 0.99999999999998 -> 2.7 Inexact Rounded
-expx434 exp 0.99999999999999 -> 2.7 Inexact Rounded
-expx435 exp 1.0000000000001 -> 2.7 Inexact Rounded
-expx436 exp 1.0000000000002 -> 2.7 Inexact Rounded
-expx437 exp 1.0000000000003 -> 2.7 Inexact Rounded
-
--- basics at low precisions
-precision: 3
-expx501 exp -Infinity -> 0
-expx502 exp -10 -> 0.0000454 Inexact Rounded
-expx503 exp -1 -> 0.368 Inexact Rounded
-expx504 exp 0 -> 1
-expx505 exp -0 -> 1
-expx506 exp 1 -> 2.72 Inexact Rounded
-expx507 exp 0.693147181 -> 2.00 Inexact Rounded
-expx508 exp 10 -> 2.20E+4 Inexact Rounded
-expx509 exp +Infinity -> Infinity
-precision: 2
-expx511 exp -Infinity -> 0
-expx512 exp -10 -> 0.000045 Inexact Rounded
-expx513 exp -1 -> 0.37 Inexact Rounded
-expx514 exp 0 -> 1
-expx515 exp -0 -> 1
-expx516 exp 1 -> 2.7 Inexact Rounded
-expx517 exp 0.693147181 -> 2.0 Inexact Rounded
-expx518 exp 10 -> 2.2E+4 Inexact Rounded
-expx519 exp +Infinity -> Infinity
-precision: 1
-expx521 exp -Infinity -> 0
-expx522 exp -10 -> 0.00005 Inexact Rounded
-expx523 exp -1 -> 0.4 Inexact Rounded
-expx524 exp 0 -> 1
-expx525 exp -0 -> 1
-expx526 exp 1 -> 3 Inexact Rounded
-expx527 exp 0.693147181 -> 2 Inexact Rounded
-expx528 exp 10 -> 2E+4 Inexact Rounded
-expx529 exp +Infinity -> Infinity
-
--- overflows, including some overprecise borderlines
-precision: 7
-maxExponent: 384
-minExponent: -383
-expx701 exp 1000000000 -> Infinity Overflow Inexact Rounded
-expx702 exp 100000000 -> Infinity Overflow Inexact Rounded
-expx703 exp 10000000 -> Infinity Overflow Inexact Rounded
-expx704 exp 1000000 -> Infinity Overflow Inexact Rounded
-expx705 exp 100000 -> Infinity Overflow Inexact Rounded
-expx706 exp 10000 -> Infinity Overflow Inexact Rounded
-expx707 exp 1000 -> Infinity Overflow Inexact Rounded
-expx708 exp 886.4952608 -> Infinity Overflow Inexact Rounded
-expx709 exp 886.4952607 -> 9.999999E+384 Inexact Rounded
-expx710 exp 886.49527 -> Infinity Overflow Inexact Rounded
-expx711 exp 886.49526 -> 9.999992E+384 Inexact Rounded
-precision: 16
-expx721 exp 886.4952608027075883 -> Infinity Overflow Inexact Rounded
-expx722 exp 886.4952608027075882 -> 9.999999999999999E+384 Inexact Rounded
-expx723 exp 886.49526080270759 -> Infinity Overflow Inexact Rounded
-expx724 exp 886.49526080270758 -> 9.999999999999917E+384 Inexact Rounded
-expx725 exp 886.4952608027076 -> Infinity Overflow Inexact Rounded
-expx726 exp 886.4952608027075 -> 9.999999999999117E+384 Inexact Rounded
--- and by special request ...
-precision: 15
-expx731 exp 886.495260802708 -> Infinity Overflow Inexact Rounded
-expx732 exp 886.495260802707 -> 9.99999999999412E+384 Inexact Rounded
-expx733 exp 886.495260802706 -> 9.99999999998412E+384 Inexact Rounded
-maxExponent: 999
-minExponent: -999
-expx735 exp 2302.58509299405 -> Infinity Overflow Inexact Rounded
-expx736 exp 2302.58509299404 -> 9.99999999994316E+999 Inexact Rounded
-expx737 exp 2302.58509299403 -> 9.99999999984316E+999 Inexact Rounded
-
--- subnormals and underflows, including underflow-to-zero edge point
-precision: 7
-maxExponent: 384
-minExponent: -383
-expx751 exp -1000000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx752 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx753 exp -10000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx754 exp -1000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx755 exp -100000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx756 exp -10000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx757 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
-expx758 exp -881.89009 -> 1.000001E-383 Inexact Rounded
-expx759 exp -881.8901 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
-expx760 exp -885 -> 4.4605E-385 Inexact Rounded Underflow Subnormal
-expx761 exp -888 -> 2.221E-386 Inexact Rounded Underflow Subnormal
-expx762 exp -890 -> 3.01E-387 Inexact Rounded Underflow Subnormal
-expx763 exp -892.9 -> 1.7E-388 Inexact Rounded Underflow Subnormal
-expx764 exp -893 -> 1.5E-388 Inexact Rounded Underflow Subnormal
-expx765 exp -893.5 -> 9E-389 Inexact Rounded Underflow Subnormal
-expx766 exp -895.7056 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx769 exp -895.8 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx770 exp -895.73 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx771 exp -896.3987 -> 1E-389 Inexact Rounded Underflow Subnormal
-expx772 exp -896.3988 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-expx773 exp -898.0081 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-expx774 exp -898.0082 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
-
--- special values
-maxexponent: 999
-minexponent: -999
-expx820 exp Inf -> Infinity
-expx821 exp -Inf -> 0
-expx822 exp NaN -> NaN
-expx823 exp sNaN -> NaN Invalid_operation
--- propagating NaNs
-expx824 exp sNaN123 -> NaN123 Invalid_operation
-expx825 exp -sNaN321 -> -NaN321 Invalid_operation
-expx826 exp NaN456 -> NaN456
-expx827 exp -NaN654 -> -NaN654
-expx828 exp NaN1 -> NaN1
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-expx901 exp -Infinity -> NaN Invalid_context
-precision: 99999999
-expx902 exp -Infinity -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-expx903 exp -Infinity -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-expx904 exp -Infinity -> 0
-maxExponent: 999999
-minExponent: -1000000
-expx905 exp -Infinity -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-expx906 exp -Infinity -> 0
-
---
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- Null test
-expx900 exp # -> NaN Invalid_operation
-
-
--- Randoms P=50, within 0-999
-Precision: 50
-maxExponent: 384
-minExponent: -383
-expx1501 exp 656.35397950590285612266095596539934213943872885728 -> 1.1243757610640319783611178528839652672062820040314E+285 Inexact Rounded
-expx1502 exp 0.93620571093652800225038550600780322831236082781471 -> 2.5502865130986176689199711857825771311178046842009 Inexact Rounded
-expx1503 exp 0.00000000000000008340785856601514714183373874105791 -> 1.0000000000000000834078585660151506202691740252512 Inexact Rounded
-expx1504 exp 0.00009174057262887789625745574686545163168788456203 -> 1.0000917447809239005146722341251524081006051473273 Inexact Rounded
-expx1505 exp 33.909116897973797735657751591014926629051117541243 -> 532773181025002.03543618901306726495870476617232229 Inexact Rounded
-expx1506 exp 0.00000740470413004406592124575295278456936809587311 -> 1.0000074047315449333590066395670306135567889210814 Inexact Rounded
-expx1507 exp 0.00000000000124854922222108802453746922483071445492 -> 1.0000000000012485492222218674621176239911424968263 Inexact Rounded
-expx1508 exp 4.1793280674155659794286951159430651258356014391382 -> 65.321946520147199404199787811336860087975118278185 Inexact Rounded
-expx1509 exp 485.43595745460655893746179890255529919221550201686 -> 6.6398403920459617255950476953129377459845366585463E+210 Inexact Rounded
-expx1510 exp 0.00000000003547259806590856032527875157830328156597 -> 1.0000000000354725980665377129320589406715000685515 Inexact Rounded
-expx1511 exp 0.00000000000000759621497339104047930616478635042678 -> 1.0000000000000075962149733910693305471257715463887 Inexact Rounded
-expx1512 exp 9.7959168821760339304571595474480640286072720233796 -> 17960.261146042955179164303653412650751681436352437 Inexact Rounded
-expx1513 exp 0.00000000566642006258290526783901451194943164535581 -> 1.0000000056664200786370634609832438815665249347650 Inexact Rounded
-expx1514 exp 741.29888791134298194088827572374718940925820027354 -> 8.7501694006317332808128946666402622432064923198731E+321 Inexact Rounded
-expx1515 exp 032.75573003552517668808529099897153710887014947935 -> 168125196578678.17725841108617955904425345631092339 Inexact Rounded
-expx1516 exp 42.333700726429333308594265553422902463737399437644 -> 2428245675864172475.4681119493045657797309369672012 Inexact Rounded
-expx1517 exp 0.00000000000000559682616876491888197609158802835798 -> 1.0000000000000055968261687649345442076732739577049 Inexact Rounded
-expx1518 exp 0.00000000000080703688668280193584758300973549486312 -> 1.0000000000008070368866831275901158164321867914342 Inexact Rounded
-expx1519 exp 640.72396012796509482382712891709072570653606838251 -> 1.8318094990683394229304133068983914236995326891045E+278 Inexact Rounded
-expx1520 exp 0.00000000000000509458922167631071416948112219512224 -> 1.0000000000000050945892216763236915891499324358556 Inexact Rounded
-expx1521 exp 6.7670394314315206378625221583973414660727960241395 -> 868.73613012822031367806248697092884415119568271315 Inexact Rounded
-expx1522 exp 04.823217407412963506638267226891024138054783122548 -> 124.36457929588837129731821077586705505565904205366 Inexact Rounded
-expx1523 exp 193.51307878701196403991208482520115359690106143615 -> 1.1006830872854715677390914655452261550768957576034E+84 Inexact Rounded
-expx1524 exp 5.7307749038303650539200345901210497015617393970463 -> 308.20800743106843083522721523715645950574866495196 Inexact Rounded
-expx1525 exp 0.00000000000095217825199797965200541169123743500267 -> 1.0000000000009521782519984329737172007991390381273 Inexact Rounded
-expx1526 exp 0.00027131440949183370966393682617930153495028919140 -> 1.0002713512185751022906058160480606598754913607364 Inexact Rounded
-expx1527 exp 0.00000000064503059114680682343002315662069272707123 -> 1.0000000006450305913548390552323517403613135496633 Inexact Rounded
-expx1528 exp 0.00000000000000095616643506527288866235238548440593 -> 1.0000000000000009561664350652733457894781582009094 Inexact Rounded
-expx1529 exp 0.00000000000000086449942811678650244459550252743433 -> 1.0000000000000008644994281167868761242261096529986 Inexact Rounded
-expx1530 exp 0.06223488355635359965683053157729204988381887621850 -> 1.0642122813392406657789688931838919323826250630831 Inexact Rounded
-expx1531 exp 0.00000400710807804429435502657131912308680674057053 -> 1.0000040071161065125925620890019319832127863559260 Inexact Rounded
-expx1532 exp 85.522796894744576211573232055494551429297878413017 -> 13870073686404228452757799770251085177.853337368935 Inexact Rounded
-expx1533 exp 9.1496720811363678696938036379756663548353399954363 -> 9411.3537122832743386783597629161763057370034495157 Inexact Rounded
-expx1534 exp 8.2215705240788294472944382056330516738577785177942 -> 3720.3406813383076953899654701615084425598377758189 Inexact Rounded
-expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
-expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
-expx1537 exp 33.555726197149525061455517784870570470833498096559 -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
-expx1538 exp 9.7898079803906215094140010009583375537259810398659 -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
-expx1539 exp 89.157697327174521542502447953032536541038636966347 -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
-expx1540 exp 25.022947600123328912029051897171319573322888514885 -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded
-
--- exp(1) at 34
-Precision: 34
-expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded
-
--- Randoms P=34, within 0-999
-Precision: 34
-maxExponent: 6144
-minExponent: -6143
-expx1201 exp 309.5948855821510212996700645087188 -> 2.853319692901387521201738015050724E+134 Inexact Rounded
-expx1202 exp 9.936543068706211420422803962680164 -> 20672.15839203171877476511093276022 Inexact Rounded
-expx1203 exp 6.307870323881505684429839491707908 -> 548.8747777054637296137277391754665 Inexact Rounded
-expx1204 exp 0.0003543281389438420535201308282503 -> 1.000354390920573746164733350843155 Inexact Rounded
-expx1205 exp 0.0000037087453363918375598394920229 -> 1.000003708752213796324841920189323 Inexact Rounded
-expx1206 exp 0.0020432312687512438040222444116585 -> 1.002045320088164826013561630975308 Inexact Rounded
-expx1207 exp 6.856313340032177672550343216129586 -> 949.8587981604144147983589660524396 Inexact Rounded
-expx1208 exp 0.0000000000402094928333815643326418 -> 1.000000000040209492834189965989612 Inexact Rounded
-expx1209 exp 0.0049610784722412117632647003545839 -> 1.004973404997901987039589029277833 Inexact Rounded
-expx1210 exp 0.0000891471883724066909746786702686 -> 1.000089151162101085412780088266699 Inexact Rounded
-expx1211 exp 08.59979170376061890684723211112566 -> 5430.528314920905714615339273738097 Inexact Rounded
-expx1212 exp 9.473117039341003854872778112752590 -> 13005.36234331224953460055897913917 Inexact Rounded
-expx1213 exp 0.0999060724692207648429969999310118 -> 1.105067116975190602296052700726802 Inexact Rounded
-expx1214 exp 0.0000000927804533555877884082269247 -> 1.000000092780457659694183954740772 Inexact Rounded
-expx1215 exp 0.0376578583872889916298772818265677 -> 1.038375900489771946477857818447556 Inexact Rounded
-expx1216 exp 261.6896411697539524911536116712307 -> 4.470613562127465095241600174941460E+113 Inexact Rounded
-expx1217 exp 0.0709997423269162980875824213889626 -> 1.073580949235407949417814485533172 Inexact Rounded
-expx1218 exp 0.0000000444605583295169895235658731 -> 1.000000044460559317887627657593900 Inexact Rounded
-expx1219 exp 0.0000021224072854777512281369815185 -> 1.000002122409537785687390631070906 Inexact Rounded
-expx1220 exp 547.5174462574156885473558485475052 -> 6.078629247383807942612114579728672E+237 Inexact Rounded
-expx1221 exp 0.0000009067598041615192002339844670 -> 1.000000906760215268314680115374387 Inexact Rounded
-expx1222 exp 0.0316476500308065365803455533244603 -> 1.032153761880187977658387961769034 Inexact Rounded
-expx1223 exp 84.46160530377645101833996706384473 -> 4.799644995897968383503269871697856E+36 Inexact Rounded
-expx1224 exp 0.0000000000520599740290848018904145 -> 1.000000000052059974030439922338393 Inexact Rounded
-expx1225 exp 0.0000006748530640093620665651726708 -> 1.000000674853291722742292331812997 Inexact Rounded
-expx1226 exp 0.0000000116853119761042020507916169 -> 1.000000011685312044377460306165203 Inexact Rounded
-expx1227 exp 0.0022593818094258636727616886693280 -> 1.002261936135876893707094845543461 Inexact Rounded
-expx1228 exp 0.0029398857673478912249856509667517 -> 1.002944211469495086813087651287012 Inexact Rounded
-expx1229 exp 0.7511480029928802775376270557636963 -> 2.119431734510320169806976569366789 Inexact Rounded
-expx1230 exp 174.9431952176750671150886423048447 -> 9.481222305374955011464619468044051E+75 Inexact Rounded
-expx1231 exp 0.0000810612451694136129199895164424 -> 1.000081064530720924186615149646920 Inexact Rounded
-expx1232 exp 51.06888989702669288180946272499035 -> 15098613888619165073959.89896018749 Inexact Rounded
-expx1233 exp 0.0000000005992887599437093651494510 -> 1.000000000599288760123282874082758 Inexact Rounded
-expx1234 exp 714.8549046761054856311108828903972 -> 2.867744544891081117381595080480784E+310 Inexact Rounded
-expx1235 exp 0.0000000004468247802990643645607110 -> 1.000000000446824780398890556720233 Inexact Rounded
-expx1236 exp 831.5818151589890366323551672043709 -> 1.417077409182624969435938062261655E+361 Inexact Rounded
-expx1237 exp 0.0000000006868323825179605747108044 -> 1.000000000686832382753829935602454 Inexact Rounded
-expx1238 exp 0.0000001306740266408976840228440255 -> 1.000000130674035178748675187648098 Inexact Rounded
-expx1239 exp 0.3182210609022267704811502412335163 -> 1.374680115667798185758927247894859 Inexact Rounded
-expx1240 exp 0.0147741234179104437440264644295501 -> 1.014883800239950682628277534839222 Inexact Rounded
-
--- Randoms P=16, within 0-99
-Precision: 16
-maxExponent: 384
-minExponent: -383
-expx1101 exp 8.473011527013724 -> 4783.900643969246 Inexact Rounded
-expx1102 exp 0.0000055753022764 -> 1.000005575317818 Inexact Rounded
-expx1103 exp 0.0000323474114482 -> 1.000032347934631 Inexact Rounded
-expx1104 exp 64.54374138544166 -> 1.073966476173531E+28 Inexact Rounded
-expx1105 exp 90.47203246416569 -> 1.956610887250643E+39 Inexact Rounded
-expx1106 exp 9.299931532342757 -> 10937.27033325227 Inexact Rounded
-expx1107 exp 8.759678437852203 -> 6372.062234495381 Inexact Rounded
-expx1108 exp 0.0000931755127172 -> 1.000093179853690 Inexact Rounded
-expx1109 exp 0.0000028101158373 -> 1.000002810119786 Inexact Rounded
-expx1110 exp 0.0000008008130919 -> 1.000000800813413 Inexact Rounded
-expx1111 exp 8.339771722299049 -> 4187.133803081878 Inexact Rounded
-expx1112 exp 0.0026140497995474 -> 1.002617469406750 Inexact Rounded
-expx1113 exp 0.7478033356261771 -> 2.112354781975418 Inexact Rounded
-expx1114 exp 51.77663761827966 -> 3.064135801120365E+22 Inexact Rounded
-expx1115 exp 0.1524989783061012 -> 1.164741272084955 Inexact Rounded
-expx1116 exp 0.0066298798669219 -> 1.006651906170791 Inexact Rounded
-expx1117 exp 9.955141865534960 -> 21060.23334287038 Inexact Rounded
-expx1118 exp 92.34503059198483 -> 1.273318993481226E+40 Inexact Rounded
-expx1119 exp 0.0000709388677346 -> 1.000070941383956 Inexact Rounded
-expx1120 exp 79.12883036433204 -> 2.318538899389243E+34 Inexact Rounded
-expx1121 exp 0.0000090881548873 -> 1.000009088196185 Inexact Rounded
-expx1122 exp 0.0424828809603411 -> 1.043398194245720 Inexact Rounded
-expx1123 exp 0.8009035891427416 -> 2.227552811933310 Inexact Rounded
-expx1124 exp 8.825786167283102 -> 6807.540455289995 Inexact Rounded
-expx1125 exp 1.535457249746275 -> 4.643448260146849 Inexact Rounded
-expx1126 exp 69.02254254355800 -> 9.464754500670653E+29 Inexact Rounded
-expx1127 exp 0.0007050554368713 -> 1.000705304046880 Inexact Rounded
-expx1128 exp 0.0000081206549504 -> 1.000008120687923 Inexact Rounded
-expx1129 exp 0.621774854641137 -> 1.862230298554903 Inexact Rounded
-expx1130 exp 3.847629031404354 -> 46.88177613568203 Inexact Rounded
-expx1131 exp 24.81250184697732 -> 59694268456.19966 Inexact Rounded
-expx1132 exp 5.107546500516044 -> 165.2643809755670 Inexact Rounded
-expx1133 exp 79.17810943951986 -> 2.435656372541360E+34 Inexact Rounded
-expx1134 exp 0.0051394695667015 -> 1.005152699295301 Inexact Rounded
-expx1135 exp 57.44504488501725 -> 8.872908566929688E+24 Inexact Rounded
-expx1136 exp 0.0000508388968036 -> 1.000050840189122 Inexact Rounded
-expx1137 exp 69.71309932148997 -> 1.888053740693541E+30 Inexact Rounded
-expx1138 exp 0.0064183412981502 -> 1.006438982988835 Inexact Rounded
-expx1139 exp 9.346991220814677 -> 11464.27802035082 Inexact Rounded
-expx1140 exp 33.09087139999152 -> 235062229168763.5 Inexact Rounded
-
--- Randoms P=7, within 0-9
-Precision: 7
-maxExponent: 96
-minExponent: -95
-expx1001 exp 2.395441 -> 10.97304 Inexact Rounded
-expx1002 exp 0.6406779 -> 1.897767 Inexact Rounded
-expx1003 exp 0.5618218 -> 1.753865 Inexact Rounded
-expx1004 exp 3.055120 -> 21.22373 Inexact Rounded
-expx1005 exp 1.536792 -> 4.649650 Inexact Rounded
-expx1006 exp 0.0801591 -> 1.083459 Inexact Rounded
-expx1007 exp 0.0966875 -> 1.101516 Inexact Rounded
-expx1008 exp 0.0646761 -> 1.066813 Inexact Rounded
-expx1009 exp 0.0095670 -> 1.009613 Inexact Rounded
-expx1010 exp 2.956859 -> 19.23745 Inexact Rounded
-expx1011 exp 7.504679 -> 1816.522 Inexact Rounded
-expx1012 exp 0.0045259 -> 1.004536 Inexact Rounded
-expx1013 exp 3.810071 -> 45.15364 Inexact Rounded
-expx1014 exp 1.502390 -> 4.492413 Inexact Rounded
-expx1015 exp 0.0321523 -> 1.032675 Inexact Rounded
-expx1016 exp 0.0057214 -> 1.005738 Inexact Rounded
-expx1017 exp 9.811445 -> 18241.33 Inexact Rounded
-expx1018 exp 3.245249 -> 25.66810 Inexact Rounded
-expx1019 exp 0.3189742 -> 1.375716 Inexact Rounded
-expx1020 exp 0.8621610 -> 2.368273 Inexact Rounded
-expx1021 exp 0.0122511 -> 1.012326 Inexact Rounded
-expx1022 exp 2.202088 -> 9.043877 Inexact Rounded
-expx1023 exp 8.778203 -> 6491.202 Inexact Rounded
-expx1024 exp 0.1896279 -> 1.208800 Inexact Rounded
-expx1025 exp 0.4510947 -> 1.570030 Inexact Rounded
-expx1026 exp 0.276413 -> 1.318392 Inexact Rounded
-expx1027 exp 4.490067 -> 89.12742 Inexact Rounded
-expx1028 exp 0.0439786 -> 1.044960 Inexact Rounded
-expx1029 exp 0.8168245 -> 2.263301 Inexact Rounded
-expx1030 exp 0.0391658 -> 1.039943 Inexact Rounded
-expx1031 exp 9.261816 -> 10528.24 Inexact Rounded
-expx1032 exp 9.611186 -> 14930.87 Inexact Rounded
-expx1033 exp 9.118125 -> 9119.087 Inexact Rounded
-expx1034 exp 9.469083 -> 12953.00 Inexact Rounded
-expx1035 exp 0.0499983 -> 1.051269 Inexact Rounded
-expx1036 exp 0.0050746 -> 1.005087 Inexact Rounded
-expx1037 exp 0.0014696 -> 1.001471 Inexact Rounded
-expx1038 exp 9.138494 -> 9306.739 Inexact Rounded
-expx1039 exp 0.0065436 -> 1.006565 Inexact Rounded
-expx1040 exp 0.7284803 -> 2.071930 Inexact Rounded
-
+------------------------------------------------------------------------
+-- exp.decTest -- decimal natural exponentiation --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- Tests of the exponential funtion. Currently all testcases here
+-- show results which are correctly rounded (within <= 0.5 ulp).
+
+extended: 1
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics (examples in specificiation, etc.)
+expx001 exp -Infinity -> 0
+expx002 exp -10 -> 0.0000453999298 Inexact Rounded
+expx003 exp -1 -> 0.367879441 Inexact Rounded
+expx004 exp 0 -> 1
+expx005 exp -0 -> 1
+expx006 exp 1 -> 2.71828183 Inexact Rounded
+expx007 exp 0.693147181 -> 2.00000000 Inexact Rounded
+expx008 exp 10 -> 22026.4658 Inexact Rounded
+expx009 exp +Infinity -> Infinity
+
+-- tiny edge cases
+precision: 7
+expx011 exp 0.1 -> 1.105171 Inexact Rounded
+expx012 exp 0.01 -> 1.010050 Inexact Rounded
+expx013 exp 0.001 -> 1.001001 Inexact Rounded
+expx014 exp 0.0001 -> 1.000100 Inexact Rounded
+expx015 exp 0.00001 -> 1.000010 Inexact Rounded
+expx016 exp 0.000001 -> 1.000001 Inexact Rounded
+expx017 exp 0.0000001 -> 1.000000 Inexact Rounded
+expx018 exp 0.0000003 -> 1.000000 Inexact Rounded
+expx019 exp 0.0000004 -> 1.000000 Inexact Rounded
+expx020 exp 0.0000005 -> 1.000001 Inexact Rounded
+expx021 exp 0.0000008 -> 1.000001 Inexact Rounded
+expx022 exp 0.0000009 -> 1.000001 Inexact Rounded
+expx023 exp 0.0000010 -> 1.000001 Inexact Rounded
+expx024 exp 0.0000011 -> 1.000001 Inexact Rounded
+expx025 exp 0.00000009 -> 1.000000 Inexact Rounded
+expx026 exp 0.00000005 -> 1.000000 Inexact Rounded
+expx027 exp 0.00000004 -> 1.000000 Inexact Rounded
+expx028 exp 0.00000001 -> 1.000000 Inexact Rounded
+
+-- and some more zeros
+expx030 exp 0.00000000 -> 1
+expx031 exp 0E+100 -> 1
+expx032 exp 0E-100 -> 1
+expx033 exp -0.00000000 -> 1
+expx034 exp -0E+100 -> 1
+expx035 exp -0E-100 -> 1
+
+-- basic e=0, e=1, e=2, e=4, e>=8 cases
+precision: 7
+expx041 exp 1 -> 2.718282 Inexact Rounded
+expx042 exp -1 -> 0.3678794 Inexact Rounded
+expx043 exp 10 -> 22026.47 Inexact Rounded
+expx044 exp -10 -> 0.00004539993 Inexact Rounded
+expx045 exp 100 -> 2.688117E+43 Inexact Rounded
+expx046 exp -100 -> 3.720076E-44 Inexact Rounded
+expx047 exp 1000 -> Infinity Overflow Inexact Rounded
+expx048 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx049 exp 100000000 -> Infinity Overflow Inexact Rounded
+expx050 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+
+-- miscellanea
+-- similar to 'VF bug' test, at 17, but with last digit corrected for decimal
+precision: 16
+expx055 exp -5.42410311287441459172E+2 -> 2.717658486884572E-236 Inexact Rounded
+-- result from NetRexx/Java prototype -> 2.7176584868845721117677929628617246054459644711108E-236
+-- result from Rexx (series) version -> 2.717658486884572111767792962861724605446E-236
+precision: 17
+expx056 exp -5.42410311287441459172E+2 -> 2.7176584868845721E-236 Inexact Rounded
+precision: 18
+expx057 exp -5.42410311287441459172E+2 -> 2.71765848688457211E-236 Inexact Rounded
+precision: 19
+expx058 exp -5.42410311287441459172E+2 -> 2.717658486884572112E-236 Inexact Rounded
+precision: 20
+expx059 exp -5.42410311287441459172E+2 -> 2.7176584868845721118E-236 Inexact Rounded
+
+-- rounding in areas of ..500.., ..499.., ..100.., ..999.. sequences
+precision: 50
+expx101 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
+precision: 31
+expx102 exp -9E-8 -> 0.9999999100000040499998785000027 Inexact Rounded
+precision: 30
+expx103 exp -9E-8 -> 0.999999910000004049999878500003 Inexact Rounded
+precision: 29
+expx104 exp -9E-8 -> 0.99999991000000404999987850000 Inexact Rounded
+precision: 28
+expx105 exp -9E-8 -> 0.9999999100000040499998785000 Inexact Rounded
+precision: 27
+expx106 exp -9E-8 -> 0.999999910000004049999878500 Inexact Rounded
+precision: 26
+expx107 exp -9E-8 -> 0.99999991000000404999987850 Inexact Rounded
+precision: 25
+expx108 exp -9E-8 -> 0.9999999100000040499998785 Inexact Rounded
+precision: 24
+expx109 exp -9E-8 -> 0.999999910000004049999879 Inexact Rounded
+precision: 23
+expx110 exp -9E-8 -> 0.99999991000000404999988 Inexact Rounded
+precision: 22
+expx111 exp -9E-8 -> 0.9999999100000040499999 Inexact Rounded
+precision: 21
+expx112 exp -9E-8 -> 0.999999910000004050000 Inexact Rounded
+precision: 20
+expx113 exp -9E-8 -> 0.99999991000000405000 Inexact Rounded
+precision: 19
+expx114 exp -9E-8 -> 0.9999999100000040500 Inexact Rounded
+precision: 18
+expx115 exp -9E-8 -> 0.999999910000004050 Inexact Rounded
+precision: 17
+expx116 exp -9E-8 -> 0.99999991000000405 Inexact Rounded
+precision: 16
+expx117 exp -9E-8 -> 0.9999999100000040 Inexact Rounded
+precision: 15
+expx118 exp -9E-8 -> 0.999999910000004 Inexact Rounded
+precision: 14
+expx119 exp -9E-8 -> 0.99999991000000 Inexact Rounded
+precision: 13
+expx120 exp -9E-8 -> 0.9999999100000 Inexact Rounded
+precision: 12
+expx121 exp -9E-8 -> 0.999999910000 Inexact Rounded
+precision: 11
+expx122 exp -9E-8 -> 0.99999991000 Inexact Rounded
+precision: 10
+expx123 exp -9E-8 -> 0.9999999100 Inexact Rounded
+precision: 9
+expx124 exp -9E-8 -> 0.999999910 Inexact Rounded
+precision: 8
+expx125 exp -9E-8 -> 0.99999991 Inexact Rounded
+precision: 7
+expx126 exp -9E-8 -> 0.9999999 Inexact Rounded
+precision: 6
+expx127 exp -9E-8 -> 1.00000 Inexact Rounded
+precision: 5
+expx128 exp -9E-8 -> 1.0000 Inexact Rounded
+precision: 4
+expx129 exp -9E-8 -> 1.000 Inexact Rounded
+precision: 3
+expx130 exp -9E-8 -> 1.00 Inexact Rounded
+precision: 2
+expx131 exp -9E-8 -> 1.0 Inexact Rounded
+precision: 1
+expx132 exp -9E-8 -> 1 Inexact Rounded
+
+
+-- sanity checks, with iteration counts [normalized so 0<=|x|<1]
+precision: 50
+
+expx210 exp 0 -> 1
+-- iterations: 2
+expx211 exp -1E-40 -> 0.99999999999999999999999999999999999999990000000000 Inexact Rounded
+-- iterations: 8
+expx212 exp -9E-7 -> 0.99999910000040499987850002733749507925073811240510 Inexact Rounded
+-- iterations: 6
+expx213 exp -9E-8 -> 0.99999991000000404999987850000273374995079250073811 Inexact Rounded
+-- iterations: 15
+expx214 exp -0.003 -> 0.99700449550337297601206623409756091074177480489845 Inexact Rounded
+-- iterations: 14
+expx215 exp -0.001 -> 0.99900049983337499166805535716765597470235590236008 Inexact Rounded
+-- iterations: 26
+expx216 exp -0.1 -> 0.90483741803595957316424905944643662119470536098040 Inexact Rounded
+-- iterations: 39
+expx217 exp -0.7 -> 0.49658530379140951470480009339752896170766716571182 Inexact Rounded
+-- iterations: 41
+expx218 exp -0.9 -> 0.40656965974059911188345423964562598783370337617038 Inexact Rounded
+-- iterations: 43
+expx219 exp -0.99 -> 0.37157669102204569053152411990820138691802885490501 Inexact Rounded
+-- iterations: 26
+expx220 exp -1 -> 0.36787944117144232159552377016146086744581113103177 Inexact Rounded
+-- iterations: 26
+expx221 exp -1.01 -> 0.36421897957152331975704629563734548959589139192482 Inexact Rounded
+-- iterations: 27
+expx222 exp -1.1 -> 0.33287108369807955328884690643131552161247952156921 Inexact Rounded
+-- iterations: 28
+expx223 exp -1.5 -> 0.22313016014842982893328047076401252134217162936108 Inexact Rounded
+-- iterations: 30
+expx224 exp -2 -> 0.13533528323661269189399949497248440340763154590958 Inexact Rounded
+-- iterations: 36
+expx225 exp -5 -> 0.0067379469990854670966360484231484242488495850273551 Inexact Rounded
+-- iterations: 26
+expx226 exp -10 -> 0.000045399929762484851535591515560550610237918088866565 Inexact Rounded
+-- iterations: 28
+expx227 exp -14 -> 8.3152871910356788406398514256526229460765836498457E-7 Inexact Rounded
+-- iterations: 29
+expx228 exp -15 -> 3.0590232050182578837147949770228963937082078081856E-7 Inexact Rounded
+-- iterations: 30
+expx233 exp 0 -> 1
+-- iterations: 2
+expx234 exp 1E-40 -> 1.0000000000000000000000000000000000000001000000000 Inexact Rounded
+-- iterations: 7
+expx235 exp 9E-7 -> 1.0000009000004050001215000273375049207507381125949 Inexact Rounded
+-- iterations: 6
+expx236 exp 9E-8 -> 1.0000000900000040500001215000027337500492075007381 Inexact Rounded
+-- iterations: 15
+expx237 exp 0.003 -> 1.0030045045033770260129340913489002053318727195619 Inexact Rounded
+-- iterations: 13
+expx238 exp 0.001 -> 1.0010005001667083416680557539930583115630762005807 Inexact Rounded
+-- iterations: 25
+expx239 exp 0.1 -> 1.1051709180756476248117078264902466682245471947375 Inexact Rounded
+-- iterations: 38
+expx240 exp 0.7 -> 2.0137527074704765216245493885830652700175423941459 Inexact Rounded
+-- iterations: 41
+expx241 exp 0.9 -> 2.4596031111569496638001265636024706954217723064401 Inexact Rounded
+-- iterations: 42
+expx242 exp 0.99 -> 2.6912344723492622890998794040710139721802931841030 Inexact Rounded
+-- iterations: 26
+expx243 exp 1 -> 2.7182818284590452353602874713526624977572470937000 Inexact Rounded
+-- iterations: 26
+expx244 exp 1.01 -> 2.7456010150169164939897763166603876240737508195960 Inexact Rounded
+-- iterations: 26
+expx245 exp 1.1 -> 3.0041660239464331120584079535886723932826810260163 Inexact Rounded
+-- iterations: 28
+expx246 exp 1.5 -> 4.4816890703380648226020554601192758190057498683697 Inexact Rounded
+-- iterations: 29
+expx247 exp 2 -> 7.3890560989306502272304274605750078131803155705518 Inexact Rounded
+-- iterations: 36
+expx248 exp 5 -> 148.41315910257660342111558004055227962348766759388 Inexact Rounded
+-- iterations: 26
+expx249 exp 10 -> 22026.465794806716516957900645284244366353512618557 Inexact Rounded
+-- iterations: 28
+expx250 exp 14 -> 1202604.2841647767777492367707678594494124865433761 Inexact Rounded
+-- iterations: 28
+expx251 exp 15 -> 3269017.3724721106393018550460917213155057385438200 Inexact Rounded
+-- iterations: 29
+
+-- a biggie [result verified 3 ways]
+precision: 250
+expx260 exp 1 -> 2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427427466391932003059921817413596629043572900334295260595630738132328627943490763233829880753195251019011573834187930702154089149934884167509244761460668 Inexact Rounded
+
+-- extreme range boundaries
+precision: 16
+maxExponent: 999999
+minExponent: -999999
+-- Ntiny boundary
+expx290 exp -2302618.022332529 -> 0E-1000014 Underflow Subnormal Inexact Rounded Clamped
+expx291 exp -2302618.022332528 -> 1E-1000014 Underflow Subnormal Inexact Rounded
+-- Nmax/10 and Nmax boundary
+expx292 exp 2302582.790408952 -> 9.999999993100277E+999998 Inexact Rounded
+expx293 exp 2302582.790408953 -> 1.000000000310028E+999999 Inexact Rounded
+expx294 exp 2302585.092993946 -> 9.999999003159870E+999999 Inexact Rounded
+expx295 exp 2302585.092994036 -> 9.999999903159821E+999999 Inexact Rounded
+expx296 exp 2302585.092994045 -> 9.999999993159820E+999999 Inexact Rounded
+expx297 exp 2302585.092994046 -> Infinity Overflow Inexact Rounded
+
+-- 0<-x<<1 effects
+precision: 30
+expx320 exp -4.9999999999999E-8 -> 0.999999950000001250000979166617 Inexact Rounded
+expx321 exp -5.0000000000000E-8 -> 0.999999950000001249999979166667 Inexact Rounded
+expx322 exp -5.0000000000001E-8 -> 0.999999950000001249998979166717 Inexact Rounded
+precision: 20
+expx323 exp -4.9999999999999E-8 -> 0.99999995000000125000 Inexact Rounded
+expx324 exp -5.0000000000000E-8 -> 0.99999995000000125000 Inexact Rounded
+expx325 exp -5.0000000000001E-8 -> 0.99999995000000125000 Inexact Rounded
+precision: 14
+expx326 exp -4.9999999999999E-8 -> 0.99999995000000 Inexact Rounded
+expx327 exp -5.0000000000000E-8 -> 0.99999995000000 Inexact Rounded
+expx328 exp -5.0000000000001E-8 -> 0.99999995000000 Inexact Rounded
+-- overprecise and 0<-x<<1
+precision: 8
+expx330 exp -4.9999999999999E-8 -> 0.99999995 Inexact Rounded
+expx331 exp -5.0000000000000E-8 -> 0.99999995 Inexact Rounded
+expx332 exp -5.0000000000001E-8 -> 0.99999995 Inexact Rounded
+precision: 7
+expx333 exp -4.9999999999999E-8 -> 1.000000 Inexact Rounded
+expx334 exp -5.0000000000000E-8 -> 1.000000 Inexact Rounded
+expx335 exp -5.0000000000001E-8 -> 1.000000 Inexact Rounded
+precision: 3
+expx336 exp -4.9999999999999E-8 -> 1.00 Inexact Rounded
+expx337 exp -5.0000000000000E-8 -> 1.00 Inexact Rounded
+expx338 exp -5.0000000000001E-8 -> 1.00 Inexact Rounded
+
+-- 0<x<<1 effects
+precision: 30
+expx340 exp 4.9999999999999E-8 -> 1.00000005000000124999902083328 Inexact Rounded
+expx341 exp 5.0000000000000E-8 -> 1.00000005000000125000002083333 Inexact Rounded
+expx342 exp 5.0000000000001E-8 -> 1.00000005000000125000102083338 Inexact Rounded
+precision: 20
+expx343 exp 4.9999999999999E-8 -> 1.0000000500000012500 Inexact Rounded
+expx344 exp 5.0000000000000E-8 -> 1.0000000500000012500 Inexact Rounded
+expx345 exp 5.0000000000001E-8 -> 1.0000000500000012500 Inexact Rounded
+precision: 14
+expx346 exp 4.9999999999999E-8 -> 1.0000000500000 Inexact Rounded
+expx347 exp 5.0000000000000E-8 -> 1.0000000500000 Inexact Rounded
+expx348 exp 5.0000000000001E-8 -> 1.0000000500000 Inexact Rounded
+-- overprecise and 0<x<<1
+precision: 8
+expx350 exp 4.9999999999999E-8 -> 1.0000001 Inexact Rounded
+expx351 exp 5.0000000000000E-8 -> 1.0000001 Inexact Rounded
+expx352 exp 5.0000000000001E-8 -> 1.0000001 Inexact Rounded
+precision: 7
+expx353 exp 4.9999999999999E-8 -> 1.000000 Inexact Rounded
+expx354 exp 5.0000000000000E-8 -> 1.000000 Inexact Rounded
+expx355 exp 5.0000000000001E-8 -> 1.000000 Inexact Rounded
+precision: 3
+expx356 exp 4.9999999999999E-8 -> 1.00 Inexact Rounded
+expx357 exp 5.0000000000000E-8 -> 1.00 Inexact Rounded
+expx358 exp 5.0000000000001E-8 -> 1.00 Inexact Rounded
+
+-- cases near 1 -- 1 2345678901234567890
+precision: 20
+expx401 exp 0.99999999999996 -> 2.7182818284589365041 Inexact Rounded
+expx402 exp 0.99999999999997 -> 2.7182818284589636869 Inexact Rounded
+expx403 exp 0.99999999999998 -> 2.7182818284589908697 Inexact Rounded
+expx404 exp 0.99999999999999 -> 2.7182818284590180525 Inexact Rounded
+expx405 exp 1.0000000000000 -> 2.7182818284590452354 Inexact Rounded
+expx406 exp 1.0000000000001 -> 2.7182818284593170635 Inexact Rounded
+expx407 exp 1.0000000000002 -> 2.7182818284595888917 Inexact Rounded
+precision: 14
+expx411 exp 0.99999999999996 -> 2.7182818284589 Inexact Rounded
+expx412 exp 0.99999999999997 -> 2.7182818284590 Inexact Rounded
+expx413 exp 0.99999999999998 -> 2.7182818284590 Inexact Rounded
+expx414 exp 0.99999999999999 -> 2.7182818284590 Inexact Rounded
+expx415 exp 1.0000000000000 -> 2.7182818284590 Inexact Rounded
+expx416 exp 1.0000000000001 -> 2.7182818284593 Inexact Rounded
+expx417 exp 1.0000000000002 -> 2.7182818284596 Inexact Rounded
+-- overprecise...
+precision: 7
+expx421 exp 0.99999999999996 -> 2.718282 Inexact Rounded
+expx422 exp 0.99999999999997 -> 2.718282 Inexact Rounded
+expx423 exp 0.99999999999998 -> 2.718282 Inexact Rounded
+expx424 exp 0.99999999999999 -> 2.718282 Inexact Rounded
+expx425 exp 1.0000000000001 -> 2.718282 Inexact Rounded
+expx426 exp 1.0000000000002 -> 2.718282 Inexact Rounded
+expx427 exp 1.0000000000003 -> 2.718282 Inexact Rounded
+precision: 2
+expx431 exp 0.99999999999996 -> 2.7 Inexact Rounded
+expx432 exp 0.99999999999997 -> 2.7 Inexact Rounded
+expx433 exp 0.99999999999998 -> 2.7 Inexact Rounded
+expx434 exp 0.99999999999999 -> 2.7 Inexact Rounded
+expx435 exp 1.0000000000001 -> 2.7 Inexact Rounded
+expx436 exp 1.0000000000002 -> 2.7 Inexact Rounded
+expx437 exp 1.0000000000003 -> 2.7 Inexact Rounded
+
+-- basics at low precisions
+precision: 3
+expx501 exp -Infinity -> 0
+expx502 exp -10 -> 0.0000454 Inexact Rounded
+expx503 exp -1 -> 0.368 Inexact Rounded
+expx504 exp 0 -> 1
+expx505 exp -0 -> 1
+expx506 exp 1 -> 2.72 Inexact Rounded
+expx507 exp 0.693147181 -> 2.00 Inexact Rounded
+expx508 exp 10 -> 2.20E+4 Inexact Rounded
+expx509 exp +Infinity -> Infinity
+precision: 2
+expx511 exp -Infinity -> 0
+expx512 exp -10 -> 0.000045 Inexact Rounded
+expx513 exp -1 -> 0.37 Inexact Rounded
+expx514 exp 0 -> 1
+expx515 exp -0 -> 1
+expx516 exp 1 -> 2.7 Inexact Rounded
+expx517 exp 0.693147181 -> 2.0 Inexact Rounded
+expx518 exp 10 -> 2.2E+4 Inexact Rounded
+expx519 exp +Infinity -> Infinity
+precision: 1
+expx521 exp -Infinity -> 0
+expx522 exp -10 -> 0.00005 Inexact Rounded
+expx523 exp -1 -> 0.4 Inexact Rounded
+expx524 exp 0 -> 1
+expx525 exp -0 -> 1
+expx526 exp 1 -> 3 Inexact Rounded
+expx527 exp 0.693147181 -> 2 Inexact Rounded
+expx528 exp 10 -> 2E+4 Inexact Rounded
+expx529 exp +Infinity -> Infinity
+
+-- overflows, including some overprecise borderlines
+precision: 7
+maxExponent: 384
+minExponent: -383
+expx701 exp 1000000000 -> Infinity Overflow Inexact Rounded
+expx702 exp 100000000 -> Infinity Overflow Inexact Rounded
+expx703 exp 10000000 -> Infinity Overflow Inexact Rounded
+expx704 exp 1000000 -> Infinity Overflow Inexact Rounded
+expx705 exp 100000 -> Infinity Overflow Inexact Rounded
+expx706 exp 10000 -> Infinity Overflow Inexact Rounded
+expx707 exp 1000 -> Infinity Overflow Inexact Rounded
+expx708 exp 886.4952608 -> Infinity Overflow Inexact Rounded
+expx709 exp 886.4952607 -> 9.999999E+384 Inexact Rounded
+expx710 exp 886.49527 -> Infinity Overflow Inexact Rounded
+expx711 exp 886.49526 -> 9.999992E+384 Inexact Rounded
+precision: 16
+expx721 exp 886.4952608027075883 -> Infinity Overflow Inexact Rounded
+expx722 exp 886.4952608027075882 -> 9.999999999999999E+384 Inexact Rounded
+expx723 exp 886.49526080270759 -> Infinity Overflow Inexact Rounded
+expx724 exp 886.49526080270758 -> 9.999999999999917E+384 Inexact Rounded
+expx725 exp 886.4952608027076 -> Infinity Overflow Inexact Rounded
+expx726 exp 886.4952608027075 -> 9.999999999999117E+384 Inexact Rounded
+-- and by special request ...
+precision: 15
+expx731 exp 886.495260802708 -> Infinity Overflow Inexact Rounded
+expx732 exp 886.495260802707 -> 9.99999999999412E+384 Inexact Rounded
+expx733 exp 886.495260802706 -> 9.99999999998412E+384 Inexact Rounded
+maxExponent: 999
+minExponent: -999
+expx735 exp 2302.58509299405 -> Infinity Overflow Inexact Rounded
+expx736 exp 2302.58509299404 -> 9.99999999994316E+999 Inexact Rounded
+expx737 exp 2302.58509299403 -> 9.99999999984316E+999 Inexact Rounded
+
+-- subnormals and underflows, including underflow-to-zero edge point
+precision: 7
+maxExponent: 384
+minExponent: -383
+expx751 exp -1000000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx752 exp -100000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx753 exp -10000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx754 exp -1000000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx755 exp -100000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx756 exp -10000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx757 exp -1000 -> 0E-389 Underflow Inexact Rounded Clamped Subnormal
+expx758 exp -881.89009 -> 1.000001E-383 Inexact Rounded
+expx759 exp -881.8901 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
+expx760 exp -885 -> 4.4605E-385 Inexact Rounded Underflow Subnormal
+expx761 exp -888 -> 2.221E-386 Inexact Rounded Underflow Subnormal
+expx762 exp -890 -> 3.01E-387 Inexact Rounded Underflow Subnormal
+expx763 exp -892.9 -> 1.7E-388 Inexact Rounded Underflow Subnormal
+expx764 exp -893 -> 1.5E-388 Inexact Rounded Underflow Subnormal
+expx765 exp -893.5 -> 9E-389 Inexact Rounded Underflow Subnormal
+expx766 exp -895.7056 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx769 exp -895.8 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx770 exp -895.73 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx771 exp -896.3987 -> 1E-389 Inexact Rounded Underflow Subnormal
+expx772 exp -896.3988 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+expx773 exp -898.0081 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+expx774 exp -898.0082 -> 0E-389 Inexact Rounded Underflow Subnormal Clamped
+
+-- special values
+maxexponent: 999
+minexponent: -999
+expx820 exp Inf -> Infinity
+expx821 exp -Inf -> 0
+expx822 exp NaN -> NaN
+expx823 exp sNaN -> NaN Invalid_operation
+-- propagating NaNs
+expx824 exp sNaN123 -> NaN123 Invalid_operation
+expx825 exp -sNaN321 -> -NaN321 Invalid_operation
+expx826 exp NaN456 -> NaN456
+expx827 exp -NaN654 -> -NaN654
+expx828 exp NaN1 -> NaN1
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+expx901 exp -Infinity -> NaN Invalid_context
+precision: 99999999
+expx902 exp -Infinity -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+expx903 exp -Infinity -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+expx904 exp -Infinity -> 0
+maxExponent: 999999
+minExponent: -1000000
+expx905 exp -Infinity -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+expx906 exp -Infinity -> 0
+
+--
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- Null test
+expx900 exp # -> NaN Invalid_operation
+
+
+-- Randoms P=50, within 0-999
+Precision: 50
+maxExponent: 384
+minExponent: -383
+expx1501 exp 656.35397950590285612266095596539934213943872885728 -> 1.1243757610640319783611178528839652672062820040314E+285 Inexact Rounded
+expx1502 exp 0.93620571093652800225038550600780322831236082781471 -> 2.5502865130986176689199711857825771311178046842009 Inexact Rounded
+expx1503 exp 0.00000000000000008340785856601514714183373874105791 -> 1.0000000000000000834078585660151506202691740252512 Inexact Rounded
+expx1504 exp 0.00009174057262887789625745574686545163168788456203 -> 1.0000917447809239005146722341251524081006051473273 Inexact Rounded
+expx1505 exp 33.909116897973797735657751591014926629051117541243 -> 532773181025002.03543618901306726495870476617232229 Inexact Rounded
+expx1506 exp 0.00000740470413004406592124575295278456936809587311 -> 1.0000074047315449333590066395670306135567889210814 Inexact Rounded
+expx1507 exp 0.00000000000124854922222108802453746922483071445492 -> 1.0000000000012485492222218674621176239911424968263 Inexact Rounded
+expx1508 exp 4.1793280674155659794286951159430651258356014391382 -> 65.321946520147199404199787811336860087975118278185 Inexact Rounded
+expx1509 exp 485.43595745460655893746179890255529919221550201686 -> 6.6398403920459617255950476953129377459845366585463E+210 Inexact Rounded
+expx1510 exp 0.00000000003547259806590856032527875157830328156597 -> 1.0000000000354725980665377129320589406715000685515 Inexact Rounded
+expx1511 exp 0.00000000000000759621497339104047930616478635042678 -> 1.0000000000000075962149733910693305471257715463887 Inexact Rounded
+expx1512 exp 9.7959168821760339304571595474480640286072720233796 -> 17960.261146042955179164303653412650751681436352437 Inexact Rounded
+expx1513 exp 0.00000000566642006258290526783901451194943164535581 -> 1.0000000056664200786370634609832438815665249347650 Inexact Rounded
+expx1514 exp 741.29888791134298194088827572374718940925820027354 -> 8.7501694006317332808128946666402622432064923198731E+321 Inexact Rounded
+expx1515 exp 032.75573003552517668808529099897153710887014947935 -> 168125196578678.17725841108617955904425345631092339 Inexact Rounded
+expx1516 exp 42.333700726429333308594265553422902463737399437644 -> 2428245675864172475.4681119493045657797309369672012 Inexact Rounded
+expx1517 exp 0.00000000000000559682616876491888197609158802835798 -> 1.0000000000000055968261687649345442076732739577049 Inexact Rounded
+expx1518 exp 0.00000000000080703688668280193584758300973549486312 -> 1.0000000000008070368866831275901158164321867914342 Inexact Rounded
+expx1519 exp 640.72396012796509482382712891709072570653606838251 -> 1.8318094990683394229304133068983914236995326891045E+278 Inexact Rounded
+expx1520 exp 0.00000000000000509458922167631071416948112219512224 -> 1.0000000000000050945892216763236915891499324358556 Inexact Rounded
+expx1521 exp 6.7670394314315206378625221583973414660727960241395 -> 868.73613012822031367806248697092884415119568271315 Inexact Rounded
+expx1522 exp 04.823217407412963506638267226891024138054783122548 -> 124.36457929588837129731821077586705505565904205366 Inexact Rounded
+expx1523 exp 193.51307878701196403991208482520115359690106143615 -> 1.1006830872854715677390914655452261550768957576034E+84 Inexact Rounded
+expx1524 exp 5.7307749038303650539200345901210497015617393970463 -> 308.20800743106843083522721523715645950574866495196 Inexact Rounded
+expx1525 exp 0.00000000000095217825199797965200541169123743500267 -> 1.0000000000009521782519984329737172007991390381273 Inexact Rounded
+expx1526 exp 0.00027131440949183370966393682617930153495028919140 -> 1.0002713512185751022906058160480606598754913607364 Inexact Rounded
+expx1527 exp 0.00000000064503059114680682343002315662069272707123 -> 1.0000000006450305913548390552323517403613135496633 Inexact Rounded
+expx1528 exp 0.00000000000000095616643506527288866235238548440593 -> 1.0000000000000009561664350652733457894781582009094 Inexact Rounded
+expx1529 exp 0.00000000000000086449942811678650244459550252743433 -> 1.0000000000000008644994281167868761242261096529986 Inexact Rounded
+expx1530 exp 0.06223488355635359965683053157729204988381887621850 -> 1.0642122813392406657789688931838919323826250630831 Inexact Rounded
+expx1531 exp 0.00000400710807804429435502657131912308680674057053 -> 1.0000040071161065125925620890019319832127863559260 Inexact Rounded
+expx1532 exp 85.522796894744576211573232055494551429297878413017 -> 13870073686404228452757799770251085177.853337368935 Inexact Rounded
+expx1533 exp 9.1496720811363678696938036379756663548353399954363 -> 9411.3537122832743386783597629161763057370034495157 Inexact Rounded
+expx1534 exp 8.2215705240788294472944382056330516738577785177942 -> 3720.3406813383076953899654701615084425598377758189 Inexact Rounded
+expx1535 exp 0.00000000015772064569640613142823203726821076239561 -> 1.0000000001577206457088440324683315788358926129830 Inexact Rounded
+expx1536 exp 0.58179346473959531432624153576883440625538017532480 -> 1.7892445018275360163797022372655837188423194863605 Inexact Rounded
+expx1537 exp 33.555726197149525061455517784870570470833498096559 -> 374168069896324.62578073148993526626307095854407952 Inexact Rounded
+expx1538 exp 9.7898079803906215094140010009583375537259810398659 -> 17850.878119912208888217100998019986634620368538426 Inexact Rounded
+expx1539 exp 89.157697327174521542502447953032536541038636966347 -> 525649152320166503771224149330448089550.67293829227 Inexact Rounded
+expx1540 exp 25.022947600123328912029051897171319573322888514885 -> 73676343442.952517824345431437683153304645851960524 Inexact Rounded
+
+-- exp(1) at 34
+Precision: 34
+expx1200 exp 1 -> 2.718281828459045235360287471352662 Inexact Rounded
+
+-- Randoms P=34, within 0-999
+Precision: 34
+maxExponent: 6144
+minExponent: -6143
+expx1201 exp 309.5948855821510212996700645087188 -> 2.853319692901387521201738015050724E+134 Inexact Rounded
+expx1202 exp 9.936543068706211420422803962680164 -> 20672.15839203171877476511093276022 Inexact Rounded
+expx1203 exp 6.307870323881505684429839491707908 -> 548.8747777054637296137277391754665 Inexact Rounded
+expx1204 exp 0.0003543281389438420535201308282503 -> 1.000354390920573746164733350843155 Inexact Rounded
+expx1205 exp 0.0000037087453363918375598394920229 -> 1.000003708752213796324841920189323 Inexact Rounded
+expx1206 exp 0.0020432312687512438040222444116585 -> 1.002045320088164826013561630975308 Inexact Rounded
+expx1207 exp 6.856313340032177672550343216129586 -> 949.8587981604144147983589660524396 Inexact Rounded
+expx1208 exp 0.0000000000402094928333815643326418 -> 1.000000000040209492834189965989612 Inexact Rounded
+expx1209 exp 0.0049610784722412117632647003545839 -> 1.004973404997901987039589029277833 Inexact Rounded
+expx1210 exp 0.0000891471883724066909746786702686 -> 1.000089151162101085412780088266699 Inexact Rounded
+expx1211 exp 08.59979170376061890684723211112566 -> 5430.528314920905714615339273738097 Inexact Rounded
+expx1212 exp 9.473117039341003854872778112752590 -> 13005.36234331224953460055897913917 Inexact Rounded
+expx1213 exp 0.0999060724692207648429969999310118 -> 1.105067116975190602296052700726802 Inexact Rounded
+expx1214 exp 0.0000000927804533555877884082269247 -> 1.000000092780457659694183954740772 Inexact Rounded
+expx1215 exp 0.0376578583872889916298772818265677 -> 1.038375900489771946477857818447556 Inexact Rounded
+expx1216 exp 261.6896411697539524911536116712307 -> 4.470613562127465095241600174941460E+113 Inexact Rounded
+expx1217 exp 0.0709997423269162980875824213889626 -> 1.073580949235407949417814485533172 Inexact Rounded
+expx1218 exp 0.0000000444605583295169895235658731 -> 1.000000044460559317887627657593900 Inexact Rounded
+expx1219 exp 0.0000021224072854777512281369815185 -> 1.000002122409537785687390631070906 Inexact Rounded
+expx1220 exp 547.5174462574156885473558485475052 -> 6.078629247383807942612114579728672E+237 Inexact Rounded
+expx1221 exp 0.0000009067598041615192002339844670 -> 1.000000906760215268314680115374387 Inexact Rounded
+expx1222 exp 0.0316476500308065365803455533244603 -> 1.032153761880187977658387961769034 Inexact Rounded
+expx1223 exp 84.46160530377645101833996706384473 -> 4.799644995897968383503269871697856E+36 Inexact Rounded
+expx1224 exp 0.0000000000520599740290848018904145 -> 1.000000000052059974030439922338393 Inexact Rounded
+expx1225 exp 0.0000006748530640093620665651726708 -> 1.000000674853291722742292331812997 Inexact Rounded
+expx1226 exp 0.0000000116853119761042020507916169 -> 1.000000011685312044377460306165203 Inexact Rounded
+expx1227 exp 0.0022593818094258636727616886693280 -> 1.002261936135876893707094845543461 Inexact Rounded
+expx1228 exp 0.0029398857673478912249856509667517 -> 1.002944211469495086813087651287012 Inexact Rounded
+expx1229 exp 0.7511480029928802775376270557636963 -> 2.119431734510320169806976569366789 Inexact Rounded
+expx1230 exp 174.9431952176750671150886423048447 -> 9.481222305374955011464619468044051E+75 Inexact Rounded
+expx1231 exp 0.0000810612451694136129199895164424 -> 1.000081064530720924186615149646920 Inexact Rounded
+expx1232 exp 51.06888989702669288180946272499035 -> 15098613888619165073959.89896018749 Inexact Rounded
+expx1233 exp 0.0000000005992887599437093651494510 -> 1.000000000599288760123282874082758 Inexact Rounded
+expx1234 exp 714.8549046761054856311108828903972 -> 2.867744544891081117381595080480784E+310 Inexact Rounded
+expx1235 exp 0.0000000004468247802990643645607110 -> 1.000000000446824780398890556720233 Inexact Rounded
+expx1236 exp 831.5818151589890366323551672043709 -> 1.417077409182624969435938062261655E+361 Inexact Rounded
+expx1237 exp 0.0000000006868323825179605747108044 -> 1.000000000686832382753829935602454 Inexact Rounded
+expx1238 exp 0.0000001306740266408976840228440255 -> 1.000000130674035178748675187648098 Inexact Rounded
+expx1239 exp 0.3182210609022267704811502412335163 -> 1.374680115667798185758927247894859 Inexact Rounded
+expx1240 exp 0.0147741234179104437440264644295501 -> 1.014883800239950682628277534839222 Inexact Rounded
+
+-- Randoms P=16, within 0-99
+Precision: 16
+maxExponent: 384
+minExponent: -383
+expx1101 exp 8.473011527013724 -> 4783.900643969246 Inexact Rounded
+expx1102 exp 0.0000055753022764 -> 1.000005575317818 Inexact Rounded
+expx1103 exp 0.0000323474114482 -> 1.000032347934631 Inexact Rounded
+expx1104 exp 64.54374138544166 -> 1.073966476173531E+28 Inexact Rounded
+expx1105 exp 90.47203246416569 -> 1.956610887250643E+39 Inexact Rounded
+expx1106 exp 9.299931532342757 -> 10937.27033325227 Inexact Rounded
+expx1107 exp 8.759678437852203 -> 6372.062234495381 Inexact Rounded
+expx1108 exp 0.0000931755127172 -> 1.000093179853690 Inexact Rounded
+expx1109 exp 0.0000028101158373 -> 1.000002810119786 Inexact Rounded
+expx1110 exp 0.0000008008130919 -> 1.000000800813413 Inexact Rounded
+expx1111 exp 8.339771722299049 -> 4187.133803081878 Inexact Rounded
+expx1112 exp 0.0026140497995474 -> 1.002617469406750 Inexact Rounded
+expx1113 exp 0.7478033356261771 -> 2.112354781975418 Inexact Rounded
+expx1114 exp 51.77663761827966 -> 3.064135801120365E+22 Inexact Rounded
+expx1115 exp 0.1524989783061012 -> 1.164741272084955 Inexact Rounded
+expx1116 exp 0.0066298798669219 -> 1.006651906170791 Inexact Rounded
+expx1117 exp 9.955141865534960 -> 21060.23334287038 Inexact Rounded
+expx1118 exp 92.34503059198483 -> 1.273318993481226E+40 Inexact Rounded
+expx1119 exp 0.0000709388677346 -> 1.000070941383956 Inexact Rounded
+expx1120 exp 79.12883036433204 -> 2.318538899389243E+34 Inexact Rounded
+expx1121 exp 0.0000090881548873 -> 1.000009088196185 Inexact Rounded
+expx1122 exp 0.0424828809603411 -> 1.043398194245720 Inexact Rounded
+expx1123 exp 0.8009035891427416 -> 2.227552811933310 Inexact Rounded
+expx1124 exp 8.825786167283102 -> 6807.540455289995 Inexact Rounded
+expx1125 exp 1.535457249746275 -> 4.643448260146849 Inexact Rounded
+expx1126 exp 69.02254254355800 -> 9.464754500670653E+29 Inexact Rounded
+expx1127 exp 0.0007050554368713 -> 1.000705304046880 Inexact Rounded
+expx1128 exp 0.0000081206549504 -> 1.000008120687923 Inexact Rounded
+expx1129 exp 0.621774854641137 -> 1.862230298554903 Inexact Rounded
+expx1130 exp 3.847629031404354 -> 46.88177613568203 Inexact Rounded
+expx1131 exp 24.81250184697732 -> 59694268456.19966 Inexact Rounded
+expx1132 exp 5.107546500516044 -> 165.2643809755670 Inexact Rounded
+expx1133 exp 79.17810943951986 -> 2.435656372541360E+34 Inexact Rounded
+expx1134 exp 0.0051394695667015 -> 1.005152699295301 Inexact Rounded
+expx1135 exp 57.44504488501725 -> 8.872908566929688E+24 Inexact Rounded
+expx1136 exp 0.0000508388968036 -> 1.000050840189122 Inexact Rounded
+expx1137 exp 69.71309932148997 -> 1.888053740693541E+30 Inexact Rounded
+expx1138 exp 0.0064183412981502 -> 1.006438982988835 Inexact Rounded
+expx1139 exp 9.346991220814677 -> 11464.27802035082 Inexact Rounded
+expx1140 exp 33.09087139999152 -> 235062229168763.5 Inexact Rounded
+
+-- Randoms P=7, within 0-9
+Precision: 7
+maxExponent: 96
+minExponent: -95
+expx1001 exp 2.395441 -> 10.97304 Inexact Rounded
+expx1002 exp 0.6406779 -> 1.897767 Inexact Rounded
+expx1003 exp 0.5618218 -> 1.753865 Inexact Rounded
+expx1004 exp 3.055120 -> 21.22373 Inexact Rounded
+expx1005 exp 1.536792 -> 4.649650 Inexact Rounded
+expx1006 exp 0.0801591 -> 1.083459 Inexact Rounded
+expx1007 exp 0.0966875 -> 1.101516 Inexact Rounded
+expx1008 exp 0.0646761 -> 1.066813 Inexact Rounded
+expx1009 exp 0.0095670 -> 1.009613 Inexact Rounded
+expx1010 exp 2.956859 -> 19.23745 Inexact Rounded
+expx1011 exp 7.504679 -> 1816.522 Inexact Rounded
+expx1012 exp 0.0045259 -> 1.004536 Inexact Rounded
+expx1013 exp 3.810071 -> 45.15364 Inexact Rounded
+expx1014 exp 1.502390 -> 4.492413 Inexact Rounded
+expx1015 exp 0.0321523 -> 1.032675 Inexact Rounded
+expx1016 exp 0.0057214 -> 1.005738 Inexact Rounded
+expx1017 exp 9.811445 -> 18241.33 Inexact Rounded
+expx1018 exp 3.245249 -> 25.66810 Inexact Rounded
+expx1019 exp 0.3189742 -> 1.375716 Inexact Rounded
+expx1020 exp 0.8621610 -> 2.368273 Inexact Rounded
+expx1021 exp 0.0122511 -> 1.012326 Inexact Rounded
+expx1022 exp 2.202088 -> 9.043877 Inexact Rounded
+expx1023 exp 8.778203 -> 6491.202 Inexact Rounded
+expx1024 exp 0.1896279 -> 1.208800 Inexact Rounded
+expx1025 exp 0.4510947 -> 1.570030 Inexact Rounded
+expx1026 exp 0.276413 -> 1.318392 Inexact Rounded
+expx1027 exp 4.490067 -> 89.12742 Inexact Rounded
+expx1028 exp 0.0439786 -> 1.044960 Inexact Rounded
+expx1029 exp 0.8168245 -> 2.263301 Inexact Rounded
+expx1030 exp 0.0391658 -> 1.039943 Inexact Rounded
+expx1031 exp 9.261816 -> 10528.24 Inexact Rounded
+expx1032 exp 9.611186 -> 14930.87 Inexact Rounded
+expx1033 exp 9.118125 -> 9119.087 Inexact Rounded
+expx1034 exp 9.469083 -> 12953.00 Inexact Rounded
+expx1035 exp 0.0499983 -> 1.051269 Inexact Rounded
+expx1036 exp 0.0050746 -> 1.005087 Inexact Rounded
+expx1037 exp 0.0014696 -> 1.001471 Inexact Rounded
+expx1038 exp 9.138494 -> 9306.739 Inexact Rounded
+expx1039 exp 0.0065436 -> 1.006565 Inexact Rounded
+expx1040 exp 0.7284803 -> 2.071930 Inexact Rounded
+
diff --git a/Lib/test/decimaltestdata/extra.decTest b/Lib/test/decimaltestdata/extra.decTest
index b630d8e3f9d..fe8b77a6dd9 100644
--- a/Lib/test/decimaltestdata/extra.decTest
+++ b/Lib/test/decimaltestdata/extra.decTest
@@ -222,25 +222,12 @@ extr1700 power 10 1e-999999999 -> 1.000000000000000 Inexact Rounded
extr1701 power 100.0 -557.71e-742888888 -> 1.000000000000000 Inexact Rounded
extr1702 power 10 1e-100 -> 1.000000000000000 Inexact Rounded
--- Another one (see issue #12080). Thanks again to Stefan Krah.
-extr1703 power 4 -1.2e-999999999 -> 1.000000000000000 Inexact Rounded
-
-- A couple of interesting exact cases for power. Note that the specification
-- requires these to be reported as Inexact.
extr1710 power 1e375 56e-3 -> 1.000000000000000E+21 Inexact Rounded
extr1711 power 10000 0.75 -> 1000.000000000000 Inexact Rounded
extr1712 power 1e-24 0.875 -> 1.000000000000000E-21 Inexact Rounded
--- Some more exact cases, exercising power with negative second argument.
-extr1720 power 400 -0.5 -> 0.05000000000000000 Inexact Rounded
-extr1721 power 4096 -0.75 -> 0.001953125000000000 Inexact Rounded
-extr1722 power 625e4 -0.25 -> 0.02000000000000000 Inexact Rounded
-
--- Nonexact cases, to exercise some of the early exit conditions from
--- _power_exact.
-extr1730 power 2048 -0.75 -> 0.003284751622084822 Inexact Rounded
-
-
-- Tests for the is_* boolean operations
precision: 9
maxExponent: 999
diff --git a/Lib/test/decimaltestdata/fma.decTest b/Lib/test/decimaltestdata/fma.decTest
index a8197ef8a43..b0a81ca1791 100644
--- a/Lib/test/decimaltestdata/fma.decTest
+++ b/Lib/test/decimaltestdata/fma.decTest
@@ -1,3426 +1,3426 @@
-------------------------------------------------------------------------
--- fma.decTest -- decimal fused multiply add --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- These tests comprese three parts:
--- 1. Sanity checks and other three-operand tests (especially those
--- where the fused operation makes a difference)
--- 2. Multiply tests (third operand is neutral zero [0E+emax])
--- 3. Addition tests (first operand is 1)
--- The multiply and addition tests are extensive because FMA may have
--- its own dedicated multiplication or addition routine(s), and they
--- also inherently check the left-to-right properties.
-
--- Sanity checks
-fmax0001 fma 1 1 1 -> 2
-fmax0002 fma 1 1 2 -> 3
-fmax0003 fma 2 2 3 -> 7
-fmax0004 fma 9 9 9 -> 90
-fmax0005 fma -1 1 1 -> 0
-fmax0006 fma -1 1 2 -> 1
-fmax0007 fma -2 2 3 -> -1
-fmax0008 fma -9 9 9 -> -72
-fmax0011 fma 1 -1 1 -> 0
-fmax0012 fma 1 -1 2 -> 1
-fmax0013 fma 2 -2 3 -> -1
-fmax0014 fma 9 -9 9 -> -72
-fmax0015 fma 1 1 -1 -> 0
-fmax0016 fma 1 1 -2 -> -1
-fmax0017 fma 2 2 -3 -> 1
-fmax0018 fma 9 9 -9 -> 72
-fmax0019 fma 3 5 7 -> 22
-fmax0029 fma 3 -5 7 -> -8
-
--- non-integer exacts
-fma0100 fma 25.2 63.6 -438 -> 1164.72
-fma0101 fma 0.301 0.380 334 -> 334.114380
-fma0102 fma 49.2 -4.8 23.3 -> -212.86
-fma0103 fma 4.22 0.079 -94.6 -> -94.26662
-fma0104 fma 903 0.797 0.887 -> 720.578
-fma0105 fma 6.13 -161 65.9 -> -921.03
-fma0106 fma 28.2 727 5.45 -> 20506.85
-fma0107 fma 4 605 688 -> 3108
-fma0108 fma 93.3 0.19 0.226 -> 17.953
-fma0109 fma 0.169 -341 5.61 -> -52.019
-fma0110 fma -72.2 30 -51.2 -> -2217.2
-fma0111 fma -0.409 13 20.4 -> 15.083
-fma0112 fma 317 77.0 19.0 -> 24428.0
-fma0113 fma 47 6.58 1.62 -> 310.88
-fma0114 fma 1.36 0.984 0.493 -> 1.83124
-fma0115 fma 72.7 274 1.56 -> 19921.36
-fma0116 fma 335 847 83 -> 283828
-fma0117 fma 666 0.247 25.4 -> 189.902
-fma0118 fma -3.87 3.06 78.0 -> 66.1578
-fma0119 fma 0.742 192 35.6 -> 178.064
-fma0120 fma -91.6 5.29 0.153 -> -484.411
-
--- cases where result is different from separate multiply + add; each
--- is preceded by the result of unfused multiply and add
--- [this is about 20% of all similar cases in general]
--- 888565290 1557.96930 -86087.7578 -> 1.38435735E+12
-fma0201 fma 888565290 1557.96930 -86087.7578 -> 1.38435736E+12 Inexact Rounded
--- -85519342.9 735155419 42010431 -> -6.28700084E+16
-fma0205 fma -85519342.9 735155419 42010431 -> -6.28700083E+16 Inexact Rounded
--- -98025.5 -294603.472 10414348.2 -> 2.88890669E+10
-fma0208 fma -98025.5 -294603.472 10414348.2 -> 2.88890670E+10 Inexact Rounded
--- 5967627.39 83526540.6 498494.810 -> 4.98455271E+14
-fma0211 fma 5967627.39 83526540.6 498494.810 -> 4.98455272E+14 Inexact Rounded
--- 3456.9433 874.39518 197866.615 -> 3220601.18
-fma0216 fma 3456.9433 874.39518 197866.615 -> 3220601.17 Inexact Rounded
--- 62769.8287 2096.98927 48.420317 -> 131627705
-fma0218 fma 62769.8287 2096.98927 48.420317 -> 131627706 Inexact Rounded
--- -68.81500 59961113.9 -8988862 -> -4.13521291E+9
-fma0219 fma -68.81500 59961113.9 -8988862 -> -4.13521292E+9 Inexact Rounded
--- 2126341.02 63491.5152 302427455 -> 1.35307040E+11
-fma0226 fma 2126341.02 63491.5152 302427455 -> 1.35307041E+11 Inexact Rounded
-
-
--- Infinite combinations
-fmax0800 fma Inf Inf Inf -> Infinity
-fmax0801 fma Inf Inf -Inf -> NaN Invalid_operation
-fmax0802 fma Inf -Inf Inf -> NaN Invalid_operation
-fmax0803 fma Inf -Inf -Inf -> -Infinity
-fmax0804 fma -Inf Inf Inf -> NaN Invalid_operation
-fmax0805 fma -Inf Inf -Inf -> -Infinity
-fmax0806 fma -Inf -Inf Inf -> Infinity
-fmax0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
-fmax0808 fma -Inf 0 1 -> NaN Invalid_operation
-fmax0809 fma -Inf 0 NaN -> NaN Invalid_operation
-
--- Triple NaN propagation
-fmax0900 fma NaN2 NaN3 NaN5 -> NaN2
-fmax0901 fma 0 NaN3 NaN5 -> NaN3
-fmax0902 fma 0 0 NaN5 -> NaN5
--- first sNaN wins (consider qNaN from earlier sNaN being
--- overridden by an sNaN in third operand)
-fmax0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-fmax0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
-fmax0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
-fmax0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
-fmax0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
-fmax0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
-
--- MULTIPLICATION TESTS ------------------------------------------------
--- sanity checks (as base, above)
-fmax2000 fma 2 2 0E+999999 -> 4
-fmax2001 fma 2 3 0E+999999 -> 6
-fmax2002 fma 5 1 0E+999999 -> 5
-fmax2003 fma 5 2 0E+999999 -> 10
-fmax2004 fma 1.20 2 0E+999999 -> 2.40
-fmax2005 fma 1.20 0 0E+999999 -> 0.00
-fmax2006 fma 1.20 -2 0E+999999 -> -2.40
-fmax2007 fma -1.20 2 0E+999999 -> -2.40
-fmax2008 fma -1.20 0 0E+999999 -> 0.00
-fmax2009 fma -1.20 -2 0E+999999 -> 2.40
-fmax2010 fma 5.09 7.1 0E+999999 -> 36.139
-fmax2011 fma 2.5 4 0E+999999 -> 10.0
-fmax2012 fma 2.50 4 0E+999999 -> 10.00
-fmax2013 fma 1.23456789 1.00000000 0E+999999 -> 1.23456789 Rounded
-fmax2014 fma 9.999999999 9.999999999 0E+999999 -> 100.000000 Inexact Rounded
-fmax2015 fma 2.50 4 0E+999999 -> 10.00
-precision: 6
-fmax2016 fma 2.50 4 0E+999999 -> 10.00
-fmax2017 fma 9.999999 9.999999 0E+999999 -> 100.000 Inexact Rounded
-fmax2018 fma 9.999999 -9.999999 0E+999999 -> -100.000 Inexact Rounded
-fmax2019 fma -9.999999 9.999999 0E+999999 -> -100.000 Inexact Rounded
-fmax2020 fma -9.999999 -9.999999 0E+999999 -> 100.000 Inexact Rounded
-
--- 1999.12.21: next one is a edge case if intermediate longs are used
-precision: 15
-fmax2059 fma 999999999999 9765625 0E+999999 -> 9.76562499999023E+18 Inexact Rounded
-precision: 30
-fmax2160 fma 999999999999 9765625 0E+999999 -> 9765624999990234375
-precision: 9
------
-
--- zeros, etc.
-fmax2021 fma 0 0 0E+999999 -> 0
-fmax2022 fma 0 -0 0E+999999 -> 0
-fmax2023 fma -0 0 0E+999999 -> 0
-fmax2024 fma -0 -0 0E+999999 -> 0
-fmax2025 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2026 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2027 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2028 fma -0.0 -0.0 0E+999999 -> 0.00
-fmax2030 fma 5.00 1E-3 0E+999999 -> 0.00500
-fmax2031 fma 00.00 0.000 0E+999999 -> 0.00000
-fmax2032 fma 00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2033 fma 0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2034 fma -5.00 1E-3 0E+999999 -> -0.00500
-fmax2035 fma -00.00 0.000 0E+999999 -> 0.00000
-fmax2036 fma -00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2037 fma -0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2038 fma 5.00 -1E-3 0E+999999 -> -0.00500
-fmax2039 fma 00.00 -0.000 0E+999999 -> 0.00000
-fmax2040 fma 00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2041 fma 0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
-fmax2042 fma -5.00 -1E-3 0E+999999 -> 0.00500
-fmax2043 fma -00.00 -0.000 0E+999999 -> 0.00000
-fmax2044 fma -00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
-fmax2045 fma -0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
-
--- examples from decarith multiply
-fmax2050 fma 1.20 3 0E+999999 -> 3.60
-fmax2051 fma 7 3 0E+999999 -> 21
-fmax2052 fma 0.9 0.8 0E+999999 -> 0.72
-fmax2053 fma 0.9 -0 0E+999999 -> 0.0
-fmax2054 fma 654321 654321 0E+999999 -> 4.28135971E+11 Inexact Rounded
-
-fmax2060 fma 123.45 1e7 0E+999999 -> 1.2345E+9
-fmax2061 fma 123.45 1e8 0E+999999 -> 1.2345E+10
-fmax2062 fma 123.45 1e+9 0E+999999 -> 1.2345E+11
-fmax2063 fma 123.45 1e10 0E+999999 -> 1.2345E+12
-fmax2064 fma 123.45 1e11 0E+999999 -> 1.2345E+13
-fmax2065 fma 123.45 1e12 0E+999999 -> 1.2345E+14
-fmax2066 fma 123.45 1e13 0E+999999 -> 1.2345E+15
-
-
--- test some intermediate lengths
-precision: 9
-fmax2080 fma 0.1 123456789 0E+999999 -> 12345678.9
-fmax2081 fma 0.1 1234567891 0E+999999 -> 123456789 Inexact Rounded
-fmax2082 fma 0.1 12345678912 0E+999999 -> 1.23456789E+9 Inexact Rounded
-fmax2083 fma 0.1 12345678912345 0E+999999 -> 1.23456789E+12 Inexact Rounded
-fmax2084 fma 0.1 123456789 0E+999999 -> 12345678.9
-precision: 8
-fmax2085 fma 0.1 12345678912 0E+999999 -> 1.2345679E+9 Inexact Rounded
-fmax2086 fma 0.1 12345678912345 0E+999999 -> 1.2345679E+12 Inexact Rounded
-precision: 7
-fmax2087 fma 0.1 12345678912 0E+999999 -> 1.234568E+9 Inexact Rounded
-fmax2088 fma 0.1 12345678912345 0E+999999 -> 1.234568E+12 Inexact Rounded
-
-precision: 9
-fmax2090 fma 123456789 0.1 0E+999999 -> 12345678.9
-fmax2091 fma 1234567891 0.1 0E+999999 -> 123456789 Inexact Rounded
-fmax2092 fma 12345678912 0.1 0E+999999 -> 1.23456789E+9 Inexact Rounded
-fmax2093 fma 12345678912345 0.1 0E+999999 -> 1.23456789E+12 Inexact Rounded
-fmax2094 fma 123456789 0.1 0E+999999 -> 12345678.9
-precision: 8
-fmax2095 fma 12345678912 0.1 0E+999999 -> 1.2345679E+9 Inexact Rounded
-fmax2096 fma 12345678912345 0.1 0E+999999 -> 1.2345679E+12 Inexact Rounded
-precision: 7
-fmax2097 fma 12345678912 0.1 0E+999999 -> 1.234568E+9 Inexact Rounded
-fmax2098 fma 12345678912345 0.1 0E+999999 -> 1.234568E+12 Inexact Rounded
-
--- test some more edge cases and carries
-maxexponent: 9999
-minexponent: -9999
-precision: 33
-fmax2101 fma 9 9 0E+999999 -> 81
-fmax2102 fma 9 90 0E+999999 -> 810
-fmax2103 fma 9 900 0E+999999 -> 8100
-fmax2104 fma 9 9000 0E+999999 -> 81000
-fmax2105 fma 9 90000 0E+999999 -> 810000
-fmax2106 fma 9 900000 0E+999999 -> 8100000
-fmax2107 fma 9 9000000 0E+999999 -> 81000000
-fmax2108 fma 9 90000000 0E+999999 -> 810000000
-fmax2109 fma 9 900000000 0E+999999 -> 8100000000
-fmax2110 fma 9 9000000000 0E+999999 -> 81000000000
-fmax2111 fma 9 90000000000 0E+999999 -> 810000000000
-fmax2112 fma 9 900000000000 0E+999999 -> 8100000000000
-fmax2113 fma 9 9000000000000 0E+999999 -> 81000000000000
-fmax2114 fma 9 90000000000000 0E+999999 -> 810000000000000
-fmax2115 fma 9 900000000000000 0E+999999 -> 8100000000000000
-fmax2116 fma 9 9000000000000000 0E+999999 -> 81000000000000000
-fmax2117 fma 9 90000000000000000 0E+999999 -> 810000000000000000
-fmax2118 fma 9 900000000000000000 0E+999999 -> 8100000000000000000
-fmax2119 fma 9 9000000000000000000 0E+999999 -> 81000000000000000000
-fmax2120 fma 9 90000000000000000000 0E+999999 -> 810000000000000000000
-fmax2121 fma 9 900000000000000000000 0E+999999 -> 8100000000000000000000
-fmax2122 fma 9 9000000000000000000000 0E+999999 -> 81000000000000000000000
-fmax2123 fma 9 90000000000000000000000 0E+999999 -> 810000000000000000000000
--- test some more edge cases without carries
-fmax2131 fma 3 3 0E+999999 -> 9
-fmax2132 fma 3 30 0E+999999 -> 90
-fmax2133 fma 3 300 0E+999999 -> 900
-fmax2134 fma 3 3000 0E+999999 -> 9000
-fmax2135 fma 3 30000 0E+999999 -> 90000
-fmax2136 fma 3 300000 0E+999999 -> 900000
-fmax2137 fma 3 3000000 0E+999999 -> 9000000
-fmax2138 fma 3 30000000 0E+999999 -> 90000000
-fmax2139 fma 3 300000000 0E+999999 -> 900000000
-fmax2140 fma 3 3000000000 0E+999999 -> 9000000000
-fmax2141 fma 3 30000000000 0E+999999 -> 90000000000
-fmax2142 fma 3 300000000000 0E+999999 -> 900000000000
-fmax2143 fma 3 3000000000000 0E+999999 -> 9000000000000
-fmax2144 fma 3 30000000000000 0E+999999 -> 90000000000000
-fmax2145 fma 3 300000000000000 0E+999999 -> 900000000000000
-fmax2146 fma 3 3000000000000000 0E+999999 -> 9000000000000000
-fmax2147 fma 3 30000000000000000 0E+999999 -> 90000000000000000
-fmax2148 fma 3 300000000000000000 0E+999999 -> 900000000000000000
-fmax2149 fma 3 3000000000000000000 0E+999999 -> 9000000000000000000
-fmax2150 fma 3 30000000000000000000 0E+999999 -> 90000000000000000000
-fmax2151 fma 3 300000000000000000000 0E+999999 -> 900000000000000000000
-fmax2152 fma 3 3000000000000000000000 0E+999999 -> 9000000000000000000000
-fmax2153 fma 3 30000000000000000000000 0E+999999 -> 90000000000000000000000
-
-maxexponent: 999999
-minexponent: -999999
-precision: 9
--- test some cases that are close to exponent overflow/underflow
-fmax2170 fma 1 9e999999 0E+999999 -> 9E+999999
-fmax2171 fma 1 9.9e999999 0E+999999 -> 9.9E+999999
-fmax2172 fma 1 9.99e999999 0E+999999 -> 9.99E+999999
-fmax2173 fma 9e999999 1 0E+999999 -> 9E+999999
-fmax2174 fma 9.9e999999 1 0E+999999 -> 9.9E+999999
-fmax2176 fma 9.99e999999 1 0E+999999 -> 9.99E+999999
-fmax2177 fma 1 9.99999e999999 0E+999999 -> 9.99999E+999999
-fmax2178 fma 9.99999e999999 1 0E+999999 -> 9.99999E+999999
-
-fmax2180 fma 0.1 9e-999998 0E+999999 -> 9E-999999
-fmax2181 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
-fmax2182 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
-
-fmax2183 fma 0.1 9e-999998 0E+999999 -> 9E-999999
-fmax2184 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
-fmax2185 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
-fmax2186 fma 0.1 999e-999997 0E+999999 -> 9.99E-999996
-fmax2187 fma 0.1 9999e-999997 0E+999999 -> 9.999E-999995
-fmax2188 fma 0.1 99999e-999997 0E+999999 -> 9.9999E-999994
-
-fmax2190 fma 1 9e-999998 0E+999999 -> 9E-999998
-fmax2191 fma 1 99e-999998 0E+999999 -> 9.9E-999997
-fmax2192 fma 1 999e-999998 0E+999999 -> 9.99E-999996
-fmax2193 fma 9e-999998 1 0E+999999 -> 9E-999998
-fmax2194 fma 99e-999998 1 0E+999999 -> 9.9E-999997
-fmax2195 fma 999e-999998 1 0E+999999 -> 9.99E-999996
-
--- long operand triangle
-precision: 33
-fmax2246 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511992830 Inexact Rounded
-precision: 32
-fmax2247 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199283 Inexact Rounded
-precision: 31
-fmax2248 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165119928 Inexact Rounded
-precision: 30
-fmax2249 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511993 Inexact Rounded
-precision: 29
-fmax2250 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199 Inexact Rounded
-precision: 28
-fmax2251 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165120 Inexact Rounded
-precision: 27
-fmax2252 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916512 Inexact Rounded
-precision: 26
-fmax2253 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651 Inexact Rounded
-precision: 25
-fmax2254 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165 Inexact Rounded
-precision: 24
-fmax2255 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671917 Inexact Rounded
-precision: 23
-fmax2256 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967192 Inexact Rounded
-precision: 22
-fmax2257 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719 Inexact Rounded
-precision: 21
-fmax2258 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369672 Inexact Rounded
-precision: 20
-fmax2259 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967 Inexact Rounded
-precision: 19
-fmax2260 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933697 Inexact Rounded
-precision: 18
-fmax2261 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193370 Inexact Rounded
-precision: 17
-fmax2262 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119337 Inexact Rounded
-precision: 16
-fmax2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011934 Inexact Rounded
-precision: 15
-fmax2264 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193 Inexact Rounded
-precision: 14
-fmax2265 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119 Inexact Rounded
-precision: 13
-fmax2266 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908012 Inexact Rounded
-precision: 12
-fmax2267 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801 Inexact Rounded
-precision: 11
-fmax2268 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080 Inexact Rounded
-precision: 10
-fmax2269 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908 Inexact Rounded
-precision: 9
-fmax2270 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.291 Inexact Rounded
-precision: 8
-fmax2271 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29 Inexact Rounded
-precision: 7
-fmax2272 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.3 Inexact Rounded
-precision: 6
-fmax2273 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433 Inexact Rounded
-precision: 5
-fmax2274 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.4543E+5 Inexact Rounded
-precision: 4
-fmax2275 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.454E+5 Inexact Rounded
-precision: 3
-fmax2276 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.45E+5 Inexact Rounded
-precision: 2
-fmax2277 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.5E+5 Inexact Rounded
-precision: 1
-fmax2278 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1E+5 Inexact Rounded
-
--- test some edge cases with exact rounding
-maxexponent: 9999
-minexponent: -9999
-precision: 9
-fmax2301 fma 9 9 0E+999999 -> 81
-fmax2302 fma 9 90 0E+999999 -> 810
-fmax2303 fma 9 900 0E+999999 -> 8100
-fmax2304 fma 9 9000 0E+999999 -> 81000
-fmax2305 fma 9 90000 0E+999999 -> 810000
-fmax2306 fma 9 900000 0E+999999 -> 8100000
-fmax2307 fma 9 9000000 0E+999999 -> 81000000
-fmax2308 fma 9 90000000 0E+999999 -> 810000000
-fmax2309 fma 9 900000000 0E+999999 -> 8.10000000E+9 Rounded
-fmax2310 fma 9 9000000000 0E+999999 -> 8.10000000E+10 Rounded
-fmax2311 fma 9 90000000000 0E+999999 -> 8.10000000E+11 Rounded
-fmax2312 fma 9 900000000000 0E+999999 -> 8.10000000E+12 Rounded
-fmax2313 fma 9 9000000000000 0E+999999 -> 8.10000000E+13 Rounded
-fmax2314 fma 9 90000000000000 0E+999999 -> 8.10000000E+14 Rounded
-fmax2315 fma 9 900000000000000 0E+999999 -> 8.10000000E+15 Rounded
-fmax2316 fma 9 9000000000000000 0E+999999 -> 8.10000000E+16 Rounded
-fmax2317 fma 9 90000000000000000 0E+999999 -> 8.10000000E+17 Rounded
-fmax2318 fma 9 900000000000000000 0E+999999 -> 8.10000000E+18 Rounded
-fmax2319 fma 9 9000000000000000000 0E+999999 -> 8.10000000E+19 Rounded
-fmax2320 fma 9 90000000000000000000 0E+999999 -> 8.10000000E+20 Rounded
-fmax2321 fma 9 900000000000000000000 0E+999999 -> 8.10000000E+21 Rounded
-fmax2322 fma 9 9000000000000000000000 0E+999999 -> 8.10000000E+22 Rounded
-fmax2323 fma 9 90000000000000000000000 0E+999999 -> 8.10000000E+23 Rounded
-
--- fastpath breakers
-precision: 29
-fmax2330 fma 1.491824697641270317824852952837224 1.105170918075647624811707826490246514675628614562883537345747603 0E+999999 -> 1.6487212707001281468486507878 Inexact Rounded
-precision: 55
-fmax2331 fma 0.8958341352965282506768545828765117803873717284891040428 0.8958341352965282506768545828765117803873717284891040428 0E+999999 -> 0.8025187979624784829842553829934069955890983696752228299 Inexact Rounded
-
-
--- tryzeros cases
-precision: 7
-rounding: half_up
-maxExponent: 92
-minexponent: -92
-fmax2504 fma 0E-60 1000E-60 0E+999999 -> 0E-98 Clamped
-fmax2505 fma 100E+60 0E+60 0E+999999 -> 0E+92 Clamped
-
--- mixed with zeros
-maxexponent: 999999
-minexponent: -999999
-precision: 9
-fmax2541 fma 0 -1 0E+999999 -> 0
-fmax2542 fma -0 -1 0E+999999 -> 0
-fmax2543 fma 0 1 0E+999999 -> 0
-fmax2544 fma -0 1 0E+999999 -> 0
-fmax2545 fma -1 0 0E+999999 -> 0
-fmax2546 fma -1 -0 0E+999999 -> 0
-fmax2547 fma 1 0 0E+999999 -> 0
-fmax2548 fma 1 -0 0E+999999 -> 0
-
-fmax2551 fma 0.0 -1 0E+999999 -> 0.0
-fmax2552 fma -0.0 -1 0E+999999 -> 0.0
-fmax2553 fma 0.0 1 0E+999999 -> 0.0
-fmax2554 fma -0.0 1 0E+999999 -> 0.0
-fmax2555 fma -1.0 0 0E+999999 -> 0.0
-fmax2556 fma -1.0 -0 0E+999999 -> 0.0
-fmax2557 fma 1.0 0 0E+999999 -> 0.0
-fmax2558 fma 1.0 -0 0E+999999 -> 0.0
-
-fmax2561 fma 0 -1.0 0E+999999 -> 0.0
-fmax2562 fma -0 -1.0 0E+999999 -> 0.0
-fmax2563 fma 0 1.0 0E+999999 -> 0.0
-fmax2564 fma -0 1.0 0E+999999 -> 0.0
-fmax2565 fma -1 0.0 0E+999999 -> 0.0
-fmax2566 fma -1 -0.0 0E+999999 -> 0.0
-fmax2567 fma 1 0.0 0E+999999 -> 0.0
-fmax2568 fma 1 -0.0 0E+999999 -> 0.0
-
-fmax2571 fma 0.0 -1.0 0E+999999 -> 0.00
-fmax2572 fma -0.0 -1.0 0E+999999 -> 0.00
-fmax2573 fma 0.0 1.0 0E+999999 -> 0.00
-fmax2574 fma -0.0 1.0 0E+999999 -> 0.00
-fmax2575 fma -1.0 0.0 0E+999999 -> 0.00
-fmax2576 fma -1.0 -0.0 0E+999999 -> 0.00
-fmax2577 fma 1.0 0.0 0E+999999 -> 0.00
-fmax2578 fma 1.0 -0.0 0E+999999 -> 0.00
-
-
--- Specials
-fmax2580 fma Inf -Inf 0E+999999 -> -Infinity
-fmax2581 fma Inf -1000 0E+999999 -> -Infinity
-fmax2582 fma Inf -1 0E+999999 -> -Infinity
-fmax2583 fma Inf -0 0E+999999 -> NaN Invalid_operation
-fmax2584 fma Inf 0 0E+999999 -> NaN Invalid_operation
-fmax2585 fma Inf 1 0E+999999 -> Infinity
-fmax2586 fma Inf 1000 0E+999999 -> Infinity
-fmax2587 fma Inf Inf 0E+999999 -> Infinity
-fmax2588 fma -1000 Inf 0E+999999 -> -Infinity
-fmax2589 fma -Inf Inf 0E+999999 -> -Infinity
-fmax2590 fma -1 Inf 0E+999999 -> -Infinity
-fmax2591 fma -0 Inf 0E+999999 -> NaN Invalid_operation
-fmax2592 fma 0 Inf 0E+999999 -> NaN Invalid_operation
-fmax2593 fma 1 Inf 0E+999999 -> Infinity
-fmax2594 fma 1000 Inf 0E+999999 -> Infinity
-fmax2595 fma Inf Inf 0E+999999 -> Infinity
-
-fmax2600 fma -Inf -Inf 0E+999999 -> Infinity
-fmax2601 fma -Inf -1000 0E+999999 -> Infinity
-fmax2602 fma -Inf -1 0E+999999 -> Infinity
-fmax2603 fma -Inf -0 0E+999999 -> NaN Invalid_operation
-fmax2604 fma -Inf 0 0E+999999 -> NaN Invalid_operation
-fmax2605 fma -Inf 1 0E+999999 -> -Infinity
-fmax2606 fma -Inf 1000 0E+999999 -> -Infinity
-fmax2607 fma -Inf Inf 0E+999999 -> -Infinity
-fmax2608 fma -1000 Inf 0E+999999 -> -Infinity
-fmax2609 fma -Inf -Inf 0E+999999 -> Infinity
-fmax2610 fma -1 -Inf 0E+999999 -> Infinity
-fmax2611 fma -0 -Inf 0E+999999 -> NaN Invalid_operation
-fmax2612 fma 0 -Inf 0E+999999 -> NaN Invalid_operation
-fmax2613 fma 1 -Inf 0E+999999 -> -Infinity
-fmax2614 fma 1000 -Inf 0E+999999 -> -Infinity
-fmax2615 fma Inf -Inf 0E+999999 -> -Infinity
-
-fmax2621 fma NaN -Inf 0E+999999 -> NaN
-fmax2622 fma NaN -1000 0E+999999 -> NaN
-fmax2623 fma NaN -1 0E+999999 -> NaN
-fmax2624 fma NaN -0 0E+999999 -> NaN
-fmax2625 fma NaN 0 0E+999999 -> NaN
-fmax2626 fma NaN 1 0E+999999 -> NaN
-fmax2627 fma NaN 1000 0E+999999 -> NaN
-fmax2628 fma NaN Inf 0E+999999 -> NaN
-fmax2629 fma NaN NaN 0E+999999 -> NaN
-fmax2630 fma -Inf NaN 0E+999999 -> NaN
-fmax2631 fma -1000 NaN 0E+999999 -> NaN
-fmax2632 fma -1 NaN 0E+999999 -> NaN
-fmax2633 fma -0 NaN 0E+999999 -> NaN
-fmax2634 fma 0 NaN 0E+999999 -> NaN
-fmax2635 fma 1 NaN 0E+999999 -> NaN
-fmax2636 fma 1000 NaN 0E+999999 -> NaN
-fmax2637 fma Inf NaN 0E+999999 -> NaN
-
-fmax2641 fma sNaN -Inf 0E+999999 -> NaN Invalid_operation
-fmax2642 fma sNaN -1000 0E+999999 -> NaN Invalid_operation
-fmax2643 fma sNaN -1 0E+999999 -> NaN Invalid_operation
-fmax2644 fma sNaN -0 0E+999999 -> NaN Invalid_operation
-fmax2645 fma sNaN 0 0E+999999 -> NaN Invalid_operation
-fmax2646 fma sNaN 1 0E+999999 -> NaN Invalid_operation
-fmax2647 fma sNaN 1000 0E+999999 -> NaN Invalid_operation
-fmax2648 fma sNaN NaN 0E+999999 -> NaN Invalid_operation
-fmax2649 fma sNaN sNaN 0E+999999 -> NaN Invalid_operation
-fmax2650 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
-fmax2651 fma -Inf sNaN 0E+999999 -> NaN Invalid_operation
-fmax2652 fma -1000 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2653 fma -1 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2654 fma -0 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2655 fma 0 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2656 fma 1 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2657 fma 1000 sNaN 0E+999999 -> NaN Invalid_operation
-fmax2658 fma Inf sNaN 0E+999999 -> NaN Invalid_operation
-fmax2659 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
-
--- propagating NaNs
-fmax2661 fma NaN9 -Inf 0E+999999 -> NaN9
-fmax2662 fma NaN8 999 0E+999999 -> NaN8
-fmax2663 fma NaN71 Inf 0E+999999 -> NaN71
-fmax2664 fma NaN6 NaN5 0E+999999 -> NaN6
-fmax2665 fma -Inf NaN4 0E+999999 -> NaN4
-fmax2666 fma -999 NaN33 0E+999999 -> NaN33
-fmax2667 fma Inf NaN2 0E+999999 -> NaN2
-
-fmax2671 fma sNaN99 -Inf 0E+999999 -> NaN99 Invalid_operation
-fmax2672 fma sNaN98 -11 0E+999999 -> NaN98 Invalid_operation
-fmax2673 fma sNaN97 NaN 0E+999999 -> NaN97 Invalid_operation
-fmax2674 fma sNaN16 sNaN94 0E+999999 -> NaN16 Invalid_operation
-fmax2675 fma NaN95 sNaN93 0E+999999 -> NaN93 Invalid_operation
-fmax2676 fma -Inf sNaN92 0E+999999 -> NaN92 Invalid_operation
-fmax2677 fma 088 sNaN91 0E+999999 -> NaN91 Invalid_operation
-fmax2678 fma Inf sNaN90 0E+999999 -> NaN90 Invalid_operation
-fmax2679 fma NaN sNaN89 0E+999999 -> NaN89 Invalid_operation
-
-fmax2681 fma -NaN9 -Inf 0E+999999 -> -NaN9
-fmax2682 fma -NaN8 999 0E+999999 -> -NaN8
-fmax2683 fma -NaN71 Inf 0E+999999 -> -NaN71
-fmax2684 fma -NaN6 -NaN5 0E+999999 -> -NaN6
-fmax2685 fma -Inf -NaN4 0E+999999 -> -NaN4
-fmax2686 fma -999 -NaN33 0E+999999 -> -NaN33
-fmax2687 fma Inf -NaN2 0E+999999 -> -NaN2
-
-fmax2691 fma -sNaN99 -Inf 0E+999999 -> -NaN99 Invalid_operation
-fmax2692 fma -sNaN98 -11 0E+999999 -> -NaN98 Invalid_operation
-fmax2693 fma -sNaN97 NaN 0E+999999 -> -NaN97 Invalid_operation
-fmax2694 fma -sNaN16 -sNaN94 0E+999999 -> -NaN16 Invalid_operation
-fmax2695 fma -NaN95 -sNaN93 0E+999999 -> -NaN93 Invalid_operation
-fmax2696 fma -Inf -sNaN92 0E+999999 -> -NaN92 Invalid_operation
-fmax2697 fma 088 -sNaN91 0E+999999 -> -NaN91 Invalid_operation
-fmax2698 fma Inf -sNaN90 0E+999999 -> -NaN90 Invalid_operation
-fmax2699 fma -NaN -sNaN89 0E+999999 -> -NaN89 Invalid_operation
-
-fmax2701 fma -NaN -Inf 0E+999999 -> -NaN
-fmax2702 fma -NaN 999 0E+999999 -> -NaN
-fmax2703 fma -NaN Inf 0E+999999 -> -NaN
-fmax2704 fma -NaN -NaN 0E+999999 -> -NaN
-fmax2705 fma -Inf -NaN0 0E+999999 -> -NaN
-fmax2706 fma -999 -NaN 0E+999999 -> -NaN
-fmax2707 fma Inf -NaN 0E+999999 -> -NaN
-
-fmax2711 fma -sNaN -Inf 0E+999999 -> -NaN Invalid_operation
-fmax2712 fma -sNaN -11 0E+999999 -> -NaN Invalid_operation
-fmax2713 fma -sNaN00 NaN 0E+999999 -> -NaN Invalid_operation
-fmax2714 fma -sNaN -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2715 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2716 fma -Inf -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2717 fma 088 -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2718 fma Inf -sNaN 0E+999999 -> -NaN Invalid_operation
-fmax2719 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
-
--- overflow and underflow tests .. note subnormal results
-maxexponent: 999999
-minexponent: -999999
-fmax2730 fma +1.23456789012345E-0 9E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2731 fma 9E+999999 +1.23456789012345E-0 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2732 fma +0.100 9E-999999 0E+999999 -> 9.00E-1000000 Subnormal
-fmax2733 fma 9E-999999 +0.100 0E+999999 -> 9.00E-1000000 Subnormal
-fmax2735 fma -1.23456789012345E-0 9E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2736 fma 9E+999999 -1.23456789012345E-0 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2737 fma -0.100 9E-999999 0E+999999 -> -9.00E-1000000 Subnormal
-fmax2738 fma 9E-999999 -0.100 0E+999999 -> -9.00E-1000000 Subnormal
-
--- signs
-fmax2751 fma 1e+777777 1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2752 fma 1e+777777 -1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
-fmax2753 fma -1e+777777 1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
-fmax2754 fma -1e+777777 -1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2755 fma 1e-777777 1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2756 fma 1e-777777 -1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2757 fma -1e-777777 1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2758 fma -1e-777777 -1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-
--- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
-precision: 9
-fmax2760 fma 1e-600000 1e-400001 0E+999999 -> 1E-1000001 Subnormal
-fmax2761 fma 1e-600000 1e-400002 0E+999999 -> 1E-1000002 Subnormal
-fmax2762 fma 1e-600000 1e-400003 0E+999999 -> 1E-1000003 Subnormal
-fmax2763 fma 1e-600000 1e-400004 0E+999999 -> 1E-1000004 Subnormal
-fmax2764 fma 1e-600000 1e-400005 0E+999999 -> 1E-1000005 Subnormal
-fmax2765 fma 1e-600000 1e-400006 0E+999999 -> 1E-1000006 Subnormal
-fmax2766 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
-fmax2767 fma 1e-600000 1e-400008 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2768 fma 1e-600000 1e-400009 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
-fmax2769 fma 1e-600000 1e-400010 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
--- [no equivalent of 'subnormal' for overflow]
-fmax2770 fma 1e+600000 1e+400001 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2771 fma 1e+600000 1e+400002 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2772 fma 1e+600000 1e+400003 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2773 fma 1e+600000 1e+400004 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2774 fma 1e+600000 1e+400005 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2775 fma 1e+600000 1e+400006 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2776 fma 1e+600000 1e+400007 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2777 fma 1e+600000 1e+400008 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2778 fma 1e+600000 1e+400009 0E+999999 -> Infinity Overflow Inexact Rounded
-fmax2779 fma 1e+600000 1e+400010 0E+999999 -> Infinity Overflow Inexact Rounded
-
--- 'subnormal' test edge condition at higher precisions
-precision: 99
-fmax2780 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
-fmax2781 fma 1e-600000 1e-400008 0E+999999 -> 1E-1000008 Subnormal
-fmax2782 fma 1e-600000 1e-400097 0E+999999 -> 1E-1000097 Subnormal
-fmax2783 fma 1e-600000 1e-400098 0E+999999 -> 0E-1000097 Underflow Subnormal Inexact Rounded Clamped
-precision: 999
-fmax2784 fma 1e-600000 1e-400997 0E+999999 -> 1E-1000997 Subnormal
-fmax2785 fma 1e-600000 1e-400998 0E+999999 -> 0E-1000997 Underflow Subnormal Inexact Rounded Clamped
-
--- test subnormals rounding
-precision: 5
-maxExponent: 999
-minexponent: -999
-rounding: half_even
-
-fmax2801 fma 1.0000E-999 1 0E+999999 -> 1.0000E-999
-fmax2802 fma 1.000E-999 1e-1 0E+999999 -> 1.000E-1000 Subnormal
-fmax2803 fma 1.00E-999 1e-2 0E+999999 -> 1.00E-1001 Subnormal
-fmax2804 fma 1.0E-999 1e-3 0E+999999 -> 1.0E-1002 Subnormal
-fmax2805 fma 1.0E-999 1e-4 0E+999999 -> 1E-1003 Subnormal Rounded
-fmax2806 fma 1.3E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2807 fma 1.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2808 fma 1.7E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2809 fma 2.3E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2810 fma 2.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2811 fma 2.7E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
-fmax2812 fma 1.49E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2813 fma 1.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2814 fma 1.51E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2815 fma 2.49E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2816 fma 2.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
-fmax2817 fma 2.51E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
-
-fmax2818 fma 1E-999 1e-4 0E+999999 -> 1E-1003 Subnormal
-fmax2819 fma 3E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2820 fma 5E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2821 fma 7E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2822 fma 9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-fmax2823 fma 9.9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
-
-fmax2824 fma 1E-999 -1e-4 0E+999999 -> -1E-1003 Subnormal
-fmax2825 fma 3E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2826 fma -5E-999 1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2827 fma 7E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2828 fma -9E-999 1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2829 fma 9.9E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
-fmax2830 fma 3.0E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
-
-fmax2831 fma 1.0E-501 1e-501 0E+999999 -> 1.0E-1002 Subnormal
-fmax2832 fma 2.0E-501 2e-501 0E+999999 -> 4.0E-1002 Subnormal
-fmax2833 fma 4.0E-501 4e-501 0E+999999 -> 1.60E-1001 Subnormal
-fmax2834 fma 10.0E-501 10e-501 0E+999999 -> 1.000E-1000 Subnormal
-fmax2835 fma 30.0E-501 30e-501 0E+999999 -> 9.000E-1000 Subnormal
-fmax2836 fma 40.0E-501 40e-501 0E+999999 -> 1.6000E-999
-
--- squares
-fmax2840 fma 1E-502 1e-502 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2841 fma 1E-501 1e-501 0E+999999 -> 1E-1002 Subnormal
-fmax2842 fma 2E-501 2e-501 0E+999999 -> 4E-1002 Subnormal
-fmax2843 fma 4E-501 4e-501 0E+999999 -> 1.6E-1001 Subnormal
-fmax2844 fma 10E-501 10e-501 0E+999999 -> 1.00E-1000 Subnormal
-fmax2845 fma 30E-501 30e-501 0E+999999 -> 9.00E-1000 Subnormal
-fmax2846 fma 40E-501 40e-501 0E+999999 -> 1.600E-999
-
--- cubes
-fmax2850 fma 1E-670 1e-335 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
-fmax2851 fma 1E-668 1e-334 0E+999999 -> 1E-1002 Subnormal
-fmax2852 fma 4E-668 2e-334 0E+999999 -> 8E-1002 Subnormal
-fmax2853 fma 9E-668 3e-334 0E+999999 -> 2.7E-1001 Subnormal
-fmax2854 fma 16E-668 4e-334 0E+999999 -> 6.4E-1001 Subnormal
-fmax2855 fma 25E-668 5e-334 0E+999999 -> 1.25E-1000 Subnormal
-fmax2856 fma 10E-668 100e-334 0E+999999 -> 1.000E-999
-
--- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
-precision: 19
-fmax2860 fma 6636851557994578716E-520 6636851557994578716E-520 0E+999999 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded
-
--- Long operand overflow may be a different path
-precision: 3
-maxExponent: 999999
-minexponent: -999999
-fmax2870 fma 1 9.999E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2871 fma 1 -9.999E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
-fmax2872 fma 9.999E+999999 1 0E+999999 -> Infinity Inexact Overflow Rounded
-fmax2873 fma -9.999E+999999 1 0E+999999 -> -Infinity Inexact Overflow Rounded
-
--- check for double-rounded subnormals
-precision: 5
-maxexponent: 79
-minexponent: -79
-fmax2881 fma 1.2347E-40 1.2347E-40 0E+999999 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax2882 fma 1.234E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2883 fma 1.23E-40 1.23E-40 0E+999999 -> 1.513E-80 Inexact Rounded Subnormal Underflow
-fmax2884 fma 1.2E-40 1.2E-40 0E+999999 -> 1.44E-80 Subnormal
-fmax2885 fma 1.2E-40 1.2E-41 0E+999999 -> 1.44E-81 Subnormal
-fmax2886 fma 1.2E-40 1.2E-42 0E+999999 -> 1.4E-82 Subnormal Inexact Rounded Underflow
-fmax2887 fma 1.2E-40 1.3E-42 0E+999999 -> 1.6E-82 Subnormal Inexact Rounded Underflow
-fmax2888 fma 1.3E-40 1.3E-42 0E+999999 -> 1.7E-82 Subnormal Inexact Rounded Underflow
-fmax2889 fma 1.3E-40 1.3E-43 0E+999999 -> 2E-83 Subnormal Inexact Rounded Underflow
-fmax2890 fma 1.3E-41 1.3E-43 0E+999999 -> 0E-83 Clamped Subnormal Inexact Rounded Underflow
-
-fmax2891 fma 1.2345E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
-fmax2892 fma 1.23456E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
-fmax2893 fma 1.2345E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2894 fma 1.23456E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
-fmax2895 fma 1.2345E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
-fmax2896 fma 1.23456E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
-
--- Now explore the case where we get a normal result with Underflow
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
-fmax2900 fma 0.3000000000E-191 0.3000000000E-191 0E+999999 -> 9.00000000000000E-384 Subnormal Rounded
-fmax2901 fma 0.3000000001E-191 0.3000000001E-191 0E+999999 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
-fmax2902 fma 9.999999999999999E-383 0.0999999999999 0E+999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
-fmax2903 fma 9.999999999999999E-383 0.09999999999999 0E+999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
-fmax2904 fma 9.999999999999999E-383 0.099999999999999 0E+999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
-fmax2905 fma 9.999999999999999E-383 0.0999999999999999 0E+999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
--- prove operands are exact
-fmax2906 fma 9.999999999999999E-383 1 0E+999999 -> 9.999999999999999E-383
-fmax2907 fma 1 0.09999999999999999 0E+999999 -> 0.09999999999999999
--- the next rounds to Nmin
-fmax2908 fma 9.999999999999999E-383 0.09999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2909 fma 9.999999999999999E-383 0.099999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2910 fma 9.999999999999999E-383 0.0999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax2911 fma 9.999999999999999E-383 0.09999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- Examples from SQL proposal (Krishna Kulkarni)
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
-fmax2921 fma 130E-2 120E-2 0E+999999 -> 1.5600
-fmax2922 fma 130E-2 12E-1 0E+999999 -> 1.560
-fmax2923 fma 130E-2 1E0 0E+999999 -> 1.30
-
--- Null tests
-fmax2990 fma # 10 0E+999999 -> NaN Invalid_operation
-fmax2991 fma 10 # 0E+999999 -> NaN Invalid_operation
-
--- ADDITION TESTS ------------------------------------------------------
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- [first group are 'quick confidence check']
-fmax3001 fma 1 1 1 -> 2
-fmax3002 fma 1 2 3 -> 5
-fmax3003 fma 1 '5.75' '3.3' -> 9.05
-fmax3004 fma 1 '5' '-3' -> 2
-fmax3005 fma 1 '-5' '-3' -> -8
-fmax3006 fma 1 '-7' '2.5' -> -4.5
-fmax3007 fma 1 '0.7' '0.3' -> 1.0
-fmax3008 fma 1 '1.25' '1.25' -> 2.50
-fmax3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-fmax3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
-fmax3011 fma 1 '0.4444444444' '0.5555555555' -> '1.00000000' Inexact Rounded
-fmax3012 fma 1 '0.4444444440' '0.5555555555' -> '1.00000000' Inexact Rounded
-fmax3013 fma 1 '0.4444444444' '0.5555555550' -> '0.999999999' Inexact Rounded
-fmax3014 fma 1 '0.44444444449' '0' -> '0.444444444' Inexact Rounded
-fmax3015 fma 1 '0.444444444499' '0' -> '0.444444444' Inexact Rounded
-fmax3016 fma 1 '0.4444444444999' '0' -> '0.444444444' Inexact Rounded
-fmax3017 fma 1 '0.4444444445000' '0' -> '0.444444445' Inexact Rounded
-fmax3018 fma 1 '0.4444444445001' '0' -> '0.444444445' Inexact Rounded
-fmax3019 fma 1 '0.444444444501' '0' -> '0.444444445' Inexact Rounded
-fmax3020 fma 1 '0.44444444451' '0' -> '0.444444445' Inexact Rounded
-
-fmax3021 fma 1 0 1 -> 1
-fmax3022 fma 1 1 1 -> 2
-fmax3023 fma 1 2 1 -> 3
-fmax3024 fma 1 3 1 -> 4
-fmax3025 fma 1 4 1 -> 5
-fmax3026 fma 1 5 1 -> 6
-fmax3027 fma 1 6 1 -> 7
-fmax3028 fma 1 7 1 -> 8
-fmax3029 fma 1 8 1 -> 9
-fmax3030 fma 1 9 1 -> 10
-
--- some carrying effects
-fmax3031 fma 1 '0.9998' '0.0000' -> '0.9998'
-fmax3032 fma 1 '0.9998' '0.0001' -> '0.9999'
-fmax3033 fma 1 '0.9998' '0.0002' -> '1.0000'
-fmax3034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-fmax3035 fma 1 '70' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3036 fma 1 '700' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3037 fma 1 '7000' '10000e+9' -> '1.00000000E+13' Inexact Rounded
-fmax3038 fma 1 '70000' '10000e+9' -> '1.00000001E+13' Inexact Rounded
-fmax3039 fma 1 '700000' '10000e+9' -> '1.00000007E+13' Rounded
-
--- symmetry:
-fmax3040 fma 1 '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded
-fmax3041 fma 1 '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded
-fmax3042 fma 1 '10000e+9' '7000' -> '1.00000000E+13' Inexact Rounded
-fmax3044 fma 1 '10000e+9' '70000' -> '1.00000001E+13' Inexact Rounded
-fmax3045 fma 1 '10000e+9' '700000' -> '1.00000007E+13' Rounded
-
--- same, higher precision
-precision: 15
-fmax3046 fma 1 '10000e+9' '7' -> '10000000000007'
-fmax3047 fma 1 '10000e+9' '70' -> '10000000000070'
-fmax3048 fma 1 '10000e+9' '700' -> '10000000000700'
-fmax3049 fma 1 '10000e+9' '7000' -> '10000000007000'
-fmax3050 fma 1 '10000e+9' '70000' -> '10000000070000'
-fmax3051 fma 1 '10000e+9' '700000' -> '10000000700000'
-fmax3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
-
--- examples from decarith
-fmax3053 fma 1 '12' '7.00' -> '19.00'
-fmax3054 fma 1 '1.3' '-1.07' -> '0.23'
-fmax3055 fma 1 '1.3' '-1.30' -> '0.00'
-fmax3056 fma 1 '1.3' '-2.07' -> '-0.77'
-fmax3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- zero preservation
-precision: 6
-fmax3060 fma 1 '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded
-fmax3061 fma 1 1 '0.0001' -> '1.0001'
-fmax3062 fma 1 1 '0.00001' -> '1.00001'
-fmax3063 fma 1 1 '0.000001' -> '1.00000' Inexact Rounded
-fmax3064 fma 1 1 '0.0000001' -> '1.00000' Inexact Rounded
-fmax3065 fma 1 1 '0.00000001' -> '1.00000' Inexact Rounded
-
--- some funny zeros [in case of bad signum]
-fmax3070 fma 1 1 0 -> 1
-fmax3071 fma 1 1 0. -> 1
-fmax3072 fma 1 1 .0 -> 1.0
-fmax3073 fma 1 1 0.0 -> 1.0
-fmax3074 fma 1 1 0.00 -> 1.00
-fmax3075 fma 1 0 1 -> 1
-fmax3076 fma 1 0. 1 -> 1
-fmax3077 fma 1 .0 1 -> 1.0
-fmax3078 fma 1 0.0 1 -> 1.0
-fmax3079 fma 1 0.00 1 -> 1.00
-
-precision: 9
-
--- some carries
-fmax3080 fma 1 999999998 1 -> 999999999
-fmax3081 fma 1 999999999 1 -> 1.00000000E+9 Rounded
-fmax3082 fma 1 99999999 1 -> 100000000
-fmax3083 fma 1 9999999 1 -> 10000000
-fmax3084 fma 1 999999 1 -> 1000000
-fmax3085 fma 1 99999 1 -> 100000
-fmax3086 fma 1 9999 1 -> 10000
-fmax3087 fma 1 999 1 -> 1000
-fmax3088 fma 1 99 1 -> 100
-fmax3089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-fmax3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-fmax3091 fma 1 '-56267E-6' 0 -> '-0.056267'
-fmax3092 fma 1 '-56267E-5' 0 -> '-0.56267'
-fmax3093 fma 1 '-56267E-4' 0 -> '-5.6267'
-fmax3094 fma 1 '-56267E-3' 0 -> '-56.267'
-fmax3095 fma 1 '-56267E-2' 0 -> '-562.67'
-fmax3096 fma 1 '-56267E-1' 0 -> '-5626.7'
-fmax3097 fma 1 '-56267E-0' 0 -> '-56267'
-fmax3098 fma 1 '-5E-10' 0 -> '-5E-10'
-fmax3099 fma 1 '-5E-7' 0 -> '-5E-7'
-fmax3100 fma 1 '-5E-6' 0 -> '-0.000005'
-fmax3101 fma 1 '-5E-5' 0 -> '-0.00005'
-fmax3102 fma 1 '-5E-4' 0 -> '-0.0005'
-fmax3103 fma 1 '-5E-1' 0 -> '-0.5'
-fmax3104 fma 1 '-5E0' 0 -> '-5'
-fmax3105 fma 1 '-5E1' 0 -> '-50'
-fmax3106 fma 1 '-5E5' 0 -> '-500000'
-fmax3107 fma 1 '-5E8' 0 -> '-500000000'
-fmax3108 fma 1 '-5E9' 0 -> '-5.00000000E+9' Rounded
-fmax3109 fma 1 '-5E10' 0 -> '-5.00000000E+10' Rounded
-fmax3110 fma 1 '-5E11' 0 -> '-5.00000000E+11' Rounded
-fmax3111 fma 1 '-5E100' 0 -> '-5.00000000E+100' Rounded
-
--- more RHS swaps
-fmax3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-fmax3114 fma 1 0 '-56267E-6' -> '-0.056267'
-fmax3116 fma 1 0 '-56267E-5' -> '-0.56267'
-fmax3117 fma 1 0 '-56267E-4' -> '-5.6267'
-fmax3119 fma 1 0 '-56267E-3' -> '-56.267'
-fmax3120 fma 1 0 '-56267E-2' -> '-562.67'
-fmax3121 fma 1 0 '-56267E-1' -> '-5626.7'
-fmax3122 fma 1 0 '-56267E-0' -> '-56267'
-fmax3123 fma 1 0 '-5E-10' -> '-5E-10'
-fmax3124 fma 1 0 '-5E-7' -> '-5E-7'
-fmax3125 fma 1 0 '-5E-6' -> '-0.000005'
-fmax3126 fma 1 0 '-5E-5' -> '-0.00005'
-fmax3127 fma 1 0 '-5E-4' -> '-0.0005'
-fmax3128 fma 1 0 '-5E-1' -> '-0.5'
-fmax3129 fma 1 0 '-5E0' -> '-5'
-fmax3130 fma 1 0 '-5E1' -> '-50'
-fmax3131 fma 1 0 '-5E5' -> '-500000'
-fmax3132 fma 1 0 '-5E8' -> '-500000000'
-fmax3133 fma 1 0 '-5E9' -> '-5.00000000E+9' Rounded
-fmax3134 fma 1 0 '-5E10' -> '-5.00000000E+10' Rounded
-fmax3135 fma 1 0 '-5E11' -> '-5.00000000E+11' Rounded
-fmax3136 fma 1 0 '-5E100' -> '-5.00000000E+100' Rounded
-
--- related
-fmax3137 fma 1 1 '0E-12' -> '1.00000000' Rounded
-fmax3138 fma 1 -1 '0E-12' -> '-1.00000000' Rounded
-fmax3139 fma 1 '0E-12' 1 -> '1.00000000' Rounded
-fmax3140 fma 1 '0E-12' -1 -> '-1.00000000' Rounded
-fmax3141 fma 1 1E+4 0.0000 -> '10000.0000'
-fmax3142 fma 1 1E+4 0.00000 -> '10000.0000' Rounded
-fmax3143 fma 1 0.000 1E+5 -> '100000.000'
-fmax3144 fma 1 0.0000 1E+5 -> '100000.000' Rounded
-
--- [some of the next group are really constructor tests]
-fmax3146 fma 1 '00.0' 0 -> '0.0'
-fmax3147 fma 1 '0.00' 0 -> '0.00'
-fmax3148 fma 1 0 '0.00' -> '0.00'
-fmax3149 fma 1 0 '00.0' -> '0.0'
-fmax3150 fma 1 '00.0' '0.00' -> '0.00'
-fmax3151 fma 1 '0.00' '00.0' -> '0.00'
-fmax3152 fma 1 '3' '.3' -> '3.3'
-fmax3153 fma 1 '3.' '.3' -> '3.3'
-fmax3154 fma 1 '3.0' '.3' -> '3.3'
-fmax3155 fma 1 '3.00' '.3' -> '3.30'
-fmax3156 fma 1 '3' '3' -> '6'
-fmax3157 fma 1 '3' '+3' -> '6'
-fmax3158 fma 1 '3' '-3' -> '0'
-fmax3159 fma 1 '0.3' '-0.3' -> '0.0'
-fmax3160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-precision: 15
-fmax3161 fma 1 '1E+12' '-1' -> '999999999999'
-fmax3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
-fmax3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
-fmax3164 fma 1 '-1' '1E+12' -> '999999999999'
-fmax3165 fma 1 '7E+12' '-1' -> '6999999999999'
-fmax3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
-fmax3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
-fmax3168 fma 1 '-1' '7E+12' -> '6999999999999'
-
--- 123456789012345 123456789012345 1 23456789012345
-fmax3170 fma 1 '0.444444444444444' '0.555555555555563' -> '1.00000000000001' Inexact Rounded
-fmax3171 fma 1 '0.444444444444444' '0.555555555555562' -> '1.00000000000001' Inexact Rounded
-fmax3172 fma 1 '0.444444444444444' '0.555555555555561' -> '1.00000000000001' Inexact Rounded
-fmax3173 fma 1 '0.444444444444444' '0.555555555555560' -> '1.00000000000000' Inexact Rounded
-fmax3174 fma 1 '0.444444444444444' '0.555555555555559' -> '1.00000000000000' Inexact Rounded
-fmax3175 fma 1 '0.444444444444444' '0.555555555555558' -> '1.00000000000000' Inexact Rounded
-fmax3176 fma 1 '0.444444444444444' '0.555555555555557' -> '1.00000000000000' Inexact Rounded
-fmax3177 fma 1 '0.444444444444444' '0.555555555555556' -> '1.00000000000000' Rounded
-fmax3178 fma 1 '0.444444444444444' '0.555555555555555' -> '0.999999999999999'
-fmax3179 fma 1 '0.444444444444444' '0.555555555555554' -> '0.999999999999998'
-fmax3180 fma 1 '0.444444444444444' '0.555555555555553' -> '0.999999999999997'
-fmax3181 fma 1 '0.444444444444444' '0.555555555555552' -> '0.999999999999996'
-fmax3182 fma 1 '0.444444444444444' '0.555555555555551' -> '0.999999999999995'
-fmax3183 fma 1 '0.444444444444444' '0.555555555555550' -> '0.999999999999994'
-
--- and some more, including residue effects and different roundings
-precision: 9
-rounding: half_up
-fmax3200 fma 1 '123456789' 0 -> '123456789'
-fmax3201 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3202 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3203 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3204 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3205 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3206 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3207 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3208 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
-fmax3209 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
-fmax3210 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
-fmax3211 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
-fmax3212 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
-fmax3213 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
-fmax3214 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
-fmax3215 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
-fmax3216 fma 1 '123456789' 1 -> '123456790'
-fmax3217 fma 1 '123456789' 1.000000001 -> '123456790' Inexact Rounded
-fmax3218 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3219 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
-
-rounding: half_even
-fmax3220 fma 1 '123456789' 0 -> '123456789'
-fmax3221 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3222 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3223 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3224 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3225 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3226 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3227 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3228 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
-fmax3229 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
-fmax3230 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
-fmax3231 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
-fmax3232 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
-fmax3233 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
-fmax3234 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
-fmax3235 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
-fmax3236 fma 1 '123456789' 1 -> '123456790'
-fmax3237 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
-fmax3238 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3239 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
--- critical few with even bottom digit...
-fmax3240 fma 1 '123456788' 0.499999999 -> '123456788' Inexact Rounded
-fmax3241 fma 1 '123456788' 0.5 -> '123456788' Inexact Rounded
-fmax3242 fma 1 '123456788' 0.500000001 -> '123456789' Inexact Rounded
-
-rounding: down
-fmax3250 fma 1 '123456789' 0 -> '123456789'
-fmax3251 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
-fmax3252 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
-fmax3253 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
-fmax3254 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
-fmax3255 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
-fmax3256 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
-fmax3257 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
-fmax3258 fma 1 '123456789' 0.5 -> '123456789' Inexact Rounded
-fmax3259 fma 1 '123456789' 0.500000001 -> '123456789' Inexact Rounded
-fmax3260 fma 1 '123456789' 0.500001 -> '123456789' Inexact Rounded
-fmax3261 fma 1 '123456789' 0.51 -> '123456789' Inexact Rounded
-fmax3262 fma 1 '123456789' 0.6 -> '123456789' Inexact Rounded
-fmax3263 fma 1 '123456789' 0.9 -> '123456789' Inexact Rounded
-fmax3264 fma 1 '123456789' 0.99999 -> '123456789' Inexact Rounded
-fmax3265 fma 1 '123456789' 0.999999999 -> '123456789' Inexact Rounded
-fmax3266 fma 1 '123456789' 1 -> '123456790'
-fmax3267 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
-fmax3268 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
-fmax3269 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
-
--- input preparation tests (operands should not be rounded)
-precision: 3
-rounding: half_up
-
-fmax3270 fma 1 '12345678900000' 9999999999999 -> '2.23E+13' Inexact Rounded
-fmax3271 fma 1 '9999999999999' 12345678900000 -> '2.23E+13' Inexact Rounded
-
-fmax3272 fma 1 '12E+3' '3444' -> '1.54E+4' Inexact Rounded
-fmax3273 fma 1 '12E+3' '3446' -> '1.54E+4' Inexact Rounded
-fmax3274 fma 1 '12E+3' '3449.9' -> '1.54E+4' Inexact Rounded
-fmax3275 fma 1 '12E+3' '3450.0' -> '1.55E+4' Inexact Rounded
-fmax3276 fma 1 '12E+3' '3450.1' -> '1.55E+4' Inexact Rounded
-fmax3277 fma 1 '12E+3' '3454' -> '1.55E+4' Inexact Rounded
-fmax3278 fma 1 '12E+3' '3456' -> '1.55E+4' Inexact Rounded
-
-fmax3281 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3282 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3283 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3284 fma 1 '3450.0' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3285 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3286 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3287 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
-
-rounding: half_down
-fmax3291 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3292 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3293 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3294 fma 1 '3450.0' '12E+3' -> '1.54E+4' Inexact Rounded
-fmax3295 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3296 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
-fmax3297 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_up
-fmax3301 fma 1 -1 1 -> 0
-fmax3302 fma 1 0 1 -> 1
-fmax3303 fma 1 1 1 -> 2
-fmax3304 fma 1 12 1 -> 13
-fmax3305 fma 1 98 1 -> 99
-fmax3306 fma 1 99 1 -> 100
-fmax3307 fma 1 100 1 -> 101
-fmax3308 fma 1 101 1 -> 102
-fmax3309 fma 1 -1 -1 -> -2
-fmax3310 fma 1 0 -1 -> -1
-fmax3311 fma 1 1 -1 -> 0
-fmax3312 fma 1 12 -1 -> 11
-fmax3313 fma 1 98 -1 -> 97
-fmax3314 fma 1 99 -1 -> 98
-fmax3315 fma 1 100 -1 -> 99
-fmax3316 fma 1 101 -1 -> 100
-
-fmax3321 fma 1 -0.01 0.01 -> 0.00
-fmax3322 fma 1 0.00 0.01 -> 0.01
-fmax3323 fma 1 0.01 0.01 -> 0.02
-fmax3324 fma 1 0.12 0.01 -> 0.13
-fmax3325 fma 1 0.98 0.01 -> 0.99
-fmax3326 fma 1 0.99 0.01 -> 1.00
-fmax3327 fma 1 1.00 0.01 -> 1.01
-fmax3328 fma 1 1.01 0.01 -> 1.02
-fmax3329 fma 1 -0.01 -0.01 -> -0.02
-fmax3330 fma 1 0.00 -0.01 -> -0.01
-fmax3331 fma 1 0.01 -0.01 -> 0.00
-fmax3332 fma 1 0.12 -0.01 -> 0.11
-fmax3333 fma 1 0.98 -0.01 -> 0.97
-fmax3334 fma 1 0.99 -0.01 -> 0.98
-fmax3335 fma 1 1.00 -0.01 -> 0.99
-fmax3336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where fma 1 ing 0 affects the coefficient
-precision: 9
-fmax3340 fma 1 1E+3 0 -> 1000
-fmax3341 fma 1 1E+8 0 -> 100000000
-fmax3342 fma 1 1E+9 0 -> 1.00000000E+9 Rounded
-fmax3343 fma 1 1E+10 0 -> 1.00000000E+10 Rounded
--- which simply follow from these cases ...
-fmax3344 fma 1 1E+3 1 -> 1001
-fmax3345 fma 1 1E+8 1 -> 100000001
-fmax3346 fma 1 1E+9 1 -> 1.00000000E+9 Inexact Rounded
-fmax3347 fma 1 1E+10 1 -> 1.00000000E+10 Inexact Rounded
-fmax3348 fma 1 1E+3 7 -> 1007
-fmax3349 fma 1 1E+8 7 -> 100000007
-fmax3350 fma 1 1E+9 7 -> 1.00000001E+9 Inexact Rounded
-fmax3351 fma 1 1E+10 7 -> 1.00000000E+10 Inexact Rounded
-
--- tryzeros cases
-precision: 7
-rounding: half_up
-maxExponent: 92
-minexponent: -92
-fmax3361 fma 1 0E+50 10000E+1 -> 1.0000E+5
-fmax3362 fma 1 10000E+1 0E-50 -> 100000.0 Rounded
-fmax3363 fma 1 10000E+1 10000E-50 -> 100000.0 Rounded Inexact
-fmax3364 fma 1 9.999999E+92 -9.999999E+92 -> 0E+86
-
--- a curiosity from JSR 13 testing
-rounding: half_down
-precision: 10
-fmax3370 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3371 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-rounding: half_up
-precision: 10
-fmax3372 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3373 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-rounding: half_even
-precision: 10
-fmax3374 fma 1 99999999 81512 -> 100081511
-precision: 6
-fmax3375 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
-
--- ulp replacement tests
-precision: 9
-maxexponent: 999999
-minexponent: -999999
-fmax3400 fma 1 1 77e-7 -> 1.0000077
-fmax3401 fma 1 1 77e-8 -> 1.00000077
-fmax3402 fma 1 1 77e-9 -> 1.00000008 Inexact Rounded
-fmax3403 fma 1 1 77e-10 -> 1.00000001 Inexact Rounded
-fmax3404 fma 1 1 77e-11 -> 1.00000000 Inexact Rounded
-fmax3405 fma 1 1 77e-12 -> 1.00000000 Inexact Rounded
-fmax3406 fma 1 1 77e-999 -> 1.00000000 Inexact Rounded
-fmax3407 fma 1 1 77e-999999 -> 1.00000000 Inexact Rounded
-
-fmax3410 fma 1 10 77e-7 -> 10.0000077
-fmax3411 fma 1 10 77e-8 -> 10.0000008 Inexact Rounded
-fmax3412 fma 1 10 77e-9 -> 10.0000001 Inexact Rounded
-fmax3413 fma 1 10 77e-10 -> 10.0000000 Inexact Rounded
-fmax3414 fma 1 10 77e-11 -> 10.0000000 Inexact Rounded
-fmax3415 fma 1 10 77e-12 -> 10.0000000 Inexact Rounded
-fmax3416 fma 1 10 77e-999 -> 10.0000000 Inexact Rounded
-fmax3417 fma 1 10 77e-999999 -> 10.0000000 Inexact Rounded
-
-fmax3420 fma 1 77e-7 1 -> 1.0000077
-fmax3421 fma 1 77e-8 1 -> 1.00000077
-fmax3422 fma 1 77e-9 1 -> 1.00000008 Inexact Rounded
-fmax3423 fma 1 77e-10 1 -> 1.00000001 Inexact Rounded
-fmax3424 fma 1 77e-11 1 -> 1.00000000 Inexact Rounded
-fmax3425 fma 1 77e-12 1 -> 1.00000000 Inexact Rounded
-fmax3426 fma 1 77e-999 1 -> 1.00000000 Inexact Rounded
-fmax3427 fma 1 77e-999999 1 -> 1.00000000 Inexact Rounded
-
-fmax3430 fma 1 77e-7 10 -> 10.0000077
-fmax3431 fma 1 77e-8 10 -> 10.0000008 Inexact Rounded
-fmax3432 fma 1 77e-9 10 -> 10.0000001 Inexact Rounded
-fmax3433 fma 1 77e-10 10 -> 10.0000000 Inexact Rounded
-fmax3434 fma 1 77e-11 10 -> 10.0000000 Inexact Rounded
-fmax3435 fma 1 77e-12 10 -> 10.0000000 Inexact Rounded
-fmax3436 fma 1 77e-999 10 -> 10.0000000 Inexact Rounded
-fmax3437 fma 1 77e-999999 10 -> 10.0000000 Inexact Rounded
-
--- negative ulps
-fmax3440 fma 1 1 -77e-7 -> 0.9999923
-fmax3441 fma 1 1 -77e-8 -> 0.99999923
-fmax3442 fma 1 1 -77e-9 -> 0.999999923
-fmax3443 fma 1 1 -77e-10 -> 0.999999992 Inexact Rounded
-fmax3444 fma 1 1 -77e-11 -> 0.999999999 Inexact Rounded
-fmax3445 fma 1 1 -77e-12 -> 1.00000000 Inexact Rounded
-fmax3446 fma 1 1 -77e-999 -> 1.00000000 Inexact Rounded
-fmax3447 fma 1 1 -77e-999999 -> 1.00000000 Inexact Rounded
-
-fmax3450 fma 1 10 -77e-7 -> 9.9999923
-fmax3451 fma 1 10 -77e-8 -> 9.99999923
-fmax3452 fma 1 10 -77e-9 -> 9.99999992 Inexact Rounded
-fmax3453 fma 1 10 -77e-10 -> 9.99999999 Inexact Rounded
-fmax3454 fma 1 10 -77e-11 -> 10.0000000 Inexact Rounded
-fmax3455 fma 1 10 -77e-12 -> 10.0000000 Inexact Rounded
-fmax3456 fma 1 10 -77e-999 -> 10.0000000 Inexact Rounded
-fmax3457 fma 1 10 -77e-999999 -> 10.0000000 Inexact Rounded
-
-fmax3460 fma 1 -77e-7 1 -> 0.9999923
-fmax3461 fma 1 -77e-8 1 -> 0.99999923
-fmax3462 fma 1 -77e-9 1 -> 0.999999923
-fmax3463 fma 1 -77e-10 1 -> 0.999999992 Inexact Rounded
-fmax3464 fma 1 -77e-11 1 -> 0.999999999 Inexact Rounded
-fmax3465 fma 1 -77e-12 1 -> 1.00000000 Inexact Rounded
-fmax3466 fma 1 -77e-999 1 -> 1.00000000 Inexact Rounded
-fmax3467 fma 1 -77e-999999 1 -> 1.00000000 Inexact Rounded
-
-fmax3470 fma 1 -77e-7 10 -> 9.9999923
-fmax3471 fma 1 -77e-8 10 -> 9.99999923
-fmax3472 fma 1 -77e-9 10 -> 9.99999992 Inexact Rounded
-fmax3473 fma 1 -77e-10 10 -> 9.99999999 Inexact Rounded
-fmax3474 fma 1 -77e-11 10 -> 10.0000000 Inexact Rounded
-fmax3475 fma 1 -77e-12 10 -> 10.0000000 Inexact Rounded
-fmax3476 fma 1 -77e-999 10 -> 10.0000000 Inexact Rounded
-fmax3477 fma 1 -77e-999999 10 -> 10.0000000 Inexact Rounded
-
--- negative ulps
-fmax3480 fma 1 -1 77e-7 -> -0.9999923
-fmax3481 fma 1 -1 77e-8 -> -0.99999923
-fmax3482 fma 1 -1 77e-9 -> -0.999999923
-fmax3483 fma 1 -1 77e-10 -> -0.999999992 Inexact Rounded
-fmax3484 fma 1 -1 77e-11 -> -0.999999999 Inexact Rounded
-fmax3485 fma 1 -1 77e-12 -> -1.00000000 Inexact Rounded
-fmax3486 fma 1 -1 77e-999 -> -1.00000000 Inexact Rounded
-fmax3487 fma 1 -1 77e-999999 -> -1.00000000 Inexact Rounded
-
-fmax3490 fma 1 -10 77e-7 -> -9.9999923
-fmax3491 fma 1 -10 77e-8 -> -9.99999923
-fmax3492 fma 1 -10 77e-9 -> -9.99999992 Inexact Rounded
-fmax3493 fma 1 -10 77e-10 -> -9.99999999 Inexact Rounded
-fmax3494 fma 1 -10 77e-11 -> -10.0000000 Inexact Rounded
-fmax3495 fma 1 -10 77e-12 -> -10.0000000 Inexact Rounded
-fmax3496 fma 1 -10 77e-999 -> -10.0000000 Inexact Rounded
-fmax3497 fma 1 -10 77e-999999 -> -10.0000000 Inexact Rounded
-
-fmax3500 fma 1 77e-7 -1 -> -0.9999923
-fmax3501 fma 1 77e-8 -1 -> -0.99999923
-fmax3502 fma 1 77e-9 -1 -> -0.999999923
-fmax3503 fma 1 77e-10 -1 -> -0.999999992 Inexact Rounded
-fmax3504 fma 1 77e-11 -1 -> -0.999999999 Inexact Rounded
-fmax3505 fma 1 77e-12 -1 -> -1.00000000 Inexact Rounded
-fmax3506 fma 1 77e-999 -1 -> -1.00000000 Inexact Rounded
-fmax3507 fma 1 77e-999999 -1 -> -1.00000000 Inexact Rounded
-
-fmax3510 fma 1 77e-7 -10 -> -9.9999923
-fmax3511 fma 1 77e-8 -10 -> -9.99999923
-fmax3512 fma 1 77e-9 -10 -> -9.99999992 Inexact Rounded
-fmax3513 fma 1 77e-10 -10 -> -9.99999999 Inexact Rounded
-fmax3514 fma 1 77e-11 -10 -> -10.0000000 Inexact Rounded
-fmax3515 fma 1 77e-12 -10 -> -10.0000000 Inexact Rounded
-fmax3516 fma 1 77e-999 -10 -> -10.0000000 Inexact Rounded
-fmax3517 fma 1 77e-999999 -10 -> -10.0000000 Inexact Rounded
-
-
--- long operands
-maxexponent: 999
-minexponent: -999
-precision: 9
-fmax3521 fma 1 12345678000 0 -> 1.23456780E+10 Rounded
-fmax3522 fma 1 0 12345678000 -> 1.23456780E+10 Rounded
-fmax3523 fma 1 1234567800 0 -> 1.23456780E+9 Rounded
-fmax3524 fma 1 0 1234567800 -> 1.23456780E+9 Rounded
-fmax3525 fma 1 1234567890 0 -> 1.23456789E+9 Rounded
-fmax3526 fma 1 0 1234567890 -> 1.23456789E+9 Rounded
-fmax3527 fma 1 1234567891 0 -> 1.23456789E+9 Inexact Rounded
-fmax3528 fma 1 0 1234567891 -> 1.23456789E+9 Inexact Rounded
-fmax3529 fma 1 12345678901 0 -> 1.23456789E+10 Inexact Rounded
-fmax3530 fma 1 0 12345678901 -> 1.23456789E+10 Inexact Rounded
-fmax3531 fma 1 1234567896 0 -> 1.23456790E+9 Inexact Rounded
-fmax3532 fma 1 0 1234567896 -> 1.23456790E+9 Inexact Rounded
-
-precision: 15
--- still checking
-fmax3541 fma 1 12345678000 0 -> 12345678000
-fmax3542 fma 1 0 12345678000 -> 12345678000
-fmax3543 fma 1 1234567800 0 -> 1234567800
-fmax3544 fma 1 0 1234567800 -> 1234567800
-fmax3545 fma 1 1234567890 0 -> 1234567890
-fmax3546 fma 1 0 1234567890 -> 1234567890
-fmax3547 fma 1 1234567891 0 -> 1234567891
-fmax3548 fma 1 0 1234567891 -> 1234567891
-fmax3549 fma 1 12345678901 0 -> 12345678901
-fmax3550 fma 1 0 12345678901 -> 12345678901
-fmax3551 fma 1 1234567896 0 -> 1234567896
-fmax3552 fma 1 0 1234567896 -> 1234567896
-
--- verify a query
-precision: 16
-maxExponent: +394
-minExponent: -393
-rounding: down
-fmax3561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-fmax3562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
--- and using decimal64 bounds...
-precision: 16
-maxExponent: +384
-minExponent: -383
-rounding: down
-fmax3563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-fmax3564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
-
--- some more residue effects with extreme rounding
-precision: 9
-rounding: half_up
-fmax3601 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3602 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3603 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3604 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3605 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
-rounding: up
-fmax3606 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
-rounding: down
-fmax3607 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3611 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3612 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3613 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3614 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3615 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: up
-fmax3616 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
-rounding: down
-fmax3617 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
-
-rounding: half_up
-fmax3621 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3622 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3623 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3624 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3625 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
-rounding: up
-fmax3626 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
-rounding: down
-fmax3627 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3631 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: half_even
-fmax3632 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: half_down
-fmax3633 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: floor
-fmax3634 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3635 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: up
-fmax3636 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
-rounding: down
-fmax3637 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
-
-rounding: half_up
-fmax3641 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: half_even
-fmax3642 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: half_down
-fmax3643 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: floor
-fmax3644 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
-rounding: ceiling
-fmax3645 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: up
-fmax3646 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
-rounding: down
-fmax3647 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
-
-rounding: half_up
-fmax3651 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: half_even
-fmax3652 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: half_down
-fmax3653 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: floor
-fmax3654 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-rounding: ceiling
-fmax3655 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
-rounding: up
-fmax3656 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
-rounding: down
-fmax3657 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
-
--- long operand triangle
-rounding: half_up
-precision: 37
-fmax3660 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538
-precision: 36
-fmax3661 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454 Inexact Rounded
-precision: 35
-fmax3662 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345 Inexact Rounded
-precision: 34
-fmax3663 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835 Inexact Rounded
-precision: 33
-fmax3664 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483 Inexact Rounded
-precision: 32
-fmax3665 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148 Inexact Rounded
-precision: 31
-fmax3666 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded
-precision: 30
-fmax3667 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711 Inexact Rounded
-precision: 29
-fmax3668 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371 Inexact Rounded
-precision: 28
-fmax3669 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337 Inexact Rounded
-precision: 27
-fmax3670 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234 Inexact Rounded
-precision: 26
-fmax3671 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223 Inexact Rounded
-precision: 25
-fmax3672 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922 Inexact Rounded
-precision: 24
-fmax3673 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892 Inexact Rounded
-precision: 23
-fmax3674 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389 Inexact Rounded
-precision: 22
-fmax3675 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639 Inexact Rounded
-precision: 21
-fmax3676 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364 Inexact Rounded
-precision: 20
-fmax3677 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236 Inexact Rounded
-precision: 19
-fmax3678 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024 Inexact Rounded
-precision: 18
-fmax3679 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102 Inexact Rounded
-precision: 17
-fmax3680 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110 Inexact Rounded
-precision: 16
-fmax3681 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211 Inexact Rounded
-precision: 15
-fmax3682 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221 Inexact Rounded
-precision: 14
-fmax3683 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422 Inexact Rounded
-precision: 13
-fmax3684 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42 Inexact Rounded
-precision: 12
-fmax3685 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4 Inexact Rounded
-precision: 11
-fmax3686 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166 Inexact Rounded
-precision: 10
-fmax3687 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10 Inexact Rounded
-precision: 9
-fmax3688 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10 Inexact Rounded
-precision: 8
-fmax3689 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10 Inexact Rounded
-precision: 7
-fmax3690 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10 Inexact Rounded
-precision: 6
-fmax3691 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10 Inexact Rounded
-precision: 5
-fmax3692 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10 Inexact Rounded
-precision: 4
-fmax3693 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10 Inexact Rounded
-precision: 3
-fmax3694 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10 Inexact Rounded
-precision: 2
-fmax3695 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10 Inexact Rounded
-precision: 1
-fmax3696 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11 Inexact Rounded
-
--- more zeros, etc.
-rounding: half_up
-precision: 9
-
-fmax3701 fma 1 5.00 1.00E-3 -> 5.00100
-fmax3702 fma 1 00.00 0.000 -> 0.000
-fmax3703 fma 1 00.00 0E-3 -> 0.000
-fmax3704 fma 1 0E-3 00.00 -> 0.000
-
-fmax3710 fma 1 0E+3 00.00 -> 0.00
-fmax3711 fma 1 0E+3 00.0 -> 0.0
-fmax3712 fma 1 0E+3 00. -> 0
-fmax3713 fma 1 0E+3 00.E+1 -> 0E+1
-fmax3714 fma 1 0E+3 00.E+2 -> 0E+2
-fmax3715 fma 1 0E+3 00.E+3 -> 0E+3
-fmax3716 fma 1 0E+3 00.E+4 -> 0E+3
-fmax3717 fma 1 0E+3 00.E+5 -> 0E+3
-fmax3718 fma 1 0E+3 -00.0 -> 0.0
-fmax3719 fma 1 0E+3 -00. -> 0
-fmax3731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-fmax3720 fma 1 00.00 0E+3 -> 0.00
-fmax3721 fma 1 00.0 0E+3 -> 0.0
-fmax3722 fma 1 00. 0E+3 -> 0
-fmax3723 fma 1 00.E+1 0E+3 -> 0E+1
-fmax3724 fma 1 00.E+2 0E+3 -> 0E+2
-fmax3725 fma 1 00.E+3 0E+3 -> 0E+3
-fmax3726 fma 1 00.E+4 0E+3 -> 0E+3
-fmax3727 fma 1 00.E+5 0E+3 -> 0E+3
-fmax3728 fma 1 -00.00 0E+3 -> 0.00
-fmax3729 fma 1 -00.0 0E+3 -> 0.0
-fmax3730 fma 1 -00. 0E+3 -> 0
-
-fmax3732 fma 1 0 0 -> 0
-fmax3733 fma 1 0 -0 -> 0
-fmax3734 fma 1 -0 0 -> 0
-fmax3735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-fmax3736 fma 1 1 -1 -> 0
-fmax3737 fma 1 -1 -1 -> -2
-fmax3738 fma 1 1 1 -> 2
-fmax3739 fma 1 -1 1 -> 0
-
-fmax3741 fma 1 0 -1 -> -1
-fmax3742 fma 1 -0 -1 -> -1
-fmax3743 fma 1 0 1 -> 1
-fmax3744 fma 1 -0 1 -> 1
-fmax3745 fma 1 -1 0 -> -1
-fmax3746 fma 1 -1 -0 -> -1
-fmax3747 fma 1 1 0 -> 1
-fmax3748 fma 1 1 -0 -> 1
-
-fmax3751 fma 1 0.0 -1 -> -1.0
-fmax3752 fma 1 -0.0 -1 -> -1.0
-fmax3753 fma 1 0.0 1 -> 1.0
-fmax3754 fma 1 -0.0 1 -> 1.0
-fmax3755 fma 1 -1.0 0 -> -1.0
-fmax3756 fma 1 -1.0 -0 -> -1.0
-fmax3757 fma 1 1.0 0 -> 1.0
-fmax3758 fma 1 1.0 -0 -> 1.0
-
-fmax3761 fma 1 0 -1.0 -> -1.0
-fmax3762 fma 1 -0 -1.0 -> -1.0
-fmax3763 fma 1 0 1.0 -> 1.0
-fmax3764 fma 1 -0 1.0 -> 1.0
-fmax3765 fma 1 -1 0.0 -> -1.0
-fmax3766 fma 1 -1 -0.0 -> -1.0
-fmax3767 fma 1 1 0.0 -> 1.0
-fmax3768 fma 1 1 -0.0 -> 1.0
-
-fmax3771 fma 1 0.0 -1.0 -> -1.0
-fmax3772 fma 1 -0.0 -1.0 -> -1.0
-fmax3773 fma 1 0.0 1.0 -> 1.0
-fmax3774 fma 1 -0.0 1.0 -> 1.0
-fmax3775 fma 1 -1.0 0.0 -> -1.0
-fmax3776 fma 1 -1.0 -0.0 -> -1.0
-fmax3777 fma 1 1.0 0.0 -> 1.0
-fmax3778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-fmax3780 fma 1 -Inf -Inf -> -Infinity
-fmax3781 fma 1 -Inf -1000 -> -Infinity
-fmax3782 fma 1 -Inf -1 -> -Infinity
-fmax3783 fma 1 -Inf -0 -> -Infinity
-fmax3784 fma 1 -Inf 0 -> -Infinity
-fmax3785 fma 1 -Inf 1 -> -Infinity
-fmax3786 fma 1 -Inf 1000 -> -Infinity
-fmax3787 fma 1 -1000 -Inf -> -Infinity
-fmax3788 fma 1 -Inf -Inf -> -Infinity
-fmax3789 fma 1 -1 -Inf -> -Infinity
-fmax3790 fma 1 -0 -Inf -> -Infinity
-fmax3791 fma 1 0 -Inf -> -Infinity
-fmax3792 fma 1 1 -Inf -> -Infinity
-fmax3793 fma 1 1000 -Inf -> -Infinity
-fmax3794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-fmax3800 fma 1 Inf -Inf -> NaN Invalid_operation
-fmax3801 fma 1 Inf -1000 -> Infinity
-fmax3802 fma 1 Inf -1 -> Infinity
-fmax3803 fma 1 Inf -0 -> Infinity
-fmax3804 fma 1 Inf 0 -> Infinity
-fmax3805 fma 1 Inf 1 -> Infinity
-fmax3806 fma 1 Inf 1000 -> Infinity
-fmax3807 fma 1 Inf Inf -> Infinity
-fmax3808 fma 1 -1000 Inf -> Infinity
-fmax3809 fma 1 -Inf Inf -> NaN Invalid_operation
-fmax3810 fma 1 -1 Inf -> Infinity
-fmax3811 fma 1 -0 Inf -> Infinity
-fmax3812 fma 1 0 Inf -> Infinity
-fmax3813 fma 1 1 Inf -> Infinity
-fmax3814 fma 1 1000 Inf -> Infinity
-fmax3815 fma 1 Inf Inf -> Infinity
-
-fmax3821 fma 1 NaN -Inf -> NaN
-fmax3822 fma 1 NaN -1000 -> NaN
-fmax3823 fma 1 NaN -1 -> NaN
-fmax3824 fma 1 NaN -0 -> NaN
-fmax3825 fma 1 NaN 0 -> NaN
-fmax3826 fma 1 NaN 1 -> NaN
-fmax3827 fma 1 NaN 1000 -> NaN
-fmax3828 fma 1 NaN Inf -> NaN
-fmax3829 fma 1 NaN NaN -> NaN
-fmax3830 fma 1 -Inf NaN -> NaN
-fmax3831 fma 1 -1000 NaN -> NaN
-fmax3832 fma 1 -1 NaN -> NaN
-fmax3833 fma 1 -0 NaN -> NaN
-fmax3834 fma 1 0 NaN -> NaN
-fmax3835 fma 1 1 NaN -> NaN
-fmax3836 fma 1 1000 NaN -> NaN
-fmax3837 fma 1 Inf NaN -> NaN
-
-fmax3841 fma 1 sNaN -Inf -> NaN Invalid_operation
-fmax3842 fma 1 sNaN -1000 -> NaN Invalid_operation
-fmax3843 fma 1 sNaN -1 -> NaN Invalid_operation
-fmax3844 fma 1 sNaN -0 -> NaN Invalid_operation
-fmax3845 fma 1 sNaN 0 -> NaN Invalid_operation
-fmax3846 fma 1 sNaN 1 -> NaN Invalid_operation
-fmax3847 fma 1 sNaN 1000 -> NaN Invalid_operation
-fmax3848 fma 1 sNaN NaN -> NaN Invalid_operation
-fmax3849 fma 1 sNaN sNaN -> NaN Invalid_operation
-fmax3850 fma 1 NaN sNaN -> NaN Invalid_operation
-fmax3851 fma 1 -Inf sNaN -> NaN Invalid_operation
-fmax3852 fma 1 -1000 sNaN -> NaN Invalid_operation
-fmax3853 fma 1 -1 sNaN -> NaN Invalid_operation
-fmax3854 fma 1 -0 sNaN -> NaN Invalid_operation
-fmax3855 fma 1 0 sNaN -> NaN Invalid_operation
-fmax3856 fma 1 1 sNaN -> NaN Invalid_operation
-fmax3857 fma 1 1000 sNaN -> NaN Invalid_operation
-fmax3858 fma 1 Inf sNaN -> NaN Invalid_operation
-fmax3859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-fmax3861 fma 1 NaN1 -Inf -> NaN1
-fmax3862 fma 1 +NaN2 -1000 -> NaN2
-fmax3863 fma 1 NaN3 1000 -> NaN3
-fmax3864 fma 1 NaN4 Inf -> NaN4
-fmax3865 fma 1 NaN5 +NaN6 -> NaN5
-fmax3866 fma 1 -Inf NaN7 -> NaN7
-fmax3867 fma 1 -1000 NaN8 -> NaN8
-fmax3868 fma 1 1000 NaN9 -> NaN9
-fmax3869 fma 1 Inf +NaN10 -> NaN10
-fmax3871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-fmax3872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-fmax3873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-fmax3874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-fmax3875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-fmax3876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-fmax3877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-fmax3878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-fmax3879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-fmax3880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-fmax3881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-fmax3882 fma 1 -NaN26 NaN28 -> -NaN26
-fmax3883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-fmax3884 fma 1 1000 -NaN30 -> -NaN30
-fmax3885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- overflow, underflow and subnormal tests
-maxexponent: 999999
-minexponent: -999999
-precision: 9
-fmax3890 fma 1 1E+999999 9E+999999 -> Infinity Overflow Inexact Rounded
-fmax3891 fma 1 9E+999999 1E+999999 -> Infinity Overflow Inexact Rounded
-fmax3892 fma 1 -1.1E-999999 1E-999999 -> -1E-1000000 Subnormal
-fmax3893 fma 1 1E-999999 -1.1e-999999 -> -1E-1000000 Subnormal
-fmax3894 fma 1 -1.0001E-999999 1E-999999 -> -1E-1000003 Subnormal
-fmax3895 fma 1 1E-999999 -1.0001e-999999 -> -1E-1000003 Subnormal
-fmax3896 fma 1 -1E+999999 -9E+999999 -> -Infinity Overflow Inexact Rounded
-fmax3897 fma 1 -9E+999999 -1E+999999 -> -Infinity Overflow Inexact Rounded
-fmax3898 fma 1 +1.1E-999999 -1E-999999 -> 1E-1000000 Subnormal
-fmax3899 fma 1 -1E-999999 +1.1e-999999 -> 1E-1000000 Subnormal
-fmax3900 fma 1 +1.0001E-999999 -1E-999999 -> 1E-1000003 Subnormal
-fmax3901 fma 1 -1E-999999 +1.0001e-999999 -> 1E-1000003 Subnormal
-fmax3902 fma 1 -1E+999999 +9E+999999 -> 8E+999999
-fmax3903 fma 1 -9E+999999 +1E+999999 -> -8E+999999
-
-precision: 3
-fmax3904 fma 1 0 -9.999E+999999 -> -Infinity Inexact Overflow Rounded
-fmax3905 fma 1 -9.999E+999999 0 -> -Infinity Inexact Overflow Rounded
-fmax3906 fma 1 0 9.999E+999999 -> Infinity Inexact Overflow Rounded
-fmax3907 fma 1 9.999E+999999 0 -> Infinity Inexact Overflow Rounded
-
-precision: 3
-maxexponent: 999
-minexponent: -999
-fmax3910 fma 1 1.00E-999 0 -> 1.00E-999
-fmax3911 fma 1 0.1E-999 0 -> 1E-1000 Subnormal
-fmax3912 fma 1 0.10E-999 0 -> 1.0E-1000 Subnormal
-fmax3913 fma 1 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
-fmax3914 fma 1 0.01E-999 0 -> 1E-1001 Subnormal
--- next is rounded to Nmin
-fmax3915 fma 1 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
-fmax3916 fma 1 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3917 fma 1 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
-fmax3918 fma 1 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3919 fma 1 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3920 fma 1 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
-fmax3930 fma 1 -1.00E-999 0 -> -1.00E-999
-fmax3931 fma 1 -0.1E-999 0 -> -1E-1000 Subnormal
-fmax3932 fma 1 -0.10E-999 0 -> -1.0E-1000 Subnormal
-fmax3933 fma 1 -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
-fmax3934 fma 1 -0.01E-999 0 -> -1E-1001 Subnormal
--- next is rounded to Nmin
-fmax3935 fma 1 -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
-fmax3936 fma 1 -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3937 fma 1 -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
-fmax3938 fma 1 -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3939 fma 1 -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3940 fma 1 -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
--- some non-zero subnormal fma 1 s
-fmax3950 fma 1 1.00E-999 0.1E-999 -> 1.10E-999
-fmax3951 fma 1 0.1E-999 0.1E-999 -> 2E-1000 Subnormal
-fmax3952 fma 1 0.10E-999 0.1E-999 -> 2.0E-1000 Subnormal
-fmax3953 fma 1 0.100E-999 0.1E-999 -> 2.0E-1000 Subnormal Rounded
-fmax3954 fma 1 0.01E-999 0.1E-999 -> 1.1E-1000 Subnormal
-fmax3955 fma 1 0.999E-999 0.1E-999 -> 1.10E-999 Inexact Rounded
-fmax3956 fma 1 0.099E-999 0.1E-999 -> 2.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3957 fma 1 0.009E-999 0.1E-999 -> 1.1E-1000 Inexact Rounded Subnormal Underflow
-fmax3958 fma 1 0.001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3959 fma 1 0.0009E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3960 fma 1 0.0001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
--- negatives...
-fmax3961 fma 1 1.00E-999 -0.1E-999 -> 9.0E-1000 Subnormal
-fmax3962 fma 1 0.1E-999 -0.1E-999 -> 0E-1000
-fmax3963 fma 1 0.10E-999 -0.1E-999 -> 0E-1001
-fmax3964 fma 1 0.100E-999 -0.1E-999 -> 0E-1001 Clamped
-fmax3965 fma 1 0.01E-999 -0.1E-999 -> -9E-1001 Subnormal
-fmax3966 fma 1 0.999E-999 -0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3967 fma 1 0.099E-999 -0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-fmax3968 fma 1 0.009E-999 -0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow
-fmax3969 fma 1 0.001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3970 fma 1 0.0009E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-fmax3971 fma 1 0.0001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-
--- some 'real' numbers
-maxExponent: 384
-minExponent: -383
-precision: 8
-fmax3566 fma 1 99999061735E-394 0E-394 -> 9.999906E-384 Inexact Rounded Underflow Subnormal
-precision: 7
-fmax3567 fma 1 99999061735E-394 0E-394 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
-precision: 6
-fmax3568 fma 1 99999061735E-394 0E-394 -> 9.9999E-384 Inexact Rounded Underflow Subnormal
-
--- now the case where we can get underflow but the result is normal
--- [note this can't happen if the operands are also bounded, as we
--- cannot represent 1E-399, for example]
-precision: 16
-rounding: half_up
-maxExponent: 384
-minExponent: -383
-
-fmax3571 fma 1 1E-383 0 -> 1E-383
-fmax3572 fma 1 1E-384 0 -> 1E-384 Subnormal
-fmax3573 fma 1 1E-383 1E-384 -> 1.1E-383
-fmax3574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
-
--- Here we explore the boundary of rounding a subnormal to Nmin
-fmax3575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax3576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax3577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax3580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- check for double-rounded subnormals
-precision: 5
-maxexponent: 79
-minexponent: -79
--- Add: lhs and rhs 0
-fmax31001 fma 1 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31002 fma 1 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31003 fma 1 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31004 fma 1 0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31005 fma 1 0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31006 fma 1 0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-
--- Add: lhs >> rhs and vice versa
-fmax31011 fma 1 1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31012 fma 1 1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31013 fma 1 1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31014 fma 1 1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31015 fma 1 1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-fmax31016 fma 1 1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
-
--- Add: lhs + rhs fma 1 ition carried out
-fmax31021 fma 1 1.52443E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31022 fma 1 1.52444E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31023 fma 1 1.52445E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31024 fma 1 1.00001E-80 1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31025 fma 1 1.00001E-80 1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-fmax31026 fma 1 1.00001E-80 1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
-
--- And for round down full and subnormal results
-precision: 16
-maxExponent: +384
-minExponent: -383
-rounding: down
-
-fmax31100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-fmax31101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-fmax31103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-fmax31104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-fmax31105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-fmax31106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-fmax31107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-fmax31108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-fmax31109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-fmax31110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-fmax31111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-fmax31113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-fmax31114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-fmax31115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-fmax31116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-fmax31117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-fmax31118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-fmax31119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
-rounding: down
-precision: 7
-maxExponent: +96
-minExponent: -95
-fmax31130 fma 1 1 -1e-200 -> 0.9999999 Rounded Inexact
--- subnormal boundary
-fmax31131 fma 1 1.000000E-94 -1e-200 -> 9.999999E-95 Rounded Inexact
-fmax31132 fma 1 1.000001E-95 -1e-200 -> 1.000000E-95 Rounded Inexact
-fmax31133 fma 1 1.000000E-95 -1e-200 -> 9.99999E-96 Rounded Inexact Subnormal Underflow
-fmax31134 fma 1 0.999999E-95 -1e-200 -> 9.99998E-96 Rounded Inexact Subnormal Underflow
-fmax31135 fma 1 0.001000E-95 -1e-200 -> 9.99E-99 Rounded Inexact Subnormal Underflow
-fmax31136 fma 1 0.000999E-95 -1e-200 -> 9.98E-99 Rounded Inexact Subnormal Underflow
-fmax31137 fma 1 1.000000E-95 -1e-101 -> 9.99999E-96 Subnormal
-fmax31138 fma 1 10000E-101 -1e-200 -> 9.999E-98 Subnormal Inexact Rounded Underflow
-fmax31139 fma 1 1000E-101 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
-fmax31140 fma 1 100E-101 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
-fmax31141 fma 1 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
-fmax31142 fma 1 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31143 fma 1 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31144 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
-fmax31151 fma 1 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
-fmax31152 fma 1 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
-fmax31153 fma 1 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
-fmax31154 fma 1 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31155 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31156 fma 1 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31157 fma 1 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
-fmax31160 fma 1 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
-fmax31161 fma 1 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
-
--- tests based on Gunnar Degnbol's edge case
-precision: 15
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-fmax31200 fma 1 1E15 -0.5 -> 1.00000000000000E+15 Inexact Rounded
-fmax31201 fma 1 1E15 -0.50 -> 1.00000000000000E+15 Inexact Rounded
-fmax31210 fma 1 1E15 -0.51 -> 999999999999999 Inexact Rounded
-fmax31211 fma 1 1E15 -0.501 -> 999999999999999 Inexact Rounded
-fmax31212 fma 1 1E15 -0.5001 -> 999999999999999 Inexact Rounded
-fmax31213 fma 1 1E15 -0.50001 -> 999999999999999 Inexact Rounded
-fmax31214 fma 1 1E15 -0.500001 -> 999999999999999 Inexact Rounded
-fmax31215 fma 1 1E15 -0.5000001 -> 999999999999999 Inexact Rounded
-fmax31216 fma 1 1E15 -0.50000001 -> 999999999999999 Inexact Rounded
-fmax31217 fma 1 1E15 -0.500000001 -> 999999999999999 Inexact Rounded
-fmax31218 fma 1 1E15 -0.5000000001 -> 999999999999999 Inexact Rounded
-fmax31219 fma 1 1E15 -0.50000000001 -> 999999999999999 Inexact Rounded
-fmax31220 fma 1 1E15 -0.500000000001 -> 999999999999999 Inexact Rounded
-fmax31221 fma 1 1E15 -0.5000000000001 -> 999999999999999 Inexact Rounded
-fmax31222 fma 1 1E15 -0.50000000000001 -> 999999999999999 Inexact Rounded
-fmax31223 fma 1 1E15 -0.500000000000001 -> 999999999999999 Inexact Rounded
-fmax31224 fma 1 1E15 -0.5000000000000001 -> 999999999999999 Inexact Rounded
-fmax31225 fma 1 1E15 -0.5000000000000000 -> 1.00000000000000E+15 Inexact Rounded
-fmax31230 fma 1 1E15 -5000000.000000001 -> 999999995000000 Inexact Rounded
-
-precision: 16
-
-fmax31300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax31310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-fmax31311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-fmax31312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-fmax31313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-fmax31314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-fmax31315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-fmax31316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-fmax31317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-fmax31318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-fmax31319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-fmax31320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-fmax31321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-fmax31322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-fmax31323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-fmax31324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-fmax31325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax31339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-fmax31340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-fmax31341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-fmax31349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-fmax31350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-fmax31351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-fmax31352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-fmax31353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-fmax31354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-fmax31355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-fmax31356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-fmax31357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-fmax31358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-fmax31359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-fmax31360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-fmax31361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-fmax31362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-fmax31363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-fmax31364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-fmax31365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax31379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax31380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-fmax31381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax31382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-fmax31395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-fmax31396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-precision: 15
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-fmax31400 fma 1 0 1.23456789012345 -> 1.23456789012345
-fmax31401 fma 1 0 1.23456789012345E-1 -> 0.123456789012345
-fmax31402 fma 1 0 1.23456789012345E-2 -> 0.0123456789012345
-fmax31403 fma 1 0 1.23456789012345E-3 -> 0.00123456789012345
-fmax31404 fma 1 0 1.23456789012345E-4 -> 0.000123456789012345
-fmax31405 fma 1 0 1.23456789012345E-5 -> 0.0000123456789012345
-fmax31406 fma 1 0 1.23456789012345E-6 -> 0.00000123456789012345
-fmax31407 fma 1 0 1.23456789012345E-7 -> 1.23456789012345E-7
-fmax31408 fma 1 0 1.23456789012345E-8 -> 1.23456789012345E-8
-fmax31409 fma 1 0 1.23456789012345E-9 -> 1.23456789012345E-9
-fmax31410 fma 1 0 1.23456789012345E-10 -> 1.23456789012345E-10
-fmax31411 fma 1 0 1.23456789012345E-11 -> 1.23456789012345E-11
-fmax31412 fma 1 0 1.23456789012345E-12 -> 1.23456789012345E-12
-fmax31413 fma 1 0 1.23456789012345E-13 -> 1.23456789012345E-13
-fmax31414 fma 1 0 1.23456789012345E-14 -> 1.23456789012345E-14
-fmax31415 fma 1 0 1.23456789012345E-15 -> 1.23456789012345E-15
-fmax31416 fma 1 0 1.23456789012345E-16 -> 1.23456789012345E-16
-fmax31417 fma 1 0 1.23456789012345E-17 -> 1.23456789012345E-17
-fmax31418 fma 1 0 1.23456789012345E-18 -> 1.23456789012345E-18
-fmax31419 fma 1 0 1.23456789012345E-19 -> 1.23456789012345E-19
-
--- same, precision 16..
-precision: 16
-fmax31420 fma 1 0 1.123456789012345 -> 1.123456789012345
-fmax31421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-fmax31422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-fmax31423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-fmax31424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-fmax31425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-fmax31426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-fmax31427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-fmax31428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-fmax31429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-fmax31430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-fmax31431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-fmax31432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-fmax31433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-fmax31434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-fmax31435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-fmax31436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-fmax31437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-fmax31438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-fmax31439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-fmax31440 fma 1 1.123456789012345 0 -> 1.123456789012345
-fmax31441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-fmax31442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-fmax31443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-fmax31444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-fmax31445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-fmax31446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-fmax31447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-fmax31448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-fmax31449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-fmax31450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-fmax31451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-fmax31452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-fmax31453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-fmax31454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-fmax31455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-fmax31456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-fmax31457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-fmax31458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-fmax31459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-fmax31460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-fmax31461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-fmax31462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-fmax31463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-fmax31464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-fmax31465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-fmax31466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-fmax31467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-fmax31468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-fmax31469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-fmax31470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-fmax31471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-fmax31472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-fmax31473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-fmax31474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-fmax31475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-fmax31476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-fmax31477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-fmax31478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-fmax31479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-precision: 16
-maxExponent: 384
-minexponent: -383
-
-rounding: half_up
--- exact zeros from zeros
-fmax31500 fma 1 0 0E-19 -> 0E-19
-fmax31501 fma 1 -0 0E-19 -> 0E-19
-fmax31502 fma 1 0 -0E-19 -> 0E-19
-fmax31503 fma 1 -0 -0E-19 -> -0E-19
-fmax31504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_down
--- exact zeros from zeros
-fmax31520 fma 1 0 0E-19 -> 0E-19
-fmax31521 fma 1 -0 0E-19 -> 0E-19
-fmax31522 fma 1 0 -0E-19 -> 0E-19
-fmax31523 fma 1 -0 -0E-19 -> -0E-19
-fmax31524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_even
--- exact zeros from zeros
-fmax31540 fma 1 0 0E-19 -> 0E-19
-fmax31541 fma 1 -0 0E-19 -> 0E-19
-fmax31542 fma 1 0 -0E-19 -> 0E-19
-fmax31543 fma 1 -0 -0E-19 -> -0E-19
-fmax31544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: up
--- exact zeros from zeros
-fmax31560 fma 1 0 0E-19 -> 0E-19
-fmax31561 fma 1 -0 0E-19 -> 0E-19
-fmax31562 fma 1 0 -0E-19 -> 0E-19
-fmax31563 fma 1 -0 -0E-19 -> -0E-19
-fmax31564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax31574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax31575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
-rounding: down
--- exact zeros from zeros
-fmax31580 fma 1 0 0E-19 -> 0E-19
-fmax31581 fma 1 -0 0E-19 -> 0E-19
-fmax31582 fma 1 0 -0E-19 -> 0E-19
-fmax31583 fma 1 -0 -0E-19 -> -0E-19
-fmax31584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: ceiling
--- exact zeros from zeros
-fmax31600 fma 1 0 0E-19 -> 0E-19
-fmax31601 fma 1 -0 0E-19 -> 0E-19
-fmax31602 fma 1 0 -0E-19 -> 0E-19
-fmax31603 fma 1 -0 -0E-19 -> -0E-19
-fmax31604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax31606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax31607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax31615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax31616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax31617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax31618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-fmax31620 fma 1 0 0E-19 -> 0E-19
-fmax31621 fma 1 -0 0E-19 -> -0E-19 -- *
-fmax31622 fma 1 0 -0E-19 -> -0E-19 -- *
-fmax31623 fma 1 -0 -0E-19 -> -0E-19
-fmax31624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax31625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
-fmax31626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
-fmax31627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax31631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax31634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax31635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax31636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
-fmax31637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
-fmax31638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
--- BigDecimal problem testcases 2006.01.23
-precision: 16
-maxExponent: 384
-minexponent: -383
-
-rounding: down
-precision: 7
-fmax31651 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31652 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31653 fma 1 10001E+2 -2E+1 -> 1.0000E+6 Inexact Rounded
-precision: 4
-fmax31654 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
-precision: 3
-fmax31655 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
-precision: 2
-fmax31656 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
-precision: 1
-fmax31657 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
-
-rounding: half_even
-precision: 7
-fmax31661 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31662 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31663 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
-precision: 4
-fmax31664 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
-precision: 3
-fmax31665 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
-precision: 2
-fmax31666 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
-precision: 1
-fmax31667 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
-
-rounding: up
-precision: 7
-fmax31671 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 6
-fmax31672 fma 1 10001E+2 -2E+1 -> 1.00008E+6
-precision: 5
-fmax31673 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
-precision: 4
-fmax31674 fma 1 10001E+2 -2E+1 -> 1.001E+6 Inexact Rounded
-precision: 3
-fmax31675 fma 1 10001E+2 -2E+1 -> 1.01E+6 Inexact Rounded
-precision: 2
-fmax31676 fma 1 10001E+2 -2E+1 -> 1.1E+6 Inexact Rounded
-precision: 1
-fmax31677 fma 1 10001E+2 -2E+1 -> 2E+6 Inexact Rounded
-
-precision: 34
-rounding: half_up
-maxExponent: 6144
-minExponent: -6143
--- Examples from SQL proposal (Krishna Kulkarni)
-fmax31701 fma 1 130E-2 120E-2 -> 2.50
-fmax31702 fma 1 130E-2 12E-1 -> 2.50
-fmax31703 fma 1 130E-2 1E0 -> 2.30
-fmax31704 fma 1 1E2 1E4 -> 1.01E+4
-fmax31705 subtract 130E-2 120E-2 -> 0.10
-fmax31706 subtract 130E-2 12E-1 -> 0.10
-fmax31707 subtract 130E-2 1E0 -> 0.30
-fmax31708 subtract 1E2 1E4 -> -9.9E+3
-
-------------------------------------------------------------------------
--- Same as above, using decimal64 default parameters --
-------------------------------------------------------------------------
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- [first group are 'quick confidence check']
-fmax36001 fma 1 1 1 -> 2
-fmax36002 fma 1 2 3 -> 5
-fmax36003 fma 1 '5.75' '3.3' -> 9.05
-fmax36004 fma 1 '5' '-3' -> 2
-fmax36005 fma 1 '-5' '-3' -> -8
-fmax36006 fma 1 '-7' '2.5' -> -4.5
-fmax36007 fma 1 '0.7' '0.3' -> 1.0
-fmax36008 fma 1 '1.25' '1.25' -> 2.50
-fmax36009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
-fmax36010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
-
-fmax36011 fma 1 '0.44444444444444444' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
-fmax36012 fma 1 '0.44444444444444440' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
-fmax36013 fma 1 '0.44444444444444444' '0.55555555555555550' -> '0.9999999999999999' Inexact Rounded
-fmax36014 fma 1 '0.444444444444444449' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36015 fma 1 '0.4444444444444444499' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36016 fma 1 '0.44444444444444444999' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36017 fma 1 '0.44444444444444445000' '0' -> '0.4444444444444444' Inexact Rounded
-fmax36018 fma 1 '0.44444444444444445001' '0' -> '0.4444444444444445' Inexact Rounded
-fmax36019 fma 1 '0.4444444444444444501' '0' -> '0.4444444444444445' Inexact Rounded
-fmax36020 fma 1 '0.444444444444444451' '0' -> '0.4444444444444445' Inexact Rounded
-
-fmax36021 fma 1 0 1 -> 1
-fmax36022 fma 1 1 1 -> 2
-fmax36023 fma 1 2 1 -> 3
-fmax36024 fma 1 3 1 -> 4
-fmax36025 fma 1 4 1 -> 5
-fmax36026 fma 1 5 1 -> 6
-fmax36027 fma 1 6 1 -> 7
-fmax36028 fma 1 7 1 -> 8
-fmax36029 fma 1 8 1 -> 9
-fmax36030 fma 1 9 1 -> 10
-
--- some carrying effects
-fmax36031 fma 1 '0.9998' '0.0000' -> '0.9998'
-fmax36032 fma 1 '0.9998' '0.0001' -> '0.9999'
-fmax36033 fma 1 '0.9998' '0.0002' -> '1.0000'
-fmax36034 fma 1 '0.9998' '0.0003' -> '1.0001'
-
-fmax36035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
-fmax36038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
-fmax36039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
-
--- symmetry:
-fmax36040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
-fmax36041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
-fmax36042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
-fmax36044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
-fmax36045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
-
-fmax36046 fma 1 '10000e+9' '7' -> '10000000000007'
-fmax36047 fma 1 '10000e+9' '70' -> '10000000000070'
-fmax36048 fma 1 '10000e+9' '700' -> '10000000000700'
-fmax36049 fma 1 '10000e+9' '7000' -> '10000000007000'
-fmax36050 fma 1 '10000e+9' '70000' -> '10000000070000'
-fmax36051 fma 1 '10000e+9' '700000' -> '10000000700000'
-
--- examples from decarith
-fmax36053 fma 1 '12' '7.00' -> '19.00'
-fmax36054 fma 1 '1.3' '-1.07' -> '0.23'
-fmax36055 fma 1 '1.3' '-1.30' -> '0.00'
-fmax36056 fma 1 '1.3' '-2.07' -> '-0.77'
-fmax36057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
-
--- from above
-fmax36061 fma 1 1 '0.1' -> '1.1'
-fmax36062 fma 1 1 '0.01' -> '1.01'
-fmax36063 fma 1 1 '0.001' -> '1.001'
-fmax36064 fma 1 1 '0.0001' -> '1.0001'
-fmax36065 fma 1 1 '0.00001' -> '1.00001'
-fmax36066 fma 1 1 '0.000001' -> '1.000001'
-fmax36067 fma 1 1 '0.0000001' -> '1.0000001'
-fmax36068 fma 1 1 '0.00000001' -> '1.00000001'
-
--- some funny zeros [in case of bad signum]
-fmax36070 fma 1 1 0 -> 1
-fmax36071 fma 1 1 0. -> 1
-fmax36072 fma 1 1 .0 -> 1.0
-fmax36073 fma 1 1 0.0 -> 1.0
-fmax36074 fma 1 1 0.00 -> 1.00
-fmax36075 fma 1 0 1 -> 1
-fmax36076 fma 1 0. 1 -> 1
-fmax36077 fma 1 .0 1 -> 1.0
-fmax36078 fma 1 0.0 1 -> 1.0
-fmax36079 fma 1 0.00 1 -> 1.00
-
--- some carries
-fmax36080 fma 1 9999999999999998 1 -> 9999999999999999
-fmax36081 fma 1 9999999999999999 1 -> 1.000000000000000E+16 Rounded
-fmax36082 fma 1 999999999999999 1 -> 1000000000000000
-fmax36083 fma 1 9999999999999 1 -> 10000000000000
-fmax36084 fma 1 99999999999 1 -> 100000000000
-fmax36085 fma 1 999999999 1 -> 1000000000
-fmax36086 fma 1 9999999 1 -> 10000000
-fmax36087 fma 1 99999 1 -> 100000
-fmax36088 fma 1 999 1 -> 1000
-fmax36089 fma 1 9 1 -> 10
-
-
--- more LHS swaps
-fmax36090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
-fmax36091 fma 1 '-56267E-6' 0 -> '-0.056267'
-fmax36092 fma 1 '-56267E-5' 0 -> '-0.56267'
-fmax36093 fma 1 '-56267E-4' 0 -> '-5.6267'
-fmax36094 fma 1 '-56267E-3' 0 -> '-56.267'
-fmax36095 fma 1 '-56267E-2' 0 -> '-562.67'
-fmax36096 fma 1 '-56267E-1' 0 -> '-5626.7'
-fmax36097 fma 1 '-56267E-0' 0 -> '-56267'
-fmax36098 fma 1 '-5E-10' 0 -> '-5E-10'
-fmax36099 fma 1 '-5E-7' 0 -> '-5E-7'
-fmax36100 fma 1 '-5E-6' 0 -> '-0.000005'
-fmax36101 fma 1 '-5E-5' 0 -> '-0.00005'
-fmax36102 fma 1 '-5E-4' 0 -> '-0.0005'
-fmax36103 fma 1 '-5E-1' 0 -> '-0.5'
-fmax36104 fma 1 '-5E0' 0 -> '-5'
-fmax36105 fma 1 '-5E1' 0 -> '-50'
-fmax36106 fma 1 '-5E5' 0 -> '-500000'
-fmax36107 fma 1 '-5E15' 0 -> '-5000000000000000'
-fmax36108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
-fmax36109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
-fmax36110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
-fmax36111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
-
--- more RHS swaps
-fmax36113 fma 1 0 '-56267E-10' -> '-0.0000056267'
-fmax36114 fma 1 0 '-56267E-6' -> '-0.056267'
-fmax36116 fma 1 0 '-56267E-5' -> '-0.56267'
-fmax36117 fma 1 0 '-56267E-4' -> '-5.6267'
-fmax36119 fma 1 0 '-56267E-3' -> '-56.267'
-fmax36120 fma 1 0 '-56267E-2' -> '-562.67'
-fmax36121 fma 1 0 '-56267E-1' -> '-5626.7'
-fmax36122 fma 1 0 '-56267E-0' -> '-56267'
-fmax36123 fma 1 0 '-5E-10' -> '-5E-10'
-fmax36124 fma 1 0 '-5E-7' -> '-5E-7'
-fmax36125 fma 1 0 '-5E-6' -> '-0.000005'
-fmax36126 fma 1 0 '-5E-5' -> '-0.00005'
-fmax36127 fma 1 0 '-5E-4' -> '-0.0005'
-fmax36128 fma 1 0 '-5E-1' -> '-0.5'
-fmax36129 fma 1 0 '-5E0' -> '-5'
-fmax36130 fma 1 0 '-5E1' -> '-50'
-fmax36131 fma 1 0 '-5E5' -> '-500000'
-fmax36132 fma 1 0 '-5E15' -> '-5000000000000000'
-fmax36133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
-fmax36134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
-fmax36135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
-fmax36136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
-
--- related
-fmax36137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
-fmax36138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
-fmax36139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
-fmax36140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
-fmax36141 fma 1 1E+11 0.0000 -> '100000000000.0000'
-fmax36142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
-fmax36143 fma 1 0.000 1E+12 -> '1000000000000.000'
-fmax36144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
-
--- [some of the next group are really constructor tests]
-fmax36146 fma 1 '00.0' 0 -> '0.0'
-fmax36147 fma 1 '0.00' 0 -> '0.00'
-fmax36148 fma 1 0 '0.00' -> '0.00'
-fmax36149 fma 1 0 '00.0' -> '0.0'
-fmax36150 fma 1 '00.0' '0.00' -> '0.00'
-fmax36151 fma 1 '0.00' '00.0' -> '0.00'
-fmax36152 fma 1 '3' '.3' -> '3.3'
-fmax36153 fma 1 '3.' '.3' -> '3.3'
-fmax36154 fma 1 '3.0' '.3' -> '3.3'
-fmax36155 fma 1 '3.00' '.3' -> '3.30'
-fmax36156 fma 1 '3' '3' -> '6'
-fmax36157 fma 1 '3' '+3' -> '6'
-fmax36158 fma 1 '3' '-3' -> '0'
-fmax36159 fma 1 '0.3' '-0.3' -> '0.0'
-fmax36160 fma 1 '0.03' '-0.03' -> '0.00'
-
--- try borderline precision, with carries, etc.
-fmax36161 fma 1 '1E+13' '-1' -> '9999999999999'
-fmax36162 fma 1 '1E+13' '1.11' -> '10000000000001.11'
-fmax36163 fma 1 '1.11' '1E+13' -> '10000000000001.11'
-fmax36164 fma 1 '-1' '1E+13' -> '9999999999999'
-fmax36165 fma 1 '7E+13' '-1' -> '69999999999999'
-fmax36166 fma 1 '7E+13' '1.11' -> '70000000000001.11'
-fmax36167 fma 1 '1.11' '7E+13' -> '70000000000001.11'
-fmax36168 fma 1 '-1' '7E+13' -> '69999999999999'
-
--- 1234567890123456 1234567890123456 1 234567890123456
-fmax36170 fma 1 '0.4444444444444444' '0.5555555555555563' -> '1.000000000000001' Inexact Rounded
-fmax36171 fma 1 '0.4444444444444444' '0.5555555555555562' -> '1.000000000000001' Inexact Rounded
-fmax36172 fma 1 '0.4444444444444444' '0.5555555555555561' -> '1.000000000000000' Inexact Rounded
-fmax36173 fma 1 '0.4444444444444444' '0.5555555555555560' -> '1.000000000000000' Inexact Rounded
-fmax36174 fma 1 '0.4444444444444444' '0.5555555555555559' -> '1.000000000000000' Inexact Rounded
-fmax36175 fma 1 '0.4444444444444444' '0.5555555555555558' -> '1.000000000000000' Inexact Rounded
-fmax36176 fma 1 '0.4444444444444444' '0.5555555555555557' -> '1.000000000000000' Inexact Rounded
-fmax36177 fma 1 '0.4444444444444444' '0.5555555555555556' -> '1.000000000000000' Rounded
-fmax36178 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
-fmax36179 fma 1 '0.4444444444444444' '0.5555555555555554' -> '0.9999999999999998'
-fmax36180 fma 1 '0.4444444444444444' '0.5555555555555553' -> '0.9999999999999997'
-fmax36181 fma 1 '0.4444444444444444' '0.5555555555555552' -> '0.9999999999999996'
-fmax36182 fma 1 '0.4444444444444444' '0.5555555555555551' -> '0.9999999999999995'
-fmax36183 fma 1 '0.4444444444444444' '0.5555555555555550' -> '0.9999999999999994'
-
--- and some more, including residue effects and different roundings
-rounding: half_up
-fmax36200 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36201 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36202 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36203 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36204 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36205 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36206 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36207 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36208 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-fmax36209 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-fmax36210 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-fmax36211 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-fmax36212 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-fmax36213 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-fmax36214 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-fmax36215 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
-fmax36216 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36217 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
-fmax36218 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36219 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
-rounding: half_even
-fmax36220 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36221 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36222 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36223 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36224 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36225 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36226 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36227 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36228 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
-fmax36229 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
-fmax36230 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
-fmax36231 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
-fmax36232 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
-fmax36233 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
-fmax36234 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
-fmax36235 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
-fmax36236 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36237 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-fmax36238 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36239 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
--- critical few with even bottom digit...
-fmax36240 fma 1 '6543210123456788' 0.499999 -> '6543210123456788' Inexact Rounded
-fmax36241 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
-fmax36242 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
-
-rounding: down
-fmax36250 fma 1 '6543210123456789' 0 -> '6543210123456789'
-fmax36251 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
-fmax36252 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
-fmax36253 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
-fmax36254 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
-fmax36255 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
-fmax36256 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36257 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
-fmax36258 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
-fmax36259 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
-fmax36260 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
-fmax36261 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
-fmax36262 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
-fmax36263 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
-fmax36264 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
-fmax36265 fma 1 '6543210123456789' 0.999999 -> '6543210123456789' Inexact Rounded
-fmax36266 fma 1 '6543210123456789' 1 -> '6543210123456790'
-fmax36267 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
-fmax36268 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
-fmax36269 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
-
--- 1 in last place tests
-rounding: half_even
-fmax36301 fma 1 -1 1 -> 0
-fmax36302 fma 1 0 1 -> 1
-fmax36303 fma 1 1 1 -> 2
-fmax36304 fma 1 12 1 -> 13
-fmax36305 fma 1 98 1 -> 99
-fmax36306 fma 1 99 1 -> 100
-fmax36307 fma 1 100 1 -> 101
-fmax36308 fma 1 101 1 -> 102
-fmax36309 fma 1 -1 -1 -> -2
-fmax36310 fma 1 0 -1 -> -1
-fmax36311 fma 1 1 -1 -> 0
-fmax36312 fma 1 12 -1 -> 11
-fmax36313 fma 1 98 -1 -> 97
-fmax36314 fma 1 99 -1 -> 98
-fmax36315 fma 1 100 -1 -> 99
-fmax36316 fma 1 101 -1 -> 100
-
-fmax36321 fma 1 -0.01 0.01 -> 0.00
-fmax36322 fma 1 0.00 0.01 -> 0.01
-fmax36323 fma 1 0.01 0.01 -> 0.02
-fmax36324 fma 1 0.12 0.01 -> 0.13
-fmax36325 fma 1 0.98 0.01 -> 0.99
-fmax36326 fma 1 0.99 0.01 -> 1.00
-fmax36327 fma 1 1.00 0.01 -> 1.01
-fmax36328 fma 1 1.01 0.01 -> 1.02
-fmax36329 fma 1 -0.01 -0.01 -> -0.02
-fmax36330 fma 1 0.00 -0.01 -> -0.01
-fmax36331 fma 1 0.01 -0.01 -> 0.00
-fmax36332 fma 1 0.12 -0.01 -> 0.11
-fmax36333 fma 1 0.98 -0.01 -> 0.97
-fmax36334 fma 1 0.99 -0.01 -> 0.98
-fmax36335 fma 1 1.00 -0.01 -> 0.99
-fmax36336 fma 1 1.01 -0.01 -> 1.00
-
--- some more cases where fma 1 ing 0 affects the coefficient
-fmax36340 fma 1 1E+3 0 -> 1000
-fmax36341 fma 1 1E+15 0 -> 1000000000000000
-fmax36342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
-fmax36343 fma 1 1E+17 0 -> 1.000000000000000E+17 Rounded
--- which simply follow from these cases ...
-fmax36344 fma 1 1E+3 1 -> 1001
-fmax36345 fma 1 1E+15 1 -> 1000000000000001
-fmax36346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
-fmax36347 fma 1 1E+17 1 -> 1.000000000000000E+17 Inexact Rounded
-fmax36348 fma 1 1E+3 7 -> 1007
-fmax36349 fma 1 1E+15 7 -> 1000000000000007
-fmax36350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
-fmax36351 fma 1 1E+17 7 -> 1.000000000000000E+17 Inexact Rounded
-
--- tryzeros cases
-fmax36361 fma 1 0E+50 10000E+1 -> 1.0000E+5
-fmax36362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
-fmax36363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
-fmax36364 fma 1 12.34 0e-398 -> 12.34000000000000 Rounded
-
--- ulp replacement tests
-fmax36400 fma 1 1 77e-14 -> 1.00000000000077
-fmax36401 fma 1 1 77e-15 -> 1.000000000000077
-fmax36402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
-fmax36403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
-fmax36404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
-fmax36405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
-fmax36406 fma 1 1 77e-99 -> 1.000000000000000 Inexact Rounded
-
-fmax36410 fma 1 10 77e-14 -> 10.00000000000077
-fmax36411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
-fmax36412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
-fmax36413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
-fmax36414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
-fmax36415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
-fmax36416 fma 1 10 77e-99 -> 10.00000000000000 Inexact Rounded
-
-fmax36420 fma 1 77e-14 1 -> 1.00000000000077
-fmax36421 fma 1 77e-15 1 -> 1.000000000000077
-fmax36422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
-fmax36423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
-fmax36424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
-fmax36425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
-fmax36426 fma 1 77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-fmax36430 fma 1 77e-14 10 -> 10.00000000000077
-fmax36431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
-fmax36432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
-fmax36433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
-fmax36434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
-fmax36435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
-fmax36436 fma 1 77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-fmax36440 fma 1 1 -77e-14 -> 0.99999999999923
-fmax36441 fma 1 1 -77e-15 -> 0.999999999999923
-fmax36442 fma 1 1 -77e-16 -> 0.9999999999999923
-fmax36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
-fmax36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
-fmax36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
-fmax36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
-
-fmax36450 fma 1 10 -77e-14 -> 9.99999999999923
-fmax36451 fma 1 10 -77e-15 -> 9.999999999999923
-fmax36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
-fmax36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
-fmax36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
-fmax36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
-fmax36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
-
-fmax36460 fma 1 -77e-14 1 -> 0.99999999999923
-fmax36461 fma 1 -77e-15 1 -> 0.999999999999923
-fmax36462 fma 1 -77e-16 1 -> 0.9999999999999923
-fmax36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
-fmax36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
-fmax36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
-fmax36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
-
-fmax36470 fma 1 -77e-14 10 -> 9.99999999999923
-fmax36471 fma 1 -77e-15 10 -> 9.999999999999923
-fmax36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
-fmax36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
-fmax36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
-fmax36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
-fmax36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
-
--- negative ulps
-fmax36480 fma 1 -1 77e-14 -> -0.99999999999923
-fmax36481 fma 1 -1 77e-15 -> -0.999999999999923
-fmax36482 fma 1 -1 77e-16 -> -0.9999999999999923
-fmax36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
-fmax36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
-fmax36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
-fmax36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
-
-fmax36490 fma 1 -10 77e-14 -> -9.99999999999923
-fmax36491 fma 1 -10 77e-15 -> -9.999999999999923
-fmax36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
-fmax36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
-fmax36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
-fmax36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
-fmax36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
-
-fmax36500 fma 1 77e-14 -1 -> -0.99999999999923
-fmax36501 fma 1 77e-15 -1 -> -0.999999999999923
-fmax36502 fma 1 77e-16 -1 -> -0.9999999999999923
-fmax36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
-fmax36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
-fmax36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
-fmax36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
-
-fmax36510 fma 1 77e-14 -10 -> -9.99999999999923
-fmax36511 fma 1 77e-15 -10 -> -9.999999999999923
-fmax36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
-fmax36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
-fmax36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
-fmax36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
-fmax36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
-
-
--- long operands
-fmax36521 fma 1 101234562345678000 0 -> 1.012345623456780E+17 Rounded
-fmax36522 fma 1 0 101234562345678000 -> 1.012345623456780E+17 Rounded
-fmax36523 fma 1 10123456234567800 0 -> 1.012345623456780E+16 Rounded
-fmax36524 fma 1 0 10123456234567800 -> 1.012345623456780E+16 Rounded
-fmax36525 fma 1 10123456234567890 0 -> 1.012345623456789E+16 Rounded
-fmax36526 fma 1 0 10123456234567890 -> 1.012345623456789E+16 Rounded
-fmax36527 fma 1 10123456234567891 0 -> 1.012345623456789E+16 Inexact Rounded
-fmax36528 fma 1 0 10123456234567891 -> 1.012345623456789E+16 Inexact Rounded
-fmax36529 fma 1 101234562345678901 0 -> 1.012345623456789E+17 Inexact Rounded
-fmax36530 fma 1 0 101234562345678901 -> 1.012345623456789E+17 Inexact Rounded
-fmax36531 fma 1 10123456234567896 0 -> 1.012345623456790E+16 Inexact Rounded
-fmax36532 fma 1 0 10123456234567896 -> 1.012345623456790E+16 Inexact Rounded
-
--- verify a query
-rounding: down
-fmax36561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
-fmax36562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
--- and using decimal64 bounds...
-rounding: down
-fmax36563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
-fmax36564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
-
--- more zeros, etc.
-rounding: half_even
-
-fmax36701 fma 1 5.00 1.00E-3 -> 5.00100
-fmax36702 fma 1 00.00 0.000 -> 0.000
-fmax36703 fma 1 00.00 0E-3 -> 0.000
-fmax36704 fma 1 0E-3 00.00 -> 0.000
-
-fmax36710 fma 1 0E+3 00.00 -> 0.00
-fmax36711 fma 1 0E+3 00.0 -> 0.0
-fmax36712 fma 1 0E+3 00. -> 0
-fmax36713 fma 1 0E+3 00.E+1 -> 0E+1
-fmax36714 fma 1 0E+3 00.E+2 -> 0E+2
-fmax36715 fma 1 0E+3 00.E+3 -> 0E+3
-fmax36716 fma 1 0E+3 00.E+4 -> 0E+3
-fmax36717 fma 1 0E+3 00.E+5 -> 0E+3
-fmax36718 fma 1 0E+3 -00.0 -> 0.0
-fmax36719 fma 1 0E+3 -00. -> 0
-fmax36731 fma 1 0E+3 -00.E+1 -> 0E+1
-
-fmax36720 fma 1 00.00 0E+3 -> 0.00
-fmax36721 fma 1 00.0 0E+3 -> 0.0
-fmax36722 fma 1 00. 0E+3 -> 0
-fmax36723 fma 1 00.E+1 0E+3 -> 0E+1
-fmax36724 fma 1 00.E+2 0E+3 -> 0E+2
-fmax36725 fma 1 00.E+3 0E+3 -> 0E+3
-fmax36726 fma 1 00.E+4 0E+3 -> 0E+3
-fmax36727 fma 1 00.E+5 0E+3 -> 0E+3
-fmax36728 fma 1 -00.00 0E+3 -> 0.00
-fmax36729 fma 1 -00.0 0E+3 -> 0.0
-fmax36730 fma 1 -00. 0E+3 -> 0
-
-fmax36732 fma 1 0 0 -> 0
-fmax36733 fma 1 0 -0 -> 0
-fmax36734 fma 1 -0 0 -> 0
-fmax36735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
-
-fmax36736 fma 1 1 -1 -> 0
-fmax36737 fma 1 -1 -1 -> -2
-fmax36738 fma 1 1 1 -> 2
-fmax36739 fma 1 -1 1 -> 0
-
-fmax36741 fma 1 0 -1 -> -1
-fmax36742 fma 1 -0 -1 -> -1
-fmax36743 fma 1 0 1 -> 1
-fmax36744 fma 1 -0 1 -> 1
-fmax36745 fma 1 -1 0 -> -1
-fmax36746 fma 1 -1 -0 -> -1
-fmax36747 fma 1 1 0 -> 1
-fmax36748 fma 1 1 -0 -> 1
-
-fmax36751 fma 1 0.0 -1 -> -1.0
-fmax36752 fma 1 -0.0 -1 -> -1.0
-fmax36753 fma 1 0.0 1 -> 1.0
-fmax36754 fma 1 -0.0 1 -> 1.0
-fmax36755 fma 1 -1.0 0 -> -1.0
-fmax36756 fma 1 -1.0 -0 -> -1.0
-fmax36757 fma 1 1.0 0 -> 1.0
-fmax36758 fma 1 1.0 -0 -> 1.0
-
-fmax36761 fma 1 0 -1.0 -> -1.0
-fmax36762 fma 1 -0 -1.0 -> -1.0
-fmax36763 fma 1 0 1.0 -> 1.0
-fmax36764 fma 1 -0 1.0 -> 1.0
-fmax36765 fma 1 -1 0.0 -> -1.0
-fmax36766 fma 1 -1 -0.0 -> -1.0
-fmax36767 fma 1 1 0.0 -> 1.0
-fmax36768 fma 1 1 -0.0 -> 1.0
-
-fmax36771 fma 1 0.0 -1.0 -> -1.0
-fmax36772 fma 1 -0.0 -1.0 -> -1.0
-fmax36773 fma 1 0.0 1.0 -> 1.0
-fmax36774 fma 1 -0.0 1.0 -> 1.0
-fmax36775 fma 1 -1.0 0.0 -> -1.0
-fmax36776 fma 1 -1.0 -0.0 -> -1.0
-fmax36777 fma 1 1.0 0.0 -> 1.0
-fmax36778 fma 1 1.0 -0.0 -> 1.0
-
--- Specials
-fmax36780 fma 1 -Inf -Inf -> -Infinity
-fmax36781 fma 1 -Inf -1000 -> -Infinity
-fmax36782 fma 1 -Inf -1 -> -Infinity
-fmax36783 fma 1 -Inf -0 -> -Infinity
-fmax36784 fma 1 -Inf 0 -> -Infinity
-fmax36785 fma 1 -Inf 1 -> -Infinity
-fmax36786 fma 1 -Inf 1000 -> -Infinity
-fmax36787 fma 1 -1000 -Inf -> -Infinity
-fmax36788 fma 1 -Inf -Inf -> -Infinity
-fmax36789 fma 1 -1 -Inf -> -Infinity
-fmax36790 fma 1 -0 -Inf -> -Infinity
-fmax36791 fma 1 0 -Inf -> -Infinity
-fmax36792 fma 1 1 -Inf -> -Infinity
-fmax36793 fma 1 1000 -Inf -> -Infinity
-fmax36794 fma 1 Inf -Inf -> NaN Invalid_operation
-
-fmax36800 fma 1 Inf -Inf -> NaN Invalid_operation
-fmax36801 fma 1 Inf -1000 -> Infinity
-fmax36802 fma 1 Inf -1 -> Infinity
-fmax36803 fma 1 Inf -0 -> Infinity
-fmax36804 fma 1 Inf 0 -> Infinity
-fmax36805 fma 1 Inf 1 -> Infinity
-fmax36806 fma 1 Inf 1000 -> Infinity
-fmax36807 fma 1 Inf Inf -> Infinity
-fmax36808 fma 1 -1000 Inf -> Infinity
-fmax36809 fma 1 -Inf Inf -> NaN Invalid_operation
-fmax36810 fma 1 -1 Inf -> Infinity
-fmax36811 fma 1 -0 Inf -> Infinity
-fmax36812 fma 1 0 Inf -> Infinity
-fmax36813 fma 1 1 Inf -> Infinity
-fmax36814 fma 1 1000 Inf -> Infinity
-fmax36815 fma 1 Inf Inf -> Infinity
-
-fmax36821 fma 1 NaN -Inf -> NaN
-fmax36822 fma 1 NaN -1000 -> NaN
-fmax36823 fma 1 NaN -1 -> NaN
-fmax36824 fma 1 NaN -0 -> NaN
-fmax36825 fma 1 NaN 0 -> NaN
-fmax36826 fma 1 NaN 1 -> NaN
-fmax36827 fma 1 NaN 1000 -> NaN
-fmax36828 fma 1 NaN Inf -> NaN
-fmax36829 fma 1 NaN NaN -> NaN
-fmax36830 fma 1 -Inf NaN -> NaN
-fmax36831 fma 1 -1000 NaN -> NaN
-fmax36832 fma 1 -1 NaN -> NaN
-fmax36833 fma 1 -0 NaN -> NaN
-fmax36834 fma 1 0 NaN -> NaN
-fmax36835 fma 1 1 NaN -> NaN
-fmax36836 fma 1 1000 NaN -> NaN
-fmax36837 fma 1 Inf NaN -> NaN
-
-fmax36841 fma 1 sNaN -Inf -> NaN Invalid_operation
-fmax36842 fma 1 sNaN -1000 -> NaN Invalid_operation
-fmax36843 fma 1 sNaN -1 -> NaN Invalid_operation
-fmax36844 fma 1 sNaN -0 -> NaN Invalid_operation
-fmax36845 fma 1 sNaN 0 -> NaN Invalid_operation
-fmax36846 fma 1 sNaN 1 -> NaN Invalid_operation
-fmax36847 fma 1 sNaN 1000 -> NaN Invalid_operation
-fmax36848 fma 1 sNaN NaN -> NaN Invalid_operation
-fmax36849 fma 1 sNaN sNaN -> NaN Invalid_operation
-fmax36850 fma 1 NaN sNaN -> NaN Invalid_operation
-fmax36851 fma 1 -Inf sNaN -> NaN Invalid_operation
-fmax36852 fma 1 -1000 sNaN -> NaN Invalid_operation
-fmax36853 fma 1 -1 sNaN -> NaN Invalid_operation
-fmax36854 fma 1 -0 sNaN -> NaN Invalid_operation
-fmax36855 fma 1 0 sNaN -> NaN Invalid_operation
-fmax36856 fma 1 1 sNaN -> NaN Invalid_operation
-fmax36857 fma 1 1000 sNaN -> NaN Invalid_operation
-fmax36858 fma 1 Inf sNaN -> NaN Invalid_operation
-fmax36859 fma 1 NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-fmax36861 fma 1 NaN1 -Inf -> NaN1
-fmax36862 fma 1 +NaN2 -1000 -> NaN2
-fmax36863 fma 1 NaN3 1000 -> NaN3
-fmax36864 fma 1 NaN4 Inf -> NaN4
-fmax36865 fma 1 NaN5 +NaN6 -> NaN5
-fmax36866 fma 1 -Inf NaN7 -> NaN7
-fmax36867 fma 1 -1000 NaN8 -> NaN8
-fmax36868 fma 1 1000 NaN9 -> NaN9
-fmax36869 fma 1 Inf +NaN10 -> NaN10
-fmax36871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
-fmax36872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
-fmax36873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
-fmax36874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
-fmax36875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
-fmax36876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
-fmax36877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
-fmax36878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
-fmax36879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
-fmax36880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
-fmax36881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
-fmax36882 fma 1 -NaN26 NaN28 -> -NaN26
-fmax36883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-fmax36884 fma 1 1000 -NaN30 -> -NaN30
-fmax36885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- now the case where we can get underflow but the result is normal
--- [note this can't happen if the operands are also bounded, as we
--- cannot represent 1E-399, for example]
-
-fmax36571 fma 1 1E-383 0 -> 1E-383
-fmax36572 fma 1 1E-384 0 -> 1E-384 Subnormal
-fmax36573 fma 1 1E-383 1E-384 -> 1.1E-383
-fmax36574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
-
--- Here we explore the boundary of rounding a subnormal to Nmin
-fmax36575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax36576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
-fmax36577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-fmax36580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
-
--- check overflow edge case
--- 1234567890123456
-fmax36972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
-fmax36973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
-fmax36974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
-fmax36975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
-fmax36976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
-fmax36977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
-fmax36978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
-fmax36979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
-fmax36980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
-fmax36981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
-fmax36984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
-
-fmax36985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
-fmax36986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
-fmax36987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
-fmax36988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
-fmax36989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
-fmax36990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
-fmax36991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
-fmax36992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
-fmax36993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
-fmax36994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
-fmax36997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
-
--- And for round down full and subnormal results
-rounding: down
-fmax361100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
-fmax361101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
-fmax361103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
-fmax361104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
-fmax361105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
-fmax361106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
-fmax361107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
-fmax361108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
-fmax361109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
-
-rounding: ceiling
-fmax361110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
-fmax361111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
-fmax361113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
-fmax361114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
-fmax361115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
-fmax361116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
-fmax361117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
-fmax361118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
-fmax361119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
-
--- tests based on Gunnar Degnbol's edge case
-rounding: half_even
-
-fmax361300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax361310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
-fmax361311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
-fmax361312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
-fmax361313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
-fmax361314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
-fmax361315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
-fmax361316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
-fmax361317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
-fmax361318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
-fmax361319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
-fmax361320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
-fmax361321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
-fmax361322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
-fmax361323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
-fmax361324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
-fmax361325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax361339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
-
-fmax361340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
-fmax361341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
-
-fmax361349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
-fmax361350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
-fmax361351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
-fmax361352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
-fmax361353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
-fmax361354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
-fmax361355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
-fmax361356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
-fmax361357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
-fmax361358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
-fmax361359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
-fmax361360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
-fmax361361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
-fmax361362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
-fmax361363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
-fmax361364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
-fmax361365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
-fmax361379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
-fmax361380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
-fmax361381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
-fmax361382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
-fmax361395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
-fmax361396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
-
--- More GD edge cases, where difference between the unadjusted
--- exponents is larger than the maximum precision and one side is 0
-fmax361420 fma 1 0 1.123456789012345 -> 1.123456789012345
-fmax361421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
-fmax361422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
-fmax361423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
-fmax361424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
-fmax361425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
-fmax361426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
-fmax361427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
-fmax361428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
-fmax361429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
-fmax361430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
-fmax361431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
-fmax361432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
-fmax361433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
-fmax361434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
-fmax361435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
-fmax361436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
-fmax361437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
-fmax361438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
-fmax361439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
-
--- same, reversed 0
-fmax361440 fma 1 1.123456789012345 0 -> 1.123456789012345
-fmax361441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
-fmax361442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
-fmax361443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
-fmax361444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
-fmax361445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
-fmax361446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
-fmax361447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
-fmax361448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
-fmax361449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
-fmax361450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
-fmax361451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
-fmax361452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
-fmax361453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
-fmax361454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
-fmax361455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
-fmax361456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
-fmax361457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
-fmax361458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
-fmax361459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
-
--- same, Es on the 0
-fmax361460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
-fmax361461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
-fmax361462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
-fmax361463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
-fmax361464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
-fmax361465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
-fmax361466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
-fmax361467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
-fmax361468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
-fmax361469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
-fmax361470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
-fmax361471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
-fmax361472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
-fmax361473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
-fmax361474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
-fmax361475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
--- next four flag Rounded because the 0 extends the result
-fmax361476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
-fmax361477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
-fmax361478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
-fmax361479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
-
--- sum of two opposite-sign operands is exactly 0 and floor => -0
-rounding: half_up
--- exact zeros from zeros
-fmax361500 fma 1 0 0E-19 -> 0E-19
-fmax361501 fma 1 -0 0E-19 -> 0E-19
-fmax361502 fma 1 0 -0E-19 -> 0E-19
-fmax361503 fma 1 -0 -0E-19 -> -0E-19
-fmax361504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_down
--- exact zeros from zeros
-fmax361520 fma 1 0 0E-19 -> 0E-19
-fmax361521 fma 1 -0 0E-19 -> 0E-19
-fmax361522 fma 1 0 -0E-19 -> 0E-19
-fmax361523 fma 1 -0 -0E-19 -> -0E-19
-fmax361524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: half_even
--- exact zeros from zeros
-fmax361540 fma 1 0 0E-19 -> 0E-19
-fmax361541 fma 1 -0 0E-19 -> 0E-19
-fmax361542 fma 1 0 -0E-19 -> 0E-19
-fmax361543 fma 1 -0 -0E-19 -> -0E-19
-fmax361544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: up
--- exact zeros from zeros
-fmax361560 fma 1 0 0E-19 -> 0E-19
-fmax361561 fma 1 -0 0E-19 -> 0E-19
-fmax361562 fma 1 0 -0E-19 -> 0E-19
-fmax361563 fma 1 -0 -0E-19 -> -0E-19
-fmax361564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax361574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax361575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
-rounding: down
--- exact zeros from zeros
-fmax361580 fma 1 0 0E-19 -> 0E-19
-fmax361581 fma 1 -0 0E-19 -> 0E-19
-fmax361582 fma 1 0 -0E-19 -> 0E-19
-fmax361583 fma 1 -0 -0E-19 -> -0E-19
-fmax361584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
-rounding: ceiling
--- exact zeros from zeros
-fmax361600 fma 1 0 0E-19 -> 0E-19
-fmax361601 fma 1 -0 0E-19 -> 0E-19
-fmax361602 fma 1 0 -0E-19 -> 0E-19
-fmax361603 fma 1 -0 -0E-19 -> -0E-19
-fmax361604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
-fmax361606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
-fmax361607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
--- some exact zeros from non-zeros
-fmax361615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
-fmax361616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
-fmax361617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
-fmax361618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
-
--- and the extra-special ugly case; unusual minuses marked by -- *
-rounding: floor
--- exact zeros from zeros
-fmax361620 fma 1 0 0E-19 -> 0E-19
-fmax361621 fma 1 -0 0E-19 -> -0E-19 -- *
-fmax361622 fma 1 0 -0E-19 -> -0E-19 -- *
-fmax361623 fma 1 -0 -0E-19 -> -0E-19
-fmax361624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
-fmax361625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
-fmax361626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
-fmax361627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
--- inexact zeros
-fmax361631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
-fmax361634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
--- some exact zeros from non-zeros
-fmax361635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
-fmax361636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
-fmax361637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
-fmax361638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
-
--- Examples from SQL proposal (Krishna Kulkarni)
-fmax361701 fma 1 130E-2 120E-2 -> 2.50
-fmax361702 fma 1 130E-2 12E-1 -> 2.50
-fmax361703 fma 1 130E-2 1E0 -> 2.30
-fmax361704 fma 1 1E2 1E4 -> 1.01E+4
-fmax361705 subtract 130E-2 120E-2 -> 0.10
-fmax361706 subtract 130E-2 12E-1 -> 0.10
-fmax361707 subtract 130E-2 1E0 -> 0.30
-fmax361708 subtract 1E2 1E4 -> -9.9E+3
-
--- Gappy coefficients; check residue handling even with full coefficient gap
-rounding: half_even
-
-fmax362001 fma 1 1234567890123456 1 -> 1234567890123457
-fmax362002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
-fmax362003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
-fmax362004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
-fmax362005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
-fmax362006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
-fmax362007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
-fmax362008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
-fmax362009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
-fmax362010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
-fmax362011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
-fmax362012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
-fmax362013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
-fmax362014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
-fmax362015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
-fmax362016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
-fmax362017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
-fmax362018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
-fmax362019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
-fmax362020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
-fmax362021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
-
--- widening second argument at gap
-fmax362030 fma 1 12345678 1 -> 12345679
-fmax362031 fma 1 12345678 0.1 -> 12345678.1
-fmax362032 fma 1 12345678 0.12 -> 12345678.12
-fmax362033 fma 1 12345678 0.123 -> 12345678.123
-fmax362034 fma 1 12345678 0.1234 -> 12345678.1234
-fmax362035 fma 1 12345678 0.12345 -> 12345678.12345
-fmax362036 fma 1 12345678 0.123456 -> 12345678.123456
-fmax362037 fma 1 12345678 0.1234567 -> 12345678.1234567
-fmax362038 fma 1 12345678 0.12345678 -> 12345678.12345678
-fmax362039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
-fmax362040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
-fmax362041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
-fmax362042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
-fmax362043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
-fmax362044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
-fmax362045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
-fmax362046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
-fmax362047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
-fmax362048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
-fmax362049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
--- 90123456
-rounding: half_even
-fmax362050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
-fmax362051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
-fmax362052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
-fmax362053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
-fmax362054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
-fmax362055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
-fmax362056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
-fmax362057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
-fmax362060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
-fmax362061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
-fmax362062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
-fmax362063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
-fmax362064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
-fmax362065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
-fmax362066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
-fmax362067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
--- far-out residues (full coefficient gap is 16+15 digits)
-rounding: up
-fmax362070 fma 1 12345678 1E-8 -> 12345678.00000001
-fmax362071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
-fmax362072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
-fmax362073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
-fmax362074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
-fmax362075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
-fmax362076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
-fmax362077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
-fmax362078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
-fmax362079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
-fmax362080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
-fmax362081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
-fmax362082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
-fmax362083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
-fmax362084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
-fmax362085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
-fmax362086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
-fmax362087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
-fmax362088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
-fmax362089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
-
--- payload decapitate x3
-precision: 5
-fmax363000 fma 1 1 sNaN1234567890 -> NaN67890 Invalid_operation
-fmax363001 fma 1 -sNaN1234512345 1 -> -NaN12345 Invalid_operation
-fmax363002 fma sNaN1234554321 1 1 -> NaN54321 Invalid_operation
-
--- Null tests
-fmax39990 fma 1 10 # -> NaN Invalid_operation
-fmax39991 fma 1 # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- fma.decTest -- decimal fused multiply add --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- These tests comprese three parts:
+-- 1. Sanity checks and other three-operand tests (especially those
+-- where the fused operation makes a difference)
+-- 2. Multiply tests (third operand is neutral zero [0E+emax])
+-- 3. Addition tests (first operand is 1)
+-- The multiply and addition tests are extensive because FMA may have
+-- its own dedicated multiplication or addition routine(s), and they
+-- also inherently check the left-to-right properties.
+
+-- Sanity checks
+fmax0001 fma 1 1 1 -> 2
+fmax0002 fma 1 1 2 -> 3
+fmax0003 fma 2 2 3 -> 7
+fmax0004 fma 9 9 9 -> 90
+fmax0005 fma -1 1 1 -> 0
+fmax0006 fma -1 1 2 -> 1
+fmax0007 fma -2 2 3 -> -1
+fmax0008 fma -9 9 9 -> -72
+fmax0011 fma 1 -1 1 -> 0
+fmax0012 fma 1 -1 2 -> 1
+fmax0013 fma 2 -2 3 -> -1
+fmax0014 fma 9 -9 9 -> -72
+fmax0015 fma 1 1 -1 -> 0
+fmax0016 fma 1 1 -2 -> -1
+fmax0017 fma 2 2 -3 -> 1
+fmax0018 fma 9 9 -9 -> 72
+fmax0019 fma 3 5 7 -> 22
+fmax0029 fma 3 -5 7 -> -8
+
+-- non-integer exacts
+fma0100 fma 25.2 63.6 -438 -> 1164.72
+fma0101 fma 0.301 0.380 334 -> 334.114380
+fma0102 fma 49.2 -4.8 23.3 -> -212.86
+fma0103 fma 4.22 0.079 -94.6 -> -94.26662
+fma0104 fma 903 0.797 0.887 -> 720.578
+fma0105 fma 6.13 -161 65.9 -> -921.03
+fma0106 fma 28.2 727 5.45 -> 20506.85
+fma0107 fma 4 605 688 -> 3108
+fma0108 fma 93.3 0.19 0.226 -> 17.953
+fma0109 fma 0.169 -341 5.61 -> -52.019
+fma0110 fma -72.2 30 -51.2 -> -2217.2
+fma0111 fma -0.409 13 20.4 -> 15.083
+fma0112 fma 317 77.0 19.0 -> 24428.0
+fma0113 fma 47 6.58 1.62 -> 310.88
+fma0114 fma 1.36 0.984 0.493 -> 1.83124
+fma0115 fma 72.7 274 1.56 -> 19921.36
+fma0116 fma 335 847 83 -> 283828
+fma0117 fma 666 0.247 25.4 -> 189.902
+fma0118 fma -3.87 3.06 78.0 -> 66.1578
+fma0119 fma 0.742 192 35.6 -> 178.064
+fma0120 fma -91.6 5.29 0.153 -> -484.411
+
+-- cases where result is different from separate multiply + add; each
+-- is preceded by the result of unfused multiply and add
+-- [this is about 20% of all similar cases in general]
+-- 888565290 1557.96930 -86087.7578 -> 1.38435735E+12
+fma0201 fma 888565290 1557.96930 -86087.7578 -> 1.38435736E+12 Inexact Rounded
+-- -85519342.9 735155419 42010431 -> -6.28700084E+16
+fma0205 fma -85519342.9 735155419 42010431 -> -6.28700083E+16 Inexact Rounded
+-- -98025.5 -294603.472 10414348.2 -> 2.88890669E+10
+fma0208 fma -98025.5 -294603.472 10414348.2 -> 2.88890670E+10 Inexact Rounded
+-- 5967627.39 83526540.6 498494.810 -> 4.98455271E+14
+fma0211 fma 5967627.39 83526540.6 498494.810 -> 4.98455272E+14 Inexact Rounded
+-- 3456.9433 874.39518 197866.615 -> 3220601.18
+fma0216 fma 3456.9433 874.39518 197866.615 -> 3220601.17 Inexact Rounded
+-- 62769.8287 2096.98927 48.420317 -> 131627705
+fma0218 fma 62769.8287 2096.98927 48.420317 -> 131627706 Inexact Rounded
+-- -68.81500 59961113.9 -8988862 -> -4.13521291E+9
+fma0219 fma -68.81500 59961113.9 -8988862 -> -4.13521292E+9 Inexact Rounded
+-- 2126341.02 63491.5152 302427455 -> 1.35307040E+11
+fma0226 fma 2126341.02 63491.5152 302427455 -> 1.35307041E+11 Inexact Rounded
+
+
+-- Infinite combinations
+fmax0800 fma Inf Inf Inf -> Infinity
+fmax0801 fma Inf Inf -Inf -> NaN Invalid_operation
+fmax0802 fma Inf -Inf Inf -> NaN Invalid_operation
+fmax0803 fma Inf -Inf -Inf -> -Infinity
+fmax0804 fma -Inf Inf Inf -> NaN Invalid_operation
+fmax0805 fma -Inf Inf -Inf -> -Infinity
+fmax0806 fma -Inf -Inf Inf -> Infinity
+fmax0807 fma -Inf -Inf -Inf -> NaN Invalid_operation
+fmax0808 fma -Inf 0 1 -> NaN Invalid_operation
+fmax0809 fma -Inf 0 NaN -> NaN Invalid_operation
+
+-- Triple NaN propagation
+fmax0900 fma NaN2 NaN3 NaN5 -> NaN2
+fmax0901 fma 0 NaN3 NaN5 -> NaN3
+fmax0902 fma 0 0 NaN5 -> NaN5
+-- first sNaN wins (consider qNaN from earlier sNaN being
+-- overridden by an sNaN in third operand)
+fmax0903 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+fmax0904 fma 0 sNaN2 sNaN3 -> NaN2 Invalid_operation
+fmax0905 fma 0 0 sNaN3 -> NaN3 Invalid_operation
+fmax0906 fma sNaN1 sNaN2 sNaN3 -> NaN1 Invalid_operation
+fmax0907 fma NaN7 sNaN2 sNaN3 -> NaN2 Invalid_operation
+fmax0908 fma NaN7 NaN5 sNaN3 -> NaN3 Invalid_operation
+
+-- MULTIPLICATION TESTS ------------------------------------------------
+-- sanity checks (as base, above)
+fmax2000 fma 2 2 0E+999999 -> 4
+fmax2001 fma 2 3 0E+999999 -> 6
+fmax2002 fma 5 1 0E+999999 -> 5
+fmax2003 fma 5 2 0E+999999 -> 10
+fmax2004 fma 1.20 2 0E+999999 -> 2.40
+fmax2005 fma 1.20 0 0E+999999 -> 0.00
+fmax2006 fma 1.20 -2 0E+999999 -> -2.40
+fmax2007 fma -1.20 2 0E+999999 -> -2.40
+fmax2008 fma -1.20 0 0E+999999 -> 0.00
+fmax2009 fma -1.20 -2 0E+999999 -> 2.40
+fmax2010 fma 5.09 7.1 0E+999999 -> 36.139
+fmax2011 fma 2.5 4 0E+999999 -> 10.0
+fmax2012 fma 2.50 4 0E+999999 -> 10.00
+fmax2013 fma 1.23456789 1.00000000 0E+999999 -> 1.23456789 Rounded
+fmax2014 fma 9.999999999 9.999999999 0E+999999 -> 100.000000 Inexact Rounded
+fmax2015 fma 2.50 4 0E+999999 -> 10.00
+precision: 6
+fmax2016 fma 2.50 4 0E+999999 -> 10.00
+fmax2017 fma 9.999999 9.999999 0E+999999 -> 100.000 Inexact Rounded
+fmax2018 fma 9.999999 -9.999999 0E+999999 -> -100.000 Inexact Rounded
+fmax2019 fma -9.999999 9.999999 0E+999999 -> -100.000 Inexact Rounded
+fmax2020 fma -9.999999 -9.999999 0E+999999 -> 100.000 Inexact Rounded
+
+-- 1999.12.21: next one is a edge case if intermediate longs are used
+precision: 15
+fmax2059 fma 999999999999 9765625 0E+999999 -> 9.76562499999023E+18 Inexact Rounded
+precision: 30
+fmax2160 fma 999999999999 9765625 0E+999999 -> 9765624999990234375
+precision: 9
+-----
+
+-- zeros, etc.
+fmax2021 fma 0 0 0E+999999 -> 0
+fmax2022 fma 0 -0 0E+999999 -> 0
+fmax2023 fma -0 0 0E+999999 -> 0
+fmax2024 fma -0 -0 0E+999999 -> 0
+fmax2025 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2026 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2027 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2028 fma -0.0 -0.0 0E+999999 -> 0.00
+fmax2030 fma 5.00 1E-3 0E+999999 -> 0.00500
+fmax2031 fma 00.00 0.000 0E+999999 -> 0.00000
+fmax2032 fma 00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2033 fma 0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2034 fma -5.00 1E-3 0E+999999 -> -0.00500
+fmax2035 fma -00.00 0.000 0E+999999 -> 0.00000
+fmax2036 fma -00.00 0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2037 fma -0E-3 00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2038 fma 5.00 -1E-3 0E+999999 -> -0.00500
+fmax2039 fma 00.00 -0.000 0E+999999 -> 0.00000
+fmax2040 fma 00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2041 fma 0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
+fmax2042 fma -5.00 -1E-3 0E+999999 -> 0.00500
+fmax2043 fma -00.00 -0.000 0E+999999 -> 0.00000
+fmax2044 fma -00.00 -0E-3 0E+999999 -> 0.00000 -- rhs is 0
+fmax2045 fma -0E-3 -00.00 0E+999999 -> 0.00000 -- lhs is 0
+
+-- examples from decarith multiply
+fmax2050 fma 1.20 3 0E+999999 -> 3.60
+fmax2051 fma 7 3 0E+999999 -> 21
+fmax2052 fma 0.9 0.8 0E+999999 -> 0.72
+fmax2053 fma 0.9 -0 0E+999999 -> 0.0
+fmax2054 fma 654321 654321 0E+999999 -> 4.28135971E+11 Inexact Rounded
+
+fmax2060 fma 123.45 1e7 0E+999999 -> 1.2345E+9
+fmax2061 fma 123.45 1e8 0E+999999 -> 1.2345E+10
+fmax2062 fma 123.45 1e+9 0E+999999 -> 1.2345E+11
+fmax2063 fma 123.45 1e10 0E+999999 -> 1.2345E+12
+fmax2064 fma 123.45 1e11 0E+999999 -> 1.2345E+13
+fmax2065 fma 123.45 1e12 0E+999999 -> 1.2345E+14
+fmax2066 fma 123.45 1e13 0E+999999 -> 1.2345E+15
+
+
+-- test some intermediate lengths
+precision: 9
+fmax2080 fma 0.1 123456789 0E+999999 -> 12345678.9
+fmax2081 fma 0.1 1234567891 0E+999999 -> 123456789 Inexact Rounded
+fmax2082 fma 0.1 12345678912 0E+999999 -> 1.23456789E+9 Inexact Rounded
+fmax2083 fma 0.1 12345678912345 0E+999999 -> 1.23456789E+12 Inexact Rounded
+fmax2084 fma 0.1 123456789 0E+999999 -> 12345678.9
+precision: 8
+fmax2085 fma 0.1 12345678912 0E+999999 -> 1.2345679E+9 Inexact Rounded
+fmax2086 fma 0.1 12345678912345 0E+999999 -> 1.2345679E+12 Inexact Rounded
+precision: 7
+fmax2087 fma 0.1 12345678912 0E+999999 -> 1.234568E+9 Inexact Rounded
+fmax2088 fma 0.1 12345678912345 0E+999999 -> 1.234568E+12 Inexact Rounded
+
+precision: 9
+fmax2090 fma 123456789 0.1 0E+999999 -> 12345678.9
+fmax2091 fma 1234567891 0.1 0E+999999 -> 123456789 Inexact Rounded
+fmax2092 fma 12345678912 0.1 0E+999999 -> 1.23456789E+9 Inexact Rounded
+fmax2093 fma 12345678912345 0.1 0E+999999 -> 1.23456789E+12 Inexact Rounded
+fmax2094 fma 123456789 0.1 0E+999999 -> 12345678.9
+precision: 8
+fmax2095 fma 12345678912 0.1 0E+999999 -> 1.2345679E+9 Inexact Rounded
+fmax2096 fma 12345678912345 0.1 0E+999999 -> 1.2345679E+12 Inexact Rounded
+precision: 7
+fmax2097 fma 12345678912 0.1 0E+999999 -> 1.234568E+9 Inexact Rounded
+fmax2098 fma 12345678912345 0.1 0E+999999 -> 1.234568E+12 Inexact Rounded
+
+-- test some more edge cases and carries
+maxexponent: 9999
+minexponent: -9999
+precision: 33
+fmax2101 fma 9 9 0E+999999 -> 81
+fmax2102 fma 9 90 0E+999999 -> 810
+fmax2103 fma 9 900 0E+999999 -> 8100
+fmax2104 fma 9 9000 0E+999999 -> 81000
+fmax2105 fma 9 90000 0E+999999 -> 810000
+fmax2106 fma 9 900000 0E+999999 -> 8100000
+fmax2107 fma 9 9000000 0E+999999 -> 81000000
+fmax2108 fma 9 90000000 0E+999999 -> 810000000
+fmax2109 fma 9 900000000 0E+999999 -> 8100000000
+fmax2110 fma 9 9000000000 0E+999999 -> 81000000000
+fmax2111 fma 9 90000000000 0E+999999 -> 810000000000
+fmax2112 fma 9 900000000000 0E+999999 -> 8100000000000
+fmax2113 fma 9 9000000000000 0E+999999 -> 81000000000000
+fmax2114 fma 9 90000000000000 0E+999999 -> 810000000000000
+fmax2115 fma 9 900000000000000 0E+999999 -> 8100000000000000
+fmax2116 fma 9 9000000000000000 0E+999999 -> 81000000000000000
+fmax2117 fma 9 90000000000000000 0E+999999 -> 810000000000000000
+fmax2118 fma 9 900000000000000000 0E+999999 -> 8100000000000000000
+fmax2119 fma 9 9000000000000000000 0E+999999 -> 81000000000000000000
+fmax2120 fma 9 90000000000000000000 0E+999999 -> 810000000000000000000
+fmax2121 fma 9 900000000000000000000 0E+999999 -> 8100000000000000000000
+fmax2122 fma 9 9000000000000000000000 0E+999999 -> 81000000000000000000000
+fmax2123 fma 9 90000000000000000000000 0E+999999 -> 810000000000000000000000
+-- test some more edge cases without carries
+fmax2131 fma 3 3 0E+999999 -> 9
+fmax2132 fma 3 30 0E+999999 -> 90
+fmax2133 fma 3 300 0E+999999 -> 900
+fmax2134 fma 3 3000 0E+999999 -> 9000
+fmax2135 fma 3 30000 0E+999999 -> 90000
+fmax2136 fma 3 300000 0E+999999 -> 900000
+fmax2137 fma 3 3000000 0E+999999 -> 9000000
+fmax2138 fma 3 30000000 0E+999999 -> 90000000
+fmax2139 fma 3 300000000 0E+999999 -> 900000000
+fmax2140 fma 3 3000000000 0E+999999 -> 9000000000
+fmax2141 fma 3 30000000000 0E+999999 -> 90000000000
+fmax2142 fma 3 300000000000 0E+999999 -> 900000000000
+fmax2143 fma 3 3000000000000 0E+999999 -> 9000000000000
+fmax2144 fma 3 30000000000000 0E+999999 -> 90000000000000
+fmax2145 fma 3 300000000000000 0E+999999 -> 900000000000000
+fmax2146 fma 3 3000000000000000 0E+999999 -> 9000000000000000
+fmax2147 fma 3 30000000000000000 0E+999999 -> 90000000000000000
+fmax2148 fma 3 300000000000000000 0E+999999 -> 900000000000000000
+fmax2149 fma 3 3000000000000000000 0E+999999 -> 9000000000000000000
+fmax2150 fma 3 30000000000000000000 0E+999999 -> 90000000000000000000
+fmax2151 fma 3 300000000000000000000 0E+999999 -> 900000000000000000000
+fmax2152 fma 3 3000000000000000000000 0E+999999 -> 9000000000000000000000
+fmax2153 fma 3 30000000000000000000000 0E+999999 -> 90000000000000000000000
+
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+-- test some cases that are close to exponent overflow/underflow
+fmax2170 fma 1 9e999999 0E+999999 -> 9E+999999
+fmax2171 fma 1 9.9e999999 0E+999999 -> 9.9E+999999
+fmax2172 fma 1 9.99e999999 0E+999999 -> 9.99E+999999
+fmax2173 fma 9e999999 1 0E+999999 -> 9E+999999
+fmax2174 fma 9.9e999999 1 0E+999999 -> 9.9E+999999
+fmax2176 fma 9.99e999999 1 0E+999999 -> 9.99E+999999
+fmax2177 fma 1 9.99999e999999 0E+999999 -> 9.99999E+999999
+fmax2178 fma 9.99999e999999 1 0E+999999 -> 9.99999E+999999
+
+fmax2180 fma 0.1 9e-999998 0E+999999 -> 9E-999999
+fmax2181 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
+fmax2182 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
+
+fmax2183 fma 0.1 9e-999998 0E+999999 -> 9E-999999
+fmax2184 fma 0.1 99e-999998 0E+999999 -> 9.9E-999998
+fmax2185 fma 0.1 999e-999998 0E+999999 -> 9.99E-999997
+fmax2186 fma 0.1 999e-999997 0E+999999 -> 9.99E-999996
+fmax2187 fma 0.1 9999e-999997 0E+999999 -> 9.999E-999995
+fmax2188 fma 0.1 99999e-999997 0E+999999 -> 9.9999E-999994
+
+fmax2190 fma 1 9e-999998 0E+999999 -> 9E-999998
+fmax2191 fma 1 99e-999998 0E+999999 -> 9.9E-999997
+fmax2192 fma 1 999e-999998 0E+999999 -> 9.99E-999996
+fmax2193 fma 9e-999998 1 0E+999999 -> 9E-999998
+fmax2194 fma 99e-999998 1 0E+999999 -> 9.9E-999997
+fmax2195 fma 999e-999998 1 0E+999999 -> 9.99E-999996
+
+-- long operand triangle
+precision: 33
+fmax2246 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511992830 Inexact Rounded
+precision: 32
+fmax2247 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199283 Inexact Rounded
+precision: 31
+fmax2248 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165119928 Inexact Rounded
+precision: 30
+fmax2249 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916511993 Inexact Rounded
+precision: 29
+fmax2250 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651199 Inexact Rounded
+precision: 28
+fmax2251 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165120 Inexact Rounded
+precision: 27
+fmax2252 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671916512 Inexact Rounded
+precision: 26
+fmax2253 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967191651 Inexact Rounded
+precision: 25
+fmax2254 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719165 Inexact Rounded
+precision: 24
+fmax2255 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369671917 Inexact Rounded
+precision: 23
+fmax2256 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967192 Inexact Rounded
+precision: 22
+fmax2257 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933696719 Inexact Rounded
+precision: 21
+fmax2258 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193369672 Inexact Rounded
+precision: 20
+fmax2259 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119336967 Inexact Rounded
+precision: 19
+fmax2260 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011933697 Inexact Rounded
+precision: 18
+fmax2261 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193370 Inexact Rounded
+precision: 17
+fmax2262 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119337 Inexact Rounded
+precision: 16
+fmax2263 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908011934 Inexact Rounded
+precision: 15
+fmax2264 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801193 Inexact Rounded
+precision: 14
+fmax2265 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080119 Inexact Rounded
+precision: 13
+fmax2266 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908012 Inexact Rounded
+precision: 12
+fmax2267 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.290801 Inexact Rounded
+precision: 11
+fmax2268 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29080 Inexact Rounded
+precision: 10
+fmax2269 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.2908 Inexact Rounded
+precision: 9
+fmax2270 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.291 Inexact Rounded
+precision: 8
+fmax2271 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.29 Inexact Rounded
+precision: 7
+fmax2272 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433.3 Inexact Rounded
+precision: 6
+fmax2273 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 145433 Inexact Rounded
+precision: 5
+fmax2274 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.4543E+5 Inexact Rounded
+precision: 4
+fmax2275 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.454E+5 Inexact Rounded
+precision: 3
+fmax2276 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.45E+5 Inexact Rounded
+precision: 2
+fmax2277 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1.5E+5 Inexact Rounded
+precision: 1
+fmax2278 fma 30269.587755640502150977251770554 4.8046009735990873395936309640543 0E+999999 -> 1E+5 Inexact Rounded
+
+-- test some edge cases with exact rounding
+maxexponent: 9999
+minexponent: -9999
+precision: 9
+fmax2301 fma 9 9 0E+999999 -> 81
+fmax2302 fma 9 90 0E+999999 -> 810
+fmax2303 fma 9 900 0E+999999 -> 8100
+fmax2304 fma 9 9000 0E+999999 -> 81000
+fmax2305 fma 9 90000 0E+999999 -> 810000
+fmax2306 fma 9 900000 0E+999999 -> 8100000
+fmax2307 fma 9 9000000 0E+999999 -> 81000000
+fmax2308 fma 9 90000000 0E+999999 -> 810000000
+fmax2309 fma 9 900000000 0E+999999 -> 8.10000000E+9 Rounded
+fmax2310 fma 9 9000000000 0E+999999 -> 8.10000000E+10 Rounded
+fmax2311 fma 9 90000000000 0E+999999 -> 8.10000000E+11 Rounded
+fmax2312 fma 9 900000000000 0E+999999 -> 8.10000000E+12 Rounded
+fmax2313 fma 9 9000000000000 0E+999999 -> 8.10000000E+13 Rounded
+fmax2314 fma 9 90000000000000 0E+999999 -> 8.10000000E+14 Rounded
+fmax2315 fma 9 900000000000000 0E+999999 -> 8.10000000E+15 Rounded
+fmax2316 fma 9 9000000000000000 0E+999999 -> 8.10000000E+16 Rounded
+fmax2317 fma 9 90000000000000000 0E+999999 -> 8.10000000E+17 Rounded
+fmax2318 fma 9 900000000000000000 0E+999999 -> 8.10000000E+18 Rounded
+fmax2319 fma 9 9000000000000000000 0E+999999 -> 8.10000000E+19 Rounded
+fmax2320 fma 9 90000000000000000000 0E+999999 -> 8.10000000E+20 Rounded
+fmax2321 fma 9 900000000000000000000 0E+999999 -> 8.10000000E+21 Rounded
+fmax2322 fma 9 9000000000000000000000 0E+999999 -> 8.10000000E+22 Rounded
+fmax2323 fma 9 90000000000000000000000 0E+999999 -> 8.10000000E+23 Rounded
+
+-- fastpath breakers
+precision: 29
+fmax2330 fma 1.491824697641270317824852952837224 1.105170918075647624811707826490246514675628614562883537345747603 0E+999999 -> 1.6487212707001281468486507878 Inexact Rounded
+precision: 55
+fmax2331 fma 0.8958341352965282506768545828765117803873717284891040428 0.8958341352965282506768545828765117803873717284891040428 0E+999999 -> 0.8025187979624784829842553829934069955890983696752228299 Inexact Rounded
+
+
+-- tryzeros cases
+precision: 7
+rounding: half_up
+maxExponent: 92
+minexponent: -92
+fmax2504 fma 0E-60 1000E-60 0E+999999 -> 0E-98 Clamped
+fmax2505 fma 100E+60 0E+60 0E+999999 -> 0E+92 Clamped
+
+-- mixed with zeros
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+fmax2541 fma 0 -1 0E+999999 -> 0
+fmax2542 fma -0 -1 0E+999999 -> 0
+fmax2543 fma 0 1 0E+999999 -> 0
+fmax2544 fma -0 1 0E+999999 -> 0
+fmax2545 fma -1 0 0E+999999 -> 0
+fmax2546 fma -1 -0 0E+999999 -> 0
+fmax2547 fma 1 0 0E+999999 -> 0
+fmax2548 fma 1 -0 0E+999999 -> 0
+
+fmax2551 fma 0.0 -1 0E+999999 -> 0.0
+fmax2552 fma -0.0 -1 0E+999999 -> 0.0
+fmax2553 fma 0.0 1 0E+999999 -> 0.0
+fmax2554 fma -0.0 1 0E+999999 -> 0.0
+fmax2555 fma -1.0 0 0E+999999 -> 0.0
+fmax2556 fma -1.0 -0 0E+999999 -> 0.0
+fmax2557 fma 1.0 0 0E+999999 -> 0.0
+fmax2558 fma 1.0 -0 0E+999999 -> 0.0
+
+fmax2561 fma 0 -1.0 0E+999999 -> 0.0
+fmax2562 fma -0 -1.0 0E+999999 -> 0.0
+fmax2563 fma 0 1.0 0E+999999 -> 0.0
+fmax2564 fma -0 1.0 0E+999999 -> 0.0
+fmax2565 fma -1 0.0 0E+999999 -> 0.0
+fmax2566 fma -1 -0.0 0E+999999 -> 0.0
+fmax2567 fma 1 0.0 0E+999999 -> 0.0
+fmax2568 fma 1 -0.0 0E+999999 -> 0.0
+
+fmax2571 fma 0.0 -1.0 0E+999999 -> 0.00
+fmax2572 fma -0.0 -1.0 0E+999999 -> 0.00
+fmax2573 fma 0.0 1.0 0E+999999 -> 0.00
+fmax2574 fma -0.0 1.0 0E+999999 -> 0.00
+fmax2575 fma -1.0 0.0 0E+999999 -> 0.00
+fmax2576 fma -1.0 -0.0 0E+999999 -> 0.00
+fmax2577 fma 1.0 0.0 0E+999999 -> 0.00
+fmax2578 fma 1.0 -0.0 0E+999999 -> 0.00
+
+
+-- Specials
+fmax2580 fma Inf -Inf 0E+999999 -> -Infinity
+fmax2581 fma Inf -1000 0E+999999 -> -Infinity
+fmax2582 fma Inf -1 0E+999999 -> -Infinity
+fmax2583 fma Inf -0 0E+999999 -> NaN Invalid_operation
+fmax2584 fma Inf 0 0E+999999 -> NaN Invalid_operation
+fmax2585 fma Inf 1 0E+999999 -> Infinity
+fmax2586 fma Inf 1000 0E+999999 -> Infinity
+fmax2587 fma Inf Inf 0E+999999 -> Infinity
+fmax2588 fma -1000 Inf 0E+999999 -> -Infinity
+fmax2589 fma -Inf Inf 0E+999999 -> -Infinity
+fmax2590 fma -1 Inf 0E+999999 -> -Infinity
+fmax2591 fma -0 Inf 0E+999999 -> NaN Invalid_operation
+fmax2592 fma 0 Inf 0E+999999 -> NaN Invalid_operation
+fmax2593 fma 1 Inf 0E+999999 -> Infinity
+fmax2594 fma 1000 Inf 0E+999999 -> Infinity
+fmax2595 fma Inf Inf 0E+999999 -> Infinity
+
+fmax2600 fma -Inf -Inf 0E+999999 -> Infinity
+fmax2601 fma -Inf -1000 0E+999999 -> Infinity
+fmax2602 fma -Inf -1 0E+999999 -> Infinity
+fmax2603 fma -Inf -0 0E+999999 -> NaN Invalid_operation
+fmax2604 fma -Inf 0 0E+999999 -> NaN Invalid_operation
+fmax2605 fma -Inf 1 0E+999999 -> -Infinity
+fmax2606 fma -Inf 1000 0E+999999 -> -Infinity
+fmax2607 fma -Inf Inf 0E+999999 -> -Infinity
+fmax2608 fma -1000 Inf 0E+999999 -> -Infinity
+fmax2609 fma -Inf -Inf 0E+999999 -> Infinity
+fmax2610 fma -1 -Inf 0E+999999 -> Infinity
+fmax2611 fma -0 -Inf 0E+999999 -> NaN Invalid_operation
+fmax2612 fma 0 -Inf 0E+999999 -> NaN Invalid_operation
+fmax2613 fma 1 -Inf 0E+999999 -> -Infinity
+fmax2614 fma 1000 -Inf 0E+999999 -> -Infinity
+fmax2615 fma Inf -Inf 0E+999999 -> -Infinity
+
+fmax2621 fma NaN -Inf 0E+999999 -> NaN
+fmax2622 fma NaN -1000 0E+999999 -> NaN
+fmax2623 fma NaN -1 0E+999999 -> NaN
+fmax2624 fma NaN -0 0E+999999 -> NaN
+fmax2625 fma NaN 0 0E+999999 -> NaN
+fmax2626 fma NaN 1 0E+999999 -> NaN
+fmax2627 fma NaN 1000 0E+999999 -> NaN
+fmax2628 fma NaN Inf 0E+999999 -> NaN
+fmax2629 fma NaN NaN 0E+999999 -> NaN
+fmax2630 fma -Inf NaN 0E+999999 -> NaN
+fmax2631 fma -1000 NaN 0E+999999 -> NaN
+fmax2632 fma -1 NaN 0E+999999 -> NaN
+fmax2633 fma -0 NaN 0E+999999 -> NaN
+fmax2634 fma 0 NaN 0E+999999 -> NaN
+fmax2635 fma 1 NaN 0E+999999 -> NaN
+fmax2636 fma 1000 NaN 0E+999999 -> NaN
+fmax2637 fma Inf NaN 0E+999999 -> NaN
+
+fmax2641 fma sNaN -Inf 0E+999999 -> NaN Invalid_operation
+fmax2642 fma sNaN -1000 0E+999999 -> NaN Invalid_operation
+fmax2643 fma sNaN -1 0E+999999 -> NaN Invalid_operation
+fmax2644 fma sNaN -0 0E+999999 -> NaN Invalid_operation
+fmax2645 fma sNaN 0 0E+999999 -> NaN Invalid_operation
+fmax2646 fma sNaN 1 0E+999999 -> NaN Invalid_operation
+fmax2647 fma sNaN 1000 0E+999999 -> NaN Invalid_operation
+fmax2648 fma sNaN NaN 0E+999999 -> NaN Invalid_operation
+fmax2649 fma sNaN sNaN 0E+999999 -> NaN Invalid_operation
+fmax2650 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
+fmax2651 fma -Inf sNaN 0E+999999 -> NaN Invalid_operation
+fmax2652 fma -1000 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2653 fma -1 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2654 fma -0 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2655 fma 0 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2656 fma 1 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2657 fma 1000 sNaN 0E+999999 -> NaN Invalid_operation
+fmax2658 fma Inf sNaN 0E+999999 -> NaN Invalid_operation
+fmax2659 fma NaN sNaN 0E+999999 -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax2661 fma NaN9 -Inf 0E+999999 -> NaN9
+fmax2662 fma NaN8 999 0E+999999 -> NaN8
+fmax2663 fma NaN71 Inf 0E+999999 -> NaN71
+fmax2664 fma NaN6 NaN5 0E+999999 -> NaN6
+fmax2665 fma -Inf NaN4 0E+999999 -> NaN4
+fmax2666 fma -999 NaN33 0E+999999 -> NaN33
+fmax2667 fma Inf NaN2 0E+999999 -> NaN2
+
+fmax2671 fma sNaN99 -Inf 0E+999999 -> NaN99 Invalid_operation
+fmax2672 fma sNaN98 -11 0E+999999 -> NaN98 Invalid_operation
+fmax2673 fma sNaN97 NaN 0E+999999 -> NaN97 Invalid_operation
+fmax2674 fma sNaN16 sNaN94 0E+999999 -> NaN16 Invalid_operation
+fmax2675 fma NaN95 sNaN93 0E+999999 -> NaN93 Invalid_operation
+fmax2676 fma -Inf sNaN92 0E+999999 -> NaN92 Invalid_operation
+fmax2677 fma 088 sNaN91 0E+999999 -> NaN91 Invalid_operation
+fmax2678 fma Inf sNaN90 0E+999999 -> NaN90 Invalid_operation
+fmax2679 fma NaN sNaN89 0E+999999 -> NaN89 Invalid_operation
+
+fmax2681 fma -NaN9 -Inf 0E+999999 -> -NaN9
+fmax2682 fma -NaN8 999 0E+999999 -> -NaN8
+fmax2683 fma -NaN71 Inf 0E+999999 -> -NaN71
+fmax2684 fma -NaN6 -NaN5 0E+999999 -> -NaN6
+fmax2685 fma -Inf -NaN4 0E+999999 -> -NaN4
+fmax2686 fma -999 -NaN33 0E+999999 -> -NaN33
+fmax2687 fma Inf -NaN2 0E+999999 -> -NaN2
+
+fmax2691 fma -sNaN99 -Inf 0E+999999 -> -NaN99 Invalid_operation
+fmax2692 fma -sNaN98 -11 0E+999999 -> -NaN98 Invalid_operation
+fmax2693 fma -sNaN97 NaN 0E+999999 -> -NaN97 Invalid_operation
+fmax2694 fma -sNaN16 -sNaN94 0E+999999 -> -NaN16 Invalid_operation
+fmax2695 fma -NaN95 -sNaN93 0E+999999 -> -NaN93 Invalid_operation
+fmax2696 fma -Inf -sNaN92 0E+999999 -> -NaN92 Invalid_operation
+fmax2697 fma 088 -sNaN91 0E+999999 -> -NaN91 Invalid_operation
+fmax2698 fma Inf -sNaN90 0E+999999 -> -NaN90 Invalid_operation
+fmax2699 fma -NaN -sNaN89 0E+999999 -> -NaN89 Invalid_operation
+
+fmax2701 fma -NaN -Inf 0E+999999 -> -NaN
+fmax2702 fma -NaN 999 0E+999999 -> -NaN
+fmax2703 fma -NaN Inf 0E+999999 -> -NaN
+fmax2704 fma -NaN -NaN 0E+999999 -> -NaN
+fmax2705 fma -Inf -NaN0 0E+999999 -> -NaN
+fmax2706 fma -999 -NaN 0E+999999 -> -NaN
+fmax2707 fma Inf -NaN 0E+999999 -> -NaN
+
+fmax2711 fma -sNaN -Inf 0E+999999 -> -NaN Invalid_operation
+fmax2712 fma -sNaN -11 0E+999999 -> -NaN Invalid_operation
+fmax2713 fma -sNaN00 NaN 0E+999999 -> -NaN Invalid_operation
+fmax2714 fma -sNaN -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2715 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2716 fma -Inf -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2717 fma 088 -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2718 fma Inf -sNaN 0E+999999 -> -NaN Invalid_operation
+fmax2719 fma -NaN -sNaN 0E+999999 -> -NaN Invalid_operation
+
+-- overflow and underflow tests .. note subnormal results
+maxexponent: 999999
+minexponent: -999999
+fmax2730 fma +1.23456789012345E-0 9E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2731 fma 9E+999999 +1.23456789012345E-0 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2732 fma +0.100 9E-999999 0E+999999 -> 9.00E-1000000 Subnormal
+fmax2733 fma 9E-999999 +0.100 0E+999999 -> 9.00E-1000000 Subnormal
+fmax2735 fma -1.23456789012345E-0 9E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2736 fma 9E+999999 -1.23456789012345E-0 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2737 fma -0.100 9E-999999 0E+999999 -> -9.00E-1000000 Subnormal
+fmax2738 fma 9E-999999 -0.100 0E+999999 -> -9.00E-1000000 Subnormal
+
+-- signs
+fmax2751 fma 1e+777777 1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2752 fma 1e+777777 -1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
+fmax2753 fma -1e+777777 1e+411111 0E+999999 -> -Infinity Overflow Inexact Rounded
+fmax2754 fma -1e+777777 -1e+411111 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2755 fma 1e-777777 1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2756 fma 1e-777777 -1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2757 fma -1e-777777 1e-411111 0E+999999 -> -0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2758 fma -1e-777777 -1e-411111 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+
+-- 'subnormal' boundary (all hard underflow or overflow in base arithemtic)
+precision: 9
+fmax2760 fma 1e-600000 1e-400001 0E+999999 -> 1E-1000001 Subnormal
+fmax2761 fma 1e-600000 1e-400002 0E+999999 -> 1E-1000002 Subnormal
+fmax2762 fma 1e-600000 1e-400003 0E+999999 -> 1E-1000003 Subnormal
+fmax2763 fma 1e-600000 1e-400004 0E+999999 -> 1E-1000004 Subnormal
+fmax2764 fma 1e-600000 1e-400005 0E+999999 -> 1E-1000005 Subnormal
+fmax2765 fma 1e-600000 1e-400006 0E+999999 -> 1E-1000006 Subnormal
+fmax2766 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
+fmax2767 fma 1e-600000 1e-400008 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2768 fma 1e-600000 1e-400009 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+fmax2769 fma 1e-600000 1e-400010 0E+999999 -> 0E-1000007 Underflow Subnormal Inexact Rounded Clamped
+-- [no equivalent of 'subnormal' for overflow]
+fmax2770 fma 1e+600000 1e+400001 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2771 fma 1e+600000 1e+400002 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2772 fma 1e+600000 1e+400003 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2773 fma 1e+600000 1e+400004 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2774 fma 1e+600000 1e+400005 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2775 fma 1e+600000 1e+400006 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2776 fma 1e+600000 1e+400007 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2777 fma 1e+600000 1e+400008 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2778 fma 1e+600000 1e+400009 0E+999999 -> Infinity Overflow Inexact Rounded
+fmax2779 fma 1e+600000 1e+400010 0E+999999 -> Infinity Overflow Inexact Rounded
+
+-- 'subnormal' test edge condition at higher precisions
+precision: 99
+fmax2780 fma 1e-600000 1e-400007 0E+999999 -> 1E-1000007 Subnormal
+fmax2781 fma 1e-600000 1e-400008 0E+999999 -> 1E-1000008 Subnormal
+fmax2782 fma 1e-600000 1e-400097 0E+999999 -> 1E-1000097 Subnormal
+fmax2783 fma 1e-600000 1e-400098 0E+999999 -> 0E-1000097 Underflow Subnormal Inexact Rounded Clamped
+precision: 999
+fmax2784 fma 1e-600000 1e-400997 0E+999999 -> 1E-1000997 Subnormal
+fmax2785 fma 1e-600000 1e-400998 0E+999999 -> 0E-1000997 Underflow Subnormal Inexact Rounded Clamped
+
+-- test subnormals rounding
+precision: 5
+maxExponent: 999
+minexponent: -999
+rounding: half_even
+
+fmax2801 fma 1.0000E-999 1 0E+999999 -> 1.0000E-999
+fmax2802 fma 1.000E-999 1e-1 0E+999999 -> 1.000E-1000 Subnormal
+fmax2803 fma 1.00E-999 1e-2 0E+999999 -> 1.00E-1001 Subnormal
+fmax2804 fma 1.0E-999 1e-3 0E+999999 -> 1.0E-1002 Subnormal
+fmax2805 fma 1.0E-999 1e-4 0E+999999 -> 1E-1003 Subnormal Rounded
+fmax2806 fma 1.3E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2807 fma 1.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2808 fma 1.7E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2809 fma 2.3E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2810 fma 2.5E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2811 fma 2.7E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
+fmax2812 fma 1.49E-999 1e-4 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2813 fma 1.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2814 fma 1.51E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2815 fma 2.49E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2816 fma 2.50E-999 1e-4 0E+999999 -> 2E-1003 Underflow Subnormal Inexact Rounded
+fmax2817 fma 2.51E-999 1e-4 0E+999999 -> 3E-1003 Underflow Subnormal Inexact Rounded
+
+fmax2818 fma 1E-999 1e-4 0E+999999 -> 1E-1003 Subnormal
+fmax2819 fma 3E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2820 fma 5E-999 1e-5 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2821 fma 7E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2822 fma 9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+fmax2823 fma 9.9E-999 1e-5 0E+999999 -> 1E-1003 Underflow Subnormal Inexact Rounded
+
+fmax2824 fma 1E-999 -1e-4 0E+999999 -> -1E-1003 Subnormal
+fmax2825 fma 3E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2826 fma -5E-999 1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2827 fma 7E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2828 fma -9E-999 1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2829 fma 9.9E-999 -1e-5 0E+999999 -> -1E-1003 Underflow Subnormal Inexact Rounded
+fmax2830 fma 3.0E-999 -1e-5 0E+999999 -> -0E-1003 Underflow Subnormal Inexact Rounded Clamped
+
+fmax2831 fma 1.0E-501 1e-501 0E+999999 -> 1.0E-1002 Subnormal
+fmax2832 fma 2.0E-501 2e-501 0E+999999 -> 4.0E-1002 Subnormal
+fmax2833 fma 4.0E-501 4e-501 0E+999999 -> 1.60E-1001 Subnormal
+fmax2834 fma 10.0E-501 10e-501 0E+999999 -> 1.000E-1000 Subnormal
+fmax2835 fma 30.0E-501 30e-501 0E+999999 -> 9.000E-1000 Subnormal
+fmax2836 fma 40.0E-501 40e-501 0E+999999 -> 1.6000E-999
+
+-- squares
+fmax2840 fma 1E-502 1e-502 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2841 fma 1E-501 1e-501 0E+999999 -> 1E-1002 Subnormal
+fmax2842 fma 2E-501 2e-501 0E+999999 -> 4E-1002 Subnormal
+fmax2843 fma 4E-501 4e-501 0E+999999 -> 1.6E-1001 Subnormal
+fmax2844 fma 10E-501 10e-501 0E+999999 -> 1.00E-1000 Subnormal
+fmax2845 fma 30E-501 30e-501 0E+999999 -> 9.00E-1000 Subnormal
+fmax2846 fma 40E-501 40e-501 0E+999999 -> 1.600E-999
+
+-- cubes
+fmax2850 fma 1E-670 1e-335 0E+999999 -> 0E-1003 Underflow Subnormal Inexact Rounded Clamped
+fmax2851 fma 1E-668 1e-334 0E+999999 -> 1E-1002 Subnormal
+fmax2852 fma 4E-668 2e-334 0E+999999 -> 8E-1002 Subnormal
+fmax2853 fma 9E-668 3e-334 0E+999999 -> 2.7E-1001 Subnormal
+fmax2854 fma 16E-668 4e-334 0E+999999 -> 6.4E-1001 Subnormal
+fmax2855 fma 25E-668 5e-334 0E+999999 -> 1.25E-1000 Subnormal
+fmax2856 fma 10E-668 100e-334 0E+999999 -> 1.000E-999
+
+-- test derived from result of 0.099 ** 999 at 15 digits with unlimited exponent
+precision: 19
+fmax2860 fma 6636851557994578716E-520 6636851557994578716E-520 0E+999999 -> 4.40477986028551E-1003 Underflow Subnormal Inexact Rounded
+
+-- Long operand overflow may be a different path
+precision: 3
+maxExponent: 999999
+minexponent: -999999
+fmax2870 fma 1 9.999E+999999 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2871 fma 1 -9.999E+999999 0E+999999 -> -Infinity Inexact Overflow Rounded
+fmax2872 fma 9.999E+999999 1 0E+999999 -> Infinity Inexact Overflow Rounded
+fmax2873 fma -9.999E+999999 1 0E+999999 -> -Infinity Inexact Overflow Rounded
+
+-- check for double-rounded subnormals
+precision: 5
+maxexponent: 79
+minexponent: -79
+fmax2881 fma 1.2347E-40 1.2347E-40 0E+999999 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax2882 fma 1.234E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2883 fma 1.23E-40 1.23E-40 0E+999999 -> 1.513E-80 Inexact Rounded Subnormal Underflow
+fmax2884 fma 1.2E-40 1.2E-40 0E+999999 -> 1.44E-80 Subnormal
+fmax2885 fma 1.2E-40 1.2E-41 0E+999999 -> 1.44E-81 Subnormal
+fmax2886 fma 1.2E-40 1.2E-42 0E+999999 -> 1.4E-82 Subnormal Inexact Rounded Underflow
+fmax2887 fma 1.2E-40 1.3E-42 0E+999999 -> 1.6E-82 Subnormal Inexact Rounded Underflow
+fmax2888 fma 1.3E-40 1.3E-42 0E+999999 -> 1.7E-82 Subnormal Inexact Rounded Underflow
+fmax2889 fma 1.3E-40 1.3E-43 0E+999999 -> 2E-83 Subnormal Inexact Rounded Underflow
+fmax2890 fma 1.3E-41 1.3E-43 0E+999999 -> 0E-83 Clamped Subnormal Inexact Rounded Underflow
+
+fmax2891 fma 1.2345E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
+fmax2892 fma 1.23456E-39 1.234E-40 0E+999999 -> 1.5234E-79 Inexact Rounded
+fmax2893 fma 1.2345E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2894 fma 1.23456E-40 1.234E-40 0E+999999 -> 1.523E-80 Inexact Rounded Subnormal Underflow
+fmax2895 fma 1.2345E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
+fmax2896 fma 1.23456E-41 1.234E-40 0E+999999 -> 1.52E-81 Inexact Rounded Subnormal Underflow
+
+-- Now explore the case where we get a normal result with Underflow
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+fmax2900 fma 0.3000000000E-191 0.3000000000E-191 0E+999999 -> 9.00000000000000E-384 Subnormal Rounded
+fmax2901 fma 0.3000000001E-191 0.3000000001E-191 0E+999999 -> 9.00000000600000E-384 Underflow Inexact Subnormal Rounded
+fmax2902 fma 9.999999999999999E-383 0.0999999999999 0E+999999 -> 9.99999999999000E-384 Underflow Inexact Subnormal Rounded
+fmax2903 fma 9.999999999999999E-383 0.09999999999999 0E+999999 -> 9.99999999999900E-384 Underflow Inexact Subnormal Rounded
+fmax2904 fma 9.999999999999999E-383 0.099999999999999 0E+999999 -> 9.99999999999990E-384 Underflow Inexact Subnormal Rounded
+fmax2905 fma 9.999999999999999E-383 0.0999999999999999 0E+999999 -> 9.99999999999999E-384 Underflow Inexact Subnormal Rounded
+-- prove operands are exact
+fmax2906 fma 9.999999999999999E-383 1 0E+999999 -> 9.999999999999999E-383
+fmax2907 fma 1 0.09999999999999999 0E+999999 -> 0.09999999999999999
+-- the next rounds to Nmin
+fmax2908 fma 9.999999999999999E-383 0.09999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2909 fma 9.999999999999999E-383 0.099999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2910 fma 9.999999999999999E-383 0.0999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax2911 fma 9.999999999999999E-383 0.09999999999999999999 0E+999999 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+fmax2921 fma 130E-2 120E-2 0E+999999 -> 1.5600
+fmax2922 fma 130E-2 12E-1 0E+999999 -> 1.560
+fmax2923 fma 130E-2 1E0 0E+999999 -> 1.30
+
+-- Null tests
+fmax2990 fma # 10 0E+999999 -> NaN Invalid_operation
+fmax2991 fma 10 # 0E+999999 -> NaN Invalid_operation
+
+-- ADDITION TESTS ------------------------------------------------------
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- [first group are 'quick confidence check']
+fmax3001 fma 1 1 1 -> 2
+fmax3002 fma 1 2 3 -> 5
+fmax3003 fma 1 '5.75' '3.3' -> 9.05
+fmax3004 fma 1 '5' '-3' -> 2
+fmax3005 fma 1 '-5' '-3' -> -8
+fmax3006 fma 1 '-7' '2.5' -> -4.5
+fmax3007 fma 1 '0.7' '0.3' -> 1.0
+fmax3008 fma 1 '1.25' '1.25' -> 2.50
+fmax3009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+fmax3010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+fmax3011 fma 1 '0.4444444444' '0.5555555555' -> '1.00000000' Inexact Rounded
+fmax3012 fma 1 '0.4444444440' '0.5555555555' -> '1.00000000' Inexact Rounded
+fmax3013 fma 1 '0.4444444444' '0.5555555550' -> '0.999999999' Inexact Rounded
+fmax3014 fma 1 '0.44444444449' '0' -> '0.444444444' Inexact Rounded
+fmax3015 fma 1 '0.444444444499' '0' -> '0.444444444' Inexact Rounded
+fmax3016 fma 1 '0.4444444444999' '0' -> '0.444444444' Inexact Rounded
+fmax3017 fma 1 '0.4444444445000' '0' -> '0.444444445' Inexact Rounded
+fmax3018 fma 1 '0.4444444445001' '0' -> '0.444444445' Inexact Rounded
+fmax3019 fma 1 '0.444444444501' '0' -> '0.444444445' Inexact Rounded
+fmax3020 fma 1 '0.44444444451' '0' -> '0.444444445' Inexact Rounded
+
+fmax3021 fma 1 0 1 -> 1
+fmax3022 fma 1 1 1 -> 2
+fmax3023 fma 1 2 1 -> 3
+fmax3024 fma 1 3 1 -> 4
+fmax3025 fma 1 4 1 -> 5
+fmax3026 fma 1 5 1 -> 6
+fmax3027 fma 1 6 1 -> 7
+fmax3028 fma 1 7 1 -> 8
+fmax3029 fma 1 8 1 -> 9
+fmax3030 fma 1 9 1 -> 10
+
+-- some carrying effects
+fmax3031 fma 1 '0.9998' '0.0000' -> '0.9998'
+fmax3032 fma 1 '0.9998' '0.0001' -> '0.9999'
+fmax3033 fma 1 '0.9998' '0.0002' -> '1.0000'
+fmax3034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+fmax3035 fma 1 '70' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3036 fma 1 '700' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3037 fma 1 '7000' '10000e+9' -> '1.00000000E+13' Inexact Rounded
+fmax3038 fma 1 '70000' '10000e+9' -> '1.00000001E+13' Inexact Rounded
+fmax3039 fma 1 '700000' '10000e+9' -> '1.00000007E+13' Rounded
+
+-- symmetry:
+fmax3040 fma 1 '10000e+9' '70' -> '1.00000000E+13' Inexact Rounded
+fmax3041 fma 1 '10000e+9' '700' -> '1.00000000E+13' Inexact Rounded
+fmax3042 fma 1 '10000e+9' '7000' -> '1.00000000E+13' Inexact Rounded
+fmax3044 fma 1 '10000e+9' '70000' -> '1.00000001E+13' Inexact Rounded
+fmax3045 fma 1 '10000e+9' '700000' -> '1.00000007E+13' Rounded
+
+-- same, higher precision
+precision: 15
+fmax3046 fma 1 '10000e+9' '7' -> '10000000000007'
+fmax3047 fma 1 '10000e+9' '70' -> '10000000000070'
+fmax3048 fma 1 '10000e+9' '700' -> '10000000000700'
+fmax3049 fma 1 '10000e+9' '7000' -> '10000000007000'
+fmax3050 fma 1 '10000e+9' '70000' -> '10000000070000'
+fmax3051 fma 1 '10000e+9' '700000' -> '10000000700000'
+fmax3052 fma 1 '10000e+9' '7000000' -> '10000007000000'
+
+-- examples from decarith
+fmax3053 fma 1 '12' '7.00' -> '19.00'
+fmax3054 fma 1 '1.3' '-1.07' -> '0.23'
+fmax3055 fma 1 '1.3' '-1.30' -> '0.00'
+fmax3056 fma 1 '1.3' '-2.07' -> '-0.77'
+fmax3057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- zero preservation
+precision: 6
+fmax3060 fma 1 '10000e+9' '70000' -> '1.00000E+13' Inexact Rounded
+fmax3061 fma 1 1 '0.0001' -> '1.0001'
+fmax3062 fma 1 1 '0.00001' -> '1.00001'
+fmax3063 fma 1 1 '0.000001' -> '1.00000' Inexact Rounded
+fmax3064 fma 1 1 '0.0000001' -> '1.00000' Inexact Rounded
+fmax3065 fma 1 1 '0.00000001' -> '1.00000' Inexact Rounded
+
+-- some funny zeros [in case of bad signum]
+fmax3070 fma 1 1 0 -> 1
+fmax3071 fma 1 1 0. -> 1
+fmax3072 fma 1 1 .0 -> 1.0
+fmax3073 fma 1 1 0.0 -> 1.0
+fmax3074 fma 1 1 0.00 -> 1.00
+fmax3075 fma 1 0 1 -> 1
+fmax3076 fma 1 0. 1 -> 1
+fmax3077 fma 1 .0 1 -> 1.0
+fmax3078 fma 1 0.0 1 -> 1.0
+fmax3079 fma 1 0.00 1 -> 1.00
+
+precision: 9
+
+-- some carries
+fmax3080 fma 1 999999998 1 -> 999999999
+fmax3081 fma 1 999999999 1 -> 1.00000000E+9 Rounded
+fmax3082 fma 1 99999999 1 -> 100000000
+fmax3083 fma 1 9999999 1 -> 10000000
+fmax3084 fma 1 999999 1 -> 1000000
+fmax3085 fma 1 99999 1 -> 100000
+fmax3086 fma 1 9999 1 -> 10000
+fmax3087 fma 1 999 1 -> 1000
+fmax3088 fma 1 99 1 -> 100
+fmax3089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+fmax3090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+fmax3091 fma 1 '-56267E-6' 0 -> '-0.056267'
+fmax3092 fma 1 '-56267E-5' 0 -> '-0.56267'
+fmax3093 fma 1 '-56267E-4' 0 -> '-5.6267'
+fmax3094 fma 1 '-56267E-3' 0 -> '-56.267'
+fmax3095 fma 1 '-56267E-2' 0 -> '-562.67'
+fmax3096 fma 1 '-56267E-1' 0 -> '-5626.7'
+fmax3097 fma 1 '-56267E-0' 0 -> '-56267'
+fmax3098 fma 1 '-5E-10' 0 -> '-5E-10'
+fmax3099 fma 1 '-5E-7' 0 -> '-5E-7'
+fmax3100 fma 1 '-5E-6' 0 -> '-0.000005'
+fmax3101 fma 1 '-5E-5' 0 -> '-0.00005'
+fmax3102 fma 1 '-5E-4' 0 -> '-0.0005'
+fmax3103 fma 1 '-5E-1' 0 -> '-0.5'
+fmax3104 fma 1 '-5E0' 0 -> '-5'
+fmax3105 fma 1 '-5E1' 0 -> '-50'
+fmax3106 fma 1 '-5E5' 0 -> '-500000'
+fmax3107 fma 1 '-5E8' 0 -> '-500000000'
+fmax3108 fma 1 '-5E9' 0 -> '-5.00000000E+9' Rounded
+fmax3109 fma 1 '-5E10' 0 -> '-5.00000000E+10' Rounded
+fmax3110 fma 1 '-5E11' 0 -> '-5.00000000E+11' Rounded
+fmax3111 fma 1 '-5E100' 0 -> '-5.00000000E+100' Rounded
+
+-- more RHS swaps
+fmax3113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+fmax3114 fma 1 0 '-56267E-6' -> '-0.056267'
+fmax3116 fma 1 0 '-56267E-5' -> '-0.56267'
+fmax3117 fma 1 0 '-56267E-4' -> '-5.6267'
+fmax3119 fma 1 0 '-56267E-3' -> '-56.267'
+fmax3120 fma 1 0 '-56267E-2' -> '-562.67'
+fmax3121 fma 1 0 '-56267E-1' -> '-5626.7'
+fmax3122 fma 1 0 '-56267E-0' -> '-56267'
+fmax3123 fma 1 0 '-5E-10' -> '-5E-10'
+fmax3124 fma 1 0 '-5E-7' -> '-5E-7'
+fmax3125 fma 1 0 '-5E-6' -> '-0.000005'
+fmax3126 fma 1 0 '-5E-5' -> '-0.00005'
+fmax3127 fma 1 0 '-5E-4' -> '-0.0005'
+fmax3128 fma 1 0 '-5E-1' -> '-0.5'
+fmax3129 fma 1 0 '-5E0' -> '-5'
+fmax3130 fma 1 0 '-5E1' -> '-50'
+fmax3131 fma 1 0 '-5E5' -> '-500000'
+fmax3132 fma 1 0 '-5E8' -> '-500000000'
+fmax3133 fma 1 0 '-5E9' -> '-5.00000000E+9' Rounded
+fmax3134 fma 1 0 '-5E10' -> '-5.00000000E+10' Rounded
+fmax3135 fma 1 0 '-5E11' -> '-5.00000000E+11' Rounded
+fmax3136 fma 1 0 '-5E100' -> '-5.00000000E+100' Rounded
+
+-- related
+fmax3137 fma 1 1 '0E-12' -> '1.00000000' Rounded
+fmax3138 fma 1 -1 '0E-12' -> '-1.00000000' Rounded
+fmax3139 fma 1 '0E-12' 1 -> '1.00000000' Rounded
+fmax3140 fma 1 '0E-12' -1 -> '-1.00000000' Rounded
+fmax3141 fma 1 1E+4 0.0000 -> '10000.0000'
+fmax3142 fma 1 1E+4 0.00000 -> '10000.0000' Rounded
+fmax3143 fma 1 0.000 1E+5 -> '100000.000'
+fmax3144 fma 1 0.0000 1E+5 -> '100000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+fmax3146 fma 1 '00.0' 0 -> '0.0'
+fmax3147 fma 1 '0.00' 0 -> '0.00'
+fmax3148 fma 1 0 '0.00' -> '0.00'
+fmax3149 fma 1 0 '00.0' -> '0.0'
+fmax3150 fma 1 '00.0' '0.00' -> '0.00'
+fmax3151 fma 1 '0.00' '00.0' -> '0.00'
+fmax3152 fma 1 '3' '.3' -> '3.3'
+fmax3153 fma 1 '3.' '.3' -> '3.3'
+fmax3154 fma 1 '3.0' '.3' -> '3.3'
+fmax3155 fma 1 '3.00' '.3' -> '3.30'
+fmax3156 fma 1 '3' '3' -> '6'
+fmax3157 fma 1 '3' '+3' -> '6'
+fmax3158 fma 1 '3' '-3' -> '0'
+fmax3159 fma 1 '0.3' '-0.3' -> '0.0'
+fmax3160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+precision: 15
+fmax3161 fma 1 '1E+12' '-1' -> '999999999999'
+fmax3162 fma 1 '1E+12' '1.11' -> '1000000000001.11'
+fmax3163 fma 1 '1.11' '1E+12' -> '1000000000001.11'
+fmax3164 fma 1 '-1' '1E+12' -> '999999999999'
+fmax3165 fma 1 '7E+12' '-1' -> '6999999999999'
+fmax3166 fma 1 '7E+12' '1.11' -> '7000000000001.11'
+fmax3167 fma 1 '1.11' '7E+12' -> '7000000000001.11'
+fmax3168 fma 1 '-1' '7E+12' -> '6999999999999'
+
+-- 123456789012345 123456789012345 1 23456789012345
+fmax3170 fma 1 '0.444444444444444' '0.555555555555563' -> '1.00000000000001' Inexact Rounded
+fmax3171 fma 1 '0.444444444444444' '0.555555555555562' -> '1.00000000000001' Inexact Rounded
+fmax3172 fma 1 '0.444444444444444' '0.555555555555561' -> '1.00000000000001' Inexact Rounded
+fmax3173 fma 1 '0.444444444444444' '0.555555555555560' -> '1.00000000000000' Inexact Rounded
+fmax3174 fma 1 '0.444444444444444' '0.555555555555559' -> '1.00000000000000' Inexact Rounded
+fmax3175 fma 1 '0.444444444444444' '0.555555555555558' -> '1.00000000000000' Inexact Rounded
+fmax3176 fma 1 '0.444444444444444' '0.555555555555557' -> '1.00000000000000' Inexact Rounded
+fmax3177 fma 1 '0.444444444444444' '0.555555555555556' -> '1.00000000000000' Rounded
+fmax3178 fma 1 '0.444444444444444' '0.555555555555555' -> '0.999999999999999'
+fmax3179 fma 1 '0.444444444444444' '0.555555555555554' -> '0.999999999999998'
+fmax3180 fma 1 '0.444444444444444' '0.555555555555553' -> '0.999999999999997'
+fmax3181 fma 1 '0.444444444444444' '0.555555555555552' -> '0.999999999999996'
+fmax3182 fma 1 '0.444444444444444' '0.555555555555551' -> '0.999999999999995'
+fmax3183 fma 1 '0.444444444444444' '0.555555555555550' -> '0.999999999999994'
+
+-- and some more, including residue effects and different roundings
+precision: 9
+rounding: half_up
+fmax3200 fma 1 '123456789' 0 -> '123456789'
+fmax3201 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3202 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3203 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3204 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3205 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3206 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3207 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3208 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
+fmax3209 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
+fmax3210 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
+fmax3211 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
+fmax3212 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
+fmax3213 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
+fmax3214 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
+fmax3215 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
+fmax3216 fma 1 '123456789' 1 -> '123456790'
+fmax3217 fma 1 '123456789' 1.000000001 -> '123456790' Inexact Rounded
+fmax3218 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3219 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+
+rounding: half_even
+fmax3220 fma 1 '123456789' 0 -> '123456789'
+fmax3221 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3222 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3223 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3224 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3225 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3226 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3227 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3228 fma 1 '123456789' 0.5 -> '123456790' Inexact Rounded
+fmax3229 fma 1 '123456789' 0.500000001 -> '123456790' Inexact Rounded
+fmax3230 fma 1 '123456789' 0.500001 -> '123456790' Inexact Rounded
+fmax3231 fma 1 '123456789' 0.51 -> '123456790' Inexact Rounded
+fmax3232 fma 1 '123456789' 0.6 -> '123456790' Inexact Rounded
+fmax3233 fma 1 '123456789' 0.9 -> '123456790' Inexact Rounded
+fmax3234 fma 1 '123456789' 0.99999 -> '123456790' Inexact Rounded
+fmax3235 fma 1 '123456789' 0.999999999 -> '123456790' Inexact Rounded
+fmax3236 fma 1 '123456789' 1 -> '123456790'
+fmax3237 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
+fmax3238 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3239 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+-- critical few with even bottom digit...
+fmax3240 fma 1 '123456788' 0.499999999 -> '123456788' Inexact Rounded
+fmax3241 fma 1 '123456788' 0.5 -> '123456788' Inexact Rounded
+fmax3242 fma 1 '123456788' 0.500000001 -> '123456789' Inexact Rounded
+
+rounding: down
+fmax3250 fma 1 '123456789' 0 -> '123456789'
+fmax3251 fma 1 '123456789' 0.000000001 -> '123456789' Inexact Rounded
+fmax3252 fma 1 '123456789' 0.000001 -> '123456789' Inexact Rounded
+fmax3253 fma 1 '123456789' 0.1 -> '123456789' Inexact Rounded
+fmax3254 fma 1 '123456789' 0.4 -> '123456789' Inexact Rounded
+fmax3255 fma 1 '123456789' 0.49 -> '123456789' Inexact Rounded
+fmax3256 fma 1 '123456789' 0.499999 -> '123456789' Inexact Rounded
+fmax3257 fma 1 '123456789' 0.499999999 -> '123456789' Inexact Rounded
+fmax3258 fma 1 '123456789' 0.5 -> '123456789' Inexact Rounded
+fmax3259 fma 1 '123456789' 0.500000001 -> '123456789' Inexact Rounded
+fmax3260 fma 1 '123456789' 0.500001 -> '123456789' Inexact Rounded
+fmax3261 fma 1 '123456789' 0.51 -> '123456789' Inexact Rounded
+fmax3262 fma 1 '123456789' 0.6 -> '123456789' Inexact Rounded
+fmax3263 fma 1 '123456789' 0.9 -> '123456789' Inexact Rounded
+fmax3264 fma 1 '123456789' 0.99999 -> '123456789' Inexact Rounded
+fmax3265 fma 1 '123456789' 0.999999999 -> '123456789' Inexact Rounded
+fmax3266 fma 1 '123456789' 1 -> '123456790'
+fmax3267 fma 1 '123456789' 1.00000001 -> '123456790' Inexact Rounded
+fmax3268 fma 1 '123456789' 1.00001 -> '123456790' Inexact Rounded
+fmax3269 fma 1 '123456789' 1.1 -> '123456790' Inexact Rounded
+
+-- input preparation tests (operands should not be rounded)
+precision: 3
+rounding: half_up
+
+fmax3270 fma 1 '12345678900000' 9999999999999 -> '2.23E+13' Inexact Rounded
+fmax3271 fma 1 '9999999999999' 12345678900000 -> '2.23E+13' Inexact Rounded
+
+fmax3272 fma 1 '12E+3' '3444' -> '1.54E+4' Inexact Rounded
+fmax3273 fma 1 '12E+3' '3446' -> '1.54E+4' Inexact Rounded
+fmax3274 fma 1 '12E+3' '3449.9' -> '1.54E+4' Inexact Rounded
+fmax3275 fma 1 '12E+3' '3450.0' -> '1.55E+4' Inexact Rounded
+fmax3276 fma 1 '12E+3' '3450.1' -> '1.55E+4' Inexact Rounded
+fmax3277 fma 1 '12E+3' '3454' -> '1.55E+4' Inexact Rounded
+fmax3278 fma 1 '12E+3' '3456' -> '1.55E+4' Inexact Rounded
+
+fmax3281 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3282 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3283 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3284 fma 1 '3450.0' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3285 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3286 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3287 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
+
+rounding: half_down
+fmax3291 fma 1 '3444' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3292 fma 1 '3446' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3293 fma 1 '3449.9' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3294 fma 1 '3450.0' '12E+3' -> '1.54E+4' Inexact Rounded
+fmax3295 fma 1 '3450.1' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3296 fma 1 '3454' '12E+3' -> '1.55E+4' Inexact Rounded
+fmax3297 fma 1 '3456' '12E+3' -> '1.55E+4' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_up
+fmax3301 fma 1 -1 1 -> 0
+fmax3302 fma 1 0 1 -> 1
+fmax3303 fma 1 1 1 -> 2
+fmax3304 fma 1 12 1 -> 13
+fmax3305 fma 1 98 1 -> 99
+fmax3306 fma 1 99 1 -> 100
+fmax3307 fma 1 100 1 -> 101
+fmax3308 fma 1 101 1 -> 102
+fmax3309 fma 1 -1 -1 -> -2
+fmax3310 fma 1 0 -1 -> -1
+fmax3311 fma 1 1 -1 -> 0
+fmax3312 fma 1 12 -1 -> 11
+fmax3313 fma 1 98 -1 -> 97
+fmax3314 fma 1 99 -1 -> 98
+fmax3315 fma 1 100 -1 -> 99
+fmax3316 fma 1 101 -1 -> 100
+
+fmax3321 fma 1 -0.01 0.01 -> 0.00
+fmax3322 fma 1 0.00 0.01 -> 0.01
+fmax3323 fma 1 0.01 0.01 -> 0.02
+fmax3324 fma 1 0.12 0.01 -> 0.13
+fmax3325 fma 1 0.98 0.01 -> 0.99
+fmax3326 fma 1 0.99 0.01 -> 1.00
+fmax3327 fma 1 1.00 0.01 -> 1.01
+fmax3328 fma 1 1.01 0.01 -> 1.02
+fmax3329 fma 1 -0.01 -0.01 -> -0.02
+fmax3330 fma 1 0.00 -0.01 -> -0.01
+fmax3331 fma 1 0.01 -0.01 -> 0.00
+fmax3332 fma 1 0.12 -0.01 -> 0.11
+fmax3333 fma 1 0.98 -0.01 -> 0.97
+fmax3334 fma 1 0.99 -0.01 -> 0.98
+fmax3335 fma 1 1.00 -0.01 -> 0.99
+fmax3336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where fma 1 ing 0 affects the coefficient
+precision: 9
+fmax3340 fma 1 1E+3 0 -> 1000
+fmax3341 fma 1 1E+8 0 -> 100000000
+fmax3342 fma 1 1E+9 0 -> 1.00000000E+9 Rounded
+fmax3343 fma 1 1E+10 0 -> 1.00000000E+10 Rounded
+-- which simply follow from these cases ...
+fmax3344 fma 1 1E+3 1 -> 1001
+fmax3345 fma 1 1E+8 1 -> 100000001
+fmax3346 fma 1 1E+9 1 -> 1.00000000E+9 Inexact Rounded
+fmax3347 fma 1 1E+10 1 -> 1.00000000E+10 Inexact Rounded
+fmax3348 fma 1 1E+3 7 -> 1007
+fmax3349 fma 1 1E+8 7 -> 100000007
+fmax3350 fma 1 1E+9 7 -> 1.00000001E+9 Inexact Rounded
+fmax3351 fma 1 1E+10 7 -> 1.00000000E+10 Inexact Rounded
+
+-- tryzeros cases
+precision: 7
+rounding: half_up
+maxExponent: 92
+minexponent: -92
+fmax3361 fma 1 0E+50 10000E+1 -> 1.0000E+5
+fmax3362 fma 1 10000E+1 0E-50 -> 100000.0 Rounded
+fmax3363 fma 1 10000E+1 10000E-50 -> 100000.0 Rounded Inexact
+fmax3364 fma 1 9.999999E+92 -9.999999E+92 -> 0E+86
+
+-- a curiosity from JSR 13 testing
+rounding: half_down
+precision: 10
+fmax3370 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3371 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+rounding: half_up
+precision: 10
+fmax3372 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3373 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+rounding: half_even
+precision: 10
+fmax3374 fma 1 99999999 81512 -> 100081511
+precision: 6
+fmax3375 fma 1 99999999 81512 -> 1.00082E+8 Rounded Inexact
+
+-- ulp replacement tests
+precision: 9
+maxexponent: 999999
+minexponent: -999999
+fmax3400 fma 1 1 77e-7 -> 1.0000077
+fmax3401 fma 1 1 77e-8 -> 1.00000077
+fmax3402 fma 1 1 77e-9 -> 1.00000008 Inexact Rounded
+fmax3403 fma 1 1 77e-10 -> 1.00000001 Inexact Rounded
+fmax3404 fma 1 1 77e-11 -> 1.00000000 Inexact Rounded
+fmax3405 fma 1 1 77e-12 -> 1.00000000 Inexact Rounded
+fmax3406 fma 1 1 77e-999 -> 1.00000000 Inexact Rounded
+fmax3407 fma 1 1 77e-999999 -> 1.00000000 Inexact Rounded
+
+fmax3410 fma 1 10 77e-7 -> 10.0000077
+fmax3411 fma 1 10 77e-8 -> 10.0000008 Inexact Rounded
+fmax3412 fma 1 10 77e-9 -> 10.0000001 Inexact Rounded
+fmax3413 fma 1 10 77e-10 -> 10.0000000 Inexact Rounded
+fmax3414 fma 1 10 77e-11 -> 10.0000000 Inexact Rounded
+fmax3415 fma 1 10 77e-12 -> 10.0000000 Inexact Rounded
+fmax3416 fma 1 10 77e-999 -> 10.0000000 Inexact Rounded
+fmax3417 fma 1 10 77e-999999 -> 10.0000000 Inexact Rounded
+
+fmax3420 fma 1 77e-7 1 -> 1.0000077
+fmax3421 fma 1 77e-8 1 -> 1.00000077
+fmax3422 fma 1 77e-9 1 -> 1.00000008 Inexact Rounded
+fmax3423 fma 1 77e-10 1 -> 1.00000001 Inexact Rounded
+fmax3424 fma 1 77e-11 1 -> 1.00000000 Inexact Rounded
+fmax3425 fma 1 77e-12 1 -> 1.00000000 Inexact Rounded
+fmax3426 fma 1 77e-999 1 -> 1.00000000 Inexact Rounded
+fmax3427 fma 1 77e-999999 1 -> 1.00000000 Inexact Rounded
+
+fmax3430 fma 1 77e-7 10 -> 10.0000077
+fmax3431 fma 1 77e-8 10 -> 10.0000008 Inexact Rounded
+fmax3432 fma 1 77e-9 10 -> 10.0000001 Inexact Rounded
+fmax3433 fma 1 77e-10 10 -> 10.0000000 Inexact Rounded
+fmax3434 fma 1 77e-11 10 -> 10.0000000 Inexact Rounded
+fmax3435 fma 1 77e-12 10 -> 10.0000000 Inexact Rounded
+fmax3436 fma 1 77e-999 10 -> 10.0000000 Inexact Rounded
+fmax3437 fma 1 77e-999999 10 -> 10.0000000 Inexact Rounded
+
+-- negative ulps
+fmax3440 fma 1 1 -77e-7 -> 0.9999923
+fmax3441 fma 1 1 -77e-8 -> 0.99999923
+fmax3442 fma 1 1 -77e-9 -> 0.999999923
+fmax3443 fma 1 1 -77e-10 -> 0.999999992 Inexact Rounded
+fmax3444 fma 1 1 -77e-11 -> 0.999999999 Inexact Rounded
+fmax3445 fma 1 1 -77e-12 -> 1.00000000 Inexact Rounded
+fmax3446 fma 1 1 -77e-999 -> 1.00000000 Inexact Rounded
+fmax3447 fma 1 1 -77e-999999 -> 1.00000000 Inexact Rounded
+
+fmax3450 fma 1 10 -77e-7 -> 9.9999923
+fmax3451 fma 1 10 -77e-8 -> 9.99999923
+fmax3452 fma 1 10 -77e-9 -> 9.99999992 Inexact Rounded
+fmax3453 fma 1 10 -77e-10 -> 9.99999999 Inexact Rounded
+fmax3454 fma 1 10 -77e-11 -> 10.0000000 Inexact Rounded
+fmax3455 fma 1 10 -77e-12 -> 10.0000000 Inexact Rounded
+fmax3456 fma 1 10 -77e-999 -> 10.0000000 Inexact Rounded
+fmax3457 fma 1 10 -77e-999999 -> 10.0000000 Inexact Rounded
+
+fmax3460 fma 1 -77e-7 1 -> 0.9999923
+fmax3461 fma 1 -77e-8 1 -> 0.99999923
+fmax3462 fma 1 -77e-9 1 -> 0.999999923
+fmax3463 fma 1 -77e-10 1 -> 0.999999992 Inexact Rounded
+fmax3464 fma 1 -77e-11 1 -> 0.999999999 Inexact Rounded
+fmax3465 fma 1 -77e-12 1 -> 1.00000000 Inexact Rounded
+fmax3466 fma 1 -77e-999 1 -> 1.00000000 Inexact Rounded
+fmax3467 fma 1 -77e-999999 1 -> 1.00000000 Inexact Rounded
+
+fmax3470 fma 1 -77e-7 10 -> 9.9999923
+fmax3471 fma 1 -77e-8 10 -> 9.99999923
+fmax3472 fma 1 -77e-9 10 -> 9.99999992 Inexact Rounded
+fmax3473 fma 1 -77e-10 10 -> 9.99999999 Inexact Rounded
+fmax3474 fma 1 -77e-11 10 -> 10.0000000 Inexact Rounded
+fmax3475 fma 1 -77e-12 10 -> 10.0000000 Inexact Rounded
+fmax3476 fma 1 -77e-999 10 -> 10.0000000 Inexact Rounded
+fmax3477 fma 1 -77e-999999 10 -> 10.0000000 Inexact Rounded
+
+-- negative ulps
+fmax3480 fma 1 -1 77e-7 -> -0.9999923
+fmax3481 fma 1 -1 77e-8 -> -0.99999923
+fmax3482 fma 1 -1 77e-9 -> -0.999999923
+fmax3483 fma 1 -1 77e-10 -> -0.999999992 Inexact Rounded
+fmax3484 fma 1 -1 77e-11 -> -0.999999999 Inexact Rounded
+fmax3485 fma 1 -1 77e-12 -> -1.00000000 Inexact Rounded
+fmax3486 fma 1 -1 77e-999 -> -1.00000000 Inexact Rounded
+fmax3487 fma 1 -1 77e-999999 -> -1.00000000 Inexact Rounded
+
+fmax3490 fma 1 -10 77e-7 -> -9.9999923
+fmax3491 fma 1 -10 77e-8 -> -9.99999923
+fmax3492 fma 1 -10 77e-9 -> -9.99999992 Inexact Rounded
+fmax3493 fma 1 -10 77e-10 -> -9.99999999 Inexact Rounded
+fmax3494 fma 1 -10 77e-11 -> -10.0000000 Inexact Rounded
+fmax3495 fma 1 -10 77e-12 -> -10.0000000 Inexact Rounded
+fmax3496 fma 1 -10 77e-999 -> -10.0000000 Inexact Rounded
+fmax3497 fma 1 -10 77e-999999 -> -10.0000000 Inexact Rounded
+
+fmax3500 fma 1 77e-7 -1 -> -0.9999923
+fmax3501 fma 1 77e-8 -1 -> -0.99999923
+fmax3502 fma 1 77e-9 -1 -> -0.999999923
+fmax3503 fma 1 77e-10 -1 -> -0.999999992 Inexact Rounded
+fmax3504 fma 1 77e-11 -1 -> -0.999999999 Inexact Rounded
+fmax3505 fma 1 77e-12 -1 -> -1.00000000 Inexact Rounded
+fmax3506 fma 1 77e-999 -1 -> -1.00000000 Inexact Rounded
+fmax3507 fma 1 77e-999999 -1 -> -1.00000000 Inexact Rounded
+
+fmax3510 fma 1 77e-7 -10 -> -9.9999923
+fmax3511 fma 1 77e-8 -10 -> -9.99999923
+fmax3512 fma 1 77e-9 -10 -> -9.99999992 Inexact Rounded
+fmax3513 fma 1 77e-10 -10 -> -9.99999999 Inexact Rounded
+fmax3514 fma 1 77e-11 -10 -> -10.0000000 Inexact Rounded
+fmax3515 fma 1 77e-12 -10 -> -10.0000000 Inexact Rounded
+fmax3516 fma 1 77e-999 -10 -> -10.0000000 Inexact Rounded
+fmax3517 fma 1 77e-999999 -10 -> -10.0000000 Inexact Rounded
+
+
+-- long operands
+maxexponent: 999
+minexponent: -999
+precision: 9
+fmax3521 fma 1 12345678000 0 -> 1.23456780E+10 Rounded
+fmax3522 fma 1 0 12345678000 -> 1.23456780E+10 Rounded
+fmax3523 fma 1 1234567800 0 -> 1.23456780E+9 Rounded
+fmax3524 fma 1 0 1234567800 -> 1.23456780E+9 Rounded
+fmax3525 fma 1 1234567890 0 -> 1.23456789E+9 Rounded
+fmax3526 fma 1 0 1234567890 -> 1.23456789E+9 Rounded
+fmax3527 fma 1 1234567891 0 -> 1.23456789E+9 Inexact Rounded
+fmax3528 fma 1 0 1234567891 -> 1.23456789E+9 Inexact Rounded
+fmax3529 fma 1 12345678901 0 -> 1.23456789E+10 Inexact Rounded
+fmax3530 fma 1 0 12345678901 -> 1.23456789E+10 Inexact Rounded
+fmax3531 fma 1 1234567896 0 -> 1.23456790E+9 Inexact Rounded
+fmax3532 fma 1 0 1234567896 -> 1.23456790E+9 Inexact Rounded
+
+precision: 15
+-- still checking
+fmax3541 fma 1 12345678000 0 -> 12345678000
+fmax3542 fma 1 0 12345678000 -> 12345678000
+fmax3543 fma 1 1234567800 0 -> 1234567800
+fmax3544 fma 1 0 1234567800 -> 1234567800
+fmax3545 fma 1 1234567890 0 -> 1234567890
+fmax3546 fma 1 0 1234567890 -> 1234567890
+fmax3547 fma 1 1234567891 0 -> 1234567891
+fmax3548 fma 1 0 1234567891 -> 1234567891
+fmax3549 fma 1 12345678901 0 -> 12345678901
+fmax3550 fma 1 0 12345678901 -> 12345678901
+fmax3551 fma 1 1234567896 0 -> 1234567896
+fmax3552 fma 1 0 1234567896 -> 1234567896
+
+-- verify a query
+precision: 16
+maxExponent: +394
+minExponent: -393
+rounding: down
+fmax3561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+fmax3562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+-- and using decimal64 bounds...
+precision: 16
+maxExponent: +384
+minExponent: -383
+rounding: down
+fmax3563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+fmax3564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+
+-- some more residue effects with extreme rounding
+precision: 9
+rounding: half_up
+fmax3601 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3602 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3603 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3604 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3605 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
+rounding: up
+fmax3606 fma 1 123456789 0.000001 -> 123456790 Inexact Rounded
+rounding: down
+fmax3607 fma 1 123456789 0.000001 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3611 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3612 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3613 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3614 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3615 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: up
+fmax3616 fma 1 123456789 -0.000001 -> 123456789 Inexact Rounded
+rounding: down
+fmax3617 fma 1 123456789 -0.000001 -> 123456788 Inexact Rounded
+
+rounding: half_up
+fmax3621 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3622 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3623 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3624 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3625 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
+rounding: up
+fmax3626 fma 1 123456789 0.499999 -> 123456790 Inexact Rounded
+rounding: down
+fmax3627 fma 1 123456789 0.499999 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3631 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: half_even
+fmax3632 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: half_down
+fmax3633 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: floor
+fmax3634 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3635 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: up
+fmax3636 fma 1 123456789 -0.499999 -> 123456789 Inexact Rounded
+rounding: down
+fmax3637 fma 1 123456789 -0.499999 -> 123456788 Inexact Rounded
+
+rounding: half_up
+fmax3641 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: half_even
+fmax3642 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: half_down
+fmax3643 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: floor
+fmax3644 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
+rounding: ceiling
+fmax3645 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: up
+fmax3646 fma 1 123456789 0.500001 -> 123456790 Inexact Rounded
+rounding: down
+fmax3647 fma 1 123456789 0.500001 -> 123456789 Inexact Rounded
+
+rounding: half_up
+fmax3651 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: half_even
+fmax3652 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: half_down
+fmax3653 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: floor
+fmax3654 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+rounding: ceiling
+fmax3655 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
+rounding: up
+fmax3656 fma 1 123456789 -0.500001 -> 123456789 Inexact Rounded
+rounding: down
+fmax3657 fma 1 123456789 -0.500001 -> 123456788 Inexact Rounded
+
+-- long operand triangle
+rounding: half_up
+precision: 37
+fmax3660 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114834538
+precision: 36
+fmax3661 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483454 Inexact Rounded
+precision: 35
+fmax3662 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148345 Inexact Rounded
+precision: 34
+fmax3663 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337114835 Inexact Rounded
+precision: 33
+fmax3664 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711483 Inexact Rounded
+precision: 32
+fmax3665 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371148 Inexact Rounded
+precision: 31
+fmax3666 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337115 Inexact Rounded
+precision: 30
+fmax3667 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892233711 Inexact Rounded
+precision: 29
+fmax3668 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223371 Inexact Rounded
+precision: 28
+fmax3669 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922337 Inexact Rounded
+precision: 27
+fmax3670 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892234 Inexact Rounded
+precision: 26
+fmax3671 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389223 Inexact Rounded
+precision: 25
+fmax3672 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023638922 Inexact Rounded
+precision: 24
+fmax3673 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102363892 Inexact Rounded
+precision: 23
+fmax3674 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236389 Inexact Rounded
+precision: 22
+fmax3675 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211023639 Inexact Rounded
+precision: 21
+fmax3676 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102364 Inexact Rounded
+precision: 20
+fmax3677 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110236 Inexact Rounded
+precision: 19
+fmax3678 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211024 Inexact Rounded
+precision: 18
+fmax3679 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221102 Inexact Rounded
+precision: 17
+fmax3680 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422110 Inexact Rounded
+precision: 16
+fmax3681 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42211 Inexact Rounded
+precision: 15
+fmax3682 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4221 Inexact Rounded
+precision: 14
+fmax3683 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.422 Inexact Rounded
+precision: 13
+fmax3684 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.42 Inexact Rounded
+precision: 12
+fmax3685 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166.4 Inexact Rounded
+precision: 11
+fmax3686 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 98471174166 Inexact Rounded
+precision: 10
+fmax3687 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117417E+10 Inexact Rounded
+precision: 9
+fmax3688 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84711742E+10 Inexact Rounded
+precision: 8
+fmax3689 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471174E+10 Inexact Rounded
+precision: 7
+fmax3690 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847117E+10 Inexact Rounded
+precision: 6
+fmax3691 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.84712E+10 Inexact Rounded
+precision: 5
+fmax3692 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8471E+10 Inexact Rounded
+precision: 4
+fmax3693 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.847E+10 Inexact Rounded
+precision: 3
+fmax3694 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.85E+10 Inexact Rounded
+precision: 2
+fmax3695 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 9.8E+10 Inexact Rounded
+precision: 1
+fmax3696 fma 1 98471198160.56524417578665886060 -23994.14313393939743548945165462 -> 1E+11 Inexact Rounded
+
+-- more zeros, etc.
+rounding: half_up
+precision: 9
+
+fmax3701 fma 1 5.00 1.00E-3 -> 5.00100
+fmax3702 fma 1 00.00 0.000 -> 0.000
+fmax3703 fma 1 00.00 0E-3 -> 0.000
+fmax3704 fma 1 0E-3 00.00 -> 0.000
+
+fmax3710 fma 1 0E+3 00.00 -> 0.00
+fmax3711 fma 1 0E+3 00.0 -> 0.0
+fmax3712 fma 1 0E+3 00. -> 0
+fmax3713 fma 1 0E+3 00.E+1 -> 0E+1
+fmax3714 fma 1 0E+3 00.E+2 -> 0E+2
+fmax3715 fma 1 0E+3 00.E+3 -> 0E+3
+fmax3716 fma 1 0E+3 00.E+4 -> 0E+3
+fmax3717 fma 1 0E+3 00.E+5 -> 0E+3
+fmax3718 fma 1 0E+3 -00.0 -> 0.0
+fmax3719 fma 1 0E+3 -00. -> 0
+fmax3731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+fmax3720 fma 1 00.00 0E+3 -> 0.00
+fmax3721 fma 1 00.0 0E+3 -> 0.0
+fmax3722 fma 1 00. 0E+3 -> 0
+fmax3723 fma 1 00.E+1 0E+3 -> 0E+1
+fmax3724 fma 1 00.E+2 0E+3 -> 0E+2
+fmax3725 fma 1 00.E+3 0E+3 -> 0E+3
+fmax3726 fma 1 00.E+4 0E+3 -> 0E+3
+fmax3727 fma 1 00.E+5 0E+3 -> 0E+3
+fmax3728 fma 1 -00.00 0E+3 -> 0.00
+fmax3729 fma 1 -00.0 0E+3 -> 0.0
+fmax3730 fma 1 -00. 0E+3 -> 0
+
+fmax3732 fma 1 0 0 -> 0
+fmax3733 fma 1 0 -0 -> 0
+fmax3734 fma 1 -0 0 -> 0
+fmax3735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+fmax3736 fma 1 1 -1 -> 0
+fmax3737 fma 1 -1 -1 -> -2
+fmax3738 fma 1 1 1 -> 2
+fmax3739 fma 1 -1 1 -> 0
+
+fmax3741 fma 1 0 -1 -> -1
+fmax3742 fma 1 -0 -1 -> -1
+fmax3743 fma 1 0 1 -> 1
+fmax3744 fma 1 -0 1 -> 1
+fmax3745 fma 1 -1 0 -> -1
+fmax3746 fma 1 -1 -0 -> -1
+fmax3747 fma 1 1 0 -> 1
+fmax3748 fma 1 1 -0 -> 1
+
+fmax3751 fma 1 0.0 -1 -> -1.0
+fmax3752 fma 1 -0.0 -1 -> -1.0
+fmax3753 fma 1 0.0 1 -> 1.0
+fmax3754 fma 1 -0.0 1 -> 1.0
+fmax3755 fma 1 -1.0 0 -> -1.0
+fmax3756 fma 1 -1.0 -0 -> -1.0
+fmax3757 fma 1 1.0 0 -> 1.0
+fmax3758 fma 1 1.0 -0 -> 1.0
+
+fmax3761 fma 1 0 -1.0 -> -1.0
+fmax3762 fma 1 -0 -1.0 -> -1.0
+fmax3763 fma 1 0 1.0 -> 1.0
+fmax3764 fma 1 -0 1.0 -> 1.0
+fmax3765 fma 1 -1 0.0 -> -1.0
+fmax3766 fma 1 -1 -0.0 -> -1.0
+fmax3767 fma 1 1 0.0 -> 1.0
+fmax3768 fma 1 1 -0.0 -> 1.0
+
+fmax3771 fma 1 0.0 -1.0 -> -1.0
+fmax3772 fma 1 -0.0 -1.0 -> -1.0
+fmax3773 fma 1 0.0 1.0 -> 1.0
+fmax3774 fma 1 -0.0 1.0 -> 1.0
+fmax3775 fma 1 -1.0 0.0 -> -1.0
+fmax3776 fma 1 -1.0 -0.0 -> -1.0
+fmax3777 fma 1 1.0 0.0 -> 1.0
+fmax3778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+fmax3780 fma 1 -Inf -Inf -> -Infinity
+fmax3781 fma 1 -Inf -1000 -> -Infinity
+fmax3782 fma 1 -Inf -1 -> -Infinity
+fmax3783 fma 1 -Inf -0 -> -Infinity
+fmax3784 fma 1 -Inf 0 -> -Infinity
+fmax3785 fma 1 -Inf 1 -> -Infinity
+fmax3786 fma 1 -Inf 1000 -> -Infinity
+fmax3787 fma 1 -1000 -Inf -> -Infinity
+fmax3788 fma 1 -Inf -Inf -> -Infinity
+fmax3789 fma 1 -1 -Inf -> -Infinity
+fmax3790 fma 1 -0 -Inf -> -Infinity
+fmax3791 fma 1 0 -Inf -> -Infinity
+fmax3792 fma 1 1 -Inf -> -Infinity
+fmax3793 fma 1 1000 -Inf -> -Infinity
+fmax3794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+fmax3800 fma 1 Inf -Inf -> NaN Invalid_operation
+fmax3801 fma 1 Inf -1000 -> Infinity
+fmax3802 fma 1 Inf -1 -> Infinity
+fmax3803 fma 1 Inf -0 -> Infinity
+fmax3804 fma 1 Inf 0 -> Infinity
+fmax3805 fma 1 Inf 1 -> Infinity
+fmax3806 fma 1 Inf 1000 -> Infinity
+fmax3807 fma 1 Inf Inf -> Infinity
+fmax3808 fma 1 -1000 Inf -> Infinity
+fmax3809 fma 1 -Inf Inf -> NaN Invalid_operation
+fmax3810 fma 1 -1 Inf -> Infinity
+fmax3811 fma 1 -0 Inf -> Infinity
+fmax3812 fma 1 0 Inf -> Infinity
+fmax3813 fma 1 1 Inf -> Infinity
+fmax3814 fma 1 1000 Inf -> Infinity
+fmax3815 fma 1 Inf Inf -> Infinity
+
+fmax3821 fma 1 NaN -Inf -> NaN
+fmax3822 fma 1 NaN -1000 -> NaN
+fmax3823 fma 1 NaN -1 -> NaN
+fmax3824 fma 1 NaN -0 -> NaN
+fmax3825 fma 1 NaN 0 -> NaN
+fmax3826 fma 1 NaN 1 -> NaN
+fmax3827 fma 1 NaN 1000 -> NaN
+fmax3828 fma 1 NaN Inf -> NaN
+fmax3829 fma 1 NaN NaN -> NaN
+fmax3830 fma 1 -Inf NaN -> NaN
+fmax3831 fma 1 -1000 NaN -> NaN
+fmax3832 fma 1 -1 NaN -> NaN
+fmax3833 fma 1 -0 NaN -> NaN
+fmax3834 fma 1 0 NaN -> NaN
+fmax3835 fma 1 1 NaN -> NaN
+fmax3836 fma 1 1000 NaN -> NaN
+fmax3837 fma 1 Inf NaN -> NaN
+
+fmax3841 fma 1 sNaN -Inf -> NaN Invalid_operation
+fmax3842 fma 1 sNaN -1000 -> NaN Invalid_operation
+fmax3843 fma 1 sNaN -1 -> NaN Invalid_operation
+fmax3844 fma 1 sNaN -0 -> NaN Invalid_operation
+fmax3845 fma 1 sNaN 0 -> NaN Invalid_operation
+fmax3846 fma 1 sNaN 1 -> NaN Invalid_operation
+fmax3847 fma 1 sNaN 1000 -> NaN Invalid_operation
+fmax3848 fma 1 sNaN NaN -> NaN Invalid_operation
+fmax3849 fma 1 sNaN sNaN -> NaN Invalid_operation
+fmax3850 fma 1 NaN sNaN -> NaN Invalid_operation
+fmax3851 fma 1 -Inf sNaN -> NaN Invalid_operation
+fmax3852 fma 1 -1000 sNaN -> NaN Invalid_operation
+fmax3853 fma 1 -1 sNaN -> NaN Invalid_operation
+fmax3854 fma 1 -0 sNaN -> NaN Invalid_operation
+fmax3855 fma 1 0 sNaN -> NaN Invalid_operation
+fmax3856 fma 1 1 sNaN -> NaN Invalid_operation
+fmax3857 fma 1 1000 sNaN -> NaN Invalid_operation
+fmax3858 fma 1 Inf sNaN -> NaN Invalid_operation
+fmax3859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax3861 fma 1 NaN1 -Inf -> NaN1
+fmax3862 fma 1 +NaN2 -1000 -> NaN2
+fmax3863 fma 1 NaN3 1000 -> NaN3
+fmax3864 fma 1 NaN4 Inf -> NaN4
+fmax3865 fma 1 NaN5 +NaN6 -> NaN5
+fmax3866 fma 1 -Inf NaN7 -> NaN7
+fmax3867 fma 1 -1000 NaN8 -> NaN8
+fmax3868 fma 1 1000 NaN9 -> NaN9
+fmax3869 fma 1 Inf +NaN10 -> NaN10
+fmax3871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+fmax3872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+fmax3873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+fmax3874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+fmax3875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+fmax3876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+fmax3877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+fmax3878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+fmax3879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+fmax3880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+fmax3881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+fmax3882 fma 1 -NaN26 NaN28 -> -NaN26
+fmax3883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+fmax3884 fma 1 1000 -NaN30 -> -NaN30
+fmax3885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- overflow, underflow and subnormal tests
+maxexponent: 999999
+minexponent: -999999
+precision: 9
+fmax3890 fma 1 1E+999999 9E+999999 -> Infinity Overflow Inexact Rounded
+fmax3891 fma 1 9E+999999 1E+999999 -> Infinity Overflow Inexact Rounded
+fmax3892 fma 1 -1.1E-999999 1E-999999 -> -1E-1000000 Subnormal
+fmax3893 fma 1 1E-999999 -1.1e-999999 -> -1E-1000000 Subnormal
+fmax3894 fma 1 -1.0001E-999999 1E-999999 -> -1E-1000003 Subnormal
+fmax3895 fma 1 1E-999999 -1.0001e-999999 -> -1E-1000003 Subnormal
+fmax3896 fma 1 -1E+999999 -9E+999999 -> -Infinity Overflow Inexact Rounded
+fmax3897 fma 1 -9E+999999 -1E+999999 -> -Infinity Overflow Inexact Rounded
+fmax3898 fma 1 +1.1E-999999 -1E-999999 -> 1E-1000000 Subnormal
+fmax3899 fma 1 -1E-999999 +1.1e-999999 -> 1E-1000000 Subnormal
+fmax3900 fma 1 +1.0001E-999999 -1E-999999 -> 1E-1000003 Subnormal
+fmax3901 fma 1 -1E-999999 +1.0001e-999999 -> 1E-1000003 Subnormal
+fmax3902 fma 1 -1E+999999 +9E+999999 -> 8E+999999
+fmax3903 fma 1 -9E+999999 +1E+999999 -> -8E+999999
+
+precision: 3
+fmax3904 fma 1 0 -9.999E+999999 -> -Infinity Inexact Overflow Rounded
+fmax3905 fma 1 -9.999E+999999 0 -> -Infinity Inexact Overflow Rounded
+fmax3906 fma 1 0 9.999E+999999 -> Infinity Inexact Overflow Rounded
+fmax3907 fma 1 9.999E+999999 0 -> Infinity Inexact Overflow Rounded
+
+precision: 3
+maxexponent: 999
+minexponent: -999
+fmax3910 fma 1 1.00E-999 0 -> 1.00E-999
+fmax3911 fma 1 0.1E-999 0 -> 1E-1000 Subnormal
+fmax3912 fma 1 0.10E-999 0 -> 1.0E-1000 Subnormal
+fmax3913 fma 1 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
+fmax3914 fma 1 0.01E-999 0 -> 1E-1001 Subnormal
+-- next is rounded to Nmin
+fmax3915 fma 1 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
+fmax3916 fma 1 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3917 fma 1 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
+fmax3918 fma 1 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3919 fma 1 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3920 fma 1 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+fmax3930 fma 1 -1.00E-999 0 -> -1.00E-999
+fmax3931 fma 1 -0.1E-999 0 -> -1E-1000 Subnormal
+fmax3932 fma 1 -0.10E-999 0 -> -1.0E-1000 Subnormal
+fmax3933 fma 1 -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
+fmax3934 fma 1 -0.01E-999 0 -> -1E-1001 Subnormal
+-- next is rounded to Nmin
+fmax3935 fma 1 -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
+fmax3936 fma 1 -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3937 fma 1 -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
+fmax3938 fma 1 -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3939 fma 1 -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3940 fma 1 -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+-- some non-zero subnormal fma 1 s
+fmax3950 fma 1 1.00E-999 0.1E-999 -> 1.10E-999
+fmax3951 fma 1 0.1E-999 0.1E-999 -> 2E-1000 Subnormal
+fmax3952 fma 1 0.10E-999 0.1E-999 -> 2.0E-1000 Subnormal
+fmax3953 fma 1 0.100E-999 0.1E-999 -> 2.0E-1000 Subnormal Rounded
+fmax3954 fma 1 0.01E-999 0.1E-999 -> 1.1E-1000 Subnormal
+fmax3955 fma 1 0.999E-999 0.1E-999 -> 1.10E-999 Inexact Rounded
+fmax3956 fma 1 0.099E-999 0.1E-999 -> 2.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3957 fma 1 0.009E-999 0.1E-999 -> 1.1E-1000 Inexact Rounded Subnormal Underflow
+fmax3958 fma 1 0.001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3959 fma 1 0.0009E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3960 fma 1 0.0001E-999 0.1E-999 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+-- negatives...
+fmax3961 fma 1 1.00E-999 -0.1E-999 -> 9.0E-1000 Subnormal
+fmax3962 fma 1 0.1E-999 -0.1E-999 -> 0E-1000
+fmax3963 fma 1 0.10E-999 -0.1E-999 -> 0E-1001
+fmax3964 fma 1 0.100E-999 -0.1E-999 -> 0E-1001 Clamped
+fmax3965 fma 1 0.01E-999 -0.1E-999 -> -9E-1001 Subnormal
+fmax3966 fma 1 0.999E-999 -0.1E-999 -> 9.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3967 fma 1 0.099E-999 -0.1E-999 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+fmax3968 fma 1 0.009E-999 -0.1E-999 -> -9E-1001 Inexact Rounded Subnormal Underflow
+fmax3969 fma 1 0.001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3970 fma 1 0.0009E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+fmax3971 fma 1 0.0001E-999 -0.1E-999 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+
+-- some 'real' numbers
+maxExponent: 384
+minExponent: -383
+precision: 8
+fmax3566 fma 1 99999061735E-394 0E-394 -> 9.999906E-384 Inexact Rounded Underflow Subnormal
+precision: 7
+fmax3567 fma 1 99999061735E-394 0E-394 -> 9.99991E-384 Inexact Rounded Underflow Subnormal
+precision: 6
+fmax3568 fma 1 99999061735E-394 0E-394 -> 9.9999E-384 Inexact Rounded Underflow Subnormal
+
+-- now the case where we can get underflow but the result is normal
+-- [note this can't happen if the operands are also bounded, as we
+-- cannot represent 1E-399, for example]
+precision: 16
+rounding: half_up
+maxExponent: 384
+minExponent: -383
+
+fmax3571 fma 1 1E-383 0 -> 1E-383
+fmax3572 fma 1 1E-384 0 -> 1E-384 Subnormal
+fmax3573 fma 1 1E-383 1E-384 -> 1.1E-383
+fmax3574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
+
+-- Here we explore the boundary of rounding a subnormal to Nmin
+fmax3575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax3576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax3577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax3580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- check for double-rounded subnormals
+precision: 5
+maxexponent: 79
+minexponent: -79
+-- Add: lhs and rhs 0
+fmax31001 fma 1 1.52444E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31002 fma 1 1.52445E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31003 fma 1 1.52446E-80 0 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31004 fma 1 0 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31005 fma 1 0 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31006 fma 1 0 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+
+-- Add: lhs >> rhs and vice versa
+fmax31011 fma 1 1.52444E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31012 fma 1 1.52445E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31013 fma 1 1.52446E-80 1E-100 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31014 fma 1 1E-100 1.52444E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31015 fma 1 1E-100 1.52445E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+fmax31016 fma 1 1E-100 1.52446E-80 -> 1.524E-80 Inexact Rounded Subnormal Underflow
+
+-- Add: lhs + rhs fma 1 ition carried out
+fmax31021 fma 1 1.52443E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31022 fma 1 1.52444E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31023 fma 1 1.52445E-80 1.00001E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31024 fma 1 1.00001E-80 1.52443E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31025 fma 1 1.00001E-80 1.52444E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+fmax31026 fma 1 1.00001E-80 1.52445E-80 -> 2.524E-80 Inexact Rounded Subnormal Underflow
+
+-- And for round down full and subnormal results
+precision: 16
+maxExponent: +384
+minExponent: -383
+rounding: down
+
+fmax31100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+fmax31101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+fmax31103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+fmax31104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+fmax31105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+fmax31106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+fmax31107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+fmax31108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+fmax31109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+fmax31110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+fmax31111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+fmax31113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+fmax31114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+fmax31115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+fmax31116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+fmax31117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+fmax31118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+fmax31119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+rounding: down
+precision: 7
+maxExponent: +96
+minExponent: -95
+fmax31130 fma 1 1 -1e-200 -> 0.9999999 Rounded Inexact
+-- subnormal boundary
+fmax31131 fma 1 1.000000E-94 -1e-200 -> 9.999999E-95 Rounded Inexact
+fmax31132 fma 1 1.000001E-95 -1e-200 -> 1.000000E-95 Rounded Inexact
+fmax31133 fma 1 1.000000E-95 -1e-200 -> 9.99999E-96 Rounded Inexact Subnormal Underflow
+fmax31134 fma 1 0.999999E-95 -1e-200 -> 9.99998E-96 Rounded Inexact Subnormal Underflow
+fmax31135 fma 1 0.001000E-95 -1e-200 -> 9.99E-99 Rounded Inexact Subnormal Underflow
+fmax31136 fma 1 0.000999E-95 -1e-200 -> 9.98E-99 Rounded Inexact Subnormal Underflow
+fmax31137 fma 1 1.000000E-95 -1e-101 -> 9.99999E-96 Subnormal
+fmax31138 fma 1 10000E-101 -1e-200 -> 9.999E-98 Subnormal Inexact Rounded Underflow
+fmax31139 fma 1 1000E-101 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
+fmax31140 fma 1 100E-101 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
+fmax31141 fma 1 10E-101 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
+fmax31142 fma 1 1E-101 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31143 fma 1 0E-101 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31144 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+fmax31151 fma 1 10000E-102 -1e-200 -> 9.99E-99 Subnormal Inexact Rounded Underflow
+fmax31152 fma 1 1000E-102 -1e-200 -> 9.9E-100 Subnormal Inexact Rounded Underflow
+fmax31153 fma 1 100E-102 -1e-200 -> 9E-101 Subnormal Inexact Rounded Underflow
+fmax31154 fma 1 10E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31155 fma 1 1E-102 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31156 fma 1 0E-102 -1e-200 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31157 fma 1 1E-103 -1e-200 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+fmax31160 fma 1 100E-105 -1e-101 -> -0E-101 Subnormal Inexact Rounded Underflow Clamped
+fmax31161 fma 1 100E-105 -1e-201 -> 0E-101 Subnormal Inexact Rounded Underflow Clamped
+
+-- tests based on Gunnar Degnbol's edge case
+precision: 15
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+fmax31200 fma 1 1E15 -0.5 -> 1.00000000000000E+15 Inexact Rounded
+fmax31201 fma 1 1E15 -0.50 -> 1.00000000000000E+15 Inexact Rounded
+fmax31210 fma 1 1E15 -0.51 -> 999999999999999 Inexact Rounded
+fmax31211 fma 1 1E15 -0.501 -> 999999999999999 Inexact Rounded
+fmax31212 fma 1 1E15 -0.5001 -> 999999999999999 Inexact Rounded
+fmax31213 fma 1 1E15 -0.50001 -> 999999999999999 Inexact Rounded
+fmax31214 fma 1 1E15 -0.500001 -> 999999999999999 Inexact Rounded
+fmax31215 fma 1 1E15 -0.5000001 -> 999999999999999 Inexact Rounded
+fmax31216 fma 1 1E15 -0.50000001 -> 999999999999999 Inexact Rounded
+fmax31217 fma 1 1E15 -0.500000001 -> 999999999999999 Inexact Rounded
+fmax31218 fma 1 1E15 -0.5000000001 -> 999999999999999 Inexact Rounded
+fmax31219 fma 1 1E15 -0.50000000001 -> 999999999999999 Inexact Rounded
+fmax31220 fma 1 1E15 -0.500000000001 -> 999999999999999 Inexact Rounded
+fmax31221 fma 1 1E15 -0.5000000000001 -> 999999999999999 Inexact Rounded
+fmax31222 fma 1 1E15 -0.50000000000001 -> 999999999999999 Inexact Rounded
+fmax31223 fma 1 1E15 -0.500000000000001 -> 999999999999999 Inexact Rounded
+fmax31224 fma 1 1E15 -0.5000000000000001 -> 999999999999999 Inexact Rounded
+fmax31225 fma 1 1E15 -0.5000000000000000 -> 1.00000000000000E+15 Inexact Rounded
+fmax31230 fma 1 1E15 -5000000.000000001 -> 999999995000000 Inexact Rounded
+
+precision: 16
+
+fmax31300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax31310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+fmax31311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+fmax31312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+fmax31313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+fmax31314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+fmax31315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+fmax31316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+fmax31317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+fmax31318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+fmax31319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+fmax31320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+fmax31321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+fmax31322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+fmax31323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+fmax31324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+fmax31325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax31339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+fmax31340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+fmax31341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+fmax31349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+fmax31350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+fmax31351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+fmax31352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+fmax31353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+fmax31354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+fmax31355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+fmax31356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+fmax31357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+fmax31358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+fmax31359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+fmax31360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+fmax31361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+fmax31362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+fmax31363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+fmax31364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+fmax31365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax31379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax31380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+fmax31381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax31382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+fmax31395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+fmax31396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+precision: 15
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+fmax31400 fma 1 0 1.23456789012345 -> 1.23456789012345
+fmax31401 fma 1 0 1.23456789012345E-1 -> 0.123456789012345
+fmax31402 fma 1 0 1.23456789012345E-2 -> 0.0123456789012345
+fmax31403 fma 1 0 1.23456789012345E-3 -> 0.00123456789012345
+fmax31404 fma 1 0 1.23456789012345E-4 -> 0.000123456789012345
+fmax31405 fma 1 0 1.23456789012345E-5 -> 0.0000123456789012345
+fmax31406 fma 1 0 1.23456789012345E-6 -> 0.00000123456789012345
+fmax31407 fma 1 0 1.23456789012345E-7 -> 1.23456789012345E-7
+fmax31408 fma 1 0 1.23456789012345E-8 -> 1.23456789012345E-8
+fmax31409 fma 1 0 1.23456789012345E-9 -> 1.23456789012345E-9
+fmax31410 fma 1 0 1.23456789012345E-10 -> 1.23456789012345E-10
+fmax31411 fma 1 0 1.23456789012345E-11 -> 1.23456789012345E-11
+fmax31412 fma 1 0 1.23456789012345E-12 -> 1.23456789012345E-12
+fmax31413 fma 1 0 1.23456789012345E-13 -> 1.23456789012345E-13
+fmax31414 fma 1 0 1.23456789012345E-14 -> 1.23456789012345E-14
+fmax31415 fma 1 0 1.23456789012345E-15 -> 1.23456789012345E-15
+fmax31416 fma 1 0 1.23456789012345E-16 -> 1.23456789012345E-16
+fmax31417 fma 1 0 1.23456789012345E-17 -> 1.23456789012345E-17
+fmax31418 fma 1 0 1.23456789012345E-18 -> 1.23456789012345E-18
+fmax31419 fma 1 0 1.23456789012345E-19 -> 1.23456789012345E-19
+
+-- same, precision 16..
+precision: 16
+fmax31420 fma 1 0 1.123456789012345 -> 1.123456789012345
+fmax31421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+fmax31422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+fmax31423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+fmax31424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+fmax31425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+fmax31426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+fmax31427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+fmax31428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+fmax31429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+fmax31430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+fmax31431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+fmax31432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+fmax31433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+fmax31434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+fmax31435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+fmax31436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+fmax31437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+fmax31438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+fmax31439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+fmax31440 fma 1 1.123456789012345 0 -> 1.123456789012345
+fmax31441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+fmax31442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+fmax31443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+fmax31444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+fmax31445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+fmax31446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+fmax31447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+fmax31448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+fmax31449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+fmax31450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+fmax31451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+fmax31452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+fmax31453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+fmax31454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+fmax31455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+fmax31456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+fmax31457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+fmax31458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+fmax31459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+fmax31460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+fmax31461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+fmax31462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+fmax31463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+fmax31464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+fmax31465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+fmax31466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+fmax31467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+fmax31468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+fmax31469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+fmax31470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+fmax31471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+fmax31472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+fmax31473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+fmax31474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+fmax31475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+fmax31476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+fmax31477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+fmax31478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+fmax31479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+precision: 16
+maxExponent: 384
+minexponent: -383
+
+rounding: half_up
+-- exact zeros from zeros
+fmax31500 fma 1 0 0E-19 -> 0E-19
+fmax31501 fma 1 -0 0E-19 -> 0E-19
+fmax31502 fma 1 0 -0E-19 -> 0E-19
+fmax31503 fma 1 -0 -0E-19 -> -0E-19
+fmax31504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_down
+-- exact zeros from zeros
+fmax31520 fma 1 0 0E-19 -> 0E-19
+fmax31521 fma 1 -0 0E-19 -> 0E-19
+fmax31522 fma 1 0 -0E-19 -> 0E-19
+fmax31523 fma 1 -0 -0E-19 -> -0E-19
+fmax31524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_even
+-- exact zeros from zeros
+fmax31540 fma 1 0 0E-19 -> 0E-19
+fmax31541 fma 1 -0 0E-19 -> 0E-19
+fmax31542 fma 1 0 -0E-19 -> 0E-19
+fmax31543 fma 1 -0 -0E-19 -> -0E-19
+fmax31544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: up
+-- exact zeros from zeros
+fmax31560 fma 1 0 0E-19 -> 0E-19
+fmax31561 fma 1 -0 0E-19 -> 0E-19
+fmax31562 fma 1 0 -0E-19 -> 0E-19
+fmax31563 fma 1 -0 -0E-19 -> -0E-19
+fmax31564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax31574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax31575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+rounding: down
+-- exact zeros from zeros
+fmax31580 fma 1 0 0E-19 -> 0E-19
+fmax31581 fma 1 -0 0E-19 -> 0E-19
+fmax31582 fma 1 0 -0E-19 -> 0E-19
+fmax31583 fma 1 -0 -0E-19 -> -0E-19
+fmax31584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: ceiling
+-- exact zeros from zeros
+fmax31600 fma 1 0 0E-19 -> 0E-19
+fmax31601 fma 1 -0 0E-19 -> 0E-19
+fmax31602 fma 1 0 -0E-19 -> 0E-19
+fmax31603 fma 1 -0 -0E-19 -> -0E-19
+fmax31604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax31606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax31607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax31615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax31616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax31617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax31618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+fmax31620 fma 1 0 0E-19 -> 0E-19
+fmax31621 fma 1 -0 0E-19 -> -0E-19 -- *
+fmax31622 fma 1 0 -0E-19 -> -0E-19 -- *
+fmax31623 fma 1 -0 -0E-19 -> -0E-19
+fmax31624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax31625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
+fmax31626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
+fmax31627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax31631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax31634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax31635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax31636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
+fmax31637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
+fmax31638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+-- BigDecimal problem testcases 2006.01.23
+precision: 16
+maxExponent: 384
+minexponent: -383
+
+rounding: down
+precision: 7
+fmax31651 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31652 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31653 fma 1 10001E+2 -2E+1 -> 1.0000E+6 Inexact Rounded
+precision: 4
+fmax31654 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
+precision: 3
+fmax31655 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
+precision: 2
+fmax31656 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
+precision: 1
+fmax31657 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
+
+rounding: half_even
+precision: 7
+fmax31661 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31662 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31663 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
+precision: 4
+fmax31664 fma 1 10001E+2 -2E+1 -> 1.000E+6 Inexact Rounded
+precision: 3
+fmax31665 fma 1 10001E+2 -2E+1 -> 1.00E+6 Inexact Rounded
+precision: 2
+fmax31666 fma 1 10001E+2 -2E+1 -> 1.0E+6 Inexact Rounded
+precision: 1
+fmax31667 fma 1 10001E+2 -2E+1 -> 1E+6 Inexact Rounded
+
+rounding: up
+precision: 7
+fmax31671 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 6
+fmax31672 fma 1 10001E+2 -2E+1 -> 1.00008E+6
+precision: 5
+fmax31673 fma 1 10001E+2 -2E+1 -> 1.0001E+6 Inexact Rounded
+precision: 4
+fmax31674 fma 1 10001E+2 -2E+1 -> 1.001E+6 Inexact Rounded
+precision: 3
+fmax31675 fma 1 10001E+2 -2E+1 -> 1.01E+6 Inexact Rounded
+precision: 2
+fmax31676 fma 1 10001E+2 -2E+1 -> 1.1E+6 Inexact Rounded
+precision: 1
+fmax31677 fma 1 10001E+2 -2E+1 -> 2E+6 Inexact Rounded
+
+precision: 34
+rounding: half_up
+maxExponent: 6144
+minExponent: -6143
+-- Examples from SQL proposal (Krishna Kulkarni)
+fmax31701 fma 1 130E-2 120E-2 -> 2.50
+fmax31702 fma 1 130E-2 12E-1 -> 2.50
+fmax31703 fma 1 130E-2 1E0 -> 2.30
+fmax31704 fma 1 1E2 1E4 -> 1.01E+4
+fmax31705 subtract 130E-2 120E-2 -> 0.10
+fmax31706 subtract 130E-2 12E-1 -> 0.10
+fmax31707 subtract 130E-2 1E0 -> 0.30
+fmax31708 subtract 1E2 1E4 -> -9.9E+3
+
+------------------------------------------------------------------------
+-- Same as above, using decimal64 default parameters --
+------------------------------------------------------------------------
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- [first group are 'quick confidence check']
+fmax36001 fma 1 1 1 -> 2
+fmax36002 fma 1 2 3 -> 5
+fmax36003 fma 1 '5.75' '3.3' -> 9.05
+fmax36004 fma 1 '5' '-3' -> 2
+fmax36005 fma 1 '-5' '-3' -> -8
+fmax36006 fma 1 '-7' '2.5' -> -4.5
+fmax36007 fma 1 '0.7' '0.3' -> 1.0
+fmax36008 fma 1 '1.25' '1.25' -> 2.50
+fmax36009 fma 1 '1.23456789' '1.00000000' -> '2.23456789'
+fmax36010 fma 1 '1.23456789' '1.00000011' -> '2.23456800'
+
+fmax36011 fma 1 '0.44444444444444444' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
+fmax36012 fma 1 '0.44444444444444440' '0.55555555555555555' -> '1.000000000000000' Inexact Rounded
+fmax36013 fma 1 '0.44444444444444444' '0.55555555555555550' -> '0.9999999999999999' Inexact Rounded
+fmax36014 fma 1 '0.444444444444444449' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36015 fma 1 '0.4444444444444444499' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36016 fma 1 '0.44444444444444444999' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36017 fma 1 '0.44444444444444445000' '0' -> '0.4444444444444444' Inexact Rounded
+fmax36018 fma 1 '0.44444444444444445001' '0' -> '0.4444444444444445' Inexact Rounded
+fmax36019 fma 1 '0.4444444444444444501' '0' -> '0.4444444444444445' Inexact Rounded
+fmax36020 fma 1 '0.444444444444444451' '0' -> '0.4444444444444445' Inexact Rounded
+
+fmax36021 fma 1 0 1 -> 1
+fmax36022 fma 1 1 1 -> 2
+fmax36023 fma 1 2 1 -> 3
+fmax36024 fma 1 3 1 -> 4
+fmax36025 fma 1 4 1 -> 5
+fmax36026 fma 1 5 1 -> 6
+fmax36027 fma 1 6 1 -> 7
+fmax36028 fma 1 7 1 -> 8
+fmax36029 fma 1 8 1 -> 9
+fmax36030 fma 1 9 1 -> 10
+
+-- some carrying effects
+fmax36031 fma 1 '0.9998' '0.0000' -> '0.9998'
+fmax36032 fma 1 '0.9998' '0.0001' -> '0.9999'
+fmax36033 fma 1 '0.9998' '0.0002' -> '1.0000'
+fmax36034 fma 1 '0.9998' '0.0003' -> '1.0001'
+
+fmax36035 fma 1 '70' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36036 fma 1 '700' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36037 fma 1 '7000' '10000e+16' -> '1.000000000000000E+20' Inexact Rounded
+fmax36038 fma 1 '70000' '10000e+16' -> '1.000000000000001E+20' Inexact Rounded
+fmax36039 fma 1 '700000' '10000e+16' -> '1.000000000000007E+20' Rounded
+
+-- symmetry:
+fmax36040 fma 1 '10000e+16' '70' -> '1.000000000000000E+20' Inexact Rounded
+fmax36041 fma 1 '10000e+16' '700' -> '1.000000000000000E+20' Inexact Rounded
+fmax36042 fma 1 '10000e+16' '7000' -> '1.000000000000000E+20' Inexact Rounded
+fmax36044 fma 1 '10000e+16' '70000' -> '1.000000000000001E+20' Inexact Rounded
+fmax36045 fma 1 '10000e+16' '700000' -> '1.000000000000007E+20' Rounded
+
+fmax36046 fma 1 '10000e+9' '7' -> '10000000000007'
+fmax36047 fma 1 '10000e+9' '70' -> '10000000000070'
+fmax36048 fma 1 '10000e+9' '700' -> '10000000000700'
+fmax36049 fma 1 '10000e+9' '7000' -> '10000000007000'
+fmax36050 fma 1 '10000e+9' '70000' -> '10000000070000'
+fmax36051 fma 1 '10000e+9' '700000' -> '10000000700000'
+
+-- examples from decarith
+fmax36053 fma 1 '12' '7.00' -> '19.00'
+fmax36054 fma 1 '1.3' '-1.07' -> '0.23'
+fmax36055 fma 1 '1.3' '-1.30' -> '0.00'
+fmax36056 fma 1 '1.3' '-2.07' -> '-0.77'
+fmax36057 fma 1 '1E+2' '1E+4' -> '1.01E+4'
+
+-- from above
+fmax36061 fma 1 1 '0.1' -> '1.1'
+fmax36062 fma 1 1 '0.01' -> '1.01'
+fmax36063 fma 1 1 '0.001' -> '1.001'
+fmax36064 fma 1 1 '0.0001' -> '1.0001'
+fmax36065 fma 1 1 '0.00001' -> '1.00001'
+fmax36066 fma 1 1 '0.000001' -> '1.000001'
+fmax36067 fma 1 1 '0.0000001' -> '1.0000001'
+fmax36068 fma 1 1 '0.00000001' -> '1.00000001'
+
+-- some funny zeros [in case of bad signum]
+fmax36070 fma 1 1 0 -> 1
+fmax36071 fma 1 1 0. -> 1
+fmax36072 fma 1 1 .0 -> 1.0
+fmax36073 fma 1 1 0.0 -> 1.0
+fmax36074 fma 1 1 0.00 -> 1.00
+fmax36075 fma 1 0 1 -> 1
+fmax36076 fma 1 0. 1 -> 1
+fmax36077 fma 1 .0 1 -> 1.0
+fmax36078 fma 1 0.0 1 -> 1.0
+fmax36079 fma 1 0.00 1 -> 1.00
+
+-- some carries
+fmax36080 fma 1 9999999999999998 1 -> 9999999999999999
+fmax36081 fma 1 9999999999999999 1 -> 1.000000000000000E+16 Rounded
+fmax36082 fma 1 999999999999999 1 -> 1000000000000000
+fmax36083 fma 1 9999999999999 1 -> 10000000000000
+fmax36084 fma 1 99999999999 1 -> 100000000000
+fmax36085 fma 1 999999999 1 -> 1000000000
+fmax36086 fma 1 9999999 1 -> 10000000
+fmax36087 fma 1 99999 1 -> 100000
+fmax36088 fma 1 999 1 -> 1000
+fmax36089 fma 1 9 1 -> 10
+
+
+-- more LHS swaps
+fmax36090 fma 1 '-56267E-10' 0 -> '-0.0000056267'
+fmax36091 fma 1 '-56267E-6' 0 -> '-0.056267'
+fmax36092 fma 1 '-56267E-5' 0 -> '-0.56267'
+fmax36093 fma 1 '-56267E-4' 0 -> '-5.6267'
+fmax36094 fma 1 '-56267E-3' 0 -> '-56.267'
+fmax36095 fma 1 '-56267E-2' 0 -> '-562.67'
+fmax36096 fma 1 '-56267E-1' 0 -> '-5626.7'
+fmax36097 fma 1 '-56267E-0' 0 -> '-56267'
+fmax36098 fma 1 '-5E-10' 0 -> '-5E-10'
+fmax36099 fma 1 '-5E-7' 0 -> '-5E-7'
+fmax36100 fma 1 '-5E-6' 0 -> '-0.000005'
+fmax36101 fma 1 '-5E-5' 0 -> '-0.00005'
+fmax36102 fma 1 '-5E-4' 0 -> '-0.0005'
+fmax36103 fma 1 '-5E-1' 0 -> '-0.5'
+fmax36104 fma 1 '-5E0' 0 -> '-5'
+fmax36105 fma 1 '-5E1' 0 -> '-50'
+fmax36106 fma 1 '-5E5' 0 -> '-500000'
+fmax36107 fma 1 '-5E15' 0 -> '-5000000000000000'
+fmax36108 fma 1 '-5E16' 0 -> '-5.000000000000000E+16' Rounded
+fmax36109 fma 1 '-5E17' 0 -> '-5.000000000000000E+17' Rounded
+fmax36110 fma 1 '-5E18' 0 -> '-5.000000000000000E+18' Rounded
+fmax36111 fma 1 '-5E100' 0 -> '-5.000000000000000E+100' Rounded
+
+-- more RHS swaps
+fmax36113 fma 1 0 '-56267E-10' -> '-0.0000056267'
+fmax36114 fma 1 0 '-56267E-6' -> '-0.056267'
+fmax36116 fma 1 0 '-56267E-5' -> '-0.56267'
+fmax36117 fma 1 0 '-56267E-4' -> '-5.6267'
+fmax36119 fma 1 0 '-56267E-3' -> '-56.267'
+fmax36120 fma 1 0 '-56267E-2' -> '-562.67'
+fmax36121 fma 1 0 '-56267E-1' -> '-5626.7'
+fmax36122 fma 1 0 '-56267E-0' -> '-56267'
+fmax36123 fma 1 0 '-5E-10' -> '-5E-10'
+fmax36124 fma 1 0 '-5E-7' -> '-5E-7'
+fmax36125 fma 1 0 '-5E-6' -> '-0.000005'
+fmax36126 fma 1 0 '-5E-5' -> '-0.00005'
+fmax36127 fma 1 0 '-5E-4' -> '-0.0005'
+fmax36128 fma 1 0 '-5E-1' -> '-0.5'
+fmax36129 fma 1 0 '-5E0' -> '-5'
+fmax36130 fma 1 0 '-5E1' -> '-50'
+fmax36131 fma 1 0 '-5E5' -> '-500000'
+fmax36132 fma 1 0 '-5E15' -> '-5000000000000000'
+fmax36133 fma 1 0 '-5E16' -> '-5.000000000000000E+16' Rounded
+fmax36134 fma 1 0 '-5E17' -> '-5.000000000000000E+17' Rounded
+fmax36135 fma 1 0 '-5E18' -> '-5.000000000000000E+18' Rounded
+fmax36136 fma 1 0 '-5E100' -> '-5.000000000000000E+100' Rounded
+
+-- related
+fmax36137 fma 1 1 '0E-19' -> '1.000000000000000' Rounded
+fmax36138 fma 1 -1 '0E-19' -> '-1.000000000000000' Rounded
+fmax36139 fma 1 '0E-19' 1 -> '1.000000000000000' Rounded
+fmax36140 fma 1 '0E-19' -1 -> '-1.000000000000000' Rounded
+fmax36141 fma 1 1E+11 0.0000 -> '100000000000.0000'
+fmax36142 fma 1 1E+11 0.00000 -> '100000000000.0000' Rounded
+fmax36143 fma 1 0.000 1E+12 -> '1000000000000.000'
+fmax36144 fma 1 0.0000 1E+12 -> '1000000000000.000' Rounded
+
+-- [some of the next group are really constructor tests]
+fmax36146 fma 1 '00.0' 0 -> '0.0'
+fmax36147 fma 1 '0.00' 0 -> '0.00'
+fmax36148 fma 1 0 '0.00' -> '0.00'
+fmax36149 fma 1 0 '00.0' -> '0.0'
+fmax36150 fma 1 '00.0' '0.00' -> '0.00'
+fmax36151 fma 1 '0.00' '00.0' -> '0.00'
+fmax36152 fma 1 '3' '.3' -> '3.3'
+fmax36153 fma 1 '3.' '.3' -> '3.3'
+fmax36154 fma 1 '3.0' '.3' -> '3.3'
+fmax36155 fma 1 '3.00' '.3' -> '3.30'
+fmax36156 fma 1 '3' '3' -> '6'
+fmax36157 fma 1 '3' '+3' -> '6'
+fmax36158 fma 1 '3' '-3' -> '0'
+fmax36159 fma 1 '0.3' '-0.3' -> '0.0'
+fmax36160 fma 1 '0.03' '-0.03' -> '0.00'
+
+-- try borderline precision, with carries, etc.
+fmax36161 fma 1 '1E+13' '-1' -> '9999999999999'
+fmax36162 fma 1 '1E+13' '1.11' -> '10000000000001.11'
+fmax36163 fma 1 '1.11' '1E+13' -> '10000000000001.11'
+fmax36164 fma 1 '-1' '1E+13' -> '9999999999999'
+fmax36165 fma 1 '7E+13' '-1' -> '69999999999999'
+fmax36166 fma 1 '7E+13' '1.11' -> '70000000000001.11'
+fmax36167 fma 1 '1.11' '7E+13' -> '70000000000001.11'
+fmax36168 fma 1 '-1' '7E+13' -> '69999999999999'
+
+-- 1234567890123456 1234567890123456 1 234567890123456
+fmax36170 fma 1 '0.4444444444444444' '0.5555555555555563' -> '1.000000000000001' Inexact Rounded
+fmax36171 fma 1 '0.4444444444444444' '0.5555555555555562' -> '1.000000000000001' Inexact Rounded
+fmax36172 fma 1 '0.4444444444444444' '0.5555555555555561' -> '1.000000000000000' Inexact Rounded
+fmax36173 fma 1 '0.4444444444444444' '0.5555555555555560' -> '1.000000000000000' Inexact Rounded
+fmax36174 fma 1 '0.4444444444444444' '0.5555555555555559' -> '1.000000000000000' Inexact Rounded
+fmax36175 fma 1 '0.4444444444444444' '0.5555555555555558' -> '1.000000000000000' Inexact Rounded
+fmax36176 fma 1 '0.4444444444444444' '0.5555555555555557' -> '1.000000000000000' Inexact Rounded
+fmax36177 fma 1 '0.4444444444444444' '0.5555555555555556' -> '1.000000000000000' Rounded
+fmax36178 fma 1 '0.4444444444444444' '0.5555555555555555' -> '0.9999999999999999'
+fmax36179 fma 1 '0.4444444444444444' '0.5555555555555554' -> '0.9999999999999998'
+fmax36180 fma 1 '0.4444444444444444' '0.5555555555555553' -> '0.9999999999999997'
+fmax36181 fma 1 '0.4444444444444444' '0.5555555555555552' -> '0.9999999999999996'
+fmax36182 fma 1 '0.4444444444444444' '0.5555555555555551' -> '0.9999999999999995'
+fmax36183 fma 1 '0.4444444444444444' '0.5555555555555550' -> '0.9999999999999994'
+
+-- and some more, including residue effects and different roundings
+rounding: half_up
+fmax36200 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36201 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36202 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36203 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36204 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36205 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36206 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36207 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36208 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+fmax36209 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+fmax36210 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+fmax36211 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+fmax36212 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+fmax36213 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+fmax36214 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+fmax36215 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
+fmax36216 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36217 fma 1 '6543210123456789' 1.000000001 -> '6543210123456790' Inexact Rounded
+fmax36218 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36219 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+rounding: half_even
+fmax36220 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36221 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36222 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36223 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36224 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36225 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36226 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36227 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36228 fma 1 '6543210123456789' 0.5 -> '6543210123456790' Inexact Rounded
+fmax36229 fma 1 '6543210123456789' 0.500000001 -> '6543210123456790' Inexact Rounded
+fmax36230 fma 1 '6543210123456789' 0.500001 -> '6543210123456790' Inexact Rounded
+fmax36231 fma 1 '6543210123456789' 0.51 -> '6543210123456790' Inexact Rounded
+fmax36232 fma 1 '6543210123456789' 0.6 -> '6543210123456790' Inexact Rounded
+fmax36233 fma 1 '6543210123456789' 0.9 -> '6543210123456790' Inexact Rounded
+fmax36234 fma 1 '6543210123456789' 0.99999 -> '6543210123456790' Inexact Rounded
+fmax36235 fma 1 '6543210123456789' 0.999999 -> '6543210123456790' Inexact Rounded
+fmax36236 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36237 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+fmax36238 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36239 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+-- critical few with even bottom digit...
+fmax36240 fma 1 '6543210123456788' 0.499999 -> '6543210123456788' Inexact Rounded
+fmax36241 fma 1 '6543210123456788' 0.5 -> '6543210123456788' Inexact Rounded
+fmax36242 fma 1 '6543210123456788' 0.500000001 -> '6543210123456789' Inexact Rounded
+
+rounding: down
+fmax36250 fma 1 '6543210123456789' 0 -> '6543210123456789'
+fmax36251 fma 1 '6543210123456789' 0.000000001 -> '6543210123456789' Inexact Rounded
+fmax36252 fma 1 '6543210123456789' 0.000001 -> '6543210123456789' Inexact Rounded
+fmax36253 fma 1 '6543210123456789' 0.1 -> '6543210123456789' Inexact Rounded
+fmax36254 fma 1 '6543210123456789' 0.4 -> '6543210123456789' Inexact Rounded
+fmax36255 fma 1 '6543210123456789' 0.49 -> '6543210123456789' Inexact Rounded
+fmax36256 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36257 fma 1 '6543210123456789' 0.499999 -> '6543210123456789' Inexact Rounded
+fmax36258 fma 1 '6543210123456789' 0.5 -> '6543210123456789' Inexact Rounded
+fmax36259 fma 1 '6543210123456789' 0.500000001 -> '6543210123456789' Inexact Rounded
+fmax36260 fma 1 '6543210123456789' 0.500001 -> '6543210123456789' Inexact Rounded
+fmax36261 fma 1 '6543210123456789' 0.51 -> '6543210123456789' Inexact Rounded
+fmax36262 fma 1 '6543210123456789' 0.6 -> '6543210123456789' Inexact Rounded
+fmax36263 fma 1 '6543210123456789' 0.9 -> '6543210123456789' Inexact Rounded
+fmax36264 fma 1 '6543210123456789' 0.99999 -> '6543210123456789' Inexact Rounded
+fmax36265 fma 1 '6543210123456789' 0.999999 -> '6543210123456789' Inexact Rounded
+fmax36266 fma 1 '6543210123456789' 1 -> '6543210123456790'
+fmax36267 fma 1 '6543210123456789' 1.00000001 -> '6543210123456790' Inexact Rounded
+fmax36268 fma 1 '6543210123456789' 1.00001 -> '6543210123456790' Inexact Rounded
+fmax36269 fma 1 '6543210123456789' 1.1 -> '6543210123456790' Inexact Rounded
+
+-- 1 in last place tests
+rounding: half_even
+fmax36301 fma 1 -1 1 -> 0
+fmax36302 fma 1 0 1 -> 1
+fmax36303 fma 1 1 1 -> 2
+fmax36304 fma 1 12 1 -> 13
+fmax36305 fma 1 98 1 -> 99
+fmax36306 fma 1 99 1 -> 100
+fmax36307 fma 1 100 1 -> 101
+fmax36308 fma 1 101 1 -> 102
+fmax36309 fma 1 -1 -1 -> -2
+fmax36310 fma 1 0 -1 -> -1
+fmax36311 fma 1 1 -1 -> 0
+fmax36312 fma 1 12 -1 -> 11
+fmax36313 fma 1 98 -1 -> 97
+fmax36314 fma 1 99 -1 -> 98
+fmax36315 fma 1 100 -1 -> 99
+fmax36316 fma 1 101 -1 -> 100
+
+fmax36321 fma 1 -0.01 0.01 -> 0.00
+fmax36322 fma 1 0.00 0.01 -> 0.01
+fmax36323 fma 1 0.01 0.01 -> 0.02
+fmax36324 fma 1 0.12 0.01 -> 0.13
+fmax36325 fma 1 0.98 0.01 -> 0.99
+fmax36326 fma 1 0.99 0.01 -> 1.00
+fmax36327 fma 1 1.00 0.01 -> 1.01
+fmax36328 fma 1 1.01 0.01 -> 1.02
+fmax36329 fma 1 -0.01 -0.01 -> -0.02
+fmax36330 fma 1 0.00 -0.01 -> -0.01
+fmax36331 fma 1 0.01 -0.01 -> 0.00
+fmax36332 fma 1 0.12 -0.01 -> 0.11
+fmax36333 fma 1 0.98 -0.01 -> 0.97
+fmax36334 fma 1 0.99 -0.01 -> 0.98
+fmax36335 fma 1 1.00 -0.01 -> 0.99
+fmax36336 fma 1 1.01 -0.01 -> 1.00
+
+-- some more cases where fma 1 ing 0 affects the coefficient
+fmax36340 fma 1 1E+3 0 -> 1000
+fmax36341 fma 1 1E+15 0 -> 1000000000000000
+fmax36342 fma 1 1E+16 0 -> 1.000000000000000E+16 Rounded
+fmax36343 fma 1 1E+17 0 -> 1.000000000000000E+17 Rounded
+-- which simply follow from these cases ...
+fmax36344 fma 1 1E+3 1 -> 1001
+fmax36345 fma 1 1E+15 1 -> 1000000000000001
+fmax36346 fma 1 1E+16 1 -> 1.000000000000000E+16 Inexact Rounded
+fmax36347 fma 1 1E+17 1 -> 1.000000000000000E+17 Inexact Rounded
+fmax36348 fma 1 1E+3 7 -> 1007
+fmax36349 fma 1 1E+15 7 -> 1000000000000007
+fmax36350 fma 1 1E+16 7 -> 1.000000000000001E+16 Inexact Rounded
+fmax36351 fma 1 1E+17 7 -> 1.000000000000000E+17 Inexact Rounded
+
+-- tryzeros cases
+fmax36361 fma 1 0E+50 10000E+1 -> 1.0000E+5
+fmax36362 fma 1 10000E+1 0E-50 -> 100000.0000000000 Rounded
+fmax36363 fma 1 10000E+1 10000E-50 -> 100000.0000000000 Rounded Inexact
+fmax36364 fma 1 12.34 0e-398 -> 12.34000000000000 Rounded
+
+-- ulp replacement tests
+fmax36400 fma 1 1 77e-14 -> 1.00000000000077
+fmax36401 fma 1 1 77e-15 -> 1.000000000000077
+fmax36402 fma 1 1 77e-16 -> 1.000000000000008 Inexact Rounded
+fmax36403 fma 1 1 77e-17 -> 1.000000000000001 Inexact Rounded
+fmax36404 fma 1 1 77e-18 -> 1.000000000000000 Inexact Rounded
+fmax36405 fma 1 1 77e-19 -> 1.000000000000000 Inexact Rounded
+fmax36406 fma 1 1 77e-99 -> 1.000000000000000 Inexact Rounded
+
+fmax36410 fma 1 10 77e-14 -> 10.00000000000077
+fmax36411 fma 1 10 77e-15 -> 10.00000000000008 Inexact Rounded
+fmax36412 fma 1 10 77e-16 -> 10.00000000000001 Inexact Rounded
+fmax36413 fma 1 10 77e-17 -> 10.00000000000000 Inexact Rounded
+fmax36414 fma 1 10 77e-18 -> 10.00000000000000 Inexact Rounded
+fmax36415 fma 1 10 77e-19 -> 10.00000000000000 Inexact Rounded
+fmax36416 fma 1 10 77e-99 -> 10.00000000000000 Inexact Rounded
+
+fmax36420 fma 1 77e-14 1 -> 1.00000000000077
+fmax36421 fma 1 77e-15 1 -> 1.000000000000077
+fmax36422 fma 1 77e-16 1 -> 1.000000000000008 Inexact Rounded
+fmax36423 fma 1 77e-17 1 -> 1.000000000000001 Inexact Rounded
+fmax36424 fma 1 77e-18 1 -> 1.000000000000000 Inexact Rounded
+fmax36425 fma 1 77e-19 1 -> 1.000000000000000 Inexact Rounded
+fmax36426 fma 1 77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+fmax36430 fma 1 77e-14 10 -> 10.00000000000077
+fmax36431 fma 1 77e-15 10 -> 10.00000000000008 Inexact Rounded
+fmax36432 fma 1 77e-16 10 -> 10.00000000000001 Inexact Rounded
+fmax36433 fma 1 77e-17 10 -> 10.00000000000000 Inexact Rounded
+fmax36434 fma 1 77e-18 10 -> 10.00000000000000 Inexact Rounded
+fmax36435 fma 1 77e-19 10 -> 10.00000000000000 Inexact Rounded
+fmax36436 fma 1 77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+fmax36440 fma 1 1 -77e-14 -> 0.99999999999923
+fmax36441 fma 1 1 -77e-15 -> 0.999999999999923
+fmax36442 fma 1 1 -77e-16 -> 0.9999999999999923
+fmax36443 fma 1 1 -77e-17 -> 0.9999999999999992 Inexact Rounded
+fmax36444 fma 1 1 -77e-18 -> 0.9999999999999999 Inexact Rounded
+fmax36445 fma 1 1 -77e-19 -> 1.000000000000000 Inexact Rounded
+fmax36446 fma 1 1 -77e-99 -> 1.000000000000000 Inexact Rounded
+
+fmax36450 fma 1 10 -77e-14 -> 9.99999999999923
+fmax36451 fma 1 10 -77e-15 -> 9.999999999999923
+fmax36452 fma 1 10 -77e-16 -> 9.999999999999992 Inexact Rounded
+fmax36453 fma 1 10 -77e-17 -> 9.999999999999999 Inexact Rounded
+fmax36454 fma 1 10 -77e-18 -> 10.00000000000000 Inexact Rounded
+fmax36455 fma 1 10 -77e-19 -> 10.00000000000000 Inexact Rounded
+fmax36456 fma 1 10 -77e-99 -> 10.00000000000000 Inexact Rounded
+
+fmax36460 fma 1 -77e-14 1 -> 0.99999999999923
+fmax36461 fma 1 -77e-15 1 -> 0.999999999999923
+fmax36462 fma 1 -77e-16 1 -> 0.9999999999999923
+fmax36463 fma 1 -77e-17 1 -> 0.9999999999999992 Inexact Rounded
+fmax36464 fma 1 -77e-18 1 -> 0.9999999999999999 Inexact Rounded
+fmax36465 fma 1 -77e-19 1 -> 1.000000000000000 Inexact Rounded
+fmax36466 fma 1 -77e-99 1 -> 1.000000000000000 Inexact Rounded
+
+fmax36470 fma 1 -77e-14 10 -> 9.99999999999923
+fmax36471 fma 1 -77e-15 10 -> 9.999999999999923
+fmax36472 fma 1 -77e-16 10 -> 9.999999999999992 Inexact Rounded
+fmax36473 fma 1 -77e-17 10 -> 9.999999999999999 Inexact Rounded
+fmax36474 fma 1 -77e-18 10 -> 10.00000000000000 Inexact Rounded
+fmax36475 fma 1 -77e-19 10 -> 10.00000000000000 Inexact Rounded
+fmax36476 fma 1 -77e-99 10 -> 10.00000000000000 Inexact Rounded
+
+-- negative ulps
+fmax36480 fma 1 -1 77e-14 -> -0.99999999999923
+fmax36481 fma 1 -1 77e-15 -> -0.999999999999923
+fmax36482 fma 1 -1 77e-16 -> -0.9999999999999923
+fmax36483 fma 1 -1 77e-17 -> -0.9999999999999992 Inexact Rounded
+fmax36484 fma 1 -1 77e-18 -> -0.9999999999999999 Inexact Rounded
+fmax36485 fma 1 -1 77e-19 -> -1.000000000000000 Inexact Rounded
+fmax36486 fma 1 -1 77e-99 -> -1.000000000000000 Inexact Rounded
+
+fmax36490 fma 1 -10 77e-14 -> -9.99999999999923
+fmax36491 fma 1 -10 77e-15 -> -9.999999999999923
+fmax36492 fma 1 -10 77e-16 -> -9.999999999999992 Inexact Rounded
+fmax36493 fma 1 -10 77e-17 -> -9.999999999999999 Inexact Rounded
+fmax36494 fma 1 -10 77e-18 -> -10.00000000000000 Inexact Rounded
+fmax36495 fma 1 -10 77e-19 -> -10.00000000000000 Inexact Rounded
+fmax36496 fma 1 -10 77e-99 -> -10.00000000000000 Inexact Rounded
+
+fmax36500 fma 1 77e-14 -1 -> -0.99999999999923
+fmax36501 fma 1 77e-15 -1 -> -0.999999999999923
+fmax36502 fma 1 77e-16 -1 -> -0.9999999999999923
+fmax36503 fma 1 77e-17 -1 -> -0.9999999999999992 Inexact Rounded
+fmax36504 fma 1 77e-18 -1 -> -0.9999999999999999 Inexact Rounded
+fmax36505 fma 1 77e-19 -1 -> -1.000000000000000 Inexact Rounded
+fmax36506 fma 1 77e-99 -1 -> -1.000000000000000 Inexact Rounded
+
+fmax36510 fma 1 77e-14 -10 -> -9.99999999999923
+fmax36511 fma 1 77e-15 -10 -> -9.999999999999923
+fmax36512 fma 1 77e-16 -10 -> -9.999999999999992 Inexact Rounded
+fmax36513 fma 1 77e-17 -10 -> -9.999999999999999 Inexact Rounded
+fmax36514 fma 1 77e-18 -10 -> -10.00000000000000 Inexact Rounded
+fmax36515 fma 1 77e-19 -10 -> -10.00000000000000 Inexact Rounded
+fmax36516 fma 1 77e-99 -10 -> -10.00000000000000 Inexact Rounded
+
+
+-- long operands
+fmax36521 fma 1 101234562345678000 0 -> 1.012345623456780E+17 Rounded
+fmax36522 fma 1 0 101234562345678000 -> 1.012345623456780E+17 Rounded
+fmax36523 fma 1 10123456234567800 0 -> 1.012345623456780E+16 Rounded
+fmax36524 fma 1 0 10123456234567800 -> 1.012345623456780E+16 Rounded
+fmax36525 fma 1 10123456234567890 0 -> 1.012345623456789E+16 Rounded
+fmax36526 fma 1 0 10123456234567890 -> 1.012345623456789E+16 Rounded
+fmax36527 fma 1 10123456234567891 0 -> 1.012345623456789E+16 Inexact Rounded
+fmax36528 fma 1 0 10123456234567891 -> 1.012345623456789E+16 Inexact Rounded
+fmax36529 fma 1 101234562345678901 0 -> 1.012345623456789E+17 Inexact Rounded
+fmax36530 fma 1 0 101234562345678901 -> 1.012345623456789E+17 Inexact Rounded
+fmax36531 fma 1 10123456234567896 0 -> 1.012345623456790E+16 Inexact Rounded
+fmax36532 fma 1 0 10123456234567896 -> 1.012345623456790E+16 Inexact Rounded
+
+-- verify a query
+rounding: down
+fmax36561 fma 1 1e-398 9.000000000000000E+384 -> 9.000000000000000E+384 Inexact Rounded
+fmax36562 fma 1 0 9.000000000000000E+384 -> 9.000000000000000E+384 Rounded
+-- and using decimal64 bounds...
+rounding: down
+fmax36563 fma 1 1e-388 9.000000000000000E+374 -> 9.000000000000000E+374 Inexact Rounded
+fmax36564 fma 1 0 9.000000000000000E+374 -> 9.000000000000000E+374 Rounded
+
+-- more zeros, etc.
+rounding: half_even
+
+fmax36701 fma 1 5.00 1.00E-3 -> 5.00100
+fmax36702 fma 1 00.00 0.000 -> 0.000
+fmax36703 fma 1 00.00 0E-3 -> 0.000
+fmax36704 fma 1 0E-3 00.00 -> 0.000
+
+fmax36710 fma 1 0E+3 00.00 -> 0.00
+fmax36711 fma 1 0E+3 00.0 -> 0.0
+fmax36712 fma 1 0E+3 00. -> 0
+fmax36713 fma 1 0E+3 00.E+1 -> 0E+1
+fmax36714 fma 1 0E+3 00.E+2 -> 0E+2
+fmax36715 fma 1 0E+3 00.E+3 -> 0E+3
+fmax36716 fma 1 0E+3 00.E+4 -> 0E+3
+fmax36717 fma 1 0E+3 00.E+5 -> 0E+3
+fmax36718 fma 1 0E+3 -00.0 -> 0.0
+fmax36719 fma 1 0E+3 -00. -> 0
+fmax36731 fma 1 0E+3 -00.E+1 -> 0E+1
+
+fmax36720 fma 1 00.00 0E+3 -> 0.00
+fmax36721 fma 1 00.0 0E+3 -> 0.0
+fmax36722 fma 1 00. 0E+3 -> 0
+fmax36723 fma 1 00.E+1 0E+3 -> 0E+1
+fmax36724 fma 1 00.E+2 0E+3 -> 0E+2
+fmax36725 fma 1 00.E+3 0E+3 -> 0E+3
+fmax36726 fma 1 00.E+4 0E+3 -> 0E+3
+fmax36727 fma 1 00.E+5 0E+3 -> 0E+3
+fmax36728 fma 1 -00.00 0E+3 -> 0.00
+fmax36729 fma 1 -00.0 0E+3 -> 0.0
+fmax36730 fma 1 -00. 0E+3 -> 0
+
+fmax36732 fma 1 0 0 -> 0
+fmax36733 fma 1 0 -0 -> 0
+fmax36734 fma 1 -0 0 -> 0
+fmax36735 fma 1 -0 -0 -> -0 -- IEEE 854 special case
+
+fmax36736 fma 1 1 -1 -> 0
+fmax36737 fma 1 -1 -1 -> -2
+fmax36738 fma 1 1 1 -> 2
+fmax36739 fma 1 -1 1 -> 0
+
+fmax36741 fma 1 0 -1 -> -1
+fmax36742 fma 1 -0 -1 -> -1
+fmax36743 fma 1 0 1 -> 1
+fmax36744 fma 1 -0 1 -> 1
+fmax36745 fma 1 -1 0 -> -1
+fmax36746 fma 1 -1 -0 -> -1
+fmax36747 fma 1 1 0 -> 1
+fmax36748 fma 1 1 -0 -> 1
+
+fmax36751 fma 1 0.0 -1 -> -1.0
+fmax36752 fma 1 -0.0 -1 -> -1.0
+fmax36753 fma 1 0.0 1 -> 1.0
+fmax36754 fma 1 -0.0 1 -> 1.0
+fmax36755 fma 1 -1.0 0 -> -1.0
+fmax36756 fma 1 -1.0 -0 -> -1.0
+fmax36757 fma 1 1.0 0 -> 1.0
+fmax36758 fma 1 1.0 -0 -> 1.0
+
+fmax36761 fma 1 0 -1.0 -> -1.0
+fmax36762 fma 1 -0 -1.0 -> -1.0
+fmax36763 fma 1 0 1.0 -> 1.0
+fmax36764 fma 1 -0 1.0 -> 1.0
+fmax36765 fma 1 -1 0.0 -> -1.0
+fmax36766 fma 1 -1 -0.0 -> -1.0
+fmax36767 fma 1 1 0.0 -> 1.0
+fmax36768 fma 1 1 -0.0 -> 1.0
+
+fmax36771 fma 1 0.0 -1.0 -> -1.0
+fmax36772 fma 1 -0.0 -1.0 -> -1.0
+fmax36773 fma 1 0.0 1.0 -> 1.0
+fmax36774 fma 1 -0.0 1.0 -> 1.0
+fmax36775 fma 1 -1.0 0.0 -> -1.0
+fmax36776 fma 1 -1.0 -0.0 -> -1.0
+fmax36777 fma 1 1.0 0.0 -> 1.0
+fmax36778 fma 1 1.0 -0.0 -> 1.0
+
+-- Specials
+fmax36780 fma 1 -Inf -Inf -> -Infinity
+fmax36781 fma 1 -Inf -1000 -> -Infinity
+fmax36782 fma 1 -Inf -1 -> -Infinity
+fmax36783 fma 1 -Inf -0 -> -Infinity
+fmax36784 fma 1 -Inf 0 -> -Infinity
+fmax36785 fma 1 -Inf 1 -> -Infinity
+fmax36786 fma 1 -Inf 1000 -> -Infinity
+fmax36787 fma 1 -1000 -Inf -> -Infinity
+fmax36788 fma 1 -Inf -Inf -> -Infinity
+fmax36789 fma 1 -1 -Inf -> -Infinity
+fmax36790 fma 1 -0 -Inf -> -Infinity
+fmax36791 fma 1 0 -Inf -> -Infinity
+fmax36792 fma 1 1 -Inf -> -Infinity
+fmax36793 fma 1 1000 -Inf -> -Infinity
+fmax36794 fma 1 Inf -Inf -> NaN Invalid_operation
+
+fmax36800 fma 1 Inf -Inf -> NaN Invalid_operation
+fmax36801 fma 1 Inf -1000 -> Infinity
+fmax36802 fma 1 Inf -1 -> Infinity
+fmax36803 fma 1 Inf -0 -> Infinity
+fmax36804 fma 1 Inf 0 -> Infinity
+fmax36805 fma 1 Inf 1 -> Infinity
+fmax36806 fma 1 Inf 1000 -> Infinity
+fmax36807 fma 1 Inf Inf -> Infinity
+fmax36808 fma 1 -1000 Inf -> Infinity
+fmax36809 fma 1 -Inf Inf -> NaN Invalid_operation
+fmax36810 fma 1 -1 Inf -> Infinity
+fmax36811 fma 1 -0 Inf -> Infinity
+fmax36812 fma 1 0 Inf -> Infinity
+fmax36813 fma 1 1 Inf -> Infinity
+fmax36814 fma 1 1000 Inf -> Infinity
+fmax36815 fma 1 Inf Inf -> Infinity
+
+fmax36821 fma 1 NaN -Inf -> NaN
+fmax36822 fma 1 NaN -1000 -> NaN
+fmax36823 fma 1 NaN -1 -> NaN
+fmax36824 fma 1 NaN -0 -> NaN
+fmax36825 fma 1 NaN 0 -> NaN
+fmax36826 fma 1 NaN 1 -> NaN
+fmax36827 fma 1 NaN 1000 -> NaN
+fmax36828 fma 1 NaN Inf -> NaN
+fmax36829 fma 1 NaN NaN -> NaN
+fmax36830 fma 1 -Inf NaN -> NaN
+fmax36831 fma 1 -1000 NaN -> NaN
+fmax36832 fma 1 -1 NaN -> NaN
+fmax36833 fma 1 -0 NaN -> NaN
+fmax36834 fma 1 0 NaN -> NaN
+fmax36835 fma 1 1 NaN -> NaN
+fmax36836 fma 1 1000 NaN -> NaN
+fmax36837 fma 1 Inf NaN -> NaN
+
+fmax36841 fma 1 sNaN -Inf -> NaN Invalid_operation
+fmax36842 fma 1 sNaN -1000 -> NaN Invalid_operation
+fmax36843 fma 1 sNaN -1 -> NaN Invalid_operation
+fmax36844 fma 1 sNaN -0 -> NaN Invalid_operation
+fmax36845 fma 1 sNaN 0 -> NaN Invalid_operation
+fmax36846 fma 1 sNaN 1 -> NaN Invalid_operation
+fmax36847 fma 1 sNaN 1000 -> NaN Invalid_operation
+fmax36848 fma 1 sNaN NaN -> NaN Invalid_operation
+fmax36849 fma 1 sNaN sNaN -> NaN Invalid_operation
+fmax36850 fma 1 NaN sNaN -> NaN Invalid_operation
+fmax36851 fma 1 -Inf sNaN -> NaN Invalid_operation
+fmax36852 fma 1 -1000 sNaN -> NaN Invalid_operation
+fmax36853 fma 1 -1 sNaN -> NaN Invalid_operation
+fmax36854 fma 1 -0 sNaN -> NaN Invalid_operation
+fmax36855 fma 1 0 sNaN -> NaN Invalid_operation
+fmax36856 fma 1 1 sNaN -> NaN Invalid_operation
+fmax36857 fma 1 1000 sNaN -> NaN Invalid_operation
+fmax36858 fma 1 Inf sNaN -> NaN Invalid_operation
+fmax36859 fma 1 NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+fmax36861 fma 1 NaN1 -Inf -> NaN1
+fmax36862 fma 1 +NaN2 -1000 -> NaN2
+fmax36863 fma 1 NaN3 1000 -> NaN3
+fmax36864 fma 1 NaN4 Inf -> NaN4
+fmax36865 fma 1 NaN5 +NaN6 -> NaN5
+fmax36866 fma 1 -Inf NaN7 -> NaN7
+fmax36867 fma 1 -1000 NaN8 -> NaN8
+fmax36868 fma 1 1000 NaN9 -> NaN9
+fmax36869 fma 1 Inf +NaN10 -> NaN10
+fmax36871 fma 1 sNaN11 -Inf -> NaN11 Invalid_operation
+fmax36872 fma 1 sNaN12 -1000 -> NaN12 Invalid_operation
+fmax36873 fma 1 sNaN13 1000 -> NaN13 Invalid_operation
+fmax36874 fma 1 sNaN14 NaN17 -> NaN14 Invalid_operation
+fmax36875 fma 1 sNaN15 sNaN18 -> NaN15 Invalid_operation
+fmax36876 fma 1 NaN16 sNaN19 -> NaN19 Invalid_operation
+fmax36877 fma 1 -Inf +sNaN20 -> NaN20 Invalid_operation
+fmax36878 fma 1 -1000 sNaN21 -> NaN21 Invalid_operation
+fmax36879 fma 1 1000 sNaN22 -> NaN22 Invalid_operation
+fmax36880 fma 1 Inf sNaN23 -> NaN23 Invalid_operation
+fmax36881 fma 1 +NaN25 +sNaN24 -> NaN24 Invalid_operation
+fmax36882 fma 1 -NaN26 NaN28 -> -NaN26
+fmax36883 fma 1 -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+fmax36884 fma 1 1000 -NaN30 -> -NaN30
+fmax36885 fma 1 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- now the case where we can get underflow but the result is normal
+-- [note this can't happen if the operands are also bounded, as we
+-- cannot represent 1E-399, for example]
+
+fmax36571 fma 1 1E-383 0 -> 1E-383
+fmax36572 fma 1 1E-384 0 -> 1E-384 Subnormal
+fmax36573 fma 1 1E-383 1E-384 -> 1.1E-383
+fmax36574 subtract 1E-383 1E-384 -> 9E-384 Subnormal
+
+-- Here we explore the boundary of rounding a subnormal to Nmin
+fmax36575 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax36576 subtract 1E-383 1E-398 -> 9.99999999999999E-384 Subnormal
+fmax36577 subtract 1E-383 1E-399 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36578 subtract 1E-383 1E-400 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36579 subtract 1E-383 1E-401 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+fmax36580 subtract 1E-383 1E-402 -> 1.000000000000000E-383 Underflow Inexact Subnormal Rounded
+
+-- check overflow edge case
+-- 1234567890123456
+fmax36972 apply 9.999999999999999E+384 -> 9.999999999999999E+384
+fmax36973 fma 1 9.999999999999999E+384 1 -> 9.999999999999999E+384 Inexact Rounded
+fmax36974 fma 1 9999999999999999E+369 1 -> 9.999999999999999E+384 Inexact Rounded
+fmax36975 fma 1 9999999999999999E+369 1E+369 -> Infinity Overflow Inexact Rounded
+fmax36976 fma 1 9999999999999999E+369 9E+368 -> Infinity Overflow Inexact Rounded
+fmax36977 fma 1 9999999999999999E+369 8E+368 -> Infinity Overflow Inexact Rounded
+fmax36978 fma 1 9999999999999999E+369 7E+368 -> Infinity Overflow Inexact Rounded
+fmax36979 fma 1 9999999999999999E+369 6E+368 -> Infinity Overflow Inexact Rounded
+fmax36980 fma 1 9999999999999999E+369 5E+368 -> Infinity Overflow Inexact Rounded
+fmax36981 fma 1 9999999999999999E+369 4E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36982 fma 1 9999999999999999E+369 3E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36983 fma 1 9999999999999999E+369 2E+368 -> 9.999999999999999E+384 Inexact Rounded
+fmax36984 fma 1 9999999999999999E+369 1E+368 -> 9.999999999999999E+384 Inexact Rounded
+
+fmax36985 apply -9.999999999999999E+384 -> -9.999999999999999E+384
+fmax36986 fma 1 -9.999999999999999E+384 -1 -> -9.999999999999999E+384 Inexact Rounded
+fmax36987 fma 1 -9999999999999999E+369 -1 -> -9.999999999999999E+384 Inexact Rounded
+fmax36988 fma 1 -9999999999999999E+369 -1E+369 -> -Infinity Overflow Inexact Rounded
+fmax36989 fma 1 -9999999999999999E+369 -9E+368 -> -Infinity Overflow Inexact Rounded
+fmax36990 fma 1 -9999999999999999E+369 -8E+368 -> -Infinity Overflow Inexact Rounded
+fmax36991 fma 1 -9999999999999999E+369 -7E+368 -> -Infinity Overflow Inexact Rounded
+fmax36992 fma 1 -9999999999999999E+369 -6E+368 -> -Infinity Overflow Inexact Rounded
+fmax36993 fma 1 -9999999999999999E+369 -5E+368 -> -Infinity Overflow Inexact Rounded
+fmax36994 fma 1 -9999999999999999E+369 -4E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36995 fma 1 -9999999999999999E+369 -3E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36996 fma 1 -9999999999999999E+369 -2E+368 -> -9.999999999999999E+384 Inexact Rounded
+fmax36997 fma 1 -9999999999999999E+369 -1E+368 -> -9.999999999999999E+384 Inexact Rounded
+
+-- And for round down full and subnormal results
+rounding: down
+fmax361100 fma 1 1e+2 -1e-383 -> 99.99999999999999 Rounded Inexact
+fmax361101 fma 1 1e+1 -1e-383 -> 9.999999999999999 Rounded Inexact
+fmax361103 fma 1 +1 -1e-383 -> 0.9999999999999999 Rounded Inexact
+fmax361104 fma 1 1e-1 -1e-383 -> 0.09999999999999999 Rounded Inexact
+fmax361105 fma 1 1e-2 -1e-383 -> 0.009999999999999999 Rounded Inexact
+fmax361106 fma 1 1e-3 -1e-383 -> 0.0009999999999999999 Rounded Inexact
+fmax361107 fma 1 1e-4 -1e-383 -> 0.00009999999999999999 Rounded Inexact
+fmax361108 fma 1 1e-5 -1e-383 -> 0.000009999999999999999 Rounded Inexact
+fmax361109 fma 1 1e-6 -1e-383 -> 9.999999999999999E-7 Rounded Inexact
+
+rounding: ceiling
+fmax361110 fma 1 -1e+2 +1e-383 -> -99.99999999999999 Rounded Inexact
+fmax361111 fma 1 -1e+1 +1e-383 -> -9.999999999999999 Rounded Inexact
+fmax361113 fma 1 -1 +1e-383 -> -0.9999999999999999 Rounded Inexact
+fmax361114 fma 1 -1e-1 +1e-383 -> -0.09999999999999999 Rounded Inexact
+fmax361115 fma 1 -1e-2 +1e-383 -> -0.009999999999999999 Rounded Inexact
+fmax361116 fma 1 -1e-3 +1e-383 -> -0.0009999999999999999 Rounded Inexact
+fmax361117 fma 1 -1e-4 +1e-383 -> -0.00009999999999999999 Rounded Inexact
+fmax361118 fma 1 -1e-5 +1e-383 -> -0.000009999999999999999 Rounded Inexact
+fmax361119 fma 1 -1e-6 +1e-383 -> -9.999999999999999E-7 Rounded Inexact
+
+-- tests based on Gunnar Degnbol's edge case
+rounding: half_even
+
+fmax361300 fma 1 1E16 -0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax361310 fma 1 1E16 -0.51 -> 9999999999999999 Inexact Rounded
+fmax361311 fma 1 1E16 -0.501 -> 9999999999999999 Inexact Rounded
+fmax361312 fma 1 1E16 -0.5001 -> 9999999999999999 Inexact Rounded
+fmax361313 fma 1 1E16 -0.50001 -> 9999999999999999 Inexact Rounded
+fmax361314 fma 1 1E16 -0.500001 -> 9999999999999999 Inexact Rounded
+fmax361315 fma 1 1E16 -0.5000001 -> 9999999999999999 Inexact Rounded
+fmax361316 fma 1 1E16 -0.50000001 -> 9999999999999999 Inexact Rounded
+fmax361317 fma 1 1E16 -0.500000001 -> 9999999999999999 Inexact Rounded
+fmax361318 fma 1 1E16 -0.5000000001 -> 9999999999999999 Inexact Rounded
+fmax361319 fma 1 1E16 -0.50000000001 -> 9999999999999999 Inexact Rounded
+fmax361320 fma 1 1E16 -0.500000000001 -> 9999999999999999 Inexact Rounded
+fmax361321 fma 1 1E16 -0.5000000000001 -> 9999999999999999 Inexact Rounded
+fmax361322 fma 1 1E16 -0.50000000000001 -> 9999999999999999 Inexact Rounded
+fmax361323 fma 1 1E16 -0.500000000000001 -> 9999999999999999 Inexact Rounded
+fmax361324 fma 1 1E16 -0.5000000000000001 -> 9999999999999999 Inexact Rounded
+fmax361325 fma 1 1E16 -0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361326 fma 1 1E16 -0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361327 fma 1 1E16 -0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361328 fma 1 1E16 -0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361329 fma 1 1E16 -0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361330 fma 1 1E16 -0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361331 fma 1 1E16 -0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361332 fma 1 1E16 -0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361333 fma 1 1E16 -0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361334 fma 1 1E16 -0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361335 fma 1 1E16 -0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361336 fma 1 1E16 -0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361337 fma 1 1E16 -0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361338 fma 1 1E16 -0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax361339 fma 1 1E16 -0.50 -> 1.000000000000000E+16 Inexact Rounded
+
+fmax361340 fma 1 1E16 -5000000.000010001 -> 9999999995000000 Inexact Rounded
+fmax361341 fma 1 1E16 -5000000.000000001 -> 9999999995000000 Inexact Rounded
+
+fmax361349 fma 1 9999999999999999 0.4 -> 9999999999999999 Inexact Rounded
+fmax361350 fma 1 9999999999999999 0.49 -> 9999999999999999 Inexact Rounded
+fmax361351 fma 1 9999999999999999 0.499 -> 9999999999999999 Inexact Rounded
+fmax361352 fma 1 9999999999999999 0.4999 -> 9999999999999999 Inexact Rounded
+fmax361353 fma 1 9999999999999999 0.49999 -> 9999999999999999 Inexact Rounded
+fmax361354 fma 1 9999999999999999 0.499999 -> 9999999999999999 Inexact Rounded
+fmax361355 fma 1 9999999999999999 0.4999999 -> 9999999999999999 Inexact Rounded
+fmax361356 fma 1 9999999999999999 0.49999999 -> 9999999999999999 Inexact Rounded
+fmax361357 fma 1 9999999999999999 0.499999999 -> 9999999999999999 Inexact Rounded
+fmax361358 fma 1 9999999999999999 0.4999999999 -> 9999999999999999 Inexact Rounded
+fmax361359 fma 1 9999999999999999 0.49999999999 -> 9999999999999999 Inexact Rounded
+fmax361360 fma 1 9999999999999999 0.499999999999 -> 9999999999999999 Inexact Rounded
+fmax361361 fma 1 9999999999999999 0.4999999999999 -> 9999999999999999 Inexact Rounded
+fmax361362 fma 1 9999999999999999 0.49999999999999 -> 9999999999999999 Inexact Rounded
+fmax361363 fma 1 9999999999999999 0.499999999999999 -> 9999999999999999 Inexact Rounded
+fmax361364 fma 1 9999999999999999 0.4999999999999999 -> 9999999999999999 Inexact Rounded
+fmax361365 fma 1 9999999999999999 0.5000000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361367 fma 1 9999999999999999 0.500000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361368 fma 1 9999999999999999 0.50000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361369 fma 1 9999999999999999 0.5000000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361370 fma 1 9999999999999999 0.500000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361371 fma 1 9999999999999999 0.50000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361372 fma 1 9999999999999999 0.5000000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361373 fma 1 9999999999999999 0.500000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361374 fma 1 9999999999999999 0.50000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361375 fma 1 9999999999999999 0.5000000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361376 fma 1 9999999999999999 0.500000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361377 fma 1 9999999999999999 0.50000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361378 fma 1 9999999999999999 0.5000 -> 1.000000000000000E+16 Inexact Rounded
+fmax361379 fma 1 9999999999999999 0.500 -> 1.000000000000000E+16 Inexact Rounded
+fmax361380 fma 1 9999999999999999 0.50 -> 1.000000000000000E+16 Inexact Rounded
+fmax361381 fma 1 9999999999999999 0.5 -> 1.000000000000000E+16 Inexact Rounded
+fmax361382 fma 1 9999999999999999 0.5000000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361383 fma 1 9999999999999999 0.500000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361384 fma 1 9999999999999999 0.50000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361385 fma 1 9999999999999999 0.5000000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361386 fma 1 9999999999999999 0.500000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361387 fma 1 9999999999999999 0.50000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361388 fma 1 9999999999999999 0.5000000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361389 fma 1 9999999999999999 0.500000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361390 fma 1 9999999999999999 0.50000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361391 fma 1 9999999999999999 0.5000001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361392 fma 1 9999999999999999 0.500001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361393 fma 1 9999999999999999 0.50001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361394 fma 1 9999999999999999 0.5001 -> 1.000000000000000E+16 Inexact Rounded
+fmax361395 fma 1 9999999999999999 0.501 -> 1.000000000000000E+16 Inexact Rounded
+fmax361396 fma 1 9999999999999999 0.51 -> 1.000000000000000E+16 Inexact Rounded
+
+-- More GD edge cases, where difference between the unadjusted
+-- exponents is larger than the maximum precision and one side is 0
+fmax361420 fma 1 0 1.123456789012345 -> 1.123456789012345
+fmax361421 fma 1 0 1.123456789012345E-1 -> 0.1123456789012345
+fmax361422 fma 1 0 1.123456789012345E-2 -> 0.01123456789012345
+fmax361423 fma 1 0 1.123456789012345E-3 -> 0.001123456789012345
+fmax361424 fma 1 0 1.123456789012345E-4 -> 0.0001123456789012345
+fmax361425 fma 1 0 1.123456789012345E-5 -> 0.00001123456789012345
+fmax361426 fma 1 0 1.123456789012345E-6 -> 0.000001123456789012345
+fmax361427 fma 1 0 1.123456789012345E-7 -> 1.123456789012345E-7
+fmax361428 fma 1 0 1.123456789012345E-8 -> 1.123456789012345E-8
+fmax361429 fma 1 0 1.123456789012345E-9 -> 1.123456789012345E-9
+fmax361430 fma 1 0 1.123456789012345E-10 -> 1.123456789012345E-10
+fmax361431 fma 1 0 1.123456789012345E-11 -> 1.123456789012345E-11
+fmax361432 fma 1 0 1.123456789012345E-12 -> 1.123456789012345E-12
+fmax361433 fma 1 0 1.123456789012345E-13 -> 1.123456789012345E-13
+fmax361434 fma 1 0 1.123456789012345E-14 -> 1.123456789012345E-14
+fmax361435 fma 1 0 1.123456789012345E-15 -> 1.123456789012345E-15
+fmax361436 fma 1 0 1.123456789012345E-16 -> 1.123456789012345E-16
+fmax361437 fma 1 0 1.123456789012345E-17 -> 1.123456789012345E-17
+fmax361438 fma 1 0 1.123456789012345E-18 -> 1.123456789012345E-18
+fmax361439 fma 1 0 1.123456789012345E-19 -> 1.123456789012345E-19
+
+-- same, reversed 0
+fmax361440 fma 1 1.123456789012345 0 -> 1.123456789012345
+fmax361441 fma 1 1.123456789012345E-1 0 -> 0.1123456789012345
+fmax361442 fma 1 1.123456789012345E-2 0 -> 0.01123456789012345
+fmax361443 fma 1 1.123456789012345E-3 0 -> 0.001123456789012345
+fmax361444 fma 1 1.123456789012345E-4 0 -> 0.0001123456789012345
+fmax361445 fma 1 1.123456789012345E-5 0 -> 0.00001123456789012345
+fmax361446 fma 1 1.123456789012345E-6 0 -> 0.000001123456789012345
+fmax361447 fma 1 1.123456789012345E-7 0 -> 1.123456789012345E-7
+fmax361448 fma 1 1.123456789012345E-8 0 -> 1.123456789012345E-8
+fmax361449 fma 1 1.123456789012345E-9 0 -> 1.123456789012345E-9
+fmax361450 fma 1 1.123456789012345E-10 0 -> 1.123456789012345E-10
+fmax361451 fma 1 1.123456789012345E-11 0 -> 1.123456789012345E-11
+fmax361452 fma 1 1.123456789012345E-12 0 -> 1.123456789012345E-12
+fmax361453 fma 1 1.123456789012345E-13 0 -> 1.123456789012345E-13
+fmax361454 fma 1 1.123456789012345E-14 0 -> 1.123456789012345E-14
+fmax361455 fma 1 1.123456789012345E-15 0 -> 1.123456789012345E-15
+fmax361456 fma 1 1.123456789012345E-16 0 -> 1.123456789012345E-16
+fmax361457 fma 1 1.123456789012345E-17 0 -> 1.123456789012345E-17
+fmax361458 fma 1 1.123456789012345E-18 0 -> 1.123456789012345E-18
+fmax361459 fma 1 1.123456789012345E-19 0 -> 1.123456789012345E-19
+
+-- same, Es on the 0
+fmax361460 fma 1 1.123456789012345 0E-0 -> 1.123456789012345
+fmax361461 fma 1 1.123456789012345 0E-1 -> 1.123456789012345
+fmax361462 fma 1 1.123456789012345 0E-2 -> 1.123456789012345
+fmax361463 fma 1 1.123456789012345 0E-3 -> 1.123456789012345
+fmax361464 fma 1 1.123456789012345 0E-4 -> 1.123456789012345
+fmax361465 fma 1 1.123456789012345 0E-5 -> 1.123456789012345
+fmax361466 fma 1 1.123456789012345 0E-6 -> 1.123456789012345
+fmax361467 fma 1 1.123456789012345 0E-7 -> 1.123456789012345
+fmax361468 fma 1 1.123456789012345 0E-8 -> 1.123456789012345
+fmax361469 fma 1 1.123456789012345 0E-9 -> 1.123456789012345
+fmax361470 fma 1 1.123456789012345 0E-10 -> 1.123456789012345
+fmax361471 fma 1 1.123456789012345 0E-11 -> 1.123456789012345
+fmax361472 fma 1 1.123456789012345 0E-12 -> 1.123456789012345
+fmax361473 fma 1 1.123456789012345 0E-13 -> 1.123456789012345
+fmax361474 fma 1 1.123456789012345 0E-14 -> 1.123456789012345
+fmax361475 fma 1 1.123456789012345 0E-15 -> 1.123456789012345
+-- next four flag Rounded because the 0 extends the result
+fmax361476 fma 1 1.123456789012345 0E-16 -> 1.123456789012345 Rounded
+fmax361477 fma 1 1.123456789012345 0E-17 -> 1.123456789012345 Rounded
+fmax361478 fma 1 1.123456789012345 0E-18 -> 1.123456789012345 Rounded
+fmax361479 fma 1 1.123456789012345 0E-19 -> 1.123456789012345 Rounded
+
+-- sum of two opposite-sign operands is exactly 0 and floor => -0
+rounding: half_up
+-- exact zeros from zeros
+fmax361500 fma 1 0 0E-19 -> 0E-19
+fmax361501 fma 1 -0 0E-19 -> 0E-19
+fmax361502 fma 1 0 -0E-19 -> 0E-19
+fmax361503 fma 1 -0 -0E-19 -> -0E-19
+fmax361504 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361505 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361506 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361507 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361511 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361512 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361513 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361514 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361515 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361516 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361517 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361518 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_down
+-- exact zeros from zeros
+fmax361520 fma 1 0 0E-19 -> 0E-19
+fmax361521 fma 1 -0 0E-19 -> 0E-19
+fmax361522 fma 1 0 -0E-19 -> 0E-19
+fmax361523 fma 1 -0 -0E-19 -> -0E-19
+fmax361524 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361525 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361526 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361527 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361531 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361532 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361533 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361534 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361535 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361536 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361537 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361538 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: half_even
+-- exact zeros from zeros
+fmax361540 fma 1 0 0E-19 -> 0E-19
+fmax361541 fma 1 -0 0E-19 -> 0E-19
+fmax361542 fma 1 0 -0E-19 -> 0E-19
+fmax361543 fma 1 -0 -0E-19 -> -0E-19
+fmax361544 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361545 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361546 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361547 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361551 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361552 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361553 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361554 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361555 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361556 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361557 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361558 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: up
+-- exact zeros from zeros
+fmax361560 fma 1 0 0E-19 -> 0E-19
+fmax361561 fma 1 -0 0E-19 -> 0E-19
+fmax361562 fma 1 0 -0E-19 -> 0E-19
+fmax361563 fma 1 -0 -0E-19 -> -0E-19
+fmax361564 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361565 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361566 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361567 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361571 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361572 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361573 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax361574 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax361575 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361576 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361577 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361578 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+rounding: down
+-- exact zeros from zeros
+fmax361580 fma 1 0 0E-19 -> 0E-19
+fmax361581 fma 1 -0 0E-19 -> 0E-19
+fmax361582 fma 1 0 -0E-19 -> 0E-19
+fmax361583 fma 1 -0 -0E-19 -> -0E-19
+fmax361584 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361585 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361586 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361587 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361591 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361592 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361593 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361594 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361595 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361596 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361597 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361598 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+rounding: ceiling
+-- exact zeros from zeros
+fmax361600 fma 1 0 0E-19 -> 0E-19
+fmax361601 fma 1 -0 0E-19 -> 0E-19
+fmax361602 fma 1 0 -0E-19 -> 0E-19
+fmax361603 fma 1 -0 -0E-19 -> -0E-19
+fmax361604 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361605 fma 1 -0E-400 0E-19 -> 0E-398 Clamped
+fmax361606 fma 1 0E-400 -0E-19 -> 0E-398 Clamped
+fmax361607 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361611 fma 1 1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361612 fma 1 -1E-401 1E-400 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361613 fma 1 1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361614 fma 1 -1E-401 -1E-400 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+-- some exact zeros from non-zeros
+fmax361615 fma 1 1E-401 1E-401 -> 1E-398 Subnormal Inexact Rounded Underflow
+fmax361616 fma 1 -1E-401 1E-401 -> 0E-398 Clamped
+fmax361617 fma 1 1E-401 -1E-401 -> 0E-398 Clamped
+fmax361618 fma 1 -1E-401 -1E-401 -> -0E-398 Subnormal Inexact Rounded Underflow Clamped
+
+-- and the extra-special ugly case; unusual minuses marked by -- *
+rounding: floor
+-- exact zeros from zeros
+fmax361620 fma 1 0 0E-19 -> 0E-19
+fmax361621 fma 1 -0 0E-19 -> -0E-19 -- *
+fmax361622 fma 1 0 -0E-19 -> -0E-19 -- *
+fmax361623 fma 1 -0 -0E-19 -> -0E-19
+fmax361624 fma 1 0E-400 0E-19 -> 0E-398 Clamped
+fmax361625 fma 1 -0E-400 0E-19 -> -0E-398 Clamped -- *
+fmax361626 fma 1 0E-400 -0E-19 -> -0E-398 Clamped -- *
+fmax361627 fma 1 -0E-400 -0E-19 -> -0E-398 Clamped
+-- inexact zeros
+fmax361631 fma 1 1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361632 fma 1 -1E-401 1E-400 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361633 fma 1 1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+fmax361634 fma 1 -1E-401 -1E-400 -> -1E-398 Subnormal Inexact Rounded Underflow
+-- some exact zeros from non-zeros
+fmax361635 fma 1 1E-401 1E-401 -> 0E-398 Subnormal Inexact Rounded Underflow Clamped
+fmax361636 fma 1 -1E-401 1E-401 -> -0E-398 Clamped -- *
+fmax361637 fma 1 1E-401 -1E-401 -> -0E-398 Clamped -- *
+fmax361638 fma 1 -1E-401 -1E-401 -> -1E-398 Subnormal Inexact Rounded Underflow
+
+-- Examples from SQL proposal (Krishna Kulkarni)
+fmax361701 fma 1 130E-2 120E-2 -> 2.50
+fmax361702 fma 1 130E-2 12E-1 -> 2.50
+fmax361703 fma 1 130E-2 1E0 -> 2.30
+fmax361704 fma 1 1E2 1E4 -> 1.01E+4
+fmax361705 subtract 130E-2 120E-2 -> 0.10
+fmax361706 subtract 130E-2 12E-1 -> 0.10
+fmax361707 subtract 130E-2 1E0 -> 0.30
+fmax361708 subtract 1E2 1E4 -> -9.9E+3
+
+-- Gappy coefficients; check residue handling even with full coefficient gap
+rounding: half_even
+
+fmax362001 fma 1 1234567890123456 1 -> 1234567890123457
+fmax362002 fma 1 1234567890123456 0.6 -> 1234567890123457 Inexact Rounded
+fmax362003 fma 1 1234567890123456 0.06 -> 1234567890123456 Inexact Rounded
+fmax362004 fma 1 1234567890123456 6E-3 -> 1234567890123456 Inexact Rounded
+fmax362005 fma 1 1234567890123456 6E-4 -> 1234567890123456 Inexact Rounded
+fmax362006 fma 1 1234567890123456 6E-5 -> 1234567890123456 Inexact Rounded
+fmax362007 fma 1 1234567890123456 6E-6 -> 1234567890123456 Inexact Rounded
+fmax362008 fma 1 1234567890123456 6E-7 -> 1234567890123456 Inexact Rounded
+fmax362009 fma 1 1234567890123456 6E-8 -> 1234567890123456 Inexact Rounded
+fmax362010 fma 1 1234567890123456 6E-9 -> 1234567890123456 Inexact Rounded
+fmax362011 fma 1 1234567890123456 6E-10 -> 1234567890123456 Inexact Rounded
+fmax362012 fma 1 1234567890123456 6E-11 -> 1234567890123456 Inexact Rounded
+fmax362013 fma 1 1234567890123456 6E-12 -> 1234567890123456 Inexact Rounded
+fmax362014 fma 1 1234567890123456 6E-13 -> 1234567890123456 Inexact Rounded
+fmax362015 fma 1 1234567890123456 6E-14 -> 1234567890123456 Inexact Rounded
+fmax362016 fma 1 1234567890123456 6E-15 -> 1234567890123456 Inexact Rounded
+fmax362017 fma 1 1234567890123456 6E-16 -> 1234567890123456 Inexact Rounded
+fmax362018 fma 1 1234567890123456 6E-17 -> 1234567890123456 Inexact Rounded
+fmax362019 fma 1 1234567890123456 6E-18 -> 1234567890123456 Inexact Rounded
+fmax362020 fma 1 1234567890123456 6E-19 -> 1234567890123456 Inexact Rounded
+fmax362021 fma 1 1234567890123456 6E-20 -> 1234567890123456 Inexact Rounded
+
+-- widening second argument at gap
+fmax362030 fma 1 12345678 1 -> 12345679
+fmax362031 fma 1 12345678 0.1 -> 12345678.1
+fmax362032 fma 1 12345678 0.12 -> 12345678.12
+fmax362033 fma 1 12345678 0.123 -> 12345678.123
+fmax362034 fma 1 12345678 0.1234 -> 12345678.1234
+fmax362035 fma 1 12345678 0.12345 -> 12345678.12345
+fmax362036 fma 1 12345678 0.123456 -> 12345678.123456
+fmax362037 fma 1 12345678 0.1234567 -> 12345678.1234567
+fmax362038 fma 1 12345678 0.12345678 -> 12345678.12345678
+fmax362039 fma 1 12345678 0.123456789 -> 12345678.12345679 Inexact Rounded
+fmax362040 fma 1 12345678 0.123456785 -> 12345678.12345678 Inexact Rounded
+fmax362041 fma 1 12345678 0.1234567850 -> 12345678.12345678 Inexact Rounded
+fmax362042 fma 1 12345678 0.1234567851 -> 12345678.12345679 Inexact Rounded
+fmax362043 fma 1 12345678 0.12345678501 -> 12345678.12345679 Inexact Rounded
+fmax362044 fma 1 12345678 0.123456785001 -> 12345678.12345679 Inexact Rounded
+fmax362045 fma 1 12345678 0.1234567850001 -> 12345678.12345679 Inexact Rounded
+fmax362046 fma 1 12345678 0.12345678500001 -> 12345678.12345679 Inexact Rounded
+fmax362047 fma 1 12345678 0.123456785000001 -> 12345678.12345679 Inexact Rounded
+fmax362048 fma 1 12345678 0.1234567850000001 -> 12345678.12345679 Inexact Rounded
+fmax362049 fma 1 12345678 0.1234567850000000 -> 12345678.12345678 Inexact Rounded
+-- 90123456
+rounding: half_even
+fmax362050 fma 1 12345678 0.0234567750000000 -> 12345678.02345678 Inexact Rounded
+fmax362051 fma 1 12345678 0.0034567750000000 -> 12345678.00345678 Inexact Rounded
+fmax362052 fma 1 12345678 0.0004567750000000 -> 12345678.00045678 Inexact Rounded
+fmax362053 fma 1 12345678 0.0000567750000000 -> 12345678.00005678 Inexact Rounded
+fmax362054 fma 1 12345678 0.0000067750000000 -> 12345678.00000678 Inexact Rounded
+fmax362055 fma 1 12345678 0.0000007750000000 -> 12345678.00000078 Inexact Rounded
+fmax362056 fma 1 12345678 0.0000000750000000 -> 12345678.00000008 Inexact Rounded
+fmax362057 fma 1 12345678 0.0000000050000000 -> 12345678.00000000 Inexact Rounded
+fmax362060 fma 1 12345678 0.0234567750000001 -> 12345678.02345678 Inexact Rounded
+fmax362061 fma 1 12345678 0.0034567750000001 -> 12345678.00345678 Inexact Rounded
+fmax362062 fma 1 12345678 0.0004567750000001 -> 12345678.00045678 Inexact Rounded
+fmax362063 fma 1 12345678 0.0000567750000001 -> 12345678.00005678 Inexact Rounded
+fmax362064 fma 1 12345678 0.0000067750000001 -> 12345678.00000678 Inexact Rounded
+fmax362065 fma 1 12345678 0.0000007750000001 -> 12345678.00000078 Inexact Rounded
+fmax362066 fma 1 12345678 0.0000000750000001 -> 12345678.00000008 Inexact Rounded
+fmax362067 fma 1 12345678 0.0000000050000001 -> 12345678.00000001 Inexact Rounded
+-- far-out residues (full coefficient gap is 16+15 digits)
+rounding: up
+fmax362070 fma 1 12345678 1E-8 -> 12345678.00000001
+fmax362071 fma 1 12345678 1E-9 -> 12345678.00000001 Inexact Rounded
+fmax362072 fma 1 12345678 1E-10 -> 12345678.00000001 Inexact Rounded
+fmax362073 fma 1 12345678 1E-11 -> 12345678.00000001 Inexact Rounded
+fmax362074 fma 1 12345678 1E-12 -> 12345678.00000001 Inexact Rounded
+fmax362075 fma 1 12345678 1E-13 -> 12345678.00000001 Inexact Rounded
+fmax362076 fma 1 12345678 1E-14 -> 12345678.00000001 Inexact Rounded
+fmax362077 fma 1 12345678 1E-15 -> 12345678.00000001 Inexact Rounded
+fmax362078 fma 1 12345678 1E-16 -> 12345678.00000001 Inexact Rounded
+fmax362079 fma 1 12345678 1E-17 -> 12345678.00000001 Inexact Rounded
+fmax362080 fma 1 12345678 1E-18 -> 12345678.00000001 Inexact Rounded
+fmax362081 fma 1 12345678 1E-19 -> 12345678.00000001 Inexact Rounded
+fmax362082 fma 1 12345678 1E-20 -> 12345678.00000001 Inexact Rounded
+fmax362083 fma 1 12345678 1E-25 -> 12345678.00000001 Inexact Rounded
+fmax362084 fma 1 12345678 1E-30 -> 12345678.00000001 Inexact Rounded
+fmax362085 fma 1 12345678 1E-31 -> 12345678.00000001 Inexact Rounded
+fmax362086 fma 1 12345678 1E-32 -> 12345678.00000001 Inexact Rounded
+fmax362087 fma 1 12345678 1E-33 -> 12345678.00000001 Inexact Rounded
+fmax362088 fma 1 12345678 1E-34 -> 12345678.00000001 Inexact Rounded
+fmax362089 fma 1 12345678 1E-35 -> 12345678.00000001 Inexact Rounded
+
+-- payload decapitate x3
+precision: 5
+fmax363000 fma 1 1 sNaN1234567890 -> NaN67890 Invalid_operation
+fmax363001 fma 1 -sNaN1234512345 1 -> -NaN12345 Invalid_operation
+fmax363002 fma sNaN1234554321 1 1 -> NaN54321 Invalid_operation
+
+-- Null tests
+fmax39990 fma 1 10 # -> NaN Invalid_operation
+fmax39991 fma 1 # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/invert.decTest b/Lib/test/decimaltestdata/invert.decTest
index a2f7be5a779..9ef5a9137ce 100644
--- a/Lib/test/decimaltestdata/invert.decTest
+++ b/Lib/test/decimaltestdata/invert.decTest
@@ -1,176 +1,176 @@
-------------------------------------------------------------------------
--- invert.decTest -- digitwise logical INVERT --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table), and examples from decArith
-invx001 invert 0 -> 111111111
-invx002 invert 1 -> 111111110
-invx003 invert 10 -> 111111101
-invx004 invert 111111111 -> 0
-invx005 invert 000000000 -> 111111111
-invx006 invert 101010101 -> '10101010'
--- and at msd and msd-1
-invx007 invert 000000000 -> 111111111
-invx009 invert 100000000 -> 11111111
-invx011 invert 000000000 -> 111111111
-invx013 invert 010000000 -> 101111111
-
--- Various lengths
--- 123456789 123456789
-invx021 invert 111111111 -> 0
-invx022 invert 111111111111 -> 0
-invx023 invert 11111111 -> 100000000
-invx025 invert 1111111 -> 110000000
-invx026 invert 111111 -> 111000000
-invx027 invert 11111 -> 111100000
-invx028 invert 1111 -> 111110000
-invx029 invert 111 -> 111111000
-invx031 invert 11 -> 111111100
-invx032 invert 1 -> 111111110
-invx033 invert 111111111111 -> 0
-invx034 invert 11111111111 -> 0
-invx035 invert 1111111111 -> 0
-invx036 invert 111111111 -> 0
-
-invx080 invert 011111111 -> 100000000
-invx081 invert 101111111 -> 10000000
-invx082 invert 110111111 -> 1000000
-invx083 invert 111011111 -> 100000
-invx084 invert 111101111 -> 10000
-invx085 invert 111110111 -> 1000
-invx086 invert 111111011 -> 100
-invx087 invert 111111101 -> 10
-invx088 invert 111111110 -> 1
-invx089 invert 011111011 -> 100000100
-invx090 invert 101111101 -> 10000010
-invx091 invert 110111110 -> 1000001
-invx092 invert 111011101 -> 100010
-invx093 invert 111101011 -> 10100
-invx094 invert 111110111 -> 1000
-invx095 invert 111101011 -> 10100
-invx096 invert 111011101 -> 100010
-invx097 invert 110111110 -> 1000001
-invx098 invert 101111101 -> 10000010
-invx099 invert 011111011 -> 100000100
-
--- non-0/1 should not be accepted, nor should signs
-invx220 invert 111111112 -> NaN Invalid_operation
-invx221 invert 333333333 -> NaN Invalid_operation
-invx222 invert 555555555 -> NaN Invalid_operation
-invx223 invert 777777777 -> NaN Invalid_operation
-invx224 invert 999999999 -> NaN Invalid_operation
-invx225 invert 222222222 -> NaN Invalid_operation
-invx226 invert 444444444 -> NaN Invalid_operation
-invx227 invert 666666666 -> NaN Invalid_operation
-invx228 invert 888888888 -> NaN Invalid_operation
-invx229 invert 999999999 -> NaN Invalid_operation
-invx230 invert 999999999 -> NaN Invalid_operation
-invx231 invert 999999999 -> NaN Invalid_operation
-invx232 invert 999999999 -> NaN Invalid_operation
--- a few randoms
-invx240 invert 567468689 -> NaN Invalid_operation
-invx241 invert 567367689 -> NaN Invalid_operation
-invx242 invert -631917772 -> NaN Invalid_operation
-invx243 invert -756253257 -> NaN Invalid_operation
-invx244 invert 835590149 -> NaN Invalid_operation
--- test MSD
-invx250 invert 200000000 -> NaN Invalid_operation
-invx251 invert 300000000 -> NaN Invalid_operation
-invx252 invert 400000000 -> NaN Invalid_operation
-invx253 invert 500000000 -> NaN Invalid_operation
-invx254 invert 600000000 -> NaN Invalid_operation
-invx255 invert 700000000 -> NaN Invalid_operation
-invx256 invert 800000000 -> NaN Invalid_operation
-invx257 invert 900000000 -> NaN Invalid_operation
--- test MSD-1
-invx270 invert 021000000 -> NaN Invalid_operation
-invx271 invert 030100000 -> NaN Invalid_operation
-invx272 invert 040010000 -> NaN Invalid_operation
-invx273 invert 050001000 -> NaN Invalid_operation
-invx274 invert 160000100 -> NaN Invalid_operation
-invx275 invert 170000010 -> NaN Invalid_operation
-invx276 invert 180000000 -> NaN Invalid_operation
-invx277 invert 190000000 -> NaN Invalid_operation
--- test LSD
-invx280 invert 000000002 -> NaN Invalid_operation
-invx281 invert 000000003 -> NaN Invalid_operation
-invx282 invert 000000004 -> NaN Invalid_operation
-invx283 invert 000000005 -> NaN Invalid_operation
-invx284 invert 101000006 -> NaN Invalid_operation
-invx285 invert 100100007 -> NaN Invalid_operation
-invx286 invert 100010008 -> NaN Invalid_operation
-invx287 invert 100001009 -> NaN Invalid_operation
--- test Middie
-invx288 invert 000020000 -> NaN Invalid_operation
-invx289 invert 000030001 -> NaN Invalid_operation
-invx290 invert 000040000 -> NaN Invalid_operation
-invx291 invert 000050000 -> NaN Invalid_operation
-invx292 invert 101060000 -> NaN Invalid_operation
-invx293 invert 100170010 -> NaN Invalid_operation
-invx294 invert 100080100 -> NaN Invalid_operation
-invx295 invert 100091000 -> NaN Invalid_operation
--- signs
-invx296 invert -100001000 -> NaN Invalid_operation
-invx299 invert 100001000 -> 11110111
-
--- Nmax, Nmin, Ntiny
-invx341 invert 9.99999999E+999 -> NaN Invalid_operation
-invx342 invert 1E-999 -> NaN Invalid_operation
-invx343 invert 1.00000000E-999 -> NaN Invalid_operation
-invx344 invert 1E-1007 -> NaN Invalid_operation
-invx345 invert -1E-1007 -> NaN Invalid_operation
-invx346 invert -1.00000000E-999 -> NaN Invalid_operation
-invx347 invert -1E-999 -> NaN Invalid_operation
-invx348 invert -9.99999999E+999 -> NaN Invalid_operation
-
--- A few other non-integers
-invx361 invert 1.0 -> NaN Invalid_operation
-invx362 invert 1E+1 -> NaN Invalid_operation
-invx363 invert 0.0 -> NaN Invalid_operation
-invx364 invert 0E+1 -> NaN Invalid_operation
-invx365 invert 9.9 -> NaN Invalid_operation
-invx366 invert 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-invx788 invert -Inf -> NaN Invalid_operation
-invx794 invert Inf -> NaN Invalid_operation
-invx821 invert NaN -> NaN Invalid_operation
-invx841 invert sNaN -> NaN Invalid_operation
--- propagating NaNs
-invx861 invert NaN1 -> NaN Invalid_operation
-invx862 invert +NaN2 -> NaN Invalid_operation
-invx863 invert NaN3 -> NaN Invalid_operation
-invx864 invert NaN4 -> NaN Invalid_operation
-invx865 invert NaN5 -> NaN Invalid_operation
-invx871 invert sNaN11 -> NaN Invalid_operation
-invx872 invert sNaN12 -> NaN Invalid_operation
-invx873 invert sNaN13 -> NaN Invalid_operation
-invx874 invert sNaN14 -> NaN Invalid_operation
-invx875 invert sNaN15 -> NaN Invalid_operation
-invx876 invert NaN16 -> NaN Invalid_operation
-invx881 invert +NaN25 -> NaN Invalid_operation
-invx882 invert -NaN26 -> NaN Invalid_operation
-invx883 invert -sNaN27 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- invert.decTest -- digitwise logical INVERT --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table), and examples from decArith
+invx001 invert 0 -> 111111111
+invx002 invert 1 -> 111111110
+invx003 invert 10 -> 111111101
+invx004 invert 111111111 -> 0
+invx005 invert 000000000 -> 111111111
+invx006 invert 101010101 -> '10101010'
+-- and at msd and msd-1
+invx007 invert 000000000 -> 111111111
+invx009 invert 100000000 -> 11111111
+invx011 invert 000000000 -> 111111111
+invx013 invert 010000000 -> 101111111
+
+-- Various lengths
+-- 123456789 123456789
+invx021 invert 111111111 -> 0
+invx022 invert 111111111111 -> 0
+invx023 invert 11111111 -> 100000000
+invx025 invert 1111111 -> 110000000
+invx026 invert 111111 -> 111000000
+invx027 invert 11111 -> 111100000
+invx028 invert 1111 -> 111110000
+invx029 invert 111 -> 111111000
+invx031 invert 11 -> 111111100
+invx032 invert 1 -> 111111110
+invx033 invert 111111111111 -> 0
+invx034 invert 11111111111 -> 0
+invx035 invert 1111111111 -> 0
+invx036 invert 111111111 -> 0
+
+invx080 invert 011111111 -> 100000000
+invx081 invert 101111111 -> 10000000
+invx082 invert 110111111 -> 1000000
+invx083 invert 111011111 -> 100000
+invx084 invert 111101111 -> 10000
+invx085 invert 111110111 -> 1000
+invx086 invert 111111011 -> 100
+invx087 invert 111111101 -> 10
+invx088 invert 111111110 -> 1
+invx089 invert 011111011 -> 100000100
+invx090 invert 101111101 -> 10000010
+invx091 invert 110111110 -> 1000001
+invx092 invert 111011101 -> 100010
+invx093 invert 111101011 -> 10100
+invx094 invert 111110111 -> 1000
+invx095 invert 111101011 -> 10100
+invx096 invert 111011101 -> 100010
+invx097 invert 110111110 -> 1000001
+invx098 invert 101111101 -> 10000010
+invx099 invert 011111011 -> 100000100
+
+-- non-0/1 should not be accepted, nor should signs
+invx220 invert 111111112 -> NaN Invalid_operation
+invx221 invert 333333333 -> NaN Invalid_operation
+invx222 invert 555555555 -> NaN Invalid_operation
+invx223 invert 777777777 -> NaN Invalid_operation
+invx224 invert 999999999 -> NaN Invalid_operation
+invx225 invert 222222222 -> NaN Invalid_operation
+invx226 invert 444444444 -> NaN Invalid_operation
+invx227 invert 666666666 -> NaN Invalid_operation
+invx228 invert 888888888 -> NaN Invalid_operation
+invx229 invert 999999999 -> NaN Invalid_operation
+invx230 invert 999999999 -> NaN Invalid_operation
+invx231 invert 999999999 -> NaN Invalid_operation
+invx232 invert 999999999 -> NaN Invalid_operation
+-- a few randoms
+invx240 invert 567468689 -> NaN Invalid_operation
+invx241 invert 567367689 -> NaN Invalid_operation
+invx242 invert -631917772 -> NaN Invalid_operation
+invx243 invert -756253257 -> NaN Invalid_operation
+invx244 invert 835590149 -> NaN Invalid_operation
+-- test MSD
+invx250 invert 200000000 -> NaN Invalid_operation
+invx251 invert 300000000 -> NaN Invalid_operation
+invx252 invert 400000000 -> NaN Invalid_operation
+invx253 invert 500000000 -> NaN Invalid_operation
+invx254 invert 600000000 -> NaN Invalid_operation
+invx255 invert 700000000 -> NaN Invalid_operation
+invx256 invert 800000000 -> NaN Invalid_operation
+invx257 invert 900000000 -> NaN Invalid_operation
+-- test MSD-1
+invx270 invert 021000000 -> NaN Invalid_operation
+invx271 invert 030100000 -> NaN Invalid_operation
+invx272 invert 040010000 -> NaN Invalid_operation
+invx273 invert 050001000 -> NaN Invalid_operation
+invx274 invert 160000100 -> NaN Invalid_operation
+invx275 invert 170000010 -> NaN Invalid_operation
+invx276 invert 180000000 -> NaN Invalid_operation
+invx277 invert 190000000 -> NaN Invalid_operation
+-- test LSD
+invx280 invert 000000002 -> NaN Invalid_operation
+invx281 invert 000000003 -> NaN Invalid_operation
+invx282 invert 000000004 -> NaN Invalid_operation
+invx283 invert 000000005 -> NaN Invalid_operation
+invx284 invert 101000006 -> NaN Invalid_operation
+invx285 invert 100100007 -> NaN Invalid_operation
+invx286 invert 100010008 -> NaN Invalid_operation
+invx287 invert 100001009 -> NaN Invalid_operation
+-- test Middie
+invx288 invert 000020000 -> NaN Invalid_operation
+invx289 invert 000030001 -> NaN Invalid_operation
+invx290 invert 000040000 -> NaN Invalid_operation
+invx291 invert 000050000 -> NaN Invalid_operation
+invx292 invert 101060000 -> NaN Invalid_operation
+invx293 invert 100170010 -> NaN Invalid_operation
+invx294 invert 100080100 -> NaN Invalid_operation
+invx295 invert 100091000 -> NaN Invalid_operation
+-- signs
+invx296 invert -100001000 -> NaN Invalid_operation
+invx299 invert 100001000 -> 11110111
+
+-- Nmax, Nmin, Ntiny
+invx341 invert 9.99999999E+999 -> NaN Invalid_operation
+invx342 invert 1E-999 -> NaN Invalid_operation
+invx343 invert 1.00000000E-999 -> NaN Invalid_operation
+invx344 invert 1E-1007 -> NaN Invalid_operation
+invx345 invert -1E-1007 -> NaN Invalid_operation
+invx346 invert -1.00000000E-999 -> NaN Invalid_operation
+invx347 invert -1E-999 -> NaN Invalid_operation
+invx348 invert -9.99999999E+999 -> NaN Invalid_operation
+
+-- A few other non-integers
+invx361 invert 1.0 -> NaN Invalid_operation
+invx362 invert 1E+1 -> NaN Invalid_operation
+invx363 invert 0.0 -> NaN Invalid_operation
+invx364 invert 0E+1 -> NaN Invalid_operation
+invx365 invert 9.9 -> NaN Invalid_operation
+invx366 invert 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+invx788 invert -Inf -> NaN Invalid_operation
+invx794 invert Inf -> NaN Invalid_operation
+invx821 invert NaN -> NaN Invalid_operation
+invx841 invert sNaN -> NaN Invalid_operation
+-- propagating NaNs
+invx861 invert NaN1 -> NaN Invalid_operation
+invx862 invert +NaN2 -> NaN Invalid_operation
+invx863 invert NaN3 -> NaN Invalid_operation
+invx864 invert NaN4 -> NaN Invalid_operation
+invx865 invert NaN5 -> NaN Invalid_operation
+invx871 invert sNaN11 -> NaN Invalid_operation
+invx872 invert sNaN12 -> NaN Invalid_operation
+invx873 invert sNaN13 -> NaN Invalid_operation
+invx874 invert sNaN14 -> NaN Invalid_operation
+invx875 invert sNaN15 -> NaN Invalid_operation
+invx876 invert NaN16 -> NaN Invalid_operation
+invx881 invert +NaN25 -> NaN Invalid_operation
+invx882 invert -NaN26 -> NaN Invalid_operation
+invx883 invert -sNaN27 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/ln.decTest b/Lib/test/decimaltestdata/ln.decTest
index f602af23775..efcb2a66065 100644
--- a/Lib/test/decimaltestdata/ln.decTest
+++ b/Lib/test/decimaltestdata/ln.decTest
@@ -1,611 +1,611 @@
-------------------------------------------------------------------------
--- ln.decTest -- decimal natural logarithm --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics (examples in specification)
-precision: 9
-lnxs001 ln 0 -> -Infinity
-lnxs002 ln 1.000 -> 0
-lnxs003 ln 2.71828183 -> 1.00000000 Inexact Rounded
-lnxs004 ln 10 -> 2.30258509 Inexact Rounded
-lnxs005 ln +Infinity -> Infinity
-
-
--- basics
-precision: 16
-lnx0001 ln 0 -> -Infinity
-lnx0002 ln 1E-9 -> -20.72326583694641 Inexact Rounded
-lnx0003 ln 0.0007 -> -7.264430222920869 Inexact Rounded
-lnx0004 ln 0.1 -> -2.302585092994046 Inexact Rounded
-lnx0005 ln 0.7 -> -0.3566749439387324 Inexact Rounded
-lnx0006 ln 1 -> 0
-lnx0007 ln 1.000 -> 0
-lnx0008 ln 1.5 -> 0.4054651081081644 Inexact Rounded
-lnx0009 ln 2 -> 0.6931471805599453 Inexact Rounded
-lnx0010 ln 2.718281828459045 -> 0.9999999999999999 Inexact Rounded
-lnx0011 ln 2.718281828459046 -> 1.000000000000000 Inexact Rounded
-lnx0012 ln 2.718281828459047 -> 1.000000000000001 Inexact Rounded
-lnx0013 ln 10 -> 2.302585092994046 Inexact Rounded
-lnx0014 ln 10.5 -> 2.351375257163478 Inexact Rounded
-lnx0015 ln 9999 -> 9.210240366975849 Inexact Rounded
-lnx0016 ln 1E6 -> 13.81551055796427 Inexact Rounded
-lnx0017 ln 1E+9 -> 20.72326583694641 Inexact Rounded
-lnx0018 ln +Infinity -> Infinity
-
--- notable cases
--- negatives
-lnx0021 ln -1E-9 -> NaN Invalid_operation
-lnx0022 ln -0.0007 -> NaN Invalid_operation
-lnx0023 ln -0.1 -> NaN Invalid_operation
-lnx0024 ln -0.7 -> NaN Invalid_operation
-lnx0025 ln -1 -> NaN Invalid_operation
-lnx0026 ln -1.5 -> NaN Invalid_operation
-lnx0027 ln -2 -> NaN Invalid_operation
-lnx0029 ln -10.5 -> NaN Invalid_operation
-lnx0028 ln -9999 -> NaN Invalid_operation
-lnx0030 ln -2.718281828459045 -> NaN Invalid_operation
-lnx0031 ln -2.718281828459046 -> NaN Invalid_operation
-lnx0032 ln -0 -> -Infinity
-lnx0033 ln -0E+17 -> -Infinity
-lnx0034 ln -0E-17 -> -Infinity
--- other zeros
-lnx0041 ln 0 -> -Infinity
-lnx0042 ln 0E+17 -> -Infinity
-lnx0043 ln 0E-17 -> -Infinity
--- infinities
-lnx0045 ln -Infinity -> NaN Invalid_operation
-lnx0046 ln +Infinity -> Infinity
--- ones
-lnx0050 ln 1 -> 0
-lnx0051 ln 1.0 -> 0
-lnx0052 ln 1.000000000000000 -> 0
-lnx0053 ln 1.000000000000000000 -> 0
-
--- lower precision basics
-Precision: 7
-lnx0101 ln 0 -> -Infinity
-lnx0102 ln 1E-9 -> -20.72327 Inexact Rounded
-lnx0103 ln 0.0007 -> -7.264430 Inexact Rounded
-lnx0104 ln 0.1 -> -2.302585 Inexact Rounded
-lnx0105 ln 0.7 -> -0.3566749 Inexact Rounded
-lnx0106 ln 1 -> 0
-lnx0107 ln 1.5 -> 0.4054651 Inexact Rounded
-lnx0108 ln 2 -> 0.6931472 Inexact Rounded
-lnx0109 ln 2.718281828459045 -> 1.000000 Inexact Rounded
-lnx0110 ln 2.718281828459046 -> 1.000000 Inexact Rounded
-lnx0111 ln 2.718281828459047 -> 1.000000 Inexact Rounded
-lnx0112 ln 10 -> 2.302585 Inexact Rounded
-lnx0113 ln 10.5 -> 2.351375 Inexact Rounded
-lnx0114 ln 9999 -> 9.210240 Inexact Rounded
-lnx0115 ln 1E6 -> 13.81551 Inexact Rounded
-lnx0116 ln 1E+9 -> 20.72327 Inexact Rounded
-lnx0117 ln +Infinity -> Infinity
-Precision: 2
-lnx0121 ln 0 -> -Infinity
-lnx0122 ln 1E-9 -> -21 Inexact Rounded
-lnx0123 ln 0.0007 -> -7.3 Inexact Rounded
-lnx0124 ln 0.1 -> -2.3 Inexact Rounded
-lnx0125 ln 0.7 -> -0.36 Inexact Rounded
-lnx0126 ln 1 -> 0
-lnx0127 ln 1.5 -> 0.41 Inexact Rounded
-lnx0128 ln 2 -> 0.69 Inexact Rounded
-lnx0129 ln 2.718281828459045 -> 1.0 Inexact Rounded
-lnx0130 ln 2.718281828459046 -> 1.0 Inexact Rounded
-lnx0131 ln 2.718281828459047 -> 1.0 Inexact Rounded
-lnx0132 ln 10 -> 2.3 Inexact Rounded
-lnx0133 ln 10.5 -> 2.4 Inexact Rounded
-lnx0134 ln 9999 -> 9.2 Inexact Rounded
-lnx0135 ln 1E6 -> 14 Inexact Rounded
-lnx0136 ln 1E+9 -> 21 Inexact Rounded
-lnx0137 ln +Infinity -> Infinity
-Precision: 1
-lnx0141 ln 0 -> -Infinity
-lnx0142 ln 1E-9 -> -2E+1 Inexact Rounded
-lnx0143 ln 0.0007 -> -7 Inexact Rounded
-lnx0144 ln 0.1 -> -2 Inexact Rounded
-lnx0145 ln 0.7 -> -0.4 Inexact Rounded
-lnx0146 ln 1 -> 0
-lnx0147 ln 1.5 -> 0.4 Inexact Rounded
-lnx0148 ln 2 -> 0.7 Inexact Rounded
-lnx0149 ln 2.718281828459045 -> 1 Inexact Rounded
-lnx0150 ln 2.718281828459046 -> 1 Inexact Rounded
-lnx0151 ln 2.718281828459047 -> 1 Inexact Rounded
-lnx0152 ln 10 -> 2 Inexact Rounded
-lnx0153 ln 10.5 -> 2 Inexact Rounded
-lnx0154 ln 9999 -> 9 Inexact Rounded
-lnx0155 ln 1E6 -> 1E+1 Inexact Rounded
-lnx0156 ln 1E+9 -> 2E+1 Inexact Rounded
-lnx0157 ln +Infinity -> Infinity
-
--- group low-precision ln(1)s:
-precision: 1
-lnx0161 ln 1 -> 0
-precision: 2
-lnx0162 ln 1 -> 0
-precision: 3
-lnx0163 ln 1 -> 0
-precision: 4
-lnx0164 ln 1 -> 0
-precision: 5
-lnx0165 ln 1 -> 0
-precision: 6
-lnx0166 ln 1 -> 0
-precision: 7
-lnx0167 ln 1 -> 0
-precision: 8
-lnx0168 ln 1 -> 0
-
--- edge-test ln(2) and ln(10) in case of lookasides
-precision: 45
-lnx201 ln 2 -> 0.693147180559945309417232121458176568075500134 Inexact Rounded
-lnx202 ln 10 -> 2.30258509299404568401799145468436420760110149 Inexact Rounded
-precision: 44
-lnx203 ln 2 -> 0.69314718055994530941723212145817656807550013 Inexact Rounded
-lnx204 ln 10 -> 2.3025850929940456840179914546843642076011015 Inexact Rounded
-precision: 43
-lnx205 ln 2 -> 0.6931471805599453094172321214581765680755001 Inexact Rounded
-lnx206 ln 10 -> 2.302585092994045684017991454684364207601101 Inexact Rounded
-precision: 42
-lnx207 ln 2 -> 0.693147180559945309417232121458176568075500 Inexact Rounded
-lnx208 ln 10 -> 2.30258509299404568401799145468436420760110 Inexact Rounded
-precision: 41
-lnx209 ln 2 -> 0.69314718055994530941723212145817656807550 Inexact Rounded
-lnx210 ln 10 -> 2.3025850929940456840179914546843642076011 Inexact Rounded
-precision: 40
-lnx211 ln 2 -> 0.6931471805599453094172321214581765680755 Inexact Rounded
-lnx212 ln 10 -> 2.302585092994045684017991454684364207601 Inexact Rounded
-precision: 39
-lnx213 ln 2 -> 0.693147180559945309417232121458176568076 Inexact Rounded
-lnx214 ln 10 -> 2.30258509299404568401799145468436420760 Inexact Rounded
-precision: 38
-lnx215 ln 2 -> 0.69314718055994530941723212145817656808 Inexact Rounded
-lnx216 ln 10 -> 2.3025850929940456840179914546843642076 Inexact Rounded
-precision: 37
-lnx217 ln 2 -> 0.6931471805599453094172321214581765681 Inexact Rounded
-lnx218 ln 10 -> 2.302585092994045684017991454684364208 Inexact Rounded
-precision: 36
-lnx219 ln 2 -> 0.693147180559945309417232121458176568 Inexact Rounded
-lnx220 ln 10 -> 2.30258509299404568401799145468436421 Inexact Rounded
-precision: 35
-lnx221 ln 2 -> 0.69314718055994530941723212145817657 Inexact Rounded
-lnx222 ln 10 -> 2.3025850929940456840179914546843642 Inexact Rounded
-precision: 34
-lnx223 ln 2 -> 0.6931471805599453094172321214581766 Inexact Rounded
-lnx224 ln 10 -> 2.302585092994045684017991454684364 Inexact Rounded
-precision: 33
-lnx225 ln 2 -> 0.693147180559945309417232121458177 Inexact Rounded
-lnx226 ln 10 -> 2.30258509299404568401799145468436 Inexact Rounded
-precision: 32
-lnx227 ln 2 -> 0.69314718055994530941723212145818 Inexact Rounded
-lnx228 ln 10 -> 2.3025850929940456840179914546844 Inexact Rounded
-precision: 31
-lnx229 ln 2 -> 0.6931471805599453094172321214582 Inexact Rounded
-lnx230 ln 10 -> 2.302585092994045684017991454684 Inexact Rounded
-precision: 30
-lnx231 ln 2 -> 0.693147180559945309417232121458 Inexact Rounded
-lnx232 ln 10 -> 2.30258509299404568401799145468 Inexact Rounded
-
--- extreme input range values
-maxExponent: 384
-minExponent: -383
-Precision: 16
-
-lnx0901 ln 1e-400 -> -921.0340371976183 Inexact Rounded
-lnx0902 ln 1e+400 -> 921.0340371976183 Inexact Rounded
-lnx0903 ln 1e-999999 -> -2302582.790408953 Inexact Rounded
-lnx0904 ln 1e+999999 -> 2302582.790408953 Inexact Rounded
-lnx0905 ln 1e-1000013 -> -2302615.026600255 Inexact Rounded
-lnx0906 ln 2e-1000013 -> -2302614.333453074 Inexact Rounded
-
-lnx0910 ln 9.999999e+999999 -> 2302585.092993946 Inexact Rounded
-lnx0911 ln 9.9999999e+999999 -> 2302585.092994036 Inexact Rounded
-lnx0912 ln 9.99999999e+999999 -> 2302585.092994045 Inexact Rounded
-lnx0913 ln 9.999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0914 ln 9.999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0915 ln 9.999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-lnx0916 ln 9.999999999999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
-
--- randoms
--- P=50, within 0-999
-Precision: 50
-maxExponent: 384
-minExponent: -383
-lnx1501 ln 0.00098800906574486388604608477869812518857023768951 -> -6.9198186844033787995945147836955586009548513043689 Inexact Rounded
-lnx1502 ln 158.15866624664623070184595045304145949900714987827 -> 5.0635987458895647454907806507503825602758392287684 Inexact Rounded
-lnx1503 ln 0.00565661412059571925040285814021799775249288309321 -> -5.1749297776760632102047540300491550931651318975237 Inexact Rounded
-lnx1504 ln 0.00000006914232532620489602008402091666547903180607 -> -16.487098770877825308138976818688771638172333034347 Inexact Rounded
-lnx1505 ln 0.00025380374621297657504661540749355251231770070723 -> -8.2789492423005003205242162741569033124260321954589 Inexact Rounded
-lnx1506 ln 83.033654063877426261108592599182418953442677554806 -> 4.4192459962647137976949249810815698465031609843669 Inexact Rounded
-lnx1507 ln 0.00000000416863228092481651627734668440663678118729 -> -19.295677845122141772791294599714950175284915666430 Inexact Rounded
-lnx1508 ln 0.00000140847873187820570181214271960511080523457669 -> -13.473000349581967189668305314384952251556809480339 Inexact Rounded
-lnx1509 ln 66.176106555181527101630351127583944689752069132522 -> 4.1923194696232505883666171116966137694013431504252 Inexact Rounded
-lnx1510 ln 0.00000000000009899043487403590900111602024562297908 -> -29.943753166877840985821508112917991506656545174163 Inexact Rounded
-lnx1511 ln 0.00000000000324618296721747097510453388683912733569 -> -26.453541281444586819009546418577507163362590139422 Inexact Rounded
-lnx1512 ln 72.646968818463546449499147579023555008392860423385 -> 4.2856116660689646882852128853423566276718230426479 Inexact Rounded
-lnx1513 ln 0.00000000000000066755483124635612574263153825990523 -> -34.942910142802769319262875080398852491588707172483 Inexact Rounded
-lnx1514 ln 61.002910447202398204114909451851111424657671911002 -> 4.1109215752843377323363182051446177066434038096529 Inexact Rounded
-lnx1515 ln 917.06917611331980999227893584010544542312239174774 -> 6.8211829068303114128752453661946446979787826282907 Inexact Rounded
-lnx1516 ln 0.00000000170823794883673083358549749078972003965194 -> -20.187803436976150477297246666771626827057191023004 Inexact Rounded
-lnx1517 ln 0.53731767845358224445809761315159249898566542910649 -> -0.62116577939968409211736413628236285160048357000961 Inexact Rounded
-lnx1518 ln 0.00000000000000008965291392882804161299758708033373 -> -36.950585970980857376081265073276303670820056916206 Inexact Rounded
-lnx1519 ln 0.00000000006990244916026429904498278982530170295668 -> -23.383920429244457578373523508427783144589480420753 Inexact Rounded
-lnx1520 ln 4.0312542977070300070506064666536478373801988540614 -> 1.3940775676592451945795752796421391871302024763305 Inexact Rounded
-lnx1521 ln 271.84991311551875601432518819562391699324632396423 -> 5.6052501239873862517916679747146539808077431873478 Inexact Rounded
-lnx1522 ln 7.4118671629373864667229445746862314443895404818689 -> 2.0030823863706344628239147639318289961917060121141 Inexact Rounded
-lnx1523 ln 0.00000000000002026311452625364905357321664186034258 -> -31.529974180054438792043856877314043794320951134754 Inexact Rounded
-lnx1524 ln 0.00000000000009563398651261756952398250624737809347 -> -29.978248130576972953141284136962670021368834792579 Inexact Rounded
-lnx1525 ln 0.00000000009556772669409858653026558223465197808991 -> -23.071185939748285541228206161472956661196956741186 Inexact Rounded
-lnx1526 ln 6.8441648298027301292342057248737326152250794026761 -> 1.9233964395801946597272589473417948024361005082908 Inexact Rounded
-lnx1527 ln 0.00000000000073059699884439979394945822035704264577 -> -27.944914388353724718836101828677771967128509603158 Inexact Rounded
-lnx1528 ln 0.00000000000000002610078280419082263138064745416787 -> -38.184566367516207885573773320135965798717120735115 Inexact Rounded
-lnx1529 ln 0.00000000000000000150259517166294243088546806083283 -> -41.039337946266676108538170837580051699618334928421 Inexact Rounded
-lnx1530 ln 0.00000000000000087919160541714580707181969708502091 -> -34.667528818827671507514319744047440696187358676848 Inexact Rounded
-lnx1531 ln 0.00000000000395726725120787763271849577708068584598 -> -26.255467416961357741818735787226671938678424748431 Inexact Rounded
-lnx1532 ln 0.00000000002014334901669366218018377213150715938355 -> -24.628146955635359035289123027319969201693737159108 Inexact Rounded
-lnx1533 ln 0.00000008097927101101093117753938766241442896030637 -> -16.329072628469715178637178365710373398203190937454 Inexact Rounded
-lnx1534 ln 0.00000000000017115834162632864392039668116243984176 -> -29.396187292434898225453626794459285157263177528034 Inexact Rounded
-lnx1535 ln 0.39168317593866334087305459933723864294857086105035 -> -0.93730199062757240485836637306785037368746737693029 Inexact Rounded
-lnx1536 ln 79.335036798971515026519630103325369729637514127617 -> 4.3736798570287828823772149735170431010616961976965 Inexact Rounded
-lnx1537 ln 0.00000000000000056004952129926137413602116591493625 -> -35.118506463181870020730685884333000241039028127213 Inexact Rounded
-lnx1538 ln 0.00000006006035907843890918832481099660639553666078 -> -16.627915795747112566532705974853114454405010472043 Inexact Rounded
-lnx1539 ln 0.00000000085242024937414906371333826574632450587590 -> -20.882941460268101080186482230657774997273494107221 Inexact Rounded
-lnx1540 ln 0.00000000000043671099499262350316173246550771951561 -> -28.459504757285639221776305968469058854558726593945 Inexact Rounded
-
--- P=34, within 0-999
-Precision: 34
-lnx1201 ln 0.0086732880815927182997566810334394 -> -4.747507311920844752486938187973721 Inexact Rounded
-lnx1202 ln 0.0007104103693460260609792222569854 -> -7.249667769903503023005549250347695 Inexact Rounded
-lnx1203 ln 786.8398945385105190697541493392742 -> 6.668024790031836340471824147010546 Inexact Rounded
-lnx1204 ln 0.7723073620282687656895190171967399 -> -0.2583726708506850868786816238217326 Inexact Rounded
-lnx1205 ln 0.0061057951517197631287183938412200 -> -5.098516933918797347064454103742635 Inexact Rounded
-lnx1206 ln 0.6181379708184393730103917562498745 -> -0.4810435926903365087463387760350021 Inexact Rounded
-lnx1207 ln 09.13888261229039989110753389096760 -> 2.212538125507975574509563027696021 Inexact Rounded
-lnx1208 ln 802.0105417063143696497292158147174 -> 6.687121752052341737234832203350214 Inexact Rounded
-lnx1209 ln 778.7749710387773713523028497333058 -> 6.657722135126935472086625031413031 Inexact Rounded
-lnx1210 ln 0.0024457295895346502513567679390616 -> -6.013411799940245345321348290398517 Inexact Rounded
-lnx1211 ln 0.0000511296947872828310338864217860 -> -9.881145118237281798081573131711636 Inexact Rounded
-lnx1212 ln 0.0000246803508602554924938685155658 -> -10.60950314264825661825360971430218 Inexact Rounded
-lnx1213 ln 9.027898199253511668242977766616082 -> 2.200319582778899029786017830557293 Inexact Rounded
-lnx1214 ln 0.0991812396542505631850692800904188 -> -2.310806398964672258823043180400384 Inexact Rounded
-lnx1215 ln 0.0000000000070238810143028811223924 -> -25.68170519961636647174714538290075 Inexact Rounded
-lnx1216 ln 2.630101665342826494730394729313167 -> 0.9670225014664367465128243039749559 Inexact Rounded
-lnx1217 ln 0.0056878928594359587691526063254683 -> -5.169415422904037819736637399445096 Inexact Rounded
-lnx1218 ln 567.3436047121057843908106573095590 -> 6.340965124964258486463444360787970 Inexact Rounded
-lnx1219 ln 1.199291248124655996614605745649725 -> 0.1817307557425911805765087755675657 Inexact Rounded
-lnx1220 ln 25.02050448582031098696267479135557 -> 3.219695668137659139544178905459317 Inexact Rounded
-lnx1221 ln 0.0000000000009939597023558756961300 -> -27.63707972996537636504396558259058 Inexact Rounded
-lnx1222 ln 0.0000007988551670159429716506430403 -> -14.04008617542597230988198612376415 Inexact Rounded
-lnx1223 ln 4.681515800176129184873770605589795 -> 1.543621946415383338972124445445748 Inexact Rounded
-lnx1224 ln 15.95126669161103011206658749345781 -> 2.769538242479483539275986395443539 Inexact Rounded
-lnx1225 ln 0.0301626783922211213675457279076066 -> -3.501149933677283341023932281826341 Inexact Rounded
-lnx1226 ln 000.0040544064881821770528475185674 -> -5.507950967557021671647165889608324 Inexact Rounded
-lnx1227 ln 29.01617095935593792095913785100360 -> 3.367853293862745651888450004473297 Inexact Rounded
-lnx1228 ln 78.01836167344736733024804243195323 -> 4.356944205055768575987781375003992 Inexact Rounded
-lnx1229 ln 0.0000000096545319316965321158634893 -> -18.45583840160965814462095477365013 Inexact Rounded
-lnx1230 ln 97.95475237720579752770587185074428 -> 4.584505661612812742208619358214729 Inexact Rounded
-lnx1231 ln 528.0609262050423246402564228432371 -> 6.269211667589138113396583894315956 Inexact Rounded
-lnx1232 ln 0.0000002250064349732969696660452972 -> -15.30713683526963996712167701738724 Inexact Rounded
-lnx1233 ln 47.97063637767998658567199049725754 -> 3.870589081585660692195989854842372 Inexact Rounded
-lnx1234 ln 0.0005394311344541432318853513414361 -> -7.524995428393925934087126702974121 Inexact Rounded
-lnx1235 ln 0.0000000090973385649567471674972633 -> -18.51528393158931783447035004125791 Inexact Rounded
-lnx1236 ln 0.0000000000238776490227576197317977 -> -24.45807828188389561331158879207262 Inexact Rounded
-lnx1237 ln 0.0000236587000231921532145326218758 -> -10.65177964499823314952429277979034 Inexact Rounded
-lnx1238 ln 499.1277448846130709827154556125942 -> 6.212862064761427967461188083514774 Inexact Rounded
-lnx1239 ln 0.0000003960192300284787663712417647 -> -14.74180306619298548093697608293284 Inexact Rounded
-lnx1240 ln 41.08268350829477451667228892495136 -> 3.715586706887278039173584859218960 Inexact Rounded
-
--- P=16, within 0-99
-Precision: 16
-lnx1101 ln 7.964875261033948 -> 2.075041282352241 Inexact Rounded
-lnx1102 ln 13.54527396845394 -> 2.606037701870263 Inexact Rounded
-lnx1103 ln 0.0008026554341331 -> -7.127585034321814 Inexact Rounded
-lnx1104 ln 0.0000030582233261 -> -12.69767642300625 Inexact Rounded
-lnx1105 ln 0.0004477497509672 -> -7.711276073210766 Inexact Rounded
-lnx1106 ln 7.616268622474371 -> 2.030286567675148 Inexact Rounded
-lnx1107 ln 51.58329925806381 -> 3.943197962309569 Inexact Rounded
-lnx1108 ln 0.0018197497951263 -> -6.309056262549345 Inexact Rounded
-lnx1109 ln 2.956282457072984 -> 1.083932552334575 Inexact Rounded
-lnx1110 ln 0.3843325579189906 -> -0.9562470649400558 Inexact Rounded
-lnx1111 ln 0.0074466329265663 -> -4.899993304919237 Inexact Rounded
-lnx1112 ln 0.0003372478532993 -> -7.994692428206378 Inexact Rounded
-lnx1113 ln 0.0084792263167809 -> -4.770136069569271 Inexact Rounded
-lnx1114 ln 5.926756998151102 -> 1.779477182834305 Inexact Rounded
-lnx1115 ln 9.025699152180897 -> 2.200075969604119 Inexact Rounded
-lnx1116 ln 1.910124643533526 -> 0.6471684983238183 Inexact Rounded
-lnx1117 ln 0.8158922711411020 -> -0.2034729533939387 Inexact Rounded
-lnx1118 ln 0.0067080016475322 -> -5.004454189414139 Inexact Rounded
-lnx1119 ln 0.0047583242092716 -> -5.347859729601094 Inexact Rounded
-lnx1120 ln 0.0386647411641339 -> -3.252827175263113 Inexact Rounded
-lnx1121 ln 0.0050226427841761 -> -5.293799032774131 Inexact Rounded
-lnx1122 ln 6.927937541637261 -> 1.935562155866906 Inexact Rounded
-lnx1123 ln 0.0000095745343513 -> -11.55640365579814 Inexact Rounded
-lnx1124 ln 1.602465492956538 -> 0.4715433763243936 Inexact Rounded
-lnx1125 ln 38.98415625087535 -> 3.663155313610213 Inexact Rounded
-lnx1126 ln 5.343182042276734 -> 1.675821363568112 Inexact Rounded
-lnx1127 ln 55.89763703245816 -> 4.023522107934110 Inexact Rounded
-lnx1128 ln 0.7445257810280847 -> -0.2950077988101030 Inexact Rounded
-lnx1129 ln 1.631407314946094 -> 0.4894430257201248 Inexact Rounded
-lnx1130 ln 0.0005462451932602 -> -7.512442611116852 Inexact Rounded
-lnx1131 ln 0.0000864173269362 -> -9.356322359017317 Inexact Rounded
-lnx1132 ln 5.227161719132849 -> 1.653868438439637 Inexact Rounded
-lnx1133 ln 60.57078466941998 -> 4.103812675662452 Inexact Rounded
-lnx1134 ln 0.0992864325333160 -> -2.309746348350318 Inexact Rounded
-lnx1135 ln 09.48564268447325 -> 2.249779359074983 Inexact Rounded
-lnx1136 ln 0.0036106089355634 -> -5.623878840650787 Inexact Rounded
-lnx1137 ln 1.805176865587172 -> 0.5906585734593707 Inexact Rounded
-lnx1138 ln 62.59363259642255 -> 4.136663557220559 Inexact Rounded
-lnx1139 ln 4.373828261137201 -> 1.475638657912000 Inexact Rounded
-lnx1140 ln 0.994483524148738 -> -0.005531747794938690 Inexact Rounded
-
--- P=7, within 0-9
-Precision: 7
-lnx1001 ln 0.0912025 -> -2.394673 Inexact Rounded
-lnx1002 ln 0.9728626 -> -0.02751242 Inexact Rounded
-lnx1003 ln 0.3886032 -> -0.9451965 Inexact Rounded
-lnx1004 ln 8.798639 -> 2.174597 Inexact Rounded
-lnx1005 ln 2.459121 -> 0.8998040 Inexact Rounded
-lnx1006 ln 2.013193 -> 0.6997220 Inexact Rounded
-lnx1007 ln 9.064857 -> 2.204405 Inexact Rounded
-lnx1008 ln 5.796417 -> 1.757240 Inexact Rounded
-lnx1009 ln 0.1143471 -> -2.168517 Inexact Rounded
-lnx1010 ln 0.5341542 -> -0.6270707 Inexact Rounded
-lnx1011 ln 6.693781 -> 1.901179 Inexact Rounded
-lnx1012 ln 0.0081779 -> -4.806320 Inexact Rounded
-lnx1013 ln 8.313616 -> 2.117895 Inexact Rounded
-lnx1014 ln 3.486925 -> 1.249020 Inexact Rounded
-lnx1015 ln 0.1801401 -> -1.714020 Inexact Rounded
-lnx1016 ln 0.5227148 -> -0.6487193 Inexact Rounded
-lnx1017 ln 7.818111 -> 2.056443 Inexact Rounded
-lnx1018 ln 0.0870671 -> -2.441076 Inexact Rounded
-lnx1019 ln 8.153966 -> 2.098504 Inexact Rounded
-lnx1020 ln 2.040975 -> 0.7134276 Inexact Rounded
-lnx1021 ln 1.481642 -> 0.3931509 Inexact Rounded
-lnx1022 ln 0.2610123 -> -1.343188 Inexact Rounded
-lnx1023 ln 0.466723 -> -0.7620193 Inexact Rounded
-lnx1024 ln 0.0518756 -> -2.958907 Inexact Rounded
-lnx1025 ln 2.056410 -> 0.7209617 Inexact Rounded
-lnx1026 ln 0.181522 -> -1.706378 Inexact Rounded
-lnx1027 ln 0.515551 -> -0.6625190 Inexact Rounded
-lnx1028 ln 8.425089 -> 2.131214 Inexact Rounded
-lnx1029 ln 2.077091 -> 0.7309684 Inexact Rounded
-lnx1030 ln 6.212705 -> 1.826596 Inexact Rounded
-lnx1031 ln 5.729343 -> 1.745601 Inexact Rounded
-lnx1032 ln 4.831251 -> 1.575105 Inexact Rounded
-lnx1033 ln 2.029760 -> 0.7079176 Inexact Rounded
-lnx1034 ln 8.615060 -> 2.153512 Inexact Rounded
-lnx1035 ln 0.0611511 -> -2.794407 Inexact Rounded
-lnx1036 ln 5.195269 -> 1.647748 Inexact Rounded
-lnx1037 ln 9.617686 -> 2.263604 Inexact Rounded
-lnx1038 ln 0.0049382 -> -5.310754 Inexact Rounded
-lnx1039 ln 2.786840 -> 1.024908 Inexact Rounded
-lnx1040 ln 0.0091073 -> -4.698679 Inexact Rounded
-
--- from here 3-digit tests are based on reverse exp tests
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
-lnx001 ln 0 -> -Infinity
-lnx002 ln 0.367879441 -> -1.00000000 Inexact Rounded
-lnx003 ln 1 -> 0
-lnx005 ln 2.71828183 -> 1.00000000 Inexact Rounded
-lnx006 ln 2.00000000 -> 0.693147181 Inexact Rounded
-lnx007 ln +Infinity -> Infinity
-
--- tiny edge cases
-precision: 7
-lnx011 ln 1.105171 -> 0.1000001 Inexact Rounded
-lnx012 ln 1.010050 -> 0.009999835 Inexact Rounded
-lnx013 ln 1.000010 -> 0.000009999950 Inexact Rounded
-lnx014 ln 1.000001 -> 9.999995E-7 Inexact Rounded
-lnx015 ln 1.000000 -> 0
-
--- basic e=0, e=1, e=2, e=4, e>=8 cases
-precision: 7
-lnx041 ln 2.718282 -> 1.000000 Inexact Rounded
-lnx042 ln 0.3678794 -> -1.000000 Inexact Rounded
-lnx043 ln 22026.47 -> 10.00000 Inexact Rounded
-lnx044 ln 0.00004539993 -> -10.00000 Inexact Rounded
-lnx045 ln 2.688117E+43 -> 100.0000 Inexact Rounded
-lnx046 ln 3.720076E-44 -> -100.0000 Inexact Rounded
-lnx047 ln Infinity -> Infinity
-lnx048 ln 0E-389 -> -Infinity
-
--- miscellanea
-precision: 16
-lnx055 ln 2.717658486884572E-236 -> -542.4103112874415 Inexact Rounded
-precision: 17
-lnx056 ln 2.7176584868845721E-236 -> -542.41031128744146 Inexact Rounded
-precision: 18
-lnx057 ln 2.71765848688457211E-236 -> -542.410311287441459 Inexact Rounded
-precision: 19
-lnx058 ln 2.717658486884572112E-236 -> -542.4103112874414592 Inexact Rounded
-precision: 20
-lnx059 ln 2.7176584868845721118E-236 -> -542.41031128744145917 Inexact Rounded
-
--- inputs ending in ..500.., ..499.., ..100.., ..999.. sequences
-precision: 50
-lnx102 ln 0.9999999100000040499998785000027 -> -9.0000000000000000000000033749953829996446124861750E-8 Inexact Rounded
-precision: 30
-lnx103 ln 0.999999910000004049999878500003 -> -8.99999999999999999999997337499E-8 Inexact Rounded
-precision: 29
-lnx104 ln 0.99999991000000404999987850000 -> -9.0000000000000000000002733750E-8 Inexact Rounded
-precision: 28
-lnx105 ln 0.9999999100000040499998785000 -> -9.000000000000000000000273375E-8 Inexact Rounded
-precision: 27
-lnx106 ln 0.999999910000004049999878500 -> -9.00000000000000000000027338E-8 Inexact Rounded
-precision: 26
-lnx107 ln 0.99999991000000404999987850 -> -9.0000000000000000000002734E-8 Inexact Rounded
-precision: 25
-lnx108 ln 0.9999999100000040499998785 -> -9.000000000000000000000273E-8 Inexact Rounded
-precision: 24
-lnx109 ln 0.999999910000004049999879 -> -8.99999999999999995000027E-8 Inexact Rounded
-precision: 23
-lnx110 ln 0.99999991000000404999988 -> -8.9999999999999998500003E-8 Inexact Rounded
-precision: 22
-lnx111 ln 0.9999999100000040499999 -> -8.999999999999997850000E-8 Inexact Rounded
-precision: 21
-lnx112 ln 0.999999910000004050000 -> -8.99999999999998785000E-8 Inexact Rounded
-precision: 20
-lnx113 ln 0.99999991000000405000 -> -8.9999999999999878500E-8 Inexact Rounded
-precision: 19
-lnx114 ln 0.9999999100000040500 -> -8.999999999999987850E-8 Inexact Rounded
-precision: 18
-lnx115 ln 0.999999910000004050 -> -8.99999999999998785E-8 Inexact Rounded
--- next may be a > 0.5ulp case; a more precise answer is:
--- -8.99999999999998784999918E-8
-precision: 17
-lnx116 ln 0.99999991000000405 -> -8.9999999999999878E-8 Inexact Rounded
-precision: 16
-lnx117 ln 0.9999999100000040 -> -9.000000004999988E-8 Inexact Rounded
-precision: 15
-lnx118 ln 0.999999910000004 -> -9.00000000499999E-8 Inexact Rounded
-precision: 14
-lnx119 ln 0.99999991000000 -> -9.0000004050000E-8 Inexact Rounded
-precision: 13
-lnx120 ln 0.9999999100000 -> -9.000000405000E-8 Inexact Rounded
-precision: 12
-lnx121 ln 0.999999910000 -> -9.00000040500E-8 Inexact Rounded
-precision: 11
-lnx122 ln 0.99999991000 -> -9.0000004050E-8 Inexact Rounded
-precision: 10
-lnx123 ln 0.9999999100 -> -9.000000405E-8 Inexact Rounded
-precision: 9
-lnx124 ln 0.999999910 -> -9.00000041E-8 Inexact Rounded
-precision: 8
-lnx125 ln 0.99999991 -> -9.0000004E-8 Inexact Rounded
-precision: 7
-lnx126 ln 0.9999999 -> -1.000000E-7 Inexact Rounded
-precision: 16
-lnx126b ln 0.9999999 -> -1.000000050000003E-7 Inexact Rounded
-precision: 6
-lnx127 ln 0.999999 -> -0.00000100000 Inexact Rounded
-precision: 5
-lnx128 ln 0.99999 -> -0.000010000 Inexact Rounded
-precision: 4
-lnx129 ln 0.9999 -> -0.0001000 Inexact Rounded
-precision: 3
-lnx130 ln 0.999 -> -0.00100 Inexact Rounded
-precision: 2
-lnx131 ln 0.99 -> -0.010 Inexact Rounded
-precision: 1
-lnx132 ln 0.9 -> -0.1 Inexact Rounded
-
-
--- cases near 1 -- 1 2345678901234567890
-precision: 20
-lnx401 ln 2.7182818284589365041 -> 0.99999999999996000000 Inexact Rounded
-lnx402 ln 2.7182818284589636869 -> 0.99999999999997000000 Inexact Rounded
-lnx403 ln 2.7182818284589908697 -> 0.99999999999997999999 Inexact Rounded
-lnx404 ln 2.7182818284590180525 -> 0.99999999999998999998 Inexact Rounded
-lnx405 ln 2.7182818284590452354 -> 1.0000000000000000000 Inexact Rounded
-lnx406 ln 2.7182818284593170635 -> 1.0000000000001000000 Inexact Rounded
-lnx407 ln 2.7182818284595888917 -> 1.0000000000002000000 Inexact Rounded
-precision: 14
-lnx411 ln 2.7182818284589 -> 0.99999999999995 Inexact Rounded
-lnx413 ln 2.7182818284590 -> 0.99999999999998 Inexact Rounded
-lnx416 ln 2.7182818284591 -> 1.0000000000000 Inexact Rounded
-lnx417 ln 2.7182818284592 -> 1.0000000000001 Inexact Rounded
-
--- overflows, including some exp overprecise borderlines
-precision: 7
-maxExponent: 384
-minExponent: -383
-lnx709 ln 9.999999E+384 -> 886.4953 Inexact Rounded
-lnx711 ln 9.999992E+384 -> 886.4953 Inexact Rounded
-precision: 16
-lnx722 ln 9.999999999999999E+384 -> 886.4952608027076 Inexact Rounded
-lnx724 ln 9.999999999999917E+384 -> 886.4952608027076 Inexact Rounded
-lnx726 ln 9.999999999999117E+384 -> 886.4952608027075 Inexact Rounded
--- and more...
-precision: 15
-maxExponent: 999
-minExponent: -999
-lnx731 ln 9.99999999999999E+999 -> 2302.58509299405 Inexact Rounded
--- next may be a > 0.5ulp case; a more precise answer is:
--- 2302.58509299404495001799145442
-lnx732 ln 9.99999999999266E+999 -> 2302.58509299404 Inexact Rounded
-lnx733 ln 9.99999999999265E+999 -> 2302.58509299404 Inexact Rounded
-lnx734 ln 9.99999999999264E+999 -> 2302.58509299404 Inexact Rounded
-
--- subnormals and underflows for exp, including underflow-to-zero edge point
-precision: 7
-maxExponent: 384
-minExponent: -383
-lnx751 ln 0E-389 -> -Infinity
-lnx758 ln 1.000001E-383 -> -881.8901 Inexact Rounded
-lnx759 ln 9.99991E-384 -> -881.8901 Inexact Rounded
-lnx760 ln 4.4605E-385 -> -885.0000 Inexact Rounded
-lnx761 ln 2.221E-386 -> -887.9999 Inexact Rounded
-lnx762 ln 3.01E-387 -> -889.9985 Inexact Rounded
-lnx763 ln 1.7E-388 -> -892.8724 Inexact Rounded
-lnx764 ln 1.5E-388 -> -892.9976 Inexact Rounded
-lnx765 ln 9E-389 -> -893.5084 Inexact Rounded
-lnx766 ln 1E-389 -> -895.7056 Inexact Rounded
-lnx774 ln 0E-389 -> -Infinity
-
--- special values
-lnx820 ln Infinity -> Infinity
-lnx821 ln 0 -> -Infinity
-lnx822 ln NaN -> NaN
-lnx823 ln sNaN -> NaN Invalid_operation
--- propagating NaNs
-lnx824 ln sNaN123 -> NaN123 Invalid_operation
-lnx825 ln -sNaN321 -> -NaN321 Invalid_operation
-lnx826 ln NaN456 -> NaN456
-lnx827 ln -NaN654 -> -NaN654
-lnx828 ln NaN1 -> NaN1
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-lnx901 ln 1 -> NaN Invalid_context
-precision: 99999999
-lnx902 ln 0 -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-lnx903 ln 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-lnx904 ln 0 -> -Infinity
-maxExponent: 999999
-minExponent: -1000000
-lnx905 ln 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-lnx906 ln 0 -> -Infinity
-
--- payload decapitate
-precision: 5
-lnx910 ln -sNaN1234567890 -> -NaN67890 Invalid_operation
-
--- Null test
-lnx900 ln # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- ln.decTest -- decimal natural logarithm --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics (examples in specification)
+precision: 9
+lnxs001 ln 0 -> -Infinity
+lnxs002 ln 1.000 -> 0
+lnxs003 ln 2.71828183 -> 1.00000000 Inexact Rounded
+lnxs004 ln 10 -> 2.30258509 Inexact Rounded
+lnxs005 ln +Infinity -> Infinity
+
+
+-- basics
+precision: 16
+lnx0001 ln 0 -> -Infinity
+lnx0002 ln 1E-9 -> -20.72326583694641 Inexact Rounded
+lnx0003 ln 0.0007 -> -7.264430222920869 Inexact Rounded
+lnx0004 ln 0.1 -> -2.302585092994046 Inexact Rounded
+lnx0005 ln 0.7 -> -0.3566749439387324 Inexact Rounded
+lnx0006 ln 1 -> 0
+lnx0007 ln 1.000 -> 0
+lnx0008 ln 1.5 -> 0.4054651081081644 Inexact Rounded
+lnx0009 ln 2 -> 0.6931471805599453 Inexact Rounded
+lnx0010 ln 2.718281828459045 -> 0.9999999999999999 Inexact Rounded
+lnx0011 ln 2.718281828459046 -> 1.000000000000000 Inexact Rounded
+lnx0012 ln 2.718281828459047 -> 1.000000000000001 Inexact Rounded
+lnx0013 ln 10 -> 2.302585092994046 Inexact Rounded
+lnx0014 ln 10.5 -> 2.351375257163478 Inexact Rounded
+lnx0015 ln 9999 -> 9.210240366975849 Inexact Rounded
+lnx0016 ln 1E6 -> 13.81551055796427 Inexact Rounded
+lnx0017 ln 1E+9 -> 20.72326583694641 Inexact Rounded
+lnx0018 ln +Infinity -> Infinity
+
+-- notable cases
+-- negatives
+lnx0021 ln -1E-9 -> NaN Invalid_operation
+lnx0022 ln -0.0007 -> NaN Invalid_operation
+lnx0023 ln -0.1 -> NaN Invalid_operation
+lnx0024 ln -0.7 -> NaN Invalid_operation
+lnx0025 ln -1 -> NaN Invalid_operation
+lnx0026 ln -1.5 -> NaN Invalid_operation
+lnx0027 ln -2 -> NaN Invalid_operation
+lnx0029 ln -10.5 -> NaN Invalid_operation
+lnx0028 ln -9999 -> NaN Invalid_operation
+lnx0030 ln -2.718281828459045 -> NaN Invalid_operation
+lnx0031 ln -2.718281828459046 -> NaN Invalid_operation
+lnx0032 ln -0 -> -Infinity
+lnx0033 ln -0E+17 -> -Infinity
+lnx0034 ln -0E-17 -> -Infinity
+-- other zeros
+lnx0041 ln 0 -> -Infinity
+lnx0042 ln 0E+17 -> -Infinity
+lnx0043 ln 0E-17 -> -Infinity
+-- infinities
+lnx0045 ln -Infinity -> NaN Invalid_operation
+lnx0046 ln +Infinity -> Infinity
+-- ones
+lnx0050 ln 1 -> 0
+lnx0051 ln 1.0 -> 0
+lnx0052 ln 1.000000000000000 -> 0
+lnx0053 ln 1.000000000000000000 -> 0
+
+-- lower precision basics
+Precision: 7
+lnx0101 ln 0 -> -Infinity
+lnx0102 ln 1E-9 -> -20.72327 Inexact Rounded
+lnx0103 ln 0.0007 -> -7.264430 Inexact Rounded
+lnx0104 ln 0.1 -> -2.302585 Inexact Rounded
+lnx0105 ln 0.7 -> -0.3566749 Inexact Rounded
+lnx0106 ln 1 -> 0
+lnx0107 ln 1.5 -> 0.4054651 Inexact Rounded
+lnx0108 ln 2 -> 0.6931472 Inexact Rounded
+lnx0109 ln 2.718281828459045 -> 1.000000 Inexact Rounded
+lnx0110 ln 2.718281828459046 -> 1.000000 Inexact Rounded
+lnx0111 ln 2.718281828459047 -> 1.000000 Inexact Rounded
+lnx0112 ln 10 -> 2.302585 Inexact Rounded
+lnx0113 ln 10.5 -> 2.351375 Inexact Rounded
+lnx0114 ln 9999 -> 9.210240 Inexact Rounded
+lnx0115 ln 1E6 -> 13.81551 Inexact Rounded
+lnx0116 ln 1E+9 -> 20.72327 Inexact Rounded
+lnx0117 ln +Infinity -> Infinity
+Precision: 2
+lnx0121 ln 0 -> -Infinity
+lnx0122 ln 1E-9 -> -21 Inexact Rounded
+lnx0123 ln 0.0007 -> -7.3 Inexact Rounded
+lnx0124 ln 0.1 -> -2.3 Inexact Rounded
+lnx0125 ln 0.7 -> -0.36 Inexact Rounded
+lnx0126 ln 1 -> 0
+lnx0127 ln 1.5 -> 0.41 Inexact Rounded
+lnx0128 ln 2 -> 0.69 Inexact Rounded
+lnx0129 ln 2.718281828459045 -> 1.0 Inexact Rounded
+lnx0130 ln 2.718281828459046 -> 1.0 Inexact Rounded
+lnx0131 ln 2.718281828459047 -> 1.0 Inexact Rounded
+lnx0132 ln 10 -> 2.3 Inexact Rounded
+lnx0133 ln 10.5 -> 2.4 Inexact Rounded
+lnx0134 ln 9999 -> 9.2 Inexact Rounded
+lnx0135 ln 1E6 -> 14 Inexact Rounded
+lnx0136 ln 1E+9 -> 21 Inexact Rounded
+lnx0137 ln +Infinity -> Infinity
+Precision: 1
+lnx0141 ln 0 -> -Infinity
+lnx0142 ln 1E-9 -> -2E+1 Inexact Rounded
+lnx0143 ln 0.0007 -> -7 Inexact Rounded
+lnx0144 ln 0.1 -> -2 Inexact Rounded
+lnx0145 ln 0.7 -> -0.4 Inexact Rounded
+lnx0146 ln 1 -> 0
+lnx0147 ln 1.5 -> 0.4 Inexact Rounded
+lnx0148 ln 2 -> 0.7 Inexact Rounded
+lnx0149 ln 2.718281828459045 -> 1 Inexact Rounded
+lnx0150 ln 2.718281828459046 -> 1 Inexact Rounded
+lnx0151 ln 2.718281828459047 -> 1 Inexact Rounded
+lnx0152 ln 10 -> 2 Inexact Rounded
+lnx0153 ln 10.5 -> 2 Inexact Rounded
+lnx0154 ln 9999 -> 9 Inexact Rounded
+lnx0155 ln 1E6 -> 1E+1 Inexact Rounded
+lnx0156 ln 1E+9 -> 2E+1 Inexact Rounded
+lnx0157 ln +Infinity -> Infinity
+
+-- group low-precision ln(1)s:
+precision: 1
+lnx0161 ln 1 -> 0
+precision: 2
+lnx0162 ln 1 -> 0
+precision: 3
+lnx0163 ln 1 -> 0
+precision: 4
+lnx0164 ln 1 -> 0
+precision: 5
+lnx0165 ln 1 -> 0
+precision: 6
+lnx0166 ln 1 -> 0
+precision: 7
+lnx0167 ln 1 -> 0
+precision: 8
+lnx0168 ln 1 -> 0
+
+-- edge-test ln(2) and ln(10) in case of lookasides
+precision: 45
+lnx201 ln 2 -> 0.693147180559945309417232121458176568075500134 Inexact Rounded
+lnx202 ln 10 -> 2.30258509299404568401799145468436420760110149 Inexact Rounded
+precision: 44
+lnx203 ln 2 -> 0.69314718055994530941723212145817656807550013 Inexact Rounded
+lnx204 ln 10 -> 2.3025850929940456840179914546843642076011015 Inexact Rounded
+precision: 43
+lnx205 ln 2 -> 0.6931471805599453094172321214581765680755001 Inexact Rounded
+lnx206 ln 10 -> 2.302585092994045684017991454684364207601101 Inexact Rounded
+precision: 42
+lnx207 ln 2 -> 0.693147180559945309417232121458176568075500 Inexact Rounded
+lnx208 ln 10 -> 2.30258509299404568401799145468436420760110 Inexact Rounded
+precision: 41
+lnx209 ln 2 -> 0.69314718055994530941723212145817656807550 Inexact Rounded
+lnx210 ln 10 -> 2.3025850929940456840179914546843642076011 Inexact Rounded
+precision: 40
+lnx211 ln 2 -> 0.6931471805599453094172321214581765680755 Inexact Rounded
+lnx212 ln 10 -> 2.302585092994045684017991454684364207601 Inexact Rounded
+precision: 39
+lnx213 ln 2 -> 0.693147180559945309417232121458176568076 Inexact Rounded
+lnx214 ln 10 -> 2.30258509299404568401799145468436420760 Inexact Rounded
+precision: 38
+lnx215 ln 2 -> 0.69314718055994530941723212145817656808 Inexact Rounded
+lnx216 ln 10 -> 2.3025850929940456840179914546843642076 Inexact Rounded
+precision: 37
+lnx217 ln 2 -> 0.6931471805599453094172321214581765681 Inexact Rounded
+lnx218 ln 10 -> 2.302585092994045684017991454684364208 Inexact Rounded
+precision: 36
+lnx219 ln 2 -> 0.693147180559945309417232121458176568 Inexact Rounded
+lnx220 ln 10 -> 2.30258509299404568401799145468436421 Inexact Rounded
+precision: 35
+lnx221 ln 2 -> 0.69314718055994530941723212145817657 Inexact Rounded
+lnx222 ln 10 -> 2.3025850929940456840179914546843642 Inexact Rounded
+precision: 34
+lnx223 ln 2 -> 0.6931471805599453094172321214581766 Inexact Rounded
+lnx224 ln 10 -> 2.302585092994045684017991454684364 Inexact Rounded
+precision: 33
+lnx225 ln 2 -> 0.693147180559945309417232121458177 Inexact Rounded
+lnx226 ln 10 -> 2.30258509299404568401799145468436 Inexact Rounded
+precision: 32
+lnx227 ln 2 -> 0.69314718055994530941723212145818 Inexact Rounded
+lnx228 ln 10 -> 2.3025850929940456840179914546844 Inexact Rounded
+precision: 31
+lnx229 ln 2 -> 0.6931471805599453094172321214582 Inexact Rounded
+lnx230 ln 10 -> 2.302585092994045684017991454684 Inexact Rounded
+precision: 30
+lnx231 ln 2 -> 0.693147180559945309417232121458 Inexact Rounded
+lnx232 ln 10 -> 2.30258509299404568401799145468 Inexact Rounded
+
+-- extreme input range values
+maxExponent: 384
+minExponent: -383
+Precision: 16
+
+lnx0901 ln 1e-400 -> -921.0340371976183 Inexact Rounded
+lnx0902 ln 1e+400 -> 921.0340371976183 Inexact Rounded
+lnx0903 ln 1e-999999 -> -2302582.790408953 Inexact Rounded
+lnx0904 ln 1e+999999 -> 2302582.790408953 Inexact Rounded
+lnx0905 ln 1e-1000013 -> -2302615.026600255 Inexact Rounded
+lnx0906 ln 2e-1000013 -> -2302614.333453074 Inexact Rounded
+
+lnx0910 ln 9.999999e+999999 -> 2302585.092993946 Inexact Rounded
+lnx0911 ln 9.9999999e+999999 -> 2302585.092994036 Inexact Rounded
+lnx0912 ln 9.99999999e+999999 -> 2302585.092994045 Inexact Rounded
+lnx0913 ln 9.999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0914 ln 9.999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0915 ln 9.999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+lnx0916 ln 9.999999999999999999999999e+999999 -> 2302585.092994046 Inexact Rounded
+
+-- randoms
+-- P=50, within 0-999
+Precision: 50
+maxExponent: 384
+minExponent: -383
+lnx1501 ln 0.00098800906574486388604608477869812518857023768951 -> -6.9198186844033787995945147836955586009548513043689 Inexact Rounded
+lnx1502 ln 158.15866624664623070184595045304145949900714987827 -> 5.0635987458895647454907806507503825602758392287684 Inexact Rounded
+lnx1503 ln 0.00565661412059571925040285814021799775249288309321 -> -5.1749297776760632102047540300491550931651318975237 Inexact Rounded
+lnx1504 ln 0.00000006914232532620489602008402091666547903180607 -> -16.487098770877825308138976818688771638172333034347 Inexact Rounded
+lnx1505 ln 0.00025380374621297657504661540749355251231770070723 -> -8.2789492423005003205242162741569033124260321954589 Inexact Rounded
+lnx1506 ln 83.033654063877426261108592599182418953442677554806 -> 4.4192459962647137976949249810815698465031609843669 Inexact Rounded
+lnx1507 ln 0.00000000416863228092481651627734668440663678118729 -> -19.295677845122141772791294599714950175284915666430 Inexact Rounded
+lnx1508 ln 0.00000140847873187820570181214271960511080523457669 -> -13.473000349581967189668305314384952251556809480339 Inexact Rounded
+lnx1509 ln 66.176106555181527101630351127583944689752069132522 -> 4.1923194696232505883666171116966137694013431504252 Inexact Rounded
+lnx1510 ln 0.00000000000009899043487403590900111602024562297908 -> -29.943753166877840985821508112917991506656545174163 Inexact Rounded
+lnx1511 ln 0.00000000000324618296721747097510453388683912733569 -> -26.453541281444586819009546418577507163362590139422 Inexact Rounded
+lnx1512 ln 72.646968818463546449499147579023555008392860423385 -> 4.2856116660689646882852128853423566276718230426479 Inexact Rounded
+lnx1513 ln 0.00000000000000066755483124635612574263153825990523 -> -34.942910142802769319262875080398852491588707172483 Inexact Rounded
+lnx1514 ln 61.002910447202398204114909451851111424657671911002 -> 4.1109215752843377323363182051446177066434038096529 Inexact Rounded
+lnx1515 ln 917.06917611331980999227893584010544542312239174774 -> 6.8211829068303114128752453661946446979787826282907 Inexact Rounded
+lnx1516 ln 0.00000000170823794883673083358549749078972003965194 -> -20.187803436976150477297246666771626827057191023004 Inexact Rounded
+lnx1517 ln 0.53731767845358224445809761315159249898566542910649 -> -0.62116577939968409211736413628236285160048357000961 Inexact Rounded
+lnx1518 ln 0.00000000000000008965291392882804161299758708033373 -> -36.950585970980857376081265073276303670820056916206 Inexact Rounded
+lnx1519 ln 0.00000000006990244916026429904498278982530170295668 -> -23.383920429244457578373523508427783144589480420753 Inexact Rounded
+lnx1520 ln 4.0312542977070300070506064666536478373801988540614 -> 1.3940775676592451945795752796421391871302024763305 Inexact Rounded
+lnx1521 ln 271.84991311551875601432518819562391699324632396423 -> 5.6052501239873862517916679747146539808077431873478 Inexact Rounded
+lnx1522 ln 7.4118671629373864667229445746862314443895404818689 -> 2.0030823863706344628239147639318289961917060121141 Inexact Rounded
+lnx1523 ln 0.00000000000002026311452625364905357321664186034258 -> -31.529974180054438792043856877314043794320951134754 Inexact Rounded
+lnx1524 ln 0.00000000000009563398651261756952398250624737809347 -> -29.978248130576972953141284136962670021368834792579 Inexact Rounded
+lnx1525 ln 0.00000000009556772669409858653026558223465197808991 -> -23.071185939748285541228206161472956661196956741186 Inexact Rounded
+lnx1526 ln 6.8441648298027301292342057248737326152250794026761 -> 1.9233964395801946597272589473417948024361005082908 Inexact Rounded
+lnx1527 ln 0.00000000000073059699884439979394945822035704264577 -> -27.944914388353724718836101828677771967128509603158 Inexact Rounded
+lnx1528 ln 0.00000000000000002610078280419082263138064745416787 -> -38.184566367516207885573773320135965798717120735115 Inexact Rounded
+lnx1529 ln 0.00000000000000000150259517166294243088546806083283 -> -41.039337946266676108538170837580051699618334928421 Inexact Rounded
+lnx1530 ln 0.00000000000000087919160541714580707181969708502091 -> -34.667528818827671507514319744047440696187358676848 Inexact Rounded
+lnx1531 ln 0.00000000000395726725120787763271849577708068584598 -> -26.255467416961357741818735787226671938678424748431 Inexact Rounded
+lnx1532 ln 0.00000000002014334901669366218018377213150715938355 -> -24.628146955635359035289123027319969201693737159108 Inexact Rounded
+lnx1533 ln 0.00000008097927101101093117753938766241442896030637 -> -16.329072628469715178637178365710373398203190937454 Inexact Rounded
+lnx1534 ln 0.00000000000017115834162632864392039668116243984176 -> -29.396187292434898225453626794459285157263177528034 Inexact Rounded
+lnx1535 ln 0.39168317593866334087305459933723864294857086105035 -> -0.93730199062757240485836637306785037368746737693029 Inexact Rounded
+lnx1536 ln 79.335036798971515026519630103325369729637514127617 -> 4.3736798570287828823772149735170431010616961976965 Inexact Rounded
+lnx1537 ln 0.00000000000000056004952129926137413602116591493625 -> -35.118506463181870020730685884333000241039028127213 Inexact Rounded
+lnx1538 ln 0.00000006006035907843890918832481099660639553666078 -> -16.627915795747112566532705974853114454405010472043 Inexact Rounded
+lnx1539 ln 0.00000000085242024937414906371333826574632450587590 -> -20.882941460268101080186482230657774997273494107221 Inexact Rounded
+lnx1540 ln 0.00000000000043671099499262350316173246550771951561 -> -28.459504757285639221776305968469058854558726593945 Inexact Rounded
+
+-- P=34, within 0-999
+Precision: 34
+lnx1201 ln 0.0086732880815927182997566810334394 -> -4.747507311920844752486938187973721 Inexact Rounded
+lnx1202 ln 0.0007104103693460260609792222569854 -> -7.249667769903503023005549250347695 Inexact Rounded
+lnx1203 ln 786.8398945385105190697541493392742 -> 6.668024790031836340471824147010546 Inexact Rounded
+lnx1204 ln 0.7723073620282687656895190171967399 -> -0.2583726708506850868786816238217326 Inexact Rounded
+lnx1205 ln 0.0061057951517197631287183938412200 -> -5.098516933918797347064454103742635 Inexact Rounded
+lnx1206 ln 0.6181379708184393730103917562498745 -> -0.4810435926903365087463387760350021 Inexact Rounded
+lnx1207 ln 09.13888261229039989110753389096760 -> 2.212538125507975574509563027696021 Inexact Rounded
+lnx1208 ln 802.0105417063143696497292158147174 -> 6.687121752052341737234832203350214 Inexact Rounded
+lnx1209 ln 778.7749710387773713523028497333058 -> 6.657722135126935472086625031413031 Inexact Rounded
+lnx1210 ln 0.0024457295895346502513567679390616 -> -6.013411799940245345321348290398517 Inexact Rounded
+lnx1211 ln 0.0000511296947872828310338864217860 -> -9.881145118237281798081573131711636 Inexact Rounded
+lnx1212 ln 0.0000246803508602554924938685155658 -> -10.60950314264825661825360971430218 Inexact Rounded
+lnx1213 ln 9.027898199253511668242977766616082 -> 2.200319582778899029786017830557293 Inexact Rounded
+lnx1214 ln 0.0991812396542505631850692800904188 -> -2.310806398964672258823043180400384 Inexact Rounded
+lnx1215 ln 0.0000000000070238810143028811223924 -> -25.68170519961636647174714538290075 Inexact Rounded
+lnx1216 ln 2.630101665342826494730394729313167 -> 0.9670225014664367465128243039749559 Inexact Rounded
+lnx1217 ln 0.0056878928594359587691526063254683 -> -5.169415422904037819736637399445096 Inexact Rounded
+lnx1218 ln 567.3436047121057843908106573095590 -> 6.340965124964258486463444360787970 Inexact Rounded
+lnx1219 ln 1.199291248124655996614605745649725 -> 0.1817307557425911805765087755675657 Inexact Rounded
+lnx1220 ln 25.02050448582031098696267479135557 -> 3.219695668137659139544178905459317 Inexact Rounded
+lnx1221 ln 0.0000000000009939597023558756961300 -> -27.63707972996537636504396558259058 Inexact Rounded
+lnx1222 ln 0.0000007988551670159429716506430403 -> -14.04008617542597230988198612376415 Inexact Rounded
+lnx1223 ln 4.681515800176129184873770605589795 -> 1.543621946415383338972124445445748 Inexact Rounded
+lnx1224 ln 15.95126669161103011206658749345781 -> 2.769538242479483539275986395443539 Inexact Rounded
+lnx1225 ln 0.0301626783922211213675457279076066 -> -3.501149933677283341023932281826341 Inexact Rounded
+lnx1226 ln 000.0040544064881821770528475185674 -> -5.507950967557021671647165889608324 Inexact Rounded
+lnx1227 ln 29.01617095935593792095913785100360 -> 3.367853293862745651888450004473297 Inexact Rounded
+lnx1228 ln 78.01836167344736733024804243195323 -> 4.356944205055768575987781375003992 Inexact Rounded
+lnx1229 ln 0.0000000096545319316965321158634893 -> -18.45583840160965814462095477365013 Inexact Rounded
+lnx1230 ln 97.95475237720579752770587185074428 -> 4.584505661612812742208619358214729 Inexact Rounded
+lnx1231 ln 528.0609262050423246402564228432371 -> 6.269211667589138113396583894315956 Inexact Rounded
+lnx1232 ln 0.0000002250064349732969696660452972 -> -15.30713683526963996712167701738724 Inexact Rounded
+lnx1233 ln 47.97063637767998658567199049725754 -> 3.870589081585660692195989854842372 Inexact Rounded
+lnx1234 ln 0.0005394311344541432318853513414361 -> -7.524995428393925934087126702974121 Inexact Rounded
+lnx1235 ln 0.0000000090973385649567471674972633 -> -18.51528393158931783447035004125791 Inexact Rounded
+lnx1236 ln 0.0000000000238776490227576197317977 -> -24.45807828188389561331158879207262 Inexact Rounded
+lnx1237 ln 0.0000236587000231921532145326218758 -> -10.65177964499823314952429277979034 Inexact Rounded
+lnx1238 ln 499.1277448846130709827154556125942 -> 6.212862064761427967461188083514774 Inexact Rounded
+lnx1239 ln 0.0000003960192300284787663712417647 -> -14.74180306619298548093697608293284 Inexact Rounded
+lnx1240 ln 41.08268350829477451667228892495136 -> 3.715586706887278039173584859218960 Inexact Rounded
+
+-- P=16, within 0-99
+Precision: 16
+lnx1101 ln 7.964875261033948 -> 2.075041282352241 Inexact Rounded
+lnx1102 ln 13.54527396845394 -> 2.606037701870263 Inexact Rounded
+lnx1103 ln 0.0008026554341331 -> -7.127585034321814 Inexact Rounded
+lnx1104 ln 0.0000030582233261 -> -12.69767642300625 Inexact Rounded
+lnx1105 ln 0.0004477497509672 -> -7.711276073210766 Inexact Rounded
+lnx1106 ln 7.616268622474371 -> 2.030286567675148 Inexact Rounded
+lnx1107 ln 51.58329925806381 -> 3.943197962309569 Inexact Rounded
+lnx1108 ln 0.0018197497951263 -> -6.309056262549345 Inexact Rounded
+lnx1109 ln 2.956282457072984 -> 1.083932552334575 Inexact Rounded
+lnx1110 ln 0.3843325579189906 -> -0.9562470649400558 Inexact Rounded
+lnx1111 ln 0.0074466329265663 -> -4.899993304919237 Inexact Rounded
+lnx1112 ln 0.0003372478532993 -> -7.994692428206378 Inexact Rounded
+lnx1113 ln 0.0084792263167809 -> -4.770136069569271 Inexact Rounded
+lnx1114 ln 5.926756998151102 -> 1.779477182834305 Inexact Rounded
+lnx1115 ln 9.025699152180897 -> 2.200075969604119 Inexact Rounded
+lnx1116 ln 1.910124643533526 -> 0.6471684983238183 Inexact Rounded
+lnx1117 ln 0.8158922711411020 -> -0.2034729533939387 Inexact Rounded
+lnx1118 ln 0.0067080016475322 -> -5.004454189414139 Inexact Rounded
+lnx1119 ln 0.0047583242092716 -> -5.347859729601094 Inexact Rounded
+lnx1120 ln 0.0386647411641339 -> -3.252827175263113 Inexact Rounded
+lnx1121 ln 0.0050226427841761 -> -5.293799032774131 Inexact Rounded
+lnx1122 ln 6.927937541637261 -> 1.935562155866906 Inexact Rounded
+lnx1123 ln 0.0000095745343513 -> -11.55640365579814 Inexact Rounded
+lnx1124 ln 1.602465492956538 -> 0.4715433763243936 Inexact Rounded
+lnx1125 ln 38.98415625087535 -> 3.663155313610213 Inexact Rounded
+lnx1126 ln 5.343182042276734 -> 1.675821363568112 Inexact Rounded
+lnx1127 ln 55.89763703245816 -> 4.023522107934110 Inexact Rounded
+lnx1128 ln 0.7445257810280847 -> -0.2950077988101030 Inexact Rounded
+lnx1129 ln 1.631407314946094 -> 0.4894430257201248 Inexact Rounded
+lnx1130 ln 0.0005462451932602 -> -7.512442611116852 Inexact Rounded
+lnx1131 ln 0.0000864173269362 -> -9.356322359017317 Inexact Rounded
+lnx1132 ln 5.227161719132849 -> 1.653868438439637 Inexact Rounded
+lnx1133 ln 60.57078466941998 -> 4.103812675662452 Inexact Rounded
+lnx1134 ln 0.0992864325333160 -> -2.309746348350318 Inexact Rounded
+lnx1135 ln 09.48564268447325 -> 2.249779359074983 Inexact Rounded
+lnx1136 ln 0.0036106089355634 -> -5.623878840650787 Inexact Rounded
+lnx1137 ln 1.805176865587172 -> 0.5906585734593707 Inexact Rounded
+lnx1138 ln 62.59363259642255 -> 4.136663557220559 Inexact Rounded
+lnx1139 ln 4.373828261137201 -> 1.475638657912000 Inexact Rounded
+lnx1140 ln 0.994483524148738 -> -0.005531747794938690 Inexact Rounded
+
+-- P=7, within 0-9
+Precision: 7
+lnx1001 ln 0.0912025 -> -2.394673 Inexact Rounded
+lnx1002 ln 0.9728626 -> -0.02751242 Inexact Rounded
+lnx1003 ln 0.3886032 -> -0.9451965 Inexact Rounded
+lnx1004 ln 8.798639 -> 2.174597 Inexact Rounded
+lnx1005 ln 2.459121 -> 0.8998040 Inexact Rounded
+lnx1006 ln 2.013193 -> 0.6997220 Inexact Rounded
+lnx1007 ln 9.064857 -> 2.204405 Inexact Rounded
+lnx1008 ln 5.796417 -> 1.757240 Inexact Rounded
+lnx1009 ln 0.1143471 -> -2.168517 Inexact Rounded
+lnx1010 ln 0.5341542 -> -0.6270707 Inexact Rounded
+lnx1011 ln 6.693781 -> 1.901179 Inexact Rounded
+lnx1012 ln 0.0081779 -> -4.806320 Inexact Rounded
+lnx1013 ln 8.313616 -> 2.117895 Inexact Rounded
+lnx1014 ln 3.486925 -> 1.249020 Inexact Rounded
+lnx1015 ln 0.1801401 -> -1.714020 Inexact Rounded
+lnx1016 ln 0.5227148 -> -0.6487193 Inexact Rounded
+lnx1017 ln 7.818111 -> 2.056443 Inexact Rounded
+lnx1018 ln 0.0870671 -> -2.441076 Inexact Rounded
+lnx1019 ln 8.153966 -> 2.098504 Inexact Rounded
+lnx1020 ln 2.040975 -> 0.7134276 Inexact Rounded
+lnx1021 ln 1.481642 -> 0.3931509 Inexact Rounded
+lnx1022 ln 0.2610123 -> -1.343188 Inexact Rounded
+lnx1023 ln 0.466723 -> -0.7620193 Inexact Rounded
+lnx1024 ln 0.0518756 -> -2.958907 Inexact Rounded
+lnx1025 ln 2.056410 -> 0.7209617 Inexact Rounded
+lnx1026 ln 0.181522 -> -1.706378 Inexact Rounded
+lnx1027 ln 0.515551 -> -0.6625190 Inexact Rounded
+lnx1028 ln 8.425089 -> 2.131214 Inexact Rounded
+lnx1029 ln 2.077091 -> 0.7309684 Inexact Rounded
+lnx1030 ln 6.212705 -> 1.826596 Inexact Rounded
+lnx1031 ln 5.729343 -> 1.745601 Inexact Rounded
+lnx1032 ln 4.831251 -> 1.575105 Inexact Rounded
+lnx1033 ln 2.029760 -> 0.7079176 Inexact Rounded
+lnx1034 ln 8.615060 -> 2.153512 Inexact Rounded
+lnx1035 ln 0.0611511 -> -2.794407 Inexact Rounded
+lnx1036 ln 5.195269 -> 1.647748 Inexact Rounded
+lnx1037 ln 9.617686 -> 2.263604 Inexact Rounded
+lnx1038 ln 0.0049382 -> -5.310754 Inexact Rounded
+lnx1039 ln 2.786840 -> 1.024908 Inexact Rounded
+lnx1040 ln 0.0091073 -> -4.698679 Inexact Rounded
+
+-- from here 3-digit tests are based on reverse exp tests
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+lnx001 ln 0 -> -Infinity
+lnx002 ln 0.367879441 -> -1.00000000 Inexact Rounded
+lnx003 ln 1 -> 0
+lnx005 ln 2.71828183 -> 1.00000000 Inexact Rounded
+lnx006 ln 2.00000000 -> 0.693147181 Inexact Rounded
+lnx007 ln +Infinity -> Infinity
+
+-- tiny edge cases
+precision: 7
+lnx011 ln 1.105171 -> 0.1000001 Inexact Rounded
+lnx012 ln 1.010050 -> 0.009999835 Inexact Rounded
+lnx013 ln 1.000010 -> 0.000009999950 Inexact Rounded
+lnx014 ln 1.000001 -> 9.999995E-7 Inexact Rounded
+lnx015 ln 1.000000 -> 0
+
+-- basic e=0, e=1, e=2, e=4, e>=8 cases
+precision: 7
+lnx041 ln 2.718282 -> 1.000000 Inexact Rounded
+lnx042 ln 0.3678794 -> -1.000000 Inexact Rounded
+lnx043 ln 22026.47 -> 10.00000 Inexact Rounded
+lnx044 ln 0.00004539993 -> -10.00000 Inexact Rounded
+lnx045 ln 2.688117E+43 -> 100.0000 Inexact Rounded
+lnx046 ln 3.720076E-44 -> -100.0000 Inexact Rounded
+lnx047 ln Infinity -> Infinity
+lnx048 ln 0E-389 -> -Infinity
+
+-- miscellanea
+precision: 16
+lnx055 ln 2.717658486884572E-236 -> -542.4103112874415 Inexact Rounded
+precision: 17
+lnx056 ln 2.7176584868845721E-236 -> -542.41031128744146 Inexact Rounded
+precision: 18
+lnx057 ln 2.71765848688457211E-236 -> -542.410311287441459 Inexact Rounded
+precision: 19
+lnx058 ln 2.717658486884572112E-236 -> -542.4103112874414592 Inexact Rounded
+precision: 20
+lnx059 ln 2.7176584868845721118E-236 -> -542.41031128744145917 Inexact Rounded
+
+-- inputs ending in ..500.., ..499.., ..100.., ..999.. sequences
+precision: 50
+lnx102 ln 0.9999999100000040499998785000027 -> -9.0000000000000000000000033749953829996446124861750E-8 Inexact Rounded
+precision: 30
+lnx103 ln 0.999999910000004049999878500003 -> -8.99999999999999999999997337499E-8 Inexact Rounded
+precision: 29
+lnx104 ln 0.99999991000000404999987850000 -> -9.0000000000000000000002733750E-8 Inexact Rounded
+precision: 28
+lnx105 ln 0.9999999100000040499998785000 -> -9.000000000000000000000273375E-8 Inexact Rounded
+precision: 27
+lnx106 ln 0.999999910000004049999878500 -> -9.00000000000000000000027338E-8 Inexact Rounded
+precision: 26
+lnx107 ln 0.99999991000000404999987850 -> -9.0000000000000000000002734E-8 Inexact Rounded
+precision: 25
+lnx108 ln 0.9999999100000040499998785 -> -9.000000000000000000000273E-8 Inexact Rounded
+precision: 24
+lnx109 ln 0.999999910000004049999879 -> -8.99999999999999995000027E-8 Inexact Rounded
+precision: 23
+lnx110 ln 0.99999991000000404999988 -> -8.9999999999999998500003E-8 Inexact Rounded
+precision: 22
+lnx111 ln 0.9999999100000040499999 -> -8.999999999999997850000E-8 Inexact Rounded
+precision: 21
+lnx112 ln 0.999999910000004050000 -> -8.99999999999998785000E-8 Inexact Rounded
+precision: 20
+lnx113 ln 0.99999991000000405000 -> -8.9999999999999878500E-8 Inexact Rounded
+precision: 19
+lnx114 ln 0.9999999100000040500 -> -8.999999999999987850E-8 Inexact Rounded
+precision: 18
+lnx115 ln 0.999999910000004050 -> -8.99999999999998785E-8 Inexact Rounded
+-- next may be a > 0.5ulp case; a more precise answer is:
+-- -8.99999999999998784999918E-8
+precision: 17
+lnx116 ln 0.99999991000000405 -> -8.9999999999999878E-8 Inexact Rounded
+precision: 16
+lnx117 ln 0.9999999100000040 -> -9.000000004999988E-8 Inexact Rounded
+precision: 15
+lnx118 ln 0.999999910000004 -> -9.00000000499999E-8 Inexact Rounded
+precision: 14
+lnx119 ln 0.99999991000000 -> -9.0000004050000E-8 Inexact Rounded
+precision: 13
+lnx120 ln 0.9999999100000 -> -9.000000405000E-8 Inexact Rounded
+precision: 12
+lnx121 ln 0.999999910000 -> -9.00000040500E-8 Inexact Rounded
+precision: 11
+lnx122 ln 0.99999991000 -> -9.0000004050E-8 Inexact Rounded
+precision: 10
+lnx123 ln 0.9999999100 -> -9.000000405E-8 Inexact Rounded
+precision: 9
+lnx124 ln 0.999999910 -> -9.00000041E-8 Inexact Rounded
+precision: 8
+lnx125 ln 0.99999991 -> -9.0000004E-8 Inexact Rounded
+precision: 7
+lnx126 ln 0.9999999 -> -1.000000E-7 Inexact Rounded
+precision: 16
+lnx126b ln 0.9999999 -> -1.000000050000003E-7 Inexact Rounded
+precision: 6
+lnx127 ln 0.999999 -> -0.00000100000 Inexact Rounded
+precision: 5
+lnx128 ln 0.99999 -> -0.000010000 Inexact Rounded
+precision: 4
+lnx129 ln 0.9999 -> -0.0001000 Inexact Rounded
+precision: 3
+lnx130 ln 0.999 -> -0.00100 Inexact Rounded
+precision: 2
+lnx131 ln 0.99 -> -0.010 Inexact Rounded
+precision: 1
+lnx132 ln 0.9 -> -0.1 Inexact Rounded
+
+
+-- cases near 1 -- 1 2345678901234567890
+precision: 20
+lnx401 ln 2.7182818284589365041 -> 0.99999999999996000000 Inexact Rounded
+lnx402 ln 2.7182818284589636869 -> 0.99999999999997000000 Inexact Rounded
+lnx403 ln 2.7182818284589908697 -> 0.99999999999997999999 Inexact Rounded
+lnx404 ln 2.7182818284590180525 -> 0.99999999999998999998 Inexact Rounded
+lnx405 ln 2.7182818284590452354 -> 1.0000000000000000000 Inexact Rounded
+lnx406 ln 2.7182818284593170635 -> 1.0000000000001000000 Inexact Rounded
+lnx407 ln 2.7182818284595888917 -> 1.0000000000002000000 Inexact Rounded
+precision: 14
+lnx411 ln 2.7182818284589 -> 0.99999999999995 Inexact Rounded
+lnx413 ln 2.7182818284590 -> 0.99999999999998 Inexact Rounded
+lnx416 ln 2.7182818284591 -> 1.0000000000000 Inexact Rounded
+lnx417 ln 2.7182818284592 -> 1.0000000000001 Inexact Rounded
+
+-- overflows, including some exp overprecise borderlines
+precision: 7
+maxExponent: 384
+minExponent: -383
+lnx709 ln 9.999999E+384 -> 886.4953 Inexact Rounded
+lnx711 ln 9.999992E+384 -> 886.4953 Inexact Rounded
+precision: 16
+lnx722 ln 9.999999999999999E+384 -> 886.4952608027076 Inexact Rounded
+lnx724 ln 9.999999999999917E+384 -> 886.4952608027076 Inexact Rounded
+lnx726 ln 9.999999999999117E+384 -> 886.4952608027075 Inexact Rounded
+-- and more...
+precision: 15
+maxExponent: 999
+minExponent: -999
+lnx731 ln 9.99999999999999E+999 -> 2302.58509299405 Inexact Rounded
+-- next may be a > 0.5ulp case; a more precise answer is:
+-- 2302.58509299404495001799145442
+lnx732 ln 9.99999999999266E+999 -> 2302.58509299404 Inexact Rounded
+lnx733 ln 9.99999999999265E+999 -> 2302.58509299404 Inexact Rounded
+lnx734 ln 9.99999999999264E+999 -> 2302.58509299404 Inexact Rounded
+
+-- subnormals and underflows for exp, including underflow-to-zero edge point
+precision: 7
+maxExponent: 384
+minExponent: -383
+lnx751 ln 0E-389 -> -Infinity
+lnx758 ln 1.000001E-383 -> -881.8901 Inexact Rounded
+lnx759 ln 9.99991E-384 -> -881.8901 Inexact Rounded
+lnx760 ln 4.4605E-385 -> -885.0000 Inexact Rounded
+lnx761 ln 2.221E-386 -> -887.9999 Inexact Rounded
+lnx762 ln 3.01E-387 -> -889.9985 Inexact Rounded
+lnx763 ln 1.7E-388 -> -892.8724 Inexact Rounded
+lnx764 ln 1.5E-388 -> -892.9976 Inexact Rounded
+lnx765 ln 9E-389 -> -893.5084 Inexact Rounded
+lnx766 ln 1E-389 -> -895.7056 Inexact Rounded
+lnx774 ln 0E-389 -> -Infinity
+
+-- special values
+lnx820 ln Infinity -> Infinity
+lnx821 ln 0 -> -Infinity
+lnx822 ln NaN -> NaN
+lnx823 ln sNaN -> NaN Invalid_operation
+-- propagating NaNs
+lnx824 ln sNaN123 -> NaN123 Invalid_operation
+lnx825 ln -sNaN321 -> -NaN321 Invalid_operation
+lnx826 ln NaN456 -> NaN456
+lnx827 ln -NaN654 -> -NaN654
+lnx828 ln NaN1 -> NaN1
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+lnx901 ln 1 -> NaN Invalid_context
+precision: 99999999
+lnx902 ln 0 -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+lnx903 ln 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+lnx904 ln 0 -> -Infinity
+maxExponent: 999999
+minExponent: -1000000
+lnx905 ln 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+lnx906 ln 0 -> -Infinity
+
+-- payload decapitate
+precision: 5
+lnx910 ln -sNaN1234567890 -> -NaN67890 Invalid_operation
+
+-- Null test
+lnx900 ln # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/log10.decTest b/Lib/test/decimaltestdata/log10.decTest
index 6502f0d0914..5169eabde35 100644
--- a/Lib/test/decimaltestdata/log10.decTest
+++ b/Lib/test/decimaltestdata/log10.decTest
@@ -1,551 +1,551 @@
-------------------------------------------------------------------------
--- log10.decTest -- decimal logarithm in base 10 --
--- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This emphasises the testing of notable cases, as they will often
--- have unusual paths (especially the 10**n results).
-
-extended: 1
-precision: 16
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- examples in specification
-precision: 9
-logxs000 log10 0 -> -Infinity
-logxs001 log10 0.001 -> -3
-logxs002 log10 1 -> 0
-logxs003 log10 2 -> 0.301029996 Inexact Rounded
-logxs004 log10 10 -> 1
-logxs005 log10 70 -> 1.84509804 Inexact Rounded
-logxs006 log10 +Infinity -> Infinity
-
-
--- basics (examples in specification, etc.)
-precision: 16
-logx0000 log10 0 -> -Infinity
-logx0001 log10 7E-1000 -> -999.1549019599857 Inexact Rounded
-logx0002 log10 1.1E-9 -> -8.958607314841775 Inexact Rounded
-logx0003 log10 0.0007 -> -3.154901959985743 Inexact Rounded
-logx0004 log10 0.11 -> -0.9586073148417750 Inexact Rounded
-logx0005 log10 0.7 -> -0.1549019599857432 Inexact Rounded
-logx0006 log10 1 -> 0
-logx0007 log10 1.5 -> 0.1760912590556812 Inexact Rounded
-logx0008 log10 2 -> 0.3010299956639812 Inexact Rounded
-logx0009 log10 2.718281828459045 -> 0.4342944819032518 Inexact Rounded
-logx0010 log10 2.718281828459046 -> 0.4342944819032519 Inexact Rounded
-logx0011 log10 2.718281828459047 -> 0.4342944819032521 Inexact Rounded
-logx0012 log10 7 -> 0.8450980400142568 Inexact Rounded
-logx0013 log10 10 -> 1
-logx0014 log10 10.5 -> 1.021189299069938 Inexact Rounded
-logx0015 log10 11 -> 1.041392685158225 Inexact Rounded
-logx0016 log10 70 -> 1.845098040014257 Inexact Rounded
-logx0017 log10 9999 -> 3.999956568380192 Inexact Rounded
-logx0018 log10 1.21E6 -> 6.082785370316450 Inexact Rounded
-logx0019 log10 1.1E+9 -> 9.041392685158225 Inexact Rounded
-logx0020 log10 7E+1000 -> 1000.845098040014 Inexact Rounded
-logx0021 log10 +Infinity -> Infinity
-
--- notable cases
--- negatives
-logx0031 log10 -1E-9 -> NaN Invalid_operation
-logx0032 log10 -0.0007 -> NaN Invalid_operation
-logx0033 log10 -0.1 -> NaN Invalid_operation
-logx0034 log10 -0.7 -> NaN Invalid_operation
-logx0035 log10 -1 -> NaN Invalid_operation
-logx0036 log10 -1.5 -> NaN Invalid_operation
-logx0037 log10 -2 -> NaN Invalid_operation
-logx0038 log10 -10.5 -> NaN Invalid_operation
-logx0039 log10 -10.5 -> NaN Invalid_operation
-logx0040 log10 -9999 -> NaN Invalid_operation
-logx0041 log10 -10 -> NaN Invalid_operation
-logx0042 log10 -0 -> -Infinity
-logx0043 log10 -0E+17 -> -Infinity
-logx0044 log10 -0E-17 -> -Infinity
--- other zeros
-logx0051 log10 0 -> -Infinity
-logx0052 log10 0E+17 -> -Infinity
-logx0053 log10 0E-17 -> -Infinity
--- infinities
-logx0055 log10 -Infinity -> NaN Invalid_operation
-logx0056 log10 +Infinity -> Infinity
--- ones
-logx0061 log10 1 -> 0
-logx0062 log10 1.0 -> 0
-logx0063 log10 1.000000000000000 -> 0
-logx0064 log10 1.000000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-logx1100 log10 1 -> 0
-logx1101 log10 10 -> 1
-logx1102 log10 100 -> 2
-logx1103 log10 1000 -> 3
-logx1104 log10 10000 -> 4
-logx1105 log10 100000 -> 5
-logx1106 log10 1000000 -> 6
-logx1107 log10 10000000 -> 7
-logx1108 log10 100000000 -> 8
-logx1109 log10 1000000000 -> 9
-logx1110 log10 10000000000 -> 10
-logx1111 log10 100000000000 -> 11
-logx1112 log10 1000000000000 -> 12
-logx1113 log10 0.00000000001 -> -11
-logx1114 log10 0.0000000001 -> -10
-logx1115 log10 0.000000001 -> -9
-logx1116 log10 0.00000001 -> -8
-logx1117 log10 0.0000001 -> -7
-logx1118 log10 0.000001 -> -6
-logx1119 log10 0.00001 -> -5
-logx1120 log10 0.0001 -> -4
-logx1121 log10 0.001 -> -3
-logx1122 log10 0.01 -> -2
-logx1123 log10 0.1 -> -1
-logx1124 log10 1E-99 -> -99
-logx1125 log10 1E-100 -> -100
-logx1126 log10 1E-383 -> -383
-
--- check normally exact cases round properly
-precision: 1
-logx1141 log10 10000000000 -> 1E+1 Rounded
-logx1142 log10 1000000000000 -> 1E+1 Inexact Rounded
-logx1143 log10 1E+100 -> 1E+2 Rounded
-logx1144 log10 1E+123 -> 1E+2 Inexact Rounded
-logx1145 log10 1E+126 -> 1E+2 Inexact Rounded
-logx1146 log10 1E+916 -> 9E+2 Inexact Rounded
-logx1147 log10 1E+999 -> 1E+3 Inexact Rounded
-
-precision: 2
-logx1151 log10 10000000000 -> 10
-logx1152 log10 1000000000000 -> 12
-logx1153 log10 1E+100 -> 1.0E+2 Rounded
-logx1154 log10 1E+123 -> 1.2E+2 Inexact Rounded
-logx1155 log10 1E+126 -> 1.3E+2 Inexact Rounded
-logx1156 log10 1E+916 -> 9.2E+2 Inexact Rounded
-logx1157 log10 1E+999 -> 1.0E+3 Inexact Rounded
--- some half-way point rounds, other cases, and negatives
-logx1158 log10 1E+125 -> 1.2E+2 Inexact Rounded
-logx1159 log10 1E+135 -> 1.4E+2 Inexact Rounded
-logx1160 log10 1E+129 -> 1.3E+2 Inexact Rounded
-logx1161 log10 1E+131 -> 1.3E+2 Inexact Rounded
-logx1162 log10 1E-123 -> -1.2E+2 Inexact Rounded
-logx1163 log10 1E-126 -> -1.3E+2 Inexact Rounded
-logx1164 log10 1E-916 -> -9.2E+2 Inexact Rounded
-logx1165 log10 1E-999 -> -1.0E+3 Inexact Rounded
-logx1166 log10 1E-125 -> -1.2E+2 Inexact Rounded
-logx1167 log10 1E-135 -> -1.4E+2 Inexact Rounded
-logx1168 log10 1E-129 -> -1.3E+2 Inexact Rounded
-logx1169 log10 1E-131 -> -1.3E+2 Inexact Rounded
-
-precision: 3
-logx1171 log10 10000000000 -> 10
-logx1172 log10 1000000000000 -> 12
-logx1173 log10 1E+100 -> 100
-logx1174 log10 1E+123 -> 123
-logx1175 log10 1E+126 -> 126
-logx1176 log10 1E+916 -> 916
-logx1177 log10 1E+999 -> 999
-
--- log10(2) .. tests both ln(2) and ln(10) constants, too
-precision: 50
-logx1201 log10 2 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-logx1202 log10 2.000 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-logx1203 log10 0.2E1 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
-precision: 49
-logx1204 log10 2 -> 0.3010299956639811952137388947244930267681898814621 Inexact Rounded
-precision: 48
-logx1205 log10 2 -> 0.301029995663981195213738894724493026768189881462 Inexact Rounded
-precision: 47
-logx1206 log10 2 -> 0.30102999566398119521373889472449302676818988146 Inexact Rounded
-precision: 46
-logx1207 log10 2 -> 0.3010299956639811952137388947244930267681898815 Inexact Rounded
-precision: 45
-logx1208 log10 2 -> 0.301029995663981195213738894724493026768189881 Inexact Rounded
-precision: 44
-logx1209 log10 2 -> 0.30102999566398119521373889472449302676818988 Inexact Rounded
-precision: 43
-logx1210 log10 2 -> 0.3010299956639811952137388947244930267681899 Inexact Rounded
-precision: 42
-logx1211 log10 2 -> 0.301029995663981195213738894724493026768190 Inexact Rounded
-precision: 41
-logx1212 log10 2 -> 0.30102999566398119521373889472449302676819 Inexact Rounded
-precision: 40
-logx1213 log10 2 -> 0.3010299956639811952137388947244930267682 Inexact Rounded
-precision: 39
-logx1214 log10 2 -> 0.301029995663981195213738894724493026768 Inexact Rounded
-precision: 38
-logx1215 log10 2 -> 0.30102999566398119521373889472449302677 Inexact Rounded
-precision: 37
-logx1216 log10 2 -> 0.3010299956639811952137388947244930268 Inexact Rounded
-precision: 36
-logx1217 log10 2 -> 0.301029995663981195213738894724493027 Inexact Rounded
-precision: 35
-logx1218 log10 2 -> 0.30102999566398119521373889472449303 Inexact Rounded
-precision: 34
-logx1219 log10 2 -> 0.3010299956639811952137388947244930 Inexact Rounded
-precision: 33
-logx1220 log10 2 -> 0.301029995663981195213738894724493 Inexact Rounded
-precision: 32
-logx1221 log10 2 -> 0.30102999566398119521373889472449 Inexact Rounded
-precision: 31
-logx1222 log10 2 -> 0.3010299956639811952137388947245 Inexact Rounded
-precision: 30
-logx1223 log10 2 -> 0.301029995663981195213738894724 Inexact Rounded
-precision: 29
-logx1224 log10 2 -> 0.30102999566398119521373889472 Inexact Rounded
-precision: 28
-logx1225 log10 2 -> 0.3010299956639811952137388947 Inexact Rounded
-precision: 27
-logx1226 log10 2 -> 0.301029995663981195213738895 Inexact Rounded
-precision: 26
-logx1227 log10 2 -> 0.30102999566398119521373889 Inexact Rounded
-precision: 25
-logx1228 log10 2 -> 0.3010299956639811952137389 Inexact Rounded
-precision: 24
-logx1229 log10 2 -> 0.301029995663981195213739 Inexact Rounded
-precision: 23
-logx1230 log10 2 -> 0.30102999566398119521374 Inexact Rounded
-precision: 22
-logx1231 log10 2 -> 0.3010299956639811952137 Inexact Rounded
-precision: 21
-logx1232 log10 2 -> 0.301029995663981195214 Inexact Rounded
-precision: 20
-logx1233 log10 2 -> 0.30102999566398119521 Inexact Rounded
-precision: 19
-logx1234 log10 2 -> 0.3010299956639811952 Inexact Rounded
-precision: 18
-logx1235 log10 2 -> 0.301029995663981195 Inexact Rounded
-precision: 17
-logx1236 log10 2 -> 0.30102999566398120 Inexact Rounded
-precision: 16
-logx1237 log10 2 -> 0.3010299956639812 Inexact Rounded
-precision: 15
-logx1238 log10 2 -> 0.301029995663981 Inexact Rounded
-precision: 14
-logx1239 log10 2 -> 0.30102999566398 Inexact Rounded
-precision: 13
-logx1240 log10 2 -> 0.3010299956640 Inexact Rounded
-precision: 12
-logx1241 log10 2 -> 0.301029995664 Inexact Rounded
-precision: 11
-logx1242 log10 2 -> 0.30102999566 Inexact Rounded
-precision: 10
-logx1243 log10 2 -> 0.3010299957 Inexact Rounded
-precision: 9
-logx1244 log10 2 -> 0.301029996 Inexact Rounded
-precision: 8
-logx1245 log10 2 -> 0.30103000 Inexact Rounded
-precision: 7
-logx1246 log10 2 -> 0.3010300 Inexact Rounded
-precision: 6
-logx1247 log10 2 -> 0.301030 Inexact Rounded
-precision: 5
-logx1248 log10 2 -> 0.30103 Inexact Rounded
-precision: 4
-logx1249 log10 2 -> 0.3010 Inexact Rounded
-precision: 3
-logx1250 log10 2 -> 0.301 Inexact Rounded
-precision: 2
-logx1251 log10 2 -> 0.30 Inexact Rounded
-precision: 1
-logx1252 log10 2 -> 0.3 Inexact Rounded
-
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- More close-to-e, etc., tests
-precision: 34
-logx1301 log10 2.718281828459045235360287471352661 -> 0.4342944819032518276511289189166048 Inexact Rounded
-logx1302 log10 2.718281828459045235360287471352662 -> 0.4342944819032518276511289189166050 Inexact Rounded
-logx1303 log10 2.718281828459045235360287471352663 -> 0.4342944819032518276511289189166052 Inexact Rounded
-logx1304 log10 0.99999999999999999999999999999999 -> -4.342944819032518276511289189166073E-33 Inexact Rounded
-logx1305 log10 0.999999999999999999999999999999999 -> -4.342944819032518276511289189166053E-34 Inexact Rounded
-logx1306 log10 0.9999999999999999999999999999999999 -> -4.342944819032518276511289189166051E-35 Inexact Rounded
-logx1307 log10 1.000000000000000000000000000000000 -> 0
-logx1308 log10 1.0000000000000000000000000000000001 -> 4.342944819032518276511289189166051E-35 Inexact Rounded
-logx1309 log10 1.000000000000000000000000000000001 -> 4.342944819032518276511289189166049E-34 Inexact Rounded
-logx1310 log10 1.00000000000000000000000000000001 -> 4.342944819032518276511289189166029E-33 Inexact Rounded
--- lower p
-precision: 7
-logx1320 log10 0.999999 -> -4.342947E-7 Inexact Rounded
-logx1321 log10 0.9999999 -> -4.342945E-8 Inexact Rounded
-logx1322 log10 0.99999999 -> -4.342945E-9 Inexact Rounded
-logx1323 log10 0.999999999 -> -4.342945E-10 Inexact Rounded
-logx1324 log10 1.00000000 -> 0
-logx1325 log10 1.00000001 -> 4.342945E-9 Inexact Rounded
-logx1326 log10 1.0000001 -> 4.342945E-8 Inexact Rounded
-logx1327 log10 1.000001 -> 4.342943E-7 Inexact Rounded
-
--- near 10^3
-precision: 9
-logx1331 log10 999.9999998 -> 3.00000000 Inexact Rounded
-logx1332 log10 999.9999999 -> 3.00000000 Inexact Rounded
-logx1333 log10 1000.000000 -> 3
-logx1334 log10 1000.000001 -> 3.00000000 Inexact Rounded
-logx1335 log10 1000.000002 -> 3.00000000 Inexact Rounded
-precision: 16
-logx1341 log10 999.9999998 -> 2.999999999913141 Inexact Rounded
-logx1342 log10 999.9999999 -> 2.999999999956571 Inexact Rounded
-logx1343 log10 1000.000000 -> 3
-logx1344 log10 1000.000001 -> 3.000000000434294 Inexact Rounded
-logx1345 log10 1000.000002 -> 3.000000000868589 Inexact Rounded
-
--- suggestions from Ilan Nehama
-logx1400 log10 10E-3 -> -2
-logx1401 log10 10E-2 -> -1
-logx1402 log10 100E-2 -> 0
-logx1403 log10 1000E-2 -> 1
-logx1404 log10 10000E-2 -> 2
-logx1405 log10 10E-1 -> 0
-logx1406 log10 100E-1 -> 1
-logx1407 log10 1000E-1 -> 2
-logx1408 log10 10000E-1 -> 3
-logx1409 log10 10E0 -> 1
-logx1410 log10 100E0 -> 2
-logx1411 log10 1000E0 -> 3
-logx1412 log10 10000E0 -> 4
-logx1413 log10 10E1 -> 2
-logx1414 log10 100E1 -> 3
-logx1415 log10 1000E1 -> 4
-logx1416 log10 10000E1 -> 5
-logx1417 log10 10E2 -> 3
-logx1418 log10 100E2 -> 4
-logx1419 log10 1000E2 -> 5
-logx1420 log10 10000E2 -> 6
-
--- Randoms
--- P=50, within 0-9999
-Precision: 50
-logx2501 log10 0.00035448001667968141775891246991912655961163345904 -> -3.4504082425411775290864053318247274944685586188505 Inexact Rounded
-logx2502 log10 70.636455726424311228255338637935330826995136597644 -> 1.8490288998408492045793070255302335558140975719247 Inexact Rounded
-logx2503 log10 0.00000000000000233550362473821889060812804063040169 -> -14.631619454343834858023578299142866557717904223667 Inexact Rounded
-logx2504 log10 97.783628621523244679901260358286898958832135433764 -> 1.9902661493224219517897657964362571690592734407330 Inexact Rounded
-logx2505 log10 0062.2377135315858392802612812022807838599572017342 -> 1.7940536293085066199287632725026837018486533544141 Inexact Rounded
-logx2506 log10 6.3767634652071053619977602804724129652981747879532 -> 0.80460030789825961615100163576080761326857374098644 Inexact Rounded
-logx2507 log10 63.297088981313278529306533814195068850532666658798 -> 1.8013837373724427092417170149098614410849353839673 Inexact Rounded
-logx2508 log10 0.00000077239693316881797717820110898167721602299187 -> -6.1121594592718550613773886241951966264826760310047 Inexact Rounded
-logx2509 log10 0.00000003953580359780185534830572461922527831395002 -> -7.4030094293833847136252547069905477213541787177561 Inexact Rounded
-logx2510 log10 754.62905817369989169188998111527272688791544577204 -> 2.8777335243761300047758534304371912099958057545416 Inexact Rounded
-logx2511 log10 0.00000048360378410241428936607147056283282849158312 -> -6.3155103095309353457604038397980091650760346334512 Inexact Rounded
-logx2512 log10 0.00007509037583645612577196104591672080542932166089 -> -4.1244157219700166314012344705538088030592896111026 Inexact Rounded
-logx2513 log10 0.00000000000705475944638915053419839063567898092064 -> -11.151517790256466048553810002525868198178167950377 Inexact Rounded
-logx2514 log10 9.6210300460497657917445410947099633479609165120661 -> 0.98322157093260978206633922877716078683518617768411 Inexact Rounded
-logx2515 log10 0.00000000050150361386555527496607245976120864985611 -> -9.2997259330798261040411086835563234390934934629340 Inexact Rounded
-logx2516 log10 098.24754029731994125797723545333677604490074810751 -> 1.9923216862874337077795278629351060819105679670633 Inexact Rounded
-logx2517 log10 7.5091998150046994320441463854301624742491015752980 -> 0.87559366078005924080766469158763499725414024128781 Inexact Rounded
-logx2518 log10 0.00000000000079540571273330075193668596942268542425 -> -12.099411294165176028817305108475326325006250936963 Inexact Rounded
-logx2519 log10 0.00000042395034799555215782907515074134154915491701 -> -6.3726850039125381134069450802108893075604464135297 Inexact Rounded
-logx2520 log10 56.683376304674355481905023145238799909301732694982 -> 1.7534557107853480435703421826077606250636580091754 Inexact Rounded
-logx2521 log10 48.734033811444195070807606721517169810438049581227 -> 1.6878323602741065190942654710049433808208291564049 Inexact Rounded
-logx2522 log10 0.00074830310930046865009851706989430228561880221063 -> -3.1259224502209974082223667712016445572431791920618 Inexact Rounded
-logx2523 log10 36.677348885111593384020836720396262497122708598359 -> 1.5643979364260796086754530282302605477567469395425 Inexact Rounded
-logx2524 log10 0.00000000000000004495678560480432858812419145833744 -> -16.347204748239740510014320630363244015916029619561 Inexact Rounded
-logx2525 log10 9509.5854013650642799374159131940108748594774307104 -> 3.9781615829916326741100166519726824430945406302661 Inexact Rounded
-logx2526 log10 0.07834891268689177014044454793608715276615743819097 -> -1.1059670262197643147805517398621288897669876996348 Inexact Rounded
-logx2527 log10 0.00000029584529880706128444454688454999032801904794 -> -6.5289353275814043710076526920566721570375026917206 Inexact Rounded
-logx2528 log10 3.0713496544497618098794332787772186176981011904294 -> 0.48732926103896828546424341029492468100431414072994 Inexact Rounded
-logx2529 log10 352.66392670788816474407442785460803833927136413943 -> 2.5473610388199562714709836398243933320284077008314 Inexact Rounded
-logx2530 log10 0.00304743125181876267210516527361742185617091801650 -> -2.5160660830163981967774124745311497447050056400207 Inexact Rounded
-logx2531 log10 0.00000076120535894952136499250364604538117729437183 -> -6.1184981629047051532448413863950776496652483019415 Inexact Rounded
-logx2532 log10 769.88795978534353052965286195053735007473187735815 -> 2.8864275277862652709986498581064117950288798222100 Inexact Rounded
-logx2533 log10 0.00000000000000041297494808612226304619570016336188 -> -15.384076292745415917510668454361868659468669804710 Inexact Rounded
-logx2534 log10 860.88864595714426940247940960258558876903741966974 -> 2.9349469800554277915920278090647283233440859155176 Inexact Rounded
-logx2535 log10 5839.0328812994787235900178587371051096898683972444 -> 3.7663409208972392569269125539438874737147906238543 Inexact Rounded
-logx2536 log10 0.00000028532710151284840471670497112821201598377841 -> -6.5446569753514027675878879843238065488490618159490 Inexact Rounded
-logx2537 log10 0.00000000000000009734490059931638483445631835651581 -> -16.011686794011271135978633880864278692254243106931 Inexact Rounded
-logx2538 log10 5.8610949526439529489252302463450302981511714144330 -> 0.76797875722452549281028552067645732490929361952278 Inexact Rounded
-logx2539 log10 6.6282432221115923372151148990137179611977576327206 -> 0.82139843639227213211012044000785757267155736071361 Inexact Rounded
-logx2540 log10 0.00000000001994071862386846626954819923923344413454 -> -10.700259194632339980266559224447212260115021637626 Inexact Rounded
-
--- P=34, within 0-9999
-Precision: 34
-logx2201 log10 1.522513203889714179088327328864183 -> 0.1825610677098896250496651330492109 Inexact Rounded
-logx2202 log10 0.171123774769717316154080888930404 -> -0.7666896483548462582461898092764408 Inexact Rounded
-logx2203 log10 0.0000000997467236251714283104963838 -> -7.001101360652518274271569010312115 Inexact Rounded
-logx2204 log10 0.0008856103624122479769647543468633 -> -3.052757310476070891830490327138190 Inexact Rounded
-logx2205 log10 1.938274868738032930709498221236758 -> 0.2874153648259449520201536171714594 Inexact Rounded
-logx2206 log10 479.5667847823826713082613445010097 -> 2.680849095850361068709165157286435 Inexact Rounded
-logx2207 log10 8856.136599178820202141823157336804 -> 3.947244306584767101480454261950559 Inexact Rounded
-logx2208 log10 0.0000911026318801903982642871344858 -> -4.040469076434979398438617464033826 Inexact Rounded
-logx2209 log10 0.0000000000017271112650427414732630 -> -11.76267968314038748995178212654921 Inexact Rounded
-logx2210 log10 6.962605370078885647639503548229695 -> 0.8427717807200322352686396925992250 Inexact Rounded
-logx2211 log10 0.3354804428992793132855923541692781 -> -0.4743327923012159170967636070844834 Inexact Rounded
-logx2212 log10 2.079864257474859008252165836663504 -> 0.3180349916198059046812506741388856 Inexact Rounded
-logx2213 log10 2805.479529292939499220276986621988 -> 3.448007104139974344565978780624744 Inexact Rounded
-logx2214 log10 66.45731133034187374557028537213949 -> 1.822542767005644041661520936223086 Inexact Rounded
-logx2215 log10 0.0000001206521261762681738274822835 -> -6.918465020390216969561494755767318 Inexact Rounded
-logx2216 log10 0.0000000001884891916264401160472381 -> -9.724713548119065386091933007528633 Inexact Rounded
-logx2217 log10 0.0000015467279551726326581314582759 -> -5.810586065070435383755759514608738 Inexact Rounded
-logx2218 log10 0.0090776316728068586744633914135952 -> -2.042027442843745884503280954390114 Inexact Rounded
-logx2219 log10 0.0000000000024541106528713393740030 -> -11.61010585935635713090119156069479 Inexact Rounded
-logx2220 log10 14.12936879385863410081087750645856 -> 1.150122760895466989841057385742662 Inexact Rounded
-logx2221 log10 0.0000036912481831392922922647231392 -> -5.432826753789892283556211380824203 Inexact Rounded
-logx2222 log10 0.0000000004067477525420424270138734 -> -9.390674838050073122857868012475060 Inexact Rounded
-logx2223 log10 7080.122562705399744969319589806194 -> 3.850040775747103318724330047546916 Inexact Rounded
-logx2224 log10 261.3491411363679209175524790255725 -> 2.417221077227536319655699517530855 Inexact Rounded
-logx2225 log10 003.9945581449915240094728380041494 -> 0.6014687471531988260823066997845691 Inexact Rounded
-logx2226 log10 0.0000000000583549164588495206767840 -> -10.23392254834182677023231713519341 Inexact Rounded
-logx2227 log10 9567.961832607240278342761088487484 -> 3.980819434211107631569386147016368 Inexact Rounded
-logx2228 log10 06.26592979160342972777219828867033 -> 0.7969855243966221408595024012574729 Inexact Rounded
-logx2229 log10 0.0000000000589847046598067273287319 -> -10.22926059078206218717755253582907 Inexact Rounded
-logx2230 log10 567.9388648235589204769442863724997 -> 2.754301589058313576472380262907638 Inexact Rounded
-logx2231 log10 039.7790325480037778918162264883415 -> 1.599654216592019199639285308997886 Inexact Rounded
-logx2232 log10 0.0000000005123951921894162149817207 -> -9.290394953898862694847327137242690 Inexact Rounded
-logx2233 log10 0.0000000000038500999723636904276723 -> -11.41452799337924056186867324854691 Inexact Rounded
-logx2234 log10 0.0006726500658977759825616537935864 -> -3.172210810922768725687671849421792 Inexact Rounded
-logx2235 log10 260.2400250475967528429943779126507 -> 2.415374092073799204236801383070064 Inexact Rounded
-logx2236 log10 0.0000000006101942339385102585042548 -> -9.214531900562046557191261226632509 Inexact Rounded
-logx2237 log10 0.0000000010846867501382746760066557 -> -8.964695664883282406359874242387236 Inexact Rounded
-logx2238 log10 60.24078375568814769010333711509928 -> 1.779890613567084253168373266648922 Inexact Rounded
-logx2239 log10 0.0012058738711757669337600252986093 -> -2.918698115012605915753728220896010 Inexact Rounded
-logx2240 log10 230.9450930197841600611503095185600 -> 2.363508739056822846742942599628966 Inexact Rounded
-
--- P=16, within 0-999
-Precision: 16
-logx2101 log10 0.0072067119605184 -> -2.142262835573038 Inexact Rounded
-logx2102 log10 503.6828482226624 -> 2.702157162195652 Inexact Rounded
-logx2103 log10 64.96074447821815 -> 1.812650993464174 Inexact Rounded
-logx2104 log10 48.75408597467246 -> 1.688011018842600 Inexact Rounded
-logx2105 log10 0.0329009839269587 -> -1.482791113975280 Inexact Rounded
-logx2106 log10 223.5320415060633 -> 2.349339784523410 Inexact Rounded
-logx2107 log10 73.12765002292194 -> 1.864081617476268 Inexact Rounded
-logx2108 log10 487.3749378358509 -> 2.687863192802252 Inexact Rounded
-logx2109 log10 0.0000019671987621 -> -5.706151757557926 Inexact Rounded
-logx2110 log10 0.0570680660609784 -> -1.243606844697873 Inexact Rounded
-logx2111 log10 33.10311638788998 -> 1.519868880976773 Inexact Rounded
-logx2112 log10 0.0687382699187077 -> -1.162801402868185 Inexact Rounded
-logx2113 log10 258.9416193626484 -> 2.413201859654145 Inexact Rounded
-logx2114 log10 0.0005306100136736 -> -3.275224558269725 Inexact Rounded
-logx2115 log10 65.78490393408572 -> 1.818126244825109 Inexact Rounded
-logx2116 log10 504.2328842073510 -> 2.702631165346958 Inexact Rounded
-logx2117 log10 9.417432755815027 -> 0.9739325278524503 Inexact Rounded
-logx2118 log10 006.7054835355498 -> 0.8264301004947640 Inexact Rounded
-logx2119 log10 0.0917012272363915 -> -1.037624852133399 Inexact Rounded
-logx2120 log10 5.959404385244921 -> 0.7752028561953401 Inexact Rounded
-logx2121 log10 0.0001209759148486 -> -3.917301084968903 Inexact Rounded
-logx2122 log10 0.0004706112139838 -> -3.327337728428039 Inexact Rounded
-logx2123 log10 0.0069700457377046 -> -2.156764372035771 Inexact Rounded
-logx2124 log10 0.5155584569852619 -> -0.2877220847805025 Inexact Rounded
-logx2125 log10 88.06005885607414 -> 1.944778971389913 Inexact Rounded
-logx2126 log10 0.0448240038219866 -> -1.348489353509709 Inexact Rounded
-logx2127 log10 3.419622484059565 -> 0.5339781639101145 Inexact Rounded
-logx2128 log10 5.171123353858721 -> 0.7135848977142854 Inexact Rounded
-logx2129 log10 0.0002133188319807 -> -3.670970802945872 Inexact Rounded
-logx2130 log10 46.21086703136966 -> 1.664744117045149 Inexact Rounded
-logx2131 log10 0.0000631053714415 -> -4.199933672639880 Inexact Rounded
-logx2132 log10 78.66019196870698 -> 1.895755001962469 Inexact Rounded
-logx2133 log10 0.0007152278351188 -> -3.145555592082297 Inexact Rounded
-logx2134 log10 45.52509819928536 -> 1.658250891256892 Inexact Rounded
-logx2135 log10 0.0000703227795740 -> -4.152903971697183 Inexact Rounded
-logx2136 log10 26.24438641426669 -> 1.419036423550599 Inexact Rounded
-logx2137 log10 0.0000044654829535 -> -5.350131564166817 Inexact Rounded
-logx2138 log10 0.7360702733062529 -> -0.1330807211893611 Inexact Rounded
-logx2139 log10 8.417059176469655 -> 0.9251603805112778 Inexact Rounded
-logx2140 log10 0.0002926570767968 -> -3.533640969664818 Inexact Rounded
-
--- P=7, within 0-99
-Precision: 7
-logx2001 log10 57.26089 -> 1.757858 Inexact Rounded
-logx2002 log10 0.0575421 -> -1.240014 Inexact Rounded
-logx2003 log10 0.5918465 -> -0.2277909 Inexact Rounded
-logx2004 log10 0.0068776 -> -2.162563 Inexact Rounded
-logx2005 log10 0.0066833 -> -2.175009 Inexact Rounded
-logx2006 log10 9.926963 -> 0.9968164 Inexact Rounded
-logx2007 log10 0.0041852 -> -2.378284 Inexact Rounded
-logx2008 log10 84.15412 -> 1.925075 Inexact Rounded
-logx2009 log10 2.466856 -> 0.3921438 Inexact Rounded
-logx2010 log10 0.0058047 -> -2.236220 Inexact Rounded
-logx2011 log10 9.885154 -> 0.9949834 Inexact Rounded
-logx2012 log10 0.6667654 -> -0.1760269 Inexact Rounded
-logx2013 log10 34.65736 -> 1.539795 Inexact Rounded
-logx2014 log10 0.0026884 -> -2.570506 Inexact Rounded
-logx2015 log10 0.0432767 -> -1.363746 Inexact Rounded
-logx2016 log10 66.01407 -> 1.819637 Inexact Rounded
-logx2017 log10 0.0070572 -> -2.151368 Inexact Rounded
-logx2018 log10 0.0731613 -> -1.135719 Inexact Rounded
-logx2019 log10 9.838983 -> 0.9929502 Inexact Rounded
-logx2020 log10 15.89696 -> 1.201314 Inexact Rounded
-logx2021 log10 8.459247 -> 0.9273317 Inexact Rounded
-logx2022 log10 0.0010873 -> -2.963651 Inexact Rounded
-logx2023 log10 0.6498619 -> -0.1871789 Inexact Rounded
-logx2024 log10 0.0847008 -> -1.072112 Inexact Rounded
-logx2025 log10 0.0075489 -> -2.122116 Inexact Rounded
-logx2026 log10 51.11152 -> 1.708519 Inexact Rounded
-logx2027 log10 0.7233866 -> -0.1406295 Inexact Rounded
-logx2028 log10 2.254721 -> 0.3530928 Inexact Rounded
-logx2029 log10 6.568444 -> 0.8174625 Inexact Rounded
-logx2030 log10 83.72639 -> 1.922862 Inexact Rounded
-logx2031 log10 6.720585 -> 0.8274071 Inexact Rounded
-logx2032 log10 87.90366 -> 1.944007 Inexact Rounded
-logx2033 log10 0.0433324 -> -1.363187 Inexact Rounded
-logx2034 log10 34.63912 -> 1.539567 Inexact Rounded
-logx2035 log10 0.8089059 -> -0.09210200 Inexact Rounded
-logx2036 log10 7.793405 -> 0.8917272 Inexact Rounded
-logx2037 log10 0.0041757 -> -2.379271 Inexact Rounded
-logx2038 log10 7.135417 -> 0.8534194 Inexact Rounded
-logx2039 log10 12.49570 -> 1.096761 Inexact Rounded
-logx2040 log10 6.356276 -> 0.8032027 Inexact Rounded
-
---------
-maxExponent: 384
-minExponent: -383
-precision: 16
-rounding: half_even
-
--- special values
-logx820 log10 Infinity -> Infinity
-logx821 log10 0 -> -Infinity
-logx822 log10 NaN -> NaN
-logx823 log10 sNaN -> NaN Invalid_operation
--- propagating NaNs
-logx824 log10 sNaN123 -> NaN123 Invalid_operation
-logx825 log10 -sNaN321 -> -NaN321 Invalid_operation
-logx826 log10 NaN456 -> NaN456
-logx827 log10 -NaN654 -> -NaN654
-logx828 log10 NaN1 -> NaN1
-
-
--- Invalid operations due to restrictions
--- [next two probably skipped by most test harnesses]
-precision: 100000000
-logx901 log10 1 -> NaN Invalid_context
-precision: 99999999
-logx902 log10 0 -> NaN Invalid_context
-
-precision: 9
-maxExponent: 1000000
-minExponent: -999999
-logx903 log10 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999999
-logx904 log10 0 -> -Infinity
-maxExponent: 999999
-minExponent: -1000000
-logx905 log10 1 -> NaN Invalid_context
-maxExponent: 999999
-minExponent: -999998
-logx906 log10 0 -> -Infinity
-
--- Null test
-logx900 log10 # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- log10.decTest -- decimal logarithm in base 10 --
+-- Copyright (c) IBM Corporation, 2005, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This emphasises the testing of notable cases, as they will often
+-- have unusual paths (especially the 10**n results).
+
+extended: 1
+precision: 16
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- examples in specification
+precision: 9
+logxs000 log10 0 -> -Infinity
+logxs001 log10 0.001 -> -3
+logxs002 log10 1 -> 0
+logxs003 log10 2 -> 0.301029996 Inexact Rounded
+logxs004 log10 10 -> 1
+logxs005 log10 70 -> 1.84509804 Inexact Rounded
+logxs006 log10 +Infinity -> Infinity
+
+
+-- basics (examples in specification, etc.)
+precision: 16
+logx0000 log10 0 -> -Infinity
+logx0001 log10 7E-1000 -> -999.1549019599857 Inexact Rounded
+logx0002 log10 1.1E-9 -> -8.958607314841775 Inexact Rounded
+logx0003 log10 0.0007 -> -3.154901959985743 Inexact Rounded
+logx0004 log10 0.11 -> -0.9586073148417750 Inexact Rounded
+logx0005 log10 0.7 -> -0.1549019599857432 Inexact Rounded
+logx0006 log10 1 -> 0
+logx0007 log10 1.5 -> 0.1760912590556812 Inexact Rounded
+logx0008 log10 2 -> 0.3010299956639812 Inexact Rounded
+logx0009 log10 2.718281828459045 -> 0.4342944819032518 Inexact Rounded
+logx0010 log10 2.718281828459046 -> 0.4342944819032519 Inexact Rounded
+logx0011 log10 2.718281828459047 -> 0.4342944819032521 Inexact Rounded
+logx0012 log10 7 -> 0.8450980400142568 Inexact Rounded
+logx0013 log10 10 -> 1
+logx0014 log10 10.5 -> 1.021189299069938 Inexact Rounded
+logx0015 log10 11 -> 1.041392685158225 Inexact Rounded
+logx0016 log10 70 -> 1.845098040014257 Inexact Rounded
+logx0017 log10 9999 -> 3.999956568380192 Inexact Rounded
+logx0018 log10 1.21E6 -> 6.082785370316450 Inexact Rounded
+logx0019 log10 1.1E+9 -> 9.041392685158225 Inexact Rounded
+logx0020 log10 7E+1000 -> 1000.845098040014 Inexact Rounded
+logx0021 log10 +Infinity -> Infinity
+
+-- notable cases
+-- negatives
+logx0031 log10 -1E-9 -> NaN Invalid_operation
+logx0032 log10 -0.0007 -> NaN Invalid_operation
+logx0033 log10 -0.1 -> NaN Invalid_operation
+logx0034 log10 -0.7 -> NaN Invalid_operation
+logx0035 log10 -1 -> NaN Invalid_operation
+logx0036 log10 -1.5 -> NaN Invalid_operation
+logx0037 log10 -2 -> NaN Invalid_operation
+logx0038 log10 -10.5 -> NaN Invalid_operation
+logx0039 log10 -10.5 -> NaN Invalid_operation
+logx0040 log10 -9999 -> NaN Invalid_operation
+logx0041 log10 -10 -> NaN Invalid_operation
+logx0042 log10 -0 -> -Infinity
+logx0043 log10 -0E+17 -> -Infinity
+logx0044 log10 -0E-17 -> -Infinity
+-- other zeros
+logx0051 log10 0 -> -Infinity
+logx0052 log10 0E+17 -> -Infinity
+logx0053 log10 0E-17 -> -Infinity
+-- infinities
+logx0055 log10 -Infinity -> NaN Invalid_operation
+logx0056 log10 +Infinity -> Infinity
+-- ones
+logx0061 log10 1 -> 0
+logx0062 log10 1.0 -> 0
+logx0063 log10 1.000000000000000 -> 0
+logx0064 log10 1.000000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+logx1100 log10 1 -> 0
+logx1101 log10 10 -> 1
+logx1102 log10 100 -> 2
+logx1103 log10 1000 -> 3
+logx1104 log10 10000 -> 4
+logx1105 log10 100000 -> 5
+logx1106 log10 1000000 -> 6
+logx1107 log10 10000000 -> 7
+logx1108 log10 100000000 -> 8
+logx1109 log10 1000000000 -> 9
+logx1110 log10 10000000000 -> 10
+logx1111 log10 100000000000 -> 11
+logx1112 log10 1000000000000 -> 12
+logx1113 log10 0.00000000001 -> -11
+logx1114 log10 0.0000000001 -> -10
+logx1115 log10 0.000000001 -> -9
+logx1116 log10 0.00000001 -> -8
+logx1117 log10 0.0000001 -> -7
+logx1118 log10 0.000001 -> -6
+logx1119 log10 0.00001 -> -5
+logx1120 log10 0.0001 -> -4
+logx1121 log10 0.001 -> -3
+logx1122 log10 0.01 -> -2
+logx1123 log10 0.1 -> -1
+logx1124 log10 1E-99 -> -99
+logx1125 log10 1E-100 -> -100
+logx1126 log10 1E-383 -> -383
+
+-- check normally exact cases round properly
+precision: 1
+logx1141 log10 10000000000 -> 1E+1 Rounded
+logx1142 log10 1000000000000 -> 1E+1 Inexact Rounded
+logx1143 log10 1E+100 -> 1E+2 Rounded
+logx1144 log10 1E+123 -> 1E+2 Inexact Rounded
+logx1145 log10 1E+126 -> 1E+2 Inexact Rounded
+logx1146 log10 1E+916 -> 9E+2 Inexact Rounded
+logx1147 log10 1E+999 -> 1E+3 Inexact Rounded
+
+precision: 2
+logx1151 log10 10000000000 -> 10
+logx1152 log10 1000000000000 -> 12
+logx1153 log10 1E+100 -> 1.0E+2 Rounded
+logx1154 log10 1E+123 -> 1.2E+2 Inexact Rounded
+logx1155 log10 1E+126 -> 1.3E+2 Inexact Rounded
+logx1156 log10 1E+916 -> 9.2E+2 Inexact Rounded
+logx1157 log10 1E+999 -> 1.0E+3 Inexact Rounded
+-- some half-way point rounds, other cases, and negatives
+logx1158 log10 1E+125 -> 1.2E+2 Inexact Rounded
+logx1159 log10 1E+135 -> 1.4E+2 Inexact Rounded
+logx1160 log10 1E+129 -> 1.3E+2 Inexact Rounded
+logx1161 log10 1E+131 -> 1.3E+2 Inexact Rounded
+logx1162 log10 1E-123 -> -1.2E+2 Inexact Rounded
+logx1163 log10 1E-126 -> -1.3E+2 Inexact Rounded
+logx1164 log10 1E-916 -> -9.2E+2 Inexact Rounded
+logx1165 log10 1E-999 -> -1.0E+3 Inexact Rounded
+logx1166 log10 1E-125 -> -1.2E+2 Inexact Rounded
+logx1167 log10 1E-135 -> -1.4E+2 Inexact Rounded
+logx1168 log10 1E-129 -> -1.3E+2 Inexact Rounded
+logx1169 log10 1E-131 -> -1.3E+2 Inexact Rounded
+
+precision: 3
+logx1171 log10 10000000000 -> 10
+logx1172 log10 1000000000000 -> 12
+logx1173 log10 1E+100 -> 100
+logx1174 log10 1E+123 -> 123
+logx1175 log10 1E+126 -> 126
+logx1176 log10 1E+916 -> 916
+logx1177 log10 1E+999 -> 999
+
+-- log10(2) .. tests both ln(2) and ln(10) constants, too
+precision: 50
+logx1201 log10 2 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+logx1202 log10 2.000 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+logx1203 log10 0.2E1 -> 0.30102999566398119521373889472449302676818988146211 Inexact Rounded
+precision: 49
+logx1204 log10 2 -> 0.3010299956639811952137388947244930267681898814621 Inexact Rounded
+precision: 48
+logx1205 log10 2 -> 0.301029995663981195213738894724493026768189881462 Inexact Rounded
+precision: 47
+logx1206 log10 2 -> 0.30102999566398119521373889472449302676818988146 Inexact Rounded
+precision: 46
+logx1207 log10 2 -> 0.3010299956639811952137388947244930267681898815 Inexact Rounded
+precision: 45
+logx1208 log10 2 -> 0.301029995663981195213738894724493026768189881 Inexact Rounded
+precision: 44
+logx1209 log10 2 -> 0.30102999566398119521373889472449302676818988 Inexact Rounded
+precision: 43
+logx1210 log10 2 -> 0.3010299956639811952137388947244930267681899 Inexact Rounded
+precision: 42
+logx1211 log10 2 -> 0.301029995663981195213738894724493026768190 Inexact Rounded
+precision: 41
+logx1212 log10 2 -> 0.30102999566398119521373889472449302676819 Inexact Rounded
+precision: 40
+logx1213 log10 2 -> 0.3010299956639811952137388947244930267682 Inexact Rounded
+precision: 39
+logx1214 log10 2 -> 0.301029995663981195213738894724493026768 Inexact Rounded
+precision: 38
+logx1215 log10 2 -> 0.30102999566398119521373889472449302677 Inexact Rounded
+precision: 37
+logx1216 log10 2 -> 0.3010299956639811952137388947244930268 Inexact Rounded
+precision: 36
+logx1217 log10 2 -> 0.301029995663981195213738894724493027 Inexact Rounded
+precision: 35
+logx1218 log10 2 -> 0.30102999566398119521373889472449303 Inexact Rounded
+precision: 34
+logx1219 log10 2 -> 0.3010299956639811952137388947244930 Inexact Rounded
+precision: 33
+logx1220 log10 2 -> 0.301029995663981195213738894724493 Inexact Rounded
+precision: 32
+logx1221 log10 2 -> 0.30102999566398119521373889472449 Inexact Rounded
+precision: 31
+logx1222 log10 2 -> 0.3010299956639811952137388947245 Inexact Rounded
+precision: 30
+logx1223 log10 2 -> 0.301029995663981195213738894724 Inexact Rounded
+precision: 29
+logx1224 log10 2 -> 0.30102999566398119521373889472 Inexact Rounded
+precision: 28
+logx1225 log10 2 -> 0.3010299956639811952137388947 Inexact Rounded
+precision: 27
+logx1226 log10 2 -> 0.301029995663981195213738895 Inexact Rounded
+precision: 26
+logx1227 log10 2 -> 0.30102999566398119521373889 Inexact Rounded
+precision: 25
+logx1228 log10 2 -> 0.3010299956639811952137389 Inexact Rounded
+precision: 24
+logx1229 log10 2 -> 0.301029995663981195213739 Inexact Rounded
+precision: 23
+logx1230 log10 2 -> 0.30102999566398119521374 Inexact Rounded
+precision: 22
+logx1231 log10 2 -> 0.3010299956639811952137 Inexact Rounded
+precision: 21
+logx1232 log10 2 -> 0.301029995663981195214 Inexact Rounded
+precision: 20
+logx1233 log10 2 -> 0.30102999566398119521 Inexact Rounded
+precision: 19
+logx1234 log10 2 -> 0.3010299956639811952 Inexact Rounded
+precision: 18
+logx1235 log10 2 -> 0.301029995663981195 Inexact Rounded
+precision: 17
+logx1236 log10 2 -> 0.30102999566398120 Inexact Rounded
+precision: 16
+logx1237 log10 2 -> 0.3010299956639812 Inexact Rounded
+precision: 15
+logx1238 log10 2 -> 0.301029995663981 Inexact Rounded
+precision: 14
+logx1239 log10 2 -> 0.30102999566398 Inexact Rounded
+precision: 13
+logx1240 log10 2 -> 0.3010299956640 Inexact Rounded
+precision: 12
+logx1241 log10 2 -> 0.301029995664 Inexact Rounded
+precision: 11
+logx1242 log10 2 -> 0.30102999566 Inexact Rounded
+precision: 10
+logx1243 log10 2 -> 0.3010299957 Inexact Rounded
+precision: 9
+logx1244 log10 2 -> 0.301029996 Inexact Rounded
+precision: 8
+logx1245 log10 2 -> 0.30103000 Inexact Rounded
+precision: 7
+logx1246 log10 2 -> 0.3010300 Inexact Rounded
+precision: 6
+logx1247 log10 2 -> 0.301030 Inexact Rounded
+precision: 5
+logx1248 log10 2 -> 0.30103 Inexact Rounded
+precision: 4
+logx1249 log10 2 -> 0.3010 Inexact Rounded
+precision: 3
+logx1250 log10 2 -> 0.301 Inexact Rounded
+precision: 2
+logx1251 log10 2 -> 0.30 Inexact Rounded
+precision: 1
+logx1252 log10 2 -> 0.3 Inexact Rounded
+
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- More close-to-e, etc., tests
+precision: 34
+logx1301 log10 2.718281828459045235360287471352661 -> 0.4342944819032518276511289189166048 Inexact Rounded
+logx1302 log10 2.718281828459045235360287471352662 -> 0.4342944819032518276511289189166050 Inexact Rounded
+logx1303 log10 2.718281828459045235360287471352663 -> 0.4342944819032518276511289189166052 Inexact Rounded
+logx1304 log10 0.99999999999999999999999999999999 -> -4.342944819032518276511289189166073E-33 Inexact Rounded
+logx1305 log10 0.999999999999999999999999999999999 -> -4.342944819032518276511289189166053E-34 Inexact Rounded
+logx1306 log10 0.9999999999999999999999999999999999 -> -4.342944819032518276511289189166051E-35 Inexact Rounded
+logx1307 log10 1.000000000000000000000000000000000 -> 0
+logx1308 log10 1.0000000000000000000000000000000001 -> 4.342944819032518276511289189166051E-35 Inexact Rounded
+logx1309 log10 1.000000000000000000000000000000001 -> 4.342944819032518276511289189166049E-34 Inexact Rounded
+logx1310 log10 1.00000000000000000000000000000001 -> 4.342944819032518276511289189166029E-33 Inexact Rounded
+-- lower p
+precision: 7
+logx1320 log10 0.999999 -> -4.342947E-7 Inexact Rounded
+logx1321 log10 0.9999999 -> -4.342945E-8 Inexact Rounded
+logx1322 log10 0.99999999 -> -4.342945E-9 Inexact Rounded
+logx1323 log10 0.999999999 -> -4.342945E-10 Inexact Rounded
+logx1324 log10 1.00000000 -> 0
+logx1325 log10 1.00000001 -> 4.342945E-9 Inexact Rounded
+logx1326 log10 1.0000001 -> 4.342945E-8 Inexact Rounded
+logx1327 log10 1.000001 -> 4.342943E-7 Inexact Rounded
+
+-- near 10^3
+precision: 9
+logx1331 log10 999.9999998 -> 3.00000000 Inexact Rounded
+logx1332 log10 999.9999999 -> 3.00000000 Inexact Rounded
+logx1333 log10 1000.000000 -> 3
+logx1334 log10 1000.000001 -> 3.00000000 Inexact Rounded
+logx1335 log10 1000.000002 -> 3.00000000 Inexact Rounded
+precision: 16
+logx1341 log10 999.9999998 -> 2.999999999913141 Inexact Rounded
+logx1342 log10 999.9999999 -> 2.999999999956571 Inexact Rounded
+logx1343 log10 1000.000000 -> 3
+logx1344 log10 1000.000001 -> 3.000000000434294 Inexact Rounded
+logx1345 log10 1000.000002 -> 3.000000000868589 Inexact Rounded
+
+-- suggestions from Ilan Nehama
+logx1400 log10 10E-3 -> -2
+logx1401 log10 10E-2 -> -1
+logx1402 log10 100E-2 -> 0
+logx1403 log10 1000E-2 -> 1
+logx1404 log10 10000E-2 -> 2
+logx1405 log10 10E-1 -> 0
+logx1406 log10 100E-1 -> 1
+logx1407 log10 1000E-1 -> 2
+logx1408 log10 10000E-1 -> 3
+logx1409 log10 10E0 -> 1
+logx1410 log10 100E0 -> 2
+logx1411 log10 1000E0 -> 3
+logx1412 log10 10000E0 -> 4
+logx1413 log10 10E1 -> 2
+logx1414 log10 100E1 -> 3
+logx1415 log10 1000E1 -> 4
+logx1416 log10 10000E1 -> 5
+logx1417 log10 10E2 -> 3
+logx1418 log10 100E2 -> 4
+logx1419 log10 1000E2 -> 5
+logx1420 log10 10000E2 -> 6
+
+-- Randoms
+-- P=50, within 0-9999
+Precision: 50
+logx2501 log10 0.00035448001667968141775891246991912655961163345904 -> -3.4504082425411775290864053318247274944685586188505 Inexact Rounded
+logx2502 log10 70.636455726424311228255338637935330826995136597644 -> 1.8490288998408492045793070255302335558140975719247 Inexact Rounded
+logx2503 log10 0.00000000000000233550362473821889060812804063040169 -> -14.631619454343834858023578299142866557717904223667 Inexact Rounded
+logx2504 log10 97.783628621523244679901260358286898958832135433764 -> 1.9902661493224219517897657964362571690592734407330 Inexact Rounded
+logx2505 log10 0062.2377135315858392802612812022807838599572017342 -> 1.7940536293085066199287632725026837018486533544141 Inexact Rounded
+logx2506 log10 6.3767634652071053619977602804724129652981747879532 -> 0.80460030789825961615100163576080761326857374098644 Inexact Rounded
+logx2507 log10 63.297088981313278529306533814195068850532666658798 -> 1.8013837373724427092417170149098614410849353839673 Inexact Rounded
+logx2508 log10 0.00000077239693316881797717820110898167721602299187 -> -6.1121594592718550613773886241951966264826760310047 Inexact Rounded
+logx2509 log10 0.00000003953580359780185534830572461922527831395002 -> -7.4030094293833847136252547069905477213541787177561 Inexact Rounded
+logx2510 log10 754.62905817369989169188998111527272688791544577204 -> 2.8777335243761300047758534304371912099958057545416 Inexact Rounded
+logx2511 log10 0.00000048360378410241428936607147056283282849158312 -> -6.3155103095309353457604038397980091650760346334512 Inexact Rounded
+logx2512 log10 0.00007509037583645612577196104591672080542932166089 -> -4.1244157219700166314012344705538088030592896111026 Inexact Rounded
+logx2513 log10 0.00000000000705475944638915053419839063567898092064 -> -11.151517790256466048553810002525868198178167950377 Inexact Rounded
+logx2514 log10 9.6210300460497657917445410947099633479609165120661 -> 0.98322157093260978206633922877716078683518617768411 Inexact Rounded
+logx2515 log10 0.00000000050150361386555527496607245976120864985611 -> -9.2997259330798261040411086835563234390934934629340 Inexact Rounded
+logx2516 log10 098.24754029731994125797723545333677604490074810751 -> 1.9923216862874337077795278629351060819105679670633 Inexact Rounded
+logx2517 log10 7.5091998150046994320441463854301624742491015752980 -> 0.87559366078005924080766469158763499725414024128781 Inexact Rounded
+logx2518 log10 0.00000000000079540571273330075193668596942268542425 -> -12.099411294165176028817305108475326325006250936963 Inexact Rounded
+logx2519 log10 0.00000042395034799555215782907515074134154915491701 -> -6.3726850039125381134069450802108893075604464135297 Inexact Rounded
+logx2520 log10 56.683376304674355481905023145238799909301732694982 -> 1.7534557107853480435703421826077606250636580091754 Inexact Rounded
+logx2521 log10 48.734033811444195070807606721517169810438049581227 -> 1.6878323602741065190942654710049433808208291564049 Inexact Rounded
+logx2522 log10 0.00074830310930046865009851706989430228561880221063 -> -3.1259224502209974082223667712016445572431791920618 Inexact Rounded
+logx2523 log10 36.677348885111593384020836720396262497122708598359 -> 1.5643979364260796086754530282302605477567469395425 Inexact Rounded
+logx2524 log10 0.00000000000000004495678560480432858812419145833744 -> -16.347204748239740510014320630363244015916029619561 Inexact Rounded
+logx2525 log10 9509.5854013650642799374159131940108748594774307104 -> 3.9781615829916326741100166519726824430945406302661 Inexact Rounded
+logx2526 log10 0.07834891268689177014044454793608715276615743819097 -> -1.1059670262197643147805517398621288897669876996348 Inexact Rounded
+logx2527 log10 0.00000029584529880706128444454688454999032801904794 -> -6.5289353275814043710076526920566721570375026917206 Inexact Rounded
+logx2528 log10 3.0713496544497618098794332787772186176981011904294 -> 0.48732926103896828546424341029492468100431414072994 Inexact Rounded
+logx2529 log10 352.66392670788816474407442785460803833927136413943 -> 2.5473610388199562714709836398243933320284077008314 Inexact Rounded
+logx2530 log10 0.00304743125181876267210516527361742185617091801650 -> -2.5160660830163981967774124745311497447050056400207 Inexact Rounded
+logx2531 log10 0.00000076120535894952136499250364604538117729437183 -> -6.1184981629047051532448413863950776496652483019415 Inexact Rounded
+logx2532 log10 769.88795978534353052965286195053735007473187735815 -> 2.8864275277862652709986498581064117950288798222100 Inexact Rounded
+logx2533 log10 0.00000000000000041297494808612226304619570016336188 -> -15.384076292745415917510668454361868659468669804710 Inexact Rounded
+logx2534 log10 860.88864595714426940247940960258558876903741966974 -> 2.9349469800554277915920278090647283233440859155176 Inexact Rounded
+logx2535 log10 5839.0328812994787235900178587371051096898683972444 -> 3.7663409208972392569269125539438874737147906238543 Inexact Rounded
+logx2536 log10 0.00000028532710151284840471670497112821201598377841 -> -6.5446569753514027675878879843238065488490618159490 Inexact Rounded
+logx2537 log10 0.00000000000000009734490059931638483445631835651581 -> -16.011686794011271135978633880864278692254243106931 Inexact Rounded
+logx2538 log10 5.8610949526439529489252302463450302981511714144330 -> 0.76797875722452549281028552067645732490929361952278 Inexact Rounded
+logx2539 log10 6.6282432221115923372151148990137179611977576327206 -> 0.82139843639227213211012044000785757267155736071361 Inexact Rounded
+logx2540 log10 0.00000000001994071862386846626954819923923344413454 -> -10.700259194632339980266559224447212260115021637626 Inexact Rounded
+
+-- P=34, within 0-9999
+Precision: 34
+logx2201 log10 1.522513203889714179088327328864183 -> 0.1825610677098896250496651330492109 Inexact Rounded
+logx2202 log10 0.171123774769717316154080888930404 -> -0.7666896483548462582461898092764408 Inexact Rounded
+logx2203 log10 0.0000000997467236251714283104963838 -> -7.001101360652518274271569010312115 Inexact Rounded
+logx2204 log10 0.0008856103624122479769647543468633 -> -3.052757310476070891830490327138190 Inexact Rounded
+logx2205 log10 1.938274868738032930709498221236758 -> 0.2874153648259449520201536171714594 Inexact Rounded
+logx2206 log10 479.5667847823826713082613445010097 -> 2.680849095850361068709165157286435 Inexact Rounded
+logx2207 log10 8856.136599178820202141823157336804 -> 3.947244306584767101480454261950559 Inexact Rounded
+logx2208 log10 0.0000911026318801903982642871344858 -> -4.040469076434979398438617464033826 Inexact Rounded
+logx2209 log10 0.0000000000017271112650427414732630 -> -11.76267968314038748995178212654921 Inexact Rounded
+logx2210 log10 6.962605370078885647639503548229695 -> 0.8427717807200322352686396925992250 Inexact Rounded
+logx2211 log10 0.3354804428992793132855923541692781 -> -0.4743327923012159170967636070844834 Inexact Rounded
+logx2212 log10 2.079864257474859008252165836663504 -> 0.3180349916198059046812506741388856 Inexact Rounded
+logx2213 log10 2805.479529292939499220276986621988 -> 3.448007104139974344565978780624744 Inexact Rounded
+logx2214 log10 66.45731133034187374557028537213949 -> 1.822542767005644041661520936223086 Inexact Rounded
+logx2215 log10 0.0000001206521261762681738274822835 -> -6.918465020390216969561494755767318 Inexact Rounded
+logx2216 log10 0.0000000001884891916264401160472381 -> -9.724713548119065386091933007528633 Inexact Rounded
+logx2217 log10 0.0000015467279551726326581314582759 -> -5.810586065070435383755759514608738 Inexact Rounded
+logx2218 log10 0.0090776316728068586744633914135952 -> -2.042027442843745884503280954390114 Inexact Rounded
+logx2219 log10 0.0000000000024541106528713393740030 -> -11.61010585935635713090119156069479 Inexact Rounded
+logx2220 log10 14.12936879385863410081087750645856 -> 1.150122760895466989841057385742662 Inexact Rounded
+logx2221 log10 0.0000036912481831392922922647231392 -> -5.432826753789892283556211380824203 Inexact Rounded
+logx2222 log10 0.0000000004067477525420424270138734 -> -9.390674838050073122857868012475060 Inexact Rounded
+logx2223 log10 7080.122562705399744969319589806194 -> 3.850040775747103318724330047546916 Inexact Rounded
+logx2224 log10 261.3491411363679209175524790255725 -> 2.417221077227536319655699517530855 Inexact Rounded
+logx2225 log10 003.9945581449915240094728380041494 -> 0.6014687471531988260823066997845691 Inexact Rounded
+logx2226 log10 0.0000000000583549164588495206767840 -> -10.23392254834182677023231713519341 Inexact Rounded
+logx2227 log10 9567.961832607240278342761088487484 -> 3.980819434211107631569386147016368 Inexact Rounded
+logx2228 log10 06.26592979160342972777219828867033 -> 0.7969855243966221408595024012574729 Inexact Rounded
+logx2229 log10 0.0000000000589847046598067273287319 -> -10.22926059078206218717755253582907 Inexact Rounded
+logx2230 log10 567.9388648235589204769442863724997 -> 2.754301589058313576472380262907638 Inexact Rounded
+logx2231 log10 039.7790325480037778918162264883415 -> 1.599654216592019199639285308997886 Inexact Rounded
+logx2232 log10 0.0000000005123951921894162149817207 -> -9.290394953898862694847327137242690 Inexact Rounded
+logx2233 log10 0.0000000000038500999723636904276723 -> -11.41452799337924056186867324854691 Inexact Rounded
+logx2234 log10 0.0006726500658977759825616537935864 -> -3.172210810922768725687671849421792 Inexact Rounded
+logx2235 log10 260.2400250475967528429943779126507 -> 2.415374092073799204236801383070064 Inexact Rounded
+logx2236 log10 0.0000000006101942339385102585042548 -> -9.214531900562046557191261226632509 Inexact Rounded
+logx2237 log10 0.0000000010846867501382746760066557 -> -8.964695664883282406359874242387236 Inexact Rounded
+logx2238 log10 60.24078375568814769010333711509928 -> 1.779890613567084253168373266648922 Inexact Rounded
+logx2239 log10 0.0012058738711757669337600252986093 -> -2.918698115012605915753728220896010 Inexact Rounded
+logx2240 log10 230.9450930197841600611503095185600 -> 2.363508739056822846742942599628966 Inexact Rounded
+
+-- P=16, within 0-999
+Precision: 16
+logx2101 log10 0.0072067119605184 -> -2.142262835573038 Inexact Rounded
+logx2102 log10 503.6828482226624 -> 2.702157162195652 Inexact Rounded
+logx2103 log10 64.96074447821815 -> 1.812650993464174 Inexact Rounded
+logx2104 log10 48.75408597467246 -> 1.688011018842600 Inexact Rounded
+logx2105 log10 0.0329009839269587 -> -1.482791113975280 Inexact Rounded
+logx2106 log10 223.5320415060633 -> 2.349339784523410 Inexact Rounded
+logx2107 log10 73.12765002292194 -> 1.864081617476268 Inexact Rounded
+logx2108 log10 487.3749378358509 -> 2.687863192802252 Inexact Rounded
+logx2109 log10 0.0000019671987621 -> -5.706151757557926 Inexact Rounded
+logx2110 log10 0.0570680660609784 -> -1.243606844697873 Inexact Rounded
+logx2111 log10 33.10311638788998 -> 1.519868880976773 Inexact Rounded
+logx2112 log10 0.0687382699187077 -> -1.162801402868185 Inexact Rounded
+logx2113 log10 258.9416193626484 -> 2.413201859654145 Inexact Rounded
+logx2114 log10 0.0005306100136736 -> -3.275224558269725 Inexact Rounded
+logx2115 log10 65.78490393408572 -> 1.818126244825109 Inexact Rounded
+logx2116 log10 504.2328842073510 -> 2.702631165346958 Inexact Rounded
+logx2117 log10 9.417432755815027 -> 0.9739325278524503 Inexact Rounded
+logx2118 log10 006.7054835355498 -> 0.8264301004947640 Inexact Rounded
+logx2119 log10 0.0917012272363915 -> -1.037624852133399 Inexact Rounded
+logx2120 log10 5.959404385244921 -> 0.7752028561953401 Inexact Rounded
+logx2121 log10 0.0001209759148486 -> -3.917301084968903 Inexact Rounded
+logx2122 log10 0.0004706112139838 -> -3.327337728428039 Inexact Rounded
+logx2123 log10 0.0069700457377046 -> -2.156764372035771 Inexact Rounded
+logx2124 log10 0.5155584569852619 -> -0.2877220847805025 Inexact Rounded
+logx2125 log10 88.06005885607414 -> 1.944778971389913 Inexact Rounded
+logx2126 log10 0.0448240038219866 -> -1.348489353509709 Inexact Rounded
+logx2127 log10 3.419622484059565 -> 0.5339781639101145 Inexact Rounded
+logx2128 log10 5.171123353858721 -> 0.7135848977142854 Inexact Rounded
+logx2129 log10 0.0002133188319807 -> -3.670970802945872 Inexact Rounded
+logx2130 log10 46.21086703136966 -> 1.664744117045149 Inexact Rounded
+logx2131 log10 0.0000631053714415 -> -4.199933672639880 Inexact Rounded
+logx2132 log10 78.66019196870698 -> 1.895755001962469 Inexact Rounded
+logx2133 log10 0.0007152278351188 -> -3.145555592082297 Inexact Rounded
+logx2134 log10 45.52509819928536 -> 1.658250891256892 Inexact Rounded
+logx2135 log10 0.0000703227795740 -> -4.152903971697183 Inexact Rounded
+logx2136 log10 26.24438641426669 -> 1.419036423550599 Inexact Rounded
+logx2137 log10 0.0000044654829535 -> -5.350131564166817 Inexact Rounded
+logx2138 log10 0.7360702733062529 -> -0.1330807211893611 Inexact Rounded
+logx2139 log10 8.417059176469655 -> 0.9251603805112778 Inexact Rounded
+logx2140 log10 0.0002926570767968 -> -3.533640969664818 Inexact Rounded
+
+-- P=7, within 0-99
+Precision: 7
+logx2001 log10 57.26089 -> 1.757858 Inexact Rounded
+logx2002 log10 0.0575421 -> -1.240014 Inexact Rounded
+logx2003 log10 0.5918465 -> -0.2277909 Inexact Rounded
+logx2004 log10 0.0068776 -> -2.162563 Inexact Rounded
+logx2005 log10 0.0066833 -> -2.175009 Inexact Rounded
+logx2006 log10 9.926963 -> 0.9968164 Inexact Rounded
+logx2007 log10 0.0041852 -> -2.378284 Inexact Rounded
+logx2008 log10 84.15412 -> 1.925075 Inexact Rounded
+logx2009 log10 2.466856 -> 0.3921438 Inexact Rounded
+logx2010 log10 0.0058047 -> -2.236220 Inexact Rounded
+logx2011 log10 9.885154 -> 0.9949834 Inexact Rounded
+logx2012 log10 0.6667654 -> -0.1760269 Inexact Rounded
+logx2013 log10 34.65736 -> 1.539795 Inexact Rounded
+logx2014 log10 0.0026884 -> -2.570506 Inexact Rounded
+logx2015 log10 0.0432767 -> -1.363746 Inexact Rounded
+logx2016 log10 66.01407 -> 1.819637 Inexact Rounded
+logx2017 log10 0.0070572 -> -2.151368 Inexact Rounded
+logx2018 log10 0.0731613 -> -1.135719 Inexact Rounded
+logx2019 log10 9.838983 -> 0.9929502 Inexact Rounded
+logx2020 log10 15.89696 -> 1.201314 Inexact Rounded
+logx2021 log10 8.459247 -> 0.9273317 Inexact Rounded
+logx2022 log10 0.0010873 -> -2.963651 Inexact Rounded
+logx2023 log10 0.6498619 -> -0.1871789 Inexact Rounded
+logx2024 log10 0.0847008 -> -1.072112 Inexact Rounded
+logx2025 log10 0.0075489 -> -2.122116 Inexact Rounded
+logx2026 log10 51.11152 -> 1.708519 Inexact Rounded
+logx2027 log10 0.7233866 -> -0.1406295 Inexact Rounded
+logx2028 log10 2.254721 -> 0.3530928 Inexact Rounded
+logx2029 log10 6.568444 -> 0.8174625 Inexact Rounded
+logx2030 log10 83.72639 -> 1.922862 Inexact Rounded
+logx2031 log10 6.720585 -> 0.8274071 Inexact Rounded
+logx2032 log10 87.90366 -> 1.944007 Inexact Rounded
+logx2033 log10 0.0433324 -> -1.363187 Inexact Rounded
+logx2034 log10 34.63912 -> 1.539567 Inexact Rounded
+logx2035 log10 0.8089059 -> -0.09210200 Inexact Rounded
+logx2036 log10 7.793405 -> 0.8917272 Inexact Rounded
+logx2037 log10 0.0041757 -> -2.379271 Inexact Rounded
+logx2038 log10 7.135417 -> 0.8534194 Inexact Rounded
+logx2039 log10 12.49570 -> 1.096761 Inexact Rounded
+logx2040 log10 6.356276 -> 0.8032027 Inexact Rounded
+
+--------
+maxExponent: 384
+minExponent: -383
+precision: 16
+rounding: half_even
+
+-- special values
+logx820 log10 Infinity -> Infinity
+logx821 log10 0 -> -Infinity
+logx822 log10 NaN -> NaN
+logx823 log10 sNaN -> NaN Invalid_operation
+-- propagating NaNs
+logx824 log10 sNaN123 -> NaN123 Invalid_operation
+logx825 log10 -sNaN321 -> -NaN321 Invalid_operation
+logx826 log10 NaN456 -> NaN456
+logx827 log10 -NaN654 -> -NaN654
+logx828 log10 NaN1 -> NaN1
+
+
+-- Invalid operations due to restrictions
+-- [next two probably skipped by most test harnesses]
+precision: 100000000
+logx901 log10 1 -> NaN Invalid_context
+precision: 99999999
+logx902 log10 0 -> NaN Invalid_context
+
+precision: 9
+maxExponent: 1000000
+minExponent: -999999
+logx903 log10 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999999
+logx904 log10 0 -> -Infinity
+maxExponent: 999999
+minExponent: -1000000
+logx905 log10 1 -> NaN Invalid_context
+maxExponent: 999999
+minExponent: -999998
+logx906 log10 0 -> -Infinity
+
+-- Null test
+logx900 log10 # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/logb.decTest b/Lib/test/decimaltestdata/logb.decTest
index 8b79006257d..ff420d0a842 100644
--- a/Lib/test/decimaltestdata/logb.decTest
+++ b/Lib/test/decimaltestdata/logb.decTest
@@ -1,188 +1,188 @@
-------------------------------------------------------------------------
--- logb.decTest -- return integral adjusted exponent as per 754r --
--- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This emphasises the testing of notable cases, as they will often
--- have unusual paths (especially the 10**n results).
-
-extended: 1
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-
--- basics & examples
-precision: 9
-logbx001 logb 0 -> -Infinity Division_by_zero
-logbx002 logb 1E-999 -> -999
-logbx003 logb 9E-999 -> -999
-logbx004 logb 0.001 -> -3
-logbx005 logb 0.03 -> -2
-logbx006 logb 1 -> 0
-logbx007 logb 2 -> 0
-logbx008 logb 2.5 -> 0
-logbx009 logb 2.50 -> 0
-logbx010 logb 10 -> 1
-logbx011 logb 70 -> 1
-logbx012 logb 100 -> 2
-logbx013 logb 250 -> 2
-logbx014 logb +Infinity -> Infinity
-
--- negatives are treated as positives
-logbx021 logb -0 -> -Infinity Division_by_zero
-logbx022 logb -1E-999 -> -999
-logbx023 logb -9E-999 -> -999
-logbx024 logb -0.001 -> -3
-logbx025 logb -1 -> 0
-logbx026 logb -2 -> 0
-logbx027 logb -10 -> 1
-logbx028 logb -70 -> 1
-logbx029 logb -100 -> 2
-logbx030 logb -100000000 -> 8
-logbx031 logb -Infinity -> Infinity
-
--- zeros
-logbx111 logb 0 -> -Infinity Division_by_zero
-logbx112 logb -0 -> -Infinity Division_by_zero
-logbx113 logb 0E+4 -> -Infinity Division_by_zero
-logbx114 logb -0E+4 -> -Infinity Division_by_zero
-logbx115 logb 0.0000 -> -Infinity Division_by_zero
-logbx116 logb -0.0000 -> -Infinity Division_by_zero
-logbx117 logb 0E-141 -> -Infinity Division_by_zero
-logbx118 logb -0E-141 -> -Infinity Division_by_zero
-
--- full coefficients, alternating bits
-logbx121 logb 268268268 -> 8
-logbx122 logb -268268268 -> 8
-logbx123 logb 134134134 -> 8
-logbx124 logb -134134134 -> 8
-
--- Nmax, Nmin, Ntiny
-logbx131 logb 9.99999999E+999 -> 999
-logbx132 logb 1E-999 -> -999
-logbx133 logb 1.00000000E-999 -> -999
-logbx134 logb 1E-1007 -> -1007
-
-logbx135 logb -1E-1007 -> -1007
-logbx136 logb -1.00000000E-999 -> -999
-logbx137 logb -1E-999 -> -999
-logbx138 logb -9.99999999E+999 -> 999
-
--- ones
-logbx0061 logb 1 -> 0
-logbx0062 logb 1.0 -> 0
-logbx0063 logb 1.000000000000000 -> 0
-logbx0064 logb 1.000000000000000000 -> 0
-
--- notable cases -- exact powers of 10
-logbx1100 logb 1 -> 0
-logbx1101 logb 10 -> 1
-logbx1102 logb 100 -> 2
-logbx1103 logb 1000 -> 3
-logbx1104 logb 10000 -> 4
-logbx1105 logb 100000 -> 5
-logbx1106 logb 1000000 -> 6
-logbx1107 logb 10000000 -> 7
-logbx1108 logb 100000000 -> 8
-logbx1109 logb 1000000000 -> 9
-logbx1110 logb 10000000000 -> 10
-logbx1111 logb 100000000000 -> 11
-logbx1112 logb 1000000000000 -> 12
-logbx1113 logb 0.00000000001 -> -11
-logbx1114 logb 0.0000000001 -> -10
-logbx1115 logb 0.000000001 -> -9
-logbx1116 logb 0.00000001 -> -8
-logbx1117 logb 0.0000001 -> -7
-logbx1118 logb 0.000001 -> -6
-logbx1119 logb 0.00001 -> -5
-logbx1120 logb 0.0001 -> -4
-logbx1121 logb 0.001 -> -3
-logbx1122 logb 0.01 -> -2
-logbx1123 logb 0.1 -> -1
-logbx1124 logb 1E-99 -> -99
-logbx1125 logb 1E-100 -> -100
-logbx1126 logb 1E-383 -> -383
-logbx1127 logb 1E-999 -> -999
-
--- suggestions from Ilan Nehama
-logbx1400 logb 10E-3 -> -2
-logbx1401 logb 10E-2 -> -1
-logbx1402 logb 100E-2 -> 0
-logbx1403 logb 1000E-2 -> 1
-logbx1404 logb 10000E-2 -> 2
-logbx1405 logb 10E-1 -> 0
-logbx1406 logb 100E-1 -> 1
-logbx1407 logb 1000E-1 -> 2
-logbx1408 logb 10000E-1 -> 3
-logbx1409 logb 10E0 -> 1
-logbx1410 logb 100E0 -> 2
-logbx1411 logb 1000E0 -> 3
-logbx1412 logb 10000E0 -> 4
-logbx1413 logb 10E1 -> 2
-logbx1414 logb 100E1 -> 3
-logbx1415 logb 1000E1 -> 4
-logbx1416 logb 10000E1 -> 5
-logbx1417 logb 10E2 -> 3
-logbx1418 logb 100E2 -> 4
-logbx1419 logb 1000E2 -> 5
-logbx1420 logb 10000E2 -> 6
-
--- inexacts
-precision: 2
-logbx1500 logb 10000E2 -> 6
-logbx1501 logb 1E+99 -> 99
-logbx1502 logb 1E-99 -> -99
-logbx1503 logb 1E+100 -> 1.0E+2 Rounded
-logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded
-logbx1505 logb 1E-100 -> -1.0E+2 Rounded
-logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded
-logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded
-logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded
-logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded
-logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded
-logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded
-precision: 1
-logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded
-logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded
-logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded
-precision: 8
-logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded
-logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded
-precision: 9
-logbx1523 logb 1E+999999999 -> 999999999
-logbx1524 logb 1E-999999999 -> -999999999
-
--- special values
-precision: 9
-logbx820 logb Infinity -> Infinity
-logbx821 logb -Infinity -> Infinity
-logbx822 logb 0 -> -Infinity Division_by_zero
-logbx823 logb NaN -> NaN
-logbx824 logb sNaN -> NaN Invalid_operation
--- propagating NaNs
-logbx825 logb sNaN123 -> NaN123 Invalid_operation
-logbx826 logb -sNaN321 -> -NaN321 Invalid_operation
-logbx827 logb NaN456 -> NaN456
-logbx828 logb -NaN654 -> -NaN654
-logbx829 logb NaN1 -> NaN1
-
--- Null test
-logbx900 logb # -> NaN Invalid_operation
-
-
+------------------------------------------------------------------------
+-- logb.decTest -- return integral adjusted exponent as per 754r --
+-- Copyright (c) IBM Corporation, 2005, 2009. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This emphasises the testing of notable cases, as they will often
+-- have unusual paths (especially the 10**n results).
+
+extended: 1
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+
+-- basics & examples
+precision: 9
+logbx001 logb 0 -> -Infinity Division_by_zero
+logbx002 logb 1E-999 -> -999
+logbx003 logb 9E-999 -> -999
+logbx004 logb 0.001 -> -3
+logbx005 logb 0.03 -> -2
+logbx006 logb 1 -> 0
+logbx007 logb 2 -> 0
+logbx008 logb 2.5 -> 0
+logbx009 logb 2.50 -> 0
+logbx010 logb 10 -> 1
+logbx011 logb 70 -> 1
+logbx012 logb 100 -> 2
+logbx013 logb 250 -> 2
+logbx014 logb +Infinity -> Infinity
+
+-- negatives are treated as positives
+logbx021 logb -0 -> -Infinity Division_by_zero
+logbx022 logb -1E-999 -> -999
+logbx023 logb -9E-999 -> -999
+logbx024 logb -0.001 -> -3
+logbx025 logb -1 -> 0
+logbx026 logb -2 -> 0
+logbx027 logb -10 -> 1
+logbx028 logb -70 -> 1
+logbx029 logb -100 -> 2
+logbx030 logb -100000000 -> 8
+logbx031 logb -Infinity -> Infinity
+
+-- zeros
+logbx111 logb 0 -> -Infinity Division_by_zero
+logbx112 logb -0 -> -Infinity Division_by_zero
+logbx113 logb 0E+4 -> -Infinity Division_by_zero
+logbx114 logb -0E+4 -> -Infinity Division_by_zero
+logbx115 logb 0.0000 -> -Infinity Division_by_zero
+logbx116 logb -0.0000 -> -Infinity Division_by_zero
+logbx117 logb 0E-141 -> -Infinity Division_by_zero
+logbx118 logb -0E-141 -> -Infinity Division_by_zero
+
+-- full coefficients, alternating bits
+logbx121 logb 268268268 -> 8
+logbx122 logb -268268268 -> 8
+logbx123 logb 134134134 -> 8
+logbx124 logb -134134134 -> 8
+
+-- Nmax, Nmin, Ntiny
+logbx131 logb 9.99999999E+999 -> 999
+logbx132 logb 1E-999 -> -999
+logbx133 logb 1.00000000E-999 -> -999
+logbx134 logb 1E-1007 -> -1007
+
+logbx135 logb -1E-1007 -> -1007
+logbx136 logb -1.00000000E-999 -> -999
+logbx137 logb -1E-999 -> -999
+logbx138 logb -9.99999999E+999 -> 999
+
+-- ones
+logbx0061 logb 1 -> 0
+logbx0062 logb 1.0 -> 0
+logbx0063 logb 1.000000000000000 -> 0
+logbx0064 logb 1.000000000000000000 -> 0
+
+-- notable cases -- exact powers of 10
+logbx1100 logb 1 -> 0
+logbx1101 logb 10 -> 1
+logbx1102 logb 100 -> 2
+logbx1103 logb 1000 -> 3
+logbx1104 logb 10000 -> 4
+logbx1105 logb 100000 -> 5
+logbx1106 logb 1000000 -> 6
+logbx1107 logb 10000000 -> 7
+logbx1108 logb 100000000 -> 8
+logbx1109 logb 1000000000 -> 9
+logbx1110 logb 10000000000 -> 10
+logbx1111 logb 100000000000 -> 11
+logbx1112 logb 1000000000000 -> 12
+logbx1113 logb 0.00000000001 -> -11
+logbx1114 logb 0.0000000001 -> -10
+logbx1115 logb 0.000000001 -> -9
+logbx1116 logb 0.00000001 -> -8
+logbx1117 logb 0.0000001 -> -7
+logbx1118 logb 0.000001 -> -6
+logbx1119 logb 0.00001 -> -5
+logbx1120 logb 0.0001 -> -4
+logbx1121 logb 0.001 -> -3
+logbx1122 logb 0.01 -> -2
+logbx1123 logb 0.1 -> -1
+logbx1124 logb 1E-99 -> -99
+logbx1125 logb 1E-100 -> -100
+logbx1126 logb 1E-383 -> -383
+logbx1127 logb 1E-999 -> -999
+
+-- suggestions from Ilan Nehama
+logbx1400 logb 10E-3 -> -2
+logbx1401 logb 10E-2 -> -1
+logbx1402 logb 100E-2 -> 0
+logbx1403 logb 1000E-2 -> 1
+logbx1404 logb 10000E-2 -> 2
+logbx1405 logb 10E-1 -> 0
+logbx1406 logb 100E-1 -> 1
+logbx1407 logb 1000E-1 -> 2
+logbx1408 logb 10000E-1 -> 3
+logbx1409 logb 10E0 -> 1
+logbx1410 logb 100E0 -> 2
+logbx1411 logb 1000E0 -> 3
+logbx1412 logb 10000E0 -> 4
+logbx1413 logb 10E1 -> 2
+logbx1414 logb 100E1 -> 3
+logbx1415 logb 1000E1 -> 4
+logbx1416 logb 10000E1 -> 5
+logbx1417 logb 10E2 -> 3
+logbx1418 logb 100E2 -> 4
+logbx1419 logb 1000E2 -> 5
+logbx1420 logb 10000E2 -> 6
+
+-- inexacts
+precision: 2
+logbx1500 logb 10000E2 -> 6
+logbx1501 logb 1E+99 -> 99
+logbx1502 logb 1E-99 -> -99
+logbx1503 logb 1E+100 -> 1.0E+2 Rounded
+logbx1504 logb 1E+999 -> 1.0E+3 Inexact Rounded
+logbx1505 logb 1E-100 -> -1.0E+2 Rounded
+logbx1506 logb 1E-999 -> -1.0E+3 Inexact Rounded
+logbx1507 logb 1E-1111 -> -1.1E+3 Inexact Rounded
+logbx1508 logb 1E-3333 -> -3.3E+3 Inexact Rounded
+logbx1509 logb 1E-6666 -> -6.7E+3 Inexact Rounded
+logbx1510 logb 1E+999999999 -> 1.0E+9 Inexact Rounded
+logbx1511 logb 1E-999999999 -> -1.0E+9 Inexact Rounded
+precision: 1
+logbx1517 logb 1E-1111 -> -1E+3 Inexact Rounded
+logbx1518 logb 1E-3333 -> -3E+3 Inexact Rounded
+logbx1519 logb 1E-6666 -> -7E+3 Inexact Rounded
+precision: 8
+logbx1520 logb 1E+999999999 -> 1.0000000E+9 Inexact Rounded
+logbx1521 logb 1E-999999999 -> -1.0000000E+9 Inexact Rounded
+precision: 9
+logbx1523 logb 1E+999999999 -> 999999999
+logbx1524 logb 1E-999999999 -> -999999999
+
+-- special values
+precision: 9
+logbx820 logb Infinity -> Infinity
+logbx821 logb -Infinity -> Infinity
+logbx822 logb 0 -> -Infinity Division_by_zero
+logbx823 logb NaN -> NaN
+logbx824 logb sNaN -> NaN Invalid_operation
+-- propagating NaNs
+logbx825 logb sNaN123 -> NaN123 Invalid_operation
+logbx826 logb -sNaN321 -> -NaN321 Invalid_operation
+logbx827 logb NaN456 -> NaN456
+logbx828 logb -NaN654 -> -NaN654
+logbx829 logb NaN1 -> NaN1
+
+-- Null test
+logbx900 logb # -> NaN Invalid_operation
+
+
diff --git a/Lib/test/decimaltestdata/maxmag.decTest b/Lib/test/decimaltestdata/maxmag.decTest
index 265e912ed45..6b442130798 100644
--- a/Lib/test/decimaltestdata/maxmag.decTest
+++ b/Lib/test/decimaltestdata/maxmag.decTest
@@ -1,404 +1,404 @@
-------------------------------------------------------------------------
--- maxmag.decTest -- decimal maximum by magnitude --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- sanity checks
-mxgx001 maxmag -2 -2 -> -2
-mxgx002 maxmag -2 -1 -> -2
-mxgx003 maxmag -2 0 -> -2
-mxgx004 maxmag -2 1 -> -2
-mxgx005 maxmag -2 2 -> 2
-mxgx006 maxmag -1 -2 -> -2
-mxgx007 maxmag -1 -1 -> -1
-mxgx008 maxmag -1 0 -> -1
-mxgx009 maxmag -1 1 -> 1
-mxgx010 maxmag -1 2 -> 2
-mxgx011 maxmag 0 -2 -> -2
-mxgx012 maxmag 0 -1 -> -1
-mxgx013 maxmag 0 0 -> 0
-mxgx014 maxmag 0 1 -> 1
-mxgx015 maxmag 0 2 -> 2
-mxgx016 maxmag 1 -2 -> -2
-mxgx017 maxmag 1 -1 -> 1
-mxgx018 maxmag 1 0 -> 1
-mxgx019 maxmag 1 1 -> 1
-mxgx020 maxmag 1 2 -> 2
-mxgx021 maxmag 2 -2 -> 2
-mxgx022 maxmag 2 -1 -> 2
-mxgx023 maxmag 2 0 -> 2
-mxgx025 maxmag 2 1 -> 2
-mxgx026 maxmag 2 2 -> 2
-
--- extended zeros
-mxgx030 maxmag 0 0 -> 0
-mxgx031 maxmag 0 -0 -> 0
-mxgx032 maxmag 0 -0.0 -> 0
-mxgx033 maxmag 0 0.0 -> 0
-mxgx034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
-mxgx035 maxmag -0 -0 -> -0
-mxgx036 maxmag -0 -0.0 -> -0.0
-mxgx037 maxmag -0 0.0 -> 0.0
-mxgx038 maxmag 0.0 0 -> 0
-mxgx039 maxmag 0.0 -0 -> 0.0
-mxgx040 maxmag 0.0 -0.0 -> 0.0
-mxgx041 maxmag 0.0 0.0 -> 0.0
-mxgx042 maxmag -0.0 0 -> 0
-mxgx043 maxmag -0.0 -0 -> -0.0
-mxgx044 maxmag -0.0 -0.0 -> -0.0
-mxgx045 maxmag -0.0 0.0 -> 0.0
-
-mxgx050 maxmag -0E1 0E1 -> 0E+1
-mxgx051 maxmag -0E2 0E2 -> 0E+2
-mxgx052 maxmag -0E2 0E1 -> 0E+1
-mxgx053 maxmag -0E1 0E2 -> 0E+2
-mxgx054 maxmag 0E1 -0E1 -> 0E+1
-mxgx055 maxmag 0E2 -0E2 -> 0E+2
-mxgx056 maxmag 0E2 -0E1 -> 0E+2
-mxgx057 maxmag 0E1 -0E2 -> 0E+1
-
-mxgx058 maxmag 0E1 0E1 -> 0E+1
-mxgx059 maxmag 0E2 0E2 -> 0E+2
-mxgx060 maxmag 0E2 0E1 -> 0E+2
-mxgx061 maxmag 0E1 0E2 -> 0E+2
-mxgx062 maxmag -0E1 -0E1 -> -0E+1
-mxgx063 maxmag -0E2 -0E2 -> -0E+2
-mxgx064 maxmag -0E2 -0E1 -> -0E+1
-mxgx065 maxmag -0E1 -0E2 -> -0E+1
-
--- Specials
-precision: 9
-mxgx090 maxmag Inf -Inf -> Infinity
-mxgx091 maxmag Inf -1000 -> Infinity
-mxgx092 maxmag Inf -1 -> Infinity
-mxgx093 maxmag Inf -0 -> Infinity
-mxgx094 maxmag Inf 0 -> Infinity
-mxgx095 maxmag Inf 1 -> Infinity
-mxgx096 maxmag Inf 1000 -> Infinity
-mxgx097 maxmag Inf Inf -> Infinity
-mxgx098 maxmag -1000 Inf -> Infinity
-mxgx099 maxmag -Inf Inf -> Infinity
-mxgx100 maxmag -1 Inf -> Infinity
-mxgx101 maxmag -0 Inf -> Infinity
-mxgx102 maxmag 0 Inf -> Infinity
-mxgx103 maxmag 1 Inf -> Infinity
-mxgx104 maxmag 1000 Inf -> Infinity
-mxgx105 maxmag Inf Inf -> Infinity
-
-mxgx120 maxmag -Inf -Inf -> -Infinity
-mxgx121 maxmag -Inf -1000 -> -Infinity
-mxgx122 maxmag -Inf -1 -> -Infinity
-mxgx123 maxmag -Inf -0 -> -Infinity
-mxgx124 maxmag -Inf 0 -> -Infinity
-mxgx125 maxmag -Inf 1 -> -Infinity
-mxgx126 maxmag -Inf 1000 -> -Infinity
-mxgx127 maxmag -Inf Inf -> Infinity
-mxgx128 maxmag -Inf -Inf -> -Infinity
-mxgx129 maxmag -1000 -Inf -> -Infinity
-mxgx130 maxmag -1 -Inf -> -Infinity
-mxgx131 maxmag -0 -Inf -> -Infinity
-mxgx132 maxmag 0 -Inf -> -Infinity
-mxgx133 maxmag 1 -Inf -> -Infinity
-mxgx134 maxmag 1000 -Inf -> -Infinity
-mxgx135 maxmag Inf -Inf -> Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-mxgx141 maxmag NaN -Inf -> -Infinity
-mxgx142 maxmag NaN -1000 -> -1000
-mxgx143 maxmag NaN -1 -> -1
-mxgx144 maxmag NaN -0 -> -0
-mxgx145 maxmag NaN 0 -> 0
-mxgx146 maxmag NaN 1 -> 1
-mxgx147 maxmag NaN 1000 -> 1000
-mxgx148 maxmag NaN Inf -> Infinity
-mxgx149 maxmag NaN NaN -> NaN
-mxgx150 maxmag -Inf NaN -> -Infinity
-mxgx151 maxmag -1000 NaN -> -1000
-mxgx152 maxmag -1 NaN -> -1
-mxgx153 maxmag -0 NaN -> -0
-mxgx154 maxmag 0 NaN -> 0
-mxgx155 maxmag 1 NaN -> 1
-mxgx156 maxmag 1000 NaN -> 1000
-mxgx157 maxmag Inf NaN -> Infinity
-
-mxgx161 maxmag sNaN -Inf -> NaN Invalid_operation
-mxgx162 maxmag sNaN -1000 -> NaN Invalid_operation
-mxgx163 maxmag sNaN -1 -> NaN Invalid_operation
-mxgx164 maxmag sNaN -0 -> NaN Invalid_operation
-mxgx165 maxmag sNaN 0 -> NaN Invalid_operation
-mxgx166 maxmag sNaN 1 -> NaN Invalid_operation
-mxgx167 maxmag sNaN 1000 -> NaN Invalid_operation
-mxgx168 maxmag sNaN NaN -> NaN Invalid_operation
-mxgx169 maxmag sNaN sNaN -> NaN Invalid_operation
-mxgx170 maxmag NaN sNaN -> NaN Invalid_operation
-mxgx171 maxmag -Inf sNaN -> NaN Invalid_operation
-mxgx172 maxmag -1000 sNaN -> NaN Invalid_operation
-mxgx173 maxmag -1 sNaN -> NaN Invalid_operation
-mxgx174 maxmag -0 sNaN -> NaN Invalid_operation
-mxgx175 maxmag 0 sNaN -> NaN Invalid_operation
-mxgx176 maxmag 1 sNaN -> NaN Invalid_operation
-mxgx177 maxmag 1000 sNaN -> NaN Invalid_operation
-mxgx178 maxmag Inf sNaN -> NaN Invalid_operation
-mxgx179 maxmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-mxgx181 maxmag NaN9 -Inf -> -Infinity
-mxgx182 maxmag NaN8 9 -> 9
-mxgx183 maxmag -NaN7 Inf -> Infinity
-
-mxgx184 maxmag -NaN1 NaN11 -> -NaN1
-mxgx185 maxmag NaN2 NaN12 -> NaN2
-mxgx186 maxmag -NaN13 -NaN7 -> -NaN13
-mxgx187 maxmag NaN14 -NaN5 -> NaN14
-
-mxgx188 maxmag -Inf NaN4 -> -Infinity
-mxgx189 maxmag -9 -NaN3 -> -9
-mxgx190 maxmag Inf NaN2 -> Infinity
-
-mxgx191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
-mxgx192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
-mxgx193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
-mxgx194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
-mxgx195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
-mxgx196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
-mxgx197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
-mxgx198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
-mxgx199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
-
--- rounding checks
-maxexponent: 999
-minexponent: -999
-precision: 9
-mxgx201 maxmag 12345678000 1 -> 1.23456780E+10 Rounded
-mxgx202 maxmag 1 12345678000 -> 1.23456780E+10 Rounded
-mxgx203 maxmag 1234567800 1 -> 1.23456780E+9 Rounded
-mxgx204 maxmag 1 1234567800 -> 1.23456780E+9 Rounded
-mxgx205 maxmag 1234567890 1 -> 1.23456789E+9 Rounded
-mxgx206 maxmag 1 1234567890 -> 1.23456789E+9 Rounded
-mxgx207 maxmag 1234567891 1 -> 1.23456789E+9 Inexact Rounded
-mxgx208 maxmag 1 1234567891 -> 1.23456789E+9 Inexact Rounded
-mxgx209 maxmag 12345678901 1 -> 1.23456789E+10 Inexact Rounded
-mxgx210 maxmag 1 12345678901 -> 1.23456789E+10 Inexact Rounded
-mxgx211 maxmag 1234567896 1 -> 1.23456790E+9 Inexact Rounded
-mxgx212 maxmag 1 1234567896 -> 1.23456790E+9 Inexact Rounded
-mxgx213 maxmag -1234567891 1 -> -1.23456789E+9 Inexact Rounded
-mxgx214 maxmag 1 -1234567891 -> -1.23456789E+9 Inexact Rounded
-mxgx215 maxmag -12345678901 1 -> -1.23456789E+10 Inexact Rounded
-mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10 Inexact Rounded
-mxgx217 maxmag -1234567896 1 -> -1.23456790E+9 Inexact Rounded
-mxgx218 maxmag 1 -1234567896 -> -1.23456790E+9 Inexact Rounded
-
-precision: 15
-mxgx221 maxmag 12345678000 1 -> 12345678000
-mxgx222 maxmag 1 12345678000 -> 12345678000
-mxgx223 maxmag 1234567800 1 -> 1234567800
-mxgx224 maxmag 1 1234567800 -> 1234567800
-mxgx225 maxmag 1234567890 1 -> 1234567890
-mxgx226 maxmag 1 1234567890 -> 1234567890
-mxgx227 maxmag 1234567891 1 -> 1234567891
-mxgx228 maxmag 1 1234567891 -> 1234567891
-mxgx229 maxmag 12345678901 1 -> 12345678901
-mxgx230 maxmag 1 12345678901 -> 12345678901
-mxgx231 maxmag 1234567896 1 -> 1234567896
-mxgx232 maxmag 1 1234567896 -> 1234567896
-mxgx233 maxmag -1234567891 1 -> -1234567891
-mxgx234 maxmag 1 -1234567891 -> -1234567891
-mxgx235 maxmag -12345678901 1 -> -12345678901
-mxgx236 maxmag 1 -12345678901 -> -12345678901
-mxgx237 maxmag -1234567896 1 -> -1234567896
-mxgx238 maxmag 1 -1234567896 -> -1234567896
-
--- from examples
-mxgx280 maxmag '3' '2' -> '3'
-mxgx281 maxmag '-10' '3' -> '-10'
-mxgx282 maxmag '1.0' '1' -> '1'
-mxgx283 maxmag '1' '1.0' -> '1'
-mxgx284 maxmag '7' 'NaN' -> '7'
-
--- overflow and underflow tests ...
-maxExponent: 999999999
-minexponent: -999999999
-mxgx330 maxmag +1.23456789012345E-0 9E+999999999 -> 9E+999999999
-mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 -> 9E+999999999
-mxgx332 maxmag +0.100 9E-999999999 -> 0.100
-mxgx333 maxmag 9E-999999999 +0.100 -> 0.100
-mxgx335 maxmag -1.23456789012345E-0 9E+999999999 -> 9E+999999999
-mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 -> 9E+999999999
-mxgx337 maxmag -0.100 9E-999999999 -> -0.100
-mxgx338 maxmag 9E-999999999 -0.100 -> -0.100
-
-mxgx339 maxmag 1e-599999999 1e-400000001 -> 1E-400000001
-mxgx340 maxmag 1e-599999999 1e-400000000 -> 1E-400000000
-mxgx341 maxmag 1e-600000000 1e-400000000 -> 1E-400000000
-mxgx342 maxmag 9e-999999998 0.01 -> 0.01
-mxgx343 maxmag 9e-999999998 0.1 -> 0.1
-mxgx344 maxmag 0.01 9e-999999998 -> 0.01
-mxgx345 maxmag 1e599999999 1e400000001 -> 1E+599999999
-mxgx346 maxmag 1e599999999 1e400000000 -> 1E+599999999
-mxgx347 maxmag 1e600000000 1e400000000 -> 1E+600000000
-mxgx348 maxmag 9e999999998 100 -> 9E+999999998
-mxgx349 maxmag 9e999999998 10 -> 9E+999999998
-mxgx350 maxmag 100 9e999999998 -> 9E+999999998
--- signs
-mxgx351 maxmag 1e+777777777 1e+411111111 -> 1E+777777777
-mxgx352 maxmag 1e+777777777 -1e+411111111 -> 1E+777777777
-mxgx353 maxmag -1e+777777777 1e+411111111 -> -1E+777777777
-mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777
-mxgx355 maxmag 1e-777777777 1e-411111111 -> 1E-411111111
-mxgx356 maxmag 1e-777777777 -1e-411111111 -> -1E-411111111
-mxgx357 maxmag -1e-777777777 1e-411111111 -> 1E-411111111
-mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-mxgx401 maxmag Inf 1.1 -> Infinity
-mxgx402 maxmag 1.1 1 -> 1.1
-mxgx403 maxmag 1 1.0 -> 1
-mxgx404 maxmag 1.0 0.1 -> 1.0
-mxgx405 maxmag 0.1 0.10 -> 0.1
-mxgx406 maxmag 0.10 0.100 -> 0.10
-mxgx407 maxmag 0.10 0 -> 0.10
-mxgx408 maxmag 0 0.0 -> 0
-mxgx409 maxmag 0.0 -0 -> 0.0
-mxgx410 maxmag 0.0 -0.0 -> 0.0
-mxgx411 maxmag 0.00 -0.0 -> 0.00
-mxgx412 maxmag 0.0 -0.00 -> 0.0
-mxgx413 maxmag 0 -0.0 -> 0
-mxgx414 maxmag 0 -0 -> 0
-mxgx415 maxmag -0.0 -0 -> -0.0
-mxgx416 maxmag -0 -0.100 -> -0.100
-mxgx417 maxmag -0.100 -0.10 -> -0.100
-mxgx418 maxmag -0.10 -0.1 -> -0.10
-mxgx419 maxmag -0.1 -1.0 -> -1.0
-mxgx420 maxmag -1.0 -1 -> -1.0
-mxgx421 maxmag -1 -1.1 -> -1.1
-mxgx423 maxmag -1.1 -Inf -> -Infinity
--- same with operands reversed
-mxgx431 maxmag 1.1 Inf -> Infinity
-mxgx432 maxmag 1 1.1 -> 1.1
-mxgx433 maxmag 1.0 1 -> 1
-mxgx434 maxmag 0.1 1.0 -> 1.0
-mxgx435 maxmag 0.10 0.1 -> 0.1
-mxgx436 maxmag 0.100 0.10 -> 0.10
-mxgx437 maxmag 0 0.10 -> 0.10
-mxgx438 maxmag 0.0 0 -> 0
-mxgx439 maxmag -0 0.0 -> 0.0
-mxgx440 maxmag -0.0 0.0 -> 0.0
-mxgx441 maxmag -0.0 0.00 -> 0.00
-mxgx442 maxmag -0.00 0.0 -> 0.0
-mxgx443 maxmag -0.0 0 -> 0
-mxgx444 maxmag -0 0 -> 0
-mxgx445 maxmag -0 -0.0 -> -0.0
-mxgx446 maxmag -0.100 -0 -> -0.100
-mxgx447 maxmag -0.10 -0.100 -> -0.100
-mxgx448 maxmag -0.1 -0.10 -> -0.10
-mxgx449 maxmag -1.0 -0.1 -> -1.0
-mxgx450 maxmag -1 -1.0 -> -1.0
-mxgx451 maxmag -1.1 -1 -> -1.1
-mxgx453 maxmag -Inf -1.1 -> -Infinity
--- largies
-mxgx460 maxmag 1000 1E+3 -> 1E+3
-mxgx461 maxmag 1E+3 1000 -> 1E+3
-mxgx462 maxmag 1000 -1E+3 -> 1000
-mxgx463 maxmag 1E+3 -1000 -> 1E+3
-mxgx464 maxmag -1000 1E+3 -> 1E+3
-mxgx465 maxmag -1E+3 1000 -> 1000
-mxgx466 maxmag -1000 -1E+3 -> -1000
-mxgx467 maxmag -1E+3 -1000 -> -1000
-
--- rounding (results treated as though plus)
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-
-mxgx470 maxmag 1 .5 -> 1
-mxgx471 maxmag 10 5 -> 10
-mxgx472 maxmag 100 50 -> 100
-mxgx473 maxmag 1000 500 -> 1.00E+3 Rounded
-mxgx474 maxmag 10000 5000 -> 1.00E+4 Rounded
-mxgx475 maxmag 6 .5 -> 6
-mxgx476 maxmag 66 5 -> 66
-mxgx477 maxmag 666 50 -> 666
-mxgx478 maxmag 6666 500 -> 6.67E+3 Rounded Inexact
-mxgx479 maxmag 66666 5000 -> 6.67E+4 Rounded Inexact
-mxgx480 maxmag 33333 5000 -> 3.33E+4 Rounded Inexact
-mxgx481 maxmag .5 1 -> 1
-mxgx482 maxmag .5 10 -> 10
-mxgx483 maxmag .5 100 -> 100
-mxgx484 maxmag .5 1000 -> 1.00E+3 Rounded
-mxgx485 maxmag .5 10000 -> 1.00E+4 Rounded
-mxgx486 maxmag .5 6 -> 6
-mxgx487 maxmag .5 66 -> 66
-mxgx488 maxmag .5 666 -> 666
-mxgx489 maxmag .5 6666 -> 6.67E+3 Rounded Inexact
-mxgx490 maxmag .5 66666 -> 6.67E+4 Rounded Inexact
-mxgx491 maxmag .5 33333 -> 3.33E+4 Rounded Inexact
-
--- overflow tests
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-mxgx500 maxmag 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded
-mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded
-
--- subnormals and underflow
-precision: 3
-maxexponent: 999
-minexponent: -999
-mxgx510 maxmag 1.00E-999 0 -> 1.00E-999
-mxgx511 maxmag 0.1E-999 0 -> 1E-1000 Subnormal
-mxgx512 maxmag 0.10E-999 0 -> 1.0E-1000 Subnormal
-mxgx513 maxmag 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
-mxgx514 maxmag 0.01E-999 0 -> 1E-1001 Subnormal
--- next is rounded to Nmin
-mxgx515 maxmag 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
-mxgx516 maxmag 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
-mxgx517 maxmag 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
-mxgx518 maxmag 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx519 maxmag 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx520 maxmag 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
-mxgx530 maxmag -1.00E-999 0 -> -1.00E-999
-mxgx531 maxmag -0.1E-999 0 -> -1E-1000 Subnormal
-mxgx532 maxmag -0.10E-999 0 -> -1.0E-1000 Subnormal
-mxgx533 maxmag -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
-mxgx534 maxmag -0.01E-999 0 -> -1E-1001 Subnormal
--- next is rounded to -Nmin
-mxgx535 maxmag -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
-mxgx536 maxmag -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
-mxgx537 maxmag -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
-mxgx538 maxmag -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx539 maxmag -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-mxgx540 maxmag -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
-
--- Null tests
-mxgx900 maxmag 10 # -> NaN Invalid_operation
-mxgx901 maxmag # 10 -> NaN Invalid_operation
-
-
-
+------------------------------------------------------------------------
+-- maxmag.decTest -- decimal maximum by magnitude --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- sanity checks
+mxgx001 maxmag -2 -2 -> -2
+mxgx002 maxmag -2 -1 -> -2
+mxgx003 maxmag -2 0 -> -2
+mxgx004 maxmag -2 1 -> -2
+mxgx005 maxmag -2 2 -> 2
+mxgx006 maxmag -1 -2 -> -2
+mxgx007 maxmag -1 -1 -> -1
+mxgx008 maxmag -1 0 -> -1
+mxgx009 maxmag -1 1 -> 1
+mxgx010 maxmag -1 2 -> 2
+mxgx011 maxmag 0 -2 -> -2
+mxgx012 maxmag 0 -1 -> -1
+mxgx013 maxmag 0 0 -> 0
+mxgx014 maxmag 0 1 -> 1
+mxgx015 maxmag 0 2 -> 2
+mxgx016 maxmag 1 -2 -> -2
+mxgx017 maxmag 1 -1 -> 1
+mxgx018 maxmag 1 0 -> 1
+mxgx019 maxmag 1 1 -> 1
+mxgx020 maxmag 1 2 -> 2
+mxgx021 maxmag 2 -2 -> 2
+mxgx022 maxmag 2 -1 -> 2
+mxgx023 maxmag 2 0 -> 2
+mxgx025 maxmag 2 1 -> 2
+mxgx026 maxmag 2 2 -> 2
+
+-- extended zeros
+mxgx030 maxmag 0 0 -> 0
+mxgx031 maxmag 0 -0 -> 0
+mxgx032 maxmag 0 -0.0 -> 0
+mxgx033 maxmag 0 0.0 -> 0
+mxgx034 maxmag -0 0 -> 0 -- note: -0 = 0, but 0 chosen
+mxgx035 maxmag -0 -0 -> -0
+mxgx036 maxmag -0 -0.0 -> -0.0
+mxgx037 maxmag -0 0.0 -> 0.0
+mxgx038 maxmag 0.0 0 -> 0
+mxgx039 maxmag 0.0 -0 -> 0.0
+mxgx040 maxmag 0.0 -0.0 -> 0.0
+mxgx041 maxmag 0.0 0.0 -> 0.0
+mxgx042 maxmag -0.0 0 -> 0
+mxgx043 maxmag -0.0 -0 -> -0.0
+mxgx044 maxmag -0.0 -0.0 -> -0.0
+mxgx045 maxmag -0.0 0.0 -> 0.0
+
+mxgx050 maxmag -0E1 0E1 -> 0E+1
+mxgx051 maxmag -0E2 0E2 -> 0E+2
+mxgx052 maxmag -0E2 0E1 -> 0E+1
+mxgx053 maxmag -0E1 0E2 -> 0E+2
+mxgx054 maxmag 0E1 -0E1 -> 0E+1
+mxgx055 maxmag 0E2 -0E2 -> 0E+2
+mxgx056 maxmag 0E2 -0E1 -> 0E+2
+mxgx057 maxmag 0E1 -0E2 -> 0E+1
+
+mxgx058 maxmag 0E1 0E1 -> 0E+1
+mxgx059 maxmag 0E2 0E2 -> 0E+2
+mxgx060 maxmag 0E2 0E1 -> 0E+2
+mxgx061 maxmag 0E1 0E2 -> 0E+2
+mxgx062 maxmag -0E1 -0E1 -> -0E+1
+mxgx063 maxmag -0E2 -0E2 -> -0E+2
+mxgx064 maxmag -0E2 -0E1 -> -0E+1
+mxgx065 maxmag -0E1 -0E2 -> -0E+1
+
+-- Specials
+precision: 9
+mxgx090 maxmag Inf -Inf -> Infinity
+mxgx091 maxmag Inf -1000 -> Infinity
+mxgx092 maxmag Inf -1 -> Infinity
+mxgx093 maxmag Inf -0 -> Infinity
+mxgx094 maxmag Inf 0 -> Infinity
+mxgx095 maxmag Inf 1 -> Infinity
+mxgx096 maxmag Inf 1000 -> Infinity
+mxgx097 maxmag Inf Inf -> Infinity
+mxgx098 maxmag -1000 Inf -> Infinity
+mxgx099 maxmag -Inf Inf -> Infinity
+mxgx100 maxmag -1 Inf -> Infinity
+mxgx101 maxmag -0 Inf -> Infinity
+mxgx102 maxmag 0 Inf -> Infinity
+mxgx103 maxmag 1 Inf -> Infinity
+mxgx104 maxmag 1000 Inf -> Infinity
+mxgx105 maxmag Inf Inf -> Infinity
+
+mxgx120 maxmag -Inf -Inf -> -Infinity
+mxgx121 maxmag -Inf -1000 -> -Infinity
+mxgx122 maxmag -Inf -1 -> -Infinity
+mxgx123 maxmag -Inf -0 -> -Infinity
+mxgx124 maxmag -Inf 0 -> -Infinity
+mxgx125 maxmag -Inf 1 -> -Infinity
+mxgx126 maxmag -Inf 1000 -> -Infinity
+mxgx127 maxmag -Inf Inf -> Infinity
+mxgx128 maxmag -Inf -Inf -> -Infinity
+mxgx129 maxmag -1000 -Inf -> -Infinity
+mxgx130 maxmag -1 -Inf -> -Infinity
+mxgx131 maxmag -0 -Inf -> -Infinity
+mxgx132 maxmag 0 -Inf -> -Infinity
+mxgx133 maxmag 1 -Inf -> -Infinity
+mxgx134 maxmag 1000 -Inf -> -Infinity
+mxgx135 maxmag Inf -Inf -> Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+mxgx141 maxmag NaN -Inf -> -Infinity
+mxgx142 maxmag NaN -1000 -> -1000
+mxgx143 maxmag NaN -1 -> -1
+mxgx144 maxmag NaN -0 -> -0
+mxgx145 maxmag NaN 0 -> 0
+mxgx146 maxmag NaN 1 -> 1
+mxgx147 maxmag NaN 1000 -> 1000
+mxgx148 maxmag NaN Inf -> Infinity
+mxgx149 maxmag NaN NaN -> NaN
+mxgx150 maxmag -Inf NaN -> -Infinity
+mxgx151 maxmag -1000 NaN -> -1000
+mxgx152 maxmag -1 NaN -> -1
+mxgx153 maxmag -0 NaN -> -0
+mxgx154 maxmag 0 NaN -> 0
+mxgx155 maxmag 1 NaN -> 1
+mxgx156 maxmag 1000 NaN -> 1000
+mxgx157 maxmag Inf NaN -> Infinity
+
+mxgx161 maxmag sNaN -Inf -> NaN Invalid_operation
+mxgx162 maxmag sNaN -1000 -> NaN Invalid_operation
+mxgx163 maxmag sNaN -1 -> NaN Invalid_operation
+mxgx164 maxmag sNaN -0 -> NaN Invalid_operation
+mxgx165 maxmag sNaN 0 -> NaN Invalid_operation
+mxgx166 maxmag sNaN 1 -> NaN Invalid_operation
+mxgx167 maxmag sNaN 1000 -> NaN Invalid_operation
+mxgx168 maxmag sNaN NaN -> NaN Invalid_operation
+mxgx169 maxmag sNaN sNaN -> NaN Invalid_operation
+mxgx170 maxmag NaN sNaN -> NaN Invalid_operation
+mxgx171 maxmag -Inf sNaN -> NaN Invalid_operation
+mxgx172 maxmag -1000 sNaN -> NaN Invalid_operation
+mxgx173 maxmag -1 sNaN -> NaN Invalid_operation
+mxgx174 maxmag -0 sNaN -> NaN Invalid_operation
+mxgx175 maxmag 0 sNaN -> NaN Invalid_operation
+mxgx176 maxmag 1 sNaN -> NaN Invalid_operation
+mxgx177 maxmag 1000 sNaN -> NaN Invalid_operation
+mxgx178 maxmag Inf sNaN -> NaN Invalid_operation
+mxgx179 maxmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+mxgx181 maxmag NaN9 -Inf -> -Infinity
+mxgx182 maxmag NaN8 9 -> 9
+mxgx183 maxmag -NaN7 Inf -> Infinity
+
+mxgx184 maxmag -NaN1 NaN11 -> -NaN1
+mxgx185 maxmag NaN2 NaN12 -> NaN2
+mxgx186 maxmag -NaN13 -NaN7 -> -NaN13
+mxgx187 maxmag NaN14 -NaN5 -> NaN14
+
+mxgx188 maxmag -Inf NaN4 -> -Infinity
+mxgx189 maxmag -9 -NaN3 -> -9
+mxgx190 maxmag Inf NaN2 -> Infinity
+
+mxgx191 maxmag sNaN99 -Inf -> NaN99 Invalid_operation
+mxgx192 maxmag sNaN98 -1 -> NaN98 Invalid_operation
+mxgx193 maxmag -sNaN97 NaN -> -NaN97 Invalid_operation
+mxgx194 maxmag sNaN96 sNaN94 -> NaN96 Invalid_operation
+mxgx195 maxmag NaN95 sNaN93 -> NaN93 Invalid_operation
+mxgx196 maxmag -Inf sNaN92 -> NaN92 Invalid_operation
+mxgx197 maxmag 0 sNaN91 -> NaN91 Invalid_operation
+mxgx198 maxmag Inf -sNaN90 -> -NaN90 Invalid_operation
+mxgx199 maxmag NaN sNaN89 -> NaN89 Invalid_operation
+
+-- rounding checks
+maxexponent: 999
+minexponent: -999
+precision: 9
+mxgx201 maxmag 12345678000 1 -> 1.23456780E+10 Rounded
+mxgx202 maxmag 1 12345678000 -> 1.23456780E+10 Rounded
+mxgx203 maxmag 1234567800 1 -> 1.23456780E+9 Rounded
+mxgx204 maxmag 1 1234567800 -> 1.23456780E+9 Rounded
+mxgx205 maxmag 1234567890 1 -> 1.23456789E+9 Rounded
+mxgx206 maxmag 1 1234567890 -> 1.23456789E+9 Rounded
+mxgx207 maxmag 1234567891 1 -> 1.23456789E+9 Inexact Rounded
+mxgx208 maxmag 1 1234567891 -> 1.23456789E+9 Inexact Rounded
+mxgx209 maxmag 12345678901 1 -> 1.23456789E+10 Inexact Rounded
+mxgx210 maxmag 1 12345678901 -> 1.23456789E+10 Inexact Rounded
+mxgx211 maxmag 1234567896 1 -> 1.23456790E+9 Inexact Rounded
+mxgx212 maxmag 1 1234567896 -> 1.23456790E+9 Inexact Rounded
+mxgx213 maxmag -1234567891 1 -> -1.23456789E+9 Inexact Rounded
+mxgx214 maxmag 1 -1234567891 -> -1.23456789E+9 Inexact Rounded
+mxgx215 maxmag -12345678901 1 -> -1.23456789E+10 Inexact Rounded
+mxgx216 maxmag 1 -12345678901 -> -1.23456789E+10 Inexact Rounded
+mxgx217 maxmag -1234567896 1 -> -1.23456790E+9 Inexact Rounded
+mxgx218 maxmag 1 -1234567896 -> -1.23456790E+9 Inexact Rounded
+
+precision: 15
+mxgx221 maxmag 12345678000 1 -> 12345678000
+mxgx222 maxmag 1 12345678000 -> 12345678000
+mxgx223 maxmag 1234567800 1 -> 1234567800
+mxgx224 maxmag 1 1234567800 -> 1234567800
+mxgx225 maxmag 1234567890 1 -> 1234567890
+mxgx226 maxmag 1 1234567890 -> 1234567890
+mxgx227 maxmag 1234567891 1 -> 1234567891
+mxgx228 maxmag 1 1234567891 -> 1234567891
+mxgx229 maxmag 12345678901 1 -> 12345678901
+mxgx230 maxmag 1 12345678901 -> 12345678901
+mxgx231 maxmag 1234567896 1 -> 1234567896
+mxgx232 maxmag 1 1234567896 -> 1234567896
+mxgx233 maxmag -1234567891 1 -> -1234567891
+mxgx234 maxmag 1 -1234567891 -> -1234567891
+mxgx235 maxmag -12345678901 1 -> -12345678901
+mxgx236 maxmag 1 -12345678901 -> -12345678901
+mxgx237 maxmag -1234567896 1 -> -1234567896
+mxgx238 maxmag 1 -1234567896 -> -1234567896
+
+-- from examples
+mxgx280 maxmag '3' '2' -> '3'
+mxgx281 maxmag '-10' '3' -> '-10'
+mxgx282 maxmag '1.0' '1' -> '1'
+mxgx283 maxmag '1' '1.0' -> '1'
+mxgx284 maxmag '7' 'NaN' -> '7'
+
+-- overflow and underflow tests ...
+maxExponent: 999999999
+minexponent: -999999999
+mxgx330 maxmag +1.23456789012345E-0 9E+999999999 -> 9E+999999999
+mxgx331 maxmag 9E+999999999 +1.23456789012345E-0 -> 9E+999999999
+mxgx332 maxmag +0.100 9E-999999999 -> 0.100
+mxgx333 maxmag 9E-999999999 +0.100 -> 0.100
+mxgx335 maxmag -1.23456789012345E-0 9E+999999999 -> 9E+999999999
+mxgx336 maxmag 9E+999999999 -1.23456789012345E-0 -> 9E+999999999
+mxgx337 maxmag -0.100 9E-999999999 -> -0.100
+mxgx338 maxmag 9E-999999999 -0.100 -> -0.100
+
+mxgx339 maxmag 1e-599999999 1e-400000001 -> 1E-400000001
+mxgx340 maxmag 1e-599999999 1e-400000000 -> 1E-400000000
+mxgx341 maxmag 1e-600000000 1e-400000000 -> 1E-400000000
+mxgx342 maxmag 9e-999999998 0.01 -> 0.01
+mxgx343 maxmag 9e-999999998 0.1 -> 0.1
+mxgx344 maxmag 0.01 9e-999999998 -> 0.01
+mxgx345 maxmag 1e599999999 1e400000001 -> 1E+599999999
+mxgx346 maxmag 1e599999999 1e400000000 -> 1E+599999999
+mxgx347 maxmag 1e600000000 1e400000000 -> 1E+600000000
+mxgx348 maxmag 9e999999998 100 -> 9E+999999998
+mxgx349 maxmag 9e999999998 10 -> 9E+999999998
+mxgx350 maxmag 100 9e999999998 -> 9E+999999998
+-- signs
+mxgx351 maxmag 1e+777777777 1e+411111111 -> 1E+777777777
+mxgx352 maxmag 1e+777777777 -1e+411111111 -> 1E+777777777
+mxgx353 maxmag -1e+777777777 1e+411111111 -> -1E+777777777
+mxgx354 maxmag -1e+777777777 -1e+411111111 -> -1E+777777777
+mxgx355 maxmag 1e-777777777 1e-411111111 -> 1E-411111111
+mxgx356 maxmag 1e-777777777 -1e-411111111 -> -1E-411111111
+mxgx357 maxmag -1e-777777777 1e-411111111 -> 1E-411111111
+mxgx358 maxmag -1e-777777777 -1e-411111111 -> -1E-411111111
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+mxgx401 maxmag Inf 1.1 -> Infinity
+mxgx402 maxmag 1.1 1 -> 1.1
+mxgx403 maxmag 1 1.0 -> 1
+mxgx404 maxmag 1.0 0.1 -> 1.0
+mxgx405 maxmag 0.1 0.10 -> 0.1
+mxgx406 maxmag 0.10 0.100 -> 0.10
+mxgx407 maxmag 0.10 0 -> 0.10
+mxgx408 maxmag 0 0.0 -> 0
+mxgx409 maxmag 0.0 -0 -> 0.0
+mxgx410 maxmag 0.0 -0.0 -> 0.0
+mxgx411 maxmag 0.00 -0.0 -> 0.00
+mxgx412 maxmag 0.0 -0.00 -> 0.0
+mxgx413 maxmag 0 -0.0 -> 0
+mxgx414 maxmag 0 -0 -> 0
+mxgx415 maxmag -0.0 -0 -> -0.0
+mxgx416 maxmag -0 -0.100 -> -0.100
+mxgx417 maxmag -0.100 -0.10 -> -0.100
+mxgx418 maxmag -0.10 -0.1 -> -0.10
+mxgx419 maxmag -0.1 -1.0 -> -1.0
+mxgx420 maxmag -1.0 -1 -> -1.0
+mxgx421 maxmag -1 -1.1 -> -1.1
+mxgx423 maxmag -1.1 -Inf -> -Infinity
+-- same with operands reversed
+mxgx431 maxmag 1.1 Inf -> Infinity
+mxgx432 maxmag 1 1.1 -> 1.1
+mxgx433 maxmag 1.0 1 -> 1
+mxgx434 maxmag 0.1 1.0 -> 1.0
+mxgx435 maxmag 0.10 0.1 -> 0.1
+mxgx436 maxmag 0.100 0.10 -> 0.10
+mxgx437 maxmag 0 0.10 -> 0.10
+mxgx438 maxmag 0.0 0 -> 0
+mxgx439 maxmag -0 0.0 -> 0.0
+mxgx440 maxmag -0.0 0.0 -> 0.0
+mxgx441 maxmag -0.0 0.00 -> 0.00
+mxgx442 maxmag -0.00 0.0 -> 0.0
+mxgx443 maxmag -0.0 0 -> 0
+mxgx444 maxmag -0 0 -> 0
+mxgx445 maxmag -0 -0.0 -> -0.0
+mxgx446 maxmag -0.100 -0 -> -0.100
+mxgx447 maxmag -0.10 -0.100 -> -0.100
+mxgx448 maxmag -0.1 -0.10 -> -0.10
+mxgx449 maxmag -1.0 -0.1 -> -1.0
+mxgx450 maxmag -1 -1.0 -> -1.0
+mxgx451 maxmag -1.1 -1 -> -1.1
+mxgx453 maxmag -Inf -1.1 -> -Infinity
+-- largies
+mxgx460 maxmag 1000 1E+3 -> 1E+3
+mxgx461 maxmag 1E+3 1000 -> 1E+3
+mxgx462 maxmag 1000 -1E+3 -> 1000
+mxgx463 maxmag 1E+3 -1000 -> 1E+3
+mxgx464 maxmag -1000 1E+3 -> 1E+3
+mxgx465 maxmag -1E+3 1000 -> 1000
+mxgx466 maxmag -1000 -1E+3 -> -1000
+mxgx467 maxmag -1E+3 -1000 -> -1000
+
+-- rounding (results treated as though plus)
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+
+mxgx470 maxmag 1 .5 -> 1
+mxgx471 maxmag 10 5 -> 10
+mxgx472 maxmag 100 50 -> 100
+mxgx473 maxmag 1000 500 -> 1.00E+3 Rounded
+mxgx474 maxmag 10000 5000 -> 1.00E+4 Rounded
+mxgx475 maxmag 6 .5 -> 6
+mxgx476 maxmag 66 5 -> 66
+mxgx477 maxmag 666 50 -> 666
+mxgx478 maxmag 6666 500 -> 6.67E+3 Rounded Inexact
+mxgx479 maxmag 66666 5000 -> 6.67E+4 Rounded Inexact
+mxgx480 maxmag 33333 5000 -> 3.33E+4 Rounded Inexact
+mxgx481 maxmag .5 1 -> 1
+mxgx482 maxmag .5 10 -> 10
+mxgx483 maxmag .5 100 -> 100
+mxgx484 maxmag .5 1000 -> 1.00E+3 Rounded
+mxgx485 maxmag .5 10000 -> 1.00E+4 Rounded
+mxgx486 maxmag .5 6 -> 6
+mxgx487 maxmag .5 66 -> 66
+mxgx488 maxmag .5 666 -> 666
+mxgx489 maxmag .5 6666 -> 6.67E+3 Rounded Inexact
+mxgx490 maxmag .5 66666 -> 6.67E+4 Rounded Inexact
+mxgx491 maxmag .5 33333 -> 3.33E+4 Rounded Inexact
+
+-- overflow tests
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+mxgx500 maxmag 9.999E+999999999 0 -> Infinity Inexact Overflow Rounded
+mxgx501 maxmag -9.999E+999999999 0 -> -Infinity Inexact Overflow Rounded
+
+-- subnormals and underflow
+precision: 3
+maxexponent: 999
+minexponent: -999
+mxgx510 maxmag 1.00E-999 0 -> 1.00E-999
+mxgx511 maxmag 0.1E-999 0 -> 1E-1000 Subnormal
+mxgx512 maxmag 0.10E-999 0 -> 1.0E-1000 Subnormal
+mxgx513 maxmag 0.100E-999 0 -> 1.0E-1000 Subnormal Rounded
+mxgx514 maxmag 0.01E-999 0 -> 1E-1001 Subnormal
+-- next is rounded to Nmin
+mxgx515 maxmag 0.999E-999 0 -> 1.00E-999 Inexact Rounded Subnormal Underflow
+mxgx516 maxmag 0.099E-999 0 -> 1.0E-1000 Inexact Rounded Subnormal Underflow
+mxgx517 maxmag 0.009E-999 0 -> 1E-1001 Inexact Rounded Subnormal Underflow
+mxgx518 maxmag 0.001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx519 maxmag 0.0009E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx520 maxmag 0.0001E-999 0 -> 0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+mxgx530 maxmag -1.00E-999 0 -> -1.00E-999
+mxgx531 maxmag -0.1E-999 0 -> -1E-1000 Subnormal
+mxgx532 maxmag -0.10E-999 0 -> -1.0E-1000 Subnormal
+mxgx533 maxmag -0.100E-999 0 -> -1.0E-1000 Subnormal Rounded
+mxgx534 maxmag -0.01E-999 0 -> -1E-1001 Subnormal
+-- next is rounded to -Nmin
+mxgx535 maxmag -0.999E-999 0 -> -1.00E-999 Inexact Rounded Subnormal Underflow
+mxgx536 maxmag -0.099E-999 0 -> -1.0E-1000 Inexact Rounded Subnormal Underflow
+mxgx537 maxmag -0.009E-999 0 -> -1E-1001 Inexact Rounded Subnormal Underflow
+mxgx538 maxmag -0.001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx539 maxmag -0.0009E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+mxgx540 maxmag -0.0001E-999 0 -> -0E-1001 Inexact Rounded Subnormal Underflow Clamped
+
+-- Null tests
+mxgx900 maxmag 10 # -> NaN Invalid_operation
+mxgx901 maxmag # 10 -> NaN Invalid_operation
+
+
+
diff --git a/Lib/test/decimaltestdata/minmag.decTest b/Lib/test/decimaltestdata/minmag.decTest
index f1ac3852e83..9e562339eb6 100644
--- a/Lib/test/decimaltestdata/minmag.decTest
+++ b/Lib/test/decimaltestdata/minmag.decTest
@@ -1,390 +1,390 @@
-------------------------------------------------------------------------
--- minmag.decTest -- decimal minimum by magnitude --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- we assume that base comparison is tested in compare.decTest, so
--- these mainly cover special cases and rounding
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- sanity checks
-mngx001 minmag -2 -2 -> -2
-mngx002 minmag -2 -1 -> -1
-mngx003 minmag -2 0 -> 0
-mngx004 minmag -2 1 -> 1
-mngx005 minmag -2 2 -> -2
-mngx006 minmag -1 -2 -> -1
-mngx007 minmag -1 -1 -> -1
-mngx008 minmag -1 0 -> 0
-mngx009 minmag -1 1 -> -1
-mngx010 minmag -1 2 -> -1
-mngx011 minmag 0 -2 -> 0
-mngx012 minmag 0 -1 -> 0
-mngx013 minmag 0 0 -> 0
-mngx014 minmag 0 1 -> 0
-mngx015 minmag 0 2 -> 0
-mngx016 minmag 1 -2 -> 1
-mngx017 minmag 1 -1 -> -1
-mngx018 minmag 1 0 -> 0
-mngx019 minmag 1 1 -> 1
-mngx020 minmag 1 2 -> 1
-mngx021 minmag 2 -2 -> -2
-mngx022 minmag 2 -1 -> -1
-mngx023 minmag 2 0 -> 0
-mngx025 minmag 2 1 -> 1
-mngx026 minmag 2 2 -> 2
-
--- extended zeros
-mngx030 minmag 0 0 -> 0
-mngx031 minmag 0 -0 -> -0
-mngx032 minmag 0 -0.0 -> -0.0
-mngx033 minmag 0 0.0 -> 0.0
-mngx034 minmag -0 0 -> -0
-mngx035 minmag -0 -0 -> -0
-mngx036 minmag -0 -0.0 -> -0
-mngx037 minmag -0 0.0 -> -0
-mngx038 minmag 0.0 0 -> 0.0
-mngx039 minmag 0.0 -0 -> -0
-mngx040 minmag 0.0 -0.0 -> -0.0
-mngx041 minmag 0.0 0.0 -> 0.0
-mngx042 minmag -0.0 0 -> -0.0
-mngx043 minmag -0.0 -0 -> -0
-mngx044 minmag -0.0 -0.0 -> -0.0
-mngx045 minmag -0.0 0.0 -> -0.0
-
-mngx046 minmag 0E1 -0E1 -> -0E+1
-mngx047 minmag -0E1 0E2 -> -0E+1
-mngx048 minmag 0E2 0E1 -> 0E+1
-mngx049 minmag 0E1 0E2 -> 0E+1
-mngx050 minmag -0E3 -0E2 -> -0E+3
-mngx051 minmag -0E2 -0E3 -> -0E+3
-
--- Specials
-precision: 9
-mngx090 minmag Inf -Inf -> -Infinity
-mngx091 minmag Inf -1000 -> -1000
-mngx092 minmag Inf -1 -> -1
-mngx093 minmag Inf -0 -> -0
-mngx094 minmag Inf 0 -> 0
-mngx095 minmag Inf 1 -> 1
-mngx096 minmag Inf 1000 -> 1000
-mngx097 minmag Inf Inf -> Infinity
-mngx098 minmag -1000 Inf -> -1000
-mngx099 minmag -Inf Inf -> -Infinity
-mngx100 minmag -1 Inf -> -1
-mngx101 minmag -0 Inf -> -0
-mngx102 minmag 0 Inf -> 0
-mngx103 minmag 1 Inf -> 1
-mngx104 minmag 1000 Inf -> 1000
-mngx105 minmag Inf Inf -> Infinity
-
-mngx120 minmag -Inf -Inf -> -Infinity
-mngx121 minmag -Inf -1000 -> -1000
-mngx122 minmag -Inf -1 -> -1
-mngx123 minmag -Inf -0 -> -0
-mngx124 minmag -Inf 0 -> 0
-mngx125 minmag -Inf 1 -> 1
-mngx126 minmag -Inf 1000 -> 1000
-mngx127 minmag -Inf Inf -> -Infinity
-mngx128 minmag -Inf -Inf -> -Infinity
-mngx129 minmag -1000 -Inf -> -1000
-mngx130 minmag -1 -Inf -> -1
-mngx131 minmag -0 -Inf -> -0
-mngx132 minmag 0 -Inf -> 0
-mngx133 minmag 1 -Inf -> 1
-mngx134 minmag 1000 -Inf -> 1000
-mngx135 minmag Inf -Inf -> -Infinity
-
--- 2004.08.02 754r chooses number over NaN in mixed cases
-mngx141 minmag NaN -Inf -> -Infinity
-mngx142 minmag NaN -1000 -> -1000
-mngx143 minmag NaN -1 -> -1
-mngx144 minmag NaN -0 -> -0
-mngx145 minmag NaN 0 -> 0
-mngx146 minmag NaN 1 -> 1
-mngx147 minmag NaN 1000 -> 1000
-mngx148 minmag NaN Inf -> Infinity
-mngx149 minmag NaN NaN -> NaN
-mngx150 minmag -Inf NaN -> -Infinity
-mngx151 minmag -1000 NaN -> -1000
-mngx152 minmag -1 -NaN -> -1
-mngx153 minmag -0 NaN -> -0
-mngx154 minmag 0 -NaN -> 0
-mngx155 minmag 1 NaN -> 1
-mngx156 minmag 1000 NaN -> 1000
-mngx157 minmag Inf NaN -> Infinity
-
-mngx161 minmag sNaN -Inf -> NaN Invalid_operation
-mngx162 minmag sNaN -1000 -> NaN Invalid_operation
-mngx163 minmag sNaN -1 -> NaN Invalid_operation
-mngx164 minmag sNaN -0 -> NaN Invalid_operation
-mngx165 minmag -sNaN 0 -> -NaN Invalid_operation
-mngx166 minmag -sNaN 1 -> -NaN Invalid_operation
-mngx167 minmag sNaN 1000 -> NaN Invalid_operation
-mngx168 minmag sNaN NaN -> NaN Invalid_operation
-mngx169 minmag sNaN sNaN -> NaN Invalid_operation
-mngx170 minmag NaN sNaN -> NaN Invalid_operation
-mngx171 minmag -Inf sNaN -> NaN Invalid_operation
-mngx172 minmag -1000 sNaN -> NaN Invalid_operation
-mngx173 minmag -1 sNaN -> NaN Invalid_operation
-mngx174 minmag -0 sNaN -> NaN Invalid_operation
-mngx175 minmag 0 sNaN -> NaN Invalid_operation
-mngx176 minmag 1 sNaN -> NaN Invalid_operation
-mngx177 minmag 1000 sNaN -> NaN Invalid_operation
-mngx178 minmag Inf sNaN -> NaN Invalid_operation
-mngx179 minmag NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-mngx181 minmag NaN9 -Inf -> -Infinity
-mngx182 minmag -NaN8 9990 -> 9990
-mngx183 minmag NaN71 Inf -> Infinity
-
-mngx184 minmag NaN1 NaN54 -> NaN1
-mngx185 minmag NaN22 -NaN53 -> NaN22
-mngx186 minmag -NaN3 NaN6 -> -NaN3
-mngx187 minmag -NaN44 NaN7 -> -NaN44
-
-mngx188 minmag -Inf NaN41 -> -Infinity
-mngx189 minmag -9999 -NaN33 -> -9999
-mngx190 minmag Inf NaN2 -> Infinity
-
-mngx191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
-mngx192 minmag sNaN98 -11 -> NaN98 Invalid_operation
-mngx193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
-mngx194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
-mngx195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
-mngx196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
-mngx197 minmag 088 sNaN91 -> NaN91 Invalid_operation
-mngx198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
-mngx199 minmag NaN sNaN86 -> NaN86 Invalid_operation
-
--- rounding checks -- chosen is rounded, or not
-maxExponent: 999
-minexponent: -999
-precision: 9
-mngx201 minmag -12345678000 1 -> 1
-mngx202 minmag 1 -12345678000 -> 1
-mngx203 minmag -1234567800 1 -> 1
-mngx204 minmag 1 -1234567800 -> 1
-mngx205 minmag -1234567890 1 -> 1
-mngx206 minmag 1 -1234567890 -> 1
-mngx207 minmag -1234567891 1 -> 1
-mngx208 minmag 1 -1234567891 -> 1
-mngx209 minmag -12345678901 1 -> 1
-mngx210 minmag 1 -12345678901 -> 1
-mngx211 minmag -1234567896 1 -> 1
-mngx212 minmag 1 -1234567896 -> 1
-mngx213 minmag 1234567891 1 -> 1
-mngx214 minmag 1 1234567891 -> 1
-mngx215 minmag 12345678901 1 -> 1
-mngx216 minmag 1 12345678901 -> 1
-mngx217 minmag 1234567896 1 -> 1
-mngx218 minmag 1 1234567896 -> 1
-
-precision: 15
-mngx221 minmag -12345678000 1 -> 1
-mngx222 minmag 1 -12345678000 -> 1
-mngx223 minmag -1234567800 1 -> 1
-mngx224 minmag 1 -1234567800 -> 1
-mngx225 minmag -1234567890 1 -> 1
-mngx226 minmag 1 -1234567890 -> 1
-mngx227 minmag -1234567891 1 -> 1
-mngx228 minmag 1 -1234567891 -> 1
-mngx229 minmag -12345678901 1 -> 1
-mngx230 minmag 1 -12345678901 -> 1
-mngx231 minmag -1234567896 1 -> 1
-mngx232 minmag 1 -1234567896 -> 1
-mngx233 minmag 1234567891 1 -> 1
-mngx234 minmag 1 1234567891 -> 1
-mngx235 minmag 12345678901 1 -> 1
-mngx236 minmag 1 12345678901 -> 1
-mngx237 minmag 1234567896 1 -> 1
-mngx238 minmag 1 1234567896 -> 1
-
--- from examples
-mngx280 minmag '3' '2' -> '2'
-mngx281 minmag '-10' '3' -> '3'
-mngx282 minmag '1.0' '1' -> '1.0'
-mngx283 minmag '1' '1.0' -> '1.0'
-mngx284 minmag '7' 'NaN' -> '7'
-
--- overflow and underflow tests .. subnormal results [inputs] now allowed
-maxExponent: 999999999
-minexponent: -999999999
-mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
-mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
-mngx332 minmag -0.100 -9E-999999999 -> -9E-999999999
-mngx333 minmag -9E-999999999 -0.100 -> -9E-999999999
-mngx335 minmag +1.23456789012345E-0 -9E+999999999 -> 1.23456789012345
-mngx336 minmag -9E+999999999 1.23456789012345E-0 -> 1.23456789012345
-mngx337 minmag +0.100 -9E-999999999 -> -9E-999999999
-mngx338 minmag -9E-999999999 0.100 -> -9E-999999999
-
-mngx339 minmag -1e-599999999 -1e-400000001 -> -1E-599999999
-mngx340 minmag -1e-599999999 -1e-400000000 -> -1E-599999999
-mngx341 minmag -1e-600000000 -1e-400000000 -> -1E-600000000
-mngx342 minmag -9e-999999998 -0.01 -> -9E-999999998
-mngx343 minmag -9e-999999998 -0.1 -> -9E-999999998
-mngx344 minmag -0.01 -9e-999999998 -> -9E-999999998
-mngx345 minmag -1e599999999 -1e400000001 -> -1E+400000001
-mngx346 minmag -1e599999999 -1e400000000 -> -1E+400000000
-mngx347 minmag -1e600000000 -1e400000000 -> -1E+400000000
-mngx348 minmag -9e999999998 -100 -> -100
-mngx349 minmag -9e999999998 -10 -> -10
-mngx350 minmag -100 -9e999999998 -> -100
--- signs
-mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
-mngx352 minmag -1e+777777777 +1e+411111111 -> 1E+411111111
-mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
-mngx354 minmag +1e+777777777 +1e+411111111 -> 1E+411111111
-mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
-mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
-mngx357 minmag +1e-777777777 -1e-411111111 -> 1E-777777777
-mngx358 minmag +1e-777777777 +1e-411111111 -> 1E-777777777
-
--- expanded list from min/max 754r purple prose
--- [explicit tests for exponent ordering]
-mngx401 minmag Inf 1.1 -> 1.1
-mngx402 minmag 1.1 1 -> 1
-mngx403 minmag 1 1.0 -> 1.0
-mngx404 minmag 1.0 0.1 -> 0.1
-mngx405 minmag 0.1 0.10 -> 0.10
-mngx406 minmag 0.10 0.100 -> 0.100
-mngx407 minmag 0.10 0 -> 0
-mngx408 minmag 0 0.0 -> 0.0
-mngx409 minmag 0.0 -0 -> -0
-mngx410 minmag 0.0 -0.0 -> -0.0
-mngx411 minmag 0.00 -0.0 -> -0.0
-mngx412 minmag 0.0 -0.00 -> -0.00
-mngx413 minmag 0 -0.0 -> -0.0
-mngx414 minmag 0 -0 -> -0
-mngx415 minmag -0.0 -0 -> -0
-mngx416 minmag -0 -0.100 -> -0
-mngx417 minmag -0.100 -0.10 -> -0.10
-mngx418 minmag -0.10 -0.1 -> -0.1
-mngx419 minmag -0.1 -1.0 -> -0.1
-mngx420 minmag -1.0 -1 -> -1
-mngx421 minmag -1 -1.1 -> -1
-mngx423 minmag -1.1 -Inf -> -1.1
--- same with operands reversed
-mngx431 minmag 1.1 Inf -> 1.1
-mngx432 minmag 1 1.1 -> 1
-mngx433 minmag 1.0 1 -> 1.0
-mngx434 minmag 0.1 1.0 -> 0.1
-mngx435 minmag 0.10 0.1 -> 0.10
-mngx436 minmag 0.100 0.10 -> 0.100
-mngx437 minmag 0 0.10 -> 0
-mngx438 minmag 0.0 0 -> 0.0
-mngx439 minmag -0 0.0 -> -0
-mngx440 minmag -0.0 0.0 -> -0.0
-mngx441 minmag -0.0 0.00 -> -0.0
-mngx442 minmag -0.00 0.0 -> -0.00
-mngx443 minmag -0.0 0 -> -0.0
-mngx444 minmag -0 0 -> -0
-mngx445 minmag -0 -0.0 -> -0
-mngx446 minmag -0.100 -0 -> -0
-mngx447 minmag -0.10 -0.100 -> -0.10
-mngx448 minmag -0.1 -0.10 -> -0.1
-mngx449 minmag -1.0 -0.1 -> -0.1
-mngx450 minmag -1 -1.0 -> -1
-mngx451 minmag -1.1 -1 -> -1
-mngx453 minmag -Inf -1.1 -> -1.1
--- largies
-mngx460 minmag 1000 1E+3 -> 1000
-mngx461 minmag 1E+3 1000 -> 1000
-mngx462 minmag 1000 -1E+3 -> -1E+3
-mngx463 minmag 1E+3 -1000 -> -1000
-mngx464 minmag -1000 1E+3 -> -1000
-mngx465 minmag -1E+3 1000 -> -1E+3
-mngx466 minmag -1000 -1E+3 -> -1E+3
-mngx467 minmag -1E+3 -1000 -> -1E+3
-
--- rounding (results treated as though plus)
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-
-mngx470 minmag 1 5 -> 1
-mngx471 minmag 10 50 -> 10
-mngx472 minmag 100 500 -> 100
-mngx473 minmag 1000 5000 -> 1.00E+3 Rounded
-mngx474 minmag 10000 50000 -> 1.00E+4 Rounded
-mngx475 minmag 6 50 -> 6
-mngx476 minmag 66 500 -> 66
-mngx477 minmag 666 5000 -> 666
-mngx478 minmag 6666 50000 -> 6.67E+3 Rounded Inexact
-mngx479 minmag 66666 500000 -> 6.67E+4 Rounded Inexact
-mngx480 minmag 33333 500000 -> 3.33E+4 Rounded Inexact
-mngx481 minmag 75401 1 -> 1
-mngx482 minmag 75402 10 -> 10
-mngx483 minmag 75403 100 -> 100
-mngx484 minmag 75404 1000 -> 1.00E+3 Rounded
-mngx485 minmag 75405 10000 -> 1.00E+4 Rounded
-mngx486 minmag 75406 6 -> 6
-mngx487 minmag 75407 66 -> 66
-mngx488 minmag 75408 666 -> 666
-mngx489 minmag 75409 6666 -> 6.67E+3 Rounded Inexact
-mngx490 minmag 75410 66666 -> 6.67E+4 Rounded Inexact
-mngx491 minmag 75411 33333 -> 3.33E+4 Rounded Inexact
-
-
--- overflow tests
-maxexponent: 999999999
-minexponent: -999999999
-precision: 3
-mngx500 minmag 9.999E+999999999 0 -> 0
-mngx501 minmag -9.999E+999999999 0 -> 0
-
--- subnormals and underflow
-precision: 3
-maxexponent: 999
-minexponent: -999
-mngx510 minmag 1.00E-999 0 -> 0
-mngx511 minmag 0.1E-999 0 -> 0
-mngx512 minmag 0.10E-999 0 -> 0
-mngx513 minmag 0.100E-999 0 -> 0
-mngx514 minmag 0.01E-999 0 -> 0
-mngx515 minmag 0.999E-999 0 -> 0
-mngx516 minmag 0.099E-999 0 -> 0
-mngx517 minmag 0.009E-999 0 -> 0
-mngx518 minmag 0.001E-999 0 -> 0
-mngx519 minmag 0.0009E-999 0 -> 0
-mngx520 minmag 0.0001E-999 0 -> 0
-
-mngx530 minmag -1.00E-999 0 -> 0
-mngx531 minmag -0.1E-999 0 -> 0
-mngx532 minmag -0.10E-999 0 -> 0
-mngx533 minmag -0.100E-999 0 -> 0
-mngx534 minmag -0.01E-999 0 -> 0
-mngx535 minmag -0.999E-999 0 -> 0
-mngx536 minmag -0.099E-999 0 -> 0
-mngx537 minmag -0.009E-999 0 -> 0
-mngx538 minmag -0.001E-999 0 -> 0
-mngx539 minmag -0.0009E-999 0 -> 0
-mngx540 minmag -0.0001E-999 0 -> 0
-
-
--- Null tests
-mng900 minmag 10 # -> NaN Invalid_operation
-mng901 minmag # 10 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- minmag.decTest -- decimal minimum by magnitude --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- we assume that base comparison is tested in compare.decTest, so
+-- these mainly cover special cases and rounding
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- sanity checks
+mngx001 minmag -2 -2 -> -2
+mngx002 minmag -2 -1 -> -1
+mngx003 minmag -2 0 -> 0
+mngx004 minmag -2 1 -> 1
+mngx005 minmag -2 2 -> -2
+mngx006 minmag -1 -2 -> -1
+mngx007 minmag -1 -1 -> -1
+mngx008 minmag -1 0 -> 0
+mngx009 minmag -1 1 -> -1
+mngx010 minmag -1 2 -> -1
+mngx011 minmag 0 -2 -> 0
+mngx012 minmag 0 -1 -> 0
+mngx013 minmag 0 0 -> 0
+mngx014 minmag 0 1 -> 0
+mngx015 minmag 0 2 -> 0
+mngx016 minmag 1 -2 -> 1
+mngx017 minmag 1 -1 -> -1
+mngx018 minmag 1 0 -> 0
+mngx019 minmag 1 1 -> 1
+mngx020 minmag 1 2 -> 1
+mngx021 minmag 2 -2 -> -2
+mngx022 minmag 2 -1 -> -1
+mngx023 minmag 2 0 -> 0
+mngx025 minmag 2 1 -> 1
+mngx026 minmag 2 2 -> 2
+
+-- extended zeros
+mngx030 minmag 0 0 -> 0
+mngx031 minmag 0 -0 -> -0
+mngx032 minmag 0 -0.0 -> -0.0
+mngx033 minmag 0 0.0 -> 0.0
+mngx034 minmag -0 0 -> -0
+mngx035 minmag -0 -0 -> -0
+mngx036 minmag -0 -0.0 -> -0
+mngx037 minmag -0 0.0 -> -0
+mngx038 minmag 0.0 0 -> 0.0
+mngx039 minmag 0.0 -0 -> -0
+mngx040 minmag 0.0 -0.0 -> -0.0
+mngx041 minmag 0.0 0.0 -> 0.0
+mngx042 minmag -0.0 0 -> -0.0
+mngx043 minmag -0.0 -0 -> -0
+mngx044 minmag -0.0 -0.0 -> -0.0
+mngx045 minmag -0.0 0.0 -> -0.0
+
+mngx046 minmag 0E1 -0E1 -> -0E+1
+mngx047 minmag -0E1 0E2 -> -0E+1
+mngx048 minmag 0E2 0E1 -> 0E+1
+mngx049 minmag 0E1 0E2 -> 0E+1
+mngx050 minmag -0E3 -0E2 -> -0E+3
+mngx051 minmag -0E2 -0E3 -> -0E+3
+
+-- Specials
+precision: 9
+mngx090 minmag Inf -Inf -> -Infinity
+mngx091 minmag Inf -1000 -> -1000
+mngx092 minmag Inf -1 -> -1
+mngx093 minmag Inf -0 -> -0
+mngx094 minmag Inf 0 -> 0
+mngx095 minmag Inf 1 -> 1
+mngx096 minmag Inf 1000 -> 1000
+mngx097 minmag Inf Inf -> Infinity
+mngx098 minmag -1000 Inf -> -1000
+mngx099 minmag -Inf Inf -> -Infinity
+mngx100 minmag -1 Inf -> -1
+mngx101 minmag -0 Inf -> -0
+mngx102 minmag 0 Inf -> 0
+mngx103 minmag 1 Inf -> 1
+mngx104 minmag 1000 Inf -> 1000
+mngx105 minmag Inf Inf -> Infinity
+
+mngx120 minmag -Inf -Inf -> -Infinity
+mngx121 minmag -Inf -1000 -> -1000
+mngx122 minmag -Inf -1 -> -1
+mngx123 minmag -Inf -0 -> -0
+mngx124 minmag -Inf 0 -> 0
+mngx125 minmag -Inf 1 -> 1
+mngx126 minmag -Inf 1000 -> 1000
+mngx127 minmag -Inf Inf -> -Infinity
+mngx128 minmag -Inf -Inf -> -Infinity
+mngx129 minmag -1000 -Inf -> -1000
+mngx130 minmag -1 -Inf -> -1
+mngx131 minmag -0 -Inf -> -0
+mngx132 minmag 0 -Inf -> 0
+mngx133 minmag 1 -Inf -> 1
+mngx134 minmag 1000 -Inf -> 1000
+mngx135 minmag Inf -Inf -> -Infinity
+
+-- 2004.08.02 754r chooses number over NaN in mixed cases
+mngx141 minmag NaN -Inf -> -Infinity
+mngx142 minmag NaN -1000 -> -1000
+mngx143 minmag NaN -1 -> -1
+mngx144 minmag NaN -0 -> -0
+mngx145 minmag NaN 0 -> 0
+mngx146 minmag NaN 1 -> 1
+mngx147 minmag NaN 1000 -> 1000
+mngx148 minmag NaN Inf -> Infinity
+mngx149 minmag NaN NaN -> NaN
+mngx150 minmag -Inf NaN -> -Infinity
+mngx151 minmag -1000 NaN -> -1000
+mngx152 minmag -1 -NaN -> -1
+mngx153 minmag -0 NaN -> -0
+mngx154 minmag 0 -NaN -> 0
+mngx155 minmag 1 NaN -> 1
+mngx156 minmag 1000 NaN -> 1000
+mngx157 minmag Inf NaN -> Infinity
+
+mngx161 minmag sNaN -Inf -> NaN Invalid_operation
+mngx162 minmag sNaN -1000 -> NaN Invalid_operation
+mngx163 minmag sNaN -1 -> NaN Invalid_operation
+mngx164 minmag sNaN -0 -> NaN Invalid_operation
+mngx165 minmag -sNaN 0 -> -NaN Invalid_operation
+mngx166 minmag -sNaN 1 -> -NaN Invalid_operation
+mngx167 minmag sNaN 1000 -> NaN Invalid_operation
+mngx168 minmag sNaN NaN -> NaN Invalid_operation
+mngx169 minmag sNaN sNaN -> NaN Invalid_operation
+mngx170 minmag NaN sNaN -> NaN Invalid_operation
+mngx171 minmag -Inf sNaN -> NaN Invalid_operation
+mngx172 minmag -1000 sNaN -> NaN Invalid_operation
+mngx173 minmag -1 sNaN -> NaN Invalid_operation
+mngx174 minmag -0 sNaN -> NaN Invalid_operation
+mngx175 minmag 0 sNaN -> NaN Invalid_operation
+mngx176 minmag 1 sNaN -> NaN Invalid_operation
+mngx177 minmag 1000 sNaN -> NaN Invalid_operation
+mngx178 minmag Inf sNaN -> NaN Invalid_operation
+mngx179 minmag NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+mngx181 minmag NaN9 -Inf -> -Infinity
+mngx182 minmag -NaN8 9990 -> 9990
+mngx183 minmag NaN71 Inf -> Infinity
+
+mngx184 minmag NaN1 NaN54 -> NaN1
+mngx185 minmag NaN22 -NaN53 -> NaN22
+mngx186 minmag -NaN3 NaN6 -> -NaN3
+mngx187 minmag -NaN44 NaN7 -> -NaN44
+
+mngx188 minmag -Inf NaN41 -> -Infinity
+mngx189 minmag -9999 -NaN33 -> -9999
+mngx190 minmag Inf NaN2 -> Infinity
+
+mngx191 minmag sNaN99 -Inf -> NaN99 Invalid_operation
+mngx192 minmag sNaN98 -11 -> NaN98 Invalid_operation
+mngx193 minmag -sNaN97 NaN8 -> -NaN97 Invalid_operation
+mngx194 minmag sNaN69 sNaN94 -> NaN69 Invalid_operation
+mngx195 minmag NaN95 sNaN93 -> NaN93 Invalid_operation
+mngx196 minmag -Inf sNaN92 -> NaN92 Invalid_operation
+mngx197 minmag 088 sNaN91 -> NaN91 Invalid_operation
+mngx198 minmag Inf -sNaN90 -> -NaN90 Invalid_operation
+mngx199 minmag NaN sNaN86 -> NaN86 Invalid_operation
+
+-- rounding checks -- chosen is rounded, or not
+maxExponent: 999
+minexponent: -999
+precision: 9
+mngx201 minmag -12345678000 1 -> 1
+mngx202 minmag 1 -12345678000 -> 1
+mngx203 minmag -1234567800 1 -> 1
+mngx204 minmag 1 -1234567800 -> 1
+mngx205 minmag -1234567890 1 -> 1
+mngx206 minmag 1 -1234567890 -> 1
+mngx207 minmag -1234567891 1 -> 1
+mngx208 minmag 1 -1234567891 -> 1
+mngx209 minmag -12345678901 1 -> 1
+mngx210 minmag 1 -12345678901 -> 1
+mngx211 minmag -1234567896 1 -> 1
+mngx212 minmag 1 -1234567896 -> 1
+mngx213 minmag 1234567891 1 -> 1
+mngx214 minmag 1 1234567891 -> 1
+mngx215 minmag 12345678901 1 -> 1
+mngx216 minmag 1 12345678901 -> 1
+mngx217 minmag 1234567896 1 -> 1
+mngx218 minmag 1 1234567896 -> 1
+
+precision: 15
+mngx221 minmag -12345678000 1 -> 1
+mngx222 minmag 1 -12345678000 -> 1
+mngx223 minmag -1234567800 1 -> 1
+mngx224 minmag 1 -1234567800 -> 1
+mngx225 minmag -1234567890 1 -> 1
+mngx226 minmag 1 -1234567890 -> 1
+mngx227 minmag -1234567891 1 -> 1
+mngx228 minmag 1 -1234567891 -> 1
+mngx229 minmag -12345678901 1 -> 1
+mngx230 minmag 1 -12345678901 -> 1
+mngx231 minmag -1234567896 1 -> 1
+mngx232 minmag 1 -1234567896 -> 1
+mngx233 minmag 1234567891 1 -> 1
+mngx234 minmag 1 1234567891 -> 1
+mngx235 minmag 12345678901 1 -> 1
+mngx236 minmag 1 12345678901 -> 1
+mngx237 minmag 1234567896 1 -> 1
+mngx238 minmag 1 1234567896 -> 1
+
+-- from examples
+mngx280 minmag '3' '2' -> '2'
+mngx281 minmag '-10' '3' -> '3'
+mngx282 minmag '1.0' '1' -> '1.0'
+mngx283 minmag '1' '1.0' -> '1.0'
+mngx284 minmag '7' 'NaN' -> '7'
+
+-- overflow and underflow tests .. subnormal results [inputs] now allowed
+maxExponent: 999999999
+minexponent: -999999999
+mngx330 minmag -1.23456789012345E-0 -9E+999999999 -> -1.23456789012345
+mngx331 minmag -9E+999999999 -1.23456789012345E-0 -> -1.23456789012345
+mngx332 minmag -0.100 -9E-999999999 -> -9E-999999999
+mngx333 minmag -9E-999999999 -0.100 -> -9E-999999999
+mngx335 minmag +1.23456789012345E-0 -9E+999999999 -> 1.23456789012345
+mngx336 minmag -9E+999999999 1.23456789012345E-0 -> 1.23456789012345
+mngx337 minmag +0.100 -9E-999999999 -> -9E-999999999
+mngx338 minmag -9E-999999999 0.100 -> -9E-999999999
+
+mngx339 minmag -1e-599999999 -1e-400000001 -> -1E-599999999
+mngx340 minmag -1e-599999999 -1e-400000000 -> -1E-599999999
+mngx341 minmag -1e-600000000 -1e-400000000 -> -1E-600000000
+mngx342 minmag -9e-999999998 -0.01 -> -9E-999999998
+mngx343 minmag -9e-999999998 -0.1 -> -9E-999999998
+mngx344 minmag -0.01 -9e-999999998 -> -9E-999999998
+mngx345 minmag -1e599999999 -1e400000001 -> -1E+400000001
+mngx346 minmag -1e599999999 -1e400000000 -> -1E+400000000
+mngx347 minmag -1e600000000 -1e400000000 -> -1E+400000000
+mngx348 minmag -9e999999998 -100 -> -100
+mngx349 minmag -9e999999998 -10 -> -10
+mngx350 minmag -100 -9e999999998 -> -100
+-- signs
+mngx351 minmag -1e+777777777 -1e+411111111 -> -1E+411111111
+mngx352 minmag -1e+777777777 +1e+411111111 -> 1E+411111111
+mngx353 minmag +1e+777777777 -1e+411111111 -> -1E+411111111
+mngx354 minmag +1e+777777777 +1e+411111111 -> 1E+411111111
+mngx355 minmag -1e-777777777 -1e-411111111 -> -1E-777777777
+mngx356 minmag -1e-777777777 +1e-411111111 -> -1E-777777777
+mngx357 minmag +1e-777777777 -1e-411111111 -> 1E-777777777
+mngx358 minmag +1e-777777777 +1e-411111111 -> 1E-777777777
+
+-- expanded list from min/max 754r purple prose
+-- [explicit tests for exponent ordering]
+mngx401 minmag Inf 1.1 -> 1.1
+mngx402 minmag 1.1 1 -> 1
+mngx403 minmag 1 1.0 -> 1.0
+mngx404 minmag 1.0 0.1 -> 0.1
+mngx405 minmag 0.1 0.10 -> 0.10
+mngx406 minmag 0.10 0.100 -> 0.100
+mngx407 minmag 0.10 0 -> 0
+mngx408 minmag 0 0.0 -> 0.0
+mngx409 minmag 0.0 -0 -> -0
+mngx410 minmag 0.0 -0.0 -> -0.0
+mngx411 minmag 0.00 -0.0 -> -0.0
+mngx412 minmag 0.0 -0.00 -> -0.00
+mngx413 minmag 0 -0.0 -> -0.0
+mngx414 minmag 0 -0 -> -0
+mngx415 minmag -0.0 -0 -> -0
+mngx416 minmag -0 -0.100 -> -0
+mngx417 minmag -0.100 -0.10 -> -0.10
+mngx418 minmag -0.10 -0.1 -> -0.1
+mngx419 minmag -0.1 -1.0 -> -0.1
+mngx420 minmag -1.0 -1 -> -1
+mngx421 minmag -1 -1.1 -> -1
+mngx423 minmag -1.1 -Inf -> -1.1
+-- same with operands reversed
+mngx431 minmag 1.1 Inf -> 1.1
+mngx432 minmag 1 1.1 -> 1
+mngx433 minmag 1.0 1 -> 1.0
+mngx434 minmag 0.1 1.0 -> 0.1
+mngx435 minmag 0.10 0.1 -> 0.10
+mngx436 minmag 0.100 0.10 -> 0.100
+mngx437 minmag 0 0.10 -> 0
+mngx438 minmag 0.0 0 -> 0.0
+mngx439 minmag -0 0.0 -> -0
+mngx440 minmag -0.0 0.0 -> -0.0
+mngx441 minmag -0.0 0.00 -> -0.0
+mngx442 minmag -0.00 0.0 -> -0.00
+mngx443 minmag -0.0 0 -> -0.0
+mngx444 minmag -0 0 -> -0
+mngx445 minmag -0 -0.0 -> -0
+mngx446 minmag -0.100 -0 -> -0
+mngx447 minmag -0.10 -0.100 -> -0.10
+mngx448 minmag -0.1 -0.10 -> -0.1
+mngx449 minmag -1.0 -0.1 -> -0.1
+mngx450 minmag -1 -1.0 -> -1
+mngx451 minmag -1.1 -1 -> -1
+mngx453 minmag -Inf -1.1 -> -1.1
+-- largies
+mngx460 minmag 1000 1E+3 -> 1000
+mngx461 minmag 1E+3 1000 -> 1000
+mngx462 minmag 1000 -1E+3 -> -1E+3
+mngx463 minmag 1E+3 -1000 -> -1000
+mngx464 minmag -1000 1E+3 -> -1000
+mngx465 minmag -1E+3 1000 -> -1E+3
+mngx466 minmag -1000 -1E+3 -> -1E+3
+mngx467 minmag -1E+3 -1000 -> -1E+3
+
+-- rounding (results treated as though plus)
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+
+mngx470 minmag 1 5 -> 1
+mngx471 minmag 10 50 -> 10
+mngx472 minmag 100 500 -> 100
+mngx473 minmag 1000 5000 -> 1.00E+3 Rounded
+mngx474 minmag 10000 50000 -> 1.00E+4 Rounded
+mngx475 minmag 6 50 -> 6
+mngx476 minmag 66 500 -> 66
+mngx477 minmag 666 5000 -> 666
+mngx478 minmag 6666 50000 -> 6.67E+3 Rounded Inexact
+mngx479 minmag 66666 500000 -> 6.67E+4 Rounded Inexact
+mngx480 minmag 33333 500000 -> 3.33E+4 Rounded Inexact
+mngx481 minmag 75401 1 -> 1
+mngx482 minmag 75402 10 -> 10
+mngx483 minmag 75403 100 -> 100
+mngx484 minmag 75404 1000 -> 1.00E+3 Rounded
+mngx485 minmag 75405 10000 -> 1.00E+4 Rounded
+mngx486 minmag 75406 6 -> 6
+mngx487 minmag 75407 66 -> 66
+mngx488 minmag 75408 666 -> 666
+mngx489 minmag 75409 6666 -> 6.67E+3 Rounded Inexact
+mngx490 minmag 75410 66666 -> 6.67E+4 Rounded Inexact
+mngx491 minmag 75411 33333 -> 3.33E+4 Rounded Inexact
+
+
+-- overflow tests
+maxexponent: 999999999
+minexponent: -999999999
+precision: 3
+mngx500 minmag 9.999E+999999999 0 -> 0
+mngx501 minmag -9.999E+999999999 0 -> 0
+
+-- subnormals and underflow
+precision: 3
+maxexponent: 999
+minexponent: -999
+mngx510 minmag 1.00E-999 0 -> 0
+mngx511 minmag 0.1E-999 0 -> 0
+mngx512 minmag 0.10E-999 0 -> 0
+mngx513 minmag 0.100E-999 0 -> 0
+mngx514 minmag 0.01E-999 0 -> 0
+mngx515 minmag 0.999E-999 0 -> 0
+mngx516 minmag 0.099E-999 0 -> 0
+mngx517 minmag 0.009E-999 0 -> 0
+mngx518 minmag 0.001E-999 0 -> 0
+mngx519 minmag 0.0009E-999 0 -> 0
+mngx520 minmag 0.0001E-999 0 -> 0
+
+mngx530 minmag -1.00E-999 0 -> 0
+mngx531 minmag -0.1E-999 0 -> 0
+mngx532 minmag -0.10E-999 0 -> 0
+mngx533 minmag -0.100E-999 0 -> 0
+mngx534 minmag -0.01E-999 0 -> 0
+mngx535 minmag -0.999E-999 0 -> 0
+mngx536 minmag -0.099E-999 0 -> 0
+mngx537 minmag -0.009E-999 0 -> 0
+mngx538 minmag -0.001E-999 0 -> 0
+mngx539 minmag -0.0009E-999 0 -> 0
+mngx540 minmag -0.0001E-999 0 -> 0
+
+
+-- Null tests
+mng900 minmag 10 # -> NaN Invalid_operation
+mng901 minmag # 10 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/nextminus.decTest b/Lib/test/decimaltestdata/nextminus.decTest
index 531c5252a5f..ba93066b96a 100644
--- a/Lib/test/decimaltestdata/nextminus.decTest
+++ b/Lib/test/decimaltestdata/nextminus.decTest
@@ -1,148 +1,148 @@
-------------------------------------------------------------------------
--- nextminus.decTest -- decimal next that is less [754r nextdown] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-nextm001 nextminus 0.999999995 -> 0.999999994
-nextm002 nextminus 0.999999996 -> 0.999999995
-nextm003 nextminus 0.999999997 -> 0.999999996
-nextm004 nextminus 0.999999998 -> 0.999999997
-nextm005 nextminus 0.999999999 -> 0.999999998
-nextm006 nextminus 1.00000000 -> 0.999999999
-nextm007 nextminus 1.0 -> 0.999999999
-nextm008 nextminus 1 -> 0.999999999
-nextm009 nextminus 1.00000001 -> 1.00000000
-nextm010 nextminus 1.00000002 -> 1.00000001
-nextm011 nextminus 1.00000003 -> 1.00000002
-nextm012 nextminus 1.00000004 -> 1.00000003
-nextm013 nextminus 1.00000005 -> 1.00000004
-nextm014 nextminus 1.00000006 -> 1.00000005
-nextm015 nextminus 1.00000007 -> 1.00000006
-nextm016 nextminus 1.00000008 -> 1.00000007
-nextm017 nextminus 1.00000009 -> 1.00000008
-nextm018 nextminus 1.00000010 -> 1.00000009
-nextm019 nextminus 1.00000011 -> 1.00000010
-nextm020 nextminus 1.00000012 -> 1.00000011
-
-nextm021 nextminus -0.999999995 -> -0.999999996
-nextm022 nextminus -0.999999996 -> -0.999999997
-nextm023 nextminus -0.999999997 -> -0.999999998
-nextm024 nextminus -0.999999998 -> -0.999999999
-nextm025 nextminus -0.999999999 -> -1.00000000
-nextm026 nextminus -1.00000000 -> -1.00000001
-nextm027 nextminus -1.0 -> -1.00000001
-nextm028 nextminus -1 -> -1.00000001
-nextm029 nextminus -1.00000001 -> -1.00000002
-nextm030 nextminus -1.00000002 -> -1.00000003
-nextm031 nextminus -1.00000003 -> -1.00000004
-nextm032 nextminus -1.00000004 -> -1.00000005
-nextm033 nextminus -1.00000005 -> -1.00000006
-nextm034 nextminus -1.00000006 -> -1.00000007
-nextm035 nextminus -1.00000007 -> -1.00000008
-nextm036 nextminus -1.00000008 -> -1.00000009
-nextm037 nextminus -1.00000009 -> -1.00000010
-nextm038 nextminus -1.00000010 -> -1.00000011
-nextm039 nextminus -1.00000011 -> -1.00000012
-
--- input operand is >precision
-nextm041 nextminus 1.00000010998 -> 1.00000010
-nextm042 nextminus 1.00000010999 -> 1.00000010
-nextm043 nextminus 1.00000011000 -> 1.00000010
-nextm044 nextminus 1.00000011001 -> 1.00000011
-nextm045 nextminus 1.00000011002 -> 1.00000011
-nextm046 nextminus 1.00000011002 -> 1.00000011
-nextm047 nextminus 1.00000011052 -> 1.00000011
-nextm048 nextminus 1.00000011552 -> 1.00000011
-nextm049 nextminus -1.00000010998 -> -1.00000011
-nextm050 nextminus -1.00000010999 -> -1.00000011
-nextm051 nextminus -1.00000011000 -> -1.00000012
-nextm052 nextminus -1.00000011001 -> -1.00000012
-nextm053 nextminus -1.00000011002 -> -1.00000012
-nextm054 nextminus -1.00000011002 -> -1.00000012
-nextm055 nextminus -1.00000011052 -> -1.00000012
-nextm056 nextminus -1.00000011552 -> -1.00000012
--- ultra-tiny inputs
-nextm060 nextminus 1E-99999 -> 0E-391
-nextm061 nextminus 1E-999999999 -> 0E-391
-nextm062 nextminus 1E-391 -> 0E-391
-nextm063 nextminus -1E-99999 -> -1E-391
-nextm064 nextminus -1E-999999999 -> -1E-391
-nextm065 nextminus -1E-391 -> -2E-391
-
--- Zeros
-nextm100 nextminus -0 -> -1E-391
-nextm101 nextminus 0 -> -1E-391
-nextm102 nextminus 0.00 -> -1E-391
-nextm103 nextminus -0.00 -> -1E-391
-nextm104 nextminus 0E-300 -> -1E-391
-nextm105 nextminus 0E+300 -> -1E-391
-nextm106 nextminus 0E+30000 -> -1E-391
-nextm107 nextminus -0E+30000 -> -1E-391
-
-precision: 9
-maxExponent: 999
-minexponent: -999
--- specials
-nextm150 nextminus Inf -> 9.99999999E+999
-nextm151 nextminus -Inf -> -Infinity
-nextm152 nextminus NaN -> NaN
-nextm153 nextminus sNaN -> NaN Invalid_operation
-nextm154 nextminus NaN77 -> NaN77
-nextm155 nextminus sNaN88 -> NaN88 Invalid_operation
-nextm156 nextminus -NaN -> -NaN
-nextm157 nextminus -sNaN -> -NaN Invalid_operation
-nextm158 nextminus -NaN77 -> -NaN77
-nextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-nextm170 nextminus 9.99999999E+999 -> 9.99999998E+999
-nextm171 nextminus 9.99999998E+999 -> 9.99999997E+999
-nextm172 nextminus 1E-999 -> 9.9999999E-1000
-nextm173 nextminus 1.00000000E-999 -> 9.9999999E-1000
-nextm174 nextminus 9E-1007 -> 8E-1007
-nextm175 nextminus 9.9E-1006 -> 9.8E-1006
-nextm176 nextminus 9.9999E-1003 -> 9.9998E-1003
-nextm177 nextminus 9.9999999E-1000 -> 9.9999998E-1000
-nextm178 nextminus 9.9999998E-1000 -> 9.9999997E-1000
-nextm179 nextminus 9.9999997E-1000 -> 9.9999996E-1000
-nextm180 nextminus 0E-1007 -> -1E-1007
-nextm181 nextminus 1E-1007 -> 0E-1007
-nextm182 nextminus 2E-1007 -> 1E-1007
-
-nextm183 nextminus -0E-1007 -> -1E-1007
-nextm184 nextminus -1E-1007 -> -2E-1007
-nextm185 nextminus -2E-1007 -> -3E-1007
-nextm186 nextminus -10E-1007 -> -1.1E-1006
-nextm187 nextminus -100E-1007 -> -1.01E-1005
-nextm188 nextminus -100000E-1007 -> -1.00001E-1002
-nextm189 nextminus -1.0000E-999 -> -1.00000001E-999
-nextm190 nextminus -1.00000000E-999 -> -1.00000001E-999
-nextm191 nextminus -1E-999 -> -1.00000001E-999
-nextm192 nextminus -9.99999998E+999 -> -9.99999999E+999
-nextm193 nextminus -9.99999999E+999 -> -Infinity
-
--- Null tests
-nextm900 nextminus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nextminus.decTest -- decimal next that is less [754r nextdown] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+nextm001 nextminus 0.999999995 -> 0.999999994
+nextm002 nextminus 0.999999996 -> 0.999999995
+nextm003 nextminus 0.999999997 -> 0.999999996
+nextm004 nextminus 0.999999998 -> 0.999999997
+nextm005 nextminus 0.999999999 -> 0.999999998
+nextm006 nextminus 1.00000000 -> 0.999999999
+nextm007 nextminus 1.0 -> 0.999999999
+nextm008 nextminus 1 -> 0.999999999
+nextm009 nextminus 1.00000001 -> 1.00000000
+nextm010 nextminus 1.00000002 -> 1.00000001
+nextm011 nextminus 1.00000003 -> 1.00000002
+nextm012 nextminus 1.00000004 -> 1.00000003
+nextm013 nextminus 1.00000005 -> 1.00000004
+nextm014 nextminus 1.00000006 -> 1.00000005
+nextm015 nextminus 1.00000007 -> 1.00000006
+nextm016 nextminus 1.00000008 -> 1.00000007
+nextm017 nextminus 1.00000009 -> 1.00000008
+nextm018 nextminus 1.00000010 -> 1.00000009
+nextm019 nextminus 1.00000011 -> 1.00000010
+nextm020 nextminus 1.00000012 -> 1.00000011
+
+nextm021 nextminus -0.999999995 -> -0.999999996
+nextm022 nextminus -0.999999996 -> -0.999999997
+nextm023 nextminus -0.999999997 -> -0.999999998
+nextm024 nextminus -0.999999998 -> -0.999999999
+nextm025 nextminus -0.999999999 -> -1.00000000
+nextm026 nextminus -1.00000000 -> -1.00000001
+nextm027 nextminus -1.0 -> -1.00000001
+nextm028 nextminus -1 -> -1.00000001
+nextm029 nextminus -1.00000001 -> -1.00000002
+nextm030 nextminus -1.00000002 -> -1.00000003
+nextm031 nextminus -1.00000003 -> -1.00000004
+nextm032 nextminus -1.00000004 -> -1.00000005
+nextm033 nextminus -1.00000005 -> -1.00000006
+nextm034 nextminus -1.00000006 -> -1.00000007
+nextm035 nextminus -1.00000007 -> -1.00000008
+nextm036 nextminus -1.00000008 -> -1.00000009
+nextm037 nextminus -1.00000009 -> -1.00000010
+nextm038 nextminus -1.00000010 -> -1.00000011
+nextm039 nextminus -1.00000011 -> -1.00000012
+
+-- input operand is >precision
+nextm041 nextminus 1.00000010998 -> 1.00000010
+nextm042 nextminus 1.00000010999 -> 1.00000010
+nextm043 nextminus 1.00000011000 -> 1.00000010
+nextm044 nextminus 1.00000011001 -> 1.00000011
+nextm045 nextminus 1.00000011002 -> 1.00000011
+nextm046 nextminus 1.00000011002 -> 1.00000011
+nextm047 nextminus 1.00000011052 -> 1.00000011
+nextm048 nextminus 1.00000011552 -> 1.00000011
+nextm049 nextminus -1.00000010998 -> -1.00000011
+nextm050 nextminus -1.00000010999 -> -1.00000011
+nextm051 nextminus -1.00000011000 -> -1.00000012
+nextm052 nextminus -1.00000011001 -> -1.00000012
+nextm053 nextminus -1.00000011002 -> -1.00000012
+nextm054 nextminus -1.00000011002 -> -1.00000012
+nextm055 nextminus -1.00000011052 -> -1.00000012
+nextm056 nextminus -1.00000011552 -> -1.00000012
+-- ultra-tiny inputs
+nextm060 nextminus 1E-99999 -> 0E-391
+nextm061 nextminus 1E-999999999 -> 0E-391
+nextm062 nextminus 1E-391 -> 0E-391
+nextm063 nextminus -1E-99999 -> -1E-391
+nextm064 nextminus -1E-999999999 -> -1E-391
+nextm065 nextminus -1E-391 -> -2E-391
+
+-- Zeros
+nextm100 nextminus -0 -> -1E-391
+nextm101 nextminus 0 -> -1E-391
+nextm102 nextminus 0.00 -> -1E-391
+nextm103 nextminus -0.00 -> -1E-391
+nextm104 nextminus 0E-300 -> -1E-391
+nextm105 nextminus 0E+300 -> -1E-391
+nextm106 nextminus 0E+30000 -> -1E-391
+nextm107 nextminus -0E+30000 -> -1E-391
+
+precision: 9
+maxExponent: 999
+minexponent: -999
+-- specials
+nextm150 nextminus Inf -> 9.99999999E+999
+nextm151 nextminus -Inf -> -Infinity
+nextm152 nextminus NaN -> NaN
+nextm153 nextminus sNaN -> NaN Invalid_operation
+nextm154 nextminus NaN77 -> NaN77
+nextm155 nextminus sNaN88 -> NaN88 Invalid_operation
+nextm156 nextminus -NaN -> -NaN
+nextm157 nextminus -sNaN -> -NaN Invalid_operation
+nextm158 nextminus -NaN77 -> -NaN77
+nextm159 nextminus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+nextm170 nextminus 9.99999999E+999 -> 9.99999998E+999
+nextm171 nextminus 9.99999998E+999 -> 9.99999997E+999
+nextm172 nextminus 1E-999 -> 9.9999999E-1000
+nextm173 nextminus 1.00000000E-999 -> 9.9999999E-1000
+nextm174 nextminus 9E-1007 -> 8E-1007
+nextm175 nextminus 9.9E-1006 -> 9.8E-1006
+nextm176 nextminus 9.9999E-1003 -> 9.9998E-1003
+nextm177 nextminus 9.9999999E-1000 -> 9.9999998E-1000
+nextm178 nextminus 9.9999998E-1000 -> 9.9999997E-1000
+nextm179 nextminus 9.9999997E-1000 -> 9.9999996E-1000
+nextm180 nextminus 0E-1007 -> -1E-1007
+nextm181 nextminus 1E-1007 -> 0E-1007
+nextm182 nextminus 2E-1007 -> 1E-1007
+
+nextm183 nextminus -0E-1007 -> -1E-1007
+nextm184 nextminus -1E-1007 -> -2E-1007
+nextm185 nextminus -2E-1007 -> -3E-1007
+nextm186 nextminus -10E-1007 -> -1.1E-1006
+nextm187 nextminus -100E-1007 -> -1.01E-1005
+nextm188 nextminus -100000E-1007 -> -1.00001E-1002
+nextm189 nextminus -1.0000E-999 -> -1.00000001E-999
+nextm190 nextminus -1.00000000E-999 -> -1.00000001E-999
+nextm191 nextminus -1E-999 -> -1.00000001E-999
+nextm192 nextminus -9.99999998E+999 -> -9.99999999E+999
+nextm193 nextminus -9.99999999E+999 -> -Infinity
+
+-- Null tests
+nextm900 nextminus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/nextplus.decTest b/Lib/test/decimaltestdata/nextplus.decTest
index c66e3287270..44989e50b17 100644
--- a/Lib/test/decimaltestdata/nextplus.decTest
+++ b/Lib/test/decimaltestdata/nextplus.decTest
@@ -1,150 +1,150 @@
-------------------------------------------------------------------------
--- nextplus.decTest -- decimal next that is greater [754r nextup] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
-nextp001 nextplus 0.999999995 -> 0.999999996
-nextp002 nextplus 0.999999996 -> 0.999999997
-nextp003 nextplus 0.999999997 -> 0.999999998
-nextp004 nextplus 0.999999998 -> 0.999999999
-nextp005 nextplus 0.999999999 -> 1.00000000
-nextp006 nextplus 1.00000000 -> 1.00000001
-nextp007 nextplus 1.0 -> 1.00000001
-nextp008 nextplus 1 -> 1.00000001
-nextp009 nextplus 1.00000001 -> 1.00000002
-nextp010 nextplus 1.00000002 -> 1.00000003
-nextp011 nextplus 1.00000003 -> 1.00000004
-nextp012 nextplus 1.00000004 -> 1.00000005
-nextp013 nextplus 1.00000005 -> 1.00000006
-nextp014 nextplus 1.00000006 -> 1.00000007
-nextp015 nextplus 1.00000007 -> 1.00000008
-nextp016 nextplus 1.00000008 -> 1.00000009
-nextp017 nextplus 1.00000009 -> 1.00000010
-nextp018 nextplus 1.00000010 -> 1.00000011
-nextp019 nextplus 1.00000011 -> 1.00000012
-
-nextp021 nextplus -0.999999995 -> -0.999999994
-nextp022 nextplus -0.999999996 -> -0.999999995
-nextp023 nextplus -0.999999997 -> -0.999999996
-nextp024 nextplus -0.999999998 -> -0.999999997
-nextp025 nextplus -0.999999999 -> -0.999999998
-nextp026 nextplus -1.00000000 -> -0.999999999
-nextp027 nextplus -1.0 -> -0.999999999
-nextp028 nextplus -1 -> -0.999999999
-nextp029 nextplus -1.00000001 -> -1.00000000
-nextp030 nextplus -1.00000002 -> -1.00000001
-nextp031 nextplus -1.00000003 -> -1.00000002
-nextp032 nextplus -1.00000004 -> -1.00000003
-nextp033 nextplus -1.00000005 -> -1.00000004
-nextp034 nextplus -1.00000006 -> -1.00000005
-nextp035 nextplus -1.00000007 -> -1.00000006
-nextp036 nextplus -1.00000008 -> -1.00000007
-nextp037 nextplus -1.00000009 -> -1.00000008
-nextp038 nextplus -1.00000010 -> -1.00000009
-nextp039 nextplus -1.00000011 -> -1.00000010
-nextp040 nextplus -1.00000012 -> -1.00000011
-
--- input operand is >precision
-nextp041 nextplus 1.00000010998 -> 1.00000011
-nextp042 nextplus 1.00000010999 -> 1.00000011
-nextp043 nextplus 1.00000011000 -> 1.00000012
-nextp044 nextplus 1.00000011001 -> 1.00000012
-nextp045 nextplus 1.00000011002 -> 1.00000012
-nextp046 nextplus 1.00000011002 -> 1.00000012
-nextp047 nextplus 1.00000011052 -> 1.00000012
-nextp048 nextplus 1.00000011552 -> 1.00000012
-nextp049 nextplus -1.00000010998 -> -1.00000010
-nextp050 nextplus -1.00000010999 -> -1.00000010
-nextp051 nextplus -1.00000011000 -> -1.00000010
-nextp052 nextplus -1.00000011001 -> -1.00000011
-nextp053 nextplus -1.00000011002 -> -1.00000011
-nextp054 nextplus -1.00000011002 -> -1.00000011
-nextp055 nextplus -1.00000011052 -> -1.00000011
-nextp056 nextplus -1.00000011552 -> -1.00000011
--- ultra-tiny inputs
-nextp060 nextplus 1E-99999 -> 1E-391
-nextp061 nextplus 1E-999999999 -> 1E-391
-nextp062 nextplus 1E-391 -> 2E-391
-nextp063 nextplus -1E-99999 -> -0E-391
-nextp064 nextplus -1E-999999999 -> -0E-391
-nextp065 nextplus -1E-391 -> -0E-391
-
--- Zeros
-nextp100 nextplus 0 -> 1E-391
-nextp101 nextplus 0.00 -> 1E-391
-nextp102 nextplus 0E-300 -> 1E-391
-nextp103 nextplus 0E+300 -> 1E-391
-nextp104 nextplus 0E+30000 -> 1E-391
-nextp105 nextplus -0 -> 1E-391
-nextp106 nextplus -0.00 -> 1E-391
-nextp107 nextplus -0E-300 -> 1E-391
-nextp108 nextplus -0E+300 -> 1E-391
-nextp109 nextplus -0E+30000 -> 1E-391
-
-maxExponent: 999
-minexponent: -999
-precision: 9
--- specials
-nextp150 nextplus Inf -> Infinity
-nextp151 nextplus -Inf -> -9.99999999E+999
-nextp152 nextplus NaN -> NaN
-nextp153 nextplus sNaN -> NaN Invalid_operation
-nextp154 nextplus NaN77 -> NaN77
-nextp155 nextplus sNaN88 -> NaN88 Invalid_operation
-nextp156 nextplus -NaN -> -NaN
-nextp157 nextplus -sNaN -> -NaN Invalid_operation
-nextp158 nextplus -NaN77 -> -NaN77
-nextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-nextp170 nextplus 9.99999999E+999 -> Infinity
-nextp171 nextplus 9.99999998E+999 -> 9.99999999E+999
-nextp172 nextplus 1E-999 -> 1.00000001E-999
-nextp173 nextplus 1.00000000E-999 -> 1.00000001E-999
-nextp174 nextplus 9E-1007 -> 1.0E-1006
-nextp175 nextplus 9.9E-1006 -> 1.00E-1005
-nextp176 nextplus 9.9999E-1003 -> 1.00000E-1002
-nextp177 nextplus 9.9999999E-1000 -> 1.00000000E-999
-nextp178 nextplus 9.9999998E-1000 -> 9.9999999E-1000
-nextp179 nextplus 9.9999997E-1000 -> 9.9999998E-1000
-nextp180 nextplus 0E-1007 -> 1E-1007
-nextp181 nextplus 1E-1007 -> 2E-1007
-nextp182 nextplus 2E-1007 -> 3E-1007
-
-nextp183 nextplus -0E-1007 -> 1E-1007
-nextp184 nextplus -1E-1007 -> -0E-1007
-nextp185 nextplus -2E-1007 -> -1E-1007
-nextp186 nextplus -10E-1007 -> -9E-1007
-nextp187 nextplus -100E-1007 -> -9.9E-1006
-nextp188 nextplus -100000E-1007 -> -9.9999E-1003
-nextp189 nextplus -1.0000E-999 -> -9.9999999E-1000
-nextp190 nextplus -1.00000000E-999 -> -9.9999999E-1000
-nextp191 nextplus -1E-999 -> -9.9999999E-1000
-nextp192 nextplus -9.99999998E+999 -> -9.99999997E+999
-nextp193 nextplus -9.99999999E+999 -> -9.99999998E+999
-
--- Null tests
-nextp900 nextplus # -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nextplus.decTest -- decimal next that is greater [754r nextup] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+nextp001 nextplus 0.999999995 -> 0.999999996
+nextp002 nextplus 0.999999996 -> 0.999999997
+nextp003 nextplus 0.999999997 -> 0.999999998
+nextp004 nextplus 0.999999998 -> 0.999999999
+nextp005 nextplus 0.999999999 -> 1.00000000
+nextp006 nextplus 1.00000000 -> 1.00000001
+nextp007 nextplus 1.0 -> 1.00000001
+nextp008 nextplus 1 -> 1.00000001
+nextp009 nextplus 1.00000001 -> 1.00000002
+nextp010 nextplus 1.00000002 -> 1.00000003
+nextp011 nextplus 1.00000003 -> 1.00000004
+nextp012 nextplus 1.00000004 -> 1.00000005
+nextp013 nextplus 1.00000005 -> 1.00000006
+nextp014 nextplus 1.00000006 -> 1.00000007
+nextp015 nextplus 1.00000007 -> 1.00000008
+nextp016 nextplus 1.00000008 -> 1.00000009
+nextp017 nextplus 1.00000009 -> 1.00000010
+nextp018 nextplus 1.00000010 -> 1.00000011
+nextp019 nextplus 1.00000011 -> 1.00000012
+
+nextp021 nextplus -0.999999995 -> -0.999999994
+nextp022 nextplus -0.999999996 -> -0.999999995
+nextp023 nextplus -0.999999997 -> -0.999999996
+nextp024 nextplus -0.999999998 -> -0.999999997
+nextp025 nextplus -0.999999999 -> -0.999999998
+nextp026 nextplus -1.00000000 -> -0.999999999
+nextp027 nextplus -1.0 -> -0.999999999
+nextp028 nextplus -1 -> -0.999999999
+nextp029 nextplus -1.00000001 -> -1.00000000
+nextp030 nextplus -1.00000002 -> -1.00000001
+nextp031 nextplus -1.00000003 -> -1.00000002
+nextp032 nextplus -1.00000004 -> -1.00000003
+nextp033 nextplus -1.00000005 -> -1.00000004
+nextp034 nextplus -1.00000006 -> -1.00000005
+nextp035 nextplus -1.00000007 -> -1.00000006
+nextp036 nextplus -1.00000008 -> -1.00000007
+nextp037 nextplus -1.00000009 -> -1.00000008
+nextp038 nextplus -1.00000010 -> -1.00000009
+nextp039 nextplus -1.00000011 -> -1.00000010
+nextp040 nextplus -1.00000012 -> -1.00000011
+
+-- input operand is >precision
+nextp041 nextplus 1.00000010998 -> 1.00000011
+nextp042 nextplus 1.00000010999 -> 1.00000011
+nextp043 nextplus 1.00000011000 -> 1.00000012
+nextp044 nextplus 1.00000011001 -> 1.00000012
+nextp045 nextplus 1.00000011002 -> 1.00000012
+nextp046 nextplus 1.00000011002 -> 1.00000012
+nextp047 nextplus 1.00000011052 -> 1.00000012
+nextp048 nextplus 1.00000011552 -> 1.00000012
+nextp049 nextplus -1.00000010998 -> -1.00000010
+nextp050 nextplus -1.00000010999 -> -1.00000010
+nextp051 nextplus -1.00000011000 -> -1.00000010
+nextp052 nextplus -1.00000011001 -> -1.00000011
+nextp053 nextplus -1.00000011002 -> -1.00000011
+nextp054 nextplus -1.00000011002 -> -1.00000011
+nextp055 nextplus -1.00000011052 -> -1.00000011
+nextp056 nextplus -1.00000011552 -> -1.00000011
+-- ultra-tiny inputs
+nextp060 nextplus 1E-99999 -> 1E-391
+nextp061 nextplus 1E-999999999 -> 1E-391
+nextp062 nextplus 1E-391 -> 2E-391
+nextp063 nextplus -1E-99999 -> -0E-391
+nextp064 nextplus -1E-999999999 -> -0E-391
+nextp065 nextplus -1E-391 -> -0E-391
+
+-- Zeros
+nextp100 nextplus 0 -> 1E-391
+nextp101 nextplus 0.00 -> 1E-391
+nextp102 nextplus 0E-300 -> 1E-391
+nextp103 nextplus 0E+300 -> 1E-391
+nextp104 nextplus 0E+30000 -> 1E-391
+nextp105 nextplus -0 -> 1E-391
+nextp106 nextplus -0.00 -> 1E-391
+nextp107 nextplus -0E-300 -> 1E-391
+nextp108 nextplus -0E+300 -> 1E-391
+nextp109 nextplus -0E+30000 -> 1E-391
+
+maxExponent: 999
+minexponent: -999
+precision: 9
+-- specials
+nextp150 nextplus Inf -> Infinity
+nextp151 nextplus -Inf -> -9.99999999E+999
+nextp152 nextplus NaN -> NaN
+nextp153 nextplus sNaN -> NaN Invalid_operation
+nextp154 nextplus NaN77 -> NaN77
+nextp155 nextplus sNaN88 -> NaN88 Invalid_operation
+nextp156 nextplus -NaN -> -NaN
+nextp157 nextplus -sNaN -> -NaN Invalid_operation
+nextp158 nextplus -NaN77 -> -NaN77
+nextp159 nextplus -sNaN88 -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+nextp170 nextplus 9.99999999E+999 -> Infinity
+nextp171 nextplus 9.99999998E+999 -> 9.99999999E+999
+nextp172 nextplus 1E-999 -> 1.00000001E-999
+nextp173 nextplus 1.00000000E-999 -> 1.00000001E-999
+nextp174 nextplus 9E-1007 -> 1.0E-1006
+nextp175 nextplus 9.9E-1006 -> 1.00E-1005
+nextp176 nextplus 9.9999E-1003 -> 1.00000E-1002
+nextp177 nextplus 9.9999999E-1000 -> 1.00000000E-999
+nextp178 nextplus 9.9999998E-1000 -> 9.9999999E-1000
+nextp179 nextplus 9.9999997E-1000 -> 9.9999998E-1000
+nextp180 nextplus 0E-1007 -> 1E-1007
+nextp181 nextplus 1E-1007 -> 2E-1007
+nextp182 nextplus 2E-1007 -> 3E-1007
+
+nextp183 nextplus -0E-1007 -> 1E-1007
+nextp184 nextplus -1E-1007 -> -0E-1007
+nextp185 nextplus -2E-1007 -> -1E-1007
+nextp186 nextplus -10E-1007 -> -9E-1007
+nextp187 nextplus -100E-1007 -> -9.9E-1006
+nextp188 nextplus -100000E-1007 -> -9.9999E-1003
+nextp189 nextplus -1.0000E-999 -> -9.9999999E-1000
+nextp190 nextplus -1.00000000E-999 -> -9.9999999E-1000
+nextp191 nextplus -1E-999 -> -9.9999999E-1000
+nextp192 nextplus -9.99999998E+999 -> -9.99999997E+999
+nextp193 nextplus -9.99999999E+999 -> -9.99999998E+999
+
+-- Null tests
+nextp900 nextplus # -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/nexttoward.decTest b/Lib/test/decimaltestdata/nexttoward.decTest
index 562385a00f2..da26f651c81 100644
--- a/Lib/test/decimaltestdata/nexttoward.decTest
+++ b/Lib/test/decimaltestdata/nexttoward.decTest
@@ -1,426 +1,426 @@
-------------------------------------------------------------------------
--- nexttoward.decTest -- decimal next toward rhs [754r nextafter] --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 384
-minexponent: -383
-
--- Sanity check with a scattering of numerics
-nextt001 nexttoward 10 10 -> 10
-nextt002 nexttoward -10 -10 -> -10
-nextt003 nexttoward 1 10 -> 1.00000001
-nextt004 nexttoward 1 -10 -> 0.999999999
-nextt005 nexttoward -1 10 -> -0.999999999
-nextt006 nexttoward -1 -10 -> -1.00000001
-nextt007 nexttoward 0 10 -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt008 nexttoward 0 -10 -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt009 nexttoward 9.99999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
-nextt010 nexttoward -9.99999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
-
-------- lhs=rhs
--- finites
-nextt101 nexttoward 7 7 -> 7
-nextt102 nexttoward -7 -7 -> -7
-nextt103 nexttoward 75 75 -> 75
-nextt104 nexttoward -75 -75 -> -75
-nextt105 nexttoward 7.50 7.5 -> 7.50
-nextt106 nexttoward -7.50 -7.50 -> -7.50
-nextt107 nexttoward 7.500 7.5000 -> 7.500
-nextt108 nexttoward -7.500 -7.5 -> -7.500
-
--- zeros
-nextt111 nexttoward 0 0 -> 0
-nextt112 nexttoward -0 -0 -> -0
-nextt113 nexttoward 0E+4 0 -> 0E+4
-nextt114 nexttoward -0E+4 -0 -> -0E+4
-nextt115 nexttoward 0.0000 0.00000 -> 0.0000
-nextt116 nexttoward -0.0000 -0.00 -> -0.0000
-nextt117 nexttoward 0E-141 0 -> 0E-141
-nextt118 nexttoward -0E-141 -000 -> -0E-141
-
--- full coefficients, alternating bits
-nextt121 nexttoward 268268268 268268268 -> 268268268
-nextt122 nexttoward -268268268 -268268268 -> -268268268
-nextt123 nexttoward 134134134 134134134 -> 134134134
-nextt124 nexttoward -134134134 -134134134 -> -134134134
-
--- Nmax, Nmin, Ntiny
-nextt131 nexttoward 9.99999999E+384 9.99999999E+384 -> 9.99999999E+384
-nextt132 nexttoward 1E-383 1E-383 -> 1E-383
-nextt133 nexttoward 1.00000000E-383 1.00000000E-383 -> 1.00000000E-383
-nextt134 nexttoward 1E-391 1E-391 -> 1E-391
-
-nextt135 nexttoward -1E-391 -1E-391 -> -1E-391
-nextt136 nexttoward -1.00000000E-383 -1.00000000E-383 -> -1.00000000E-383
-nextt137 nexttoward -1E-383 -1E-383 -> -1E-383
-nextt138 nexttoward -9.99999999E+384 -9.99999999E+384 -> -9.99999999E+384
-
-------- lhs<rhs
-nextt201 nexttoward 0.999999995 Infinity -> 0.999999996
-nextt202 nexttoward 0.999999996 Infinity -> 0.999999997
-nextt203 nexttoward 0.999999997 Infinity -> 0.999999998
-nextt204 nexttoward 0.999999998 Infinity -> 0.999999999
-nextt205 nexttoward 0.999999999 Infinity -> 1.00000000
-nextt206 nexttoward 1.00000000 Infinity -> 1.00000001
-nextt207 nexttoward 1.0 Infinity -> 1.00000001
-nextt208 nexttoward 1 Infinity -> 1.00000001
-nextt209 nexttoward 1.00000001 Infinity -> 1.00000002
-nextt210 nexttoward 1.00000002 Infinity -> 1.00000003
-nextt211 nexttoward 1.00000003 Infinity -> 1.00000004
-nextt212 nexttoward 1.00000004 Infinity -> 1.00000005
-nextt213 nexttoward 1.00000005 Infinity -> 1.00000006
-nextt214 nexttoward 1.00000006 Infinity -> 1.00000007
-nextt215 nexttoward 1.00000007 Infinity -> 1.00000008
-nextt216 nexttoward 1.00000008 Infinity -> 1.00000009
-nextt217 nexttoward 1.00000009 Infinity -> 1.00000010
-nextt218 nexttoward 1.00000010 Infinity -> 1.00000011
-nextt219 nexttoward 1.00000011 Infinity -> 1.00000012
-
-nextt221 nexttoward -0.999999995 Infinity -> -0.999999994
-nextt222 nexttoward -0.999999996 Infinity -> -0.999999995
-nextt223 nexttoward -0.999999997 Infinity -> -0.999999996
-nextt224 nexttoward -0.999999998 Infinity -> -0.999999997
-nextt225 nexttoward -0.999999999 Infinity -> -0.999999998
-nextt226 nexttoward -1.00000000 Infinity -> -0.999999999
-nextt227 nexttoward -1.0 Infinity -> -0.999999999
-nextt228 nexttoward -1 Infinity -> -0.999999999
-nextt229 nexttoward -1.00000001 Infinity -> -1.00000000
-nextt230 nexttoward -1.00000002 Infinity -> -1.00000001
-nextt231 nexttoward -1.00000003 Infinity -> -1.00000002
-nextt232 nexttoward -1.00000004 Infinity -> -1.00000003
-nextt233 nexttoward -1.00000005 Infinity -> -1.00000004
-nextt234 nexttoward -1.00000006 Infinity -> -1.00000005
-nextt235 nexttoward -1.00000007 Infinity -> -1.00000006
-nextt236 nexttoward -1.00000008 Infinity -> -1.00000007
-nextt237 nexttoward -1.00000009 Infinity -> -1.00000008
-nextt238 nexttoward -1.00000010 Infinity -> -1.00000009
-nextt239 nexttoward -1.00000011 Infinity -> -1.00000010
-nextt240 nexttoward -1.00000012 Infinity -> -1.00000011
-
--- input operand is >precision
-nextt241 nexttoward 1.00000010998 Infinity -> 1.00000011
-nextt242 nexttoward 1.00000010999 Infinity -> 1.00000011
-nextt243 nexttoward 1.00000011000 Infinity -> 1.00000012
-nextt244 nexttoward 1.00000011001 Infinity -> 1.00000012
-nextt245 nexttoward 1.00000011002 Infinity -> 1.00000012
-nextt246 nexttoward 1.00000011002 Infinity -> 1.00000012
-nextt247 nexttoward 1.00000011052 Infinity -> 1.00000012
-nextt248 nexttoward 1.00000011552 Infinity -> 1.00000012
-nextt249 nexttoward -1.00000010998 Infinity -> -1.00000010
-nextt250 nexttoward -1.00000010999 Infinity -> -1.00000010
-nextt251 nexttoward -1.00000011000 Infinity -> -1.00000010
-nextt252 nexttoward -1.00000011001 Infinity -> -1.00000011
-nextt253 nexttoward -1.00000011002 Infinity -> -1.00000011
-nextt254 nexttoward -1.00000011002 Infinity -> -1.00000011
-nextt255 nexttoward -1.00000011052 Infinity -> -1.00000011
-nextt256 nexttoward -1.00000011552 Infinity -> -1.00000011
--- ultra-tiny inputs
-nextt260 nexttoward 1E-99999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt261 nexttoward 1E-999999999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt262 nexttoward 1E-391 Infinity -> 2E-391 Underflow Subnormal Inexact Rounded
-nextt263 nexttoward -1E-99999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt264 nexttoward -1E-999999999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt265 nexttoward -1E-391 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
-
--- Zeros
-nextt300 nexttoward 0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt301 nexttoward 0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt302 nexttoward 0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt303 nexttoward 0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt304 nexttoward 0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt305 nexttoward -0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt306 nexttoward -0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt307 nexttoward -0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt308 nexttoward -0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt309 nexttoward -0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
-
--- specials
-nextt350 nexttoward Inf Infinity -> Infinity
-nextt351 nexttoward -Inf Infinity -> -9.99999999E+384
-nextt352 nexttoward NaN Infinity -> NaN
-nextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
-nextt354 nexttoward NaN77 Infinity -> NaN77
-nextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
-nextt356 nexttoward -NaN Infinity -> -NaN
-nextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
-nextt358 nexttoward -NaN77 Infinity -> -NaN77
-nextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-maxExponent: 999
-minexponent: -999
-nextt370 nexttoward 9.99999999E+999 Infinity -> Infinity Overflow Inexact Rounded
-nextt371 nexttoward 9.99999998E+999 Infinity -> 9.99999999E+999
-nextt372 nexttoward 1E-999 Infinity -> 1.00000001E-999
-nextt373 nexttoward 1.00000000E-999 Infinity -> 1.00000001E-999
-nextt374 nexttoward 0.999999999E-999 Infinity -> 1.00000000E-999
-nextt375 nexttoward 0.99999999E-999 Infinity -> 1.00000000E-999
-nextt376 nexttoward 9E-1007 Infinity -> 1.0E-1006 Underflow Subnormal Inexact Rounded
-nextt377 nexttoward 9.9E-1006 Infinity -> 1.00E-1005 Underflow Subnormal Inexact Rounded
-nextt378 nexttoward 9.9999E-1003 Infinity -> 1.00000E-1002 Underflow Subnormal Inexact Rounded
-nextt379 nexttoward 9.9999998E-1000 Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt380 nexttoward 9.9999997E-1000 Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
-nextt381 nexttoward 0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-nextt382 nexttoward 1E-1007 Infinity -> 2E-1007 Underflow Subnormal Inexact Rounded
-nextt383 nexttoward 2E-1007 Infinity -> 3E-1007 Underflow Subnormal Inexact Rounded
-
-nextt385 nexttoward -0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-nextt386 nexttoward -1E-1007 Infinity -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
-nextt387 nexttoward -2E-1007 Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt388 nexttoward -10E-1007 Infinity -> -9E-1007 Underflow Subnormal Inexact Rounded
-nextt389 nexttoward -100E-1007 Infinity -> -9.9E-1006 Underflow Subnormal Inexact Rounded
-nextt390 nexttoward -100000E-1007 Infinity -> -9.9999E-1003 Underflow Subnormal Inexact Rounded
-nextt391 nexttoward -1.0000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt392 nexttoward -1.00000000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt393 nexttoward -1E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt394 nexttoward -9.99999998E+999 Infinity -> -9.99999997E+999
-nextt395 nexttoward -9.99999999E+999 Infinity -> -9.99999998E+999
-
-------- lhs>rhs
-maxExponent: 384
-minexponent: -383
-nextt401 nexttoward 0.999999995 -Infinity -> 0.999999994
-nextt402 nexttoward 0.999999996 -Infinity -> 0.999999995
-nextt403 nexttoward 0.999999997 -Infinity -> 0.999999996
-nextt404 nexttoward 0.999999998 -Infinity -> 0.999999997
-nextt405 nexttoward 0.999999999 -Infinity -> 0.999999998
-nextt406 nexttoward 1.00000000 -Infinity -> 0.999999999
-nextt407 nexttoward 1.0 -Infinity -> 0.999999999
-nextt408 nexttoward 1 -Infinity -> 0.999999999
-nextt409 nexttoward 1.00000001 -Infinity -> 1.00000000
-nextt410 nexttoward 1.00000002 -Infinity -> 1.00000001
-nextt411 nexttoward 1.00000003 -Infinity -> 1.00000002
-nextt412 nexttoward 1.00000004 -Infinity -> 1.00000003
-nextt413 nexttoward 1.00000005 -Infinity -> 1.00000004
-nextt414 nexttoward 1.00000006 -Infinity -> 1.00000005
-nextt415 nexttoward 1.00000007 -Infinity -> 1.00000006
-nextt416 nexttoward 1.00000008 -Infinity -> 1.00000007
-nextt417 nexttoward 1.00000009 -Infinity -> 1.00000008
-nextt418 nexttoward 1.00000010 -Infinity -> 1.00000009
-nextt419 nexttoward 1.00000011 -Infinity -> 1.00000010
-nextt420 nexttoward 1.00000012 -Infinity -> 1.00000011
-
-nextt421 nexttoward -0.999999995 -Infinity -> -0.999999996
-nextt422 nexttoward -0.999999996 -Infinity -> -0.999999997
-nextt423 nexttoward -0.999999997 -Infinity -> -0.999999998
-nextt424 nexttoward -0.999999998 -Infinity -> -0.999999999
-nextt425 nexttoward -0.999999999 -Infinity -> -1.00000000
-nextt426 nexttoward -1.00000000 -Infinity -> -1.00000001
-nextt427 nexttoward -1.0 -Infinity -> -1.00000001
-nextt428 nexttoward -1 -Infinity -> -1.00000001
-nextt429 nexttoward -1.00000001 -Infinity -> -1.00000002
-nextt430 nexttoward -1.00000002 -Infinity -> -1.00000003
-nextt431 nexttoward -1.00000003 -Infinity -> -1.00000004
-nextt432 nexttoward -1.00000004 -Infinity -> -1.00000005
-nextt433 nexttoward -1.00000005 -Infinity -> -1.00000006
-nextt434 nexttoward -1.00000006 -Infinity -> -1.00000007
-nextt435 nexttoward -1.00000007 -Infinity -> -1.00000008
-nextt436 nexttoward -1.00000008 -Infinity -> -1.00000009
-nextt437 nexttoward -1.00000009 -Infinity -> -1.00000010
-nextt438 nexttoward -1.00000010 -Infinity -> -1.00000011
-nextt439 nexttoward -1.00000011 -Infinity -> -1.00000012
-
--- input operand is >precision
-nextt441 nexttoward 1.00000010998 -Infinity -> 1.00000010
-nextt442 nexttoward 1.00000010999 -Infinity -> 1.00000010
-nextt443 nexttoward 1.00000011000 -Infinity -> 1.00000010
-nextt444 nexttoward 1.00000011001 -Infinity -> 1.00000011
-nextt445 nexttoward 1.00000011002 -Infinity -> 1.00000011
-nextt446 nexttoward 1.00000011002 -Infinity -> 1.00000011
-nextt447 nexttoward 1.00000011052 -Infinity -> 1.00000011
-nextt448 nexttoward 1.00000011552 -Infinity -> 1.00000011
-nextt449 nexttoward -1.00000010998 -Infinity -> -1.00000011
-nextt450 nexttoward -1.00000010999 -Infinity -> -1.00000011
-nextt451 nexttoward -1.00000011000 -Infinity -> -1.00000012
-nextt452 nexttoward -1.00000011001 -Infinity -> -1.00000012
-nextt453 nexttoward -1.00000011002 -Infinity -> -1.00000012
-nextt454 nexttoward -1.00000011002 -Infinity -> -1.00000012
-nextt455 nexttoward -1.00000011052 -Infinity -> -1.00000012
-nextt456 nexttoward -1.00000011552 -Infinity -> -1.00000012
--- ultra-tiny inputs
-nextt460 nexttoward 1E-99999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt461 nexttoward 1E-999999999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt462 nexttoward 1E-391 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
-nextt463 nexttoward -1E-99999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt464 nexttoward -1E-999999999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt465 nexttoward -1E-391 -Infinity -> -2E-391 Underflow Subnormal Inexact Rounded
-
--- Zeros
-nextt500 nexttoward -0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt501 nexttoward 0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt502 nexttoward 0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt503 nexttoward -0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt504 nexttoward 0E-300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt505 nexttoward 0E+300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt506 nexttoward 0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt507 nexttoward -0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt508 nexttoward 0.00 -0.0000 -> -0.00
-
--- specials
-nextt550 nexttoward Inf -Infinity -> 9.99999999E+384
-nextt551 nexttoward -Inf -Infinity -> -Infinity
-nextt552 nexttoward NaN -Infinity -> NaN
-nextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
-nextt554 nexttoward NaN77 -Infinity -> NaN77
-nextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
-nextt556 nexttoward -NaN -Infinity -> -NaN
-nextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
-nextt558 nexttoward -NaN77 -Infinity -> -NaN77
-nextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
-
--- Nmax, Nmin, Ntiny, subnormals
-maxExponent: 999
-minexponent: -999
-nextt570 nexttoward 9.99999999E+999 -Infinity -> 9.99999998E+999
-nextt571 nexttoward 9.99999998E+999 -Infinity -> 9.99999997E+999
-nextt572 nexttoward 1E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt573 nexttoward 1.00000000E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
-nextt574 nexttoward 9E-1007 -Infinity -> 8E-1007 Underflow Subnormal Inexact Rounded
-nextt575 nexttoward 9.9E-1006 -Infinity -> 9.8E-1006 Underflow Subnormal Inexact Rounded
-nextt576 nexttoward 9.9999E-1003 -Infinity -> 9.9998E-1003 Underflow Subnormal Inexact Rounded
-nextt577 nexttoward 9.9999999E-1000 -Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
-nextt578 nexttoward 9.9999998E-1000 -Infinity -> 9.9999997E-1000 Underflow Subnormal Inexact Rounded
-nextt579 nexttoward 9.9999997E-1000 -Infinity -> 9.9999996E-1000 Underflow Subnormal Inexact Rounded
-nextt580 nexttoward 0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt581 nexttoward 1E-1007 -Infinity -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-nextt582 nexttoward 2E-1007 -Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
-
-nextt583 nexttoward -0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
-nextt584 nexttoward -1E-1007 -Infinity -> -2E-1007 Underflow Subnormal Inexact Rounded
-nextt585 nexttoward -2E-1007 -Infinity -> -3E-1007 Underflow Subnormal Inexact Rounded
-nextt586 nexttoward -10E-1007 -Infinity -> -1.1E-1006 Underflow Subnormal Inexact Rounded
-nextt587 nexttoward -100E-1007 -Infinity -> -1.01E-1005 Underflow Subnormal Inexact Rounded
-nextt588 nexttoward -100000E-1007 -Infinity -> -1.00001E-1002 Underflow Subnormal Inexact Rounded
-nextt589 nexttoward -1.0000E-999 -Infinity -> -1.00000001E-999
-nextt590 nexttoward -1.00000000E-999 -Infinity -> -1.00000001E-999
-nextt591 nexttoward -1E-999 -Infinity -> -1.00000001E-999
-nextt592 nexttoward -9.99999998E+999 -Infinity -> -9.99999999E+999
-nextt593 nexttoward -9.99999999E+999 -Infinity -> -Infinity Overflow Inexact Rounded
-
-
-
-
-------- Specials
-maxExponent: 384
-minexponent: -383
-nextt780 nexttoward -Inf -Inf -> -Infinity
-nextt781 nexttoward -Inf -1000 -> -9.99999999E+384
-nextt782 nexttoward -Inf -1 -> -9.99999999E+384
-nextt783 nexttoward -Inf -0 -> -9.99999999E+384
-nextt784 nexttoward -Inf 0 -> -9.99999999E+384
-nextt785 nexttoward -Inf 1 -> -9.99999999E+384
-nextt786 nexttoward -Inf 1000 -> -9.99999999E+384
-nextt787 nexttoward -1000 -Inf -> -1000.00001
-nextt788 nexttoward -Inf -Inf -> -Infinity
-nextt789 nexttoward -1 -Inf -> -1.00000001
-nextt790 nexttoward -0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt791 nexttoward 0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
-nextt792 nexttoward 1 -Inf -> 0.999999999
-nextt793 nexttoward 1000 -Inf -> 999.999999
-nextt794 nexttoward Inf -Inf -> 9.99999999E+384
-
-nextt800 nexttoward Inf -Inf -> 9.99999999E+384
-nextt801 nexttoward Inf -1000 -> 9.99999999E+384
-nextt802 nexttoward Inf -1 -> 9.99999999E+384
-nextt803 nexttoward Inf -0 -> 9.99999999E+384
-nextt804 nexttoward Inf 0 -> 9.99999999E+384
-nextt805 nexttoward Inf 1 -> 9.99999999E+384
-nextt806 nexttoward Inf 1000 -> 9.99999999E+384
-nextt807 nexttoward Inf Inf -> Infinity
-nextt808 nexttoward -1000 Inf -> -999.999999
-nextt809 nexttoward -Inf Inf -> -9.99999999E+384
-nextt810 nexttoward -1 Inf -> -0.999999999
-nextt811 nexttoward -0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt812 nexttoward 0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
-nextt813 nexttoward 1 Inf -> 1.00000001
-nextt814 nexttoward 1000 Inf -> 1000.00001
-nextt815 nexttoward Inf Inf -> Infinity
-
-nextt821 nexttoward NaN -Inf -> NaN
-nextt822 nexttoward NaN -1000 -> NaN
-nextt823 nexttoward NaN -1 -> NaN
-nextt824 nexttoward NaN -0 -> NaN
-nextt825 nexttoward NaN 0 -> NaN
-nextt826 nexttoward NaN 1 -> NaN
-nextt827 nexttoward NaN 1000 -> NaN
-nextt828 nexttoward NaN Inf -> NaN
-nextt829 nexttoward NaN NaN -> NaN
-nextt830 nexttoward -Inf NaN -> NaN
-nextt831 nexttoward -1000 NaN -> NaN
-nextt832 nexttoward -1 NaN -> NaN
-nextt833 nexttoward -0 NaN -> NaN
-nextt834 nexttoward 0 NaN -> NaN
-nextt835 nexttoward 1 NaN -> NaN
-nextt836 nexttoward 1000 NaN -> NaN
-nextt837 nexttoward Inf NaN -> NaN
-
-nextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
-nextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
-nextt843 nexttoward sNaN -1 -> NaN Invalid_operation
-nextt844 nexttoward sNaN -0 -> NaN Invalid_operation
-nextt845 nexttoward sNaN 0 -> NaN Invalid_operation
-nextt846 nexttoward sNaN 1 -> NaN Invalid_operation
-nextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
-nextt848 nexttoward sNaN NaN -> NaN Invalid_operation
-nextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
-nextt850 nexttoward NaN sNaN -> NaN Invalid_operation
-nextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
-nextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
-nextt853 nexttoward -1 sNaN -> NaN Invalid_operation
-nextt854 nexttoward -0 sNaN -> NaN Invalid_operation
-nextt855 nexttoward 0 sNaN -> NaN Invalid_operation
-nextt856 nexttoward 1 sNaN -> NaN Invalid_operation
-nextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
-nextt858 nexttoward Inf sNaN -> NaN Invalid_operation
-nextt859 nexttoward NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-nextt861 nexttoward NaN1 -Inf -> NaN1
-nextt862 nexttoward +NaN2 -1000 -> NaN2
-nextt863 nexttoward NaN3 1000 -> NaN3
-nextt864 nexttoward NaN4 Inf -> NaN4
-nextt865 nexttoward NaN5 +NaN6 -> NaN5
-nextt866 nexttoward -Inf NaN7 -> NaN7
-nextt867 nexttoward -1000 NaN8 -> NaN8
-nextt868 nexttoward 1000 NaN9 -> NaN9
-nextt869 nexttoward Inf +NaN10 -> NaN10
-nextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
-nextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
-nextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
-nextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
-nextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
-nextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
-nextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
-nextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
-nextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
-nextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
-nextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
-nextt882 nexttoward -NaN26 NaN28 -> -NaN26
-nextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-nextt884 nexttoward 1000 -NaN30 -> -NaN30
-nextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- Null tests
-nextt900 nexttoward 1 # -> NaN Invalid_operation
-nextt901 nexttoward # 1 -> NaN Invalid_operation
-
+------------------------------------------------------------------------
+-- nexttoward.decTest -- decimal next toward rhs [754r nextafter] --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 384
+minexponent: -383
+
+-- Sanity check with a scattering of numerics
+nextt001 nexttoward 10 10 -> 10
+nextt002 nexttoward -10 -10 -> -10
+nextt003 nexttoward 1 10 -> 1.00000001
+nextt004 nexttoward 1 -10 -> 0.999999999
+nextt005 nexttoward -1 10 -> -0.999999999
+nextt006 nexttoward -1 -10 -> -1.00000001
+nextt007 nexttoward 0 10 -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt008 nexttoward 0 -10 -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt009 nexttoward 9.99999999E+384 +Infinity -> Infinity Overflow Inexact Rounded
+nextt010 nexttoward -9.99999999E+384 -Infinity -> -Infinity Overflow Inexact Rounded
+
+------- lhs=rhs
+-- finites
+nextt101 nexttoward 7 7 -> 7
+nextt102 nexttoward -7 -7 -> -7
+nextt103 nexttoward 75 75 -> 75
+nextt104 nexttoward -75 -75 -> -75
+nextt105 nexttoward 7.50 7.5 -> 7.50
+nextt106 nexttoward -7.50 -7.50 -> -7.50
+nextt107 nexttoward 7.500 7.5000 -> 7.500
+nextt108 nexttoward -7.500 -7.5 -> -7.500
+
+-- zeros
+nextt111 nexttoward 0 0 -> 0
+nextt112 nexttoward -0 -0 -> -0
+nextt113 nexttoward 0E+4 0 -> 0E+4
+nextt114 nexttoward -0E+4 -0 -> -0E+4
+nextt115 nexttoward 0.0000 0.00000 -> 0.0000
+nextt116 nexttoward -0.0000 -0.00 -> -0.0000
+nextt117 nexttoward 0E-141 0 -> 0E-141
+nextt118 nexttoward -0E-141 -000 -> -0E-141
+
+-- full coefficients, alternating bits
+nextt121 nexttoward 268268268 268268268 -> 268268268
+nextt122 nexttoward -268268268 -268268268 -> -268268268
+nextt123 nexttoward 134134134 134134134 -> 134134134
+nextt124 nexttoward -134134134 -134134134 -> -134134134
+
+-- Nmax, Nmin, Ntiny
+nextt131 nexttoward 9.99999999E+384 9.99999999E+384 -> 9.99999999E+384
+nextt132 nexttoward 1E-383 1E-383 -> 1E-383
+nextt133 nexttoward 1.00000000E-383 1.00000000E-383 -> 1.00000000E-383
+nextt134 nexttoward 1E-391 1E-391 -> 1E-391
+
+nextt135 nexttoward -1E-391 -1E-391 -> -1E-391
+nextt136 nexttoward -1.00000000E-383 -1.00000000E-383 -> -1.00000000E-383
+nextt137 nexttoward -1E-383 -1E-383 -> -1E-383
+nextt138 nexttoward -9.99999999E+384 -9.99999999E+384 -> -9.99999999E+384
+
+------- lhs<rhs
+nextt201 nexttoward 0.999999995 Infinity -> 0.999999996
+nextt202 nexttoward 0.999999996 Infinity -> 0.999999997
+nextt203 nexttoward 0.999999997 Infinity -> 0.999999998
+nextt204 nexttoward 0.999999998 Infinity -> 0.999999999
+nextt205 nexttoward 0.999999999 Infinity -> 1.00000000
+nextt206 nexttoward 1.00000000 Infinity -> 1.00000001
+nextt207 nexttoward 1.0 Infinity -> 1.00000001
+nextt208 nexttoward 1 Infinity -> 1.00000001
+nextt209 nexttoward 1.00000001 Infinity -> 1.00000002
+nextt210 nexttoward 1.00000002 Infinity -> 1.00000003
+nextt211 nexttoward 1.00000003 Infinity -> 1.00000004
+nextt212 nexttoward 1.00000004 Infinity -> 1.00000005
+nextt213 nexttoward 1.00000005 Infinity -> 1.00000006
+nextt214 nexttoward 1.00000006 Infinity -> 1.00000007
+nextt215 nexttoward 1.00000007 Infinity -> 1.00000008
+nextt216 nexttoward 1.00000008 Infinity -> 1.00000009
+nextt217 nexttoward 1.00000009 Infinity -> 1.00000010
+nextt218 nexttoward 1.00000010 Infinity -> 1.00000011
+nextt219 nexttoward 1.00000011 Infinity -> 1.00000012
+
+nextt221 nexttoward -0.999999995 Infinity -> -0.999999994
+nextt222 nexttoward -0.999999996 Infinity -> -0.999999995
+nextt223 nexttoward -0.999999997 Infinity -> -0.999999996
+nextt224 nexttoward -0.999999998 Infinity -> -0.999999997
+nextt225 nexttoward -0.999999999 Infinity -> -0.999999998
+nextt226 nexttoward -1.00000000 Infinity -> -0.999999999
+nextt227 nexttoward -1.0 Infinity -> -0.999999999
+nextt228 nexttoward -1 Infinity -> -0.999999999
+nextt229 nexttoward -1.00000001 Infinity -> -1.00000000
+nextt230 nexttoward -1.00000002 Infinity -> -1.00000001
+nextt231 nexttoward -1.00000003 Infinity -> -1.00000002
+nextt232 nexttoward -1.00000004 Infinity -> -1.00000003
+nextt233 nexttoward -1.00000005 Infinity -> -1.00000004
+nextt234 nexttoward -1.00000006 Infinity -> -1.00000005
+nextt235 nexttoward -1.00000007 Infinity -> -1.00000006
+nextt236 nexttoward -1.00000008 Infinity -> -1.00000007
+nextt237 nexttoward -1.00000009 Infinity -> -1.00000008
+nextt238 nexttoward -1.00000010 Infinity -> -1.00000009
+nextt239 nexttoward -1.00000011 Infinity -> -1.00000010
+nextt240 nexttoward -1.00000012 Infinity -> -1.00000011
+
+-- input operand is >precision
+nextt241 nexttoward 1.00000010998 Infinity -> 1.00000011
+nextt242 nexttoward 1.00000010999 Infinity -> 1.00000011
+nextt243 nexttoward 1.00000011000 Infinity -> 1.00000012
+nextt244 nexttoward 1.00000011001 Infinity -> 1.00000012
+nextt245 nexttoward 1.00000011002 Infinity -> 1.00000012
+nextt246 nexttoward 1.00000011002 Infinity -> 1.00000012
+nextt247 nexttoward 1.00000011052 Infinity -> 1.00000012
+nextt248 nexttoward 1.00000011552 Infinity -> 1.00000012
+nextt249 nexttoward -1.00000010998 Infinity -> -1.00000010
+nextt250 nexttoward -1.00000010999 Infinity -> -1.00000010
+nextt251 nexttoward -1.00000011000 Infinity -> -1.00000010
+nextt252 nexttoward -1.00000011001 Infinity -> -1.00000011
+nextt253 nexttoward -1.00000011002 Infinity -> -1.00000011
+nextt254 nexttoward -1.00000011002 Infinity -> -1.00000011
+nextt255 nexttoward -1.00000011052 Infinity -> -1.00000011
+nextt256 nexttoward -1.00000011552 Infinity -> -1.00000011
+-- ultra-tiny inputs
+nextt260 nexttoward 1E-99999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt261 nexttoward 1E-999999999 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt262 nexttoward 1E-391 Infinity -> 2E-391 Underflow Subnormal Inexact Rounded
+nextt263 nexttoward -1E-99999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt264 nexttoward -1E-999999999 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt265 nexttoward -1E-391 Infinity -> -0E-391 Underflow Subnormal Inexact Rounded Clamped
+
+-- Zeros
+nextt300 nexttoward 0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt301 nexttoward 0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt302 nexttoward 0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt303 nexttoward 0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt304 nexttoward 0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt305 nexttoward -0 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt306 nexttoward -0.00 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt307 nexttoward -0E-300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt308 nexttoward -0E+300 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt309 nexttoward -0E+30000 Infinity -> 1E-391 Underflow Subnormal Inexact Rounded
+
+-- specials
+nextt350 nexttoward Inf Infinity -> Infinity
+nextt351 nexttoward -Inf Infinity -> -9.99999999E+384
+nextt352 nexttoward NaN Infinity -> NaN
+nextt353 nexttoward sNaN Infinity -> NaN Invalid_operation
+nextt354 nexttoward NaN77 Infinity -> NaN77
+nextt355 nexttoward sNaN88 Infinity -> NaN88 Invalid_operation
+nextt356 nexttoward -NaN Infinity -> -NaN
+nextt357 nexttoward -sNaN Infinity -> -NaN Invalid_operation
+nextt358 nexttoward -NaN77 Infinity -> -NaN77
+nextt359 nexttoward -sNaN88 Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+maxExponent: 999
+minexponent: -999
+nextt370 nexttoward 9.99999999E+999 Infinity -> Infinity Overflow Inexact Rounded
+nextt371 nexttoward 9.99999998E+999 Infinity -> 9.99999999E+999
+nextt372 nexttoward 1E-999 Infinity -> 1.00000001E-999
+nextt373 nexttoward 1.00000000E-999 Infinity -> 1.00000001E-999
+nextt374 nexttoward 0.999999999E-999 Infinity -> 1.00000000E-999
+nextt375 nexttoward 0.99999999E-999 Infinity -> 1.00000000E-999
+nextt376 nexttoward 9E-1007 Infinity -> 1.0E-1006 Underflow Subnormal Inexact Rounded
+nextt377 nexttoward 9.9E-1006 Infinity -> 1.00E-1005 Underflow Subnormal Inexact Rounded
+nextt378 nexttoward 9.9999E-1003 Infinity -> 1.00000E-1002 Underflow Subnormal Inexact Rounded
+nextt379 nexttoward 9.9999998E-1000 Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt380 nexttoward 9.9999997E-1000 Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
+nextt381 nexttoward 0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+nextt382 nexttoward 1E-1007 Infinity -> 2E-1007 Underflow Subnormal Inexact Rounded
+nextt383 nexttoward 2E-1007 Infinity -> 3E-1007 Underflow Subnormal Inexact Rounded
+
+nextt385 nexttoward -0E-1007 Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+nextt386 nexttoward -1E-1007 Infinity -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
+nextt387 nexttoward -2E-1007 Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt388 nexttoward -10E-1007 Infinity -> -9E-1007 Underflow Subnormal Inexact Rounded
+nextt389 nexttoward -100E-1007 Infinity -> -9.9E-1006 Underflow Subnormal Inexact Rounded
+nextt390 nexttoward -100000E-1007 Infinity -> -9.9999E-1003 Underflow Subnormal Inexact Rounded
+nextt391 nexttoward -1.0000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt392 nexttoward -1.00000000E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt393 nexttoward -1E-999 Infinity -> -9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt394 nexttoward -9.99999998E+999 Infinity -> -9.99999997E+999
+nextt395 nexttoward -9.99999999E+999 Infinity -> -9.99999998E+999
+
+------- lhs>rhs
+maxExponent: 384
+minexponent: -383
+nextt401 nexttoward 0.999999995 -Infinity -> 0.999999994
+nextt402 nexttoward 0.999999996 -Infinity -> 0.999999995
+nextt403 nexttoward 0.999999997 -Infinity -> 0.999999996
+nextt404 nexttoward 0.999999998 -Infinity -> 0.999999997
+nextt405 nexttoward 0.999999999 -Infinity -> 0.999999998
+nextt406 nexttoward 1.00000000 -Infinity -> 0.999999999
+nextt407 nexttoward 1.0 -Infinity -> 0.999999999
+nextt408 nexttoward 1 -Infinity -> 0.999999999
+nextt409 nexttoward 1.00000001 -Infinity -> 1.00000000
+nextt410 nexttoward 1.00000002 -Infinity -> 1.00000001
+nextt411 nexttoward 1.00000003 -Infinity -> 1.00000002
+nextt412 nexttoward 1.00000004 -Infinity -> 1.00000003
+nextt413 nexttoward 1.00000005 -Infinity -> 1.00000004
+nextt414 nexttoward 1.00000006 -Infinity -> 1.00000005
+nextt415 nexttoward 1.00000007 -Infinity -> 1.00000006
+nextt416 nexttoward 1.00000008 -Infinity -> 1.00000007
+nextt417 nexttoward 1.00000009 -Infinity -> 1.00000008
+nextt418 nexttoward 1.00000010 -Infinity -> 1.00000009
+nextt419 nexttoward 1.00000011 -Infinity -> 1.00000010
+nextt420 nexttoward 1.00000012 -Infinity -> 1.00000011
+
+nextt421 nexttoward -0.999999995 -Infinity -> -0.999999996
+nextt422 nexttoward -0.999999996 -Infinity -> -0.999999997
+nextt423 nexttoward -0.999999997 -Infinity -> -0.999999998
+nextt424 nexttoward -0.999999998 -Infinity -> -0.999999999
+nextt425 nexttoward -0.999999999 -Infinity -> -1.00000000
+nextt426 nexttoward -1.00000000 -Infinity -> -1.00000001
+nextt427 nexttoward -1.0 -Infinity -> -1.00000001
+nextt428 nexttoward -1 -Infinity -> -1.00000001
+nextt429 nexttoward -1.00000001 -Infinity -> -1.00000002
+nextt430 nexttoward -1.00000002 -Infinity -> -1.00000003
+nextt431 nexttoward -1.00000003 -Infinity -> -1.00000004
+nextt432 nexttoward -1.00000004 -Infinity -> -1.00000005
+nextt433 nexttoward -1.00000005 -Infinity -> -1.00000006
+nextt434 nexttoward -1.00000006 -Infinity -> -1.00000007
+nextt435 nexttoward -1.00000007 -Infinity -> -1.00000008
+nextt436 nexttoward -1.00000008 -Infinity -> -1.00000009
+nextt437 nexttoward -1.00000009 -Infinity -> -1.00000010
+nextt438 nexttoward -1.00000010 -Infinity -> -1.00000011
+nextt439 nexttoward -1.00000011 -Infinity -> -1.00000012
+
+-- input operand is >precision
+nextt441 nexttoward 1.00000010998 -Infinity -> 1.00000010
+nextt442 nexttoward 1.00000010999 -Infinity -> 1.00000010
+nextt443 nexttoward 1.00000011000 -Infinity -> 1.00000010
+nextt444 nexttoward 1.00000011001 -Infinity -> 1.00000011
+nextt445 nexttoward 1.00000011002 -Infinity -> 1.00000011
+nextt446 nexttoward 1.00000011002 -Infinity -> 1.00000011
+nextt447 nexttoward 1.00000011052 -Infinity -> 1.00000011
+nextt448 nexttoward 1.00000011552 -Infinity -> 1.00000011
+nextt449 nexttoward -1.00000010998 -Infinity -> -1.00000011
+nextt450 nexttoward -1.00000010999 -Infinity -> -1.00000011
+nextt451 nexttoward -1.00000011000 -Infinity -> -1.00000012
+nextt452 nexttoward -1.00000011001 -Infinity -> -1.00000012
+nextt453 nexttoward -1.00000011002 -Infinity -> -1.00000012
+nextt454 nexttoward -1.00000011002 -Infinity -> -1.00000012
+nextt455 nexttoward -1.00000011052 -Infinity -> -1.00000012
+nextt456 nexttoward -1.00000011552 -Infinity -> -1.00000012
+-- ultra-tiny inputs
+nextt460 nexttoward 1E-99999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt461 nexttoward 1E-999999999 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt462 nexttoward 1E-391 -Infinity -> 0E-391 Underflow Subnormal Inexact Rounded Clamped
+nextt463 nexttoward -1E-99999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt464 nexttoward -1E-999999999 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt465 nexttoward -1E-391 -Infinity -> -2E-391 Underflow Subnormal Inexact Rounded
+
+-- Zeros
+nextt500 nexttoward -0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt501 nexttoward 0 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt502 nexttoward 0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt503 nexttoward -0.00 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt504 nexttoward 0E-300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt505 nexttoward 0E+300 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt506 nexttoward 0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt507 nexttoward -0E+30000 -Infinity -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt508 nexttoward 0.00 -0.0000 -> -0.00
+
+-- specials
+nextt550 nexttoward Inf -Infinity -> 9.99999999E+384
+nextt551 nexttoward -Inf -Infinity -> -Infinity
+nextt552 nexttoward NaN -Infinity -> NaN
+nextt553 nexttoward sNaN -Infinity -> NaN Invalid_operation
+nextt554 nexttoward NaN77 -Infinity -> NaN77
+nextt555 nexttoward sNaN88 -Infinity -> NaN88 Invalid_operation
+nextt556 nexttoward -NaN -Infinity -> -NaN
+nextt557 nexttoward -sNaN -Infinity -> -NaN Invalid_operation
+nextt558 nexttoward -NaN77 -Infinity -> -NaN77
+nextt559 nexttoward -sNaN88 -Infinity -> -NaN88 Invalid_operation
+
+-- Nmax, Nmin, Ntiny, subnormals
+maxExponent: 999
+minexponent: -999
+nextt570 nexttoward 9.99999999E+999 -Infinity -> 9.99999998E+999
+nextt571 nexttoward 9.99999998E+999 -Infinity -> 9.99999997E+999
+nextt572 nexttoward 1E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt573 nexttoward 1.00000000E-999 -Infinity -> 9.9999999E-1000 Underflow Subnormal Inexact Rounded
+nextt574 nexttoward 9E-1007 -Infinity -> 8E-1007 Underflow Subnormal Inexact Rounded
+nextt575 nexttoward 9.9E-1006 -Infinity -> 9.8E-1006 Underflow Subnormal Inexact Rounded
+nextt576 nexttoward 9.9999E-1003 -Infinity -> 9.9998E-1003 Underflow Subnormal Inexact Rounded
+nextt577 nexttoward 9.9999999E-1000 -Infinity -> 9.9999998E-1000 Underflow Subnormal Inexact Rounded
+nextt578 nexttoward 9.9999998E-1000 -Infinity -> 9.9999997E-1000 Underflow Subnormal Inexact Rounded
+nextt579 nexttoward 9.9999997E-1000 -Infinity -> 9.9999996E-1000 Underflow Subnormal Inexact Rounded
+nextt580 nexttoward 0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt581 nexttoward 1E-1007 -Infinity -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+nextt582 nexttoward 2E-1007 -Infinity -> 1E-1007 Underflow Subnormal Inexact Rounded
+
+nextt583 nexttoward -0E-1007 -Infinity -> -1E-1007 Underflow Subnormal Inexact Rounded
+nextt584 nexttoward -1E-1007 -Infinity -> -2E-1007 Underflow Subnormal Inexact Rounded
+nextt585 nexttoward -2E-1007 -Infinity -> -3E-1007 Underflow Subnormal Inexact Rounded
+nextt586 nexttoward -10E-1007 -Infinity -> -1.1E-1006 Underflow Subnormal Inexact Rounded
+nextt587 nexttoward -100E-1007 -Infinity -> -1.01E-1005 Underflow Subnormal Inexact Rounded
+nextt588 nexttoward -100000E-1007 -Infinity -> -1.00001E-1002 Underflow Subnormal Inexact Rounded
+nextt589 nexttoward -1.0000E-999 -Infinity -> -1.00000001E-999
+nextt590 nexttoward -1.00000000E-999 -Infinity -> -1.00000001E-999
+nextt591 nexttoward -1E-999 -Infinity -> -1.00000001E-999
+nextt592 nexttoward -9.99999998E+999 -Infinity -> -9.99999999E+999
+nextt593 nexttoward -9.99999999E+999 -Infinity -> -Infinity Overflow Inexact Rounded
+
+
+
+
+------- Specials
+maxExponent: 384
+minexponent: -383
+nextt780 nexttoward -Inf -Inf -> -Infinity
+nextt781 nexttoward -Inf -1000 -> -9.99999999E+384
+nextt782 nexttoward -Inf -1 -> -9.99999999E+384
+nextt783 nexttoward -Inf -0 -> -9.99999999E+384
+nextt784 nexttoward -Inf 0 -> -9.99999999E+384
+nextt785 nexttoward -Inf 1 -> -9.99999999E+384
+nextt786 nexttoward -Inf 1000 -> -9.99999999E+384
+nextt787 nexttoward -1000 -Inf -> -1000.00001
+nextt788 nexttoward -Inf -Inf -> -Infinity
+nextt789 nexttoward -1 -Inf -> -1.00000001
+nextt790 nexttoward -0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt791 nexttoward 0 -Inf -> -1E-391 Underflow Subnormal Inexact Rounded
+nextt792 nexttoward 1 -Inf -> 0.999999999
+nextt793 nexttoward 1000 -Inf -> 999.999999
+nextt794 nexttoward Inf -Inf -> 9.99999999E+384
+
+nextt800 nexttoward Inf -Inf -> 9.99999999E+384
+nextt801 nexttoward Inf -1000 -> 9.99999999E+384
+nextt802 nexttoward Inf -1 -> 9.99999999E+384
+nextt803 nexttoward Inf -0 -> 9.99999999E+384
+nextt804 nexttoward Inf 0 -> 9.99999999E+384
+nextt805 nexttoward Inf 1 -> 9.99999999E+384
+nextt806 nexttoward Inf 1000 -> 9.99999999E+384
+nextt807 nexttoward Inf Inf -> Infinity
+nextt808 nexttoward -1000 Inf -> -999.999999
+nextt809 nexttoward -Inf Inf -> -9.99999999E+384
+nextt810 nexttoward -1 Inf -> -0.999999999
+nextt811 nexttoward -0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt812 nexttoward 0 Inf -> 1E-391 Underflow Subnormal Inexact Rounded
+nextt813 nexttoward 1 Inf -> 1.00000001
+nextt814 nexttoward 1000 Inf -> 1000.00001
+nextt815 nexttoward Inf Inf -> Infinity
+
+nextt821 nexttoward NaN -Inf -> NaN
+nextt822 nexttoward NaN -1000 -> NaN
+nextt823 nexttoward NaN -1 -> NaN
+nextt824 nexttoward NaN -0 -> NaN
+nextt825 nexttoward NaN 0 -> NaN
+nextt826 nexttoward NaN 1 -> NaN
+nextt827 nexttoward NaN 1000 -> NaN
+nextt828 nexttoward NaN Inf -> NaN
+nextt829 nexttoward NaN NaN -> NaN
+nextt830 nexttoward -Inf NaN -> NaN
+nextt831 nexttoward -1000 NaN -> NaN
+nextt832 nexttoward -1 NaN -> NaN
+nextt833 nexttoward -0 NaN -> NaN
+nextt834 nexttoward 0 NaN -> NaN
+nextt835 nexttoward 1 NaN -> NaN
+nextt836 nexttoward 1000 NaN -> NaN
+nextt837 nexttoward Inf NaN -> NaN
+
+nextt841 nexttoward sNaN -Inf -> NaN Invalid_operation
+nextt842 nexttoward sNaN -1000 -> NaN Invalid_operation
+nextt843 nexttoward sNaN -1 -> NaN Invalid_operation
+nextt844 nexttoward sNaN -0 -> NaN Invalid_operation
+nextt845 nexttoward sNaN 0 -> NaN Invalid_operation
+nextt846 nexttoward sNaN 1 -> NaN Invalid_operation
+nextt847 nexttoward sNaN 1000 -> NaN Invalid_operation
+nextt848 nexttoward sNaN NaN -> NaN Invalid_operation
+nextt849 nexttoward sNaN sNaN -> NaN Invalid_operation
+nextt850 nexttoward NaN sNaN -> NaN Invalid_operation
+nextt851 nexttoward -Inf sNaN -> NaN Invalid_operation
+nextt852 nexttoward -1000 sNaN -> NaN Invalid_operation
+nextt853 nexttoward -1 sNaN -> NaN Invalid_operation
+nextt854 nexttoward -0 sNaN -> NaN Invalid_operation
+nextt855 nexttoward 0 sNaN -> NaN Invalid_operation
+nextt856 nexttoward 1 sNaN -> NaN Invalid_operation
+nextt857 nexttoward 1000 sNaN -> NaN Invalid_operation
+nextt858 nexttoward Inf sNaN -> NaN Invalid_operation
+nextt859 nexttoward NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+nextt861 nexttoward NaN1 -Inf -> NaN1
+nextt862 nexttoward +NaN2 -1000 -> NaN2
+nextt863 nexttoward NaN3 1000 -> NaN3
+nextt864 nexttoward NaN4 Inf -> NaN4
+nextt865 nexttoward NaN5 +NaN6 -> NaN5
+nextt866 nexttoward -Inf NaN7 -> NaN7
+nextt867 nexttoward -1000 NaN8 -> NaN8
+nextt868 nexttoward 1000 NaN9 -> NaN9
+nextt869 nexttoward Inf +NaN10 -> NaN10
+nextt871 nexttoward sNaN11 -Inf -> NaN11 Invalid_operation
+nextt872 nexttoward sNaN12 -1000 -> NaN12 Invalid_operation
+nextt873 nexttoward sNaN13 1000 -> NaN13 Invalid_operation
+nextt874 nexttoward sNaN14 NaN17 -> NaN14 Invalid_operation
+nextt875 nexttoward sNaN15 sNaN18 -> NaN15 Invalid_operation
+nextt876 nexttoward NaN16 sNaN19 -> NaN19 Invalid_operation
+nextt877 nexttoward -Inf +sNaN20 -> NaN20 Invalid_operation
+nextt878 nexttoward -1000 sNaN21 -> NaN21 Invalid_operation
+nextt879 nexttoward 1000 sNaN22 -> NaN22 Invalid_operation
+nextt880 nexttoward Inf sNaN23 -> NaN23 Invalid_operation
+nextt881 nexttoward +NaN25 +sNaN24 -> NaN24 Invalid_operation
+nextt882 nexttoward -NaN26 NaN28 -> -NaN26
+nextt883 nexttoward -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+nextt884 nexttoward 1000 -NaN30 -> -NaN30
+nextt885 nexttoward 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- Null tests
+nextt900 nexttoward 1 # -> NaN Invalid_operation
+nextt901 nexttoward # 1 -> NaN Invalid_operation
+
diff --git a/Lib/test/decimaltestdata/or.decTest b/Lib/test/decimaltestdata/or.decTest
index 1aebff4e001..f471d0b6ced 100644
--- a/Lib/test/decimaltestdata/or.decTest
+++ b/Lib/test/decimaltestdata/or.decTest
@@ -1,334 +1,334 @@
-------------------------------------------------------------------------
--- or.decTest -- digitwise logical OR --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-orx001 or 0 0 -> 0
-orx002 or 0 1 -> 1
-orx003 or 1 0 -> 1
-orx004 or 1 1 -> 1
-orx005 or 1100 1010 -> 1110
--- and at msd and msd-1
-orx006 or 000000000 000000000 -> 0
-orx007 or 000000000 100000000 -> 100000000
-orx008 or 100000000 000000000 -> 100000000
-orx009 or 100000000 100000000 -> 100000000
-orx010 or 000000000 000000000 -> 0
-orx011 or 000000000 010000000 -> 10000000
-orx012 or 010000000 000000000 -> 10000000
-orx013 or 010000000 010000000 -> 10000000
-
--- Various lengths
--- 123456789 123456789 123456789
-orx021 or 111111111 111111111 -> 111111111
-orx022 or 111111111111 111111111 -> 111111111
-orx023 or 11111111 11111111 -> 11111111
-orx025 or 1111111 1111111 -> 1111111
-orx026 or 111111 111111 -> 111111
-orx027 or 11111 11111 -> 11111
-orx028 or 1111 1111 -> 1111
-orx029 or 111 111 -> 111
-orx031 or 11 11 -> 11
-orx032 or 1 1 -> 1
-orx033 or 111111111111 1111111111 -> 111111111
-orx034 or 11111111111 11111111111 -> 111111111
-orx035 or 1111111111 111111111111 -> 111111111
-orx036 or 111111111 1111111111111 -> 111111111
-
-orx040 or 111111111 111111111111 -> 111111111
-orx041 or 11111111 111111111111 -> 111111111
-orx042 or 11111111 111111111 -> 111111111
-orx043 or 1111111 100000010 -> 101111111
-orx044 or 111111 100000100 -> 100111111
-orx045 or 11111 100001000 -> 100011111
-orx046 or 1111 100010000 -> 100011111
-orx047 or 111 100100000 -> 100100111
-orx048 or 11 101000000 -> 101000011
-orx049 or 1 110000000 -> 110000001
-
-orx050 or 1111111111 1 -> 111111111
-orx051 or 111111111 1 -> 111111111
-orx052 or 11111111 1 -> 11111111
-orx053 or 1111111 1 -> 1111111
-orx054 or 111111 1 -> 111111
-orx055 or 11111 1 -> 11111
-orx056 or 1111 1 -> 1111
-orx057 or 111 1 -> 111
-orx058 or 11 1 -> 11
-orx059 or 1 1 -> 1
-
-orx060 or 1111111111 0 -> 111111111
-orx061 or 111111111 0 -> 111111111
-orx062 or 11111111 0 -> 11111111
-orx063 or 1111111 0 -> 1111111
-orx064 or 111111 0 -> 111111
-orx065 or 11111 0 -> 11111
-orx066 or 1111 0 -> 1111
-orx067 or 111 0 -> 111
-orx068 or 11 0 -> 11
-orx069 or 1 0 -> 1
-
-orx070 or 1 1111111111 -> 111111111
-orx071 or 1 111111111 -> 111111111
-orx072 or 1 11111111 -> 11111111
-orx073 or 1 1111111 -> 1111111
-orx074 or 1 111111 -> 111111
-orx075 or 1 11111 -> 11111
-orx076 or 1 1111 -> 1111
-orx077 or 1 111 -> 111
-orx078 or 1 11 -> 11
-orx079 or 1 1 -> 1
-
-orx080 or 0 1111111111 -> 111111111
-orx081 or 0 111111111 -> 111111111
-orx082 or 0 11111111 -> 11111111
-orx083 or 0 1111111 -> 1111111
-orx084 or 0 111111 -> 111111
-orx085 or 0 11111 -> 11111
-orx086 or 0 1111 -> 1111
-orx087 or 0 111 -> 111
-orx088 or 0 11 -> 11
-orx089 or 0 1 -> 1
-
-orx090 or 011111111 111101111 -> 111111111
-orx091 or 101111111 111101111 -> 111111111
-orx092 or 110111111 111101111 -> 111111111
-orx093 or 111011111 111101111 -> 111111111
-orx094 or 111101111 111101111 -> 111101111
-orx095 or 111110111 111101111 -> 111111111
-orx096 or 111111011 111101111 -> 111111111
-orx097 or 111111101 111101111 -> 111111111
-orx098 or 111111110 111101111 -> 111111111
-
-orx100 or 111101111 011111111 -> 111111111
-orx101 or 111101111 101111111 -> 111111111
-orx102 or 111101111 110111111 -> 111111111
-orx103 or 111101111 111011111 -> 111111111
-orx104 or 111101111 111101111 -> 111101111
-orx105 or 111101111 111110111 -> 111111111
-orx106 or 111101111 111111011 -> 111111111
-orx107 or 111101111 111111101 -> 111111111
-orx108 or 111101111 111111110 -> 111111111
-
--- non-0/1 should not be accepted, nor should signs
-orx220 or 111111112 111111111 -> NaN Invalid_operation
-orx221 or 333333333 333333333 -> NaN Invalid_operation
-orx222 or 555555555 555555555 -> NaN Invalid_operation
-orx223 or 777777777 777777777 -> NaN Invalid_operation
-orx224 or 999999999 999999999 -> NaN Invalid_operation
-orx225 or 222222222 999999999 -> NaN Invalid_operation
-orx226 or 444444444 999999999 -> NaN Invalid_operation
-orx227 or 666666666 999999999 -> NaN Invalid_operation
-orx228 or 888888888 999999999 -> NaN Invalid_operation
-orx229 or 999999999 222222222 -> NaN Invalid_operation
-orx230 or 999999999 444444444 -> NaN Invalid_operation
-orx231 or 999999999 666666666 -> NaN Invalid_operation
-orx232 or 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-orx240 or 567468689 -934981942 -> NaN Invalid_operation
-orx241 or 567367689 934981942 -> NaN Invalid_operation
-orx242 or -631917772 -706014634 -> NaN Invalid_operation
-orx243 or -756253257 138579234 -> NaN Invalid_operation
-orx244 or 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-orx250 or 200000000 100000000 -> NaN Invalid_operation
-orx251 or 700000000 100000000 -> NaN Invalid_operation
-orx252 or 800000000 100000000 -> NaN Invalid_operation
-orx253 or 900000000 100000000 -> NaN Invalid_operation
-orx254 or 200000000 000000000 -> NaN Invalid_operation
-orx255 or 700000000 000000000 -> NaN Invalid_operation
-orx256 or 800000000 000000000 -> NaN Invalid_operation
-orx257 or 900000000 000000000 -> NaN Invalid_operation
-orx258 or 100000000 200000000 -> NaN Invalid_operation
-orx259 or 100000000 700000000 -> NaN Invalid_operation
-orx260 or 100000000 800000000 -> NaN Invalid_operation
-orx261 or 100000000 900000000 -> NaN Invalid_operation
-orx262 or 000000000 200000000 -> NaN Invalid_operation
-orx263 or 000000000 700000000 -> NaN Invalid_operation
-orx264 or 000000000 800000000 -> NaN Invalid_operation
-orx265 or 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-orx270 or 020000000 100000000 -> NaN Invalid_operation
-orx271 or 070100000 100000000 -> NaN Invalid_operation
-orx272 or 080010000 100000001 -> NaN Invalid_operation
-orx273 or 090001000 100000010 -> NaN Invalid_operation
-orx274 or 100000100 020010100 -> NaN Invalid_operation
-orx275 or 100000000 070001000 -> NaN Invalid_operation
-orx276 or 100000010 080010100 -> NaN Invalid_operation
-orx277 or 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-orx280 or 001000002 100000000 -> NaN Invalid_operation
-orx281 or 000000007 100000000 -> NaN Invalid_operation
-orx282 or 000000008 100000000 -> NaN Invalid_operation
-orx283 or 000000009 100000000 -> NaN Invalid_operation
-orx284 or 100000000 000100002 -> NaN Invalid_operation
-orx285 or 100100000 001000007 -> NaN Invalid_operation
-orx286 or 100010000 010000008 -> NaN Invalid_operation
-orx287 or 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-orx288 or 001020000 100000000 -> NaN Invalid_operation
-orx289 or 000070001 100000000 -> NaN Invalid_operation
-orx290 or 000080000 100010000 -> NaN Invalid_operation
-orx291 or 000090000 100001000 -> NaN Invalid_operation
-orx292 or 100000010 000020100 -> NaN Invalid_operation
-orx293 or 100100000 000070010 -> NaN Invalid_operation
-orx294 or 100010100 000080001 -> NaN Invalid_operation
-orx295 or 100001000 000090000 -> NaN Invalid_operation
--- signs
-orx296 or -100001000 -000000000 -> NaN Invalid_operation
-orx297 or -100001000 000010000 -> NaN Invalid_operation
-orx298 or 100001000 -000000000 -> NaN Invalid_operation
-orx299 or 100001000 000011000 -> 100011000
-
--- Nmax, Nmin, Ntiny
-orx331 or 2 9.99999999E+999 -> NaN Invalid_operation
-orx332 or 3 1E-999 -> NaN Invalid_operation
-orx333 or 4 1.00000000E-999 -> NaN Invalid_operation
-orx334 or 5 1E-1007 -> NaN Invalid_operation
-orx335 or 6 -1E-1007 -> NaN Invalid_operation
-orx336 or 7 -1.00000000E-999 -> NaN Invalid_operation
-orx337 or 8 -1E-999 -> NaN Invalid_operation
-orx338 or 9 -9.99999999E+999 -> NaN Invalid_operation
-orx341 or 9.99999999E+999 -18 -> NaN Invalid_operation
-orx342 or 1E-999 01 -> NaN Invalid_operation
-orx343 or 1.00000000E-999 -18 -> NaN Invalid_operation
-orx344 or 1E-1007 18 -> NaN Invalid_operation
-orx345 or -1E-1007 -10 -> NaN Invalid_operation
-orx346 or -1.00000000E-999 18 -> NaN Invalid_operation
-orx347 or -1E-999 10 -> NaN Invalid_operation
-orx348 or -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-orx361 or 1.0 1 -> NaN Invalid_operation
-orx362 or 1E+1 1 -> NaN Invalid_operation
-orx363 or 0.0 1 -> NaN Invalid_operation
-orx364 or 0E+1 1 -> NaN Invalid_operation
-orx365 or 9.9 1 -> NaN Invalid_operation
-orx366 or 9E+1 1 -> NaN Invalid_operation
-orx371 or 0 1.0 -> NaN Invalid_operation
-orx372 or 0 1E+1 -> NaN Invalid_operation
-orx373 or 0 0.0 -> NaN Invalid_operation
-orx374 or 0 0E+1 -> NaN Invalid_operation
-orx375 or 0 9.9 -> NaN Invalid_operation
-orx376 or 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-orx780 or -Inf -Inf -> NaN Invalid_operation
-orx781 or -Inf -1000 -> NaN Invalid_operation
-orx782 or -Inf -1 -> NaN Invalid_operation
-orx783 or -Inf -0 -> NaN Invalid_operation
-orx784 or -Inf 0 -> NaN Invalid_operation
-orx785 or -Inf 1 -> NaN Invalid_operation
-orx786 or -Inf 1000 -> NaN Invalid_operation
-orx787 or -1000 -Inf -> NaN Invalid_operation
-orx788 or -Inf -Inf -> NaN Invalid_operation
-orx789 or -1 -Inf -> NaN Invalid_operation
-orx790 or -0 -Inf -> NaN Invalid_operation
-orx791 or 0 -Inf -> NaN Invalid_operation
-orx792 or 1 -Inf -> NaN Invalid_operation
-orx793 or 1000 -Inf -> NaN Invalid_operation
-orx794 or Inf -Inf -> NaN Invalid_operation
-
-orx800 or Inf -Inf -> NaN Invalid_operation
-orx801 or Inf -1000 -> NaN Invalid_operation
-orx802 or Inf -1 -> NaN Invalid_operation
-orx803 or Inf -0 -> NaN Invalid_operation
-orx804 or Inf 0 -> NaN Invalid_operation
-orx805 or Inf 1 -> NaN Invalid_operation
-orx806 or Inf 1000 -> NaN Invalid_operation
-orx807 or Inf Inf -> NaN Invalid_operation
-orx808 or -1000 Inf -> NaN Invalid_operation
-orx809 or -Inf Inf -> NaN Invalid_operation
-orx810 or -1 Inf -> NaN Invalid_operation
-orx811 or -0 Inf -> NaN Invalid_operation
-orx812 or 0 Inf -> NaN Invalid_operation
-orx813 or 1 Inf -> NaN Invalid_operation
-orx814 or 1000 Inf -> NaN Invalid_operation
-orx815 or Inf Inf -> NaN Invalid_operation
-
-orx821 or NaN -Inf -> NaN Invalid_operation
-orx822 or NaN -1000 -> NaN Invalid_operation
-orx823 or NaN -1 -> NaN Invalid_operation
-orx824 or NaN -0 -> NaN Invalid_operation
-orx825 or NaN 0 -> NaN Invalid_operation
-orx826 or NaN 1 -> NaN Invalid_operation
-orx827 or NaN 1000 -> NaN Invalid_operation
-orx828 or NaN Inf -> NaN Invalid_operation
-orx829 or NaN NaN -> NaN Invalid_operation
-orx830 or -Inf NaN -> NaN Invalid_operation
-orx831 or -1000 NaN -> NaN Invalid_operation
-orx832 or -1 NaN -> NaN Invalid_operation
-orx833 or -0 NaN -> NaN Invalid_operation
-orx834 or 0 NaN -> NaN Invalid_operation
-orx835 or 1 NaN -> NaN Invalid_operation
-orx836 or 1000 NaN -> NaN Invalid_operation
-orx837 or Inf NaN -> NaN Invalid_operation
-
-orx841 or sNaN -Inf -> NaN Invalid_operation
-orx842 or sNaN -1000 -> NaN Invalid_operation
-orx843 or sNaN -1 -> NaN Invalid_operation
-orx844 or sNaN -0 -> NaN Invalid_operation
-orx845 or sNaN 0 -> NaN Invalid_operation
-orx846 or sNaN 1 -> NaN Invalid_operation
-orx847 or sNaN 1000 -> NaN Invalid_operation
-orx848 or sNaN NaN -> NaN Invalid_operation
-orx849 or sNaN sNaN -> NaN Invalid_operation
-orx850 or NaN sNaN -> NaN Invalid_operation
-orx851 or -Inf sNaN -> NaN Invalid_operation
-orx852 or -1000 sNaN -> NaN Invalid_operation
-orx853 or -1 sNaN -> NaN Invalid_operation
-orx854 or -0 sNaN -> NaN Invalid_operation
-orx855 or 0 sNaN -> NaN Invalid_operation
-orx856 or 1 sNaN -> NaN Invalid_operation
-orx857 or 1000 sNaN -> NaN Invalid_operation
-orx858 or Inf sNaN -> NaN Invalid_operation
-orx859 or NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-orx861 or NaN1 -Inf -> NaN Invalid_operation
-orx862 or +NaN2 -1000 -> NaN Invalid_operation
-orx863 or NaN3 1000 -> NaN Invalid_operation
-orx864 or NaN4 Inf -> NaN Invalid_operation
-orx865 or NaN5 +NaN6 -> NaN Invalid_operation
-orx866 or -Inf NaN7 -> NaN Invalid_operation
-orx867 or -1000 NaN8 -> NaN Invalid_operation
-orx868 or 1000 NaN9 -> NaN Invalid_operation
-orx869 or Inf +NaN10 -> NaN Invalid_operation
-orx871 or sNaN11 -Inf -> NaN Invalid_operation
-orx872 or sNaN12 -1000 -> NaN Invalid_operation
-orx873 or sNaN13 1000 -> NaN Invalid_operation
-orx874 or sNaN14 NaN17 -> NaN Invalid_operation
-orx875 or sNaN15 sNaN18 -> NaN Invalid_operation
-orx876 or NaN16 sNaN19 -> NaN Invalid_operation
-orx877 or -Inf +sNaN20 -> NaN Invalid_operation
-orx878 or -1000 sNaN21 -> NaN Invalid_operation
-orx879 or 1000 sNaN22 -> NaN Invalid_operation
-orx880 or Inf sNaN23 -> NaN Invalid_operation
-orx881 or +NaN25 +sNaN24 -> NaN Invalid_operation
-orx882 or -NaN26 NaN28 -> NaN Invalid_operation
-orx883 or -sNaN27 sNaN29 -> NaN Invalid_operation
-orx884 or 1000 -NaN30 -> NaN Invalid_operation
-orx885 or 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- or.decTest -- digitwise logical OR --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+orx001 or 0 0 -> 0
+orx002 or 0 1 -> 1
+orx003 or 1 0 -> 1
+orx004 or 1 1 -> 1
+orx005 or 1100 1010 -> 1110
+-- and at msd and msd-1
+orx006 or 000000000 000000000 -> 0
+orx007 or 000000000 100000000 -> 100000000
+orx008 or 100000000 000000000 -> 100000000
+orx009 or 100000000 100000000 -> 100000000
+orx010 or 000000000 000000000 -> 0
+orx011 or 000000000 010000000 -> 10000000
+orx012 or 010000000 000000000 -> 10000000
+orx013 or 010000000 010000000 -> 10000000
+
+-- Various lengths
+-- 123456789 123456789 123456789
+orx021 or 111111111 111111111 -> 111111111
+orx022 or 111111111111 111111111 -> 111111111
+orx023 or 11111111 11111111 -> 11111111
+orx025 or 1111111 1111111 -> 1111111
+orx026 or 111111 111111 -> 111111
+orx027 or 11111 11111 -> 11111
+orx028 or 1111 1111 -> 1111
+orx029 or 111 111 -> 111
+orx031 or 11 11 -> 11
+orx032 or 1 1 -> 1
+orx033 or 111111111111 1111111111 -> 111111111
+orx034 or 11111111111 11111111111 -> 111111111
+orx035 or 1111111111 111111111111 -> 111111111
+orx036 or 111111111 1111111111111 -> 111111111
+
+orx040 or 111111111 111111111111 -> 111111111
+orx041 or 11111111 111111111111 -> 111111111
+orx042 or 11111111 111111111 -> 111111111
+orx043 or 1111111 100000010 -> 101111111
+orx044 or 111111 100000100 -> 100111111
+orx045 or 11111 100001000 -> 100011111
+orx046 or 1111 100010000 -> 100011111
+orx047 or 111 100100000 -> 100100111
+orx048 or 11 101000000 -> 101000011
+orx049 or 1 110000000 -> 110000001
+
+orx050 or 1111111111 1 -> 111111111
+orx051 or 111111111 1 -> 111111111
+orx052 or 11111111 1 -> 11111111
+orx053 or 1111111 1 -> 1111111
+orx054 or 111111 1 -> 111111
+orx055 or 11111 1 -> 11111
+orx056 or 1111 1 -> 1111
+orx057 or 111 1 -> 111
+orx058 or 11 1 -> 11
+orx059 or 1 1 -> 1
+
+orx060 or 1111111111 0 -> 111111111
+orx061 or 111111111 0 -> 111111111
+orx062 or 11111111 0 -> 11111111
+orx063 or 1111111 0 -> 1111111
+orx064 or 111111 0 -> 111111
+orx065 or 11111 0 -> 11111
+orx066 or 1111 0 -> 1111
+orx067 or 111 0 -> 111
+orx068 or 11 0 -> 11
+orx069 or 1 0 -> 1
+
+orx070 or 1 1111111111 -> 111111111
+orx071 or 1 111111111 -> 111111111
+orx072 or 1 11111111 -> 11111111
+orx073 or 1 1111111 -> 1111111
+orx074 or 1 111111 -> 111111
+orx075 or 1 11111 -> 11111
+orx076 or 1 1111 -> 1111
+orx077 or 1 111 -> 111
+orx078 or 1 11 -> 11
+orx079 or 1 1 -> 1
+
+orx080 or 0 1111111111 -> 111111111
+orx081 or 0 111111111 -> 111111111
+orx082 or 0 11111111 -> 11111111
+orx083 or 0 1111111 -> 1111111
+orx084 or 0 111111 -> 111111
+orx085 or 0 11111 -> 11111
+orx086 or 0 1111 -> 1111
+orx087 or 0 111 -> 111
+orx088 or 0 11 -> 11
+orx089 or 0 1 -> 1
+
+orx090 or 011111111 111101111 -> 111111111
+orx091 or 101111111 111101111 -> 111111111
+orx092 or 110111111 111101111 -> 111111111
+orx093 or 111011111 111101111 -> 111111111
+orx094 or 111101111 111101111 -> 111101111
+orx095 or 111110111 111101111 -> 111111111
+orx096 or 111111011 111101111 -> 111111111
+orx097 or 111111101 111101111 -> 111111111
+orx098 or 111111110 111101111 -> 111111111
+
+orx100 or 111101111 011111111 -> 111111111
+orx101 or 111101111 101111111 -> 111111111
+orx102 or 111101111 110111111 -> 111111111
+orx103 or 111101111 111011111 -> 111111111
+orx104 or 111101111 111101111 -> 111101111
+orx105 or 111101111 111110111 -> 111111111
+orx106 or 111101111 111111011 -> 111111111
+orx107 or 111101111 111111101 -> 111111111
+orx108 or 111101111 111111110 -> 111111111
+
+-- non-0/1 should not be accepted, nor should signs
+orx220 or 111111112 111111111 -> NaN Invalid_operation
+orx221 or 333333333 333333333 -> NaN Invalid_operation
+orx222 or 555555555 555555555 -> NaN Invalid_operation
+orx223 or 777777777 777777777 -> NaN Invalid_operation
+orx224 or 999999999 999999999 -> NaN Invalid_operation
+orx225 or 222222222 999999999 -> NaN Invalid_operation
+orx226 or 444444444 999999999 -> NaN Invalid_operation
+orx227 or 666666666 999999999 -> NaN Invalid_operation
+orx228 or 888888888 999999999 -> NaN Invalid_operation
+orx229 or 999999999 222222222 -> NaN Invalid_operation
+orx230 or 999999999 444444444 -> NaN Invalid_operation
+orx231 or 999999999 666666666 -> NaN Invalid_operation
+orx232 or 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+orx240 or 567468689 -934981942 -> NaN Invalid_operation
+orx241 or 567367689 934981942 -> NaN Invalid_operation
+orx242 or -631917772 -706014634 -> NaN Invalid_operation
+orx243 or -756253257 138579234 -> NaN Invalid_operation
+orx244 or 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+orx250 or 200000000 100000000 -> NaN Invalid_operation
+orx251 or 700000000 100000000 -> NaN Invalid_operation
+orx252 or 800000000 100000000 -> NaN Invalid_operation
+orx253 or 900000000 100000000 -> NaN Invalid_operation
+orx254 or 200000000 000000000 -> NaN Invalid_operation
+orx255 or 700000000 000000000 -> NaN Invalid_operation
+orx256 or 800000000 000000000 -> NaN Invalid_operation
+orx257 or 900000000 000000000 -> NaN Invalid_operation
+orx258 or 100000000 200000000 -> NaN Invalid_operation
+orx259 or 100000000 700000000 -> NaN Invalid_operation
+orx260 or 100000000 800000000 -> NaN Invalid_operation
+orx261 or 100000000 900000000 -> NaN Invalid_operation
+orx262 or 000000000 200000000 -> NaN Invalid_operation
+orx263 or 000000000 700000000 -> NaN Invalid_operation
+orx264 or 000000000 800000000 -> NaN Invalid_operation
+orx265 or 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+orx270 or 020000000 100000000 -> NaN Invalid_operation
+orx271 or 070100000 100000000 -> NaN Invalid_operation
+orx272 or 080010000 100000001 -> NaN Invalid_operation
+orx273 or 090001000 100000010 -> NaN Invalid_operation
+orx274 or 100000100 020010100 -> NaN Invalid_operation
+orx275 or 100000000 070001000 -> NaN Invalid_operation
+orx276 or 100000010 080010100 -> NaN Invalid_operation
+orx277 or 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+orx280 or 001000002 100000000 -> NaN Invalid_operation
+orx281 or 000000007 100000000 -> NaN Invalid_operation
+orx282 or 000000008 100000000 -> NaN Invalid_operation
+orx283 or 000000009 100000000 -> NaN Invalid_operation
+orx284 or 100000000 000100002 -> NaN Invalid_operation
+orx285 or 100100000 001000007 -> NaN Invalid_operation
+orx286 or 100010000 010000008 -> NaN Invalid_operation
+orx287 or 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+orx288 or 001020000 100000000 -> NaN Invalid_operation
+orx289 or 000070001 100000000 -> NaN Invalid_operation
+orx290 or 000080000 100010000 -> NaN Invalid_operation
+orx291 or 000090000 100001000 -> NaN Invalid_operation
+orx292 or 100000010 000020100 -> NaN Invalid_operation
+orx293 or 100100000 000070010 -> NaN Invalid_operation
+orx294 or 100010100 000080001 -> NaN Invalid_operation
+orx295 or 100001000 000090000 -> NaN Invalid_operation
+-- signs
+orx296 or -100001000 -000000000 -> NaN Invalid_operation
+orx297 or -100001000 000010000 -> NaN Invalid_operation
+orx298 or 100001000 -000000000 -> NaN Invalid_operation
+orx299 or 100001000 000011000 -> 100011000
+
+-- Nmax, Nmin, Ntiny
+orx331 or 2 9.99999999E+999 -> NaN Invalid_operation
+orx332 or 3 1E-999 -> NaN Invalid_operation
+orx333 or 4 1.00000000E-999 -> NaN Invalid_operation
+orx334 or 5 1E-1007 -> NaN Invalid_operation
+orx335 or 6 -1E-1007 -> NaN Invalid_operation
+orx336 or 7 -1.00000000E-999 -> NaN Invalid_operation
+orx337 or 8 -1E-999 -> NaN Invalid_operation
+orx338 or 9 -9.99999999E+999 -> NaN Invalid_operation
+orx341 or 9.99999999E+999 -18 -> NaN Invalid_operation
+orx342 or 1E-999 01 -> NaN Invalid_operation
+orx343 or 1.00000000E-999 -18 -> NaN Invalid_operation
+orx344 or 1E-1007 18 -> NaN Invalid_operation
+orx345 or -1E-1007 -10 -> NaN Invalid_operation
+orx346 or -1.00000000E-999 18 -> NaN Invalid_operation
+orx347 or -1E-999 10 -> NaN Invalid_operation
+orx348 or -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+orx361 or 1.0 1 -> NaN Invalid_operation
+orx362 or 1E+1 1 -> NaN Invalid_operation
+orx363 or 0.0 1 -> NaN Invalid_operation
+orx364 or 0E+1 1 -> NaN Invalid_operation
+orx365 or 9.9 1 -> NaN Invalid_operation
+orx366 or 9E+1 1 -> NaN Invalid_operation
+orx371 or 0 1.0 -> NaN Invalid_operation
+orx372 or 0 1E+1 -> NaN Invalid_operation
+orx373 or 0 0.0 -> NaN Invalid_operation
+orx374 or 0 0E+1 -> NaN Invalid_operation
+orx375 or 0 9.9 -> NaN Invalid_operation
+orx376 or 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+orx780 or -Inf -Inf -> NaN Invalid_operation
+orx781 or -Inf -1000 -> NaN Invalid_operation
+orx782 or -Inf -1 -> NaN Invalid_operation
+orx783 or -Inf -0 -> NaN Invalid_operation
+orx784 or -Inf 0 -> NaN Invalid_operation
+orx785 or -Inf 1 -> NaN Invalid_operation
+orx786 or -Inf 1000 -> NaN Invalid_operation
+orx787 or -1000 -Inf -> NaN Invalid_operation
+orx788 or -Inf -Inf -> NaN Invalid_operation
+orx789 or -1 -Inf -> NaN Invalid_operation
+orx790 or -0 -Inf -> NaN Invalid_operation
+orx791 or 0 -Inf -> NaN Invalid_operation
+orx792 or 1 -Inf -> NaN Invalid_operation
+orx793 or 1000 -Inf -> NaN Invalid_operation
+orx794 or Inf -Inf -> NaN Invalid_operation
+
+orx800 or Inf -Inf -> NaN Invalid_operation
+orx801 or Inf -1000 -> NaN Invalid_operation
+orx802 or Inf -1 -> NaN Invalid_operation
+orx803 or Inf -0 -> NaN Invalid_operation
+orx804 or Inf 0 -> NaN Invalid_operation
+orx805 or Inf 1 -> NaN Invalid_operation
+orx806 or Inf 1000 -> NaN Invalid_operation
+orx807 or Inf Inf -> NaN Invalid_operation
+orx808 or -1000 Inf -> NaN Invalid_operation
+orx809 or -Inf Inf -> NaN Invalid_operation
+orx810 or -1 Inf -> NaN Invalid_operation
+orx811 or -0 Inf -> NaN Invalid_operation
+orx812 or 0 Inf -> NaN Invalid_operation
+orx813 or 1 Inf -> NaN Invalid_operation
+orx814 or 1000 Inf -> NaN Invalid_operation
+orx815 or Inf Inf -> NaN Invalid_operation
+
+orx821 or NaN -Inf -> NaN Invalid_operation
+orx822 or NaN -1000 -> NaN Invalid_operation
+orx823 or NaN -1 -> NaN Invalid_operation
+orx824 or NaN -0 -> NaN Invalid_operation
+orx825 or NaN 0 -> NaN Invalid_operation
+orx826 or NaN 1 -> NaN Invalid_operation
+orx827 or NaN 1000 -> NaN Invalid_operation
+orx828 or NaN Inf -> NaN Invalid_operation
+orx829 or NaN NaN -> NaN Invalid_operation
+orx830 or -Inf NaN -> NaN Invalid_operation
+orx831 or -1000 NaN -> NaN Invalid_operation
+orx832 or -1 NaN -> NaN Invalid_operation
+orx833 or -0 NaN -> NaN Invalid_operation
+orx834 or 0 NaN -> NaN Invalid_operation
+orx835 or 1 NaN -> NaN Invalid_operation
+orx836 or 1000 NaN -> NaN Invalid_operation
+orx837 or Inf NaN -> NaN Invalid_operation
+
+orx841 or sNaN -Inf -> NaN Invalid_operation
+orx842 or sNaN -1000 -> NaN Invalid_operation
+orx843 or sNaN -1 -> NaN Invalid_operation
+orx844 or sNaN -0 -> NaN Invalid_operation
+orx845 or sNaN 0 -> NaN Invalid_operation
+orx846 or sNaN 1 -> NaN Invalid_operation
+orx847 or sNaN 1000 -> NaN Invalid_operation
+orx848 or sNaN NaN -> NaN Invalid_operation
+orx849 or sNaN sNaN -> NaN Invalid_operation
+orx850 or NaN sNaN -> NaN Invalid_operation
+orx851 or -Inf sNaN -> NaN Invalid_operation
+orx852 or -1000 sNaN -> NaN Invalid_operation
+orx853 or -1 sNaN -> NaN Invalid_operation
+orx854 or -0 sNaN -> NaN Invalid_operation
+orx855 or 0 sNaN -> NaN Invalid_operation
+orx856 or 1 sNaN -> NaN Invalid_operation
+orx857 or 1000 sNaN -> NaN Invalid_operation
+orx858 or Inf sNaN -> NaN Invalid_operation
+orx859 or NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+orx861 or NaN1 -Inf -> NaN Invalid_operation
+orx862 or +NaN2 -1000 -> NaN Invalid_operation
+orx863 or NaN3 1000 -> NaN Invalid_operation
+orx864 or NaN4 Inf -> NaN Invalid_operation
+orx865 or NaN5 +NaN6 -> NaN Invalid_operation
+orx866 or -Inf NaN7 -> NaN Invalid_operation
+orx867 or -1000 NaN8 -> NaN Invalid_operation
+orx868 or 1000 NaN9 -> NaN Invalid_operation
+orx869 or Inf +NaN10 -> NaN Invalid_operation
+orx871 or sNaN11 -Inf -> NaN Invalid_operation
+orx872 or sNaN12 -1000 -> NaN Invalid_operation
+orx873 or sNaN13 1000 -> NaN Invalid_operation
+orx874 or sNaN14 NaN17 -> NaN Invalid_operation
+orx875 or sNaN15 sNaN18 -> NaN Invalid_operation
+orx876 or NaN16 sNaN19 -> NaN Invalid_operation
+orx877 or -Inf +sNaN20 -> NaN Invalid_operation
+orx878 or -1000 sNaN21 -> NaN Invalid_operation
+orx879 or 1000 sNaN22 -> NaN Invalid_operation
+orx880 or Inf sNaN23 -> NaN Invalid_operation
+orx881 or +NaN25 +sNaN24 -> NaN Invalid_operation
+orx882 or -NaN26 NaN28 -> NaN Invalid_operation
+orx883 or -sNaN27 sNaN29 -> NaN Invalid_operation
+orx884 or 1000 -NaN30 -> NaN Invalid_operation
+orx885 or 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/powersqrt.decTest b/Lib/test/decimaltestdata/powersqrt.decTest
index 260b941537b..6c021a0cbb4 100644
--- a/Lib/test/decimaltestdata/powersqrt.decTest
+++ b/Lib/test/decimaltestdata/powersqrt.decTest
@@ -1,2970 +1,2970 @@
-------------------------------------------------------------------------
--- powersqrt.decTest -- decimal square root, using power --
--- Copyright (c) IBM Corporation, 2004, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- These testcases are taken from squareroot.decTest but are
--- evaluated using the power operator. The differences in results
--- (153 out of 2856) fall into the following categories:
---
--- x ** 0.5 (x>0) has no preferred exponent, and is Inexact
--- (and hence full precision); almost all differences are
--- in this category
--- 0.00 ** 0.5 becomes 0 (not 0.0), etc.
--- -0 ** 0.5 becomes 0 (never -0)
--- Some exact subnormals become inexact and hence underflows
-
-extended: 1
-precision: 9
-rounding: half_even
-maxExponent: 384
-minexponent: -383
-
--- basics
-pwsx001 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx002 power -1 0.5 -> NaN Invalid_operation
-pwsx003 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx004 power -1.00 0.5 -> NaN Invalid_operation
-pwsx005 power 0 0.5 -> 0
-pwsx006 power 00.0 0.5 -> 0
-pwsx007 power 0.00 0.5 -> 0
-pwsx008 power 00.00 0.5 -> 0
-pwsx009 power 00.000 0.5 -> 0
-pwsx010 power 00.0000 0.5 -> 0
-pwsx011 power 00 0.5 -> 0
-
-pwsx012 power -2 0.5 -> NaN Invalid_operation
-pwsx013 power 2 0.5 -> 1.41421356 Inexact Rounded
-pwsx014 power -2.00 0.5 -> NaN Invalid_operation
-pwsx015 power 2.00 0.5 -> 1.41421356 Inexact Rounded
-pwsx016 power -0 0.5 -> 0
-pwsx017 power -0.0 0.5 -> 0
-pwsx018 power -00.00 0.5 -> 0
-pwsx019 power -00.000 0.5 -> 0
-pwsx020 power -0.0000 0.5 -> 0
-pwsx021 power -0E+9 0.5 -> 0
-pwsx022 power -0E+10 0.5 -> 0
-pwsx023 power -0E+11 0.5 -> 0
-pwsx024 power -0E+12 0.5 -> 0
-pwsx025 power -00 0.5 -> 0
-pwsx026 power 0E+5 0.5 -> 0
-pwsx027 power 4.0 0.5 -> 2.00000000 Inexact Rounded
-pwsx028 power 4.00 0.5 -> 2.00000000 Inexact Rounded
-
-pwsx030 power +0.1 0.5 -> 0.316227766 Inexact Rounded
-pwsx031 power -0.1 0.5 -> NaN Invalid_operation
-pwsx032 power +0.01 0.5 -> 0.100000000 Inexact Rounded
-pwsx033 power -0.01 0.5 -> NaN Invalid_operation
-pwsx034 power +0.001 0.5 -> 0.0316227766 Inexact Rounded
-pwsx035 power -0.001 0.5 -> NaN Invalid_operation
-pwsx036 power +0.000001 0.5 -> 0.00100000000 Inexact Rounded
-pwsx037 power -0.000001 0.5 -> NaN Invalid_operation
-pwsx038 power +0.000000000001 0.5 -> 0.00000100000000 Inexact Rounded
-pwsx039 power -0.000000000001 0.5 -> NaN Invalid_operation
-
-pwsx041 power 1.1 0.5 -> 1.04880885 Inexact Rounded
-pwsx042 power 1.10 0.5 -> 1.04880885 Inexact Rounded
-pwsx043 power 1.100 0.5 -> 1.04880885 Inexact Rounded
-pwsx044 power 1.110 0.5 -> 1.05356538 Inexact Rounded
-pwsx045 power -1.1 0.5 -> NaN Invalid_operation
-pwsx046 power -1.10 0.5 -> NaN Invalid_operation
-pwsx047 power -1.100 0.5 -> NaN Invalid_operation
-pwsx048 power -1.110 0.5 -> NaN Invalid_operation
-pwsx049 power 9.9 0.5 -> 3.14642654 Inexact Rounded
-pwsx050 power 9.90 0.5 -> 3.14642654 Inexact Rounded
-pwsx051 power 9.900 0.5 -> 3.14642654 Inexact Rounded
-pwsx052 power 9.990 0.5 -> 3.16069613 Inexact Rounded
-pwsx053 power -9.9 0.5 -> NaN Invalid_operation
-pwsx054 power -9.90 0.5 -> NaN Invalid_operation
-pwsx055 power -9.900 0.5 -> NaN Invalid_operation
-pwsx056 power -9.990 0.5 -> NaN Invalid_operation
-
-pwsx060 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx061 power 1.0 0.5 -> 1.00000000 Inexact Rounded
-pwsx062 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx063 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx064 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx065 power 10.0 0.5 -> 3.16227766 Inexact Rounded
-pwsx066 power 10.00 0.5 -> 3.16227766 Inexact Rounded
-pwsx067 power 100 0.5 -> 10.0000000 Inexact Rounded
-pwsx068 power 100.0 0.5 -> 10.0000000 Inexact Rounded
-pwsx069 power 100.00 0.5 -> 10.0000000 Inexact Rounded
-pwsx070 power 1.1000E+3 0.5 -> 33.1662479 Inexact Rounded
-pwsx071 power 1.10000E+3 0.5 -> 33.1662479 Inexact Rounded
-pwsx072 power -10.0 0.5 -> NaN Invalid_operation
-pwsx073 power -10.00 0.5 -> NaN Invalid_operation
-pwsx074 power -100.0 0.5 -> NaN Invalid_operation
-pwsx075 power -100.00 0.5 -> NaN Invalid_operation
-pwsx076 power -1.1000E+3 0.5 -> NaN Invalid_operation
-pwsx077 power -1.10000E+3 0.5 -> NaN Invalid_operation
-
--- famous squares
-pwsx080 power 1 0.5 -> 1.00000000 Inexact Rounded
-pwsx081 power 4 0.5 -> 2.00000000 Inexact Rounded
-pwsx082 power 9 0.5 -> 3.00000000 Inexact Rounded
-pwsx083 power 16 0.5 -> 4.00000000 Inexact Rounded
-pwsx084 power 25 0.5 -> 5.00000000 Inexact Rounded
-pwsx085 power 36 0.5 -> 6.00000000 Inexact Rounded
-pwsx086 power 49 0.5 -> 7.00000000 Inexact Rounded
-pwsx087 power 64 0.5 -> 8.00000000 Inexact Rounded
-pwsx088 power 81 0.5 -> 9.00000000 Inexact Rounded
-pwsx089 power 100 0.5 -> 10.0000000 Inexact Rounded
-pwsx090 power 121 0.5 -> 11.0000000 Inexact Rounded
-pwsx091 power 144 0.5 -> 12.0000000 Inexact Rounded
-pwsx092 power 169 0.5 -> 13.0000000 Inexact Rounded
-pwsx093 power 256 0.5 -> 16.0000000 Inexact Rounded
-pwsx094 power 1024 0.5 -> 32.0000000 Inexact Rounded
-pwsx095 power 4096 0.5 -> 64.0000000 Inexact Rounded
-pwsx100 power 0.01 0.5 -> 0.100000000 Inexact Rounded
-pwsx101 power 0.04 0.5 -> 0.200000000 Inexact Rounded
-pwsx102 power 0.09 0.5 -> 0.300000000 Inexact Rounded
-pwsx103 power 0.16 0.5 -> 0.400000000 Inexact Rounded
-pwsx104 power 0.25 0.5 -> 0.500000000 Inexact Rounded
-pwsx105 power 0.36 0.5 -> 0.600000000 Inexact Rounded
-pwsx106 power 0.49 0.5 -> 0.700000000 Inexact Rounded
-pwsx107 power 0.64 0.5 -> 0.800000000 Inexact Rounded
-pwsx108 power 0.81 0.5 -> 0.900000000 Inexact Rounded
-pwsx109 power 1.00 0.5 -> 1.00000000 Inexact Rounded
-pwsx110 power 1.21 0.5 -> 1.10000000 Inexact Rounded
-pwsx111 power 1.44 0.5 -> 1.20000000 Inexact Rounded
-pwsx112 power 1.69 0.5 -> 1.30000000 Inexact Rounded
-pwsx113 power 2.56 0.5 -> 1.60000000 Inexact Rounded
-pwsx114 power 10.24 0.5 -> 3.20000000 Inexact Rounded
-pwsx115 power 40.96 0.5 -> 6.40000000 Inexact Rounded
-
--- Precision 1 squareroot tests [exhaustive, plus exponent adjusts]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 1
-pwsx1201 power 0.1 0.5 -> 0.3 Inexact Rounded
-pwsx1202 power 0.01 0.5 -> 0.1 Inexact Rounded
-pwsx1203 power 1.0E-1 0.5 -> 0.3 Inexact Rounded
-pwsx1204 power 1.00E-2 0.5 -> 0.1 Inexact Rounded
-pwsx1205 power 1E-3 0.5 -> 0.03 Inexact Rounded
-pwsx1206 power 1E+1 0.5 -> 3 Inexact Rounded
-pwsx1207 power 1E+2 0.5 -> 1E+1 Inexact Rounded
-pwsx1208 power 1E+3 0.5 -> 3E+1 Inexact Rounded
-pwsx1209 power 0.2 0.5 -> 0.4 Inexact Rounded
-pwsx1210 power 0.02 0.5 -> 0.1 Inexact Rounded
-pwsx1211 power 2.0E-1 0.5 -> 0.4 Inexact Rounded
-pwsx1212 power 2.00E-2 0.5 -> 0.1 Inexact Rounded
-pwsx1213 power 2E-3 0.5 -> 0.04 Inexact Rounded
-pwsx1214 power 2E+1 0.5 -> 4 Inexact Rounded
-pwsx1215 power 2E+2 0.5 -> 1E+1 Inexact Rounded
-pwsx1216 power 2E+3 0.5 -> 4E+1 Inexact Rounded
-pwsx1217 power 0.3 0.5 -> 0.5 Inexact Rounded
-pwsx1218 power 0.03 0.5 -> 0.2 Inexact Rounded
-pwsx1219 power 3.0E-1 0.5 -> 0.5 Inexact Rounded
-pwsx1220 power 3.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1221 power 3E-3 0.5 -> 0.05 Inexact Rounded
-pwsx1222 power 3E+1 0.5 -> 5 Inexact Rounded
-pwsx1223 power 3E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1224 power 3E+3 0.5 -> 5E+1 Inexact Rounded
-pwsx1225 power 0.4 0.5 -> 0.6 Inexact Rounded
-pwsx1226 power 0.04 0.5 -> 0.2 Inexact Rounded
-pwsx1227 power 4.0E-1 0.5 -> 0.6 Inexact Rounded
-pwsx1228 power 4.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1229 power 4E-3 0.5 -> 0.06 Inexact Rounded
-pwsx1230 power 4E+1 0.5 -> 6 Inexact Rounded
-pwsx1231 power 4E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1232 power 4E+3 0.5 -> 6E+1 Inexact Rounded
-pwsx1233 power 0.5 0.5 -> 0.7 Inexact Rounded
-pwsx1234 power 0.05 0.5 -> 0.2 Inexact Rounded
-pwsx1235 power 5.0E-1 0.5 -> 0.7 Inexact Rounded
-pwsx1236 power 5.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1237 power 5E-3 0.5 -> 0.07 Inexact Rounded
-pwsx1238 power 5E+1 0.5 -> 7 Inexact Rounded
-pwsx1239 power 5E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1240 power 5E+3 0.5 -> 7E+1 Inexact Rounded
-pwsx1241 power 0.6 0.5 -> 0.8 Inexact Rounded
-pwsx1242 power 0.06 0.5 -> 0.2 Inexact Rounded
-pwsx1243 power 6.0E-1 0.5 -> 0.8 Inexact Rounded
-pwsx1244 power 6.00E-2 0.5 -> 0.2 Inexact Rounded
-pwsx1245 power 6E-3 0.5 -> 0.08 Inexact Rounded
-pwsx1246 power 6E+1 0.5 -> 8 Inexact Rounded
-pwsx1247 power 6E+2 0.5 -> 2E+1 Inexact Rounded
-pwsx1248 power 6E+3 0.5 -> 8E+1 Inexact Rounded
-pwsx1249 power 0.7 0.5 -> 0.8 Inexact Rounded
-pwsx1250 power 0.07 0.5 -> 0.3 Inexact Rounded
-pwsx1251 power 7.0E-1 0.5 -> 0.8 Inexact Rounded
-pwsx1252 power 7.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1253 power 7E-3 0.5 -> 0.08 Inexact Rounded
-pwsx1254 power 7E+1 0.5 -> 8 Inexact Rounded
-pwsx1255 power 7E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1256 power 7E+3 0.5 -> 8E+1 Inexact Rounded
-pwsx1257 power 0.8 0.5 -> 0.9 Inexact Rounded
-pwsx1258 power 0.08 0.5 -> 0.3 Inexact Rounded
-pwsx1259 power 8.0E-1 0.5 -> 0.9 Inexact Rounded
-pwsx1260 power 8.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1261 power 8E-3 0.5 -> 0.09 Inexact Rounded
-pwsx1262 power 8E+1 0.5 -> 9 Inexact Rounded
-pwsx1263 power 8E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1264 power 8E+3 0.5 -> 9E+1 Inexact Rounded
-pwsx1265 power 0.9 0.5 -> 0.9 Inexact Rounded
-pwsx1266 power 0.09 0.5 -> 0.3 Inexact Rounded
-pwsx1267 power 9.0E-1 0.5 -> 0.9 Inexact Rounded
-pwsx1268 power 9.00E-2 0.5 -> 0.3 Inexact Rounded
-pwsx1269 power 9E-3 0.5 -> 0.09 Inexact Rounded
-pwsx1270 power 9E+1 0.5 -> 9 Inexact Rounded
-pwsx1271 power 9E+2 0.5 -> 3E+1 Inexact Rounded
-pwsx1272 power 9E+3 0.5 -> 9E+1 Inexact Rounded
-
--- Precision 2 squareroot tests [exhaustive, plus exponent adjusts]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 2
-pwsx2201 power 0.1 0.5 -> 0.32 Inexact Rounded
-pwsx2202 power 0.01 0.5 -> 0.10 Inexact Rounded
-pwsx2203 power 1.0E-1 0.5 -> 0.32 Inexact Rounded
-pwsx2204 power 1.00E-2 0.5 -> 0.10 Inexact Rounded
-pwsx2205 power 1E-3 0.5 -> 0.032 Inexact Rounded
-pwsx2206 power 1E+1 0.5 -> 3.2 Inexact Rounded
-pwsx2207 power 1E+2 0.5 -> 10 Inexact Rounded
-pwsx2208 power 1E+3 0.5 -> 32 Inexact Rounded
-pwsx2209 power 0.2 0.5 -> 0.45 Inexact Rounded
-pwsx2210 power 0.02 0.5 -> 0.14 Inexact Rounded
-pwsx2211 power 2.0E-1 0.5 -> 0.45 Inexact Rounded
-pwsx2212 power 2.00E-2 0.5 -> 0.14 Inexact Rounded
-pwsx2213 power 2E-3 0.5 -> 0.045 Inexact Rounded
-pwsx2214 power 2E+1 0.5 -> 4.5 Inexact Rounded
-pwsx2215 power 2E+2 0.5 -> 14 Inexact Rounded
-pwsx2216 power 2E+3 0.5 -> 45 Inexact Rounded
-pwsx2217 power 0.3 0.5 -> 0.55 Inexact Rounded
-pwsx2218 power 0.03 0.5 -> 0.17 Inexact Rounded
-pwsx2219 power 3.0E-1 0.5 -> 0.55 Inexact Rounded
-pwsx2220 power 3.00E-2 0.5 -> 0.17 Inexact Rounded
-pwsx2221 power 3E-3 0.5 -> 0.055 Inexact Rounded
-pwsx2222 power 3E+1 0.5 -> 5.5 Inexact Rounded
-pwsx2223 power 3E+2 0.5 -> 17 Inexact Rounded
-pwsx2224 power 3E+3 0.5 -> 55 Inexact Rounded
-pwsx2225 power 0.4 0.5 -> 0.63 Inexact Rounded
-pwsx2226 power 0.04 0.5 -> 0.20 Inexact Rounded
-pwsx2227 power 4.0E-1 0.5 -> 0.63 Inexact Rounded
-pwsx2228 power 4.00E-2 0.5 -> 0.20 Inexact Rounded
-pwsx2229 power 4E-3 0.5 -> 0.063 Inexact Rounded
-pwsx2230 power 4E+1 0.5 -> 6.3 Inexact Rounded
-pwsx2231 power 4E+2 0.5 -> 20 Inexact Rounded
-pwsx2232 power 4E+3 0.5 -> 63 Inexact Rounded
-pwsx2233 power 0.5 0.5 -> 0.71 Inexact Rounded
-pwsx2234 power 0.05 0.5 -> 0.22 Inexact Rounded
-pwsx2235 power 5.0E-1 0.5 -> 0.71 Inexact Rounded
-pwsx2236 power 5.00E-2 0.5 -> 0.22 Inexact Rounded
-pwsx2237 power 5E-3 0.5 -> 0.071 Inexact Rounded
-pwsx2238 power 5E+1 0.5 -> 7.1 Inexact Rounded
-pwsx2239 power 5E+2 0.5 -> 22 Inexact Rounded
-pwsx2240 power 5E+3 0.5 -> 71 Inexact Rounded
-pwsx2241 power 0.6 0.5 -> 0.77 Inexact Rounded
-pwsx2242 power 0.06 0.5 -> 0.24 Inexact Rounded
-pwsx2243 power 6.0E-1 0.5 -> 0.77 Inexact Rounded
-pwsx2244 power 6.00E-2 0.5 -> 0.24 Inexact Rounded
-pwsx2245 power 6E-3 0.5 -> 0.077 Inexact Rounded
-pwsx2246 power 6E+1 0.5 -> 7.7 Inexact Rounded
-pwsx2247 power 6E+2 0.5 -> 24 Inexact Rounded
-pwsx2248 power 6E+3 0.5 -> 77 Inexact Rounded
-pwsx2249 power 0.7 0.5 -> 0.84 Inexact Rounded
-pwsx2250 power 0.07 0.5 -> 0.26 Inexact Rounded
-pwsx2251 power 7.0E-1 0.5 -> 0.84 Inexact Rounded
-pwsx2252 power 7.00E-2 0.5 -> 0.26 Inexact Rounded
-pwsx2253 power 7E-3 0.5 -> 0.084 Inexact Rounded
-pwsx2254 power 7E+1 0.5 -> 8.4 Inexact Rounded
-pwsx2255 power 7E+2 0.5 -> 26 Inexact Rounded
-pwsx2256 power 7E+3 0.5 -> 84 Inexact Rounded
-pwsx2257 power 0.8 0.5 -> 0.89 Inexact Rounded
-pwsx2258 power 0.08 0.5 -> 0.28 Inexact Rounded
-pwsx2259 power 8.0E-1 0.5 -> 0.89 Inexact Rounded
-pwsx2260 power 8.00E-2 0.5 -> 0.28 Inexact Rounded
-pwsx2261 power 8E-3 0.5 -> 0.089 Inexact Rounded
-pwsx2262 power 8E+1 0.5 -> 8.9 Inexact Rounded
-pwsx2263 power 8E+2 0.5 -> 28 Inexact Rounded
-pwsx2264 power 8E+3 0.5 -> 89 Inexact Rounded
-pwsx2265 power 0.9 0.5 -> 0.95 Inexact Rounded
-pwsx2266 power 0.09 0.5 -> 0.30 Inexact Rounded
-pwsx2267 power 9.0E-1 0.5 -> 0.95 Inexact Rounded
-pwsx2268 power 9.00E-2 0.5 -> 0.30 Inexact Rounded
-pwsx2269 power 9E-3 0.5 -> 0.095 Inexact Rounded
-pwsx2270 power 9E+1 0.5 -> 9.5 Inexact Rounded
-pwsx2271 power 9E+2 0.5 -> 30 Inexact Rounded
-pwsx2272 power 9E+3 0.5 -> 95 Inexact Rounded
-pwsx2273 power 0.10 0.5 -> 0.32 Inexact Rounded
-pwsx2274 power 0.010 0.5 -> 0.10 Inexact Rounded
-pwsx2275 power 10.0E-1 0.5 -> 1.0 Inexact Rounded
-pwsx2276 power 10.00E-2 0.5 -> 0.32 Inexact Rounded
-pwsx2277 power 10E-3 0.5 -> 0.10 Inexact Rounded
-pwsx2278 power 10E+1 0.5 -> 10 Inexact Rounded
-pwsx2279 power 10E+2 0.5 -> 32 Inexact Rounded
-pwsx2280 power 10E+3 0.5 -> 1.0E+2 Inexact Rounded
-pwsx2281 power 0.11 0.5 -> 0.33 Inexact Rounded
-pwsx2282 power 0.011 0.5 -> 0.10 Inexact Rounded
-pwsx2283 power 11.0E-1 0.5 -> 1.0 Inexact Rounded
-pwsx2284 power 11.00E-2 0.5 -> 0.33 Inexact Rounded
-pwsx2285 power 11E-3 0.5 -> 0.10 Inexact Rounded
-pwsx2286 power 11E+1 0.5 -> 10 Inexact Rounded
-pwsx2287 power 11E+2 0.5 -> 33 Inexact Rounded
-pwsx2288 power 11E+3 0.5 -> 1.0E+2 Inexact Rounded
-pwsx2289 power 0.12 0.5 -> 0.35 Inexact Rounded
-pwsx2290 power 0.012 0.5 -> 0.11 Inexact Rounded
-pwsx2291 power 12.0E-1 0.5 -> 1.1 Inexact Rounded
-pwsx2292 power 12.00E-2 0.5 -> 0.35 Inexact Rounded
-pwsx2293 power 12E-3 0.5 -> 0.11 Inexact Rounded
-pwsx2294 power 12E+1 0.5 -> 11 Inexact Rounded
-pwsx2295 power 12E+2 0.5 -> 35 Inexact Rounded
-pwsx2296 power 12E+3 0.5 -> 1.1E+2 Inexact Rounded
-pwsx2297 power 0.13 0.5 -> 0.36 Inexact Rounded
-pwsx2298 power 0.013 0.5 -> 0.11 Inexact Rounded
-pwsx2299 power 13.0E-1 0.5 -> 1.1 Inexact Rounded
-pwsx2300 power 13.00E-2 0.5 -> 0.36 Inexact Rounded
-pwsx2301 power 13E-3 0.5 -> 0.11 Inexact Rounded
-pwsx2302 power 13E+1 0.5 -> 11 Inexact Rounded
-pwsx2303 power 13E+2 0.5 -> 36 Inexact Rounded
-pwsx2304 power 13E+3 0.5 -> 1.1E+2 Inexact Rounded
-pwsx2305 power 0.14 0.5 -> 0.37 Inexact Rounded
-pwsx2306 power 0.014 0.5 -> 0.12 Inexact Rounded
-pwsx2307 power 14.0E-1 0.5 -> 1.2 Inexact Rounded
-pwsx2308 power 14.00E-2 0.5 -> 0.37 Inexact Rounded
-pwsx2309 power 14E-3 0.5 -> 0.12 Inexact Rounded
-pwsx2310 power 14E+1 0.5 -> 12 Inexact Rounded
-pwsx2311 power 14E+2 0.5 -> 37 Inexact Rounded
-pwsx2312 power 14E+3 0.5 -> 1.2E+2 Inexact Rounded
-pwsx2313 power 0.15 0.5 -> 0.39 Inexact Rounded
-pwsx2314 power 0.015 0.5 -> 0.12 Inexact Rounded
-pwsx2315 power 15.0E-1 0.5 -> 1.2 Inexact Rounded
-pwsx2316 power 15.00E-2 0.5 -> 0.39 Inexact Rounded
-pwsx2317 power 15E-3 0.5 -> 0.12 Inexact Rounded
-pwsx2318 power 15E+1 0.5 -> 12 Inexact Rounded
-pwsx2319 power 15E+2 0.5 -> 39 Inexact Rounded
-pwsx2320 power 15E+3 0.5 -> 1.2E+2 Inexact Rounded
-pwsx2321 power 0.16 0.5 -> 0.40 Inexact Rounded
-pwsx2322 power 0.016 0.5 -> 0.13 Inexact Rounded
-pwsx2323 power 16.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2324 power 16.00E-2 0.5 -> 0.40 Inexact Rounded
-pwsx2325 power 16E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2326 power 16E+1 0.5 -> 13 Inexact Rounded
-pwsx2327 power 16E+2 0.5 -> 40 Inexact Rounded
-pwsx2328 power 16E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2329 power 0.17 0.5 -> 0.41 Inexact Rounded
-pwsx2330 power 0.017 0.5 -> 0.13 Inexact Rounded
-pwsx2331 power 17.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2332 power 17.00E-2 0.5 -> 0.41 Inexact Rounded
-pwsx2333 power 17E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2334 power 17E+1 0.5 -> 13 Inexact Rounded
-pwsx2335 power 17E+2 0.5 -> 41 Inexact Rounded
-pwsx2336 power 17E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2337 power 0.18 0.5 -> 0.42 Inexact Rounded
-pwsx2338 power 0.018 0.5 -> 0.13 Inexact Rounded
-pwsx2339 power 18.0E-1 0.5 -> 1.3 Inexact Rounded
-pwsx2340 power 18.00E-2 0.5 -> 0.42 Inexact Rounded
-pwsx2341 power 18E-3 0.5 -> 0.13 Inexact Rounded
-pwsx2342 power 18E+1 0.5 -> 13 Inexact Rounded
-pwsx2343 power 18E+2 0.5 -> 42 Inexact Rounded
-pwsx2344 power 18E+3 0.5 -> 1.3E+2 Inexact Rounded
-pwsx2345 power 0.19 0.5 -> 0.44 Inexact Rounded
-pwsx2346 power 0.019 0.5 -> 0.14 Inexact Rounded
-pwsx2347 power 19.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2348 power 19.00E-2 0.5 -> 0.44 Inexact Rounded
-pwsx2349 power 19E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2350 power 19E+1 0.5 -> 14 Inexact Rounded
-pwsx2351 power 19E+2 0.5 -> 44 Inexact Rounded
-pwsx2352 power 19E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2353 power 0.20 0.5 -> 0.45 Inexact Rounded
-pwsx2354 power 0.020 0.5 -> 0.14 Inexact Rounded
-pwsx2355 power 20.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2356 power 20.00E-2 0.5 -> 0.45 Inexact Rounded
-pwsx2357 power 20E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2358 power 20E+1 0.5 -> 14 Inexact Rounded
-pwsx2359 power 20E+2 0.5 -> 45 Inexact Rounded
-pwsx2360 power 20E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2361 power 0.21 0.5 -> 0.46 Inexact Rounded
-pwsx2362 power 0.021 0.5 -> 0.14 Inexact Rounded
-pwsx2363 power 21.0E-1 0.5 -> 1.4 Inexact Rounded
-pwsx2364 power 21.00E-2 0.5 -> 0.46 Inexact Rounded
-pwsx2365 power 21E-3 0.5 -> 0.14 Inexact Rounded
-pwsx2366 power 21E+1 0.5 -> 14 Inexact Rounded
-pwsx2367 power 21E+2 0.5 -> 46 Inexact Rounded
-pwsx2368 power 21E+3 0.5 -> 1.4E+2 Inexact Rounded
-pwsx2369 power 0.22 0.5 -> 0.47 Inexact Rounded
-pwsx2370 power 0.022 0.5 -> 0.15 Inexact Rounded
-pwsx2371 power 22.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2372 power 22.00E-2 0.5 -> 0.47 Inexact Rounded
-pwsx2373 power 22E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2374 power 22E+1 0.5 -> 15 Inexact Rounded
-pwsx2375 power 22E+2 0.5 -> 47 Inexact Rounded
-pwsx2376 power 22E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2377 power 0.23 0.5 -> 0.48 Inexact Rounded
-pwsx2378 power 0.023 0.5 -> 0.15 Inexact Rounded
-pwsx2379 power 23.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2380 power 23.00E-2 0.5 -> 0.48 Inexact Rounded
-pwsx2381 power 23E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2382 power 23E+1 0.5 -> 15 Inexact Rounded
-pwsx2383 power 23E+2 0.5 -> 48 Inexact Rounded
-pwsx2384 power 23E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2385 power 0.24 0.5 -> 0.49 Inexact Rounded
-pwsx2386 power 0.024 0.5 -> 0.15 Inexact Rounded
-pwsx2387 power 24.0E-1 0.5 -> 1.5 Inexact Rounded
-pwsx2388 power 24.00E-2 0.5 -> 0.49 Inexact Rounded
-pwsx2389 power 24E-3 0.5 -> 0.15 Inexact Rounded
-pwsx2390 power 24E+1 0.5 -> 15 Inexact Rounded
-pwsx2391 power 24E+2 0.5 -> 49 Inexact Rounded
-pwsx2392 power 24E+3 0.5 -> 1.5E+2 Inexact Rounded
-pwsx2393 power 0.25 0.5 -> 0.50 Inexact Rounded
-pwsx2394 power 0.025 0.5 -> 0.16 Inexact Rounded
-pwsx2395 power 25.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2396 power 25.00E-2 0.5 -> 0.50 Inexact Rounded
-pwsx2397 power 25E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2398 power 25E+1 0.5 -> 16 Inexact Rounded
-pwsx2399 power 25E+2 0.5 -> 50 Inexact Rounded
-pwsx2400 power 25E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2401 power 0.26 0.5 -> 0.51 Inexact Rounded
-pwsx2402 power 0.026 0.5 -> 0.16 Inexact Rounded
-pwsx2403 power 26.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2404 power 26.00E-2 0.5 -> 0.51 Inexact Rounded
-pwsx2405 power 26E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2406 power 26E+1 0.5 -> 16 Inexact Rounded
-pwsx2407 power 26E+2 0.5 -> 51 Inexact Rounded
-pwsx2408 power 26E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2409 power 0.27 0.5 -> 0.52 Inexact Rounded
-pwsx2410 power 0.027 0.5 -> 0.16 Inexact Rounded
-pwsx2411 power 27.0E-1 0.5 -> 1.6 Inexact Rounded
-pwsx2412 power 27.00E-2 0.5 -> 0.52 Inexact Rounded
-pwsx2413 power 27E-3 0.5 -> 0.16 Inexact Rounded
-pwsx2414 power 27E+1 0.5 -> 16 Inexact Rounded
-pwsx2415 power 27E+2 0.5 -> 52 Inexact Rounded
-pwsx2416 power 27E+3 0.5 -> 1.6E+2 Inexact Rounded
-pwsx2417 power 0.28 0.5 -> 0.53 Inexact Rounded
-pwsx2418 power 0.028 0.5 -> 0.17 Inexact Rounded
-pwsx2419 power 28.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2420 power 28.00E-2 0.5 -> 0.53 Inexact Rounded
-pwsx2421 power 28E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2422 power 28E+1 0.5 -> 17 Inexact Rounded
-pwsx2423 power 28E+2 0.5 -> 53 Inexact Rounded
-pwsx2424 power 28E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2425 power 0.29 0.5 -> 0.54 Inexact Rounded
-pwsx2426 power 0.029 0.5 -> 0.17 Inexact Rounded
-pwsx2427 power 29.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2428 power 29.00E-2 0.5 -> 0.54 Inexact Rounded
-pwsx2429 power 29E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2430 power 29E+1 0.5 -> 17 Inexact Rounded
-pwsx2431 power 29E+2 0.5 -> 54 Inexact Rounded
-pwsx2432 power 29E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2433 power 0.30 0.5 -> 0.55 Inexact Rounded
-pwsx2434 power 0.030 0.5 -> 0.17 Inexact Rounded
-pwsx2435 power 30.0E-1 0.5 -> 1.7 Inexact Rounded
-pwsx2436 power 30.00E-2 0.5 -> 0.55 Inexact Rounded
-pwsx2437 power 30E-3 0.5 -> 0.17 Inexact Rounded
-pwsx2438 power 30E+1 0.5 -> 17 Inexact Rounded
-pwsx2439 power 30E+2 0.5 -> 55 Inexact Rounded
-pwsx2440 power 30E+3 0.5 -> 1.7E+2 Inexact Rounded
-pwsx2441 power 0.31 0.5 -> 0.56 Inexact Rounded
-pwsx2442 power 0.031 0.5 -> 0.18 Inexact Rounded
-pwsx2443 power 31.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2444 power 31.00E-2 0.5 -> 0.56 Inexact Rounded
-pwsx2445 power 31E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2446 power 31E+1 0.5 -> 18 Inexact Rounded
-pwsx2447 power 31E+2 0.5 -> 56 Inexact Rounded
-pwsx2448 power 31E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2449 power 0.32 0.5 -> 0.57 Inexact Rounded
-pwsx2450 power 0.032 0.5 -> 0.18 Inexact Rounded
-pwsx2451 power 32.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2452 power 32.00E-2 0.5 -> 0.57 Inexact Rounded
-pwsx2453 power 32E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2454 power 32E+1 0.5 -> 18 Inexact Rounded
-pwsx2455 power 32E+2 0.5 -> 57 Inexact Rounded
-pwsx2456 power 32E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2457 power 0.33 0.5 -> 0.57 Inexact Rounded
-pwsx2458 power 0.033 0.5 -> 0.18 Inexact Rounded
-pwsx2459 power 33.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2460 power 33.00E-2 0.5 -> 0.57 Inexact Rounded
-pwsx2461 power 33E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2462 power 33E+1 0.5 -> 18 Inexact Rounded
-pwsx2463 power 33E+2 0.5 -> 57 Inexact Rounded
-pwsx2464 power 33E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2465 power 0.34 0.5 -> 0.58 Inexact Rounded
-pwsx2466 power 0.034 0.5 -> 0.18 Inexact Rounded
-pwsx2467 power 34.0E-1 0.5 -> 1.8 Inexact Rounded
-pwsx2468 power 34.00E-2 0.5 -> 0.58 Inexact Rounded
-pwsx2469 power 34E-3 0.5 -> 0.18 Inexact Rounded
-pwsx2470 power 34E+1 0.5 -> 18 Inexact Rounded
-pwsx2471 power 34E+2 0.5 -> 58 Inexact Rounded
-pwsx2472 power 34E+3 0.5 -> 1.8E+2 Inexact Rounded
-pwsx2473 power 0.35 0.5 -> 0.59 Inexact Rounded
-pwsx2474 power 0.035 0.5 -> 0.19 Inexact Rounded
-pwsx2475 power 35.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2476 power 35.00E-2 0.5 -> 0.59 Inexact Rounded
-pwsx2477 power 35E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2478 power 35E+1 0.5 -> 19 Inexact Rounded
-pwsx2479 power 35E+2 0.5 -> 59 Inexact Rounded
-pwsx2480 power 35E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2481 power 0.36 0.5 -> 0.60 Inexact Rounded
-pwsx2482 power 0.036 0.5 -> 0.19 Inexact Rounded
-pwsx2483 power 36.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2484 power 36.00E-2 0.5 -> 0.60 Inexact Rounded
-pwsx2485 power 36E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2486 power 36E+1 0.5 -> 19 Inexact Rounded
-pwsx2487 power 36E+2 0.5 -> 60 Inexact Rounded
-pwsx2488 power 36E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2489 power 0.37 0.5 -> 0.61 Inexact Rounded
-pwsx2490 power 0.037 0.5 -> 0.19 Inexact Rounded
-pwsx2491 power 37.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2492 power 37.00E-2 0.5 -> 0.61 Inexact Rounded
-pwsx2493 power 37E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2494 power 37E+1 0.5 -> 19 Inexact Rounded
-pwsx2495 power 37E+2 0.5 -> 61 Inexact Rounded
-pwsx2496 power 37E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2497 power 0.38 0.5 -> 0.62 Inexact Rounded
-pwsx2498 power 0.038 0.5 -> 0.19 Inexact Rounded
-pwsx2499 power 38.0E-1 0.5 -> 1.9 Inexact Rounded
-pwsx2500 power 38.00E-2 0.5 -> 0.62 Inexact Rounded
-pwsx2501 power 38E-3 0.5 -> 0.19 Inexact Rounded
-pwsx2502 power 38E+1 0.5 -> 19 Inexact Rounded
-pwsx2503 power 38E+2 0.5 -> 62 Inexact Rounded
-pwsx2504 power 38E+3 0.5 -> 1.9E+2 Inexact Rounded
-pwsx2505 power 0.39 0.5 -> 0.62 Inexact Rounded
-pwsx2506 power 0.039 0.5 -> 0.20 Inexact Rounded
-pwsx2507 power 39.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2508 power 39.00E-2 0.5 -> 0.62 Inexact Rounded
-pwsx2509 power 39E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2510 power 39E+1 0.5 -> 20 Inexact Rounded
-pwsx2511 power 39E+2 0.5 -> 62 Inexact Rounded
-pwsx2512 power 39E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2513 power 0.40 0.5 -> 0.63 Inexact Rounded
-pwsx2514 power 0.040 0.5 -> 0.20 Inexact Rounded
-pwsx2515 power 40.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2516 power 40.00E-2 0.5 -> 0.63 Inexact Rounded
-pwsx2517 power 40E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2518 power 40E+1 0.5 -> 20 Inexact Rounded
-pwsx2519 power 40E+2 0.5 -> 63 Inexact Rounded
-pwsx2520 power 40E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2521 power 0.41 0.5 -> 0.64 Inexact Rounded
-pwsx2522 power 0.041 0.5 -> 0.20 Inexact Rounded
-pwsx2523 power 41.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2524 power 41.00E-2 0.5 -> 0.64 Inexact Rounded
-pwsx2525 power 41E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2526 power 41E+1 0.5 -> 20 Inexact Rounded
-pwsx2527 power 41E+2 0.5 -> 64 Inexact Rounded
-pwsx2528 power 41E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2529 power 0.42 0.5 -> 0.65 Inexact Rounded
-pwsx2530 power 0.042 0.5 -> 0.20 Inexact Rounded
-pwsx2531 power 42.0E-1 0.5 -> 2.0 Inexact Rounded
-pwsx2532 power 42.00E-2 0.5 -> 0.65 Inexact Rounded
-pwsx2533 power 42E-3 0.5 -> 0.20 Inexact Rounded
-pwsx2534 power 42E+1 0.5 -> 20 Inexact Rounded
-pwsx2535 power 42E+2 0.5 -> 65 Inexact Rounded
-pwsx2536 power 42E+3 0.5 -> 2.0E+2 Inexact Rounded
-pwsx2537 power 0.43 0.5 -> 0.66 Inexact Rounded
-pwsx2538 power 0.043 0.5 -> 0.21 Inexact Rounded
-pwsx2539 power 43.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2540 power 43.00E-2 0.5 -> 0.66 Inexact Rounded
-pwsx2541 power 43E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2542 power 43E+1 0.5 -> 21 Inexact Rounded
-pwsx2543 power 43E+2 0.5 -> 66 Inexact Rounded
-pwsx2544 power 43E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2545 power 0.44 0.5 -> 0.66 Inexact Rounded
-pwsx2546 power 0.044 0.5 -> 0.21 Inexact Rounded
-pwsx2547 power 44.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2548 power 44.00E-2 0.5 -> 0.66 Inexact Rounded
-pwsx2549 power 44E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2550 power 44E+1 0.5 -> 21 Inexact Rounded
-pwsx2551 power 44E+2 0.5 -> 66 Inexact Rounded
-pwsx2552 power 44E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2553 power 0.45 0.5 -> 0.67 Inexact Rounded
-pwsx2554 power 0.045 0.5 -> 0.21 Inexact Rounded
-pwsx2555 power 45.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2556 power 45.00E-2 0.5 -> 0.67 Inexact Rounded
-pwsx2557 power 45E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2558 power 45E+1 0.5 -> 21 Inexact Rounded
-pwsx2559 power 45E+2 0.5 -> 67 Inexact Rounded
-pwsx2560 power 45E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2561 power 0.46 0.5 -> 0.68 Inexact Rounded
-pwsx2562 power 0.046 0.5 -> 0.21 Inexact Rounded
-pwsx2563 power 46.0E-1 0.5 -> 2.1 Inexact Rounded
-pwsx2564 power 46.00E-2 0.5 -> 0.68 Inexact Rounded
-pwsx2565 power 46E-3 0.5 -> 0.21 Inexact Rounded
-pwsx2566 power 46E+1 0.5 -> 21 Inexact Rounded
-pwsx2567 power 46E+2 0.5 -> 68 Inexact Rounded
-pwsx2568 power 46E+3 0.5 -> 2.1E+2 Inexact Rounded
-pwsx2569 power 0.47 0.5 -> 0.69 Inexact Rounded
-pwsx2570 power 0.047 0.5 -> 0.22 Inexact Rounded
-pwsx2571 power 47.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2572 power 47.00E-2 0.5 -> 0.69 Inexact Rounded
-pwsx2573 power 47E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2574 power 47E+1 0.5 -> 22 Inexact Rounded
-pwsx2575 power 47E+2 0.5 -> 69 Inexact Rounded
-pwsx2576 power 47E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2577 power 0.48 0.5 -> 0.69 Inexact Rounded
-pwsx2578 power 0.048 0.5 -> 0.22 Inexact Rounded
-pwsx2579 power 48.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2580 power 48.00E-2 0.5 -> 0.69 Inexact Rounded
-pwsx2581 power 48E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2582 power 48E+1 0.5 -> 22 Inexact Rounded
-pwsx2583 power 48E+2 0.5 -> 69 Inexact Rounded
-pwsx2584 power 48E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2585 power 0.49 0.5 -> 0.70 Inexact Rounded
-pwsx2586 power 0.049 0.5 -> 0.22 Inexact Rounded
-pwsx2587 power 49.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2588 power 49.00E-2 0.5 -> 0.70 Inexact Rounded
-pwsx2589 power 49E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2590 power 49E+1 0.5 -> 22 Inexact Rounded
-pwsx2591 power 49E+2 0.5 -> 70 Inexact Rounded
-pwsx2592 power 49E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2593 power 0.50 0.5 -> 0.71 Inexact Rounded
-pwsx2594 power 0.050 0.5 -> 0.22 Inexact Rounded
-pwsx2595 power 50.0E-1 0.5 -> 2.2 Inexact Rounded
-pwsx2596 power 50.00E-2 0.5 -> 0.71 Inexact Rounded
-pwsx2597 power 50E-3 0.5 -> 0.22 Inexact Rounded
-pwsx2598 power 50E+1 0.5 -> 22 Inexact Rounded
-pwsx2599 power 50E+2 0.5 -> 71 Inexact Rounded
-pwsx2600 power 50E+3 0.5 -> 2.2E+2 Inexact Rounded
-pwsx2601 power 0.51 0.5 -> 0.71 Inexact Rounded
-pwsx2602 power 0.051 0.5 -> 0.23 Inexact Rounded
-pwsx2603 power 51.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2604 power 51.00E-2 0.5 -> 0.71 Inexact Rounded
-pwsx2605 power 51E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2606 power 51E+1 0.5 -> 23 Inexact Rounded
-pwsx2607 power 51E+2 0.5 -> 71 Inexact Rounded
-pwsx2608 power 51E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2609 power 0.52 0.5 -> 0.72 Inexact Rounded
-pwsx2610 power 0.052 0.5 -> 0.23 Inexact Rounded
-pwsx2611 power 52.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2612 power 52.00E-2 0.5 -> 0.72 Inexact Rounded
-pwsx2613 power 52E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2614 power 52E+1 0.5 -> 23 Inexact Rounded
-pwsx2615 power 52E+2 0.5 -> 72 Inexact Rounded
-pwsx2616 power 52E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2617 power 0.53 0.5 -> 0.73 Inexact Rounded
-pwsx2618 power 0.053 0.5 -> 0.23 Inexact Rounded
-pwsx2619 power 53.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2620 power 53.00E-2 0.5 -> 0.73 Inexact Rounded
-pwsx2621 power 53E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2622 power 53E+1 0.5 -> 23 Inexact Rounded
-pwsx2623 power 53E+2 0.5 -> 73 Inexact Rounded
-pwsx2624 power 53E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2625 power 0.54 0.5 -> 0.73 Inexact Rounded
-pwsx2626 power 0.054 0.5 -> 0.23 Inexact Rounded
-pwsx2627 power 54.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2628 power 54.00E-2 0.5 -> 0.73 Inexact Rounded
-pwsx2629 power 54E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2630 power 54E+1 0.5 -> 23 Inexact Rounded
-pwsx2631 power 54E+2 0.5 -> 73 Inexact Rounded
-pwsx2632 power 54E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2633 power 0.55 0.5 -> 0.74 Inexact Rounded
-pwsx2634 power 0.055 0.5 -> 0.23 Inexact Rounded
-pwsx2635 power 55.0E-1 0.5 -> 2.3 Inexact Rounded
-pwsx2636 power 55.00E-2 0.5 -> 0.74 Inexact Rounded
-pwsx2637 power 55E-3 0.5 -> 0.23 Inexact Rounded
-pwsx2638 power 55E+1 0.5 -> 23 Inexact Rounded
-pwsx2639 power 55E+2 0.5 -> 74 Inexact Rounded
-pwsx2640 power 55E+3 0.5 -> 2.3E+2 Inexact Rounded
-pwsx2641 power 0.56 0.5 -> 0.75 Inexact Rounded
-pwsx2642 power 0.056 0.5 -> 0.24 Inexact Rounded
-pwsx2643 power 56.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2644 power 56.00E-2 0.5 -> 0.75 Inexact Rounded
-pwsx2645 power 56E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2646 power 56E+1 0.5 -> 24 Inexact Rounded
-pwsx2647 power 56E+2 0.5 -> 75 Inexact Rounded
-pwsx2648 power 56E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2649 power 0.57 0.5 -> 0.75 Inexact Rounded
-pwsx2650 power 0.057 0.5 -> 0.24 Inexact Rounded
-pwsx2651 power 57.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2652 power 57.00E-2 0.5 -> 0.75 Inexact Rounded
-pwsx2653 power 57E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2654 power 57E+1 0.5 -> 24 Inexact Rounded
-pwsx2655 power 57E+2 0.5 -> 75 Inexact Rounded
-pwsx2656 power 57E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2657 power 0.58 0.5 -> 0.76 Inexact Rounded
-pwsx2658 power 0.058 0.5 -> 0.24 Inexact Rounded
-pwsx2659 power 58.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2660 power 58.00E-2 0.5 -> 0.76 Inexact Rounded
-pwsx2661 power 58E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2662 power 58E+1 0.5 -> 24 Inexact Rounded
-pwsx2663 power 58E+2 0.5 -> 76 Inexact Rounded
-pwsx2664 power 58E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2665 power 0.59 0.5 -> 0.77 Inexact Rounded
-pwsx2666 power 0.059 0.5 -> 0.24 Inexact Rounded
-pwsx2667 power 59.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2668 power 59.00E-2 0.5 -> 0.77 Inexact Rounded
-pwsx2669 power 59E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2670 power 59E+1 0.5 -> 24 Inexact Rounded
-pwsx2671 power 59E+2 0.5 -> 77 Inexact Rounded
-pwsx2672 power 59E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2673 power 0.60 0.5 -> 0.77 Inexact Rounded
-pwsx2674 power 0.060 0.5 -> 0.24 Inexact Rounded
-pwsx2675 power 60.0E-1 0.5 -> 2.4 Inexact Rounded
-pwsx2676 power 60.00E-2 0.5 -> 0.77 Inexact Rounded
-pwsx2677 power 60E-3 0.5 -> 0.24 Inexact Rounded
-pwsx2678 power 60E+1 0.5 -> 24 Inexact Rounded
-pwsx2679 power 60E+2 0.5 -> 77 Inexact Rounded
-pwsx2680 power 60E+3 0.5 -> 2.4E+2 Inexact Rounded
-pwsx2681 power 0.61 0.5 -> 0.78 Inexact Rounded
-pwsx2682 power 0.061 0.5 -> 0.25 Inexact Rounded
-pwsx2683 power 61.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2684 power 61.00E-2 0.5 -> 0.78 Inexact Rounded
-pwsx2685 power 61E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2686 power 61E+1 0.5 -> 25 Inexact Rounded
-pwsx2687 power 61E+2 0.5 -> 78 Inexact Rounded
-pwsx2688 power 61E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2689 power 0.62 0.5 -> 0.79 Inexact Rounded
-pwsx2690 power 0.062 0.5 -> 0.25 Inexact Rounded
-pwsx2691 power 62.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2692 power 62.00E-2 0.5 -> 0.79 Inexact Rounded
-pwsx2693 power 62E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2694 power 62E+1 0.5 -> 25 Inexact Rounded
-pwsx2695 power 62E+2 0.5 -> 79 Inexact Rounded
-pwsx2696 power 62E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2697 power 0.63 0.5 -> 0.79 Inexact Rounded
-pwsx2698 power 0.063 0.5 -> 0.25 Inexact Rounded
-pwsx2699 power 63.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2700 power 63.00E-2 0.5 -> 0.79 Inexact Rounded
-pwsx2701 power 63E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2702 power 63E+1 0.5 -> 25 Inexact Rounded
-pwsx2703 power 63E+2 0.5 -> 79 Inexact Rounded
-pwsx2704 power 63E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2705 power 0.64 0.5 -> 0.80 Inexact Rounded
-pwsx2706 power 0.064 0.5 -> 0.25 Inexact Rounded
-pwsx2707 power 64.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2708 power 64.00E-2 0.5 -> 0.80 Inexact Rounded
-pwsx2709 power 64E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2710 power 64E+1 0.5 -> 25 Inexact Rounded
-pwsx2711 power 64E+2 0.5 -> 80 Inexact Rounded
-pwsx2712 power 64E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2713 power 0.65 0.5 -> 0.81 Inexact Rounded
-pwsx2714 power 0.065 0.5 -> 0.25 Inexact Rounded
-pwsx2715 power 65.0E-1 0.5 -> 2.5 Inexact Rounded
-pwsx2716 power 65.00E-2 0.5 -> 0.81 Inexact Rounded
-pwsx2717 power 65E-3 0.5 -> 0.25 Inexact Rounded
-pwsx2718 power 65E+1 0.5 -> 25 Inexact Rounded
-pwsx2719 power 65E+2 0.5 -> 81 Inexact Rounded
-pwsx2720 power 65E+3 0.5 -> 2.5E+2 Inexact Rounded
-pwsx2721 power 0.66 0.5 -> 0.81 Inexact Rounded
-pwsx2722 power 0.066 0.5 -> 0.26 Inexact Rounded
-pwsx2723 power 66.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2724 power 66.00E-2 0.5 -> 0.81 Inexact Rounded
-pwsx2725 power 66E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2726 power 66E+1 0.5 -> 26 Inexact Rounded
-pwsx2727 power 66E+2 0.5 -> 81 Inexact Rounded
-pwsx2728 power 66E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2729 power 0.67 0.5 -> 0.82 Inexact Rounded
-pwsx2730 power 0.067 0.5 -> 0.26 Inexact Rounded
-pwsx2731 power 67.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2732 power 67.00E-2 0.5 -> 0.82 Inexact Rounded
-pwsx2733 power 67E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2734 power 67E+1 0.5 -> 26 Inexact Rounded
-pwsx2735 power 67E+2 0.5 -> 82 Inexact Rounded
-pwsx2736 power 67E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2737 power 0.68 0.5 -> 0.82 Inexact Rounded
-pwsx2738 power 0.068 0.5 -> 0.26 Inexact Rounded
-pwsx2739 power 68.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2740 power 68.00E-2 0.5 -> 0.82 Inexact Rounded
-pwsx2741 power 68E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2742 power 68E+1 0.5 -> 26 Inexact Rounded
-pwsx2743 power 68E+2 0.5 -> 82 Inexact Rounded
-pwsx2744 power 68E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2745 power 0.69 0.5 -> 0.83 Inexact Rounded
-pwsx2746 power 0.069 0.5 -> 0.26 Inexact Rounded
-pwsx2747 power 69.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2748 power 69.00E-2 0.5 -> 0.83 Inexact Rounded
-pwsx2749 power 69E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2750 power 69E+1 0.5 -> 26 Inexact Rounded
-pwsx2751 power 69E+2 0.5 -> 83 Inexact Rounded
-pwsx2752 power 69E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2753 power 0.70 0.5 -> 0.84 Inexact Rounded
-pwsx2754 power 0.070 0.5 -> 0.26 Inexact Rounded
-pwsx2755 power 70.0E-1 0.5 -> 2.6 Inexact Rounded
-pwsx2756 power 70.00E-2 0.5 -> 0.84 Inexact Rounded
-pwsx2757 power 70E-3 0.5 -> 0.26 Inexact Rounded
-pwsx2758 power 70E+1 0.5 -> 26 Inexact Rounded
-pwsx2759 power 70E+2 0.5 -> 84 Inexact Rounded
-pwsx2760 power 70E+3 0.5 -> 2.6E+2 Inexact Rounded
-pwsx2761 power 0.71 0.5 -> 0.84 Inexact Rounded
-pwsx2762 power 0.071 0.5 -> 0.27 Inexact Rounded
-pwsx2763 power 71.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2764 power 71.00E-2 0.5 -> 0.84 Inexact Rounded
-pwsx2765 power 71E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2766 power 71E+1 0.5 -> 27 Inexact Rounded
-pwsx2767 power 71E+2 0.5 -> 84 Inexact Rounded
-pwsx2768 power 71E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2769 power 0.72 0.5 -> 0.85 Inexact Rounded
-pwsx2770 power 0.072 0.5 -> 0.27 Inexact Rounded
-pwsx2771 power 72.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2772 power 72.00E-2 0.5 -> 0.85 Inexact Rounded
-pwsx2773 power 72E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2774 power 72E+1 0.5 -> 27 Inexact Rounded
-pwsx2775 power 72E+2 0.5 -> 85 Inexact Rounded
-pwsx2776 power 72E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2777 power 0.73 0.5 -> 0.85 Inexact Rounded
-pwsx2778 power 0.073 0.5 -> 0.27 Inexact Rounded
-pwsx2779 power 73.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2780 power 73.00E-2 0.5 -> 0.85 Inexact Rounded
-pwsx2781 power 73E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2782 power 73E+1 0.5 -> 27 Inexact Rounded
-pwsx2783 power 73E+2 0.5 -> 85 Inexact Rounded
-pwsx2784 power 73E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2785 power 0.74 0.5 -> 0.86 Inexact Rounded
-pwsx2786 power 0.074 0.5 -> 0.27 Inexact Rounded
-pwsx2787 power 74.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2788 power 74.00E-2 0.5 -> 0.86 Inexact Rounded
-pwsx2789 power 74E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2790 power 74E+1 0.5 -> 27 Inexact Rounded
-pwsx2791 power 74E+2 0.5 -> 86 Inexact Rounded
-pwsx2792 power 74E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2793 power 0.75 0.5 -> 0.87 Inexact Rounded
-pwsx2794 power 0.075 0.5 -> 0.27 Inexact Rounded
-pwsx2795 power 75.0E-1 0.5 -> 2.7 Inexact Rounded
-pwsx2796 power 75.00E-2 0.5 -> 0.87 Inexact Rounded
-pwsx2797 power 75E-3 0.5 -> 0.27 Inexact Rounded
-pwsx2798 power 75E+1 0.5 -> 27 Inexact Rounded
-pwsx2799 power 75E+2 0.5 -> 87 Inexact Rounded
-pwsx2800 power 75E+3 0.5 -> 2.7E+2 Inexact Rounded
-pwsx2801 power 0.76 0.5 -> 0.87 Inexact Rounded
-pwsx2802 power 0.076 0.5 -> 0.28 Inexact Rounded
-pwsx2803 power 76.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2804 power 76.00E-2 0.5 -> 0.87 Inexact Rounded
-pwsx2805 power 76E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2806 power 76E+1 0.5 -> 28 Inexact Rounded
-pwsx2807 power 76E+2 0.5 -> 87 Inexact Rounded
-pwsx2808 power 76E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2809 power 0.77 0.5 -> 0.88 Inexact Rounded
-pwsx2810 power 0.077 0.5 -> 0.28 Inexact Rounded
-pwsx2811 power 77.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2812 power 77.00E-2 0.5 -> 0.88 Inexact Rounded
-pwsx2813 power 77E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2814 power 77E+1 0.5 -> 28 Inexact Rounded
-pwsx2815 power 77E+2 0.5 -> 88 Inexact Rounded
-pwsx2816 power 77E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2817 power 0.78 0.5 -> 0.88 Inexact Rounded
-pwsx2818 power 0.078 0.5 -> 0.28 Inexact Rounded
-pwsx2819 power 78.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2820 power 78.00E-2 0.5 -> 0.88 Inexact Rounded
-pwsx2821 power 78E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2822 power 78E+1 0.5 -> 28 Inexact Rounded
-pwsx2823 power 78E+2 0.5 -> 88 Inexact Rounded
-pwsx2824 power 78E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2825 power 0.79 0.5 -> 0.89 Inexact Rounded
-pwsx2826 power 0.079 0.5 -> 0.28 Inexact Rounded
-pwsx2827 power 79.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2828 power 79.00E-2 0.5 -> 0.89 Inexact Rounded
-pwsx2829 power 79E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2830 power 79E+1 0.5 -> 28 Inexact Rounded
-pwsx2831 power 79E+2 0.5 -> 89 Inexact Rounded
-pwsx2832 power 79E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2833 power 0.80 0.5 -> 0.89 Inexact Rounded
-pwsx2834 power 0.080 0.5 -> 0.28 Inexact Rounded
-pwsx2835 power 80.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2836 power 80.00E-2 0.5 -> 0.89 Inexact Rounded
-pwsx2837 power 80E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2838 power 80E+1 0.5 -> 28 Inexact Rounded
-pwsx2839 power 80E+2 0.5 -> 89 Inexact Rounded
-pwsx2840 power 80E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2841 power 0.81 0.5 -> 0.90 Inexact Rounded
-pwsx2842 power 0.081 0.5 -> 0.28 Inexact Rounded
-pwsx2843 power 81.0E-1 0.5 -> 2.8 Inexact Rounded
-pwsx2844 power 81.00E-2 0.5 -> 0.90 Inexact Rounded
-pwsx2845 power 81E-3 0.5 -> 0.28 Inexact Rounded
-pwsx2846 power 81E+1 0.5 -> 28 Inexact Rounded
-pwsx2847 power 81E+2 0.5 -> 90 Inexact Rounded
-pwsx2848 power 81E+3 0.5 -> 2.8E+2 Inexact Rounded
-pwsx2849 power 0.82 0.5 -> 0.91 Inexact Rounded
-pwsx2850 power 0.082 0.5 -> 0.29 Inexact Rounded
-pwsx2851 power 82.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2852 power 82.00E-2 0.5 -> 0.91 Inexact Rounded
-pwsx2853 power 82E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2854 power 82E+1 0.5 -> 29 Inexact Rounded
-pwsx2855 power 82E+2 0.5 -> 91 Inexact Rounded
-pwsx2856 power 82E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2857 power 0.83 0.5 -> 0.91 Inexact Rounded
-pwsx2858 power 0.083 0.5 -> 0.29 Inexact Rounded
-pwsx2859 power 83.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2860 power 83.00E-2 0.5 -> 0.91 Inexact Rounded
-pwsx2861 power 83E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2862 power 83E+1 0.5 -> 29 Inexact Rounded
-pwsx2863 power 83E+2 0.5 -> 91 Inexact Rounded
-pwsx2864 power 83E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2865 power 0.84 0.5 -> 0.92 Inexact Rounded
-pwsx2866 power 0.084 0.5 -> 0.29 Inexact Rounded
-pwsx2867 power 84.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2868 power 84.00E-2 0.5 -> 0.92 Inexact Rounded
-pwsx2869 power 84E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2870 power 84E+1 0.5 -> 29 Inexact Rounded
-pwsx2871 power 84E+2 0.5 -> 92 Inexact Rounded
-pwsx2872 power 84E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2873 power 0.85 0.5 -> 0.92 Inexact Rounded
-pwsx2874 power 0.085 0.5 -> 0.29 Inexact Rounded
-pwsx2875 power 85.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2876 power 85.00E-2 0.5 -> 0.92 Inexact Rounded
-pwsx2877 power 85E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2878 power 85E+1 0.5 -> 29 Inexact Rounded
-pwsx2879 power 85E+2 0.5 -> 92 Inexact Rounded
-pwsx2880 power 85E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2881 power 0.86 0.5 -> 0.93 Inexact Rounded
-pwsx2882 power 0.086 0.5 -> 0.29 Inexact Rounded
-pwsx2883 power 86.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2884 power 86.00E-2 0.5 -> 0.93 Inexact Rounded
-pwsx2885 power 86E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2886 power 86E+1 0.5 -> 29 Inexact Rounded
-pwsx2887 power 86E+2 0.5 -> 93 Inexact Rounded
-pwsx2888 power 86E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2889 power 0.87 0.5 -> 0.93 Inexact Rounded
-pwsx2890 power 0.087 0.5 -> 0.29 Inexact Rounded
-pwsx2891 power 87.0E-1 0.5 -> 2.9 Inexact Rounded
-pwsx2892 power 87.00E-2 0.5 -> 0.93 Inexact Rounded
-pwsx2893 power 87E-3 0.5 -> 0.29 Inexact Rounded
-pwsx2894 power 87E+1 0.5 -> 29 Inexact Rounded
-pwsx2895 power 87E+2 0.5 -> 93 Inexact Rounded
-pwsx2896 power 87E+3 0.5 -> 2.9E+2 Inexact Rounded
-pwsx2897 power 0.88 0.5 -> 0.94 Inexact Rounded
-pwsx2898 power 0.088 0.5 -> 0.30 Inexact Rounded
-pwsx2899 power 88.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2900 power 88.00E-2 0.5 -> 0.94 Inexact Rounded
-pwsx2901 power 88E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2902 power 88E+1 0.5 -> 30 Inexact Rounded
-pwsx2903 power 88E+2 0.5 -> 94 Inexact Rounded
-pwsx2904 power 88E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2905 power 0.89 0.5 -> 0.94 Inexact Rounded
-pwsx2906 power 0.089 0.5 -> 0.30 Inexact Rounded
-pwsx2907 power 89.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2908 power 89.00E-2 0.5 -> 0.94 Inexact Rounded
-pwsx2909 power 89E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2910 power 89E+1 0.5 -> 30 Inexact Rounded
-pwsx2911 power 89E+2 0.5 -> 94 Inexact Rounded
-pwsx2912 power 89E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2913 power 0.90 0.5 -> 0.95 Inexact Rounded
-pwsx2914 power 0.090 0.5 -> 0.30 Inexact Rounded
-pwsx2915 power 90.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2916 power 90.00E-2 0.5 -> 0.95 Inexact Rounded
-pwsx2917 power 90E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2918 power 90E+1 0.5 -> 30 Inexact Rounded
-pwsx2919 power 90E+2 0.5 -> 95 Inexact Rounded
-pwsx2920 power 90E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2921 power 0.91 0.5 -> 0.95 Inexact Rounded
-pwsx2922 power 0.091 0.5 -> 0.30 Inexact Rounded
-pwsx2923 power 91.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2924 power 91.00E-2 0.5 -> 0.95 Inexact Rounded
-pwsx2925 power 91E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2926 power 91E+1 0.5 -> 30 Inexact Rounded
-pwsx2927 power 91E+2 0.5 -> 95 Inexact Rounded
-pwsx2928 power 91E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2929 power 0.92 0.5 -> 0.96 Inexact Rounded
-pwsx2930 power 0.092 0.5 -> 0.30 Inexact Rounded
-pwsx2931 power 92.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2932 power 92.00E-2 0.5 -> 0.96 Inexact Rounded
-pwsx2933 power 92E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2934 power 92E+1 0.5 -> 30 Inexact Rounded
-pwsx2935 power 92E+2 0.5 -> 96 Inexact Rounded
-pwsx2936 power 92E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2937 power 0.93 0.5 -> 0.96 Inexact Rounded
-pwsx2938 power 0.093 0.5 -> 0.30 Inexact Rounded
-pwsx2939 power 93.0E-1 0.5 -> 3.0 Inexact Rounded
-pwsx2940 power 93.00E-2 0.5 -> 0.96 Inexact Rounded
-pwsx2941 power 93E-3 0.5 -> 0.30 Inexact Rounded
-pwsx2942 power 93E+1 0.5 -> 30 Inexact Rounded
-pwsx2943 power 93E+2 0.5 -> 96 Inexact Rounded
-pwsx2944 power 93E+3 0.5 -> 3.0E+2 Inexact Rounded
-pwsx2945 power 0.94 0.5 -> 0.97 Inexact Rounded
-pwsx2946 power 0.094 0.5 -> 0.31 Inexact Rounded
-pwsx2947 power 94.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2948 power 94.00E-2 0.5 -> 0.97 Inexact Rounded
-pwsx2949 power 94E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2950 power 94E+1 0.5 -> 31 Inexact Rounded
-pwsx2951 power 94E+2 0.5 -> 97 Inexact Rounded
-pwsx2952 power 94E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2953 power 0.95 0.5 -> 0.97 Inexact Rounded
-pwsx2954 power 0.095 0.5 -> 0.31 Inexact Rounded
-pwsx2955 power 95.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2956 power 95.00E-2 0.5 -> 0.97 Inexact Rounded
-pwsx2957 power 95E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2958 power 95E+1 0.5 -> 31 Inexact Rounded
-pwsx2959 power 95E+2 0.5 -> 97 Inexact Rounded
-pwsx2960 power 95E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2961 power 0.96 0.5 -> 0.98 Inexact Rounded
-pwsx2962 power 0.096 0.5 -> 0.31 Inexact Rounded
-pwsx2963 power 96.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2964 power 96.00E-2 0.5 -> 0.98 Inexact Rounded
-pwsx2965 power 96E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2966 power 96E+1 0.5 -> 31 Inexact Rounded
-pwsx2967 power 96E+2 0.5 -> 98 Inexact Rounded
-pwsx2968 power 96E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2969 power 0.97 0.5 -> 0.98 Inexact Rounded
-pwsx2970 power 0.097 0.5 -> 0.31 Inexact Rounded
-pwsx2971 power 97.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2972 power 97.00E-2 0.5 -> 0.98 Inexact Rounded
-pwsx2973 power 97E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2974 power 97E+1 0.5 -> 31 Inexact Rounded
-pwsx2975 power 97E+2 0.5 -> 98 Inexact Rounded
-pwsx2976 power 97E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2977 power 0.98 0.5 -> 0.99 Inexact Rounded
-pwsx2978 power 0.098 0.5 -> 0.31 Inexact Rounded
-pwsx2979 power 98.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2980 power 98.00E-2 0.5 -> 0.99 Inexact Rounded
-pwsx2981 power 98E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2982 power 98E+1 0.5 -> 31 Inexact Rounded
-pwsx2983 power 98E+2 0.5 -> 99 Inexact Rounded
-pwsx2984 power 98E+3 0.5 -> 3.1E+2 Inexact Rounded
-pwsx2985 power 0.99 0.5 -> 0.99 Inexact Rounded
-pwsx2986 power 0.099 0.5 -> 0.31 Inexact Rounded
-pwsx2987 power 99.0E-1 0.5 -> 3.1 Inexact Rounded
-pwsx2988 power 99.00E-2 0.5 -> 0.99 Inexact Rounded
-pwsx2989 power 99E-3 0.5 -> 0.31 Inexact Rounded
-pwsx2990 power 99E+1 0.5 -> 31 Inexact Rounded
-pwsx2991 power 99E+2 0.5 -> 99 Inexact Rounded
-pwsx2992 power 99E+3 0.5 -> 3.1E+2 Inexact Rounded
-
--- Precision 3 squareroot tests [exhaustive, f and f/10]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 3
-pwsx3001 power 0.1 0.5 -> 0.316 Inexact Rounded
-pwsx3002 power 0.01 0.5 -> 0.100 Inexact Rounded
-pwsx3003 power 0.2 0.5 -> 0.447 Inexact Rounded
-pwsx3004 power 0.02 0.5 -> 0.141 Inexact Rounded
-pwsx3005 power 0.3 0.5 -> 0.548 Inexact Rounded
-pwsx3006 power 0.03 0.5 -> 0.173 Inexact Rounded
-pwsx3007 power 0.4 0.5 -> 0.632 Inexact Rounded
-pwsx3008 power 0.04 0.5 -> 0.200 Inexact Rounded
-pwsx3009 power 0.5 0.5 -> 0.707 Inexact Rounded
-pwsx3010 power 0.05 0.5 -> 0.224 Inexact Rounded
-pwsx3011 power 0.6 0.5 -> 0.775 Inexact Rounded
-pwsx3012 power 0.06 0.5 -> 0.245 Inexact Rounded
-pwsx3013 power 0.7 0.5 -> 0.837 Inexact Rounded
-pwsx3014 power 0.07 0.5 -> 0.265 Inexact Rounded
-pwsx3015 power 0.8 0.5 -> 0.894 Inexact Rounded
-pwsx3016 power 0.08 0.5 -> 0.283 Inexact Rounded
-pwsx3017 power 0.9 0.5 -> 0.949 Inexact Rounded
-pwsx3018 power 0.09 0.5 -> 0.300 Inexact Rounded
-pwsx3019 power 0.11 0.5 -> 0.332 Inexact Rounded
-pwsx3020 power 0.011 0.5 -> 0.105 Inexact Rounded
-pwsx3021 power 0.12 0.5 -> 0.346 Inexact Rounded
-pwsx3022 power 0.012 0.5 -> 0.110 Inexact Rounded
-pwsx3023 power 0.13 0.5 -> 0.361 Inexact Rounded
-pwsx3024 power 0.013 0.5 -> 0.114 Inexact Rounded
-pwsx3025 power 0.14 0.5 -> 0.374 Inexact Rounded
-pwsx3026 power 0.014 0.5 -> 0.118 Inexact Rounded
-pwsx3027 power 0.15 0.5 -> 0.387 Inexact Rounded
-pwsx3028 power 0.015 0.5 -> 0.122 Inexact Rounded
-pwsx3029 power 0.16 0.5 -> 0.400 Inexact Rounded
-pwsx3030 power 0.016 0.5 -> 0.126 Inexact Rounded
-pwsx3031 power 0.17 0.5 -> 0.412 Inexact Rounded
-pwsx3032 power 0.017 0.5 -> 0.130 Inexact Rounded
-pwsx3033 power 0.18 0.5 -> 0.424 Inexact Rounded
-pwsx3034 power 0.018 0.5 -> 0.134 Inexact Rounded
-pwsx3035 power 0.19 0.5 -> 0.436 Inexact Rounded
-pwsx3036 power 0.019 0.5 -> 0.138 Inexact Rounded
-pwsx3037 power 0.21 0.5 -> 0.458 Inexact Rounded
-pwsx3038 power 0.021 0.5 -> 0.145 Inexact Rounded
-pwsx3039 power 0.22 0.5 -> 0.469 Inexact Rounded
-pwsx3040 power 0.022 0.5 -> 0.148 Inexact Rounded
-pwsx3041 power 0.23 0.5 -> 0.480 Inexact Rounded
-pwsx3042 power 0.023 0.5 -> 0.152 Inexact Rounded
-pwsx3043 power 0.24 0.5 -> 0.490 Inexact Rounded
-pwsx3044 power 0.024 0.5 -> 0.155 Inexact Rounded
-pwsx3045 power 0.25 0.5 -> 0.500 Inexact Rounded
-pwsx3046 power 0.025 0.5 -> 0.158 Inexact Rounded
-pwsx3047 power 0.26 0.5 -> 0.510 Inexact Rounded
-pwsx3048 power 0.026 0.5 -> 0.161 Inexact Rounded
-pwsx3049 power 0.27 0.5 -> 0.520 Inexact Rounded
-pwsx3050 power 0.027 0.5 -> 0.164 Inexact Rounded
-pwsx3051 power 0.28 0.5 -> 0.529 Inexact Rounded
-pwsx3052 power 0.028 0.5 -> 0.167 Inexact Rounded
-pwsx3053 power 0.29 0.5 -> 0.539 Inexact Rounded
-pwsx3054 power 0.029 0.5 -> 0.170 Inexact Rounded
-pwsx3055 power 0.31 0.5 -> 0.557 Inexact Rounded
-pwsx3056 power 0.031 0.5 -> 0.176 Inexact Rounded
-pwsx3057 power 0.32 0.5 -> 0.566 Inexact Rounded
-pwsx3058 power 0.032 0.5 -> 0.179 Inexact Rounded
-pwsx3059 power 0.33 0.5 -> 0.574 Inexact Rounded
-pwsx3060 power 0.033 0.5 -> 0.182 Inexact Rounded
-pwsx3061 power 0.34 0.5 -> 0.583 Inexact Rounded
-pwsx3062 power 0.034 0.5 -> 0.184 Inexact Rounded
-pwsx3063 power 0.35 0.5 -> 0.592 Inexact Rounded
-pwsx3064 power 0.035 0.5 -> 0.187 Inexact Rounded
-pwsx3065 power 0.36 0.5 -> 0.600 Inexact Rounded
-pwsx3066 power 0.036 0.5 -> 0.190 Inexact Rounded
-pwsx3067 power 0.37 0.5 -> 0.608 Inexact Rounded
-pwsx3068 power 0.037 0.5 -> 0.192 Inexact Rounded
-pwsx3069 power 0.38 0.5 -> 0.616 Inexact Rounded
-pwsx3070 power 0.038 0.5 -> 0.195 Inexact Rounded
-pwsx3071 power 0.39 0.5 -> 0.624 Inexact Rounded
-pwsx3072 power 0.039 0.5 -> 0.197 Inexact Rounded
-pwsx3073 power 0.41 0.5 -> 0.640 Inexact Rounded
-pwsx3074 power 0.041 0.5 -> 0.202 Inexact Rounded
-pwsx3075 power 0.42 0.5 -> 0.648 Inexact Rounded
-pwsx3076 power 0.042 0.5 -> 0.205 Inexact Rounded
-pwsx3077 power 0.43 0.5 -> 0.656 Inexact Rounded
-pwsx3078 power 0.043 0.5 -> 0.207 Inexact Rounded
-pwsx3079 power 0.44 0.5 -> 0.663 Inexact Rounded
-pwsx3080 power 0.044 0.5 -> 0.210 Inexact Rounded
-pwsx3081 power 0.45 0.5 -> 0.671 Inexact Rounded
-pwsx3082 power 0.045 0.5 -> 0.212 Inexact Rounded
-pwsx3083 power 0.46 0.5 -> 0.678 Inexact Rounded
-pwsx3084 power 0.046 0.5 -> 0.214 Inexact Rounded
-pwsx3085 power 0.47 0.5 -> 0.686 Inexact Rounded
-pwsx3086 power 0.047 0.5 -> 0.217 Inexact Rounded
-pwsx3087 power 0.48 0.5 -> 0.693 Inexact Rounded
-pwsx3088 power 0.048 0.5 -> 0.219 Inexact Rounded
-pwsx3089 power 0.49 0.5 -> 0.700 Inexact Rounded
-pwsx3090 power 0.049 0.5 -> 0.221 Inexact Rounded
-pwsx3091 power 0.51 0.5 -> 0.714 Inexact Rounded
-pwsx3092 power 0.051 0.5 -> 0.226 Inexact Rounded
-pwsx3093 power 0.52 0.5 -> 0.721 Inexact Rounded
-pwsx3094 power 0.052 0.5 -> 0.228 Inexact Rounded
-pwsx3095 power 0.53 0.5 -> 0.728 Inexact Rounded
-pwsx3096 power 0.053 0.5 -> 0.230 Inexact Rounded
-pwsx3097 power 0.54 0.5 -> 0.735 Inexact Rounded
-pwsx3098 power 0.054 0.5 -> 0.232 Inexact Rounded
-pwsx3099 power 0.55 0.5 -> 0.742 Inexact Rounded
-pwsx3100 power 0.055 0.5 -> 0.235 Inexact Rounded
-pwsx3101 power 0.56 0.5 -> 0.748 Inexact Rounded
-pwsx3102 power 0.056 0.5 -> 0.237 Inexact Rounded
-pwsx3103 power 0.57 0.5 -> 0.755 Inexact Rounded
-pwsx3104 power 0.057 0.5 -> 0.239 Inexact Rounded
-pwsx3105 power 0.58 0.5 -> 0.762 Inexact Rounded
-pwsx3106 power 0.058 0.5 -> 0.241 Inexact Rounded
-pwsx3107 power 0.59 0.5 -> 0.768 Inexact Rounded
-pwsx3108 power 0.059 0.5 -> 0.243 Inexact Rounded
-pwsx3109 power 0.61 0.5 -> 0.781 Inexact Rounded
-pwsx3110 power 0.061 0.5 -> 0.247 Inexact Rounded
-pwsx3111 power 0.62 0.5 -> 0.787 Inexact Rounded
-pwsx3112 power 0.062 0.5 -> 0.249 Inexact Rounded
-pwsx3113 power 0.63 0.5 -> 0.794 Inexact Rounded
-pwsx3114 power 0.063 0.5 -> 0.251 Inexact Rounded
-pwsx3115 power 0.64 0.5 -> 0.800 Inexact Rounded
-pwsx3116 power 0.064 0.5 -> 0.253 Inexact Rounded
-pwsx3117 power 0.65 0.5 -> 0.806 Inexact Rounded
-pwsx3118 power 0.065 0.5 -> 0.255 Inexact Rounded
-pwsx3119 power 0.66 0.5 -> 0.812 Inexact Rounded
-pwsx3120 power 0.066 0.5 -> 0.257 Inexact Rounded
-pwsx3121 power 0.67 0.5 -> 0.819 Inexact Rounded
-pwsx3122 power 0.067 0.5 -> 0.259 Inexact Rounded
-pwsx3123 power 0.68 0.5 -> 0.825 Inexact Rounded
-pwsx3124 power 0.068 0.5 -> 0.261 Inexact Rounded
-pwsx3125 power 0.69 0.5 -> 0.831 Inexact Rounded
-pwsx3126 power 0.069 0.5 -> 0.263 Inexact Rounded
-pwsx3127 power 0.71 0.5 -> 0.843 Inexact Rounded
-pwsx3128 power 0.071 0.5 -> 0.266 Inexact Rounded
-pwsx3129 power 0.72 0.5 -> 0.849 Inexact Rounded
-pwsx3130 power 0.072 0.5 -> 0.268 Inexact Rounded
-pwsx3131 power 0.73 0.5 -> 0.854 Inexact Rounded
-pwsx3132 power 0.073 0.5 -> 0.270 Inexact Rounded
-pwsx3133 power 0.74 0.5 -> 0.860 Inexact Rounded
-pwsx3134 power 0.074 0.5 -> 0.272 Inexact Rounded
-pwsx3135 power 0.75 0.5 -> 0.866 Inexact Rounded
-pwsx3136 power 0.075 0.5 -> 0.274 Inexact Rounded
-pwsx3137 power 0.76 0.5 -> 0.872 Inexact Rounded
-pwsx3138 power 0.076 0.5 -> 0.276 Inexact Rounded
-pwsx3139 power 0.77 0.5 -> 0.877 Inexact Rounded
-pwsx3140 power 0.077 0.5 -> 0.277 Inexact Rounded
-pwsx3141 power 0.78 0.5 -> 0.883 Inexact Rounded
-pwsx3142 power 0.078 0.5 -> 0.279 Inexact Rounded
-pwsx3143 power 0.79 0.5 -> 0.889 Inexact Rounded
-pwsx3144 power 0.079 0.5 -> 0.281 Inexact Rounded
-pwsx3145 power 0.81 0.5 -> 0.900 Inexact Rounded
-pwsx3146 power 0.081 0.5 -> 0.285 Inexact Rounded
-pwsx3147 power 0.82 0.5 -> 0.906 Inexact Rounded
-pwsx3148 power 0.082 0.5 -> 0.286 Inexact Rounded
-pwsx3149 power 0.83 0.5 -> 0.911 Inexact Rounded
-pwsx3150 power 0.083 0.5 -> 0.288 Inexact Rounded
-pwsx3151 power 0.84 0.5 -> 0.917 Inexact Rounded
-pwsx3152 power 0.084 0.5 -> 0.290 Inexact Rounded
-pwsx3153 power 0.85 0.5 -> 0.922 Inexact Rounded
-pwsx3154 power 0.085 0.5 -> 0.292 Inexact Rounded
-pwsx3155 power 0.86 0.5 -> 0.927 Inexact Rounded
-pwsx3156 power 0.086 0.5 -> 0.293 Inexact Rounded
-pwsx3157 power 0.87 0.5 -> 0.933 Inexact Rounded
-pwsx3158 power 0.087 0.5 -> 0.295 Inexact Rounded
-pwsx3159 power 0.88 0.5 -> 0.938 Inexact Rounded
-pwsx3160 power 0.088 0.5 -> 0.297 Inexact Rounded
-pwsx3161 power 0.89 0.5 -> 0.943 Inexact Rounded
-pwsx3162 power 0.089 0.5 -> 0.298 Inexact Rounded
-pwsx3163 power 0.91 0.5 -> 0.954 Inexact Rounded
-pwsx3164 power 0.091 0.5 -> 0.302 Inexact Rounded
-pwsx3165 power 0.92 0.5 -> 0.959 Inexact Rounded
-pwsx3166 power 0.092 0.5 -> 0.303 Inexact Rounded
-pwsx3167 power 0.93 0.5 -> 0.964 Inexact Rounded
-pwsx3168 power 0.093 0.5 -> 0.305 Inexact Rounded
-pwsx3169 power 0.94 0.5 -> 0.970 Inexact Rounded
-pwsx3170 power 0.094 0.5 -> 0.307 Inexact Rounded
-pwsx3171 power 0.95 0.5 -> 0.975 Inexact Rounded
-pwsx3172 power 0.095 0.5 -> 0.308 Inexact Rounded
-pwsx3173 power 0.96 0.5 -> 0.980 Inexact Rounded
-pwsx3174 power 0.096 0.5 -> 0.310 Inexact Rounded
-pwsx3175 power 0.97 0.5 -> 0.985 Inexact Rounded
-pwsx3176 power 0.097 0.5 -> 0.311 Inexact Rounded
-pwsx3177 power 0.98 0.5 -> 0.990 Inexact Rounded
-pwsx3178 power 0.098 0.5 -> 0.313 Inexact Rounded
-pwsx3179 power 0.99 0.5 -> 0.995 Inexact Rounded
-pwsx3180 power 0.099 0.5 -> 0.315 Inexact Rounded
-pwsx3181 power 0.101 0.5 -> 0.318 Inexact Rounded
-pwsx3182 power 0.0101 0.5 -> 0.100 Inexact Rounded
-pwsx3183 power 0.102 0.5 -> 0.319 Inexact Rounded
-pwsx3184 power 0.0102 0.5 -> 0.101 Inexact Rounded
-pwsx3185 power 0.103 0.5 -> 0.321 Inexact Rounded
-pwsx3186 power 0.0103 0.5 -> 0.101 Inexact Rounded
-pwsx3187 power 0.104 0.5 -> 0.322 Inexact Rounded
-pwsx3188 power 0.0104 0.5 -> 0.102 Inexact Rounded
-pwsx3189 power 0.105 0.5 -> 0.324 Inexact Rounded
-pwsx3190 power 0.0105 0.5 -> 0.102 Inexact Rounded
-pwsx3191 power 0.106 0.5 -> 0.326 Inexact Rounded
-pwsx3192 power 0.0106 0.5 -> 0.103 Inexact Rounded
-pwsx3193 power 0.107 0.5 -> 0.327 Inexact Rounded
-pwsx3194 power 0.0107 0.5 -> 0.103 Inexact Rounded
-pwsx3195 power 0.108 0.5 -> 0.329 Inexact Rounded
-pwsx3196 power 0.0108 0.5 -> 0.104 Inexact Rounded
-pwsx3197 power 0.109 0.5 -> 0.330 Inexact Rounded
-pwsx3198 power 0.0109 0.5 -> 0.104 Inexact Rounded
-pwsx3199 power 0.111 0.5 -> 0.333 Inexact Rounded
-pwsx3200 power 0.0111 0.5 -> 0.105 Inexact Rounded
-pwsx3201 power 0.112 0.5 -> 0.335 Inexact Rounded
-pwsx3202 power 0.0112 0.5 -> 0.106 Inexact Rounded
-pwsx3203 power 0.113 0.5 -> 0.336 Inexact Rounded
-pwsx3204 power 0.0113 0.5 -> 0.106 Inexact Rounded
-pwsx3205 power 0.114 0.5 -> 0.338 Inexact Rounded
-pwsx3206 power 0.0114 0.5 -> 0.107 Inexact Rounded
-pwsx3207 power 0.115 0.5 -> 0.339 Inexact Rounded
-pwsx3208 power 0.0115 0.5 -> 0.107 Inexact Rounded
-pwsx3209 power 0.116 0.5 -> 0.341 Inexact Rounded
-pwsx3210 power 0.0116 0.5 -> 0.108 Inexact Rounded
-pwsx3211 power 0.117 0.5 -> 0.342 Inexact Rounded
-pwsx3212 power 0.0117 0.5 -> 0.108 Inexact Rounded
-pwsx3213 power 0.118 0.5 -> 0.344 Inexact Rounded
-pwsx3214 power 0.0118 0.5 -> 0.109 Inexact Rounded
-pwsx3215 power 0.119 0.5 -> 0.345 Inexact Rounded
-pwsx3216 power 0.0119 0.5 -> 0.109 Inexact Rounded
-pwsx3217 power 0.121 0.5 -> 0.348 Inexact Rounded
-pwsx3218 power 0.0121 0.5 -> 0.110 Inexact Rounded
-pwsx3219 power 0.122 0.5 -> 0.349 Inexact Rounded
-pwsx3220 power 0.0122 0.5 -> 0.110 Inexact Rounded
-pwsx3221 power 0.123 0.5 -> 0.351 Inexact Rounded
-pwsx3222 power 0.0123 0.5 -> 0.111 Inexact Rounded
-pwsx3223 power 0.124 0.5 -> 0.352 Inexact Rounded
-pwsx3224 power 0.0124 0.5 -> 0.111 Inexact Rounded
-pwsx3225 power 0.125 0.5 -> 0.354 Inexact Rounded
-pwsx3226 power 0.0125 0.5 -> 0.112 Inexact Rounded
-pwsx3227 power 0.126 0.5 -> 0.355 Inexact Rounded
-pwsx3228 power 0.0126 0.5 -> 0.112 Inexact Rounded
-pwsx3229 power 0.127 0.5 -> 0.356 Inexact Rounded
-pwsx3230 power 0.0127 0.5 -> 0.113 Inexact Rounded
-pwsx3231 power 0.128 0.5 -> 0.358 Inexact Rounded
-pwsx3232 power 0.0128 0.5 -> 0.113 Inexact Rounded
-pwsx3233 power 0.129 0.5 -> 0.359 Inexact Rounded
-pwsx3234 power 0.0129 0.5 -> 0.114 Inexact Rounded
-pwsx3235 power 0.131 0.5 -> 0.362 Inexact Rounded
-pwsx3236 power 0.0131 0.5 -> 0.114 Inexact Rounded
-pwsx3237 power 0.132 0.5 -> 0.363 Inexact Rounded
-pwsx3238 power 0.0132 0.5 -> 0.115 Inexact Rounded
-pwsx3239 power 0.133 0.5 -> 0.365 Inexact Rounded
-pwsx3240 power 0.0133 0.5 -> 0.115 Inexact Rounded
-pwsx3241 power 0.134 0.5 -> 0.366 Inexact Rounded
-pwsx3242 power 0.0134 0.5 -> 0.116 Inexact Rounded
-pwsx3243 power 0.135 0.5 -> 0.367 Inexact Rounded
-pwsx3244 power 0.0135 0.5 -> 0.116 Inexact Rounded
-pwsx3245 power 0.136 0.5 -> 0.369 Inexact Rounded
-pwsx3246 power 0.0136 0.5 -> 0.117 Inexact Rounded
-pwsx3247 power 0.137 0.5 -> 0.370 Inexact Rounded
-pwsx3248 power 0.0137 0.5 -> 0.117 Inexact Rounded
-pwsx3249 power 0.138 0.5 -> 0.371 Inexact Rounded
-pwsx3250 power 0.0138 0.5 -> 0.117 Inexact Rounded
-pwsx3251 power 0.139 0.5 -> 0.373 Inexact Rounded
-pwsx3252 power 0.0139 0.5 -> 0.118 Inexact Rounded
-pwsx3253 power 0.141 0.5 -> 0.375 Inexact Rounded
-pwsx3254 power 0.0141 0.5 -> 0.119 Inexact Rounded
-pwsx3255 power 0.142 0.5 -> 0.377 Inexact Rounded
-pwsx3256 power 0.0142 0.5 -> 0.119 Inexact Rounded
-pwsx3257 power 0.143 0.5 -> 0.378 Inexact Rounded
-pwsx3258 power 0.0143 0.5 -> 0.120 Inexact Rounded
-pwsx3259 power 0.144 0.5 -> 0.379 Inexact Rounded
-pwsx3260 power 0.0144 0.5 -> 0.120 Inexact Rounded
-pwsx3261 power 0.145 0.5 -> 0.381 Inexact Rounded
-pwsx3262 power 0.0145 0.5 -> 0.120 Inexact Rounded
-pwsx3263 power 0.146 0.5 -> 0.382 Inexact Rounded
-pwsx3264 power 0.0146 0.5 -> 0.121 Inexact Rounded
-pwsx3265 power 0.147 0.5 -> 0.383 Inexact Rounded
-pwsx3266 power 0.0147 0.5 -> 0.121 Inexact Rounded
-pwsx3267 power 0.148 0.5 -> 0.385 Inexact Rounded
-pwsx3268 power 0.0148 0.5 -> 0.122 Inexact Rounded
-pwsx3269 power 0.149 0.5 -> 0.386 Inexact Rounded
-pwsx3270 power 0.0149 0.5 -> 0.122 Inexact Rounded
-pwsx3271 power 0.151 0.5 -> 0.389 Inexact Rounded
-pwsx3272 power 0.0151 0.5 -> 0.123 Inexact Rounded
-pwsx3273 power 0.152 0.5 -> 0.390 Inexact Rounded
-pwsx3274 power 0.0152 0.5 -> 0.123 Inexact Rounded
-pwsx3275 power 0.153 0.5 -> 0.391 Inexact Rounded
-pwsx3276 power 0.0153 0.5 -> 0.124 Inexact Rounded
-pwsx3277 power 0.154 0.5 -> 0.392 Inexact Rounded
-pwsx3278 power 0.0154 0.5 -> 0.124 Inexact Rounded
-pwsx3279 power 0.155 0.5 -> 0.394 Inexact Rounded
-pwsx3280 power 0.0155 0.5 -> 0.124 Inexact Rounded
-pwsx3281 power 0.156 0.5 -> 0.395 Inexact Rounded
-pwsx3282 power 0.0156 0.5 -> 0.125 Inexact Rounded
-pwsx3283 power 0.157 0.5 -> 0.396 Inexact Rounded
-pwsx3284 power 0.0157 0.5 -> 0.125 Inexact Rounded
-pwsx3285 power 0.158 0.5 -> 0.397 Inexact Rounded
-pwsx3286 power 0.0158 0.5 -> 0.126 Inexact Rounded
-pwsx3287 power 0.159 0.5 -> 0.399 Inexact Rounded
-pwsx3288 power 0.0159 0.5 -> 0.126 Inexact Rounded
-pwsx3289 power 0.161 0.5 -> 0.401 Inexact Rounded
-pwsx3290 power 0.0161 0.5 -> 0.127 Inexact Rounded
-pwsx3291 power 0.162 0.5 -> 0.402 Inexact Rounded
-pwsx3292 power 0.0162 0.5 -> 0.127 Inexact Rounded
-pwsx3293 power 0.163 0.5 -> 0.404 Inexact Rounded
-pwsx3294 power 0.0163 0.5 -> 0.128 Inexact Rounded
-pwsx3295 power 0.164 0.5 -> 0.405 Inexact Rounded
-pwsx3296 power 0.0164 0.5 -> 0.128 Inexact Rounded
-pwsx3297 power 0.165 0.5 -> 0.406 Inexact Rounded
-pwsx3298 power 0.0165 0.5 -> 0.128 Inexact Rounded
-pwsx3299 power 0.166 0.5 -> 0.407 Inexact Rounded
-pwsx3300 power 0.0166 0.5 -> 0.129 Inexact Rounded
-pwsx3301 power 0.167 0.5 -> 0.409 Inexact Rounded
-pwsx3302 power 0.0167 0.5 -> 0.129 Inexact Rounded
-pwsx3303 power 0.168 0.5 -> 0.410 Inexact Rounded
-pwsx3304 power 0.0168 0.5 -> 0.130 Inexact Rounded
-pwsx3305 power 0.169 0.5 -> 0.411 Inexact Rounded
-pwsx3306 power 0.0169 0.5 -> 0.130 Inexact Rounded
-pwsx3307 power 0.171 0.5 -> 0.414 Inexact Rounded
-pwsx3308 power 0.0171 0.5 -> 0.131 Inexact Rounded
-pwsx3309 power 0.172 0.5 -> 0.415 Inexact Rounded
-pwsx3310 power 0.0172 0.5 -> 0.131 Inexact Rounded
-pwsx3311 power 0.173 0.5 -> 0.416 Inexact Rounded
-pwsx3312 power 0.0173 0.5 -> 0.132 Inexact Rounded
-pwsx3313 power 0.174 0.5 -> 0.417 Inexact Rounded
-pwsx3314 power 0.0174 0.5 -> 0.132 Inexact Rounded
-pwsx3315 power 0.175 0.5 -> 0.418 Inexact Rounded
-pwsx3316 power 0.0175 0.5 -> 0.132 Inexact Rounded
-pwsx3317 power 0.176 0.5 -> 0.420 Inexact Rounded
-pwsx3318 power 0.0176 0.5 -> 0.133 Inexact Rounded
-pwsx3319 power 0.177 0.5 -> 0.421 Inexact Rounded
-pwsx3320 power 0.0177 0.5 -> 0.133 Inexact Rounded
-pwsx3321 power 0.178 0.5 -> 0.422 Inexact Rounded
-pwsx3322 power 0.0178 0.5 -> 0.133 Inexact Rounded
-pwsx3323 power 0.179 0.5 -> 0.423 Inexact Rounded
-pwsx3324 power 0.0179 0.5 -> 0.134 Inexact Rounded
-pwsx3325 power 0.181 0.5 -> 0.425 Inexact Rounded
-pwsx3326 power 0.0181 0.5 -> 0.135 Inexact Rounded
-pwsx3327 power 0.182 0.5 -> 0.427 Inexact Rounded
-pwsx3328 power 0.0182 0.5 -> 0.135 Inexact Rounded
-pwsx3329 power 0.183 0.5 -> 0.428 Inexact Rounded
-pwsx3330 power 0.0183 0.5 -> 0.135 Inexact Rounded
-pwsx3331 power 0.184 0.5 -> 0.429 Inexact Rounded
-pwsx3332 power 0.0184 0.5 -> 0.136 Inexact Rounded
-pwsx3333 power 0.185 0.5 -> 0.430 Inexact Rounded
-pwsx3334 power 0.0185 0.5 -> 0.136 Inexact Rounded
-pwsx3335 power 0.186 0.5 -> 0.431 Inexact Rounded
-pwsx3336 power 0.0186 0.5 -> 0.136 Inexact Rounded
-pwsx3337 power 0.187 0.5 -> 0.432 Inexact Rounded
-pwsx3338 power 0.0187 0.5 -> 0.137 Inexact Rounded
-pwsx3339 power 0.188 0.5 -> 0.434 Inexact Rounded
-pwsx3340 power 0.0188 0.5 -> 0.137 Inexact Rounded
-pwsx3341 power 0.189 0.5 -> 0.435 Inexact Rounded
-pwsx3342 power 0.0189 0.5 -> 0.137 Inexact Rounded
-pwsx3343 power 0.191 0.5 -> 0.437 Inexact Rounded
-pwsx3344 power 0.0191 0.5 -> 0.138 Inexact Rounded
-pwsx3345 power 0.192 0.5 -> 0.438 Inexact Rounded
-pwsx3346 power 0.0192 0.5 -> 0.139 Inexact Rounded
-pwsx3347 power 0.193 0.5 -> 0.439 Inexact Rounded
-pwsx3348 power 0.0193 0.5 -> 0.139 Inexact Rounded
-pwsx3349 power 0.194 0.5 -> 0.440 Inexact Rounded
-pwsx3350 power 0.0194 0.5 -> 0.139 Inexact Rounded
-pwsx3351 power 0.195 0.5 -> 0.442 Inexact Rounded
-pwsx3352 power 0.0195 0.5 -> 0.140 Inexact Rounded
-pwsx3353 power 0.196 0.5 -> 0.443 Inexact Rounded
-pwsx3354 power 0.0196 0.5 -> 0.140 Inexact Rounded
-pwsx3355 power 0.197 0.5 -> 0.444 Inexact Rounded
-pwsx3356 power 0.0197 0.5 -> 0.140 Inexact Rounded
-pwsx3357 power 0.198 0.5 -> 0.445 Inexact Rounded
-pwsx3358 power 0.0198 0.5 -> 0.141 Inexact Rounded
-pwsx3359 power 0.199 0.5 -> 0.446 Inexact Rounded
-pwsx3360 power 0.0199 0.5 -> 0.141 Inexact Rounded
-pwsx3361 power 0.201 0.5 -> 0.448 Inexact Rounded
-pwsx3362 power 0.0201 0.5 -> 0.142 Inexact Rounded
-pwsx3363 power 0.202 0.5 -> 0.449 Inexact Rounded
-pwsx3364 power 0.0202 0.5 -> 0.142 Inexact Rounded
-pwsx3365 power 0.203 0.5 -> 0.451 Inexact Rounded
-pwsx3366 power 0.0203 0.5 -> 0.142 Inexact Rounded
-pwsx3367 power 0.204 0.5 -> 0.452 Inexact Rounded
-pwsx3368 power 0.0204 0.5 -> 0.143 Inexact Rounded
-pwsx3369 power 0.205 0.5 -> 0.453 Inexact Rounded
-pwsx3370 power 0.0205 0.5 -> 0.143 Inexact Rounded
-pwsx3371 power 0.206 0.5 -> 0.454 Inexact Rounded
-pwsx3372 power 0.0206 0.5 -> 0.144 Inexact Rounded
-pwsx3373 power 0.207 0.5 -> 0.455 Inexact Rounded
-pwsx3374 power 0.0207 0.5 -> 0.144 Inexact Rounded
-pwsx3375 power 0.208 0.5 -> 0.456 Inexact Rounded
-pwsx3376 power 0.0208 0.5 -> 0.144 Inexact Rounded
-pwsx3377 power 0.209 0.5 -> 0.457 Inexact Rounded
-pwsx3378 power 0.0209 0.5 -> 0.145 Inexact Rounded
-pwsx3379 power 0.211 0.5 -> 0.459 Inexact Rounded
-pwsx3380 power 0.0211 0.5 -> 0.145 Inexact Rounded
-pwsx3381 power 0.212 0.5 -> 0.460 Inexact Rounded
-pwsx3382 power 0.0212 0.5 -> 0.146 Inexact Rounded
-pwsx3383 power 0.213 0.5 -> 0.462 Inexact Rounded
-pwsx3384 power 0.0213 0.5 -> 0.146 Inexact Rounded
-pwsx3385 power 0.214 0.5 -> 0.463 Inexact Rounded
-pwsx3386 power 0.0214 0.5 -> 0.146 Inexact Rounded
-pwsx3387 power 0.215 0.5 -> 0.464 Inexact Rounded
-pwsx3388 power 0.0215 0.5 -> 0.147 Inexact Rounded
-pwsx3389 power 0.216 0.5 -> 0.465 Inexact Rounded
-pwsx3390 power 0.0216 0.5 -> 0.147 Inexact Rounded
-pwsx3391 power 0.217 0.5 -> 0.466 Inexact Rounded
-pwsx3392 power 0.0217 0.5 -> 0.147 Inexact Rounded
-pwsx3393 power 0.218 0.5 -> 0.467 Inexact Rounded
-pwsx3394 power 0.0218 0.5 -> 0.148 Inexact Rounded
-pwsx3395 power 0.219 0.5 -> 0.468 Inexact Rounded
-pwsx3396 power 0.0219 0.5 -> 0.148 Inexact Rounded
-pwsx3397 power 0.221 0.5 -> 0.470 Inexact Rounded
-pwsx3398 power 0.0221 0.5 -> 0.149 Inexact Rounded
-pwsx3399 power 0.222 0.5 -> 0.471 Inexact Rounded
-pwsx3400 power 0.0222 0.5 -> 0.149 Inexact Rounded
-pwsx3401 power 0.223 0.5 -> 0.472 Inexact Rounded
-pwsx3402 power 0.0223 0.5 -> 0.149 Inexact Rounded
-pwsx3403 power 0.224 0.5 -> 0.473 Inexact Rounded
-pwsx3404 power 0.0224 0.5 -> 0.150 Inexact Rounded
-pwsx3405 power 0.225 0.5 -> 0.474 Inexact Rounded
-pwsx3406 power 0.0225 0.5 -> 0.150 Inexact Rounded
-pwsx3407 power 0.226 0.5 -> 0.475 Inexact Rounded
-pwsx3408 power 0.0226 0.5 -> 0.150 Inexact Rounded
-pwsx3409 power 0.227 0.5 -> 0.476 Inexact Rounded
-pwsx3410 power 0.0227 0.5 -> 0.151 Inexact Rounded
-pwsx3411 power 0.228 0.5 -> 0.477 Inexact Rounded
-pwsx3412 power 0.0228 0.5 -> 0.151 Inexact Rounded
-pwsx3413 power 0.229 0.5 -> 0.479 Inexact Rounded
-pwsx3414 power 0.0229 0.5 -> 0.151 Inexact Rounded
-pwsx3415 power 0.231 0.5 -> 0.481 Inexact Rounded
-pwsx3416 power 0.0231 0.5 -> 0.152 Inexact Rounded
-pwsx3417 power 0.232 0.5 -> 0.482 Inexact Rounded
-pwsx3418 power 0.0232 0.5 -> 0.152 Inexact Rounded
-pwsx3419 power 0.233 0.5 -> 0.483 Inexact Rounded
-pwsx3420 power 0.0233 0.5 -> 0.153 Inexact Rounded
-pwsx3421 power 0.234 0.5 -> 0.484 Inexact Rounded
-pwsx3422 power 0.0234 0.5 -> 0.153 Inexact Rounded
-pwsx3423 power 0.235 0.5 -> 0.485 Inexact Rounded
-pwsx3424 power 0.0235 0.5 -> 0.153 Inexact Rounded
-pwsx3425 power 0.236 0.5 -> 0.486 Inexact Rounded
-pwsx3426 power 0.0236 0.5 -> 0.154 Inexact Rounded
-pwsx3427 power 0.237 0.5 -> 0.487 Inexact Rounded
-pwsx3428 power 0.0237 0.5 -> 0.154 Inexact Rounded
-pwsx3429 power 0.238 0.5 -> 0.488 Inexact Rounded
-pwsx3430 power 0.0238 0.5 -> 0.154 Inexact Rounded
-pwsx3431 power 0.239 0.5 -> 0.489 Inexact Rounded
-pwsx3432 power 0.0239 0.5 -> 0.155 Inexact Rounded
-pwsx3433 power 0.241 0.5 -> 0.491 Inexact Rounded
-pwsx3434 power 0.0241 0.5 -> 0.155 Inexact Rounded
-pwsx3435 power 0.242 0.5 -> 0.492 Inexact Rounded
-pwsx3436 power 0.0242 0.5 -> 0.156 Inexact Rounded
-pwsx3437 power 0.243 0.5 -> 0.493 Inexact Rounded
-pwsx3438 power 0.0243 0.5 -> 0.156 Inexact Rounded
-pwsx3439 power 0.244 0.5 -> 0.494 Inexact Rounded
-pwsx3440 power 0.0244 0.5 -> 0.156 Inexact Rounded
-pwsx3441 power 0.245 0.5 -> 0.495 Inexact Rounded
-pwsx3442 power 0.0245 0.5 -> 0.157 Inexact Rounded
-pwsx3443 power 0.246 0.5 -> 0.496 Inexact Rounded
-pwsx3444 power 0.0246 0.5 -> 0.157 Inexact Rounded
-pwsx3445 power 0.247 0.5 -> 0.497 Inexact Rounded
-pwsx3446 power 0.0247 0.5 -> 0.157 Inexact Rounded
-pwsx3447 power 0.248 0.5 -> 0.498 Inexact Rounded
-pwsx3448 power 0.0248 0.5 -> 0.157 Inexact Rounded
-pwsx3449 power 0.249 0.5 -> 0.499 Inexact Rounded
-pwsx3450 power 0.0249 0.5 -> 0.158 Inexact Rounded
-pwsx3451 power 0.251 0.5 -> 0.501 Inexact Rounded
-pwsx3452 power 0.0251 0.5 -> 0.158 Inexact Rounded
-pwsx3453 power 0.252 0.5 -> 0.502 Inexact Rounded
-pwsx3454 power 0.0252 0.5 -> 0.159 Inexact Rounded
-pwsx3455 power 0.253 0.5 -> 0.503 Inexact Rounded
-pwsx3456 power 0.0253 0.5 -> 0.159 Inexact Rounded
-pwsx3457 power 0.254 0.5 -> 0.504 Inexact Rounded
-pwsx3458 power 0.0254 0.5 -> 0.159 Inexact Rounded
-pwsx3459 power 0.255 0.5 -> 0.505 Inexact Rounded
-pwsx3460 power 0.0255 0.5 -> 0.160 Inexact Rounded
-pwsx3461 power 0.256 0.5 -> 0.506 Inexact Rounded
-pwsx3462 power 0.0256 0.5 -> 0.160 Inexact Rounded
-pwsx3463 power 0.257 0.5 -> 0.507 Inexact Rounded
-pwsx3464 power 0.0257 0.5 -> 0.160 Inexact Rounded
-pwsx3465 power 0.258 0.5 -> 0.508 Inexact Rounded
-pwsx3466 power 0.0258 0.5 -> 0.161 Inexact Rounded
-pwsx3467 power 0.259 0.5 -> 0.509 Inexact Rounded
-pwsx3468 power 0.0259 0.5 -> 0.161 Inexact Rounded
-pwsx3469 power 0.261 0.5 -> 0.511 Inexact Rounded
-pwsx3470 power 0.0261 0.5 -> 0.162 Inexact Rounded
-pwsx3471 power 0.262 0.5 -> 0.512 Inexact Rounded
-pwsx3472 power 0.0262 0.5 -> 0.162 Inexact Rounded
-pwsx3473 power 0.263 0.5 -> 0.513 Inexact Rounded
-pwsx3474 power 0.0263 0.5 -> 0.162 Inexact Rounded
-pwsx3475 power 0.264 0.5 -> 0.514 Inexact Rounded
-pwsx3476 power 0.0264 0.5 -> 0.162 Inexact Rounded
-pwsx3477 power 0.265 0.5 -> 0.515 Inexact Rounded
-pwsx3478 power 0.0265 0.5 -> 0.163 Inexact Rounded
-pwsx3479 power 0.266 0.5 -> 0.516 Inexact Rounded
-pwsx3480 power 0.0266 0.5 -> 0.163 Inexact Rounded
-pwsx3481 power 0.267 0.5 -> 0.517 Inexact Rounded
-pwsx3482 power 0.0267 0.5 -> 0.163 Inexact Rounded
-pwsx3483 power 0.268 0.5 -> 0.518 Inexact Rounded
-pwsx3484 power 0.0268 0.5 -> 0.164 Inexact Rounded
-pwsx3485 power 0.269 0.5 -> 0.519 Inexact Rounded
-pwsx3486 power 0.0269 0.5 -> 0.164 Inexact Rounded
-pwsx3487 power 0.271 0.5 -> 0.521 Inexact Rounded
-pwsx3488 power 0.0271 0.5 -> 0.165 Inexact Rounded
-pwsx3489 power 0.272 0.5 -> 0.522 Inexact Rounded
-pwsx3490 power 0.0272 0.5 -> 0.165 Inexact Rounded
-pwsx3491 power 0.273 0.5 -> 0.522 Inexact Rounded
-pwsx3492 power 0.0273 0.5 -> 0.165 Inexact Rounded
-pwsx3493 power 0.274 0.5 -> 0.523 Inexact Rounded
-pwsx3494 power 0.0274 0.5 -> 0.166 Inexact Rounded
-pwsx3495 power 0.275 0.5 -> 0.524 Inexact Rounded
-pwsx3496 power 0.0275 0.5 -> 0.166 Inexact Rounded
-pwsx3497 power 0.276 0.5 -> 0.525 Inexact Rounded
-pwsx3498 power 0.0276 0.5 -> 0.166 Inexact Rounded
-pwsx3499 power 0.277 0.5 -> 0.526 Inexact Rounded
-pwsx3500 power 0.0277 0.5 -> 0.166 Inexact Rounded
-pwsx3501 power 0.278 0.5 -> 0.527 Inexact Rounded
-pwsx3502 power 0.0278 0.5 -> 0.167 Inexact Rounded
-pwsx3503 power 0.279 0.5 -> 0.528 Inexact Rounded
-pwsx3504 power 0.0279 0.5 -> 0.167 Inexact Rounded
-pwsx3505 power 0.281 0.5 -> 0.530 Inexact Rounded
-pwsx3506 power 0.0281 0.5 -> 0.168 Inexact Rounded
-pwsx3507 power 0.282 0.5 -> 0.531 Inexact Rounded
-pwsx3508 power 0.0282 0.5 -> 0.168 Inexact Rounded
-pwsx3509 power 0.283 0.5 -> 0.532 Inexact Rounded
-pwsx3510 power 0.0283 0.5 -> 0.168 Inexact Rounded
-pwsx3511 power 0.284 0.5 -> 0.533 Inexact Rounded
-pwsx3512 power 0.0284 0.5 -> 0.169 Inexact Rounded
-pwsx3513 power 0.285 0.5 -> 0.534 Inexact Rounded
-pwsx3514 power 0.0285 0.5 -> 0.169 Inexact Rounded
-pwsx3515 power 0.286 0.5 -> 0.535 Inexact Rounded
-pwsx3516 power 0.0286 0.5 -> 0.169 Inexact Rounded
-pwsx3517 power 0.287 0.5 -> 0.536 Inexact Rounded
-pwsx3518 power 0.0287 0.5 -> 0.169 Inexact Rounded
-pwsx3519 power 0.288 0.5 -> 0.537 Inexact Rounded
-pwsx3520 power 0.0288 0.5 -> 0.170 Inexact Rounded
-pwsx3521 power 0.289 0.5 -> 0.538 Inexact Rounded
-pwsx3522 power 0.0289 0.5 -> 0.170 Inexact Rounded
-pwsx3523 power 0.291 0.5 -> 0.539 Inexact Rounded
-pwsx3524 power 0.0291 0.5 -> 0.171 Inexact Rounded
-pwsx3525 power 0.292 0.5 -> 0.540 Inexact Rounded
-pwsx3526 power 0.0292 0.5 -> 0.171 Inexact Rounded
-pwsx3527 power 0.293 0.5 -> 0.541 Inexact Rounded
-pwsx3528 power 0.0293 0.5 -> 0.171 Inexact Rounded
-pwsx3529 power 0.294 0.5 -> 0.542 Inexact Rounded
-pwsx3530 power 0.0294 0.5 -> 0.171 Inexact Rounded
-pwsx3531 power 0.295 0.5 -> 0.543 Inexact Rounded
-pwsx3532 power 0.0295 0.5 -> 0.172 Inexact Rounded
-pwsx3533 power 0.296 0.5 -> 0.544 Inexact Rounded
-pwsx3534 power 0.0296 0.5 -> 0.172 Inexact Rounded
-pwsx3535 power 0.297 0.5 -> 0.545 Inexact Rounded
-pwsx3536 power 0.0297 0.5 -> 0.172 Inexact Rounded
-pwsx3537 power 0.298 0.5 -> 0.546 Inexact Rounded
-pwsx3538 power 0.0298 0.5 -> 0.173 Inexact Rounded
-pwsx3539 power 0.299 0.5 -> 0.547 Inexact Rounded
-pwsx3540 power 0.0299 0.5 -> 0.173 Inexact Rounded
-pwsx3541 power 0.301 0.5 -> 0.549 Inexact Rounded
-pwsx3542 power 0.0301 0.5 -> 0.173 Inexact Rounded
-pwsx3543 power 0.302 0.5 -> 0.550 Inexact Rounded
-pwsx3544 power 0.0302 0.5 -> 0.174 Inexact Rounded
-pwsx3545 power 0.303 0.5 -> 0.550 Inexact Rounded
-pwsx3546 power 0.0303 0.5 -> 0.174 Inexact Rounded
-pwsx3547 power 0.304 0.5 -> 0.551 Inexact Rounded
-pwsx3548 power 0.0304 0.5 -> 0.174 Inexact Rounded
-pwsx3549 power 0.305 0.5 -> 0.552 Inexact Rounded
-pwsx3550 power 0.0305 0.5 -> 0.175 Inexact Rounded
-pwsx3551 power 0.306 0.5 -> 0.553 Inexact Rounded
-pwsx3552 power 0.0306 0.5 -> 0.175 Inexact Rounded
-pwsx3553 power 0.307 0.5 -> 0.554 Inexact Rounded
-pwsx3554 power 0.0307 0.5 -> 0.175 Inexact Rounded
-pwsx3555 power 0.308 0.5 -> 0.555 Inexact Rounded
-pwsx3556 power 0.0308 0.5 -> 0.175 Inexact Rounded
-pwsx3557 power 0.309 0.5 -> 0.556 Inexact Rounded
-pwsx3558 power 0.0309 0.5 -> 0.176 Inexact Rounded
-pwsx3559 power 0.311 0.5 -> 0.558 Inexact Rounded
-pwsx3560 power 0.0311 0.5 -> 0.176 Inexact Rounded
-pwsx3561 power 0.312 0.5 -> 0.559 Inexact Rounded
-pwsx3562 power 0.0312 0.5 -> 0.177 Inexact Rounded
-pwsx3563 power 0.313 0.5 -> 0.559 Inexact Rounded
-pwsx3564 power 0.0313 0.5 -> 0.177 Inexact Rounded
-pwsx3565 power 0.314 0.5 -> 0.560 Inexact Rounded
-pwsx3566 power 0.0314 0.5 -> 0.177 Inexact Rounded
-pwsx3567 power 0.315 0.5 -> 0.561 Inexact Rounded
-pwsx3568 power 0.0315 0.5 -> 0.177 Inexact Rounded
-pwsx3569 power 0.316 0.5 -> 0.562 Inexact Rounded
-pwsx3570 power 0.0316 0.5 -> 0.178 Inexact Rounded
-pwsx3571 power 0.317 0.5 -> 0.563 Inexact Rounded
-pwsx3572 power 0.0317 0.5 -> 0.178 Inexact Rounded
-pwsx3573 power 0.318 0.5 -> 0.564 Inexact Rounded
-pwsx3574 power 0.0318 0.5 -> 0.178 Inexact Rounded
-pwsx3575 power 0.319 0.5 -> 0.565 Inexact Rounded
-pwsx3576 power 0.0319 0.5 -> 0.179 Inexact Rounded
-pwsx3577 power 0.321 0.5 -> 0.567 Inexact Rounded
-pwsx3578 power 0.0321 0.5 -> 0.179 Inexact Rounded
-pwsx3579 power 0.322 0.5 -> 0.567 Inexact Rounded
-pwsx3580 power 0.0322 0.5 -> 0.179 Inexact Rounded
-pwsx3581 power 0.323 0.5 -> 0.568 Inexact Rounded
-pwsx3582 power 0.0323 0.5 -> 0.180 Inexact Rounded
-pwsx3583 power 0.324 0.5 -> 0.569 Inexact Rounded
-pwsx3584 power 0.0324 0.5 -> 0.180 Inexact Rounded
-pwsx3585 power 0.325 0.5 -> 0.570 Inexact Rounded
-pwsx3586 power 0.0325 0.5 -> 0.180 Inexact Rounded
-pwsx3587 power 0.326 0.5 -> 0.571 Inexact Rounded
-pwsx3588 power 0.0326 0.5 -> 0.181 Inexact Rounded
-pwsx3589 power 0.327 0.5 -> 0.572 Inexact Rounded
-pwsx3590 power 0.0327 0.5 -> 0.181 Inexact Rounded
-pwsx3591 power 0.328 0.5 -> 0.573 Inexact Rounded
-pwsx3592 power 0.0328 0.5 -> 0.181 Inexact Rounded
-pwsx3593 power 0.329 0.5 -> 0.574 Inexact Rounded
-pwsx3594 power 0.0329 0.5 -> 0.181 Inexact Rounded
-pwsx3595 power 0.331 0.5 -> 0.575 Inexact Rounded
-pwsx3596 power 0.0331 0.5 -> 0.182 Inexact Rounded
-pwsx3597 power 0.332 0.5 -> 0.576 Inexact Rounded
-pwsx3598 power 0.0332 0.5 -> 0.182 Inexact Rounded
-pwsx3599 power 0.333 0.5 -> 0.577 Inexact Rounded
-pwsx3600 power 0.0333 0.5 -> 0.182 Inexact Rounded
-pwsx3601 power 0.334 0.5 -> 0.578 Inexact Rounded
-pwsx3602 power 0.0334 0.5 -> 0.183 Inexact Rounded
-pwsx3603 power 0.335 0.5 -> 0.579 Inexact Rounded
-pwsx3604 power 0.0335 0.5 -> 0.183 Inexact Rounded
-pwsx3605 power 0.336 0.5 -> 0.580 Inexact Rounded
-pwsx3606 power 0.0336 0.5 -> 0.183 Inexact Rounded
-pwsx3607 power 0.337 0.5 -> 0.581 Inexact Rounded
-pwsx3608 power 0.0337 0.5 -> 0.184 Inexact Rounded
-pwsx3609 power 0.338 0.5 -> 0.581 Inexact Rounded
-pwsx3610 power 0.0338 0.5 -> 0.184 Inexact Rounded
-pwsx3611 power 0.339 0.5 -> 0.582 Inexact Rounded
-pwsx3612 power 0.0339 0.5 -> 0.184 Inexact Rounded
-pwsx3613 power 0.341 0.5 -> 0.584 Inexact Rounded
-pwsx3614 power 0.0341 0.5 -> 0.185 Inexact Rounded
-pwsx3615 power 0.342 0.5 -> 0.585 Inexact Rounded
-pwsx3616 power 0.0342 0.5 -> 0.185 Inexact Rounded
-pwsx3617 power 0.343 0.5 -> 0.586 Inexact Rounded
-pwsx3618 power 0.0343 0.5 -> 0.185 Inexact Rounded
-pwsx3619 power 0.344 0.5 -> 0.587 Inexact Rounded
-pwsx3620 power 0.0344 0.5 -> 0.185 Inexact Rounded
-pwsx3621 power 0.345 0.5 -> 0.587 Inexact Rounded
-pwsx3622 power 0.0345 0.5 -> 0.186 Inexact Rounded
-pwsx3623 power 0.346 0.5 -> 0.588 Inexact Rounded
-pwsx3624 power 0.0346 0.5 -> 0.186 Inexact Rounded
-pwsx3625 power 0.347 0.5 -> 0.589 Inexact Rounded
-pwsx3626 power 0.0347 0.5 -> 0.186 Inexact Rounded
-pwsx3627 power 0.348 0.5 -> 0.590 Inexact Rounded
-pwsx3628 power 0.0348 0.5 -> 0.187 Inexact Rounded
-pwsx3629 power 0.349 0.5 -> 0.591 Inexact Rounded
-pwsx3630 power 0.0349 0.5 -> 0.187 Inexact Rounded
-pwsx3631 power 0.351 0.5 -> 0.592 Inexact Rounded
-pwsx3632 power 0.0351 0.5 -> 0.187 Inexact Rounded
-pwsx3633 power 0.352 0.5 -> 0.593 Inexact Rounded
-pwsx3634 power 0.0352 0.5 -> 0.188 Inexact Rounded
-pwsx3635 power 0.353 0.5 -> 0.594 Inexact Rounded
-pwsx3636 power 0.0353 0.5 -> 0.188 Inexact Rounded
-pwsx3637 power 0.354 0.5 -> 0.595 Inexact Rounded
-pwsx3638 power 0.0354 0.5 -> 0.188 Inexact Rounded
-pwsx3639 power 0.355 0.5 -> 0.596 Inexact Rounded
-pwsx3640 power 0.0355 0.5 -> 0.188 Inexact Rounded
-pwsx3641 power 0.356 0.5 -> 0.597 Inexact Rounded
-pwsx3642 power 0.0356 0.5 -> 0.189 Inexact Rounded
-pwsx3643 power 0.357 0.5 -> 0.597 Inexact Rounded
-pwsx3644 power 0.0357 0.5 -> 0.189 Inexact Rounded
-pwsx3645 power 0.358 0.5 -> 0.598 Inexact Rounded
-pwsx3646 power 0.0358 0.5 -> 0.189 Inexact Rounded
-pwsx3647 power 0.359 0.5 -> 0.599 Inexact Rounded
-pwsx3648 power 0.0359 0.5 -> 0.189 Inexact Rounded
-pwsx3649 power 0.361 0.5 -> 0.601 Inexact Rounded
-pwsx3650 power 0.0361 0.5 -> 0.190 Inexact Rounded
-pwsx3651 power 0.362 0.5 -> 0.602 Inexact Rounded
-pwsx3652 power 0.0362 0.5 -> 0.190 Inexact Rounded
-pwsx3653 power 0.363 0.5 -> 0.602 Inexact Rounded
-pwsx3654 power 0.0363 0.5 -> 0.191 Inexact Rounded
-pwsx3655 power 0.364 0.5 -> 0.603 Inexact Rounded
-pwsx3656 power 0.0364 0.5 -> 0.191 Inexact Rounded
-pwsx3657 power 0.365 0.5 -> 0.604 Inexact Rounded
-pwsx3658 power 0.0365 0.5 -> 0.191 Inexact Rounded
-pwsx3659 power 0.366 0.5 -> 0.605 Inexact Rounded
-pwsx3660 power 0.0366 0.5 -> 0.191 Inexact Rounded
-pwsx3661 power 0.367 0.5 -> 0.606 Inexact Rounded
-pwsx3662 power 0.0367 0.5 -> 0.192 Inexact Rounded
-pwsx3663 power 0.368 0.5 -> 0.607 Inexact Rounded
-pwsx3664 power 0.0368 0.5 -> 0.192 Inexact Rounded
-pwsx3665 power 0.369 0.5 -> 0.607 Inexact Rounded
-pwsx3666 power 0.0369 0.5 -> 0.192 Inexact Rounded
-pwsx3667 power 0.371 0.5 -> 0.609 Inexact Rounded
-pwsx3668 power 0.0371 0.5 -> 0.193 Inexact Rounded
-pwsx3669 power 0.372 0.5 -> 0.610 Inexact Rounded
-pwsx3670 power 0.0372 0.5 -> 0.193 Inexact Rounded
-pwsx3671 power 0.373 0.5 -> 0.611 Inexact Rounded
-pwsx3672 power 0.0373 0.5 -> 0.193 Inexact Rounded
-pwsx3673 power 0.374 0.5 -> 0.612 Inexact Rounded
-pwsx3674 power 0.0374 0.5 -> 0.193 Inexact Rounded
-pwsx3675 power 0.375 0.5 -> 0.612 Inexact Rounded
-pwsx3676 power 0.0375 0.5 -> 0.194 Inexact Rounded
-pwsx3677 power 0.376 0.5 -> 0.613 Inexact Rounded
-pwsx3678 power 0.0376 0.5 -> 0.194 Inexact Rounded
-pwsx3679 power 0.377 0.5 -> 0.614 Inexact Rounded
-pwsx3680 power 0.0377 0.5 -> 0.194 Inexact Rounded
-pwsx3681 power 0.378 0.5 -> 0.615 Inexact Rounded
-pwsx3682 power 0.0378 0.5 -> 0.194 Inexact Rounded
-pwsx3683 power 0.379 0.5 -> 0.616 Inexact Rounded
-pwsx3684 power 0.0379 0.5 -> 0.195 Inexact Rounded
-pwsx3685 power 0.381 0.5 -> 0.617 Inexact Rounded
-pwsx3686 power 0.0381 0.5 -> 0.195 Inexact Rounded
-pwsx3687 power 0.382 0.5 -> 0.618 Inexact Rounded
-pwsx3688 power 0.0382 0.5 -> 0.195 Inexact Rounded
-pwsx3689 power 0.383 0.5 -> 0.619 Inexact Rounded
-pwsx3690 power 0.0383 0.5 -> 0.196 Inexact Rounded
-pwsx3691 power 0.384 0.5 -> 0.620 Inexact Rounded
-pwsx3692 power 0.0384 0.5 -> 0.196 Inexact Rounded
-pwsx3693 power 0.385 0.5 -> 0.620 Inexact Rounded
-pwsx3694 power 0.0385 0.5 -> 0.196 Inexact Rounded
-pwsx3695 power 0.386 0.5 -> 0.621 Inexact Rounded
-pwsx3696 power 0.0386 0.5 -> 0.196 Inexact Rounded
-pwsx3697 power 0.387 0.5 -> 0.622 Inexact Rounded
-pwsx3698 power 0.0387 0.5 -> 0.197 Inexact Rounded
-pwsx3699 power 0.388 0.5 -> 0.623 Inexact Rounded
-pwsx3700 power 0.0388 0.5 -> 0.197 Inexact Rounded
-pwsx3701 power 0.389 0.5 -> 0.624 Inexact Rounded
-pwsx3702 power 0.0389 0.5 -> 0.197 Inexact Rounded
-pwsx3703 power 0.391 0.5 -> 0.625 Inexact Rounded
-pwsx3704 power 0.0391 0.5 -> 0.198 Inexact Rounded
-pwsx3705 power 0.392 0.5 -> 0.626 Inexact Rounded
-pwsx3706 power 0.0392 0.5 -> 0.198 Inexact Rounded
-pwsx3707 power 0.393 0.5 -> 0.627 Inexact Rounded
-pwsx3708 power 0.0393 0.5 -> 0.198 Inexact Rounded
-pwsx3709 power 0.394 0.5 -> 0.628 Inexact Rounded
-pwsx3710 power 0.0394 0.5 -> 0.198 Inexact Rounded
-pwsx3711 power 0.395 0.5 -> 0.628 Inexact Rounded
-pwsx3712 power 0.0395 0.5 -> 0.199 Inexact Rounded
-pwsx3713 power 0.396 0.5 -> 0.629 Inexact Rounded
-pwsx3714 power 0.0396 0.5 -> 0.199 Inexact Rounded
-pwsx3715 power 0.397 0.5 -> 0.630 Inexact Rounded
-pwsx3716 power 0.0397 0.5 -> 0.199 Inexact Rounded
-pwsx3717 power 0.398 0.5 -> 0.631 Inexact Rounded
-pwsx3718 power 0.0398 0.5 -> 0.199 Inexact Rounded
-pwsx3719 power 0.399 0.5 -> 0.632 Inexact Rounded
-pwsx3720 power 0.0399 0.5 -> 0.200 Inexact Rounded
-pwsx3721 power 0.401 0.5 -> 0.633 Inexact Rounded
-pwsx3722 power 0.0401 0.5 -> 0.200 Inexact Rounded
-pwsx3723 power 0.402 0.5 -> 0.634 Inexact Rounded
-pwsx3724 power 0.0402 0.5 -> 0.200 Inexact Rounded
-pwsx3725 power 0.403 0.5 -> 0.635 Inexact Rounded
-pwsx3726 power 0.0403 0.5 -> 0.201 Inexact Rounded
-pwsx3727 power 0.404 0.5 -> 0.636 Inexact Rounded
-pwsx3728 power 0.0404 0.5 -> 0.201 Inexact Rounded
-pwsx3729 power 0.405 0.5 -> 0.636 Inexact Rounded
-pwsx3730 power 0.0405 0.5 -> 0.201 Inexact Rounded
-pwsx3731 power 0.406 0.5 -> 0.637 Inexact Rounded
-pwsx3732 power 0.0406 0.5 -> 0.201 Inexact Rounded
-pwsx3733 power 0.407 0.5 -> 0.638 Inexact Rounded
-pwsx3734 power 0.0407 0.5 -> 0.202 Inexact Rounded
-pwsx3735 power 0.408 0.5 -> 0.639 Inexact Rounded
-pwsx3736 power 0.0408 0.5 -> 0.202 Inexact Rounded
-pwsx3737 power 0.409 0.5 -> 0.640 Inexact Rounded
-pwsx3738 power 0.0409 0.5 -> 0.202 Inexact Rounded
-pwsx3739 power 0.411 0.5 -> 0.641 Inexact Rounded
-pwsx3740 power 0.0411 0.5 -> 0.203 Inexact Rounded
-pwsx3741 power 0.412 0.5 -> 0.642 Inexact Rounded
-pwsx3742 power 0.0412 0.5 -> 0.203 Inexact Rounded
-pwsx3743 power 0.413 0.5 -> 0.643 Inexact Rounded
-pwsx3744 power 0.0413 0.5 -> 0.203 Inexact Rounded
-pwsx3745 power 0.414 0.5 -> 0.643 Inexact Rounded
-pwsx3746 power 0.0414 0.5 -> 0.203 Inexact Rounded
-pwsx3747 power 0.415 0.5 -> 0.644 Inexact Rounded
-pwsx3748 power 0.0415 0.5 -> 0.204 Inexact Rounded
-pwsx3749 power 0.416 0.5 -> 0.645 Inexact Rounded
-pwsx3750 power 0.0416 0.5 -> 0.204 Inexact Rounded
-pwsx3751 power 0.417 0.5 -> 0.646 Inexact Rounded
-pwsx3752 power 0.0417 0.5 -> 0.204 Inexact Rounded
-pwsx3753 power 0.418 0.5 -> 0.647 Inexact Rounded
-pwsx3754 power 0.0418 0.5 -> 0.204 Inexact Rounded
-pwsx3755 power 0.419 0.5 -> 0.647 Inexact Rounded
-pwsx3756 power 0.0419 0.5 -> 0.205 Inexact Rounded
-pwsx3757 power 0.421 0.5 -> 0.649 Inexact Rounded
-pwsx3758 power 0.0421 0.5 -> 0.205 Inexact Rounded
-pwsx3759 power 0.422 0.5 -> 0.650 Inexact Rounded
-pwsx3760 power 0.0422 0.5 -> 0.205 Inexact Rounded
-pwsx3761 power 0.423 0.5 -> 0.650 Inexact Rounded
-pwsx3762 power 0.0423 0.5 -> 0.206 Inexact Rounded
-pwsx3763 power 0.424 0.5 -> 0.651 Inexact Rounded
-pwsx3764 power 0.0424 0.5 -> 0.206 Inexact Rounded
-pwsx3765 power 0.425 0.5 -> 0.652 Inexact Rounded
-pwsx3766 power 0.0425 0.5 -> 0.206 Inexact Rounded
-pwsx3767 power 0.426 0.5 -> 0.653 Inexact Rounded
-pwsx3768 power 0.0426 0.5 -> 0.206 Inexact Rounded
-pwsx3769 power 0.427 0.5 -> 0.653 Inexact Rounded
-pwsx3770 power 0.0427 0.5 -> 0.207 Inexact Rounded
-pwsx3771 power 0.428 0.5 -> 0.654 Inexact Rounded
-pwsx3772 power 0.0428 0.5 -> 0.207 Inexact Rounded
-pwsx3773 power 0.429 0.5 -> 0.655 Inexact Rounded
-pwsx3774 power 0.0429 0.5 -> 0.207 Inexact Rounded
-pwsx3775 power 0.431 0.5 -> 0.657 Inexact Rounded
-pwsx3776 power 0.0431 0.5 -> 0.208 Inexact Rounded
-pwsx3777 power 0.432 0.5 -> 0.657 Inexact Rounded
-pwsx3778 power 0.0432 0.5 -> 0.208 Inexact Rounded
-pwsx3779 power 0.433 0.5 -> 0.658 Inexact Rounded
-pwsx3780 power 0.0433 0.5 -> 0.208 Inexact Rounded
-pwsx3781 power 0.434 0.5 -> 0.659 Inexact Rounded
-pwsx3782 power 0.0434 0.5 -> 0.208 Inexact Rounded
-pwsx3783 power 0.435 0.5 -> 0.660 Inexact Rounded
-pwsx3784 power 0.0435 0.5 -> 0.209 Inexact Rounded
-pwsx3785 power 0.436 0.5 -> 0.660 Inexact Rounded
-pwsx3786 power 0.0436 0.5 -> 0.209 Inexact Rounded
-pwsx3787 power 0.437 0.5 -> 0.661 Inexact Rounded
-pwsx3788 power 0.0437 0.5 -> 0.209 Inexact Rounded
-pwsx3789 power 0.438 0.5 -> 0.662 Inexact Rounded
-pwsx3790 power 0.0438 0.5 -> 0.209 Inexact Rounded
-pwsx3791 power 0.439 0.5 -> 0.663 Inexact Rounded
-pwsx3792 power 0.0439 0.5 -> 0.210 Inexact Rounded
-pwsx3793 power 0.441 0.5 -> 0.664 Inexact Rounded
-pwsx3794 power 0.0441 0.5 -> 0.210 Inexact Rounded
-pwsx3795 power 0.442 0.5 -> 0.665 Inexact Rounded
-pwsx3796 power 0.0442 0.5 -> 0.210 Inexact Rounded
-pwsx3797 power 0.443 0.5 -> 0.666 Inexact Rounded
-pwsx3798 power 0.0443 0.5 -> 0.210 Inexact Rounded
-pwsx3799 power 0.444 0.5 -> 0.666 Inexact Rounded
-pwsx3800 power 0.0444 0.5 -> 0.211 Inexact Rounded
-pwsx3801 power 0.445 0.5 -> 0.667 Inexact Rounded
-pwsx3802 power 0.0445 0.5 -> 0.211 Inexact Rounded
-pwsx3803 power 0.446 0.5 -> 0.668 Inexact Rounded
-pwsx3804 power 0.0446 0.5 -> 0.211 Inexact Rounded
-pwsx3805 power 0.447 0.5 -> 0.669 Inexact Rounded
-pwsx3806 power 0.0447 0.5 -> 0.211 Inexact Rounded
-pwsx3807 power 0.448 0.5 -> 0.669 Inexact Rounded
-pwsx3808 power 0.0448 0.5 -> 0.212 Inexact Rounded
-pwsx3809 power 0.449 0.5 -> 0.670 Inexact Rounded
-pwsx3810 power 0.0449 0.5 -> 0.212 Inexact Rounded
-pwsx3811 power 0.451 0.5 -> 0.672 Inexact Rounded
-pwsx3812 power 0.0451 0.5 -> 0.212 Inexact Rounded
-pwsx3813 power 0.452 0.5 -> 0.672 Inexact Rounded
-pwsx3814 power 0.0452 0.5 -> 0.213 Inexact Rounded
-pwsx3815 power 0.453 0.5 -> 0.673 Inexact Rounded
-pwsx3816 power 0.0453 0.5 -> 0.213 Inexact Rounded
-pwsx3817 power 0.454 0.5 -> 0.674 Inexact Rounded
-pwsx3818 power 0.0454 0.5 -> 0.213 Inexact Rounded
-pwsx3819 power 0.455 0.5 -> 0.675 Inexact Rounded
-pwsx3820 power 0.0455 0.5 -> 0.213 Inexact Rounded
-pwsx3821 power 0.456 0.5 -> 0.675 Inexact Rounded
-pwsx3822 power 0.0456 0.5 -> 0.214 Inexact Rounded
-pwsx3823 power 0.457 0.5 -> 0.676 Inexact Rounded
-pwsx3824 power 0.0457 0.5 -> 0.214 Inexact Rounded
-pwsx3825 power 0.458 0.5 -> 0.677 Inexact Rounded
-pwsx3826 power 0.0458 0.5 -> 0.214 Inexact Rounded
-pwsx3827 power 0.459 0.5 -> 0.677 Inexact Rounded
-pwsx3828 power 0.0459 0.5 -> 0.214 Inexact Rounded
-pwsx3829 power 0.461 0.5 -> 0.679 Inexact Rounded
-pwsx3830 power 0.0461 0.5 -> 0.215 Inexact Rounded
-pwsx3831 power 0.462 0.5 -> 0.680 Inexact Rounded
-pwsx3832 power 0.0462 0.5 -> 0.215 Inexact Rounded
-pwsx3833 power 0.463 0.5 -> 0.680 Inexact Rounded
-pwsx3834 power 0.0463 0.5 -> 0.215 Inexact Rounded
-pwsx3835 power 0.464 0.5 -> 0.681 Inexact Rounded
-pwsx3836 power 0.0464 0.5 -> 0.215 Inexact Rounded
-pwsx3837 power 0.465 0.5 -> 0.682 Inexact Rounded
-pwsx3838 power 0.0465 0.5 -> 0.216 Inexact Rounded
-pwsx3839 power 0.466 0.5 -> 0.683 Inexact Rounded
-pwsx3840 power 0.0466 0.5 -> 0.216 Inexact Rounded
-pwsx3841 power 0.467 0.5 -> 0.683 Inexact Rounded
-pwsx3842 power 0.0467 0.5 -> 0.216 Inexact Rounded
-pwsx3843 power 0.468 0.5 -> 0.684 Inexact Rounded
-pwsx3844 power 0.0468 0.5 -> 0.216 Inexact Rounded
-pwsx3845 power 0.469 0.5 -> 0.685 Inexact Rounded
-pwsx3846 power 0.0469 0.5 -> 0.217 Inexact Rounded
-pwsx3847 power 0.471 0.5 -> 0.686 Inexact Rounded
-pwsx3848 power 0.0471 0.5 -> 0.217 Inexact Rounded
-pwsx3849 power 0.472 0.5 -> 0.687 Inexact Rounded
-pwsx3850 power 0.0472 0.5 -> 0.217 Inexact Rounded
-pwsx3851 power 0.473 0.5 -> 0.688 Inexact Rounded
-pwsx3852 power 0.0473 0.5 -> 0.217 Inexact Rounded
-pwsx3853 power 0.474 0.5 -> 0.688 Inexact Rounded
-pwsx3854 power 0.0474 0.5 -> 0.218 Inexact Rounded
-pwsx3855 power 0.475 0.5 -> 0.689 Inexact Rounded
-pwsx3856 power 0.0475 0.5 -> 0.218 Inexact Rounded
-pwsx3857 power 0.476 0.5 -> 0.690 Inexact Rounded
-pwsx3858 power 0.0476 0.5 -> 0.218 Inexact Rounded
-pwsx3859 power 0.477 0.5 -> 0.691 Inexact Rounded
-pwsx3860 power 0.0477 0.5 -> 0.218 Inexact Rounded
-pwsx3861 power 0.478 0.5 -> 0.691 Inexact Rounded
-pwsx3862 power 0.0478 0.5 -> 0.219 Inexact Rounded
-pwsx3863 power 0.479 0.5 -> 0.692 Inexact Rounded
-pwsx3864 power 0.0479 0.5 -> 0.219 Inexact Rounded
-pwsx3865 power 0.481 0.5 -> 0.694 Inexact Rounded
-pwsx3866 power 0.0481 0.5 -> 0.219 Inexact Rounded
-pwsx3867 power 0.482 0.5 -> 0.694 Inexact Rounded
-pwsx3868 power 0.0482 0.5 -> 0.220 Inexact Rounded
-pwsx3869 power 0.483 0.5 -> 0.695 Inexact Rounded
-pwsx3870 power 0.0483 0.5 -> 0.220 Inexact Rounded
-pwsx3871 power 0.484 0.5 -> 0.696 Inexact Rounded
-pwsx3872 power 0.0484 0.5 -> 0.220 Inexact Rounded
-pwsx3873 power 0.485 0.5 -> 0.696 Inexact Rounded
-pwsx3874 power 0.0485 0.5 -> 0.220 Inexact Rounded
-pwsx3875 power 0.486 0.5 -> 0.697 Inexact Rounded
-pwsx3876 power 0.0486 0.5 -> 0.220 Inexact Rounded
-pwsx3877 power 0.487 0.5 -> 0.698 Inexact Rounded
-pwsx3878 power 0.0487 0.5 -> 0.221 Inexact Rounded
-pwsx3879 power 0.488 0.5 -> 0.699 Inexact Rounded
-pwsx3880 power 0.0488 0.5 -> 0.221 Inexact Rounded
-pwsx3881 power 0.489 0.5 -> 0.699 Inexact Rounded
-pwsx3882 power 0.0489 0.5 -> 0.221 Inexact Rounded
-pwsx3883 power 0.491 0.5 -> 0.701 Inexact Rounded
-pwsx3884 power 0.0491 0.5 -> 0.222 Inexact Rounded
-pwsx3885 power 0.492 0.5 -> 0.701 Inexact Rounded
-pwsx3886 power 0.0492 0.5 -> 0.222 Inexact Rounded
-pwsx3887 power 0.493 0.5 -> 0.702 Inexact Rounded
-pwsx3888 power 0.0493 0.5 -> 0.222 Inexact Rounded
-pwsx3889 power 0.494 0.5 -> 0.703 Inexact Rounded
-pwsx3890 power 0.0494 0.5 -> 0.222 Inexact Rounded
-pwsx3891 power 0.495 0.5 -> 0.704 Inexact Rounded
-pwsx3892 power 0.0495 0.5 -> 0.222 Inexact Rounded
-pwsx3893 power 0.496 0.5 -> 0.704 Inexact Rounded
-pwsx3894 power 0.0496 0.5 -> 0.223 Inexact Rounded
-pwsx3895 power 0.497 0.5 -> 0.705 Inexact Rounded
-pwsx3896 power 0.0497 0.5 -> 0.223 Inexact Rounded
-pwsx3897 power 0.498 0.5 -> 0.706 Inexact Rounded
-pwsx3898 power 0.0498 0.5 -> 0.223 Inexact Rounded
-pwsx3899 power 0.499 0.5 -> 0.706 Inexact Rounded
-pwsx3900 power 0.0499 0.5 -> 0.223 Inexact Rounded
-pwsx3901 power 0.501 0.5 -> 0.708 Inexact Rounded
-pwsx3902 power 0.0501 0.5 -> 0.224 Inexact Rounded
-pwsx3903 power 0.502 0.5 -> 0.709 Inexact Rounded
-pwsx3904 power 0.0502 0.5 -> 0.224 Inexact Rounded
-pwsx3905 power 0.503 0.5 -> 0.709 Inexact Rounded
-pwsx3906 power 0.0503 0.5 -> 0.224 Inexact Rounded
-pwsx3907 power 0.504 0.5 -> 0.710 Inexact Rounded
-pwsx3908 power 0.0504 0.5 -> 0.224 Inexact Rounded
-pwsx3909 power 0.505 0.5 -> 0.711 Inexact Rounded
-pwsx3910 power 0.0505 0.5 -> 0.225 Inexact Rounded
-pwsx3911 power 0.506 0.5 -> 0.711 Inexact Rounded
-pwsx3912 power 0.0506 0.5 -> 0.225 Inexact Rounded
-pwsx3913 power 0.507 0.5 -> 0.712 Inexact Rounded
-pwsx3914 power 0.0507 0.5 -> 0.225 Inexact Rounded
-pwsx3915 power 0.508 0.5 -> 0.713 Inexact Rounded
-pwsx3916 power 0.0508 0.5 -> 0.225 Inexact Rounded
-pwsx3917 power 0.509 0.5 -> 0.713 Inexact Rounded
-pwsx3918 power 0.0509 0.5 -> 0.226 Inexact Rounded
-pwsx3919 power 0.511 0.5 -> 0.715 Inexact Rounded
-pwsx3920 power 0.0511 0.5 -> 0.226 Inexact Rounded
-pwsx3921 power 0.512 0.5 -> 0.716 Inexact Rounded
-pwsx3922 power 0.0512 0.5 -> 0.226 Inexact Rounded
-pwsx3923 power 0.513 0.5 -> 0.716 Inexact Rounded
-pwsx3924 power 0.0513 0.5 -> 0.226 Inexact Rounded
-pwsx3925 power 0.514 0.5 -> 0.717 Inexact Rounded
-pwsx3926 power 0.0514 0.5 -> 0.227 Inexact Rounded
-pwsx3927 power 0.515 0.5 -> 0.718 Inexact Rounded
-pwsx3928 power 0.0515 0.5 -> 0.227 Inexact Rounded
-pwsx3929 power 0.516 0.5 -> 0.718 Inexact Rounded
-pwsx3930 power 0.0516 0.5 -> 0.227 Inexact Rounded
-pwsx3931 power 0.517 0.5 -> 0.719 Inexact Rounded
-pwsx3932 power 0.0517 0.5 -> 0.227 Inexact Rounded
-pwsx3933 power 0.518 0.5 -> 0.720 Inexact Rounded
-pwsx3934 power 0.0518 0.5 -> 0.228 Inexact Rounded
-pwsx3935 power 0.519 0.5 -> 0.720 Inexact Rounded
-pwsx3936 power 0.0519 0.5 -> 0.228 Inexact Rounded
-pwsx3937 power 0.521 0.5 -> 0.722 Inexact Rounded
-pwsx3938 power 0.0521 0.5 -> 0.228 Inexact Rounded
-pwsx3939 power 0.522 0.5 -> 0.722 Inexact Rounded
-pwsx3940 power 0.0522 0.5 -> 0.228 Inexact Rounded
-pwsx3941 power 0.523 0.5 -> 0.723 Inexact Rounded
-pwsx3942 power 0.0523 0.5 -> 0.229 Inexact Rounded
-pwsx3943 power 0.524 0.5 -> 0.724 Inexact Rounded
-pwsx3944 power 0.0524 0.5 -> 0.229 Inexact Rounded
-pwsx3945 power 0.525 0.5 -> 0.725 Inexact Rounded
-pwsx3946 power 0.0525 0.5 -> 0.229 Inexact Rounded
-pwsx3947 power 0.526 0.5 -> 0.725 Inexact Rounded
-pwsx3948 power 0.0526 0.5 -> 0.229 Inexact Rounded
-pwsx3949 power 0.527 0.5 -> 0.726 Inexact Rounded
-pwsx3950 power 0.0527 0.5 -> 0.230 Inexact Rounded
-pwsx3951 power 0.528 0.5 -> 0.727 Inexact Rounded
-pwsx3952 power 0.0528 0.5 -> 0.230 Inexact Rounded
-pwsx3953 power 0.529 0.5 -> 0.727 Inexact Rounded
-pwsx3954 power 0.0529 0.5 -> 0.230 Inexact Rounded
-pwsx3955 power 0.531 0.5 -> 0.729 Inexact Rounded
-pwsx3956 power 0.0531 0.5 -> 0.230 Inexact Rounded
-pwsx3957 power 0.532 0.5 -> 0.729 Inexact Rounded
-pwsx3958 power 0.0532 0.5 -> 0.231 Inexact Rounded
-pwsx3959 power 0.533 0.5 -> 0.730 Inexact Rounded
-pwsx3960 power 0.0533 0.5 -> 0.231 Inexact Rounded
-pwsx3961 power 0.534 0.5 -> 0.731 Inexact Rounded
-pwsx3962 power 0.0534 0.5 -> 0.231 Inexact Rounded
-pwsx3963 power 0.535 0.5 -> 0.731 Inexact Rounded
-pwsx3964 power 0.0535 0.5 -> 0.231 Inexact Rounded
-pwsx3965 power 0.536 0.5 -> 0.732 Inexact Rounded
-pwsx3966 power 0.0536 0.5 -> 0.232 Inexact Rounded
-pwsx3967 power 0.537 0.5 -> 0.733 Inexact Rounded
-pwsx3968 power 0.0537 0.5 -> 0.232 Inexact Rounded
-pwsx3969 power 0.538 0.5 -> 0.733 Inexact Rounded
-pwsx3970 power 0.0538 0.5 -> 0.232 Inexact Rounded
-pwsx3971 power 0.539 0.5 -> 0.734 Inexact Rounded
-pwsx3972 power 0.0539 0.5 -> 0.232 Inexact Rounded
-pwsx3973 power 0.541 0.5 -> 0.736 Inexact Rounded
-pwsx3974 power 0.0541 0.5 -> 0.233 Inexact Rounded
-pwsx3975 power 0.542 0.5 -> 0.736 Inexact Rounded
-pwsx3976 power 0.0542 0.5 -> 0.233 Inexact Rounded
-pwsx3977 power 0.543 0.5 -> 0.737 Inexact Rounded
-pwsx3978 power 0.0543 0.5 -> 0.233 Inexact Rounded
-pwsx3979 power 0.544 0.5 -> 0.738 Inexact Rounded
-pwsx3980 power 0.0544 0.5 -> 0.233 Inexact Rounded
-pwsx3981 power 0.545 0.5 -> 0.738 Inexact Rounded
-pwsx3982 power 0.0545 0.5 -> 0.233 Inexact Rounded
-pwsx3983 power 0.546 0.5 -> 0.739 Inexact Rounded
-pwsx3984 power 0.0546 0.5 -> 0.234 Inexact Rounded
-pwsx3985 power 0.547 0.5 -> 0.740 Inexact Rounded
-pwsx3986 power 0.0547 0.5 -> 0.234 Inexact Rounded
-pwsx3987 power 0.548 0.5 -> 0.740 Inexact Rounded
-pwsx3988 power 0.0548 0.5 -> 0.234 Inexact Rounded
-pwsx3989 power 0.549 0.5 -> 0.741 Inexact Rounded
-pwsx3990 power 0.0549 0.5 -> 0.234 Inexact Rounded
-pwsx3991 power 0.551 0.5 -> 0.742 Inexact Rounded
-pwsx3992 power 0.0551 0.5 -> 0.235 Inexact Rounded
-pwsx3993 power 0.552 0.5 -> 0.743 Inexact Rounded
-pwsx3994 power 0.0552 0.5 -> 0.235 Inexact Rounded
-pwsx3995 power 0.553 0.5 -> 0.744 Inexact Rounded
-pwsx3996 power 0.0553 0.5 -> 0.235 Inexact Rounded
-pwsx3997 power 0.554 0.5 -> 0.744 Inexact Rounded
-pwsx3998 power 0.0554 0.5 -> 0.235 Inexact Rounded
-pwsx3999 power 0.555 0.5 -> 0.745 Inexact Rounded
-pwsx4000 power 0.0555 0.5 -> 0.236 Inexact Rounded
-pwsx4001 power 0.556 0.5 -> 0.746 Inexact Rounded
-pwsx4002 power 0.0556 0.5 -> 0.236 Inexact Rounded
-pwsx4003 power 0.557 0.5 -> 0.746 Inexact Rounded
-pwsx4004 power 0.0557 0.5 -> 0.236 Inexact Rounded
-pwsx4005 power 0.558 0.5 -> 0.747 Inexact Rounded
-pwsx4006 power 0.0558 0.5 -> 0.236 Inexact Rounded
-pwsx4007 power 0.559 0.5 -> 0.748 Inexact Rounded
-pwsx4008 power 0.0559 0.5 -> 0.236 Inexact Rounded
-pwsx4009 power 0.561 0.5 -> 0.749 Inexact Rounded
-pwsx4010 power 0.0561 0.5 -> 0.237 Inexact Rounded
-pwsx4011 power 0.562 0.5 -> 0.750 Inexact Rounded
-pwsx4012 power 0.0562 0.5 -> 0.237 Inexact Rounded
-pwsx4013 power 0.563 0.5 -> 0.750 Inexact Rounded
-pwsx4014 power 0.0563 0.5 -> 0.237 Inexact Rounded
-pwsx4015 power 0.564 0.5 -> 0.751 Inexact Rounded
-pwsx4016 power 0.0564 0.5 -> 0.237 Inexact Rounded
-pwsx4017 power 0.565 0.5 -> 0.752 Inexact Rounded
-pwsx4018 power 0.0565 0.5 -> 0.238 Inexact Rounded
-pwsx4019 power 0.566 0.5 -> 0.752 Inexact Rounded
-pwsx4020 power 0.0566 0.5 -> 0.238 Inexact Rounded
-pwsx4021 power 0.567 0.5 -> 0.753 Inexact Rounded
-pwsx4022 power 0.0567 0.5 -> 0.238 Inexact Rounded
-pwsx4023 power 0.568 0.5 -> 0.754 Inexact Rounded
-pwsx4024 power 0.0568 0.5 -> 0.238 Inexact Rounded
-pwsx4025 power 0.569 0.5 -> 0.754 Inexact Rounded
-pwsx4026 power 0.0569 0.5 -> 0.239 Inexact Rounded
-pwsx4027 power 0.571 0.5 -> 0.756 Inexact Rounded
-pwsx4028 power 0.0571 0.5 -> 0.239 Inexact Rounded
-pwsx4029 power 0.572 0.5 -> 0.756 Inexact Rounded
-pwsx4030 power 0.0572 0.5 -> 0.239 Inexact Rounded
-pwsx4031 power 0.573 0.5 -> 0.757 Inexact Rounded
-pwsx4032 power 0.0573 0.5 -> 0.239 Inexact Rounded
-pwsx4033 power 0.574 0.5 -> 0.758 Inexact Rounded
-pwsx4034 power 0.0574 0.5 -> 0.240 Inexact Rounded
-pwsx4035 power 0.575 0.5 -> 0.758 Inexact Rounded
-pwsx4036 power 0.0575 0.5 -> 0.240 Inexact Rounded
-pwsx4037 power 0.576 0.5 -> 0.759 Inexact Rounded
-pwsx4038 power 0.0576 0.5 -> 0.240 Inexact Rounded
-pwsx4039 power 0.577 0.5 -> 0.760 Inexact Rounded
-pwsx4040 power 0.0577 0.5 -> 0.240 Inexact Rounded
-pwsx4041 power 0.578 0.5 -> 0.760 Inexact Rounded
-pwsx4042 power 0.0578 0.5 -> 0.240 Inexact Rounded
-pwsx4043 power 0.579 0.5 -> 0.761 Inexact Rounded
-pwsx4044 power 0.0579 0.5 -> 0.241 Inexact Rounded
-pwsx4045 power 0.581 0.5 -> 0.762 Inexact Rounded
-pwsx4046 power 0.0581 0.5 -> 0.241 Inexact Rounded
-pwsx4047 power 0.582 0.5 -> 0.763 Inexact Rounded
-pwsx4048 power 0.0582 0.5 -> 0.241 Inexact Rounded
-pwsx4049 power 0.583 0.5 -> 0.764 Inexact Rounded
-pwsx4050 power 0.0583 0.5 -> 0.241 Inexact Rounded
-pwsx4051 power 0.584 0.5 -> 0.764 Inexact Rounded
-pwsx4052 power 0.0584 0.5 -> 0.242 Inexact Rounded
-pwsx4053 power 0.585 0.5 -> 0.765 Inexact Rounded
-pwsx4054 power 0.0585 0.5 -> 0.242 Inexact Rounded
-pwsx4055 power 0.586 0.5 -> 0.766 Inexact Rounded
-pwsx4056 power 0.0586 0.5 -> 0.242 Inexact Rounded
-pwsx4057 power 0.587 0.5 -> 0.766 Inexact Rounded
-pwsx4058 power 0.0587 0.5 -> 0.242 Inexact Rounded
-pwsx4059 power 0.588 0.5 -> 0.767 Inexact Rounded
-pwsx4060 power 0.0588 0.5 -> 0.242 Inexact Rounded
-pwsx4061 power 0.589 0.5 -> 0.767 Inexact Rounded
-pwsx4062 power 0.0589 0.5 -> 0.243 Inexact Rounded
-pwsx4063 power 0.591 0.5 -> 0.769 Inexact Rounded
-pwsx4064 power 0.0591 0.5 -> 0.243 Inexact Rounded
-pwsx4065 power 0.592 0.5 -> 0.769 Inexact Rounded
-pwsx4066 power 0.0592 0.5 -> 0.243 Inexact Rounded
-pwsx4067 power 0.593 0.5 -> 0.770 Inexact Rounded
-pwsx4068 power 0.0593 0.5 -> 0.244 Inexact Rounded
-pwsx4069 power 0.594 0.5 -> 0.771 Inexact Rounded
-pwsx4070 power 0.0594 0.5 -> 0.244 Inexact Rounded
-pwsx4071 power 0.595 0.5 -> 0.771 Inexact Rounded
-pwsx4072 power 0.0595 0.5 -> 0.244 Inexact Rounded
-pwsx4073 power 0.596 0.5 -> 0.772 Inexact Rounded
-pwsx4074 power 0.0596 0.5 -> 0.244 Inexact Rounded
-pwsx4075 power 0.597 0.5 -> 0.773 Inexact Rounded
-pwsx4076 power 0.0597 0.5 -> 0.244 Inexact Rounded
-pwsx4077 power 0.598 0.5 -> 0.773 Inexact Rounded
-pwsx4078 power 0.0598 0.5 -> 0.245 Inexact Rounded
-pwsx4079 power 0.599 0.5 -> 0.774 Inexact Rounded
-pwsx4080 power 0.0599 0.5 -> 0.245 Inexact Rounded
-pwsx4081 power 0.601 0.5 -> 0.775 Inexact Rounded
-pwsx4082 power 0.0601 0.5 -> 0.245 Inexact Rounded
-pwsx4083 power 0.602 0.5 -> 0.776 Inexact Rounded
-pwsx4084 power 0.0602 0.5 -> 0.245 Inexact Rounded
-pwsx4085 power 0.603 0.5 -> 0.777 Inexact Rounded
-pwsx4086 power 0.0603 0.5 -> 0.246 Inexact Rounded
-pwsx4087 power 0.604 0.5 -> 0.777 Inexact Rounded
-pwsx4088 power 0.0604 0.5 -> 0.246 Inexact Rounded
-pwsx4089 power 0.605 0.5 -> 0.778 Inexact Rounded
-pwsx4090 power 0.0605 0.5 -> 0.246 Inexact Rounded
-pwsx4091 power 0.606 0.5 -> 0.778 Inexact Rounded
-pwsx4092 power 0.0606 0.5 -> 0.246 Inexact Rounded
-pwsx4093 power 0.607 0.5 -> 0.779 Inexact Rounded
-pwsx4094 power 0.0607 0.5 -> 0.246 Inexact Rounded
-pwsx4095 power 0.608 0.5 -> 0.780 Inexact Rounded
-pwsx4096 power 0.0608 0.5 -> 0.247 Inexact Rounded
-pwsx4097 power 0.609 0.5 -> 0.780 Inexact Rounded
-pwsx4098 power 0.0609 0.5 -> 0.247 Inexact Rounded
-pwsx4099 power 0.611 0.5 -> 0.782 Inexact Rounded
-pwsx4100 power 0.0611 0.5 -> 0.247 Inexact Rounded
-pwsx4101 power 0.612 0.5 -> 0.782 Inexact Rounded
-pwsx4102 power 0.0612 0.5 -> 0.247 Inexact Rounded
-pwsx4103 power 0.613 0.5 -> 0.783 Inexact Rounded
-pwsx4104 power 0.0613 0.5 -> 0.248 Inexact Rounded
-pwsx4105 power 0.614 0.5 -> 0.784 Inexact Rounded
-pwsx4106 power 0.0614 0.5 -> 0.248 Inexact Rounded
-pwsx4107 power 0.615 0.5 -> 0.784 Inexact Rounded
-pwsx4108 power 0.0615 0.5 -> 0.248 Inexact Rounded
-pwsx4109 power 0.616 0.5 -> 0.785 Inexact Rounded
-pwsx4110 power 0.0616 0.5 -> 0.248 Inexact Rounded
-pwsx4111 power 0.617 0.5 -> 0.785 Inexact Rounded
-pwsx4112 power 0.0617 0.5 -> 0.248 Inexact Rounded
-pwsx4113 power 0.618 0.5 -> 0.786 Inexact Rounded
-pwsx4114 power 0.0618 0.5 -> 0.249 Inexact Rounded
-pwsx4115 power 0.619 0.5 -> 0.787 Inexact Rounded
-pwsx4116 power 0.0619 0.5 -> 0.249 Inexact Rounded
-pwsx4117 power 0.621 0.5 -> 0.788 Inexact Rounded
-pwsx4118 power 0.0621 0.5 -> 0.249 Inexact Rounded
-pwsx4119 power 0.622 0.5 -> 0.789 Inexact Rounded
-pwsx4120 power 0.0622 0.5 -> 0.249 Inexact Rounded
-pwsx4121 power 0.623 0.5 -> 0.789 Inexact Rounded
-pwsx4122 power 0.0623 0.5 -> 0.250 Inexact Rounded
-pwsx4123 power 0.624 0.5 -> 0.790 Inexact Rounded
-pwsx4124 power 0.0624 0.5 -> 0.250 Inexact Rounded
-pwsx4125 power 0.625 0.5 -> 0.791 Inexact Rounded
-pwsx4126 power 0.0625 0.5 -> 0.250 Inexact Rounded
-pwsx4127 power 0.626 0.5 -> 0.791 Inexact Rounded
-pwsx4128 power 0.0626 0.5 -> 0.250 Inexact Rounded
-pwsx4129 power 0.627 0.5 -> 0.792 Inexact Rounded
-pwsx4130 power 0.0627 0.5 -> 0.250 Inexact Rounded
-pwsx4131 power 0.628 0.5 -> 0.792 Inexact Rounded
-pwsx4132 power 0.0628 0.5 -> 0.251 Inexact Rounded
-pwsx4133 power 0.629 0.5 -> 0.793 Inexact Rounded
-pwsx4134 power 0.0629 0.5 -> 0.251 Inexact Rounded
-pwsx4135 power 0.631 0.5 -> 0.794 Inexact Rounded
-pwsx4136 power 0.0631 0.5 -> 0.251 Inexact Rounded
-pwsx4137 power 0.632 0.5 -> 0.795 Inexact Rounded
-pwsx4138 power 0.0632 0.5 -> 0.251 Inexact Rounded
-pwsx4139 power 0.633 0.5 -> 0.796 Inexact Rounded
-pwsx4140 power 0.0633 0.5 -> 0.252 Inexact Rounded
-pwsx4141 power 0.634 0.5 -> 0.796 Inexact Rounded
-pwsx4142 power 0.0634 0.5 -> 0.252 Inexact Rounded
-pwsx4143 power 0.635 0.5 -> 0.797 Inexact Rounded
-pwsx4144 power 0.0635 0.5 -> 0.252 Inexact Rounded
-pwsx4145 power 0.636 0.5 -> 0.797 Inexact Rounded
-pwsx4146 power 0.0636 0.5 -> 0.252 Inexact Rounded
-pwsx4147 power 0.637 0.5 -> 0.798 Inexact Rounded
-pwsx4148 power 0.0637 0.5 -> 0.252 Inexact Rounded
-pwsx4149 power 0.638 0.5 -> 0.799 Inexact Rounded
-pwsx4150 power 0.0638 0.5 -> 0.253 Inexact Rounded
-pwsx4151 power 0.639 0.5 -> 0.799 Inexact Rounded
-pwsx4152 power 0.0639 0.5 -> 0.253 Inexact Rounded
-pwsx4153 power 0.641 0.5 -> 0.801 Inexact Rounded
-pwsx4154 power 0.0641 0.5 -> 0.253 Inexact Rounded
-pwsx4155 power 0.642 0.5 -> 0.801 Inexact Rounded
-pwsx4156 power 0.0642 0.5 -> 0.253 Inexact Rounded
-pwsx4157 power 0.643 0.5 -> 0.802 Inexact Rounded
-pwsx4158 power 0.0643 0.5 -> 0.254 Inexact Rounded
-pwsx4159 power 0.644 0.5 -> 0.802 Inexact Rounded
-pwsx4160 power 0.0644 0.5 -> 0.254 Inexact Rounded
-pwsx4161 power 0.645 0.5 -> 0.803 Inexact Rounded
-pwsx4162 power 0.0645 0.5 -> 0.254 Inexact Rounded
-pwsx4163 power 0.646 0.5 -> 0.804 Inexact Rounded
-pwsx4164 power 0.0646 0.5 -> 0.254 Inexact Rounded
-pwsx4165 power 0.647 0.5 -> 0.804 Inexact Rounded
-pwsx4166 power 0.0647 0.5 -> 0.254 Inexact Rounded
-pwsx4167 power 0.648 0.5 -> 0.805 Inexact Rounded
-pwsx4168 power 0.0648 0.5 -> 0.255 Inexact Rounded
-pwsx4169 power 0.649 0.5 -> 0.806 Inexact Rounded
-pwsx4170 power 0.0649 0.5 -> 0.255 Inexact Rounded
-pwsx4171 power 0.651 0.5 -> 0.807 Inexact Rounded
-pwsx4172 power 0.0651 0.5 -> 0.255 Inexact Rounded
-pwsx4173 power 0.652 0.5 -> 0.807 Inexact Rounded
-pwsx4174 power 0.0652 0.5 -> 0.255 Inexact Rounded
-pwsx4175 power 0.653 0.5 -> 0.808 Inexact Rounded
-pwsx4176 power 0.0653 0.5 -> 0.256 Inexact Rounded
-pwsx4177 power 0.654 0.5 -> 0.809 Inexact Rounded
-pwsx4178 power 0.0654 0.5 -> 0.256 Inexact Rounded
-pwsx4179 power 0.655 0.5 -> 0.809 Inexact Rounded
-pwsx4180 power 0.0655 0.5 -> 0.256 Inexact Rounded
-pwsx4181 power 0.656 0.5 -> 0.810 Inexact Rounded
-pwsx4182 power 0.0656 0.5 -> 0.256 Inexact Rounded
-pwsx4183 power 0.657 0.5 -> 0.811 Inexact Rounded
-pwsx4184 power 0.0657 0.5 -> 0.256 Inexact Rounded
-pwsx4185 power 0.658 0.5 -> 0.811 Inexact Rounded
-pwsx4186 power 0.0658 0.5 -> 0.257 Inexact Rounded
-pwsx4187 power 0.659 0.5 -> 0.812 Inexact Rounded
-pwsx4188 power 0.0659 0.5 -> 0.257 Inexact Rounded
-pwsx4189 power 0.661 0.5 -> 0.813 Inexact Rounded
-pwsx4190 power 0.0661 0.5 -> 0.257 Inexact Rounded
-pwsx4191 power 0.662 0.5 -> 0.814 Inexact Rounded
-pwsx4192 power 0.0662 0.5 -> 0.257 Inexact Rounded
-pwsx4193 power 0.663 0.5 -> 0.814 Inexact Rounded
-pwsx4194 power 0.0663 0.5 -> 0.257 Inexact Rounded
-pwsx4195 power 0.664 0.5 -> 0.815 Inexact Rounded
-pwsx4196 power 0.0664 0.5 -> 0.258 Inexact Rounded
-pwsx4197 power 0.665 0.5 -> 0.815 Inexact Rounded
-pwsx4198 power 0.0665 0.5 -> 0.258 Inexact Rounded
-pwsx4199 power 0.666 0.5 -> 0.816 Inexact Rounded
-pwsx4200 power 0.0666 0.5 -> 0.258 Inexact Rounded
-pwsx4201 power 0.667 0.5 -> 0.817 Inexact Rounded
-pwsx4202 power 0.0667 0.5 -> 0.258 Inexact Rounded
-pwsx4203 power 0.668 0.5 -> 0.817 Inexact Rounded
-pwsx4204 power 0.0668 0.5 -> 0.258 Inexact Rounded
-pwsx4205 power 0.669 0.5 -> 0.818 Inexact Rounded
-pwsx4206 power 0.0669 0.5 -> 0.259 Inexact Rounded
-pwsx4207 power 0.671 0.5 -> 0.819 Inexact Rounded
-pwsx4208 power 0.0671 0.5 -> 0.259 Inexact Rounded
-pwsx4209 power 0.672 0.5 -> 0.820 Inexact Rounded
-pwsx4210 power 0.0672 0.5 -> 0.259 Inexact Rounded
-pwsx4211 power 0.673 0.5 -> 0.820 Inexact Rounded
-pwsx4212 power 0.0673 0.5 -> 0.259 Inexact Rounded
-pwsx4213 power 0.674 0.5 -> 0.821 Inexact Rounded
-pwsx4214 power 0.0674 0.5 -> 0.260 Inexact Rounded
-pwsx4215 power 0.675 0.5 -> 0.822 Inexact Rounded
-pwsx4216 power 0.0675 0.5 -> 0.260 Inexact Rounded
-pwsx4217 power 0.676 0.5 -> 0.822 Inexact Rounded
-pwsx4218 power 0.0676 0.5 -> 0.260 Inexact Rounded
-pwsx4219 power 0.677 0.5 -> 0.823 Inexact Rounded
-pwsx4220 power 0.0677 0.5 -> 0.260 Inexact Rounded
-pwsx4221 power 0.678 0.5 -> 0.823 Inexact Rounded
-pwsx4222 power 0.0678 0.5 -> 0.260 Inexact Rounded
-pwsx4223 power 0.679 0.5 -> 0.824 Inexact Rounded
-pwsx4224 power 0.0679 0.5 -> 0.261 Inexact Rounded
-pwsx4225 power 0.681 0.5 -> 0.825 Inexact Rounded
-pwsx4226 power 0.0681 0.5 -> 0.261 Inexact Rounded
-pwsx4227 power 0.682 0.5 -> 0.826 Inexact Rounded
-pwsx4228 power 0.0682 0.5 -> 0.261 Inexact Rounded
-pwsx4229 power 0.683 0.5 -> 0.826 Inexact Rounded
-pwsx4230 power 0.0683 0.5 -> 0.261 Inexact Rounded
-pwsx4231 power 0.684 0.5 -> 0.827 Inexact Rounded
-pwsx4232 power 0.0684 0.5 -> 0.262 Inexact Rounded
-pwsx4233 power 0.685 0.5 -> 0.828 Inexact Rounded
-pwsx4234 power 0.0685 0.5 -> 0.262 Inexact Rounded
-pwsx4235 power 0.686 0.5 -> 0.828 Inexact Rounded
-pwsx4236 power 0.0686 0.5 -> 0.262 Inexact Rounded
-pwsx4237 power 0.687 0.5 -> 0.829 Inexact Rounded
-pwsx4238 power 0.0687 0.5 -> 0.262 Inexact Rounded
-pwsx4239 power 0.688 0.5 -> 0.829 Inexact Rounded
-pwsx4240 power 0.0688 0.5 -> 0.262 Inexact Rounded
-pwsx4241 power 0.689 0.5 -> 0.830 Inexact Rounded
-pwsx4242 power 0.0689 0.5 -> 0.262 Inexact Rounded
-pwsx4243 power 0.691 0.5 -> 0.831 Inexact Rounded
-pwsx4244 power 0.0691 0.5 -> 0.263 Inexact Rounded
-pwsx4245 power 0.692 0.5 -> 0.832 Inexact Rounded
-pwsx4246 power 0.0692 0.5 -> 0.263 Inexact Rounded
-pwsx4247 power 0.693 0.5 -> 0.832 Inexact Rounded
-pwsx4248 power 0.0693 0.5 -> 0.263 Inexact Rounded
-pwsx4249 power 0.694 0.5 -> 0.833 Inexact Rounded
-pwsx4250 power 0.0694 0.5 -> 0.263 Inexact Rounded
-pwsx4251 power 0.695 0.5 -> 0.834 Inexact Rounded
-pwsx4252 power 0.0695 0.5 -> 0.264 Inexact Rounded
-pwsx4253 power 0.696 0.5 -> 0.834 Inexact Rounded
-pwsx4254 power 0.0696 0.5 -> 0.264 Inexact Rounded
-pwsx4255 power 0.697 0.5 -> 0.835 Inexact Rounded
-pwsx4256 power 0.0697 0.5 -> 0.264 Inexact Rounded
-pwsx4257 power 0.698 0.5 -> 0.835 Inexact Rounded
-pwsx4258 power 0.0698 0.5 -> 0.264 Inexact Rounded
-pwsx4259 power 0.699 0.5 -> 0.836 Inexact Rounded
-pwsx4260 power 0.0699 0.5 -> 0.264 Inexact Rounded
-pwsx4261 power 0.701 0.5 -> 0.837 Inexact Rounded
-pwsx4262 power 0.0701 0.5 -> 0.265 Inexact Rounded
-pwsx4263 power 0.702 0.5 -> 0.838 Inexact Rounded
-pwsx4264 power 0.0702 0.5 -> 0.265 Inexact Rounded
-pwsx4265 power 0.703 0.5 -> 0.838 Inexact Rounded
-pwsx4266 power 0.0703 0.5 -> 0.265 Inexact Rounded
-pwsx4267 power 0.704 0.5 -> 0.839 Inexact Rounded
-pwsx4268 power 0.0704 0.5 -> 0.265 Inexact Rounded
-pwsx4269 power 0.705 0.5 -> 0.840 Inexact Rounded
-pwsx4270 power 0.0705 0.5 -> 0.266 Inexact Rounded
-pwsx4271 power 0.706 0.5 -> 0.840 Inexact Rounded
-pwsx4272 power 0.0706 0.5 -> 0.266 Inexact Rounded
-pwsx4273 power 0.707 0.5 -> 0.841 Inexact Rounded
-pwsx4274 power 0.0707 0.5 -> 0.266 Inexact Rounded
-pwsx4275 power 0.708 0.5 -> 0.841 Inexact Rounded
-pwsx4276 power 0.0708 0.5 -> 0.266 Inexact Rounded
-pwsx4277 power 0.709 0.5 -> 0.842 Inexact Rounded
-pwsx4278 power 0.0709 0.5 -> 0.266 Inexact Rounded
-pwsx4279 power 0.711 0.5 -> 0.843 Inexact Rounded
-pwsx4280 power 0.0711 0.5 -> 0.267 Inexact Rounded
-pwsx4281 power 0.712 0.5 -> 0.844 Inexact Rounded
-pwsx4282 power 0.0712 0.5 -> 0.267 Inexact Rounded
-pwsx4283 power 0.713 0.5 -> 0.844 Inexact Rounded
-pwsx4284 power 0.0713 0.5 -> 0.267 Inexact Rounded
-pwsx4285 power 0.714 0.5 -> 0.845 Inexact Rounded
-pwsx4286 power 0.0714 0.5 -> 0.267 Inexact Rounded
-pwsx4287 power 0.715 0.5 -> 0.846 Inexact Rounded
-pwsx4288 power 0.0715 0.5 -> 0.267 Inexact Rounded
-pwsx4289 power 0.716 0.5 -> 0.846 Inexact Rounded
-pwsx4290 power 0.0716 0.5 -> 0.268 Inexact Rounded
-pwsx4291 power 0.717 0.5 -> 0.847 Inexact Rounded
-pwsx4292 power 0.0717 0.5 -> 0.268 Inexact Rounded
-pwsx4293 power 0.718 0.5 -> 0.847 Inexact Rounded
-pwsx4294 power 0.0718 0.5 -> 0.268 Inexact Rounded
-pwsx4295 power 0.719 0.5 -> 0.848 Inexact Rounded
-pwsx4296 power 0.0719 0.5 -> 0.268 Inexact Rounded
-pwsx4297 power 0.721 0.5 -> 0.849 Inexact Rounded
-pwsx4298 power 0.0721 0.5 -> 0.269 Inexact Rounded
-pwsx4299 power 0.722 0.5 -> 0.850 Inexact Rounded
-pwsx4300 power 0.0722 0.5 -> 0.269 Inexact Rounded
-pwsx4301 power 0.723 0.5 -> 0.850 Inexact Rounded
-pwsx4302 power 0.0723 0.5 -> 0.269 Inexact Rounded
-pwsx4303 power 0.724 0.5 -> 0.851 Inexact Rounded
-pwsx4304 power 0.0724 0.5 -> 0.269 Inexact Rounded
-pwsx4305 power 0.725 0.5 -> 0.851 Inexact Rounded
-pwsx4306 power 0.0725 0.5 -> 0.269 Inexact Rounded
-pwsx4307 power 0.726 0.5 -> 0.852 Inexact Rounded
-pwsx4308 power 0.0726 0.5 -> 0.269 Inexact Rounded
-pwsx4309 power 0.727 0.5 -> 0.853 Inexact Rounded
-pwsx4310 power 0.0727 0.5 -> 0.270 Inexact Rounded
-pwsx4311 power 0.728 0.5 -> 0.853 Inexact Rounded
-pwsx4312 power 0.0728 0.5 -> 0.270 Inexact Rounded
-pwsx4313 power 0.729 0.5 -> 0.854 Inexact Rounded
-pwsx4314 power 0.0729 0.5 -> 0.270 Inexact Rounded
-pwsx4315 power 0.731 0.5 -> 0.855 Inexact Rounded
-pwsx4316 power 0.0731 0.5 -> 0.270 Inexact Rounded
-pwsx4317 power 0.732 0.5 -> 0.856 Inexact Rounded
-pwsx4318 power 0.0732 0.5 -> 0.271 Inexact Rounded
-pwsx4319 power 0.733 0.5 -> 0.856 Inexact Rounded
-pwsx4320 power 0.0733 0.5 -> 0.271 Inexact Rounded
-pwsx4321 power 0.734 0.5 -> 0.857 Inexact Rounded
-pwsx4322 power 0.0734 0.5 -> 0.271 Inexact Rounded
-pwsx4323 power 0.735 0.5 -> 0.857 Inexact Rounded
-pwsx4324 power 0.0735 0.5 -> 0.271 Inexact Rounded
-pwsx4325 power 0.736 0.5 -> 0.858 Inexact Rounded
-pwsx4326 power 0.0736 0.5 -> 0.271 Inexact Rounded
-pwsx4327 power 0.737 0.5 -> 0.858 Inexact Rounded
-pwsx4328 power 0.0737 0.5 -> 0.271 Inexact Rounded
-pwsx4329 power 0.738 0.5 -> 0.859 Inexact Rounded
-pwsx4330 power 0.0738 0.5 -> 0.272 Inexact Rounded
-pwsx4331 power 0.739 0.5 -> 0.860 Inexact Rounded
-pwsx4332 power 0.0739 0.5 -> 0.272 Inexact Rounded
-pwsx4333 power 0.741 0.5 -> 0.861 Inexact Rounded
-pwsx4334 power 0.0741 0.5 -> 0.272 Inexact Rounded
-pwsx4335 power 0.742 0.5 -> 0.861 Inexact Rounded
-pwsx4336 power 0.0742 0.5 -> 0.272 Inexact Rounded
-pwsx4337 power 0.743 0.5 -> 0.862 Inexact Rounded
-pwsx4338 power 0.0743 0.5 -> 0.273 Inexact Rounded
-pwsx4339 power 0.744 0.5 -> 0.863 Inexact Rounded
-pwsx4340 power 0.0744 0.5 -> 0.273 Inexact Rounded
-pwsx4341 power 0.745 0.5 -> 0.863 Inexact Rounded
-pwsx4342 power 0.0745 0.5 -> 0.273 Inexact Rounded
-pwsx4343 power 0.746 0.5 -> 0.864 Inexact Rounded
-pwsx4344 power 0.0746 0.5 -> 0.273 Inexact Rounded
-pwsx4345 power 0.747 0.5 -> 0.864 Inexact Rounded
-pwsx4346 power 0.0747 0.5 -> 0.273 Inexact Rounded
-pwsx4347 power 0.748 0.5 -> 0.865 Inexact Rounded
-pwsx4348 power 0.0748 0.5 -> 0.273 Inexact Rounded
-pwsx4349 power 0.749 0.5 -> 0.865 Inexact Rounded
-pwsx4350 power 0.0749 0.5 -> 0.274 Inexact Rounded
-pwsx4351 power 0.751 0.5 -> 0.867 Inexact Rounded
-pwsx4352 power 0.0751 0.5 -> 0.274 Inexact Rounded
-pwsx4353 power 0.752 0.5 -> 0.867 Inexact Rounded
-pwsx4354 power 0.0752 0.5 -> 0.274 Inexact Rounded
-pwsx4355 power 0.753 0.5 -> 0.868 Inexact Rounded
-pwsx4356 power 0.0753 0.5 -> 0.274 Inexact Rounded
-pwsx4357 power 0.754 0.5 -> 0.868 Inexact Rounded
-pwsx4358 power 0.0754 0.5 -> 0.275 Inexact Rounded
-pwsx4359 power 0.755 0.5 -> 0.869 Inexact Rounded
-pwsx4360 power 0.0755 0.5 -> 0.275 Inexact Rounded
-pwsx4361 power 0.756 0.5 -> 0.869 Inexact Rounded
-pwsx4362 power 0.0756 0.5 -> 0.275 Inexact Rounded
-pwsx4363 power 0.757 0.5 -> 0.870 Inexact Rounded
-pwsx4364 power 0.0757 0.5 -> 0.275 Inexact Rounded
-pwsx4365 power 0.758 0.5 -> 0.871 Inexact Rounded
-pwsx4366 power 0.0758 0.5 -> 0.275 Inexact Rounded
-pwsx4367 power 0.759 0.5 -> 0.871 Inexact Rounded
-pwsx4368 power 0.0759 0.5 -> 0.275 Inexact Rounded
-pwsx4369 power 0.761 0.5 -> 0.872 Inexact Rounded
-pwsx4370 power 0.0761 0.5 -> 0.276 Inexact Rounded
-pwsx4371 power 0.762 0.5 -> 0.873 Inexact Rounded
-pwsx4372 power 0.0762 0.5 -> 0.276 Inexact Rounded
-pwsx4373 power 0.763 0.5 -> 0.873 Inexact Rounded
-pwsx4374 power 0.0763 0.5 -> 0.276 Inexact Rounded
-pwsx4375 power 0.764 0.5 -> 0.874 Inexact Rounded
-pwsx4376 power 0.0764 0.5 -> 0.276 Inexact Rounded
-pwsx4377 power 0.765 0.5 -> 0.875 Inexact Rounded
-pwsx4378 power 0.0765 0.5 -> 0.277 Inexact Rounded
-pwsx4379 power 0.766 0.5 -> 0.875 Inexact Rounded
-pwsx4380 power 0.0766 0.5 -> 0.277 Inexact Rounded
-pwsx4381 power 0.767 0.5 -> 0.876 Inexact Rounded
-pwsx4382 power 0.0767 0.5 -> 0.277 Inexact Rounded
-pwsx4383 power 0.768 0.5 -> 0.876 Inexact Rounded
-pwsx4384 power 0.0768 0.5 -> 0.277 Inexact Rounded
-pwsx4385 power 0.769 0.5 -> 0.877 Inexact Rounded
-pwsx4386 power 0.0769 0.5 -> 0.277 Inexact Rounded
-pwsx4387 power 0.771 0.5 -> 0.878 Inexact Rounded
-pwsx4388 power 0.0771 0.5 -> 0.278 Inexact Rounded
-pwsx4389 power 0.772 0.5 -> 0.879 Inexact Rounded
-pwsx4390 power 0.0772 0.5 -> 0.278 Inexact Rounded
-pwsx4391 power 0.773 0.5 -> 0.879 Inexact Rounded
-pwsx4392 power 0.0773 0.5 -> 0.278 Inexact Rounded
-pwsx4393 power 0.774 0.5 -> 0.880 Inexact Rounded
-pwsx4394 power 0.0774 0.5 -> 0.278 Inexact Rounded
-pwsx4395 power 0.775 0.5 -> 0.880 Inexact Rounded
-pwsx4396 power 0.0775 0.5 -> 0.278 Inexact Rounded
-pwsx4397 power 0.776 0.5 -> 0.881 Inexact Rounded
-pwsx4398 power 0.0776 0.5 -> 0.279 Inexact Rounded
-pwsx4399 power 0.777 0.5 -> 0.881 Inexact Rounded
-pwsx4400 power 0.0777 0.5 -> 0.279 Inexact Rounded
-pwsx4401 power 0.778 0.5 -> 0.882 Inexact Rounded
-pwsx4402 power 0.0778 0.5 -> 0.279 Inexact Rounded
-pwsx4403 power 0.779 0.5 -> 0.883 Inexact Rounded
-pwsx4404 power 0.0779 0.5 -> 0.279 Inexact Rounded
-pwsx4405 power 0.781 0.5 -> 0.884 Inexact Rounded
-pwsx4406 power 0.0781 0.5 -> 0.279 Inexact Rounded
-pwsx4407 power 0.782 0.5 -> 0.884 Inexact Rounded
-pwsx4408 power 0.0782 0.5 -> 0.280 Inexact Rounded
-pwsx4409 power 0.783 0.5 -> 0.885 Inexact Rounded
-pwsx4410 power 0.0783 0.5 -> 0.280 Inexact Rounded
-pwsx4411 power 0.784 0.5 -> 0.885 Inexact Rounded
-pwsx4412 power 0.0784 0.5 -> 0.280 Inexact Rounded
-pwsx4413 power 0.785 0.5 -> 0.886 Inexact Rounded
-pwsx4414 power 0.0785 0.5 -> 0.280 Inexact Rounded
-pwsx4415 power 0.786 0.5 -> 0.887 Inexact Rounded
-pwsx4416 power 0.0786 0.5 -> 0.280 Inexact Rounded
-pwsx4417 power 0.787 0.5 -> 0.887 Inexact Rounded
-pwsx4418 power 0.0787 0.5 -> 0.281 Inexact Rounded
-pwsx4419 power 0.788 0.5 -> 0.888 Inexact Rounded
-pwsx4420 power 0.0788 0.5 -> 0.281 Inexact Rounded
-pwsx4421 power 0.789 0.5 -> 0.888 Inexact Rounded
-pwsx4422 power 0.0789 0.5 -> 0.281 Inexact Rounded
-pwsx4423 power 0.791 0.5 -> 0.889 Inexact Rounded
-pwsx4424 power 0.0791 0.5 -> 0.281 Inexact Rounded
-pwsx4425 power 0.792 0.5 -> 0.890 Inexact Rounded
-pwsx4426 power 0.0792 0.5 -> 0.281 Inexact Rounded
-pwsx4427 power 0.793 0.5 -> 0.891 Inexact Rounded
-pwsx4428 power 0.0793 0.5 -> 0.282 Inexact Rounded
-pwsx4429 power 0.794 0.5 -> 0.891 Inexact Rounded
-pwsx4430 power 0.0794 0.5 -> 0.282 Inexact Rounded
-pwsx4431 power 0.795 0.5 -> 0.892 Inexact Rounded
-pwsx4432 power 0.0795 0.5 -> 0.282 Inexact Rounded
-pwsx4433 power 0.796 0.5 -> 0.892 Inexact Rounded
-pwsx4434 power 0.0796 0.5 -> 0.282 Inexact Rounded
-pwsx4435 power 0.797 0.5 -> 0.893 Inexact Rounded
-pwsx4436 power 0.0797 0.5 -> 0.282 Inexact Rounded
-pwsx4437 power 0.798 0.5 -> 0.893 Inexact Rounded
-pwsx4438 power 0.0798 0.5 -> 0.282 Inexact Rounded
-pwsx4439 power 0.799 0.5 -> 0.894 Inexact Rounded
-pwsx4440 power 0.0799 0.5 -> 0.283 Inexact Rounded
-pwsx4441 power 0.801 0.5 -> 0.895 Inexact Rounded
-pwsx4442 power 0.0801 0.5 -> 0.283 Inexact Rounded
-pwsx4443 power 0.802 0.5 -> 0.896 Inexact Rounded
-pwsx4444 power 0.0802 0.5 -> 0.283 Inexact Rounded
-pwsx4445 power 0.803 0.5 -> 0.896 Inexact Rounded
-pwsx4446 power 0.0803 0.5 -> 0.283 Inexact Rounded
-pwsx4447 power 0.804 0.5 -> 0.897 Inexact Rounded
-pwsx4448 power 0.0804 0.5 -> 0.284 Inexact Rounded
-pwsx4449 power 0.805 0.5 -> 0.897 Inexact Rounded
-pwsx4450 power 0.0805 0.5 -> 0.284 Inexact Rounded
-pwsx4451 power 0.806 0.5 -> 0.898 Inexact Rounded
-pwsx4452 power 0.0806 0.5 -> 0.284 Inexact Rounded
-pwsx4453 power 0.807 0.5 -> 0.898 Inexact Rounded
-pwsx4454 power 0.0807 0.5 -> 0.284 Inexact Rounded
-pwsx4455 power 0.808 0.5 -> 0.899 Inexact Rounded
-pwsx4456 power 0.0808 0.5 -> 0.284 Inexact Rounded
-pwsx4457 power 0.809 0.5 -> 0.899 Inexact Rounded
-pwsx4458 power 0.0809 0.5 -> 0.284 Inexact Rounded
-pwsx4459 power 0.811 0.5 -> 0.901 Inexact Rounded
-pwsx4460 power 0.0811 0.5 -> 0.285 Inexact Rounded
-pwsx4461 power 0.812 0.5 -> 0.901 Inexact Rounded
-pwsx4462 power 0.0812 0.5 -> 0.285 Inexact Rounded
-pwsx4463 power 0.813 0.5 -> 0.902 Inexact Rounded
-pwsx4464 power 0.0813 0.5 -> 0.285 Inexact Rounded
-pwsx4465 power 0.814 0.5 -> 0.902 Inexact Rounded
-pwsx4466 power 0.0814 0.5 -> 0.285 Inexact Rounded
-pwsx4467 power 0.815 0.5 -> 0.903 Inexact Rounded
-pwsx4468 power 0.0815 0.5 -> 0.285 Inexact Rounded
-pwsx4469 power 0.816 0.5 -> 0.903 Inexact Rounded
-pwsx4470 power 0.0816 0.5 -> 0.286 Inexact Rounded
-pwsx4471 power 0.817 0.5 -> 0.904 Inexact Rounded
-pwsx4472 power 0.0817 0.5 -> 0.286 Inexact Rounded
-pwsx4473 power 0.818 0.5 -> 0.904 Inexact Rounded
-pwsx4474 power 0.0818 0.5 -> 0.286 Inexact Rounded
-pwsx4475 power 0.819 0.5 -> 0.905 Inexact Rounded
-pwsx4476 power 0.0819 0.5 -> 0.286 Inexact Rounded
-pwsx4477 power 0.821 0.5 -> 0.906 Inexact Rounded
-pwsx4478 power 0.0821 0.5 -> 0.287 Inexact Rounded
-pwsx4479 power 0.822 0.5 -> 0.907 Inexact Rounded
-pwsx4480 power 0.0822 0.5 -> 0.287 Inexact Rounded
-pwsx4481 power 0.823 0.5 -> 0.907 Inexact Rounded
-pwsx4482 power 0.0823 0.5 -> 0.287 Inexact Rounded
-pwsx4483 power 0.824 0.5 -> 0.908 Inexact Rounded
-pwsx4484 power 0.0824 0.5 -> 0.287 Inexact Rounded
-pwsx4485 power 0.825 0.5 -> 0.908 Inexact Rounded
-pwsx4486 power 0.0825 0.5 -> 0.287 Inexact Rounded
-pwsx4487 power 0.826 0.5 -> 0.909 Inexact Rounded
-pwsx4488 power 0.0826 0.5 -> 0.287 Inexact Rounded
-pwsx4489 power 0.827 0.5 -> 0.909 Inexact Rounded
-pwsx4490 power 0.0827 0.5 -> 0.288 Inexact Rounded
-pwsx4491 power 0.828 0.5 -> 0.910 Inexact Rounded
-pwsx4492 power 0.0828 0.5 -> 0.288 Inexact Rounded
-pwsx4493 power 0.829 0.5 -> 0.910 Inexact Rounded
-pwsx4494 power 0.0829 0.5 -> 0.288 Inexact Rounded
-pwsx4495 power 0.831 0.5 -> 0.912 Inexact Rounded
-pwsx4496 power 0.0831 0.5 -> 0.288 Inexact Rounded
-pwsx4497 power 0.832 0.5 -> 0.912 Inexact Rounded
-pwsx4498 power 0.0832 0.5 -> 0.288 Inexact Rounded
-pwsx4499 power 0.833 0.5 -> 0.913 Inexact Rounded
-pwsx4500 power 0.0833 0.5 -> 0.289 Inexact Rounded
-pwsx4501 power 0.834 0.5 -> 0.913 Inexact Rounded
-pwsx4502 power 0.0834 0.5 -> 0.289 Inexact Rounded
-pwsx4503 power 0.835 0.5 -> 0.914 Inexact Rounded
-pwsx4504 power 0.0835 0.5 -> 0.289 Inexact Rounded
-pwsx4505 power 0.836 0.5 -> 0.914 Inexact Rounded
-pwsx4506 power 0.0836 0.5 -> 0.289 Inexact Rounded
-pwsx4507 power 0.837 0.5 -> 0.915 Inexact Rounded
-pwsx4508 power 0.0837 0.5 -> 0.289 Inexact Rounded
-pwsx4509 power 0.838 0.5 -> 0.915 Inexact Rounded
-pwsx4510 power 0.0838 0.5 -> 0.289 Inexact Rounded
-pwsx4511 power 0.839 0.5 -> 0.916 Inexact Rounded
-pwsx4512 power 0.0839 0.5 -> 0.290 Inexact Rounded
-pwsx4513 power 0.841 0.5 -> 0.917 Inexact Rounded
-pwsx4514 power 0.0841 0.5 -> 0.290 Inexact Rounded
-pwsx4515 power 0.842 0.5 -> 0.918 Inexact Rounded
-pwsx4516 power 0.0842 0.5 -> 0.290 Inexact Rounded
-pwsx4517 power 0.843 0.5 -> 0.918 Inexact Rounded
-pwsx4518 power 0.0843 0.5 -> 0.290 Inexact Rounded
-pwsx4519 power 0.844 0.5 -> 0.919 Inexact Rounded
-pwsx4520 power 0.0844 0.5 -> 0.291 Inexact Rounded
-pwsx4521 power 0.845 0.5 -> 0.919 Inexact Rounded
-pwsx4522 power 0.0845 0.5 -> 0.291 Inexact Rounded
-pwsx4523 power 0.846 0.5 -> 0.920 Inexact Rounded
-pwsx4524 power 0.0846 0.5 -> 0.291 Inexact Rounded
-pwsx4525 power 0.847 0.5 -> 0.920 Inexact Rounded
-pwsx4526 power 0.0847 0.5 -> 0.291 Inexact Rounded
-pwsx4527 power 0.848 0.5 -> 0.921 Inexact Rounded
-pwsx4528 power 0.0848 0.5 -> 0.291 Inexact Rounded
-pwsx4529 power 0.849 0.5 -> 0.921 Inexact Rounded
-pwsx4530 power 0.0849 0.5 -> 0.291 Inexact Rounded
-pwsx4531 power 0.851 0.5 -> 0.922 Inexact Rounded
-pwsx4532 power 0.0851 0.5 -> 0.292 Inexact Rounded
-pwsx4533 power 0.852 0.5 -> 0.923 Inexact Rounded
-pwsx4534 power 0.0852 0.5 -> 0.292 Inexact Rounded
-pwsx4535 power 0.853 0.5 -> 0.924 Inexact Rounded
-pwsx4536 power 0.0853 0.5 -> 0.292 Inexact Rounded
-pwsx4537 power 0.854 0.5 -> 0.924 Inexact Rounded
-pwsx4538 power 0.0854 0.5 -> 0.292 Inexact Rounded
-pwsx4539 power 0.855 0.5 -> 0.925 Inexact Rounded
-pwsx4540 power 0.0855 0.5 -> 0.292 Inexact Rounded
-pwsx4541 power 0.856 0.5 -> 0.925 Inexact Rounded
-pwsx4542 power 0.0856 0.5 -> 0.293 Inexact Rounded
-pwsx4543 power 0.857 0.5 -> 0.926 Inexact Rounded
-pwsx4544 power 0.0857 0.5 -> 0.293 Inexact Rounded
-pwsx4545 power 0.858 0.5 -> 0.926 Inexact Rounded
-pwsx4546 power 0.0858 0.5 -> 0.293 Inexact Rounded
-pwsx4547 power 0.859 0.5 -> 0.927 Inexact Rounded
-pwsx4548 power 0.0859 0.5 -> 0.293 Inexact Rounded
-pwsx4549 power 0.861 0.5 -> 0.928 Inexact Rounded
-pwsx4550 power 0.0861 0.5 -> 0.293 Inexact Rounded
-pwsx4551 power 0.862 0.5 -> 0.928 Inexact Rounded
-pwsx4552 power 0.0862 0.5 -> 0.294 Inexact Rounded
-pwsx4553 power 0.863 0.5 -> 0.929 Inexact Rounded
-pwsx4554 power 0.0863 0.5 -> 0.294 Inexact Rounded
-pwsx4555 power 0.864 0.5 -> 0.930 Inexact Rounded
-pwsx4556 power 0.0864 0.5 -> 0.294 Inexact Rounded
-pwsx4557 power 0.865 0.5 -> 0.930 Inexact Rounded
-pwsx4558 power 0.0865 0.5 -> 0.294 Inexact Rounded
-pwsx4559 power 0.866 0.5 -> 0.931 Inexact Rounded
-pwsx4560 power 0.0866 0.5 -> 0.294 Inexact Rounded
-pwsx4561 power 0.867 0.5 -> 0.931 Inexact Rounded
-pwsx4562 power 0.0867 0.5 -> 0.294 Inexact Rounded
-pwsx4563 power 0.868 0.5 -> 0.932 Inexact Rounded
-pwsx4564 power 0.0868 0.5 -> 0.295 Inexact Rounded
-pwsx4565 power 0.869 0.5 -> 0.932 Inexact Rounded
-pwsx4566 power 0.0869 0.5 -> 0.295 Inexact Rounded
-pwsx4567 power 0.871 0.5 -> 0.933 Inexact Rounded
-pwsx4568 power 0.0871 0.5 -> 0.295 Inexact Rounded
-pwsx4569 power 0.872 0.5 -> 0.934 Inexact Rounded
-pwsx4570 power 0.0872 0.5 -> 0.295 Inexact Rounded
-pwsx4571 power 0.873 0.5 -> 0.934 Inexact Rounded
-pwsx4572 power 0.0873 0.5 -> 0.295 Inexact Rounded
-pwsx4573 power 0.874 0.5 -> 0.935 Inexact Rounded
-pwsx4574 power 0.0874 0.5 -> 0.296 Inexact Rounded
-pwsx4575 power 0.875 0.5 -> 0.935 Inexact Rounded
-pwsx4576 power 0.0875 0.5 -> 0.296 Inexact Rounded
-pwsx4577 power 0.876 0.5 -> 0.936 Inexact Rounded
-pwsx4578 power 0.0876 0.5 -> 0.296 Inexact Rounded
-pwsx4579 power 0.877 0.5 -> 0.936 Inexact Rounded
-pwsx4580 power 0.0877 0.5 -> 0.296 Inexact Rounded
-pwsx4581 power 0.878 0.5 -> 0.937 Inexact Rounded
-pwsx4582 power 0.0878 0.5 -> 0.296 Inexact Rounded
-pwsx4583 power 0.879 0.5 -> 0.938 Inexact Rounded
-pwsx4584 power 0.0879 0.5 -> 0.296 Inexact Rounded
-pwsx4585 power 0.881 0.5 -> 0.939 Inexact Rounded
-pwsx4586 power 0.0881 0.5 -> 0.297 Inexact Rounded
-pwsx4587 power 0.882 0.5 -> 0.939 Inexact Rounded
-pwsx4588 power 0.0882 0.5 -> 0.297 Inexact Rounded
-pwsx4589 power 0.883 0.5 -> 0.940 Inexact Rounded
-pwsx4590 power 0.0883 0.5 -> 0.297 Inexact Rounded
-pwsx4591 power 0.884 0.5 -> 0.940 Inexact Rounded
-pwsx4592 power 0.0884 0.5 -> 0.297 Inexact Rounded
-pwsx4593 power 0.885 0.5 -> 0.941 Inexact Rounded
-pwsx4594 power 0.0885 0.5 -> 0.297 Inexact Rounded
-pwsx4595 power 0.886 0.5 -> 0.941 Inexact Rounded
-pwsx4596 power 0.0886 0.5 -> 0.298 Inexact Rounded
-pwsx4597 power 0.887 0.5 -> 0.942 Inexact Rounded
-pwsx4598 power 0.0887 0.5 -> 0.298 Inexact Rounded
-pwsx4599 power 0.888 0.5 -> 0.942 Inexact Rounded
-pwsx4600 power 0.0888 0.5 -> 0.298 Inexact Rounded
-pwsx4601 power 0.889 0.5 -> 0.943 Inexact Rounded
-pwsx4602 power 0.0889 0.5 -> 0.298 Inexact Rounded
-pwsx4603 power 0.891 0.5 -> 0.944 Inexact Rounded
-pwsx4604 power 0.0891 0.5 -> 0.298 Inexact Rounded
-pwsx4605 power 0.892 0.5 -> 0.944 Inexact Rounded
-pwsx4606 power 0.0892 0.5 -> 0.299 Inexact Rounded
-pwsx4607 power 0.893 0.5 -> 0.945 Inexact Rounded
-pwsx4608 power 0.0893 0.5 -> 0.299 Inexact Rounded
-pwsx4609 power 0.894 0.5 -> 0.946 Inexact Rounded
-pwsx4610 power 0.0894 0.5 -> 0.299 Inexact Rounded
-pwsx4611 power 0.895 0.5 -> 0.946 Inexact Rounded
-pwsx4612 power 0.0895 0.5 -> 0.299 Inexact Rounded
-pwsx4613 power 0.896 0.5 -> 0.947 Inexact Rounded
-pwsx4614 power 0.0896 0.5 -> 0.299 Inexact Rounded
-pwsx4615 power 0.897 0.5 -> 0.947 Inexact Rounded
-pwsx4616 power 0.0897 0.5 -> 0.299 Inexact Rounded
-pwsx4617 power 0.898 0.5 -> 0.948 Inexact Rounded
-pwsx4618 power 0.0898 0.5 -> 0.300 Inexact Rounded
-pwsx4619 power 0.899 0.5 -> 0.948 Inexact Rounded
-pwsx4620 power 0.0899 0.5 -> 0.300 Inexact Rounded
-pwsx4621 power 0.901 0.5 -> 0.949 Inexact Rounded
-pwsx4622 power 0.0901 0.5 -> 0.300 Inexact Rounded
-pwsx4623 power 0.902 0.5 -> 0.950 Inexact Rounded
-pwsx4624 power 0.0902 0.5 -> 0.300 Inexact Rounded
-pwsx4625 power 0.903 0.5 -> 0.950 Inexact Rounded
-pwsx4626 power 0.0903 0.5 -> 0.300 Inexact Rounded
-pwsx4627 power 0.904 0.5 -> 0.951 Inexact Rounded
-pwsx4628 power 0.0904 0.5 -> 0.301 Inexact Rounded
-pwsx4629 power 0.905 0.5 -> 0.951 Inexact Rounded
-pwsx4630 power 0.0905 0.5 -> 0.301 Inexact Rounded
-pwsx4631 power 0.906 0.5 -> 0.952 Inexact Rounded
-pwsx4632 power 0.0906 0.5 -> 0.301 Inexact Rounded
-pwsx4633 power 0.907 0.5 -> 0.952 Inexact Rounded
-pwsx4634 power 0.0907 0.5 -> 0.301 Inexact Rounded
-pwsx4635 power 0.908 0.5 -> 0.953 Inexact Rounded
-pwsx4636 power 0.0908 0.5 -> 0.301 Inexact Rounded
-pwsx4637 power 0.909 0.5 -> 0.953 Inexact Rounded
-pwsx4638 power 0.0909 0.5 -> 0.301 Inexact Rounded
-pwsx4639 power 0.911 0.5 -> 0.954 Inexact Rounded
-pwsx4640 power 0.0911 0.5 -> 0.302 Inexact Rounded
-pwsx4641 power 0.912 0.5 -> 0.955 Inexact Rounded
-pwsx4642 power 0.0912 0.5 -> 0.302 Inexact Rounded
-pwsx4643 power 0.913 0.5 -> 0.956 Inexact Rounded
-pwsx4644 power 0.0913 0.5 -> 0.302 Inexact Rounded
-pwsx4645 power 0.914 0.5 -> 0.956 Inexact Rounded
-pwsx4646 power 0.0914 0.5 -> 0.302 Inexact Rounded
-pwsx4647 power 0.915 0.5 -> 0.957 Inexact Rounded
-pwsx4648 power 0.0915 0.5 -> 0.302 Inexact Rounded
-pwsx4649 power 0.916 0.5 -> 0.957 Inexact Rounded
-pwsx4650 power 0.0916 0.5 -> 0.303 Inexact Rounded
-pwsx4651 power 0.917 0.5 -> 0.958 Inexact Rounded
-pwsx4652 power 0.0917 0.5 -> 0.303 Inexact Rounded
-pwsx4653 power 0.918 0.5 -> 0.958 Inexact Rounded
-pwsx4654 power 0.0918 0.5 -> 0.303 Inexact Rounded
-pwsx4655 power 0.919 0.5 -> 0.959 Inexact Rounded
-pwsx4656 power 0.0919 0.5 -> 0.303 Inexact Rounded
-pwsx4657 power 0.921 0.5 -> 0.960 Inexact Rounded
-pwsx4658 power 0.0921 0.5 -> 0.303 Inexact Rounded
-pwsx4659 power 0.922 0.5 -> 0.960 Inexact Rounded
-pwsx4660 power 0.0922 0.5 -> 0.304 Inexact Rounded
-pwsx4661 power 0.923 0.5 -> 0.961 Inexact Rounded
-pwsx4662 power 0.0923 0.5 -> 0.304 Inexact Rounded
-pwsx4663 power 0.924 0.5 -> 0.961 Inexact Rounded
-pwsx4664 power 0.0924 0.5 -> 0.304 Inexact Rounded
-pwsx4665 power 0.925 0.5 -> 0.962 Inexact Rounded
-pwsx4666 power 0.0925 0.5 -> 0.304 Inexact Rounded
-pwsx4667 power 0.926 0.5 -> 0.962 Inexact Rounded
-pwsx4668 power 0.0926 0.5 -> 0.304 Inexact Rounded
-pwsx4669 power 0.927 0.5 -> 0.963 Inexact Rounded
-pwsx4670 power 0.0927 0.5 -> 0.304 Inexact Rounded
-pwsx4671 power 0.928 0.5 -> 0.963 Inexact Rounded
-pwsx4672 power 0.0928 0.5 -> 0.305 Inexact Rounded
-pwsx4673 power 0.929 0.5 -> 0.964 Inexact Rounded
-pwsx4674 power 0.0929 0.5 -> 0.305 Inexact Rounded
-pwsx4675 power 0.931 0.5 -> 0.965 Inexact Rounded
-pwsx4676 power 0.0931 0.5 -> 0.305 Inexact Rounded
-pwsx4677 power 0.932 0.5 -> 0.965 Inexact Rounded
-pwsx4678 power 0.0932 0.5 -> 0.305 Inexact Rounded
-pwsx4679 power 0.933 0.5 -> 0.966 Inexact Rounded
-pwsx4680 power 0.0933 0.5 -> 0.305 Inexact Rounded
-pwsx4681 power 0.934 0.5 -> 0.966 Inexact Rounded
-pwsx4682 power 0.0934 0.5 -> 0.306 Inexact Rounded
-pwsx4683 power 0.935 0.5 -> 0.967 Inexact Rounded
-pwsx4684 power 0.0935 0.5 -> 0.306 Inexact Rounded
-pwsx4685 power 0.936 0.5 -> 0.967 Inexact Rounded
-pwsx4686 power 0.0936 0.5 -> 0.306 Inexact Rounded
-pwsx4687 power 0.937 0.5 -> 0.968 Inexact Rounded
-pwsx4688 power 0.0937 0.5 -> 0.306 Inexact Rounded
-pwsx4689 power 0.938 0.5 -> 0.969 Inexact Rounded
-pwsx4690 power 0.0938 0.5 -> 0.306 Inexact Rounded
-pwsx4691 power 0.939 0.5 -> 0.969 Inexact Rounded
-pwsx4692 power 0.0939 0.5 -> 0.306 Inexact Rounded
-pwsx4693 power 0.941 0.5 -> 0.970 Inexact Rounded
-pwsx4694 power 0.0941 0.5 -> 0.307 Inexact Rounded
-pwsx4695 power 0.942 0.5 -> 0.971 Inexact Rounded
-pwsx4696 power 0.0942 0.5 -> 0.307 Inexact Rounded
-pwsx4697 power 0.943 0.5 -> 0.971 Inexact Rounded
-pwsx4698 power 0.0943 0.5 -> 0.307 Inexact Rounded
-pwsx4699 power 0.944 0.5 -> 0.972 Inexact Rounded
-pwsx4700 power 0.0944 0.5 -> 0.307 Inexact Rounded
-pwsx4701 power 0.945 0.5 -> 0.972 Inexact Rounded
-pwsx4702 power 0.0945 0.5 -> 0.307 Inexact Rounded
-pwsx4703 power 0.946 0.5 -> 0.973 Inexact Rounded
-pwsx4704 power 0.0946 0.5 -> 0.308 Inexact Rounded
-pwsx4705 power 0.947 0.5 -> 0.973 Inexact Rounded
-pwsx4706 power 0.0947 0.5 -> 0.308 Inexact Rounded
-pwsx4707 power 0.948 0.5 -> 0.974 Inexact Rounded
-pwsx4708 power 0.0948 0.5 -> 0.308 Inexact Rounded
-pwsx4709 power 0.949 0.5 -> 0.974 Inexact Rounded
-pwsx4710 power 0.0949 0.5 -> 0.308 Inexact Rounded
-pwsx4711 power 0.951 0.5 -> 0.975 Inexact Rounded
-pwsx4712 power 0.0951 0.5 -> 0.308 Inexact Rounded
-pwsx4713 power 0.952 0.5 -> 0.976 Inexact Rounded
-pwsx4714 power 0.0952 0.5 -> 0.309 Inexact Rounded
-pwsx4715 power 0.953 0.5 -> 0.976 Inexact Rounded
-pwsx4716 power 0.0953 0.5 -> 0.309 Inexact Rounded
-pwsx4717 power 0.954 0.5 -> 0.977 Inexact Rounded
-pwsx4718 power 0.0954 0.5 -> 0.309 Inexact Rounded
-pwsx4719 power 0.955 0.5 -> 0.977 Inexact Rounded
-pwsx4720 power 0.0955 0.5 -> 0.309 Inexact Rounded
-pwsx4721 power 0.956 0.5 -> 0.978 Inexact Rounded
-pwsx4722 power 0.0956 0.5 -> 0.309 Inexact Rounded
-pwsx4723 power 0.957 0.5 -> 0.978 Inexact Rounded
-pwsx4724 power 0.0957 0.5 -> 0.309 Inexact Rounded
-pwsx4725 power 0.958 0.5 -> 0.979 Inexact Rounded
-pwsx4726 power 0.0958 0.5 -> 0.310 Inexact Rounded
-pwsx4727 power 0.959 0.5 -> 0.979 Inexact Rounded
-pwsx4728 power 0.0959 0.5 -> 0.310 Inexact Rounded
-pwsx4729 power 0.961 0.5 -> 0.980 Inexact Rounded
-pwsx4730 power 0.0961 0.5 -> 0.310 Inexact Rounded
-pwsx4731 power 0.962 0.5 -> 0.981 Inexact Rounded
-pwsx4732 power 0.0962 0.5 -> 0.310 Inexact Rounded
-pwsx4733 power 0.963 0.5 -> 0.981 Inexact Rounded
-pwsx4734 power 0.0963 0.5 -> 0.310 Inexact Rounded
-pwsx4735 power 0.964 0.5 -> 0.982 Inexact Rounded
-pwsx4736 power 0.0964 0.5 -> 0.310 Inexact Rounded
-pwsx4737 power 0.965 0.5 -> 0.982 Inexact Rounded
-pwsx4738 power 0.0965 0.5 -> 0.311 Inexact Rounded
-pwsx4739 power 0.966 0.5 -> 0.983 Inexact Rounded
-pwsx4740 power 0.0966 0.5 -> 0.311 Inexact Rounded
-pwsx4741 power 0.967 0.5 -> 0.983 Inexact Rounded
-pwsx4742 power 0.0967 0.5 -> 0.311 Inexact Rounded
-pwsx4743 power 0.968 0.5 -> 0.984 Inexact Rounded
-pwsx4744 power 0.0968 0.5 -> 0.311 Inexact Rounded
-pwsx4745 power 0.969 0.5 -> 0.984 Inexact Rounded
-pwsx4746 power 0.0969 0.5 -> 0.311 Inexact Rounded
-pwsx4747 power 0.971 0.5 -> 0.985 Inexact Rounded
-pwsx4748 power 0.0971 0.5 -> 0.312 Inexact Rounded
-pwsx4749 power 0.972 0.5 -> 0.986 Inexact Rounded
-pwsx4750 power 0.0972 0.5 -> 0.312 Inexact Rounded
-pwsx4751 power 0.973 0.5 -> 0.986 Inexact Rounded
-pwsx4752 power 0.0973 0.5 -> 0.312 Inexact Rounded
-pwsx4753 power 0.974 0.5 -> 0.987 Inexact Rounded
-pwsx4754 power 0.0974 0.5 -> 0.312 Inexact Rounded
-pwsx4755 power 0.975 0.5 -> 0.987 Inexact Rounded
-pwsx4756 power 0.0975 0.5 -> 0.312 Inexact Rounded
-pwsx4757 power 0.976 0.5 -> 0.988 Inexact Rounded
-pwsx4758 power 0.0976 0.5 -> 0.312 Inexact Rounded
-pwsx4759 power 0.977 0.5 -> 0.988 Inexact Rounded
-pwsx4760 power 0.0977 0.5 -> 0.313 Inexact Rounded
-pwsx4761 power 0.978 0.5 -> 0.989 Inexact Rounded
-pwsx4762 power 0.0978 0.5 -> 0.313 Inexact Rounded
-pwsx4763 power 0.979 0.5 -> 0.989 Inexact Rounded
-pwsx4764 power 0.0979 0.5 -> 0.313 Inexact Rounded
-pwsx4765 power 0.981 0.5 -> 0.990 Inexact Rounded
-pwsx4766 power 0.0981 0.5 -> 0.313 Inexact Rounded
-pwsx4767 power 0.982 0.5 -> 0.991 Inexact Rounded
-pwsx4768 power 0.0982 0.5 -> 0.313 Inexact Rounded
-pwsx4769 power 0.983 0.5 -> 0.991 Inexact Rounded
-pwsx4770 power 0.0983 0.5 -> 0.314 Inexact Rounded
-pwsx4771 power 0.984 0.5 -> 0.992 Inexact Rounded
-pwsx4772 power 0.0984 0.5 -> 0.314 Inexact Rounded
-pwsx4773 power 0.985 0.5 -> 0.992 Inexact Rounded
-pwsx4774 power 0.0985 0.5 -> 0.314 Inexact Rounded
-pwsx4775 power 0.986 0.5 -> 0.993 Inexact Rounded
-pwsx4776 power 0.0986 0.5 -> 0.314 Inexact Rounded
-pwsx4777 power 0.987 0.5 -> 0.993 Inexact Rounded
-pwsx4778 power 0.0987 0.5 -> 0.314 Inexact Rounded
-pwsx4779 power 0.988 0.5 -> 0.994 Inexact Rounded
-pwsx4780 power 0.0988 0.5 -> 0.314 Inexact Rounded
-pwsx4781 power 0.989 0.5 -> 0.994 Inexact Rounded
-pwsx4782 power 0.0989 0.5 -> 0.314 Inexact Rounded
-pwsx4783 power 0.991 0.5 -> 0.995 Inexact Rounded
-pwsx4784 power 0.0991 0.5 -> 0.315 Inexact Rounded
-pwsx4785 power 0.992 0.5 -> 0.996 Inexact Rounded
-pwsx4786 power 0.0992 0.5 -> 0.315 Inexact Rounded
-pwsx4787 power 0.993 0.5 -> 0.996 Inexact Rounded
-pwsx4788 power 0.0993 0.5 -> 0.315 Inexact Rounded
-pwsx4789 power 0.994 0.5 -> 0.997 Inexact Rounded
-pwsx4790 power 0.0994 0.5 -> 0.315 Inexact Rounded
-pwsx4791 power 0.995 0.5 -> 0.997 Inexact Rounded
-pwsx4792 power 0.0995 0.5 -> 0.315 Inexact Rounded
-pwsx4793 power 0.996 0.5 -> 0.998 Inexact Rounded
-pwsx4794 power 0.0996 0.5 -> 0.316 Inexact Rounded
-pwsx4795 power 0.997 0.5 -> 0.998 Inexact Rounded
-pwsx4796 power 0.0997 0.5 -> 0.316 Inexact Rounded
-pwsx4797 power 0.998 0.5 -> 0.999 Inexact Rounded
-pwsx4798 power 0.0998 0.5 -> 0.316 Inexact Rounded
-pwsx4799 power 0.999 0.5 -> 0.999 Inexact Rounded
-pwsx4800 power 0.0999 0.5 -> 0.316 Inexact Rounded
-
--- A group of precision 4 tests where Hull & Abrham adjustments are
--- needed in some cases (both up and down) [see Hull1985b]
-rounding: half_even
-maxExponent: 999
-minexponent: -999
-precision: 4
-pwsx5001 power 0.0118 0.5 -> 0.1086 Inexact Rounded
-pwsx5002 power 0.119 0.5 -> 0.3450 Inexact Rounded
-pwsx5003 power 0.0119 0.5 -> 0.1091 Inexact Rounded
-pwsx5004 power 0.121 0.5 -> 0.3479 Inexact Rounded
-pwsx5005 power 0.0121 0.5 -> 0.1100 Inexact Rounded
-pwsx5006 power 0.122 0.5 -> 0.3493 Inexact Rounded
-pwsx5007 power 0.0122 0.5 -> 0.1105 Inexact Rounded
-pwsx5008 power 0.123 0.5 -> 0.3507 Inexact Rounded
-pwsx5009 power 0.494 0.5 -> 0.7029 Inexact Rounded
-pwsx5010 power 0.0669 0.5 -> 0.2587 Inexact Rounded
-pwsx5011 power 0.9558 0.5 -> 0.9777 Inexact Rounded
-pwsx5012 power 0.9348 0.5 -> 0.9669 Inexact Rounded
-pwsx5013 power 0.9345 0.5 -> 0.9667 Inexact Rounded
-pwsx5014 power 0.09345 0.5 -> 0.3057 Inexact Rounded
-pwsx5015 power 0.9346 0.5 -> 0.9667 Inexact Rounded
-pwsx5016 power 0.09346 0.5 -> 0.3057 Inexact Rounded
-pwsx5017 power 0.9347 0.5 -> 0.9668 Inexact Rounded
-
--- examples from decArith
-precision: 9
-pwsx700 power 0 0.5 -> '0'
-pwsx701 power -0 0.5 -> '0'
-pwsx702 power 0.39 0.5 -> 0.624499800 Inexact Rounded
-pwsx703 power 100 0.5 -> '10.0000000' Inexact Rounded
-pwsx704 power 1.00 0.5 -> '1.00000000' Inexact Rounded
-pwsx705 power 7 0.5 -> '2.64575131' Inexact Rounded
-pwsx706 power 10 0.5 -> 3.16227766 Inexact Rounded
-
--- some one-offs
-precision: 9
-pwsx711 power 0.1 0.5 -> 0.316227766 Inexact Rounded
-pwsx712 power 0.2 0.5 -> 0.447213595 Inexact Rounded
-pwsx713 power 0.3 0.5 -> 0.547722558 Inexact Rounded
-pwsx714 power 0.4 0.5 -> 0.632455532 Inexact Rounded
-pwsx715 power 0.5 0.5 -> 0.707106781 Inexact Rounded
-pwsx716 power 0.6 0.5 -> 0.774596669 Inexact Rounded
-pwsx717 power 0.7 0.5 -> 0.836660027 Inexact Rounded
-pwsx718 power 0.8 0.5 -> 0.894427191 Inexact Rounded
-pwsx719 power 0.9 0.5 -> 0.948683298 Inexact Rounded
-precision: 10 -- note no normalizatoin here
-pwsx720 power +0.1 0.5 -> 0.3162277660 Inexact Rounded
-precision: 11
-pwsx721 power +0.1 0.5 -> 0.31622776602 Inexact Rounded
-precision: 12
-pwsx722 power +0.1 0.5 -> 0.316227766017 Inexact Rounded
-precision: 9
-pwsx723 power 0.39 0.5 -> 0.624499800 Inexact Rounded
-precision: 15
-pwsx724 power 0.39 0.5 -> 0.624499799839840 Inexact Rounded
-
--- discussion cases
-precision: 7
-pwsx731 power 9 0.5 -> 3.000000 Inexact Rounded
-pwsx732 power 100 0.5 -> 10.00000 Inexact Rounded
-pwsx733 power 123 0.5 -> 11.09054 Inexact Rounded
-pwsx734 power 144 0.5 -> 12.00000 Inexact Rounded
-pwsx735 power 156 0.5 -> 12.49000 Inexact Rounded
-pwsx736 power 10000 0.5 -> 100.0000 Inexact Rounded
-
--- values close to overflow (if there were input rounding)
-maxexponent: 99
-minexponent: -99
-precision: 5
-pwsx760 power 9.9997E+99 0.5 -> 9.9998E+49 Inexact Rounded
-pwsx761 power 9.9998E+99 0.5 -> 9.9999E+49 Inexact Rounded
-pwsx762 power 9.9999E+99 0.5 -> 9.9999E+49 Inexact Rounded
-pwsx763 power 9.99991E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx764 power 9.99994E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx765 power 9.99995E+99 0.5 -> 1.0000E+50 Inexact Rounded
-pwsx766 power 9.99999E+99 0.5 -> 1.0000E+50 Inexact Rounded
-precision: 9
-pwsx770 power 9.9997E+99 0.5 -> 9.99985000E+49 Inexact Rounded
-pwsx771 power 9.9998E+99 0.5 -> 9.99990000E+49 Inexact Rounded
-pwsx772 power 9.9999E+99 0.5 -> 9.99995000E+49 Inexact Rounded
-pwsx773 power 9.99991E+99 0.5 -> 9.99995500E+49 Inexact Rounded
-pwsx774 power 9.99994E+99 0.5 -> 9.99997000E+49 Inexact Rounded
-pwsx775 power 9.99995E+99 0.5 -> 9.99997500E+49 Inexact Rounded
-pwsx776 power 9.99999E+99 0.5 -> 9.99999500E+49 Inexact Rounded
-precision: 20
-pwsx780 power 9.9997E+99 0.5 -> '9.9998499988749831247E+49' Inexact Rounded
-pwsx781 power 9.9998E+99 0.5 -> '9.9998999994999949999E+49' Inexact Rounded
-pwsx782 power 9.9999E+99 0.5 -> '9.9999499998749993750E+49' Inexact Rounded
-pwsx783 power 9.99991E+99 0.5 -> '9.9999549998987495444E+49' Inexact Rounded
-pwsx784 power 9.99994E+99 0.5 -> '9.9999699999549998650E+49' Inexact Rounded
-pwsx785 power 9.99995E+99 0.5 -> '9.9999749999687499219E+49' Inexact Rounded
-pwsx786 power 9.99999E+99 0.5 -> '9.9999949999987499994E+49' Inexact Rounded
-
--- subnormals and underflows [these can only result when eMax is < digits+1]
--- Etiny = -(Emax + (precision-1))
--- start with subnormal operands and normal results
-maxexponent: 9
-minexponent: -9
-precision: 9 -- Etiny=-17
-pwsx800 power 1E-17 0.5 -> 3.16227766E-9 Inexact Rounded
-pwsx801 power 10E-17 0.5 -> 1.00000000E-8 Inexact Rounded
-precision: 10 -- Etiny=-18
-pwsx802 power 10E-18 0.5 -> 3.162277660E-9 Inexact Rounded
-pwsx803 power 1E-18 0.5 -> 1.000000000E-9 Inexact Rounded
-
-precision: 11 -- Etiny=-19
-pwsx804 power 1E-19 0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded
--- The next test should be skipped for decNumber
-pwsx805 power 10E-19 0.5 -> 1.0000000000E-9 Inexact Rounded
-precision: 12 -- Etiny=-20
-pwsx806 power 10E-20 0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
-pwsx807 power 1E-20 0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded
-
-precision: 13 -- Etiny=-21
-pwsx808 power 1E-21 0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
-pwsx809 power 10E-21 0.5 -> 1.00000000000E-10 Underflow Subnormal Inexact Rounded
-precision: 14 -- Etiny=-22
-pwsx810 power 1E-21 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
-pwsx811 power 10E-22 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
-pwsx812 power 1E-22 0.5 -> 1.00000000000E-11 Underflow Subnormal Inexact Rounded
-
-
--- special values
-maxexponent: 999
-minexponent: -999
-pwsx820 power Inf 0.5 -> Infinity
-pwsx821 power -Inf 0.5 -> NaN Invalid_operation
-pwsx822 power NaN 0.5 -> NaN
-pwsx823 power sNaN 0.5 -> NaN Invalid_operation
--- propagating NaNs
-pwsx824 power sNaN123 0.5 -> NaN123 Invalid_operation
-pwsx825 power -sNaN321 0.5 -> -NaN321 Invalid_operation
-pwsx826 power NaN456 0.5 -> NaN456
-pwsx827 power -NaN654 0.5 -> -NaN654
-pwsx828 power NaN1 0.5 -> NaN1
-
--- Null test
-pwsx900 power # 0.5 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- powersqrt.decTest -- decimal square root, using power --
+-- Copyright (c) IBM Corporation, 2004, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- These testcases are taken from squareroot.decTest but are
+-- evaluated using the power operator. The differences in results
+-- (153 out of 2856) fall into the following categories:
+--
+-- x ** 0.5 (x>0) has no preferred exponent, and is Inexact
+-- (and hence full precision); almost all differences are
+-- in this category
+-- 0.00 ** 0.5 becomes 0 (not 0.0), etc.
+-- -0 ** 0.5 becomes 0 (never -0)
+-- Some exact subnormals become inexact and hence underflows
+
+extended: 1
+precision: 9
+rounding: half_even
+maxExponent: 384
+minexponent: -383
+
+-- basics
+pwsx001 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx002 power -1 0.5 -> NaN Invalid_operation
+pwsx003 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx004 power -1.00 0.5 -> NaN Invalid_operation
+pwsx005 power 0 0.5 -> 0
+pwsx006 power 00.0 0.5 -> 0
+pwsx007 power 0.00 0.5 -> 0
+pwsx008 power 00.00 0.5 -> 0
+pwsx009 power 00.000 0.5 -> 0
+pwsx010 power 00.0000 0.5 -> 0
+pwsx011 power 00 0.5 -> 0
+
+pwsx012 power -2 0.5 -> NaN Invalid_operation
+pwsx013 power 2 0.5 -> 1.41421356 Inexact Rounded
+pwsx014 power -2.00 0.5 -> NaN Invalid_operation
+pwsx015 power 2.00 0.5 -> 1.41421356 Inexact Rounded
+pwsx016 power -0 0.5 -> 0
+pwsx017 power -0.0 0.5 -> 0
+pwsx018 power -00.00 0.5 -> 0
+pwsx019 power -00.000 0.5 -> 0
+pwsx020 power -0.0000 0.5 -> 0
+pwsx021 power -0E+9 0.5 -> 0
+pwsx022 power -0E+10 0.5 -> 0
+pwsx023 power -0E+11 0.5 -> 0
+pwsx024 power -0E+12 0.5 -> 0
+pwsx025 power -00 0.5 -> 0
+pwsx026 power 0E+5 0.5 -> 0
+pwsx027 power 4.0 0.5 -> 2.00000000 Inexact Rounded
+pwsx028 power 4.00 0.5 -> 2.00000000 Inexact Rounded
+
+pwsx030 power +0.1 0.5 -> 0.316227766 Inexact Rounded
+pwsx031 power -0.1 0.5 -> NaN Invalid_operation
+pwsx032 power +0.01 0.5 -> 0.100000000 Inexact Rounded
+pwsx033 power -0.01 0.5 -> NaN Invalid_operation
+pwsx034 power +0.001 0.5 -> 0.0316227766 Inexact Rounded
+pwsx035 power -0.001 0.5 -> NaN Invalid_operation
+pwsx036 power +0.000001 0.5 -> 0.00100000000 Inexact Rounded
+pwsx037 power -0.000001 0.5 -> NaN Invalid_operation
+pwsx038 power +0.000000000001 0.5 -> 0.00000100000000 Inexact Rounded
+pwsx039 power -0.000000000001 0.5 -> NaN Invalid_operation
+
+pwsx041 power 1.1 0.5 -> 1.04880885 Inexact Rounded
+pwsx042 power 1.10 0.5 -> 1.04880885 Inexact Rounded
+pwsx043 power 1.100 0.5 -> 1.04880885 Inexact Rounded
+pwsx044 power 1.110 0.5 -> 1.05356538 Inexact Rounded
+pwsx045 power -1.1 0.5 -> NaN Invalid_operation
+pwsx046 power -1.10 0.5 -> NaN Invalid_operation
+pwsx047 power -1.100 0.5 -> NaN Invalid_operation
+pwsx048 power -1.110 0.5 -> NaN Invalid_operation
+pwsx049 power 9.9 0.5 -> 3.14642654 Inexact Rounded
+pwsx050 power 9.90 0.5 -> 3.14642654 Inexact Rounded
+pwsx051 power 9.900 0.5 -> 3.14642654 Inexact Rounded
+pwsx052 power 9.990 0.5 -> 3.16069613 Inexact Rounded
+pwsx053 power -9.9 0.5 -> NaN Invalid_operation
+pwsx054 power -9.90 0.5 -> NaN Invalid_operation
+pwsx055 power -9.900 0.5 -> NaN Invalid_operation
+pwsx056 power -9.990 0.5 -> NaN Invalid_operation
+
+pwsx060 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx061 power 1.0 0.5 -> 1.00000000 Inexact Rounded
+pwsx062 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx063 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx064 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx065 power 10.0 0.5 -> 3.16227766 Inexact Rounded
+pwsx066 power 10.00 0.5 -> 3.16227766 Inexact Rounded
+pwsx067 power 100 0.5 -> 10.0000000 Inexact Rounded
+pwsx068 power 100.0 0.5 -> 10.0000000 Inexact Rounded
+pwsx069 power 100.00 0.5 -> 10.0000000 Inexact Rounded
+pwsx070 power 1.1000E+3 0.5 -> 33.1662479 Inexact Rounded
+pwsx071 power 1.10000E+3 0.5 -> 33.1662479 Inexact Rounded
+pwsx072 power -10.0 0.5 -> NaN Invalid_operation
+pwsx073 power -10.00 0.5 -> NaN Invalid_operation
+pwsx074 power -100.0 0.5 -> NaN Invalid_operation
+pwsx075 power -100.00 0.5 -> NaN Invalid_operation
+pwsx076 power -1.1000E+3 0.5 -> NaN Invalid_operation
+pwsx077 power -1.10000E+3 0.5 -> NaN Invalid_operation
+
+-- famous squares
+pwsx080 power 1 0.5 -> 1.00000000 Inexact Rounded
+pwsx081 power 4 0.5 -> 2.00000000 Inexact Rounded
+pwsx082 power 9 0.5 -> 3.00000000 Inexact Rounded
+pwsx083 power 16 0.5 -> 4.00000000 Inexact Rounded
+pwsx084 power 25 0.5 -> 5.00000000 Inexact Rounded
+pwsx085 power 36 0.5 -> 6.00000000 Inexact Rounded
+pwsx086 power 49 0.5 -> 7.00000000 Inexact Rounded
+pwsx087 power 64 0.5 -> 8.00000000 Inexact Rounded
+pwsx088 power 81 0.5 -> 9.00000000 Inexact Rounded
+pwsx089 power 100 0.5 -> 10.0000000 Inexact Rounded
+pwsx090 power 121 0.5 -> 11.0000000 Inexact Rounded
+pwsx091 power 144 0.5 -> 12.0000000 Inexact Rounded
+pwsx092 power 169 0.5 -> 13.0000000 Inexact Rounded
+pwsx093 power 256 0.5 -> 16.0000000 Inexact Rounded
+pwsx094 power 1024 0.5 -> 32.0000000 Inexact Rounded
+pwsx095 power 4096 0.5 -> 64.0000000 Inexact Rounded
+pwsx100 power 0.01 0.5 -> 0.100000000 Inexact Rounded
+pwsx101 power 0.04 0.5 -> 0.200000000 Inexact Rounded
+pwsx102 power 0.09 0.5 -> 0.300000000 Inexact Rounded
+pwsx103 power 0.16 0.5 -> 0.400000000 Inexact Rounded
+pwsx104 power 0.25 0.5 -> 0.500000000 Inexact Rounded
+pwsx105 power 0.36 0.5 -> 0.600000000 Inexact Rounded
+pwsx106 power 0.49 0.5 -> 0.700000000 Inexact Rounded
+pwsx107 power 0.64 0.5 -> 0.800000000 Inexact Rounded
+pwsx108 power 0.81 0.5 -> 0.900000000 Inexact Rounded
+pwsx109 power 1.00 0.5 -> 1.00000000 Inexact Rounded
+pwsx110 power 1.21 0.5 -> 1.10000000 Inexact Rounded
+pwsx111 power 1.44 0.5 -> 1.20000000 Inexact Rounded
+pwsx112 power 1.69 0.5 -> 1.30000000 Inexact Rounded
+pwsx113 power 2.56 0.5 -> 1.60000000 Inexact Rounded
+pwsx114 power 10.24 0.5 -> 3.20000000 Inexact Rounded
+pwsx115 power 40.96 0.5 -> 6.40000000 Inexact Rounded
+
+-- Precision 1 squareroot tests [exhaustive, plus exponent adjusts]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 1
+pwsx1201 power 0.1 0.5 -> 0.3 Inexact Rounded
+pwsx1202 power 0.01 0.5 -> 0.1 Inexact Rounded
+pwsx1203 power 1.0E-1 0.5 -> 0.3 Inexact Rounded
+pwsx1204 power 1.00E-2 0.5 -> 0.1 Inexact Rounded
+pwsx1205 power 1E-3 0.5 -> 0.03 Inexact Rounded
+pwsx1206 power 1E+1 0.5 -> 3 Inexact Rounded
+pwsx1207 power 1E+2 0.5 -> 1E+1 Inexact Rounded
+pwsx1208 power 1E+3 0.5 -> 3E+1 Inexact Rounded
+pwsx1209 power 0.2 0.5 -> 0.4 Inexact Rounded
+pwsx1210 power 0.02 0.5 -> 0.1 Inexact Rounded
+pwsx1211 power 2.0E-1 0.5 -> 0.4 Inexact Rounded
+pwsx1212 power 2.00E-2 0.5 -> 0.1 Inexact Rounded
+pwsx1213 power 2E-3 0.5 -> 0.04 Inexact Rounded
+pwsx1214 power 2E+1 0.5 -> 4 Inexact Rounded
+pwsx1215 power 2E+2 0.5 -> 1E+1 Inexact Rounded
+pwsx1216 power 2E+3 0.5 -> 4E+1 Inexact Rounded
+pwsx1217 power 0.3 0.5 -> 0.5 Inexact Rounded
+pwsx1218 power 0.03 0.5 -> 0.2 Inexact Rounded
+pwsx1219 power 3.0E-1 0.5 -> 0.5 Inexact Rounded
+pwsx1220 power 3.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1221 power 3E-3 0.5 -> 0.05 Inexact Rounded
+pwsx1222 power 3E+1 0.5 -> 5 Inexact Rounded
+pwsx1223 power 3E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1224 power 3E+3 0.5 -> 5E+1 Inexact Rounded
+pwsx1225 power 0.4 0.5 -> 0.6 Inexact Rounded
+pwsx1226 power 0.04 0.5 -> 0.2 Inexact Rounded
+pwsx1227 power 4.0E-1 0.5 -> 0.6 Inexact Rounded
+pwsx1228 power 4.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1229 power 4E-3 0.5 -> 0.06 Inexact Rounded
+pwsx1230 power 4E+1 0.5 -> 6 Inexact Rounded
+pwsx1231 power 4E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1232 power 4E+3 0.5 -> 6E+1 Inexact Rounded
+pwsx1233 power 0.5 0.5 -> 0.7 Inexact Rounded
+pwsx1234 power 0.05 0.5 -> 0.2 Inexact Rounded
+pwsx1235 power 5.0E-1 0.5 -> 0.7 Inexact Rounded
+pwsx1236 power 5.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1237 power 5E-3 0.5 -> 0.07 Inexact Rounded
+pwsx1238 power 5E+1 0.5 -> 7 Inexact Rounded
+pwsx1239 power 5E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1240 power 5E+3 0.5 -> 7E+1 Inexact Rounded
+pwsx1241 power 0.6 0.5 -> 0.8 Inexact Rounded
+pwsx1242 power 0.06 0.5 -> 0.2 Inexact Rounded
+pwsx1243 power 6.0E-1 0.5 -> 0.8 Inexact Rounded
+pwsx1244 power 6.00E-2 0.5 -> 0.2 Inexact Rounded
+pwsx1245 power 6E-3 0.5 -> 0.08 Inexact Rounded
+pwsx1246 power 6E+1 0.5 -> 8 Inexact Rounded
+pwsx1247 power 6E+2 0.5 -> 2E+1 Inexact Rounded
+pwsx1248 power 6E+3 0.5 -> 8E+1 Inexact Rounded
+pwsx1249 power 0.7 0.5 -> 0.8 Inexact Rounded
+pwsx1250 power 0.07 0.5 -> 0.3 Inexact Rounded
+pwsx1251 power 7.0E-1 0.5 -> 0.8 Inexact Rounded
+pwsx1252 power 7.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1253 power 7E-3 0.5 -> 0.08 Inexact Rounded
+pwsx1254 power 7E+1 0.5 -> 8 Inexact Rounded
+pwsx1255 power 7E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1256 power 7E+3 0.5 -> 8E+1 Inexact Rounded
+pwsx1257 power 0.8 0.5 -> 0.9 Inexact Rounded
+pwsx1258 power 0.08 0.5 -> 0.3 Inexact Rounded
+pwsx1259 power 8.0E-1 0.5 -> 0.9 Inexact Rounded
+pwsx1260 power 8.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1261 power 8E-3 0.5 -> 0.09 Inexact Rounded
+pwsx1262 power 8E+1 0.5 -> 9 Inexact Rounded
+pwsx1263 power 8E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1264 power 8E+3 0.5 -> 9E+1 Inexact Rounded
+pwsx1265 power 0.9 0.5 -> 0.9 Inexact Rounded
+pwsx1266 power 0.09 0.5 -> 0.3 Inexact Rounded
+pwsx1267 power 9.0E-1 0.5 -> 0.9 Inexact Rounded
+pwsx1268 power 9.00E-2 0.5 -> 0.3 Inexact Rounded
+pwsx1269 power 9E-3 0.5 -> 0.09 Inexact Rounded
+pwsx1270 power 9E+1 0.5 -> 9 Inexact Rounded
+pwsx1271 power 9E+2 0.5 -> 3E+1 Inexact Rounded
+pwsx1272 power 9E+3 0.5 -> 9E+1 Inexact Rounded
+
+-- Precision 2 squareroot tests [exhaustive, plus exponent adjusts]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 2
+pwsx2201 power 0.1 0.5 -> 0.32 Inexact Rounded
+pwsx2202 power 0.01 0.5 -> 0.10 Inexact Rounded
+pwsx2203 power 1.0E-1 0.5 -> 0.32 Inexact Rounded
+pwsx2204 power 1.00E-2 0.5 -> 0.10 Inexact Rounded
+pwsx2205 power 1E-3 0.5 -> 0.032 Inexact Rounded
+pwsx2206 power 1E+1 0.5 -> 3.2 Inexact Rounded
+pwsx2207 power 1E+2 0.5 -> 10 Inexact Rounded
+pwsx2208 power 1E+3 0.5 -> 32 Inexact Rounded
+pwsx2209 power 0.2 0.5 -> 0.45 Inexact Rounded
+pwsx2210 power 0.02 0.5 -> 0.14 Inexact Rounded
+pwsx2211 power 2.0E-1 0.5 -> 0.45 Inexact Rounded
+pwsx2212 power 2.00E-2 0.5 -> 0.14 Inexact Rounded
+pwsx2213 power 2E-3 0.5 -> 0.045 Inexact Rounded
+pwsx2214 power 2E+1 0.5 -> 4.5 Inexact Rounded
+pwsx2215 power 2E+2 0.5 -> 14 Inexact Rounded
+pwsx2216 power 2E+3 0.5 -> 45 Inexact Rounded
+pwsx2217 power 0.3 0.5 -> 0.55 Inexact Rounded
+pwsx2218 power 0.03 0.5 -> 0.17 Inexact Rounded
+pwsx2219 power 3.0E-1 0.5 -> 0.55 Inexact Rounded
+pwsx2220 power 3.00E-2 0.5 -> 0.17 Inexact Rounded
+pwsx2221 power 3E-3 0.5 -> 0.055 Inexact Rounded
+pwsx2222 power 3E+1 0.5 -> 5.5 Inexact Rounded
+pwsx2223 power 3E+2 0.5 -> 17 Inexact Rounded
+pwsx2224 power 3E+3 0.5 -> 55 Inexact Rounded
+pwsx2225 power 0.4 0.5 -> 0.63 Inexact Rounded
+pwsx2226 power 0.04 0.5 -> 0.20 Inexact Rounded
+pwsx2227 power 4.0E-1 0.5 -> 0.63 Inexact Rounded
+pwsx2228 power 4.00E-2 0.5 -> 0.20 Inexact Rounded
+pwsx2229 power 4E-3 0.5 -> 0.063 Inexact Rounded
+pwsx2230 power 4E+1 0.5 -> 6.3 Inexact Rounded
+pwsx2231 power 4E+2 0.5 -> 20 Inexact Rounded
+pwsx2232 power 4E+3 0.5 -> 63 Inexact Rounded
+pwsx2233 power 0.5 0.5 -> 0.71 Inexact Rounded
+pwsx2234 power 0.05 0.5 -> 0.22 Inexact Rounded
+pwsx2235 power 5.0E-1 0.5 -> 0.71 Inexact Rounded
+pwsx2236 power 5.00E-2 0.5 -> 0.22 Inexact Rounded
+pwsx2237 power 5E-3 0.5 -> 0.071 Inexact Rounded
+pwsx2238 power 5E+1 0.5 -> 7.1 Inexact Rounded
+pwsx2239 power 5E+2 0.5 -> 22 Inexact Rounded
+pwsx2240 power 5E+3 0.5 -> 71 Inexact Rounded
+pwsx2241 power 0.6 0.5 -> 0.77 Inexact Rounded
+pwsx2242 power 0.06 0.5 -> 0.24 Inexact Rounded
+pwsx2243 power 6.0E-1 0.5 -> 0.77 Inexact Rounded
+pwsx2244 power 6.00E-2 0.5 -> 0.24 Inexact Rounded
+pwsx2245 power 6E-3 0.5 -> 0.077 Inexact Rounded
+pwsx2246 power 6E+1 0.5 -> 7.7 Inexact Rounded
+pwsx2247 power 6E+2 0.5 -> 24 Inexact Rounded
+pwsx2248 power 6E+3 0.5 -> 77 Inexact Rounded
+pwsx2249 power 0.7 0.5 -> 0.84 Inexact Rounded
+pwsx2250 power 0.07 0.5 -> 0.26 Inexact Rounded
+pwsx2251 power 7.0E-1 0.5 -> 0.84 Inexact Rounded
+pwsx2252 power 7.00E-2 0.5 -> 0.26 Inexact Rounded
+pwsx2253 power 7E-3 0.5 -> 0.084 Inexact Rounded
+pwsx2254 power 7E+1 0.5 -> 8.4 Inexact Rounded
+pwsx2255 power 7E+2 0.5 -> 26 Inexact Rounded
+pwsx2256 power 7E+3 0.5 -> 84 Inexact Rounded
+pwsx2257 power 0.8 0.5 -> 0.89 Inexact Rounded
+pwsx2258 power 0.08 0.5 -> 0.28 Inexact Rounded
+pwsx2259 power 8.0E-1 0.5 -> 0.89 Inexact Rounded
+pwsx2260 power 8.00E-2 0.5 -> 0.28 Inexact Rounded
+pwsx2261 power 8E-3 0.5 -> 0.089 Inexact Rounded
+pwsx2262 power 8E+1 0.5 -> 8.9 Inexact Rounded
+pwsx2263 power 8E+2 0.5 -> 28 Inexact Rounded
+pwsx2264 power 8E+3 0.5 -> 89 Inexact Rounded
+pwsx2265 power 0.9 0.5 -> 0.95 Inexact Rounded
+pwsx2266 power 0.09 0.5 -> 0.30 Inexact Rounded
+pwsx2267 power 9.0E-1 0.5 -> 0.95 Inexact Rounded
+pwsx2268 power 9.00E-2 0.5 -> 0.30 Inexact Rounded
+pwsx2269 power 9E-3 0.5 -> 0.095 Inexact Rounded
+pwsx2270 power 9E+1 0.5 -> 9.5 Inexact Rounded
+pwsx2271 power 9E+2 0.5 -> 30 Inexact Rounded
+pwsx2272 power 9E+3 0.5 -> 95 Inexact Rounded
+pwsx2273 power 0.10 0.5 -> 0.32 Inexact Rounded
+pwsx2274 power 0.010 0.5 -> 0.10 Inexact Rounded
+pwsx2275 power 10.0E-1 0.5 -> 1.0 Inexact Rounded
+pwsx2276 power 10.00E-2 0.5 -> 0.32 Inexact Rounded
+pwsx2277 power 10E-3 0.5 -> 0.10 Inexact Rounded
+pwsx2278 power 10E+1 0.5 -> 10 Inexact Rounded
+pwsx2279 power 10E+2 0.5 -> 32 Inexact Rounded
+pwsx2280 power 10E+3 0.5 -> 1.0E+2 Inexact Rounded
+pwsx2281 power 0.11 0.5 -> 0.33 Inexact Rounded
+pwsx2282 power 0.011 0.5 -> 0.10 Inexact Rounded
+pwsx2283 power 11.0E-1 0.5 -> 1.0 Inexact Rounded
+pwsx2284 power 11.00E-2 0.5 -> 0.33 Inexact Rounded
+pwsx2285 power 11E-3 0.5 -> 0.10 Inexact Rounded
+pwsx2286 power 11E+1 0.5 -> 10 Inexact Rounded
+pwsx2287 power 11E+2 0.5 -> 33 Inexact Rounded
+pwsx2288 power 11E+3 0.5 -> 1.0E+2 Inexact Rounded
+pwsx2289 power 0.12 0.5 -> 0.35 Inexact Rounded
+pwsx2290 power 0.012 0.5 -> 0.11 Inexact Rounded
+pwsx2291 power 12.0E-1 0.5 -> 1.1 Inexact Rounded
+pwsx2292 power 12.00E-2 0.5 -> 0.35 Inexact Rounded
+pwsx2293 power 12E-3 0.5 -> 0.11 Inexact Rounded
+pwsx2294 power 12E+1 0.5 -> 11 Inexact Rounded
+pwsx2295 power 12E+2 0.5 -> 35 Inexact Rounded
+pwsx2296 power 12E+3 0.5 -> 1.1E+2 Inexact Rounded
+pwsx2297 power 0.13 0.5 -> 0.36 Inexact Rounded
+pwsx2298 power 0.013 0.5 -> 0.11 Inexact Rounded
+pwsx2299 power 13.0E-1 0.5 -> 1.1 Inexact Rounded
+pwsx2300 power 13.00E-2 0.5 -> 0.36 Inexact Rounded
+pwsx2301 power 13E-3 0.5 -> 0.11 Inexact Rounded
+pwsx2302 power 13E+1 0.5 -> 11 Inexact Rounded
+pwsx2303 power 13E+2 0.5 -> 36 Inexact Rounded
+pwsx2304 power 13E+3 0.5 -> 1.1E+2 Inexact Rounded
+pwsx2305 power 0.14 0.5 -> 0.37 Inexact Rounded
+pwsx2306 power 0.014 0.5 -> 0.12 Inexact Rounded
+pwsx2307 power 14.0E-1 0.5 -> 1.2 Inexact Rounded
+pwsx2308 power 14.00E-2 0.5 -> 0.37 Inexact Rounded
+pwsx2309 power 14E-3 0.5 -> 0.12 Inexact Rounded
+pwsx2310 power 14E+1 0.5 -> 12 Inexact Rounded
+pwsx2311 power 14E+2 0.5 -> 37 Inexact Rounded
+pwsx2312 power 14E+3 0.5 -> 1.2E+2 Inexact Rounded
+pwsx2313 power 0.15 0.5 -> 0.39 Inexact Rounded
+pwsx2314 power 0.015 0.5 -> 0.12 Inexact Rounded
+pwsx2315 power 15.0E-1 0.5 -> 1.2 Inexact Rounded
+pwsx2316 power 15.00E-2 0.5 -> 0.39 Inexact Rounded
+pwsx2317 power 15E-3 0.5 -> 0.12 Inexact Rounded
+pwsx2318 power 15E+1 0.5 -> 12 Inexact Rounded
+pwsx2319 power 15E+2 0.5 -> 39 Inexact Rounded
+pwsx2320 power 15E+3 0.5 -> 1.2E+2 Inexact Rounded
+pwsx2321 power 0.16 0.5 -> 0.40 Inexact Rounded
+pwsx2322 power 0.016 0.5 -> 0.13 Inexact Rounded
+pwsx2323 power 16.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2324 power 16.00E-2 0.5 -> 0.40 Inexact Rounded
+pwsx2325 power 16E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2326 power 16E+1 0.5 -> 13 Inexact Rounded
+pwsx2327 power 16E+2 0.5 -> 40 Inexact Rounded
+pwsx2328 power 16E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2329 power 0.17 0.5 -> 0.41 Inexact Rounded
+pwsx2330 power 0.017 0.5 -> 0.13 Inexact Rounded
+pwsx2331 power 17.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2332 power 17.00E-2 0.5 -> 0.41 Inexact Rounded
+pwsx2333 power 17E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2334 power 17E+1 0.5 -> 13 Inexact Rounded
+pwsx2335 power 17E+2 0.5 -> 41 Inexact Rounded
+pwsx2336 power 17E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2337 power 0.18 0.5 -> 0.42 Inexact Rounded
+pwsx2338 power 0.018 0.5 -> 0.13 Inexact Rounded
+pwsx2339 power 18.0E-1 0.5 -> 1.3 Inexact Rounded
+pwsx2340 power 18.00E-2 0.5 -> 0.42 Inexact Rounded
+pwsx2341 power 18E-3 0.5 -> 0.13 Inexact Rounded
+pwsx2342 power 18E+1 0.5 -> 13 Inexact Rounded
+pwsx2343 power 18E+2 0.5 -> 42 Inexact Rounded
+pwsx2344 power 18E+3 0.5 -> 1.3E+2 Inexact Rounded
+pwsx2345 power 0.19 0.5 -> 0.44 Inexact Rounded
+pwsx2346 power 0.019 0.5 -> 0.14 Inexact Rounded
+pwsx2347 power 19.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2348 power 19.00E-2 0.5 -> 0.44 Inexact Rounded
+pwsx2349 power 19E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2350 power 19E+1 0.5 -> 14 Inexact Rounded
+pwsx2351 power 19E+2 0.5 -> 44 Inexact Rounded
+pwsx2352 power 19E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2353 power 0.20 0.5 -> 0.45 Inexact Rounded
+pwsx2354 power 0.020 0.5 -> 0.14 Inexact Rounded
+pwsx2355 power 20.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2356 power 20.00E-2 0.5 -> 0.45 Inexact Rounded
+pwsx2357 power 20E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2358 power 20E+1 0.5 -> 14 Inexact Rounded
+pwsx2359 power 20E+2 0.5 -> 45 Inexact Rounded
+pwsx2360 power 20E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2361 power 0.21 0.5 -> 0.46 Inexact Rounded
+pwsx2362 power 0.021 0.5 -> 0.14 Inexact Rounded
+pwsx2363 power 21.0E-1 0.5 -> 1.4 Inexact Rounded
+pwsx2364 power 21.00E-2 0.5 -> 0.46 Inexact Rounded
+pwsx2365 power 21E-3 0.5 -> 0.14 Inexact Rounded
+pwsx2366 power 21E+1 0.5 -> 14 Inexact Rounded
+pwsx2367 power 21E+2 0.5 -> 46 Inexact Rounded
+pwsx2368 power 21E+3 0.5 -> 1.4E+2 Inexact Rounded
+pwsx2369 power 0.22 0.5 -> 0.47 Inexact Rounded
+pwsx2370 power 0.022 0.5 -> 0.15 Inexact Rounded
+pwsx2371 power 22.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2372 power 22.00E-2 0.5 -> 0.47 Inexact Rounded
+pwsx2373 power 22E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2374 power 22E+1 0.5 -> 15 Inexact Rounded
+pwsx2375 power 22E+2 0.5 -> 47 Inexact Rounded
+pwsx2376 power 22E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2377 power 0.23 0.5 -> 0.48 Inexact Rounded
+pwsx2378 power 0.023 0.5 -> 0.15 Inexact Rounded
+pwsx2379 power 23.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2380 power 23.00E-2 0.5 -> 0.48 Inexact Rounded
+pwsx2381 power 23E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2382 power 23E+1 0.5 -> 15 Inexact Rounded
+pwsx2383 power 23E+2 0.5 -> 48 Inexact Rounded
+pwsx2384 power 23E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2385 power 0.24 0.5 -> 0.49 Inexact Rounded
+pwsx2386 power 0.024 0.5 -> 0.15 Inexact Rounded
+pwsx2387 power 24.0E-1 0.5 -> 1.5 Inexact Rounded
+pwsx2388 power 24.00E-2 0.5 -> 0.49 Inexact Rounded
+pwsx2389 power 24E-3 0.5 -> 0.15 Inexact Rounded
+pwsx2390 power 24E+1 0.5 -> 15 Inexact Rounded
+pwsx2391 power 24E+2 0.5 -> 49 Inexact Rounded
+pwsx2392 power 24E+3 0.5 -> 1.5E+2 Inexact Rounded
+pwsx2393 power 0.25 0.5 -> 0.50 Inexact Rounded
+pwsx2394 power 0.025 0.5 -> 0.16 Inexact Rounded
+pwsx2395 power 25.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2396 power 25.00E-2 0.5 -> 0.50 Inexact Rounded
+pwsx2397 power 25E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2398 power 25E+1 0.5 -> 16 Inexact Rounded
+pwsx2399 power 25E+2 0.5 -> 50 Inexact Rounded
+pwsx2400 power 25E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2401 power 0.26 0.5 -> 0.51 Inexact Rounded
+pwsx2402 power 0.026 0.5 -> 0.16 Inexact Rounded
+pwsx2403 power 26.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2404 power 26.00E-2 0.5 -> 0.51 Inexact Rounded
+pwsx2405 power 26E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2406 power 26E+1 0.5 -> 16 Inexact Rounded
+pwsx2407 power 26E+2 0.5 -> 51 Inexact Rounded
+pwsx2408 power 26E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2409 power 0.27 0.5 -> 0.52 Inexact Rounded
+pwsx2410 power 0.027 0.5 -> 0.16 Inexact Rounded
+pwsx2411 power 27.0E-1 0.5 -> 1.6 Inexact Rounded
+pwsx2412 power 27.00E-2 0.5 -> 0.52 Inexact Rounded
+pwsx2413 power 27E-3 0.5 -> 0.16 Inexact Rounded
+pwsx2414 power 27E+1 0.5 -> 16 Inexact Rounded
+pwsx2415 power 27E+2 0.5 -> 52 Inexact Rounded
+pwsx2416 power 27E+3 0.5 -> 1.6E+2 Inexact Rounded
+pwsx2417 power 0.28 0.5 -> 0.53 Inexact Rounded
+pwsx2418 power 0.028 0.5 -> 0.17 Inexact Rounded
+pwsx2419 power 28.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2420 power 28.00E-2 0.5 -> 0.53 Inexact Rounded
+pwsx2421 power 28E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2422 power 28E+1 0.5 -> 17 Inexact Rounded
+pwsx2423 power 28E+2 0.5 -> 53 Inexact Rounded
+pwsx2424 power 28E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2425 power 0.29 0.5 -> 0.54 Inexact Rounded
+pwsx2426 power 0.029 0.5 -> 0.17 Inexact Rounded
+pwsx2427 power 29.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2428 power 29.00E-2 0.5 -> 0.54 Inexact Rounded
+pwsx2429 power 29E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2430 power 29E+1 0.5 -> 17 Inexact Rounded
+pwsx2431 power 29E+2 0.5 -> 54 Inexact Rounded
+pwsx2432 power 29E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2433 power 0.30 0.5 -> 0.55 Inexact Rounded
+pwsx2434 power 0.030 0.5 -> 0.17 Inexact Rounded
+pwsx2435 power 30.0E-1 0.5 -> 1.7 Inexact Rounded
+pwsx2436 power 30.00E-2 0.5 -> 0.55 Inexact Rounded
+pwsx2437 power 30E-3 0.5 -> 0.17 Inexact Rounded
+pwsx2438 power 30E+1 0.5 -> 17 Inexact Rounded
+pwsx2439 power 30E+2 0.5 -> 55 Inexact Rounded
+pwsx2440 power 30E+3 0.5 -> 1.7E+2 Inexact Rounded
+pwsx2441 power 0.31 0.5 -> 0.56 Inexact Rounded
+pwsx2442 power 0.031 0.5 -> 0.18 Inexact Rounded
+pwsx2443 power 31.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2444 power 31.00E-2 0.5 -> 0.56 Inexact Rounded
+pwsx2445 power 31E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2446 power 31E+1 0.5 -> 18 Inexact Rounded
+pwsx2447 power 31E+2 0.5 -> 56 Inexact Rounded
+pwsx2448 power 31E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2449 power 0.32 0.5 -> 0.57 Inexact Rounded
+pwsx2450 power 0.032 0.5 -> 0.18 Inexact Rounded
+pwsx2451 power 32.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2452 power 32.00E-2 0.5 -> 0.57 Inexact Rounded
+pwsx2453 power 32E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2454 power 32E+1 0.5 -> 18 Inexact Rounded
+pwsx2455 power 32E+2 0.5 -> 57 Inexact Rounded
+pwsx2456 power 32E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2457 power 0.33 0.5 -> 0.57 Inexact Rounded
+pwsx2458 power 0.033 0.5 -> 0.18 Inexact Rounded
+pwsx2459 power 33.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2460 power 33.00E-2 0.5 -> 0.57 Inexact Rounded
+pwsx2461 power 33E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2462 power 33E+1 0.5 -> 18 Inexact Rounded
+pwsx2463 power 33E+2 0.5 -> 57 Inexact Rounded
+pwsx2464 power 33E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2465 power 0.34 0.5 -> 0.58 Inexact Rounded
+pwsx2466 power 0.034 0.5 -> 0.18 Inexact Rounded
+pwsx2467 power 34.0E-1 0.5 -> 1.8 Inexact Rounded
+pwsx2468 power 34.00E-2 0.5 -> 0.58 Inexact Rounded
+pwsx2469 power 34E-3 0.5 -> 0.18 Inexact Rounded
+pwsx2470 power 34E+1 0.5 -> 18 Inexact Rounded
+pwsx2471 power 34E+2 0.5 -> 58 Inexact Rounded
+pwsx2472 power 34E+3 0.5 -> 1.8E+2 Inexact Rounded
+pwsx2473 power 0.35 0.5 -> 0.59 Inexact Rounded
+pwsx2474 power 0.035 0.5 -> 0.19 Inexact Rounded
+pwsx2475 power 35.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2476 power 35.00E-2 0.5 -> 0.59 Inexact Rounded
+pwsx2477 power 35E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2478 power 35E+1 0.5 -> 19 Inexact Rounded
+pwsx2479 power 35E+2 0.5 -> 59 Inexact Rounded
+pwsx2480 power 35E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2481 power 0.36 0.5 -> 0.60 Inexact Rounded
+pwsx2482 power 0.036 0.5 -> 0.19 Inexact Rounded
+pwsx2483 power 36.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2484 power 36.00E-2 0.5 -> 0.60 Inexact Rounded
+pwsx2485 power 36E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2486 power 36E+1 0.5 -> 19 Inexact Rounded
+pwsx2487 power 36E+2 0.5 -> 60 Inexact Rounded
+pwsx2488 power 36E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2489 power 0.37 0.5 -> 0.61 Inexact Rounded
+pwsx2490 power 0.037 0.5 -> 0.19 Inexact Rounded
+pwsx2491 power 37.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2492 power 37.00E-2 0.5 -> 0.61 Inexact Rounded
+pwsx2493 power 37E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2494 power 37E+1 0.5 -> 19 Inexact Rounded
+pwsx2495 power 37E+2 0.5 -> 61 Inexact Rounded
+pwsx2496 power 37E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2497 power 0.38 0.5 -> 0.62 Inexact Rounded
+pwsx2498 power 0.038 0.5 -> 0.19 Inexact Rounded
+pwsx2499 power 38.0E-1 0.5 -> 1.9 Inexact Rounded
+pwsx2500 power 38.00E-2 0.5 -> 0.62 Inexact Rounded
+pwsx2501 power 38E-3 0.5 -> 0.19 Inexact Rounded
+pwsx2502 power 38E+1 0.5 -> 19 Inexact Rounded
+pwsx2503 power 38E+2 0.5 -> 62 Inexact Rounded
+pwsx2504 power 38E+3 0.5 -> 1.9E+2 Inexact Rounded
+pwsx2505 power 0.39 0.5 -> 0.62 Inexact Rounded
+pwsx2506 power 0.039 0.5 -> 0.20 Inexact Rounded
+pwsx2507 power 39.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2508 power 39.00E-2 0.5 -> 0.62 Inexact Rounded
+pwsx2509 power 39E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2510 power 39E+1 0.5 -> 20 Inexact Rounded
+pwsx2511 power 39E+2 0.5 -> 62 Inexact Rounded
+pwsx2512 power 39E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2513 power 0.40 0.5 -> 0.63 Inexact Rounded
+pwsx2514 power 0.040 0.5 -> 0.20 Inexact Rounded
+pwsx2515 power 40.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2516 power 40.00E-2 0.5 -> 0.63 Inexact Rounded
+pwsx2517 power 40E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2518 power 40E+1 0.5 -> 20 Inexact Rounded
+pwsx2519 power 40E+2 0.5 -> 63 Inexact Rounded
+pwsx2520 power 40E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2521 power 0.41 0.5 -> 0.64 Inexact Rounded
+pwsx2522 power 0.041 0.5 -> 0.20 Inexact Rounded
+pwsx2523 power 41.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2524 power 41.00E-2 0.5 -> 0.64 Inexact Rounded
+pwsx2525 power 41E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2526 power 41E+1 0.5 -> 20 Inexact Rounded
+pwsx2527 power 41E+2 0.5 -> 64 Inexact Rounded
+pwsx2528 power 41E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2529 power 0.42 0.5 -> 0.65 Inexact Rounded
+pwsx2530 power 0.042 0.5 -> 0.20 Inexact Rounded
+pwsx2531 power 42.0E-1 0.5 -> 2.0 Inexact Rounded
+pwsx2532 power 42.00E-2 0.5 -> 0.65 Inexact Rounded
+pwsx2533 power 42E-3 0.5 -> 0.20 Inexact Rounded
+pwsx2534 power 42E+1 0.5 -> 20 Inexact Rounded
+pwsx2535 power 42E+2 0.5 -> 65 Inexact Rounded
+pwsx2536 power 42E+3 0.5 -> 2.0E+2 Inexact Rounded
+pwsx2537 power 0.43 0.5 -> 0.66 Inexact Rounded
+pwsx2538 power 0.043 0.5 -> 0.21 Inexact Rounded
+pwsx2539 power 43.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2540 power 43.00E-2 0.5 -> 0.66 Inexact Rounded
+pwsx2541 power 43E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2542 power 43E+1 0.5 -> 21 Inexact Rounded
+pwsx2543 power 43E+2 0.5 -> 66 Inexact Rounded
+pwsx2544 power 43E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2545 power 0.44 0.5 -> 0.66 Inexact Rounded
+pwsx2546 power 0.044 0.5 -> 0.21 Inexact Rounded
+pwsx2547 power 44.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2548 power 44.00E-2 0.5 -> 0.66 Inexact Rounded
+pwsx2549 power 44E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2550 power 44E+1 0.5 -> 21 Inexact Rounded
+pwsx2551 power 44E+2 0.5 -> 66 Inexact Rounded
+pwsx2552 power 44E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2553 power 0.45 0.5 -> 0.67 Inexact Rounded
+pwsx2554 power 0.045 0.5 -> 0.21 Inexact Rounded
+pwsx2555 power 45.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2556 power 45.00E-2 0.5 -> 0.67 Inexact Rounded
+pwsx2557 power 45E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2558 power 45E+1 0.5 -> 21 Inexact Rounded
+pwsx2559 power 45E+2 0.5 -> 67 Inexact Rounded
+pwsx2560 power 45E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2561 power 0.46 0.5 -> 0.68 Inexact Rounded
+pwsx2562 power 0.046 0.5 -> 0.21 Inexact Rounded
+pwsx2563 power 46.0E-1 0.5 -> 2.1 Inexact Rounded
+pwsx2564 power 46.00E-2 0.5 -> 0.68 Inexact Rounded
+pwsx2565 power 46E-3 0.5 -> 0.21 Inexact Rounded
+pwsx2566 power 46E+1 0.5 -> 21 Inexact Rounded
+pwsx2567 power 46E+2 0.5 -> 68 Inexact Rounded
+pwsx2568 power 46E+3 0.5 -> 2.1E+2 Inexact Rounded
+pwsx2569 power 0.47 0.5 -> 0.69 Inexact Rounded
+pwsx2570 power 0.047 0.5 -> 0.22 Inexact Rounded
+pwsx2571 power 47.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2572 power 47.00E-2 0.5 -> 0.69 Inexact Rounded
+pwsx2573 power 47E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2574 power 47E+1 0.5 -> 22 Inexact Rounded
+pwsx2575 power 47E+2 0.5 -> 69 Inexact Rounded
+pwsx2576 power 47E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2577 power 0.48 0.5 -> 0.69 Inexact Rounded
+pwsx2578 power 0.048 0.5 -> 0.22 Inexact Rounded
+pwsx2579 power 48.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2580 power 48.00E-2 0.5 -> 0.69 Inexact Rounded
+pwsx2581 power 48E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2582 power 48E+1 0.5 -> 22 Inexact Rounded
+pwsx2583 power 48E+2 0.5 -> 69 Inexact Rounded
+pwsx2584 power 48E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2585 power 0.49 0.5 -> 0.70 Inexact Rounded
+pwsx2586 power 0.049 0.5 -> 0.22 Inexact Rounded
+pwsx2587 power 49.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2588 power 49.00E-2 0.5 -> 0.70 Inexact Rounded
+pwsx2589 power 49E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2590 power 49E+1 0.5 -> 22 Inexact Rounded
+pwsx2591 power 49E+2 0.5 -> 70 Inexact Rounded
+pwsx2592 power 49E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2593 power 0.50 0.5 -> 0.71 Inexact Rounded
+pwsx2594 power 0.050 0.5 -> 0.22 Inexact Rounded
+pwsx2595 power 50.0E-1 0.5 -> 2.2 Inexact Rounded
+pwsx2596 power 50.00E-2 0.5 -> 0.71 Inexact Rounded
+pwsx2597 power 50E-3 0.5 -> 0.22 Inexact Rounded
+pwsx2598 power 50E+1 0.5 -> 22 Inexact Rounded
+pwsx2599 power 50E+2 0.5 -> 71 Inexact Rounded
+pwsx2600 power 50E+3 0.5 -> 2.2E+2 Inexact Rounded
+pwsx2601 power 0.51 0.5 -> 0.71 Inexact Rounded
+pwsx2602 power 0.051 0.5 -> 0.23 Inexact Rounded
+pwsx2603 power 51.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2604 power 51.00E-2 0.5 -> 0.71 Inexact Rounded
+pwsx2605 power 51E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2606 power 51E+1 0.5 -> 23 Inexact Rounded
+pwsx2607 power 51E+2 0.5 -> 71 Inexact Rounded
+pwsx2608 power 51E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2609 power 0.52 0.5 -> 0.72 Inexact Rounded
+pwsx2610 power 0.052 0.5 -> 0.23 Inexact Rounded
+pwsx2611 power 52.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2612 power 52.00E-2 0.5 -> 0.72 Inexact Rounded
+pwsx2613 power 52E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2614 power 52E+1 0.5 -> 23 Inexact Rounded
+pwsx2615 power 52E+2 0.5 -> 72 Inexact Rounded
+pwsx2616 power 52E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2617 power 0.53 0.5 -> 0.73 Inexact Rounded
+pwsx2618 power 0.053 0.5 -> 0.23 Inexact Rounded
+pwsx2619 power 53.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2620 power 53.00E-2 0.5 -> 0.73 Inexact Rounded
+pwsx2621 power 53E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2622 power 53E+1 0.5 -> 23 Inexact Rounded
+pwsx2623 power 53E+2 0.5 -> 73 Inexact Rounded
+pwsx2624 power 53E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2625 power 0.54 0.5 -> 0.73 Inexact Rounded
+pwsx2626 power 0.054 0.5 -> 0.23 Inexact Rounded
+pwsx2627 power 54.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2628 power 54.00E-2 0.5 -> 0.73 Inexact Rounded
+pwsx2629 power 54E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2630 power 54E+1 0.5 -> 23 Inexact Rounded
+pwsx2631 power 54E+2 0.5 -> 73 Inexact Rounded
+pwsx2632 power 54E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2633 power 0.55 0.5 -> 0.74 Inexact Rounded
+pwsx2634 power 0.055 0.5 -> 0.23 Inexact Rounded
+pwsx2635 power 55.0E-1 0.5 -> 2.3 Inexact Rounded
+pwsx2636 power 55.00E-2 0.5 -> 0.74 Inexact Rounded
+pwsx2637 power 55E-3 0.5 -> 0.23 Inexact Rounded
+pwsx2638 power 55E+1 0.5 -> 23 Inexact Rounded
+pwsx2639 power 55E+2 0.5 -> 74 Inexact Rounded
+pwsx2640 power 55E+3 0.5 -> 2.3E+2 Inexact Rounded
+pwsx2641 power 0.56 0.5 -> 0.75 Inexact Rounded
+pwsx2642 power 0.056 0.5 -> 0.24 Inexact Rounded
+pwsx2643 power 56.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2644 power 56.00E-2 0.5 -> 0.75 Inexact Rounded
+pwsx2645 power 56E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2646 power 56E+1 0.5 -> 24 Inexact Rounded
+pwsx2647 power 56E+2 0.5 -> 75 Inexact Rounded
+pwsx2648 power 56E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2649 power 0.57 0.5 -> 0.75 Inexact Rounded
+pwsx2650 power 0.057 0.5 -> 0.24 Inexact Rounded
+pwsx2651 power 57.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2652 power 57.00E-2 0.5 -> 0.75 Inexact Rounded
+pwsx2653 power 57E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2654 power 57E+1 0.5 -> 24 Inexact Rounded
+pwsx2655 power 57E+2 0.5 -> 75 Inexact Rounded
+pwsx2656 power 57E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2657 power 0.58 0.5 -> 0.76 Inexact Rounded
+pwsx2658 power 0.058 0.5 -> 0.24 Inexact Rounded
+pwsx2659 power 58.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2660 power 58.00E-2 0.5 -> 0.76 Inexact Rounded
+pwsx2661 power 58E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2662 power 58E+1 0.5 -> 24 Inexact Rounded
+pwsx2663 power 58E+2 0.5 -> 76 Inexact Rounded
+pwsx2664 power 58E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2665 power 0.59 0.5 -> 0.77 Inexact Rounded
+pwsx2666 power 0.059 0.5 -> 0.24 Inexact Rounded
+pwsx2667 power 59.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2668 power 59.00E-2 0.5 -> 0.77 Inexact Rounded
+pwsx2669 power 59E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2670 power 59E+1 0.5 -> 24 Inexact Rounded
+pwsx2671 power 59E+2 0.5 -> 77 Inexact Rounded
+pwsx2672 power 59E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2673 power 0.60 0.5 -> 0.77 Inexact Rounded
+pwsx2674 power 0.060 0.5 -> 0.24 Inexact Rounded
+pwsx2675 power 60.0E-1 0.5 -> 2.4 Inexact Rounded
+pwsx2676 power 60.00E-2 0.5 -> 0.77 Inexact Rounded
+pwsx2677 power 60E-3 0.5 -> 0.24 Inexact Rounded
+pwsx2678 power 60E+1 0.5 -> 24 Inexact Rounded
+pwsx2679 power 60E+2 0.5 -> 77 Inexact Rounded
+pwsx2680 power 60E+3 0.5 -> 2.4E+2 Inexact Rounded
+pwsx2681 power 0.61 0.5 -> 0.78 Inexact Rounded
+pwsx2682 power 0.061 0.5 -> 0.25 Inexact Rounded
+pwsx2683 power 61.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2684 power 61.00E-2 0.5 -> 0.78 Inexact Rounded
+pwsx2685 power 61E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2686 power 61E+1 0.5 -> 25 Inexact Rounded
+pwsx2687 power 61E+2 0.5 -> 78 Inexact Rounded
+pwsx2688 power 61E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2689 power 0.62 0.5 -> 0.79 Inexact Rounded
+pwsx2690 power 0.062 0.5 -> 0.25 Inexact Rounded
+pwsx2691 power 62.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2692 power 62.00E-2 0.5 -> 0.79 Inexact Rounded
+pwsx2693 power 62E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2694 power 62E+1 0.5 -> 25 Inexact Rounded
+pwsx2695 power 62E+2 0.5 -> 79 Inexact Rounded
+pwsx2696 power 62E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2697 power 0.63 0.5 -> 0.79 Inexact Rounded
+pwsx2698 power 0.063 0.5 -> 0.25 Inexact Rounded
+pwsx2699 power 63.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2700 power 63.00E-2 0.5 -> 0.79 Inexact Rounded
+pwsx2701 power 63E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2702 power 63E+1 0.5 -> 25 Inexact Rounded
+pwsx2703 power 63E+2 0.5 -> 79 Inexact Rounded
+pwsx2704 power 63E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2705 power 0.64 0.5 -> 0.80 Inexact Rounded
+pwsx2706 power 0.064 0.5 -> 0.25 Inexact Rounded
+pwsx2707 power 64.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2708 power 64.00E-2 0.5 -> 0.80 Inexact Rounded
+pwsx2709 power 64E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2710 power 64E+1 0.5 -> 25 Inexact Rounded
+pwsx2711 power 64E+2 0.5 -> 80 Inexact Rounded
+pwsx2712 power 64E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2713 power 0.65 0.5 -> 0.81 Inexact Rounded
+pwsx2714 power 0.065 0.5 -> 0.25 Inexact Rounded
+pwsx2715 power 65.0E-1 0.5 -> 2.5 Inexact Rounded
+pwsx2716 power 65.00E-2 0.5 -> 0.81 Inexact Rounded
+pwsx2717 power 65E-3 0.5 -> 0.25 Inexact Rounded
+pwsx2718 power 65E+1 0.5 -> 25 Inexact Rounded
+pwsx2719 power 65E+2 0.5 -> 81 Inexact Rounded
+pwsx2720 power 65E+3 0.5 -> 2.5E+2 Inexact Rounded
+pwsx2721 power 0.66 0.5 -> 0.81 Inexact Rounded
+pwsx2722 power 0.066 0.5 -> 0.26 Inexact Rounded
+pwsx2723 power 66.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2724 power 66.00E-2 0.5 -> 0.81 Inexact Rounded
+pwsx2725 power 66E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2726 power 66E+1 0.5 -> 26 Inexact Rounded
+pwsx2727 power 66E+2 0.5 -> 81 Inexact Rounded
+pwsx2728 power 66E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2729 power 0.67 0.5 -> 0.82 Inexact Rounded
+pwsx2730 power 0.067 0.5 -> 0.26 Inexact Rounded
+pwsx2731 power 67.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2732 power 67.00E-2 0.5 -> 0.82 Inexact Rounded
+pwsx2733 power 67E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2734 power 67E+1 0.5 -> 26 Inexact Rounded
+pwsx2735 power 67E+2 0.5 -> 82 Inexact Rounded
+pwsx2736 power 67E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2737 power 0.68 0.5 -> 0.82 Inexact Rounded
+pwsx2738 power 0.068 0.5 -> 0.26 Inexact Rounded
+pwsx2739 power 68.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2740 power 68.00E-2 0.5 -> 0.82 Inexact Rounded
+pwsx2741 power 68E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2742 power 68E+1 0.5 -> 26 Inexact Rounded
+pwsx2743 power 68E+2 0.5 -> 82 Inexact Rounded
+pwsx2744 power 68E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2745 power 0.69 0.5 -> 0.83 Inexact Rounded
+pwsx2746 power 0.069 0.5 -> 0.26 Inexact Rounded
+pwsx2747 power 69.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2748 power 69.00E-2 0.5 -> 0.83 Inexact Rounded
+pwsx2749 power 69E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2750 power 69E+1 0.5 -> 26 Inexact Rounded
+pwsx2751 power 69E+2 0.5 -> 83 Inexact Rounded
+pwsx2752 power 69E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2753 power 0.70 0.5 -> 0.84 Inexact Rounded
+pwsx2754 power 0.070 0.5 -> 0.26 Inexact Rounded
+pwsx2755 power 70.0E-1 0.5 -> 2.6 Inexact Rounded
+pwsx2756 power 70.00E-2 0.5 -> 0.84 Inexact Rounded
+pwsx2757 power 70E-3 0.5 -> 0.26 Inexact Rounded
+pwsx2758 power 70E+1 0.5 -> 26 Inexact Rounded
+pwsx2759 power 70E+2 0.5 -> 84 Inexact Rounded
+pwsx2760 power 70E+3 0.5 -> 2.6E+2 Inexact Rounded
+pwsx2761 power 0.71 0.5 -> 0.84 Inexact Rounded
+pwsx2762 power 0.071 0.5 -> 0.27 Inexact Rounded
+pwsx2763 power 71.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2764 power 71.00E-2 0.5 -> 0.84 Inexact Rounded
+pwsx2765 power 71E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2766 power 71E+1 0.5 -> 27 Inexact Rounded
+pwsx2767 power 71E+2 0.5 -> 84 Inexact Rounded
+pwsx2768 power 71E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2769 power 0.72 0.5 -> 0.85 Inexact Rounded
+pwsx2770 power 0.072 0.5 -> 0.27 Inexact Rounded
+pwsx2771 power 72.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2772 power 72.00E-2 0.5 -> 0.85 Inexact Rounded
+pwsx2773 power 72E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2774 power 72E+1 0.5 -> 27 Inexact Rounded
+pwsx2775 power 72E+2 0.5 -> 85 Inexact Rounded
+pwsx2776 power 72E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2777 power 0.73 0.5 -> 0.85 Inexact Rounded
+pwsx2778 power 0.073 0.5 -> 0.27 Inexact Rounded
+pwsx2779 power 73.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2780 power 73.00E-2 0.5 -> 0.85 Inexact Rounded
+pwsx2781 power 73E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2782 power 73E+1 0.5 -> 27 Inexact Rounded
+pwsx2783 power 73E+2 0.5 -> 85 Inexact Rounded
+pwsx2784 power 73E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2785 power 0.74 0.5 -> 0.86 Inexact Rounded
+pwsx2786 power 0.074 0.5 -> 0.27 Inexact Rounded
+pwsx2787 power 74.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2788 power 74.00E-2 0.5 -> 0.86 Inexact Rounded
+pwsx2789 power 74E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2790 power 74E+1 0.5 -> 27 Inexact Rounded
+pwsx2791 power 74E+2 0.5 -> 86 Inexact Rounded
+pwsx2792 power 74E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2793 power 0.75 0.5 -> 0.87 Inexact Rounded
+pwsx2794 power 0.075 0.5 -> 0.27 Inexact Rounded
+pwsx2795 power 75.0E-1 0.5 -> 2.7 Inexact Rounded
+pwsx2796 power 75.00E-2 0.5 -> 0.87 Inexact Rounded
+pwsx2797 power 75E-3 0.5 -> 0.27 Inexact Rounded
+pwsx2798 power 75E+1 0.5 -> 27 Inexact Rounded
+pwsx2799 power 75E+2 0.5 -> 87 Inexact Rounded
+pwsx2800 power 75E+3 0.5 -> 2.7E+2 Inexact Rounded
+pwsx2801 power 0.76 0.5 -> 0.87 Inexact Rounded
+pwsx2802 power 0.076 0.5 -> 0.28 Inexact Rounded
+pwsx2803 power 76.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2804 power 76.00E-2 0.5 -> 0.87 Inexact Rounded
+pwsx2805 power 76E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2806 power 76E+1 0.5 -> 28 Inexact Rounded
+pwsx2807 power 76E+2 0.5 -> 87 Inexact Rounded
+pwsx2808 power 76E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2809 power 0.77 0.5 -> 0.88 Inexact Rounded
+pwsx2810 power 0.077 0.5 -> 0.28 Inexact Rounded
+pwsx2811 power 77.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2812 power 77.00E-2 0.5 -> 0.88 Inexact Rounded
+pwsx2813 power 77E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2814 power 77E+1 0.5 -> 28 Inexact Rounded
+pwsx2815 power 77E+2 0.5 -> 88 Inexact Rounded
+pwsx2816 power 77E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2817 power 0.78 0.5 -> 0.88 Inexact Rounded
+pwsx2818 power 0.078 0.5 -> 0.28 Inexact Rounded
+pwsx2819 power 78.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2820 power 78.00E-2 0.5 -> 0.88 Inexact Rounded
+pwsx2821 power 78E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2822 power 78E+1 0.5 -> 28 Inexact Rounded
+pwsx2823 power 78E+2 0.5 -> 88 Inexact Rounded
+pwsx2824 power 78E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2825 power 0.79 0.5 -> 0.89 Inexact Rounded
+pwsx2826 power 0.079 0.5 -> 0.28 Inexact Rounded
+pwsx2827 power 79.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2828 power 79.00E-2 0.5 -> 0.89 Inexact Rounded
+pwsx2829 power 79E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2830 power 79E+1 0.5 -> 28 Inexact Rounded
+pwsx2831 power 79E+2 0.5 -> 89 Inexact Rounded
+pwsx2832 power 79E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2833 power 0.80 0.5 -> 0.89 Inexact Rounded
+pwsx2834 power 0.080 0.5 -> 0.28 Inexact Rounded
+pwsx2835 power 80.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2836 power 80.00E-2 0.5 -> 0.89 Inexact Rounded
+pwsx2837 power 80E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2838 power 80E+1 0.5 -> 28 Inexact Rounded
+pwsx2839 power 80E+2 0.5 -> 89 Inexact Rounded
+pwsx2840 power 80E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2841 power 0.81 0.5 -> 0.90 Inexact Rounded
+pwsx2842 power 0.081 0.5 -> 0.28 Inexact Rounded
+pwsx2843 power 81.0E-1 0.5 -> 2.8 Inexact Rounded
+pwsx2844 power 81.00E-2 0.5 -> 0.90 Inexact Rounded
+pwsx2845 power 81E-3 0.5 -> 0.28 Inexact Rounded
+pwsx2846 power 81E+1 0.5 -> 28 Inexact Rounded
+pwsx2847 power 81E+2 0.5 -> 90 Inexact Rounded
+pwsx2848 power 81E+3 0.5 -> 2.8E+2 Inexact Rounded
+pwsx2849 power 0.82 0.5 -> 0.91 Inexact Rounded
+pwsx2850 power 0.082 0.5 -> 0.29 Inexact Rounded
+pwsx2851 power 82.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2852 power 82.00E-2 0.5 -> 0.91 Inexact Rounded
+pwsx2853 power 82E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2854 power 82E+1 0.5 -> 29 Inexact Rounded
+pwsx2855 power 82E+2 0.5 -> 91 Inexact Rounded
+pwsx2856 power 82E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2857 power 0.83 0.5 -> 0.91 Inexact Rounded
+pwsx2858 power 0.083 0.5 -> 0.29 Inexact Rounded
+pwsx2859 power 83.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2860 power 83.00E-2 0.5 -> 0.91 Inexact Rounded
+pwsx2861 power 83E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2862 power 83E+1 0.5 -> 29 Inexact Rounded
+pwsx2863 power 83E+2 0.5 -> 91 Inexact Rounded
+pwsx2864 power 83E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2865 power 0.84 0.5 -> 0.92 Inexact Rounded
+pwsx2866 power 0.084 0.5 -> 0.29 Inexact Rounded
+pwsx2867 power 84.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2868 power 84.00E-2 0.5 -> 0.92 Inexact Rounded
+pwsx2869 power 84E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2870 power 84E+1 0.5 -> 29 Inexact Rounded
+pwsx2871 power 84E+2 0.5 -> 92 Inexact Rounded
+pwsx2872 power 84E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2873 power 0.85 0.5 -> 0.92 Inexact Rounded
+pwsx2874 power 0.085 0.5 -> 0.29 Inexact Rounded
+pwsx2875 power 85.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2876 power 85.00E-2 0.5 -> 0.92 Inexact Rounded
+pwsx2877 power 85E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2878 power 85E+1 0.5 -> 29 Inexact Rounded
+pwsx2879 power 85E+2 0.5 -> 92 Inexact Rounded
+pwsx2880 power 85E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2881 power 0.86 0.5 -> 0.93 Inexact Rounded
+pwsx2882 power 0.086 0.5 -> 0.29 Inexact Rounded
+pwsx2883 power 86.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2884 power 86.00E-2 0.5 -> 0.93 Inexact Rounded
+pwsx2885 power 86E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2886 power 86E+1 0.5 -> 29 Inexact Rounded
+pwsx2887 power 86E+2 0.5 -> 93 Inexact Rounded
+pwsx2888 power 86E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2889 power 0.87 0.5 -> 0.93 Inexact Rounded
+pwsx2890 power 0.087 0.5 -> 0.29 Inexact Rounded
+pwsx2891 power 87.0E-1 0.5 -> 2.9 Inexact Rounded
+pwsx2892 power 87.00E-2 0.5 -> 0.93 Inexact Rounded
+pwsx2893 power 87E-3 0.5 -> 0.29 Inexact Rounded
+pwsx2894 power 87E+1 0.5 -> 29 Inexact Rounded
+pwsx2895 power 87E+2 0.5 -> 93 Inexact Rounded
+pwsx2896 power 87E+3 0.5 -> 2.9E+2 Inexact Rounded
+pwsx2897 power 0.88 0.5 -> 0.94 Inexact Rounded
+pwsx2898 power 0.088 0.5 -> 0.30 Inexact Rounded
+pwsx2899 power 88.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2900 power 88.00E-2 0.5 -> 0.94 Inexact Rounded
+pwsx2901 power 88E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2902 power 88E+1 0.5 -> 30 Inexact Rounded
+pwsx2903 power 88E+2 0.5 -> 94 Inexact Rounded
+pwsx2904 power 88E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2905 power 0.89 0.5 -> 0.94 Inexact Rounded
+pwsx2906 power 0.089 0.5 -> 0.30 Inexact Rounded
+pwsx2907 power 89.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2908 power 89.00E-2 0.5 -> 0.94 Inexact Rounded
+pwsx2909 power 89E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2910 power 89E+1 0.5 -> 30 Inexact Rounded
+pwsx2911 power 89E+2 0.5 -> 94 Inexact Rounded
+pwsx2912 power 89E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2913 power 0.90 0.5 -> 0.95 Inexact Rounded
+pwsx2914 power 0.090 0.5 -> 0.30 Inexact Rounded
+pwsx2915 power 90.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2916 power 90.00E-2 0.5 -> 0.95 Inexact Rounded
+pwsx2917 power 90E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2918 power 90E+1 0.5 -> 30 Inexact Rounded
+pwsx2919 power 90E+2 0.5 -> 95 Inexact Rounded
+pwsx2920 power 90E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2921 power 0.91 0.5 -> 0.95 Inexact Rounded
+pwsx2922 power 0.091 0.5 -> 0.30 Inexact Rounded
+pwsx2923 power 91.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2924 power 91.00E-2 0.5 -> 0.95 Inexact Rounded
+pwsx2925 power 91E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2926 power 91E+1 0.5 -> 30 Inexact Rounded
+pwsx2927 power 91E+2 0.5 -> 95 Inexact Rounded
+pwsx2928 power 91E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2929 power 0.92 0.5 -> 0.96 Inexact Rounded
+pwsx2930 power 0.092 0.5 -> 0.30 Inexact Rounded
+pwsx2931 power 92.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2932 power 92.00E-2 0.5 -> 0.96 Inexact Rounded
+pwsx2933 power 92E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2934 power 92E+1 0.5 -> 30 Inexact Rounded
+pwsx2935 power 92E+2 0.5 -> 96 Inexact Rounded
+pwsx2936 power 92E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2937 power 0.93 0.5 -> 0.96 Inexact Rounded
+pwsx2938 power 0.093 0.5 -> 0.30 Inexact Rounded
+pwsx2939 power 93.0E-1 0.5 -> 3.0 Inexact Rounded
+pwsx2940 power 93.00E-2 0.5 -> 0.96 Inexact Rounded
+pwsx2941 power 93E-3 0.5 -> 0.30 Inexact Rounded
+pwsx2942 power 93E+1 0.5 -> 30 Inexact Rounded
+pwsx2943 power 93E+2 0.5 -> 96 Inexact Rounded
+pwsx2944 power 93E+3 0.5 -> 3.0E+2 Inexact Rounded
+pwsx2945 power 0.94 0.5 -> 0.97 Inexact Rounded
+pwsx2946 power 0.094 0.5 -> 0.31 Inexact Rounded
+pwsx2947 power 94.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2948 power 94.00E-2 0.5 -> 0.97 Inexact Rounded
+pwsx2949 power 94E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2950 power 94E+1 0.5 -> 31 Inexact Rounded
+pwsx2951 power 94E+2 0.5 -> 97 Inexact Rounded
+pwsx2952 power 94E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2953 power 0.95 0.5 -> 0.97 Inexact Rounded
+pwsx2954 power 0.095 0.5 -> 0.31 Inexact Rounded
+pwsx2955 power 95.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2956 power 95.00E-2 0.5 -> 0.97 Inexact Rounded
+pwsx2957 power 95E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2958 power 95E+1 0.5 -> 31 Inexact Rounded
+pwsx2959 power 95E+2 0.5 -> 97 Inexact Rounded
+pwsx2960 power 95E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2961 power 0.96 0.5 -> 0.98 Inexact Rounded
+pwsx2962 power 0.096 0.5 -> 0.31 Inexact Rounded
+pwsx2963 power 96.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2964 power 96.00E-2 0.5 -> 0.98 Inexact Rounded
+pwsx2965 power 96E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2966 power 96E+1 0.5 -> 31 Inexact Rounded
+pwsx2967 power 96E+2 0.5 -> 98 Inexact Rounded
+pwsx2968 power 96E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2969 power 0.97 0.5 -> 0.98 Inexact Rounded
+pwsx2970 power 0.097 0.5 -> 0.31 Inexact Rounded
+pwsx2971 power 97.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2972 power 97.00E-2 0.5 -> 0.98 Inexact Rounded
+pwsx2973 power 97E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2974 power 97E+1 0.5 -> 31 Inexact Rounded
+pwsx2975 power 97E+2 0.5 -> 98 Inexact Rounded
+pwsx2976 power 97E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2977 power 0.98 0.5 -> 0.99 Inexact Rounded
+pwsx2978 power 0.098 0.5 -> 0.31 Inexact Rounded
+pwsx2979 power 98.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2980 power 98.00E-2 0.5 -> 0.99 Inexact Rounded
+pwsx2981 power 98E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2982 power 98E+1 0.5 -> 31 Inexact Rounded
+pwsx2983 power 98E+2 0.5 -> 99 Inexact Rounded
+pwsx2984 power 98E+3 0.5 -> 3.1E+2 Inexact Rounded
+pwsx2985 power 0.99 0.5 -> 0.99 Inexact Rounded
+pwsx2986 power 0.099 0.5 -> 0.31 Inexact Rounded
+pwsx2987 power 99.0E-1 0.5 -> 3.1 Inexact Rounded
+pwsx2988 power 99.00E-2 0.5 -> 0.99 Inexact Rounded
+pwsx2989 power 99E-3 0.5 -> 0.31 Inexact Rounded
+pwsx2990 power 99E+1 0.5 -> 31 Inexact Rounded
+pwsx2991 power 99E+2 0.5 -> 99 Inexact Rounded
+pwsx2992 power 99E+3 0.5 -> 3.1E+2 Inexact Rounded
+
+-- Precision 3 squareroot tests [exhaustive, f and f/10]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 3
+pwsx3001 power 0.1 0.5 -> 0.316 Inexact Rounded
+pwsx3002 power 0.01 0.5 -> 0.100 Inexact Rounded
+pwsx3003 power 0.2 0.5 -> 0.447 Inexact Rounded
+pwsx3004 power 0.02 0.5 -> 0.141 Inexact Rounded
+pwsx3005 power 0.3 0.5 -> 0.548 Inexact Rounded
+pwsx3006 power 0.03 0.5 -> 0.173 Inexact Rounded
+pwsx3007 power 0.4 0.5 -> 0.632 Inexact Rounded
+pwsx3008 power 0.04 0.5 -> 0.200 Inexact Rounded
+pwsx3009 power 0.5 0.5 -> 0.707 Inexact Rounded
+pwsx3010 power 0.05 0.5 -> 0.224 Inexact Rounded
+pwsx3011 power 0.6 0.5 -> 0.775 Inexact Rounded
+pwsx3012 power 0.06 0.5 -> 0.245 Inexact Rounded
+pwsx3013 power 0.7 0.5 -> 0.837 Inexact Rounded
+pwsx3014 power 0.07 0.5 -> 0.265 Inexact Rounded
+pwsx3015 power 0.8 0.5 -> 0.894 Inexact Rounded
+pwsx3016 power 0.08 0.5 -> 0.283 Inexact Rounded
+pwsx3017 power 0.9 0.5 -> 0.949 Inexact Rounded
+pwsx3018 power 0.09 0.5 -> 0.300 Inexact Rounded
+pwsx3019 power 0.11 0.5 -> 0.332 Inexact Rounded
+pwsx3020 power 0.011 0.5 -> 0.105 Inexact Rounded
+pwsx3021 power 0.12 0.5 -> 0.346 Inexact Rounded
+pwsx3022 power 0.012 0.5 -> 0.110 Inexact Rounded
+pwsx3023 power 0.13 0.5 -> 0.361 Inexact Rounded
+pwsx3024 power 0.013 0.5 -> 0.114 Inexact Rounded
+pwsx3025 power 0.14 0.5 -> 0.374 Inexact Rounded
+pwsx3026 power 0.014 0.5 -> 0.118 Inexact Rounded
+pwsx3027 power 0.15 0.5 -> 0.387 Inexact Rounded
+pwsx3028 power 0.015 0.5 -> 0.122 Inexact Rounded
+pwsx3029 power 0.16 0.5 -> 0.400 Inexact Rounded
+pwsx3030 power 0.016 0.5 -> 0.126 Inexact Rounded
+pwsx3031 power 0.17 0.5 -> 0.412 Inexact Rounded
+pwsx3032 power 0.017 0.5 -> 0.130 Inexact Rounded
+pwsx3033 power 0.18 0.5 -> 0.424 Inexact Rounded
+pwsx3034 power 0.018 0.5 -> 0.134 Inexact Rounded
+pwsx3035 power 0.19 0.5 -> 0.436 Inexact Rounded
+pwsx3036 power 0.019 0.5 -> 0.138 Inexact Rounded
+pwsx3037 power 0.21 0.5 -> 0.458 Inexact Rounded
+pwsx3038 power 0.021 0.5 -> 0.145 Inexact Rounded
+pwsx3039 power 0.22 0.5 -> 0.469 Inexact Rounded
+pwsx3040 power 0.022 0.5 -> 0.148 Inexact Rounded
+pwsx3041 power 0.23 0.5 -> 0.480 Inexact Rounded
+pwsx3042 power 0.023 0.5 -> 0.152 Inexact Rounded
+pwsx3043 power 0.24 0.5 -> 0.490 Inexact Rounded
+pwsx3044 power 0.024 0.5 -> 0.155 Inexact Rounded
+pwsx3045 power 0.25 0.5 -> 0.500 Inexact Rounded
+pwsx3046 power 0.025 0.5 -> 0.158 Inexact Rounded
+pwsx3047 power 0.26 0.5 -> 0.510 Inexact Rounded
+pwsx3048 power 0.026 0.5 -> 0.161 Inexact Rounded
+pwsx3049 power 0.27 0.5 -> 0.520 Inexact Rounded
+pwsx3050 power 0.027 0.5 -> 0.164 Inexact Rounded
+pwsx3051 power 0.28 0.5 -> 0.529 Inexact Rounded
+pwsx3052 power 0.028 0.5 -> 0.167 Inexact Rounded
+pwsx3053 power 0.29 0.5 -> 0.539 Inexact Rounded
+pwsx3054 power 0.029 0.5 -> 0.170 Inexact Rounded
+pwsx3055 power 0.31 0.5 -> 0.557 Inexact Rounded
+pwsx3056 power 0.031 0.5 -> 0.176 Inexact Rounded
+pwsx3057 power 0.32 0.5 -> 0.566 Inexact Rounded
+pwsx3058 power 0.032 0.5 -> 0.179 Inexact Rounded
+pwsx3059 power 0.33 0.5 -> 0.574 Inexact Rounded
+pwsx3060 power 0.033 0.5 -> 0.182 Inexact Rounded
+pwsx3061 power 0.34 0.5 -> 0.583 Inexact Rounded
+pwsx3062 power 0.034 0.5 -> 0.184 Inexact Rounded
+pwsx3063 power 0.35 0.5 -> 0.592 Inexact Rounded
+pwsx3064 power 0.035 0.5 -> 0.187 Inexact Rounded
+pwsx3065 power 0.36 0.5 -> 0.600 Inexact Rounded
+pwsx3066 power 0.036 0.5 -> 0.190 Inexact Rounded
+pwsx3067 power 0.37 0.5 -> 0.608 Inexact Rounded
+pwsx3068 power 0.037 0.5 -> 0.192 Inexact Rounded
+pwsx3069 power 0.38 0.5 -> 0.616 Inexact Rounded
+pwsx3070 power 0.038 0.5 -> 0.195 Inexact Rounded
+pwsx3071 power 0.39 0.5 -> 0.624 Inexact Rounded
+pwsx3072 power 0.039 0.5 -> 0.197 Inexact Rounded
+pwsx3073 power 0.41 0.5 -> 0.640 Inexact Rounded
+pwsx3074 power 0.041 0.5 -> 0.202 Inexact Rounded
+pwsx3075 power 0.42 0.5 -> 0.648 Inexact Rounded
+pwsx3076 power 0.042 0.5 -> 0.205 Inexact Rounded
+pwsx3077 power 0.43 0.5 -> 0.656 Inexact Rounded
+pwsx3078 power 0.043 0.5 -> 0.207 Inexact Rounded
+pwsx3079 power 0.44 0.5 -> 0.663 Inexact Rounded
+pwsx3080 power 0.044 0.5 -> 0.210 Inexact Rounded
+pwsx3081 power 0.45 0.5 -> 0.671 Inexact Rounded
+pwsx3082 power 0.045 0.5 -> 0.212 Inexact Rounded
+pwsx3083 power 0.46 0.5 -> 0.678 Inexact Rounded
+pwsx3084 power 0.046 0.5 -> 0.214 Inexact Rounded
+pwsx3085 power 0.47 0.5 -> 0.686 Inexact Rounded
+pwsx3086 power 0.047 0.5 -> 0.217 Inexact Rounded
+pwsx3087 power 0.48 0.5 -> 0.693 Inexact Rounded
+pwsx3088 power 0.048 0.5 -> 0.219 Inexact Rounded
+pwsx3089 power 0.49 0.5 -> 0.700 Inexact Rounded
+pwsx3090 power 0.049 0.5 -> 0.221 Inexact Rounded
+pwsx3091 power 0.51 0.5 -> 0.714 Inexact Rounded
+pwsx3092 power 0.051 0.5 -> 0.226 Inexact Rounded
+pwsx3093 power 0.52 0.5 -> 0.721 Inexact Rounded
+pwsx3094 power 0.052 0.5 -> 0.228 Inexact Rounded
+pwsx3095 power 0.53 0.5 -> 0.728 Inexact Rounded
+pwsx3096 power 0.053 0.5 -> 0.230 Inexact Rounded
+pwsx3097 power 0.54 0.5 -> 0.735 Inexact Rounded
+pwsx3098 power 0.054 0.5 -> 0.232 Inexact Rounded
+pwsx3099 power 0.55 0.5 -> 0.742 Inexact Rounded
+pwsx3100 power 0.055 0.5 -> 0.235 Inexact Rounded
+pwsx3101 power 0.56 0.5 -> 0.748 Inexact Rounded
+pwsx3102 power 0.056 0.5 -> 0.237 Inexact Rounded
+pwsx3103 power 0.57 0.5 -> 0.755 Inexact Rounded
+pwsx3104 power 0.057 0.5 -> 0.239 Inexact Rounded
+pwsx3105 power 0.58 0.5 -> 0.762 Inexact Rounded
+pwsx3106 power 0.058 0.5 -> 0.241 Inexact Rounded
+pwsx3107 power 0.59 0.5 -> 0.768 Inexact Rounded
+pwsx3108 power 0.059 0.5 -> 0.243 Inexact Rounded
+pwsx3109 power 0.61 0.5 -> 0.781 Inexact Rounded
+pwsx3110 power 0.061 0.5 -> 0.247 Inexact Rounded
+pwsx3111 power 0.62 0.5 -> 0.787 Inexact Rounded
+pwsx3112 power 0.062 0.5 -> 0.249 Inexact Rounded
+pwsx3113 power 0.63 0.5 -> 0.794 Inexact Rounded
+pwsx3114 power 0.063 0.5 -> 0.251 Inexact Rounded
+pwsx3115 power 0.64 0.5 -> 0.800 Inexact Rounded
+pwsx3116 power 0.064 0.5 -> 0.253 Inexact Rounded
+pwsx3117 power 0.65 0.5 -> 0.806 Inexact Rounded
+pwsx3118 power 0.065 0.5 -> 0.255 Inexact Rounded
+pwsx3119 power 0.66 0.5 -> 0.812 Inexact Rounded
+pwsx3120 power 0.066 0.5 -> 0.257 Inexact Rounded
+pwsx3121 power 0.67 0.5 -> 0.819 Inexact Rounded
+pwsx3122 power 0.067 0.5 -> 0.259 Inexact Rounded
+pwsx3123 power 0.68 0.5 -> 0.825 Inexact Rounded
+pwsx3124 power 0.068 0.5 -> 0.261 Inexact Rounded
+pwsx3125 power 0.69 0.5 -> 0.831 Inexact Rounded
+pwsx3126 power 0.069 0.5 -> 0.263 Inexact Rounded
+pwsx3127 power 0.71 0.5 -> 0.843 Inexact Rounded
+pwsx3128 power 0.071 0.5 -> 0.266 Inexact Rounded
+pwsx3129 power 0.72 0.5 -> 0.849 Inexact Rounded
+pwsx3130 power 0.072 0.5 -> 0.268 Inexact Rounded
+pwsx3131 power 0.73 0.5 -> 0.854 Inexact Rounded
+pwsx3132 power 0.073 0.5 -> 0.270 Inexact Rounded
+pwsx3133 power 0.74 0.5 -> 0.860 Inexact Rounded
+pwsx3134 power 0.074 0.5 -> 0.272 Inexact Rounded
+pwsx3135 power 0.75 0.5 -> 0.866 Inexact Rounded
+pwsx3136 power 0.075 0.5 -> 0.274 Inexact Rounded
+pwsx3137 power 0.76 0.5 -> 0.872 Inexact Rounded
+pwsx3138 power 0.076 0.5 -> 0.276 Inexact Rounded
+pwsx3139 power 0.77 0.5 -> 0.877 Inexact Rounded
+pwsx3140 power 0.077 0.5 -> 0.277 Inexact Rounded
+pwsx3141 power 0.78 0.5 -> 0.883 Inexact Rounded
+pwsx3142 power 0.078 0.5 -> 0.279 Inexact Rounded
+pwsx3143 power 0.79 0.5 -> 0.889 Inexact Rounded
+pwsx3144 power 0.079 0.5 -> 0.281 Inexact Rounded
+pwsx3145 power 0.81 0.5 -> 0.900 Inexact Rounded
+pwsx3146 power 0.081 0.5 -> 0.285 Inexact Rounded
+pwsx3147 power 0.82 0.5 -> 0.906 Inexact Rounded
+pwsx3148 power 0.082 0.5 -> 0.286 Inexact Rounded
+pwsx3149 power 0.83 0.5 -> 0.911 Inexact Rounded
+pwsx3150 power 0.083 0.5 -> 0.288 Inexact Rounded
+pwsx3151 power 0.84 0.5 -> 0.917 Inexact Rounded
+pwsx3152 power 0.084 0.5 -> 0.290 Inexact Rounded
+pwsx3153 power 0.85 0.5 -> 0.922 Inexact Rounded
+pwsx3154 power 0.085 0.5 -> 0.292 Inexact Rounded
+pwsx3155 power 0.86 0.5 -> 0.927 Inexact Rounded
+pwsx3156 power 0.086 0.5 -> 0.293 Inexact Rounded
+pwsx3157 power 0.87 0.5 -> 0.933 Inexact Rounded
+pwsx3158 power 0.087 0.5 -> 0.295 Inexact Rounded
+pwsx3159 power 0.88 0.5 -> 0.938 Inexact Rounded
+pwsx3160 power 0.088 0.5 -> 0.297 Inexact Rounded
+pwsx3161 power 0.89 0.5 -> 0.943 Inexact Rounded
+pwsx3162 power 0.089 0.5 -> 0.298 Inexact Rounded
+pwsx3163 power 0.91 0.5 -> 0.954 Inexact Rounded
+pwsx3164 power 0.091 0.5 -> 0.302 Inexact Rounded
+pwsx3165 power 0.92 0.5 -> 0.959 Inexact Rounded
+pwsx3166 power 0.092 0.5 -> 0.303 Inexact Rounded
+pwsx3167 power 0.93 0.5 -> 0.964 Inexact Rounded
+pwsx3168 power 0.093 0.5 -> 0.305 Inexact Rounded
+pwsx3169 power 0.94 0.5 -> 0.970 Inexact Rounded
+pwsx3170 power 0.094 0.5 -> 0.307 Inexact Rounded
+pwsx3171 power 0.95 0.5 -> 0.975 Inexact Rounded
+pwsx3172 power 0.095 0.5 -> 0.308 Inexact Rounded
+pwsx3173 power 0.96 0.5 -> 0.980 Inexact Rounded
+pwsx3174 power 0.096 0.5 -> 0.310 Inexact Rounded
+pwsx3175 power 0.97 0.5 -> 0.985 Inexact Rounded
+pwsx3176 power 0.097 0.5 -> 0.311 Inexact Rounded
+pwsx3177 power 0.98 0.5 -> 0.990 Inexact Rounded
+pwsx3178 power 0.098 0.5 -> 0.313 Inexact Rounded
+pwsx3179 power 0.99 0.5 -> 0.995 Inexact Rounded
+pwsx3180 power 0.099 0.5 -> 0.315 Inexact Rounded
+pwsx3181 power 0.101 0.5 -> 0.318 Inexact Rounded
+pwsx3182 power 0.0101 0.5 -> 0.100 Inexact Rounded
+pwsx3183 power 0.102 0.5 -> 0.319 Inexact Rounded
+pwsx3184 power 0.0102 0.5 -> 0.101 Inexact Rounded
+pwsx3185 power 0.103 0.5 -> 0.321 Inexact Rounded
+pwsx3186 power 0.0103 0.5 -> 0.101 Inexact Rounded
+pwsx3187 power 0.104 0.5 -> 0.322 Inexact Rounded
+pwsx3188 power 0.0104 0.5 -> 0.102 Inexact Rounded
+pwsx3189 power 0.105 0.5 -> 0.324 Inexact Rounded
+pwsx3190 power 0.0105 0.5 -> 0.102 Inexact Rounded
+pwsx3191 power 0.106 0.5 -> 0.326 Inexact Rounded
+pwsx3192 power 0.0106 0.5 -> 0.103 Inexact Rounded
+pwsx3193 power 0.107 0.5 -> 0.327 Inexact Rounded
+pwsx3194 power 0.0107 0.5 -> 0.103 Inexact Rounded
+pwsx3195 power 0.108 0.5 -> 0.329 Inexact Rounded
+pwsx3196 power 0.0108 0.5 -> 0.104 Inexact Rounded
+pwsx3197 power 0.109 0.5 -> 0.330 Inexact Rounded
+pwsx3198 power 0.0109 0.5 -> 0.104 Inexact Rounded
+pwsx3199 power 0.111 0.5 -> 0.333 Inexact Rounded
+pwsx3200 power 0.0111 0.5 -> 0.105 Inexact Rounded
+pwsx3201 power 0.112 0.5 -> 0.335 Inexact Rounded
+pwsx3202 power 0.0112 0.5 -> 0.106 Inexact Rounded
+pwsx3203 power 0.113 0.5 -> 0.336 Inexact Rounded
+pwsx3204 power 0.0113 0.5 -> 0.106 Inexact Rounded
+pwsx3205 power 0.114 0.5 -> 0.338 Inexact Rounded
+pwsx3206 power 0.0114 0.5 -> 0.107 Inexact Rounded
+pwsx3207 power 0.115 0.5 -> 0.339 Inexact Rounded
+pwsx3208 power 0.0115 0.5 -> 0.107 Inexact Rounded
+pwsx3209 power 0.116 0.5 -> 0.341 Inexact Rounded
+pwsx3210 power 0.0116 0.5 -> 0.108 Inexact Rounded
+pwsx3211 power 0.117 0.5 -> 0.342 Inexact Rounded
+pwsx3212 power 0.0117 0.5 -> 0.108 Inexact Rounded
+pwsx3213 power 0.118 0.5 -> 0.344 Inexact Rounded
+pwsx3214 power 0.0118 0.5 -> 0.109 Inexact Rounded
+pwsx3215 power 0.119 0.5 -> 0.345 Inexact Rounded
+pwsx3216 power 0.0119 0.5 -> 0.109 Inexact Rounded
+pwsx3217 power 0.121 0.5 -> 0.348 Inexact Rounded
+pwsx3218 power 0.0121 0.5 -> 0.110 Inexact Rounded
+pwsx3219 power 0.122 0.5 -> 0.349 Inexact Rounded
+pwsx3220 power 0.0122 0.5 -> 0.110 Inexact Rounded
+pwsx3221 power 0.123 0.5 -> 0.351 Inexact Rounded
+pwsx3222 power 0.0123 0.5 -> 0.111 Inexact Rounded
+pwsx3223 power 0.124 0.5 -> 0.352 Inexact Rounded
+pwsx3224 power 0.0124 0.5 -> 0.111 Inexact Rounded
+pwsx3225 power 0.125 0.5 -> 0.354 Inexact Rounded
+pwsx3226 power 0.0125 0.5 -> 0.112 Inexact Rounded
+pwsx3227 power 0.126 0.5 -> 0.355 Inexact Rounded
+pwsx3228 power 0.0126 0.5 -> 0.112 Inexact Rounded
+pwsx3229 power 0.127 0.5 -> 0.356 Inexact Rounded
+pwsx3230 power 0.0127 0.5 -> 0.113 Inexact Rounded
+pwsx3231 power 0.128 0.5 -> 0.358 Inexact Rounded
+pwsx3232 power 0.0128 0.5 -> 0.113 Inexact Rounded
+pwsx3233 power 0.129 0.5 -> 0.359 Inexact Rounded
+pwsx3234 power 0.0129 0.5 -> 0.114 Inexact Rounded
+pwsx3235 power 0.131 0.5 -> 0.362 Inexact Rounded
+pwsx3236 power 0.0131 0.5 -> 0.114 Inexact Rounded
+pwsx3237 power 0.132 0.5 -> 0.363 Inexact Rounded
+pwsx3238 power 0.0132 0.5 -> 0.115 Inexact Rounded
+pwsx3239 power 0.133 0.5 -> 0.365 Inexact Rounded
+pwsx3240 power 0.0133 0.5 -> 0.115 Inexact Rounded
+pwsx3241 power 0.134 0.5 -> 0.366 Inexact Rounded
+pwsx3242 power 0.0134 0.5 -> 0.116 Inexact Rounded
+pwsx3243 power 0.135 0.5 -> 0.367 Inexact Rounded
+pwsx3244 power 0.0135 0.5 -> 0.116 Inexact Rounded
+pwsx3245 power 0.136 0.5 -> 0.369 Inexact Rounded
+pwsx3246 power 0.0136 0.5 -> 0.117 Inexact Rounded
+pwsx3247 power 0.137 0.5 -> 0.370 Inexact Rounded
+pwsx3248 power 0.0137 0.5 -> 0.117 Inexact Rounded
+pwsx3249 power 0.138 0.5 -> 0.371 Inexact Rounded
+pwsx3250 power 0.0138 0.5 -> 0.117 Inexact Rounded
+pwsx3251 power 0.139 0.5 -> 0.373 Inexact Rounded
+pwsx3252 power 0.0139 0.5 -> 0.118 Inexact Rounded
+pwsx3253 power 0.141 0.5 -> 0.375 Inexact Rounded
+pwsx3254 power 0.0141 0.5 -> 0.119 Inexact Rounded
+pwsx3255 power 0.142 0.5 -> 0.377 Inexact Rounded
+pwsx3256 power 0.0142 0.5 -> 0.119 Inexact Rounded
+pwsx3257 power 0.143 0.5 -> 0.378 Inexact Rounded
+pwsx3258 power 0.0143 0.5 -> 0.120 Inexact Rounded
+pwsx3259 power 0.144 0.5 -> 0.379 Inexact Rounded
+pwsx3260 power 0.0144 0.5 -> 0.120 Inexact Rounded
+pwsx3261 power 0.145 0.5 -> 0.381 Inexact Rounded
+pwsx3262 power 0.0145 0.5 -> 0.120 Inexact Rounded
+pwsx3263 power 0.146 0.5 -> 0.382 Inexact Rounded
+pwsx3264 power 0.0146 0.5 -> 0.121 Inexact Rounded
+pwsx3265 power 0.147 0.5 -> 0.383 Inexact Rounded
+pwsx3266 power 0.0147 0.5 -> 0.121 Inexact Rounded
+pwsx3267 power 0.148 0.5 -> 0.385 Inexact Rounded
+pwsx3268 power 0.0148 0.5 -> 0.122 Inexact Rounded
+pwsx3269 power 0.149 0.5 -> 0.386 Inexact Rounded
+pwsx3270 power 0.0149 0.5 -> 0.122 Inexact Rounded
+pwsx3271 power 0.151 0.5 -> 0.389 Inexact Rounded
+pwsx3272 power 0.0151 0.5 -> 0.123 Inexact Rounded
+pwsx3273 power 0.152 0.5 -> 0.390 Inexact Rounded
+pwsx3274 power 0.0152 0.5 -> 0.123 Inexact Rounded
+pwsx3275 power 0.153 0.5 -> 0.391 Inexact Rounded
+pwsx3276 power 0.0153 0.5 -> 0.124 Inexact Rounded
+pwsx3277 power 0.154 0.5 -> 0.392 Inexact Rounded
+pwsx3278 power 0.0154 0.5 -> 0.124 Inexact Rounded
+pwsx3279 power 0.155 0.5 -> 0.394 Inexact Rounded
+pwsx3280 power 0.0155 0.5 -> 0.124 Inexact Rounded
+pwsx3281 power 0.156 0.5 -> 0.395 Inexact Rounded
+pwsx3282 power 0.0156 0.5 -> 0.125 Inexact Rounded
+pwsx3283 power 0.157 0.5 -> 0.396 Inexact Rounded
+pwsx3284 power 0.0157 0.5 -> 0.125 Inexact Rounded
+pwsx3285 power 0.158 0.5 -> 0.397 Inexact Rounded
+pwsx3286 power 0.0158 0.5 -> 0.126 Inexact Rounded
+pwsx3287 power 0.159 0.5 -> 0.399 Inexact Rounded
+pwsx3288 power 0.0159 0.5 -> 0.126 Inexact Rounded
+pwsx3289 power 0.161 0.5 -> 0.401 Inexact Rounded
+pwsx3290 power 0.0161 0.5 -> 0.127 Inexact Rounded
+pwsx3291 power 0.162 0.5 -> 0.402 Inexact Rounded
+pwsx3292 power 0.0162 0.5 -> 0.127 Inexact Rounded
+pwsx3293 power 0.163 0.5 -> 0.404 Inexact Rounded
+pwsx3294 power 0.0163 0.5 -> 0.128 Inexact Rounded
+pwsx3295 power 0.164 0.5 -> 0.405 Inexact Rounded
+pwsx3296 power 0.0164 0.5 -> 0.128 Inexact Rounded
+pwsx3297 power 0.165 0.5 -> 0.406 Inexact Rounded
+pwsx3298 power 0.0165 0.5 -> 0.128 Inexact Rounded
+pwsx3299 power 0.166 0.5 -> 0.407 Inexact Rounded
+pwsx3300 power 0.0166 0.5 -> 0.129 Inexact Rounded
+pwsx3301 power 0.167 0.5 -> 0.409 Inexact Rounded
+pwsx3302 power 0.0167 0.5 -> 0.129 Inexact Rounded
+pwsx3303 power 0.168 0.5 -> 0.410 Inexact Rounded
+pwsx3304 power 0.0168 0.5 -> 0.130 Inexact Rounded
+pwsx3305 power 0.169 0.5 -> 0.411 Inexact Rounded
+pwsx3306 power 0.0169 0.5 -> 0.130 Inexact Rounded
+pwsx3307 power 0.171 0.5 -> 0.414 Inexact Rounded
+pwsx3308 power 0.0171 0.5 -> 0.131 Inexact Rounded
+pwsx3309 power 0.172 0.5 -> 0.415 Inexact Rounded
+pwsx3310 power 0.0172 0.5 -> 0.131 Inexact Rounded
+pwsx3311 power 0.173 0.5 -> 0.416 Inexact Rounded
+pwsx3312 power 0.0173 0.5 -> 0.132 Inexact Rounded
+pwsx3313 power 0.174 0.5 -> 0.417 Inexact Rounded
+pwsx3314 power 0.0174 0.5 -> 0.132 Inexact Rounded
+pwsx3315 power 0.175 0.5 -> 0.418 Inexact Rounded
+pwsx3316 power 0.0175 0.5 -> 0.132 Inexact Rounded
+pwsx3317 power 0.176 0.5 -> 0.420 Inexact Rounded
+pwsx3318 power 0.0176 0.5 -> 0.133 Inexact Rounded
+pwsx3319 power 0.177 0.5 -> 0.421 Inexact Rounded
+pwsx3320 power 0.0177 0.5 -> 0.133 Inexact Rounded
+pwsx3321 power 0.178 0.5 -> 0.422 Inexact Rounded
+pwsx3322 power 0.0178 0.5 -> 0.133 Inexact Rounded
+pwsx3323 power 0.179 0.5 -> 0.423 Inexact Rounded
+pwsx3324 power 0.0179 0.5 -> 0.134 Inexact Rounded
+pwsx3325 power 0.181 0.5 -> 0.425 Inexact Rounded
+pwsx3326 power 0.0181 0.5 -> 0.135 Inexact Rounded
+pwsx3327 power 0.182 0.5 -> 0.427 Inexact Rounded
+pwsx3328 power 0.0182 0.5 -> 0.135 Inexact Rounded
+pwsx3329 power 0.183 0.5 -> 0.428 Inexact Rounded
+pwsx3330 power 0.0183 0.5 -> 0.135 Inexact Rounded
+pwsx3331 power 0.184 0.5 -> 0.429 Inexact Rounded
+pwsx3332 power 0.0184 0.5 -> 0.136 Inexact Rounded
+pwsx3333 power 0.185 0.5 -> 0.430 Inexact Rounded
+pwsx3334 power 0.0185 0.5 -> 0.136 Inexact Rounded
+pwsx3335 power 0.186 0.5 -> 0.431 Inexact Rounded
+pwsx3336 power 0.0186 0.5 -> 0.136 Inexact Rounded
+pwsx3337 power 0.187 0.5 -> 0.432 Inexact Rounded
+pwsx3338 power 0.0187 0.5 -> 0.137 Inexact Rounded
+pwsx3339 power 0.188 0.5 -> 0.434 Inexact Rounded
+pwsx3340 power 0.0188 0.5 -> 0.137 Inexact Rounded
+pwsx3341 power 0.189 0.5 -> 0.435 Inexact Rounded
+pwsx3342 power 0.0189 0.5 -> 0.137 Inexact Rounded
+pwsx3343 power 0.191 0.5 -> 0.437 Inexact Rounded
+pwsx3344 power 0.0191 0.5 -> 0.138 Inexact Rounded
+pwsx3345 power 0.192 0.5 -> 0.438 Inexact Rounded
+pwsx3346 power 0.0192 0.5 -> 0.139 Inexact Rounded
+pwsx3347 power 0.193 0.5 -> 0.439 Inexact Rounded
+pwsx3348 power 0.0193 0.5 -> 0.139 Inexact Rounded
+pwsx3349 power 0.194 0.5 -> 0.440 Inexact Rounded
+pwsx3350 power 0.0194 0.5 -> 0.139 Inexact Rounded
+pwsx3351 power 0.195 0.5 -> 0.442 Inexact Rounded
+pwsx3352 power 0.0195 0.5 -> 0.140 Inexact Rounded
+pwsx3353 power 0.196 0.5 -> 0.443 Inexact Rounded
+pwsx3354 power 0.0196 0.5 -> 0.140 Inexact Rounded
+pwsx3355 power 0.197 0.5 -> 0.444 Inexact Rounded
+pwsx3356 power 0.0197 0.5 -> 0.140 Inexact Rounded
+pwsx3357 power 0.198 0.5 -> 0.445 Inexact Rounded
+pwsx3358 power 0.0198 0.5 -> 0.141 Inexact Rounded
+pwsx3359 power 0.199 0.5 -> 0.446 Inexact Rounded
+pwsx3360 power 0.0199 0.5 -> 0.141 Inexact Rounded
+pwsx3361 power 0.201 0.5 -> 0.448 Inexact Rounded
+pwsx3362 power 0.0201 0.5 -> 0.142 Inexact Rounded
+pwsx3363 power 0.202 0.5 -> 0.449 Inexact Rounded
+pwsx3364 power 0.0202 0.5 -> 0.142 Inexact Rounded
+pwsx3365 power 0.203 0.5 -> 0.451 Inexact Rounded
+pwsx3366 power 0.0203 0.5 -> 0.142 Inexact Rounded
+pwsx3367 power 0.204 0.5 -> 0.452 Inexact Rounded
+pwsx3368 power 0.0204 0.5 -> 0.143 Inexact Rounded
+pwsx3369 power 0.205 0.5 -> 0.453 Inexact Rounded
+pwsx3370 power 0.0205 0.5 -> 0.143 Inexact Rounded
+pwsx3371 power 0.206 0.5 -> 0.454 Inexact Rounded
+pwsx3372 power 0.0206 0.5 -> 0.144 Inexact Rounded
+pwsx3373 power 0.207 0.5 -> 0.455 Inexact Rounded
+pwsx3374 power 0.0207 0.5 -> 0.144 Inexact Rounded
+pwsx3375 power 0.208 0.5 -> 0.456 Inexact Rounded
+pwsx3376 power 0.0208 0.5 -> 0.144 Inexact Rounded
+pwsx3377 power 0.209 0.5 -> 0.457 Inexact Rounded
+pwsx3378 power 0.0209 0.5 -> 0.145 Inexact Rounded
+pwsx3379 power 0.211 0.5 -> 0.459 Inexact Rounded
+pwsx3380 power 0.0211 0.5 -> 0.145 Inexact Rounded
+pwsx3381 power 0.212 0.5 -> 0.460 Inexact Rounded
+pwsx3382 power 0.0212 0.5 -> 0.146 Inexact Rounded
+pwsx3383 power 0.213 0.5 -> 0.462 Inexact Rounded
+pwsx3384 power 0.0213 0.5 -> 0.146 Inexact Rounded
+pwsx3385 power 0.214 0.5 -> 0.463 Inexact Rounded
+pwsx3386 power 0.0214 0.5 -> 0.146 Inexact Rounded
+pwsx3387 power 0.215 0.5 -> 0.464 Inexact Rounded
+pwsx3388 power 0.0215 0.5 -> 0.147 Inexact Rounded
+pwsx3389 power 0.216 0.5 -> 0.465 Inexact Rounded
+pwsx3390 power 0.0216 0.5 -> 0.147 Inexact Rounded
+pwsx3391 power 0.217 0.5 -> 0.466 Inexact Rounded
+pwsx3392 power 0.0217 0.5 -> 0.147 Inexact Rounded
+pwsx3393 power 0.218 0.5 -> 0.467 Inexact Rounded
+pwsx3394 power 0.0218 0.5 -> 0.148 Inexact Rounded
+pwsx3395 power 0.219 0.5 -> 0.468 Inexact Rounded
+pwsx3396 power 0.0219 0.5 -> 0.148 Inexact Rounded
+pwsx3397 power 0.221 0.5 -> 0.470 Inexact Rounded
+pwsx3398 power 0.0221 0.5 -> 0.149 Inexact Rounded
+pwsx3399 power 0.222 0.5 -> 0.471 Inexact Rounded
+pwsx3400 power 0.0222 0.5 -> 0.149 Inexact Rounded
+pwsx3401 power 0.223 0.5 -> 0.472 Inexact Rounded
+pwsx3402 power 0.0223 0.5 -> 0.149 Inexact Rounded
+pwsx3403 power 0.224 0.5 -> 0.473 Inexact Rounded
+pwsx3404 power 0.0224 0.5 -> 0.150 Inexact Rounded
+pwsx3405 power 0.225 0.5 -> 0.474 Inexact Rounded
+pwsx3406 power 0.0225 0.5 -> 0.150 Inexact Rounded
+pwsx3407 power 0.226 0.5 -> 0.475 Inexact Rounded
+pwsx3408 power 0.0226 0.5 -> 0.150 Inexact Rounded
+pwsx3409 power 0.227 0.5 -> 0.476 Inexact Rounded
+pwsx3410 power 0.0227 0.5 -> 0.151 Inexact Rounded
+pwsx3411 power 0.228 0.5 -> 0.477 Inexact Rounded
+pwsx3412 power 0.0228 0.5 -> 0.151 Inexact Rounded
+pwsx3413 power 0.229 0.5 -> 0.479 Inexact Rounded
+pwsx3414 power 0.0229 0.5 -> 0.151 Inexact Rounded
+pwsx3415 power 0.231 0.5 -> 0.481 Inexact Rounded
+pwsx3416 power 0.0231 0.5 -> 0.152 Inexact Rounded
+pwsx3417 power 0.232 0.5 -> 0.482 Inexact Rounded
+pwsx3418 power 0.0232 0.5 -> 0.152 Inexact Rounded
+pwsx3419 power 0.233 0.5 -> 0.483 Inexact Rounded
+pwsx3420 power 0.0233 0.5 -> 0.153 Inexact Rounded
+pwsx3421 power 0.234 0.5 -> 0.484 Inexact Rounded
+pwsx3422 power 0.0234 0.5 -> 0.153 Inexact Rounded
+pwsx3423 power 0.235 0.5 -> 0.485 Inexact Rounded
+pwsx3424 power 0.0235 0.5 -> 0.153 Inexact Rounded
+pwsx3425 power 0.236 0.5 -> 0.486 Inexact Rounded
+pwsx3426 power 0.0236 0.5 -> 0.154 Inexact Rounded
+pwsx3427 power 0.237 0.5 -> 0.487 Inexact Rounded
+pwsx3428 power 0.0237 0.5 -> 0.154 Inexact Rounded
+pwsx3429 power 0.238 0.5 -> 0.488 Inexact Rounded
+pwsx3430 power 0.0238 0.5 -> 0.154 Inexact Rounded
+pwsx3431 power 0.239 0.5 -> 0.489 Inexact Rounded
+pwsx3432 power 0.0239 0.5 -> 0.155 Inexact Rounded
+pwsx3433 power 0.241 0.5 -> 0.491 Inexact Rounded
+pwsx3434 power 0.0241 0.5 -> 0.155 Inexact Rounded
+pwsx3435 power 0.242 0.5 -> 0.492 Inexact Rounded
+pwsx3436 power 0.0242 0.5 -> 0.156 Inexact Rounded
+pwsx3437 power 0.243 0.5 -> 0.493 Inexact Rounded
+pwsx3438 power 0.0243 0.5 -> 0.156 Inexact Rounded
+pwsx3439 power 0.244 0.5 -> 0.494 Inexact Rounded
+pwsx3440 power 0.0244 0.5 -> 0.156 Inexact Rounded
+pwsx3441 power 0.245 0.5 -> 0.495 Inexact Rounded
+pwsx3442 power 0.0245 0.5 -> 0.157 Inexact Rounded
+pwsx3443 power 0.246 0.5 -> 0.496 Inexact Rounded
+pwsx3444 power 0.0246 0.5 -> 0.157 Inexact Rounded
+pwsx3445 power 0.247 0.5 -> 0.497 Inexact Rounded
+pwsx3446 power 0.0247 0.5 -> 0.157 Inexact Rounded
+pwsx3447 power 0.248 0.5 -> 0.498 Inexact Rounded
+pwsx3448 power 0.0248 0.5 -> 0.157 Inexact Rounded
+pwsx3449 power 0.249 0.5 -> 0.499 Inexact Rounded
+pwsx3450 power 0.0249 0.5 -> 0.158 Inexact Rounded
+pwsx3451 power 0.251 0.5 -> 0.501 Inexact Rounded
+pwsx3452 power 0.0251 0.5 -> 0.158 Inexact Rounded
+pwsx3453 power 0.252 0.5 -> 0.502 Inexact Rounded
+pwsx3454 power 0.0252 0.5 -> 0.159 Inexact Rounded
+pwsx3455 power 0.253 0.5 -> 0.503 Inexact Rounded
+pwsx3456 power 0.0253 0.5 -> 0.159 Inexact Rounded
+pwsx3457 power 0.254 0.5 -> 0.504 Inexact Rounded
+pwsx3458 power 0.0254 0.5 -> 0.159 Inexact Rounded
+pwsx3459 power 0.255 0.5 -> 0.505 Inexact Rounded
+pwsx3460 power 0.0255 0.5 -> 0.160 Inexact Rounded
+pwsx3461 power 0.256 0.5 -> 0.506 Inexact Rounded
+pwsx3462 power 0.0256 0.5 -> 0.160 Inexact Rounded
+pwsx3463 power 0.257 0.5 -> 0.507 Inexact Rounded
+pwsx3464 power 0.0257 0.5 -> 0.160 Inexact Rounded
+pwsx3465 power 0.258 0.5 -> 0.508 Inexact Rounded
+pwsx3466 power 0.0258 0.5 -> 0.161 Inexact Rounded
+pwsx3467 power 0.259 0.5 -> 0.509 Inexact Rounded
+pwsx3468 power 0.0259 0.5 -> 0.161 Inexact Rounded
+pwsx3469 power 0.261 0.5 -> 0.511 Inexact Rounded
+pwsx3470 power 0.0261 0.5 -> 0.162 Inexact Rounded
+pwsx3471 power 0.262 0.5 -> 0.512 Inexact Rounded
+pwsx3472 power 0.0262 0.5 -> 0.162 Inexact Rounded
+pwsx3473 power 0.263 0.5 -> 0.513 Inexact Rounded
+pwsx3474 power 0.0263 0.5 -> 0.162 Inexact Rounded
+pwsx3475 power 0.264 0.5 -> 0.514 Inexact Rounded
+pwsx3476 power 0.0264 0.5 -> 0.162 Inexact Rounded
+pwsx3477 power 0.265 0.5 -> 0.515 Inexact Rounded
+pwsx3478 power 0.0265 0.5 -> 0.163 Inexact Rounded
+pwsx3479 power 0.266 0.5 -> 0.516 Inexact Rounded
+pwsx3480 power 0.0266 0.5 -> 0.163 Inexact Rounded
+pwsx3481 power 0.267 0.5 -> 0.517 Inexact Rounded
+pwsx3482 power 0.0267 0.5 -> 0.163 Inexact Rounded
+pwsx3483 power 0.268 0.5 -> 0.518 Inexact Rounded
+pwsx3484 power 0.0268 0.5 -> 0.164 Inexact Rounded
+pwsx3485 power 0.269 0.5 -> 0.519 Inexact Rounded
+pwsx3486 power 0.0269 0.5 -> 0.164 Inexact Rounded
+pwsx3487 power 0.271 0.5 -> 0.521 Inexact Rounded
+pwsx3488 power 0.0271 0.5 -> 0.165 Inexact Rounded
+pwsx3489 power 0.272 0.5 -> 0.522 Inexact Rounded
+pwsx3490 power 0.0272 0.5 -> 0.165 Inexact Rounded
+pwsx3491 power 0.273 0.5 -> 0.522 Inexact Rounded
+pwsx3492 power 0.0273 0.5 -> 0.165 Inexact Rounded
+pwsx3493 power 0.274 0.5 -> 0.523 Inexact Rounded
+pwsx3494 power 0.0274 0.5 -> 0.166 Inexact Rounded
+pwsx3495 power 0.275 0.5 -> 0.524 Inexact Rounded
+pwsx3496 power 0.0275 0.5 -> 0.166 Inexact Rounded
+pwsx3497 power 0.276 0.5 -> 0.525 Inexact Rounded
+pwsx3498 power 0.0276 0.5 -> 0.166 Inexact Rounded
+pwsx3499 power 0.277 0.5 -> 0.526 Inexact Rounded
+pwsx3500 power 0.0277 0.5 -> 0.166 Inexact Rounded
+pwsx3501 power 0.278 0.5 -> 0.527 Inexact Rounded
+pwsx3502 power 0.0278 0.5 -> 0.167 Inexact Rounded
+pwsx3503 power 0.279 0.5 -> 0.528 Inexact Rounded
+pwsx3504 power 0.0279 0.5 -> 0.167 Inexact Rounded
+pwsx3505 power 0.281 0.5 -> 0.530 Inexact Rounded
+pwsx3506 power 0.0281 0.5 -> 0.168 Inexact Rounded
+pwsx3507 power 0.282 0.5 -> 0.531 Inexact Rounded
+pwsx3508 power 0.0282 0.5 -> 0.168 Inexact Rounded
+pwsx3509 power 0.283 0.5 -> 0.532 Inexact Rounded
+pwsx3510 power 0.0283 0.5 -> 0.168 Inexact Rounded
+pwsx3511 power 0.284 0.5 -> 0.533 Inexact Rounded
+pwsx3512 power 0.0284 0.5 -> 0.169 Inexact Rounded
+pwsx3513 power 0.285 0.5 -> 0.534 Inexact Rounded
+pwsx3514 power 0.0285 0.5 -> 0.169 Inexact Rounded
+pwsx3515 power 0.286 0.5 -> 0.535 Inexact Rounded
+pwsx3516 power 0.0286 0.5 -> 0.169 Inexact Rounded
+pwsx3517 power 0.287 0.5 -> 0.536 Inexact Rounded
+pwsx3518 power 0.0287 0.5 -> 0.169 Inexact Rounded
+pwsx3519 power 0.288 0.5 -> 0.537 Inexact Rounded
+pwsx3520 power 0.0288 0.5 -> 0.170 Inexact Rounded
+pwsx3521 power 0.289 0.5 -> 0.538 Inexact Rounded
+pwsx3522 power 0.0289 0.5 -> 0.170 Inexact Rounded
+pwsx3523 power 0.291 0.5 -> 0.539 Inexact Rounded
+pwsx3524 power 0.0291 0.5 -> 0.171 Inexact Rounded
+pwsx3525 power 0.292 0.5 -> 0.540 Inexact Rounded
+pwsx3526 power 0.0292 0.5 -> 0.171 Inexact Rounded
+pwsx3527 power 0.293 0.5 -> 0.541 Inexact Rounded
+pwsx3528 power 0.0293 0.5 -> 0.171 Inexact Rounded
+pwsx3529 power 0.294 0.5 -> 0.542 Inexact Rounded
+pwsx3530 power 0.0294 0.5 -> 0.171 Inexact Rounded
+pwsx3531 power 0.295 0.5 -> 0.543 Inexact Rounded
+pwsx3532 power 0.0295 0.5 -> 0.172 Inexact Rounded
+pwsx3533 power 0.296 0.5 -> 0.544 Inexact Rounded
+pwsx3534 power 0.0296 0.5 -> 0.172 Inexact Rounded
+pwsx3535 power 0.297 0.5 -> 0.545 Inexact Rounded
+pwsx3536 power 0.0297 0.5 -> 0.172 Inexact Rounded
+pwsx3537 power 0.298 0.5 -> 0.546 Inexact Rounded
+pwsx3538 power 0.0298 0.5 -> 0.173 Inexact Rounded
+pwsx3539 power 0.299 0.5 -> 0.547 Inexact Rounded
+pwsx3540 power 0.0299 0.5 -> 0.173 Inexact Rounded
+pwsx3541 power 0.301 0.5 -> 0.549 Inexact Rounded
+pwsx3542 power 0.0301 0.5 -> 0.173 Inexact Rounded
+pwsx3543 power 0.302 0.5 -> 0.550 Inexact Rounded
+pwsx3544 power 0.0302 0.5 -> 0.174 Inexact Rounded
+pwsx3545 power 0.303 0.5 -> 0.550 Inexact Rounded
+pwsx3546 power 0.0303 0.5 -> 0.174 Inexact Rounded
+pwsx3547 power 0.304 0.5 -> 0.551 Inexact Rounded
+pwsx3548 power 0.0304 0.5 -> 0.174 Inexact Rounded
+pwsx3549 power 0.305 0.5 -> 0.552 Inexact Rounded
+pwsx3550 power 0.0305 0.5 -> 0.175 Inexact Rounded
+pwsx3551 power 0.306 0.5 -> 0.553 Inexact Rounded
+pwsx3552 power 0.0306 0.5 -> 0.175 Inexact Rounded
+pwsx3553 power 0.307 0.5 -> 0.554 Inexact Rounded
+pwsx3554 power 0.0307 0.5 -> 0.175 Inexact Rounded
+pwsx3555 power 0.308 0.5 -> 0.555 Inexact Rounded
+pwsx3556 power 0.0308 0.5 -> 0.175 Inexact Rounded
+pwsx3557 power 0.309 0.5 -> 0.556 Inexact Rounded
+pwsx3558 power 0.0309 0.5 -> 0.176 Inexact Rounded
+pwsx3559 power 0.311 0.5 -> 0.558 Inexact Rounded
+pwsx3560 power 0.0311 0.5 -> 0.176 Inexact Rounded
+pwsx3561 power 0.312 0.5 -> 0.559 Inexact Rounded
+pwsx3562 power 0.0312 0.5 -> 0.177 Inexact Rounded
+pwsx3563 power 0.313 0.5 -> 0.559 Inexact Rounded
+pwsx3564 power 0.0313 0.5 -> 0.177 Inexact Rounded
+pwsx3565 power 0.314 0.5 -> 0.560 Inexact Rounded
+pwsx3566 power 0.0314 0.5 -> 0.177 Inexact Rounded
+pwsx3567 power 0.315 0.5 -> 0.561 Inexact Rounded
+pwsx3568 power 0.0315 0.5 -> 0.177 Inexact Rounded
+pwsx3569 power 0.316 0.5 -> 0.562 Inexact Rounded
+pwsx3570 power 0.0316 0.5 -> 0.178 Inexact Rounded
+pwsx3571 power 0.317 0.5 -> 0.563 Inexact Rounded
+pwsx3572 power 0.0317 0.5 -> 0.178 Inexact Rounded
+pwsx3573 power 0.318 0.5 -> 0.564 Inexact Rounded
+pwsx3574 power 0.0318 0.5 -> 0.178 Inexact Rounded
+pwsx3575 power 0.319 0.5 -> 0.565 Inexact Rounded
+pwsx3576 power 0.0319 0.5 -> 0.179 Inexact Rounded
+pwsx3577 power 0.321 0.5 -> 0.567 Inexact Rounded
+pwsx3578 power 0.0321 0.5 -> 0.179 Inexact Rounded
+pwsx3579 power 0.322 0.5 -> 0.567 Inexact Rounded
+pwsx3580 power 0.0322 0.5 -> 0.179 Inexact Rounded
+pwsx3581 power 0.323 0.5 -> 0.568 Inexact Rounded
+pwsx3582 power 0.0323 0.5 -> 0.180 Inexact Rounded
+pwsx3583 power 0.324 0.5 -> 0.569 Inexact Rounded
+pwsx3584 power 0.0324 0.5 -> 0.180 Inexact Rounded
+pwsx3585 power 0.325 0.5 -> 0.570 Inexact Rounded
+pwsx3586 power 0.0325 0.5 -> 0.180 Inexact Rounded
+pwsx3587 power 0.326 0.5 -> 0.571 Inexact Rounded
+pwsx3588 power 0.0326 0.5 -> 0.181 Inexact Rounded
+pwsx3589 power 0.327 0.5 -> 0.572 Inexact Rounded
+pwsx3590 power 0.0327 0.5 -> 0.181 Inexact Rounded
+pwsx3591 power 0.328 0.5 -> 0.573 Inexact Rounded
+pwsx3592 power 0.0328 0.5 -> 0.181 Inexact Rounded
+pwsx3593 power 0.329 0.5 -> 0.574 Inexact Rounded
+pwsx3594 power 0.0329 0.5 -> 0.181 Inexact Rounded
+pwsx3595 power 0.331 0.5 -> 0.575 Inexact Rounded
+pwsx3596 power 0.0331 0.5 -> 0.182 Inexact Rounded
+pwsx3597 power 0.332 0.5 -> 0.576 Inexact Rounded
+pwsx3598 power 0.0332 0.5 -> 0.182 Inexact Rounded
+pwsx3599 power 0.333 0.5 -> 0.577 Inexact Rounded
+pwsx3600 power 0.0333 0.5 -> 0.182 Inexact Rounded
+pwsx3601 power 0.334 0.5 -> 0.578 Inexact Rounded
+pwsx3602 power 0.0334 0.5 -> 0.183 Inexact Rounded
+pwsx3603 power 0.335 0.5 -> 0.579 Inexact Rounded
+pwsx3604 power 0.0335 0.5 -> 0.183 Inexact Rounded
+pwsx3605 power 0.336 0.5 -> 0.580 Inexact Rounded
+pwsx3606 power 0.0336 0.5 -> 0.183 Inexact Rounded
+pwsx3607 power 0.337 0.5 -> 0.581 Inexact Rounded
+pwsx3608 power 0.0337 0.5 -> 0.184 Inexact Rounded
+pwsx3609 power 0.338 0.5 -> 0.581 Inexact Rounded
+pwsx3610 power 0.0338 0.5 -> 0.184 Inexact Rounded
+pwsx3611 power 0.339 0.5 -> 0.582 Inexact Rounded
+pwsx3612 power 0.0339 0.5 -> 0.184 Inexact Rounded
+pwsx3613 power 0.341 0.5 -> 0.584 Inexact Rounded
+pwsx3614 power 0.0341 0.5 -> 0.185 Inexact Rounded
+pwsx3615 power 0.342 0.5 -> 0.585 Inexact Rounded
+pwsx3616 power 0.0342 0.5 -> 0.185 Inexact Rounded
+pwsx3617 power 0.343 0.5 -> 0.586 Inexact Rounded
+pwsx3618 power 0.0343 0.5 -> 0.185 Inexact Rounded
+pwsx3619 power 0.344 0.5 -> 0.587 Inexact Rounded
+pwsx3620 power 0.0344 0.5 -> 0.185 Inexact Rounded
+pwsx3621 power 0.345 0.5 -> 0.587 Inexact Rounded
+pwsx3622 power 0.0345 0.5 -> 0.186 Inexact Rounded
+pwsx3623 power 0.346 0.5 -> 0.588 Inexact Rounded
+pwsx3624 power 0.0346 0.5 -> 0.186 Inexact Rounded
+pwsx3625 power 0.347 0.5 -> 0.589 Inexact Rounded
+pwsx3626 power 0.0347 0.5 -> 0.186 Inexact Rounded
+pwsx3627 power 0.348 0.5 -> 0.590 Inexact Rounded
+pwsx3628 power 0.0348 0.5 -> 0.187 Inexact Rounded
+pwsx3629 power 0.349 0.5 -> 0.591 Inexact Rounded
+pwsx3630 power 0.0349 0.5 -> 0.187 Inexact Rounded
+pwsx3631 power 0.351 0.5 -> 0.592 Inexact Rounded
+pwsx3632 power 0.0351 0.5 -> 0.187 Inexact Rounded
+pwsx3633 power 0.352 0.5 -> 0.593 Inexact Rounded
+pwsx3634 power 0.0352 0.5 -> 0.188 Inexact Rounded
+pwsx3635 power 0.353 0.5 -> 0.594 Inexact Rounded
+pwsx3636 power 0.0353 0.5 -> 0.188 Inexact Rounded
+pwsx3637 power 0.354 0.5 -> 0.595 Inexact Rounded
+pwsx3638 power 0.0354 0.5 -> 0.188 Inexact Rounded
+pwsx3639 power 0.355 0.5 -> 0.596 Inexact Rounded
+pwsx3640 power 0.0355 0.5 -> 0.188 Inexact Rounded
+pwsx3641 power 0.356 0.5 -> 0.597 Inexact Rounded
+pwsx3642 power 0.0356 0.5 -> 0.189 Inexact Rounded
+pwsx3643 power 0.357 0.5 -> 0.597 Inexact Rounded
+pwsx3644 power 0.0357 0.5 -> 0.189 Inexact Rounded
+pwsx3645 power 0.358 0.5 -> 0.598 Inexact Rounded
+pwsx3646 power 0.0358 0.5 -> 0.189 Inexact Rounded
+pwsx3647 power 0.359 0.5 -> 0.599 Inexact Rounded
+pwsx3648 power 0.0359 0.5 -> 0.189 Inexact Rounded
+pwsx3649 power 0.361 0.5 -> 0.601 Inexact Rounded
+pwsx3650 power 0.0361 0.5 -> 0.190 Inexact Rounded
+pwsx3651 power 0.362 0.5 -> 0.602 Inexact Rounded
+pwsx3652 power 0.0362 0.5 -> 0.190 Inexact Rounded
+pwsx3653 power 0.363 0.5 -> 0.602 Inexact Rounded
+pwsx3654 power 0.0363 0.5 -> 0.191 Inexact Rounded
+pwsx3655 power 0.364 0.5 -> 0.603 Inexact Rounded
+pwsx3656 power 0.0364 0.5 -> 0.191 Inexact Rounded
+pwsx3657 power 0.365 0.5 -> 0.604 Inexact Rounded
+pwsx3658 power 0.0365 0.5 -> 0.191 Inexact Rounded
+pwsx3659 power 0.366 0.5 -> 0.605 Inexact Rounded
+pwsx3660 power 0.0366 0.5 -> 0.191 Inexact Rounded
+pwsx3661 power 0.367 0.5 -> 0.606 Inexact Rounded
+pwsx3662 power 0.0367 0.5 -> 0.192 Inexact Rounded
+pwsx3663 power 0.368 0.5 -> 0.607 Inexact Rounded
+pwsx3664 power 0.0368 0.5 -> 0.192 Inexact Rounded
+pwsx3665 power 0.369 0.5 -> 0.607 Inexact Rounded
+pwsx3666 power 0.0369 0.5 -> 0.192 Inexact Rounded
+pwsx3667 power 0.371 0.5 -> 0.609 Inexact Rounded
+pwsx3668 power 0.0371 0.5 -> 0.193 Inexact Rounded
+pwsx3669 power 0.372 0.5 -> 0.610 Inexact Rounded
+pwsx3670 power 0.0372 0.5 -> 0.193 Inexact Rounded
+pwsx3671 power 0.373 0.5 -> 0.611 Inexact Rounded
+pwsx3672 power 0.0373 0.5 -> 0.193 Inexact Rounded
+pwsx3673 power 0.374 0.5 -> 0.612 Inexact Rounded
+pwsx3674 power 0.0374 0.5 -> 0.193 Inexact Rounded
+pwsx3675 power 0.375 0.5 -> 0.612 Inexact Rounded
+pwsx3676 power 0.0375 0.5 -> 0.194 Inexact Rounded
+pwsx3677 power 0.376 0.5 -> 0.613 Inexact Rounded
+pwsx3678 power 0.0376 0.5 -> 0.194 Inexact Rounded
+pwsx3679 power 0.377 0.5 -> 0.614 Inexact Rounded
+pwsx3680 power 0.0377 0.5 -> 0.194 Inexact Rounded
+pwsx3681 power 0.378 0.5 -> 0.615 Inexact Rounded
+pwsx3682 power 0.0378 0.5 -> 0.194 Inexact Rounded
+pwsx3683 power 0.379 0.5 -> 0.616 Inexact Rounded
+pwsx3684 power 0.0379 0.5 -> 0.195 Inexact Rounded
+pwsx3685 power 0.381 0.5 -> 0.617 Inexact Rounded
+pwsx3686 power 0.0381 0.5 -> 0.195 Inexact Rounded
+pwsx3687 power 0.382 0.5 -> 0.618 Inexact Rounded
+pwsx3688 power 0.0382 0.5 -> 0.195 Inexact Rounded
+pwsx3689 power 0.383 0.5 -> 0.619 Inexact Rounded
+pwsx3690 power 0.0383 0.5 -> 0.196 Inexact Rounded
+pwsx3691 power 0.384 0.5 -> 0.620 Inexact Rounded
+pwsx3692 power 0.0384 0.5 -> 0.196 Inexact Rounded
+pwsx3693 power 0.385 0.5 -> 0.620 Inexact Rounded
+pwsx3694 power 0.0385 0.5 -> 0.196 Inexact Rounded
+pwsx3695 power 0.386 0.5 -> 0.621 Inexact Rounded
+pwsx3696 power 0.0386 0.5 -> 0.196 Inexact Rounded
+pwsx3697 power 0.387 0.5 -> 0.622 Inexact Rounded
+pwsx3698 power 0.0387 0.5 -> 0.197 Inexact Rounded
+pwsx3699 power 0.388 0.5 -> 0.623 Inexact Rounded
+pwsx3700 power 0.0388 0.5 -> 0.197 Inexact Rounded
+pwsx3701 power 0.389 0.5 -> 0.624 Inexact Rounded
+pwsx3702 power 0.0389 0.5 -> 0.197 Inexact Rounded
+pwsx3703 power 0.391 0.5 -> 0.625 Inexact Rounded
+pwsx3704 power 0.0391 0.5 -> 0.198 Inexact Rounded
+pwsx3705 power 0.392 0.5 -> 0.626 Inexact Rounded
+pwsx3706 power 0.0392 0.5 -> 0.198 Inexact Rounded
+pwsx3707 power 0.393 0.5 -> 0.627 Inexact Rounded
+pwsx3708 power 0.0393 0.5 -> 0.198 Inexact Rounded
+pwsx3709 power 0.394 0.5 -> 0.628 Inexact Rounded
+pwsx3710 power 0.0394 0.5 -> 0.198 Inexact Rounded
+pwsx3711 power 0.395 0.5 -> 0.628 Inexact Rounded
+pwsx3712 power 0.0395 0.5 -> 0.199 Inexact Rounded
+pwsx3713 power 0.396 0.5 -> 0.629 Inexact Rounded
+pwsx3714 power 0.0396 0.5 -> 0.199 Inexact Rounded
+pwsx3715 power 0.397 0.5 -> 0.630 Inexact Rounded
+pwsx3716 power 0.0397 0.5 -> 0.199 Inexact Rounded
+pwsx3717 power 0.398 0.5 -> 0.631 Inexact Rounded
+pwsx3718 power 0.0398 0.5 -> 0.199 Inexact Rounded
+pwsx3719 power 0.399 0.5 -> 0.632 Inexact Rounded
+pwsx3720 power 0.0399 0.5 -> 0.200 Inexact Rounded
+pwsx3721 power 0.401 0.5 -> 0.633 Inexact Rounded
+pwsx3722 power 0.0401 0.5 -> 0.200 Inexact Rounded
+pwsx3723 power 0.402 0.5 -> 0.634 Inexact Rounded
+pwsx3724 power 0.0402 0.5 -> 0.200 Inexact Rounded
+pwsx3725 power 0.403 0.5 -> 0.635 Inexact Rounded
+pwsx3726 power 0.0403 0.5 -> 0.201 Inexact Rounded
+pwsx3727 power 0.404 0.5 -> 0.636 Inexact Rounded
+pwsx3728 power 0.0404 0.5 -> 0.201 Inexact Rounded
+pwsx3729 power 0.405 0.5 -> 0.636 Inexact Rounded
+pwsx3730 power 0.0405 0.5 -> 0.201 Inexact Rounded
+pwsx3731 power 0.406 0.5 -> 0.637 Inexact Rounded
+pwsx3732 power 0.0406 0.5 -> 0.201 Inexact Rounded
+pwsx3733 power 0.407 0.5 -> 0.638 Inexact Rounded
+pwsx3734 power 0.0407 0.5 -> 0.202 Inexact Rounded
+pwsx3735 power 0.408 0.5 -> 0.639 Inexact Rounded
+pwsx3736 power 0.0408 0.5 -> 0.202 Inexact Rounded
+pwsx3737 power 0.409 0.5 -> 0.640 Inexact Rounded
+pwsx3738 power 0.0409 0.5 -> 0.202 Inexact Rounded
+pwsx3739 power 0.411 0.5 -> 0.641 Inexact Rounded
+pwsx3740 power 0.0411 0.5 -> 0.203 Inexact Rounded
+pwsx3741 power 0.412 0.5 -> 0.642 Inexact Rounded
+pwsx3742 power 0.0412 0.5 -> 0.203 Inexact Rounded
+pwsx3743 power 0.413 0.5 -> 0.643 Inexact Rounded
+pwsx3744 power 0.0413 0.5 -> 0.203 Inexact Rounded
+pwsx3745 power 0.414 0.5 -> 0.643 Inexact Rounded
+pwsx3746 power 0.0414 0.5 -> 0.203 Inexact Rounded
+pwsx3747 power 0.415 0.5 -> 0.644 Inexact Rounded
+pwsx3748 power 0.0415 0.5 -> 0.204 Inexact Rounded
+pwsx3749 power 0.416 0.5 -> 0.645 Inexact Rounded
+pwsx3750 power 0.0416 0.5 -> 0.204 Inexact Rounded
+pwsx3751 power 0.417 0.5 -> 0.646 Inexact Rounded
+pwsx3752 power 0.0417 0.5 -> 0.204 Inexact Rounded
+pwsx3753 power 0.418 0.5 -> 0.647 Inexact Rounded
+pwsx3754 power 0.0418 0.5 -> 0.204 Inexact Rounded
+pwsx3755 power 0.419 0.5 -> 0.647 Inexact Rounded
+pwsx3756 power 0.0419 0.5 -> 0.205 Inexact Rounded
+pwsx3757 power 0.421 0.5 -> 0.649 Inexact Rounded
+pwsx3758 power 0.0421 0.5 -> 0.205 Inexact Rounded
+pwsx3759 power 0.422 0.5 -> 0.650 Inexact Rounded
+pwsx3760 power 0.0422 0.5 -> 0.205 Inexact Rounded
+pwsx3761 power 0.423 0.5 -> 0.650 Inexact Rounded
+pwsx3762 power 0.0423 0.5 -> 0.206 Inexact Rounded
+pwsx3763 power 0.424 0.5 -> 0.651 Inexact Rounded
+pwsx3764 power 0.0424 0.5 -> 0.206 Inexact Rounded
+pwsx3765 power 0.425 0.5 -> 0.652 Inexact Rounded
+pwsx3766 power 0.0425 0.5 -> 0.206 Inexact Rounded
+pwsx3767 power 0.426 0.5 -> 0.653 Inexact Rounded
+pwsx3768 power 0.0426 0.5 -> 0.206 Inexact Rounded
+pwsx3769 power 0.427 0.5 -> 0.653 Inexact Rounded
+pwsx3770 power 0.0427 0.5 -> 0.207 Inexact Rounded
+pwsx3771 power 0.428 0.5 -> 0.654 Inexact Rounded
+pwsx3772 power 0.0428 0.5 -> 0.207 Inexact Rounded
+pwsx3773 power 0.429 0.5 -> 0.655 Inexact Rounded
+pwsx3774 power 0.0429 0.5 -> 0.207 Inexact Rounded
+pwsx3775 power 0.431 0.5 -> 0.657 Inexact Rounded
+pwsx3776 power 0.0431 0.5 -> 0.208 Inexact Rounded
+pwsx3777 power 0.432 0.5 -> 0.657 Inexact Rounded
+pwsx3778 power 0.0432 0.5 -> 0.208 Inexact Rounded
+pwsx3779 power 0.433 0.5 -> 0.658 Inexact Rounded
+pwsx3780 power 0.0433 0.5 -> 0.208 Inexact Rounded
+pwsx3781 power 0.434 0.5 -> 0.659 Inexact Rounded
+pwsx3782 power 0.0434 0.5 -> 0.208 Inexact Rounded
+pwsx3783 power 0.435 0.5 -> 0.660 Inexact Rounded
+pwsx3784 power 0.0435 0.5 -> 0.209 Inexact Rounded
+pwsx3785 power 0.436 0.5 -> 0.660 Inexact Rounded
+pwsx3786 power 0.0436 0.5 -> 0.209 Inexact Rounded
+pwsx3787 power 0.437 0.5 -> 0.661 Inexact Rounded
+pwsx3788 power 0.0437 0.5 -> 0.209 Inexact Rounded
+pwsx3789 power 0.438 0.5 -> 0.662 Inexact Rounded
+pwsx3790 power 0.0438 0.5 -> 0.209 Inexact Rounded
+pwsx3791 power 0.439 0.5 -> 0.663 Inexact Rounded
+pwsx3792 power 0.0439 0.5 -> 0.210 Inexact Rounded
+pwsx3793 power 0.441 0.5 -> 0.664 Inexact Rounded
+pwsx3794 power 0.0441 0.5 -> 0.210 Inexact Rounded
+pwsx3795 power 0.442 0.5 -> 0.665 Inexact Rounded
+pwsx3796 power 0.0442 0.5 -> 0.210 Inexact Rounded
+pwsx3797 power 0.443 0.5 -> 0.666 Inexact Rounded
+pwsx3798 power 0.0443 0.5 -> 0.210 Inexact Rounded
+pwsx3799 power 0.444 0.5 -> 0.666 Inexact Rounded
+pwsx3800 power 0.0444 0.5 -> 0.211 Inexact Rounded
+pwsx3801 power 0.445 0.5 -> 0.667 Inexact Rounded
+pwsx3802 power 0.0445 0.5 -> 0.211 Inexact Rounded
+pwsx3803 power 0.446 0.5 -> 0.668 Inexact Rounded
+pwsx3804 power 0.0446 0.5 -> 0.211 Inexact Rounded
+pwsx3805 power 0.447 0.5 -> 0.669 Inexact Rounded
+pwsx3806 power 0.0447 0.5 -> 0.211 Inexact Rounded
+pwsx3807 power 0.448 0.5 -> 0.669 Inexact Rounded
+pwsx3808 power 0.0448 0.5 -> 0.212 Inexact Rounded
+pwsx3809 power 0.449 0.5 -> 0.670 Inexact Rounded
+pwsx3810 power 0.0449 0.5 -> 0.212 Inexact Rounded
+pwsx3811 power 0.451 0.5 -> 0.672 Inexact Rounded
+pwsx3812 power 0.0451 0.5 -> 0.212 Inexact Rounded
+pwsx3813 power 0.452 0.5 -> 0.672 Inexact Rounded
+pwsx3814 power 0.0452 0.5 -> 0.213 Inexact Rounded
+pwsx3815 power 0.453 0.5 -> 0.673 Inexact Rounded
+pwsx3816 power 0.0453 0.5 -> 0.213 Inexact Rounded
+pwsx3817 power 0.454 0.5 -> 0.674 Inexact Rounded
+pwsx3818 power 0.0454 0.5 -> 0.213 Inexact Rounded
+pwsx3819 power 0.455 0.5 -> 0.675 Inexact Rounded
+pwsx3820 power 0.0455 0.5 -> 0.213 Inexact Rounded
+pwsx3821 power 0.456 0.5 -> 0.675 Inexact Rounded
+pwsx3822 power 0.0456 0.5 -> 0.214 Inexact Rounded
+pwsx3823 power 0.457 0.5 -> 0.676 Inexact Rounded
+pwsx3824 power 0.0457 0.5 -> 0.214 Inexact Rounded
+pwsx3825 power 0.458 0.5 -> 0.677 Inexact Rounded
+pwsx3826 power 0.0458 0.5 -> 0.214 Inexact Rounded
+pwsx3827 power 0.459 0.5 -> 0.677 Inexact Rounded
+pwsx3828 power 0.0459 0.5 -> 0.214 Inexact Rounded
+pwsx3829 power 0.461 0.5 -> 0.679 Inexact Rounded
+pwsx3830 power 0.0461 0.5 -> 0.215 Inexact Rounded
+pwsx3831 power 0.462 0.5 -> 0.680 Inexact Rounded
+pwsx3832 power 0.0462 0.5 -> 0.215 Inexact Rounded
+pwsx3833 power 0.463 0.5 -> 0.680 Inexact Rounded
+pwsx3834 power 0.0463 0.5 -> 0.215 Inexact Rounded
+pwsx3835 power 0.464 0.5 -> 0.681 Inexact Rounded
+pwsx3836 power 0.0464 0.5 -> 0.215 Inexact Rounded
+pwsx3837 power 0.465 0.5 -> 0.682 Inexact Rounded
+pwsx3838 power 0.0465 0.5 -> 0.216 Inexact Rounded
+pwsx3839 power 0.466 0.5 -> 0.683 Inexact Rounded
+pwsx3840 power 0.0466 0.5 -> 0.216 Inexact Rounded
+pwsx3841 power 0.467 0.5 -> 0.683 Inexact Rounded
+pwsx3842 power 0.0467 0.5 -> 0.216 Inexact Rounded
+pwsx3843 power 0.468 0.5 -> 0.684 Inexact Rounded
+pwsx3844 power 0.0468 0.5 -> 0.216 Inexact Rounded
+pwsx3845 power 0.469 0.5 -> 0.685 Inexact Rounded
+pwsx3846 power 0.0469 0.5 -> 0.217 Inexact Rounded
+pwsx3847 power 0.471 0.5 -> 0.686 Inexact Rounded
+pwsx3848 power 0.0471 0.5 -> 0.217 Inexact Rounded
+pwsx3849 power 0.472 0.5 -> 0.687 Inexact Rounded
+pwsx3850 power 0.0472 0.5 -> 0.217 Inexact Rounded
+pwsx3851 power 0.473 0.5 -> 0.688 Inexact Rounded
+pwsx3852 power 0.0473 0.5 -> 0.217 Inexact Rounded
+pwsx3853 power 0.474 0.5 -> 0.688 Inexact Rounded
+pwsx3854 power 0.0474 0.5 -> 0.218 Inexact Rounded
+pwsx3855 power 0.475 0.5 -> 0.689 Inexact Rounded
+pwsx3856 power 0.0475 0.5 -> 0.218 Inexact Rounded
+pwsx3857 power 0.476 0.5 -> 0.690 Inexact Rounded
+pwsx3858 power 0.0476 0.5 -> 0.218 Inexact Rounded
+pwsx3859 power 0.477 0.5 -> 0.691 Inexact Rounded
+pwsx3860 power 0.0477 0.5 -> 0.218 Inexact Rounded
+pwsx3861 power 0.478 0.5 -> 0.691 Inexact Rounded
+pwsx3862 power 0.0478 0.5 -> 0.219 Inexact Rounded
+pwsx3863 power 0.479 0.5 -> 0.692 Inexact Rounded
+pwsx3864 power 0.0479 0.5 -> 0.219 Inexact Rounded
+pwsx3865 power 0.481 0.5 -> 0.694 Inexact Rounded
+pwsx3866 power 0.0481 0.5 -> 0.219 Inexact Rounded
+pwsx3867 power 0.482 0.5 -> 0.694 Inexact Rounded
+pwsx3868 power 0.0482 0.5 -> 0.220 Inexact Rounded
+pwsx3869 power 0.483 0.5 -> 0.695 Inexact Rounded
+pwsx3870 power 0.0483 0.5 -> 0.220 Inexact Rounded
+pwsx3871 power 0.484 0.5 -> 0.696 Inexact Rounded
+pwsx3872 power 0.0484 0.5 -> 0.220 Inexact Rounded
+pwsx3873 power 0.485 0.5 -> 0.696 Inexact Rounded
+pwsx3874 power 0.0485 0.5 -> 0.220 Inexact Rounded
+pwsx3875 power 0.486 0.5 -> 0.697 Inexact Rounded
+pwsx3876 power 0.0486 0.5 -> 0.220 Inexact Rounded
+pwsx3877 power 0.487 0.5 -> 0.698 Inexact Rounded
+pwsx3878 power 0.0487 0.5 -> 0.221 Inexact Rounded
+pwsx3879 power 0.488 0.5 -> 0.699 Inexact Rounded
+pwsx3880 power 0.0488 0.5 -> 0.221 Inexact Rounded
+pwsx3881 power 0.489 0.5 -> 0.699 Inexact Rounded
+pwsx3882 power 0.0489 0.5 -> 0.221 Inexact Rounded
+pwsx3883 power 0.491 0.5 -> 0.701 Inexact Rounded
+pwsx3884 power 0.0491 0.5 -> 0.222 Inexact Rounded
+pwsx3885 power 0.492 0.5 -> 0.701 Inexact Rounded
+pwsx3886 power 0.0492 0.5 -> 0.222 Inexact Rounded
+pwsx3887 power 0.493 0.5 -> 0.702 Inexact Rounded
+pwsx3888 power 0.0493 0.5 -> 0.222 Inexact Rounded
+pwsx3889 power 0.494 0.5 -> 0.703 Inexact Rounded
+pwsx3890 power 0.0494 0.5 -> 0.222 Inexact Rounded
+pwsx3891 power 0.495 0.5 -> 0.704 Inexact Rounded
+pwsx3892 power 0.0495 0.5 -> 0.222 Inexact Rounded
+pwsx3893 power 0.496 0.5 -> 0.704 Inexact Rounded
+pwsx3894 power 0.0496 0.5 -> 0.223 Inexact Rounded
+pwsx3895 power 0.497 0.5 -> 0.705 Inexact Rounded
+pwsx3896 power 0.0497 0.5 -> 0.223 Inexact Rounded
+pwsx3897 power 0.498 0.5 -> 0.706 Inexact Rounded
+pwsx3898 power 0.0498 0.5 -> 0.223 Inexact Rounded
+pwsx3899 power 0.499 0.5 -> 0.706 Inexact Rounded
+pwsx3900 power 0.0499 0.5 -> 0.223 Inexact Rounded
+pwsx3901 power 0.501 0.5 -> 0.708 Inexact Rounded
+pwsx3902 power 0.0501 0.5 -> 0.224 Inexact Rounded
+pwsx3903 power 0.502 0.5 -> 0.709 Inexact Rounded
+pwsx3904 power 0.0502 0.5 -> 0.224 Inexact Rounded
+pwsx3905 power 0.503 0.5 -> 0.709 Inexact Rounded
+pwsx3906 power 0.0503 0.5 -> 0.224 Inexact Rounded
+pwsx3907 power 0.504 0.5 -> 0.710 Inexact Rounded
+pwsx3908 power 0.0504 0.5 -> 0.224 Inexact Rounded
+pwsx3909 power 0.505 0.5 -> 0.711 Inexact Rounded
+pwsx3910 power 0.0505 0.5 -> 0.225 Inexact Rounded
+pwsx3911 power 0.506 0.5 -> 0.711 Inexact Rounded
+pwsx3912 power 0.0506 0.5 -> 0.225 Inexact Rounded
+pwsx3913 power 0.507 0.5 -> 0.712 Inexact Rounded
+pwsx3914 power 0.0507 0.5 -> 0.225 Inexact Rounded
+pwsx3915 power 0.508 0.5 -> 0.713 Inexact Rounded
+pwsx3916 power 0.0508 0.5 -> 0.225 Inexact Rounded
+pwsx3917 power 0.509 0.5 -> 0.713 Inexact Rounded
+pwsx3918 power 0.0509 0.5 -> 0.226 Inexact Rounded
+pwsx3919 power 0.511 0.5 -> 0.715 Inexact Rounded
+pwsx3920 power 0.0511 0.5 -> 0.226 Inexact Rounded
+pwsx3921 power 0.512 0.5 -> 0.716 Inexact Rounded
+pwsx3922 power 0.0512 0.5 -> 0.226 Inexact Rounded
+pwsx3923 power 0.513 0.5 -> 0.716 Inexact Rounded
+pwsx3924 power 0.0513 0.5 -> 0.226 Inexact Rounded
+pwsx3925 power 0.514 0.5 -> 0.717 Inexact Rounded
+pwsx3926 power 0.0514 0.5 -> 0.227 Inexact Rounded
+pwsx3927 power 0.515 0.5 -> 0.718 Inexact Rounded
+pwsx3928 power 0.0515 0.5 -> 0.227 Inexact Rounded
+pwsx3929 power 0.516 0.5 -> 0.718 Inexact Rounded
+pwsx3930 power 0.0516 0.5 -> 0.227 Inexact Rounded
+pwsx3931 power 0.517 0.5 -> 0.719 Inexact Rounded
+pwsx3932 power 0.0517 0.5 -> 0.227 Inexact Rounded
+pwsx3933 power 0.518 0.5 -> 0.720 Inexact Rounded
+pwsx3934 power 0.0518 0.5 -> 0.228 Inexact Rounded
+pwsx3935 power 0.519 0.5 -> 0.720 Inexact Rounded
+pwsx3936 power 0.0519 0.5 -> 0.228 Inexact Rounded
+pwsx3937 power 0.521 0.5 -> 0.722 Inexact Rounded
+pwsx3938 power 0.0521 0.5 -> 0.228 Inexact Rounded
+pwsx3939 power 0.522 0.5 -> 0.722 Inexact Rounded
+pwsx3940 power 0.0522 0.5 -> 0.228 Inexact Rounded
+pwsx3941 power 0.523 0.5 -> 0.723 Inexact Rounded
+pwsx3942 power 0.0523 0.5 -> 0.229 Inexact Rounded
+pwsx3943 power 0.524 0.5 -> 0.724 Inexact Rounded
+pwsx3944 power 0.0524 0.5 -> 0.229 Inexact Rounded
+pwsx3945 power 0.525 0.5 -> 0.725 Inexact Rounded
+pwsx3946 power 0.0525 0.5 -> 0.229 Inexact Rounded
+pwsx3947 power 0.526 0.5 -> 0.725 Inexact Rounded
+pwsx3948 power 0.0526 0.5 -> 0.229 Inexact Rounded
+pwsx3949 power 0.527 0.5 -> 0.726 Inexact Rounded
+pwsx3950 power 0.0527 0.5 -> 0.230 Inexact Rounded
+pwsx3951 power 0.528 0.5 -> 0.727 Inexact Rounded
+pwsx3952 power 0.0528 0.5 -> 0.230 Inexact Rounded
+pwsx3953 power 0.529 0.5 -> 0.727 Inexact Rounded
+pwsx3954 power 0.0529 0.5 -> 0.230 Inexact Rounded
+pwsx3955 power 0.531 0.5 -> 0.729 Inexact Rounded
+pwsx3956 power 0.0531 0.5 -> 0.230 Inexact Rounded
+pwsx3957 power 0.532 0.5 -> 0.729 Inexact Rounded
+pwsx3958 power 0.0532 0.5 -> 0.231 Inexact Rounded
+pwsx3959 power 0.533 0.5 -> 0.730 Inexact Rounded
+pwsx3960 power 0.0533 0.5 -> 0.231 Inexact Rounded
+pwsx3961 power 0.534 0.5 -> 0.731 Inexact Rounded
+pwsx3962 power 0.0534 0.5 -> 0.231 Inexact Rounded
+pwsx3963 power 0.535 0.5 -> 0.731 Inexact Rounded
+pwsx3964 power 0.0535 0.5 -> 0.231 Inexact Rounded
+pwsx3965 power 0.536 0.5 -> 0.732 Inexact Rounded
+pwsx3966 power 0.0536 0.5 -> 0.232 Inexact Rounded
+pwsx3967 power 0.537 0.5 -> 0.733 Inexact Rounded
+pwsx3968 power 0.0537 0.5 -> 0.232 Inexact Rounded
+pwsx3969 power 0.538 0.5 -> 0.733 Inexact Rounded
+pwsx3970 power 0.0538 0.5 -> 0.232 Inexact Rounded
+pwsx3971 power 0.539 0.5 -> 0.734 Inexact Rounded
+pwsx3972 power 0.0539 0.5 -> 0.232 Inexact Rounded
+pwsx3973 power 0.541 0.5 -> 0.736 Inexact Rounded
+pwsx3974 power 0.0541 0.5 -> 0.233 Inexact Rounded
+pwsx3975 power 0.542 0.5 -> 0.736 Inexact Rounded
+pwsx3976 power 0.0542 0.5 -> 0.233 Inexact Rounded
+pwsx3977 power 0.543 0.5 -> 0.737 Inexact Rounded
+pwsx3978 power 0.0543 0.5 -> 0.233 Inexact Rounded
+pwsx3979 power 0.544 0.5 -> 0.738 Inexact Rounded
+pwsx3980 power 0.0544 0.5 -> 0.233 Inexact Rounded
+pwsx3981 power 0.545 0.5 -> 0.738 Inexact Rounded
+pwsx3982 power 0.0545 0.5 -> 0.233 Inexact Rounded
+pwsx3983 power 0.546 0.5 -> 0.739 Inexact Rounded
+pwsx3984 power 0.0546 0.5 -> 0.234 Inexact Rounded
+pwsx3985 power 0.547 0.5 -> 0.740 Inexact Rounded
+pwsx3986 power 0.0547 0.5 -> 0.234 Inexact Rounded
+pwsx3987 power 0.548 0.5 -> 0.740 Inexact Rounded
+pwsx3988 power 0.0548 0.5 -> 0.234 Inexact Rounded
+pwsx3989 power 0.549 0.5 -> 0.741 Inexact Rounded
+pwsx3990 power 0.0549 0.5 -> 0.234 Inexact Rounded
+pwsx3991 power 0.551 0.5 -> 0.742 Inexact Rounded
+pwsx3992 power 0.0551 0.5 -> 0.235 Inexact Rounded
+pwsx3993 power 0.552 0.5 -> 0.743 Inexact Rounded
+pwsx3994 power 0.0552 0.5 -> 0.235 Inexact Rounded
+pwsx3995 power 0.553 0.5 -> 0.744 Inexact Rounded
+pwsx3996 power 0.0553 0.5 -> 0.235 Inexact Rounded
+pwsx3997 power 0.554 0.5 -> 0.744 Inexact Rounded
+pwsx3998 power 0.0554 0.5 -> 0.235 Inexact Rounded
+pwsx3999 power 0.555 0.5 -> 0.745 Inexact Rounded
+pwsx4000 power 0.0555 0.5 -> 0.236 Inexact Rounded
+pwsx4001 power 0.556 0.5 -> 0.746 Inexact Rounded
+pwsx4002 power 0.0556 0.5 -> 0.236 Inexact Rounded
+pwsx4003 power 0.557 0.5 -> 0.746 Inexact Rounded
+pwsx4004 power 0.0557 0.5 -> 0.236 Inexact Rounded
+pwsx4005 power 0.558 0.5 -> 0.747 Inexact Rounded
+pwsx4006 power 0.0558 0.5 -> 0.236 Inexact Rounded
+pwsx4007 power 0.559 0.5 -> 0.748 Inexact Rounded
+pwsx4008 power 0.0559 0.5 -> 0.236 Inexact Rounded
+pwsx4009 power 0.561 0.5 -> 0.749 Inexact Rounded
+pwsx4010 power 0.0561 0.5 -> 0.237 Inexact Rounded
+pwsx4011 power 0.562 0.5 -> 0.750 Inexact Rounded
+pwsx4012 power 0.0562 0.5 -> 0.237 Inexact Rounded
+pwsx4013 power 0.563 0.5 -> 0.750 Inexact Rounded
+pwsx4014 power 0.0563 0.5 -> 0.237 Inexact Rounded
+pwsx4015 power 0.564 0.5 -> 0.751 Inexact Rounded
+pwsx4016 power 0.0564 0.5 -> 0.237 Inexact Rounded
+pwsx4017 power 0.565 0.5 -> 0.752 Inexact Rounded
+pwsx4018 power 0.0565 0.5 -> 0.238 Inexact Rounded
+pwsx4019 power 0.566 0.5 -> 0.752 Inexact Rounded
+pwsx4020 power 0.0566 0.5 -> 0.238 Inexact Rounded
+pwsx4021 power 0.567 0.5 -> 0.753 Inexact Rounded
+pwsx4022 power 0.0567 0.5 -> 0.238 Inexact Rounded
+pwsx4023 power 0.568 0.5 -> 0.754 Inexact Rounded
+pwsx4024 power 0.0568 0.5 -> 0.238 Inexact Rounded
+pwsx4025 power 0.569 0.5 -> 0.754 Inexact Rounded
+pwsx4026 power 0.0569 0.5 -> 0.239 Inexact Rounded
+pwsx4027 power 0.571 0.5 -> 0.756 Inexact Rounded
+pwsx4028 power 0.0571 0.5 -> 0.239 Inexact Rounded
+pwsx4029 power 0.572 0.5 -> 0.756 Inexact Rounded
+pwsx4030 power 0.0572 0.5 -> 0.239 Inexact Rounded
+pwsx4031 power 0.573 0.5 -> 0.757 Inexact Rounded
+pwsx4032 power 0.0573 0.5 -> 0.239 Inexact Rounded
+pwsx4033 power 0.574 0.5 -> 0.758 Inexact Rounded
+pwsx4034 power 0.0574 0.5 -> 0.240 Inexact Rounded
+pwsx4035 power 0.575 0.5 -> 0.758 Inexact Rounded
+pwsx4036 power 0.0575 0.5 -> 0.240 Inexact Rounded
+pwsx4037 power 0.576 0.5 -> 0.759 Inexact Rounded
+pwsx4038 power 0.0576 0.5 -> 0.240 Inexact Rounded
+pwsx4039 power 0.577 0.5 -> 0.760 Inexact Rounded
+pwsx4040 power 0.0577 0.5 -> 0.240 Inexact Rounded
+pwsx4041 power 0.578 0.5 -> 0.760 Inexact Rounded
+pwsx4042 power 0.0578 0.5 -> 0.240 Inexact Rounded
+pwsx4043 power 0.579 0.5 -> 0.761 Inexact Rounded
+pwsx4044 power 0.0579 0.5 -> 0.241 Inexact Rounded
+pwsx4045 power 0.581 0.5 -> 0.762 Inexact Rounded
+pwsx4046 power 0.0581 0.5 -> 0.241 Inexact Rounded
+pwsx4047 power 0.582 0.5 -> 0.763 Inexact Rounded
+pwsx4048 power 0.0582 0.5 -> 0.241 Inexact Rounded
+pwsx4049 power 0.583 0.5 -> 0.764 Inexact Rounded
+pwsx4050 power 0.0583 0.5 -> 0.241 Inexact Rounded
+pwsx4051 power 0.584 0.5 -> 0.764 Inexact Rounded
+pwsx4052 power 0.0584 0.5 -> 0.242 Inexact Rounded
+pwsx4053 power 0.585 0.5 -> 0.765 Inexact Rounded
+pwsx4054 power 0.0585 0.5 -> 0.242 Inexact Rounded
+pwsx4055 power 0.586 0.5 -> 0.766 Inexact Rounded
+pwsx4056 power 0.0586 0.5 -> 0.242 Inexact Rounded
+pwsx4057 power 0.587 0.5 -> 0.766 Inexact Rounded
+pwsx4058 power 0.0587 0.5 -> 0.242 Inexact Rounded
+pwsx4059 power 0.588 0.5 -> 0.767 Inexact Rounded
+pwsx4060 power 0.0588 0.5 -> 0.242 Inexact Rounded
+pwsx4061 power 0.589 0.5 -> 0.767 Inexact Rounded
+pwsx4062 power 0.0589 0.5 -> 0.243 Inexact Rounded
+pwsx4063 power 0.591 0.5 -> 0.769 Inexact Rounded
+pwsx4064 power 0.0591 0.5 -> 0.243 Inexact Rounded
+pwsx4065 power 0.592 0.5 -> 0.769 Inexact Rounded
+pwsx4066 power 0.0592 0.5 -> 0.243 Inexact Rounded
+pwsx4067 power 0.593 0.5 -> 0.770 Inexact Rounded
+pwsx4068 power 0.0593 0.5 -> 0.244 Inexact Rounded
+pwsx4069 power 0.594 0.5 -> 0.771 Inexact Rounded
+pwsx4070 power 0.0594 0.5 -> 0.244 Inexact Rounded
+pwsx4071 power 0.595 0.5 -> 0.771 Inexact Rounded
+pwsx4072 power 0.0595 0.5 -> 0.244 Inexact Rounded
+pwsx4073 power 0.596 0.5 -> 0.772 Inexact Rounded
+pwsx4074 power 0.0596 0.5 -> 0.244 Inexact Rounded
+pwsx4075 power 0.597 0.5 -> 0.773 Inexact Rounded
+pwsx4076 power 0.0597 0.5 -> 0.244 Inexact Rounded
+pwsx4077 power 0.598 0.5 -> 0.773 Inexact Rounded
+pwsx4078 power 0.0598 0.5 -> 0.245 Inexact Rounded
+pwsx4079 power 0.599 0.5 -> 0.774 Inexact Rounded
+pwsx4080 power 0.0599 0.5 -> 0.245 Inexact Rounded
+pwsx4081 power 0.601 0.5 -> 0.775 Inexact Rounded
+pwsx4082 power 0.0601 0.5 -> 0.245 Inexact Rounded
+pwsx4083 power 0.602 0.5 -> 0.776 Inexact Rounded
+pwsx4084 power 0.0602 0.5 -> 0.245 Inexact Rounded
+pwsx4085 power 0.603 0.5 -> 0.777 Inexact Rounded
+pwsx4086 power 0.0603 0.5 -> 0.246 Inexact Rounded
+pwsx4087 power 0.604 0.5 -> 0.777 Inexact Rounded
+pwsx4088 power 0.0604 0.5 -> 0.246 Inexact Rounded
+pwsx4089 power 0.605 0.5 -> 0.778 Inexact Rounded
+pwsx4090 power 0.0605 0.5 -> 0.246 Inexact Rounded
+pwsx4091 power 0.606 0.5 -> 0.778 Inexact Rounded
+pwsx4092 power 0.0606 0.5 -> 0.246 Inexact Rounded
+pwsx4093 power 0.607 0.5 -> 0.779 Inexact Rounded
+pwsx4094 power 0.0607 0.5 -> 0.246 Inexact Rounded
+pwsx4095 power 0.608 0.5 -> 0.780 Inexact Rounded
+pwsx4096 power 0.0608 0.5 -> 0.247 Inexact Rounded
+pwsx4097 power 0.609 0.5 -> 0.780 Inexact Rounded
+pwsx4098 power 0.0609 0.5 -> 0.247 Inexact Rounded
+pwsx4099 power 0.611 0.5 -> 0.782 Inexact Rounded
+pwsx4100 power 0.0611 0.5 -> 0.247 Inexact Rounded
+pwsx4101 power 0.612 0.5 -> 0.782 Inexact Rounded
+pwsx4102 power 0.0612 0.5 -> 0.247 Inexact Rounded
+pwsx4103 power 0.613 0.5 -> 0.783 Inexact Rounded
+pwsx4104 power 0.0613 0.5 -> 0.248 Inexact Rounded
+pwsx4105 power 0.614 0.5 -> 0.784 Inexact Rounded
+pwsx4106 power 0.0614 0.5 -> 0.248 Inexact Rounded
+pwsx4107 power 0.615 0.5 -> 0.784 Inexact Rounded
+pwsx4108 power 0.0615 0.5 -> 0.248 Inexact Rounded
+pwsx4109 power 0.616 0.5 -> 0.785 Inexact Rounded
+pwsx4110 power 0.0616 0.5 -> 0.248 Inexact Rounded
+pwsx4111 power 0.617 0.5 -> 0.785 Inexact Rounded
+pwsx4112 power 0.0617 0.5 -> 0.248 Inexact Rounded
+pwsx4113 power 0.618 0.5 -> 0.786 Inexact Rounded
+pwsx4114 power 0.0618 0.5 -> 0.249 Inexact Rounded
+pwsx4115 power 0.619 0.5 -> 0.787 Inexact Rounded
+pwsx4116 power 0.0619 0.5 -> 0.249 Inexact Rounded
+pwsx4117 power 0.621 0.5 -> 0.788 Inexact Rounded
+pwsx4118 power 0.0621 0.5 -> 0.249 Inexact Rounded
+pwsx4119 power 0.622 0.5 -> 0.789 Inexact Rounded
+pwsx4120 power 0.0622 0.5 -> 0.249 Inexact Rounded
+pwsx4121 power 0.623 0.5 -> 0.789 Inexact Rounded
+pwsx4122 power 0.0623 0.5 -> 0.250 Inexact Rounded
+pwsx4123 power 0.624 0.5 -> 0.790 Inexact Rounded
+pwsx4124 power 0.0624 0.5 -> 0.250 Inexact Rounded
+pwsx4125 power 0.625 0.5 -> 0.791 Inexact Rounded
+pwsx4126 power 0.0625 0.5 -> 0.250 Inexact Rounded
+pwsx4127 power 0.626 0.5 -> 0.791 Inexact Rounded
+pwsx4128 power 0.0626 0.5 -> 0.250 Inexact Rounded
+pwsx4129 power 0.627 0.5 -> 0.792 Inexact Rounded
+pwsx4130 power 0.0627 0.5 -> 0.250 Inexact Rounded
+pwsx4131 power 0.628 0.5 -> 0.792 Inexact Rounded
+pwsx4132 power 0.0628 0.5 -> 0.251 Inexact Rounded
+pwsx4133 power 0.629 0.5 -> 0.793 Inexact Rounded
+pwsx4134 power 0.0629 0.5 -> 0.251 Inexact Rounded
+pwsx4135 power 0.631 0.5 -> 0.794 Inexact Rounded
+pwsx4136 power 0.0631 0.5 -> 0.251 Inexact Rounded
+pwsx4137 power 0.632 0.5 -> 0.795 Inexact Rounded
+pwsx4138 power 0.0632 0.5 -> 0.251 Inexact Rounded
+pwsx4139 power 0.633 0.5 -> 0.796 Inexact Rounded
+pwsx4140 power 0.0633 0.5 -> 0.252 Inexact Rounded
+pwsx4141 power 0.634 0.5 -> 0.796 Inexact Rounded
+pwsx4142 power 0.0634 0.5 -> 0.252 Inexact Rounded
+pwsx4143 power 0.635 0.5 -> 0.797 Inexact Rounded
+pwsx4144 power 0.0635 0.5 -> 0.252 Inexact Rounded
+pwsx4145 power 0.636 0.5 -> 0.797 Inexact Rounded
+pwsx4146 power 0.0636 0.5 -> 0.252 Inexact Rounded
+pwsx4147 power 0.637 0.5 -> 0.798 Inexact Rounded
+pwsx4148 power 0.0637 0.5 -> 0.252 Inexact Rounded
+pwsx4149 power 0.638 0.5 -> 0.799 Inexact Rounded
+pwsx4150 power 0.0638 0.5 -> 0.253 Inexact Rounded
+pwsx4151 power 0.639 0.5 -> 0.799 Inexact Rounded
+pwsx4152 power 0.0639 0.5 -> 0.253 Inexact Rounded
+pwsx4153 power 0.641 0.5 -> 0.801 Inexact Rounded
+pwsx4154 power 0.0641 0.5 -> 0.253 Inexact Rounded
+pwsx4155 power 0.642 0.5 -> 0.801 Inexact Rounded
+pwsx4156 power 0.0642 0.5 -> 0.253 Inexact Rounded
+pwsx4157 power 0.643 0.5 -> 0.802 Inexact Rounded
+pwsx4158 power 0.0643 0.5 -> 0.254 Inexact Rounded
+pwsx4159 power 0.644 0.5 -> 0.802 Inexact Rounded
+pwsx4160 power 0.0644 0.5 -> 0.254 Inexact Rounded
+pwsx4161 power 0.645 0.5 -> 0.803 Inexact Rounded
+pwsx4162 power 0.0645 0.5 -> 0.254 Inexact Rounded
+pwsx4163 power 0.646 0.5 -> 0.804 Inexact Rounded
+pwsx4164 power 0.0646 0.5 -> 0.254 Inexact Rounded
+pwsx4165 power 0.647 0.5 -> 0.804 Inexact Rounded
+pwsx4166 power 0.0647 0.5 -> 0.254 Inexact Rounded
+pwsx4167 power 0.648 0.5 -> 0.805 Inexact Rounded
+pwsx4168 power 0.0648 0.5 -> 0.255 Inexact Rounded
+pwsx4169 power 0.649 0.5 -> 0.806 Inexact Rounded
+pwsx4170 power 0.0649 0.5 -> 0.255 Inexact Rounded
+pwsx4171 power 0.651 0.5 -> 0.807 Inexact Rounded
+pwsx4172 power 0.0651 0.5 -> 0.255 Inexact Rounded
+pwsx4173 power 0.652 0.5 -> 0.807 Inexact Rounded
+pwsx4174 power 0.0652 0.5 -> 0.255 Inexact Rounded
+pwsx4175 power 0.653 0.5 -> 0.808 Inexact Rounded
+pwsx4176 power 0.0653 0.5 -> 0.256 Inexact Rounded
+pwsx4177 power 0.654 0.5 -> 0.809 Inexact Rounded
+pwsx4178 power 0.0654 0.5 -> 0.256 Inexact Rounded
+pwsx4179 power 0.655 0.5 -> 0.809 Inexact Rounded
+pwsx4180 power 0.0655 0.5 -> 0.256 Inexact Rounded
+pwsx4181 power 0.656 0.5 -> 0.810 Inexact Rounded
+pwsx4182 power 0.0656 0.5 -> 0.256 Inexact Rounded
+pwsx4183 power 0.657 0.5 -> 0.811 Inexact Rounded
+pwsx4184 power 0.0657 0.5 -> 0.256 Inexact Rounded
+pwsx4185 power 0.658 0.5 -> 0.811 Inexact Rounded
+pwsx4186 power 0.0658 0.5 -> 0.257 Inexact Rounded
+pwsx4187 power 0.659 0.5 -> 0.812 Inexact Rounded
+pwsx4188 power 0.0659 0.5 -> 0.257 Inexact Rounded
+pwsx4189 power 0.661 0.5 -> 0.813 Inexact Rounded
+pwsx4190 power 0.0661 0.5 -> 0.257 Inexact Rounded
+pwsx4191 power 0.662 0.5 -> 0.814 Inexact Rounded
+pwsx4192 power 0.0662 0.5 -> 0.257 Inexact Rounded
+pwsx4193 power 0.663 0.5 -> 0.814 Inexact Rounded
+pwsx4194 power 0.0663 0.5 -> 0.257 Inexact Rounded
+pwsx4195 power 0.664 0.5 -> 0.815 Inexact Rounded
+pwsx4196 power 0.0664 0.5 -> 0.258 Inexact Rounded
+pwsx4197 power 0.665 0.5 -> 0.815 Inexact Rounded
+pwsx4198 power 0.0665 0.5 -> 0.258 Inexact Rounded
+pwsx4199 power 0.666 0.5 -> 0.816 Inexact Rounded
+pwsx4200 power 0.0666 0.5 -> 0.258 Inexact Rounded
+pwsx4201 power 0.667 0.5 -> 0.817 Inexact Rounded
+pwsx4202 power 0.0667 0.5 -> 0.258 Inexact Rounded
+pwsx4203 power 0.668 0.5 -> 0.817 Inexact Rounded
+pwsx4204 power 0.0668 0.5 -> 0.258 Inexact Rounded
+pwsx4205 power 0.669 0.5 -> 0.818 Inexact Rounded
+pwsx4206 power 0.0669 0.5 -> 0.259 Inexact Rounded
+pwsx4207 power 0.671 0.5 -> 0.819 Inexact Rounded
+pwsx4208 power 0.0671 0.5 -> 0.259 Inexact Rounded
+pwsx4209 power 0.672 0.5 -> 0.820 Inexact Rounded
+pwsx4210 power 0.0672 0.5 -> 0.259 Inexact Rounded
+pwsx4211 power 0.673 0.5 -> 0.820 Inexact Rounded
+pwsx4212 power 0.0673 0.5 -> 0.259 Inexact Rounded
+pwsx4213 power 0.674 0.5 -> 0.821 Inexact Rounded
+pwsx4214 power 0.0674 0.5 -> 0.260 Inexact Rounded
+pwsx4215 power 0.675 0.5 -> 0.822 Inexact Rounded
+pwsx4216 power 0.0675 0.5 -> 0.260 Inexact Rounded
+pwsx4217 power 0.676 0.5 -> 0.822 Inexact Rounded
+pwsx4218 power 0.0676 0.5 -> 0.260 Inexact Rounded
+pwsx4219 power 0.677 0.5 -> 0.823 Inexact Rounded
+pwsx4220 power 0.0677 0.5 -> 0.260 Inexact Rounded
+pwsx4221 power 0.678 0.5 -> 0.823 Inexact Rounded
+pwsx4222 power 0.0678 0.5 -> 0.260 Inexact Rounded
+pwsx4223 power 0.679 0.5 -> 0.824 Inexact Rounded
+pwsx4224 power 0.0679 0.5 -> 0.261 Inexact Rounded
+pwsx4225 power 0.681 0.5 -> 0.825 Inexact Rounded
+pwsx4226 power 0.0681 0.5 -> 0.261 Inexact Rounded
+pwsx4227 power 0.682 0.5 -> 0.826 Inexact Rounded
+pwsx4228 power 0.0682 0.5 -> 0.261 Inexact Rounded
+pwsx4229 power 0.683 0.5 -> 0.826 Inexact Rounded
+pwsx4230 power 0.0683 0.5 -> 0.261 Inexact Rounded
+pwsx4231 power 0.684 0.5 -> 0.827 Inexact Rounded
+pwsx4232 power 0.0684 0.5 -> 0.262 Inexact Rounded
+pwsx4233 power 0.685 0.5 -> 0.828 Inexact Rounded
+pwsx4234 power 0.0685 0.5 -> 0.262 Inexact Rounded
+pwsx4235 power 0.686 0.5 -> 0.828 Inexact Rounded
+pwsx4236 power 0.0686 0.5 -> 0.262 Inexact Rounded
+pwsx4237 power 0.687 0.5 -> 0.829 Inexact Rounded
+pwsx4238 power 0.0687 0.5 -> 0.262 Inexact Rounded
+pwsx4239 power 0.688 0.5 -> 0.829 Inexact Rounded
+pwsx4240 power 0.0688 0.5 -> 0.262 Inexact Rounded
+pwsx4241 power 0.689 0.5 -> 0.830 Inexact Rounded
+pwsx4242 power 0.0689 0.5 -> 0.262 Inexact Rounded
+pwsx4243 power 0.691 0.5 -> 0.831 Inexact Rounded
+pwsx4244 power 0.0691 0.5 -> 0.263 Inexact Rounded
+pwsx4245 power 0.692 0.5 -> 0.832 Inexact Rounded
+pwsx4246 power 0.0692 0.5 -> 0.263 Inexact Rounded
+pwsx4247 power 0.693 0.5 -> 0.832 Inexact Rounded
+pwsx4248 power 0.0693 0.5 -> 0.263 Inexact Rounded
+pwsx4249 power 0.694 0.5 -> 0.833 Inexact Rounded
+pwsx4250 power 0.0694 0.5 -> 0.263 Inexact Rounded
+pwsx4251 power 0.695 0.5 -> 0.834 Inexact Rounded
+pwsx4252 power 0.0695 0.5 -> 0.264 Inexact Rounded
+pwsx4253 power 0.696 0.5 -> 0.834 Inexact Rounded
+pwsx4254 power 0.0696 0.5 -> 0.264 Inexact Rounded
+pwsx4255 power 0.697 0.5 -> 0.835 Inexact Rounded
+pwsx4256 power 0.0697 0.5 -> 0.264 Inexact Rounded
+pwsx4257 power 0.698 0.5 -> 0.835 Inexact Rounded
+pwsx4258 power 0.0698 0.5 -> 0.264 Inexact Rounded
+pwsx4259 power 0.699 0.5 -> 0.836 Inexact Rounded
+pwsx4260 power 0.0699 0.5 -> 0.264 Inexact Rounded
+pwsx4261 power 0.701 0.5 -> 0.837 Inexact Rounded
+pwsx4262 power 0.0701 0.5 -> 0.265 Inexact Rounded
+pwsx4263 power 0.702 0.5 -> 0.838 Inexact Rounded
+pwsx4264 power 0.0702 0.5 -> 0.265 Inexact Rounded
+pwsx4265 power 0.703 0.5 -> 0.838 Inexact Rounded
+pwsx4266 power 0.0703 0.5 -> 0.265 Inexact Rounded
+pwsx4267 power 0.704 0.5 -> 0.839 Inexact Rounded
+pwsx4268 power 0.0704 0.5 -> 0.265 Inexact Rounded
+pwsx4269 power 0.705 0.5 -> 0.840 Inexact Rounded
+pwsx4270 power 0.0705 0.5 -> 0.266 Inexact Rounded
+pwsx4271 power 0.706 0.5 -> 0.840 Inexact Rounded
+pwsx4272 power 0.0706 0.5 -> 0.266 Inexact Rounded
+pwsx4273 power 0.707 0.5 -> 0.841 Inexact Rounded
+pwsx4274 power 0.0707 0.5 -> 0.266 Inexact Rounded
+pwsx4275 power 0.708 0.5 -> 0.841 Inexact Rounded
+pwsx4276 power 0.0708 0.5 -> 0.266 Inexact Rounded
+pwsx4277 power 0.709 0.5 -> 0.842 Inexact Rounded
+pwsx4278 power 0.0709 0.5 -> 0.266 Inexact Rounded
+pwsx4279 power 0.711 0.5 -> 0.843 Inexact Rounded
+pwsx4280 power 0.0711 0.5 -> 0.267 Inexact Rounded
+pwsx4281 power 0.712 0.5 -> 0.844 Inexact Rounded
+pwsx4282 power 0.0712 0.5 -> 0.267 Inexact Rounded
+pwsx4283 power 0.713 0.5 -> 0.844 Inexact Rounded
+pwsx4284 power 0.0713 0.5 -> 0.267 Inexact Rounded
+pwsx4285 power 0.714 0.5 -> 0.845 Inexact Rounded
+pwsx4286 power 0.0714 0.5 -> 0.267 Inexact Rounded
+pwsx4287 power 0.715 0.5 -> 0.846 Inexact Rounded
+pwsx4288 power 0.0715 0.5 -> 0.267 Inexact Rounded
+pwsx4289 power 0.716 0.5 -> 0.846 Inexact Rounded
+pwsx4290 power 0.0716 0.5 -> 0.268 Inexact Rounded
+pwsx4291 power 0.717 0.5 -> 0.847 Inexact Rounded
+pwsx4292 power 0.0717 0.5 -> 0.268 Inexact Rounded
+pwsx4293 power 0.718 0.5 -> 0.847 Inexact Rounded
+pwsx4294 power 0.0718 0.5 -> 0.268 Inexact Rounded
+pwsx4295 power 0.719 0.5 -> 0.848 Inexact Rounded
+pwsx4296 power 0.0719 0.5 -> 0.268 Inexact Rounded
+pwsx4297 power 0.721 0.5 -> 0.849 Inexact Rounded
+pwsx4298 power 0.0721 0.5 -> 0.269 Inexact Rounded
+pwsx4299 power 0.722 0.5 -> 0.850 Inexact Rounded
+pwsx4300 power 0.0722 0.5 -> 0.269 Inexact Rounded
+pwsx4301 power 0.723 0.5 -> 0.850 Inexact Rounded
+pwsx4302 power 0.0723 0.5 -> 0.269 Inexact Rounded
+pwsx4303 power 0.724 0.5 -> 0.851 Inexact Rounded
+pwsx4304 power 0.0724 0.5 -> 0.269 Inexact Rounded
+pwsx4305 power 0.725 0.5 -> 0.851 Inexact Rounded
+pwsx4306 power 0.0725 0.5 -> 0.269 Inexact Rounded
+pwsx4307 power 0.726 0.5 -> 0.852 Inexact Rounded
+pwsx4308 power 0.0726 0.5 -> 0.269 Inexact Rounded
+pwsx4309 power 0.727 0.5 -> 0.853 Inexact Rounded
+pwsx4310 power 0.0727 0.5 -> 0.270 Inexact Rounded
+pwsx4311 power 0.728 0.5 -> 0.853 Inexact Rounded
+pwsx4312 power 0.0728 0.5 -> 0.270 Inexact Rounded
+pwsx4313 power 0.729 0.5 -> 0.854 Inexact Rounded
+pwsx4314 power 0.0729 0.5 -> 0.270 Inexact Rounded
+pwsx4315 power 0.731 0.5 -> 0.855 Inexact Rounded
+pwsx4316 power 0.0731 0.5 -> 0.270 Inexact Rounded
+pwsx4317 power 0.732 0.5 -> 0.856 Inexact Rounded
+pwsx4318 power 0.0732 0.5 -> 0.271 Inexact Rounded
+pwsx4319 power 0.733 0.5 -> 0.856 Inexact Rounded
+pwsx4320 power 0.0733 0.5 -> 0.271 Inexact Rounded
+pwsx4321 power 0.734 0.5 -> 0.857 Inexact Rounded
+pwsx4322 power 0.0734 0.5 -> 0.271 Inexact Rounded
+pwsx4323 power 0.735 0.5 -> 0.857 Inexact Rounded
+pwsx4324 power 0.0735 0.5 -> 0.271 Inexact Rounded
+pwsx4325 power 0.736 0.5 -> 0.858 Inexact Rounded
+pwsx4326 power 0.0736 0.5 -> 0.271 Inexact Rounded
+pwsx4327 power 0.737 0.5 -> 0.858 Inexact Rounded
+pwsx4328 power 0.0737 0.5 -> 0.271 Inexact Rounded
+pwsx4329 power 0.738 0.5 -> 0.859 Inexact Rounded
+pwsx4330 power 0.0738 0.5 -> 0.272 Inexact Rounded
+pwsx4331 power 0.739 0.5 -> 0.860 Inexact Rounded
+pwsx4332 power 0.0739 0.5 -> 0.272 Inexact Rounded
+pwsx4333 power 0.741 0.5 -> 0.861 Inexact Rounded
+pwsx4334 power 0.0741 0.5 -> 0.272 Inexact Rounded
+pwsx4335 power 0.742 0.5 -> 0.861 Inexact Rounded
+pwsx4336 power 0.0742 0.5 -> 0.272 Inexact Rounded
+pwsx4337 power 0.743 0.5 -> 0.862 Inexact Rounded
+pwsx4338 power 0.0743 0.5 -> 0.273 Inexact Rounded
+pwsx4339 power 0.744 0.5 -> 0.863 Inexact Rounded
+pwsx4340 power 0.0744 0.5 -> 0.273 Inexact Rounded
+pwsx4341 power 0.745 0.5 -> 0.863 Inexact Rounded
+pwsx4342 power 0.0745 0.5 -> 0.273 Inexact Rounded
+pwsx4343 power 0.746 0.5 -> 0.864 Inexact Rounded
+pwsx4344 power 0.0746 0.5 -> 0.273 Inexact Rounded
+pwsx4345 power 0.747 0.5 -> 0.864 Inexact Rounded
+pwsx4346 power 0.0747 0.5 -> 0.273 Inexact Rounded
+pwsx4347 power 0.748 0.5 -> 0.865 Inexact Rounded
+pwsx4348 power 0.0748 0.5 -> 0.273 Inexact Rounded
+pwsx4349 power 0.749 0.5 -> 0.865 Inexact Rounded
+pwsx4350 power 0.0749 0.5 -> 0.274 Inexact Rounded
+pwsx4351 power 0.751 0.5 -> 0.867 Inexact Rounded
+pwsx4352 power 0.0751 0.5 -> 0.274 Inexact Rounded
+pwsx4353 power 0.752 0.5 -> 0.867 Inexact Rounded
+pwsx4354 power 0.0752 0.5 -> 0.274 Inexact Rounded
+pwsx4355 power 0.753 0.5 -> 0.868 Inexact Rounded
+pwsx4356 power 0.0753 0.5 -> 0.274 Inexact Rounded
+pwsx4357 power 0.754 0.5 -> 0.868 Inexact Rounded
+pwsx4358 power 0.0754 0.5 -> 0.275 Inexact Rounded
+pwsx4359 power 0.755 0.5 -> 0.869 Inexact Rounded
+pwsx4360 power 0.0755 0.5 -> 0.275 Inexact Rounded
+pwsx4361 power 0.756 0.5 -> 0.869 Inexact Rounded
+pwsx4362 power 0.0756 0.5 -> 0.275 Inexact Rounded
+pwsx4363 power 0.757 0.5 -> 0.870 Inexact Rounded
+pwsx4364 power 0.0757 0.5 -> 0.275 Inexact Rounded
+pwsx4365 power 0.758 0.5 -> 0.871 Inexact Rounded
+pwsx4366 power 0.0758 0.5 -> 0.275 Inexact Rounded
+pwsx4367 power 0.759 0.5 -> 0.871 Inexact Rounded
+pwsx4368 power 0.0759 0.5 -> 0.275 Inexact Rounded
+pwsx4369 power 0.761 0.5 -> 0.872 Inexact Rounded
+pwsx4370 power 0.0761 0.5 -> 0.276 Inexact Rounded
+pwsx4371 power 0.762 0.5 -> 0.873 Inexact Rounded
+pwsx4372 power 0.0762 0.5 -> 0.276 Inexact Rounded
+pwsx4373 power 0.763 0.5 -> 0.873 Inexact Rounded
+pwsx4374 power 0.0763 0.5 -> 0.276 Inexact Rounded
+pwsx4375 power 0.764 0.5 -> 0.874 Inexact Rounded
+pwsx4376 power 0.0764 0.5 -> 0.276 Inexact Rounded
+pwsx4377 power 0.765 0.5 -> 0.875 Inexact Rounded
+pwsx4378 power 0.0765 0.5 -> 0.277 Inexact Rounded
+pwsx4379 power 0.766 0.5 -> 0.875 Inexact Rounded
+pwsx4380 power 0.0766 0.5 -> 0.277 Inexact Rounded
+pwsx4381 power 0.767 0.5 -> 0.876 Inexact Rounded
+pwsx4382 power 0.0767 0.5 -> 0.277 Inexact Rounded
+pwsx4383 power 0.768 0.5 -> 0.876 Inexact Rounded
+pwsx4384 power 0.0768 0.5 -> 0.277 Inexact Rounded
+pwsx4385 power 0.769 0.5 -> 0.877 Inexact Rounded
+pwsx4386 power 0.0769 0.5 -> 0.277 Inexact Rounded
+pwsx4387 power 0.771 0.5 -> 0.878 Inexact Rounded
+pwsx4388 power 0.0771 0.5 -> 0.278 Inexact Rounded
+pwsx4389 power 0.772 0.5 -> 0.879 Inexact Rounded
+pwsx4390 power 0.0772 0.5 -> 0.278 Inexact Rounded
+pwsx4391 power 0.773 0.5 -> 0.879 Inexact Rounded
+pwsx4392 power 0.0773 0.5 -> 0.278 Inexact Rounded
+pwsx4393 power 0.774 0.5 -> 0.880 Inexact Rounded
+pwsx4394 power 0.0774 0.5 -> 0.278 Inexact Rounded
+pwsx4395 power 0.775 0.5 -> 0.880 Inexact Rounded
+pwsx4396 power 0.0775 0.5 -> 0.278 Inexact Rounded
+pwsx4397 power 0.776 0.5 -> 0.881 Inexact Rounded
+pwsx4398 power 0.0776 0.5 -> 0.279 Inexact Rounded
+pwsx4399 power 0.777 0.5 -> 0.881 Inexact Rounded
+pwsx4400 power 0.0777 0.5 -> 0.279 Inexact Rounded
+pwsx4401 power 0.778 0.5 -> 0.882 Inexact Rounded
+pwsx4402 power 0.0778 0.5 -> 0.279 Inexact Rounded
+pwsx4403 power 0.779 0.5 -> 0.883 Inexact Rounded
+pwsx4404 power 0.0779 0.5 -> 0.279 Inexact Rounded
+pwsx4405 power 0.781 0.5 -> 0.884 Inexact Rounded
+pwsx4406 power 0.0781 0.5 -> 0.279 Inexact Rounded
+pwsx4407 power 0.782 0.5 -> 0.884 Inexact Rounded
+pwsx4408 power 0.0782 0.5 -> 0.280 Inexact Rounded
+pwsx4409 power 0.783 0.5 -> 0.885 Inexact Rounded
+pwsx4410 power 0.0783 0.5 -> 0.280 Inexact Rounded
+pwsx4411 power 0.784 0.5 -> 0.885 Inexact Rounded
+pwsx4412 power 0.0784 0.5 -> 0.280 Inexact Rounded
+pwsx4413 power 0.785 0.5 -> 0.886 Inexact Rounded
+pwsx4414 power 0.0785 0.5 -> 0.280 Inexact Rounded
+pwsx4415 power 0.786 0.5 -> 0.887 Inexact Rounded
+pwsx4416 power 0.0786 0.5 -> 0.280 Inexact Rounded
+pwsx4417 power 0.787 0.5 -> 0.887 Inexact Rounded
+pwsx4418 power 0.0787 0.5 -> 0.281 Inexact Rounded
+pwsx4419 power 0.788 0.5 -> 0.888 Inexact Rounded
+pwsx4420 power 0.0788 0.5 -> 0.281 Inexact Rounded
+pwsx4421 power 0.789 0.5 -> 0.888 Inexact Rounded
+pwsx4422 power 0.0789 0.5 -> 0.281 Inexact Rounded
+pwsx4423 power 0.791 0.5 -> 0.889 Inexact Rounded
+pwsx4424 power 0.0791 0.5 -> 0.281 Inexact Rounded
+pwsx4425 power 0.792 0.5 -> 0.890 Inexact Rounded
+pwsx4426 power 0.0792 0.5 -> 0.281 Inexact Rounded
+pwsx4427 power 0.793 0.5 -> 0.891 Inexact Rounded
+pwsx4428 power 0.0793 0.5 -> 0.282 Inexact Rounded
+pwsx4429 power 0.794 0.5 -> 0.891 Inexact Rounded
+pwsx4430 power 0.0794 0.5 -> 0.282 Inexact Rounded
+pwsx4431 power 0.795 0.5 -> 0.892 Inexact Rounded
+pwsx4432 power 0.0795 0.5 -> 0.282 Inexact Rounded
+pwsx4433 power 0.796 0.5 -> 0.892 Inexact Rounded
+pwsx4434 power 0.0796 0.5 -> 0.282 Inexact Rounded
+pwsx4435 power 0.797 0.5 -> 0.893 Inexact Rounded
+pwsx4436 power 0.0797 0.5 -> 0.282 Inexact Rounded
+pwsx4437 power 0.798 0.5 -> 0.893 Inexact Rounded
+pwsx4438 power 0.0798 0.5 -> 0.282 Inexact Rounded
+pwsx4439 power 0.799 0.5 -> 0.894 Inexact Rounded
+pwsx4440 power 0.0799 0.5 -> 0.283 Inexact Rounded
+pwsx4441 power 0.801 0.5 -> 0.895 Inexact Rounded
+pwsx4442 power 0.0801 0.5 -> 0.283 Inexact Rounded
+pwsx4443 power 0.802 0.5 -> 0.896 Inexact Rounded
+pwsx4444 power 0.0802 0.5 -> 0.283 Inexact Rounded
+pwsx4445 power 0.803 0.5 -> 0.896 Inexact Rounded
+pwsx4446 power 0.0803 0.5 -> 0.283 Inexact Rounded
+pwsx4447 power 0.804 0.5 -> 0.897 Inexact Rounded
+pwsx4448 power 0.0804 0.5 -> 0.284 Inexact Rounded
+pwsx4449 power 0.805 0.5 -> 0.897 Inexact Rounded
+pwsx4450 power 0.0805 0.5 -> 0.284 Inexact Rounded
+pwsx4451 power 0.806 0.5 -> 0.898 Inexact Rounded
+pwsx4452 power 0.0806 0.5 -> 0.284 Inexact Rounded
+pwsx4453 power 0.807 0.5 -> 0.898 Inexact Rounded
+pwsx4454 power 0.0807 0.5 -> 0.284 Inexact Rounded
+pwsx4455 power 0.808 0.5 -> 0.899 Inexact Rounded
+pwsx4456 power 0.0808 0.5 -> 0.284 Inexact Rounded
+pwsx4457 power 0.809 0.5 -> 0.899 Inexact Rounded
+pwsx4458 power 0.0809 0.5 -> 0.284 Inexact Rounded
+pwsx4459 power 0.811 0.5 -> 0.901 Inexact Rounded
+pwsx4460 power 0.0811 0.5 -> 0.285 Inexact Rounded
+pwsx4461 power 0.812 0.5 -> 0.901 Inexact Rounded
+pwsx4462 power 0.0812 0.5 -> 0.285 Inexact Rounded
+pwsx4463 power 0.813 0.5 -> 0.902 Inexact Rounded
+pwsx4464 power 0.0813 0.5 -> 0.285 Inexact Rounded
+pwsx4465 power 0.814 0.5 -> 0.902 Inexact Rounded
+pwsx4466 power 0.0814 0.5 -> 0.285 Inexact Rounded
+pwsx4467 power 0.815 0.5 -> 0.903 Inexact Rounded
+pwsx4468 power 0.0815 0.5 -> 0.285 Inexact Rounded
+pwsx4469 power 0.816 0.5 -> 0.903 Inexact Rounded
+pwsx4470 power 0.0816 0.5 -> 0.286 Inexact Rounded
+pwsx4471 power 0.817 0.5 -> 0.904 Inexact Rounded
+pwsx4472 power 0.0817 0.5 -> 0.286 Inexact Rounded
+pwsx4473 power 0.818 0.5 -> 0.904 Inexact Rounded
+pwsx4474 power 0.0818 0.5 -> 0.286 Inexact Rounded
+pwsx4475 power 0.819 0.5 -> 0.905 Inexact Rounded
+pwsx4476 power 0.0819 0.5 -> 0.286 Inexact Rounded
+pwsx4477 power 0.821 0.5 -> 0.906 Inexact Rounded
+pwsx4478 power 0.0821 0.5 -> 0.287 Inexact Rounded
+pwsx4479 power 0.822 0.5 -> 0.907 Inexact Rounded
+pwsx4480 power 0.0822 0.5 -> 0.287 Inexact Rounded
+pwsx4481 power 0.823 0.5 -> 0.907 Inexact Rounded
+pwsx4482 power 0.0823 0.5 -> 0.287 Inexact Rounded
+pwsx4483 power 0.824 0.5 -> 0.908 Inexact Rounded
+pwsx4484 power 0.0824 0.5 -> 0.287 Inexact Rounded
+pwsx4485 power 0.825 0.5 -> 0.908 Inexact Rounded
+pwsx4486 power 0.0825 0.5 -> 0.287 Inexact Rounded
+pwsx4487 power 0.826 0.5 -> 0.909 Inexact Rounded
+pwsx4488 power 0.0826 0.5 -> 0.287 Inexact Rounded
+pwsx4489 power 0.827 0.5 -> 0.909 Inexact Rounded
+pwsx4490 power 0.0827 0.5 -> 0.288 Inexact Rounded
+pwsx4491 power 0.828 0.5 -> 0.910 Inexact Rounded
+pwsx4492 power 0.0828 0.5 -> 0.288 Inexact Rounded
+pwsx4493 power 0.829 0.5 -> 0.910 Inexact Rounded
+pwsx4494 power 0.0829 0.5 -> 0.288 Inexact Rounded
+pwsx4495 power 0.831 0.5 -> 0.912 Inexact Rounded
+pwsx4496 power 0.0831 0.5 -> 0.288 Inexact Rounded
+pwsx4497 power 0.832 0.5 -> 0.912 Inexact Rounded
+pwsx4498 power 0.0832 0.5 -> 0.288 Inexact Rounded
+pwsx4499 power 0.833 0.5 -> 0.913 Inexact Rounded
+pwsx4500 power 0.0833 0.5 -> 0.289 Inexact Rounded
+pwsx4501 power 0.834 0.5 -> 0.913 Inexact Rounded
+pwsx4502 power 0.0834 0.5 -> 0.289 Inexact Rounded
+pwsx4503 power 0.835 0.5 -> 0.914 Inexact Rounded
+pwsx4504 power 0.0835 0.5 -> 0.289 Inexact Rounded
+pwsx4505 power 0.836 0.5 -> 0.914 Inexact Rounded
+pwsx4506 power 0.0836 0.5 -> 0.289 Inexact Rounded
+pwsx4507 power 0.837 0.5 -> 0.915 Inexact Rounded
+pwsx4508 power 0.0837 0.5 -> 0.289 Inexact Rounded
+pwsx4509 power 0.838 0.5 -> 0.915 Inexact Rounded
+pwsx4510 power 0.0838 0.5 -> 0.289 Inexact Rounded
+pwsx4511 power 0.839 0.5 -> 0.916 Inexact Rounded
+pwsx4512 power 0.0839 0.5 -> 0.290 Inexact Rounded
+pwsx4513 power 0.841 0.5 -> 0.917 Inexact Rounded
+pwsx4514 power 0.0841 0.5 -> 0.290 Inexact Rounded
+pwsx4515 power 0.842 0.5 -> 0.918 Inexact Rounded
+pwsx4516 power 0.0842 0.5 -> 0.290 Inexact Rounded
+pwsx4517 power 0.843 0.5 -> 0.918 Inexact Rounded
+pwsx4518 power 0.0843 0.5 -> 0.290 Inexact Rounded
+pwsx4519 power 0.844 0.5 -> 0.919 Inexact Rounded
+pwsx4520 power 0.0844 0.5 -> 0.291 Inexact Rounded
+pwsx4521 power 0.845 0.5 -> 0.919 Inexact Rounded
+pwsx4522 power 0.0845 0.5 -> 0.291 Inexact Rounded
+pwsx4523 power 0.846 0.5 -> 0.920 Inexact Rounded
+pwsx4524 power 0.0846 0.5 -> 0.291 Inexact Rounded
+pwsx4525 power 0.847 0.5 -> 0.920 Inexact Rounded
+pwsx4526 power 0.0847 0.5 -> 0.291 Inexact Rounded
+pwsx4527 power 0.848 0.5 -> 0.921 Inexact Rounded
+pwsx4528 power 0.0848 0.5 -> 0.291 Inexact Rounded
+pwsx4529 power 0.849 0.5 -> 0.921 Inexact Rounded
+pwsx4530 power 0.0849 0.5 -> 0.291 Inexact Rounded
+pwsx4531 power 0.851 0.5 -> 0.922 Inexact Rounded
+pwsx4532 power 0.0851 0.5 -> 0.292 Inexact Rounded
+pwsx4533 power 0.852 0.5 -> 0.923 Inexact Rounded
+pwsx4534 power 0.0852 0.5 -> 0.292 Inexact Rounded
+pwsx4535 power 0.853 0.5 -> 0.924 Inexact Rounded
+pwsx4536 power 0.0853 0.5 -> 0.292 Inexact Rounded
+pwsx4537 power 0.854 0.5 -> 0.924 Inexact Rounded
+pwsx4538 power 0.0854 0.5 -> 0.292 Inexact Rounded
+pwsx4539 power 0.855 0.5 -> 0.925 Inexact Rounded
+pwsx4540 power 0.0855 0.5 -> 0.292 Inexact Rounded
+pwsx4541 power 0.856 0.5 -> 0.925 Inexact Rounded
+pwsx4542 power 0.0856 0.5 -> 0.293 Inexact Rounded
+pwsx4543 power 0.857 0.5 -> 0.926 Inexact Rounded
+pwsx4544 power 0.0857 0.5 -> 0.293 Inexact Rounded
+pwsx4545 power 0.858 0.5 -> 0.926 Inexact Rounded
+pwsx4546 power 0.0858 0.5 -> 0.293 Inexact Rounded
+pwsx4547 power 0.859 0.5 -> 0.927 Inexact Rounded
+pwsx4548 power 0.0859 0.5 -> 0.293 Inexact Rounded
+pwsx4549 power 0.861 0.5 -> 0.928 Inexact Rounded
+pwsx4550 power 0.0861 0.5 -> 0.293 Inexact Rounded
+pwsx4551 power 0.862 0.5 -> 0.928 Inexact Rounded
+pwsx4552 power 0.0862 0.5 -> 0.294 Inexact Rounded
+pwsx4553 power 0.863 0.5 -> 0.929 Inexact Rounded
+pwsx4554 power 0.0863 0.5 -> 0.294 Inexact Rounded
+pwsx4555 power 0.864 0.5 -> 0.930 Inexact Rounded
+pwsx4556 power 0.0864 0.5 -> 0.294 Inexact Rounded
+pwsx4557 power 0.865 0.5 -> 0.930 Inexact Rounded
+pwsx4558 power 0.0865 0.5 -> 0.294 Inexact Rounded
+pwsx4559 power 0.866 0.5 -> 0.931 Inexact Rounded
+pwsx4560 power 0.0866 0.5 -> 0.294 Inexact Rounded
+pwsx4561 power 0.867 0.5 -> 0.931 Inexact Rounded
+pwsx4562 power 0.0867 0.5 -> 0.294 Inexact Rounded
+pwsx4563 power 0.868 0.5 -> 0.932 Inexact Rounded
+pwsx4564 power 0.0868 0.5 -> 0.295 Inexact Rounded
+pwsx4565 power 0.869 0.5 -> 0.932 Inexact Rounded
+pwsx4566 power 0.0869 0.5 -> 0.295 Inexact Rounded
+pwsx4567 power 0.871 0.5 -> 0.933 Inexact Rounded
+pwsx4568 power 0.0871 0.5 -> 0.295 Inexact Rounded
+pwsx4569 power 0.872 0.5 -> 0.934 Inexact Rounded
+pwsx4570 power 0.0872 0.5 -> 0.295 Inexact Rounded
+pwsx4571 power 0.873 0.5 -> 0.934 Inexact Rounded
+pwsx4572 power 0.0873 0.5 -> 0.295 Inexact Rounded
+pwsx4573 power 0.874 0.5 -> 0.935 Inexact Rounded
+pwsx4574 power 0.0874 0.5 -> 0.296 Inexact Rounded
+pwsx4575 power 0.875 0.5 -> 0.935 Inexact Rounded
+pwsx4576 power 0.0875 0.5 -> 0.296 Inexact Rounded
+pwsx4577 power 0.876 0.5 -> 0.936 Inexact Rounded
+pwsx4578 power 0.0876 0.5 -> 0.296 Inexact Rounded
+pwsx4579 power 0.877 0.5 -> 0.936 Inexact Rounded
+pwsx4580 power 0.0877 0.5 -> 0.296 Inexact Rounded
+pwsx4581 power 0.878 0.5 -> 0.937 Inexact Rounded
+pwsx4582 power 0.0878 0.5 -> 0.296 Inexact Rounded
+pwsx4583 power 0.879 0.5 -> 0.938 Inexact Rounded
+pwsx4584 power 0.0879 0.5 -> 0.296 Inexact Rounded
+pwsx4585 power 0.881 0.5 -> 0.939 Inexact Rounded
+pwsx4586 power 0.0881 0.5 -> 0.297 Inexact Rounded
+pwsx4587 power 0.882 0.5 -> 0.939 Inexact Rounded
+pwsx4588 power 0.0882 0.5 -> 0.297 Inexact Rounded
+pwsx4589 power 0.883 0.5 -> 0.940 Inexact Rounded
+pwsx4590 power 0.0883 0.5 -> 0.297 Inexact Rounded
+pwsx4591 power 0.884 0.5 -> 0.940 Inexact Rounded
+pwsx4592 power 0.0884 0.5 -> 0.297 Inexact Rounded
+pwsx4593 power 0.885 0.5 -> 0.941 Inexact Rounded
+pwsx4594 power 0.0885 0.5 -> 0.297 Inexact Rounded
+pwsx4595 power 0.886 0.5 -> 0.941 Inexact Rounded
+pwsx4596 power 0.0886 0.5 -> 0.298 Inexact Rounded
+pwsx4597 power 0.887 0.5 -> 0.942 Inexact Rounded
+pwsx4598 power 0.0887 0.5 -> 0.298 Inexact Rounded
+pwsx4599 power 0.888 0.5 -> 0.942 Inexact Rounded
+pwsx4600 power 0.0888 0.5 -> 0.298 Inexact Rounded
+pwsx4601 power 0.889 0.5 -> 0.943 Inexact Rounded
+pwsx4602 power 0.0889 0.5 -> 0.298 Inexact Rounded
+pwsx4603 power 0.891 0.5 -> 0.944 Inexact Rounded
+pwsx4604 power 0.0891 0.5 -> 0.298 Inexact Rounded
+pwsx4605 power 0.892 0.5 -> 0.944 Inexact Rounded
+pwsx4606 power 0.0892 0.5 -> 0.299 Inexact Rounded
+pwsx4607 power 0.893 0.5 -> 0.945 Inexact Rounded
+pwsx4608 power 0.0893 0.5 -> 0.299 Inexact Rounded
+pwsx4609 power 0.894 0.5 -> 0.946 Inexact Rounded
+pwsx4610 power 0.0894 0.5 -> 0.299 Inexact Rounded
+pwsx4611 power 0.895 0.5 -> 0.946 Inexact Rounded
+pwsx4612 power 0.0895 0.5 -> 0.299 Inexact Rounded
+pwsx4613 power 0.896 0.5 -> 0.947 Inexact Rounded
+pwsx4614 power 0.0896 0.5 -> 0.299 Inexact Rounded
+pwsx4615 power 0.897 0.5 -> 0.947 Inexact Rounded
+pwsx4616 power 0.0897 0.5 -> 0.299 Inexact Rounded
+pwsx4617 power 0.898 0.5 -> 0.948 Inexact Rounded
+pwsx4618 power 0.0898 0.5 -> 0.300 Inexact Rounded
+pwsx4619 power 0.899 0.5 -> 0.948 Inexact Rounded
+pwsx4620 power 0.0899 0.5 -> 0.300 Inexact Rounded
+pwsx4621 power 0.901 0.5 -> 0.949 Inexact Rounded
+pwsx4622 power 0.0901 0.5 -> 0.300 Inexact Rounded
+pwsx4623 power 0.902 0.5 -> 0.950 Inexact Rounded
+pwsx4624 power 0.0902 0.5 -> 0.300 Inexact Rounded
+pwsx4625 power 0.903 0.5 -> 0.950 Inexact Rounded
+pwsx4626 power 0.0903 0.5 -> 0.300 Inexact Rounded
+pwsx4627 power 0.904 0.5 -> 0.951 Inexact Rounded
+pwsx4628 power 0.0904 0.5 -> 0.301 Inexact Rounded
+pwsx4629 power 0.905 0.5 -> 0.951 Inexact Rounded
+pwsx4630 power 0.0905 0.5 -> 0.301 Inexact Rounded
+pwsx4631 power 0.906 0.5 -> 0.952 Inexact Rounded
+pwsx4632 power 0.0906 0.5 -> 0.301 Inexact Rounded
+pwsx4633 power 0.907 0.5 -> 0.952 Inexact Rounded
+pwsx4634 power 0.0907 0.5 -> 0.301 Inexact Rounded
+pwsx4635 power 0.908 0.5 -> 0.953 Inexact Rounded
+pwsx4636 power 0.0908 0.5 -> 0.301 Inexact Rounded
+pwsx4637 power 0.909 0.5 -> 0.953 Inexact Rounded
+pwsx4638 power 0.0909 0.5 -> 0.301 Inexact Rounded
+pwsx4639 power 0.911 0.5 -> 0.954 Inexact Rounded
+pwsx4640 power 0.0911 0.5 -> 0.302 Inexact Rounded
+pwsx4641 power 0.912 0.5 -> 0.955 Inexact Rounded
+pwsx4642 power 0.0912 0.5 -> 0.302 Inexact Rounded
+pwsx4643 power 0.913 0.5 -> 0.956 Inexact Rounded
+pwsx4644 power 0.0913 0.5 -> 0.302 Inexact Rounded
+pwsx4645 power 0.914 0.5 -> 0.956 Inexact Rounded
+pwsx4646 power 0.0914 0.5 -> 0.302 Inexact Rounded
+pwsx4647 power 0.915 0.5 -> 0.957 Inexact Rounded
+pwsx4648 power 0.0915 0.5 -> 0.302 Inexact Rounded
+pwsx4649 power 0.916 0.5 -> 0.957 Inexact Rounded
+pwsx4650 power 0.0916 0.5 -> 0.303 Inexact Rounded
+pwsx4651 power 0.917 0.5 -> 0.958 Inexact Rounded
+pwsx4652 power 0.0917 0.5 -> 0.303 Inexact Rounded
+pwsx4653 power 0.918 0.5 -> 0.958 Inexact Rounded
+pwsx4654 power 0.0918 0.5 -> 0.303 Inexact Rounded
+pwsx4655 power 0.919 0.5 -> 0.959 Inexact Rounded
+pwsx4656 power 0.0919 0.5 -> 0.303 Inexact Rounded
+pwsx4657 power 0.921 0.5 -> 0.960 Inexact Rounded
+pwsx4658 power 0.0921 0.5 -> 0.303 Inexact Rounded
+pwsx4659 power 0.922 0.5 -> 0.960 Inexact Rounded
+pwsx4660 power 0.0922 0.5 -> 0.304 Inexact Rounded
+pwsx4661 power 0.923 0.5 -> 0.961 Inexact Rounded
+pwsx4662 power 0.0923 0.5 -> 0.304 Inexact Rounded
+pwsx4663 power 0.924 0.5 -> 0.961 Inexact Rounded
+pwsx4664 power 0.0924 0.5 -> 0.304 Inexact Rounded
+pwsx4665 power 0.925 0.5 -> 0.962 Inexact Rounded
+pwsx4666 power 0.0925 0.5 -> 0.304 Inexact Rounded
+pwsx4667 power 0.926 0.5 -> 0.962 Inexact Rounded
+pwsx4668 power 0.0926 0.5 -> 0.304 Inexact Rounded
+pwsx4669 power 0.927 0.5 -> 0.963 Inexact Rounded
+pwsx4670 power 0.0927 0.5 -> 0.304 Inexact Rounded
+pwsx4671 power 0.928 0.5 -> 0.963 Inexact Rounded
+pwsx4672 power 0.0928 0.5 -> 0.305 Inexact Rounded
+pwsx4673 power 0.929 0.5 -> 0.964 Inexact Rounded
+pwsx4674 power 0.0929 0.5 -> 0.305 Inexact Rounded
+pwsx4675 power 0.931 0.5 -> 0.965 Inexact Rounded
+pwsx4676 power 0.0931 0.5 -> 0.305 Inexact Rounded
+pwsx4677 power 0.932 0.5 -> 0.965 Inexact Rounded
+pwsx4678 power 0.0932 0.5 -> 0.305 Inexact Rounded
+pwsx4679 power 0.933 0.5 -> 0.966 Inexact Rounded
+pwsx4680 power 0.0933 0.5 -> 0.305 Inexact Rounded
+pwsx4681 power 0.934 0.5 -> 0.966 Inexact Rounded
+pwsx4682 power 0.0934 0.5 -> 0.306 Inexact Rounded
+pwsx4683 power 0.935 0.5 -> 0.967 Inexact Rounded
+pwsx4684 power 0.0935 0.5 -> 0.306 Inexact Rounded
+pwsx4685 power 0.936 0.5 -> 0.967 Inexact Rounded
+pwsx4686 power 0.0936 0.5 -> 0.306 Inexact Rounded
+pwsx4687 power 0.937 0.5 -> 0.968 Inexact Rounded
+pwsx4688 power 0.0937 0.5 -> 0.306 Inexact Rounded
+pwsx4689 power 0.938 0.5 -> 0.969 Inexact Rounded
+pwsx4690 power 0.0938 0.5 -> 0.306 Inexact Rounded
+pwsx4691 power 0.939 0.5 -> 0.969 Inexact Rounded
+pwsx4692 power 0.0939 0.5 -> 0.306 Inexact Rounded
+pwsx4693 power 0.941 0.5 -> 0.970 Inexact Rounded
+pwsx4694 power 0.0941 0.5 -> 0.307 Inexact Rounded
+pwsx4695 power 0.942 0.5 -> 0.971 Inexact Rounded
+pwsx4696 power 0.0942 0.5 -> 0.307 Inexact Rounded
+pwsx4697 power 0.943 0.5 -> 0.971 Inexact Rounded
+pwsx4698 power 0.0943 0.5 -> 0.307 Inexact Rounded
+pwsx4699 power 0.944 0.5 -> 0.972 Inexact Rounded
+pwsx4700 power 0.0944 0.5 -> 0.307 Inexact Rounded
+pwsx4701 power 0.945 0.5 -> 0.972 Inexact Rounded
+pwsx4702 power 0.0945 0.5 -> 0.307 Inexact Rounded
+pwsx4703 power 0.946 0.5 -> 0.973 Inexact Rounded
+pwsx4704 power 0.0946 0.5 -> 0.308 Inexact Rounded
+pwsx4705 power 0.947 0.5 -> 0.973 Inexact Rounded
+pwsx4706 power 0.0947 0.5 -> 0.308 Inexact Rounded
+pwsx4707 power 0.948 0.5 -> 0.974 Inexact Rounded
+pwsx4708 power 0.0948 0.5 -> 0.308 Inexact Rounded
+pwsx4709 power 0.949 0.5 -> 0.974 Inexact Rounded
+pwsx4710 power 0.0949 0.5 -> 0.308 Inexact Rounded
+pwsx4711 power 0.951 0.5 -> 0.975 Inexact Rounded
+pwsx4712 power 0.0951 0.5 -> 0.308 Inexact Rounded
+pwsx4713 power 0.952 0.5 -> 0.976 Inexact Rounded
+pwsx4714 power 0.0952 0.5 -> 0.309 Inexact Rounded
+pwsx4715 power 0.953 0.5 -> 0.976 Inexact Rounded
+pwsx4716 power 0.0953 0.5 -> 0.309 Inexact Rounded
+pwsx4717 power 0.954 0.5 -> 0.977 Inexact Rounded
+pwsx4718 power 0.0954 0.5 -> 0.309 Inexact Rounded
+pwsx4719 power 0.955 0.5 -> 0.977 Inexact Rounded
+pwsx4720 power 0.0955 0.5 -> 0.309 Inexact Rounded
+pwsx4721 power 0.956 0.5 -> 0.978 Inexact Rounded
+pwsx4722 power 0.0956 0.5 -> 0.309 Inexact Rounded
+pwsx4723 power 0.957 0.5 -> 0.978 Inexact Rounded
+pwsx4724 power 0.0957 0.5 -> 0.309 Inexact Rounded
+pwsx4725 power 0.958 0.5 -> 0.979 Inexact Rounded
+pwsx4726 power 0.0958 0.5 -> 0.310 Inexact Rounded
+pwsx4727 power 0.959 0.5 -> 0.979 Inexact Rounded
+pwsx4728 power 0.0959 0.5 -> 0.310 Inexact Rounded
+pwsx4729 power 0.961 0.5 -> 0.980 Inexact Rounded
+pwsx4730 power 0.0961 0.5 -> 0.310 Inexact Rounded
+pwsx4731 power 0.962 0.5 -> 0.981 Inexact Rounded
+pwsx4732 power 0.0962 0.5 -> 0.310 Inexact Rounded
+pwsx4733 power 0.963 0.5 -> 0.981 Inexact Rounded
+pwsx4734 power 0.0963 0.5 -> 0.310 Inexact Rounded
+pwsx4735 power 0.964 0.5 -> 0.982 Inexact Rounded
+pwsx4736 power 0.0964 0.5 -> 0.310 Inexact Rounded
+pwsx4737 power 0.965 0.5 -> 0.982 Inexact Rounded
+pwsx4738 power 0.0965 0.5 -> 0.311 Inexact Rounded
+pwsx4739 power 0.966 0.5 -> 0.983 Inexact Rounded
+pwsx4740 power 0.0966 0.5 -> 0.311 Inexact Rounded
+pwsx4741 power 0.967 0.5 -> 0.983 Inexact Rounded
+pwsx4742 power 0.0967 0.5 -> 0.311 Inexact Rounded
+pwsx4743 power 0.968 0.5 -> 0.984 Inexact Rounded
+pwsx4744 power 0.0968 0.5 -> 0.311 Inexact Rounded
+pwsx4745 power 0.969 0.5 -> 0.984 Inexact Rounded
+pwsx4746 power 0.0969 0.5 -> 0.311 Inexact Rounded
+pwsx4747 power 0.971 0.5 -> 0.985 Inexact Rounded
+pwsx4748 power 0.0971 0.5 -> 0.312 Inexact Rounded
+pwsx4749 power 0.972 0.5 -> 0.986 Inexact Rounded
+pwsx4750 power 0.0972 0.5 -> 0.312 Inexact Rounded
+pwsx4751 power 0.973 0.5 -> 0.986 Inexact Rounded
+pwsx4752 power 0.0973 0.5 -> 0.312 Inexact Rounded
+pwsx4753 power 0.974 0.5 -> 0.987 Inexact Rounded
+pwsx4754 power 0.0974 0.5 -> 0.312 Inexact Rounded
+pwsx4755 power 0.975 0.5 -> 0.987 Inexact Rounded
+pwsx4756 power 0.0975 0.5 -> 0.312 Inexact Rounded
+pwsx4757 power 0.976 0.5 -> 0.988 Inexact Rounded
+pwsx4758 power 0.0976 0.5 -> 0.312 Inexact Rounded
+pwsx4759 power 0.977 0.5 -> 0.988 Inexact Rounded
+pwsx4760 power 0.0977 0.5 -> 0.313 Inexact Rounded
+pwsx4761 power 0.978 0.5 -> 0.989 Inexact Rounded
+pwsx4762 power 0.0978 0.5 -> 0.313 Inexact Rounded
+pwsx4763 power 0.979 0.5 -> 0.989 Inexact Rounded
+pwsx4764 power 0.0979 0.5 -> 0.313 Inexact Rounded
+pwsx4765 power 0.981 0.5 -> 0.990 Inexact Rounded
+pwsx4766 power 0.0981 0.5 -> 0.313 Inexact Rounded
+pwsx4767 power 0.982 0.5 -> 0.991 Inexact Rounded
+pwsx4768 power 0.0982 0.5 -> 0.313 Inexact Rounded
+pwsx4769 power 0.983 0.5 -> 0.991 Inexact Rounded
+pwsx4770 power 0.0983 0.5 -> 0.314 Inexact Rounded
+pwsx4771 power 0.984 0.5 -> 0.992 Inexact Rounded
+pwsx4772 power 0.0984 0.5 -> 0.314 Inexact Rounded
+pwsx4773 power 0.985 0.5 -> 0.992 Inexact Rounded
+pwsx4774 power 0.0985 0.5 -> 0.314 Inexact Rounded
+pwsx4775 power 0.986 0.5 -> 0.993 Inexact Rounded
+pwsx4776 power 0.0986 0.5 -> 0.314 Inexact Rounded
+pwsx4777 power 0.987 0.5 -> 0.993 Inexact Rounded
+pwsx4778 power 0.0987 0.5 -> 0.314 Inexact Rounded
+pwsx4779 power 0.988 0.5 -> 0.994 Inexact Rounded
+pwsx4780 power 0.0988 0.5 -> 0.314 Inexact Rounded
+pwsx4781 power 0.989 0.5 -> 0.994 Inexact Rounded
+pwsx4782 power 0.0989 0.5 -> 0.314 Inexact Rounded
+pwsx4783 power 0.991 0.5 -> 0.995 Inexact Rounded
+pwsx4784 power 0.0991 0.5 -> 0.315 Inexact Rounded
+pwsx4785 power 0.992 0.5 -> 0.996 Inexact Rounded
+pwsx4786 power 0.0992 0.5 -> 0.315 Inexact Rounded
+pwsx4787 power 0.993 0.5 -> 0.996 Inexact Rounded
+pwsx4788 power 0.0993 0.5 -> 0.315 Inexact Rounded
+pwsx4789 power 0.994 0.5 -> 0.997 Inexact Rounded
+pwsx4790 power 0.0994 0.5 -> 0.315 Inexact Rounded
+pwsx4791 power 0.995 0.5 -> 0.997 Inexact Rounded
+pwsx4792 power 0.0995 0.5 -> 0.315 Inexact Rounded
+pwsx4793 power 0.996 0.5 -> 0.998 Inexact Rounded
+pwsx4794 power 0.0996 0.5 -> 0.316 Inexact Rounded
+pwsx4795 power 0.997 0.5 -> 0.998 Inexact Rounded
+pwsx4796 power 0.0997 0.5 -> 0.316 Inexact Rounded
+pwsx4797 power 0.998 0.5 -> 0.999 Inexact Rounded
+pwsx4798 power 0.0998 0.5 -> 0.316 Inexact Rounded
+pwsx4799 power 0.999 0.5 -> 0.999 Inexact Rounded
+pwsx4800 power 0.0999 0.5 -> 0.316 Inexact Rounded
+
+-- A group of precision 4 tests where Hull & Abrham adjustments are
+-- needed in some cases (both up and down) [see Hull1985b]
+rounding: half_even
+maxExponent: 999
+minexponent: -999
+precision: 4
+pwsx5001 power 0.0118 0.5 -> 0.1086 Inexact Rounded
+pwsx5002 power 0.119 0.5 -> 0.3450 Inexact Rounded
+pwsx5003 power 0.0119 0.5 -> 0.1091 Inexact Rounded
+pwsx5004 power 0.121 0.5 -> 0.3479 Inexact Rounded
+pwsx5005 power 0.0121 0.5 -> 0.1100 Inexact Rounded
+pwsx5006 power 0.122 0.5 -> 0.3493 Inexact Rounded
+pwsx5007 power 0.0122 0.5 -> 0.1105 Inexact Rounded
+pwsx5008 power 0.123 0.5 -> 0.3507 Inexact Rounded
+pwsx5009 power 0.494 0.5 -> 0.7029 Inexact Rounded
+pwsx5010 power 0.0669 0.5 -> 0.2587 Inexact Rounded
+pwsx5011 power 0.9558 0.5 -> 0.9777 Inexact Rounded
+pwsx5012 power 0.9348 0.5 -> 0.9669 Inexact Rounded
+pwsx5013 power 0.9345 0.5 -> 0.9667 Inexact Rounded
+pwsx5014 power 0.09345 0.5 -> 0.3057 Inexact Rounded
+pwsx5015 power 0.9346 0.5 -> 0.9667 Inexact Rounded
+pwsx5016 power 0.09346 0.5 -> 0.3057 Inexact Rounded
+pwsx5017 power 0.9347 0.5 -> 0.9668 Inexact Rounded
+
+-- examples from decArith
+precision: 9
+pwsx700 power 0 0.5 -> '0'
+pwsx701 power -0 0.5 -> '0'
+pwsx702 power 0.39 0.5 -> 0.624499800 Inexact Rounded
+pwsx703 power 100 0.5 -> '10.0000000' Inexact Rounded
+pwsx704 power 1.00 0.5 -> '1.00000000' Inexact Rounded
+pwsx705 power 7 0.5 -> '2.64575131' Inexact Rounded
+pwsx706 power 10 0.5 -> 3.16227766 Inexact Rounded
+
+-- some one-offs
+precision: 9
+pwsx711 power 0.1 0.5 -> 0.316227766 Inexact Rounded
+pwsx712 power 0.2 0.5 -> 0.447213595 Inexact Rounded
+pwsx713 power 0.3 0.5 -> 0.547722558 Inexact Rounded
+pwsx714 power 0.4 0.5 -> 0.632455532 Inexact Rounded
+pwsx715 power 0.5 0.5 -> 0.707106781 Inexact Rounded
+pwsx716 power 0.6 0.5 -> 0.774596669 Inexact Rounded
+pwsx717 power 0.7 0.5 -> 0.836660027 Inexact Rounded
+pwsx718 power 0.8 0.5 -> 0.894427191 Inexact Rounded
+pwsx719 power 0.9 0.5 -> 0.948683298 Inexact Rounded
+precision: 10 -- note no normalizatoin here
+pwsx720 power +0.1 0.5 -> 0.3162277660 Inexact Rounded
+precision: 11
+pwsx721 power +0.1 0.5 -> 0.31622776602 Inexact Rounded
+precision: 12
+pwsx722 power +0.1 0.5 -> 0.316227766017 Inexact Rounded
+precision: 9
+pwsx723 power 0.39 0.5 -> 0.624499800 Inexact Rounded
+precision: 15
+pwsx724 power 0.39 0.5 -> 0.624499799839840 Inexact Rounded
+
+-- discussion cases
+precision: 7
+pwsx731 power 9 0.5 -> 3.000000 Inexact Rounded
+pwsx732 power 100 0.5 -> 10.00000 Inexact Rounded
+pwsx733 power 123 0.5 -> 11.09054 Inexact Rounded
+pwsx734 power 144 0.5 -> 12.00000 Inexact Rounded
+pwsx735 power 156 0.5 -> 12.49000 Inexact Rounded
+pwsx736 power 10000 0.5 -> 100.0000 Inexact Rounded
+
+-- values close to overflow (if there were input rounding)
+maxexponent: 99
+minexponent: -99
+precision: 5
+pwsx760 power 9.9997E+99 0.5 -> 9.9998E+49 Inexact Rounded
+pwsx761 power 9.9998E+99 0.5 -> 9.9999E+49 Inexact Rounded
+pwsx762 power 9.9999E+99 0.5 -> 9.9999E+49 Inexact Rounded
+pwsx763 power 9.99991E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx764 power 9.99994E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx765 power 9.99995E+99 0.5 -> 1.0000E+50 Inexact Rounded
+pwsx766 power 9.99999E+99 0.5 -> 1.0000E+50 Inexact Rounded
+precision: 9
+pwsx770 power 9.9997E+99 0.5 -> 9.99985000E+49 Inexact Rounded
+pwsx771 power 9.9998E+99 0.5 -> 9.99990000E+49 Inexact Rounded
+pwsx772 power 9.9999E+99 0.5 -> 9.99995000E+49 Inexact Rounded
+pwsx773 power 9.99991E+99 0.5 -> 9.99995500E+49 Inexact Rounded
+pwsx774 power 9.99994E+99 0.5 -> 9.99997000E+49 Inexact Rounded
+pwsx775 power 9.99995E+99 0.5 -> 9.99997500E+49 Inexact Rounded
+pwsx776 power 9.99999E+99 0.5 -> 9.99999500E+49 Inexact Rounded
+precision: 20
+pwsx780 power 9.9997E+99 0.5 -> '9.9998499988749831247E+49' Inexact Rounded
+pwsx781 power 9.9998E+99 0.5 -> '9.9998999994999949999E+49' Inexact Rounded
+pwsx782 power 9.9999E+99 0.5 -> '9.9999499998749993750E+49' Inexact Rounded
+pwsx783 power 9.99991E+99 0.5 -> '9.9999549998987495444E+49' Inexact Rounded
+pwsx784 power 9.99994E+99 0.5 -> '9.9999699999549998650E+49' Inexact Rounded
+pwsx785 power 9.99995E+99 0.5 -> '9.9999749999687499219E+49' Inexact Rounded
+pwsx786 power 9.99999E+99 0.5 -> '9.9999949999987499994E+49' Inexact Rounded
+
+-- subnormals and underflows [these can only result when eMax is < digits+1]
+-- Etiny = -(Emax + (precision-1))
+-- start with subnormal operands and normal results
+maxexponent: 9
+minexponent: -9
+precision: 9 -- Etiny=-17
+pwsx800 power 1E-17 0.5 -> 3.16227766E-9 Inexact Rounded
+pwsx801 power 10E-17 0.5 -> 1.00000000E-8 Inexact Rounded
+precision: 10 -- Etiny=-18
+pwsx802 power 10E-18 0.5 -> 3.162277660E-9 Inexact Rounded
+pwsx803 power 1E-18 0.5 -> 1.000000000E-9 Inexact Rounded
+
+precision: 11 -- Etiny=-19
+pwsx804 power 1E-19 0.5 -> 3.162277660E-10 Underflow Subnormal Inexact Rounded
+-- The next test should be skipped for decNumber
+pwsx805 power 10E-19 0.5 -> 1.0000000000E-9 Inexact Rounded
+precision: 12 -- Etiny=-20
+pwsx806 power 10E-20 0.5 -> 3.1622776602E-10 Underflow Subnormal Inexact Rounded
+pwsx807 power 1E-20 0.5 -> 1.0000000000E-10 Underflow Subnormal Inexact Rounded
+
+precision: 13 -- Etiny=-21
+pwsx808 power 1E-21 0.5 -> 3.1622776602E-11 Underflow Subnormal Inexact Rounded
+pwsx809 power 10E-21 0.5 -> 1.00000000000E-10 Underflow Subnormal Inexact Rounded
+precision: 14 -- Etiny=-22
+pwsx810 power 1E-21 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
+pwsx811 power 10E-22 0.5 -> 3.16227766017E-11 Underflow Subnormal Inexact Rounded
+pwsx812 power 1E-22 0.5 -> 1.00000000000E-11 Underflow Subnormal Inexact Rounded
+
+
+-- special values
+maxexponent: 999
+minexponent: -999
+pwsx820 power Inf 0.5 -> Infinity
+pwsx821 power -Inf 0.5 -> NaN Invalid_operation
+pwsx822 power NaN 0.5 -> NaN
+pwsx823 power sNaN 0.5 -> NaN Invalid_operation
+-- propagating NaNs
+pwsx824 power sNaN123 0.5 -> NaN123 Invalid_operation
+pwsx825 power -sNaN321 0.5 -> -NaN321 Invalid_operation
+pwsx826 power NaN456 0.5 -> NaN456
+pwsx827 power -NaN654 0.5 -> -NaN654
+pwsx828 power NaN1 0.5 -> NaN1
+
+-- Null test
+pwsx900 power # 0.5 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/rotate.decTest b/Lib/test/decimaltestdata/rotate.decTest
index 81ade79c220..12db8213178 100644
--- a/Lib/test/decimaltestdata/rotate.decTest
+++ b/Lib/test/decimaltestdata/rotate.decTest
@@ -1,247 +1,247 @@
-------------------------------------------------------------------------
--- rotate.decTest -- rotate coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-rotx001 rotate 0 0 -> 0
-rotx002 rotate 0 2 -> 0
-rotx003 rotate 1 2 -> 100
-rotx004 rotate 34 8 -> 400000003
-rotx005 rotate 1 9 -> 1
-rotx006 rotate 1 -1 -> 100000000
-rotx007 rotate 123456789 -1 -> 912345678
-rotx008 rotate 123456789 -8 -> 234567891
-rotx009 rotate 123456789 -9 -> 123456789
-rotx010 rotate 0 -2 -> 0
-
--- rhs must be an integer
-rotx011 rotate 1 1.5 -> NaN Invalid_operation
-rotx012 rotate 1 1.0 -> NaN Invalid_operation
-rotx013 rotate 1 0.1 -> NaN Invalid_operation
-rotx014 rotate 1 0.0 -> NaN Invalid_operation
-rotx015 rotate 1 1E+1 -> NaN Invalid_operation
-rotx016 rotate 1 1E+99 -> NaN Invalid_operation
-rotx017 rotate 1 Inf -> NaN Invalid_operation
-rotx018 rotate 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-rotx020 rotate 1 -1000 -> NaN Invalid_operation
-rotx021 rotate 1 -10 -> NaN Invalid_operation
-rotx022 rotate 1 10 -> NaN Invalid_operation
-rotx023 rotate 1 1000 -> NaN Invalid_operation
-
--- full pattern
-rotx030 rotate 123456789 -9 -> 123456789
-rotx031 rotate 123456789 -8 -> 234567891
-rotx032 rotate 123456789 -7 -> 345678912
-rotx033 rotate 123456789 -6 -> 456789123
-rotx034 rotate 123456789 -5 -> 567891234
-rotx035 rotate 123456789 -4 -> 678912345
-rotx036 rotate 123456789 -3 -> 789123456
-rotx037 rotate 123456789 -2 -> 891234567
-rotx038 rotate 123456789 -1 -> 912345678
-rotx039 rotate 123456789 -0 -> 123456789
-rotx040 rotate 123456789 +0 -> 123456789
-rotx041 rotate 123456789 +1 -> 234567891
-rotx042 rotate 123456789 +2 -> 345678912
-rotx043 rotate 123456789 +3 -> 456789123
-rotx044 rotate 123456789 +4 -> 567891234
-rotx045 rotate 123456789 +5 -> 678912345
-rotx046 rotate 123456789 +6 -> 789123456
-rotx047 rotate 123456789 +7 -> 891234567
-rotx048 rotate 123456789 +8 -> 912345678
-rotx049 rotate 123456789 +9 -> 123456789
-
--- zeros
-rotx060 rotate 0E-10 +9 -> 0E-10
-rotx061 rotate 0E-10 -9 -> 0E-10
-rotx062 rotate 0.000 +9 -> 0.000
-rotx063 rotate 0.000 -9 -> 0.000
-rotx064 rotate 0E+10 +9 -> 0E+10
-rotx065 rotate 0E+10 -9 -> 0E+10
-rotx066 rotate -0E-10 +9 -> -0E-10
-rotx067 rotate -0E-10 -9 -> -0E-10
-rotx068 rotate -0.000 +9 -> -0.000
-rotx069 rotate -0.000 -9 -> -0.000
-rotx070 rotate -0E+10 +9 -> -0E+10
-rotx071 rotate -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-rotx141 rotate 9.99999999E+999 -1 -> 9.99999999E+999
-rotx142 rotate 9.99999999E+999 -8 -> 9.99999999E+999
-rotx143 rotate 9.99999999E+999 1 -> 9.99999999E+999
-rotx144 rotate 9.99999999E+999 8 -> 9.99999999E+999
-rotx145 rotate 1E-999 -1 -> 1.00000000E-991
-rotx146 rotate 1E-999 -8 -> 1.0E-998
-rotx147 rotate 1E-999 1 -> 1.0E-998
-rotx148 rotate 1E-999 8 -> 1.00000000E-991
-rotx151 rotate 1.00000000E-999 -1 -> 1.0000000E-1000
-rotx152 rotate 1.00000000E-999 -8 -> 1E-1007
-rotx153 rotate 1.00000000E-999 1 -> 1E-1007
-rotx154 rotate 1.00000000E-999 8 -> 1.0000000E-1000
-rotx155 rotate 9.00000000E-999 -1 -> 9.0000000E-1000
-rotx156 rotate 9.00000000E-999 -8 -> 9E-1007
-rotx157 rotate 9.00000000E-999 1 -> 9E-1007
-rotx158 rotate 9.00000000E-999 8 -> 9.0000000E-1000
-rotx160 rotate 1E-1007 -1 -> 1.00000000E-999
-rotx161 rotate 1E-1007 -8 -> 1.0E-1006
-rotx162 rotate 1E-1007 1 -> 1.0E-1006
-rotx163 rotate 1E-1007 8 -> 1.00000000E-999
--- negatives
-rotx171 rotate -9.99999999E+999 -1 -> -9.99999999E+999
-rotx172 rotate -9.99999999E+999 -8 -> -9.99999999E+999
-rotx173 rotate -9.99999999E+999 1 -> -9.99999999E+999
-rotx174 rotate -9.99999999E+999 8 -> -9.99999999E+999
-rotx175 rotate -1E-999 -1 -> -1.00000000E-991
-rotx176 rotate -1E-999 -8 -> -1.0E-998
-rotx177 rotate -1E-999 1 -> -1.0E-998
-rotx178 rotate -1E-999 8 -> -1.00000000E-991
-rotx181 rotate -1.00000000E-999 -1 -> -1.0000000E-1000
-rotx182 rotate -1.00000000E-999 -8 -> -1E-1007
-rotx183 rotate -1.00000000E-999 1 -> -1E-1007
-rotx184 rotate -1.00000000E-999 8 -> -1.0000000E-1000
-rotx185 rotate -9.00000000E-999 -1 -> -9.0000000E-1000
-rotx186 rotate -9.00000000E-999 -8 -> -9E-1007
-rotx187 rotate -9.00000000E-999 1 -> -9E-1007
-rotx188 rotate -9.00000000E-999 8 -> -9.0000000E-1000
-rotx190 rotate -1E-1007 -1 -> -1.00000000E-999
-rotx191 rotate -1E-1007 -8 -> -1.0E-1006
-rotx192 rotate -1E-1007 1 -> -1.0E-1006
-rotx193 rotate -1E-1007 8 -> -1.00000000E-999
-
--- more negatives (of sanities)
-rotx201 rotate -0 0 -> -0
-rotx202 rotate -0 2 -> -0
-rotx203 rotate -1 2 -> -100
-rotx204 rotate -1 8 -> -100000000
-rotx205 rotate -1 9 -> -1
-rotx206 rotate -1 -1 -> -100000000
-rotx207 rotate -123456789 -1 -> -912345678
-rotx208 rotate -123456789 -8 -> -234567891
-rotx209 rotate -123456789 -9 -> -123456789
-rotx210 rotate -0 -2 -> -0
-
--- Specials; NaNs are handled as usual
-rotx781 rotate -Inf -8 -> -Infinity
-rotx782 rotate -Inf -1 -> -Infinity
-rotx783 rotate -Inf -0 -> -Infinity
-rotx784 rotate -Inf 0 -> -Infinity
-rotx785 rotate -Inf 1 -> -Infinity
-rotx786 rotate -Inf 8 -> -Infinity
-rotx787 rotate -1000 -Inf -> NaN Invalid_operation
-rotx788 rotate -Inf -Inf -> NaN Invalid_operation
-rotx789 rotate -1 -Inf -> NaN Invalid_operation
-rotx790 rotate -0 -Inf -> NaN Invalid_operation
-rotx791 rotate 0 -Inf -> NaN Invalid_operation
-rotx792 rotate 1 -Inf -> NaN Invalid_operation
-rotx793 rotate 1000 -Inf -> NaN Invalid_operation
-rotx794 rotate Inf -Inf -> NaN Invalid_operation
-
-rotx800 rotate Inf -Inf -> NaN Invalid_operation
-rotx801 rotate Inf -8 -> Infinity
-rotx802 rotate Inf -1 -> Infinity
-rotx803 rotate Inf -0 -> Infinity
-rotx804 rotate Inf 0 -> Infinity
-rotx805 rotate Inf 1 -> Infinity
-rotx806 rotate Inf 8 -> Infinity
-rotx807 rotate Inf Inf -> NaN Invalid_operation
-rotx808 rotate -1000 Inf -> NaN Invalid_operation
-rotx809 rotate -Inf Inf -> NaN Invalid_operation
-rotx810 rotate -1 Inf -> NaN Invalid_operation
-rotx811 rotate -0 Inf -> NaN Invalid_operation
-rotx812 rotate 0 Inf -> NaN Invalid_operation
-rotx813 rotate 1 Inf -> NaN Invalid_operation
-rotx814 rotate 1000 Inf -> NaN Invalid_operation
-rotx815 rotate Inf Inf -> NaN Invalid_operation
-
-rotx821 rotate NaN -Inf -> NaN
-rotx822 rotate NaN -1000 -> NaN
-rotx823 rotate NaN -1 -> NaN
-rotx824 rotate NaN -0 -> NaN
-rotx825 rotate NaN 0 -> NaN
-rotx826 rotate NaN 1 -> NaN
-rotx827 rotate NaN 1000 -> NaN
-rotx828 rotate NaN Inf -> NaN
-rotx829 rotate NaN NaN -> NaN
-rotx830 rotate -Inf NaN -> NaN
-rotx831 rotate -1000 NaN -> NaN
-rotx832 rotate -1 NaN -> NaN
-rotx833 rotate -0 NaN -> NaN
-rotx834 rotate 0 NaN -> NaN
-rotx835 rotate 1 NaN -> NaN
-rotx836 rotate 1000 NaN -> NaN
-rotx837 rotate Inf NaN -> NaN
-
-
-
-rotx841 rotate sNaN -Inf -> NaN Invalid_operation
-rotx842 rotate sNaN -1000 -> NaN Invalid_operation
-rotx843 rotate sNaN -1 -> NaN Invalid_operation
-rotx844 rotate sNaN -0 -> NaN Invalid_operation
-rotx845 rotate sNaN 0 -> NaN Invalid_operation
-rotx846 rotate sNaN 1 -> NaN Invalid_operation
-rotx847 rotate sNaN 1000 -> NaN Invalid_operation
-rotx848 rotate sNaN NaN -> NaN Invalid_operation
-rotx849 rotate sNaN sNaN -> NaN Invalid_operation
-rotx850 rotate NaN sNaN -> NaN Invalid_operation
-rotx851 rotate -Inf sNaN -> NaN Invalid_operation
-rotx852 rotate -1000 sNaN -> NaN Invalid_operation
-rotx853 rotate -1 sNaN -> NaN Invalid_operation
-rotx854 rotate -0 sNaN -> NaN Invalid_operation
-rotx855 rotate 0 sNaN -> NaN Invalid_operation
-rotx856 rotate 1 sNaN -> NaN Invalid_operation
-rotx857 rotate 1000 sNaN -> NaN Invalid_operation
-rotx858 rotate Inf sNaN -> NaN Invalid_operation
-rotx859 rotate NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-rotx861 rotate NaN1 -Inf -> NaN1
-rotx862 rotate +NaN2 -1000 -> NaN2
-rotx863 rotate NaN3 1000 -> NaN3
-rotx864 rotate NaN4 Inf -> NaN4
-rotx865 rotate NaN5 +NaN6 -> NaN5
-rotx866 rotate -Inf NaN7 -> NaN7
-rotx867 rotate -1000 NaN8 -> NaN8
-rotx868 rotate 1000 NaN9 -> NaN9
-rotx869 rotate Inf +NaN10 -> NaN10
-rotx871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
-rotx872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
-rotx873 rotate sNaN13 1000 -> NaN13 Invalid_operation
-rotx874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
-rotx875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
-rotx876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
-rotx877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
-rotx878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
-rotx879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
-rotx880 rotate Inf sNaN23 -> NaN23 Invalid_operation
-rotx881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
-rotx882 rotate -NaN26 NaN28 -> -NaN26
-rotx883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-rotx884 rotate 1000 -NaN30 -> -NaN30
-rotx885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
-
--- payload decapitate
-precision: 5
-rotx886 rotate 11 -sNaN1234567890 -> -NaN67890 Invalid_operation
+------------------------------------------------------------------------
+-- rotate.decTest -- rotate coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+rotx001 rotate 0 0 -> 0
+rotx002 rotate 0 2 -> 0
+rotx003 rotate 1 2 -> 100
+rotx004 rotate 34 8 -> 400000003
+rotx005 rotate 1 9 -> 1
+rotx006 rotate 1 -1 -> 100000000
+rotx007 rotate 123456789 -1 -> 912345678
+rotx008 rotate 123456789 -8 -> 234567891
+rotx009 rotate 123456789 -9 -> 123456789
+rotx010 rotate 0 -2 -> 0
+
+-- rhs must be an integer
+rotx011 rotate 1 1.5 -> NaN Invalid_operation
+rotx012 rotate 1 1.0 -> NaN Invalid_operation
+rotx013 rotate 1 0.1 -> NaN Invalid_operation
+rotx014 rotate 1 0.0 -> NaN Invalid_operation
+rotx015 rotate 1 1E+1 -> NaN Invalid_operation
+rotx016 rotate 1 1E+99 -> NaN Invalid_operation
+rotx017 rotate 1 Inf -> NaN Invalid_operation
+rotx018 rotate 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+rotx020 rotate 1 -1000 -> NaN Invalid_operation
+rotx021 rotate 1 -10 -> NaN Invalid_operation
+rotx022 rotate 1 10 -> NaN Invalid_operation
+rotx023 rotate 1 1000 -> NaN Invalid_operation
+
+-- full pattern
+rotx030 rotate 123456789 -9 -> 123456789
+rotx031 rotate 123456789 -8 -> 234567891
+rotx032 rotate 123456789 -7 -> 345678912
+rotx033 rotate 123456789 -6 -> 456789123
+rotx034 rotate 123456789 -5 -> 567891234
+rotx035 rotate 123456789 -4 -> 678912345
+rotx036 rotate 123456789 -3 -> 789123456
+rotx037 rotate 123456789 -2 -> 891234567
+rotx038 rotate 123456789 -1 -> 912345678
+rotx039 rotate 123456789 -0 -> 123456789
+rotx040 rotate 123456789 +0 -> 123456789
+rotx041 rotate 123456789 +1 -> 234567891
+rotx042 rotate 123456789 +2 -> 345678912
+rotx043 rotate 123456789 +3 -> 456789123
+rotx044 rotate 123456789 +4 -> 567891234
+rotx045 rotate 123456789 +5 -> 678912345
+rotx046 rotate 123456789 +6 -> 789123456
+rotx047 rotate 123456789 +7 -> 891234567
+rotx048 rotate 123456789 +8 -> 912345678
+rotx049 rotate 123456789 +9 -> 123456789
+
+-- zeros
+rotx060 rotate 0E-10 +9 -> 0E-10
+rotx061 rotate 0E-10 -9 -> 0E-10
+rotx062 rotate 0.000 +9 -> 0.000
+rotx063 rotate 0.000 -9 -> 0.000
+rotx064 rotate 0E+10 +9 -> 0E+10
+rotx065 rotate 0E+10 -9 -> 0E+10
+rotx066 rotate -0E-10 +9 -> -0E-10
+rotx067 rotate -0E-10 -9 -> -0E-10
+rotx068 rotate -0.000 +9 -> -0.000
+rotx069 rotate -0.000 -9 -> -0.000
+rotx070 rotate -0E+10 +9 -> -0E+10
+rotx071 rotate -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+rotx141 rotate 9.99999999E+999 -1 -> 9.99999999E+999
+rotx142 rotate 9.99999999E+999 -8 -> 9.99999999E+999
+rotx143 rotate 9.99999999E+999 1 -> 9.99999999E+999
+rotx144 rotate 9.99999999E+999 8 -> 9.99999999E+999
+rotx145 rotate 1E-999 -1 -> 1.00000000E-991
+rotx146 rotate 1E-999 -8 -> 1.0E-998
+rotx147 rotate 1E-999 1 -> 1.0E-998
+rotx148 rotate 1E-999 8 -> 1.00000000E-991
+rotx151 rotate 1.00000000E-999 -1 -> 1.0000000E-1000
+rotx152 rotate 1.00000000E-999 -8 -> 1E-1007
+rotx153 rotate 1.00000000E-999 1 -> 1E-1007
+rotx154 rotate 1.00000000E-999 8 -> 1.0000000E-1000
+rotx155 rotate 9.00000000E-999 -1 -> 9.0000000E-1000
+rotx156 rotate 9.00000000E-999 -8 -> 9E-1007
+rotx157 rotate 9.00000000E-999 1 -> 9E-1007
+rotx158 rotate 9.00000000E-999 8 -> 9.0000000E-1000
+rotx160 rotate 1E-1007 -1 -> 1.00000000E-999
+rotx161 rotate 1E-1007 -8 -> 1.0E-1006
+rotx162 rotate 1E-1007 1 -> 1.0E-1006
+rotx163 rotate 1E-1007 8 -> 1.00000000E-999
+-- negatives
+rotx171 rotate -9.99999999E+999 -1 -> -9.99999999E+999
+rotx172 rotate -9.99999999E+999 -8 -> -9.99999999E+999
+rotx173 rotate -9.99999999E+999 1 -> -9.99999999E+999
+rotx174 rotate -9.99999999E+999 8 -> -9.99999999E+999
+rotx175 rotate -1E-999 -1 -> -1.00000000E-991
+rotx176 rotate -1E-999 -8 -> -1.0E-998
+rotx177 rotate -1E-999 1 -> -1.0E-998
+rotx178 rotate -1E-999 8 -> -1.00000000E-991
+rotx181 rotate -1.00000000E-999 -1 -> -1.0000000E-1000
+rotx182 rotate -1.00000000E-999 -8 -> -1E-1007
+rotx183 rotate -1.00000000E-999 1 -> -1E-1007
+rotx184 rotate -1.00000000E-999 8 -> -1.0000000E-1000
+rotx185 rotate -9.00000000E-999 -1 -> -9.0000000E-1000
+rotx186 rotate -9.00000000E-999 -8 -> -9E-1007
+rotx187 rotate -9.00000000E-999 1 -> -9E-1007
+rotx188 rotate -9.00000000E-999 8 -> -9.0000000E-1000
+rotx190 rotate -1E-1007 -1 -> -1.00000000E-999
+rotx191 rotate -1E-1007 -8 -> -1.0E-1006
+rotx192 rotate -1E-1007 1 -> -1.0E-1006
+rotx193 rotate -1E-1007 8 -> -1.00000000E-999
+
+-- more negatives (of sanities)
+rotx201 rotate -0 0 -> -0
+rotx202 rotate -0 2 -> -0
+rotx203 rotate -1 2 -> -100
+rotx204 rotate -1 8 -> -100000000
+rotx205 rotate -1 9 -> -1
+rotx206 rotate -1 -1 -> -100000000
+rotx207 rotate -123456789 -1 -> -912345678
+rotx208 rotate -123456789 -8 -> -234567891
+rotx209 rotate -123456789 -9 -> -123456789
+rotx210 rotate -0 -2 -> -0
+
+-- Specials; NaNs are handled as usual
+rotx781 rotate -Inf -8 -> -Infinity
+rotx782 rotate -Inf -1 -> -Infinity
+rotx783 rotate -Inf -0 -> -Infinity
+rotx784 rotate -Inf 0 -> -Infinity
+rotx785 rotate -Inf 1 -> -Infinity
+rotx786 rotate -Inf 8 -> -Infinity
+rotx787 rotate -1000 -Inf -> NaN Invalid_operation
+rotx788 rotate -Inf -Inf -> NaN Invalid_operation
+rotx789 rotate -1 -Inf -> NaN Invalid_operation
+rotx790 rotate -0 -Inf -> NaN Invalid_operation
+rotx791 rotate 0 -Inf -> NaN Invalid_operation
+rotx792 rotate 1 -Inf -> NaN Invalid_operation
+rotx793 rotate 1000 -Inf -> NaN Invalid_operation
+rotx794 rotate Inf -Inf -> NaN Invalid_operation
+
+rotx800 rotate Inf -Inf -> NaN Invalid_operation
+rotx801 rotate Inf -8 -> Infinity
+rotx802 rotate Inf -1 -> Infinity
+rotx803 rotate Inf -0 -> Infinity
+rotx804 rotate Inf 0 -> Infinity
+rotx805 rotate Inf 1 -> Infinity
+rotx806 rotate Inf 8 -> Infinity
+rotx807 rotate Inf Inf -> NaN Invalid_operation
+rotx808 rotate -1000 Inf -> NaN Invalid_operation
+rotx809 rotate -Inf Inf -> NaN Invalid_operation
+rotx810 rotate -1 Inf -> NaN Invalid_operation
+rotx811 rotate -0 Inf -> NaN Invalid_operation
+rotx812 rotate 0 Inf -> NaN Invalid_operation
+rotx813 rotate 1 Inf -> NaN Invalid_operation
+rotx814 rotate 1000 Inf -> NaN Invalid_operation
+rotx815 rotate Inf Inf -> NaN Invalid_operation
+
+rotx821 rotate NaN -Inf -> NaN
+rotx822 rotate NaN -1000 -> NaN
+rotx823 rotate NaN -1 -> NaN
+rotx824 rotate NaN -0 -> NaN
+rotx825 rotate NaN 0 -> NaN
+rotx826 rotate NaN 1 -> NaN
+rotx827 rotate NaN 1000 -> NaN
+rotx828 rotate NaN Inf -> NaN
+rotx829 rotate NaN NaN -> NaN
+rotx830 rotate -Inf NaN -> NaN
+rotx831 rotate -1000 NaN -> NaN
+rotx832 rotate -1 NaN -> NaN
+rotx833 rotate -0 NaN -> NaN
+rotx834 rotate 0 NaN -> NaN
+rotx835 rotate 1 NaN -> NaN
+rotx836 rotate 1000 NaN -> NaN
+rotx837 rotate Inf NaN -> NaN
+
+
+
+rotx841 rotate sNaN -Inf -> NaN Invalid_operation
+rotx842 rotate sNaN -1000 -> NaN Invalid_operation
+rotx843 rotate sNaN -1 -> NaN Invalid_operation
+rotx844 rotate sNaN -0 -> NaN Invalid_operation
+rotx845 rotate sNaN 0 -> NaN Invalid_operation
+rotx846 rotate sNaN 1 -> NaN Invalid_operation
+rotx847 rotate sNaN 1000 -> NaN Invalid_operation
+rotx848 rotate sNaN NaN -> NaN Invalid_operation
+rotx849 rotate sNaN sNaN -> NaN Invalid_operation
+rotx850 rotate NaN sNaN -> NaN Invalid_operation
+rotx851 rotate -Inf sNaN -> NaN Invalid_operation
+rotx852 rotate -1000 sNaN -> NaN Invalid_operation
+rotx853 rotate -1 sNaN -> NaN Invalid_operation
+rotx854 rotate -0 sNaN -> NaN Invalid_operation
+rotx855 rotate 0 sNaN -> NaN Invalid_operation
+rotx856 rotate 1 sNaN -> NaN Invalid_operation
+rotx857 rotate 1000 sNaN -> NaN Invalid_operation
+rotx858 rotate Inf sNaN -> NaN Invalid_operation
+rotx859 rotate NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+rotx861 rotate NaN1 -Inf -> NaN1
+rotx862 rotate +NaN2 -1000 -> NaN2
+rotx863 rotate NaN3 1000 -> NaN3
+rotx864 rotate NaN4 Inf -> NaN4
+rotx865 rotate NaN5 +NaN6 -> NaN5
+rotx866 rotate -Inf NaN7 -> NaN7
+rotx867 rotate -1000 NaN8 -> NaN8
+rotx868 rotate 1000 NaN9 -> NaN9
+rotx869 rotate Inf +NaN10 -> NaN10
+rotx871 rotate sNaN11 -Inf -> NaN11 Invalid_operation
+rotx872 rotate sNaN12 -1000 -> NaN12 Invalid_operation
+rotx873 rotate sNaN13 1000 -> NaN13 Invalid_operation
+rotx874 rotate sNaN14 NaN17 -> NaN14 Invalid_operation
+rotx875 rotate sNaN15 sNaN18 -> NaN15 Invalid_operation
+rotx876 rotate NaN16 sNaN19 -> NaN19 Invalid_operation
+rotx877 rotate -Inf +sNaN20 -> NaN20 Invalid_operation
+rotx878 rotate -1000 sNaN21 -> NaN21 Invalid_operation
+rotx879 rotate 1000 sNaN22 -> NaN22 Invalid_operation
+rotx880 rotate Inf sNaN23 -> NaN23 Invalid_operation
+rotx881 rotate +NaN25 +sNaN24 -> NaN24 Invalid_operation
+rotx882 rotate -NaN26 NaN28 -> -NaN26
+rotx883 rotate -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+rotx884 rotate 1000 -NaN30 -> -NaN30
+rotx885 rotate 1000 -sNaN31 -> -NaN31 Invalid_operation
+
+-- payload decapitate
+precision: 5
+rotx886 rotate 11 -sNaN1234567890 -> -NaN67890 Invalid_operation
diff --git a/Lib/test/decimaltestdata/scaleb.decTest b/Lib/test/decimaltestdata/scaleb.decTest
index 04a65d6eae8..372e3dd4c3e 100644
--- a/Lib/test/decimaltestdata/scaleb.decTest
+++ b/Lib/test/decimaltestdata/scaleb.decTest
@@ -1,209 +1,209 @@
-------------------------------------------------------------------------
--- scaleb.decTest -- scale a number by powers of 10 --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Max |rhs| is 2*(999+9) = 2016
-
--- Sanity checks
-scbx001 scaleb 7.50 10 -> 7.50E+10
-scbx002 scaleb 7.50 3 -> 7.50E+3
-scbx003 scaleb 7.50 2 -> 750
-scbx004 scaleb 7.50 1 -> 75.0
-scbx005 scaleb 7.50 0 -> 7.50
-scbx006 scaleb 7.50 -1 -> 0.750
-scbx007 scaleb 7.50 -2 -> 0.0750
-scbx008 scaleb 7.50 -10 -> 7.50E-10
-scbx009 scaleb -7.50 3 -> -7.50E+3
-scbx010 scaleb -7.50 2 -> -750
-scbx011 scaleb -7.50 1 -> -75.0
-scbx012 scaleb -7.50 0 -> -7.50
-scbx013 scaleb -7.50 -1 -> -0.750
-
--- Infinities
-scbx014 scaleb Infinity 1 -> Infinity
-scbx015 scaleb -Infinity 2 -> -Infinity
-scbx016 scaleb Infinity -1 -> Infinity
-scbx017 scaleb -Infinity -2 -> -Infinity
-
--- Next two are somewhat undefined in 754r; treat as non-integer
-scbx018 scaleb 10 Infinity -> NaN Invalid_operation
-scbx019 scaleb 10 -Infinity -> NaN Invalid_operation
-
--- NaNs are undefined in 754r; assume usual processing
--- NaNs, 0 payload
-scbx021 scaleb NaN 1 -> NaN
-scbx022 scaleb -NaN -1 -> -NaN
-scbx023 scaleb sNaN 1 -> NaN Invalid_operation
-scbx024 scaleb -sNaN 1 -> -NaN Invalid_operation
-scbx025 scaleb 4 NaN -> NaN
-scbx026 scaleb -Inf -NaN -> -NaN
-scbx027 scaleb 4 sNaN -> NaN Invalid_operation
-scbx028 scaleb Inf -sNaN -> -NaN Invalid_operation
-
--- non-integer RHS
-scbx030 scaleb 1.23 1 -> 12.3
-scbx031 scaleb 1.23 1.00 -> NaN Invalid_operation
-scbx032 scaleb 1.23 1.1 -> NaN Invalid_operation
-scbx033 scaleb 1.23 1.01 -> NaN Invalid_operation
-scbx034 scaleb 1.23 0.01 -> NaN Invalid_operation
-scbx035 scaleb 1.23 0.11 -> NaN Invalid_operation
-scbx036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
-scbx037 scaleb 1.23 -1 -> 0.123
-scbx038 scaleb 1.23 -1.00 -> NaN Invalid_operation
-scbx039 scaleb 1.23 -1.1 -> NaN Invalid_operation
-scbx040 scaleb 1.23 -1.01 -> NaN Invalid_operation
-scbx041 scaleb 1.23 -0.01 -> NaN Invalid_operation
-scbx042 scaleb 1.23 -0.11 -> NaN Invalid_operation
-scbx043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
-scbx044 scaleb 1.23 0.1 -> NaN Invalid_operation
-scbx045 scaleb 1.23 1E+1 -> NaN Invalid_operation
-scbx046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
-scbx047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
-
-
-scbx120 scaleb 1.23 2015 -> Infinity Overflow Inexact Rounded
-scbx121 scaleb 1.23 2016 -> Infinity Overflow Inexact Rounded
-scbx122 scaleb 1.23 2017 -> NaN Invalid_operation
-scbx123 scaleb 1.23 2018 -> NaN Invalid_operation
-scbx124 scaleb 1.23 -2015 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx125 scaleb 1.23 -2016 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx126 scaleb 1.23 -2017 -> NaN Invalid_operation
-scbx127 scaleb 1.23 -2018 -> NaN Invalid_operation
-
--- NaNs, non-0 payload
--- propagating NaNs
-scbx861 scaleb NaN01 -Inf -> NaN1
-scbx862 scaleb -NaN02 -1000 -> -NaN2
-scbx863 scaleb NaN03 1000 -> NaN3
-scbx864 scaleb NaN04 Inf -> NaN4
-scbx865 scaleb NaN05 NaN61 -> NaN5
-scbx866 scaleb -Inf -NaN71 -> -NaN71
-scbx867 scaleb -1000 NaN81 -> NaN81
-scbx868 scaleb 1000 NaN91 -> NaN91
-scbx869 scaleb Inf NaN101 -> NaN101
-scbx871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
-scbx872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
-scbx873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
-scbx874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
-scbx875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
-scbx876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
-scbx877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
-scbx878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
-scbx879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
-scbx880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
-scbx881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
-
--- finites
-scbx051 scaleb 7 -2 -> 0.07
-scbx052 scaleb -7 -2 -> -0.07
-scbx053 scaleb 75 -2 -> 0.75
-scbx054 scaleb -75 -2 -> -0.75
-scbx055 scaleb 7.50 -2 -> 0.0750
-scbx056 scaleb -7.50 -2 -> -0.0750
-scbx057 scaleb 7.500 -2 -> 0.07500
-scbx058 scaleb -7.500 -2 -> -0.07500
-scbx061 scaleb 7 -1 -> 0.7
-scbx062 scaleb -7 -1 -> -0.7
-scbx063 scaleb 75 -1 -> 7.5
-scbx064 scaleb -75 -1 -> -7.5
-scbx065 scaleb 7.50 -1 -> 0.750
-scbx066 scaleb -7.50 -1 -> -0.750
-scbx067 scaleb 7.500 -1 -> 0.7500
-scbx068 scaleb -7.500 -1 -> -0.7500
-scbx071 scaleb 7 0 -> 7
-scbx072 scaleb -7 0 -> -7
-scbx073 scaleb 75 0 -> 75
-scbx074 scaleb -75 0 -> -75
-scbx075 scaleb 7.50 0 -> 7.50
-scbx076 scaleb -7.50 0 -> -7.50
-scbx077 scaleb 7.500 0 -> 7.500
-scbx078 scaleb -7.500 0 -> -7.500
-scbx081 scaleb 7 1 -> 7E+1
-scbx082 scaleb -7 1 -> -7E+1
-scbx083 scaleb 75 1 -> 7.5E+2
-scbx084 scaleb -75 1 -> -7.5E+2
-scbx085 scaleb 7.50 1 -> 75.0
-scbx086 scaleb -7.50 1 -> -75.0
-scbx087 scaleb 7.500 1 -> 75.00
-scbx088 scaleb -7.500 1 -> -75.00
-scbx091 scaleb 7 2 -> 7E+2
-scbx092 scaleb -7 2 -> -7E+2
-scbx093 scaleb 75 2 -> 7.5E+3
-scbx094 scaleb -75 2 -> -7.5E+3
-scbx095 scaleb 7.50 2 -> 750
-scbx096 scaleb -7.50 2 -> -750
-scbx097 scaleb 7.500 2 -> 750.0
-scbx098 scaleb -7.500 2 -> -750.0
-
--- zeros
-scbx111 scaleb 0 1 -> 0E+1
-scbx112 scaleb -0 2 -> -0E+2
-scbx113 scaleb 0E+4 3 -> 0E+7
-scbx114 scaleb -0E+4 4 -> -0E+8
-scbx115 scaleb 0.0000 5 -> 0E+1
-scbx116 scaleb -0.0000 6 -> -0E+2
-scbx117 scaleb 0E-141 7 -> 0E-134
-scbx118 scaleb -0E-141 8 -> -0E-133
-
--- Nmax, Nmin, Ntiny
-scbx132 scaleb 9.99999999E+999 +999 -> Infinity Overflow Inexact Rounded
-scbx133 scaleb 9.99999999E+999 +10 -> Infinity Overflow Inexact Rounded
-scbx134 scaleb 9.99999999E+999 +1 -> Infinity Overflow Inexact Rounded
-scbx135 scaleb 9.99999999E+999 0 -> 9.99999999E+999
-scbx136 scaleb 9.99999999E+999 -1 -> 9.99999999E+998
-scbx137 scaleb 1E-999 +1 -> 1E-998
-scbx138 scaleb 1E-999 -0 -> 1E-999
-scbx139 scaleb 1E-999 -1 -> 1E-1000 Subnormal
-scbx140 scaleb 1.00000000E-999 +1 -> 1.00000000E-998
-scbx141 scaleb 1.00000000E-999 0 -> 1.00000000E-999
-scbx142 scaleb 1.00000000E-999 -1 -> 1.0000000E-1000 Subnormal Rounded
-scbx143 scaleb 1E-1007 +1 -> 1E-1006 Subnormal
-scbx144 scaleb 1E-1007 -0 -> 1E-1007 Subnormal
-scbx145 scaleb 1E-1007 -1 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
-
-scbx150 scaleb -1E-1007 +1 -> -1E-1006 Subnormal
-scbx151 scaleb -1E-1007 -0 -> -1E-1007 Subnormal
-scbx152 scaleb -1E-1007 -1 -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
-scbx153 scaleb -1.00000000E-999 +1 -> -1.00000000E-998
-scbx154 scaleb -1.00000000E-999 +0 -> -1.00000000E-999
-scbx155 scaleb -1.00000000E-999 -1 -> -1.0000000E-1000 Subnormal Rounded
-scbx156 scaleb -1E-999 +1 -> -1E-998
-scbx157 scaleb -1E-999 -0 -> -1E-999
-scbx158 scaleb -1E-999 -1 -> -1E-1000 Subnormal
-scbx159 scaleb -9.99999999E+999 +1 -> -Infinity Overflow Inexact Rounded
-scbx160 scaleb -9.99999999E+999 +0 -> -9.99999999E+999
-scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998
-scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded
-scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded
-
--- Krah examples
-precision: 34
-maxExponent: 999999999
-minExponent: -999999999
--- integer overflow in 3.61 or earlier
-scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation
--- out of range
-scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- scaleb.decTest -- scale a number by powers of 10 --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Max |rhs| is 2*(999+9) = 2016
+
+-- Sanity checks
+scbx001 scaleb 7.50 10 -> 7.50E+10
+scbx002 scaleb 7.50 3 -> 7.50E+3
+scbx003 scaleb 7.50 2 -> 750
+scbx004 scaleb 7.50 1 -> 75.0
+scbx005 scaleb 7.50 0 -> 7.50
+scbx006 scaleb 7.50 -1 -> 0.750
+scbx007 scaleb 7.50 -2 -> 0.0750
+scbx008 scaleb 7.50 -10 -> 7.50E-10
+scbx009 scaleb -7.50 3 -> -7.50E+3
+scbx010 scaleb -7.50 2 -> -750
+scbx011 scaleb -7.50 1 -> -75.0
+scbx012 scaleb -7.50 0 -> -7.50
+scbx013 scaleb -7.50 -1 -> -0.750
+
+-- Infinities
+scbx014 scaleb Infinity 1 -> Infinity
+scbx015 scaleb -Infinity 2 -> -Infinity
+scbx016 scaleb Infinity -1 -> Infinity
+scbx017 scaleb -Infinity -2 -> -Infinity
+
+-- Next two are somewhat undefined in 754r; treat as non-integer
+scbx018 scaleb 10 Infinity -> NaN Invalid_operation
+scbx019 scaleb 10 -Infinity -> NaN Invalid_operation
+
+-- NaNs are undefined in 754r; assume usual processing
+-- NaNs, 0 payload
+scbx021 scaleb NaN 1 -> NaN
+scbx022 scaleb -NaN -1 -> -NaN
+scbx023 scaleb sNaN 1 -> NaN Invalid_operation
+scbx024 scaleb -sNaN 1 -> -NaN Invalid_operation
+scbx025 scaleb 4 NaN -> NaN
+scbx026 scaleb -Inf -NaN -> -NaN
+scbx027 scaleb 4 sNaN -> NaN Invalid_operation
+scbx028 scaleb Inf -sNaN -> -NaN Invalid_operation
+
+-- non-integer RHS
+scbx030 scaleb 1.23 1 -> 12.3
+scbx031 scaleb 1.23 1.00 -> NaN Invalid_operation
+scbx032 scaleb 1.23 1.1 -> NaN Invalid_operation
+scbx033 scaleb 1.23 1.01 -> NaN Invalid_operation
+scbx034 scaleb 1.23 0.01 -> NaN Invalid_operation
+scbx035 scaleb 1.23 0.11 -> NaN Invalid_operation
+scbx036 scaleb 1.23 0.999999999 -> NaN Invalid_operation
+scbx037 scaleb 1.23 -1 -> 0.123
+scbx038 scaleb 1.23 -1.00 -> NaN Invalid_operation
+scbx039 scaleb 1.23 -1.1 -> NaN Invalid_operation
+scbx040 scaleb 1.23 -1.01 -> NaN Invalid_operation
+scbx041 scaleb 1.23 -0.01 -> NaN Invalid_operation
+scbx042 scaleb 1.23 -0.11 -> NaN Invalid_operation
+scbx043 scaleb 1.23 -0.999999999 -> NaN Invalid_operation
+scbx044 scaleb 1.23 0.1 -> NaN Invalid_operation
+scbx045 scaleb 1.23 1E+1 -> NaN Invalid_operation
+scbx046 scaleb 1.23 1.1234E+6 -> NaN Invalid_operation
+scbx047 scaleb 1.23 1.123E+4 -> NaN Invalid_operation
+
+
+scbx120 scaleb 1.23 2015 -> Infinity Overflow Inexact Rounded
+scbx121 scaleb 1.23 2016 -> Infinity Overflow Inexact Rounded
+scbx122 scaleb 1.23 2017 -> NaN Invalid_operation
+scbx123 scaleb 1.23 2018 -> NaN Invalid_operation
+scbx124 scaleb 1.23 -2015 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx125 scaleb 1.23 -2016 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx126 scaleb 1.23 -2017 -> NaN Invalid_operation
+scbx127 scaleb 1.23 -2018 -> NaN Invalid_operation
+
+-- NaNs, non-0 payload
+-- propagating NaNs
+scbx861 scaleb NaN01 -Inf -> NaN1
+scbx862 scaleb -NaN02 -1000 -> -NaN2
+scbx863 scaleb NaN03 1000 -> NaN3
+scbx864 scaleb NaN04 Inf -> NaN4
+scbx865 scaleb NaN05 NaN61 -> NaN5
+scbx866 scaleb -Inf -NaN71 -> -NaN71
+scbx867 scaleb -1000 NaN81 -> NaN81
+scbx868 scaleb 1000 NaN91 -> NaN91
+scbx869 scaleb Inf NaN101 -> NaN101
+scbx871 scaleb sNaN011 -Inf -> NaN11 Invalid_operation
+scbx872 scaleb sNaN012 -1000 -> NaN12 Invalid_operation
+scbx873 scaleb -sNaN013 1000 -> -NaN13 Invalid_operation
+scbx874 scaleb sNaN014 NaN171 -> NaN14 Invalid_operation
+scbx875 scaleb sNaN015 sNaN181 -> NaN15 Invalid_operation
+scbx876 scaleb NaN016 sNaN191 -> NaN191 Invalid_operation
+scbx877 scaleb -Inf sNaN201 -> NaN201 Invalid_operation
+scbx878 scaleb -1000 sNaN211 -> NaN211 Invalid_operation
+scbx879 scaleb 1000 -sNaN221 -> -NaN221 Invalid_operation
+scbx880 scaleb Inf sNaN231 -> NaN231 Invalid_operation
+scbx881 scaleb NaN025 sNaN241 -> NaN241 Invalid_operation
+
+-- finites
+scbx051 scaleb 7 -2 -> 0.07
+scbx052 scaleb -7 -2 -> -0.07
+scbx053 scaleb 75 -2 -> 0.75
+scbx054 scaleb -75 -2 -> -0.75
+scbx055 scaleb 7.50 -2 -> 0.0750
+scbx056 scaleb -7.50 -2 -> -0.0750
+scbx057 scaleb 7.500 -2 -> 0.07500
+scbx058 scaleb -7.500 -2 -> -0.07500
+scbx061 scaleb 7 -1 -> 0.7
+scbx062 scaleb -7 -1 -> -0.7
+scbx063 scaleb 75 -1 -> 7.5
+scbx064 scaleb -75 -1 -> -7.5
+scbx065 scaleb 7.50 -1 -> 0.750
+scbx066 scaleb -7.50 -1 -> -0.750
+scbx067 scaleb 7.500 -1 -> 0.7500
+scbx068 scaleb -7.500 -1 -> -0.7500
+scbx071 scaleb 7 0 -> 7
+scbx072 scaleb -7 0 -> -7
+scbx073 scaleb 75 0 -> 75
+scbx074 scaleb -75 0 -> -75
+scbx075 scaleb 7.50 0 -> 7.50
+scbx076 scaleb -7.50 0 -> -7.50
+scbx077 scaleb 7.500 0 -> 7.500
+scbx078 scaleb -7.500 0 -> -7.500
+scbx081 scaleb 7 1 -> 7E+1
+scbx082 scaleb -7 1 -> -7E+1
+scbx083 scaleb 75 1 -> 7.5E+2
+scbx084 scaleb -75 1 -> -7.5E+2
+scbx085 scaleb 7.50 1 -> 75.0
+scbx086 scaleb -7.50 1 -> -75.0
+scbx087 scaleb 7.500 1 -> 75.00
+scbx088 scaleb -7.500 1 -> -75.00
+scbx091 scaleb 7 2 -> 7E+2
+scbx092 scaleb -7 2 -> -7E+2
+scbx093 scaleb 75 2 -> 7.5E+3
+scbx094 scaleb -75 2 -> -7.5E+3
+scbx095 scaleb 7.50 2 -> 750
+scbx096 scaleb -7.50 2 -> -750
+scbx097 scaleb 7.500 2 -> 750.0
+scbx098 scaleb -7.500 2 -> -750.0
+
+-- zeros
+scbx111 scaleb 0 1 -> 0E+1
+scbx112 scaleb -0 2 -> -0E+2
+scbx113 scaleb 0E+4 3 -> 0E+7
+scbx114 scaleb -0E+4 4 -> -0E+8
+scbx115 scaleb 0.0000 5 -> 0E+1
+scbx116 scaleb -0.0000 6 -> -0E+2
+scbx117 scaleb 0E-141 7 -> 0E-134
+scbx118 scaleb -0E-141 8 -> -0E-133
+
+-- Nmax, Nmin, Ntiny
+scbx132 scaleb 9.99999999E+999 +999 -> Infinity Overflow Inexact Rounded
+scbx133 scaleb 9.99999999E+999 +10 -> Infinity Overflow Inexact Rounded
+scbx134 scaleb 9.99999999E+999 +1 -> Infinity Overflow Inexact Rounded
+scbx135 scaleb 9.99999999E+999 0 -> 9.99999999E+999
+scbx136 scaleb 9.99999999E+999 -1 -> 9.99999999E+998
+scbx137 scaleb 1E-999 +1 -> 1E-998
+scbx138 scaleb 1E-999 -0 -> 1E-999
+scbx139 scaleb 1E-999 -1 -> 1E-1000 Subnormal
+scbx140 scaleb 1.00000000E-999 +1 -> 1.00000000E-998
+scbx141 scaleb 1.00000000E-999 0 -> 1.00000000E-999
+scbx142 scaleb 1.00000000E-999 -1 -> 1.0000000E-1000 Subnormal Rounded
+scbx143 scaleb 1E-1007 +1 -> 1E-1006 Subnormal
+scbx144 scaleb 1E-1007 -0 -> 1E-1007 Subnormal
+scbx145 scaleb 1E-1007 -1 -> 0E-1007 Underflow Subnormal Inexact Rounded Clamped
+
+scbx150 scaleb -1E-1007 +1 -> -1E-1006 Subnormal
+scbx151 scaleb -1E-1007 -0 -> -1E-1007 Subnormal
+scbx152 scaleb -1E-1007 -1 -> -0E-1007 Underflow Subnormal Inexact Rounded Clamped
+scbx153 scaleb -1.00000000E-999 +1 -> -1.00000000E-998
+scbx154 scaleb -1.00000000E-999 +0 -> -1.00000000E-999
+scbx155 scaleb -1.00000000E-999 -1 -> -1.0000000E-1000 Subnormal Rounded
+scbx156 scaleb -1E-999 +1 -> -1E-998
+scbx157 scaleb -1E-999 -0 -> -1E-999
+scbx158 scaleb -1E-999 -1 -> -1E-1000 Subnormal
+scbx159 scaleb -9.99999999E+999 +1 -> -Infinity Overflow Inexact Rounded
+scbx160 scaleb -9.99999999E+999 +0 -> -9.99999999E+999
+scbx161 scaleb -9.99999999E+999 -1 -> -9.99999999E+998
+scbx162 scaleb -9E+999 +1 -> -Infinity Overflow Inexact Rounded
+scbx163 scaleb -1E+999 +1 -> -Infinity Overflow Inexact Rounded
+
+-- Krah examples
+precision: 34
+maxExponent: 999999999
+minExponent: -999999999
+-- integer overflow in 3.61 or earlier
+scbx164 scaleb 1E-999999999 -1200000000 -> NaN Invalid_operation
+-- out of range
+scbx165 scaleb -1E-999999999 +1200000000 -> NaN Invalid_operation
diff --git a/Lib/test/decimaltestdata/shift.decTest b/Lib/test/decimaltestdata/shift.decTest
index 78838cc10d3..3fac72f722e 100644
--- a/Lib/test/decimaltestdata/shift.decTest
+++ b/Lib/test/decimaltestdata/shift.decTest
@@ -1,250 +1,250 @@
-------------------------------------------------------------------------
--- shift.decTest -- shift coefficient left or right --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check
-shix001 shift 0 0 -> 0
-shix002 shift 0 2 -> 0
-shix003 shift 1 2 -> 100
-shix004 shift 1 8 -> 100000000
-shix005 shift 1 9 -> 0
-shix006 shift 1 -1 -> 0
-shix007 shift 123456789 -1 -> 12345678
-shix008 shift 123456789 -8 -> 1
-shix009 shift 123456789 -9 -> 0
-shix010 shift 0 -2 -> 0
-
--- rhs must be an integer
-shix011 shift 1 1.5 -> NaN Invalid_operation
-shix012 shift 1 1.0 -> NaN Invalid_operation
-shix013 shift 1 0.1 -> NaN Invalid_operation
-shix014 shift 1 0.0 -> NaN Invalid_operation
-shix015 shift 1 1E+1 -> NaN Invalid_operation
-shix016 shift 1 1E+99 -> NaN Invalid_operation
-shix017 shift 1 Inf -> NaN Invalid_operation
-shix018 shift 1 -Inf -> NaN Invalid_operation
--- and |rhs| <= precision
-shix020 shift 1 -1000 -> NaN Invalid_operation
-shix021 shift 1 -10 -> NaN Invalid_operation
-shix022 shift 1 10 -> NaN Invalid_operation
-shix023 shift 1 1000 -> NaN Invalid_operation
-
--- full shifting pattern
-shix030 shift 123456789 -9 -> 0
-shix031 shift 123456789 -8 -> 1
-shix032 shift 123456789 -7 -> 12
-shix033 shift 123456789 -6 -> 123
-shix034 shift 123456789 -5 -> 1234
-shix035 shift 123456789 -4 -> 12345
-shix036 shift 123456789 -3 -> 123456
-shix037 shift 123456789 -2 -> 1234567
-shix038 shift 123456789 -1 -> 12345678
-shix039 shift 123456789 -0 -> 123456789
-shix040 shift 123456789 +0 -> 123456789
-shix041 shift 123456789 +1 -> 234567890
-shix042 shift 123456789 +2 -> 345678900
-shix043 shift 123456789 +3 -> 456789000
-shix044 shift 123456789 +4 -> 567890000
-shix045 shift 123456789 +5 -> 678900000
-shix046 shift 123456789 +6 -> 789000000
-shix047 shift 123456789 +7 -> 890000000
-shix048 shift 123456789 +8 -> 900000000
-shix049 shift 123456789 +9 -> 0
-
--- from examples
-shix051 shift 34 8 -> '400000000'
-shix052 shift 12 9 -> '0'
-shix053 shift 123456789 -2 -> '1234567'
-shix054 shift 123456789 0 -> '123456789'
-shix055 shift 123456789 +2 -> '345678900'
-
--- zeros
-shix060 shift 0E-10 +9 -> 0E-10
-shix061 shift 0E-10 -9 -> 0E-10
-shix062 shift 0.000 +9 -> 0.000
-shix063 shift 0.000 -9 -> 0.000
-shix064 shift 0E+10 +9 -> 0E+10
-shix065 shift 0E+10 -9 -> 0E+10
-shix066 shift -0E-10 +9 -> -0E-10
-shix067 shift -0E-10 -9 -> -0E-10
-shix068 shift -0.000 +9 -> -0.000
-shix069 shift -0.000 -9 -> -0.000
-shix070 shift -0E+10 +9 -> -0E+10
-shix071 shift -0E+10 -9 -> -0E+10
-
--- Nmax, Nmin, Ntiny
-shix141 shift 9.99999999E+999 -1 -> 9.9999999E+998
-shix142 shift 9.99999999E+999 -8 -> 9E+991
-shix143 shift 9.99999999E+999 1 -> 9.99999990E+999
-shix144 shift 9.99999999E+999 8 -> 9.00000000E+999
-shix145 shift 1E-999 -1 -> 0E-999
-shix146 shift 1E-999 -8 -> 0E-999
-shix147 shift 1E-999 1 -> 1.0E-998
-shix148 shift 1E-999 8 -> 1.00000000E-991
-shix151 shift 1.00000000E-999 -1 -> 1.0000000E-1000
-shix152 shift 1.00000000E-999 -8 -> 1E-1007
-shix153 shift 1.00000000E-999 1 -> 0E-1007
-shix154 shift 1.00000000E-999 8 -> 0E-1007
-shix155 shift 9.00000000E-999 -1 -> 9.0000000E-1000
-shix156 shift 9.00000000E-999 -8 -> 9E-1007
-shix157 shift 9.00000000E-999 1 -> 0E-1007
-shix158 shift 9.00000000E-999 8 -> 0E-1007
-shix160 shift 1E-1007 -1 -> 0E-1007
-shix161 shift 1E-1007 -8 -> 0E-1007
-shix162 shift 1E-1007 1 -> 1.0E-1006
-shix163 shift 1E-1007 8 -> 1.00000000E-999
--- negatives
-shix171 shift -9.99999999E+999 -1 -> -9.9999999E+998
-shix172 shift -9.99999999E+999 -8 -> -9E+991
-shix173 shift -9.99999999E+999 1 -> -9.99999990E+999
-shix174 shift -9.99999999E+999 8 -> -9.00000000E+999
-shix175 shift -1E-999 -1 -> -0E-999
-shix176 shift -1E-999 -8 -> -0E-999
-shix177 shift -1E-999 1 -> -1.0E-998
-shix178 shift -1E-999 8 -> -1.00000000E-991
-shix181 shift -1.00000000E-999 -1 -> -1.0000000E-1000
-shix182 shift -1.00000000E-999 -8 -> -1E-1007
-shix183 shift -1.00000000E-999 1 -> -0E-1007
-shix184 shift -1.00000000E-999 8 -> -0E-1007
-shix185 shift -9.00000000E-999 -1 -> -9.0000000E-1000
-shix186 shift -9.00000000E-999 -8 -> -9E-1007
-shix187 shift -9.00000000E-999 1 -> -0E-1007
-shix188 shift -9.00000000E-999 8 -> -0E-1007
-shix190 shift -1E-1007 -1 -> -0E-1007
-shix191 shift -1E-1007 -8 -> -0E-1007
-shix192 shift -1E-1007 1 -> -1.0E-1006
-shix193 shift -1E-1007 8 -> -1.00000000E-999
-
--- more negatives (of sanities)
-shix201 shift -0 0 -> -0
-shix202 shift -0 2 -> -0
-shix203 shift -1 2 -> -100
-shix204 shift -1 8 -> -100000000
-shix205 shift -1 9 -> -0
-shix206 shift -1 -1 -> -0
-shix207 shift -123456789 -1 -> -12345678
-shix208 shift -123456789 -8 -> -1
-shix209 shift -123456789 -9 -> -0
-shix210 shift -0 -2 -> -0
-shix211 shift -0 -0 -> -0
-
-
--- Specials; NaNs are handled as usual
-shix781 shift -Inf -8 -> -Infinity
-shix782 shift -Inf -1 -> -Infinity
-shix783 shift -Inf -0 -> -Infinity
-shix784 shift -Inf 0 -> -Infinity
-shix785 shift -Inf 1 -> -Infinity
-shix786 shift -Inf 8 -> -Infinity
-shix787 shift -1000 -Inf -> NaN Invalid_operation
-shix788 shift -Inf -Inf -> NaN Invalid_operation
-shix789 shift -1 -Inf -> NaN Invalid_operation
-shix790 shift -0 -Inf -> NaN Invalid_operation
-shix791 shift 0 -Inf -> NaN Invalid_operation
-shix792 shift 1 -Inf -> NaN Invalid_operation
-shix793 shift 1000 -Inf -> NaN Invalid_operation
-shix794 shift Inf -Inf -> NaN Invalid_operation
-
-shix800 shift Inf -Inf -> NaN Invalid_operation
-shix801 shift Inf -8 -> Infinity
-shix802 shift Inf -1 -> Infinity
-shix803 shift Inf -0 -> Infinity
-shix804 shift Inf 0 -> Infinity
-shix805 shift Inf 1 -> Infinity
-shix806 shift Inf 8 -> Infinity
-shix807 shift Inf Inf -> NaN Invalid_operation
-shix808 shift -1000 Inf -> NaN Invalid_operation
-shix809 shift -Inf Inf -> NaN Invalid_operation
-shix810 shift -1 Inf -> NaN Invalid_operation
-shix811 shift -0 Inf -> NaN Invalid_operation
-shix812 shift 0 Inf -> NaN Invalid_operation
-shix813 shift 1 Inf -> NaN Invalid_operation
-shix814 shift 1000 Inf -> NaN Invalid_operation
-shix815 shift Inf Inf -> NaN Invalid_operation
-
-shix821 shift NaN -Inf -> NaN
-shix822 shift NaN -1000 -> NaN
-shix823 shift NaN -1 -> NaN
-shix824 shift NaN -0 -> NaN
-shix825 shift NaN 0 -> NaN
-shix826 shift NaN 1 -> NaN
-shix827 shift NaN 1000 -> NaN
-shix828 shift NaN Inf -> NaN
-shix829 shift NaN NaN -> NaN
-shix830 shift -Inf NaN -> NaN
-shix831 shift -1000 NaN -> NaN
-shix832 shift -1 NaN -> NaN
-shix833 shift -0 NaN -> NaN
-shix834 shift 0 NaN -> NaN
-shix835 shift 1 NaN -> NaN
-shix836 shift 1000 NaN -> NaN
-shix837 shift Inf NaN -> NaN
-
-shix841 shift sNaN -Inf -> NaN Invalid_operation
-shix842 shift sNaN -1000 -> NaN Invalid_operation
-shix843 shift sNaN -1 -> NaN Invalid_operation
-shix844 shift sNaN -0 -> NaN Invalid_operation
-shix845 shift sNaN 0 -> NaN Invalid_operation
-shix846 shift sNaN 1 -> NaN Invalid_operation
-shix847 shift sNaN 1000 -> NaN Invalid_operation
-shix848 shift sNaN NaN -> NaN Invalid_operation
-shix849 shift sNaN sNaN -> NaN Invalid_operation
-shix850 shift NaN sNaN -> NaN Invalid_operation
-shix851 shift -Inf sNaN -> NaN Invalid_operation
-shix852 shift -1000 sNaN -> NaN Invalid_operation
-shix853 shift -1 sNaN -> NaN Invalid_operation
-shix854 shift -0 sNaN -> NaN Invalid_operation
-shix855 shift 0 sNaN -> NaN Invalid_operation
-shix856 shift 1 sNaN -> NaN Invalid_operation
-shix857 shift 1000 sNaN -> NaN Invalid_operation
-shix858 shift Inf sNaN -> NaN Invalid_operation
-shix859 shift NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-shix861 shift NaN1 -Inf -> NaN1
-shix862 shift +NaN2 -1000 -> NaN2
-shix863 shift NaN3 1000 -> NaN3
-shix864 shift NaN4 Inf -> NaN4
-shix865 shift NaN5 +NaN6 -> NaN5
-shix866 shift -Inf NaN7 -> NaN7
-shix867 shift -1000 NaN8 -> NaN8
-shix868 shift 1000 NaN9 -> NaN9
-shix869 shift Inf +NaN10 -> NaN10
-shix871 shift sNaN11 -Inf -> NaN11 Invalid_operation
-shix872 shift sNaN12 -1000 -> NaN12 Invalid_operation
-shix873 shift sNaN13 1000 -> NaN13 Invalid_operation
-shix874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
-shix875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
-shix876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
-shix877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
-shix878 shift -1000 sNaN21 -> NaN21 Invalid_operation
-shix879 shift 1000 sNaN22 -> NaN22 Invalid_operation
-shix880 shift Inf sNaN23 -> NaN23 Invalid_operation
-shix881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
-shix882 shift -NaN26 NaN28 -> -NaN26
-shix883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
-shix884 shift 1000 -NaN30 -> -NaN30
-shix885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
+------------------------------------------------------------------------
+-- shift.decTest -- shift coefficient left or right --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check
+shix001 shift 0 0 -> 0
+shix002 shift 0 2 -> 0
+shix003 shift 1 2 -> 100
+shix004 shift 1 8 -> 100000000
+shix005 shift 1 9 -> 0
+shix006 shift 1 -1 -> 0
+shix007 shift 123456789 -1 -> 12345678
+shix008 shift 123456789 -8 -> 1
+shix009 shift 123456789 -9 -> 0
+shix010 shift 0 -2 -> 0
+
+-- rhs must be an integer
+shix011 shift 1 1.5 -> NaN Invalid_operation
+shix012 shift 1 1.0 -> NaN Invalid_operation
+shix013 shift 1 0.1 -> NaN Invalid_operation
+shix014 shift 1 0.0 -> NaN Invalid_operation
+shix015 shift 1 1E+1 -> NaN Invalid_operation
+shix016 shift 1 1E+99 -> NaN Invalid_operation
+shix017 shift 1 Inf -> NaN Invalid_operation
+shix018 shift 1 -Inf -> NaN Invalid_operation
+-- and |rhs| <= precision
+shix020 shift 1 -1000 -> NaN Invalid_operation
+shix021 shift 1 -10 -> NaN Invalid_operation
+shix022 shift 1 10 -> NaN Invalid_operation
+shix023 shift 1 1000 -> NaN Invalid_operation
+
+-- full shifting pattern
+shix030 shift 123456789 -9 -> 0
+shix031 shift 123456789 -8 -> 1
+shix032 shift 123456789 -7 -> 12
+shix033 shift 123456789 -6 -> 123
+shix034 shift 123456789 -5 -> 1234
+shix035 shift 123456789 -4 -> 12345
+shix036 shift 123456789 -3 -> 123456
+shix037 shift 123456789 -2 -> 1234567
+shix038 shift 123456789 -1 -> 12345678
+shix039 shift 123456789 -0 -> 123456789
+shix040 shift 123456789 +0 -> 123456789
+shix041 shift 123456789 +1 -> 234567890
+shix042 shift 123456789 +2 -> 345678900
+shix043 shift 123456789 +3 -> 456789000
+shix044 shift 123456789 +4 -> 567890000
+shix045 shift 123456789 +5 -> 678900000
+shix046 shift 123456789 +6 -> 789000000
+shix047 shift 123456789 +7 -> 890000000
+shix048 shift 123456789 +8 -> 900000000
+shix049 shift 123456789 +9 -> 0
+
+-- from examples
+shix051 shift 34 8 -> '400000000'
+shix052 shift 12 9 -> '0'
+shix053 shift 123456789 -2 -> '1234567'
+shix054 shift 123456789 0 -> '123456789'
+shix055 shift 123456789 +2 -> '345678900'
+
+-- zeros
+shix060 shift 0E-10 +9 -> 0E-10
+shix061 shift 0E-10 -9 -> 0E-10
+shix062 shift 0.000 +9 -> 0.000
+shix063 shift 0.000 -9 -> 0.000
+shix064 shift 0E+10 +9 -> 0E+10
+shix065 shift 0E+10 -9 -> 0E+10
+shix066 shift -0E-10 +9 -> -0E-10
+shix067 shift -0E-10 -9 -> -0E-10
+shix068 shift -0.000 +9 -> -0.000
+shix069 shift -0.000 -9 -> -0.000
+shix070 shift -0E+10 +9 -> -0E+10
+shix071 shift -0E+10 -9 -> -0E+10
+
+-- Nmax, Nmin, Ntiny
+shix141 shift 9.99999999E+999 -1 -> 9.9999999E+998
+shix142 shift 9.99999999E+999 -8 -> 9E+991
+shix143 shift 9.99999999E+999 1 -> 9.99999990E+999
+shix144 shift 9.99999999E+999 8 -> 9.00000000E+999
+shix145 shift 1E-999 -1 -> 0E-999
+shix146 shift 1E-999 -8 -> 0E-999
+shix147 shift 1E-999 1 -> 1.0E-998
+shix148 shift 1E-999 8 -> 1.00000000E-991
+shix151 shift 1.00000000E-999 -1 -> 1.0000000E-1000
+shix152 shift 1.00000000E-999 -8 -> 1E-1007
+shix153 shift 1.00000000E-999 1 -> 0E-1007
+shix154 shift 1.00000000E-999 8 -> 0E-1007
+shix155 shift 9.00000000E-999 -1 -> 9.0000000E-1000
+shix156 shift 9.00000000E-999 -8 -> 9E-1007
+shix157 shift 9.00000000E-999 1 -> 0E-1007
+shix158 shift 9.00000000E-999 8 -> 0E-1007
+shix160 shift 1E-1007 -1 -> 0E-1007
+shix161 shift 1E-1007 -8 -> 0E-1007
+shix162 shift 1E-1007 1 -> 1.0E-1006
+shix163 shift 1E-1007 8 -> 1.00000000E-999
+-- negatives
+shix171 shift -9.99999999E+999 -1 -> -9.9999999E+998
+shix172 shift -9.99999999E+999 -8 -> -9E+991
+shix173 shift -9.99999999E+999 1 -> -9.99999990E+999
+shix174 shift -9.99999999E+999 8 -> -9.00000000E+999
+shix175 shift -1E-999 -1 -> -0E-999
+shix176 shift -1E-999 -8 -> -0E-999
+shix177 shift -1E-999 1 -> -1.0E-998
+shix178 shift -1E-999 8 -> -1.00000000E-991
+shix181 shift -1.00000000E-999 -1 -> -1.0000000E-1000
+shix182 shift -1.00000000E-999 -8 -> -1E-1007
+shix183 shift -1.00000000E-999 1 -> -0E-1007
+shix184 shift -1.00000000E-999 8 -> -0E-1007
+shix185 shift -9.00000000E-999 -1 -> -9.0000000E-1000
+shix186 shift -9.00000000E-999 -8 -> -9E-1007
+shix187 shift -9.00000000E-999 1 -> -0E-1007
+shix188 shift -9.00000000E-999 8 -> -0E-1007
+shix190 shift -1E-1007 -1 -> -0E-1007
+shix191 shift -1E-1007 -8 -> -0E-1007
+shix192 shift -1E-1007 1 -> -1.0E-1006
+shix193 shift -1E-1007 8 -> -1.00000000E-999
+
+-- more negatives (of sanities)
+shix201 shift -0 0 -> -0
+shix202 shift -0 2 -> -0
+shix203 shift -1 2 -> -100
+shix204 shift -1 8 -> -100000000
+shix205 shift -1 9 -> -0
+shix206 shift -1 -1 -> -0
+shix207 shift -123456789 -1 -> -12345678
+shix208 shift -123456789 -8 -> -1
+shix209 shift -123456789 -9 -> -0
+shix210 shift -0 -2 -> -0
+shix211 shift -0 -0 -> -0
+
+
+-- Specials; NaNs are handled as usual
+shix781 shift -Inf -8 -> -Infinity
+shix782 shift -Inf -1 -> -Infinity
+shix783 shift -Inf -0 -> -Infinity
+shix784 shift -Inf 0 -> -Infinity
+shix785 shift -Inf 1 -> -Infinity
+shix786 shift -Inf 8 -> -Infinity
+shix787 shift -1000 -Inf -> NaN Invalid_operation
+shix788 shift -Inf -Inf -> NaN Invalid_operation
+shix789 shift -1 -Inf -> NaN Invalid_operation
+shix790 shift -0 -Inf -> NaN Invalid_operation
+shix791 shift 0 -Inf -> NaN Invalid_operation
+shix792 shift 1 -Inf -> NaN Invalid_operation
+shix793 shift 1000 -Inf -> NaN Invalid_operation
+shix794 shift Inf -Inf -> NaN Invalid_operation
+
+shix800 shift Inf -Inf -> NaN Invalid_operation
+shix801 shift Inf -8 -> Infinity
+shix802 shift Inf -1 -> Infinity
+shix803 shift Inf -0 -> Infinity
+shix804 shift Inf 0 -> Infinity
+shix805 shift Inf 1 -> Infinity
+shix806 shift Inf 8 -> Infinity
+shix807 shift Inf Inf -> NaN Invalid_operation
+shix808 shift -1000 Inf -> NaN Invalid_operation
+shix809 shift -Inf Inf -> NaN Invalid_operation
+shix810 shift -1 Inf -> NaN Invalid_operation
+shix811 shift -0 Inf -> NaN Invalid_operation
+shix812 shift 0 Inf -> NaN Invalid_operation
+shix813 shift 1 Inf -> NaN Invalid_operation
+shix814 shift 1000 Inf -> NaN Invalid_operation
+shix815 shift Inf Inf -> NaN Invalid_operation
+
+shix821 shift NaN -Inf -> NaN
+shix822 shift NaN -1000 -> NaN
+shix823 shift NaN -1 -> NaN
+shix824 shift NaN -0 -> NaN
+shix825 shift NaN 0 -> NaN
+shix826 shift NaN 1 -> NaN
+shix827 shift NaN 1000 -> NaN
+shix828 shift NaN Inf -> NaN
+shix829 shift NaN NaN -> NaN
+shix830 shift -Inf NaN -> NaN
+shix831 shift -1000 NaN -> NaN
+shix832 shift -1 NaN -> NaN
+shix833 shift -0 NaN -> NaN
+shix834 shift 0 NaN -> NaN
+shix835 shift 1 NaN -> NaN
+shix836 shift 1000 NaN -> NaN
+shix837 shift Inf NaN -> NaN
+
+shix841 shift sNaN -Inf -> NaN Invalid_operation
+shix842 shift sNaN -1000 -> NaN Invalid_operation
+shix843 shift sNaN -1 -> NaN Invalid_operation
+shix844 shift sNaN -0 -> NaN Invalid_operation
+shix845 shift sNaN 0 -> NaN Invalid_operation
+shix846 shift sNaN 1 -> NaN Invalid_operation
+shix847 shift sNaN 1000 -> NaN Invalid_operation
+shix848 shift sNaN NaN -> NaN Invalid_operation
+shix849 shift sNaN sNaN -> NaN Invalid_operation
+shix850 shift NaN sNaN -> NaN Invalid_operation
+shix851 shift -Inf sNaN -> NaN Invalid_operation
+shix852 shift -1000 sNaN -> NaN Invalid_operation
+shix853 shift -1 sNaN -> NaN Invalid_operation
+shix854 shift -0 sNaN -> NaN Invalid_operation
+shix855 shift 0 sNaN -> NaN Invalid_operation
+shix856 shift 1 sNaN -> NaN Invalid_operation
+shix857 shift 1000 sNaN -> NaN Invalid_operation
+shix858 shift Inf sNaN -> NaN Invalid_operation
+shix859 shift NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+shix861 shift NaN1 -Inf -> NaN1
+shix862 shift +NaN2 -1000 -> NaN2
+shix863 shift NaN3 1000 -> NaN3
+shix864 shift NaN4 Inf -> NaN4
+shix865 shift NaN5 +NaN6 -> NaN5
+shix866 shift -Inf NaN7 -> NaN7
+shix867 shift -1000 NaN8 -> NaN8
+shix868 shift 1000 NaN9 -> NaN9
+shix869 shift Inf +NaN10 -> NaN10
+shix871 shift sNaN11 -Inf -> NaN11 Invalid_operation
+shix872 shift sNaN12 -1000 -> NaN12 Invalid_operation
+shix873 shift sNaN13 1000 -> NaN13 Invalid_operation
+shix874 shift sNaN14 NaN17 -> NaN14 Invalid_operation
+shix875 shift sNaN15 sNaN18 -> NaN15 Invalid_operation
+shix876 shift NaN16 sNaN19 -> NaN19 Invalid_operation
+shix877 shift -Inf +sNaN20 -> NaN20 Invalid_operation
+shix878 shift -1000 sNaN21 -> NaN21 Invalid_operation
+shix879 shift 1000 sNaN22 -> NaN22 Invalid_operation
+shix880 shift Inf sNaN23 -> NaN23 Invalid_operation
+shix881 shift +NaN25 +sNaN24 -> NaN24 Invalid_operation
+shix882 shift -NaN26 NaN28 -> -NaN26
+shix883 shift -sNaN27 sNaN29 -> -NaN27 Invalid_operation
+shix884 shift 1000 -NaN30 -> -NaN30
+shix885 shift 1000 -sNaN31 -> -NaN31 Invalid_operation
diff --git a/Lib/test/decimaltestdata/tointegralx.decTest b/Lib/test/decimaltestdata/tointegralx.decTest
index e250e3a06ea..0ce0d0935e1 100644
--- a/Lib/test/decimaltestdata/tointegralx.decTest
+++ b/Lib/test/decimaltestdata/tointegralx.decTest
@@ -1,255 +1,255 @@
-------------------------------------------------------------------------
--- tointegralx.decTest -- round decimal to integral value, exact --
--- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
--- This set of tests tests the extended specification 'round-to-integral
--- value' operation (from IEEE 854, later modified in 754r).
--- All non-zero results are defined as being those from either copy or
--- quantize, so those are assumed to have been tested.
-
--- This tests toIntegraExact, which may set Inexact
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
-intxx001 tointegralx 0 -> 0
-intxx002 tointegralx 0.0 -> 0
-intxx003 tointegralx 0.1 -> 0 Inexact Rounded
-intxx004 tointegralx 0.2 -> 0 Inexact Rounded
-intxx005 tointegralx 0.3 -> 0 Inexact Rounded
-intxx006 tointegralx 0.4 -> 0 Inexact Rounded
-intxx007 tointegralx 0.5 -> 1 Inexact Rounded
-intxx008 tointegralx 0.6 -> 1 Inexact Rounded
-intxx009 tointegralx 0.7 -> 1 Inexact Rounded
-intxx010 tointegralx 0.8 -> 1 Inexact Rounded
-intxx011 tointegralx 0.9 -> 1 Inexact Rounded
-intxx012 tointegralx 1 -> 1
-intxx013 tointegralx 1.0 -> 1 Rounded
-intxx014 tointegralx 1.1 -> 1 Inexact Rounded
-intxx015 tointegralx 1.2 -> 1 Inexact Rounded
-intxx016 tointegralx 1.3 -> 1 Inexact Rounded
-intxx017 tointegralx 1.4 -> 1 Inexact Rounded
-intxx018 tointegralx 1.5 -> 2 Inexact Rounded
-intxx019 tointegralx 1.6 -> 2 Inexact Rounded
-intxx020 tointegralx 1.7 -> 2 Inexact Rounded
-intxx021 tointegralx 1.8 -> 2 Inexact Rounded
-intxx022 tointegralx 1.9 -> 2 Inexact Rounded
--- negatives
-intxx031 tointegralx -0 -> -0
-intxx032 tointegralx -0.0 -> -0
-intxx033 tointegralx -0.1 -> -0 Inexact Rounded
-intxx034 tointegralx -0.2 -> -0 Inexact Rounded
-intxx035 tointegralx -0.3 -> -0 Inexact Rounded
-intxx036 tointegralx -0.4 -> -0 Inexact Rounded
-intxx037 tointegralx -0.5 -> -1 Inexact Rounded
-intxx038 tointegralx -0.6 -> -1 Inexact Rounded
-intxx039 tointegralx -0.7 -> -1 Inexact Rounded
-intxx040 tointegralx -0.8 -> -1 Inexact Rounded
-intxx041 tointegralx -0.9 -> -1 Inexact Rounded
-intxx042 tointegralx -1 -> -1
-intxx043 tointegralx -1.0 -> -1 Rounded
-intxx044 tointegralx -1.1 -> -1 Inexact Rounded
-intxx045 tointegralx -1.2 -> -1 Inexact Rounded
-intxx046 tointegralx -1.3 -> -1 Inexact Rounded
-intxx047 tointegralx -1.4 -> -1 Inexact Rounded
-intxx048 tointegralx -1.5 -> -2 Inexact Rounded
-intxx049 tointegralx -1.6 -> -2 Inexact Rounded
-intxx050 tointegralx -1.7 -> -2 Inexact Rounded
-intxx051 tointegralx -1.8 -> -2 Inexact Rounded
-intxx052 tointegralx -1.9 -> -2 Inexact Rounded
--- next two would be NaN using quantize(x, 0)
-intxx053 tointegralx 10E+30 -> 1.0E+31
-intxx054 tointegralx -10E+30 -> -1.0E+31
-
--- numbers around precision
-precision: 9
-intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded
-intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded
-intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded
-intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
-intxx065 tointegralx '56267E-0' -> '56267'
-intxx066 tointegralx '56267E+0' -> '56267'
-intxx067 tointegralx '56267E+1' -> '5.6267E+5'
-intxx068 tointegralx '56267E+2' -> '5.6267E+6'
-intxx069 tointegralx '56267E+3' -> '5.6267E+7'
-intxx070 tointegralx '56267E+4' -> '5.6267E+8'
-intxx071 tointegralx '56267E+5' -> '5.6267E+9'
-intxx072 tointegralx '56267E+6' -> '5.6267E+10'
-intxx073 tointegralx '1.23E+96' -> '1.23E+96'
-intxx074 tointegralx '1.23E+384' -> '1.23E+384'
-intxx075 tointegralx '1.23E+999' -> '1.23E+999'
-
-intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
-intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
-intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
-intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
-intxx085 tointegralx '-56267E-0' -> '-56267'
-intxx086 tointegralx '-56267E+0' -> '-56267'
-intxx087 tointegralx '-56267E+1' -> '-5.6267E+5'
-intxx088 tointegralx '-56267E+2' -> '-5.6267E+6'
-intxx089 tointegralx '-56267E+3' -> '-5.6267E+7'
-intxx090 tointegralx '-56267E+4' -> '-5.6267E+8'
-intxx091 tointegralx '-56267E+5' -> '-5.6267E+9'
-intxx092 tointegralx '-56267E+6' -> '-5.6267E+10'
-intxx093 tointegralx '-1.23E+96' -> '-1.23E+96'
-intxx094 tointegralx '-1.23E+384' -> '-1.23E+384'
-intxx095 tointegralx '-1.23E+999' -> '-1.23E+999'
-
--- subnormal inputs
-intxx100 tointegralx 1E-999 -> 0 Inexact Rounded
-intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded
-intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded
-intxx103 tointegralx 0E-999 -> 0
-
--- specials and zeros
-intxx120 tointegralx 'Inf' -> Infinity
-intxx121 tointegralx '-Inf' -> -Infinity
-intxx122 tointegralx NaN -> NaN
-intxx123 tointegralx sNaN -> NaN Invalid_operation
-intxx124 tointegralx 0 -> 0
-intxx125 tointegralx -0 -> -0
-intxx126 tointegralx 0.000 -> 0
-intxx127 tointegralx 0.00 -> 0
-intxx128 tointegralx 0.0 -> 0
-intxx129 tointegralx 0 -> 0
-intxx130 tointegralx 0E-3 -> 0
-intxx131 tointegralx 0E-2 -> 0
-intxx132 tointegralx 0E-1 -> 0
-intxx133 tointegralx 0E-0 -> 0
-intxx134 tointegralx 0E+1 -> 0E+1
-intxx135 tointegralx 0E+2 -> 0E+2
-intxx136 tointegralx 0E+3 -> 0E+3
-intxx137 tointegralx 0E+4 -> 0E+4
-intxx138 tointegralx 0E+5 -> 0E+5
-intxx139 tointegralx -0.000 -> -0
-intxx140 tointegralx -0.00 -> -0
-intxx141 tointegralx -0.0 -> -0
-intxx142 tointegralx -0 -> -0
-intxx143 tointegralx -0E-3 -> -0
-intxx144 tointegralx -0E-2 -> -0
-intxx145 tointegralx -0E-1 -> -0
-intxx146 tointegralx -0E-0 -> -0
-intxx147 tointegralx -0E+1 -> -0E+1
-intxx148 tointegralx -0E+2 -> -0E+2
-intxx149 tointegralx -0E+3 -> -0E+3
-intxx150 tointegralx -0E+4 -> -0E+4
-intxx151 tointegralx -0E+5 -> -0E+5
--- propagating NaNs
-intxx152 tointegralx NaN808 -> NaN808
-intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation
-intxx154 tointegralx -NaN808 -> -NaN808
-intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
-intxx156 tointegralx -NaN -> -NaN
-intxx157 tointegralx -sNaN -> -NaN Invalid_operation
-
--- examples
-rounding: half_up
-precision: 9
-intxx200 tointegralx 2.1 -> 2 Inexact Rounded
-intxx201 tointegralx 100 -> 100
-intxx202 tointegralx 100.0 -> 100 Rounded
-intxx203 tointegralx 101.5 -> 102 Inexact Rounded
-intxx204 tointegralx -101.5 -> -102 Inexact Rounded
-intxx205 tointegralx 10E+5 -> 1.0E+6
-intxx206 tointegralx 7.89E+77 -> 7.89E+77
-intxx207 tointegralx -Inf -> -Infinity
-
-
--- all rounding modes
-rounding: half_even
-
-intxx210 tointegralx 55.5 -> 56 Inexact Rounded
-intxx211 tointegralx 56.5 -> 56 Inexact Rounded
-intxx212 tointegralx 57.5 -> 58 Inexact Rounded
-intxx213 tointegralx -55.5 -> -56 Inexact Rounded
-intxx214 tointegralx -56.5 -> -56 Inexact Rounded
-intxx215 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_up
-
-intxx220 tointegralx 55.5 -> 56 Inexact Rounded
-intxx221 tointegralx 56.5 -> 57 Inexact Rounded
-intxx222 tointegralx 57.5 -> 58 Inexact Rounded
-intxx223 tointegralx -55.5 -> -56 Inexact Rounded
-intxx224 tointegralx -56.5 -> -57 Inexact Rounded
-intxx225 tointegralx -57.5 -> -58 Inexact Rounded
-
-rounding: half_down
-
-intxx230 tointegralx 55.5 -> 55 Inexact Rounded
-intxx231 tointegralx 56.5 -> 56 Inexact Rounded
-intxx232 tointegralx 57.5 -> 57 Inexact Rounded
-intxx233 tointegralx -55.5 -> -55 Inexact Rounded
-intxx234 tointegralx -56.5 -> -56 Inexact Rounded
-intxx235 tointegralx -57.5 -> -57 Inexact Rounded
-
-rounding: up
-
-intxx240 tointegralx 55.3 -> 56 Inexact Rounded
-intxx241 tointegralx 56.3 -> 57 Inexact Rounded
-intxx242 tointegralx 57.3 -> 58 Inexact Rounded
-intxx243 tointegralx -55.3 -> -56 Inexact Rounded
-intxx244 tointegralx -56.3 -> -57 Inexact Rounded
-intxx245 tointegralx -57.3 -> -58 Inexact Rounded
-
-rounding: down
-
-intxx250 tointegralx 55.7 -> 55 Inexact Rounded
-intxx251 tointegralx 56.7 -> 56 Inexact Rounded
-intxx252 tointegralx 57.7 -> 57 Inexact Rounded
-intxx253 tointegralx -55.7 -> -55 Inexact Rounded
-intxx254 tointegralx -56.7 -> -56 Inexact Rounded
-intxx255 tointegralx -57.7 -> -57 Inexact Rounded
-
-rounding: ceiling
-
-intxx260 tointegralx 55.3 -> 56 Inexact Rounded
-intxx261 tointegralx 56.3 -> 57 Inexact Rounded
-intxx262 tointegralx 57.3 -> 58 Inexact Rounded
-intxx263 tointegralx -55.3 -> -55 Inexact Rounded
-intxx264 tointegralx -56.3 -> -56 Inexact Rounded
-intxx265 tointegralx -57.3 -> -57 Inexact Rounded
-
-rounding: floor
-
-intxx270 tointegralx 55.7 -> 55 Inexact Rounded
-intxx271 tointegralx 56.7 -> 56 Inexact Rounded
-intxx272 tointegralx 57.7 -> 57 Inexact Rounded
-intxx273 tointegralx -55.7 -> -56 Inexact Rounded
-intxx274 tointegralx -56.7 -> -57 Inexact Rounded
-intxx275 tointegralx -57.7 -> -58 Inexact Rounded
-
--- Int and uInt32 edge values for testing conversions
-precision: 16
-intxx300 tointegralx -2147483646 -> -2147483646
-intxx301 tointegralx -2147483647 -> -2147483647
-intxx302 tointegralx -2147483648 -> -2147483648
-intxx303 tointegralx -2147483649 -> -2147483649
-intxx304 tointegralx 2147483646 -> 2147483646
-intxx305 tointegralx 2147483647 -> 2147483647
-intxx306 tointegralx 2147483648 -> 2147483648
-intxx307 tointegralx 2147483649 -> 2147483649
-intxx308 tointegralx 4294967294 -> 4294967294
-intxx309 tointegralx 4294967295 -> 4294967295
-intxx310 tointegralx 4294967296 -> 4294967296
-intxx311 tointegralx 4294967297 -> 4294967297
+------------------------------------------------------------------------
+-- tointegralx.decTest -- round decimal to integral value, exact --
+-- Copyright (c) IBM Corporation, 2001, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+-- This set of tests tests the extended specification 'round-to-integral
+-- value' operation (from IEEE 854, later modified in 754r).
+-- All non-zero results are defined as being those from either copy or
+-- quantize, so those are assumed to have been tested.
+
+-- This tests toIntegraExact, which may set Inexact
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+intxx001 tointegralx 0 -> 0
+intxx002 tointegralx 0.0 -> 0
+intxx003 tointegralx 0.1 -> 0 Inexact Rounded
+intxx004 tointegralx 0.2 -> 0 Inexact Rounded
+intxx005 tointegralx 0.3 -> 0 Inexact Rounded
+intxx006 tointegralx 0.4 -> 0 Inexact Rounded
+intxx007 tointegralx 0.5 -> 1 Inexact Rounded
+intxx008 tointegralx 0.6 -> 1 Inexact Rounded
+intxx009 tointegralx 0.7 -> 1 Inexact Rounded
+intxx010 tointegralx 0.8 -> 1 Inexact Rounded
+intxx011 tointegralx 0.9 -> 1 Inexact Rounded
+intxx012 tointegralx 1 -> 1
+intxx013 tointegralx 1.0 -> 1 Rounded
+intxx014 tointegralx 1.1 -> 1 Inexact Rounded
+intxx015 tointegralx 1.2 -> 1 Inexact Rounded
+intxx016 tointegralx 1.3 -> 1 Inexact Rounded
+intxx017 tointegralx 1.4 -> 1 Inexact Rounded
+intxx018 tointegralx 1.5 -> 2 Inexact Rounded
+intxx019 tointegralx 1.6 -> 2 Inexact Rounded
+intxx020 tointegralx 1.7 -> 2 Inexact Rounded
+intxx021 tointegralx 1.8 -> 2 Inexact Rounded
+intxx022 tointegralx 1.9 -> 2 Inexact Rounded
+-- negatives
+intxx031 tointegralx -0 -> -0
+intxx032 tointegralx -0.0 -> -0
+intxx033 tointegralx -0.1 -> -0 Inexact Rounded
+intxx034 tointegralx -0.2 -> -0 Inexact Rounded
+intxx035 tointegralx -0.3 -> -0 Inexact Rounded
+intxx036 tointegralx -0.4 -> -0 Inexact Rounded
+intxx037 tointegralx -0.5 -> -1 Inexact Rounded
+intxx038 tointegralx -0.6 -> -1 Inexact Rounded
+intxx039 tointegralx -0.7 -> -1 Inexact Rounded
+intxx040 tointegralx -0.8 -> -1 Inexact Rounded
+intxx041 tointegralx -0.9 -> -1 Inexact Rounded
+intxx042 tointegralx -1 -> -1
+intxx043 tointegralx -1.0 -> -1 Rounded
+intxx044 tointegralx -1.1 -> -1 Inexact Rounded
+intxx045 tointegralx -1.2 -> -1 Inexact Rounded
+intxx046 tointegralx -1.3 -> -1 Inexact Rounded
+intxx047 tointegralx -1.4 -> -1 Inexact Rounded
+intxx048 tointegralx -1.5 -> -2 Inexact Rounded
+intxx049 tointegralx -1.6 -> -2 Inexact Rounded
+intxx050 tointegralx -1.7 -> -2 Inexact Rounded
+intxx051 tointegralx -1.8 -> -2 Inexact Rounded
+intxx052 tointegralx -1.9 -> -2 Inexact Rounded
+-- next two would be NaN using quantize(x, 0)
+intxx053 tointegralx 10E+30 -> 1.0E+31
+intxx054 tointegralx -10E+30 -> -1.0E+31
+
+-- numbers around precision
+precision: 9
+intxx060 tointegralx '56267E-10' -> '0' Inexact Rounded
+intxx061 tointegralx '56267E-5' -> '1' Inexact Rounded
+intxx062 tointegralx '56267E-2' -> '563' Inexact Rounded
+intxx063 tointegralx '56267E-1' -> '5627' Inexact Rounded
+intxx065 tointegralx '56267E-0' -> '56267'
+intxx066 tointegralx '56267E+0' -> '56267'
+intxx067 tointegralx '56267E+1' -> '5.6267E+5'
+intxx068 tointegralx '56267E+2' -> '5.6267E+6'
+intxx069 tointegralx '56267E+3' -> '5.6267E+7'
+intxx070 tointegralx '56267E+4' -> '5.6267E+8'
+intxx071 tointegralx '56267E+5' -> '5.6267E+9'
+intxx072 tointegralx '56267E+6' -> '5.6267E+10'
+intxx073 tointegralx '1.23E+96' -> '1.23E+96'
+intxx074 tointegralx '1.23E+384' -> '1.23E+384'
+intxx075 tointegralx '1.23E+999' -> '1.23E+999'
+
+intxx080 tointegralx '-56267E-10' -> '-0' Inexact Rounded
+intxx081 tointegralx '-56267E-5' -> '-1' Inexact Rounded
+intxx082 tointegralx '-56267E-2' -> '-563' Inexact Rounded
+intxx083 tointegralx '-56267E-1' -> '-5627' Inexact Rounded
+intxx085 tointegralx '-56267E-0' -> '-56267'
+intxx086 tointegralx '-56267E+0' -> '-56267'
+intxx087 tointegralx '-56267E+1' -> '-5.6267E+5'
+intxx088 tointegralx '-56267E+2' -> '-5.6267E+6'
+intxx089 tointegralx '-56267E+3' -> '-5.6267E+7'
+intxx090 tointegralx '-56267E+4' -> '-5.6267E+8'
+intxx091 tointegralx '-56267E+5' -> '-5.6267E+9'
+intxx092 tointegralx '-56267E+6' -> '-5.6267E+10'
+intxx093 tointegralx '-1.23E+96' -> '-1.23E+96'
+intxx094 tointegralx '-1.23E+384' -> '-1.23E+384'
+intxx095 tointegralx '-1.23E+999' -> '-1.23E+999'
+
+-- subnormal inputs
+intxx100 tointegralx 1E-999 -> 0 Inexact Rounded
+intxx101 tointegralx 0.1E-999 -> 0 Inexact Rounded
+intxx102 tointegralx 0.01E-999 -> 0 Inexact Rounded
+intxx103 tointegralx 0E-999 -> 0
+
+-- specials and zeros
+intxx120 tointegralx 'Inf' -> Infinity
+intxx121 tointegralx '-Inf' -> -Infinity
+intxx122 tointegralx NaN -> NaN
+intxx123 tointegralx sNaN -> NaN Invalid_operation
+intxx124 tointegralx 0 -> 0
+intxx125 tointegralx -0 -> -0
+intxx126 tointegralx 0.000 -> 0
+intxx127 tointegralx 0.00 -> 0
+intxx128 tointegralx 0.0 -> 0
+intxx129 tointegralx 0 -> 0
+intxx130 tointegralx 0E-3 -> 0
+intxx131 tointegralx 0E-2 -> 0
+intxx132 tointegralx 0E-1 -> 0
+intxx133 tointegralx 0E-0 -> 0
+intxx134 tointegralx 0E+1 -> 0E+1
+intxx135 tointegralx 0E+2 -> 0E+2
+intxx136 tointegralx 0E+3 -> 0E+3
+intxx137 tointegralx 0E+4 -> 0E+4
+intxx138 tointegralx 0E+5 -> 0E+5
+intxx139 tointegralx -0.000 -> -0
+intxx140 tointegralx -0.00 -> -0
+intxx141 tointegralx -0.0 -> -0
+intxx142 tointegralx -0 -> -0
+intxx143 tointegralx -0E-3 -> -0
+intxx144 tointegralx -0E-2 -> -0
+intxx145 tointegralx -0E-1 -> -0
+intxx146 tointegralx -0E-0 -> -0
+intxx147 tointegralx -0E+1 -> -0E+1
+intxx148 tointegralx -0E+2 -> -0E+2
+intxx149 tointegralx -0E+3 -> -0E+3
+intxx150 tointegralx -0E+4 -> -0E+4
+intxx151 tointegralx -0E+5 -> -0E+5
+-- propagating NaNs
+intxx152 tointegralx NaN808 -> NaN808
+intxx153 tointegralx sNaN080 -> NaN80 Invalid_operation
+intxx154 tointegralx -NaN808 -> -NaN808
+intxx155 tointegralx -sNaN080 -> -NaN80 Invalid_operation
+intxx156 tointegralx -NaN -> -NaN
+intxx157 tointegralx -sNaN -> -NaN Invalid_operation
+
+-- examples
+rounding: half_up
+precision: 9
+intxx200 tointegralx 2.1 -> 2 Inexact Rounded
+intxx201 tointegralx 100 -> 100
+intxx202 tointegralx 100.0 -> 100 Rounded
+intxx203 tointegralx 101.5 -> 102 Inexact Rounded
+intxx204 tointegralx -101.5 -> -102 Inexact Rounded
+intxx205 tointegralx 10E+5 -> 1.0E+6
+intxx206 tointegralx 7.89E+77 -> 7.89E+77
+intxx207 tointegralx -Inf -> -Infinity
+
+
+-- all rounding modes
+rounding: half_even
+
+intxx210 tointegralx 55.5 -> 56 Inexact Rounded
+intxx211 tointegralx 56.5 -> 56 Inexact Rounded
+intxx212 tointegralx 57.5 -> 58 Inexact Rounded
+intxx213 tointegralx -55.5 -> -56 Inexact Rounded
+intxx214 tointegralx -56.5 -> -56 Inexact Rounded
+intxx215 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_up
+
+intxx220 tointegralx 55.5 -> 56 Inexact Rounded
+intxx221 tointegralx 56.5 -> 57 Inexact Rounded
+intxx222 tointegralx 57.5 -> 58 Inexact Rounded
+intxx223 tointegralx -55.5 -> -56 Inexact Rounded
+intxx224 tointegralx -56.5 -> -57 Inexact Rounded
+intxx225 tointegralx -57.5 -> -58 Inexact Rounded
+
+rounding: half_down
+
+intxx230 tointegralx 55.5 -> 55 Inexact Rounded
+intxx231 tointegralx 56.5 -> 56 Inexact Rounded
+intxx232 tointegralx 57.5 -> 57 Inexact Rounded
+intxx233 tointegralx -55.5 -> -55 Inexact Rounded
+intxx234 tointegralx -56.5 -> -56 Inexact Rounded
+intxx235 tointegralx -57.5 -> -57 Inexact Rounded
+
+rounding: up
+
+intxx240 tointegralx 55.3 -> 56 Inexact Rounded
+intxx241 tointegralx 56.3 -> 57 Inexact Rounded
+intxx242 tointegralx 57.3 -> 58 Inexact Rounded
+intxx243 tointegralx -55.3 -> -56 Inexact Rounded
+intxx244 tointegralx -56.3 -> -57 Inexact Rounded
+intxx245 tointegralx -57.3 -> -58 Inexact Rounded
+
+rounding: down
+
+intxx250 tointegralx 55.7 -> 55 Inexact Rounded
+intxx251 tointegralx 56.7 -> 56 Inexact Rounded
+intxx252 tointegralx 57.7 -> 57 Inexact Rounded
+intxx253 tointegralx -55.7 -> -55 Inexact Rounded
+intxx254 tointegralx -56.7 -> -56 Inexact Rounded
+intxx255 tointegralx -57.7 -> -57 Inexact Rounded
+
+rounding: ceiling
+
+intxx260 tointegralx 55.3 -> 56 Inexact Rounded
+intxx261 tointegralx 56.3 -> 57 Inexact Rounded
+intxx262 tointegralx 57.3 -> 58 Inexact Rounded
+intxx263 tointegralx -55.3 -> -55 Inexact Rounded
+intxx264 tointegralx -56.3 -> -56 Inexact Rounded
+intxx265 tointegralx -57.3 -> -57 Inexact Rounded
+
+rounding: floor
+
+intxx270 tointegralx 55.7 -> 55 Inexact Rounded
+intxx271 tointegralx 56.7 -> 56 Inexact Rounded
+intxx272 tointegralx 57.7 -> 57 Inexact Rounded
+intxx273 tointegralx -55.7 -> -56 Inexact Rounded
+intxx274 tointegralx -56.7 -> -57 Inexact Rounded
+intxx275 tointegralx -57.7 -> -58 Inexact Rounded
+
+-- Int and uInt32 edge values for testing conversions
+precision: 16
+intxx300 tointegralx -2147483646 -> -2147483646
+intxx301 tointegralx -2147483647 -> -2147483647
+intxx302 tointegralx -2147483648 -> -2147483648
+intxx303 tointegralx -2147483649 -> -2147483649
+intxx304 tointegralx 2147483646 -> 2147483646
+intxx305 tointegralx 2147483647 -> 2147483647
+intxx306 tointegralx 2147483648 -> 2147483648
+intxx307 tointegralx 2147483649 -> 2147483649
+intxx308 tointegralx 4294967294 -> 4294967294
+intxx309 tointegralx 4294967295 -> 4294967295
+intxx310 tointegralx 4294967296 -> 4294967296
+intxx311 tointegralx 4294967297 -> 4294967297
diff --git a/Lib/test/decimaltestdata/xor.decTest b/Lib/test/decimaltestdata/xor.decTest
index 122976e44cc..cd71bbcf86b 100644
--- a/Lib/test/decimaltestdata/xor.decTest
+++ b/Lib/test/decimaltestdata/xor.decTest
@@ -1,335 +1,335 @@
-------------------------------------------------------------------------
--- xor.decTest -- digitwise logical XOR --
--- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
-------------------------------------------------------------------------
--- Please see the document "General Decimal Arithmetic Testcases" --
--- at http://www2.hursley.ibm.com/decimal for the description of --
--- these testcases. --
--- --
--- These testcases are experimental ('beta' versions), and they --
--- may contain errors. They are offered on an as-is basis. In --
--- particular, achieving the same results as the tests here is not --
--- a guarantee that an implementation complies with any Standard --
--- or specification. The tests are not exhaustive. --
--- --
--- Please send comments, suggestions, and corrections to the author: --
--- Mike Cowlishaw, IBM Fellow --
--- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
--- mfc@uk.ibm.com --
-------------------------------------------------------------------------
-version: 2.59
-
-extended: 1
-precision: 9
-rounding: half_up
-maxExponent: 999
-minExponent: -999
-
--- Sanity check (truth table)
-xorx001 xor 0 0 -> 0
-xorx002 xor 0 1 -> 1
-xorx003 xor 1 0 -> 1
-xorx004 xor 1 1 -> 0
-xorx005 xor 1100 1010 -> 110
-xorx006 xor 1111 10 -> 1101
--- and at msd and msd-1
-xorx010 xor 000000000 000000000 -> 0
-xorx011 xor 000000000 100000000 -> 100000000
-xorx012 xor 100000000 000000000 -> 100000000
-xorx013 xor 100000000 100000000 -> 0
-xorx014 xor 000000000 000000000 -> 0
-xorx015 xor 000000000 010000000 -> 10000000
-xorx016 xor 010000000 000000000 -> 10000000
-xorx017 xor 010000000 010000000 -> 0
-
--- Various lengths
--- 123456789 123456789 123456789
-xorx021 xor 111111111 111111111 -> 0
-xorx022 xor 111111111111 111111111 -> 0
-xorx023 xor 11111111 11111111 -> 0
-xorx025 xor 1111111 1111111 -> 0
-xorx026 xor 111111 111111 -> 0
-xorx027 xor 11111 11111 -> 0
-xorx028 xor 1111 1111 -> 0
-xorx029 xor 111 111 -> 0
-xorx031 xor 11 11 -> 0
-xorx032 xor 1 1 -> 0
-xorx033 xor 111111111111 1111111111 -> 0
-xorx034 xor 11111111111 11111111111 -> 0
-xorx035 xor 1111111111 111111111111 -> 0
-xorx036 xor 111111111 1111111111111 -> 0
-
-xorx040 xor 111111111 111111111111 -> 0
-xorx041 xor 11111111 111111111111 -> 100000000
-xorx042 xor 11111111 111111111 -> 100000000
-xorx043 xor 1111111 100000010 -> 101111101
-xorx044 xor 111111 100000100 -> 100111011
-xorx045 xor 11111 100001000 -> 100010111
-xorx046 xor 1111 100010000 -> 100011111
-xorx047 xor 111 100100000 -> 100100111
-xorx048 xor 11 101000000 -> 101000011
-xorx049 xor 1 110000000 -> 110000001
-
-xorx050 xor 1111111111 1 -> 111111110
-xorx051 xor 111111111 1 -> 111111110
-xorx052 xor 11111111 1 -> 11111110
-xorx053 xor 1111111 1 -> 1111110
-xorx054 xor 111111 1 -> 111110
-xorx055 xor 11111 1 -> 11110
-xorx056 xor 1111 1 -> 1110
-xorx057 xor 111 1 -> 110
-xorx058 xor 11 1 -> 10
-xorx059 xor 1 1 -> 0
-
-xorx060 xor 1111111111 0 -> 111111111
-xorx061 xor 111111111 0 -> 111111111
-xorx062 xor 11111111 0 -> 11111111
-xorx063 xor 1111111 0 -> 1111111
-xorx064 xor 111111 0 -> 111111
-xorx065 xor 11111 0 -> 11111
-xorx066 xor 1111 0 -> 1111
-xorx067 xor 111 0 -> 111
-xorx068 xor 11 0 -> 11
-xorx069 xor 1 0 -> 1
-
-xorx070 xor 1 1111111111 -> 111111110
-xorx071 xor 1 111111111 -> 111111110
-xorx072 xor 1 11111111 -> 11111110
-xorx073 xor 1 1111111 -> 1111110
-xorx074 xor 1 111111 -> 111110
-xorx075 xor 1 11111 -> 11110
-xorx076 xor 1 1111 -> 1110
-xorx077 xor 1 111 -> 110
-xorx078 xor 1 11 -> 10
-xorx079 xor 1 1 -> 0
-
-xorx080 xor 0 1111111111 -> 111111111
-xorx081 xor 0 111111111 -> 111111111
-xorx082 xor 0 11111111 -> 11111111
-xorx083 xor 0 1111111 -> 1111111
-xorx084 xor 0 111111 -> 111111
-xorx085 xor 0 11111 -> 11111
-xorx086 xor 0 1111 -> 1111
-xorx087 xor 0 111 -> 111
-xorx088 xor 0 11 -> 11
-xorx089 xor 0 1 -> 1
-
-xorx090 xor 011111111 111101111 -> 100010000
-xorx091 xor 101111111 111101111 -> 10010000
-xorx092 xor 110111111 111101111 -> 1010000
-xorx093 xor 111011111 111101111 -> 110000
-xorx094 xor 111101111 111101111 -> 0
-xorx095 xor 111110111 111101111 -> 11000
-xorx096 xor 111111011 111101111 -> 10100
-xorx097 xor 111111101 111101111 -> 10010
-xorx098 xor 111111110 111101111 -> 10001
-
-xorx100 xor 111101111 011111111 -> 100010000
-xorx101 xor 111101111 101111111 -> 10010000
-xorx102 xor 111101111 110111111 -> 1010000
-xorx103 xor 111101111 111011111 -> 110000
-xorx104 xor 111101111 111101111 -> 0
-xorx105 xor 111101111 111110111 -> 11000
-xorx106 xor 111101111 111111011 -> 10100
-xorx107 xor 111101111 111111101 -> 10010
-xorx108 xor 111101111 111111110 -> 10001
-
--- non-0/1 should not be accepted, nor should signs
-xorx220 xor 111111112 111111111 -> NaN Invalid_operation
-xorx221 xor 333333333 333333333 -> NaN Invalid_operation
-xorx222 xor 555555555 555555555 -> NaN Invalid_operation
-xorx223 xor 777777777 777777777 -> NaN Invalid_operation
-xorx224 xor 999999999 999999999 -> NaN Invalid_operation
-xorx225 xor 222222222 999999999 -> NaN Invalid_operation
-xorx226 xor 444444444 999999999 -> NaN Invalid_operation
-xorx227 xor 666666666 999999999 -> NaN Invalid_operation
-xorx228 xor 888888888 999999999 -> NaN Invalid_operation
-xorx229 xor 999999999 222222222 -> NaN Invalid_operation
-xorx230 xor 999999999 444444444 -> NaN Invalid_operation
-xorx231 xor 999999999 666666666 -> NaN Invalid_operation
-xorx232 xor 999999999 888888888 -> NaN Invalid_operation
--- a few randoms
-xorx240 xor 567468689 -934981942 -> NaN Invalid_operation
-xorx241 xor 567367689 934981942 -> NaN Invalid_operation
-xorx242 xor -631917772 -706014634 -> NaN Invalid_operation
-xorx243 xor -756253257 138579234 -> NaN Invalid_operation
-xorx244 xor 835590149 567435400 -> NaN Invalid_operation
--- test MSD
-xorx250 xor 200000000 100000000 -> NaN Invalid_operation
-xorx251 xor 700000000 100000000 -> NaN Invalid_operation
-xorx252 xor 800000000 100000000 -> NaN Invalid_operation
-xorx253 xor 900000000 100000000 -> NaN Invalid_operation
-xorx254 xor 200000000 000000000 -> NaN Invalid_operation
-xorx255 xor 700000000 000000000 -> NaN Invalid_operation
-xorx256 xor 800000000 000000000 -> NaN Invalid_operation
-xorx257 xor 900000000 000000000 -> NaN Invalid_operation
-xorx258 xor 100000000 200000000 -> NaN Invalid_operation
-xorx259 xor 100000000 700000000 -> NaN Invalid_operation
-xorx260 xor 100000000 800000000 -> NaN Invalid_operation
-xorx261 xor 100000000 900000000 -> NaN Invalid_operation
-xorx262 xor 000000000 200000000 -> NaN Invalid_operation
-xorx263 xor 000000000 700000000 -> NaN Invalid_operation
-xorx264 xor 000000000 800000000 -> NaN Invalid_operation
-xorx265 xor 000000000 900000000 -> NaN Invalid_operation
--- test MSD-1
-xorx270 xor 020000000 100000000 -> NaN Invalid_operation
-xorx271 xor 070100000 100000000 -> NaN Invalid_operation
-xorx272 xor 080010000 100000001 -> NaN Invalid_operation
-xorx273 xor 090001000 100000010 -> NaN Invalid_operation
-xorx274 xor 100000100 020010100 -> NaN Invalid_operation
-xorx275 xor 100000000 070001000 -> NaN Invalid_operation
-xorx276 xor 100000010 080010100 -> NaN Invalid_operation
-xorx277 xor 100000000 090000010 -> NaN Invalid_operation
--- test LSD
-xorx280 xor 001000002 100000000 -> NaN Invalid_operation
-xorx281 xor 000000007 100000000 -> NaN Invalid_operation
-xorx282 xor 000000008 100000000 -> NaN Invalid_operation
-xorx283 xor 000000009 100000000 -> NaN Invalid_operation
-xorx284 xor 100000000 000100002 -> NaN Invalid_operation
-xorx285 xor 100100000 001000007 -> NaN Invalid_operation
-xorx286 xor 100010000 010000008 -> NaN Invalid_operation
-xorx287 xor 100001000 100000009 -> NaN Invalid_operation
--- test Middie
-xorx288 xor 001020000 100000000 -> NaN Invalid_operation
-xorx289 xor 000070001 100000000 -> NaN Invalid_operation
-xorx290 xor 000080000 100010000 -> NaN Invalid_operation
-xorx291 xor 000090000 100001000 -> NaN Invalid_operation
-xorx292 xor 100000010 000020100 -> NaN Invalid_operation
-xorx293 xor 100100000 000070010 -> NaN Invalid_operation
-xorx294 xor 100010100 000080001 -> NaN Invalid_operation
-xorx295 xor 100001000 000090000 -> NaN Invalid_operation
--- signs
-xorx296 xor -100001000 -000000000 -> NaN Invalid_operation
-xorx297 xor -100001000 000010000 -> NaN Invalid_operation
-xorx298 xor 100001000 -000000000 -> NaN Invalid_operation
-xorx299 xor 100001000 000011000 -> 100010000
-
--- Nmax, Nmin, Ntiny
-xorx331 xor 2 9.99999999E+999 -> NaN Invalid_operation
-xorx332 xor 3 1E-999 -> NaN Invalid_operation
-xorx333 xor 4 1.00000000E-999 -> NaN Invalid_operation
-xorx334 xor 5 1E-1007 -> NaN Invalid_operation
-xorx335 xor 6 -1E-1007 -> NaN Invalid_operation
-xorx336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
-xorx337 xor 8 -1E-999 -> NaN Invalid_operation
-xorx338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
-xorx341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
-xorx342 xor 1E-999 01 -> NaN Invalid_operation
-xorx343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
-xorx344 xor 1E-1007 18 -> NaN Invalid_operation
-xorx345 xor -1E-1007 -10 -> NaN Invalid_operation
-xorx346 xor -1.00000000E-999 18 -> NaN Invalid_operation
-xorx347 xor -1E-999 10 -> NaN Invalid_operation
-xorx348 xor -9.99999999E+999 -18 -> NaN Invalid_operation
-
--- A few other non-integers
-xorx361 xor 1.0 1 -> NaN Invalid_operation
-xorx362 xor 1E+1 1 -> NaN Invalid_operation
-xorx363 xor 0.0 1 -> NaN Invalid_operation
-xorx364 xor 0E+1 1 -> NaN Invalid_operation
-xorx365 xor 9.9 1 -> NaN Invalid_operation
-xorx366 xor 9E+1 1 -> NaN Invalid_operation
-xorx371 xor 0 1.0 -> NaN Invalid_operation
-xorx372 xor 0 1E+1 -> NaN Invalid_operation
-xorx373 xor 0 0.0 -> NaN Invalid_operation
-xorx374 xor 0 0E+1 -> NaN Invalid_operation
-xorx375 xor 0 9.9 -> NaN Invalid_operation
-xorx376 xor 0 9E+1 -> NaN Invalid_operation
-
--- All Specials are in error
-xorx780 xor -Inf -Inf -> NaN Invalid_operation
-xorx781 xor -Inf -1000 -> NaN Invalid_operation
-xorx782 xor -Inf -1 -> NaN Invalid_operation
-xorx783 xor -Inf -0 -> NaN Invalid_operation
-xorx784 xor -Inf 0 -> NaN Invalid_operation
-xorx785 xor -Inf 1 -> NaN Invalid_operation
-xorx786 xor -Inf 1000 -> NaN Invalid_operation
-xorx787 xor -1000 -Inf -> NaN Invalid_operation
-xorx788 xor -Inf -Inf -> NaN Invalid_operation
-xorx789 xor -1 -Inf -> NaN Invalid_operation
-xorx790 xor -0 -Inf -> NaN Invalid_operation
-xorx791 xor 0 -Inf -> NaN Invalid_operation
-xorx792 xor 1 -Inf -> NaN Invalid_operation
-xorx793 xor 1000 -Inf -> NaN Invalid_operation
-xorx794 xor Inf -Inf -> NaN Invalid_operation
-
-xorx800 xor Inf -Inf -> NaN Invalid_operation
-xorx801 xor Inf -1000 -> NaN Invalid_operation
-xorx802 xor Inf -1 -> NaN Invalid_operation
-xorx803 xor Inf -0 -> NaN Invalid_operation
-xorx804 xor Inf 0 -> NaN Invalid_operation
-xorx805 xor Inf 1 -> NaN Invalid_operation
-xorx806 xor Inf 1000 -> NaN Invalid_operation
-xorx807 xor Inf Inf -> NaN Invalid_operation
-xorx808 xor -1000 Inf -> NaN Invalid_operation
-xorx809 xor -Inf Inf -> NaN Invalid_operation
-xorx810 xor -1 Inf -> NaN Invalid_operation
-xorx811 xor -0 Inf -> NaN Invalid_operation
-xorx812 xor 0 Inf -> NaN Invalid_operation
-xorx813 xor 1 Inf -> NaN Invalid_operation
-xorx814 xor 1000 Inf -> NaN Invalid_operation
-xorx815 xor Inf Inf -> NaN Invalid_operation
-
-xorx821 xor NaN -Inf -> NaN Invalid_operation
-xorx822 xor NaN -1000 -> NaN Invalid_operation
-xorx823 xor NaN -1 -> NaN Invalid_operation
-xorx824 xor NaN -0 -> NaN Invalid_operation
-xorx825 xor NaN 0 -> NaN Invalid_operation
-xorx826 xor NaN 1 -> NaN Invalid_operation
-xorx827 xor NaN 1000 -> NaN Invalid_operation
-xorx828 xor NaN Inf -> NaN Invalid_operation
-xorx829 xor NaN NaN -> NaN Invalid_operation
-xorx830 xor -Inf NaN -> NaN Invalid_operation
-xorx831 xor -1000 NaN -> NaN Invalid_operation
-xorx832 xor -1 NaN -> NaN Invalid_operation
-xorx833 xor -0 NaN -> NaN Invalid_operation
-xorx834 xor 0 NaN -> NaN Invalid_operation
-xorx835 xor 1 NaN -> NaN Invalid_operation
-xorx836 xor 1000 NaN -> NaN Invalid_operation
-xorx837 xor Inf NaN -> NaN Invalid_operation
-
-xorx841 xor sNaN -Inf -> NaN Invalid_operation
-xorx842 xor sNaN -1000 -> NaN Invalid_operation
-xorx843 xor sNaN -1 -> NaN Invalid_operation
-xorx844 xor sNaN -0 -> NaN Invalid_operation
-xorx845 xor sNaN 0 -> NaN Invalid_operation
-xorx846 xor sNaN 1 -> NaN Invalid_operation
-xorx847 xor sNaN 1000 -> NaN Invalid_operation
-xorx848 xor sNaN NaN -> NaN Invalid_operation
-xorx849 xor sNaN sNaN -> NaN Invalid_operation
-xorx850 xor NaN sNaN -> NaN Invalid_operation
-xorx851 xor -Inf sNaN -> NaN Invalid_operation
-xorx852 xor -1000 sNaN -> NaN Invalid_operation
-xorx853 xor -1 sNaN -> NaN Invalid_operation
-xorx854 xor -0 sNaN -> NaN Invalid_operation
-xorx855 xor 0 sNaN -> NaN Invalid_operation
-xorx856 xor 1 sNaN -> NaN Invalid_operation
-xorx857 xor 1000 sNaN -> NaN Invalid_operation
-xorx858 xor Inf sNaN -> NaN Invalid_operation
-xorx859 xor NaN sNaN -> NaN Invalid_operation
-
--- propagating NaNs
-xorx861 xor NaN1 -Inf -> NaN Invalid_operation
-xorx862 xor +NaN2 -1000 -> NaN Invalid_operation
-xorx863 xor NaN3 1000 -> NaN Invalid_operation
-xorx864 xor NaN4 Inf -> NaN Invalid_operation
-xorx865 xor NaN5 +NaN6 -> NaN Invalid_operation
-xorx866 xor -Inf NaN7 -> NaN Invalid_operation
-xorx867 xor -1000 NaN8 -> NaN Invalid_operation
-xorx868 xor 1000 NaN9 -> NaN Invalid_operation
-xorx869 xor Inf +NaN10 -> NaN Invalid_operation
-xorx871 xor sNaN11 -Inf -> NaN Invalid_operation
-xorx872 xor sNaN12 -1000 -> NaN Invalid_operation
-xorx873 xor sNaN13 1000 -> NaN Invalid_operation
-xorx874 xor sNaN14 NaN17 -> NaN Invalid_operation
-xorx875 xor sNaN15 sNaN18 -> NaN Invalid_operation
-xorx876 xor NaN16 sNaN19 -> NaN Invalid_operation
-xorx877 xor -Inf +sNaN20 -> NaN Invalid_operation
-xorx878 xor -1000 sNaN21 -> NaN Invalid_operation
-xorx879 xor 1000 sNaN22 -> NaN Invalid_operation
-xorx880 xor Inf sNaN23 -> NaN Invalid_operation
-xorx881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
-xorx882 xor -NaN26 NaN28 -> NaN Invalid_operation
-xorx883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
-xorx884 xor 1000 -NaN30 -> NaN Invalid_operation
-xorx885 xor 1000 -sNaN31 -> NaN Invalid_operation
+------------------------------------------------------------------------
+-- xor.decTest -- digitwise logical XOR --
+-- Copyright (c) IBM Corporation, 1981, 2008. All rights reserved. --
+------------------------------------------------------------------------
+-- Please see the document "General Decimal Arithmetic Testcases" --
+-- at http://www2.hursley.ibm.com/decimal for the description of --
+-- these testcases. --
+-- --
+-- These testcases are experimental ('beta' versions), and they --
+-- may contain errors. They are offered on an as-is basis. In --
+-- particular, achieving the same results as the tests here is not --
+-- a guarantee that an implementation complies with any Standard --
+-- or specification. The tests are not exhaustive. --
+-- --
+-- Please send comments, suggestions, and corrections to the author: --
+-- Mike Cowlishaw, IBM Fellow --
+-- IBM UK, PO Box 31, Birmingham Road, Warwick CV34 5JL, UK --
+-- mfc@uk.ibm.com --
+------------------------------------------------------------------------
+version: 2.59
+
+extended: 1
+precision: 9
+rounding: half_up
+maxExponent: 999
+minExponent: -999
+
+-- Sanity check (truth table)
+xorx001 xor 0 0 -> 0
+xorx002 xor 0 1 -> 1
+xorx003 xor 1 0 -> 1
+xorx004 xor 1 1 -> 0
+xorx005 xor 1100 1010 -> 110
+xorx006 xor 1111 10 -> 1101
+-- and at msd and msd-1
+xorx010 xor 000000000 000000000 -> 0
+xorx011 xor 000000000 100000000 -> 100000000
+xorx012 xor 100000000 000000000 -> 100000000
+xorx013 xor 100000000 100000000 -> 0
+xorx014 xor 000000000 000000000 -> 0
+xorx015 xor 000000000 010000000 -> 10000000
+xorx016 xor 010000000 000000000 -> 10000000
+xorx017 xor 010000000 010000000 -> 0
+
+-- Various lengths
+-- 123456789 123456789 123456789
+xorx021 xor 111111111 111111111 -> 0
+xorx022 xor 111111111111 111111111 -> 0
+xorx023 xor 11111111 11111111 -> 0
+xorx025 xor 1111111 1111111 -> 0
+xorx026 xor 111111 111111 -> 0
+xorx027 xor 11111 11111 -> 0
+xorx028 xor 1111 1111 -> 0
+xorx029 xor 111 111 -> 0
+xorx031 xor 11 11 -> 0
+xorx032 xor 1 1 -> 0
+xorx033 xor 111111111111 1111111111 -> 0
+xorx034 xor 11111111111 11111111111 -> 0
+xorx035 xor 1111111111 111111111111 -> 0
+xorx036 xor 111111111 1111111111111 -> 0
+
+xorx040 xor 111111111 111111111111 -> 0
+xorx041 xor 11111111 111111111111 -> 100000000
+xorx042 xor 11111111 111111111 -> 100000000
+xorx043 xor 1111111 100000010 -> 101111101
+xorx044 xor 111111 100000100 -> 100111011
+xorx045 xor 11111 100001000 -> 100010111
+xorx046 xor 1111 100010000 -> 100011111
+xorx047 xor 111 100100000 -> 100100111
+xorx048 xor 11 101000000 -> 101000011
+xorx049 xor 1 110000000 -> 110000001
+
+xorx050 xor 1111111111 1 -> 111111110
+xorx051 xor 111111111 1 -> 111111110
+xorx052 xor 11111111 1 -> 11111110
+xorx053 xor 1111111 1 -> 1111110
+xorx054 xor 111111 1 -> 111110
+xorx055 xor 11111 1 -> 11110
+xorx056 xor 1111 1 -> 1110
+xorx057 xor 111 1 -> 110
+xorx058 xor 11 1 -> 10
+xorx059 xor 1 1 -> 0
+
+xorx060 xor 1111111111 0 -> 111111111
+xorx061 xor 111111111 0 -> 111111111
+xorx062 xor 11111111 0 -> 11111111
+xorx063 xor 1111111 0 -> 1111111
+xorx064 xor 111111 0 -> 111111
+xorx065 xor 11111 0 -> 11111
+xorx066 xor 1111 0 -> 1111
+xorx067 xor 111 0 -> 111
+xorx068 xor 11 0 -> 11
+xorx069 xor 1 0 -> 1
+
+xorx070 xor 1 1111111111 -> 111111110
+xorx071 xor 1 111111111 -> 111111110
+xorx072 xor 1 11111111 -> 11111110
+xorx073 xor 1 1111111 -> 1111110
+xorx074 xor 1 111111 -> 111110
+xorx075 xor 1 11111 -> 11110
+xorx076 xor 1 1111 -> 1110
+xorx077 xor 1 111 -> 110
+xorx078 xor 1 11 -> 10
+xorx079 xor 1 1 -> 0
+
+xorx080 xor 0 1111111111 -> 111111111
+xorx081 xor 0 111111111 -> 111111111
+xorx082 xor 0 11111111 -> 11111111
+xorx083 xor 0 1111111 -> 1111111
+xorx084 xor 0 111111 -> 111111
+xorx085 xor 0 11111 -> 11111
+xorx086 xor 0 1111 -> 1111
+xorx087 xor 0 111 -> 111
+xorx088 xor 0 11 -> 11
+xorx089 xor 0 1 -> 1
+
+xorx090 xor 011111111 111101111 -> 100010000
+xorx091 xor 101111111 111101111 -> 10010000
+xorx092 xor 110111111 111101111 -> 1010000
+xorx093 xor 111011111 111101111 -> 110000
+xorx094 xor 111101111 111101111 -> 0
+xorx095 xor 111110111 111101111 -> 11000
+xorx096 xor 111111011 111101111 -> 10100
+xorx097 xor 111111101 111101111 -> 10010
+xorx098 xor 111111110 111101111 -> 10001
+
+xorx100 xor 111101111 011111111 -> 100010000
+xorx101 xor 111101111 101111111 -> 10010000
+xorx102 xor 111101111 110111111 -> 1010000
+xorx103 xor 111101111 111011111 -> 110000
+xorx104 xor 111101111 111101111 -> 0
+xorx105 xor 111101111 111110111 -> 11000
+xorx106 xor 111101111 111111011 -> 10100
+xorx107 xor 111101111 111111101 -> 10010
+xorx108 xor 111101111 111111110 -> 10001
+
+-- non-0/1 should not be accepted, nor should signs
+xorx220 xor 111111112 111111111 -> NaN Invalid_operation
+xorx221 xor 333333333 333333333 -> NaN Invalid_operation
+xorx222 xor 555555555 555555555 -> NaN Invalid_operation
+xorx223 xor 777777777 777777777 -> NaN Invalid_operation
+xorx224 xor 999999999 999999999 -> NaN Invalid_operation
+xorx225 xor 222222222 999999999 -> NaN Invalid_operation
+xorx226 xor 444444444 999999999 -> NaN Invalid_operation
+xorx227 xor 666666666 999999999 -> NaN Invalid_operation
+xorx228 xor 888888888 999999999 -> NaN Invalid_operation
+xorx229 xor 999999999 222222222 -> NaN Invalid_operation
+xorx230 xor 999999999 444444444 -> NaN Invalid_operation
+xorx231 xor 999999999 666666666 -> NaN Invalid_operation
+xorx232 xor 999999999 888888888 -> NaN Invalid_operation
+-- a few randoms
+xorx240 xor 567468689 -934981942 -> NaN Invalid_operation
+xorx241 xor 567367689 934981942 -> NaN Invalid_operation
+xorx242 xor -631917772 -706014634 -> NaN Invalid_operation
+xorx243 xor -756253257 138579234 -> NaN Invalid_operation
+xorx244 xor 835590149 567435400 -> NaN Invalid_operation
+-- test MSD
+xorx250 xor 200000000 100000000 -> NaN Invalid_operation
+xorx251 xor 700000000 100000000 -> NaN Invalid_operation
+xorx252 xor 800000000 100000000 -> NaN Invalid_operation
+xorx253 xor 900000000 100000000 -> NaN Invalid_operation
+xorx254 xor 200000000 000000000 -> NaN Invalid_operation
+xorx255 xor 700000000 000000000 -> NaN Invalid_operation
+xorx256 xor 800000000 000000000 -> NaN Invalid_operation
+xorx257 xor 900000000 000000000 -> NaN Invalid_operation
+xorx258 xor 100000000 200000000 -> NaN Invalid_operation
+xorx259 xor 100000000 700000000 -> NaN Invalid_operation
+xorx260 xor 100000000 800000000 -> NaN Invalid_operation
+xorx261 xor 100000000 900000000 -> NaN Invalid_operation
+xorx262 xor 000000000 200000000 -> NaN Invalid_operation
+xorx263 xor 000000000 700000000 -> NaN Invalid_operation
+xorx264 xor 000000000 800000000 -> NaN Invalid_operation
+xorx265 xor 000000000 900000000 -> NaN Invalid_operation
+-- test MSD-1
+xorx270 xor 020000000 100000000 -> NaN Invalid_operation
+xorx271 xor 070100000 100000000 -> NaN Invalid_operation
+xorx272 xor 080010000 100000001 -> NaN Invalid_operation
+xorx273 xor 090001000 100000010 -> NaN Invalid_operation
+xorx274 xor 100000100 020010100 -> NaN Invalid_operation
+xorx275 xor 100000000 070001000 -> NaN Invalid_operation
+xorx276 xor 100000010 080010100 -> NaN Invalid_operation
+xorx277 xor 100000000 090000010 -> NaN Invalid_operation
+-- test LSD
+xorx280 xor 001000002 100000000 -> NaN Invalid_operation
+xorx281 xor 000000007 100000000 -> NaN Invalid_operation
+xorx282 xor 000000008 100000000 -> NaN Invalid_operation
+xorx283 xor 000000009 100000000 -> NaN Invalid_operation
+xorx284 xor 100000000 000100002 -> NaN Invalid_operation
+xorx285 xor 100100000 001000007 -> NaN Invalid_operation
+xorx286 xor 100010000 010000008 -> NaN Invalid_operation
+xorx287 xor 100001000 100000009 -> NaN Invalid_operation
+-- test Middie
+xorx288 xor 001020000 100000000 -> NaN Invalid_operation
+xorx289 xor 000070001 100000000 -> NaN Invalid_operation
+xorx290 xor 000080000 100010000 -> NaN Invalid_operation
+xorx291 xor 000090000 100001000 -> NaN Invalid_operation
+xorx292 xor 100000010 000020100 -> NaN Invalid_operation
+xorx293 xor 100100000 000070010 -> NaN Invalid_operation
+xorx294 xor 100010100 000080001 -> NaN Invalid_operation
+xorx295 xor 100001000 000090000 -> NaN Invalid_operation
+-- signs
+xorx296 xor -100001000 -000000000 -> NaN Invalid_operation
+xorx297 xor -100001000 000010000 -> NaN Invalid_operation
+xorx298 xor 100001000 -000000000 -> NaN Invalid_operation
+xorx299 xor 100001000 000011000 -> 100010000
+
+-- Nmax, Nmin, Ntiny
+xorx331 xor 2 9.99999999E+999 -> NaN Invalid_operation
+xorx332 xor 3 1E-999 -> NaN Invalid_operation
+xorx333 xor 4 1.00000000E-999 -> NaN Invalid_operation
+xorx334 xor 5 1E-1007 -> NaN Invalid_operation
+xorx335 xor 6 -1E-1007 -> NaN Invalid_operation
+xorx336 xor 7 -1.00000000E-999 -> NaN Invalid_operation
+xorx337 xor 8 -1E-999 -> NaN Invalid_operation
+xorx338 xor 9 -9.99999999E+999 -> NaN Invalid_operation
+xorx341 xor 9.99999999E+999 -18 -> NaN Invalid_operation
+xorx342 xor 1E-999 01 -> NaN Invalid_operation
+xorx343 xor 1.00000000E-999 -18 -> NaN Invalid_operation
+xorx344 xor 1E-1007 18 -> NaN Invalid_operation
+xorx345 xor -1E-1007 -10 -> NaN Invalid_operation
+xorx346 xor -1.00000000E-999 18 -> NaN Invalid_operation
+xorx347 xor -1E-999 10 -> NaN Invalid_operation
+xorx348 xor -9.99999999E+999 -18 -> NaN Invalid_operation
+
+-- A few other non-integers
+xorx361 xor 1.0 1 -> NaN Invalid_operation
+xorx362 xor 1E+1 1 -> NaN Invalid_operation
+xorx363 xor 0.0 1 -> NaN Invalid_operation
+xorx364 xor 0E+1 1 -> NaN Invalid_operation
+xorx365 xor 9.9 1 -> NaN Invalid_operation
+xorx366 xor 9E+1 1 -> NaN Invalid_operation
+xorx371 xor 0 1.0 -> NaN Invalid_operation
+xorx372 xor 0 1E+1 -> NaN Invalid_operation
+xorx373 xor 0 0.0 -> NaN Invalid_operation
+xorx374 xor 0 0E+1 -> NaN Invalid_operation
+xorx375 xor 0 9.9 -> NaN Invalid_operation
+xorx376 xor 0 9E+1 -> NaN Invalid_operation
+
+-- All Specials are in error
+xorx780 xor -Inf -Inf -> NaN Invalid_operation
+xorx781 xor -Inf -1000 -> NaN Invalid_operation
+xorx782 xor -Inf -1 -> NaN Invalid_operation
+xorx783 xor -Inf -0 -> NaN Invalid_operation
+xorx784 xor -Inf 0 -> NaN Invalid_operation
+xorx785 xor -Inf 1 -> NaN Invalid_operation
+xorx786 xor -Inf 1000 -> NaN Invalid_operation
+xorx787 xor -1000 -Inf -> NaN Invalid_operation
+xorx788 xor -Inf -Inf -> NaN Invalid_operation
+xorx789 xor -1 -Inf -> NaN Invalid_operation
+xorx790 xor -0 -Inf -> NaN Invalid_operation
+xorx791 xor 0 -Inf -> NaN Invalid_operation
+xorx792 xor 1 -Inf -> NaN Invalid_operation
+xorx793 xor 1000 -Inf -> NaN Invalid_operation
+xorx794 xor Inf -Inf -> NaN Invalid_operation
+
+xorx800 xor Inf -Inf -> NaN Invalid_operation
+xorx801 xor Inf -1000 -> NaN Invalid_operation
+xorx802 xor Inf -1 -> NaN Invalid_operation
+xorx803 xor Inf -0 -> NaN Invalid_operation
+xorx804 xor Inf 0 -> NaN Invalid_operation
+xorx805 xor Inf 1 -> NaN Invalid_operation
+xorx806 xor Inf 1000 -> NaN Invalid_operation
+xorx807 xor Inf Inf -> NaN Invalid_operation
+xorx808 xor -1000 Inf -> NaN Invalid_operation
+xorx809 xor -Inf Inf -> NaN Invalid_operation
+xorx810 xor -1 Inf -> NaN Invalid_operation
+xorx811 xor -0 Inf -> NaN Invalid_operation
+xorx812 xor 0 Inf -> NaN Invalid_operation
+xorx813 xor 1 Inf -> NaN Invalid_operation
+xorx814 xor 1000 Inf -> NaN Invalid_operation
+xorx815 xor Inf Inf -> NaN Invalid_operation
+
+xorx821 xor NaN -Inf -> NaN Invalid_operation
+xorx822 xor NaN -1000 -> NaN Invalid_operation
+xorx823 xor NaN -1 -> NaN Invalid_operation
+xorx824 xor NaN -0 -> NaN Invalid_operation
+xorx825 xor NaN 0 -> NaN Invalid_operation
+xorx826 xor NaN 1 -> NaN Invalid_operation
+xorx827 xor NaN 1000 -> NaN Invalid_operation
+xorx828 xor NaN Inf -> NaN Invalid_operation
+xorx829 xor NaN NaN -> NaN Invalid_operation
+xorx830 xor -Inf NaN -> NaN Invalid_operation
+xorx831 xor -1000 NaN -> NaN Invalid_operation
+xorx832 xor -1 NaN -> NaN Invalid_operation
+xorx833 xor -0 NaN -> NaN Invalid_operation
+xorx834 xor 0 NaN -> NaN Invalid_operation
+xorx835 xor 1 NaN -> NaN Invalid_operation
+xorx836 xor 1000 NaN -> NaN Invalid_operation
+xorx837 xor Inf NaN -> NaN Invalid_operation
+
+xorx841 xor sNaN -Inf -> NaN Invalid_operation
+xorx842 xor sNaN -1000 -> NaN Invalid_operation
+xorx843 xor sNaN -1 -> NaN Invalid_operation
+xorx844 xor sNaN -0 -> NaN Invalid_operation
+xorx845 xor sNaN 0 -> NaN Invalid_operation
+xorx846 xor sNaN 1 -> NaN Invalid_operation
+xorx847 xor sNaN 1000 -> NaN Invalid_operation
+xorx848 xor sNaN NaN -> NaN Invalid_operation
+xorx849 xor sNaN sNaN -> NaN Invalid_operation
+xorx850 xor NaN sNaN -> NaN Invalid_operation
+xorx851 xor -Inf sNaN -> NaN Invalid_operation
+xorx852 xor -1000 sNaN -> NaN Invalid_operation
+xorx853 xor -1 sNaN -> NaN Invalid_operation
+xorx854 xor -0 sNaN -> NaN Invalid_operation
+xorx855 xor 0 sNaN -> NaN Invalid_operation
+xorx856 xor 1 sNaN -> NaN Invalid_operation
+xorx857 xor 1000 sNaN -> NaN Invalid_operation
+xorx858 xor Inf sNaN -> NaN Invalid_operation
+xorx859 xor NaN sNaN -> NaN Invalid_operation
+
+-- propagating NaNs
+xorx861 xor NaN1 -Inf -> NaN Invalid_operation
+xorx862 xor +NaN2 -1000 -> NaN Invalid_operation
+xorx863 xor NaN3 1000 -> NaN Invalid_operation
+xorx864 xor NaN4 Inf -> NaN Invalid_operation
+xorx865 xor NaN5 +NaN6 -> NaN Invalid_operation
+xorx866 xor -Inf NaN7 -> NaN Invalid_operation
+xorx867 xor -1000 NaN8 -> NaN Invalid_operation
+xorx868 xor 1000 NaN9 -> NaN Invalid_operation
+xorx869 xor Inf +NaN10 -> NaN Invalid_operation
+xorx871 xor sNaN11 -Inf -> NaN Invalid_operation
+xorx872 xor sNaN12 -1000 -> NaN Invalid_operation
+xorx873 xor sNaN13 1000 -> NaN Invalid_operation
+xorx874 xor sNaN14 NaN17 -> NaN Invalid_operation
+xorx875 xor sNaN15 sNaN18 -> NaN Invalid_operation
+xorx876 xor NaN16 sNaN19 -> NaN Invalid_operation
+xorx877 xor -Inf +sNaN20 -> NaN Invalid_operation
+xorx878 xor -1000 sNaN21 -> NaN Invalid_operation
+xorx879 xor 1000 sNaN22 -> NaN Invalid_operation
+xorx880 xor Inf sNaN23 -> NaN Invalid_operation
+xorx881 xor +NaN25 +sNaN24 -> NaN Invalid_operation
+xorx882 xor -NaN26 NaN28 -> NaN Invalid_operation
+xorx883 xor -sNaN27 sNaN29 -> NaN Invalid_operation
+xorx884 xor 1000 -NaN30 -> NaN Invalid_operation
+xorx885 xor 1000 -sNaN31 -> NaN Invalid_operation
diff --git a/Lib/test/dis_module.py b/Lib/test/dis_module.py
new file mode 100644
index 00000000000..afbf600fdee
--- /dev/null
+++ b/Lib/test/dis_module.py
@@ -0,0 +1,5 @@
+
+# A simple module for testing the dis module.
+
+def f(): pass
+def g(): pass
diff --git a/Lib/test/doctest_aliases.py b/Lib/test/doctest_aliases.py
index 1f33f83276f..30cefafa83e 100644
--- a/Lib/test/doctest_aliases.py
+++ b/Lib/test/doctest_aliases.py
@@ -5,7 +5,7 @@ class TwoNames:
def f(self):
'''
- >>> print TwoNames().f()
+ >>> print(TwoNames().f())
f
'''
return 'f'
diff --git a/Lib/test/double_const.py b/Lib/test/double_const.py
index 16c33a19c98..67852aaf982 100644
--- a/Lib/test/double_const.py
+++ b/Lib/test/double_const.py
@@ -1,4 +1,4 @@
-from test.test_support import TestFailed
+from test.support import TestFailed
# A test for SF bug 422177: manifest float constants varied way too much in
# precision depending on whether Python was loading a module for the first
diff --git a/Lib/test/encoded_modules/__init__.py b/Lib/test/encoded_modules/__init__.py
new file mode 100644
index 00000000000..ec43252aad2
--- /dev/null
+++ b/Lib/test/encoded_modules/__init__.py
@@ -0,0 +1,23 @@
+# -*- encoding: utf-8 -*-
+
+# This is a package that contains a number of modules that are used to
+# test import from the source files that have different encodings.
+# This file (the __init__ module of the package), is encoded in utf-8
+# and contains a list of strings from various unicode planes that are
+# encoded differently to compare them to the same strings encoded
+# differently in submodules. The following list, test_strings,
+# contains a list of tuples. The first element of each tuple is the
+# suffix that should be prepended with 'module_' to arrive at the
+# encoded submodule name, the second item is the encoding and the last
+# is the test string. The same string is assigned to the variable
+# named 'test' inside the submodule. If the decoding of modules works
+# correctly, from module_xyz import test should result in the same
+# string as listed below in the 'xyz' entry.
+
+# module, encoding, test string
+test_strings = (
+ ('iso_8859_1', 'iso-8859-1', "Les hommes ont oublié cette vérité, "
+ "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens "
+ "responsable pour toujours de ce que tu as apprivoisé."),
+ ('koi8_r', 'koi8-r', "Познание беÑконечноÑти требует беÑконечного времени.")
+)
diff --git a/Lib/test/encoded_modules/module_iso_8859_1.py b/Lib/test/encoded_modules/module_iso_8859_1.py
new file mode 100644
index 00000000000..8f4a15c905d
--- /dev/null
+++ b/Lib/test/encoded_modules/module_iso_8859_1.py
@@ -0,0 +1,5 @@
+# test iso-8859-1 encoding
+# -*- encoding: iso-8859-1 -*-
+test = ("Les hommes ont oublié cette vérité, "
+ "dit le renard. Mais tu ne dois pas l'oublier. Tu deviens "
+ "responsable pour toujours de ce que tu as apprivoisé.")
diff --git a/Lib/test/encoded_modules/module_koi8_r.py b/Lib/test/encoded_modules/module_koi8_r.py
new file mode 100644
index 00000000000..9b23a5a218e
--- /dev/null
+++ b/Lib/test/encoded_modules/module_koi8_r.py
@@ -0,0 +1,3 @@
+# test koi8-r encoding
+# -*- encoding: koi8-r -*-
+test = "ðÏÚÎÁÎÉÅ ÂÅÓËÏÎÅÞÎÏÓÔÉ ÔÒÅÂÕÅÔ ÂÅÓËÏÎÅÞÎÏÇÏ ×ÒÅÍÅÎÉ."
diff --git a/Lib/test/exception_hierarchy.txt b/Lib/test/exception_hierarchy.txt
index 82b6ddfd4bd..5037b335d97 100644
--- a/Lib/test/exception_hierarchy.txt
+++ b/Lib/test/exception_hierarchy.txt
@@ -4,40 +4,39 @@ BaseException
+-- GeneratorExit
+-- Exception
+-- StopIteration
- +-- StandardError
- | +-- BufferError
- | +-- ArithmeticError
- | | +-- FloatingPointError
- | | +-- OverflowError
- | | +-- ZeroDivisionError
- | +-- AssertionError
- | +-- AttributeError
- | +-- EnvironmentError
- | | +-- IOError
- | | +-- OSError
- | | +-- WindowsError (Windows)
- | | +-- VMSError (VMS)
- | +-- EOFError
- | +-- ImportError
- | +-- LookupError
- | | +-- IndexError
- | | +-- KeyError
- | +-- MemoryError
- | +-- NameError
- | | +-- UnboundLocalError
- | +-- ReferenceError
- | +-- RuntimeError
- | | +-- NotImplementedError
- | +-- SyntaxError
- | | +-- IndentationError
- | | +-- TabError
- | +-- SystemError
- | +-- TypeError
- | +-- ValueError
- | +-- UnicodeError
- | +-- UnicodeDecodeError
- | +-- UnicodeEncodeError
- | +-- UnicodeTranslateError
+ +-- ArithmeticError
+ | +-- FloatingPointError
+ | +-- OverflowError
+ | +-- ZeroDivisionError
+ +-- AssertionError
+ +-- AttributeError
+ +-- BufferError
+ +-- EnvironmentError
+ | +-- IOError
+ | +-- OSError
+ | +-- WindowsError (Windows)
+ | +-- VMSError (VMS)
+ +-- EOFError
+ +-- ImportError
+ +-- LookupError
+ | +-- IndexError
+ | +-- KeyError
+ +-- MemoryError
+ +-- NameError
+ | +-- UnboundLocalError
+ +-- ReferenceError
+ +-- RuntimeError
+ | +-- NotImplementedError
+ +-- SyntaxError
+ | +-- IndentationError
+ | +-- TabError
+ +-- SystemError
+ +-- TypeError
+ +-- ValueError
+ | +-- UnicodeError
+ | +-- UnicodeDecodeError
+ | +-- UnicodeEncodeError
+ | +-- UnicodeTranslateError
+-- Warning
+-- DeprecationWarning
+-- PendingDeprecationWarning
@@ -45,6 +44,7 @@ BaseException
+-- SyntaxWarning
+-- UserWarning
+-- FutureWarning
- +-- ImportWarning
- +-- UnicodeWarning
- +-- BytesWarning
+ +-- ImportWarning
+ +-- UnicodeWarning
+ +-- BytesWarning
+ +-- ResourceWarning
diff --git a/Lib/test/fork_wait.py b/Lib/test/fork_wait.py
index 2646cbd5816..1caab1c491c 100644
--- a/Lib/test/fork_wait.py
+++ b/Lib/test/fork_wait.py
@@ -7,14 +7,11 @@ child after a fork().
On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
-
-While BeOS doesn't officially support fork and native threading in
-the same application, the present example should work just fine. DC
"""
import os, sys, time, unittest
-import test.test_support as test_support
-thread = test_support.import_module('thread')
+import test.support as support
+_thread = support.import_module('_thread')
LONGSLEEP = 2
SHORTSLEEP = 0.5
@@ -48,13 +45,12 @@ class ForkWait(unittest.TestCase):
def test_wait(self):
for i in range(NUM_THREADS):
- thread.start_new(self.f, (i,))
+ _thread.start_new(self.f, (i,))
time.sleep(LONGSLEEP)
- a = self.alive.keys()
- a.sort()
- self.assertEqual(a, range(NUM_THREADS))
+ a = sorted(self.alive.keys())
+ self.assertEqual(a, list(range(NUM_THREADS)))
prefork_lives = self.alive.copy()
diff --git a/Lib/test/formatfloat_testcases.txt b/Lib/test/formatfloat_testcases.txt
index 43ef0409543..25c07ba2939 100644
--- a/Lib/test/formatfloat_testcases.txt
+++ b/Lib/test/formatfloat_testcases.txt
@@ -81,14 +81,6 @@
%f 0.0000005001 -> 0.000001
%f 0.0000004999 -> 0.000000
--- nans and infinities
-%f nan -> nan
-%f inf -> inf
-%f -infinity -> -inf
-%F nan -> NAN
-%F infinity -> INF
-%F -inf -> -INF
-
-- 'e' code formatting with explicit precision (>= 0). Output should
-- always have exactly the number of places after the point that were
-- requested.
@@ -210,14 +202,6 @@
%#.1e 123.4 -> 1.2e+02
%#.2e 0.0001357 -> 1.36e-04
--- nans and infinities
-%e nan -> nan
-%e inf -> inf
-%e -infinity -> -inf
-%E nan -> NAN
-%E infinity -> INF
-%E -inf -> -INF
-
-- 'g' code formatting.
-- zeros
@@ -295,6 +279,11 @@
%.2g 0.000123 -> 0.00012
%.2g 0.0000123 -> 1.2e-05
+-- bad cases from http://bugs.python.org/issue9980
+%.12g 38210.0 -> 38210
+%.12g 37210.0 -> 37210
+%.12g 36210.0 -> 36210
+
-- alternate g formatting: always include decimal point and
-- exactly <precision> significant digits.
%#.0g 0 -> 0.
@@ -330,51 +319,37 @@
%#.5g 234.56 -> 234.56
%#.6g 234.56 -> 234.560
--- nans and infinities
-%g nan -> nan
-%g inf -> inf
-%g -infinity -> -inf
-%G nan -> NAN
-%G infinity -> INF
-%G -inf -> -INF
-
--- for repr formatting see the separate test_short_repr test in
--- test_float.py. Not all platforms use short repr for floats.
-
--- str formatting. Result always includes decimal point and at
+-- repr formatting. Result always includes decimal point and at
-- least one digit after the point, or an exponent.
-%s 0 -> 0.0
-%s 1 -> 1.0
-
-%s 0.01 -> 0.01
-%s 0.02 -> 0.02
-%s 0.03 -> 0.03
-%s 0.04 -> 0.04
-%s 0.05 -> 0.05
-
--- str truncates to 12 significant digits
-%s 1.234123412341 -> 1.23412341234
-%s 1.23412341234 -> 1.23412341234
-%s 1.2341234123 -> 1.2341234123
-
--- values >= 1e11 get an exponent
-%s 10 -> 10.0
-%s 100 -> 100.0
-%s 1e10 -> 10000000000.0
-%s 9.999e10 -> 99990000000.0
-%s 99999999999 -> 99999999999.0
-%s 99999999999.9 -> 99999999999.9
-%s 99999999999.99 -> 1e+11
-%s 1e11 -> 1e+11
-%s 1e12 -> 1e+12
+%r 0 -> 0.0
+%r 1 -> 1.0
+
+%r 0.01 -> 0.01
+%r 0.02 -> 0.02
+%r 0.03 -> 0.03
+%r 0.04 -> 0.04
+%r 0.05 -> 0.05
+
+-- values >= 1e16 get an exponent
+%r 10 -> 10.0
+%r 100 -> 100.0
+%r 1e15 -> 1000000000000000.0
+%r 9.999e15 -> 9999000000000000.0
+%r 9999999999999998 -> 9999999999999998.0
+%r 9999999999999999 -> 1e+16
+%r 1e16 -> 1e+16
+%r 1e17 -> 1e+17
-- as do values < 1e-4
-%s 1e-3 -> 0.001
-%s 1.001e-4 -> 0.0001001
-%s 1.000000000001e-4 -> 0.0001
-%s 1.00000000001e-4 -> 0.000100000000001
-%s 1.0000000001e-4 -> 0.00010000000001
-%s 1e-4 -> 0.0001
-%s 0.999999999999e-4 -> 9.99999999999e-05
-%s 0.999e-4 -> 9.99e-05
-%s 1e-5 -> 1e-05
+%r 1e-3 -> 0.001
+%r 1.001e-4 -> 0.0001001
+%r 1.0000000000000001e-4 -> 0.0001
+%r 1.000000000000001e-4 -> 0.0001000000000000001
+%r 1.00000000001e-4 -> 0.000100000000001
+%r 1.0000000001e-4 -> 0.00010000000001
+%r 1e-4 -> 0.0001
+%r 0.99999999999999999e-4 -> 0.0001
+%r 0.9999999999999999e-4 -> 9.999999999999999e-05
+%r 0.999999999999e-4 -> 9.99999999999e-05
+%r 0.999e-4 -> 9.99e-05
+%r 1e-5 -> 1e-05
diff --git a/Lib/test/gdb_sample.py b/Lib/test/gdb_sample.py
index a732b25b4d2..cab13fb4da5 100644
--- a/Lib/test/gdb_sample.py
+++ b/Lib/test/gdb_sample.py
@@ -7,6 +7,6 @@ def bar(a, b, c):
baz(a, b, c)
def baz(*args):
- print(42)
+ id(42)
foo(1, 2, 3)
diff --git a/Lib/test/greyrgb.uue b/Lib/test/greyrgb.uue
deleted file mode 100644
index de1beba180a..00000000000
--- a/Lib/test/greyrgb.uue
+++ /dev/null
@@ -1,1547 +0,0 @@
-begin 644 greytest.rgb
-M =H! 0 " 0 ! ! "0 )( ;F\@;F%M90
-M
-M ! " #_ $ %-
-M\ 0]<$ %%Z! !2>P
-M
-M
-M
-M
-M
-M
-M
-M H +!@ # L T1 .%@ #QH ! >
-M 1(P $BD !,O 4- %3H !8_ 710 &$H !E0 :50 &UD
-M !Q? =90 'FH !]P @=@ (7D ")^ CA )(D "6/ FE
-M)YH "B> II *JH "NP LM0 +;D "Z_ OQ ,,@ #', R
-MT ,]4 #39 UWP -N4 #?J X\ .?0 #KX [_ /0( #X'
-M _"@ 0! $$5 !"&P 0R$ $0G !%+0 1C( $<X !(/@ 24(
-M $I( !+3@ 3%( $U8 !.7@ 3V0 %!J !1< 4G4 %-Z !4@
-M588 %:, !7D0 6)8 %F; !:H 6Z0 %RH !=K0 7K( %^X !@
-MO@ 8<0 &+* !CS0 9-( &77 !FW 9^( &CH !I[@ :O0 &OZ
-M !L_P ;@, &\) !P#@ <1( '(8 !S'@ =", '4I !V+P =S,
-M '@Y !Y/P >D0 'M* !\4 ?58 'Y: !_8 @&0 (%I "";P
-M@W4 (1[ "%?P AH4 (>* "(D B98 (J< "+H@ C*@ (VN ".
-ML@ C[8 )"Z "1OP DL0 )/* "4T E=8 );< "7X@ F.@ )GM
-M ":\@ F_@ )S\ "> @ GP@ * . "A$P HA< *,< "D(0 I28
-M *8K "G, J#8 *D[ "J00 JT< *Q- "M4P KED *]> "P9
-ML6H +)P "S= M'H +6 "VA@ MXL +B/ "YDP NI< +N= "\
-MHP O:D +ZN "_M P+H ,' #"Q@ P\P ,31 #%UP QMT ,?C
-M #(Z R>T ,KS #+]P S/P ,X" #/" T T -$2 #2& TQX
-M -0D #5*@ UB\ -<U #8.@ V3X -I# #;2 W$T -U3 #>60
-MWU\ .!E #A:P XG .-T #D>0 Y7T .:# #GB0 Z(\ .F4 #J
-MF0 ZY\ .RD #MJ [JX .^T #PN0 \;\ /+% #SR@ ]- /76
-M #VVP ]^ /CF #YZP ^O /OU #\^P _@$ /\' $ # ! 1(
-M 0(6 $#&P !!"$ 04G $&+ !!S( 0@X $)/ !"D( 0M' $,3 !
-M#5$ 0Y6 !!@ 04 $& !!0 00 $$ !!0 08 $& !
-M!0 08 $% !!@ 04 $& !!0 00 $& !!@ 04 $&
-M !!@ 0, $% !!@ 04 $& !!0 08 $$ !!@ 08
-M $& !!0 00 $& !!0 00 $$ !! 04 $$ !!@
-M 08 $% !!@ 00 $$ !! 08 $% ! P 08 $% !
-M!@ 08 $& !!@ 04 $& !!@ 00 $& !!@ 00 $&
-M !!@ 08 $& !!@ 04 $% !!@ 08 $& !!0 04
-M $% !!0 00 $$ !!0 04 $& !!@ 08 $& ! P
-M 04 $% !!0 08 $& !!@ 08 $& !!0 00 $& !
-M!0 00 $& !!@ 04 $& !!@ 00 $& !!@ 04 $&
-M !!@ 08 $$ !!@ 00 $% !!@ 08 $& !! 08
-M $% !!@ 08 $& !!@ 08 $& !! 00 $$ !!0
-M 04 $& !!@ 08 $& !!@ 08 $% !!0 08 $$ !
-M!@ 08 $& !!0 00 $% !!0 04 $% !!0 08 $%
-M !!@ 08 $& !!@ 08 $% !!@ 08 $& !! 08
-M $& !!@ 04 $$ !! 00 $& !!@ 08 $% !!@
-M 08 $& !!@ 08 $% !!@ 08 $& !!0 04 $& !
-M! 04 $& !!@ 04 $% !!@ 08 $& !!@ 04 $&
-M !!0 00 $% !!0 04 $& !!@ 08 $& !!@ 04
-M $$ !!0 00 $& !!@ 08 $% !!0 08 $% !!
-M 08 $& !!0 08 $& !!0 08 $& !!0 04 $& !
-M!0 04 $% !!@ 08 $& !!0 08 $$ !!0 08 $&
-M !!0 08 $& !! 08 $% !!0 04 $% !!OZ*@EA6
-M*3156$5:6TUF<DE8/R4M,C ^16:"=7UP2S]I<FM;6&-B13EO:$]$+59<<G=%
-M1%IR?7IQ:F%C6EIH245?9UA/<GT^65IB:G)N=HIM6C])6&]B:# .-GV&<F)A
-M9()@,B4M%3EZ8FAB8F!"24UC8VM8+2 =&SEU@WIMBDS^$@D5+6EJ6UHM)3(^
-M16)R<FE:8F=J<FM/6%QB8F-;6E9)6E9B:G-K6V-I8UA)/F%J9F)B;G5U?7IH
-M/SQ?8W-S:4E@?'-J8F E&$R(844^:6]B:%0I$E@I#A(M259?:'-Z;TAH8$1$
-M/F)O6%A%6V$_3X"*8"<V:VIT?'U@+3\Y@DQ6 44!:@"(>HII,#9$6%D#.?Y$
-M=W5H8%D_*1@@+3!0<F9K8E@_8W=B:V-B5BTE16%H7D4M,&]W2$Q:6W)\;5MR
-M:UI:8#!%:W=G16-Z*5A666QZ;FZ!8F-8'3!B8EH;#A5-;EI/8UQF=SXM/#(V
-M6C)H@FMK<FQ;8V)K:TE5.Q4@8HJ*=85R/!@.(FAN8F [$BOU6%5$:GUZ8TUC
-M:VMC7F)J;VM@3V!J65E-1$AJ8S]87&A-/CY;8&!H8F)Z>7)U:EA%:5MK@4\Y
-M8H-V>VE8-CQ;@W V+4QO3#=64!U)1# 5&#M$8'!C<G!83#Y$:%A-;EA8+39+
-M6%IZC'I+/FEJ;GV">$DV.TE@ 3D!1 #^<8)P-EAA8FI?+1LE<()F8V-?22DM
-M.RU-:F)B3#8M3W!B;W)8.3DG&SE@6%@I'6)[:F-@36IR6T]R:EII/B=8<GIK
-M6$]G/U9$6G)R;7)R4')H,BU8<E8M*SE5:&!'6FEB>U@V<&!:/QM)<G)Z@W):
-M9EMB<E9A1!(51'J*=75]_G0R#AA):FIW:" ;26AB<75N8D5$8G)J8E]0>G)@
-M17=[8FIH23Y@9T5%8FE-.3Q-7V)K5B=B@')Z:FE;;$UF@TLV:H-N?7-825IW
-M>W!)24]K224V5D16:6$@&#(\16E-6SDM7VI:=WIZ:FM@-ALE+39F?'I836M:
-M9GV"@FI%/X)%:P$V 5@ \')M>F-;6V)V=RT.)6.(8F-P<F$V-F ^6FI?36X[
-M&RU;6H"":3XV/" R23961#9;<WAI7%]G8UE%<$U%:#XI16)R=VA)1U9,+UAG
-M:EM<:V-R9E@Y18!J5DEH:G!C8$E1;WIB25A))VY@-C)8=VMJ374#8OY)22T5
-M$BUB<FIJ=6U@,B V36)\=R4.&S9B>7)K9DU%3&MJ8FA%9GI,+6]W:G)K6C]9
-M:$U5:G)H8$0Y25M<224E8&MR9EM;<'-Z=TE9>H)N?'9@7EEJ<FY0>H* :D5;
-M23E):&\P)RE86%I@8Q42,&A%<'IU>GIJ7"T@%25-:ER-339A:FIZ?()Z6UA@
-M<P%8 6D R')1:F)88UIM?EP;)59S1$UW?7 V.6A-3$Q627)H-C(V1'J"<E]5
-M53Y452 _8%A)6&-96F]R6DD_:$DY8VE>6F)M>F]),$PM(@-)Z5A)6')R9FE-
-M5G*#6DUB:FI$6E8M3'UZ24UN7EI--BU;?V)K6G)R:V))6#\R+39@6FAC9F9J
-M7#8V/V)U=RT@&!56<FUJ:E]8.5IA8F](2'4V&SE,:GMM:$E%8%8V37-J:6!)
-M6&IH/B 5+0-$QTU-;WI_8"T[7H)];FMB6UY::FQ;?8F*<EIC838P:5DB*1M)
-M8$56:R(I1#DV8VYRAX-]=U\V,CYJ>DPY(#9L<FU]=7=@36][ 7H!< "B@6YB
-M44A@66-R=S\T.5\M.6]]@&):<&]:14D^>7)@.RU?>@-R_G!F3&!N("5)8EI%
-M/S9%:H!B3#Y)6$E;>GIL<GIZ<E4V8$E$24D_/C8Y8%MB:E!B8H)Z7EEJ=3XY
-M61LI=GI%15Y[>G$_&S9Z8VMB=75R8D]/8VE63&);8V]F<F9914E86FIW7U4[
-M,F-R<F9Q:F-/6"]%;V)B:U0@(#9;>G)Q8:0M24DG16M<8VAB8WMR9S(8.UA$
-M-EA$871L/B4I,'6"8&-H168$:YMN@(9]9F-A/R5?7"4K("TY54UJ26QI+2U:
-M6EX#>HU]:UI)26*#83(8(EQZ V:%:F!-:W(!>@%W /Y[AG=@6#E-6F)S:%A5
-M16EO<GAY@GN"BG!)-!)B9F)0+5IS7E!M>V],67-5("U)8%@K%39@>G-R8#]8
-M36N";D1/<H)Z:UA-25I)+2TV6# V/TUJ8FMH:H)J6EMC8$E5,#QR:TU9/UIZ
-M@FT@2'-F=FIB8FUS8DUC<X-U:W!R646K>GIB44UG:%EJ@G)B6FIJ:VZ >VYK
-M:#LV7EEJ=V-$$B5J>G5N=TD@&RU?:@-:N45(>WMK+1A)<FI8:V-)84L;&"D_
-M>&U:9FDV37-S;&E;=7A]=G)K6UA-7#9$/S0;/V!B16IH+45;6@-CEFMK=6M:
-M259B7C\M-F!L/TQK8UIB:FH!8@%$ /YG@GUS6#!$8&!:6#E$+6!K:VIR>G=D
-M?7=M3R5823DR+5EB:$UB>G!)37IO/S(R.TLE&"UA:G)W33YM36J":S8V46YU
-M>F],1%Q6,B4R7D0R-C!61%!@36IR:VEB8UMA259J64UB/S9K>FLE)5IK:V(Y
-M/F)R<EM:4'V*;6AJ6DG^<GMJ:V)Z<DQ$=7!F:%!;8F9V?7UU<F<^231C<F)$
-M%2EB=7)0>H [&SQ83%IH8#8G:GI@&PXM8FIK>W=I8#\8%14M<5I,8W!)/FEZ
-M<F]F4UR">'IL;G):6DE,65XE+55-=VIF>FI;:&!%/S\V/V ^)3Y,8VMB8E@R
-M+3EK;VAH@G)Z 7<!60#^:W5V?$T_24UA/S8V.QLV359:7&IR669B36AF6$D[
-M("4V/V!88G=O6DUR<FA$13P\*PX;26]B:DDV:%IC?EHP26U;4WUZ6D169$T\
-M+5A:26 ^/V9H:%E;8FMC14UJ:F-B:$186UA::G)A031%36)6+24O6FMR8D1B
-MA6)%3%I?_EQM:FUK;G=G67%Y<FLY5EQ<8F9Z=7QZ64(M6W):8#8M3&)H*5"#
-M:"TY138W8FH_*6AZ6B48)4U::G5Z:V=9*Q@.(%MP:%AK83]-<7IZ9F!-=75S
-M6WJ#8UMA6&!I/"DV57!<2')K<&MC6#]$/DEC6DD^+6-R:VE-*2TE17!C6X)B
-M=@&" 6D BF)B9GLV-EAJ:%H#2?X_25986%9:<G)O:41@<V-852DK-#9)6%EC
-M:F=R:VIK8%4^-C .#BUH:F)%3W)J<G\^&"5?84QR<EY)-CY663P^3&!R:"=@
-M>G)Z64QB:EX_5F]J:V=>24EB<G5Z=GIR8F!8650I&R4Y<F]G;X)H/C98=V)'
-M7U!:<F9P:F9R>FKS5$QB:V)<9EN"@G!:26]O3&A>259)6CY,>GII7UE%-CEC
-M23YB>F<[.T1965I636)J:$DE& D;2UA,6ED^/RU%:UMR>G9U:DQNBG=C6TQH
-M:U4[+5AN<UI:8W)N;G=C34UH:VMJ5B4Y:V-K6T1).RU?6DQ':P%] 6L _E]%
-M8( V+3EJ;4QA24E>8&-J:&!6<(!Z=T]8:WIJ8#8[,BU)9U],3&)[<6)G:5@M
-M.SD@&!(_;VU)37)W@H)4(!@E25MF:F)9-CLP6$4Y15MV<B(P:G)O-BE/>GIJ
-M6$1B:%MC8%9<=7U]>W)S:F-I36A5.Q@;6FIU@H)J/BU>??YR658^+6I:7&Y;
-M3W%W:$1C=6YL63]R<F]B9')G.5IB;&]H3$1C@FYS>VA64TMC9UI?9F(P26%-
-M8UI:8&IR>FT\*Q@I5DU-25M%/DE83%9J>GIF/AU:DH)P84E:8DL^66EF?6XY
-M8')K4'MR6#9::X!]8S8P8VMF84Q(:&!?3T6"6EP!:@%P /YH/TU[-"4=4SXP
-M:#8V6FIJ8EM)+UN':G)R34V":F)@7#P@+6AW8DE:=WI;8&!8-D0_.S(I+6!J
-M6%1::H)]=U4T*S98:VIC<$DP26%))S]-<GH_)5IO7R(2/WI_<E8@+41:8EIB
-M6G5]?7IJ7%IQ=DU,.3LG&#M9<H-\8BTE8FVN9FIB2#9:65EJ64E:<EPY3')P
-M<FH^6F)@6F)J21MA3%%K:F@Y-VUK9GIW;V!?6P-KSV!%&SM?/T5B8FIR?8EZ
-M8U @+6A8+2U@24E%26!86FMK1"TE5I**@FA823\M-G!P6GIZ,#!0:D5:7&8E
-M+3EZBG)9.5!B65M--FER<$DP8F\!: %O /Y)25EI6%0[.QL;6#()3&IJ:V$V
-M&TU_:FU[8F)K33]J:T08%4AZ<%E:<GMJ;V-)-DQD/BTR-DA:35]83VIJ8F!%
-M.RTY66MB<F(M/V9@-C9:>GMB,$E:/A@2*6B":T4E"2U-641-8W6&?6YB.2E;
-M;EI8/BD8#A@@1'IZ5B([<G+^:7)J63]>7V)B3%QC:T\^27)Z<F@V.5M;7&IJ
-M6A5?6C]G8F-@.6!H66YU;FAC34U<<F@^&RU(/CY/8VYR<HEM8EDE&U9M("UM
-M138_-CY)6EAF*2!58GJ%DGI)-B 8)7)W:VIN8$M8:F-O:F@[*259=7IR6%9B
-M8EM%+4QO;68Y@FAQ 7<!20#S6$5@1&IW8&%%+3])-%]K:VA%1#!H:V-Z>FIK
-M:U]):&L[&!@^<FL_-DQR>W)O6C8R;V%%.SY66E9$6F)J;V!:6E9)238_<G5W
-M.39@63\_:'5R>F%0638K,#9(:'<M.Q@I8&A;/T1,;7IJ3242-F=-35DM*0,)
-M_AL^64DE3()R8G)H8%MB8%I;8G)Z<D0E27!R=G)>3UI;9WML:T1-9TQJ8UIJ
-M8W!H36J":F)W:4E/=V]:2U4[(C]836ER=81U<EM$-$EI("UH6DD[*PY-8E9)
-M$B!-8V)N@HIG*0X.%5""?6I9:&!-:F9U>FM@255@65EZ:FAC<(I@-C9)7V)J
-M8FYT 7H!< #^6#Y)16=O3%EP83])-F)Z=V@P1$E)-C!Q@FIK:V-K@'=)("56
-M8EH_+2=CBFIJ6D0_36)/1#9-:&]%8&EJ<FA;:')R8S\M8G9Z6#E?.2U%8G)D
-M>H*"8CLR25A@:FIH,@D@6&IJ:4PY37)R9U4@+6!@9UI852D.#B R,#PM3'5J
-M_D<Y2$5@<&I:35YU=7)-+3]K<G5J:V]V9UQR;UM816!B<FM964Q@6EINBG)9
-M<GI-8'IZ8%AQ2!(E5C!):FEUAH)J64M$8#L\:6IB8#(.&UEB138_858V-EAN
-M8DP_.QT_=8)W6F-6-V)U;FYF;U]-8VQ/56IO6F-B-D15+2=@>H)Z@@%U 7
-M_E8Y6556:$DP8G=I9S96<G)C25AC624@3'5R:&)J;GIM<$0E.3XY/T4M.7)>
-M8TD^245-1#DV/UEB9EA;<'=B35Z"BGIK/DE::FM$8#8;-DUB9VUXA6M$0C])
-M8&=:;QL)"45536]O6$5K<G)W2S9F7'IL8$E402 K,ALI*3]O:^I)+24V36MJ
-M8%IP?7!F8U168G)R8EIJ=W%;<')J14EC9G)R9TE$14U:9H)W6F-B1&)Z<EE8
-M<F E+3L_24U0:WU]7%E?6FAD26!;8F]4*39O>F)8/C8_4"T_<F<[+3M426IU
-M<F-@14E:=75Z W*31%AP:2(Y8TE9:UI%1!L2,&)PB@%M 78 _F ^8%XG.50E
-M,$QF>E9::VM:36EL9BT;-G!R7%IF>G9K:VY+1"4@-EA)36=6:4U6:&!/6F!)
-M6$U$:$E/8VI@+3EK=H6"84E-:F]'-TDI&S9)1W-R?7)98$D^1$E89S05#BU)
-M36MW;UIG66:"8S!@.69Z:D4P840M/#(V.S99<KE@/R V3V)B2$ARB'5F8F)@
-M6F)J6UA?;VI<<FMJ6DEK=W)B8$D_/DE:8FMO8FA-1%IR:456:W)H64D$6,-;
-M:VYB66IO;7IC85E-:G]?3VZ*>F]8(AM)6$EU<DDE-F!'8FM/9TDP:6MF<GI]
-M?69A6W)[)4%)'3EM:UX_,!@8+5EZ 6X!=0#^8E]K:"4E7%4G+41B;UQW<VM0
-M:6MK6" M8VPY33]<<&-;8%I8.14M13!C6"M@8F)R@%!B;V-L83Y%8&E:16 ^
-M+38Y;H)B3%EK=V =2U@E*3\Y6G-U=5IB6D1)/U9@540@-DU98G)R9G)),&I@
-M'4@V5GIZ8"U%841)6EI835EF_ED\,C]%6&M@8G)V;G)N:W)K239@8V!88&%;
-M6E]C<G]Q:5@V-CY;:V-C;GIJ2458:FM;:G)R:$1$:&MK8U@_66%@8G!C9FYR
-M85A98VM:6V9K8UMH+1@B239F>G)/:&I,1%I$6E@M6&IJ9&UUBEQC9G*"14A8
-M*2)8:F):8$DI*8(^:P%F 6H _EIH<& M(#]N23\^1&IR>FMR6D]9:F0I)5I:
-M+5A%1%E?/S!(24DR.S8;.3X;/F)-<G])36]R=V$M)5A_;SE:;6$V)4]W:$18
-M:W)@)419,BD^24]K9F968F=)35A)6EA9/UE@6$Q/:F9S8#!,8"5)/T50;G)8
-M16%M/F)K8U\Y3?YP6#8_.T5@9G)U=6-K8UYF<%026'!A15EA65A@:')]?8EA
-M.RDM16MJ8W)Z:T586E!P8%IP<F@_.6J&A7))/UYI3TAR<GI_>G)P8'!C23Y@
-M8DU/=UDK*38[6W.$=WIZ:$187#YG8E]B:F)3>H9:/V)Z=58P/BD8275B7&9@
-M/TN"/D4!<@%B ,PV6%@;/C\_8%I823Y8:GIR<6(_.5MI/C996"U89EA-6$DI
-M'39)6$DV+40[)2T_1&]V2S9:>HI>&!@P<H%+.5MR8UAC>G\G87)F:#8[ S^+
-M,#];6U8O1&!Q:%8#2?Y-36!P8VA96F]M;6M,5F(_26 R'4]W7SY-<D1>;G%;
-M+3ES<4LV-CYA:WQN<FAL<&EK=UX8.7]P/TEA:&!J;6I[=8IW5!LK+3E8<7J#
-M8D5/13]::$E-8VE9.6"#BFL_+5EK8$UB7&U\?7J#>&I9.3YA8TU-:F!)*24_
-M3%Z#>GJC@G)'5DDP8FUB65YK7&9U<U9%:WUJ150E#C9R8B(^1%IN@V$!- $@
-M /XR6&9;15A8259:6$DY6&IZ=5XV,$E666=K83M)5DU-6V!4+2U)6EA67$DV
-M-E4^6'=K63XP:HI)#@D517IP1#E::W=Z=7\P5G=Q:E8M)55H24EH338V3$1B
-M>FE)3T1%.5B$>G);:H*"9G)J65MC6V\[&SYB5DE)6CEQ<VQA1$O^=X)N/!LV
-M8&Z"=FYL9GJ =H!C&!M8:38P6H!O6FA:;V9]@W \+2T;)6."B%I'6V%%8&M)
-M,$5I83];>GYW7BU)8FAA6TQ?<FIJBHIO6DUF>G=-6G-H3SD5+5L_8F-;:W)B
-M8$DV6FIJ6EAN=5I9:&))6X)R:FA/%1):32DV.3]9@GIR 8 !50#^2T]K<%AG
-M63X_6&)?23]-<G-K/C8_241;;FI8:&A)/EIK;TM8:$PY8%\P*2(V.7* 6T]5
-M*3]U8"<8("U,=VD_/UMZ>W)Z8#EJBG59( D@,#968DD=/F]R=6A-:W)N3S9-
-M>GYH+TQZ@FI:=W),9FUI7C]@34UN238Y>GIF6T]I_G-]>V$8%3=R>G-C34]]
-MAG9]<#PI.5]0)2]Z@&-C8FA@<G9V:%XV&!@_>H):/U!T6W=[8"TP85LV16MN
-M>G@_/TEI6DU).6)837:&;V-$4')U8VMR:T1L241U63Y$/CEC=WIR6&AJ8V9S
-M>GIB35A-.6.'9EQ98#8@.4U$2T5)3()C9@&& 7( _FE%:WI;:F,^.6-B7U]8
-M36IU<6!)26!@6FMK:'-O54EA8F-)8')@+6!G-C(G$AM:@FA%/S]9;VM84%!)
-M6EQ?/C94:FYN>W)-1'UV3R 8#A@T8&]),#E,<F@Y25IR8S8V6$A:82U$>GUN
-M46IR7&)M6T]:<%DY9E\M&VMK8VE%6^=R:7IJ*QTM:FYK22<P=XI]?7MI7C9%
-M6"TG:FM@<%!$67AC5CE9;C0@/VMR.38Y:&B"BFTI-F9:/R5/6W)X238V84DY
-M.QTV-C!C@&UL1$UF:F-[>V-A<&YW?7(^+2DM6')Z<FIO<F-B W*6:V!)-BDY
-M>F)B6EA$.TEB.3]9<$0^3 *# /YR.4UZ;VIG.2M;8%]B<FIJ=75O5E9O:EM;
-M6DQF;TQ:8V-@7UIN8CE?9T55+14;17EO-BU+8'=K25A@6V-;64D_26-D:X%J
-M8D5R@GAG.Q@@1'=R8&EM3V9:&QLP<F(=+5]%-D])16^"=6A1:G)R6TLV/U]F
-M5DQ8-CE-8$Q8+3#G6V-W=BTT15MJ:T08*6N"=7U[9F@V/FE)26E-1'5I/D=K
-M;C0;/G]F/TUJ:#\V+3Y(>H=R/TMI8D4@+45CA'!5-D4_2U4R-C!:<GV#9F-A
-M7T11>GUF7&-R@GIP2S8\,DEK:SDM:XAO30-;ED]9854V+4UZ7DE)1#Q$5CXM
-M/GQ?)24!<@&# /YK24UZ:G!,/CY@85!:?V9J:W)O36)W:VEH9UH_66%:66)J
-M:V]P8UAB65A-7UY$3')W238V.6MH24E:8%]<8F]B1$U-7GIB:EQF=8)Z6QL2
-M+6]$1&J(>F9?*0X;66 ;+6A%7V@^&T2"B')B2&V*6EQ)0D1B:EI).SY/8%I,
-M+27^16-J:C<_9F-C:TL@+6MZ=G!W;%@I+V]P6FDV(F)Z;F];6"4K:(5W86!P
-M:F=5*S8_:G)<14UO:ELR&Q@Y?(1W/S _6& _+2D^669Z,CEB<4E%=GUU8&AZ
-M?()P1#Q926%R;%D^9WUZ;%I-23\_:68\&R)B;CM58&%I6DD\26M@@B4. 4P!
-M=0#*3#E:>DUW8#Y(6G!B37%M=VIJ8CE%<GMQ<W=K/C]66$U;:U%I6UM>:T]6
-M3&-O;VAF<F)51#9;:5EH8DT_15IZ=TDV)TUW<FI036(#<OY?.S]<)2UC?7UN
-M7U5!-F9B-C9H,%!R/A(E:()F3#Y:BFH^1&A08V];-C8_8&MS:4E)65YN>UI@
-M:VMQ8#8E+4]K>V-(:ED8%4R"<UDE&U9V<H)_51(E:W5S6TUL<FMB83YO;UY/
-M655;>&$R&!4[8GB*:3]/:6-)-#Q866-K-BFS/F9:1&IZ;F)K<GIZ8S\Y8%II
-M>&!/;G)U=GUR8%A$-G-X22DK24TP:6IJ>G(Y66-S:2T. 38!< #^)1U@>FER
-M9EI-6&]W26)RBH%Z<$4V6G)B:G-K34M81#Y$9SD_13]-;$U61$E;=WMH7&)@
-M63Y::5I_;T0M-D1J>FE$(#EJ@GMF6F-,6G%W:F-I)39B>G)J3&)J4')[8&!V
-M.5IH6#0K27)B241B@GI/26A68')8)25$<HAZ8EAI_FE13V)::FEC=W ^)398
-M37)Q3&)%'1@V<FI)*39:6U%RBF88&#EB:6)C:VIC36DV7&I-8V8Y-EYI,A4E
-M6%!Z?7)C;'IJ<BT^:6]B:&%$.6]D34]O8D1@8EQF63PM5C]:=V%B<G9N<G5R
-M>G=)&V]W8#Y@838E5F-;>H))/V)[=X)>( $; 3\ UQ@5-EJ <F-$+V1O6B=:
-M<GR"@G-M35AB34AJ=T5)6$U@8&))1#\V16AI:%@P+5ER=F!:6E@V16=9AWI8
-M+3]@8F9W839)8'5]<EMC23]9<F1B=S8V8GIR6@-C_F)J=7IQ:2U)24UA25MF
-M3456:X6"9E]9+S9A52LE,FZ%=S\_36YQ22]%:EI;>WIO3V%A16-W7F@V(" _
-M<6M6-$EI-C!9>G=%(!LV3UIR<EY:3V]85FA87G-97EIO/Q@V:%IO4%QW;G=K
-M=3XV36],-UI-.6MJ3$1H<"U-33E-<*98+3\R,&)F<G5V8VEC6EQZ5!)9?5M%
-M6W%926MH2')S22 Y@HUZ7@$R 2 _BDK,CY]B&]$'3=@/" ^8G6"@&-:7')K
-M5CLY<&-86EAK<5@W66 [-F)R>G=)+3E9<FM$138E/V!%>GUH26)Z=VMK=V)%
-M26MR<F)B8TDV8FM99F]-:W5<1&!18WMP3WJ";3\V-CE:6G=K1"U)8VEZ=7)B
-M," V.3Y5/W)]<DE86_Y<=7=8.6 P/G)M;6IZ:SE:=V--/RDI/F-:5"TY9D0I
-M16IJ=#0@)2TV:WM;1&MR<DQB<&%K<7!B<F<M/W=R8S8T:W-L<G)@6%MI225/
-M/TEC8D4E16 V5DD^.7-Q1"TV/F%K?&YR:&QP:6MW7A@Y?W _27%I3&IM16I:
-M-A(G8H*"BG<!20$R /Y97D5/:()];U9)/RDI8%IJ?()J6%IR:F)$,%IC8&EK
-M:W)@/UAH/B V;WIZ;UA836]P6#88%24_,'!R8D5<?7):6GJ 6D5C8FER:G)H
-M1%9J9F)H8EIN:4Q)+TU[<F)]DGH_.RT^36)R:#X;+4DR6X)R<E@@)R M7DES
-M?690<GO18EQK;TU8)2U%15!M@&\Y37)L6UD_+39$/S\M/FM8/TEP8FM>,B K
-M-FJ":4EK>G598'-L8VMI35!H3UES@&M$+4UR:VIR;W)Z>V)%6TDY26AO!#:K
-M5DUB2W>";CP;-F!N@G9N;&9Z@': 8Q@;6&DV,%J ;UIH35I9;C0;)V:"?0%H
-M 5D _H!B65Y88VY[>F))(!AJ<69N>F)K<%QJ:FE5.4U)6FIJ<F]925I$*1M,
-M<G5R8%A)<'IW1!@8&R ;;%])/UJ"<#0_<H)R6F)C6DA<<GI@5F)K6TUH6$5-
-M/CPB-F]07GV,@E8^+41;;W)O12TR.R4V>FUK:"D5&" [6&AR1$%UBOZ 6S]:
-M8G!%-CPT26)F<EAL;FMA8&%+84E)5" =16)),')_:VE5*RU)8WIZ>'M[<$E-
-M<VMI44U9,#!8;W9[<FA5-T]A1&)D>H6#<EIC838P:5DB*39)341H:7-]>V$8
-M%3=R>G-C34]]AG9]<#PI.5]0)2]Z@&-C6V)A?8!>-D6"=W4!; %K /Z"33E@
-M15A,<'MK5" 28WIK:W=B:FE,6')Z:#XM)24^8G)W:F%//D0[25IJ<FH^,&*"
-M>F@_.24@(&AG1#]:>G(^.6-N<F!B:V V/UEK:$U9>F=%8EH^+1L@%39-+2=J
-M@GQ--BT[.6MK<G)624DI)7IR9FM5%14@,DE@6C9A@X#^DG<P,#]K639%/UIO
-M3%EB>FY0:G%;8GIB8V0T'39O339O@&YC:4E$/U!C<G6"<EA)36M[:U@_53 E
-M6&YV<FIK6EAA12=84&Z AGUF8V$_)5]<)1LM=VA-6UMR:7IJ*QTM:FYK22<P
-M=XI]?7MI7C9%6"TG:FM@<&=0:WI]@&E/@EIB 7(!>@#^@TDG639).6EP8E4@
-M)5IZ>F)J:F)8+39B9'Y;-"D8($5C<F];2RU):6A@:7IZ1"=:@H)Z:$DE+45H
-M650V26AK35EB<G)H:69J6$E$14TY7W)Z.5E;8#(.#A@T22T;37J"62T[.QLY
-M36* :EE@+1MR<FMO:385&"U)6$DB8HAN_G2#8SLE8#\V56!I<F8_1'=K1%QI
-M+3!W?%M8-BM+=U@Y<WI>6EIH<4E%:7)N?7-%63E(?7-P83X@&TEZ@W);7T5;
-M>& Y6&);=7A]=G)K6UA-7#8;)5IR9EHP6V-W=BTT15MJ:T08*6N"=7U[9F@V
-M/FE)26E-1'6(:7=K<G)I/((;)P%F 8, PGM))4D\+1M-8#DV("58<H)O:F)6
-M.38V/C=R8U1$," M1&-H5BT8-F]P86-T@E@I1'*)@GMR+3!F<%I-54E)84]@
-M6@-R_FE;:G)B7SXV+4]N@F)R:F->,A@R86A5*45K?&LP.3<I)2=->FMM;S\@
-M17!R:W)<*2 T56$V$CEJ>GV&<E@R8#\\7V-S<VE)8'QS:F)@)1A,B&%%(!LY
-MAV P:G)A6D5;@4\Y:W)SAX-B7S=)<&9P82D.#BUB>GIC8$5C@FM/8[MR9E-<
-M@GAZ;&YR6EI)54E88F]I)45C:FHW/V9C8VM+("UK>G9P=VQ8*2]O<%II-B)B
-MBGIK8&EK8#8.#@$P 6( _C9Z@&!9+2<V840I("E8<GIZ<D\_.5AF7D]U8E]8
-M1#(R,%9B8C\@+6AO659J>FHY+4UZ?7IZ/RU:>FM:8E@_241-/V)K<FAH8W)D
-M6V0_/$EF?$=K=69R21LR:H)O/C9B9(!F8$0_52)%<EQF@F,[+4EF<FMH-B5>
-M?6-9*SYCBOZ-BGML36)816E;:X%/.6*#=GMI6#8\6X-P-A@8-H)K/V%H6DQ?
-M8VM8/VMJ9HJ/<FD_8&%(<6$I%1@M36IK:V@Y37MP6$UJ9F!-=75S6WJ#8UMA
-M6VMS6F-I25E>;GM:8&MK<6 V)2U/:WMC2&I9&!5,@G-9)1M6=79G,B4@)3Z"
-M=U4"%0#^26I[@&YR:$5@1#LR+59B<G* 6U]H86QW:6=%:G=86$E$3V)J:%X_
-M8&E96FIZ=6A$/V)U:F9A15EV=FMC8V%-1#8M3V)N15MR@&)B3U9)6&MJ1$U-
-M7&HV%25,9&(V)6."@GU];6I5%39R9U!Z<EH_5F!J;U82%5J':'!926*#_H6&
-M?8%A6VE;;$UF@TLV:H-N?7-825IW>W!)*RE):VM;84U@16)J:DDT8VA/>HUV
-M:#E,1#!I8T0@(#]I<TU(<V9%8W=),$Q;<GIV=6I,;HIW8UMB:W)@6F)I:5%/
-M8EIJ:6-W<#XE-EA-<G%,8D4=&#9R:DDI-EI<6V]).2<8+8)O;0$. 2D _DE9
-M9'=09H!B6$0R,D1)36]K:D10;V)9;W)@+6AR8U8_1%E:6598/T4_16!K<G=B
-M14]O<W!:64E-<G=B7FIO:$TV)4EO83DP:'MR7%]H6&M[>G)P36)J524M6%]$
-M&QM9>GV%?&IK/Q@I<'IF<W=B3VA?7&<Y& DG<FIN:6!-9H%Z WW\<F%;6W!S
-M>G=)67J";GQV8%Y9:G)N4%@\26):6E@Y6&%B9G!+'4UH.6:1@F M+55)86MF
-M-B V8W<V)5IO6UMP6# ^5FIZ>F8^'5J2@G!A5G!I245%36YQ22]%:EI;>WIO
-M3V%A16-W7F@V(" _<6M6-$EI3S9K,$1:)39W@P$M 2< L4E-6FE$2'IR:TDM
-M+4E>1&-W34E-6F)96W)P+5EW:U\V+4E?/SY)6%@R(E]C:WI;-DD#<LMH23XV
-M:W)G6F)R<F M&#=H24@;/FIB/V)J67*%?7:!:V)B:4E89W!)&!@V:69]@FI/
-M&PX;8()U=W)O6EI/8E@M.RD;16-B6U@_47,#?;!Z:D],;WI_8"T[7H)];FMB
-M6UY::FQ;8%I/6$E-8#X^6W)L9E45+5PY6H.*<"4;2W #=\EC/#=C>EDT/DU;
-M:6]A23966FMK1"TE5I**@FA)7&-)/DE;7'5W6#E@,#YR;6UJ>FLY6G=C33\I
-M*3YC6E0M.69A1&]%-CL;&TR" 6@!/@#^:$UC<$E%:W6'9R4I5%A%6G1$2&A;
-M7F!%7GU)37]R:EE$5DU).SY)8#\E86QZ>F(V/UQ[<FI8+1MC<G)K<GIU<$0M
-M/UP[5#8M23DM36);9(J$5'5R8FMK6F=W;TDE("U8669U>EDI#@X^@GUZ<E!,
-M.3!H8#(_5CXV6EDM-EA@EDU>=7V#=5M$871L/B4I,'6"8&-I168$:YEQ<FLY
-M/UAN/BT_6FM(530T/S9%9G!W)1M+ W+*:6%6.6.#@7!?/DUU>FI;*4E:6&8I
-M(%EJ?862>FEG9F)%6GMB7&MO35@E+45%4&V ;SE-<FQ;63\M-D0_/RT^:W=8
-M9&=8.R ;+6@!=P%< +E:,#EH/CEG>H-W24E@7T5-:%E9:&AC8$E/<FI,:VMC
-M8VAG7TT^/E9@/S!I<')J6$D^17)U<E@E&%@#:O=Z>G:#<E]?24E:;5\^+2U%
-M6D=B?8E:4&IR<FI,67)K6#8I-DE9:69J:3P8&"5B<G)K6E@M)5A?1#]F7C9$
-M+0X@15@M,%MK?8)[8TEA2QL8*3]X;5IF;2U)<W-L:6MN;#8V27!8/S9%6D58
-M9FE$-D5B8TTE&S]S7@-;R& V-F:$>W=A6W5[8UHM36)621(837)F=9**<FMN
-M>V%%BH!;/UIB<$4V/#1)8F9R6&QN:V%@84MA24E4(!U%>&)B7UA)-BDI.0%H
-M 5H W%8V+4DM+4ER@WI086%B8%E@8&-R8FA@+2U;?W)H8$]88VIH6DE)6&]-
-M+45B<FA-24E-8VIH5"T.259B:W)Z>X*":V!)25IJ>E8V/TE%35IR>F ^5FIT
-M<DU8:FM: TG^7$];6EQH6#8R/CYB:F!)240^6%8^-E966%4T#ALM6$$E+3!K
-MBI)[86 _&!45+7%:3&9W23YI>G)O<EQC.RTV8VEN86-:/SE::ED_:7IW-B4I
-M/U$Y)S9C<$D@,')B9F]C;GI[=SYB;U8I%2!$<EE:>GUR:FZ%=S^ DG<P-DE@
-MH5@V13]:;TQ98GIN4&IQ6V)Z8F-D-!TV=V]:34E%1#\V+0$_ 5@ _B='4$16
-M34U::GUZ:CE88FI:.6IU;E@I("UGBG9L:3XE/F]B5FAK<FI@6%MM<FM;5EAA
-M=VM@/S8_8&!W>G5R<FE@36!:6%IJ<FIO8$]-6VMR<EA-53]@<FYS6TD_8')O
-M62TI.5IU<FE;8VQK6#\V/TU;<%DK)6EA66A+-"M+:?YI/!@./X*-@G)G62L8
-M#B!;<&A8:V$_37%Z>H)[6T0R-EAJ;W!R<&%$8W)83W*&@#\V27%A-A@;8&Q$
-M(#)I8#]:3411;H,Y8G)C,B Y37IF86EN9T=RBG)5;G2#8S\Y6$D\56!I:V$_
-M36MK3%QI+3!H<&!8-BM):VD^-C(M/FJ";S8"/P#^6%A)-D1-36ER=7IK-CY8
-M45@^:GIF330\-T5Z>FYC,AL@8UM%8FIJ;FQC;VUN;%E);W)J;EI)/SY)6G*"
-M@G5K<VM@6F!B8&AM8W)R6T5C>WIR63E>56!S<G);)25@=G)C1" E26MZ=U!C
-M?75I1"D;-FAP:3\E16!8:V V+45R_H!5#@X_=7UU<6AF/RL8*4EF;UDY15@^
-M6F9R=HIP7C\V26)J<G-Z=UAJ:UIH8W6#3UE?>W1$*2U;:#\@,EIW6UM>-C!(
-M9EA::FQ/-D1)<W-B6FP^&T1]:EAZ?89R6#]82SQ?86EI63]8:6-B8F E+4UK
-M84L@-DUK:#\E*2DM3()C30%/ 6$ _F-C1#8V/TMH<F9H@%4M/C9$:&9U8B<E
-M86E86G5Z:#8@)SM8;G!J3UIB:WIN:FD^-G)R64<_6#LE*39:>GUU:FYK8EI@
-M8VIK:F)1>G0;27)R:G5%15IP<W9W8#0@6FY;3U@E&S]A6ULG1'IV<FD_&"EA
-M:%YG1#\_+8-L224P:_Y[/ X.5G5[;FQH<69$*2M88V-P)1U$24EB:%!N;&%)
-M/UE:8GAN>H=P;&Q/:&QW?EMA.5MW:4MA<'=9*39%<G)C:5Y526!P;UI-35IJ
-M6FIJ139//SM)8V=;<G)K3$]6:&YR;UA5-B ;/UA:8FA6/CY)25MJ<&M;6V R
-M)3M)8VB"9D\!5@%I +=C8EH^+2([<%YC6W9C,#8@&UAZ:SD5)6EM:D]/@&Y8
-M.S(M,&^">F)-24AZ>V!;)2!9:UA)/C\V R"(+5QR;FIJ;FH#8OYF>FUK8W)W
-M+4M:3U%V<&%@3VIF<F->/V%K14]I1#]B<G)F-CM0<G. ;#(E8%I8:&EI6#^#
-M:TD;/GAZ21@81&IZ:UA%8GA:.S]88V%K7E5+8&!(;U@_36$\*6EF7EIF@WUN
-M8W=J8EEK@F-F,C96:6F!<G)I25A+8H!L8V)I8W&[:VYS22=6>FI66T0E-F!I
-M:5]B8G)R;UE-6W)F9F],8#P8#BE)6&)O6V!)/SY-<G9R8D]K6B V36QR:F@!
-M:P%R /YK3&)M$A(V5DAA6V9W/BTI&"UN:24.)6AN7&MK>G)B22TM1%E]@G)?
-M6%9J>VM6.T19:%I-6%E)-CP\,CYB;UE<>FIK:V!-:DQ9>W=Z36!A345:;W)W
-M86E:6F)B;&MH6%EP84]B>G6 <FE%8EYN:F8_6F-I:VYS<&"":T0828/^BG%8
-M14E?>VQ$&S!S<%E+,%MW:VEQ8$UF24UH/S9$)2U965@_6W)K:&%J>G P.7-W
-M<$LM.5A;9W)C3UMI/V)Z<EH^3%YR35""9R55=W!%65@\25AI<F)08FIR;UA-
-M:G)R:G!6:FT_'2!)6VYZ<F]I2418=W)R:UIC:$M51%MC@D50 7H!=0"T9T1J
-M@QL21$U$8FM<:V-85#0M8%\M(#9L<F)O=GIM8DDK(E8_8F)C65]U=G5J5CY)
-M/FEG301@_FAI=5]/838R=V)/3%A%6#8^;G)R9FIW:DTV,&*"@G-915A><G):
-M24UR;%EC<F-R;75R=V-/6F9K<%M>:VMJ7F9_6T0I)V*(@X* 3TAR<#(2'5EJ
-M8UY$/F)B=V]625I8.4E@83(@+5E8/S]88#9%9UIR<#PE1X-R<$LV6'!C8<AA
-M25!F/UIB5CDI*4];35MZ=S8G8&,P2U]96C9/<F=%/T=B;VA::W)Z<FMJ;W)@
-M/RU$6'%Z;UYK34EB6VYK:EIB4&)W8F%)&QT!: %F ,!B3&Z1)1A56UIH<F-1
-M8F):6$M$/S8Y3W)U<G)J;6I)+2L826!8.38P6G)]@VA%,"TM8W=I65M@:G*!
-M>VM/6#(M W+384U-6#X_:&-B;6MU>F(R%2]WB'I/.5I,;VMA13YI8UAH>FM:
-M2&IZ@W%%66MM<D]/6F]C3U%J6#9$*2=-<HJ*;%%J:RTG)38P25I$)24M;G)C
-M86,#6>5H=S(@-&!H8$E8/Q@E2UEP:U@E-G-S>W _5G)\:4U:344_:6 ^)14I
-M25@^1&IZ<D1).398:%I8/TEJ8TE$.41G:F-G:FMR<FMK<F)6/EA@:G)G35I@
-M36%)6G)G3VE)479]<F$I&P%9 6H B%HP6HI8,%AC!&O^85A035AH*1LI1&!J
-M;H)U<F-P1!LR)3YM6#0I*3Y99GI?/D0I(#YC>E!96UIN@G5B35@_27IZ@W!-
-M85M%/V!8.6)F>XAC)0D26H-W8#D^.V):84U/3T4^6GML8V-H>HIL,$AZ=7)%
-M/TEC8F-C:6$M1#8I-DUUBGI/4'-87EY5]"DM5#L8&RU9<FMZ@6$_.6)0.RDV
-M26IR8V!$+3Q5:'=R7B4W:W)]<F%C6V9[8EL_+3!O;4DI&"5$22T;/FZ"?U0=
-M/$EB7&$\-C]:6F!H<69N@G!)17> <D]%35AB:W=W:EHP+V!;6C8Y6EHY<4]-
-M8GIU<F$V 6$!<@#^:#];;G)A36)R:E!C<G);24]?.1(2)4EC<HJ">FMH7CLV
-M86!H230T/%A98VM)+39;(!(V:%I86EMN>W);35@V6&YUB&(T8W!824\^)3 _
-M@)%P*0X827)F:V$^/VA98VQA2T0V-V=A8&MZ=8-C-D5[@G=@/SE)87)Z6FDV
-M/SXM_C9-8G:"6TUL<%MA:5Q)83\R+39)6F-Z@G!826U-+3M$15IK<W)9/UA8
-M8W!S8S957GJ":UMQ6T1RB'IA/S9I:4DR*2T_82L@)6*%?6@M-EMJ<DLW/$M9
-M1$1K<V)>>W=A6'*#=6$^/EA:;G=R:F I$C]/6#X_240G8VE86%!F>H)W30%:
-M 7, _FM;8VIZ:U9B>FM:8W)V>&!-3%48#@XI27J2A'5R:EA)28B#<DTR+3YI
-M;V)H5"D26"D.$BU)5E]H<WIR:&)B-CE%9H-@,&)R:VQH23()&VJ)>DDT+5AK
-M7G)S/DEP8F-K83]97CY915AB=UQZ<458<GMZ<T0M1%ER?75F8VA%19]@:V)>
-M11U,:G)P1!LE8GIB45A8/AU8844_,&-0.2U) V"K6V)R<FYK;&E5/"U-=7US
-M8VQS8UMB:6QV=6UC6CXV6&A@35]J6ELY27R";0-RL'M$+55@7C\^8WIP6W)R
-M8V-K>W)B/UAA36IP<E!8,A@E26-H9U9$.UMF:F-$4')U8P%K 7( _F-06EY\
-M=T=B>FM88G)U>F]-8%@;"0X8-FN*BFU>338V1(J%@F]4+2U,;TPW5E =240P
-M%1@[1&!P8W)R;VMK6"T;/WAP.6)U9')R3#()&%F"=UM>6$5),&!O.5AA:6EB
-M6#!::#]A24U97$UR>%M98VQZ:D0I-C9C?7%;3V V/Z!Z;FAC624M25Z(;CLR
-M6W5R:V-O-BU)6$54/E@V(!M%6P-8PDQ-6V-C:6-926!Q:WIR7G)K6TE/86=R
-M=69A8#])=X-J9G!R6#8E/WN";G5R:F!>)4)@6$D_3'5N6F-@1&MC<FIO8 -C
-MF'IS>FA@230I6%IR;V!-:&EC:FQ$369J8P)[ /YF33M-=GU$35I,-&!J;7-U
-M4&IP,A4.'3QO@HUZ12TI+4EZ>()U<EY)3VM))3961%9I82 8,CQ%:4U;<F)B
-M7F @&"5-8UAN:D]F@ELV&"!@>G=$.7!I-A(V8#9/15AI340;/UXG/T1,9T1)
-M;')C22<_<FLP+40V/W=R6EMF+4G^=U1W>F8M("5:>WMH25IR:7> =V!%3UI)
-M8FAF+0X8/TU%/DU)-C]88%I:6$E@>F)K<G)N8DE%241)8V)-8V-88H*1<FR!
-M?&$I("UJ>G=Z6SXP8"DK/SX_-CEJ<TQ8:$]@86EI8F)H.4V">FIB8E8^1$DY
-M:6]$16)K6EQF8V%?@D11 7H!?0#^=7)816IZ:$E)+1@^54U[@%!,<D4P%2 R
-M3'IV>F$R(!LV:W9V:F9R>H* :D5;23E):&\P)RE86%I@8VUJ6%M;1&YF)25B
-MBG(_:H5Z<#8M67I[8"4P<&T;-FA@839/<F)>*3YQ52DM27!;64]B:FD\,DQB
-M239$2S9)8V-B<$D^]&E(<H)X7C E8VUK:#E-:4A9?8)R;EE/3VAK8S0.($E-
-M24E865IB6#8E/EI@6V ^,&:#;G%I245$-EMF.4]I85IB@G)4;FYB+1LB36IJ
-M?&]F6T\R*T1+539)8W)%/F9W85A;<FMB/Q@E;W)H6$Q8/D1)(F!K UB)7&)(
-M,CEB<4E% 78!?0#^;GIZ:%MF;S V13DV1#ERBGI::E95+3QA8W)J;F V*2D\
-M3W!N;&)D?8F*<EIC838P:5DB*1M)8$56:VUB7UXV.7MB&Q4W=6]':&AU?4DM
-M35QV@2T2+5@I&U9C9B=9>&IP/S!S;24V640P8G%F;GIJ6TE':&%82TE/245$
-M<F]/_F!H:VYS6SL^8W)K8SPY86%::WJ#>&A1<'=R9U45)4U:.4E;6V)V=RT@
-M-EA@6E@^&T1K37* :6%@15AP64UB8UL_9H-K8V)P7C(R=$Q$8GMZ@&-5-D5A
-M85AA:7!5-EIK8UA%8W-O-A@E86]J8%I935]))6ES<6)89G%/-BD^9H):1 %J
-M 7H _F1F;FUR6U@E%2T\/SXY<(:(:UI:9CY$;GIJ:7)A/RT_845I7&IK4&Z
-MAGUF8V$_)5]<)2L@+3E536IR:UY)&RUC-@D.'6IZ8W!$68A+/%M:<()A.2 E
-M/!@E6&85/G-'7UE)<G(M/VD[%2MP;G6*;F-P:VQO:$U'64DV,&MW6OY-:FQC
-M65XP-D=F<G!),%IC:6-K@H1N36)K<FMF1$EP:C(V6&-:;7Y<*3))6$U)9BTE
-M/SYC<W-L8DUH8UA8:F9@+6J&<V-%:F)).VI,6&F">H->8FT^-D596VEK8$]C
-M:F)I/TEC<VE%1&-P:&]R:%IG6E5B<GIJ1&:"8V%$.6^"9$T!3P%O /YZ8EQ;
-M:VE6/A4@)54V/&A]?6I%2UA@15F(6UEW:3\M6'!-8TQB@&);=7A]=G)K6UA-
-M7#9$/S0;/V!B<F]@2QL_:$0G'1MBBGU[85B"/S9A<'J*>F M+44@%2TV"25@
-M/C Y8&YZ6W!K530_6T]F@VM/>HA[;G)925E4)15-<F/^86MC:V-K64LV16)Z
-M6R4_:VMI8W.*?6M:3%MP8TQ6<FM81$Q@66-R=S\_158_/F]M,B4_66-F<UQC
-M:#E$6&)N:"U,<G=J+4E65DE:7VAK<GJ(04UZ;BTM-D5I:4U8:6MS<DE46UYS
-M:U9(<$UP=W)K:F9C.3]N>UQB=5Q:33EK@FI, 40!:P#^@W)'6G%C8F$R%1@V
-M/CYF?75K+2TV<&A-=UMI=V$_-DQB6E@P,G=R9E-<@GAZ;&YR6EI)3%E>)2U5
-M36!W6TP^8(" :R4)-GI]=G)B@UDP.6IZ?8IK/EEA-"DK%0X;8%@V+6!W=UIR
-M:&!@86M;6FYI,&.*AGIJ8#Y%/A@.+5]0_E!J9GAR<7=S8%59:U\M/V-<;W!F
-M?8)U<EI)8FL_1&QK6%A-.4U:8G-H3TE)6FB#AVDM/T5:9GIB8F<M(C8_=W)+
-M16)N<E@V1$1)16-O:DE>>UEM>FU;1#8_:%@M+3E<@H-,16%%8VE85EE)8&IR
-M=7)O8AL2.7IW;G)B3S])8X)B10$E 44 _GI[159C15IR;S\Y)2U$8W5H<BD5
-M&UAK;W)(9VQ%/F-I6CE)-D5J:F9@375U<UMZ@V-;85A@:3PI-E5$8EL^86QN
-M?'<\("U:>GIF8G=Q351L>W*">V-F:5Y)4$$@,EA@1#9-9G)B35E96$UZ<EI:
-M82=:?8=Z9F-823\5"1@_2ZDV-UIZ7&-[;F]@8%I-66%C6V-L:WUR>G9P6V)J
-M7E]Z:T]833E$8&!:6 ,_U&-RBGUR:5L_36-Z>EQ853(;)VMR7CE$8FMC2SY4
-M/R<V4&Q536(Y<HIF6UDV:8!5&Q@I-F:(:$]:15E@14PY5E9;9GIZ<F ;%1M;
-M;F9M:EM):W!J/@$; 2< _H"*:F-96FER9EA@+2U%:WMR<C\I&#)(>G5B<F,Y
-M56:!=S8V8'=P3%MR>G9U:DQNBG=C6TQH:U4[+5AA34DB/V]R9G=/-DM-;8-R
-M9FUW33EI<FMC9G=O8F-96V8E55M)26!O<'=H-C\V+2=K<FQT<$1K?8I[8UMI
-M84DI"0XM1?X@&U9J/UJ!<FAB8%M)6F%C<5MA9G)R=G5R<F]D26^"<FA-23])
-M36$_-C8[+6IF@GIC:F-56UYNB6A86V8I&T5B<4E)2&A;8#DE+3P;-FEI:E@B
-M6H-L338E8H-O/" R539KB&]A25]H6DU%259(6G5Z=TE$,AM)<&-R9C]->H*"
-M:UX!1 %4 /Y]BGUL4&=R<EY9.39$-CEP;FMH:4LM,&N!8V9@)TE)2'(M'5IZ
-M6#E6:GIZ9CX=6I*"<&%)6F)+/EEI6G)R1"5B>W)R338_+2]J<EQ@<FQ@:%IC
-M6#E::5@_/EII*4E4(")H>G)[<F-H51@826),8UQ:<X*%?6MH:G!B7C 8("G^
-M("!)8RTP=V):34E915IQ<EYC8%IK8DA]>VI_=S9K?75Z9C8V6&IH6DE)6#9J
-M;75[;T\V6&%P;'):/TEI:4L^6FM@8%MA/VA4*2U@,B5M669Q26.#:UDV/%MZ
-M<V8\25@V/WIN6V%H<&]H6%9@6$UJ?7!486DG+VA;7G-;3W*'@G!, 6@!:@#^
-M:X)\:F%::GIR:"<V=$0;-F-:<VYH/R5:>VMK9R4V5#]6&Q@P7T(M6%IK:T0M
-M)5:2BH)H6$D_+39P<#EHBF@5/FI<;U@^52 @1%@Y6')Z>W)B;&)@7V-:-BU)
-M83])-@X5,$5,4&1U=7<I#B(^5#\G)UIZ=75F:VMN>FM>.R E_CPV6W$\)5A-
-M:$E$/"5+@W]/.4UB<& G<G-C<G-%;'5R;V@V+3EJ;4Q>24EF8UQ0:F<^)3Y/
-M;&QC238V379W34UJ6G!@8U5B5C8M340R:$M%>W%L@W):24D^6G5Z<G%@1#]F
-M9D]A8W-S;&E68V Y4&IH7EA8539@345R<F)F=8*"8P)- /Y%:WIU:UM89()O
-M)2UQ:3LE245K:FM@,E9R8EMK24EA3TD^1#XY-AU)6EAF*2!9:GV%DGI)-B 8
-M)7)W6%N*=RD_84QK;5AA/#Q86#8P7'J*>GIW:W)W;V)+/"U%25A5.3(V*2(^
-M1%IN@V$T("5821L817=N:EY/:&9U;VE4.S;^23YA>F@[-DEW8#L@%2UO>UD@
-M+6!S:#]H:V)J:V%J7U!G5C0E'5,^/DD^-F!H5C1-23 \1%IS<F)653Y%:X-K
-M5F!%:VM/=6I5.R5%,#]Z2S]R>G)]<V-A.QLE:H)]@F-F;VM:7F%C<W5K8T1B
-M<$Q%6UE>/RT_-RTY:W!5.T]F@GR# 5L!.0#^+5AN>FUK8D]M<#\M8H!P/CY)
-M7UI9639-<V]<8DQC=$Q$8FM9+3PM36)621(837)F=9**9RD.#A50@G)B=8!A
-M8ULO3VIK8SE8;& \&S!S@VYV>FQR>GIR:44E+41@<7!A/RTI-CD_67IR@%4R
-M6&9;1%EZ<FI9-EAO9&9O7E]+_E@Y37ER225$>V@R%1@M86\\#AL^:W)W>W)J
-M8EYA:DDP:UA85#L[)2U$.S9-:U]%63\G,$E/;'-@-TE)2V.#@FIC86Y[6W)K
-M6D0@23(V=6);:6!J>GUQ:44K)4UR>G)C;'-C6V)I;'9U;6,G1')?6F%6338E
-M-S8K+4]Z=5HY8H)0>@%H 38 M1L_<&YF=7IB4& M%3!J@%])5$5%5CX^16)R
-M<E@P37),6&EZ9SLV/F)O5BD5($1R65IZ?7<T PZY-G)Q<GIK8G-C/CE:@&@M
-M3'=B1!@517-R64];<G5U@GA4)3(_86-O8%A$1$M%24QC9H9R2T]K<&IB W*R
-M838P:FA/:W-K85@V1&MI11LM85A5/#1);V<I#A4R36)ZB7)J8EE>8DLP8$1J
-M=V!A1#8#/]588V=)2U0V-#9%6%!)&R4M/TQQ@FU<;&Y]<H!:860V83X_4&MG
-M=UQ,>FYK:6%$8&EJ;F-><FM;24]A9W)U9F%)8&)-36M@6TLV7EY$+3EJ@VHE
-M6DEB 6,!+0#^(#!>:$UN@FIB6" .*4EN9$UH138^)TE81%QR8C9)8EIH:W)F
-M84DY8G)C,B Y37IF86EN<V8P#@XM:VUU@G)9:FI8-F%]:T1$@&])'14E3'IL
-M65E;:V9V=TD;("=@6FQ@6$DV1%EP1#Y,@X-I16MZ<FMK9G=I539C8TMC>WIR
-M_FQ@6&MP9C0I)2=8:4EC>FD@"1@I/T1F?7I;34U@3UA:245G;TQ9<%X_23]:
-M:6!664D_7DE88%]$+3(I-C9$;FI:<W)F=8!/86)6/EA61$E@<6A624E$8%IJ
-M359B6C\M6&AJ:$U%;WIJ=VE8:%])26):6EE):'!8,B58>G<R6();:P%/ 38
-M_C]+8&Y;3WUR46 \%2U69FI;;F [(!4W7S]);' _1$5C;VI;4&-@6%IJ;$\V
-M1$ES<V):;'IJ9BL2+6)Z;7EZ:VIO/R)@>EQ>,')J5C)!/"=J<F]H6EM19V(M
-M(" I/DQQ=VE)-BT^?%\E)7*#<CE->G5R:FV"<%XP6%A+:W)M??Z)<EEB>WMF
-M6!@8+4]A<'YP-BDM-EA@8%!O:UA%6CE/;(-R6D5B:&MH64E,6EM)35HV+5IK
-M<&)B6#!$6%Y56&)98(" 6VIR16]J64E95F!-1&)Z:4E/1$U$<H!J65@V(#Y8
-M8F]6.6ER8W)Z8EE:23E)/S=89FAR6"48/'-]83Z"3( !6P$V /XY.5EN>VIZ
-M<F)C6C8W/D5R?79K6"LM6&)626IP23<G-E!L6$588G!O6DU-6FI::FI%-D]Z
-M>FI5)3(Y:G]B8GIF;T0I/VIB5C]K>F$M1%8V8'-Z;6)-:')8*2]8;CLP8()Z
-M8$D\.7)C)0Y,=6M)37IZ<F9M@G-K/R4M8'-K6WK^DG=/8WJ"=6Y!&#(M2WIR
-M34E-6&!@8FM@-GIJ36$M-F-Z8TU88F)M>G-Z<&!8/DUF-A@V:WIR8U\^.6!X
-M<'1@-BUU@G-K<&)R=V):23E6<$DT:G)R:E@M)VJ)@F)654$V/CEC<$U(:UMF
-M>FI6:&@[+4DE16%R>F@E#AUB;GLI@C!R 6,!/P#^*1L^;WR"@GIF:UMA64E%
-M8G6&=4\G/FMS:W!R<F-+/!LV:4TV2W!K;G-))U9Z:E9;1"4V<GU:5"TV6&J
-M8EMN3UMB7DEK<EE/<GIK7B<P-D]Z@FY@16IZ:"DE19!6&RUR@DPY86A[:24.
-M-G!,.5IZ>W)C7&YL<F$@%3EC:T]J_HJ"6%9J@X-U<$M?7DEH:UA88&MK:&EF
-M:EAR=6MJ.R)%9U9;8FMJ:VMN?8)W:3\_8EX;-F!K=7=L83]/:DU%)3(I375[
-M;V)R@GIN<EXM,&AH-D59;8=6&Q4^@HIZ8F%?8#8B/EIC-%I@:')J66IF23)I
-M/"U)<GUP-!@;/EIN/X(_:P%K 58 _B4K66M]>WUM:&!$6EAC8FERAGU-("U;
-M=6YZ@H)S:F R)6TY%2UA35""9R55=W!%65@\27![;UXR)3EB@G!J9F)07FM)
-M6G5C8GIN8W<V/#(Y@'IC-C9:9G=5)3^";B ;28)P23]BBH%>(!L_)1U@>G=R
-M:V]U=G5F-"LM3VE%1/YZBFDP17Q[=G)I3&)R26%/6UIN<G)I6VIR<WMN8U4;
-M+5E/<GIC8UQ;:WN#?7!86&IF+2U836)X:6)-6FM@)1LV6%I<:F-6:GIR<GIJ
-M8E]B:T0I)4>"5B .&UEZ;6IH47=A/D1):%A63%!B8VEJ3UA8:V$E,&-U<FE5
-M/$UP>UF"87(!:@%$ .X@/VA;@G5]9EQ;3#XV3VE99GUZ6B(5.6)?;H.&@FM-
-M1#)H1!LM/D59>G<V)V!C,$M?65IS=6I:12TE+V9]<FUK3V)B8%IK<'=S7&MU
-M1%Y$,G*":"4;+3)J:5E);'-F)2EK;4D@.8*->EXI&Q45-@-:_F)K>G5Z<DM$
-M24MA65AQ@G V/F-F=6)@)T5P/TE$33]B:W)H:&-R>WUS8S\8&"TP8G)%34U/
-M8W)Z>W=J:G=>,CQ+.45P:UM@:7)P63]/>'-R:F)-7V]J:FM09']Z<E@V-DQN
-M8D(I("U@3UEM1&-P6U@_67=I239)6&!@,"=A:8]I-"E/8V-K:%E$8W9K<'H!
-M<@%) *0I/VM/;GJ"<F-)/TP^,&-B:FYN3U @.SXV3WJ"AFM%,#]Z;S\#-LTW
-M:GIR1$DY-EAH6F-R<G=N63\M+6-N;F)C6VA:8W!J:G5K3UIH/FEX6F]Z5A@.
-M&#QC:VQ@6VIW6#9@:C82)V*&C8(\(!TI,CY$/S\T:P-Z_E@P85E)26ER;7IC
-M:6E(9G-9-EEI84U$-BU/8FY%6V]Z=G5U<C88#A@V8W-6/T1::V]B36IW<G!$
-M/U]I-C9<:F)H:V)K=VA18W6$>F(_5FIB65],1W&">GIO:5MF:VA>/"U$.415
-M(C]P8E@V3WQZ<%A98EI@/S)8:W-5*2TY;8EL338;+69P=W0!<@%@ /XM)V)C
-M6FMU?(-K/EA6'3E,<X)N6V%)5DDI-F=UBG)),C9U>F])+1L2/FZ"?U0=/$UB
-M7G)K9GIZ<FQ+-F)N<DQ$-FE@1&AN@GI064DM)VF(;G6":308&TMK;G)-14QR
-M:%9O=VXT&R=FA85I55]>14]>141$6VYZ@&(E3%I%27#^<E%J8FIX145R:V)K
-M=V]H338E26]A.3!H<FMJ8F)5(!4;26MZ:UD_16N!62DY7')H/S]9=UDV-EY%
-M34DM1&QR82M:?8)K*3]J:%9)245$:GI\@GIK:FIR=$LV-DE@5!LE6%D^66-\
-M=6MB66]@6F%@:7)[:40@&V!P/Q4."2U;@D5' 7(!8@#^+41O<EE,6VV*<D5)
-M8#8V.6F">G=S<&I@6%5;9GU[83X^4'I\<%0I&"5BA7UH+39,66-L=VQO<75Z
-M8EAH9F-@/R!%:#E%6H*"1#X\& E$>GI]@WIA)1@^8W)P/C!$<G=:3V)]@%XV
-M17=U;&N 8EE>7CM):&]F:WIR2V!%+3YW_H%N8E%:=V-86GIZ<G]R<F M&#=H
-M24@;/FII:$U%:6,@)6AZ?6L_-C):@F]$-D]O8$E))U]L/"T[254M&!TY:W E
-M-F9_<BTG36]A24E$(DAQ;8)Y;FIJ=WMP5"T_;VT_-DU@-C]C=75B14AC2$UI
-M6G)B8UI>-"!-;U42#A@M38(^)P%, 40 _BD^66MO8G)R>G)H5DU>7#!$@7UN
-M<G5R35MW<&)R=6I:1#]:9&1X83(E36U39VE)8%QK7&MS<G)N;EI0:EI)85XE
-M-FA@15A[@F@V&R K,&)K>H)Z8S(@)3!@:V8V-FAR9CE$>GV :4]:8G)Z@DTY
-M8$DE&T5R<F9N9FMP11LE1/Y[AG=@6FMH242 @WJ&>G5P1"T_7#M4-BU-:&MA
-M2UIC.2UB@GUK,ALE6()Z:%A;=W-B52 V8$DR+6%U53PM-UMQ7C98:F-),CD^
-M23X^238Y7UEJ;F]H8G)]@&<[-F!G/S9?;U0P:G5R6C ^6$1,7SEH36%%8FE+
-M<7M@*2DR25B"6& !:0%> /Y</S8P.3]R@G)K6TDY8V])+5EZ9EYF:#8Y=8)C
-M36]H6VEA6$4_@'(V-G!C)TAO26MR8UQC7FYR:UI)66-I2V)O0BD^5C9$>H1R
-M1!M862<Y36:"?7)C7D$@/EM@+2)$23\E-FMN<FL\&R=F@X-))UE)*0XE9W)R
-M<&!K>&8[.UGH9X)]<V-:8"4;8']K<GIZ@W)?8$D_6FU?36-O8V%P61T;27)V
-M:3P5%3]W>FI816)P6FEF-EM6/" Y;UM%25AA<6@^-C!::&!4+39%.SE86&!B
-M9FI@7EEM>H)B84E65BTM6'9G/G&">F(#/HE)8V V5F-?:T<#8HEA6$]@35IB
-M7VL!> & /YW6TDR$AM@>FQC8#8E6W)P246 :$U08" ;6H)K3U9,37!_<$U/
-M?W<^-FAB25A@16-K8EI;6VYZ<FI)/DQI8&E[:#LG/BTM<(J"22)-624M26%R
-M=7-R:V$_26%F-BT_/RD5+6)Z>V\M#@XP8GM))4E<,A4@6&ER=V-C:VE)3VGV
-M:W5V?'!?52 .+6)H8W-Z>H)R8TD_3VIZ7VMH36%K82D@6')R:UDR&S9J>FUA
-M6&%;15ES65MH53L\340P+3YC<&M?/S9>8H!O,BDV/TE665IB<G%H6EEB9'EB
-M3$1)1#(M16=,6'*"@FM6+24V8FI:6F):<F-:6@-BAVAF7$]I:V(!9@%U /Y[
-M<FE$"14V6F)<6CPM26MR<F*"<$Q:8"L2+6-W:& V.5N#>SDV:H!K36!(8&1,
-M8')<:FMC7F9Z<VI$(#EA.6)Z<F-)-B 83(^*<%E+84D_36-H7')Z<F=;66)K
-M6$M96#8I*45R?7<_(" M1&M>+3!>1"DO15M;>G)C8DE%6FOM8F)F>WAK7B 5
-M(%EO8G)R:6!-8%M86FIR:G):/DE18$1):VYK<4]$*39K>G%B8VYA/UAF:5YK
-M6DM88$DV(" _5F-R6V!H36IJ23(V24U624E-9W%Q<FAB6EIR9SDV23PV/TDV
-M36IZ?7)J/R V5@-:D&)B:FI-6F),3']W:$588VH!8@%F /YR<FM>(!@R/D5:
-M6CXM6&-B:W*#>F%::%DI&#EO7%@[/TUK<BT;-F)R:F ^5F Y6H)J<VQF:T1C
-M;&$^&S]8)4QD;7)I22 .+7EU=G$Y17-P8F)G36)N<FYP;&-C6F%;:'!>,#9B
-M;G)H2UA9:&QH22TR.SQ)6UM,9G5O6$4^6'"\7T5@@()V9U@T,EER:W5K;&A@
-M6EA-3VAM8V-:-BTM-C)6@&)>=T0M("5@<FYI6F%A6%MC8W)Z8#8Y:6$_ R"7
-M,%I@1&=K8"T8&#M;;G)L85A)245B<$D#/Z=%66A;6%AA85QZ<$]$:W5;3&-8
-M6"TI/EIC7T1$8$PV)UI><&E64&T!<@%B *]Q8EIB.Q@[6#!$22TE7FE/3'N"
-M>FI::W))("UO6C8^6&!03#LR)2]-6DUA8VE:3 1R_EQK36-K8%4R-EXM8%MB
-M:FQ)& XB6DU;51T_>GQF6FU@8%QB<'A[8U])86%B>W)</TE-8V=H<F-R<FIB
-M52 5+6AI:%@_<FI+63\P;V@_37M]?7IR7D5+241B:UY::V8V)2E)<F)K:%0[
-M*14@17IF9HA@*Q@@6GI[<%M%245:<<U(:GIO+1L^6$LM*2LG640P6G)A-Q@8
-M+6%]=FYP:5Y)-D5R<$LV/DDV-CX_6GAX8VMK7BTY;GMP8UE)/#1$86=8+3EB
-M240V+1U-?V)-9@&" 68 IH%H4&%$-DE8.3LR&"!)6CDG<(I\8EAR>FDV.6A:
-M+39C=V8^,$D[ R74+6%J<'MI36)N>W)L6FIZ:V _/UE)8&-K:VI)& DR7BTM
-M( D_<FU6.6)C8EPY:7=Z:UE5:7!P:EQZ:$0[2UIC>F9>>FIN<#D.)6)O:%D_
-M:V P22T2 TG^66EK=G)[=V)A/QLV36!?67<\(!@B8F)R>FA>*0X@26QC:GIO
-M-B V:7N">FA:23\Y6V-A=W-5-#E8638V539+,A)%:V-%,!TE16MR8EA@8F)R
-M<6UW8S8V52T5("4P:GUZ=6YW/AM,BHI[<%I865IN<F ^/F!-87!+("5B:#8Y
-M 7L!=@#)@G)B/UA;:&MI62T8-#E;5B)@B8IO6G*(=F!:6UDR+6F#>F _-DDT
-M'0X;24Q:>H5:/UZ#>G)B:WIU:TQ%541836!R>FA>,C]H)0,)_B)B?V Y7V)H
-M:$E89G)?,$EI8&-O4&]O/S1+6F^#:%MR:W)K.Q@@1&-I3UYC6# V(!@E&R(^
-M8VQH3W6)>UE$(!4M;FE;8EPG#@Y636=J4&M5&"!88%I-<F,M)55R<G5Z>W!A
-M84E%:G![B&]@6&!?-BU<6E@8#B5@8FEA1#0G1(]J34U@9FIR;VAN<UE>63D#
-M&*(I1&)B7&MS5!4G9&UV>W)K;VMN=FIB6D5$38!K5#)$7R(M 6(!;0#):V-R
-M7S]->GQS8EA$6#!$;"(P;8)Z8&-]9D5K>E@M($F"<G)P63XR#@D@0B=);H6*
-M:W)]>F9B;'IF>GI@,"=;4QU->F!R;H!H( ,5_B V:X!C8$5%;G!%8'%8,DEC
-M6$QWB'IK1" M/V-[8#E::WIO/"D^6$589&-P6F!85#(T*2D2,&-,/DV"?VE5
-M( XE<(5P6V!>.Q@M66--,%A>&Q@\66)@=TLE(#MC8V)R>VM><FDP8F)R@GIR
-M9EIM,C9F85E$1#Q$6G)K:54E+9M-,#YB8VUR9F)8:VMP;$DG%0XT8$TY.5IB
-M530#+99%=W9N:6M><FY_<D14.VMW6V%R:T0V 4D!6P#^33Y'8SXY<G)C<&)@
-M:$U5:#]$6V):6WN"8SE@>EHV-DER;FYJ:50K"14G+15)6V: =85]<69F>W)9
-M:8)W/B!62"5):DAC6WIP,C \.RLE37MB63\^9F\^6'!H1%E@8VAF@X):/CDE
-M.UAF6"TM17)S52 Y;T4_:FYZ36-P3SX__C\[*RU).S(\;FUP62<8+6:#=UI;
-M6&!!%3Y925EA:%4\1$UJ8F Y6#PT.45:<G-B37J 6$]:6EQ;;U\_6"TG6FMH
-M8%A>7DQS8W-4&Q@M239-:FYN8F958VAR<VDV(!(T;%L^6F-98V-5*Q@;5G)L
-M4&)L:VU]<DQC6$UJ6EQZ=H)I10$P 5L _EXM&UAB6W!-,&!J8EI,;')-3'I-
-M)S9K=6-$:')B6%E<<GIJ8EIF/!@G," .*38^35N(>F)<:W)R;VYR:V!83UMH
-M8FIB<&IJ7&T_/U@R($V :DU:36MI.S]@=5@V,$UP2')[-B(V)2U)8$DT+55L
-M@6]$27)9+4ELBD5%;5HV1?Y-3%Y$/TE$.6](:&!$1#YJ@X)L8F)R;#Q+6$1-
-M6UIO:FE::&@V&TE>+2 V6')P6SEF@VM@7&A%/UAH65A",C]C=T@Y3W M8F-O
-M51@2*5HM-F)Y;UYK3TU9:7-[6#0G-&%;.6J!;'-R9CP@%39R<UI<<G5[?6([
-M644[6UMC9G6"=7,!8 %9 /Y8.Q)$>F9B/C]$8&!,16-R3"EZ83(W26-/2W!K
-M8FIK:F]Z;6I/:$D8&" 8%2 V1!LM>WI96G!/9GQU63]B>UA-<UI::G*$>EIJ
-M53Y:/!LP<FIJ9TQ:8SXE.7=P/BU$8V. @U4I+3(B.6\^(!LY:X!B8GAZ9RTE
-M285?.6))*4G^6T=B9E5964]P6$P^1&A836YZ=VMJ<W=H35M)56!%8WIZ9F9I
-M-BE)6$0R.UAW8V%H<GMN<FIJ6$U:8FQC8#X_66I8-DE924]C6D4T("U:-B5%
-M@GIB8E5$.4]N@W!+23E8239BC8.#@G-A3R4V:W)G8FY[:X-G16D_/V)K9EY<
-M@E%R 7(!30#^/QL.+7)R6D1@669@2S9$<F])>FI%24E9-C!<:F-R:UIJ>GIK
-M8VU9/#)$1#0T25P2(&IW2&)]6F)Z<F@^068^1']H/TU9;8*";UQ)540K*6!:
-M9F]@:6A4,#):8E5886!>@HER/B4\*25C10X.%4E-+41Z>F<M%2=J:UIO824V
-M_F!@65I-24U+:G=@23EC=TDR/VMR9EYN=TA-63YA26%N@G!:63]A?4E+7C]H
-M=V)@9G*#>G: <V!@7TQF<G!?66%J85A+6%E96TDV-"4_8#8;+6I]<F)%6#LP
-M6GIZ:T\P23LE18R,AGUS8UHT,EA<9F)<:%9U9S]B.3E6=VIL:8)%6@%J 5L
-MZE@I&"5B7&)-66-Q;'!--EJ"@WUK23\V23DI.6)C<W-K:GJ#8V)P8UE@:F]I
-M7VI6#B5?<DM'<F-C:FUS=UM8&RUW>F):7V)LC'I:6%A)1$EC<&]K8G!P8%59
-M9D1@:G);3'J2BF\\1$0P6C0##OX5%0XV>GIB1#1$:%E88W%)/D]I5EIO6$5)
-M1VYR6#]:>F\I%2U96#D_=E8^6"TV3VQJ>GIM/REB?TT_:3Y$<F)-6VZ#<F-Z
-M@&=-1"E,<WIK8&%;:6-@6UA@6$D\+2U)6C8E*4QJ@VM%/C8@,&MV;FD_1"D@
-M+8*-A8-S8UI864^36FIF35IF:FIC9CX=)6MK<W=-3 )K *EB7C(R6#=913E8
-M6V!R<S\G8HI];EM/1#]$.S=A;FQR;69Z>F)%6DE%<@."GVMR;1L_3&)I.5@Y
-M3V!B=8-S7@D816YW8V-H3WIS14P#6/Y@67)R7UER<F);:6@V7WJ":4UZDI)Z
-M645927 V,#D@#@D.-H*":DE+<8-96&-J;V](83DY>'!%16A9:VEH:FUZ5"<@
-M+5I3/F)-154M%2U,6G)S;S8I8FDM,'%8+4D^-%]F<EM)46UW8S\E.6QZ>FM@
-M8%]O<&!88UDV-C(V8&*R/D1$-C)J8U@R,BLI369N<G!)$A(I;85U?7Y@36MQ
-M2$U>8UI8:G5F@G5<+1LP47IS33D!:P%R (1U<FA$ UK^545$&RU:<F$B.7I\
-M;G=P8U4M)2 ^;UI@9F:#9FA8+14E67IZ?7)D<B4M/UAB23LE)3M$6X)N7SDI
-M-G=N<EE)650E%4UK8F%K8VMC:UER6DD^85DR376%<EYNBH9U8%A827=:6GA5
-M(!4.*7!Z8T5)<H9H,#)@9GIK9RDE3%\G^2!W1#EGB8I]>W!F-C9;:T5H8EI@
-M-BLT+3Y68F \26!@)25B9BTG1$]F>H!R8$UB<G!9/$MB;7MR:EMA8F)C6&MA
-M,A@@-FAK8%MH2S(^6V<R-#PV/UA)16MN01T;3VM1>XIC16:">FMC8S P<GID
-M<F9I850V7V]:25@!8P%V +)Z>W=H9FI985@M$B V26-$,&)M<GIN<& T%3))
-M6$U)67)U35A8%0X5,%A>9EH_7V8^-@-:_DDI%24M27IR6$L_6')Z:F ^13X8
-M#BU?4%!J9GAR<7=O:%XV-CPI-EMU;F-D?8)R:VMI16MM<G)Q64$P+6!F6TE;
-M=WUW239;8G5K;%A635@M(%PV&SEZA7Q]>G=886QJ/V)O4&-%25LV24DW/S8V
-M3VE5-EA-+25):6YVB8)P3,M-8VA)/DUI:G=R8T]W:4]C:7IL11@5+6!B:')P
-M<%8^3&I/568\+3\W+3EL=U4[3TU9>HIP35QVA7UZ;#PE;()U=7-O8DE):G!)
-M/DT!7 %R /Y9=VIF>FI;:& M("D@-F ^)3Y,<WUN<F R%3Y@/DE826MJ2454
-M%0X@+4598F)6175S25AI8UE)-C9$6'=W6TE)6FYU:F-823\5"1@_2S8W6GI<
-M8WMF:W=>-D0\)4QJ1UIJ;6)><G)H36MU=V-P<%A>7V!-6SY/>GUR<%A;;'K^
-M<F9R<FE:53)551LE6G5T;F9Z;&MR:D0W=W)C8VM86&!8-BTV+2U-:5EA-BU5
-M86IB4'J%>U8^65A)56%B66I_8TUP:V)B:X*#21@.+5MC6V%KA7Y]@V9-24PV
-M)3<V*25/>WA:.2]B@WYU6EIJ<(9];6E)9W5M;7UZ63)I>FHV@C9? 6(!9P#^
-M17!<2')K<&MC5CY)-DEC6DD^+6-[;7!-*2!)9#X_7EIL3TE)8#\R4%Q;86)J
-M=TURBF)'<&YC:%9)6$QO=V)824]R=FM;:6%)*0D.+44@&U9J/UJ!:6)R6#!;
-M:#9$6D1$65L^-&MJ8&-[<6):;'!,6F-@8%L[6'5[8')C15J!_G)13&U[:U@;
-M-E4[-DEH:FMC<VMD=6\^'5]R8VIS6EIR:TDE*3(;-E@_3S(V6X%_:UIF@X!-
-M-DE8/TU@838R:EM$<&]B6V-Z>E@E'3Q@8%I96WN&AXIW8V!;2S9>7D0M.6Z#
-M:B4;,GIR:V-H6UQ]?5QB6'=F:VY]>DPK8WEG+8(G60%J 5\ _DUN<UI:8W)N
-M;G=I359H:VMJ5B4Y:V-K6T0V5F]<26%I<FI@6GIP3$EO7&-:87(^48)R2&IL
-M8VMF8G!:67IO6EA;=GIK:&IP8EXP&" I("!)8RTP=UA68U@M26IP8VAH8%E8
-M/C!;8T]C?6!%36)K8DE)/UIJ3%IM>6-B8#E9>_YK.2E%<G]F,C8^14DV.5M9
-M8W=B8G)J8#8V1$Q:8F-K=7)O53(I(#QF138E-C]H@()B6GJ"5ATP7&!).5E5
-M/UA5+7)R6DU1;61O83P^7T]-/CE-=8V*<EM96EE):'!8,B58>G<R&"EB3#E+
-M6F!;<H-Z6T58-V)S;G5J36)D83:"+4T!6@%$ /XV9GUN.6!R:U![<E@V6FN
-M?6,V,&-K9F%,/TEB;VMB<FMM<EIR?6(P3TU88&MK-B=F<F!B8UYR>F)W6#!B
-M:%E:6FYU9FMK;GIK7CL@)3PV6W$\)5A)6&%C24EKBGIK>G]N:TDE2&-:8G5I
-M/SE,:FI6/RE$<EM88G)O8U@Y6H#^:SLE+5E[<EMB7F!@.R<[-CEJ:UIH/V)P
-M1"U)245;=W5C=WQ@/C(G6V!$)3(M+5QZ8TU/<E8;(%9K:# V6$M@859Z<T5/
-M6FA$67-X85M8:%@T+5IZAGII/S=89FAR6"48/'-]84E5440E+3])3U!Z@EI5
-M-B4^7$=F>GAR5EA$@BUF 5@!'0#^+5IZ>C P4&I%6EQF)2TY>HIR63E08EE;
-M34L_1&)P7&=13W)B3VYR23\^/UER;UM)35QJ8$E(:G)N@&$V25M-5EIN:EY/
-M:&9U;VE4.S9)/F%Z:#LV6V-:8&!8:HAS3&*"@GII.S!89W)U:4DV,&!H:%4M
-M+V!;15MK:6);8W)Z_G)@/#Q/9W)J;FEI<F9$-B4E36QC24EP9SXV9EA$3VMS
-M8FYW3&%K,#EA6#]!("4^8&]I35E)(!4^=W=$+3 V6&-H<FD_26%825IM?7)R
-M87!C53=/:WUR:4DE16%R>F@E#AUB;GMZ>V-)/#9).6EI;'HY+3(R25I)16:"
-M@G=H-H(=6 %A 24 FEAK:FY@2UAJ8V]J:#LI)5EU>G)85F)B6T5- V#^8F)K
-M3UAJ<F)J;DU6224P:'IO<FM9:FI-/T1$7'MZ:6MB23E)<FI9-EAO9&9O7E]+
-M6#E->7)))4UB7T])37*(<# Y<WJ"@VDV.6:"=7=)+3)834U@6#XY345J:E9$
-M6FI_;75J84U86EMB<&-F=W=K1" 8*4]?1%A_<D0M8$DPXTLY8G)R8RD^=TDG
-M35@_53(T1#Y:<&)H5BL.+7" :38E-#EB<&)?/S]824]C;FUQ<FEC8T]+66-N
-M8EQI/"U)<GUP-!@;/EIN?8IX8#]+/R);<VIK)0XM+4507SEB@H5]<C\@/P%J
-M 6$ \X)]:EEH8$UJ9G5Z:V!)56!967IJ:&-P8#8M8G)U9F)R:$E9;G)K:F)A
-M-A451')N=7I:8G> <$D\/W)U=7)D23\_<G)A-C!J:$]K<VMA6#9$:VE%&V)H
-M8%@_.5QZ<F!+8&)Z@VL_)3]U<GEH/BU8/RT_6TD#+==B@"TG7V!-3X!R6TUK
-M=V$Y:&]J<GIW6T0@'2U66FM_=FE8:44V53(V=W]9)QM@;4186T5F1$EH35!L
-M;VYB1"LT3'!P1"4T/%!W;FI$/TD_15IK:G)[>F,#6ZYI8FM836MA)3!C=7)I
-M53Q-<'N%C7AC145>/%MJ2"T.#CX\/SDM,&*"A7%R8U4_ 3D!:P#^=8)W6F-6
-M-V)U;FYF;U]-8VQ/56IO6F-B-AM$:FUK669Q5E]P:VA/:G [#@XE245G=TQ)
-M9H:(:%8Y:'IR>G(V/UYF=VE5-F-C2V-[>G)L8%AK<&8T1$U-26!@3&M9<GQG
-M36MK9&E:/TQF=75J6%M82UEH840E$CEJ/R Y1!LG_F]R.3!?@W _/UMB=7IZ
-M:F$T&" V36N <FMC:TDV/"DE:HIO.Q@P8&E]:3EJ;VEP6$]:6H)K13<V1&AW
-M82DM14ES>GII8TE$,"]65EQVBG)C:VMR;FI836EI-"E/8V-K:%E$8W:-DH!O
-M33E-6&-0.3D=#CY@=38)%3E[A6YB38)).P$= 3\ BVIU<F-@14E:=75Z W+^
-M1%AP:2(Y8TE9:UH[6%EJ?V)J<E9'6VIP145K9RD=.SLE/U\G-FIZ>FD^&T5K
-M6W)M/C8_;8)P7C!86$MK<FU]B7)98GM[9DDY+25);UIP8FV(>F-K6C]R>FDV
-M/TUR@V]A8%MA8V]@/" M,F)$.3PK+5MW+1@P<G5>,$E:<GIZ\G)R52 @&RU6
-M:VYM<W!9/SP;&T>%>EHT)2U);G V1&UO8#E)5B]R:UDT&RU$8F]5)2TG8G)U
-M?7I@638@+3(V:XV#8F9N<FYZ8V%K<U4I+3EM;$TV&RUFAI*-@VH_-EIS84EA
-M00X;.6I<(!L_<H-U9S8E.P%4 4D WF)K3V=),&EK9G)Z?7UF85MR>R5!21TY
-M;6MH3T1/>GIY>FIF5FI[:3!;<DDM.4DR($DR&V%O6CXR($1@15IB340M;8)S
-M:S\E+6!S:UMZDG=/8WJ"=5H^( XE7U9-8&($<OYA.5MR:DDR(DAZ:V)K8DA:
-M<G=;3S\Y8& _3UXV7X!N1#9C<G M15EU<F):;FY$/#(K16!18W)O.2U>,CQB
-M?8)P/CD@)4UW23!?8CX;.6D_6V _-"<I-C9%9C08)4E?:GI]6V-8.RTE,F)U
-M@UQ9>W5N<T5;<GMI1" ;8' _%0Z>"2UL?'!]@F,V17AR34AF("4I,G1>&S!9
-M;75W21LV 6 !1P#^1%I$6E@M36IJ9&AUBEQC9G*"14A8*2)8:FA8.4UZ?'5]
-M@G);6X*(7UEC8F!68VXE/CP;.6I9/#(V9F))/DEB23]<;FQR82 5.6-K3VJ*
-M@EA6:H.#82TG%2UM/C!).2<^;WIP25A::F$_*39F8FMK:4U;<GIJ:FAC8UHB
-M,$0P_DUZ>F Y66MP-#]B=6MA6$]C8%9A-#9-24UH6"T8:5]I:VIR@T0R&Q@^
-M:EA6:&([&S9P6%A>-BT\1%4^.6%$)41$8&IR;EIP6S8I&S9@7&Y,2&YN:W M
-M.6)C6EXT($UO51()#B!,6T]4>G(Y+6M]6TUR1#8M-FAR62M86F9Z<H)/: %J
-M 4P _D187"]W8E]B:V)3>H9:/V)Z=58P/BD8275:/CE%>GM(4'MR8EIU@G)C
-M3V%B6&IR-DA$.SY9:F0I-G=R6TD^6#D_:W)S<F8T*RU/:45$>HII,$5\>U@;
-M*1@E9#X^6#P8&V!Z>G!H6F)I2V9@7EIA8FEJ<GMZ<G)Q@&M)&!@;&_XY<F(Y
-M,#E?<%A):7]R:VMI8D5-<EXI.5A8:$DE(')Z<FA,4(AW1"D;26A?:H-J23Q@
-M<FIQ83\\.T]I23]-1!LM56AR<EHY:T\M&!4M341:15EL8V-P23]-845B:4MQ
-M>V @%2!5:5I8.6)R5#9C?6Q%:V$Y*5A6<G))6%E;<X2"=WH!>@%H /)'5DD;
-M<G5B65YK7&9U<U9%:WUJ150E#C9R=SDE,&M_23!B8F-R=7IR:DU-14EC8S9:
-M:&EI3V)W6#!J:UA%23XV/V)R=75P2T1)2V%96'&"<#8^8V9)*2 8*58V:6I)
-M("UG=7IN8VEA8#9@:F!,23E)66T#>OYM<H6"8S(=#A@_:V)$/CDY7V);9GIK
-M67&(=UI;:G!>2TE)84D@#FF$@G))-VN*:#LM26!@9GIJ3%MP>FZ!<TD[/T5I
-M2S!+/RLM6&EW@$U+84LT("M$2SDV.6!N:F-R:4]>84E:<&9Z?6@\-%B#>V-C
-M7E%R9SE1<G=;44TY)SZ+.4QH6&)H3%Z#>GH!@@%R /YB8$DE6FIJ6EAK<F)9
-M:&))6X)R:FA$&QM:>E\R&SEB/BU88&IM>G5F=7))16EP6S9$<FUW5C=K8V-R
-M:DD^/S995D5F<GIZ6#!A64E):7)M>F-I:4@_9FLV-E@V8&!)+45R>H)G26-J
-M8SY$;TTM25XM+45N=6Y9;GB*<U@K("#^5G=B:&);65A-6V=K8DQF@H)U<G)F
-M9F)?6&-5& Y-@HIU7BU)@F\Y,C9)7W=R8$QJ<VYF:7)A-CPM6%@E,BTV7F8V
-M6GIP<FI9/C]>:6E>-C]C8D0Y=7=)6%I)6%IF@GUN6S9/BGM1;&M16V)>25MR
-M:U@_3$M97E8_.6N"6S]B@F-; 6L!<@#^<G)H6FAJ8V9R<G5F6%A-.6.'9EQ0
-M:#(@.6)17"4R/B451&IB47IZ8FQJ3$EP<&I$,F)N=U\^33]B<GIB6%A%:6-)
-M6VYZ@&(E3%I%27!R46IB:GA%*6* :#X_24U)/E1H<FUR5CQB<G)B35I$&RU8
-M1#8P6G%B3&!NB7MI238M_C]H8V-H359:-DAK<F%97FY]=6Z%>V9B6UM9/!@.
-M-GI]:FE83X)R138E.59J:U]6:FMC;UA9:$E$-EA@.RDR.TE?+39H;UMN:V!9
-M8VMR:5E)8$\;&V)R2$DW+3E%6FUP:U _17U[2&-R:V!<:&EH<G!-8#8Y;7)H
-M(B5CBG59/H)$/@$P 6, VW)Z:F)K<F-B;G)R:V!)+14Y>F)H8F)).S]-3VE)
-M/CPI(#9O:$5R@H)U:$E):VIJ:39$<H9R:V@P25YJ:V-82UMB:&]F:WIR2V!%
-M+3YW@6YB45IW8S1A>H!J34T#28M8>GIR8S8I6&IR8P-8S40M+38V1&-C:EI:
-M8W5R:&!825Y:8&)K23 ^.RU$:FE866)Z:UQ]>F-@6$D_+2 5(FMZ;VM)*7*
-M:E\_/DU:6EA@8V-I<E9,<&E886Q@ S_"24U8/$E96%EH<FYW:F)J:W!A32T=
-M&TUR13LK*S=88F-C6S\_36Y\6$5O6DEC:&)G;G%97!L;26%(#A)%@GUR/BTE
-M 24!5@#^:VM)-FN(;TU86UA+66E>-B56>EXV/SP[.S8V;G=C7FY5-DU@:G)<
-M3%AS6"TW65MJ8!LM:FYB:E!)/T]K:V _/V!%<G)F;F9K<$4;)41[AG=@6FMH
-M9FMP7S\I+45B:E]).4E:<W)H8%A)24UC>VM:36IK4&E:8V):65A:8V-8_F)0
-M8()K1%!88SL@-C(Y8G!K65IF855+23\V/T0K&!M?<3])2%A0>FMC9F-8:&-A
-M8%@_+5IR:W!J:5D_8%M:6EMC>FEA34Q;9FIR;FQ%46]H23M$8V-S:54M04E)
-M1&EL:3\V36-P22=-/S!::VIK8TU::6$V16M8+6!]>GIP2X(V/ $K 3\ _G)L
-M63YG?7IL6DE%-C]K:388(F)N.UE@86%5)3YH141C;V=+36IZ8TU:>FDE+59A
-M:5@@)6N#BG=8*2U9=W)@24EH)6=R<G!@:WAF.SM99X)]<V-:8#E$:VDM#A@V
-M9G)C32U%64EB;7II23])8W5Z8F)J:DQI8EI/6F%)35IC;/YB23]J<F9O>')9
-M,BT\-C!R?6MJ9F-B6S\[/T]C1 X.-F-)/TM8369K:W)K8V-R:6-8,A@M3V-R
-M:V-/26MN8UYC9FYN:U@V+4QB:F!I/SYH:5@V/X"">WMI-CEI22=%:VE)/T^#
-M=V%9:5D_36-G:T4G36Q[8V9J6UEL>GV"<$2"/%D!20%A /YX8$]N<G5V?7)@
-M6$0V<WA)*2M)33!I:F9[=#Q$/RT_9VYS:UIR@VLY.69]/T1>:VMA,"E?@HV
-M51@@67)C:5E;:2!8:7)W8V-K:4E/:6MU=GQP7U5+/EIH/SE$25IC9F(I+38;
-M/FM]<UL_/V)]>EI,<FYC<GII145P83E)37KK@&,Y6F9>;7UZ:D<_52(;6G9R
-M<G-[>EL^2UM@:EDG#B!)23];:6%:9FYU<FMB9G)S;DDK&"5+;&-92UE\>F-/
-M6V)J;GIO/R4^6&)/144_86E%-D1ZAV]Z=ED^=W T/VE;15DY=7)86FMC:5 #
-M8)([&"U(?8!S=GIG8UIR>F,_.6 !6@%I /YW86)R=FYR=7)Z=TD;;W=@/F!A
-M-B568UMZ?W%C/QLE26MR9EMRAG V-EMR:UMJ<G)H1$1K@XZ#82M%7V)B:6-K
-M:S=%6UMZ<F-B245::V)B9GMX:UYI6&!S:W-K8$]L<V)91" .-G-V<F(Y/FA^
-M@DDP8WIS8V)T.R5H=TU/26G^A',_16->6VUZ6UM)3#=$8VYN=75]BF]%26-K
-M8UIN/!LR+3Q96VA@:7-F>H)K7&=R>VDY&!(\;&A86V%[@F,V5&%-8GM[8#))
-M65E$/$4_258I%2]Z?%MF<&-8>GMA66M/16M93TPY/F!:7U5-14EC*Q@E3WUM
-M;8)N8&!99ED\@BU6 3\!6@#^8F9R=79C:6-:7'I4$EE]6T5;<5E):VA(<GU]
-MB5DK%2E%:VIB=8-O1%I:4'!@6G!R:#\Y:H:&<D4W:6E/2')O<GI)6UM,9G5O
-M6$4^6'!?36)Z@G9G8V-K:F9R<F-)4&-$>W B#BUK<FYJ/BU,>H)-+41Z=UY:
-M9S8@16-'65AK_G)V:45,9FM:83),6$L_6FQJ;G5V=8)Z8UE;8V-8>F\M*1@E
-M/SE-37!R6FMU=6MF:X!R+0X.+5I:16MK=7I:/EEA2TU]?5II<G!I/#99:6A$
-M& X237-%25E%8'9N<VMH6UER@W Y-C!86UDE+3P^8UY!*REB:F)H=69?.4UP
-M6((M/P$R 3 _F%K?&YR:&QP:6MW7A@Y?W _27%I3&IM16I[<))Z5!LK+3E8
-M<7J#8D5/13]::$E-8VE9.6"#BF,V)UEK8$UB7&U\:&EH6#]R:DM9/S!O9TE8
-M>GI]>DQ(:V]B7&IS8S8P)WMU/!@M;'IU9DT[.6=Z1#9)8FMC:V]<545835MG
-M>OYN:W!:24QW;&%+6&->*3E>:V-N=7)]@F]A/EI;8'*#63LE*2DM/DEJ:V-C
-M9G)K<W)Z<RD.%1@V.RU;4%!K345C:6%9?75%:FYR:#8R6'J)51@5&TUS23 V
-M)59[<F-C<&MK;7V$638_65H_("4T15M0;V8T.6AK7FYQ6RTY<W&"1"T!-@$^
-M ,Q@;H)V;FQF>H!V@&,8&UAI-C!:@&]::$U:=U&&BG@\+2T;)6."B%I'6V%%
-M8&M),$5I83];>GYW7BU)8FAA6TQ?<F)O:%D_:V P22T2 TGB66EK=G)C6UYK
-M:$U0<G Y-S9R;FDM)5AZ@W-A3SE:>DP^54Q:;')F66$Y85I(:WIN<FM-/SEA
-M8W!J;VI,,B4Y;VMN<FY]BG)@-D5/37)U7EE)12LK/TM@6G)Q3UIR@WMQ<#P#
-M(,HO-RU8,")$24U:8W%R?79;:VIJ8"TE.76*<#PT,DUW:308&#YR;F!B;VIR
-M:FV&=$M8:6$V-#0K+4DY3'-5-DQB<7-L841+=X)N/ $; 38 _C=R>G-C34]]
-MAG9]<#PI.5]0)2]Z@&-C6V)H6'IZ=FA>-A@8/WJ"6C]0=%MW>V M,&%;-D5K
-M;GIX/S]):5I-23EB1&-I3UYC6# V+24I)24^8VQH3W5Z:U%B:%AI8CYA;VYF
-M:DDE/VN*@F-B3%YZ:EA)25YJ;G)>12)>8$QJ<OYF;7=;240V.6Q@:VI-52 ;
-M3&)B<VY\AW)6/S])16)U6VEC63P\65Y).7)W63]K@H9U7%98/RLR559-*1(I
-M-EE915IN?7MK<G)C6B .&TAZ=VEA84UR;%4@(#]B:VAC8F9W<W)U@%M:>W<^
-M/EE%-CX_26YX84E0>GIF6T]I<WV">V$!& $5 ,LM:FYK22<P=XI]?7MI7C9%
-M6"TG:FM@<&=01%EX8U8Y66XT(#]K<CDV.6AH@HIM*39F6C\E3UMR>$DV-F%)
-M.3L=-EA%6&1C<%I@340$-OXE.6-,/FUU>DU%6T]A33E@<GIJ:F$_.4EU@F99
-M8WN#<DTO.V%T>H-[6"T_6$UR;EI9<FI(22TR86)B3TUP)0XB+31J>G5]>EI;
-M85@V86M@:V-%239%83\;3&IH-DQR>'5;4&MF/"U/=4\M&!@W9E5%1%!U=FMR
-M<F)@,B K3V^Q:W)R;5M<:TU$/$E:66)H6UQK9V]K<DU%<H%86&QP6DEA:6I]
-M<3Y-<G)F:45;<FEZ:@$K 1T VD5;:FM$&"EK@G5]>V9H-CYI24EI341UB&D^
-M1VMN-!L^?V8_36IH/S8M/DAZAW(_2VEB12 M16.$<%4V13]57BTV,%9N<DUC
-M;T166T]%3&MB3')[359K3U@R+0-R_F%-35@^/VAC8FUK<G=B6'N*;DDE&S!B
-M?8:*:V%8141N>F<_6GI9.2T_5%MB6#EZ12L5%1M$;5Q;>F)>=V V8F!C:V))
-M5#\[65D@(DEI239;<G):36MP239%@$D=("E+;4]524QB<GIN<EY18%Y@:G!B
-M9G)Z8V%C.55@2U@^1*-66EEC3&)R:SDM8G-/8GN#:$5F@G)N<CY,8U]$8"TP
-M6V-W=@$M 30 _F9C8VM+("UK>G9P=VQ8*2]O<%II-B)BBGIN;UM8)2MHA7=A
-M8'!J9U4K-C]J<EQ%36]J6S(;&#E\A'<_,#=/838I+41:9CEC9V)J:V,V-EQB
-M26MR:UIB35@_27IZ@W!-85M%/V!8.6)F>GIH27**=5I$)1LY9'6&>EIA845B
-MAOYZ341J:54V2U1-8&D[<GAF.R Y25M$)V)B47-O-F)P:6)::6E/2V-L-B!8
-M:FE)3V)T345>;D\_6H)6%14M8%8P26%;8%QF;'M-.5!F9FQR:EQ::FMI8#9-
-M=6--/SE%/DE@/TUN:$D[.T@P4'V#<T5:=7)V>V$_6V _3"TE16.":FH!-P$_
-M /YK:W%@-B4M3VM[8TAJ61@53()S624;5G5V<H)_51(E:W5S6TUL<FMB83YO
-M;UY/655;>&$R&!4[8GB*:3]/;&E%-#Q68&-I6F)G:G)K3UA<8EMK6EA86TU8
-M-EAN=8AB-&-P6$E//B4P1'J :TE:@G5523Y86%%F;V=%37=6*WW^?')O6D5A
-M84U:3'-R24QK<V-$6F--6%]:8FQJ:B=:;GI).6MS8UYS=$4;3()R3$5::DE+
-M<&Y@65I]8!(.&#\[("5,:&-@8%YZ:T\[16-R>G5C7UIC6TL_.75[:UI+6EE+
-M34],:6-I9BT@($5J=GMS8UI(>GUW36-R<VE)25E>@FY[ 5H!8 #^:6-W<#XE
-M-EA-<G%,8D4=&#9R:DDI-EI<6U%UC6X8&#EB:6)C:VIC36DV7&I-8V8Y-EYI
-M,A4E6%!Z?7)C;'IJ<BT^:6]B>F--8VMK8UYB:G)I8SD_6VAB8C8Y16:#8#!B
-M<FML:$DR"1MJB7)).75J/S!A8EE@>W)C3T]J21M<_G5T>V)A:&,_64AN=U@G
-M369@6&-;,#!C:G)Z=U8R16)W22U-:VYC;&L\#C9U:CE%6%\P.7)C66QJ<V,T
-M%25)254T26)A1%AL;6YZ8DE-:H:";%M;8TTP+2)B@G)F6%IC:5MA66!A;&(M
-M("!)35MF>W183':"@&-RB'IB6&EI48)/8@%: 6H _EI;>WIO3V%A16-W7F@V
-M(" _<6M6-$EI3S8G67UX12 ;-D]:<G)>6D]O6%9H6%YS65Y:;S\8-FA:;U!<
-M=VYW:W4^-DUO3&YB141B<FIB7U!Z>F ^/W=O:VM8+1L_>' Y8G5D<G),,@D8
-M68)W6SEC8CXV6G!:37IR345K>G!)1.I<=7A,35!P7UI;:W5:-D5@6%IJ8S8V
-M3VMU?7=)-C];<EE)25IJ9FI-&S!)<V@Y6&-C53]C13!:<H-S<3PV6#M+86)B
-M6"4B3&MZ@G)I.4A]?6]/6&M:,BTV8WUZ:$0Y8G%L8V9L:G)B+2TT!#^2;GI;
-M8X)V=F-NA7<_/TUN<4DO 44!:@#^,#YR;6UJ>FLY6G=C33\I*3YC6E0M.69A
-M1"DY:F9T-" E+39K>UM$:W)R3&)P86MQ<&)R9RT_=W)C-C1K<VQR<F!86VE)
-M:V9-14QK:F)H169Z3"TM;V)B7F @&"5-8UAN:D]F@ELV&"!@>G=$/UI/,$UI
-M;&A::$PG'5J"<VM)_EER;E@V-F-J8VAR@G _7EI$36MO/BU/=W)N>U@M-EMR
-M4%EC8V)C8408+5MZ=UE:6V-Q8V,_("=0?8-\8U9:.3]S:UI9, X;7'I]@&,_
-M.4AB>EI98&%)+3E1:G)L)QM$>H%J:VQJ=6@_1%98,"TE16);9WMS9EYR?7))
-M6%M<=8)W6 $Y 6 _B4M1450;8!O.4UR;%M9/RTV1#\_+3YK=U@_27!B:UXR
-M("LV:H)I26MZ=5E@<VQC:VE-4&A/67. :T0M37)K:G)O<GI[8FIJ7U@Y6F%B
-M;TA(=38.&SEJ6%M;1&YF)25BBG(_:H5Z<#8M67I[8$5;8#8V1&)W<EXM%1@Y
-M:UIC6^QR;FMB53]-:VIB<GIZ26-C1$]B324E27-R:WMP.R!):4188V1K8F%I
-M/"E-<WMP:V%B:W-S63PI+6N">VA18DLY8V%%3S<.#C9PBH9J6UXP57IK:&-P
-M83LP24106AL.'6*#>FI<:G5<26%I:40#/Y$Y.7!R>EM(<WUF4')[8EQK;P%-
-M 5@ _D4V/#1)8F9R6&QN:V%@84MA24E4(!U%>&)),')_:VE5*RU)8WIZ>'M[
-M<$E-<VMI44U9,#!8;W9[<FA5-T]A1&)D>H6#<F9Q:F-/6"]%;V)B:U0P("!B
-M7UXV.7MB&Q4W=6]':&AU?4DM35QV@3E;:V-5+3=R@V,_1$196V!C:OYU:F);
-M8FM19FI:7G)]<G-C36QA'1@8-G%<4'IV4$EO=UA-86I<67)S8RU$9FYJ>X!R
-M8V9[<EA$15AN>UM/:&):8UI83S0@)R\Y=HEP<&D_3&M;:VM[@6D_24E+/A@.
-M&S]N<G)/8W9@26!K8F%A8VDR'45F=TU-<G)$076*@%N"/UH!8@%P /Y9-D4_
-M6F],66)Z;E!J<5MB>F)C9#0=-G=O339O@&YC:4E$/U!C<G6"<EA)36M[:U@_
-M53 E6&YV<FIK6EAA12=84&Z AGUN@'MN:V@[-EY9:G=C8402:UY)&RUC-@D.
-M'6IZ8W!$68A+/%M:<()93&Z"=U@R3'ER<&E)/CEA<&;^<$=B<5M<8V];1#]>
-M=89Z:S]F6 X5*S]J6D1K:UQ(>H)R8&]P.3)K<FI$,%AB6G:#>V-:>GIK85A8
-M7F(Y1&-J:F%6:VD^*418-DQK8VMO:6IA86Q1<H)Z:$UB:5@T-#)):%I:6U%N
-M<&%:6$1-6VN!9C(I8W(Y17IH-F&#@))W@C P 3\!:P#^/S958&ER9C]$=VM$
-M7&DM,'=\6U@V*TN#=U@Y<WI>6EIH<4E%:7)N?7-%63E(?7-P83X@&TEZ@W);
-M7T5;>& Y6&);=7A]9G9]?75R9SY)-&-R8F%$%6]@2QL_:$0G'1MBBGU[85B"
-M/S9A<'J#22<R>HIN845<<G5W6CLE1'):_F,O3(!S8V)K6D0R,&9\;FIB8UDK
-M*4EP:VE98$EK6W9U>FMZ>TDY8UM)-BU)6$US?7UR:FIB7&E>?&Q9.45-67)6
-M.6)022U9:V9-3$5C8UXV:&M6159)+T5K:FM;655)3VMP.3\_2&ML6UD_+2(P
-M<GMA-CE)*3!R22)BB&YT@X)C.P$E 6 _C\\7V-S<VE)8'QS:F)@)1A,B&%%
-M(!LY>H=@,&IR85I%6X%/.6MR<X>#8E\W27!F<&$I#@XM8GIZ8V!%8X)K3V-R
-M9E-<@EQB9GIU?'I90BU;<EIH8#9W6TP^8(" :R4)-GI]=G)B@UDP.6IZ:S8;
-M)5YZ:F(V27MZ<DU+16!J1?Y8.3EZ?7)B33E)52U-=6IC6UE-+2U%6V-O8TDM
-M8VMV>GIJ;GM:67)C-BDP,D0_8W)]@G9S:UA@47)R6#9$545R:$5-/CDM37)S
-M8T5$6TTP-EQP;%H_.39%<F]N6UM925A0=3XE-C9C:UI89BD.$CER=G%)/" M
-M:382.6IZ?8:"<E@!,@%@ /Y816E;:X%/.6*#=GMI6#8\6X-P-A@8-GN-;#]A
-M:%I,7V-K6#]K:F:*CW)I/V!A2'%A*148+4UJ:VMH.4U[<%A-:F9@375K8EQF
-M6X*"<%I);V],36A>8EL^86QN?'<\("U:>GIF8G=Q351L<V@M&"!)66-)&RUI
-M=FM-6&-R:DW^;3D=4&UR<$D@+5@M-FIN<UM@8#E>85I-7&A>+5AR;FV"9&9Z
-M8#EF<CXM,BTM.SE1>X9R<GIB8VEB8TDI67%/9W)L:TD_/SEB<FM-5F Y(#Y$
-M8UYB124_169U>F);639)6VMA-TMA<W=K7&D[&!4E6X.1;%88+6%9*SYCBHV*
-M@GML 4T!8@#^:5ML36:#2S9J@VY]<UA)6G=[<$DK*3]Z?6M;84U@16)J:DDT
-M8VA/>HUV:#E,1#!I8T0@(#]I<TU(<V9%8W=),$Q;<GIV=6YK6DUR<F]B9')G
-M.5A:8DU)(C]O<F9W3S9+36V#<F9M=TTY:7)H/"D8,C]-/QLE66-;84UK<FI-
-M_F98-%919W-I54M-+25B;GIL8EHY:V-?241@824Y8G)U@EY0;F,M16))2S8T
-M("D;)V)]<F)U<VMR:T4V)6B"4$UB@W)A86-<6G)R6F-R7C]?6&MC6S\@+3];
-MAH9R3&-)16]R8S]/:V)K;FMK83P8&T5ZDH)A)2UH<%E)8H.%AH)]@0%A 5L
-M_EM;<'-Z=TE9>H)N?'9@7EEJ<FY06#Q%8VM-6EHY6&%B9G!+'4UH.6:1@F M
-M+55)86MF-B V8W<V)5IO6UMP6# ^5FIZ>G)F:F)-8F)@6F)J21M)84QR<D0E
-M8GMR<DTV/RTO:G)<8')L8&A:8V9F1"U)85\\+4E)15A(:V9>8_UB6EEK8&-F
-M<W)T:#8@3VQ[=6M-.6ID3S8M.6$_-#!9?8)N:W!C2TE;36%+1"TI("!-8&MH
-M:FQS>FLM%25C>FI)17-R8V-J:EEH9FMK<FI@8EIK<VQ).RT=.8:"@EM;.2UG
-M;%D_3ULY.4UB:VM>&!(M7&YZ;#]):FYI8$UF>@-] 7(!80"O3TQO>G]@+3M>
-M@GUN:V);7EIJ;%M@6D]86DE,8#X^6W)L9E45+5PY6H.*<"4;2W #=_YC/#=C
-M>EDT/DU;:6]A23966FMK1"TY6H**@FA823\M-G!P.6B*:!4^:EQO6#Y5("!$
-M6#E8<GI[<F)L:6II-CE-3S\[.3 V/D1L:UQW=FI;4$AH8F-L?6Y+("U@>GIJ
-M34]R<F@\("E86UDR.7*">G)P9F!-7UIK:4DM,CD_:6++8G)I6G)U:"TE16-F
-M>V%)36--6'!M6UI$:GMP3TUB:UMB<F!5630M?69J<G [&SYJ:UAB6S(R-CEB
-M:44@&"5)6')J14UC8EM8/U%S WT!>@%J )!;1&%T;#XE*3!U@F!C:45F!&N:
-M<7)K7#D_6&X^+3]::TA5-#0_-D5F<'<E&TL#<OYI858Y8X.!<%\^375Z:ELI
-M25I89BD@66I]A9)Z238@&"5R=UA;BG<I/V%,:VU883P\6%@V,%QZBGIZ<F-K
-M:F-C6UDV/DD[-BT^8FM9@(:#=%@^6%I:<H)N8T0;28"";$5;;FYH12DI25YR
-M2S]P=G)N;&M:2$Q$8FM@/S9)6FN$8U!B; -BR&-4/FAB7GIW6#\[+4UW9G-K
-M3V=V@&!/9G)K6G)R36!A7X)8,EIB22 M:X)P9F<^+38=254E.40_64]P8C8P
-M6EDM-EA@35YU?0&# 74 L'MC26%+&Q@I/WAM6F9M+4ES<VQI:VYL6C8V27!8
-M/S9%6D589FE$-D5B8U8@&S]S7@-;_F V-F:$>W=A6W5[8UHM36)621(837)F
-M=9**9RD.#A50@G)B=8!A8ULO3VIK8SE8;& \&S!S@VYV>FIK:V-J:V-8/UA8
-M53]5:$TO<H6&>F%913E$;'IU8DD2+6:":C]B<FY@.S(T/TA<33!C9FI:4&]%
-M-DE+84]:6#];8&!A5LU9:EM)35AB8VA:85IM=TD@%3EO.6)R9FEF<F-I;&MK
-M:G)S33]%<(IK-S8I(!4@37*"<FIF3U0[1$LW/TMA8UEB83\G1"T.($58+3!;
-M:P%] 8( SY)[86 _&!45+7%:3&9W23YI>G)O<EQC33LM-F-I;F%C6C\Y6FI9
-M/VV ARD8)3]1.2<V8W!)(#!R8F9O8VYZ>W<^8F]6*14@1')96GI]=S0##OXV
-M<G%R>FMB<V,^.5J :"U,=V)$&!5%<W)96UEK:U%$:U!)/CY58UI0;ELM:HA\
-M7EMJ6!LB7V!J8E@K($1Y;EM>>FMI23([.T1:6EA>6FI:,%@V*39%;U]$2TE-
-M34E,34]Q2RTV84UK8V-P/U%P+0X.+6 V.4QB:6E-16MH16VN;6IZ:SE:=V--
-M/RDI/F-:5"TY<FQR=8-X3TE823E;:5AA84E)7BL.&RU8024M, %K 8H _HV"
-M<F=9*Q@.(%MP:%AK83]-<7IZ@GM;6D0R-EAJ;W!R<&%$8W)83W**D#8T27%A
-M-A@;8&Q$(#)I8#]:3411;H,Y8G)C,B Y37IF86EN<V8P#@XM:VUU@G)9:FI8
-M-F%]:T1$@&])'14E3'IK6DUB:TTY;TPP)S)):VA(:FLV3?Z#=4U)6VLV-E]B
-M6TAC;38V:69K;GIB7&Y+/C9%8V9S;U" >F-N9BDV17)825MQ:$D^23XG7T0M
-M+4E%8FQC6EAP<40@'31>8%M;8EII-BU68#9%4&V ;SE-<FQ;63\M-D0_/RT^
-M8EYN=9"";G!I6#E/6$E;8#E)=U@K*TMI:3R"& X!/P&" /Y]=7%H9C\K&"E)
-M9F]9.458/EIF<G:*<&!>/S9)8FIR<WIW6&IK6FAC=8-/65][=$0I+5MH/R R
-M6G=;6UXV,$AF6%IJ;$\V1$ES<V):;'IJ9BL2+6)Z;7EZ:VIO/R)@>EQ>,')J
-M5C)!/"=B:V!-8&]:16I:+2 V3W=[:&!:)S#^<G!$25AC6EIR<FLW6WLV)U4Y
-M4%!J:UMK8DTV15I<<H!:9GUG;F@_-D5Z6C8W;H!P25E$,EA$-UE)1%EZ=T5%
-M8G):1#L_6%M:8W-:3#]$6&8M-$EB9FI;8VYK86!A2V%)250@'5A/:G"&A&MV
-MA&Q)65@_14T_27IH-BU%<H!5@@X. 3\!=0#^>VYL:'%F1"DK6&-C<"4=1$E)
-M8FA0;FQJ84D_65IB>&YZAW!L;$]H;'=^6V$Y6W=I2V%P=UDI-D5R<F-I7E5)
-M8'!O6DU-6FI::FI%-D]Z>FI5)3(Y:G]B8GIF;T0I/VIB5C]K>F$M1%8^6FEC
-M35AZ8$UC32TI/TAQ@G=F8395_G)N/T1@6UA08F9R:&.#7BU)2UL_.7%R:UI9
-M6$U-.4V";EIF;EYC6$0G;F V,EAW:V)B6V!H3#YI83XT8FI:3TQJ345)/TU%
-M36!S<DQ6/DE;5C]:;UE:8G)K4&IQ6V)Z8F-D-!TY)TE>>H--4XJ"8F-@23L_
-M26F#;$DE,&M[/((.#@%6 74 _GIK6$5B>%H[/UAC86M>54M@8$AO6#]-<&$\
-M*6EF7EIF@WUN8W=J8EEK@F-F,C96:6F!<G)I25A+8H!L8V)I8W%K;G-))U9Z
-M:E9;1"4V<GU:5"TV6&J 8EMN3UMB7DEK<EE/<GIK7B<P-D]H8TE)>G)R:C8;
-M&S8V8HIZ7FEA8_Y_=T]@6F%835I>:G)DA75:6VEO1")$<7-:15E-839$>H)B
-M4$U@6TUN7EI--BU;?V);645%6EDP2VQ>-CE$86A-35A+6$E8-C!):GIR:DL_
-M6%A@:7)A35IR:T1<:2TP=WQ;6#8K52 @5GIZ14U]>G)R;6DM545K@VM)&SYX
-M>DF"&!@!1 %J /Y[;$0;,'-P64LP6W=K:7%@369)36@_-F%$)2U965@_6W)K
-M:&%J>G P.7-W<$LM.5A;9W)C3UMI/V)Z<EH^3%YR35""9R55=W!%65@\27![
-M;UXR)3EB@G!J9F)07FM)6G5C8GIN8W<V/#9)<FM-5G)Z?7I>*R M.UIV@F9K
-M;E[^8D@P8TUC8%M/6F)J<FYZ;F)S<VQ)169[6DE$16I/:6IZ;F,Y26A%7GMZ
-M<3\;-GIC8%@[)3!H23!R>FE++3Y86#Y$538P<CXR-F%B;(!81#])8W-S:4M@
-M>'-J8EDM)4R(844@*40I&#ER<F9R>FM-7G-P&RTP8X)K1!A)@XIQ@EA% 4D!
-M7P#^<G R$AU9:F-A1#EB8G=O5DE:6#E)8&%>,A@M8%@^/UA@-D5G6G)P/"5'
-M@W)P2S98<&-A84E09C]:8E8Y*2E/6TU;>G<V)V!C,$M?65IS=6I:12TE+V9]
-M<FUK3V)B8%IK<'=S7&MU1%Y$16MR1$1F=76&8S\_.UEK<GUR;GUI_D0V-D]5
-M14U:8V)B:&!K<FI(<FYJ8$U:;FIP5CE)6W)R>G)A.4EO63]:>H)M($AS9D5B
-M<$4Y6%@[>XIZ:UY51$LM)2T2&V)@-AM$23]W8UE)/UMK@5@^8H-V>VE8-CQA
-M=VD\("E4,B4M3VIF@8-P.3YR>BL8&UM_6T0I)V*(@X*"@ %/ 4@ DFIK+2<E
-M-C!%8$D;&QUU=6-A8P-9_FAW:"D@-&-O8$18/!@E2UEP:U@E-G-S>W _5G)\
-M:4U:344_:6 ^)14I25@^1&IZ<D1).398:%IC<G)W;ED_+2UC;FYB8UMH6F-P
-M:FIU:T]::#YI>%IO>CXM8FI1=4PV6#8_8&YZ?6YX<D5+:6YA,$5/25]M>FMJ
-M<FIA:W)J8NM@6"]$=8=8+4]U@GUZ6CY-<F(_-FMZ:R4E6F];6VM8.4E%67V-
-M>F)W<&)I1"D2(#Q9;U0;-FE;:VQC6#E-9H-+-FJ#;GUS64E8<'-K23(T854W
-M/$U96GJ$<S8@4'5$& XY:E@V1"DG4'*2D@%L 5$ BE!S6%Y>52DM6#L##OYJ
-M<FYZ@6$_.6)08#LI+41J=V-@1"T\56AW<EXE-VMR?7)A8UMF>V);/RTP<'55
-M& X;1$DM&SYN@G]4'3Q-8EYR:V9Z>G)L2S9B;G),1#9I8$1H;H)Z4%E)+2=I
-MB&YU@DD26G)>3"<E23LR14UF>VUN<CDM8G=8*2TV&SYK?7KS17-K8EQN<FAC
-M5BDM1WIR+4QM?7IR345;>F-+/V-U84$T/DU;:6]A23DG3W6*=EQV<F-S:54K
-M,E9B;V%$6'IR:5M-+1MS>G=)67)];GQV8%Y9:FYK6E@\<G=>16-B66Y[<$DI
-M.6A))PXV:6$M1#P5&T1]D@%[ 4\ _DUL<%MA:5Q)83\@'15C8F-Z@G!826U-
-M/RT\1"U(:W-R63]86%YS>V,V55YZ@FM;<5M$<HAZ83\M<H%8$@X5/F$K("5B
-MA7UH+39,66-L=VQO<75Z8EAH9F-@/R!%:#E%6H*"1#X\& E$>GI]@S8E6WIR
-M6"4@1%A6/CM:=5Q9?_Y+*45P+5E$( XV<W9R/VAP8EIK;F-96EY>36IB+6=W
-M>G5B1$UH:DU$86]R6E9P7SY-=7IJ6S8R/VI]?6MM<F)[<F8\-DE9:3\V6F)R
-M>G!)*R!Z?V P/UYU=6YK8EM>6FIL6V!:.6AN26)Z:V9Z>FA)/UE)*0XE6FDV
-M-CX5&"6"67T!@@%; /YC>G=A3V-O8VE%+3(8/SY0<H!S:VER:T0E/V8_.6!R
-M=G!96DU-8W)I87$_7'J 47)N/TAZA'!-176"81T.&"U)2S8V36U39VE)8%QK
-M7&MS<G)N;EI0:EI)85XE-FA@15A[@F@V&R K,&)K>H(V-FN">F,[%399<%I)
-M87)C1'+>8S8^:#)[<"(.+6MR;F!H:UMC:VUI2#YC>G)@/B5B=7UR33)%<&L^
-M-F)Z>V!)>W=A6W5[8UHY9DE,;H)U:F)(:VY;65E;8%@V+3DP3&MR8UY5=&P^
-M)2U):G)J8VA%9@1KGG%R&T5H,#EZ=5QN?7)B24]))0X826$M(AL;.458;@&#
-M 7, _G)Z@GAH8W-S?&A81"D@/DU-;7IR>GIR6#=)<V$V6')V>G!@255%3$U-
-M<E@Y7(!W<G=))5!\<#D_=8-X1#1$-C]@/SYH8R=(;TEK<F-<8UYN<FM:25EC
-M:4MB;T(I/E8V1'J$<D0;6%DG.4UF@E4P8X)]:DD2&SY[;V%C<F]-6_Y;/DEH
-M9GMU/!@M;'IU:FQK8VAR9F)))TQ]>W V+6)V@GM6.T1B;T0V3')R:%AB9F]C
-M;GI[=R)86"U9=72!:UIK8C):8VIK6$E<6$M88$Q9<'AA2QL8*3]C:&)F;2U)
-M<W-L:6M@-C)F+1U9:EIB=G-I6%E4*1@K87)A1" ;/VF"<FL!=@%W /YR=GI[
-M<F9R=H-R<G0[&#9)35MK<GJ#<F!+6&-9-CMB<GU[85E9-BTM,&);/SEB=UEI
-M5"!$<G-,/VJ">F%9>&99:$E%:&))6&!%8VMB6EM;;GIR:DD^3&E@:7MH.R<^
-M+2UPBH))(DU9)2U)87)B/F-]>FYH*14T8F9K;G5U:%O^8%98:7-R;FDM)5AZ
-M?5Q-:V: ?6I:239-:W)R251B:WV";VAK8VM-241K8EI)8#]:3411;H,[26$V
-M2V]J<F)8;&(P16)F<F--84U::5DG)UE[8#\8%14V86!-9G=)/FEZ<G)O6C8[
-M<%D_6'!H:7!K:UMI83PR/VAW:V-;&RUC@G)S 6P!8P#^67)J<W);:W=[9FV(
-M62 [-DU,36MN=FYL85M;3S\W16J*>D]-8E4R+55Q3S<I.6]@84L;)VM[<$EO
-M@FQ6-&-Q:W)H6%I(8&1,8')<:FMC7F9Z<VI$(#EA.6)Z<F-)-B 83(^*<%E+
-M84D_36-H6C]-<FIR<$DG.V9'66]Z=G5L_F-A9FEK;F9J225):W9:-D10=8)R
-M6TU98&-G<EMI8F!B?&EMB'IR6F-S:6%)-G=;6UXV,$AF:6AI;&IR;&M-3&)P
-M644Y1')W8F-%.5@^& X=1&=9*Q@.(%AO:%AK83]-:G9V<F,M*6MC3U%U=GM\
-M=W)K=V!%6&!98FA<;2T;28)J>@%O 4@ F4MB34QR8DAG<G![>FM5/!L@(#]A
-M2#E%<F,#6/X_,ATY:X!8,#]N83=C>D]$/TEC>WU9(!M:>G=-<HES8#8Y8VMB
-M;V):159@.5J":G-L9FM$8VQA/AL_6"5,9&UR:4D@#BUY=79Q.45S<&)B9T5G
-M3UEB;7)926!R7CQ)6#E'>G)K<FQC<FIF841%6FMC/C ^8G%U8EE;3U9-8FSD
-M8F-:<'MK6VYP=3E,@F%8.5AR<F-I7E5-6UI%;GIV;G)B/RU)@')8.QLY?7)L
-M6DE9+2 G%1MH9C\K&"E)8FM@2458/EIF<G)P*QM66"4;.5]R?(!K;G,_,&-R
-M6TL^,%@^+2T^:@%W 5@ R6]J245K<$U/:VMN:6!B9CPP&S]W32TP8$LV16MI
-M/R4E16]I2S!F>&EL=FE815MG>F]%.T1I<FM-<HI[8E@_/U@O35I-86-I6DP$
-M<OY<:TUC:V!5,C9>+6!;8FIL21@.(EI-6U4=/WI\9EI@6& Y+5IZ<EMA=WIC
-M6UY$(BE'8UIJ8TU85E9C8$U:8FM;.41H<G)J<&)91#Y9:V-:3&YU<FM%6G5N
-M8'5%-D5;8H!L8V)A8VE+/UI]>F-I6CLE27=U;VXV+6]K;%M0;42S)T0P&VAQ
-M9D0I*TEA8V!)/D5)26)C8F-$.UAC& D8+4UN?WIN8TE+9VI><%@\1$M5/"5%
-M 7(!8@#!<VM,87=L86%X<45%34]C2UM537IA-DE9+2 V@X%M530V6%E96')X
-M=VYK<%H_6UMM9RTM5G!R32=X>G=:3&AA338#+?YA:G![:4UB;GMR;%IJ>FM@
-M/S]926!C:VMJ21@),EXM+2 )/W)M6DU:6%@M&T5R9DUC<H)<2&@^("TY245/
-M3"U%8FYF6#8M-F)C238_3&-Z=7=C+1LV:&(E37=:8'<Y1&"#B6XV+6%C8GIR
-M6CY,6VI-/V.$@FM/138V6F9K=W*\.39P<F]I67IU2UY>.T5B>%H[/UA@8V->
-M6$M@8$AI6TU915EP.QT=(#),<HA\3TEW>G)R>FE5/SYI:#Y8 5@!4 #C<$4P
-M8X!B6GN*@UD^25AA15AA3&MI6%A$%0X;@8J"=V$_-BDV88B"=7)F:T\^83]-
-M<$DM/VIO-AMP@WA-.6ER6#8@&RE)3%IZA5H_7H-Z<F)K>G5K3$551%A-8')Z
-M:%XR/V@E PG^(F)_8$5835@R*41J2%A:8H)O6EH^-C])24U/22DR3VMO8$0R
-M-$U-13P;&S]Z=7IR1!@@6V @17)@6F@Y16!V>V(E+6A96F)6.2DI3ULY6'"#
-MA8);26!88&!><V@^.6MK6UIP<GI\<G!?&S!S<%E+.5MK:VEQ8$UF24UH/VM)
-MFD5K7BDK)RTP6X-Z5EES;G)N@WM@/R=J<TE% 44!80#C<40;.7)I37*-BF]6
-M7$E::5E,6&!L<5M5)PX@>H:*@W=9*0X5.8*,A'UK8$M9639);&A987%O2R5O
-M>G-96&-F8#8@&"!")TENA8IK<GUZ9F)L>F9Z>F P)UM3'4UZ8')N@&@@ Q7^
-M(#9K@&-@25E)-DE?1$M,68-P;&M)56%C8TD_:5P\1&-Z<F!)/S8R)2D.#B)0
-M>H)Z8$$[4& V8'=C6F V)UIU<ED;*59):6 ^)14I25@M37=;9(A,/G-Z:&%1
-M:FE86FZ"8#E:;FMS9E\Y$AU9:F-A1#]/8')O5DE:6#E)8')LFF%J<3(I*38\
-M6WIR3&ER<&AB=HIZ6#9C=V _ 2T!7@#^<5@;(&)P.4^&CG),14M:=VE+14]I
-M:U9-/!@86G)U?8%F( D)(FN,A8-R8%EA8F!;8TU-;(*"8T5H8F)I<VMC6#08
-M%2<M%4E;9H!UA7UQ9F9[<EEI@G<^(%9()4EJ2&-;>G R,#P[*R5->V)86$E@
-M241-15E%18B*;F-(25MRX')@.5!I345H<G)B8ED^(!@5%1TR1%IZB%DV8&M-
-M6&N">FI98#9,;FMI/UYH37!U51@.&T1)/EEJ,#=O/B)CBGQU8&-K13M$>G(V
-M27-K:UH_+2LE-C!%8$0E)39J=6-A8P-9G6AJ<G!S?6E!)2TY8WMR8&%9445%
-M6GV#:EAB<G!+ 2T!3P#^<VT;&$5H85ERBGI8/$E$:X)C,$]Q8TU)/S0R.5A>
-M9G-@& D))7"*?'UZ245C9FIJ:38M7H*&:T5)/TMF>FM:6#P8)S @#BDV/DU;
-MB'IB7&MR<F]N<FM@6$];:&)J8G!J:EQM/S]8,B!-@&I-/S!85C8M/V Y)W**
-M>G)8.3]L]&UR;DE;645::FM[<FE)-#DP(#150D5RAT0B6'I%6FAN<GIM:FAC
-M8DAO15AT8'*!6!(.%3YA/V)F53E>1!4Y>H""<6-8+14;36\^88*"<V [*T19
-M52DM6#L@("U:<FYZ@6$_.6);8V)R?75>,B =2'*">G-F S:)1')[:V-B8VQ%
-M 3P!3P#^:VI>03]97V. ?6YI85M84&II-DUI6DU$2UE925E:8G)N-C0@)6*#
-M@G)W6#Y/345:<"T;67U];TTR)39J@W=),DD8&" 8%2 V1!LM>WI96G!/9GQU
-M63]B>UA-<UI::G*$>EIJ53Y:/!LP<FIJ.R5$6"T;-FAA/EIR7'IH/C9-_D]J
-M<FMI6C\Y35Q[A7IB5EE$&R5).4MZB#D;26M-6DQ-3&I;<G:$:C]B/RU,<G6"
-M81T.&"U)-FUW:UI)6#8_8VU]?8-K*148-D158GQ]>V]$+5EA:%Q)83\I("E)
-M6V-Z@G!826UP33ENAVUB/SP@+41NAH-W8&$^-EEB15IO8X)@-@%) 6D _DUB
-M=W%)13YB>G5K<G=C:V)O:%E@6SXM/%E-6C V8&%F<#]+1"5$<G)F=&EI6#\G
-M/EX;&#EJ<G!>540V8XB 83]9/#)$1#0T25P2(&IW2&)]6F)Z<F@^068^1']H
-M/TU9;8*";UQ)6$4@*6!:9CXI25@@$BE(;'!><DAQ<D5)6-0_3%EJ=V(_-CE-
-M9G5U9W!O:#0;-BU)=H9A*3Y;5F-;85MB3'=]AGM;6E@[.6IU@WA$-$0V/QM,
-M>G5O1%9%6'!H4%R*BF9%,B4E6&=M9G=V6#9;6V,#:*E)-#(I/CY0<H!S:VER
-M;V _7G]:6F!8654^36Z$<V=W8$MA6T]><FI-&P$^ 5H _CE%<G];/B))8E!:
-M<GIW<F9S8UIH8"T;+5E@83XM.6EK;$M87C9):V$Y7'IU8EDV/E@\-C]-6EY9
-M8& P2&YR8G=C66!J;VE?:E8.)5]R2T=R8V-J;7-W6U@;+7=Z8EIB9FJ,>EI8
-M7DE526-P;S8\7F$T&"4B2&I-:U!G<E]B8OYA6#Y9<VD^-DEG3TAB7F]B:4DK
-M)2 V:G5R84E@8&-;6UA,.7*"@G);8V-F6&E;:5]6854\*RDM3'IZ6E@M1')R
-M,#!R?')K8"4@6&IO4'*#<UAS:6EL<G-H6$0I(#Y-36UZ<GIZ8F-C;&]%.596
-M8VE;6$Q[<V. @5M98UIK>G*"62 !+0$^ /Y$-TQR840@)TDY.5IR:FUV>W)>
-M:VA5,BT_6FIA,B5-<VMA86E@:'A@(#")>F))6&!@:7%I24M;2V-H,$ER63)R
-M<EYJ:6-[8#9((B),<G):25MP.45;6FM:36-I8G)K<FI%.45B9W5;8H:":S\M
-M-F!;238[/$]:6FM$26)C:F+^:G)/16)C/R4V8T\V-D5?6F--1"D5,F)J7&A$
-M6G)J8D1823!J=7I[4%!C:&MK:FI?;W->/UYM.QU@?7<_&S9B9C8V<&9B6' V
-M(#E?9S9-<GYZ>W)F:W-[<G)T.Q@V24U;:W)Z@V)K;'-I538M6'!W<V%-<G-6
-M<H5K6V!,:VQG@FE5 38!.P#^;V),8V]@7CXV2UA96TUK=7Q[:VEJ<&E>26)<
-M8S8I-F!:8FAQ9FZ"<3LM@8-R3T5,8&IZ=TU-;UMJ:4]:>F8M3&MC8G)R=6MA
-M7C0T-D]O:EI,=TPM36)B6E%B<TU%2&IR8#];6TUB1#EMBH!--RU/6$D^25MP
-M8V: :#\Y8X)8_EIF:VMJ8E$E-F)I22TV6&%H6%@T$BU86E9,-C!M<V\V-EA@
-M:F)R?69::$Q;8F9N:%MR:#!%<F88+6J(/Q4I25E98X%S:$A9/BDR25@P16)F
-M;G-R7&MW>V9MB%D@.S9-3$UK;G9P:W)R8V$[(CEB=8-R6%A[:6]R:G=J:W!;
-M8()B8@%9 5H _G5Z:%QR7FA>,%N!>V$P6FYZ?6)/36N"=UMJ<DLW/%5>.41K
-M<V)>>W=A17*#=6$^/EA:;G=-36);9UM)269Q7D5(8EIB<FMB8%%?6$DY7')R
-M6FI8)3!B:&-I8VQ913!-7()N<D\V6$U$:W6":#<[65M)/CE)<&='>G-)'5N*
-M8OY$1V9Z;6MC+3]B<7)8-E5(6FMK5B R9FMH6"TI6WMW22U%:VA$8GIN;&)@
-M35I-8V]$4&\V-F]M&Q)$=4DR56!H5F-R>H)R6$DM/TU8-D5;3%!9<F-/9W)P
-M>WIK53P;(" _84@Y8UMW>F)A52DM-F*%@VEB>G5V:UIC9G-P6VR":$0!80%C
-M /YB9FYR<EI821LY@X9K6&%J;FYB23Y:=WIR<GM$+55@7C\^8WIP6W)R8V-K
-M>W)B/UAA36IP36!;8&E;8&%>:V-A16!).4]R8U8^6&!%+45J=7)G6S\R1&MF
-M8F9N8E8^-D5]?79H14]C:WAR?7A)-FAP34E)1&EO.6IZ-QM)@EO^6D]-:DQ9
-M>S _:WQZ:S!>/B=:;7(M-FEM;VA)/$UZ@&D\/&%C24AK8UY$:6%)*V-G/D5O
-M24EK9AL8/W5;36EP;TA%.4=ZA7IO/TE6/S(Y6EMI36ML34]K:VYI8&)F/# ;
-M/W=-+3\V8W)-15E%*1@P;H)L:WIN>G);6$QH:6%K@G V 3X!30"O6F-!8WQ-
-M-BD8,'* 9FMK=7)B9V%)65E<<FI@7B5"8%A)/TQU;EIC8$1K8W)J;V #8_YZ
-M<V!C8VAC8W)[;FE-8FEA22TE<FM-)S]U6"TM3&YZ8EI-3S]96D5$;&)9/S8V
-M6FYF8EM,8FYN@GV":TUB<F):8%EB:#]/>U\G8')':F)%6#8^;CLP7(*";#!H
-M1!@E38!),&IR8EQ@33]B<G!8/T1H8U!B:V@V26E>.5E;24G.:%IG<FM$-EIK
-M:6QC:G)B9BTB6FQ]>F!B6"TI-EIF>F-Q:V%A>'%%14U/8TM;54UZ838M)4E;
-M/S<_2S8.&$5B15MR9GIR:&);66%A8W)H 3X!- #^,#X8*W=C/" 8&U![8V)B
-M=7IK;VM-/S]86SXP8"DK/SX_-CEJ<TQ8:$]@86EI8F)H.4V">EE(8V]R<GIV
-M;7A:45E/640\@GI@)2=G8"T;-GJ"/SE)6%A::%8Y34QA6$1)1%A/1TDR3TQB
-M>F1N<EEC7&MC3&N#7"=)<G);<&A)_F)<35@^/V@[)41V?6-6=UD2&$1Z<EEB
-M;V-%658^.4QA8# =1&-J8G)W-CEC>&A)-DM@6EIR>FQR84U83&=937)R<V0V
-M6$U0=75Z;SPR+45N<VAW8F)[BH-9/DE8845884QK:5@V("U923]%13L8&$M:
-M+3!(15!K:UY;2&!N:X)R<P%W 3\ _C\@%2UK=UA$'0XG:W)I6F=W=75Z6CY)
-M:F]F6T\R*T1+539)8W)%/F9W85A;<FMB/Q@E;W(_)4UK:WR$<V!Z<EI)14E)
-M1&YZ;SDM1388%2E<?4DM25E?8V9C8UDP:7I:34UB:5M@/S\V3'-07%Q-13!-
-M.2=BBF(;-DQ-:VY-5OY-1V%;13]@/C);=6T^;WIJ*1(E4'J 8F-I/SE-8%E9
-M8FM$.S]::V)B<C\V2'MR21M$<%E%<GIF<FI/6$E56#E0>GIR:6):669Z>FI8
-M1"\V8W)@:&-1<HV*;U9<25II64Q88&QQ22 @/V!:8&8_&QM9:4D[24D^6V-:
-M6T5'9UR"<6<!>@%\ /YI/"LV86M95C(8)4]K:V%:8FY^@%I)2VY[>H!C539%
-M86%886EP539::V-816-S;S88)6%O/!4I/SEF@H-]<G-F6%A-3UAJ>GIK85@;
-M#B=<:W5H/EYB;W)K7F96&T1U=69/4%M%.4E-,$1J:4\Y22T5*1@5.75W-C\^
-M)T=01%;^34UC<%A)3SE88G);'6M];E@I("UGBG9L:38E-FA::')Z;V=86VUW
-M<F,_66%W<EXE-F-C8'J":V9H:6!-8&E/2')Z:WIR25MS>W5R6$E)-EMI6%MC
-M35F&CG),14M:=VE+14]I:VL[("5%6&)]62LE:7!+6#\V.6EH14Q%1$Q8@FE;
-M 6,!@@"]>F@R+4U:6T]5-#0^:6]B6DU9<GM9,BUB@GJ#7F)M/C9%65MI:V!/
-M8VIB:3])8W-I141C<%XR&R4E.5IF>P-C UO^66!K?7UZ<V(I&"E::FI:1$5,
-M;H-Z:EM-1$]R?6YR83DP-CY6/E9::FA8654;'1T@+4QH24]A6%A)-D1-36)R
-M:VQH-CY845DM:GIF33]$/T5R<FMH)1@E6$UB:F9R<F-O;7)R63]W<FIN8U4\
-M/DEB>HZ*=6MS<%M):'1,:&UCO7)[6REC@WIR63E>56!H6UM@65ARBGI8/$E$
-M:X)C,$]Q8WII1"D;-FEW:3\E16!%:5D\-FAK5D5622]%:UH!1 %J /YJ;T5$
-M8%IB6&$\*R4V:&E;84]C:DD;$CER>HA!37IN+2TV16EI35AI:W-R251;7G-K
-M5DAP<6!!-#])3V)Q;%YC85M;8%ERA(1U<F(V+51P>G-B6EH^4(6*:D5;:F9N
-M=FZ#<F-)+2U+86QK<G!;2&DM(#M)8VAF3U9I8V-$-C;^/TMH<F9H@%4M/C9$
-M:&9U6F)K:V-;8%@_8"48'3MQ<FA/6F)K>FYJ:SXM<G)91S]8.QLE+6**AGUJ
-M<GIB+41R:VMJ8E%Z=!M)<G)J=45%6F]K:VE@/R!:;EM/6"4;/V%;6R=$>G9R
-M:3\8*6%H7F=$/S\M85M$-EQP;%H_.39%@G* 3D!/P#^:6M96VAL<6EO62TE
-M($5?8&-96F\V#@DE25Y[66UZ;5M$-C]H6"TM.5R"@TQ%845C:5A667=R6E19
-M65MR>GIP8V-;3UA/>HR$=6YC239@=7MZ6&-L:45J?6(Y3&IL9FMT:6"*>DLM
-M-D1N>G9R8$UH52DV36QR:FAK<F-B6CXM_B([<%YC6W9C,#8@&UAZ:VAI<G!K
-M6VEA26Y9/#(M;X)Z8DU)2'I[8%LE(%EK6$DR/C(.&!@M6W5U:FIS;U]A8F9Z
-M;6MC<G<M2UI/479P86!/:FIK8UX_86M%3VE$/V)R<F8V.U!R<X!L,B5@6EAH
-M:6E8/SE@;CY$8UYB124_18)F@@%9 4D _F!96F-/<HER=W)@-"5+16%L7T]P
-M6RDP/%5-8CERBF9;639I@%4;&"DV9HAH3UI%66!%3#E:;VM;6F%C:UY[<W)S
-M:%M826I]A'IF84LV3')Z;4]:9H!B8FM@/CY<;FMB<V9GA8!I/C8;27=U=6M9
-M6UA+541;8T50>G5K3&)M$OX2-E9(85MF=SXM*1@M;FEV>WQW<FMW8$5R8DDM
-M+5E]@G)?6%9J>VM6.T19:%I-9F%+*30\,CYB;UE<>FIK:V!-:DQ9>W=Z36!A
-M345:;W)W86E:6F)B;&MH6%EP84]B>G6 <FE%8EYN:F8_6F-I:VYS<& ;/X!?
-M6&MC6S\@+3^"6X(!8@%; /X\'3EH6&.'>FYZ=6M88T5-:$U@:F(V54MI:E@B
-M6H-L338E8H-O/" R539KB&]A25]H6DU%/TUJ;TEC:V T8W)S@&];6%AB<G5Z
-M:UD_1#!$8D=I64=[<F-:7U0^,%MB2&IU?8: >F!)*3!;;FMJ8EM;8&-B84D;
-M'6AF9T1J@QNN$D1-1&)K7&MC6%0T+6!?7W)\@&MN<S\P;6))*R(_8F);65]U
-M=G5J5CY)/FEG.0-CSVEJ<75?3V$V,G=B3TQ815@V/FYR<F9J=VI--C!B@H)S
-M64587G)R6DE-<FQ98W)C<FUU<G=C3UIF:W!;7FMK:EYF*3EK8EIK<VQ).RT=
-M.7 !8P%6 .T\(#9965MW>W)R=WIK:F-P:3]%6E@P/T199G%)8X-K638\6WIS
-M9CQ)6#8_>FY;86AP;VA8.3]<<FAJ;V G,$5C>FM@6EA:6EQ]@VDY53\=+1MB
-M8CE>8UA:6$Q6-CY-+TUN?8J&?'=8-"4_4')C UO(7G9]<F$I&UEJ8DQND248
-M55M::')C46)B6EA+1#\M36Y_>FYC24MJ22TK&%Q8.38P6G)]@VA%,"TM8W=I
-M65M::GJ!>VM/6#(M W+#84U-6#X_:&-B;6MU>F(R%2]WB'I/.5I,;VMA13YI
-M8UAH>FM:2&IZ@W%%66MM<D]/6F]C3U%I8VIB:UMB<F!5630M8 %J 6 _DLP
-M7G!B3%QR:%MB>G):3'-Z8TM)6%E824M%>W%L@W):24D^6G5Z<G%@1#]F9D]A
-M8W-S;&E82V%X9UYC<%4T+4UP3UM@6EI%,FN*=S8V+1@K*T5O8$0^25I;6$DY
-M/TDM.6!J?8:#<EM5*24M6EI-6UM/8GIU<F$V87):,%J*6(,P6&,$:_EA6%!-
-M6&@I&R R3'*(?$])=W!$&S(E;5@V*2D^669Z7SY$*2 ^8WI065M:;H)U8DU8
-M/TEZ>H-P36%;13]@6#EB9GN(8R4)$EJ#=V Y/CMB6F%-3T]%/EI[;&-C:'J*
-M;#!(>G5R13])8V)C8WJ#<V9R:UIR<DU@85]I 5H!40#"/RE->G=,3'!@/SEO
-M<DDV6GIN6$5%8&]+2S]R>G)]<V-A.QLE:H)]@F-F;VM:7F%C<W5K8V$Y,&]W
-M6DAJ:$DV26E;!&"E22T_=8IQ2388.V%%;'-9-CE64&!924E8.SEA6V."@G-:
-M8$LR.P-)_EMC6%A09GIW35IS:#];;G)A36)R:E!C<G);24]?.1(G+3!;@WI6
-M67-H7CLV86A)-#0\6%EC:TDM-EL@$C9H6EA:6VY[<EM-6#98;G6(8C1C<%A)
-M3SXE,#^ D7 I#AA)<F9K83X_:%EC;&%+1#8W9V%@:WIU@V,V17N"=V _.9))
-M87)Z?7UN;&MK:G)S33]%<'<!;0%- /Y$&R5B>F)18VDM'5AA13\P8U M-C]A
-M=V9B6VE@:GI]<6E%*R5-=7US8VQS8UMB:6QV=6UC7RT;6H)H15],.3]%:6!C
-M:6!R;V Y6H*$:T@I/W!$37)P.3(O.5A@6F%I23YB8VM[=69B6V%H9U9)15MB
-M:F-$4')U8VMR:UMC:GK^:U9B>FM:8W)V>&!-340@*38\6WIR3&ER:EA)5G)O
-M33(M/FEO8FA4*1)8*0X2+4E67VAS>G)H8F(V.45F@V P8G)K;&A),@D;:HEZ
-M230M6&M><G,^27!B8VMA/UE>/EE%6&)W7'IQ15AR>WIS1"U$67)]=69C:$5'
-M=W):7D4=@DQJ 7(!< #^;CLR6W5R:V-O-BU)6$54/E@V+4188VYR<F=W7$QZ
-M;FMI841@<6MZ<EYR:UM)3V%G<G5F86 _27>#:F9P22T[16%;6VMO;FMO:5!R
-M@VU8/SE:-CYK<DDV+39,8$E/>UY%14US=G)B8$E-<F]@36)C8VIL1$UF:F-[
-M>V-06EY\_G='8GIK6&)R=7IO6F!4*2DM.6-[<F!A64TV/DUW>FM4+2U,;TPW
-M5E =240P%1@[1&!P8W)R;VMK6"T;/WAP.6)U9')R3#()&%F"=UM>6$5),&!O
-M.5AA:6EB6#!::#]A24U97$UR>%M98VQZ:D0I-C9C?7%;3V V/WIN:&-9)8(M
-M20%> 8@ _GMH25IR:7> =V!%3UI)8FAF+2 V15IB9FYK<#XP8EIB8EDV6WIB
-M:W)R;F))14E$26-B36-C6&*"D7)L@6@_1$5A9CE%=TA(:WIC8GYM3$DP-B4^
-M7')C6#8M.58G.7IN138I45I>:F V+6EO1$E@8V)<9F-A7T11>GUF33M-=OY]
-M1$U:3#1@:FUS=5!B8SLR(!U(<H)Z<V8M*2U)<GIU<EY)3VM))3961%9I82 8
-M,CQ%:4U;<F)B7F @&"5-8UAN:D]F@ELV&"!@>G=$.7!I-A(V8#9/15AI340;
-M/UXG/T1,9T1);')C22<_<FLP+40V/W=R6EMF+4EW5'=Z9BV"("4!6@%[ .MK
-M:#E-:4A9?8)R;EE/3VAK8S0.#B4^34U<:G)955M865IA24QC/C!F@VYQ:4E%
-M1#9;9CE/:6%:8H)R5&YB:VE93UPE(&M)15IR65M[<UQ@538\14QB8V-)-C8E
-M#B=B:DEB7C8=-EM>+1M@:P-:_F)B33(Y8G%)179]=7)816IZ:$E)+1@^54U[
-M@%!,<D4_/" M1&Z&@W<R(!LV:W9J9G)Z@H!J15M).4EH;S G*5A86F!C;6I8
-M6UM$;F8E)6**<C]JA7IP-BU9>GM@)3!P;1LV:&!9/UAR8EXI/G%5*2U)<%M9
-M3V)J:3PR3&))-I)$2S9)8V-B<$D^:4AR@GA>,"4!8P%M /YK8SPY86%::WJ#
-M>&A1<'=R9U50(!@V24]98F)-8VA923!9:%9@-AM$:TUR@&EA8$58<%E-8F-;
-M/V:#:V-;:W-P83XE+6-H;VMN6EIZBG)K;%A@:6)B66IJ3&9%(")9839W>V$Y
-M/F!8/TEI<W%B6F)K3S8I/F9:1&IZ;GIZ:%O^9F\P-D4Y-D0Y<HIZ6FI68%A9
-M53Y-;H1S-BDI/$]N;&)D?8F*<EIC838P:5DB*1M)8$56:VUB7UXV.7MB&Q4W
-M=6]':&AU?4DM35QV@2T2+5@I&U9B83Y9:VIP/S!S;24V640P8G%F;GIJ6TE'
-M:&%82TE/245$<F]/8&AK;G-;@CL^ 6,!<@#^<G!),%IC:6-K@H1N36)K<FMF
-M<D0I-DU/3'!O6%AF:UX\8& T168M)3\^8W-S;&)-:&-86&IF8"UJAG-C6G)Z
-M;&%+/#Q/<'* >F-:;HEZ7F-::')F8T]<:C!@8U@V.5@^7GIR6DE:/CE:8G)Z
-M:D1F@F-A1#EO9$U/;V1F;FUR_EM8)14M/#\^.7"&B&M:6F8^1&YZ:FER83\M
-M/V%%7&IK4&Z AGUF8V$_)5]<)2L@+3E536IR:UY)&RUC-@D.'6IZ8W!$68A+
-M/%M:<()A.2 E/!@E6'IZ231)<6$V&!M@;$0[%2MP;G6*;F-P:VQO:$U'64DV
-M,&MW6DUJ;&-97H(P-@%' 68 _F)Z6R4_:VMI8W.*?6M:3%MP8VI65#D_64U:
-M=W Y6G)A:7UP-C9O;3(E/UEC9G-<8V@Y1%AB;F@M3')W:E!R>F-/6&%527)J
-M=75N6UZ&@V)08F9J9G)K8W!)25!;/QM%84EC<UHP2RT_:#D_;GM<8G5<6DTY
-M:VI,1&MZ8EQ;:_YI5CX5("55-CQH?7UJ14M88$59B%M9=VD_+5AP34QB@&);
-M=7A]=G)K6UA-7#9$/S0;/V!B<F]@2QL_:$0G'1MBBGU[85B"/S9A<'J*>F M
-M+44@%2UU@T]97WMT1"DM6V@_530_6T]F@VM/>HA[;G)925E4)15-<F-A:V-K
-M8VN"64L!-@%% /Y9:U\M/V-<;W!F?8)U<EI)8FM@66A@15E96FMP)TQN/V*"
-M@F)C@X=I+3]%6F9Z8F)G+2(V/W=R2T5B;G)C:G)K6$E%6&%R<VUJ;6I;=GUM
-M6UIN<F)R<FEL=VQA6#L2+3Y+8698,#(5,&$;$CEZ=VYR8D\_26-B125%@W)'
-M6G'^8V)A,A48-CX^9GUU:RTM-G!H37)B/S9K>C9,8EHP,G=R9E-<@GAZ;&YR
-M6EI)3%E>)2U536!W6TP^8(" :R4)-GI]=G)B@UDP.6IZ?8IK/EEA-"DK=WY;
-M83E;=VE+87!W66!@86M;6FYI,&.*AGIJ8#Y%/A@.+5]04&IF>')Q@G=S 6 !
-M50#^8%I-66%C6V-L:WUR>G9P6V)J6F%L:455/T]B:S]/7$1:<GIU;8I]<FE;
-M/TUC>GI<6%4R&R=K<EXY1&)K8DQB:VT[("U/369[=6MK9FYU;FM/<GUZ;FYK
-M9FII>&A+-RD;26]@/S [*S9$&Q4;6VYF;6I;26MP:CX;)WI[159C_D5:<F\_
-M.24M1&-U:'(I%1M8:UMZ8TL_8W5C:5HY-D5J:F9@375U<UMZ@V-;85A@:3PI
-M-E5$8EL^86QN?'<\("U:>GIF8G=Q351L>W*">V-F:5Y)4&N"8V8R-E9I:8%R
-M<FE96$UZ<EI:82=:?8=Z9F-823\5"1@_2S8W6GI<8X)[;@%O 6 U6!;25IA
-M8W%;869R<G9U<G)O9&E;:F]-241%7VIB8%E>8FJ"<F:">F-J8U5;7FZ):%A;
-M9BD;16)Q24E(:%0G.5MI/"LK)1TV;W5R8VMP:FMC26)U?6<#:H%N W+^:V@\
-M$EE[8E@M)SEH8$0R&TEP8W)F/TUZ@FM>1%2 BFIC65II<F988"TM16M[<G(_
-M*1@R2&AJ341A;W)J@7<V8'=P3%MR>G9U:DQNBG=C6TQH:U4[+5AA34DB/V]R
-M9G=/-DM-;8-R9FUW33EI<FMC9G=O8F-96SES=W!++3E8I%MG<F-/-BTG:W)L
-M='!$:WV*>V-;:6%)*0D.+44@&U9J/UJ!<@%H 6( _DE915IQ<EYC8%IK8E!Z
-M>VI_=W!L<FI9-BTM/W!933E@8$5K:FUU>V]/-EAA<&QR6C]):6E+/EIK8&!;
-M850M+4U82UE0+2DB-U%B3%!C<G)C35IK;F)945IF;G)Z>F@W%4UR6E!C84U1
-M8FMI)R]H6UYS6T]RAW!,:&I]BGUL4/YG<G)>63DV1#8Y<&YK:&E++3!P:TU%
-M8')R35I@/UIZ6#E6:GIZ9CX=6I*"<&%)6F)+/EEI6G)R1"5B>W)R338_+2]J
-M<EQ@<FQ@:%IC6#E::5@_/EHE1X-R<$LV6'!C86%)51@826),8UQ:<X*%?6MH
-M:G!B7C 8("D@($EC+3""=V(!6@%- /Y$/"5+@W]/.4UB:V P:W)B<GAR<HV*
-M;U9<25II64PM6&!86V-<4&IG/B4^3VQL8TDV-DUV=TU-:EIP8&-F6#]8.41@
-M85E)25\P24PO.6-R<F)B:&I:1#E%6G)B<F@_-FMZ6UH_9GQS8DU:8E4V8$U%
-M<G)B9G6"8TU-:X)\:F'^6FIZ<F@G-G1$&S9C6G-N:#\E6G)J8V ^/DE-238^
-M64(M6%IK:T0M)5:2BH)H6$D_+39P<#EHBF@5/FI<;U@^52 @1%@Y6')Z>W)B
-M;&)@7V-:-BU))39S<WMP/U9R?&E-6G<I#B(^5#\G)UIZ=75F:VMN>FM>.R E
-M/#9;<3PE@EA- 6@!20#^.R 5+6][62 M8'-H2VAK7&9K:UR&CG),14M:=VE+
-M/TMC8VAI5C1-23 \1%IS<F)653Y%:X-K5F!%:VM/8VE;838G/T]/1V-R239)
-M)RU)6W)R:FMJ9U@_.4EP6WIC2T1C;EA:6W)U>G)@3UA)+59$.6AN:VMF?(-;
-M.45K>G5K_EM89()O)2UQ:3LE245K:FM@,E9N9F)J24EA5DD_/CDV'4E:6&8I
-M(%EJ?862>DDV(!@E<G=86XIW*3]A3&MM6&$\/%A8-C!<>HIZ>G=K<G=O8DL\
-M+24W:W)]<F%C6V9[8EN#830@)5A)&QA%=VYJ7D]H9G5O:50[-DD^87IH.X(V
-M20%W 6 O3(5&"UA;SP.&SYK<G=[<FIB8EM;<HIZ6#Q)1&N"8S8_6VMC:U]%
-M63\G,$E/;'-@-TE)2V.#@FIC86Y[6U #:?YA1#=%/TQF?7 Y1#8M/R]B>U!/
-M:FMQ9DE%;&AJ34Q@:&A)37*"?7IM8DU8.2U5/D5@9UIJ8E!Z:#8M6&YZ;6MB
-M3VUP/RUB@' ^/DE?6EE9-DUS;UQB3&-T3$1B62T\+4UB5DD2&$UR9G62BF<I
-M#@X54()R8G6 86-;+T]J:V/ .5AL8#P;,'.#;G9Z;')Z>G)I124V55YZ@FM;
-M<5M$<HAZ>G* 53)89EM$67IR:EDV6&]D9F]>7TM8.4UY<DDE1 %[ 6@ _E4\
-M-$EO9RD.%3)-8GJ)<FIB65HV6FY;3U@E&S]A6S(V16UI9F=)2U0V-#9%6%!)
-M&R4M/TQQ@FU<;&Y]<FMB8VQO<6-I1$Q->X):1#8M/"4Y9T0P1&-K;TTY8W!K
-M6$Q:8%@E17)@=8)F45A8/B=$,#Y@:$5$6DEB8RT;/W!N9J]U>F)08"T5,&J
-M7TE41456/CY%8G)R6#!-<DQ8:6<[-CYB;U8I%2!$<EE:>GUW- ,.N39R<7)Z
-M:V)S8SXY6H!H+4QW8D08%45S<EE/6W)U=8)X5"5A<3]<>H!1<FX_2'J$8V:&
-M<DM/:W!J8@-RDF$V,&IH3VMS:V%8-D1K:44;+0%A 5@ _EAI26-Z:2 )#B _
-M.6)]>EM-36!$86M%3VE$/V)R<C\R+5EK;&)664D_7DE88%]$+3(I-C9$;FI:
-M<W)F=7U@1&-O9FYW6#\P:X)Z:#\M55Y$6U4V-DU;:D0V6GI]=6I))2 E56(O
-M67IB5EA<5BTV-D5:<%E)6%MK3S8@,%YH3?YN@FIB6" .*4EN9$UH138^)TE8
-M1%QR8C9)8EIH:V9A23EB<F,R(#E->F9A:6YS9C .#BUK;76"<EEJ:E@V87UK
-M1$2 ;TD=%25,>FQ965MK9G9W21M-<E@Y7(!W<G=))5!\/DR#@VE%:WIR:VMF
-M=VE5-F-C2V-[>G)L8%AK<&:"-"D!)0$G /XM3V%P?G R%0XE66!@4&]K6$5:
-M;&MH6%EP84]B>G5H64E$7UM)35HV+5IK<&)B6#!$6%Y56&)98(" 6VI]:CY,
-M6EYK;&%:14UR>G!A16)O6DUC63]-8FM%-D5:>GUK1" 8(%A:2W!R1TE816 M
-M*RTV3%MB2SY,@%LV/TM@;EO^3WUR46 \%2U69FI;;F [(!4W7S]);' _1$5C
-M;VI08V!86FIL3S9$27-S8EIL>FIF*Q(M8GIM>7IK:F\_(F!Z7%XP<FI6,D$\
-M)VIR;VA:6U%G8BT@,&);/SEB=UEI5"!$<B4E<H-R.4UZ=7)J;8)P7C!86$MK
-M<FU]B7)98GM[@F98 A@ Z#(M2W"">DDR(#9I>W<P3'IJ36%R<EI)37)L6V-R
-M8WIS>G!@6#Y-9C88-FMZ<F-?/CE@>'!T8#8M=8)S:VIB6EE:8VM:6G!)/V-F
-M8F-C<GM@-F-J6FEV>FD_.3E-<FDV&" R/S!(@'-8 TG^838B-B=)36%8*3!R
-M8S\Y.5EN>VIZ<F)C6C8W/D5R?79K6"LM6&)626IP23<V/EAG15AB<&]:34U:
-M:EIJ:D4V3WIZ:E4E,CEJ?V)B>F9O1"D_:F)6/VMZ82U$5C9@<WIM8DUH<E@I
-M+U5Q3S<I.6]H84D;+6,I#DQU:TE->GIRE69M@G-K/R4M8'-K6WJ2=T]C>H)U
-M;@%! 1@ _E]>24%<@#DV,CYR@W)96G)U:VIO:V%%/FEC6&-S:VMN?8)W:3\_
-M8EX;)6EK=7=L83]/:DU%)3(I375[;TU%6F-;:'IB6FYC54E%8V9::G)B/TUI
-M8W**AH)K:4D_6V _,D1>8#XM8X%R:5I-8&E<8$1%6%I8/S]K:U8I&SYO?/Z"
-M@GIF:UMA64E%8G6&=4\G/FMS:W!R<F-+/S8_23]+<&MN<TDG5GIJ5EM$)39R
-M?5I4+398:H!B6VY/6V)>26MR64]R>FM>)S V3WJ";F!%:GIH*25C>D]$/TEC
-M=W!5/SE/*1@V<$PY6GI[<F-<;FQR82 5.6-K3VJ*@EA6:H."@W4!< %+ /Y,
-M8G(M-W G3&YR>G)>:W)S>VYC8EIA34]/145:<&Q;:WN#?7!86&IF(!MI.5IX
-M:6)-6FM@)1LV6%I<:FA)+3Y@6VMZ<FIR<F-)17%S1TUB8UE-3U9;?7QU=H)O
-M5D589D5;:VI@/SEP;7)B5C]P:GIK5F!L85EA<FI$)2M9:WW^>WUM:&!$6EAC
-M8FERAGU-("U;=6YZ@H)S:E@[/U4M+6%-4()G)55W<$596#Q)<'MO7C(E.6*"
-M<&IF8E!>:TE:=6-B>FYC=S8\,CF >F,V-EIF=U4E/X)N(!M)@G!825IR<%@@
-M&S\E'6!Z=W)K;W5V=68T*RU/:45$>HII,$5\@GMV 7(!:0#^)T5P5#=K/T]<
-M<HI[8FIZ@X-Z:VA96V%92T0[/F)A3V-R>GMW:FIW7C(K625%<&M;8&ER<%D_
-M3WAS=VIH538M1&EL;FIB:G)B.3YL>D0G/V--6&%@669R=&YZ9E@^-D5A6F9N
-M9TD^7UEK;UM%8%!U:DQ%9F9K<'IR22 _:%N"Z'5]9EQ;3#XV3VE99GUZ6B(5
-M.6)?;H.&@FM-/SQ8&RT^15EZ=S8G8&,P2U]96G-U:EI%+24O9GUR;6M/8F)@
-M6FMP=W-<:W5$7D0R<H)H)1LM,FII64EL<V8E*6MM22!$=8-Z7BD;%14V UJ5
-M8FMZ=7IR2T1)2V%96'&"<#8^8V9U 6(!8 #^-EEI22UJ8F!9=86"8E!F=GU\
-M@X V&Q@@.V-L5D5$6FMO8DUJ=W)P1#]?:38V7&IB:&MB:W=H46-UA'IK6U@T
-M+6)Z>F]%6F90.6%S<TD;+40P36MR:E%B;75U7F!8.S]@6DUB8D1-:6MF8EI@
-M8T]K7EA:8F-P=W1R8"D_:T]NGGJ"<F-)/TP^,&-B:FYN3U @.SXV3WJ"AFM%
-M,#]Z/P,VS3=J>G)$23DV6&A:8W)R=VY9/RTM8VYN8F-;:%IC<&IJ=6M/6F@^
-M:7A:;WI6& X8/&-K;&!;:G=8-F!J-A(G8H:-@CP@'2DR/D0_/S1K WJ/6#!A
-M64E):7)M>F-I:4AF 7,!60#^8FMW/B!P64TY:WUZ<F ^8VM;:8!;*1@@26MZ
-M:UD_16N!62DY7')H/S]9=UDV-EY%34DM1&QR82M:A()N8EH_)TAU?7=9<ED^
-M*VR#?6@^550E3')[=F!;6VIU8E!I6%EB8D],34E8:W)F:TU68EIL8%A:3&-;
-M14=R8BTG8F-:_FMU?(-K/EA6'3E,<X)N6V%)5DDI-F=UBG)),C9U;TDM&Q(^
-M;H)_5!T\36)><FMF>GIR;$LV8FYR3$0V:6!$:&Z">E!922TG:8AN=8)I-!@;
-M2VMN<DU%3')H5F]W;C0;)V:%A6E57UY%3UY%1$1;;GJ 8B5,6D5)<')1:F)J
-M>()%10%R 6L _GIR?TD217!)+4QR>G%P-FEO/C!8<&,@)6AZ?6L_-C):@F]$
-M-D]O8$E))U]L/"T[254M&!TY:W E+6J"=FMC8#9%<H)]:HIC+2U@>H)O3&%)
-M&W!Z@X-R:V!98FA(6V-K<V))6$E)6FUZ<G)::5I,3$UF3T5:7SXG3$0M1&]R
-M6?Y,6VV*<D5)8#8V.6F">G=S<&I@6%5;9GU[83X^4'QP5"D8)6*%?6@M-DQ9
-M8VQW;&]Q=7IB6&AF8V _($5H.45:@H)$/CP8"41Z>GV#>F$E&#YC<G ^,$1R
-M=UI/8GV 7C9%=W5L:X!B65Y>.TEH;V9K>G)+8$4M/G>!;F)16G>"8U@!6@%Z
-M /Z#>H9P,#EO:#]%8WIF8C]H=V$\-EIC.2UB@GUK,ALE6()Z:%A;=W-B52 V
-M8$DR+6%U53PM-UMQ7C98:VMF8W!I8FU\@W-R8"D@/W)Z:C8V+0Y:<FEU>G)J
-M66)R6TU;9G5F.38V,%9R=7QR47!B23XI6%A$8UI:8&E>*3Y9:V_^8G)R>G)H
-M5DU>7#!$@7UN<G5R35MW<&)R=6I:1#]D9'AA,B5-;5-G:4E@7&M<:W-R<FYN
-M6E!J6DEA7B4V:&!%6'N":#8;("LP8FMZ@GIC,B E,&!K9C8V:')F.41Z?8!I
-M3UIB<GJ"33E@224;17)R9FYF:W!%&R5$>X9W8%IK@FA) 40!@ #^?VMN@V!;
-M<FI-6&IZ8DQ8:W=C:6EP61T;27)V:3P5%3]W>FI816)P6FEF-EM6/" Y;UM%
-M25AA<6@^-C!::%E/;W=F>GIR6C\8#BE::FI5&Q4526)/8FIM;4=,<GI087)P
-M;CDM*1LY<G)Z:T=B8V)@6$]C6F-J7VMX@%P_-C Y_C]R@G)K6TDY8V])+5EZ
-M9EYF:#8Y=8)C36]H6VEA13^ <C8V<&,G2&]):W)C7&->;G)K6DE98VE+8F]"
-M*3Y6-D1ZA')$&UA9)SE-9H)]<F->02 ^6V M(D1)/R4V:VYR:SP;)V:#@TDG
-M64DI#B5G<G)P8&MX9CL[66>"?7-C6H)@)0$; 6 [6)I7GII8H)R5FIZ>FM$
-M8W-K3&-W:V$I(%AR<FM9,ALV:GIM85AA6T59<UE;:%4[/$U$,"T^8W!K7S\V
-M7FA>-D=K7'I\<F,[#@X;6&IJ;3P@06-I3&)B<G=81&):1%N =7)8-CPM/W-]
-M>G)C6ED#8OYH9EQ/:6MB9G5W6TDR$AM@>FQC8#8E6W)P246 :$U08" ;6H)K
-M3U9,37!W6%IK=SXV:&))6&!%8VMB6EM;;GIR:DD^3&E@:7MH.R<^+2UPBH))
-M(DU9)2U)87)U<W)K83])868V+3\_*14M8GI[;RT.#C!B>TDE25PR%2!8:7*0
-M=V-C:VE)3VEK=79\<%]5( $. 2T _EEO7G)B8WUS35QR<W))6G)?)T1C46!$
-M26MN:W%/1"DV:WIQ8F-N83]89FE>:UI+6&!)-B @/U9C<EM@:F)%+4EI8G)V
-M=W=I.RDV8&-::TDV27MR34U9>W5<:6,V+V-V@G5C/U5)6G5\9FMJ35MC24Q_
-M=VA%6&-J8F9[<FE$"?X5-EIB7%H\+4EK<G)B@G!,6F K$BUC=VA@-CY;8%A-
-M8F]K36!(8&1,8')<:FMC7F9Z<VI$(#EA.6)Z<F-)-B 83(^*<%E+84D_36-H
-M7')Z<F=;66)K6$M96#8I*45R?7<_(" M1&M>+3!>1"DO15M;>G)C8DE%6FMB
-M8F9[>&N"7B !%0$@ +-9<FMS;%MH=V V*45K:$QC7QL;,BTV,E: 8EYW1"T@
-M)6!R;FE:86%86V-C<GI@-CEI83\#(/XP6F _;WIK1#1):6IR=7)R@')98'=F
-M1%A)/TEO>DD^37)J6FMJ1#LY8H-M8D])36IL=5Q?1$1@3#8G6EYP:590;7)B
-M<G)K7B 8,CY%6EH^+5AC8FMR@WIA6FA9*1@Y;UQ8/S]86DD^16)R:F ^5F Y
-M6H)J<VQF:T1C;&$^&S_*6"5,9&UR:4D@#BUY=79Q.45S<&)B9TUB;G)N<&QC
-M8UIA6VAP7C V8FYR:$M866AL:$DM,CL\25M;3&9U;UA%/EAP7T5@@()V9U@!
-M- $R /Y+241J<%I9<G I&"5-<EML<$DI)2D5($5Z:FJ 8"L8(%IZ>W!;14E%
-M6G%(:GIO+1L^6$LM*2LG640B8HIR6$188%EJ:VMB@WUC<H-R2$E%/T5Z>TE$
-M:&9C:EQC14DB6'IF65E%3&IF:VM8+3EB240V+1U-?V)-9H)F<6):8CNI&#M8
-M,$1)+25>:4],>X)Z:EIK<DD@+6]:-CY88%@_-B4O35I-86-I6DP$<M-<:TUC
-M:V!5,C9>+6!;8FIL21@.(EI-6U4=/WI\9EIM8&!<8G!X>V-?26%A8GMR7#])
-M36-G:')C<G)J8E4@%2UH:6A8/W)J2UD_,&]H/TU[?7UZ<@%> 44 _F$_&S98
-M8EA9=SL.#B)B8G> :5Y5*0X@26EC:G9I-B V:7N">FA:23\Y6V-A=W-5-#E8
-M638V539+,A)$?W);:'-K6EI;8SYS>F-F>G5C6E9)+7F*:UIB7&MK6EM).QM8
-M=7)-13]8;FEF<V ^/F!-87!+("5B:#8Y>W:!:%!A1* V25@Y.S(8($E:.2=P
-MBGQB6')Z:38Y:%HM-F-P83Y).P,EU"UA:G![:4UB;GMR;%IJ>FM@/S]926!C
-M:VMJ21@),EXM+2 )/W)M5CEB8V)<.6EW>FM956EP<&I<>FA$.TM:8WIF7GIJ
-M;G Y#B5B;VA9/VM@,$DM$@-)AEEI:W9R>P%W 6( _EE$(!4M;FE;8EPG#@Y6
-M36=J4&MW51@@6&!:6G)C+255<G)U>GMP86%)16IP>XAO8%A@7S8M7%I8& XE
-M8$E8:WI[:UI86$EC9VMN9D]G6F-)%5E\@G)<8V)J8F!)/C1);G9-)TEB:V=F
-M>FIB6D5$38!K5#)$7R(M8FV"<F(_6,-;:&MI62T8-#E;5B)@B8IO6G*(=F!:
-M6UDR+6%Z<DD^230=#AM)3%IZA5H_7H-Z<F)K>G5K3$551%A-8')Z:%XR/V@E
-M PFZ(F)_8#E?8FAH25AF<E\P26E@8V]0;V\_-$M:;X-H6W)K<FL[&"!$8VE/
-M7F-8,#8@&"4;(CYC;&A/=0&) 7L _FE5( XE<(5P6V!>.Q@M66--,%AP7AL8
-M/%EB8'=+)2 [8V-B<GMK7G)I,&)B<H)Z<F9:;3(V9F%91$0\1!LP8FZ <EI6
-M24U;6F)U:FM$1&(P"3),9'%<8EQR<FM8)S9C:VY6)39$8%!9@&Y_<D14.VMW
-M6V%R:T0V25MK8W)?/\-->GQS8EA$6#!$;"(P;8)Z8&-]9D5K>E@M($EZ<FM9
-M/C(."2!")TENA8IK<GUZ9F)L>F9Z>F P)UM3'4UZ8')N@&@@ Q6Z(#9K@&-@
-M145N<$5@<5@R26-83'>(>FM$("T_8WM@.5IK>F\\*3Y815AD8W!:8%A4,C0I
-M*1(P8TP^30&" 7\ _G!9)Q@M9H-W6EM88$$5/EE)66%A:%4\1$UJ8F Y6#PT
-M.45:<G-B37J 6$]:6EQ;;U\_6"TG6FMH8%A>7CP_8W)Z<EA83T]86VA91W=J
-M6F%5-$MK<FYB.45RBGU9+2)B:FMO7DE)6$QB<FU]<DQC6$UJ6EQZ=FE%,%M-
-M/D=C/OXY<G)C<&)@:$U5:#]$6V):6WN"8SE@>EHV-DER;FII5"L)%2<M%4E;
-M9H!UA7UQ9F9[<EEI@G<^(%9()4EJ2&-;>G R,#P[*R5->V)9/SYF;SY8<&A$
-M66!C:&:#@EH^.24[6&)8-BU%<G-5(#EO13]J;GI-8W!//C\_.RLM23N",CP!
-M;@%M /YH8$1$/FJ#@FQB8G)L/$M81$U;85IO:FE::&@V&TE>+2 V6')P6SEF
-M@VM@7&A%/UAH65A",C]C=T@Y3W!>16-K;G!)6%A)6%A@33!><FQR<$1;<X*#
-M:!T;6HV*:C88)TU(:6);641-;V9[?6([644[6UMC9G5U<V!97BT;6&+^6W!-
-M,&!J8EI,;')-3'I-)S9K=6-$:')B6%E<<GIB6F8\&"<P( XI-CY-6XAZ8EQK
-M<G)O;G)K8%A/6VAB:F)P:FI<;3\_6#(@38!J35I-:VD[/V!U6#8P37!(<GLV
-M(C8E+4E:238M56R!;T1)<EDM26R*145M6C9%34Q>1#])@D0Y 6\!2 #^3#Y$
-M:%A-;GIW:VIS=VA-6TE58$U%8WIZ9F9I-BE)6$0R.UAW8V%H<GMN<FIJ6$U:
-M8FQC8#X_66I8+3!P83];<FMK3UI83UA-6& ^2%I(<GI66&9]A%\2#C9]DHI9
-M)2D_14U$65HP/T4W:X-G16D_/V)K9EY<47)R35@[$D1Z_F9B/C]$8&!,16-R
-M3"EZ83(W26-/2W!K8FIK:F]Z:D]H21@8(!@5(#9$&RU[>EE:<$]F?'59/V)[
-M6$US6EIJ<H1Z6FI5/EH\&S!R:FIG3%IC/B4Y=W ^+41C8X"#52DM,B(Y6#\E
-M&SEK@&)B>'IG+25)A5\Y8DDI25M'8F9568)93P%P 5@ _F!).6-W23(_:W)F
-M7FYW2$U9/F%)26%N@G!:63]A?4E+7C]H=V)@9G*#>G: <V!@7TQF<G!?66%J
-M9D0_8V!%87AQ:VE;84E95EEC:5D_)UAB5CE;@H)X01@R:X:*=U@_66)@+3]A
-M23LB(E9U9S]B.3E6=VIL:45::EL_&PXM<OYR6D1@669@2S9$<F])>FI%24E9
-M-C!<:F-R:UIJ>FMC;5D\,D1$-#1)7!(@:G=(8GU:8GIR:#Y!9CY$?V@_35EM
-M@H)O7$E812 I8%IF;V!I:%0P,EIB55AA8%Z"B7(^)3PI-EA$%0X524TM1'IZ
-M9RT5)VIK6F]A)39@8%E:34F"34L!:@%W /YR6#]:>F\I%2U96#D_=E8^6"TV
-M-D]L:GIZ;3\I8G]-/VD^1')B35MN@W)C>H!G340I3'-Z:V!A6VEC:&->/UAO
-M:F-C65@^245837!P6UEH65@E.6U]A' V2V-N@GIR3TQB6"=8<H!O23]F:FIC
-M9CX=)6MK<W=-3&MK6"D8)6+^7&)-66-Q;'!--EJ"@WUK23\V23DI.6)C<W-K
-M:GIF8G!C66!J;VE?:E8.)5]R2T=R8V-J;7-W6U@;+7=Z8EI?8FR,>EI87DE5
-M26-P;VMB<'!@55EF1&!J<EM,>I**;SP_1#]).Q@.#A45#C9Z>F)$-$1H65AC
-M<4D^3VE66F]8@D5) 4<!;@#^:VEH:FUZ5"<@+5I3/F)-154M%1(M3%IR<V\V
-M*6)I+3!Q6"U)/C1?9G);25%M=V,_)3EL>GIK8&!?;W!?845:;FI@6$D_35D_
-M2$E@>V=P;V9G13EH;7IR145-8G)U>G):;%@I16Z*@G5K:G5F@G5<+1LP47IS
-M33EK<F)>,C)8HS=913E86V!R<S\G8HI];EM/1#]$.S=A;FQR;6YR8DU8245R
-M X+::W)M&S],8FDY6#E/8&)U@W->"1A%;G=C8VA/>G-%3%A)5F!9<G)?67)R
-M8EMI:#9?>H)I37J2DGI;15A88#\T.2 ."0XV@H)J24MQ@UE88VIO;TAA.3EX
-M<$5% 6@!60#].6>)BGU[<&8V-EMK16AB6F V*RLT+3Y68F \26!@)25B9BTG
-M1$]F>H!R8$UB<G!9/$MB;7MR:EMA8F)I64U::W=L8%Y)8VEA/C9%6%IJ8DQ8
-M:4UI8EEB9F!)6$U;>X)::FA)5G*)>'5N<GID<F9I850V7V]:25AC=G5R:$0#
-M6OY5140;+5IR82(Y>GQN=W!C52TE(#YO6F!F:W)H22T5(%F">GUR9'(E+3]8
-M8DD[)24[1%N";E\Y*2U$5F!B:V)W<D1)/TMC:%M@<EE:<EI)/F%9,DUUA7)>
-M;HJ&=6!;6%AP6EIX52 5#BEP>F-%27*&:# R8&9Z:V<I)4Q?)R !=P%$ /X;
-M.7J%?'UZ=UAA;&H_8F]08T5)6%LV24DW/S8V3VE5-EA-+25):6YVB8)P3$UC
-M:$D^36EJ=W)C3W=K16-@.3!:>G!S<6%I<G);/UA,.4U%-C9@8&IK23E<8%E@
-M/CES<S]B8C Y<H5\<F)L@G5U<V]B24EJ<$D^35QR>GMW:&:L:EEA6"T2(#9)
-M8T0P8FUR>FYP8#05,DE834E9;G):6!4)"2=:669:/U]F/C8#6M$Y6G)J6"=9
-M86AK8VM-241K8EI)8#\_-DEK:#X_<&IB;VA>-C8\*39;=6YC9'V"<FMK:45K
-M;7)R<5E!,"U@9EM)6W=]=TDV6V)U:VQ85DU8+2 !7 $V /X;)5IU=&YF>FQK
-M<FI$-W=R8V-K;UA88%@V+38M+4UI66$V+55A:F)0>H5[5CY96$E586)9:G]C
-M38%W36%C-A@G5DUR<E%W?79;66MP33E)23DP1%IK6CEB:%IC7S]@6C9P6"4E
-M375U;6AG=6UM?7I9,FEZ:C8V7V)G67=J9GK^:EMH8"T@*2 V8#XE/DQS?6YR
-M8#(5/F ^25A):VI%5!4.%2 ^66=B5D5U<TE8:&)-375S6S Y36J(>G):8W-I
-M84DV=UM8-CEK7QTE8FYJ9FMW7C9$/"5,:D=::FUB7G)R:$UK=7=C<'!87E]@
-M35L^3WI]<G!86VQZ<F9R<FE:@E4R E4 _CLV26AJ:V-S:V1U;SX=7W)C:G-[
-M6EIR:TDE*3(;-E@_3S(V6X%_:UIF@X!--DE8/TU@838R:ELR@7I,7V]5*1LM
-M.5QB37*%=5I;:VYH+4EH:3\_+45916)R:V-J8%\^'6A@-C8^66)'8W=F:VYU
-M<E K8WEG+2=9:E]%:V):<OYK:VAB6#Y)-DEC6DD^+6-[;7!-*2!)9#X_7EIC
-M7%9@/S)07F!C8FIW36MZ8EEK:F-C;G5R8%9,8FIN=3E,@F%8.5AR<G!9+6)@
-M*39J:F%I8G)8,%MH-D1:1$196SXT:VI@8WMQ8EIL<$Q:8V!@6SM8=7M@<F-%
-M6H%R44QM>VN"6!L!-@%5 /Y%238Y6UEC=V)B<FI@-C9$3%IB<F-K=7)O53(I
-M(#QF138E-C]H@()B6GJ"5ATP7&!).5E5/UA5+7IZ1$UW<%X@+61B5DEF@G5:
-M6G-R6BT_:W)U9B4R6%]J;G)K9G)H/AMC8T5-340Y)3!8-V)N:FYH6F)D838M
-M35I$36-L6UO^8FIJ8VM@24E8:FMJ5B4Y:V-K6T0V5F]<26%C:F)::W!,26]<
-M8UIA<DE;=V]:8FMB6FMK:FUR8F)-7')N8'5%-D5;8H!N<UA823Q)6DTP6%9C
-M6"U):G!C:&A@65@^,%MC3V-]8$5-8FMB24D_6FI,6FUY8V)@.5E[:SDI17)_
-M@F8R 38!/@#^:7)F1#8E)4UL8TE)<&<^/V%81$U/:W-B;G=,86LP.6%8/T$@
-M)3Y@;VE-64DI(&!J:VIB47IT8VAR:3])>H!9-D1)/R4M8GV%:SE,:38;7GIR
-M:TTM1#Y:8EIQ@H)R4#XM<H**>F9I7S0@,C))6D]-9H*"=V@V'59@,BU:<G(P
-M_D5:8UIB8F ^-D5ZBG)9.5!B65M-2S]$8G!<8UM<8D]N<DD_/C]9<F];6%MB
-M:F!)+2E86$1$?8)C145@=GMB)2UH65IB169Z;V!+36!9-EMC6F!@6&J(<TQB
-M@H)Z:3LP6&=R=6E)-C!@:&A5+2]@6T5;:VEB6V-R>G)@/#Q/9X)R:@%N 6D
-M_F9W=VM$(!@I3U]$6']P53Y823!)2SEB<G)C*3]O22=-6#]5,C1$/EIP8FA6
-M,B!89GIM:V-R=V)P8E\V+6J":DE)62T.$E9N?7I,/S\E&UB"=4U))38M24T^
-M66Z">TD;&UIMBGUR<G=I/RTM15!?.6*"A7UR/RD_8V%;:VIN8)5+6&IC;VIB
-M/S(E675Z<EA68F);14T#8+%B8FM/6')B:FY-5DDE,&AZ;W)K66IJ32 @7&%-
-M6W6%8#8G6G5R61LI5DEI8$EB;FMH V.T:TE-8E]/24URB' P.7-Z@H-I-CEF
-M@G5W22TR6$U-8%@^.4U%:FI61%IJ?VUU:F%-6%I;8@%P 6, _FIR>G=;1" =
-M+59::W]V:5MA13)%7C(V=W]9*2589DE86T5F1$EH35!L;VY@1"U836I,67MW
-M>E!W;FI$-F. 9FA863PP)6-]A8EJ2S8@(#9R:C!-53L[8%M92T51>E@5%3EK
-M>F9:3&)[:SX\/SDM,&*"A7%R8U4_/F>"?6I9:.U@36IF=7IK8$E58%E9>FIH
-M8W!@-BUB<G5F8G)H26YR:VIB8385%41R;G5Z6F)W@"4@8VQF676*66 V3&YK
-M:3]>:$UP=7![6V)H1&)J:VEB:&!8/SE<>G)@2V!B>H-K/R4_=7)Y:#XM6#\M
-M/UM) RV08H M)U]@34^ <EM-:W=A.0%H 6\ _F)U>GIJ8308(#9-:X!R:6-L
-M224M/S(P:HIO.R P6FE]:3EJ;VEP6$]:6H)K23Q615@V/FYR:UIK>GII8W)[
-M:& ^.6AM2X"*A'QR8U9454MJ8S\^6D]$8&)R:UDO658R,"=J=5Q$+3!P8CY@
-M=38)%3E[A6YB34D['3]U@G=:8_Y6-V)U;FYF;U]-8VQ/56IO6F-B-AM$:FUK
-M669Q5G!K:$]J<#L.#B5)16=W3$EFABT\8VMO1&J&;6IH8V)(;T58=&!R@6]U
-M:%IG+3E::W!$34U)8&!,:UER?&=-:VMD:5H_3&9U=6I86UA+66AA1"42.6H_
-M(#E$&R=O<CDP7X."<#\!/P%; /Y:<GIZ<G)5(" ;+59K5C]+8UI)/C!;<FIP
-M35HT)2U);G V1&UO8#E)5D1R:UDT34U8/C]H8EHY7VMU?7I\=VA@/S9::V%F
-M?6YF:EIK:G)Z?6],7E9@24Q/?8-W7E98-UA)8GIW6C]58S ;.6I<(!L_<H-U
-M9S8E.U1):G5R8V"&14E:=75Z W+W1%AP:2(Y8TE9:UH[6%EJ?V)J<E9;:G!%
-M16MG*1T[.R4_7R<V:GHV5&MC63=,6UMR=H1J/V(_+4QR=8)O:VIK<E0M/FAX
-M23DM)4EH6G!B;8AZ8VM:/W)Z:38_37*#;V%@6V%C;V \("TR8D0Y/"LM6W<M
-M&#!R=5X!, %) /Y9=7)B6FYN1#PR*T5834U@:VMJ5BT_:V-K8V@^.2 E37=)
-M,%]B/BT^8$E:8#\T36%;13]@6#DR25IF?8*%@&),:'!I8F@Y241$3$1O:EQN
-M=7)(:')O:%A$:7AU8EIA2$5[@H9Z6T];<#LE*3)T7ALP66UU=TD;-F!'8FM/
-M9TG8,&EK9G)Z?7UF85MR>R5!21TY;6MH3T1/>GIY>FI6:GMI,%MR22TY23(@
-M23(;86]:5FIJ34E%)TQW?89[6UI8.SEJ=8-Z9EIK>F<V+5]X6CX@%2U?5DU@
-M8@1RI&$Y6W)J23(B2'IK8FMB2%IR=UM//SE@8#]/7C9?@&Y$-F-R< $M 44
-M_F)U:V%83V-@5F$T-DU)/D]K@'UC-C!C:V-C<DTR&Q@^:EA6:&([&S]H8%A>
-M-BTT8W!824\^)41$:&-U=7=[:UIK>FIB8CDB+4E%-FA?6UI::TU;:D]J:TQJ
-M?75L8F-:.5YT?75L8UMC6#8M-FAR62M86F9Z<D]H:DQ$6D1:6/XM36IJ9&AU
-MBEQC9G*"14A8*2)8:FA8.4UZ?'5]@EM;@HA?66-B8%9C;B4^/!LY:G!B6VI;
-M6V V.7*"@G);8V-F6&E;:5E6/V-Z=UD_8'=A+2<5,F8_,$DY)SYO>G!)6%IJ
-M83\I-F9B:VMI35MR>FIJ:&-C6B(P1#!->GI@.5F":W !- $_ /YI?W)K:VEB
-M14UR7BDY82TM.7J*<EDY4&):8WIW1"D;26A?:H-J23Q@<FIQ83\\.5IK:VQH
-M23(R56ER=UI;<G!K;7IK65I)&QM<9UAI6FAH1%!J8F)%35HY7(IR;G)S8C]%
-M1T]R<FE>4$TY*5A6<G))6%E;<X1W>GIH1%A<+W?^8E]B:V)3>H9:/V)Z=58P
-M/BD8275:/CE%>GM(4'MB6G6"<F-/86)8:G(V2$0[/EF!<E!B:&!I6#!J=7I[
-M4%!C:&MK:FI$24E89X!8241B6!LI&"5D/CY8/!@;8'IZ<&A:8FE+9F!>6F%@
-M:&AR>WIR<G& :TD8&!L;.7)B.3 Y@E]P 5@!20##9GIK67&(=UI;:G!>2V@[
-M*259=7IR6%9B8EMKBF@[+4E@8&9Z:DQ;<'IN@7-)/S])8%@P23\M-EAI=X!-
-M1%EB:5!R;P-)_BTE+4UK;UI-8V!-:G!C65E)(D>";6YU9FI$/E9:8G5]<FA-
-M.2<^.4QH6&)H3%Z#>GJ"<D=621MR=6)97FM<9G5S5D5K?6I%5"4.-G)W.24P
-M:W]),&)C<G5Z<FI-345)8V,V6FAI:4^#?4Q::V-B<&!J8G)]9EIH3%MB9FY$
-M-J988$1H3UE96DDI(!@I5C9I:DD@+6=U>FYC:6%@-F!J8$Q)/DE9:@-ZD6UR
-MA8)C,AT.&#]K8D0^.3E? 6(!6P#^9VMB3&:"@G5R<F9F8FM@255@65EZ:FAC
-M:V!8>F\Y,C9)7W=R8$QJ<VYF:7)A-CPY358M,BTV668V4()P33 P8$5(:$U-
-M6#LI)39I<EI:8V!86FIB6FEI*2=C>GUV8EY8*59K6V9]?6YB3$M97E8_.6N"
-M6S]B8UMK<F)@225:_FIJ6EAN=5I9:&))6X)R:FA/%1):>E\R&SEB/BU8:FUZ
-M=69U<DE%:7!;-D1R;7=6@GPY25I?1W-K:$1B>FYL8F!-6DUC/R4Y84];:&MH
-M13]F:S8V6#9@8TDM17)Z@F=)8VIC/D1O32U)7#8P16YU;EEN>(IS7"D8(%9W
-M8FAB6X)96 %- 5L _FMR85E>;GUU;H5[9EYF;U]-8VE/5FIO8&-@6X)R138E
-M.59J:U]-:FMC;UA9:$E$-EA8-B ;&U9?)2UK<G!5+45936MH6&!%)14E87!:
-M6&M964]J8UAJ<TDB.6N%@V]96#8^4&E;;H-B638Y;7)H(B5CBG59/D0^,&IZ
-M>G)8:/YJ8V9S>WI;35A-.6.'9EQ/;2T5.6)17"4R/B451&)1>GIB;&I,27!P
-M:D0R8FYW7WV%.24B/CEB86-)2&MC7D1I84DK8V!526%;6V->:38I8H!H/C])
-M544^5&AR;7)6/&)R>F@Y8C\;+5A$-C!:<6),8&Z)@&U0-BD_:&-C:$V"5EH!
-M-@%( (U$:FE866)Z:UQ]>F)J W+^1%MK8S8Y8TU:8BER@&I?.S!)6EI-:'!K
-M;VM83'!I6&%L8#L@%2 V53Q$64U;=V9)65MC:UAF21@.%4E987%X6CER<EIC
-M>GUA&QM,=75J63D[*2=,6D=R8CD;&TEA2 X218)]<CXM)25-=8IU:F]R8V)U
-M?8=S8$DM%3EZ8FAB\&)@0DE-3VE)/CPI(#9H17*"@G5H24EK:FII-D1RAG)M
-MBDP2"14M:6I;6BTE,CY%8G)R:5IO:UIJ:W)K6V(V-&%Z@&IC8$@M+5AZ>G)C
-M-BE8;H6#6F!-/"TM-C9$8V-J6EIC>GQW:%Q)7EI@8FM),#X!.P$M /X;/F=O
-M6EMF;V)M;F)B?7UF86!K;S8_22DY6C!;<G)W;C8P2S8V8FIB<G ^,%]U46MN
-M8D08)3PM-FY@1"4Y:VA-85M$145J/R4K*40P.6N 1R>!:DQB;8)I*R5-<FIB
-M338I1$0M/DUI6TDI(#<V/AL8179M=CX;)3Q$37UZ66K^>W9N<F)M@W)H238_
-M6C)H@FMK<FQ;8W=P:$0V5#YJ25E\BG5@14EA8V9I,B)B?75UA7(\& XB:&YB
-M8#L2*UA51&I]>F-J<EIK;'MZ8TU526EW>W)R<#X;&$EZ?VY?)1@E1X*":FA%
-M22TM-C]A=V9B6VE@:GI]<E@Y6F$_8W)9@BTE 54!,@#^(!LY<G=;8GIR<FUI
-M:76"8F-F<GI)2%@M+44E/DQF>H-@+41+/%!P3&)H*14O:5IB:VM$($1N.QMP
-M;T0M/FEC3%]8238^8EA5-C9F+14^8AT.;V1;65%N339)<G5Z:E@\(&%K6#9@
-M=VE@7DM$-DDW.UIM8F(M#B4M+1UB>41;_GUF7GIF66)F:VE86$4;27)R>H-R
-M6DUN>G5<.5I94$DO9X!:.5AI87!K6"TM6G)J=75]=#(.&$EJ:G=H(!M):&)Q
-M=6YB:FI%8&J"@F(^6%EK<FMK>H)8&!4R7G=B13 .%2UQ=7IP36 _+3]8:75]
-M<F=W7$QZ;G)?-C!)'3EO38(M-@%- 40 TRT8&TUJ6FEZ:F)J;&)H238V26EC
-M8G)O23E%-CLI8(*#<#<V2556:VAB:" @.UE96F)H,A@R8U4E:F])/DUK:$]8
-M8$E8240Y7S(;6DD;,C\M*5I0 W+^:SDB/WM\=6I,-"!I>FH_27IZ;V)A24MI
-M.4EJ>FY@*1TT/#(I7V(M7VQ:8GIZ9FY>8V!816Y@-C)8=VMJ34UK;75K36!J
-M7U@M27)?+4UP8V9X23(_8V-K:FIR;5\R(#9-8GQW)0X;-F)Y<FMF:&\V-EEU
-M@F))25A@8TU9:W)BJD4T-DQB:4PT&#Q@<G)Z<F)@-ALV25IB9GIK<#XP8EI<
-M:V _.R4^8DDM, %; 68 _E4M-EY816)Z:$UB<FIW324@-F!06G*(;UA)/S\E
-M27J":C\V.41C<'IR:$])7EI9:')I/" @241)=W!-/TUJ:UE)6$1-6TPV23XM
-M.6@[.4E98%A$<GR!>E4R+6MU=7)-(A5-;F@^+VN"<DQ))TEW,#9%>H9K23)%
-M:5Y)8#DE;^%J65IZ@U!-8%M-;EY:338M6W]B:TQ8:V)C:F9K:VIC539,6#Y%
-M<FI<>U@_16E:36)J9F9J5C8V/V)R;S8@&!56<FUJ:GJ&6C]B>G56,#XR*4EJ
-M7TE%6&%A64E-:&X[&TEB W*<9EQG.R 5)3E%1%QJ<EE56UA,7&MI6"U<:%A4
-M-@%% 6\ _E])6VYI86AR6D5J>G)_>#P5-&%>-C)J@F))+4EI6&Z#>G!A/CM@
-M46-C36)K=VI66G!W:$0M+2 ^@GIP8V-S:UM)2S\^8FIW8E@Y-EA8+45J8EE+
-M;H-]?4PV56IQ>GIB,#E64%DV%3YZ@FHM("UA1#85,GIK.4DP,$1H:#8;.?Y:
-M6$1:>F,Y26A%7GMZ<3\;-GIC;EI-3$U@:UQR<F)B.2 R)1@M9DPT8FI@-UI<
-M-EIC9G)F645)6%IJ;UA$.S)C<G)F<69U<U9%:WUJ150M(#9R=TD^26)@63\V
-M6FM>/S]$6F-B7TUH9D0@(#9)3UEB8DUC:%E,6FIR6#!;33F"23X!+0%6 /Y9
-M6$5-8GI[=SX=27IF>H!$%1M$<#L2.7]W-A(G8F)L@WIR<%AA?6%6/RE/:WN(
-M;4E;<FMB840I+7)Z@G)F?8)H/S\V/V!:<FIH:%M;5ATE6EI%8&IQ=7UB,%9L
-M>G9V<DEB:$TW238Y9H6#8%5%66IH,BE-7S!$9CXM6FY@,BG6/UA)6G)A.4EO
-M63]:>H)M($AS9G9K238B.7!F>H-J;3XR,A4.$D1F14QR;T5);C\M/G)Z<F-?
-M239+8F)6)5IJ:EI8;G5:66AB25N"<FIH3R E5G5O:58#2:<_66MH1#Y):& _
-M*1LV:VM8/RDV5EA'<&]86&9K;VA>:V@V34DY.S\!50%/ /Y@:UDT1&]Z>DD[
-M-DQK;&M9,C)C>E4@)6)W/R!$2$UC>GIB8E@_:G)A52LE16:">W=?7&MC<&D_
-M+6)Z@GIF=HIW230M/V)B:V)J:F)Q:"(5,BT^:F)$8W-C/T1-<FYZ<V-U=6H^
-M22T^:X:)<F)56&)S8#P^8%IH>FA66G-K6BWH-F!B1%M:/DUR8C\V:WIK)25:
-M;W)R;UXM+4E';7AN?V P1$$8#BUH5DEM<FA)8G!4/V9<;8!K8#])>GIR6&AJ
-M8V9S=G5F35A-.6.'9EQ07S8E/F1F:V)<2U8Y37ER22U$>V$V&Q@M8&@#294Y
-M/UE-6G=P.5IR>W=H7G!@5EI5)S\!=0%; /Y/:FQ>26%<<E!I22E;<#\_/D]Z
-M>ED[,D]R;45H8$5/<GI,1V Y6F)?:F @)3EW?7IJ1UEB9FM)*4UM?7IR>GU[
-M:30T16)G;VIB;F]U>E\[/"5%<EE$:6%/6&!;:V9<8VYU@GI8+1(I:'V%@F))
-M16QK6U0Y33]B=6)0:'IK:27+)5AK.3]-15MZ8TL_8W5A030^35Q9;UQ%/U99
-M=VYB;7 P268I&"U,:%E::V--66IP3&)07'IU6CE6=8IU:F]R8V)N<GIK8$DM
-M%3EZ V*R6DD[/VA/:W-K8U@V1&MI11LM85A5/#1);V [5FA@15E96FMP)TQN
-M?8)J7FMK8F!+)2<!@0%I /Y61&ML8VMI:%MC8#Y9<"T;+45W<EI6/S99:UMH
-M:%E8:GIF14P^23]$<(%<)2=B<EQB8#E0<&D_)4EH<G9N<GIZ<E@V26)J:VYF
-M9G**C()C:#]:@FM68TL_3W=N:F V26I]A85P*0X@3&IUD'=$)6IB1&E88"\Y
-M2# G37=<83G^&S96.45$36AJ341A;W):5G!?/F),8F)814AK@W!B9G),36]+
-M-DAS9D5B<$4Y7UEH6FIO;6UZ:#!):VLY+6N(;TU86UA+66E>-B56<EY%240[
-M.V-+8WIV<FM@6&MP9C0I)2=8:4EC>FD@86QI154_3V)K/T]<<HI[8FIW;&-$
-M@AL; 6L!:@#^9#E-<5IBA7=O:G):8G<[&"5);VI:65Y$14U@2%A)1&)M;V _
-M/#(@)6!U=U9"5EI%36@Y.6):/!@R2VEO:VIN=7AB-C988&-N<EQJ?86"<EIH
-M4W5V<#XB("]J<FI$+55R<'J#?UX@.VE:/WJ/3!LE239,8G)J9%DE%25-6$18
-M_E0Y+256,D5P:SXV8GI[8$E[=V%R;V)06TD_:GQU:V)R;F)K;%XE6F];6VM8
-M.59@:VMR<G%B:G)9+7)L63YG?7IL6DE%-C]K:388(F)F/U5@8&%82VMR;7N#
-M<EEB>WMF6!@8+4]A<'YP,EMJ;TU)1$5?:F)@676%@F)0:F)B88(R)0%8 6@
-M_FM).6MG8(%N8FIR:U!K6#(M8VIC34UO;UMA:UI-/SE:8V)@/S8R$C)63W)R
-M:FM9/V%K63E)-CLR-D5C8VIF9G5W:#8V3TE;;X)-/W)R9G(_7&9B<H(^&!@M
-M6VI8+2)8?VYJ;7IW-C9@:"]-@G<\*4E),#]LB8-X64\_1%M84/YK6S9$6#M$
-M8F]$-DQR<FA88F9O:H)V8&!%/FMZ=&U;:G)Z>GMW-#Y-6VEO84E)36MW;FUR
-M6FMR?S]X8$]N<G5V?7)@6$0V<WA)*2M)33!C:FIP-F!S:UMZDG=/8WJ"=6Y!
-M&#(M2W"">DEL<FI9-BTM/W!933EK?7IR8$E$9W>":%4!+0%- +IA6#!6<GJ"
-M<FIK;G)C7TQ516)@6F!-<6U-37MZ:4(V8%Y?7UI>,A@I23Y::W)Z;TDY3&E@
-M63\R)4M: V+^:FYR>F(^/U@V-DU[:DUJ;U!S8F)R:FJ#<$E51#Y812TE17)]
-M:EE::TU).5E$)UEZ6C!-:F P1'J">FIK<&$Y6G)J6"=986AK8VM-241K8EI)
-M8#]:6X)R=8AK15IR<FQ8-C)B@GUZ<%\^375Z:EL[,&F(<F9O1$]B<FAW86)R
-MPW9N<G5R>G=)&V]W8#Y@838E5F)B:RT^8VM/:HJ"6%9J@X-U<$M?7DE!8F],
-M:7IP8S\I,B5%<$DM3')Z<7 \)4QZ>G@!( $E /Y6.2T^:G5V<G=O6FQP6DU8
-M16EF14E;;VH^/W9U;U4V6FI02#E8,C(K+3984&)U>G!$/F)C:4\R&S]@:G)K
-M8FMN?W)A6EL_-C9J>F)N:C]J@FIZ<FIU<E!K6# [/C8I26Z"A6-::EI:24Q@
-M56%R6B(V66)?-EAZ=61F<G!$377^>ULG.4UMB'IR6F-S:6%)-G=;6SEK3V:%
-M<D]@>FYZ8" 2)UMR8GMW85MU>V-:&QM;@GUR<EE:;V9J8F9R=79C:6-:7'I4
-M$EE]6T5;<5E):V-:8C8T3VE%1'J*:3!%?'MV<FE,8G(_1%H^6E%C;V V1$0Y
-M;V@_16-Z9F)5+2UC@H)Z 38!,@#^:38M26-K7E-M8C!-8TT^245I8T5%7FQH
-M6$V#;EI8&SEK8TDV/BDM+1@M8#Y%:WIR:%I?85%%22DV6&IN=6I>7FMR>V]B
-M:$DP3&)<8F1;:W5J<FYJ<FE-:V-)+2TI$B5-=(9U:V)(259$3$E(:F\V25A9
-M8D1$<FY>3UQN:V-U_GUZ8$\Y6VYP=3E,@F%8.5AR<F,P341J<DTP17=M?6L\
-M*RDY7SEB9F]C;GI[=PD2,&IZ=7IF8FIB8F%K?&YR:&QP:6MW7A@Y?W _27%I
-M3&IM36)$24MA65AQ@G V/F-F=6)@)T5P5#\\/%DP*V!H-C]I6W)J35AJ>F),
-M6#\M38)Z>@(^ --F5"5):&!,35Q@+3!,,B4[26-8/UAB:U]86GI]8E@I+6!P
-M65IF.3(@%2EB-CY?:'%O8FMI23 [*3!-6EMK?V]:3&)R:F)B53\V.TU$8G)R
-M9FIZ;P-K_F)B7E\R.R )"2UF<G6">C9%;UI$+2=/8D5K<F)K8D1K9F!-,$1B
-M6G=Z;'6 66M%6G5N8'5%-D5;8H!L23]$:VM$(")@;'IU<FA@6$DV6#]:3411
-M;H,P("U6<G5U;7J :EA@;H)V;FQF>H!V@&,8&UAI-C!:@&]::$U:,&%92:I)
-M:7)M>F-I:4AF<UDV66E)+2D\:3XE6%HM+4UB@G)6:GIZ:T0Y24]B<G(!,@$M
-M /X^/AU%;VMC:&-I7D5F+2DR-DTM+6]_:$U,8GJ%>VA85EIJ65ER8$0T*TM@
-M-CY/87!P8G)_:#8E,#!I6SE:>G5J5EIB9G),6$DM)S8Y8&I:8EIR<EQ1:FYK
-M7E\V-CL."1LG-TA3@$4P66]A/BT^.3MS>F9C:EIP:FI,)38V,&+^6SEDC7]W
-M.41@@XEN-BUA8V)Z<EI))SY0;4LV7UE/<H)J;UH_-FA@6UXV,$AF:&!@6FIB
-M3&2!BGI--W)Z<V--3WV&=GUP/"DY7U E+WJ 8V-;8B5,6D5)<')1:F)J>$5%
-M<FMB:W<^(!LV8E8_35@R+3!C?7--9'V#<DD[37)O@F); 2D!&P#^/S(8-G=U
-M8VA;<F@_:"TM53LM$AM:BF]).5IK?8)Q9G1K<FI><FMI239M3S9%6VMJ;UI1
-M@'=8+3DI8V8V67IZ<F]B36N"3%@Y+3\_/EEB6%M-7&I),$1M;F)B24D^(# [
-M(!L;,')I2T1B6EM813(E8'IV:V),8X*":E9)*2!9_DDG1'V*:#E%8'9[8B4M
-M:%E:8E9-21L5/H%R:W)5(EEW4%EA-C9H<F-I7E5/6EIK<G!C.25,>H9[12UJ
-M;FM))S!WBGU]>VE>-D58+2=J:V!P9U!+8$4M/G>!;F)16G=C6%IZ>G)_21(.
-M&UII;G!?.QLB86YJ.T5U?7)).5AR@H)J3P%5 40 _F<V&!M9<DU)37%R7V([
-M)UA4)0D5,'IZ:$D^17)Z<F9R;&UN;FI/8V _<%0E+4EJ<FI6169B3S9$-V%?
-M.5ER9FYR8#EC>FEG*25)9EM;:DU::VIK5C8G8G)R:EIC8$EJ=V _1%]U>W!C
-M8TA-<DPI,$59;G]B+39W@FU_6" 58)EF35MUA6 V)UIU<ED;*59):6 ^630.
-M#B)B VKD21(M7T1,:$0;8H!L8V);8%LP16N :"4827)Z>F)%6VIK1!@I:X)U
-M?7MF:#8^:4E):4U$=8AI:W!%&R5$>X9W8%IK:$E$@(-ZAG P#A5$6WJ0;RT;
-M,DEW;S8P8%YB8$D^8(!J/P%; 7< _H!)*25)8DD_.4]Z@&9A14E?52 8(%9T
-M>FM$)4QL8EQ08V-F>FA$3UE-:%@I%1L_>G)F1$TY138V.TE8,%AB/UIJ7S9:
-M<EEL)0XE1%EB:CY-@GUW8D(I6&)R<DQ,2#!>?7IF:G)F:VIM=T0Y:EH@*41%
-M3'5C/REAAVUZ8"4@8_YL9EEUBEE@-DQN:VD_7FA-<'552QL)#B!)34P_7T19
-M7C8P6FTM8GIR6CY,6EHE%39J9QL88'I:6G)F8V-K2R M:WIV<'=L6"DO;W!:
-M:38B8HIZ:WAF.SM99X)]<V-:8"4;8']K;H-@(" V,FV2>C\I5$1:=SXM6#8P
-M65@V,'*"<#X!+P%J /Y_<G1D:&)8-B4I:Y!R8V!)6FA6.Q@;/VUM7SPY8DP^
-M+4E82')I/S998&A8/"D@-FAR;&AH25]$)2DM1"TV238Y8&!B;VM)8$0@*TM-
-M8E8;+7J*>FI,+3LV8H!C2S V-D^&>F-U:59%6WI;36IP4 XM6&IJ7%I)6GIU
-M:U@M/&/^:V]$:H9M:FAC8DAO15AT8'*!6&8M&!A$<&]?8&MK>GI:.T5H5EIB
-M5CDI*4];.1LM6F@I(FN -B=Z:VMQ8#8E+4]K>V-(:ED8%4R"<UDE&U9U=F-K
-M:4E/:6MU=GMP7U4@#BUB:5YZ:3P\-C9K@G):.S8_.6E--EA$&SY?21L_@F%>
-M 14!.0#^6EIW>G]R:#8;-%AU:UIW7TMH6TDI$BU:8E]F25]8-BU886)R;S8;
-M/VAP/S9>7D0Y6FMR=V!A6#PI(C8G*SPM-EA1:WIR<&E@,BE$8$PP#AMKC&UJ
-M8EA5-F"":TU-7B4=>FUQ>FU6-DUZ6T1F:V@@&$EZ<D\P6F)M<G!A-E1K_F-9
-M-TQ;6W)VA&H_8C\M3')U@F&(;SXE/VEH6FAK:G5Z<E],:&%H8#XE%2E)6& M
-M/FIB.R5R@S8.:VEC=W ^)39837)Q3&)%'1@V<FI)*39:7%MC8DE%6FMB8F9S
-M<&A>(!4@66]><F),8#!><'MW8F=98&AK7SE$4S9):&@R+8(V80(M /XM-FEN
-M@GUO025$6$Q--G):/FAO669$/UMO:F-B8V \+5AC>X-Q5"LV8'$_.6)_:$59
-M469U>6M;8$M>6#\T*QLV6$QC>G5W8ED_/#=H1"TP(%B*;6)-8V=-8G)B/UI:
-M.RER=&UZ<%A%2']B/VIJ;S8;-GIZ6"U86V)06V%:5FK^:DU)12=,=WV&>UM:
-M6#LY:G6#>'5\8UE4/D5866I@:V=R8F)J;W!U51@.&T1)8C\Y7S @&UIZ21M@
-M6EM[>F]/86%%8W=>:#8@(#]Q:U9-24AZ>V!;)2!9:UA)/D4[#A@8-#)9<FMS
-M;%MH-F!O>GIK:$UA=7)R=%@M,%9R@F$_@BM+ 4D!+0#^,BE):G6">E4M7FA$
-M33YB3S9:<$]B;TU-<H!K9F]J5C8Y37J%<FA95&AP24EC?'-8/SE(9GIR8F-:
-M:&M:9#P;+4E)3')W;6)$+T0Y:CXE,AL^<'-B16%L<'IU33!;6DL@3'IU?7UP
-M3$EK;V-H6V@\)4EU=6A-7V)H13E(<&);HVI;6V V.7*"@G);8V-F6&E;:5]'
-M<FMF=TTB6$QB.5E-5D5: W+:@5@2#A4^8&]?24DE%1M8;UHV:C ^<FUM:GIK
-M.5IW8TT_*2D^8UI47UA6:GMK5CM$66A:369A2RDT/%Y%2TE$:G!:65568WUZ
-M:EI9/S]W=8J%22DV6GIO7CM6 5@!.P#^1!LT26-R<E@M66):7V-H-B5)8$Q/
-M8E@Y8H)Z:G!P7%LV,'*"<4UB6F)R63Y$=X%J6#LM8'!C:%I:2&-<<%0M+3Y)
-M269J:EI?/EE$6%8@%1M)/V-@+45B<GA]:TU?8V [,EER;GR'8$U96VMP3$PI
-M)6*#:V9B8FIJ33!9@7)0VF)H8&E8,&IU>GM04&-H:VMJ:E\P8G=B<$0V25I6
-M+3])+25):V-R>F$=#A@M27)R:V$_-%AK:U@E1"4M1450;8!O.4UR;%M9/RTV
-M1#\_65]U=G5J5CY)/FEG.0-CHVEJ<7=B83\;-EAB6$DV.7)Z8D4_)1M;?(:*
-M:$1$16EC8$E6 5\!60#8:6!8:TUK<$D=16A966-W6B _8$587T]+6GUZ9TUK
-M8V9$/UQU:CE%.5IK83\\37!P:%\_35M)869%7V!,6DT_-EAF3VEB;%!;6FJ
-M>F=8,BU824U?-C]$9P-R_F-D<FI:23EA8VZ"<E5$16-S6C<I)4E]:F-B8G)Z
-M21U:@WU,6FMC8G!@:F)R?69::$Q;8F9N:#Y,9&IR7UE?6F!%1#L8#CYJ8&IK
-M9D$T1#8_>H6"<EE);WIJ52 ;138\-$EB9G)8;&YK86!A2V%)250P6G)]@VA%
-M,"TM8W=I6:5;6FIZ@8E[640@%2UN:4D^,&)J:5XY(#!$:G6";EE-25MB8U9?
-M 4T!:P"O@&]98C]@:5HV16A98S]B:$E):6!86UAI7G)U6SE,8V),245J<F!$
-M/U9;5DEI:6,#8OYH;V!-6V I26]@23Y$&SEI4&-B=4]C15&*C()W239)6V-B
-M25Y916J">F)9<GI/22T_8DE;@G)J:$\5(DUO+4EF34E$.6^)8"U,@GPY25I?
-M1W-K:$1B>FYL8F!-6DUC;T1-6UM-4'!B6F--5C8@($5H:%8T,C(;*U1,:GA]
-M>EG.3'*"<F,_,EDV13]:;TQ98GIN4&IQ6V)Z8F-D*3Y99GI?/D0I(#YC>E!9
-M6UIN@H)_:54@#B5A<$E$25A$8&QI.RU6:&9]>V)).3E8:$U8 5D!=@#^BG=/
-M8R4V5E]%8&I,:U@V6$DY8&!8/T]R>GV":#\_8VI@23];:F!6:&!8/S]K>G)K
-M3TUR@GIJ:VL_6FMK:$D\*3];8')R:E!B24EU?7V*;D])35IB3&%)&U"*BF9(
-M6GIW.2TV33ECAV9<3VTM%3Y?6%AB.2 8%3EP>F]F?84Y_B4B/CEB86-)2&MC
-M7D1I84DK8V=B:FMC+2UB8D]C8U@W24U:;W)H7E561#9)+3YJ;G):4&YZ=7IK
-M63\V56!I<F8_1'=K1%QI+3!W?%M8/%A98VM)+39;(!(V:%I86EMN>VYM<%DG
-A&#9B<$M)66 _,%I[<"TV6F)R@GIP5#!)6H)@6 %9 74
-
-end
diff --git a/Lib/test/infinite_reload.py b/Lib/test/infinite_reload.py
deleted file mode 100644
index 841ccad0b98..00000000000
--- a/Lib/test/infinite_reload.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# For testing http://python.org/sf/742342, which reports that Python
-# segfaults (infinite recursion in C) in the presence of infinite
-# reload()ing. This module is imported by test_import.py:test_infinite_reload
-# to make sure this doesn't happen any more.
-
-import imp
-import infinite_reload
-imp.reload(infinite_reload)
diff --git a/Lib/test/inspect_fodder.py b/Lib/test/inspect_fodder.py
index afde2e2514b..ec96eb7e435 100644
--- a/Lib/test/inspect_fodder.py
+++ b/Lib/test/inspect_fodder.py
@@ -5,7 +5,7 @@ import sys, inspect
# line 5
# line 7
-def spam(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h):
+def spam(a, b, c, d=3, e=4, f=5, *g, **h):
eggs(b + d, c + f)
# line 11
@@ -15,7 +15,7 @@ def eggs(x, y):
fr = inspect.currentframe()
st = inspect.stack()
p = x
- q = y // 0
+ q = y / 0
# line 20
class StupidGit:
diff --git a/Lib/test/inspect_fodder2.py b/Lib/test/inspect_fodder2.py
index 3d978cffe3d..bd7106fea86 100644
--- a/Lib/test/inspect_fodder2.py
+++ b/Lib/test/inspect_fodder2.py
@@ -7,7 +7,7 @@ def wrap(foo=None):
# line 7
def replace(func):
def insteadfunc():
- print 'hello'
+ print('hello')
return insteadfunc
# line 13
@@ -60,8 +60,8 @@ def with_comment(): # hello
# line 61
multiline_sig = [
- lambda (x,
- y): x+y,
+ lambda x, \
+ y: x+y,
None,
]
@@ -96,4 +96,16 @@ def f():
"doc"
return 42
return X
-method_in_dynamic_class = f().g.im_func
+method_in_dynamic_class = f().g
+
+#line 101
+def keyworded(*arg1, arg2=1):
+ pass
+
+#line 105
+def annotated(arg1: list):
+ pass
+
+#line 109
+def keyword_only_arg(*, arg):
+ pass
diff --git a/Lib/json/tests/__init__.py b/Lib/test/json_tests/__init__.py
index 90cb2b7ad64..779c7a46b3d 100644
--- a/Lib/json/tests/__init__.py
+++ b/Lib/test/json_tests/__init__.py
@@ -4,11 +4,11 @@ import json
import doctest
import unittest
-from test import test_support
+from test import support
# import json with and without accelerations
-cjson = test_support.import_fresh_module('json', fresh=['_json'])
-pyjson = test_support.import_fresh_module('json', blocked=['_json'])
+cjson = support.import_fresh_module('json', fresh=['_json'])
+pyjson = support.import_fresh_module('json', blocked=['_json'])
# create two base classes that will be used by the other tests
class PyTest(unittest.TestCase):
@@ -49,7 +49,7 @@ def test_suite():
loader = unittest.TestLoader()
for fn in os.listdir(here):
if fn.startswith("test") and fn.endswith(".py"):
- modname = "json.tests." + fn[:-3]
+ modname = "test.json_tests." + fn[:-3]
__import__(modname)
module = sys.modules[modname]
suite.addTests(loader.loadTestsFromModule(module))
diff --git a/Lib/json/tests/test_decode.py b/Lib/test/json_tests/test_decode.py
index 478a16ba0fd..0a55a33f1ea 100644
--- a/Lib/json/tests/test_decode.py
+++ b/Lib/test/json_tests/test_decode.py
@@ -1,10 +1,10 @@
import decimal
-from StringIO import StringIO
+from io import StringIO
from collections import OrderedDict
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
-class TestDecode(object):
+class TestDecode:
def test_decimal(self):
rval = self.loads('1.1', parse_float=decimal.Decimal)
self.assertTrue(isinstance(rval, decimal.Decimal))
@@ -15,45 +15,54 @@ class TestDecode(object):
self.assertTrue(isinstance(rval, float))
self.assertEqual(rval, 1.0)
- def test_decoder_optimizations(self):
- # Several optimizations were made that skip over calls to
- # the whitespace regex, so this test is designed to try and
- # exercise the uncommon cases. The array cases are already covered.
- rval = self.loads('{ "key" : "value" , "k":"v" }')
- self.assertEqual(rval, {"key":"value", "k":"v"})
-
def test_empty_objects(self):
self.assertEqual(self.loads('{}'), {})
self.assertEqual(self.loads('[]'), [])
- self.assertEqual(self.loads('""'), u"")
- self.assertIsInstance(self.loads('""'), unicode)
+ self.assertEqual(self.loads('""'), "")
def test_object_pairs_hook(self):
s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),
("qrt", 5), ("pad", 6), ("hoy", 7)]
self.assertEqual(self.loads(s), eval(s))
- self.assertEqual(self.loads(s, object_pairs_hook=lambda x: x), p)
+ self.assertEqual(self.loads(s, object_pairs_hook = lambda x: x), p)
self.assertEqual(self.json.load(StringIO(s),
object_pairs_hook=lambda x: x), p)
- od = self.loads(s, object_pairs_hook=OrderedDict)
+ od = self.loads(s, object_pairs_hook = OrderedDict)
self.assertEqual(od, OrderedDict(p))
self.assertEqual(type(od), OrderedDict)
# the object_pairs_hook takes priority over the object_hook
- self.assertEqual(self.loads(s,
- object_pairs_hook=OrderedDict,
- object_hook=lambda x: None),
+ self.assertEqual(self.loads(s, object_pairs_hook = OrderedDict,
+ object_hook = lambda x: None),
OrderedDict(p))
+ def test_decoder_optimizations(self):
+ # Several optimizations were made that skip over calls to
+ # the whitespace regex, so this test is designed to try and
+ # exercise the uncommon cases. The array cases are already covered.
+ rval = self.loads('{ "key" : "value" , "k":"v" }')
+ self.assertEqual(rval, {"key":"value", "k":"v"})
+
+ def check_keys_reuse(self, source, loads):
+ rval = loads(source)
+ (a, b), (c, d) = sorted(rval[0]), sorted(rval[1])
+ self.assertIs(a, c)
+ self.assertIs(b, d)
+
+ def test_keys_reuse(self):
+ s = '[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]'
+ self.check_keys_reuse(s, self.loads)
+ self.check_keys_reuse(s, self.json.decoder.JSONDecoder().decode)
+
def test_extra_data(self):
s = '[1, 2, 3]5'
msg = 'Extra data'
- self.assertRaisesRegexp(ValueError, msg, self.loads, s)
+ self.assertRaisesRegex(ValueError, msg, self.loads, s)
def test_invalid_escape(self):
s = '["abc\\y"]'
msg = 'escape'
- self.assertRaisesRegexp(ValueError, msg, self.loads, s)
+ self.assertRaisesRegex(ValueError, msg, self.loads, s)
class TestPyDecode(TestDecode, PyTest): pass
class TestCDecode(TestDecode, CTest): pass
diff --git a/Lib/json/tests/test_default.py b/Lib/test/json_tests/test_default.py
index c2a07f605ef..672c753fbf7 100644
--- a/Lib/json/tests/test_default.py
+++ b/Lib/test/json_tests/test_default.py
@@ -1,7 +1,7 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
-class TestDefault(object):
+class TestDefault:
def test_default(self):
self.assertEqual(
self.dumps(type, default=repr),
diff --git a/Lib/json/tests/test_dump.py b/Lib/test/json_tests/test_dump.py
index cd92569d98a..fee972eac4a 100644
--- a/Lib/json/tests/test_dump.py
+++ b/Lib/test/json_tests/test_dump.py
@@ -1,8 +1,8 @@
-from cStringIO import StringIO
-from json.tests import PyTest, CTest
+from io import StringIO
+from test.json_tests import PyTest, CTest
-class TestDump(object):
+class TestDump:
def test_dump(self):
sio = StringIO()
self.json.dump({}, sio)
@@ -16,7 +16,7 @@ class TestDump(object):
{True: False, False: True}, sort_keys=True),
'{"false": true, "true": false}')
self.assertEqual(self.dumps(
- {2: 3.0, 4.0: 5L, False: 1, 6L: True}, sort_keys=True),
+ {2: 3.0, 4.0: 5, False: 1, 6: True}, sort_keys=True),
'{"false": 1, "2": 3.0, "4.0": 5, "6": true}')
# Issue 16228: Crash on encoding resized list
diff --git a/Lib/test/json_tests/test_encode_basestring_ascii.py b/Lib/test/json_tests/test_encode_basestring_ascii.py
new file mode 100644
index 00000000000..bfca69d18db
--- /dev/null
+++ b/Lib/test/json_tests/test_encode_basestring_ascii.py
@@ -0,0 +1,44 @@
+from collections import OrderedDict
+from test.json_tests import PyTest, CTest
+
+
+CASES = [
+ ('/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'),
+ ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
+ ('controls', '"controls"'),
+ ('\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
+ ('{"object with 1 member":["array with 1 element"]}', '"{\\"object with 1 member\\":[\\"array with 1 element\\"]}"'),
+ (' s p a c e d ', '" s p a c e d "'),
+ ('\U0001d120', '"\\ud834\\udd20"'),
+ ('\u03b1\u03a9', '"\\u03b1\\u03a9"'),
+ ('\u03b1\u03a9', '"\\u03b1\\u03a9"'),
+ ('\u03b1\u03a9', '"\\u03b1\\u03a9"'),
+ ('\u03b1\u03a9', '"\\u03b1\\u03a9"'),
+ ("`1~!@#$%^&*()_+-={':[,]}|;.</>?", '"`1~!@#$%^&*()_+-={\':[,]}|;.</>?"'),
+ ('\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'),
+ ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'),
+]
+
+class TestEncodeBasestringAscii:
+ def test_encode_basestring_ascii(self):
+ fname = self.json.encoder.encode_basestring_ascii.__name__
+ for input_string, expect in CASES:
+ result = self.json.encoder.encode_basestring_ascii(input_string)
+ self.assertEqual(result, expect,
+ '{0!r} != {1!r} for {2}({3!r})'.format(
+ result, expect, fname, input_string))
+
+ def test_ordered_dict(self):
+ # See issue 6105
+ items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
+ s = self.dumps(OrderedDict(items))
+ self.assertEqual(s, '{"one": 1, "two": 2, "three": 3, "four": 4, "five": 5}')
+
+ def test_sorted_dict(self):
+ items = [('one', 1), ('two', 2), ('three', 3), ('four', 4), ('five', 5)]
+ s = self.dumps(dict(items), sort_keys=True)
+ self.assertEqual(s, '{"five": 5, "four": 4, "one": 1, "three": 3, "two": 2}')
+
+
+class TestPyEncodeBasestringAscii(TestEncodeBasestringAscii, PyTest): pass
+class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest): pass
diff --git a/Lib/json/tests/test_fail.py b/Lib/test/json_tests/test_fail.py
index e31b3792c40..7809056a731 100644
--- a/Lib/json/tests/test_fail.py
+++ b/Lib/test/json_tests/test_fail.py
@@ -1,4 +1,4 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
# 2007-10-05
JSONDOCS = [
@@ -69,7 +69,7 @@ JSONDOCS = [
# http://json.org/JSON_checker/test/fail33.json
'["mismatch"}',
# http://code.google.com/p/simplejson/issues/detail?id=3
- u'["A\u001FZ control characters in string"]',
+ '["A\u001FZ control characters in string"]',
]
SKIPS = {
@@ -77,7 +77,7 @@ SKIPS = {
18: "spec doesn't specify any nesting limitations",
}
-class TestFail(object):
+class TestFail:
def test_failures(self):
for idx, doc in enumerate(JSONDOCS):
idx = idx + 1
diff --git a/Lib/json/tests/test_float.py b/Lib/test/json_tests/test_float.py
index 049f9ae1832..38ef7e94b38 100644
--- a/Lib/json/tests/test_float.py
+++ b/Lib/test/json_tests/test_float.py
@@ -1,21 +1,17 @@
import math
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
-class TestFloat(object):
+class TestFloat:
def test_floats(self):
- for num in [1617161771.7650001, math.pi, math.pi**100,
- math.pi**-100, 3.1]:
+ for num in [1617161771.7650001, math.pi, math.pi**100, math.pi**-100, 3.1]:
self.assertEqual(float(self.dumps(num)), num)
self.assertEqual(self.loads(self.dumps(num)), num)
- self.assertEqual(self.loads(unicode(self.dumps(num))), num)
def test_ints(self):
- for num in [1, 1L, 1<<32, 1<<64]:
+ for num in [1, 1<<32, 1<<64]:
self.assertEqual(self.dumps(num), str(num))
self.assertEqual(int(self.dumps(num)), num)
- self.assertEqual(self.loads(self.dumps(num)), num)
- self.assertEqual(self.loads(unicode(self.dumps(num))), num)
def test_out_of_range(self):
self.assertEqual(self.loads('[23456789012E666]'), [float('inf')])
diff --git a/Lib/json/tests/test_indent.py b/Lib/test/json_tests/test_indent.py
index 9b1876123a4..4c706463396 100644
--- a/Lib/json/tests/test_indent.py
+++ b/Lib/test/json_tests/test_indent.py
@@ -1,44 +1,47 @@
import textwrap
-from StringIO import StringIO
-from json.tests import PyTest, CTest
+from io import StringIO
+from test.json_tests import PyTest, CTest
-class TestIndent(object):
+class TestIndent:
def test_indent(self):
h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
{'nifty': 87}, {'field': 'yes', 'morefield': False} ]
expect = textwrap.dedent("""\
[
- [
- "blorpie"
- ],
- [
- "whoops"
- ],
- [],
- "d-shtaeou",
- "d-nthiouh",
- "i-vhbjkhnth",
- {
- "nifty": 87
- },
- {
- "field": "yes",
- "morefield": false
- }
+ \t[
+ \t\t"blorpie"
+ \t],
+ \t[
+ \t\t"whoops"
+ \t],
+ \t[],
+ \t"d-shtaeou",
+ \t"d-nthiouh",
+ \t"i-vhbjkhnth",
+ \t{
+ \t\t"nifty": 87
+ \t},
+ \t{
+ \t\t"field": "yes",
+ \t\t"morefield": false
+ \t}
]""")
-
d1 = self.dumps(h)
d2 = self.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
+ d3 = self.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
h1 = self.loads(d1)
h2 = self.loads(d2)
+ h3 = self.loads(d3)
self.assertEqual(h1, h)
self.assertEqual(h2, h)
- self.assertEqual(d2, expect)
+ self.assertEqual(h3, h)
+ self.assertEqual(d2, expect.expandtabs(2))
+ self.assertEqual(d3, expect)
def test_indent0(self):
h = {3: 1}
diff --git a/Lib/json/tests/test_pass1.py b/Lib/test/json_tests/test_pass1.py
index df8259b7f25..52445f396e0 100644
--- a/Lib/json/tests/test_pass1.py
+++ b/Lib/test/json_tests/test_pass1.py
@@ -1,4 +1,4 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
# from http://json.org/JSON_checker/test/pass1.json
@@ -63,7 +63,7 @@ JSON = r'''
,"rosebud"]
'''
-class TestPass1(object):
+class TestPass1:
def test_parse(self):
# test in/out equivalence and parsing
res = self.loads(JSON)
diff --git a/Lib/json/tests/test_pass2.py b/Lib/test/json_tests/test_pass2.py
index a2bb6d72113..eee6383382c 100644
--- a/Lib/json/tests/test_pass2.py
+++ b/Lib/test/json_tests/test_pass2.py
@@ -1,4 +1,4 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
# from http://json.org/JSON_checker/test/pass2.json
@@ -6,7 +6,7 @@ JSON = r'''
[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]
'''
-class TestPass2(object):
+class TestPass2:
def test_parse(self):
# test in/out equivalence and parsing
res = self.loads(JSON)
diff --git a/Lib/json/tests/test_pass3.py b/Lib/test/json_tests/test_pass3.py
index 221f9a0c3d5..228eee8adb9 100644
--- a/Lib/json/tests/test_pass3.py
+++ b/Lib/test/json_tests/test_pass3.py
@@ -1,4 +1,4 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
# from http://json.org/JSON_checker/test/pass3.json
@@ -12,7 +12,7 @@ JSON = r'''
'''
-class TestPass3(object):
+class TestPass3:
def test_parse(self):
# test in/out equivalence and parsing
res = self.loads(JSON)
diff --git a/Lib/json/tests/test_recursion.py b/Lib/test/json_tests/test_recursion.py
index b5221e5d16b..192ed9cf40c 100644
--- a/Lib/json/tests/test_recursion.py
+++ b/Lib/test/json_tests/test_recursion.py
@@ -1,11 +1,11 @@
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
class JSONTestObject:
pass
-class TestRecursion(object):
+class TestRecursion:
def test_listrecursion(self):
x = []
x.append(x)
@@ -68,25 +68,17 @@ class TestRecursion(object):
def test_highly_nested_objects_decoding(self):
# test that loading highly-nested objects doesn't segfault when C
# accelerations are used. See #12017
- # str
with self.assertRaises(RuntimeError):
self.loads('{"a":' * 100000 + '1' + '}' * 100000)
with self.assertRaises(RuntimeError):
self.loads('{"a":' * 100000 + '[1]' + '}' * 100000)
with self.assertRaises(RuntimeError):
self.loads('[' * 100000 + '1' + ']' * 100000)
- # unicode
- with self.assertRaises(RuntimeError):
- self.loads(u'{"a":' * 100000 + u'1' + u'}' * 100000)
- with self.assertRaises(RuntimeError):
- self.loads(u'{"a":' * 100000 + u'[1]' + u'}' * 100000)
- with self.assertRaises(RuntimeError):
- self.loads(u'[' * 100000 + u'1' + u']' * 100000)
def test_highly_nested_objects_encoding(self):
# See #12051
l, d = [], {}
- for x in xrange(100000):
+ for x in range(100000):
l, d = [l], {'k':d}
with self.assertRaises(RuntimeError):
self.dumps(l)
diff --git a/Lib/test/json_tests/test_scanstring.py b/Lib/test/json_tests/test_scanstring.py
new file mode 100644
index 00000000000..f82cdeead3c
--- /dev/null
+++ b/Lib/test/json_tests/test_scanstring.py
@@ -0,0 +1,103 @@
+import sys
+from test.json_tests import PyTest, CTest
+
+
+class TestScanstring:
+ def test_scanstring(self):
+ scanstring = self.json.decoder.scanstring
+ self.assertEqual(
+ scanstring('"z\\ud834\\udd20x"', 1, True),
+ ('z\U0001d120x', 16))
+
+ if sys.maxunicode == 65535:
+ self.assertEqual(
+ scanstring('"z\U0001d120x"', 1, True),
+ ('z\U0001d120x', 6))
+ else:
+ self.assertEqual(
+ scanstring('"z\U0001d120x"', 1, True),
+ ('z\U0001d120x', 5))
+
+ self.assertEqual(
+ scanstring('"\\u007b"', 1, True),
+ ('{', 8))
+
+ self.assertEqual(
+ scanstring('"A JSON payload should be an object or array, not a string."', 1, True),
+ ('A JSON payload should be an object or array, not a string.', 60))
+
+ self.assertEqual(
+ scanstring('["Unclosed array"', 2, True),
+ ('Unclosed array', 17))
+
+ self.assertEqual(
+ scanstring('["extra comma",]', 2, True),
+ ('extra comma', 14))
+
+ self.assertEqual(
+ scanstring('["double extra comma",,]', 2, True),
+ ('double extra comma', 21))
+
+ self.assertEqual(
+ scanstring('["Comma after the close"],', 2, True),
+ ('Comma after the close', 24))
+
+ self.assertEqual(
+ scanstring('["Extra close"]]', 2, True),
+ ('Extra close', 14))
+
+ self.assertEqual(
+ scanstring('{"Extra comma": true,}', 2, True),
+ ('Extra comma', 14))
+
+ self.assertEqual(
+ scanstring('{"Extra value after close": true} "misplaced quoted value"', 2, True),
+ ('Extra value after close', 26))
+
+ self.assertEqual(
+ scanstring('{"Illegal expression": 1 + 2}', 2, True),
+ ('Illegal expression', 21))
+
+ self.assertEqual(
+ scanstring('{"Illegal invocation": alert()}', 2, True),
+ ('Illegal invocation', 21))
+
+ self.assertEqual(
+ scanstring('{"Numbers cannot have leading zeroes": 013}', 2, True),
+ ('Numbers cannot have leading zeroes', 37))
+
+ self.assertEqual(
+ scanstring('{"Numbers cannot be hex": 0x14}', 2, True),
+ ('Numbers cannot be hex', 24))
+
+ self.assertEqual(
+ scanstring('[[[[[[[[[[[[[[[[[[[["Too deep"]]]]]]]]]]]]]]]]]]]]', 21, True),
+ ('Too deep', 30))
+
+ self.assertEqual(
+ scanstring('{"Missing colon" null}', 2, True),
+ ('Missing colon', 16))
+
+ self.assertEqual(
+ scanstring('{"Double colon":: null}', 2, True),
+ ('Double colon', 15))
+
+ self.assertEqual(
+ scanstring('{"Comma instead of colon", null}', 2, True),
+ ('Comma instead of colon', 25))
+
+ self.assertEqual(
+ scanstring('["Colon instead of comma": false]', 2, True),
+ ('Colon instead of comma', 25))
+
+ self.assertEqual(
+ scanstring('["Bad value", truth]', 2, True),
+ ('Bad value', 12))
+
+ def test_overflow(self):
+ with self.assertRaises(OverflowError):
+ self.json.decoder.scanstring(b"xxx", sys.maxsize+1)
+
+
+class TestPyScanstring(TestScanstring, PyTest): pass
+class TestCScanstring(TestScanstring, CTest): pass
diff --git a/Lib/json/tests/test_separators.py b/Lib/test/json_tests/test_separators.py
index a4246e1f2dc..a01b38c0807 100644
--- a/Lib/json/tests/test_separators.py
+++ b/Lib/test/json_tests/test_separators.py
@@ -1,8 +1,8 @@
import textwrap
-from json.tests import PyTest, CTest
+from test.json_tests import PyTest, CTest
-class TestSeparators(object):
+class TestSeparators:
def test_separators(self):
h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
{'nifty': 87}, {'field': 'yes', 'morefield': False} ]
diff --git a/Lib/json/tests/test_speedups.py b/Lib/test/json_tests/test_speedups.py
index 7186a40932f..5c24c0580b0 100644
--- a/Lib/json/tests/test_speedups.py
+++ b/Lib/test/json_tests/test_speedups.py
@@ -1,4 +1,4 @@
-from json.tests import CTest
+from test.json_tests import CTest
class TestSpeedups(CTest):
@@ -12,12 +12,13 @@ class TestSpeedups(CTest):
self.assertIs(self.json.encoder.encode_basestring_ascii,
self.json.encoder.c_encode_basestring_ascii)
+
class TestDecode(CTest):
def test_make_scanner(self):
self.assertRaises(AttributeError, self.json.scanner.c_make_scanner, 1)
def test_make_encoder(self):
self.assertRaises(TypeError, self.json.encoder.c_make_encoder,
- None,
- "\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
+ (True, False),
+ b"\xCD\x7D\x3D\x4E\x12\x4C\xF9\x79\xD7\x52\xBA\x82\xF2\x27\x4A\x7D\xA0\xCA\x75",
None)
diff --git a/Lib/json/tests/test_tool.py b/Lib/test/json_tests/test_tool.py
index 27dfb84fdbd..0c39e56837b 100644
--- a/Lib/json/tests/test_tool.py
+++ b/Lib/test/json_tests/test_tool.py
@@ -3,7 +3,7 @@ import sys
import textwrap
import unittest
import subprocess
-from test import test_support
+from test import support
from test.script_helper import assert_python_ok
class TestTool(unittest.TestCase):
@@ -38,15 +38,15 @@ class TestTool(unittest.TestCase):
""")
def test_stdin_stdout(self):
- proc = subprocess.Popen(
+ with subprocess.Popen(
(sys.executable, '-m', 'json.tool'),
- stdin=subprocess.PIPE, stdout=subprocess.PIPE)
- out, err = proc.communicate(self.data.encode())
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
+ out, err = proc.communicate(self.data.encode())
self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
self.assertEqual(err, None)
def _create_infile(self):
- infile = test_support.TESTFN
+ infile = support.TESTFN
with open(infile, "w") as fp:
self.addCleanup(os.remove, infile)
fp.write(self.data)
@@ -60,7 +60,7 @@ class TestTool(unittest.TestCase):
def test_infile_outfile(self):
infile = self._create_infile()
- outfile = test_support.TESTFN + '.out'
+ outfile = support.TESTFN + '.out'
rc, out, err = assert_python_ok('-m', 'json.tool', infile, outfile)
self.addCleanup(os.remove, outfile)
with open(outfile, "r") as fp:
diff --git a/Lib/test/json_tests/test_unicode.py b/Lib/test/json_tests/test_unicode.py
new file mode 100644
index 00000000000..f226aa6f03d
--- /dev/null
+++ b/Lib/test/json_tests/test_unicode.py
@@ -0,0 +1,75 @@
+from collections import OrderedDict
+from test.json_tests import PyTest, CTest
+
+
+class TestUnicode:
+ # test_encoding1 and test_encoding2 from 2.x are irrelevant (only str
+ # is supported as input, not bytes).
+
+ def test_encoding3(self):
+ u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+ j = self.dumps(u)
+ self.assertEqual(j, '"\\u03b1\\u03a9"')
+
+ def test_encoding4(self):
+ u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+ j = self.dumps([u])
+ self.assertEqual(j, '["\\u03b1\\u03a9"]')
+
+ def test_encoding5(self):
+ u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+ j = self.dumps(u, ensure_ascii=False)
+ self.assertEqual(j, '"{0}"'.format(u))
+
+ def test_encoding6(self):
+ u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
+ j = self.dumps([u], ensure_ascii=False)
+ self.assertEqual(j, '["{0}"]'.format(u))
+
+ def test_big_unicode_encode(self):
+ u = '\U0001d120'
+ self.assertEqual(self.dumps(u), '"\\ud834\\udd20"')
+ self.assertEqual(self.dumps(u, ensure_ascii=False), '"\U0001d120"')
+
+ def test_big_unicode_decode(self):
+ u = 'z\U0001d120x'
+ self.assertEqual(self.loads('"' + u + '"'), u)
+ self.assertEqual(self.loads('"z\\ud834\\udd20x"'), u)
+
+ def test_unicode_decode(self):
+ for i in range(0, 0xd7ff):
+ u = chr(i)
+ s = '"\\u{0:04x}"'.format(i)
+ self.assertEqual(self.loads(s), u)
+
+ def test_unicode_preservation(self):
+ self.assertEqual(type(self.loads('""')), str)
+ self.assertEqual(type(self.loads('"a"')), str)
+ self.assertEqual(type(self.loads('["a"]')[0]), str)
+
+ def test_bytes_encode(self):
+ self.assertRaises(TypeError, self.dumps, b"hi")
+ self.assertRaises(TypeError, self.dumps, [b"hi"])
+
+ def test_bytes_decode(self):
+ self.assertRaises(TypeError, self.loads, b'"hi"')
+ self.assertRaises(TypeError, self.loads, b'["hi"]')
+
+
+ def test_object_pairs_hook_with_unicode(self):
+ s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
+ p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),
+ ("qrt", 5), ("pad", 6), ("hoy", 7)]
+ self.assertEqual(self.loads(s), eval(s))
+ self.assertEqual(self.loads(s, object_pairs_hook = lambda x: x), p)
+ od = self.loads(s, object_pairs_hook = OrderedDict)
+ self.assertEqual(od, OrderedDict(p))
+ self.assertEqual(type(od), OrderedDict)
+ # the object_pairs_hook takes priority over the object_hook
+ self.assertEqual(self.loads(s, object_pairs_hook = OrderedDict,
+ object_hook = lambda x: None),
+ OrderedDict(p))
+
+
+class TestPyUnicode(TestUnicode, PyTest): pass
+class TestCUnicode(TestUnicode, CTest): pass
diff --git a/Lib/test/keycert.pem b/Lib/test/keycert.pem
index 2f46fcf1c62..64318aa2e03 100644
--- a/Lib/test/keycert.pem
+++ b/Lib/test/keycert.pem
@@ -1,32 +1,31 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXwIBAAKBgQC8ddrhm+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9L
-opdJhTvbGfEj0DQs1IE8M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVH
-fhi/VwovESJlaBOp+WMnfhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQAB
-AoGBAK0FZpaKj6WnJZN0RqhhK+ggtBWwBnc0U/ozgKz2j1s3fsShYeiGtW6CK5nU
-D1dZ5wzhbGThI7LiOXDvRucc9n7vUgi0alqPQ/PFodPxAN/eEYkmXQ7W2k7zwsDA
-IUK0KUhktQbLu8qF/m8qM86ba9y9/9YkXuQbZ3COl5ahTZrhAkEA301P08RKv3KM
-oXnGU2UHTuJ1MAD2hOrPxjD4/wxA/39EWG9bZczbJyggB4RHu0I3NOSFjAm3HQm0
-ANOu5QK9owJBANgOeLfNNcF4pp+UikRFqxk5hULqRAWzVxVrWe85FlPm0VVmHbb/
-loif7mqjU8o1jTd/LM7RD9f2usZyE2psaw8CQQCNLhkpX3KO5kKJmS9N7JMZSc4j
-oog58yeYO8BBqKKzpug0LXuQultYv2K4veaIO04iL9VLe5z9S/Q1jaCHBBuXAkEA
-z8gjGoi1AOp6PBBLZNsncCvcV/0aC+1se4HxTNo2+duKSDnbq+ljqOM+E7odU+Nq
-ewvIWOG//e8fssd0mq3HywJBAJ8l/c8GVmrpFTx8r/nZ2Pyyjt3dH1widooDXYSV
-q6Gbf41Llo5sYAtmxdndTLASuHKecacTgZVhy0FryZpLKrU=
------END RSA PRIVATE KEY-----
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm
+LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0
+ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP
+USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt
+CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq
+SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK
+UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y
+BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ
+ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5
+oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik
+eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F
+0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS
+x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/
+SPIXQuT8RMPDVNQ=
+-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
-MIICpzCCAhCgAwIBAgIJAP+qStv1cIGNMA0GCSqGSIb3DQEBBQUAMIGJMQswCQYD
-VQQGEwJVUzERMA8GA1UECBMIRGVsYXdhcmUxEzARBgNVBAcTCldpbG1pbmd0b24x
-IzAhBgNVBAoTGlB5dGhvbiBTb2Z0d2FyZSBGb3VuZGF0aW9uMQwwCgYDVQQLEwNT
-U0wxHzAdBgNVBAMTFnNvbWVtYWNoaW5lLnB5dGhvbi5vcmcwHhcNMDcwODI3MTY1
-NDUwWhcNMTMwMjE2MTY1NDUwWjCBiTELMAkGA1UEBhMCVVMxETAPBgNVBAgTCERl
-bGF3YXJlMRMwEQYDVQQHEwpXaWxtaW5ndG9uMSMwIQYDVQQKExpQeXRob24gU29m
-dHdhcmUgRm91bmRhdGlvbjEMMAoGA1UECxMDU1NMMR8wHQYDVQQDExZzb21lbWFj
-aGluZS5weXRob24ub3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8ddrh
-m+LutBvjYcQlnH21PPIseJ1JVG2HMmN2CmZk2YukO+9LopdJhTvbGfEj0DQs1IE8
-M+kTUyOmuKfVrFMKwtVeCJphrAnhoz7TYOuLBSqt7lVHfhi/VwovESJlaBOp+WMn
-fhcduPEYHYx/6cnVapIkZnLt30zu2um+DzA9jQIDAQABoxUwEzARBglghkgBhvhC
-AQEEBAMCBkAwDQYJKoZIhvcNAQEFBQADgYEAF4Q5BVqmCOLv1n8je/Jw9K669VXb
-08hyGzQhkemEBYQd6fzQ9A/1ZzHkJKb1P6yreOLSEh4KcxYPyrLRC1ll8nr5OlCx
-CMhKkTnR6qBsdNV0XtdU2+N25hqW+Ma4ZeqsN/iiJVCGNOZGnvQuvCAGWF8+J/f/
-iHkC6gGdBJhogs4=
+MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw
+MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH
+Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k
+YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
+gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7
+6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt
+pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw
+FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd
+BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G
+lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1
+CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX
-----END CERTIFICATE-----
diff --git a/Lib/test/keycert2.pem b/Lib/test/keycert2.pem
new file mode 100644
index 00000000000..e8a9e082b31
--- /dev/null
+++ b/Lib/test/keycert2.pem
@@ -0,0 +1,31 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAJnsJZVrppL+W5I9
+zGQrrawWwE5QJpBK9nWw17mXrZ03R1cD9BamLGivVISbPlRlAVnZBEyh1ATpsB7d
+CUQ+WHEvALquvx4+Yw5l+fXeiYRjrLRBYZuVy8yNtXzU3iWcGObcYRkUdiXdOyP7
+sLF2YZHRvQZpzgDBKkrraeQ81w21AgMBAAECgYBEm7n07FMHWlE+0kT0sXNsLYfy
+YE+QKZnJw9WkaDN+zFEEPELkhZVt5BjsMraJr6v2fIEqF0gGGJPkbenffVq2B5dC
+lWUOxvJHufMK4sM3Cp6s/gOp3LP+QkzVnvJSfAyZU6l+4PGX5pLdUsXYjPxgzjzL
+S36tF7/2Uv1WePyLUQJBAMsPhYzUXOPRgmbhcJiqi9A9c3GO8kvSDYTCKt3VMnqz
+HBn6MQ4VQasCD1F+7jWTI0FU/3vdw8non/Fj8hhYqZcCQQDCDRdvmZqDiZnpMqDq
+L6ZSrLTVtMvZXZbgwForaAD9uHj51TME7+eYT7EG2YCgJTXJ4YvRJEnPNyskwdKt
+vTSTAkEAtaaN/vyemEJ82BIGStwONNw0ILsSr5cZ9tBHzqiA/tipY+e36HRFiXhP
+QcU9zXlxyWkDH8iz9DSAmE2jbfoqwwJANlMJ65E543cjIlitGcKLMnvtCCLcKpb7
+xSG0XJB6Lo11OKPJ66jp0gcFTSCY1Lx2CXVd+gfJrfwI1Pp562+bhwJBAJ9IfDPU
+R8OpO9v1SGd8x33Owm7uXOpB9d63/T70AD1QOXjKUC4eXYbt0WWfWuny/RNPRuyh
+w7DXSfUF+kPKolU=
+-----END PRIVATE KEY-----
+-----BEGIN CERTIFICATE-----
+MIICXTCCAcagAwIBAgIJAIO3upAG445fMA0GCSqGSIb3DQEBBQUAMGIxCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTAeFw0x
+MDEwMDkxNTAxMDBaFw0yMDEwMDYxNTAxMDBaMGIxCzAJBgNVBAYTAlhZMRcwFQYD
+VQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZv
+dW5kYXRpb24xFTATBgNVBAMTDGZha2Vob3N0bmFtZTCBnzANBgkqhkiG9w0BAQEF
+AAOBjQAwgYkCgYEAmewllWumkv5bkj3MZCutrBbATlAmkEr2dbDXuZetnTdHVwP0
+FqYsaK9UhJs+VGUBWdkETKHUBOmwHt0JRD5YcS8Auq6/Hj5jDmX59d6JhGOstEFh
+m5XLzI21fNTeJZwY5txhGRR2Jd07I/uwsXZhkdG9BmnOAMEqSutp5DzXDbUCAwEA
+AaMbMBkwFwYDVR0RBBAwDoIMZmFrZWhvc3RuYW1lMA0GCSqGSIb3DQEBBQUAA4GB
+AH+iMClLLGSaKWgwXsmdVo4FhTZZHo8Uprrtg3N9FxEeE50btpDVQysgRt5ias3K
+m+bME9zbKwvbVWD5zZdjus4pDgzwF/iHyccL8JyYhxOvS/9zmvAtFXj/APIIbZFp
+IT75d9f88ScIGEtknZQejnrdhB64tYki/EqluiuKBqKD
+-----END CERTIFICATE-----
diff --git a/Lib/test/leakers/test_dictself.py b/Lib/test/leakers/test_dictself.py
deleted file mode 100644
index 99bd37d8ccf..00000000000
--- a/Lib/test/leakers/test_dictself.py
+++ /dev/null
@@ -1,12 +0,0 @@
-'''Test case for "self.__dict__ = self" circular reference bug (#1469629)'''
-
-import gc
-
-class LeakyDict(dict):
- pass
-
-def leak():
- ld = LeakyDict()
- ld.__dict__ = ld
- del ld
- gc.collect(); gc.collect(); gc.collect()
diff --git a/Lib/test/leakers/test_gestalt.py b/Lib/test/leakers/test_gestalt.py
index 46bfcc806dc..e0081c1fc51 100644
--- a/Lib/test/leakers/test_gestalt.py
+++ b/Lib/test/leakers/test_gestalt.py
@@ -1,7 +1,7 @@
import sys
if sys.platform != 'darwin':
- raise ValueError, "This test only leaks on Mac OS X"
+ raise ValueError("This test only leaks on Mac OS X")
def leak():
# taken from platform._mac_ver_lookup()
diff --git a/Lib/test/leakers/test_selftype.py b/Lib/test/leakers/test_selftype.py
index 4207c328bae..12f29345d2c 100644
--- a/Lib/test/leakers/test_selftype.py
+++ b/Lib/test/leakers/test_selftype.py
@@ -6,8 +6,8 @@ import gc
def leak():
class T(type):
pass
- class U(type):
- __metaclass__ = T
+ class U(type, metaclass=T):
+ pass
U.__class__ = U
del U
gc.collect(); gc.collect(); gc.collect()
diff --git a/Lib/test/list_tests.py b/Lib/test/list_tests.py
index b8d6d6bda67..be054eadf6e 100644
--- a/Lib/test/list_tests.py
+++ b/Lib/test/list_tests.py
@@ -4,8 +4,10 @@ Tests common to list and UserList.UserList
import sys
import os
+from functools import cmp_to_key
+
+from test import support, seq_tests
-from test import test_support, seq_tests
class CommonTest(seq_tests.CommonTest):
@@ -46,23 +48,23 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
l0 = []
- for i in xrange(sys.getrecursionlimit() + 100):
+ for i in range(sys.getrecursionlimit() + 100):
l0 = [l0]
self.assertRaises(RuntimeError, repr, l0)
def test_print(self):
- d = self.type2test(xrange(200))
+ d = self.type2test(range(200))
d.append(d)
- d.extend(xrange(200,400))
+ d.extend(range(200,400))
d.append(d)
d.append(400)
try:
- with open(test_support.TESTFN, "wb") as fo:
- print >> fo, d,
- with open(test_support.TESTFN, "rb") as fo:
+ with open(support.TESTFN, "w") as fo:
+ fo.write(str(d))
+ with open(support.TESTFN, "r") as fo:
self.assertEqual(fo.read(), repr(d))
finally:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_set_subscript(self):
a = self.type2test(range(20))
@@ -79,7 +81,7 @@ class CommonTest(seq_tests.CommonTest):
a = self.type2test(range(20))
r = reversed(a)
self.assertEqual(list(r), self.type2test(range(19, -1, -1)))
- self.assertRaises(StopIteration, r.next)
+ self.assertRaises(StopIteration, next, r)
self.assertEqual(list(reversed(self.type2test())),
self.type2test())
# Bug 3689: make sure list-reversed-iterator doesn't have __len__
@@ -103,16 +105,16 @@ class CommonTest(seq_tests.CommonTest):
self.assertRaises(TypeError, a.__setitem__)
a = self.type2test([0,1,2,3,4])
- a[0L] = 1
- a[1L] = 2
- a[2L] = 3
+ a[0] = 1
+ a[1] = 2
+ a[2] = 3
self.assertEqual(a, self.type2test([1,2,3,3,4]))
a[0] = 5
a[1] = 6
a[2] = 7
self.assertEqual(a, self.type2test([5,6,7,3,4]))
- a[-2L] = 88
- a[-1L] = 99
+ a[-2] = 88
+ a[-1] = 99
self.assertEqual(a, self.type2test([5,6,7,88,99]))
a[-2] = 8
a[-1] = 9
@@ -182,10 +184,8 @@ class CommonTest(seq_tests.CommonTest):
a[:] = tuple(range(10))
self.assertEqual(a, self.type2test(range(10)))
- self.assertRaises(TypeError, a.__setslice__, 0, 1, 5)
self.assertRaises(TypeError, a.__setitem__, slice(0, 1, 5))
- self.assertRaises(TypeError, a.__setslice__)
self.assertRaises(TypeError, a.__setitem__)
def test_delslice(self):
@@ -195,8 +195,8 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a, self.type2test([]))
a = self.type2test([0, 1])
- del a[1L:2L]
- del a[0L:1L]
+ del a[1:2]
+ del a[0:1]
self.assertEqual(a, self.type2test([]))
a = self.type2test([0, 1])
@@ -204,7 +204,7 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a, self.type2test([1]))
a = self.type2test([0, 1])
- del a[-2L:-1L]
+ del a[-2:-1]
self.assertEqual(a, self.type2test([1]))
a = self.type2test([0, 1])
@@ -213,8 +213,8 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a, self.type2test([]))
a = self.type2test([0, 1])
- del a[1L:]
- del a[:1L]
+ del a[1:]
+ del a[:1]
self.assertEqual(a, self.type2test([]))
a = self.type2test([0, 1])
@@ -222,7 +222,7 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a, self.type2test([0]))
a = self.type2test([0, 1])
- del a[-1L:]
+ del a[-1:]
self.assertEqual(a, self.type2test([0]))
a = self.type2test([0, 1])
@@ -389,8 +389,8 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(a.index(0, -3), 3)
self.assertEqual(a.index(0, 3, 4), 3)
self.assertEqual(a.index(0, -3, -2), 3)
- self.assertEqual(a.index(0, -4*sys.maxint, 4*sys.maxint), 2)
- self.assertRaises(ValueError, a.index, 0, 4*sys.maxint,-4*sys.maxint)
+ self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2)
+ self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize)
self.assertRaises(ValueError, a.index, 2, 0, -10)
a.remove(0)
self.assertRaises(ValueError, a.index, 2, 0, 4)
@@ -404,7 +404,7 @@ class CommonTest(seq_tests.CommonTest):
del self.victim[:]
return False
a = self.type2test()
- a[:] = [EvilCmp(a) for _ in xrange(100)]
+ a[:] = [EvilCmp(a) for _ in range(100)]
# This used to seg fault before patch #1005778
self.assertRaises(ValueError, a.index, None)
@@ -419,11 +419,6 @@ class CommonTest(seq_tests.CommonTest):
self.assertRaises(TypeError, u.reverse, 42)
def test_sort(self):
- with test_support.check_py3k_warnings(
- ("the cmp argument is not supported", DeprecationWarning)):
- self._test_sort()
-
- def _test_sort(self):
u = self.type2test([1, 0])
u.sort()
self.assertEqual(u, [0, 1])
@@ -435,24 +430,39 @@ class CommonTest(seq_tests.CommonTest):
self.assertRaises(TypeError, u.sort, 42, 42)
def revcmp(a, b):
- return cmp(b, a)
- u.sort(revcmp)
+ if a == b:
+ return 0
+ elif a < b:
+ return 1
+ else: # a > b
+ return -1
+ u.sort(key=cmp_to_key(revcmp))
self.assertEqual(u, self.type2test([2,1,0,-1,-2]))
# The following dumps core in unpatched Python 1.5:
def myComparison(x,y):
- return cmp(x%3, y%7)
+ xmod, ymod = x%3, y%7
+ if xmod == ymod:
+ return 0
+ elif xmod < ymod:
+ return -1
+ else: # xmod > ymod
+ return 1
z = self.type2test(range(12))
- z.sort(myComparison)
+ z.sort(key=cmp_to_key(myComparison))
self.assertRaises(TypeError, z.sort, 2)
def selfmodifyingComparison(x,y):
z.append(1)
- return cmp(x, y)
- self.assertRaises(ValueError, z.sort, selfmodifyingComparison)
-
- self.assertRaises(TypeError, z.sort, lambda x, y: 's')
+ if x == y:
+ return 0
+ elif x < y:
+ return -1
+ else: # x > y
+ return 1
+ self.assertRaises(ValueError, z.sort,
+ key=cmp_to_key(selfmodifyingComparison))
self.assertRaises(TypeError, z.sort, 42, 42, 42, 42)
@@ -462,7 +472,7 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(u, list("ham"))
def test_iadd(self):
- super(CommonTest, self).test_iadd()
+ super().test_iadd()
u = self.type2test([0, 1])
u2 = u
u += [2, 3]
diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index 966f9bd7ca0..094cc7a4597 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -4,11 +4,11 @@ Various tests for synchronization primitives.
import sys
import time
-from thread import start_new_thread, get_ident
+from _thread import start_new_thread, get_ident, TIMEOUT_MAX
import threading
import unittest
-from test import test_support as support
+from test import support
def _wait():
@@ -62,6 +62,14 @@ class BaseTestCase(unittest.TestCase):
support.threading_cleanup(*self._threads)
support.reap_children()
+ def assertTimeout(self, actual, expected):
+ # The waiting and/or time.time() can be imprecise, which
+ # is why comparing to the expected value would sometimes fail
+ # (especially under Windows).
+ self.assertGreaterEqual(actual, expected * 0.6)
+ # Test nothing insane happened
+ self.assertLess(actual, expected * 10.0)
+
class BaseLockTests(BaseTestCase):
"""
@@ -141,7 +149,39 @@ class BaseLockTests(BaseTestCase):
# We run many threads in the hope that existing threads ids won't
# be recycled.
Bunch(f, 15).wait_for_finished()
- self.assertEqual(n, len(threading.enumerate()))
+ if len(threading.enumerate()) != n:
+ # There is a small window during which a Thread instance's
+ # target function has finished running, but the Thread is still
+ # alive and registered. Avoid spurious failures by waiting a
+ # bit more (seen on a buildbot).
+ time.sleep(0.4)
+ self.assertEqual(n, len(threading.enumerate()))
+
+ def test_timeout(self):
+ lock = self.locktype()
+ # Can't set timeout if not blocking
+ self.assertRaises(ValueError, lock.acquire, 0, 1)
+ # Invalid timeout values
+ self.assertRaises(ValueError, lock.acquire, timeout=-100)
+ self.assertRaises(OverflowError, lock.acquire, timeout=1e100)
+ self.assertRaises(OverflowError, lock.acquire, timeout=TIMEOUT_MAX + 1)
+ # TIMEOUT_MAX is ok
+ lock.acquire(timeout=TIMEOUT_MAX)
+ lock.release()
+ t1 = time.time()
+ self.assertTrue(lock.acquire(timeout=5))
+ t2 = time.time()
+ # Just a sanity test that it didn't actually wait for the timeout.
+ self.assertLess(t2 - t1, 5)
+ results = []
+ def f():
+ t1 = time.time()
+ results.append(lock.acquire(timeout=0.5))
+ t2 = time.time()
+ results.append(t2 - t1)
+ Bunch(f, 1).wait_for_finished()
+ self.assertFalse(results[0])
+ self.assertTimeout(results[1], 0.5)
class LockTests(BaseLockTests):
@@ -179,6 +219,16 @@ class LockTests(BaseLockTests):
lock.acquire()
lock.release()
+ def test_state_after_timeout(self):
+ # Issue #11618: check that lock is in a proper state after a
+ # (non-zero) timeout.
+ lock = self.locktype()
+ lock.acquire()
+ self.assertFalse(lock.acquire(timeout=0.01))
+ lock.release()
+ self.assertFalse(lock.locked())
+ self.assertTrue(lock.acquire(blocking=False))
+
class RLockTests(BaseLockTests):
"""
@@ -284,14 +334,14 @@ class EventTests(BaseTestCase):
def f():
results1.append(evt.wait(0.0))
t1 = time.time()
- r = evt.wait(0.2)
+ r = evt.wait(0.5)
t2 = time.time()
results2.append((r, t2 - t1))
Bunch(f, N).wait_for_finished()
self.assertEqual(results1, [False] * N)
for r, dt in results2:
self.assertFalse(r)
- self.assertTrue(dt >= 0.2, dt)
+ self.assertTimeout(dt, 0.5)
# The event is set
results1 = []
results2 = []
@@ -301,6 +351,22 @@ class EventTests(BaseTestCase):
for r, dt in results2:
self.assertTrue(r)
+ def test_set_and_clear(self):
+ # Issue #13502: check that wait() returns true even when the event is
+ # cleared before the waiting thread is woken up.
+ evt = self.eventtype()
+ results = []
+ N = 5
+ def f():
+ results.append(evt.wait(1))
+ b = Bunch(f, N)
+ b.wait_for_started()
+ time.sleep(0.5)
+ evt.set()
+ evt.clear()
+ b.wait_for_finished()
+ self.assertEqual(results, [True] * N)
+
class ConditionTests(BaseTestCase):
"""
@@ -341,13 +407,13 @@ class ConditionTests(BaseTestCase):
phase_num = 0
def f():
cond.acquire()
- cond.wait()
+ result = cond.wait()
cond.release()
- results1.append(phase_num)
+ results1.append((result, phase_num))
cond.acquire()
- cond.wait()
+ result = cond.wait()
cond.release()
- results2.append(phase_num)
+ results2.append((result, phase_num))
b = Bunch(f, N)
b.wait_for_started()
_wait()
@@ -360,7 +426,7 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results1) < 3:
_wait()
- self.assertEqual(results1, [1] * 3)
+ self.assertEqual(results1, [(True, 1)] * 3)
self.assertEqual(results2, [])
# Notify 5 threads: they might be in their first or second wait
cond.acquire()
@@ -370,8 +436,8 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results1) + len(results2) < 8:
_wait()
- self.assertEqual(results1, [1] * 3 + [2] * 2)
- self.assertEqual(results2, [2] * 3)
+ self.assertEqual(results1, [(True, 1)] * 3 + [(True, 2)] * 2)
+ self.assertEqual(results2, [(True, 2)] * 3)
# Notify all threads: they are all in their second wait
cond.acquire()
cond.notify_all()
@@ -380,8 +446,8 @@ class ConditionTests(BaseTestCase):
cond.release()
while len(results2) < 5:
_wait()
- self.assertEqual(results1, [1] * 3 + [2] * 2)
- self.assertEqual(results2, [2] * 3 + [3] * 2)
+ self.assertEqual(results1, [(True, 1)] * 3 + [(True,2)] * 2)
+ self.assertEqual(results2, [(True, 2)] * 3 + [(True, 3)] * 2)
b.wait_for_finished()
def test_notify(self):
@@ -397,14 +463,60 @@ class ConditionTests(BaseTestCase):
def f():
cond.acquire()
t1 = time.time()
- cond.wait(0.2)
+ result = cond.wait(0.5)
t2 = time.time()
cond.release()
- results.append(t2 - t1)
+ results.append((t2 - t1, result))
Bunch(f, N).wait_for_finished()
- self.assertEqual(len(results), 5)
- for dt in results:
- self.assertTrue(dt >= 0.2, dt)
+ self.assertEqual(len(results), N)
+ for dt, result in results:
+ self.assertTimeout(dt, 0.5)
+ # Note that conceptually (that"s the condition variable protocol)
+ # a wait() may succeed even if no one notifies us and before any
+ # timeout occurs. Spurious wakeups can occur.
+ # This makes it hard to verify the result value.
+ # In practice, this implementation has no spurious wakeups.
+ self.assertFalse(result)
+
+ def test_waitfor(self):
+ cond = self.condtype()
+ state = 0
+ def f():
+ with cond:
+ result = cond.wait_for(lambda : state==4)
+ self.assertTrue(result)
+ self.assertEqual(state, 4)
+ b = Bunch(f, 1)
+ b.wait_for_started()
+ for i in range(4):
+ time.sleep(0.01)
+ with cond:
+ state += 1
+ cond.notify()
+ b.wait_for_finished()
+
+ def test_waitfor_timeout(self):
+ cond = self.condtype()
+ state = 0
+ success = []
+ def f():
+ with cond:
+ dt = time.time()
+ result = cond.wait_for(lambda : state==4, timeout=0.1)
+ dt = time.time() - dt
+ self.assertFalse(result)
+ self.assertTimeout(dt, 0.1)
+ success.append(None)
+ b = Bunch(f, 1)
+ b.wait_for_started()
+ # Only increment 3 times, so state == 4 is never reached.
+ for i in range(3):
+ time.sleep(0.01)
+ with cond:
+ state += 1
+ cond.notify()
+ b.wait_for_finished()
+ self.assertEqual(len(success), 1)
class BaseSemaphoreTests(BaseTestCase):
@@ -414,7 +526,7 @@ class BaseSemaphoreTests(BaseTestCase):
def test_constructor(self):
self.assertRaises(ValueError, self.semtype, value = -1)
- self.assertRaises(ValueError, self.semtype, value = -sys.maxint)
+ self.assertRaises(ValueError, self.semtype, value = -sys.maxsize)
def test_acquire(self):
sem = self.semtype(1)
@@ -487,6 +599,19 @@ class BaseSemaphoreTests(BaseTestCase):
# ordered.
self.assertEqual(sorted(results), [False] * 7 + [True] * 3 )
+ def test_acquire_timeout(self):
+ sem = self.semtype(2)
+ self.assertRaises(ValueError, sem.acquire, False, timeout=1.0)
+ self.assertTrue(sem.acquire(timeout=0.005))
+ self.assertTrue(sem.acquire(timeout=0.005))
+ self.assertFalse(sem.acquire(timeout=0.005))
+ sem.release()
+ self.assertTrue(sem.acquire(timeout=0.005))
+ t = time.time()
+ self.assertFalse(sem.acquire(timeout=0.5))
+ dt = time.time() - t
+ self.assertTimeout(dt, 0.5)
+
def test_default_value(self):
# The default initial value is 1.
sem = self.semtype()
@@ -544,3 +669,196 @@ class BoundedSemaphoreTests(BaseSemaphoreTests):
sem.acquire()
sem.release()
self.assertRaises(ValueError, sem.release)
+
+
+class BarrierTests(BaseTestCase):
+ """
+ Tests for Barrier objects.
+ """
+ N = 5
+ defaultTimeout = 2.0
+
+ def setUp(self):
+ self.barrier = self.barriertype(self.N, timeout=self.defaultTimeout)
+ def tearDown(self):
+ self.barrier.abort()
+
+ def run_threads(self, f):
+ b = Bunch(f, self.N-1)
+ f()
+ b.wait_for_finished()
+
+ def multipass(self, results, n):
+ m = self.barrier.parties
+ self.assertEqual(m, self.N)
+ for i in range(n):
+ results[0].append(True)
+ self.assertEqual(len(results[1]), i * m)
+ self.barrier.wait()
+ results[1].append(True)
+ self.assertEqual(len(results[0]), (i + 1) * m)
+ self.barrier.wait()
+ self.assertEqual(self.barrier.n_waiting, 0)
+ self.assertFalse(self.barrier.broken)
+
+ def test_barrier(self, passes=1):
+ """
+ Test that a barrier is passed in lockstep
+ """
+ results = [[],[]]
+ def f():
+ self.multipass(results, passes)
+ self.run_threads(f)
+
+ def test_barrier_10(self):
+ """
+ Test that a barrier works for 10 consecutive runs
+ """
+ return self.test_barrier(10)
+
+ def test_wait_return(self):
+ """
+ test the return value from barrier.wait
+ """
+ results = []
+ def f():
+ r = self.barrier.wait()
+ results.append(r)
+
+ self.run_threads(f)
+ self.assertEqual(sum(results), sum(range(self.N)))
+
+ def test_action(self):
+ """
+ Test the 'action' callback
+ """
+ results = []
+ def action():
+ results.append(True)
+ barrier = self.barriertype(self.N, action)
+ def f():
+ barrier.wait()
+ self.assertEqual(len(results), 1)
+
+ self.run_threads(f)
+
+ def test_abort(self):
+ """
+ Test that an abort will put the barrier in a broken state
+ """
+ results1 = []
+ results2 = []
+ def f():
+ try:
+ i = self.barrier.wait()
+ if i == self.N//2:
+ raise RuntimeError
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ except RuntimeError:
+ self.barrier.abort()
+ pass
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertTrue(self.barrier.broken)
+
+ def test_reset(self):
+ """
+ Test that a 'reset' on a barrier frees the waiting threads
+ """
+ results1 = []
+ results2 = []
+ results3 = []
+ def f():
+ i = self.barrier.wait()
+ if i == self.N//2:
+ # Wait until the other threads are all in the barrier.
+ while self.barrier.n_waiting < self.N-1:
+ time.sleep(0.001)
+ self.barrier.reset()
+ else:
+ try:
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ # Now, pass the barrier again
+ self.barrier.wait()
+ results3.append(True)
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertEqual(len(results3), self.N)
+
+
+ def test_abort_and_reset(self):
+ """
+ Test that a barrier can be reset after being broken.
+ """
+ results1 = []
+ results2 = []
+ results3 = []
+ barrier2 = self.barriertype(self.N)
+ def f():
+ try:
+ i = self.barrier.wait()
+ if i == self.N//2:
+ raise RuntimeError
+ self.barrier.wait()
+ results1.append(True)
+ except threading.BrokenBarrierError:
+ results2.append(True)
+ except RuntimeError:
+ self.barrier.abort()
+ pass
+ # Synchronize and reset the barrier. Must synchronize first so
+ # that everyone has left it when we reset, and after so that no
+ # one enters it before the reset.
+ if barrier2.wait() == self.N//2:
+ self.barrier.reset()
+ barrier2.wait()
+ self.barrier.wait()
+ results3.append(True)
+
+ self.run_threads(f)
+ self.assertEqual(len(results1), 0)
+ self.assertEqual(len(results2), self.N-1)
+ self.assertEqual(len(results3), self.N)
+
+ def test_timeout(self):
+ """
+ Test wait(timeout)
+ """
+ def f():
+ i = self.barrier.wait()
+ if i == self.N // 2:
+ # One thread is late!
+ time.sleep(1.0)
+ # Default timeout is 2.0, so this is shorter.
+ self.assertRaises(threading.BrokenBarrierError,
+ self.barrier.wait, 0.5)
+ self.run_threads(f)
+
+ def test_default_timeout(self):
+ """
+ Test the barrier's default timeout
+ """
+ # create a barrier with a low default timeout
+ barrier = self.barriertype(self.N, timeout=0.3)
+ def f():
+ i = barrier.wait()
+ if i == self.N // 2:
+ # One thread is later than the default timeout of 0.3s.
+ time.sleep(1.0)
+ self.assertRaises(threading.BrokenBarrierError, barrier.wait)
+ self.run_threads(f)
+
+ def test_single_thread(self):
+ b = self.barriertype(1)
+ b.wait()
+ b.wait()
diff --git a/Lib/test/make_ssl_certs.py b/Lib/test/make_ssl_certs.py
new file mode 100644
index 00000000000..48d2e57f4be
--- /dev/null
+++ b/Lib/test/make_ssl_certs.py
@@ -0,0 +1,64 @@
+"""Make the custom certificate and private key files used by test_ssl
+and friends."""
+
+import os
+import sys
+import tempfile
+from subprocess import *
+
+req_template = """
+ [req]
+ distinguished_name = req_distinguished_name
+ x509_extensions = req_x509_extensions
+ prompt = no
+
+ [req_distinguished_name]
+ C = XY
+ L = Castle Anthrax
+ O = Python Software Foundation
+ CN = {hostname}
+
+ [req_x509_extensions]
+ subjectAltName = DNS:{hostname}
+ """
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+def make_cert_key(hostname):
+ tempnames = []
+ for i in range(3):
+ with tempfile.NamedTemporaryFile(delete=False) as f:
+ tempnames.append(f.name)
+ req_file, cert_file, key_file = tempnames
+ try:
+ with open(req_file, 'w') as f:
+ f.write(req_template.format(hostname=hostname))
+ args = ['req', '-new', '-days', '3650', '-nodes', '-x509',
+ '-newkey', 'rsa:1024', '-keyout', key_file,
+ '-out', cert_file, '-config', req_file]
+ check_call(['openssl'] + args)
+ with open(cert_file, 'r') as f:
+ cert = f.read()
+ with open(key_file, 'r') as f:
+ key = f.read()
+ return cert, key
+ finally:
+ for name in tempnames:
+ os.remove(name)
+
+
+if __name__ == '__main__':
+ os.chdir(here)
+ cert, key = make_cert_key('localhost')
+ with open('ssl_cert.pem', 'w') as f:
+ f.write(cert)
+ with open('ssl_key.pem', 'w') as f:
+ f.write(key)
+ with open('keycert.pem', 'w') as f:
+ f.write(key)
+ f.write(cert)
+ # For certificate matching tests
+ cert, key = make_cert_key('fakehostname')
+ with open('keycert2.pem', 'w') as f:
+ f.write(key)
+ f.write(cert)
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py
index f43750bb83f..bc12c7756f2 100644
--- a/Lib/test/mapping_tests.py
+++ b/Lib/test/mapping_tests.py
@@ -1,7 +1,6 @@
# tests common to dict and UserDict
import unittest
-import UserDict
-import test_support
+import collections
class BasicTestMappingProtocol(unittest.TestCase):
@@ -15,7 +14,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
def _reference(self):
"""Return a dictionary of values which are invariant by storage
in the object under test."""
- return {1:2, "key1":"value1", "key2":(1,2,3)}
+ return {"1": "2", "key1":"value1", "key2":(1,2,3)}
def _empty_mapping(self):
"""Return an empty mapping object"""
return self.type2test()
@@ -50,43 +49,40 @@ class BasicTestMappingProtocol(unittest.TestCase):
#Indexing
for key, value in self.reference.items():
self.assertEqual(d[key], value)
- knownkey = self.other.keys()[0]
+ knownkey = list(self.other.keys())[0]
self.assertRaises(KeyError, lambda:d[knownkey])
#len
self.assertEqual(len(p), 0)
self.assertEqual(len(d), len(self.reference))
- #in
+ #__contains__
for k in self.reference:
self.assertIn(k, d)
for k in self.other:
self.assertNotIn(k, d)
- #has_key
- with test_support.check_py3k_warnings(quiet=True):
- for k in self.reference:
- self.assertTrue(d.has_key(k))
- for k in self.other:
- self.assertFalse(d.has_key(k))
#cmp
- self.assertEqual(cmp(p,p), 0)
- self.assertEqual(cmp(d,d), 0)
- self.assertEqual(cmp(p,d), -1)
- self.assertEqual(cmp(d,p), 1)
+ self.assertEqual(p, p)
+ self.assertEqual(d, d)
+ self.assertNotEqual(p, d)
+ self.assertNotEqual(d, p)
#__non__zero__
if p: self.fail("Empty mapping must compare to False")
if not d: self.fail("Full mapping must compare to True")
# keys(), items(), iterkeys() ...
def check_iterandlist(iter, lst, ref):
- self.assertTrue(hasattr(iter, 'next'))
+ self.assertTrue(hasattr(iter, '__next__'))
self.assertTrue(hasattr(iter, '__iter__'))
x = list(iter)
self.assertTrue(set(x)==set(lst)==set(ref))
- check_iterandlist(d.iterkeys(), d.keys(), self.reference.keys())
- check_iterandlist(iter(d), d.keys(), self.reference.keys())
- check_iterandlist(d.itervalues(), d.values(), self.reference.values())
- check_iterandlist(d.iteritems(), d.items(), self.reference.items())
+ check_iterandlist(iter(d.keys()), list(d.keys()),
+ self.reference.keys())
+ check_iterandlist(iter(d), list(d.keys()), self.reference.keys())
+ check_iterandlist(iter(d.values()), list(d.values()),
+ self.reference.values())
+ check_iterandlist(iter(d.items()), list(d.items()),
+ self.reference.items())
#get
- key, value = d.iteritems().next()
- knownkey, knownvalue = self.other.iteritems().next()
+ key, value = next(iter(d.items()))
+ knownkey, knownvalue = next(iter(self.other.items()))
self.assertEqual(d.get(key, knownvalue), value)
self.assertEqual(d.get(knownkey, knownvalue), knownvalue)
self.assertNotIn(knownkey, d)
@@ -105,14 +101,14 @@ class BasicTestMappingProtocol(unittest.TestCase):
#update
p.update(self.reference)
self.assertEqual(dict(p), self.reference)
- items = p.items()
+ items = list(p.items())
p = self._empty_mapping()
p.update(items)
self.assertEqual(dict(p), self.reference)
d = self._full_mapping(self.reference)
#setdefault
- key, value = d.iteritems().next()
- knownkey, knownvalue = self.other.iteritems().next()
+ key, value = next(iter(d.items()))
+ knownkey, knownvalue = next(iter(self.other.items()))
self.assertEqual(d.setdefault(key, knownvalue), value)
self.assertEqual(d[key], value)
self.assertEqual(d.setdefault(knownkey, knownvalue), knownvalue)
@@ -144,21 +140,21 @@ class BasicTestMappingProtocol(unittest.TestCase):
def test_keys(self):
d = self._empty_mapping()
- self.assertEqual(d.keys(), [])
+ self.assertEqual(list(d.keys()), [])
d = self.reference
- self.assertIn(self.inmapping.keys()[0], d.keys())
- self.assertNotIn(self.other.keys()[0], d.keys())
+ self.assertIn(list(self.inmapping.keys())[0], d.keys())
+ self.assertNotIn(list(self.other.keys())[0], d.keys())
self.assertRaises(TypeError, d.keys, None)
def test_values(self):
d = self._empty_mapping()
- self.assertEqual(d.values(), [])
+ self.assertEqual(list(d.values()), [])
self.assertRaises(TypeError, d.values, None)
def test_items(self):
d = self._empty_mapping()
- self.assertEqual(d.items(), [])
+ self.assertEqual(list(d.items()), [])
self.assertRaises(TypeError, d.items, None)
@@ -168,7 +164,8 @@ class BasicTestMappingProtocol(unittest.TestCase):
def test_getitem(self):
d = self.reference
- self.assertEqual(d[self.inmapping.keys()[0]], self.inmapping.values()[0])
+ self.assertEqual(d[list(self.inmapping.keys())[0]],
+ list(self.inmapping.values())[0])
self.assertRaises(TypeError, d.__getitem__)
@@ -176,7 +173,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
# mapping argument
d = self._empty_mapping()
d.update(self.other)
- self.assertEqual(d.items(), self.other.items())
+ self.assertEqual(list(d.items()), list(self.other.items()))
# No argument
d = self._empty_mapping()
@@ -186,12 +183,12 @@ class BasicTestMappingProtocol(unittest.TestCase):
# item sequence
d = self._empty_mapping()
d.update(self.other.items())
- self.assertEqual(d.items(), self.other.items())
+ self.assertEqual(list(d.items()), list(self.other.items()))
# Iterator
d = self._empty_mapping()
- d.update(self.other.iteritems())
- self.assertEqual(d.items(), self.other.items())
+ d.update(self.other.items())
+ self.assertEqual(list(d.items()), list(self.other.items()))
# FIXME: Doesn't work with UserDict
# self.assertRaises((TypeError, AttributeError), d.update, None)
@@ -207,14 +204,8 @@ class BasicTestMappingProtocol(unittest.TestCase):
return self.d[i]
d.clear()
d.update(SimpleUserDict())
- i1 = d.items()
- i2 = self.reference.items()
-
- def safe_sort_key(kv):
- k, v = kv
- return id(type(k)), id(type(v)), k, v
- i1.sort(key=safe_sort_key)
- i2.sort(key=safe_sort_key)
+ i1 = sorted(d.items())
+ i2 = sorted(self.reference.items())
self.assertEqual(i1, i2)
class Exc(Exception): pass
@@ -234,7 +225,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
self.i = 1
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i:
self.i = 0
return 'a'
@@ -251,7 +242,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
self.i = ord('a')
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i <= ord('z'):
rtn = chr(self.i)
self.i += 1
@@ -266,7 +257,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
class badseq(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise Exc()
self.assertRaises(Exc, d.update, badseq())
@@ -277,13 +268,15 @@ class BasicTestMappingProtocol(unittest.TestCase):
def test_get(self):
d = self._empty_mapping()
- self.assertTrue(d.get(self.other.keys()[0]) is None)
- self.assertEqual(d.get(self.other.keys()[0], 3), 3)
+ self.assertTrue(d.get(list(self.other.keys())[0]) is None)
+ self.assertEqual(d.get(list(self.other.keys())[0], 3), 3)
d = self.reference
- self.assertTrue(d.get(self.other.keys()[0]) is None)
- self.assertEqual(d.get(self.other.keys()[0], 3), 3)
- self.assertEqual(d.get(self.inmapping.keys()[0]), self.inmapping.values()[0])
- self.assertEqual(d.get(self.inmapping.keys()[0], 3), self.inmapping.values()[0])
+ self.assertTrue(d.get(list(self.other.keys())[0]) is None)
+ self.assertEqual(d.get(list(self.other.keys())[0], 3), 3)
+ self.assertEqual(d.get(list(self.inmapping.keys())[0]),
+ list(self.inmapping.values())[0])
+ self.assertEqual(d.get(list(self.inmapping.keys())[0], 3),
+ list(self.inmapping.values())[0])
self.assertRaises(TypeError, d.get)
self.assertRaises(TypeError, d.get, None, None, None)
@@ -298,9 +291,9 @@ class BasicTestMappingProtocol(unittest.TestCase):
def test_pop(self):
d = self._empty_mapping()
- k, v = self.inmapping.items()[0]
+ k, v = list(self.inmapping.items())[0]
d[k] = v
- self.assertRaises(KeyError, d.pop, self.other.keys()[0])
+ self.assertRaises(KeyError, d.pop, list(self.other.keys())[0])
self.assertEqual(d.pop(k), v)
self.assertEqual(len(d), 0)
@@ -324,7 +317,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
def test_keys(self):
BasicTestMappingProtocol.test_keys(self)
d = self._empty_mapping()
- self.assertEqual(d.keys(), [])
+ self.assertEqual(list(d.keys()), [])
d = self._full_mapping({'a': 1, 'b': 2})
k = d.keys()
self.assertIn('a', k)
@@ -334,23 +327,13 @@ class TestMappingProtocol(BasicTestMappingProtocol):
def test_values(self):
BasicTestMappingProtocol.test_values(self)
d = self._full_mapping({1:2})
- self.assertEqual(d.values(), [2])
+ self.assertEqual(list(d.values()), [2])
def test_items(self):
BasicTestMappingProtocol.test_items(self)
d = self._full_mapping({1:2})
- self.assertEqual(d.items(), [(1, 2)])
-
- def test_has_key(self):
- d = self._empty_mapping()
- self.assertTrue(not d.has_key('a'))
- d = self._full_mapping({'a': 1, 'b': 2})
- k = d.keys()
- k.sort(key=lambda k: (id(type(k)), k))
- self.assertEqual(k, ['a', 'b'])
-
- self.assertRaises(TypeError, d.has_key)
+ self.assertEqual(list(d.items()), [(1, 2)])
def test_contains(self):
d = self._empty_mapping()
@@ -422,7 +405,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
# iterator
d = self._full_mapping({1:3, 2:4})
- d.update(self._full_mapping({1:2, 3:4, 5:6}).iteritems())
+ d.update(self._full_mapping({1:2, 3:4, 5:6}).items())
self.assertEqual(d, {1:2, 2:4, 3:4, 5:6})
class SimpleUserDict:
@@ -452,15 +435,13 @@ class TestMappingProtocol(BasicTestMappingProtocol):
self.assertEqual(dictlike().fromkeys('a'), {'a':None})
self.assertTrue(dictlike.fromkeys('a').__class__ is dictlike)
self.assertTrue(dictlike().fromkeys('a').__class__ is dictlike)
- # FIXME: the following won't work with UserDict, because it's an old style class
- # self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
+ self.assertTrue(type(dictlike.fromkeys('a')) is dictlike)
class mydict(self.type2test):
def __new__(cls):
- return UserDict.UserDict()
+ return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- # FIXME: the following won't work with UserDict, because it's an old style class
- # self.assertIsInstance(ud, UserDict.UserDict)
+ self.assertIsInstance(ud, collections.UserDict)
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -474,7 +455,7 @@ class TestMappingProtocol(BasicTestMappingProtocol):
class BadSeq(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise Exc()
self.assertRaises(Exc, self.type2test.fromkeys, BadSeq())
@@ -546,13 +527,6 @@ class TestMappingProtocol(BasicTestMappingProtocol):
d = self._empty_mapping()
k, v = 'abc', 'def'
- # verify longs/ints get same value when key > 32 bits (for 64-bit archs)
- # see SF bug #689659
- x = 4503599627370496L
- y = 4503599627370496
- h = self._full_mapping({x: 'anything', y: 'something else'})
- self.assertEqual(h[x], h[y])
-
self.assertEqual(d.pop(k, v), v)
d[k] = v
self.assertEqual(d.pop(k, 1), v)
@@ -592,10 +566,10 @@ class TestHashMappingProtocol(TestMappingProtocol):
TestMappingProtocol.test_fromkeys(self)
class mydict(self.type2test):
def __new__(cls):
- return UserDict.UserDict()
+ return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assertIsInstance(ud, UserDict.UserDict)
+ self.assertIsInstance(ud, collections.UserDict)
def test_pop(self):
TestMappingProtocol.test_pop(self)
@@ -645,9 +619,10 @@ class TestHashMappingProtocol(TestMappingProtocol):
d = self._full_mapping({1: BadRepr()})
self.assertRaises(Exc, repr, d)
- def test_le(self):
- self.assertTrue(not (self._empty_mapping() < self._empty_mapping()))
- self.assertTrue(not (self._full_mapping({1: 2}) < self._full_mapping({1L: 2L})))
+ def test_eq(self):
+ self.assertEqual(self._empty_mapping(), self._empty_mapping())
+ self.assertEqual(self._full_mapping({1: 2}),
+ self._full_mapping({1: 2}))
class Exc(Exception): pass
@@ -655,16 +630,12 @@ class TestHashMappingProtocol(TestMappingProtocol):
def __eq__(self, other):
raise Exc()
def __hash__(self):
- return 42
+ return 1
d1 = self._full_mapping({BadCmp(): 1})
d2 = self._full_mapping({1: 1})
- try:
- d1 < d2
- except Exc:
- pass
- else:
- self.fail("< didn't raise Exc")
+ self.assertRaises(Exc, lambda: BadCmp()==1)
+ self.assertRaises(Exc, lambda: d1==d2)
def test_setdefault(self):
TestMappingProtocol.test_setdefault(self)
diff --git a/Lib/test/math_testcases.txt b/Lib/test/math_testcases.txt
index be1a49f0d36..5e24335a879 100644
--- a/Lib/test/math_testcases.txt
+++ b/Lib/test/math_testcases.txt
@@ -371,6 +371,78 @@ gam0141 gamma -127.45117632943295 -> 1.1831110896236810e-214
-----------------------------------------------------------
+-- log1p: log(1 + x), without precision loss for small x --
+-----------------------------------------------------------
+
+-- special values
+log1p0000 log1p 0.0 -> 0.0
+log1p0001 log1p -0.0 -> -0.0
+log1p0002 log1p inf -> inf
+log1p0003 log1p -inf -> nan invalid
+log1p0004 log1p nan -> nan
+
+-- singularity at -1.0
+log1p0010 log1p -1.0 -> -inf divide-by-zero
+log1p0011 log1p -0.9999999999999999 -> -36.736800569677101
+
+-- finite values < 1.0 are invalid
+log1p0020 log1p -1.0000000000000002 -> nan invalid
+log1p0021 log1p -1.1 -> nan invalid
+log1p0022 log1p -2.0 -> nan invalid
+log1p0023 log1p -1e300 -> nan invalid
+
+-- tiny x: log1p(x) ~ x
+log1p0110 log1p 5e-324 -> 5e-324
+log1p0111 log1p 1e-320 -> 1e-320
+log1p0112 log1p 1e-300 -> 1e-300
+log1p0113 log1p 1e-150 -> 1e-150
+log1p0114 log1p 1e-20 -> 1e-20
+
+log1p0120 log1p -5e-324 -> -5e-324
+log1p0121 log1p -1e-320 -> -1e-320
+log1p0122 log1p -1e-300 -> -1e-300
+log1p0123 log1p -1e-150 -> -1e-150
+log1p0124 log1p -1e-20 -> -1e-20
+
+-- some (mostly) random small and moderate-sized values
+log1p0200 log1p -0.89156889782277482 -> -2.2216403106762863
+log1p0201 log1p -0.23858496047770464 -> -0.27257668276980057
+log1p0202 log1p -0.011641726191307515 -> -0.011710021654495657
+log1p0203 log1p -0.0090126398571693817 -> -0.0090534993825007650
+log1p0204 log1p -0.00023442805985712781 -> -0.00023445554240995693
+log1p0205 log1p -1.5672870980936349e-5 -> -1.5672993801662046e-5
+log1p0206 log1p -7.9650013274825295e-6 -> -7.9650330482740401e-6
+log1p0207 log1p -2.5202948343227410e-7 -> -2.5202951519170971e-7
+log1p0208 log1p -8.2446372820745855e-11 -> -8.2446372824144559e-11
+log1p0209 log1p -8.1663670046490789e-12 -> -8.1663670046824230e-12
+log1p0210 log1p 7.0351735084656292e-18 -> 7.0351735084656292e-18
+log1p0211 log1p 5.2732161907375226e-12 -> 5.2732161907236188e-12
+log1p0212 log1p 1.0000000000000000e-10 -> 9.9999999995000007e-11
+log1p0213 log1p 2.1401273266000197e-9 -> 2.1401273243099470e-9
+log1p0214 log1p 1.2668914653979560e-8 -> 1.2668914573728861e-8
+log1p0215 log1p 1.6250007816299069e-6 -> 1.6249994613175672e-6
+log1p0216 log1p 8.3740495645839399e-6 -> 8.3740145024266269e-6
+log1p0217 log1p 3.0000000000000001e-5 -> 2.9999550008999799e-5
+log1p0218 log1p 0.0070000000000000001 -> 0.0069756137364252423
+log1p0219 log1p 0.013026235315053002 -> 0.012942123564008787
+log1p0220 log1p 0.013497160797236184 -> 0.013406885521915038
+log1p0221 log1p 0.027625599078135284 -> 0.027250897463483054
+log1p0222 log1p 0.14179687245544870 -> 0.13260322540908789
+
+-- large values
+log1p0300 log1p 1.7976931348623157e+308 -> 709.78271289338397
+log1p0301 log1p 1.0000000000000001e+300 -> 690.77552789821368
+log1p0302 log1p 1.0000000000000001e+70 -> 161.18095650958321
+log1p0303 log1p 10000000000.000000 -> 23.025850930040455
+
+-- other values transferred from testLog1p in test_math
+log1p0400 log1p -0.63212055882855767 -> -1.0000000000000000
+log1p0401 log1p 1.7182818284590451 -> 1.0000000000000000
+log1p0402 log1p 1.0000000000000000 -> 0.69314718055994529
+log1p0403 log1p 1.2379400392853803e+27 -> 62.383246250395075
+
+
+-----------------------------------------------------------
-- expm1: exp(x) - 1, without precision loss for small x --
-----------------------------------------------------------
diff --git a/Lib/test/mime.types b/Lib/test/mime.types
new file mode 100644
index 00000000000..68724430c8a
--- /dev/null
+++ b/Lib/test/mime.types
@@ -0,0 +1,1445 @@
+# This is a comment. I love comments. -*- indent-tabs-mode: t -*-
+
+# This file controls what Internet media types are sent to the client for
+# given file extension(s). Sending the correct media type to the client
+# is important so they know how to handle the content of the file.
+# Extra types can either be added here or by using an AddType directive
+# in your config files. For more information about Internet media types,
+# please read RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type
+# registry is at <http://www.iana.org/assignments/media-types/>.
+
+# IANA types
+
+# MIME type Extensions
+application/1d-interleaved-parityfec
+application/3gpp-ims+xml
+application/activemessage
+application/andrew-inset ez
+application/applefile
+application/atom+xml atom
+application/atomcat+xml atomcat
+application/atomicmail
+application/atomsvc+xml atomsvc
+application/auth-policy+xml apxml
+application/batch-SMTP
+application/beep+xml
+application/cals-1840
+application/ccxml+xml ccxml
+application/cdmi-capability cdmia
+application/cdmi-container cdmic
+application/cdmi-domain cdmid
+application/cdmi-object cdmio
+application/cdmi-queue cdmiq
+application/cea-2018+xml
+application/cellml+xml cellml cml
+application/cfw
+application/cnrp+xml
+application/commonground
+application/conference-info+xml
+application/cpl+xml cpl
+application/csta+xml
+application/CSTAdata+xml
+application/cybercash
+application/davmount+xml davmount
+application/dca-rft
+application/dec-dx
+application/dialog-info+xml
+application/dicom dcm
+application/dns
+application/dskpp+xml xmls
+application/dssc+der dssc
+application/dssc+xml xdssc
+application/dvcs dvc
+application/ecmascript
+application/EDI-Consent
+application/EDI-X12
+application/EDIFACT
+application/emma+xml emma
+application/epp+xml
+application/eshop
+application/exi exi
+application/fastinfoset finf
+application/fastsoap
+# fits, fit, fts: image/fits
+application/fits
+application/font-tdpfr pfr
+application/framework-attributes+xml
+application/H224
+application/hal+xml hal
+application/held+xml
+application/http
+application/hyperstudio stk
+application/ibe-key-request+xml
+application/ibe-pkg-reply+xml
+application/ibe-pp-data
+application/iges
+application/im-iscomposing+xml
+application/index
+application/index.cmd
+application/index.obj
+application/index.response
+application/index.vnd
+application/iotp
+application/ipfix ipfix
+application/ipp
+application/isup
+application/javascript js
+application/json json
+application/kpml-request+xml
+application/kpml-response+xml
+application/lost+xml lostxml
+application/mac-binhex40 hqx
+application/macwriteii
+application/mads+xml mads
+application/marc mrc
+application/marcxml+xml mrcx
+application/mathematica nb ma mb
+application/mathml-content+xml
+application/mathml-presentation+xml
+application/mathml+xml mml
+application/mbms-associated-procedure-description+xml
+application/mbms-deregister+xml
+application/mbms-envelope+xml
+application/mbms-msk-response+xml
+application/mbms-msk+xml
+application/mbms-protection-description+xml
+application/mbms-reception-report+xml
+application/mbms-register-response+xml
+application/mbms-register+xml
+application/mbms-user-service-description+xml
+application/mbox mbox
+application/media_control+xml
+application/mediaservercontrol+xml
+application/metalink4+xml meta4
+application/mets+xml mets
+application/mikey
+application/mods+xml mods
+application/moss-keys
+application/moss-signature
+application/mosskey-data
+application/mosskey-request
+application/mp21 m21 mp21
+# mp4, mpg4: video/mp4, see RFC 4337
+application/mp4
+application/mpeg4-generic
+application/mpeg4-iod
+application/mpeg4-iod-xmt
+application/msc-ivr+xml
+application/msc-mixer+xml
+application/msword doc
+application/mxf mxf
+application/nasdata
+application/news-checkgroups
+application/news-groupinfo
+application/news-transmission
+application/nss
+application/ocsp-request orq
+application/ocsp-response ors
+application/octet-stream bin lha lzh exe class so dll img iso
+application/oda oda
+application/oebps-package+xml opf
+application/ogg ogx
+application/parityfec
+# xer: application/xcap-error+xml
+application/patch-ops-error+xml
+application/pdf pdf
+application/pgp-encrypted
+application/pgp-keys
+application/pgp-signature sig
+application/pidf-diff+xml
+application/pidf+xml
+application/pkcs10 p10
+application/pkcs7-mime p7m p7c
+application/pkcs7-signature p7s
+application/pkcs8 p8
+# ac: application/vnd.nokia.n-gage.ac+xml
+application/pkix-attr-cert
+application/pkix-cert cer
+application/pkix-crl crl
+application/pkix-pkipath pkipath
+application/pkixcmp
+application/pls+xml pls
+application/poc-settings+xml
+application/postscript ps eps ai
+application/prs.alvestrand.titrax-sheet
+application/prs.cww cw cww
+application/prs.nprend rnd rct
+application/prs.plucker
+application/prs.rdf-xml-crypt rdf-crypt
+application/prs.xsf+xml xsf
+application/pskc+xml pskcxml
+application/qsig
+application/rdf+xml rdf
+application/reginfo+xml rif
+application/relax-ng-compact-syntax rnc
+application/remote-printing
+application/resource-lists-diff+xml rld
+application/resource-lists+xml rl
+application/riscos
+application/rlmi+xml
+application/rls-services+xml rs
+application/rtf rtf
+application/rtx
+application/samlassertion+xml
+application/samlmetadata+xml
+application/sbml+xml
+application/scvp-cv-request scq
+application/scvp-cv-response scs
+application/scvp-vp-request spq
+application/scvp-vp-response spp
+application/sdp sdp
+application/set-payment
+application/set-payment-initiation
+application/set-registration
+application/set-registration-initiation
+application/sgml
+application/sgml-open-catalog soc
+application/shf+xml shf
+application/sieve siv sieve
+application/simple-filter+xml cl
+application/simple-message-summary
+application/simpleSymbolContainer
+application/slate
+# obsoleted by application/smil+xml
+application/smil smil smi sml
+# smil, smi: application/smil for now
+application/smil+xml
+application/soap+fastinfoset
+application/soap+xml
+application/sparql-query rq
+application/sparql-results+xml srx
+application/spirits-event+xml
+application/srgs gram
+application/srgs+xml grxml
+application/sru+xml sru
+application/ssml+xml ssml
+application/tamp-apex-update tau
+application/tamp-apex-update-confirm auc
+application/tamp-community-update tcu
+application/tamp-community-update-confirm cuc
+application/tamp-error ter
+application/tamp-sequence-adjust tsa
+application/tamp-sequence-adjust-confirm sac
+# tsq: application/timestamp-query
+application/tamp-status-query
+# tsr: application/timestamp-reply
+application/tamp-status-response
+application/tamp-update tur
+application/tamp-update-confirm tuc
+application/tei+xml tei teiCorpus odd
+application/thraud+xml tfi
+application/timestamp-query tsq
+application/timestamp-reply tsr
+application/timestamped-data tsd
+application/tve-trigger
+application/ulpfec
+application/vemmi
+application/vnd.3gpp.bsf+xml
+application/vnd.3gpp.pic-bw-large plb
+application/vnd.3gpp.pic-bw-small psb
+application/vnd.3gpp.pic-bw-var pvb
+# sms: application/vnd.3gpp2.sms
+application/vnd.3gpp.sms
+application/vnd.3gpp2.bcmcsinfo+xml
+application/vnd.3gpp2.sms sms
+application/vnd.3gpp2.tcap tcap
+application/vnd.3M.Post-it-Notes pwn
+application/vnd.accpac.simply.aso aso
+application/vnd.accpac.simply.imp imp
+application/vnd.acucobol acu
+application/vnd.acucorp atc acutc
+application/vnd.adobe.fxp fxp fxpl
+application/vnd.adobe.partial-upload
+application/vnd.adobe.xdp+xml xdp
+application/vnd.adobe.xfdf xfdf
+application/vnd.aether.imp
+application/vnd.ah-barcode
+application/vnd.ahead.space ahead
+application/vnd.airzip.filesecure.azf azf
+application/vnd.airzip.filesecure.azs azs
+application/vnd.americandynamics.acc acc
+application/vnd.amiga.ami ami
+application/vnd.amundsen.maze+xml
+application/vnd.anser-web-certificate-issue-initiation cii
+# Not in IANA listing, but is on FTP site?
+application/vnd.anser-web-funds-transfer-initiation fti
+# atx: audio/ATRAC-X
+application/vnd.antix.game-component
+application/vnd.apple.installer+xml dist distz pkg mpkg
+# m3u: application/x-mpegurl for now
+application/vnd.apple.mpegurl m3u8
+application/vnd.aristanetworks.swi swi
+application/vnd.audiograph aep
+application/vnd.autopackage package
+application/vnd.avistar+xml
+application/vnd.blueice.multipass mpm
+application/vnd.bluetooth.ep.oob ep
+application/vnd.bmi bmi
+application/vnd.businessobjects rep
+application/vnd.cab-jscript
+application/vnd.canon-cpdl
+application/vnd.canon-lips
+application/vnd.cendio.thinlinc.clientconf tlclient
+application/vnd.chemdraw+xml cdxml
+application/vnd.chipnuts.karaoke-mmd mmd
+application/vnd.cinderella cdy
+application/vnd.cirpack.isdn-ext
+application/vnd.claymore cla
+application/vnd.cloanto.rp9 rp9
+application/vnd.clonk.c4group c4g c4d c4f c4p c4u
+application/vnd.cluetrust.cartomobile-config c11amc
+application/vnd.cluetrust.cartomobile-config-pkg c11amz
+# icc: application/vnd.iccprofile
+application/vnd.commerce-battelle ica icf icd ic0 ic1 ic2 ic3 ic4 ic5 ic6 ic7 ic8
+application/vnd.commonspace csp cst
+application/vnd.contact.cmsg cdbcmsg
+application/vnd.cosmocaller cmc
+application/vnd.crick.clicker clkx
+application/vnd.crick.clicker.keyboard clkk
+application/vnd.crick.clicker.palette clkp
+application/vnd.crick.clicker.template clkt
+application/vnd.crick.clicker.wordbank clkw
+application/vnd.criticaltools.wbs+xml wbs
+application/vnd.ctc-posml pml
+application/vnd.ctct.ws+xml
+application/vnd.cups-pdf
+application/vnd.cups-postscript
+application/vnd.cups-ppd ppd
+application/vnd.cups-raster
+application/vnd.cups-raw
+application/vnd.curl curl
+application/vnd.cybank
+application/vnd.data-vision.rdz rdz
+application/vnd.dece.data uvf uvvf uvd uvvd
+application/vnd.dece.ttml+xml uvt uvvt
+application/vnd.dece.unspecified uvx uvvx
+application/vnd.denovo.fcselayout-link fe_launch
+application/vnd.dir-bi.plate-dl-nosuffix
+application/vnd.dna dna
+application/vnd.dolby.mobile.1
+application/vnd.dolby.mobile.2
+application/vnd.dpgraph dpg mwc dpgraph
+application/vnd.dreamfactory dfac
+application/vnd.dvb.ait ait
+# class: application/octet-stream
+application/vnd.dvb.dvbj
+application/vnd.dvb.esgcontainer
+application/vnd.dvb.ipdcdftnotifaccess
+application/vnd.dvb.ipdcesgaccess
+application/vnd.dvb.ipdcesgaccess2
+application/vnd.dvb.ipdcesgpdd
+application/vnd.dvb.ipdcroaming
+application/vnd.dvb.iptv.alfec-base
+application/vnd.dvb.iptv.alfec-enhancement
+application/vnd.dvb.notif-aggregate-root+xml
+application/vnd.dvb.notif-container+xml
+application/vnd.dvb.notif-generic+xml
+application/vnd.dvb.notif-ia-msglist+xml
+application/vnd.dvb.notif-ia-registration-request+xml
+application/vnd.dvb.notif-ia-registration-response+xml
+application/vnd.dvb.notif-init+xml
+# pfr: application/font-tdpfr
+application/vnd.dvb.pfr
+application/vnd.dvb.service svc
+# dxr: application/x-director
+application/vnd.dxr
+application/vnd.dynageo geo
+application/vnd.easykaraoke.cdgdownload
+application/vnd.ecdis-update
+application/vnd.ecowin.chart mag
+application/vnd.ecowin.filerequest
+application/vnd.ecowin.fileupdate
+application/vnd.ecowin.series
+application/vnd.ecowin.seriesrequest
+application/vnd.ecowin.seriesupdate
+application/vnd.enliven nml
+application/vnd.epson.esf esf
+application/vnd.epson.msf msf
+application/vnd.epson.quickanime qam
+application/vnd.epson.salt slt
+application/vnd.epson.ssf ssf
+application/vnd.ericsson.quickcall qcall qca
+application/vnd.eszigno3+xml es3 et3
+application/vnd.etsi.aoc+xml
+application/vnd.etsi.cug+xml
+application/vnd.etsi.iptvcommand+xml
+application/vnd.etsi.iptvdiscovery+xml
+application/vnd.etsi.iptvprofile+xml
+application/vnd.etsi.iptvsad-bc+xml
+application/vnd.etsi.iptvsad-cod+xml
+application/vnd.etsi.iptvsad-npvr+xml
+application/vnd.etsi.iptvservice+xml
+application/vnd.etsi.iptvsync+xml
+application/vnd.etsi.iptvueprofile+xml
+application/vnd.etsi.mcid+xml
+application/vnd.etsi.overload-control-policy-dataset+xml
+application/vnd.etsi.sci+xml
+application/vnd.etsi.simservs+xml
+application/vnd.etsi.tsl.der
+application/vnd.etsi.tsl+xml
+application/vnd.eudora.data
+application/vnd.ezpix-album ez2
+application/vnd.ezpix-package ez3
+application/vnd.f-secure.mobile
+application/vnd.fdf fdf
+application/vnd.fdsn.mseed msd mseed
+application/vnd.fdsn.seed seed dataless
+application/vnd.ffsns
+# all extensions: application/vnd.hbci
+application/vnd.fints
+application/vnd.FloGraphIt gph
+application/vnd.fluxtime.clip ftc
+application/vnd.font-fontforge-sfd sfd
+application/vnd.framemaker fm
+application/vnd.frogans.fnc fnc
+application/vnd.frogans.ltf ltf
+application/vnd.fsc.weblaunch fsc
+application/vnd.fujitsu.oasys oas
+application/vnd.fujitsu.oasys2 oa2
+application/vnd.fujitsu.oasys3 oa3
+application/vnd.fujitsu.oasysgp fg5
+application/vnd.fujitsu.oasysprs bh2
+application/vnd.fujixerox.ART-EX
+application/vnd.fujixerox.ART4
+application/vnd.fujixerox.ddd ddd
+application/vnd.fujixerox.docuworks xdw
+application/vnd.fujixerox.docuworks.binder xbd
+application/vnd.fujixerox.HBPL
+application/vnd.fut-misnet
+application/vnd.fuzzysheet fzs
+application/vnd.genomatix.tuxedo txd
+application/vnd.geocube+xml g3 g³
+application/vnd.geogebra.file ggb
+application/vnd.geogebra.tool ggt
+application/vnd.geometry-explorer gex gre
+application/vnd.geonext gxt
+application/vnd.geoplan g2w
+application/vnd.geospace g3w
+application/vnd.globalplatform.card-content-mgt
+application/vnd.globalplatform.card-content-mgt-response
+# application/vnd.gmx deprecated 2009-03-04
+application/vnd.google-earth.kml+xml kml
+application/vnd.google-earth.kmz kmz
+application/vnd.grafeq gqf gqs
+application/vnd.gridmp
+application/vnd.groove-account gac
+application/vnd.groove-help ghf
+application/vnd.groove-identity-message gim
+application/vnd.groove-injector grv
+application/vnd.groove-tool-message gtm
+application/vnd.groove-tool-template tpl
+application/vnd.groove-vcard vcg
+application/vnd.HandHeld-Entertainment+xml zmm
+application/vnd.hbci hbci hbc kom upa pkd bpd
+# rep: application/vnd.businessobjects
+application/vnd.hcl-bireports
+application/vnd.hhe.lesson-player les
+application/vnd.hp-HPGL hpgl
+application/vnd.hp-hpid hpi hpid
+application/vnd.hp-hps hps
+application/vnd.hp-jlyt jlt
+application/vnd.hp-PCL pcl
+application/vnd.hp-PCLXL
+application/vnd.httphone
+application/vnd.hydrostatix.sof-data sfd-hdstx
+application/vnd.hzn-3d-crossword x3d
+application/vnd.ibm.afplinedata
+application/vnd.ibm.electronic-media emm
+application/vnd.ibm.MiniPay mpy
+application/vnd.ibm.modcap list3820 listafp afp pseg3820
+application/vnd.ibm.rights-management irm
+application/vnd.ibm.secure-container sc
+application/vnd.iccprofile icc icm
+application/vnd.igloader igl
+application/vnd.immervision-ivp ivp
+application/vnd.immervision-ivu ivu
+application/vnd.informedcontrol.rms+xml
+# application/vnd.informix-visionary obsoleted by application/vnd.visionary
+application/vnd.infotech.project
+application/vnd.infotech.project+xml
+application/vnd.insors.igm igm
+application/vnd.intercon.formnet xpw xpx
+application/vnd.intergeo i2g
+application/vnd.intertrust.digibox
+application/vnd.intertrust.nncp
+application/vnd.intu.qbo qbo
+application/vnd.intu.qfx qfx
+application/vnd.iptc.g2.conceptitem+xml
+application/vnd.iptc.g2.knowledgeitem+xml
+application/vnd.iptc.g2.newsitem+xml
+application/vnd.iptc.g2.packageitem+xml
+application/vnd.ipunplugged.rcprofile rcprofile
+application/vnd.irepository.package+xml irp
+application/vnd.is-xpr xpr
+application/vnd.isac.fcs fcs
+application/vnd.jam jam
+application/vnd.japannet-directory-service
+application/vnd.japannet-jpnstore-wakeup
+application/vnd.japannet-payment-wakeup
+application/vnd.japannet-registration
+application/vnd.japannet-registration-wakeup
+application/vnd.japannet-setstore-wakeup
+application/vnd.japannet-verification
+application/vnd.japannet-verification-wakeup
+application/vnd.jcp.javame.midlet-rms rms
+application/vnd.jisp jisp
+application/vnd.joost.joda-archive joda
+application/vnd.kahootz ktz ktr
+application/vnd.kde.karbon karbon
+application/vnd.kde.kchart chrt
+application/vnd.kde.kformula kfo
+application/vnd.kde.kivio flw
+application/vnd.kde.kontour kon
+application/vnd.kde.kpresenter kpr kpt
+application/vnd.kde.kspread ksp
+application/vnd.kde.kword kwd kwt
+application/vnd.kenameaapp htke
+application/vnd.kidspiration kia
+application/vnd.Kinar kne knp sdf
+application/vnd.koan skp skd skm skt
+application/vnd.kodak-descriptor sse
+application/vnd.las.las+xml lasxml
+application/vnd.liberty-request+xml
+application/vnd.llamagraphics.life-balance.desktop lbd
+application/vnd.llamagraphics.life-balance.exchange+xml lbe
+application/vnd.lotus-1-2-3 123 wk4 wk3 wk1
+application/vnd.lotus-approach apr vew
+application/vnd.lotus-freelance prz pre
+application/vnd.lotus-notes nsf ntf ndl ns4 ns3 ns2 nsh nsg
+application/vnd.lotus-organizer or3 or2 org
+application/vnd.lotus-screencam scm
+application/vnd.lotus-wordpro lwp sam
+application/vnd.macports.portpkg portpkg
+application/vnd.marlin.drm.actiontoken+xml
+application/vnd.marlin.drm.conftoken+xml
+application/vnd.marlin.drm.license+xml
+application/vnd.marlin.drm.mdcf mdc
+application/vnd.mcd mcd
+application/vnd.medcalcdata mc1
+application/vnd.mediastation.cdkey cdkey
+application/vnd.meridian-slingshot
+application/vnd.MFER mwf
+application/vnd.mfmp mfm
+application/vnd.micrografx.flo flo
+application/vnd.micrografx.igx igx
+application/vnd.mif mif
+application/vnd.minisoft-hp3000-save
+application/vnd.mitsubishi.misty-guard.trustweb
+application/vnd.Mobius.DAF daf
+application/vnd.Mobius.DIS dis
+application/vnd.Mobius.MBK mbk
+application/vnd.Mobius.MQY mqy
+application/vnd.Mobius.MSL msl
+application/vnd.Mobius.PLC plc
+application/vnd.Mobius.TXF txf
+application/vnd.mophun.application mpn
+application/vnd.mophun.certificate mpc
+application/vnd.motorola.flexsuite
+application/vnd.motorola.flexsuite.adsi
+application/vnd.motorola.flexsuite.fis
+application/vnd.motorola.flexsuite.gotap
+application/vnd.motorola.flexsuite.kmr
+application/vnd.motorola.flexsuite.ttc
+application/vnd.motorola.flexsuite.wem
+application/vnd.motorola.iprm
+application/vnd.mozilla.xul+xml xul
+application/vnd.ms-artgalry cil
+application/vnd.ms-asf asf
+application/vnd.ms-cab-compressed cab
+application/vnd.ms-excel xls
+application/vnd.ms-excel.template.macroEnabled.12 xltm
+application/vnd.ms-excel.addin.macroEnabled.12 xlam
+application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
+application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
+application/vnd.ms-fontobject eot
+application/vnd.ms-htmlhelp chm
+application/vnd.ms-ims ims
+application/vnd.ms-lrm lrm
+application/vnd.ms-office.activeX+xml
+application/vnd.ms-officetheme thmx
+application/vnd.ms-playready.initiator+xml
+application/vnd.ms-powerpoint ppt
+application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
+application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
+application/vnd.ms-powerpoint.slide.macroEnabled.12 sldm
+application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
+application/vnd.ms-powerpoint.template.macroEnabled.12 potm
+application/vnd.ms-project mpp
+application/vnd.ms-tnef tnef tnf
+application/vnd.ms-wmdrm.lic-chlg-req
+application/vnd.ms-wmdrm.lic-resp
+application/vnd.ms-wmdrm.meter-chlg-req
+application/vnd.ms-wmdrm.meter-resp
+application/vnd.ms-word.document.macroEnabled.12 docm
+application/vnd.ms-word.template.macroEnabled.12 dotm
+application/vnd.ms-works wcm wdb wks wps
+application/vnd.ms-wpl wpl
+application/vnd.ms-xpsdocument xps
+application/vnd.mseq mseq
+application/vnd.msign
+application/vnd.multiad.creator crtr
+application/vnd.multiad.creator.cif cif
+application/vnd.music-niff
+application/vnd.musician mus
+application/vnd.muvee.style msty
+application/vnd.ncd.control
+application/vnd.ncd.reference
+application/vnd.nervana entity request bkm kcm
+application/vnd.netfpx
+application/vnd.neurolanguage.nlu nlu
+application/vnd.noblenet-directory nnd
+application/vnd.noblenet-sealer nns
+application/vnd.noblenet-web nnw
+application/vnd.nokia.catalogs
+application/vnd.nokia.conml+wbxml
+application/vnd.nokia.conml+xml
+application/vnd.nokia.iptv.config+xml
+application/vnd.nokia.iSDS-radio-presets
+application/vnd.nokia.landmark+wbxml
+application/vnd.nokia.landmark+xml
+application/vnd.nokia.landmarkcollection+xml
+application/vnd.nokia.n-gage.ac+xml ac
+application/vnd.nokia.n-gage.data ngdat
+application/vnd.nokia.n-gage.symbian.install n-gage
+application/vnd.nokia.ncd
+application/vnd.nokia.pcd+wbxml
+application/vnd.nokia.pcd+xml
+application/vnd.nokia.radio-preset rpst
+application/vnd.nokia.radio-presets rpss
+application/vnd.novadigm.EDM edm
+application/vnd.novadigm.EDX edx
+application/vnd.novadigm.EXT ext
+application/vnd.ntt-local.file-transfer
+application/vnd.ntt-local.sip-ta_remote
+application/vnd.ntt-local.sip-ta_tcp_stream
+application/vnd.oasis.opendocument.chart odc
+application/vnd.oasis.opendocument.chart-template otc
+application/vnd.oasis.opendocument.database odb
+application/vnd.oasis.opendocument.formula odf
+application/vnd.oasis.opendocument.formula-template otf
+application/vnd.oasis.opendocument.graphics odg
+application/vnd.oasis.opendocument.graphics-template otg
+application/vnd.oasis.opendocument.image odi
+application/vnd.oasis.opendocument.image-template oti
+application/vnd.oasis.opendocument.presentation odp
+application/vnd.oasis.opendocument.presentation-template otp
+application/vnd.oasis.opendocument.spreadsheet ods
+application/vnd.oasis.opendocument.spreadsheet-template ots
+application/vnd.oasis.opendocument.text odt
+application/vnd.oasis.opendocument.text-master odm
+application/vnd.oasis.opendocument.text-template ott
+application/vnd.oasis.opendocument.text-web oth
+application/vnd.obn
+application/vnd.oipf.contentaccessdownload+xml
+application/vnd.oipf.contentaccessstreaming+xml
+application/vnd.oipf.cspg-hexbinary
+application/vnd.oipf.dae.svg+xml
+application/vnd.oipf.dae.xhtml+xml
+application/vnd.oipf.mippvcontrolmessage+xml
+application/vnd.oipf.pae.gem
+application/vnd.oipf.spdiscovery+xml
+application/vnd.oipf.spdlist+xml
+application/vnd.oipf.ueprofile+xml
+application/vnd.olpc-sugar xo
+application/vnd.oma.bcast.associated-procedure-parameter+xml
+application/vnd.oma.bcast.drm-trigger+xml
+application/vnd.oma.bcast.imd+xml
+application/vnd.oma.bcast.ltkm
+application/vnd.oma.bcast.notification+xml
+application/vnd.oma.bcast.provisioningtrigger
+application/vnd.oma.bcast.sgboot
+application/vnd.oma.bcast.sgdd+xml
+application/vnd.oma.bcast.sgdu
+application/vnd.oma.bcast.simple-symbol-container
+application/vnd.oma.bcast.smartcard-trigger+xml
+application/vnd.oma.bcast.sprov+xml
+application/vnd.oma.bcast.stkm
+application/vnd.oma.cab-address-book+xml
+application/vnd.oma.cab-feature-handler+xml
+application/vnd.oma.cab-pcc+xml
+application/vnd.oma.cab-user-prefs+xml
+application/vnd.oma.dcd
+application/vnd.oma.dcdc
+application/vnd.oma.dd2+xml dd2
+application/vnd.oma.drm.risd+xml
+application/vnd.oma.group-usage-list+xml
+application/vnd.oma.poc.detailed-progress-report+xml
+application/vnd.oma.poc.final-report+xml
+application/vnd.oma.poc.groups+xml
+application/vnd.oma.poc.invocation-descriptor+xml
+application/vnd.oma.poc.optimized-progress-report+xml
+application/vnd.oma.push
+application/vnd.oma.scidm.messages+xml
+application/vnd.oma.xcap-directory+xml
+application/vnd.oma-scws-config
+application/vnd.oma-scws-http-request
+application/vnd.oma-scws-http-response
+application/vnd.omads-email+xml
+application/vnd.omads-file+xml
+application/vnd.omads-folder+xml
+application/vnd.omaloc-supl-init
+application/vnd.openofficeorg.extension oxt
+application/vnd.openxmlformats-officedocument.custom-properties+xml
+application/vnd.openxmlformats-officedocument.customXmlProperties+xml
+application/vnd.openxmlformats-officedocument.drawing+xml
+application/vnd.openxmlformats-officedocument.drawingml.chart+xml
+application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml
+application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml
+application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml
+application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml
+application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml
+application/vnd.openxmlformats-officedocument.extended-properties+xml
+application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml
+application/vnd.openxmlformats-officedocument.presentationml.comments+xml
+application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml
+application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml
+application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml
+application/vnd.openxmlformats-officedocument.presentationml.presProps+xml
+application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
+application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml
+application/vnd.openxmlformats-officedocument.presentationml.slide sldx
+application/vnd.openxmlformats-officedocument.presentationml.slide+xml
+application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml
+application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml
+application/vnd.openxmlformats-officedocument.presentationml.slideUpdateInfo+xml
+application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
+application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml
+application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml
+application/vnd.openxmlformats-officedocument.presentationml.tags+xml
+application/vnd.openxmlformats-officedocument.presentationml.template potx
+application/vnd.openxmlformats-officedocument.presentationml.template.main+xml
+application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.dialogsheet+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.tableSingleCells+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
+application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.userNames+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.volatileDependencies+xml
+application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml
+application/vnd.openxmlformats-officedocument.theme+xml
+application/vnd.openxmlformats-officedocument.themeOverride+xml
+application/vnd.openxmlformats-officedocument.vmlDrawing
+application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
+application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
+application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml
+application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml
+application/vnd.openxmlformats-package.core-properties+xml
+application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml
+application/vnd.openxmlformats-package.relationships+xml
+application/vnd.osa.netdeploy ndc
+application/vnd.osgeo.mapguide.package mgp
+# jar: application/x-java-archive
+application/vnd.osgi.bundle
+application/vnd.osgi.dp dp
+application/vnd.otps.ct-kip+xml
+application/vnd.palm prc pdb pqa oprc
+application/vnd.paos+xml
+application/vnd.pawaafile paw
+application/vnd.pg.format str
+application/vnd.pg.osasli ei6
+application/vnd.piaccess.application-license pil
+application/vnd.picsel efif
+application/vnd.pmi.widget wg
+application/vnd.poc.group-advertisement+xml
+application/vnd.pocketlearn plf
+application/vnd.powerbuilder6 pbd
+application/vnd.powerbuilder6-s
+application/vnd.powerbuilder7
+application/vnd.powerbuilder7-s
+application/vnd.powerbuilder75
+application/vnd.powerbuilder75-s
+application/vnd.preminet preminet
+application/vnd.previewsystems.box box vbox
+application/vnd.proteus.magazine mgz
+application/vnd.publishare-delta-tree qps
+# pti: image/prs.pti
+application/vnd.pvi.ptid1 ptid
+application/vnd.pwg-multiplexed
+application/vnd.pwg-xhtml-print+xml
+application/vnd.qualcomm.brew-app-res bar
+application/vnd.Quark.QuarkXPress qxd qxt qwd qwt qxl qxb
+application/vnd.quobject-quoxdocument quox quiz
+application/vnd.radisys.moml+xml
+application/vnd.radisys.msml-audit-conf+xml
+application/vnd.radisys.msml-audit-conn+xml
+application/vnd.radisys.msml-audit-dialog+xml
+application/vnd.radisys.msml-audit-stream+xml
+application/vnd.radisys.msml-audit+xml
+application/vnd.radisys.msml-conf+xml
+application/vnd.radisys.msml-dialog-base+xml
+application/vnd.radisys.msml-dialog-fax-detect+xml
+application/vnd.radisys.msml-dialog-fax-sendrecv+xml
+application/vnd.radisys.msml-dialog-group+xml
+application/vnd.radisys.msml-dialog-speech+xml
+application/vnd.radisys.msml-dialog-transform+xml
+application/vnd.radisys.msml-dialog+xml
+application/vnd.radisys.msml+xml
+application/vnd.rainstor.data tree
+application/vnd.rapid
+application/vnd.realvnc.bed bed
+application/vnd.recordare.musicxml mxl
+application/vnd.recordare.musicxml+xml
+application/vnd.RenLearn.rlprint
+application/vnd.rig.cryptonote cryptonote
+application/vnd.route66.link66+xml link66
+application/vnd.ruckus.download
+application/vnd.s3sms
+application/vnd.sailingtracker.track st
+application/vnd.sbm.cid
+application/vnd.sbm.mid2
+application/vnd.scribus scd sla slaz
+application/vnd.sealed.3df s3df
+application/vnd.sealed.csf scsf
+application/vnd.sealed.doc sdoc sdo s1w
+application/vnd.sealed.eml seml sem
+application/vnd.sealed.mht smht smh
+application/vnd.sealed.net
+# spp: application/scvp-vp-response
+application/vnd.sealed.ppt sppt s1p
+application/vnd.sealed.tiff stif
+application/vnd.sealed.xls sxls sxl s1e
+# stm: audio/x-stm
+application/vnd.sealedmedia.softseal.html stml s1h
+application/vnd.sealedmedia.softseal.pdf spdf spd s1a
+application/vnd.seemail see
+application/vnd.sema sema
+application/vnd.semd semd
+application/vnd.semf semf
+application/vnd.shana.informed.formdata ifm
+application/vnd.shana.informed.formtemplate itp
+application/vnd.shana.informed.interchange iif
+application/vnd.shana.informed.package ipk
+application/vnd.SimTech-MindMapper twd twds
+application/vnd.smaf mmf
+application/vnd.smart.notebook notebook
+application/vnd.smart.teacher teacher
+application/vnd.software602.filler.form+xml fo
+application/vnd.software602.filler.form-xml-zip zfo
+application/vnd.solent.sdkm+xml sdkm sdkd
+application/vnd.spotfire.dxp dxp
+application/vnd.spotfire.sfs sfs
+application/vnd.sss-cod
+application/vnd.sss-dtf
+application/vnd.sss-ntf
+application/vnd.stepmania.stepchart sm
+application/vnd.street-stream
+application/vnd.sun.wadl+xml wadl
+application/vnd.sus-calendar sus susp
+application/vnd.svd
+application/vnd.swiftview-ics
+application/vnd.syncml.dm.notification
+application/vnd.syncml.ds.notification
+application/vnd.syncml.dm+wbxml bdm
+application/vnd.syncml.dm+xml xdm
+application/vnd.syncml+xml xsm
+application/vnd.tao.intent-module-archive tao
+application/vnd.tmobile-livetv tmo
+application/vnd.trid.tpt tpt
+application/vnd.triscape.mxs mxs
+application/vnd.trueapp tra
+application/vnd.truedoc
+# cab: application/vnd.ms-cab-compressed
+application/vnd.ubisoft.webplayer
+application/vnd.ufdl ufdl ufd frm
+application/vnd.uiq.theme utz
+application/vnd.umajin umj
+application/vnd.unity unityweb
+application/vnd.uoml+xml uoml uo
+application/vnd.uplanet.alert
+application/vnd.uplanet.alert-wbxml
+application/vnd.uplanet.bearer-choice
+application/vnd.uplanet.bearer-choice-wbxml
+application/vnd.uplanet.cacheop
+application/vnd.uplanet.cacheop-wbxml
+application/vnd.uplanet.channel
+application/vnd.uplanet.channel-wbxml
+application/vnd.uplanet.list
+application/vnd.uplanet.list-wbxml
+application/vnd.uplanet.listcmd
+application/vnd.uplanet.listcmd-wbxml
+application/vnd.uplanet.signal
+application/vnd.vcx vcx
+# sxi: application/vnd.sun.xml.impress
+application/vnd.vd-study mxi study-inter model-inter
+# mcd: application/vnd.mcd
+application/vnd.vectorworks vwx
+application/vnd.verimatrix.vcas
+application/vnd.vidsoft.vidconference vsc
+application/vnd.visio vsd vst vsw vss
+application/vnd.visionary vis
+# vsc: application/vnd.vidsoft.vidconference
+application/vnd.vividence.scriptfile
+application/vnd.vsf vsf
+application/vnd.wap.sic sic
+application/vnd.wap.slc slc
+application/vnd.wap.wbxml wbxml
+application/vnd.wap.wmlc wmlc
+application/vnd.wap.wmlscriptc wmlsc
+application/vnd.webturbo wtb
+application/vnd.wfa.wsc wsc
+application/vnd.wmc wmc
+application/vnd.wmf.bootstrap
+# nb: application/mathematica for now
+application/vnd.wolfram.mathematica
+application/vnd.wolfram.mathematica.package m
+application/vnd.wolfram.player nbp
+application/vnd.wordperfect wpd
+application/vnd.wqd wqd
+application/vnd.wrq-hp3000-labelled
+application/vnd.wt.stf stf
+application/vnd.wv.csp+xml
+application/vnd.wv.csp+wbxml wv
+application/vnd.wv.ssp+xml
+application/vnd.xara xar
+application/vnd.xfdl xfdl xfd
+application/vnd.xfdl.webform
+application/vnd.xmi+xml
+application/vnd.xmpie.cpkg cpkg
+application/vnd.xmpie.dpkg dpkg
+# dpkg: application/vnd.xmpie.dpkg
+application/vnd.xmpie.plan
+application/vnd.xmpie.ppkg ppkg
+application/vnd.xmpie.xlim xlim
+application/vnd.yamaha.hv-dic hvd
+application/vnd.yamaha.hv-script hvs
+application/vnd.yamaha.hv-voice hvp
+application/vnd.yamaha.openscoreformat osf
+application/vnd.yamaha.openscoreformat.osfpvg+xml
+application/vnd.yamaha.remote-setup
+application/vnd.yamaha.smaf-audio saf
+application/vnd.yamaha.smaf-phrase spf
+application/vnd.yamaha.tunnel-udpencap
+application/vnd.yellowriver-custom-menu cmp
+application/vnd.zul zir zirz
+application/vnd.zzazz.deck+xml zaz
+application/voicexml+xml vxml
+application/vq-rtcp-xr
+application/watcherinfo+xml wif
+application/whoispp-query
+application/whoispp-response
+application/widget wgt
+application/wita
+application/wordperfect5.1
+application/wsdl+xml wsdl
+application/wspolicy+xml wspolicy
+application/x400-bp
+application/xcap-att+xml xav
+application/xcap-caps+xml xca
+application/xcap-diff+xml xdf
+application/xcap-el+xml xel
+application/xcap-error+xml xer
+application/xcap-ns+xml xns
+application/xcon-conference-info-diff+xml
+application/xcon-conference-info+xml
+application/xenc+xml
+application/xhtml+xml xhtml xhtm xht
+# application/xhtml-voice+xml obsoleted by application/xv+xml
+# xml, xsd, rng: text/xml
+application/xml
+# mod: audio/x-mod
+application/xml-dtd dtd
+# ent: text/xml-external-parsed-entity
+application/xml-external-parsed-entity
+application/xmpp+xml
+application/xop+xml xop
+application/xslt+xml xsl xslt
+application/xv+xml mxml xhvml xvml xvm
+application/yang yang
+application/yin+xml yin
+application/zip zip
+audio/1d-interleaved-parityfec
+audio/32kadpcm 726
+# 3gp, 3gpp: video/3gpp
+audio/3gpp
+# 3g2, 3gpp2: video/3gpp2
+audio/3gpp2
+audio/ac3 ac3
+audio/AMR amr
+audio/AMR-WB awb
+audio/amr-wb+
+audio/asc acn
+# aa3, omg: audio/ATRAC3
+audio/ATRAC-ADVANCED-LOSSLESS aal
+# aa3, omg: audio/ATRAC3
+audio/ATRAC-X atx
+audio/ATRAC3 at3 aa3 omg
+audio/basic au snd
+audio/BV16
+audio/BV32
+audio/clearmode
+audio/CN
+audio/DAT12
+audio/dls dls
+audio/dsr-es201108
+audio/dsr-es202050
+audio/dsr-es202211
+audio/dsr-es202212
+audio/DVI4
+audio/eac3
+audio/EVRC evc
+# qcp: audio/qcelp
+audio/EVRC-QCP
+audio/EVRC0
+audio/EVRC1
+audio/EVRCB evb
+audio/EVRCB0
+audio/EVRCWB evw
+audio/EVRCWB0
+audio/EVRCWB1
+audio/G719
+audio/G722
+audio/G7221
+audio/G723
+audio/G726-16
+audio/G726-24
+audio/G726-32
+audio/G726-40
+audio/G728
+audio/G729
+audio/G7291
+audio/G729D
+audio/G729E
+audio/GSM
+audio/GSM-EFR
+audio/GSM-HR-08
+audio/iLBC lbc
+audio/ip-mr_v2.5
+# wav: audio/wav
+audio/L16 l16
+audio/L20
+audio/L24
+audio/L8
+audio/LPC
+audio/mobile-xmf mxmf
+# mp4, mpg4: video/mp4, see RFC 4337
+audio/mp4
+audio/MP4A-LATM
+audio/MPA
+audio/mpa-robust
+audio/mpeg mp3 mpga mp1 mp2
+audio/mpeg4-generic
+audio/ogg oga ogg spx
+audio/parityfec
+audio/PCMA
+audio/PCMA-WB
+audio/PCMU
+audio/PCMU-WB
+audio/prs.sid sid psid
+audio/qcelp qcp
+audio/RED
+audio/rtp-enc-aescm128
+audio/rtp-midi
+audio/rtx
+audio/SMV smv
+# qcp: audio/qcelp, see RFC 3625
+audio/SMV-QCP
+audio/SMV0
+# mid: audio/midi
+audio/sp-midi
+audio/speex
+audio/t140c
+audio/t38
+audio/telephone-event
+audio/tone
+audio/UEMCLIP
+audio/ulpfec
+audio/VDVI
+audio/VMR-WB
+audio/vnd.3gpp.iufp
+audio/vnd.4SB
+audio/vnd.audikoz koz
+audio/vnd.CELP
+audio/vnd.cisco.nse
+audio/vnd.cmles.radio-events
+audio/vnd.cns.anp1
+audio/vnd.cns.inf1
+audio/vnd.dece.audio uva uvva
+audio/vnd.digital-winds eol
+audio/vnd.dlna.adts
+audio/vnd.dolby.heaac.1
+audio/vnd.dolby.heaac.2
+audio/vnd.dolby.mlp mlp
+audio/vnd.dolby.mps
+audio/vnd.dolby.pl2
+audio/vnd.dolby.pl2x
+audio/vnd.dolby.pl2z
+audio/vnd.dolby.pulse.1
+audio/vnd.dra
+# wav: audio/wav, cpt: application/mac-compactpro
+audio/vnd.dts dts
+audio/vnd.dts.hd dtshd
+audio/vnd.dvb.file dvb
+audio/vnd.everad.plj plj
+# rm: audio/x-pn-realaudio
+audio/vnd.hns.audio
+audio/vnd.lucent.voice lvp
+audio/vnd.ms-playready.media.pya pya
+# mxmf: audio/mobile-xmf
+audio/vnd.nokia.mobile-xmf
+audio/vnd.nortel.vbk vbk
+audio/vnd.nuera.ecelp4800 ecelp4800
+audio/vnd.nuera.ecelp7470 ecelp7470
+audio/vnd.nuera.ecelp9600 ecelp9600
+audio/vnd.octel.sbc
+# audio/vnd.qcelp deprecated in favour of audio/qcelp
+audio/vnd.rhetorex.32kadpcm
+audio/vnd.rip rip
+audio/vnd.sealedmedia.softseal.mpeg smp3 smp s1m
+audio/vnd.vmx.cvsd
+audio/vorbis
+audio/vorbis-config
+image/cgm
+image/fits fits fit fts
+image/g3fax
+image/gif gif
+image/ief ief
+image/jp2 jp2 jpg2
+image/jpeg jpg jpeg jpe jfif
+image/jpm jpm jpgm
+image/jpx jpx jpf
+image/ktx ktx
+image/naplps
+image/png png
+image/prs.btif btif btf
+image/prs.pti pti
+image/svg+xml svg svgz
+image/t38 t38
+image/tiff tiff tif
+image/tiff-fx tfx
+image/vnd.adobe.photoshop psd
+image/vnd.cns.inf2
+image/vnd.dece.graphic uvi uvvi uvg uvvg
+image/vnd.djvu djvu djv
+image/vnd.dvb.subtitle sub
+image/vnd.dwg
+image/vnd.dxf dxf
+image/vnd.fastbidsheet fbs
+image/vnd.fpx fpx
+image/vnd.fst fst
+image/vnd.fujixerox.edmics-mmr mmr
+image/vnd.fujixerox.edmics-rlc rlc
+image/vnd.globalgraphics.pgb pgb
+image/vnd.microsoft.icon ico
+image/vnd.mix
+image/vnd.ms-modi mdi
+image/vnd.net-fpx
+image/vnd.radiance hdr rgbe xyze
+image/vnd.sealed.png spng spn s1n
+image/vnd.sealedmedia.softseal.gif sgif sgi s1g
+image/vnd.sealedmedia.softseal.jpg sjpg sjp s1j
+image/vnd.svf
+image/vnd.wap.wbmp wbmp
+image/vnd.xiff xif
+message/CPIM
+message/delivery-status
+message/disposition-notification
+message/external-body
+message/feedback-report
+message/global u8msg
+message/global-delivery-status u8dsn
+message/global-disposition-notification u8mdn
+message/global-headers u8hdr
+message/http
+# cl: application/simple-filter+xml
+message/imdn+xml
+# message/news obsoleted by message/rfc822
+message/partial
+message/rfc822 eml mail art
+message/s-http
+message/sip
+message/sipfrag
+message/tracking-status
+message/vnd.si.simp
+model/iges igs iges
+model/mesh msh mesh silo
+model/vnd.collada+xml dae
+model/vnd.dwf dwf
+# 3dml, 3dm: text/vnd.in3d.3dml
+model/vnd.flatland.3dml
+model/vnd.gdl gdl gsm win dor lmp rsm msm ism
+model/vnd.gs-gdl
+model/vnd.gtw gtw
+model/vnd.moml+xml moml
+model/vnd.mts mts
+model/vnd.parasolid.transmit.binary x_b xmt_bin
+model/vnd.parasolid.transmit.text x_t xmt_txt
+model/vnd.vtu vtu
+model/vrml wrl vrml
+multipart/alternative
+multipart/appledouble
+multipart/byteranges
+multipart/digest
+multipart/encrypted
+multipart/form-data
+multipart/header-set
+multipart/mixed
+multipart/parallel
+multipart/related
+multipart/report
+multipart/signed
+multipart/voice-message vpm
+text/1d-interleaved-parityfec
+text/calendar ics ifb
+text/css css
+text/csv csv
+text/directory
+text/dns soa zone
+# text/ecmascript obsoleted by application/ecmascript
+text/enriched
+text/html html htm
+# text/javascript obsoleted by application/javascript
+text/n3 n3
+text/parityfec
+text/plain txt asc text pm el c h cc hh cxx hxx f90
+text/prs.fallenstein.rst rst
+text/prs.lines.tag tag dsc
+text/RED
+text/rfc822-headers
+text/richtext rtx
+# rtf: application/rtf
+text/rtf
+text/rtp-enc-aescm128
+text/rtx
+text/sgml sgml sgm
+text/t140
+text/tab-separated-values tsv
+text/troff
+text/turtle ttl
+text/ulpfec
+text/uri-list uris uri
+text/vnd.abc abc
+# curl: application/vnd.curl
+text/vnd.curl
+text/vnd.DMClientScript dms
+text/vnd.esmertec.theme-descriptor jtd
+text/vnd.fly fly
+text/vnd.fmi.flexstor flx
+text/vnd.graphviz gv dot
+text/vnd.in3d.3dml 3dml 3dm
+text/vnd.in3d.spot spot spo
+text/vnd.IPTC.NewsML
+text/vnd.IPTC.NITF
+text/vnd.latex-z
+text/vnd.motorola.reflex
+text/vnd.ms-mediapackage mpf
+text/vnd.net2phone.commcenter.command ccc
+text/vnd.radisys.msml-basic-layout
+text/vnd.si.uricatalogue uric
+text/vnd.sun.j2me.app-descriptor jad
+text/vnd.trolltech.linguist ts
+text/vnd.wap.si si
+text/vnd.wap.sl sl
+text/vnd.wap.wml wml
+text/vnd.wap.wmlscript wmls
+text/xml xml xsd rng
+text/xml-external-parsed-entity ent
+video/1d-interleaved-parityfec
+video/3gpp 3gp 3gpp
+video/3gpp2 3g2 3gpp2
+video/3gpp-tt
+video/BMPEG
+video/BT656
+video/CelB
+video/DV
+video/H261
+video/H263
+video/H263-1998
+video/H263-2000
+video/H264
+video/H264-RCDO
+video/H264-SVC
+video/JPEG
+video/jpeg2000
+video/mj2 mj2 mjp2
+video/MP1S
+video/MP2P
+video/MP2T
+video/mp4 mp4 mpg4
+video/MP4V-ES
+video/mpeg mpeg mpg mpe
+video/mpeg4-generic
+video/MPV
+video/nv
+video/ogg ogv
+video/parityfec
+video/pointer
+video/quicktime mov qt
+video/raw
+video/rtp-enc-aescm128
+video/rtx
+video/SMPTE292M
+video/ulpfec
+video/vc1
+video/vnd.CCTV
+video/vnd.dece.hd uvh uvvh
+video/vnd.dece.mobile uvm uvvm
+video/vnd.dece.mp4 uvu uvvu
+video/vnd.dece.pd uvp uvvp
+video/vnd.dece.sd uvs uvvs
+video/vnd.dece.video uvv uvvv
+video/vnd.directv.mpeg
+video/vnd.directv.mpeg-tts
+video/vnd.dlna.mpeg-tts
+video/vnd.fvt fvt
+# rm: audio/x-pn-realaudio
+video/vnd.hns.video
+video/vnd.iptvforum.1dparityfec-1010
+video/vnd.iptvforum.1dparityfec-2005
+video/vnd.iptvforum.2dparityfec-1010
+video/vnd.iptvforum.2dparityfec-2005
+video/vnd.iptvforum.ttsavc
+video/vnd.iptvforum.ttsmpeg2
+video/vnd.motorola.video
+video/vnd.motorola.videop
+video/vnd.mpegurl mxu m4u
+video/vnd.ms-playready.media.pyv pyv
+video/vnd.nokia.interleaved-multimedia nim
+video/vnd.nokia.videovoip
+# mp4: video/mp4
+video/vnd.objectvideo
+video/vnd.sealed.mpeg1 smpg s11
+# smpg: video/vnd.sealed.mpeg1
+video/vnd.sealed.mpeg4 s14
+video/vnd.sealed.swf sswf ssw
+video/vnd.sealedmedia.softseal.mov smov smo s1q
+# uvu, uvvu: video/vnd.dece.mp4
+video/vnd.uvvu.mp4
+video/vnd.vivo
+
+# Non-IANA types
+
+application/epub+zip epub
+application/mac-compactpro cpt
+application/metalink+xml metalink
+application/rss+xml rss
+application/vnd.android.package-archive apk
+application/vnd.oma.dd+xml dd
+application/vnd.oma.drm.content dcf
+# odf: application/vnd.oasis.opendocument.formula
+application/vnd.oma.drm.dcf o4a o4v
+application/vnd.oma.drm.message dm
+application/vnd.oma.drm.rights+wbxml drc
+application/vnd.oma.drm.rights+xml dr
+application/vnd.sun.xml.calc sxc
+application/vnd.sun.xml.calc.template stc
+application/vnd.sun.xml.draw sxd
+application/vnd.sun.xml.draw.template std
+application/vnd.sun.xml.impress sxi
+application/vnd.sun.xml.impress.template sti
+application/vnd.sun.xml.math sxm
+application/vnd.sun.xml.writer sxw
+application/vnd.sun.xml.writer.global sxg
+application/vnd.sun.xml.writer.template stw
+application/vnd.symbian.install sis
+application/vnd.wap.mms-message mms
+application/x-annodex anx
+application/x-bcpio bcpio
+application/x-bittorrent torrent
+application/x-bzip2 bz2
+application/x-cdlink vcd
+application/x-chess-pgn pgn
+application/x-cpio cpio
+application/x-csh csh
+application/x-director dcr dir dxr
+application/x-dvi dvi
+application/x-futuresplash spl
+application/x-gtar gtar
+application/x-gzip gz tgz
+application/x-hdf hdf
+application/x-java-archive jar
+application/x-java-jnlp-file jnlp
+application/x-java-pack200 pack
+application/x-killustrator kil
+application/x-latex latex
+application/x-netcdf nc cdf
+application/x-perl pl
+application/x-rpm rpm
+application/x-sh sh
+application/x-shar shar
+application/x-shockwave-flash swf
+application/x-stuffit sit
+application/x-sv4cpio sv4cpio
+application/x-sv4crc sv4crc
+application/x-tar tar
+application/x-tcl tcl
+application/x-tex tex
+application/x-texinfo texinfo texi
+application/x-troff t tr roff
+application/x-troff-man man 1 2 3 4 5 6 7 8
+application/x-troff-me me
+application/x-troff-ms ms
+application/x-ustar ustar
+application/x-wais-source src
+application/x-xpinstall xpi
+application/x-xspf+xml xspf
+application/x-xz xz
+audio/midi mid midi kar
+audio/x-aiff aif aiff aifc
+audio/x-annodex axa
+audio/x-flac flac
+audio/x-mod mod ult uni m15 mtm 669 med
+audio/x-mpegurl m3u
+audio/x-ms-wax wax
+audio/x-ms-wma wma
+audio/x-pn-realaudio ram rm
+audio/x-realaudio ra
+audio/x-s3m s3m
+audio/x-stm stm
+audio/x-wav wav
+chemical/x-xyz xyz
+image/bmp bmp
+image/x-cmu-raster ras
+image/x-portable-anymap pnm
+image/x-portable-bitmap pbm
+image/x-portable-graymap pgm
+image/x-portable-pixmap ppm
+image/x-rgb rgb
+image/x-targa tga
+image/x-xbitmap xbm
+image/x-xpixmap xpm
+image/x-xwindowdump xwd
+text/cache-manifest manifest
+text/html-sandboxed sandboxed
+text/x-pod pod
+text/x-setext etx
+text/x-vcard vcf
+video/webm webm
+video/x-annodex axv
+video/x-flv flv
+video/x-javafx fxm
+video/x-ms-asf asx
+video/x-ms-wm wm
+video/x-ms-wmv wmv
+video/x-ms-wmx wmx
+video/x-ms-wvx wvx
+video/x-msvideo avi
+video/x-sgi-movie movie
+x-conference/x-cooltalk ice
+x-epoc/x-sisx-app sisx
diff --git a/Lib/test/mock_socket.py b/Lib/test/mock_socket.py
new file mode 100644
index 00000000000..803693283b3
--- /dev/null
+++ b/Lib/test/mock_socket.py
@@ -0,0 +1,154 @@
+"""Mock socket module used by the smtpd and smtplib tests.
+"""
+
+# imported for _GLOBAL_DEFAULT_TIMEOUT
+import socket as socket_module
+
+# Mock socket module
+_defaulttimeout = None
+_reply_data = None
+
+# This is used to queue up data to be read through socket.makefile, typically
+# *before* the socket object is even created. It is intended to handle a single
+# line which the socket will feed on recv() or makefile().
+def reply_with(line):
+ global _reply_data
+ _reply_data = line
+
+
+class MockFile:
+ """Mock file object returned by MockSocket.makefile().
+ """
+ def __init__(self, lines):
+ self.lines = lines
+ def readline(self):
+ return self.lines.pop(0) + b'\r\n'
+ def close(self):
+ pass
+
+
+class MockSocket:
+ """Mock socket object used by smtpd and smtplib tests.
+ """
+ def __init__(self):
+ global _reply_data
+ self.output = []
+ self.lines = []
+ if _reply_data:
+ self.lines.append(_reply_data)
+ _reply_data = None
+ self.conn = None
+ self.timeout = None
+
+ def queue_recv(self, line):
+ self.lines.append(line)
+
+ def recv(self, bufsize, flags=None):
+ data = self.lines.pop(0) + b'\r\n'
+ return data
+
+ def fileno(self):
+ return 0
+
+ def settimeout(self, timeout):
+ if timeout is None:
+ self.timeout = _defaulttimeout
+ else:
+ self.timeout = timeout
+
+ def gettimeout(self):
+ return self.timeout
+
+ def setsockopt(self, level, optname, value):
+ pass
+
+ def getsockopt(self, level, optname, buflen=None):
+ return 0
+
+ def bind(self, address):
+ pass
+
+ def accept(self):
+ self.conn = MockSocket()
+ return self.conn, 'c'
+
+ def getsockname(self):
+ return ('0.0.0.0', 0)
+
+ def setblocking(self, flag):
+ pass
+
+ def listen(self, backlog):
+ pass
+
+ def makefile(self, mode='r', bufsize=-1):
+ handle = MockFile(self.lines)
+ return handle
+
+ def sendall(self, buffer, flags=None):
+ self.last = data
+ self.output.append(data)
+ return len(data)
+
+ def send(self, data, flags=None):
+ self.last = data
+ self.output.append(data)
+ return len(data)
+
+ def getpeername(self):
+ return 'peer'
+
+ def close(self):
+ pass
+
+
+def socket(family=None, type=None, proto=None):
+ return MockSocket()
+
+
+def create_connection(address, timeout=socket_module._GLOBAL_DEFAULT_TIMEOUT):
+ try:
+ int_port = int(address[1])
+ except ValueError:
+ raise error
+ ms = MockSocket()
+ if timeout is socket_module._GLOBAL_DEFAULT_TIMEOUT:
+ timeout = getdefaulttimeout()
+ ms.settimeout(timeout)
+ return ms
+
+
+def setdefaulttimeout(timeout):
+ global _defaulttimeout
+ _defaulttimeout = timeout
+
+
+def getdefaulttimeout():
+ return _defaulttimeout
+
+
+def getfqdn():
+ return ""
+
+
+def gethostname():
+ pass
+
+
+def gethostbyname(name):
+ return ""
+
+
+class gaierror(Exception):
+ pass
+
+
+class error(Exception):
+ pass
+
+
+# Constants
+AF_INET = None
+SOCK_STREAM = None
+SOL_SOCKET = None
+SO_REUSEADDR = None
diff --git a/Lib/test/mp_fork_bomb.py b/Lib/test/mp_fork_bomb.py
index 72cea255de1..908afe3045f 100644
--- a/Lib/test/mp_fork_bomb.py
+++ b/Lib/test/mp_fork_bomb.py
@@ -1,16 +1,13 @@
-import multiprocessing
+import multiprocessing, sys
-def foo(conn):
- conn.send("123")
+def foo():
+ print("123")
# Because "if __name__ == '__main__'" is missing this will not work
# correctly on Windows. However, we should get a RuntimeError rather
# than the Windows equivalent of a fork bomb.
-r, w = multiprocessing.Pipe(False)
-p = multiprocessing.Process(target=foo, args=(w,))
+p = multiprocessing.Process(target=foo)
p.start()
-w.close()
-print(r.recv())
-r.close()
p.join()
+sys.exit(p.exitcode)
diff --git a/Lib/test/outstanding_bugs.py b/Lib/test/outstanding_bugs.py
index 04afcbd8ad8..0849ee58858 100644
--- a/Lib/test/outstanding_bugs.py
+++ b/Lib/test/outstanding_bugs.py
@@ -7,16 +7,82 @@
#
import unittest
-from test import test_support
+from test import support
#
-# No test cases for outstanding bugs at the moment.
+# One test case for outstanding bugs at the moment:
#
+# test_io
+import io
+class TextIOWrapperTest(unittest.TestCase):
+
+ def setUp(self):
+ self.testdata = b"AAA\r\nBBB\rCCC\r\nDDD\nEEE\r\n"
+ self.normalized = b"AAA\nBBB\nCCC\nDDD\nEEE\n".decode("ASCII")
+
+ def tearDown(self):
+ support.unlink(support.TESTFN)
+
+
+ def test_issue1395_1(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+
+ # read one char at a time
+ reads = ""
+ while True:
+ c = txt.read(1)
+ if not c:
+ break
+ reads += c
+ self.assertEqual(reads, self.normalized)
+
+ def test_issue1395_2(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = ""
+ while True:
+ c = txt.read(4)
+ if not c:
+ break
+ reads += c
+ self.assertEqual(reads, self.normalized)
+
+ def test_issue1395_3(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ reads += txt.read(4)
+ reads += txt.readline()
+ reads += txt.readline()
+ reads += txt.readline()
+ self.assertEqual(reads, self.normalized)
+
+ def test_issue1395_4(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ reads += txt.read()
+ self.assertEqual(reads, self.normalized)
+
+ def test_issue1395_5(self):
+ txt = io.TextIOWrapper(io.BytesIO(self.testdata), encoding="ASCII")
+ txt._CHUNK_SIZE = 4
+
+ reads = txt.read(4)
+ pos = txt.tell()
+ txt.seek(0)
+ txt.seek(pos)
+ self.assertEqual(txt.read(4), "BBB\n")
+
+
def test_main():
- #test_support.run_unittest()
- pass
+ support.run_unittest(
+ TextIOWrapperTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index c321f8e78a5..4d491b0173c 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -1,60 +1,30 @@
+import io
import unittest
import pickle
-import cPickle
-import StringIO
-import cStringIO
import pickletools
-import copy_reg
+import sys
+import copyreg
+from http.cookies import SimpleCookie
-from test.test_support import TestFailed, have_unicode, TESTFN
+from test.support import (
+ TestFailed, TESTFN, run_with_locale,
+ _2G, _4G, bigmemtest,
+ )
+
+from pickle import bytes_types
# Tests that try a number of pickle protocols should have a
# for proto in protocols:
# kind of outer loop.
-assert pickle.HIGHEST_PROTOCOL == cPickle.HIGHEST_PROTOCOL == 2
protocols = range(pickle.HIGHEST_PROTOCOL + 1)
-# Copy of test.test_support.run_with_locale. This is needed to support Python
-# 2.4, which didn't include it. This is all to support test_xpickle, which
-# bounces pickled objects through older Python versions to test backwards
-# compatibility.
-def run_with_locale(catstr, *locales):
- def decorator(func):
- def inner(*args, **kwds):
- try:
- import locale
- category = getattr(locale, catstr)
- orig_locale = locale.setlocale(category)
- except AttributeError:
- # if the test author gives us an invalid category string
- raise
- except:
- # cannot retrieve original locale, so do nothing
- locale = orig_locale = None
- else:
- for loc in locales:
- try:
- locale.setlocale(category, loc)
- break
- except:
- pass
-
- # now run the function, resetting the locale on exceptions
- try:
- return func(*args, **kwds)
- finally:
- if locale and orig_locale:
- locale.setlocale(category, orig_locale)
- inner.func_name = func.func_name
- inner.__doc__ = func.__doc__
- return inner
- return decorator
+character_size = 4 if sys.maxunicode > 0xFFFF else 2
# Return True if opcode code appears in the pickle, else False.
def opcode_in_pickle(code, pickle):
for op, dummy, dummy in pickletools.genops(pickle):
- if op.code == code:
+ if op.code == code.decode("latin-1"):
return True
return False
@@ -62,10 +32,25 @@ def opcode_in_pickle(code, pickle):
def count_opcode(code, pickle):
n = 0
for op, dummy, dummy in pickletools.genops(pickle):
- if op.code == code:
+ if op.code == code.decode("latin-1"):
n += 1
return n
+
+class UnseekableIO(io.BytesIO):
+ def peek(self, *args):
+ raise NotImplementedError
+
+ def seekable(self):
+ return False
+
+ def seek(self, *args):
+ raise io.UnsupportedOperation
+
+ def tell(self):
+ raise io.UnsupportedOperation
+
+
# We can't very well test the extension registry without putting known stuff
# in it, but we have to be careful to restore its original state. Code
# should do this:
@@ -81,29 +66,41 @@ class ExtensionSaver:
# there is one).
def __init__(self, code):
self.code = code
- if code in copy_reg._inverted_registry:
- self.pair = copy_reg._inverted_registry[code]
- copy_reg.remove_extension(self.pair[0], self.pair[1], code)
+ if code in copyreg._inverted_registry:
+ self.pair = copyreg._inverted_registry[code]
+ copyreg.remove_extension(self.pair[0], self.pair[1], code)
else:
self.pair = None
# Restore previous registration for code.
def restore(self):
code = self.code
- curpair = copy_reg._inverted_registry.get(code)
+ curpair = copyreg._inverted_registry.get(code)
if curpair is not None:
- copy_reg.remove_extension(curpair[0], curpair[1], code)
+ copyreg.remove_extension(curpair[0], curpair[1], code)
pair = self.pair
if pair is not None:
- copy_reg.add_extension(pair[0], pair[1], code)
+ copyreg.add_extension(pair[0], pair[1], code)
class C:
- def __cmp__(self, other):
- return cmp(self.__dict__, other.__dict__)
+ def __eq__(self, other):
+ return self.__dict__ == other.__dict__
+
+class D(C):
+ def __init__(self, arg):
+ pass
+
+class E(C):
+ def __getinitargs__(self):
+ return ()
import __main__
__main__.C = C
C.__module__ = "__main__"
+__main__.D = D
+D.__module__ = "__main__"
+__main__.E = E
+E.__module__ = "__main__"
class myint(int):
def __init__(self, x):
@@ -121,8 +118,8 @@ class initarg(C):
class metaclass(type):
pass
-class use_metaclass(object):
- __metaclass__ = metaclass
+class use_metaclass(object, metaclass=metaclass):
+ pass
class pickling_metaclass(type):
def __eq__(self, other):
@@ -132,8 +129,6 @@ class pickling_metaclass(type):
def __reduce__(self):
return (create_dynamic_class, self.reduce_args)
- __hash__ = None
-
def create_dynamic_class(name, bases):
result = pickling_metaclass(name, bases, dict())
result.reduce_args = (name, bases)
@@ -142,262 +137,281 @@ def create_dynamic_class(name, bases):
# DATA0 .. DATA2 are the pickles we expect under the various protocols, for
# the object returned by create_data().
-# break into multiple strings to avoid confusing font-lock-mode
-DATA0 = """(lp1
-I0
-aL1L
-aF2
-ac__builtin__
-complex
-p2
-""" + \
-"""(F3
-F0
-tRp3
-aI1
-aI-1
-aI255
-aI-255
-aI-256
-aI65535
-aI-65535
-aI-65536
-aI2147483647
-aI-2147483647
-aI-2147483648
-a""" + \
-"""(S'abc'
-p4
-g4
-""" + \
-"""(i__main__
-C
-p5
-""" + \
-"""(dp6
-S'foo'
-p7
-I1
-sS'bar'
-p8
-I2
-sbg5
-tp9
-ag9
-aI5
-a.
-"""
-
-# Disassembly of DATA0.
+DATA0 = (
+ b'(lp0\nL0L\naL1L\naF2.0\nac'
+ b'builtins\ncomplex\n'
+ b'p1\n(F3.0\nF0.0\ntp2\nRp'
+ b'3\naL1L\naL-1L\naL255L\naL-'
+ b'255L\naL-256L\naL65535L\na'
+ b'L-65535L\naL-65536L\naL2'
+ b'147483647L\naL-2147483'
+ b'647L\naL-2147483648L\na('
+ b'Vabc\np4\ng4\nccopyreg'
+ b'\n_reconstructor\np5\n('
+ b'c__main__\nC\np6\ncbu'
+ b'iltins\nobject\np7\nNt'
+ b'p8\nRp9\n(dp10\nVfoo\np1'
+ b'1\nL1L\nsVbar\np12\nL2L\nsb'
+ b'g9\ntp13\nag13\naL5L\na.'
+)
+
+# Disassembly of DATA0
DATA0_DIS = """\
0: ( MARK
1: l LIST (MARK at 0)
- 2: p PUT 1
- 5: I INT 0
- 8: a APPEND
- 9: L LONG 1L
- 13: a APPEND
- 14: F FLOAT 2.0
- 17: a APPEND
- 18: c GLOBAL '__builtin__ complex'
- 39: p PUT 2
+ 2: p PUT 0
+ 5: L LONG 0
+ 9: a APPEND
+ 10: L LONG 1
+ 14: a APPEND
+ 15: F FLOAT 2.0
+ 20: a APPEND
+ 21: c GLOBAL 'builtins complex'
+ 39: p PUT 1
42: ( MARK
43: F FLOAT 3.0
- 46: F FLOAT 0.0
- 49: t TUPLE (MARK at 42)
- 50: R REDUCE
- 51: p PUT 3
- 54: a APPEND
- 55: I INT 1
- 58: a APPEND
- 59: I INT -1
- 63: a APPEND
- 64: I INT 255
- 69: a APPEND
- 70: I INT -255
- 76: a APPEND
- 77: I INT -256
- 83: a APPEND
- 84: I INT 65535
- 91: a APPEND
- 92: I INT -65535
- 100: a APPEND
- 101: I INT -65536
- 109: a APPEND
- 110: I INT 2147483647
- 122: a APPEND
- 123: I INT -2147483647
- 136: a APPEND
- 137: I INT -2147483648
- 150: a APPEND
- 151: ( MARK
- 152: S STRING 'abc'
- 159: p PUT 4
- 162: g GET 4
- 165: ( MARK
- 166: i INST '__main__ C' (MARK at 165)
- 178: p PUT 5
- 181: ( MARK
- 182: d DICT (MARK at 181)
- 183: p PUT 6
- 186: S STRING 'foo'
- 193: p PUT 7
- 196: I INT 1
- 199: s SETITEM
- 200: S STRING 'bar'
- 207: p PUT 8
- 210: I INT 2
- 213: s SETITEM
- 214: b BUILD
- 215: g GET 5
- 218: t TUPLE (MARK at 151)
- 219: p PUT 9
- 222: a APPEND
- 223: g GET 9
- 226: a APPEND
- 227: I INT 5
- 230: a APPEND
- 231: . STOP
+ 48: F FLOAT 0.0
+ 53: t TUPLE (MARK at 42)
+ 54: p PUT 2
+ 57: R REDUCE
+ 58: p PUT 3
+ 61: a APPEND
+ 62: L LONG 1
+ 66: a APPEND
+ 67: L LONG -1
+ 72: a APPEND
+ 73: L LONG 255
+ 79: a APPEND
+ 80: L LONG -255
+ 87: a APPEND
+ 88: L LONG -256
+ 95: a APPEND
+ 96: L LONG 65535
+ 104: a APPEND
+ 105: L LONG -65535
+ 114: a APPEND
+ 115: L LONG -65536
+ 124: a APPEND
+ 125: L LONG 2147483647
+ 138: a APPEND
+ 139: L LONG -2147483647
+ 153: a APPEND
+ 154: L LONG -2147483648
+ 168: a APPEND
+ 169: ( MARK
+ 170: V UNICODE 'abc'
+ 175: p PUT 4
+ 178: g GET 4
+ 181: c GLOBAL 'copyreg _reconstructor'
+ 205: p PUT 5
+ 208: ( MARK
+ 209: c GLOBAL '__main__ C'
+ 221: p PUT 6
+ 224: c GLOBAL 'builtins object'
+ 241: p PUT 7
+ 244: N NONE
+ 245: t TUPLE (MARK at 208)
+ 246: p PUT 8
+ 249: R REDUCE
+ 250: p PUT 9
+ 253: ( MARK
+ 254: d DICT (MARK at 253)
+ 255: p PUT 10
+ 259: V UNICODE 'foo'
+ 264: p PUT 11
+ 268: L LONG 1
+ 272: s SETITEM
+ 273: V UNICODE 'bar'
+ 278: p PUT 12
+ 282: L LONG 2
+ 286: s SETITEM
+ 287: b BUILD
+ 288: g GET 9
+ 291: t TUPLE (MARK at 169)
+ 292: p PUT 13
+ 296: a APPEND
+ 297: g GET 13
+ 301: a APPEND
+ 302: L LONG 5
+ 306: a APPEND
+ 307: . STOP
highest protocol among opcodes = 0
"""
-DATA1 = (']q\x01(K\x00L1L\nG@\x00\x00\x00\x00\x00\x00\x00'
- 'c__builtin__\ncomplex\nq\x02(G@\x08\x00\x00\x00\x00\x00'
- '\x00G\x00\x00\x00\x00\x00\x00\x00\x00tRq\x03K\x01J\xff\xff'
- '\xff\xffK\xffJ\x01\xff\xff\xffJ\x00\xff\xff\xffM\xff\xff'
- 'J\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff\xff\x7fJ\x01\x00'
- '\x00\x80J\x00\x00\x00\x80(U\x03abcq\x04h\x04(c__main__\n'
- 'C\nq\x05oq\x06}q\x07(U\x03fooq\x08K\x01U\x03barq\tK\x02ubh'
- '\x06tq\nh\nK\x05e.'
- )
-
-# Disassembly of DATA1.
+DATA1 = (
+ b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c'
+ b'builtins\ncomplex\nq\x01'
+ b'(G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00t'
+ b'q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ'
+ b'\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff'
+ b'\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00ab'
+ b'cq\x04h\x04ccopyreg\n_reco'
+ b'nstructor\nq\x05(c__main'
+ b'__\nC\nq\x06cbuiltins\n'
+ b'object\nq\x07Ntq\x08Rq\t}q\n('
+ b'X\x03\x00\x00\x00fooq\x0bK\x01X\x03\x00\x00\x00bar'
+ b'q\x0cK\x02ubh\ttq\rh\rK\x05e.'
+)
+
+# Disassembly of DATA1
DATA1_DIS = """\
0: ] EMPTY_LIST
- 1: q BINPUT 1
+ 1: q BINPUT 0
3: ( MARK
4: K BININT1 0
- 6: L LONG 1L
- 10: G BINFLOAT 2.0
- 19: c GLOBAL '__builtin__ complex'
- 40: q BINPUT 2
- 42: ( MARK
- 43: G BINFLOAT 3.0
- 52: G BINFLOAT 0.0
- 61: t TUPLE (MARK at 42)
- 62: R REDUCE
- 63: q BINPUT 3
- 65: K BININT1 1
- 67: J BININT -1
- 72: K BININT1 255
- 74: J BININT -255
- 79: J BININT -256
- 84: M BININT2 65535
- 87: J BININT -65535
- 92: J BININT -65536
- 97: J BININT 2147483647
- 102: J BININT -2147483647
- 107: J BININT -2147483648
- 112: ( MARK
- 113: U SHORT_BINSTRING 'abc'
+ 6: K BININT1 1
+ 8: G BINFLOAT 2.0
+ 17: c GLOBAL 'builtins complex'
+ 35: q BINPUT 1
+ 37: ( MARK
+ 38: G BINFLOAT 3.0
+ 47: G BINFLOAT 0.0
+ 56: t TUPLE (MARK at 37)
+ 57: q BINPUT 2
+ 59: R REDUCE
+ 60: q BINPUT 3
+ 62: K BININT1 1
+ 64: J BININT -1
+ 69: K BININT1 255
+ 71: J BININT -255
+ 76: J BININT -256
+ 81: M BININT2 65535
+ 84: J BININT -65535
+ 89: J BININT -65536
+ 94: J BININT 2147483647
+ 99: J BININT -2147483647
+ 104: J BININT -2147483648
+ 109: ( MARK
+ 110: X BINUNICODE 'abc'
118: q BINPUT 4
120: h BINGET 4
- 122: ( MARK
- 123: c GLOBAL '__main__ C'
- 135: q BINPUT 5
- 137: o OBJ (MARK at 122)
- 138: q BINPUT 6
- 140: } EMPTY_DICT
- 141: q BINPUT 7
- 143: ( MARK
- 144: U SHORT_BINSTRING 'foo'
- 149: q BINPUT 8
- 151: K BININT1 1
- 153: U SHORT_BINSTRING 'bar'
- 158: q BINPUT 9
- 160: K BININT1 2
- 162: u SETITEMS (MARK at 143)
- 163: b BUILD
- 164: h BINGET 6
- 166: t TUPLE (MARK at 112)
- 167: q BINPUT 10
- 169: h BINGET 10
- 171: K BININT1 5
- 173: e APPENDS (MARK at 3)
- 174: . STOP
+ 122: c GLOBAL 'copyreg _reconstructor'
+ 146: q BINPUT 5
+ 148: ( MARK
+ 149: c GLOBAL '__main__ C'
+ 161: q BINPUT 6
+ 163: c GLOBAL 'builtins object'
+ 180: q BINPUT 7
+ 182: N NONE
+ 183: t TUPLE (MARK at 148)
+ 184: q BINPUT 8
+ 186: R REDUCE
+ 187: q BINPUT 9
+ 189: } EMPTY_DICT
+ 190: q BINPUT 10
+ 192: ( MARK
+ 193: X BINUNICODE 'foo'
+ 201: q BINPUT 11
+ 203: K BININT1 1
+ 205: X BINUNICODE 'bar'
+ 213: q BINPUT 12
+ 215: K BININT1 2
+ 217: u SETITEMS (MARK at 192)
+ 218: b BUILD
+ 219: h BINGET 9
+ 221: t TUPLE (MARK at 109)
+ 222: q BINPUT 13
+ 224: h BINGET 13
+ 226: K BININT1 5
+ 228: e APPENDS (MARK at 3)
+ 229: . STOP
highest protocol among opcodes = 1
"""
-DATA2 = ('\x80\x02]q\x01(K\x00\x8a\x01\x01G@\x00\x00\x00\x00\x00\x00\x00'
- 'c__builtin__\ncomplex\nq\x02G@\x08\x00\x00\x00\x00\x00\x00G\x00'
- '\x00\x00\x00\x00\x00\x00\x00\x86Rq\x03K\x01J\xff\xff\xff\xffK'
- '\xffJ\x01\xff\xff\xffJ\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xff'
- 'J\x00\x00\xff\xffJ\xff\xff\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00'
- '\x80(U\x03abcq\x04h\x04(c__main__\nC\nq\x05oq\x06}q\x07(U\x03foo'
- 'q\x08K\x01U\x03barq\tK\x02ubh\x06tq\nh\nK\x05e.')
-
-# Disassembly of DATA2.
+DATA2 = (
+ b'\x80\x02]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c'
+ b'builtins\ncomplex\n'
+ b'q\x01G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00'
+ b'\x86q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xff'
+ b'J\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff'
+ b'\xff\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00a'
+ b'bcq\x04h\x04c__main__\nC\nq\x05'
+ b')\x81q\x06}q\x07(X\x03\x00\x00\x00fooq\x08K\x01'
+ b'X\x03\x00\x00\x00barq\tK\x02ubh\x06tq\nh'
+ b'\nK\x05e.'
+)
+
+# Disassembly of DATA2
DATA2_DIS = """\
0: \x80 PROTO 2
2: ] EMPTY_LIST
- 3: q BINPUT 1
+ 3: q BINPUT 0
5: ( MARK
6: K BININT1 0
- 8: \x8a LONG1 1L
- 11: G BINFLOAT 2.0
- 20: c GLOBAL '__builtin__ complex'
- 41: q BINPUT 2
- 43: G BINFLOAT 3.0
- 52: G BINFLOAT 0.0
- 61: \x86 TUPLE2
- 62: R REDUCE
- 63: q BINPUT 3
- 65: K BININT1 1
- 67: J BININT -1
- 72: K BININT1 255
- 74: J BININT -255
- 79: J BININT -256
- 84: M BININT2 65535
- 87: J BININT -65535
- 92: J BININT -65536
- 97: J BININT 2147483647
- 102: J BININT -2147483647
- 107: J BININT -2147483648
- 112: ( MARK
- 113: U SHORT_BINSTRING 'abc'
- 118: q BINPUT 4
- 120: h BINGET 4
- 122: ( MARK
- 123: c GLOBAL '__main__ C'
- 135: q BINPUT 5
- 137: o OBJ (MARK at 122)
- 138: q BINPUT 6
- 140: } EMPTY_DICT
- 141: q BINPUT 7
- 143: ( MARK
- 144: U SHORT_BINSTRING 'foo'
- 149: q BINPUT 8
- 151: K BININT1 1
- 153: U SHORT_BINSTRING 'bar'
- 158: q BINPUT 9
- 160: K BININT1 2
- 162: u SETITEMS (MARK at 143)
- 163: b BUILD
- 164: h BINGET 6
- 166: t TUPLE (MARK at 112)
- 167: q BINPUT 10
- 169: h BINGET 10
- 171: K BININT1 5
- 173: e APPENDS (MARK at 5)
- 174: . STOP
+ 8: K BININT1 1
+ 10: G BINFLOAT 2.0
+ 19: c GLOBAL 'builtins complex'
+ 37: q BINPUT 1
+ 39: G BINFLOAT 3.0
+ 48: G BINFLOAT 0.0
+ 57: \x86 TUPLE2
+ 58: q BINPUT 2
+ 60: R REDUCE
+ 61: q BINPUT 3
+ 63: K BININT1 1
+ 65: J BININT -1
+ 70: K BININT1 255
+ 72: J BININT -255
+ 77: J BININT -256
+ 82: M BININT2 65535
+ 85: J BININT -65535
+ 90: J BININT -65536
+ 95: J BININT 2147483647
+ 100: J BININT -2147483647
+ 105: J BININT -2147483648
+ 110: ( MARK
+ 111: X BINUNICODE 'abc'
+ 119: q BINPUT 4
+ 121: h BINGET 4
+ 123: c GLOBAL '__main__ C'
+ 135: q BINPUT 5
+ 137: ) EMPTY_TUPLE
+ 138: \x81 NEWOBJ
+ 139: q BINPUT 6
+ 141: } EMPTY_DICT
+ 142: q BINPUT 7
+ 144: ( MARK
+ 145: X BINUNICODE 'foo'
+ 153: q BINPUT 8
+ 155: K BININT1 1
+ 157: X BINUNICODE 'bar'
+ 165: q BINPUT 9
+ 167: K BININT1 2
+ 169: u SETITEMS (MARK at 144)
+ 170: b BUILD
+ 171: h BINGET 6
+ 173: t TUPLE (MARK at 110)
+ 174: q BINPUT 10
+ 176: h BINGET 10
+ 178: K BININT1 5
+ 180: e APPENDS (MARK at 5)
+ 181: . STOP
highest protocol among opcodes = 2
"""
+# set([1,2]) pickled from 2.x with protocol 2
+DATA3 = b'\x80\x02c__builtin__\nset\nq\x00]q\x01(K\x01K\x02e\x85q\x02Rq\x03.'
+
+# xrange(5) pickled from 2.x with protocol 2
+DATA4 = b'\x80\x02c__builtin__\nxrange\nq\x00K\x00K\x05K\x01\x87q\x01Rq\x02.'
+
+# a SimpleCookie() object pickled from 2.x with protocol 2
+DATA5 = (b'\x80\x02cCookie\nSimpleCookie\nq\x00)\x81q\x01U\x03key'
+ b'q\x02cCookie\nMorsel\nq\x03)\x81q\x04(U\x07commentq\x05U'
+ b'\x00q\x06U\x06domainq\x07h\x06U\x06secureq\x08h\x06U\x07'
+ b'expiresq\th\x06U\x07max-ageq\nh\x06U\x07versionq\x0bh\x06U'
+ b'\x04pathq\x0ch\x06U\x08httponlyq\rh\x06u}q\x0e(U\x0b'
+ b'coded_valueq\x0fU\x05valueq\x10h\x10h\x10h\x02h\x02ubs}q\x11b.')
+
+# set([3]) pickled from 2.x with protocol 2
+DATA6 = b'\x80\x02c__builtin__\nset\nq\x00]q\x01K\x03a\x85q\x02Rq\x03.'
+
+
def create_data():
c = C()
c.foo = 1
c.bar = 2
- x = [0, 1L, 2.0, 3.0+0j]
+ x = [0, 1, 2.0, 3.0+0j]
# Append some integer test cases at cPickle.c's internal size
# cutoffs.
uint1max = 0xff
@@ -414,7 +428,7 @@ def create_data():
return x
class AbstractPickleTests(unittest.TestCase):
- # Subclass must define self.dumps, self.loads, self.error.
+ # Subclass must define self.dumps, self.loads.
_testdata = create_data()
@@ -448,11 +462,71 @@ class AbstractPickleTests(unittest.TestCase):
got = self.loads(s)
self.assertEqual(expected, got)
- def test_load_from_canned_string(self):
- expected = self._testdata
- for canned in DATA0, DATA1, DATA2:
- got = self.loads(canned)
- self.assertEqual(expected, got)
+ def test_load_from_data0(self):
+ self.assertEqual(self._testdata, self.loads(DATA0))
+
+ def test_load_from_data1(self):
+ self.assertEqual(self._testdata, self.loads(DATA1))
+
+ def test_load_from_data2(self):
+ self.assertEqual(self._testdata, self.loads(DATA2))
+
+ def test_load_classic_instance(self):
+ # See issue5180. Test loading 2.x pickles that
+ # contain an instance of old style class.
+ for X, args in [(C, ()), (D, ('x',)), (E, ())]:
+ xname = X.__name__.encode('ascii')
+ # Protocol 0 (text mode pickle):
+ """
+ 0: ( MARK
+ 1: i INST '__main__ X' (MARK at 0)
+ 15: p PUT 0
+ 18: ( MARK
+ 19: d DICT (MARK at 18)
+ 20: p PUT 1
+ 23: b BUILD
+ 24: . STOP
+ """
+ pickle0 = (b"(i__main__\n"
+ b"X\n"
+ b"p0\n"
+ b"(dp1\nb.").replace(b'X', xname)
+ self.assertEqual(X(*args), self.loads(pickle0))
+
+ # Protocol 1 (binary mode pickle)
+ """
+ 0: ( MARK
+ 1: c GLOBAL '__main__ X'
+ 15: q BINPUT 0
+ 17: o OBJ (MARK at 0)
+ 18: q BINPUT 1
+ 20: } EMPTY_DICT
+ 21: q BINPUT 2
+ 23: b BUILD
+ 24: . STOP
+ """
+ pickle1 = (b'(c__main__\n'
+ b'X\n'
+ b'q\x00oq\x01}q\x02b.').replace(b'X', xname)
+ self.assertEqual(X(*args), self.loads(pickle1))
+
+ # Protocol 2 (pickle2 = b'\x80\x02' + pickle1)
+ """
+ 0: \x80 PROTO 2
+ 2: ( MARK
+ 3: c GLOBAL '__main__ X'
+ 17: q BINPUT 0
+ 19: o OBJ (MARK at 2)
+ 20: q BINPUT 1
+ 22: } EMPTY_DICT
+ 23: q BINPUT 2
+ 25: b BUILD
+ 26: . STOP
+ """
+ pickle2 = (b'\x80\x02(c__main__\n'
+ b'X\n'
+ b'q\x00oq\x01}q\x02b.').replace(b'X', xname)
+ self.assertEqual(X(*args), self.loads(pickle2))
# There are gratuitous differences between pickles produced by
# pickle and cPickle, largely because cPickle starts PUT indices at
@@ -461,11 +535,12 @@ class AbstractPickleTests(unittest.TestCase):
# is a mystery. cPickle also suppresses PUT for objects with a refcount
# of 1.
def dont_test_disassembly(self):
+ from io import StringIO
from pickletools import dis
for proto, expected in (0, DATA0_DIS), (1, DATA1_DIS):
s = self.dumps(self._testdata, proto)
- filelike = cStringIO.StringIO()
+ filelike = StringIO()
dis(s, out=filelike)
got = filelike.getvalue()
self.assertEqual(expected, got)
@@ -495,7 +570,7 @@ class AbstractPickleTests(unittest.TestCase):
for proto in protocols:
s = self.dumps(d, proto)
x = self.loads(s)
- self.assertEqual(x.keys(), [1])
+ self.assertEqual(list(x.keys()), [1])
self.assertTrue(x[1] is x)
def test_recursive_inst(self):
@@ -518,48 +593,63 @@ class AbstractPickleTests(unittest.TestCase):
x = self.loads(s)
self.assertEqual(len(x), 1)
self.assertEqual(dir(x[0]), dir(i))
- self.assertEqual(x[0].attr.keys(), [1])
+ self.assertEqual(list(x[0].attr.keys()), [1])
self.assertTrue(x[0].attr[1] is x)
- def test_garyp(self):
- self.assertRaises(self.error, self.loads, 'garyp')
+ def test_get(self):
+ self.assertRaises(KeyError, self.loads, b'g0\np0')
+ self.assertEqual(self.loads(b'((Kdtp0\nh\x00l.))'), [(100,), (100,)])
def test_insecure_strings(self):
- insecure = ["abc", "2 + 2", # not quoted
- #"'abc' + 'def'", # not a single quoted string
- "'abc", # quote is not closed
- "'abc\"", # open quote and close quote don't match
- "'abc' ?", # junk after close quote
- "'\\'", # trailing backslash
+ # XXX Some of these tests are temporarily disabled
+ insecure = [b"abc", b"2 + 2", # not quoted
+ ## b"'abc' + 'def'", # not a single quoted string
+ b"'abc", # quote is not closed
+ b"'abc\"", # open quote and close quote don't match
+ b"'abc' ?", # junk after close quote
+ b"'\\'", # trailing backslash
# some tests of the quoting rules
- #"'abc\"\''",
- #"'\\\\a\'\'\'\\\'\\\\\''",
+ ## b"'abc\"\''",
+ ## b"'\\\\a\'\'\'\\\'\\\\\''",
]
- for s in insecure:
- buf = "S" + s + "\012p0\012."
+ for b in insecure:
+ buf = b"S" + b + b"\012p0\012."
self.assertRaises(ValueError, self.loads, buf)
- if have_unicode:
- def test_unicode(self):
- endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>',
- u'<\\>', u'<\\\U00012345>']
- for proto in protocols:
- for u in endcases:
- p = self.dumps(u, proto)
- u2 = self.loads(p)
- self.assertEqual(u2, u)
+ def test_unicode(self):
+ endcases = ['', '<\\u>', '<\\\u1234>', '<\n>',
+ '<\\>', '<\\\U00012345>',
+ # surrogates
+ '<\udc80>']
+ for proto in protocols:
+ for u in endcases:
+ p = self.dumps(u, proto)
+ u2 = self.loads(p)
+ self.assertEqual(u2, u)
- def test_unicode_high_plane(self):
- t = u'\U00012345'
- for proto in protocols:
- p = self.dumps(t, proto)
- t2 = self.loads(p)
- self.assertEqual(t2, t)
+ def test_unicode_high_plane(self):
+ t = '\U00012345'
+ for proto in protocols:
+ p = self.dumps(t, proto)
+ t2 = self.loads(p)
+ self.assertEqual(t2, t)
+
+ def test_bytes(self):
+ for proto in protocols:
+ for s in b'', b'xyz', b'xyz'*100:
+ p = self.dumps(s)
+ self.assertEqual(self.loads(p), s)
+ for s in [bytes([i]) for i in range(256)]:
+ p = self.dumps(s)
+ self.assertEqual(self.loads(p), s)
+ for s in [bytes([i, i]) for i in range(256)]:
+ p = self.dumps(s)
+ self.assertEqual(self.loads(p), s)
def test_ints(self):
import sys
for proto in protocols:
- n = sys.maxint
+ n = sys.maxsize
while n:
for expected in (-n, n):
s = self.dumps(expected, proto)
@@ -568,20 +658,20 @@ class AbstractPickleTests(unittest.TestCase):
n = n >> 1
def test_maxint64(self):
- maxint64 = (1L << 63) - 1
- data = 'I' + str(maxint64) + '\n.'
+ maxint64 = (1 << 63) - 1
+ data = b'I' + str(maxint64).encode("ascii") + b'\n.'
got = self.loads(data)
self.assertEqual(got, maxint64)
# Try too with a bogus literal.
- data = 'I' + str(maxint64) + 'JUNK\n.'
+ data = b'I' + str(maxint64).encode("ascii") + b'JUNK\n.'
self.assertRaises(ValueError, self.loads, data)
def test_long(self):
for proto in protocols:
# 256 bytes is where LONG4 begins.
for nbits in 1, 8, 8*254, 8*255, 8*256, 8*257:
- nbase = 1L << nbits
+ nbase = 1 << nbits
for npos in nbase-1, nbase, nbase+1:
for n in npos, -npos:
pickle = self.dumps(n, proto)
@@ -589,7 +679,7 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(n, got)
# Try a monster. This is quadratic-time in protos 0 & 1, so don't
# bother with those.
- nbase = long("deadbeeffeedface", 16)
+ nbase = int("deadbeeffeedface", 16)
nbase += nbase << 1000000
for n in nbase, -nbase:
p = self.dumps(n, 2)
@@ -608,8 +698,8 @@ class AbstractPickleTests(unittest.TestCase):
@run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
def test_float_format(self):
- # make sure that floats are formatted locale independent
- self.assertEqual(self.dumps(1.2)[0:3], 'F1.')
+ # make sure that floats are formatted locale independent with proto 0
+ self.assertEqual(self.dumps(1.2, 0)[0:3], b'F1.')
def test_reduce(self):
pass
@@ -617,6 +707,11 @@ class AbstractPickleTests(unittest.TestCase):
def test_getinitargs(self):
pass
+ def test_pop_empty_stack(self):
+ # Test issue7455
+ s = b'0'
+ self.assertRaises((pickle.UnpicklingError, IndexError), self.loads, s)
+
def test_metaclass(self):
a = use_metaclass()
for proto in protocols:
@@ -626,7 +721,7 @@ class AbstractPickleTests(unittest.TestCase):
def test_dynamic_class(self):
a = create_dynamic_class("my_dynamic_class", (object,))
- copy_reg.pickle(pickling_metaclass, pickling_metaclass.__reduce__)
+ copyreg.pickle(pickling_metaclass, pickling_metaclass.__reduce__)
for proto in protocols:
s = self.dumps(a, proto)
b = self.loads(s)
@@ -659,22 +754,22 @@ class AbstractPickleTests(unittest.TestCase):
for proto in protocols:
expected = build_none
if proto >= 2:
- expected = pickle.PROTO + chr(proto) + expected
+ expected = pickle.PROTO + bytes([proto]) + expected
p = self.dumps(None, proto)
self.assertEqual(p, expected)
oob = protocols[-1] + 1 # a future protocol
- badpickle = pickle.PROTO + chr(oob) + build_none
+ badpickle = pickle.PROTO + bytes([oob]) + build_none
try:
self.loads(badpickle)
- except ValueError, detail:
+ except ValueError as detail:
self.assertTrue(str(detail).startswith(
"unsupported pickle protocol"))
else:
self.fail("expected bad protocol number to raise ValueError")
def test_long1(self):
- x = 12345678910111213141516178920L
+ x = 12345678910111213141516178920
for proto in protocols:
s = self.dumps(x, proto)
y = self.loads(s)
@@ -682,7 +777,7 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(opcode_in_pickle(pickle.LONG1, s), proto >= 2)
def test_long4(self):
- x = 12345678910111213141516178920L << (256*8)
+ x = 12345678910111213141516178920 << (256*8)
for proto in protocols:
s = self.dumps(x, proto)
y = self.loads(s)
@@ -708,6 +803,12 @@ class AbstractPickleTests(unittest.TestCase):
(2, 2): pickle.TUPLE2,
(2, 3): pickle.TUPLE3,
(2, 4): pickle.TUPLE,
+
+ (3, 0): pickle.EMPTY_TUPLE,
+ (3, 1): pickle.TUPLE1,
+ (3, 2): pickle.TUPLE2,
+ (3, 3): pickle.TUPLE3,
+ (3, 4): pickle.TUPLE,
}
a = ()
b = (1,)
@@ -727,14 +828,17 @@ class AbstractPickleTests(unittest.TestCase):
expected_opcode = {(0, None): pickle.NONE,
(1, None): pickle.NONE,
(2, None): pickle.NONE,
+ (3, None): pickle.NONE,
(0, True): pickle.INT,
(1, True): pickle.INT,
(2, True): pickle.NEWTRUE,
+ (3, True): pickle.NEWTRUE,
(0, False): pickle.INT,
(1, False): pickle.INT,
(2, False): pickle.NEWFALSE,
+ (3, False): pickle.NEWFALSE,
}
for proto in protocols:
for x in None, False, True:
@@ -776,22 +880,22 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(B(x), B(y), detail)
self.assertEqual(x.__dict__, y.__dict__, detail)
- # Register a type with copy_reg, with extension code extcode. Pickle
+ # Register a type with copyreg, with extension code extcode. Pickle
# an object of that type. Check that the resulting pickle uses opcode
# (EXT[124]) under proto 2, and not in proto 1.
def produce_global_ext(self, extcode, opcode):
e = ExtensionSaver(extcode)
try:
- copy_reg.add_extension(__name__, "MyList", extcode)
+ copyreg.add_extension(__name__, "MyList", extcode)
x = MyList([1, 2, 3])
x.foo = 42
x.bar = "hello"
# Dump using protocol 1 for comparison.
s1 = self.dumps(x, 1)
- self.assertIn(__name__, s1)
- self.assertIn("MyList", s1)
+ self.assertIn(__name__.encode("utf-8"), s1)
+ self.assertIn(b"MyList", s1)
self.assertEqual(opcode_in_pickle(opcode, s1), False)
y = self.loads(s1)
@@ -800,9 +904,9 @@ class AbstractPickleTests(unittest.TestCase):
# Dump using protocol 2 for test.
s2 = self.dumps(x, 2)
- self.assertNotIn(__name__, s2)
- self.assertNotIn("MyList", s2)
- self.assertEqual(opcode_in_pickle(opcode, s2), True)
+ self.assertNotIn(__name__.encode("utf-8"), s2)
+ self.assertNotIn(b"MyList", s2)
+ self.assertEqual(opcode_in_pickle(opcode, s2), True, repr(s2))
y = self.loads(s2)
self.assertEqual(list(x), list(y))
@@ -827,7 +931,7 @@ class AbstractPickleTests(unittest.TestCase):
def test_list_chunking(self):
n = 10 # too small to chunk
- x = range(n)
+ x = list(range(n))
for proto in protocols:
s = self.dumps(x, proto)
y = self.loads(s)
@@ -836,7 +940,7 @@ class AbstractPickleTests(unittest.TestCase):
self.assertEqual(num_appends, proto > 0)
n = 2500 # expect at least two chunks when proto > 0
- x = range(n)
+ x = list(range(n))
for proto in protocols:
s = self.dumps(x, proto)
y = self.loads(s)
@@ -852,6 +956,7 @@ class AbstractPickleTests(unittest.TestCase):
x = dict.fromkeys(range(n))
for proto in protocols:
s = self.dumps(x, proto)
+ self.assertIsInstance(s, bytes_types)
y = self.loads(s)
self.assertEqual(x, y)
num_setitems = count_opcode(pickle.SETITEMS, s)
@@ -935,6 +1040,14 @@ class AbstractPickleTests(unittest.TestCase):
y = self.loads(s)
self.assertEqual(y._reduce_called, 1)
+ def test_bad_getattr(self):
+ x = BadGetattr()
+ for proto in 0, 1:
+ self.assertRaises(RuntimeError, self.dumps, x, proto)
+ # protocol 2 don't raise a RuntimeError.
+ d = self.dumps(x, 2)
+ self.assertRaises(RuntimeError, self.loads, d)
+
def test_reduce_bad_iterator(self):
# Issue4176: crash when 4th and 5th items of __reduce__()
# are not iterators
@@ -951,17 +1064,17 @@ class AbstractPickleTests(unittest.TestCase):
for proto in protocols:
try:
self.dumps(C(), proto)
- except (AttributeError, pickle.PickleError, cPickle.PickleError):
+ except (pickle.PickleError):
pass
try:
self.dumps(D(), proto)
- except (AttributeError, pickle.PickleError, cPickle.PickleError):
+ except (pickle.PickleError):
pass
def test_many_puts_and_gets(self):
# Test that internal data structures correctly deal with lots of
# puts/gets.
- keys = ("aaa" + str(i) for i in xrange(100))
+ keys = ("aaa" + str(i) for i in range(100))
large_dict = dict((k, [4, 5, 6]) for k in keys)
obj = [dict(large_dict), dict(large_dict), dict(large_dict)]
@@ -986,6 +1099,153 @@ class AbstractPickleTests(unittest.TestCase):
for x_key, y_key in zip(x_keys, y_keys):
self.assertIs(x_key, y_key)
+ def test_unpickle_from_2x(self):
+ # Unpickle non-trivial data from Python 2.x.
+ loaded = self.loads(DATA3)
+ self.assertEqual(loaded, set([1, 2]))
+ loaded = self.loads(DATA4)
+ self.assertEqual(type(loaded), type(range(0)))
+ self.assertEqual(list(loaded), list(range(5)))
+ loaded = self.loads(DATA5)
+ self.assertEqual(type(loaded), SimpleCookie)
+ self.assertEqual(list(loaded.keys()), ["key"])
+ self.assertEqual(loaded["key"].value, "Set-Cookie: key=value")
+
+ def test_pickle_to_2x(self):
+ # Pickle non-trivial data with protocol 2, expecting that it yields
+ # the same result as Python 2.x did.
+ # NOTE: this test is a bit too strong since we can produce different
+ # bytecode that 2.x will still understand.
+ dumped = self.dumps(range(5), 2)
+ self.assertEqual(dumped, DATA4)
+ dumped = self.dumps(set([3]), 2)
+ self.assertEqual(dumped, DATA6)
+
+ def test_large_pickles(self):
+ # Test the correctness of internal buffering routines when handling
+ # large data.
+ for proto in protocols:
+ data = (1, min, b'xy' * (30 * 1024), len)
+ dumped = self.dumps(data, proto)
+ loaded = self.loads(dumped)
+ self.assertEqual(len(loaded), len(data))
+ self.assertEqual(loaded, data)
+
+ def test_empty_bytestring(self):
+ # issue 11286
+ empty = self.loads(b'\x80\x03U\x00q\x00.', encoding='koi8-r')
+ self.assertEqual(empty, '')
+
+ def check_negative_32b_binXXX(self, dumped):
+ if sys.maxsize > 2**32:
+ self.skipTest("test is only meaningful on 32-bit builds")
+ # XXX Pure Python pickle reads lengths as signed and passes
+ # them directly to read() (hence the EOFError)
+ with self.assertRaises((pickle.UnpicklingError, EOFError,
+ ValueError, OverflowError)):
+ self.loads(dumped)
+
+ def test_negative_32b_binbytes(self):
+ # On 32-bit builds, a BINBYTES of 2**31 or more is refused
+ self.check_negative_32b_binXXX(b'\x80\x03B\xff\xff\xff\xffxyzq\x00.')
+
+ def test_negative_32b_binunicode(self):
+ # On 32-bit builds, a BINUNICODE of 2**31 or more is refused
+ self.check_negative_32b_binXXX(b'\x80\x03X\xff\xff\xff\xffxyzq\x00.')
+
+ def test_negative_put(self):
+ # Issue #12847
+ dumped = b'Va\np-1\n.'
+ self.assertRaises(ValueError, self.loads, dumped)
+
+ def test_negative_32b_binput(self):
+ # Issue #12847
+ if sys.maxsize > 2**32:
+ self.skipTest("test is only meaningful on 32-bit builds")
+ dumped = b'\x80\x03X\x01\x00\x00\x00ar\xff\xff\xff\xff.'
+ self.assertRaises(ValueError, self.loads, dumped)
+
+
+class BigmemPickleTests(unittest.TestCase):
+
+ # Binary protocols can serialize longs of up to 2GB-1
+
+ @bigmemtest(size=_2G, memuse=1 + 1, dry_run=False)
+ def test_huge_long_32b(self, size):
+ data = 1 << (8 * size)
+ try:
+ for proto in protocols:
+ if proto < 2:
+ continue
+ with self.assertRaises((ValueError, OverflowError)):
+ self.dumps(data, protocol=proto)
+ finally:
+ data = None
+
+ # Protocol 3 can serialize up to 4GB-1 as a bytes object
+ # (older protocols don't have a dedicated opcode for bytes and are
+ # too inefficient)
+
+ @bigmemtest(size=_2G, memuse=1 + 1, dry_run=False)
+ def test_huge_bytes_32b(self, size):
+ data = b"abcd" * (size // 4)
+ try:
+ for proto in protocols:
+ if proto < 3:
+ continue
+ try:
+ pickled = self.dumps(data, protocol=proto)
+ self.assertTrue(b"abcd" in pickled[:15])
+ self.assertTrue(b"abcd" in pickled[-15:])
+ finally:
+ pickled = None
+ finally:
+ data = None
+
+ @bigmemtest(size=_4G, memuse=1 + 1, dry_run=False)
+ def test_huge_bytes_64b(self, size):
+ data = b"a" * size
+ try:
+ for proto in protocols:
+ if proto < 3:
+ continue
+ with self.assertRaises((ValueError, OverflowError)):
+ self.dumps(data, protocol=proto)
+ finally:
+ data = None
+
+ # All protocols use 1-byte per printable ASCII character; we add another
+ # byte because the encoded form has to be copied into the internal buffer.
+
+ @bigmemtest(size=_2G, memuse=2 + character_size, dry_run=False)
+ def test_huge_str_32b(self, size):
+ data = "abcd" * (size // 4)
+ try:
+ for proto in protocols:
+ try:
+ pickled = self.dumps(data, protocol=proto)
+ self.assertTrue(b"abcd" in pickled[:15])
+ self.assertTrue(b"abcd" in pickled[-15:])
+ finally:
+ pickled = None
+ finally:
+ data = None
+
+ # BINUNICODE (protocols 1, 2 and 3) cannot carry more than
+ # 2**32 - 1 bytes of utf-8 encoded unicode.
+
+ @bigmemtest(size=_4G, memuse=1 + character_size, dry_run=False)
+ def test_huge_str_64b(self, size):
+ data = "a" * size
+ try:
+ for proto in protocols:
+ if proto == 0:
+ continue
+ with self.assertRaises((ValueError, OverflowError)):
+ self.dumps(data, protocol=proto)
+ finally:
+ data = None
+
# Test classes for reduce_ex
@@ -1009,7 +1269,7 @@ class REX_three(object):
self._proto = proto
return REX_two, ()
def __reduce__(self):
- raise TestFailed, "This __reduce__ shouldn't be called"
+ raise TestFailed("This __reduce__ shouldn't be called")
class REX_four(object):
_proto = None
@@ -1030,9 +1290,6 @@ class REX_five(object):
class MyInt(int):
sample = 1
-class MyLong(long):
- sample = 1L
-
class MyFloat(float):
sample = 1.0
@@ -1042,8 +1299,8 @@ class MyComplex(complex):
class MyStr(str):
sample = "hello"
-class MyUnicode(unicode):
- sample = u"hello \u1234"
+class MyUnicode(str):
+ sample = "hello \u1234"
class MyTuple(tuple):
sample = (1, 2, 3)
@@ -1054,7 +1311,7 @@ class MyList(list):
class MyDict(dict):
sample = {"a": 1, "b": 2}
-myclasses = [MyInt, MyLong, MyFloat,
+myclasses = [MyInt, MyFloat,
MyComplex,
MyStr, MyUnicode,
MyTuple, MyList, MyDict]
@@ -1068,70 +1325,70 @@ class SimpleNewObj(object):
# raise an error, to make sure this isn't called
raise TypeError("SimpleNewObj.__init__() didn't expect to get called")
+class BadGetattr:
+ def __getattr__(self, key):
+ self.foo
+
+
class AbstractPickleModuleTests(unittest.TestCase):
def test_dump_closed_file(self):
import os
- f = open(TESTFN, "w")
+ f = open(TESTFN, "wb")
try:
f.close()
- self.assertRaises(ValueError, self.module.dump, 123, f)
+ self.assertRaises(ValueError, pickle.dump, 123, f)
finally:
os.remove(TESTFN)
def test_load_closed_file(self):
import os
- f = open(TESTFN, "w")
+ f = open(TESTFN, "wb")
try:
f.close()
- self.assertRaises(ValueError, self.module.dump, 123, f)
+ self.assertRaises(ValueError, pickle.dump, 123, f)
finally:
os.remove(TESTFN)
def test_load_from_and_dump_to_file(self):
- stream = cStringIO.StringIO()
+ stream = io.BytesIO()
data = [123, {}, 124]
- self.module.dump(data, stream)
+ pickle.dump(data, stream)
stream.seek(0)
- unpickled = self.module.load(stream)
+ unpickled = pickle.load(stream)
self.assertEqual(unpickled, data)
def test_highest_protocol(self):
# Of course this needs to be changed when HIGHEST_PROTOCOL changes.
- self.assertEqual(self.module.HIGHEST_PROTOCOL, 2)
+ self.assertEqual(pickle.HIGHEST_PROTOCOL, 3)
def test_callapi(self):
- f = cStringIO.StringIO()
+ f = io.BytesIO()
# With and without keyword arguments
- self.module.dump(123, f, -1)
- self.module.dump(123, file=f, protocol=-1)
- self.module.dumps(123, -1)
- self.module.dumps(123, protocol=-1)
- self.module.Pickler(f, -1)
- self.module.Pickler(f, protocol=-1)
-
- def test_incomplete_input(self):
- s = StringIO.StringIO("X''.")
- self.assertRaises(EOFError, self.module.load, s)
-
- def test_restricted(self):
- # issue7128: cPickle failed in restricted mode
- builtins = {self.module.__name__: self.module,
- '__import__': __import__}
- d = {}
- teststr = "def f(): {0}.dumps(0)".format(self.module.__name__)
- exec teststr in {'__builtins__': builtins}, d
- d['f']()
+ pickle.dump(123, f, -1)
+ pickle.dump(123, file=f, protocol=-1)
+ pickle.dumps(123, -1)
+ pickle.dumps(123, protocol=-1)
+ pickle.Pickler(f, -1)
+ pickle.Pickler(f, protocol=-1)
+
+ def test_bad_init(self):
+ # Test issue3664 (pickle can segfault from a badly initialized Pickler).
+ # Override initialization without calling __init__() of the superclass.
+ class BadPickler(pickle.Pickler):
+ def __init__(self): pass
+
+ class BadUnpickler(pickle.Unpickler):
+ def __init__(self): pass
+
+ self.assertRaises(pickle.PicklingError, BadPickler().dump, 0)
+ self.assertRaises(pickle.UnpicklingError, BadUnpickler().load)
def test_bad_input(self):
# Test issue4298
- s = '\x58\0\0\0\x54'
- self.assertRaises(EOFError, self.module.loads, s)
- # Test issue7455
- s = '0'
- # XXX Why doesn't pickle raise UnpicklingError?
- self.assertRaises((IndexError, cPickle.UnpicklingError),
- self.module.loads, s)
+ s = bytes([0x58, 0, 0, 0, 0x54])
+ self.assertRaises(EOFError, pickle.loads, s)
+
class AbstractPersistentPicklerTests(unittest.TestCase):
@@ -1155,7 +1412,7 @@ class AbstractPersistentPicklerTests(unittest.TestCase):
def test_persistence(self):
self.id_count = 0
self.load_count = 0
- L = range(10)
+ L = list(range(10))
self.assertEqual(self.loads(self.dumps(L)), L)
self.assertEqual(self.id_count, 5)
self.assertEqual(self.load_count, 5)
@@ -1163,11 +1420,12 @@ class AbstractPersistentPicklerTests(unittest.TestCase):
def test_bin_persistence(self):
self.id_count = 0
self.load_count = 0
- L = range(10)
+ L = list(range(10))
self.assertEqual(self.loads(self.dumps(L, 1)), L)
self.assertEqual(self.id_count, 5)
self.assertEqual(self.load_count, 5)
+
class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
pickler_class = None
@@ -1184,7 +1442,7 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
# object again, the third serialized form should be identical to the
# first one we obtained.
data = ["abcdefg", "abcdefg", 44]
- f = cStringIO.StringIO()
+ f = io.BytesIO()
pickler = self.pickler_class(f)
pickler.dump(data)
@@ -1211,13 +1469,13 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
def test_priming_pickler_memo(self):
# Verify that we can set the Pickler's memo attribute.
data = ["abcdefg", "abcdefg", 44]
- f = cStringIO.StringIO()
+ f = io.BytesIO()
pickler = self.pickler_class(f)
pickler.dump(data)
first_pickled = f.getvalue()
- f = cStringIO.StringIO()
+ f = io.BytesIO()
primed = self.pickler_class(f)
primed.memo = pickler.memo
@@ -1229,25 +1487,25 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
def test_priming_unpickler_memo(self):
# Verify that we can set the Unpickler's memo attribute.
data = ["abcdefg", "abcdefg", 44]
- f = cStringIO.StringIO()
+ f = io.BytesIO()
pickler = self.pickler_class(f)
pickler.dump(data)
first_pickled = f.getvalue()
- f = cStringIO.StringIO()
+ f = io.BytesIO()
primed = self.pickler_class(f)
primed.memo = pickler.memo
primed.dump(data)
primed_pickled = f.getvalue()
- unpickler = self.unpickler_class(cStringIO.StringIO(first_pickled))
+ unpickler = self.unpickler_class(io.BytesIO(first_pickled))
unpickled_data1 = unpickler.load()
self.assertEqual(unpickled_data1, data)
- primed = self.unpickler_class(cStringIO.StringIO(primed_pickled))
+ primed = self.unpickler_class(io.BytesIO(primed_pickled))
primed.memo = unpickler.memo
unpickled_data2 = primed.load()
@@ -1258,18 +1516,18 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
def test_reusing_unpickler_objects(self):
data1 = ["abcdefg", "abcdefg", 44]
- f = cStringIO.StringIO()
+ f = io.BytesIO()
pickler = self.pickler_class(f)
pickler.dump(data1)
pickled1 = f.getvalue()
data2 = ["abcdefg", 44, 44]
- f = cStringIO.StringIO()
+ f = io.BytesIO()
pickler = self.pickler_class(f)
pickler.dump(data2)
pickled2 = f.getvalue()
- f = cStringIO.StringIO()
+ f = io.BytesIO()
f.write(pickled1)
f.seek(0)
unpickler = self.unpickler_class(f)
@@ -1280,3 +1538,60 @@ class AbstractPicklerUnpicklerObjectTests(unittest.TestCase):
f.write(pickled2)
f.seek(0)
self.assertEqual(unpickler.load(), data2)
+
+ def _check_multiple_unpicklings(self, ioclass):
+ for proto in protocols:
+ data1 = [(x, str(x)) for x in range(2000)] + [b"abcde", len]
+ f = ioclass()
+ pickler = self.pickler_class(f, protocol=proto)
+ pickler.dump(data1)
+ pickled = f.getvalue()
+
+ N = 5
+ f = ioclass(pickled * N)
+ unpickler = self.unpickler_class(f)
+ for i in range(N):
+ if f.seekable():
+ pos = f.tell()
+ self.assertEqual(unpickler.load(), data1)
+ if f.seekable():
+ self.assertEqual(f.tell(), pos + len(pickled))
+ self.assertRaises(EOFError, unpickler.load)
+
+ def test_multiple_unpicklings_seekable(self):
+ self._check_multiple_unpicklings(io.BytesIO)
+
+ def test_multiple_unpicklings_unseekable(self):
+ self._check_multiple_unpicklings(UnseekableIO)
+
+ def test_unpickling_buffering_readline(self):
+ # Issue #12687: the unpickler's buffering logic could fail with
+ # text mode opcodes.
+ data = list(range(10))
+ for proto in protocols:
+ for buf_size in range(1, 11):
+ f = io.BufferedRandom(io.BytesIO(), buffer_size=buf_size)
+ pickler = self.pickler_class(f, protocol=proto)
+ pickler.dump(data)
+ f.seek(0)
+ unpickler = self.unpickler_class(f)
+ self.assertEqual(unpickler.load(), data)
+
+
+if __name__ == "__main__":
+ # Print some stuff that can be used to rewrite DATA{0,1,2}
+ from pickletools import dis
+ x = create_data()
+ for i in range(3):
+ p = pickle.dumps(x, i)
+ print("DATA{0} = (".format(i))
+ for j in range(0, len(p), 20):
+ b = bytes(p[j:j+20])
+ print(" {0!r}".format(b))
+ print(")")
+ print()
+ print("# Disassembly of DATA{0}".format(i))
+ print("DATA{0}_DIS = \"\"\"\\".format(i))
+ dis(p)
+ print("\"\"\"")
+ print()
diff --git a/Lib/test/pstats.pck b/Lib/test/pstats.pck
new file mode 100644
index 00000000000..c48ccb73a9f
--- /dev/null
+++ b/Lib/test/pstats.pck
Binary files differ
diff --git a/Lib/test/pydoc_mod.py b/Lib/test/pydoc_mod.py
index 9c53324a6d5..f86b5c621e3 100644
--- a/Lib/test/pydoc_mod.py
+++ b/Lib/test/pydoc_mod.py
@@ -3,7 +3,7 @@
__author__ = "Benjamin Peterson"
__credits__ = "Nobody"
__version__ = "1.2.3.4"
-
+__xyz__ = "X, Y and Z"
class A:
"""Hello and goodbye"""
diff --git a/Lib/test/pydocfodder.py b/Lib/test/pydocfodder.py
index 2cf1cbdc048..2530320a222 100644
--- a/Lib/test/pydocfodder.py
+++ b/Lib/test/pydocfodder.py
@@ -194,19 +194,19 @@ class FunkyProperties(object):
def __init__(self, attr):
self.attr = attr
def __call__(self, inst):
- print 'Get called', self, inst
+ print('Get called', self, inst)
return inst.desc[self.attr]
class set_desc:
def __init__(self, attr):
self.attr = attr
def __call__(self, inst, val):
- print 'Set called', self, inst, val
+ print('Set called', self, inst, val)
inst.desc[self.attr] = val
class del_desc:
def __init__(self, attr):
self.attr = attr
def __call__(self, inst):
- print 'Del called', self, inst
+ print('Del called', self, inst)
del inst.desc[self.attr]
x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x')
diff --git a/Lib/test/pystone.py b/Lib/test/pystone.py
index c9892ff0758..d7f1ec9b6cc 100755
--- a/Lib/test/pystone.py
+++ b/Lib/test/pystone.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
"PYSTONE" Benchmark Program
@@ -59,9 +59,9 @@ FALSE = 0
def main(loops=LOOPS):
benchtime, stones = pystones(loops)
- print "Pystone(%s) time for %d passes = %g" % \
- (__version__, loops, benchtime)
- print "This machine benchmarks at %g pystones/second" % stones
+ print("Pystone(%s) time for %d passes = %g" % \
+ (__version__, loops, benchtime))
+ print("This machine benchmarks at %g pystones/second" % stones)
def pystones(loops=LOOPS):
@@ -72,7 +72,7 @@ BoolGlob = FALSE
Char1Glob = '\0'
Char2Glob = '\0'
Array1Glob = [0]*51
-Array2Glob = map(lambda x: x[:], [Array1Glob]*51)
+Array2Glob = [x[:] for x in [Array1Glob]*51]
PtrGlb = None
PtrGlbNext = None
@@ -255,8 +255,8 @@ def Func3(EnumParIn):
if __name__ == '__main__':
import sys
def error(msg):
- print >>sys.stderr, msg,
- print >>sys.stderr, "usage: %s [number_of_loops]" % sys.argv[0]
+ print(msg, end=' ', file=sys.stderr)
+ print("usage: %s [number_of_loops]" % sys.argv[0], file=sys.stderr)
sys.exit(100)
nargs = len(sys.argv) - 1
if nargs > 1:
diff --git a/Lib/test/re_tests.py b/Lib/test/re_tests.py
index 25b1229d637..5d16e3d183c 100755
--- a/Lib/test/re_tests.py
+++ b/Lib/test/re_tests.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# -*- mode: python -*-
# Re test suite and benchmark suite v1.5
@@ -661,14 +661,10 @@ xyzabc
('^([ab]*?)(?<!(a))c', 'abc', SUCCEED, 'g1+"-"+g2', 'ab-None'),
]
-try:
- u = eval("u'\N{LATIN CAPITAL LETTER A WITH DIAERESIS}'")
-except SyntaxError:
- pass
-else:
- tests.extend([
+u = '\N{LATIN CAPITAL LETTER A WITH DIAERESIS}'
+tests.extend([
# bug 410271: \b broken under locales
(r'\b.\b', 'a', SUCCEED, 'found', 'a'),
(r'(?u)\b.\b', u, SUCCEED, 'found', u),
(r'(?u)\w', u, SUCCEED, 'found', u),
- ])
+])
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index dd47cc36e01..84beb8dee5c 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1,9 +1,9 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""
Usage:
-python -m test.regrtest [options] [test_name1 [test_name2 ...]]
+python -m test [options] [test_name1 [test_name2 ...]]
python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
@@ -14,7 +14,7 @@ them in alphabetical order (but see -M and -u, below, for exceptions).
For more rigorous testing, it is useful to use the following
command line:
-python -E -tt -Wd -3 -m test.regrtest [options] [test_name1 ...]
+python -E -Wd -m test [options] [test_name1 ...]
Options:
@@ -25,9 +25,10 @@ Verbosity
-v/--verbose -- run tests in verbose mode with output to stdout
-w/--verbose2 -- re-run failed tests in verbose mode
--W/--verbose3 -- re-run failed tests in verbose mode immediately
+-W/--verbose3 -- display test output on failure
+-d/--debug -- print traceback for failed tests
-q/--quiet -- no output unless one or more tests fail
--S/--slow -- print the slowest 10 tests
+-o/--slow -- print the slowest 10 tests
--header -- print header with interpreter info
Selecting tests
@@ -37,6 +38,8 @@ Selecting tests
-f/--fromfile -- read names of tests to run from a file (see below)
-x/--exclude -- arguments are tests to *exclude*
-s/--single -- single step through a set of tests (see below)
+-m/--match PAT -- match test cases and methods with glob pattern PAT
+-G/--failfast -- fail as soon as a test fails (only with -v or -W)
-u/--use RES1,RES2,...
-- specify which special resource intensive tests to run
-M/--memlimit LIMIT
@@ -56,6 +59,7 @@ Special runs
-N/--nocoverdir -- Put coverage files alongside modules
-t/--threshold THRESHOLD
-- call gc.set_threshold(THRESHOLD)
+-n/--nowindows -- suppress error message boxes on Windows
-F/--forever -- run the specified tests in a loop, until an error happens
@@ -76,6 +80,12 @@ is possible to single step through the test files. This is useful when
doing memory analysis on the Python interpreter, which process tends to
consume too many resources to run the full regression test non-stop.
+-S is used to continue running tests after an aborted run. It will
+maintain the order a standard run (ie, this assumes -r is not used).
+This is useful after the tests have prematurely stopped for some external
+reason and you want to start running from where you left off rather
+than starting from the beginning.
+
-f reads the names of tests from the file given as f's argument, one
or more test names per line. Whitespace is ignored. Blank lines and
lines beginning with '#' are ignored. This is especially useful for
@@ -129,9 +139,6 @@ resources to test. Currently only the following are defined:
network - It is okay to run tests that use external network
resource, e.g. testing SSL support for sockets.
- bsddb - It is okay to run the bsddb testsuite, which takes
- a long time to complete.
-
decimal - Test the decimal module against a large suite that
verifies compliance with standards.
@@ -143,30 +150,39 @@ resources to test. Currently only the following are defined:
gui - Run tests that require a running GUI.
- xpickle - Test pickle and cPickle against Python 2.4, 2.5 and 2.6 to
- test backwards compatibility. These tests take a long time
- to run.
-
To enable all resources except one, use '-uall,-<resource>'. For
-example, to run all the tests except for the bsddb tests, give the
-option '-uall,-bsddb'.
+example, to run all the tests except for the gui tests, give the
+option '-uall,-gui'.
"""
-import StringIO
+import builtins
+import errno
import getopt
+import io
import json
+import logging
import os
+import platform
import random
import re
+import shutil
import sys
+import sysconfig
+import tempfile
import time
import traceback
-import warnings
import unittest
-import tempfile
-import imp
-import platform
-import sysconfig
+import warnings
+from inspect import isabstract
+
+try:
+ import threading
+except ImportError:
+ threading = None
+try:
+ import multiprocessing.process
+except ImportError:
+ multiprocessing = None
# Some times __path__ and __file__ are not absolute (e.g. while running from
@@ -179,7 +195,7 @@ import sysconfig
# (site.py absolutize them), the __file__ and __path__ will be absolute too.
# Therefore it is necessary to absolutize manually the __file__ and __path__ of
# the packages to prevent later imports to fail when the CWD is different.
-for module in sys.modules.itervalues():
+for module in sys.modules.values():
if hasattr(module, '__path__'):
module.__path__ = [os.path.abspath(path) for path in module.__path__]
if hasattr(module, '__file__'):
@@ -210,19 +226,17 @@ SKIPPED = -2
RESOURCE_DENIED = -3
INTERRUPTED = -4
-from test import test_support
+from test import support
-RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
- 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui',
- 'xpickle')
+RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network',
+ 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui')
TEMPDIR = os.path.abspath(tempfile.gettempdir())
-
-def usage(code, msg=''):
- print __doc__
- if msg: print msg
- sys.exit(code)
+def usage(msg):
+ print(msg, file=sys.stderr)
+ print("Use --help for usage", file=sys.stderr)
+ sys.exit(2)
def main(tests=None, testdir=None, verbose=0, quiet=False,
@@ -230,7 +244,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
findleaks=False, use_resources=None, trace=False, coverdir='coverage',
runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
random_seed=None, use_mp=None, verbose3=False, forever=False,
- header=False):
+ header=False, failfast=False, match_tests=None):
"""Execute a test suite.
This also parses command-line options and modifies its behavior
@@ -254,39 +268,51 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
on the command line.
"""
- test_support.record_original_stdout(sys.stdout)
+ replace_stdout()
+
+ support.record_original_stdout(sys.stdout)
try:
- opts, args = getopt.getopt(sys.argv[1:], 'hvqxsSrf:lu:t:TD:NLR:FwWM:j:',
+ opts, args = getopt.getopt(sys.argv[1:], 'hvqxsoS:rf:lu:t:TD:NLR:FdwWM:nj:Gm:',
['help', 'verbose', 'verbose2', 'verbose3', 'quiet',
'exclude', 'single', 'slow', 'randomize', 'fromfile=', 'findleaks',
- 'use=', 'threshold=', 'trace', 'coverdir=', 'nocoverdir',
+ 'use=', 'threshold=', 'coverdir=', 'nocoverdir',
'runleaks', 'huntrleaks=', 'memlimit=', 'randseed=',
- 'multiprocess=', 'slaveargs=', 'forever', 'header'])
- except getopt.error, msg:
- usage(2, msg)
+ 'multiprocess=', 'coverage', 'slaveargs=', 'forever', 'debug',
+ 'start=', 'nowindows', 'header', 'failfast', 'match='])
+ except getopt.error as msg:
+ usage(msg)
# Defaults
if random_seed is None:
random_seed = random.randrange(10000000)
if use_resources is None:
use_resources = []
+ debug = False
+ start = None
for o, a in opts:
if o in ('-h', '--help'):
- usage(0)
+ print(__doc__)
+ return
elif o in ('-v', '--verbose'):
verbose += 1
elif o in ('-w', '--verbose2'):
verbose2 = True
+ elif o in ('-d', '--debug'):
+ debug = True
elif o in ('-W', '--verbose3'):
verbose3 = True
+ elif o in ('-G', '--failfast'):
+ failfast = True
elif o in ('-q', '--quiet'):
quiet = True;
verbose = 0
elif o in ('-x', '--exclude'):
exclude = True
+ elif o in ('-S', '--start'):
+ start = a
elif o in ('-s', '--single'):
single = True
- elif o in ('-S', '--slow'):
+ elif o in ('-o', '--slow'):
print_slow = True
elif o in ('-r', '--randomize'):
randomize = True
@@ -294,6 +320,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
random_seed = int(a)
elif o in ('-f', '--fromfile'):
fromfile = a
+ elif o in ('-m', '--match'):
+ match_tests = a
elif o in ('-l', '--findleaks'):
findleaks = True
elif o in ('-L', '--runleaks'):
@@ -310,8 +338,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
elif o in ('-R', '--huntrleaks'):
huntrleaks = a.split(':')
if len(huntrleaks) not in (2, 3):
- print a, huntrleaks
- usage(2, '-R takes 2 or 3 colon-separated arguments')
+ print(a, huntrleaks)
+ usage('-R takes 2 or 3 colon-separated arguments')
if not huntrleaks[0]:
huntrleaks[0] = 5
else:
@@ -322,8 +350,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
huntrleaks[1] = int(huntrleaks[1])
if len(huntrleaks) == 2 or not huntrleaks[2]:
huntrleaks[2:] = ["reflog.txt"]
+ # Avoid false positives due to the character cache in
+ # stringobject.c filling slowly with random data
+ warm_char_cache()
elif o in ('-M', '--memlimit'):
- test_support.set_memlimit(a)
+ support.set_memlimit(a)
elif o in ('-u', '--use'):
u = [x.lower() for x in a.split(',')]
for r in u:
@@ -335,12 +366,27 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
remove = True
r = r[1:]
if r not in RESOURCE_NAMES:
- usage(1, 'Invalid -u/--use option: ' + a)
+ usage('Invalid -u/--use option: ' + a)
if remove:
if r in use_resources:
use_resources.remove(r)
elif r not in use_resources:
use_resources.append(r)
+ elif o in ('-n', '--nowindows'):
+ import msvcrt
+ msvcrt.SetErrorMode(msvcrt.SEM_FAILCRITICALERRORS|
+ msvcrt.SEM_NOALIGNMENTFAULTEXCEPT|
+ msvcrt.SEM_NOGPFAULTERRORBOX|
+ msvcrt.SEM_NOOPENFILEERRORBOX)
+ try:
+ msvcrt.CrtSetReportMode
+ except AttributeError:
+ # release build
+ pass
+ else:
+ for m in [msvcrt.CRT_WARN, msvcrt.CRT_ERROR, msvcrt.CRT_ASSERT]:
+ msvcrt.CrtSetReportMode(m, msvcrt.CRTDBG_MODE_FILE)
+ msvcrt.CrtSetReportFile(m, msvcrt.CRTDBG_FILE_STDERR)
elif o in ('-F', '--forever'):
forever = True
elif o in ('-j', '--multiprocess'):
@@ -351,21 +397,26 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
args, kwargs = json.loads(a)
try:
result = runtest(*args, **kwargs)
- except BaseException, e:
+ except BaseException as e:
result = INTERRUPTED, e.__class__.__name__
- print # Force a newline (just in case)
- print json.dumps(result)
+ sys.stdout.flush()
+ print() # Force a newline (just in case)
+ print(json.dumps(result))
sys.exit(0)
else:
- print >>sys.stderr, ("No handler for option {}. Please "
- "report this as a bug at http://bugs.python.org.").format(o)
+ print(("No handler for option {}. Please report this as a bug "
+ "at http://bugs.python.org.").format(o), file=sys.stderr)
sys.exit(1)
if single and fromfile:
- usage(2, "-s and -f don't go together!")
+ usage("-s and -f don't go together!")
if use_mp and trace:
- usage(2, "-T and -j don't go together!")
+ usage("-T and -j don't go together!")
if use_mp and findleaks:
- usage(2, "-l and -j don't go together!")
+ usage("-l and -j don't go together!")
+ if use_mp and support.max_memuse:
+ usage("-M and -j don't go together!")
+ if failfast and not (verbose or verbose3):
+ usage("-G/--failfast needs either -v or -W")
good = []
bad = []
@@ -378,7 +429,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
try:
import gc
except ImportError:
- print 'No GC available, disabling findleaks.'
+ print('No GC available, disabling findleaks.')
findleaks = False
else:
# Uncomment the line below to report garbage that is not
@@ -399,8 +450,10 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if fromfile:
tests = []
- fp = open(os.path.join(test_support.SAVEDCWD, fromfile))
+ fp = open(os.path.join(support.SAVEDCWD, fromfile))
+ count_pat = re.compile(r'\[\s*\d+/\s*\d+\]')
for line in fp:
+ line = count_pat.sub('', line)
guts = line.split() # assuming no test has whitespace in its name
if guts and not guts[0].startswith('#'):
tests.extend(guts)
@@ -422,12 +475,11 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
# For a partial run, we do not need to clutter the output.
if verbose or header or not (quiet or single or tests or args):
# Print basic platform information
- print "==", platform.python_implementation(), \
- " ".join(sys.version.split())
- print "== ", platform.platform(aliased=True), \
- "%s-endian" % sys.byteorder
- print "== ", os.getcwd()
- print "Testing with flags:", sys.flags
+ print("==", platform.python_implementation(), *sys.version.split())
+ print("== ", platform.platform(aliased=True),
+ "%s-endian" % sys.byteorder)
+ print("== ", os.getcwd())
+ print("Testing with flags:", sys.flags)
alltests = findtests(testdir, stdtests, nottests)
selected = tests or args or alltests
@@ -437,17 +489,25 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
next_single_test = alltests[alltests.index(selected[0])+1]
except IndexError:
next_single_test = None
+ # Remove all the selected tests that precede start if it's set.
+ if start:
+ try:
+ del selected[:selected.index(start)]
+ except ValueError:
+ print("Couldn't find starting test (%s), using all tests" % start)
if randomize:
random.seed(random_seed)
- print "Using random seed", random_seed
+ print("Using random seed", random_seed)
random.shuffle(selected)
if trace:
- import trace
- tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+ import trace, tempfile
+ tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,
+ tempfile.gettempdir()],
trace=False, count=True)
test_times = []
- test_support.use_resources = use_resources
+ support.verbose = verbose # Tell tests to be moderately quiet
+ support.use_resources = use_resources
save_modules = sys.modules.keys()
def accumulate_result(test, result):
@@ -458,7 +518,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
elif ok == FAILED:
bad.append(test)
elif ok == ENV_CHANGED:
- bad.append(test)
environment_changed.append(test)
elif ok == SKIPPED:
skipped.append(test)
@@ -474,43 +533,50 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if bad:
return
tests = test_forever()
+ test_count = ''
+ test_count_width = 3
else:
tests = iter(selected)
+ test_count = '/{}'.format(len(selected))
+ test_count_width = len(test_count) - 1
if use_mp:
try:
from threading import Thread
except ImportError:
- print "Multiprocess option requires thread support"
+ print("Multiprocess option requires thread support")
sys.exit(2)
- from Queue import Queue
+ from queue import Queue
from subprocess import Popen, PIPE
debug_output_pat = re.compile(r"\[\d+ refs\]$")
output = Queue()
- def tests_and_args():
- for test in tests:
- args_tuple = (
- (test, verbose, quiet),
- dict(huntrleaks=huntrleaks, use_resources=use_resources)
- )
- yield (test, args_tuple)
- pending = tests_and_args()
- opt_args = test_support.args_from_interpreter_flags()
+ pending = MultiprocessTests(tests)
+ opt_args = support.args_from_interpreter_flags()
base_cmd = [sys.executable] + opt_args + ['-m', 'test.regrtest']
def work():
# A worker thread.
try:
while True:
try:
- test, args_tuple = next(pending)
+ test = next(pending)
except StopIteration:
output.put((None, None, None, None))
return
+ args_tuple = (
+ (test, verbose, quiet),
+ dict(huntrleaks=huntrleaks, use_resources=use_resources,
+ debug=debug, output_on_failure=verbose3,
+ failfast=failfast, match_tests=match_tests)
+ )
# -E is needed by some tests, e.g. test_import
+ # Running the child from the same working directory ensures
+ # that TEMPDIR for the child is the same when
+ # sysconfig.is_python_build() is true. See issue 15300.
popen = Popen(base_cmd + ['--slaveargs', json.dumps(args_tuple)],
stdout=PIPE, stderr=PIPE,
universal_newlines=True,
- close_fds=(os.name != 'nt'))
+ close_fds=(os.name != 'nt'),
+ cwd=support.SAVEDCWD)
stdout, stderr = popen.communicate()
# Strip last refcount output line if it exists, since it
# comes from the shutdown of the interpreter in the subcommand.
@@ -520,8 +586,6 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
output.put((None, None, None, None))
return
result = json.loads(result)
- if not quiet:
- stdout = test+'\n'+stdout
output.put((test, stdout.rstrip(), stderr.rstrip(), result))
except BaseException:
output.put((None, None, None, None))
@@ -530,31 +594,40 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
for worker in workers:
worker.start()
finished = 0
+ test_index = 1
try:
while finished < use_mp:
test, stdout, stderr, result = output.get()
if test is None:
finished += 1
continue
+ accumulate_result(test, result)
+ if not quiet:
+ fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}"
+ print(fmt.format(
+ test_count_width, test_index, test_count,
+ len(bad), test))
if stdout:
- print stdout
+ print(stdout)
if stderr:
- print >>sys.stderr, stderr
+ print(stderr, file=sys.stderr)
sys.stdout.flush()
sys.stderr.flush()
if result[0] == INTERRUPTED:
assert result[1] == 'KeyboardInterrupt'
raise KeyboardInterrupt # What else?
- accumulate_result(test, result)
+ test_index += 1
except KeyboardInterrupt:
interrupted = True
- pending.close()
+ pending.interrupted = True
for worker in workers:
worker.join()
else:
- for test in tests:
+ for test_index, test in enumerate(tests, 1):
if not quiet:
- print test
+ fmt = "[{1:{0}}{2}/{3}] {4}" if bad else "[{1:{0}}{2}] {4}"
+ print(fmt.format(
+ test_count_width, test_index, test_count, len(bad), test))
sys.stdout.flush()
if trace:
# If we're tracing code coverage, then we don't exit with status
@@ -563,11 +636,10 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
globals=globals(), locals=vars())
else:
try:
- result = runtest(test, verbose, quiet, huntrleaks)
+ result = runtest(test, verbose, quiet, huntrleaks, debug,
+ output_on_failure=verbose3,
+ failfast=failfast, match_tests=match_tests)
accumulate_result(test, result)
- if verbose3 and result[0] == FAILED:
- print "Re-running test %r in verbose mode" % test
- runtest(test, True, quiet, huntrleaks)
except KeyboardInterrupt:
interrupted = True
break
@@ -576,8 +648,8 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if findleaks:
gc.collect()
if gc.garbage:
- print "Warning: test created", len(gc.garbage),
- print "uncollectable object(s)."
+ print("Warning: test created", len(gc.garbage), end=' ')
+ print("uncollectable object(s).")
# move the uncollectable objects somewhere so we don't see
# them again
found_garbage.extend(gc.garbage)
@@ -585,35 +657,35 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
# Unload the newly imported modules (best effort finalization)
for module in sys.modules.keys():
if module not in save_modules and module.startswith("test."):
- test_support.unload(module)
+ support.unload(module)
if interrupted:
# print a newline after ^C
- print
- print "Test suite interrupted by signal SIGINT."
+ print()
+ print("Test suite interrupted by signal SIGINT.")
omitted = set(selected) - set(good) - set(bad) - set(skipped)
- print count(len(omitted), "test"), "omitted:"
+ print(count(len(omitted), "test"), "omitted:")
printlist(omitted)
if good and not quiet:
if not bad and not skipped and not interrupted and len(good) > 1:
- print "All",
- print count(len(good), "test"), "OK."
+ print("All", end=' ')
+ print(count(len(good), "test"), "OK.")
if print_slow:
test_times.sort(reverse=True)
- print "10 slowest tests:"
+ print("10 slowest tests:")
for time, test in test_times[:10]:
- print "%s: %.1fs" % (test, time)
+ print("%s: %.1fs" % (test, time))
if bad:
- bad = set(bad) - set(environment_changed)
+ bad = sorted(set(bad) - set(environment_changed))
if bad:
- print count(len(bad), "test"), "failed:"
+ print(count(len(bad), "test"), "failed:")
printlist(bad)
- if environment_changed:
- print "{} altered the execution environment:".format(
- count(len(environment_changed), "test"))
- printlist(environment_changed)
+ if environment_changed:
+ print("{} altered the execution environment:".format(
+ count(len(environment_changed), "test")))
+ printlist(environment_changed)
if skipped and not quiet:
- print count(len(skipped), "test"), "skipped:"
+ print(count(len(skipped), "test"), "skipped:")
printlist(skipped)
e = _ExpectedSkips()
@@ -621,26 +693,26 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
if e.isvalid():
surprise = set(skipped) - e.getexpected() - set(resource_denieds)
if surprise:
- print count(len(surprise), "skip"), \
- "unexpected on", plat + ":"
+ print(count(len(surprise), "skip"), \
+ "unexpected on", plat + ":")
printlist(surprise)
else:
- print "Those skips are all expected on", plat + "."
+ print("Those skips are all expected on", plat + ".")
else:
- print "Ask someone to teach regrtest.py about which tests are"
- print "expected to get skipped on", plat + "."
+ print("Ask someone to teach regrtest.py about which tests are")
+ print("expected to get skipped on", plat + ".")
if verbose2 and bad:
- print "Re-running failed tests in verbose mode"
+ print("Re-running failed tests in verbose mode")
for test in bad:
- print "Re-running test %r in verbose mode" % test
+ print("Re-running test %r in verbose mode" % test)
sys.stdout.flush()
try:
- test_support.verbose = True
- ok = runtest(test, True, quiet, huntrleaks)
+ verbose = True
+ ok = runtest(test, True, quiet, huntrleaks, debug)
except KeyboardInterrupt:
# print a newline separate from the ^C
- print
+ print()
break
except:
raise
@@ -675,7 +747,6 @@ STDTESTS = [
]
NOTTESTS = {
- 'test_support',
'test_future1',
'test_future2',
}
@@ -692,8 +763,48 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS):
tests.append(modname)
return stdtests + sorted(tests)
+# We do not use a generator so multiple threads can call next().
+class MultiprocessTests(object):
+
+ """A thread-safe iterator over tests for multiprocess mode."""
+
+ def __init__(self, tests):
+ self.interrupted = False
+ self.lock = threading.Lock()
+ self.tests = tests
+
+ def __iter__(self):
+ return self
+
+ def __next__(self):
+ with self.lock:
+ if self.interrupted:
+ raise StopIteration('tests interrupted')
+ return next(self.tests)
+
+def replace_stdout():
+ """Set stdout encoder error handler to backslashreplace (as stderr error
+ handler) to avoid UnicodeEncodeError when printing a traceback"""
+ if os.name == "nt":
+ # Replace sys.stdout breaks the stdout newlines on Windows: issue #8533
+ return
+
+ import atexit
+
+ stdout = sys.stdout
+ sys.stdout = open(stdout.fileno(), 'w',
+ encoding=stdout.encoding,
+ errors="backslashreplace",
+ closefd=False)
+
+ def restore_stdout():
+ sys.stdout.close()
+ sys.stdout = stdout
+ atexit.register(restore_stdout)
+
def runtest(test, verbose, quiet,
- huntrleaks=False, use_resources=None):
+ huntrleaks=False, debug=False, use_resources=None,
+ output_on_failure=False, failfast=False, match_tests=None):
"""Run a single test.
test -- the name of the test
@@ -702,6 +813,8 @@ def runtest(test, verbose, quiet,
test_times -- a list of (time, test_name) pairs
huntrleaks -- run multiple times to test for leaks; requires a debug
build; a triple corresponding to -R's three arguments
+ output_on_failure -- if true, display test output on failure
+
Returns one of the test result constants:
INTERRUPTED KeyboardInterrupt when run under -j
RESOURCE_DENIED test skipped because resource denied
@@ -711,14 +824,48 @@ def runtest(test, verbose, quiet,
PASSED test passed
"""
- test_support.verbose = verbose # Tell tests to be moderately quiet
if use_resources is not None:
- test_support.use_resources = use_resources
+ support.use_resources = use_resources
try:
- return runtest_inner(test, verbose, quiet, huntrleaks)
+ support.match_tests = match_tests
+ if failfast:
+ support.failfast = True
+ if output_on_failure:
+ support.verbose = True
+
+ # Reuse the same instance to all calls to runtest(). Some
+ # tests keep a reference to sys.stdout or sys.stderr
+ # (eg. test_argparse).
+ if runtest.stringio is None:
+ stream = io.StringIO()
+ runtest.stringio = stream
+ else:
+ stream = runtest.stringio
+ stream.seek(0)
+ stream.truncate()
+
+ orig_stdout = sys.stdout
+ orig_stderr = sys.stderr
+ try:
+ sys.stdout = stream
+ sys.stderr = stream
+ result = runtest_inner(test, verbose, quiet, huntrleaks,
+ debug, display_failure=False)
+ if result[0] == FAILED:
+ output = stream.getvalue()
+ orig_stderr.write(output)
+ orig_stderr.flush()
+ finally:
+ sys.stdout = orig_stdout
+ sys.stderr = orig_stderr
+ else:
+ support.verbose = verbose # Tell tests to be moderately quiet
+ result = runtest_inner(test, verbose, quiet, huntrleaks, debug,
+ display_failure=not verbose)
+ return result
finally:
cleanup_test_droppings(test, verbose)
-
+runtest.stringio = None
# Unit tests are supposed to leave the execution environment unchanged
# once they complete. But sometimes tests have bugs, especially when
@@ -760,8 +907,13 @@ class saved_test_environment:
# the corresponding method names.
resources = ('sys.argv', 'cwd', 'sys.stdin', 'sys.stdout', 'sys.stderr',
- 'os.environ', 'sys.path', 'asyncore.socket_map',
- 'test_support.TESTFN',
+ 'os.environ', 'sys.path', 'sys.path_hooks', '__import__',
+ 'warnings.filters', 'asyncore.socket_map',
+ 'logging._handlers', 'logging._handlerList',
+ 'shutil.archive_formats', 'shutil.unpack_formats',
+ 'sys.warnoptions', 'threading._dangling',
+ 'multiprocessing.process._dangling',
+ 'support.TESTFN',
)
def get_sys_argv(self):
@@ -803,6 +955,23 @@ class saved_test_environment:
sys.path = saved_path[1]
sys.path[:] = saved_path[2]
+ def get_sys_path_hooks(self):
+ return id(sys.path_hooks), sys.path_hooks, sys.path_hooks[:]
+ def restore_sys_path_hooks(self, saved_hooks):
+ sys.path_hooks = saved_hooks[1]
+ sys.path_hooks[:] = saved_hooks[2]
+
+ def get___import__(self):
+ return builtins.__import__
+ def restore___import__(self, import_):
+ builtins.__import__ = import_
+
+ def get_warnings_filters(self):
+ return id(warnings.filters), warnings.filters, warnings.filters[:]
+ def restore_warnings_filters(self, saved_filters):
+ warnings.filters = saved_filters[1]
+ warnings.filters[:] = saved_filters[2]
+
def get_asyncore_socket_map(self):
asyncore = sys.modules.get('asyncore')
# XXX Making a copy keeps objects alive until __exit__ gets called.
@@ -813,20 +982,82 @@ class saved_test_environment:
asyncore.close_all(ignore_all=True)
asyncore.socket_map.update(saved_map)
- def get_test_support_TESTFN(self):
- if os.path.isfile(test_support.TESTFN):
+ def get_shutil_archive_formats(self):
+ # we could call get_archives_formats() but that only returns the
+ # registry keys; we want to check the values too (the functions that
+ # are registered)
+ return shutil._ARCHIVE_FORMATS, shutil._ARCHIVE_FORMATS.copy()
+ def restore_shutil_archive_formats(self, saved):
+ shutil._ARCHIVE_FORMATS = saved[0]
+ shutil._ARCHIVE_FORMATS.clear()
+ shutil._ARCHIVE_FORMATS.update(saved[1])
+
+ def get_shutil_unpack_formats(self):
+ return shutil._UNPACK_FORMATS, shutil._UNPACK_FORMATS.copy()
+ def restore_shutil_unpack_formats(self, saved):
+ shutil._UNPACK_FORMATS = saved[0]
+ shutil._UNPACK_FORMATS.clear()
+ shutil._UNPACK_FORMATS.update(saved[1])
+
+ def get_logging__handlers(self):
+ # _handlers is a WeakValueDictionary
+ return id(logging._handlers), logging._handlers, logging._handlers.copy()
+ def restore_logging__handlers(self, saved_handlers):
+ # Can't easily revert the logging state
+ pass
+
+ def get_logging__handlerList(self):
+ # _handlerList is a list of weakrefs to handlers
+ return id(logging._handlerList), logging._handlerList, logging._handlerList[:]
+ def restore_logging__handlerList(self, saved_handlerList):
+ # Can't easily revert the logging state
+ pass
+
+ def get_sys_warnoptions(self):
+ return id(sys.warnoptions), sys.warnoptions, sys.warnoptions[:]
+ def restore_sys_warnoptions(self, saved_options):
+ sys.warnoptions = saved_options[1]
+ sys.warnoptions[:] = saved_options[2]
+
+ # Controlling dangling references to Thread objects can make it easier
+ # to track reference leaks.
+ def get_threading__dangling(self):
+ if not threading:
+ return None
+ # This copies the weakrefs without making any strong reference
+ return threading._dangling.copy()
+ def restore_threading__dangling(self, saved):
+ if not threading:
+ return
+ threading._dangling.clear()
+ threading._dangling.update(saved)
+
+ # Same for Process objects
+ def get_multiprocessing_process__dangling(self):
+ if not multiprocessing:
+ return None
+ # This copies the weakrefs without making any strong reference
+ return multiprocessing.process._dangling.copy()
+ def restore_multiprocessing_process__dangling(self, saved):
+ if not multiprocessing:
+ return
+ multiprocessing.process._dangling.clear()
+ multiprocessing.process._dangling.update(saved)
+
+ def get_support_TESTFN(self):
+ if os.path.isfile(support.TESTFN):
result = 'f'
- elif os.path.isdir(test_support.TESTFN):
+ elif os.path.isdir(support.TESTFN):
result = 'd'
else:
result = None
return result
- def restore_test_support_TESTFN(self, saved_value):
+ def restore_support_TESTFN(self, saved_value):
if saved_value is None:
- if os.path.isfile(test_support.TESTFN):
- os.unlink(test_support.TESTFN)
- elif os.path.isdir(test_support.TESTFN):
- shutil.rmtree(test_support.TESTFN)
+ if os.path.isfile(support.TESTFN):
+ os.unlink(support.TESTFN)
+ elif os.path.isdir(support.TESTFN):
+ shutil.rmtree(support.TESTFN)
def resource_info(self):
for name in self.resources:
@@ -851,96 +1082,72 @@ class saved_test_environment:
self.changed = True
restore(original)
if not self.quiet:
- print >>sys.stderr, (
- "Warning -- {} was modified by {}".format(
- name, self.testname))
+ print("Warning -- {} was modified by {}".format(
+ name, self.testname),
+ file=sys.stderr)
if self.verbose > 1:
- print >>sys.stderr, (
- " Before: {}\n After: {} ".format(
- original, current))
- # XXX (ncoghlan): for most resources (e.g. sys.path) identity
- # matters at least as much as value. For others (e.g. cwd),
- # identity is irrelevant. Should we add a mechanism to check
- # for substitution in the cases where it matters?
+ print(" Before: {}\n After: {} ".format(
+ original, current),
+ file=sys.stderr)
return False
-def runtest_inner(test, verbose, quiet, huntrleaks=False):
- test_support.unload(test)
- if verbose:
- capture_stdout = None
- else:
- capture_stdout = StringIO.StringIO()
+def runtest_inner(test, verbose, quiet,
+ huntrleaks=False, debug=False, display_failure=True):
+ support.unload(test)
test_time = 0.0
refleak = False # True if the test leaked references.
try:
- save_stdout = sys.stdout
- try:
- if capture_stdout:
- sys.stdout = capture_stdout
- if test.startswith('test.'):
- abstest = test
- else:
- # Always import it from the test package
- abstest = 'test.' + test
- with saved_test_environment(test, verbose, quiet) as environment:
- start_time = time.time()
- the_package = __import__(abstest, globals(), locals(), [])
- the_module = getattr(the_package, test)
- # Old tests run to completion simply as a side-effect of
- # being imported. For tests based on unittest or doctest,
- # explicitly invoke their test_main() function (if it exists).
- indirect_test = getattr(the_module, "test_main", None)
- if indirect_test is not None:
- indirect_test()
- if huntrleaks:
- refleak = dash_R(the_module, test, indirect_test,
- huntrleaks)
- test_time = time.time() - start_time
- finally:
- sys.stdout = save_stdout
- except test_support.ResourceDenied, msg:
+ if test.startswith('test.'):
+ abstest = test
+ else:
+ # Always import it from the test package
+ abstest = 'test.' + test
+ with saved_test_environment(test, verbose, quiet) as environment:
+ start_time = time.time()
+ the_package = __import__(abstest, globals(), locals(), [])
+ the_module = getattr(the_package, test)
+ # Old tests run to completion simply as a side-effect of
+ # being imported. For tests based on unittest or doctest,
+ # explicitly invoke their test_main() function (if it exists).
+ indirect_test = getattr(the_module, "test_main", None)
+ if indirect_test is not None:
+ indirect_test()
+ if huntrleaks:
+ refleak = dash_R(the_module, test, indirect_test,
+ huntrleaks)
+ test_time = time.time() - start_time
+ except support.ResourceDenied as msg:
if not quiet:
- print test, "skipped --", msg
+ print(test, "skipped --", msg)
sys.stdout.flush()
return RESOURCE_DENIED, test_time
- except unittest.SkipTest, msg:
+ except unittest.SkipTest as msg:
if not quiet:
- print test, "skipped --", msg
+ print(test, "skipped --", msg)
sys.stdout.flush()
return SKIPPED, test_time
except KeyboardInterrupt:
raise
- except test_support.TestFailed, msg:
- print >>sys.stderr, "test", test, "failed --", msg
+ except support.TestFailed as msg:
+ if display_failure:
+ print("test", test, "failed --", msg, file=sys.stderr)
+ else:
+ print("test", test, "failed", file=sys.stderr)
sys.stderr.flush()
return FAILED, test_time
except:
- type, value = sys.exc_info()[:2]
- print >>sys.stderr, "test", test, "crashed --", str(type) + ":", value
+ msg = traceback.format_exc()
+ print("test", test, "crashed --", msg, file=sys.stderr)
sys.stderr.flush()
- if verbose:
- traceback.print_exc(file=sys.stderr)
- sys.stderr.flush()
return FAILED, test_time
else:
if refleak:
return FAILED, test_time
if environment.changed:
return ENV_CHANGED, test_time
- # Except in verbose mode, tests should not print anything
- if verbose or huntrleaks:
- return PASSED, test_time
- output = capture_stdout.getvalue()
- if not output:
- return PASSED, test_time
- print "test", test, "produced unexpected output:"
- print "*" * 70
- print output
- print "*" * 70
- sys.stdout.flush()
- return FAILED, test_time
+ return PASSED, test_time
def cleanup_test_droppings(testname, verbose):
import shutil
@@ -948,6 +1155,8 @@ def cleanup_test_droppings(testname, verbose):
import gc
# First kill any dangling references to open files etc.
+ # This can also issue some ResourceWarnings which would otherwise get
+ # triggered during the following test run, and possibly produce failures.
gc.collect()
# Try to clean up junk commonly left behind. While tests shouldn't leave
@@ -956,7 +1165,7 @@ def cleanup_test_droppings(testname, verbose):
# since if a test leaves a file open, it cannot be deleted by name (while
# there's nothing we can do about that here either, we can display the
# name of the offending test, which is a real help).
- for name in (test_support.TESTFN,
+ for name in (support.TESTFN,
"db_home",
):
if not os.path.exists(name):
@@ -971,16 +1180,16 @@ def cleanup_test_droppings(testname, verbose):
"directory nor file" % name)
if verbose:
- print "%r left behind %s %r" % (testname, kind, name)
+ print("%r left behind %s %r" % (testname, kind, name))
try:
# if we have chmod, fix possible permissions problems
# that might prevent cleanup
if (hasattr(os, 'chmod')):
os.chmod(name, stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
nuker(name)
- except Exception, msg:
- print >> sys.stderr, ("%r left behind %s %r and it couldn't be "
- "removed: %s" % (testname, kind, name, msg))
+ except Exception as msg:
+ print(("%r left behind %s %r and it couldn't be "
+ "removed: %s" % (testname, kind, name, msg)), file=sys.stderr)
def dash_R(the_module, test, indirect_test, huntrleaks):
"""Run a test multiple times, looking for reference leaks.
@@ -989,7 +1198,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
False if the test didn't leak references; True if we detected refleaks.
"""
# This code is hackish and inelegant, but it seems to do the job.
- import copy_reg, _abcoll, _pyio
+ import copyreg, _abcoll
if not hasattr(sys, 'gettotalrefcount'):
raise Exception("Tracking reference leaks requires a debug build "
@@ -997,7 +1206,7 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
# Save current values for dash_R_cleanup() to restore.
fs = warnings.filters[:]
- ps = copy_reg.dispatch_table.copy()
+ ps = copyreg.dispatch_table.copy()
pic = sys.path_importer_cache.copy()
try:
import zipimport
@@ -1006,10 +1215,8 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
else:
zdc = zipimport._zip_directory_cache.copy()
abcs = {}
- modules = _abcoll, _pyio
- for abc in [getattr(mod, a) for mod in modules for a in mod.__all__]:
- # XXX isinstance(abc, ABCMeta) leads to infinite recursion
- if not hasattr(abc, '_abc_registry'):
+ for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
+ if not isabstract(abc):
continue
for obj in abc.__subclasses__() + [abc]:
abcs[obj] = obj._abc_registry.copy()
@@ -1019,40 +1226,44 @@ def dash_R(the_module, test, indirect_test, huntrleaks):
indirect_test()
else:
def run_the_test():
- imp.reload(the_module)
+ del sys.modules[the_module.__name__]
+ exec('import ' + the_module.__name__)
deltas = []
nwarmup, ntracked, fname = huntrleaks
- fname = os.path.join(test_support.SAVEDCWD, fname)
+ fname = os.path.join(support.SAVEDCWD, fname)
repcount = nwarmup + ntracked
- print >> sys.stderr, "beginning", repcount, "repetitions"
- print >> sys.stderr, ("1234567890"*(repcount//10 + 1))[:repcount]
+ print("beginning", repcount, "repetitions", file=sys.stderr)
+ print(("1234567890"*(repcount//10 + 1))[:repcount], file=sys.stderr)
+ sys.stderr.flush()
dash_R_cleanup(fs, ps, pic, zdc, abcs)
for i in range(repcount):
rc_before = sys.gettotalrefcount()
run_the_test()
sys.stderr.write('.')
+ sys.stderr.flush()
dash_R_cleanup(fs, ps, pic, zdc, abcs)
rc_after = sys.gettotalrefcount()
if i >= nwarmup:
deltas.append(rc_after - rc_before)
- print >> sys.stderr
+ print(file=sys.stderr)
if any(deltas):
msg = '%s leaked %s references, sum=%s' % (test, deltas, sum(deltas))
- print >> sys.stderr, msg
+ print(msg, file=sys.stderr)
+ sys.stderr.flush()
with open(fname, "a") as refrep:
- print >> refrep, msg
+ print(msg, file=refrep)
refrep.flush()
return True
return False
def dash_R_cleanup(fs, ps, pic, zdc, abcs):
- import gc, copy_reg
+ import gc, copyreg
import _strptime, linecache
- dircache = test_support.import_module('dircache', deprecated=True)
- import urlparse, urllib, urllib2, mimetypes, doctest
- import struct, filecmp
+ import urllib.parse, urllib.request, mimetypes, doctest
+ import struct, filecmp, _abcoll
from distutils.dir_util import _path_created
+ from weakref import WeakSet
# Clear the warnings registry, so they can be displayed again
for mod in sys.modules.values():
@@ -1061,8 +1272,8 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
# Restore some original values.
warnings.filters[:] = fs
- copy_reg.dispatch_table.clear()
- copy_reg.dispatch_table.update(ps)
+ copyreg.dispatch_table.clear()
+ copyreg.dispatch_table.update(ps)
sys.path_importer_cache.clear()
sys.path_importer_cache.update(pic)
try:
@@ -1077,19 +1288,26 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
sys._clear_type_cache()
# Clear ABC registries, restoring previously saved ABC registries.
- for abc, registry in abcs.items():
- abc._abc_registry = registry.copy()
- abc._abc_cache.clear()
- abc._abc_negative_cache.clear()
+ for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]:
+ if not isabstract(abc):
+ continue
+ for obj in abc.__subclasses__() + [abc]:
+ obj._abc_registry = abcs.get(obj, WeakSet()).copy()
+ obj._abc_cache.clear()
+ obj._abc_negative_cache.clear()
+
+ # Flush standard output, so that buffered data is sent to the OS and
+ # associated Python objects are reclaimed.
+ for stream in (sys.stdout, sys.stderr, sys.__stdout__, sys.__stderr__):
+ if stream is not None:
+ stream.flush()
# Clear assorted module caches.
_path_created.clear()
re.purge()
_strptime._regex_cache.clear()
- urlparse.clear_cache()
- urllib.urlcleanup()
- urllib2.install_opener(None)
- dircache.reset()
+ urllib.parse.clear_cache()
+ urllib.request.urlcleanup()
linecache.clearcache()
mimetypes._default_mime_types()
filecmp._cache.clear()
@@ -1106,6 +1324,11 @@ def dash_R_cleanup(fs, ps, pic, zdc, abcs):
# Collect cyclic trash.
gc.collect()
+def warm_char_cache():
+ s = bytes(range(256))
+ for i in range(256):
+ s[i:i+1]
+
def findtestdir(path=None):
return path or os.path.dirname(__file__) or os.curdir
@@ -1134,8 +1357,8 @@ def printlist(x, width=70, indent=4):
from textwrap import fill
blanks = ' ' * indent
# Print the sorted list: 'x' may be a '--random' list or a set()
- print fill(' '.join(str(elt) for elt in sorted(x)), width,
- initial_indent=blanks, subsequent_indent=blanks)
+ print(fill(' '.join(str(elt) for elt in sorted(x)), width,
+ initial_indent=blanks, subsequent_indent=blanks))
# Map sys.platform to a string containing the basenames of tests
# expected to be skipped on that platform.
@@ -1155,22 +1378,18 @@ _expectations = {
'win32':
"""
test__locale
- test_bsddb185
- test_bsddb3
- test_commands
test_crypt
test_curses
test_dbm
- test_dl
test_fcntl
test_fork1
test_epoll
- test_gdbm
+ test_dbm_gnu
+ test_dbm_ndbm
test_grp
test_ioctl
test_largefile
test_kqueue
- test_mhlib
test_openpty
test_ossaudiodev
test_pipes
@@ -1180,25 +1399,20 @@ _expectations = {
test_pwd
test_resource
test_signal
+ test_syslog
test_threadsignals
- test_timing
test_wait3
test_wait4
""",
'linux2':
"""
- test_bsddb185
test_curses
- test_dl
test_largefile
test_kqueue
test_ossaudiodev
""",
'unixware7':
"""
- test_bsddb
- test_bsddb185
- test_dl
test_epoll
test_largefile
test_kqueue
@@ -1210,9 +1424,6 @@ _expectations = {
""",
'openunix8':
"""
- test_bsddb
- test_bsddb185
- test_dl
test_epoll
test_largefile
test_kqueue
@@ -1225,9 +1436,6 @@ _expectations = {
'sco_sv3':
"""
test_asynchat
- test_bsddb
- test_bsddb185
- test_dl
test_fork1
test_epoll
test_gettext
@@ -1245,64 +1453,26 @@ _expectations = {
test_threadedtempfile
test_threading
""",
- 'riscos':
- """
- test_asynchat
- test_atexit
- test_bsddb
- test_bsddb185
- test_bsddb3
- test_commands
- test_crypt
- test_dbm
- test_dl
- test_fcntl
- test_fork1
- test_epoll
- test_gdbm
- test_grp
- test_largefile
- test_locale
- test_kqueue
- test_mmap
- test_openpty
- test_poll
- test_popen2
- test_pty
- test_pwd
- test_strop
- test_sundry
- test_thread
- test_threaded_import
- test_threadedtempfile
- test_threading
- test_timing
- """,
'darwin':
"""
test__locale
- test_bsddb
- test_bsddb3
test_curses
test_epoll
+ test_dbm_gnu
test_gdb
- test_gdbm
test_largefile
test_locale
- test_kqueue
test_minidom
test_ossaudiodev
test_poll
""",
'sunos5':
"""
- test_bsddb
- test_bsddb185
test_curses
test_dbm
test_epoll
test_kqueue
- test_gdbm
+ test_dbm_gnu
test_gzip
test_openpty
test_zipfile
@@ -1310,12 +1480,9 @@ _expectations = {
""",
'hp-ux11':
"""
- test_bsddb
- test_bsddb185
test_curses
- test_dl
test_epoll
- test_gdbm
+ test_dbm_gnu
test_gzip
test_largefile
test_locale
@@ -1327,26 +1494,8 @@ _expectations = {
test_zipfile
test_zlib
""",
- 'atheos':
- """
- test_bsddb185
- test_curses
- test_dl
- test_gdbm
- test_epoll
- test_largefile
- test_locale
- test_kqueue
- test_mhlib
- test_mmap
- test_poll
- test_popen2
- test_resource
- """,
'cygwin':
"""
- test_bsddb185
- test_bsddb3
test_curses
test_dbm
test_epoll
@@ -1360,15 +1509,10 @@ _expectations = {
'os2emx':
"""
test_audioop
- test_bsddb185
- test_bsddb3
- test_commands
test_curses
- test_dl
test_epoll
test_kqueue
test_largefile
- test_mhlib
test_mmap
test_openpty
test_ossaudiodev
@@ -1378,10 +1522,8 @@ _expectations = {
""",
'freebsd4':
"""
- test_bsddb
- test_bsddb3
test_epoll
- test_gdbm
+ test_dbm_gnu
test_locale
test_ossaudiodev
test_pep277
@@ -1397,13 +1539,9 @@ _expectations = {
""",
'aix5':
"""
- test_bsddb
- test_bsddb185
- test_bsddb3
test_bz2
- test_dl
test_epoll
- test_gdbm
+ test_dbm_gnu
test_gzip
test_kqueue
test_ossaudiodev
@@ -1416,13 +1554,9 @@ _expectations = {
""",
'openbsd3':
"""
- test_ascii_formatd
- test_bsddb
- test_bsddb3
test_ctypes
- test_dl
test_epoll
- test_gdbm
+ test_dbm_gnu
test_locale
test_normalization
test_ossaudiodev
@@ -1435,15 +1569,10 @@ _expectations = {
""",
'netbsd3':
"""
- test_ascii_formatd
- test_bsddb
- test_bsddb185
- test_bsddb3
test_ctypes
test_curses
- test_dl
test_epoll
- test_gdbm
+ test_dbm_gnu
test_locale
test_ossaudiodev
test_pep277
@@ -1469,49 +1598,39 @@ class _ExpectedSkips:
s = _expectations[sys.platform]
self.expected = set(s.split())
- # expected to be skipped on every platform, even Linux
- self.expected.add('test_linuxaudiodev')
+ # These are broken tests, for now skipped on every platform.
+ # XXX Fix these!
+ self.expected.add('test_nis')
+ # expected to be skipped on every platform, even Linux
if not os.path.supports_unicode_filenames:
self.expected.add('test_pep277')
+ # doctest, profile and cProfile tests fail when the codec for the
+ # fs encoding isn't built in because PyUnicode_Decode() adds two
+ # calls into Python.
+ encs = ("utf-8", "latin-1", "ascii", "mbcs", "utf-16", "utf-32")
+ if sys.getfilesystemencoding().lower() not in encs:
+ self.expected.add('test_profile')
+ self.expected.add('test_cProfile')
+ self.expected.add('test_doctest')
+
if test_timeout.skip_expected:
self.expected.add('test_timeout')
- if sys.maxint == 9223372036854775807L:
- self.expected.add('test_imageop')
-
- if sys.platform != "darwin":
- MAC_ONLY = ["test_macos", "test_macostools", "test_aepack",
- "test_plistlib", "test_scriptpackages",
- "test_applesingle"]
- for skip in MAC_ONLY:
- self.expected.add(skip)
- elif len(u'\0'.encode('unicode-internal')) == 4:
- self.expected.add("test_macostools")
-
-
if sys.platform != "win32":
# test_sqlite is only reliable on Windows where the library
# is distributed with Python
- WIN_ONLY = ["test_unicode_file", "test_winreg",
+ WIN_ONLY = {"test_unicode_file", "test_winreg",
"test_winsound", "test_startfile",
- "test_sqlite", "test_msilib"]
- for skip in WIN_ONLY:
- self.expected.add(skip)
-
- if sys.platform != 'irix':
- IRIX_ONLY = ["test_imageop", "test_al", "test_cd", "test_cl",
- "test_gl", "test_imgfile"]
- for skip in IRIX_ONLY:
- self.expected.add(skip)
+ "test_sqlite", "test_msilib"}
+ self.expected |= WIN_ONLY
if sys.platform != 'sunos5':
- self.expected.add('test_sunaudiodev')
self.expected.add('test_nis')
- if not sys.py3kwarning:
- self.expected.add('test_py3kwarn')
+ if support.python_is_optimized():
+ self.expected.add("test_gdb")
self.valid = True
@@ -1528,24 +1647,18 @@ class _ExpectedSkips:
assert self.isvalid()
return self.expected
-if __name__ == '__main__':
- # findtestdir() gets the dirname out of __file__, so we have to make it
- # absolute before changing the working directory.
- # For example __file__ may be relative when running trace or profile.
- # See issue #9323.
- __file__ = os.path.abspath(__file__)
-
- # sanity check
- assert __file__ == os.path.abspath(sys.argv[0])
-
+def _make_temp_dir_for_build(TEMPDIR):
# When tests are run from the Python build directory, it is best practice
# to keep the test files in a subfolder. It eases the cleanup of leftover
# files using command "make distclean".
if sysconfig.is_python_build():
TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
TEMPDIR = os.path.abspath(TEMPDIR)
- if not os.path.exists(TEMPDIR):
+ try:
os.mkdir(TEMPDIR)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
# Define a writable temp dir that will be used as cwd while running
# the tests. The name of the dir includes the pid to allow parallel
@@ -1553,10 +1666,35 @@ if __name__ == '__main__':
TESTCWD = 'test_python_{}'.format(os.getpid())
TESTCWD = os.path.join(TEMPDIR, TESTCWD)
+ return TEMPDIR, TESTCWD
+
+if __name__ == '__main__':
+ # Remove regrtest.py's own directory from the module search path. Despite
+ # the elimination of implicit relative imports, this is still needed to
+ # ensure that submodules of the test package do not inappropriately appear
+ # as top-level modules even when people (or buildbots!) invoke regrtest.py
+ # directly instead of using the -m switch
+ mydir = os.path.abspath(os.path.normpath(os.path.dirname(sys.argv[0])))
+ i = len(sys.path)
+ while i >= 0:
+ i -= 1
+ if os.path.abspath(os.path.normpath(sys.path[i])) == mydir:
+ del sys.path[i]
+
+ # findtestdir() gets the dirname out of __file__, so we have to make it
+ # absolute before changing the working directory.
+ # For example __file__ may be relative when running trace or profile.
+ # See issue #9323.
+ __file__ = os.path.abspath(__file__)
+
+ # sanity check
+ assert __file__ == os.path.abspath(sys.argv[0])
+
+ TEMPDIR, TESTCWD = _make_temp_dir_for_build(TEMPDIR)
# Run the tests in a context manager that temporary changes the CWD to a
# temporary and writable directory. If it's not possible to create or
# change the CWD, the original CWD will be used. The original CWD is
- # available from test_support.SAVEDCWD.
- with test_support.temp_cwd(TESTCWD, quiet=True):
+ # available from support.SAVEDCWD.
+ with support.temp_cwd(TESTCWD, quiet=True):
main()
diff --git a/Lib/test/reperf.py b/Lib/test/reperf.py
index 68ac40f1328..7c6823471ea 100644
--- a/Lib/test/reperf.py
+++ b/Lib/test/reperf.py
@@ -17,7 +17,7 @@ def timefunc(n, func, *args, **kw):
finally:
t1 = time.clock()
if n > 1:
- print n, "times",
- print func.__name__, "%.3f" % (t1-t0), "CPU seconds"
+ print(n, "times", end=' ')
+ print(func.__name__, "%.3f" % (t1-t0), "CPU seconds")
main()
diff --git a/Lib/test/sample_doctest.py b/Lib/test/sample_doctest.py
index e5adee0f6fd..89eb5cb7cf1 100644
--- a/Lib/test/sample_doctest.py
+++ b/Lib/test/sample_doctest.py
@@ -40,9 +40,9 @@ def test_silly_setup():
def w_blank():
"""
>>> if 1:
- ... print 'a'
- ... print
- ... print 'b'
+ ... print('a')
+ ... print()
+ ... print('b')
a
<BLANKLINE>
b
diff --git a/Lib/test/script_helper.py b/Lib/test/script_helper.py
index 7f7c70ea067..ba446cd69b9 100644
--- a/Lib/test/script_helper.py
+++ b/Lib/test/script_helper.py
@@ -3,33 +3,31 @@
import sys
import os
-import re
import os.path
import tempfile
import subprocess
import py_compile
import contextlib
import shutil
-try:
- import zipfile
-except ImportError:
- # If Python is build without Unicode support, importing _io will
- # fail, which, in turn, means that zipfile cannot be imported
- # Most of this module can then still be used.
- pass
+import zipfile
-from test.test_support import strip_python_stderr
+from imp import source_from_cache
+from test.support import make_legacy_pyc, strip_python_stderr
# Executing the interpreter in a subprocess
def _assert_python(expected_success, *args, **env_vars):
cmd_line = [sys.executable]
if not env_vars:
cmd_line.append('-E')
- cmd_line.extend(args)
# Need to preserve the original environment, for in-place testing of
# shared library builds.
env = os.environ.copy()
+ # But a special flag that can be set to override -- in this case, the
+ # caller is responsible to pass the full environment.
+ if env_vars.pop('__cleanenv', None):
+ env = {}
env.update(env_vars)
+ cmd_line.extend(args)
p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
env=env)
@@ -61,19 +59,11 @@ def assert_python_failure(*args, **env_vars):
"""
return _assert_python(False, *args, **env_vars)
-def python_exit_code(*args):
- cmd_line = [sys.executable, '-E']
- cmd_line.extend(args)
- with open(os.devnull, 'w') as devnull:
- return subprocess.call(cmd_line, stdout=devnull,
- stderr=subprocess.STDOUT)
-
-def spawn_python(*args, **kwargs):
+def spawn_python(*args):
cmd_line = [sys.executable, '-E']
cmd_line.extend(args)
return subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- **kwargs)
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def kill_python(p):
p.stdin.close()
@@ -85,14 +75,6 @@ def kill_python(p):
subprocess._cleanup()
return data
-def run_python(*args, **kwargs):
- if __debug__:
- p = spawn_python(*args, **kwargs)
- else:
- p = spawn_python('-O', *args, **kwargs)
- stdout_data = kill_python(p)
- return p.wait(), stdout_data
-
# Script creation utilities
@contextlib.contextmanager
def temp_dir():
@@ -106,37 +88,36 @@ def temp_dir():
def make_script(script_dir, script_basename, source):
script_filename = script_basename+os.extsep+'py'
script_name = os.path.join(script_dir, script_filename)
- script_file = open(script_name, 'w')
+ # The script should be encoded to UTF-8, the default string encoding
+ script_file = open(script_name, 'w', encoding='utf-8')
script_file.write(source)
script_file.close()
return script_name
-def compile_script(script_name):
- py_compile.compile(script_name, doraise=True)
- if __debug__:
- compiled_name = script_name + 'c'
- else:
- compiled_name = script_name + 'o'
- return compiled_name
-
def make_zip_script(zip_dir, zip_basename, script_name, name_in_zip=None):
zip_filename = zip_basename+os.extsep+'zip'
zip_name = os.path.join(zip_dir, zip_filename)
zip_file = zipfile.ZipFile(zip_name, 'w')
if name_in_zip is None:
- name_in_zip = os.path.basename(script_name)
+ parts = script_name.split(os.sep)
+ if len(parts) >= 2 and parts[-2] == '__pycache__':
+ legacy_pyc = make_legacy_pyc(source_from_cache(script_name))
+ name_in_zip = os.path.basename(legacy_pyc)
+ script_name = legacy_pyc
+ else:
+ name_in_zip = os.path.basename(script_name)
zip_file.write(script_name, name_in_zip)
zip_file.close()
- #if test.test_support.verbose:
+ #if test.support.verbose:
# zip_file = zipfile.ZipFile(zip_name, 'r')
# print 'Contents of %r:' % zip_name
# zip_file.printdir()
# zip_file.close()
return zip_name, os.path.join(zip_name, name_in_zip)
-def make_pkg(pkg_dir):
+def make_pkg(pkg_dir, init_source=''):
os.mkdir(pkg_dir)
- make_script(pkg_dir, '__init__', '')
+ make_script(pkg_dir, '__init__', init_source)
def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
source, depth=1, compiled=False):
@@ -147,8 +128,8 @@ def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
script_name = make_script(zip_dir, script_basename, source)
unlink.append(script_name)
if compiled:
- init_name = compile_script(init_name)
- script_name = compile_script(script_name)
+ init_name = py_compile(init_name, doraise=True)
+ script_name = py_compile(script_name, doraise=True)
unlink.extend((init_name, script_name))
pkg_names = [os.sep.join([pkg_name]*i) for i in range(1, depth+1)]
script_name_in_zip = os.path.join(pkg_names[-1], os.path.basename(script_name))
@@ -162,7 +143,7 @@ def make_zip_pkg(zip_dir, zip_basename, pkg_name, script_basename,
zip_file.close()
for name in unlink:
os.unlink(name)
- #if test.test_support.verbose:
+ #if test.support.verbose:
# zip_file = zipfile.ZipFile(zip_name, 'r')
# print 'Contents of %r:' % zip_name
# zip_file.printdir()
diff --git a/Lib/test/seq_tests.py b/Lib/test/seq_tests.py
index f5e4e0ef552..f655c29eee2 100644
--- a/Lib/test/seq_tests.py
+++ b/Lib/test/seq_tests.py
@@ -26,7 +26,7 @@ class IterFunc:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -46,14 +46,14 @@ class IterNextOnly:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
return v
class IterNoNext:
- 'Iterator missing next()'
+ 'Iterator missing __next__()'
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
@@ -67,7 +67,7 @@ class IterGenExc:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
3 // 0
class IterFuncStop:
@@ -76,13 +76,13 @@ class IterFuncStop:
pass
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
-from itertools import chain, imap
+from itertools import chain
def itermulti(seqn):
'Test multiple tiers of iterators'
- return chain(imap(lambda x:x, iterfunc(IterGen(Sequence(seqn)))))
+ return chain(map(lambda x:x, iterfunc(IterGen(Sequence(seqn)))))
class CommonTest(unittest.TestCase):
# The type to be tested
@@ -120,7 +120,7 @@ class CommonTest(unittest.TestCase):
self.assertEqual(len(vv), len(s))
# Create from various iteratables
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (Sequence, IterFunc, IterGen,
itermulti, iterfunc):
self.assertEqual(self.type2test(g(s)), self.type2test(s))
@@ -136,12 +136,12 @@ class CommonTest(unittest.TestCase):
def test_getitem(self):
u = self.type2test([0, 1, 2, 3, 4])
- for i in xrange(len(u)):
+ for i in range(len(u)):
self.assertEqual(u[i], i)
- self.assertEqual(u[long(i)], i)
- for i in xrange(-len(u), -1):
+ self.assertEqual(u[int(i)], i)
+ for i in range(-len(u), -1):
self.assertEqual(u[i], len(u)+i)
- self.assertEqual(u[long(i)], len(u)+i)
+ self.assertEqual(u[int(i)], len(u)+i)
self.assertRaises(IndexError, u.__getitem__, -len(u)-1)
self.assertRaises(IndexError, u.__getitem__, len(u))
self.assertRaises(ValueError, u.__getitem__, slice(0,10,0))
@@ -189,14 +189,12 @@ class CommonTest(unittest.TestCase):
self.assertEqual(u[-100:100:], u)
self.assertEqual(u[100:-100:-1], u[::-1])
self.assertEqual(u[-100:100:-1], self.type2test([]))
- self.assertEqual(u[-100L:100L:2L], self.type2test([0, 2, 4]))
+ self.assertEqual(u[-100:100:2], self.type2test([0, 2, 4]))
# Test extreme cases with long ints
a = self.type2test([0,1,2,3,4])
- self.assertEqual(a[ -pow(2,128L): 3 ], self.type2test([0,1,2]))
- self.assertEqual(a[ 3: pow(2,145L) ], self.type2test([3,4]))
-
- self.assertRaises(TypeError, u.__getslice__)
+ self.assertEqual(a[ -pow(2,128): 3 ], self.type2test([0,1,2]))
+ self.assertEqual(a[ 3: pow(2,145) ], self.type2test([3,4]))
def test_contains(self):
u = self.type2test([0, 1, 2])
@@ -253,16 +251,16 @@ class CommonTest(unittest.TestCase):
self.assertEqual(self.type2test([-1]) + u1, self.type2test([-1, 0]))
self.assertEqual(self.type2test(), u2*0)
self.assertEqual(self.type2test(), 0*u2)
- self.assertEqual(self.type2test(), u2*0L)
- self.assertEqual(self.type2test(), 0L*u2)
+ self.assertEqual(self.type2test(), u2*0)
+ self.assertEqual(self.type2test(), 0*u2)
self.assertEqual(u2, u2*1)
self.assertEqual(u2, 1*u2)
- self.assertEqual(u2, u2*1L)
- self.assertEqual(u2, 1L*u2)
+ self.assertEqual(u2, u2*1)
+ self.assertEqual(u2, 1*u2)
+ self.assertEqual(u2+u2, u2*2)
+ self.assertEqual(u2+u2, 2*u2)
self.assertEqual(u2+u2, u2*2)
self.assertEqual(u2+u2, 2*u2)
- self.assertEqual(u2+u2, u2*2L)
- self.assertEqual(u2+u2, 2L*u2)
self.assertEqual(u2+u2+u2, u2*3)
self.assertEqual(u2+u2+u2, 3*u2)
@@ -295,19 +293,19 @@ class CommonTest(unittest.TestCase):
class T(self.type2test):
def __getitem__(self, key):
return str(key) + '!!!'
- self.assertEqual(iter(T((1,2))).next(), 1)
+ self.assertEqual(next(iter(T((1,2)))), 1)
def test_repeat(self):
- for m in xrange(4):
+ for m in range(4):
s = tuple(range(m))
- for n in xrange(-3, 5):
+ for n in range(-3, 5):
self.assertEqual(self.type2test(s*n), self.type2test(s)*n)
self.assertEqual(self.type2test(s)*(-4), self.type2test([]))
self.assertEqual(id(s), id(s*1))
def test_bigrepeat(self):
import sys
- if sys.maxint <= 2147483647:
+ if sys.maxsize <= 2147483647:
x = self.type2test([0])
x *= 2**16
self.assertRaises(MemoryError, x.__mul__, 2**16)
@@ -316,10 +314,10 @@ class CommonTest(unittest.TestCase):
def test_subscript(self):
a = self.type2test([10, 11])
- self.assertEqual(a.__getitem__(0L), 10)
- self.assertEqual(a.__getitem__(1L), 11)
- self.assertEqual(a.__getitem__(-2L), 10)
- self.assertEqual(a.__getitem__(-1L), 11)
+ self.assertEqual(a.__getitem__(0), 10)
+ self.assertEqual(a.__getitem__(1), 11)
+ self.assertEqual(a.__getitem__(-2), 10)
+ self.assertEqual(a.__getitem__(-1), 11)
self.assertRaises(IndexError, a.__getitem__, -3)
self.assertRaises(IndexError, a.__getitem__, 3)
self.assertEqual(a.__getitem__(slice(0,1)), self.type2test([10]))
@@ -387,6 +385,6 @@ class CommonTest(unittest.TestCase):
self.assertEqual(a.index(0, -3), 3)
self.assertEqual(a.index(0, 3, 4), 3)
self.assertEqual(a.index(0, -3, -2), 3)
- self.assertEqual(a.index(0, -4*sys.maxint, 4*sys.maxint), 2)
- self.assertRaises(ValueError, a.index, 0, 4*sys.maxint,-4*sys.maxint)
+ self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2)
+ self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize)
self.assertRaises(ValueError, a.index, 2, 0, -10)
diff --git a/Lib/test/sha256.pem b/Lib/test/sha256.pem
index 94755765156..d3db4b85c0a 100644
--- a/Lib/test/sha256.pem
+++ b/Lib/test/sha256.pem
@@ -1,128 +1,128 @@
# Certificate chain for https://sha256.tbs-internet.com
- 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=Certificats TBS X509/CN=ecom.tbs-x509.com
- i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA business
+ 0 s:/C=FR/postalCode=14000/ST=Calvados/L=CAEN/street=22 rue de Bretagne/O=TBS INTERNET/OU=0002 440443810/OU=sha-256 production/CN=sha256.tbs-internet.com
+ i:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC
-----BEGIN CERTIFICATE-----
-MIIGTjCCBTagAwIBAgIQOh3d9dNDPq1cSdJmEiMpqDANBgkqhkiG9w0BAQUFADCB
-yTELMAkGA1UEBhMCRlIxETAPBgNVBAgTCENhbHZhZG9zMQ0wCwYDVQQHEwRDYWVu
-MRUwEwYDVQQKEwxUQlMgSU5URVJORVQxSDBGBgNVBAsTP1Rlcm1zIGFuZCBDb25k
-aXRpb25zOiBodHRwOi8vd3d3LnRicy1pbnRlcm5ldC5jb20vQ0EvcmVwb3NpdG9y
-eTEYMBYGA1UECxMPVEJTIElOVEVSTkVUIENBMR0wGwYDVQQDExRUQlMgWDUwOSBD
-QSBidXNpbmVzczAeFw0xMTAxMjUwMDAwMDBaFw0xMzAyMDUyMzU5NTlaMIHHMQsw
-CQYDVQQGEwJGUjEOMAwGA1UEERMFMTQwMDAxETAPBgNVBAgTCENhbHZhZG9zMQ0w
-CwYDVQQHEwRDQUVOMRswGQYDVQQJExIyMiBydWUgZGUgQnJldGFnbmUxFTATBgNV
-BAoTDFRCUyBJTlRFUk5FVDEXMBUGA1UECxMOMDAwMiA0NDA0NDM4MTAxHTAbBgNV
-BAsTFENlcnRpZmljYXRzIFRCUyBYNTA5MRowGAYDVQQDExFlY29tLnRicy14NTA5
-LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKRrlHUnJ++1lpcg
-jtYco7cdmRe+EEfTmwPfCdfV3G1QfsTSvY6FfMpm/83pqHfT+4ANwr18wD9ZrAEN
-G16mf9VdCGK12+TP7DmqeZyGIqlFFoahQnmb8EarvE43/1UeQ2CV9XmzwZvpqeli
-LfXsFonawrY3H6ZnMwS64St61Z+9gdyuZ/RbsoZBbT5KUjDEG844QRU4OT1IGeEI
-eY5NM5RNIh6ZNhVtqeeCxMS7afONkHQrOco73RdSTRck/Hj96Ofl3MHNHryr+AMK
-DGFk1kLCZGpPdXtkxXvaDeQoiYDlil26CWc+YK6xyDPMdsWvoG14ZLyCpzMXA7/7
-4YAQRH0CAwEAAaOCAjAwggIsMB8GA1UdIwQYMBaAFBoJBMz5CY+7HqDO1KQUf0vV
-I1jNMB0GA1UdDgQWBBQgOU8HsWzbmD4WZP5Wtdw7jca2WDAOBgNVHQ8BAf8EBAMC
-BaAwDAYDVR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIw
-TAYDVR0gBEUwQzBBBgsrBgEEAYDlNwIBATAyMDAGCCsGAQUFBwIBFiRodHRwczov
-L3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL0NQUzEwdwYDVR0fBHAwbjA3oDWgM4Yx
-aHR0cDovL2NybC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQWJ1c2luZXNzLmNy
-bDAzoDGgL4YtaHR0cDovL2NybC50YnMteDUwOS5jb20vVEJTWDUwOUNBYnVzaW5l
-c3MuY3JsMIGwBggrBgEFBQcBAQSBozCBoDA9BggrBgEFBQcwAoYxaHR0cDovL2Ny
-dC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQWJ1c2luZXNzLmNydDA5BggrBgEF
-BQcwAoYtaHR0cDovL2NydC50YnMteDUwOS5jb20vVEJTWDUwOUNBYnVzaW5lc3Mu
-Y3J0MCQGCCsGAQUFBzABhhhodHRwOi8vb2NzcC50YnMteDUwOS5jb20wMwYDVR0R
-BCwwKoIRZWNvbS50YnMteDUwOS5jb22CFXd3dy5lY29tLnRicy14NTA5LmNvbTAN
-BgkqhkiG9w0BAQUFAAOCAQEArT4NHfbY87bGAw8lPV4DmHlmuDuVp/y7ltO3Ynse
-3Rz8RxW2AzuO0Oy2F0Cu4yWKtMyEyMXyHqWtae7ElRbdTu5w5GwVBLJHClCzC8S9
-SpgMMQTx3Rgn8vjkHuU9VZQlulZyiPK7yunjc7c310S9FRZ7XxOwf8Nnx4WnB+No
-WrfApzhhQl31w+RyrNxZe58hCfDDHmevRvwLjQ785ZoQXJDj2j3qAD4aI2yB8lB5
-oaE1jlCJzC7Kmz/Y9jzfmv/zAs1LQTm9ktevv4BTUFaGjv9jxnQ1xnS862ZiouLW
-zZYIlYPf4F6JjXGiIQgQRglILUfq3ftJd9/ok9W9ZF8h8w==
+MIIGXDCCBUSgAwIBAgIRAKpVmHgg9nfCodAVwcP4siwwDQYJKoZIhvcNAQELBQAw
+gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl
+bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u
+ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv
+cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg
+Q0EgU0dDMB4XDTEyMDEwNDAwMDAwMFoXDTE0MDIxNzIzNTk1OVowgcsxCzAJBgNV
+BAYTAkZSMQ4wDAYDVQQREwUxNDAwMDERMA8GA1UECBMIQ2FsdmFkb3MxDTALBgNV
+BAcTBENBRU4xGzAZBgNVBAkTEjIyIHJ1ZSBkZSBCcmV0YWduZTEVMBMGA1UEChMM
+VEJTIElOVEVSTkVUMRcwFQYDVQQLEw4wMDAyIDQ0MDQ0MzgxMDEbMBkGA1UECxMS
+c2hhLTI1NiBwcm9kdWN0aW9uMSAwHgYDVQQDExdzaGEyNTYudGJzLWludGVybmV0
+LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKQIX/zdJcyxty0m
+PM1XQSoSSifueS3AVcgqMsaIKS/u+rYzsv4hQ/qA6vLn5m5/ewUcZDj7zdi6rBVf
+PaVNXJ6YinLX0tkaW8TEjeVuZG5yksGZlhCt1CJ1Ho9XLiLaP4uJ7MCoNUntpJ+E
+LfrOdgsIj91kPmwjDJeztVcQCvKzhjVJA/KxdInc0JvOATn7rpaSmQI5bvIjufgo
+qVsTPwVFzuUYULXBk7KxRT7MiEqnd5HvviNh0285QC478zl3v0I0Fb5El4yD3p49
+IthcRnxzMKc0UhU5ogi0SbONyBfm/mzONVfSxpM+MlyvZmJqrbuuLoEDzJD+t8PU
+xSuzgbcCAwEAAaOCAj4wggI6MB8GA1UdIwQYMBaAFAdEdoWTKLx/bXjSCuv6TEvf
+2YIfMB0GA1UdDgQWBBT/qTGYdaj+f61c2IRFL/B1eEsM8DAOBgNVHQ8BAf8EBAMC
+BaAwDAYDVR0TAQH/BAIwADA0BgNVHSUELTArBggrBgEFBQcDAQYIKwYBBQUHAwIG
+CisGAQQBgjcKAwMGCWCGSAGG+EIEATBLBgNVHSAERDBCMEAGCisGAQQB5TcCBAEw
+MjAwBggrBgEFBQcCARYkaHR0cHM6Ly93d3cudGJzLWludGVybmV0LmNvbS9DQS9D
+UFM0MG0GA1UdHwRmMGQwMqAwoC6GLGh0dHA6Ly9jcmwudGJzLWludGVybmV0LmNv
+bS9UQlNYNTA5Q0FTR0MuY3JsMC6gLKAqhihodHRwOi8vY3JsLnRicy14NTA5LmNv
+bS9UQlNYNTA5Q0FTR0MuY3JsMIGmBggrBgEFBQcBAQSBmTCBljA4BggrBgEFBQcw
+AoYsaHR0cDovL2NydC50YnMtaW50ZXJuZXQuY29tL1RCU1g1MDlDQVNHQy5jcnQw
+NAYIKwYBBQUHMAKGKGh0dHA6Ly9jcnQudGJzLXg1MDkuY29tL1RCU1g1MDlDQVNH
+Qy5jcnQwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLnRicy14NTA5LmNvbTA/BgNV
+HREEODA2ghdzaGEyNTYudGJzLWludGVybmV0LmNvbYIbd3d3LnNoYTI1Ni50YnMt
+aW50ZXJuZXQuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQA0pOuL8QvAa5yksTbGShzX
+ABApagunUGoEydv4YJT1MXy9tTp7DrWaozZSlsqBxrYAXP1d9r2fuKbEniYHxaQ0
+UYaf1VSIlDo1yuC8wE7wxbHDIpQ/E5KAyxiaJ8obtDhFstWAPAH+UoGXq0kj2teN
+21sFQ5dXgA95nldvVFsFhrRUNB6xXAcaj0VZFhttI0ZfQZmQwEI/P+N9Jr40OGun
+aa+Dn0TMeUH4U20YntfLbu2nDcJcYfyurm+8/0Tr4HznLnedXu9pCPYj0TaddrgT
+XO0oFiyy7qGaY6+qKh71yD64Y3ycCJ/HR9Wm39mjZYc9ezYwT4noP6r7Lk8YO7/q
-----END CERTIFICATE-----
- 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA business
+ 1 s:/C=FR/ST=Calvados/L=Caen/O=TBS INTERNET/OU=Terms and Conditions: http://www.tbs-internet.com/CA/repository/OU=TBS INTERNET CA/CN=TBS X509 CA SGC
i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
-----BEGIN CERTIFICATE-----
-MIIFPzCCBCegAwIBAgIQDlBz/++iRSmLDeVRHT/hADANBgkqhkiG9w0BAQUFADBv
+MIIFVjCCBD6gAwIBAgIQXpDZ0ETJMV02WTx3GTnhhTANBgkqhkiG9w0BAQUFADBv
MQswCQYDVQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFk
ZFRydXN0IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBF
-eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDcwOTE4MTkyMlow
-gckxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl
+eHRlcm5hbCBDQSBSb290MB4XDTA1MTIwMTAwMDAwMFoXDTE5MDYyNDE5MDYzMFow
+gcQxCzAJBgNVBAYTAkZSMREwDwYDVQQIEwhDYWx2YWRvczENMAsGA1UEBxMEQ2Fl
bjEVMBMGA1UEChMMVEJTIElOVEVSTkVUMUgwRgYDVQQLEz9UZXJtcyBhbmQgQ29u
ZGl0aW9uczogaHR0cDovL3d3dy50YnMtaW50ZXJuZXQuY29tL0NBL3JlcG9zaXRv
-cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEdMBsGA1UEAxMUVEJTIFg1MDkg
-Q0EgYnVzaW5lc3MwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDB1PAU
-qudCcz3tmyGcf+u6EkZqonKKHrV4gZYbvVkIRojmmlhfi/jwvpHvo8bqSt/9Rj5S
-jhCDW0pcbI+IPPtD1Jy+CHNSfnMqVDy6CKQ3p5maTzCMG6ZT+XjnvcND5v+FtaiB
-xk1iCX6uvt0jeUtdZvYbyytsSDE6c3Y5//wRxOF8tM1JxibwO3pyER26jbbN2gQz
-m/EkdGjLdJ4svPk23WDAvQ6G0/z2LcAaJB+XLfqRwfQpHQvfKa1uTi8PivC8qtip
-rmNQMMPMjxSK2azX8cKjjTDJiUKaCb4VHlJDWKEsCFRpgJAoAuX8f7Yfs1M4esGo
-sWb3PGspK3O22uIlAgMBAAGjggF6MIIBdjAdBgNVHQ4EFgQUGgkEzPkJj7seoM7U
-pBR/S9UjWM0wDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQAwGAYD
-VR0gBBEwDzANBgsrBgEEAYDlNwIBATB7BgNVHR8EdDByMDigNqA0hjJodHRwOi8v
-Y3JsLmNvbW9kb2NhLmNvbS9BZGRUcnVzdEV4dGVybmFsQ0FSb290LmNybDA2oDSg
-MoYwaHR0cDovL2NybC5jb21vZG8ubmV0L0FkZFRydXN0RXh0ZXJuYWxDQVJvb3Qu
-Y3JsMIGGBggrBgEFBQcBAQR6MHgwOwYIKwYBBQUHMAKGL2h0dHA6Ly9jcnQuY29t
-b2RvY2EuY29tL0FkZFRydXN0VVROU2VydmVyQ0EuY3J0MDkGCCsGAQUFBzAChi1o
-dHRwOi8vY3J0LmNvbW9kby5uZXQvQWRkVHJ1c3RVVE5TZXJ2ZXJDQS5jcnQwEQYJ
-YIZIAYb4QgEBBAQDAgIEMA0GCSqGSIb3DQEBBQUAA4IBAQA7mqrMgk/MrE6QnbNA
-h4nRCn2ti4bg4w2C3lB6bSvRPnYwuNw9Jb8vuKkNFzRDxNJXqVDZdfFW5CVQJuyd
-nfAx83+wk+spzvFaE1KhFYfN9G9pQfXUfvDRoIcJgPEKUXL1wRiOG+IjU3VVI8pg
-IgqHkr7ylln5i5zCiFAPuIJmYUSFg/gxH5xkCNcjJqqrHrHatJr6Qrrke93joupw
-oU1njfAcZtYp6fbiK6u2b1pJqwkVBE8RsfLnPhRj+SFbpvjv8Od7o/ieJhFIYQNU
-k2jX2u8qZnAiNw93LZW9lpYjtuvMXq8QQppENNja5b53q7UwI+lU7ZGjZ7quuESp
-J6/5
+cnkxGDAWBgNVBAsTD1RCUyBJTlRFUk5FVCBDQTEYMBYGA1UEAxMPVEJTIFg1MDkg
+Q0EgU0dDMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsgOkO3f7wzN6
+rOjg45tR5vjBfzK7qmV9IBxb/QW9EEXxG+E7FNhZqQLtwGBKoSsHTnQqV75wWMk0
+9tinWvftBkSpj5sTi/8cbzJfUvTSVYh3Qxv6AVVjMMH/ruLjE6y+4PoaPs8WoYAQ
+ts5R4Z1g8c/WnTepLst2x0/Wv7GmuoQi+gXvHU6YrBiu7XkeYhzc95QdviWSJRDk
+owhb5K43qhcvjRmBfO/paGlCliDGZp8mHwrI21mwobWpVjTxZRwYO3bd4+TGcI4G
+Ie5wmHwE8F7SK1tgSqbBacKjDa93j7txKkfz/Yd2n7TGqOXiHPsJpG655vrKtnXk
+9vs1zoDeJQIDAQABo4IBljCCAZIwHQYDVR0OBBYEFAdEdoWTKLx/bXjSCuv6TEvf
+2YIfMA4GA1UdDwEB/wQEAwIBBjASBgNVHRMBAf8ECDAGAQH/AgEAMCAGA1UdJQQZ
+MBcGCisGAQQBgjcKAwMGCWCGSAGG+EIEATAYBgNVHSAEETAPMA0GCysGAQQBgOU3
+AgQBMHsGA1UdHwR0MHIwOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29tL0Fk
+ZFRydXN0RXh0ZXJuYWxDQVJvb3QuY3JsMDagNKAyhjBodHRwOi8vY3JsLmNvbW9k
+by5uZXQvQWRkVHJ1c3RFeHRlcm5hbENBUm9vdC5jcmwwgYAGCCsGAQUFBwEBBHQw
+cjA4BggrBgEFBQcwAoYsaHR0cDovL2NydC5jb21vZG9jYS5jb20vQWRkVHJ1c3RV
+VE5TR0NDQS5jcnQwNgYIKwYBBQUHMAKGKmh0dHA6Ly9jcnQuY29tb2RvLm5ldC9B
+ZGRUcnVzdFVUTlNHQ0NBLmNydDARBglghkgBhvhCAQEEBAMCAgQwDQYJKoZIhvcN
+AQEFBQADggEBAK2zEzs+jcIrVK9oDkdDZNvhuBYTdCfpxfFs+OAujW0bIfJAy232
+euVsnJm6u/+OrqKudD2tad2BbejLLXhMZViaCmK7D9nrXHx4te5EP8rL19SUVqLY
+1pTnv5dhNgEgvA7n5lIzDSYs7yRLsr7HJsYPr6SeYSuZizyX1SNz7ooJ32/F3X98
+RB0Mlc/E0OyOrkQ9/y5IrnpnaSora8CnUrV5XNOg+kyCz9edCyx4D5wXYcwZPVWz
+8aDqquESrezPyjtfi4WRO4s/VD3HLZvOxzMrWAVYCDG9FxaOhF0QGuuG1F7F3GKV
+v6prNyCl016kRl2j1UT+a7gLd8fA25A4C9E=
-----END CERTIFICATE-----
2 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
- i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware
+ i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
-----BEGIN CERTIFICATE-----
-MIIETzCCAzegAwIBAgIQHM5EYpUZep1jUvnyI6m2mDANBgkqhkiG9w0BAQUFADCB
-lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
+MIIEZjCCA06gAwIBAgIQUSYKkxzif5zDpV954HKugjANBgkqhkiG9w0BAQUFADCB
+kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
-dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt
-SGFyZHdhcmUwHhcNMDUwNjA3MDgwOTEwWhcNMTkwNzA5MTgxOTIyWjBvMQswCQYD
-VQQGEwJTRTEUMBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0
-IEV4dGVybmFsIFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5h
-bCBDQSBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAt/caM+by
-AAQtOeBOW+0fvGwPzbX6I7bO3psRM5ekKUx9k5+9SryT7QMa44/P5W1QWtaXKZRa
-gLBJetsulf24yr83OC0ePpFBrXBWx/BPP+gynnTKyJBU6cZfD3idmkA8Dqxhql4U
-j56HoWpQ3NeaTq8Fs6ZxlJxxs1BgCscTnTgHhgKo6ahpJhiQq0ywTyOrOk+E2N/O
-n+Fpb7vXQtdrROTHre5tQV9yWnEIN7N5ZaRZoJQ39wAvDcKSctrQOHLbFKhFxF0q
-fbe01sTurM0TRLfJK91DACX6YblpalgjEbenM49WdVn1zSnXRrcKK2W200JvFbK4
-e/vv6V1T1TRaJwIDAQABo4G9MIG6MB8GA1UdIwQYMBaAFKFyXyYbKJhDlV0HN9WF
-lp1L0sNFMB0GA1UdDgQWBBStvZh6NLQm9/rEJlTvA73gJMtUGjAOBgNVHQ8BAf8E
-BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zARBglghkgBhvhCAQEEBAMCAQIwRAYDVR0f
-BD0wOzA5oDegNYYzaHR0cDovL2NybC51c2VydHJ1c3QuY29tL1VUTi1VU0VSRmly
-c3QtSGFyZHdhcmUuY3JsMA0GCSqGSIb3DQEBBQUAA4IBAQByQhANOs4kClrwF8BW
-onvUOGCSjRK52zYZgDXYNjDtmr5rJ6NyPFDNn+JxkLpjYetIFMTbSRe679Bt8m7a
-gIAoQYFQtxMuyLnJegB2aEbQiIxh/tC21UcFF7ktdnDoTlA6w3pLuvunaI84Of3o
-2YBrhzkTbCfaYk5JRlTpudW9DkUkHBsyx3nknPKnplkIGaK0jgn8E0n+SFabYaHk
-I9LroYT/+JtLefh9lgBdAgVv0UPbzoGfuDsrk/Zh+UrgbLFpHoVnElhzbkh64Z0X
-OGaJunQc68cCZu5HTn/aK7fBGMcVflRCXLVEQpU9PIAdGA8Ynvg684t8GMaKsRl1
-jIGZ
+dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw
+IFNHQzAeFw0wNTA2MDcwODA5MTBaFw0xOTA2MjQxOTA2MzBaMG8xCzAJBgNVBAYT
+AlNFMRQwEgYDVQQKEwtBZGRUcnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0
+ZXJuYWwgVFRQIE5ldHdvcmsxIjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENB
+IFJvb3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC39xoz5vIABC05
+4E5b7R+8bA/Ntfojts7emxEzl6QpTH2Tn71KvJPtAxrjj8/lbVBa1pcplFqAsEl6
+2y6V/bjKvzc4LR4+kUGtcFbH8E8/6DKedMrIkFTpxl8PeJ2aQDwOrGGqXhSPnoeh
+alDc15pOrwWzpnGUnHGzUGAKxxOdOAeGAqjpqGkmGJCrTLBPI6s6T4TY386f4Wlv
+u9dC12tE5Met7m1BX3JacQg3s3llpFmglDf3AC8NwpJy2tA4ctsUqEXEXSp9t7TW
+xO6szRNEt8kr3UMAJfphuWlqWCMRt6czj1Z1WfXNKddGtworZbbTQm8Vsrh7++/p
+XVPVNFonAgMBAAGjgdgwgdUwHwYDVR0jBBgwFoAUUzLRs89/+uDxoF2FTpLSnkUd
+tE8wHQYDVR0OBBYEFK29mHo0tCb3+sQmVO8DveAky1QaMA4GA1UdDwEB/wQEAwIB
+BjAPBgNVHRMBAf8EBTADAQH/MBEGCWCGSAGG+EIBAQQEAwIBAjAgBgNVHSUEGTAX
+BgorBgEEAYI3CgMDBglghkgBhvhCBAEwPQYDVR0fBDYwNDAyoDCgLoYsaHR0cDov
+L2NybC51c2VydHJ1c3QuY29tL1VUTi1EQVRBQ29ycFNHQy5jcmwwDQYJKoZIhvcN
+AQEFBQADggEBAMbuUxdoFLJRIh6QWA2U/b3xcOWGLcM2MY9USEbnLQg3vGwKYOEO
+rVE04BKT6b64q7gmtOmWPSiPrmQH/uAB7MXjkesYoPF1ftsK5p+R26+udd8jkWjd
+FwBaS/9kbHDrARrQkNnHptZt9hPk/7XJ0h4qy7ElQyZ42TCbTg0evmnv3+r+LbPM
++bDdtRTKkdSytaX7ARmjR3mfnYyVhzT4HziS2jamEfpr62vp3EV4FTkG101B5CHI
+3C+H0be/SGB1pWLLJN47YaApIKa+xWycxOkKaSLvkTr6Jq/RW0GnOuL4OAdCq8Fb
++M5tug8EPzI0rNwEKNdwMBQmBsTkm5jVz3g=
-----END CERTIFICATE-----
- 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware
- i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware
+ 3 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
+ i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN - DATACorp SGC
-----BEGIN CERTIFICATE-----
-MIIEdDCCA1ygAwIBAgIQRL4Mi1AAJLQR0zYq/mUK/TANBgkqhkiG9w0BAQUFADCB
-lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
+MIIEXjCCA0agAwIBAgIQRL4Mi1AAIbQR0ypoBqmtaTANBgkqhkiG9w0BAQUFADCB
+kzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
-dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt
-SGFyZHdhcmUwHhcNOTkwNzA5MTgxMDQyWhcNMTkwNzA5MTgxOTIyWjCBlzELMAkG
-A1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2UgQ2l0eTEe
-MBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExhodHRwOi8v
-d3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3QtSGFyZHdh
-cmUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCx98M4P7Sof885glFn
-0G2f0v9Y8+efK+wNiVSZuTiZFvfgIXlIwrthdBKWHTxqctU8EGc6Oe0rE81m65UJ
-M6Rsl7HoxuzBdXmcRl6Nq9Bq/bkqVRcQVLMZ8Jr28bFdtqdt++BxF2uiiPsA3/4a
-MXcMmgF6sTLjKwEHOG7DpV4jvEWbe1DByTCP2+UretNb+zNAHqDVmBe8i4fDidNd
-oI6yqqr2jmmIBsX6iSHzCJ1pLgkzmykNRg+MzEk0sGlRvfkGzWitZky8PqxhvQqI
-DsjfPe58BEydCl5rkdbux+0ojatNh4lz0G6k0B4WixThdkQDf2Os5M1JnMWS9Ksy
-oUhbAgMBAAGjgbkwgbYwCwYDVR0PBAQDAgHGMA8GA1UdEwEB/wQFMAMBAf8wHQYD
-VR0OBBYEFKFyXyYbKJhDlV0HN9WFlp1L0sNFMEQGA1UdHwQ9MDswOaA3oDWGM2h0
-dHA6Ly9jcmwudXNlcnRydXN0LmNvbS9VVE4tVVNFUkZpcnN0LUhhcmR3YXJlLmNy
-bDAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYBBQUHAwUGCCsGAQUFBwMGBggrBgEF
-BQcDBzANBgkqhkiG9w0BAQUFAAOCAQEARxkP3nTGmZev/K0oXnWO6y1n7k57K9cM
-//bey1WiCuFMVGWTYGufEpytXoMs61quwOQt9ABjHbjAbPLPSbtNk28Gpgoiskli
-CE7/yMgUsogWXecB5BKV5UU0s4tpvc+0hY91UZ59Ojg6FEgSxvunOxqNDYJAB+gE
-CJChicsZUN/KHAG8HQQZexB2lzvukJDKxA4fFm517zP4029bHpbj4HR3dHuKom4t
-3XbWOTCC8KucUvIqx69JXn7HaOWCgchqJ/kniCrVWFCVH/A7HFe7fRQ5YiuayZSS
-KqMiDP+JJn1fIytH1xUdqWqeUQ0qUZ6B+dQ7XnASfxAynB67nfhmqA==
+dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xGzAZBgNVBAMTElVUTiAtIERBVEFDb3Jw
+IFNHQzAeFw05OTA2MjQxODU3MjFaFw0xOTA2MjQxOTA2MzBaMIGTMQswCQYDVQQG
+EwJVUzELMAkGA1UECBMCVVQxFzAVBgNVBAcTDlNhbHQgTGFrZSBDaXR5MR4wHAYD
+VQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxITAfBgNVBAsTGGh0dHA6Ly93d3cu
+dXNlcnRydXN0LmNvbTEbMBkGA1UEAxMSVVROIC0gREFUQUNvcnAgU0dDMIIBIjAN
+BgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3+5YEKIrblXEjr8uRgnn4AgPLit6
+E5Qbvfa2gI5lBZMAHryv4g+OGQ0SR+ysraP6LnD43m77VkIVni5c7yPeIbkFdicZ
+D0/Ww5y0vpQZY/KmEQrrU0icvvIpOxboGqBMpsn0GFlowHDyUwDAXlCCpVZvNvlK
+4ESGoE1O1kduSUrLZ9emxAW5jh70/P/N5zbgnAVssjMiFdC04MwXwLLA9P4yPykq
+lXvY8qdOD1R8oQ2AswkDwf9c3V6aPryuvEeKaq5xyh+xKrhfQgUL7EYw0XILyulW
+bfXv33i+Ybqypa4ETLyorGkVl73v67SMvzX41MPRKA5cOp9wGDMgd8SirwIDAQAB
+o4GrMIGoMAsGA1UdDwQEAwIBxjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRT
+MtGzz3/64PGgXYVOktKeRR20TzA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8vY3Js
+LnVzZXJ0cnVzdC5jb20vVVROLURBVEFDb3JwU0dDLmNybDAqBgNVHSUEIzAhBggr
+BgEFBQcDAQYKKwYBBAGCNwoDAwYJYIZIAYb4QgQBMA0GCSqGSIb3DQEBBQUAA4IB
+AQAnNZcAiosovcYzMB4p/OL31ZjUQLtgyr+rFywJNn9Q+kHcrpY6CiM+iVnJowft
+Gzet/Hy+UUla3joKVAgWRcKZsYfNjGjgaQPpxE6YsjuMFrMOoAyYUJuTqXAJyCyj
+j98C5OBxOvG0I3KgqgHf35g+FFCgMSa9KOlaMCZ1+XtgHI3zzVAmbQQnmt/VDUVH
+KWss5nbZqSl9Mt3JNjy9rjXxEZ4du5A/EkdOjtd+D2JzHVImOBwYSf0wdJrE5SIv
+2MCN7ZF6TACPcn9d2t0bi0Vr591pl6jFVkwPDPafepE39peC4N1xaf92P2BNPM/3
+mfnGV/TJVTl4uix5yaaIK/QI
-----END CERTIFICATE-----
diff --git a/Lib/test/sndhdrdata/README b/Lib/test/sndhdrdata/README
new file mode 100644
index 00000000000..8a17c0041a4
--- /dev/null
+++ b/Lib/test/sndhdrdata/README
@@ -0,0 +1,12 @@
+Sound file samples used by Lib/test/test_sndhdr.py and generated using the
+following commands:
+
+ dd if=/dev/zero of=sndhdr.raw bs=20 count=1
+ sox -s -2 -c 2 -r 44100 sndhdr.raw sndhdr.<format>
+
+Sound file samples used by Lib/test/test_sndhdr.py and generated using the
+following commands:
+
+ dd if=/dev/zero of=sndhdr.raw bs=20 count=1
+ sox -s -2 -c 2 -r 44100 sndhdr.raw sndhdr.<format>
+
diff --git a/Lib/test/sndhdrdata/sndhdr.8svx b/Lib/test/sndhdrdata/sndhdr.8svx
new file mode 100644
index 00000000000..8cd6cde5e09
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.8svx
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.aifc b/Lib/test/sndhdrdata/sndhdr.aifc
new file mode 100644
index 00000000000..8aae4e730bd
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.aifc
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.aiff b/Lib/test/sndhdrdata/sndhdr.aiff
new file mode 100644
index 00000000000..8c279a762f1
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.aiff
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.au b/Lib/test/sndhdrdata/sndhdr.au
new file mode 100644
index 00000000000..67c9e8fdd99
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.au
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.hcom b/Lib/test/sndhdrdata/sndhdr.hcom
new file mode 100644
index 00000000000..debb02d9dd9
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.hcom
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.sndt b/Lib/test/sndhdrdata/sndhdr.sndt
new file mode 100644
index 00000000000..e1ca9cb185d
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.sndt
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.voc b/Lib/test/sndhdrdata/sndhdr.voc
new file mode 100644
index 00000000000..53a91fd1eae
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.voc
Binary files differ
diff --git a/Lib/test/sndhdrdata/sndhdr.wav b/Lib/test/sndhdrdata/sndhdr.wav
new file mode 100644
index 00000000000..0dca36739cd
--- /dev/null
+++ b/Lib/test/sndhdrdata/sndhdr.wav
Binary files differ
diff --git a/Lib/test/sortperf.py b/Lib/test/sortperf.py
index cc83ee43d9e..0ce88de4c16 100644
--- a/Lib/test/sortperf.py
+++ b/Lib/test/sortperf.py
@@ -24,7 +24,7 @@ def randfloats(n):
fp = open(fn, "rb")
except IOError:
r = random.random
- result = [r() for i in xrange(n)]
+ result = [r() for i in range(n)]
try:
try:
fp = open(fn, "wb")
@@ -37,8 +37,8 @@ def randfloats(n):
os.unlink(fn)
except os.error:
pass
- except IOError, msg:
- print "can't write", fn, ":", msg
+ except IOError as msg:
+ print("can't write", fn, ":", msg)
else:
result = marshal.load(fp)
fp.close()
@@ -60,7 +60,7 @@ def doit(L):
t0 = time.clock()
L.sort()
t1 = time.clock()
- print "%6.2f" % (t1-t0),
+ print("%6.2f" % (t1-t0), end=' ')
flush()
def tabulate(r):
@@ -84,11 +84,11 @@ def tabulate(r):
"""
cases = tuple([ch + "sort" for ch in r"*\/3+%~=!"])
fmt = ("%2s %7s" + " %6s"*len(cases))
- print fmt % (("i", "2**i") + cases)
+ print(fmt % (("i", "2**i") + cases))
for i in r:
n = 1 << i
L = randfloats(n)
- print "%2d %7d" % (i, n),
+ print("%2d %7d" % (i, n), end=' ')
flush()
doit(L) # *sort
L.reverse()
@@ -108,7 +108,7 @@ def tabulate(r):
doit(L) # +sort
# Replace 1% of the elements at random.
- for dummy in xrange(n // 100):
+ for dummy in range(n // 100):
L[random.randrange(n)] = random.random()
doit(L) # %sort
@@ -118,12 +118,12 @@ def tabulate(r):
L = L * (n // 4)
# Force the elements to be distinct objects, else timings can be
# artificially low.
- L = map(lambda x: --x, L)
+ L = list(map(lambda x: --x, L))
doit(L) # ~sort
del L
# All equal. Again, force the elements to be distinct objects.
- L = map(abs, [-0.5] * n)
+ L = list(map(abs, [-0.5] * n))
doit(L) # =sort
del L
@@ -131,13 +131,13 @@ def tabulate(r):
# for an older implementation of quicksort, which used the median
# of the first, last and middle elements as the pivot.
half = n // 2
- L = range(half - 1, -1, -1)
+ L = list(range(half - 1, -1, -1))
L.extend(range(half))
# Force to float, so that the timings are comparable. This is
# significantly faster if we leave tham as ints.
- L = map(float, L)
+ L = list(map(float, L))
doit(L) # !sort
- print
+ print()
def main():
"""Main program when invoked as a script.
diff --git a/Lib/test/ssl_cert.pem b/Lib/test/ssl_cert.pem
index 9d7ac238d86..47a7d7e37e8 100644
--- a/Lib/test/ssl_cert.pem
+++ b/Lib/test/ssl_cert.pem
@@ -1,14 +1,15 @@
-----BEGIN CERTIFICATE-----
-MIICLDCCAdYCAQAwDQYJKoZIhvcNAQEEBQAwgaAxCzAJBgNVBAYTAlBUMRMwEQYD
-VQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5ldXJv
-bmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMTEmJy
-dXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZpMB4X
-DTk2MDkwNTAzNDI0M1oXDTk2MTAwNTAzNDI0M1owgaAxCzAJBgNVBAYTAlBUMRMw
-EQYDVQQIEwpRdWVlbnNsYW5kMQ8wDQYDVQQHEwZMaXNib2ExFzAVBgNVBAoTDk5l
-dXJvbmlvLCBMZGEuMRgwFgYDVQQLEw9EZXNlbnZvbHZpbWVudG8xGzAZBgNVBAMT
-EmJydXR1cy5uZXVyb25pby5wdDEbMBkGCSqGSIb3DQEJARYMc2FtcG9AaWtpLmZp
-MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNw
-L4lYKbpzzlmC5beaQXeQ2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAATAN
-BgkqhkiG9w0BAQQFAANBAFqPEKFjk6T6CKTHvaQeEAsX0/8YHPHqH/9AnhSjrwuX
-9EBc0n6bVGhN7XaXd6sJ7dym9sbsWxb+pJdurnkxjx4=
+MIICVDCCAb2gAwIBAgIJANfHOBkZr8JOMA0GCSqGSIb3DQEBBQUAMF8xCzAJBgNV
+BAYTAlhZMRcwFQYDVQQHEw5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9u
+IFNvZnR3YXJlIEZvdW5kYXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xMDEw
+MDgyMzAxNTZaFw0yMDEwMDUyMzAxNTZaMF8xCzAJBgNVBAYTAlhZMRcwFQYDVQQH
+Ew5DYXN0bGUgQW50aHJheDEjMCEGA1UEChMaUHl0aG9uIFNvZnR3YXJlIEZvdW5k
+YXRpb24xEjAQBgNVBAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
+gYkCgYEA21vT5isq7F68amYuuNpSFlKDPrMUCa4YWYqZRt2OZ+/3NKaZ2xAiSwr7
+6MrQF70t5nLbSPpqE5+5VrS58SY+g/sXLiFd6AplH1wJZwh78DofbFYXUggktFMt
+pTyiX8jtP66bkcPkDADA089RI1TQR6Ca+n7HFa7c1fabVV6i3zkCAwEAAaMYMBYw
+FAYDVR0RBA0wC4IJbG9jYWxob3N0MA0GCSqGSIb3DQEBBQUAA4GBAHPctQBEQ4wd
+BJ6+JcpIraopLn8BGhbjNWj40mmRqWB/NAWF6M5ne7KpGAu7tLeG4hb1zLaldK8G
+lxy2GPSRF6LFS48dpEj2HbMv2nvv6xxalDMJ9+DicWgAKTQ6bcX2j3GUkCR0g/T1
+CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX
-----END CERTIFICATE-----
diff --git a/Lib/test/ssl_key.pem b/Lib/test/ssl_key.pem
index 239ad66f990..3fd3bbd54a3 100644
--- a/Lib/test/ssl_key.pem
+++ b/Lib/test/ssl_key.pem
@@ -1,9 +1,16 @@
------BEGIN RSA PRIVATE KEY-----
-MIIBPAIBAAJBAL7+aty3S1iBA/+yxjxv4q1MUTd1kjNwL4lYKbpzzlmC5beaQXeQ
-2RmGMTXU+mDvuqItjVHOK3DvPK7lTcSGftUCAwEAAQJBALjkK+jc2+iihI98riEF
-oudmkNziSRTYjnwjx8mCoAjPWviB3c742eO3FG4/soi1jD9A5alihEOXfUzloenr
-8IECIQD3B5+0l+68BA/6d76iUNqAAV8djGTzvxnCxycnxPQydQIhAMXt4trUI3nc
-a+U8YL2HPFA3gmhBsSICbq2OptOCnM7hAiEA6Xi3JIQECob8YwkRj29DU3/4WYD7
-WLPgsQpwo1GuSpECICGsnWH5oaeD9t9jbFoSfhJvv0IZmxdcLpRcpslpeWBBAiEA
-6/5B8J0GHdJq89FHwEG/H2eVVUYu5y/aD6sgcm+0Avg=
------END RSA PRIVATE KEY-----
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm
+LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0
+ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP
+USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt
+CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq
+SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK
+UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y
+BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ
+ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5
+oPIfAkEA8pDddarP5tCvTTgUpmTFbakm0KoTZm2+FzHcnA4jRh+XNTjTOv98Y6Ik
+eO5d1ZnKXseWvkZncQgxfdnMqqpj5wJAcNq/RVne1DbYlwWchT2Si65MYmmJ8t+F
+0mcsULqjOnEMwf5e+ptq5LzwbyrHZYq5FNk7ocufPv/ZQrcSSC+cFwJBAKvOJByS
+x56qyGeZLOQlWS2JS3KJo59XuLFGqcbgN9Om9xFa41Yb4N9NvplFivsvZdw3m1Q/
+SPIXQuT8RMPDVNQ=
+-----END PRIVATE KEY-----
diff --git a/Lib/test/ssl_servers.py b/Lib/test/ssl_servers.py
new file mode 100644
index 00000000000..77c05426107
--- /dev/null
+++ b/Lib/test/ssl_servers.py
@@ -0,0 +1,189 @@
+import os
+import sys
+import ssl
+import pprint
+import socket
+import urllib.parse
+# Rename HTTPServer to _HTTPServer so as to avoid confusion with HTTPSServer.
+from http.server import (HTTPServer as _HTTPServer,
+ SimpleHTTPRequestHandler, BaseHTTPRequestHandler)
+
+from test import support
+threading = support.import_module("threading")
+
+here = os.path.dirname(__file__)
+
+HOST = support.HOST
+CERTFILE = os.path.join(here, 'keycert.pem')
+
+# This one's based on HTTPServer, which is based on SocketServer
+
+class HTTPSServer(_HTTPServer):
+
+ def __init__(self, server_address, handler_class, context):
+ _HTTPServer.__init__(self, server_address, handler_class)
+ self.context = context
+
+ def __str__(self):
+ return ('<%s %s:%s>' %
+ (self.__class__.__name__,
+ self.server_name,
+ self.server_port))
+
+ def get_request(self):
+ # override this to wrap socket with SSL
+ try:
+ sock, addr = self.socket.accept()
+ sslconn = self.context.wrap_socket(sock, server_side=True)
+ except socket.error as e:
+ # socket errors are silenced by the caller, print them here
+ if support.verbose:
+ sys.stderr.write("Got an error:\n%s\n" % e)
+ raise
+ return sslconn, addr
+
+class RootedHTTPRequestHandler(SimpleHTTPRequestHandler):
+ # need to override translate_path to get a known root,
+ # instead of using os.curdir, since the test could be
+ # run from anywhere
+
+ server_version = "TestHTTPS/1.0"
+ root = here
+ # Avoid hanging when a request gets interrupted by the client
+ timeout = 5
+
+ def translate_path(self, path):
+ """Translate a /-separated PATH to the local filename syntax.
+
+ Components that mean special things to the local file system
+ (e.g. drive or directory names) are ignored. (XXX They should
+ probably be diagnosed.)
+
+ """
+ # abandon query parameters
+ path = urllib.parse.urlparse(path)[2]
+ path = os.path.normpath(urllib.parse.unquote(path))
+ words = path.split('/')
+ words = filter(None, words)
+ path = self.root
+ for word in words:
+ drive, word = os.path.splitdrive(word)
+ head, word = os.path.split(word)
+ path = os.path.join(path, word)
+ return path
+
+ def log_message(self, format, *args):
+ # we override this to suppress logging unless "verbose"
+ if support.verbose:
+ sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" %
+ (self.server.server_address,
+ self.server.server_port,
+ self.request.cipher(),
+ self.log_date_time_string(),
+ format%args))
+
+
+class StatsRequestHandler(BaseHTTPRequestHandler):
+ """Example HTTP request handler which returns SSL statistics on GET
+ requests.
+ """
+
+ server_version = "StatsHTTPS/1.0"
+
+ def do_GET(self, send_body=True):
+ """Serve a GET request."""
+ sock = self.rfile.raw._sock
+ context = sock.context
+ body = pprint.pformat(context.session_stats())
+ body = body.encode('utf-8')
+ self.send_response(200)
+ self.send_header("Content-type", "text/plain; charset=utf-8")
+ self.send_header("Content-Length", str(len(body)))
+ self.end_headers()
+ if send_body:
+ self.wfile.write(body)
+
+ def do_HEAD(self):
+ """Serve a HEAD request."""
+ self.do_GET(send_body=False)
+
+ def log_request(self, format, *args):
+ if support.verbose:
+ BaseHTTPRequestHandler.log_request(self, format, *args)
+
+
+class HTTPSServerThread(threading.Thread):
+
+ def __init__(self, context, host=HOST, handler_class=None):
+ self.flag = None
+ self.server = HTTPSServer((host, 0),
+ handler_class or RootedHTTPRequestHandler,
+ context)
+ self.port = self.server.server_port
+ threading.Thread.__init__(self)
+ self.daemon = True
+
+ def __str__(self):
+ return "<%s %s>" % (self.__class__.__name__, self.server)
+
+ def start(self, flag=None):
+ self.flag = flag
+ threading.Thread.start(self)
+
+ def run(self):
+ if self.flag:
+ self.flag.set()
+ try:
+ self.server.serve_forever(0.05)
+ finally:
+ self.server.server_close()
+
+ def stop(self):
+ self.server.shutdown()
+
+
+def make_https_server(case, certfile=CERTFILE, host=HOST, handler_class=None):
+ # we assume the certfile contains both private key and certificate
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.load_cert_chain(certfile)
+ server = HTTPSServerThread(context, host, handler_class)
+ flag = threading.Event()
+ server.start(flag)
+ flag.wait()
+ def cleanup():
+ if support.verbose:
+ sys.stdout.write('stopping HTTPS server\n')
+ server.stop()
+ if support.verbose:
+ sys.stdout.write('joining HTTPS thread\n')
+ server.join()
+ case.addCleanup(cleanup)
+ return server
+
+
+if __name__ == "__main__":
+ import argparse
+ parser = argparse.ArgumentParser(
+ description='Run a test HTTPS server. '
+ 'By default, the current directory is served.')
+ parser.add_argument('-p', '--port', type=int, default=4433,
+ help='port to listen on (default: %(default)s)')
+ parser.add_argument('-q', '--quiet', dest='verbose', default=True,
+ action='store_false', help='be less verbose')
+ parser.add_argument('-s', '--stats', dest='use_stats_handler', default=False,
+ action='store_true', help='always return stats page')
+ args = parser.parse_args()
+
+ support.verbose = args.verbose
+ if args.use_stats_handler:
+ handler_class = StatsRequestHandler
+ else:
+ handler_class = RootedHTTPRequestHandler
+ handler_class.root = os.getcwd()
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.load_cert_chain(CERTFILE)
+
+ server = HTTPSServer(("", args.port), handler_class, context)
+ if args.verbose:
+ print("Listening on https://localhost:{0.port}".format(args))
+ server.serve_forever(0.1)
diff --git a/Lib/test/string_tests.py b/Lib/test/string_tests.py
index a1615126349..413f9dd8fea 100644
--- a/Lib/test/string_tests.py
+++ b/Lib/test/string_tests.py
@@ -3,8 +3,8 @@ Common tests shared by test_str, test_unicode, test_userstring and test_string.
"""
import unittest, string, sys, struct
-from test import test_support
-from UserList import UserList
+from test import support
+from collections import UserList
class Sequence:
def __init__(self, seq='wxyz'): self.seq = seq
@@ -12,16 +12,17 @@ class Sequence:
def __getitem__(self, i): return self.seq[i]
class BadSeq1(Sequence):
- def __init__(self): self.seq = [7, 'hello', 123L]
+ def __init__(self): self.seq = [7, 'hello', 123]
+ def __str__(self): return '{0} {1} {2}'.format(*self.seq)
class BadSeq2(Sequence):
def __init__(self): self.seq = ['a', 'b', 'c']
def __len__(self): return 8
-class CommonTest(unittest.TestCase):
- # This testcase contains test that can be used in all
- # stringlike classes. Currently this is str, unicode
- # UserString and the string module.
+class BaseTest(unittest.TestCase):
+ # These tests are for buffers of values (bytes) and not
+ # specific to character interpretation, used for bytes objects
+ # and various string implementations
# The type to be tested
# Change in subclasses to change the behaviour of fixtesttype()
@@ -40,63 +41,49 @@ class CommonTest(unittest.TestCase):
elif isinstance(obj, dict):
return dict([
(self.fixtype(key), self.fixtype(value))
- for (key, value) in obj.iteritems()
+ for (key, value) in obj.items()
])
else:
return obj
- # check that object.method(*args) returns result
- def checkequal(self, result, object, methodname, *args):
+ # check that obj.method(*args) returns result
+ def checkequal(self, result, obj, methodname, *args):
result = self.fixtype(result)
- object = self.fixtype(object)
+ obj = self.fixtype(obj)
args = self.fixtype(args)
- realresult = getattr(object, methodname)(*args)
+ realresult = getattr(obj, methodname)(*args)
self.assertEqual(
result,
realresult
)
# if the original is returned make sure that
# this doesn't happen with subclasses
- if object == realresult:
- class subtype(self.__class__.type2test):
- pass
- object = subtype(object)
- realresult = getattr(object, methodname)(*args)
- self.assertTrue(object is not realresult)
-
- # check that object.method(*args) raises exc
- def checkraises(self, exc, object, methodname, *args):
- object = self.fixtype(object)
+ if obj is realresult:
+ try:
+ class subtype(self.__class__.type2test):
+ pass
+ except TypeError:
+ pass # Skip this if we can't subclass
+ else:
+ obj = subtype(obj)
+ realresult = getattr(obj, methodname)(*args)
+ self.assertIsNot(obj, realresult)
+
+ # check that obj.method(*args) raises exc
+ def checkraises(self, exc, obj, methodname, *args):
+ obj = self.fixtype(obj)
args = self.fixtype(args)
self.assertRaises(
exc,
- getattr(object, methodname),
+ getattr(obj, methodname),
*args
)
- # call object.method(*args) without any checks
- def checkcall(self, object, methodname, *args):
- object = self.fixtype(object)
+ # call obj.method(*args) without any checks
+ def checkcall(self, obj, methodname, *args):
+ obj = self.fixtype(obj)
args = self.fixtype(args)
- getattr(object, methodname)(*args)
-
- def test_hash(self):
- # SF bug 1054139: += optimization was not invalidating cached hash value
- a = self.type2test('DNSSEC')
- b = self.type2test('')
- for c in a:
- b += c
- hash(b)
- self.assertEqual(hash(a), hash(b))
-
- def test_capitalize(self):
- self.checkequal(' hello ', ' hello ', 'capitalize')
- self.checkequal('Hello ', 'Hello ','capitalize')
- self.checkequal('Hello ', 'hello ','capitalize')
- self.checkequal('Aaaa', 'aaaa', 'capitalize')
- self.checkequal('Aaaa', 'AaAa', 'capitalize')
-
- self.checkraises(TypeError, 'hello', 'capitalize', 42)
+ getattr(obj, methodname)(*args)
def test_count(self):
self.checkequal(3, 'aaa', 'count', 'a')
@@ -122,11 +109,11 @@ class CommonTest(unittest.TestCase):
self.checkequal(1, '', 'count', '')
self.checkequal(0, '', 'count', '', 1, 1)
- self.checkequal(0, '', 'count', '', sys.maxint, 0)
+ self.checkequal(0, '', 'count', '', sys.maxsize, 0)
self.checkequal(0, '', 'count', 'xx')
self.checkequal(0, '', 'count', 'xx', 1, 1)
- self.checkequal(0, '', 'count', 'xx', sys.maxint, 0)
+ self.checkequal(0, '', 'count', 'xx', sys.maxsize, 0)
self.checkraises(TypeError, 'hello', 'count')
self.checkraises(TypeError, 'hello', 'count', 42)
@@ -138,20 +125,20 @@ class CommonTest(unittest.TestCase):
digits = 7
base = len(charset)
teststrings = set()
- for i in xrange(base ** digits):
+ for i in range(base ** digits):
entry = []
- for j in xrange(digits):
+ for j in range(digits):
i, m = divmod(i, base)
entry.append(charset[m])
teststrings.add(''.join(entry))
- teststrings = list(teststrings)
+ teststrings = [self.fixtype(ts) for ts in teststrings]
for i in teststrings:
- i = self.fixtype(i)
n = len(i)
for j in teststrings:
r1 = i.count(j)
if j:
- r2, rem = divmod(n - len(i.replace(j, '')), len(j))
+ r2, rem = divmod(n - len(i.replace(j, self.fixtype(''))),
+ len(j))
else:
r2, rem = len(i)+1, 0
if rem or r1 != r2:
@@ -179,11 +166,11 @@ class CommonTest(unittest.TestCase):
self.checkequal(0, '', 'find', '')
self.checkequal(-1, '', 'find', '', 1, 1)
- self.checkequal(-1, '', 'find', '', sys.maxint, 0)
+ self.checkequal(-1, '', 'find', '', sys.maxsize, 0)
self.checkequal(-1, '', 'find', 'xx')
self.checkequal(-1, '', 'find', 'xx', 1, 1)
- self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0)
+ self.checkequal(-1, '', 'find', 'xx', sys.maxsize, 0)
# issue 7458
self.checkequal(-1, 'ab', 'find', 'xxx', sys.maxsize + 1, 0)
@@ -195,15 +182,14 @@ class CommonTest(unittest.TestCase):
digits = 5
base = len(charset)
teststrings = set()
- for i in xrange(base ** digits):
+ for i in range(base ** digits):
entry = []
- for j in xrange(digits):
+ for j in range(digits):
i, m = divmod(i, base)
entry.append(charset[m])
teststrings.add(''.join(entry))
- teststrings = list(teststrings)
+ teststrings = [self.fixtype(ts) for ts in teststrings]
for i in teststrings:
- i = self.fixtype(i)
for j in teststrings:
loc = i.find(j)
r1 = (loc != -1)
@@ -239,22 +225,21 @@ class CommonTest(unittest.TestCase):
digits = 5
base = len(charset)
teststrings = set()
- for i in xrange(base ** digits):
+ for i in range(base ** digits):
entry = []
- for j in xrange(digits):
+ for j in range(digits):
i, m = divmod(i, base)
entry.append(charset[m])
teststrings.add(''.join(entry))
- teststrings = list(teststrings)
+ teststrings = [self.fixtype(ts) for ts in teststrings]
for i in teststrings:
- i = self.fixtype(i)
for j in teststrings:
loc = i.rfind(j)
r1 = (loc != -1)
r2 = j in i
self.assertEqual(r1, r2)
if loc != -1:
- self.assertEqual(i[loc:loc+len(j)], self.fixtype(j))
+ self.assertEqual(i[loc:loc+len(j)], j)
# issue 7458
self.checkequal(-1, 'ab', 'rfind', 'xxx', sys.maxsize + 1, 0)
@@ -324,38 +309,11 @@ class CommonTest(unittest.TestCase):
self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
# This test is only valid when sizeof(int) == sizeof(void*) == 4.
- if sys.maxint < (1 << 32) and struct.calcsize('P') == 4:
+ if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4:
self.checkraises(OverflowError,
- '\ta\n\tb', 'expandtabs', sys.maxint)
+ '\ta\n\tb', 'expandtabs', sys.maxsize)
def test_split(self):
- self.checkequal(['this', 'is', 'the', 'split', 'function'],
- 'this is the split function', 'split')
-
- # by whitespace
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split')
- self.checkequal(['a', 'b c d'], 'a b c d', 'split', None, 1)
- self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None,
- sys.maxint-1)
- self.checkequal(['a b c d'], 'a b c d', 'split', None, 0)
- self.checkequal(['a b c d'], ' a b c d', 'split', None, 0)
- self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2)
-
- self.checkequal([], ' ', 'split')
- self.checkequal(['a'], ' a ', 'split')
- self.checkequal(['a', 'b'], ' a b ', 'split')
- self.checkequal(['a', 'b '], ' a b ', 'split', None, 1)
- self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1)
- self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2)
- self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split')
- aaa = ' a '*20
- self.checkequal(['a']*20, aaa, 'split')
- self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1)
- self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19)
-
# by a char
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|')
self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0)
@@ -364,7 +322,7 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3)
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4)
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|',
- sys.maxint-2)
+ sys.maxsize-2)
self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0)
self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2)
self.checkequal(['endcase ', ''], 'endcase |', 'split', '|')
@@ -383,7 +341,7 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3)
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4)
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//',
- sys.maxint-10)
+ sys.maxsize-10)
self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0)
self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2)
self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test')
@@ -405,9 +363,6 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a']*18 + ['aBLAHa'], ('aBLAH'*20)[:-4],
'split', 'BLAH', 18)
- # mixed use of str and unicode
- self.checkequal([u'a', u'b', u'c d'], 'a b c d', 'split', u' ', 2)
-
# argument type
self.checkraises(TypeError, 'hello', 'split', 42, 42, 42)
@@ -416,36 +371,6 @@ class CommonTest(unittest.TestCase):
self.checkraises(ValueError, 'hello', 'split', '', 0)
def test_rsplit(self):
- self.checkequal(['this', 'is', 'the', 'rsplit', 'function'],
- 'this is the rsplit function', 'rsplit')
-
- # by whitespace
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'rsplit')
- self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1)
- self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4)
- self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None,
- sys.maxint-20)
- self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0)
- self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0)
- self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
-
- self.checkequal([], ' ', 'rsplit')
- self.checkequal(['a'], ' a ', 'rsplit')
- self.checkequal(['a', 'b'], ' a b ', 'rsplit')
- self.checkequal([' a', 'b'], ' a b ', 'rsplit', None, 1)
- self.checkequal([' a b','c'], ' a b c ', 'rsplit',
- None, 1)
- self.checkequal([' a', 'b', 'c'], ' a b c ', 'rsplit',
- None, 2)
- self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88)
- aaa = ' a '*20
- self.checkequal(['a']*20, aaa, 'rsplit')
- self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1)
- self.checkequal([' a a'] + ['a']*18, aaa, 'rsplit', None, 18)
-
-
# by a char
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|')
self.checkequal(['a|b|c', 'd'], 'a|b|c|d', 'rsplit', '|', 1)
@@ -453,7 +378,7 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3)
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4)
self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|',
- sys.maxint-100)
+ sys.maxsize-100)
self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0)
self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2)
self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|')
@@ -473,7 +398,7 @@ class CommonTest(unittest.TestCase):
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3)
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4)
self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//',
- sys.maxint-5)
+ sys.maxsize-5)
self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0)
self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2)
self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test')
@@ -495,9 +420,6 @@ class CommonTest(unittest.TestCase):
self.checkequal(['aBLAHa'] + ['a']*18, ('aBLAH'*20)[:-4],
'rsplit', 'BLAH', 18)
- # mixed use of str and unicode
- self.checkequal([u'a b', u'c', u'd'], 'a b c d', 'rsplit', u' ', 2)
-
# argument type
self.checkraises(TypeError, 'hello', 'rsplit', 42, 42, 42)
@@ -505,69 +427,6 @@ class CommonTest(unittest.TestCase):
self.checkraises(ValueError, 'hello', 'rsplit', '')
self.checkraises(ValueError, 'hello', 'rsplit', '', 0)
- def test_strip(self):
- self.checkequal('hello', ' hello ', 'strip')
- self.checkequal('hello ', ' hello ', 'lstrip')
- self.checkequal(' hello', ' hello ', 'rstrip')
- self.checkequal('hello', 'hello', 'strip')
-
- # strip/lstrip/rstrip with None arg
- self.checkequal('hello', ' hello ', 'strip', None)
- self.checkequal('hello ', ' hello ', 'lstrip', None)
- self.checkequal(' hello', ' hello ', 'rstrip', None)
- self.checkequal('hello', 'hello', 'strip', None)
-
- # strip/lstrip/rstrip with str arg
- self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz')
- self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz')
- self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz')
- self.checkequal('hello', 'hello', 'strip', 'xyz')
-
- # strip/lstrip/rstrip with unicode arg
- if test_support.have_unicode:
- self.checkequal(unicode('hello', 'ascii'), 'xyzzyhelloxyzzy',
- 'strip', unicode('xyz', 'ascii'))
- self.checkequal(unicode('helloxyzzy', 'ascii'), 'xyzzyhelloxyzzy',
- 'lstrip', unicode('xyz', 'ascii'))
- self.checkequal(unicode('xyzzyhello', 'ascii'), 'xyzzyhelloxyzzy',
- 'rstrip', unicode('xyz', 'ascii'))
- # XXX
- #self.checkequal(unicode('hello', 'ascii'), 'hello',
- # 'strip', unicode('xyz', 'ascii'))
-
- self.checkraises(TypeError, 'hello', 'strip', 42, 42)
- self.checkraises(TypeError, 'hello', 'lstrip', 42, 42)
- self.checkraises(TypeError, 'hello', 'rstrip', 42, 42)
-
- def test_ljust(self):
- self.checkequal('abc ', 'abc', 'ljust', 10)
- self.checkequal('abc ', 'abc', 'ljust', 6)
- self.checkequal('abc', 'abc', 'ljust', 3)
- self.checkequal('abc', 'abc', 'ljust', 2)
- self.checkequal('abc*******', 'abc', 'ljust', 10, '*')
- self.checkraises(TypeError, 'abc', 'ljust')
-
- def test_rjust(self):
- self.checkequal(' abc', 'abc', 'rjust', 10)
- self.checkequal(' abc', 'abc', 'rjust', 6)
- self.checkequal('abc', 'abc', 'rjust', 3)
- self.checkequal('abc', 'abc', 'rjust', 2)
- self.checkequal('*******abc', 'abc', 'rjust', 10, '*')
- self.checkraises(TypeError, 'abc', 'rjust')
-
- def test_center(self):
- self.checkequal(' abc ', 'abc', 'center', 10)
- self.checkequal(' abc ', 'abc', 'center', 6)
- self.checkequal('abc', 'abc', 'center', 3)
- self.checkequal('abc', 'abc', 'center', 2)
- self.checkequal('***abc****', 'abc', 'center', 10, '*')
- self.checkraises(TypeError, 'abc', 'center')
-
- def test_swapcase(self):
- self.checkequal('hEllO CoMPuTErS', 'HeLLo cOmpUteRs', 'swapcase')
-
- self.checkraises(TypeError, 'hello', 'swapcase', 42)
-
def test_replace(self):
EQ = self.checkequal
@@ -577,7 +436,7 @@ class CommonTest(unittest.TestCase):
EQ("", "", "replace", "A", "")
EQ("", "", "replace", "A", "A")
EQ("", "", "replace", "", "", 100)
- EQ("", "", "replace", "", "", sys.maxint)
+ EQ("", "", "replace", "", "", sys.maxsize)
# interleave (from=="", 'to' gets inserted everywhere)
EQ("A", "A", "replace", "", "")
@@ -586,7 +445,7 @@ class CommonTest(unittest.TestCase):
EQ("*-#A*-#", "A", "replace", "", "*-#")
EQ("*-A*-A*-", "AA", "replace", "", "*-")
EQ("*-A*-A*-", "AA", "replace", "", "*-", -1)
- EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint)
+ EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize)
EQ("*-A*-A*-", "AA", "replace", "", "*-", 4)
EQ("*-A*-A*-", "AA", "replace", "", "*-", 3)
EQ("*-A*-A", "AA", "replace", "", "*-", 2)
@@ -597,7 +456,7 @@ class CommonTest(unittest.TestCase):
EQ("", "A", "replace", "A", "")
EQ("", "AAA", "replace", "A", "")
EQ("", "AAA", "replace", "A", "", -1)
- EQ("", "AAA", "replace", "A", "", sys.maxint)
+ EQ("", "AAA", "replace", "A", "", sys.maxsize)
EQ("", "AAA", "replace", "A", "", 4)
EQ("", "AAA", "replace", "A", "", 3)
EQ("A", "AAA", "replace", "A", "", 2)
@@ -606,7 +465,7 @@ class CommonTest(unittest.TestCase):
EQ("", "AAAAAAAAAA", "replace", "A", "")
EQ("BCD", "ABACADA", "replace", "A", "")
EQ("BCD", "ABACADA", "replace", "A", "", -1)
- EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint)
+ EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize)
EQ("BCD", "ABACADA", "replace", "A", "", 5)
EQ("BCD", "ABACADA", "replace", "A", "", 4)
EQ("BCDA", "ABACADA", "replace", "A", "", 3)
@@ -629,7 +488,7 @@ class CommonTest(unittest.TestCase):
EQ("thaet", "thaet", "replace", "the", "")
EQ("here and re", "here and there", "replace", "the", "")
EQ("here and re and re", "here and there and there",
- "replace", "the", "", sys.maxint)
+ "replace", "the", "", sys.maxsize)
EQ("here and re and re", "here and there and there",
"replace", "the", "", -1)
EQ("here and re and re", "here and there and there",
@@ -654,7 +513,7 @@ class CommonTest(unittest.TestCase):
# single character replace in place (len(from)==len(to)==1)
EQ("Who goes there?", "Who goes there?", "replace", "o", "o")
EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O")
- EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint)
+ EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize)
EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1)
EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3)
EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2)
@@ -671,7 +530,7 @@ class CommonTest(unittest.TestCase):
# substring replace in place (len(from)==len(to) > 1)
EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**")
- EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint)
+ EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize)
EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1)
EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4)
EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3)
@@ -685,7 +544,7 @@ class CommonTest(unittest.TestCase):
# replace single character (len(from)==1, len(to)>1)
EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK")
EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1)
- EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint)
+ EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize)
EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2)
EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1)
EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0)
@@ -697,7 +556,7 @@ class CommonTest(unittest.TestCase):
EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
"replace", "spam", "ham")
EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
- "replace", "spam", "ham", sys.maxint)
+ "replace", "spam", "ham", sys.maxsize)
EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
"replace", "spam", "ham", -1)
EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam",
@@ -715,11 +574,12 @@ class CommonTest(unittest.TestCase):
EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
- with test_support.check_py3k_warnings():
- ba = buffer('a')
- bb = buffer('b')
- EQ("bbc", "abc", "replace", ba, bb)
- EQ("aac", "abc", "replace", bb, ba)
+ # XXX Commented out. Is there any reason to support buffer objects
+ # as arguments for str.replace()? GvR
+## ba = bytearray('a')
+## bb = bytearray('b')
+## EQ("bbc", "abc", "replace", ba, bb)
+## EQ("aac", "abc", "replace", bb, ba)
#
self.checkequal('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
@@ -751,13 +611,191 @@ class CommonTest(unittest.TestCase):
def test_replace_overflow(self):
# Check for overflow checking on 32 bit machines
- if sys.maxint != 2147483647 or struct.calcsize("P") > 4:
+ if sys.maxsize != 2147483647 or struct.calcsize("P") > 4:
return
A2_16 = "A" * (2**16)
self.checkraises(OverflowError, A2_16, "replace", "", A2_16)
self.checkraises(OverflowError, A2_16, "replace", "A", A2_16)
self.checkraises(OverflowError, A2_16, "replace", "AA", A2_16+A2_16)
+
+
+class CommonTest(BaseTest):
+ # This testcase contains test that can be used in all
+ # stringlike classes. Currently this is str, unicode
+ # UserString and the string module.
+
+ def test_hash(self):
+ # SF bug 1054139: += optimization was not invalidating cached hash value
+ a = self.type2test('DNSSEC')
+ b = self.type2test('')
+ for c in a:
+ b += c
+ hash(b)
+ self.assertEqual(hash(a), hash(b))
+
+ def test_capitalize(self):
+ self.checkequal(' hello ', ' hello ', 'capitalize')
+ self.checkequal('Hello ', 'Hello ','capitalize')
+ self.checkequal('Hello ', 'hello ','capitalize')
+ self.checkequal('Aaaa', 'aaaa', 'capitalize')
+ self.checkequal('Aaaa', 'AaAa', 'capitalize')
+
+ # check that titlecased chars are lowered correctly
+ # \u1ffc is the titlecased char
+ self.checkequal('\u1ffc\u1ff3\u1ff3\u1ff3',
+ '\u1ff3\u1ff3\u1ffc\u1ffc', 'capitalize')
+ # check with cased non-letter chars
+ self.checkequal('\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
+ '\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3', 'capitalize')
+ self.checkequal('\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
+ '\u24df\u24e8\u24e3\u24d7\u24de\u24dd', 'capitalize')
+ self.checkequal('\u2160\u2171\u2172',
+ '\u2160\u2161\u2162', 'capitalize')
+ self.checkequal('\u2160\u2171\u2172',
+ '\u2170\u2171\u2172', 'capitalize')
+ # check with Ll chars with no upper - nothing changes here
+ self.checkequal('\u019b\u1d00\u1d86\u0221\u1fb7',
+ '\u019b\u1d00\u1d86\u0221\u1fb7', 'capitalize')
+
+ self.checkraises(TypeError, 'hello', 'capitalize', 42)
+
+ def test_lower(self):
+ self.checkequal('hello', 'HeLLo', 'lower')
+ self.checkequal('hello', 'hello', 'lower')
+ self.checkraises(TypeError, 'hello', 'lower', 42)
+
+ def test_upper(self):
+ self.checkequal('HELLO', 'HeLLo', 'upper')
+ self.checkequal('HELLO', 'HELLO', 'upper')
+ self.checkraises(TypeError, 'hello', 'upper', 42)
+
+ def test_expandtabs(self):
+ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
+ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
+ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 4)
+ self.checkequal('abc\r\nab def\ng hi', 'abc\r\nab\tdef\ng\thi', 'expandtabs', 4)
+ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs')
+ self.checkequal('abc\rab def\ng hi', 'abc\rab\tdef\ng\thi', 'expandtabs', 8)
+ self.checkequal('abc\r\nab\r\ndef\ng\r\nhi', 'abc\r\nab\r\ndef\ng\r\nhi', 'expandtabs', 4)
+
+ self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42)
+
+ def test_additional_split(self):
+ self.checkequal(['this', 'is', 'the', 'split', 'function'],
+ 'this is the split function', 'split')
+
+ # by whitespace
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'split')
+ self.checkequal(['a', 'b c d'], 'a b c d', 'split', None, 1)
+ self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None,
+ sys.maxsize-1)
+ self.checkequal(['a b c d'], 'a b c d', 'split', None, 0)
+ self.checkequal(['a b c d'], ' a b c d', 'split', None, 0)
+ self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2)
+
+ self.checkequal([], ' ', 'split')
+ self.checkequal(['a'], ' a ', 'split')
+ self.checkequal(['a', 'b'], ' a b ', 'split')
+ self.checkequal(['a', 'b '], ' a b ', 'split', None, 1)
+ self.checkequal(['a', 'b c '], ' a b c ', 'split', None, 1)
+ self.checkequal(['a', 'b', 'c '], ' a b c ', 'split', None, 2)
+ self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'split')
+ aaa = ' a '*20
+ self.checkequal(['a']*20, aaa, 'split')
+ self.checkequal(['a'] + [aaa[4:]], aaa, 'split', None, 1)
+ self.checkequal(['a']*19 + ['a '], aaa, 'split', None, 19)
+
+ # mixed use of str and unicode
+ self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', ' ', 2)
+
+ def test_additional_rsplit(self):
+ self.checkequal(['this', 'is', 'the', 'rsplit', 'function'],
+ 'this is the rsplit function', 'rsplit')
+
+ # by whitespace
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d ', 'rsplit')
+ self.checkequal(['a b c', 'd'], 'a b c d', 'rsplit', None, 1)
+ self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4)
+ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None,
+ sys.maxsize-20)
+ self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0)
+ self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0)
+ self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2)
+
+ self.checkequal([], ' ', 'rsplit')
+ self.checkequal(['a'], ' a ', 'rsplit')
+ self.checkequal(['a', 'b'], ' a b ', 'rsplit')
+ self.checkequal([' a', 'b'], ' a b ', 'rsplit', None, 1)
+ self.checkequal([' a b','c'], ' a b c ', 'rsplit',
+ None, 1)
+ self.checkequal([' a', 'b', 'c'], ' a b c ', 'rsplit',
+ None, 2)
+ self.checkequal(['a', 'b'], '\n\ta \t\r b \v ', 'rsplit', None, 88)
+ aaa = ' a '*20
+ self.checkequal(['a']*20, aaa, 'rsplit')
+ self.checkequal([aaa[:-4]] + ['a'], aaa, 'rsplit', None, 1)
+ self.checkequal([' a a'] + ['a']*18, aaa, 'rsplit', None, 18)
+
+ # mixed use of str and unicode
+ self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', ' ', 2)
+
+ def test_strip(self):
+ self.checkequal('hello', ' hello ', 'strip')
+ self.checkequal('hello ', ' hello ', 'lstrip')
+ self.checkequal(' hello', ' hello ', 'rstrip')
+ self.checkequal('hello', 'hello', 'strip')
+
+ # strip/lstrip/rstrip with None arg
+ self.checkequal('hello', ' hello ', 'strip', None)
+ self.checkequal('hello ', ' hello ', 'lstrip', None)
+ self.checkequal(' hello', ' hello ', 'rstrip', None)
+ self.checkequal('hello', 'hello', 'strip', None)
+
+ # strip/lstrip/rstrip with str arg
+ self.checkequal('hello', 'xyzzyhelloxyzzy', 'strip', 'xyz')
+ self.checkequal('helloxyzzy', 'xyzzyhelloxyzzy', 'lstrip', 'xyz')
+ self.checkequal('xyzzyhello', 'xyzzyhelloxyzzy', 'rstrip', 'xyz')
+ self.checkequal('hello', 'hello', 'strip', 'xyz')
+
+ self.checkraises(TypeError, 'hello', 'strip', 42, 42)
+ self.checkraises(TypeError, 'hello', 'lstrip', 42, 42)
+ self.checkraises(TypeError, 'hello', 'rstrip', 42, 42)
+
+ def test_ljust(self):
+ self.checkequal('abc ', 'abc', 'ljust', 10)
+ self.checkequal('abc ', 'abc', 'ljust', 6)
+ self.checkequal('abc', 'abc', 'ljust', 3)
+ self.checkequal('abc', 'abc', 'ljust', 2)
+ self.checkequal('abc*******', 'abc', 'ljust', 10, '*')
+ self.checkraises(TypeError, 'abc', 'ljust')
+
+ def test_rjust(self):
+ self.checkequal(' abc', 'abc', 'rjust', 10)
+ self.checkequal(' abc', 'abc', 'rjust', 6)
+ self.checkequal('abc', 'abc', 'rjust', 3)
+ self.checkequal('abc', 'abc', 'rjust', 2)
+ self.checkequal('*******abc', 'abc', 'rjust', 10, '*')
+ self.checkraises(TypeError, 'abc', 'rjust')
+
+ def test_center(self):
+ self.checkequal(' abc ', 'abc', 'center', 10)
+ self.checkequal(' abc ', 'abc', 'center', 6)
+ self.checkequal('abc', 'abc', 'center', 3)
+ self.checkequal('abc', 'abc', 'center', 2)
+ self.checkequal('***abc****', 'abc', 'center', 10, '*')
+ self.checkraises(TypeError, 'abc', 'center')
+
+ def test_swapcase(self):
+ self.checkequal('hEllO CoMPuTErS', 'HeLLo cOmpUteRs', 'swapcase')
+
+ self.checkraises(TypeError, 'hello', 'swapcase', 42)
+
def test_zfill(self):
self.checkequal('123', '123', 'zfill', 2)
self.checkequal('123', '123', 'zfill', 3)
@@ -774,9 +812,6 @@ class CommonTest(unittest.TestCase):
self.checkraises(TypeError, '123', 'zfill')
-# XXX alias for py3k forward compatibility
-BaseTest = CommonTest
-
class MixinStrUnicodeUserStringTest:
# additional tests that only work for
# stringlike objects, i.e. str, unicode, UserString
@@ -983,28 +1018,28 @@ class MixinStrUnicodeUserStringTest:
self.checkequal(False, '', '__contains__', 'asdf')
def test_subscript(self):
- self.checkequal(u'a', 'abc', '__getitem__', 0)
- self.checkequal(u'c', 'abc', '__getitem__', -1)
- self.checkequal(u'a', 'abc', '__getitem__', 0L)
- self.checkequal(u'abc', 'abc', '__getitem__', slice(0, 3))
- self.checkequal(u'abc', 'abc', '__getitem__', slice(0, 1000))
- self.checkequal(u'a', 'abc', '__getitem__', slice(0, 1))
- self.checkequal(u'', 'abc', '__getitem__', slice(0, 0))
+ self.checkequal('a', 'abc', '__getitem__', 0)
+ self.checkequal('c', 'abc', '__getitem__', -1)
+ self.checkequal('a', 'abc', '__getitem__', 0)
+ self.checkequal('abc', 'abc', '__getitem__', slice(0, 3))
+ self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000))
+ self.checkequal('a', 'abc', '__getitem__', slice(0, 1))
+ self.checkequal('', 'abc', '__getitem__', slice(0, 0))
self.checkraises(TypeError, 'abc', '__getitem__', 'def')
def test_slice(self):
- self.checkequal('abc', 'abc', '__getslice__', 0, 1000)
- self.checkequal('abc', 'abc', '__getslice__', 0, 3)
- self.checkequal('ab', 'abc', '__getslice__', 0, 2)
- self.checkequal('bc', 'abc', '__getslice__', 1, 3)
- self.checkequal('b', 'abc', '__getslice__', 1, 2)
- self.checkequal('', 'abc', '__getslice__', 2, 2)
- self.checkequal('', 'abc', '__getslice__', 1000, 1000)
- self.checkequal('', 'abc', '__getslice__', 2000, 1000)
- self.checkequal('', 'abc', '__getslice__', 2, 1)
-
- self.checkraises(TypeError, 'abc', '__getslice__', 'def')
+ self.checkequal('abc', 'abc', '__getitem__', slice(0, 1000))
+ self.checkequal('abc', 'abc', '__getitem__', slice(0, 3))
+ self.checkequal('ab', 'abc', '__getitem__', slice(0, 2))
+ self.checkequal('bc', 'abc', '__getitem__', slice(1, 3))
+ self.checkequal('b', 'abc', '__getitem__', slice(1, 2))
+ self.checkequal('', 'abc', '__getitem__', slice(2, 2))
+ self.checkequal('', 'abc', '__getitem__', slice(1000, 1000))
+ self.checkequal('', 'abc', '__getitem__', slice(2000, 1000))
+ self.checkequal('', 'abc', '__getitem__', slice(2, 1))
+
+ self.checkraises(TypeError, 'abc', '__getitem__', 'def')
def test_extended_getslice(self):
# Test extended slicing by comparing with list slicing.
@@ -1015,7 +1050,7 @@ class MixinStrUnicodeUserStringTest:
# Skip step 0 (invalid)
for step in indices[1:]:
L = list(s)[start:stop:step]
- self.checkequal(u"".join(L), s, '__getitem__',
+ self.checkequal("".join(L), s, '__getitem__',
slice(start, stop, step))
def test_mul(self):
@@ -1041,29 +1076,25 @@ class MixinStrUnicodeUserStringTest:
self.checkequal('w x y z', ' ', 'join', Sequence())
self.checkequal('abc', 'a', 'join', ('abc',))
self.checkequal('z', 'a', 'join', UserList(['z']))
- if test_support.have_unicode:
- self.checkequal(unicode('a.b.c'), unicode('.'), 'join', ['a', 'b', 'c'])
- self.checkequal(unicode('a.b.c'), '.', 'join', [unicode('a'), 'b', 'c'])
- self.checkequal(unicode('a.b.c'), '.', 'join', ['a', unicode('b'), 'c'])
- self.checkequal(unicode('a.b.c'), '.', 'join', ['a', 'b', unicode('c')])
- self.checkraises(TypeError, '.', 'join', ['a', unicode('b'), 3])
+ self.checkequal('a.b.c', '.', 'join', ['a', 'b', 'c'])
+ self.assertRaises(TypeError, '.'.join, ['a', 'b', 3])
for i in [5, 25, 125]:
self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
['a' * i] * i)
self.checkequal(((('a' * i) + '-') * i)[:-1], '-', 'join',
('a' * i,) * i)
- self.checkraises(TypeError, ' ', 'join', BadSeq1())
+ #self.checkequal(str(BadSeq1()), ' ', 'join', BadSeq1())
self.checkequal('a b c', ' ', 'join', BadSeq2())
self.checkraises(TypeError, ' ', 'join')
self.checkraises(TypeError, ' ', 'join', 7)
- self.checkraises(TypeError, ' ', 'join', Sequence([7, 'hello', 123L]))
+ self.checkraises(TypeError, ' ', 'join', [1, 2, bytes()])
try:
def f():
yield 4 + ""
self.fixtype(' ').join(f())
- except TypeError, e:
+ except TypeError as e:
if '+' not in str(e):
self.fail('join() ate exception message')
else:
@@ -1083,11 +1114,9 @@ class MixinStrUnicodeUserStringTest:
# unicode raises ValueError, str raises OverflowError
self.checkraises((ValueError, OverflowError), '%c', '__mod__', ordinal)
- longvalue = sys.maxint + 10L
+ longvalue = sys.maxsize + 10
slongvalue = str(longvalue)
- if slongvalue[-1] in ("L","l"): slongvalue = slongvalue[:-1]
self.checkequal(' 42', '%3ld', '__mod__', 42)
- self.checkequal('42', '%d', '__mod__', 42L)
self.checkequal('42', '%d', '__mod__', 42.0)
self.checkequal(slongvalue, '%d', '__mod__', longvalue)
self.checkcall('%d', '__mod__', float(longvalue))
@@ -1101,7 +1130,7 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(ValueError, '%(foo', '__mod__', {})
self.checkraises(TypeError, '%(foo)s %(bar)s', '__mod__', ('foo', 42))
self.checkraises(TypeError, '%d', '__mod__', "42") # not numeric
- self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int/long conversion provided
+ self.checkraises(TypeError, '%d', '__mod__', (42+0j)) # no int conversion provided
# argument names with properly nested brackets are supported
self.checkequal('bar', '%((foo))s', '__mod__', {'(foo)': 'bar'})
@@ -1118,10 +1147,10 @@ class MixinStrUnicodeUserStringTest:
def test_floatformatting(self):
# float formatting
- for prec in xrange(100):
+ for prec in range(100):
format = '%%.%if' % prec
value = 0.01
- for x in xrange(60):
+ for x in range(60):
value = value * 3.14159265359 / 3.0 * 10.0
self.checkcall(format, "__mod__", value)
@@ -1159,9 +1188,6 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(ValueError, S, 'partition', '')
self.checkraises(TypeError, S, 'partition', None)
- # mixed use of str and unicode
- self.assertEqual('a/b/c'.partition(u'/'), ('a', '/', 'b/c'))
-
def test_rpartition(self):
self.checkequal(('this is the rparti', 'ti', 'on method'),
@@ -1177,9 +1203,6 @@ class MixinStrUnicodeUserStringTest:
self.checkraises(ValueError, S, 'rpartition', '')
self.checkraises(TypeError, S, 'rpartition', None)
- # mixed use of str and unicode
- self.assertEqual('a/b/c'.rpartition(u'/'), ('a/b', '/', 'c'))
-
def test_none_arguments(self):
# issue 11828
s = 'hello'
@@ -1222,73 +1245,21 @@ class MixinStrUnicodeUserStringTest:
# issue 11828
s = 'hello'
x = 'x'
- self.assertRaisesRegexp(TypeError, r'\bfind\b', s.find,
+ self.assertRaisesRegex(TypeError, r'^find\(', s.find,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\brfind\b', s.rfind,
+ self.assertRaisesRegex(TypeError, r'^rfind\(', s.rfind,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\bindex\b', s.index,
+ self.assertRaisesRegex(TypeError, r'^index\(', s.index,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\brindex\b', s.rindex,
+ self.assertRaisesRegex(TypeError, r'^rindex\(', s.rindex,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'^count\(', s.count,
+ self.assertRaisesRegex(TypeError, r'^count\(', s.count,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'^startswith\(', s.startswith,
+ self.assertRaisesRegex(TypeError, r'^startswith\(', s.startswith,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'^endswith\(', s.endswith,
+ self.assertRaisesRegex(TypeError, r'^endswith\(', s.endswith,
x, None, None, None)
-class MixinStrStringUserStringTest:
- # Additional tests for 8bit strings, i.e. str, UserString and
- # the string module
-
- def test_maketrans(self):
- self.assertEqual(
- ''.join(map(chr, xrange(256))).replace('abc', 'xyz'),
- string.maketrans('abc', 'xyz')
- )
- self.assertRaises(ValueError, string.maketrans, 'abc', 'xyzw')
-
- def test_translate(self):
- table = string.maketrans('abc', 'xyz')
- self.checkequal('xyzxyz', 'xyzabcdef', 'translate', table, 'def')
-
- table = string.maketrans('a', 'A')
- self.checkequal('Abc', 'abc', 'translate', table)
- self.checkequal('xyz', 'xyz', 'translate', table)
- self.checkequal('yz', 'xyz', 'translate', table, 'x')
- self.checkequal('yx', 'zyzzx', 'translate', None, 'z')
- self.checkequal('zyzzx', 'zyzzx', 'translate', None, '')
- self.checkequal('zyzzx', 'zyzzx', 'translate', None)
- self.checkraises(ValueError, 'xyz', 'translate', 'too short', 'strip')
- self.checkraises(ValueError, 'xyz', 'translate', 'too short')
-
-
-class MixinStrUserStringTest:
- # Additional tests that only work with
- # 8bit compatible object, i.e. str and UserString
-
- if test_support.have_unicode:
- def test_encoding_decoding(self):
- codecs = [('rot13', 'uryyb jbeyq'),
- ('base64', 'aGVsbG8gd29ybGQ=\n'),
- ('hex', '68656c6c6f20776f726c64'),
- ('uu', 'begin 666 <data>\n+:&5L;&\\@=V]R;&0 \n \nend\n')]
- for encoding, data in codecs:
- self.checkequal(data, 'hello world', 'encode', encoding)
- self.checkequal('hello world', data, 'decode', encoding)
- # zlib is optional, so we make the test optional too...
- try:
- import zlib
- except ImportError:
- pass
- else:
- data = 'x\x9c\xcbH\xcd\xc9\xc9W(\xcf/\xcaI\x01\x00\x1a\x0b\x04]'
- self.checkequal(data, 'hello world', 'encode', 'zlib')
- self.checkequal('hello world', data, 'decode', 'zlib')
-
- self.checkraises(TypeError, 'xyz', 'decode', 42)
- self.checkraises(TypeError, 'xyz', 'encode', 42)
-
class MixinStrUnicodeTest:
# Additional tests that only work with str and unicode.
@@ -1303,34 +1274,34 @@ class MixinStrUnicodeTest:
pass
s1 = subclass("abcd")
s2 = t().join([s1])
- self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is t)
+ self.assertIsNot(s1, s2)
+ self.assertIs(type(s2), t)
s1 = t("abcd")
s2 = t().join([s1])
- self.assertTrue(s1 is s2)
+ self.assertIs(s1, s2)
# Should also test mixed-type join.
- if t is unicode:
+ if t is str:
s1 = subclass("abcd")
s2 = "".join([s1])
- self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is t)
+ self.assertIsNot(s1, s2)
+ self.assertIs(type(s2), t)
s1 = t("abcd")
s2 = "".join([s1])
- self.assertTrue(s1 is s2)
-
- elif t is str:
- s1 = subclass("abcd")
- s2 = u"".join([s1])
- self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is unicode) # promotes!
-
- s1 = t("abcd")
- s2 = u"".join([s1])
- self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is unicode) # promotes!
+ self.assertIs(s1, s2)
+
+## elif t is str8:
+## s1 = subclass("abcd")
+## s2 = "".join([s1])
+## self.assertIsNot(s1, s2)
+## self.assertIs(type(s2), str) # promotes!
+
+## s1 = t("abcd")
+## s2 = "".join([s1])
+## self.assertIsNot(s1, s2)
+## self.assertIs(type(s2), str) # promotes!
else:
self.fail("unexpected type for MixinStrUnicodeTest %r" % t)
diff --git a/Lib/test/subprocessdata/fd_status.py b/Lib/test/subprocessdata/fd_status.py
new file mode 100644
index 00000000000..1f61e13a345
--- /dev/null
+++ b/Lib/test/subprocessdata/fd_status.py
@@ -0,0 +1,24 @@
+"""When called as a script, print a comma-separated list of the open
+file descriptors on stdout."""
+
+import errno
+import os
+
+try:
+ _MAXFD = os.sysconf("SC_OPEN_MAX")
+except:
+ _MAXFD = 256
+
+if __name__ == "__main__":
+ fds = []
+ for fd in range(0, _MAXFD):
+ try:
+ st = os.fstat(fd)
+ except OSError as e:
+ if e.errno == errno.EBADF:
+ continue
+ raise
+ # Ignore Solaris door files
+ if st.st_mode & 0xF000 != 0xd000:
+ fds.append(fd)
+ print(','.join(map(str, fds)))
diff --git a/Lib/test/subprocessdata/input_reader.py b/Lib/test/subprocessdata/input_reader.py
new file mode 100644
index 00000000000..1dc3191ad18
--- /dev/null
+++ b/Lib/test/subprocessdata/input_reader.py
@@ -0,0 +1,7 @@
+"""When called as a script, consumes the input"""
+
+import sys
+
+if __name__ == "__main__":
+ for line in sys.stdin:
+ pass
diff --git a/Lib/test/subprocessdata/qcat.py b/Lib/test/subprocessdata/qcat.py
new file mode 100644
index 00000000000..fe6f9db25c9
--- /dev/null
+++ b/Lib/test/subprocessdata/qcat.py
@@ -0,0 +1,7 @@
+"""When ran as a script, simulates cat with no arguments."""
+
+import sys
+
+if __name__ == "__main__":
+ for line in sys.stdin:
+ sys.stdout.write(line)
diff --git a/Lib/test/subprocessdata/qgrep.py b/Lib/test/subprocessdata/qgrep.py
new file mode 100644
index 00000000000..69906379a9b
--- /dev/null
+++ b/Lib/test/subprocessdata/qgrep.py
@@ -0,0 +1,10 @@
+"""When called with a single argument, simulated fgrep with a single
+argument and no options."""
+
+import sys
+
+if __name__ == "__main__":
+ pattern = sys.argv[1]
+ for line in sys.stdin:
+ if pattern in line:
+ sys.stdout.write(line)
diff --git a/Lib/test/test_support.py b/Lib/test/support.py
index 270b46bc174..e1ec9e2d1f7 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/support.py
@@ -1,7 +1,7 @@
"""Supporting definitions for the Python regression tests."""
-if __name__ != 'test.test_support':
- raise ImportError('test_support must be imported from the test package')
+if __name__ != 'test.support':
+ raise ImportError('support must be imported from the test package')
import contextlib
import errno
@@ -15,31 +15,49 @@ import shutil
import warnings
import unittest
import importlib
-import UserDict
+import collections
import re
+import subprocess
+import imp
import time
+import sysconfig
+import fnmatch
+import logging.handlers
import struct
+import tempfile
import _testcapi
+
+try:
+ import _thread, threading
+except ImportError:
+ _thread = None
+ threading = None
try:
- import thread
+ import multiprocessing.process
except ImportError:
- thread = None
-
-__all__ = ["Error", "TestFailed", "ResourceDenied", "import_module",
- "verbose", "use_resources", "max_memuse", "record_original_stdout",
- "get_original_stdout", "unload", "unlink", "rmtree", "forget",
- "is_resource_enabled", "requires", "find_unused_port", "bind_port",
- "fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ",
- "SAVEDCWD", "temp_cwd", "findfile", "sortdict", "check_syntax_error",
- "open_urlresource", "check_warnings", "check_py3k_warnings",
- "CleanImport", "EnvironmentVarGuard", "captured_output",
- "captured_stdout", "TransientResource", "transient_internet",
- "run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest",
- "BasicTestRunner", "run_unittest", "run_doctest", "threading_setup",
- "threading_cleanup", "reap_children", "cpython_only",
- "check_impl_detail", "get_attribute", "py3k_bytes",
- "import_fresh_module", "threading_cleanup", "reap_children",
- "strip_python_stderr"]
+ multiprocessing = None
+
+
+__all__ = [
+ "Error", "TestFailed", "ResourceDenied", "import_module",
+ "verbose", "use_resources", "max_memuse", "record_original_stdout",
+ "get_original_stdout", "unload", "unlink", "rmtree", "forget",
+ "is_resource_enabled", "requires", "requires_mac_ver",
+ "find_unused_port", "bind_port",
+ "fcmp", "is_jython", "TESTFN", "HOST", "FUZZ", "SAVEDCWD", "temp_cwd",
+ "findfile", "sortdict", "check_syntax_error", "open_urlresource",
+ "check_warnings", "CleanImport", "EnvironmentVarGuard",
+ "TransientResource", "captured_output", "captured_stdout",
+ "captured_stdin", "captured_stderr",
+ "time_out", "socket_peer_reset", "ioerror_peer_reset",
+ "run_with_locale", 'temp_umask', "transient_internet",
+ "set_memlimit", "bigmemtest", "bigaddrspacetest", "BasicTestRunner",
+ "run_unittest", "run_doctest", "threading_setup", "threading_cleanup",
+ "reap_children", "cpython_only", "check_impl_detail", "get_attribute",
+ "swap_item", "swap_attr", "requires_IEEE_754",
+ "TestHandler", "Matcher", "can_symlink", "skip_unless_symlink",
+ "import_fresh_module", "failfast", "run_with_tz"
+ ]
class Error(Exception):
"""Base class for regression test exceptions."""
@@ -51,7 +69,7 @@ class ResourceDenied(unittest.SkipTest):
"""Test skipped because it requested a disallowed resource.
This is raised when a test calls requires() for a resource that
- has not been enabled. It is used to distinguish between expected
+ has not be enabled. It is used to distinguish between expected
and unexpected skips.
"""
@@ -79,7 +97,7 @@ def import_module(name, deprecated=False):
with _ignore_deprecated_imports(deprecated):
try:
return importlib.import_module(name)
- except ImportError, msg:
+ except ImportError as msg:
raise unittest.SkipTest(str(msg))
@@ -122,8 +140,8 @@ def import_fresh_module(name, fresh=(), blocked=(), deprecated=False):
If deprecated is True, any module or package deprecation messages
will be suppressed."""
- # NOTE: test_heapq, test_json, and test_warnings include extra sanity
- # checks to make sure that this utility function is working as expected
+ # NOTE: test_heapq, test_json and test_warnings include extra sanity checks
+ # to make sure that this utility function is working as expected
with _ignore_deprecated_imports(deprecated):
# Keep track of modules saved for later restoration as well
# as those which just need a blocking entry removed
@@ -157,12 +175,13 @@ def get_attribute(obj, name):
else:
return attribute
-
verbose = 1 # Flag set to 0 by regrtest.py
use_resources = None # Flag set to [] by regrtest.py
max_memuse = 0 # Disable bigmem tests (they will still be run with
# small sizes, to make sure they work.)
real_max_memuse = 0
+failfast = False
+match_tests = None
# _original_stdout is meant to hold stdout at the time regrtest began.
# This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
@@ -240,8 +259,10 @@ else:
def unlink(filename):
try:
_unlink(filename)
- except OSError:
- pass
+ except OSError as error:
+ # The filename need not exist.
+ if error.errno not in (errno.ENOENT, errno.ENOTDIR):
+ raise
def rmdir(dirname):
try:
@@ -254,21 +275,72 @@ def rmdir(dirname):
def rmtree(path):
try:
_rmtree(path)
- except OSError, e:
+ except OSError as error:
# Unix returns ENOENT, Windows returns ESRCH.
- if e.errno not in (errno.ENOENT, errno.ESRCH):
+ if error.errno not in (errno.ENOENT, errno.ESRCH):
raise
+def make_legacy_pyc(source):
+ """Move a PEP 3147 pyc/pyo file to its legacy pyc/pyo location.
+
+ The choice of .pyc or .pyo extension is done based on the __debug__ flag
+ value.
+
+ :param source: The file system path to the source file. The source file
+ does not need to exist, however the PEP 3147 pyc file must exist.
+ :return: The file system path to the legacy pyc file.
+ """
+ pyc_file = imp.cache_from_source(source)
+ up_one = os.path.dirname(os.path.abspath(source))
+ legacy_pyc = os.path.join(up_one, source + ('c' if __debug__ else 'o'))
+ os.rename(pyc_file, legacy_pyc)
+ return legacy_pyc
+
def forget(modname):
- '''"Forget" a module was ever imported by removing it from sys.modules and
- deleting any .pyc and .pyo files.'''
+ """'Forget' a module was ever imported.
+
+ This removes the module from sys.modules and deletes any PEP 3147 or
+ legacy .pyc and .pyo files.
+ """
unload(modname)
for dirname in sys.path:
- unlink(os.path.join(dirname, modname + os.extsep + 'pyc'))
- # Deleting the .pyo file cannot be within the 'try' for the .pyc since
- # the chance exists that there is no .pyc (and thus the 'try' statement
- # is exited) but there is a .pyo file.
- unlink(os.path.join(dirname, modname + os.extsep + 'pyo'))
+ source = os.path.join(dirname, modname + '.py')
+ # It doesn't matter if they exist or not, unlink all possible
+ # combinations of PEP 3147 and legacy pyc and pyo files.
+ unlink(source + 'c')
+ unlink(source + 'o')
+ unlink(imp.cache_from_source(source, debug_override=True))
+ unlink(imp.cache_from_source(source, debug_override=False))
+
+# On some platforms, should not run gui test even if it is allowed
+# in `use_resources'.
+if sys.platform.startswith('win'):
+ import ctypes
+ import ctypes.wintypes
+ def _is_gui_available():
+ UOI_FLAGS = 1
+ WSF_VISIBLE = 0x0001
+ class USEROBJECTFLAGS(ctypes.Structure):
+ _fields_ = [("fInherit", ctypes.wintypes.BOOL),
+ ("fReserved", ctypes.wintypes.BOOL),
+ ("dwFlags", ctypes.wintypes.DWORD)]
+ dll = ctypes.windll.user32
+ h = dll.GetProcessWindowStation()
+ if not h:
+ raise ctypes.WinError()
+ uof = USEROBJECTFLAGS()
+ needed = ctypes.wintypes.DWORD()
+ res = dll.GetUserObjectInformationW(h,
+ UOI_FLAGS,
+ ctypes.byref(uof),
+ ctypes.sizeof(uof),
+ ctypes.byref(needed))
+ if not res:
+ raise ctypes.WinError()
+ return bool(uof.dwFlags & WSF_VISIBLE)
+else:
+ def _is_gui_available():
+ return True
def is_resource_enabled(resource):
"""Test whether a resource is enabled. Known resources are set by
@@ -279,7 +351,11 @@ def requires(resource, msg=None):
"""Raise ResourceDenied if the specified resource is not available.
If the caller's module is __main__ then automatically return True. The
- possibility of False being returned occurs when regrtest.py is executing."""
+ possibility of False being returned occurs when regrtest.py is
+ executing.
+ """
+ if resource == 'gui' and not _is_gui_available():
+ raise unittest.SkipTest("Cannot use the 'gui' resource")
# see if the caller's module is __main__ - if so, treat as if
# the resource was set
if sys._getframe(1).f_globals.get("__name__") == "__main__":
@@ -289,6 +365,33 @@ def requires(resource, msg=None):
msg = "Use of the `%s' resource not enabled" % resource
raise ResourceDenied(msg)
+def requires_mac_ver(*min_version):
+ """Decorator raising SkipTest if the OS is Mac OS X and the OS X
+ version if less than min_version.
+
+ For example, @requires_mac_ver(10, 5) raises SkipTest if the OS X version
+ is lesser than 10.5.
+ """
+ def decorator(func):
+ @functools.wraps(func)
+ def wrapper(*args, **kw):
+ if sys.platform == 'darwin':
+ version_txt = platform.mac_ver()[0]
+ try:
+ version = tuple(map(int, version_txt.split('.')))
+ except ValueError:
+ pass
+ else:
+ if version < min_version:
+ min_version_txt = '.'.join(map(str, min_version))
+ raise unittest.SkipTest(
+ "Mac OS X %s or higher required, not %s"
+ % (min_version_txt, version_txt))
+ return func(*args, **kw)
+ wrapper.min_version = min_version
+ return wrapper
+ return decorator
+
HOST = 'localhost'
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
@@ -344,7 +447,9 @@ def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
port returned to us by the OS won't immediately be dished back out to some
other process when we close and delete our temporary socket but before our
calling code has a chance to bind the returned port. We can deal with this
- issue if/when we come across it."""
+ issue if/when we come across it.
+ """
+
tempsock = socket.socket(family, socktype)
port = bind_port(tempsock)
tempsock.close()
@@ -365,6 +470,7 @@ def bind_port(sock, host=HOST):
on Windows), it will be set on the socket. This will prevent anyone else
from bind()'ing to our host/port for the duration of the test.
"""
+
if sock.family == socket.AF_INET and sock.type == socket.SOCK_STREAM:
if hasattr(socket, 'SO_REUSEADDR'):
if sock.getsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR) == 1:
@@ -399,11 +505,10 @@ def fcmp(x, y): # fuzzy comparison function
return (len(x) > len(y)) - (len(x) < len(y))
return (x > y) - (x < y)
-try:
- unicode
- have_unicode = True
-except NameError:
- have_unicode = False
+# decorator for skipping tests on non-IEEE 754 platforms
+requires_IEEE_754 = unittest.skipUnless(
+ float.__getformat__("double").startswith("IEEE"),
+ "test requires IEEE 754 doubles")
is_jython = sys.platform.startswith('java')
@@ -411,83 +516,91 @@ is_jython = sys.platform.startswith('java')
if os.name == 'java':
# Jython disallows @ in module names
TESTFN = '$test'
-elif os.name == 'riscos':
- TESTFN = 'testfile'
else:
TESTFN = '@test'
- # Unicode name only used if TEST_FN_ENCODING exists for the platform.
- if have_unicode:
- # Assuming sys.getfilesystemencoding()!=sys.getdefaultencoding()
- # TESTFN_UNICODE is a filename that can be encoded using the
- # file system encoding, but *not* with the default (ascii) encoding
- if isinstance('', unicode):
- # python -U
- # XXX perhaps unicode() should accept Unicode strings?
- TESTFN_UNICODE = "@test-\xe0\xf2"
- else:
- # 2 latin characters.
- TESTFN_UNICODE = unicode("@test-\xe0\xf2", "latin-1")
- TESTFN_ENCODING = sys.getfilesystemencoding()
- # TESTFN_UNENCODABLE is a filename that should *not* be
- # able to be encoded by *either* the default or filesystem encoding.
- # This test really only makes sense on Windows NT platforms
- # which have special Unicode support in posixmodule.
- if (not hasattr(sys, "getwindowsversion") or
- sys.getwindowsversion()[3] < 2): # 0=win32s or 1=9x/ME
- TESTFN_UNENCODABLE = None
- else:
- # Japanese characters (I think - from bug 846133)
- TESTFN_UNENCODABLE = eval('u"@test-\u5171\u6709\u3055\u308c\u308b"')
- try:
- # XXX - Note - should be using TESTFN_ENCODING here - but for
- # Windows, "mbcs" currently always operates as if in
- # errors=ignore' mode - hence we get '?' characters rather than
- # the exception. 'Latin1' operates as we expect - ie, fails.
- # See [ 850997 ] mbcs encoding ignores errors
- TESTFN_UNENCODABLE.encode("Latin1")
- except UnicodeEncodeError:
- pass
- else:
- print \
- 'WARNING: The filename %r CAN be encoded by the filesystem. ' \
- 'Unicode filename tests may not be effective' \
- % TESTFN_UNENCODABLE
-
# Disambiguate TESTFN for parallel testing, while letting it remain a valid
# module name.
TESTFN = "{}_{}_tmp".format(TESTFN, os.getpid())
+
+# TESTFN_UNICODE is a non-ascii filename
+TESTFN_UNICODE = TESTFN + "-\xe0\xf2\u0258\u0141\u011f"
+if sys.platform == 'darwin':
+ # In Mac OS X's VFS API file names are, by definition, canonically
+ # decomposed Unicode, encoded using UTF-8. See QA1173:
+ # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
+ import unicodedata
+ TESTFN_UNICODE = unicodedata.normalize('NFD', TESTFN_UNICODE)
+TESTFN_ENCODING = sys.getfilesystemencoding()
+
+# TESTFN_UNENCODABLE is a filename (str type) that should *not* be able to be
+# encoded by the filesystem encoding (in strict mode). It can be None if we
+# cannot generate such filename.
+TESTFN_UNENCODABLE = None
+if os.name in ('nt', 'ce'):
+ # skip win32s (0) or Windows 9x/ME (1)
+ if sys.getwindowsversion().platform >= 2:
+ # Different kinds of characters from various languages to minimize the
+ # probability that the whole name is encodable to MBCS (issue #9819)
+ TESTFN_UNENCODABLE = TESTFN + "-\u5171\u0141\u2661\u0363\uDC80"
+ try:
+ TESTFN_UNENCODABLE.encode(TESTFN_ENCODING)
+ except UnicodeEncodeError:
+ pass
+ else:
+ print('WARNING: The filename %r CAN be encoded by the filesystem encoding (%s). '
+ 'Unicode filename tests may not be effective'
+ % (TESTFN_UNENCODABLE, TESTFN_ENCODING))
+ TESTFN_UNENCODABLE = None
+# Mac OS X denies unencodable filenames (invalid utf-8)
+elif sys.platform != 'darwin':
+ try:
+ # ascii and utf-8 cannot encode the byte 0xff
+ b'\xff'.decode(TESTFN_ENCODING)
+ except UnicodeDecodeError:
+ # 0xff will be encoded using the surrogate character u+DCFF
+ TESTFN_UNENCODABLE = TESTFN \
+ + b'-\xff'.decode(TESTFN_ENCODING, 'surrogateescape')
+ else:
+ # File system encoding (eg. ISO-8859-* encodings) can encode
+ # the byte 0xff. Skip some unicode filename tests.
+ pass
+
# Save the initial cwd
SAVEDCWD = os.getcwd()
@contextlib.contextmanager
-def temp_cwd(name='tempcwd', quiet=False):
+def temp_cwd(name='tempcwd', quiet=False, path=None):
"""
- Context manager that creates a temporary directory and set it as CWD.
+ Context manager that temporarily changes the CWD.
- The new CWD is created in the current directory and it's named *name*.
- If *quiet* is False (default) and it's not possible to create or change
- the CWD, an error is raised. If it's True, only a warning is raised
- and the original CWD is used.
+ An existing path may be provided as *path*, in which case this
+ function makes no changes to the file system.
+
+ Otherwise, the new CWD is created in the current directory and it's
+ named *name*. If *quiet* is False (default) and it's not possible to
+ create or change the CWD, an error is raised. If it's True, only a
+ warning is raised and the original CWD is used.
"""
- if have_unicode and isinstance(name, unicode):
- try:
- name = name.encode(sys.getfilesystemencoding() or 'ascii')
- except UnicodeEncodeError:
- if not quiet:
- raise unittest.SkipTest('unable to encode the cwd name with '
- 'the filesystem encoding.')
saved_dir = os.getcwd()
is_temporary = False
+ if path is None:
+ path = name
+ try:
+ os.mkdir(name)
+ is_temporary = True
+ except OSError:
+ if not quiet:
+ raise
+ warnings.warn('tests may fail, unable to create temp CWD ' + name,
+ RuntimeWarning, stacklevel=3)
try:
- os.mkdir(name)
- os.chdir(name)
- is_temporary = True
+ os.chdir(path)
except OSError:
if not quiet:
raise
- warnings.warn('tests may fail, unable to change the CWD to ' + name,
+ warnings.warn('tests may fail, unable to change the CWD to ' + path,
RuntimeWarning, stacklevel=3)
try:
yield os.getcwd()
@@ -497,6 +610,16 @@ def temp_cwd(name='tempcwd', quiet=False):
rmtree(name)
+@contextlib.contextmanager
+def temp_umask(umask):
+ """Context manager that temporarily sets the process umask."""
+ oldmask = os.umask(umask)
+ try:
+ yield
+ finally:
+ os.umask(oldmask)
+
+
def findfile(file, here=__file__, subdir=None):
"""Try to find a file on sys.path and the working directory. If it is not
found the argument passed to the function is returned (this does not
@@ -514,8 +637,7 @@ def findfile(file, here=__file__, subdir=None):
def sortdict(dict):
"Like repr(dict), but in sorted order."
- items = dict.items()
- items.sort()
+ items = sorted(dict.items())
reprpairs = ["%r: %r" % pair for pair in items]
withcommas = ", ".join(reprpairs)
return "{%s}" % withcommas
@@ -536,15 +658,17 @@ def check_syntax_error(testcase, statement):
testcase.assertRaises(SyntaxError, compile, statement,
'<test string>', 'exec')
-def open_urlresource(url, check=None):
- import urlparse, urllib2
+def open_urlresource(url, *args, **kw):
+ import urllib.request, urllib.parse
+
+ check = kw.pop('check', None)
- filename = urlparse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
+ filename = urllib.parse.urlparse(url)[2].split('/')[-1] # '/': it's URL!
fn = os.path.join(os.path.dirname(__file__), "data", filename)
def check_valid_file(fn):
- f = open(fn)
+ f = open(fn, *args, **kw)
if check is None:
return f
elif check(f):
@@ -561,8 +685,8 @@ def open_urlresource(url, check=None):
# Verify the requirement before downloading the file
requires('urlfetch')
- print >> get_original_stdout(), '\tfetching %s ...' % url
- f = urllib2.urlopen(url, timeout=15)
+ print('\tfetching %s ...' % url, file=get_original_stdout())
+ f = urllib.request.urlopen(url, timeout=15)
try:
with open(fn, "wb") as out:
s = f.read()
@@ -619,22 +743,22 @@ def _filterwarnings(filters, quiet=False):
sys.modules['warnings'].simplefilter("always")
yield WarningsRecorder(w)
# Filter the recorded warnings
- reraise = [warning.message for warning in w]
+ reraise = list(w)
missing = []
for msg, cat in filters:
seen = False
- for exc in reraise[:]:
- message = str(exc)
+ for w in reraise[:]:
+ warning = w.message
# Filter out the matching messages
- if (re.match(msg, message, re.I) and
- issubclass(exc.__class__, cat)):
+ if (re.match(msg, str(warning), re.I) and
+ issubclass(warning.__class__, cat)):
seen = True
- reraise.remove(exc)
+ reraise.remove(w)
if not seen and not quiet:
# This filter caught nothing
missing.append((msg, cat.__name__))
if reraise:
- raise AssertionError("unhandled warning %r" % reraise[0])
+ raise AssertionError("unhandled warning %s" % reraise[0])
if missing:
raise AssertionError("filter (%r, %s) did not catch any warning" %
missing[0])
@@ -664,29 +788,6 @@ def check_warnings(*filters, **kwargs):
return _filterwarnings(filters, quiet)
-@contextlib.contextmanager
-def check_py3k_warnings(*filters, **kwargs):
- """Context manager to silence py3k warnings.
-
- Accept 2-tuples as positional arguments:
- ("message regexp", WarningCategory)
-
- Optional argument:
- - if 'quiet' is True, it does not fail if a filter catches nothing
- (default False)
-
- Without argument, it defaults to:
- check_py3k_warnings(("", DeprecationWarning), quiet=False)
- """
- if sys.py3kwarning:
- if not filters:
- filters = (("", DeprecationWarning),)
- else:
- # It should not raise any py3k warning
- filters = ()
- return _filterwarnings(filters, kwargs.get('quiet'))
-
-
class CleanImport(object):
"""Context manager to force import to return a new module reference.
@@ -719,7 +820,7 @@ class CleanImport(object):
sys.modules.update(self.original_modules)
-class EnvironmentVarGuard(UserDict.DictMixin):
+class EnvironmentVarGuard(collections.MutableMapping):
"""Class to help protect the environment variable properly. Can be used as
a context manager."""
@@ -747,6 +848,12 @@ class EnvironmentVarGuard(UserDict.DictMixin):
def keys(self):
return self._environ.keys()
+ def __iter__(self):
+ return iter(self._environ)
+
+ def __len__(self):
+ return len(self._environ)
+
def set(self, envvar, value):
self[envvar] = value
@@ -808,7 +915,7 @@ class TransientResource(object):
self.attrs, raise ResourceDenied. Otherwise let the exception
propagate (if any)."""
if type_ is not None and issubclass(self.exc, type_):
- for attr, attr_value in self.attrs.iteritems():
+ for attr, attr_value in self.attrs.items():
if not hasattr(value, attr):
break
if getattr(value, attr) != attr_value:
@@ -816,9 +923,16 @@ class TransientResource(object):
else:
raise ResourceDenied("an optional resource is not available")
+# Context managers that raise ResourceDenied when various issues
+# with the Internet connection manifest themselves as exceptions.
+# XXX deprecate these and use transient_internet() instead
+time_out = TransientResource(IOError, errno=errno.ETIMEDOUT)
+socket_peer_reset = TransientResource(socket.error, errno=errno.ECONNRESET)
+ioerror_peer_reset = TransientResource(IOError, errno=errno.ECONNRESET)
+
@contextlib.contextmanager
-def transient_internet(resource_name, timeout=30.0, errnos=()):
+def transient_internet(resource_name, *, timeout=30.0, errnos=()):
"""Return a context manager that raises ResourceDenied when various issues
with the Internet connection manifest themselves as exceptions."""
default_errnos = [
@@ -833,8 +947,7 @@ def transient_internet(resource_name, timeout=30.0, errnos=()):
('EAI_FAIL', -4),
('EAI_NONAME', -2),
('EAI_NODATA', -5),
- # Windows defines EAI_NODATA as 11001 but idiotic getaddrinfo()
- # implementation actually returns WSANO_DATA i.e. 11004.
+ # Encountered when trying to resolve IPv6-only hostnames
('WSANO_DATA', 11004),
]
@@ -854,7 +967,7 @@ def transient_internet(resource_name, timeout=30.0, errnos=()):
n in captured_errnos):
if not verbose:
sys.stderr.write(denied.args[0] + "\n")
- raise denied
+ raise denied from err
old_timeout = socket.getdefaulttimeout()
try:
@@ -885,11 +998,11 @@ def transient_internet(resource_name, timeout=30.0, errnos=()):
@contextlib.contextmanager
def captured_output(stream_name):
- """Return a context manager used by captured_stdout and captured_stdin
+ """Return a context manager used by captured_stdout/stdin/stderr
that temporarily replaces the sys stream *stream_name* with a StringIO."""
- import StringIO
+ import io
orig_stdout = getattr(sys, stream_name)
- setattr(sys, stream_name, StringIO.StringIO())
+ setattr(sys, stream_name, io.StringIO())
try:
yield getattr(sys, stream_name)
finally:
@@ -899,7 +1012,7 @@ def captured_stdout():
"""Capture the output of sys.stdout:
with captured_stdout() as s:
- print "hello"
+ print("hello")
self.assertEqual(s.getvalue(), "hello")
"""
return captured_output("stdout")
@@ -910,6 +1023,7 @@ def captured_stderr():
def captured_stdin():
return captured_output("stdin")
+
def gc_collect():
"""Force as many objects as possible to be collected.
@@ -927,6 +1041,16 @@ def gc_collect():
gc.collect()
+def python_is_optimized():
+ """Find if Python was built with optimizations."""
+ cflags = sysconfig.get_config_var('PY_CFLAGS') or ''
+ final_opt = ""
+ for opt in cflags.split():
+ if opt.startswith('-O'):
+ final_opt = opt
+ return final_opt and final_opt != '-O0'
+
+
_header = '2P'
if hasattr(sys, "gettotalrefcount"):
_header = '2P' + _header
@@ -952,7 +1076,6 @@ def check_sizeof(test, o, size):
% (type(o), result, size)
test.assertEqual(result, size, msg)
-
#=======================================================================
# Decorator for running a function in a different locale, correctly resetting
# it afterwards.
@@ -984,13 +1107,47 @@ def run_with_locale(catstr, *locales):
finally:
if locale and orig_locale:
locale.setlocale(category, orig_locale)
- inner.func_name = func.func_name
+ inner.__name__ = func.__name__
+ inner.__doc__ = func.__doc__
+ return inner
+ return decorator
+
+#=======================================================================
+# Decorator for running a function in a specific timezone, correctly
+# resetting it afterwards.
+
+def run_with_tz(tz):
+ def decorator(func):
+ def inner(*args, **kwds):
+ try:
+ tzset = time.tzset
+ except AttributeError:
+ raise unittest.SkipTest("tzset required")
+ if 'TZ' in os.environ:
+ orig_tz = os.environ['TZ']
+ else:
+ orig_tz = None
+ os.environ['TZ'] = tz
+ tzset()
+
+ # now run the function, resetting the tz on exceptions
+ try:
+ return func(*args, **kwds)
+ finally:
+ if orig_tz == None:
+ del os.environ['TZ']
+ else:
+ os.environ['TZ'] = orig_tz
+ time.tzset()
+
+ inner.__name__ = func.__name__
inner.__doc__ = func.__doc__
return inner
return decorator
#=======================================================================
-# Big-memory-test support. Separate from 'resources' because memory use should be configurable.
+# Big-memory-test support. Separate from 'resources' because memory use
+# should be configurable.
# Some handy shorthands. Note that these are used for byte-limits as well
# as size-limits, in the various bigmem tests
@@ -1022,63 +1179,91 @@ def set_memlimit(limit):
raise ValueError('Memory limit %r too low to be useful' % (limit,))
max_memuse = memlimit
-def bigmemtest(minsize, memuse, overhead=5*_1M):
+def _memory_watchdog(start_evt, finish_evt, period=10.0):
+ """A function which periodically watches the process' memory consumption
+ and prints it out.
+ """
+ # XXX: because of the GIL, and because the very long operations tested
+ # in most bigmem tests are uninterruptible, the loop below gets woken up
+ # much less often than expected.
+ # The polling code should be rewritten in raw C, without holding the GIL,
+ # and push results onto an anonymous pipe.
+ try:
+ page_size = os.sysconf('SC_PAGESIZE')
+ except (ValueError, AttributeError):
+ try:
+ page_size = os.sysconf('SC_PAGE_SIZE')
+ except (ValueError, AttributeError):
+ page_size = 4096
+ procfile = '/proc/{pid}/statm'.format(pid=os.getpid())
+ try:
+ f = open(procfile, 'rb')
+ except IOError as e:
+ warnings.warn('/proc not available for stats: {}'.format(e),
+ RuntimeWarning)
+ sys.stderr.flush()
+ return
+ with f:
+ start_evt.set()
+ old_data = -1
+ while not finish_evt.wait(period):
+ f.seek(0)
+ statm = f.read().decode('ascii')
+ data = int(statm.split()[5])
+ if data != old_data:
+ old_data = data
+ print(" ... process data size: {data:.1f}G"
+ .format(data=data * page_size / (1024 ** 3)))
+
+def bigmemtest(size, memuse, dry_run=True):
"""Decorator for bigmem tests.
'minsize' is the minimum useful size for the test (in arbitrary,
test-interpreted units.) 'memuse' is the number of 'bytes per size' for
- the test, or a good estimate of it. 'overhead' specifies fixed overhead,
- independent of the testsize, and defaults to 5Mb.
+ the test, or a good estimate of it.
- The decorator tries to guess a good value for 'size' and passes it to
- the decorated test function. If minsize * memuse is more than the
- allowed memory use (as defined by max_memuse), the test is skipped.
- Otherwise, minsize is adjusted upward to use up to max_memuse.
+ if 'dry_run' is False, it means the test doesn't support dummy runs
+ when -M is not specified.
"""
def decorator(f):
def wrapper(self):
- if not max_memuse:
- # If max_memuse is 0 (the default),
- # we still want to run the tests with size set to a few kb,
- # to make sure they work. We still want to avoid using
- # too much memory, though, but we do that noisily.
- maxsize = 5147
- self.assertFalse(maxsize * memuse + overhead > 20 * _1M)
- else:
- maxsize = int((max_memuse - overhead) / memuse)
- if maxsize < minsize:
- # Really ought to print 'test skipped' or something
- if verbose:
- sys.stderr.write("Skipping %s because of memory "
- "constraint\n" % (f.__name__,))
- return
- # Try to keep some breathing room in memory use
- maxsize = max(maxsize - 50 * _1M, minsize)
- return f(self, maxsize)
- wrapper.minsize = minsize
- wrapper.memuse = memuse
- wrapper.overhead = overhead
- return wrapper
- return decorator
-
-def precisionbigmemtest(size, memuse, overhead=5*_1M):
- def decorator(f):
- def wrapper(self):
+ size = wrapper.size
+ memuse = wrapper.memuse
if not real_max_memuse:
maxsize = 5147
else:
maxsize = size
- if real_max_memuse and real_max_memuse < maxsize * memuse:
- if verbose:
- sys.stderr.write("Skipping %s because of memory "
- "constraint\n" % (f.__name__,))
- return
+ if ((real_max_memuse or not dry_run)
+ and real_max_memuse < maxsize * memuse):
+ raise unittest.SkipTest(
+ "not enough memory: %.1fG minimum needed"
+ % (size * memuse / (1024 ** 3)))
+
+ if real_max_memuse and verbose and threading:
+ print()
+ print(" ... expected peak memory use: {peak:.1f}G"
+ .format(peak=size * memuse / (1024 ** 3)))
+ sys.stdout.flush()
+ start_evt = threading.Event()
+ finish_evt = threading.Event()
+ t = threading.Thread(target=_memory_watchdog,
+ args=(start_evt, finish_evt, 0.5))
+ t.daemon = True
+ t.start()
+ start_evt.set()
+ else:
+ t = None
+
+ try:
+ return f(self, maxsize)
+ finally:
+ if t:
+ finish_evt.set()
+ t.join()
- return f(self, maxsize)
wrapper.size = size
wrapper.memuse = memuse
- wrapper.overhead = overhead
return wrapper
return decorator
@@ -1086,9 +1271,13 @@ def bigaddrspacetest(f):
"""Decorator for tests that fill the address space."""
def wrapper(self):
if max_memuse < MAX_Py_ssize_t:
- if verbose:
- sys.stderr.write("Skipping %s because of memory "
- "constraint\n" % (f.__name__,))
+ if MAX_Py_ssize_t >= 2**63 - 1 and max_memuse >= 2**31:
+ raise unittest.SkipTest(
+ "not enough memory: try a 32-bit build instead")
+ else:
+ raise unittest.SkipTest(
+ "not enough memory: %.1fG minimum needed"
+ % (MAX_Py_ssize_t / (1024 ** 3)))
else:
return f(self)
return wrapper
@@ -1106,6 +1295,8 @@ def _id(obj):
return obj
def requires_resource(resource):
+ if resource == 'gui' and not _is_gui_available():
+ return unittest.skip("resource 'gui' is not available")
if is_resource_enabled(resource):
return _id
else:
@@ -1134,8 +1325,8 @@ def _parse_guards(guards):
# Returns a tuple ({platform_name: run_me}, default_value)
if not guards:
return ({'cpython': True}, False)
- is_true = guards.values()[0]
- assert guards.values() == [is_true] * len(guards) # all True or all False
+ is_true = list(guards.values())[0]
+ assert list(guards.values()) == [is_true] * len(guards) # all True or all False
return (guards, not is_true)
# Use the following check to guard CPython's implementation-specific tests --
@@ -1151,11 +1342,24 @@ def check_impl_detail(**guards):
return guards.get(platform.python_implementation().lower(), default)
+def _filter_suite(suite, pred):
+ """Recursively filter test cases in a suite based on a predicate."""
+ newtests = []
+ for test in suite._tests:
+ if isinstance(test, unittest.TestSuite):
+ _filter_suite(test, pred)
+ newtests.append(test)
+ else:
+ if pred(test):
+ newtests.append(test)
+ suite._tests = newtests
+
def _run_suite(suite):
"""Run tests from a unittest.TestSuite-derived class."""
if verbose:
- runner = unittest.TextTestRunner(sys.stdout, verbosity=2)
+ runner = unittest.TextTestRunner(sys.stdout, verbosity=2,
+ failfast=failfast)
else:
runner = BasicTestRunner()
@@ -1167,8 +1371,7 @@ def _run_suite(suite):
err = result.failures[0][1]
else:
err = "multiple errors occurred"
- if not verbose:
- err += "; run in verbose mode for details"
+ if not verbose: err += "; run in verbose mode for details"
raise TestFailed(err)
@@ -1186,6 +1389,14 @@ def run_unittest(*classes):
suite.addTest(cls)
else:
suite.addTest(unittest.makeSuite(cls))
+ def case_pred(test):
+ if match_tests is None:
+ return True
+ for name in test.id().split("."):
+ if fnmatch.fnmatchcase(name, match_tests):
+ return True
+ return False
+ _filter_suite(suite, case_pred)
_run_suite(suite)
@@ -1196,7 +1407,7 @@ def run_doctest(module, verbosity=None):
"""Run doctest on the given module. Return (#failures, #tests).
If optional argument verbosity is not specified (or is None), pass
- test_support's belief about verbosity on to doctest. Else doctest's
+ support's belief about verbosity on to doctest. Else doctest's
usual behavior is used (it searches sys.argv for -v).
"""
@@ -1207,20 +1418,37 @@ def run_doctest(module, verbosity=None):
else:
verbosity = None
- # Direct doctest output (normally just errors) to real stdout; doctest
- # output shouldn't be compared by regrtest.
- save_stdout = sys.stdout
- sys.stdout = get_original_stdout()
- try:
- f, t = doctest.testmod(module, verbose=verbosity)
- if f:
- raise TestFailed("%d of %d doctests failed" % (f, t))
- finally:
- sys.stdout = save_stdout
+ f, t = doctest.testmod(module, verbose=verbosity)
+ if f:
+ raise TestFailed("%d of %d doctests failed" % (f, t))
if verbose:
- print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t)
+ print('doctest (%s) ... %d tests with zero failures' %
+ (module.__name__, t))
return f, t
+
+#=======================================================================
+# Support for saving and restoring the imported modules.
+
+def modules_setup():
+ return sys.modules.copy(),
+
+def modules_cleanup(oldmodules):
+ # Encoders/decoders are registered permanently within the internal
+ # codec cache. If we destroy the corresponding modules their
+ # globals will be set to None which will trip up the cached functions.
+ encodings = [(k, v) for k, v in sys.modules.items()
+ if k.startswith('encodings.')]
+ sys.modules.clear()
+ sys.modules.update(encodings)
+ # XXX: This kind of problem can affect more than just encodings. In particular
+ # extension modules (such as _ssl) don't cope with reloading properly.
+ # Really, test modules should be cleaning out the test specific modules they
+ # know they added (ala test_runpy) rather than relying on this function (as
+ # test_importhooks and test_pkg do currently).
+ # Implicitly imported *real* modules should be left alone (see issue 10556).
+ sys.modules.update(oldmodules)
+
#=======================================================================
# Threading support to prevent reporting refleaks when running regrtest.py -R
@@ -1233,21 +1461,21 @@ def run_doctest(module, verbosity=None):
# at the end of a test run.
def threading_setup():
- if thread:
- return thread._count(),
+ if _thread:
+ return _thread._count(), threading._dangling.copy()
else:
- return 1,
+ return 1, ()
-def threading_cleanup(nb_threads):
- if not thread:
+def threading_cleanup(*original_values):
+ if not _thread:
return
-
_MAX_COUNT = 10
for count in range(_MAX_COUNT):
- n = thread._count()
- if n == nb_threads:
+ values = _thread._count(), threading._dangling
+ if values == original_values:
break
time.sleep(0.1)
+ gc_collect()
# XXX print a warning in case of failure?
def reap_threads(func):
@@ -1255,7 +1483,7 @@ def reap_threads(func):
ensure that the threads are cleaned up even when the test fails.
If threading is unavailable this function does nothing.
"""
- if not thread:
+ if not _thread:
return func
@functools.wraps(func)
@@ -1287,20 +1515,69 @@ def reap_children():
except:
break
-def py3k_bytes(b):
- """Emulate the py3k bytes() constructor.
+@contextlib.contextmanager
+def swap_attr(obj, attr, new_val):
+ """Temporary swap out an attribute with a new object.
+
+ Usage:
+ with swap_attr(obj, "attr", 5):
+ ...
- NOTE: This is only a best effort function.
+ This will set obj.attr to 5 for the duration of the with: block,
+ restoring the old value at the end of the block. If `attr` doesn't
+ exist on `obj`, it will be created and then deleted at the end of the
+ block.
"""
- try:
- # memoryview?
- return b.tobytes()
- except AttributeError:
+ if hasattr(obj, attr):
+ real_val = getattr(obj, attr)
+ setattr(obj, attr, new_val)
+ try:
+ yield
+ finally:
+ setattr(obj, attr, real_val)
+ else:
+ setattr(obj, attr, new_val)
+ try:
+ yield
+ finally:
+ delattr(obj, attr)
+
+@contextlib.contextmanager
+def swap_item(obj, item, new_val):
+ """Temporary swap out an item with a new object.
+
+ Usage:
+ with swap_item(obj, "item", 5):
+ ...
+
+ This will set obj["item"] to 5 for the duration of the with: block,
+ restoring the old value at the end of the block. If `item` doesn't
+ exist on `obj`, it will be created and then deleted at the end of the
+ block.
+ """
+ if item in obj:
+ real_val = obj[item]
+ obj[item] = new_val
+ try:
+ yield
+ finally:
+ obj[item] = real_val
+ else:
+ obj[item] = new_val
try:
- # iterable of ints?
- return b"".join(chr(x) for x in b)
- except TypeError:
- return bytes(b)
+ yield
+ finally:
+ del obj[item]
+
+def strip_python_stderr(stderr):
+ """Strip the stderr of a Python process from potential debug output
+ emitted by the interpreter.
+
+ This will typically be run on the result of the communicate() method
+ of a subprocess.Popen object.
+ """
+ stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
+ return stderr
def args_from_interpreter_flags():
"""Return a list of command-line arguments reproducing the current
@@ -1308,11 +1585,11 @@ def args_from_interpreter_flags():
flag_opt_map = {
'bytes_warning': 'b',
'dont_write_bytecode': 'B',
+ 'hash_randomization': 'R',
'ignore_environment': 'E',
'no_user_site': 's',
'no_site': 'S',
'optimize': 'O',
- 'py3k_warning': '3',
'verbose': 'v',
}
args = []
@@ -1322,12 +1599,123 @@ def args_from_interpreter_flags():
args.append('-' + opt * v)
return args
-def strip_python_stderr(stderr):
- """Strip the stderr of a Python process from potential debug output
- emitted by the interpreter.
+#============================================================
+# Support for assertions about logging.
+#============================================================
+
+class TestHandler(logging.handlers.BufferingHandler):
+ def __init__(self, matcher):
+ # BufferingHandler takes a "capacity" argument
+ # so as to know when to flush. As we're overriding
+ # shouldFlush anyway, we can set a capacity of zero.
+ # You can call flush() manually to clear out the
+ # buffer.
+ logging.handlers.BufferingHandler.__init__(self, 0)
+ self.matcher = matcher
+
+ def shouldFlush(self):
+ return False
+
+ def emit(self, record):
+ self.format(record)
+ self.buffer.append(record.__dict__)
+
+ def matches(self, **kwargs):
+ """
+ Look for a saved dict whose keys/values match the supplied arguments.
+ """
+ result = False
+ for d in self.buffer:
+ if self.matcher.matches(d, **kwargs):
+ result = True
+ break
+ return result
+
+class Matcher(object):
+
+ _partial_matches = ('msg', 'message')
+
+ def matches(self, d, **kwargs):
+ """
+ Try to match a single dict with the supplied arguments.
+
+ Keys whose values are strings and which are in self._partial_matches
+ will be checked for partial (i.e. substring) matches. You can extend
+ this scheme to (for example) do regular expression matching, etc.
+ """
+ result = True
+ for k in kwargs:
+ v = kwargs[k]
+ dv = d.get(k)
+ if not self.match_value(k, dv, v):
+ result = False
+ break
+ return result
+
+ def match_value(self, k, dv, v):
+ """
+ Try to match a single stored value (dv) with a supplied value (v).
+ """
+ if type(v) != type(dv):
+ result = False
+ elif type(dv) is not str or k not in self._partial_matches:
+ result = (v == dv)
+ else:
+ result = dv.find(v) >= 0
+ return result
+
+
+_can_symlink = None
+def can_symlink():
+ global _can_symlink
+ if _can_symlink is not None:
+ return _can_symlink
+ symlink_path = TESTFN + "can_symlink"
+ try:
+ os.symlink(TESTFN, symlink_path)
+ can = True
+ except (OSError, NotImplementedError, AttributeError):
+ can = False
+ else:
+ os.remove(symlink_path)
+ _can_symlink = can
+ return can
+
+def skip_unless_symlink(test):
+ """Skip decorator for tests that require functional symlink"""
+ ok = can_symlink()
+ msg = "Requires functional symlink implementation"
+ return test if ok else unittest.skip(msg)(test)
+
+def patch(test_instance, object_to_patch, attr_name, new_value):
+ """Override 'object_to_patch'.'attr_name' with 'new_value'.
+
+ Also, add a cleanup procedure to 'test_instance' to restore
+ 'object_to_patch' value for 'attr_name'.
+ The 'attr_name' should be a valid attribute for 'object_to_patch'.
- This will typically be run on the result of the communicate() method
- of a subprocess.Popen object.
"""
- stderr = re.sub(br"\[\d+ refs\]\r?\n?$", b"", stderr).strip()
- return stderr
+ # check that 'attr_name' is a real attribute for 'object_to_patch'
+ # will raise AttributeError if it does not exist
+ getattr(object_to_patch, attr_name)
+
+ # keep a copy of the old value
+ attr_is_local = False
+ try:
+ old_value = object_to_patch.__dict__[attr_name]
+ except (AttributeError, KeyError):
+ old_value = getattr(object_to_patch, attr_name, None)
+ else:
+ attr_is_local = True
+
+ # restore the value when the test is done
+ def cleanup():
+ if attr_is_local:
+ setattr(object_to_patch, attr_name, old_value)
+ else:
+ delattr(object_to_patch, attr_name)
+
+ test_instance.addCleanup(cleanup)
+
+ # actually override the attribute
+ setattr(object_to_patch, attr_name, new_value)
diff --git a/Lib/test/symlink_support.py b/Lib/test/symlink_support.py
deleted file mode 100644
index 301d0f99a92..00000000000
--- a/Lib/test/symlink_support.py
+++ /dev/null
@@ -1,100 +0,0 @@
-import os
-import unittest
-import platform
-
-from test.test_support import TESTFN
-
-def can_symlink():
- # cache the result in can_symlink.prev_val
- prev_val = getattr(can_symlink, 'prev_val', None)
- if prev_val is not None:
- return prev_val
- symlink_path = TESTFN + "can_symlink"
- try:
- symlink(TESTFN, symlink_path)
- can = True
- except (OSError, NotImplementedError, AttributeError):
- can = False
- else:
- os.remove(symlink_path)
- can_symlink.prev_val = can
- return can
-
-def skip_unless_symlink(test):
- """Skip decorator for tests that require functional symlink"""
- ok = can_symlink()
- msg = "Requires functional symlink implementation"
- return test if ok else unittest.skip(msg)(test)
-
-def _symlink_win32(target, link, target_is_directory=False):
- """
- Ctypes symlink implementation since Python doesn't support
- symlinks in windows yet. Borrowed from jaraco.windows project.
- """
- import ctypes.wintypes
- CreateSymbolicLink = ctypes.windll.kernel32.CreateSymbolicLinkW
- CreateSymbolicLink.argtypes = (
- ctypes.wintypes.LPWSTR,
- ctypes.wintypes.LPWSTR,
- ctypes.wintypes.DWORD,
- )
- CreateSymbolicLink.restype = ctypes.wintypes.BOOLEAN
-
- def format_system_message(errno):
- """
- Call FormatMessage with a system error number to retrieve
- the descriptive error message.
- """
- # first some flags used by FormatMessageW
- ALLOCATE_BUFFER = 0x100
- ARGUMENT_ARRAY = 0x2000
- FROM_HMODULE = 0x800
- FROM_STRING = 0x400
- FROM_SYSTEM = 0x1000
- IGNORE_INSERTS = 0x200
-
- # Let FormatMessageW allocate the buffer (we'll free it below)
- # Also, let it know we want a system error message.
- flags = ALLOCATE_BUFFER | FROM_SYSTEM
- source = None
- message_id = errno
- language_id = 0
- result_buffer = ctypes.wintypes.LPWSTR()
- buffer_size = 0
- arguments = None
- bytes = ctypes.windll.kernel32.FormatMessageW(
- flags,
- source,
- message_id,
- language_id,
- ctypes.byref(result_buffer),
- buffer_size,
- arguments,
- )
- # note the following will cause an infinite loop if GetLastError
- # repeatedly returns an error that cannot be formatted, although
- # this should not happen.
- handle_nonzero_success(bytes)
- message = result_buffer.value
- ctypes.windll.kernel32.LocalFree(result_buffer)
- return message
-
- def handle_nonzero_success(result):
- if result == 0:
- value = ctypes.windll.kernel32.GetLastError()
- strerror = format_system_message(value)
- raise WindowsError(value, strerror)
-
- target_is_directory = target_is_directory or os.path.isdir(target)
- handle_nonzero_success(CreateSymbolicLink(link, target, target_is_directory))
-
-symlink = os.symlink if hasattr(os, 'symlink') else (
- _symlink_win32 if platform.system() == 'Windows' else None
-)
-
-def remove_symlink(name):
- # On Windows, to remove a directory symlink, one must use rmdir
- try:
- os.rmdir(name)
- except OSError:
- os.remove(name)
diff --git a/Lib/test/test_MimeWriter.py b/Lib/test/test_MimeWriter.py
deleted file mode 100644
index 2f6636dfdf1..00000000000
--- a/Lib/test/test_MimeWriter.py
+++ /dev/null
@@ -1,292 +0,0 @@
-"""Test program for MimeWriter module.
-
-The test program was too big to comfortably fit in the MimeWriter
-class, so it's here in its own file.
-
-This should generate Barry's example, modulo some quotes and newlines.
-
-"""
-
-import unittest, StringIO
-from test.test_support import run_unittest, import_module
-
-import_module("MimeWriter", deprecated=True)
-from MimeWriter import MimeWriter
-
-SELLER = '''\
-INTERFACE Seller-1;
-
-TYPE Seller = OBJECT
- DOCUMENTATION "A simple Seller interface to test ILU"
- METHODS
- price():INTEGER,
- END;
-'''
-
-BUYER = '''\
-class Buyer:
- def __setup__(self, maxprice):
- self._maxprice = maxprice
-
- def __main__(self, kos):
- """Entry point upon arrival at a new KOS."""
- broker = kos.broker()
- # B4 == Barry's Big Bass Business :-)
- seller = broker.lookup('Seller_1.Seller', 'B4')
- if seller:
- price = seller.price()
- print 'Seller wants $', price, '... '
- if price > self._maxprice:
- print 'too much!'
- else:
- print "I'll take it!"
- else:
- print 'no seller found here'
-''' # Don't ask why this comment is here
-
-STATE = '''\
-# instantiate a buyer instance and put it in a magic place for the KOS
-# to find.
-__kp__ = Buyer()
-__kp__.__setup__(500)
-'''
-
-SIMPLE_METADATA = [
- ("Interpreter", "python"),
- ("Interpreter-Version", "1.3"),
- ("Owner-Name", "Barry Warsaw"),
- ("Owner-Rendezvous", "bwarsaw@cnri.reston.va.us"),
- ("Home-KSS", "kss.cnri.reston.va.us"),
- ("Identifier", "hdl://cnri.kss/my_first_knowbot"),
- ("Launch-Date", "Mon Feb 12 16:39:03 EST 1996"),
- ]
-
-COMPLEX_METADATA = [
- ("Metadata-Type", "complex"),
- ("Metadata-Key", "connection"),
- ("Access", "read-only"),
- ("Connection-Description", "Barry's Big Bass Business"),
- ("Connection-Id", "B4"),
- ("Connection-Direction", "client"),
- ]
-
-EXTERNAL_METADATA = [
- ("Metadata-Type", "complex"),
- ("Metadata-Key", "generic-interface"),
- ("Access", "read-only"),
- ("Connection-Description", "Generic Interface for All Knowbots"),
- ("Connection-Id", "generic-kp"),
- ("Connection-Direction", "client"),
- ]
-
-
-OUTPUT = '''\
-From: bwarsaw@cnri.reston.va.us
-Date: Mon Feb 12 17:21:48 EST 1996
-To: kss-submit@cnri.reston.va.us
-MIME-Version: 1.0
-Content-Type: multipart/knowbot;
- boundary="801spam999";
- version="0.1"
-
-This is a multi-part message in MIME format.
-
---801spam999
-Content-Type: multipart/knowbot-metadata;
- boundary="802spam999"
-
-
---802spam999
-Content-Type: message/rfc822
-KP-Metadata-Type: simple
-KP-Access: read-only
-
-KPMD-Interpreter: python
-KPMD-Interpreter-Version: 1.3
-KPMD-Owner-Name: Barry Warsaw
-KPMD-Owner-Rendezvous: bwarsaw@cnri.reston.va.us
-KPMD-Home-KSS: kss.cnri.reston.va.us
-KPMD-Identifier: hdl://cnri.kss/my_first_knowbot
-KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996
-
---802spam999
-Content-Type: text/isl
-KP-Metadata-Type: complex
-KP-Metadata-Key: connection
-KP-Access: read-only
-KP-Connection-Description: Barry's Big Bass Business
-KP-Connection-Id: B4
-KP-Connection-Direction: client
-
-INTERFACE Seller-1;
-
-TYPE Seller = OBJECT
- DOCUMENTATION "A simple Seller interface to test ILU"
- METHODS
- price():INTEGER,
- END;
-
---802spam999
-Content-Type: message/external-body;
- access-type="URL";
- URL="hdl://cnri.kss/generic-knowbot"
-
-Content-Type: text/isl
-KP-Metadata-Type: complex
-KP-Metadata-Key: generic-interface
-KP-Access: read-only
-KP-Connection-Description: Generic Interface for All Knowbots
-KP-Connection-Id: generic-kp
-KP-Connection-Direction: client
-
-
---802spam999--
-
---801spam999
-Content-Type: multipart/knowbot-code;
- boundary="803spam999"
-
-
---803spam999
-Content-Type: text/plain
-KP-Module-Name: BuyerKP
-
-class Buyer:
- def __setup__(self, maxprice):
- self._maxprice = maxprice
-
- def __main__(self, kos):
- """Entry point upon arrival at a new KOS."""
- broker = kos.broker()
- # B4 == Barry's Big Bass Business :-)
- seller = broker.lookup('Seller_1.Seller', 'B4')
- if seller:
- price = seller.price()
- print 'Seller wants $', price, '... '
- if price > self._maxprice:
- print 'too much!'
- else:
- print "I'll take it!"
- else:
- print 'no seller found here'
-
---803spam999--
-
---801spam999
-Content-Type: multipart/knowbot-state;
- boundary="804spam999"
-KP-Main-Module: main
-
-
---804spam999
-Content-Type: text/plain
-KP-Module-Name: main
-
-# instantiate a buyer instance and put it in a magic place for the KOS
-# to find.
-__kp__ = Buyer()
-__kp__.__setup__(500)
-
---804spam999--
-
---801spam999--
-'''
-
-class MimewriterTest(unittest.TestCase):
-
- def test(self):
- buf = StringIO.StringIO()
-
- # Toplevel headers
-
- toplevel = MimeWriter(buf)
- toplevel.addheader("From", "bwarsaw@cnri.reston.va.us")
- toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996")
- toplevel.addheader("To", "kss-submit@cnri.reston.va.us")
- toplevel.addheader("MIME-Version", "1.0")
-
- # Toplevel body parts
-
- f = toplevel.startmultipartbody("knowbot", "801spam999",
- [("version", "0.1")], prefix=0)
- f.write("This is a multi-part message in MIME format.\n")
-
- # First toplevel body part: metadata
-
- md = toplevel.nextpart()
- md.startmultipartbody("knowbot-metadata", "802spam999")
-
- # Metadata part 1
-
- md1 = md.nextpart()
- md1.addheader("KP-Metadata-Type", "simple")
- md1.addheader("KP-Access", "read-only")
- m = MimeWriter(md1.startbody("message/rfc822"))
- for key, value in SIMPLE_METADATA:
- m.addheader("KPMD-" + key, value)
- m.flushheaders()
- del md1
-
- # Metadata part 2
-
- md2 = md.nextpart()
- for key, value in COMPLEX_METADATA:
- md2.addheader("KP-" + key, value)
- f = md2.startbody("text/isl")
- f.write(SELLER)
- del md2
-
- # Metadata part 3
-
- md3 = md.nextpart()
- f = md3.startbody("message/external-body",
- [("access-type", "URL"),
- ("URL", "hdl://cnri.kss/generic-knowbot")])
- m = MimeWriter(f)
- for key, value in EXTERNAL_METADATA:
- md3.addheader("KP-" + key, value)
- md3.startbody("text/isl")
- # Phantom body doesn't need to be written
-
- md.lastpart()
-
- # Second toplevel body part: code
-
- code = toplevel.nextpart()
- code.startmultipartbody("knowbot-code", "803spam999")
-
- # Code: buyer program source
-
- buyer = code.nextpart()
- buyer.addheader("KP-Module-Name", "BuyerKP")
- f = buyer.startbody("text/plain")
- f.write(BUYER)
-
- code.lastpart()
-
- # Third toplevel body part: state
-
- state = toplevel.nextpart()
- state.addheader("KP-Main-Module", "main")
- state.startmultipartbody("knowbot-state", "804spam999")
-
- # State: a bunch of assignments
-
- st = state.nextpart()
- st.addheader("KP-Module-Name", "main")
- f = st.startbody("text/plain")
- f.write(STATE)
-
- state.lastpart()
-
- # End toplevel body parts
-
- toplevel.lastpart()
-
- self.assertEqual(buf.getvalue(), OUTPUT)
-
-def test_main():
- run_unittest(MimewriterTest)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_SimpleHTTPServer.py b/Lib/test/test_SimpleHTTPServer.py
deleted file mode 100644
index 66ec8536849..00000000000
--- a/Lib/test/test_SimpleHTTPServer.py
+++ /dev/null
@@ -1,41 +0,0 @@
-"""
-These tests only check url parsing for now.
-We don't want to require the 'network' resource.
-"""
-
-import os, unittest
-from SimpleHTTPServer import SimpleHTTPRequestHandler
-from test import test_support
-
-
-class SocketlessRequestHandler (SimpleHTTPRequestHandler):
- def __init__(self):
- pass
-
-class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
- """ Test url parsing """
- def setUp (self):
- self.translated = os.getcwd()
- self.translated = os.path.join(self.translated, 'filename')
- self.handler = SocketlessRequestHandler ()
-
- def test_queryArguments (self):
- path = self.handler.translate_path ('/filename')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('/filename?foo=bar')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('/filename?a=b&spam=eggs#zot')
- self.assertEqual (path, self.translated)
-
- def test_startWithDoubleSlash (self):
- path = self.handler.translate_path ('//filename')
- self.assertEqual (path, self.translated)
- path = self.handler.translate_path ('//filename?foo=bar')
- self.assertEqual (path, self.translated)
-
-
-def test_main():
- test_support.run_unittest(SimpleHTTPRequestHandlerTestCase)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_StringIO.py b/Lib/test/test_StringIO.py
deleted file mode 100644
index bf0c733db7b..00000000000
--- a/Lib/test/test_StringIO.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# Tests StringIO and cStringIO
-
-import unittest
-import StringIO
-import cStringIO
-import types
-import array
-from test import test_support
-
-
-class TestGenericStringIO(unittest.TestCase):
- # use a class variable MODULE to define which module is being tested
-
- # Line of data to test as string
- _line = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!'
-
- # Constructor to use for the test data (._line is passed to this
- # constructor)
- constructor = str
-
- def setUp(self):
- self._line = self.constructor(self._line)
- self._lines = self.constructor((self._line + '\n') * 5)
- self._fp = self.MODULE.StringIO(self._lines)
-
- def test_reads(self):
- eq = self.assertEqual
- self.assertRaises(TypeError, self._fp.seek)
- eq(self._fp.read(10), self._line[:10])
- eq(self._fp.readline(), self._line[10:] + '\n')
- eq(len(self._fp.readlines(60)), 2)
- self._fp.seek(0)
- eq(self._fp.readline(-1), self._line + '\n')
-
- def test_writes(self):
- f = self.MODULE.StringIO()
- self.assertRaises(TypeError, f.seek)
- f.write(self._line[:6])
- f.seek(3)
- f.write(self._line[20:26])
- f.write(self._line[52])
- self.assertEqual(f.getvalue(), 'abcuvwxyz!')
-
- def test_writelines(self):
- f = self.MODULE.StringIO()
- f.writelines([self._line[0], self._line[1], self._line[2]])
- f.seek(0)
- self.assertEqual(f.getvalue(), 'abc')
-
- def test_writelines_error(self):
- def errorGen():
- yield 'a'
- raise KeyboardInterrupt()
- f = self.MODULE.StringIO()
- self.assertRaises(KeyboardInterrupt, f.writelines, errorGen())
-
- def test_truncate(self):
- eq = self.assertEqual
- f = self.MODULE.StringIO()
- f.write(self._lines)
- f.seek(10)
- f.truncate()
- eq(f.getvalue(), 'abcdefghij')
- f.truncate(5)
- eq(f.getvalue(), 'abcde')
- f.write('xyz')
- eq(f.getvalue(), 'abcdexyz')
- self.assertRaises(IOError, f.truncate, -1)
- f.close()
- self.assertRaises(ValueError, f.write, 'frobnitz')
-
- def test_closed_flag(self):
- f = self.MODULE.StringIO()
- self.assertEqual(f.closed, False)
- f.close()
- self.assertEqual(f.closed, True)
- f = self.MODULE.StringIO("abc")
- self.assertEqual(f.closed, False)
- f.close()
- self.assertEqual(f.closed, True)
-
- def test_isatty(self):
- f = self.MODULE.StringIO()
- self.assertRaises(TypeError, f.isatty, None)
- self.assertEqual(f.isatty(), False)
- f.close()
- self.assertRaises(ValueError, f.isatty)
-
- def test_iterator(self):
- eq = self.assertEqual
- unless = self.assertTrue
- eq(iter(self._fp), self._fp)
- # Does this object support the iteration protocol?
- unless(hasattr(self._fp, '__iter__'))
- unless(hasattr(self._fp, 'next'))
- i = 0
- for line in self._fp:
- eq(line, self._line + '\n')
- i += 1
- eq(i, 5)
- self._fp.close()
- self.assertRaises(ValueError, self._fp.next)
-
- def test_getvalue(self):
- self._fp.close()
- self.assertRaises(ValueError, self._fp.getvalue)
-
-class TestStringIO(TestGenericStringIO):
- MODULE = StringIO
-
- def test_unicode(self):
-
- if not test_support.have_unicode: return
-
- # The StringIO module also supports concatenating Unicode
- # snippets to larger Unicode strings. This is tested by this
- # method. Note that cStringIO does not support this extension.
-
- f = self.MODULE.StringIO()
- f.write(self._line[:6])
- f.seek(3)
- f.write(unicode(self._line[20:26]))
- f.write(unicode(self._line[52]))
- s = f.getvalue()
- self.assertEqual(s, unicode('abcuvwxyz!'))
- self.assertEqual(type(s), types.UnicodeType)
-
-class TestcStringIO(TestGenericStringIO):
- MODULE = cStringIO
-
- def test_array_support(self):
- # Issue #1730114: cStringIO should accept array objects
- a = array.array('B', [0,1,2])
- f = self.MODULE.StringIO(a)
- self.assertEqual(f.getvalue(), '\x00\x01\x02')
-
- def test_unicode(self):
-
- if not test_support.have_unicode: return
-
- # The cStringIO module converts Unicode strings to character
- # strings when writing them to cStringIO objects.
- # Check that this works.
-
- f = self.MODULE.StringIO()
- f.write(u'abcde')
- s = f.getvalue()
- self.assertEqual(s, 'abcde')
- self.assertEqual(type(s), str)
-
- f = self.MODULE.StringIO(u'abcde')
- s = f.getvalue()
- self.assertEqual(s, 'abcde')
- self.assertEqual(type(s), str)
-
- self.assertRaises(UnicodeEncodeError, self.MODULE.StringIO, u'\xf4')
-
-
-import sys
-if sys.platform.startswith('java'):
- # Jython doesn't have a buffer object, so we just do a useless
- # fake of the buffer tests.
- buffer = str
-
-class TestBufferStringIO(TestStringIO):
- constructor = buffer
-
-class TestBuffercStringIO(TestcStringIO):
- constructor = buffer
-
-
-def test_main():
- test_support.run_unittest(TestStringIO, TestcStringIO)
- with test_support.check_py3k_warnings(("buffer.. not supported",
- DeprecationWarning)):
- test_support.run_unittest(TestBufferStringIO, TestBuffercStringIO)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test___all__.py b/Lib/test/test___all__.py
index 2c5dbefb3a0..608ec01f140 100644
--- a/Lib/test/test___all__.py
+++ b/Lib/test/test___all__.py
@@ -1,16 +1,8 @@
-from __future__ import print_function
-
import unittest
-from test import test_support as support
+from test import support
import os
import sys
-# Setup bsddb warnings
-try:
- bsddb = support.import_module('bsddb', deprecated=True)
-except unittest.SkipTest:
- pass
-
class NoAll(RuntimeError):
pass
@@ -23,10 +15,12 @@ class AllTest(unittest.TestCase):
def check_all(self, modname):
names = {}
- with support.check_warnings((".* (module|package)",
- DeprecationWarning), quiet=True):
+ with support.check_warnings(
+ (".* (module|package)", DeprecationWarning),
+ ("", ResourceWarning),
+ quiet=True):
try:
- exec "import %s" % modname in names
+ exec("import %s" % modname, names)
except:
# Silent fail here seems the best route since some modules
# may not be available or not initialize properly in all
@@ -36,7 +30,7 @@ class AllTest(unittest.TestCase):
raise NoAll(modname)
names = {}
try:
- exec "from %s import *" % modname in names
+ exec("from %s import *" % modname, names)
except Exception as e:
# Include the module name in the exception string
self.fail("__all__ failure in {}: {}: {}".format(
@@ -102,7 +96,7 @@ class AllTest(unittest.TestCase):
# This heuristic speeds up the process by removing, de facto,
# most test modules (and avoiding the auto-executing ones).
with open(path, "rb") as f:
- if "__all__" not in f.read():
+ if b"__all__" not in f.read():
raise NoAll(modname)
self.check_all(modname)
except NoAll:
diff --git a/Lib/test/test___future__.py b/Lib/test/test___future__.py
index 1d8f8e68525..9ae4ce40ad4 100644
--- a/Lib/test/test___future__.py
+++ b/Lib/test/test___future__.py
@@ -1,6 +1,6 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
import unittest
-from test import test_support
+from test import support
import __future__
GOOD_SERIALS = ("alpha", "beta", "candidate", "final")
@@ -39,7 +39,7 @@ class FutureTest(unittest.TestCase):
a(isinstance(major, int), "%s major isn't int" % name)
a(isinstance(minor, int), "%s minor isn't int" % name)
a(isinstance(micro, int), "%s micro isn't int" % name)
- a(isinstance(level, basestring),
+ a(isinstance(level, str),
"%s level isn't string" % name)
a(level in GOOD_SERIALS,
"%s level string has unknown value" % name)
@@ -60,7 +60,7 @@ class FutureTest(unittest.TestCase):
def test_main():
- test_support.run_unittest(FutureTest)
+ support.run_unittest(FutureTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index afcb92635df..3fadb575f29 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -1,5 +1,5 @@
-from test.test_support import run_unittest
-from _locale import (setlocale, LC_NUMERIC, localeconv, Error)
+from test.support import run_unittest
+from _locale import (setlocale, LC_ALL, LC_CTYPE, LC_NUMERIC, localeconv, Error)
try:
from _locale import (RADIXCHAR, THOUSEP, nl_langinfo)
except ImportError:
@@ -40,10 +40,10 @@ known_numerics = {'fr_FR' : (',', ''), 'en_US':('.', ',')}
class _LocaleTests(unittest.TestCase):
def setUp(self):
- self.oldlocale = setlocale(LC_NUMERIC)
+ self.oldlocale = setlocale(LC_ALL)
def tearDown(self):
- setlocale(LC_NUMERIC, self.oldlocale)
+ setlocale(LC_ALL, self.oldlocale)
# Want to know what value was calculated, what it was compared against,
# what function was used for the calculation, what type of data was used,
@@ -71,6 +71,7 @@ class _LocaleTests(unittest.TestCase):
for loc in candidate_locales:
try:
setlocale(LC_NUMERIC, loc)
+ setlocale(LC_CTYPE, loc)
except Error:
continue
for li, lc in ((RADIXCHAR, "decimal_point"),
@@ -82,9 +83,11 @@ class _LocaleTests(unittest.TestCase):
for loc in candidate_locales:
try:
setlocale(LC_NUMERIC, loc)
+ setlocale(LC_CTYPE, loc)
except Error:
continue
- for lc in ("decimal_point", "thousands_sep"):
+ for lc in ("decimal_point",
+ "thousands_sep"):
self.numeric_tester('localeconv', localeconv()[lc], lc, loc)
@unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
@@ -93,6 +96,7 @@ class _LocaleTests(unittest.TestCase):
for loc in candidate_locales:
try:
setlocale(LC_NUMERIC, loc)
+ setlocale(LC_CTYPE, loc)
except Error:
continue
for li, lc in ((RADIXCHAR, "decimal_point"),
@@ -115,6 +119,7 @@ class _LocaleTests(unittest.TestCase):
for loc in candidate_locales:
try:
setlocale(LC_NUMERIC, loc)
+ setlocale(LC_CTYPE, loc)
except Error:
continue
diff --git a/Lib/test/test_abc.py b/Lib/test/test_abc.py
index 6a8c3a13274..d86f97c068c 100644
--- a/Lib/test/test_abc.py
+++ b/Lib/test/test_abc.py
@@ -3,8 +3,8 @@
"""Unit tests for abc.py."""
-import unittest, weakref
-from test import test_support
+import unittest
+from test import support
import abc
from inspect import isabstract
@@ -26,28 +26,64 @@ class TestABC(unittest.TestCase):
def bar(self): pass
self.assertFalse(hasattr(bar, "__isabstractmethod__"))
- class C:
- __metaclass__ = abc.ABCMeta
+ class C(metaclass=abc.ABCMeta):
@abc.abstractproperty
def foo(self): return 3
class D(C):
@property
- def foo(self): return super(D, self).foo
+ def foo(self): return super().foo
self.assertEqual(D().foo, 3)
+ def test_abstractclassmethod_basics(self):
+ @abc.abstractclassmethod
+ def foo(cls): pass
+ self.assertTrue(foo.__isabstractmethod__)
+ @classmethod
+ def bar(cls): pass
+ self.assertFalse(hasattr(bar, "__isabstractmethod__"))
+
+ class C(metaclass=abc.ABCMeta):
+ @abc.abstractclassmethod
+ def foo(cls): return cls.__name__
+ self.assertRaises(TypeError, C)
+ class D(C):
+ @classmethod
+ def foo(cls): return super().foo()
+ self.assertEqual(D.foo(), 'D')
+ self.assertEqual(D().foo(), 'D')
+
+ def test_abstractstaticmethod_basics(self):
+ @abc.abstractstaticmethod
+ def foo(): pass
+ self.assertTrue(foo.__isabstractmethod__)
+ @staticmethod
+ def bar(): pass
+ self.assertFalse(hasattr(bar, "__isabstractmethod__"))
+
+ class C(metaclass=abc.ABCMeta):
+ @abc.abstractstaticmethod
+ def foo(): return 3
+ self.assertRaises(TypeError, C)
+ class D(C):
+ @staticmethod
+ def foo(): return 4
+ self.assertEqual(D.foo(), 4)
+ self.assertEqual(D().foo(), 4)
+
def test_abstractmethod_integration(self):
- for abstractthing in [abc.abstractmethod, abc.abstractproperty]:
- class C:
- __metaclass__ = abc.ABCMeta
+ for abstractthing in [abc.abstractmethod, abc.abstractproperty,
+ abc.abstractclassmethod,
+ abc.abstractstaticmethod]:
+ class C(metaclass=abc.ABCMeta):
@abstractthing
def foo(self): pass # abstract
def bar(self): pass # concrete
- self.assertEqual(C.__abstractmethods__, set(["foo"]))
+ self.assertEqual(C.__abstractmethods__, {"foo"})
self.assertRaises(TypeError, C) # because foo is abstract
self.assertTrue(isabstract(C))
class D(C):
def bar(self): pass # concrete override of concrete
- self.assertEqual(D.__abstractmethods__, set(["foo"]))
+ self.assertEqual(D.__abstractmethods__, {"foo"})
self.assertRaises(TypeError, D) # because foo is still abstract
self.assertTrue(isabstract(D))
class E(D):
@@ -58,32 +94,26 @@ class TestABC(unittest.TestCase):
class F(E):
@abstractthing
def bar(self): pass # abstract override of concrete
- self.assertEqual(F.__abstractmethods__, set(["bar"]))
+ self.assertEqual(F.__abstractmethods__, {"bar"})
self.assertRaises(TypeError, F) # because bar is abstract now
self.assertTrue(isabstract(F))
- def test_subclass_oldstyle_class(self):
- class A:
- __metaclass__ = abc.ABCMeta
- class OldstyleClass:
- pass
- self.assertFalse(issubclass(OldstyleClass, A))
- self.assertFalse(issubclass(A, OldstyleClass))
-
- def test_isinstance_class(self):
- class A:
- __metaclass__ = abc.ABCMeta
- class OldstyleClass:
+ def test_metaclass_abc(self):
+ # Metaclasses can be ABCs, too.
+ class A(metaclass=abc.ABCMeta):
+ @abc.abstractmethod
+ def x(self):
+ pass
+ self.assertEqual(A.__abstractmethods__, {"x"})
+ class meta(type, A):
+ def x(self):
+ return 1
+ class C(metaclass=meta):
pass
- self.assertFalse(isinstance(OldstyleClass, A))
- self.assertTrue(isinstance(OldstyleClass, type(OldstyleClass)))
- self.assertFalse(isinstance(A, OldstyleClass))
- # This raises a recursion depth error, but is low-priority:
- # self.assertTrue(isinstance(A, abc.ABCMeta))
def test_registration_basics(self):
- class A:
- __metaclass__ = abc.ABCMeta
+ class A(metaclass=abc.ABCMeta):
+ pass
class B(object):
pass
b = B()
@@ -105,9 +135,9 @@ class TestABC(unittest.TestCase):
self.assertIsInstance(c, (A,))
def test_isinstance_invalidation(self):
- class A:
- __metaclass__ = abc.ABCMeta
- class B(object):
+ class A(metaclass=abc.ABCMeta):
+ pass
+ class B:
pass
b = B()
self.assertFalse(isinstance(b, A))
@@ -117,8 +147,8 @@ class TestABC(unittest.TestCase):
self.assertTrue(isinstance(b, (A,)))
def test_registration_builtins(self):
- class A:
- __metaclass__ = abc.ABCMeta
+ class A(metaclass=abc.ABCMeta):
+ pass
A.register(int)
self.assertIsInstance(42, A)
self.assertIsInstance(42, (A,))
@@ -126,15 +156,18 @@ class TestABC(unittest.TestCase):
self.assertTrue(issubclass(int, (A,)))
class B(A):
pass
- B.register(basestring)
+ B.register(str)
+ class C(str): pass
self.assertIsInstance("", A)
self.assertIsInstance("", (A,))
self.assertTrue(issubclass(str, A))
self.assertTrue(issubclass(str, (A,)))
+ self.assertTrue(issubclass(C, A))
+ self.assertTrue(issubclass(C, (A,)))
def test_registration_edge_cases(self):
- class A:
- __metaclass__ = abc.ABCMeta
+ class A(metaclass=abc.ABCMeta):
+ pass
A.register(A) # should pass silently
class A1(A):
pass
@@ -150,24 +183,24 @@ class TestABC(unittest.TestCase):
C.register(B) # ok
def test_register_non_class(self):
- class A(object):
- __metaclass__ = abc.ABCMeta
- self.assertRaisesRegexp(TypeError, "Can only register classes",
- A.register, 4)
+ class A(metaclass=abc.ABCMeta):
+ pass
+ self.assertRaisesRegex(TypeError, "Can only register classes",
+ A.register, 4)
def test_registration_transitiveness(self):
- class A:
- __metaclass__ = abc.ABCMeta
+ class A(metaclass=abc.ABCMeta):
+ pass
self.assertTrue(issubclass(A, A))
self.assertTrue(issubclass(A, (A,)))
- class B:
- __metaclass__ = abc.ABCMeta
+ class B(metaclass=abc.ABCMeta):
+ pass
self.assertFalse(issubclass(A, B))
self.assertFalse(issubclass(A, (B,)))
self.assertFalse(issubclass(B, A))
self.assertFalse(issubclass(B, (A,)))
- class C:
- __metaclass__ = abc.ABCMeta
+ class C(metaclass=abc.ABCMeta):
+ pass
A.register(B)
class B1(B):
pass
@@ -195,38 +228,22 @@ class TestABC(unittest.TestCase):
self.assertIsInstance(42, (A,))
def test_all_new_methods_are_called(self):
- class A:
- __metaclass__ = abc.ABCMeta
+ class A(metaclass=abc.ABCMeta):
+ pass
class B(object):
counter = 0
def __new__(cls):
B.counter += 1
- return super(B, cls).__new__(cls)
+ return super().__new__(cls)
class C(A, B):
pass
self.assertEqual(B.counter, 0)
C()
self.assertEqual(B.counter, 1)
- def test_cache_leak(self):
- # See issue #2521.
- class A(object):
- __metaclass__ = abc.ABCMeta
- @abc.abstractmethod
- def f(self):
- pass
- class C(A):
- def f(self):
- A.f(self)
- r = weakref.ref(C)
- # Trigger cache.
- C().f()
- del C
- test_support.gc_collect()
- self.assertEqual(r(), None)
def test_main():
- test_support.run_unittest(TestABC)
+ support.run_unittest(TestABC)
if __name__ == "__main__":
diff --git a/Lib/test/test_abstract_numbers.py b/Lib/test/test_abstract_numbers.py
index 925f8cf60c1..2a396cdad15 100644
--- a/Lib/test/test_abstract_numbers.py
+++ b/Lib/test/test_abstract_numbers.py
@@ -1,9 +1,10 @@
"""Unit tests for numbers.py."""
import math
+import operator
import unittest
from numbers import Complex, Real, Rational, Integral
-from test import test_support
+from test import support
class TestNumbers(unittest.TestCase):
def test_int(self):
@@ -16,16 +17,6 @@ class TestNumbers(unittest.TestCase):
self.assertEqual(7, int(7).numerator)
self.assertEqual(1, int(7).denominator)
- def test_long(self):
- self.assertTrue(issubclass(long, Integral))
- self.assertTrue(issubclass(long, Complex))
-
- self.assertEqual(7, long(7).real)
- self.assertEqual(0, long(7).imag)
- self.assertEqual(7, long(7).conjugate())
- self.assertEqual(7, long(7).numerator)
- self.assertEqual(1, long(7).denominator)
-
def test_float(self):
self.assertFalse(issubclass(float, Rational))
self.assertTrue(issubclass(float, Real))
@@ -40,12 +31,15 @@ class TestNumbers(unittest.TestCase):
c1, c2 = complex(3, 2), complex(4,1)
# XXX: This is not ideal, but see the comment in math_trunc().
- self.assertRaises(AttributeError, math.trunc, c1)
+ self.assertRaises(TypeError, math.trunc, c1)
+ self.assertRaises(TypeError, operator.mod, c1, c2)
+ self.assertRaises(TypeError, divmod, c1, c2)
+ self.assertRaises(TypeError, operator.floordiv, c1, c2)
self.assertRaises(TypeError, float, c1)
self.assertRaises(TypeError, int, c1)
def test_main():
- test_support.run_unittest(TestNumbers)
+ support.run_unittest(TestNumbers)
if __name__ == "__main__":
diff --git a/Lib/test/test_aepack.py b/Lib/test/test_aepack.py
deleted file mode 100644
index f4ea25b5f04..00000000000
--- a/Lib/test/test_aepack.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# Copyright (C) 2003 Python Software Foundation
-
-import unittest
-import os
-from test import test_support
-
-aetypes = test_support.import_module('aetypes')
-aepack = test_support.import_module('aepack')
-
-class TestAepack(unittest.TestCase):
- OBJECTS = [
- aetypes.Enum('enum'),
- aetypes.Type('type'),
- aetypes.Keyword('kwrd'),
- aetypes.Range(1, 10),
- aetypes.Comparison(1, '< ', 10),
- aetypes.Logical('not ', 1),
- aetypes.IntlText(0, 0, 'international text'),
- aetypes.IntlWritingCode(0,0),
- aetypes.QDPoint(50,100),
- aetypes.QDRectangle(50,100,150,200),
- aetypes.RGBColor(0x7000, 0x6000, 0x5000),
- aetypes.Unknown('xxxx', 'unknown type data'),
- aetypes.Character(1),
- aetypes.Character(2, aetypes.Line(2)),
- ]
-
- def test_roundtrip_string(self):
- o = 'a string'
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o, unpacked)
-
- def test_roundtrip_int(self):
- o = 12
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o, unpacked)
-
- def test_roundtrip_float(self):
- o = 12.1
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o, unpacked)
-
- def test_roundtrip_None(self):
- o = None
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o, unpacked)
-
- def test_roundtrip_aeobjects(self):
- for o in self.OBJECTS:
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(repr(o), repr(unpacked))
-
- def test_roundtrip_FSSpec(self):
- try:
- import Carbon.File
- except:
- return
-
- if not hasattr(Carbon.File, "FSSpec"):
- return
- o = Carbon.File.FSSpec(os.curdir)
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o.as_pathname(), unpacked.as_pathname())
-
- def test_roundtrip_Alias(self):
- try:
- import Carbon.File
- except:
- return
- if not hasattr(Carbon.File, "FSSpec"):
- return
- o = Carbon.File.FSSpec(os.curdir).NewAliasMinimal()
- packed = aepack.pack(o)
- unpacked = aepack.unpack(packed)
- self.assertEqual(o.FSResolveAlias(None)[0].as_pathname(),
- unpacked.FSResolveAlias(None)[0].as_pathname())
-
-
-def test_main():
- test_support.run_unittest(TestAepack)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_aifc.py b/Lib/test/test_aifc.py
index e4928382582..ee4ad6b0a32 100644
--- a/Lib/test/test_aifc.py
+++ b/Lib/test/test_aifc.py
@@ -1,7 +1,8 @@
-from test.test_support import findfile, run_unittest, TESTFN
+from test.support import findfile, run_unittest, TESTFN, captured_stdout, unlink
import unittest
import os
import io
+import struct
import aifc
@@ -20,10 +21,8 @@ class AIFCTest(unittest.TestCase):
self.fout.close()
except (aifc.Error, AttributeError):
pass
- try:
- os.remove(TESTFN)
- except OSError:
- pass
+ unlink(TESTFN)
+ unlink(TESTFN + '.aiff')
def test_skipunknown(self):
#Issue 2245
@@ -32,29 +31,38 @@ class AIFCTest(unittest.TestCase):
def test_params(self):
f = self.f = aifc.open(self.sndfilepath)
+ self.assertEqual(f.getfp().name, self.sndfilepath)
self.assertEqual(f.getnchannels(), 2)
self.assertEqual(f.getsampwidth(), 2)
self.assertEqual(f.getframerate(), 48000)
self.assertEqual(f.getnframes(), 14400)
- self.assertEqual(f.getcomptype(), 'NONE')
- self.assertEqual(f.getcompname(), 'not compressed')
- self.assertEqual(f.getparams(), (2, 2, 48000, 14400, 'NONE', 'not compressed'))
+ self.assertEqual(f.getcomptype(), b'NONE')
+ self.assertEqual(f.getcompname(), b'not compressed')
+ self.assertEqual(
+ f.getparams(),
+ (2, 2, 48000, 14400, b'NONE', b'not compressed'),
+ )
def test_read(self):
f = self.f = aifc.open(self.sndfilepath)
+ self.assertEqual(f.readframes(0), b'')
self.assertEqual(f.tell(), 0)
- self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
+ self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
f.rewind()
pos0 = f.tell()
self.assertEqual(pos0, 0)
- self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
+ self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
pos2 = f.tell()
self.assertEqual(pos2, 2)
- self.assertEqual(f.readframes(2), '\x17t\x17t"\xad"\xad')
+ self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad')
f.setpos(pos2)
- self.assertEqual(f.readframes(2), '\x17t\x17t"\xad"\xad')
+ self.assertEqual(f.readframes(2), b'\x17t\x17t"\xad"\xad')
f.setpos(pos0)
- self.assertEqual(f.readframes(2), '\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
+ self.assertEqual(f.readframes(2), b'\x00\x00\x00\x00\x0b\xd4\x0b\xd4')
+ with self.assertRaises(aifc.Error):
+ f.setpos(-1)
+ with self.assertRaises(aifc.Error):
+ f.setpos(f.getnframes() + 1)
def test_write(self):
f = self.f = aifc.open(self.sndfilepath)
@@ -76,7 +84,7 @@ class AIFCTest(unittest.TestCase):
fout.setnchannels(f.getnchannels())
fout.setsampwidth(f.getsampwidth())
fout.setframerate(f.getframerate())
- fout.setcomptype('ULAW', 'foo')
+ fout.setcomptype(b'ULAW', b'foo')
for frame in range(f.getnframes()):
fout.writeframes(f.readframes(1))
fout.close()
@@ -87,10 +95,8 @@ class AIFCTest(unittest.TestCase):
fout = self.fout = aifc.open(TESTFN, 'rb')
f.rewind()
self.assertEqual(f.getparams()[0:3], fout.getparams()[0:3])
- self.assertEqual(fout.getcomptype(), 'ULAW')
- self.assertEqual(fout.getcompname(), 'foo')
- # XXX: this test fails, not sure if it should succeed or not
- # self.assertEqual(f.readframes(5), fout.readframes(5))
+ self.assertEqual(fout.getcomptype(), b'ULAW')
+ self.assertEqual(fout.getcompname(), b'foo')
def test_close(self):
class Wrapfile(object):
@@ -107,6 +113,39 @@ class AIFCTest(unittest.TestCase):
f.close()
self.assertEqual(testfile.closed, True)
+ def test_write_header_comptype_sampwidth(self):
+ for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ fout.setnchannels(1)
+ fout.setframerate(1)
+ fout.setcomptype(comptype, b'')
+ fout.close()
+ self.assertEqual(fout.getsampwidth(), 2)
+ fout.initfp(None)
+
+ def test_write_markers_values(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ self.assertEqual(fout.getmarkers(), None)
+ fout.setmark(1, 0, b'foo1')
+ fout.setmark(1, 1, b'foo2')
+ self.assertEqual(fout.getmark(1), (1, 1, b'foo2'))
+ self.assertEqual(fout.getmarkers(), [(1, 1, b'foo2')])
+ fout.initfp(None)
+
+ def test_read_markers(self):
+ fout = self.fout = aifc.open(TESTFN, 'wb')
+ fout.aiff()
+ fout.setparams((1, 1, 1, 1, b'NONE', b''))
+ fout.setmark(1, 0, b'odd')
+ fout.setmark(2, 0, b'even')
+ fout.writeframes(b'\x00')
+ fout.close()
+ f = self.f = aifc.open(TESTFN, 'rb')
+ self.assertEqual(f.getmarkers(), [(1, 0, b'odd'), (2, 0, b'even')])
+ self.assertEqual(f.getmark(1), (1, 0, b'odd'))
+ self.assertEqual(f.getmark(2), (2, 0, b'even'))
+ self.assertRaises(aifc.Error, f.getmark, 3)
+
class AIFCLowLevelTest(unittest.TestCase):
@@ -143,6 +182,148 @@ class AIFCLowLevelTest(unittest.TestCase):
with self.assertRaises(ValueError):
aifc._write_string(f, b'too long' * 255)
+ def test_wrong_open_mode(self):
+ with self.assertRaises(aifc.Error):
+ aifc.open(TESTFN, 'wrong_mode')
+
+ def test_read_wrong_form(self):
+ b1 = io.BytesIO(b'WRNG' + struct.pack('>L', 0))
+ b2 = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'WRNG')
+ self.assertRaises(aifc.Error, aifc.open, b1)
+ self.assertRaises(aifc.Error, aifc.open, b2)
+
+ def test_read_no_comm_chunk(self):
+ b = io.BytesIO(b'FORM' + struct.pack('>L', 4) + b'AIFF')
+ self.assertRaises(aifc.Error, aifc.open, b)
+
+ def test_read_wrong_compression_type(self):
+ b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
+ b += b'COMM' + struct.pack('>LhlhhLL', 23, 0, 0, 0, 0, 0, 0)
+ b += b'WRNG' + struct.pack('B', 0)
+ self.assertRaises(aifc.Error, aifc.open, io.BytesIO(b))
+
+ def test_read_wrong_marks(self):
+ b = b'FORM' + struct.pack('>L', 4) + b'AIFF'
+ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
+ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
+ b += b'MARK' + struct.pack('>LhB', 3, 1, 1)
+ with captured_stdout() as s:
+ f = aifc.open(io.BytesIO(b))
+ self.assertEqual(
+ s.getvalue(),
+ 'Warning: MARK chunk contains only 0 markers instead of 1\n')
+ self.assertEqual(f.getmarkers(), None)
+
+ def test_read_comm_kludge_compname_even(self):
+ b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
+ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
+ b += b'NONE' + struct.pack('B', 4) + b'even' + b'\x00'
+ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
+ with captured_stdout() as s:
+ f = aifc.open(io.BytesIO(b))
+ self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n')
+ self.assertEqual(f.getcompname(), b'even')
+
+ def test_read_comm_kludge_compname_odd(self):
+ b = b'FORM' + struct.pack('>L', 4) + b'AIFC'
+ b += b'COMM' + struct.pack('>LhlhhLL', 18, 0, 0, 0, 0, 0, 0)
+ b += b'NONE' + struct.pack('B', 3) + b'odd'
+ b += b'SSND' + struct.pack('>L', 8) + b'\x00' * 8
+ with captured_stdout() as s:
+ f = aifc.open(io.BytesIO(b))
+ self.assertEqual(s.getvalue(), 'Warning: bad COMM chunk size\n')
+ self.assertEqual(f.getcompname(), b'odd')
+
+ def test_write_params_raises(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ wrong_params = (0, 0, 0, 0, b'WRNG', '')
+ self.assertRaises(aifc.Error, fout.setparams, wrong_params)
+ self.assertRaises(aifc.Error, fout.getparams)
+ self.assertRaises(aifc.Error, fout.setnchannels, 0)
+ self.assertRaises(aifc.Error, fout.getnchannels)
+ self.assertRaises(aifc.Error, fout.setsampwidth, 0)
+ self.assertRaises(aifc.Error, fout.getsampwidth)
+ self.assertRaises(aifc.Error, fout.setframerate, 0)
+ self.assertRaises(aifc.Error, fout.getframerate)
+ self.assertRaises(aifc.Error, fout.setcomptype, b'WRNG', '')
+ fout.aiff()
+ fout.setnchannels(1)
+ fout.setsampwidth(1)
+ fout.setframerate(1)
+ fout.setnframes(1)
+ fout.writeframes(b'\x00')
+ self.assertRaises(aifc.Error, fout.setparams, (1, 1, 1, 1, 1, 1))
+ self.assertRaises(aifc.Error, fout.setnchannels, 1)
+ self.assertRaises(aifc.Error, fout.setsampwidth, 1)
+ self.assertRaises(aifc.Error, fout.setframerate, 1)
+ self.assertRaises(aifc.Error, fout.setnframes, 1)
+ self.assertRaises(aifc.Error, fout.setcomptype, b'NONE', '')
+ self.assertRaises(aifc.Error, fout.aiff)
+ self.assertRaises(aifc.Error, fout.aifc)
+
+ def test_write_params_singles(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ fout.aifc()
+ fout.setnchannels(1)
+ fout.setsampwidth(2)
+ fout.setframerate(3)
+ fout.setnframes(4)
+ fout.setcomptype(b'NONE', b'name')
+ self.assertEqual(fout.getnchannels(), 1)
+ self.assertEqual(fout.getsampwidth(), 2)
+ self.assertEqual(fout.getframerate(), 3)
+ self.assertEqual(fout.getnframes(), 0)
+ self.assertEqual(fout.tell(), 0)
+ self.assertEqual(fout.getcomptype(), b'NONE')
+ self.assertEqual(fout.getcompname(), b'name')
+ fout.writeframes(b'\x00' * 4 * fout.getsampwidth() * fout.getnchannels())
+ self.assertEqual(fout.getnframes(), 4)
+ self.assertEqual(fout.tell(), 4)
+
+ def test_write_params_bunch(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ fout.aifc()
+ p = (1, 2, 3, 4, b'NONE', b'name')
+ fout.setparams(p)
+ self.assertEqual(fout.getparams(), p)
+ fout.initfp(None)
+
+ def test_write_header_raises(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ self.assertRaises(aifc.Error, fout.close)
+ fout.setnchannels(1)
+ self.assertRaises(aifc.Error, fout.close)
+ fout.setsampwidth(1)
+ self.assertRaises(aifc.Error, fout.close)
+ fout.initfp(None)
+
+ def test_write_header_comptype_raises(self):
+ for comptype in (b'ULAW', b'ulaw', b'ALAW', b'alaw', b'G722'):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ fout.setsampwidth(1)
+ fout.setcomptype(comptype, b'')
+ self.assertRaises(aifc.Error, fout.close)
+ fout.initfp(None)
+
+ def test_write_markers_raises(self):
+ fout = aifc.open(io.BytesIO(), 'wb')
+ self.assertRaises(aifc.Error, fout.setmark, 0, 0, b'')
+ self.assertRaises(aifc.Error, fout.setmark, 1, -1, b'')
+ self.assertRaises(aifc.Error, fout.setmark, 1, 0, None)
+ self.assertRaises(aifc.Error, fout.getmark, 1)
+ fout.initfp(None)
+
+ def test_write_aiff_by_extension(self):
+ sampwidth = 2
+ fout = self.fout = aifc.open(TESTFN + '.aiff', 'wb')
+ fout.setparams((1, sampwidth, 1, 1, b'ULAW', b''))
+ frames = b'\x00' * fout.getnchannels() * sampwidth
+ fout.writeframes(frames)
+ fout.close()
+ f = self.f = aifc.open(TESTFN + '.aiff', 'rb')
+ self.assertEqual(f.getcomptype(), b'NONE')
+ f.close()
+
def test_main():
run_unittest(AIFCTest)
diff --git a/Lib/test/test_al.py b/Lib/test/test_al.py
deleted file mode 100755
index 688576dc6ad..00000000000
--- a/Lib/test/test_al.py
+++ /dev/null
@@ -1,25 +0,0 @@
-#! /usr/bin/env python
-"""Whimpy test script for the al module
- Roger E. Masse
-"""
-from test.test_support import verbose, import_module
-al = import_module('al', deprecated=True)
-
-alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getparams',
- 'newconfig', 'openport', 'queryparams', 'setparams']
-
-# This is a very unobtrusive test for the existence of the al module and all its
-# attributes. More comprehensive examples can be found in Demo/al
-
-def test_main():
- # touch all the attributes of al without doing anything
- if verbose:
- print 'Touching al module attributes...'
- for attr in alattrs:
- if verbose:
- print 'touching: ', attr
- getattr(al, attr)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_anydbm.py b/Lib/test/test_anydbm.py
deleted file mode 100644
index a01dd0bd9fc..00000000000
--- a/Lib/test/test_anydbm.py
+++ /dev/null
@@ -1,97 +0,0 @@
-#! /usr/bin/env python
-"""Test script for the anydbm module
- based on testdumbdbm.py
-"""
-
-import os
-import unittest
-import glob
-from test import test_support
-
-_fname = test_support.TESTFN
-
-# Silence Py3k warning
-anydbm = test_support.import_module('anydbm', deprecated=True)
-
-def _delete_files():
- # we don't know the precise name the underlying database uses
- # so we use glob to locate all names
- for f in glob.glob(_fname + "*"):
- try:
- os.unlink(f)
- except OSError:
- pass
-
-class AnyDBMTestCase(unittest.TestCase):
- _dict = {'0': '',
- 'a': 'Python:',
- 'b': 'Programming',
- 'c': 'the',
- 'd': 'way',
- 'f': 'Guido',
- 'g': 'intended'
- }
-
- def __init__(self, *args):
- unittest.TestCase.__init__(self, *args)
-
- def test_anydbm_creation(self):
- f = anydbm.open(_fname, 'c')
- self.assertEqual(f.keys(), [])
- for key in self._dict:
- f[key] = self._dict[key]
- self.read_helper(f)
- f.close()
-
- def test_anydbm_modification(self):
- self.init_db()
- f = anydbm.open(_fname, 'c')
- self._dict['g'] = f['g'] = "indented"
- self.read_helper(f)
- f.close()
-
- def test_anydbm_read(self):
- self.init_db()
- f = anydbm.open(_fname, 'r')
- self.read_helper(f)
- f.close()
-
- def test_anydbm_keys(self):
- self.init_db()
- f = anydbm.open(_fname, 'r')
- keys = self.keys_helper(f)
- f.close()
-
- def read_helper(self, f):
- keys = self.keys_helper(f)
- for key in self._dict:
- self.assertEqual(self._dict[key], f[key])
-
- def init_db(self):
- f = anydbm.open(_fname, 'n')
- for k in self._dict:
- f[k] = self._dict[k]
- f.close()
-
- def keys_helper(self, f):
- keys = f.keys()
- keys.sort()
- dkeys = self._dict.keys()
- dkeys.sort()
- self.assertEqual(keys, dkeys)
- return keys
-
- def tearDown(self):
- _delete_files()
-
- def setUp(self):
- _delete_files()
-
-def test_main():
- try:
- test_support.run_unittest(AnyDBMTestCase)
- finally:
- _delete_files()
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_applesingle.py b/Lib/test/test_applesingle.py
deleted file mode 100644
index 1beffe0f2f4..00000000000
--- a/Lib/test/test_applesingle.py
+++ /dev/null
@@ -1,71 +0,0 @@
-# Copyright (C) 2003 Python Software Foundation
-
-import unittest
-import os
-from test import test_support
-import struct
-
-MacOS = test_support.import_module('MacOS')
-# The following should exist if MacOS does.
-import applesingle
-
-AS_MAGIC=0x00051600
-AS_VERSION=0x00020000
-dataforkdata = 'hello\r\0world\n'
-resourceforkdata = 'goodbye\ncruel\0world\r'
-
-applesingledata = struct.pack(">ll16sh", AS_MAGIC, AS_VERSION, "foo", 2) + \
- struct.pack(">llllll", 1, 50, len(dataforkdata),
- 2, 50+len(dataforkdata), len(resourceforkdata)) + \
- dataforkdata + \
- resourceforkdata
-TESTFN2 = test_support.TESTFN + '2'
-
-class TestApplesingle(unittest.TestCase):
-
- def setUp(self):
- fp = open(test_support.TESTFN, 'w')
- fp.write(applesingledata)
- fp.close()
-
- def tearDown(self):
- try:
- os.unlink(test_support.TESTFN)
- except:
- pass
- try:
- os.unlink(TESTFN2)
- except:
- pass
-
- def compareData(self, isrf, data):
- if isrf:
- fp = MacOS.openrf(TESTFN2, '*rb')
- else:
- fp = open(TESTFN2, 'rb')
- filedata = fp.read(1000)
- self.assertEqual(data, filedata)
-
- def test_applesingle(self):
- try:
- os.unlink(TESTFN2)
- except:
- pass
- applesingle.decode(test_support.TESTFN, TESTFN2)
- self.compareData(False, dataforkdata)
- self.compareData(True, resourceforkdata)
-
- def test_applesingle_resonly(self):
- try:
- os.unlink(TESTFN2)
- except:
- pass
- applesingle.decode(test_support.TESTFN, TESTFN2, resonly=True)
- self.compareData(False, resourceforkdata)
-
-def test_main():
- test_support.run_unittest(TestApplesingle)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 30fdf4a4f46..22c26cc1038 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -11,13 +11,12 @@ import tempfile
import unittest
import argparse
-from StringIO import StringIO
+from io import StringIO
+from test import support
class StdIOBuffer(StringIO):
pass
-from test import test_support
-
class TestCase(unittest.TestCase):
def assertEqual(self, obj1, obj2):
@@ -33,7 +32,7 @@ class TestCase(unittest.TestCase):
# The tests assume that line wrapping occurs at 80 columns, but this
# behaviour can be overridden by setting the COLUMNS environment
# variable. To ensure that this assumption is true, unset COLUMNS.
- env = test_support.EnvironmentVarGuard()
+ env = support.EnvironmentVarGuard()
env.unset("COLUMNS")
self.addCleanup(env.__exit__)
@@ -72,8 +71,6 @@ class NS(object):
kwarg_str = ', '.join(['%s=%r' % tup for tup in sorted_items])
return '%s(%s)' % (type(self).__name__, kwarg_str)
- __hash__ = None
-
def __eq__(self, other):
return vars(self) == vars(other)
@@ -1430,8 +1427,6 @@ class RFile(object):
def __init__(self, name):
self.name = name
- __hash__ = None
-
def __eq__(self, other):
if other in self.seen:
text = self.seen[other]
@@ -1458,7 +1453,7 @@ class TestFileTypeR(TempDirMixin, ParserTestCase):
Sig('-x', type=argparse.FileType()),
Sig('spam', type=argparse.FileType('r')),
]
- failures = ['-x', '-x bar', 'non-existent-file.txt']
+ failures = ['-x', '', 'non-existent-file.txt']
successes = [
('foo', NS(x=None, spam=RFile('foo'))),
('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
@@ -1498,7 +1493,7 @@ class TestFileTypeRB(TempDirMixin, ParserTestCase):
Sig('-x', type=argparse.FileType('rb')),
Sig('spam', type=argparse.FileType('rb')),
]
- failures = ['-x', '-x bar']
+ failures = ['-x', '']
successes = [
('foo', NS(x=None, spam=RFile('foo'))),
('-x foo bar', NS(x=RFile('foo'), spam=RFile('bar'))),
@@ -1513,8 +1508,6 @@ class WFile(object):
def __init__(self, name):
self.name = name
- __hash__ = None
-
def __eq__(self, other):
if other not in self.seen:
text = 'Check that file is writable.'
@@ -1539,8 +1532,7 @@ class TestFileTypeW(TempDirMixin, ParserTestCase):
Sig('-x', type=argparse.FileType('w')),
Sig('spam', type=argparse.FileType('w')),
]
- failures = ['-x', '-x bar']
- failures = ['-x', '-x bar', 'readonly']
+ failures = ['-x', '', 'readonly']
successes = [
('foo', NS(x=None, spam=WFile('foo'))),
('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
@@ -1555,7 +1547,7 @@ class TestFileTypeWB(TempDirMixin, ParserTestCase):
Sig('-x', type=argparse.FileType('wb')),
Sig('spam', type=argparse.FileType('wb')),
]
- failures = ['-x', '-x bar']
+ failures = ['-x', '']
successes = [
('foo', NS(x=None, spam=WFile('foo'))),
('-x foo bar', NS(x=WFile('foo'), spam=WFile('bar'))),
@@ -1587,8 +1579,6 @@ class TestTypeUserDefined(ParserTestCase):
def __init__(self, value):
self.value = value
- __hash__ = None
-
def __eq__(self, other):
return (type(self), self.value) == (type(other), other.value)
@@ -1611,8 +1601,6 @@ class TestTypeClassicClass(ParserTestCase):
def __init__(self, value):
self.value = value
- __hash__ = None
-
def __eq__(self, other):
return (type(self), self.value) == (type(other), other.value)
@@ -1745,7 +1733,8 @@ class TestAddSubparsers(TestCase):
def assertArgumentParserError(self, *args, **kwargs):
self.assertRaises(ArgumentParserError, *args, **kwargs)
- def _get_parser(self, subparser_help=False, prefix_chars=None):
+ def _get_parser(self, subparser_help=False, prefix_chars=None,
+ aliases=False):
# create a parser with a subparsers argument
if prefix_chars:
parser = ErrorRaisingArgumentParser(
@@ -1761,13 +1750,21 @@ class TestAddSubparsers(TestCase):
'bar', type=float, help='bar help')
# check that only one subparsers argument can be added
- subparsers = parser.add_subparsers(help='command help')
+ subparsers_kwargs = {}
+ if aliases:
+ subparsers_kwargs['metavar'] = 'COMMAND'
+ subparsers_kwargs['title'] = 'commands'
+ else:
+ subparsers_kwargs['help'] = 'command help'
+ subparsers = parser.add_subparsers(**subparsers_kwargs)
self.assertArgumentParserError(parser.add_subparsers)
# add first sub-parser
parser1_kwargs = dict(description='1 description')
if subparser_help:
parser1_kwargs['help'] = '1 help'
+ if aliases:
+ parser1_kwargs['aliases'] = ['1alias1', '1alias2']
parser1 = subparsers.add_parser('1', **parser1_kwargs)
parser1.add_argument('-w', type=int, help='w help')
parser1.add_argument('x', choices='abc', help='x help')
@@ -1792,7 +1789,7 @@ class TestAddSubparsers(TestCase):
return parser
def setUp(self):
- super(TestAddSubparsers, self).setUp()
+ super().setUp()
self.parser = self._get_parser()
self.command_help_parser = self._get_parser(subparser_help=True)
@@ -1997,6 +1994,45 @@ class TestAddSubparsers(TestCase):
-y {1,2,3} y help
'''))
+ def test_alias_invocation(self):
+ parser = self._get_parser(aliases=True)
+ self.assertEqual(
+ parser.parse_known_args('0.5 1alias1 b'.split()),
+ (NS(foo=False, bar=0.5, w=None, x='b'), []),
+ )
+ self.assertEqual(
+ parser.parse_known_args('0.5 1alias2 b'.split()),
+ (NS(foo=False, bar=0.5, w=None, x='b'), []),
+ )
+
+ def test_error_alias_invocation(self):
+ parser = self._get_parser(aliases=True)
+ self.assertArgumentParserError(parser.parse_args,
+ '0.5 1alias3 b'.split())
+
+ def test_alias_help(self):
+ parser = self._get_parser(aliases=True, subparser_help=True)
+ self.maxDiff = None
+ self.assertEqual(parser.format_help(), textwrap.dedent("""\
+ usage: PROG [-h] [--foo] bar COMMAND ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+
+ commands:
+ COMMAND
+ 1 (1alias1, 1alias2)
+ 1 help
+ 2 2 help
+ 3 3 help
+ """))
+
# ============
# Groups tests
# ============
@@ -2047,7 +2083,7 @@ class TestParentParsers(TestCase):
self.assertRaises(ArgumentParserError, *args, **kwargs)
def setUp(self):
- super(TestParentParsers, self).setUp()
+ super().setUp()
self.wxyz_parent = ErrorRaisingArgumentParser(add_help=False)
self.wxyz_parent.add_argument('--w')
x_group = self.wxyz_parent.add_argument_group('x')
@@ -4740,19 +4776,19 @@ class TestImportStar(TestCase):
items = [
name
for name, value in vars(argparse).items()
- if not name.startswith("_")
+ if not (name.startswith("_") or name == 'ngettext')
if not inspect.ismodule(value)
]
self.assertEqual(sorted(items), sorted(argparse.__all__))
def test_main():
# silence warnings about version argument - these are expected
- with test_support.check_warnings(
+ with support.check_warnings(
('The "version" argument to ArgumentParser is deprecated.',
DeprecationWarning),
('The (format|print)_version method is deprecated',
DeprecationWarning)):
- test_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_array.py b/Lib/test/test_array.py
index 74dccbf1120..e26e9add055 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -1,24 +1,31 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test the arraymodule.
Roger E. Masse
"""
import unittest
+from test import support
+import weakref
+import pickle
+import operator
+import io
+import math
+import struct
import warnings
-from test import test_support
-from weakref import proxy
-import array, cStringIO
-from cPickle import loads, dumps, HIGHEST_PROTOCOL
+
+import array
+from array import _array_reconstructor as array_reconstructor
+
class ArraySubclass(array.array):
pass
class ArraySubclassWithKwargs(array.array):
def __init__(self, typecode, newarg=None):
- array.array.__init__(self, typecode)
+ array.array.__init__(self)
tests = [] # list to accumulate all tests
-typecodes = "cubBhHiIlLfd"
+typecodes = "ubBhHiIlLfd"
class BadConstructorTest(unittest.TestCase):
@@ -30,6 +37,137 @@ class BadConstructorTest(unittest.TestCase):
tests.append(BadConstructorTest)
+# Machine format codes.
+#
+# Search for "enum machine_format_code" in Modules/arraymodule.c to get the
+# authoritative values.
+UNKNOWN_FORMAT = -1
+UNSIGNED_INT8 = 0
+SIGNED_INT8 = 1
+UNSIGNED_INT16_LE = 2
+UNSIGNED_INT16_BE = 3
+SIGNED_INT16_LE = 4
+SIGNED_INT16_BE = 5
+UNSIGNED_INT32_LE = 6
+UNSIGNED_INT32_BE = 7
+SIGNED_INT32_LE = 8
+SIGNED_INT32_BE = 9
+UNSIGNED_INT64_LE = 10
+UNSIGNED_INT64_BE = 11
+SIGNED_INT64_LE = 12
+SIGNED_INT64_BE = 13
+IEEE_754_FLOAT_LE = 14
+IEEE_754_FLOAT_BE = 15
+IEEE_754_DOUBLE_LE = 16
+IEEE_754_DOUBLE_BE = 17
+UTF16_LE = 18
+UTF16_BE = 19
+UTF32_LE = 20
+UTF32_BE = 21
+
+class ArrayReconstructorTest(unittest.TestCase):
+
+ def test_error(self):
+ self.assertRaises(TypeError, array_reconstructor,
+ "", "b", 0, b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ str, "b", 0, b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ array.array, "b", '', b"")
+ self.assertRaises(TypeError, array_reconstructor,
+ array.array, "b", 0, "")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "?", 0, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "b", UNKNOWN_FORMAT, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "b", 22, b"")
+ self.assertRaises(ValueError, array_reconstructor,
+ array.array, "d", 16, b"a")
+
+ def test_numbers(self):
+ testcases = (
+ (['B', 'H', 'I', 'L'], UNSIGNED_INT8, '=BBBB',
+ [0x80, 0x7f, 0, 0xff]),
+ (['b', 'h', 'i', 'l'], SIGNED_INT8, '=bbb',
+ [-0x80, 0x7f, 0]),
+ (['H', 'I', 'L'], UNSIGNED_INT16_LE, '<HHHH',
+ [0x8000, 0x7fff, 0, 0xffff]),
+ (['H', 'I', 'L'], UNSIGNED_INT16_BE, '>HHHH',
+ [0x8000, 0x7fff, 0, 0xffff]),
+ (['h', 'i', 'l'], SIGNED_INT16_LE, '<hhh',
+ [-0x8000, 0x7fff, 0]),
+ (['h', 'i', 'l'], SIGNED_INT16_BE, '>hhh',
+ [-0x8000, 0x7fff, 0]),
+ (['I', 'L'], UNSIGNED_INT32_LE, '<IIII',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['I', 'L'], UNSIGNED_INT32_BE, '>IIII',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['i', 'l'], SIGNED_INT32_LE, '<iii',
+ [-1<<31, (1<<31)-1, 0]),
+ (['i', 'l'], SIGNED_INT32_BE, '>iii',
+ [-1<<31, (1<<31)-1, 0]),
+ (['L'], UNSIGNED_INT64_LE, '<QQQQ',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['L'], UNSIGNED_INT64_BE, '>QQQQ',
+ [1<<31, (1<<31)-1, 0, (1<<32)-1]),
+ (['l'], SIGNED_INT64_LE, '<qqq',
+ [-1<<31, (1<<31)-1, 0]),
+ (['l'], SIGNED_INT64_BE, '>qqq',
+ [-1<<31, (1<<31)-1, 0]),
+ # The following tests for INT64 will raise an OverflowError
+ # when run on a 32-bit machine. The tests are simply skipped
+ # in that case.
+ (['L'], UNSIGNED_INT64_LE, '<QQQQ',
+ [1<<63, (1<<63)-1, 0, (1<<64)-1]),
+ (['L'], UNSIGNED_INT64_BE, '>QQQQ',
+ [1<<63, (1<<63)-1, 0, (1<<64)-1]),
+ (['l'], SIGNED_INT64_LE, '<qqq',
+ [-1<<63, (1<<63)-1, 0]),
+ (['l'], SIGNED_INT64_BE, '>qqq',
+ [-1<<63, (1<<63)-1, 0]),
+ (['f'], IEEE_754_FLOAT_LE, '<ffff',
+ [16711938.0, float('inf'), float('-inf'), -0.0]),
+ (['f'], IEEE_754_FLOAT_BE, '>ffff',
+ [16711938.0, float('inf'), float('-inf'), -0.0]),
+ (['d'], IEEE_754_DOUBLE_LE, '<dddd',
+ [9006104071832581.0, float('inf'), float('-inf'), -0.0]),
+ (['d'], IEEE_754_DOUBLE_BE, '>dddd',
+ [9006104071832581.0, float('inf'), float('-inf'), -0.0])
+ )
+ for testcase in testcases:
+ valid_typecodes, mformat_code, struct_fmt, values = testcase
+ arraystr = struct.pack(struct_fmt, *values)
+ for typecode in valid_typecodes:
+ try:
+ a = array.array(typecode, values)
+ except OverflowError:
+ continue # Skip this test case.
+ b = array_reconstructor(
+ array.array, typecode, mformat_code, arraystr)
+ self.assertEqual(a, b,
+ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
+
+ def test_unicode(self):
+ teststr = "Bonne Journ\xe9e \U0002030a\U00020347"
+ testcases = (
+ (UTF16_LE, "UTF-16-LE"),
+ (UTF16_BE, "UTF-16-BE"),
+ (UTF32_LE, "UTF-32-LE"),
+ (UTF32_BE, "UTF-32-BE")
+ )
+ for testcase in testcases:
+ mformat_code, encoding = testcase
+ a = array.array('u', teststr)
+ b = array_reconstructor(
+ array.array, 'u', mformat_code, teststr.encode(encoding))
+ self.assertEqual(a, b,
+ msg="{0!r} != {1!r}; testcase={2!r}".format(a, b, testcase))
+
+
+tests.append(ArrayReconstructorTest)
+
+
class BaseTest(unittest.TestCase):
# Required class attributes (provided by subclasses
# typecode: the typecode to test
@@ -66,7 +204,7 @@ class BaseTest(unittest.TestCase):
bi = a.buffer_info()
self.assertIsInstance(bi, tuple)
self.assertEqual(len(bi), 2)
- self.assertIsInstance(bi[0], (int, long))
+ self.assertIsInstance(bi[0], int)
self.assertIsInstance(bi[1], int)
self.assertEqual(bi[1], len(a))
@@ -97,31 +235,38 @@ class BaseTest(unittest.TestCase):
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
+ def test_reduce_ex(self):
+ a = array.array(self.typecode, self.example)
+ for protocol in range(3):
+ self.assertIs(a.__reduce_ex__(protocol)[0], array.array)
+ for protocol in range(3, pickle.HIGHEST_PROTOCOL):
+ self.assertIs(a.__reduce_ex__(protocol)[0], array_reconstructor)
+
def test_pickle(self):
- for protocol in range(HIGHEST_PROTOCOL + 1):
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode, self.example)
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
a = ArraySubclass(self.typecode, self.example)
a.x = 10
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
self.assertEqual(a.x, b.x)
self.assertEqual(type(a), type(b))
def test_pickle_for_empty_array(self):
- for protocol in range(HIGHEST_PROTOCOL + 1):
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode)
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
a = ArraySubclass(self.typecode)
a.x = 10
- b = loads(dumps(a, protocol))
+ b = pickle.loads(pickle.dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
self.assertEqual(a, b)
self.assertEqual(a.x, b.x)
@@ -163,51 +308,44 @@ class BaseTest(unittest.TestCase):
def test_tofromfile(self):
a = array.array(self.typecode, 2*self.example)
self.assertRaises(TypeError, a.tofile)
- self.assertRaises(TypeError, a.tofile, cStringIO.StringIO())
- test_support.unlink(test_support.TESTFN)
- f = open(test_support.TESTFN, 'wb')
+ support.unlink(support.TESTFN)
+ f = open(support.TESTFN, 'wb')
try:
a.tofile(f)
f.close()
b = array.array(self.typecode)
- f = open(test_support.TESTFN, 'rb')
+ f = open(support.TESTFN, 'rb')
self.assertRaises(TypeError, b.fromfile)
- self.assertRaises(
- TypeError,
- b.fromfile,
- cStringIO.StringIO(), len(self.example)
- )
b.fromfile(f, len(self.example))
self.assertEqual(b, array.array(self.typecode, self.example))
self.assertNotEqual(a, b)
- b.fromfile(f, len(self.example))
+ self.assertRaises(EOFError, b.fromfile, f, len(self.example)+1)
self.assertEqual(a, b)
- self.assertRaises(EOFError, b.fromfile, f, 1)
f.close()
finally:
if not f.closed:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_fromfile_ioerror(self):
# Issue #5395: Check if fromfile raises a proper IOError
# instead of EOFError.
a = array.array(self.typecode)
- f = open(test_support.TESTFN, 'wb')
+ f = open(support.TESTFN, 'wb')
try:
self.assertRaises(IOError, a.fromfile, f, len(self.example))
finally:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_filewrite(self):
a = array.array(self.typecode, 2*self.example)
- f = open(test_support.TESTFN, 'wb')
+ f = open(support.TESTFN, 'wb')
try:
f.write(a)
f.close()
b = array.array(self.typecode)
- f = open(test_support.TESTFN, 'rb')
+ f = open(support.TESTFN, 'rb')
b.fromfile(f, len(self.example))
self.assertEqual(b, array.array(self.typecode, self.example))
self.assertNotEqual(a, b)
@@ -217,7 +355,7 @@ class BaseTest(unittest.TestCase):
finally:
if not f.closed:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_tofromlist(self):
a = array.array(self.typecode, 2*self.example)
@@ -230,15 +368,40 @@ class BaseTest(unittest.TestCase):
self.assertEqual(a, b)
def test_tofromstring(self):
+ nb_warnings = 4
+ with warnings.catch_warnings(record=True) as r:
+ warnings.filterwarnings("always",
+ message=r"(to|from)string\(\) is deprecated",
+ category=DeprecationWarning)
+ a = array.array(self.typecode, 2*self.example)
+ b = array.array(self.typecode)
+ self.assertRaises(TypeError, a.tostring, 42)
+ self.assertRaises(TypeError, b.fromstring)
+ self.assertRaises(TypeError, b.fromstring, 42)
+ b.fromstring(a.tostring())
+ self.assertEqual(a, b)
+ if a.itemsize>1:
+ self.assertRaises(ValueError, b.fromstring, "x")
+ nb_warnings += 1
+ self.assertEqual(len(r), nb_warnings)
+
+ def test_tofrombytes(self):
a = array.array(self.typecode, 2*self.example)
b = array.array(self.typecode)
- self.assertRaises(TypeError, a.tostring, 42)
- self.assertRaises(TypeError, b.fromstring)
- self.assertRaises(TypeError, b.fromstring, 42)
- b.fromstring(a.tostring())
+ self.assertRaises(TypeError, a.tobytes, 42)
+ self.assertRaises(TypeError, b.frombytes)
+ self.assertRaises(TypeError, b.frombytes, 42)
+ b.frombytes(a.tobytes())
+ c = array.array(self.typecode, bytearray(a.tobytes()))
self.assertEqual(a, b)
+ self.assertEqual(a, c)
if a.itemsize>1:
- self.assertRaises(ValueError, b.fromstring, "x")
+ self.assertRaises(ValueError, b.frombytes, b"x")
+
+ def test_fromarray(self):
+ a = array.array(self.typecode, self.example)
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
def test_repr(self):
a = array.array(self.typecode, 2*self.example)
@@ -346,6 +509,12 @@ class BaseTest(unittest.TestCase):
array.array(self.typecode)
)
+ a = 5 * array.array(self.typecode, self.example[:1])
+ self.assertEqual(
+ a,
+ array.array(self.typecode, [a[0]] * 5)
+ )
+
self.assertRaises(TypeError, a.__mul__, "bad")
def test_imul(self):
@@ -380,9 +549,9 @@ class BaseTest(unittest.TestCase):
def test_getitem(self):
a = array.array(self.typecode, self.example)
self.assertEntryEqual(a[0], self.example[0])
- self.assertEntryEqual(a[0L], self.example[0])
+ self.assertEntryEqual(a[0], self.example[0])
+ self.assertEntryEqual(a[-1], self.example[-1])
self.assertEntryEqual(a[-1], self.example[-1])
- self.assertEntryEqual(a[-1L], self.example[-1])
self.assertEntryEqual(a[len(self.example)-1], self.example[-1])
self.assertEntryEqual(a[-len(self.example)], self.example[0])
self.assertRaises(TypeError, a.__getitem__)
@@ -395,7 +564,7 @@ class BaseTest(unittest.TestCase):
self.assertEntryEqual(a[0], a[-1])
a = array.array(self.typecode, self.example)
- a[0L] = a[-1]
+ a[0] = a[-1]
self.assertEntryEqual(a[0], a[-1])
a = array.array(self.typecode, self.example)
@@ -403,7 +572,7 @@ class BaseTest(unittest.TestCase):
self.assertEntryEqual(a[0], a[-1])
a = array.array(self.typecode, self.example)
- a[-1L] = a[0]
+ a[-1] = a[0]
self.assertEntryEqual(a[0], a[-1])
a = array.array(self.typecode, self.example)
@@ -606,12 +775,10 @@ class BaseTest(unittest.TestCase):
)
a = array.array(self.typecode, self.example)
- self.assertRaises(TypeError, a.__setslice__, 0, 0, None)
self.assertRaises(TypeError, a.__setitem__, slice(0, 0), None)
self.assertRaises(TypeError, a.__setitem__, slice(0, 1), None)
b = array.array(self.badtypecode())
- self.assertRaises(TypeError, a.__setslice__, 0, 0, b)
self.assertRaises(TypeError, a.__setitem__, slice(0, 0), b)
self.assertRaises(TypeError, a.__setitem__, slice(0, 1), b)
@@ -761,14 +928,43 @@ class BaseTest(unittest.TestCase):
def test_buffer(self):
a = array.array(self.typecode, self.example)
- with test_support.check_py3k_warnings():
- b = buffer(a)
- self.assertEqual(b[0], a.tostring()[0])
+ m = memoryview(a)
+ expected = m.tobytes()
+ self.assertEqual(a.tobytes(), expected)
+ self.assertEqual(a.tobytes()[0], expected[0])
+ # Resizing is forbidden when there are buffer exports.
+ # For issue 4509, we also check after each error that
+ # the array was not modified.
+ self.assertRaises(BufferError, a.append, a[0])
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.extend, a[0:1])
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.remove, a[0])
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.pop, 0)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.fromlist, a.tolist())
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, a.frombytes, a.tobytes())
+ self.assertEqual(m.tobytes(), expected)
+ if self.typecode == 'u':
+ self.assertRaises(BufferError, a.fromunicode, a.tounicode())
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, operator.imul, a, 2)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, operator.imul, a, 0)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, operator.setitem, a, slice(0, 0), a)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, operator.delitem, a, 0)
+ self.assertEqual(m.tobytes(), expected)
+ self.assertRaises(BufferError, operator.delitem, a, slice(0, 1))
+ self.assertEqual(m.tobytes(), expected)
def test_weakref(self):
s = array.array(self.typecode, self.example)
- p = proxy(s)
- self.assertEqual(p.tostring(), s.tostring())
+ p = weakref.proxy(s)
+ self.assertEqual(p.tobytes(), s.tobytes())
s = None
self.assertRaises(ReferenceError, len, p)
@@ -784,89 +980,63 @@ class BaseTest(unittest.TestCase):
def test_subclass_with_kwargs(self):
# SF bug #1486663 -- this used to erroneously raise a TypeError
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", '', DeprecationWarning)
- ArraySubclassWithKwargs('b', newarg=1)
+ ArraySubclassWithKwargs('b', newarg=1)
+ def test_create_from_bytes(self):
+ # XXX This test probably needs to be moved in a subclass or
+ # generalized to use self.typecode.
+ a = array.array('H', b"1234")
+ self.assertEqual(len(a) * a.itemsize, 4)
-class StringTest(BaseTest):
-
- def test_setitem(self):
- super(StringTest, self).test_setitem()
+ @support.cpython_only
+ def test_sizeof_with_buffer(self):
a = array.array(self.typecode, self.example)
- self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
-
-class CharacterTest(StringTest):
- typecode = 'c'
- example = '\x01azAZ\x00\xfe'
- smallerexample = '\x01azAY\x00\xfe'
- biggerexample = '\x01azAZ\x00\xff'
- outside = '\x33'
- minitemsize = 1
+ basesize = support.calcvobjsize('4Pi')
+ buffer_size = a.buffer_info()[1] * a.itemsize
+ support.check_sizeof(self, a, basesize + buffer_size)
- def test_subbclassing(self):
- class EditableString(array.array):
- def __new__(cls, s, *args, **kwargs):
- return array.array.__new__(cls, 'c', s)
+ @support.cpython_only
+ def test_sizeof_without_buffer(self):
+ a = array.array(self.typecode)
+ basesize = support.calcvobjsize('4Pi')
+ support.check_sizeof(self, a, basesize)
- def __init__(self, s, color='blue'):
- self.color = color
- def strip(self):
- self[:] = array.array('c', self.tostring().strip())
+class StringTest(BaseTest):
- def __repr__(self):
- return 'EditableString(%r)' % self.tostring()
+ def test_setitem(self):
+ super().test_setitem()
+ a = array.array(self.typecode, self.example)
+ self.assertRaises(TypeError, a.__setitem__, 0, self.example[:2])
- s = EditableString("\ttest\r\n")
- s.strip()
- self.assertEqual(s.tostring(), "test")
+class UnicodeTest(StringTest):
+ typecode = 'u'
+ example = '\x01\u263a\x00\ufeff'
+ smallerexample = '\x01\u263a\x00\ufefe'
+ biggerexample = '\x01\u263a\x01\ufeff'
+ outside = str('\x33')
+ minitemsize = 2
- self.assertEqual(s.color, "blue")
- s.color = "red"
- self.assertEqual(s.color, "red")
- self.assertEqual(s.__dict__.keys(), ["color"])
+ def test_unicode(self):
+ self.assertRaises(TypeError, array.array, 'b', 'foo')
- def test_nounicode(self):
- a = array.array(self.typecode, self.example)
- self.assertRaises(ValueError, a.fromunicode, unicode(''))
- self.assertRaises(ValueError, a.tounicode)
-
-tests.append(CharacterTest)
-
-if test_support.have_unicode:
- class UnicodeTest(StringTest):
- typecode = 'u'
- example = unicode(r'\x01\u263a\x00\ufeff', 'unicode-escape')
- smallerexample = unicode(r'\x01\u263a\x00\ufefe', 'unicode-escape')
- biggerexample = unicode(r'\x01\u263a\x01\ufeff', 'unicode-escape')
- outside = unicode('\x33')
- minitemsize = 2
-
- def test_unicode(self):
- self.assertRaises(TypeError, array.array, 'b', unicode('foo', 'ascii'))
-
- a = array.array('u', unicode(r'\xa0\xc2\u1234', 'unicode-escape'))
- a.fromunicode(unicode(' ', 'ascii'))
- a.fromunicode(unicode('', 'ascii'))
- a.fromunicode(unicode('', 'ascii'))
- a.fromunicode(unicode(r'\x11abc\xff\u1234', 'unicode-escape'))
- s = a.tounicode()
- self.assertEqual(
- s,
- unicode(r'\xa0\xc2\u1234 \x11abc\xff\u1234', 'unicode-escape')
- )
+ a = array.array('u', '\xa0\xc2\u1234')
+ a.fromunicode(' ')
+ a.fromunicode('')
+ a.fromunicode('')
+ a.fromunicode('\x11abc\xff\u1234')
+ s = a.tounicode()
+ self.assertEqual(s, '\xa0\xc2\u1234 \x11abc\xff\u1234')
- s = unicode(r'\x00="\'a\\b\x80\xff\u0000\u0001\u1234', 'unicode-escape')
- a = array.array('u', s)
- self.assertEqual(
- repr(a),
- r"""array('u', u'\x00="\'a\\b\x80\xff\x00\x01\u1234')"""
- )
+ s = '\x00="\'a\\b\x80\xff\u0000\u0001\u1234'
+ a = array.array('u', s)
+ self.assertEqual(
+ repr(a),
+ "array('u', '\\x00=\"\\'a\\\\b\\x80\xff\\x00\\x01\u1234')")
- self.assertRaises(TypeError, a.fromunicode)
+ self.assertRaises(TypeError, a.fromunicode)
- tests.append(UnicodeTest)
+tests.append(UnicodeTest)
class NumberTest(BaseTest):
@@ -880,7 +1050,7 @@ class NumberTest(BaseTest):
self.assertEqual(a[3::-2], array.array(self.typecode, [3,1]))
self.assertEqual(a[-100:100:], a)
self.assertEqual(a[100:-100:-1], a[::-1])
- self.assertEqual(a[-100L:100L:2L], array.array(self.typecode, [0,2,4]))
+ self.assertEqual(a[-100:100:2], array.array(self.typecode, [0,2,4]))
self.assertEqual(a[1000:2000:2], array.array(self.typecode, []))
self.assertEqual(a[-1000:-2000:-2], array.array(self.typecode, []))
@@ -921,7 +1091,7 @@ class NumberTest(BaseTest):
def test_iterationcontains(self):
a = array.array(self.typecode, range(10))
- self.assertEqual(list(a), range(10))
+ self.assertEqual(list(a), list(range(10)))
b = array.array(self.typecode, [20])
self.assertEqual(a[-1] in a, True)
self.assertEqual(b[0] not in a, True)
@@ -961,6 +1131,11 @@ class NumberTest(BaseTest):
self.assertRaises(AttributeError, setattr, a, "color", "blue")
+ def test_frombytearray(self):
+ a = array.array('b', range(10))
+ b = array.array(self.typecode, a)
+ self.assertEqual(a, b)
+
class SignedNumberTest(NumberTest):
example = [-1, 0, 1, 42, 0x7f]
smallerexample = [-1, 0, 1, 42, 0x7e]
@@ -969,8 +1144,8 @@ class SignedNumberTest(NumberTest):
def test_overflow(self):
a = array.array(self.typecode)
- lower = -1 * long(pow(2, a.itemsize * 8 - 1))
- upper = long(pow(2, a.itemsize * 8 - 1)) - 1L
+ lower = -1 * int(pow(2, a.itemsize * 8 - 1))
+ upper = int(pow(2, a.itemsize * 8 - 1)) - 1
self.check_overflow(lower, upper)
class UnsignedNumberTest(NumberTest):
@@ -982,21 +1157,25 @@ class UnsignedNumberTest(NumberTest):
def test_overflow(self):
a = array.array(self.typecode)
lower = 0
- upper = long(pow(2, a.itemsize * 8)) - 1L
+ upper = int(pow(2, a.itemsize * 8)) - 1
self.check_overflow(lower, upper)
- @test_support.cpython_only
- def test_sizeof_with_buffer(self):
+ def test_bytes_extend(self):
+ s = bytes(self.example)
+
a = array.array(self.typecode, self.example)
- basesize = test_support.calcvobjsize('4P')
- buffer_size = a.buffer_info()[1] * a.itemsize
- test_support.check_sizeof(self, a, basesize + buffer_size)
+ a.extend(s)
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example+self.example)
+ )
- @test_support.cpython_only
- def test_sizeof_without_buffer(self):
- a = array.array(self.typecode)
- basesize = test_support.calcvobjsize('4P')
- test_support.check_sizeof(self, a, basesize)
+ a = array.array(self.typecode, self.example)
+ a.extend(bytearray(reversed(s)))
+ self.assertEqual(
+ a,
+ array.array(self.typecode, self.example+self.example[::-1])
+ )
class ByteTest(SignedNumberTest):
@@ -1060,7 +1239,7 @@ class FPTest(NumberTest):
# On alphas treating the byte swapped bit patters as
# floats/doubles results in floating point exceptions
# => compare the 8bit string values instead
- self.assertNotEqual(a.tostring(), b.tostring())
+ self.assertNotEqual(a.tobytes(), b.tobytes())
b.byteswap()
self.assertEqual(a, b)
@@ -1095,17 +1274,17 @@ tests.append(DoubleTest)
def test_main(verbose=None):
import sys
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*tests)
+ for i in range(len(counts)):
+ support.run_unittest(*tests)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_ascii_formatd.py b/Lib/test/test_ascii_formatd.py
deleted file mode 100644
index c4a616dc8a8..00000000000
--- a/Lib/test/test_ascii_formatd.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# PyOS_ascii_formatd is deprecated and not called from anywhere in
-# Python itself. So this module is the only place it gets tested.
-# Test that it works, and test that it's deprecated.
-
-import unittest
-from test.test_support import check_warnings, run_unittest, import_module
-
-# Skip tests if _ctypes module does not exist
-import_module('_ctypes')
-
-from ctypes import pythonapi, create_string_buffer, sizeof, byref, c_double
-PyOS_ascii_formatd = pythonapi.PyOS_ascii_formatd
-
-
-class FormatDeprecationTests(unittest.TestCase):
-
- def test_format_deprecation(self):
- buf = create_string_buffer(' ' * 100)
-
- with check_warnings(('PyOS_ascii_formatd is deprecated',
- DeprecationWarning)):
- PyOS_ascii_formatd(byref(buf), sizeof(buf), '%+.10f',
- c_double(10.0))
- self.assertEqual(buf.value, '+10.0000000000')
-
-
-class FormatTests(unittest.TestCase):
- # ensure that, for the restricted set of format codes,
- # %-formatting returns the same values os PyOS_ascii_formatd
- def test_format(self):
- buf = create_string_buffer(' ' * 100)
-
- tests = [
- ('%f', 100.0),
- ('%g', 100.0),
- ('%#g', 100.0),
- ('%#.2g', 100.0),
- ('%#.2g', 123.4567),
- ('%#.2g', 1.234567e200),
- ('%e', 1.234567e200),
- ('%e', 1.234),
- ('%+e', 1.234),
- ('%-e', 1.234),
- ]
-
- with check_warnings(('PyOS_ascii_formatd is deprecated',
- DeprecationWarning)):
- for format, val in tests:
- PyOS_ascii_formatd(byref(buf), sizeof(buf), format,
- c_double(val))
- self.assertEqual(buf.value, format % val)
-
-
-def test_main():
- run_unittest(FormatDeprecationTests, FormatTests)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_ast.py b/Lib/test/test_ast.py
index 4f80197f8d7..2887092a7d7 100644
--- a/Lib/test/test_ast.py
+++ b/Lib/test/test_ast.py
@@ -1,9 +1,9 @@
-import sys, itertools, unittest
-from test import test_support
+import sys, unittest
+from test import support
import ast
def to_tuple(t):
- if t is None or isinstance(t, (basestring, int, long, complex)):
+ if t is None or isinstance(t, (str, int, complex)):
return t
elif isinstance(t, list):
return [to_tuple(e) for e in t]
@@ -46,8 +46,6 @@ exec_tests = [
"v = 1",
# AugAssign
"v += 1",
- # Print
- "print >>f, 1, ",
# For
"for v in v:pass",
# While
@@ -55,7 +53,7 @@ exec_tests = [
# If
"if v:pass",
# Raise
- "raise Exception, 'string'",
+ "raise Exception('string')",
# TryExcept
"try:\n pass\nexcept Exception:\n pass",
# TryFinally
@@ -66,8 +64,6 @@ exec_tests = [
"import sys",
# ImportFrom
"from sys import v",
- # Exec
- "exec 'v'",
# Global
"global v",
# Expr
@@ -147,10 +143,8 @@ eval_tests = [
"1 < 2 < 3",
# Call
"f(1,2,c=3,*d,**e)",
- # Repr
- "`v`",
# Num
- "10L",
+ "10",
# Str
"'string'",
# Attribute
@@ -201,12 +195,6 @@ class AST_Tests(unittest.TestCase):
with self.assertRaises(AttributeError):
x.vararg
- with self.assertRaises(AttributeError):
- x.foobar = 21
-
- with self.assertRaises(AttributeError):
- ast.AST(lineno=2)
-
with self.assertRaises(TypeError):
# "_ast.AST constructor takes 0 positional arguments"
ast.AST(2)
@@ -215,7 +203,7 @@ class AST_Tests(unittest.TestCase):
for input, output, kind in ((exec_tests, exec_results, "exec"),
(single_tests, single_results, "single"),
(eval_tests, eval_results, "eval")):
- for i, o in itertools.izip(input, output):
+ for i, o in zip(input, output):
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
self.assertEqual(to_tuple(ast_tree), o)
self._assertTrueorder(ast_tree, (0, 0))
@@ -224,8 +212,7 @@ class AST_Tests(unittest.TestCase):
slc = ast.parse("x[::]").body[0].value.slice
self.assertIsNone(slc.upper)
self.assertIsNone(slc.lower)
- self.assertIsInstance(slc.step, ast.Name)
- self.assertEqual(slc.step.id, "None")
+ self.assertIsNone(slc.step)
def test_from_import(self):
im = ast.parse("from . import y").body[0]
@@ -246,7 +233,7 @@ class AST_Tests(unittest.TestCase):
self.assertTrue(issubclass(ast.Gt, ast.AST))
def test_field_attr_existence(self):
- for name, item in ast.__dict__.iteritems():
+ for name, item in ast.__dict__.items():
if isinstance(item, type) and name != 'AST' and name[0].isupper():
x = item()
if isinstance(x, ast.AST):
@@ -254,12 +241,14 @@ class AST_Tests(unittest.TestCase):
def test_arguments(self):
x = ast.arguments()
- self.assertEqual(x._fields, ('args', 'vararg', 'kwarg', 'defaults'))
+ self.assertEqual(x._fields, ('args', 'vararg', 'varargannotation',
+ 'kwonlyargs', 'kwarg', 'kwargannotation',
+ 'defaults', 'kw_defaults'))
with self.assertRaises(AttributeError):
x.vararg
- x = ast.arguments(1, 2, 3, 4)
+ x = ast.arguments(*range(1, 9))
self.assertEqual(x.vararg, 2)
def test_field_attr_writable(self):
@@ -301,7 +290,7 @@ class AST_Tests(unittest.TestCase):
self.assertEqual(x.body, body)
def test_nodeclasses(self):
- # Zero arguments constructor explicitely allowed
+ # Zero arguments constructor explicitly allowed
x = ast.BinOp()
self.assertEqual(x._fields, ('left', 'op', 'right'))
@@ -368,19 +357,26 @@ class AST_Tests(unittest.TestCase):
ast2 = mod.loads(mod.dumps(ast, protocol))
self.assertEqual(to_tuple(ast2), to_tuple(ast))
+ def test_invalid_sum(self):
+ pos = dict(lineno=2, col_offset=3)
+ m = ast.Module([ast.Expr(ast.expr(**pos), **pos)])
+ with self.assertRaises(TypeError) as cm:
+ compile(m, "<test>", "exec")
+ self.assertIn("but got <_ast.expr", str(cm.exception))
+
def test_invalid_identitifer(self):
- m = ast.Module([ast.Expr(ast.Name(u"x", ast.Load()))])
+ m = ast.Module([ast.Expr(ast.Name(42, ast.Load()))])
ast.fix_missing_locations(m)
with self.assertRaises(TypeError) as cm:
compile(m, "<test>", "exec")
self.assertIn("identifier must be of type str", str(cm.exception))
def test_invalid_string(self):
- m = ast.Module([ast.Expr(ast.Str(43))])
+ m = ast.Module([ast.Expr(ast.Str(42))])
ast.fix_missing_locations(m)
with self.assertRaises(TypeError) as cm:
compile(m, "<test>", "exec")
- self.assertIn("string must be of type str or uni", str(cm.exception))
+ self.assertIn("string must be of type str", str(cm.exception))
class ASTHelpers_Test(unittest.TestCase):
@@ -390,6 +386,12 @@ class ASTHelpers_Test(unittest.TestCase):
b = compile('foo(1 + 1)', '<unknown>', 'exec', ast.PyCF_ONLY_AST)
self.assertEqual(ast.dump(a), ast.dump(b))
+ def test_parse_in_error(self):
+ try:
+ 1/0
+ except Exception:
+ self.assertRaises(SyntaxError, ast.parse, r"'\U'")
+
def test_dump(self):
node = ast.parse('spam(eggs, "and cheese")')
self.assertEqual(ast.dump(node),
@@ -478,19 +480,32 @@ class ASTHelpers_Test(unittest.TestCase):
self.assertEqual(ast.literal_eval('[1, 2, 3]'), [1, 2, 3])
self.assertEqual(ast.literal_eval('{"foo": 42}'), {"foo": 42})
self.assertEqual(ast.literal_eval('(True, False, None)'), (True, False, None))
+ self.assertEqual(ast.literal_eval('{1, 2, 3}'), {1, 2, 3})
+ self.assertEqual(ast.literal_eval('b"hi"'), b"hi")
self.assertRaises(ValueError, ast.literal_eval, 'foo()')
+ self.assertEqual(ast.literal_eval('-6'), -6)
+ self.assertEqual(ast.literal_eval('-6j+3'), 3-6j)
+ self.assertEqual(ast.literal_eval('3.25'), 3.25)
def test_literal_eval_issue4907(self):
self.assertEqual(ast.literal_eval('2j'), 2j)
self.assertEqual(ast.literal_eval('10 + 2j'), 10 + 2j)
self.assertEqual(ast.literal_eval('1.5 - 2j'), 1.5 - 2j)
- self.assertRaises(ValueError, ast.literal_eval, '2 + (3 + 4j)')
+
+ def test_bad_integer(self):
+ # issue13436: Bad error message with invalid numeric values
+ body = [ast.ImportFrom(module='time',
+ names=[ast.alias(name='sleep')],
+ level=None,
+ lineno=None, col_offset=None)]
+ mod = ast.Module(body)
+ with self.assertRaises(ValueError) as cm:
+ compile(mod, 'test', 'exec')
+ self.assertIn("invalid integer value: None", str(cm.exception))
def test_main():
- with test_support.check_py3k_warnings(("backquote not supported",
- SyntaxWarning)):
- test_support.run_unittest(AST_Tests, ASTHelpers_Test)
+ support.run_unittest(AST_Tests, ASTHelpers_Test)
def main():
if __name__ != '__main__':
@@ -498,40 +513,38 @@ def main():
if sys.argv[1:] == ['-g']:
for statements, kind in ((exec_tests, "exec"), (single_tests, "single"),
(eval_tests, "eval")):
- print kind+"_results = ["
+ print(kind+"_results = [")
for s in statements:
- print repr(to_tuple(compile(s, "?", kind, 0x400)))+","
- print "]"
- print "main()"
+ print(repr(to_tuple(compile(s, "?", kind, 0x400)))+",")
+ print("]")
+ print("main()")
raise SystemExit
test_main()
#### EVERYTHING BELOW IS GENERATED #####
exec_results = [
('Module', [('Expr', (1, 0), ('Name', (1, 0), 'None', ('Load',)))]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Pass', (1, 9))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',))], None, None, []), [('Pass', (1, 10))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',))], None, None, [('Num', (1, 8), 0)]), [('Pass', (1, 12))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], 'args', None, []), [('Pass', (1, 14))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, 'kwargs', []), [('Pass', (1, 17))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('Name', (1, 6), 'a', ('Param',)), ('Name', (1, 9), 'b', ('Param',)), ('Name', (1, 14), 'c', ('Param',)), ('Name', (1, 22), 'd', ('Param',)), ('Name', (1, 28), 'e', ('Param',))], 'args', 'kwargs', [('Num', (1, 11), 1), ('Name', (1, 16), 'None', ('Load',)), ('List', (1, 24), [], ('Load',)), ('Dict', (1, 30), [], [])]), [('Pass', (1, 52))], [])]),
-('Module', [('ClassDef', (1, 0), 'C', [], [('Pass', (1, 8))], [])]),
-('Module', [('ClassDef', (1, 0), 'C', [('Name', (1, 8), 'object', ('Load',))], [('Pass', (1, 17))], [])]),
-('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Pass', (1, 9))], [], None)]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None)], None, None, [], None, None, [], []), [('Pass', (1, 10))], [], None)]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None)], None, None, [], None, None, [('Num', (1, 8), 0)], []), [('Pass', (1, 12))], [], None)]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], 'args', None, [], None, None, [], []), [('Pass', (1, 14))], [], None)]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], 'kwargs', None, [], []), [('Pass', (1, 17))], [], None)]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [('arg', 'a', None), ('arg', 'b', None), ('arg', 'c', None), ('arg', 'd', None), ('arg', 'e', None)], 'args', None, [], 'kwargs', None, [('Num', (1, 11), 1), ('Name', (1, 16), 'None', ('Load',)), ('List', (1, 24), [], ('Load',)), ('Dict', (1, 30), [], [])], []), [('Pass', (1, 52))], [], None)]),
+('Module', [('ClassDef', (1, 0), 'C', [], [], None, None, [('Pass', (1, 8))], [])]),
+('Module', [('ClassDef', (1, 0), 'C', [('Name', (1, 8), 'object', ('Load',))], [], None, None, [('Pass', (1, 17))], [])]),
+('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, [], None, None, [], []), [('Return', (1, 8), ('Num', (1, 15), 1))], [], None)]),
('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]),
('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]),
('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]),
-('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]),
('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]),
('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]),
('Module', [('If', (1, 0), ('Name', (1, 3), 'v', ('Load',)), [('Pass', (1, 5))], [])]),
-('Module', [('Raise', (1, 0), ('Name', (1, 6), 'Exception', ('Load',)), ('Str', (1, 17), 'string'), None)]),
+('Module', [('Raise', (1, 0), ('Call', (1, 6), ('Name', (1, 6), 'Exception', ('Load',)), [('Str', (1, 16), 'string')], [], None, None), None)]),
('Module', [('TryExcept', (1, 0), [('Pass', (2, 2))], [('ExceptHandler', (3, 0), ('Name', (3, 7), 'Exception', ('Load',)), None, [('Pass', (4, 2))])], [])]),
('Module', [('TryFinally', (1, 0), [('Pass', (2, 2))], [('Pass', (4, 2))])]),
('Module', [('Assert', (1, 0), ('Name', (1, 7), 'v', ('Load',)), None)]),
('Module', [('Import', (1, 0), [('alias', 'sys', None)])]),
('Module', [('ImportFrom', (1, 0), 'sys', [('alias', 'v', None)], 0)]),
-('Module', [('Exec', (1, 0), ('Str', (1, 5), 'v'), None, None)]),
('Module', [('Global', (1, 0), ['v'])]),
('Module', [('Expr', (1, 0), ('Num', (1, 0), 1))]),
('Module', [('Pass', (1, 0))]),
@@ -555,7 +568,7 @@ eval_results = [
('Expression', ('BoolOp', (1, 0), ('And',), [('Name', (1, 0), 'a', ('Load',)), ('Name', (1, 6), 'b', ('Load',))])),
('Expression', ('BinOp', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Add',), ('Name', (1, 4), 'b', ('Load',)))),
('Expression', ('UnaryOp', (1, 0), ('Not',), ('Name', (1, 4), 'v', ('Load',)))),
-('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, []), ('Name', (1, 7), 'None', ('Load',)))),
+('Expression', ('Lambda', (1, 0), ('arguments', [], None, None, [], None, None, [], []), ('Name', (1, 7), 'None', ('Load',)))),
('Expression', ('Dict', (1, 0), [('Num', (1, 2), 1)], [('Num', (1, 4), 2)])),
('Expression', ('Dict', (1, 0), [], [])),
('Expression', ('Set', (1, 0), [('Name', (1, 1), 'None', ('Load',))])),
@@ -564,8 +577,7 @@ eval_results = [
('Expression', ('GeneratorExp', (1, 1), ('Name', (1, 1), 'a', ('Load',)), [('comprehension', ('Name', (1, 7), 'b', ('Store',)), ('Name', (1, 12), 'c', ('Load',)), [('Name', (1, 17), 'd', ('Load',))])])),
('Expression', ('Compare', (1, 0), ('Num', (1, 0), 1), [('Lt',), ('Lt',)], [('Num', (1, 4), 2), ('Num', (1, 8), 3)])),
('Expression', ('Call', (1, 0), ('Name', (1, 0), 'f', ('Load',)), [('Num', (1, 2), 1), ('Num', (1, 4), 2)], [('keyword', 'c', ('Num', (1, 8), 3))], ('Name', (1, 11), 'd', ('Load',)), ('Name', (1, 15), 'e', ('Load',)))),
-('Expression', ('Repr', (1, 0), ('Name', (1, 1), 'v', ('Load',)))),
-('Expression', ('Num', (1, 0), 10L)),
+('Expression', ('Num', (1, 0), 10)),
('Expression', ('Str', (1, 0), 'string')),
('Expression', ('Attribute', (1, 0), ('Name', (1, 0), 'a', ('Load',)), 'b', ('Load',))),
('Expression', ('Subscript', (1, 0), ('Name', (1, 0), 'a', ('Load',)), ('Slice', ('Name', (1, 2), 'b', ('Load',)), ('Name', (1, 4), 'c', ('Load',)), None), ('Load',))),
diff --git a/Lib/test/test_asynchat.py b/Lib/test/test_asynchat.py
index c81ec0de450..c79fe6f6138 100644
--- a/Lib/test/test_asynchat.py
+++ b/Lib/test/test_asynchat.py
@@ -1,16 +1,20 @@
# test asynchat
+from test import support
+
+# If this fails, the test will be skipped.
+thread = support.import_module('_thread')
+
import asyncore, asynchat, socket, time
import unittest
import sys
-from test import test_support
try:
import threading
except ImportError:
threading = None
-HOST = test_support.HOST
-SERVER_QUIT = 'QUIT\n'
+HOST = support.HOST
+SERVER_QUIT = b'QUIT\n'
if threading:
class echo_server(threading.Thread):
@@ -22,7 +26,7 @@ if threading:
threading.Thread.__init__(self)
self.event = event
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
# This will be set if the client wants us to wait before echoing data
# back.
self.start_resend_event = None
@@ -31,7 +35,7 @@ if threading:
self.sock.listen(1)
self.event.set()
conn, client = self.sock.accept()
- self.buffer = ""
+ self.buffer = b""
# collect data until quit message is seen
while SERVER_QUIT not in self.buffer:
data = conn.recv(1)
@@ -40,7 +44,7 @@ if threading:
self.buffer = self.buffer + data
# remove the SERVER_QUIT message
- self.buffer = self.buffer.replace(SERVER_QUIT, '')
+ self.buffer = self.buffer.replace(SERVER_QUIT, b'')
if self.start_resend_event:
self.start_resend_event.wait()
@@ -67,24 +71,23 @@ if threading:
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((HOST, server_port))
self.set_terminator(terminator)
- self.buffer = ''
-
- def handle_connect(self):
- pass
+ self.buffer = b""
- if sys.platform == 'darwin':
- # select.poll returns a select.POLLHUP at the end of the tests
- # on darwin, so just ignore it
- def handle_expt(self):
+ def handle_connect(self):
pass
+ if sys.platform == 'darwin':
+ # select.poll returns a select.POLLHUP at the end of the tests
+ # on darwin, so just ignore it
+ def handle_expt(self):
+ pass
+
def collect_incoming_data(self, data):
self.buffer += data
def found_terminator(self):
self.contents.append(self.buffer)
- self.buffer = ""
-
+ self.buffer = b""
def start_echo_server():
event = threading.Event()
@@ -101,10 +104,10 @@ class TestAsynchat(unittest.TestCase):
usepoll = False
def setUp (self):
- self._threads = test_support.threading_setup()
+ self._threads = support.threading_setup()
def tearDown (self):
- test_support.threading_cleanup(*self._threads)
+ support.threading_cleanup(*self._threads)
def line_terminator_check(self, term, server_chunk):
event = threading.Event()
@@ -115,14 +118,14 @@ class TestAsynchat(unittest.TestCase):
event.clear()
time.sleep(0.01) # Give server time to start accepting.
c = echo_client(term, s.port)
- c.push("hello ")
- c.push("world%s" % term)
- c.push("I'm not dead yet!%s" % term)
+ c.push(b"hello ")
+ c.push(b"world" + term)
+ c.push(b"I'm not dead yet!" + term)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
s.join()
- self.assertEqual(c.contents, ["hello world", "I'm not dead yet!"])
+ self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
# the line terminator tests below check receiving variously-sized
# chunks back from the server in order to exercise all branches of
@@ -131,23 +134,23 @@ class TestAsynchat(unittest.TestCase):
def test_line_terminator1(self):
# test one-character terminator
for l in (1,2,3):
- self.line_terminator_check('\n', l)
+ self.line_terminator_check(b'\n', l)
def test_line_terminator2(self):
# test two-character terminator
for l in (1,2,3):
- self.line_terminator_check('\r\n', l)
+ self.line_terminator_check(b'\r\n', l)
def test_line_terminator3(self):
# test three-character terminator
for l in (1,2,3):
- self.line_terminator_check('qqq', l)
+ self.line_terminator_check(b'qqq', l)
def numeric_terminator_check(self, termlen):
# Try reading a fixed number of bytes
s, event = start_echo_server()
c = echo_client(termlen, s.port)
- data = "hello world, I'm not dead yet!\n"
+ data = b"hello world, I'm not dead yet!\n"
c.push(data)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
@@ -159,16 +162,15 @@ class TestAsynchat(unittest.TestCase):
# check that ints & longs both work (since type is
# explicitly checked in async_chat.handle_read)
self.numeric_terminator_check(1)
- self.numeric_terminator_check(1L)
def test_numeric_terminator2(self):
- self.numeric_terminator_check(6L)
+ self.numeric_terminator_check(6)
def test_none_terminator(self):
# Try reading a fixed number of bytes
s, event = start_echo_server()
c = echo_client(None, s.port)
- data = "hello world, I'm not dead yet!\n"
+ data = b"hello world, I'm not dead yet!\n"
c.push(data)
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
@@ -179,41 +181,42 @@ class TestAsynchat(unittest.TestCase):
def test_simple_producer(self):
s, event = start_echo_server()
- c = echo_client('\n', s.port)
- data = "hello world\nI'm not dead yet!\n"
+ c = echo_client(b'\n', s.port)
+ data = b"hello world\nI'm not dead yet!\n"
p = asynchat.simple_producer(data+SERVER_QUIT, buffer_size=8)
c.push_with_producer(p)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
s.join()
- self.assertEqual(c.contents, ["hello world", "I'm not dead yet!"])
+ self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
def test_string_producer(self):
s, event = start_echo_server()
- c = echo_client('\n', s.port)
- data = "hello world\nI'm not dead yet!\n"
+ c = echo_client(b'\n', s.port)
+ data = b"hello world\nI'm not dead yet!\n"
c.push_with_producer(data+SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
s.join()
- self.assertEqual(c.contents, ["hello world", "I'm not dead yet!"])
+ self.assertEqual(c.contents, [b"hello world", b"I'm not dead yet!"])
def test_empty_line(self):
# checks that empty lines are handled correctly
s, event = start_echo_server()
- c = echo_client('\n', s.port)
- c.push("hello world\n\nI'm not dead yet!\n")
+ c = echo_client(b'\n', s.port)
+ c.push(b"hello world\n\nI'm not dead yet!\n")
c.push(SERVER_QUIT)
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
s.join()
- self.assertEqual(c.contents, ["hello world", "", "I'm not dead yet!"])
+ self.assertEqual(c.contents,
+ [b"hello world", b"", b"I'm not dead yet!"])
def test_close_when_done(self):
s, event = start_echo_server()
s.start_resend_event = threading.Event()
- c = echo_client('\n', s.port)
- c.push("hello world\nI'm not dead yet!\n")
+ c = echo_client(b'\n', s.port)
+ c.push(b"hello world\nI'm not dead yet!\n")
c.push(SERVER_QUIT)
c.close_when_done()
asyncore.loop(use_poll=self.usepoll, count=300, timeout=.01)
@@ -229,7 +232,7 @@ class TestAsynchat(unittest.TestCase):
# the server might have been able to send a byte or two back, but this
# at least checks that it received something and didn't just fail
# (which could still result in the client not having received anything)
- self.assertTrue(len(s.buffer) > 0)
+ self.assertGreater(len(s.buffer), 0)
class TestAsynchat_WithPoll(TestAsynchat):
@@ -244,29 +247,29 @@ class TestFifo(unittest.TestCase):
def test_basic(self):
f = asynchat.fifo()
f.push(7)
- f.push('a')
+ f.push(b'a')
self.assertEqual(len(f), 2)
self.assertEqual(f.first(), 7)
self.assertEqual(f.pop(), (1, 7))
self.assertEqual(len(f), 1)
- self.assertEqual(f.first(), 'a')
+ self.assertEqual(f.first(), b'a')
self.assertEqual(f.is_empty(), False)
- self.assertEqual(f.pop(), (1, 'a'))
+ self.assertEqual(f.pop(), (1, b'a'))
self.assertEqual(len(f), 0)
self.assertEqual(f.is_empty(), True)
self.assertEqual(f.pop(), (0, None))
def test_given_list(self):
- f = asynchat.fifo(['x', 17, 3])
+ f = asynchat.fifo([b'x', 17, 3])
self.assertEqual(len(f), 3)
- self.assertEqual(f.pop(), (1, 'x'))
+ self.assertEqual(f.pop(), (1, b'x'))
self.assertEqual(f.pop(), (1, 17))
self.assertEqual(f.pop(), (1, 3))
self.assertEqual(f.pop(), (0, None))
def test_main(verbose=None):
- test_support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
+ support.run_unittest(TestAsynchat, TestAsynchat_WithPoll,
TestHelperFunctions, TestFifo)
if __name__ == "__main__":
diff --git a/Lib/test/test_asyncore.py b/Lib/test/test_asyncore.py
index 8f875ffb5f6..5f55df89f51 100644
--- a/Lib/test/test_asyncore.py
+++ b/Lib/test/test_asyncore.py
@@ -9,16 +9,17 @@ import warnings
import errno
import struct
-from test import test_support
-from test.test_support import TESTFN, run_unittest, unlink
-from StringIO import StringIO
+from test import support
+from test.support import TESTFN, run_unittest, unlink
+from io import BytesIO
+from io import StringIO
try:
import threading
except ImportError:
threading = None
-HOST = test_support.HOST
+HOST = support.HOST
class dummysocket:
def __init__(self):
@@ -76,8 +77,8 @@ def capture_server(evt, buf, serv):
if r:
data = conn.recv(10)
# keep everything except for the newline terminator
- buf.write(data.replace('\n', ''))
- if '\n' in data:
+ buf.write(data.replace(b'\n', b''))
+ if b'\n' in data:
break
n -= 1
time.sleep(0.01)
@@ -296,7 +297,6 @@ class DispatcherTests(unittest.TestCase):
d.handle_read()
d.handle_write()
d.handle_connect()
- d.handle_accept()
finally:
sys.stdout = stdout
@@ -304,8 +304,7 @@ class DispatcherTests(unittest.TestCase):
expected = ['warning: unhandled incoming priority event',
'warning: unhandled read event',
'warning: unhandled write event',
- 'warning: unhandled connect event',
- 'warning: unhandled accept event']
+ 'warning: unhandled connect event']
self.assertEqual(lines, expected)
def test_issue_8594(self):
@@ -314,8 +313,8 @@ class DispatcherTests(unittest.TestCase):
d = asyncore.dispatcher(socket.socket())
# make sure the error message no longer refers to the socket
# object but the dispatcher instance instead
- self.assertRaisesRegexp(AttributeError, 'dispatcher instance',
- getattr, d, 'foo')
+ self.assertRaisesRegex(AttributeError, 'dispatcher instance',
+ 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:
@@ -351,14 +350,14 @@ class DispatcherWithSendTests(unittest.TestCase):
asyncore.close_all()
@unittest.skipUnless(threading, 'Threading required for this test.')
- @test_support.reap_threads
+ @support.reap_threads
def test_send(self):
evt = threading.Event()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(3)
- port = test_support.bind_port(sock)
+ port = support.bind_port(sock)
- cap = StringIO()
+ cap = BytesIO()
args = (evt, cap, sock)
t = threading.Thread(target=capture_server, args=args)
t.start()
@@ -367,7 +366,7 @@ class DispatcherWithSendTests(unittest.TestCase):
# refuses connections on slow machines without this wait)
time.sleep(0.2)
- data = "Suppose there isn't a 16-ton weight?"
+ data = b"Suppose there isn't a 16-ton weight?"
d = dispatcherwithsend_noread()
d.create_socket(socket.AF_INET, socket.SOCK_STREAM)
d.connect((HOST, port))
@@ -377,7 +376,7 @@ class DispatcherWithSendTests(unittest.TestCase):
d.send(data)
d.send(data)
- d.send('\n')
+ d.send(b'\n')
n = 1000
while d.out_buffer and n > 0:
@@ -398,9 +397,9 @@ class DispatcherWithSendTests_UsePoll(DispatcherWithSendTests):
'asyncore.file_wrapper required')
class FileWrapperTest(unittest.TestCase):
def setUp(self):
- self.d = "It's not dead, it's sleeping!"
- with file(TESTFN, 'w') as h:
- h.write(self.d)
+ self.d = b"It's not dead, it's sleeping!"
+ with open(TESTFN, 'wb') as file:
+ file.write(self.d)
def tearDown(self):
unlink(TESTFN)
@@ -412,15 +411,14 @@ class FileWrapperTest(unittest.TestCase):
self.assertNotEqual(w.fd, fd)
self.assertNotEqual(w.fileno(), fd)
- self.assertEqual(w.recv(13), "It's not dead")
- self.assertEqual(w.read(6), ", it's")
+ self.assertEqual(w.recv(13), b"It's not dead")
+ self.assertEqual(w.read(6), b", it's")
w.close()
self.assertRaises(OSError, w.read, 1)
-
def test_send(self):
- d1 = "Come again?"
- d2 = "I want to buy some cheese."
+ d1 = b"Come again?"
+ d2 = b"I want to buy some cheese."
fd = os.open(TESTFN, os.O_WRONLY | os.O_APPEND)
w = asyncore.file_wrapper(fd)
os.close(fd)
@@ -428,7 +426,8 @@ class FileWrapperTest(unittest.TestCase):
w.write(d1)
w.send(d2)
w.close()
- self.assertEqual(file(TESTFN).read(), self.d + d1 + d2)
+ with open(TESTFN, 'rb') as file:
+ self.assertEqual(file.read(), self.d + d1 + d2)
@unittest.skipUnless(hasattr(asyncore, 'file_dispatcher'),
'asyncore.file_dispatcher required')
@@ -453,6 +452,9 @@ class BaseTestHandler(asyncore.dispatcher):
def handle_accept(self):
raise Exception("handle_accept not supposed to be called")
+ def handle_accepted(self):
+ raise Exception("handle_accepted not supposed to be called")
+
def handle_connect(self):
raise Exception("handle_connect not supposed to be called")
@@ -483,10 +485,8 @@ class TCPServer(asyncore.dispatcher):
def address(self):
return self.socket.getsockname()[:2]
- def handle_accept(self):
- pair = self.accept()
- if pair is not None:
- self.handler(pair[0])
+ def handle_accepted(self, sock, addr):
+ self.handler(sock)
def handle_error(self):
raise
@@ -549,6 +549,30 @@ class BaseTestAPI(unittest.TestCase):
client = BaseClient(server.address)
self.loop_waiting_for_flag(server)
+ def test_handle_accepted(self):
+ # make sure handle_accepted() is called when a client connects
+
+ class TestListener(BaseTestHandler):
+
+ def __init__(self):
+ BaseTestHandler.__init__(self)
+ self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.bind((HOST, 0))
+ self.listen(5)
+ self.address = self.socket.getsockname()[:2]
+
+ def handle_accept(self):
+ asyncore.dispatcher.handle_accept(self)
+
+ def handle_accepted(self, sock, addr):
+ sock.close()
+ self.flag = True
+
+ server = TestListener()
+ client = BaseClient(server.address)
+ self.loop_waiting_for_flag(server)
+
+
def test_handle_read(self):
# make sure handle_read is called on data received
@@ -559,7 +583,7 @@ class BaseTestAPI(unittest.TestCase):
class TestHandler(BaseTestHandler):
def __init__(self, conn):
BaseTestHandler.__init__(self, conn)
- self.send('x' * 1024)
+ self.send(b'x' * 1024)
server = TCPServer(TestHandler)
client = TestClient(server.address)
@@ -614,7 +638,7 @@ class BaseTestAPI(unittest.TestCase):
class TestHandler(BaseTestHandler):
def __init__(self, conn):
BaseTestHandler.__init__(self, conn)
- self.socket.send(chr(244), socket.MSG_OOB)
+ self.socket.send(bytes(chr(244), 'latin-1'), socket.MSG_OOB)
server = TCPServer(TestHandler)
client = TestClient(server.address)
@@ -672,7 +696,8 @@ class BaseTestAPI(unittest.TestCase):
s = asyncore.dispatcher()
s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.assertEqual(s.socket.family, socket.AF_INET)
- self.assertEqual(s.socket.type, socket.SOCK_STREAM)
+ SOCK_NONBLOCK = getattr(socket, 'SOCK_NONBLOCK', 0)
+ self.assertEqual(s.socket.type, socket.SOCK_STREAM | SOCK_NONBLOCK)
def test_bind(self):
s1 = asyncore.dispatcher()
@@ -698,6 +723,7 @@ class BaseTestAPI(unittest.TestCase):
s = asyncore.dispatcher(socket.socket())
self.assertFalse(s.socket.getsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR))
+ s.socket.close()
s.create_socket(socket.AF_INET, socket.SOCK_STREAM)
s.set_reuse_addr()
self.assertTrue(s.socket.getsockopt(socket.SOL_SOCKET,
@@ -706,14 +732,14 @@ class BaseTestAPI(unittest.TestCase):
sock.close()
@unittest.skipUnless(threading, 'Threading required for this test.')
- @test_support.reap_threads
+ @support.reap_threads
def test_quick_connect(self):
# see: http://bugs.python.org/issue10340
server = TCPServer()
t = threading.Thread(target=lambda: asyncore.loop(timeout=0.1, count=500))
t.start()
- for x in xrange(20):
+ for x in range(20):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(.2)
s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER,
@@ -725,7 +751,6 @@ class BaseTestAPI(unittest.TestCase):
finally:
s.close()
-
class TestAPI_UseSelect(BaseTestAPI):
use_poll = False
diff --git a/Lib/test/test_atexit.py b/Lib/test/test_atexit.py
index bf85b752536..5200af7ed91 100644
--- a/Lib/test/test_atexit.py
+++ b/Lib/test/test_atexit.py
@@ -1,82 +1,129 @@
import sys
import unittest
-import StringIO
+import io
import atexit
-from imp import reload
-from test import test_support
+from test import support
+
+### helpers
+def h1():
+ print("h1")
+
+def h2():
+ print("h2")
+
+def h3():
+ print("h3")
+
+def h4(*args, **kwargs):
+ print("h4", args, kwargs)
+
+def raise1():
+ raise TypeError
+
+def raise2():
+ raise SystemError
class TestCase(unittest.TestCase):
def setUp(self):
- s = StringIO.StringIO()
self.save_stdout = sys.stdout
self.save_stderr = sys.stderr
- sys.stdout = sys.stderr = self.subst_io = s
- self.save_handlers = atexit._exithandlers
- atexit._exithandlers = []
+ self.stream = io.StringIO()
+ sys.stdout = sys.stderr = self.stream
+ atexit._clear()
def tearDown(self):
sys.stdout = self.save_stdout
sys.stderr = self.save_stderr
- atexit._exithandlers = self.save_handlers
+ atexit._clear()
def test_args(self):
- atexit.register(self.h1)
- atexit.register(self.h4)
- atexit.register(self.h4, 4, kw="abc")
+ # be sure args are handled properly
+ atexit.register(h1)
+ atexit.register(h4)
+ atexit.register(h4, 4, kw="abc")
atexit._run_exitfuncs()
- self.assertEqual(self.subst_io.getvalue(),
- "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")
+
+ self.assertEqual(self.stream.getvalue(),
+ "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")
def test_badargs(self):
atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
self.assertRaises(TypeError, atexit._run_exitfuncs)
def test_order(self):
- atexit.register(self.h1)
- atexit.register(self.h2)
- atexit.register(self.h3)
+ # be sure handlers are executed in reverse order
+ atexit.register(h1)
+ atexit.register(h2)
+ atexit.register(h3)
atexit._run_exitfuncs()
- self.assertEqual(self.subst_io.getvalue(), "h3\nh2\nh1\n")
-
- def test_sys_override(self):
- # be sure a preset sys.exitfunc is handled properly
- exfunc = sys.exitfunc
- sys.exitfunc = self.h1
- reload(atexit)
- try:
- atexit.register(self.h2)
- atexit._run_exitfuncs()
- finally:
- sys.exitfunc = exfunc
- self.assertEqual(self.subst_io.getvalue(), "h2\nh1\n")
+
+ self.assertEqual(self.stream.getvalue(), "h3\nh2\nh1\n")
def test_raise(self):
- atexit.register(self.raise1)
- atexit.register(self.raise2)
+ # be sure raises are handled properly
+ atexit.register(raise1)
+ atexit.register(raise2)
+
self.assertRaises(TypeError, atexit._run_exitfuncs)
- ### helpers
- def h1(self):
- print "h1"
+ def test_raise_unnormalized(self):
+ # Issue #10756: Make sure that an unnormalized exception is
+ # handled properly
+ atexit.register(lambda: 1 / 0)
- def h2(self):
- print "h2"
+ self.assertRaises(ZeroDivisionError, atexit._run_exitfuncs)
+ self.assertIn("ZeroDivisionError", self.stream.getvalue())
- def h3(self):
- print "h3"
+ def test_stress(self):
+ a = [0]
+ def inc():
+ a[0] += 1
- def h4(self, *args, **kwargs):
- print "h4", args, kwargs
+ for i in range(128):
+ atexit.register(inc)
+ atexit._run_exitfuncs()
- def raise1(self):
- raise TypeError
+ self.assertEqual(a[0], 128)
- def raise2(self):
- raise SystemError
+ def test_clear(self):
+ a = [0]
+ def inc():
+ a[0] += 1
-def test_main():
- test_support.run_unittest(TestCase)
+ atexit.register(inc)
+ atexit._clear()
+ atexit._run_exitfuncs()
+ self.assertEqual(a[0], 0)
+
+ def test_unregister(self):
+ a = [0]
+ def inc():
+ a[0] += 1
+ def dec():
+ a[0] -= 1
+
+ for i in range(4):
+ atexit.register(inc)
+ atexit.register(dec)
+ atexit.unregister(inc)
+ atexit._run_exitfuncs()
+
+ self.assertEqual(a[0], -1)
+
+ def test_bound_methods(self):
+ l = []
+ atexit.register(l.append, 5)
+ atexit._run_exitfuncs()
+ self.assertEqual(l, [5])
+
+ atexit.unregister(l.append)
+ atexit._run_exitfuncs()
+ self.assertEqual(l, [5])
+
+
+def test_main():
+ support.run_unittest(TestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py
index 5b8e0f1e152..c14e8b87a85 100644
--- a/Lib/test/test_audioop.py
+++ b/Lib/test/test_audioop.py
@@ -1,23 +1,23 @@
import audioop
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
-endian = 'big' if audioop.getsample('\0\1', 2, 0) == 1 else 'little'
+endian = 'big' if audioop.getsample(b'\0\1', 2, 0) == 1 else 'little'
def gendata1():
- return '\0\1\2'
+ return b'\0\1\2'
def gendata2():
if endian == 'big':
- return '\0\0\0\1\0\2'
+ return b'\0\0\0\1\0\2'
else:
- return '\0\0\1\0\2\0'
+ return b'\0\0\1\0\2\0'
def gendata4():
if endian == 'big':
- return '\0\0\0\0\0\0\0\1\0\0\0\2'
+ return b'\0\0\0\0\0\0\0\1\0\0\0\2'
else:
- return '\0\0\0\0\1\0\0\0\2\0\0\0'
+ return b'\0\0\0\0\1\0\0\0\2\0\0\0'
data = [gendata1(), gendata2(), gendata4()]
@@ -68,9 +68,9 @@ class TestAudioop(unittest.TestCase):
def test_add(self):
data2 = []
for d in data:
- str = ''
- for s in d:
- str = str + chr(ord(s)*2)
+ str = bytearray(len(d))
+ for i,b in enumerate(d):
+ str[i] = 2*b
data2.append(str)
self.assertEqual(audioop.add(data[0], data[0], 1), data2[0])
self.assertEqual(audioop.add(data[1], data[1], 2), data2[1])
@@ -101,12 +101,12 @@ class TestAudioop(unittest.TestCase):
def test_lin2adpcm(self):
# Very cursory test
- self.assertEqual(audioop.lin2adpcm('\0\0\0\0', 1, None), ('\0\0', (0,0)))
+ self.assertEqual(audioop.lin2adpcm(b'\0\0\0\0', 1, None), (b'\0\0', (0,0)))
def test_lin2alaw(self):
- self.assertEqual(audioop.lin2alaw(data[0], 1), '\xd5\xc5\xf5')
- self.assertEqual(audioop.lin2alaw(data[1], 2), '\xd5\xd5\xd5')
- self.assertEqual(audioop.lin2alaw(data[2], 4), '\xd5\xd5\xd5')
+ self.assertEqual(audioop.lin2alaw(data[0], 1), b'\xd5\xc5\xf5')
+ self.assertEqual(audioop.lin2alaw(data[1], 2), b'\xd5\xd5\xd5')
+ self.assertEqual(audioop.lin2alaw(data[2], 4), b'\xd5\xd5\xd5')
def test_alaw2lin(self):
# Cursory
@@ -124,9 +124,9 @@ class TestAudioop(unittest.TestCase):
b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02')
def test_lin2ulaw(self):
- self.assertEqual(audioop.lin2ulaw(data[0], 1), '\xff\xe7\xdb')
- self.assertEqual(audioop.lin2ulaw(data[1], 2), '\xff\xff\xff')
- self.assertEqual(audioop.lin2ulaw(data[2], 4), '\xff\xff\xff')
+ self.assertEqual(audioop.lin2ulaw(data[0], 1), b'\xff\xe7\xdb')
+ self.assertEqual(audioop.lin2ulaw(data[1], 2), b'\xff\xff\xff')
+ self.assertEqual(audioop.lin2ulaw(data[2], 4), b'\xff\xff\xff')
def test_ulaw2lin(self):
# Cursory
@@ -146,9 +146,9 @@ class TestAudioop(unittest.TestCase):
def test_mul(self):
data2 = []
for d in data:
- str = ''
- for s in d:
- str = str + chr(ord(s)*2)
+ str = bytearray(len(d))
+ for i,b in enumerate(d):
+ str[i] = 2*b
data2.append(str)
self.assertEqual(audioop.mul(data[0], 1, 2), data2[0])
self.assertEqual(audioop.mul(data[1],2, 2), data2[1])
@@ -158,21 +158,23 @@ class TestAudioop(unittest.TestCase):
state = None
d1, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
d2, state = audioop.ratecv(data[0], 1, 1, 8000, 16000, state)
- self.assertEqual(d1 + d2, '\000\000\001\001\002\001\000\000\001\001\002')
+ self.assertEqual(d1 + d2, b'\000\000\001\001\002\001\000\000\001\001\002')
def test_reverse(self):
- self.assertEqual(audioop.reverse(data[0], 1), '\2\1\0')
+ self.assertEqual(audioop.reverse(data[0], 1), b'\2\1\0')
def test_tomono(self):
- data2 = ''
+ data2 = bytearray()
for d in data[0]:
- data2 = data2 + d + d
+ data2.append(d)
+ data2.append(d)
self.assertEqual(audioop.tomono(data2, 1, 0.5, 0.5), data[0])
def test_tostereo(self):
- data2 = ''
+ data2 = bytearray()
for d in data[0]:
- data2 = data2 + d + d
+ data2.append(d)
+ data2.append(d)
self.assertEqual(audioop.tostereo(data[0], 1, 1, 1), data2)
def test_findfactor(self):
@@ -193,7 +195,7 @@ class TestAudioop(unittest.TestCase):
def test_negativelen(self):
# from issue 3306, previously it segfaulted
self.assertRaises(audioop.error,
- audioop.findmax, ''.join( chr(x) for x in xrange(256)), -2392392)
+ audioop.findmax, ''.join(chr(x) for x in range(256)), -2392392)
def test_issue7673(self):
state = None
diff --git a/Lib/test/test_augassign.py b/Lib/test/test_augassign.py
index 059e8b74c90..9a59c58ec06 100644
--- a/Lib/test/test_augassign.py
+++ b/Lib/test/test_augassign.py
@@ -1,6 +1,6 @@
# Augmented assignment test.
-from test.test_support import run_unittest, check_py3k_warnings
+from test.support import run_unittest
import unittest
@@ -17,12 +17,7 @@ class AugAssignTest(unittest.TestCase):
x |= 5
x ^= 1
x /= 2
- if 1/2 == 0:
- # classic division
- self.assertEqual(x, 3)
- else:
- # new-style division (with -Qnew)
- self.assertEqual(x, 3.0)
+ self.assertEqual(x, 3.0)
def test_with_unpacking(self):
self.assertRaises(SyntaxError, compile, "x, b += 3", "<test>", "exec")
@@ -39,10 +34,7 @@ class AugAssignTest(unittest.TestCase):
x[0] |= 5
x[0] ^= 1
x[0] /= 2
- if 1/2 == 0:
- self.assertEqual(x[0], 3)
- else:
- self.assertEqual(x[0], 3.0)
+ self.assertEqual(x[0], 3.0)
def testInDict(self):
x = {0: 2}
@@ -56,10 +48,7 @@ class AugAssignTest(unittest.TestCase):
x[0] |= 5
x[0] ^= 1
x[0] /= 2
- if 1/2 == 0:
- self.assertEqual(x[0], 3)
- else:
- self.assertEqual(x[0], 3.0)
+ self.assertEqual(x[0], 3.0)
def testSequences(self):
x = [1,2]
@@ -168,6 +157,9 @@ class AugAssignTest(unittest.TestCase):
def __truediv__(self, val):
output.append("__truediv__ called")
return self
+ def __rtruediv__(self, val):
+ output.append("__rtruediv__ called")
+ return self
def __itruediv__(self, val):
output.append("__itruediv__ called")
return self
@@ -241,16 +233,9 @@ class AugAssignTest(unittest.TestCase):
1 * x
x *= 1
- if 1/2 == 0:
- x / 1
- 1 / x
- x /= 1
- else:
- # True division is in effect, so "/" doesn't map to __div__ etc;
- # but the canned expected-output file requires that those get called.
- x.__div__(1)
- x.__rdiv__(1)
- x.__idiv__(1)
+ x / 1
+ 1 / x
+ x /= 1
x // 1
1 // x
@@ -294,9 +279,9 @@ __isub__ called
__mul__ called
__rmul__ called
__imul__ called
-__div__ called
-__rdiv__ called
-__idiv__ called
+__truediv__ called
+__rtruediv__ called
+__itruediv__ called
__floordiv__ called
__rfloordiv__ called
__ifloordiv__ called
@@ -324,8 +309,7 @@ __ilshift__ called
'''.splitlines())
def test_main():
- with check_py3k_warnings(("classic int division", DeprecationWarning)):
- run_unittest(AugAssignTest)
+ run_unittest(AugAssignTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
index ff2c3700d3b..ca94504b1cd 100644
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -1,190 +1,270 @@
import unittest
-from test import test_support
+from test import support
import base64
+import binascii
+import os
+import sys
+import subprocess
+
-
class LegacyBase64TestCase(unittest.TestCase):
- def test_encodestring(self):
+ def test_encodebytes(self):
eq = self.assertEqual
- eq(base64.encodestring("www.python.org"), "d3d3LnB5dGhvbi5vcmc=\n")
- eq(base64.encodestring("a"), "YQ==\n")
- eq(base64.encodestring("ab"), "YWI=\n")
- eq(base64.encodestring("abc"), "YWJj\n")
- eq(base64.encodestring(""), "")
- eq(base64.encodestring("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}"),
- "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
-
- def test_decodestring(self):
+ eq(base64.encodebytes(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=\n")
+ eq(base64.encodebytes(b"a"), b"YQ==\n")
+ eq(base64.encodebytes(b"ab"), b"YWI=\n")
+ eq(base64.encodebytes(b"abc"), b"YWJj\n")
+ eq(base64.encodebytes(b""), b"")
+ eq(base64.encodebytes(b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}"),
+ b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n")
+ self.assertRaises(TypeError, base64.encodebytes, "")
+
+ def test_decodebytes(self):
eq = self.assertEqual
- eq(base64.decodestring("d3d3LnB5dGhvbi5vcmc=\n"), "www.python.org")
- eq(base64.decodestring("YQ==\n"), "a")
- eq(base64.decodestring("YWI=\n"), "ab")
- eq(base64.decodestring("YWJj\n"), "abc")
- eq(base64.decodestring("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}")
- eq(base64.decodestring(''), '')
+ eq(base64.decodebytes(b"d3d3LnB5dGhvbi5vcmc=\n"), b"www.python.org")
+ eq(base64.decodebytes(b"YQ==\n"), b"a")
+ eq(base64.decodebytes(b"YWI=\n"), b"ab")
+ eq(base64.decodebytes(b"YWJj\n"), b"abc")
+ eq(base64.decodebytes(b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n"),
+ b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}")
+ eq(base64.decodebytes(b''), b'')
+ self.assertRaises(TypeError, base64.decodebytes, "")
def test_encode(self):
eq = self.assertEqual
- from cStringIO import StringIO
- infp = StringIO('abcdefghijklmnopqrstuvwxyz'
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- '0123456789!@#0^&*();:<>,. []{}')
- outfp = StringIO()
+ from io import BytesIO
+ infp = BytesIO(b'abcdefghijklmnopqrstuvwxyz'
+ b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ b'0123456789!@#0^&*();:<>,. []{}')
+ outfp = BytesIO()
base64.encode(infp, outfp)
eq(outfp.getvalue(),
- 'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE'
- 'RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT'
- 'Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n')
+ b'YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE'
+ b'RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT'
+ b'Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==\n')
def test_decode(self):
- from cStringIO import StringIO
- infp = StringIO('d3d3LnB5dGhvbi5vcmc=')
- outfp = StringIO()
+ from io import BytesIO
+ infp = BytesIO(b'd3d3LnB5dGhvbi5vcmc=')
+ outfp = BytesIO()
base64.decode(infp, outfp)
- self.assertEqual(outfp.getvalue(), 'www.python.org')
+ self.assertEqual(outfp.getvalue(), b'www.python.org')
-
class BaseXYTestCase(unittest.TestCase):
def test_b64encode(self):
eq = self.assertEqual
# Test default alphabet
- eq(base64.b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=")
- eq(base64.b64encode('\x00'), 'AA==')
- eq(base64.b64encode("a"), "YQ==")
- eq(base64.b64encode("ab"), "YWI=")
- eq(base64.b64encode("abc"), "YWJj")
- eq(base64.b64encode(""), "")
- eq(base64.b64encode("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}"),
- "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
+ eq(base64.b64encode(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=")
+ eq(base64.b64encode(b'\x00'), b'AA==')
+ eq(base64.b64encode(b"a"), b"YQ==")
+ eq(base64.b64encode(b"ab"), b"YWI=")
+ eq(base64.b64encode(b"abc"), b"YWJj")
+ eq(base64.b64encode(b""), b"")
+ eq(base64.b64encode(b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}"),
+ b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
# Test with arbitrary alternative characters
- eq(base64.b64encode('\xd3V\xbeo\xf7\x1d', altchars='*$'), '01a*b$cd')
+ eq(base64.b64encode(b'\xd3V\xbeo\xf7\x1d', altchars=b'*$'), b'01a*b$cd')
+ # Check if passing a str object raises an error
+ self.assertRaises(TypeError, base64.b64encode, "")
+ self.assertRaises(TypeError, base64.b64encode, b"", altchars="")
# Test standard alphabet
- eq(base64.standard_b64encode("www.python.org"), "d3d3LnB5dGhvbi5vcmc=")
- eq(base64.standard_b64encode("a"), "YQ==")
- eq(base64.standard_b64encode("ab"), "YWI=")
- eq(base64.standard_b64encode("abc"), "YWJj")
- eq(base64.standard_b64encode(""), "")
- eq(base64.standard_b64encode("abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}"),
- "YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
+ eq(base64.standard_b64encode(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=")
+ eq(base64.standard_b64encode(b"a"), b"YQ==")
+ eq(base64.standard_b64encode(b"ab"), b"YWI=")
+ eq(base64.standard_b64encode(b"abc"), b"YWJj")
+ eq(base64.standard_b64encode(b""), b"")
+ eq(base64.standard_b64encode(b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}"),
+ b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ==")
+ # Check if passing a str object raises an error
+ self.assertRaises(TypeError, base64.standard_b64encode, "")
+ self.assertRaises(TypeError, base64.standard_b64encode, b"", altchars="")
# Test with 'URL safe' alternative characters
- eq(base64.urlsafe_b64encode('\xd3V\xbeo\xf7\x1d'), '01a-b_cd')
+ eq(base64.urlsafe_b64encode(b'\xd3V\xbeo\xf7\x1d'), b'01a-b_cd')
+ # Check if passing a str object raises an error
+ self.assertRaises(TypeError, base64.urlsafe_b64encode, "")
def test_b64decode(self):
eq = self.assertEqual
- eq(base64.b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
- eq(base64.b64decode('AA=='), '\x00')
- eq(base64.b64decode("YQ=="), "a")
- eq(base64.b64decode("YWI="), "ab")
- eq(base64.b64decode("YWJj"), "abc")
- eq(base64.b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}")
- eq(base64.b64decode(''), '')
+ eq(base64.b64decode(b"d3d3LnB5dGhvbi5vcmc="), b"www.python.org")
+ eq(base64.b64decode(b'AA=='), b'\x00')
+ eq(base64.b64decode(b"YQ=="), b"a")
+ eq(base64.b64decode(b"YWI="), b"ab")
+ eq(base64.b64decode(b"YWJj"), b"abc")
+ eq(base64.b64decode(b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0\nNT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
+ b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}")
+ eq(base64.b64decode(b''), b'')
# Test with arbitrary alternative characters
- eq(base64.b64decode('01a*b$cd', altchars='*$'), '\xd3V\xbeo\xf7\x1d')
+ eq(base64.b64decode(b'01a*b$cd', altchars=b'*$'), b'\xd3V\xbeo\xf7\x1d')
+ # Check if passing a str object raises an error
+ self.assertRaises(TypeError, base64.b64decode, "")
+ self.assertRaises(TypeError, base64.b64decode, b"", altchars="")
# Test standard alphabet
- eq(base64.standard_b64decode("d3d3LnB5dGhvbi5vcmc="), "www.python.org")
- eq(base64.standard_b64decode("YQ=="), "a")
- eq(base64.standard_b64decode("YWI="), "ab")
- eq(base64.standard_b64decode("YWJj"), "abc")
- eq(base64.standard_b64decode(""), "")
- eq(base64.standard_b64decode("YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
- "RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
- "Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789!@#0^&*();:<>,. []{}")
+ eq(base64.standard_b64decode(b"d3d3LnB5dGhvbi5vcmc="), b"www.python.org")
+ eq(base64.standard_b64decode(b"YQ=="), b"a")
+ eq(base64.standard_b64decode(b"YWI="), b"ab")
+ eq(base64.standard_b64decode(b"YWJj"), b"abc")
+ eq(base64.standard_b64decode(b""), b"")
+ eq(base64.standard_b64decode(b"YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNE"
+ b"RUZHSElKS0xNTk9QUVJTVFVWV1hZWjAxMjM0NT"
+ b"Y3ODkhQCMwXiYqKCk7Ojw+LC4gW117fQ=="),
+ b"abcdefghijklmnopqrstuvwxyz"
+ b"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ b"0123456789!@#0^&*();:<>,. []{}")
+ # Check if passing a str object raises an error
+ self.assertRaises(TypeError, base64.standard_b64decode, "")
+ self.assertRaises(TypeError, base64.standard_b64decode, b"", altchars="")
# Test with 'URL safe' alternative characters
- eq(base64.urlsafe_b64decode('01a-b_cd'), '\xd3V\xbeo\xf7\x1d')
+ eq(base64.urlsafe_b64decode(b'01a-b_cd'), b'\xd3V\xbeo\xf7\x1d')
+ self.assertRaises(TypeError, base64.urlsafe_b64decode, "")
- def test_b64decode_error(self):
- self.assertRaises(TypeError, base64.b64decode, 'abc')
+ def test_b64decode_padding_error(self):
+ self.assertRaises(binascii.Error, base64.b64decode, b'abc')
+
+ def test_b64decode_invalid_chars(self):
+ # issue 1466065: Test some invalid characters.
+ tests = ((b'%3d==', b'\xdd'),
+ (b'$3d==', b'\xdd'),
+ (b'[==', b''),
+ (b'YW]3=', b'am'),
+ (b'3{d==', b'\xdd'),
+ (b'3d}==', b'\xdd'),
+ (b'@@', b''),
+ (b'!', b''),
+ (b'YWJj\nYWI=', b'abcab'))
+ for bstr, res in tests:
+ self.assertEqual(base64.b64decode(bstr), res)
+ with self.assertRaises(binascii.Error):
+ base64.b64decode(bstr, validate=True)
def test_b32encode(self):
eq = self.assertEqual
- eq(base64.b32encode(''), '')
- eq(base64.b32encode('\x00'), 'AA======')
- eq(base64.b32encode('a'), 'ME======')
- eq(base64.b32encode('ab'), 'MFRA====')
- eq(base64.b32encode('abc'), 'MFRGG===')
- eq(base64.b32encode('abcd'), 'MFRGGZA=')
- eq(base64.b32encode('abcde'), 'MFRGGZDF')
+ eq(base64.b32encode(b''), b'')
+ eq(base64.b32encode(b'\x00'), b'AA======')
+ eq(base64.b32encode(b'a'), b'ME======')
+ eq(base64.b32encode(b'ab'), b'MFRA====')
+ eq(base64.b32encode(b'abc'), b'MFRGG===')
+ eq(base64.b32encode(b'abcd'), b'MFRGGZA=')
+ eq(base64.b32encode(b'abcde'), b'MFRGGZDF')
+ self.assertRaises(TypeError, base64.b32encode, "")
def test_b32decode(self):
eq = self.assertEqual
- eq(base64.b32decode(''), '')
- eq(base64.b32decode('AA======'), '\x00')
- eq(base64.b32decode('ME======'), 'a')
- eq(base64.b32decode('MFRA===='), 'ab')
- eq(base64.b32decode('MFRGG==='), 'abc')
- eq(base64.b32decode('MFRGGZA='), 'abcd')
- eq(base64.b32decode('MFRGGZDF'), 'abcde')
+ eq(base64.b32decode(b''), b'')
+ eq(base64.b32decode(b'AA======'), b'\x00')
+ eq(base64.b32decode(b'ME======'), b'a')
+ eq(base64.b32decode(b'MFRA===='), b'ab')
+ eq(base64.b32decode(b'MFRGG==='), b'abc')
+ eq(base64.b32decode(b'MFRGGZA='), b'abcd')
+ eq(base64.b32decode(b'MFRGGZDF'), b'abcde')
+ self.assertRaises(TypeError, base64.b32decode, "")
def test_b32decode_casefold(self):
eq = self.assertEqual
- eq(base64.b32decode('', True), '')
- eq(base64.b32decode('ME======', True), 'a')
- eq(base64.b32decode('MFRA====', True), 'ab')
- eq(base64.b32decode('MFRGG===', True), 'abc')
- eq(base64.b32decode('MFRGGZA=', True), 'abcd')
- eq(base64.b32decode('MFRGGZDF', True), 'abcde')
+ eq(base64.b32decode(b'', True), b'')
+ eq(base64.b32decode(b'ME======', True), b'a')
+ eq(base64.b32decode(b'MFRA====', True), b'ab')
+ eq(base64.b32decode(b'MFRGG===', True), b'abc')
+ eq(base64.b32decode(b'MFRGGZA=', True), b'abcd')
+ eq(base64.b32decode(b'MFRGGZDF', True), b'abcde')
# Lower cases
- eq(base64.b32decode('me======', True), 'a')
- eq(base64.b32decode('mfra====', True), 'ab')
- eq(base64.b32decode('mfrgg===', True), 'abc')
- eq(base64.b32decode('mfrggza=', True), 'abcd')
- eq(base64.b32decode('mfrggzdf', True), 'abcde')
+ eq(base64.b32decode(b'me======', True), b'a')
+ eq(base64.b32decode(b'mfra====', True), b'ab')
+ eq(base64.b32decode(b'mfrgg===', True), b'abc')
+ eq(base64.b32decode(b'mfrggza=', True), b'abcd')
+ eq(base64.b32decode(b'mfrggzdf', True), b'abcde')
# Expected exceptions
- self.assertRaises(TypeError, base64.b32decode, 'me======')
+ self.assertRaises(TypeError, base64.b32decode, b'me======')
# Mapping zero and one
- eq(base64.b32decode('MLO23456'), 'b\xdd\xad\xf3\xbe')
- eq(base64.b32decode('M1023456', map01='L'), 'b\xdd\xad\xf3\xbe')
- eq(base64.b32decode('M1023456', map01='I'), 'b\x1d\xad\xf3\xbe')
+ eq(base64.b32decode(b'MLO23456'), b'b\xdd\xad\xf3\xbe')
+ eq(base64.b32decode(b'M1023456', map01=b'L'), b'b\xdd\xad\xf3\xbe')
+ eq(base64.b32decode(b'M1023456', map01=b'I'), b'b\x1d\xad\xf3\xbe')
+ self.assertRaises(TypeError, base64.b32decode, b"", map01="")
def test_b32decode_error(self):
- self.assertRaises(TypeError, base64.b32decode, 'abc')
- self.assertRaises(TypeError, base64.b32decode, 'ABCDEF==')
+ self.assertRaises(binascii.Error, base64.b32decode, b'abc')
+ self.assertRaises(binascii.Error, base64.b32decode, b'ABCDEF==')
def test_b16encode(self):
eq = self.assertEqual
- eq(base64.b16encode('\x01\x02\xab\xcd\xef'), '0102ABCDEF')
- eq(base64.b16encode('\x00'), '00')
+ eq(base64.b16encode(b'\x01\x02\xab\xcd\xef'), b'0102ABCDEF')
+ eq(base64.b16encode(b'\x00'), b'00')
+ self.assertRaises(TypeError, base64.b16encode, "")
def test_b16decode(self):
eq = self.assertEqual
- eq(base64.b16decode('0102ABCDEF'), '\x01\x02\xab\xcd\xef')
- eq(base64.b16decode('00'), '\x00')
+ eq(base64.b16decode(b'0102ABCDEF'), b'\x01\x02\xab\xcd\xef')
+ eq(base64.b16decode(b'00'), b'\x00')
# Lower case is not allowed without a flag
- self.assertRaises(TypeError, base64.b16decode, '0102abcdef')
+ self.assertRaises(binascii.Error, base64.b16decode, b'0102abcdef')
# Case fold
- eq(base64.b16decode('0102abcdef', True), '\x01\x02\xab\xcd\xef')
+ eq(base64.b16decode(b'0102abcdef', True), b'\x01\x02\xab\xcd\xef')
+ self.assertRaises(TypeError, base64.b16decode, "")
+
+ def test_ErrorHeritage(self):
+ self.assertTrue(issubclass(binascii.Error, ValueError))
+
+
+
+class TestMain(unittest.TestCase):
+ def tearDown(self):
+ if os.path.exists(support.TESTFN):
+ os.unlink(support.TESTFN)
+
+ def get_output(self, *args, **options):
+ args = (sys.executable, '-m', 'base64') + args
+ return subprocess.check_output(args, **options)
+
+ def test_encode_decode(self):
+ output = self.get_output('-t')
+ self.assertSequenceEqual(output.splitlines(), (
+ b"b'Aladdin:open sesame'",
+ br"b'QWxhZGRpbjpvcGVuIHNlc2FtZQ==\n'",
+ b"b'Aladdin:open sesame'",
+ ))
+
+ def test_encode_file(self):
+ with open(support.TESTFN, 'wb') as fp:
+ fp.write(b'a\xffb\n')
+
+ output = self.get_output('-e', support.TESTFN)
+ self.assertEqual(output.rstrip(), b'Yf9iCg==')
+
+ with open(support.TESTFN, 'rb') as fp:
+ output = self.get_output('-e', stdin=fp)
+ self.assertEqual(output.rstrip(), b'Yf9iCg==')
+
+ def test_decode(self):
+ with open(support.TESTFN, 'wb') as fp:
+ fp.write(b'Yf9iCg==')
+ output = self.get_output('-d', support.TESTFN)
+ self.assertEqual(output.rstrip(), b'a\xffb')
+
-
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_bastion.py b/Lib/test/test_bastion.py
deleted file mode 100644
index 4760ec875cd..00000000000
--- a/Lib/test/test_bastion.py
+++ /dev/null
@@ -1,3 +0,0 @@
-##import Bastion
-##
-##Bastion._test()
diff --git a/Lib/test/test_bigaddrspace.py b/Lib/test/test_bigaddrspace.py
index db19a53c709..b8c59d41d39 100644
--- a/Lib/test/test_bigaddrspace.py
+++ b/Lib/test/test_bigaddrspace.py
@@ -1,46 +1,101 @@
-from test import test_support
-from test.test_support import bigaddrspacetest, MAX_Py_ssize_t
+"""
+These tests are meant to exercise that requests to create objects bigger
+than what the address space allows are properly met with an OverflowError
+(rather than crash weirdly).
+
+Primarily, this means 32-bit builds with at least 2 GB of available memory.
+You need to pass the -M option to regrtest (e.g. "-M 2.1G") for tests to
+be enabled.
+"""
+
+from test import support
+from test.support import bigaddrspacetest, MAX_Py_ssize_t
import unittest
import operator
import sys
-class StrTest(unittest.TestCase):
+class BytesTest(unittest.TestCase):
@bigaddrspacetest
def test_concat(self):
- s1 = 'x' * MAX_Py_ssize_t
- self.assertRaises(OverflowError, operator.add, s1, '?')
+ # Allocate a bytestring that's near the maximum size allowed by
+ # the address space, and then try to build a new, larger one through
+ # concatenation.
+ try:
+ x = b"x" * (MAX_Py_ssize_t - 128)
+ self.assertRaises(OverflowError, operator.add, x, b"x" * 128)
+ finally:
+ x = None
@bigaddrspacetest
def test_optimized_concat(self):
- x = 'x' * MAX_Py_ssize_t
try:
- x = x + '?' # this statement uses a fast path in ceval.c
- except OverflowError:
- pass
- else:
- self.fail("should have raised OverflowError")
+ x = b"x" * (MAX_Py_ssize_t - 128)
+
+ with self.assertRaises(OverflowError) as cm:
+ # this statement used a fast path in ceval.c
+ x = x + b"x" * 128
+
+ with self.assertRaises(OverflowError) as cm:
+ # this statement used a fast path in ceval.c
+ x += b"x" * 128
+ finally:
+ x = None
+
+ @bigaddrspacetest
+ def test_repeat(self):
+ try:
+ x = b"x" * (MAX_Py_ssize_t - 128)
+ self.assertRaises(OverflowError, operator.mul, x, 128)
+ finally:
+ x = None
+
+
+class StrTest(unittest.TestCase):
+
+ unicodesize = 2 if sys.maxunicode < 65536 else 4
+
+ @bigaddrspacetest
+ def test_concat(self):
+ try:
+ # Create a string that would fill almost the address space
+ x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize))
+ # Unicode objects trigger MemoryError in case an operation that's
+ # going to cause a size overflow is executed
+ self.assertRaises(MemoryError, operator.add, x, x)
+ finally:
+ x = None
+
+ @bigaddrspacetest
+ def test_optimized_concat(self):
try:
- x += '?' # this statement uses a fast path in ceval.c
- except OverflowError:
- pass
- else:
- self.fail("should have raised OverflowError")
- self.assertEqual(len(x), MAX_Py_ssize_t)
+ x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize))
+
+ with self.assertRaises(MemoryError) as cm:
+ # this statement uses a fast path in ceval.c
+ x = x + x
- ### the following test is pending a patch
- # (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
- #@bigaddrspacetest
- #def test_repeat(self):
- # self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
+ with self.assertRaises(MemoryError) as cm:
+ # this statement uses a fast path in ceval.c
+ x += x
+ finally:
+ x = None
+
+ @bigaddrspacetest
+ def test_repeat(self):
+ try:
+ x = "x" * int(MAX_Py_ssize_t // (1.1 * self.unicodesize))
+ self.assertRaises(MemoryError, operator.mul, x, 2)
+ finally:
+ x = None
def test_main():
- test_support.run_unittest(StrTest)
+ support.run_unittest(BytesTest, StrTest)
if __name__ == '__main__':
if len(sys.argv) > 1:
- test_support.set_memlimit(sys.argv[1])
+ support.set_memlimit(sys.argv[1])
test_main()
diff --git a/Lib/test/test_bigmem.py b/Lib/test/test_bigmem.py
index c41c3730631..f3c6ebbf05f 100644
--- a/Lib/test/test_bigmem.py
+++ b/Lib/test/test_bigmem.py
@@ -1,10 +1,10 @@
-from test import test_support
-from test.test_support import bigmemtest, _1G, _2G, _4G, precisionbigmemtest
+from test import support
+from test.support import bigmemtest, _1G, _2G, _4G
import unittest
import operator
-import string
import sys
+import functools
# Bigmem testing houserules:
#
@@ -14,7 +14,7 @@ import sys
# value has been created. Use 'del s' before the create_largestring call.
#
# - Do *not* compare large objects using assertEqual or similar. It's a
-# lengty operation and the errormessage will be utterly useless due to
+# lengthy operation and the errormessage will be utterly useless due to
# its size. To make sure whether a result has the right contents, better
# to use the strip or count methods, or compare meaningful slices.
#
@@ -25,27 +25,36 @@ import sys
# a large object, make the subobject of a length that is not a power of
# 2. That way, int-wrapping problems are more easily detected.
#
-# - While the bigmemtest decorator speaks of 'minsize', all tests will
-# actually be called with a much smaller number too, in the normal
-# test run (5Kb currently.) This is so the tests themselves get frequent
-# testing. Consequently, always make all large allocations based on the
+# - Despite the bigmemtest decorator, all tests will actually be called
+# with a much smaller number too, in the normal test run (5Kb currently.)
+# This is so the tests themselves get frequent testing.
+# Consequently, always make all large allocations based on the
# passed-in 'size', and don't rely on the size being very large. Also,
# memuse-per-size should remain sane (less than a few thousand); if your
# test uses more, adjust 'size' upward, instead.
-class StrTest(unittest.TestCase):
- @bigmemtest(minsize=_2G, memuse=2)
+# BEWARE: it seems that one failing test can yield other subsequent tests to
+# fail as well. I do not know whether it is due to memory fragmentation
+# issues, or other specifics of the platform malloc() routine.
+
+character_size = 4 if sys.maxunicode > 0xFFFF else 2
+
+
+class BaseStrTest:
+
+ @bigmemtest(size=_2G, memuse=2)
def test_capitalize(self, size):
- SUBSTR = ' abc def ghi'
- s = '-' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = self.from_latin1(' abc def ghi')
+ s = _('-') * size + SUBSTR
caps = s.capitalize()
self.assertEqual(caps[-len(SUBSTR):],
SUBSTR.capitalize())
- self.assertEqual(caps.lstrip('-'), SUBSTR)
+ self.assertEqual(caps.lstrip(_('-')), SUBSTR)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_center(self, size):
- SUBSTR = ' abc def ghi'
+ SUBSTR = self.from_latin1(' abc def ghi')
s = SUBSTR.center(size)
self.assertEqual(len(s), size)
lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
@@ -54,319 +63,283 @@ class StrTest(unittest.TestCase):
self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
self.assertEqual(s.strip(), SUBSTR.strip())
- @precisionbigmemtest(size=_2G - 1, memuse=1)
- def test_center_unicode(self, size):
- SUBSTR = u' abc def ghi'
- try:
- s = SUBSTR.center(size)
- except OverflowError:
- pass # acceptable on 32-bit
- else:
- self.assertEqual(len(s), size)
- lpadsize = rpadsize = (len(s) - len(SUBSTR)) // 2
- if len(s) % 2:
- lpadsize += 1
- self.assertEqual(s[lpadsize:-rpadsize], SUBSTR)
- self.assertEqual(s.strip(), SUBSTR.strip())
- del s
-
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_count(self, size):
- SUBSTR = ' abc def ghi'
- s = '.' * size + SUBSTR
- self.assertEqual(s.count('.'), size)
- s += '.'
- self.assertEqual(s.count('.'), size + 1)
- self.assertEqual(s.count(' '), 3)
- self.assertEqual(s.count('i'), 1)
- self.assertEqual(s.count('j'), 0)
-
- @bigmemtest(minsize=_2G + 2, memuse=3)
- def test_decode(self, size):
- s = '.' * size
- self.assertEqual(len(s.decode('utf-8')), size)
-
- def basic_encode_test(self, size, enc, c=u'.', expectedsize=None):
- if expectedsize is None:
- expectedsize = size
-
- s = c * size
- self.assertEqual(len(s.encode(enc)), expectedsize)
-
- @bigmemtest(minsize=_2G + 2, memuse=3)
- def test_encode(self, size):
- return self.basic_encode_test(size, 'utf-8')
-
- @precisionbigmemtest(size=_4G // 6 + 2, memuse=2)
- def test_encode_raw_unicode_escape(self, size):
- try:
- return self.basic_encode_test(size, 'raw_unicode_escape')
- except MemoryError:
- pass # acceptable on 32-bit
-
- @precisionbigmemtest(size=_4G // 5 + 70, memuse=3)
- def test_encode_utf7(self, size):
- try:
- return self.basic_encode_test(size, 'utf7')
- except MemoryError:
- pass # acceptable on 32-bit
-
- @precisionbigmemtest(size=_4G // 4 + 5, memuse=6)
- def test_encode_utf32(self, size):
- try:
- return self.basic_encode_test(size, 'utf32', expectedsize=4*size+4)
- except MemoryError:
- pass # acceptable on 32-bit
-
- @precisionbigmemtest(size=_2G-1, memuse=4)
- def test_decodeascii(self, size):
- return self.basic_encode_test(size, 'ascii', c='A')
-
- @precisionbigmemtest(size=_4G // 5, memuse=6+2)
- def test_unicode_repr_oflw(self, size):
- self.skipTest("test crashes - see issue #14904")
- try:
- s = u"\uAAAA"*size
- r = repr(s)
- except MemoryError:
- pass # acceptable on 32-bit
- else:
- self.assertTrue(s == eval(r))
-
- @bigmemtest(minsize=_2G, memuse=2)
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
+ s = _('.') * size + SUBSTR
+ self.assertEqual(s.count(_('.')), size)
+ s += _('.')
+ self.assertEqual(s.count(_('.')), size + 1)
+ self.assertEqual(s.count(_(' ')), 3)
+ self.assertEqual(s.count(_('i')), 1)
+ self.assertEqual(s.count(_('j')), 0)
+
+ @bigmemtest(size=_2G, memuse=2)
def test_endswith(self, size):
- SUBSTR = ' abc def ghi'
- s = '-' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
+ s = _('-') * size + SUBSTR
self.assertTrue(s.endswith(SUBSTR))
self.assertTrue(s.endswith(s))
- s2 = '...' + s
+ s2 = _('...') + s
self.assertTrue(s2.endswith(s))
- self.assertFalse(s.endswith('a' + SUBSTR))
+ self.assertFalse(s.endswith(_('a') + SUBSTR))
self.assertFalse(SUBSTR.endswith(s))
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_expandtabs(self, size):
- s = '-' * size
+ _ = self.from_latin1
+ s = _('-') * size
tabsize = 8
self.assertEqual(s.expandtabs(), s)
del s
slen, remainder = divmod(size, tabsize)
- s = ' \t' * slen
+ s = _(' \t') * slen
s = s.expandtabs(tabsize)
self.assertEqual(len(s), size - remainder)
- self.assertEqual(len(s.strip(' ')), 0)
+ self.assertEqual(len(s.strip(_(' '))), 0)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_find(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
- s = ''.join([SUBSTR, '-' * size, SUBSTR])
- self.assertEqual(s.find(' '), 0)
+ s = _('').join([SUBSTR, _('-') * size, SUBSTR])
+ self.assertEqual(s.find(_(' ')), 0)
self.assertEqual(s.find(SUBSTR), 0)
- self.assertEqual(s.find(' ', sublen), sublen + size)
+ self.assertEqual(s.find(_(' '), sublen), sublen + size)
self.assertEqual(s.find(SUBSTR, len(SUBSTR)), sublen + size)
- self.assertEqual(s.find('i'), SUBSTR.find('i'))
- self.assertEqual(s.find('i', sublen),
- sublen + size + SUBSTR.find('i'))
- self.assertEqual(s.find('i', size),
- sublen + size + SUBSTR.find('i'))
- self.assertEqual(s.find('j'), -1)
-
- @bigmemtest(minsize=_2G, memuse=2)
+ self.assertEqual(s.find(_('i')), SUBSTR.find(_('i')))
+ self.assertEqual(s.find(_('i'), sublen),
+ sublen + size + SUBSTR.find(_('i')))
+ self.assertEqual(s.find(_('i'), size),
+ sublen + size + SUBSTR.find(_('i')))
+ self.assertEqual(s.find(_('j')), -1)
+
+ @bigmemtest(size=_2G, memuse=2)
def test_index(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
- s = ''.join([SUBSTR, '-' * size, SUBSTR])
- self.assertEqual(s.index(' '), 0)
+ s = _('').join([SUBSTR, _('-') * size, SUBSTR])
+ self.assertEqual(s.index(_(' ')), 0)
self.assertEqual(s.index(SUBSTR), 0)
- self.assertEqual(s.index(' ', sublen), sublen + size)
+ self.assertEqual(s.index(_(' '), sublen), sublen + size)
self.assertEqual(s.index(SUBSTR, sublen), sublen + size)
- self.assertEqual(s.index('i'), SUBSTR.index('i'))
- self.assertEqual(s.index('i', sublen),
- sublen + size + SUBSTR.index('i'))
- self.assertEqual(s.index('i', size),
- sublen + size + SUBSTR.index('i'))
- self.assertRaises(ValueError, s.index, 'j')
-
- @bigmemtest(minsize=_2G, memuse=2)
+ self.assertEqual(s.index(_('i')), SUBSTR.index(_('i')))
+ self.assertEqual(s.index(_('i'), sublen),
+ sublen + size + SUBSTR.index(_('i')))
+ self.assertEqual(s.index(_('i'), size),
+ sublen + size + SUBSTR.index(_('i')))
+ self.assertRaises(ValueError, s.index, _('j'))
+
+ @bigmemtest(size=_2G, memuse=2)
def test_isalnum(self, size):
- SUBSTR = '123456'
- s = 'a' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = _('123456')
+ s = _('a') * size + SUBSTR
self.assertTrue(s.isalnum())
- s += '.'
+ s += _('.')
self.assertFalse(s.isalnum())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isalpha(self, size):
- SUBSTR = 'zzzzzzz'
- s = 'a' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = _('zzzzzzz')
+ s = _('a') * size + SUBSTR
self.assertTrue(s.isalpha())
- s += '.'
+ s += _('.')
self.assertFalse(s.isalpha())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isdigit(self, size):
- SUBSTR = '123456'
- s = '9' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = _('123456')
+ s = _('9') * size + SUBSTR
self.assertTrue(s.isdigit())
- s += 'z'
+ s += _('z')
self.assertFalse(s.isdigit())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_islower(self, size):
- chars = ''.join([ chr(c) for c in range(255) if not chr(c).isupper() ])
+ _ = self.from_latin1
+ chars = _(''.join(
+ chr(c) for c in range(255) if not chr(c).isupper()))
repeats = size // len(chars) + 2
s = chars * repeats
self.assertTrue(s.islower())
- s += 'A'
+ s += _('A')
self.assertFalse(s.islower())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isspace(self, size):
- whitespace = ' \f\n\r\t\v'
+ _ = self.from_latin1
+ whitespace = _(' \f\n\r\t\v')
repeats = size // len(whitespace) + 2
s = whitespace * repeats
self.assertTrue(s.isspace())
- s += 'j'
+ s += _('j')
self.assertFalse(s.isspace())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_istitle(self, size):
- SUBSTR = '123456'
- s = ''.join(['A', 'a' * size, SUBSTR])
+ _ = self.from_latin1
+ SUBSTR = _('123456')
+ s = _('').join([_('A'), _('a') * size, SUBSTR])
self.assertTrue(s.istitle())
- s += 'A'
+ s += _('A')
self.assertTrue(s.istitle())
- s += 'aA'
+ s += _('aA')
self.assertFalse(s.istitle())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_isupper(self, size):
- chars = ''.join([ chr(c) for c in range(255) if not chr(c).islower() ])
+ _ = self.from_latin1
+ chars = _(''.join(
+ chr(c) for c in range(255) if not chr(c).islower()))
repeats = size // len(chars) + 2
s = chars * repeats
self.assertTrue(s.isupper())
- s += 'a'
+ s += _('a')
self.assertFalse(s.isupper())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_join(self, size):
- s = 'A' * size
- x = s.join(['aaaaa', 'bbbbb'])
- self.assertEqual(x.count('a'), 5)
- self.assertEqual(x.count('b'), 5)
- self.assertTrue(x.startswith('aaaaaA'))
- self.assertTrue(x.endswith('Abbbbb'))
-
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ _ = self.from_latin1
+ s = _('A') * size
+ x = s.join([_('aaaaa'), _('bbbbb')])
+ self.assertEqual(x.count(_('a')), 5)
+ self.assertEqual(x.count(_('b')), 5)
+ self.assertTrue(x.startswith(_('aaaaaA')))
+ self.assertTrue(x.endswith(_('Abbbbb')))
+
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_ljust(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
- self.assertTrue(s.startswith(SUBSTR + ' '))
+ self.assertTrue(s.startswith(SUBSTR + _(' ')))
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_lower(self, size):
- s = 'A' * size
+ _ = self.from_latin1
+ s = _('A') * size
s = s.lower()
self.assertEqual(len(s), size)
- self.assertEqual(s.count('a'), size)
+ self.assertEqual(s.count(_('a')), size)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_lstrip(self, size):
- SUBSTR = 'abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _('abc def ghi')
s = SUBSTR.rjust(size)
self.assertEqual(len(s), size)
self.assertEqual(s.lstrip(), SUBSTR.lstrip())
del s
s = SUBSTR.ljust(size)
self.assertEqual(len(s), size)
- stripped = s.lstrip()
- self.assertTrue(stripped is s)
+ # Type-specific optimization
+ if isinstance(s, (str, bytes)):
+ stripped = s.lstrip()
+ self.assertTrue(stripped is s)
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_replace(self, size):
- replacement = 'a'
- s = ' ' * size
- s = s.replace(' ', replacement)
+ _ = self.from_latin1
+ replacement = _('a')
+ s = _(' ') * size
+ s = s.replace(_(' '), replacement)
self.assertEqual(len(s), size)
self.assertEqual(s.count(replacement), size)
- s = s.replace(replacement, ' ', size - 4)
+ s = s.replace(replacement, _(' '), size - 4)
self.assertEqual(len(s), size)
self.assertEqual(s.count(replacement), 4)
- self.assertEqual(s[-10:], ' aaaa')
+ self.assertEqual(s[-10:], _(' aaaa'))
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_rfind(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
- s = ''.join([SUBSTR, '-' * size, SUBSTR])
- self.assertEqual(s.rfind(' '), sublen + size + SUBSTR.rfind(' '))
+ s = _('').join([SUBSTR, _('-') * size, SUBSTR])
+ self.assertEqual(s.rfind(_(' ')), sublen + size + SUBSTR.rfind(_(' ')))
self.assertEqual(s.rfind(SUBSTR), sublen + size)
- self.assertEqual(s.rfind(' ', 0, size), SUBSTR.rfind(' '))
+ self.assertEqual(s.rfind(_(' '), 0, size), SUBSTR.rfind(_(' ')))
self.assertEqual(s.rfind(SUBSTR, 0, sublen + size), 0)
- self.assertEqual(s.rfind('i'), sublen + size + SUBSTR.rfind('i'))
- self.assertEqual(s.rfind('i', 0, sublen), SUBSTR.rfind('i'))
- self.assertEqual(s.rfind('i', 0, sublen + size),
- SUBSTR.rfind('i'))
- self.assertEqual(s.rfind('j'), -1)
+ self.assertEqual(s.rfind(_('i')), sublen + size + SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('i'), 0, sublen), SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('i'), 0, sublen + size),
+ SUBSTR.rfind(_('i')))
+ self.assertEqual(s.rfind(_('j')), -1)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_rindex(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
sublen = len(SUBSTR)
- s = ''.join([SUBSTR, '-' * size, SUBSTR])
- self.assertEqual(s.rindex(' '),
- sublen + size + SUBSTR.rindex(' '))
+ s = _('').join([SUBSTR, _('-') * size, SUBSTR])
+ self.assertEqual(s.rindex(_(' ')),
+ sublen + size + SUBSTR.rindex(_(' ')))
self.assertEqual(s.rindex(SUBSTR), sublen + size)
- self.assertEqual(s.rindex(' ', 0, sublen + size - 1),
- SUBSTR.rindex(' '))
+ self.assertEqual(s.rindex(_(' '), 0, sublen + size - 1),
+ SUBSTR.rindex(_(' ')))
self.assertEqual(s.rindex(SUBSTR, 0, sublen + size), 0)
- self.assertEqual(s.rindex('i'),
- sublen + size + SUBSTR.rindex('i'))
- self.assertEqual(s.rindex('i', 0, sublen), SUBSTR.rindex('i'))
- self.assertEqual(s.rindex('i', 0, sublen + size),
- SUBSTR.rindex('i'))
- self.assertRaises(ValueError, s.rindex, 'j')
-
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ self.assertEqual(s.rindex(_('i')),
+ sublen + size + SUBSTR.rindex(_('i')))
+ self.assertEqual(s.rindex(_('i'), 0, sublen), SUBSTR.rindex(_('i')))
+ self.assertEqual(s.rindex(_('i'), 0, sublen + size),
+ SUBSTR.rindex(_('i')))
+ self.assertRaises(ValueError, s.rindex, _('j'))
+
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_rjust(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
- self.assertTrue(s.startswith(SUBSTR + ' '))
+ self.assertTrue(s.startswith(SUBSTR + _(' ')))
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_rstrip(self, size):
- SUBSTR = ' abc def ghi'
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
s = SUBSTR.ljust(size)
self.assertEqual(len(s), size)
self.assertEqual(s.rstrip(), SUBSTR.rstrip())
del s
s = SUBSTR.rjust(size)
self.assertEqual(len(s), size)
- stripped = s.rstrip()
- self.assertTrue(stripped is s)
+ # Type-specific optimization
+ if isinstance(s, (str, bytes)):
+ stripped = s.rstrip()
+ self.assertTrue(stripped is s)
# The test takes about size bytes to build a string, and then about
# sqrt(size) substrings of sqrt(size) in size and a list to
# hold sqrt(size) items. It's close but just over 2x size.
- @bigmemtest(minsize=_2G, memuse=2.1)
+ @bigmemtest(size=_2G, memuse=2.1)
def test_split_small(self, size):
+ _ = self.from_latin1
# Crudely calculate an estimate so that the result of s.split won't
# take up an inordinate amount of memory
chunksize = int(size ** 0.5 + 2)
- SUBSTR = 'a' + ' ' * chunksize
+ SUBSTR = _('a') + _(' ') * chunksize
s = SUBSTR * chunksize
l = s.split()
self.assertEqual(len(l), chunksize)
- self.assertEqual(set(l), set(['a']))
+ expected = _('a')
+ for item in l:
+ self.assertEqual(item, expected)
del l
- l = s.split('a')
+ l = s.split(_('a'))
self.assertEqual(len(l), chunksize + 1)
- self.assertEqual(set(l), set(['', ' ' * chunksize]))
+ expected = _(' ') * chunksize
+ for item in filter(None, l):
+ self.assertEqual(item, expected)
# Allocates a string of twice size (and briefly two) and a list of
# size. Because of internal affairs, the s.split() call produces a
@@ -374,39 +347,45 @@ class StrTest(unittest.TestCase):
# suffer for the list size. (Otherwise, it'd cost another 48 times
# size in bytes!) Nevertheless, a list of size takes
# 8*size bytes.
- @bigmemtest(minsize=_2G + 5, memuse=10)
+ @bigmemtest(size=_2G + 5, memuse=10)
def test_split_large(self, size):
- s = ' a' * size + ' '
+ _ = self.from_latin1
+ s = _(' a') * size + _(' ')
l = s.split()
self.assertEqual(len(l), size)
- self.assertEqual(set(l), set(['a']))
+ self.assertEqual(set(l), set([_('a')]))
del l
- l = s.split('a')
+ l = s.split(_('a'))
self.assertEqual(len(l), size + 1)
- self.assertEqual(set(l), set([' ']))
+ self.assertEqual(set(l), set([_(' ')]))
- @bigmemtest(minsize=_2G, memuse=2.1)
+ @bigmemtest(size=_2G, memuse=2.1)
def test_splitlines(self, size):
+ _ = self.from_latin1
# Crudely calculate an estimate so that the result of s.split won't
# take up an inordinate amount of memory
chunksize = int(size ** 0.5 + 2) // 2
- SUBSTR = ' ' * chunksize + '\n' + ' ' * chunksize + '\r\n'
+ SUBSTR = _(' ') * chunksize + _('\n') + _(' ') * chunksize + _('\r\n')
s = SUBSTR * chunksize
l = s.splitlines()
self.assertEqual(len(l), chunksize * 2)
- self.assertEqual(set(l), set([' ' * chunksize]))
+ expected = _(' ') * chunksize
+ for item in l:
+ self.assertEqual(item, expected)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_startswith(self, size):
- SUBSTR = ' abc def ghi'
- s = '-' * size + SUBSTR
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi')
+ s = _('-') * size + SUBSTR
self.assertTrue(s.startswith(s))
- self.assertTrue(s.startswith('-' * size))
+ self.assertTrue(s.startswith(_('-') * size))
self.assertFalse(s.startswith(SUBSTR))
- @bigmemtest(minsize=_2G, memuse=1)
+ @bigmemtest(size=_2G, memuse=1)
def test_strip(self, size):
- SUBSTR = ' abc def ghi '
+ _ = self.from_latin1
+ SUBSTR = _(' abc def ghi ')
s = SUBSTR.rjust(size)
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
@@ -415,9 +394,10 @@ class StrTest(unittest.TestCase):
self.assertEqual(len(s), size)
self.assertEqual(s.strip(), SUBSTR.strip())
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_swapcase(self, size):
- SUBSTR = "aBcDeFG12.'\xa9\x00"
+ _ = self.from_latin1
+ SUBSTR = _("aBcDeFG12.'\xa9\x00")
sublen = len(SUBSTR)
repeats = size // sublen + 2
s = SUBSTR * repeats
@@ -426,18 +406,27 @@ class StrTest(unittest.TestCase):
self.assertEqual(s[:sublen * 3], SUBSTR.swapcase() * 3)
self.assertEqual(s[-sublen * 3:], SUBSTR.swapcase() * 3)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_title(self, size):
- SUBSTR = 'SpaaHAaaAaham'
+ _ = self.from_latin1
+ SUBSTR = _('SpaaHAaaAaham')
s = SUBSTR * (size // len(SUBSTR) + 2)
s = s.title()
self.assertTrue(s.startswith((SUBSTR * 3).title()))
self.assertTrue(s.endswith(SUBSTR.lower() * 3))
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_translate(self, size):
- trans = string.maketrans('.aZ', '-!$')
- SUBSTR = 'aZz.z.Aaz.'
+ _ = self.from_latin1
+ SUBSTR = _('aZz.z.Aaz.')
+ if isinstance(SUBSTR, str):
+ trans = {
+ ord(_('.')): _('-'),
+ ord(_('a')): _('!'),
+ ord(_('Z')): _('$'),
+ }
+ else:
+ trans = bytes.maketrans(b'.aZ', b'-!$')
sublen = len(SUBSTR)
repeats = size // sublen + 2
s = SUBSTR * repeats
@@ -445,105 +434,54 @@ class StrTest(unittest.TestCase):
self.assertEqual(len(s), repeats * sublen)
self.assertEqual(s[:sublen], SUBSTR.translate(trans))
self.assertEqual(s[-sublen:], SUBSTR.translate(trans))
- self.assertEqual(s.count('.'), 0)
- self.assertEqual(s.count('!'), repeats * 2)
- self.assertEqual(s.count('z'), repeats * 3)
+ self.assertEqual(s.count(_('.')), 0)
+ self.assertEqual(s.count(_('!')), repeats * 2)
+ self.assertEqual(s.count(_('z')), repeats * 3)
- @bigmemtest(minsize=_2G + 5, memuse=2)
+ @bigmemtest(size=_2G + 5, memuse=2)
def test_upper(self, size):
- s = 'a' * size
+ _ = self.from_latin1
+ s = _('a') * size
s = s.upper()
self.assertEqual(len(s), size)
- self.assertEqual(s.count('A'), size)
+ self.assertEqual(s.count(_('A')), size)
- @bigmemtest(minsize=_2G + 20, memuse=1)
+ @bigmemtest(size=_2G + 20, memuse=1)
def test_zfill(self, size):
- SUBSTR = '-568324723598234'
+ _ = self.from_latin1
+ SUBSTR = _('-568324723598234')
s = SUBSTR.zfill(size)
- self.assertTrue(s.endswith('0' + SUBSTR[1:]))
- self.assertTrue(s.startswith('-0'))
+ self.assertTrue(s.endswith(_('0') + SUBSTR[1:]))
+ self.assertTrue(s.startswith(_('-0')))
self.assertEqual(len(s), size)
- self.assertEqual(s.count('0'), size - len(SUBSTR))
-
- @bigmemtest(minsize=_2G + 10, memuse=2)
- def test_format(self, size):
- s = '-' * size
- sf = '%s' % (s,)
- self.assertTrue(s == sf)
- del sf
- sf = '..%s..' % (s,)
- self.assertEqual(len(sf), len(s) + 4)
- self.assertTrue(sf.startswith('..-'))
- self.assertTrue(sf.endswith('-..'))
- del s, sf
-
- size //= 2
- edge = '-' * size
- s = ''.join([edge, '%s', edge])
- del edge
- s = s % '...'
- self.assertEqual(len(s), size * 2 + 3)
- self.assertEqual(s.count('.'), 3)
- self.assertEqual(s.count('-'), size * 2)
-
- @bigmemtest(minsize=_2G + 10, memuse=5)
- def test_repr_small(self, size):
- s = '-' * size
- s = repr(s)
- self.assertEqual(len(s), size + 2)
- self.assertEqual(s[0], "'")
- self.assertEqual(s[-1], "'")
- self.assertEqual(s.count('-'), size)
- del s
- # repr() will create a string four times as large as this 'binary
- # string', but we don't want to allocate much more than twice
- # size in total. (We do extra testing in test_repr_large())
- s = '\x00' * size
- s = repr(s)
- self.assertEqual(len(s), size * 4 + 2)
- self.assertEqual(s[0], "'")
- self.assertEqual(s[-1], "'")
- self.assertEqual(s.count('\\'), size)
- self.assertEqual(s.count('0'), size * 2)
-
- @bigmemtest(minsize=_2G + 10, memuse=5)
- def test_repr_large(self, size):
- s = '\x00' * size
- s = repr(s)
- self.assertEqual(len(s), size * 4 + 2)
- self.assertEqual(s[0], "'")
- self.assertEqual(s[-1], "'")
- self.assertEqual(s.count('\\'), size)
- self.assertEqual(s.count('0'), size * 2)
-
- @bigmemtest(minsize=2**32 // 5, memuse=6+2)
- def test_unicode_repr(self, size):
- s = u"\uAAAA" * size
- self.assertTrue(len(repr(s)) > size)
+ self.assertEqual(s.count(_('0')), size - len(SUBSTR))
# This test is meaningful even with size < 2G, as long as the
# doubled string is > 2G (but it tests more if both are > 2G :)
- @bigmemtest(minsize=_1G + 2, memuse=3)
+ @bigmemtest(size=_1G + 2, memuse=3)
def test_concat(self, size):
- s = '.' * size
+ _ = self.from_latin1
+ s = _('.') * size
self.assertEqual(len(s), size)
s = s + s
self.assertEqual(len(s), size * 2)
- self.assertEqual(s.count('.'), size * 2)
+ self.assertEqual(s.count(_('.')), size * 2)
# This test is meaningful even with size < 2G, as long as the
# repeated string is > 2G (but it tests more if both are > 2G :)
- @bigmemtest(minsize=_1G + 2, memuse=3)
+ @bigmemtest(size=_1G + 2, memuse=3)
def test_repeat(self, size):
- s = '.' * size
+ _ = self.from_latin1
+ s = _('.') * size
self.assertEqual(len(s), size)
s = s * 2
self.assertEqual(len(s), size * 2)
- self.assertEqual(s.count('.'), size * 2)
+ self.assertEqual(s.count(_('.')), size * 2)
- @bigmemtest(minsize=_2G + 20, memuse=2)
+ @bigmemtest(size=_2G + 20, memuse=2)
def test_slice_and_getitem(self, size):
- SUBSTR = '0123456789'
+ _ = self.from_latin1
+ SUBSTR = _('0123456789')
sublen = len(SUBSTR)
s = SUBSTR * (size // sublen)
stepsize = len(s) // 100
@@ -561,9 +499,9 @@ class StrTest(unittest.TestCase):
self.assertEqual(s[-1], SUBSTR[-1])
self.assertEqual(s[len(s) - 10], SUBSTR[0])
self.assertEqual(s[-sublen], SUBSTR[0])
- self.assertEqual(s[len(s):], '')
- self.assertEqual(s[len(s) - 1:], SUBSTR[-1])
- self.assertEqual(s[-1:], SUBSTR[-1])
+ self.assertEqual(s[len(s):], _(''))
+ self.assertEqual(s[len(s) - 1:], SUBSTR[-1:])
+ self.assertEqual(s[-1:], SUBSTR[-1:])
self.assertEqual(s[len(s) - sublen:], SUBSTR)
self.assertEqual(s[-sublen:], SUBSTR)
self.assertEqual(len(s[:]), len(s))
@@ -574,32 +512,34 @@ class StrTest(unittest.TestCase):
self.assertRaises(IndexError, operator.getitem, s, len(s) + 1)
self.assertRaises(IndexError, operator.getitem, s, len(s) + 1<<31)
- @bigmemtest(minsize=_2G, memuse=2)
+ @bigmemtest(size=_2G, memuse=2)
def test_contains(self, size):
- SUBSTR = '0123456789'
- edge = '-' * (size // 2)
- s = ''.join([edge, SUBSTR, edge])
+ _ = self.from_latin1
+ SUBSTR = _('0123456789')
+ edge = _('-') * (size // 2)
+ s = _('').join([edge, SUBSTR, edge])
del edge
self.assertIn(SUBSTR, s)
self.assertNotIn(SUBSTR * 2, s)
- self.assertIn('-', s)
- self.assertNotIn('a', s)
- s += 'a'
- self.assertIn('a', s)
+ self.assertIn(_('-'), s)
+ self.assertNotIn(_('a'), s)
+ s += _('a')
+ self.assertIn(_('a'), s)
- @bigmemtest(minsize=_2G + 10, memuse=2)
+ @bigmemtest(size=_2G + 10, memuse=2)
def test_compare(self, size):
- s1 = '-' * size
- s2 = '-' * size
- self.assertTrue(s1 == s2)
+ _ = self.from_latin1
+ s1 = _('-') * size
+ s2 = _('-') * size
+ self.assertEqual(s1, s2)
del s2
- s2 = s1 + 'a'
+ s2 = s1 + _('a')
self.assertFalse(s1 == s2)
del s2
- s2 = '.' * size
+ s2 = _('.') * size
self.assertFalse(s1 == s2)
- @bigmemtest(minsize=_2G + 10, memuse=1)
+ @bigmemtest(size=_2G + 10, memuse=1)
def test_hash(self, size):
# Not sure if we can do any meaningful tests here... Even if we
# start relying on the exact algorithm used, the result will be
@@ -607,12 +547,196 @@ class StrTest(unittest.TestCase):
# test is dodgy (there's no *guarantee* that the two things should
# have a different hash, even if they, in the current
# implementation, almost always do.)
- s = '\x00' * size
+ _ = self.from_latin1
+ s = _('\x00') * size
h1 = hash(s)
del s
- s = '\x00' * (size + 1)
+ s = _('\x00') * (size + 1)
self.assertFalse(h1 == hash(s))
+
+class StrTest(unittest.TestCase, BaseStrTest):
+
+ def from_latin1(self, s):
+ return s
+
+ def basic_encode_test(self, size, enc, c='.', expectedsize=None):
+ if expectedsize is None:
+ expectedsize = size
+
+ try:
+ s = c * size
+ self.assertEqual(len(s.encode(enc)), expectedsize)
+ finally:
+ s = None
+
+ def setUp(self):
+ # HACK: adjust memory use of tests inherited from BaseStrTest
+ # according to character size.
+ self._adjusted = {}
+ for name in dir(BaseStrTest):
+ if not name.startswith('test_'):
+ continue
+ meth = getattr(type(self), name)
+ try:
+ memuse = meth.memuse
+ except AttributeError:
+ continue
+ meth.memuse = character_size * memuse
+ self._adjusted[name] = memuse
+
+ def tearDown(self):
+ for name, memuse in self._adjusted.items():
+ getattr(type(self), name).memuse = memuse
+
+ # the utf8 encoder preallocates big time (4x the number of characters)
+ @bigmemtest(size=_2G + 2, memuse=character_size + 4)
+ def test_encode(self, size):
+ return self.basic_encode_test(size, 'utf-8')
+
+ @bigmemtest(size=_4G // 6 + 2, memuse=character_size + 1)
+ def test_encode_raw_unicode_escape(self, size):
+ try:
+ return self.basic_encode_test(size, 'raw_unicode_escape')
+ except MemoryError:
+ pass # acceptable on 32-bit
+
+ @bigmemtest(size=_4G // 5 + 70, memuse=character_size + 1)
+ def test_encode_utf7(self, size):
+ try:
+ return self.basic_encode_test(size, 'utf7')
+ except MemoryError:
+ pass # acceptable on 32-bit
+
+ @bigmemtest(size=_4G // 4 + 5, memuse=character_size + 4)
+ def test_encode_utf32(self, size):
+ try:
+ return self.basic_encode_test(size, 'utf32', expectedsize=4*size+4)
+ except MemoryError:
+ pass # acceptable on 32-bit
+
+ @bigmemtest(size=_2G - 1, memuse=character_size + 1)
+ def test_encode_ascii(self, size):
+ return self.basic_encode_test(size, 'ascii', c='A')
+
+ @bigmemtest(size=_2G + 10, memuse=character_size * 2)
+ def test_format(self, size):
+ s = '-' * size
+ sf = '%s' % (s,)
+ self.assertEqual(s, sf)
+ del sf
+ sf = '..%s..' % (s,)
+ self.assertEqual(len(sf), len(s) + 4)
+ self.assertTrue(sf.startswith('..-'))
+ self.assertTrue(sf.endswith('-..'))
+ del s, sf
+
+ size //= 2
+ edge = '-' * size
+ s = ''.join([edge, '%s', edge])
+ del edge
+ s = s % '...'
+ self.assertEqual(len(s), size * 2 + 3)
+ self.assertEqual(s.count('.'), 3)
+ self.assertEqual(s.count('-'), size * 2)
+
+ @bigmemtest(size=_2G + 10, memuse=character_size * 2)
+ def test_repr_small(self, size):
+ s = '-' * size
+ s = repr(s)
+ self.assertEqual(len(s), size + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('-'), size)
+ del s
+ # repr() will create a string four times as large as this 'binary
+ # string', but we don't want to allocate much more than twice
+ # size in total. (We do extra testing in test_repr_large())
+ size = size // 5 * 2
+ s = '\x00' * size
+ s = repr(s)
+ self.assertEqual(len(s), size * 4 + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('\\'), size)
+ self.assertEqual(s.count('0'), size * 2)
+
+ @bigmemtest(size=_2G + 10, memuse=character_size * 5)
+ def test_repr_large(self, size):
+ s = '\x00' * size
+ s = repr(s)
+ self.assertEqual(len(s), size * 4 + 2)
+ self.assertEqual(s[0], "'")
+ self.assertEqual(s[-1], "'")
+ self.assertEqual(s.count('\\'), size)
+ self.assertEqual(s.count('0'), size * 2)
+
+ @bigmemtest(size=_2G // 5 + 1, memuse=character_size * 7)
+ def test_unicode_repr(self, size):
+ # Use an assigned, but not printable code point.
+ # It is in the range of the low surrogates \uDC00-\uDFFF.
+ char = "\uDCBA"
+ s = char * size
+ try:
+ for f in (repr, ascii):
+ r = f(s)
+ self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size)
+ self.assertTrue(r.endswith(r"\udcba'"), r[-10:])
+ r = None
+ finally:
+ r = s = None
+
+ # The character takes 4 bytes even in UCS-2 builds because it will
+ # be decomposed into surrogates.
+ @bigmemtest(size=_2G // 5 + 1, memuse=4 + character_size * 9)
+ def test_unicode_repr_wide(self, size):
+ char = "\U0001DCBA"
+ s = char * size
+ try:
+ for f in (repr, ascii):
+ r = f(s)
+ self.assertEqual(len(r), 2 + (len(f(char)) - 2) * size)
+ self.assertTrue(r.endswith(r"\U0001dcba'"), r[-12:])
+ r = None
+ finally:
+ r = s = None
+
+ @bigmemtest(size=_4G // 5, memuse=character_size * (6 + 1))
+ def _test_unicode_repr_overflow(self, size):
+ # XXX not sure what this test is about
+ char = "\uDCBA"
+ s = char * size
+ try:
+ r = repr(s)
+ self.assertTrue(s == eval(r))
+ finally:
+ r = s = None
+
+
+class BytesTest(unittest.TestCase, BaseStrTest):
+
+ def from_latin1(self, s):
+ return s.encode("latin1")
+
+ @bigmemtest(size=_2G + 2, memuse=1 + character_size)
+ def test_decode(self, size):
+ s = self.from_latin1('.') * size
+ self.assertEqual(len(s.decode('utf-8')), size)
+
+
+class BytearrayTest(unittest.TestCase, BaseStrTest):
+
+ def from_latin1(self, s):
+ return bytearray(s.encode("latin1"))
+
+ @bigmemtest(size=_2G + 2, memuse=1 + character_size)
+ def test_decode(self, size):
+ s = self.from_latin1('.') * size
+ self.assertEqual(len(s.decode('utf-8')), size)
+
+ test_hash = None
+ test_split_large = None
+
class TupleTest(unittest.TestCase):
# Tuples have a small, fixed-sized head and an array of pointers to
@@ -624,13 +748,13 @@ class TupleTest(unittest.TestCase):
# having more than 2<<31 references to any given object. Hence the
# use of different types of objects as contents in different tests.
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_compare(self, size):
- t1 = (u'',) * size
- t2 = (u'',) * size
- self.assertTrue(t1 == t2)
+ t1 = ('',) * size
+ t2 = ('',) * size
+ self.assertEqual(t1, t2)
del t2
- t2 = (u'',) * (size + 1)
+ t2 = ('',) * (size + 1)
self.assertFalse(t1 == t2)
del t2
t2 = (1,) * size
@@ -647,15 +771,15 @@ class TupleTest(unittest.TestCase):
t = t + t
self.assertEqual(len(t), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
return self.basic_concat_test(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_concat_large(self, size):
return self.basic_concat_test(size)
- @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
t = (1, 2, 3, 4, 5) * size
self.assertEqual(len(t), size * 5)
@@ -663,7 +787,7 @@ class TupleTest(unittest.TestCase):
self.assertNotIn((1, 2, 3, 4, 5), t)
self.assertNotIn(0, t)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_hash(self, size):
t1 = (0,) * size
h1 = hash(t1)
@@ -671,7 +795,7 @@ class TupleTest(unittest.TestCase):
t2 = (0,) * (size + 1)
self.assertFalse(h1 == hash(t2))
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
t = (None,) * size
self.assertEqual(len(t), size)
@@ -696,22 +820,23 @@ class TupleTest(unittest.TestCase):
t = t * 2
self.assertEqual(len(t), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_repeat_large(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_1G - 1, memuse=12)
+ @bigmemtest(size=_1G - 1, memuse=12)
def test_repeat_large_2(self, size):
return self.basic_test_repeat(size)
- @precisionbigmemtest(size=_1G - 1, memuse=9)
+ @bigmemtest(size=_1G - 1, memuse=9)
def test_from_2G_generator(self, size):
+ self.skipTest("test needs much more memory than advertised, see issue5438")
try:
- t = tuple(xrange(size))
+ t = tuple(range(size))
except MemoryError:
pass # acceptable on 32-bit
else:
@@ -721,10 +846,11 @@ class TupleTest(unittest.TestCase):
count += 1
self.assertEqual(count, size)
- @precisionbigmemtest(size=_1G - 25, memuse=9)
+ @bigmemtest(size=_1G - 25, memuse=9)
def test_from_almost_2G_generator(self, size):
+ self.skipTest("test needs much more memory than advertised, see issue5438")
try:
- t = tuple(xrange(size))
+ t = tuple(range(size))
count = 0
for item in t:
self.assertEqual(item, count)
@@ -743,11 +869,11 @@ class TupleTest(unittest.TestCase):
self.assertEqual(s[-5:], '0, 0)')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3)
+ @bigmemtest(size=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3)
+ @bigmemtest(size=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
@@ -758,13 +884,13 @@ class ListTest(unittest.TestCase):
# lists hold references to various objects to test their refcount
# limits.
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_compare(self, size):
- l1 = [u''] * size
- l2 = [u''] * size
- self.assertTrue(l1 == l2)
+ l1 = [''] * size
+ l2 = [''] * size
+ self.assertEqual(l1, l2)
del l2
- l2 = [u''] * (size + 1)
+ l2 = [''] * (size + 1)
self.assertFalse(l1 == l2)
del l2
l2 = [2] * size
@@ -781,11 +907,11 @@ class ListTest(unittest.TestCase):
l = l + l
self.assertEqual(len(l), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_concat_small(self, size):
return self.basic_test_concat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_concat_large(self, size):
return self.basic_test_concat(size)
@@ -796,15 +922,15 @@ class ListTest(unittest.TestCase):
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_inplace_concat_small(self, size):
return self.basic_test_inplace_concat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_inplace_concat_large(self, size):
return self.basic_test_inplace_concat(size)
- @bigmemtest(minsize=_2G // 5 + 10, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 10, memuse=8 * 5)
def test_contains(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEqual(len(l), size * 5)
@@ -812,12 +938,12 @@ class ListTest(unittest.TestCase):
self.assertNotIn([1, 2, 3, 4, 5], l)
self.assertNotIn(0, l)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_hash(self, size):
l = [0] * size
self.assertRaises(TypeError, hash, l)
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_index_and_slice(self, size):
l = [None] * size
self.assertEqual(len(l), size)
@@ -881,11 +1007,11 @@ class ListTest(unittest.TestCase):
l = l * 2
self.assertEqual(len(l), size * 2)
- @bigmemtest(minsize=_2G // 2 + 2, memuse=24)
+ @bigmemtest(size=_2G // 2 + 2, memuse=24)
def test_repeat_small(self, size):
return self.basic_test_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=24)
+ @bigmemtest(size=_2G + 2, memuse=24)
def test_repeat_large(self, size):
return self.basic_test_repeat(size)
@@ -901,11 +1027,11 @@ class ListTest(unittest.TestCase):
self.assertEqual(len(l), size * 2)
self.assertTrue(l[size - 1] is l[-1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
+ @bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_inplace_repeat_small(self, size):
return self.basic_test_inplace_repeat(size)
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_inplace_repeat_large(self, size):
return self.basic_test_inplace_repeat(size)
@@ -918,17 +1044,17 @@ class ListTest(unittest.TestCase):
self.assertEqual(s[-5:], '0, 0]')
self.assertEqual(s.count('0'), size)
- @bigmemtest(minsize=_2G // 3 + 2, memuse=8 + 3)
+ @bigmemtest(size=_2G // 3 + 2, memuse=8 + 3 * character_size)
def test_repr_small(self, size):
return self.basic_test_repr(size)
- @bigmemtest(minsize=_2G + 2, memuse=8 + 3)
+ @bigmemtest(size=_2G + 2, memuse=8 + 3 * character_size)
def test_repr_large(self, size):
return self.basic_test_repr(size)
# list overallocates ~1/8th of the total size (on first expansion) so
# the single list.append call puts memuse at 9 bytes per size.
- @bigmemtest(minsize=_2G, memuse=9)
+ @bigmemtest(size=_2G, memuse=9)
def test_append(self, size):
l = [object()] * size
l.append(object())
@@ -936,39 +1062,39 @@ class ListTest(unittest.TestCase):
self.assertTrue(l[-3] is l[-2])
self.assertFalse(l[-2] is l[-1])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_count(self, size):
l = [1, 2, 3, 4, 5] * size
self.assertEqual(l.count(1), size)
self.assertEqual(l.count("1"), 0)
def basic_test_extend(self, size):
- l = [file] * size
+ l = [object] * size
l.extend(l)
self.assertEqual(len(l), size * 2)
self.assertTrue(l[0] is l[-1])
self.assertTrue(l[size - 1] is l[size + 1])
- @bigmemtest(minsize=_2G // 2 + 2, memuse=16)
+ @bigmemtest(size=_2G // 2 + 2, memuse=16)
def test_extend_small(self, size):
return self.basic_test_extend(size)
- @bigmemtest(minsize=_2G + 2, memuse=16)
+ @bigmemtest(size=_2G + 2, memuse=16)
def test_extend_large(self, size):
return self.basic_test_extend(size)
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_index(self, size):
- l = [1L, 2L, 3L, 4L, 5L] * size
+ l = [1, 2, 3, 4, 5] * size
size *= 5
self.assertEqual(l.index(1), 0)
self.assertEqual(l.index(5, size - 5), size - 1)
self.assertEqual(l.index(5, size - 5, size), size - 1)
self.assertRaises(ValueError, l.index, 1, size - 4, size)
- self.assertRaises(ValueError, l.index, 6L)
+ self.assertRaises(ValueError, l.index, 6)
# This tests suffers from overallocation, just like test_append.
- @bigmemtest(minsize=_2G + 10, memuse=9)
+ @bigmemtest(size=_2G + 10, memuse=9)
def test_insert(self, size):
l = [1.0] * size
l.insert(size - 1, "A")
@@ -987,31 +1113,31 @@ class ListTest(unittest.TestCase):
self.assertEqual(l[:3], [1.0, "C", 1.0])
self.assertEqual(l[size - 3:], ["A", 1.0, "B"])
- @bigmemtest(minsize=_2G // 5 + 4, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 4, memuse=8 * 5)
def test_pop(self, size):
- l = [u"a", u"b", u"c", u"d", u"e"] * size
+ l = ["a", "b", "c", "d", "e"] * size
size *= 5
self.assertEqual(len(l), size)
item = l.pop()
size -= 1
self.assertEqual(len(l), size)
- self.assertEqual(item, u"e")
- self.assertEqual(l[-2:], [u"c", u"d"])
+ self.assertEqual(item, "e")
+ self.assertEqual(l[-2:], ["c", "d"])
item = l.pop(0)
size -= 1
self.assertEqual(len(l), size)
- self.assertEqual(item, u"a")
- self.assertEqual(l[:2], [u"b", u"c"])
+ self.assertEqual(item, "a")
+ self.assertEqual(l[:2], ["b", "c"])
item = l.pop(size - 2)
size -= 1
self.assertEqual(len(l), size)
- self.assertEqual(item, u"c")
- self.assertEqual(l[-2:], [u"b", u"d"])
+ self.assertEqual(item, "c")
+ self.assertEqual(l[-2:], ["b", "d"])
- @bigmemtest(minsize=_2G + 10, memuse=8)
+ @bigmemtest(size=_2G + 10, memuse=8)
def test_remove(self, size):
l = [10] * size
self.assertEqual(len(l), size)
@@ -1031,7 +1157,7 @@ class ListTest(unittest.TestCase):
self.assertEqual(len(l), size)
self.assertEqual(l[-2:], [10, 10])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_reverse(self, size):
l = [1, 2, 3, 4, 5] * size
l.reverse()
@@ -1039,7 +1165,7 @@ class ListTest(unittest.TestCase):
self.assertEqual(l[-5:], [5, 4, 3, 2, 1])
self.assertEqual(l[:5], [5, 4, 3, 2, 1])
- @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
+ @bigmemtest(size=_2G // 5 + 2, memuse=8 * 5)
def test_sort(self, size):
l = [1, 2, 3, 4, 5] * size
l.sort()
@@ -1048,26 +1174,11 @@ class ListTest(unittest.TestCase):
self.assertEqual(l[:10], [1] * 10)
self.assertEqual(l[-10:], [5] * 10)
-class BufferTest(unittest.TestCase):
-
- @precisionbigmemtest(size=_1G, memuse=4)
- def test_repeat(self, size):
- try:
- with test_support.check_py3k_warnings():
- b = buffer("AAAA")*size
- except MemoryError:
- pass # acceptable on 32-bit
- else:
- count = 0
- for c in b:
- self.assertEqual(c, 'A')
- count += 1
- self.assertEqual(count, size*4)
-
def test_main():
- test_support.run_unittest(StrTest, TupleTest, ListTest, BufferTest)
+ support.run_unittest(StrTest, BytesTest, BytearrayTest,
+ TupleTest, ListTest)
if __name__ == '__main__':
if len(sys.argv) > 1:
- test_support.set_memlimit(sys.argv[1])
+ support.set_memlimit(sys.argv[1])
test_main()
diff --git a/Lib/test/test_binascii.py b/Lib/test/test_binascii.py
index f825f1c0779..1e9e888f28b 100644
--- a/Lib/test/test_binascii.py
+++ b/Lib/test/test_binascii.py
@@ -1,6 +1,6 @@
"""Test the binascii C module."""
-from test import test_support
+from test import support
import unittest
import binascii
import array
@@ -15,12 +15,12 @@ all_functions = a2b_functions + b2a_functions + ['crc32', 'crc_hqx']
class BinASCIITest(unittest.TestCase):
- type2test = str
+ type2test = bytes
# Create binary test data
- rawdata = "The quick brown fox jumps over the lazy dog.\r\n"
+ rawdata = b"The quick brown fox jumps over the lazy dog.\r\n"
# Be slow so we don't depend on other modules
- rawdata += "".join(map(chr, xrange(256)))
- rawdata += "\r\nHello world.\n"
+ rawdata += bytes(range(256))
+ rawdata += b"\r\nHello world.\n"
def setUp(self):
self.data = self.type2test(self.rawdata)
@@ -46,16 +46,16 @@ class BinASCIITest(unittest.TestCase):
try:
a = b2a(self.type2test(raw))
res = a2b(self.type2test(a))
- except Exception, err:
+ except Exception as err:
self.fail("{}/{} conversion raises {!r}".format(fb, fa, err))
if fb == 'b2a_hqx':
# b2a_hqx returns a tuple
res, _ = res
self.assertEqual(res, raw, "{}/{} conversion: "
"{!r} != {!r}".format(fb, fa, res, raw))
- self.assertIsInstance(res, str)
- self.assertIsInstance(a, str)
- self.assertLess(max(ord(c) for c in a), 128)
+ self.assertIsInstance(res, bytes)
+ self.assertIsInstance(a, bytes)
+ self.assertLess(max(a), 128)
self.assertIsInstance(binascii.crc_hqx(raw, 0), int)
self.assertIsInstance(binascii.crc32(raw), int)
@@ -67,11 +67,11 @@ class BinASCIITest(unittest.TestCase):
b = self.type2test(self.rawdata[i:i+MAX_BASE64])
a = binascii.b2a_base64(b)
lines.append(a)
- res = ""
+ res = bytes()
for line in lines:
a = self.type2test(line)
b = binascii.a2b_base64(a)
- res = res + b
+ res += b
self.assertEqual(res, self.rawdata)
def test_base64invalid(self):
@@ -84,24 +84,23 @@ class BinASCIITest(unittest.TestCase):
a = binascii.b2a_base64(b)
lines.append(a)
- fillers = ""
- valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/"
- for i in xrange(256):
- c = chr(i)
- if c not in valid:
- fillers += c
+ fillers = bytearray()
+ valid = b"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/"
+ for i in range(256):
+ if i not in valid:
+ fillers.append(i)
def addnoise(line):
noise = fillers
ratio = len(line) // len(noise)
- res = ""
+ res = bytearray()
while line and noise:
if len(line) // len(noise) > ratio:
c, line = line[0], line[1:]
else:
c, noise = noise[0], noise[1:]
- res += c
+ res.append(c)
return res + noise + line
- res = ""
+ res = bytearray()
for line in map(addnoise, lines):
a = self.type2test(line)
b = binascii.a2b_base64(a)
@@ -110,7 +109,7 @@ class BinASCIITest(unittest.TestCase):
# Test base64 with just invalid characters, which should return
# empty strings. TBD: shouldn't it raise an exception instead ?
- self.assertEqual(binascii.a2b_base64(self.type2test(fillers)), '')
+ self.assertEqual(binascii.a2b_base64(self.type2test(fillers)), b'')
def test_uu(self):
MAX_UU = 45
@@ -119,27 +118,27 @@ class BinASCIITest(unittest.TestCase):
b = self.type2test(self.rawdata[i:i+MAX_UU])
a = binascii.b2a_uu(b)
lines.append(a)
- res = ""
+ res = bytes()
for line in lines:
a = self.type2test(line)
b = binascii.a2b_uu(a)
res += b
self.assertEqual(res, self.rawdata)
- self.assertEqual(binascii.a2b_uu("\x7f"), "\x00"*31)
- self.assertEqual(binascii.a2b_uu("\x80"), "\x00"*32)
- self.assertEqual(binascii.a2b_uu("\xff"), "\x00"*31)
- self.assertRaises(binascii.Error, binascii.a2b_uu, "\xff\x00")
- self.assertRaises(binascii.Error, binascii.a2b_uu, "!!!!")
+ self.assertEqual(binascii.a2b_uu(b"\x7f"), b"\x00"*31)
+ self.assertEqual(binascii.a2b_uu(b"\x80"), b"\x00"*32)
+ self.assertEqual(binascii.a2b_uu(b"\xff"), b"\x00"*31)
+ self.assertRaises(binascii.Error, binascii.a2b_uu, b"\xff\x00")
+ self.assertRaises(binascii.Error, binascii.a2b_uu, b"!!!!")
- self.assertRaises(binascii.Error, binascii.b2a_uu, 46*"!")
+ self.assertRaises(binascii.Error, binascii.b2a_uu, 46*b"!")
# Issue #7701 (crash on a pydebug build)
- self.assertEqual(binascii.b2a_uu('x'), '!> \n')
+ self.assertEqual(binascii.b2a_uu(b'x'), b'!> \n')
def test_crc32(self):
- crc = binascii.crc32(self.type2test("Test the CRC-32 of"))
- crc = binascii.crc32(self.type2test(" this string."), crc)
+ crc = binascii.crc32(self.type2test(b"Test the CRC-32 of"))
+ crc = binascii.crc32(self.type2test(b" this string."), crc)
self.assertEqual(crc, 1571220330)
self.assertRaises(TypeError, binascii.crc32)
@@ -156,51 +155,48 @@ class BinASCIITest(unittest.TestCase):
def test_hex(self):
# test hexlification
- s = '{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
+ s = b'{s\005\000\000\000worldi\002\000\000\000s\005\000\000\000helloi\001\000\000\0000'
t = binascii.b2a_hex(self.type2test(s))
u = binascii.a2b_hex(self.type2test(t))
self.assertEqual(s, u)
- self.assertRaises(TypeError, binascii.a2b_hex, t[:-1])
- self.assertRaises(TypeError, binascii.a2b_hex, t[:-1] + 'q')
+ self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1])
+ self.assertRaises(binascii.Error, binascii.a2b_hex, t[:-1] + b'q')
- # Verify the treatment of Unicode strings
- if test_support.have_unicode:
- self.assertEqual(binascii.hexlify(unicode('a', 'ascii')), '61')
+ self.assertEqual(binascii.hexlify(b'a'), b'61')
def test_qp(self):
# A test for SF bug 534347 (segfaults without the proper fix)
try:
- binascii.a2b_qp("", **{1:1})
+ binascii.a2b_qp(b"", **{1:1})
except TypeError:
pass
else:
self.fail("binascii.a2b_qp(**{1:1}) didn't raise TypeError")
- self.assertEqual(binascii.a2b_qp("= "), "= ")
- self.assertEqual(binascii.a2b_qp("=="), "=")
- self.assertEqual(binascii.a2b_qp("=AX"), "=AX")
+ self.assertEqual(binascii.a2b_qp(b"= "), b"= ")
+ self.assertEqual(binascii.a2b_qp(b"=="), b"=")
+ self.assertEqual(binascii.a2b_qp(b"=AX"), b"=AX")
self.assertRaises(TypeError, binascii.b2a_qp, foo="bar")
- self.assertEqual(binascii.a2b_qp("=00\r\n=00"), "\x00\r\n\x00")
+ self.assertEqual(binascii.a2b_qp(b"=00\r\n=00"), b"\x00\r\n\x00")
self.assertEqual(
- binascii.b2a_qp("\xff\r\n\xff\n\xff"),
- "=FF\r\n=FF\r\n=FF"
- )
+ binascii.b2a_qp(b"\xff\r\n\xff\n\xff"),
+ b"=FF\r\n=FF\r\n=FF")
self.assertEqual(
- binascii.b2a_qp("0"*75+"\xff\r\n\xff\r\n\xff"),
- "0"*75+"=\r\n=FF\r\n=FF\r\n=FF"
- )
+ binascii.b2a_qp(b"0"*75+b"\xff\r\n\xff\r\n\xff"),
+ b"0"*75+b"=\r\n=FF\r\n=FF\r\n=FF")
- self.assertEqual(binascii.b2a_qp('\0\n'), '=00\n')
- self.assertEqual(binascii.b2a_qp('\0\n', quotetabs=True), '=00\n')
- self.assertEqual(binascii.b2a_qp('foo\tbar\t\n'), 'foo\tbar=09\n')
- self.assertEqual(binascii.b2a_qp('foo\tbar\t\n', quotetabs=True), 'foo=09bar=09\n')
+ self.assertEqual(binascii.b2a_qp(b'\0\n'), b'=00\n')
+ self.assertEqual(binascii.b2a_qp(b'\0\n', quotetabs=True), b'=00\n')
+ self.assertEqual(binascii.b2a_qp(b'foo\tbar\t\n'), b'foo\tbar=09\n')
+ self.assertEqual(binascii.b2a_qp(b'foo\tbar\t\n', quotetabs=True),
+ b'foo=09bar=09\n')
- self.assertEqual(binascii.b2a_qp('.'), '=2E')
- self.assertEqual(binascii.b2a_qp('.\n'), '=2E\n')
- self.assertEqual(binascii.b2a_qp('a.\n'), 'a.\n')
+ self.assertEqual(binascii.b2a_qp(b'.'), b'=2E')
+ self.assertEqual(binascii.b2a_qp(b'.\n'), b'=2E\n')
+ self.assertEqual(binascii.b2a_qp(b'a.\n'), b'a.\n')
def test_empty_string(self):
# A test for SF bug #1022953. Make sure SystemError is not raised.
- empty = self.type2test('')
+ empty = self.type2test(b'')
for func in all_functions:
if func == 'crc_hqx':
# crc_hqx needs 2 arguments
@@ -209,13 +205,23 @@ class BinASCIITest(unittest.TestCase):
f = getattr(binascii, func)
try:
f(empty)
- except Exception, err:
+ except Exception as err:
self.fail("{}({!r}) raises {!r}".format(func, empty, err))
+ def test_unicode_strings(self):
+ # Unicode strings are not accepted.
+ for func in all_functions:
+ try:
+ self.assertRaises(TypeError, getattr(binascii, func), "test")
+ except Exception as err:
+ self.fail('{}("test") raises {!r}'.format(func, err))
+ # crc_hqx needs 2 arguments
+ self.assertRaises(TypeError, binascii.crc_hqx, "test", 0)
+
class ArrayBinASCIITest(BinASCIITest):
def type2test(self, s):
- return array.array('c', s)
+ return array.array('B', list(s))
class BytearrayBinASCIITest(BinASCIITest):
@@ -227,10 +233,10 @@ class MemoryviewBinASCIITest(BinASCIITest):
def test_main():
- test_support.run_unittest(BinASCIITest,
- ArrayBinASCIITest,
- BytearrayBinASCIITest,
- MemoryviewBinASCIITest)
+ support.run_unittest(BinASCIITest,
+ ArrayBinASCIITest,
+ BytearrayBinASCIITest,
+ MemoryviewBinASCIITest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_binhex.py b/Lib/test/test_binhex.py
index 2f89703b44a..a807bca6393 100755
--- a/Lib/test/test_binhex.py
+++ b/Lib/test/test_binhex.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the binhex C module
Uses the mechanism of the python binhex module
@@ -7,26 +7,25 @@
import binhex
import os
import unittest
-from test import test_support
+from test import support
class BinHexTestCase(unittest.TestCase):
def setUp(self):
- self.fname1 = test_support.TESTFN + "1"
- self.fname2 = test_support.TESTFN + "2"
+ self.fname1 = support.TESTFN + "1"
+ self.fname2 = support.TESTFN + "2"
+ self.fname3 = support.TESTFN + "very_long_filename__very_long_filename__very_long_filename__very_long_filename__"
def tearDown(self):
- try: os.unlink(self.fname1)
- except OSError: pass
+ support.unlink(self.fname1)
+ support.unlink(self.fname2)
+ support.unlink(self.fname3)
- try: os.unlink(self.fname2)
- except OSError: pass
-
- DATA = 'Jack is my hero'
+ DATA = b'Jack is my hero'
def test_binhex(self):
- f = open(self.fname1, 'w')
+ f = open(self.fname1, 'wb')
f.write(self.DATA)
f.close()
@@ -34,15 +33,24 @@ class BinHexTestCase(unittest.TestCase):
binhex.hexbin(self.fname2, self.fname1)
- f = open(self.fname1, 'r')
+ f = open(self.fname1, 'rb')
finish = f.readline()
f.close()
self.assertEqual(self.DATA, finish)
+ def test_binhex_error_on_long_filename(self):
+ """
+ The testcase fails if no exception is raised when a filename parameter provided to binhex.binhex()
+ is too long, or if the exception raised in binhex.binhex() is not an instance of binhex.Error.
+ """
+ f3 = open(self.fname3, 'wb')
+ f3.close()
+
+ self.assertRaises(binhex.Error, binhex.binhex, self.fname3, self.fname2)
def test_main():
- test_support.run_unittest(BinHexTestCase)
+ support.run_unittest(BinHexTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_binop.py b/Lib/test/test_binop.py
index b1ef626a9ac..84179167e21 100644
--- a/Lib/test/test_binop.py
+++ b/Lib/test/test_binop.py
@@ -1,7 +1,8 @@
"""Tests for binary operators on subtypes of built-in types."""
import unittest
-from test import test_support
+from test import support
+from operator import eq, ne, lt, gt, le, ge
def gcd(a, b):
"""Greatest common divisor using Euclid's algorithm."""
@@ -10,12 +11,12 @@ def gcd(a, b):
return b
def isint(x):
- """Test whether an object is an instance of int or long."""
- return isinstance(x, int) or isinstance(x, long)
+ """Test whether an object is an instance of int."""
+ return isinstance(x, int)
def isnum(x):
"""Test whether an object is an instance of a built-in numeric type."""
- for T in int, long, float, complex:
+ for T in int, float, complex:
if isinstance(x, T):
return 1
return 0
@@ -26,24 +27,24 @@ def isRat(x):
class Rat(object):
- """Rational number implemented as a normalized pair of longs."""
+ """Rational number implemented as a normalized pair of ints."""
__slots__ = ['_Rat__num', '_Rat__den']
- def __init__(self, num=0L, den=1L):
+ def __init__(self, num=0, den=1):
"""Constructor: Rat([num[, den]]).
- The arguments must be ints or longs, and default to (0, 1)."""
+ The arguments must be ints, and default to (0, 1)."""
if not isint(num):
- raise TypeError, "Rat numerator must be int or long (%r)" % num
+ raise TypeError("Rat numerator must be int (%r)" % num)
if not isint(den):
- raise TypeError, "Rat denominator must be int or long (%r)" % den
+ raise TypeError("Rat denominator must be int (%r)" % den)
# But the zero is always on
if den == 0:
- raise ZeroDivisionError, "zero denominator"
+ raise ZeroDivisionError("zero denominator")
g = gcd(den, num)
- self.__num = long(num//g)
- self.__den = long(den//g)
+ self.__num = int(num//g)
+ self.__den = int(den//g)
def _get_num(self):
"""Accessor function for read-only 'num' attribute of Rat."""
@@ -73,15 +74,9 @@ class Rat(object):
try:
return int(self.__num)
except OverflowError:
- raise OverflowError, ("%s too large to convert to int" %
+ raise OverflowError("%s too large to convert to int" %
repr(self))
- raise ValueError, "can't convert %s to int" % repr(self)
-
- def __long__(self):
- """Convert a Rat to an long; self.den must be 1."""
- if self.__den == 1:
- return long(self.__num)
- raise ValueError, "can't convert %s to long" % repr(self)
+ raise ValueError("can't convert %s to int" % repr(self))
def __add__(self, other):
"""Add two Rats, or a Rat and a number."""
@@ -140,8 +135,6 @@ class Rat(object):
return float(self) / other
return NotImplemented
- __div__ = __truediv__
-
def __rtruediv__(self, other):
"""Divide two Rats, or a Rat and a number (reversed args)."""
if isRat(other):
@@ -152,8 +145,6 @@ class Rat(object):
return other / float(self)
return NotImplemented
- __rdiv__ = __rtruediv__
-
def __floordiv__(self, other):
"""Divide two Rats, returning the floored result."""
if isint(other):
@@ -207,9 +198,6 @@ class Rat(object):
"""Compare two Rats for inequality."""
return not self == other
- # Silence Py3k warning
- __hash__ = None
-
class RatTestCase(unittest.TestCase):
"""Unit tests for Rat class and its support utilities."""
@@ -232,9 +220,6 @@ class RatTestCase(unittest.TestCase):
a = Rat(10, 15)
self.assertEqual(a.num, 2)
self.assertEqual(a.den, 3)
- a = Rat(10L, 15L)
- self.assertEqual(a.num, 2)
- self.assertEqual(a.den, 3)
a = Rat(10, -15)
self.assertEqual(a.num, -2)
self.assertEqual(a.den, 3)
@@ -308,24 +293,88 @@ class RatTestCase(unittest.TestCase):
self.assertEqual(Rat(10), 10.0)
self.assertEqual(10.0, Rat(10))
- def test_future_div(self):
- exec future_test
+ def test_true_div(self):
+ self.assertEqual(Rat(10, 3) / Rat(5, 7), Rat(14, 3))
+ self.assertEqual(Rat(10, 3) / 3, Rat(10, 9))
+ self.assertEqual(2 / Rat(5), Rat(2, 5))
+ self.assertEqual(3.0 * Rat(1, 2), 1.5)
+ self.assertEqual(Rat(1, 2) * 3.0, 1.5)
+ self.assertEqual(eval('1/2'), 0.5)
# XXX Ran out of steam; TO DO: divmod, div, future division
-future_test = """
-from __future__ import division
-self.assertEqual(Rat(10, 3) / Rat(5, 7), Rat(14, 3))
-self.assertEqual(Rat(10, 3) / 3, Rat(10, 9))
-self.assertEqual(2 / Rat(5), Rat(2, 5))
-self.assertEqual(3.0 * Rat(1, 2), 1.5)
-self.assertEqual(Rat(1, 2) * 3.0, 1.5)
-self.assertEqual(eval('1/2'), 0.5)
-"""
-def test_main():
- test_support.run_unittest(RatTestCase)
+class OperationLogger:
+ """Base class for classes with operation logging."""
+ def __init__(self, logger):
+ self.logger = logger
+ def log_operation(self, *args):
+ self.logger(*args)
+
+def op_sequence(op, *classes):
+ """Return the sequence of operations that results from applying
+ the operation `op` to instances of the given classes."""
+ log = []
+ instances = []
+ for c in classes:
+ instances.append(c(log.append))
+
+ try:
+ op(*instances)
+ except TypeError:
+ pass
+ return log
+
+class A(OperationLogger):
+ def __eq__(self, other):
+ self.log_operation('A.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('A.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('A.__ge__')
+ return NotImplemented
+
+class B(OperationLogger):
+ def __eq__(self, other):
+ self.log_operation('B.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('B.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('B.__ge__')
+ return NotImplemented
+class C(B):
+ def __eq__(self, other):
+ self.log_operation('C.__eq__')
+ return NotImplemented
+ def __le__(self, other):
+ self.log_operation('C.__le__')
+ return NotImplemented
+ def __ge__(self, other):
+ self.log_operation('C.__ge__')
+ return NotImplemented
+
+class OperationOrderTests(unittest.TestCase):
+ def test_comparison_orders(self):
+ self.assertEqual(op_sequence(eq, A, A), ['A.__eq__', 'A.__eq__'])
+ self.assertEqual(op_sequence(eq, A, B), ['A.__eq__', 'B.__eq__'])
+ self.assertEqual(op_sequence(eq, B, A), ['B.__eq__', 'A.__eq__'])
+ # C is a subclass of B, so C.__eq__ is called first
+ self.assertEqual(op_sequence(eq, B, C), ['C.__eq__', 'B.__eq__'])
+ self.assertEqual(op_sequence(eq, C, B), ['C.__eq__', 'B.__eq__'])
+
+ self.assertEqual(op_sequence(le, A, A), ['A.__le__', 'A.__ge__'])
+ self.assertEqual(op_sequence(le, A, B), ['A.__le__', 'B.__ge__'])
+ self.assertEqual(op_sequence(le, B, A), ['B.__le__', 'A.__ge__'])
+ self.assertEqual(op_sequence(le, B, C), ['C.__ge__', 'B.__le__'])
+ self.assertEqual(op_sequence(le, C, B), ['C.__le__', 'B.__ge__'])
+
+def test_main():
+ support.run_unittest(RatTestCase, OperationOrderTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index 5c3330b4e41..f95ed635c3b 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -1,7 +1,7 @@
import sys
import unittest
-from test import test_support
-from UserList import UserList
+from test import support
+from collections import UserList
# We do a bit of trickery here to be able to test both the C implementation
# and the Python implementation of the module.
@@ -24,7 +24,7 @@ import bisect as c_bisect
class Range(object):
- """A trivial xrange()-like object without any integer width limitations."""
+ """A trivial range()-like object without any integer width limitations."""
def __init__(self, start, stop):
self.start = start
self.stop = stop
@@ -148,10 +148,7 @@ class TestBisect(unittest.TestCase):
# Issue 13496
mod = self.module
n = sys.maxsize
- try:
- data = xrange(n-1)
- except OverflowError:
- self.skipTest("can't create a xrange() object of size `sys.maxsize`")
+ data = range(n-1)
self.assertEqual(mod.bisect_left(data, n-3), n-3)
self.assertEqual(mod.bisect_right(data, n-3), n-2)
self.assertEqual(mod.bisect_left(data, n-3, n-10, n), n-3)
@@ -175,8 +172,8 @@ class TestBisect(unittest.TestCase):
def test_random(self, n=25):
from random import randrange
- for i in xrange(n):
- data = [randrange(0, n, 2) for j in xrange(i)]
+ for i in range(n):
+ data = [randrange(0, n, 2) for j in range(i)]
data.sort()
elem = randrange(-1, n+1)
ip = self.module.bisect_left(data, elem)
@@ -192,9 +189,9 @@ class TestBisect(unittest.TestCase):
def test_optionalSlicing(self):
for func, data, elem, expected in self.precomputedCases:
- for lo in xrange(4):
+ for lo in range(4):
lo = min(len(data), lo)
- for hi in xrange(3,8):
+ for hi in range(3,8):
hi = min(len(data), hi)
ip = func(data, elem, lo, hi)
self.assertTrue(lo <= ip <= hi)
@@ -235,7 +232,7 @@ class TestInsort(unittest.TestCase):
def test_vsBuiltinSort(self, n=500):
from random import choice
for insorted in (list(), UserList()):
- for i in xrange(n):
+ for i in range(n):
digit = choice("0123456789")
if digit in "02468":
f = self.module.insort_left
@@ -279,8 +276,13 @@ class GetOnly:
class CmpErr:
"Dummy element that always raises an error during comparison"
- def __cmp__(self, other):
+ def __lt__(self, other):
raise ZeroDivisionError
+ __gt__ = __lt__
+ __le__ = __lt__
+ __ge__ = __lt__
+ __eq__ = __lt__
+ __ne__ = __lt__
class TestErrorHandling(unittest.TestCase):
module = None
@@ -293,12 +295,12 @@ class TestErrorHandling(unittest.TestCase):
def test_len_only(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
- self.assertRaises(AttributeError, f, LenOnly(), 10)
+ self.assertRaises(TypeError, f, LenOnly(), 10)
def test_get_only(self):
for f in (self.module.bisect_left, self.module.bisect_right,
self.module.insort_left, self.module.insort_right):
- self.assertRaises(AttributeError, f, GetOnly(), 10)
+ self.assertRaises(TypeError, f, GetOnly(), 10)
def test_cmp_err(self):
seq = [CmpErr(), CmpErr(), CmpErr()]
@@ -335,7 +337,7 @@ This example uses bisect() to look up a letter grade for an exam total
...
>>> grade(66)
'C'
- >>> map(grade, [33, 99, 77, 44, 12, 88])
+ >>> list(map(grade, [33, 99, 77, 44, 12, 88]))
['E', 'A', 'B', 'D', 'F', 'A']
"""
@@ -351,18 +353,18 @@ def test_main(verbose=None):
TestInsortPython, TestInsortC,
TestErrorHandlingPython, TestErrorHandlingC]
- test_support.run_unittest(*test_classes)
- test_support.run_doctest(test_bisect, verbose)
+ support.run_unittest(*test_classes)
+ support.run_doctest(test_bisect, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_bool.py b/Lib/test/test_bool.py
index 16cd1aa1ff8..b296870b09b 100644
--- a/Lib/test/test_bool.py
+++ b/Lib/test/test_bool.py
@@ -1,7 +1,7 @@
# Test properties of bool promised by PEP 285
import unittest
-from test import test_support
+from test import support
import os
@@ -20,14 +20,14 @@ class BoolTest(unittest.TestCase):
def test_print(self):
try:
- fo = open(test_support.TESTFN, "wb")
- print >> fo, False, True
+ fo = open(support.TESTFN, "w")
+ print(False, True, file=fo)
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), 'False True\n')
finally:
fo.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_repr(self):
self.assertEqual(repr(False), 'False')
@@ -51,12 +51,6 @@ class BoolTest(unittest.TestCase):
self.assertEqual(float(True), 1.0)
self.assertIsNot(float(True), True)
- def test_long(self):
- self.assertEqual(long(False), 0L)
- self.assertIsNot(long(False), False)
- self.assertEqual(long(True), 1L)
- self.assertIsNot(long(True), True)
-
def test_math(self):
self.assertEqual(+False, 0)
self.assertIsNot(+False, False)
@@ -97,10 +91,10 @@ class BoolTest(unittest.TestCase):
self.assertEqual(False*1, 0)
self.assertIsNot(False*1, False)
- self.assertEqual(True//1, 1)
- self.assertIsNot(True//1, True)
- self.assertEqual(False//1, 0)
- self.assertIsNot(False//1, False)
+ self.assertEqual(True/1, 1)
+ self.assertIsNot(True/1, True)
+ self.assertEqual(False/1, 0)
+ self.assertIsNot(False/1, False)
for b in False, True:
for i in 0, 1, 2:
@@ -195,12 +189,9 @@ class BoolTest(unittest.TestCase):
self.assertIs(issubclass(bool, int), True)
self.assertIs(issubclass(int, bool), False)
- def test_haskey(self):
+ def test_contains(self):
self.assertIs(1 in {}, False)
self.assertIs(1 in {1:1}, True)
- with test_support.check_py3k_warnings():
- self.assertIs({}.has_key(1), False)
- self.assertIs({1:1}.has_key(1), True)
def test_string(self):
self.assertIs("xyz".endswith("z"), True)
@@ -213,7 +204,13 @@ class BoolTest(unittest.TestCase):
self.assertIs("xyz".isdigit(), False)
self.assertIs("xyz".islower(), True)
self.assertIs("XYZ".islower(), False)
+ self.assertIs("0123".isdecimal(), True)
+ self.assertIs("xyz".isdecimal(), False)
+ self.assertIs("0123".isnumeric(), True)
+ self.assertIs("xyz".isnumeric(), False)
self.assertIs(" ".isspace(), True)
+ self.assertIs("\xa0".isspace(), True)
+ self.assertIs("\u3000".isspace(), True)
self.assertIs("XYZ".isspace(), False)
self.assertIs("X".istitle(), True)
self.assertIs("x".istitle(), False)
@@ -222,30 +219,6 @@ class BoolTest(unittest.TestCase):
self.assertIs("xyz".startswith("x"), True)
self.assertIs("xyz".startswith("z"), False)
- if test_support.have_unicode:
- self.assertIs(unicode("xyz", 'ascii').endswith(unicode("z", 'ascii')), True)
- self.assertIs(unicode("xyz", 'ascii').endswith(unicode("x", 'ascii')), False)
- self.assertIs(unicode("xyz0123", 'ascii').isalnum(), True)
- self.assertIs(unicode("@#$%", 'ascii').isalnum(), False)
- self.assertIs(unicode("xyz", 'ascii').isalpha(), True)
- self.assertIs(unicode("@#$%", 'ascii').isalpha(), False)
- self.assertIs(unicode("0123", 'ascii').isdecimal(), True)
- self.assertIs(unicode("xyz", 'ascii').isdecimal(), False)
- self.assertIs(unicode("0123", 'ascii').isdigit(), True)
- self.assertIs(unicode("xyz", 'ascii').isdigit(), False)
- self.assertIs(unicode("xyz", 'ascii').islower(), True)
- self.assertIs(unicode("XYZ", 'ascii').islower(), False)
- self.assertIs(unicode("0123", 'ascii').isnumeric(), True)
- self.assertIs(unicode("xyz", 'ascii').isnumeric(), False)
- self.assertIs(unicode(" ", 'ascii').isspace(), True)
- self.assertIs(unicode("XYZ", 'ascii').isspace(), False)
- self.assertIs(unicode("X", 'ascii').istitle(), True)
- self.assertIs(unicode("x", 'ascii').istitle(), False)
- self.assertIs(unicode("XYZ", 'ascii').isupper(), True)
- self.assertIs(unicode("xyz", 'ascii').isupper(), False)
- self.assertIs(unicode("xyz", 'ascii').startswith(unicode("x", 'ascii')), True)
- self.assertIs(unicode("xyz", 'ascii').startswith(unicode("z", 'ascii')), False)
-
def test_boolean(self):
self.assertEqual(True & 1, 1)
self.assertNotIsInstance(True & 1, bool)
@@ -261,16 +234,16 @@ class BoolTest(unittest.TestCase):
def test_fileclosed(self):
try:
- f = file(test_support.TESTFN, "w")
+ f = open(support.TESTFN, "w")
self.assertIs(f.closed, False)
f.close()
self.assertIs(f.closed, True)
finally:
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_types(self):
# types are always true.
- for t in [bool, complex, dict, file, float, int, list, long, object,
+ for t in [bool, complex, dict, float, int, list, object,
set, str, tuple, type]:
self.assertIs(bool(t), True)
@@ -278,19 +251,10 @@ class BoolTest(unittest.TestCase):
import operator
self.assertIs(operator.truth(0), False)
self.assertIs(operator.truth(1), True)
- with test_support.check_py3k_warnings():
- self.assertIs(operator.isCallable(0), False)
- self.assertIs(operator.isCallable(len), True)
- self.assertIs(operator.isNumberType(None), False)
- self.assertIs(operator.isNumberType(0), True)
self.assertIs(operator.not_(1), False)
self.assertIs(operator.not_(0), True)
- self.assertIs(operator.isSequenceType(0), False)
- self.assertIs(operator.isSequenceType([]), True)
self.assertIs(operator.contains([], 1), False)
self.assertIs(operator.contains([1], 1), True)
- self.assertIs(operator.isMappingType(1), False)
- self.assertIs(operator.isMappingType({}), True)
self.assertIs(operator.lt(0, 0), False)
self.assertIs(operator.lt(0, 1), True)
self.assertIs(operator.is_(True, True), True)
@@ -310,61 +274,64 @@ class BoolTest(unittest.TestCase):
self.assertIs(pickle.loads(pickle.dumps(True, True)), True)
self.assertIs(pickle.loads(pickle.dumps(False, True)), False)
- def test_cpickle(self):
- import cPickle
- self.assertIs(cPickle.loads(cPickle.dumps(True)), True)
- self.assertIs(cPickle.loads(cPickle.dumps(False)), False)
- self.assertIs(cPickle.loads(cPickle.dumps(True, True)), True)
- self.assertIs(cPickle.loads(cPickle.dumps(False, True)), False)
-
- def test_mixedpickle(self):
- import pickle, cPickle
- self.assertIs(pickle.loads(cPickle.dumps(True)), True)
- self.assertIs(pickle.loads(cPickle.dumps(False)), False)
- self.assertIs(pickle.loads(cPickle.dumps(True, True)), True)
- self.assertIs(pickle.loads(cPickle.dumps(False, True)), False)
-
- self.assertIs(cPickle.loads(pickle.dumps(True)), True)
- self.assertIs(cPickle.loads(pickle.dumps(False)), False)
- self.assertIs(cPickle.loads(pickle.dumps(True, True)), True)
- self.assertIs(cPickle.loads(pickle.dumps(False, True)), False)
-
def test_picklevalues(self):
- import pickle, cPickle
-
# Test for specific backwards-compatible pickle values
- self.assertEqual(pickle.dumps(True), "I01\n.")
- self.assertEqual(pickle.dumps(False), "I00\n.")
- self.assertEqual(cPickle.dumps(True), "I01\n.")
- self.assertEqual(cPickle.dumps(False), "I00\n.")
- self.assertEqual(pickle.dumps(True, True), "I01\n.")
- self.assertEqual(pickle.dumps(False, True), "I00\n.")
- self.assertEqual(cPickle.dumps(True, True), "I01\n.")
- self.assertEqual(cPickle.dumps(False, True), "I00\n.")
+ import pickle
+ self.assertEqual(pickle.dumps(True, protocol=0), b"I01\n.")
+ self.assertEqual(pickle.dumps(False, protocol=0), b"I00\n.")
+ self.assertEqual(pickle.dumps(True, protocol=1), b"I01\n.")
+ self.assertEqual(pickle.dumps(False, protocol=1), b"I00\n.")
+ self.assertEqual(pickle.dumps(True, protocol=2), b'\x80\x02\x88.')
+ self.assertEqual(pickle.dumps(False, protocol=2), b'\x80\x02\x89.')
def test_convert_to_bool(self):
# Verify that TypeError occurs when bad things are returned
- # from __nonzero__(). This isn't really a bool test, but
+ # from __bool__(). This isn't really a bool test, but
# it's related.
check = lambda o: self.assertRaises(TypeError, bool, o)
class Foo(object):
- def __nonzero__(self):
+ def __bool__(self):
return self
check(Foo())
class Bar(object):
- def __nonzero__(self):
+ def __bool__(self):
return "Yes"
check(Bar())
class Baz(int):
- def __nonzero__(self):
+ def __bool__(self):
return self
check(Baz())
+ # __bool__() must return a bool not an int
+ class Spam(int):
+ def __bool__(self):
+ return 1
+ check(Spam())
+
+ class Eggs:
+ def __len__(self):
+ return -1
+ self.assertRaises(ValueError, bool, Eggs())
+
+ def test_sane_len(self):
+ # this test just tests our assumptions about __len__
+ # this will start failing if __len__ changes assertions
+ for badval in ['illegal', -1, 1 << 32]:
+ class A:
+ def __len__(self):
+ return badval
+ try:
+ bool(A())
+ except (Exception) as e_bool:
+ try:
+ len(A())
+ except (Exception) as e_len:
+ self.assertEqual(str(e_bool), str(e_len))
def test_main():
- test_support.run_unittest(BoolTest)
+ support.run_unittest(BoolTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
deleted file mode 100755
index d1ee0a14a96..00000000000
--- a/Lib/test/test_bsddb.py
+++ /dev/null
@@ -1,357 +0,0 @@
-#! /usr/bin/env python
-"""Test script for the bsddb C module by Roger E. Masse
- Adapted to unittest format and expanded scope by Raymond Hettinger
-"""
-import os, sys
-import unittest
-from test import test_support
-
-# Skip test if _bsddb wasn't built.
-test_support.import_module('_bsddb')
-
-bsddb = test_support.import_module('bsddb', deprecated=True)
-# Just so we know it's imported:
-test_support.import_module('dbhash', deprecated=True)
-
-
-class TestBSDDB(unittest.TestCase):
- openflag = 'c'
-
- def setUp(self):
- self.f = self.openmethod[0](self.fname, self.openflag, cachesize=32768)
- self.d = dict(q='Guido', w='van', e='Rossum', r='invented', t='Python', y='')
- for k, v in self.d.iteritems():
- self.f[k] = v
-
- def tearDown(self):
- self.f.sync()
- self.f.close()
- if self.fname is None:
- return
- try:
- os.remove(self.fname)
- except os.error:
- pass
-
- def test_getitem(self):
- for k, v in self.d.iteritems():
- self.assertEqual(self.f[k], v)
-
- def test_len(self):
- self.assertEqual(len(self.f), len(self.d))
-
- def test_change(self):
- self.f['r'] = 'discovered'
- self.assertEqual(self.f['r'], 'discovered')
- self.assertIn('r', self.f.keys())
- self.assertIn('discovered', self.f.values())
-
- def test_close_and_reopen(self):
- if self.fname is None:
- # if we're using an in-memory only db, we can't reopen it
- # so finish here.
- return
- self.f.close()
- self.f = self.openmethod[0](self.fname, 'w')
- for k, v in self.d.iteritems():
- self.assertEqual(self.f[k], v)
-
- def assertSetEquals(self, seqn1, seqn2):
- self.assertEqual(set(seqn1), set(seqn2))
-
- def test_mapping_iteration_methods(self):
- f = self.f
- d = self.d
- self.assertSetEquals(d, f)
- self.assertSetEquals(d.keys(), f.keys())
- self.assertSetEquals(d.values(), f.values())
- self.assertSetEquals(d.items(), f.items())
- self.assertSetEquals(d.iterkeys(), f.iterkeys())
- self.assertSetEquals(d.itervalues(), f.itervalues())
- self.assertSetEquals(d.iteritems(), f.iteritems())
-
- def test_iter_while_modifying_values(self):
- di = iter(self.d)
- while 1:
- try:
- key = di.next()
- self.d[key] = 'modified '+key
- except StopIteration:
- break
-
- # it should behave the same as a dict. modifying values
- # of existing keys should not break iteration. (adding
- # or removing keys should)
- loops_left = len(self.f)
- fi = iter(self.f)
- while 1:
- try:
- key = fi.next()
- self.f[key] = 'modified '+key
- loops_left -= 1
- except StopIteration:
- break
- self.assertEqual(loops_left, 0)
-
- self.test_mapping_iteration_methods()
-
- def test_iter_abort_on_changed_size(self):
- def DictIterAbort():
- di = iter(self.d)
- while 1:
- try:
- di.next()
- self.d['newkey'] = 'SPAM'
- except StopIteration:
- break
- self.assertRaises(RuntimeError, DictIterAbort)
-
- def DbIterAbort():
- fi = iter(self.f)
- while 1:
- try:
- fi.next()
- self.f['newkey'] = 'SPAM'
- except StopIteration:
- break
- self.assertRaises(RuntimeError, DbIterAbort)
-
- def test_iteritems_abort_on_changed_size(self):
- def DictIteritemsAbort():
- di = self.d.iteritems()
- while 1:
- try:
- di.next()
- self.d['newkey'] = 'SPAM'
- except StopIteration:
- break
- self.assertRaises(RuntimeError, DictIteritemsAbort)
-
- def DbIteritemsAbort():
- fi = self.f.iteritems()
- while 1:
- try:
- key, value = fi.next()
- del self.f[key]
- except StopIteration:
- break
- self.assertRaises(RuntimeError, DbIteritemsAbort)
-
- def test_iteritems_while_modifying_values(self):
- di = self.d.iteritems()
- while 1:
- try:
- k, v = di.next()
- self.d[k] = 'modified '+v
- except StopIteration:
- break
-
- # it should behave the same as a dict. modifying values
- # of existing keys should not break iteration. (adding
- # or removing keys should)
- loops_left = len(self.f)
- fi = self.f.iteritems()
- while 1:
- try:
- k, v = fi.next()
- self.f[k] = 'modified '+v
- loops_left -= 1
- except StopIteration:
- break
- self.assertEqual(loops_left, 0)
-
- self.test_mapping_iteration_methods()
-
- def test_first_next_looping(self):
- items = [self.f.first()]
- for i in xrange(1, len(self.f)):
- items.append(self.f.next())
- self.assertSetEquals(items, self.d.items())
-
- def test_previous_last_looping(self):
- items = [self.f.last()]
- for i in xrange(1, len(self.f)):
- items.append(self.f.previous())
- self.assertSetEquals(items, self.d.items())
-
- def test_first_while_deleting(self):
- # Test for bug 1725856
- self.assertTrue(len(self.d) >= 2, "test requires >=2 items")
- for _ in self.d:
- key = self.f.first()[0]
- del self.f[key]
- self.assertEqual([], self.f.items(), "expected empty db after test")
-
- def test_last_while_deleting(self):
- # Test for bug 1725856's evil twin
- self.assertTrue(len(self.d) >= 2, "test requires >=2 items")
- for _ in self.d:
- key = self.f.last()[0]
- del self.f[key]
- self.assertEqual([], self.f.items(), "expected empty db after test")
-
- def test_set_location(self):
- self.assertEqual(self.f.set_location('e'), ('e', self.d['e']))
-
- def test_contains(self):
- for k in self.d:
- self.assertIn(k, self.f)
- self.assertNotIn('not here', self.f)
-
- def test_has_key(self):
- for k in self.d:
- self.assertTrue(self.f.has_key(k))
- self.assertTrue(not self.f.has_key('not here'))
-
- def test_clear(self):
- self.f.clear()
- self.assertEqual(len(self.f), 0)
-
- def test__no_deadlock_first(self, debug=0):
- # do this so that testers can see what function we're in in
- # verbose mode when we deadlock.
- sys.stdout.flush()
-
- # in pybsddb's _DBWithCursor this causes an internal DBCursor
- # object is created. Other test_ methods in this class could
- # inadvertently cause the deadlock but an explicit test is needed.
- if debug: print "A"
- k,v = self.f.first()
- if debug: print "B", k
- self.f[k] = "deadlock. do not pass go. do not collect $200."
- if debug: print "C"
- # if the bsddb implementation leaves the DBCursor open during
- # the database write and locking+threading support is enabled
- # the cursor's read lock will deadlock the write lock request..
-
- # test the iterator interface
- if True:
- if debug: print "D"
- i = self.f.iteritems()
- k,v = i.next()
- if debug: print "E"
- self.f[k] = "please don't deadlock"
- if debug: print "F"
- while 1:
- try:
- k,v = i.next()
- except StopIteration:
- break
- if debug: print "F2"
-
- i = iter(self.f)
- if debug: print "G"
- while i:
- try:
- if debug: print "H"
- k = i.next()
- if debug: print "I"
- self.f[k] = "deadlocks-r-us"
- if debug: print "J"
- except StopIteration:
- i = None
- if debug: print "K"
-
- # test the legacy cursor interface mixed with writes
- self.assertIn(self.f.first()[0], self.d)
- k = self.f.next()[0]
- self.assertIn(k, self.d)
- self.f[k] = "be gone with ye deadlocks"
- self.assertTrue(self.f[k], "be gone with ye deadlocks")
-
- def test_for_cursor_memleak(self):
- # do the bsddb._DBWithCursor iterator internals leak cursors?
- nc1 = len(self.f._cursor_refs)
- # create iterator
- i = self.f.iteritems()
- nc2 = len(self.f._cursor_refs)
- # use the iterator (should run to the first yield, creating the cursor)
- k, v = i.next()
- nc3 = len(self.f._cursor_refs)
- # destroy the iterator; this should cause the weakref callback
- # to remove the cursor object from self.f._cursor_refs
- del i
- nc4 = len(self.f._cursor_refs)
-
- self.assertEqual(nc1, nc2)
- self.assertEqual(nc1, nc4)
- self.assertTrue(nc3 == nc1+1)
-
- def test_popitem(self):
- k, v = self.f.popitem()
- self.assertIn(k, self.d)
- self.assertIn(v, self.d.values())
- self.assertNotIn(k, self.f)
- self.assertEqual(len(self.d)-1, len(self.f))
-
- def test_pop(self):
- k = 'w'
- v = self.f.pop(k)
- self.assertEqual(v, self.d[k])
- self.assertNotIn(k, self.f)
- self.assertNotIn(v, self.f.values())
- self.assertEqual(len(self.d)-1, len(self.f))
-
- def test_get(self):
- self.assertEqual(self.f.get('NotHere'), None)
- self.assertEqual(self.f.get('NotHere', 'Default'), 'Default')
- self.assertEqual(self.f.get('q', 'Default'), self.d['q'])
-
- def test_setdefault(self):
- self.assertEqual(self.f.setdefault('new', 'dog'), 'dog')
- self.assertEqual(self.f.setdefault('r', 'cat'), self.d['r'])
-
- def test_update(self):
- new = dict(y='life', u='of', i='brian')
- self.f.update(new)
- self.d.update(new)
- for k, v in self.d.iteritems():
- self.assertEqual(self.f[k], v)
-
- def test_keyordering(self):
- if self.openmethod[0] is not bsddb.btopen:
- return
- keys = self.d.keys()
- keys.sort()
- self.assertEqual(self.f.first()[0], keys[0])
- self.assertEqual(self.f.next()[0], keys[1])
- self.assertEqual(self.f.last()[0], keys[-1])
- self.assertEqual(self.f.previous()[0], keys[-2])
- self.assertEqual(list(self.f), keys)
-
-class TestBTree(TestBSDDB):
- fname = test_support.TESTFN
- openmethod = [bsddb.btopen]
-
-class TestBTree_InMemory(TestBSDDB):
- fname = None
- openmethod = [bsddb.btopen]
-
-class TestBTree_InMemory_Truncate(TestBSDDB):
- fname = None
- openflag = 'n'
- openmethod = [bsddb.btopen]
-
-class TestHashTable(TestBSDDB):
- fname = test_support.TESTFN
- openmethod = [bsddb.hashopen]
-
-class TestHashTable_InMemory(TestBSDDB):
- fname = None
- openmethod = [bsddb.hashopen]
-
-## # (bsddb.rnopen,'Record Numbers'), 'put' for RECNO for bsddb 1.85
-## # appears broken... at least on
-## # Solaris Intel - rmasse 1/97
-
-def test_main(verbose=None):
- test_support.run_unittest(
- TestBTree,
- TestHashTable,
- TestBTree_InMemory,
- TestHashTable_InMemory,
- TestBTree_InMemory_Truncate,
- )
-
-if __name__ == "__main__":
- test_main(verbose=True)
diff --git a/Lib/test/test_bsddb185.py b/Lib/test/test_bsddb185.py
deleted file mode 100644
index 98102c14579..00000000000
--- a/Lib/test/test_bsddb185.py
+++ /dev/null
@@ -1,43 +0,0 @@
-"""Tests for the bsddb185 module.
-
-The file 185test.db found in Lib/test/ is for testing purposes with this
-testing suite.
-
-"""
-from test.test_support import run_unittest, findfile, import_module
-import unittest
-bsddb185 = import_module('bsddb185', deprecated=True)
-import anydbm
-import whichdb
-import os
-import tempfile
-import shutil
-
-class Bsddb185Tests(unittest.TestCase):
-
- def test_open_existing_hash(self):
- # Verify we can open a file known to be a hash v2 file
- db = bsddb185.hashopen(findfile("185test.db"))
- self.assertEqual(db["1"], "1")
- db.close()
-
- def test_whichdb(self):
- # Verify that whichdb correctly sniffs the known hash v2 file
- self.assertEqual(whichdb.whichdb(findfile("185test.db")), "bsddb185")
-
- def test_anydbm_create(self):
- # Verify that anydbm.open does *not* create a bsddb185 file
- tmpdir = tempfile.mkdtemp()
- try:
- dbfile = os.path.join(tmpdir, "foo.db")
- anydbm.open(dbfile, "c").close()
- ftype = whichdb.whichdb(dbfile)
- self.assertNotEqual(ftype, "bsddb185")
- finally:
- shutil.rmtree(tmpdir)
-
-def test_main():
- run_unittest(Bsddb185Tests)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_bsddb3.py b/Lib/test/test_bsddb3.py
deleted file mode 100644
index 099145b460a..00000000000
--- a/Lib/test/test_bsddb3.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# Test driver for bsddb package.
-"""
-Run all test cases.
-"""
-import os
-import sys
-import tempfile
-import time
-import unittest
-from test.test_support import requires, run_unittest, import_module
-
-# Skip test if _bsddb module was not built.
-import_module('_bsddb')
-# Silence Py3k warning
-import_module('bsddb', deprecated=True)
-
-# When running as a script instead of within the regrtest framework, skip the
-# requires test, since it's obvious we want to run them.
-if __name__ != '__main__':
- requires('bsddb')
-
-verbose = False
-if 'verbose' in sys.argv:
- verbose = True
- sys.argv.remove('verbose')
-
-if 'silent' in sys.argv: # take care of old flag, just in case
- verbose = False
- sys.argv.remove('silent')
-
-
-class TimingCheck(unittest.TestCase):
-
- """This class is not a real test. Its purpose is to print a message
- periodically when the test runs slowly. This will prevent the buildbots
- from timing out on slow machines."""
-
- # How much time in seconds before printing a 'Still working' message.
- # Since this is run at most once between each test module, use a smaller
- # interval than other tests.
- _PRINT_WORKING_MSG_INTERVAL = 4 * 60
-
- # next_time is used as a global variable that survives each instance.
- # This is necessary since a new instance will be created for each test.
- next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
-
- def testCheckElapsedTime(self):
- # Print still working message since these tests can be really slow.
- now = time.time()
- if self.next_time <= now:
- TimingCheck.next_time = now + self._PRINT_WORKING_MSG_INTERVAL
- sys.__stdout__.write(' test_bsddb3 still working, be patient...\n')
- sys.__stdout__.flush()
-
-
-# For invocation through regrtest
-def test_main():
- from bsddb import db
- from bsddb.test import test_all
- test_all.set_test_path_prefix(os.path.join(tempfile.gettempdir(),
- 'z-test_bsddb3-%s' %
- os.getpid()))
- # Please leave this print in, having this show up in the buildbots
- # makes diagnosing problems a lot easier.
- print >>sys.stderr, db.DB_VERSION_STRING
- print >>sys.stderr, 'Test path prefix: ', test_all.get_test_path_prefix()
- try:
- run_unittest(test_all.suite(module_prefix='bsddb.test.',
- timing_check=TimingCheck))
- finally:
- # The only reason to remove db_home is in case if there is an old
- # one lying around. This might be by a different user, so just
- # ignore errors. We should always make a unique name now.
- try:
- test_all.remove_test_path_directory()
- except:
- pass
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_buffer.py b/Lib/test/test_buffer.py
deleted file mode 100644
index 6bdc34d28ea..00000000000
--- a/Lib/test/test_buffer.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""Unit tests for buffer objects.
-
-For now, tests just new or changed functionality.
-
-"""
-
-import unittest
-from test import test_support
-
-class BufferTests(unittest.TestCase):
-
- def test_extended_getslice(self):
- # Test extended slicing by comparing with list slicing.
- s = "".join(chr(c) for c in list(range(255, -1, -1)))
- b = buffer(s)
- indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
- for start in indices:
- for stop in indices:
- # Skip step 0 (invalid)
- for step in indices[1:]:
- self.assertEqual(b[start:stop:step],
- s[start:stop:step])
-
-
-def test_main():
- with test_support.check_py3k_warnings(("buffer.. not supported",
- DeprecationWarning)):
- test_support.run_unittest(BufferTests)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_bufio.py b/Lib/test/test_bufio.py
index 108b1e18696..5ab6f5a0da4 100644
--- a/Lib/test/test_bufio.py
+++ b/Lib/test/test_bufio.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support as support
+from test import support
import io # C implementation.
import _pyio as pyio # Python implementation.
@@ -68,12 +68,9 @@ class CBufferSizeTest(BufferSizeTest):
class PyBufferSizeTest(BufferSizeTest):
open = staticmethod(pyio.open)
-class BuiltinBufferSizeTest(BufferSizeTest):
- open = open
-
def test_main():
- support.run_unittest(CBufferSizeTest, PyBufferSizeTest, BuiltinBufferSizeTest)
+ support.run_unittest(CBufferSizeTest, PyBufferSizeTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py
index d75c44afbba..dab56cefd82 100644
--- a/Lib/test/test_builtin.py
+++ b/Lib/test/test_builtin.py
@@ -2,17 +2,23 @@
import platform
import unittest
-from test.test_support import fcmp, have_unicode, TESTFN, unlink, \
- run_unittest, check_py3k_warnings
+import sys
import warnings
+import collections
+import io
+import os
+import ast
+import types
+import builtins
+import random
+import traceback
+from test.support import fcmp, TESTFN, unlink, run_unittest, check_warnings
from operator import neg
+try:
+ import pty, signal
+except ImportError:
+ pty = signal = None
-import sys, cStringIO, random, UserDict
-
-# count the number of test runs.
-# used to skip running test_execfile() multiple times
-# and to create unique strings to intern in test_intern()
-numruns = 0
class Squares:
@@ -52,9 +58,52 @@ class BitBucket:
def write(self, line):
pass
+test_conv_no_sign = [
+ ('0', 0),
+ ('1', 1),
+ ('9', 9),
+ ('10', 10),
+ ('99', 99),
+ ('100', 100),
+ ('314', 314),
+ (' 314', 314),
+ ('314 ', 314),
+ (' \t\t 314 \t\t ', 314),
+ (repr(sys.maxsize), sys.maxsize),
+ (' 1x', ValueError),
+ (' 1 ', 1),
+ (' 1\02 ', ValueError),
+ ('', ValueError),
+ (' ', ValueError),
+ (' \t\t ', ValueError),
+ (str(b'\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
+ (chr(0x200), ValueError),
+]
+
+test_conv_sign = [
+ ('0', 0),
+ ('1', 1),
+ ('9', 9),
+ ('10', 10),
+ ('99', 99),
+ ('100', 100),
+ ('314', 314),
+ (' 314', ValueError),
+ ('314 ', 314),
+ (' \t\t 314 \t\t ', ValueError),
+ (repr(sys.maxsize), sys.maxsize),
+ (' 1x', ValueError),
+ (' 1 ', ValueError),
+ (' 1\02 ', ValueError),
+ ('', ValueError),
+ (' ', ValueError),
+ (' \t\t ', ValueError),
+ (str(b'\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
+ (chr(0x200), ValueError),
+]
class TestFailingBool:
- def __nonzero__(self):
+ def __bool__(self):
raise RuntimeError
class TestFailingIter:
@@ -79,15 +128,11 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(abs(0), 0)
self.assertEqual(abs(1234), 1234)
self.assertEqual(abs(-1234), 1234)
- self.assertTrue(abs(-sys.maxint-1) > 0)
+ self.assertTrue(abs(-sys.maxsize-1) > 0)
# float
self.assertEqual(abs(0.0), 0.0)
self.assertEqual(abs(3.14), 3.14)
self.assertEqual(abs(-3.14), 3.14)
- # long
- self.assertEqual(abs(0L), 0L)
- self.assertEqual(abs(1234L), 1234L)
- self.assertEqual(abs(-1234L), 1234L)
# str
self.assertRaises(TypeError, abs, 'a')
# bool
@@ -129,36 +174,45 @@ class BuiltinTest(unittest.TestCase):
S = [10, 20, 30]
self.assertEqual(any(x > 42 for x in S), False)
+ def test_ascii(self):
+ self.assertEqual(ascii(''), '\'\'')
+ self.assertEqual(ascii(0), '0')
+ self.assertEqual(ascii(()), '()')
+ self.assertEqual(ascii([]), '[]')
+ self.assertEqual(ascii({}), '{}')
+ a = []
+ a.append(a)
+ self.assertEqual(ascii(a), '[[...]]')
+ a = {}
+ a[0] = a
+ self.assertEqual(ascii(a), '{0: {...}}')
+ # Advanced checks for unicode strings
+ def _check_uni(s):
+ self.assertEqual(ascii(s), repr(s))
+ _check_uni("'")
+ _check_uni('"')
+ _check_uni('"\'')
+ _check_uni('\0')
+ _check_uni('\r\n\t .')
+ # Unprintable non-ASCII characters
+ _check_uni('\x85')
+ _check_uni('\u1fff')
+ _check_uni('\U00012fff')
+ # Lone surrogates
+ _check_uni('\ud800')
+ _check_uni('\udfff')
+ # Issue #9804: surrogates should be joined even for printable
+ # wide characters (UCS-2 builds).
+ self.assertEqual(ascii('\U0001d121'), "'\\U0001d121'")
+ # All together
+ s = "'\0\"\n\r\t abcd\x85é\U00012fff\uD800\U0001D121xxx."
+ self.assertEqual(ascii(s),
+ r"""'\'\x00"\n\r\t abcd\x85\xe9\U00012fff\ud800\U0001d121xxx.'""")
+
def test_neg(self):
- x = -sys.maxint-1
+ x = -sys.maxsize-1
self.assertTrue(isinstance(x, int))
- self.assertEqual(-x, sys.maxint+1)
-
- def test_apply(self):
- def f0(*args):
- self.assertEqual(args, ())
- def f1(a1):
- self.assertEqual(a1, 1)
- def f2(a1, a2):
- self.assertEqual(a1, 1)
- self.assertEqual(a2, 2)
- def f3(a1, a2, a3):
- self.assertEqual(a1, 1)
- self.assertEqual(a2, 2)
- self.assertEqual(a3, 3)
- apply(f0, ())
- apply(f1, (1,))
- apply(f2, (1, 2))
- apply(f3, (1, 2, 3))
-
- # A PyCFunction that takes only positional parameters should allow an
- # empty keyword dictionary to pass without a complaint, but raise a
- # TypeError if the dictionary is non-empty.
- apply(id, (1,), {})
- self.assertRaises(TypeError, apply, id, (1,), {"foo": 1})
- self.assertRaises(TypeError, apply)
- self.assertRaises(TypeError, apply, id, 42)
- self.assertRaises(TypeError, apply, id, (42,), 42)
+ self.assertEqual(-x, sys.maxsize+1)
def test_callable(self):
self.assertTrue(callable(len))
@@ -169,95 +223,104 @@ class BuiltinTest(unittest.TestCase):
def f(): pass
self.assertTrue(callable(f))
- class Classic:
+ class C1:
def meth(self): pass
- self.assertTrue(callable(Classic))
- c = Classic()
+ self.assertTrue(callable(C1))
+ c = C1()
self.assertTrue(callable(c.meth))
self.assertFalse(callable(c))
- class NewStyle(object):
- def meth(self): pass
- self.assertTrue(callable(NewStyle))
- n = NewStyle()
- self.assertTrue(callable(n.meth))
- self.assertFalse(callable(n))
-
- # Classic and new-style classes evaluate __call__() differently
+ # __call__ is looked up on the class, not the instance
c.__call__ = None
- self.assertTrue(callable(c))
+ self.assertFalse(callable(c))
+ c.__call__ = lambda self: 0
+ self.assertFalse(callable(c))
del c.__call__
self.assertFalse(callable(c))
- n.__call__ = None
- self.assertFalse(callable(n))
- del n.__call__
- self.assertFalse(callable(n))
- class N2(object):
+ class C2(object):
def __call__(self): pass
- n2 = N2()
- self.assertTrue(callable(n2))
- class N3(N2): pass
- n3 = N3()
- self.assertTrue(callable(n3))
+ c2 = C2()
+ self.assertTrue(callable(c2))
+ c2.__call__ = None
+ self.assertTrue(callable(c2))
+ class C3(C2): pass
+ c3 = C3()
+ self.assertTrue(callable(c3))
def test_chr(self):
self.assertEqual(chr(32), ' ')
self.assertEqual(chr(65), 'A')
self.assertEqual(chr(97), 'a')
self.assertEqual(chr(0xff), '\xff')
- self.assertRaises(ValueError, chr, 256)
+ self.assertRaises(ValueError, chr, 1<<24)
+ self.assertEqual(chr(sys.maxunicode),
+ str(('\\U%08x' % (sys.maxunicode)).encode("ascii"),
+ 'unicode-escape'))
self.assertRaises(TypeError, chr)
+ self.assertEqual(chr(0x0000FFFF), "\U0000FFFF")
+ self.assertEqual(chr(0x00010000), "\U00010000")
+ self.assertEqual(chr(0x00010001), "\U00010001")
+ self.assertEqual(chr(0x000FFFFE), "\U000FFFFE")
+ self.assertEqual(chr(0x000FFFFF), "\U000FFFFF")
+ self.assertEqual(chr(0x00100000), "\U00100000")
+ self.assertEqual(chr(0x00100001), "\U00100001")
+ self.assertEqual(chr(0x0010FFFE), "\U0010FFFE")
+ self.assertEqual(chr(0x0010FFFF), "\U0010FFFF")
+ self.assertRaises(ValueError, chr, -1)
+ self.assertRaises(ValueError, chr, 0x00110000)
+ self.assertRaises((OverflowError, ValueError), chr, 2**32)
def test_cmp(self):
- self.assertEqual(cmp(-1, 1), -1)
- self.assertEqual(cmp(1, -1), 1)
- self.assertEqual(cmp(1, 1), 0)
- # verify that circular objects are not handled
- a = []; a.append(a)
- b = []; b.append(b)
- from UserList import UserList
- c = UserList(); c.append(c)
- self.assertRaises(RuntimeError, cmp, a, b)
- self.assertRaises(RuntimeError, cmp, b, c)
- self.assertRaises(RuntimeError, cmp, c, a)
- self.assertRaises(RuntimeError, cmp, a, c)
- # okay, now break the cycles
- a.pop(); b.pop(); c.pop()
- self.assertRaises(TypeError, cmp)
-
- def test_coerce(self):
- self.assertTrue(not fcmp(coerce(1, 1.1), (1.0, 1.1)))
- self.assertEqual(coerce(1, 1L), (1L, 1L))
- self.assertTrue(not fcmp(coerce(1L, 1.1), (1.0, 1.1)))
- self.assertRaises(TypeError, coerce)
- class BadNumber:
- def __coerce__(self, other):
- raise ValueError
- self.assertRaises(ValueError, coerce, 42, BadNumber())
- self.assertRaises(OverflowError, coerce, 0.5, int("12345" * 1000))
+ self.assertTrue(not hasattr(builtins, "cmp"))
def test_compile(self):
- compile('print 1\n', '', 'exec')
- bom = '\xef\xbb\xbf'
- compile(bom + 'print 1\n', '', 'exec')
+ compile('print(1)\n', '', 'exec')
+ bom = b'\xef\xbb\xbf'
+ compile(bom + b'print(1)\n', '', 'exec')
compile(source='pass', filename='?', mode='exec')
compile(dont_inherit=0, filename='tmp', source='0', mode='eval')
compile('pass', '?', dont_inherit=1, mode='exec')
+ compile(memoryview(b"text"), "name", "exec")
self.assertRaises(TypeError, compile)
- self.assertRaises(ValueError, compile, 'print 42\n', '<string>', 'badmode')
- self.assertRaises(ValueError, compile, 'print 42\n', '<string>', 'single', 0xff)
+ self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'badmode')
+ self.assertRaises(ValueError, compile, 'print(42)\n', '<string>', 'single', 0xff)
self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
self.assertRaises(TypeError, compile, 'pass', '?', 'exec',
mode='eval', source='0', filename='tmp')
- if have_unicode:
- compile(unicode('print u"\xc3\xa5"\n', 'utf8'), '', 'exec')
- self.assertRaises(TypeError, compile, unichr(0), 'f', 'exec')
- self.assertRaises(ValueError, compile, unicode('a = 1'), 'f', 'bad')
+ compile('print("\xe5")\n', '', 'exec')
+ self.assertRaises(TypeError, compile, chr(0), 'f', 'exec')
+ self.assertRaises(ValueError, compile, str('a = 1'), 'f', 'bad')
+ # test the optimize argument
+
+ codestr = '''def f():
+ """doc"""
+ try:
+ assert False
+ except AssertionError:
+ return (True, f.__doc__)
+ else:
+ return (False, f.__doc__)
+ '''
+ def f(): """doc"""
+ values = [(-1, __debug__, f.__doc__),
+ (0, True, 'doc'),
+ (1, False, 'doc'),
+ (2, False, None)]
+ for optval, debugval, docstring in values:
+ # test both direct compilation and compilation via AST
+ codeobjs = []
+ codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
+ tree = ast.parse(codestr)
+ codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
+ for code in codeobjs:
+ ns = {}
+ exec(code, ns)
+ rv = ns['f']()
+ self.assertEqual(rv, (debugval, docstring))
def test_delattr(self):
- import sys
sys.spam = 1
delattr(sys, 'spam')
self.assertRaises(TypeError, delattr)
@@ -271,11 +334,9 @@ class BuiltinTest(unittest.TestCase):
self.assertIn('local_var', dir())
# dir(module)
- import sys
self.assertIn('exit', dir(sys))
# dir(module_with_invalid__dict__)
- import types
class Foo(types.ModuleType):
__dict__ = 8
f = Foo("foo")
@@ -324,24 +385,20 @@ class BuiltinTest(unittest.TestCase):
f = Foo()
self.assertRaises(TypeError, dir, f)
+ # dir(traceback)
+ try:
+ raise IndexError
+ except:
+ self.assertEqual(len(dir(sys.exc_info()[2])), 4)
+
+
def test_divmod(self):
self.assertEqual(divmod(12, 7), (1, 5))
self.assertEqual(divmod(-12, 7), (-2, 2))
self.assertEqual(divmod(12, -7), (-2, -2))
self.assertEqual(divmod(-12, -7), (1, -5))
- self.assertEqual(divmod(12L, 7L), (1L, 5L))
- self.assertEqual(divmod(-12L, 7L), (-2L, 2L))
- self.assertEqual(divmod(12L, -7L), (-2L, -2L))
- self.assertEqual(divmod(-12L, -7L), (1L, -5L))
-
- self.assertEqual(divmod(12, 7L), (1, 5L))
- self.assertEqual(divmod(-12, 7L), (-2, 2L))
- self.assertEqual(divmod(12L, -7), (-2L, -2))
- self.assertEqual(divmod(-12L, -7), (1L, -5))
-
- self.assertEqual(divmod(-sys.maxint-1, -1),
- (sys.maxint+1, 0))
+ self.assertEqual(divmod(-sys.maxsize-1, -1), (sys.maxsize+1, 0))
self.assertTrue(not fcmp(divmod(3.25, 1.0), (3.0, 0.25)))
self.assertTrue(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75)))
@@ -359,22 +416,14 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(eval('a', globals, locals), 1)
self.assertEqual(eval('b', globals, locals), 200)
self.assertEqual(eval('c', globals, locals), 300)
- if have_unicode:
- self.assertEqual(eval(unicode('1+1')), 2)
- self.assertEqual(eval(unicode(' 1+1\n')), 2)
globals = {'a': 1, 'b': 2}
locals = {'b': 200, 'c': 300}
- if have_unicode:
- self.assertEqual(eval(unicode('a'), globals), 1)
- self.assertEqual(eval(unicode('a'), globals, locals), 1)
- self.assertEqual(eval(unicode('b'), globals, locals), 200)
- self.assertEqual(eval(unicode('c'), globals, locals), 300)
- bom = '\xef\xbb\xbf'
- self.assertEqual(eval(bom + 'a', globals, locals), 1)
- self.assertEqual(eval(unicode('u"\xc3\xa5"', 'utf8'), globals),
- unicode('\xc3\xa5', 'utf8'))
+ bom = b'\xef\xbb\xbf'
+ self.assertEqual(eval(bom + b'a', globals, locals), 1)
+ self.assertEqual(eval('"\xe5"', globals), "\xe5")
self.assertRaises(TypeError, eval)
self.assertRaises(TypeError, eval, ())
+ self.assertRaises(SyntaxError, eval, bom[:2] + b'a')
def test_general_eval(self):
# Tests that general mappings can be used for the locals argument
@@ -420,7 +469,7 @@ class BuiltinTest(unittest.TestCase):
# Verify locals stores (used by list comps)
eval('[locals() for i in (2,3)]', g, d)
- eval('[locals() for i in (2,3)]', g, UserDict.UserDict())
+ eval('[locals() for i in (2,3)]', g, collections.UserDict())
class SpreadSheet:
"Sample application showing nested, calculated lookups."
@@ -442,68 +491,50 @@ class BuiltinTest(unittest.TestCase):
def __getitem__(self, item):
raise KeyError(item)
def keys(self):
- return 'a'
+ return 1 # used to be 'a' but that's no longer an error
self.assertRaises(TypeError, eval, 'dir()', globals(), C())
- # Done outside of the method test_z to get the correct scope
- z = 0
- f = open(TESTFN, 'w')
- f.write('z = z+1\n')
- f.write('z = z*2\n')
- f.close()
- with check_py3k_warnings(("execfile.. not supported in 3.x",
- DeprecationWarning)):
- execfile(TESTFN)
-
- def test_execfile(self):
- global numruns
- if numruns:
- return
- numruns += 1
-
- globals = {'a': 1, 'b': 2}
- locals = {'b': 200, 'c': 300}
-
- self.assertEqual(self.__class__.z, 2)
- globals['z'] = 0
- execfile(TESTFN, globals)
- self.assertEqual(globals['z'], 2)
- locals['z'] = 0
- execfile(TESTFN, globals, locals)
- self.assertEqual(locals['z'], 2)
-
- class M:
- "Test mapping interface versus possible calls from execfile()."
- def __init__(self):
- self.z = 10
- def __getitem__(self, key):
- if key == 'z':
- return self.z
- raise KeyError
- def __setitem__(self, key, value):
- if key == 'z':
- self.z = value
- return
- raise KeyError
-
- locals = M()
- locals['z'] = 0
- execfile(TESTFN, globals, locals)
- self.assertEqual(locals['z'], 2)
-
- unlink(TESTFN)
- self.assertRaises(TypeError, execfile)
- self.assertRaises(TypeError, execfile, TESTFN, {}, ())
- import os
- self.assertRaises(IOError, execfile, os.curdir)
- self.assertRaises(IOError, execfile, "I_dont_exist")
+ def test_exec(self):
+ g = {}
+ exec('z = 1', g)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ self.assertEqual(g, {'z': 1})
+
+ exec('z = 1+1', g)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ self.assertEqual(g, {'z': 2})
+ g = {}
+ l = {}
+
+ with check_warnings():
+ warnings.filterwarnings("ignore", "global statement",
+ module="<string>")
+ exec('global a; a = 1; b = 2', g, l)
+ if '__builtins__' in g:
+ del g['__builtins__']
+ if '__builtins__' in l:
+ del l['__builtins__']
+ self.assertEqual((g, l), ({'a': 1}, {'b': 2}))
+
+ def test_exec_redirected(self):
+ savestdout = sys.stdout
+ sys.stdout = None # Whatever that cannot flush()
+ try:
+ # Used to raise SystemError('error return without exception set')
+ exec('a')
+ except NameError:
+ pass
+ finally:
+ sys.stdout = savestdout
def test_filter(self):
- self.assertEqual(filter(lambda c: 'a' <= c <= 'z', 'Hello World'), 'elloorld')
- self.assertEqual(filter(None, [1, 'hello', [], [3], '', None, 9, 0]), [1, 'hello', [3], 9])
- self.assertEqual(filter(lambda x: x > 0, [1, -3, 9, 0, 2]), [1, 9, 2])
- self.assertEqual(filter(None, Squares(10)), [1, 4, 9, 16, 25, 36, 49, 64, 81])
- self.assertEqual(filter(lambda x: x%2, Squares(10)), [1, 9, 25, 49, 81])
+ self.assertEqual(list(filter(lambda c: 'a' <= c <= 'z', 'Hello World')), list('elloorld'))
+ self.assertEqual(list(filter(None, [1, 'hello', [], [3], '', None, 9, 0])), [1, 'hello', [3], 9])
+ self.assertEqual(list(filter(lambda x: x > 0, [1, -3, 9, 0, 2])), [1, 9, 2])
+ self.assertEqual(list(filter(None, Squares(10))), [1, 4, 9, 16, 25, 36, 49, 64, 81])
+ self.assertEqual(list(filter(lambda x: x%2, Squares(10))), [1, 9, 25, 49, 81])
def identity(item):
return 1
filter(identity, Squares(5))
@@ -513,136 +544,48 @@ class BuiltinTest(unittest.TestCase):
if index<4:
return 42
raise ValueError
- self.assertRaises(ValueError, filter, lambda x: x, BadSeq())
+ self.assertRaises(ValueError, list, filter(lambda x: x, BadSeq()))
def badfunc():
pass
- self.assertRaises(TypeError, filter, badfunc, range(5))
+ self.assertRaises(TypeError, list, filter(badfunc, range(5)))
# test bltinmodule.c::filtertuple()
- self.assertEqual(filter(None, (1, 2)), (1, 2))
- self.assertEqual(filter(lambda x: x>=3, (1, 2, 3, 4)), (3, 4))
- self.assertRaises(TypeError, filter, 42, (1, 2))
-
- # test bltinmodule.c::filterstring()
- self.assertEqual(filter(None, "12"), "12")
- self.assertEqual(filter(lambda x: x>="3", "1234"), "34")
- self.assertRaises(TypeError, filter, 42, "12")
- class badstr(str):
- def __getitem__(self, index):
- raise ValueError
- self.assertRaises(ValueError, filter, lambda x: x >="3", badstr("1234"))
-
- class badstr2(str):
- def __getitem__(self, index):
- return 42
- self.assertRaises(TypeError, filter, lambda x: x >=42, badstr2("1234"))
-
- class weirdstr(str):
- def __getitem__(self, index):
- return weirdstr(2*str.__getitem__(self, index))
- self.assertEqual(filter(lambda x: x>="33", weirdstr("1234")), "3344")
-
- class shiftstr(str):
- def __getitem__(self, index):
- return chr(ord(str.__getitem__(self, index))+1)
- self.assertEqual(filter(lambda x: x>="3", shiftstr("1234")), "345")
-
- if have_unicode:
- # test bltinmodule.c::filterunicode()
- self.assertEqual(filter(None, unicode("12")), unicode("12"))
- self.assertEqual(filter(lambda x: x>="3", unicode("1234")), unicode("34"))
- self.assertRaises(TypeError, filter, 42, unicode("12"))
- self.assertRaises(ValueError, filter, lambda x: x >="3", badstr(unicode("1234")))
-
- class badunicode(unicode):
- def __getitem__(self, index):
- return 42
- self.assertRaises(TypeError, filter, lambda x: x >=42, badunicode("1234"))
-
- class weirdunicode(unicode):
- def __getitem__(self, index):
- return weirdunicode(2*unicode.__getitem__(self, index))
- self.assertEqual(
- filter(lambda x: x>=unicode("33"), weirdunicode("1234")), unicode("3344"))
-
- class shiftunicode(unicode):
- def __getitem__(self, index):
- return unichr(ord(unicode.__getitem__(self, index))+1)
- self.assertEqual(
- filter(lambda x: x>=unicode("3"), shiftunicode("1234")),
- unicode("345")
- )
-
- def test_filter_subclasses(self):
- # test that filter() never returns tuple, str or unicode subclasses
- # and that the result always goes through __getitem__
- funcs = (None, bool, lambda x: True)
- class tuple2(tuple):
- def __getitem__(self, index):
- return 2*tuple.__getitem__(self, index)
- class str2(str):
- def __getitem__(self, index):
- return 2*str.__getitem__(self, index)
- inputs = {
- tuple2: {(): (), (1, 2, 3): (2, 4, 6)},
- str2: {"": "", "123": "112233"}
- }
- if have_unicode:
- class unicode2(unicode):
- def __getitem__(self, index):
- return 2*unicode.__getitem__(self, index)
- inputs[unicode2] = {
- unicode(): unicode(),
- unicode("123"): unicode("112233")
- }
-
- for (cls, inps) in inputs.iteritems():
- for (inp, exp) in inps.iteritems():
- # make sure the output goes through __getitem__
- # even if func is None
- self.assertEqual(
- filter(funcs[0], cls(inp)),
- filter(funcs[1], cls(inp))
- )
- for func in funcs:
- outp = filter(func, cls(inp))
- self.assertEqual(outp, exp)
- self.assertTrue(not isinstance(outp, cls))
+ self.assertEqual(list(filter(None, (1, 2))), [1, 2])
+ self.assertEqual(list(filter(lambda x: x>=3, (1, 2, 3, 4))), [3, 4])
+ self.assertRaises(TypeError, list, filter(42, (1, 2)))
def test_getattr(self):
- import sys
self.assertTrue(getattr(sys, 'stdout') is sys.stdout)
self.assertRaises(TypeError, getattr, sys, 1)
self.assertRaises(TypeError, getattr, sys, 1, "foo")
self.assertRaises(TypeError, getattr)
- if have_unicode:
- self.assertRaises(UnicodeError, getattr, sys, unichr(sys.maxunicode))
+ self.assertRaises(AttributeError, getattr, sys, chr(sys.maxunicode))
+ # unicode surrogates are not encodable to the default encoding (utf8)
+ self.assertRaises(AttributeError, getattr, 1, "\uDAD1\uD51E")
def test_hasattr(self):
- import sys
self.assertTrue(hasattr(sys, 'stdout'))
self.assertRaises(TypeError, hasattr, sys, 1)
self.assertRaises(TypeError, hasattr)
- if have_unicode:
- self.assertRaises(UnicodeError, hasattr, sys, unichr(sys.maxunicode))
+ self.assertEqual(False, hasattr(sys, chr(sys.maxunicode)))
- # Check that hasattr allows SystemExit and KeyboardInterrupts by
+ # Check that hasattr propagates all exceptions outside of
+ # AttributeError.
class A:
def __getattr__(self, what):
- raise KeyboardInterrupt
- self.assertRaises(KeyboardInterrupt, hasattr, A(), "b")
+ raise SystemExit
+ self.assertRaises(SystemExit, hasattr, A(), "b")
class B:
def __getattr__(self, what):
- raise SystemExit
- self.assertRaises(SystemExit, hasattr, B(), "b")
+ raise ValueError
+ self.assertRaises(ValueError, hasattr, B(), "b")
def test_hash(self):
hash(None)
- self.assertEqual(hash(1), hash(1L))
+ self.assertEqual(hash(1), hash(1))
self.assertEqual(hash(1), hash(1.0))
hash('spam')
- if have_unicode:
- self.assertEqual(hash('spam'), hash(unicode('spam')))
+ self.assertEqual(hash('spam'), hash(b'spam'))
hash((0,1,2,3))
def f(): pass
self.assertRaises(TypeError, hash, [])
@@ -652,73 +595,36 @@ class BuiltinTest(unittest.TestCase):
def __hash__(self):
return 2**100
self.assertEqual(type(hash(X())), int)
- class Y(object):
- def __hash__(self):
- return 2**100
- self.assertEqual(type(hash(Y())), int)
- class Z(long):
+ class Z(int):
def __hash__(self):
return self
- self.assertEqual(hash(Z(42)), hash(42L))
+ self.assertEqual(hash(Z(42)), hash(42))
def test_hex(self):
self.assertEqual(hex(16), '0x10')
- self.assertEqual(hex(16L), '0x10L')
self.assertEqual(hex(-16), '-0x10')
- self.assertEqual(hex(-16L), '-0x10L')
self.assertRaises(TypeError, hex, {})
def test_id(self):
id(None)
id(1)
- id(1L)
id(1.0)
id('spam')
id((0,1,2,3))
id([0,1,2,3])
id({'spam': 1, 'eggs': 2, 'ham': 3})
- # Test input() later, together with raw_input
-
- # test_int(): see test_int.py for int() tests.
-
- def test_intern(self):
- self.assertRaises(TypeError, intern)
- # This fails if the test is run twice with a constant string,
- # therefore append the run counter
- s = "never interned before " + str(numruns)
- self.assertTrue(intern(s) is s)
- s2 = s.swapcase().swapcase()
- self.assertTrue(intern(s2) is s)
-
- # Subclasses of string can't be interned, because they
- # provide too much opportunity for insane things to happen.
- # We don't want them in the interned dict and if they aren't
- # actually interned, we don't want to create the appearance
- # that they are by allowing intern() to succeed.
- class S(str):
- def __hash__(self):
- return 123
-
- self.assertRaises(TypeError, intern, S("abc"))
-
- # It's still safe to pass these strings to routines that
- # call intern internally, e.g. PyObject_SetAttr().
- s = S("abc")
- setattr(s, s, s)
- self.assertEqual(getattr(s, s), s)
+ # Test input() later, alphabetized as if it were raw_input
def test_iter(self):
self.assertRaises(TypeError, iter)
self.assertRaises(TypeError, iter, 42, 42)
lists = [("1", "2"), ["1", "2"], "12"]
- if have_unicode:
- lists.append(unicode("12"))
for l in lists:
i = iter(l)
- self.assertEqual(i.next(), '1')
- self.assertEqual(i.next(), '2')
- self.assertRaises(StopIteration, i.next)
+ self.assertEqual(next(i), '1')
+ self.assertEqual(next(i), '2')
+ self.assertRaises(StopIteration, next, i)
def test_isinstance(self):
class C:
@@ -766,27 +672,24 @@ class BuiltinTest(unittest.TestCase):
def __len__(self):
raise ValueError
self.assertRaises(ValueError, len, BadSeq())
- self.assertRaises(TypeError, len, 2)
- class ClassicStyle: pass
- class NewStyle(object): pass
- self.assertRaises(AttributeError, len, ClassicStyle())
- self.assertRaises(TypeError, len, NewStyle())
+ class InvalidLen:
+ def __len__(self):
+ return None
+ self.assertRaises(TypeError, len, InvalidLen())
+ class FloatLen:
+ def __len__(self):
+ return 4.5
+ self.assertRaises(TypeError, len, FloatLen())
+ class HugeLen:
+ def __len__(self):
+ return sys.maxsize + 1
+ self.assertRaises(OverflowError, len, HugeLen())
+ class NoLenMethod(object): pass
+ self.assertRaises(TypeError, len, NoLenMethod())
def test_map(self):
self.assertEqual(
- map(None, 'hello world'),
- ['h','e','l','l','o',' ','w','o','r','l','d']
- )
- self.assertEqual(
- map(None, 'abcd', 'efg'),
- [('a', 'e'), ('b', 'f'), ('c', 'g'), ('d', None)]
- )
- self.assertEqual(
- map(None, range(10)),
- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
- )
- self.assertEqual(
- map(lambda x: x*x, range(1,4)),
+ list(map(lambda x: x*x, range(1,4))),
[1, 4, 9]
)
try:
@@ -795,11 +698,11 @@ class BuiltinTest(unittest.TestCase):
def sqrt(x):
return pow(x, 0.5)
self.assertEqual(
- map(lambda x: map(sqrt,x), [[16, 4], [81, 9]]),
+ list(map(lambda x: list(map(sqrt, x)), [[16, 4], [81, 9]])),
[[4.0, 2.0], [9.0, 3.0]]
)
self.assertEqual(
- map(lambda x, y: x+y, [1,3,2], [9,1,4]),
+ list(map(lambda x, y: x+y, [1,3,2], [9,1,4])),
[10, 4, 6]
)
@@ -808,43 +711,41 @@ class BuiltinTest(unittest.TestCase):
for i in v: accu = accu + i
return accu
self.assertEqual(
- map(plus, [1, 3, 7]),
+ list(map(plus, [1, 3, 7])),
[1, 3, 7]
)
self.assertEqual(
- map(plus, [1, 3, 7], [4, 9, 2]),
+ list(map(plus, [1, 3, 7], [4, 9, 2])),
[1+4, 3+9, 7+2]
)
self.assertEqual(
- map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0]),
+ list(map(plus, [1, 3, 7], [4, 9, 2], [1, 1, 0])),
[1+4+1, 3+9+1, 7+2+0]
)
self.assertEqual(
- map(None, Squares(10)),
+ list(map(int, Squares(10))),
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
)
+ def Max(a, b):
+ if a is None:
+ return b
+ if b is None:
+ return a
+ return max(a, b)
self.assertEqual(
- map(int, Squares(10)),
- [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
- )
- self.assertEqual(
- map(None, Squares(3), Squares(2)),
- [(0,0), (1,1), (4,None)]
- )
- self.assertEqual(
- map(max, Squares(3), Squares(2)),
- [0, 1, 4]
+ list(map(Max, Squares(3), Squares(2))),
+ [0, 1]
)
self.assertRaises(TypeError, map)
self.assertRaises(TypeError, map, lambda x: x, 42)
- self.assertEqual(map(None, [42]), [42])
class BadSeq:
- def __getitem__(self, index):
+ def __iter__(self):
raise ValueError
- self.assertRaises(ValueError, map, lambda x: x, BadSeq())
+ yield None
+ self.assertRaises(ValueError, list, map(lambda x: x, BadSeq()))
def badfunc(x):
raise RuntimeError
- self.assertRaises(RuntimeError, map, badfunc, range(5))
+ self.assertRaises(RuntimeError, list, map(badfunc, range(5)))
def test_max(self):
self.assertEqual(max('123123'), '3')
@@ -852,9 +753,9 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(max((1, 2, 3, 1, 2, 3)), 3)
self.assertEqual(max([1, 2, 3, 1, 2, 3]), 3)
- self.assertEqual(max(1, 2L, 3.0), 3.0)
- self.assertEqual(max(1L, 2.0, 3), 3)
- self.assertEqual(max(1.0, 2, 3L), 3L)
+ self.assertEqual(max(1, 2, 3.0), 3.0)
+ self.assertEqual(max(1, 2.0, 3), 3)
+ self.assertEqual(max(1.0, 2, 3), 3)
for stmt in (
"max(key=int)", # no args
@@ -864,7 +765,7 @@ class BuiltinTest(unittest.TestCase):
"max(1, 2, key=1)", # keyfunc is not callable
):
try:
- exec(stmt) in globals()
+ exec(stmt, globals())
except TypeError:
pass
else:
@@ -886,9 +787,9 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(min((1, 2, 3, 1, 2, 3)), 1)
self.assertEqual(min([1, 2, 3, 1, 2, 3]), 1)
- self.assertEqual(min(1, 2L, 3.0), 1)
- self.assertEqual(min(1L, 2.0, 3), 1L)
- self.assertEqual(min(1.0, 2, 3L), 1.0)
+ self.assertEqual(min(1, 2, 3.0), 1)
+ self.assertEqual(min(1, 2.0, 3), 1)
+ self.assertEqual(min(1.0, 2, 3), 1.0)
self.assertRaises(TypeError, min)
self.assertRaises(TypeError, min, 42)
@@ -897,10 +798,6 @@ class BuiltinTest(unittest.TestCase):
def __getitem__(self, index):
raise ValueError
self.assertRaises(ValueError, min, BadSeq())
- class BadNumber:
- def __cmp__(self, other):
- raise ValueError
- self.assertRaises(ValueError, min, (42, BadNumber()))
for stmt in (
"min(key=int)", # no args
@@ -910,7 +807,7 @@ class BuiltinTest(unittest.TestCase):
"min(1, 2, key=1)", # keyfunc is not callable
):
try:
- exec(stmt) in globals()
+ exec(stmt, globals())
except TypeError:
pass
else:
@@ -937,7 +834,7 @@ class BuiltinTest(unittest.TestCase):
class Iter(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
it = iter(Iter())
@@ -954,18 +851,15 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(next(it, 42), 42)
def test_oct(self):
- self.assertEqual(oct(100), '0144')
- self.assertEqual(oct(100L), '0144L')
- self.assertEqual(oct(-100), '-0144')
- self.assertEqual(oct(-100L), '-0144L')
+ self.assertEqual(oct(100), '0o144')
+ self.assertEqual(oct(-100), '-0o144')
self.assertRaises(TypeError, oct, ())
def write_testfile(self):
- # NB the first 4 lines are also used to test input and raw_input, below
+ # NB the first 4 lines are also used to test input, below
fp = open(TESTFN, 'w')
try:
fp.write('1+1\n')
- fp.write('1+1\n')
fp.write('The quick brown fox jumps over the lazy dog')
fp.write('.\n')
fp.write('Dear John\n')
@@ -979,7 +873,6 @@ class BuiltinTest(unittest.TestCase):
fp = open(TESTFN, 'r')
try:
self.assertEqual(fp.readline(4), '1+1\n')
- self.assertEqual(fp.readline(4), '1+1\n')
self.assertEqual(fp.readline(), 'The quick brown fox jumps over the lazy dog.\n')
self.assertEqual(fp.readline(4), 'Dear')
self.assertEqual(fp.readline(100), ' John\n')
@@ -993,11 +886,28 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(ord(' '), 32)
self.assertEqual(ord('A'), 65)
self.assertEqual(ord('a'), 97)
- if have_unicode:
- self.assertEqual(ord(unichr(sys.maxunicode)), sys.maxunicode)
+ self.assertEqual(ord('\x80'), 128)
+ self.assertEqual(ord('\xff'), 255)
+
+ self.assertEqual(ord(b' '), 32)
+ self.assertEqual(ord(b'A'), 65)
+ self.assertEqual(ord(b'a'), 97)
+ self.assertEqual(ord(b'\x80'), 128)
+ self.assertEqual(ord(b'\xff'), 255)
+
+ self.assertEqual(ord(chr(sys.maxunicode)), sys.maxunicode)
self.assertRaises(TypeError, ord, 42)
- if have_unicode:
- self.assertRaises(TypeError, ord, unicode("12"))
+
+ self.assertEqual(ord(chr(0x10FFFF)), 0x10FFFF)
+ self.assertEqual(ord("\U0000FFFF"), 0x0000FFFF)
+ self.assertEqual(ord("\U00010000"), 0x00010000)
+ self.assertEqual(ord("\U00010001"), 0x00010001)
+ self.assertEqual(ord("\U000FFFFE"), 0x000FFFFE)
+ self.assertEqual(ord("\U000FFFFF"), 0x000FFFFF)
+ self.assertEqual(ord("\U00100000"), 0x00100000)
+ self.assertEqual(ord("\U00100001"), 0x00100001)
+ self.assertEqual(ord("\U0010FFFE"), 0x0010FFFE)
+ self.assertEqual(ord("\U0010FFFF"), 0x0010FFFF)
def test_pow(self):
self.assertEqual(pow(0,0), 1)
@@ -1015,21 +925,6 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(pow(-2,2), 4)
self.assertEqual(pow(-2,3), -8)
- self.assertEqual(pow(0L,0), 1)
- self.assertEqual(pow(0L,1), 0)
- self.assertEqual(pow(1L,0), 1)
- self.assertEqual(pow(1L,1), 1)
-
- self.assertEqual(pow(2L,0), 1)
- self.assertEqual(pow(2L,10), 1024)
- self.assertEqual(pow(2L,20), 1024*1024)
- self.assertEqual(pow(2L,30), 1024*1024*1024)
-
- self.assertEqual(pow(-2L,0), 1)
- self.assertEqual(pow(-2L,1), -2)
- self.assertEqual(pow(-2L,2), 4)
- self.assertEqual(pow(-2L,3), -8)
-
self.assertAlmostEqual(pow(0.,0), 1.)
self.assertAlmostEqual(pow(0.,1), 0.)
self.assertAlmostEqual(pow(1.,0), 1.)
@@ -1045,9 +940,9 @@ class BuiltinTest(unittest.TestCase):
self.assertAlmostEqual(pow(-2.,2), 4.)
self.assertAlmostEqual(pow(-2.,3), -8.)
- for x in 2, 2L, 2.0:
- for y in 10, 10L, 10.0:
- for z in 1000, 1000L, 1000.0:
+ for x in 2, 2.0:
+ for y in 10, 10.0:
+ for z in 1000, 1000.0:
if isinstance(x, float) or \
isinstance(y, float) or \
isinstance(z, float):
@@ -1055,124 +950,15 @@ class BuiltinTest(unittest.TestCase):
else:
self.assertAlmostEqual(pow(x, y, z), 24.0)
+ self.assertAlmostEqual(pow(-1, 0.5), 1j)
+ self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j)
+
self.assertRaises(TypeError, pow, -1, -2, 3)
self.assertRaises(ValueError, pow, 1, 2, 0)
- self.assertRaises(TypeError, pow, -1L, -2L, 3L)
- self.assertRaises(ValueError, pow, 1L, 2L, 0L)
- # Will return complex in 3.0:
- self.assertRaises(ValueError, pow, -342.43, 0.234)
self.assertRaises(TypeError, pow)
- def test_range(self):
- self.assertEqual(range(3), [0, 1, 2])
- self.assertEqual(range(1, 5), [1, 2, 3, 4])
- self.assertEqual(range(0), [])
- self.assertEqual(range(-3), [])
- self.assertEqual(range(1, 10, 3), [1, 4, 7])
- self.assertEqual(range(5, -5, -3), [5, 2, -1, -4])
-
- # Now test range() with longs
- self.assertEqual(range(-2**100), [])
- self.assertEqual(range(0, -2**100), [])
- self.assertEqual(range(0, 2**100, -1), [])
- self.assertEqual(range(0, 2**100, -1), [])
-
- a = long(10 * sys.maxint)
- b = long(100 * sys.maxint)
- c = long(50 * sys.maxint)
-
- self.assertEqual(range(a, a+2), [a, a+1])
- self.assertEqual(range(a+2, a, -1L), [a+2, a+1])
- self.assertEqual(range(a+4, a, -2), [a+4, a+2])
-
- seq = range(a, b, c)
- self.assertIn(a, seq)
- self.assertNotIn(b, seq)
- self.assertEqual(len(seq), 2)
-
- seq = range(b, a, -c)
- self.assertIn(b, seq)
- self.assertNotIn(a, seq)
- self.assertEqual(len(seq), 2)
-
- seq = range(-a, -b, -c)
- self.assertIn(-a, seq)
- self.assertNotIn(-b, seq)
- self.assertEqual(len(seq), 2)
-
- self.assertRaises(TypeError, range)
- self.assertRaises(TypeError, range, 1, 2, 3, 4)
- self.assertRaises(ValueError, range, 1, 2, 0)
- self.assertRaises(ValueError, range, a, a + 1, long(0))
-
- class badzero(int):
- def __cmp__(self, other):
- raise RuntimeError
- __hash__ = None # Invalid cmp makes this unhashable
- self.assertRaises(RuntimeError, range, a, a + 1, badzero(1))
-
- # Reject floats.
- self.assertRaises(TypeError, range, 1., 1., 1.)
- self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
-
- self.assertRaises(TypeError, range, 0, "spam")
- self.assertRaises(TypeError, range, 0, 42, "spam")
-
- self.assertRaises(OverflowError, range, -sys.maxint, sys.maxint)
- self.assertRaises(OverflowError, range, 0, 2*sys.maxint)
-
- bignum = 2*sys.maxint
- smallnum = 42
- # Old-style user-defined class with __int__ method
- class I0:
- def __init__(self, n):
- self.n = int(n)
- def __int__(self):
- return self.n
- self.assertEqual(range(I0(bignum), I0(bignum + 1)), [bignum])
- self.assertEqual(range(I0(smallnum), I0(smallnum + 1)), [smallnum])
-
- # New-style user-defined class with __int__ method
- class I1(object):
- def __init__(self, n):
- self.n = int(n)
- def __int__(self):
- return self.n
- self.assertEqual(range(I1(bignum), I1(bignum + 1)), [bignum])
- self.assertEqual(range(I1(smallnum), I1(smallnum + 1)), [smallnum])
-
- # New-style user-defined class with failing __int__ method
- class IX(object):
- def __int__(self):
- raise RuntimeError
- self.assertRaises(RuntimeError, range, IX())
-
- # New-style user-defined class with invalid __int__ method
- class IN(object):
- def __int__(self):
- return "not a number"
- self.assertRaises(TypeError, range, IN())
-
- # Exercise various combinations of bad arguments, to check
- # refcounting logic
- self.assertRaises(TypeError, range, 0.0)
-
- self.assertRaises(TypeError, range, 0, 0.0)
- self.assertRaises(TypeError, range, 0.0, 0)
- self.assertRaises(TypeError, range, 0.0, 0.0)
-
- self.assertRaises(TypeError, range, 0, 0, 1.0)
- self.assertRaises(TypeError, range, 0, 0.0, 1)
- self.assertRaises(TypeError, range, 0, 0.0, 1.0)
- self.assertRaises(TypeError, range, 0.0, 0, 1)
- self.assertRaises(TypeError, range, 0.0, 0, 1.0)
- self.assertRaises(TypeError, range, 0.0, 0.0, 1)
- self.assertRaises(TypeError, range, 0.0, 0.0, 1.0)
-
-
-
- def test_input_and_raw_input(self):
+ def test_input(self):
self.write_testfile()
fp = open(TESTFN, 'r')
savestdin = sys.stdin
@@ -1180,10 +966,9 @@ class BuiltinTest(unittest.TestCase):
try:
sys.stdin = fp
sys.stdout = BitBucket()
- self.assertEqual(input(), 2)
- self.assertEqual(input('testing\n'), 2)
- self.assertEqual(raw_input(), 'The quick brown fox jumps over the lazy dog.')
- self.assertEqual(raw_input('testing\n'), 'Dear John')
+ self.assertEqual(input(), "1+1")
+ self.assertEqual(input(), 'The quick brown fox jumps over the lazy dog.')
+ self.assertEqual(input('testing\n'), 'Dear John')
# SF 1535165: don't segfault on closed stdin
# sys.stdout must be a regular file for triggering
@@ -1192,33 +977,13 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(ValueError, input)
sys.stdout = BitBucket()
- sys.stdin = cStringIO.StringIO("NULL\0")
+ sys.stdin = io.StringIO("NULL\0")
self.assertRaises(TypeError, input, 42, 42)
- sys.stdin = cStringIO.StringIO(" 'whitespace'")
- self.assertEqual(input(), 'whitespace')
- sys.stdin = cStringIO.StringIO()
+ sys.stdin = io.StringIO(" 'whitespace'")
+ self.assertEqual(input(), " 'whitespace'")
+ sys.stdin = io.StringIO()
self.assertRaises(EOFError, input)
- # SF 876178: make sure input() respect future options.
- sys.stdin = cStringIO.StringIO('1/2')
- sys.stdout = cStringIO.StringIO()
- exec compile('print input()', 'test_builtin_tmp', 'exec')
- sys.stdin.seek(0, 0)
- exec compile('from __future__ import division;print input()',
- 'test_builtin_tmp', 'exec')
- sys.stdin.seek(0, 0)
- exec compile('print input()', 'test_builtin_tmp', 'exec')
- # The result we expect depends on whether new division semantics
- # are already in effect.
- if 1/2 == 0:
- # This test was compiled with old semantics.
- expected = ['0', '0.5', '0']
- else:
- # This test was compiled with new semantics (e.g., -Qnew
- # was given on the command line.
- expected = ['0.5', '0.5', '0.5']
- self.assertEqual(sys.stdout.getvalue().splitlines(), expected)
-
del sys.stdout
self.assertRaises(RuntimeError, input, 'prompt')
del sys.stdin
@@ -1229,53 +994,85 @@ class BuiltinTest(unittest.TestCase):
fp.close()
unlink(TESTFN)
- def test_reduce(self):
- add = lambda x, y: x+y
- self.assertEqual(reduce(add, ['a', 'b', 'c'], ''), 'abc')
- self.assertEqual(
- reduce(add, [['a', 'c'], [], ['d', 'w']], []),
- ['a','c','d','w']
- )
- self.assertEqual(reduce(lambda x, y: x*y, range(2,8), 1), 5040)
- self.assertEqual(
- reduce(lambda x, y: x*y, range(2,21), 1L),
- 2432902008176640000L
- )
- self.assertEqual(reduce(add, Squares(10)), 285)
- self.assertEqual(reduce(add, Squares(10), 0), 285)
- self.assertEqual(reduce(add, Squares(0), 0), 0)
- self.assertRaises(TypeError, reduce)
- self.assertRaises(TypeError, reduce, 42)
- self.assertRaises(TypeError, reduce, 42, 42)
- self.assertRaises(TypeError, reduce, 42, 42, 42)
- self.assertRaises(TypeError, reduce, None, range(5))
- self.assertRaises(TypeError, reduce, add, 42)
- self.assertEqual(reduce(42, "1"), "1") # func is never called with one item
- self.assertEqual(reduce(42, "", "1"), "1") # func is never called with one item
- self.assertRaises(TypeError, reduce, 42, (42, 42))
- self.assertRaises(TypeError, reduce, add, []) # arg 2 must not be empty sequence with no initial value
- self.assertRaises(TypeError, reduce, add, "")
- self.assertRaises(TypeError, reduce, add, ())
- self.assertEqual(reduce(add, [], None), None)
- self.assertEqual(reduce(add, [], 42), 42)
-
- class BadSeq:
- def __getitem__(self, index):
- raise ValueError
- self.assertRaises(ValueError, reduce, 42, BadSeq())
-
- def test_reload(self):
- import marshal
- reload(marshal)
- import string
- reload(string)
- ## import sys
- ## self.assertRaises(ImportError, reload, sys)
+ @unittest.skipUnless(pty, "the pty and signal modules must be available")
+ def check_input_tty(self, prompt, terminal_input, stdio_encoding=None):
+ if not sys.stdin.isatty() or not sys.stdout.isatty():
+ self.skipTest("stdin and stdout must be ttys")
+ r, w = os.pipe()
+ try:
+ pid, fd = pty.fork()
+ except (OSError, AttributeError) as e:
+ os.close(r)
+ os.close(w)
+ self.skipTest("pty.fork() raised {}".format(e))
+ if pid == 0:
+ # Child
+ try:
+ # Make sure we don't get stuck if there's a problem
+ signal.alarm(2)
+ os.close(r)
+ # Check the error handlers are accounted for
+ if stdio_encoding:
+ sys.stdin = io.TextIOWrapper(sys.stdin.detach(),
+ encoding=stdio_encoding,
+ errors='surrogateescape')
+ sys.stdout = io.TextIOWrapper(sys.stdout.detach(),
+ encoding=stdio_encoding,
+ errors='replace')
+ with open(w, "w") as wpipe:
+ print("tty =", sys.stdin.isatty() and sys.stdout.isatty(), file=wpipe)
+ print(ascii(input(prompt)), file=wpipe)
+ except:
+ traceback.print_exc()
+ finally:
+ # We don't want to return to unittest...
+ os._exit(0)
+ # Parent
+ os.close(w)
+ os.write(fd, terminal_input + b"\r\n")
+ # Get results from the pipe
+ with open(r, "r") as rpipe:
+ lines = []
+ while True:
+ line = rpipe.readline().strip()
+ if line == "":
+ # The other end was closed => the child exited
+ break
+ lines.append(line)
+ # Check the result was got and corresponds to the user's terminal input
+ if len(lines) != 2:
+ # Something went wrong, try to get at stderr
+ with open(fd, "r", encoding="ascii", errors="ignore") as child_output:
+ self.fail("got %d lines in pipe but expected 2, child output was:\n%s"
+ % (len(lines), child_output.read()))
+ os.close(fd)
+ # Check we did exercise the GNU readline path
+ self.assertIn(lines[0], {'tty = True', 'tty = False'})
+ if lines[0] != 'tty = True':
+ self.skipTest("standard IO in should have been a tty")
+ input_result = eval(lines[1]) # ascii() -> eval() roundtrip
+ if stdio_encoding:
+ expected = terminal_input.decode(stdio_encoding, 'surrogateescape')
+ else:
+ expected = terminal_input.decode(sys.stdin.encoding) # what else?
+ self.assertEqual(input_result, expected)
+
+ def test_input_tty(self):
+ # Test input() functionality when wired to a tty (the code path
+ # is different and invokes GNU readline if available).
+ self.check_input_tty("prompt", b"quux")
+
+ def test_input_tty_non_ascii(self):
+ # Check stdin/stdout encoding is used when invoking GNU readline
+ self.check_input_tty("prompté", b"quux\xe9", "utf-8")
+
+ def test_input_tty_non_ascii_unicode_errors(self):
+ # Check stdin/stdout error handler is used when invoking GNU readline
+ self.check_input_tty("prompté", b"quux\xe9", "ascii")
def test_repr(self):
self.assertEqual(repr(''), '\'\'')
self.assertEqual(repr(0), '0')
- self.assertEqual(repr(0L), '0L')
self.assertEqual(repr(()), '()')
self.assertEqual(repr([]), '[]')
self.assertEqual(repr({}), '{}')
@@ -1288,7 +1085,7 @@ class BuiltinTest(unittest.TestCase):
def test_round(self):
self.assertEqual(round(0.0), 0.0)
- self.assertEqual(type(round(0.0)), float) # Will be int in 3.0.
+ self.assertEqual(type(round(0.0)), int)
self.assertEqual(round(1.0), 1.0)
self.assertEqual(round(10.0), 10.0)
self.assertEqual(round(1000000000.0), 1000000000.0)
@@ -1322,20 +1119,20 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(type(round(-8.0, 0)), float)
self.assertEqual(type(round(-8.0, 1)), float)
- # Check half rounding behaviour.
+ # Check even / odd rounding behaviour
self.assertEqual(round(5.5), 6)
- self.assertEqual(round(6.5), 7)
+ self.assertEqual(round(6.5), 6)
self.assertEqual(round(-5.5), -6)
- self.assertEqual(round(-6.5), -7)
+ self.assertEqual(round(-6.5), -6)
# Check behavior on ints
self.assertEqual(round(0), 0)
self.assertEqual(round(8), 8)
self.assertEqual(round(-8), -8)
- self.assertEqual(type(round(0)), float) # Will be int in 3.0.
- self.assertEqual(type(round(-8, -1)), float)
- self.assertEqual(type(round(-8, 0)), float)
- self.assertEqual(type(round(-8, 1)), float)
+ self.assertEqual(type(round(0)), int)
+ self.assertEqual(type(round(-8, -1)), int)
+ self.assertEqual(type(round(-8, 0)), int)
+ self.assertEqual(type(round(-8, 1)), int)
# test new kwargs
self.assertEqual(round(number=-8.0, ndigits=-1), -10.0)
@@ -1343,11 +1140,11 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, round)
# test generic rounding delegation for reals
- class TestRound(object):
- def __float__(self):
- return 23.0
+ class TestRound:
+ def __round__(self):
+ return 23
- class TestNoRound(object):
+ class TestNoRound:
pass
self.assertEqual(round(TestRound()), 23)
@@ -1356,7 +1153,7 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, round, TestNoRound())
t = TestNoRound()
- t.__float__ = lambda *args: args
+ t.__round__ = lambda *args: args
self.assertRaises(TypeError, round, t)
self.assertRaises(TypeError, round, t, 0)
@@ -1387,10 +1184,12 @@ class BuiltinTest(unittest.TestCase):
self.assertRaises(TypeError, setattr, sys, 1, 'spam')
self.assertRaises(TypeError, setattr)
+ # test_str(): see test_unicode.py and test_bytes.py for str() tests.
+
def test_sum(self):
self.assertEqual(sum([]), 0)
- self.assertEqual(sum(range(2,8)), 27)
- self.assertEqual(sum(iter(range(2,8))), 27)
+ self.assertEqual(sum(list(range(2,8))), 27)
+ self.assertEqual(sum(iter(list(range(2,8)))), 27)
self.assertEqual(sum(Squares(10)), 285)
self.assertEqual(sum(iter(Squares(10))), 285)
self.assertEqual(sum([[1], [2], [3]], []), [1, 2, 3])
@@ -1416,19 +1215,6 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(type(''), type('123'))
self.assertNotEqual(type(''), type(()))
- def test_unichr(self):
- if have_unicode:
- self.assertEqual(unichr(32), unicode(' '))
- self.assertEqual(unichr(65), unicode('A'))
- self.assertEqual(unichr(97), unicode('a'))
- self.assertEqual(
- unichr(sys.maxunicode),
- unicode('\\U%08x' % (sys.maxunicode), 'unicode-escape')
- )
- self.assertRaises(ValueError, unichr, sys.maxunicode+1)
- self.assertRaises(TypeError, unichr)
- self.assertRaises((OverflowError, ValueError), unichr, 2**32)
-
# We don't want self in vars(), so these are static methods
@staticmethod
@@ -1449,7 +1235,6 @@ class BuiltinTest(unittest.TestCase):
def test_vars(self):
self.assertEqual(set(vars()), set(dir()))
- import sys
self.assertEqual(set(vars(sys)), set(dir(sys)))
self.assertEqual(self.get_vars_f0(), {})
self.assertEqual(self.get_vars_f2(), {'a': 1, 'b': 2})
@@ -1461,22 +1246,23 @@ class BuiltinTest(unittest.TestCase):
a = (1, 2, 3)
b = (4, 5, 6)
t = [(1, 4), (2, 5), (3, 6)]
- self.assertEqual(zip(a, b), t)
+ self.assertEqual(list(zip(a, b)), t)
b = [4, 5, 6]
- self.assertEqual(zip(a, b), t)
+ self.assertEqual(list(zip(a, b)), t)
b = (4, 5, 6, 7)
- self.assertEqual(zip(a, b), t)
+ self.assertEqual(list(zip(a, b)), t)
class I:
def __getitem__(self, i):
if i < 0 or i > 2: raise IndexError
return i + 4
- self.assertEqual(zip(a, I()), t)
- self.assertEqual(zip(), [])
- self.assertEqual(zip(*[]), [])
+ self.assertEqual(list(zip(a, I())), t)
+ self.assertEqual(list(zip()), [])
+ self.assertEqual(list(zip(*[])), [])
self.assertRaises(TypeError, zip, None)
class G:
pass
self.assertRaises(TypeError, zip, a, G())
+ self.assertRaises(RuntimeError, zip, a, TestFailingIter())
# Make sure zip doesn't try to allocate a billion elements for the
# result list when one of its arguments doesn't say how long it is.
@@ -1488,7 +1274,7 @@ class BuiltinTest(unittest.TestCase):
else:
return i
self.assertEqual(
- zip(SequenceWithoutALength(), xrange(2**30)),
+ list(zip(SequenceWithoutALength(), range(2**30))),
list(enumerate(range(5)))
)
@@ -1498,7 +1284,7 @@ class BuiltinTest(unittest.TestCase):
raise ValueError
else:
return i
- self.assertRaises(ValueError, zip, BadSeq(), BadSeq())
+ self.assertRaises(ValueError, list, zip(BadSeq(), BadSeq()))
def test_format(self):
# Test the basic machinery of the format() builtin. Don't test
@@ -1525,25 +1311,6 @@ class BuiltinTest(unittest.TestCase):
class DerivedFromSimple2(DerivedFromSimple): pass
return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2
- # In 3.0, classes_classic has the same meaning as classes_new
- def classes_classic():
- class A:
- def __init__(self, x):
- self.x = x
- def __format__(self, format_spec):
- return str(self.x) + format_spec
- class DerivedFromA(A):
- pass
-
- class Simple: pass
- class DerivedFromSimple(Simple):
- def __init__(self, x):
- self.x = x
- def __format__(self, format_spec):
- return str(self.x) + format_spec
- class DerivedFromSimple2(DerivedFromSimple): pass
- return A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2
-
def class_test(A, DerivedFromA, DerivedFromSimple, DerivedFromSimple2):
self.assertEqual(format(A(3), 'spec'), '3spec')
self.assertEqual(format(DerivedFromA(4), 'spec'), '4spec')
@@ -1552,7 +1319,6 @@ class BuiltinTest(unittest.TestCase):
'10abcdef')
class_test(*classes_new())
- class_test(*classes_classic())
def empty_format_spec(value):
# test that:
@@ -1606,7 +1372,7 @@ class BuiltinTest(unittest.TestCase):
else:
self.assertEqual(len(w), 0)
- fmt_strs = ['', 's', u'', u's']
+ fmt_strs = ['', 's']
class A:
def __format__(self, fmt_str):
@@ -1640,14 +1406,14 @@ class BuiltinTest(unittest.TestCase):
self.assertEqual(bin(-(2**65-1)), '-0b' + '1' * 65)
def test_bytearray_translate(self):
- x = bytearray("abc")
- self.assertRaises(ValueError, x.translate, "1", 1)
- self.assertRaises(TypeError, x.translate, "1"*256, 1)
+ x = bytearray(b"abc")
+ self.assertRaises(ValueError, x.translate, b"1", 1)
+ self.assertRaises(TypeError, x.translate, b"1"*256, 1)
class TestSorted(unittest.TestCase):
def test_basic(self):
- data = range(100)
+ data = list(range(100))
copy = data[:]
random.shuffle(copy)
self.assertEqual(data, sorted(copy))
@@ -1655,9 +1421,6 @@ class TestSorted(unittest.TestCase):
data.reverse()
random.shuffle(copy)
- self.assertEqual(data, sorted(copy, cmp=lambda x, y: cmp(y,x)))
- self.assertNotEqual(data, copy)
- random.shuffle(copy)
self.assertEqual(data, sorted(copy, key=lambda x: -x))
self.assertNotEqual(data, copy)
random.shuffle(copy)
@@ -1666,16 +1429,12 @@ class TestSorted(unittest.TestCase):
def test_inputtypes(self):
s = 'abracadabra'
- types = [list, tuple]
- if have_unicode:
- types.insert(0, unicode)
+ types = [list, tuple, str]
for T in types:
self.assertEqual(sorted(s), sorted(T(s)))
- s = ''.join(dict.fromkeys(s).keys()) # unique letters only
- types = [set, frozenset, list, tuple, dict.fromkeys]
- if have_unicode:
- types.insert(0, unicode)
+ s = ''.join(set(s)) # unique letters only
+ types = [str, set, frozenset, list, tuple, dict.fromkeys]
for T in types:
self.assertEqual(sorted(s), sorted(T(s)))
@@ -1683,27 +1442,20 @@ class TestSorted(unittest.TestCase):
data = 'The quick Brown fox Jumped over The lazy Dog'.split()
self.assertRaises(TypeError, sorted, data, None, lambda x,y: 0)
-def _run_unittest(*args):
- with check_py3k_warnings(
- (".+ not supported in 3.x", DeprecationWarning),
- (".+ is renamed to imp.reload", DeprecationWarning),
- ("classic int division", DeprecationWarning)):
- run_unittest(*args)
-
def test_main(verbose=None):
test_classes = (BuiltinTest, TestSorted)
- _run_unittest(*test_classes)
+ run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- _run_unittest(*test_classes)
+ for i in range(len(counts)):
+ run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
diff --git a/Lib/test/test_bytes.py b/Lib/test/test_bytes.py
index 520459d039c..89e22740fc6 100644
--- a/Lib/test/test_bytes.py
+++ b/Lib/test/test_bytes.py
@@ -13,7 +13,7 @@ import functools
import pickle
import tempfile
import unittest
-import test.test_support
+import test.support
import test.string_tests
import test.buffer_tests
@@ -22,7 +22,7 @@ if sys.flags.bytes_warning:
def check_bytes_warnings(func):
@functools.wraps(func)
def wrapper(*args, **kw):
- with test.test_support.check_warnings(('', BytesWarning)):
+ with test.support.check_warnings(('', BytesWarning)):
return func(*args, **kw)
return wrapper
else:
@@ -45,19 +45,26 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(type(b), self.type2test)
self.assertEqual(b.__class__, self.type2test)
+ def test_copy(self):
+ a = self.type2test(b"abcd")
+ for copy_method in (copy.copy, copy.deepcopy):
+ b = copy_method(a)
+ self.assertEqual(a, b)
+ self.assertEqual(type(a), type(b))
+
def test_empty_sequence(self):
b = self.type2test()
self.assertEqual(len(b), 0)
self.assertRaises(IndexError, lambda: b[0])
self.assertRaises(IndexError, lambda: b[1])
- self.assertRaises(IndexError, lambda: b[sys.maxint])
- self.assertRaises(IndexError, lambda: b[sys.maxint+1])
+ self.assertRaises(IndexError, lambda: b[sys.maxsize])
+ self.assertRaises(IndexError, lambda: b[sys.maxsize+1])
self.assertRaises(IndexError, lambda: b[10**100])
self.assertRaises(IndexError, lambda: b[-1])
self.assertRaises(IndexError, lambda: b[-2])
- self.assertRaises(IndexError, lambda: b[-sys.maxint])
- self.assertRaises(IndexError, lambda: b[-sys.maxint-1])
- self.assertRaises(IndexError, lambda: b[-sys.maxint-2])
+ self.assertRaises(IndexError, lambda: b[-sys.maxsize])
+ self.assertRaises(IndexError, lambda: b[-sys.maxsize-1])
+ self.assertRaises(IndexError, lambda: b[-sys.maxsize-2])
self.assertRaises(IndexError, lambda: b[-10**100])
def test_from_list(self):
@@ -87,22 +94,21 @@ class BaseBytesTest(unittest.TestCase):
self.assertRaises(TypeError, self.type2test, 0.0)
class C:
pass
- # allowed in 2.x
- #self.assertRaises(TypeError, self.type2test, ["0"])
+ self.assertRaises(TypeError, self.type2test, ["0"])
self.assertRaises(TypeError, self.type2test, [0.0])
self.assertRaises(TypeError, self.type2test, [None])
self.assertRaises(TypeError, self.type2test, [C()])
def test_constructor_value_errors(self):
self.assertRaises(ValueError, self.type2test, [-1])
- self.assertRaises(ValueError, self.type2test, [-sys.maxint])
- self.assertRaises(ValueError, self.type2test, [-sys.maxint-1])
- self.assertRaises(ValueError, self.type2test, [-sys.maxint-2])
+ self.assertRaises(ValueError, self.type2test, [-sys.maxsize])
+ self.assertRaises(ValueError, self.type2test, [-sys.maxsize-1])
+ self.assertRaises(ValueError, self.type2test, [-sys.maxsize-2])
self.assertRaises(ValueError, self.type2test, [-10**100])
self.assertRaises(ValueError, self.type2test, [256])
self.assertRaises(ValueError, self.type2test, [257])
- self.assertRaises(ValueError, self.type2test, [sys.maxint])
- self.assertRaises(ValueError, self.type2test, [sys.maxint+1])
+ self.assertRaises(ValueError, self.type2test, [sys.maxsize])
+ self.assertRaises(ValueError, self.type2test, [sys.maxsize+1])
self.assertRaises(ValueError, self.type2test, [10**100])
def test_compare(self):
@@ -131,13 +137,16 @@ class BaseBytesTest(unittest.TestCase):
@check_bytes_warnings
def test_compare_to_str(self):
# Byte comparisons with unicode should always fail!
- # Test this for all expected byte orders and Unicode character sizes
- self.assertEqual(self.type2test(b"\0a\0b\0c") == u"abc", False)
- self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == u"abc", False)
- self.assertEqual(self.type2test(b"a\0b\0c\0") == u"abc", False)
- self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == u"abc", False)
- self.assertEqual(self.type2test() == unicode(), False)
- self.assertEqual(self.type2test() != unicode(), True)
+ # Test this for all expected byte orders and Unicode character
+ # sizes.
+ self.assertEqual(self.type2test(b"\0a\0b\0c") == "abc", False)
+ self.assertEqual(self.type2test(b"\0\0\0a\0\0\0b\0\0\0c") == "abc",
+ False)
+ self.assertEqual(self.type2test(b"a\0b\0c\0") == "abc", False)
+ self.assertEqual(self.type2test(b"a\0\0\0b\0\0\0c\0\0\0") == "abc",
+ False)
+ self.assertEqual(self.type2test() == str(), False)
+ self.assertEqual(self.type2test() != str(), True)
def test_reversed(self):
input = list(map(ord, "Hello"))
@@ -178,20 +187,20 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(b[start:stop:step], self.type2test(L[start:stop:step]))
def test_encoding(self):
- sample = u"Hello world\n\u1234\u5678\u9abc\udef0"
+ sample = "Hello world\n\u1234\u5678\u9abc"
for enc in ("utf8", "utf16"):
b = self.type2test(sample, enc)
self.assertEqual(b, self.type2test(sample.encode(enc)))
self.assertRaises(UnicodeEncodeError, self.type2test, sample, "latin1")
b = self.type2test(sample, "latin1", "ignore")
- self.assertEqual(b, self.type2test(sample[:-4], "utf-8"))
+ self.assertEqual(b, self.type2test(sample[:-3], "utf-8"))
def test_decode(self):
- sample = u"Hello world\n\u1234\u5678\u9abc\def0\def0"
+ sample = "Hello world\n\u1234\u5678\u9abc\def0\def0"
for enc in ("utf8", "utf16"):
b = self.type2test(sample, enc)
self.assertEqual(b.decode(enc), sample)
- sample = u"Hello world\n\x80\x81\xfe\xff"
+ sample = "Hello world\n\x80\x81\xfe\xff"
b = self.type2test(sample, "latin1")
self.assertRaises(UnicodeDecodeError, b.decode, "utf8")
self.assertEqual(b.decode("utf8", "ignore"), "Hello world\n")
@@ -212,8 +221,8 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(b1 + b2, b"abcdef")
self.assertEqual(b1 + bytes(b"def"), b"abcdef")
self.assertEqual(bytes(b"def") + b1, b"defabc")
- self.assertRaises(TypeError, lambda: b1 + u"def")
- self.assertRaises(TypeError, lambda: u"abc" + b2)
+ self.assertRaises(TypeError, lambda: b1 + "def")
+ self.assertRaises(TypeError, lambda: "abc" + b2)
def test_repeat(self):
for b in b"abc", self.type2test(b"abc"):
@@ -223,8 +232,10 @@ class BaseBytesTest(unittest.TestCase):
self.assertRaises(TypeError, lambda: b * 3.14)
self.assertRaises(TypeError, lambda: 3.14 * b)
# XXX Shouldn't bytes and bytearray agree on what to raise?
- self.assertRaises((OverflowError, MemoryError),
- lambda: b * sys.maxsize)
+ with self.assertRaises((OverflowError, MemoryError)):
+ c = b * sys.maxsize
+ with self.assertRaises((OverflowError, MemoryError)):
+ b *= sys.maxsize
def test_repeat_1char(self):
self.assertEqual(self.type2test(b'x')*100, self.type2test([ord('x')]*100))
@@ -238,7 +249,7 @@ class BaseBytesTest(unittest.TestCase):
self.assertRaises(ValueError, lambda: -1 in b)
self.assertRaises(TypeError, lambda: None in b)
self.assertRaises(TypeError, lambda: float(ord('a')) in b)
- self.assertRaises(TypeError, lambda: u"a" in b)
+ self.assertRaises(TypeError, lambda: "a" in b)
for f in bytes, bytearray:
self.assertIn(f(b""), b)
self.assertIn(f(b"a"), b)
@@ -255,16 +266,17 @@ class BaseBytesTest(unittest.TestCase):
def test_fromhex(self):
self.assertRaises(TypeError, self.type2test.fromhex)
self.assertRaises(TypeError, self.type2test.fromhex, 1)
- self.assertEqual(self.type2test.fromhex(u''), self.type2test())
+ self.assertEqual(self.type2test.fromhex(''), self.type2test())
b = bytearray([0x1a, 0x2b, 0x30])
- self.assertEqual(self.type2test.fromhex(u'1a2B30'), b)
- self.assertEqual(self.type2test.fromhex(u' 1A 2B 30 '), b)
- self.assertEqual(self.type2test.fromhex(u'0000'), b'\0\0')
- self.assertRaises(ValueError, self.type2test.fromhex, u'a')
- self.assertRaises(ValueError, self.type2test.fromhex, u'rt')
- self.assertRaises(ValueError, self.type2test.fromhex, u'1a b cd')
- self.assertRaises(ValueError, self.type2test.fromhex, u'\x00')
- self.assertRaises(ValueError, self.type2test.fromhex, u'12 \x00 34')
+ self.assertEqual(self.type2test.fromhex('1a2B30'), b)
+ self.assertEqual(self.type2test.fromhex(' 1A 2B 30 '), b)
+ self.assertEqual(self.type2test.fromhex('0000'), b'\0\0')
+ self.assertRaises(TypeError, self.type2test.fromhex, b'1B')
+ self.assertRaises(ValueError, self.type2test.fromhex, 'a')
+ self.assertRaises(ValueError, self.type2test.fromhex, 'rt')
+ self.assertRaises(ValueError, self.type2test.fromhex, '1a b cd')
+ self.assertRaises(ValueError, self.type2test.fromhex, '\x00')
+ self.assertRaises(ValueError, self.type2test.fromhex, '12 \x00 34')
def test_join(self):
self.assertEqual(self.type2test(b"").join([]), b"")
@@ -291,6 +303,11 @@ class BaseBytesTest(unittest.TestCase):
self.assertTrue(b.startswith(b"h"))
self.assertFalse(b.startswith(b"hellow"))
self.assertFalse(b.startswith(b"ha"))
+ with self.assertRaises(TypeError) as cm:
+ b.startswith([b'h'])
+ exc = str(cm.exception)
+ self.assertIn('bytes', exc)
+ self.assertIn('tuple', exc)
def test_endswith(self):
b = self.type2test(b'hello')
@@ -300,6 +317,11 @@ class BaseBytesTest(unittest.TestCase):
self.assertTrue(b.endswith(b"o"))
self.assertFalse(b.endswith(b"whello"))
self.assertFalse(b.endswith(b"no"))
+ with self.assertRaises(TypeError) as cm:
+ b.endswith([b'o'])
+ exc = str(cm.exception)
+ self.assertIn('bytes', exc)
+ self.assertIn('tuple', exc)
def test_find(self):
b = self.type2test(b'mississippi')
@@ -360,7 +382,7 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(self.type2test(b' a bb c ').split(None, 3), [b'a', b'bb', b'c'])
def test_split_string_error(self):
- self.assertRaises(TypeError, self.type2test(b'a b').split, u' ')
+ self.assertRaises(TypeError, self.type2test(b'a b').split, ' ')
def test_split_unicodewhitespace(self):
b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
@@ -385,7 +407,7 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(self.type2test(b' a bb c ').rsplit(None, 3), [b'a', b'bb', b'c'])
def test_rsplit_string_error(self):
- self.assertRaises(TypeError, self.type2test(b'a b').rsplit, u' ')
+ self.assertRaises(TypeError, self.type2test(b'a b').rsplit, ' ')
def test_rsplit_unicodewhitespace(self):
b = self.type2test(b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F")
@@ -447,15 +469,23 @@ class BaseBytesTest(unittest.TestCase):
self.assertEqual(self.type2test(b'abc').rstrip(memoryview(b'ac')), b'ab')
def test_strip_string_error(self):
- self.assertRaises(TypeError, self.type2test(b'abc').strip, u'b')
- self.assertRaises(TypeError, self.type2test(b'abc').lstrip, u'b')
- self.assertRaises(TypeError, self.type2test(b'abc').rstrip, u'b')
+ self.assertRaises(TypeError, self.type2test(b'abc').strip, 'b')
+ self.assertRaises(TypeError, self.type2test(b'abc').lstrip, 'b')
+ self.assertRaises(TypeError, self.type2test(b'abc').rstrip, 'b')
def test_ord(self):
b = self.type2test(b'\0A\x7f\x80\xff')
self.assertEqual([ord(b[i:i+1]) for i in range(len(b))],
[0, 65, 127, 128, 255])
+ def test_maketrans(self):
+ transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
+ self.assertEqual(self.type2test.maketrans(b'abc', b'xyz'), transtable)
+ transtable = b'\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374xyz'
+ self.assertEqual(self.type2test.maketrans(b'\375\376\377', b'xyz'), transtable)
+ self.assertRaises(ValueError, self.type2test.maketrans, b'abc', b'xyzq')
+ self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 'def')
+
def test_none_arguments(self):
# issue 11828
b = self.type2test(b'hello')
@@ -503,22 +533,64 @@ class BaseBytesTest(unittest.TestCase):
# issue 11828
b = self.type2test(b'hello')
x = self.type2test(b'x')
- self.assertRaisesRegexp(TypeError, r'\bfind\b', b.find,
+ self.assertRaisesRegex(TypeError, r'\bfind\b', b.find,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\brfind\b', b.rfind,
+ self.assertRaisesRegex(TypeError, r'\brfind\b', b.rfind,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\bindex\b', b.index,
+ self.assertRaisesRegex(TypeError, r'\bindex\b', b.index,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\brindex\b', b.rindex,
+ self.assertRaisesRegex(TypeError, r'\brindex\b', b.rindex,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\bcount\b', b.count,
+ self.assertRaisesRegex(TypeError, r'\bcount\b', b.count,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\bstartswith\b', b.startswith,
+ self.assertRaisesRegex(TypeError, r'\bstartswith\b', b.startswith,
x, None, None, None)
- self.assertRaisesRegexp(TypeError, r'\bendswith\b', b.endswith,
+ self.assertRaisesRegex(TypeError, r'\bendswith\b', b.endswith,
x, None, None, None)
+class BytesTest(BaseBytesTest):
+ type2test = bytes
+
+ def test_buffer_is_readonly(self):
+ fd = os.dup(sys.stdin.fileno())
+ with open(fd, "rb", buffering=0) as f:
+ self.assertRaises(TypeError, f.readinto, b"")
+
+ def test_custom(self):
+ class A:
+ def __bytes__(self):
+ return b'abc'
+ self.assertEqual(bytes(A()), b'abc')
+ class A: pass
+ self.assertRaises(TypeError, bytes, A())
+ class A:
+ def __bytes__(self):
+ return None
+ self.assertRaises(TypeError, bytes, A())
+
+ # Test PyBytes_FromFormat()
+ def test_from_format(self):
+ test.support.import_module('ctypes')
+ from ctypes import pythonapi, py_object, c_int, c_char_p
+ PyBytes_FromFormat = pythonapi.PyBytes_FromFormat
+ PyBytes_FromFormat.restype = py_object
+
+ self.assertEqual(PyBytes_FromFormat(b'format'),
+ b'format')
+
+ self.assertEqual(PyBytes_FromFormat(b'%'), b'%')
+ self.assertEqual(PyBytes_FromFormat(b'%%'), b'%')
+ self.assertEqual(PyBytes_FromFormat(b'%%s'), b'%s')
+ self.assertEqual(PyBytes_FromFormat(b'[%%]'), b'[%]')
+ self.assertEqual(PyBytes_FromFormat(b'%%%c', c_int(ord('_'))), b'%_')
+
+ self.assertEqual(PyBytes_FromFormat(b'c:%c', c_int(255)),
+ b'c:\xff')
+ self.assertEqual(PyBytes_FromFormat(b's:%s', c_char_p(b'cstr')),
+ b's:cstr')
+
+
class ByteArrayTest(BaseBytesTest):
type2test = bytearray
@@ -538,9 +610,7 @@ class ByteArrayTest(BaseBytesTest):
b = bytearray(20)
n = f.readinto(b)
self.assertEqual(n, len(short_sample))
- # Python 2.x
- b_sample = (ord(s) for s in sample)
- self.assertEqual(list(b), list(b_sample))
+ self.assertEqual(list(b), list(sample))
# Test writing in binary mode
with open(tfn, "wb") as f:
f.write(b)
@@ -568,7 +638,7 @@ class ByteArrayTest(BaseBytesTest):
def by(s):
return bytearray(map(ord, s))
b = by("Hello, world")
- self.assertEqual(re.findall(r"\w+", b), [by("Hello"), by("world")])
+ self.assertEqual(re.findall(br"\w+", b), [by("Hello"), by("world")])
def test_setitem(self):
b = bytearray([1, 2, 3])
@@ -644,10 +714,8 @@ class ByteArrayTest(BaseBytesTest):
b[3:4] = []
self.assertEqual(b, bytearray([102, 111, 111, 111, 111]))
- b[1:] = list(b'uuuu') # this works only on Python2
- self.assertEqual(b, bytearray([102, 117, 117, 117, 117]))
-
- for elem in [5, -5, 0, long(10e20), u'str', 2.3, [u'a', u'b'], [[]]]:
+ for elem in [5, -5, 0, int(10e20), 'str', 2.3,
+ ['a', 'b'], [b'a', b'b'], [[]]]:
with self.assertRaises(TypeError):
b[3:4] = elem
@@ -692,7 +760,7 @@ class ByteArrayTest(BaseBytesTest):
b += b"xyz"
self.assertEqual(b, b"abcdefxyz")
try:
- b += u""
+ b += ""
except TypeError:
pass
else:
@@ -734,16 +802,16 @@ class ByteArrayTest(BaseBytesTest):
self.assertEqual(a[5:], orig)
a = bytearray(b'')
# Test iterators that don't have a __length_hint__
- a.extend(map(ord, orig * 25))
- a.extend(ord(x) for x in orig * 25)
+ a.extend(map(int, orig * 25))
+ a.extend(int(x) for x in orig * 25)
self.assertEqual(a, orig * 50)
self.assertEqual(a[-5:], orig)
a = bytearray(b'')
- a.extend(iter(map(ord, orig * 50)))
+ a.extend(iter(map(int, orig * 50)))
self.assertEqual(a, orig * 50)
self.assertEqual(a[-5:], orig)
a = bytearray(b'')
- a.extend(list(map(ord, orig * 50)))
+ a.extend(list(map(int, orig * 50)))
self.assertEqual(a, orig * 50)
self.assertEqual(a[-5:], orig)
a = bytearray(b'')
@@ -762,12 +830,12 @@ class ByteArrayTest(BaseBytesTest):
self.assertEqual(b, b'heo')
self.assertRaises(ValueError, lambda: b.remove(ord('l')))
self.assertRaises(ValueError, lambda: b.remove(400))
- self.assertRaises(TypeError, lambda: b.remove(u'e'))
+ self.assertRaises(TypeError, lambda: b.remove('e'))
# remove first and last
b.remove(ord('o'))
b.remove(ord('h'))
self.assertEqual(b, b'e')
- self.assertRaises(TypeError, lambda: b.remove(u'e'))
+ self.assertRaises(TypeError, lambda: b.remove(b'e'))
b.remove(Indexable(ord('e')))
self.assertEqual(b, b'')
@@ -792,7 +860,7 @@ class ByteArrayTest(BaseBytesTest):
b = bytearray()
b.append(ord('A'))
self.assertEqual(len(b), 1)
- self.assertRaises(TypeError, lambda: b.append(u'o'))
+ self.assertRaises(TypeError, lambda: b.append(b'o'))
b = bytearray()
b.append(Indexable(ord('A')))
self.assertEqual(b, b'A')
@@ -804,8 +872,7 @@ class ByteArrayTest(BaseBytesTest):
b.insert(-2, ord('i'))
b.insert(1000, ord('i'))
self.assertEqual(b, b'mississippi')
- # allowed in 2.x
- #self.assertRaises(TypeError, lambda: b.insert(0, b'1'))
+ self.assertRaises(TypeError, lambda: b.insert(0, b'1'))
b = bytearray()
b.insert(0, Indexable(ord('A')))
self.assertEqual(b, b'A')
@@ -873,12 +940,6 @@ class ByteArrayTest(BaseBytesTest):
self.assertRaises(BufferError, delslice)
self.assertEqual(b, orig)
- def test_empty_bytearray(self):
- # Issue #7561: operations on empty bytearrays could crash in many
- # situations, due to a fragile implementation of the
- # PyByteArray_AS_STRING() C macro.
- self.assertRaises(ValueError, int, bytearray(b''))
-
class AssortedBytesTest(unittest.TestCase):
#
@@ -983,6 +1044,26 @@ class AssortedBytesTest(unittest.TestCase):
def test_rsplit_bytearray(self):
self.assertEqual(b'a b'.rsplit(memoryview(b' ')), [b'a', b'b'])
+ def test_return_self(self):
+ # bytearray.replace must always return a new bytearray
+ b = bytearray()
+ self.assertFalse(b.replace(b'', b'') is b)
+
+ def test_compare(self):
+ if sys.flags.bytes_warning:
+ def bytes_warning():
+ return test.support.check_warnings(('', BytesWarning))
+ with bytes_warning():
+ b'' == ''
+ with bytes_warning():
+ b'' != ''
+ with bytes_warning():
+ bytearray(b'') == ''
+ with bytes_warning():
+ bytearray(b'') != ''
+ else:
+ self.skipTest("BytesWarning is needed for this test: use -bb option")
+
# Optimizations:
# __iter__? (optimization)
# __reversed__? (optimization)
@@ -1014,8 +1095,8 @@ class BytearrayPEP3137Test(unittest.TestCase,
self.assertTrue(val is not newval,
methname+' returned self on a mutable object')
for expr in ('val.split()[0]', 'val.rsplit()[0]',
- 'val.partition(".")[0]', 'val.rpartition(".")[2]',
- 'val.splitlines()[0]', 'val.replace("", "")'):
+ 'val.partition(b".")[0]', 'val.rpartition(b".")[2]',
+ 'val.splitlines()[0]', 'val.replace(b"", b"")'):
newval = eval(expr)
self.assertEqual(val, newval)
self.assertTrue(val is not newval,
@@ -1026,7 +1107,7 @@ class FixedStringTest(test.string_tests.BaseTest):
def fixtype(self, obj):
if isinstance(obj, str):
return obj.encode("utf-8")
- return super(FixedStringTest, self).fixtype(obj)
+ return super().fixtype(obj)
# Currently the bytes containment testing uses a single integer
# value. This may not be the final design, but until then the
@@ -1039,26 +1120,22 @@ class FixedStringTest(test.string_tests.BaseTest):
pass
def test_lower(self):
pass
- def test_hash(self):
- # XXX check this out
- pass
-
class ByteArrayAsStringTest(FixedStringTest):
type2test = bytearray
+class BytesAsStringTest(FixedStringTest):
+ type2test = bytes
-class ByteArraySubclass(bytearray):
- pass
-class ByteArraySubclassTest(unittest.TestCase):
+class SubclassTest(unittest.TestCase):
def test_basic(self):
- self.assertTrue(issubclass(ByteArraySubclass, bytearray))
- self.assertIsInstance(ByteArraySubclass(), bytearray)
+ self.assertTrue(issubclass(self.subclass2test, self.type2test))
+ self.assertIsInstance(self.subclass2test(), self.type2test)
a, b = b"abcd", b"efgh"
- _a, _b = ByteArraySubclass(a), ByteArraySubclass(b)
+ _a, _b = self.subclass2test(a), self.subclass2test(b)
# test comparison operators with subclass instances
self.assertTrue(_a == _a)
@@ -1081,19 +1158,19 @@ class ByteArraySubclassTest(unittest.TestCase):
# Make sure join returns a NEW object for single item sequences
# involving a subclass.
# Make sure that it is of the appropriate type.
- s1 = ByteArraySubclass(b"abcd")
- s2 = bytearray().join([s1])
+ s1 = self.subclass2test(b"abcd")
+ s2 = self.type2test().join([s1])
self.assertTrue(s1 is not s2)
- self.assertTrue(type(s2) is bytearray, type(s2))
+ self.assertTrue(type(s2) is self.type2test, type(s2))
# Test reverse, calling join on subclass
s3 = s1.join([b"abcd"])
- self.assertTrue(type(s3) is bytearray)
+ self.assertTrue(type(s3) is self.type2test)
def test_pickle(self):
- a = ByteArraySubclass(b"abcd")
+ a = self.subclass2test(b"abcd")
a.x = 10
- a.y = ByteArraySubclass(b"efgh")
+ a.y = self.subclass2test(b"efgh")
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
b = pickle.loads(pickle.dumps(a, proto))
self.assertNotEqual(id(a), id(b))
@@ -1104,9 +1181,9 @@ class ByteArraySubclassTest(unittest.TestCase):
self.assertEqual(type(a.y), type(b.y))
def test_copy(self):
- a = ByteArraySubclass(b"abcd")
+ a = self.subclass2test(b"abcd")
a.x = 10
- a.y = ByteArraySubclass(b"efgh")
+ a.y = self.subclass2test(b"efgh")
for copy_method in (copy.copy, copy.deepcopy):
b = copy_method(a)
self.assertNotEqual(id(a), id(b))
@@ -1116,24 +1193,38 @@ class ByteArraySubclassTest(unittest.TestCase):
self.assertEqual(type(a), type(b))
self.assertEqual(type(a.y), type(b.y))
+
+class ByteArraySubclass(bytearray):
+ pass
+
+class BytesSubclass(bytes):
+ pass
+
+class ByteArraySubclassTest(SubclassTest):
+ type2test = bytearray
+ subclass2test = ByteArraySubclass
+
def test_init_override(self):
class subclass(bytearray):
- def __init__(self, newarg=1, *args, **kwargs):
- bytearray.__init__(self, *args, **kwargs)
+ def __init__(me, newarg=1, *args, **kwargs):
+ bytearray.__init__(me, *args, **kwargs)
+ x = subclass(4, b"abcd")
x = subclass(4, source=b"abcd")
self.assertEqual(x, b"abcd")
x = subclass(newarg=4, source=b"abcd")
self.assertEqual(x, b"abcd")
+
+class BytesSubclassTest(SubclassTest):
+ type2test = bytes
+ subclass2test = BytesSubclass
+
+
def test_main():
- #test.test_support.run_unittest(BytesTest)
- #test.test_support.run_unittest(AssortedBytesTest)
- #test.test_support.run_unittest(BytesAsStringTest)
- test.test_support.run_unittest(
- ByteArrayTest,
- ByteArrayAsStringTest,
- ByteArraySubclassTest,
- BytearrayPEP3137Test)
+ test.support.run_unittest(
+ BytesTest, AssortedBytesTest, BytesAsStringTest,
+ ByteArrayTest, ByteArrayAsStringTest, BytesSubclassTest,
+ ByteArraySubclassTest, BytearrayPEP3137Test)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_bz2.py b/Lib/test/test_bz2.py
index 8a5ae55cd39..5b48e2b6fba 100644
--- a/Lib/test/test_bz2.py
+++ b/Lib/test/test_bz2.py
@@ -1,9 +1,9 @@
-#!/usr/bin/env python
-from test import test_support
-from test.test_support import TESTFN, _4G, bigmemtest, import_module, findfile
+#!/usr/bin/env python3
+from test import support
+from test.support import TESTFN, _4G, bigmemtest, findfile
import unittest
-from cStringIO import StringIO
+from io import BytesIO
import os
import subprocess
import sys
@@ -13,16 +13,17 @@ try:
except ImportError:
threading = None
-bz2 = import_module('bz2')
+# Skip tests if the bz2 module doesn't exist.
+bz2 = support.import_module('bz2')
from bz2 import BZ2File, BZ2Compressor, BZ2Decompressor
-has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx", "riscos")
+has_cmdline_bunzip2 = sys.platform not in ("win32", "os2emx")
class BaseTest(unittest.TestCase):
"Base for other testcases."
- TEXT = 'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n'
- DATA = 'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2<Q\xb5\x0fH\xd3\xd4\xdd\xd5\x87\xbb\xf8\x94\r\x8f\xafI\x12\xe1\xc9\xf8/E\x00pu\x89\x12]\xc9\xbbDL\nQ\x0e\t1\x12\xdf\xa0\xc0\x97\xac2O9\x89\x13\x94\x0e\x1c7\x0ed\x95I\x0c\xaaJ\xa4\x18L\x10\x05#\x9c\xaf\xba\xbc/\x97\x8a#C\xc8\xe1\x8cW\xf9\xe2\xd0\xd6M\xa7\x8bXa<e\x84t\xcbL\xb3\xa7\xd9\xcd\xd1\xcb\x84.\xaf\xb3\xab\xab\xad`n}\xa0lh\tE,\x8eZ\x15\x17VH>\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`'
- DATA_CRLF = 'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1<l\xba\xcb_\xc00xY\x17r\x17\x88\x08\x08@\xa0\ry@\x10\x04$)`\xf2\xce\x89z\xb0s\xec\x9b.iW\x9d\x81\xb5-+t\x9f\x1a\'\x97dB\xf5x\xb5\xbe.[.\xd7\x0e\x81\xe7\x08\x1cN`\x88\x10\xca\x87\xc3!"\x80\x92R\xa1/\xd1\xc0\xe6mf\xac\xbd\x99\xcca\xb3\x8780>\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80'
+ TEXT = b'root:x:0:0:root:/root:/bin/bash\nbin:x:1:1:bin:/bin:\ndaemon:x:2:2:daemon:/sbin:\nadm:x:3:4:adm:/var/adm:\nlp:x:4:7:lp:/var/spool/lpd:\nsync:x:5:0:sync:/sbin:/bin/sync\nshutdown:x:6:0:shutdown:/sbin:/sbin/shutdown\nhalt:x:7:0:halt:/sbin:/sbin/halt\nmail:x:8:12:mail:/var/spool/mail:\nnews:x:9:13:news:/var/spool/news:\nuucp:x:10:14:uucp:/var/spool/uucp:\noperator:x:11:0:operator:/root:\ngames:x:12:100:games:/usr/games:\ngopher:x:13:30:gopher:/usr/lib/gopher-data:\nftp:x:14:50:FTP User:/var/ftp:/bin/bash\nnobody:x:65534:65534:Nobody:/home:\npostfix:x:100:101:postfix:/var/spool/postfix:\nniemeyer:x:500:500::/home/niemeyer:/bin/bash\npostgres:x:101:102:PostgreSQL Server:/var/lib/pgsql:/bin/bash\nmysql:x:102:103:MySQL server:/var/lib/mysql:/bin/bash\nwww:x:103:104::/var/www:/bin/false\n'
+ DATA = b'BZh91AY&SY.\xc8N\x18\x00\x01>_\x80\x00\x10@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe00\x01\x99\xaa\x00\xc0\x03F\x86\x8c#&\x83F\x9a\x03\x06\xa6\xd0\xa6\x93M\x0fQ\xa7\xa8\x06\x804hh\x12$\x11\xa4i4\xf14S\xd2<Q\xb5\x0fH\xd3\xd4\xdd\xd5\x87\xbb\xf8\x94\r\x8f\xafI\x12\xe1\xc9\xf8/E\x00pu\x89\x12]\xc9\xbbDL\nQ\x0e\t1\x12\xdf\xa0\xc0\x97\xac2O9\x89\x13\x94\x0e\x1c7\x0ed\x95I\x0c\xaaJ\xa4\x18L\x10\x05#\x9c\xaf\xba\xbc/\x97\x8a#C\xc8\xe1\x8cW\xf9\xe2\xd0\xd6M\xa7\x8bXa<e\x84t\xcbL\xb3\xa7\xd9\xcd\xd1\xcb\x84.\xaf\xb3\xab\xab\xad`n}\xa0lh\tE,\x8eZ\x15\x17VH>\x88\xe5\xcd9gd6\x0b\n\xe9\x9b\xd5\x8a\x99\xf7\x08.K\x8ev\xfb\xf7xw\xbb\xdf\xa1\x92\xf1\xdd|/";\xa2\xba\x9f\xd5\xb1#A\xb6\xf6\xb3o\xc9\xc5y\\\xebO\xe7\x85\x9a\xbc\xb6f8\x952\xd5\xd7"%\x89>V,\xf7\xa6z\xe2\x9f\xa3\xdf\x11\x11"\xd6E)I\xa9\x13^\xca\xf3r\xd0\x03U\x922\xf26\xec\xb6\xed\x8b\xc3U\x13\x9d\xc5\x170\xa4\xfa^\x92\xacDF\x8a\x97\xd6\x19\xfe\xdd\xb8\xbd\x1a\x9a\x19\xa3\x80ankR\x8b\xe5\xd83]\xa9\xc6\x08\x82f\xf6\xb9"6l$\xb8j@\xc0\x8a\xb0l1..\xbak\x83ls\x15\xbc\xf4\xc1\x13\xbe\xf8E\xb8\x9d\r\xa8\x9dk\x84\xd3n\xfa\xacQ\x07\xb1%y\xaav\xb4\x08\xe0z\x1b\x16\xf5\x04\xe9\xcc\xb9\x08z\x1en7.G\xfc]\xc9\x14\xe1B@\xbb!8`'
+ DATA_CRLF = b'BZh91AY&SY\xaez\xbbN\x00\x01H\xdf\x80\x00\x12@\x02\xff\xf0\x01\x07n\x00?\xe7\xff\xe0@\x01\xbc\xc6`\x86*\x8d=M\xa9\x9a\x86\xd0L@\x0fI\xa6!\xa1\x13\xc8\x88jdi\x8d@\x03@\x1a\x1a\x0c\x0c\x83 \x00\xc4h2\x19\x01\x82D\x84e\t\xe8\x99\x89\x19\x1ah\x00\r\x1a\x11\xaf\x9b\x0fG\xf5(\x1b\x1f?\t\x12\xcf\xb5\xfc\x95E\x00ps\x89\x12^\xa4\xdd\xa2&\x05(\x87\x04\x98\x89u\xe40%\xb6\x19\'\x8c\xc4\x89\xca\x07\x0e\x1b!\x91UIFU%C\x994!DI\xd2\xfa\xf0\xf1N8W\xde\x13A\xf5\x9cr%?\x9f3;I45A\xd1\x8bT\xb1<l\xba\xcb_\xc00xY\x17r\x17\x88\x08\x08@\xa0\ry@\x10\x04$)`\xf2\xce\x89z\xb0s\xec\x9b.iW\x9d\x81\xb5-+t\x9f\x1a\'\x97dB\xf5x\xb5\xbe.[.\xd7\x0e\x81\xe7\x08\x1cN`\x88\x10\xca\x87\xc3!"\x80\x92R\xa1/\xd1\xc0\xe6mf\xac\xbd\x99\xcca\xb3\x8780>\xa4\xc7\x8d\x1a\\"\xad\xa1\xabyBg\x15\xb9l\x88\x88\x91k"\x94\xa4\xd4\x89\xae*\xa6\x0b\x10\x0c\xd6\xd4m\xe86\xec\xb5j\x8a\x86j\';\xca.\x01I\xf2\xaaJ\xe8\x88\x8cU+t3\xfb\x0c\n\xa33\x13r2\r\x16\xe0\xb3(\xbf\x1d\x83r\xe7M\xf0D\x1365\xd8\x88\xd3\xa4\x92\xcb2\x06\x04\\\xc1\xb0\xea//\xbek&\xd8\xe6+t\xe5\xa1\x13\xada\x16\xder5"w]\xa2i\xb7[\x97R \xe2IT\xcd;Z\x04dk4\xad\x8a\t\xd3\x81z\x10\xf1:^`\xab\x1f\xc5\xdc\x91N\x14$+\x9e\xae\xd3\x80'
with open(findfile("testbz2_bigmem.bz2"), "rb") as f:
DATA_BIGMEM = f.read()
@@ -77,13 +78,13 @@ class BZ2FileTest(BaseTest):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.read, None)
- self.assertEqual(bz2f.read(0), "")
+ self.assertEqual(bz2f.read(0), b"")
def testReadChunk10(self):
# "Test BZ2File.read() in chunks of 10 bytes"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
- text = ''
+ text = b''
while 1:
str = bz2f.read(10)
if not str:
@@ -102,7 +103,7 @@ class BZ2FileTest(BaseTest):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readline, None)
- sio = StringIO(self.TEXT)
+ sio = BytesIO(self.TEXT)
for line in sio.readlines():
self.assertEqual(bz2f.readline(), line)
@@ -111,14 +112,14 @@ class BZ2FileTest(BaseTest):
self.createTempFile()
with BZ2File(self.filename) as bz2f:
self.assertRaises(TypeError, bz2f.readlines, None)
- sio = StringIO(self.TEXT)
+ sio = BytesIO(self.TEXT)
self.assertEqual(bz2f.readlines(), sio.readlines())
def testIterator(self):
# "Test iter(BZ2File)"
self.createTempFile()
with BZ2File(self.filename) as bz2f:
- sio = StringIO(self.TEXT)
+ sio = BytesIO(self.TEXT)
self.assertEqual(list(iter(bz2f)), sio.readlines())
def testClosedIteratorDeadlock(self):
@@ -127,35 +128,11 @@ class BZ2FileTest(BaseTest):
self.createTempFile()
bz2f = BZ2File(self.filename)
bz2f.close()
- self.assertRaises(ValueError, bz2f.next)
- # This call will deadlock of the above .next call failed to
+ self.assertRaises(ValueError, bz2f.__next__)
+ # This call will deadlock of the above .__next__ call failed to
# release the lock.
self.assertRaises(ValueError, bz2f.readlines)
- def testXReadLines(self):
- # "Test BZ2File.xreadlines()"
- self.createTempFile()
- bz2f = BZ2File(self.filename)
- sio = StringIO(self.TEXT)
- self.assertEqual(list(bz2f.xreadlines()), sio.readlines())
- bz2f.close()
-
- def testUniversalNewlinesLF(self):
- # "Test BZ2File.read() with universal newlines (\\n)"
- self.createTempFile()
- bz2f = BZ2File(self.filename, "rU")
- self.assertEqual(bz2f.read(), self.TEXT)
- self.assertEqual(bz2f.newlines, "\n")
- bz2f.close()
-
- def testUniversalNewlinesCRLF(self):
- # "Test BZ2File.read() with universal newlines (\\r\\n)"
- self.createTempFile(crlf=1)
- bz2f = BZ2File(self.filename, "rU")
- self.assertEqual(bz2f.read(), self.TEXT)
- self.assertEqual(bz2f.newlines, "\r\n")
- bz2f.close()
-
def testWrite(self):
# "Test BZ2File.write()"
with BZ2File(self.filename, "w") as bz2f:
@@ -181,7 +158,7 @@ class BZ2FileTest(BaseTest):
# "Test BZ2File.writelines()"
with BZ2File(self.filename, "w") as bz2f:
self.assertRaises(TypeError, bz2f.writelines)
- sio = StringIO(self.TEXT)
+ sio = BytesIO(self.TEXT)
bz2f.writelines(sio.readlines())
# patch #1535500
self.assertRaises(ValueError, bz2f.writelines, ["a"])
@@ -190,11 +167,11 @@ class BZ2FileTest(BaseTest):
def testWriteMethodsOnReadOnlyFile(self):
with BZ2File(self.filename, "w") as bz2f:
- bz2f.write("abc")
+ bz2f.write(b"abc")
with BZ2File(self.filename, "r") as bz2f:
- self.assertRaises(IOError, bz2f.write, "a")
- self.assertRaises(IOError, bz2f.writelines, ["a"])
+ self.assertRaises(IOError, bz2f.write, b"a")
+ self.assertRaises(IOError, bz2f.writelines, [b"a"])
def testSeekForward(self):
# "Test BZ2File.seek(150, 0)"
@@ -225,7 +202,7 @@ class BZ2FileTest(BaseTest):
with BZ2File(self.filename) as bz2f:
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
- self.assertEqual(bz2f.read(), "")
+ self.assertEqual(bz2f.read(), b"")
def testSeekPostEndTwice(self):
# "Test BZ2File.seek(150000) twice"
@@ -234,7 +211,7 @@ class BZ2FileTest(BaseTest):
bz2f.seek(150000)
bz2f.seek(150000)
self.assertEqual(bz2f.tell(), len(self.TEXT))
- self.assertEqual(bz2f.read(), "")
+ self.assertEqual(bz2f.read(), b"")
def testSeekPreStart(self):
# "Test BZ2File.seek(-150, 0)"
@@ -247,7 +224,7 @@ class BZ2FileTest(BaseTest):
def testOpenDel(self):
# "Test opening and deleting a file many times"
self.createTempFile()
- for i in xrange(10000):
+ for i in range(10000):
o = BZ2File(self.filename)
del o
@@ -255,27 +232,17 @@ class BZ2FileTest(BaseTest):
# "Test opening a nonexistent file"
self.assertRaises(IOError, BZ2File, "/non/existent")
- def testModeU(self):
- # Bug #1194181: bz2.BZ2File opened for write with mode "U"
- self.createTempFile()
- bz2f = BZ2File(self.filename, "U")
- bz2f.close()
- f = file(self.filename)
- f.seek(0, 2)
- self.assertEqual(f.tell(), len(self.DATA))
- f.close()
-
def testBug1191043(self):
# readlines() for files containing no newline
- data = 'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
+ data = b'BZh91AY&SY\xd9b\x89]\x00\x00\x00\x03\x80\x04\x00\x02\x00\x0c\x00 \x00!\x9ah3M\x13<]\xc9\x14\xe1BCe\x8a%t'
with open(self.filename, "wb") as f:
f.write(data)
with BZ2File(self.filename) as bz2f:
lines = bz2f.readlines()
- self.assertEqual(lines, ['Test'])
+ self.assertEqual(lines, [b'Test'])
with BZ2File(self.filename) as bz2f:
xlines = list(bz2f.readlines())
- self.assertEqual(xlines, ['Test'])
+ self.assertEqual(xlines, [b'Test'])
def testContextProtocol(self):
# BZ2File supports the context management protocol
@@ -293,16 +260,16 @@ class BZ2FileTest(BaseTest):
self.fail("__enter__ on a closed file didn't raise an exception")
try:
with BZ2File(self.filename, "wb") as f:
- 1 // 0
+ 1/0
except ZeroDivisionError:
pass
else:
- self.fail("1 // 0 didn't raise an exception")
+ self.fail("1/0 didn't raise an exception")
@unittest.skipUnless(threading, 'Threading required for this test.')
def testThreading(self):
# Using a BZ2File from several threads doesn't deadlock (issue #7205).
- data = "1" * 2**20
+ data = b"1" * 2**20
nthreads = 10
with bz2.BZ2File(self.filename, 'wb') as f:
def comp():
@@ -340,7 +307,7 @@ class BZ2CompressorTest(BaseTest):
# "Test BZ2Compressor.compress()/flush() with chunks of 10 bytes"
bz2c = BZ2Compressor()
n = 0
- data = ''
+ data = b''
while 1:
str = self.TEXT[n*10:(n+1)*10]
if not str:
@@ -350,15 +317,15 @@ class BZ2CompressorTest(BaseTest):
data += bz2c.flush()
self.assertEqual(self.decompress(data), self.TEXT)
- @bigmemtest(_4G, memuse=1.25)
+ @bigmemtest(size=_4G, memuse=1.25)
def testBigmem(self, size):
- text = "a" * size
+ text = b"a" * size
bz2c = bz2.BZ2Compressor()
data = bz2c.compress(text) + bz2c.flush()
del text
text = self.decompress(data)
self.assertEqual(len(text), size)
- self.assertEqual(text.strip("a"), "")
+ self.assertEqual(text.strip(b"a"), b"")
class BZ2DecompressorTest(BaseTest):
@@ -375,7 +342,7 @@ class BZ2DecompressorTest(BaseTest):
def testDecompressChunks10(self):
# "Test BZ2Decompressor.decompress() with chunks of 10 bytes"
bz2d = BZ2Decompressor()
- text = ''
+ text = b''
n = 0
while 1:
str = self.DATA[n*10:(n+1)*10]
@@ -388,7 +355,7 @@ class BZ2DecompressorTest(BaseTest):
def testDecompressUnusedData(self):
# "Test BZ2Decompressor.decompress() with unused data"
bz2d = BZ2Decompressor()
- unused_data = "this is unused data"
+ unused_data = b"this is unused data"
text = bz2d.decompress(self.DATA+unused_data)
self.assertEqual(text, self.TEXT)
self.assertEqual(bz2d.unused_data, unused_data)
@@ -397,17 +364,15 @@ class BZ2DecompressorTest(BaseTest):
# "Calling BZ2Decompressor.decompress() after EOS must raise EOFError"
bz2d = BZ2Decompressor()
text = bz2d.decompress(self.DATA)
- self.assertRaises(EOFError, bz2d.decompress, "anything")
- self.assertRaises(EOFError, bz2d.decompress, "")
+ self.assertRaises(EOFError, bz2d.decompress, b"anything")
+ self.assertRaises(EOFError, bz2d.decompress, b"")
- @bigmemtest(_4G, memuse=1.25)
- def testBigmem(self, size):
+ @bigmemtest(size=_4G, memuse=1.25, dry_run=False)
+ def testBigmem(self, unused_size):
# Issue #14398: decompression fails when output data is >=2GB.
- if size < _4G:
- self.skipTest("Test needs 5GB of memory to run.")
text = bz2.BZ2Decompressor().decompress(self.DATA_BIGMEM)
self.assertEqual(len(text), _4G)
- self.assertEqual(text.strip("\0"), "")
+ self.assertEqual(text.strip(b"\0"), b"")
class FuncTest(BaseTest):
@@ -425,39 +390,37 @@ class FuncTest(BaseTest):
def testDecompressEmpty(self):
# "Test decompress() function with empty string"
- text = bz2.decompress("")
- self.assertEqual(text, "")
+ text = bz2.decompress(b"")
+ self.assertEqual(text, b"")
def testDecompressIncomplete(self):
# "Test decompress() function with incomplete data"
self.assertRaises(ValueError, bz2.decompress, self.DATA[:-10])
- @bigmemtest(_4G, memuse=1.25)
+ @bigmemtest(size=_4G, memuse=1.25)
def testCompressBigmem(self, size):
- text = "a" * size
+ text = b"a" * size
data = bz2.compress(text)
del text
text = self.decompress(data)
self.assertEqual(len(text), size)
- self.assertEqual(text.strip("a"), "")
+ self.assertEqual(text.strip(b"a"), b"")
- @bigmemtest(_4G, memuse=1.25)
- def testDecompressBigmem(self, size):
+ @bigmemtest(size=_4G, memuse=1.25, dry_run=False)
+ def testDecompressBigmem(self, unused_size):
# Issue #14398: decompression fails when output data is >=2GB.
- if size < _4G:
- self.skipTest("Test needs 5GB of memory to run.")
text = bz2.decompress(self.DATA_BIGMEM)
self.assertEqual(len(text), _4G)
- self.assertEqual(text.strip("\0"), "")
+ self.assertEqual(text.strip(b"\0"), b"")
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
BZ2FileTest,
BZ2CompressorTest,
BZ2DecompressorTest,
FuncTest
)
- test_support.reap_children()
+ support.reap_children()
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_calendar.py b/Lib/test/test_calendar.py
index 0f91d295903..948a1197b9c 100644
--- a/Lib/test/test_calendar.py
+++ b/Lib/test/test_calendar.py
@@ -1,11 +1,12 @@
import calendar
import unittest
-from test import test_support
+from test import support
+from test.script_helper import assert_python_ok
+import time
import locale
import datetime
-
result_2004_text = """
2004
@@ -196,9 +197,11 @@ class OutputTestCase(unittest.TestCase):
)
def test_output_htmlcalendar(self):
+ encoding = 'ascii'
+ cal = calendar.HTMLCalendar()
self.assertEqual(
- calendar.HTMLCalendar().formatyearpage(2004).strip(),
- result_2004_html.strip()
+ cal.formatyearpage(2004, encoding=encoding).strip(b' \t\n'),
+ result_2004_html.strip(' \t\n').encode(encoding)
)
@@ -214,7 +217,7 @@ class CalendarTestCase(unittest.TestCase):
self.assertEqual(calendar.isleap(2003), 0)
def test_setfirstweekday(self):
- self.assertRaises(ValueError, calendar.setfirstweekday, 'flabber')
+ self.assertRaises(TypeError, calendar.setfirstweekday, 'flabber')
self.assertRaises(ValueError, calendar.setfirstweekday, -1)
self.assertRaises(ValueError, calendar.setfirstweekday, 200)
orig = calendar.firstweekday()
@@ -280,7 +283,7 @@ class MonthCalendarTestCase(unittest.TestCase):
def check_weeks(self, year, month, weeks):
cal = calendar.monthcalendar(year, month)
self.assertEqual(len(cal), len(weeks))
- for i in xrange(len(weeks)):
+ for i in range(len(weeks)):
self.assertEqual(weeks[i], sum(day != 0 for day in cal[i]))
@@ -399,6 +402,13 @@ class SundayTestCase(MonthCalendarTestCase):
# A 31-day december starting on friday (2+7+7+7+7+1 days)
self.check_weeks(1995, 12, (2, 7, 7, 7, 7, 1))
+class TimegmTestCase(unittest.TestCase):
+ TIMESTAMPS = [0, 10, 100, 1000, 10000, 100000, 1000000,
+ 1234567890, 1262304000, 1275785153,]
+ def test_timegm(self):
+ for secs in self.TIMESTAMPS:
+ tuple = time.gmtime(secs)
+ self.assertEqual(secs, calendar.timegm(tuple))
class MonthRangeTestCase(unittest.TestCase):
def test_january(self):
@@ -448,14 +458,21 @@ class LeapdaysTestCase(unittest.TestCase):
self.assertEqual(calendar.leapdays(1997,2020), 5)
+class ConsoleOutputTestCase(unittest.TestCase):
+ def test_outputs_bytes(self):
+ (return_code, stdout, stderr) = assert_python_ok('-m', 'calendar', '--type=html', '2010')
+ self.assertEqual(stdout[:6], b'<?xml ')
+
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
OutputTestCase,
CalendarTestCase,
MondayTestCase,
SundayTestCase,
+ TimegmTestCase,
MonthRangeTestCase,
LeapdaysTestCase,
+ ConsoleOutputTestCase
)
diff --git a/Lib/test/test_call.py b/Lib/test/test_call.py
index d06c2c94c53..c00ccbac85b 100644
--- a/Lib/test/test_call.py
+++ b/Lib/test/test_call.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support
+from test import support
# The test cases here cover several paths through the function calling
# code. They depend on the METH_XXX flag that is used to define a C
@@ -9,42 +9,39 @@ from test import test_support
class CFunctionCalls(unittest.TestCase):
def test_varargs0(self):
- self.assertRaises(TypeError, {}.has_key)
+ self.assertRaises(TypeError, {}.__contains__)
def test_varargs1(self):
- with test_support.check_py3k_warnings():
- {}.has_key(0)
+ {}.__contains__(0)
def test_varargs2(self):
- self.assertRaises(TypeError, {}.has_key, 0, 1)
+ self.assertRaises(TypeError, {}.__contains__, 0, 1)
def test_varargs0_ext(self):
try:
- {}.has_key(*())
+ {}.__contains__(*())
except TypeError:
pass
def test_varargs1_ext(self):
- with test_support.check_py3k_warnings():
- {}.has_key(*(0,))
+ {}.__contains__(*(0,))
def test_varargs2_ext(self):
try:
- with test_support.check_py3k_warnings():
- {}.has_key(*(1, 2))
+ {}.__contains__(*(1, 2))
except TypeError:
pass
else:
raise RuntimeError
def test_varargs0_kw(self):
- self.assertRaises(TypeError, {}.has_key, x=2)
+ self.assertRaises(TypeError, {}.__contains__, x=2)
def test_varargs1_kw(self):
- self.assertRaises(TypeError, {}.has_key, x=2)
+ self.assertRaises(TypeError, {}.__contains__, x=2)
def test_varargs2_kw(self):
- self.assertRaises(TypeError, {}.has_key, x=2, y=2)
+ self.assertRaises(TypeError, {}.__contains__, x=2, y=2)
def test_oldargs0_0(self):
{}.keys()
@@ -127,7 +124,7 @@ class CFunctionCalls(unittest.TestCase):
def test_main():
- test_support.run_unittest(CFunctionCalls)
+ support.run_unittest(CFunctionCalls)
if __name__ == "__main__":
diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
index 7dec2de655f..4d931f8d3c6 100644
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -2,17 +2,90 @@
# these are all functions _testcapi exports whose name begins with 'test_'.
from __future__ import with_statement
+import os
+import pickle
+import random
+import subprocess
import sys
import time
-import random
import unittest
-from test import test_support
+from test import support
+try:
+ import _posixsubprocess
+except ImportError:
+ _posixsubprocess = None
try:
import threading
except ImportError:
threading = None
import _testcapi
+
+def testfunction(self):
+ """some doc"""
+ return self
+
+class InstanceMethod:
+ id = _testcapi.instancemethod(id)
+ testfunction = _testcapi.instancemethod(testfunction)
+
+class CAPITest(unittest.TestCase):
+
+ def test_instancemethod(self):
+ inst = InstanceMethod()
+ self.assertEqual(id(inst), inst.id())
+ self.assertTrue(inst.testfunction() is inst)
+ self.assertEqual(inst.testfunction.__doc__, testfunction.__doc__)
+ self.assertEqual(InstanceMethod.testfunction.__doc__, testfunction.__doc__)
+
+ InstanceMethod.testfunction.attribute = "test"
+ self.assertEqual(testfunction.attribute, "test")
+ self.assertRaises(AttributeError, setattr, inst.testfunction, "attribute", "test")
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_no_FatalError_infinite_loop(self):
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import _testcapi;'
+ '_testcapi.crash_no_current_thread()'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (out, err) = p.communicate()
+ self.assertEqual(out, b'')
+ # This used to cause an infinite loop.
+ self.assertEqual(err.rstrip(),
+ b'Fatal Python error:'
+ b' PyThreadState_Get: no current thread')
+
+ def test_memoryview_from_NULL_pointer(self):
+ self.assertRaises(ValueError, _testcapi.make_memoryview_from_NULL_pointer)
+
+ @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.')
+ def test_seq_bytes_to_charp_array(self):
+ # Issue #15732: crash in _PySequence_BytesToCharpArray()
+ class Z(object):
+ def __len__(self):
+ return 1
+ self.assertRaises(TypeError, _posixsubprocess.fork_exec,
+ 1,Z(),3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
+ # Issue #15736: overflow in _PySequence_BytesToCharpArray()
+ class Z(object):
+ def __len__(self):
+ return sys.maxsize
+ def __getitem__(self, i):
+ return b'x'
+ self.assertRaises(MemoryError, _posixsubprocess.fork_exec,
+ 1,Z(),3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
+
+ @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.')
+ def test_subprocess_fork_exec(self):
+ class Z(object):
+ def __len__(self):
+ return 1
+
+ # Issue #15738: crash in subprocess_fork_exec()
+ self.assertRaises(TypeError, _posixsubprocess.fork_exec,
+ Z(),[b'1'],3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
+
@unittest.skipUnless(threading, 'Threading required for this test.')
class TestPendingCalls(unittest.TestCase):
@@ -38,19 +111,20 @@ class TestPendingCalls(unittest.TestCase):
#this busy loop is where we expect to be interrupted to
#run our callbacks. Note that callbacks are only run on the
#main thread
- if False and test_support.verbose:
- print "(%i)"%(len(l),),
- for i in xrange(1000):
+ if False and support.verbose:
+ print("(%i)"%(len(l),),)
+ for i in range(1000):
a = i*i
if context and not context.event.is_set():
continue
count += 1
self.assertTrue(count < 10000,
"timeout waiting for %i callbacks, got %i"%(n, len(l)))
- if False and test_support.verbose:
- print "(%i)"%(len(l),)
+ if False and support.verbose:
+ print("(%i)"%(len(l),))
def test_pendingcalls_threaded(self):
+
#do every callback on a separate thread
n = 32 #total callbacks
threads = []
@@ -80,8 +154,8 @@ class TestPendingCalls(unittest.TestCase):
with context.lock:
context.nFinished += 1
nFinished = context.nFinished
- if False and test_support.verbose:
- print "finished threads: ", nFinished
+ if False and support.verbose:
+ print("finished threads: ", nFinished)
if nFinished == context.nThreads:
context.event.set()
@@ -95,46 +169,96 @@ class TestPendingCalls(unittest.TestCase):
self.pendingcalls_submit(l, n)
self.pendingcalls_wait(l, n)
+ def test_subinterps(self):
+ # XXX this test leaks in refleak runs
+ import builtins
+ r, w = os.pipe()
+ code = """if 1:
+ import sys, builtins, pickle
+ with open({:d}, "wb") as f:
+ pickle.dump(id(sys.modules), f)
+ pickle.dump(id(builtins), f)
+ """.format(w)
+ with open(r, "rb") as f:
+ ret = _testcapi.run_in_subinterp(code)
+ self.assertEqual(ret, 0)
+ self.assertNotEqual(pickle.load(f), id(sys.modules))
+ self.assertNotEqual(pickle.load(f), id(builtins))
+
+# Bug #6012
+class Test6012(unittest.TestCase):
+ def test(self):
+ self.assertEqual(_testcapi.argparsing("Hello", "World"), 1)
+
+
+class EmbeddingTest(unittest.TestCase):
+
+ @unittest.skipIf(
+ sys.platform.startswith('win'),
+ "test doesn't work under Windows")
+ def test_subinterps(self):
+ # XXX only tested under Unix checkouts
+ basepath = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
+ oldcwd = os.getcwd()
+ # This is needed otherwise we get a fatal error:
+ # "Py_Initialize: Unable to get the locale encoding
+ # LookupError: no codec search functions registered: can't find encoding"
+ os.chdir(basepath)
+ try:
+ exe = os.path.join(basepath, "Modules", "_testembed")
+ if not os.path.exists(exe):
+ self.skipTest("%r doesn't exist" % exe)
+ p = subprocess.Popen([exe],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ (out, err) = p.communicate()
+ self.assertEqual(p.returncode, 0,
+ "bad returncode %d, stderr is %r" %
+ (p.returncode, err))
+ if support.verbose:
+ print()
+ print(out.decode('latin1'))
+ print(err.decode('latin1'))
+ finally:
+ os.chdir(oldcwd)
+
def test_main():
+ support.run_unittest(CAPITest, TestPendingCalls, Test6012, EmbeddingTest)
for name in dir(_testcapi):
if name.startswith('test_'):
test = getattr(_testcapi, name)
- if test_support.verbose:
- print "internal", name
- try:
- test()
- except _testcapi.error:
- raise test_support.TestFailed, sys.exc_info()[1]
+ if support.verbose:
+ print("internal", name)
+ test()
# some extra thread-state tests driven via _testcapi
def TestThreadState():
- if test_support.verbose:
- print "auto-thread-state"
+ if support.verbose:
+ print("auto-thread-state")
idents = []
def callback():
- idents.append(thread.get_ident())
+ idents.append(_thread.get_ident())
_testcapi._test_thread_state(callback)
a = b = callback
time.sleep(1)
# Check our main thread is in the list exactly 3 times.
- if idents.count(thread.get_ident()) != 3:
- raise test_support.TestFailed, \
- "Couldn't find main thread correctly in the list"
+ if idents.count(_thread.get_ident()) != 3:
+ raise support.TestFailed(
+ "Couldn't find main thread correctly in the list")
if threading:
- import thread
+ import _thread
import time
TestThreadState()
- t=threading.Thread(target=TestThreadState)
+ t = threading.Thread(target=TestThreadState)
t.start()
t.join()
- test_support.run_unittest(TestPendingCalls)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_cd.py b/Lib/test/test_cd.py
deleted file mode 100755
index edaa82bf453..00000000000
--- a/Lib/test/test_cd.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#! /usr/bin/env python
-"""Whimpy test script for the cd module
- Roger E. Masse
-"""
-from test.test_support import verbose, import_module
-
-cd = import_module('cd')
-
-cdattrs = ['BLOCKSIZE', 'CDROM', 'DATASIZE', 'ERROR', 'NODISC', 'PAUSED', 'PLAYING', 'READY',
- 'STILL', '__doc__', '__name__', 'atime', 'audio', 'catalog', 'control', 'createparser', 'error',
- 'ident', 'index', 'msftoframe', 'open', 'pnum', 'ptime']
-
-
-# This is a very inobtrusive test for the existence of the cd module and all its
-# attributes. More comprehensive examples can be found in Demo/cd and
-# require that you have a CD and a CD ROM drive
-
-def test_main():
- # touch all the attributes of cd without doing anything
- if verbose:
- print 'Touching cd module attributes...'
- for attr in cdattrs:
- if verbose:
- print 'touching: ', attr
- getattr(cd, attr)
-
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py
index f0073f04af7..a6e905049fb 100644
--- a/Lib/test/test_cfgparser.py
+++ b/Lib/test/test_cfgparser.py
@@ -1,111 +1,249 @@
-import ConfigParser
-import StringIO
+import collections
+import configparser
+import io
import os
+import sys
+import textwrap
import unittest
-import UserDict
+import warnings
-from test import test_support
+from test import support
+class SortedDict(collections.UserDict):
-class SortedDict(UserDict.UserDict):
def items(self):
- result = self.data.items()
- result.sort()
- return result
+ return sorted(self.data.items())
def keys(self):
- result = self.data.keys()
- result.sort()
- return result
+ return sorted(self.data.keys())
def values(self):
- # XXX never used?
- result = self.items()
- return [i[1] for i in result]
+ return [i[1] for i in self.items()]
+
+ def iteritems(self):
+ return iter(self.items())
+
+ def iterkeys(self):
+ return iter(self.keys())
+
+ def itervalues(self):
+ return iter(self.values())
- def iteritems(self): return iter(self.items())
- def iterkeys(self): return iter(self.keys())
__iter__ = iterkeys
- def itervalues(self): return iter(self.values())
-class TestCaseBase(unittest.TestCase):
+class CfgParserTestCaseClass(unittest.TestCase):
allow_no_value = False
+ delimiters = ('=', ':')
+ comment_prefixes = (';', '#')
+ inline_comment_prefixes = (';', '#')
+ empty_lines_in_values = True
+ dict_type = configparser._default_dict
+ strict = False
+ default_section = configparser.DEFAULTSECT
+ interpolation = configparser._UNSET
def newconfig(self, defaults=None):
- if defaults is None:
- self.cf = self.config_class(allow_no_value=self.allow_no_value)
- else:
- self.cf = self.config_class(defaults,
- allow_no_value=self.allow_no_value)
- return self.cf
+ arguments = dict(
+ defaults=defaults,
+ allow_no_value=self.allow_no_value,
+ delimiters=self.delimiters,
+ comment_prefixes=self.comment_prefixes,
+ inline_comment_prefixes=self.inline_comment_prefixes,
+ empty_lines_in_values=self.empty_lines_in_values,
+ dict_type=self.dict_type,
+ strict=self.strict,
+ default_section=self.default_section,
+ interpolation=self.interpolation,
+ )
+ instance = self.config_class(**arguments)
+ return instance
def fromstring(self, string, defaults=None):
cf = self.newconfig(defaults)
- sio = StringIO.StringIO(string)
- cf.readfp(sio)
+ cf.read_string(string)
return cf
- def test_basic(self):
- config_string = (
- "[Foo Bar]\n"
- "foo=bar\n"
- "[Spacey Bar]\n"
- "foo = bar\n"
- "[Commented Bar]\n"
- "foo: bar ; comment\n"
- "[Long Line]\n"
- "foo: this line is much, much longer than my editor\n"
- " likes it.\n"
- "[Section\\with$weird%characters[\t]\n"
- "[Internationalized Stuff]\n"
- "foo[bg]: Bulgarian\n"
- "foo=Default\n"
- "foo[en]=English\n"
- "foo[de]=Deutsch\n"
- "[Spaces]\n"
- "key with spaces : value\n"
- "another with spaces = splat!\n"
- )
+class BasicTestCase(CfgParserTestCaseClass):
+
+ def basic_test(self, cf):
+ E = ['Commented Bar',
+ 'Foo Bar',
+ 'Internationalized Stuff',
+ 'Long Line',
+ 'Section\\with$weird%characters[\t',
+ 'Spaces',
+ 'Spacey Bar',
+ 'Spacey Bar From The Beginning',
+ 'Types',
+ ]
+
if self.allow_no_value:
- config_string += (
- "[NoValue]\n"
- "option-without-value\n"
- )
+ E.append('NoValue')
+ E.sort()
+ F = [('baz', 'qwe'), ('foo', 'bar3')]
- cf = self.fromstring(config_string)
+ # API access
L = cf.sections()
L.sort()
- E = [r'Commented Bar',
- r'Foo Bar',
- r'Internationalized Stuff',
- r'Long Line',
- r'Section\with$weird%characters[' '\t',
- r'Spaces',
- r'Spacey Bar',
- ]
- if self.allow_no_value:
- E.append(r'NoValue')
- E.sort()
eq = self.assertEqual
eq(L, E)
+ L = cf.items('Spacey Bar From The Beginning')
+ L.sort()
+ eq(L, F)
+
+ # mapping access
+ L = [section for section in cf]
+ L.sort()
+ E.append(self.default_section)
+ E.sort()
+ eq(L, E)
+ L = cf['Spacey Bar From The Beginning'].items()
+ L = sorted(list(L))
+ eq(L, F)
+ L = cf.items()
+ L = sorted(list(L))
+ self.assertEqual(len(L), len(E))
+ for name, section in L:
+ eq(name, section.name)
+ eq(cf.defaults(), cf[self.default_section])
# The use of spaces in the section names serves as a
# regression test for SourceForge bug #583248:
# http://www.python.org/sf/583248
- eq(cf.get('Foo Bar', 'foo'), 'bar')
- eq(cf.get('Spacey Bar', 'foo'), 'bar')
- eq(cf.get('Commented Bar', 'foo'), 'bar')
+
+ # API access
+ eq(cf.get('Foo Bar', 'foo'), 'bar1')
+ eq(cf.get('Spacey Bar', 'foo'), 'bar2')
+ eq(cf.get('Spacey Bar From The Beginning', 'foo'), 'bar3')
+ eq(cf.get('Spacey Bar From The Beginning', 'baz'), 'qwe')
+ eq(cf.get('Commented Bar', 'foo'), 'bar4')
+ eq(cf.get('Commented Bar', 'baz'), 'qwe')
eq(cf.get('Spaces', 'key with spaces'), 'value')
eq(cf.get('Spaces', 'another with spaces'), 'splat!')
+ eq(cf.getint('Types', 'int'), 42)
+ eq(cf.get('Types', 'int'), "42")
+ self.assertAlmostEqual(cf.getfloat('Types', 'float'), 0.44)
+ eq(cf.get('Types', 'float'), "0.44")
+ eq(cf.getboolean('Types', 'boolean'), False)
+ eq(cf.get('Types', '123'), 'strange but acceptable')
if self.allow_no_value:
eq(cf.get('NoValue', 'option-without-value'), None)
- self.assertNotIn('__name__', cf.options("Foo Bar"),
- '__name__ "option" should not be exposed by the API!')
-
- # Make sure the right things happen for remove_option();
- # added to include check for SourceForge bug #123324:
+ # test vars= and fallback=
+ eq(cf.get('Foo Bar', 'foo', fallback='baz'), 'bar1')
+ eq(cf.get('Foo Bar', 'foo', vars={'foo': 'baz'}), 'baz')
+ with self.assertRaises(configparser.NoSectionError):
+ cf.get('No Such Foo Bar', 'foo')
+ with self.assertRaises(configparser.NoOptionError):
+ cf.get('Foo Bar', 'no-such-foo')
+ eq(cf.get('No Such Foo Bar', 'foo', fallback='baz'), 'baz')
+ eq(cf.get('Foo Bar', 'no-such-foo', fallback='baz'), 'baz')
+ eq(cf.get('Spacey Bar', 'foo', fallback=None), 'bar2')
+ eq(cf.get('No Such Spacey Bar', 'foo', fallback=None), None)
+ eq(cf.getint('Types', 'int', fallback=18), 42)
+ eq(cf.getint('Types', 'no-such-int', fallback=18), 18)
+ eq(cf.getint('Types', 'no-such-int', fallback="18"), "18") # sic!
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getint('Types', 'no-such-int')
+ self.assertAlmostEqual(cf.getfloat('Types', 'float',
+ fallback=0.0), 0.44)
+ self.assertAlmostEqual(cf.getfloat('Types', 'no-such-float',
+ fallback=0.0), 0.0)
+ eq(cf.getfloat('Types', 'no-such-float', fallback="0.0"), "0.0") # sic!
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getfloat('Types', 'no-such-float')
+ eq(cf.getboolean('Types', 'boolean', fallback=True), False)
+ eq(cf.getboolean('Types', 'no-such-boolean', fallback="yes"),
+ "yes") # sic!
+ eq(cf.getboolean('Types', 'no-such-boolean', fallback=True), True)
+ with self.assertRaises(configparser.NoOptionError):
+ cf.getboolean('Types', 'no-such-boolean')
+ eq(cf.getboolean('No Such Types', 'boolean', fallback=True), True)
+ if self.allow_no_value:
+ eq(cf.get('NoValue', 'option-without-value', fallback=False), None)
+ eq(cf.get('NoValue', 'no-such-option-without-value',
+ fallback=False), False)
+
+ # mapping access
+ eq(cf['Foo Bar']['foo'], 'bar1')
+ eq(cf['Spacey Bar']['foo'], 'bar2')
+ section = cf['Spacey Bar From The Beginning']
+ eq(section.name, 'Spacey Bar From The Beginning')
+ self.assertIs(section.parser, cf)
+ with self.assertRaises(AttributeError):
+ section.name = 'Name is read-only'
+ with self.assertRaises(AttributeError):
+ section.parser = 'Parser is read-only'
+ eq(section['foo'], 'bar3')
+ eq(section['baz'], 'qwe')
+ eq(cf['Commented Bar']['foo'], 'bar4')
+ eq(cf['Commented Bar']['baz'], 'qwe')
+ eq(cf['Spaces']['key with spaces'], 'value')
+ eq(cf['Spaces']['another with spaces'], 'splat!')
+ eq(cf['Long Line']['foo'],
+ 'this line is much, much longer than my editor\nlikes it.')
+ if self.allow_no_value:
+ eq(cf['NoValue']['option-without-value'], None)
+ # test vars= and fallback=
+ eq(cf['Foo Bar'].get('foo', 'baz'), 'bar1')
+ eq(cf['Foo Bar'].get('foo', fallback='baz'), 'bar1')
+ eq(cf['Foo Bar'].get('foo', vars={'foo': 'baz'}), 'baz')
+ with self.assertRaises(KeyError):
+ cf['No Such Foo Bar']['foo']
+ with self.assertRaises(KeyError):
+ cf['Foo Bar']['no-such-foo']
+ with self.assertRaises(KeyError):
+ cf['No Such Foo Bar'].get('foo', fallback='baz')
+ eq(cf['Foo Bar'].get('no-such-foo', 'baz'), 'baz')
+ eq(cf['Foo Bar'].get('no-such-foo', fallback='baz'), 'baz')
+ eq(cf['Foo Bar'].get('no-such-foo'), None)
+ eq(cf['Spacey Bar'].get('foo', None), 'bar2')
+ eq(cf['Spacey Bar'].get('foo', fallback=None), 'bar2')
+ with self.assertRaises(KeyError):
+ cf['No Such Spacey Bar'].get('foo', None)
+ eq(cf['Types'].getint('int', 18), 42)
+ eq(cf['Types'].getint('int', fallback=18), 42)
+ eq(cf['Types'].getint('no-such-int', 18), 18)
+ eq(cf['Types'].getint('no-such-int', fallback=18), 18)
+ eq(cf['Types'].getint('no-such-int', "18"), "18") # sic!
+ eq(cf['Types'].getint('no-such-int', fallback="18"), "18") # sic!
+ eq(cf['Types'].getint('no-such-int'), None)
+ self.assertAlmostEqual(cf['Types'].getfloat('float', 0.0), 0.44)
+ self.assertAlmostEqual(cf['Types'].getfloat('float',
+ fallback=0.0), 0.44)
+ self.assertAlmostEqual(cf['Types'].getfloat('no-such-float', 0.0), 0.0)
+ self.assertAlmostEqual(cf['Types'].getfloat('no-such-float',
+ fallback=0.0), 0.0)
+ eq(cf['Types'].getfloat('no-such-float', "0.0"), "0.0") # sic!
+ eq(cf['Types'].getfloat('no-such-float', fallback="0.0"), "0.0") # sic!
+ eq(cf['Types'].getfloat('no-such-float'), None)
+ eq(cf['Types'].getboolean('boolean', True), False)
+ eq(cf['Types'].getboolean('boolean', fallback=True), False)
+ eq(cf['Types'].getboolean('no-such-boolean', "yes"), "yes") # sic!
+ eq(cf['Types'].getboolean('no-such-boolean', fallback="yes"),
+ "yes") # sic!
+ eq(cf['Types'].getboolean('no-such-boolean', True), True)
+ eq(cf['Types'].getboolean('no-such-boolean', fallback=True), True)
+ eq(cf['Types'].getboolean('no-such-boolean'), None)
+ if self.allow_no_value:
+ eq(cf['NoValue'].get('option-without-value', False), None)
+ eq(cf['NoValue'].get('option-without-value', fallback=False), None)
+ eq(cf['NoValue'].get('no-such-option-without-value', False), False)
+ eq(cf['NoValue'].get('no-such-option-without-value',
+ fallback=False), False)
+
+ # Make sure the right things happen for remove_section() and
+ # remove_option(); added to include check for SourceForge bug #123324.
+
+ cf[self.default_section]['this_value'] = '1'
+ cf[self.default_section]['that_value'] = '2'
+
+ # API access
+ self.assertTrue(cf.remove_section('Spaces'))
+ self.assertFalse(cf.has_option('Spaces', 'key with spaces'))
+ self.assertFalse(cf.remove_section('Spaces'))
+ self.assertFalse(cf.remove_section(self.default_section))
self.assertTrue(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report existence of option")
self.assertFalse(cf.has_option('Foo Bar', 'foo'),
@@ -113,26 +251,199 @@ class TestCaseBase(unittest.TestCase):
self.assertFalse(cf.remove_option('Foo Bar', 'foo'),
"remove_option() failed to report non-existence of option"
" that was removed")
+ self.assertTrue(cf.has_option('Foo Bar', 'this_value'))
+ self.assertFalse(cf.remove_option('Foo Bar', 'this_value'))
+ self.assertTrue(cf.remove_option(self.default_section, 'this_value'))
+ self.assertFalse(cf.has_option('Foo Bar', 'this_value'))
+ self.assertFalse(cf.remove_option(self.default_section, 'this_value'))
- self.assertRaises(ConfigParser.NoSectionError,
- cf.remove_option, 'No Such Section', 'foo')
+ with self.assertRaises(configparser.NoSectionError) as cm:
+ cf.remove_option('No Such Section', 'foo')
+ self.assertEqual(cm.exception.args, ('No Such Section',))
eq(cf.get('Long Line', 'foo'),
'this line is much, much longer than my editor\nlikes it.')
+ # mapping access
+ del cf['Types']
+ self.assertFalse('Types' in cf)
+ with self.assertRaises(KeyError):
+ del cf['Types']
+ with self.assertRaises(ValueError):
+ del cf[self.default_section]
+ del cf['Spacey Bar']['foo']
+ self.assertFalse('foo' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf['Spacey Bar']['foo']
+ self.assertTrue('that_value' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf['Spacey Bar']['that_value']
+ del cf[self.default_section]['that_value']
+ self.assertFalse('that_value' in cf['Spacey Bar'])
+ with self.assertRaises(KeyError):
+ del cf[self.default_section]['that_value']
+ with self.assertRaises(KeyError):
+ del cf['No Such Section']['foo']
+
+ # Don't add new asserts below in this method as most of the options
+ # and sections are now removed.
+
+ def test_basic(self):
+ config_string = """\
+[Foo Bar]
+foo{0[0]}bar1
+[Spacey Bar]
+foo {0[0]} bar2
+[Spacey Bar From The Beginning]
+ foo {0[0]} bar3
+ baz {0[0]} qwe
+[Commented Bar]
+foo{0[1]} bar4 {1[1]} comment
+baz{0[0]}qwe {1[0]}another one
+[Long Line]
+foo{0[1]} this line is much, much longer than my editor
+ likes it.
+[Section\\with$weird%characters[\t]
+[Internationalized Stuff]
+foo[bg]{0[1]} Bulgarian
+foo{0[0]}Default
+foo[en]{0[0]}English
+foo[de]{0[0]}Deutsch
+[Spaces]
+key with spaces {0[1]} value
+another with spaces {0[0]} splat!
+[Types]
+int {0[1]} 42
+float {0[0]} 0.44
+boolean {0[0]} NO
+123 {0[1]} strange but acceptable
+""".format(self.delimiters, self.comment_prefixes)
+ if self.allow_no_value:
+ config_string += (
+ "[NoValue]\n"
+ "option-without-value\n"
+ )
+ cf = self.fromstring(config_string)
+ self.basic_test(cf)
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateOptionError):
+ cf.read_string(textwrap.dedent("""\
+ [Duplicate Options Here]
+ option {0[0]} with a value
+ option {0[1]} with another value
+ """.format(self.delimiters)))
+ with self.assertRaises(configparser.DuplicateSectionError):
+ cf.read_string(textwrap.dedent("""\
+ [And Now For Something]
+ completely different {0[0]} True
+ [And Now For Something]
+ the larch {0[1]} 1
+ """.format(self.delimiters)))
+ else:
+ cf.read_string(textwrap.dedent("""\
+ [Duplicate Options Here]
+ option {0[0]} with a value
+ option {0[1]} with another value
+ """.format(self.delimiters)))
+
+ cf.read_string(textwrap.dedent("""\
+ [And Now For Something]
+ completely different {0[0]} True
+ [And Now For Something]
+ the larch {0[1]} 1
+ """.format(self.delimiters)))
+
+ def test_basic_from_dict(self):
+ config = {
+ "Foo Bar": {
+ "foo": "bar1",
+ },
+ "Spacey Bar": {
+ "foo": "bar2",
+ },
+ "Spacey Bar From The Beginning": {
+ "foo": "bar3",
+ "baz": "qwe",
+ },
+ "Commented Bar": {
+ "foo": "bar4",
+ "baz": "qwe",
+ },
+ "Long Line": {
+ "foo": "this line is much, much longer than my editor\nlikes "
+ "it.",
+ },
+ "Section\\with$weird%characters[\t": {
+ },
+ "Internationalized Stuff": {
+ "foo[bg]": "Bulgarian",
+ "foo": "Default",
+ "foo[en]": "English",
+ "foo[de]": "Deutsch",
+ },
+ "Spaces": {
+ "key with spaces": "value",
+ "another with spaces": "splat!",
+ },
+ "Types": {
+ "int": 42,
+ "float": 0.44,
+ "boolean": False,
+ 123: "strange but acceptable",
+ },
+ }
+ if self.allow_no_value:
+ config.update({
+ "NoValue": {
+ "option-without-value": None,
+ }
+ })
+ cf = self.newconfig()
+ cf.read_dict(config)
+ self.basic_test(cf)
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateSectionError):
+ cf.read_dict({
+ '1': {'key': 'value'},
+ 1: {'key2': 'value2'},
+ })
+ with self.assertRaises(configparser.DuplicateOptionError):
+ cf.read_dict({
+ "Duplicate Options Here": {
+ 'option': 'with a value',
+ 'OPTION': 'with another value',
+ },
+ })
+ else:
+ cf.read_dict({
+ 'section': {'key': 'value'},
+ 'SECTION': {'key2': 'value2'},
+ })
+ cf.read_dict({
+ "Duplicate Options Here": {
+ 'option': 'with a value',
+ 'OPTION': 'with another value',
+ },
+ })
+
def test_case_sensitivity(self):
cf = self.newconfig()
cf.add_section("A")
cf.add_section("a")
+ cf.add_section("B")
L = cf.sections()
L.sort()
eq = self.assertEqual
- eq(L, ["A", "a"])
+ eq(L, ["A", "B", "a"])
cf.set("a", "B", "value")
eq(cf.options("a"), ["b"])
eq(cf.get("a", "b"), "value",
"could not locate option, expecting case-insensitive option names")
+ with self.assertRaises(configparser.NoSectionError):
+ # section names are case-sensitive
+ cf.set("b", "A", "value")
self.assertTrue(cf.has_option("a", "b"))
+ self.assertFalse(cf.has_option("b", "b"))
cf.set("A", "A-B", "A-B value")
for opt in ("a-b", "A-b", "a-B", "A-B"):
self.assertTrue(
@@ -145,42 +456,104 @@ class TestCaseBase(unittest.TestCase):
# SF bug #432369:
cf = self.fromstring(
- "[MySection]\nOption: first line\n\tsecond line\n")
+ "[MySection]\nOption{} first line \n\tsecond line \n".format(
+ self.delimiters[0]))
eq(cf.options("MySection"), ["option"])
eq(cf.get("MySection", "Option"), "first line\nsecond line")
# SF bug #561822:
- cf = self.fromstring("[section]\nnekey=nevalue\n",
+ cf = self.fromstring("[section]\n"
+ "nekey{}nevalue\n".format(self.delimiters[0]),
defaults={"key":"value"})
self.assertTrue(cf.has_option("section", "Key"))
+ def test_case_sensitivity_mapping_access(self):
+ cf = self.newconfig()
+ cf["A"] = {}
+ cf["a"] = {"B": "value"}
+ cf["B"] = {}
+ L = [section for section in cf]
+ L.sort()
+ eq = self.assertEqual
+ elem_eq = self.assertCountEqual
+ eq(L, sorted(["A", "B", self.default_section, "a"]))
+ eq(cf["a"].keys(), {"b"})
+ eq(cf["a"]["b"], "value",
+ "could not locate option, expecting case-insensitive option names")
+ with self.assertRaises(KeyError):
+ # section names are case-sensitive
+ cf["b"]["A"] = "value"
+ self.assertTrue("b" in cf["a"])
+ cf["A"]["A-B"] = "A-B value"
+ for opt in ("a-b", "A-b", "a-B", "A-B"):
+ self.assertTrue(
+ opt in cf["A"],
+ "has_option() returned false for option which should exist")
+ eq(cf["A"].keys(), {"a-b"})
+ eq(cf["a"].keys(), {"b"})
+ del cf["a"]["B"]
+ elem_eq(cf["a"].keys(), {})
+
+ # SF bug #432369:
+ cf = self.fromstring(
+ "[MySection]\nOption{} first line \n\tsecond line \n".format(
+ self.delimiters[0]))
+ eq(cf["MySection"].keys(), {"option"})
+ eq(cf["MySection"]["Option"], "first line\nsecond line")
+
+ # SF bug #561822:
+ cf = self.fromstring("[section]\n"
+ "nekey{}nevalue\n".format(self.delimiters[0]),
+ defaults={"key":"value"})
+ self.assertTrue("Key" in cf["section"])
+
def test_default_case_sensitivity(self):
cf = self.newconfig({"foo": "Bar"})
self.assertEqual(
- cf.get("DEFAULT", "Foo"), "Bar",
+ cf.get(self.default_section, "Foo"), "Bar",
"could not locate option, expecting case-insensitive option names")
cf = self.newconfig({"Foo": "Bar"})
self.assertEqual(
- cf.get("DEFAULT", "Foo"), "Bar",
+ cf.get(self.default_section, "Foo"), "Bar",
"could not locate option, expecting case-insensitive defaults")
def test_parse_errors(self):
- self.newconfig()
- self.parse_error(ConfigParser.ParsingError,
- "[Foo]\n extra-spaces: splat\n")
- self.parse_error(ConfigParser.ParsingError,
- "[Foo]\n extra-spaces= splat\n")
- self.parse_error(ConfigParser.ParsingError,
- "[Foo]\n:value-without-option-name\n")
- self.parse_error(ConfigParser.ParsingError,
- "[Foo]\n=value-without-option-name\n")
- self.parse_error(ConfigParser.MissingSectionHeaderError,
- "No Section!\n")
-
- def parse_error(self, exc, src):
- sio = StringIO.StringIO(src)
- self.assertRaises(exc, self.cf.readfp, sio)
+ cf = self.newconfig()
+ self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n"
+ "{}val-without-opt-name\n".format(self.delimiters[0]))
+ self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n"
+ "{}val-without-opt-name\n".format(self.delimiters[1]))
+ e = self.parse_error(cf, configparser.MissingSectionHeaderError,
+ "No Section!\n")
+ self.assertEqual(e.args, ('<???>', 1, "No Section!\n"))
+ if not self.allow_no_value:
+ e = self.parse_error(cf, configparser.ParsingError,
+ "[Foo]\n wrong-indent\n")
+ self.assertEqual(e.args, ('<???>',))
+ # read_file on a real file
+ tricky = support.findfile("cfgparser.3")
+ if self.delimiters[0] == '=':
+ error = configparser.ParsingError
+ expected = (tricky,)
+ else:
+ error = configparser.MissingSectionHeaderError
+ expected = (tricky, 1,
+ ' # INI with as many tricky parts as possible\n')
+ with open(tricky, encoding='utf-8') as f:
+ e = self.parse_error(cf, error, f)
+ self.assertEqual(e.args, expected)
+
+ def parse_error(self, cf, exc, src):
+ if hasattr(src, 'readline'):
+ sio = src
+ else:
+ sio = io.StringIO(src)
+ with self.assertRaises(exc) as cm:
+ cf.read_file(sio)
+ return cm.exception
def test_query_errors(self):
cf = self.newconfig()
@@ -189,18 +562,20 @@ class TestCaseBase(unittest.TestCase):
self.assertFalse(cf.has_section("Foo"),
"new ConfigParser should have no acknowledged "
"sections")
- self.assertRaises(ConfigParser.NoSectionError,
- cf.options, "Foo")
- self.assertRaises(ConfigParser.NoSectionError,
- cf.set, "foo", "bar", "value")
- self.get_error(ConfigParser.NoSectionError, "foo", "bar")
+ with self.assertRaises(configparser.NoSectionError):
+ cf.options("Foo")
+ with self.assertRaises(configparser.NoSectionError):
+ cf.set("foo", "bar", "value")
+ e = self.get_error(cf, configparser.NoSectionError, "foo", "bar")
+ self.assertEqual(e.args, ("foo",))
cf.add_section("foo")
- self.get_error(ConfigParser.NoOptionError, "foo", "bar")
+ e = self.get_error(cf, configparser.NoOptionError, "foo", "bar")
+ self.assertEqual(e.args, ("bar", "foo"))
- def get_error(self, exc, section, option):
+ def get_error(self, cf, exc, section, option):
try:
- self.cf.get(section, option)
- except exc, e:
+ cf.get(section, option)
+ except exc as e:
return e
else:
self.fail("expected exception type %s.%s"
@@ -209,21 +584,21 @@ class TestCaseBase(unittest.TestCase):
def test_boolean(self):
cf = self.fromstring(
"[BOOLTEST]\n"
- "T1=1\n"
- "T2=TRUE\n"
- "T3=True\n"
- "T4=oN\n"
- "T5=yes\n"
- "F1=0\n"
- "F2=FALSE\n"
- "F3=False\n"
- "F4=oFF\n"
- "F5=nO\n"
- "E1=2\n"
- "E2=foo\n"
- "E3=-1\n"
- "E4=0.1\n"
- "E5=FALSE AND MORE"
+ "T1{equals}1\n"
+ "T2{equals}TRUE\n"
+ "T3{equals}True\n"
+ "T4{equals}oN\n"
+ "T5{equals}yes\n"
+ "F1{equals}0\n"
+ "F2{equals}FALSE\n"
+ "F3{equals}False\n"
+ "F4{equals}oFF\n"
+ "F5{equals}nO\n"
+ "E1{equals}2\n"
+ "E2{equals}foo\n"
+ "E3{equals}-1\n"
+ "E4{equals}0.1\n"
+ "E5{equals}FALSE AND MORE".format(equals=self.delimiters[0])
)
for x in range(1, 5):
self.assertTrue(cf.getboolean('BOOLTEST', 't%d' % x))
@@ -234,17 +609,49 @@ class TestCaseBase(unittest.TestCase):
def test_weird_errors(self):
cf = self.newconfig()
cf.add_section("Foo")
- self.assertRaises(ConfigParser.DuplicateSectionError,
- cf.add_section, "Foo")
+ with self.assertRaises(configparser.DuplicateSectionError) as cm:
+ cf.add_section("Foo")
+ e = cm.exception
+ self.assertEqual(str(e), "Section 'Foo' already exists")
+ self.assertEqual(e.args, ("Foo", None, None))
+
+ if self.strict:
+ with self.assertRaises(configparser.DuplicateSectionError) as cm:
+ cf.read_string(textwrap.dedent("""\
+ [Foo]
+ will this be added{equals}True
+ [Bar]
+ what about this{equals}True
+ [Foo]
+ oops{equals}this won't
+ """.format(equals=self.delimiters[0])), source='<foo-bar>')
+ e = cm.exception
+ self.assertEqual(str(e), "While reading from <foo-bar> [line 5]: "
+ "section 'Foo' already exists")
+ self.assertEqual(e.args, ("Foo", '<foo-bar>', 5))
+
+ with self.assertRaises(configparser.DuplicateOptionError) as cm:
+ cf.read_dict({'Bar': {'opt': 'val', 'OPT': 'is really `opt`'}})
+ e = cm.exception
+ self.assertEqual(str(e), "While reading from <dict>: option 'opt' "
+ "in section 'Bar' already exists")
+ self.assertEqual(e.args, ("Bar", "opt", "<dict>", None))
def test_write(self):
config_string = (
"[Long Line]\n"
- "foo: this line is much, much longer than my editor\n"
+ "foo{0[0]} this line is much, much longer than my editor\n"
" likes it.\n"
- "[DEFAULT]\n"
- "foo: another very\n"
+ "[{default_section}]\n"
+ "foo{0[1]} another very\n"
" long line\n"
+ "[Long Line - With Comments!]\n"
+ "test {0[1]} we {comment} can\n"
+ " also {comment} place\n"
+ " comments {comment} in\n"
+ " multiline {comment} values"
+ "\n".format(self.delimiters, comment=self.comment_prefixes[0],
+ default_section=self.default_section)
)
if self.allow_no_value:
config_string += (
@@ -253,29 +660,40 @@ class TestCaseBase(unittest.TestCase):
)
cf = self.fromstring(config_string)
- output = StringIO.StringIO()
- cf.write(output)
- expect_string = (
- "[DEFAULT]\n"
- "foo = another very\n"
- "\tlong line\n"
- "\n"
- "[Long Line]\n"
- "foo = this line is much, much longer than my editor\n"
- "\tlikes it.\n"
- "\n"
- )
- if self.allow_no_value:
- expect_string += (
- "[Valueless]\n"
- "option-without-value\n"
+ for space_around_delimiters in (True, False):
+ output = io.StringIO()
+ cf.write(output, space_around_delimiters=space_around_delimiters)
+ delimiter = self.delimiters[0]
+ if space_around_delimiters:
+ delimiter = " {} ".format(delimiter)
+ expect_string = (
+ "[{default_section}]\n"
+ "foo{equals}another very\n"
+ "\tlong line\n"
+ "\n"
+ "[Long Line]\n"
+ "foo{equals}this line is much, much longer than my editor\n"
+ "\tlikes it.\n"
"\n"
+ "[Long Line - With Comments!]\n"
+ "test{equals}we\n"
+ "\talso\n"
+ "\tcomments\n"
+ "\tmultiline\n"
+ "\n".format(equals=delimiter,
+ default_section=self.default_section)
)
- self.assertEqual(output.getvalue(), expect_string)
+ if self.allow_no_value:
+ expect_string += (
+ "[Valueless]\n"
+ "option-without-value\n"
+ "\n"
+ )
+ self.assertEqual(output.getvalue(), expect_string)
def test_set_string_types(self):
cf = self.fromstring("[sect]\n"
- "option1=foo\n")
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
# Check that we don't get an exception when setting values in
# an existing section using strings:
class mystr(str):
@@ -284,16 +702,14 @@ class TestCaseBase(unittest.TestCase):
cf.set("sect", "option1", mystr("splat"))
cf.set("sect", "option2", "splat")
cf.set("sect", "option2", mystr("splat"))
- try:
- unicode
- except NameError:
- pass
- else:
- cf.set("sect", "option1", unicode("splat"))
- cf.set("sect", "option2", unicode("splat"))
+ cf.set("sect", "option1", "splat")
+ cf.set("sect", "option2", "splat")
def test_read_returns_file_list(self):
- file1 = test_support.findfile("cfgparser.1")
+ if self.delimiters[0] != '=':
+ # skip reading the file if we're using an incompatible format
+ return
+ file1 = support.findfile("cfgparser.1")
# check when we pass a mix of readable and non-readable files:
cf = self.newconfig()
parsed_files = cf.read([file1, "nonexistent-file"])
@@ -317,104 +733,205 @@ class TestCaseBase(unittest.TestCase):
def get_interpolation_config(self):
return self.fromstring(
"[Foo]\n"
- "bar=something %(with1)s interpolation (1 step)\n"
- "bar9=something %(with9)s lots of interpolation (9 steps)\n"
- "bar10=something %(with10)s lots of interpolation (10 steps)\n"
- "bar11=something %(with11)s lots of interpolation (11 steps)\n"
- "with11=%(with10)s\n"
- "with10=%(with9)s\n"
- "with9=%(with8)s\n"
- "with8=%(With7)s\n"
- "with7=%(WITH6)s\n"
- "with6=%(with5)s\n"
- "With5=%(with4)s\n"
- "WITH4=%(with3)s\n"
- "with3=%(with2)s\n"
- "with2=%(with1)s\n"
- "with1=with\n"
+ "bar{equals}something %(with1)s interpolation (1 step)\n"
+ "bar9{equals}something %(with9)s lots of interpolation (9 steps)\n"
+ "bar10{equals}something %(with10)s lots of interpolation (10 steps)\n"
+ "bar11{equals}something %(with11)s lots of interpolation (11 steps)\n"
+ "with11{equals}%(with10)s\n"
+ "with10{equals}%(with9)s\n"
+ "with9{equals}%(with8)s\n"
+ "with8{equals}%(With7)s\n"
+ "with7{equals}%(WITH6)s\n"
+ "with6{equals}%(with5)s\n"
+ "With5{equals}%(with4)s\n"
+ "WITH4{equals}%(with3)s\n"
+ "with3{equals}%(with2)s\n"
+ "with2{equals}%(with1)s\n"
+ "with1{equals}with\n"
"\n"
"[Mutual Recursion]\n"
- "foo=%(bar)s\n"
- "bar=%(foo)s\n"
+ "foo{equals}%(bar)s\n"
+ "bar{equals}%(foo)s\n"
"\n"
"[Interpolation Error]\n"
- "name=%(reference)s\n",
# no definition for 'reference'
- defaults={"getname": "%(__name__)s"})
+ "name{equals}%(reference)s\n".format(equals=self.delimiters[0]))
def check_items_config(self, expected):
- cf = self.fromstring(
- "[section]\n"
- "name = value\n"
- "key: |%(name)s| \n"
- "getdefault: |%(default)s|\n"
- "getname: |%(__name__)s|",
- defaults={"default": "<default>"})
- L = list(cf.items("section"))
+ cf = self.fromstring("""
+ [section]
+ name {0[0]} %(value)s
+ key{0[1]} |%(name)s|
+ getdefault{0[1]} |%(default)s|
+ """.format(self.delimiters), defaults={"default": "<default>"})
+ L = list(cf.items("section", vars={'value': 'value'}))
L.sort()
self.assertEqual(L, expected)
+ with self.assertRaises(configparser.NoSectionError):
+ cf.items("no such section")
-class ConfigParserTestCase(TestCaseBase):
- config_class = ConfigParser.ConfigParser
- allow_no_value = True
+class StrictTestCase(BasicTestCase):
+ config_class = configparser.RawConfigParser
+ strict = True
+
+
+class ConfigParserTestCase(BasicTestCase):
+ config_class = configparser.ConfigParser
def test_interpolation(self):
- rawval = {
- ConfigParser.ConfigParser: ("something %(with11)s "
- "lots of interpolation (11 steps)"),
- ConfigParser.SafeConfigParser: "%(with1)s",
- }
cf = self.get_interpolation_config()
eq = self.assertEqual
- eq(cf.get("Foo", "getname"), "Foo")
eq(cf.get("Foo", "bar"), "something with interpolation (1 step)")
eq(cf.get("Foo", "bar9"),
"something with lots of interpolation (9 steps)")
eq(cf.get("Foo", "bar10"),
"something with lots of interpolation (10 steps)")
- self.get_error(ConfigParser.InterpolationDepthError, "Foo", "bar11")
+ e = self.get_error(cf, configparser.InterpolationDepthError, "Foo", "bar11")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(e.args, ("bar11", "Foo", "%(with1)s"))
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ self.assertEqual(e.args, ("bar11", "Foo",
+ "something %(with11)s lots of interpolation (11 steps)"))
def test_interpolation_missing_value(self):
- self.get_interpolation_config()
- e = self.get_error(ConfigParser.InterpolationError,
+ cf = self.get_interpolation_config()
+ e = self.get_error(cf, configparser.InterpolationMissingOptionError,
"Interpolation Error", "name")
self.assertEqual(e.reference, "reference")
self.assertEqual(e.section, "Interpolation Error")
self.assertEqual(e.option, "name")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(e.args, ('name', 'Interpolation Error',
+ '', 'reference'))
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ self.assertEqual(e.args, ('name', 'Interpolation Error',
+ '%(reference)s', 'reference'))
def test_items(self):
self.check_items_config([('default', '<default>'),
('getdefault', '|<default>|'),
- ('getname', '|section|'),
('key', '|value|'),
- ('name', 'value')])
+ ('name', 'value'),
+ ('value', 'value')])
+
+ def test_safe_interpolation(self):
+ # See http://www.python.org/sf/511737
+ cf = self.fromstring("[section]\n"
+ "option1{eq}xxx\n"
+ "option2{eq}%(option1)s/xxx\n"
+ "ok{eq}%(option1)s/%%s\n"
+ "not_ok{eq}%(option2)s/%%s".format(
+ eq=self.delimiters[0]))
+ self.assertEqual(cf.get("section", "ok"), "xxx/%s")
+ if self.interpolation == configparser._UNSET:
+ self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
+ elif isinstance(self.interpolation, configparser.LegacyInterpolation):
+ with self.assertRaises(TypeError):
+ cf.get("section", "not_ok")
+
+ def test_set_malformatted_interpolation(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
+ self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ # bug #5741: double percents are *not* malformed
+ cf.set("sect", "option2", "foo%%bar")
+ self.assertEqual(cf.get("sect", "option2"), "foo%bar")
def test_set_nonstring_types(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+ # Check that we get a TypeError when setting non-string values
+ # in an existing section:
+ self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
+ self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
+ self.assertRaises(TypeError, cf.set, "sect", "option1", object())
+ self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
+ self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
+ self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+ self.assertRaises(TypeError, cf.set, "sect", 123, "invalid opt name!")
+ self.assertRaises(TypeError, cf.add_section, 123)
+
+ def test_add_section_default(self):
cf = self.newconfig()
- cf.add_section('non-string')
- cf.set('non-string', 'int', 1)
- cf.set('non-string', 'list', [0, 1, 1, 2, 3, 5, 8, 13, '%('])
- cf.set('non-string', 'dict', {'pi': 3.14159, '%(': 1,
- '%(list)': '%(list)'})
- cf.set('non-string', 'string_with_interpolation', '%(list)s')
- cf.set('non-string', 'no-value')
- self.assertEqual(cf.get('non-string', 'int', raw=True), 1)
- self.assertRaises(TypeError, cf.get, 'non-string', 'int')
- self.assertEqual(cf.get('non-string', 'list', raw=True),
- [0, 1, 1, 2, 3, 5, 8, 13, '%('])
- self.assertRaises(TypeError, cf.get, 'non-string', 'list')
- self.assertEqual(cf.get('non-string', 'dict', raw=True),
- {'pi': 3.14159, '%(': 1, '%(list)': '%(list)'})
- self.assertRaises(TypeError, cf.get, 'non-string', 'dict')
- self.assertEqual(cf.get('non-string', 'string_with_interpolation',
- raw=True), '%(list)s')
- self.assertRaises(ValueError, cf.get, 'non-string',
- 'string_with_interpolation', raw=False)
- self.assertEqual(cf.get('non-string', 'no-value'), None)
-
-class MultilineValuesTestCase(TestCaseBase):
- config_class = ConfigParser.ConfigParser
+ self.assertRaises(ValueError, cf.add_section, self.default_section)
+
+
+class ConfigParserTestCaseNoInterpolation(BasicTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = None
+ ini = textwrap.dedent("""
+ [numbers]
+ one = 1
+ two = %(one)s * 2
+ three = ${common:one} * 3
+
+ [hexen]
+ sixteen = ${numbers:two} * 8
+ """).strip()
+
+ def assertMatchesIni(self, cf):
+ self.assertEqual(cf['numbers']['one'], '1')
+ self.assertEqual(cf['numbers']['two'], '%(one)s * 2')
+ self.assertEqual(cf['numbers']['three'], '${common:one} * 3')
+ self.assertEqual(cf['hexen']['sixteen'], '${numbers:two} * 8')
+
+ def test_no_interpolation(self):
+ cf = self.fromstring(self.ini)
+ self.assertMatchesIni(cf)
+
+ def test_empty_case(self):
+ cf = self.newconfig()
+ self.assertIsNone(cf.read_string(""))
+
+ def test_none_as_default_interpolation(self):
+ class CustomConfigParser(configparser.ConfigParser):
+ _DEFAULT_INTERPOLATION = None
+
+ cf = CustomConfigParser()
+ cf.read_string(self.ini)
+ self.assertMatchesIni(cf)
+
+
+class ConfigParserTestCaseLegacyInterpolation(ConfigParserTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = configparser.LegacyInterpolation()
+
+ def test_set_malformatted_interpolation(self):
+ cf = self.fromstring("[sect]\n"
+ "option1{eq}foo\n".format(eq=self.delimiters[0]))
+
+ self.assertEqual(cf.get('sect', "option1"), "foo")
+
+ cf.set("sect", "option1", "%foo")
+ self.assertEqual(cf.get('sect', "option1"), "%foo")
+ cf.set("sect", "option1", "foo%")
+ self.assertEqual(cf.get('sect', "option1"), "foo%")
+ cf.set("sect", "option1", "f%oo")
+ self.assertEqual(cf.get('sect', "option1"), "f%oo")
+
+ # bug #5741: double percents are *not* malformed
+ cf.set("sect", "option2", "foo%%bar")
+ self.assertEqual(cf.get("sect", "option2"), "foo%%bar")
+
+class ConfigParserTestCaseNonStandardDelimiters(ConfigParserTestCase):
+ delimiters = (':=', '$')
+ comment_prefixes = ('//', '"')
+ inline_comment_prefixes = ('//', '"')
+
+class ConfigParserTestCaseNonStandardDefaultSection(ConfigParserTestCase):
+ default_section = 'general'
+
+class MultilineValuesTestCase(BasicTestCase):
+ config_class = configparser.ConfigParser
wonderful_spam = ("I'm having spam spam spam spam "
"spam spam spam beaked beans spam "
"spam spam and spam!").replace(' ', '\t\n')
@@ -426,28 +943,27 @@ class MultilineValuesTestCase(TestCaseBase):
cf.add_section(s)
for j in range(10):
cf.set(s, 'lovely_spam{}'.format(j), self.wonderful_spam)
- with open(test_support.TESTFN, 'w') as f:
+ with open(support.TESTFN, 'w') as f:
cf.write(f)
def tearDown(self):
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
def test_dominating_multiline_values(self):
- # we're reading from file because this is where the code changed
+ # We're reading from file because this is where the code changed
# during performance updates in Python 3.2
cf_from_file = self.newconfig()
- with open(test_support.TESTFN) as f:
- cf_from_file.readfp(f)
+ with open(support.TESTFN) as f:
+ cf_from_file.read_file(f)
self.assertEqual(cf_from_file.get('section8', 'lovely_spam4'),
self.wonderful_spam.replace('\t\n', '\n'))
-class RawConfigParserTestCase(TestCaseBase):
- config_class = ConfigParser.RawConfigParser
+class RawConfigParserTestCase(BasicTestCase):
+ config_class = configparser.RawConfigParser
def test_interpolation(self):
cf = self.get_interpolation_config()
eq = self.assertEqual
- eq(cf.get("Foo", "getname"), "%(__name__)s")
eq(cf.get("Foo", "bar"),
"something %(with1)s interpolation (1 step)")
eq(cf.get("Foo", "bar9"),
@@ -460,9 +976,9 @@ class RawConfigParserTestCase(TestCaseBase):
def test_items(self):
self.check_items_config([('default', '<default>'),
('getdefault', '|%(default)s|'),
- ('getname', '|%(__name__)s|'),
('key', '|%(name)s|'),
- ('name', 'value')])
+ ('name', '%(value)s'),
+ ('value', 'value')])
def test_set_nonstring_types(self):
cf = self.newconfig()
@@ -474,84 +990,260 @@ class RawConfigParserTestCase(TestCaseBase):
self.assertEqual(cf.get('non-string', 'list'),
[0, 1, 1, 2, 3, 5, 8, 13])
self.assertEqual(cf.get('non-string', 'dict'), {'pi': 3.14159})
+ cf.add_section(123)
+ cf.set(123, 'this is sick', True)
+ self.assertEqual(cf.get(123, 'this is sick'), True)
+ if cf._dict is configparser._default_dict:
+ # would not work for SortedDict; only checking for the most common
+ # default dictionary (OrderedDict)
+ cf.optionxform = lambda x: x
+ cf.set('non-string', 1, 1)
+ self.assertEqual(cf.get('non-string', 1), 1)
+
+class RawConfigParserTestCaseNonStandardDelimiters(RawConfigParserTestCase):
+ delimiters = (':=', '$')
+ comment_prefixes = ('//', '"')
+ inline_comment_prefixes = ('//', '"')
+
+class RawConfigParserTestSambaConf(CfgParserTestCaseClass):
+ config_class = configparser.RawConfigParser
+ comment_prefixes = ('#', ';', '----')
+ inline_comment_prefixes = ('//',)
+ empty_lines_in_values = False
+
+ def test_reading(self):
+ smbconf = support.findfile("cfgparser.2")
+ # check when we pass a mix of readable and non-readable files:
+ cf = self.newconfig()
+ parsed_files = cf.read([smbconf, "nonexistent-file"], encoding='utf-8')
+ self.assertEqual(parsed_files, [smbconf])
+ sections = ['global', 'homes', 'printers',
+ 'print$', 'pdf-generator', 'tmp', 'Agustin']
+ self.assertEqual(cf.sections(), sections)
+ self.assertEqual(cf.get("global", "workgroup"), "MDKGROUP")
+ self.assertEqual(cf.getint("global", "max log size"), 50)
+ self.assertEqual(cf.get("global", "hosts allow"), "127.")
+ self.assertEqual(cf.get("tmp", "echo command"), "cat %s; rm %s")
+
+class ConfigParserTestCaseExtendedInterpolation(BasicTestCase):
+ config_class = configparser.ConfigParser
+ interpolation = configparser.ExtendedInterpolation()
+ default_section = 'common'
+ strict = True
+
+ def fromstring(self, string, defaults=None, optionxform=None):
+ cf = self.newconfig(defaults)
+ if optionxform:
+ cf.optionxform = optionxform
+ cf.read_string(string)
+ return cf
+ def test_extended_interpolation(self):
+ cf = self.fromstring(textwrap.dedent("""
+ [common]
+ favourite Beatle = Paul
+ favourite color = green
+
+ [tom]
+ favourite band = ${favourite color} day
+ favourite pope = John ${favourite Beatle} II
+ sequel = ${favourite pope}I
+
+ [ambv]
+ favourite Beatle = George
+ son of Edward VII = ${favourite Beatle} V
+ son of George V = ${son of Edward VII}I
+
+ [stanley]
+ favourite Beatle = ${ambv:favourite Beatle}
+ favourite pope = ${tom:favourite pope}
+ favourite color = black
+ favourite state of mind = paranoid
+ favourite movie = soylent ${common:favourite color}
+ favourite song = ${favourite color} sabbath - ${favourite state of mind}
+ """).strip())
-class SafeConfigParserTestCase(ConfigParserTestCase):
- config_class = ConfigParser.SafeConfigParser
-
- def test_safe_interpolation(self):
- # See http://www.python.org/sf/511737
- cf = self.fromstring("[section]\n"
- "option1=xxx\n"
- "option2=%(option1)s/xxx\n"
- "ok=%(option1)s/%%s\n"
- "not_ok=%(option2)s/%%s")
- self.assertEqual(cf.get("section", "ok"), "xxx/%s")
- self.assertEqual(cf.get("section", "not_ok"), "xxx/xxx/%s")
-
- def test_set_malformatted_interpolation(self):
- cf = self.fromstring("[sect]\n"
- "option1=foo\n")
-
- self.assertEqual(cf.get('sect', "option1"), "foo")
-
- self.assertRaises(ValueError, cf.set, "sect", "option1", "%foo")
- self.assertRaises(ValueError, cf.set, "sect", "option1", "foo%")
- self.assertRaises(ValueError, cf.set, "sect", "option1", "f%oo")
-
- self.assertEqual(cf.get('sect', "option1"), "foo")
-
- # bug #5741: double percents are *not* malformed
- cf.set("sect", "option2", "foo%%bar")
- self.assertEqual(cf.get("sect", "option2"), "foo%bar")
+ eq = self.assertEqual
+ eq(cf['common']['favourite Beatle'], 'Paul')
+ eq(cf['common']['favourite color'], 'green')
+ eq(cf['tom']['favourite Beatle'], 'Paul')
+ eq(cf['tom']['favourite color'], 'green')
+ eq(cf['tom']['favourite band'], 'green day')
+ eq(cf['tom']['favourite pope'], 'John Paul II')
+ eq(cf['tom']['sequel'], 'John Paul III')
+ eq(cf['ambv']['favourite Beatle'], 'George')
+ eq(cf['ambv']['favourite color'], 'green')
+ eq(cf['ambv']['son of Edward VII'], 'George V')
+ eq(cf['ambv']['son of George V'], 'George VI')
+ eq(cf['stanley']['favourite Beatle'], 'George')
+ eq(cf['stanley']['favourite color'], 'black')
+ eq(cf['stanley']['favourite state of mind'], 'paranoid')
+ eq(cf['stanley']['favourite movie'], 'soylent green')
+ eq(cf['stanley']['favourite pope'], 'John Paul II')
+ eq(cf['stanley']['favourite song'],
+ 'black sabbath - paranoid')
+
+ def test_endless_loop(self):
+ cf = self.fromstring(textwrap.dedent("""
+ [one for you]
+ ping = ${one for me:pong}
+
+ [one for me]
+ pong = ${one for you:ping}
+
+ [selfish]
+ me = ${me}
+ """).strip())
+
+ with self.assertRaises(configparser.InterpolationDepthError):
+ cf['one for you']['ping']
+ with self.assertRaises(configparser.InterpolationDepthError):
+ cf['selfish']['me']
+
+ def test_strange_options(self):
+ cf = self.fromstring("""
+ [dollars]
+ $var = $$value
+ $var2 = ${$var}
+ ${sick} = cannot interpolate me
+
+ [interpolated]
+ $other = ${dollars:$var}
+ $trying = ${dollars:${sick}}
+ """)
+
+ self.assertEqual(cf['dollars']['$var'], '$value')
+ self.assertEqual(cf['interpolated']['$other'], '$value')
+ self.assertEqual(cf['dollars']['${sick}'], 'cannot interpolate me')
+ exception_class = configparser.InterpolationMissingOptionError
+ with self.assertRaises(exception_class) as cm:
+ cf['interpolated']['$trying']
+ self.assertEqual(cm.exception.reference, 'dollars:${sick')
+ self.assertEqual(cm.exception.args[2], '}') #rawval
+
+ def test_case_sensitivity_basic(self):
+ ini = textwrap.dedent("""
+ [common]
+ optionlower = value
+ OptionUpper = Value
+
+ [Common]
+ optionlower = a better ${common:optionlower}
+ OptionUpper = A Better ${common:OptionUpper}
+
+ [random]
+ foolower = ${common:optionlower} redefined
+ FooUpper = ${Common:OptionUpper} Redefined
+ """).strip()
+
+ cf = self.fromstring(ini)
+ eq = self.assertEqual
+ eq(cf['common']['optionlower'], 'value')
+ eq(cf['common']['OptionUpper'], 'Value')
+ eq(cf['Common']['optionlower'], 'a better value')
+ eq(cf['Common']['OptionUpper'], 'A Better Value')
+ eq(cf['random']['foolower'], 'value redefined')
+ eq(cf['random']['FooUpper'], 'A Better Value Redefined')
+
+ def test_case_sensitivity_conflicts(self):
+ ini = textwrap.dedent("""
+ [common]
+ option = value
+ Option = Value
+
+ [Common]
+ option = a better ${common:option}
+ Option = A Better ${common:Option}
+
+ [random]
+ foo = ${common:option} redefined
+ Foo = ${Common:Option} Redefined
+ """).strip()
+ with self.assertRaises(configparser.DuplicateOptionError):
+ cf = self.fromstring(ini)
+
+ # raw options
+ cf = self.fromstring(ini, optionxform=lambda opt: opt)
+ eq = self.assertEqual
+ eq(cf['common']['option'], 'value')
+ eq(cf['common']['Option'], 'Value')
+ eq(cf['Common']['option'], 'a better value')
+ eq(cf['Common']['Option'], 'A Better Value')
+ eq(cf['random']['foo'], 'value redefined')
+ eq(cf['random']['Foo'], 'A Better Value Redefined')
+
+ def test_other_errors(self):
+ cf = self.fromstring("""
+ [interpolation fail]
+ case1 = ${where's the brace
+ case2 = ${does_not_exist}
+ case3 = ${wrong_section:wrong_value}
+ case4 = ${i:like:colon:characters}
+ case5 = $100 for Fail No 5!
+ """)
+
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case1']
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf['interpolation fail']['case2']
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf['interpolation fail']['case3']
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case4']
+ with self.assertRaises(configparser.InterpolationSyntaxError):
+ cf['interpolation fail']['case5']
+ with self.assertRaises(ValueError):
+ cf['interpolation fail']['case6'] = "BLACK $ABBATH"
+
+
+class ConfigParserTestCaseNoValue(ConfigParserTestCase):
+ allow_no_value = True
- def test_set_nonstring_types(self):
- cf = self.fromstring("[sect]\n"
- "option1=foo\n")
- # Check that we get a TypeError when setting non-string values
- # in an existing section:
- self.assertRaises(TypeError, cf.set, "sect", "option1", 1)
- self.assertRaises(TypeError, cf.set, "sect", "option1", 1.0)
- self.assertRaises(TypeError, cf.set, "sect", "option1", object())
- self.assertRaises(TypeError, cf.set, "sect", "option2", 1)
- self.assertRaises(TypeError, cf.set, "sect", "option2", 1.0)
- self.assertRaises(TypeError, cf.set, "sect", "option2", object())
+class ConfigParserTestCaseTrickyFile(CfgParserTestCaseClass):
+ config_class = configparser.ConfigParser
+ delimiters = {'='}
+ comment_prefixes = {'#'}
+ allow_no_value = True
- def test_add_section_default_1(self):
+ def test_cfgparser_dot_3(self):
+ tricky = support.findfile("cfgparser.3")
cf = self.newconfig()
- self.assertRaises(ValueError, cf.add_section, "default")
-
- def test_add_section_default_2(self):
+ self.assertEqual(len(cf.read(tricky, encoding='utf-8')), 1)
+ self.assertEqual(cf.sections(), ['strange',
+ 'corruption',
+ 'yeah, sections can be '
+ 'indented as well',
+ 'another one!',
+ 'no values here',
+ 'tricky interpolation',
+ 'more interpolation'])
+ self.assertEqual(cf.getint(self.default_section, 'go',
+ vars={'interpolate': '-1'}), -1)
+ with self.assertRaises(ValueError):
+ # no interpolation will happen
+ cf.getint(self.default_section, 'go', raw=True,
+ vars={'interpolate': '-1'})
+ self.assertEqual(len(cf.get('strange', 'other').split('\n')), 4)
+ self.assertEqual(len(cf.get('corruption', 'value').split('\n')), 10)
+ longname = 'yeah, sections can be indented as well'
+ self.assertFalse(cf.getboolean(longname, 'are they subsections'))
+ self.assertEqual(cf.get(longname, 'lets use some Unicode'), '片仮å')
+ self.assertEqual(len(cf.items('another one!')), 5) # 4 in section and
+ # `go` from DEFAULT
+ with self.assertRaises(configparser.InterpolationMissingOptionError):
+ cf.items('no values here')
+ self.assertEqual(cf.get('tricky interpolation', 'lets'), 'do this')
+ self.assertEqual(cf.get('tricky interpolation', 'lets'),
+ cf.get('tricky interpolation', 'go'))
+ self.assertEqual(cf.get('more interpolation', 'lets'), 'go shopping')
+
+ def test_unicode_failure(self):
+ tricky = support.findfile("cfgparser.3")
cf = self.newconfig()
- self.assertRaises(ValueError, cf.add_section, "DEFAULT")
+ with self.assertRaises(UnicodeDecodeError):
+ cf.read(tricky, encoding='ascii')
-class SafeConfigParserTestCaseNoValue(SafeConfigParserTestCase):
- allow_no_value = True
-
-class TestChainMap(unittest.TestCase):
- def test_issue_12717(self):
- d1 = dict(red=1, green=2)
- d2 = dict(green=3, blue=4)
- dcomb = d2.copy()
- dcomb.update(d1)
- cm = ConfigParser._Chainmap(d1, d2)
- self.assertIsInstance(cm.keys(), list)
- self.assertEqual(set(cm.keys()), set(dcomb.keys())) # keys()
- self.assertEqual(set(cm.values()), set(dcomb.values())) # values()
- self.assertEqual(set(cm.items()), set(dcomb.items())) # items()
- self.assertEqual(set(cm), set(dcomb)) # __iter__ ()
- self.assertEqual(cm, dcomb) # __eq__()
- self.assertEqual([cm[k] for k in dcomb], dcomb.values()) # __getitem__()
- klist = 'red green blue black brown'.split()
- self.assertEqual([cm.get(k, 10) for k in klist],
- [dcomb.get(k, 10) for k in klist]) # get()
- self.assertEqual([k in cm for k in klist],
- [k in dcomb for k in klist]) # __contains__()
- with test_support.check_py3k_warnings():
- self.assertEqual([cm.has_key(k) for k in klist],
- [dcomb.has_key(k) for k in klist]) # has_key()
-
class Issue7005TestCase(unittest.TestCase):
"""Test output when None is set() as a value and allow_no_value == False.
@@ -566,34 +1258,34 @@ class Issue7005TestCase(unittest.TestCase):
cp = config_class(allow_no_value=False)
cp.add_section("section")
cp.set("section", "option", None)
- sio = StringIO.StringIO()
+ sio = io.StringIO()
cp.write(sio)
return sio.getvalue()
def test_none_as_value_stringified(self):
- output = self.prepare(ConfigParser.ConfigParser)
- self.assertEqual(output, self.expected_output)
+ cp = configparser.ConfigParser(allow_no_value=False)
+ cp.add_section("section")
+ with self.assertRaises(TypeError):
+ cp.set("section", "option", None)
def test_none_as_value_stringified_raw(self):
- output = self.prepare(ConfigParser.RawConfigParser)
+ output = self.prepare(configparser.RawConfigParser)
self.assertEqual(output, self.expected_output)
class SortedTestCase(RawConfigParserTestCase):
- def newconfig(self, defaults=None):
- self.cf = self.config_class(defaults=defaults, dict_type=SortedDict)
- return self.cf
+ dict_type = SortedDict
def test_sorted(self):
- self.fromstring("[b]\n"
- "o4=1\n"
- "o3=2\n"
- "o2=3\n"
- "o1=4\n"
- "[a]\n"
- "k=v\n")
- output = StringIO.StringIO()
- self.cf.write(output)
+ cf = self.fromstring("[b]\n"
+ "o4=1\n"
+ "o3=2\n"
+ "o2=3\n"
+ "o1=4\n"
+ "[a]\n"
+ "k=v\n")
+ output = io.StringIO()
+ cf.write(output)
self.assertEqual(output.getvalue(),
"[a]\n"
"k = v\n\n"
@@ -604,12 +1296,191 @@ class SortedTestCase(RawConfigParserTestCase):
"o4 = 1\n\n")
+class CompatibleTestCase(CfgParserTestCaseClass):
+ config_class = configparser.RawConfigParser
+ comment_prefixes = '#;'
+ inline_comment_prefixes = ';'
+
+ def test_comment_handling(self):
+ config_string = textwrap.dedent("""\
+ [Commented Bar]
+ baz=qwe ; a comment
+ foo: bar # not a comment!
+ # but this is a comment
+ ; another comment
+ quirk: this;is not a comment
+ ; a space must precede an inline comment
+ """)
+ cf = self.fromstring(config_string)
+ self.assertEqual(cf.get('Commented Bar', 'foo'),
+ 'bar # not a comment!')
+ self.assertEqual(cf.get('Commented Bar', 'baz'), 'qwe')
+ self.assertEqual(cf.get('Commented Bar', 'quirk'),
+ 'this;is not a comment')
+
+class CopyTestCase(BasicTestCase):
+ config_class = configparser.ConfigParser
+
+ def fromstring(self, string, defaults=None):
+ cf = self.newconfig(defaults)
+ cf.read_string(string)
+ cf_copy = self.newconfig()
+ cf_copy.read_dict(cf)
+ # we have to clean up option duplicates that appeared because of
+ # the magic DEFAULTSECT behaviour.
+ for section in cf_copy.values():
+ if section.name == self.default_section:
+ continue
+ for default, value in cf[self.default_section].items():
+ if section[default] == value:
+ del section[default]
+ return cf_copy
+
+
+class FakeFile:
+ def __init__(self):
+ file_path = support.findfile("cfgparser.1")
+ with open(file_path) as f:
+ self.lines = f.readlines()
+ self.lines.reverse()
+
+ def readline(self):
+ if len(self.lines):
+ return self.lines.pop()
+ return ''
+
+
+def readline_generator(f):
+ """As advised in Doc/library/configparser.rst."""
+ line = f.readline()
+ while line:
+ yield line
+ line = f.readline()
+
+
+class ReadFileTestCase(unittest.TestCase):
+ def test_file(self):
+ file_path = support.findfile("cfgparser.1")
+ parser = configparser.ConfigParser()
+ with open(file_path) as f:
+ parser.read_file(f)
+ self.assertIn("Foo Bar", parser)
+ self.assertIn("foo", parser["Foo Bar"])
+ self.assertEqual(parser["Foo Bar"]["foo"], "newbar")
+
+ def test_iterable(self):
+ lines = textwrap.dedent("""
+ [Foo Bar]
+ foo=newbar""").strip().split('\n')
+ parser = configparser.ConfigParser()
+ parser.read_file(lines)
+ self.assertIn("Foo Bar", parser)
+ self.assertIn("foo", parser["Foo Bar"])
+ self.assertEqual(parser["Foo Bar"]["foo"], "newbar")
+
+ def test_readline_generator(self):
+ """Issue #11670."""
+ parser = configparser.ConfigParser()
+ with self.assertRaises(TypeError):
+ parser.read_file(FakeFile())
+ parser.read_file(readline_generator(FakeFile()))
+ self.assertIn("Foo Bar", parser)
+ self.assertIn("foo", parser["Foo Bar"])
+ self.assertEqual(parser["Foo Bar"]["foo"], "newbar")
+
+
+class CoverageOneHundredTestCase(unittest.TestCase):
+ """Covers edge cases in the codebase."""
+
+ def test_duplicate_option_error(self):
+ error = configparser.DuplicateOptionError('section', 'option')
+ self.assertEqual(error.section, 'section')
+ self.assertEqual(error.option, 'option')
+ self.assertEqual(error.source, None)
+ self.assertEqual(error.lineno, None)
+ self.assertEqual(error.args, ('section', 'option', None, None))
+ self.assertEqual(str(error), "Option 'option' in section 'section' "
+ "already exists")
+
+ def test_interpolation_depth_error(self):
+ error = configparser.InterpolationDepthError('option', 'section',
+ 'rawval')
+ self.assertEqual(error.args, ('option', 'section', 'rawval'))
+ self.assertEqual(error.option, 'option')
+ self.assertEqual(error.section, 'section')
+
+ def test_parsing_error(self):
+ with self.assertRaises(ValueError) as cm:
+ configparser.ParsingError()
+ self.assertEqual(str(cm.exception), "Required argument `source' not "
+ "given.")
+ with self.assertRaises(ValueError) as cm:
+ configparser.ParsingError(source='source', filename='filename')
+ self.assertEqual(str(cm.exception), "Cannot specify both `filename' "
+ "and `source'. Use `source'.")
+ error = configparser.ParsingError(filename='source')
+ self.assertEqual(error.source, 'source')
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ self.assertEqual(error.filename, 'source')
+ error.filename = 'filename'
+ self.assertEqual(error.source, 'filename')
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+
+ def test_interpolation_validation(self):
+ parser = configparser.ConfigParser()
+ parser.read_string("""
+ [section]
+ invalid_percent = %
+ invalid_reference = %(()
+ invalid_variable = %(does_not_exist)s
+ """)
+ with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+ parser['section']['invalid_percent']
+ self.assertEqual(str(cm.exception), "'%' must be followed by '%' or "
+ "'(', found: '%'")
+ with self.assertRaises(configparser.InterpolationSyntaxError) as cm:
+ parser['section']['invalid_reference']
+ self.assertEqual(str(cm.exception), "bad interpolation variable "
+ "reference '%(()'")
+
+ def test_readfp_deprecation(self):
+ sio = io.StringIO("""
+ [section]
+ option = value
+ """)
+ parser = configparser.ConfigParser()
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ parser.readfp(sio, filename='StringIO')
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+ self.assertEqual(len(parser), 2)
+ self.assertEqual(parser['section']['option'], 'value')
+
+ def test_safeconfigparser_deprecation(self):
+ with warnings.catch_warnings(record=True) as w:
+ warnings.simplefilter("always", DeprecationWarning)
+ parser = configparser.SafeConfigParser()
+ for warning in w:
+ self.assertTrue(warning.category is DeprecationWarning)
+
+ def test_sectionproxy_repr(self):
+ parser = configparser.ConfigParser()
+ parser.read_string("""
+ [section]
+ key = value
+ """)
+ self.assertEqual(repr(parser['section']), '<Section: section>')
+
+
class ExceptionPicklingTestCase(unittest.TestCase):
"""Tests for issue #13760: ConfigParser exceptions are not picklable."""
def test_error(self):
import pickle
- e1 = ConfigParser.Error('value')
+ e1 = configparser.Error('value')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
@@ -617,7 +1488,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_nosectionerror(self):
import pickle
- e1 = ConfigParser.NoSectionError('section')
+ e1 = configparser.NoSectionError('section')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
@@ -627,7 +1498,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_nooptionerror(self):
import pickle
- e1 = ConfigParser.NoOptionError('option', 'section')
+ e1 = configparser.NoOptionError('option', 'section')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
@@ -638,17 +1509,33 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_duplicatesectionerror(self):
import pickle
- e1 = ConfigParser.DuplicateSectionError('section')
+ e1 = configparser.DuplicateSectionError('section', 'source', 123)
+ pickled = pickle.dumps(e1)
+ e2 = pickle.loads(pickled)
+ self.assertEqual(e1.message, e2.message)
+ self.assertEqual(e1.args, e2.args)
+ self.assertEqual(e1.section, e2.section)
+ self.assertEqual(e1.source, e2.source)
+ self.assertEqual(e1.lineno, e2.lineno)
+ self.assertEqual(repr(e1), repr(e2))
+
+ def test_duplicateoptionerror(self):
+ import pickle
+ e1 = configparser.DuplicateOptionError('section', 'option', 'source',
+ 123)
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
self.assertEqual(e1.args, e2.args)
self.assertEqual(e1.section, e2.section)
+ self.assertEqual(e1.option, e2.option)
+ self.assertEqual(e1.source, e2.source)
+ self.assertEqual(e1.lineno, e2.lineno)
self.assertEqual(repr(e1), repr(e2))
def test_interpolationerror(self):
import pickle
- e1 = ConfigParser.InterpolationError('option', 'section', 'msg')
+ e1 = configparser.InterpolationError('option', 'section', 'msg')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
@@ -659,7 +1546,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_interpolationmissingoptionerror(self):
import pickle
- e1 = ConfigParser.InterpolationMissingOptionError('option', 'section',
+ e1 = configparser.InterpolationMissingOptionError('option', 'section',
'rawval', 'reference')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
@@ -672,7 +1559,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_interpolationsyntaxerror(self):
import pickle
- e1 = ConfigParser.InterpolationSyntaxError('option', 'section', 'msg')
+ e1 = configparser.InterpolationSyntaxError('option', 'section', 'msg')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
@@ -683,7 +1570,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_interpolationdeptherror(self):
import pickle
- e1 = ConfigParser.InterpolationDepthError('option', 'section',
+ e1 = configparser.InterpolationDepthError('option', 'section',
'rawval')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
@@ -695,7 +1582,7 @@ class ExceptionPicklingTestCase(unittest.TestCase):
def test_parsingerror(self):
import pickle
- e1 = ConfigParser.ParsingError('source')
+ e1 = configparser.ParsingError('source')
e1.append(1, 'line1')
e1.append(2, 'line2')
e1.append(3, 'line3')
@@ -703,36 +1590,54 @@ class ExceptionPicklingTestCase(unittest.TestCase):
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
self.assertEqual(e1.args, e2.args)
- self.assertEqual(e1.filename, e2.filename)
+ self.assertEqual(e1.source, e2.source)
+ self.assertEqual(e1.errors, e2.errors)
+ self.assertEqual(repr(e1), repr(e2))
+ e1 = configparser.ParsingError(filename='filename')
+ e1.append(1, 'line1')
+ e1.append(2, 'line2')
+ e1.append(3, 'line3')
+ pickled = pickle.dumps(e1)
+ e2 = pickle.loads(pickled)
+ self.assertEqual(e1.message, e2.message)
+ self.assertEqual(e1.args, e2.args)
+ self.assertEqual(e1.source, e2.source)
self.assertEqual(e1.errors, e2.errors)
self.assertEqual(repr(e1), repr(e2))
def test_missingsectionheadererror(self):
import pickle
- e1 = ConfigParser.MissingSectionHeaderError('filename', 123, 'line')
+ e1 = configparser.MissingSectionHeaderError('filename', 123, 'line')
pickled = pickle.dumps(e1)
e2 = pickle.loads(pickled)
self.assertEqual(e1.message, e2.message)
self.assertEqual(e1.args, e2.args)
self.assertEqual(e1.line, e2.line)
- self.assertEqual(e1.filename, e2.filename)
+ self.assertEqual(e1.source, e2.source)
self.assertEqual(e1.lineno, e2.lineno)
self.assertEqual(repr(e1), repr(e2))
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
ConfigParserTestCase,
+ ConfigParserTestCaseNonStandardDelimiters,
+ ConfigParserTestCaseNoValue,
+ ConfigParserTestCaseExtendedInterpolation,
+ ConfigParserTestCaseLegacyInterpolation,
+ ConfigParserTestCaseNoInterpolation,
+ ConfigParserTestCaseTrickyFile,
MultilineValuesTestCase,
RawConfigParserTestCase,
- SafeConfigParserTestCase,
- SafeConfigParserTestCaseNoValue,
+ RawConfigParserTestCaseNonStandardDelimiters,
+ RawConfigParserTestSambaConf,
SortedTestCase,
Issue7005TestCase,
- TestChainMap,
+ StrictTestCase,
+ CompatibleTestCase,
+ CopyTestCase,
+ ConfigParserTestCaseNonStandardDefaultSection,
+ ReadFileTestCase,
+ CoverageOneHundredTestCase,
ExceptionPicklingTestCase,
)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_cgi.py b/Lib/test/test_cgi.py
index f6abe976cf7..3031fb38262 100644
--- a/Lib/test/test_cgi.py
+++ b/Lib/test/test_cgi.py
@@ -1,9 +1,10 @@
-from test.test_support import run_unittest, check_warnings
+from test.support import run_unittest, check_warnings
import cgi
import os
import sys
import tempfile
import unittest
+from io import StringIO, BytesIO
class HackedSysModule:
# The regression test will have real values in sys.argv, which
@@ -13,11 +14,6 @@ class HackedSysModule:
cgi.sys = HackedSysModule()
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
class ComparableException:
def __init__(self, err):
self.err = err
@@ -25,13 +21,11 @@ class ComparableException:
def __str__(self):
return str(self.err)
- def __cmp__(self, anExc):
+ def __eq__(self, anExc):
if not isinstance(anExc, Exception):
- return -1
- x = cmp(self.err.__class__, anExc.__class__)
- if x != 0:
- return x
- return cmp(self.err.args, anExc.args)
+ return NotImplemented
+ return (self.err.__class__ == anExc.__class__ and
+ self.err.args == anExc.args)
def __getattr__(self, attr):
return getattr(self.err, attr)
@@ -43,15 +37,15 @@ def do_test(buf, method):
env['REQUEST_METHOD'] = 'GET'
env['QUERY_STRING'] = buf
elif method == "POST":
- fp = StringIO(buf)
+ fp = BytesIO(buf.encode('latin-1')) # FieldStorage expects bytes
env['REQUEST_METHOD'] = 'POST'
env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
env['CONTENT_LENGTH'] = str(len(buf))
else:
- raise ValueError, "unknown method: %s" % method
+ raise ValueError("unknown method: %s" % method)
try:
return cgi.parse(fp, env, strict_parsing=1)
- except StandardError, err:
+ except Exception as err:
return ComparableException(err)
parse_strict_test_cases = [
@@ -101,16 +95,20 @@ parse_strict_test_cases = [
})
]
+def norm(seq):
+ return sorted(seq, key=repr)
+
def first_elts(list):
- return map(lambda x:x[0], list)
+ return [p[0] for p in list]
def first_second_elts(list):
- return map(lambda p:(p[0], p[1][0]), list)
+ return [(p[0], p[1][0]) for p in list]
def gen_result(data, environ):
- fake_stdin = StringIO(data)
+ encoding = 'latin-1'
+ fake_stdin = BytesIO(data.encode(encoding))
fake_stdin.seek(0)
- form = cgi.FieldStorage(fp=fake_stdin, environ=environ)
+ form = cgi.FieldStorage(fp=fake_stdin, environ=environ, encoding=encoding)
result = {}
for k, v in dict(form).items():
@@ -129,61 +127,27 @@ class CgiTests(unittest.TestCase):
for orig, expect in parse_strict_test_cases:
# Test basic parsing
d = do_test(orig, "GET")
- self.assertEqual(d, expect, "Error parsing %s" % repr(orig))
+ self.assertEqual(d, expect, "Error parsing %s method GET" % repr(orig))
d = do_test(orig, "POST")
- self.assertEqual(d, expect, "Error parsing %s" % repr(orig))
+ self.assertEqual(d, expect, "Error parsing %s method POST" % repr(orig))
env = {'QUERY_STRING': orig}
- fcd = cgi.FormContentDict(env)
- sd = cgi.SvFormContentDict(env)
fs = cgi.FieldStorage(environ=env)
if isinstance(expect, dict):
# test dict interface
- self.assertEqual(len(expect), len(fcd))
- self.assertItemsEqual(expect.keys(), fcd.keys())
- self.assertItemsEqual(expect.values(), fcd.values())
- self.assertItemsEqual(expect.items(), fcd.items())
- self.assertEqual(fcd.get("nonexistent field", "default"), "default")
- self.assertEqual(len(sd), len(fs))
- self.assertItemsEqual(sd.keys(), fs.keys())
+ self.assertEqual(len(expect), len(fs))
+ self.assertCountEqual(expect.keys(), fs.keys())
+ ##self.assertEqual(norm(expect.values()), norm(fs.values()))
+ ##self.assertEqual(norm(expect.items()), norm(fs.items()))
self.assertEqual(fs.getvalue("nonexistent field", "default"), "default")
# test individual fields
for key in expect.keys():
expect_val = expect[key]
- self.assertTrue(fcd.has_key(key))
- self.assertItemsEqual(fcd[key], expect[key])
- self.assertEqual(fcd.get(key, "default"), fcd[key])
- self.assertTrue(fs.has_key(key))
+ self.assertIn(key, fs)
if len(expect_val) > 1:
- single_value = 0
- else:
- single_value = 1
- try:
- val = sd[key]
- except IndexError:
- self.assertFalse(single_value)
self.assertEqual(fs.getvalue(key), expect_val)
else:
- self.assertTrue(single_value)
- self.assertEqual(val, expect_val[0])
self.assertEqual(fs.getvalue(key), expect_val[0])
- self.assertItemsEqual(sd.getlist(key), expect_val)
- if single_value:
- self.assertItemsEqual(sd.values(),
- first_elts(expect.values()))
- self.assertItemsEqual(sd.items(),
- first_second_elts(expect.items()))
-
- def test_weird_formcontentdict(self):
- # Test the weird FormContentDict classes
- env = {'QUERY_STRING': "x=1&y=2.0&z=2-3.%2b0&1=1abc"}
- expect = {'x': 1, 'y': 2.0, 'z': '2-3.+0', '1': '1abc'}
- d = cgi.InterpFormContentDict(env)
- for k, v in expect.items():
- self.assertEqual(d[k], v)
- for k, v in d.items():
- self.assertEqual(expect[k], v)
- self.assertItemsEqual(expect.values(), d.values())
def test_log(self):
cgi.log("Testing")
@@ -196,6 +160,13 @@ class CgiTests(unittest.TestCase):
cgi.logfp = None
cgi.logfile = "/dev/null"
cgi.initlog("%s", "Testing log 3")
+ def log_cleanup():
+ """Restore the global state of the log vars."""
+ cgi.logfile = ''
+ cgi.logfp.close()
+ cgi.logfp = None
+ cgi.log = cgi.initlog
+ self.addCleanup(log_cleanup)
cgi.log("Testing log 4")
def test_fieldstorage_readline(self):
@@ -222,50 +193,52 @@ class CgiTests(unittest.TestCase):
setattr(self, name, a)
return a
- f = TestReadlineFile(tempfile.TemporaryFile())
- f.write('x' * 256 * 1024)
+ f = TestReadlineFile(tempfile.TemporaryFile("wb+"))
+ self.addCleanup(f.close)
+ f.write(b'x' * 256 * 1024)
f.seek(0)
env = {'REQUEST_METHOD':'PUT'}
fs = cgi.FieldStorage(fp=f, environ=env)
+ self.addCleanup(fs.file.close)
# if we're not chunking properly, readline is only called twice
# (by read_binary); if we are chunking properly, it will be called 5 times
# as long as the chunksize is 1 << 16.
self.assertTrue(f.numcalls > 2)
+ f.close()
def test_fieldstorage_multipart(self):
#Test basic FieldStorage multipart parsing
- env = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':'multipart/form-data; boundary=---------------------------721837373350705526688164684', 'CONTENT_LENGTH':'558'}
- postdata = """-----------------------------721837373350705526688164684
-Content-Disposition: form-data; name="id"
-
-1234
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="title"
-
-
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="file"; filename="test.txt"
-Content-Type: text/plain
-
-Testing 123.
-
------------------------------721837373350705526688164684
-Content-Disposition: form-data; name="submit"
-
- Add\x20
------------------------------721837373350705526688164684--
-"""
- fs = cgi.FieldStorage(fp=StringIO(postdata), environ=env)
+ env = {
+ 'REQUEST_METHOD': 'POST',
+ 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
+ 'CONTENT_LENGTH': '558'}
+ fp = BytesIO(POSTDATA.encode('latin-1'))
+ fs = cgi.FieldStorage(fp, environ=env, encoding="latin-1")
self.assertEqual(len(fs.list), 4)
expect = [{'name':'id', 'filename':None, 'value':'1234'},
{'name':'title', 'filename':None, 'value':''},
- {'name':'file', 'filename':'test.txt','value':'Testing 123.\n'},
+ {'name':'file', 'filename':'test.txt', 'value':b'Testing 123.\n'},
{'name':'submit', 'filename':None, 'value':' Add '}]
for x in range(len(fs.list)):
for k, exp in expect[x].items():
got = getattr(fs.list[x], k)
self.assertEqual(got, exp)
+ def test_fieldstorage_multipart_non_ascii(self):
+ #Test basic FieldStorage multipart parsing
+ env = {'REQUEST_METHOD':'POST',
+ 'CONTENT_TYPE': 'multipart/form-data; boundary={}'.format(BOUNDARY),
+ 'CONTENT_LENGTH':'558'}
+ for encoding in ['iso-8859-1','utf-8']:
+ fp = BytesIO(POSTDATA_NON_ASCII.encode(encoding))
+ fs = cgi.FieldStorage(fp, environ=env,encoding=encoding)
+ self.assertEqual(len(fs.list), 1)
+ expect = [{'name':'id', 'filename':None, 'value':'\xe7\xf1\x80'}]
+ for x in range(len(fs.list)):
+ for k, exp in expect[x].items():
+ got = getattr(fs.list[x], k)
+ self.assertEqual(got, exp)
+
_qs_result = {
'key1': 'value1',
'key2': ['value2x', 'value2y'],
@@ -284,8 +257,7 @@ Content-Disposition: form-data; name="submit"
self.assertEqual(self._qs_result, v)
def testQSAndFormData(self):
- data = """
----123
+ data = """---123
Content-Disposition: form-data; name="key2"
value2y
@@ -309,8 +281,7 @@ value4
self.assertEqual(self._qs_result, v)
def testQSAndFormDataFile(self):
- data = """
----123
+ data = """---123
Content-Disposition: form-data; name="key2"
value2y
@@ -338,22 +309,22 @@ this is the content of the fake file
}
result = self._qs_result.copy()
result.update({
- 'upload': 'this is the content of the fake file\n'
+ 'upload': b'this is the content of the fake file\n'
})
v = gen_result(data, environ)
self.assertEqual(result, v)
def test_deprecated_parse_qs(self):
- # this func is moved to urlparse, this is just a sanity check
- with check_warnings(('cgi.parse_qs is deprecated, use urlparse.'
- 'parse_qs instead', PendingDeprecationWarning)):
+ # 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 urlparse, this is just a sanity check
- with check_warnings(('cgi.parse_qsl is deprecated, use urlparse.'
- 'parse_qsl instead', PendingDeprecationWarning)):
+ # 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'))
@@ -387,6 +358,37 @@ this is the content of the fake file
("form-data", {"name": "files", "filename": 'fo"o;bar'}))
+BOUNDARY = "---------------------------721837373350705526688164684"
+
+POSTDATA = """-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="id"
+
+1234
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="title"
+
+
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="file"; filename="test.txt"
+Content-Type: text/plain
+
+Testing 123.
+
+-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="submit"
+
+ Add\x20
+-----------------------------721837373350705526688164684--
+"""
+
+POSTDATA_NON_ASCII = """-----------------------------721837373350705526688164684
+Content-Disposition: form-data; name="id"
+
+\xe7\xf1\x80
+-----------------------------721837373350705526688164684
+"""
+
+
def test_main():
run_unittest(CgiTests)
diff --git a/Lib/test/test_charmapcodec.py b/Lib/test/test_charmapcodec.py
index d984059af9c..6226587267e 100644
--- a/Lib/test/test_charmapcodec.py
+++ b/Lib/test/test_charmapcodec.py
@@ -9,7 +9,7 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
"""#"
-import test.test_support, unittest
+import test.support, unittest
import codecs
@@ -27,30 +27,30 @@ codecname = 'testcodec'
class CharmapCodecTest(unittest.TestCase):
def test_constructorx(self):
- self.assertEqual(unicode('abc', codecname), u'abc')
- self.assertEqual(unicode('xdef', codecname), u'abcdef')
- self.assertEqual(unicode('defx', codecname), u'defabc')
- self.assertEqual(unicode('dxf', codecname), u'dabcf')
- self.assertEqual(unicode('dxfx', codecname), u'dabcfabc')
+ self.assertEqual(str(b'abc', codecname), 'abc')
+ self.assertEqual(str(b'xdef', codecname), 'abcdef')
+ self.assertEqual(str(b'defx', codecname), 'defabc')
+ self.assertEqual(str(b'dxf', codecname), 'dabcf')
+ self.assertEqual(str(b'dxfx', codecname), 'dabcfabc')
def test_encodex(self):
- self.assertEqual(u'abc'.encode(codecname), 'abc')
- self.assertEqual(u'xdef'.encode(codecname), 'abcdef')
- self.assertEqual(u'defx'.encode(codecname), 'defabc')
- self.assertEqual(u'dxf'.encode(codecname), 'dabcf')
- self.assertEqual(u'dxfx'.encode(codecname), 'dabcfabc')
+ self.assertEqual('abc'.encode(codecname), b'abc')
+ self.assertEqual('xdef'.encode(codecname), b'abcdef')
+ self.assertEqual('defx'.encode(codecname), b'defabc')
+ self.assertEqual('dxf'.encode(codecname), b'dabcf')
+ self.assertEqual('dxfx'.encode(codecname), b'dabcfabc')
def test_constructory(self):
- self.assertEqual(unicode('ydef', codecname), u'def')
- self.assertEqual(unicode('defy', codecname), u'def')
- self.assertEqual(unicode('dyf', codecname), u'df')
- self.assertEqual(unicode('dyfy', codecname), u'df')
+ self.assertEqual(str(b'ydef', codecname), 'def')
+ self.assertEqual(str(b'defy', codecname), 'def')
+ self.assertEqual(str(b'dyf', codecname), 'df')
+ self.assertEqual(str(b'dyfy', codecname), 'df')
def test_maptoundefined(self):
- self.assertRaises(UnicodeError, unicode, 'abc\001', codecname)
+ self.assertRaises(UnicodeError, str, b'abc\001', codecname)
def test_main():
- test.test_support.run_unittest(CharmapCodecTest)
+ test.support.run_unittest(CharmapCodecTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_cl.py b/Lib/test/test_cl.py
deleted file mode 100755
index 50102e92679..00000000000
--- a/Lib/test/test_cl.py
+++ /dev/null
@@ -1,82 +0,0 @@
-#! /usr/bin/env python
-"""Whimpy test script for the cl module
- Roger E. Masse
-"""
-from test.test_support import verbose, import_module
-
-cl = import_module('cl')
-
-clattrs = ['ADDED_ALGORITHM_ERROR', 'ALAW', 'ALGORITHM_ID',
-'ALGORITHM_VERSION', 'AUDIO', 'AWARE_ERROR', 'AWARE_MPEG_AUDIO',
-'AWARE_MULTIRATE', 'AWCMP_CONST_QUAL', 'AWCMP_FIXED_RATE',
-'AWCMP_INDEPENDENT', 'AWCMP_JOINT_STEREO', 'AWCMP_LOSSLESS',
-'AWCMP_MPEG_LAYER_I', 'AWCMP_MPEG_LAYER_II', 'AWCMP_STEREO',
-'Algorithm', 'AlgorithmNumber', 'AlgorithmType', 'AudioFormatName',
-'BAD_ALGORITHM_NAME', 'BAD_ALGORITHM_TYPE', 'BAD_BLOCK_SIZE',
-'BAD_BOARD', 'BAD_BUFFERING', 'BAD_BUFFERLENGTH_NEG',
-'BAD_BUFFERLENGTH_ODD', 'BAD_BUFFER_EXISTS', 'BAD_BUFFER_HANDLE',
-'BAD_BUFFER_POINTER', 'BAD_BUFFER_QUERY_SIZE', 'BAD_BUFFER_SIZE',
-'BAD_BUFFER_SIZE_POINTER', 'BAD_BUFFER_TYPE',
-'BAD_COMPRESSION_SCHEME', 'BAD_COMPRESSOR_HANDLE',
-'BAD_COMPRESSOR_HANDLE_POINTER', 'BAD_FRAME_SIZE',
-'BAD_FUNCTIONALITY', 'BAD_FUNCTION_POINTER', 'BAD_HEADER_SIZE',
-'BAD_INITIAL_VALUE', 'BAD_INTERNAL_FORMAT', 'BAD_LICENSE',
-'BAD_MIN_GT_MAX', 'BAD_NO_BUFFERSPACE', 'BAD_NUMBER_OF_BLOCKS',
-'BAD_PARAM', 'BAD_PARAM_ID_POINTER', 'BAD_PARAM_TYPE', 'BAD_POINTER',
-'BAD_PVBUFFER', 'BAD_SCHEME_POINTER', 'BAD_STREAM_HEADER',
-'BAD_STRING_POINTER', 'BAD_TEXT_STRING_PTR', 'BEST_FIT',
-'BIDIRECTIONAL', 'BITRATE_POLICY', 'BITRATE_TARGET',
-'BITS_PER_COMPONENT', 'BLENDING', 'BLOCK_SIZE', 'BOTTOM_UP',
-'BUFFER_NOT_CREATED', 'BUF_DATA', 'BUF_FRAME', 'BytesPerPixel',
-'BytesPerSample', 'CHANNEL_POLICY', 'CHROMA_THRESHOLD', 'CODEC',
-'COMPONENTS', 'COMPRESSED_BUFFER_SIZE', 'COMPRESSION_RATIO',
-'COMPRESSOR', 'CONTINUOUS_BLOCK', 'CONTINUOUS_NONBLOCK',
-'CompressImage', 'DATA', 'DECOMPRESSOR', 'DecompressImage',
-'EDGE_THRESHOLD', 'ENABLE_IMAGEINFO', 'END_OF_SEQUENCE', 'ENUM_VALUE',
-'EXACT_COMPRESSION_RATIO', 'EXTERNAL_DEVICE', 'FLOATING_ENUM_VALUE',
-'FLOATING_RANGE_VALUE', 'FRAME', 'FRAME_BUFFER_SIZE',
-'FRAME_BUFFER_SIZE_ZERO', 'FRAME_RATE', 'FRAME_TYPE', 'G711_ALAW',
-'G711_ULAW', 'GRAYSCALE', 'GetAlgorithmName', 'HDCC',
-'HDCC_SAMPLES_PER_TILE', 'HDCC_TILE_THRESHOLD', 'HEADER_START_CODE',
-'IMAGE_HEIGHT', 'IMAGE_WIDTH', 'INTERNAL_FORMAT',
-'INTERNAL_IMAGE_HEIGHT', 'INTERNAL_IMAGE_WIDTH', 'INTRA', 'JPEG',
-'JPEG_ERROR', 'JPEG_NUM_PARAMS', 'JPEG_QUALITY_FACTOR',
-'JPEG_QUANTIZATION_TABLES', 'JPEG_SOFTWARE', 'JPEG_STREAM_HEADERS',
-'KEYFRAME', 'LAST_FRAME_INDEX', 'LAYER', 'LUMA_THRESHOLD',
-'MAX_NUMBER_OF_AUDIO_ALGORITHMS', 'MAX_NUMBER_OF_ORIGINAL_FORMATS',
-'MAX_NUMBER_OF_PARAMS', 'MAX_NUMBER_OF_VIDEO_ALGORITHMS', 'MONO',
-'MPEG_VIDEO', 'MVC1', 'MVC2', 'MVC2_BLENDING', 'MVC2_BLENDING_OFF',
-'MVC2_BLENDING_ON', 'MVC2_CHROMA_THRESHOLD', 'MVC2_EDGE_THRESHOLD',
-'MVC2_ERROR', 'MVC2_LUMA_THRESHOLD', 'NEXT_NOT_AVAILABLE',
-'NOISE_MARGIN', 'NONE', 'NUMBER_OF_FRAMES', 'NUMBER_OF_PARAMS',
-'ORIENTATION', 'ORIGINAL_FORMAT', 'OpenCompressor',
-'OpenDecompressor', 'PARAM_OUT_OF_RANGE', 'PREDICTED', 'PREROLL',
-'ParamID', 'ParamNumber', 'ParamType', 'QUALITY_FACTOR',
-'QUALITY_LEVEL', 'QueryAlgorithms', 'QueryMaxHeaderSize',
-'QueryScheme', 'QuerySchemeFromName', 'RANGE_VALUE', 'RGB', 'RGB332',
-'RGB8', 'RGBA', 'RGBX', 'RLE', 'RLE24', 'RTR', 'RTR1',
-'RTR_QUALITY_LEVEL', 'SAMPLES_PER_TILE', 'SCHEME_BUSY',
-'SCHEME_NOT_AVAILABLE', 'SPEED', 'STEREO_INTERLEAVED',
-'STREAM_HEADERS', 'SetDefault', 'SetMax', 'SetMin', 'TILE_THRESHOLD',
-'TOP_DOWN', 'ULAW', 'UNCOMPRESSED', 'UNCOMPRESSED_AUDIO',
-'UNCOMPRESSED_VIDEO', 'UNKNOWN_SCHEME', 'VIDEO', 'VideoFormatName',
-'Y', 'YCbCr', 'YCbCr422', 'YCbCr422DC', 'YCbCr422HC', 'YUV', 'YUV422',
-'YUV422DC', 'YUV422HC', '__doc__', '__name__', 'cvt_type', 'error']
-
-
-# This is a very inobtrusive test for the existence of the cl
-# module and all its attributes.
-
-def test_main():
- # touch all the attributes of al without doing anything
- if verbose:
- print 'Touching cl module attributes...'
- for attr in clattrs:
- if verbose:
- print 'touching: ', attr
- getattr(cl, attr)
-
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_class.py b/Lib/test/test_class.py
index e5cdf088f42..c7003fbe608 100644
--- a/Lib/test/test_class.py
+++ b/Lib/test/test_class.py
@@ -2,7 +2,7 @@
import unittest
-from test import test_support
+from test import support
testmeths = [
@@ -13,8 +13,8 @@ testmeths = [
"rsub",
"mul",
"rmul",
- "div",
- "rdiv",
+ "truediv",
+ "rtruediv",
"mod",
"rmod",
"divmod",
@@ -35,11 +35,8 @@ testmeths = [
# List/dict operations
"contains",
"getitem",
- "getslice",
"setitem",
- "setslice",
"delitem",
- "delslice",
# Unary operations
"neg",
@@ -51,15 +48,11 @@ testmeths = [
]
# These need to return something other than None
-# "coerce",
# "hash",
# "str",
# "repr",
# "int",
-# "long",
# "float",
-# "oct",
-# "hex",
# These are separate because they can influence the test of other methods.
# "getattr",
@@ -73,61 +66,70 @@ def trackCall(f):
return f(*args, **kwargs)
return track
-class AllTests:
- trackCall = trackCall
+statictests = """
+@trackCall
+def __hash__(self, *args):
+ return hash(id(self))
- @trackCall
- def __coerce__(self, *args):
- return (self,) + args
+@trackCall
+def __str__(self, *args):
+ return "AllTests"
- @trackCall
- def __hash__(self, *args):
- return hash(id(self))
+@trackCall
+def __repr__(self, *args):
+ return "AllTests"
- @trackCall
- def __str__(self, *args):
- return "AllTests"
+@trackCall
+def __int__(self, *args):
+ return 1
- @trackCall
- def __repr__(self, *args):
- return "AllTests"
+@trackCall
+def __index__(self, *args):
+ return 1
- @trackCall
- def __int__(self, *args):
- return 1
+@trackCall
+def __float__(self, *args):
+ return 1.0
- @trackCall
- def __float__(self, *args):
- return 1.0
+@trackCall
+def __eq__(self, *args):
+ return True
- @trackCall
- def __long__(self, *args):
- return 1L
+@trackCall
+def __ne__(self, *args):
+ return False
- @trackCall
- def __oct__(self, *args):
- return '01'
+@trackCall
+def __lt__(self, *args):
+ return False
- @trackCall
- def __hex__(self, *args):
- return '0x1'
+@trackCall
+def __le__(self, *args):
+ return True
- @trackCall
- def __cmp__(self, *args):
- return 0
+@trackCall
+def __gt__(self, *args):
+ return False
+
+@trackCall
+def __ge__(self, *args):
+ return True
+"""
# Synthesize all the other AllTests methods from the names in testmeths.
method_template = """\
@trackCall
-def __%(method)s__(self, *args):
+def __%s__(self, *args):
pass
"""
+d = {}
+exec(statictests, globals(), d)
for method in testmeths:
- exec method_template % locals() in AllTests.__dict__
-
-del method, method_template
+ exec(method_template % method, globals(), d)
+AllTests = type("AllTests", (object,), d)
+del d, statictests, method, method_template
class ClassTests(unittest.TestCase):
def setUp(self):
@@ -150,102 +152,102 @@ class ClassTests(unittest.TestCase):
callLst[:] = []
testme + 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__add__", (testme, 1))])
+ self.assertCallStack([("__add__", (testme, 1))])
callLst[:] = []
1 + testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__radd__", (testme, 1))])
+ self.assertCallStack([("__radd__", (testme, 1))])
callLst[:] = []
testme - 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__sub__", (testme, 1))])
+ self.assertCallStack([("__sub__", (testme, 1))])
callLst[:] = []
1 - testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rsub__", (testme, 1))])
+ self.assertCallStack([("__rsub__", (testme, 1))])
callLst[:] = []
testme * 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__mul__", (testme, 1))])
+ self.assertCallStack([("__mul__", (testme, 1))])
callLst[:] = []
1 * testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rmul__", (testme, 1))])
+ self.assertCallStack([("__rmul__", (testme, 1))])
if 1/2 == 0:
callLst[:] = []
testme / 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__div__", (testme, 1))])
+ self.assertCallStack([("__div__", (testme, 1))])
callLst[:] = []
1 / testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rdiv__", (testme, 1))])
+ self.assertCallStack([("__rdiv__", (testme, 1))])
callLst[:] = []
testme % 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__mod__", (testme, 1))])
+ self.assertCallStack([("__mod__", (testme, 1))])
callLst[:] = []
1 % testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rmod__", (testme, 1))])
+ self.assertCallStack([("__rmod__", (testme, 1))])
callLst[:] = []
divmod(testme,1)
- self.assertCallStack([("__coerce__", (testme, 1)), ("__divmod__", (testme, 1))])
+ self.assertCallStack([("__divmod__", (testme, 1))])
callLst[:] = []
divmod(1, testme)
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rdivmod__", (testme, 1))])
+ self.assertCallStack([("__rdivmod__", (testme, 1))])
callLst[:] = []
testme ** 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__pow__", (testme, 1))])
+ self.assertCallStack([("__pow__", (testme, 1))])
callLst[:] = []
1 ** testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rpow__", (testme, 1))])
+ self.assertCallStack([("__rpow__", (testme, 1))])
callLst[:] = []
testme >> 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rshift__", (testme, 1))])
+ self.assertCallStack([("__rshift__", (testme, 1))])
callLst[:] = []
1 >> testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rrshift__", (testme, 1))])
+ self.assertCallStack([("__rrshift__", (testme, 1))])
callLst[:] = []
testme << 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__lshift__", (testme, 1))])
+ self.assertCallStack([("__lshift__", (testme, 1))])
callLst[:] = []
1 << testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rlshift__", (testme, 1))])
+ self.assertCallStack([("__rlshift__", (testme, 1))])
callLst[:] = []
testme & 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__and__", (testme, 1))])
+ self.assertCallStack([("__and__", (testme, 1))])
callLst[:] = []
1 & testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rand__", (testme, 1))])
+ self.assertCallStack([("__rand__", (testme, 1))])
callLst[:] = []
testme | 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__or__", (testme, 1))])
+ self.assertCallStack([("__or__", (testme, 1))])
callLst[:] = []
1 | testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__ror__", (testme, 1))])
+ self.assertCallStack([("__ror__", (testme, 1))])
callLst[:] = []
testme ^ 1
- self.assertCallStack([("__coerce__", (testme, 1)), ("__xor__", (testme, 1))])
+ self.assertCallStack([("__xor__", (testme, 1))])
callLst[:] = []
1 ^ testme
- self.assertCallStack([("__coerce__", (testme, 1)), ("__rxor__", (testme, 1))])
+ self.assertCallStack([("__rxor__", (testme, 1))])
def testListAndDictOps(self):
testme = AllTests()
@@ -278,15 +280,16 @@ class ClassTests(unittest.TestCase):
callLst[:] = []
testme[:42]
- self.assertCallStack([('__getslice__', (testme, 0, 42))])
+ self.assertCallStack([('__getitem__', (testme, slice(None, 42)))])
callLst[:] = []
testme[:42] = "The Answer"
- self.assertCallStack([('__setslice__', (testme, 0, 42, "The Answer"))])
+ self.assertCallStack([('__setitem__', (testme, slice(None, 42),
+ "The Answer"))])
callLst[:] = []
del testme[:42]
- self.assertCallStack([('__delslice__', (testme, 0, 42))])
+ self.assertCallStack([('__delitem__', (testme, slice(None, 42)))])
callLst[:] = []
testme[2:1024:10]
@@ -319,50 +322,6 @@ class ClassTests(unittest.TestCase):
slice(None, 24, None),
24, 100)))])
- # Now remove the slice hooks to see if converting normal slices to
- # slice object works.
-
- getslice = AllTests.__getslice__
- del AllTests.__getslice__
- setslice = AllTests.__setslice__
- del AllTests.__setslice__
- delslice = AllTests.__delslice__
- del AllTests.__delslice__
-
- # XXX when using new-style classes the slice testme[:42] produces
- # slice(None, 42, None) instead of slice(0, 42, None). py3k will have
- # to change this test.
- callLst[:] = []
- testme[:42]
- self.assertCallStack([('__getitem__', (testme, slice(0, 42, None)))])
-
- callLst[:] = []
- testme[:42] = "The Answer"
- self.assertCallStack([('__setitem__', (testme, slice(0, 42, None),
- "The Answer"))])
- callLst[:] = []
- del testme[:42]
- self.assertCallStack([('__delitem__', (testme, slice(0, 42, None)))])
-
- # Restore the slice methods, or the tests will fail with regrtest -R.
- AllTests.__getslice__ = getslice
- AllTests.__setslice__ = setslice
- AllTests.__delslice__ = delslice
-
-
- @test_support.cpython_only
- def testDelItem(self):
- class A:
- ok = False
- def __delitem__(self, key):
- self.ok = True
- a = A()
- # Subtle: we need to call PySequence_SetItem, not PyMapping_SetItem.
- from _testcapi import sequence_delitem
- sequence_delitem(a, 2)
- self.assertTrue(a.ok)
-
-
def testUnaryOps(self):
testme = AllTests()
@@ -379,17 +338,14 @@ class ClassTests(unittest.TestCase):
int(testme)
self.assertCallStack([('__int__', (testme,))])
callLst[:] = []
- long(testme)
- self.assertCallStack([('__long__', (testme,))])
- callLst[:] = []
float(testme)
self.assertCallStack([('__float__', (testme,))])
callLst[:] = []
oct(testme)
- self.assertCallStack([('__oct__', (testme,))])
+ self.assertCallStack([('__index__', (testme,))])
callLst[:] = []
hex(testme)
- self.assertCallStack([('__hex__', (testme,))])
+ self.assertCallStack([('__index__', (testme,))])
def testMisc(self):
@@ -409,43 +365,35 @@ class ClassTests(unittest.TestCase):
callLst[:] = []
testme == 1
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
+ self.assertCallStack([('__eq__', (testme, 1))])
callLst[:] = []
testme < 1
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
+ self.assertCallStack([('__lt__', (testme, 1))])
callLst[:] = []
testme > 1
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
-
- callLst[:] = []
- eval('testme <> 1') # XXX kill this in py3k
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
+ self.assertCallStack([('__gt__', (testme, 1))])
callLst[:] = []
testme != 1
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (testme, 1))])
+ self.assertCallStack([('__ne__', (testme, 1))])
callLst[:] = []
1 == testme
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
+ self.assertCallStack([('__eq__', (1, testme))])
callLst[:] = []
1 < testme
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
+ self.assertCallStack([('__gt__', (1, testme))])
callLst[:] = []
1 > testme
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
-
- callLst[:] = []
- eval('1 <> testme')
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
+ self.assertCallStack([('__lt__', (1, testme))])
callLst[:] = []
1 != testme
- self.assertCallStack([("__coerce__", (testme, 1)), ('__cmp__', (1, testme))])
+ self.assertCallStack([('__ne__', (1, testme))])
def testGetSetAndDel(self):
@@ -496,40 +444,14 @@ class ClassTests(unittest.TestCase):
def __int__(self):
return None
__float__ = __int__
- __long__ = __int__
__str__ = __int__
__repr__ = __int__
__oct__ = __int__
__hex__ = __int__
- for f in [int, float, long, str, repr, oct, hex]:
+ for f in [int, float, str, repr, oct, hex]:
self.assertRaises(TypeError, f, BadTypeClass())
- def testMixIntsAndLongs(self):
- # mixing up ints and longs is okay
- class IntLongMixClass:
- @trackCall
- def __int__(self):
- return 42L
-
- @trackCall
- def __long__(self):
- return 64
-
- mixIntAndLong = IntLongMixClass()
-
- callLst[:] = []
- as_int = int(mixIntAndLong)
- self.assertEqual(type(as_int), long)
- self.assertEqual(as_int, 42L)
- self.assertCallStack([('__int__', (mixIntAndLong,))])
-
- callLst[:] = []
- as_long = long(mixIntAndLong)
- self.assertEqual(type(as_long), long)
- self.assertEqual(as_long, 64)
- self.assertCallStack([('__long__', (mixIntAndLong,))])
-
def testHashStuff(self):
# Test correct errors from hash() on objects with comparisons but
# no __hash__
@@ -539,11 +461,6 @@ class ClassTests(unittest.TestCase):
hash(C0()) # This should work; the next two should raise TypeError
- class C1:
- def __cmp__(self, other): return 0
-
- self.assertRaises(TypeError, hash, C1())
-
class C2:
def __eq__(self, other): return 1
@@ -575,7 +492,7 @@ class ClassTests(unittest.TestCase):
a = property(booh)
try:
A().a # Raised AttributeError: A instance has no attribute 'a'
- except AttributeError, x:
+ except AttributeError as x:
if str(x) != "booh":
self.fail("attribute error for A().a got masked: %s" % x)
@@ -589,7 +506,7 @@ class ClassTests(unittest.TestCase):
# In debug mode, printed XXX undetected error and
# raises AttributeError
I()
- except AttributeError, x:
+ except AttributeError as x:
pass
else:
self.fail("attribute error for I.__init__ got masked")
@@ -625,22 +542,11 @@ class ClassTests(unittest.TestCase):
self.assertEqual(hash(B.f), hash(A.f))
# the following triggers a SystemError in 2.4
- a = A(hash(A.f.im_func)^(-1))
+ a = A(hash(A.f)^(-1))
hash(a.f)
- def testAttrSlots(self):
- class C:
- pass
- for c in C, C():
- self.assertRaises(TypeError, type(c).__getattribute__, c, [])
- self.assertRaises(TypeError, type(c).__setattr__, c, [], [])
-
def test_main():
- with test_support.check_py3k_warnings(
- (".+__(get|set|del)slice__ has been removed", DeprecationWarning),
- ("classic int division", DeprecationWarning),
- ("<> not supported", DeprecationWarning)):
- test_support.run_unittest(ClassTests)
+ support.run_unittest(ClassTests)
if __name__=='__main__':
test_main()
diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py
index 8b5c4bf34ff..692ea361f44 100644
--- a/Lib/test/test_cmath.py
+++ b/Lib/test/test_cmath.py
@@ -1,8 +1,9 @@
-from test.test_support import run_unittest
+from test.support import run_unittest, requires_IEEE_754
from test.test_math import parse_testfile, test_file
import unittest
import cmath, math
from cmath import phase, polar, rect, pi
+import sysconfig
INF = float('inf')
NAN = float('nan')
@@ -61,6 +62,39 @@ class CMathTests(unittest.TestCase):
def tearDown(self):
self.test_values.close()
+ def assertFloatIdentical(self, x, y):
+ """Fail unless floats x and y are identical, in the sense that:
+ (1) both x and y are nans, or
+ (2) both x and y are infinities, with the same sign, or
+ (3) both x and y are zeros, with the same sign, or
+ (4) x and y are both finite and nonzero, and x == y
+
+ """
+ msg = 'floats {!r} and {!r} are not identical'
+
+ if math.isnan(x) or math.isnan(y):
+ if math.isnan(x) and math.isnan(y):
+ return
+ elif x == y:
+ if x != 0.0:
+ return
+ # both zero; check that signs match
+ elif math.copysign(1.0, x) == math.copysign(1.0, y):
+ return
+ else:
+ msg += ': zeros have different signs'
+ self.fail(msg.format(x, y))
+
+ def assertComplexIdentical(self, x, y):
+ """Fail unless complex numbers x and y have equal values and signs.
+
+ In particular, if x and y both have real (or imaginary) part
+ zero, but the zeros have different signs, this test will fail.
+
+ """
+ self.assertFloatIdentical(x.real, y.real)
+ self.assertFloatIdentical(x.imag, y.imag)
+
def rAssertAlmostEqual(self, a, b, rel_err = 2e-15, abs_err = 5e-323,
msg=None):
"""Fail if the two floating-point numbers are not almost equal.
@@ -131,7 +165,7 @@ class CMathTests(unittest.TestCase):
# a variety of non-complex numbers, used to check that
# non-complex return values from __complex__ give an error
- non_complexes = ["not complex", 1, 5L, 2., None,
+ non_complexes = ["not complex", 1, 5, 2., None,
object(), NotImplemented]
# Now we introduce a variety of classes whose instances might
@@ -168,11 +202,9 @@ class CMathTests(unittest.TestCase):
pass
class MyInt(object):
def __int__(self): return 2
- def __long__(self): return 2L
def __index__(self): return 2
class MyIntOS:
def __int__(self): return 2
- def __long__(self): return 2L
def __index__(self): return 2
# other possible combinations of __float__ and __complex__
@@ -205,7 +237,7 @@ class CMathTests(unittest.TestCase):
self.assertEqual(f(JustFloatOS()), f(flt_arg))
# TypeError should be raised for classes not providing
# either __complex__ or __float__, even if they provide
- # __int__, __long__ or __index__. An old-style class
+ # __int__ or __index__. An old-style class
# currently raises AttributeError instead of a TypeError;
# this could be considered a bug.
self.assertRaises(TypeError, f, NeitherComplexNorFloat())
@@ -224,7 +256,7 @@ class CMathTests(unittest.TestCase):
# ints and longs should be acceptable inputs to all cmath
# functions, by virtue of providing a __float__ method
for f in self.test_functions:
- for arg in [2, 2L, 2.]:
+ for arg in [2, 2.]:
self.assertEqual(f(arg), f(arg.__float__()))
# but strings should give a TypeError
@@ -280,10 +312,8 @@ class CMathTests(unittest.TestCase):
self.rAssertAlmostEqual(math.log(v, base), z.real)
self.assertEqual(0., z.imag)
+ @requires_IEEE_754
def test_specific_values(self):
- if not float.__getformat__("double").startswith("IEEE"):
- return
-
def rect_complex(z):
"""Wrapped version of rect that accepts a complex number instead of
two float arguments."""
@@ -428,9 +458,11 @@ class CMathTests(unittest.TestCase):
self.assertEqual(abs(complex(INF, NAN)), INF)
self.assertTrue(math.isnan(abs(complex(NAN, NAN))))
+
+ @requires_IEEE_754
+ def test_abs_overflows(self):
# result overflows
- if float.__getformat__("double").startswith("IEEE"):
- self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
+ self.assertRaises(OverflowError, abs, complex(1.4e308, 1.4e308))
def assertCEqual(self, a, b):
eps = 1E-7
@@ -444,6 +476,15 @@ class CMathTests(unittest.TestCase):
self.assertCEqual(rect(1, pi/2), (0, 1.))
self.assertCEqual(rect(1, -pi/2), (0, -1.))
+ def test_isfinite(self):
+ real_vals = [float('-inf'), -2.3, -0.0,
+ 0.0, 2.3, float('inf'), float('nan')]
+ for x in real_vals:
+ for y in real_vals:
+ z = complex(x, y)
+ self.assertEqual(cmath.isfinite(z),
+ math.isfinite(x) and math.isfinite(y))
+
def test_isnan(self):
self.assertFalse(cmath.isnan(1))
self.assertFalse(cmath.isnan(1j))
@@ -466,6 +507,27 @@ class CMathTests(unittest.TestCase):
self.assertTrue(cmath.isinf(complex(NAN, INF)))
self.assertTrue(cmath.isinf(complex(INF, NAN)))
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('TANH_PRESERVES_ZERO_SIGN') == 0,
+ "system tanh() function doesn't copy the sign")
+ def testTanhSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.tanh(z), z)
+
+ # The algorithm used for atan and atanh makes use of the system
+ # log1p function; If that system function doesn't respect the sign
+ # of zero, then atan and atanh will also have difficulties with
+ # the sign of complex zeros.
+ @requires_IEEE_754
+ def testAtanSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.atan(z), z)
+
+ @requires_IEEE_754
+ def testAtanhSign(self):
+ for z in complex_zeros:
+ self.assertComplexIdentical(cmath.atanh(z), z)
+
def test_main():
run_unittest(CMathTests)
diff --git a/Lib/test/test_cmd.py b/Lib/test/test_cmd.py
index ed9258b1bfe..3a463558fb7 100644
--- a/Lib/test/test_cmd.py
+++ b/Lib/test/test_cmd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""
Test script for the 'cmd' module
Original by Michael Schneider
@@ -7,10 +7,10 @@ Original by Michael Schneider
import cmd
import sys
-from test import test_support
import re
import unittest
-import StringIO
+import io
+from test import support
class samplecmdclass(cmd.Cmd):
"""
@@ -100,9 +100,9 @@ class samplecmdclass(cmd.Cmd):
<BLANKLINE>
Test for the function columnize():
- >>> mycmd.columnize([str(i) for i in xrange(20)])
+ >>> mycmd.columnize([str(i) for i in range(20)])
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
- >>> mycmd.columnize([str(i) for i in xrange(20)], 10)
+ >>> mycmd.columnize([str(i) for i in range(20)], 10)
0 7 14
1 8 15
2 9 16
@@ -136,18 +136,16 @@ class samplecmdclass(cmd.Cmd):
"""
def preloop(self):
- print "Hello from preloop"
+ print("Hello from preloop")
def postloop(self):
- print "Hello from postloop"
+ print("Hello from postloop")
def completedefault(self, *ignored):
- print "This is the completedefault methode"
- return
+ print("This is the completedefault methode")
def complete_command(self):
- print "complete command"
- return
+ print("complete command")
def do_shell(self, s):
pass
@@ -155,17 +153,17 @@ class samplecmdclass(cmd.Cmd):
def do_add(self, s):
l = s.split()
if len(l) != 2:
- print "*** invalid number of arguments"
+ print("*** invalid number of arguments")
return
try:
l = [int(i) for i in l]
except ValueError:
- print "*** arguments should be numbers"
+ print("*** arguments should be numbers")
return
- print l[0]+l[1]
+ print(l[0]+l[1])
def help_add(self):
- print "help text for add"
+ print("help text for add")
return
def do_exit(self, arg):
@@ -177,7 +175,7 @@ class TestAlternateInput(unittest.TestCase):
class simplecmd(cmd.Cmd):
def do_print(self, args):
- print >>self.stdout, args
+ print(args, file=self.stdout)
def do_EOF(self, args):
return True
@@ -186,13 +184,13 @@ class TestAlternateInput(unittest.TestCase):
class simplecmd2(simplecmd):
def do_EOF(self, args):
- print >>self.stdout, '*** Unknown syntax: EOF'
+ print('*** Unknown syntax: EOF', file=self.stdout)
return True
def test_file_with_missing_final_nl(self):
- input = StringIO.StringIO("print test\nprint test2")
- output = StringIO.StringIO()
+ input = io.StringIO("print test\nprint test2")
+ output = io.StringIO()
cmd = self.simplecmd(stdin=input, stdout=output)
cmd.use_rawinput = False
cmd.cmdloop()
@@ -203,8 +201,8 @@ class TestAlternateInput(unittest.TestCase):
def test_input_reset_at_EOF(self):
- input = StringIO.StringIO("print test\nprint test2")
- output = StringIO.StringIO()
+ input = io.StringIO("print test\nprint test2")
+ output = io.StringIO()
cmd = self.simplecmd2(stdin=input, stdout=output)
cmd.use_rawinput = False
cmd.cmdloop()
@@ -212,8 +210,8 @@ class TestAlternateInput(unittest.TestCase):
("(Cmd) test\n"
"(Cmd) test2\n"
"(Cmd) *** Unknown syntax: EOF\n"))
- input = StringIO.StringIO("print \n\n")
- output = StringIO.StringIO()
+ input = io.StringIO("print \n\n")
+ output = io.StringIO()
cmd.stdin = input
cmd.stdout = output
cmd.cmdloop()
@@ -225,16 +223,16 @@ class TestAlternateInput(unittest.TestCase):
def test_main(verbose=None):
from test import test_cmd
- test_support.run_doctest(test_cmd, verbose)
- test_support.run_unittest(TestAlternateInput)
+ support.run_doctest(test_cmd, verbose)
+ support.run_unittest(TestAlternateInput)
def test_coverage(coverdir):
- trace = test_support.import_module('trace')
+ trace = support.import_module('trace')
tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
trace=0, count=1)
tracer.run('reload(cmd);test_main()')
r=tracer.results()
- print "Writing coverage results..."
+ print("Writing coverage results...")
r.write_results(show_missing=True, summary=True, coverdir=coverdir)
if __name__ == "__main__":
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py
index 12f26d9e450..c10bd761ac3 100644
--- a/Lib/test/test_cmd_line.py
+++ b/Lib/test/test_cmd_line.py
@@ -1,32 +1,32 @@
# Tests invocation of the interpreter with various command line arguments
-# All tests are executed with environment variables ignored
+# Most tests are executed with environment variables ignored
# See test_cmd_line_script.py for testing of script execution
-import test.test_support
+import test.support, unittest
+import os
import sys
-import unittest
-from test.script_helper import (
- assert_python_ok, assert_python_failure, spawn_python, kill_python,
- python_exit_code
-)
+import subprocess
+import tempfile
+from test.script_helper import (spawn_python, kill_python, assert_python_ok,
+ assert_python_failure)
-class CmdLineTest(unittest.TestCase):
- def start_python(self, *args):
- p = spawn_python(*args)
- return kill_python(p)
-
- def exit_code(self, *args):
- return python_exit_code(*args)
+# XXX (ncoghlan): Move to script_helper and make consistent with run_python
+def _kill_python_and_exit_code(p):
+ data = kill_python(p)
+ returncode = p.wait()
+ return data, returncode
+class CmdLineTest(unittest.TestCase):
def test_directories(self):
- self.assertNotEqual(self.exit_code('.'), 0)
- self.assertNotEqual(self.exit_code('< .'), 0)
+ assert_python_failure('.')
+ assert_python_failure('< .')
def verify_valid_flag(self, cmd_line):
- data = self.start_python(cmd_line)
- self.assertTrue(data == '' or data.endswith('\n'))
- self.assertNotIn('Traceback', data)
+ rc, out, err = assert_python_ok(*cmd_line)
+ self.assertTrue(out == b'' or out.endswith(b'\n'))
+ self.assertNotIn(b'Traceback', out)
+ self.assertNotIn(b'Traceback', err)
def test_optimize(self):
self.verify_valid_flag('-O')
@@ -42,53 +42,307 @@ class CmdLineTest(unittest.TestCase):
self.verify_valid_flag('-S')
def test_usage(self):
- self.assertIn('usage', self.start_python('-h'))
+ rc, out, err = assert_python_ok('-h')
+ self.assertIn(b'usage', out)
def test_version(self):
- version = 'Python %d.%d' % sys.version_info[:2]
- self.assertTrue(self.start_python('-V').startswith(version))
+ version = ('Python %d.%d' % sys.version_info[:2]).encode("ascii")
+ rc, out, err = assert_python_ok('-V')
+ self.assertTrue(err.startswith(version))
+
+ def test_verbose(self):
+ # -v causes imports to write to stderr. If the write to
+ # stderr itself causes an import to happen (for the output
+ # codec), a recursion loop can occur.
+ rc, out, err = assert_python_ok('-v')
+ self.assertNotIn(b'stack overflow', err)
+ rc, out, err = assert_python_ok('-vv')
+ self.assertNotIn(b'stack overflow', err)
+
+ def test_xoptions(self):
+ rc, out, err = assert_python_ok('-c', 'import sys; print(sys._xoptions)')
+ opts = eval(out.splitlines()[0])
+ self.assertEqual(opts, {})
+ rc, out, err = assert_python_ok(
+ '-Xa', '-Xb=c,d=e', '-c', 'import sys; print(sys._xoptions)')
+ opts = eval(out.splitlines()[0])
+ self.assertEqual(opts, {'a': True, 'b': 'c,d=e'})
def test_run_module(self):
# Test expected operation of the '-m' switch
# Switch needs an argument
- self.assertNotEqual(self.exit_code('-m'), 0)
+ assert_python_failure('-m')
# Check we get an error for a nonexistent module
- self.assertNotEqual(
- self.exit_code('-m', 'fnord43520xyz'),
- 0)
+ assert_python_failure('-m', 'fnord43520xyz')
# Check the runpy module also gives an error for
# a nonexistent module
- self.assertNotEqual(
- self.exit_code('-m', 'runpy', 'fnord43520xyz'),
- 0)
+ assert_python_failure('-m', 'runpy', 'fnord43520xyz'),
# All good if module is located and run successfully
- self.assertEqual(
- self.exit_code('-m', 'timeit', '-n', '1'),
- 0)
+ assert_python_ok('-m', 'timeit', '-n', '1'),
def test_run_module_bug1764407(self):
# -m and -i need to play well together
# Runs the timeit module and checks the __main__
# namespace has been populated appropriately
p = spawn_python('-i', '-m', 'timeit', '-n', '1')
- p.stdin.write('Timer\n')
- p.stdin.write('exit()\n')
+ p.stdin.write(b'Timer\n')
+ p.stdin.write(b'exit()\n')
data = kill_python(p)
- self.assertTrue(data.startswith('1 loop'))
- self.assertIn('__main__.Timer', data)
+ self.assertTrue(data.find(b'1 loop') != -1)
+ self.assertTrue(data.find(b'__main__.Timer') != -1)
def test_run_code(self):
# Test expected operation of the '-c' switch
# Switch needs an argument
- self.assertNotEqual(self.exit_code('-c'), 0)
+ assert_python_failure('-c')
# Check we get an error for an uncaught exception
- self.assertNotEqual(
- self.exit_code('-c', 'raise Exception'),
- 0)
+ assert_python_failure('-c', 'raise Exception')
# All good if execution is successful
- self.assertEqual(
- self.exit_code('-c', 'pass'),
- 0)
+ assert_python_ok('-c', 'pass')
+
+ @unittest.skipIf(sys.getfilesystemencoding() == 'ascii',
+ 'need a filesystem encoding different than ASCII')
+ def test_non_ascii(self):
+ # Test handling of non-ascii data
+ command = "assert(ord('\xe9') == 0xe9)"
+ assert_python_ok('-c', command)
+
+ # On Windows, pass bytes to subprocess doesn't test how Python decodes the
+ # command line, but how subprocess does decode bytes to unicode. Python
+ # doesn't decode the command line because Windows provides directly the
+ # arguments as unicode (using wmain() instead of main()).
+ @unittest.skipIf(sys.platform == 'win32',
+ 'Windows has a native unicode API')
+ def test_undecodable_code(self):
+ undecodable = b"\xff"
+ env = os.environ.copy()
+ # Use C locale to get ascii for the locale encoding
+ env['LC_ALL'] = 'C'
+ code = (
+ b'import locale; '
+ b'print(ascii("' + undecodable + b'"), '
+ b'locale.getpreferredencoding())')
+ p = subprocess.Popen(
+ [sys.executable, "-c", code],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ env=env)
+ stdout, stderr = p.communicate()
+ if p.returncode == 1:
+ # _Py_char2wchar() decoded b'\xff' as '\udcff' (b'\xff' is not
+ # decodable from ASCII) and run_command() failed on
+ # PyUnicode_AsUTF8String(). This is the expected behaviour on
+ # Linux.
+ pattern = b"Unable to decode the command from the command line:"
+ elif p.returncode == 0:
+ # _Py_char2wchar() decoded b'\xff' as '\xff' even if the locale is
+ # C and the locale encoding is ASCII. It occurs on FreeBSD, Solaris
+ # and Mac OS X.
+ pattern = b"'\\xff' "
+ # The output is followed by the encoding name, an alias to ASCII.
+ # Examples: "US-ASCII" or "646" (ISO 646, on Solaris).
+ else:
+ raise AssertionError("Unknown exit code: %s, output=%a" % (p.returncode, stdout))
+ if not stdout.startswith(pattern):
+ raise AssertionError("%a doesn't start with %a" % (stdout, pattern))
+
+ @unittest.skipUnless(sys.platform == 'darwin', 'test specific to Mac OS X')
+ def test_osx_utf8(self):
+ def check_output(text):
+ decoded = text.decode('utf8', 'surrogateescape')
+ expected = ascii(decoded).encode('ascii') + b'\n'
+
+ env = os.environ.copy()
+ # C locale gives ASCII locale encoding, but Python uses UTF-8
+ # to parse the command line arguments on Mac OS X
+ env['LC_ALL'] = 'C'
+
+ p = subprocess.Popen(
+ (sys.executable, "-c", "import sys; print(ascii(sys.argv[1]))", text),
+ stdout=subprocess.PIPE,
+ env=env)
+ stdout, stderr = p.communicate()
+ self.assertEqual(stdout, expected)
+ self.assertEqual(p.returncode, 0)
+
+ # test valid utf-8
+ text = 'e:\xe9, euro:\u20ac, non-bmp:\U0010ffff'.encode('utf-8')
+ check_output(text)
+
+ # test invalid utf-8
+ text = (
+ b'\xff' # invalid byte
+ b'\xc3\xa9' # valid utf-8 character
+ b'\xc3\xff' # invalid byte sequence
+ b'\xed\xa0\x80' # lone surrogate character (invalid)
+ )
+ check_output(text)
+
+ def test_unbuffered_output(self):
+ # Test expected operation of the '-u' switch
+ for stream in ('stdout', 'stderr'):
+ # Binary is unbuffered
+ code = ("import os, sys; sys.%s.buffer.write(b'x'); os._exit(0)"
+ % stream)
+ rc, out, err = assert_python_ok('-u', '-c', code)
+ data = err if stream == 'stderr' else out
+ self.assertEqual(data, b'x', "binary %s not unbuffered" % stream)
+ # Text is line-buffered
+ code = ("import os, sys; sys.%s.write('x\\n'); os._exit(0)"
+ % stream)
+ rc, out, err = assert_python_ok('-u', '-c', code)
+ data = err if stream == 'stderr' else out
+ self.assertEqual(data.strip(), b'x',
+ "text %s not line-buffered" % stream)
+
+ def test_unbuffered_input(self):
+ # sys.stdin still works with '-u'
+ code = ("import sys; sys.stdout.write(sys.stdin.read(1))")
+ p = spawn_python('-u', '-c', code)
+ p.stdin.write(b'x')
+ p.stdin.flush()
+ data, rc = _kill_python_and_exit_code(p)
+ self.assertEqual(rc, 0)
+ self.assertTrue(data.startswith(b'x'), data)
+
+ def test_large_PYTHONPATH(self):
+ path1 = "ABCDE" * 100
+ path2 = "FGHIJ" * 100
+ path = path1 + os.pathsep + path2
+
+ code = """if 1:
+ import sys
+ path = ":".join(sys.path)
+ path = path.encode("ascii", "backslashreplace")
+ sys.stdout.buffer.write(path)"""
+ rc, out, err = assert_python_ok('-S', '-c', code,
+ PYTHONPATH=path)
+ self.assertIn(path1.encode('ascii'), out)
+ self.assertIn(path2.encode('ascii'), out)
+
+ def test_displayhook_unencodable(self):
+ for encoding in ('ascii', 'latin1', 'utf8'):
+ env = os.environ.copy()
+ env['PYTHONIOENCODING'] = encoding
+ p = subprocess.Popen(
+ [sys.executable, '-i'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ env=env)
+ # non-ascii, surrogate, non-BMP printable, non-BMP unprintable
+ text = "a=\xe9 b=\uDC80 c=\U00010000 d=\U0010FFFF"
+ p.stdin.write(ascii(text).encode('ascii') + b"\n")
+ p.stdin.write(b'exit()\n')
+ data = kill_python(p)
+ escaped = repr(text).encode(encoding, 'backslashreplace')
+ self.assertIn(escaped, data)
+
+ def check_input(self, code, expected):
+ with tempfile.NamedTemporaryFile("wb+") as stdin:
+ sep = os.linesep.encode('ASCII')
+ stdin.write(sep.join((b'abc', b'def')))
+ stdin.flush()
+ stdin.seek(0)
+ with subprocess.Popen(
+ (sys.executable, "-c", code),
+ stdin=stdin, stdout=subprocess.PIPE) as proc:
+ stdout, stderr = proc.communicate()
+ self.assertEqual(stdout.rstrip(), expected)
+
+ def test_stdin_readline(self):
+ # Issue #11272: check that sys.stdin.readline() replaces '\r\n' by '\n'
+ # on Windows (sys.stdin is opened in binary mode)
+ self.check_input(
+ "import sys; print(repr(sys.stdin.readline()))",
+ b"'abc\\n'")
+
+ def test_builtin_input(self):
+ # Issue #11272: check that input() strips newlines ('\n' or '\r\n')
+ self.check_input(
+ "print(repr(input()))",
+ b"'abc'")
+
+ def test_output_newline(self):
+ # Issue 13119 Newline for print() should be \r\n on Windows.
+ code = """if 1:
+ import sys
+ print(1)
+ print(2)
+ print(3, file=sys.stderr)
+ print(4, file=sys.stderr)"""
+ rc, out, err = assert_python_ok('-c', code)
+
+ if sys.platform == 'win32':
+ self.assertEqual(b'1\r\n2\r\n', out)
+ self.assertEqual(b'3\r\n4', err)
+ else:
+ self.assertEqual(b'1\n2\n', out)
+ self.assertEqual(b'3\n4', err)
+
+ def test_unmached_quote(self):
+ # Issue #10206: python program starting with unmatched quote
+ # spewed spaces to stdout
+ rc, out, err = assert_python_failure('-c', "'")
+ self.assertRegex(err.decode('ascii', 'ignore'), 'SyntaxError')
+ self.assertEqual(b'', out)
+
+ def test_stdout_flush_at_shutdown(self):
+ # Issue #5319: if stdout.flush() fails at shutdown, an error should
+ # be printed out.
+ code = """if 1:
+ import os, sys
+ sys.stdout.write('x')
+ os.close(sys.stdout.fileno())"""
+ rc, out, err = assert_python_ok('-c', code)
+ self.assertEqual(b'', out)
+ self.assertRegex(err.decode('ascii', 'ignore'),
+ 'Exception IOError: .* ignored')
+
+ def test_closed_stdout(self):
+ # Issue #13444: if stdout has been explicitly closed, we should
+ # not attempt to flush it at shutdown.
+ code = "import sys; sys.stdout.close()"
+ rc, out, err = assert_python_ok('-c', code)
+ self.assertEqual(b'', err)
+
+ # Issue #7111: Python should work without standard streams
+
+ @unittest.skipIf(os.name != 'posix', "test needs POSIX semantics")
+ def _test_no_stdio(self, streams):
+ code = """if 1:
+ import os, sys
+ for i, s in enumerate({streams}):
+ if getattr(sys, s) is not None:
+ os._exit(i + 1)
+ os._exit(42)""".format(streams=streams)
+ def preexec():
+ if 'stdin' in streams:
+ os.close(0)
+ if 'stdout' in streams:
+ os.close(1)
+ if 'stderr' in streams:
+ os.close(2)
+ p = subprocess.Popen(
+ [sys.executable, "-E", "-c", code],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ preexec_fn=preexec)
+ out, err = p.communicate()
+ self.assertEqual(test.support.strip_python_stderr(err), b'')
+ self.assertEqual(p.returncode, 42)
+
+ def test_no_stdin(self):
+ self._test_no_stdio(['stdin'])
+
+ def test_no_stdout(self):
+ self._test_no_stdio(['stdout'])
+
+ def test_no_stderr(self):
+ self._test_no_stdio(['stderr'])
+
+ def test_no_std_streams(self):
+ self._test_no_stdio(['stdin', 'stdout', 'stderr'])
def test_hash_randomization(self):
# Verify that -R enables hash randomization:
@@ -96,24 +350,26 @@ class CmdLineTest(unittest.TestCase):
hashes = []
for i in range(2):
code = 'print(hash("spam"))'
- data = self.start_python('-R', '-c', code)
- hashes.append(data)
+ rc, out, err = assert_python_ok('-R', '-c', code)
+ self.assertEqual(rc, 0)
+ hashes.append(out)
self.assertNotEqual(hashes[0], hashes[1])
# Verify that sys.flags contains hash_randomization
- code = 'import sys; print sys.flags'
- data = self.start_python('-R', '-c', code)
- self.assertTrue('hash_randomization=1' in data)
+ code = 'import sys; print("random is", sys.flags.hash_randomization)'
+ rc, out, err = assert_python_ok('-R', '-c', code)
+ self.assertEqual(rc, 0)
+ self.assertIn(b'random is 1', out)
def test_del___main__(self):
# Issue #15001: PyRun_SimpleFileExFlags() did crash because it kept a
# borrowed reference to the dict of __main__ module and later modify
# the dict whereas the module was destroyed
- filename = test.test_support.TESTFN
- self.addCleanup(test.test_support.unlink, filename)
+ filename = test.support.TESTFN
+ self.addCleanup(test.support.unlink, filename)
with open(filename, "w") as script:
- print >>script, "import sys"
- print >>script, "del sys.modules['__main__']"
+ print("import sys", file=script)
+ print("del sys.modules['__main__']", file=script)
assert_python_ok(filename)
def test_unknown_options(self):
@@ -136,8 +392,8 @@ class CmdLineTest(unittest.TestCase):
def test_main():
- test.test_support.run_unittest(CmdLineTest)
- test.test_support.reap_children()
+ test.support.run_unittest(CmdLineTest)
+ test.support.reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_cmd_line_script.py b/Lib/test/test_cmd_line_script.py
index 8b05227b8b4..6b59d963491 100644
--- a/Lib/test/test_cmd_line_script.py
+++ b/Lib/test/test_cmd_line_script.py
@@ -1,16 +1,17 @@
-# Tests command line execution of scripts
+# tests command line execution of scripts
import unittest
+import sys
import os
import os.path
-import test.test_support
-from test.script_helper import (run_python,
- temp_dir, make_script, compile_script,
- assert_python_failure, make_pkg,
- make_zip_script, make_zip_pkg)
+import py_compile
-verbose = test.test_support.verbose
+from test import support
+from test.script_helper import (
+ make_pkg, make_script, make_zip_pkg, make_zip_script,
+ assert_python_ok, assert_python_failure, temp_dir)
+verbose = support.verbose
example_args = ['test1', 'test2', 'test3']
@@ -31,12 +32,20 @@ f()
assertEqual(result, ['Top level assignment', 'Lower level reference'])
# Check population of magic variables
assertEqual(__name__, '__main__')
-print '__file__==%r' % __file__
-print '__package__==%r' % __package__
+print('__file__==%a' % __file__)
+assertEqual(__cached__, None)
+print('__package__==%r' % __package__)
# Check the sys module
import sys
assertIdentical(globals(), sys.modules[__name__].__dict__)
-print 'sys.argv[0]==%r' % sys.argv[0]
+from test import test_cmd_line_script
+example_args_list = test_cmd_line_script.example_args
+assertEqual(sys.argv[1:], example_args_list)
+print('sys.argv[0]==%a' % sys.argv[0])
+print('sys.path[0]==%a' % sys.path[0])
+# Check the working directory
+import os
+print('cwd==%a' % os.getcwd())
"""
def _make_test_script(script_dir, script_basename, source=test_source):
@@ -66,60 +75,80 @@ def _make_launch_script(script_dir, script_basename, module_name, path=None):
return make_script(script_dir, script_basename, source)
class CmdLineTest(unittest.TestCase):
- def _check_script(self, script_name, expected_file,
- expected_argv0, expected_package,
- *cmd_line_switches):
- run_args = cmd_line_switches + (script_name,)
- exit_code, data = run_python(*run_args)
- if verbose:
- print 'Output from test script %r:' % script_name
- print data
+ def _check_output(self, script_name, exit_code, data,
+ expected_file, expected_argv0,
+ expected_path0, expected_package):
+ if verbose > 1:
+ print("Output from test script %r:" % script_name)
+ print(data)
self.assertEqual(exit_code, 0)
- printed_file = '__file__==%r' % expected_file
- printed_argv0 = 'sys.argv[0]==%r' % expected_argv0
+ printed_file = '__file__==%a' % expected_file
printed_package = '__package__==%r' % expected_package
- if verbose:
- print 'Expected output:'
- print printed_file
- print printed_package
- print printed_argv0
- self.assertIn(printed_file, data)
- self.assertIn(printed_package, data)
- self.assertIn(printed_argv0, data)
+ printed_argv0 = 'sys.argv[0]==%a' % expected_argv0
+ printed_path0 = 'sys.path[0]==%a' % expected_path0
+ printed_cwd = 'cwd==%a' % os.getcwd()
+ if verbose > 1:
+ print('Expected output:')
+ print(printed_file)
+ print(printed_package)
+ print(printed_argv0)
+ print(printed_cwd)
+ self.assertIn(printed_file.encode('utf-8'), data)
+ self.assertIn(printed_package.encode('utf-8'), data)
+ self.assertIn(printed_argv0.encode('utf-8'), data)
+ self.assertIn(printed_path0.encode('utf-8'), data)
+ self.assertIn(printed_cwd.encode('utf-8'), data)
+
+ def _check_script(self, script_name, expected_file,
+ expected_argv0, expected_path0,
+ expected_package,
+ *cmd_line_switches):
+ if not __debug__:
+ cmd_line_switches += ('-' + 'O' * sys.flags.optimize,)
+ run_args = cmd_line_switches + (script_name,) + tuple(example_args)
+ rc, out, err = assert_python_ok(*run_args)
+ self._check_output(script_name, rc, out + err, expected_file,
+ expected_argv0, expected_path0, expected_package)
def _check_import_error(self, script_name, expected_msg,
*cmd_line_switches):
run_args = cmd_line_switches + (script_name,)
- exit_code, data = run_python(*run_args)
- if verbose:
- print 'Output from test script %r:' % script_name
- print data
- print 'Expected output: %r' % expected_msg
- self.assertIn(expected_msg, data)
+ rc, out, err = assert_python_failure(*run_args)
+ if verbose > 1:
+ print('Output from test script %r:' % script_name)
+ print(err)
+ print('Expected output: %r' % expected_msg)
+ self.assertIn(expected_msg.encode('utf-8'), err)
def test_basic_script(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
- self._check_script(script_name, script_name, script_name, None)
+ self._check_script(script_name, script_name, script_name,
+ script_dir, None)
def test_script_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, 'script')
- compiled_name = compile_script(script_name)
+ py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- self._check_script(compiled_name, compiled_name, compiled_name, None)
+ pyc_file = support.make_legacy_pyc(script_name)
+ self._check_script(pyc_file, pyc_file,
+ pyc_file, script_dir, None)
def test_directory(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- self._check_script(script_dir, script_name, script_dir, '')
+ self._check_script(script_dir, script_name, script_dir,
+ script_dir, '')
def test_directory_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- compiled_name = compile_script(script_name)
+ py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- self._check_script(script_dir, compiled_name, script_dir, '')
+ pyc_file = support.make_legacy_pyc(script_name)
+ self._check_script(script_dir, pyc_file, script_dir,
+ script_dir, '')
def test_directory_error(self):
with temp_dir() as script_dir:
@@ -130,14 +159,14 @@ class CmdLineTest(unittest.TestCase):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
zip_name, run_name = make_zip_script(script_dir, 'test_zip', script_name)
- self._check_script(zip_name, run_name, zip_name, '')
+ self._check_script(zip_name, run_name, zip_name, zip_name, '')
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
script_name = _make_test_script(script_dir, '__main__')
- compiled_name = compile_script(script_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
zip_name, run_name = make_zip_script(script_dir, 'test_zip', compiled_name)
- self._check_script(zip_name, run_name, zip_name, '')
+ self._check_script(zip_name, run_name, zip_name, zip_name, '')
def test_zipfile_error(self):
with temp_dir() as script_dir:
@@ -152,19 +181,19 @@ class CmdLineTest(unittest.TestCase):
make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, 'script')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script')
- self._check_script(launch_name, script_name, script_name, 'test_pkg')
+ self._check_script(launch_name, script_name, script_name, script_dir, 'test_pkg')
def test_module_in_package_in_zipfile(self):
with temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script', zip_name)
- self._check_script(launch_name, run_name, run_name, 'test_pkg')
+ self._check_script(launch_name, run_name, run_name, zip_name, 'test_pkg')
def test_module_in_subpackage_in_zipfile(self):
with temp_dir() as script_dir:
zip_name, run_name = _make_test_zip_pkg(script_dir, 'test_zip', 'test_pkg', 'script', depth=2)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.test_pkg.script', zip_name)
- self._check_script(launch_name, run_name, run_name, 'test_pkg.test_pkg')
+ self._check_script(launch_name, run_name, run_name, zip_name, 'test_pkg.test_pkg')
def test_package(self):
with temp_dir() as script_dir:
@@ -173,18 +202,19 @@ class CmdLineTest(unittest.TestCase):
script_name = _make_test_script(pkg_dir, '__main__')
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
self._check_script(launch_name, script_name,
- script_name, 'test_pkg')
+ script_name, script_dir, 'test_pkg')
def test_package_compiled(self):
with temp_dir() as script_dir:
pkg_dir = os.path.join(script_dir, 'test_pkg')
make_pkg(pkg_dir)
script_name = _make_test_script(pkg_dir, '__main__')
- compiled_name = compile_script(script_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
os.remove(script_name)
+ pyc_file = support.make_legacy_pyc(script_name)
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
- self._check_script(launch_name, compiled_name,
- compiled_name, 'test_pkg')
+ self._check_script(launch_name, pyc_file,
+ pyc_file, script_dir, 'test_pkg')
def test_package_error(self):
with temp_dir() as script_dir:
@@ -207,23 +237,66 @@ class CmdLineTest(unittest.TestCase):
launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg')
self._check_import_error(launch_name, msg)
+ def test_issue8202(self):
+ # Make sure package __init__ modules see "-m" in sys.argv0 while
+ # searching for the module to execute
+ with temp_dir() as script_dir:
+ with support.temp_cwd(path=script_dir):
+ pkg_dir = os.path.join(script_dir, 'test_pkg')
+ make_pkg(pkg_dir, "import sys; print('init_argv0==%r' % sys.argv[0])")
+ script_name = _make_test_script(pkg_dir, 'script')
+ rc, out, err = assert_python_ok('-m', 'test_pkg.script', *example_args)
+ if verbose > 1:
+ print(out)
+ expected = "init_argv0==%r" % '-m'
+ self.assertIn(expected.encode('utf-8'), out)
+ self._check_output(script_name, rc, out,
+ script_name, script_name, '', 'test_pkg')
+
+ def test_issue8202_dash_c_file_ignored(self):
+ # Make sure a "-c" file in the current directory
+ # does not alter the value of sys.path[0]
+ with temp_dir() as script_dir:
+ with support.temp_cwd(path=script_dir):
+ with open("-c", "w") as f:
+ f.write("data")
+ rc, out, err = assert_python_ok('-c',
+ 'import sys; print("sys.path[0]==%r" % sys.path[0])')
+ if verbose > 1:
+ print(out)
+ expected = "sys.path[0]==%r" % ''
+ self.assertIn(expected.encode('utf-8'), out)
+
+ def test_issue8202_dash_m_file_ignored(self):
+ # Make sure a "-m" file in the current directory
+ # does not alter the value of sys.path[0]
+ with temp_dir() as script_dir:
+ script_name = _make_test_script(script_dir, 'other')
+ with support.temp_cwd(path=script_dir):
+ with open("-m", "w") as f:
+ f.write("data")
+ rc, out, err = assert_python_ok('-m', 'other', *example_args)
+ self._check_output(script_name, rc, out,
+ script_name, script_name, '', '')
+
def test_dash_m_error_code_is_one(self):
# If a module is invoked with the -m command line flag
# and results in an error that the return code to the
# shell is '1'
with temp_dir() as script_dir:
- pkg_dir = os.path.join(script_dir, 'test_pkg')
- make_pkg(pkg_dir)
- script_name = _make_test_script(pkg_dir, 'other', "if __name__ == '__main__': raise ValueError")
- rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)
- if verbose > 1:
- print(out)
- self.assertEqual(rc, 1)
-
+ with support.temp_cwd(path=script_dir):
+ pkg_dir = os.path.join(script_dir, 'test_pkg')
+ make_pkg(pkg_dir)
+ script_name = _make_test_script(pkg_dir, 'other',
+ "if __name__ == '__main__': raise ValueError")
+ rc, out, err = assert_python_failure('-m', 'test_pkg.other', *example_args)
+ if verbose > 1:
+ print(out)
+ self.assertEqual(rc, 1)
def test_main():
- test.test_support.run_unittest(CmdLineTest)
- test.test_support.reap_children()
+ support.run_unittest(CmdLineTest)
+ support.reap_children()
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index 97adf590bc9..e1c7a783de1 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -6,9 +6,10 @@
... return g
...
->>> dump(f.func_code)
+>>> dump(f.__code__)
name: f
argcount: 1
+kwonlyargcount: 0
names: ()
varnames: ('x', 'g')
cellvars: ('x',)
@@ -17,9 +18,10 @@ nlocals: 2
flags: 3
consts: ('None', '<code object g>')
->>> dump(f(4).func_code)
+>>> dump(f(4).__code__)
name: g
argcount: 1
+kwonlyargcount: 0
names: ()
varnames: ('y',)
cellvars: ()
@@ -34,9 +36,11 @@ consts: ('None',)
... c = a * b
... return c
...
->>> dump(h.func_code)
+
+>>> dump(h.__code__)
name: h
argcount: 2
+kwonlyargcount: 0
names: ()
varnames: ('x', 'y', 'a', 'b', 'c')
cellvars: ()
@@ -46,14 +50,15 @@ flags: 67
consts: ('None',)
>>> def attrs(obj):
-... print obj.attr1
-... print obj.attr2
-... print obj.attr3
+... print(obj.attr1)
+... print(obj.attr2)
+... print(obj.attr3)
->>> dump(attrs.func_code)
+>>> dump(attrs.__code__)
name: attrs
argcount: 1
-names: ('attr1', 'attr2', 'attr3')
+kwonlyargcount: 0
+names: ('print', 'attr1', 'attr2', 'attr3')
varnames: ('obj',)
cellvars: ()
freevars: ()
@@ -65,11 +70,12 @@ consts: ('None',)
... 'doc string'
... 'not a docstring'
... 53
-... 53L
+... 0x53
->>> dump(optimize_away.func_code)
+>>> dump(optimize_away.__code__)
name: optimize_away
argcount: 0
+kwonlyargcount: 0
names: ()
varnames: ()
cellvars: ()
@@ -78,6 +84,22 @@ nlocals: 0
flags: 67
consts: ("'doc string'", 'None')
+>>> def keywordonly_args(a,b,*,k1):
+... return a,b,k1
+...
+
+>>> dump(keywordonly_args.__code__)
+name: keywordonly_args
+argcount: 2
+kwonlyargcount: 1
+names: ()
+varnames: ('a', 'b', 'k1')
+cellvars: ()
+freevars: ()
+nlocals: 3
+flags: 67
+consts: ('None',)
+
"""
import unittest
@@ -96,10 +118,10 @@ def consts(t):
def dump(co):
"""Print out a text representation of a code object."""
- for attr in ["name", "argcount", "names", "varnames", "cellvars",
- "freevars", "nlocals", "flags"]:
- print "%s: %s" % (attr, getattr(co, "co_" + attr))
- print "consts:", tuple(consts(co.co_consts))
+ for attr in ["name", "argcount", "kwonlyargcount", "names", "varnames",
+ "cellvars", "freevars", "nlocals", "flags"]:
+ print("%s: %s" % (attr, getattr(co, "co_" + attr)))
+ print("consts:", tuple(consts(co.co_consts)))
class CodeTest(unittest.TestCase):
@@ -117,7 +139,7 @@ class CodeWeakRefTest(unittest.TestCase):
# Create a code object in a clean environment so that we know we have
# the only reference to it left.
namespace = {}
- exec "def f(): pass" in globals(), namespace
+ exec("def f(): pass", globals(), namespace)
f = namespace["f"]
del namespace
@@ -137,7 +159,7 @@ class CodeWeakRefTest(unittest.TestCase):
def test_main(verbose=None):
- from test.test_support import run_doctest, run_unittest
+ from test.support import run_doctest, run_unittest
from test import test_code
run_doctest(test_code, verbose)
run_unittest(CodeTest, CodeWeakRefTest)
diff --git a/Lib/test/test_codeccallbacks.py b/Lib/test/test_codeccallbacks.py
index 150a0d2a809..e656d2fe8f7 100644
--- a/Lib/test/test_codeccallbacks.py
+++ b/Lib/test/test_codeccallbacks.py
@@ -1,5 +1,5 @@
-import test.test_support, unittest
-import sys, codecs, htmlentitydefs, unicodedata
+import test.support, unittest
+import sys, codecs, html.entities, unicodedata
class PosReturn:
# this can be used for configurable callbacks
@@ -16,48 +16,48 @@ class PosReturn:
# otherwise we'd get an endless loop
if realpos <= exc.start:
self.pos = len(exc.object)
- return (u"<?>", oldpos)
+ return ("<?>", oldpos)
# A UnicodeEncodeError object with a bad start attribute
class BadStartUnicodeEncodeError(UnicodeEncodeError):
def __init__(self):
- UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad")
+ UnicodeEncodeError.__init__(self, "ascii", "", 0, 1, "bad")
self.start = []
# A UnicodeEncodeError object with a bad object attribute
class BadObjectUnicodeEncodeError(UnicodeEncodeError):
def __init__(self):
- UnicodeEncodeError.__init__(self, "ascii", u"", 0, 1, "bad")
+ UnicodeEncodeError.__init__(self, "ascii", "", 0, 1, "bad")
self.object = []
# A UnicodeDecodeError object without an end attribute
class NoEndUnicodeDecodeError(UnicodeDecodeError):
def __init__(self):
- UnicodeDecodeError.__init__(self, "ascii", "", 0, 1, "bad")
+ UnicodeDecodeError.__init__(self, "ascii", bytearray(b""), 0, 1, "bad")
del self.end
# A UnicodeDecodeError object with a bad object attribute
class BadObjectUnicodeDecodeError(UnicodeDecodeError):
def __init__(self):
- UnicodeDecodeError.__init__(self, "ascii", "", 0, 1, "bad")
+ UnicodeDecodeError.__init__(self, "ascii", bytearray(b""), 0, 1, "bad")
self.object = []
# A UnicodeTranslateError object without a start attribute
class NoStartUnicodeTranslateError(UnicodeTranslateError):
def __init__(self):
- UnicodeTranslateError.__init__(self, u"", 0, 1, "bad")
+ UnicodeTranslateError.__init__(self, "", 0, 1, "bad")
del self.start
# A UnicodeTranslateError object without an end attribute
class NoEndUnicodeTranslateError(UnicodeTranslateError):
def __init__(self):
- UnicodeTranslateError.__init__(self, u"", 0, 1, "bad")
+ UnicodeTranslateError.__init__(self, "", 0, 1, "bad")
del self.end
# A UnicodeTranslateError object without an object attribute
class NoObjectUnicodeTranslateError(UnicodeTranslateError):
def __init__(self):
- UnicodeTranslateError.__init__(self, u"", 0, 1, "bad")
+ UnicodeTranslateError.__init__(self, "", 0, 1, "bad")
del self.object
class CodecCallbackTest(unittest.TestCase):
@@ -66,14 +66,14 @@ class CodecCallbackTest(unittest.TestCase):
# replace unencodable characters which numeric character entities.
# For ascii, latin-1 and charmaps this is completely implemented
# in C and should be reasonably fast.
- s = u"\u30b9\u30d1\u30e2 \xe4nd eggs"
+ s = "\u30b9\u30d1\u30e2 \xe4nd eggs"
self.assertEqual(
s.encode("ascii", "xmlcharrefreplace"),
- "&#12473;&#12497;&#12514; &#228;nd eggs"
+ b"&#12473;&#12497;&#12514; &#228;nd eggs"
)
self.assertEqual(
s.encode("latin-1", "xmlcharrefreplace"),
- "&#12473;&#12497;&#12514; \xe4nd eggs"
+ b"&#12473;&#12497;&#12514; \xe4nd eggs"
)
def test_xmlcharnamereplace(self):
@@ -86,20 +86,20 @@ class CodecCallbackTest(unittest.TestCase):
l = []
for c in exc.object[exc.start:exc.end]:
try:
- l.append(u"&%s;" % htmlentitydefs.codepoint2name[ord(c)])
+ l.append("&%s;" % html.entities.codepoint2name[ord(c)])
except KeyError:
- l.append(u"&#%d;" % ord(c))
- return (u"".join(l), exc.end)
+ l.append("&#%d;" % ord(c))
+ return ("".join(l), exc.end)
codecs.register_error(
"test.xmlcharnamereplace", xmlcharnamereplace)
- sin = u"\xab\u211c\xbb = \u2329\u1234\u20ac\u232a"
- sout = "&laquo;&real;&raquo; = &lang;&#4660;&euro;&rang;"
+ sin = "\xab\u211c\xbb = \u2329\u1234\u20ac\u232a"
+ sout = b"&laquo;&real;&raquo; = &lang;&#4660;&euro;&rang;"
self.assertEqual(sin.encode("ascii", "test.xmlcharnamereplace"), sout)
- sout = "\xab&real;\xbb = &lang;&#4660;&euro;&rang;"
+ sout = b"\xab&real;\xbb = &lang;&#4660;&euro;&rang;"
self.assertEqual(sin.encode("latin-1", "test.xmlcharnamereplace"), sout)
- sout = "\xab&real;\xbb = &lang;&#4660;\xa4&rang;"
+ sout = b"\xab&real;\xbb = &lang;&#4660;\xa4&rang;"
self.assertEqual(sin.encode("iso-8859-15", "test.xmlcharnamereplace"), sout)
def test_uninamereplace(self):
@@ -116,41 +116,41 @@ class CodecCallbackTest(unittest.TestCase):
raise TypeError("don't know how to handle %r" % exc)
l = []
for c in exc.object[exc.start:exc.end]:
- l.append(unicodedata.name(c, u"0x%x" % ord(c)))
- return (u"\033[1m%s\033[0m" % u", ".join(l), exc.end)
+ l.append(unicodedata.name(c, "0x%x" % ord(c)))
+ return ("\033[1m%s\033[0m" % ", ".join(l), exc.end)
codecs.register_error(
"test.uninamereplace", uninamereplace)
- sin = u"\xac\u1234\u20ac\u8000"
- sout = "\033[1mNOT SIGN, ETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000\033[0m"
+ sin = "\xac\u1234\u20ac\u8000"
+ sout = b"\033[1mNOT SIGN, ETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000\033[0m"
self.assertEqual(sin.encode("ascii", "test.uninamereplace"), sout)
- sout = "\xac\033[1mETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000\033[0m"
+ sout = b"\xac\033[1mETHIOPIC SYLLABLE SEE, EURO SIGN, CJK UNIFIED IDEOGRAPH-8000\033[0m"
self.assertEqual(sin.encode("latin-1", "test.uninamereplace"), sout)
- sout = "\xac\033[1mETHIOPIC SYLLABLE SEE\033[0m\xa4\033[1mCJK UNIFIED IDEOGRAPH-8000\033[0m"
+ sout = b"\xac\033[1mETHIOPIC SYLLABLE SEE\033[0m\xa4\033[1mCJK UNIFIED IDEOGRAPH-8000\033[0m"
self.assertEqual(sin.encode("iso-8859-15", "test.uninamereplace"), sout)
def test_backslashescape(self):
# Does the same as the "unicode-escape" encoding, but with different
# base encodings.
- sin = u"a\xac\u1234\u20ac\u8000"
+ sin = "a\xac\u1234\u20ac\u8000"
if sys.maxunicode > 0xffff:
- sin += unichr(sys.maxunicode)
- sout = "a\\xac\\u1234\\u20ac\\u8000"
+ sin += chr(sys.maxunicode)
+ sout = b"a\\xac\\u1234\\u20ac\\u8000"
if sys.maxunicode > 0xffff:
- sout += "\\U%08x" % sys.maxunicode
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("ascii", "backslashreplace"), sout)
- sout = "a\xac\\u1234\\u20ac\\u8000"
+ sout = b"a\xac\\u1234\\u20ac\\u8000"
if sys.maxunicode > 0xffff:
- sout += "\\U%08x" % sys.maxunicode
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("latin-1", "backslashreplace"), sout)
- sout = "a\xac\\u1234\xa4\\u8000"
+ sout = b"a\xac\\u1234\xa4\\u8000"
if sys.maxunicode > 0xffff:
- sout += "\\U%08x" % sys.maxunicode
+ sout += bytes("\\U%08x" % sys.maxunicode, "ascii")
self.assertEqual(sin.encode("iso-8859-15", "backslashreplace"), sout)
def test_decoding_callbacks(self):
@@ -161,20 +161,20 @@ class CodecCallbackTest(unittest.TestCase):
def relaxedutf8(exc):
if not isinstance(exc, UnicodeDecodeError):
raise TypeError("don't know how to handle %r" % exc)
- if exc.object[exc.start:exc.start+2] == "\xc0\x80":
- return (u"\x00", exc.start+2) # retry after two bytes
+ if exc.object[exc.start:exc.start+2] == b"\xc0\x80":
+ return ("\x00", exc.start+2) # retry after two bytes
else:
raise exc
codecs.register_error("test.relaxedutf8", relaxedutf8)
# all the "\xc0\x80" will be decoded to "\x00"
- sin = "a\x00b\xc0\x80c\xc3\xbc\xc0\x80\xc0\x80"
- sout = u"a\x00b\x00c\xfc\x00\x00"
+ sin = b"a\x00b\xc0\x80c\xc3\xbc\xc0\x80\xc0\x80"
+ sout = "a\x00b\x00c\xfc\x00\x00"
self.assertEqual(sin.decode("utf-8", "test.relaxedutf8"), sout)
# "\xc0\x81" is not valid and a UnicodeDecodeError will be raised
- sin = "\xc0\x80\xc0\x81"
+ sin = b"\xc0\x80\xc0\x81"
self.assertRaises(UnicodeDecodeError, sin.decode,
"utf-8", "test.relaxedutf8")
@@ -183,106 +183,106 @@ class CodecCallbackTest(unittest.TestCase):
# mapped through the encoding again. This means, that
# to be able to use e.g. the "replace" handler, the
# charmap has to have a mapping for "?".
- charmap = dict([ (ord(c), 2*c.upper()) for c in "abcdefgh"])
- sin = u"abc"
- sout = "AABBCC"
+ charmap = dict((ord(c), bytes(2*c.upper(), 'ascii')) for c in "abcdefgh")
+ sin = "abc"
+ sout = b"AABBCC"
self.assertEqual(codecs.charmap_encode(sin, "strict", charmap)[0], sout)
- sin = u"abcA"
+ sin = "abcA"
self.assertRaises(UnicodeError, codecs.charmap_encode, sin, "strict", charmap)
- charmap[ord("?")] = "XYZ"
- sin = u"abcDEF"
- sout = "AABBCCXYZXYZXYZ"
+ charmap[ord("?")] = b"XYZ"
+ sin = "abcDEF"
+ sout = b"AABBCCXYZXYZXYZ"
self.assertEqual(codecs.charmap_encode(sin, "replace", charmap)[0], sout)
- charmap[ord("?")] = u"XYZ"
- self.assertRaises(TypeError, codecs.charmap_encode, sin, "replace", charmap)
-
- charmap[ord("?")] = u"XYZ"
+ charmap[ord("?")] = "XYZ" # wrong type in mapping
self.assertRaises(TypeError, codecs.charmap_encode, sin, "replace", charmap)
def test_decodeunicodeinternal(self):
self.assertRaises(
UnicodeDecodeError,
- "\x00\x00\x00\x00\x00".decode,
+ b"\x00\x00\x00\x00\x00".decode,
"unicode-internal",
)
if sys.maxunicode > 0xffff:
def handler_unicodeinternal(exc):
if not isinstance(exc, UnicodeDecodeError):
raise TypeError("don't know how to handle %r" % exc)
- return (u"\x01", 1)
+ return ("\x01", 1)
self.assertEqual(
- "\x00\x00\x00\x00\x00".decode("unicode-internal", "ignore"),
- u"\u0000"
+ b"\x00\x00\x00\x00\x00".decode("unicode-internal", "ignore"),
+ "\u0000"
)
self.assertEqual(
- "\x00\x00\x00\x00\x00".decode("unicode-internal", "replace"),
- u"\u0000\ufffd"
+ b"\x00\x00\x00\x00\x00".decode("unicode-internal", "replace"),
+ "\u0000\ufffd"
)
codecs.register_error("test.hui", handler_unicodeinternal)
self.assertEqual(
- "\x00\x00\x00\x00\x00".decode("unicode-internal", "test.hui"),
- u"\u0000\u0001\u0000"
+ b"\x00\x00\x00\x00\x00".decode("unicode-internal", "test.hui"),
+ "\u0000\u0001\u0000"
)
def test_callbacks(self):
def handler1(exc):
- if not isinstance(exc, UnicodeEncodeError) \
- and not isinstance(exc, UnicodeDecodeError):
+ r = range(exc.start, exc.end)
+ if isinstance(exc, UnicodeEncodeError):
+ l = ["<%d>" % ord(exc.object[pos]) for pos in r]
+ elif isinstance(exc, UnicodeDecodeError):
+ l = ["<%d>" % exc.object[pos] for pos in r]
+ else:
raise TypeError("don't know how to handle %r" % exc)
- l = [u"<%d>" % ord(exc.object[pos]) for pos in xrange(exc.start, exc.end)]
- return (u"[%s]" % u"".join(l), exc.end)
+ return ("[%s]" % "".join(l), exc.end)
codecs.register_error("test.handler1", handler1)
def handler2(exc):
if not isinstance(exc, UnicodeDecodeError):
raise TypeError("don't know how to handle %r" % exc)
- l = [u"<%d>" % ord(exc.object[pos]) for pos in xrange(exc.start, exc.end)]
- return (u"[%s]" % u"".join(l), exc.end+1) # skip one character
+ l = ["<%d>" % exc.object[pos] for pos in range(exc.start, exc.end)]
+ return ("[%s]" % "".join(l), exc.end+1) # skip one character
codecs.register_error("test.handler2", handler2)
- s = "\x00\x81\x7f\x80\xff"
+ s = b"\x00\x81\x7f\x80\xff"
self.assertEqual(
s.decode("ascii", "test.handler1"),
- u"\x00[<129>]\x7f[<128>][<255>]"
+ "\x00[<129>]\x7f[<128>][<255>]"
)
self.assertEqual(
s.decode("ascii", "test.handler2"),
- u"\x00[<129>][<128>]"
+ "\x00[<129>][<128>]"
)
self.assertEqual(
- "\\u3042\u3xxx".decode("unicode-escape", "test.handler1"),
- u"\u3042[<92><117><51><120>]xx"
+ b"\\u3042\u3xxx".decode("unicode-escape", "test.handler1"),
+ "\u3042[<92><117><51><120>]xx"
)
self.assertEqual(
- "\\u3042\u3xx".decode("unicode-escape", "test.handler1"),
- u"\u3042[<92><117><51><120><120>]"
+ b"\\u3042\u3xx".decode("unicode-escape", "test.handler1"),
+ "\u3042[<92><117><51><120><120>]"
)
self.assertEqual(
- codecs.charmap_decode("abc", "test.handler1", {ord("a"): u"z"})[0],
- u"z[<98>][<99>]"
+ codecs.charmap_decode(b"abc", "test.handler1", {ord("a"): "z"})[0],
+ "z[<98>][<99>]"
)
self.assertEqual(
- u"g\xfc\xdfrk".encode("ascii", "test.handler1"),
- u"g[<252><223>]rk"
+ "g\xfc\xdfrk".encode("ascii", "test.handler1"),
+ b"g[<252><223>]rk"
)
self.assertEqual(
- u"g\xfc\xdf".encode("ascii", "test.handler1"),
- u"g[<252><223>]"
+ "g\xfc\xdf".encode("ascii", "test.handler1"),
+ b"g[<252><223>]"
)
def test_longstrings(self):
@@ -295,7 +295,7 @@ class CodecCallbackTest(unittest.TestCase):
codecs.register_error("test." + err, codecs.lookup_error(err))
l = 1000
errors += [ "test." + err for err in errors ]
- for uni in [ s*l for s in (u"x", u"\u3042", u"a\xe4") ]:
+ for uni in [ s*l for s in ("x", "\u3042", "a\xe4") ]:
for enc in ("ascii", "latin-1", "iso-8859-1", "iso-8859-15",
"utf-8", "utf-7", "utf-16", "utf-32"):
for err in errors:
@@ -311,14 +311,14 @@ class CodecCallbackTest(unittest.TestCase):
# check with one argument too much
self.assertRaises(TypeError, exctype, *(args + ["too much"]))
# check with one argument of the wrong type
- wrongargs = [ "spam", u"eggs", 42, 1.0, None ]
- for i in xrange(len(args)):
+ wrongargs = [ "spam", b"eggs", b"spam", 42, 1.0, None ]
+ for i in range(len(args)):
for wrongarg in wrongargs:
if type(wrongarg) is type(args[i]):
continue
# build argument array
callargs = []
- for j in xrange(len(args)):
+ for j in range(len(args)):
if i==j:
callargs.append(wrongarg)
else:
@@ -332,73 +332,73 @@ class CodecCallbackTest(unittest.TestCase):
def test_unicodeencodeerror(self):
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"g\xfcrk", 1, 2, "ouch"],
- "'ascii' codec can't encode character u'\\xfc' in position 1: ouch"
+ ["ascii", "g\xfcrk", 1, 2, "ouch"],
+ "'ascii' codec can't encode character '\\xfc' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"g\xfcrk", 1, 4, "ouch"],
+ ["ascii", "g\xfcrk", 1, 4, "ouch"],
"'ascii' codec can't encode characters in position 1-3: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"\xfcx", 0, 1, "ouch"],
- "'ascii' codec can't encode character u'\\xfc' in position 0: ouch"
+ ["ascii", "\xfcx", 0, 1, "ouch"],
+ "'ascii' codec can't encode character '\\xfc' in position 0: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"\u0100x", 0, 1, "ouch"],
- "'ascii' codec can't encode character u'\\u0100' in position 0: ouch"
+ ["ascii", "\u0100x", 0, 1, "ouch"],
+ "'ascii' codec can't encode character '\\u0100' in position 0: ouch"
)
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"\uffffx", 0, 1, "ouch"],
- "'ascii' codec can't encode character u'\\uffff' in position 0: ouch"
+ ["ascii", "\uffffx", 0, 1, "ouch"],
+ "'ascii' codec can't encode character '\\uffff' in position 0: ouch"
)
if sys.maxunicode > 0xffff:
self.check_exceptionobjectargs(
UnicodeEncodeError,
- ["ascii", u"\U00010000x", 0, 1, "ouch"],
- "'ascii' codec can't encode character u'\\U00010000' in position 0: ouch"
+ ["ascii", "\U00010000x", 0, 1, "ouch"],
+ "'ascii' codec can't encode character '\\U00010000' in position 0: ouch"
)
def test_unicodedecodeerror(self):
self.check_exceptionobjectargs(
UnicodeDecodeError,
- ["ascii", "g\xfcrk", 1, 2, "ouch"],
+ ["ascii", bytearray(b"g\xfcrk"), 1, 2, "ouch"],
"'ascii' codec can't decode byte 0xfc in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeDecodeError,
- ["ascii", "g\xfcrk", 1, 3, "ouch"],
+ ["ascii", bytearray(b"g\xfcrk"), 1, 3, "ouch"],
"'ascii' codec can't decode bytes in position 1-2: ouch"
)
def test_unicodetranslateerror(self):
self.check_exceptionobjectargs(
UnicodeTranslateError,
- [u"g\xfcrk", 1, 2, "ouch"],
- "can't translate character u'\\xfc' in position 1: ouch"
+ ["g\xfcrk", 1, 2, "ouch"],
+ "can't translate character '\\xfc' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
- [u"g\u0100rk", 1, 2, "ouch"],
- "can't translate character u'\\u0100' in position 1: ouch"
+ ["g\u0100rk", 1, 2, "ouch"],
+ "can't translate character '\\u0100' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
- [u"g\uffffrk", 1, 2, "ouch"],
- "can't translate character u'\\uffff' in position 1: ouch"
+ ["g\uffffrk", 1, 2, "ouch"],
+ "can't translate character '\\uffff' in position 1: ouch"
)
if sys.maxunicode > 0xffff:
self.check_exceptionobjectargs(
UnicodeTranslateError,
- [u"g\U00010000rk", 1, 2, "ouch"],
- "can't translate character u'\\U00010000' in position 1: ouch"
+ ["g\U00010000rk", 1, 2, "ouch"],
+ "can't translate character '\\U00010000' in position 1: ouch"
)
self.check_exceptionobjectargs(
UnicodeTranslateError,
- [u"g\xfcrk", 1, 3, "ouch"],
+ ["g\xfcrk", 1, 3, "ouch"],
"can't translate characters in position 1-2: ouch"
)
@@ -420,7 +420,7 @@ class CodecCallbackTest(unittest.TestCase):
self.assertRaises(
UnicodeEncodeError,
codecs.strict_errors,
- UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")
+ UnicodeEncodeError("ascii", "\u3042", 0, 1, "ouch")
)
def test_badandgoodignoreexceptions(self):
@@ -438,16 +438,19 @@ class CodecCallbackTest(unittest.TestCase):
)
# If the correct exception is passed in, "ignore" returns an empty replacement
self.assertEqual(
- codecs.ignore_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")),
- (u"", 1)
+ codecs.ignore_errors(
+ UnicodeEncodeError("ascii", "\u3042", 0, 1, "ouch")),
+ ("", 1)
)
self.assertEqual(
- codecs.ignore_errors(UnicodeDecodeError("ascii", "\xff", 0, 1, "ouch")),
- (u"", 1)
+ codecs.ignore_errors(
+ UnicodeDecodeError("ascii", bytearray(b"\xff"), 0, 1, "ouch")),
+ ("", 1)
)
self.assertEqual(
- codecs.ignore_errors(UnicodeTranslateError(u"\u3042", 0, 1, "ouch")),
- (u"", 1)
+ codecs.ignore_errors(
+ UnicodeTranslateError("\u3042", 0, 1, "ouch")),
+ ("", 1)
)
def test_badandgoodreplaceexceptions(self):
@@ -473,18 +476,21 @@ class CodecCallbackTest(unittest.TestCase):
codecs.replace_errors,
BadObjectUnicodeDecodeError()
)
- # With the correct exception, "replace" returns an "?" or u"\ufffd" replacement
+ # With the correct exception, "replace" returns an "?" or "\ufffd" replacement
self.assertEqual(
- codecs.replace_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")),
- (u"?", 1)
+ codecs.replace_errors(
+ UnicodeEncodeError("ascii", "\u3042", 0, 1, "ouch")),
+ ("?", 1)
)
self.assertEqual(
- codecs.replace_errors(UnicodeDecodeError("ascii", "\xff", 0, 1, "ouch")),
- (u"\ufffd", 1)
+ codecs.replace_errors(
+ UnicodeDecodeError("ascii", bytearray(b"\xff"), 0, 1, "ouch")),
+ ("\ufffd", 1)
)
self.assertEqual(
- codecs.replace_errors(UnicodeTranslateError(u"\u3042", 0, 1, "ouch")),
- (u"\ufffd", 1)
+ codecs.replace_errors(
+ UnicodeTranslateError("\u3042", 0, 1, "ouch")),
+ ("\ufffd", 1)
)
def test_badandgoodxmlcharrefreplaceexceptions(self):
@@ -504,21 +510,21 @@ class CodecCallbackTest(unittest.TestCase):
self.assertRaises(
TypeError,
codecs.xmlcharrefreplace_errors,
- UnicodeDecodeError("ascii", "\xff", 0, 1, "ouch")
+ UnicodeDecodeError("ascii", bytearray(b"\xff"), 0, 1, "ouch")
)
self.assertRaises(
TypeError,
codecs.xmlcharrefreplace_errors,
- UnicodeTranslateError(u"\u3042", 0, 1, "ouch")
+ UnicodeTranslateError("\u3042", 0, 1, "ouch")
)
# Use the correct exception
cs = (0, 1, 9, 10, 99, 100, 999, 1000, 9999, 10000, 0x3042)
- s = "".join(unichr(c) for c in cs)
+ s = "".join(chr(c) for c in cs)
self.assertEqual(
codecs.xmlcharrefreplace_errors(
UnicodeEncodeError("ascii", s, 0, len(s), "ouch")
),
- (u"".join(u"&#%d;" % ord(c) for c in s), len(s))
+ ("".join("&#%d;" % ord(c) for c in s), len(s))
)
def test_badandgoodbackslashreplaceexceptions(self):
@@ -538,46 +544,67 @@ class CodecCallbackTest(unittest.TestCase):
self.assertRaises(
TypeError,
codecs.backslashreplace_errors,
- UnicodeDecodeError("ascii", "\xff", 0, 1, "ouch")
+ UnicodeDecodeError("ascii", bytearray(b"\xff"), 0, 1, "ouch")
)
self.assertRaises(
TypeError,
codecs.backslashreplace_errors,
- UnicodeTranslateError(u"\u3042", 0, 1, "ouch")
+ UnicodeTranslateError("\u3042", 0, 1, "ouch")
)
# Use the correct exception
self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\u3042", 0, 1, "ouch")),
- (u"\\u3042", 1)
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\u3042", 0, 1, "ouch")),
+ ("\\u3042", 1)
)
self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\x00", 0, 1, "ouch")),
- (u"\\x00", 1)
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\x00", 0, 1, "ouch")),
+ ("\\x00", 1)
)
self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\xff", 0, 1, "ouch")),
- (u"\\xff", 1)
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\xff", 0, 1, "ouch")),
+ ("\\xff", 1)
)
self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\u0100", 0, 1, "ouch")),
- (u"\\u0100", 1)
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\u0100", 0, 1, "ouch")),
+ ("\\u0100", 1)
)
self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\uffff", 0, 1, "ouch")),
- (u"\\uffff", 1)
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\uffff", 0, 1, "ouch")),
+ ("\\uffff", 1)
+ )
+ # 1 on UCS-4 builds, 2 on UCS-2
+ len_wide = len("\U00010000")
+ self.assertEqual(
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\U00010000",
+ 0, len_wide, "ouch")),
+ ("\\U00010000", len_wide)
+ )
+ self.assertEqual(
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\U0010ffff",
+ 0, len_wide, "ouch")),
+ ("\\U0010ffff", len_wide)
+ )
+ # Lone surrogates (regardless of unicode width)
+ self.assertEqual(
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\ud800", 0, 1, "ouch")),
+ ("\\ud800", 1)
+ )
+ self.assertEqual(
+ codecs.backslashreplace_errors(
+ UnicodeEncodeError("ascii", "\udfff", 0, 1, "ouch")),
+ ("\\udfff", 1)
)
- if sys.maxunicode>0xffff:
- self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\U00010000", 0, 1, "ouch")),
- (u"\\U00010000", 1)
- )
- self.assertEqual(
- codecs.backslashreplace_errors(UnicodeEncodeError("ascii", u"\U0010ffff", 0, 1, "ouch")),
- (u"\\U0010ffff", 1)
- )
def test_badhandlerresults(self):
- results = ( 42, u"foo", (1,2,3), (u"foo", 1, 3), (u"foo", None), (u"foo",), ("foo", 1, 3), ("foo", None), ("foo",) )
+ results = ( 42, "foo", (1,2,3), ("foo", 1, 3), ("foo", None), ("foo",), ("foo", 1, 3), ("foo", None), ("foo",) )
encs = ("ascii", "latin-1", "iso-8859-1", "iso-8859-15")
for res in results:
@@ -585,15 +612,15 @@ class CodecCallbackTest(unittest.TestCase):
for enc in encs:
self.assertRaises(
TypeError,
- u"\u3042".encode,
+ "\u3042".encode,
enc,
"test.badhandler"
)
for (enc, bytes) in (
- ("ascii", "\xff"),
- ("utf-8", "\xff"),
- ("utf-7", "+x-"),
- ("unicode-internal", "\x00"),
+ ("ascii", b"\xff"),
+ ("utf-8", b"\xff"),
+ ("utf-7", b"+x-"),
+ ("unicode-internal", b"\x00"),
):
self.assertRaises(
TypeError,
@@ -618,14 +645,14 @@ class CodecCallbackTest(unittest.TestCase):
def test_unencodablereplacement(self):
def unencrepl(exc):
if isinstance(exc, UnicodeEncodeError):
- return (u"\u4242", exc.end)
+ return ("\u4242", exc.end)
else:
raise TypeError("don't know how to handle %r" % exc)
codecs.register_error("test.unencreplhandler", unencrepl)
for enc in ("ascii", "iso-8859-1", "iso-8859-15"):
self.assertRaises(
UnicodeEncodeError,
- u"\u4242".encode,
+ "\u4242".encode,
enc,
"test.unencreplhandler"
)
@@ -654,7 +681,7 @@ class CodecCallbackTest(unittest.TestCase):
v = (1, 5, 10, 50, 100, 500, 1000, 5000, 10000, 50000)
if sys.maxunicode>=100000:
v += (100000, 500000, 1000000)
- s = u"".join([unichr(x) for x in v])
+ s = "".join([chr(x) for x in v])
codecs.register_error("test.xmlcharrefreplace", codecs.xmlcharrefreplace_errors)
for enc in ("ascii", "iso-8859-15"):
for err in ("xmlcharrefreplace", "test.xmlcharrefreplace"):
@@ -664,103 +691,103 @@ class CodecCallbackTest(unittest.TestCase):
# enhance coverage of:
# Objects/unicodeobject.c::unicode_decode_call_errorhandler()
# and callers
- self.assertRaises(LookupError, "\xff".decode, "ascii", "test.unknown")
+ self.assertRaises(LookupError, b"\xff".decode, "ascii", "test.unknown")
def baddecodereturn1(exc):
return 42
codecs.register_error("test.baddecodereturn1", baddecodereturn1)
- self.assertRaises(TypeError, "\xff".decode, "ascii", "test.baddecodereturn1")
- self.assertRaises(TypeError, "\\".decode, "unicode-escape", "test.baddecodereturn1")
- self.assertRaises(TypeError, "\\x0".decode, "unicode-escape", "test.baddecodereturn1")
- self.assertRaises(TypeError, "\\x0y".decode, "unicode-escape", "test.baddecodereturn1")
- self.assertRaises(TypeError, "\\Uffffeeee".decode, "unicode-escape", "test.baddecodereturn1")
- self.assertRaises(TypeError, "\\uyyyy".decode, "raw-unicode-escape", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\xff".decode, "ascii", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\\".decode, "unicode-escape", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\\x0".decode, "unicode-escape", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\\x0y".decode, "unicode-escape", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\\Uffffeeee".decode, "unicode-escape", "test.baddecodereturn1")
+ self.assertRaises(TypeError, b"\\uyyyy".decode, "raw-unicode-escape", "test.baddecodereturn1")
def baddecodereturn2(exc):
- return (u"?", None)
+ return ("?", None)
codecs.register_error("test.baddecodereturn2", baddecodereturn2)
- self.assertRaises(TypeError, "\xff".decode, "ascii", "test.baddecodereturn2")
+ self.assertRaises(TypeError, b"\xff".decode, "ascii", "test.baddecodereturn2")
handler = PosReturn()
codecs.register_error("test.posreturn", handler.handle)
# Valid negative position
handler.pos = -1
- self.assertEqual("\xff0".decode("ascii", "test.posreturn"), u"<?>0")
+ self.assertEqual(b"\xff0".decode("ascii", "test.posreturn"), "<?>0")
# Valid negative position
handler.pos = -2
- self.assertEqual("\xff0".decode("ascii", "test.posreturn"), u"<?><?>")
+ self.assertEqual(b"\xff0".decode("ascii", "test.posreturn"), "<?><?>")
# Negative position out of bounds
handler.pos = -3
- self.assertRaises(IndexError, "\xff0".decode, "ascii", "test.posreturn")
+ self.assertRaises(IndexError, b"\xff0".decode, "ascii", "test.posreturn")
# Valid positive position
handler.pos = 1
- self.assertEqual("\xff0".decode("ascii", "test.posreturn"), u"<?>0")
+ self.assertEqual(b"\xff0".decode("ascii", "test.posreturn"), "<?>0")
# Largest valid positive position (one beyond end of input)
handler.pos = 2
- self.assertEqual("\xff0".decode("ascii", "test.posreturn"), u"<?>")
+ self.assertEqual(b"\xff0".decode("ascii", "test.posreturn"), "<?>")
# Invalid positive position
handler.pos = 3
- self.assertRaises(IndexError, "\xff0".decode, "ascii", "test.posreturn")
+ self.assertRaises(IndexError, b"\xff0".decode, "ascii", "test.posreturn")
# Restart at the "0"
handler.pos = 6
- self.assertEqual("\\uyyyy0".decode("raw-unicode-escape", "test.posreturn"), u"<?>0")
+ self.assertEqual(b"\\uyyyy0".decode("raw-unicode-escape", "test.posreturn"), "<?>0")
class D(dict):
def __getitem__(self, key):
raise ValueError
- self.assertRaises(UnicodeError, codecs.charmap_decode, "\xff", "strict", {0xff: None})
- self.assertRaises(ValueError, codecs.charmap_decode, "\xff", "strict", D())
- self.assertRaises(TypeError, codecs.charmap_decode, "\xff", "strict", {0xff: 0x110000})
+ self.assertRaises(UnicodeError, codecs.charmap_decode, b"\xff", "strict", {0xff: None})
+ self.assertRaises(ValueError, codecs.charmap_decode, b"\xff", "strict", D())
+ self.assertRaises(TypeError, codecs.charmap_decode, b"\xff", "strict", {0xff: 0x110000})
def test_encodehelper(self):
# enhance coverage of:
# Objects/unicodeobject.c::unicode_encode_call_errorhandler()
# and callers
- self.assertRaises(LookupError, u"\xff".encode, "ascii", "test.unknown")
+ self.assertRaises(LookupError, "\xff".encode, "ascii", "test.unknown")
def badencodereturn1(exc):
return 42
codecs.register_error("test.badencodereturn1", badencodereturn1)
- self.assertRaises(TypeError, u"\xff".encode, "ascii", "test.badencodereturn1")
+ self.assertRaises(TypeError, "\xff".encode, "ascii", "test.badencodereturn1")
def badencodereturn2(exc):
- return (u"?", None)
+ return ("?", None)
codecs.register_error("test.badencodereturn2", badencodereturn2)
- self.assertRaises(TypeError, u"\xff".encode, "ascii", "test.badencodereturn2")
+ self.assertRaises(TypeError, "\xff".encode, "ascii", "test.badencodereturn2")
handler = PosReturn()
codecs.register_error("test.posreturn", handler.handle)
# Valid negative position
handler.pos = -1
- self.assertEqual(u"\xff0".encode("ascii", "test.posreturn"), "<?>0")
+ self.assertEqual("\xff0".encode("ascii", "test.posreturn"), b"<?>0")
# Valid negative position
handler.pos = -2
- self.assertEqual(u"\xff0".encode("ascii", "test.posreturn"), "<?><?>")
+ self.assertEqual("\xff0".encode("ascii", "test.posreturn"), b"<?><?>")
# Negative position out of bounds
handler.pos = -3
- self.assertRaises(IndexError, u"\xff0".encode, "ascii", "test.posreturn")
+ self.assertRaises(IndexError, "\xff0".encode, "ascii", "test.posreturn")
# Valid positive position
handler.pos = 1
- self.assertEqual(u"\xff0".encode("ascii", "test.posreturn"), "<?>0")
+ self.assertEqual("\xff0".encode("ascii", "test.posreturn"), b"<?>0")
# Largest valid positive position (one beyond end of input
handler.pos = 2
- self.assertEqual(u"\xff0".encode("ascii", "test.posreturn"), "<?>")
+ self.assertEqual("\xff0".encode("ascii", "test.posreturn"), b"<?>")
# Invalid positive position
handler.pos = 3
- self.assertRaises(IndexError, u"\xff0".encode, "ascii", "test.posreturn")
+ self.assertRaises(IndexError, "\xff0".encode, "ascii", "test.posreturn")
handler.pos = 0
@@ -768,9 +795,9 @@ class CodecCallbackTest(unittest.TestCase):
def __getitem__(self, key):
raise ValueError
for err in ("strict", "replace", "xmlcharrefreplace", "backslashreplace", "test.posreturn"):
- self.assertRaises(UnicodeError, codecs.charmap_encode, u"\xff", err, {0xff: None})
- self.assertRaises(ValueError, codecs.charmap_encode, u"\xff", err, D())
- self.assertRaises(TypeError, codecs.charmap_encode, u"\xff", err, {0xff: 300})
+ self.assertRaises(UnicodeError, codecs.charmap_encode, "\xff", err, {0xff: None})
+ self.assertRaises(ValueError, codecs.charmap_encode, "\xff", err, D())
+ self.assertRaises(TypeError, codecs.charmap_encode, "\xff", err, {0xff: 300})
def test_translatehelper(self):
# enhance coverage of:
@@ -781,24 +808,58 @@ class CodecCallbackTest(unittest.TestCase):
class D(dict):
def __getitem__(self, key):
raise ValueError
- self.assertRaises(ValueError, u"\xff".translate, D())
- self.assertRaises(TypeError, u"\xff".translate, {0xff: sys.maxunicode+1})
- self.assertRaises(TypeError, u"\xff".translate, {0xff: ()})
+ #self.assertRaises(ValueError, "\xff".translate, D())
+ self.assertRaises(TypeError, "\xff".translate, {0xff: sys.maxunicode+1})
+ self.assertRaises(TypeError, "\xff".translate, {0xff: ()})
def test_bug828737(self):
charmap = {
- ord("&"): u"&amp;",
- ord("<"): u"&lt;",
- ord(">"): u"&gt;",
- ord('"'): u"&quot;",
+ ord("&"): "&amp;",
+ ord("<"): "&lt;",
+ ord(">"): "&gt;",
+ ord('"'): "&quot;",
}
for n in (1, 10, 100, 1000):
- text = u'abc<def>ghi'*n
+ text = 'abc<def>ghi'*n
text.translate(charmap)
+ def test_mutatingdecodehandler(self):
+ baddata = [
+ ("ascii", b"\xff"),
+ ("utf-7", b"++"),
+ ("utf-8", b"\xff"),
+ ("utf-16", b"\xff"),
+ ("utf-32", b"\xff"),
+ ("unicode-escape", b"\\u123g"),
+ ("raw-unicode-escape", b"\\u123g"),
+ ("unicode-internal", b"\xff"),
+ ]
+
+ def replacing(exc):
+ if isinstance(exc, UnicodeDecodeError):
+ exc.object = 42
+ return ("\u4242", 0)
+ else:
+ raise TypeError("don't know how to handle %r" % exc)
+ codecs.register_error("test.replacing", replacing)
+ for (encoding, data) in baddata:
+ self.assertRaises(TypeError, data.decode, encoding, "test.replacing")
+
+ def mutating(exc):
+ if isinstance(exc, UnicodeDecodeError):
+ exc.object[:] = b""
+ return ("\u4242", 0)
+ else:
+ raise TypeError("don't know how to handle %r" % exc)
+ codecs.register_error("test.mutating", mutating)
+ # If the decoder doesn't pick up the modified input the following
+ # will lead to an endless loop
+ for (encoding, data) in baddata:
+ self.assertRaises(TypeError, data.decode, encoding, "test.replacing")
+
def test_main():
- test.test_support.run_unittest(CodecCallbackTest)
+ test.support.run_unittest(CodecCallbackTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_cn.py b/Lib/test/test_codecencodings_cn.py
index 215e8de3b66..dca9f10b836 100644
--- a/Lib/test/test_codecencodings_cn.py
+++ b/Lib/test/test_codecencodings_cn.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_cn.py
# Codec encoding tests for PRC encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -13,12 +13,12 @@ class Test_GB2312(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('gb2312')
codectests = (
# invalid bytes
- ("abc\x81\x81\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x81\x81\xc1\xc4", "replace", u"abc\ufffd\u804a"),
- ("abc\x81\x81\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
- ("abc\x81\x81\xc1\xc4", "ignore", u"abc\u804a"),
- ("\xc1\x64", "strict", None),
+ (b"abc\x81\x81\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x81\x81\xc1\xc4", "replace", "abc\ufffd\u804a"),
+ (b"abc\x81\x81\xc1\xc4\xc8", "replace", "abc\ufffd\u804a\ufffd"),
+ (b"abc\x81\x81\xc1\xc4", "ignore", "abc\u804a"),
+ (b"\xc1\x64", "strict", None),
)
class Test_GBK(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -26,13 +26,13 @@ class Test_GBK(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('gbk')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"),
- ("\x83\x34\x83\x31", "strict", None),
- (u"\u30fb", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u804a"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u804a\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u804a"),
+ (b"\x83\x34\x83\x31", "strict", None),
+ ("\u30fb", "strict", None),
)
class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -40,13 +40,13 @@ class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('gb18030')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u804a"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"),
- ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"),
- (u"\u30fb", "strict", "\x819\xa79"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u804a"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u804a\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u804a"),
+ (b"abc\x84\x39\x84\x39\xc1\xc4", "replace", "abc\ufffd\u804a"),
+ ("\u30fb", "strict", b"\x819\xa79"),
)
has_iso10646 = True
@@ -59,28 +59,28 @@ class Test_HZ(test_multibytecodec_support.TestBase, unittest.TestCase):
b'The next sentence is in GB.~{<:Ky2;S{#,~}~\n'
b'~{NpJ)l6HK!#~}Bye.\n',
'strict',
- u'This sentence is in ASCII.\n'
- u'The next sentence is in GB.'
- u'\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
- u'Bye.\n'),
+ 'This sentence is in ASCII.\n'
+ 'The next sentence is in GB.'
+ '\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
+ 'Bye.\n'),
# test '~\n' (4 lines)
(b'This sentence is in ASCII.\n'
b'The next sentence is in GB.~\n'
b'~{<:Ky2;S{#,NpJ)l6HK!#~}~\n'
b'Bye.\n',
'strict',
- u'This sentence is in ASCII.\n'
- u'The next sentence is in GB.'
- u'\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
- u'Bye.\n'),
+ 'This sentence is in ASCII.\n'
+ 'The next sentence is in GB.'
+ '\u5df1\u6240\u4e0d\u6b32\uff0c\u52ff\u65bd\u65bc\u4eba\u3002'
+ 'Bye.\n'),
# invalid bytes
- (b'ab~cd', 'replace', u'ab\uFFFDd'),
- (b'ab\xffcd', 'replace', u'ab\uFFFDcd'),
- (b'ab~{\x81\x81\x41\x44~}cd', 'replace', u'ab\uFFFD\uFFFD\u804Acd'),
+ (b'ab~cd', 'replace', 'ab\uFFFDd'),
+ (b'ab\xffcd', 'replace', 'ab\uFFFDcd'),
+ (b'ab~{\x81\x81\x41\x44~}cd', 'replace', 'ab\uFFFD\uFFFD\u804Acd'),
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_hk.py b/Lib/test/test_codecencodings_hk.py
index b1c260631fd..ccdc0b4c554 100644
--- a/Lib/test/test_codecencodings_hk.py
+++ b/Lib/test/test_codecencodings_hk.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_hk.py
# Codec encoding tests for HongKong encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -13,15 +13,15 @@ class Test_Big5HKSCS(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('big5hkscs')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u8b10"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u8b10\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u8b10"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u8b10"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u8b10\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u8b10"),
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_iso2022.py b/Lib/test/test_codecencodings_iso2022.py
index 9d1d2afa8c7..8c6e8a5965b 100644
--- a/Lib/test/test_codecencodings_iso2022.py
+++ b/Lib/test/test_codecencodings_iso2022.py
@@ -2,36 +2,36 @@
#
# Codec encoding tests for ISO 2022 encodings.
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
COMMON_CODEC_TESTS = (
# invalid bytes
- (b'ab\xFFcd', 'replace', u'ab\uFFFDcd'),
- (b'ab\x1Bdef', 'replace', u'ab\x1Bdef'),
- (b'ab\x1B$def', 'replace', u'ab\uFFFD'),
+ (b'ab\xFFcd', 'replace', 'ab\uFFFDcd'),
+ (b'ab\x1Bdef', 'replace', 'ab\x1Bdef'),
+ (b'ab\x1B$def', 'replace', 'ab\uFFFD'),
)
class Test_ISO2022_JP(test_multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp'
tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
- (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
+ (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
class Test_ISO2022_JP2(test_multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_jp_2'
tstring = test_multibytecodec_support.load_teststring('iso2022_jp')
codectests = COMMON_CODEC_TESTS + (
- (b'ab\x1BNdef', 'replace', u'abdef'),
+ (b'ab\x1BNdef', 'replace', 'abdef'),
)
class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'iso2022_kr'
tstring = test_multibytecodec_support.load_teststring('iso2022_kr')
codectests = COMMON_CODEC_TESTS + (
- (b'ab\x1BNdef', 'replace', u'ab\x1BNdef'),
+ (b'ab\x1BNdef', 'replace', 'ab\x1BNdef'),
)
# iso2022_kr.txt cannot be used to test "chunk coding": the escape
@@ -40,7 +40,7 @@ class Test_ISO2022_KR(test_multibytecodec_support.TestBase, unittest.TestCase):
pass
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_jp.py b/Lib/test/test_codecencodings_jp.py
index 5f81f41206e..f56a3738961 100644
--- a/Lib/test/test_codecencodings_jp.py
+++ b/Lib/test/test_codecencodings_jp.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_jp.py
# Codec encoding tests for Japanese encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -13,14 +13,14 @@ class Test_CP932(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('shift_jis')
codectests = (
# invalid bytes
- ("abc\x81\x00\x81\x00\x82\x84", "strict", None),
- ("abc\xf8", "strict", None),
- ("abc\x81\x00\x82\x84", "replace", u"abc\ufffd\uff44"),
- ("abc\x81\x00\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),
- ("abc\x81\x00\x82\x84", "ignore", u"abc\uff44"),
+ (b"abc\x81\x00\x81\x00\x82\x84", "strict", None),
+ (b"abc\xf8", "strict", None),
+ (b"abc\x81\x00\x82\x84", "replace", "abc\ufffd\uff44"),
+ (b"abc\x81\x00\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
+ (b"abc\x81\x00\x82\x84", "ignore", "abc\uff44"),
# sjis vs cp932
- ("\\\x7e", "replace", u"\\\x7e"),
- ("\x81\x5f\x81\x61\x81\x7c", "replace", u"\uff3c\u2225\uff0d"),
+ (b"\\\x7e", "replace", "\\\x7e"),
+ (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\uff3c\u2225\uff0d"),
)
class Test_EUC_JISX0213(test_multibytecodec_support.TestBase,
@@ -29,28 +29,28 @@ class Test_EUC_JISX0213(test_multibytecodec_support.TestBase,
tstring = test_multibytecodec_support.load_teststring('euc_jisx0213')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u7956"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u7956\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u7956"),
- ("abc\x8f\x83\x83", "replace", u"abc\ufffd"),
- ("\xc1\x64", "strict", None),
- ("\xa1\xc0", "strict", u"\uff3c"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u7956"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u7956\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"),
+ (b"abc\x8f\x83\x83", "replace", "abc\ufffd"),
+ (b"\xc1\x64", "strict", None),
+ (b"\xa1\xc0", "strict", "\uff3c"),
)
xmlcharnametest = (
- u"\xab\u211c\xbb = \u2329\u1234\u232a",
- "\xa9\xa8&real;\xa9\xb2 = &lang;&#4660;&rang;"
+ "\xab\u211c\xbb = \u2329\u1234\u232a",
+ b"\xa9\xa8&real;\xa9\xb2 = &lang;&#4660;&rang;"
)
eucjp_commontests = (
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u7956"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u7956\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u7956"),
- ("abc\x8f\x83\x83", "replace", u"abc\ufffd"),
- ("\xc1\x64", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u7956"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u7956\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u7956"),
+ (b"abc\x8f\x83\x83", "replace", "abc\ufffd"),
+ (b"\xc1\x64", "strict", None),
)
class Test_EUC_JP_COMPAT(test_multibytecodec_support.TestBase,
@@ -58,25 +58,25 @@ class Test_EUC_JP_COMPAT(test_multibytecodec_support.TestBase,
encoding = 'euc_jp'
tstring = test_multibytecodec_support.load_teststring('euc_jp')
codectests = eucjp_commontests + (
- ("\xa1\xc0\\", "strict", u"\uff3c\\"),
- (u"\xa5", "strict", "\x5c"),
- (u"\u203e", "strict", "\x7e"),
+ (b"\xa1\xc0\\", "strict", "\uff3c\\"),
+ ("\xa5", "strict", b"\x5c"),
+ ("\u203e", "strict", b"\x7e"),
)
shiftjis_commonenctests = (
- ("abc\x80\x80\x82\x84", "strict", None),
- ("abc\xf8", "strict", None),
- ("abc\x80\x80\x82\x84", "replace", u"abc\ufffd\uff44"),
- ("abc\x80\x80\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),
- ("abc\x80\x80\x82\x84def", "ignore", u"abc\uff44def"),
+ (b"abc\x80\x80\x82\x84", "strict", None),
+ (b"abc\xf8", "strict", None),
+ (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\uff44"),
+ (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
+ (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"),
)
class Test_SJIS_COMPAT(test_multibytecodec_support.TestBase, unittest.TestCase):
encoding = 'shift_jis'
tstring = test_multibytecodec_support.load_teststring('shift_jis')
codectests = shiftjis_commonenctests + (
- ("\\\x7e", "strict", u"\\\x7e"),
- ("\x81\x5f\x81\x61\x81\x7c", "strict", u"\uff3c\u2016\u2212"),
+ (b"\\\x7e", "strict", "\\\x7e"),
+ (b"\x81\x5f\x81\x61\x81\x7c", "strict", "\uff3c\u2016\u2212"),
)
class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -84,22 +84,22 @@ class Test_SJISX0213(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('shift_jisx0213')
codectests = (
# invalid bytes
- ("abc\x80\x80\x82\x84", "strict", None),
- ("abc\xf8", "strict", None),
- ("abc\x80\x80\x82\x84", "replace", u"abc\ufffd\uff44"),
- ("abc\x80\x80\x82\x84\x88", "replace", u"abc\ufffd\uff44\ufffd"),
- ("abc\x80\x80\x82\x84def", "ignore", u"abc\uff44def"),
+ (b"abc\x80\x80\x82\x84", "strict", None),
+ (b"abc\xf8", "strict", None),
+ (b"abc\x80\x80\x82\x84", "replace", "abc\ufffd\uff44"),
+ (b"abc\x80\x80\x82\x84\x88", "replace", "abc\ufffd\uff44\ufffd"),
+ (b"abc\x80\x80\x82\x84def", "ignore", "abc\uff44def"),
# sjis vs cp932
- ("\\\x7e", "replace", u"\xa5\u203e"),
- ("\x81\x5f\x81\x61\x81\x7c", "replace", u"\x5c\u2016\u2212"),
+ (b"\\\x7e", "replace", "\xa5\u203e"),
+ (b"\x81\x5f\x81\x61\x81\x7c", "replace", "\x5c\u2016\u2212"),
)
xmlcharnametest = (
- u"\xab\u211c\xbb = \u2329\u1234\u232a",
- "\x85G&real;\x85Q = &lang;&#4660;&rang;"
+ "\xab\u211c\xbb = \u2329\u1234\u232a",
+ b"\x85G&real;\x85Q = &lang;&#4660;&rang;"
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_kr.py b/Lib/test/test_codecencodings_kr.py
index 8c866a9caaa..de4da7f5b6d 100644
--- a/Lib/test/test_codecencodings_kr.py
+++ b/Lib/test/test_codecencodings_kr.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_kr.py
# Codec encoding tests for ROK encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -13,11 +13,11 @@ class Test_CP949(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('cp949')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\uc894"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\uc894\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
)
class Test_EUCKR(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -25,29 +25,29 @@ class Test_EUCKR(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('euc_kr')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\uc894"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\uc894\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\uc894"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\uc894"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\uc894\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\uc894"),
# composed make-up sequence errors
- ("\xa4\xd4", "strict", None),
- ("\xa4\xd4\xa4", "strict", None),
- ("\xa4\xd4\xa4\xb6", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa4", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", u"\uc4d4"),
- ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", u"\uc4d4x"),
- ("a\xa4\xd4\xa4\xb6\xa4", "replace", u"a\ufffd"),
- ("\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None),
- ("\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None),
- ("\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", u"\ufffd"),
- ("\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", u"\ufffd"),
- ("\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", u"\ufffd"),
- ("\xc1\xc4", "strict", u"\uc894"),
+ (b"\xa4\xd4", "strict", None),
+ (b"\xa4\xd4\xa4", "strict", None),
+ (b"\xa4\xd4\xa4\xb6", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa4", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4", "strict", "\uc4d4"),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xd4x", "strict", "\uc4d4x"),
+ (b"a\xa4\xd4\xa4\xb6\xa4", "replace", "a\ufffd"),
+ (b"\xa4\xd4\xa3\xb6\xa4\xd0\xa4\xd4", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa3\xd0\xa4\xd4", "strict", None),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa3\xd4", "strict", None),
+ (b"\xa4\xd4\xa4\xff\xa4\xd0\xa4\xd4", "replace", "\ufffd"),
+ (b"\xa4\xd4\xa4\xb6\xa4\xff\xa4\xd4", "replace", "\ufffd"),
+ (b"\xa4\xd4\xa4\xb6\xa4\xd0\xa4\xff", "replace", "\ufffd"),
+ (b"\xc1\xc4", "strict", "\uc894"),
)
class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase):
@@ -55,15 +55,15 @@ class Test_JOHAB(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('johab')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\ucd27"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\ucd27\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\ucd27"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\ucd27"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\ucd27\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\ucd27"),
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecencodings_tw.py b/Lib/test/test_codecencodings_tw.py
index 983d06f0034..12d3c9fa041 100644
--- a/Lib/test/test_codecencodings_tw.py
+++ b/Lib/test/test_codecencodings_tw.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecencodings_tw.py
# Codec encoding tests for ROC encodings.
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -13,15 +13,15 @@ class Test_Big5(test_multibytecodec_support.TestBase, unittest.TestCase):
tstring = test_multibytecodec_support.load_teststring('big5')
codectests = (
# invalid bytes
- ("abc\x80\x80\xc1\xc4", "strict", None),
- ("abc\xc8", "strict", None),
- ("abc\x80\x80\xc1\xc4", "replace", u"abc\ufffd\u8b10"),
- ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u8b10\ufffd"),
- ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u8b10"),
+ (b"abc\x80\x80\xc1\xc4", "strict", None),
+ (b"abc\xc8", "strict", None),
+ (b"abc\x80\x80\xc1\xc4", "replace", "abc\ufffd\u8b10"),
+ (b"abc\x80\x80\xc1\xc4\xc8", "replace", "abc\ufffd\u8b10\ufffd"),
+ (b"abc\x80\x80\xc1\xc4", "ignore", "abc\u8b10"),
)
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecmaps_cn.py b/Lib/test/test_codecmaps_cn.py
index 344fc562f71..063919d6d8c 100644
--- a/Lib/test/test_codecmaps_cn.py
+++ b/Lib/test/test_codecmaps_cn.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_cn.py
# Codec mapping tests for PRC encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -27,7 +27,7 @@ class TestGB18030Map(test_multibytecodec_support.TestBase_Mapping,
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecmaps_hk.py b/Lib/test/test_codecmaps_hk.py
index 362ab7fafcb..bbe1f2f905c 100644
--- a/Lib/test/test_codecmaps_hk.py
+++ b/Lib/test/test_codecmaps_hk.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_hk.py
# Codec mapping tests for HongKong encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -14,8 +14,8 @@ class TestBig5HKSCSMap(test_multibytecodec_support.TestBase_Mapping,
mapfileurl = 'http://people.freebsd.org/~perky/i18n/BIG5HKSCS-2004.TXT'
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
- test_support.use_resources = ['urlfetch']
+ support.use_resources = ['urlfetch']
test_main()
diff --git a/Lib/test/test_codecmaps_jp.py b/Lib/test/test_codecmaps_jp.py
index 5466a986b9d..652bd81515b 100644
--- a/Lib/test/test_codecmaps_jp.py
+++ b/Lib/test/test_codecmaps_jp.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_jp.py
# Codec mapping tests for Japanese encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -14,14 +14,14 @@ class TestCP932Map(test_multibytecodec_support.TestBase_Mapping,
mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
'WINDOWS/CP932.TXT'
supmaps = [
- ('\x80', u'\u0080'),
- ('\xa0', u'\uf8f0'),
- ('\xfd', u'\uf8f1'),
- ('\xfe', u'\uf8f2'),
- ('\xff', u'\uf8f3'),
+ (b'\x80', '\u0080'),
+ (b'\xa0', '\uf8f0'),
+ (b'\xfd', '\uf8f1'),
+ (b'\xfe', '\uf8f2'),
+ (b'\xff', '\uf8f3'),
]
for i in range(0xa1, 0xe0):
- supmaps.append((chr(i), unichr(i+0xfec0)))
+ supmaps.append((bytes([i]), chr(i+0xfec0)))
class TestEUCJPCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
@@ -38,12 +38,12 @@ class TestSJISCOMPATMap(test_multibytecodec_support.TestBase_Mapping,
mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/OBSOLETE' \
'/EASTASIA/JIS/SHIFTJIS.TXT'
pass_enctest = [
- ('\x81_', u'\\'),
+ (b'\x81_', '\\'),
]
pass_dectest = [
- ('\\', u'\xa5'),
- ('~', u'\u203e'),
- ('\x81_', u'\\'),
+ (b'\\', '\xa5'),
+ (b'~', '\u203e'),
+ (b'\x81_', '\\'),
]
class TestEUCJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
@@ -61,7 +61,7 @@ class TestSJISX0213Map(test_multibytecodec_support.TestBase_Mapping,
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecmaps_kr.py b/Lib/test/test_codecmaps_kr.py
index 39c612e8a22..d909c8bd588 100644
--- a/Lib/test/test_codecmaps_kr.py
+++ b/Lib/test/test_codecmaps_kr.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_kr.py
# Codec mapping tests for ROK encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -21,8 +21,8 @@ class TestEUCKRMap(test_multibytecodec_support.TestBase_Mapping,
mapfileurl = 'http://people.freebsd.org/~perky/i18n/EUC-KR.TXT'
# A4D4 HANGUL FILLER indicates the begin of 8-bytes make-up sequence.
- pass_enctest = [('\xa4\xd4', u'\u3164')]
- pass_dectest = [('\xa4\xd4', u'\u3164')]
+ pass_enctest = [(b'\xa4\xd4', '\u3164')]
+ pass_dectest = [(b'\xa4\xd4', '\u3164')]
class TestJOHABMap(test_multibytecodec_support.TestBase_Mapping,
@@ -34,11 +34,11 @@ class TestJOHABMap(test_multibytecodec_support.TestBase_Mapping,
# but, in early 90s that is the only era used johab widely,
# the most softwares implements it as REVERSE SOLIDUS.
# So, we ignore the standard here.
- pass_enctest = [('\\', u'\u20a9')]
- pass_dectest = [('\\', u'\u20a9')]
+ pass_enctest = [(b'\\', '\u20a9')]
+ pass_dectest = [(b'\\', '\u20a9')]
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecmaps_tw.py b/Lib/test/test_codecmaps_tw.py
index 143ae230b87..6db5091fc3a 100644
--- a/Lib/test/test_codecmaps_tw.py
+++ b/Lib/test/test_codecmaps_tw.py
@@ -1,10 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_codecmaps_tw.py
# Codec mapping tests for ROC encodings
#
-from test import test_support
+from test import support
from test import test_multibytecodec_support
import unittest
@@ -20,12 +20,12 @@ class TestCP950Map(test_multibytecodec_support.TestBase_Mapping,
mapfileurl = 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/' \
'WINDOWS/CP950.TXT'
pass_enctest = [
- ('\xa2\xcc', u'\u5341'),
- ('\xa2\xce', u'\u5345'),
+ (b'\xa2\xcc', '\u5341'),
+ (b'\xa2\xce', '\u5345'),
]
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index f620b4cde37..0f7c23efccb 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1,15 +1,15 @@
-from test import test_support
+from test import support
import unittest
import codecs
import locale
-import sys, StringIO, _testcapi
+import sys, _testcapi, io
class Queue(object):
"""
queue: write bytes at one end, read bytes from the other end
"""
- def __init__(self):
- self._buffer = ""
+ def __init__(self, buffer):
+ self._buffer = buffer
def write(self, chars):
self._buffer += chars
@@ -17,61 +17,93 @@ class Queue(object):
def read(self, size=-1):
if size<0:
s = self._buffer
- self._buffer = ""
+ self._buffer = self._buffer[:0] # make empty
return s
else:
s = self._buffer[:size]
self._buffer = self._buffer[size:]
return s
-class ReadTest(unittest.TestCase):
+class MixInCheckStateHandling:
+ def check_state_handling_decode(self, encoding, u, s):
+ for i in range(len(s)+1):
+ d = codecs.getincrementaldecoder(encoding)()
+ part1 = d.decode(s[:i])
+ state = d.getstate()
+ self.assertIsInstance(state[1], int)
+ # Check that the condition stated in the documentation for
+ # IncrementalDecoder.getstate() holds
+ if not state[1]:
+ # reset decoder to the default state without anything buffered
+ d.setstate((state[0][:0], 0))
+ # Feeding the previous input may not produce any output
+ self.assertTrue(not d.decode(state[0]))
+ # The decoder must return to the same state
+ self.assertEqual(state, d.getstate())
+ # Create a new decoder and set it to the state
+ # we extracted from the old one
+ d = codecs.getincrementaldecoder(encoding)()
+ d.setstate(state)
+ part2 = d.decode(s[i:], True)
+ self.assertEqual(u, part1+part2)
+
+ def check_state_handling_encode(self, encoding, u, s):
+ for i in range(len(u)+1):
+ d = codecs.getincrementalencoder(encoding)()
+ part1 = d.encode(u[:i])
+ state = d.getstate()
+ d = codecs.getincrementalencoder(encoding)()
+ d.setstate(state)
+ part2 = d.encode(u[i:], True)
+ self.assertEqual(s, part1+part2)
+
+class ReadTest(unittest.TestCase, MixInCheckStateHandling):
def check_partial(self, input, partialresults):
# get a StreamReader for the encoding and feed the bytestring version
# of input to the reader byte by byte. Read everything available from
# the StreamReader and check that the results equal the appropriate
# entries from partialresults.
- q = Queue()
+ q = Queue(b"")
r = codecs.getreader(self.encoding)(q)
- result = u""
+ result = ""
for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
- q.write(c)
+ q.write(bytes([c]))
result += r.read()
self.assertEqual(result, partialresult)
# check that there's nothing left in the buffers
- self.assertEqual(r.read(), u"")
- self.assertEqual(r.bytebuffer, "")
- self.assertEqual(r.charbuffer, u"")
+ self.assertEqual(r.read(), "")
+ self.assertEqual(r.bytebuffer, b"")
# do the check again, this time using a incremental decoder
d = codecs.getincrementaldecoder(self.encoding)()
- result = u""
+ result = ""
for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
- result += d.decode(c)
+ result += d.decode(bytes([c]))
self.assertEqual(result, partialresult)
# check that there's nothing left in the buffers
- self.assertEqual(d.decode("", True), u"")
- self.assertEqual(d.buffer, "")
+ self.assertEqual(d.decode(b"", True), "")
+ self.assertEqual(d.buffer, b"")
# Check whether the reset method works properly
d.reset()
- result = u""
+ result = ""
for (c, partialresult) in zip(input.encode(self.encoding), partialresults):
- result += d.decode(c)
+ result += d.decode(bytes([c]))
self.assertEqual(result, partialresult)
# check that there's nothing left in the buffers
- self.assertEqual(d.decode("", True), u"")
- self.assertEqual(d.buffer, "")
+ self.assertEqual(d.decode(b"", True), "")
+ self.assertEqual(d.buffer, b"")
# check iterdecode()
encoded = input.encode(self.encoding)
self.assertEqual(
input,
- u"".join(codecs.iterdecode(encoded, self.encoding))
+ "".join(codecs.iterdecode([bytes([c]) for c in encoded], self.encoding))
)
def test_readline(self):
def getreader(input):
- stream = StringIO.StringIO(input.encode(self.encoding))
+ stream = io.BytesIO(input.encode(self.encoding))
return codecs.getreader(self.encoding)(stream)
def readalllines(input, keepends=True, size=None):
@@ -84,9 +116,9 @@ class ReadTest(unittest.TestCase):
lines.append(line)
return "|".join(lines)
- s = u"foo\nbar\r\nbaz\rspam\u2028eggs"
- sexpected = u"foo\n|bar\r\n|baz\r|spam\u2028|eggs"
- sexpectednoends = u"foo|bar|baz|spam|eggs"
+ s = "foo\nbar\r\nbaz\rspam\u2028eggs"
+ sexpected = "foo\n|bar\r\n|baz\r|spam\u2028|eggs"
+ sexpectednoends = "foo|bar|baz|spam|eggs"
self.assertEqual(readalllines(s, True), sexpected)
self.assertEqual(readalllines(s, False), sexpectednoends)
self.assertEqual(readalllines(s, True, 10), sexpected)
@@ -95,28 +127,28 @@ class ReadTest(unittest.TestCase):
# Test long lines (multiple calls to read() in readline())
vw = []
vwo = []
- for (i, lineend) in enumerate(u"\n \r\n \r \u2028".split()):
- vw.append((i*200)*u"\3042" + lineend)
- vwo.append((i*200)*u"\3042")
+ for (i, lineend) in enumerate("\n \r\n \r \u2028".split()):
+ vw.append((i*200)*"\3042" + lineend)
+ vwo.append((i*200)*"\3042")
self.assertEqual(readalllines("".join(vw), True), "".join(vw))
self.assertEqual(readalllines("".join(vw), False),"".join(vwo))
# Test lines where the first read might end with \r, so the
# reader has to look ahead whether this is a lone \r or a \r\n
- for size in xrange(80):
- for lineend in u"\n \r\n \r \u2028".split():
- s = 10*(size*u"a" + lineend + u"xxx\n")
+ for size in range(80):
+ for lineend in "\n \r\n \r \u2028".split():
+ s = 10*(size*"a" + lineend + "xxx\n")
reader = getreader(s)
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(
reader.readline(keepends=True),
- size*u"a" + lineend,
+ size*"a" + lineend,
)
reader = getreader(s)
- for i in xrange(10):
+ for i in range(10):
self.assertEqual(
reader.readline(keepends=False),
- size*u"a",
+ size*"a",
)
def test_bug1175396(self):
@@ -183,147 +215,153 @@ class ReadTest(unittest.TestCase):
' break\r\n',
' \r\n',
]
- stream = StringIO.StringIO("".join(s).encode(self.encoding))
+ stream = io.BytesIO("".join(s).encode(self.encoding))
reader = codecs.getreader(self.encoding)(stream)
for (i, line) in enumerate(reader):
self.assertEqual(line, s[i])
def test_readlinequeue(self):
- q = Queue()
+ q = Queue(b"")
writer = codecs.getwriter(self.encoding)(q)
reader = codecs.getreader(self.encoding)(q)
# No lineends
- writer.write(u"foo\r")
- self.assertEqual(reader.readline(keepends=False), u"foo")
- writer.write(u"\nbar\r")
- self.assertEqual(reader.readline(keepends=False), u"")
- self.assertEqual(reader.readline(keepends=False), u"bar")
- writer.write(u"baz")
- self.assertEqual(reader.readline(keepends=False), u"baz")
- self.assertEqual(reader.readline(keepends=False), u"")
+ writer.write("foo\r")
+ self.assertEqual(reader.readline(keepends=False), "foo")
+ writer.write("\nbar\r")
+ self.assertEqual(reader.readline(keepends=False), "")
+ self.assertEqual(reader.readline(keepends=False), "bar")
+ writer.write("baz")
+ self.assertEqual(reader.readline(keepends=False), "baz")
+ self.assertEqual(reader.readline(keepends=False), "")
# Lineends
- writer.write(u"foo\r")
- self.assertEqual(reader.readline(keepends=True), u"foo\r")
- writer.write(u"\nbar\r")
- self.assertEqual(reader.readline(keepends=True), u"\n")
- self.assertEqual(reader.readline(keepends=True), u"bar\r")
- writer.write(u"baz")
- self.assertEqual(reader.readline(keepends=True), u"baz")
- self.assertEqual(reader.readline(keepends=True), u"")
- writer.write(u"foo\r\n")
- self.assertEqual(reader.readline(keepends=True), u"foo\r\n")
+ writer.write("foo\r")
+ self.assertEqual(reader.readline(keepends=True), "foo\r")
+ writer.write("\nbar\r")
+ self.assertEqual(reader.readline(keepends=True), "\n")
+ self.assertEqual(reader.readline(keepends=True), "bar\r")
+ writer.write("baz")
+ self.assertEqual(reader.readline(keepends=True), "baz")
+ self.assertEqual(reader.readline(keepends=True), "")
+ writer.write("foo\r\n")
+ self.assertEqual(reader.readline(keepends=True), "foo\r\n")
def test_bug1098990_a(self):
- s1 = u"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n"
- s2 = u"offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n"
- s3 = u"next line.\r\n"
+ s1 = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy\r\n"
+ s2 = "offending line: ladfj askldfj klasdj fskla dfzaskdj fasklfj laskd fjasklfzzzzaa%whereisthis!!!\r\n"
+ s3 = "next line.\r\n"
s = (s1+s2+s3).encode(self.encoding)
- stream = StringIO.StringIO(s)
+ stream = io.BytesIO(s)
reader = codecs.getreader(self.encoding)(stream)
self.assertEqual(reader.readline(), s1)
self.assertEqual(reader.readline(), s2)
self.assertEqual(reader.readline(), s3)
- self.assertEqual(reader.readline(), u"")
+ self.assertEqual(reader.readline(), "")
def test_bug1098990_b(self):
- s1 = u"aaaaaaaaaaaaaaaaaaaaaaaa\r\n"
- s2 = u"bbbbbbbbbbbbbbbbbbbbbbbb\r\n"
- s3 = u"stillokay:bbbbxx\r\n"
- s4 = u"broken!!!!badbad\r\n"
- s5 = u"againokay.\r\n"
+ s1 = "aaaaaaaaaaaaaaaaaaaaaaaa\r\n"
+ s2 = "bbbbbbbbbbbbbbbbbbbbbbbb\r\n"
+ s3 = "stillokay:bbbbxx\r\n"
+ s4 = "broken!!!!badbad\r\n"
+ s5 = "againokay.\r\n"
s = (s1+s2+s3+s4+s5).encode(self.encoding)
- stream = StringIO.StringIO(s)
+ stream = io.BytesIO(s)
reader = codecs.getreader(self.encoding)(stream)
self.assertEqual(reader.readline(), s1)
self.assertEqual(reader.readline(), s2)
self.assertEqual(reader.readline(), s3)
self.assertEqual(reader.readline(), s4)
self.assertEqual(reader.readline(), s5)
- self.assertEqual(reader.readline(), u"")
+ self.assertEqual(reader.readline(), "")
class UTF32Test(ReadTest):
encoding = "utf-32"
- spamle = ('\xff\xfe\x00\x00'
- 's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00'
- 's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00')
- spambe = ('\x00\x00\xfe\xff'
- '\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m'
- '\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m')
+ spamle = (b'\xff\xfe\x00\x00'
+ b's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00'
+ b's\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m\x00\x00\x00')
+ spambe = (b'\x00\x00\xfe\xff'
+ b'\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m'
+ b'\x00\x00\x00s\x00\x00\x00p\x00\x00\x00a\x00\x00\x00m')
def test_only_one_bom(self):
_,_,reader,writer = codecs.lookup(self.encoding)
# encode some stream
- s = StringIO.StringIO()
+ s = io.BytesIO()
f = writer(s)
- f.write(u"spam")
- f.write(u"spam")
+ f.write("spam")
+ f.write("spam")
d = s.getvalue()
# check whether there is exactly one BOM in it
self.assertTrue(d == self.spamle or d == self.spambe)
# try to read it back
- s = StringIO.StringIO(d)
+ s = io.BytesIO(d)
f = reader(s)
- self.assertEqual(f.read(), u"spamspam")
+ self.assertEqual(f.read(), "spamspam")
def test_badbom(self):
- s = StringIO.StringIO(4*"\xff")
+ s = io.BytesIO(4*b"\xff")
f = codecs.getreader(self.encoding)(s)
self.assertRaises(UnicodeError, f.read)
- s = StringIO.StringIO(8*"\xff")
+ s = io.BytesIO(8*b"\xff")
f = codecs.getreader(self.encoding)(s)
self.assertRaises(UnicodeError, f.read)
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"", # first byte of BOM read
- u"", # second byte of BOM read
- u"", # third byte of BOM read
- u"", # fourth byte of BOM read => byteorder known
- u"",
- u"",
- u"",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "", # first byte of BOM read
+ "", # second byte of BOM read
+ "", # third byte of BOM read
+ "", # fourth byte of BOM read => byteorder known
+ "",
+ "",
+ "",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_handlers(self):
- self.assertEqual((u'\ufffd', 1),
- codecs.utf_32_decode('\x01', 'replace', True))
- self.assertEqual((u'', 1),
- codecs.utf_32_decode('\x01', 'ignore', True))
+ self.assertEqual(('\ufffd', 1),
+ codecs.utf_32_decode(b'\x01', 'replace', True))
+ self.assertEqual(('', 1),
+ codecs.utf_32_decode(b'\x01', 'ignore', True))
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_decode,
- "\xff", "strict", True)
+ b"\xff", "strict", True)
+
+ def test_decoder_state(self):
+ self.check_state_handling_decode(self.encoding,
+ "spamspam", self.spamle)
+ self.check_state_handling_decode(self.encoding,
+ "spamspam", self.spambe)
def test_issue8941(self):
# Issue #8941: insufficient result allocation when decoding into
# surrogate pairs on UCS-2 builds.
- encoded_le = '\xff\xfe\x00\x00' + '\x00\x00\x01\x00' * 1024
- self.assertEqual(u'\U00010000' * 1024,
+ encoded_le = b'\xff\xfe\x00\x00' + b'\x00\x00\x01\x00' * 1024
+ self.assertEqual('\U00010000' * 1024,
codecs.utf_32_decode(encoded_le)[0])
- encoded_be = '\x00\x00\xfe\xff' + '\x00\x01\x00\x00' * 1024
- self.assertEqual(u'\U00010000' * 1024,
+ encoded_be = b'\x00\x00\xfe\xff' + b'\x00\x01\x00\x00' * 1024
+ self.assertEqual('\U00010000' * 1024,
codecs.utf_32_decode(encoded_be)[0])
class UTF32LETest(ReadTest):
@@ -331,39 +369,39 @@ class UTF32LETest(ReadTest):
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"",
- u"",
- u"",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "",
+ "",
+ "",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_simple(self):
- self.assertEqual(u"\U00010203".encode(self.encoding), "\x03\x02\x01\x00")
+ self.assertEqual("\U00010203".encode(self.encoding), b"\x03\x02\x01\x00")
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_le_decode,
- "\xff", "strict", True)
+ b"\xff", "strict", True)
def test_issue8941(self):
# Issue #8941: insufficient result allocation when decoding into
# surrogate pairs on UCS-2 builds.
- encoded = '\x00\x00\x01\x00' * 1024
- self.assertEqual(u'\U00010000' * 1024,
+ encoded = b'\x00\x00\x01\x00' * 1024
+ self.assertEqual('\U00010000' * 1024,
codecs.utf_32_le_decode(encoded)[0])
class UTF32BETest(ReadTest):
@@ -371,109 +409,116 @@ class UTF32BETest(ReadTest):
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"",
- u"",
- u"",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "",
+ "",
+ "",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_simple(self):
- self.assertEqual(u"\U00010203".encode(self.encoding), "\x00\x01\x02\x03")
+ self.assertEqual("\U00010203".encode(self.encoding), b"\x00\x01\x02\x03")
def test_errors(self):
self.assertRaises(UnicodeDecodeError, codecs.utf_32_be_decode,
- "\xff", "strict", True)
+ b"\xff", "strict", True)
def test_issue8941(self):
# Issue #8941: insufficient result allocation when decoding into
# surrogate pairs on UCS-2 builds.
- encoded = '\x00\x01\x00\x00' * 1024
- self.assertEqual(u'\U00010000' * 1024,
+ encoded = b'\x00\x01\x00\x00' * 1024
+ self.assertEqual('\U00010000' * 1024,
codecs.utf_32_be_decode(encoded)[0])
class UTF16Test(ReadTest):
encoding = "utf-16"
- spamle = '\xff\xfes\x00p\x00a\x00m\x00s\x00p\x00a\x00m\x00'
- spambe = '\xfe\xff\x00s\x00p\x00a\x00m\x00s\x00p\x00a\x00m'
+ spamle = b'\xff\xfes\x00p\x00a\x00m\x00s\x00p\x00a\x00m\x00'
+ spambe = b'\xfe\xff\x00s\x00p\x00a\x00m\x00s\x00p\x00a\x00m'
def test_only_one_bom(self):
_,_,reader,writer = codecs.lookup(self.encoding)
# encode some stream
- s = StringIO.StringIO()
+ s = io.BytesIO()
f = writer(s)
- f.write(u"spam")
- f.write(u"spam")
+ f.write("spam")
+ f.write("spam")
d = s.getvalue()
# check whether there is exactly one BOM in it
self.assertTrue(d == self.spamle or d == self.spambe)
# try to read it back
- s = StringIO.StringIO(d)
+ s = io.BytesIO(d)
f = reader(s)
- self.assertEqual(f.read(), u"spamspam")
+ self.assertEqual(f.read(), "spamspam")
def test_badbom(self):
- s = StringIO.StringIO("\xff\xff")
+ s = io.BytesIO(b"\xff\xff")
f = codecs.getreader(self.encoding)(s)
self.assertRaises(UnicodeError, f.read)
- s = StringIO.StringIO("\xff\xff\xff\xff")
+ s = io.BytesIO(b"\xff\xff\xff\xff")
f = codecs.getreader(self.encoding)(s)
self.assertRaises(UnicodeError, f.read)
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"", # first byte of BOM read
- u"", # second byte of BOM read => byteorder known
- u"",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "", # first byte of BOM read
+ "", # second byte of BOM read => byteorder known
+ "",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_handlers(self):
- self.assertEqual((u'\ufffd', 1),
- codecs.utf_16_decode('\x01', 'replace', True))
- self.assertEqual((u'', 1),
- codecs.utf_16_decode('\x01', 'ignore', True))
+ self.assertEqual(('\ufffd', 1),
+ codecs.utf_16_decode(b'\x01', 'replace', True))
+ self.assertEqual(('', 1),
+ codecs.utf_16_decode(b'\x01', 'ignore', True))
def test_errors(self):
- self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode, "\xff", "strict", True)
+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_decode,
+ b"\xff", "strict", True)
+
+ def test_decoder_state(self):
+ self.check_state_handling_decode(self.encoding,
+ "spamspam", self.spamle)
+ self.check_state_handling_decode(self.encoding,
+ "spamspam", self.spambe)
def test_bug691291(self):
# Files are always opened in binary mode, even if no binary mode was
# specified. This means that no automatic conversion of '\n' is done
# on reading and writing.
- s1 = u'Hello\r\nworld\r\n'
+ s1 = 'Hello\r\nworld\r\n'
s = s1.encode(self.encoding)
- self.addCleanup(test_support.unlink, test_support.TESTFN)
- with open(test_support.TESTFN, 'wb') as fp:
+ self.addCleanup(support.unlink, support.TESTFN)
+ with open(support.TESTFN, 'wb') as fp:
fp.write(s)
- with codecs.open(test_support.TESTFN, 'U', encoding=self.encoding) as reader:
+ with codecs.open(support.TESTFN, 'U', encoding=self.encoding) as reader:
self.assertEqual(reader.read(), s1)
class UTF16LETest(ReadTest):
@@ -481,107 +526,149 @@ class UTF16LETest(ReadTest):
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_errors(self):
tests = [
- (b'\xff', u'\ufffd'),
- (b'A\x00Z', u'A\ufffd'),
- (b'A\x00B\x00C\x00D\x00Z', u'ABCD\ufffd'),
- (b'\x00\xd8', u'\ufffd'),
- (b'\x00\xd8A', u'\ufffd'),
- (b'\x00\xd8A\x00', u'\ufffdA'),
- (b'\x00\xdcA\x00', u'\ufffdA'),
+ (b'\xff', '\ufffd'),
+ (b'A\x00Z', 'A\ufffd'),
+ (b'A\x00B\x00C\x00D\x00Z', 'ABCD\ufffd'),
+ (b'\x00\xd8', '\ufffd'),
+ (b'\x00\xd8A', '\ufffd'),
+ (b'\x00\xd8A\x00', '\ufffdA'),
+ (b'\x00\xdcA\x00', '\ufffdA'),
]
for raw, expected in tests:
self.assertRaises(UnicodeDecodeError, codecs.utf_16_le_decode,
raw, 'strict', True)
self.assertEqual(raw.decode('utf-16le', 'replace'), expected)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\x00\xd8\x03\xde')
+ self.assertEqual(b'\x00\xd8\x03\xde'.decode(self.encoding),
+ "\U00010203")
+
class UTF16BETest(ReadTest):
encoding = "utf-16-be"
def test_partial(self):
self.check_partial(
- u"\x00\xff\u0100\uffff",
+ "\x00\xff\u0100\uffff",
[
- u"",
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100",
- u"\x00\xff\u0100\uffff",
+ "",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100",
+ "\x00\xff\u0100\uffff",
]
)
def test_errors(self):
tests = [
- (b'\xff', u'\ufffd'),
- (b'\x00A\xff', u'A\ufffd'),
- (b'\x00A\x00B\x00C\x00DZ', u'ABCD\ufffd'),
- (b'\xd8\x00', u'\ufffd'),
- (b'\xd8\x00\xdc', u'\ufffd'),
- (b'\xd8\x00\x00A', u'\ufffdA'),
- (b'\xdc\x00\x00A', u'\ufffdA'),
+ (b'\xff', '\ufffd'),
+ (b'\x00A\xff', 'A\ufffd'),
+ (b'\x00A\x00B\x00C\x00DZ', 'ABCD\ufffd'),
+ (b'\xd8\x00', '\ufffd'),
+ (b'\xd8\x00\xdc', '\ufffd'),
+ (b'\xd8\x00\x00A', '\ufffdA'),
+ (b'\xdc\x00\x00A', '\ufffdA'),
]
for raw, expected in tests:
self.assertRaises(UnicodeDecodeError, codecs.utf_16_be_decode,
raw, 'strict', True)
self.assertEqual(raw.decode('utf-16be', 'replace'), expected)
+ def test_nonbmp(self):
+ self.assertEqual("\U00010203".encode(self.encoding),
+ b'\xd8\x00\xde\x03')
+ self.assertEqual(b'\xd8\x00\xde\x03'.decode(self.encoding),
+ "\U00010203")
+
class UTF8Test(ReadTest):
encoding = "utf-8"
def test_partial(self):
self.check_partial(
- u"\x00\xff\u07ff\u0800\uffff",
+ "\x00\xff\u07ff\u0800\uffff",
[
- u"\x00",
- u"\x00",
- u"\x00\xff",
- u"\x00\xff",
- u"\x00\xff\u07ff",
- u"\x00\xff\u07ff",
- u"\x00\xff\u07ff",
- u"\x00\xff\u07ff\u0800",
- u"\x00\xff\u07ff\u0800",
- u"\x00\xff\u07ff\u0800",
- u"\x00\xff\u07ff\u0800\uffff",
+ "\x00",
+ "\x00",
+ "\x00\xff",
+ "\x00\xff",
+ "\x00\xff\u07ff",
+ "\x00\xff\u07ff",
+ "\x00\xff\u07ff",
+ "\x00\xff\u07ff\u0800",
+ "\x00\xff\u07ff\u0800",
+ "\x00\xff\u07ff\u0800",
+ "\x00\xff\u07ff\u0800\uffff",
]
)
+ def test_decoder_state(self):
+ u = "\x00\x7f\x80\xff\u0100\u07ff\u0800\uffff\U0010ffff"
+ self.check_state_handling_decode(self.encoding,
+ u, u.encode(self.encoding))
+
+ def test_lone_surrogates(self):
+ self.assertRaises(UnicodeEncodeError, "\ud800".encode, "utf-8")
+ self.assertRaises(UnicodeDecodeError, b"\xed\xa0\x80".decode, "utf-8")
+ self.assertEqual("[\uDC80]".encode("utf-8", "backslashreplace"),
+ b'[\\udc80]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "xmlcharrefreplace"),
+ b'[&#56448;]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "surrogateescape"),
+ b'[\x80]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "ignore"),
+ b'[]')
+ self.assertEqual("[\uDC80]".encode("utf-8", "replace"),
+ b'[?]')
+
+ def test_surrogatepass_handler(self):
+ self.assertEqual("abc\ud800def".encode("utf-8", "surrogatepass"),
+ b"abc\xed\xa0\x80def")
+ self.assertEqual(b"abc\xed\xa0\x80def".decode("utf-8", "surrogatepass"),
+ "abc\ud800def")
+ self.assertTrue(codecs.lookup_error("surrogatepass"))
+ with self.assertRaises(UnicodeDecodeError):
+ b"abc\xed\xa0".decode("utf-8", "surrogatepass")
+ with self.assertRaises(UnicodeDecodeError):
+ b"abc\xed\xa0z".decode("utf-8", "surrogatepass")
+
class UTF7Test(ReadTest):
encoding = "utf-7"
def test_partial(self):
self.check_partial(
- u"a+-b",
+ "a+-b",
[
- u"a",
- u"a",
- u"a+",
- u"a+-",
- u"a+-b",
+ "a",
+ "a",
+ "a+",
+ "a+-",
+ "a+-b",
]
)
class UTF16ExTest(unittest.TestCase):
def test_errors(self):
- self.assertRaises(UnicodeDecodeError, codecs.utf_16_ex_decode, "\xff", "strict", 0, True)
+ self.assertRaises(UnicodeDecodeError, codecs.utf_16_ex_decode, b"\xff", "strict", 0, True)
def test_bad_args(self):
self.assertRaises(TypeError, codecs.utf_16_ex_decode)
@@ -591,74 +678,62 @@ class ReadBufferTest(unittest.TestCase):
def test_array(self):
import array
self.assertEqual(
- codecs.readbuffer_encode(array.array("c", "spam")),
- ("spam", 4)
+ codecs.readbuffer_encode(array.array("b", b"spam")),
+ (b"spam", 4)
)
def test_empty(self):
- self.assertEqual(codecs.readbuffer_encode(""), ("", 0))
+ self.assertEqual(codecs.readbuffer_encode(""), (b"", 0))
def test_bad_args(self):
self.assertRaises(TypeError, codecs.readbuffer_encode)
self.assertRaises(TypeError, codecs.readbuffer_encode, 42)
-class CharBufferTest(unittest.TestCase):
-
- def test_string(self):
- self.assertEqual(codecs.charbuffer_encode("spam"), ("spam", 4))
-
- def test_empty(self):
- self.assertEqual(codecs.charbuffer_encode(""), ("", 0))
-
- def test_bad_args(self):
- self.assertRaises(TypeError, codecs.charbuffer_encode)
- self.assertRaises(TypeError, codecs.charbuffer_encode, 42)
-
class UTF8SigTest(ReadTest):
encoding = "utf-8-sig"
def test_partial(self):
self.check_partial(
- u"\ufeff\x00\xff\u07ff\u0800\uffff",
+ "\ufeff\x00\xff\u07ff\u0800\uffff",
[
- u"",
- u"",
- u"", # First BOM has been read and skipped
- u"",
- u"",
- u"\ufeff", # Second BOM has been read and emitted
- u"\ufeff\x00", # "\x00" read and emitted
- u"\ufeff\x00", # First byte of encoded u"\xff" read
- u"\ufeff\x00\xff", # Second byte of encoded u"\xff" read
- u"\ufeff\x00\xff", # First byte of encoded u"\u07ff" read
- u"\ufeff\x00\xff\u07ff", # Second byte of encoded u"\u07ff" read
- u"\ufeff\x00\xff\u07ff",
- u"\ufeff\x00\xff\u07ff",
- u"\ufeff\x00\xff\u07ff\u0800",
- u"\ufeff\x00\xff\u07ff\u0800",
- u"\ufeff\x00\xff\u07ff\u0800",
- u"\ufeff\x00\xff\u07ff\u0800\uffff",
+ "",
+ "",
+ "", # First BOM has been read and skipped
+ "",
+ "",
+ "\ufeff", # Second BOM has been read and emitted
+ "\ufeff\x00", # "\x00" read and emitted
+ "\ufeff\x00", # First byte of encoded "\xff" read
+ "\ufeff\x00\xff", # Second byte of encoded "\xff" read
+ "\ufeff\x00\xff", # First byte of encoded "\u07ff" read
+ "\ufeff\x00\xff\u07ff", # Second byte of encoded "\u07ff" read
+ "\ufeff\x00\xff\u07ff",
+ "\ufeff\x00\xff\u07ff",
+ "\ufeff\x00\xff\u07ff\u0800",
+ "\ufeff\x00\xff\u07ff\u0800",
+ "\ufeff\x00\xff\u07ff\u0800",
+ "\ufeff\x00\xff\u07ff\u0800\uffff",
]
)
def test_bug1601501(self):
# SF bug #1601501: check that the codec works with a buffer
- unicode("\xef\xbb\xbf", "utf-8-sig")
+ self.assertEqual(str(b"\xef\xbb\xbf", "utf-8-sig"), "")
def test_bom(self):
d = codecs.getincrementaldecoder("utf-8-sig")()
- s = u"spam"
+ s = "spam"
self.assertEqual(d.decode(s.encode("utf-8-sig")), s)
def test_stream_bom(self):
- unistring = u"ABC\u00A1\u2200XYZ"
- bytestring = codecs.BOM_UTF8 + "ABC\xC2\xA1\xE2\x88\x80XYZ"
+ unistring = "ABC\u00A1\u2200XYZ"
+ bytestring = codecs.BOM_UTF8 + b"ABC\xC2\xA1\xE2\x88\x80XYZ"
reader = codecs.getreader("utf-8-sig")
- for sizehint in [None] + range(1, 11) + \
+ for sizehint in [None] + list(range(1, 11)) + \
[64, 128, 256, 512, 1024]:
- istream = reader(StringIO.StringIO(bytestring))
- ostream = StringIO.StringIO()
+ istream = reader(io.BytesIO(bytestring))
+ ostream = io.StringIO()
while 1:
if sizehint is not None:
data = istream.read(sizehint)
@@ -673,14 +748,14 @@ class UTF8SigTest(ReadTest):
self.assertEqual(got, unistring)
def test_stream_bare(self):
- unistring = u"ABC\u00A1\u2200XYZ"
- bytestring = "ABC\xC2\xA1\xE2\x88\x80XYZ"
+ unistring = "ABC\u00A1\u2200XYZ"
+ bytestring = b"ABC\xC2\xA1\xE2\x88\x80XYZ"
reader = codecs.getreader("utf-8-sig")
- for sizehint in [None] + range(1, 11) + \
+ for sizehint in [None] + list(range(1, 11)) + \
[64, 128, 256, 512, 1024]:
- istream = reader(StringIO.StringIO(bytestring))
- ostream = StringIO.StringIO()
+ istream = reader(io.BytesIO(bytestring))
+ ostream = io.StringIO()
while 1:
if sizehint is not None:
data = istream.read(sizehint)
@@ -700,9 +775,9 @@ class EscapeDecodeTest(unittest.TestCase):
class RecodingTest(unittest.TestCase):
def test_recoding(self):
- f = StringIO.StringIO()
+ f = io.BytesIO()
f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8")
- f2.write(u"a")
+ f2.write("a")
f2.close()
# Python used to crash on this at exit because of a refcount
# bug in _codecsmodule.c
@@ -710,110 +785,110 @@ class RecodingTest(unittest.TestCase):
# From RFC 3492
punycode_testcases = [
# A Arabic (Egyptian):
- (u"\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644"
- u"\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
- "egbpdaj6bu4bxfgehfvwxn"),
+ ("\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644"
+ "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F",
+ b"egbpdaj6bu4bxfgehfvwxn"),
# B Chinese (simplified):
- (u"\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
- "ihqwcrb4cv8a8dqg056pqjye"),
+ ("\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587",
+ b"ihqwcrb4cv8a8dqg056pqjye"),
# C Chinese (traditional):
- (u"\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587",
- "ihqwctvzc91f659drss3x8bo0yb"),
+ ("\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587",
+ b"ihqwctvzc91f659drss3x8bo0yb"),
# D Czech: Pro<ccaron>prost<ecaron>nemluv<iacute><ccaron>esky
- (u"\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074"
- u"\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D"
- u"\u0065\u0073\u006B\u0079",
- "Proprostnemluvesky-uyb24dma41a"),
+ ("\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074"
+ "\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D"
+ "\u0065\u0073\u006B\u0079",
+ b"Proprostnemluvesky-uyb24dma41a"),
# E Hebrew:
- (u"\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8"
- u"\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2"
- u"\u05D1\u05E8\u05D9\u05EA",
- "4dbcagdahymbxekheh6e0a7fei0b"),
+ ("\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8"
+ "\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2"
+ "\u05D1\u05E8\u05D9\u05EA",
+ b"4dbcagdahymbxekheh6e0a7fei0b"),
# F Hindi (Devanagari):
- (u"\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D"
- u"\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939"
- u"\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947"
- u"\u0939\u0948\u0902",
- "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd"),
+ ("\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D"
+ "\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939"
+ "\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947"
+ "\u0939\u0948\u0902",
+ b"i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd"),
#(G) Japanese (kanji and hiragana):
- (u"\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092"
- u"\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B",
- "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa"),
+ ("\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092"
+ "\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B",
+ b"n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa"),
# (H) Korean (Hangul syllables):
- (u"\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774"
- u"\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74"
- u"\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C",
- "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j"
- "psd879ccm6fea98c"),
+ ("\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774"
+ "\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74"
+ "\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C",
+ b"989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j"
+ b"psd879ccm6fea98c"),
# (I) Russian (Cyrillic):
- (u"\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E"
- u"\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440"
- u"\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A"
- u"\u0438",
- "b1abfaaepdrnnbgefbaDotcwatmq2g4l"),
+ ("\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E"
+ "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440"
+ "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A"
+ "\u0438",
+ b"b1abfaaepdrnnbgefbaDotcwatmq2g4l"),
# (J) Spanish: Porqu<eacute>nopuedensimplementehablarenEspa<ntilde>ol
- (u"\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070"
- u"\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070"
- u"\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061"
- u"\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070"
- u"\u0061\u00F1\u006F\u006C",
- "PorqunopuedensimplementehablarenEspaol-fmd56a"),
+ ("\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070"
+ "\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070"
+ "\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061"
+ "\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070"
+ "\u0061\u00F1\u006F\u006C",
+ b"PorqunopuedensimplementehablarenEspaol-fmd56a"),
# (K) Vietnamese:
# T<adotbelow>isaoh<odotbelow>kh<ocirc>ngth<ecirchookabove>ch\
# <ihookabove>n<oacute>iti<ecircacute>ngVi<ecircdotbelow>t
- (u"\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B"
- u"\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068"
- u"\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067"
- u"\u0056\u0069\u1EC7\u0074",
- "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g"),
+ ("\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B"
+ "\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068"
+ "\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067"
+ "\u0056\u0069\u1EC7\u0074",
+ b"TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g"),
#(L) 3<nen>B<gumi><kinpachi><sensei>
- (u"\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F",
- "3B-ww4c5e180e575a65lsy2b"),
+ ("\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F",
+ b"3B-ww4c5e180e575a65lsy2b"),
# (M) <amuro><namie>-with-SUPER-MONKEYS
- (u"\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074"
- u"\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D"
- u"\u004F\u004E\u004B\u0045\u0059\u0053",
- "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n"),
+ ("\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074"
+ "\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D"
+ "\u004F\u004E\u004B\u0045\u0059\u0053",
+ b"-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n"),
# (N) Hello-Another-Way-<sorezore><no><basho>
- (u"\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F"
- u"\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D"
- u"\u305D\u308C\u305E\u308C\u306E\u5834\u6240",
- "Hello-Another-Way--fc4qua05auwb3674vfr0b"),
+ ("\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F"
+ "\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D"
+ "\u305D\u308C\u305E\u308C\u306E\u5834\u6240",
+ b"Hello-Another-Way--fc4qua05auwb3674vfr0b"),
# (O) <hitotsu><yane><no><shita>2
- (u"\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032",
- "2-u9tlzr9756bt3uc0v"),
+ ("\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032",
+ b"2-u9tlzr9756bt3uc0v"),
# (P) Maji<de>Koi<suru>5<byou><mae>
- (u"\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059"
- u"\u308B\u0035\u79D2\u524D",
- "MajiKoi5-783gue6qz075azm5e"),
+ ("\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059"
+ "\u308B\u0035\u79D2\u524D",
+ b"MajiKoi5-783gue6qz075azm5e"),
# (Q) <pafii>de<runba>
- (u"\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0",
- "de-jg4avhby1noc0d"),
+ ("\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0",
+ b"de-jg4avhby1noc0d"),
# (R) <sono><supiido><de>
- (u"\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067",
- "d9juau41awczczp"),
+ ("\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067",
+ b"d9juau41awczczp"),
# (S) -> $1.00 <-
- (u"\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020"
- u"\u003C\u002D",
- "-> $1.00 <--")
+ ("\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020"
+ "\u003C\u002D",
+ b"-> $1.00 <--")
]
for i in punycode_testcases:
if len(i)!=2:
- print repr(i)
+ print(repr(i))
class PunycodeTest(unittest.TestCase):
def test_encode(self):
@@ -823,11 +898,16 @@ class PunycodeTest(unittest.TestCase):
# code produces only lower case. Converting just puny to
# lower is also insufficient, since some of the input characters
# are upper case.
- self.assertEqual(uni.encode("punycode").lower(), puny.lower())
+ self.assertEqual(
+ str(uni.encode("punycode"), "ascii").lower(),
+ str(puny, "ascii").lower()
+ )
def test_decode(self):
for uni, puny in punycode_testcases:
self.assertEqual(uni, puny.decode("punycode"))
+ puny = puny.decode("ascii").encode("ascii")
+ self.assertEqual(uni, puny.decode("punycode"))
class UnicodeInternalTest(unittest.TestCase):
def test_bug1251300(self):
@@ -835,34 +915,34 @@ class UnicodeInternalTest(unittest.TestCase):
# points" above 0x10ffff on UCS-4 builds.
if sys.maxunicode > 0xffff:
ok = [
- ("\x00\x10\xff\xff", u"\U0010ffff"),
- ("\x00\x00\x01\x01", u"\U00000101"),
- ("", u""),
+ (b"\x00\x10\xff\xff", "\U0010ffff"),
+ (b"\x00\x00\x01\x01", "\U00000101"),
+ (b"", ""),
]
not_ok = [
- "\x7f\xff\xff\xff",
- "\x80\x00\x00\x00",
- "\x81\x00\x00\x00",
- "\x00",
- "\x00\x00\x00\x00\x00",
+ b"\x7f\xff\xff\xff",
+ b"\x80\x00\x00\x00",
+ b"\x81\x00\x00\x00",
+ b"\x00",
+ b"\x00\x00\x00\x00\x00",
]
for internal, uni in ok:
if sys.byteorder == "little":
- internal = "".join(reversed(internal))
+ internal = bytes(reversed(internal))
self.assertEqual(uni, internal.decode("unicode_internal"))
for internal in not_ok:
if sys.byteorder == "little":
- internal = "".join(reversed(internal))
+ internal = bytes(reversed(internal))
self.assertRaises(UnicodeDecodeError, internal.decode,
"unicode_internal")
def test_decode_error_attributes(self):
if sys.maxunicode > 0xffff:
try:
- "\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
- except UnicodeDecodeError, ex:
+ b"\x00\x00\x00\x00\x00\x11\x11\x00".decode("unicode_internal")
+ except UnicodeDecodeError as ex:
self.assertEqual("unicode_internal", ex.encoding)
- self.assertEqual("\x00\x00\x00\x00\x00\x11\x11\x00", ex.object)
+ self.assertEqual(b"\x00\x00\x00\x00\x00\x11\x11\x00", ex.object)
self.assertEqual(4, ex.start)
self.assertEqual(8, ex.end)
else:
@@ -872,171 +952,171 @@ class UnicodeInternalTest(unittest.TestCase):
if sys.maxunicode > 0xffff:
codecs.register_error("UnicodeInternalTest", codecs.ignore_errors)
decoder = codecs.getdecoder("unicode_internal")
- ab = u"ab".encode("unicode_internal")
- ignored = decoder("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
- "UnicodeInternalTest")
- self.assertEqual((u"ab", 12), ignored)
+ ab = "ab".encode("unicode_internal").decode()
+ ignored = decoder(bytes("%s\x22\x22\x22\x22%s" % (ab[:4], ab[4:]),
+ "ascii"),
+ "UnicodeInternalTest")
+ self.assertEqual(("ab", 12), ignored)
def test_encode_length(self):
# Issue 3739
encoder = codecs.getencoder("unicode_internal")
- self.assertEqual(encoder(u"a")[1], 1)
- self.assertEqual(encoder(u"\xe9\u0142")[1], 2)
+ self.assertEqual(encoder("a")[1], 1)
+ self.assertEqual(encoder("\xe9\u0142")[1], 2)
- encoder = codecs.getencoder("string-escape")
- self.assertEqual(encoder(r'\x00')[1], 4)
+ self.assertEqual(codecs.escape_encode(br'\x00')[1], 4)
# From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
nameprep_tests = [
# 3.1 Map to nothing.
- ('foo\xc2\xad\xcd\x8f\xe1\xa0\x86\xe1\xa0\x8bbar'
- '\xe2\x80\x8b\xe2\x81\xa0baz\xef\xb8\x80\xef\xb8\x88\xef'
- '\xb8\x8f\xef\xbb\xbf',
- 'foobarbaz'),
+ (b'foo\xc2\xad\xcd\x8f\xe1\xa0\x86\xe1\xa0\x8bbar'
+ b'\xe2\x80\x8b\xe2\x81\xa0baz\xef\xb8\x80\xef\xb8\x88\xef'
+ b'\xb8\x8f\xef\xbb\xbf',
+ b'foobarbaz'),
# 3.2 Case folding ASCII U+0043 U+0041 U+0046 U+0045.
- ('CAFE',
- 'cafe'),
+ (b'CAFE',
+ b'cafe'),
# 3.3 Case folding 8bit U+00DF (german sharp s).
# The original test case is bogus; it says \xc3\xdf
- ('\xc3\x9f',
- 'ss'),
+ (b'\xc3\x9f',
+ b'ss'),
# 3.4 Case folding U+0130 (turkish capital I with dot).
- ('\xc4\xb0',
- 'i\xcc\x87'),
+ (b'\xc4\xb0',
+ b'i\xcc\x87'),
# 3.5 Case folding multibyte U+0143 U+037A.
- ('\xc5\x83\xcd\xba',
- '\xc5\x84 \xce\xb9'),
+ (b'\xc5\x83\xcd\xba',
+ b'\xc5\x84 \xce\xb9'),
# 3.6 Case folding U+2121 U+33C6 U+1D7BB.
# XXX: skip this as it fails in UCS-2 mode
#('\xe2\x84\xa1\xe3\x8f\x86\xf0\x9d\x9e\xbb',
# 'telc\xe2\x88\x95kg\xcf\x83'),
(None, None),
# 3.7 Normalization of U+006a U+030c U+00A0 U+00AA.
- ('j\xcc\x8c\xc2\xa0\xc2\xaa',
- '\xc7\xb0 a'),
+ (b'j\xcc\x8c\xc2\xa0\xc2\xaa',
+ b'\xc7\xb0 a'),
# 3.8 Case folding U+1FB7 and normalization.
- ('\xe1\xbe\xb7',
- '\xe1\xbe\xb6\xce\xb9'),
+ (b'\xe1\xbe\xb7',
+ b'\xe1\xbe\xb6\xce\xb9'),
# 3.9 Self-reverting case folding U+01F0 and normalization.
# The original test case is bogus, it says `\xc7\xf0'
- ('\xc7\xb0',
- '\xc7\xb0'),
+ (b'\xc7\xb0',
+ b'\xc7\xb0'),
# 3.10 Self-reverting case folding U+0390 and normalization.
- ('\xce\x90',
- '\xce\x90'),
+ (b'\xce\x90',
+ b'\xce\x90'),
# 3.11 Self-reverting case folding U+03B0 and normalization.
- ('\xce\xb0',
- '\xce\xb0'),
+ (b'\xce\xb0',
+ b'\xce\xb0'),
# 3.12 Self-reverting case folding U+1E96 and normalization.
- ('\xe1\xba\x96',
- '\xe1\xba\x96'),
+ (b'\xe1\xba\x96',
+ b'\xe1\xba\x96'),
# 3.13 Self-reverting case folding U+1F56 and normalization.
- ('\xe1\xbd\x96',
- '\xe1\xbd\x96'),
+ (b'\xe1\xbd\x96',
+ b'\xe1\xbd\x96'),
# 3.14 ASCII space character U+0020.
- (' ',
- ' '),
+ (b' ',
+ b' '),
# 3.15 Non-ASCII 8bit space character U+00A0.
- ('\xc2\xa0',
- ' '),
+ (b'\xc2\xa0',
+ b' '),
# 3.16 Non-ASCII multibyte space character U+1680.
- ('\xe1\x9a\x80',
+ (b'\xe1\x9a\x80',
None),
# 3.17 Non-ASCII multibyte space character U+2000.
- ('\xe2\x80\x80',
- ' '),
+ (b'\xe2\x80\x80',
+ b' '),
# 3.18 Zero Width Space U+200b.
- ('\xe2\x80\x8b',
- ''),
+ (b'\xe2\x80\x8b',
+ b''),
# 3.19 Non-ASCII multibyte space character U+3000.
- ('\xe3\x80\x80',
- ' '),
+ (b'\xe3\x80\x80',
+ b' '),
# 3.20 ASCII control characters U+0010 U+007F.
- ('\x10\x7f',
- '\x10\x7f'),
+ (b'\x10\x7f',
+ b'\x10\x7f'),
# 3.21 Non-ASCII 8bit control character U+0085.
- ('\xc2\x85',
+ (b'\xc2\x85',
None),
# 3.22 Non-ASCII multibyte control character U+180E.
- ('\xe1\xa0\x8e',
+ (b'\xe1\xa0\x8e',
None),
# 3.23 Zero Width No-Break Space U+FEFF.
- ('\xef\xbb\xbf',
- ''),
+ (b'\xef\xbb\xbf',
+ b''),
# 3.24 Non-ASCII control character U+1D175.
- ('\xf0\x9d\x85\xb5',
+ (b'\xf0\x9d\x85\xb5',
None),
# 3.25 Plane 0 private use character U+F123.
- ('\xef\x84\xa3',
+ (b'\xef\x84\xa3',
None),
# 3.26 Plane 15 private use character U+F1234.
- ('\xf3\xb1\x88\xb4',
+ (b'\xf3\xb1\x88\xb4',
None),
# 3.27 Plane 16 private use character U+10F234.
- ('\xf4\x8f\x88\xb4',
+ (b'\xf4\x8f\x88\xb4',
None),
# 3.28 Non-character code point U+8FFFE.
- ('\xf2\x8f\xbf\xbe',
+ (b'\xf2\x8f\xbf\xbe',
None),
# 3.29 Non-character code point U+10FFFF.
- ('\xf4\x8f\xbf\xbf',
+ (b'\xf4\x8f\xbf\xbf',
None),
# 3.30 Surrogate code U+DF42.
- ('\xed\xbd\x82',
+ (b'\xed\xbd\x82',
None),
# 3.31 Non-plain text character U+FFFD.
- ('\xef\xbf\xbd',
+ (b'\xef\xbf\xbd',
None),
# 3.32 Ideographic description character U+2FF5.
- ('\xe2\xbf\xb5',
+ (b'\xe2\xbf\xb5',
None),
# 3.33 Display property character U+0341.
- ('\xcd\x81',
- '\xcc\x81'),
+ (b'\xcd\x81',
+ b'\xcc\x81'),
# 3.34 Left-to-right mark U+200E.
- ('\xe2\x80\x8e',
+ (b'\xe2\x80\x8e',
None),
# 3.35 Deprecated U+202A.
- ('\xe2\x80\xaa',
+ (b'\xe2\x80\xaa',
None),
# 3.36 Language tagging character U+E0001.
- ('\xf3\xa0\x80\x81',
+ (b'\xf3\xa0\x80\x81',
None),
# 3.37 Language tagging character U+E0042.
- ('\xf3\xa0\x81\x82',
+ (b'\xf3\xa0\x81\x82',
None),
# 3.38 Bidi: RandALCat character U+05BE and LCat characters.
- ('foo\xd6\xbebar',
+ (b'foo\xd6\xbebar',
None),
# 3.39 Bidi: RandALCat character U+FD50 and LCat characters.
- ('foo\xef\xb5\x90bar',
+ (b'foo\xef\xb5\x90bar',
None),
# 3.40 Bidi: RandALCat character U+FB38 and LCat characters.
- ('foo\xef\xb9\xb6bar',
- 'foo \xd9\x8ebar'),
+ (b'foo\xef\xb9\xb6bar',
+ b'foo \xd9\x8ebar'),
# 3.41 Bidi: RandALCat without trailing RandALCat U+0627 U+0031.
- ('\xd8\xa71',
+ (b'\xd8\xa71',
None),
# 3.42 Bidi: RandALCat character U+0627 U+0031 U+0628.
- ('\xd8\xa71\xd8\xa8',
- '\xd8\xa71\xd8\xa8'),
+ (b'\xd8\xa71\xd8\xa8',
+ b'\xd8\xa71\xd8\xa8'),
# 3.43 Unassigned code point U+E0002.
# Skip this test as we allow unassigned
- #('\xf3\xa0\x80\x82',
+ #(b'\xf3\xa0\x80\x82',
# None),
(None, None),
# 3.44 Larger test (shrinking).
# Original test case reads \xc3\xdf
- ('X\xc2\xad\xc3\x9f\xc4\xb0\xe2\x84\xa1j\xcc\x8c\xc2\xa0\xc2'
- '\xaa\xce\xb0\xe2\x80\x80',
- 'xssi\xcc\x87tel\xc7\xb0 a\xce\xb0 '),
+ (b'X\xc2\xad\xc3\x9f\xc4\xb0\xe2\x84\xa1j\xcc\x8c\xc2\xa0\xc2'
+ b'\xaa\xce\xb0\xe2\x80\x80',
+ b'xssi\xcc\x87tel\xc7\xb0 a\xce\xb0 '),
# 3.45 Larger test (expanding).
# Original test case reads \xc3\x9f
- ('X\xc3\x9f\xe3\x8c\x96\xc4\xb0\xe2\x84\xa1\xe2\x92\x9f\xe3\x8c'
- '\x80',
- 'xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3'
- '\x83\x88\xe3\x83\xabi\xcc\x87tel\x28d\x29\xe3\x82'
- '\xa2\xe3\x83\x91\xe3\x83\xbc\xe3\x83\x88')
+ (b'X\xc3\x9f\xe3\x8c\x96\xc4\xb0\xe2\x84\xa1\xe2\x92\x9f\xe3\x8c'
+ b'\x80',
+ b'xss\xe3\x82\xad\xe3\x83\xad\xe3\x83\xa1\xe3\x83\xbc\xe3'
+ b'\x83\x88\xe3\x83\xabi\xcc\x87tel\x28d\x29\xe3\x82'
+ b'\xa2\xe3\x83\x91\xe3\x83\xbc\xe3\x83\x88')
]
@@ -1048,110 +1128,109 @@ class NameprepTest(unittest.TestCase):
# Skipped
continue
# The Unicode strings are given in UTF-8
- orig = unicode(orig, "utf-8")
+ orig = str(orig, "utf-8", "surrogatepass")
if prepped is None:
# Input contains prohibited characters
self.assertRaises(UnicodeError, nameprep, orig)
else:
- prepped = unicode(prepped, "utf-8")
+ prepped = str(prepped, "utf-8", "surrogatepass")
try:
self.assertEqual(nameprep(orig), prepped)
- except Exception,e:
- raise test_support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
+ except Exception as e:
+ raise support.TestFailed("Test 3.%d: %s" % (pos+1, str(e)))
class IDNACodecTest(unittest.TestCase):
def test_builtin_decode(self):
- self.assertEqual(unicode("python.org", "idna"), u"python.org")
- self.assertEqual(unicode("python.org.", "idna"), u"python.org.")
- self.assertEqual(unicode("xn--pythn-mua.org", "idna"), u"pyth\xf6n.org")
- self.assertEqual(unicode("xn--pythn-mua.org.", "idna"), u"pyth\xf6n.org.")
+ self.assertEqual(str(b"python.org", "idna"), "python.org")
+ self.assertEqual(str(b"python.org.", "idna"), "python.org.")
+ self.assertEqual(str(b"xn--pythn-mua.org", "idna"), "pyth\xf6n.org")
+ self.assertEqual(str(b"xn--pythn-mua.org.", "idna"), "pyth\xf6n.org.")
def test_builtin_encode(self):
- self.assertEqual(u"python.org".encode("idna"), "python.org")
- self.assertEqual("python.org.".encode("idna"), "python.org.")
- self.assertEqual(u"pyth\xf6n.org".encode("idna"), "xn--pythn-mua.org")
- self.assertEqual(u"pyth\xf6n.org.".encode("idna"), "xn--pythn-mua.org.")
+ self.assertEqual("python.org".encode("idna"), b"python.org")
+ self.assertEqual("python.org.".encode("idna"), b"python.org.")
+ self.assertEqual("pyth\xf6n.org".encode("idna"), b"xn--pythn-mua.org")
+ self.assertEqual("pyth\xf6n.org.".encode("idna"), b"xn--pythn-mua.org.")
def test_stream(self):
- import StringIO
- r = codecs.getreader("idna")(StringIO.StringIO("abc"))
+ r = codecs.getreader("idna")(io.BytesIO(b"abc"))
r.read(3)
- self.assertEqual(r.read(), u"")
+ self.assertEqual(r.read(), "")
def test_incremental_decode(self):
self.assertEqual(
- "".join(codecs.iterdecode("python.org", "idna")),
- u"python.org"
+ "".join(codecs.iterdecode((bytes([c]) for c in b"python.org"), "idna")),
+ "python.org"
)
self.assertEqual(
- "".join(codecs.iterdecode("python.org.", "idna")),
- u"python.org."
+ "".join(codecs.iterdecode((bytes([c]) for c in b"python.org."), "idna")),
+ "python.org."
)
self.assertEqual(
- "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
- u"pyth\xf6n.org."
+ "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")),
+ "pyth\xf6n.org."
)
self.assertEqual(
- "".join(codecs.iterdecode("xn--pythn-mua.org.", "idna")),
- u"pyth\xf6n.org."
+ "".join(codecs.iterdecode((bytes([c]) for c in b"xn--pythn-mua.org."), "idna")),
+ "pyth\xf6n.org."
)
decoder = codecs.getincrementaldecoder("idna")()
- self.assertEqual(decoder.decode("xn--xam", ), u"")
- self.assertEqual(decoder.decode("ple-9ta.o", ), u"\xe4xample.")
- self.assertEqual(decoder.decode(u"rg"), u"")
- self.assertEqual(decoder.decode(u"", True), u"org")
+ self.assertEqual(decoder.decode(b"xn--xam", ), "")
+ self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.")
+ self.assertEqual(decoder.decode(b"rg"), "")
+ self.assertEqual(decoder.decode(b"", True), "org")
decoder.reset()
- self.assertEqual(decoder.decode("xn--xam", ), u"")
- self.assertEqual(decoder.decode("ple-9ta.o", ), u"\xe4xample.")
- self.assertEqual(decoder.decode("rg."), u"org.")
- self.assertEqual(decoder.decode("", True), u"")
+ self.assertEqual(decoder.decode(b"xn--xam", ), "")
+ self.assertEqual(decoder.decode(b"ple-9ta.o", ), "\xe4xample.")
+ self.assertEqual(decoder.decode(b"rg."), "org.")
+ self.assertEqual(decoder.decode(b"", True), "")
def test_incremental_encode(self):
self.assertEqual(
- "".join(codecs.iterencode(u"python.org", "idna")),
- "python.org"
+ b"".join(codecs.iterencode("python.org", "idna")),
+ b"python.org"
)
self.assertEqual(
- "".join(codecs.iterencode(u"python.org.", "idna")),
- "python.org."
+ b"".join(codecs.iterencode("python.org.", "idna")),
+ b"python.org."
)
self.assertEqual(
- "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
- "xn--pythn-mua.org."
+ b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")),
+ b"xn--pythn-mua.org."
)
self.assertEqual(
- "".join(codecs.iterencode(u"pyth\xf6n.org.", "idna")),
- "xn--pythn-mua.org."
+ b"".join(codecs.iterencode("pyth\xf6n.org.", "idna")),
+ b"xn--pythn-mua.org."
)
encoder = codecs.getincrementalencoder("idna")()
- self.assertEqual(encoder.encode(u"\xe4x"), "")
- self.assertEqual(encoder.encode(u"ample.org"), "xn--xample-9ta.")
- self.assertEqual(encoder.encode(u"", True), "org")
+ self.assertEqual(encoder.encode("\xe4x"), b"")
+ self.assertEqual(encoder.encode("ample.org"), b"xn--xample-9ta.")
+ self.assertEqual(encoder.encode("", True), b"org")
encoder.reset()
- self.assertEqual(encoder.encode(u"\xe4x"), "")
- self.assertEqual(encoder.encode(u"ample.org."), "xn--xample-9ta.org.")
- self.assertEqual(encoder.encode(u"", True), "")
+ self.assertEqual(encoder.encode("\xe4x"), b"")
+ self.assertEqual(encoder.encode("ample.org."), b"xn--xample-9ta.org.")
+ self.assertEqual(encoder.encode("", True), b"")
class CodecsModuleTest(unittest.TestCase):
def test_decode(self):
- self.assertEqual(codecs.decode('\xe4\xf6\xfc', 'latin-1'),
- u'\xe4\xf6\xfc')
+ self.assertEqual(codecs.decode(b'\xe4\xf6\xfc', 'latin-1'),
+ '\xe4\xf6\xfc')
self.assertRaises(TypeError, codecs.decode)
- self.assertEqual(codecs.decode('abc'), u'abc')
- self.assertRaises(UnicodeDecodeError, codecs.decode, '\xff', 'ascii')
+ self.assertEqual(codecs.decode(b'abc'), 'abc')
+ self.assertRaises(UnicodeDecodeError, codecs.decode, b'\xff', 'ascii')
def test_encode(self):
- self.assertEqual(codecs.encode(u'\xe4\xf6\xfc', 'latin-1'),
- '\xe4\xf6\xfc')
+ self.assertEqual(codecs.encode('\xe4\xf6\xfc', 'latin-1'),
+ b'\xe4\xf6\xfc')
self.assertRaises(TypeError, codecs.encode)
self.assertRaises(LookupError, codecs.encode, "foo", "__spam__")
- self.assertEqual(codecs.encode(u'abc'), 'abc')
- self.assertRaises(UnicodeEncodeError, codecs.encode, u'\xffff', 'ascii')
+ self.assertEqual(codecs.encode('abc'), b'abc')
+ self.assertRaises(UnicodeEncodeError, codecs.encode, '\xffff', 'ascii')
def test_register(self):
self.assertRaises(TypeError, codecs.register)
@@ -1180,8 +1259,8 @@ class CodecsModuleTest(unittest.TestCase):
def test_lookup_issue1813(self):
# Issue #1813: under Turkish locales, lookup of some codecs failed
- # because 'I' is lowercased as a dotless "i"
- oldlocale = locale.getlocale(locale.LC_CTYPE)
+ # because 'I' is lowercased as "ı" (dotless i)
+ oldlocale = locale.setlocale(locale.LC_CTYPE)
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
try:
locale.setlocale(locale.LC_CTYPE, 'tr_TR')
@@ -1195,43 +1274,26 @@ class StreamReaderTest(unittest.TestCase):
def setUp(self):
self.reader = codecs.getreader('utf-8')
- self.stream = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80')
+ self.stream = io.BytesIO(b'\xed\x95\x9c\n\xea\xb8\x80')
def test_readlines(self):
f = self.reader(self.stream)
- self.assertEqual(f.readlines(), [u'\ud55c\n', u'\uae00'])
+ self.assertEqual(f.readlines(), ['\ud55c\n', '\uae00'])
class EncodedFileTest(unittest.TestCase):
def test_basic(self):
- f = StringIO.StringIO('\xed\x95\x9c\n\xea\xb8\x80')
+ f = io.BytesIO(b'\xed\x95\x9c\n\xea\xb8\x80')
ef = codecs.EncodedFile(f, 'utf-16-le', 'utf-8')
- self.assertEqual(ef.read(), '\\\xd5\n\x00\x00\xae')
+ self.assertEqual(ef.read(), b'\\\xd5\n\x00\x00\xae')
- f = StringIO.StringIO()
+ f = io.BytesIO()
ef = codecs.EncodedFile(f, 'utf-8', 'latin1')
- ef.write('\xc3\xbc')
- self.assertEqual(f.getvalue(), '\xfc')
-
-class Str2StrTest(unittest.TestCase):
-
- def test_read(self):
- sin = "\x80".encode("base64_codec")
- reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
- sout = reader.read()
- self.assertEqual(sout, "\x80")
- self.assertIsInstance(sout, str)
-
- def test_readline(self):
- sin = "\x80".encode("base64_codec")
- reader = codecs.getreader("base64_codec")(StringIO.StringIO(sin))
- sout = reader.readline()
- self.assertEqual(sout, "\x80")
- self.assertIsInstance(sout, str)
+ ef.write(b'\xc3\xbc')
+ self.assertEqual(f.getvalue(), b'\xfc')
all_unicode_encodings = [
"ascii",
- "base64_codec",
"big5",
"big5hkscs",
"charmap",
@@ -1280,7 +1342,6 @@ all_unicode_encodings = [
"gb18030",
"gb2312",
"gbk",
- "hex_codec",
"hp_roman8",
"hz",
"idna",
@@ -1320,7 +1381,6 @@ all_unicode_encodings = [
"ptcp154",
"punycode",
"raw_unicode_escape",
- "rot_13",
"shift_jis",
"shift_jis_2004",
"shift_jisx0213",
@@ -1337,52 +1397,22 @@ all_unicode_encodings = [
if hasattr(codecs, "mbcs_encode"):
all_unicode_encodings.append("mbcs")
-# The following encodings work only with str, not unicode
-all_string_encodings = [
- "quopri_codec",
- "string_escape",
- "uu_codec",
-]
-
# The following encoding is not tested, because it's not supposed
# to work:
# "undefined"
# The following encodings don't work in stateful mode
broken_unicode_with_streams = [
- "base64_codec",
- "hex_codec",
"punycode",
"unicode_internal"
]
-broken_incremental_coders = broken_unicode_with_streams[:]
-
-# The following encodings only support "strict" mode
-only_strict_mode = [
+broken_incremental_coders = broken_unicode_with_streams + [
"idna",
- "zlib_codec",
- "bz2_codec",
]
-try:
- import bz2
-except ImportError:
- pass
-else:
- all_unicode_encodings.append("bz2_codec")
- broken_unicode_with_streams.append("bz2_codec")
-
-try:
- import zlib
-except ImportError:
- pass
-else:
- all_unicode_encodings.append("zlib_codec")
- broken_unicode_with_streams.append("zlib_codec")
-
-class BasicUnicodeTest(unittest.TestCase):
+class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling):
def test_basics(self):
- s = u"abc123" # all codecs should be able to encode these
+ s = "abc123" # all codecs should be able to encode these
for encoding in all_unicode_encodings:
name = codecs.lookup(encoding).name
if encoding.endswith("_codec"):
@@ -1390,24 +1420,26 @@ class BasicUnicodeTest(unittest.TestCase):
elif encoding == "latin_1":
name = "latin_1"
self.assertEqual(encoding.replace("_", "-"), name.replace("_", "-"))
- (bytes, size) = codecs.getencoder(encoding)(s)
+ (b, size) = codecs.getencoder(encoding)(s)
self.assertEqual(size, len(s), "%r != %r (encoding=%r)" % (size, len(s), encoding))
- (chars, size) = codecs.getdecoder(encoding)(bytes)
+ (chars, size) = codecs.getdecoder(encoding)(b)
self.assertEqual(chars, s, "%r != %r (encoding=%r)" % (chars, s, encoding))
if encoding not in broken_unicode_with_streams:
# check stream reader/writer
- q = Queue()
+ q = Queue(b"")
writer = codecs.getwriter(encoding)(q)
- encodedresult = ""
+ encodedresult = b""
for c in s:
writer.write(c)
- encodedresult += q.read()
- q = Queue()
+ chunk = q.read()
+ self.assertTrue(type(chunk) is bytes, type(chunk))
+ encodedresult += chunk
+ q = Queue(b"")
reader = codecs.getreader(encoding)(q)
- decodedresult = u""
+ decodedresult = ""
for c in encodedresult:
- q.write(c)
+ q.write(bytes([c]))
decodedresult += reader.read()
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
@@ -1421,38 +1453,38 @@ class BasicUnicodeTest(unittest.TestCase):
pass
else:
# check incremental decoder/encoder
- encodedresult = ""
+ encodedresult = b""
for c in s:
encodedresult += encoder.encode(c)
- encodedresult += encoder.encode(u"", True)
+ encodedresult += encoder.encode("", True)
decoder = codecs.getincrementaldecoder(encoding)()
- decodedresult = u""
+ decodedresult = ""
for c in encodedresult:
- decodedresult += decoder.decode(c)
- decodedresult += decoder.decode("", True)
+ decodedresult += decoder.decode(bytes([c]))
+ decodedresult += decoder.decode(b"", True)
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
# check C API
- encodedresult = ""
+ encodedresult = b""
for c in s:
encodedresult += cencoder.encode(c)
- encodedresult += cencoder.encode(u"", True)
+ encodedresult += cencoder.encode("", True)
cdecoder = _testcapi.codec_incrementaldecoder(encoding)
- decodedresult = u""
+ decodedresult = ""
for c in encodedresult:
- decodedresult += cdecoder.decode(c)
- decodedresult += cdecoder.decode("", True)
+ decodedresult += cdecoder.decode(bytes([c]))
+ decodedresult += cdecoder.decode(b"", True)
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
# check iterencode()/iterdecode()
- result = u"".join(codecs.iterdecode(codecs.iterencode(s, encoding), encoding))
+ result = "".join(codecs.iterdecode(codecs.iterencode(s, encoding), encoding))
self.assertEqual(result, s, "%r != %r (encoding=%r)" % (result, s, encoding))
# check iterencode()/iterdecode() with empty string
- result = u"".join(codecs.iterdecode(codecs.iterencode(u"", encoding), encoding))
- self.assertEqual(result, u"")
+ result = "".join(codecs.iterdecode(codecs.iterencode("", encoding), encoding))
+ self.assertEqual(result, "")
- if encoding not in only_strict_mode:
+ if encoding not in ("idna", "mbcs"):
# check incremental decoder/encoder with errors argument
try:
encoder = codecs.getincrementalencoder(encoding)("ignore")
@@ -1460,30 +1492,30 @@ class BasicUnicodeTest(unittest.TestCase):
except LookupError: # no IncrementalEncoder
pass
else:
- encodedresult = "".join(encoder.encode(c) for c in s)
+ encodedresult = b"".join(encoder.encode(c) for c in s)
decoder = codecs.getincrementaldecoder(encoding)("ignore")
- decodedresult = u"".join(decoder.decode(c) for c in encodedresult)
+ decodedresult = "".join(decoder.decode(bytes([c])) for c in encodedresult)
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
- encodedresult = "".join(cencoder.encode(c) for c in s)
+ encodedresult = b"".join(cencoder.encode(c) for c in s)
cdecoder = _testcapi.codec_incrementaldecoder(encoding, "ignore")
- decodedresult = u"".join(cdecoder.decode(c) for c in encodedresult)
+ decodedresult = "".join(cdecoder.decode(bytes([c])) for c in encodedresult)
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
def test_seek(self):
# all codecs should be able to encode these
- s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456")
+ s = "%s\n%s\n" % (100*"abc123", 100*"def456")
for encoding in all_unicode_encodings:
if encoding == "idna": # FIXME: See SF bug #1163178
continue
if encoding in broken_unicode_with_streams:
continue
- reader = codecs.getreader(encoding)(StringIO.StringIO(s.encode(encoding)))
- for t in xrange(5):
+ reader = codecs.getreader(encoding)(io.BytesIO(s.encode(encoding)))
+ for t in range(5):
# Test that calling seek resets the internal codec state and buffers
reader.seek(0, 0)
- line = reader.readline()
- self.assertEqual(s[:len(line)], line)
+ data = reader.read()
+ self.assertEqual(s, data)
def test_bad_decode_args(self):
for encoding in all_unicode_encodings:
@@ -1503,180 +1535,242 @@ class BasicUnicodeTest(unittest.TestCase):
table_type = type(cp1140.encoding_table)
self.assertEqual(table_type, table_type)
-class BasicStrTest(unittest.TestCase):
- def test_basics(self):
- s = "abc123"
- for encoding in all_string_encodings:
- (bytes, size) = codecs.getencoder(encoding)(s)
- self.assertEqual(size, len(s))
- (chars, size) = codecs.getdecoder(encoding)(bytes)
- self.assertEqual(chars, s, "%r != %r (encoding=%r)" % (chars, s, encoding))
+ def test_decoder_state(self):
+ # Check that getstate() and setstate() handle the state properly
+ u = "abc123"
+ for encoding in all_unicode_encodings:
+ if encoding not in broken_incremental_coders:
+ self.check_state_handling_decode(encoding, u, u.encode(encoding))
+ self.check_state_handling_encode(encoding, u, u.encode(encoding))
class CharmapTest(unittest.TestCase):
def test_decode_with_string_map(self):
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict", u"abc"),
- (u"abc", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "strict", "abc"),
+ ("abc", 3)
)
- self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "replace", u"ab"),
- (u"ab\ufffd", 3)
+ self.assertRaises(UnicodeDecodeError,
+ codecs.charmap_decode, b"\x00\x01\x02", "strict", "ab"
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "replace", u"ab\ufffe"),
- (u"ab\ufffd", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab"),
+ ("ab\ufffd", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab"),
- (u"ab", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "replace", "ab\ufffe"),
+ ("ab\ufffd", 3)
)
- self.assertRaises(UnicodeDecodeError,
- codecs.charmap_decode, b"\x00\x01\x02", "strict", u"ab"
+ self.assertEqual(
+ codecs.charmap_decode(b"\x00\x01\x02", "ignore", "ab"),
+ ("ab", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "ignore", u"ab\ufffe"),
- (u"ab", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "ignore", "ab\ufffe"),
+ ("ab", 3)
)
- allbytes = "".join(chr(i) for i in xrange(256))
+ allbytes = bytes(range(256))
self.assertEqual(
- codecs.charmap_decode(allbytes, "ignore", u""),
- (u"", len(allbytes))
+ codecs.charmap_decode(allbytes, "ignore", ""),
+ ("", len(allbytes))
)
def test_decode_with_int2str_map(self):
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
- {0: u'a', 1: u'b', 2: u'c'}),
- (u"abc", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
+ {0: 'a', 1: 'b', 2: 'c'}),
+ ("abc", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
- {0: u'Aa', 1: u'Bb', 2: u'Cc'}),
- (u"AaBbCc", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
+ {0: 'Aa', 1: 'Bb', 2: 'Cc'}),
+ ("AaBbCc", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
- {0: u'\U0010FFFF', 1: u'b', 2: u'c'}),
- (u"\U0010FFFFbc", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
+ {0: '\U0010FFFF', 1: 'b', 2: 'c'}),
+ ("\U0010FFFFbc", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
- {0: u'a', 1: u'b', 2: u''}),
- (u"ab", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
+ {0: 'a', 1: 'b', 2: ''}),
+ ("ab", 3)
)
self.assertRaises(UnicodeDecodeError,
- codecs.charmap_decode, "\x00\x01\x02", "strict",
- {0: u'a', 1: u'b'}
+ codecs.charmap_decode, b"\x00\x01\x02", "strict",
+ {0: 'a', 1: 'b'}
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "replace",
- {0: u'a', 1: u'b'}),
- (u"ab\ufffd", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "replace",
+ {0: 'a', 1: 'b'}),
+ ("ab\ufffd", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "replace",
- {0: u'a', 1: u'b', 2: None}),
- (u"ab\ufffd", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "replace",
+ {0: 'a', 1: 'b', 2: None}),
+ ("ab\ufffd", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "ignore",
- {0: u'a', 1: u'b'}),
- (u"ab", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "ignore",
+ {0: 'a', 1: 'b'}),
+ ("ab", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "ignore",
- {0: u'a', 1: u'b', 2: None}),
- (u"ab", 3)
+ codecs.charmap_decode(b"\x00\x01\x02", "ignore",
+ {0: 'a', 1: 'b', 2: None}),
+ ("ab", 3)
)
allbytes = bytes(range(256))
self.assertEqual(
codecs.charmap_decode(allbytes, "ignore", {}),
- (u"", len(allbytes))
+ ("", len(allbytes))
)
def test_decode_with_int2int_map(self):
- a = ord(u'a')
- b = ord(u'b')
- c = ord(u'c')
+ a = ord('a')
+ b = ord('b')
+ c = ord('c')
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
{0: a, 1: b, 2: c}),
- (u"abc", 3)
+ ("abc", 3)
)
# Issue #15379
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "strict",
+ codecs.charmap_decode(b"\x00\x01\x02", "strict",
{0: 0x10FFFF, 1: b, 2: c}),
- (u"\U0010FFFFbc", 3)
+ ("\U0010FFFFbc", 3)
)
self.assertRaises(TypeError,
- codecs.charmap_decode, "\x00\x01\x02", "strict",
+ codecs.charmap_decode, b"\x00\x01\x02", "strict",
{0: 0x110000, 1: b, 2: c}
)
self.assertRaises(UnicodeDecodeError,
- codecs.charmap_decode, "\x00\x01\x02", "strict",
+ codecs.charmap_decode, b"\x00\x01\x02", "strict",
{0: a, 1: b},
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "replace",
+ codecs.charmap_decode(b"\x00\x01\x02", "replace",
{0: a, 1: b}),
- (u"ab\ufffd", 3)
+ ("ab\ufffd", 3)
)
self.assertEqual(
- codecs.charmap_decode("\x00\x01\x02", "ignore",
+ codecs.charmap_decode(b"\x00\x01\x02", "ignore",
{0: a, 1: b}),
- (u"ab", 3)
+ ("ab", 3)
)
class WithStmtTest(unittest.TestCase):
def test_encodedfile(self):
- f = StringIO.StringIO("\xc3\xbc")
+ f = io.BytesIO(b"\xc3\xbc")
with codecs.EncodedFile(f, "latin-1", "utf-8") as ef:
- self.assertEqual(ef.read(), "\xfc")
+ self.assertEqual(ef.read(), b"\xfc")
def test_streamreaderwriter(self):
- f = StringIO.StringIO("\xc3\xbc")
+ f = io.BytesIO(b"\xc3\xbc")
info = codecs.lookup("utf-8")
with codecs.StreamReaderWriter(f, info.streamreader,
info.streamwriter, 'strict') as srw:
- self.assertEqual(srw.read(), u"\xfc")
+ self.assertEqual(srw.read(), "\xfc")
+
+class TypesTest(unittest.TestCase):
+ def test_decode_unicode(self):
+ # Most decoders don't accept unicode input
+ decoders = [
+ codecs.utf_7_decode,
+ codecs.utf_8_decode,
+ codecs.utf_16_le_decode,
+ codecs.utf_16_be_decode,
+ codecs.utf_16_ex_decode,
+ codecs.utf_32_decode,
+ codecs.utf_32_le_decode,
+ codecs.utf_32_be_decode,
+ codecs.utf_32_ex_decode,
+ codecs.latin_1_decode,
+ codecs.ascii_decode,
+ codecs.charmap_decode,
+ ]
+ if hasattr(codecs, "mbcs_decode"):
+ decoders.append(codecs.mbcs_decode)
+ for decoder in decoders:
+ self.assertRaises(TypeError, decoder, "xxx")
+
+ def test_unicode_escape(self):
+ # Escape-decoding an unicode string is supported ang gives the same
+ # result as decoding the equivalent ASCII bytes string.
+ self.assertEqual(codecs.unicode_escape_decode(r"\u1234"), ("\u1234", 6))
+ self.assertEqual(codecs.unicode_escape_decode(br"\u1234"), ("\u1234", 6))
+ self.assertEqual(codecs.raw_unicode_escape_decode(r"\u1234"), ("\u1234", 6))
+ self.assertEqual(codecs.raw_unicode_escape_decode(br"\u1234"), ("\u1234", 6))
+
+class SurrogateEscapeTest(unittest.TestCase):
+
+ def test_utf8(self):
+ # Bad byte
+ self.assertEqual(b"foo\x80bar".decode("utf-8", "surrogateescape"),
+ "foo\udc80bar")
+ self.assertEqual("foo\udc80bar".encode("utf-8", "surrogateescape"),
+ b"foo\x80bar")
+ # bad-utf-8 encoded surrogate
+ self.assertEqual(b"\xed\xb0\x80".decode("utf-8", "surrogateescape"),
+ "\udced\udcb0\udc80")
+ self.assertEqual("\udced\udcb0\udc80".encode("utf-8", "surrogateescape"),
+ b"\xed\xb0\x80")
+
+ def test_ascii(self):
+ # bad byte
+ self.assertEqual(b"foo\x80bar".decode("ascii", "surrogateescape"),
+ "foo\udc80bar")
+ self.assertEqual("foo\udc80bar".encode("ascii", "surrogateescape"),
+ b"foo\x80bar")
+
+ def test_charmap(self):
+ # bad byte: \xa5 is unmapped in iso-8859-3
+ self.assertEqual(b"foo\xa5bar".decode("iso-8859-3", "surrogateescape"),
+ "foo\udca5bar")
+ self.assertEqual("foo\udca5bar".encode("iso-8859-3", "surrogateescape"),
+ b"foo\xa5bar")
+
+ def test_latin1(self):
+ # Issue6373
+ self.assertEqual("\udce4\udceb\udcef\udcf6\udcfc".encode("latin1", "surrogateescape"),
+ b"\xe4\xeb\xef\xf6\xfc")
class BomTest(unittest.TestCase):
def test_seek0(self):
- data = u"1234567890"
+ data = "1234567890"
tests = ("utf-16",
"utf-16-le",
"utf-16-be",
"utf-32",
"utf-32-le",
"utf-32-be")
- self.addCleanup(test_support.unlink, test_support.TESTFN)
+ self.addCleanup(support.unlink, support.TESTFN)
for encoding in tests:
# Check if the BOM is written only once
- with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
+ with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
f.write(data)
f.write(data)
f.seek(0)
@@ -1685,7 +1779,7 @@ class BomTest(unittest.TestCase):
self.assertEqual(f.read(), data * 2)
# Check that the BOM is written after a seek(0)
- with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
+ with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
f.write(data[0])
self.assertNotEqual(f.tell(), 0)
f.seek(0)
@@ -1694,7 +1788,7 @@ class BomTest(unittest.TestCase):
self.assertEqual(f.read(), data)
# (StreamWriter) Check that the BOM is written after a seek(0)
- with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
+ with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
f.writer.write(data[0])
self.assertNotEqual(f.writer.tell(), 0)
f.writer.seek(0)
@@ -1704,7 +1798,7 @@ class BomTest(unittest.TestCase):
# Check that the BOM is not written after a seek() at a position
# different than the start
- with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
+ with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
f.write(data)
f.seek(f.tell())
f.write(data)
@@ -1713,7 +1807,7 @@ class BomTest(unittest.TestCase):
# (StreamWriter) Check that the BOM is not written after a seek()
# at a position different than the start
- with codecs.open(test_support.TESTFN, 'w+', encoding=encoding) as f:
+ with codecs.open(support.TESTFN, 'w+', encoding=encoding) as f:
f.writer.write(data)
f.writer.seek(f.writer.tell())
f.writer.write(data)
@@ -1721,8 +1815,56 @@ class BomTest(unittest.TestCase):
self.assertEqual(f.read(), data * 2)
+bytes_transform_encodings = [
+ "base64_codec",
+ "uu_codec",
+ "quopri_codec",
+ "hex_codec",
+]
+try:
+ import zlib
+except ImportError:
+ pass
+else:
+ bytes_transform_encodings.append("zlib_codec")
+try:
+ import bz2
+except ImportError:
+ pass
+else:
+ bytes_transform_encodings.append("bz2_codec")
+
+class TransformCodecTest(unittest.TestCase):
+
+ def test_basics(self):
+ binput = bytes(range(256))
+ for encoding in bytes_transform_encodings:
+ # generic codecs interface
+ (o, size) = codecs.getencoder(encoding)(binput)
+ self.assertEqual(size, len(binput))
+ (i, size) = codecs.getdecoder(encoding)(o)
+ self.assertEqual(size, len(o))
+ self.assertEqual(i, binput)
+
+ def test_read(self):
+ for encoding in bytes_transform_encodings:
+ sin = codecs.encode(b"\x80", encoding)
+ reader = codecs.getreader(encoding)(io.BytesIO(sin))
+ sout = reader.read()
+ self.assertEqual(sout, b"\x80")
+
+ def test_readline(self):
+ for encoding in bytes_transform_encodings:
+ if encoding in ['uu_codec', 'zlib_codec']:
+ continue
+ sin = codecs.encode(b"\x80", encoding)
+ reader = codecs.getreader(encoding)(io.BytesIO(sin))
+ sout = reader.readline()
+ self.assertEqual(sout, b"\x80")
+
+
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
UTF32Test,
UTF32LETest,
UTF32BETest,
@@ -1734,8 +1876,6 @@ def test_main():
UTF7Test,
UTF16ExTest,
ReadBufferTest,
- CharBufferTest,
- EscapeDecodeTest,
RecodingTest,
PunycodeTest,
UnicodeInternalTest,
@@ -1744,12 +1884,13 @@ def test_main():
CodecsModuleTest,
StreamReaderTest,
EncodedFileTest,
- Str2StrTest,
BasicUnicodeTest,
- BasicStrTest,
CharmapTest,
WithStmtTest,
+ TypesTest,
+ SurrogateEscapeTest,
BomTest,
+ TransformCodecTest,
)
diff --git a/Lib/test/test_codeop.py b/Lib/test/test_codeop.py
index 00cd3ceb76f..b65423b34cd 100644
--- a/Lib/test/test_codeop.py
+++ b/Lib/test/test_codeop.py
@@ -3,18 +3,18 @@
Nick Mathewson
"""
import unittest
-from test.test_support import run_unittest, is_jython
+from test.support import run_unittest, is_jython
from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
+import io
if is_jython:
import sys
- import cStringIO
def unify_callables(d):
for n,v in d.items():
- if callable(v):
- d[n] = callable
+ if hasattr(v, '__call__'):
+ d[n] = True
return d
class CodeopTests(unittest.TestCase):
@@ -27,10 +27,10 @@ class CodeopTests(unittest.TestCase):
if symbol == "single":
d,r = {},{}
saved_stdout = sys.stdout
- sys.stdout = cStringIO.StringIO()
+ sys.stdout = io.StringIO()
try:
- exec code in d
- exec compile(str,"<input>","single") in r
+ exec(code, d)
+ exec(compile(str,"<input>","single"), r)
finally:
sys.stdout = saved_stdout
elif symbol == 'eval':
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py
index 7f5ddb1934b..f9db0b40f00 100644
--- a/Lib/test/test_coding.py
+++ b/Lib/test/test_coding.py
@@ -1,6 +1,7 @@
-import test.test_support, unittest
-import os
+import test.support, unittest
+from test.support import TESTFN, unlink, unload
+import os, sys
class CodingTest(unittest.TestCase):
def test_bad_coding(self):
@@ -16,13 +17,40 @@ class CodingTest(unittest.TestCase):
path = os.path.dirname(__file__)
filename = os.path.join(path, module_name + '.py')
- with open(filename) as fp:
- text = fp.read()
- self.assertRaises(SyntaxError, compile, text, filename, 'exec')
+ with open(filename, "rb") as fp:
+ bytes = fp.read()
+ self.assertRaises(SyntaxError, compile, bytes, filename, 'exec')
+
+ def test_exec_valid_coding(self):
+ d = {}
+ exec('# coding: cp949\na = 5\n', d)
+ self.assertEqual(d['a'], 5)
+
+ def test_file_parse(self):
+ # issue1134: all encodings outside latin-1 and utf-8 fail on
+ # multiline strings and long lines (>512 columns)
+ unload(TESTFN)
+ sys.path.insert(0, os.curdir)
+ filename = TESTFN + ".py"
+ f = open(filename, "w")
+ try:
+ f.write("# -*- coding: cp1252 -*-\n")
+ f.write("'''A short string\n")
+ f.write("'''\n")
+ f.write("'A very long string %s'\n" % ("X" * 1000))
+ f.close()
+
+ __import__(TESTFN)
+ finally:
+ f.close()
+ unlink(filename)
+ unlink(filename + "c")
+ unload(TESTFN)
+ del sys.path[0]
def test_error_from_string(self):
# See http://bugs.python.org/issue6289
- input = u"# coding: ascii\n\N{SNOWMAN}".encode('utf-8')
+ input = "# coding: ascii\n\N{SNOWMAN}".encode('utf-8')
with self.assertRaises(SyntaxError) as c:
compile(input, "<string>", "exec")
expected = "'ascii' codec can't decode byte 0xe2 in position 16: " \
@@ -31,7 +59,7 @@ class CodingTest(unittest.TestCase):
def test_main():
- test.test_support.run_unittest(CodingTest)
+ test.support.run_unittest(CodingTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_coercion.py b/Lib/test/test_coercion.py
deleted file mode 100644
index 2b55c419ab9..00000000000
--- a/Lib/test/test_coercion.py
+++ /dev/null
@@ -1,348 +0,0 @@
-import copy
-import unittest
-from test.test_support import run_unittest, TestFailed, check_warnings
-
-
-# Fake a number that implements numeric methods through __coerce__
-class CoerceNumber:
- def __init__(self, arg):
- self.arg = arg
-
- def __repr__(self):
- return '<CoerceNumber %s>' % repr(self.arg)
-
- def __coerce__(self, other):
- if isinstance(other, CoerceNumber):
- return self.arg, other.arg
- else:
- return (self.arg, other)
-
-# New-style class version of CoerceNumber
-class CoerceTo(object):
- def __init__(self, arg):
- self.arg = arg
- def __coerce__(self, other):
- if isinstance(other, CoerceTo):
- return self.arg, other.arg
- else:
- return self.arg, other
-
-
-# Fake a number that implements numeric ops through methods.
-class MethodNumber:
- def __init__(self,arg):
- self.arg = arg
-
- def __repr__(self):
- return '<MethodNumber %s>' % repr(self.arg)
-
- def __add__(self,other):
- return self.arg + other
-
- def __radd__(self,other):
- return other + self.arg
-
- def __sub__(self,other):
- return self.arg - other
-
- def __rsub__(self,other):
- return other - self.arg
-
- def __mul__(self,other):
- return self.arg * other
-
- def __rmul__(self,other):
- return other * self.arg
-
- def __div__(self,other):
- return self.arg / other
-
- def __rdiv__(self,other):
- return other / self.arg
-
- def __truediv__(self,other):
- return self.arg / other
-
- def __rtruediv__(self,other):
- return other / self.arg
-
- def __floordiv__(self,other):
- return self.arg // other
-
- def __rfloordiv__(self,other):
- return other // self.arg
-
- def __pow__(self,other):
- return self.arg ** other
-
- def __rpow__(self,other):
- return other ** self.arg
-
- def __mod__(self,other):
- return self.arg % other
-
- def __rmod__(self,other):
- return other % self.arg
-
- def __cmp__(self, other):
- return cmp(self.arg, other)
-
-
-candidates = [2, 2L, 4.0, 2+0j, [1], (2,), None,
- MethodNumber(2), CoerceNumber(2)]
-
-infix_binops = [ '+', '-', '*', '**', '%', '//', '/' ]
-
-TE = TypeError
-# b = both normal and augmented give same result list
-# s = single result lists for normal and augmented
-# e = equals other results
-# result lists: ['+', '-', '*', '**', '%', '//', ('classic /', 'new /')]
-# ^^^^^^^^^^^^^^^^^^^^^^
-# 2-tuple if results differ
-# else only one value
-infix_results = {
- # 2
- (0,0): ('b', [4, 0, 4, 4, 0, 1, (1, 1.0)]),
- (0,1): ('e', (0,0)),
- (0,2): ('b', [6.0, -2.0, 8.0, 16.0, 2.0, 0.0, 0.5]),
- (0,3): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
- (0,4): ('b', [TE, TE, [1, 1], TE, TE, TE, TE]),
- (0,5): ('b', [TE, TE, (2, 2), TE, TE, TE, TE]),
- (0,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (0,7): ('e', (0,0)),
- (0,8): ('e', (0,0)),
-
- # 2L
- (1,0): ('e', (0,0)),
- (1,1): ('e', (0,1)),
- (1,2): ('e', (0,2)),
- (1,3): ('e', (0,3)),
- (1,4): ('e', (0,4)),
- (1,5): ('e', (0,5)),
- (1,6): ('e', (0,6)),
- (1,7): ('e', (0,7)),
- (1,8): ('e', (0,8)),
-
- # 4.0
- (2,0): ('b', [6.0, 2.0, 8.0, 16.0, 0.0, 2.0, 2.0]),
- (2,1): ('e', (2,0)),
- (2,2): ('b', [8.0, 0.0, 16.0, 256.0, 0.0, 1.0, 1.0]),
- (2,3): ('b', [6+0j, 2+0j, 8+0j, 16+0j, 0+0j, 2+0j, 2+0j]),
- (2,4): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (2,5): ('e', (2,4)),
- (2,6): ('e', (2,4)),
- (2,7): ('e', (2,0)),
- (2,8): ('e', (2,0)),
-
- # (2+0j)
- (3,0): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
- (3,1): ('e', (3,0)),
- (3,2): ('b', [6+0j, -2+0j, 8+0j, 16+0j, 2+0j, 0+0j, 0.5+0j]),
- (3,3): ('b', [4+0j, 0+0j, 4+0j, 4+0j, 0+0j, 1+0j, 1+0j]),
- (3,4): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (3,5): ('e', (3,4)),
- (3,6): ('e', (3,4)),
- (3,7): ('e', (3,0)),
- (3,8): ('e', (3,0)),
-
- # [1]
- (4,0): ('b', [TE, TE, [1, 1], TE, TE, TE, TE]),
- (4,1): ('e', (4,0)),
- (4,2): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (4,3): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (4,4): ('b', [[1, 1], TE, TE, TE, TE, TE, TE]),
- (4,5): ('s', [TE, TE, TE, TE, TE, TE, TE], [[1, 2], TE, TE, TE, TE, TE, TE]),
- (4,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (4,7): ('e', (4,0)),
- (4,8): ('e', (4,0)),
-
- # (2,)
- (5,0): ('b', [TE, TE, (2, 2), TE, TE, TE, TE]),
- (5,1): ('e', (5,0)),
- (5,2): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (5,3): ('e', (5,2)),
- (5,4): ('e', (5,2)),
- (5,5): ('b', [(2, 2), TE, TE, TE, TE, TE, TE]),
- (5,6): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (5,7): ('e', (5,0)),
- (5,8): ('e', (5,0)),
-
- # None
- (6,0): ('b', [TE, TE, TE, TE, TE, TE, TE]),
- (6,1): ('e', (6,0)),
- (6,2): ('e', (6,0)),
- (6,3): ('e', (6,0)),
- (6,4): ('e', (6,0)),
- (6,5): ('e', (6,0)),
- (6,6): ('e', (6,0)),
- (6,7): ('e', (6,0)),
- (6,8): ('e', (6,0)),
-
- # MethodNumber(2)
- (7,0): ('e', (0,0)),
- (7,1): ('e', (0,1)),
- (7,2): ('e', (0,2)),
- (7,3): ('e', (0,3)),
- (7,4): ('e', (0,4)),
- (7,5): ('e', (0,5)),
- (7,6): ('e', (0,6)),
- (7,7): ('e', (0,7)),
- (7,8): ('e', (0,8)),
-
- # CoerceNumber(2)
- (8,0): ('e', (0,0)),
- (8,1): ('e', (0,1)),
- (8,2): ('e', (0,2)),
- (8,3): ('e', (0,3)),
- (8,4): ('e', (0,4)),
- (8,5): ('e', (0,5)),
- (8,6): ('e', (0,6)),
- (8,7): ('e', (0,7)),
- (8,8): ('e', (0,8)),
-}
-
-def process_infix_results():
- for key in sorted(infix_results):
- val = infix_results[key]
- if val[0] == 'e':
- infix_results[key] = infix_results[val[1]]
- else:
- if val[0] == 's':
- res = (val[1], val[2])
- elif val[0] == 'b':
- res = (val[1], val[1])
- for i in range(1):
- if isinstance(res[i][6], tuple):
- if 1/2 == 0:
- # testing with classic (floor) division
- res[i][6] = res[i][6][0]
- else:
- # testing with -Qnew
- res[i][6] = res[i][6][1]
- infix_results[key] = res
-
-
-with check_warnings(("classic (int|long) division", DeprecationWarning),
- quiet=True):
- process_infix_results()
- # now infix_results has two lists of results for every pairing.
-
-prefix_binops = [ 'divmod' ]
-prefix_results = [
- [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)],
- [(1L,0L), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1L,0L)],
- [(2.0,0.0), (2.0,0.0), (1.0,0.0), ((2+0j),0j), TE, TE, TE, TE, (2.0,0.0)],
- [((1+0j),0j), ((1+0j),0j), (0j,(2+0j)), ((1+0j),0j), TE, TE, TE, TE, ((1+0j),0j)],
- [TE, TE, TE, TE, TE, TE, TE, TE, TE],
- [TE, TE, TE, TE, TE, TE, TE, TE, TE],
- [TE, TE, TE, TE, TE, TE, TE, TE, TE],
- [TE, TE, TE, TE, TE, TE, TE, TE, TE],
- [(1,0), (1L,0L), (0.0,2.0), ((1+0j),0j), TE, TE, TE, TE, (1,0)]
-]
-
-def format_float(value):
- if abs(value) < 0.01:
- return '0.0'
- else:
- return '%.1f' % value
-
-# avoid testing platform fp quirks
-def format_result(value):
- if isinstance(value, complex):
- return '(%s + %sj)' % (format_float(value.real),
- format_float(value.imag))
- elif isinstance(value, float):
- return format_float(value)
- return str(value)
-
-class CoercionTest(unittest.TestCase):
- def test_infix_binops(self):
- for ia, a in enumerate(candidates):
- for ib, b in enumerate(candidates):
- results = infix_results[(ia, ib)]
- for op, res, ires in zip(infix_binops, results[0], results[1]):
- if res is TE:
- self.assertRaises(TypeError, eval,
- 'a %s b' % op, {'a': a, 'b': b})
- else:
- self.assertEqual(format_result(res),
- format_result(eval('a %s b' % op)),
- '%s %s %s == %s failed' % (a, op, b, res))
- try:
- z = copy.copy(a)
- except copy.Error:
- z = a # assume it has no inplace ops
- if ires is TE:
- try:
- exec 'z %s= b' % op
- except TypeError:
- pass
- else:
- self.fail("TypeError not raised")
- else:
- exec('z %s= b' % op)
- self.assertEqual(ires, z)
-
- def test_prefix_binops(self):
- for ia, a in enumerate(candidates):
- for ib, b in enumerate(candidates):
- for op in prefix_binops:
- res = prefix_results[ia][ib]
- if res is TE:
- self.assertRaises(TypeError, eval,
- '%s(a, b)' % op, {'a': a, 'b': b})
- else:
- self.assertEqual(format_result(res),
- format_result(eval('%s(a, b)' % op)),
- '%s(%s, %s) == %s failed' % (op, a, b, res))
-
- def test_cmptypes(self):
- # Built-in tp_compare slots expect their arguments to have the
- # same type, but a user-defined __coerce__ doesn't have to obey.
- # SF #980352
- evil_coercer = CoerceTo(42)
- # Make sure these don't crash any more
- self.assertNotEqual(cmp(u'fish', evil_coercer), 0)
- self.assertNotEqual(cmp(slice(1), evil_coercer), 0)
- # ...but that this still works
- class WackyComparer(object):
- def __cmp__(slf, other):
- self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other)
- return 0
- __hash__ = None # Invalid cmp makes this unhashable
- self.assertEqual(cmp(WackyComparer(), evil_coercer), 0)
- # ...and classic classes too, since that code path is a little different
- class ClassicWackyComparer:
- def __cmp__(slf, other):
- self.assertTrue(other == 42, 'expected evil_coercer, got %r' % other)
- return 0
- self.assertEqual(cmp(ClassicWackyComparer(), evil_coercer), 0)
-
- def test_infinite_rec_classic_classes(self):
- # if __coerce__() returns its arguments reversed it causes an infinite
- # recursion for classic classes.
- class Tester:
- def __coerce__(self, other):
- return other, self
-
- exc = TestFailed("__coerce__() returning its arguments reverse "
- "should raise RuntimeError")
- try:
- Tester() + 1
- except (RuntimeError, TypeError):
- return
- except:
- raise exc
- else:
- raise exc
-
-def test_main():
- with check_warnings(("complex divmod.., // and % are deprecated",
- DeprecationWarning),
- ("classic (int|long) division", DeprecationWarning),
- quiet=True):
- run_unittest(CoercionTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 313f81ff656..b2a5f052604 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -1,19 +1,121 @@
+"""Unit tests for collections.py."""
import unittest, doctest, operator
import inspect
-from test import test_support
-from collections import namedtuple, Counter, OrderedDict
+from test import support
+from collections import namedtuple, Counter, OrderedDict, _count_elements
from test import mapping_tests
-import pickle, cPickle, copy
+import pickle, copy
from random import randrange, shuffle
import keyword
import re
import sys
+from collections import _ChainMap
from collections import Hashable, Iterable, Iterator
from collections import Sized, Container, Callable
from collections import Set, MutableSet
-from collections import Mapping, MutableMapping
+from collections import Mapping, MutableMapping, KeysView, ItemsView, UserDict
from collections import Sequence, MutableSequence
+from collections import ByteString
+
+
+################################################################################
+### _ChainMap (helper class for configparser)
+################################################################################
+
+ChainMap = _ChainMap # rename to keep test code in sync with 3.3 version
+
+class TestChainMap(unittest.TestCase):
+
+ def test_basics(self):
+ c = ChainMap()
+ c['a'] = 1
+ c['b'] = 2
+ d = c.new_child()
+ d['b'] = 20
+ d['c'] = 30
+ self.assertEqual(d.maps, [{'b':20, 'c':30}, {'a':1, 'b':2}]) # check internal state
+ self.assertEqual(d.items(), dict(a=1, b=20, c=30).items()) # check items/iter/getitem
+ self.assertEqual(len(d), 3) # check len
+ for key in 'abc': # check contains
+ self.assertIn(key, d)
+ for k, v in dict(a=1, b=20, c=30, z=100).items(): # check get
+ self.assertEqual(d.get(k, 100), v)
+
+ del d['b'] # unmask a value
+ self.assertEqual(d.maps, [{'c':30}, {'a':1, 'b':2}]) # check internal state
+ self.assertEqual(d.items(), dict(a=1, b=2, c=30).items()) # check items/iter/getitem
+ self.assertEqual(len(d), 3) # check len
+ for key in 'abc': # check contains
+ self.assertIn(key, d)
+ for k, v in dict(a=1, b=2, c=30, z=100).items(): # check get
+ self.assertEqual(d.get(k, 100), v)
+ self.assertIn(repr(d), [ # check repr
+ type(d).__name__ + "({'c': 30}, {'a': 1, 'b': 2})",
+ type(d).__name__ + "({'c': 30}, {'b': 2, 'a': 1})"
+ ])
+
+ for e in d.copy(), copy.copy(d): # check shallow copies
+ self.assertEqual(d, e)
+ self.assertEqual(d.maps, e.maps)
+ self.assertIsNot(d, e)
+ self.assertIsNot(d.maps[0], e.maps[0])
+ for m1, m2 in zip(d.maps[1:], e.maps[1:]):
+ self.assertIs(m1, m2)
+
+ for e in [pickle.loads(pickle.dumps(d)),
+ copy.deepcopy(d),
+ eval(repr(d))
+ ]: # check deep copies
+ self.assertEqual(d, e)
+ self.assertEqual(d.maps, e.maps)
+ self.assertIsNot(d, e)
+ for m1, m2 in zip(d.maps, e.maps):
+ self.assertIsNot(m1, m2, e)
+
+ f = d.new_child()
+ f['b'] = 5
+ self.assertEqual(f.maps, [{'b': 5}, {'c':30}, {'a':1, 'b':2}])
+ self.assertEqual(f.parents.maps, [{'c':30}, {'a':1, 'b':2}]) # check parents
+ self.assertEqual(f['b'], 5) # find first in chain
+ self.assertEqual(f.parents['b'], 2) # look beyond maps[0]
+
+ def test_contructor(self):
+ self.assertEqual(ChainMap().maps, [{}]) # no-args --> one new dict
+ self.assertEqual(ChainMap({1:2}).maps, [{1:2}]) # 1 arg --> list
+
+ def test_bool(self):
+ self.assertFalse(ChainMap())
+ self.assertFalse(ChainMap({}, {}))
+ self.assertTrue(ChainMap({1:2}, {}))
+ self.assertTrue(ChainMap({}, {1:2}))
+
+ def test_missing(self):
+ class DefaultChainMap(ChainMap):
+ def __missing__(self, key):
+ return 999
+ d = DefaultChainMap(dict(a=1, b=2), dict(b=20, c=30))
+ for k, v in dict(a=1, b=2, c=30, d=999).items():
+ self.assertEqual(d[k], v) # check __getitem__ w/missing
+ for k, v in dict(a=1, b=2, c=30, d=77).items():
+ self.assertEqual(d.get(k, 77), v) # check get() w/ missing
+ for k, v in dict(a=True, b=True, c=True, d=False).items():
+ self.assertEqual(k in d, v) # check __contains__ w/missing
+ self.assertEqual(d.pop('a', 1001), 1, d)
+ self.assertEqual(d.pop('a', 1002), 1002) # check pop() w/missing
+ self.assertEqual(d.popitem(), ('b', 2)) # check popitem() w/missing
+ with self.assertRaises(KeyError):
+ d.popitem()
+
+ def test_dict_coercion(self):
+ d = ChainMap(dict(a=1, b=2), dict(b=20, c=30))
+ self.assertEqual(dict(d), dict(a=1, b=2, c=30))
+ self.assertEqual(dict(d.items()), dict(a=1, b=2, c=30))
+
+
+################################################################################
+### Named Tuples
+################################################################################
TestNT = namedtuple('TestNT', 'x y z') # type used for pickle tests
@@ -40,9 +142,9 @@ class TestNamedTuple(unittest.TestCase):
namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names
namedtuple('_', 'a b c') # Test leading underscores in a typename
- nt = namedtuple('nt', u'the quick brown fox') # check unicode input
+ nt = namedtuple('nt', 'the quick brown fox') # check unicode input
self.assertNotIn("u'", repr(nt._fields))
- nt = namedtuple('nt', (u'the', u'quick')) # check unicode input
+ nt = namedtuple('nt', ('the', 'quick')) # check unicode input
self.assertNotIn("u'", repr(nt._fields))
self.assertRaises(TypeError, Point._make, [11]) # catch too few args
@@ -138,7 +240,8 @@ class TestNamedTuple(unittest.TestCase):
self.assertEqual(Dot(1)._replace(d=999), (999,))
self.assertEqual(Dot(1)._fields, ('d',))
- n = 5000
+ # n = 5000
+ n = 254 # SyntaxError: more than 255 arguments:
import string, random
names = list(set(''.join([random.choice(string.ascii_letters)
for j in range(10)]) for i in range(n)))
@@ -154,7 +257,7 @@ class TestNamedTuple(unittest.TestCase):
d_expected = dict(zip(names, range(n)))
self.assertEqual(d, d_expected)
b2 = b._replace(**dict([(names[1], 999),(names[-5], 42)]))
- b2_expected = range(n)
+ b2_expected = list(range(n))
b2_expected[1] = 999
b2_expected[-5] = 42
self.assertEqual(b2, tuple(b2_expected))
@@ -162,7 +265,7 @@ class TestNamedTuple(unittest.TestCase):
def test_pickle(self):
p = TestNT(x=10, y=20, z=30)
- for module in pickle, cPickle:
+ for module in (pickle,):
loads = getattr(module, 'loads')
dumps = getattr(module, 'dumps')
for protocol in -1, 0, 1, 2:
@@ -187,7 +290,7 @@ class TestNamedTuple(unittest.TestCase):
self.assertEqual(newt, (10,20,30,40,50))
# Broader test of all interesting names in a template
- with test_support.captured_stdout() as template:
+ with support.captured_stdout() as template:
T = namedtuple('T', 'x', verbose=True)
words = set(re.findall('[A-Za-z]+', template.getvalue()))
words -= set(keyword.kwlist)
@@ -215,6 +318,20 @@ class TestNamedTuple(unittest.TestCase):
# test __getnewargs__
self.assertEqual(t.__getnewargs__(), values)
+ def test_repr(self):
+ with support.captured_stdout() as template:
+ A = namedtuple('A', 'x', verbose=True)
+ self.assertEqual(repr(A(1)), 'A(x=1)')
+ # repr should show the name of the subclass
+ class B(A):
+ pass
+ self.assertEqual(repr(B(1)), 'B(x=1)')
+
+
+################################################################################
+### Abstract Base Classes
+################################################################################
+
class ABCTestCase(unittest.TestCase):
def validate_abstract_methods(self, abc, *names):
@@ -234,24 +351,14 @@ class ABCTestCase(unittest.TestCase):
def validate_isinstance(self, abc, name):
stub = lambda s, *args: 0
- # new-style class
- C = type('C', (object,), {name: stub})
- self.assertIsInstance(C(), abc)
- self.assertTrue(issubclass(C, abc))
- # old-style class
- class C: pass
+ C = type('C', (object,), {'__hash__': None})
setattr(C, name, stub)
self.assertIsInstance(C(), abc)
self.assertTrue(issubclass(C, abc))
- # new-style class
C = type('C', (object,), {'__hash__': None})
self.assertNotIsInstance(C(), abc)
self.assertFalse(issubclass(C, abc))
- # old-style class
- class C: pass
- self.assertNotIsInstance(C(), abc)
- self.assertFalse(issubclass(C, abc))
def validate_comparison(self, instance):
ops = ['lt', 'gt', 'le', 'ge', 'ne', 'or', 'and', 'xor', 'sub']
@@ -288,7 +395,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
def test_Hashable(self):
# Check some non-hashables
- non_samples = [list(), set(), dict()]
+ non_samples = [bytearray(), list(), set(), dict()]
for x in non_samples:
self.assertNotIsInstance(x, Hashable)
self.assertFalse(issubclass(type(x), Hashable), repr(type(x)))
@@ -297,7 +404,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
int(), float(), complex(),
str(),
tuple(), frozenset(),
- int, list, object, type,
+ int, list, object, type, bytes()
]
for x in samples:
self.assertIsInstance(x, Hashable)
@@ -306,8 +413,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
# Check direct subclassing
class H(Hashable):
def __hash__(self):
- return super(H, self).__hash__()
- __eq__ = Hashable.__eq__ # Silence Py3k warning
+ return super().__hash__()
self.assertEqual(hash(H()), 0)
self.assertFalse(issubclass(int, H))
self.validate_abstract_methods(Hashable, '__hash__')
@@ -320,7 +426,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
self.assertNotIsInstance(x, Iterable)
self.assertFalse(issubclass(type(x), Iterable), repr(type(x)))
# Check some iterables
- samples = [str(),
+ samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(), dict().values(),
(lambda: (yield))(),
@@ -332,19 +438,18 @@ class TestOneTrickPonyABCs(ABCTestCase):
# Check direct subclassing
class I(Iterable):
def __iter__(self):
- return super(I, self).__iter__()
+ return super().__iter__()
self.assertEqual(list(I()), [])
self.assertFalse(issubclass(str, I))
self.validate_abstract_methods(Iterable, '__iter__')
self.validate_isinstance(Iterable, '__iter__')
def test_Iterator(self):
- non_samples = [None, 42, 3.14, 1j, "".encode('ascii'), "", (), [],
- {}, set()]
+ non_samples = [None, 42, 3.14, 1j, b"", "", (), [], {}, set()]
for x in non_samples:
self.assertNotIsInstance(x, Iterator)
self.assertFalse(issubclass(type(x), Iterator), repr(type(x)))
- samples = [iter(str()),
+ samples = [iter(bytes()), iter(str()),
iter(tuple()), iter(list()), iter(dict()),
iter(set()), iter(frozenset()),
iter(dict().keys()), iter(dict().items()),
@@ -355,7 +460,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
for x in samples:
self.assertIsInstance(x, Iterator)
self.assertTrue(issubclass(type(x), Iterator), repr(type(x)))
- self.validate_abstract_methods(Iterator, 'next', '__iter__')
+ self.validate_abstract_methods(Iterator, '__next__', '__iter__')
# Issue 10565
class NextOnly:
@@ -363,11 +468,6 @@ class TestOneTrickPonyABCs(ABCTestCase):
yield 1
raise StopIteration
self.assertNotIsInstance(NextOnly(), Iterator)
- class NextOnlyNew(object):
- def __next__(self):
- yield 1
- raise StopIteration
- self.assertNotIsInstance(NextOnlyNew(), Iterator)
def test_Sized(self):
non_samples = [None, 42, 3.14, 1j,
@@ -377,7 +477,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
for x in non_samples:
self.assertNotIsInstance(x, Sized)
self.assertFalse(issubclass(type(x), Sized), repr(type(x)))
- samples = [str(),
+ samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(), dict().values(),
]
@@ -395,7 +495,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
for x in non_samples:
self.assertNotIsInstance(x, Container)
self.assertFalse(issubclass(type(x), Container), repr(type(x)))
- samples = [str(),
+ samples = [bytes(), str(),
tuple(), list(), set(), frozenset(), dict(),
dict().keys(), dict().items(),
]
@@ -407,7 +507,7 @@ class TestOneTrickPonyABCs(ABCTestCase):
def test_Callable(self):
non_samples = [None, 42, 3.14, 1j,
- "", "".encode('ascii'), (), [], {}, set(),
+ "", b"", (), [], {}, set(),
(lambda: (yield))(),
(x for x in []),
]
@@ -435,7 +535,6 @@ class TestOneTrickPonyABCs(ABCTestCase):
def test_registration(self):
for B in Hashable, Iterable, Iterator, Sized, Container, Callable:
class C:
- __metaclass__ = type
__hash__ = None # Make sure it isn't hashable by default
self.assertFalse(issubclass(C, B), B.__name__)
B.register(C)
@@ -512,7 +611,7 @@ class TestCollectionABCs(ABCTestCase):
def test_issue_4920(self):
# MutableSet.pop() method did not work
- class MySet(collections.MutableSet):
+ class MySet(MutableSet):
__slots__=['__s']
def __init__(self,items=None):
if items is None:
@@ -552,13 +651,46 @@ class TestCollectionABCs(ABCTestCase):
s |= s
self.assertEqual(s, full)
+ def test_issue16373(self):
+ # Recursion error comparing comparable and noncomparable
+ # Set instances
+ class MyComparableSet(Set):
+ def __contains__(self, x):
+ return False
+ def __len__(self):
+ return 0
+ def __iter__(self):
+ return iter([])
+ class MyNonComparableSet(Set):
+ def __contains__(self, x):
+ return False
+ def __len__(self):
+ return 0
+ def __iter__(self):
+ return iter([])
+ def __le__(self, x):
+ return NotImplemented
+ def __lt__(self, x):
+ return NotImplemented
+
+ cs = MyComparableSet()
+ ncs = MyNonComparableSet()
+ with self.assertRaises(TypeError):
+ ncs < cs
+ with self.assertRaises(TypeError):
+ ncs <= cs
+ with self.assertRaises(TypeError):
+ cs > ncs
+ with self.assertRaises(TypeError):
+ cs >= ncs
+
def test_Mapping(self):
for sample in [dict]:
self.assertIsInstance(sample(), Mapping)
self.assertTrue(issubclass(sample, Mapping))
self.validate_abstract_methods(Mapping, '__contains__', '__iter__', '__len__',
'__getitem__')
- class MyMapping(collections.Mapping):
+ class MyMapping(Mapping):
def __len__(self):
return 0
def __getitem__(self, i):
@@ -574,28 +706,67 @@ class TestCollectionABCs(ABCTestCase):
self.validate_abstract_methods(MutableMapping, '__contains__', '__iter__', '__len__',
'__getitem__', '__setitem__', '__delitem__')
+ def test_MutableMapping_subclass(self):
+ # Test issue 9214
+ mymap = UserDict()
+ mymap['red'] = 5
+ self.assertIsInstance(mymap.keys(), Set)
+ self.assertIsInstance(mymap.keys(), KeysView)
+ self.assertIsInstance(mymap.items(), Set)
+ self.assertIsInstance(mymap.items(), ItemsView)
+
+ mymap = UserDict()
+ mymap['red'] = 5
+ z = mymap.keys() | {'orange'}
+ self.assertIsInstance(z, set)
+ list(z)
+ mymap['blue'] = 7 # Shouldn't affect 'z'
+ self.assertEqual(sorted(z), ['orange', 'red'])
+
+ mymap = UserDict()
+ mymap['red'] = 5
+ z = mymap.items() | {('orange', 3)}
+ self.assertIsInstance(z, set)
+ list(z)
+ mymap['blue'] = 7 # Shouldn't affect 'z'
+ self.assertEqual(sorted(z), [('orange', 3), ('red', 5)])
+
def test_Sequence(self):
- for sample in [tuple, list, str]:
+ for sample in [tuple, list, bytes, str]:
self.assertIsInstance(sample(), Sequence)
self.assertTrue(issubclass(sample, Sequence))
- self.assertTrue(issubclass(basestring, Sequence))
self.assertIsInstance(range(10), Sequence)
- self.assertTrue(issubclass(xrange, Sequence))
+ self.assertTrue(issubclass(range, Sequence))
self.assertTrue(issubclass(str, Sequence))
self.validate_abstract_methods(Sequence, '__contains__', '__iter__', '__len__',
'__getitem__')
+ def test_ByteString(self):
+ for sample in [bytes, bytearray]:
+ self.assertIsInstance(sample(), ByteString)
+ self.assertTrue(issubclass(sample, ByteString))
+ for sample in [str, list, tuple]:
+ self.assertNotIsInstance(sample(), ByteString)
+ self.assertFalse(issubclass(sample, ByteString))
+ self.assertNotIsInstance(memoryview(b""), ByteString)
+ self.assertFalse(issubclass(memoryview, ByteString))
+
def test_MutableSequence(self):
- for sample in [tuple, str]:
+ for sample in [tuple, str, bytes]:
self.assertNotIsInstance(sample(), MutableSequence)
self.assertFalse(issubclass(sample, MutableSequence))
- for sample in [list]:
+ for sample in [list, bytearray]:
self.assertIsInstance(sample(), MutableSequence)
self.assertTrue(issubclass(sample, MutableSequence))
- self.assertFalse(issubclass(basestring, MutableSequence))
+ self.assertFalse(issubclass(str, MutableSequence))
self.validate_abstract_methods(MutableSequence, '__contains__', '__iter__',
'__len__', '__getitem__', '__setitem__', '__delitem__', 'insert')
+
+################################################################################
+### Counter
+################################################################################
+
class TestCounter(unittest.TestCase):
def test_basics(self):
@@ -615,9 +786,6 @@ class TestCounter(unittest.TestCase):
[('a', 3), ('b', 2), ('c', 1)])
self.assertEqual(c['b'], 2)
self.assertEqual(c['z'], 0)
- with test_support.check_py3k_warnings():
- self.assertEqual(c.has_key('c'), True)
- self.assertEqual(c.has_key('z'), False)
self.assertEqual(c.__contains__('c'), True)
self.assertEqual(c.__contains__('z'), False)
self.assertEqual(c.get('b', 10), 2)
@@ -675,10 +843,6 @@ class TestCounter(unittest.TestCase):
pickle.loads(pickle.dumps(words, 1)),
pickle.loads(pickle.dumps(words, 2)),
pickle.loads(pickle.dumps(words, -1)),
- cPickle.loads(cPickle.dumps(words, 0)),
- cPickle.loads(cPickle.dumps(words, 1)),
- cPickle.loads(cPickle.dumps(words, 2)),
- cPickle.loads(cPickle.dumps(words, -1)),
eval(repr(words)),
update_test,
Counter(words),
@@ -762,6 +926,30 @@ class TestCounter(unittest.TestCase):
c.subtract('aaaabbcce')
self.assertEqual(c, Counter(a=-1, b=0, c=-1, d=1, e=-1))
+ def test_repr_nonsortable(self):
+ c = Counter(a=2, b=None)
+ r = repr(c)
+ self.assertIn("'a': 2", r)
+ self.assertIn("'b': None", r)
+
+ def test_helper_function(self):
+ # two paths, one for real dicts and one for other mappings
+ elems = list('abracadabra')
+
+ d = dict()
+ _count_elements(d, elems)
+ self.assertEqual(d, {'a': 5, 'r': 2, 'b': 2, 'c': 1, 'd': 1})
+
+ m = OrderedDict()
+ _count_elements(m, elems)
+ self.assertEqual(m,
+ OrderedDict([('a', 5), ('b', 2), ('r', 2), ('c', 1), ('d', 1)]))
+
+
+################################################################################
+### OrderedDict
+################################################################################
+
class TestOrderedDict(unittest.TestCase):
def test_init(self):
@@ -854,12 +1042,9 @@ class TestOrderedDict(unittest.TestCase):
shuffle(pairs)
od = OrderedDict(pairs)
self.assertEqual(list(od), [t[0] for t in pairs])
- self.assertEqual(od.keys()[:], [t[0] for t in pairs])
- self.assertEqual(od.values()[:], [t[1] for t in pairs])
- self.assertEqual(od.items()[:], pairs)
- self.assertEqual(list(od.iterkeys()), [t[0] for t in pairs])
- self.assertEqual(list(od.itervalues()), [t[1] for t in pairs])
- self.assertEqual(list(od.iteritems()), pairs)
+ self.assertEqual(list(od.keys()), [t[0] for t in pairs])
+ self.assertEqual(list(od.values()), [t[1] for t in pairs])
+ self.assertEqual(list(od.items()), pairs)
self.assertEqual(list(reversed(od)),
[t[0] for t in reversed(pairs)])
@@ -926,6 +1111,7 @@ class TestOrderedDict(unittest.TestCase):
pickle.loads(pickle.dumps(od, 0)),
pickle.loads(pickle.dumps(od, 1)),
pickle.loads(pickle.dumps(od, 2)),
+ pickle.loads(pickle.dumps(od, 3)),
pickle.loads(pickle.dumps(od, -1)),
eval(repr(od)),
update_test,
@@ -996,12 +1182,25 @@ class TestOrderedDict(unittest.TestCase):
od['a'] = 1
self.assertEqual(list(od.items()), [('b', 2), ('a', 1)])
- def test_views(self):
- s = 'the quick brown fox jumped over a lazy dog yesterday before dawn'.split()
- od = OrderedDict.fromkeys(s)
- self.assertEqual(list(od.viewkeys()), s)
- self.assertEqual(list(od.viewvalues()), [None for k in s])
- self.assertEqual(list(od.viewitems()), [(k, None) for k in s])
+ def test_move_to_end(self):
+ od = OrderedDict.fromkeys('abcde')
+ self.assertEqual(list(od), list('abcde'))
+ od.move_to_end('c')
+ self.assertEqual(list(od), list('abdec'))
+ od.move_to_end('c', 0)
+ self.assertEqual(list(od), list('cabde'))
+ od.move_to_end('c', 0)
+ self.assertEqual(list(od), list('cabde'))
+ od.move_to_end('e')
+ self.assertEqual(list(od), list('cabde'))
+ with self.assertRaises(KeyError):
+ od.move_to_end('x')
+
+ def test_sizeof(self):
+ # Wimpy test: Just verify the reported size is larger than a regular dict
+ d = dict(a=1)
+ od = OrderedDict(**d)
+ self.assertGreater(sys.getsizeof(od), sys.getsizeof(d))
def test_override_update(self):
# Verify that subclasses can override update() without breaking __init__()
@@ -1028,15 +1227,21 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
d = self._empty_mapping()
self.assertRaises(KeyError, d.popitem)
-import collections
+
+################################################################################
+### Run tests
+################################################################################
+
+import doctest, collections
def test_main(verbose=None):
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,
- TestCollectionABCs, TestCounter,
+ TestCollectionABCs, TestCounter, TestChainMap,
TestOrderedDict, GeneralMappingTests, SubclassMappingTests]
- test_support.run_unittest(*test_classes)
- test_support.run_doctest(collections, verbose)
+ support.run_unittest(*test_classes)
+ support.run_doctest(collections, verbose)
+
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_colorsys.py b/Lib/test/test_colorsys.py
index a8cd885db12..e405b8a4d03 100644
--- a/Lib/test/test_colorsys.py
+++ b/Lib/test/test_colorsys.py
@@ -1,4 +1,4 @@
-import unittest, test.test_support
+import unittest, test.support
import colorsys
def frange(start, stop, step):
@@ -70,7 +70,7 @@ class ColorsysTest(unittest.TestCase):
self.assertTripleEqual(rgb, colorsys.hls_to_rgb(*hls))
def test_main():
- test.test_support.run_unittest(ColorsysTest)
+ test.support.run_unittest(ColorsysTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_commands.py b/Lib/test/test_commands.py
deleted file mode 100644
index 066b1828604..00000000000
--- a/Lib/test/test_commands.py
+++ /dev/null
@@ -1,74 +0,0 @@
-'''
- Tests for commands module
- Nick Mathewson
-'''
-import unittest
-import os, tempfile, re
-
-from test.test_support import run_unittest, reap_children, import_module, \
- check_warnings
-
-# Silence Py3k warning
-commands = import_module('commands', deprecated=True)
-
-# The module says:
-# "NB This only works (and is only relevant) for UNIX."
-#
-# Actually, getoutput should work on any platform with an os.popen, but
-# I'll take the comment as given, and skip this suite.
-
-if os.name != 'posix':
- raise unittest.SkipTest('Not posix; skipping test_commands')
-
-
-class CommandTests(unittest.TestCase):
-
- def test_getoutput(self):
- self.assertEqual(commands.getoutput('echo xyzzy'), 'xyzzy')
- self.assertEqual(commands.getstatusoutput('echo xyzzy'), (0, 'xyzzy'))
-
- # we use mkdtemp in the next line to create an empty directory
- # under our exclusive control; from that, we can invent a pathname
- # that we _know_ won't exist. This is guaranteed to fail.
- dir = None
- try:
- dir = tempfile.mkdtemp()
- name = os.path.join(dir, "foo")
-
- status, output = commands.getstatusoutput('cat ' + name)
- self.assertNotEqual(status, 0)
- finally:
- if dir is not None:
- os.rmdir(dir)
-
- def test_getstatus(self):
- # This pattern should match 'ls -ld /.' on any posix
- # system, however perversely configured. Even on systems
- # (e.g., Cygwin) where user and group names can have spaces:
- # drwxr-xr-x 15 Administ Domain U 4096 Aug 12 12:50 /
- # drwxr-xr-x 15 Joe User My Group 4096 Aug 12 12:50 /
- # Note that the first case above has a space in the group name
- # while the second one has a space in both names.
- # Special attributes supported:
- # + = has ACLs
- # @ = has Mac OS X extended attributes
- # . = has a SELinux security context
- pat = r'''d......... # It is a directory.
- [.+@]? # It may have special attributes.
- \s+\d+ # It has some number of links.
- [^/]* # Skip user, group, size, and date.
- /\. # and end with the name of the file.
- '''
-
- with check_warnings((".*commands.getstatus.. is deprecated",
- DeprecationWarning)):
- self.assertTrue(re.match(pat, commands.getstatus("/."), re.VERBOSE))
-
-
-def test_main():
- run_unittest(CommandTests)
- reap_children()
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_compare.py b/Lib/test/test_compare.py
index 13da80d2d4d..ee3794ae9a3 100644
--- a/Lib/test/test_compare.py
+++ b/Lib/test/test_compare.py
@@ -1,23 +1,10 @@
import unittest
-from test import test_support
+from test import support
class Empty:
def __repr__(self):
return '<Empty>'
-class Coerce:
- def __init__(self, arg):
- self.arg = arg
-
- def __repr__(self):
- return '<Coerce %s>' % self.arg
-
- def __coerce__(self, other):
- if isinstance(other, Coerce):
- return self.arg, other.arg
- else:
- return self.arg, other
-
class Cmp:
def __init__(self,arg):
self.arg = arg
@@ -25,11 +12,18 @@ class Cmp:
def __repr__(self):
return '<Cmp %s>' % self.arg
- def __cmp__(self, other):
- return cmp(self.arg, other)
+ def __eq__(self, other):
+ return self.arg == other
+
+class Anything:
+ def __eq__(self, other):
+ return True
+
+ def __ne__(self, other):
+ return False
class ComparisonTest(unittest.TestCase):
- set1 = [2, 2.0, 2L, 2+0j, Coerce(2), Cmp(2.0)]
+ set1 = [2, 2.0, 2, 2+0j, Cmp(2.0)]
set2 = [[1], (3,), None, Empty()]
candidates = set1 + set2
@@ -48,11 +42,26 @@ class ComparisonTest(unittest.TestCase):
L.insert(len(L)//2, Empty())
for a in L:
for b in L:
- self.assertEqual(cmp(a, b), cmp(id(a), id(b)),
+ self.assertEqual(a == b, id(a) == id(b),
'a=%r, b=%r' % (a, b))
+ def test_ne_defaults_to_not_eq(self):
+ a = Cmp(1)
+ b = Cmp(1)
+ self.assertTrue(a == b)
+ self.assertFalse(a != b)
+
+ def test_issue_1393(self):
+ x = lambda: None
+ self.assertEqual(x, Anything())
+ self.assertEqual(Anything(), x)
+ y = object()
+ self.assertEqual(y, Anything())
+ self.assertEqual(Anything(), y)
+
+
def test_main():
- test_support.run_unittest(ComparisonTest)
+ support.run_unittest(ComparisonTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 4bcb4384085..58ef2979a05 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -1,8 +1,7 @@
import unittest
import sys
import _ast
-from test import test_support
-import textwrap
+from test import support
class TestSpecifics(unittest.TestCase):
@@ -22,31 +21,19 @@ class TestSpecifics(unittest.TestCase):
def test_debug_assignment(self):
# catch assignments to __debug__
self.assertRaises(SyntaxError, compile, '__debug__ = 1', '?', 'single')
- import __builtin__
- prev = __builtin__.__debug__
- setattr(__builtin__, '__debug__', 'sure')
- setattr(__builtin__, '__debug__', prev)
+ import builtins
+ prev = builtins.__debug__
+ setattr(builtins, '__debug__', 'sure')
+ setattr(builtins, '__debug__', prev)
def test_argument_handling(self):
# detect duplicate positional and keyword arguments
self.assertRaises(SyntaxError, eval, 'lambda a,a:0')
self.assertRaises(SyntaxError, eval, 'lambda a,a=1:0')
self.assertRaises(SyntaxError, eval, 'lambda a=1,a=1:0')
- try:
- exec 'def f(a, a): pass'
- self.fail("duplicate arguments")
- except SyntaxError:
- pass
- try:
- exec 'def f(a = 0, a = 1): pass'
- self.fail("duplicate keyword arguments")
- except SyntaxError:
- pass
- try:
- exec 'def f(a): global a; a = 1'
- self.fail("variable is global and local")
- except SyntaxError:
- pass
+ self.assertRaises(SyntaxError, exec, 'def f(a, a): pass')
+ self.assertRaises(SyntaxError, exec, 'def f(a = 0, a = 1): pass')
+ self.assertRaises(SyntaxError, exec, 'def f(a): global a; a = 1')
def test_syntax_error(self):
self.assertRaises(SyntaxError, compile, "1+*3", "filename", "exec")
@@ -55,39 +42,7 @@ class TestSpecifics(unittest.TestCase):
self.assertRaises(SyntaxError, compile, "f(None=1)", "<string>", "exec")
def test_duplicate_global_local(self):
- try:
- exec 'def f(a): global a; a = 1'
- self.fail("variable is global and local")
- except SyntaxError:
- pass
-
- def test_exec_functional_style(self):
- # Exec'ing a tuple of length 2 works.
- g = {'b': 2}
- exec("a = b + 1", g)
- self.assertEqual(g['a'], 3)
-
- # As does exec'ing a tuple of length 3.
- l = {'b': 3}
- g = {'b': 5, 'c': 7}
- exec("a = b + c", g, l)
- self.assertNotIn('a', g)
- self.assertEqual(l['a'], 10)
-
- # Tuples not of length 2 or 3 are invalid.
- with self.assertRaises(TypeError):
- exec("a = b + 1",)
-
- with self.assertRaises(TypeError):
- exec("a = b + 1", {}, {}, {})
-
- # Can't mix and match the two calling forms.
- g = {'a': 3, 'b': 4}
- l = {}
- with self.assertRaises(TypeError):
- exec("a = b + 1", g) in g
- with self.assertRaises(TypeError):
- exec("a = b + 1", g, l) in g, l
+ self.assertRaises(SyntaxError, exec, 'def f(a): global a; a = 1')
def test_exec_with_general_mapping_for_locals(self):
@@ -104,37 +59,27 @@ class TestSpecifics(unittest.TestCase):
m = M()
g = globals()
- exec 'z = a' in g, m
+ exec('z = a', g, m)
self.assertEqual(m.results, ('z', 12))
try:
- exec 'z = b' in g, m
+ exec('z = b', g, m)
except NameError:
pass
else:
self.fail('Did not detect a KeyError')
- exec 'z = dir()' in g, m
+ exec('z = dir()', g, m)
self.assertEqual(m.results, ('z', list('xyz')))
- exec 'z = globals()' in g, m
+ exec('z = globals()', g, m)
self.assertEqual(m.results, ('z', g))
- exec 'z = locals()' in g, m
+ exec('z = locals()', g, m)
self.assertEqual(m.results, ('z', m))
- try:
- exec 'z = b' in m
- except TypeError:
- pass
- else:
- self.fail('Did not validate globals as a real dict')
+ self.assertRaises(TypeError, exec, 'z = b', m)
class A:
"Non-mapping"
pass
m = A()
- try:
- exec 'z = a' in g, m
- except TypeError:
- pass
- else:
- self.fail('Did not validate locals as a mapping')
+ self.assertRaises(TypeError, exec, 'z = a', g, m)
# Verify that dict subclasses work as well
class D(dict):
@@ -143,11 +88,12 @@ class TestSpecifics(unittest.TestCase):
return 12
return dict.__getitem__(self, key)
d = D()
- exec 'z = a' in g, d
+ exec('z = a', g, d)
self.assertEqual(d['z'], 12)
def test_extended_arg(self):
longexpr = 'x = x or ' + '-x' * 2500
+ g = {}
code = '''
def f(x):
%s
@@ -166,39 +112,11 @@ def f(x):
# EXTENDED_ARG/JUMP_ABSOLUTE here
return x
''' % ((longexpr,)*10)
- exec code
- self.assertEqual(f(5), 0)
-
- def test_complex_args(self):
-
- with test_support.check_py3k_warnings(
- ("tuple parameter unpacking has been removed", SyntaxWarning)):
- exec textwrap.dedent('''
- def comp_args((a, b)):
- return a,b
- self.assertEqual(comp_args((1, 2)), (1, 2))
-
- def comp_args((a, b)=(3, 4)):
- return a, b
- self.assertEqual(comp_args((1, 2)), (1, 2))
- self.assertEqual(comp_args(), (3, 4))
-
- def comp_args(a, (b, c)):
- return a, b, c
- self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3))
-
- def comp_args(a=2, (b, c)=(3, 4)):
- return a, b, c
- self.assertEqual(comp_args(1, (2, 3)), (1, 2, 3))
- self.assertEqual(comp_args(), (2, 3, 4))
- ''')
+ exec(code, g)
+ self.assertEqual(g['f'](5), 0)
def test_argument_order(self):
- try:
- exec 'def f(a=1, (b, c)): pass'
- self.fail("non-default args after default")
- except SyntaxError:
- pass
+ self.assertRaises(SyntaxError, exec, 'def f(a=1, b): pass')
def test_float_literals(self):
# testing bad float literals
@@ -223,29 +141,26 @@ if 1:
s256 = "".join(["\n"] * 256 + ["spam"])
co = compile(s256, 'fn', 'exec')
self.assertEqual(co.co_firstlineno, 257)
- self.assertEqual(co.co_lnotab, '')
+ self.assertEqual(co.co_lnotab, bytes())
def test_literals_with_leading_zeroes(self):
for arg in ["077787", "0xj", "0x.", "0e", "090000000000000",
"080000000000000", "000000000000009", "000000000000008",
"0b42", "0BADCAFE", "0o123456789", "0b1.1", "0o4.2",
- "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0o8", "0o78"]:
+ "0b101j2", "0o153j2", "0b100e1", "0o777e1", "0777",
+ "000777", "000000000000007"]:
self.assertRaises(SyntaxError, eval, arg)
- self.assertEqual(eval("0777"), 511)
- self.assertEqual(eval("0777L"), 511)
- self.assertEqual(eval("000777"), 511)
self.assertEqual(eval("0xff"), 255)
- self.assertEqual(eval("0xffL"), 255)
- self.assertEqual(eval("0XfF"), 255)
self.assertEqual(eval("0777."), 777)
self.assertEqual(eval("0777.0"), 777)
self.assertEqual(eval("000000000000000000000000000000000000000000000000000777e0"), 777)
self.assertEqual(eval("0777e1"), 7770)
self.assertEqual(eval("0e0"), 0)
- self.assertEqual(eval("0000E-012"), 0)
+ self.assertEqual(eval("0000e-012"), 0)
self.assertEqual(eval("09.5"), 9.5)
self.assertEqual(eval("0777j"), 777j)
+ self.assertEqual(eval("000"), 0)
self.assertEqual(eval("00j"), 0j)
self.assertEqual(eval("00.0"), 0)
self.assertEqual(eval("0e3"), 0)
@@ -254,38 +169,33 @@ if 1:
self.assertEqual(eval("090000000000000e0"), 90000000000000.)
self.assertEqual(eval("090000000000000e-0"), 90000000000000.)
self.assertEqual(eval("090000000000000j"), 90000000000000j)
- self.assertEqual(eval("000000000000007"), 7)
self.assertEqual(eval("000000000000008."), 8.)
self.assertEqual(eval("000000000000009."), 9.)
self.assertEqual(eval("0b101010"), 42)
self.assertEqual(eval("-0b000000000010"), -2)
self.assertEqual(eval("0o777"), 511)
self.assertEqual(eval("-0o0000010"), -8)
- self.assertEqual(eval("020000000000.0"), 20000000000.0)
- self.assertEqual(eval("037777777777e0"), 37777777777.0)
- self.assertEqual(eval("01000000000000000000000.0"),
- 1000000000000000000000.0)
def test_unary_minus(self):
# Verify treatment of unary minus on negative numbers SF bug #660455
- if sys.maxint == 2147483647:
+ if sys.maxsize == 2147483647:
# 32-bit machine
all_one_bits = '0xffffffff'
- self.assertEqual(eval(all_one_bits), 4294967295L)
- self.assertEqual(eval("-" + all_one_bits), -4294967295L)
- elif sys.maxint == 9223372036854775807:
+ self.assertEqual(eval(all_one_bits), 4294967295)
+ self.assertEqual(eval("-" + all_one_bits), -4294967295)
+ elif sys.maxsize == 9223372036854775807:
# 64-bit machine
all_one_bits = '0xffffffffffffffff'
- self.assertEqual(eval(all_one_bits), 18446744073709551615L)
- self.assertEqual(eval("-" + all_one_bits), -18446744073709551615L)
+ self.assertEqual(eval(all_one_bits), 18446744073709551615)
+ self.assertEqual(eval("-" + all_one_bits), -18446744073709551615)
else:
self.fail("How many bits *does* this machine have???")
- # Verify treatment of constant folding on -(sys.maxint+1)
+ # Verify treatment of constant folding on -(sys.maxsize+1)
# i.e. -2147483648 on 32 bit platforms. Should return int, not long.
- self.assertIsInstance(eval("%s" % (-sys.maxint - 1)), int)
- self.assertIsInstance(eval("%s" % (-sys.maxint - 2)), long)
+ self.assertIsInstance(eval("%s" % (-sys.maxsize - 1)), int)
+ self.assertIsInstance(eval("%s" % (-sys.maxsize - 2)), int)
- if sys.maxint == 9223372036854775807:
+ if sys.maxsize == 9223372036854775807:
def test_32_63_bit_values(self):
a = +4294967296 # 1 << 32
b = -4294967296 # 1 << 32
@@ -296,7 +206,7 @@ if 1:
g = +9223372036854775807 # 1 << 63 - 1
h = -9223372036854775807 # 1 << 63 - 1
- for variable in self.test_32_63_bit_values.func_code.co_consts:
+ for variable in self.test_32_63_bit_values.__code__.co_consts:
if variable is not None:
self.assertIsInstance(variable, int)
@@ -325,10 +235,6 @@ if 1:
stmt += "\n"
self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'single')
self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'exec')
- # This is ok.
- compile("from None import x", "tmp", "exec")
- compile("from x import None as y", "tmp", "exec")
- compile("import None as x", "tmp", "exec")
def test_import(self):
succeed = [
@@ -384,15 +290,15 @@ if 1:
f2 = lambda x=2: x
return f1, f2
f1, f2 = f()
- self.assertNotEqual(id(f1.func_code), id(f2.func_code))
+ self.assertNotEqual(id(f1.__code__), id(f2.__code__))
def test_lambda_doc(self):
l = lambda: "foo"
self.assertIsNone(l.__doc__)
- def test_unicode_encoding(self):
- code = u"# -*- coding: utf-8 -*-\npass\n"
- self.assertRaises(SyntaxError, compile, code, "tmp", "exec")
+## def test_unicode_encoding(self):
+## code = "# -*- coding: utf-8 -*-\npass\n"
+## self.assertRaises(SyntaxError, compile, code, "tmp", "exec")
def test_subscripts(self):
# SF bug 1448804
@@ -466,6 +372,19 @@ if 1:
del d[..., ...]
self.assertNotIn((Ellipsis, Ellipsis), d)
+ def test_annotation_limit(self):
+ # 16 bits are available for # of annotations, but only 8 bits are
+ # available for the parameter count, hence 255
+ # is the max. Ensure the result of too many annotations is a
+ # SyntaxError.
+ s = "def f(%s): pass"
+ s %= ', '.join('a%d:%d' % (i,i) for i in range(256))
+ self.assertRaises(SyntaxError, compile, s, '?', 'exec')
+ # Test that the max # of annotations compiles.
+ s = "def f(%s): pass"
+ s %= ', '.join('a%d:%d' % (i,i) for i in range(255))
+ compile(s, '?', 'exec')
+
def test_mangling(self):
class A:
def f():
@@ -474,10 +393,10 @@ if 1:
import __mangled_mod
import __package__.module
- self.assertIn("_A__mangled", A.f.func_code.co_varnames)
- self.assertIn("__not_mangled__", A.f.func_code.co_varnames)
- self.assertIn("_A__mangled_mod", A.f.func_code.co_varnames)
- self.assertIn("__package__", A.f.func_code.co_varnames)
+ self.assertIn("_A__mangled", A.f.__code__.co_varnames)
+ self.assertIn("__not_mangled__", A.f.__code__.co_varnames)
+ self.assertIn("_A__mangled_mod", A.f.__code__.co_varnames)
+ self.assertIn("__package__", A.f.__code__.co_varnames)
def test_compile_ast(self):
fname = __file__
@@ -487,12 +406,8 @@ if 1:
fcontents = f.read()
sample_code = [
['<assign>', 'x = 5'],
- ['<print1>', 'print 1'],
- ['<printv>', 'print v'],
- ['<printTrue>', 'print True'],
- ['<printList>', 'print []'],
['<ifblock>', """if True:\n pass\n"""],
- ['<forblock>', """for n in [1, 2, 3]:\n print n\n"""],
+ ['<forblock>', """for n in [1, 2, 3]:\n print(n)\n"""],
['<deffunc>', """def foo():\n pass\nfoo()\n"""],
[fname, fcontents],
]
@@ -507,7 +422,7 @@ if 1:
self.assertEqual(co2.co_filename, '%s3' % fname)
# raise exception when node type doesn't match with compile mode
- co1 = compile('print 1', '<string>', 'exec', _ast.PyCF_ONLY_AST)
+ co1 = compile('print(1)', '<string>', 'exec', _ast.PyCF_ONLY_AST)
self.assertRaises(TypeError, compile, co1, '<ast>', 'eval')
# raise exception when node type is no start node
@@ -520,7 +435,7 @@ if 1:
def test_main():
- test_support.run_unittest(TestSpecifics)
+ support.run_unittest(TestSpecifics)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index bff69893ce8..ba9fe465f83 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -1,25 +1,33 @@
+import sys
import compileall
import imp
import os
import py_compile
import shutil
import struct
+import subprocess
import tempfile
-from test import test_support
+import time
import unittest
+import io
+from test import support, script_helper
class CompileallTests(unittest.TestCase):
def setUp(self):
self.directory = tempfile.mkdtemp()
self.source_path = os.path.join(self.directory, '_test.py')
- self.bc_path = self.source_path + ('c' if __debug__ else 'o')
+ self.bc_path = imp.cache_from_source(self.source_path)
with open(self.source_path, 'w') as file:
file.write('x = 123\n')
self.source_path2 = os.path.join(self.directory, '_test2.py')
- self.bc_path2 = self.source_path2 + ('c' if __debug__ else 'o')
+ self.bc_path2 = imp.cache_from_source(self.source_path2)
shutil.copyfile(self.source_path, self.source_path2)
+ self.subdirectory = os.path.join(self.directory, '_subdir')
+ os.mkdir(self.subdirectory)
+ self.source_path3 = os.path.join(self.subdirectory, '_test3.py')
+ shutil.copyfile(self.source_path, self.source_path3)
def tearDown(self):
shutil.rmtree(self.directory)
@@ -63,17 +71,297 @@ class CompileallTests(unittest.TestCase):
except:
pass
compileall.compile_file(self.source_path, force=False, quiet=True)
- self.assertTrue(os.path.isfile(self.bc_path) \
- and not os.path.isfile(self.bc_path2))
+ self.assertTrue(os.path.isfile(self.bc_path) and
+ not os.path.isfile(self.bc_path2))
os.unlink(self.bc_path)
compileall.compile_dir(self.directory, force=False, quiet=True)
- self.assertTrue(os.path.isfile(self.bc_path) \
- and os.path.isfile(self.bc_path2))
+ self.assertTrue(os.path.isfile(self.bc_path) and
+ os.path.isfile(self.bc_path2))
os.unlink(self.bc_path)
os.unlink(self.bc_path2)
+ def test_no_pycache_in_non_package(self):
+ # Bug 8563 reported that __pycache__ directories got created by
+ # compile_file() for non-.py files.
+ data_dir = os.path.join(self.directory, 'data')
+ data_file = os.path.join(data_dir, 'file')
+ os.mkdir(data_dir)
+ # touch data/file
+ with open(data_file, 'w'):
+ pass
+ compileall.compile_file(data_file)
+ self.assertFalse(os.path.exists(os.path.join(data_dir, '__pycache__')))
+
+ def test_optimize(self):
+ # make sure compiling with different optimization settings than the
+ # interpreter's creates the correct file names
+ optimize = 1 if __debug__ else 0
+ compileall.compile_dir(self.directory, quiet=True, optimize=optimize)
+ cached = imp.cache_from_source(self.source_path,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached))
+ cached2 = imp.cache_from_source(self.source_path2,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached2))
+ cached3 = imp.cache_from_source(self.source_path3,
+ debug_override=not optimize)
+ self.assertTrue(os.path.isfile(cached3))
+
+
+class EncodingTest(unittest.TestCase):
+ """Issue 6716: compileall should escape source code when printing errors
+ to stdout."""
+
+ def setUp(self):
+ self.directory = tempfile.mkdtemp()
+ self.source_path = os.path.join(self.directory, '_test.py')
+ with open(self.source_path, 'w', encoding='utf-8') as file:
+ file.write('# -*- coding: utf-8 -*-\n')
+ file.write('print u"\u20ac"\n')
+
+ def tearDown(self):
+ shutil.rmtree(self.directory)
+
+ def test_error(self):
+ try:
+ orig_stdout = sys.stdout
+ sys.stdout = io.TextIOWrapper(io.BytesIO(),encoding='ascii')
+ compileall.compile_dir(self.directory)
+ finally:
+ sys.stdout = orig_stdout
+
+
+class CommandLineTests(unittest.TestCase):
+ """Test compileall's CLI."""
+
+ def _get_run_args(self, args):
+ interp_args = ['-S']
+ if sys.flags.optimize:
+ interp_args.append({1 : '-O', 2 : '-OO'}[sys.flags.optimize])
+ return interp_args + ['-m', 'compileall'] + list(args)
+
+ def assertRunOK(self, *args, **env_vars):
+ rc, out, err = script_helper.assert_python_ok(
+ *self._get_run_args(args), **env_vars)
+ self.assertEqual(b'', err)
+ return out
+
+ def assertRunNotOK(self, *args, **env_vars):
+ rc, out, err = script_helper.assert_python_failure(
+ *self._get_run_args(args), **env_vars)
+ return rc, out, err
+
+ def assertCompiled(self, fn):
+ self.assertTrue(os.path.exists(imp.cache_from_source(fn)))
+
+ def assertNotCompiled(self, fn):
+ self.assertFalse(os.path.exists(imp.cache_from_source(fn)))
+
+ def setUp(self):
+ self.addCleanup(self._cleanup)
+ self.directory = tempfile.mkdtemp()
+ self.pkgdir = os.path.join(self.directory, 'foo')
+ os.mkdir(self.pkgdir)
+ self.pkgdir_cachedir = os.path.join(self.pkgdir, '__pycache__')
+ # Create the __init__.py and a package module.
+ self.initfn = script_helper.make_script(self.pkgdir, '__init__', '')
+ self.barfn = script_helper.make_script(self.pkgdir, 'bar', '')
+
+ def _cleanup(self):
+ support.rmtree(self.directory)
+
+ def test_no_args_compiles_path(self):
+ # Note that -l is implied for the no args case.
+ bazfn = script_helper.make_script(self.directory, 'baz', '')
+ self.assertRunOK(PYTHONPATH=self.directory)
+ self.assertCompiled(bazfn)
+ self.assertNotCompiled(self.initfn)
+ self.assertNotCompiled(self.barfn)
+
+ # Ensure that the default behavior of compileall's CLI is to create
+ # PEP 3147 pyc/pyo files.
+ for name, ext, switch in [
+ ('normal', 'pyc', []),
+ ('optimize', 'pyo', ['-O']),
+ ('doubleoptimize', 'pyo', ['-OO']),
+ ]:
+ def f(self, ext=ext, switch=switch):
+ script_helper.assert_python_ok(*(switch +
+ ['-m', 'compileall', '-q', self.pkgdir]))
+ # Verify the __pycache__ directory contents.
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ expected = sorted(base.format(imp.get_tag(), ext) for base in
+ ('__init__.{}.{}', 'bar.{}.{}'))
+ self.assertEqual(sorted(os.listdir(self.pkgdir_cachedir)), expected)
+ # Make sure there are no .pyc files in the source directory.
+ self.assertFalse([fn for fn in os.listdir(self.pkgdir)
+ if fn.endswith(ext)])
+ locals()['test_pep3147_paths_' + name] = f
+
+ def test_legacy_paths(self):
+ # Ensure that with the proper switch, compileall leaves legacy
+ # pyc/pyo files, and no __pycache__ directory.
+ self.assertRunOK('-b', '-q', self.pkgdir)
+ # Verify the __pycache__ directory contents.
+ self.assertFalse(os.path.exists(self.pkgdir_cachedir))
+ opt = 'c' if __debug__ else 'o'
+ expected = sorted(['__init__.py', '__init__.py' + opt, 'bar.py',
+ 'bar.py' + opt])
+ self.assertEqual(sorted(os.listdir(self.pkgdir)), expected)
+
+ def test_multiple_runs(self):
+ # Bug 8527 reported that multiple calls produced empty
+ # __pycache__/__pycache__ directories.
+ self.assertRunOK('-q', self.pkgdir)
+ # Verify the __pycache__ directory contents.
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ cachecachedir = os.path.join(self.pkgdir_cachedir, '__pycache__')
+ self.assertFalse(os.path.exists(cachecachedir))
+ # Call compileall again.
+ self.assertRunOK('-q', self.pkgdir)
+ self.assertTrue(os.path.exists(self.pkgdir_cachedir))
+ self.assertFalse(os.path.exists(cachecachedir))
+
+ def test_force(self):
+ self.assertRunOK('-q', self.pkgdir)
+ pycpath = imp.cache_from_source(self.barfn)
+ # set atime/mtime backward to avoid file timestamp resolution issues
+ os.utime(pycpath, (time.time()-60,)*2)
+ mtime = os.stat(pycpath).st_mtime
+ # without force, no recompilation
+ self.assertRunOK('-q', self.pkgdir)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertEqual(mtime, mtime2)
+ # now force it.
+ self.assertRunOK('-q', '-f', self.pkgdir)
+ mtime2 = os.stat(pycpath).st_mtime
+ self.assertNotEqual(mtime, mtime2)
+
+ def test_recursion_control(self):
+ subpackage = os.path.join(self.pkgdir, 'spam')
+ os.mkdir(subpackage)
+ subinitfn = script_helper.make_script(subpackage, '__init__', '')
+ hamfn = script_helper.make_script(subpackage, 'ham', '')
+ self.assertRunOK('-q', '-l', self.pkgdir)
+ self.assertNotCompiled(subinitfn)
+ self.assertFalse(os.path.exists(os.path.join(subpackage, '__pycache__')))
+ self.assertRunOK('-q', self.pkgdir)
+ self.assertCompiled(subinitfn)
+ self.assertCompiled(hamfn)
+
+ def test_quiet(self):
+ noisy = self.assertRunOK(self.pkgdir)
+ quiet = self.assertRunOK('-q', self.pkgdir)
+ self.assertNotEqual(b'', noisy)
+ self.assertEqual(b'', quiet)
+
+ def test_regexp(self):
+ self.assertRunOK('-q', '-x', r'ba[^\\/]*$', self.pkgdir)
+ self.assertNotCompiled(self.barfn)
+ self.assertCompiled(self.initfn)
+
+ def test_multiple_dirs(self):
+ pkgdir2 = os.path.join(self.directory, 'foo2')
+ os.mkdir(pkgdir2)
+ init2fn = script_helper.make_script(pkgdir2, '__init__', '')
+ bar2fn = script_helper.make_script(pkgdir2, 'bar2', '')
+ self.assertRunOK('-q', self.pkgdir, pkgdir2)
+ self.assertCompiled(self.initfn)
+ self.assertCompiled(self.barfn)
+ self.assertCompiled(init2fn)
+ self.assertCompiled(bar2fn)
+
+ def test_d_takes_exactly_one_dir(self):
+ rc, out, err = self.assertRunNotOK('-d', 'foo')
+ self.assertEqual(out, b'')
+ self.assertRegex(err, b'-d')
+ rc, out, err = self.assertRunNotOK('-d', 'foo', 'bar')
+ self.assertEqual(out, b'')
+ self.assertRegex(err, b'-d')
+
+ def test_d_compile_error(self):
+ script_helper.make_script(self.pkgdir, 'crunchyfrog', 'bad(syntax')
+ rc, out, err = self.assertRunNotOK('-q', '-d', 'dinsdale', self.pkgdir)
+ self.assertRegex(out, b'File "dinsdale')
+
+ def test_d_runtime_error(self):
+ bazfn = script_helper.make_script(self.pkgdir, 'baz', 'raise Exception')
+ self.assertRunOK('-q', '-d', 'dinsdale', self.pkgdir)
+ fn = script_helper.make_script(self.pkgdir, 'bing', 'import baz')
+ pyc = imp.cache_from_source(bazfn)
+ os.rename(pyc, os.path.join(self.pkgdir, 'baz.pyc'))
+ os.remove(bazfn)
+ rc, out, err = script_helper.assert_python_failure(fn)
+ self.assertRegex(err, b'File "dinsdale')
+
+ def test_include_bad_file(self):
+ rc, out, err = self.assertRunNotOK(
+ '-i', os.path.join(self.directory, 'nosuchfile'), self.pkgdir)
+ self.assertRegex(out, b'rror.*nosuchfile')
+ self.assertNotRegex(err, b'Traceback')
+ self.assertFalse(os.path.exists(imp.cache_from_source(
+ self.pkgdir_cachedir)))
+
+ def test_include_file_with_arg(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+ l1.write(os.path.join(self.pkgdir, 'f1.py')+os.linesep)
+ l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+ self.assertRunOK('-i', os.path.join(self.directory, 'l1'), f4)
+ self.assertCompiled(f1)
+ self.assertCompiled(f2)
+ self.assertNotCompiled(f3)
+ self.assertCompiled(f4)
+
+ def test_include_file_no_arg(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ with open(os.path.join(self.directory, 'l1'), 'w') as l1:
+ l1.write(os.path.join(self.pkgdir, 'f2.py')+os.linesep)
+ self.assertRunOK('-i', os.path.join(self.directory, 'l1'))
+ self.assertNotCompiled(f1)
+ self.assertCompiled(f2)
+ self.assertNotCompiled(f3)
+ self.assertNotCompiled(f4)
+
+ def test_include_on_stdin(self):
+ f1 = script_helper.make_script(self.pkgdir, 'f1', '')
+ f2 = script_helper.make_script(self.pkgdir, 'f2', '')
+ f3 = script_helper.make_script(self.pkgdir, 'f3', '')
+ f4 = script_helper.make_script(self.pkgdir, 'f4', '')
+ p = script_helper.spawn_python(*(self._get_run_args(()) + ['-i', '-']))
+ p.stdin.write((f3+os.linesep).encode('ascii'))
+ script_helper.kill_python(p)
+ self.assertNotCompiled(f1)
+ self.assertNotCompiled(f2)
+ self.assertCompiled(f3)
+ self.assertNotCompiled(f4)
+
+ def test_compiles_as_much_as_possible(self):
+ bingfn = script_helper.make_script(self.pkgdir, 'bing', 'syntax(error')
+ rc, out, err = self.assertRunNotOK('nosuchfile', self.initfn,
+ bingfn, self.barfn)
+ self.assertRegex(out, b'rror')
+ self.assertNotCompiled(bingfn)
+ self.assertCompiled(self.initfn)
+ self.assertCompiled(self.barfn)
+
+ def test_invalid_arg_produces_message(self):
+ out = self.assertRunOK('badfilename')
+ self.assertRegex(out, b"Can't list 'badfilename'")
+
+
def test_main():
- test_support.run_unittest(CompileallTests)
+ support.run_unittest(
+ CommandLineTests,
+ CompileallTests,
+ EncodingTest,
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_compiler.py b/Lib/test/test_compiler.py
deleted file mode 100644
index 45988117039..00000000000
--- a/Lib/test/test_compiler.py
+++ /dev/null
@@ -1,317 +0,0 @@
-import test.test_support
-compiler = test.test_support.import_module('compiler', deprecated=True)
-from compiler.ast import flatten
-import os, sys, time, unittest
-from random import random
-from StringIO import StringIO
-
-# How much time in seconds can pass before we print a 'Still working' message.
-_PRINT_WORKING_MSG_INTERVAL = 5 * 60
-
-class TrivialContext(object):
- def __enter__(self):
- return self
- def __exit__(self, *exc_info):
- pass
-
-class CompilerTest(unittest.TestCase):
-
- def testCompileLibrary(self):
- # A simple but large test. Compile all the code in the
- # standard library and its test suite. This doesn't verify
- # that any of the code is correct, merely the compiler is able
- # to generate some kind of code for it.
-
- next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
- # warning: if 'os' or 'test_support' are moved in some other dir,
- # they should be changed here.
- libdir = os.path.dirname(os.__file__)
- testdir = os.path.dirname(test.test_support.__file__)
-
- for dir in [testdir]:
- for basename in "test_os.py",:
- # Print still working message since this test can be really slow
- if next_time <= time.time():
- next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
- print >>sys.__stdout__, \
- ' testCompileLibrary still working, be patient...'
- sys.__stdout__.flush()
-
- if not basename.endswith(".py"):
- continue
- if not TEST_ALL and random() < 0.98:
- continue
- path = os.path.join(dir, basename)
- if test.test_support.verbose:
- print "compiling", path
- f = open(path, "U")
- buf = f.read()
- f.close()
- if "badsyntax" in basename or "bad_coding" in basename:
- self.assertRaises(SyntaxError, compiler.compile,
- buf, basename, "exec")
- else:
- try:
- compiler.compile(buf, basename, "exec")
- except Exception, e:
- args = list(e.args)
- args.append("in file %s]" % basename)
- #args[0] += "[in file %s]" % basename
- e.args = tuple(args)
- raise
-
- def testNewClassSyntax(self):
- compiler.compile("class foo():pass\n\n","<string>","exec")
-
- def testYieldExpr(self):
- compiler.compile("def g(): yield\n\n", "<string>", "exec")
-
- def testKeywordAfterStarargs(self):
- def f(*args, **kwargs):
- self.assertEqual((args, kwargs), ((2,3), {'x': 1, 'y': 4}))
- c = compiler.compile('f(x=1, *(2, 3), y=4)', '<string>', 'exec')
- exec c in {'f': f}
-
- self.assertRaises(SyntaxError, compiler.parse, "foo(a=1, b)")
- self.assertRaises(SyntaxError, compiler.parse, "foo(1, *args, 3)")
-
- def testTryExceptFinally(self):
- # Test that except and finally clauses in one try stmt are recognized
- c = compiler.compile("try:\n 1//0\nexcept:\n e = 1\nfinally:\n f = 1",
- "<string>", "exec")
- dct = {}
- exec c in dct
- self.assertEqual(dct.get('e'), 1)
- self.assertEqual(dct.get('f'), 1)
-
- def testDefaultArgs(self):
- self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass")
-
- def testDocstrings(self):
- c = compiler.compile('"doc"', '<string>', 'exec')
- self.assertIn('__doc__', c.co_names)
- c = compiler.compile('def f():\n "doc"', '<string>', 'exec')
- g = {}
- exec c in g
- self.assertEqual(g['f'].__doc__, "doc")
-
- def testLineNo(self):
- # Test that all nodes except Module have a correct lineno attribute.
- filename = __file__
- if filename.endswith((".pyc", ".pyo")):
- filename = filename[:-1]
- tree = compiler.parseFile(filename)
- self.check_lineno(tree)
-
- def check_lineno(self, node):
- try:
- self._check_lineno(node)
- except AssertionError:
- print node.__class__, node.lineno
- raise
-
- def _check_lineno(self, node):
- if not node.__class__ in NOLINENO:
- self.assertIsInstance(node.lineno, int,
- "lineno=%s on %s" % (node.lineno, node.__class__))
- self.assertTrue(node.lineno > 0,
- "lineno=%s on %s" % (node.lineno, node.__class__))
- for child in node.getChildNodes():
- self.check_lineno(child)
-
- def testFlatten(self):
- self.assertEqual(flatten([1, [2]]), [1, 2])
- self.assertEqual(flatten((1, (2,))), [1, 2])
-
- def testNestedScope(self):
- c = compiler.compile('def g():\n'
- ' a = 1\n'
- ' def f(): return a + 2\n'
- ' return f()\n'
- 'result = g()',
- '<string>',
- 'exec')
- dct = {}
- exec c in dct
- self.assertEqual(dct.get('result'), 3)
-
- def testGenExp(self):
- c = compiler.compile('list((i,j) for i in range(3) if i < 3'
- ' for j in range(4) if j > 2)',
- '<string>',
- 'eval')
- self.assertEqual(eval(c), [(0, 3), (1, 3), (2, 3)])
-
- def testSetLiteral(self):
- c = compiler.compile('{1, 2, 3}', '<string>', 'eval')
- self.assertEqual(eval(c), {1,2,3})
- c = compiler.compile('{1, 2, 3,}', '<string>', 'eval')
- self.assertEqual(eval(c), {1,2,3})
-
- def testDictLiteral(self):
- c = compiler.compile('{1:2, 2:3, 3:4}', '<string>', 'eval')
- self.assertEqual(eval(c), {1:2, 2:3, 3:4})
- c = compiler.compile('{1:2, 2:3, 3:4,}', '<string>', 'eval')
- self.assertEqual(eval(c), {1:2, 2:3, 3:4})
-
- def testSetComp(self):
- c = compiler.compile('{x for x in range(1, 4)}', '<string>', 'eval')
- self.assertEqual(eval(c), {1, 2, 3})
- c = compiler.compile('{x * y for x in range(3) if x != 0'
- ' for y in range(4) if y != 0}',
- '<string>',
- 'eval')
- self.assertEqual(eval(c), {1, 2, 3, 4, 6})
-
- def testDictComp(self):
- c = compiler.compile('{x:x+1 for x in range(1, 4)}', '<string>', 'eval')
- self.assertEqual(eval(c), {1:2, 2:3, 3:4})
- c = compiler.compile('{(x, y) : y for x in range(2) if x != 0'
- ' for y in range(3) if y != 0}',
- '<string>',
- 'eval')
- self.assertEqual(eval(c), {(1, 2): 2, (1, 1): 1})
-
- def testWith(self):
- # SF bug 1638243
- c = compiler.compile('from __future__ import with_statement\n'
- 'def f():\n'
- ' with TrivialContext():\n'
- ' return 1\n'
- 'result = f()',
- '<string>',
- 'exec' )
- dct = {'TrivialContext': TrivialContext}
- exec c in dct
- self.assertEqual(dct.get('result'), 1)
-
- def testWithAss(self):
- c = compiler.compile('from __future__ import with_statement\n'
- 'def f():\n'
- ' with TrivialContext() as tc:\n'
- ' return 1\n'
- 'result = f()',
- '<string>',
- 'exec' )
- dct = {'TrivialContext': TrivialContext}
- exec c in dct
- self.assertEqual(dct.get('result'), 1)
-
- def testWithMult(self):
- events = []
- class Ctx:
- def __init__(self, n):
- self.n = n
- def __enter__(self):
- events.append(self.n)
- def __exit__(self, *args):
- pass
- c = compiler.compile('from __future__ import with_statement\n'
- 'def f():\n'
- ' with Ctx(1) as tc, Ctx(2) as tc2:\n'
- ' return 1\n'
- 'result = f()',
- '<string>',
- 'exec' )
- dct = {'Ctx': Ctx}
- exec c in dct
- self.assertEqual(dct.get('result'), 1)
- self.assertEqual(events, [1, 2])
-
- def testGlobal(self):
- code = compiler.compile('global x\nx=1', '<string>', 'exec')
- d1 = {'__builtins__': {}}
- d2 = {}
- exec code in d1, d2
- # x should be in the globals dict
- self.assertEqual(d1.get('x'), 1)
-
- def testPrintFunction(self):
- c = compiler.compile('from __future__ import print_function\n'
- 'print("a", "b", sep="**", end="++", '
- 'file=output)',
- '<string>',
- 'exec' )
- dct = {'output': StringIO()}
- exec c in dct
- self.assertEqual(dct['output'].getvalue(), 'a**b++')
-
- def _testErrEnc(self, src, text, offset):
- try:
- compile(src, "", "exec")
- except SyntaxError, e:
- self.assertEqual(e.offset, offset)
- self.assertEqual(e.text, text)
-
- def testSourceCodeEncodingsError(self):
- # Test SyntaxError with encoding definition
- sjis = "print '\x83\x70\x83\x43\x83\x5c\x83\x93', '\n"
- ascii = "print '12345678', '\n"
- encdef = "#! -*- coding: ShiftJIS -*-\n"
-
- # ascii source without encdef
- self._testErrEnc(ascii, ascii, 19)
-
- # ascii source with encdef
- self._testErrEnc(encdef+ascii, ascii, 19)
-
- # non-ascii source with encdef
- self._testErrEnc(encdef+sjis, sjis, 19)
-
- # ShiftJIS source without encdef
- self._testErrEnc(sjis, sjis, 19)
-
-
-NOLINENO = (compiler.ast.Module, compiler.ast.Stmt, compiler.ast.Discard)
-
-###############################################################################
-# code below is just used to trigger some possible errors, for the benefit of
-# testLineNo
-###############################################################################
-
-class Toto:
- """docstring"""
- pass
-
-a, b = 2, 3
-[c, d] = 5, 6
-l = [(x, y) for x, y in zip(range(5), range(5,10))]
-l[0]
-l[3:4]
-d = {'a': 2}
-d = {}
-d = {x: y for x, y in zip(range(5), range(5,10))}
-s = {x for x in range(10)}
-s = {1}
-t = ()
-t = (1, 2)
-l = []
-l = [1, 2]
-if l:
- pass
-else:
- a, b = b, a
-
-try:
- print yo
-except:
- yo = 3
-else:
- yo += 3
-
-try:
- a += b
-finally:
- b = 0
-
-from math import *
-
-###############################################################################
-
-def test_main():
- global TEST_ALL
- TEST_ALL = test.test_support.is_resource_enabled("cpu")
- test.test_support.run_unittest(CompilerTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py
index 59e86773ad1..6b34ddc0a68 100644
--- a/Lib/test/test_complex.py
+++ b/Lib/test/test_complex.py
@@ -1,8 +1,9 @@
import unittest
-from test import test_support
+from test import support
from random import random
from math import atan2, isnan, copysign
+import operator
INF = float("inf")
NAN = float("nan")
@@ -71,20 +72,16 @@ class ComplexTest(unittest.TestCase):
if x != 0:
q = z / x
self.assertClose(q, y)
- q = z.__div__(x)
- self.assertClose(q, y)
q = z.__truediv__(x)
self.assertClose(q, y)
if y != 0:
q = z / y
self.assertClose(q, x)
- q = z.__div__(y)
- self.assertClose(q, x)
q = z.__truediv__(y)
self.assertClose(q, x)
- def test_div(self):
- simple_real = [float(i) for i in xrange(-5, 6)]
+ def test_truediv(self):
+ simple_real = [float(i) for i in range(-5, 6)]
simple_complex = [complex(x, y) for x in simple_real for y in simple_real]
for x in simple_complex:
for y in simple_complex:
@@ -96,11 +93,11 @@ class ComplexTest(unittest.TestCase):
self.check_div(complex(1e-200, 1e-200), 1+0j)
# Just for fun.
- for i in xrange(100):
+ for i in range(100):
self.check_div(complex(random(), random()),
complex(random(), random()))
- self.assertRaises(ZeroDivisionError, complex.__div__, 1+1j, 0+0j)
+ self.assertRaises(ZeroDivisionError, complex.__truediv__, 1+1j, 0+0j)
# FIXME: The following currently crashes on Alpha
# self.assertRaises(OverflowError, pow, 1e200+1j, 1e200+1j)
@@ -109,36 +106,34 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ZeroDivisionError, complex.__truediv__, 1+1j, 0+0j)
def test_floordiv(self):
- self.assertAlmostEqual(complex.__floordiv__(3+0j, 1.5+0j), 2)
- self.assertRaises(ZeroDivisionError, complex.__floordiv__, 3+0j, 0+0j)
-
- def test_coerce(self):
- self.assertRaises(OverflowError, complex.__coerce__, 1+1j, 1L<<10000)
-
- def test_no_implicit_coerce(self):
- # Python 2.7 removed implicit coercion from the complex type
- class A(object):
- def __coerce__(self, other):
- raise RuntimeError
- __hash__ = None
- def __cmp__(self, other):
- return -1
-
- a = A()
- self.assertRaises(TypeError, lambda: a + 2.0j)
- self.assertTrue(a < 2.0j)
+ self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 1.5+0j)
+ self.assertRaises(TypeError, complex.__floordiv__, 3+0j, 0+0j)
def test_richcompare(self):
- self.assertEqual(complex.__eq__(1+1j, 1L<<10000), False)
- self.assertEqual(complex.__lt__(1+1j, None), NotImplemented)
+ self.assertIs(complex.__eq__(1+1j, 1<<10000), False)
+ self.assertIs(complex.__lt__(1+1j, None), NotImplemented)
self.assertIs(complex.__eq__(1+1j, 1+1j), True)
self.assertIs(complex.__eq__(1+1j, 2+2j), False)
self.assertIs(complex.__ne__(1+1j, 1+1j), False)
self.assertIs(complex.__ne__(1+1j, 2+2j), True)
- self.assertRaises(TypeError, complex.__lt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__le__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__gt__, 1+1j, 2+2j)
- self.assertRaises(TypeError, complex.__ge__, 1+1j, 2+2j)
+ for i in range(1, 100):
+ f = i / 100.0
+ self.assertIs(complex.__eq__(f+0j, f), True)
+ self.assertIs(complex.__ne__(f+0j, f), False)
+ self.assertIs(complex.__eq__(complex(f, f), f), False)
+ self.assertIs(complex.__ne__(complex(f, f), f), True)
+ self.assertIs(complex.__lt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__le__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__gt__(1+1j, 2+2j), NotImplemented)
+ self.assertIs(complex.__ge__(1+1j, 2+2j), NotImplemented)
+ self.assertRaises(TypeError, operator.lt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.le, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.gt, 1+1j, 2+2j)
+ self.assertRaises(TypeError, operator.ge, 1+1j, 2+2j)
+ self.assertIs(operator.eq(1+1j, 1+1j), True)
+ self.assertIs(operator.eq(1+1j, 2+2j), False)
+ self.assertIs(operator.ne(1+1j, 1+1j), False)
+ self.assertIs(operator.ne(1+1j, 2+2j), True)
def test_richcompare_boundaries(self):
def check(n, deltas, is_equal, imag = 0.0):
@@ -158,18 +153,14 @@ class ComplexTest(unittest.TestCase):
check(2 ** 53, range(-100, 0), lambda delta: True)
def test_mod(self):
- self.assertRaises(ZeroDivisionError, (1+1j).__mod__, 0+0j)
-
- a = 3.33+4.43j
- try:
- a % 0
- except ZeroDivisionError:
- pass
- else:
- self.fail("modulo parama can't be 0")
+ # % is no longer supported on complex numbers
+ self.assertRaises(TypeError, (1+1j).__mod__, 0+0j)
+ self.assertRaises(TypeError, lambda: (3.33+4.43j) % 0)
+ self.assertRaises(TypeError, (1+1j).__mod__, 4.3j)
def test_divmod(self):
- self.assertRaises(ZeroDivisionError, divmod, 1+1j, 0+0j)
+ self.assertRaises(TypeError, divmod, 1+1j, 1+0j)
+ self.assertRaises(TypeError, divmod, 1+1j, 0+0j)
def test_pow(self):
self.assertAlmostEqual(pow(1+1j, 0+0j), 1.0)
@@ -211,7 +202,7 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, pow, a, b, 0)
def test_boolcontext(self):
- for i in xrange(100):
+ for i in range(100):
self.assertTrue(complex(random() + 1e-6, random() + 1e-6))
self.assertTrue(not complex(0.0, 0.0))
@@ -229,29 +220,30 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(complex(NS(1+10j)), 1+10j)
self.assertRaises(TypeError, complex, OS(None))
self.assertRaises(TypeError, complex, NS(None))
+ self.assertRaises(TypeError, complex, {})
self.assertAlmostEqual(complex("1+10j"), 1+10j)
self.assertAlmostEqual(complex(10), 10+0j)
self.assertAlmostEqual(complex(10.0), 10+0j)
- self.assertAlmostEqual(complex(10L), 10+0j)
+ self.assertAlmostEqual(complex(10), 10+0j)
self.assertAlmostEqual(complex(10+0j), 10+0j)
self.assertAlmostEqual(complex(1,10), 1+10j)
- self.assertAlmostEqual(complex(1,10L), 1+10j)
+ self.assertAlmostEqual(complex(1,10), 1+10j)
+ self.assertAlmostEqual(complex(1,10.0), 1+10j)
+ self.assertAlmostEqual(complex(1,10), 1+10j)
+ self.assertAlmostEqual(complex(1,10), 1+10j)
self.assertAlmostEqual(complex(1,10.0), 1+10j)
- self.assertAlmostEqual(complex(1L,10), 1+10j)
- self.assertAlmostEqual(complex(1L,10L), 1+10j)
- self.assertAlmostEqual(complex(1L,10.0), 1+10j)
self.assertAlmostEqual(complex(1.0,10), 1+10j)
- self.assertAlmostEqual(complex(1.0,10L), 1+10j)
+ self.assertAlmostEqual(complex(1.0,10), 1+10j)
self.assertAlmostEqual(complex(1.0,10.0), 1+10j)
self.assertAlmostEqual(complex(3.14+0j), 3.14+0j)
self.assertAlmostEqual(complex(3.14), 3.14+0j)
self.assertAlmostEqual(complex(314), 314.0+0j)
- self.assertAlmostEqual(complex(314L), 314.0+0j)
+ self.assertAlmostEqual(complex(314), 314.0+0j)
self.assertAlmostEqual(complex(3.14+0j, 0j), 3.14+0j)
self.assertAlmostEqual(complex(3.14, 0.0), 3.14+0j)
self.assertAlmostEqual(complex(314, 0), 314.0+0j)
- self.assertAlmostEqual(complex(314L, 0L), 314.0+0j)
+ self.assertAlmostEqual(complex(314, 0), 314.0+0j)
self.assertAlmostEqual(complex(0j, 3.14j), -3.14+0j)
self.assertAlmostEqual(complex(0.0, 3.14j), -3.14+0j)
self.assertAlmostEqual(complex(0j, 3.14), 3.14j)
@@ -301,15 +293,12 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(TypeError, complex, "1", "1")
self.assertRaises(TypeError, complex, 1, "1")
- if test_support.have_unicode:
- self.assertEqual(complex(unicode(" 3.14+J ")), 3.14+1j)
-
# SF bug 543840: complex(string) accepts strings with \0
# Fixed in 2.3.
self.assertRaises(ValueError, complex, '1+1j\0j')
self.assertRaises(TypeError, int, 5+3j)
- self.assertRaises(TypeError, long, 5+3j)
+ self.assertRaises(TypeError, int, 5+3j)
self.assertRaises(TypeError, float, 5+3j)
self.assertRaises(ValueError, complex, "")
self.assertRaises(TypeError, complex, None)
@@ -325,8 +314,7 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "1+2j)")
self.assertRaises(ValueError, complex, "1+(2j)")
self.assertRaises(ValueError, complex, "(1+2j)123")
- if test_support.have_unicode:
- self.assertRaises(ValueError, complex, unicode("x"))
+ self.assertRaises(ValueError, complex, "x")
self.assertRaises(ValueError, complex, "1j+2")
self.assertRaises(ValueError, complex, "1e1ej")
self.assertRaises(ValueError, complex, "1e++1ej")
@@ -336,9 +324,10 @@ class ComplexTest(unittest.TestCase):
self.assertRaises(ValueError, complex, "1.11.1j")
self.assertRaises(ValueError, complex, "1e1.1j")
- if test_support.have_unicode:
- # check that complex accepts long unicode strings
- self.assertEqual(type(complex(unicode("1"*500))), complex)
+ # check that complex accepts long unicode strings
+ self.assertEqual(type(complex("1"*500)), complex)
+ # check whitespace processing
+ self.assertEqual(complex('\N{EM SPACE}(\N{EN SPACE}1+1j ) '), 1+1j)
class EvilExc(Exception):
pass
@@ -381,94 +370,59 @@ class ComplexTest(unittest.TestCase):
self.assertAlmostEqual(complex(complex1(1j)), 2j)
self.assertRaises(TypeError, complex, complex2(1j))
- def test_subclass(self):
- class xcomplex(complex):
- def __add__(self,other):
- return xcomplex(complex(self) + other)
- __radd__ = __add__
-
- def __sub__(self,other):
- return xcomplex(complex(self) + other)
- __rsub__ = __sub__
-
- def __mul__(self,other):
- return xcomplex(complex(self) * other)
- __rmul__ = __mul__
-
- def __div__(self,other):
- return xcomplex(complex(self) / other)
-
- def __rdiv__(self,other):
- return xcomplex(other / complex(self))
-
- __truediv__ = __div__
- __rtruediv__ = __rdiv__
-
- def __floordiv__(self,other):
- return xcomplex(complex(self) // other)
-
- def __rfloordiv__(self,other):
- return xcomplex(other // complex(self))
-
- def __pow__(self,other):
- return xcomplex(complex(self) ** other)
-
- def __rpow__(self,other):
- return xcomplex(other ** complex(self) )
-
- def __mod__(self,other):
- return xcomplex(complex(self) % other)
-
- def __rmod__(self,other):
- return xcomplex(other % complex(self))
-
- infix_binops = ('+', '-', '*', '**', '%', '//', '/')
- xcomplex_values = (xcomplex(1), xcomplex(123.0),
- xcomplex(-10+2j), xcomplex(3+187j),
- xcomplex(3-78j))
- test_values = (1, 123.0, 10-19j, xcomplex(1+2j),
- xcomplex(1+87j), xcomplex(10+90j))
-
- for op in infix_binops:
- for x in xcomplex_values:
- for y in test_values:
- a = 'x %s y' % op
- b = 'y %s x' % op
- self.assertTrue(type(eval(a)) is type(eval(b)) is xcomplex)
-
def test_hash(self):
- for x in xrange(-30, 30):
+ for x in range(-30, 30):
self.assertEqual(hash(x), hash(complex(x, 0)))
x /= 3.0 # now check against floating point
self.assertEqual(hash(x), hash(complex(x, 0.)))
def test_abs(self):
- nums = [complex(x/3., y/7.) for x in xrange(-9,9) for y in xrange(-9,9)]
+ nums = [complex(x/3., y/7.) for x in range(-9,9) for y in range(-9,9)]
for num in nums:
self.assertAlmostEqual((num.real**2 + num.imag**2) ** 0.5, abs(num))
- def test_repr(self):
- self.assertEqual(repr(1+6j), '(1+6j)')
- self.assertEqual(repr(1-6j), '(1-6j)')
+ def test_repr_str(self):
+ def test(v, expected, test_fn=self.assertEqual):
+ test_fn(repr(v), expected)
+ test_fn(str(v), expected)
- self.assertNotEqual(repr(-(1+0j)), '(-1+-0j)')
+ test(1+6j, '(1+6j)')
+ test(1-6j, '(1-6j)')
+
+ test(-(1+0j), '(-1+-0j)', test_fn=self.assertNotEqual)
+
+ test(complex(1., INF), "(1+infj)")
+ test(complex(1., -INF), "(1-infj)")
+ test(complex(INF, 1), "(inf+1j)")
+ test(complex(-INF, INF), "(-inf+infj)")
+ test(complex(NAN, 1), "(nan+1j)")
+ test(complex(1, NAN), "(1+nanj)")
+ test(complex(NAN, NAN), "(nan+nanj)")
+
+ test(complex(0, INF), "infj")
+ test(complex(0, -INF), "-infj")
+ test(complex(0, NAN), "nanj")
self.assertEqual(1-6j,complex(repr(1-6j)))
self.assertEqual(1+6j,complex(repr(1+6j)))
self.assertEqual(-6j,complex(repr(-6j)))
self.assertEqual(6j,complex(repr(6j)))
- self.assertEqual(repr(complex(1., INF)), "(1+infj)")
- self.assertEqual(repr(complex(1., -INF)), "(1-infj)")
- self.assertEqual(repr(complex(INF, 1)), "(inf+1j)")
- self.assertEqual(repr(complex(-INF, INF)), "(-inf+infj)")
- self.assertEqual(repr(complex(NAN, 1)), "(nan+1j)")
- self.assertEqual(repr(complex(1, NAN)), "(1+nanj)")
- self.assertEqual(repr(complex(NAN, NAN)), "(nan+nanj)")
+ @support.requires_IEEE_754
+ def test_negative_zero_repr_str(self):
+ def test(v, expected, test_fn=self.assertEqual):
+ test_fn(repr(v), expected)
+ test_fn(str(v), expected)
- self.assertEqual(repr(complex(0, INF)), "infj")
- self.assertEqual(repr(complex(0, -INF)), "-infj")
- self.assertEqual(repr(complex(0, NAN)), "nanj")
+ test(complex(0., 1.), "1j")
+ test(complex(-0., 1.), "(-0+1j)")
+ test(complex(0., -1.), "-1j")
+ test(complex(-0., -1.), "(-0-1j)")
+
+ test(complex(0., 0.), "0j")
+ test(complex(0., -0.), "-0j")
+ test(complex(-0., 0.), "(-0+0j)")
+ test(complex(-0., -0.), "(-0-0j)")
def test_neg(self):
self.assertEqual(-(1+6j), -1-6j)
@@ -479,15 +433,15 @@ class ComplexTest(unittest.TestCase):
fo = None
try:
- fo = open(test_support.TESTFN, "wb")
- print >>fo, a, b
+ fo = open(support.TESTFN, "w")
+ print(a, b, file=fo)
fo.close()
- fo = open(test_support.TESTFN, "rb")
- self.assertEqual(fo.read(), "%s %s\n" % (a, b))
+ fo = open(support.TESTFN, "r")
+ self.assertEqual(fo.read(), ("%s %s\n" % (a, b)))
finally:
if (fo is not None) and (not fo.closed):
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_getnewargs(self):
self.assertEqual((1+2j).__getnewargs__(), (1.0, 2.0))
@@ -497,22 +451,36 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(complex(0, INF).__getnewargs__(), (0.0, INF))
self.assertEqual(complex(INF, 0).__getnewargs__(), (INF, 0.0))
- if float.__getformat__("double").startswith("IEEE"):
- def test_plus_minus_0j(self):
- # test that -0j and 0j literals are not identified
- z1, z2 = 0j, -0j
- self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
- self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
-
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
+ def test_plus_minus_0j(self):
+ # test that -0j and 0j literals are not identified
+ z1, z2 = 0j, -0j
+ self.assertEqual(atan2(z1.imag, -1.), atan2(0., -1.))
+ self.assertEqual(atan2(z2.imag, -1.), atan2(-0., -1.))
+
+ @support.requires_IEEE_754
+ def test_negated_imaginary_literal(self):
+ z0 = -0j
+ z1 = -7j
+ z2 = -1e1000j
+ # Note: In versions of Python < 3.2, a negated imaginary literal
+ # accidentally ended up with real part 0.0 instead of -0.0, thanks to a
+ # modification during CST -> AST translation (see issue #9011). That's
+ # fixed in Python 3.2.
+ self.assertFloatsAreIdentical(z0.real, -0.0)
+ self.assertFloatsAreIdentical(z0.imag, -0.0)
+ self.assertFloatsAreIdentical(z1.real, -0.0)
+ self.assertFloatsAreIdentical(z1.imag, -7.0)
+ self.assertFloatsAreIdentical(z2.real, -0.0)
+ self.assertFloatsAreIdentical(z2.imag, -INF)
+
+ @support.requires_IEEE_754
def test_overflow(self):
self.assertEqual(complex("1e500"), complex(INF, 0.0))
self.assertEqual(complex("-1e500j"), complex(0.0, -INF))
self.assertEqual(complex("-1e500+1.8e308j"), complex(-INF, INF))
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_repr_roundtrip(self):
vals = [0.0, 1e-500, 1e-315, 1e-200, 0.0123, 3.1415, 1e50, INF, NAN]
vals += [-v for v in vals]
@@ -607,8 +575,28 @@ class ComplexTest(unittest.TestCase):
self.assertEqual(format(1.5e21+3j, '^40,.2f'), ' 1,500,000,000,000,000,000,000.00+3.00j ')
self.assertEqual(format(1.5e21+3000j, ',.2f'), '1,500,000,000,000,000,000,000.00+3,000.00j')
- # alternate is invalid
- self.assertRaises(ValueError, (1.5+0.5j).__format__, '#f')
+ # Issue 7094: Alternate formatting (specified by #)
+ self.assertEqual(format(1+1j, '.0e'), '1e+00+1e+00j')
+ self.assertEqual(format(1+1j, '#.0e'), '1.e+00+1.e+00j')
+ self.assertEqual(format(1+1j, '.0f'), '1+1j')
+ self.assertEqual(format(1+1j, '#.0f'), '1.+1.j')
+ self.assertEqual(format(1.1+1.1j, 'g'), '1.1+1.1j')
+ self.assertEqual(format(1.1+1.1j, '#g'), '1.10000+1.10000j')
+
+ # Alternate doesn't make a difference for these, they format the same with or without it
+ self.assertEqual(format(1+1j, '.1e'), '1.0e+00+1.0e+00j')
+ self.assertEqual(format(1+1j, '#.1e'), '1.0e+00+1.0e+00j')
+ self.assertEqual(format(1+1j, '.1f'), '1.0+1.0j')
+ self.assertEqual(format(1+1j, '#.1f'), '1.0+1.0j')
+
+ # Misc. other alternate tests
+ self.assertEqual(format((-1.5+0.5j), '#f'), '-1.500000+0.500000j')
+ self.assertEqual(format((-1.5+0.5j), '#.0f'), '-2.+0.j')
+ self.assertEqual(format((-1.5+0.5j), '#e'), '-1.500000e+00+5.000000e-01j')
+ self.assertEqual(format((-1.5+0.5j), '#.0e'), '-2.e+00+5.e-01j')
+ self.assertEqual(format((-1.5+0.5j), '#g'), '-1.50000+0.500000j')
+ self.assertEqual(format((-1.5+0.5j), '.0g'), '-2+0.5j')
+ self.assertEqual(format((-1.5+0.5j), '#.0g'), '-2.+0.5j')
# zero padding is invalid
self.assertRaises(ValueError, (1.5+0.5j).__format__, '010f')
@@ -623,29 +611,26 @@ class ComplexTest(unittest.TestCase):
# make sure everything works in ''.format()
self.assertEqual('*{0:.3f}*'.format(3.14159+2.71828j), '*3.142+2.718j*')
- # issue 3382: 'f' and 'F' with inf's and nan's
- self.assertEqual('{0:f}'.format(INF+0j), 'inf+0.000000j')
- self.assertEqual('{0:F}'.format(INF+0j), 'INF+0.000000j')
- self.assertEqual('{0:f}'.format(-INF+0j), '-inf+0.000000j')
- self.assertEqual('{0:F}'.format(-INF+0j), '-INF+0.000000j')
- self.assertEqual('{0:f}'.format(complex(INF, INF)), 'inf+infj')
- self.assertEqual('{0:F}'.format(complex(INF, INF)), 'INF+INFj')
- self.assertEqual('{0:f}'.format(complex(INF, -INF)), 'inf-infj')
- self.assertEqual('{0:F}'.format(complex(INF, -INF)), 'INF-INFj')
- self.assertEqual('{0:f}'.format(complex(-INF, INF)), '-inf+infj')
- self.assertEqual('{0:F}'.format(complex(-INF, INF)), '-INF+INFj')
- self.assertEqual('{0:f}'.format(complex(-INF, -INF)), '-inf-infj')
- self.assertEqual('{0:F}'.format(complex(-INF, -INF)), '-INF-INFj')
-
- self.assertEqual('{0:f}'.format(complex(NAN, 0)), 'nan+0.000000j')
- self.assertEqual('{0:F}'.format(complex(NAN, 0)), 'NAN+0.000000j')
- self.assertEqual('{0:f}'.format(complex(NAN, NAN)), 'nan+nanj')
- self.assertEqual('{0:F}'.format(complex(NAN, NAN)), 'NAN+NANj')
+ # issue 3382
+ self.assertEqual(format(complex(NAN, NAN), 'f'), 'nan+nanj')
+ self.assertEqual(format(complex(1, NAN), 'f'), '1.000000+nanj')
+ self.assertEqual(format(complex(NAN, 1), 'f'), 'nan+1.000000j')
+ self.assertEqual(format(complex(NAN, -1), 'f'), 'nan-1.000000j')
+ self.assertEqual(format(complex(NAN, NAN), 'F'), 'NAN+NANj')
+ self.assertEqual(format(complex(1, NAN), 'F'), '1.000000+NANj')
+ self.assertEqual(format(complex(NAN, 1), 'F'), 'NAN+1.000000j')
+ self.assertEqual(format(complex(NAN, -1), 'F'), 'NAN-1.000000j')
+ self.assertEqual(format(complex(INF, INF), 'f'), 'inf+infj')
+ self.assertEqual(format(complex(1, INF), 'f'), '1.000000+infj')
+ self.assertEqual(format(complex(INF, 1), 'f'), 'inf+1.000000j')
+ self.assertEqual(format(complex(INF, -1), 'f'), 'inf-1.000000j')
+ self.assertEqual(format(complex(INF, INF), 'F'), 'INF+INFj')
+ self.assertEqual(format(complex(1, INF), 'F'), '1.000000+INFj')
+ self.assertEqual(format(complex(INF, 1), 'F'), 'INF+1.000000j')
+ self.assertEqual(format(complex(INF, -1), 'F'), 'INF-1.000000j')
def test_main():
- with test_support.check_warnings(("complex divmod.., // and % are "
- "deprecated", DeprecationWarning)):
- test_support.run_unittest(ComplexTest)
+ support.run_unittest(ComplexTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_complex_args.py b/Lib/test/test_complex_args.py
deleted file mode 100644
index 036cbea4029..00000000000
--- a/Lib/test/test_complex_args.py
+++ /dev/null
@@ -1,118 +0,0 @@
-
-import unittest
-from test import test_support
-import textwrap
-
-class ComplexArgsTestCase(unittest.TestCase):
-
- def check(self, func, expected, *args):
- self.assertEqual(func(*args), expected)
-
- # These functions are tested below as lambdas too. If you add a
- # function test, also add a similar lambda test.
-
- # Functions are wrapped in "exec" statements in order to
- # silence Py3k warnings.
-
- def test_func_parens_no_unpacking(self):
- exec textwrap.dedent("""
- def f(((((x))))): return x
- self.check(f, 1, 1)
- # Inner parens are elided, same as: f(x,)
- def f(((x)),): return x
- self.check(f, 2, 2)
- """)
-
- def test_func_1(self):
- exec textwrap.dedent("""
- def f(((((x),)))): return x
- self.check(f, 3, (3,))
- def f(((((x)),))): return x
- self.check(f, 4, (4,))
- def f(((((x))),)): return x
- self.check(f, 5, (5,))
- def f(((x),)): return x
- self.check(f, 6, (6,))
- """)
-
- def test_func_2(self):
- exec textwrap.dedent("""
- def f(((((x)),),)): return x
- self.check(f, 2, ((2,),))
- """)
-
- def test_func_3(self):
- exec textwrap.dedent("""
- def f((((((x)),),),)): return x
- self.check(f, 3, (((3,),),))
- """)
-
- def test_func_complex(self):
- exec textwrap.dedent("""
- def f((((((x)),),),), a, b, c): return x, a, b, c
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- def f(((((((x)),)),),), a, b, c): return x, a, b, c
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- def f(a, b, c, ((((((x)),)),),)): return a, b, c, x
- self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),))
- """)
-
- # Duplicate the tests above, but for lambda. If you add a lambda test,
- # also add a similar function test above.
-
- def test_lambda_parens_no_unpacking(self):
- exec textwrap.dedent("""
- f = lambda (((((x))))): x
- self.check(f, 1, 1)
- # Inner parens are elided, same as: f(x,)
- f = lambda ((x)),: x
- self.check(f, 2, 2)
- """)
-
- def test_lambda_1(self):
- exec textwrap.dedent("""
- f = lambda (((((x),)))): x
- self.check(f, 3, (3,))
- f = lambda (((((x)),))): x
- self.check(f, 4, (4,))
- f = lambda (((((x))),)): x
- self.check(f, 5, (5,))
- f = lambda (((x),)): x
- self.check(f, 6, (6,))
- """)
-
- def test_lambda_2(self):
- exec textwrap.dedent("""
- f = lambda (((((x)),),)): x
- self.check(f, 2, ((2,),))
- """)
-
- def test_lambda_3(self):
- exec textwrap.dedent("""
- f = lambda ((((((x)),),),)): x
- self.check(f, 3, (((3,),),))
- """)
-
- def test_lambda_complex(self):
- exec textwrap.dedent("""
- f = lambda (((((x)),),),), a, b, c: (x, a, b, c)
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- f = lambda ((((((x)),)),),), a, b, c: (x, a, b, c)
- self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7)
-
- f = lambda a, b, c, ((((((x)),)),),): (a, b, c, x)
- self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),))
- """)
-
-
-def test_main():
- with test_support.check_py3k_warnings(
- ("tuple parameter unpacking has been removed", SyntaxWarning),
- ("parenthesized argument names are invalid", SyntaxWarning)):
- test_support.run_unittest(ComplexArgsTestCase)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_concurrent_futures.py b/Lib/test/test_concurrent_futures.py
new file mode 100644
index 00000000000..2afa93802e2
--- /dev/null
+++ b/Lib/test/test_concurrent_futures.py
@@ -0,0 +1,639 @@
+import test.support
+
+# Skip tests if _multiprocessing wasn't built.
+test.support.import_module('_multiprocessing')
+# Skip tests if sem_open implementation is broken.
+test.support.import_module('multiprocessing.synchronize')
+# import threading after _multiprocessing to raise a more revelant error
+# message: "No module named _multiprocessing". _multiprocessing is not compiled
+# without thread support.
+test.support.import_module('threading')
+
+from test.script_helper import assert_python_ok
+
+import sys
+import threading
+import time
+import unittest
+
+from concurrent import futures
+from concurrent.futures._base import (
+ PENDING, RUNNING, CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED, Future)
+import concurrent.futures.process
+
+
+def create_future(state=PENDING, exception=None, result=None):
+ f = Future()
+ f._state = state
+ f._exception = exception
+ f._result = result
+ return f
+
+
+PENDING_FUTURE = create_future(state=PENDING)
+RUNNING_FUTURE = create_future(state=RUNNING)
+CANCELLED_FUTURE = create_future(state=CANCELLED)
+CANCELLED_AND_NOTIFIED_FUTURE = create_future(state=CANCELLED_AND_NOTIFIED)
+EXCEPTION_FUTURE = create_future(state=FINISHED, exception=IOError())
+SUCCESSFUL_FUTURE = create_future(state=FINISHED, result=42)
+
+
+def mul(x, y):
+ return x * y
+
+
+def sleep_and_raise(t):
+ time.sleep(t)
+ raise Exception('this is an exception')
+
+def sleep_and_print(t, msg):
+ time.sleep(t)
+ print(msg)
+ sys.stdout.flush()
+
+
+class ExecutorMixin:
+ worker_count = 5
+
+ def setUp(self):
+ self.t1 = time.time()
+ try:
+ self.executor = self.executor_type(max_workers=self.worker_count)
+ except NotImplementedError as e:
+ self.skipTest(str(e))
+ self._prime_executor()
+
+ def tearDown(self):
+ self.executor.shutdown(wait=True)
+ dt = time.time() - self.t1
+ if test.support.verbose:
+ print("%.2fs" % dt, end=' ')
+ self.assertLess(dt, 60, "synchronization issue: test lasted too long")
+
+ def _prime_executor(self):
+ # Make sure that the executor is ready to do work before running the
+ # tests. This should reduce the probability of timeouts in the tests.
+ futures = [self.executor.submit(time.sleep, 0.1)
+ for _ in range(self.worker_count)]
+
+ for f in futures:
+ f.result()
+
+
+class ThreadPoolMixin(ExecutorMixin):
+ executor_type = futures.ThreadPoolExecutor
+
+
+class ProcessPoolMixin(ExecutorMixin):
+ executor_type = futures.ProcessPoolExecutor
+
+
+class ExecutorShutdownTest(unittest.TestCase):
+ def test_run_after_shutdown(self):
+ self.executor.shutdown()
+ self.assertRaises(RuntimeError,
+ self.executor.submit,
+ pow, 2, 5)
+
+ def test_interpreter_shutdown(self):
+ # Test the atexit hook for shutdown of worker threads and processes
+ rc, out, err = assert_python_ok('-c', """if 1:
+ from concurrent.futures import {executor_type}
+ from time import sleep
+ from test.test_concurrent_futures import sleep_and_print
+ t = {executor_type}(5)
+ t.submit(sleep_and_print, 1.0, "apple")
+ """.format(executor_type=self.executor_type.__name__))
+ # Errors in atexit hooks don't change the process exit code, check
+ # stderr manually.
+ self.assertFalse(err)
+ self.assertEqual(out.strip(), b"apple")
+
+ def test_hang_issue12364(self):
+ fs = [self.executor.submit(time.sleep, 0.1) for _ in range(50)]
+ self.executor.shutdown()
+ for f in fs:
+ f.result()
+
+
+class ThreadPoolShutdownTest(ThreadPoolMixin, ExecutorShutdownTest):
+ def _prime_executor(self):
+ pass
+
+ def test_threads_terminate(self):
+ self.executor.submit(mul, 21, 2)
+ self.executor.submit(mul, 6, 7)
+ self.executor.submit(mul, 3, 14)
+ self.assertEqual(len(self.executor._threads), 3)
+ self.executor.shutdown()
+ for t in self.executor._threads:
+ t.join()
+
+ def test_context_manager_shutdown(self):
+ with futures.ThreadPoolExecutor(max_workers=5) as e:
+ executor = e
+ self.assertEqual(list(e.map(abs, range(-5, 5))),
+ [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
+
+ for t in executor._threads:
+ t.join()
+
+ def test_del_shutdown(self):
+ executor = futures.ThreadPoolExecutor(max_workers=5)
+ executor.map(abs, range(-5, 5))
+ threads = executor._threads
+ del executor
+
+ for t in threads:
+ t.join()
+
+
+class ProcessPoolShutdownTest(ProcessPoolMixin, ExecutorShutdownTest):
+ def _prime_executor(self):
+ pass
+
+ def test_processes_terminate(self):
+ self.executor.submit(mul, 21, 2)
+ self.executor.submit(mul, 6, 7)
+ self.executor.submit(mul, 3, 14)
+ self.assertEqual(len(self.executor._processes), 5)
+ processes = self.executor._processes
+ self.executor.shutdown()
+
+ for p in processes:
+ p.join()
+
+ def test_context_manager_shutdown(self):
+ with futures.ProcessPoolExecutor(max_workers=5) as e:
+ processes = e._processes
+ self.assertEqual(list(e.map(abs, range(-5, 5))),
+ [5, 4, 3, 2, 1, 0, 1, 2, 3, 4])
+
+ for p in processes:
+ p.join()
+
+ def test_del_shutdown(self):
+ executor = futures.ProcessPoolExecutor(max_workers=5)
+ list(executor.map(abs, range(-5, 5)))
+ queue_management_thread = executor._queue_management_thread
+ processes = executor._processes
+ del executor
+
+ queue_management_thread.join()
+ for p in processes:
+ p.join()
+
+
+class WaitTests(unittest.TestCase):
+
+ def test_first_completed(self):
+ future1 = self.executor.submit(mul, 21, 2)
+ future2 = self.executor.submit(time.sleep, 1.5)
+
+ done, not_done = futures.wait(
+ [CANCELLED_FUTURE, future1, future2],
+ return_when=futures.FIRST_COMPLETED)
+
+ self.assertEqual(set([future1]), done)
+ self.assertEqual(set([CANCELLED_FUTURE, future2]), not_done)
+
+ def test_first_completed_some_already_completed(self):
+ future1 = self.executor.submit(time.sleep, 1.5)
+
+ finished, pending = futures.wait(
+ [CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE, future1],
+ return_when=futures.FIRST_COMPLETED)
+
+ self.assertEqual(
+ set([CANCELLED_AND_NOTIFIED_FUTURE, SUCCESSFUL_FUTURE]),
+ finished)
+ self.assertEqual(set([future1]), pending)
+
+ def test_first_exception(self):
+ future1 = self.executor.submit(mul, 2, 21)
+ future2 = self.executor.submit(sleep_and_raise, 1.5)
+ future3 = self.executor.submit(time.sleep, 3)
+
+ finished, pending = futures.wait(
+ [future1, future2, future3],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([future1, future2]), finished)
+ self.assertEqual(set([future3]), pending)
+
+ def test_first_exception_some_already_complete(self):
+ future1 = self.executor.submit(divmod, 21, 0)
+ future2 = self.executor.submit(time.sleep, 1.5)
+
+ finished, pending = futures.wait(
+ [SUCCESSFUL_FUTURE,
+ CANCELLED_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ future1, future2],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ future1]), finished)
+ self.assertEqual(set([CANCELLED_FUTURE, future2]), pending)
+
+ def test_first_exception_one_already_failed(self):
+ future1 = self.executor.submit(time.sleep, 2)
+
+ finished, pending = futures.wait(
+ [EXCEPTION_FUTURE, future1],
+ return_when=futures.FIRST_EXCEPTION)
+
+ self.assertEqual(set([EXCEPTION_FUTURE]), finished)
+ self.assertEqual(set([future1]), pending)
+
+ def test_all_completed(self):
+ future1 = self.executor.submit(divmod, 2, 0)
+ future2 = self.executor.submit(mul, 2, 21)
+
+ finished, pending = futures.wait(
+ [SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ future1,
+ future2],
+ return_when=futures.ALL_COMPLETED)
+
+ self.assertEqual(set([SUCCESSFUL_FUTURE,
+ CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ future1,
+ future2]), finished)
+ self.assertEqual(set(), pending)
+
+ def test_timeout(self):
+ future1 = self.executor.submit(mul, 6, 7)
+ future2 = self.executor.submit(time.sleep, 3)
+
+ finished, pending = futures.wait(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2],
+ timeout=1.5,
+ return_when=futures.ALL_COMPLETED)
+
+ self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1]), finished)
+ self.assertEqual(set([future2]), pending)
+
+
+class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests):
+
+ def test_pending_calls_race(self):
+ # Issue #14406: multi-threaded race condition when waiting on all
+ # futures.
+ event = threading.Event()
+ def future_func():
+ event.wait()
+ oldswitchinterval = sys.getswitchinterval()
+ sys.setswitchinterval(1e-6)
+ try:
+ fs = {self.executor.submit(future_func) for i in range(100)}
+ event.set()
+ futures.wait(fs, return_when=futures.ALL_COMPLETED)
+ finally:
+ sys.setswitchinterval(oldswitchinterval)
+
+
+class ProcessPoolWaitTests(ProcessPoolMixin, WaitTests):
+ pass
+
+
+class AsCompletedTests(unittest.TestCase):
+ # TODO(brian@sweetapp.com): Should have a test with a non-zero timeout.
+ def test_no_timeout(self):
+ future1 = self.executor.submit(mul, 2, 21)
+ future2 = self.executor.submit(mul, 7, 6)
+
+ completed = set(futures.as_completed(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2]))
+ self.assertEqual(set(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1, future2]),
+ completed)
+
+ def test_zero_timeout(self):
+ future1 = self.executor.submit(time.sleep, 2)
+ completed_futures = set()
+ try:
+ for future in futures.as_completed(
+ [CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE,
+ future1],
+ timeout=0):
+ completed_futures.add(future)
+ except futures.TimeoutError:
+ pass
+
+ self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
+ EXCEPTION_FUTURE,
+ SUCCESSFUL_FUTURE]),
+ completed_futures)
+
+
+class ThreadPoolAsCompletedTests(ThreadPoolMixin, AsCompletedTests):
+ pass
+
+
+class ProcessPoolAsCompletedTests(ProcessPoolMixin, AsCompletedTests):
+ pass
+
+
+class ExecutorTest(unittest.TestCase):
+ # Executor.shutdown() and context manager usage is tested by
+ # ExecutorShutdownTest.
+ def test_submit(self):
+ future = self.executor.submit(pow, 2, 8)
+ self.assertEqual(256, future.result())
+
+ def test_submit_keyword(self):
+ future = self.executor.submit(mul, 2, y=8)
+ self.assertEqual(16, future.result())
+
+ def test_map(self):
+ self.assertEqual(
+ list(self.executor.map(pow, range(10), range(10))),
+ list(map(pow, range(10), range(10))))
+
+ def test_map_exception(self):
+ i = self.executor.map(divmod, [1, 1, 1, 1], [2, 3, 0, 5])
+ self.assertEqual(i.__next__(), (0, 1))
+ self.assertEqual(i.__next__(), (0, 1))
+ self.assertRaises(ZeroDivisionError, i.__next__)
+
+ def test_map_timeout(self):
+ results = []
+ try:
+ for i in self.executor.map(time.sleep,
+ [0, 0, 3],
+ timeout=1.5):
+ results.append(i)
+ except futures.TimeoutError:
+ pass
+ else:
+ self.fail('expected TimeoutError')
+
+ self.assertEqual([None, None], results)
+
+
+class ThreadPoolExecutorTest(ThreadPoolMixin, ExecutorTest):
+ pass
+
+
+class ProcessPoolExecutorTest(ProcessPoolMixin, ExecutorTest):
+ pass
+
+
+class FutureTests(unittest.TestCase):
+ def test_done_callback_with_result(self):
+ callback_result = None
+ def fn(callback_future):
+ nonlocal callback_result
+ callback_result = callback_future.result()
+
+ f = Future()
+ f.add_done_callback(fn)
+ f.set_result(5)
+ self.assertEqual(5, callback_result)
+
+ def test_done_callback_with_exception(self):
+ callback_exception = None
+ def fn(callback_future):
+ nonlocal callback_exception
+ callback_exception = callback_future.exception()
+
+ f = Future()
+ f.add_done_callback(fn)
+ f.set_exception(Exception('test'))
+ self.assertEqual(('test',), callback_exception.args)
+
+ def test_done_callback_with_cancel(self):
+ was_cancelled = None
+ def fn(callback_future):
+ nonlocal was_cancelled
+ was_cancelled = callback_future.cancelled()
+
+ f = Future()
+ f.add_done_callback(fn)
+ self.assertTrue(f.cancel())
+ self.assertTrue(was_cancelled)
+
+ def test_done_callback_raises(self):
+ with test.support.captured_stderr() as stderr:
+ raising_was_called = False
+ fn_was_called = False
+
+ def raising_fn(callback_future):
+ nonlocal raising_was_called
+ raising_was_called = True
+ raise Exception('doh!')
+
+ def fn(callback_future):
+ nonlocal fn_was_called
+ fn_was_called = True
+
+ f = Future()
+ f.add_done_callback(raising_fn)
+ f.add_done_callback(fn)
+ f.set_result(5)
+ self.assertTrue(raising_was_called)
+ self.assertTrue(fn_was_called)
+ self.assertIn('Exception: doh!', stderr.getvalue())
+
+ def test_done_callback_already_successful(self):
+ callback_result = None
+ def fn(callback_future):
+ nonlocal callback_result
+ callback_result = callback_future.result()
+
+ f = Future()
+ f.set_result(5)
+ f.add_done_callback(fn)
+ self.assertEqual(5, callback_result)
+
+ def test_done_callback_already_failed(self):
+ callback_exception = None
+ def fn(callback_future):
+ nonlocal callback_exception
+ callback_exception = callback_future.exception()
+
+ f = Future()
+ f.set_exception(Exception('test'))
+ f.add_done_callback(fn)
+ self.assertEqual(('test',), callback_exception.args)
+
+ def test_done_callback_already_cancelled(self):
+ was_cancelled = None
+ def fn(callback_future):
+ nonlocal was_cancelled
+ was_cancelled = callback_future.cancelled()
+
+ f = Future()
+ self.assertTrue(f.cancel())
+ f.add_done_callback(fn)
+ self.assertTrue(was_cancelled)
+
+ def test_repr(self):
+ self.assertRegex(repr(PENDING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=pending>')
+ self.assertRegex(repr(RUNNING_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=running>')
+ self.assertRegex(repr(CANCELLED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(repr(CANCELLED_AND_NOTIFIED_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=cancelled>')
+ self.assertRegex(
+ repr(EXCEPTION_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=finished raised IOError>')
+ self.assertRegex(
+ repr(SUCCESSFUL_FUTURE),
+ '<Future at 0x[0-9a-f]+ state=finished returned int>')
+
+
+ def test_cancel(self):
+ f1 = create_future(state=PENDING)
+ f2 = create_future(state=RUNNING)
+ f3 = create_future(state=CANCELLED)
+ f4 = create_future(state=CANCELLED_AND_NOTIFIED)
+ f5 = create_future(state=FINISHED, exception=IOError())
+ f6 = create_future(state=FINISHED, result=5)
+
+ self.assertTrue(f1.cancel())
+ self.assertEqual(f1._state, CANCELLED)
+
+ self.assertFalse(f2.cancel())
+ self.assertEqual(f2._state, RUNNING)
+
+ self.assertTrue(f3.cancel())
+ self.assertEqual(f3._state, CANCELLED)
+
+ self.assertTrue(f4.cancel())
+ self.assertEqual(f4._state, CANCELLED_AND_NOTIFIED)
+
+ self.assertFalse(f5.cancel())
+ self.assertEqual(f5._state, FINISHED)
+
+ self.assertFalse(f6.cancel())
+ self.assertEqual(f6._state, FINISHED)
+
+ def test_cancelled(self):
+ self.assertFalse(PENDING_FUTURE.cancelled())
+ self.assertFalse(RUNNING_FUTURE.cancelled())
+ self.assertTrue(CANCELLED_FUTURE.cancelled())
+ self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.cancelled())
+ self.assertFalse(EXCEPTION_FUTURE.cancelled())
+ self.assertFalse(SUCCESSFUL_FUTURE.cancelled())
+
+ def test_done(self):
+ self.assertFalse(PENDING_FUTURE.done())
+ self.assertFalse(RUNNING_FUTURE.done())
+ self.assertTrue(CANCELLED_FUTURE.done())
+ self.assertTrue(CANCELLED_AND_NOTIFIED_FUTURE.done())
+ self.assertTrue(EXCEPTION_FUTURE.done())
+ self.assertTrue(SUCCESSFUL_FUTURE.done())
+
+ def test_running(self):
+ self.assertFalse(PENDING_FUTURE.running())
+ self.assertTrue(RUNNING_FUTURE.running())
+ self.assertFalse(CANCELLED_FUTURE.running())
+ self.assertFalse(CANCELLED_AND_NOTIFIED_FUTURE.running())
+ self.assertFalse(EXCEPTION_FUTURE.running())
+ self.assertFalse(SUCCESSFUL_FUTURE.running())
+
+ def test_result_with_timeout(self):
+ self.assertRaises(futures.TimeoutError,
+ PENDING_FUTURE.result, timeout=0)
+ self.assertRaises(futures.TimeoutError,
+ RUNNING_FUTURE.result, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_FUTURE.result, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_AND_NOTIFIED_FUTURE.result, timeout=0)
+ self.assertRaises(IOError, EXCEPTION_FUTURE.result, timeout=0)
+ self.assertEqual(SUCCESSFUL_FUTURE.result(timeout=0), 42)
+
+ def test_result_with_success(self):
+ # TODO(brian@sweetapp.com): This test is timing dependant.
+ def notification():
+ # Wait until the main thread is waiting for the result.
+ time.sleep(1)
+ f1.set_result(42)
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertEqual(f1.result(timeout=5), 42)
+
+ def test_result_with_cancel(self):
+ # TODO(brian@sweetapp.com): This test is timing dependant.
+ def notification():
+ # Wait until the main thread is waiting for the result.
+ time.sleep(1)
+ f1.cancel()
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertRaises(futures.CancelledError, f1.result, timeout=5)
+
+ def test_exception_with_timeout(self):
+ self.assertRaises(futures.TimeoutError,
+ PENDING_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.TimeoutError,
+ RUNNING_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_FUTURE.exception, timeout=0)
+ self.assertRaises(futures.CancelledError,
+ CANCELLED_AND_NOTIFIED_FUTURE.exception, timeout=0)
+ self.assertTrue(isinstance(EXCEPTION_FUTURE.exception(timeout=0),
+ IOError))
+ self.assertEqual(SUCCESSFUL_FUTURE.exception(timeout=0), None)
+
+ def test_exception_with_success(self):
+ def notification():
+ # Wait until the main thread is waiting for the exception.
+ time.sleep(1)
+ with f1._condition:
+ f1._state = FINISHED
+ f1._exception = IOError()
+ f1._condition.notify_all()
+
+ f1 = create_future(state=PENDING)
+ t = threading.Thread(target=notification)
+ t.start()
+
+ self.assertTrue(isinstance(f1.exception(timeout=5), IOError))
+
+@test.support.reap_threads
+def test_main():
+ try:
+ test.support.run_unittest(ProcessPoolExecutorTest,
+ ThreadPoolExecutorTest,
+ ProcessPoolWaitTests,
+ ThreadPoolWaitTests,
+ ProcessPoolAsCompletedTests,
+ ThreadPoolAsCompletedTests,
+ FutureTests,
+ ProcessPoolShutdownTest,
+ ThreadPoolShutdownTest)
+ finally:
+ test.support.reap_children()
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_contains.py b/Lib/test/test_contains.py
index 7138081dc82..a667a16d8c7 100644
--- a/Lib/test/test_contains.py
+++ b/Lib/test/test_contains.py
@@ -1,4 +1,5 @@
-from test.test_support import have_unicode, run_unittest
+from collections import deque
+from test.support import run_unittest
import unittest
@@ -6,7 +7,7 @@ class base_set:
def __init__(self, el):
self.el = el
-class set(base_set):
+class myset(base_set):
def __contains__(self, el):
return self.el == el
@@ -14,11 +15,10 @@ class seq(base_set):
def __getitem__(self, n):
return [self.el][n]
-
class TestContains(unittest.TestCase):
def test_common_tests(self):
a = base_set(1)
- b = set(1)
+ b = myset(1)
c = seq(1)
self.assertIn(1, b)
self.assertNotIn(0, b)
@@ -36,28 +36,6 @@ class TestContains(unittest.TestCase):
self.assertRaises(TypeError, lambda: None in 'abc')
- if have_unicode:
- def test_char_in_unicode(self):
- self.assertIn('c', unicode('abc'))
- self.assertNotIn('d', unicode('abc'))
-
- self.assertIn('', unicode(''))
- self.assertIn(unicode(''), '')
- self.assertIn(unicode(''), unicode(''))
- self.assertIn('', unicode('abc'))
- self.assertIn(unicode(''), 'abc')
- self.assertIn(unicode(''), unicode('abc'))
-
- self.assertRaises(TypeError, lambda: None in unicode('abc'))
-
- # test Unicode char in Unicode
- self.assertIn(unicode('c'), unicode('abc'))
- self.assertNotIn(unicode('d'), unicode('abc'))
-
- # test Unicode char in string
- self.assertIn(unicode('c'), 'abc')
- self.assertNotIn(unicode('d'), 'abc')
-
def test_builtin_sequence_types(self):
# a collection of tests on builtin sequence types
a = range(10)
@@ -78,30 +56,34 @@ class TestContains(unittest.TestCase):
This class is designed to make sure that the contains code
works when the list is modified during the check.
"""
- aList = range(15)
- def __cmp__(self, other):
+ aList = list(range(15))
+ def __eq__(self, other):
if other == 12:
self.aList.remove(12)
self.aList.remove(13)
self.aList.remove(14)
- return 1
+ return 0
self.assertNotIn(Deviant1(), Deviant1.aList)
- class Deviant2:
- """Behaves strangely when compared
-
- This class raises an exception during comparison. That in
- turn causes the comparison to fail with a TypeError.
- """
- def __cmp__(self, other):
- if other == 4:
- raise RuntimeError, "gotcha"
-
- try:
- self.assertNotIn(Deviant2(), a)
- except TypeError:
- pass
+ def test_nonreflexive(self):
+ # containment and equality tests involving elements that are
+ # not necessarily equal to themselves
+
+ class MyNonReflexive(object):
+ def __eq__(self, other):
+ return False
+ def __hash__(self):
+ return 28
+
+ values = float('nan'), 1, None, 'abc', MyNonReflexive()
+ constructors = list, tuple, dict.fromkeys, set, frozenset, deque
+ for constructor in constructors:
+ container = constructor(values)
+ for elem in container:
+ self.assertIn(elem, container)
+ self.assertTrue(container == constructor(values))
+ self.assertTrue(container == container)
def test_main():
diff --git a/Lib/test/test_contextlib.py b/Lib/test/test_contextlib.py
index f28c95eadbc..6e38305123d 100644
--- a/Lib/test/test_contextlib.py
+++ b/Lib/test/test_contextlib.py
@@ -4,7 +4,7 @@ import sys
import tempfile
import unittest
from contextlib import * # Tests __all__
-from test import test_support
+from test import support
try:
import threading
except ImportError:
@@ -72,7 +72,7 @@ class ContextManagerTestCase(unittest.TestCase):
state.append(1)
try:
yield 42
- except ZeroDivisionError, e:
+ except ZeroDivisionError as e:
state.append(e.args[0])
self.assertEqual(state, [1, 42, 999])
with woohoo() as x:
@@ -106,119 +106,6 @@ class ContextManagerTestCase(unittest.TestCase):
baz = self._create_contextmanager_attribs()
self.assertEqual(baz.__doc__, "Whee!")
-class NestedTestCase(unittest.TestCase):
-
- # XXX This needs more work
-
- def test_nested(self):
- @contextmanager
- def a():
- yield 1
- @contextmanager
- def b():
- yield 2
- @contextmanager
- def c():
- yield 3
- with nested(a(), b(), c()) as (x, y, z):
- self.assertEqual(x, 1)
- self.assertEqual(y, 2)
- self.assertEqual(z, 3)
-
- def test_nested_cleanup(self):
- state = []
- @contextmanager
- def a():
- state.append(1)
- try:
- yield 2
- finally:
- state.append(3)
- @contextmanager
- def b():
- state.append(4)
- try:
- yield 5
- finally:
- state.append(6)
- with self.assertRaises(ZeroDivisionError):
- with nested(a(), b()) as (x, y):
- state.append(x)
- state.append(y)
- 1 // 0
- self.assertEqual(state, [1, 4, 2, 5, 6, 3])
-
- def test_nested_right_exception(self):
- @contextmanager
- def a():
- yield 1
- class b(object):
- def __enter__(self):
- return 2
- def __exit__(self, *exc_info):
- try:
- raise Exception()
- except:
- pass
- with self.assertRaises(ZeroDivisionError):
- with nested(a(), b()) as (x, y):
- 1 // 0
- self.assertEqual((x, y), (1, 2))
-
- def test_nested_b_swallows(self):
- @contextmanager
- def a():
- yield
- @contextmanager
- def b():
- try:
- yield
- except:
- # Swallow the exception
- pass
- try:
- with nested(a(), b()):
- 1 // 0
- except ZeroDivisionError:
- self.fail("Didn't swallow ZeroDivisionError")
-
- def test_nested_break(self):
- @contextmanager
- def a():
- yield
- state = 0
- while True:
- state += 1
- with nested(a(), a()):
- break
- state += 10
- self.assertEqual(state, 1)
-
- def test_nested_continue(self):
- @contextmanager
- def a():
- yield
- state = 0
- while state < 3:
- state += 1
- with nested(a(), a()):
- continue
- state += 10
- self.assertEqual(state, 3)
-
- def test_nested_return(self):
- @contextmanager
- def a():
- try:
- yield
- except:
- pass
- def foo():
- with nested(a(), a()):
- return 1
- return 10
- self.assertEqual(foo(), 1)
-
class ClosingTestCase(unittest.TestCase):
# XXX This needs more work
@@ -244,7 +131,7 @@ class ClosingTestCase(unittest.TestCase):
with self.assertRaises(ZeroDivisionError):
with closing(x) as y:
self.assertEqual(x, y)
- 1 // 0
+ 1 / 0
self.assertEqual(state, [1])
class FileContextTestCase(unittest.TestCase):
@@ -262,10 +149,10 @@ class FileContextTestCase(unittest.TestCase):
with open(tfn, "r") as f:
self.assertFalse(f.closed)
self.assertEqual(f.read(), "Booh\n")
- 1 // 0
+ 1 / 0
self.assertTrue(f.closed)
finally:
- test_support.unlink(tfn)
+ support.unlink(tfn)
@unittest.skipUnless(threading, 'Threading required for this test.')
class LockContextTestCase(unittest.TestCase):
@@ -278,7 +165,7 @@ class LockContextTestCase(unittest.TestCase):
with self.assertRaises(ZeroDivisionError):
with lock:
self.assertTrue(locked())
- 1 // 0
+ 1 / 0
self.assertFalse(locked())
def testWithLock(self):
@@ -315,12 +202,177 @@ class LockContextTestCase(unittest.TestCase):
return True
self.boilerPlate(lock, locked)
+
+class mycontext(ContextDecorator):
+ started = False
+ exc = None
+ catch = False
+
+ def __enter__(self):
+ self.started = True
+ return self
+
+ def __exit__(self, *exc):
+ self.exc = exc
+ return self.catch
+
+
+class TestContextDecorator(unittest.TestCase):
+
+ def test_contextdecorator(self):
+ context = mycontext()
+ with context as result:
+ self.assertIs(result, context)
+ self.assertTrue(context.started)
+
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_contextdecorator_with_exception(self):
+ context = mycontext()
+
+ with self.assertRaisesRegex(NameError, 'foo'):
+ with context:
+ raise NameError('foo')
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+ context = mycontext()
+ context.catch = True
+ with context:
+ raise NameError('foo')
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+
+ def test_decorator(self):
+ context = mycontext()
+
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ test()
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_decorator_with_exception(self):
+ context = mycontext()
+
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ raise NameError('foo')
+
+ with self.assertRaisesRegex(NameError, 'foo'):
+ test()
+ self.assertIsNotNone(context.exc)
+ self.assertIs(context.exc[0], NameError)
+
+
+ def test_decorating_method(self):
+ context = mycontext()
+
+ class Test(object):
+
+ @context
+ def method(self, a, b, c=None):
+ self.a = a
+ self.b = b
+ self.c = c
+
+ # these tests are for argument passing when used as a decorator
+ test = Test()
+ test.method(1, 2)
+ self.assertEqual(test.a, 1)
+ self.assertEqual(test.b, 2)
+ self.assertEqual(test.c, None)
+
+ test = Test()
+ test.method('a', 'b', 'c')
+ self.assertEqual(test.a, 'a')
+ self.assertEqual(test.b, 'b')
+ self.assertEqual(test.c, 'c')
+
+ test = Test()
+ test.method(a=1, b=2)
+ self.assertEqual(test.a, 1)
+ self.assertEqual(test.b, 2)
+
+
+ def test_typo_enter(self):
+ class mycontext(ContextDecorator):
+ def __unter__(self):
+ pass
+ def __exit__(self, *exc):
+ pass
+
+ with self.assertRaises(AttributeError):
+ with mycontext():
+ pass
+
+
+ def test_typo_exit(self):
+ class mycontext(ContextDecorator):
+ def __enter__(self):
+ pass
+ def __uxit__(self, *exc):
+ pass
+
+ with self.assertRaises(AttributeError):
+ with mycontext():
+ pass
+
+
+ def test_contextdecorator_as_mixin(self):
+ class somecontext(object):
+ started = False
+ exc = None
+
+ def __enter__(self):
+ self.started = True
+ return self
+
+ def __exit__(self, *exc):
+ self.exc = exc
+
+ class mycontext(somecontext, ContextDecorator):
+ pass
+
+ context = mycontext()
+ @context
+ def test():
+ self.assertIsNone(context.exc)
+ self.assertTrue(context.started)
+ test()
+ self.assertEqual(context.exc, (None, None, None))
+
+
+ def test_contextmanager_as_decorator(self):
+ @contextmanager
+ def woohoo(y):
+ state.append(y)
+ yield
+ state.append(999)
+
+ state = []
+ @woohoo(1)
+ def test(x):
+ self.assertEqual(state, [1])
+ state.append(x)
+ test('something')
+ self.assertEqual(state, [1, 'something', 999])
+
+ # Issue #11647: Ensure the decorated function is 'reusable'
+ state = []
+ test('something else')
+ self.assertEqual(state, [1, 'something else', 999])
+
+
# This is needed to make the test actually run under regrtest.py!
def test_main():
- with test_support.check_warnings(("With-statements now directly support "
- "multiple context managers",
- DeprecationWarning)):
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_cookie.py b/Lib/test/test_cookie.py
deleted file mode 100644
index 816133e4972..00000000000
--- a/Lib/test/test_cookie.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# Simple test suite for Cookie.py
-
-from test.test_support import run_unittest, run_doctest, check_warnings
-import unittest
-import Cookie
-
-
-class CookieTests(unittest.TestCase):
- # Currently this only tests SimpleCookie
- def test_basic(self):
- cases = [
- { 'data': 'chips=ahoy; vienna=finger',
- 'dict': {'chips':'ahoy', 'vienna':'finger'},
- 'repr': "<SimpleCookie: chips='ahoy' vienna='finger'>",
- 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger',
- },
-
- { 'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
- 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'},
- 'repr': '''<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\\n;'>''',
- 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
- },
-
- # Check illegal cookies that have an '=' char in an unquoted value
- { 'data': 'keebler=E=mc2',
- 'dict': {'keebler' : 'E=mc2'},
- 'repr': "<SimpleCookie: keebler='E=mc2'>",
- 'output': 'Set-Cookie: keebler=E=mc2',
- }
- ]
-
- for case in cases:
- C = Cookie.SimpleCookie()
- C.load(case['data'])
- self.assertEqual(repr(C), case['repr'])
- self.assertEqual(C.output(sep='\n'), case['output'])
- for k, v in sorted(case['dict'].iteritems()):
- self.assertEqual(C[k].value, v)
-
- def test_load(self):
- C = Cookie.SimpleCookie()
- C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
-
- self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE')
- self.assertEqual(C['Customer']['version'], '1')
- self.assertEqual(C['Customer']['path'], '/acme')
-
- self.assertEqual(C.output(['path']),
- 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
- self.assertEqual(C.js_output(), r"""
- <script type="text/javascript">
- <!-- begin hiding
- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
- // end hiding -->
- </script>
- """)
- self.assertEqual(C.js_output(['path']), r"""
- <script type="text/javascript">
- <!-- begin hiding
- document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
- // end hiding -->
- </script>
- """)
-
- # loading 'expires'
- C = Cookie.SimpleCookie()
- C.load('Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMT')
- self.assertEqual(C['Customer']['expires'],
- 'Wed, 01 Jan 2010 00:00:00 GMT')
- C = Cookie.SimpleCookie()
- C.load('Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMT')
- self.assertEqual(C['Customer']['expires'],
- 'Wed, 01 Jan 98 00:00:00 GMT')
-
- def test_extended_encode(self):
- # Issue 9824: some browsers don't follow the standard; we now
- # encode , and ; to keep them from tripping up.
- C = Cookie.SimpleCookie()
- C['val'] = "some,funky;stuff"
- self.assertEqual(C.output(['val']),
- 'Set-Cookie: val="some\\054funky\\073stuff"')
-
- def test_quoted_meta(self):
- # Try cookie with quoted meta-data
- C = Cookie.SimpleCookie()
- C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
- self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE')
- self.assertEqual(C['Customer']['version'], '1')
- self.assertEqual(C['Customer']['path'], '/acme')
-
-def test_main():
- run_unittest(CookieTests)
- if Cookie.__doc__ is not None:
- with check_warnings(('.+Cookie class is insecure; do not use it',
- DeprecationWarning)):
- run_doctest(Cookie)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_copy.py b/Lib/test/test_copy.py
index 6b64f10112e..a84c109b87b 100644
--- a/Lib/test/test_copy.py
+++ b/Lib/test/test_copy.py
@@ -1,11 +1,16 @@
"""Unit tests for the copy module."""
import copy
-import copy_reg
+import copyreg
import weakref
+from operator import le, lt, ge, gt, eq, ne
import unittest
-from test import test_support
+from test import support
+
+order_comparisons = le, lt, ge, gt
+equality_comparisons = eq, ne
+comparisons = order_comparisons + equality_comparisons
class TestCopy(unittest.TestCase):
@@ -43,7 +48,7 @@ class TestCopy(unittest.TestCase):
return (C, (obj.foo,))
x = C(42)
self.assertRaises(TypeError, copy.copy, x)
- copy_reg.pickle(C, pickle_C, C)
+ copyreg.pickle(C, pickle_C, C)
y = copy.copy(x)
def test_copy_reduce_ex(self):
@@ -51,7 +56,7 @@ class TestCopy(unittest.TestCase):
def __reduce_ex__(self, proto):
return ""
def __reduce__(self):
- raise test_support.TestFailed, "shouldn't call this"
+ raise support.TestFailed("shouldn't call this")
x = C()
y = copy.copy(x)
self.assertTrue(y is x)
@@ -68,7 +73,7 @@ class TestCopy(unittest.TestCase):
class C(object):
def __getattribute__(self, name):
if name.startswith("__reduce"):
- raise AttributeError, name
+ raise AttributeError(name)
return object.__getattribute__(self, name)
x = C()
self.assertRaises(copy.Error, copy.copy, x)
@@ -82,9 +87,9 @@ class TestCopy(unittest.TestCase):
pass
def f():
pass
- tests = [None, 42, 2L**100, 3.14, True, False, 1j,
- "hello", u"hello\u1234", f.func_code,
- NewStyle, xrange(10), Classic, max]
+ tests = [None, 42, 2**100, 3.14, True, False, 1j,
+ "hello", "hello\u1234", f.__code__,
+ NewStyle, range(10), Classic, max]
for x in tests:
self.assertTrue(copy.copy(x) is x, repr(x))
@@ -104,8 +109,8 @@ class TestCopy(unittest.TestCase):
class C:
def __init__(self, foo):
self.foo = foo
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -115,8 +120,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __copy__(self):
return C(self.foo)
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -126,8 +131,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __getinitargs__(self):
return (self.foo,)
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -137,8 +142,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __getstate__(self):
return {"foo": self.foo}
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -148,8 +153,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __setstate__(self, state):
self.foo = state["foo"]
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -161,8 +166,8 @@ class TestCopy(unittest.TestCase):
return self.foo
def __setstate__(self, state):
self.foo = state
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C(42)
self.assertEqual(copy.copy(x), x)
@@ -191,8 +196,8 @@ class TestCopy(unittest.TestCase):
# type.
class Meta(type):
pass
- class C:
- __metaclass__ = Meta
+ class C(metaclass=Meta):
+ pass
self.assertEqual(copy.deepcopy(C), C)
def test_deepcopy_deepcopy(self):
@@ -216,7 +221,7 @@ class TestCopy(unittest.TestCase):
return (C, (obj.foo,))
x = C(42)
self.assertRaises(TypeError, copy.deepcopy, x)
- copy_reg.pickle(C, pickle_C, C)
+ copyreg.pickle(C, pickle_C, C)
y = copy.deepcopy(x)
def test_deepcopy_reduce_ex(self):
@@ -224,7 +229,7 @@ class TestCopy(unittest.TestCase):
def __reduce_ex__(self, proto):
return ""
def __reduce__(self):
- raise test_support.TestFailed, "shouldn't call this"
+ raise support.TestFailed("shouldn't call this")
x = C()
y = copy.deepcopy(x)
self.assertTrue(y is x)
@@ -241,7 +246,7 @@ class TestCopy(unittest.TestCase):
class C(object):
def __getattribute__(self, name):
if name.startswith("__reduce"):
- raise AttributeError, name
+ raise AttributeError(name)
return object.__getattribute__(self, name)
x = C()
self.assertRaises(copy.Error, copy.deepcopy, x)
@@ -255,9 +260,9 @@ class TestCopy(unittest.TestCase):
pass
def f():
pass
- tests = [None, 42, 2L**100, 3.14, True, False, 1j,
- "hello", u"hello\u1234", f.func_code,
- NewStyle, xrange(10), Classic, max]
+ tests = [None, 42, 2**100, 3.14, True, False, 1j,
+ "hello", "hello\u1234", f.__code__,
+ NewStyle, range(10), Classic, max]
for x in tests:
self.assertTrue(copy.deepcopy(x) is x, repr(x))
@@ -272,7 +277,8 @@ class TestCopy(unittest.TestCase):
x = []
x.append(x)
y = copy.deepcopy(x)
- self.assertRaises(RuntimeError, cmp, y, x)
+ for op in comparisons:
+ self.assertRaises(RuntimeError, op, y, x)
self.assertTrue(y is not x)
self.assertTrue(y[0] is y)
self.assertEqual(len(y), 1)
@@ -288,7 +294,8 @@ class TestCopy(unittest.TestCase):
x = ([],)
x[0].append(x)
y = copy.deepcopy(x)
- self.assertRaises(RuntimeError, cmp, y, x)
+ for op in comparisons:
+ self.assertRaises(RuntimeError, op, y, x)
self.assertTrue(y is not x)
self.assertTrue(y[0] is not x[0])
self.assertTrue(y[0][0] is y)
@@ -304,7 +311,10 @@ class TestCopy(unittest.TestCase):
x = {}
x['foo'] = x
y = copy.deepcopy(x)
- self.assertRaises(RuntimeError, cmp, y, x)
+ for op in order_comparisons:
+ self.assertRaises(TypeError, op, y, x)
+ for op in equality_comparisons:
+ self.assertRaises(RuntimeError, op, y, x)
self.assertTrue(y is not x)
self.assertTrue(y['foo'] is y)
self.assertEqual(len(y), 1)
@@ -319,8 +329,8 @@ class TestCopy(unittest.TestCase):
class C:
def __init__(self, foo):
self.foo = foo
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -332,8 +342,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __deepcopy__(self, memo):
return C(copy.deepcopy(self.foo, memo))
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -346,8 +356,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __getinitargs__(self):
return (self.foo,)
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -360,8 +370,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __getstate__(self):
return {"foo": self.foo}
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -374,8 +384,8 @@ class TestCopy(unittest.TestCase):
self.foo = foo
def __setstate__(self, state):
self.foo = state["foo"]
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -390,8 +400,8 @@ class TestCopy(unittest.TestCase):
return self.foo
def __setstate__(self, state):
self.foo = state
- def __cmp__(self, other):
- return cmp(self.foo, other.foo)
+ def __eq__(self, other):
+ return self.foo == other.foo
x = C([42])
y = copy.deepcopy(x)
self.assertEqual(y, x)
@@ -434,9 +444,8 @@ class TestCopy(unittest.TestCase):
class C(object):
def __reduce__(self):
return (C, (), self.__dict__)
- def __cmp__(self, other):
- return cmp(self.__dict__, other.__dict__)
- __hash__ = None # Silence Py3k warning
+ def __eq__(self, other):
+ return self.__dict__ == other.__dict__
x = C()
x.foo = [42]
y = copy.copy(x)
@@ -451,9 +460,8 @@ class TestCopy(unittest.TestCase):
return (C, (), self.__dict__)
def __setstate__(self, state):
self.__dict__.update(state)
- def __cmp__(self, other):
- return cmp(self.__dict__, other.__dict__)
- __hash__ = None # Silence Py3k warning
+ def __eq__(self, other):
+ return self.__dict__ == other.__dict__
x = C()
x.foo = [42]
y = copy.copy(x)
@@ -477,10 +485,9 @@ class TestCopy(unittest.TestCase):
class C(list):
def __reduce__(self):
return (C, (), self.__dict__, iter(self))
- def __cmp__(self, other):
- return (cmp(list(self), list(other)) or
- cmp(self.__dict__, other.__dict__))
- __hash__ = None # Silence Py3k warning
+ def __eq__(self, other):
+ return (list(self) == list(other) and
+ self.__dict__ == other.__dict__)
x = C([[1, 2], 3])
y = copy.copy(x)
self.assertEqual(x, y)
@@ -494,11 +501,10 @@ class TestCopy(unittest.TestCase):
def test_reduce_5tuple(self):
class C(dict):
def __reduce__(self):
- return (C, (), self.__dict__, None, self.iteritems())
- def __cmp__(self, other):
- return (cmp(dict(self), list(dict)) or
- cmp(self.__dict__, other.__dict__))
- __hash__ = None # Silence Py3k warning
+ return (C, (), self.__dict__, None, self.items())
+ def __eq__(self, other):
+ return (dict(self) == dict(other) and
+ self.__dict__ == other.__dict__)
x = C([("foo", [1, 2]), ("bar", 3)])
y = copy.copy(x)
self.assertEqual(x, y)
@@ -532,9 +538,9 @@ class TestCopy(unittest.TestCase):
if not d:
d = {}
self._keys = list(d.keys())
- dict.__init__(self, d)
+ super().__init__(d)
def __setitem__(self, key, item):
- dict.__setitem__(self, key, item)
+ super().__setitem__(key, item)
if key not in self._keys:
self._keys.append(key)
x = C(d={'foo':0})
@@ -589,7 +595,7 @@ class TestCopy(unittest.TestCase):
def test_getstate_exc(self):
class EvilState(object):
def __getstate__(self):
- raise ValueError, "ain't got no stickin' state"
+ raise ValueError("ain't got no stickin' state")
self.assertRaises(ValueError, copy.copy, EvilState())
def test_copy_function(self):
@@ -626,7 +632,7 @@ class TestCopy(unittest.TestCase):
def _check_copy_weakdict(self, _dicttype):
class C(object):
pass
- a, b, c, d = [C() for i in xrange(4)]
+ a, b, c, d = [C() for i in range(4)]
u = _dicttype()
u[a] = b
u[c] = d
@@ -653,7 +659,7 @@ class TestCopy(unittest.TestCase):
class C(object):
def __init__(self, i):
self.i = i
- a, b, c, d = [C(i) for i in xrange(4)]
+ a, b, c, d = [C(i) for i in range(4)]
u = weakref.WeakKeyDictionary()
u[a] = b
u[c] = d
@@ -672,7 +678,7 @@ class TestCopy(unittest.TestCase):
class C(object):
def __init__(self, i):
self.i = i
- a, b, c, d = [C(i) for i in xrange(4)]
+ a, b, c, d = [C(i) for i in range(4)]
u = weakref.WeakValueDictionary()
u[a] = b
u[c] = d
@@ -699,14 +705,14 @@ class TestCopy(unittest.TestCase):
f.b = f.m
g = copy.deepcopy(f)
self.assertEqual(g.m, g.b)
- self.assertTrue(g.b.im_self is g)
+ self.assertTrue(g.b.__self__ is g)
g.b()
def global_foo(x, y): return x+y
def test_main():
- test_support.run_unittest(TestCopy)
+ support.run_unittest(TestCopy)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_copy_reg.py b/Lib/test/test_copyreg.py
index 8cdb8b7d2ab..abe0748f851 100644
--- a/Lib/test/test_copy_reg.py
+++ b/Lib/test/test_copyreg.py
@@ -1,7 +1,7 @@
-import copy_reg
+import copyreg
import unittest
-from test import test_support
+from test import support
from test.pickletester import ExtensionSaver
class C:
@@ -27,15 +27,15 @@ class WithInherited(WithSingleString):
class CopyRegTestCase(unittest.TestCase):
def test_class(self):
- self.assertRaises(TypeError, copy_reg.pickle,
+ self.assertRaises(TypeError, copyreg.pickle,
C, None, None)
def test_noncallable_reduce(self):
- self.assertRaises(TypeError, copy_reg.pickle,
+ self.assertRaises(TypeError, copyreg.pickle,
type(1), "not a callable")
def test_noncallable_constructor(self):
- self.assertRaises(TypeError, copy_reg.pickle,
+ self.assertRaises(TypeError, copyreg.pickle,
type(1), int, "not a callable")
def test_bool(self):
@@ -47,42 +47,42 @@ class CopyRegTestCase(unittest.TestCase):
e = ExtensionSaver(code)
try:
# Shouldn't be in registry now.
- self.assertRaises(ValueError, copy_reg.remove_extension,
+ self.assertRaises(ValueError, copyreg.remove_extension,
mod, func, code)
- copy_reg.add_extension(mod, func, code)
+ copyreg.add_extension(mod, func, code)
# Should be in the registry.
- self.assertTrue(copy_reg._extension_registry[mod, func] == code)
- self.assertTrue(copy_reg._inverted_registry[code] == (mod, func))
+ self.assertTrue(copyreg._extension_registry[mod, func] == code)
+ self.assertTrue(copyreg._inverted_registry[code] == (mod, func))
# Shouldn't be in the cache.
- self.assertNotIn(code, copy_reg._extension_cache)
+ self.assertNotIn(code, copyreg._extension_cache)
# Redundant registration should be OK.
- copy_reg.add_extension(mod, func, code) # shouldn't blow up
+ copyreg.add_extension(mod, func, code) # shouldn't blow up
# Conflicting code.
- self.assertRaises(ValueError, copy_reg.add_extension,
+ self.assertRaises(ValueError, copyreg.add_extension,
mod, func, code + 1)
- self.assertRaises(ValueError, copy_reg.remove_extension,
+ self.assertRaises(ValueError, copyreg.remove_extension,
mod, func, code + 1)
# Conflicting module name.
- self.assertRaises(ValueError, copy_reg.add_extension,
+ self.assertRaises(ValueError, copyreg.add_extension,
mod[1:], func, code )
- self.assertRaises(ValueError, copy_reg.remove_extension,
+ self.assertRaises(ValueError, copyreg.remove_extension,
mod[1:], func, code )
# Conflicting function name.
- self.assertRaises(ValueError, copy_reg.add_extension,
+ self.assertRaises(ValueError, copyreg.add_extension,
mod, func[1:], code)
- self.assertRaises(ValueError, copy_reg.remove_extension,
+ self.assertRaises(ValueError, copyreg.remove_extension,
mod, func[1:], code)
# Can't remove one that isn't registered at all.
- if code + 1 not in copy_reg._inverted_registry:
- self.assertRaises(ValueError, copy_reg.remove_extension,
+ if code + 1 not in copyreg._inverted_registry:
+ self.assertRaises(ValueError, copyreg.remove_extension,
mod[1:], func[1:], code + 1)
finally:
e.restore()
# Shouldn't be there anymore.
- self.assertNotIn((mod, func), copy_reg._extension_registry)
- # The code *may* be in copy_reg._extension_registry, though, if
+ self.assertNotIn((mod, func), copyreg._extension_registry)
+ # The code *may* be in copyreg._extension_registry, though, if
# we happened to pick on a registered code. So don't check for
# that.
@@ -90,31 +90,31 @@ class CopyRegTestCase(unittest.TestCase):
for code in 1, 0x7fffffff:
e = ExtensionSaver(code)
try:
- copy_reg.add_extension(mod, func, code)
- copy_reg.remove_extension(mod, func, code)
+ copyreg.add_extension(mod, func, code)
+ copyreg.remove_extension(mod, func, code)
finally:
e.restore()
# Ensure invalid codes blow up.
- for code in -1, 0, 0x80000000L:
- self.assertRaises(ValueError, copy_reg.add_extension,
+ for code in -1, 0, 0x80000000:
+ self.assertRaises(ValueError, copyreg.add_extension,
mod, func, code)
def test_slotnames(self):
- self.assertEqual(copy_reg._slotnames(WithoutSlots), [])
- self.assertEqual(copy_reg._slotnames(WithWeakref), [])
+ self.assertEqual(copyreg._slotnames(WithoutSlots), [])
+ self.assertEqual(copyreg._slotnames(WithWeakref), [])
expected = ['_WithPrivate__spam']
- self.assertEqual(copy_reg._slotnames(WithPrivate), expected)
- self.assertEqual(copy_reg._slotnames(WithSingleString), ['spam'])
+ self.assertEqual(copyreg._slotnames(WithPrivate), expected)
+ self.assertEqual(copyreg._slotnames(WithSingleString), ['spam'])
expected = ['eggs', 'spam']
expected.sort()
- result = copy_reg._slotnames(WithInherited)
+ result = copyreg._slotnames(WithInherited)
result.sort()
self.assertEqual(result, expected)
def test_main():
- test_support.run_unittest(CopyRegTestCase)
+ support.run_unittest(CopyRegTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_cpickle.py b/Lib/test/test_cpickle.py
deleted file mode 100644
index c240669873a..00000000000
--- a/Lib/test/test_cpickle.py
+++ /dev/null
@@ -1,139 +0,0 @@
-import cPickle, unittest
-from cStringIO import StringIO
-from test.pickletester import AbstractPickleTests, AbstractPickleModuleTests
-from test.pickletester import AbstractPicklerUnpicklerObjectTests
-from test import test_support
-
-class cPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
-
- def setUp(self):
- self.dumps = cPickle.dumps
- self.loads = cPickle.loads
-
- error = cPickle.BadPickleGet
- module = cPickle
-
-class cPicklePicklerTests(AbstractPickleTests):
-
- def dumps(self, arg, proto=0):
- f = StringIO()
- p = cPickle.Pickler(f, proto)
- p.dump(arg)
- f.seek(0)
- return f.read()
-
- def loads(self, buf):
- f = StringIO(buf)
- p = cPickle.Unpickler(f)
- return p.load()
-
- error = cPickle.BadPickleGet
-
-class cPickleListPicklerTests(AbstractPickleTests):
-
- def dumps(self, arg, proto=0):
- p = cPickle.Pickler(proto)
- p.dump(arg)
- return p.getvalue()
-
- def loads(self, *args):
- f = StringIO(args[0])
- p = cPickle.Unpickler(f)
- return p.load()
-
- error = cPickle.BadPickleGet
-
-class cPickleFastPicklerTests(AbstractPickleTests):
-
- def dumps(self, arg, proto=0):
- f = StringIO()
- p = cPickle.Pickler(f, proto)
- p.fast = 1
- p.dump(arg)
- f.seek(0)
- return f.read()
-
- def loads(self, *args):
- f = StringIO(args[0])
- p = cPickle.Unpickler(f)
- return p.load()
-
- error = cPickle.BadPickleGet
-
- def test_recursive_list(self):
- self.assertRaises(ValueError,
- AbstractPickleTests.test_recursive_list,
- self)
-
- def test_recursive_tuple(self):
- self.assertRaises(ValueError,
- AbstractPickleTests.test_recursive_tuple,
- self)
-
- def test_recursive_inst(self):
- self.assertRaises(ValueError,
- AbstractPickleTests.test_recursive_inst,
- self)
-
- def test_recursive_dict(self):
- self.assertRaises(ValueError,
- AbstractPickleTests.test_recursive_dict,
- self)
-
- def test_recursive_multi(self):
- self.assertRaises(ValueError,
- AbstractPickleTests.test_recursive_multi,
- self)
-
- def test_nonrecursive_deep(self):
- # If it's not cyclic, it should pickle OK even if the nesting
- # depth exceeds PY_CPICKLE_FAST_LIMIT. That happens to be
- # 50 today. Jack Jansen reported stack overflow on Mac OS 9
- # at 64.
- a = []
- for i in range(60):
- a = [a]
- b = self.loads(self.dumps(a))
- self.assertEqual(a, b)
-
-class cPicklePicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
-
- pickler_class = cPickle.Pickler
- unpickler_class = cPickle.Unpickler
-
-
-class Node(object):
- pass
-
-class cPickleDeepRecursive(unittest.TestCase):
- def test_issue2702(self):
- # This should raise a RecursionLimit but in some
- # platforms (FreeBSD, win32) sometimes raises KeyError instead,
- # or just silently terminates the interpreter (=crashes).
- nodes = [Node() for i in range(500)]
- for n in nodes:
- n.connections = list(nodes)
- n.connections.remove(n)
- self.assertRaises((AttributeError, RuntimeError), cPickle.dumps, n)
-
- def test_issue3179(self):
- # Safe test, because I broke this case when fixing the
- # behaviour for the previous test.
- res=[]
- for x in range(1,2000):
- res.append(dict(doc=x, similar=[]))
- cPickle.dumps(res)
-
-
-def test_main():
- test_support.run_unittest(
- cPickleTests,
- cPicklePicklerTests,
- cPickleListPicklerTests,
- cPickleFastPicklerTests,
- cPickleDeepRecursive,
- cPicklePicklerUnpicklerObjectTests,
- )
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_cprofile.py b/Lib/test/test_cprofile.py
index af3fe62a9a6..ae17c2b6948 100644
--- a/Lib/test/test_cprofile.py
+++ b/Lib/test/test_cprofile.py
@@ -1,7 +1,7 @@
"""Test suite for the cProfile module."""
import sys
-from test.test_support import run_unittest, TESTFN, unlink
+from test.support import run_unittest, TESTFN, unlink
# rip off all interesting stuff from test_profile
import cProfile
@@ -9,21 +9,25 @@ from test.test_profile import ProfileTest, regenerate_expected_output
class CProfileTest(ProfileTest):
profilerclass = cProfile.Profile
- expected_list_sort_output = "{method 'sort' of 'list' objects}"
+ expected_max_output = "{built-in method max}"
+
+ def get_expected_output(self):
+ return _ProfileOutput
# Issue 3895.
def test_bad_counter_during_dealloc(self):
import _lsprof
# Must use a file as StringIO doesn't trigger the bug.
- sys.stderr = open(TESTFN, 'w')
- try:
- obj = _lsprof.Profiler(lambda: int)
- obj.enable()
- obj = _lsprof.Profiler(1)
- obj.disable()
- finally:
- sys.stderr = sys.__stderr__
- unlink(TESTFN)
+ with open(TESTFN, 'w') as file:
+ sys.stderr = file
+ try:
+ obj = _lsprof.Profiler(lambda: int)
+ obj.enable()
+ obj = _lsprof.Profiler(1)
+ obj.disable()
+ finally:
+ sys.stderr = sys.__stderr__
+ unlink(TESTFN)
def test_main():
@@ -38,13 +42,8 @@ def main():
# Don't remove this comment. Everything below it is auto-generated.
#--cut--------------------------------------------------------------------------
-CProfileTest.expected_output['print_stats'] = """\
- 126 function calls (106 primitive calls) in 1.000 seconds
-
- Ordered by: standard name
-
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.000 0.000 1.000 1.000 <string>:1(<module>)
+_ProfileOutput = {}
+_ProfileOutput['print_stats'] = """\
28 0.028 0.001 0.028 0.001 profilee.py:110(__getattr__)
1 0.270 0.270 1.000 1.000 profilee.py:25(testfunc)
23/3 0.150 0.007 0.170 0.057 profilee.py:35(factorial)
@@ -53,23 +52,9 @@ CProfileTest.expected_output['print_stats'] = """\
4 0.116 0.029 0.120 0.030 profilee.py:73(helper1)
2 0.000 0.000 0.140 0.070 profilee.py:84(helper2_indirect)
8 0.312 0.039 0.400 0.050 profilee.py:88(helper2)
- 8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper)
- 12 0.000 0.000 0.012 0.001 {hasattr}
- 4 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- 8 0.000 0.000 0.000 0.000 {range}
- 4 0.000 0.000 0.000 0.000 {sys.exc_info}
-
-
-"""
-CProfileTest.expected_output['print_callers'] = """\
- Ordered by: standard name
-
-Function was called by...
- ncalls tottime cumtime
-<string>:1(<module>) <-
+ 8 0.064 0.008 0.080 0.010 profilee.py:98(subhelper)"""
+_ProfileOutput['print_callers'] = """\
profilee.py:110(__getattr__) <- 16 0.016 0.016 profilee.py:98(subhelper)
- 12 0.012 0.012 {hasattr}
profilee.py:25(testfunc) <- 1 0.270 1.000 <string>:1(<module>)
profilee.py:35(factorial) <- 1 0.014 0.130 profilee.py:25(testfunc)
20/3 0.130 0.147 profilee.py:35(factorial)
@@ -81,20 +66,11 @@ profilee.py:84(helper2_indirect) <- 2 0.000 0.140
profilee.py:88(helper2) <- 6 0.234 0.300 profilee.py:55(helper)
2 0.078 0.100 profilee.py:84(helper2_indirect)
profilee.py:98(subhelper) <- 8 0.064 0.080 profilee.py:88(helper2)
-{hasattr} <- 4 0.000 0.004 profilee.py:73(helper1)
+{built-in method exc_info} <- 4 0.000 0.000 profilee.py:73(helper1)
+{built-in method hasattr} <- 4 0.000 0.004 profilee.py:73(helper1)
8 0.000 0.008 profilee.py:88(helper2)
-{method 'append' of 'list' objects} <- 4 0.000 0.000 profilee.py:73(helper1)
-{method 'disable' of '_lsprof.Profiler' objects} <-
-{range} <- 8 0.000 0.000 profilee.py:98(subhelper)
-{sys.exc_info} <- 4 0.000 0.000 profilee.py:73(helper1)
-
-
-"""
-CProfileTest.expected_output['print_callees'] = """\
- Ordered by: standard name
-
-Function called...
- ncalls tottime cumtime
+{method 'append' of 'list' objects} <- 4 0.000 0.000 profilee.py:73(helper1)"""
+_ProfileOutput['print_callees'] = """\
<string>:1(<module>) -> 1 0.270 1.000 profilee.py:25(testfunc)
profilee.py:110(__getattr__) ->
profilee.py:25(testfunc) -> 1 0.014 0.130 profilee.py:35(factorial)
@@ -105,23 +81,12 @@ profilee.py:48(mul) ->
profilee.py:55(helper) -> 4 0.116 0.120 profilee.py:73(helper1)
2 0.000 0.140 profilee.py:84(helper2_indirect)
6 0.234 0.300 profilee.py:88(helper2)
-profilee.py:73(helper1) -> 4 0.000 0.004 {hasattr}
- 4 0.000 0.000 {method 'append' of 'list' objects}
- 4 0.000 0.000 {sys.exc_info}
+profilee.py:73(helper1) -> 4 0.000 0.000 {built-in method exc_info}
profilee.py:84(helper2_indirect) -> 2 0.006 0.040 profilee.py:35(factorial)
2 0.078 0.100 profilee.py:88(helper2)
profilee.py:88(helper2) -> 8 0.064 0.080 profilee.py:98(subhelper)
- 8 0.000 0.008 {hasattr}
profilee.py:98(subhelper) -> 16 0.016 0.016 profilee.py:110(__getattr__)
- 8 0.000 0.000 {range}
-{hasattr} -> 12 0.012 0.012 profilee.py:110(__getattr__)
-{method 'append' of 'list' objects} ->
-{method 'disable' of '_lsprof.Profiler' objects} ->
-{range} ->
-{sys.exc_info} ->
-
-
-"""
+{built-in method hasattr} -> 12 0.012 0.012 profilee.py:110(__getattr__)"""
if __name__ == "__main__":
main()
diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py
index 4db200d4031..2adb28d7cea 100644
--- a/Lib/test/test_crypt.py
+++ b/Lib/test/test_crypt.py
@@ -1,17 +1,17 @@
-from test import test_support
+from test import support
import unittest
-crypt = test_support.import_module('crypt')
+crypt = support.import_module('crypt')
class CryptTestCase(unittest.TestCase):
def test_crypt(self):
c = crypt.crypt('mypassword', 'ab')
- if test_support.verbose:
- print 'Test encryption: ', c
+ if support.verbose:
+ print('Test encryption: ', c)
def test_main():
- test_support.run_unittest(CryptTestCase)
+ support.run_unittest(CryptTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_csv.py b/Lib/test/test_csv.py
index 53ca5ab12f1..55796a204ad 100644
--- a/Lib/test/test_csv.py
+++ b/Lib/test/test_csv.py
@@ -1,16 +1,15 @@
-# -*- coding: iso-8859-1 -*-
# Copyright (C) 2001,2002 Python Software Foundation
# csv package unit tests
+import io
import sys
import os
import unittest
-from StringIO import StringIO
-import tempfile
+from io import StringIO
+from tempfile import TemporaryFile
import csv
import gc
-import io
-from test import test_support
+from test import support
class Test_Csv(unittest.TestCase):
"""
@@ -54,8 +53,8 @@ class Test_Csv(unittest.TestCase):
self.assertEqual(obj.dialect.skipinitialspace, False)
self.assertEqual(obj.dialect.strict, False)
# Try deleting or changing attributes (they are read-only)
- self.assertRaises(TypeError, delattr, obj.dialect, 'delimiter')
- self.assertRaises(TypeError, setattr, obj.dialect, 'delimiter', ':')
+ self.assertRaises(AttributeError, delattr, obj.dialect, 'delimiter')
+ self.assertRaises(AttributeError, setattr, obj.dialect, 'delimiter', ':')
self.assertRaises(AttributeError, delattr, obj.dialect, 'quoting')
self.assertRaises(AttributeError, setattr, obj.dialect,
'quoting', None)
@@ -118,17 +117,12 @@ class Test_Csv(unittest.TestCase):
def _write_test(self, fields, expect, **kwargs):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, **kwargs)
writer.writerow(fields)
fileobj.seek(0)
self.assertEqual(fileobj.read(),
expect + writer.dialect.lineterminator)
- finally:
- fileobj.close()
- os.unlink(name)
def test_write_arg_valid(self):
self.assertRaises(csv.Error, self._write_test, None, '')
@@ -195,29 +189,13 @@ class Test_Csv(unittest.TestCase):
raise IOError
writer = csv.writer(BrokenFile())
self.assertRaises(IOError, writer.writerows, [['a']])
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj)
self.assertRaises(TypeError, writer.writerows, None)
writer.writerows([['a','b'],['c','d']])
fileobj.seek(0)
self.assertEqual(fileobj.read(), "a,b\r\nc,d\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
-
- def test_write_float(self):
- # Issue 13573: loss of precision because csv.writer
- # uses str() for floats instead of repr()
- orig_row = [1.234567890123, 1.0/7.0, 'abc']
- f = StringIO()
- c = csv.writer(f, quoting=csv.QUOTE_NONNUMERIC)
- c.writerow(orig_row)
- f.seek(0)
- c = csv.reader(f, quoting=csv.QUOTE_NONNUMERIC)
- new_row = next(c)
- self.assertEqual(orig_row, new_row)
def _read_test(self, input, expect, **kwargs):
reader = csv.reader(input, **kwargs)
@@ -234,6 +212,10 @@ class Test_Csv(unittest.TestCase):
['ab\0c'], None, strict = 1)
self._read_test(['"ab"c'], [['abc']], doublequote = 0)
+ self.assertRaises(csv.Error, self._read_test,
+ [b'ab\0c'], None)
+
+
def test_read_eol(self):
self._read_test(['a,b'], [['a','b']])
self._read_test(['a,b\n'], [['a','b']])
@@ -294,23 +276,19 @@ class Test_Csv(unittest.TestCase):
csv.field_size_limit(limit)
def test_read_linenum(self):
- for r in (csv.reader(['line,1', 'line,2', 'line,3']),
- csv.DictReader(['line,1', 'line,2', 'line,3'],
- fieldnames=['a', 'b', 'c'])):
- self.assertEqual(r.line_num, 0)
- r.next()
- self.assertEqual(r.line_num, 1)
- r.next()
- self.assertEqual(r.line_num, 2)
- r.next()
- self.assertEqual(r.line_num, 3)
- self.assertRaises(StopIteration, r.next)
- self.assertEqual(r.line_num, 3)
+ r = csv.reader(['line,1', 'line,2', 'line,3'])
+ self.assertEqual(r.line_num, 0)
+ next(r)
+ self.assertEqual(r.line_num, 1)
+ next(r)
+ self.assertEqual(r.line_num, 2)
+ next(r)
+ self.assertEqual(r.line_num, 3)
+ self.assertRaises(StopIteration, next, r)
+ self.assertEqual(r.line_num, 3)
def test_roundtrip_quoteed_newlines(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj)
self.assertRaises(TypeError, writer.writerows, None)
rows = [['a\nb','b'],['c','x\r\nd']]
@@ -318,9 +296,6 @@ class Test_Csv(unittest.TestCase):
fileobj.seek(0)
for i, row in enumerate(csv.reader(fileobj)):
self.assertEqual(row, rows[i])
- finally:
- fileobj.close()
- os.unlink(name)
class TestDialectRegistry(unittest.TestCase):
def test_registry_badargs(self):
@@ -370,17 +345,21 @@ class TestDialectRegistry(unittest.TestCase):
quoting = csv.QUOTE_NONE
escapechar = "\\"
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("abc def\nc1ccccc1 benzene\n")
fileobj.seek(0)
- rdr = csv.reader(fileobj, dialect=space())
- self.assertEqual(rdr.next(), ["abc", "def"])
- self.assertEqual(rdr.next(), ["c1ccccc1", "benzene"])
- finally:
- fileobj.close()
- os.unlink(name)
+ reader = csv.reader(fileobj, dialect=space())
+ self.assertEqual(next(reader), ["abc", "def"])
+ self.assertEqual(next(reader), ["c1ccccc1", "benzene"])
+
+ def compare_dialect_123(self, expected, *writeargs, **kwwriteargs):
+
+ with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
+
+ writer = csv.writer(fileobj, *writeargs, **kwwriteargs)
+ writer.writerow([1,2,3])
+ fileobj.seek(0)
+ self.assertEqual(fileobj.read(), expected)
def test_dialect_apply(self):
class testA(csv.excel):
@@ -389,63 +368,19 @@ class TestDialectRegistry(unittest.TestCase):
delimiter = ":"
class testC(csv.excel):
delimiter = "|"
+ class testUni(csv.excel):
+ delimiter = "\u039B"
csv.register_dialect('testC', testC)
try:
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
- writer = csv.writer(fileobj)
- writer.writerow([1,2,3])
- fileobj.seek(0)
- self.assertEqual(fileobj.read(), "1,2,3\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
-
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
- writer = csv.writer(fileobj, testA)
- writer.writerow([1,2,3])
- fileobj.seek(0)
- self.assertEqual(fileobj.read(), "1\t2\t3\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
-
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
- writer = csv.writer(fileobj, dialect=testB())
- writer.writerow([1,2,3])
- fileobj.seek(0)
- self.assertEqual(fileobj.read(), "1:2:3\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
-
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
- writer = csv.writer(fileobj, dialect='testC')
- writer.writerow([1,2,3])
- fileobj.seek(0)
- self.assertEqual(fileobj.read(), "1|2|3\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
-
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
- writer = csv.writer(fileobj, dialect=testA, delimiter=';')
- writer.writerow([1,2,3])
- fileobj.seek(0)
- self.assertEqual(fileobj.read(), "1;2;3\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
+ self.compare_dialect_123("1,2,3\r\n")
+ self.compare_dialect_123("1\t2\t3\r\n", testA)
+ self.compare_dialect_123("1:2:3\r\n", dialect=testB())
+ self.compare_dialect_123("1|2|3\r\n", dialect='testC')
+ self.compare_dialect_123("1;2;3\r\n", dialect=testA,
+ delimiter=';')
+ self.compare_dialect_123("1\u039B2\u039B3\r\n",
+ dialect=testUni)
finally:
csv.unregister_dialect('testC')
@@ -460,29 +395,19 @@ class TestDialectRegistry(unittest.TestCase):
class TestCsvBase(unittest.TestCase):
def readerAssertEqual(self, input, expected_result):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
fileobj.write(input)
fileobj.seek(0)
reader = csv.reader(fileobj, dialect = self.dialect)
fields = list(reader)
self.assertEqual(fields, expected_result)
- finally:
- fileobj.close()
- os.unlink(name)
def writerAssertEqual(self, input, expected_result):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, dialect = self.dialect)
writer.writerows(input)
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected_result)
- finally:
- fileobj.close()
- os.unlink(name)
class TestDialectExcel(TestCsvBase):
dialect = 'excel'
@@ -594,6 +519,15 @@ class TestEscapedExcel(TestCsvBase):
def test_read_escape_fieldsep(self):
self.readerAssertEqual('abc\\,def\r\n', [['abc,def']])
+class TestDialectUnix(TestCsvBase):
+ dialect = 'unix'
+
+ def test_simple_writer(self):
+ self.writerAssertEqual([[1, 'abc def', 'abc']], '"1","abc def","abc"\n')
+
+ def test_simple_reader(self):
+ self.readerAssertEqual('"1","abc def","abc"\n', [['1', 'abc def', 'abc']])
+
class QuotedEscapedExcel(csv.excel):
quoting = csv.QUOTE_NONNUMERIC
escapechar = '\\'
@@ -611,9 +545,7 @@ class TestDictFields(unittest.TestCase):
### "long" means the row is longer than the number of fieldnames
### "short" means there are fewer elements in the row than fieldnames
def test_write_simple_dict(self):
- fd, name = tempfile.mkstemp()
- fileobj = io.open(fd, 'w+b')
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.DictWriter(fileobj, fieldnames = ["f1", "f2", "f3"])
writer.writeheader()
fileobj.seek(0)
@@ -622,130 +554,88 @@ class TestDictFields(unittest.TestCase):
fileobj.seek(0)
fileobj.readline() # header
self.assertEqual(fileobj.read(), "10,,abc\r\n")
- finally:
- fileobj.close()
- os.unlink(name)
def test_write_no_fields(self):
fileobj = StringIO()
self.assertRaises(TypeError, csv.DictWriter, fileobj)
def test_read_dict_fields(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("1,2,abc\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj,
fieldnames=["f1", "f2", "f3"])
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2', "f3": 'abc'})
- finally:
- fileobj.close()
- os.unlink(name)
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2', "f3": 'abc'})
def test_read_dict_no_fieldnames(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj)
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2', "f3": 'abc'})
self.assertEqual(reader.fieldnames, ["f1", "f2", "f3"])
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2', "f3": 'abc'})
- finally:
- fileobj.close()
- os.unlink(name)
# Two test cases to make sure existing ways of implicitly setting
# fieldnames continue to work. Both arise from discussion in issue3436.
def test_read_dict_fieldnames_from_file(self):
- fd, name = tempfile.mkstemp()
- f = os.fdopen(fd, "w+b")
- try:
- f.write("f1,f2,f3\r\n1,2,abc\r\n")
- f.seek(0)
- reader = csv.DictReader(f, fieldnames=csv.reader(f).next())
+ with TemporaryFile("w+") as fileobj:
+ fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
+ fileobj.seek(0)
+ reader = csv.DictReader(fileobj,
+ fieldnames=next(csv.reader(fileobj)))
self.assertEqual(reader.fieldnames, ["f1", "f2", "f3"])
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2', "f3": 'abc'})
- finally:
- f.close()
- os.unlink(name)
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2', "f3": 'abc'})
def test_read_dict_fieldnames_chain(self):
import itertools
- fd, name = tempfile.mkstemp()
- f = os.fdopen(fd, "w+b")
- try:
- f.write("f1,f2,f3\r\n1,2,abc\r\n")
- f.seek(0)
- reader = csv.DictReader(f)
+ with TemporaryFile("w+") as fileobj:
+ fileobj.write("f1,f2,f3\r\n1,2,abc\r\n")
+ fileobj.seek(0)
+ reader = csv.DictReader(fileobj)
first = next(reader)
for row in itertools.chain([first], reader):
self.assertEqual(reader.fieldnames, ["f1", "f2", "f3"])
self.assertEqual(row, {"f1": '1', "f2": '2', "f3": 'abc'})
- finally:
- f.close()
- os.unlink(name)
def test_read_long(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("1,2,abc,4,5,6\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj,
fieldnames=["f1", "f2"])
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2',
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2',
None: ["abc", "4", "5", "6"]})
- finally:
- fileobj.close()
- os.unlink(name)
def test_read_long_with_rest(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("1,2,abc,4,5,6\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj,
fieldnames=["f1", "f2"], restkey="_rest")
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2',
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2',
"_rest": ["abc", "4", "5", "6"]})
- finally:
- fileobj.close()
- os.unlink(name)
def test_read_long_with_rest_no_fieldnames(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("f1,f2\r\n1,2,abc,4,5,6\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj, restkey="_rest")
self.assertEqual(reader.fieldnames, ["f1", "f2"])
- self.assertEqual(reader.next(), {"f1": '1', "f2": '2',
+ self.assertEqual(next(reader), {"f1": '1', "f2": '2',
"_rest": ["abc", "4", "5", "6"]})
- finally:
- fileobj.close()
- os.unlink(name)
def test_read_short(self):
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+") as fileobj:
fileobj.write("1,2,abc,4,5,6\r\n1,2,abc\r\n")
fileobj.seek(0)
reader = csv.DictReader(fileobj,
fieldnames="1 2 3 4 5 6".split(),
restval="DEFAULT")
- self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+ self.assertEqual(next(reader), {"1": '1', "2": '2', "3": 'abc',
"4": '4', "5": '5', "6": '6'})
- self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+ self.assertEqual(next(reader), {"1": '1', "2": '2', "3": 'abc',
"4": 'DEFAULT', "5": 'DEFAULT',
"6": 'DEFAULT'})
- finally:
- fileobj.close()
- os.unlink(name)
def test_read_multi(self):
sample = [
@@ -756,7 +646,7 @@ class TestDictFields(unittest.TestCase):
reader = csv.DictReader(sample,
fieldnames="i1 float i2 s1 s2".split())
- self.assertEqual(reader.next(), {"i1": '2147483648',
+ self.assertEqual(next(reader), {"i1": '2147483648',
"float": '43.0e12',
"i2": '17',
"s1": 'abc',
@@ -766,16 +656,16 @@ class TestDictFields(unittest.TestCase):
reader = csv.DictReader(["1,2,abc,4,5,6\r\n","\r\n",
"1,2,abc,4,5,6\r\n"],
fieldnames="1 2 3 4 5 6".split())
- self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+ self.assertEqual(next(reader), {"1": '1', "2": '2', "3": 'abc',
"4": '4', "5": '5', "6": '6'})
- self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+ self.assertEqual(next(reader), {"1": '1', "2": '2', "3": 'abc',
"4": '4', "5": '5', "6": '6'})
def test_read_semi_sep(self):
reader = csv.DictReader(["1;2;abc;4;5;6\r\n"],
fieldnames="1 2 3 4 5 6".split(),
delimiter=';')
- self.assertEqual(reader.next(), {"1": '1', "2": '2', "3": 'abc',
+ self.assertEqual(next(reader), {"1": '1', "2": '2', "3": 'abc',
"4": '4', "5": '5', "6": '6'})
class TestArrayWrites(unittest.TestCase):
@@ -784,64 +674,45 @@ class TestArrayWrites(unittest.TestCase):
contents = [(20-i) for i in range(20)]
a = array.array('i', contents)
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, dialect="excel")
writer.writerow(a)
expected = ",".join([str(i) for i in a])+"\r\n"
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected)
- finally:
- fileobj.close()
- os.unlink(name)
def test_double_write(self):
import array
contents = [(20-i)*0.1 for i in range(20)]
a = array.array('d', contents)
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, dialect="excel")
writer.writerow(a)
- expected = ",".join([repr(i) for i in a])+"\r\n"
+ expected = ",".join([str(i) for i in a])+"\r\n"
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected)
- finally:
- fileobj.close()
- os.unlink(name)
def test_float_write(self):
import array
contents = [(20-i)*0.1 for i in range(20)]
a = array.array('f', contents)
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, dialect="excel")
writer.writerow(a)
- expected = ",".join([repr(i) for i in a])+"\r\n"
+ expected = ",".join([str(i) for i in a])+"\r\n"
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected)
- finally:
- fileobj.close()
- os.unlink(name)
def test_char_write(self):
import array, string
- a = array.array('c', string.letters)
- fd, name = tempfile.mkstemp()
- fileobj = os.fdopen(fd, "w+b")
- try:
+ a = array.array('u', string.ascii_letters)
+
+ with TemporaryFile("w+", newline='') as fileobj:
writer = csv.writer(fileobj, dialect="excel")
writer.writerow(a)
expected = ",".join(a)+"\r\n"
fileobj.seek(0)
self.assertEqual(fileobj.read(), expected)
- finally:
- fileobj.close()
- os.unlink(name)
class TestDialectValidity(unittest.TestCase):
def test_quoting(self):
@@ -979,7 +850,7 @@ Stonecutters Seafood and Chop House, Lemont, IL, 12/19/02, Week Back
self.assertTrue(dialect.doublequote)
if not hasattr(sys, "gettotalrefcount"):
- if test_support.verbose: print "*** skipping leakage tests ***"
+ if support.verbose: print("*** skipping leakage tests ***")
else:
class NUL:
def write(s, *args):
@@ -990,7 +861,7 @@ else:
def test_create_read(self):
delta = 0
lastrc = sys.gettotalrefcount()
- for i in xrange(20):
+ for i in range(20):
gc.collect()
self.assertEqual(gc.garbage, [])
rc = sys.gettotalrefcount()
@@ -1006,7 +877,7 @@ else:
delta = 0
lastrc = sys.gettotalrefcount()
s = NUL()
- for i in xrange(20):
+ for i in range(20):
gc.collect()
self.assertEqual(gc.garbage, [])
rc = sys.gettotalrefcount()
@@ -1022,7 +893,7 @@ else:
delta = 0
rows = ["a,b,c\r\n"]*5
lastrc = sys.gettotalrefcount()
- for i in xrange(20):
+ for i in range(20):
gc.collect()
self.assertEqual(gc.garbage, [])
rc = sys.gettotalrefcount()
@@ -1039,7 +910,7 @@ else:
rows = [[1,2,3]]*5
s = NUL()
lastrc = sys.gettotalrefcount()
- for i in xrange(20):
+ for i in range(20):
gc.collect()
self.assertEqual(gc.garbage, [])
rc = sys.gettotalrefcount()
@@ -1051,24 +922,36 @@ else:
# if writer leaks during write, last delta should be 5 or more
self.assertEqual(delta < 5, True)
-# commented out for now - csv module doesn't yet support Unicode
-## class TestUnicode(unittest.TestCase):
-## def test_unicode_read(self):
-## import codecs
-## f = codecs.EncodedFile(StringIO("Martin von Löwis,"
-## "Marc André Lemburg,"
-## "Guido van Rossum,"
-## "François Pinard\r\n"),
-## data_encoding='iso-8859-1')
-## reader = csv.reader(f)
-## self.assertEqual(list(reader), [[u"Martin von Löwis",
-## u"Marc André Lemburg",
-## u"Guido van Rossum",
-## u"François Pinardn"]])
+class TestUnicode(unittest.TestCase):
+
+ names = ["Martin von Löwis",
+ "Marc André Lemburg",
+ "Guido van Rossum",
+ "François Pinard"]
+
+ def test_unicode_read(self):
+ import io
+ with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
+ fileobj.write(",".join(self.names) + "\r\n")
+ fileobj.seek(0)
+ reader = csv.reader(fileobj)
+ self.assertEqual(list(reader), [self.names])
+
+
+ def test_unicode_write(self):
+ import io
+ with TemporaryFile("w+", newline='', encoding="utf-8") as fileobj:
+ writer = csv.writer(fileobj)
+ writer.writerow(self.names)
+ expected = ",".join(self.names)+"\r\n"
+ fileobj.seek(0)
+ self.assertEqual(fileobj.read(), expected)
+
+
def test_main():
mod = sys.modules[__name__]
- test_support.run_unittest(
+ support.run_unittest(
*[getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
)
diff --git a/Lib/test/test_ctypes.py b/Lib/test/test_ctypes.py
index 17f287449af..7d9abdcba72 100644
--- a/Lib/test/test_ctypes.py
+++ b/Lib/test/test_ctypes.py
@@ -1,12 +1,13 @@
import unittest
-from test.test_support import run_unittest, import_module
-#Skip tests if _ctypes module does not exist
+from test.support import run_unittest, import_module
+
+# Skip tests if _ctypes module was not built.
import_module('_ctypes')
+import ctypes.test
def test_main():
- import ctypes.test
skipped, testcases = ctypes.test.get_tests(ctypes.test, "test_*.py", verbosity=0)
suites = [unittest.makeSuite(t) for t in testcases]
run_unittest(unittest.TestSuite(suites))
diff --git a/Lib/test/test_curses.py b/Lib/test/test_curses.py
index fa0d469e475..58121477b1d 100644
--- a/Lib/test/test_curses.py
+++ b/Lib/test/test_curses.py
@@ -16,8 +16,10 @@ import sys, tempfile, os
# option. If not available, nothing after this line will be executed.
import unittest
-from test.test_support import requires, import_module
+from test.support import requires, import_module
requires('curses')
+
+# If either of these don't exist, skip the tests.
curses = import_module('curses')
curses.panel = import_module('curses.panel')
@@ -25,7 +27,7 @@ curses.panel = import_module('curses.panel')
# XXX: if newterm was supported we could use it instead of initscr and not exit
term = os.environ.get('TERM')
if not term or term == 'unknown':
- raise unittest.SkipTest, "$TERM=%r, calling initscr() may cause exit" % term
+ raise unittest.SkipTest("$TERM=%r, calling initscr() may cause exit" % term)
if sys.platform == "cygwin":
raise unittest.SkipTest("cygwin's curses mostly just hangs")
@@ -75,7 +77,7 @@ def window_funcs(stdscr):
except TypeError:
pass
else:
- raise RuntimeError, "Expected win.border() to raise TypeError"
+ raise RuntimeError("Expected win.border() to raise TypeError")
stdscr.clearok(1)
@@ -181,14 +183,14 @@ def module_funcs(stdscr):
win = curses.newwin(5,5)
win = curses.newwin(5,5, 1,1)
curses.nl() ; curses.nl(1)
- curses.putp('abc')
+ curses.putp(b'abc')
curses.qiflush()
curses.raw() ; curses.raw(1)
curses.setsyx(5,5)
curses.tigetflag('hc')
curses.tigetnum('co')
curses.tigetstr('cr')
- curses.tparm('cr')
+ curses.tparm(b'cr')
curses.typeahead(sys.__stdin__.fileno())
curses.unctrl('a')
curses.ungetch('a')
@@ -237,7 +239,7 @@ def unit_tests():
('\x8a', '!^J'), ('\xc1', '!A'),
]:
if ascii.unctrl(ch) != expected:
- print 'curses.unctrl fails on character', repr(ch)
+ print('curses.unctrl fails on character', repr(ch))
def test_userptr_without_set(stdscr):
@@ -246,7 +248,7 @@ def test_userptr_without_set(stdscr):
# try to access userptr() before calling set_userptr() -- segfaults
try:
p.userptr()
- raise RuntimeError, 'userptr should fail since not set'
+ raise RuntimeError('userptr should fail since not set')
except curses.panel.error:
pass
@@ -256,12 +258,17 @@ def test_resize_term(stdscr):
curses.resizeterm(lines - 1, cols + 1)
if curses.LINES != lines - 1 or curses.COLS != cols + 1:
- raise RuntimeError, "Expected resizeterm to update LINES and COLS"
+ raise RuntimeError("Expected resizeterm to update LINES and COLS")
def test_issue6243(stdscr):
curses.ungetch(1025)
stdscr.getkey()
+def test_issue10570():
+ b = curses.tparm(curses.tigetstr("cup"), 5, 3)
+ assert type(b) is bytes
+ curses.putp(b)
+
def main(stdscr):
curses.savetty()
try:
@@ -270,21 +277,23 @@ def main(stdscr):
test_userptr_without_set(stdscr)
test_resize_term(stdscr)
test_issue6243(stdscr)
+ test_issue10570()
finally:
curses.resetty()
-if __name__ == '__main__':
- curses.wrapper(main)
- unit_tests()
-else:
- if not sys.__stdout__.isatty():
- raise unittest.SkipTest("sys.__stdout__ is not a tty")
+def test_main():
+ if not sys.stdout.isatty():
+ raise unittest.SkipTest("sys.stdout is not a tty")
# testing setupterm() inside initscr/endwin
# causes terminal breakage
- curses.setupterm(fd=sys.__stdout__.fileno())
+ curses.setupterm(fd=sys.stdout.fileno())
try:
stdscr = curses.initscr()
main(stdscr)
finally:
curses.endwin()
unit_tests()
+
+if __name__ == '__main__':
+ curses.wrapper(main)
+ unit_tests()
diff --git a/Lib/test/test_datetime.py b/Lib/test/test_datetime.py
index d246d60797e..d9ddb32363a 100644
--- a/Lib/test/test_datetime.py
+++ b/Lib/test/test_datetime.py
@@ -1,3367 +1,48 @@
-"""Test date/time type.
-
-See http://www.zope.org/Members/fdrake/DateTimeWiki/TestCases
-"""
-from __future__ import division
-import sys
-import pickle
-import cPickle
import unittest
-
-from test import test_support
-
-from datetime import MINYEAR, MAXYEAR
-from datetime import timedelta
-from datetime import tzinfo
-from datetime import time
-from datetime import date, datetime
-
-pickle_choices = [(pickler, unpickler, proto)
- for pickler in pickle, cPickle
- for unpickler in pickle, cPickle
- for proto in range(3)]
-assert len(pickle_choices) == 2*2*3
-
-# An arbitrary collection of objects of non-datetime types, for testing
-# mixed-type comparisons.
-OTHERSTUFF = (10, 10L, 34.5, "abc", {}, [], ())
-
-
-#############################################################################
-# module tests
-
-class TestModule(unittest.TestCase):
-
- def test_constants(self):
- import datetime
- self.assertEqual(datetime.MINYEAR, 1)
- self.assertEqual(datetime.MAXYEAR, 9999)
-
-#############################################################################
-# tzinfo tests
-
-class FixedOffset(tzinfo):
- def __init__(self, offset, name, dstoffset=42):
- if isinstance(offset, int):
- offset = timedelta(minutes=offset)
- if isinstance(dstoffset, int):
- dstoffset = timedelta(minutes=dstoffset)
- self.__offset = offset
- self.__name = name
- self.__dstoffset = dstoffset
- def __repr__(self):
- return self.__name.lower()
- def utcoffset(self, dt):
- return self.__offset
- def tzname(self, dt):
- return self.__name
- def dst(self, dt):
- return self.__dstoffset
-
-class PicklableFixedOffset(FixedOffset):
- def __init__(self, offset=None, name=None, dstoffset=None):
- FixedOffset.__init__(self, offset, name, dstoffset)
-
-class TestTZInfo(unittest.TestCase):
-
- def test_non_abstractness(self):
- # In order to allow subclasses to get pickled, the C implementation
- # wasn't able to get away with having __init__ raise
- # NotImplementedError.
- useless = tzinfo()
- dt = datetime.max
- self.assertRaises(NotImplementedError, useless.tzname, dt)
- self.assertRaises(NotImplementedError, useless.utcoffset, dt)
- self.assertRaises(NotImplementedError, useless.dst, dt)
-
- def test_subclass_must_override(self):
- class NotEnough(tzinfo):
- def __init__(self, offset, name):
- self.__offset = offset
- self.__name = name
- self.assertTrue(issubclass(NotEnough, tzinfo))
- ne = NotEnough(3, "NotByALongShot")
- self.assertIsInstance(ne, tzinfo)
-
- dt = datetime.now()
- self.assertRaises(NotImplementedError, ne.tzname, dt)
- self.assertRaises(NotImplementedError, ne.utcoffset, dt)
- self.assertRaises(NotImplementedError, ne.dst, dt)
-
- def test_normal(self):
- fo = FixedOffset(3, "Three")
- self.assertIsInstance(fo, tzinfo)
- for dt in datetime.now(), None:
- self.assertEqual(fo.utcoffset(dt), timedelta(minutes=3))
- self.assertEqual(fo.tzname(dt), "Three")
- self.assertEqual(fo.dst(dt), timedelta(minutes=42))
-
- def test_pickling_base(self):
- # There's no point to pickling tzinfo objects on their own (they
- # carry no data), but they need to be picklable anyway else
- # concrete subclasses can't be pickled.
- orig = tzinfo.__new__(tzinfo)
- self.assertTrue(type(orig) is tzinfo)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertTrue(type(derived) is tzinfo)
-
- def test_pickling_subclass(self):
- # Make sure we can pickle/unpickle an instance of a subclass.
- offset = timedelta(minutes=-300)
- orig = PicklableFixedOffset(offset, 'cookie')
- self.assertIsInstance(orig, tzinfo)
- self.assertTrue(type(orig) is PicklableFixedOffset)
- self.assertEqual(orig.utcoffset(None), offset)
- self.assertEqual(orig.tzname(None), 'cookie')
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertIsInstance(derived, tzinfo)
- self.assertTrue(type(derived) is PicklableFixedOffset)
- self.assertEqual(derived.utcoffset(None), offset)
- self.assertEqual(derived.tzname(None), 'cookie')
-
-#############################################################################
-# Base clase for testing a particular aspect of timedelta, time, date and
-# datetime comparisons.
-
-class HarmlessMixedComparison:
- # Test that __eq__ and __ne__ don't complain for mixed-type comparisons.
-
- # Subclasses must define 'theclass', and theclass(1, 1, 1) must be a
- # legit constructor.
-
- def test_harmless_mixed_comparison(self):
- me = self.theclass(1, 1, 1)
-
- self.assertFalse(me == ())
- self.assertTrue(me != ())
- self.assertFalse(() == me)
- self.assertTrue(() != me)
-
- self.assertIn(me, [1, 20L, [], me])
- self.assertIn([], [me, 1, 20L, []])
-
- def test_harmful_mixed_comparison(self):
- me = self.theclass(1, 1, 1)
-
- self.assertRaises(TypeError, lambda: me < ())
- self.assertRaises(TypeError, lambda: me <= ())
- self.assertRaises(TypeError, lambda: me > ())
- self.assertRaises(TypeError, lambda: me >= ())
-
- self.assertRaises(TypeError, lambda: () < me)
- self.assertRaises(TypeError, lambda: () <= me)
- self.assertRaises(TypeError, lambda: () > me)
- self.assertRaises(TypeError, lambda: () >= me)
-
- self.assertRaises(TypeError, cmp, (), me)
- self.assertRaises(TypeError, cmp, me, ())
-
-#############################################################################
-# timedelta tests
-
-class TestTimeDelta(HarmlessMixedComparison, unittest.TestCase):
-
- theclass = timedelta
-
- def test_constructor(self):
- eq = self.assertEqual
- td = timedelta
-
- # Check keyword args to constructor
- eq(td(), td(weeks=0, days=0, hours=0, minutes=0, seconds=0,
- milliseconds=0, microseconds=0))
- eq(td(1), td(days=1))
- eq(td(0, 1), td(seconds=1))
- eq(td(0, 0, 1), td(microseconds=1))
- eq(td(weeks=1), td(days=7))
- eq(td(days=1), td(hours=24))
- eq(td(hours=1), td(minutes=60))
- eq(td(minutes=1), td(seconds=60))
- eq(td(seconds=1), td(milliseconds=1000))
- eq(td(milliseconds=1), td(microseconds=1000))
-
- # Check float args to constructor
- eq(td(weeks=1.0/7), td(days=1))
- eq(td(days=1.0/24), td(hours=1))
- eq(td(hours=1.0/60), td(minutes=1))
- eq(td(minutes=1.0/60), td(seconds=1))
- eq(td(seconds=0.001), td(milliseconds=1))
- eq(td(milliseconds=0.001), td(microseconds=1))
-
- def test_computations(self):
- eq = self.assertEqual
- td = timedelta
-
- a = td(7) # One week
- b = td(0, 60) # One minute
- c = td(0, 0, 1000) # One millisecond
- eq(a+b+c, td(7, 60, 1000))
- eq(a-b, td(6, 24*3600 - 60))
- eq(-a, td(-7))
- eq(+a, td(7))
- eq(-b, td(-1, 24*3600 - 60))
- eq(-c, td(-1, 24*3600 - 1, 999000))
- eq(abs(a), a)
- eq(abs(-a), a)
- eq(td(6, 24*3600), a)
- eq(td(0, 0, 60*1000000), b)
- eq(a*10, td(70))
- eq(a*10, 10*a)
- eq(a*10L, 10*a)
- eq(b*10, td(0, 600))
- eq(10*b, td(0, 600))
- eq(b*10L, td(0, 600))
- eq(c*10, td(0, 0, 10000))
- eq(10*c, td(0, 0, 10000))
- eq(c*10L, td(0, 0, 10000))
- eq(a*-1, -a)
- eq(b*-2, -b-b)
- eq(c*-2, -c+-c)
- eq(b*(60*24), (b*60)*24)
- eq(b*(60*24), (60*b)*24)
- eq(c*1000, td(0, 1))
- eq(1000*c, td(0, 1))
- eq(a//7, td(1))
- eq(b//10, td(0, 6))
- eq(c//1000, td(0, 0, 1))
- eq(a//10, td(0, 7*24*360))
- eq(a//3600000, td(0, 0, 7*24*1000))
-
- # Issue #11576
- eq(td(999999999, 86399, 999999) - td(999999999, 86399, 999998),
- td(0, 0, 1))
- eq(td(999999999, 1, 1) - td(999999999, 1, 0),
- td(0, 0, 1))
-
-
- def test_disallowed_computations(self):
- a = timedelta(42)
-
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1L, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # Mul/div by float isn't supported.
- x = 2.3
- self.assertRaises(TypeError, lambda: a*x)
- self.assertRaises(TypeError, lambda: x*a)
- self.assertRaises(TypeError, lambda: a/x)
- self.assertRaises(TypeError, lambda: x/a)
- self.assertRaises(TypeError, lambda: a // x)
- self.assertRaises(TypeError, lambda: x // a)
-
- # Division of int by timedelta doesn't make sense.
- # Division by zero doesn't make sense.
- for zero in 0, 0L:
- self.assertRaises(TypeError, lambda: zero // a)
- self.assertRaises(ZeroDivisionError, lambda: a // zero)
-
- def test_basic_attributes(self):
- days, seconds, us = 1, 7, 31
- td = timedelta(days, seconds, us)
- self.assertEqual(td.days, days)
- self.assertEqual(td.seconds, seconds)
- self.assertEqual(td.microseconds, us)
-
- def test_total_seconds(self):
- td = timedelta(days=365)
- self.assertEqual(td.total_seconds(), 31536000.0)
- for total_seconds in [123456.789012, -123456.789012, 0.123456, 0, 1e6]:
- td = timedelta(seconds=total_seconds)
- self.assertEqual(td.total_seconds(), total_seconds)
- # Issue8644: Test that td.total_seconds() has the same
- # accuracy as td / timedelta(seconds=1).
- for ms in [-1, -2, -123]:
- td = timedelta(microseconds=ms)
- self.assertEqual(td.total_seconds(),
- ((24*3600*td.days + td.seconds)*10**6
- + td.microseconds)/10**6)
-
- def test_carries(self):
- t1 = timedelta(days=100,
- weeks=-7,
- hours=-24*(100-49),
- minutes=-3,
- seconds=12,
- microseconds=(3*60 - 12) * 1e6 + 1)
- t2 = timedelta(microseconds=1)
- self.assertEqual(t1, t2)
-
- def test_hash_equality(self):
- t1 = timedelta(days=100,
- weeks=-7,
- hours=-24*(100-49),
- minutes=-3,
- seconds=12,
- microseconds=(3*60 - 12) * 1000000)
- t2 = timedelta()
- self.assertEqual(hash(t1), hash(t2))
-
- t1 += timedelta(weeks=7)
- t2 += timedelta(days=7*7)
- self.assertEqual(t1, t2)
- self.assertEqual(hash(t1), hash(t2))
-
- d = {t1: 1}
- d[t2] = 2
- self.assertEqual(len(d), 1)
- self.assertEqual(d[t1], 2)
-
- def test_pickling(self):
- args = 12, 34, 56
- orig = timedelta(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_compare(self):
- t1 = timedelta(2, 3, 4)
- t2 = timedelta(2, 3, 4)
- self.assertTrue(t1 == t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
- self.assertEqual(cmp(t1, t2), 0)
- self.assertEqual(cmp(t2, t1), 0)
-
- for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
- t2 = timedelta(*args) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
- self.assertEqual(cmp(t1, t2), -1)
- self.assertEqual(cmp(t2, t1), 1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 <= badarg)
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_str(self):
- td = timedelta
- eq = self.assertEqual
-
- eq(str(td(1)), "1 day, 0:00:00")
- eq(str(td(-1)), "-1 day, 0:00:00")
- eq(str(td(2)), "2 days, 0:00:00")
- eq(str(td(-2)), "-2 days, 0:00:00")
-
- eq(str(td(hours=12, minutes=58, seconds=59)), "12:58:59")
- eq(str(td(hours=2, minutes=3, seconds=4)), "2:03:04")
- eq(str(td(weeks=-30, hours=23, minutes=12, seconds=34)),
- "-210 days, 23:12:34")
-
- eq(str(td(milliseconds=1)), "0:00:00.001000")
- eq(str(td(microseconds=3)), "0:00:00.000003")
-
- eq(str(td(days=999999999, hours=23, minutes=59, seconds=59,
- microseconds=999999)),
- "999999999 days, 23:59:59.999999")
-
- def test_roundtrip(self):
- for td in (timedelta(days=999999999, hours=23, minutes=59,
- seconds=59, microseconds=999999),
- timedelta(days=-999999999),
- timedelta(days=1, seconds=2, microseconds=3)):
-
- # Verify td -> string -> td identity.
- s = repr(td)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- td2 = eval(s)
- self.assertEqual(td, td2)
-
- # Verify identity via reconstructing from pieces.
- td2 = timedelta(td.days, td.seconds, td.microseconds)
- self.assertEqual(td, td2)
-
- def test_resolution_info(self):
- self.assertIsInstance(timedelta.min, timedelta)
- self.assertIsInstance(timedelta.max, timedelta)
- self.assertIsInstance(timedelta.resolution, timedelta)
- self.assertTrue(timedelta.max > timedelta.min)
- self.assertEqual(timedelta.min, timedelta(-999999999))
- self.assertEqual(timedelta.max, timedelta(999999999, 24*3600-1, 1e6-1))
- self.assertEqual(timedelta.resolution, timedelta(0, 0, 1))
-
- def test_overflow(self):
- tiny = timedelta.resolution
-
- td = timedelta.min + tiny
- td -= tiny # no problem
- self.assertRaises(OverflowError, td.__sub__, tiny)
- self.assertRaises(OverflowError, td.__add__, -tiny)
-
- td = timedelta.max - tiny
- td += tiny # no problem
- self.assertRaises(OverflowError, td.__add__, tiny)
- self.assertRaises(OverflowError, td.__sub__, -tiny)
-
- self.assertRaises(OverflowError, lambda: -timedelta.max)
-
- def test_microsecond_rounding(self):
- td = timedelta
- eq = self.assertEqual
-
- # Single-field rounding.
- eq(td(milliseconds=0.4/1000), td(0)) # rounds to 0
- eq(td(milliseconds=-0.4/1000), td(0)) # rounds to 0
- eq(td(milliseconds=0.6/1000), td(microseconds=1))
- eq(td(milliseconds=-0.6/1000), td(microseconds=-1))
-
- # Rounding due to contributions from more than one field.
- us_per_hour = 3600e6
- us_per_day = us_per_hour * 24
- eq(td(days=.4/us_per_day), td(0))
- eq(td(hours=.2/us_per_hour), td(0))
- eq(td(days=.4/us_per_day, hours=.2/us_per_hour), td(microseconds=1))
-
- eq(td(days=-.4/us_per_day), td(0))
- eq(td(hours=-.2/us_per_hour), td(0))
- eq(td(days=-.4/us_per_day, hours=-.2/us_per_hour), td(microseconds=-1))
-
- def test_massive_normalization(self):
- td = timedelta(microseconds=-1)
- self.assertEqual((td.days, td.seconds, td.microseconds),
- (-1, 24*3600-1, 999999))
-
- def test_bool(self):
- self.assertTrue(timedelta(1))
- self.assertTrue(timedelta(0, 1))
- self.assertTrue(timedelta(0, 0, 1))
- self.assertTrue(timedelta(microseconds=1))
- self.assertTrue(not timedelta(0))
-
- def test_subclass_timedelta(self):
-
- class T(timedelta):
- @staticmethod
- def from_td(td):
- return T(td.days, td.seconds, td.microseconds)
-
- def as_hours(self):
- sum = (self.days * 24 +
- self.seconds / 3600.0 +
- self.microseconds / 3600e6)
- return round(sum)
-
- t1 = T(days=1)
- self.assertTrue(type(t1) is T)
- self.assertEqual(t1.as_hours(), 24)
-
- t2 = T(days=-1, seconds=-3600)
- self.assertTrue(type(t2) is T)
- self.assertEqual(t2.as_hours(), -25)
-
- t3 = t1 + t2
- self.assertTrue(type(t3) is timedelta)
- t4 = T.from_td(t3)
- self.assertTrue(type(t4) is T)
- self.assertEqual(t3.days, t4.days)
- self.assertEqual(t3.seconds, t4.seconds)
- self.assertEqual(t3.microseconds, t4.microseconds)
- self.assertEqual(str(t3), str(t4))
- self.assertEqual(t4.as_hours(), -1)
-
-#############################################################################
-# date tests
-
-class TestDateOnly(unittest.TestCase):
- # Tests here won't pass if also run on datetime objects, so don't
- # subclass this to test datetimes too.
-
- def test_delta_non_days_ignored(self):
- dt = date(2000, 1, 2)
- delta = timedelta(days=1, hours=2, minutes=3, seconds=4,
- microseconds=5)
- days = timedelta(delta.days)
- self.assertEqual(days, timedelta(1))
-
- dt2 = dt + delta
- self.assertEqual(dt2, dt + days)
-
- dt2 = delta + dt
- self.assertEqual(dt2, dt + days)
-
- dt2 = dt - delta
- self.assertEqual(dt2, dt - days)
-
- delta = -delta
- days = timedelta(delta.days)
- self.assertEqual(days, timedelta(-2))
-
- dt2 = dt + delta
- self.assertEqual(dt2, dt + days)
-
- dt2 = delta + dt
- self.assertEqual(dt2, dt + days)
-
- dt2 = dt - delta
- self.assertEqual(dt2, dt - days)
-
-class SubclassDate(date):
- sub_var = 1
-
-class TestDate(HarmlessMixedComparison, unittest.TestCase):
- # Tests here should pass for both dates and datetimes, except for a
- # few tests that TestDateTime overrides.
-
- theclass = date
-
- def test_basic_attributes(self):
- dt = self.theclass(2002, 3, 1)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
-
- def test_roundtrip(self):
- for dt in (self.theclass(1, 2, 3),
- self.theclass.today()):
- # Verify dt -> string -> date identity.
- s = repr(dt)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- dt2 = eval(s)
- self.assertEqual(dt, dt2)
-
- # Verify identity via reconstructing from pieces.
- dt2 = self.theclass(dt.year, dt.month, dt.day)
- self.assertEqual(dt, dt2)
-
- def test_ordinal_conversions(self):
- # Check some fixed values.
- for y, m, d, n in [(1, 1, 1, 1), # calendar origin
- (1, 12, 31, 365),
- (2, 1, 1, 366),
- # first example from "Calendrical Calculations"
- (1945, 11, 12, 710347)]:
- d = self.theclass(y, m, d)
- self.assertEqual(n, d.toordinal())
- fromord = self.theclass.fromordinal(n)
- self.assertEqual(d, fromord)
- if hasattr(fromord, "hour"):
- # if we're checking something fancier than a date, verify
- # the extra fields have been zeroed out
- self.assertEqual(fromord.hour, 0)
- self.assertEqual(fromord.minute, 0)
- self.assertEqual(fromord.second, 0)
- self.assertEqual(fromord.microsecond, 0)
-
- # Check first and last days of year spottily across the whole
- # range of years supported.
- for year in xrange(MINYEAR, MAXYEAR+1, 7):
- # Verify (year, 1, 1) -> ordinal -> y, m, d is identity.
- d = self.theclass(year, 1, 1)
- n = d.toordinal()
- d2 = self.theclass.fromordinal(n)
- self.assertEqual(d, d2)
- # Verify that moving back a day gets to the end of year-1.
- if year > 1:
- d = self.theclass.fromordinal(n-1)
- d2 = self.theclass(year-1, 12, 31)
- self.assertEqual(d, d2)
- self.assertEqual(d2.toordinal(), n-1)
-
- # Test every day in a leap-year and a non-leap year.
- dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
- for year, isleap in (2000, True), (2002, False):
- n = self.theclass(year, 1, 1).toordinal()
- for month, maxday in zip(range(1, 13), dim):
- if month == 2 and isleap:
- maxday += 1
- for day in range(1, maxday+1):
- d = self.theclass(year, month, day)
- self.assertEqual(d.toordinal(), n)
- self.assertEqual(d, self.theclass.fromordinal(n))
- n += 1
-
- def test_extreme_ordinals(self):
- a = self.theclass.min
- a = self.theclass(a.year, a.month, a.day) # get rid of time parts
- aord = a.toordinal()
- b = a.fromordinal(aord)
- self.assertEqual(a, b)
-
- self.assertRaises(ValueError, lambda: a.fromordinal(aord - 1))
-
- b = a + timedelta(days=1)
- self.assertEqual(b.toordinal(), aord + 1)
- self.assertEqual(b, self.theclass.fromordinal(aord + 1))
-
- a = self.theclass.max
- a = self.theclass(a.year, a.month, a.day) # get rid of time parts
- aord = a.toordinal()
- b = a.fromordinal(aord)
- self.assertEqual(a, b)
-
- self.assertRaises(ValueError, lambda: a.fromordinal(aord + 1))
-
- b = a - timedelta(days=1)
- self.assertEqual(b.toordinal(), aord - 1)
- self.assertEqual(b, self.theclass.fromordinal(aord - 1))
-
- def test_bad_constructor_arguments(self):
- # bad years
- self.theclass(MINYEAR, 1, 1) # no exception
- self.theclass(MAXYEAR, 1, 1) # no exception
- self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
- self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
- # bad months
- self.theclass(2000, 1, 1) # no exception
- self.theclass(2000, 12, 1) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
- self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
- # bad days
- self.theclass(2000, 2, 29) # no exception
- self.theclass(2004, 2, 29) # no exception
- self.theclass(2400, 2, 29) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
- self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
- self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
-
- def test_hash_equality(self):
- d = self.theclass(2000, 12, 31)
- # same thing
- e = self.theclass(2000, 12, 31)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(2001, 1, 1)
- # same thing
- e = self.theclass(2001, 1, 1)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_computations(self):
- a = self.theclass(2002, 1, 31)
- b = self.theclass(1956, 1, 31)
-
- diff = a-b
- self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
- self.assertEqual(diff.seconds, 0)
- self.assertEqual(diff.microseconds, 0)
-
- day = timedelta(1)
- week = timedelta(7)
- a = self.theclass(2002, 3, 2)
- self.assertEqual(a + day, self.theclass(2002, 3, 3))
- self.assertEqual(day + a, self.theclass(2002, 3, 3))
- self.assertEqual(a - day, self.theclass(2002, 3, 1))
- self.assertEqual(-day + a, self.theclass(2002, 3, 1))
- self.assertEqual(a + week, self.theclass(2002, 3, 9))
- self.assertEqual(a - week, self.theclass(2002, 2, 23))
- self.assertEqual(a + 52*week, self.theclass(2003, 3, 1))
- self.assertEqual(a - 52*week, self.theclass(2001, 3, 3))
- self.assertEqual((a + week) - a, week)
- self.assertEqual((a + day) - a, day)
- self.assertEqual((a - week) - a, -week)
- self.assertEqual((a - day) - a, -day)
- self.assertEqual(a - (a + week), -week)
- self.assertEqual(a - (a + day), -day)
- self.assertEqual(a - (a - week), week)
- self.assertEqual(a - (a - day), day)
-
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1L, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # delta - date is senseless.
- self.assertRaises(TypeError, lambda: day - a)
- # mixing date and (delta or date) via * or // is senseless
- self.assertRaises(TypeError, lambda: day * a)
- self.assertRaises(TypeError, lambda: a * day)
- self.assertRaises(TypeError, lambda: day // a)
- self.assertRaises(TypeError, lambda: a // day)
- self.assertRaises(TypeError, lambda: a * a)
- self.assertRaises(TypeError, lambda: a // a)
- # date + date is senseless
- self.assertRaises(TypeError, lambda: a + a)
-
- def test_overflow(self):
- tiny = self.theclass.resolution
-
- for delta in [tiny, timedelta(1), timedelta(2)]:
- dt = self.theclass.min + delta
- dt -= delta # no problem
- self.assertRaises(OverflowError, dt.__sub__, delta)
- self.assertRaises(OverflowError, dt.__add__, -delta)
-
- dt = self.theclass.max - delta
- dt += delta # no problem
- self.assertRaises(OverflowError, dt.__add__, delta)
- self.assertRaises(OverflowError, dt.__sub__, -delta)
-
- def test_fromtimestamp(self):
- import time
-
- # Try an arbitrary fixed value.
- year, month, day = 1999, 9, 19
- ts = time.mktime((year, month, day, 0, 0, 0, 0, 0, -1))
- d = self.theclass.fromtimestamp(ts)
- self.assertEqual(d.year, year)
- self.assertEqual(d.month, month)
- self.assertEqual(d.day, day)
-
- def test_insane_fromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.fromtimestamp,
- insane)
-
- def test_today(self):
- import time
-
- # We claim that today() is like fromtimestamp(time.time()), so
- # prove it.
- for dummy in range(3):
- today = self.theclass.today()
- ts = time.time()
- todayagain = self.theclass.fromtimestamp(ts)
- if today == todayagain:
- break
- # There are several legit reasons that could fail:
- # 1. It recently became midnight, between the today() and the
- # time() calls.
- # 2. The platform time() has such fine resolution that we'll
- # never get the same value twice.
- # 3. The platform time() has poor resolution, and we just
- # happened to call today() right before a resolution quantum
- # boundary.
- # 4. The system clock got fiddled between calls.
- # In any case, wait a little while and try again.
- time.sleep(0.1)
-
- # It worked or it didn't. If it didn't, assume it's reason #2, and
- # let the test pass if they're within half a second of each other.
- self.assertTrue(today == todayagain or
- abs(todayagain - today) < timedelta(seconds=0.5))
-
- def test_weekday(self):
- for i in range(7):
- # March 4, 2002 is a Monday
- self.assertEqual(self.theclass(2002, 3, 4+i).weekday(), i)
- self.assertEqual(self.theclass(2002, 3, 4+i).isoweekday(), i+1)
- # January 2, 1956 is a Monday
- self.assertEqual(self.theclass(1956, 1, 2+i).weekday(), i)
- self.assertEqual(self.theclass(1956, 1, 2+i).isoweekday(), i+1)
-
- def test_isocalendar(self):
- # Check examples from
- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
- for i in range(7):
- d = self.theclass(2003, 12, 22+i)
- self.assertEqual(d.isocalendar(), (2003, 52, i+1))
- d = self.theclass(2003, 12, 29) + timedelta(i)
- self.assertEqual(d.isocalendar(), (2004, 1, i+1))
- d = self.theclass(2004, 1, 5+i)
- self.assertEqual(d.isocalendar(), (2004, 2, i+1))
- d = self.theclass(2009, 12, 21+i)
- self.assertEqual(d.isocalendar(), (2009, 52, i+1))
- d = self.theclass(2009, 12, 28) + timedelta(i)
- self.assertEqual(d.isocalendar(), (2009, 53, i+1))
- d = self.theclass(2010, 1, 4+i)
- self.assertEqual(d.isocalendar(), (2010, 1, i+1))
-
- def test_iso_long_years(self):
- # Calculate long ISO years and compare to table from
- # http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
- ISO_LONG_YEARS_TABLE = """
- 4 32 60 88
- 9 37 65 93
- 15 43 71 99
- 20 48 76
- 26 54 82
-
- 105 133 161 189
- 111 139 167 195
- 116 144 172
- 122 150 178
- 128 156 184
-
- 201 229 257 285
- 207 235 263 291
- 212 240 268 296
- 218 246 274
- 224 252 280
-
- 303 331 359 387
- 308 336 364 392
- 314 342 370 398
- 320 348 376
- 325 353 381
- """
- iso_long_years = map(int, ISO_LONG_YEARS_TABLE.split())
- iso_long_years.sort()
- L = []
- for i in range(400):
- d = self.theclass(2000+i, 12, 31)
- d1 = self.theclass(1600+i, 12, 31)
- self.assertEqual(d.isocalendar()[1:], d1.isocalendar()[1:])
- if d.isocalendar()[1] == 53:
- L.append(i)
- self.assertEqual(L, iso_long_years)
-
- def test_isoformat(self):
- t = self.theclass(2, 3, 2)
- self.assertEqual(t.isoformat(), "0002-03-02")
-
- def test_ctime(self):
- t = self.theclass(2002, 3, 2)
- self.assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002")
-
- def test_strftime(self):
- t = self.theclass(2005, 3, 2)
- self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05")
- self.assertEqual(t.strftime(""), "") # SF bug #761337
- self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784
-
- self.assertRaises(TypeError, t.strftime) # needs an arg
- self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
- self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
-
- # test that unicode input is allowed (issue 2782)
- self.assertEqual(t.strftime(u"%m"), "03")
-
- # A naive object replaces %z and %Z w/ empty strings.
- self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
-
- #make sure that invalid format specifiers are handled correctly
- #self.assertRaises(ValueError, t.strftime, "%e")
- #self.assertRaises(ValueError, t.strftime, "%")
- #self.assertRaises(ValueError, t.strftime, "%#")
-
- #oh well, some systems just ignore those invalid ones.
- #at least, excercise them to make sure that no crashes
- #are generated
- for f in ["%e", "%", "%#"]:
- try:
- t.strftime(f)
- except ValueError:
- pass
-
- #check that this standard extension works
- t.strftime("%f")
-
-
- def test_format(self):
- dt = self.theclass(2007, 9, 10)
- self.assertEqual(dt.__format__(''), str(dt))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(2007, 9, 10)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(2007, 9, 10)
- self.assertEqual(b.__format__(''), str(dt))
-
- for fmt in ["m:%m d:%d y:%y",
- "m:%m d:%d y:%y H:%H M:%M S:%S",
- "%z %Z",
- ]:
- self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_resolution_info(self):
- self.assertIsInstance(self.theclass.min, self.theclass)
- self.assertIsInstance(self.theclass.max, self.theclass)
- self.assertIsInstance(self.theclass.resolution, timedelta)
- self.assertTrue(self.theclass.max > self.theclass.min)
-
- def test_extreme_timedelta(self):
- big = self.theclass.max - self.theclass.min
- # 3652058 days, 23 hours, 59 minutes, 59 seconds, 999999 microseconds
- n = (big.days*24*3600 + big.seconds)*1000000 + big.microseconds
- # n == 315537897599999999 ~= 2**58.13
- justasbig = timedelta(0, 0, n)
- self.assertEqual(big, justasbig)
- self.assertEqual(self.theclass.min + big, self.theclass.max)
- self.assertEqual(self.theclass.max - big, self.theclass.min)
-
- def test_timetuple(self):
- for i in range(7):
- # January 2, 1956 is a Monday (0)
- d = self.theclass(1956, 1, 2+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 1, 2+i, 0, 0, 0, i, 2+i, -1))
- # February 1, 1956 is a Wednesday (2)
- d = self.theclass(1956, 2, 1+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 2, 1+i, 0, 0, 0, (2+i)%7, 32+i, -1))
- # March 1, 1956 is a Thursday (3), and is the 31+29+1 = 61st day
- # of the year.
- d = self.theclass(1956, 3, 1+i)
- t = d.timetuple()
- self.assertEqual(t, (1956, 3, 1+i, 0, 0, 0, (3+i)%7, 61+i, -1))
- self.assertEqual(t.tm_year, 1956)
- self.assertEqual(t.tm_mon, 3)
- self.assertEqual(t.tm_mday, 1+i)
- self.assertEqual(t.tm_hour, 0)
- self.assertEqual(t.tm_min, 0)
- self.assertEqual(t.tm_sec, 0)
- self.assertEqual(t.tm_wday, (3+i)%7)
- self.assertEqual(t.tm_yday, 61+i)
- self.assertEqual(t.tm_isdst, -1)
-
- def test_pickling(self):
- args = 6, 7, 23
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_compare(self):
- t1 = self.theclass(2, 3, 4)
- t2 = self.theclass(2, 3, 4)
- self.assertTrue(t1 == t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
- self.assertEqual(cmp(t1, t2), 0)
- self.assertEqual(cmp(t2, t1), 0)
-
- for args in (3, 3, 3), (2, 4, 4), (2, 3, 5):
- t2 = self.theclass(*args) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
- self.assertEqual(cmp(t1, t2), -1)
- self.assertEqual(cmp(t2, t1), 1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_mixed_compare(self):
- our = self.theclass(2000, 4, 5)
- self.assertRaises(TypeError, cmp, our, 1)
- self.assertRaises(TypeError, cmp, 1, our)
-
- class AnotherDateTimeClass(object):
- def __cmp__(self, other):
- # Return "equal" so calling this can't be confused with
- # compare-by-address (which never says "equal" for distinct
- # objects).
- return 0
- __hash__ = None # Silence Py3k warning
-
- # This still errors, because date and datetime comparison raise
- # TypeError instead of NotImplemented when they don't know what to
- # do, in order to stop comparison from falling back to the default
- # compare-by-address.
- their = AnotherDateTimeClass()
- self.assertRaises(TypeError, cmp, our, their)
- # Oops: The next stab raises TypeError in the C implementation,
- # but not in the Python implementation of datetime. The difference
- # is due to that the Python implementation defines __cmp__ but
- # the C implementation defines tp_richcompare. This is more pain
- # to fix than it's worth, so commenting out the test.
- # self.assertEqual(cmp(their, our), 0)
-
- # But date and datetime comparison return NotImplemented instead if the
- # other object has a timetuple attr. This gives the other object a
- # chance to do the comparison.
- class Comparable(AnotherDateTimeClass):
- def timetuple(self):
- return ()
-
- their = Comparable()
- self.assertEqual(cmp(our, their), 0)
- self.assertEqual(cmp(their, our), 0)
- self.assertTrue(our == their)
- self.assertTrue(their == our)
-
- def test_bool(self):
- # All dates are considered true.
- self.assertTrue(self.theclass.min)
- self.assertTrue(self.theclass.max)
-
- def test_strftime_out_of_range(self):
- # For nasty technical reasons, we can't handle years before 1900.
- cls = self.theclass
- self.assertEqual(cls(1900, 1, 1).strftime("%Y"), "1900")
- for y in 1, 49, 51, 99, 100, 1000, 1899:
- self.assertRaises(ValueError, cls(y, 1, 1).strftime, "%Y")
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_subclass_date(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.year + self.month
-
- args = 2003, 4, 14
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.toordinal(), dt2.toordinal())
- self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month - 7)
-
- def test_pickling_subclass_date(self):
-
- args = 6, 7, 23
- orig = SubclassDate(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_backdoor_resistance(self):
- # For fast unpickling, the constructor accepts a pickle string.
- # This is a low-overhead backdoor. A user can (by intent or
- # mistake) pass a string directly, which (if it's the right length)
- # will get treated like a pickle, and bypass the normal sanity
- # checks in the constructor. This can create insane objects.
- # The constructor doesn't want to burn the time to validate all
- # fields, but does check the month field. This stops, e.g.,
- # datetime.datetime('1995-03-25') from yielding an insane object.
- base = '1995-03-25'
- if not issubclass(self.theclass, datetime):
- base = base[:4]
- for month_byte in '9', chr(0), chr(13), '\xff':
- self.assertRaises(TypeError, self.theclass,
- base[:2] + month_byte + base[3:])
- for ord_byte in range(1, 13):
- # This shouldn't blow up because of the month byte alone. If
- # the implementation changes to do more-careful checking, it may
- # blow up because other fields are insane.
- self.theclass(base[:2] + chr(ord_byte) + base[3:])
-
-#############################################################################
-# datetime tests
-
-class SubclassDatetime(datetime):
- sub_var = 1
-
-class TestDateTime(TestDate):
-
- theclass = datetime
-
- def test_basic_attributes(self):
- dt = self.theclass(2002, 3, 1, 12, 0)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
- self.assertEqual(dt.hour, 12)
- self.assertEqual(dt.minute, 0)
- self.assertEqual(dt.second, 0)
- self.assertEqual(dt.microsecond, 0)
-
- def test_basic_attributes_nonzero(self):
- # Make sure all attributes are non-zero so bugs in
- # bit-shifting access show up.
- dt = self.theclass(2002, 3, 1, 12, 59, 59, 8000)
- self.assertEqual(dt.year, 2002)
- self.assertEqual(dt.month, 3)
- self.assertEqual(dt.day, 1)
- self.assertEqual(dt.hour, 12)
- self.assertEqual(dt.minute, 59)
- self.assertEqual(dt.second, 59)
- self.assertEqual(dt.microsecond, 8000)
-
- def test_roundtrip(self):
- for dt in (self.theclass(1, 2, 3, 4, 5, 6, 7),
- self.theclass.now()):
- # Verify dt -> string -> datetime identity.
- s = repr(dt)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- dt2 = eval(s)
- self.assertEqual(dt, dt2)
-
- # Verify identity via reconstructing from pieces.
- dt2 = self.theclass(dt.year, dt.month, dt.day,
- dt.hour, dt.minute, dt.second,
- dt.microsecond)
- self.assertEqual(dt, dt2)
-
- def test_isoformat(self):
- t = self.theclass(2, 3, 2, 4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat('T'), "0002-03-02T04:05:01.000123")
- self.assertEqual(t.isoformat(' '), "0002-03-02 04:05:01.000123")
- self.assertEqual(t.isoformat('\x00'), "0002-03-02\x0004:05:01.000123")
- # str is ISO format with the separator forced to a blank.
- self.assertEqual(str(t), "0002-03-02 04:05:01.000123")
-
- t = self.theclass(2, 3, 2)
- self.assertEqual(t.isoformat(), "0002-03-02T00:00:00")
- self.assertEqual(t.isoformat('T'), "0002-03-02T00:00:00")
- self.assertEqual(t.isoformat(' '), "0002-03-02 00:00:00")
- # str is ISO format with the separator forced to a blank.
- self.assertEqual(str(t), "0002-03-02 00:00:00")
-
- def test_format(self):
- dt = self.theclass(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(dt.__format__(''), str(dt))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(2007, 9, 10, 4, 5, 1, 123)
- self.assertEqual(b.__format__(''), str(dt))
-
- for fmt in ["m:%m d:%d y:%y",
- "m:%m d:%d y:%y H:%H M:%M S:%S",
- "%z %Z",
- ]:
- self.assertEqual(dt.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(a.__format__(fmt), dt.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_more_ctime(self):
- # Test fields that TestDate doesn't touch.
- import time
-
- t = self.theclass(2002, 3, 2, 18, 3, 5, 123)
- self.assertEqual(t.ctime(), "Sat Mar 2 18:03:05 2002")
- # Oops! The next line fails on Win2K under MSVC 6, so it's commented
- # out. The difference is that t.ctime() produces " 2" for the day,
- # but platform ctime() produces "02" for the day. According to
- # C99, t.ctime() is correct here.
- # self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
-
- # So test a case where that difference doesn't matter.
- t = self.theclass(2002, 3, 22, 18, 3, 5, 123)
- self.assertEqual(t.ctime(), time.ctime(time.mktime(t.timetuple())))
-
- def test_tz_independent_comparing(self):
- dt1 = self.theclass(2002, 3, 1, 9, 0, 0)
- dt2 = self.theclass(2002, 3, 1, 10, 0, 0)
- dt3 = self.theclass(2002, 3, 1, 9, 0, 0)
- self.assertEqual(dt1, dt3)
- self.assertTrue(dt2 > dt3)
-
- # Make sure comparison doesn't forget microseconds, and isn't done
- # via comparing a float timestamp (an IEEE double doesn't have enough
- # precision to span microsecond resolution across years 1 thru 9999,
- # so comparing via timestamp necessarily calls some distinct values
- # equal).
- dt1 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999998)
- us = timedelta(microseconds=1)
- dt2 = dt1 + us
- self.assertEqual(dt2 - dt1, us)
- self.assertTrue(dt1 < dt2)
-
- def test_strftime_with_bad_tzname_replace(self):
- # verify ok if tzinfo.tzname().replace() returns a non-string
- class MyTzInfo(FixedOffset):
- def tzname(self, dt):
- class MyStr(str):
- def replace(self, *args):
- return None
- return MyStr('name')
- t = self.theclass(2005, 3, 2, 0, 0, 0, 0, MyTzInfo(3, 'name'))
- self.assertRaises(TypeError, t.strftime, '%Z')
-
- def test_bad_constructor_arguments(self):
- # bad years
- self.theclass(MINYEAR, 1, 1) # no exception
- self.theclass(MAXYEAR, 1, 1) # no exception
- self.assertRaises(ValueError, self.theclass, MINYEAR-1, 1, 1)
- self.assertRaises(ValueError, self.theclass, MAXYEAR+1, 1, 1)
- # bad months
- self.theclass(2000, 1, 1) # no exception
- self.theclass(2000, 12, 1) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 0, 1)
- self.assertRaises(ValueError, self.theclass, 2000, 13, 1)
- # bad days
- self.theclass(2000, 2, 29) # no exception
- self.theclass(2004, 2, 29) # no exception
- self.theclass(2400, 2, 29) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 2, 30)
- self.assertRaises(ValueError, self.theclass, 2001, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2100, 2, 29)
- self.assertRaises(ValueError, self.theclass, 1900, 2, 29)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 0)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 32)
- # bad hours
- self.theclass(2000, 1, 31, 0) # no exception
- self.theclass(2000, 1, 31, 23) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 24)
- # bad minutes
- self.theclass(2000, 1, 31, 23, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 60)
- # bad seconds
- self.theclass(2000, 1, 31, 23, 59, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, -1)
- self.assertRaises(ValueError, self.theclass, 2000, 1, 31, 23, 59, 60)
- # bad microseconds
- self.theclass(2000, 1, 31, 23, 59, 59, 0) # no exception
- self.theclass(2000, 1, 31, 23, 59, 59, 999999) # no exception
- self.assertRaises(ValueError, self.theclass,
- 2000, 1, 31, 23, 59, 59, -1)
- self.assertRaises(ValueError, self.theclass,
- 2000, 1, 31, 23, 59, 59,
- 1000000)
-
- def test_hash_equality(self):
- d = self.theclass(2000, 12, 31, 23, 30, 17)
- e = self.theclass(2000, 12, 31, 23, 30, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(2001, 1, 1, 0, 5, 17)
- e = self.theclass(2001, 1, 1, 0, 5, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_computations(self):
- a = self.theclass(2002, 1, 31)
- b = self.theclass(1956, 1, 31)
- diff = a-b
- self.assertEqual(diff.days, 46*365 + len(range(1956, 2002, 4)))
- self.assertEqual(diff.seconds, 0)
- self.assertEqual(diff.microseconds, 0)
- a = self.theclass(2002, 3, 2, 17, 6)
- millisec = timedelta(0, 0, 1000)
- hour = timedelta(0, 3600)
- day = timedelta(1)
- week = timedelta(7)
- self.assertEqual(a + hour, self.theclass(2002, 3, 2, 18, 6))
- self.assertEqual(hour + a, self.theclass(2002, 3, 2, 18, 6))
- self.assertEqual(a + 10*hour, self.theclass(2002, 3, 3, 3, 6))
- self.assertEqual(a - hour, self.theclass(2002, 3, 2, 16, 6))
- self.assertEqual(-hour + a, self.theclass(2002, 3, 2, 16, 6))
- self.assertEqual(a - hour, a + -hour)
- self.assertEqual(a - 20*hour, self.theclass(2002, 3, 1, 21, 6))
- self.assertEqual(a + day, self.theclass(2002, 3, 3, 17, 6))
- self.assertEqual(a - day, self.theclass(2002, 3, 1, 17, 6))
- self.assertEqual(a + week, self.theclass(2002, 3, 9, 17, 6))
- self.assertEqual(a - week, self.theclass(2002, 2, 23, 17, 6))
- self.assertEqual(a + 52*week, self.theclass(2003, 3, 1, 17, 6))
- self.assertEqual(a - 52*week, self.theclass(2001, 3, 3, 17, 6))
- self.assertEqual((a + week) - a, week)
- self.assertEqual((a + day) - a, day)
- self.assertEqual((a + hour) - a, hour)
- self.assertEqual((a + millisec) - a, millisec)
- self.assertEqual((a - week) - a, -week)
- self.assertEqual((a - day) - a, -day)
- self.assertEqual((a - hour) - a, -hour)
- self.assertEqual((a - millisec) - a, -millisec)
- self.assertEqual(a - (a + week), -week)
- self.assertEqual(a - (a + day), -day)
- self.assertEqual(a - (a + hour), -hour)
- self.assertEqual(a - (a + millisec), -millisec)
- self.assertEqual(a - (a - week), week)
- self.assertEqual(a - (a - day), day)
- self.assertEqual(a - (a - hour), hour)
- self.assertEqual(a - (a - millisec), millisec)
- self.assertEqual(a + (week + day + hour + millisec),
- self.theclass(2002, 3, 10, 18, 6, 0, 1000))
- self.assertEqual(a + (week + day + hour + millisec),
- (((a + week) + day) + hour) + millisec)
- self.assertEqual(a - (week + day + hour + millisec),
- self.theclass(2002, 2, 22, 16, 5, 59, 999000))
- self.assertEqual(a - (week + day + hour + millisec),
- (((a - week) - day) - hour) - millisec)
- # Add/sub ints, longs, floats should be illegal
- for i in 1, 1L, 1.0:
- self.assertRaises(TypeError, lambda: a+i)
- self.assertRaises(TypeError, lambda: a-i)
- self.assertRaises(TypeError, lambda: i+a)
- self.assertRaises(TypeError, lambda: i-a)
-
- # delta - datetime is senseless.
- self.assertRaises(TypeError, lambda: day - a)
- # mixing datetime and (delta or datetime) via * or // is senseless
- self.assertRaises(TypeError, lambda: day * a)
- self.assertRaises(TypeError, lambda: a * day)
- self.assertRaises(TypeError, lambda: day // a)
- self.assertRaises(TypeError, lambda: a // day)
- self.assertRaises(TypeError, lambda: a * a)
- self.assertRaises(TypeError, lambda: a // a)
- # datetime + datetime is senseless
- self.assertRaises(TypeError, lambda: a + a)
-
- def test_pickling(self):
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_more_pickling(self):
- a = self.theclass(2003, 2, 7, 16, 48, 37, 444116)
- s = pickle.dumps(a)
- b = pickle.loads(s)
- self.assertEqual(b.year, 2003)
- self.assertEqual(b.month, 2)
- self.assertEqual(b.day, 7)
-
- def test_pickling_subclass_datetime(self):
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = SubclassDatetime(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_more_compare(self):
- # The test_compare() inherited from TestDate covers the error cases.
- # We just want to test lexicographic ordering on the members datetime
- # has that date lacks.
- args = [2000, 11, 29, 20, 58, 16, 999998]
- t1 = self.theclass(*args)
- t2 = self.theclass(*args)
- self.assertTrue(t1 == t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
- self.assertEqual(cmp(t1, t2), 0)
- self.assertEqual(cmp(t2, t1), 0)
-
- for i in range(len(args)):
- newargs = args[:]
- newargs[i] = args[i] + 1
- t2 = self.theclass(*newargs) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
- self.assertEqual(cmp(t1, t2), -1)
- self.assertEqual(cmp(t2, t1), 1)
-
-
- # A helper for timestamp constructor tests.
- def verify_field_equality(self, expected, got):
- self.assertEqual(expected.tm_year, got.year)
- self.assertEqual(expected.tm_mon, got.month)
- self.assertEqual(expected.tm_mday, got.day)
- self.assertEqual(expected.tm_hour, got.hour)
- self.assertEqual(expected.tm_min, got.minute)
- self.assertEqual(expected.tm_sec, got.second)
-
- def test_fromtimestamp(self):
- import time
-
- ts = time.time()
- expected = time.localtime(ts)
- got = self.theclass.fromtimestamp(ts)
- self.verify_field_equality(expected, got)
-
- def test_utcfromtimestamp(self):
- import time
-
- ts = time.time()
- expected = time.gmtime(ts)
- got = self.theclass.utcfromtimestamp(ts)
- self.verify_field_equality(expected, got)
-
- def test_microsecond_rounding(self):
- # Test whether fromtimestamp "rounds up" floats that are less
- # than one microsecond smaller than an integer.
- self.assertEqual(self.theclass.fromtimestamp(0.9999999),
- self.theclass.fromtimestamp(1))
-
- def test_insane_fromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.fromtimestamp,
- insane)
-
- def test_insane_utcfromtimestamp(self):
- # It's possible that some platform maps time_t to double,
- # and that this test will fail there. This test should
- # exempt such platforms (provided they return reasonable
- # results!).
- for insane in -1e200, 1e200:
- self.assertRaises(ValueError, self.theclass.utcfromtimestamp,
- insane)
- @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
- def test_negative_float_fromtimestamp(self):
- # The result is tz-dependent; at least test that this doesn't
- # fail (like it did before bug 1646728 was fixed).
- self.theclass.fromtimestamp(-1.05)
-
- @unittest.skipIf(sys.platform == "win32", "Windows doesn't accept negative timestamps")
- def test_negative_float_utcfromtimestamp(self):
- d = self.theclass.utcfromtimestamp(-1.05)
- self.assertEqual(d, self.theclass(1969, 12, 31, 23, 59, 58, 950000))
-
- def test_utcnow(self):
- import time
-
- # Call it a success if utcnow() and utcfromtimestamp() are within
- # a second of each other.
- tolerance = timedelta(seconds=1)
- for dummy in range(3):
- from_now = self.theclass.utcnow()
- from_timestamp = self.theclass.utcfromtimestamp(time.time())
- if abs(from_timestamp - from_now) <= tolerance:
- break
- # Else try again a few times.
- self.assertTrue(abs(from_timestamp - from_now) <= tolerance)
-
- def test_strptime(self):
- import _strptime
-
- string = '2004-12-01 13:02:47.197'
- format = '%Y-%m-%d %H:%M:%S.%f'
- result, frac = _strptime._strptime(string, format)
- expected = self.theclass(*(result[0:6]+(frac,)))
- got = self.theclass.strptime(string, format)
- self.assertEqual(expected, got)
-
- def test_more_timetuple(self):
- # This tests fields beyond those tested by the TestDate.test_timetuple.
- t = self.theclass(2004, 12, 31, 6, 22, 33)
- self.assertEqual(t.timetuple(), (2004, 12, 31, 6, 22, 33, 4, 366, -1))
- self.assertEqual(t.timetuple(),
- (t.year, t.month, t.day,
- t.hour, t.minute, t.second,
- t.weekday(),
- t.toordinal() - date(t.year, 1, 1).toordinal() + 1,
- -1))
- tt = t.timetuple()
- self.assertEqual(tt.tm_year, t.year)
- self.assertEqual(tt.tm_mon, t.month)
- self.assertEqual(tt.tm_mday, t.day)
- self.assertEqual(tt.tm_hour, t.hour)
- self.assertEqual(tt.tm_min, t.minute)
- self.assertEqual(tt.tm_sec, t.second)
- self.assertEqual(tt.tm_wday, t.weekday())
- self.assertEqual(tt.tm_yday, t.toordinal() -
- date(t.year, 1, 1).toordinal() + 1)
- self.assertEqual(tt.tm_isdst, -1)
-
- def test_more_strftime(self):
- # This tests fields beyond those tested by the TestDate.test_strftime.
- t = self.theclass(2004, 12, 31, 6, 22, 33, 47)
- self.assertEqual(t.strftime("%m %d %y %f %S %M %H %j"),
- "12 31 04 000047 33 22 06 366")
-
- def test_extract(self):
- dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
- self.assertEqual(dt.date(), date(2002, 3, 4))
- self.assertEqual(dt.time(), time(18, 45, 3, 1234))
-
- def test_combine(self):
- d = date(2002, 3, 4)
- t = time(18, 45, 3, 1234)
- expected = self.theclass(2002, 3, 4, 18, 45, 3, 1234)
- combine = self.theclass.combine
- dt = combine(d, t)
- self.assertEqual(dt, expected)
-
- dt = combine(time=t, date=d)
- self.assertEqual(dt, expected)
-
- self.assertEqual(d, dt.date())
- self.assertEqual(t, dt.time())
- self.assertEqual(dt, combine(dt.date(), dt.time()))
-
- self.assertRaises(TypeError, combine) # need an arg
- self.assertRaises(TypeError, combine, d) # need two args
- self.assertRaises(TypeError, combine, t, d) # args reversed
- self.assertRaises(TypeError, combine, d, t, 1) # too many args
- self.assertRaises(TypeError, combine, "date", "time") # wrong types
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3, 4, 5, 6, 7]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4),
- ("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_astimezone(self):
- # Pretty boring! The TZ test is more interesting here. astimezone()
- # simply can't be applied to a naive object.
- dt = self.theclass.now()
- f = FixedOffset(44, "")
- self.assertRaises(TypeError, dt.astimezone) # not enough args
- self.assertRaises(TypeError, dt.astimezone, f, f) # too many args
- self.assertRaises(TypeError, dt.astimezone, dt) # arg wrong type
- self.assertRaises(ValueError, dt.astimezone, f) # naive
- self.assertRaises(ValueError, dt.astimezone, tz=f) # naive
-
- class Bogus(tzinfo):
- def utcoffset(self, dt): return None
- def dst(self, dt): return timedelta(0)
- bog = Bogus()
- self.assertRaises(ValueError, dt.astimezone, bog) # naive
-
- class AlsoBogus(tzinfo):
- def utcoffset(self, dt): return timedelta(0)
- def dst(self, dt): return None
- alsobog = AlsoBogus()
- self.assertRaises(ValueError, dt.astimezone, alsobog) # also naive
-
- def test_subclass_datetime(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.year + self.month + self.second
-
- args = 2003, 4, 14, 12, 13, 41
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.toordinal(), dt2.toordinal())
- self.assertEqual(dt2.newmeth(-7), dt1.year + dt1.month +
- dt1.second - 7)
-
-class SubclassTime(time):
- sub_var = 1
-
-class TestTime(HarmlessMixedComparison, unittest.TestCase):
-
- theclass = time
-
- def test_basic_attributes(self):
- t = self.theclass(12, 0)
- self.assertEqual(t.hour, 12)
- self.assertEqual(t.minute, 0)
- self.assertEqual(t.second, 0)
- self.assertEqual(t.microsecond, 0)
-
- def test_basic_attributes_nonzero(self):
- # Make sure all attributes are non-zero so bugs in
- # bit-shifting access show up.
- t = self.theclass(12, 59, 59, 8000)
- self.assertEqual(t.hour, 12)
- self.assertEqual(t.minute, 59)
- self.assertEqual(t.second, 59)
- self.assertEqual(t.microsecond, 8000)
-
- def test_roundtrip(self):
- t = self.theclass(1, 2, 3, 4)
-
- # Verify t -> string -> time identity.
- s = repr(t)
- self.assertTrue(s.startswith('datetime.'))
- s = s[9:]
- t2 = eval(s)
- self.assertEqual(t, t2)
-
- # Verify identity via reconstructing from pieces.
- t2 = self.theclass(t.hour, t.minute, t.second,
- t.microsecond)
- self.assertEqual(t, t2)
-
- def test_comparing(self):
- args = [1, 2, 3, 4]
- t1 = self.theclass(*args)
- t2 = self.theclass(*args)
- self.assertTrue(t1 == t2)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t1 >= t2)
- self.assertTrue(not t1 != t2)
- self.assertTrue(not t1 < t2)
- self.assertTrue(not t1 > t2)
- self.assertEqual(cmp(t1, t2), 0)
- self.assertEqual(cmp(t2, t1), 0)
-
- for i in range(len(args)):
- newargs = args[:]
- newargs[i] = args[i] + 1
- t2 = self.theclass(*newargs) # this is larger than t1
- self.assertTrue(t1 < t2)
- self.assertTrue(t2 > t1)
- self.assertTrue(t1 <= t2)
- self.assertTrue(t2 >= t1)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 != t1)
- self.assertTrue(not t1 == t2)
- self.assertTrue(not t2 == t1)
- self.assertTrue(not t1 > t2)
- self.assertTrue(not t2 < t1)
- self.assertTrue(not t1 >= t2)
- self.assertTrue(not t2 <= t1)
- self.assertEqual(cmp(t1, t2), -1)
- self.assertEqual(cmp(t2, t1), 1)
-
- for badarg in OTHERSTUFF:
- self.assertEqual(t1 == badarg, False)
- self.assertEqual(t1 != badarg, True)
- self.assertEqual(badarg == t1, False)
- self.assertEqual(badarg != t1, True)
-
- self.assertRaises(TypeError, lambda: t1 <= badarg)
- self.assertRaises(TypeError, lambda: t1 < badarg)
- self.assertRaises(TypeError, lambda: t1 > badarg)
- self.assertRaises(TypeError, lambda: t1 >= badarg)
- self.assertRaises(TypeError, lambda: badarg <= t1)
- self.assertRaises(TypeError, lambda: badarg < t1)
- self.assertRaises(TypeError, lambda: badarg > t1)
- self.assertRaises(TypeError, lambda: badarg >= t1)
-
- def test_bad_constructor_arguments(self):
- # bad hours
- self.theclass(0, 0) # no exception
- self.theclass(23, 0) # no exception
- self.assertRaises(ValueError, self.theclass, -1, 0)
- self.assertRaises(ValueError, self.theclass, 24, 0)
- # bad minutes
- self.theclass(23, 0) # no exception
- self.theclass(23, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 23, -1)
- self.assertRaises(ValueError, self.theclass, 23, 60)
- # bad seconds
- self.theclass(23, 59, 0) # no exception
- self.theclass(23, 59, 59) # no exception
- self.assertRaises(ValueError, self.theclass, 23, 59, -1)
- self.assertRaises(ValueError, self.theclass, 23, 59, 60)
- # bad microseconds
- self.theclass(23, 59, 59, 0) # no exception
- self.theclass(23, 59, 59, 999999) # no exception
- self.assertRaises(ValueError, self.theclass, 23, 59, 59, -1)
- self.assertRaises(ValueError, self.theclass, 23, 59, 59, 1000000)
-
- def test_hash_equality(self):
- d = self.theclass(23, 30, 17)
- e = self.theclass(23, 30, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- d = self.theclass(0, 5, 17)
- e = self.theclass(0, 5, 17)
- self.assertEqual(d, e)
- self.assertEqual(hash(d), hash(e))
-
- dic = {d: 1}
- dic[e] = 2
- self.assertEqual(len(dic), 1)
- self.assertEqual(dic[d], 2)
- self.assertEqual(dic[e], 2)
-
- def test_isoformat(self):
- t = self.theclass(4, 5, 1, 123)
- self.assertEqual(t.isoformat(), "04:05:01.000123")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass()
- self.assertEqual(t.isoformat(), "00:00:00")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=1)
- self.assertEqual(t.isoformat(), "00:00:00.000001")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=10)
- self.assertEqual(t.isoformat(), "00:00:00.000010")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=100)
- self.assertEqual(t.isoformat(), "00:00:00.000100")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=1000)
- self.assertEqual(t.isoformat(), "00:00:00.001000")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=10000)
- self.assertEqual(t.isoformat(), "00:00:00.010000")
- self.assertEqual(t.isoformat(), str(t))
-
- t = self.theclass(microsecond=100000)
- self.assertEqual(t.isoformat(), "00:00:00.100000")
- self.assertEqual(t.isoformat(), str(t))
-
- def test_1653736(self):
- # verify it doesn't accept extra keyword arguments
- t = self.theclass(second=1)
- self.assertRaises(TypeError, t.isoformat, foo=3)
-
- def test_strftime(self):
- t = self.theclass(1, 2, 3, 4)
- self.assertEqual(t.strftime('%H %M %S %f'), "01 02 03 000004")
- # A naive object replaces %z and %Z with empty strings.
- self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
-
- def test_format(self):
- t = self.theclass(1, 2, 3, 4)
- self.assertEqual(t.__format__(''), str(t))
-
- # check that a derived class's __str__() gets called
- class A(self.theclass):
- def __str__(self):
- return 'A'
- a = A(1, 2, 3, 4)
- self.assertEqual(a.__format__(''), 'A')
-
- # check that a derived class's strftime gets called
- class B(self.theclass):
- def strftime(self, format_spec):
- return 'B'
- b = B(1, 2, 3, 4)
- self.assertEqual(b.__format__(''), str(t))
-
- for fmt in ['%H %M %S',
- ]:
- self.assertEqual(t.__format__(fmt), t.strftime(fmt))
- self.assertEqual(a.__format__(fmt), t.strftime(fmt))
- self.assertEqual(b.__format__(fmt), 'B')
-
- def test_str(self):
- self.assertEqual(str(self.theclass(1, 2, 3, 4)), "01:02:03.000004")
- self.assertEqual(str(self.theclass(10, 2, 3, 4000)), "10:02:03.004000")
- self.assertEqual(str(self.theclass(0, 2, 3, 400000)), "00:02:03.400000")
- self.assertEqual(str(self.theclass(12, 2, 3, 0)), "12:02:03")
- self.assertEqual(str(self.theclass(23, 15, 0, 0)), "23:15:00")
-
- def test_repr(self):
- name = 'datetime.' + self.theclass.__name__
- self.assertEqual(repr(self.theclass(1, 2, 3, 4)),
- "%s(1, 2, 3, 4)" % name)
- self.assertEqual(repr(self.theclass(10, 2, 3, 4000)),
- "%s(10, 2, 3, 4000)" % name)
- self.assertEqual(repr(self.theclass(0, 2, 3, 400000)),
- "%s(0, 2, 3, 400000)" % name)
- self.assertEqual(repr(self.theclass(12, 2, 3, 0)),
- "%s(12, 2, 3)" % name)
- self.assertEqual(repr(self.theclass(23, 15, 0, 0)),
- "%s(23, 15)" % name)
-
- def test_resolution_info(self):
- self.assertIsInstance(self.theclass.min, self.theclass)
- self.assertIsInstance(self.theclass.max, self.theclass)
- self.assertIsInstance(self.theclass.resolution, timedelta)
- self.assertTrue(self.theclass.max > self.theclass.min)
-
- def test_pickling(self):
- args = 20, 59, 16, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_pickling_subclass_time(self):
- args = 20, 59, 16, 64**2
- orig = SubclassTime(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- def test_bool(self):
- cls = self.theclass
- self.assertTrue(cls(1))
- self.assertTrue(cls(0, 1))
- self.assertTrue(cls(0, 0, 1))
- self.assertTrue(cls(0, 0, 0, 1))
- self.assertTrue(not cls(0))
- self.assertTrue(not cls())
-
- def test_replace(self):
- cls = self.theclass
- args = [1, 2, 3, 4]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Out of bounds.
- base = cls(1)
- self.assertRaises(ValueError, base.replace, hour=24)
- self.assertRaises(ValueError, base.replace, minute=-1)
- self.assertRaises(ValueError, base.replace, second=100)
- self.assertRaises(ValueError, base.replace, microsecond=1000000)
-
- def test_subclass_time(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.second
-
- args = 4, 5, 6
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.isoformat(), dt2.isoformat())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
-
- def test_backdoor_resistance(self):
- # see TestDate.test_backdoor_resistance().
- base = '2:59.0'
- for hour_byte in ' ', '9', chr(24), '\xff':
- self.assertRaises(TypeError, self.theclass,
- hour_byte + base[1:])
-
-# A mixin for classes with a tzinfo= argument. Subclasses must define
-# theclass as a class atribute, and theclass(1, 1, 1, tzinfo=whatever)
-# must be legit (which is true for time and datetime).
-class TZInfoBase:
-
- def test_argument_passing(self):
- cls = self.theclass
- # A datetime passes itself on, a time passes None.
- class introspective(tzinfo):
- def tzname(self, dt): return dt and "real" or "none"
- def utcoffset(self, dt):
- return timedelta(minutes = dt and 42 or -42)
- dst = utcoffset
-
- obj = cls(1, 2, 3, tzinfo=introspective())
-
- expected = cls is time and "none" or "real"
- self.assertEqual(obj.tzname(), expected)
-
- expected = timedelta(minutes=(cls is time and -42 or 42))
- self.assertEqual(obj.utcoffset(), expected)
- self.assertEqual(obj.dst(), expected)
-
- def test_bad_tzinfo_classes(self):
- cls = self.theclass
- self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=12)
-
- class NiceTry(object):
- def __init__(self): pass
- def utcoffset(self, dt): pass
- self.assertRaises(TypeError, cls, 1, 1, 1, tzinfo=NiceTry)
-
- class BetterTry(tzinfo):
- def __init__(self): pass
- def utcoffset(self, dt): pass
- b = BetterTry()
- t = cls(1, 1, 1, tzinfo=b)
- self.assertTrue(t.tzinfo is b)
-
- def test_utc_offset_out_of_bounds(self):
- class Edgy(tzinfo):
- def __init__(self, offset):
- self.offset = timedelta(minutes=offset)
- def utcoffset(self, dt):
- return self.offset
-
- cls = self.theclass
- for offset, legit in ((-1440, False),
- (-1439, True),
- (1439, True),
- (1440, False)):
- if cls is time:
- t = cls(1, 2, 3, tzinfo=Edgy(offset))
- elif cls is datetime:
- t = cls(6, 6, 6, 1, 2, 3, tzinfo=Edgy(offset))
- else:
- assert 0, "impossible"
- if legit:
- aofs = abs(offset)
- h, m = divmod(aofs, 60)
- tag = "%c%02d:%02d" % (offset < 0 and '-' or '+', h, m)
- if isinstance(t, datetime):
- t = t.timetz()
- self.assertEqual(str(t), "01:02:03" + tag)
- else:
- self.assertRaises(ValueError, str, t)
-
- def test_tzinfo_classes(self):
- cls = self.theclass
- class C1(tzinfo):
- def utcoffset(self, dt): return None
- def dst(self, dt): return None
- def tzname(self, dt): return None
- for t in (cls(1, 1, 1),
- cls(1, 1, 1, tzinfo=None),
- cls(1, 1, 1, tzinfo=C1())):
- self.assertTrue(t.utcoffset() is None)
- self.assertTrue(t.dst() is None)
- self.assertTrue(t.tzname() is None)
-
- class C3(tzinfo):
- def utcoffset(self, dt): return timedelta(minutes=-1439)
- def dst(self, dt): return timedelta(minutes=1439)
- def tzname(self, dt): return "aname"
- t = cls(1, 1, 1, tzinfo=C3())
- self.assertEqual(t.utcoffset(), timedelta(minutes=-1439))
- self.assertEqual(t.dst(), timedelta(minutes=1439))
- self.assertEqual(t.tzname(), "aname")
-
- # Wrong types.
- class C4(tzinfo):
- def utcoffset(self, dt): return "aname"
- def dst(self, dt): return 7
- def tzname(self, dt): return 0
- t = cls(1, 1, 1, tzinfo=C4())
- self.assertRaises(TypeError, t.utcoffset)
- self.assertRaises(TypeError, t.dst)
- self.assertRaises(TypeError, t.tzname)
-
- # Offset out of range.
- class C6(tzinfo):
- def utcoffset(self, dt): return timedelta(hours=-24)
- def dst(self, dt): return timedelta(hours=24)
- t = cls(1, 1, 1, tzinfo=C6())
- self.assertRaises(ValueError, t.utcoffset)
- self.assertRaises(ValueError, t.dst)
-
- # Not a whole number of minutes.
- class C7(tzinfo):
- def utcoffset(self, dt): return timedelta(seconds=61)
- def dst(self, dt): return timedelta(microseconds=-81)
- t = cls(1, 1, 1, tzinfo=C7())
- self.assertRaises(ValueError, t.utcoffset)
- self.assertRaises(ValueError, t.dst)
-
- def test_aware_compare(self):
- cls = self.theclass
-
- # Ensure that utcoffset() gets ignored if the comparands have
- # the same tzinfo member.
- class OperandDependentOffset(tzinfo):
- def utcoffset(self, t):
- if t.minute < 10:
- # d0 and d1 equal after adjustment
- return timedelta(minutes=t.minute)
- else:
- # d2 off in the weeds
- return timedelta(minutes=59)
-
- base = cls(8, 9, 10, tzinfo=OperandDependentOffset())
- d0 = base.replace(minute=3)
- d1 = base.replace(minute=9)
- d2 = base.replace(minute=11)
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = cmp(x, y)
- expected = cmp(x.minute, y.minute)
- self.assertEqual(got, expected)
-
- # However, if they're different members, uctoffset is not ignored.
- # Note that a time can't actually have an operand-depedent offset,
- # though (and time.utcoffset() passes None to tzinfo.utcoffset()),
- # so skip this test for time.
- if cls is not time:
- d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
- d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
- d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = cmp(x, y)
- if (x is d0 or x is d1) and (y is d0 or y is d1):
- expected = 0
- elif x is y is d2:
- expected = 0
- elif x is d2:
- expected = -1
- else:
- assert y is d2
- expected = 1
- self.assertEqual(got, expected)
-
-
-# Testing time objects with a non-None tzinfo.
-class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
- theclass = time
-
- def test_empty(self):
- t = self.theclass()
- self.assertEqual(t.hour, 0)
- self.assertEqual(t.minute, 0)
- self.assertEqual(t.second, 0)
- self.assertEqual(t.microsecond, 0)
- self.assertTrue(t.tzinfo is None)
-
- def test_zones(self):
- est = FixedOffset(-300, "EST", 1)
- utc = FixedOffset(0, "UTC", -2)
- met = FixedOffset(60, "MET", 3)
- t1 = time( 7, 47, tzinfo=est)
- t2 = time(12, 47, tzinfo=utc)
- t3 = time(13, 47, tzinfo=met)
- t4 = time(microsecond=40)
- t5 = time(microsecond=40, tzinfo=utc)
-
- self.assertEqual(t1.tzinfo, est)
- self.assertEqual(t2.tzinfo, utc)
- self.assertEqual(t3.tzinfo, met)
- self.assertTrue(t4.tzinfo is None)
- self.assertEqual(t5.tzinfo, utc)
-
- self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
- self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
- self.assertTrue(t4.utcoffset() is None)
- self.assertRaises(TypeError, t1.utcoffset, "no args")
-
- self.assertEqual(t1.tzname(), "EST")
- self.assertEqual(t2.tzname(), "UTC")
- self.assertEqual(t3.tzname(), "MET")
- self.assertTrue(t4.tzname() is None)
- self.assertRaises(TypeError, t1.tzname, "no args")
-
- self.assertEqual(t1.dst(), timedelta(minutes=1))
- self.assertEqual(t2.dst(), timedelta(minutes=-2))
- self.assertEqual(t3.dst(), timedelta(minutes=3))
- self.assertTrue(t4.dst() is None)
- self.assertRaises(TypeError, t1.dst, "no args")
-
- self.assertEqual(hash(t1), hash(t2))
- self.assertEqual(hash(t1), hash(t3))
- self.assertEqual(hash(t2), hash(t3))
-
- self.assertEqual(t1, t2)
- self.assertEqual(t1, t3)
- self.assertEqual(t2, t3)
- self.assertRaises(TypeError, lambda: t4 == t5) # mixed tz-aware & naive
- self.assertRaises(TypeError, lambda: t4 < t5) # mixed tz-aware & naive
- self.assertRaises(TypeError, lambda: t5 < t4) # mixed tz-aware & naive
-
- self.assertEqual(str(t1), "07:47:00-05:00")
- self.assertEqual(str(t2), "12:47:00+00:00")
- self.assertEqual(str(t3), "13:47:00+01:00")
- self.assertEqual(str(t4), "00:00:00.000040")
- self.assertEqual(str(t5), "00:00:00.000040+00:00")
-
- self.assertEqual(t1.isoformat(), "07:47:00-05:00")
- self.assertEqual(t2.isoformat(), "12:47:00+00:00")
- self.assertEqual(t3.isoformat(), "13:47:00+01:00")
- self.assertEqual(t4.isoformat(), "00:00:00.000040")
- self.assertEqual(t5.isoformat(), "00:00:00.000040+00:00")
-
- d = 'datetime.time'
- self.assertEqual(repr(t1), d + "(7, 47, tzinfo=est)")
- self.assertEqual(repr(t2), d + "(12, 47, tzinfo=utc)")
- self.assertEqual(repr(t3), d + "(13, 47, tzinfo=met)")
- self.assertEqual(repr(t4), d + "(0, 0, 0, 40)")
- self.assertEqual(repr(t5), d + "(0, 0, 0, 40, tzinfo=utc)")
-
- self.assertEqual(t1.strftime("%H:%M:%S %%Z=%Z %%z=%z"),
- "07:47:00 %Z=EST %z=-0500")
- self.assertEqual(t2.strftime("%H:%M:%S %Z %z"), "12:47:00 UTC +0000")
- self.assertEqual(t3.strftime("%H:%M:%S %Z %z"), "13:47:00 MET +0100")
-
- yuck = FixedOffset(-1439, "%z %Z %%z%%Z")
- t1 = time(23, 59, tzinfo=yuck)
- self.assertEqual(t1.strftime("%H:%M %%Z='%Z' %%z='%z'"),
- "23:59 %Z='%z %Z %%z%%Z' %z='-2359'")
-
- # Check that an invalid tzname result raises an exception.
- class Badtzname(tzinfo):
- def tzname(self, dt): return 42
- t = time(2, 3, 4, tzinfo=Badtzname())
- self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
- self.assertRaises(TypeError, t.strftime, "%Z")
-
- def test_hash_edge_cases(self):
- # Offsets that overflow a basic time.
- t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
- t2 = self.theclass(0, 0, 2, 3, tzinfo=FixedOffset(1438, ""))
- self.assertEqual(hash(t1), hash(t2))
-
- t1 = self.theclass(23, 58, 6, 100, tzinfo=FixedOffset(-1000, ""))
- t2 = self.theclass(23, 48, 6, 100, tzinfo=FixedOffset(-1010, ""))
- self.assertEqual(hash(t1), hash(t2))
-
- def test_pickling(self):
- # Try one without a tzinfo.
- args = 20, 59, 16, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- # Try one with a tzinfo.
- tinfo = PicklableFixedOffset(-300, 'cookie')
- orig = self.theclass(5, 6, 7, tzinfo=tinfo)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
- self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
- self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(derived.tzname(), 'cookie')
-
- def test_more_bool(self):
- # Test cases with non-None tzinfo.
- cls = self.theclass
-
- t = cls(0, tzinfo=FixedOffset(-300, ""))
- self.assertTrue(t)
-
- t = cls(5, tzinfo=FixedOffset(-300, ""))
- self.assertTrue(t)
-
- t = cls(5, tzinfo=FixedOffset(300, ""))
- self.assertTrue(not t)
-
- t = cls(23, 59, tzinfo=FixedOffset(23*60 + 59, ""))
- self.assertTrue(not t)
-
- # Mostly ensuring this doesn't overflow internally.
- t = cls(0, tzinfo=FixedOffset(23*60 + 59, ""))
- self.assertTrue(t)
-
- # But this should yield a value error -- the utcoffset is bogus.
- t = cls(0, tzinfo=FixedOffset(24*60, ""))
- self.assertRaises(ValueError, lambda: bool(t))
-
- # Likewise.
- t = cls(0, tzinfo=FixedOffset(-24*60, ""))
- self.assertRaises(ValueError, lambda: bool(t))
-
- def test_replace(self):
- cls = self.theclass
- z100 = FixedOffset(100, "+100")
- zm200 = FixedOffset(timedelta(minutes=-200), "-200")
- args = [1, 2, 3, 4, z100]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8),
- ("tzinfo", zm200)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Ensure we can get rid of a tzinfo.
- self.assertEqual(base.tzname(), "+100")
- base2 = base.replace(tzinfo=None)
- self.assertTrue(base2.tzinfo is None)
- self.assertTrue(base2.tzname() is None)
-
- # Ensure we can add one.
- base3 = base2.replace(tzinfo=z100)
- self.assertEqual(base, base3)
- self.assertTrue(base.tzinfo is base3.tzinfo)
-
- # Out of bounds.
- base = cls(1)
- self.assertRaises(ValueError, base.replace, hour=24)
- self.assertRaises(ValueError, base.replace, minute=-1)
- self.assertRaises(ValueError, base.replace, second=100)
- self.assertRaises(ValueError, base.replace, microsecond=1000000)
-
- def test_mixed_compare(self):
- t1 = time(1, 2, 3)
- t2 = time(1, 2, 3)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=None)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(None, ""))
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(0, ""))
- self.assertRaises(TypeError, lambda: t1 == t2)
-
- # In time w/ identical tzinfo objects, utcoffset is ignored.
- class Varies(tzinfo):
- def __init__(self):
- self.offset = timedelta(minutes=22)
- def utcoffset(self, t):
- self.offset += timedelta(minutes=1)
- return self.offset
-
- v = Varies()
- t1 = t2.replace(tzinfo=v)
- t2 = t2.replace(tzinfo=v)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
- self.assertEqual(t1, t2)
-
- # But if they're not identical, it isn't ignored.
- t2 = t2.replace(tzinfo=Varies())
- self.assertTrue(t1 < t2) # t1's offset counter still going up
-
- def test_subclass_timetz(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.second
-
- args = 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.second - 7)
-
-
-# Testing datetime objects with a non-None tzinfo.
-
-class TestDateTimeTZ(TestDateTime, TZInfoBase, unittest.TestCase):
- theclass = datetime
-
- def test_trivial(self):
- dt = self.theclass(1, 2, 3, 4, 5, 6, 7)
- self.assertEqual(dt.year, 1)
- self.assertEqual(dt.month, 2)
- self.assertEqual(dt.day, 3)
- self.assertEqual(dt.hour, 4)
- self.assertEqual(dt.minute, 5)
- self.assertEqual(dt.second, 6)
- self.assertEqual(dt.microsecond, 7)
- self.assertEqual(dt.tzinfo, None)
-
- def test_even_more_compare(self):
- # The test_compare() and test_more_compare() inherited from TestDate
- # and TestDateTime covered non-tzinfo cases.
-
- # Smallest possible after UTC adjustment.
- t1 = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
- # Largest possible after UTC adjustment.
- t2 = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, ""))
-
- # Make sure those compare correctly, and w/o overflow.
- self.assertTrue(t1 < t2)
- self.assertTrue(t1 != t2)
- self.assertTrue(t2 > t1)
-
- self.assertTrue(t1 == t1)
- self.assertTrue(t2 == t2)
-
- # Equal afer adjustment.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""))
- t2 = self.theclass(2, 1, 1, 3, 13, tzinfo=FixedOffset(3*60+13+2, ""))
- self.assertEqual(t1, t2)
-
- # Change t1 not to subtract a minute, and t1 should be larger.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(0, ""))
- self.assertTrue(t1 > t2)
-
- # Change t1 to subtract 2 minutes, and t1 should be smaller.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(2, ""))
- self.assertTrue(t1 < t2)
-
- # Back to the original t1, but make seconds resolve it.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
- second=1)
- self.assertTrue(t1 > t2)
-
- # Likewise, but make microseconds resolve it.
- t1 = self.theclass(1, 12, 31, 23, 59, tzinfo=FixedOffset(1, ""),
- microsecond=1)
- self.assertTrue(t1 > t2)
-
- # Make t2 naive and it should fail.
- t2 = self.theclass.min
- self.assertRaises(TypeError, lambda: t1 == t2)
- self.assertEqual(t2, t2)
-
- # It's also naive if it has tzinfo but tzinfo.utcoffset() is None.
- class Naive(tzinfo):
- def utcoffset(self, dt): return None
- t2 = self.theclass(5, 6, 7, tzinfo=Naive())
- self.assertRaises(TypeError, lambda: t1 == t2)
- self.assertEqual(t2, t2)
-
- # OTOH, it's OK to compare two of these mixing the two ways of being
- # naive.
- t1 = self.theclass(5, 6, 7)
- self.assertEqual(t1, t2)
-
- # Try a bogus uctoffset.
- class Bogus(tzinfo):
- def utcoffset(self, dt):
- return timedelta(minutes=1440) # out of bounds
- t1 = self.theclass(2, 2, 2, tzinfo=Bogus())
- t2 = self.theclass(2, 2, 2, tzinfo=FixedOffset(0, ""))
- self.assertRaises(ValueError, lambda: t1 == t2)
-
- def test_pickling(self):
- # Try one without a tzinfo.
- args = 6, 7, 23, 20, 59, 1, 64**2
- orig = self.theclass(*args)
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
-
- # Try one with a tzinfo.
- tinfo = PicklableFixedOffset(-300, 'cookie')
- orig = self.theclass(*args, **{'tzinfo': tinfo})
- derived = self.theclass(1, 1, 1, tzinfo=FixedOffset(0, "", 0))
- for pickler, unpickler, proto in pickle_choices:
- green = pickler.dumps(orig, proto)
- derived = unpickler.loads(green)
- self.assertEqual(orig, derived)
- self.assertIsInstance(derived.tzinfo, PicklableFixedOffset)
- self.assertEqual(derived.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(derived.tzname(), 'cookie')
-
- def test_extreme_hashes(self):
- # If an attempt is made to hash these via subtracting the offset
- # then hashing a datetime object, OverflowError results. The
- # Python implementation used to blow up here.
- t = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, ""))
- hash(t)
- t = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, ""))
- hash(t)
-
- # OTOH, an OOB offset should blow up.
- t = self.theclass(5, 5, 5, tzinfo=FixedOffset(-1440, ""))
- self.assertRaises(ValueError, hash, t)
-
- def test_zones(self):
- est = FixedOffset(-300, "EST")
- utc = FixedOffset(0, "UTC")
- met = FixedOffset(60, "MET")
- t1 = datetime(2002, 3, 19, 7, 47, tzinfo=est)
- t2 = datetime(2002, 3, 19, 12, 47, tzinfo=utc)
- t3 = datetime(2002, 3, 19, 13, 47, tzinfo=met)
- self.assertEqual(t1.tzinfo, est)
- self.assertEqual(t2.tzinfo, utc)
- self.assertEqual(t3.tzinfo, met)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=-300))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=0))
- self.assertEqual(t3.utcoffset(), timedelta(minutes=60))
- self.assertEqual(t1.tzname(), "EST")
- self.assertEqual(t2.tzname(), "UTC")
- self.assertEqual(t3.tzname(), "MET")
- self.assertEqual(hash(t1), hash(t2))
- self.assertEqual(hash(t1), hash(t3))
- self.assertEqual(hash(t2), hash(t3))
- self.assertEqual(t1, t2)
- self.assertEqual(t1, t3)
- self.assertEqual(t2, t3)
- self.assertEqual(str(t1), "2002-03-19 07:47:00-05:00")
- self.assertEqual(str(t2), "2002-03-19 12:47:00+00:00")
- self.assertEqual(str(t3), "2002-03-19 13:47:00+01:00")
- d = 'datetime.datetime(2002, 3, 19, '
- self.assertEqual(repr(t1), d + "7, 47, tzinfo=est)")
- self.assertEqual(repr(t2), d + "12, 47, tzinfo=utc)")
- self.assertEqual(repr(t3), d + "13, 47, tzinfo=met)")
-
- def test_combine(self):
- met = FixedOffset(60, "MET")
- d = date(2002, 3, 4)
- tz = time(18, 45, 3, 1234, tzinfo=met)
- dt = datetime.combine(d, tz)
- self.assertEqual(dt, datetime(2002, 3, 4, 18, 45, 3, 1234,
- tzinfo=met))
-
- def test_extract(self):
- met = FixedOffset(60, "MET")
- dt = self.theclass(2002, 3, 4, 18, 45, 3, 1234, tzinfo=met)
- self.assertEqual(dt.date(), date(2002, 3, 4))
- self.assertEqual(dt.time(), time(18, 45, 3, 1234))
- self.assertEqual(dt.timetz(), time(18, 45, 3, 1234, tzinfo=met))
-
- def test_tz_aware_arithmetic(self):
- import random
-
- now = self.theclass.now()
- tz55 = FixedOffset(-330, "west 5:30")
- timeaware = now.time().replace(tzinfo=tz55)
- nowaware = self.theclass.combine(now.date(), timeaware)
- self.assertTrue(nowaware.tzinfo is tz55)
- self.assertEqual(nowaware.timetz(), timeaware)
-
- # Can't mix aware and non-aware.
- self.assertRaises(TypeError, lambda: now - nowaware)
- self.assertRaises(TypeError, lambda: nowaware - now)
-
- # And adding datetime's doesn't make sense, aware or not.
- self.assertRaises(TypeError, lambda: now + nowaware)
- self.assertRaises(TypeError, lambda: nowaware + now)
- self.assertRaises(TypeError, lambda: nowaware + nowaware)
-
- # Subtracting should yield 0.
- self.assertEqual(now - now, timedelta(0))
- self.assertEqual(nowaware - nowaware, timedelta(0))
-
- # Adding a delta should preserve tzinfo.
- delta = timedelta(weeks=1, minutes=12, microseconds=5678)
- nowawareplus = nowaware + delta
- self.assertTrue(nowaware.tzinfo is tz55)
- nowawareplus2 = delta + nowaware
- self.assertTrue(nowawareplus2.tzinfo is tz55)
- self.assertEqual(nowawareplus, nowawareplus2)
-
- # that - delta should be what we started with, and that - what we
- # started with should be delta.
- diff = nowawareplus - delta
- self.assertTrue(diff.tzinfo is tz55)
- self.assertEqual(nowaware, diff)
- self.assertRaises(TypeError, lambda: delta - nowawareplus)
- self.assertEqual(nowawareplus - nowaware, delta)
-
- # Make up a random timezone.
- tzr = FixedOffset(random.randrange(-1439, 1440), "randomtimezone")
- # Attach it to nowawareplus.
- nowawareplus = nowawareplus.replace(tzinfo=tzr)
- self.assertTrue(nowawareplus.tzinfo is tzr)
- # Make sure the difference takes the timezone adjustments into account.
- got = nowaware - nowawareplus
- # Expected: (nowaware base - nowaware offset) -
- # (nowawareplus base - nowawareplus offset) =
- # (nowaware base - nowawareplus base) +
- # (nowawareplus offset - nowaware offset) =
- # -delta + nowawareplus offset - nowaware offset
- expected = nowawareplus.utcoffset() - nowaware.utcoffset() - delta
- self.assertEqual(got, expected)
-
- # Try max possible difference.
- min = self.theclass(1, 1, 1, tzinfo=FixedOffset(1439, "min"))
- max = self.theclass(MAXYEAR, 12, 31, 23, 59, 59, 999999,
- tzinfo=FixedOffset(-1439, "max"))
- maxdiff = max - min
- self.assertEqual(maxdiff, self.theclass.max - self.theclass.min +
- timedelta(minutes=2*1439))
-
- def test_tzinfo_now(self):
- meth = self.theclass.now
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth()
- # Try with and without naming the keyword.
- off42 = FixedOffset(42, "42")
- another = meth(off42)
- again = meth(tz=off42)
- self.assertTrue(another.tzinfo is again.tzinfo)
- self.assertEqual(another.utcoffset(), timedelta(minutes=42))
- # Bad argument with and w/o naming the keyword.
- self.assertRaises(TypeError, meth, 16)
- self.assertRaises(TypeError, meth, tzinfo=16)
- # Bad keyword name.
- self.assertRaises(TypeError, meth, tinfo=off42)
- # Too many args.
- self.assertRaises(TypeError, meth, off42, off42)
-
- # We don't know which time zone we're in, and don't have a tzinfo
- # class to represent it, so seeing whether a tz argument actually
- # does a conversion is tricky.
- weirdtz = FixedOffset(timedelta(hours=15, minutes=58), "weirdtz", 0)
- utc = FixedOffset(0, "utc", 0)
- for dummy in range(3):
- now = datetime.now(weirdtz)
- self.assertTrue(now.tzinfo is weirdtz)
- utcnow = datetime.utcnow().replace(tzinfo=utc)
- now2 = utcnow.astimezone(weirdtz)
- if abs(now - now2) < timedelta(seconds=30):
- break
- # Else the code is broken, or more than 30 seconds passed between
- # calls; assuming the latter, just try again.
- else:
- # Three strikes and we're out.
- self.fail("utcnow(), now(tz), or astimezone() may be broken")
-
- def test_tzinfo_fromtimestamp(self):
- import time
- meth = self.theclass.fromtimestamp
- ts = time.time()
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth(ts)
- # Try with and without naming the keyword.
- off42 = FixedOffset(42, "42")
- another = meth(ts, off42)
- again = meth(ts, tz=off42)
- self.assertTrue(another.tzinfo is again.tzinfo)
- self.assertEqual(another.utcoffset(), timedelta(minutes=42))
- # Bad argument with and w/o naming the keyword.
- self.assertRaises(TypeError, meth, ts, 16)
- self.assertRaises(TypeError, meth, ts, tzinfo=16)
- # Bad keyword name.
- self.assertRaises(TypeError, meth, ts, tinfo=off42)
- # Too many args.
- self.assertRaises(TypeError, meth, ts, off42, off42)
- # Too few args.
- self.assertRaises(TypeError, meth)
-
- # Try to make sure tz= actually does some conversion.
- timestamp = 1000000000
- utcdatetime = datetime.utcfromtimestamp(timestamp)
- # In POSIX (epoch 1970), that's 2001-09-09 01:46:40 UTC, give or take.
- # But on some flavor of Mac, it's nowhere near that. So we can't have
- # any idea here what time that actually is, we can only test that
- # relative changes match.
- utcoffset = timedelta(hours=-15, minutes=39) # arbitrary, but not zero
- tz = FixedOffset(utcoffset, "tz", 0)
- expected = utcdatetime + utcoffset
- got = datetime.fromtimestamp(timestamp, tz)
- self.assertEqual(expected, got.replace(tzinfo=None))
-
- def test_tzinfo_utcnow(self):
- meth = self.theclass.utcnow
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth()
- # Try with and without naming the keyword; for whatever reason,
- # utcnow() doesn't accept a tzinfo argument.
- off42 = FixedOffset(42, "42")
- self.assertRaises(TypeError, meth, off42)
- self.assertRaises(TypeError, meth, tzinfo=off42)
-
- def test_tzinfo_utcfromtimestamp(self):
- import time
- meth = self.theclass.utcfromtimestamp
- ts = time.time()
- # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up).
- base = meth(ts)
- # Try with and without naming the keyword; for whatever reason,
- # utcfromtimestamp() doesn't accept a tzinfo argument.
- off42 = FixedOffset(42, "42")
- self.assertRaises(TypeError, meth, ts, off42)
- self.assertRaises(TypeError, meth, ts, tzinfo=off42)
-
- def test_tzinfo_timetuple(self):
- # TestDateTime tested most of this. datetime adds a twist to the
- # DST flag.
- class DST(tzinfo):
- def __init__(self, dstvalue):
- if isinstance(dstvalue, int):
- dstvalue = timedelta(minutes=dstvalue)
- self.dstvalue = dstvalue
- def dst(self, dt):
- return self.dstvalue
-
- cls = self.theclass
- for dstvalue, flag in (-33, 1), (33, 1), (0, 0), (None, -1):
- d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue))
- t = d.timetuple()
- self.assertEqual(1, t.tm_year)
- self.assertEqual(1, t.tm_mon)
- self.assertEqual(1, t.tm_mday)
- self.assertEqual(10, t.tm_hour)
- self.assertEqual(20, t.tm_min)
- self.assertEqual(30, t.tm_sec)
- self.assertEqual(0, t.tm_wday)
- self.assertEqual(1, t.tm_yday)
- self.assertEqual(flag, t.tm_isdst)
-
- # dst() returns wrong type.
- self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple)
-
- # dst() at the edge.
- self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1)
- self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1)
-
- # dst() out of range.
- self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple)
- self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple)
-
- def test_utctimetuple(self):
- class DST(tzinfo):
- def __init__(self, dstvalue):
- if isinstance(dstvalue, int):
- dstvalue = timedelta(minutes=dstvalue)
- self.dstvalue = dstvalue
- def dst(self, dt):
- return self.dstvalue
-
- cls = self.theclass
- # This can't work: DST didn't implement utcoffset.
- self.assertRaises(NotImplementedError,
- cls(1, 1, 1, tzinfo=DST(0)).utcoffset)
-
- class UOFS(DST):
- def __init__(self, uofs, dofs=None):
- DST.__init__(self, dofs)
- self.uofs = timedelta(minutes=uofs)
- def utcoffset(self, dt):
- return self.uofs
-
- # Ensure tm_isdst is 0 regardless of what dst() says: DST is never
- # in effect for a UTC time.
- for dstvalue in -33, 33, 0, None:
- d = cls(1, 2, 3, 10, 20, 30, 40, tzinfo=UOFS(-53, dstvalue))
- t = d.utctimetuple()
- self.assertEqual(d.year, t.tm_year)
- self.assertEqual(d.month, t.tm_mon)
- self.assertEqual(d.day, t.tm_mday)
- self.assertEqual(11, t.tm_hour) # 20mm + 53mm = 1hn + 13mm
- self.assertEqual(13, t.tm_min)
- self.assertEqual(d.second, t.tm_sec)
- self.assertEqual(d.weekday(), t.tm_wday)
- self.assertEqual(d.toordinal() - date(1, 1, 1).toordinal() + 1,
- t.tm_yday)
- self.assertEqual(0, t.tm_isdst)
-
- # At the edges, UTC adjustment can normalize into years out-of-range
- # for a datetime object. Ensure that a correct timetuple is
- # created anyway.
- tiny = cls(MINYEAR, 1, 1, 0, 0, 37, tzinfo=UOFS(1439))
- # That goes back 1 minute less than a full day.
- t = tiny.utctimetuple()
- self.assertEqual(t.tm_year, MINYEAR-1)
- self.assertEqual(t.tm_mon, 12)
- self.assertEqual(t.tm_mday, 31)
- self.assertEqual(t.tm_hour, 0)
- self.assertEqual(t.tm_min, 1)
- self.assertEqual(t.tm_sec, 37)
- self.assertEqual(t.tm_yday, 366) # "year 0" is a leap year
- self.assertEqual(t.tm_isdst, 0)
-
- huge = cls(MAXYEAR, 12, 31, 23, 59, 37, 999999, tzinfo=UOFS(-1439))
- # That goes forward 1 minute less than a full day.
- t = huge.utctimetuple()
- self.assertEqual(t.tm_year, MAXYEAR+1)
- self.assertEqual(t.tm_mon, 1)
- self.assertEqual(t.tm_mday, 1)
- self.assertEqual(t.tm_hour, 23)
- self.assertEqual(t.tm_min, 58)
- self.assertEqual(t.tm_sec, 37)
- self.assertEqual(t.tm_yday, 1)
- self.assertEqual(t.tm_isdst, 0)
-
- def test_tzinfo_isoformat(self):
- zero = FixedOffset(0, "+00:00")
- plus = FixedOffset(220, "+03:40")
- minus = FixedOffset(-231, "-03:51")
- unknown = FixedOffset(None, "")
-
- cls = self.theclass
- datestr = '0001-02-03'
- for ofs in None, zero, plus, minus, unknown:
- for us in 0, 987001:
- d = cls(1, 2, 3, 4, 5, 59, us, tzinfo=ofs)
- timestr = '04:05:59' + (us and '.987001' or '')
- ofsstr = ofs is not None and d.tzname() or ''
- tailstr = timestr + ofsstr
- iso = d.isoformat()
- self.assertEqual(iso, datestr + 'T' + tailstr)
- self.assertEqual(iso, d.isoformat('T'))
- self.assertEqual(d.isoformat('k'), datestr + 'k' + tailstr)
- self.assertEqual(str(d), datestr + ' ' + tailstr)
-
- def test_replace(self):
- cls = self.theclass
- z100 = FixedOffset(100, "+100")
- zm200 = FixedOffset(timedelta(minutes=-200), "-200")
- args = [1, 2, 3, 4, 5, 6, 7, z100]
- base = cls(*args)
- self.assertEqual(base, base.replace())
-
- i = 0
- for name, newval in (("year", 2),
- ("month", 3),
- ("day", 4),
- ("hour", 5),
- ("minute", 6),
- ("second", 7),
- ("microsecond", 8),
- ("tzinfo", zm200)):
- newargs = args[:]
- newargs[i] = newval
- expected = cls(*newargs)
- got = base.replace(**{name: newval})
- self.assertEqual(expected, got)
- i += 1
-
- # Ensure we can get rid of a tzinfo.
- self.assertEqual(base.tzname(), "+100")
- base2 = base.replace(tzinfo=None)
- self.assertTrue(base2.tzinfo is None)
- self.assertTrue(base2.tzname() is None)
-
- # Ensure we can add one.
- base3 = base2.replace(tzinfo=z100)
- self.assertEqual(base, base3)
- self.assertTrue(base.tzinfo is base3.tzinfo)
-
- # Out of bounds.
- base = cls(2000, 2, 29)
- self.assertRaises(ValueError, base.replace, year=2001)
-
- def test_more_astimezone(self):
- # The inherited test_astimezone covered some trivial and error cases.
- fnone = FixedOffset(None, "None")
- f44m = FixedOffset(44, "44")
- fm5h = FixedOffset(-timedelta(hours=5), "m300")
-
- dt = self.theclass.now(tz=f44m)
- self.assertTrue(dt.tzinfo is f44m)
- # Replacing with degenerate tzinfo raises an exception.
- self.assertRaises(ValueError, dt.astimezone, fnone)
- # Ditto with None tz.
- self.assertRaises(TypeError, dt.astimezone, None)
- # Replacing with same tzinfo makes no change.
- x = dt.astimezone(dt.tzinfo)
- self.assertTrue(x.tzinfo is f44m)
- self.assertEqual(x.date(), dt.date())
- self.assertEqual(x.time(), dt.time())
-
- # Replacing with different tzinfo does adjust.
- got = dt.astimezone(fm5h)
- self.assertTrue(got.tzinfo is fm5h)
- self.assertEqual(got.utcoffset(), timedelta(hours=-5))
- expected = dt - dt.utcoffset() # in effect, convert to UTC
- expected += fm5h.utcoffset(dt) # and from there to local time
- expected = expected.replace(tzinfo=fm5h) # and attach new tzinfo
- self.assertEqual(got.date(), expected.date())
- self.assertEqual(got.time(), expected.time())
- self.assertEqual(got.timetz(), expected.timetz())
- self.assertTrue(got.tzinfo is expected.tzinfo)
- self.assertEqual(got, expected)
-
- def test_aware_subtract(self):
- cls = self.theclass
-
- # Ensure that utcoffset() is ignored when the operands have the
- # same tzinfo member.
- class OperandDependentOffset(tzinfo):
- def utcoffset(self, t):
- if t.minute < 10:
- # d0 and d1 equal after adjustment
- return timedelta(minutes=t.minute)
- else:
- # d2 off in the weeds
- return timedelta(minutes=59)
-
- base = cls(8, 9, 10, 11, 12, 13, 14, tzinfo=OperandDependentOffset())
- d0 = base.replace(minute=3)
- d1 = base.replace(minute=9)
- d2 = base.replace(minute=11)
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = x - y
- expected = timedelta(minutes=x.minute - y.minute)
- self.assertEqual(got, expected)
-
- # OTOH, if the tzinfo members are distinct, utcoffsets aren't
- # ignored.
- base = cls(8, 9, 10, 11, 12, 13, 14)
- d0 = base.replace(minute=3, tzinfo=OperandDependentOffset())
- d1 = base.replace(minute=9, tzinfo=OperandDependentOffset())
- d2 = base.replace(minute=11, tzinfo=OperandDependentOffset())
- for x in d0, d1, d2:
- for y in d0, d1, d2:
- got = x - y
- if (x is d0 or x is d1) and (y is d0 or y is d1):
- expected = timedelta(0)
- elif x is y is d2:
- expected = timedelta(0)
- elif x is d2:
- expected = timedelta(minutes=(11-59)-0)
- else:
- assert y is d2
- expected = timedelta(minutes=0-(11-59))
- self.assertEqual(got, expected)
-
- def test_mixed_compare(self):
- t1 = datetime(1, 2, 3, 4, 5, 6, 7)
- t2 = datetime(1, 2, 3, 4, 5, 6, 7)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=None)
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(None, ""))
- self.assertEqual(t1, t2)
- t2 = t2.replace(tzinfo=FixedOffset(0, ""))
- self.assertRaises(TypeError, lambda: t1 == t2)
-
- # In datetime w/ identical tzinfo objects, utcoffset is ignored.
- class Varies(tzinfo):
- def __init__(self):
- self.offset = timedelta(minutes=22)
- def utcoffset(self, t):
- self.offset += timedelta(minutes=1)
- return self.offset
-
- v = Varies()
- t1 = t2.replace(tzinfo=v)
- t2 = t2.replace(tzinfo=v)
- self.assertEqual(t1.utcoffset(), timedelta(minutes=23))
- self.assertEqual(t2.utcoffset(), timedelta(minutes=24))
- self.assertEqual(t1, t2)
-
- # But if they're not identical, it isn't ignored.
- t2 = t2.replace(tzinfo=Varies())
- self.assertTrue(t1 < t2) # t1's offset counter still going up
-
- def test_subclass_datetimetz(self):
-
- class C(self.theclass):
- theAnswer = 42
-
- def __new__(cls, *args, **kws):
- temp = kws.copy()
- extra = temp.pop('extra')
- result = self.theclass.__new__(cls, *args, **temp)
- result.extra = extra
- return result
-
- def newmeth(self, start):
- return start + self.hour + self.year
-
- args = 2002, 12, 31, 4, 5, 6, 500, FixedOffset(-300, "EST", 1)
-
- dt1 = self.theclass(*args)
- dt2 = C(*args, **{'extra': 7})
-
- self.assertEqual(dt2.__class__, C)
- self.assertEqual(dt2.theAnswer, 42)
- self.assertEqual(dt2.extra, 7)
- self.assertEqual(dt1.utcoffset(), dt2.utcoffset())
- self.assertEqual(dt2.newmeth(-7), dt1.hour + dt1.year - 7)
-
-# Pain to set up DST-aware tzinfo classes.
-
-def first_sunday_on_or_after(dt):
- days_to_go = 6 - dt.weekday()
- if days_to_go:
- dt += timedelta(days_to_go)
- return dt
-
-ZERO = timedelta(0)
-HOUR = timedelta(hours=1)
-DAY = timedelta(days=1)
-# In the US, DST starts at 2am (standard time) on the first Sunday in April.
-DSTSTART = datetime(1, 4, 1, 2)
-# and ends at 2am (DST time; 1am standard time) on the last Sunday of Oct,
-# which is the first Sunday on or after Oct 25. Because we view 1:MM as
-# being standard time on that day, there is no spelling in local time of
-# the last hour of DST (that's 1:MM DST, but 1:MM is taken as standard time).
-DSTEND = datetime(1, 10, 25, 1)
-
-class USTimeZone(tzinfo):
-
- def __init__(self, hours, reprname, stdname, dstname):
- self.stdoffset = timedelta(hours=hours)
- self.reprname = reprname
- self.stdname = stdname
- self.dstname = dstname
-
- def __repr__(self):
- return self.reprname
-
- def tzname(self, dt):
- if self.dst(dt):
- return self.dstname
- else:
- return self.stdname
-
- def utcoffset(self, dt):
- return self.stdoffset + self.dst(dt)
-
- def dst(self, dt):
- if dt is None or dt.tzinfo is None:
- # An exception instead may be sensible here, in one or more of
- # the cases.
- return ZERO
- assert dt.tzinfo is self
-
- # Find first Sunday in April.
- start = first_sunday_on_or_after(DSTSTART.replace(year=dt.year))
- assert start.weekday() == 6 and start.month == 4 and start.day <= 7
-
- # Find last Sunday in October.
- end = first_sunday_on_or_after(DSTEND.replace(year=dt.year))
- assert end.weekday() == 6 and end.month == 10 and end.day >= 25
-
- # Can't compare naive to aware objects, so strip the timezone from
- # dt first.
- if start <= dt.replace(tzinfo=None) < end:
- return HOUR
- else:
- return ZERO
-
-Eastern = USTimeZone(-5, "Eastern", "EST", "EDT")
-Central = USTimeZone(-6, "Central", "CST", "CDT")
-Mountain = USTimeZone(-7, "Mountain", "MST", "MDT")
-Pacific = USTimeZone(-8, "Pacific", "PST", "PDT")
-utc_real = FixedOffset(0, "UTC", 0)
-# For better test coverage, we want another flavor of UTC that's west of
-# the Eastern and Pacific timezones.
-utc_fake = FixedOffset(-12*60, "UTCfake", 0)
-
-class TestTimezoneConversions(unittest.TestCase):
- # The DST switch times for 2002, in std time.
- dston = datetime(2002, 4, 7, 2)
- dstoff = datetime(2002, 10, 27, 1)
-
- theclass = datetime
-
- # Check a time that's inside DST.
- def checkinside(self, dt, tz, utc, dston, dstoff):
- self.assertEqual(dt.dst(), HOUR)
-
- # Conversion to our own timezone is always an identity.
- self.assertEqual(dt.astimezone(tz), dt)
-
- asutc = dt.astimezone(utc)
- there_and_back = asutc.astimezone(tz)
-
- # Conversion to UTC and back isn't always an identity here,
- # because there are redundant spellings (in local time) of
- # UTC time when DST begins: the clock jumps from 1:59:59
- # to 3:00:00, and a local time of 2:MM:SS doesn't really
- # make sense then. The classes above treat 2:MM:SS as
- # daylight time then (it's "after 2am"), really an alias
- # for 1:MM:SS standard time. The latter form is what
- # conversion back from UTC produces.
- if dt.date() == dston.date() and dt.hour == 2:
- # We're in the redundant hour, and coming back from
- # UTC gives the 1:MM:SS standard-time spelling.
- self.assertEqual(there_and_back + HOUR, dt)
- # Although during was considered to be in daylight
- # time, there_and_back is not.
- self.assertEqual(there_and_back.dst(), ZERO)
- # They're the same times in UTC.
- self.assertEqual(there_and_back.astimezone(utc),
- dt.astimezone(utc))
- else:
- # We're not in the redundant hour.
- self.assertEqual(dt, there_and_back)
-
- # Because we have a redundant spelling when DST begins, there is
- # (unfortunately) an hour when DST ends that can't be spelled at all in
- # local time. When DST ends, the clock jumps from 1:59 back to 1:00
- # again. The hour 1:MM DST has no spelling then: 1:MM is taken to be
- # standard time. 1:MM DST == 0:MM EST, but 0:MM is taken to be
- # daylight time. The hour 1:MM daylight == 0:MM standard can't be
- # expressed in local time. Nevertheless, we want conversion back
- # from UTC to mimic the local clock's "repeat an hour" behavior.
- nexthour_utc = asutc + HOUR
- nexthour_tz = nexthour_utc.astimezone(tz)
- if dt.date() == dstoff.date() and dt.hour == 0:
- # We're in the hour before the last DST hour. The last DST hour
- # is ineffable. We want the conversion back to repeat 1:MM.
- self.assertEqual(nexthour_tz, dt.replace(hour=1))
- nexthour_utc += HOUR
- nexthour_tz = nexthour_utc.astimezone(tz)
- self.assertEqual(nexthour_tz, dt.replace(hour=1))
- else:
- self.assertEqual(nexthour_tz - dt, HOUR)
-
- # Check a time that's outside DST.
- def checkoutside(self, dt, tz, utc):
- self.assertEqual(dt.dst(), ZERO)
-
- # Conversion to our own timezone is always an identity.
- self.assertEqual(dt.astimezone(tz), dt)
-
- # Converting to UTC and back is an identity too.
- asutc = dt.astimezone(utc)
- there_and_back = asutc.astimezone(tz)
- self.assertEqual(dt, there_and_back)
-
- def convert_between_tz_and_utc(self, tz, utc):
- dston = self.dston.replace(tzinfo=tz)
- # Because 1:MM on the day DST ends is taken as being standard time,
- # there is no spelling in tz for the last hour of daylight time.
- # For purposes of the test, the last hour of DST is 0:MM, which is
- # taken as being daylight time (and 1:MM is taken as being standard
- # time).
- dstoff = self.dstoff.replace(tzinfo=tz)
- for delta in (timedelta(weeks=13),
- DAY,
- HOUR,
- timedelta(minutes=1),
- timedelta(microseconds=1)):
-
- self.checkinside(dston, tz, utc, dston, dstoff)
- for during in dston + delta, dstoff - delta:
- self.checkinside(during, tz, utc, dston, dstoff)
-
- self.checkoutside(dstoff, tz, utc)
- for outside in dston - delta, dstoff + delta:
- self.checkoutside(outside, tz, utc)
-
- def test_easy(self):
- # Despite the name of this test, the endcases are excruciating.
- self.convert_between_tz_and_utc(Eastern, utc_real)
- self.convert_between_tz_and_utc(Pacific, utc_real)
- self.convert_between_tz_and_utc(Eastern, utc_fake)
- self.convert_between_tz_and_utc(Pacific, utc_fake)
- # The next is really dancing near the edge. It works because
- # Pacific and Eastern are far enough apart that their "problem
- # hours" don't overlap.
- self.convert_between_tz_and_utc(Eastern, Pacific)
- self.convert_between_tz_and_utc(Pacific, Eastern)
- # OTOH, these fail! Don't enable them. The difficulty is that
- # the edge case tests assume that every hour is representable in
- # the "utc" class. This is always true for a fixed-offset tzinfo
- # class (lke utc_real and utc_fake), but not for Eastern or Central.
- # For these adjacent DST-aware time zones, the range of time offsets
- # tested ends up creating hours in the one that aren't representable
- # in the other. For the same reason, we would see failures in the
- # Eastern vs Pacific tests too if we added 3*HOUR to the list of
- # offset deltas in convert_between_tz_and_utc().
- #
- # self.convert_between_tz_and_utc(Eastern, Central) # can't work
- # self.convert_between_tz_and_utc(Central, Eastern) # can't work
-
- def test_tricky(self):
- # 22:00 on day before daylight starts.
- fourback = self.dston - timedelta(hours=4)
- ninewest = FixedOffset(-9*60, "-0900", 0)
- fourback = fourback.replace(tzinfo=ninewest)
- # 22:00-0900 is 7:00 UTC == 2:00 EST == 3:00 DST. Since it's "after
- # 2", we should get the 3 spelling.
- # If we plug 22:00 the day before into Eastern, it "looks like std
- # time", so its offset is returned as -5, and -5 - -9 = 4. Adding 4
- # to 22:00 lands on 2:00, which makes no sense in local time (the
- # local clock jumps from 1 to 3). The point here is to make sure we
- # get the 3 spelling.
- expected = self.dston.replace(hour=3)
- got = fourback.astimezone(Eastern).replace(tzinfo=None)
- self.assertEqual(expected, got)
-
- # Similar, but map to 6:00 UTC == 1:00 EST == 2:00 DST. In that
- # case we want the 1:00 spelling.
- sixutc = self.dston.replace(hour=6, tzinfo=utc_real)
- # Now 6:00 "looks like daylight", so the offset wrt Eastern is -4,
- # and adding -4-0 == -4 gives the 2:00 spelling. We want the 1:00 EST
- # spelling.
- expected = self.dston.replace(hour=1)
- got = sixutc.astimezone(Eastern).replace(tzinfo=None)
- self.assertEqual(expected, got)
-
- # Now on the day DST ends, we want "repeat an hour" behavior.
- # UTC 4:MM 5:MM 6:MM 7:MM checking these
- # EST 23:MM 0:MM 1:MM 2:MM
- # EDT 0:MM 1:MM 2:MM 3:MM
- # wall 0:MM 1:MM 1:MM 2:MM against these
- for utc in utc_real, utc_fake:
- for tz in Eastern, Pacific:
- first_std_hour = self.dstoff - timedelta(hours=2) # 23:MM
- # Convert that to UTC.
- first_std_hour -= tz.utcoffset(None)
- # Adjust for possibly fake UTC.
- asutc = first_std_hour + utc.utcoffset(None)
- # First UTC hour to convert; this is 4:00 when utc=utc_real &
- # tz=Eastern.
- asutcbase = asutc.replace(tzinfo=utc)
- for tzhour in (0, 1, 1, 2):
- expectedbase = self.dstoff.replace(hour=tzhour)
- for minute in 0, 30, 59:
- expected = expectedbase.replace(minute=minute)
- asutc = asutcbase.replace(minute=minute)
- astz = asutc.astimezone(tz)
- self.assertEqual(astz.replace(tzinfo=None), expected)
- asutcbase += HOUR
-
-
- def test_bogus_dst(self):
- class ok(tzinfo):
- def utcoffset(self, dt): return HOUR
- def dst(self, dt): return HOUR
-
- now = self.theclass.now().replace(tzinfo=utc_real)
- # Doesn't blow up.
- now.astimezone(ok())
-
- # Does blow up.
- class notok(ok):
- def dst(self, dt): return None
- self.assertRaises(ValueError, now.astimezone, notok())
-
- def test_fromutc(self):
- self.assertRaises(TypeError, Eastern.fromutc) # not enough args
- now = datetime.utcnow().replace(tzinfo=utc_real)
- self.assertRaises(ValueError, Eastern.fromutc, now) # wrong tzinfo
- now = now.replace(tzinfo=Eastern) # insert correct tzinfo
- enow = Eastern.fromutc(now) # doesn't blow up
- self.assertEqual(enow.tzinfo, Eastern) # has right tzinfo member
- self.assertRaises(TypeError, Eastern.fromutc, now, now) # too many args
- self.assertRaises(TypeError, Eastern.fromutc, date.today()) # wrong type
-
- # Always converts UTC to standard time.
- class FauxUSTimeZone(USTimeZone):
- def fromutc(self, dt):
- return dt + self.stdoffset
- FEastern = FauxUSTimeZone(-5, "FEastern", "FEST", "FEDT")
-
- # UTC 4:MM 5:MM 6:MM 7:MM 8:MM 9:MM
- # EST 23:MM 0:MM 1:MM 2:MM 3:MM 4:MM
- # EDT 0:MM 1:MM 2:MM 3:MM 4:MM 5:MM
-
- # Check around DST start.
- start = self.dston.replace(hour=4, tzinfo=Eastern)
- fstart = start.replace(tzinfo=FEastern)
- for wall in 23, 0, 1, 3, 4, 5:
- expected = start.replace(hour=wall)
- if wall == 23:
- expected -= timedelta(days=1)
- got = Eastern.fromutc(start)
- self.assertEqual(expected, got)
-
- expected = fstart + FEastern.stdoffset
- got = FEastern.fromutc(fstart)
- self.assertEqual(expected, got)
-
- # Ensure astimezone() calls fromutc() too.
- got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
- self.assertEqual(expected, got)
-
- start += HOUR
- fstart += HOUR
-
- # Check around DST end.
- start = self.dstoff.replace(hour=4, tzinfo=Eastern)
- fstart = start.replace(tzinfo=FEastern)
- for wall in 0, 1, 1, 2, 3, 4:
- expected = start.replace(hour=wall)
- got = Eastern.fromutc(start)
- self.assertEqual(expected, got)
-
- expected = fstart + FEastern.stdoffset
- got = FEastern.fromutc(fstart)
- self.assertEqual(expected, got)
-
- # Ensure astimezone() calls fromutc() too.
- got = fstart.replace(tzinfo=utc_real).astimezone(FEastern)
- self.assertEqual(expected, got)
-
- start += HOUR
- fstart += HOUR
-
-
-#############################################################################
-# oddballs
-
-class Oddballs(unittest.TestCase):
-
- def test_bug_1028306(self):
- # Trying to compare a date to a datetime should act like a mixed-
- # type comparison, despite that datetime is a subclass of date.
- as_date = date.today()
- as_datetime = datetime.combine(as_date, time())
- self.assertTrue(as_date != as_datetime)
- self.assertTrue(as_datetime != as_date)
- self.assertTrue(not as_date == as_datetime)
- self.assertTrue(not as_datetime == as_date)
- self.assertRaises(TypeError, lambda: as_date < as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime < as_date)
- self.assertRaises(TypeError, lambda: as_date <= as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime <= as_date)
- self.assertRaises(TypeError, lambda: as_date > as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime > as_date)
- self.assertRaises(TypeError, lambda: as_date >= as_datetime)
- self.assertRaises(TypeError, lambda: as_datetime >= as_date)
-
- # Neverthelss, comparison should work with the base-class (date)
- # projection if use of a date method is forced.
- self.assertTrue(as_date.__eq__(as_datetime))
- different_day = (as_date.day + 1) % 20 + 1
- self.assertTrue(not as_date.__eq__(as_datetime.replace(day=
- different_day)))
-
- # And date should compare with other subclasses of date. If a
- # subclass wants to stop this, it's up to the subclass to do so.
- date_sc = SubclassDate(as_date.year, as_date.month, as_date.day)
- self.assertEqual(as_date, date_sc)
- self.assertEqual(date_sc, as_date)
-
- # Ditto for datetimes.
- datetime_sc = SubclassDatetime(as_datetime.year, as_datetime.month,
- as_date.day, 0, 0, 0)
- self.assertEqual(as_datetime, datetime_sc)
- self.assertEqual(datetime_sc, as_datetime)
+import sys
+from test.support import import_fresh_module, run_unittest
+
+TESTS = 'test.datetimetester'
+
+# XXX: import_fresh_module() is supposed to leave sys.module cache untouched,
+# XXX: but it does not, so we have to save and restore it ourselves.
+save_sys_modules = sys.modules.copy()
+try:
+ pure_tests = import_fresh_module(TESTS, fresh=['datetime', '_strptime'],
+ blocked=['_datetime'])
+ fast_tests = import_fresh_module(TESTS, fresh=['datetime',
+ '_datetime', '_strptime'])
+finally:
+ sys.modules.clear()
+ sys.modules.update(save_sys_modules)
+test_modules = [pure_tests, fast_tests]
+test_suffixes = ["_Pure", "_Fast"]
+# XXX(gb) First run all the _Pure tests, then all the _Fast tests. You might
+# not believe this, but in spite of all the sys.modules trickery running a _Pure
+# test last will leave a mix of pure and native datetime stuff lying around.
+test_classes = []
+
+for module, suffix in zip(test_modules, test_suffixes):
+ for name, cls in module.__dict__.items():
+ if not (isinstance(cls, type) and issubclass(cls, unittest.TestCase)):
+ continue
+ cls.__name__ = name + suffix
+ @classmethod
+ def setUpClass(cls_, module=module):
+ cls_._save_sys_modules = sys.modules.copy()
+ sys.modules[TESTS] = module
+ sys.modules['datetime'] = module.datetime_module
+ sys.modules['_strptime'] = module._strptime
+ @classmethod
+ def tearDownClass(cls_):
+ sys.modules.clear()
+ sys.modules.update(cls_._save_sys_modules)
+ cls.setUpClass = setUpClass
+ cls.tearDownClass = tearDownClass
+ test_classes.append(cls)
def test_main():
- test_support.run_unittest(__name__)
+ run_unittest(*test_classes)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py
index 41b0b5cc476..26d4c146238 100644
--- a/Lib/test/test_dbm.py
+++ b/Lib/test/test_dbm.py
@@ -1,42 +1,180 @@
-from test import test_support
+#! /usr/bin/env python3
+"""Test script for the dbm.open function based on testdumbdbm.py"""
+
+import os
import unittest
-dbm = test_support.import_module('dbm')
+import glob
+import test.support
+
+# Skip tests if dbm module doesn't exist.
+dbm = test.support.import_module('dbm')
+
+_fname = test.support.TESTFN
+
+#
+# Iterates over every database module supported by dbm currently available,
+# setting dbm to use each in turn, and yielding that module
+#
+def dbm_iterator():
+ for name in dbm._names:
+ try:
+ mod = __import__(name, fromlist=['open'])
+ except ImportError:
+ continue
+ dbm._modules[name] = mod
+ yield mod
+
+#
+# Clean up all scratch databases we might have created during testing
+#
+def delete_files():
+ # we don't know the precise name the underlying database uses
+ # so we use glob to locate all names
+ for f in glob.glob(_fname + "*"):
+ test.support.unlink(f)
+
+
+class AnyDBMTestCase(unittest.TestCase):
+ _dict = {'0': b'',
+ 'a': b'Python:',
+ 'b': b'Programming',
+ 'c': b'the',
+ 'd': b'way',
+ 'f': b'Guido',
+ 'g': b'intended',
+ }
+
+ def init_db(self):
+ f = dbm.open(_fname, 'n')
+ for k in self._dict:
+ f[k.encode("ascii")] = self._dict[k]
+ f.close()
+
+ def keys_helper(self, f):
+ keys = sorted(k.decode("ascii") for k in f.keys())
+ dkeys = sorted(self._dict.keys())
+ self.assertEqual(keys, dkeys)
+ return keys
+
+ def test_error(self):
+ self.assertTrue(issubclass(self.module.error, IOError))
+
+ def test_anydbm_not_existing(self):
+ self.assertRaises(dbm.error, dbm.open, _fname)
+
+ def test_anydbm_creation(self):
+ f = dbm.open(_fname, 'c')
+ self.assertEqual(list(f.keys()), [])
+ for key in self._dict:
+ f[key.encode("ascii")] = self._dict[key]
+ self.read_helper(f)
+ f.close()
+
+ def test_anydbm_creation_n_file_exists_with_invalid_contents(self):
+ with open(_fname, "w") as w:
+ pass # create an empty file
+
+ f = dbm.open(_fname, 'n')
+ self.addCleanup(f.close)
+ self.assertEqual(len(f), 0)
+
+ def test_anydbm_modification(self):
+ self.init_db()
+ f = dbm.open(_fname, 'c')
+ self._dict['g'] = f[b'g'] = b"indented"
+ self.read_helper(f)
+ f.close()
-class DbmTestCase(unittest.TestCase):
+ def test_anydbm_read(self):
+ self.init_db()
+ f = dbm.open(_fname, 'r')
+ self.read_helper(f)
+ f.close()
+
+ def test_anydbm_keys(self):
+ self.init_db()
+ f = dbm.open(_fname, 'r')
+ keys = self.keys_helper(f)
+ f.close()
+
+ def test_anydbm_access(self):
+ self.init_db()
+ f = dbm.open(_fname, 'r')
+ key = "a".encode("ascii")
+ self.assertIn(key, f)
+ assert(f[key] == b"Python:")
+ f.close()
+
+ def read_helper(self, f):
+ keys = self.keys_helper(f)
+ for key in self._dict:
+ self.assertEqual(self._dict[key], f[key.encode("ascii")])
+
+ def tearDown(self):
+ delete_files()
def setUp(self):
- self.filename = test_support.TESTFN
- self.d = dbm.open(self.filename, 'c')
- self.d.close()
+ dbm._defaultmod = self.module
+ delete_files()
+
+
+class WhichDBTestCase(unittest.TestCase):
+ # Actual test methods are added to namespace after class definition.
+ def __init__(self, *args):
+ unittest.TestCase.__init__(self, *args)
+
+ def test_whichdb(self):
+ for module in dbm_iterator():
+ # Check whether whichdb correctly guesses module name
+ # for databases opened with "module" module.
+ # Try with empty files first
+ name = module.__name__
+ if name == 'dbm.dumb':
+ continue # whichdb can't support dbm.dumb
+ delete_files()
+ f = module.open(_fname, 'c')
+ f.close()
+ self.assertEqual(name, dbm.whichdb(_fname))
+ # Now add a key
+ f = module.open(_fname, 'w')
+ f[b"1"] = b"1"
+ # and test that we can find it
+ self.assertIn(b"1", f)
+ # and read it
+ self.assertTrue(f[b"1"] == b"1")
+ f.close()
+ self.assertEqual(name, dbm.whichdb(_fname))
def tearDown(self):
- for suffix in ['', '.pag', '.dir', '.db']:
- test_support.unlink(self.filename + suffix)
+ delete_files()
+
+ def setUp(self):
+ delete_files()
+ self.filename = test.support.TESTFN
+ self.d = dbm.open(self.filename, 'c')
+ self.d.close()
def test_keys(self):
self.d = dbm.open(self.filename, 'c')
self.assertEqual(self.d.keys(), [])
- a = [('a', 'b'), ('12345678910', '019237410982340912840198242')]
+ a = [(b'a', b'b'), (b'12345678910', b'019237410982340912840198242')]
for k, v in a:
self.d[k] = v
self.assertEqual(sorted(self.d.keys()), sorted(k for (k, v) in a))
for k, v in a:
self.assertIn(k, self.d)
self.assertEqual(self.d[k], v)
- self.assertNotIn('xxx', self.d)
- self.assertRaises(KeyError, lambda: self.d['xxx'])
+ self.assertNotIn(b'xxx', self.d)
+ self.assertRaises(KeyError, lambda: self.d[b'xxx'])
self.d.close()
- def test_modes(self):
- for mode in ['r', 'rw', 'w', 'n']:
- try:
- self.d = dbm.open(self.filename, mode)
- self.d.close()
- except dbm.error:
- self.fail()
def test_main():
- test_support.run_unittest(DbmTestCase)
+ classes = [WhichDBTestCase]
+ for mod in dbm_iterator():
+ classes.append(type("TestCase-" + mod.__name__, (AnyDBMTestCase,),
+ {'module': mod}))
+ test.support.run_unittest(*classes)
-if __name__ == '__main__':
+if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_dumbdbm.py b/Lib/test/test_dbm_dumb.py
index 041fac171ff..6b981c429df 100644
--- a/Lib/test/test_dumbdbm.py
+++ b/Lib/test/test_dbm_dumb.py
@@ -1,14 +1,15 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the dumbdbm module
Original by Roger E. Masse
"""
+import io
import os
import unittest
-import dumbdbm
-from test import test_support
+import dbm.dumb as dumbdbm
+from test import support
-_fname = test_support.TESTFN
+_fname = support.TESTFN
def _delete_files():
for ext in [".dir", ".dat", ".bak"]:
@@ -18,13 +19,14 @@ def _delete_files():
pass
class DumbDBMTestCase(unittest.TestCase):
- _dict = {'0': '',
- 'a': 'Python:',
- 'b': 'Programming',
- 'c': 'the',
- 'd': 'way',
- 'f': 'Guido',
- 'g': 'intended'
+ _dict = {b'0': b'',
+ b'a': b'Python:',
+ b'b': b'Programming',
+ b'c': b'the',
+ b'd': b'way',
+ b'f': b'Guido',
+ b'g': b'intended',
+ '\u00fc'.encode('utf-8') : b'!',
}
def __init__(self, *args):
@@ -32,7 +34,7 @@ class DumbDBMTestCase(unittest.TestCase):
def test_dumbdbm_creation(self):
f = dumbdbm.open(_fname, 'c')
- self.assertEqual(f.keys(), [])
+ self.assertEqual(list(f.keys()), [])
for key in self._dict:
f[key] = self._dict[key]
self.read_helper(f)
@@ -44,17 +46,17 @@ class DumbDBMTestCase(unittest.TestCase):
return
try:
- old_umask = os.umask(0002)
- f = dumbdbm.open(_fname, 'c', 0637)
+ old_umask = os.umask(0o002)
+ f = dumbdbm.open(_fname, 'c', 0o637)
f.close()
finally:
os.umask(old_umask)
- expected_mode = 0635
+ expected_mode = 0o635
if os.name != 'posix':
# Windows only supports setting the read-only attribute.
# This shouldn't fail, but doesn't work like Unix either.
- expected_mode = 0666
+ expected_mode = 0o666
import stat
st = os.stat(_fname + '.dat')
@@ -64,15 +66,15 @@ class DumbDBMTestCase(unittest.TestCase):
def test_close_twice(self):
f = dumbdbm.open(_fname)
- f['a'] = 'b'
- self.assertEqual(f['a'], 'b')
+ f[b'a'] = b'b'
+ self.assertEqual(f[b'a'], b'b')
f.close()
f.close()
def test_dumbdbm_modification(self):
self.init_db()
f = dumbdbm.open(_fname, 'w')
- self._dict['g'] = f['g'] = "indented"
+ self._dict[b'g'] = f[b'g'] = b"indented"
self.read_helper(f)
f.close()
@@ -88,32 +90,60 @@ class DumbDBMTestCase(unittest.TestCase):
keys = self.keys_helper(f)
f.close()
+ def test_write_contains(self):
+ f = dumbdbm.open(_fname)
+ f[b'1'] = b'hello'
+ self.assertIn(b'1', f)
+ f.close()
+
def test_write_write_read(self):
# test for bug #482460
f = dumbdbm.open(_fname)
- f['1'] = 'hello'
- f['1'] = 'hello2'
+ f[b'1'] = b'hello'
+ f[b'1'] = b'hello2'
f.close()
f = dumbdbm.open(_fname)
- self.assertEqual(f['1'], 'hello2')
+ self.assertEqual(f[b'1'], b'hello2')
f.close()
+ def test_str_read(self):
+ self.init_db()
+ f = dumbdbm.open(_fname, 'r')
+ self.assertEqual(f['\u00fc'], self._dict['\u00fc'.encode('utf-8')])
+
+ def test_str_write_contains(self):
+ self.init_db()
+ f = dumbdbm.open(_fname)
+ f['\u00fc'] = b'!'
+ f['1'] = 'a'
+ f.close()
+ f = dumbdbm.open(_fname, 'r')
+ self.assertIn('\u00fc', f)
+ self.assertEqual(f['\u00fc'.encode('utf-8')],
+ self._dict['\u00fc'.encode('utf-8')])
+ self.assertEqual(f[b'1'], b'a')
+
def test_line_endings(self):
# test for bug #1172763: dumbdbm would die if the line endings
# weren't what was expected.
f = dumbdbm.open(_fname)
- f['1'] = 'hello'
- f['2'] = 'hello2'
+ f[b'1'] = b'hello'
+ f[b'2'] = b'hello2'
f.close()
- # Mangle the file by adding \r before each newline
- data = open(_fname + '.dir').read()
- data = data.replace('\n', '\r\n')
- open(_fname + '.dir', 'wb').write(data)
+ # Mangle the file by changing the line separator to Windows or Unix
+ with io.open(_fname + '.dir', 'rb') as file:
+ data = file.read()
+ if os.linesep == '\n':
+ data = data.replace(b'\n', b'\r\n')
+ else:
+ data = data.replace(b'\r\n', b'\n')
+ with io.open(_fname + '.dir', 'wb') as file:
+ file.write(data)
f = dumbdbm.open(_fname)
- self.assertEqual(f['1'], 'hello')
- self.assertEqual(f['2'], 'hello2')
+ self.assertEqual(f[b'1'], b'hello')
+ self.assertEqual(f[b'2'], b'hello2')
def read_helper(self, f):
@@ -128,10 +158,8 @@ class DumbDBMTestCase(unittest.TestCase):
f.close()
def keys_helper(self, f):
- keys = f.keys()
- keys.sort()
- dkeys = self._dict.keys()
- dkeys.sort()
+ keys = sorted(f.keys())
+ dkeys = sorted(self._dict.keys())
self.assertEqual(keys, dkeys)
return keys
@@ -149,17 +177,15 @@ class DumbDBMTestCase(unittest.TestCase):
del d[k]
del f[k]
else:
- v = random.choice('abc') * random.randrange(10000)
+ v = random.choice((b'a', b'b', b'c')) * random.randrange(10000)
d[k] = v
f[k] = v
self.assertEqual(f[k], v)
f.close()
f = dumbdbm.open(_fname)
- expected = d.items()
- expected.sort()
- got = f.items()
- got.sort()
+ expected = sorted((k.encode("latin-1"), v) for k, v in d.items())
+ got = sorted(f.items())
self.assertEqual(expected, got)
f.close()
@@ -171,7 +197,7 @@ class DumbDBMTestCase(unittest.TestCase):
def test_main():
try:
- test_support.run_unittest(DumbDBMTestCase)
+ support.run_unittest(DumbDBMTestCase)
finally:
_delete_files()
diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_dbm_gnu.py
index e9169a24e7e..30a39f7b895 100644..100755
--- a/Lib/test/test_gdbm.py
+++ b/Lib/test/test_dbm_gnu.py
@@ -1,13 +1,13 @@
+from test import support
+gdbm = support.import_module("dbm.gnu") #skip if not supported
import unittest
import os
-from test.test_support import TESTFN, run_unittest, unlink, import_module
-gdbm = import_module('gdbm')
+from test.support import verbose, TESTFN, run_unittest, unlink
filename = TESTFN
class TestGdbm(unittest.TestCase):
-
def setUp(self):
self.g = None
@@ -21,15 +21,21 @@ class TestGdbm(unittest.TestCase):
self.assertEqual(self.g.keys(), [])
self.g['a'] = 'b'
self.g['12345678910'] = '019237410982340912840198242'
+ self.g[b'bytes'] = b'data'
key_set = set(self.g.keys())
- self.assertEqual(key_set, frozenset(['a', '12345678910']))
- self.assertTrue(self.g.has_key('a'))
+ self.assertEqual(key_set, set([b'a', b'bytes', b'12345678910']))
+ self.assertIn(b'a', self.g)
+ self.assertEqual(self.g[b'bytes'], b'data')
key = self.g.firstkey()
while key:
self.assertIn(key, key_set)
key_set.remove(key)
key = self.g.nextkey(key)
self.assertRaises(KeyError, lambda: self.g['xxx'])
+ # get() and setdefault() work as in the dict interface
+ self.assertEqual(self.g.get(b'xxx', b'foo'), b'foo')
+ self.assertEqual(self.g.setdefault(b'xxx', b'foo'), b'foo')
+ self.assertEqual(self.g[b'xxx'], b'foo')
def test_error_conditions(self):
# Try to open a non-existent database.
@@ -47,7 +53,7 @@ class TestGdbm(unittest.TestCase):
all = set(gdbm.open_flags)
# Test standard flags (presumably "crwn").
modes = all - set('fsu')
- for mode in sorted(modes):
+ for mode in sorted(modes): # put "c" mode first
self.g = gdbm.open(filename, mode)
self.g.close()
diff --git a/Lib/test/test_dbm_ndbm.py b/Lib/test/test_dbm_ndbm.py
new file mode 100755
index 00000000000..00dcbd2160e
--- /dev/null
+++ b/Lib/test/test_dbm_ndbm.py
@@ -0,0 +1,43 @@
+from test import support
+support.import_module("dbm.ndbm") #skip if not supported
+import unittest
+import os
+import random
+import dbm.ndbm
+from dbm.ndbm import error
+
+class DbmTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.filename = support.TESTFN
+ self.d = dbm.ndbm.open(self.filename, 'c')
+ self.d.close()
+
+ def tearDown(self):
+ for suffix in ['', '.pag', '.dir', '.db']:
+ support.unlink(self.filename + suffix)
+
+ def test_keys(self):
+ self.d = dbm.ndbm.open(self.filename, 'c')
+ self.assertTrue(self.d.keys() == [])
+ self.d['a'] = 'b'
+ self.d[b'bytes'] = b'data'
+ self.d['12345678910'] = '019237410982340912840198242'
+ self.d.keys()
+ self.assertIn(b'a', self.d)
+ self.assertEqual(self.d[b'bytes'], b'data')
+ self.d.close()
+
+ def test_modes(self):
+ for mode in ['r', 'rw', 'w', 'n']:
+ try:
+ self.d = dbm.ndbm.open(self.filename, mode)
+ self.d.close()
+ except error:
+ self.fail()
+
+def test_main():
+ support.run_unittest(DbmTestCase)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_decimal.py b/Lib/test/test_decimal.py
index 3e184efc2e1..30d397178d0 100644
--- a/Lib/test/test_decimal.py
+++ b/Lib/test/test_decimal.py
@@ -27,12 +27,14 @@ with the corresponding argument.
import math
import os, sys
import operator
+import warnings
import pickle, copy
import unittest
from decimal import *
import numbers
-from test.test_support import (run_unittest, run_doctest,
- is_resource_enabled, check_py3k_warnings)
+from test.support import (run_unittest, run_doctest, is_resource_enabled,
+ requires_IEEE_754)
+from test.support import check_warnings
import random
try:
import threading
@@ -60,11 +62,6 @@ def init():
)
setcontext(DefaultTestContext)
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
-
TESTDATADIR = 'decimaltestdata'
if __name__ == '__main__':
file = sys.argv[0]
@@ -255,7 +252,7 @@ class DecimalTest(unittest.TestCase):
return self.eval_equation(s)
def eval_directive(self, s):
- funct, value = map(lambda x: x.strip().lower(), s.split(':'))
+ funct, value = (x.strip().lower() for x in s.split(':'))
if funct == 'rounding':
value = RoundingDict[value]
else:
@@ -279,7 +276,7 @@ class DecimalTest(unittest.TestCase):
L = Sides[0].strip().split()
id = L[0]
if DEBUG:
- print "Test ", id,
+ print("Test ", id, end=" ")
funct = L[1].lower()
valstemp = L[2:]
L = Sides[1].strip().split()
@@ -327,7 +324,7 @@ class DecimalTest(unittest.TestCase):
funct(self.context.create_decimal(v))
except error:
pass
- except Signals, e:
+ except Signals as e:
self.fail("Raised %s in %s when %s disabled" % \
(e, s, error))
else:
@@ -347,7 +344,7 @@ class DecimalTest(unittest.TestCase):
funct(*vals)
except error:
pass
- except Signals, e:
+ except Signals as e:
self.fail("Raised %s in %s when %s disabled" % \
(e, s, error))
else:
@@ -362,7 +359,7 @@ class DecimalTest(unittest.TestCase):
funct(*vals)
except error:
pass
- except Signals, e:
+ except Signals as e:
self.fail("Raised %s in %s; expected %s" %
(type(e), s, error))
else:
@@ -373,23 +370,26 @@ class DecimalTest(unittest.TestCase):
if DEBUG:
- print "--", self.context
+ print("--", self.context)
try:
result = str(funct(*vals))
if fname in LOGICAL_FUNCTIONS:
result = str(int(eval(result))) # 'True', 'False' -> '1', '0'
- except Signals, error:
+ except Signals as error:
self.fail("Raised %s in %s" % (error, s))
except: #Catch any error long enough to state the test case.
- print "ERROR:", s
+ print("ERROR:", s)
raise
myexceptions = self.getexceptions()
self.context.clear_flags()
+ myexceptions.sort(key=repr)
+ theirexceptions.sort(key=repr)
+
self.assertEqual(result, ans,
'Incorrect answer for ' + s + ' -- got ' + result)
- self.assertItemsEqual(myexceptions, theirexceptions,
+ self.assertEqual(myexceptions, theirexceptions,
'Incorrect flags set in ' + s + ' -- got ' + str(myexceptions))
return
@@ -405,7 +405,7 @@ class DecimalTest(unittest.TestCase):
def change_max_exponent(self, exp):
self.context.Emax = exp
def change_clamp(self, clamp):
- self.context._clamp = clamp
+ self.context.clamp = clamp
@@ -459,12 +459,6 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
self.assertEqual(str(Decimal('1.3E4 \n')), '1.3E+4')
self.assertEqual(str(Decimal(' -7.89')), '-7.89')
- #unicode strings should be permitted
- self.assertEqual(str(Decimal(u'0E-017')), '0E-17')
- self.assertEqual(str(Decimal(u'45')), '45')
- self.assertEqual(str(Decimal(u'-Inf')), '-Infinity')
- self.assertEqual(str(Decimal(u'NaN123')), 'NaN123')
-
def test_explicit_from_tuples(self):
#zero
@@ -600,9 +594,9 @@ class DecimalExplicitConstructionTest(unittest.TestCase):
def test_unicode_digits(self):
test_values = {
- u'\uff11': '1',
- u'\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372',
- u'-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400',
+ '\uff11': '1',
+ '\u0660.\u0660\u0663\u0667\u0662e-\u0663' : '0.0000372',
+ '-nan\u0c68\u0c6a\u0c66\u0c66' : '-NaN2400',
}
for input, expected in test_values.items():
self.assertEqual(str(Decimal(input)), expected)
@@ -663,17 +657,11 @@ class DecimalImplicitConstructionTest(unittest.TestCase):
('+', '__add__', '__radd__'),
('-', '__sub__', '__rsub__'),
('*', '__mul__', '__rmul__'),
+ ('/', '__truediv__', '__rtruediv__'),
('%', '__mod__', '__rmod__'),
('//', '__floordiv__', '__rfloordiv__'),
('**', '__pow__', '__rpow__')
]
- with check_py3k_warnings():
- if 1 / 2 == 0:
- # testing with classic division, so add __div__
- oplist.append(('/', '__div__', '__rdiv__'))
- else:
- # testing with -Qnew, so add __truediv__
- oplist.append(('/', '__truediv__', '__rtruediv__'))
for sym, lop, rop in oplist:
setattr(E, lop, lambda self, other: 'str' + lop + str(other))
@@ -826,6 +814,18 @@ class DecimalFormatTest(unittest.TestCase):
# issue 6850
('a=-7.0', '0.12345', 'aaaa0.1'),
+
+ # Issue 7094: Alternate formatting (specified by #)
+ ('.0e', '1.0', '1e+0'),
+ ('#.0e', '1.0', '1.e+0'),
+ ('.0f', '1.0', '1'),
+ ('#.0f', '1.0', '1.'),
+ ('g', '1.1', '1.1'),
+ ('#g', '1.1', '1.1'),
+ ('.0g', '1', '1'),
+ ('#.0g', '1', '1.'),
+ ('.0%', '1.0', '100%'),
+ ('#.0%', '1.0', '100.%'),
]
for fmt, d, result in test_values:
self.assertEqual(format(Decimal(d), fmt), result)
@@ -1263,17 +1263,11 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertNotEqual(da, dc)
self.assertLessEqual(da, db)
self.assertGreaterEqual(da, db)
- self.assertEqual(cmp(dc,da), 1)
- self.assertEqual(cmp(da,dc), -1)
- self.assertEqual(cmp(da,db), 0)
#a Decimal and an int
self.assertGreater(dc, 23)
self.assertLess(23, dc)
self.assertEqual(dc, 45)
- self.assertEqual(cmp(dc,23), 1)
- self.assertEqual(cmp(23,dc), -1)
- self.assertEqual(cmp(dc,45), 0)
#a Decimal and uncomparable
self.assertNotEqual(da, 'ugly')
@@ -1282,17 +1276,12 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertNotEqual(da, object)
# sortable
- a = map(Decimal, xrange(100))
+ a = list(map(Decimal, range(100)))
b = a[:]
random.shuffle(a)
a.sort()
self.assertEqual(a, b)
- # with None
- with check_py3k_warnings():
- self.assertFalse(Decimal(1) < None)
- self.assertTrue(Decimal(1) > None)
-
def test_decimal_float_comparison(self):
da = Decimal('0.25')
db = Decimal('3.0')
@@ -1318,19 +1307,26 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(id(dc), id(d))
def test_hash_method(self):
+ def hashit(d):
+ a = hash(d)
+ b = d.__hash__()
+ self.assertEqual(a, b)
+ return a
+
#just that it's hashable
- hash(Decimal(23))
- hash(Decimal('Infinity'))
- hash(Decimal('-Infinity'))
- hash(Decimal('nan123'))
- hash(Decimal('-NaN'))
+ hashit(Decimal(23))
+ hashit(Decimal('Infinity'))
+ hashit(Decimal('-Infinity'))
+ hashit(Decimal('nan123'))
+ hashit(Decimal('-NaN'))
test_values = [Decimal(sign*(2**m + n))
for m in [0, 14, 15, 16, 17, 30, 31,
- 32, 33, 62, 63, 64, 65, 66]
+ 32, 33, 61, 62, 63, 64, 65, 66]
for n in range(-10, 10)
for sign in [-1, 1]]
test_values.extend([
+ Decimal("-1"), # ==> -2
Decimal("-0"), # zeros
Decimal("0.00"),
Decimal("-0.000"),
@@ -1354,13 +1350,13 @@ class DecimalUsabilityTest(unittest.TestCase):
# check that hash(d) == hash(int(d)) for integral values
for value in test_values:
- self.assertEqual(hash(value), hash(int(value)))
+ self.assertEqual(hashit(value), hashit(int(value)))
#the same hash that to an int
- self.assertEqual(hash(Decimal(23)), hash(23))
+ self.assertEqual(hashit(Decimal(23)), hashit(23))
self.assertRaises(TypeError, hash, Decimal('sNaN'))
- self.assertTrue(hash(Decimal('Inf')))
- self.assertTrue(hash(Decimal('-Inf')))
+ self.assertTrue(hashit(Decimal('Inf')))
+ self.assertTrue(hashit(Decimal('-Inf')))
# check that the hashes of a Decimal float match when they
# represent exactly the same values
@@ -1369,7 +1365,7 @@ class DecimalUsabilityTest(unittest.TestCase):
for s in test_strings:
f = float(s)
d = Decimal(s)
- self.assertEqual(hash(f), hash(d))
+ self.assertEqual(hashit(f), hashit(d))
# check that the value of the hash doesn't depend on the
# current context (issue #1757)
@@ -1378,11 +1374,11 @@ class DecimalUsabilityTest(unittest.TestCase):
x = Decimal("123456789.1")
c.prec = 6
- h1 = hash(x)
+ h1 = hashit(x)
c.prec = 10
- h2 = hash(x)
+ h2 = hashit(x)
c.prec = 16
- h3 = hash(x)
+ h3 = hashit(x)
self.assertEqual(h1, h2)
self.assertEqual(h1, h3)
@@ -1420,18 +1416,8 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(str(d), '15.32') # str
self.assertEqual(repr(d), "Decimal('15.32')") # repr
- # result type of string methods should be str, not unicode
- unicode_inputs = [u'123.4', u'0.5E2', u'Infinity', u'sNaN',
- u'-0.0E100', u'-NaN001', u'-Inf']
-
- for u in unicode_inputs:
- d = Decimal(u)
- self.assertEqual(type(str(d)), str)
- self.assertEqual(type(repr(d)), str)
- self.assertEqual(type(d.to_eng_string()), str)
-
def test_tonum_methods(self):
- #Test float, int and long methods.
+ #Test float and int methods.
d1 = Decimal('66')
d2 = Decimal('15.32')
@@ -1440,14 +1426,96 @@ class DecimalUsabilityTest(unittest.TestCase):
self.assertEqual(int(d1), 66)
self.assertEqual(int(d2), 15)
- #long
- self.assertEqual(long(d1), 66)
- self.assertEqual(long(d2), 15)
-
#float
self.assertEqual(float(d1), 66)
self.assertEqual(float(d2), 15.32)
+ #floor
+ test_pairs = [
+ ('123.00', 123),
+ ('3.2', 3),
+ ('3.54', 3),
+ ('3.899', 3),
+ ('-2.3', -3),
+ ('-11.0', -11),
+ ('0.0', 0),
+ ('-0E3', 0),
+ ]
+ for d, i in test_pairs:
+ self.assertEqual(math.floor(Decimal(d)), i)
+ self.assertRaises(ValueError, math.floor, Decimal('-NaN'))
+ self.assertRaises(ValueError, math.floor, Decimal('sNaN'))
+ self.assertRaises(ValueError, math.floor, Decimal('NaN123'))
+ self.assertRaises(OverflowError, math.floor, Decimal('Inf'))
+ self.assertRaises(OverflowError, math.floor, Decimal('-Inf'))
+
+ #ceiling
+ test_pairs = [
+ ('123.00', 123),
+ ('3.2', 4),
+ ('3.54', 4),
+ ('3.899', 4),
+ ('-2.3', -2),
+ ('-11.0', -11),
+ ('0.0', 0),
+ ('-0E3', 0),
+ ]
+ for d, i in test_pairs:
+ self.assertEqual(math.ceil(Decimal(d)), i)
+ self.assertRaises(ValueError, math.ceil, Decimal('-NaN'))
+ self.assertRaises(ValueError, math.ceil, Decimal('sNaN'))
+ self.assertRaises(ValueError, math.ceil, Decimal('NaN123'))
+ self.assertRaises(OverflowError, math.ceil, Decimal('Inf'))
+ self.assertRaises(OverflowError, math.ceil, Decimal('-Inf'))
+
+ #round, single argument
+ test_pairs = [
+ ('123.00', 123),
+ ('3.2', 3),
+ ('3.54', 4),
+ ('3.899', 4),
+ ('-2.3', -2),
+ ('-11.0', -11),
+ ('0.0', 0),
+ ('-0E3', 0),
+ ('-3.5', -4),
+ ('-2.5', -2),
+ ('-1.5', -2),
+ ('-0.5', 0),
+ ('0.5', 0),
+ ('1.5', 2),
+ ('2.5', 2),
+ ('3.5', 4),
+ ]
+ for d, i in test_pairs:
+ self.assertEqual(round(Decimal(d)), i)
+ self.assertRaises(ValueError, round, Decimal('-NaN'))
+ self.assertRaises(ValueError, round, Decimal('sNaN'))
+ self.assertRaises(ValueError, round, Decimal('NaN123'))
+ self.assertRaises(OverflowError, round, Decimal('Inf'))
+ self.assertRaises(OverflowError, round, Decimal('-Inf'))
+
+ #round, two arguments; this is essentially equivalent
+ #to quantize, which is already extensively tested
+ test_triples = [
+ ('123.456', -4, '0E+4'),
+ ('123.456', -3, '0E+3'),
+ ('123.456', -2, '1E+2'),
+ ('123.456', -1, '1.2E+2'),
+ ('123.456', 0, '123'),
+ ('123.456', 1, '123.5'),
+ ('123.456', 2, '123.46'),
+ ('123.456', 3, '123.456'),
+ ('123.456', 4, '123.4560'),
+ ('123.455', 2, '123.46'),
+ ('123.445', 2, '123.44'),
+ ('Inf', 4, 'NaN'),
+ ('-Inf', -23, 'NaN'),
+ ('sNaN314', 3, 'NaN314'),
+ ]
+ for d, n, r in test_triples:
+ self.assertEqual(str(round(Decimal(d), n)), r)
+
def test_nan_to_float(self):
# Test conversions of decimal NANs to float.
# See http://bugs.python.org/issue15544
@@ -1549,7 +1617,6 @@ class DecimalUsabilityTest(unittest.TestCase):
checkSameDec("__abs__")
checkSameDec("__add__", True)
- checkSameDec("__div__", True)
checkSameDec("__divmod__", True)
checkSameDec("__eq__", True)
checkSameDec("__ne__", True)
@@ -1562,15 +1629,13 @@ class DecimalUsabilityTest(unittest.TestCase):
checkSameDec("__hash__")
checkSameDec("__int__")
checkSameDec("__trunc__")
- checkSameDec("__long__")
checkSameDec("__mod__", True)
checkSameDec("__mul__", True)
checkSameDec("__neg__")
- checkSameDec("__nonzero__")
+ checkSameDec("__bool__")
checkSameDec("__pos__")
checkSameDec("__pow__", True)
checkSameDec("__radd__", True)
- checkSameDec("__rdiv__", True)
checkSameDec("__rdivmod__", True)
checkSameDec("__repr__")
checkSameDec("__rfloordiv__", True)
@@ -1691,11 +1756,6 @@ class DecimalPythonAPItests(unittest.TestCase):
self.assertRaises(OverflowError, int, Decimal('inf'))
self.assertRaises(OverflowError, int, Decimal('-inf'))
- self.assertRaises(ValueError, long, Decimal('-nan'))
- self.assertRaises(ValueError, long, Decimal('snan'))
- self.assertRaises(OverflowError, long, Decimal('inf'))
- self.assertRaises(OverflowError, long, Decimal('-inf'))
-
def test_trunc(self):
for x in range(-250, 250):
s = '%0.2f' % (x / 100.0)
@@ -1777,6 +1837,26 @@ class ContextAPItests(unittest.TestCase):
self.assertNotEqual(id(c.flags), id(d.flags))
self.assertNotEqual(id(c.traps), id(d.traps))
+ def test__clamp(self):
+ # In Python 3.2, the private attribute `_clamp` was made
+ # public (issue 8540), with the old `_clamp` becoming a
+ # property wrapping `clamp`. For the duration of Python 3.2
+ # only, the attribute should be gettable/settable via both
+ # `clamp` and `_clamp`; in Python 3.3, `_clamp` should be
+ # removed.
+ c = Context(clamp = 0)
+ self.assertEqual(c.clamp, 0)
+
+ with check_warnings(("", DeprecationWarning)):
+ c._clamp = 1
+ self.assertEqual(c.clamp, 1)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 1)
+ c.clamp = 0
+ self.assertEqual(c.clamp, 0)
+ with check_warnings(("", DeprecationWarning)):
+ self.assertEqual(c._clamp, 0)
+
def test_abs(self):
c = Context()
d = c.abs(Decimal(-1))
@@ -2274,14 +2354,16 @@ class ContextFlags(unittest.TestCase):
for flag in extra_flags:
if flag not in expected_flags:
expected_flags.append(flag)
+ expected_flags.sort(key=id)
# flags we actually got
new_flags = [k for k,v in context.flags.items() if v]
+ new_flags.sort(key=id)
self.assertEqual(ans, new_ans,
"operation produces different answers depending on flags set: " +
"expected %s, got %s." % (ans, new_ans))
- self.assertItemsEqual(new_flags, expected_flags,
+ self.assertEqual(new_flags, expected_flags,
"operation raises different flags depending on flags set: " +
"expected %s, got %s" % (expected_flags, new_flags))
diff --git a/Lib/test/test_decorators.py b/Lib/test/test_decorators.py
index cf2bc3000c4..53c94691122 100644
--- a/Lib/test/test_decorators.py
+++ b/Lib/test/test_decorators.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support
+from test import support
def funcattrs(**kwds):
def decorate(func):
@@ -27,7 +27,7 @@ class DbcheckError (Exception):
def dbcheck(exprstr, globals=None, locals=None):
"Decorator to implement debugging assertions"
def decorate(func):
- expr = compile(exprstr, "dbcheck-%s" % func.func_name, "eval")
+ expr = compile(exprstr, "dbcheck-%s" % func.__name__, "eval")
def check(*args, **kwds):
if not eval(expr, globals, locals):
raise DbcheckError(exprstr, func, args, kwds)
@@ -40,12 +40,12 @@ def dbcheck(exprstr, globals=None, locals=None):
def countcalls(counts):
"Decorator to count calls to a function"
def decorate(func):
- func_name = func.func_name
+ func_name = func.__name__
counts[func_name] = 0
def call(*args, **kwds):
counts[func_name] += 1
return func(*args, **kwds)
- call.func_name = func_name
+ call.__name__ = func_name
return call
return decorate
@@ -63,7 +63,7 @@ def memoize(func):
except TypeError:
# Unhashable argument
return func(*args)
- call.func_name = func.func_name
+ call.__name__ = func.__name__
return call
# -----------------------------------------------
@@ -131,7 +131,7 @@ class TestDecorators(unittest.TestCase):
@countcalls(counts)
def double(x):
return x * 2
- self.assertEqual(double.func_name, 'double')
+ self.assertEqual(double.__name__, 'double')
self.assertEqual(counts, dict(double=0))
@@ -302,8 +302,8 @@ class TestClassDecorators(unittest.TestCase):
self.assertEqual(C.extra, 'second')
def test_main():
- test_support.run_unittest(TestDecorators)
- test_support.run_unittest(TestClassDecorators)
+ support.run_unittest(TestDecorators)
+ support.run_unittest(TestClassDecorators)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_defaultdict.py b/Lib/test/test_defaultdict.py
index 3d760b9ffbb..532d535981b 100644
--- a/Lib/test/test_defaultdict.py
+++ b/Lib/test/test_defaultdict.py
@@ -2,9 +2,10 @@
import os
import copy
+import pickle
import tempfile
import unittest
-from test import test_support
+from test import support
from collections import defaultdict
@@ -43,7 +44,7 @@ class TestDefaultDict(unittest.TestCase):
self.assertEqual(d2.default_factory, None)
try:
d2[15]
- except KeyError, err:
+ except KeyError as err:
self.assertEqual(err.args, (15,))
else:
self.fail("d2[15] didn't raise KeyError")
@@ -65,7 +66,7 @@ class TestDefaultDict(unittest.TestCase):
d2 = defaultdict(int)
self.assertEqual(d2.default_factory, int)
d2[12] = 42
- self.assertEqual(repr(d2), "defaultdict(<type 'int'>, {12: 42})")
+ self.assertEqual(repr(d2), "defaultdict(<class 'int'>, {12: 42})")
def foo(): return 43
d3 = defaultdict(foo)
self.assertTrue(d3.default_factory is foo)
@@ -83,8 +84,8 @@ class TestDefaultDict(unittest.TestCase):
try:
f = open(tfn, "w+")
try:
- print >>f, d1
- print >>f, d2
+ print(d1, file=f)
+ print(d2, file=f)
f.seek(0)
self.assertEqual(f.readline(), repr(d1) + "\n")
self.assertEqual(f.readline(), repr(d2) + "\n")
@@ -143,7 +144,7 @@ class TestDefaultDict(unittest.TestCase):
d1 = defaultdict()
try:
d1[(1,)]
- except KeyError, err:
+ except KeyError as err:
self.assertEqual(err.args[0], (1,))
else:
self.fail("expected KeyError")
@@ -165,7 +166,7 @@ class TestDefaultDict(unittest.TestCase):
try:
f = open(tfn, "w+")
try:
- print >>f, d
+ print(d, file=f)
finally:
f.close()
finally:
@@ -174,8 +175,16 @@ class TestDefaultDict(unittest.TestCase):
def test_callable_arg(self):
self.assertRaises(TypeError, defaultdict, {})
+ def test_pickleing(self):
+ d = defaultdict(int)
+ d[1]
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ s = pickle.dumps(d, proto)
+ o = pickle.loads(s)
+ self.assertEqual(d, o)
+
def test_main():
- test_support.run_unittest(TestDefaultDict)
+ support.run_unittest(TestDefaultDict)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 595a0c4a35c..f0afe1dcb75 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -1,10 +1,11 @@
from collections import deque
import unittest
-from test import test_support, seq_tests
+from test import support, seq_tests
import gc
import weakref
import copy
-import cPickle as pickle
+import pickle
+from io import StringIO
import random
import struct
@@ -29,23 +30,23 @@ class MutateCmp:
class TestBasic(unittest.TestCase):
def test_basics(self):
- d = deque(xrange(-5125, -5000))
- d.__init__(xrange(200))
- for i in xrange(200, 400):
+ d = deque(range(-5125, -5000))
+ d.__init__(range(200))
+ for i in range(200, 400):
d.append(i)
- for i in reversed(xrange(-200, 0)):
+ for i in reversed(range(-200, 0)):
d.appendleft(i)
- self.assertEqual(list(d), range(-200, 400))
+ self.assertEqual(list(d), list(range(-200, 400)))
self.assertEqual(len(d), 600)
- left = [d.popleft() for i in xrange(250)]
- self.assertEqual(left, range(-200, 50))
- self.assertEqual(list(d), range(50, 400))
+ left = [d.popleft() for i in range(250)]
+ self.assertEqual(left, list(range(-200, 50)))
+ self.assertEqual(list(d), list(range(50, 400)))
- right = [d.pop() for i in xrange(250)]
+ right = [d.pop() for i in range(250)]
right.reverse()
- self.assertEqual(right, range(150, 400))
- self.assertEqual(list(d), range(50, 150))
+ self.assertEqual(right, list(range(150, 400)))
+ self.assertEqual(list(d), list(range(50, 150)))
def test_maxlen(self):
self.assertRaises(ValueError, deque, 'abc', -1)
@@ -54,40 +55,40 @@ class TestBasic(unittest.TestCase):
d = deque(it, maxlen=3)
self.assertEqual(list(it), [])
self.assertEqual(repr(d), 'deque([7, 8, 9], maxlen=3)')
- self.assertEqual(list(d), range(7, 10))
+ self.assertEqual(list(d), [7, 8, 9])
self.assertEqual(d, deque(range(10), 3))
d.append(10)
- self.assertEqual(list(d), range(8, 11))
+ self.assertEqual(list(d), [8, 9, 10])
d.appendleft(7)
- self.assertEqual(list(d), range(7, 10))
+ self.assertEqual(list(d), [7, 8, 9])
d.extend([10, 11])
- self.assertEqual(list(d), range(9, 12))
+ self.assertEqual(list(d), [9, 10, 11])
d.extendleft([8, 7])
- self.assertEqual(list(d), range(7, 10))
- d = deque(xrange(200), maxlen=10)
+ self.assertEqual(list(d), [7, 8, 9])
+ d = deque(range(200), maxlen=10)
d.append(d)
- test_support.unlink(test_support.TESTFN)
- fo = open(test_support.TESTFN, "wb")
+ support.unlink(support.TESTFN)
+ fo = open(support.TESTFN, "w")
try:
- print >> fo, d,
+ fo.write(str(d))
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
d = deque(range(10), maxlen=None)
self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])')
- fo = open(test_support.TESTFN, "wb")
+ fo = open(support.TESTFN, "w")
try:
- print >> fo, d,
+ fo.write(str(d))
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_maxlen_zero(self):
it = iter(range(100))
@@ -162,7 +163,6 @@ class TestBasic(unittest.TestCase):
self.assertEqual(x <= y, list(x) <= list(y), (x,y))
self.assertEqual(x > y, list(x) > list(y), (x,y))
self.assertEqual(x >= y, list(x) >= list(y), (x,y))
- self.assertEqual(cmp(x,y), cmp(list(x),list(y)), (x,y))
def test_extend(self):
d = deque('a')
@@ -193,15 +193,15 @@ class TestBasic(unittest.TestCase):
def test_getitem(self):
n = 200
- d = deque(xrange(n))
- l = range(n)
- for i in xrange(n):
+ d = deque(range(n))
+ l = list(range(n))
+ for i in range(n):
d.popleft()
l.pop(0)
if random.random() < 0.5:
d.append(i)
l.append(i)
- for j in xrange(1-len(l), len(l)):
+ for j in range(1-len(l), len(l)):
assert d[j] == l[j]
d = deque('superman')
@@ -213,22 +213,22 @@ class TestBasic(unittest.TestCase):
def test_setitem(self):
n = 200
- d = deque(xrange(n))
- for i in xrange(n):
+ d = deque(range(n))
+ for i in range(n):
d[i] = 10 * i
- self.assertEqual(list(d), [10*i for i in xrange(n)])
+ self.assertEqual(list(d), [10*i for i in range(n)])
l = list(d)
- for i in xrange(1-n, 0, -1):
+ for i in range(1-n, 0, -1):
d[i] = 7*i
l[i] = 7*i
self.assertEqual(list(d), l)
def test_delitem(self):
n = 500 # O(n**2) test, don't make this too big
- d = deque(xrange(n))
+ d = deque(range(n))
self.assertRaises(IndexError, d.__delitem__, -n-1)
self.assertRaises(IndexError, d.__delitem__, n)
- for i in xrange(n):
+ for i in range(n):
self.assertEqual(len(d), n-i)
j = random.randrange(-len(d), len(d))
val = d[j]
@@ -263,11 +263,11 @@ class TestBasic(unittest.TestCase):
d.rotate() # check default to 1
self.assertEqual(tuple(d), s)
- for i in xrange(n*3):
+ for i in range(n*3):
d = deque(s)
e = deque(d)
d.rotate(i) # check vs. rot(1) n times
- for j in xrange(i):
+ for j in range(i):
e.rotate(1)
self.assertEqual(tuple(d), tuple(e))
d.rotate(-i) # check that it works in reverse
@@ -275,11 +275,11 @@ class TestBasic(unittest.TestCase):
e.rotate(n-i) # check that it wraps forward
self.assertEqual(tuple(e), s)
- for i in xrange(n*3):
+ for i in range(n*3):
d = deque(s)
e = deque(d)
d.rotate(-i)
- for j in xrange(i):
+ for j in range(i):
e.rotate(-1) # check vs. rot(-1) n times
self.assertEqual(tuple(d), tuple(e))
d.rotate(i) # check that it works in reverse
@@ -291,7 +291,7 @@ class TestBasic(unittest.TestCase):
e = deque(s)
e.rotate(BIG+17) # verify on long series of rotates
dr = d.rotate
- for i in xrange(BIG+17):
+ for i in range(BIG+17):
dr()
self.assertEqual(tuple(d), tuple(e))
@@ -324,7 +324,7 @@ class TestBasic(unittest.TestCase):
self.assertRaises(IndexError, d.popleft)
def test_clear(self):
- d = deque(xrange(100))
+ d = deque(range(100))
self.assertEqual(len(d), 100)
d.clear()
self.assertEqual(len(d), 0)
@@ -357,25 +357,25 @@ class TestBasic(unittest.TestCase):
self.assertEqual(d, deque())
def test_repr(self):
- d = deque(xrange(200))
+ d = deque(range(200))
e = eval(repr(d))
self.assertEqual(list(d), list(e))
d.append(d)
self.assertIn('...', repr(d))
def test_print(self):
- d = deque(xrange(200))
+ d = deque(range(200))
d.append(d)
- test_support.unlink(test_support.TESTFN)
- fo = open(test_support.TESTFN, "wb")
try:
- print >> fo, d,
+ support.unlink(support.TESTFN)
+ fo = open(support.TESTFN, "w")
+ print(d, file=fo, end='')
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(d))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_init(self):
self.assertRaises(TypeError, deque, 'abc', 2, 3);
@@ -386,33 +386,34 @@ class TestBasic(unittest.TestCase):
def test_long_steadystate_queue_popleft(self):
for size in (0, 1, 2, 100, 1000):
- d = deque(xrange(size))
+ d = deque(range(size))
append, pop = d.append, d.popleft
- for i in xrange(size, BIG):
+ for i in range(size, BIG):
append(i)
x = pop()
if x != i - size:
self.assertEqual(x, i-size)
- self.assertEqual(list(d), range(BIG-size, BIG))
+ self.assertEqual(list(d), list(range(BIG-size, BIG)))
def test_long_steadystate_queue_popright(self):
for size in (0, 1, 2, 100, 1000):
- d = deque(reversed(xrange(size)))
+ d = deque(reversed(range(size)))
append, pop = d.appendleft, d.pop
- for i in xrange(size, BIG):
+ for i in range(size, BIG):
append(i)
x = pop()
if x != i - size:
self.assertEqual(x, i-size)
- self.assertEqual(list(reversed(list(d))), range(BIG-size, BIG))
+ self.assertEqual(list(reversed(list(d))),
+ list(range(BIG-size, BIG)))
def test_big_queue_popleft(self):
pass
d = deque()
append, pop = d.append, d.popleft
- for i in xrange(BIG):
+ for i in range(BIG):
append(i)
- for i in xrange(BIG):
+ for i in range(BIG):
x = pop()
if x != i:
self.assertEqual(x, i)
@@ -420,9 +421,9 @@ class TestBasic(unittest.TestCase):
def test_big_queue_popright(self):
d = deque()
append, pop = d.appendleft, d.pop
- for i in xrange(BIG):
+ for i in range(BIG):
append(i)
- for i in xrange(BIG):
+ for i in range(BIG):
x = pop()
if x != i:
self.assertEqual(x, i)
@@ -430,9 +431,9 @@ class TestBasic(unittest.TestCase):
def test_big_stack_right(self):
d = deque()
append, pop = d.append, d.pop
- for i in xrange(BIG):
+ for i in range(BIG):
append(i)
- for i in reversed(xrange(BIG)):
+ for i in reversed(range(BIG)):
x = pop()
if x != i:
self.assertEqual(x, i)
@@ -441,22 +442,22 @@ class TestBasic(unittest.TestCase):
def test_big_stack_left(self):
d = deque()
append, pop = d.appendleft, d.popleft
- for i in xrange(BIG):
+ for i in range(BIG):
append(i)
- for i in reversed(xrange(BIG)):
+ for i in reversed(range(BIG)):
x = pop()
if x != i:
self.assertEqual(x, i)
self.assertEqual(len(d), 0)
def test_roundtrip_iter_init(self):
- d = deque(xrange(200))
+ d = deque(range(200))
e = deque(d)
self.assertNotEqual(id(d), id(e))
self.assertEqual(list(d), list(e))
def test_pickle(self):
- d = deque(xrange(200))
+ d = deque(range(200))
for i in range(pickle.HIGHEST_PROTOCOL + 1):
s = pickle.dumps(d, i)
e = pickle.loads(s)
@@ -490,7 +491,7 @@ class TestBasic(unittest.TestCase):
self.assertEqual(list(d), list(e))
def test_reversed(self):
- for s in ('abcd', xrange(2000)):
+ for s in ('abcd', range(2000)):
self.assertEqual(list(reversed(deque(s))), list(reversed(s)))
def test_gc_doesnt_blowup(self):
@@ -498,7 +499,7 @@ class TestBasic(unittest.TestCase):
# This used to assert-fail in deque_traverse() under a debug
# build, or run wild with a NULL pointer in a release build.
d = deque()
- for i in xrange(100):
+ for i in range(100):
d.append(1)
gc.collect()
@@ -518,12 +519,12 @@ class TestBasic(unittest.TestCase):
gc.collect()
self.assertTrue(ref() is None, "Cycle was not collected")
- check_sizeof = test_support.check_sizeof
+ check_sizeof = support.check_sizeof
- @test_support.cpython_only
+ @support.cpython_only
def test_sizeof(self):
BLOCKLEN = 62
- basesize = test_support.calcobjsize('2P4PlP')
+ basesize = support.calcobjsize('2P4PlP')
blocksize = struct.calcsize('2P%dP' % BLOCKLEN)
self.assertEqual(object.__sizeof__(deque()), basesize)
check = self.check_sizeof
@@ -536,7 +537,7 @@ class TestBasic(unittest.TestCase):
class TestVariousIteratorArgs(unittest.TestCase):
def test_constructor(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (seq_tests.Sequence, seq_tests.IterFunc,
seq_tests.IterGen, seq_tests.IterFuncStop,
seq_tests.itermulti, seq_tests.iterfunc):
@@ -549,13 +550,13 @@ class TestVariousIteratorArgs(unittest.TestCase):
d = deque('abcdefg')
it = iter(d)
d.pop()
- self.assertRaises(RuntimeError, it.next)
+ self.assertRaises(RuntimeError, next, it)
def test_runtime_error_on_empty_deque(self):
d = deque()
it = iter(d)
d.append(10)
- self.assertRaises(RuntimeError, it.next)
+ self.assertRaises(RuntimeError, next, it)
class Deque(deque):
pass
@@ -567,23 +568,23 @@ class DequeWithBadIter(deque):
class TestSubclass(unittest.TestCase):
def test_basics(self):
- d = Deque(xrange(25))
- d.__init__(xrange(200))
- for i in xrange(200, 400):
+ d = Deque(range(25))
+ d.__init__(range(200))
+ for i in range(200, 400):
d.append(i)
- for i in reversed(xrange(-200, 0)):
+ for i in reversed(range(-200, 0)):
d.appendleft(i)
- self.assertEqual(list(d), range(-200, 400))
+ self.assertEqual(list(d), list(range(-200, 400)))
self.assertEqual(len(d), 600)
- left = [d.popleft() for i in xrange(250)]
- self.assertEqual(left, range(-200, 50))
- self.assertEqual(list(d), range(50, 400))
+ left = [d.popleft() for i in range(250)]
+ self.assertEqual(left, list(range(-200, 50)))
+ self.assertEqual(list(d), list(range(50, 400)))
- right = [d.pop() for i in xrange(250)]
+ right = [d.pop() for i in range(250)]
right.reverse()
- self.assertEqual(right, range(150, 400))
- self.assertEqual(list(d), range(50, 150))
+ self.assertEqual(right, list(range(150, 400)))
+ self.assertEqual(list(d), list(range(50, 150)))
d.clear()
self.assertEqual(len(d), 0)
@@ -675,7 +676,7 @@ Example from the Library Reference: Doc/lib/libcollections.tex
>>> from collections import deque
>>> d = deque('ghi') # make a new deque with three items
>>> for elem in d: # iterate over the deque's elements
-... print elem.upper()
+... print(elem.upper())
G
H
I
@@ -738,14 +739,14 @@ deque(['a', 'b', 'd', 'e', 'f'])
... while pending:
... task = pending.popleft()
... try:
-... yield task.next()
+... yield next(task)
... except StopIteration:
... continue
... pending.append(task)
...
>>> for value in roundrobin('abc', 'd', 'efgh'):
-... print value
+... print(value)
...
a
d
@@ -764,7 +765,7 @@ h
... d.append(pair)
... return list(d)
...
->>> print maketree('abcdefgh')
+>>> print(maketree('abcdefgh'))
[[[['a', 'b'], ['c', 'd']], [['e', 'f'], ['g', 'h']]]]
"""
@@ -783,21 +784,21 @@ def test_main(verbose=None):
TestSubclassWithKwargs,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
# doctests
from test import test_deque
- test_support.run_doctest(test_deque, verbose)
+ support.run_doctest(test_deque, verbose)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index bfb3552f55a..cdaf7d2aca0 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1,12 +1,13 @@
-import __builtin__
+import builtins
import gc
import sys
import types
+import math
import unittest
import weakref
from copy import deepcopy
-from test import test_support
+from test import support
class OperatorsTest(unittest.TestCase):
@@ -34,7 +35,7 @@ class OperatorsTest(unittest.TestCase):
'ge': '>=',
}
- for name, expr in self.binops.items():
+ for name, expr in list(self.binops.items()):
if expr.islower():
expr = expr + "(a, b)"
else:
@@ -47,13 +48,12 @@ class OperatorsTest(unittest.TestCase):
'abs': 'abs',
'invert': '~',
'int': 'int',
- 'long': 'long',
'float': 'float',
'oct': 'oct',
'hex': 'hex',
}
- for name, expr in self.unops.items():
+ for name, expr in list(self.unops.items()):
if expr.islower():
expr = expr + "(a)"
else:
@@ -97,7 +97,7 @@ class OperatorsTest(unittest.TestCase):
bm = getattr(a, meth)
self.assertEqual(bm(b), res)
- def ternop_test(self, a, b, c, res, expr="a[b:c]", meth="__getslice__"):
+ def sliceop_test(self, a, b, c, res, expr="a[b:c]", meth="__getitem__"):
d = {'a': a, 'b': b, 'c': c}
self.assertEqual(eval(expr, d), res)
t = type(a)
@@ -107,13 +107,13 @@ class OperatorsTest(unittest.TestCase):
# in some implementations (e.g. PyPy), 'm' can be a regular unbound
# method object; the getattr() below obtains its underlying function.
self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth])
- self.assertEqual(m(a, b, c), res)
+ self.assertEqual(m(a, slice(b, c)), res)
bm = getattr(a, meth)
- self.assertEqual(bm(b, c), res)
+ self.assertEqual(bm(slice(b, c)), res)
def setop_test(self, a, b, res, stmt="a+=b", meth="__iadd__"):
d = {'a': deepcopy(a), 'b': b}
- exec stmt in d
+ exec(stmt, d)
self.assertEqual(d['a'], res)
t = type(a)
m = getattr(t, meth)
@@ -132,7 +132,7 @@ class OperatorsTest(unittest.TestCase):
def set2op_test(self, a, b, c, res, stmt="a[b]=c", meth="__setitem__"):
d = {'a': deepcopy(a), 'b': b, 'c': c}
- exec stmt in d
+ exec(stmt, d)
self.assertEqual(d['a'], res)
t = type(a)
m = getattr(t, meth)
@@ -149,9 +149,9 @@ class OperatorsTest(unittest.TestCase):
bm(b, c)
self.assertEqual(d['a'], res)
- def set3op_test(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setslice__"):
+ def setsliceop_test(self, a, b, c, d, res, stmt="a[b:c]=d", meth="__setitem__"):
dictionary = {'a': deepcopy(a), 'b': b, 'c': c, 'd': d}
- exec stmt in dictionary
+ exec(stmt, dictionary)
self.assertEqual(dictionary['a'], res)
t = type(a)
while meth not in t.__dict__:
@@ -161,11 +161,11 @@ class OperatorsTest(unittest.TestCase):
# method object; the getattr() below obtains its underlying function.
self.assertEqual(getattr(m, 'im_func', m), t.__dict__[meth])
dictionary['a'] = deepcopy(a)
- m(dictionary['a'], b, c, d)
+ m(dictionary['a'], slice(b, c), d)
self.assertEqual(dictionary['a'], res)
dictionary['a'] = deepcopy(a)
bm = getattr(dictionary['a'], meth)
- bm(b, c, d)
+ bm(slice(b, c), d)
self.assertEqual(dictionary['a'], res)
def test_lists(self):
@@ -175,29 +175,25 @@ class OperatorsTest(unittest.TestCase):
self.binop_test([1,2,3], 2, 1, "b in a", "__contains__")
self.binop_test([1,2,3], 4, 0, "b in a", "__contains__")
self.binop_test([1,2,3], 1, 2, "a[b]", "__getitem__")
- self.ternop_test([1,2,3], 0, 2, [1,2], "a[b:c]", "__getslice__")
+ self.sliceop_test([1,2,3], 0, 2, [1,2], "a[b:c]", "__getitem__")
self.setop_test([1], [2], [1,2], "a+=b", "__iadd__")
self.setop_test([1,2], 3, [1,2,1,2,1,2], "a*=b", "__imul__")
self.unop_test([1,2,3], 3, "len(a)", "__len__")
self.binop_test([1,2], 3, [1,2,1,2,1,2], "a*b", "__mul__")
self.binop_test([1,2], 3, [1,2,1,2,1,2], "b*a", "__rmul__")
self.set2op_test([1,2], 1, 3, [1,3], "a[b]=c", "__setitem__")
- self.set3op_test([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d",
- "__setslice__")
+ self.setsliceop_test([1,2,3,4], 1, 3, [5,6], [1,5,6,4], "a[b:c]=d",
+ "__setitem__")
def test_dicts(self):
# Testing dict operations...
- if hasattr(dict, '__cmp__'): # PyPy has only rich comparison on dicts
- self.binop_test({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__")
- else:
- self.binop_test({1:2}, {2:1}, True, "a < b", "__lt__")
self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__")
self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__")
self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__")
d = {1:2, 3:4}
l1 = []
- for i in d.keys():
+ for i in list(d.keys()):
l1.append(i)
l = []
for i in iter(d):
@@ -222,14 +218,14 @@ class OperatorsTest(unittest.TestCase):
def number_operators(self, a, b, skip=[]):
dict = {'a': a, 'b': b}
- for name, expr in self.binops.items():
+ for name, expr in list(self.binops.items()):
if name not in skip:
name = "__%s__" % name
if hasattr(a, name):
res = eval(expr, dict)
self.binop_test(a, b, res, expr, name)
- for name, expr in self.unops.items():
+ for name, expr in list(self.unops.items()):
if name not in skip:
name = "__%s__" % name
if hasattr(a, name):
@@ -240,29 +236,19 @@ class OperatorsTest(unittest.TestCase):
# Testing int operations...
self.number_operators(100, 3)
# The following crashes in Python 2.2
- self.assertEqual((1).__nonzero__(), 1)
- self.assertEqual((0).__nonzero__(), 0)
+ self.assertEqual((1).__bool__(), 1)
+ self.assertEqual((0).__bool__(), 0)
# This returns 'NotImplemented' in Python 2.2
class C(int):
def __add__(self, other):
return NotImplemented
- self.assertEqual(C(5L), 5)
+ self.assertEqual(C(5), 5)
try:
C() + ""
except TypeError:
pass
else:
self.fail("NotImplemented should have caused TypeError")
- try:
- C(sys.maxint+1)
- except OverflowError:
- pass
- else:
- self.fail("should have raised OverflowError")
-
- def test_longs(self):
- # Testing long operations...
- self.number_operators(100L, 3L)
def test_floats(self):
# Testing float operations...
@@ -271,7 +257,8 @@ class OperatorsTest(unittest.TestCase):
def test_complexes(self):
# Testing complex operations...
self.number_operators(100.0j, 3.0j, skip=['lt', 'le', 'gt', 'ge',
- 'int', 'long', 'float'])
+ 'int', 'float',
+ 'divmod', 'mod'])
class Number(complex):
__slots__ = ['prec']
@@ -300,7 +287,12 @@ class OperatorsTest(unittest.TestCase):
self.assertEqual(repr(a), "234.5")
self.assertEqual(a.prec, 12)
- @test_support.impl_detail("the module 'xxsubtype' is internal")
+ def test_explicit_reverse_methods(self):
+ # see issue 9930
+ self.assertEqual(complex.__radd__(3j, 4.0), complex(4.0, 3.0))
+ self.assertEqual(float.__rsub__(3.0, 1), -2.0)
+
+ @support.impl_detail("the module 'xxsubtype' is internal")
def test_spam_lists(self):
# Testing spamlist operations...
import copy, xxsubtype as spam
@@ -317,21 +309,21 @@ class OperatorsTest(unittest.TestCase):
self.binop_test(spamlist([1,2,3]), 2, 1, "b in a", "__contains__")
self.binop_test(spamlist([1,2,3]), 4, 0, "b in a", "__contains__")
self.binop_test(spamlist([1,2,3]), 1, 2, "a[b]", "__getitem__")
- self.ternop_test(spamlist([1,2,3]), 0, 2, spamlist([1,2]), "a[b:c]",
- "__getslice__")
+ self.sliceop_test(spamlist([1,2,3]), 0, 2, spamlist([1,2]), "a[b:c]",
+ "__getitem__")
self.setop_test(spamlist([1]), spamlist([2]), spamlist([1,2]), "a+=b",
- "__iadd__")
+ "__iadd__")
self.setop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*=b",
- "__imul__")
+ "__imul__")
self.unop_test(spamlist([1,2,3]), 3, "len(a)", "__len__")
self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "a*b",
- "__mul__")
+ "__mul__")
self.binop_test(spamlist([1,2]), 3, spamlist([1,2,1,2,1,2]), "b*a",
- "__rmul__")
+ "__rmul__")
self.set2op_test(spamlist([1,2]), 1, 3, spamlist([1,3]), "a[b]=c",
- "__setitem__")
- self.set3op_test(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]),
- spamlist([1,5,6,4]), "a[b:c]=d", "__setslice__")
+ "__setitem__")
+ self.setsliceop_test(spamlist([1,2,3,4]), 1, 3, spamlist([5,6]),
+ spamlist([1,5,6,4]), "a[b:c]=d", "__setitem__")
# Test subclassing
class C(spam.spamlist):
def foo(self): return 1
@@ -344,27 +336,25 @@ class OperatorsTest(unittest.TestCase):
a.setstate(42)
self.assertEqual(a.getstate(), 42)
- @test_support.impl_detail("the module 'xxsubtype' is internal")
+ @support.impl_detail("the module 'xxsubtype' is internal")
def test_spam_dicts(self):
# Testing spamdict operations...
import copy, xxsubtype as spam
def spamdict(d, memo=None):
import xxsubtype as spam
sd = spam.spamdict()
- for k, v in d.items():
+ for k, v in list(d.items()):
sd[k] = v
return sd
# This is an ugly hack:
copy._deepcopy_dispatch[spam.spamdict] = spamdict
- self.binop_test(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)",
- "__cmp__")
self.binop_test(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__")
self.binop_test(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__")
self.binop_test(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__")
d = spamdict({1:2,3:4})
l1 = []
- for i in d.keys():
+ for i in list(d.keys()):
l1.append(i)
l = []
for i in iter(d):
@@ -388,10 +378,10 @@ class OperatorsTest(unittest.TestCase):
class C(spam.spamdict):
def foo(self): return 1
a = C()
- self.assertEqual(a.items(), [])
+ self.assertEqual(list(a.items()), [])
self.assertEqual(a.foo(), 1)
a['foo'] = 'bar'
- self.assertEqual(a.items(), [('foo', 'bar')])
+ self.assertEqual(list(a.items()), [('foo', 'bar')])
self.assertEqual(a.getstate(), 0)
a.setstate(100)
self.assertEqual(a.getstate(), 100)
@@ -413,7 +403,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.assertEqual(len(a), 1)
self_local.state = a[0]
if kw:
- for k, v in kw.items():
+ for k, v in list(kw.items()):
self_local[v] = k
def __getitem__(self, key):
return self.get(key, 0)
@@ -454,9 +444,9 @@ class ClassPropertiesAndMethods(unittest.TestCase):
# Testing Python subclass of list...
class C(list):
def __getitem__(self, i):
+ if isinstance(i, slice):
+ return i.start, i.stop
return list.__getitem__(self, i) + 100
- def __getslice__(self, i, j):
- return (i, j)
a = C()
a.extend([0,1,2])
self.assertEqual(a[0], 100)
@@ -465,9 +455,8 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.assertEqual(a[100:200], (100,200))
def test_metaclass(self):
- # Testing __metaclass__...
- class C:
- __metaclass__ = type
+ # Testing metaclasses...
+ class C(metaclass=type):
def __init__(self):
self.__state = 0
def getstate(self):
@@ -478,9 +467,10 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.assertEqual(a.getstate(), 0)
a.setstate(10)
self.assertEqual(a.getstate(), 10)
- class D:
- class __metaclass__(type):
- def myself(cls): return cls
+ class _metaclass(type):
+ def myself(cls): return cls
+ class D(metaclass=_metaclass):
+ pass
self.assertEqual(D.myself(), D)
d = D()
self.assertEqual(d.__class__, D)
@@ -488,8 +478,8 @@ class ClassPropertiesAndMethods(unittest.TestCase):
def __new__(cls, name, bases, dict):
dict['__spam__'] = 1
return type.__new__(cls, name, bases, dict)
- class C:
- __metaclass__ = M1
+ class C(metaclass=M1):
+ pass
self.assertEqual(C.__spam__, 1)
c = C()
self.assertEqual(c.__spam__, 1)
@@ -512,8 +502,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
continue
setattr(it, key, self.dict[key].__get__(it, self))
return it
- class C:
- __metaclass__ = M2
+ class C(metaclass=M2):
def spam(self):
return 42
self.assertEqual(C.name, 'C')
@@ -539,8 +528,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
name = "__super"
setattr(cls, name, super(cls))
return cls
- class A:
- __metaclass__ = autosuper
+ class A(metaclass=autosuper):
def meth(self):
return "A"
class B(A):
@@ -563,7 +551,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
# named _get_x and/or _set_x are found
def __new__(metaclass, name, bases, dict):
hits = {}
- for key, val in dict.iteritems():
+ for key, val in dict.items():
if key.startswith("_get_"):
key = key[5:]
get, set = hits.get(key, (None, None))
@@ -574,12 +562,11 @@ class ClassPropertiesAndMethods(unittest.TestCase):
get, set = hits.get(key, (None, None))
set = val
hits[key] = get, set
- for key, (get, set) in hits.iteritems():
+ for key, (get, set) in hits.items():
dict[key] = property(get, set)
return super(autoproperty, metaclass).__new__(metaclass,
name, bases, dict)
- class A:
- __metaclass__ = autoproperty
+ class A(metaclass=autoproperty):
def _get_x(self):
return -self.__x
def _set_x(self, x):
@@ -593,8 +580,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
class multimetaclass(autoproperty, autosuper):
# Merge of multiple cooperating metaclasses
pass
- class A:
- __metaclass__ = multimetaclass
+ class A(metaclass=multimetaclass):
def _get_x(self):
return "A"
class B(A):
@@ -613,8 +599,8 @@ class ClassPropertiesAndMethods(unittest.TestCase):
counter = 0
def __init__(self, *args):
T.counter += 1
- class C:
- __metaclass__ = T
+ class C(metaclass=T):
+ pass
self.assertEqual(T.counter, 1)
a = C()
self.assertEqual(type(a), C)
@@ -635,12 +621,180 @@ class ClassPropertiesAndMethods(unittest.TestCase):
class B(object):
pass
- class C(object):
- __metaclass__ = A
+ class C(object, metaclass=A):
+ pass
# The most derived metaclass of D is A rather than type.
class D(B, C):
pass
+ self.assertIs(A, type(D))
+
+ # issue1294232: correct metaclass calculation
+ new_calls = [] # to check the order of __new__ calls
+ class AMeta(type):
+ @staticmethod
+ def __new__(mcls, name, bases, ns):
+ new_calls.append('AMeta')
+ return super().__new__(mcls, name, bases, ns)
+ @classmethod
+ def __prepare__(mcls, name, bases):
+ return {}
+
+ class BMeta(AMeta):
+ @staticmethod
+ def __new__(mcls, name, bases, ns):
+ new_calls.append('BMeta')
+ return super().__new__(mcls, name, bases, ns)
+ @classmethod
+ def __prepare__(mcls, name, bases):
+ ns = super().__prepare__(name, bases)
+ ns['BMeta_was_here'] = True
+ return ns
+
+ class A(metaclass=AMeta):
+ pass
+ self.assertEqual(['AMeta'], new_calls)
+ new_calls[:] = []
+
+ class B(metaclass=BMeta):
+ pass
+ # BMeta.__new__ calls AMeta.__new__ with super:
+ self.assertEqual(['BMeta', 'AMeta'], new_calls)
+ new_calls[:] = []
+
+ class C(A, B):
+ pass
+ # The most derived metaclass is BMeta:
+ self.assertEqual(['BMeta', 'AMeta'], new_calls)
+ new_calls[:] = []
+ # BMeta.__prepare__ should've been called:
+ self.assertIn('BMeta_was_here', C.__dict__)
+
+ # The order of the bases shouldn't matter:
+ class C2(B, A):
+ pass
+ self.assertEqual(['BMeta', 'AMeta'], new_calls)
+ new_calls[:] = []
+ self.assertIn('BMeta_was_here', C2.__dict__)
+
+ # Check correct metaclass calculation when a metaclass is declared:
+ class D(C, metaclass=type):
+ pass
+ self.assertEqual(['BMeta', 'AMeta'], new_calls)
+ new_calls[:] = []
+ self.assertIn('BMeta_was_here', D.__dict__)
+
+ class E(C, metaclass=AMeta):
+ pass
+ self.assertEqual(['BMeta', 'AMeta'], new_calls)
+ new_calls[:] = []
+ self.assertIn('BMeta_was_here', E.__dict__)
+
+ # Special case: the given metaclass isn't a class,
+ # so there is no metaclass calculation.
+ marker = object()
+ def func(*args, **kwargs):
+ return marker
+ class X(metaclass=func):
+ pass
+ class Y(object, metaclass=func):
+ pass
+ class Z(D, metaclass=func):
+ pass
+ self.assertIs(marker, X)
+ self.assertIs(marker, Y)
+ self.assertIs(marker, Z)
+
+ # The given metaclass is a class,
+ # but not a descendant of type.
+ prepare_calls = [] # to track __prepare__ calls
+ class ANotMeta:
+ def __new__(mcls, *args, **kwargs):
+ new_calls.append('ANotMeta')
+ return super().__new__(mcls)
+ @classmethod
+ def __prepare__(mcls, name, bases):
+ prepare_calls.append('ANotMeta')
+ return {}
+ class BNotMeta(ANotMeta):
+ def __new__(mcls, *args, **kwargs):
+ new_calls.append('BNotMeta')
+ return super().__new__(mcls)
+ @classmethod
+ def __prepare__(mcls, name, bases):
+ prepare_calls.append('BNotMeta')
+ return super().__prepare__(name, bases)
+
+ class A(metaclass=ANotMeta):
+ pass
+ self.assertIs(ANotMeta, type(A))
+ self.assertEqual(['ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+ self.assertEqual(['ANotMeta'], new_calls)
+ new_calls[:] = []
+
+ class B(metaclass=BNotMeta):
+ pass
+ self.assertIs(BNotMeta, type(B))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+
+ class C(A, B):
+ pass
+ self.assertIs(BNotMeta, type(C))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+
+ class C2(B, A):
+ pass
+ self.assertIs(BNotMeta, type(C2))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+
+ # This is a TypeError, because of a metaclass conflict:
+ # BNotMeta is neither a subclass, nor a superclass of type
+ with self.assertRaises(TypeError):
+ class D(C, metaclass=type):
+ pass
+
+ class E(C, metaclass=ANotMeta):
+ pass
+ self.assertIs(BNotMeta, type(E))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+
+ class F(object(), C):
+ pass
+ self.assertIs(BNotMeta, type(F))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+
+ class F2(C, object()):
+ pass
+ self.assertIs(BNotMeta, type(F2))
+ self.assertEqual(['BNotMeta', 'ANotMeta'], new_calls)
+ new_calls[:] = []
+ self.assertEqual(['BNotMeta', 'ANotMeta'], prepare_calls)
+ prepare_calls[:] = []
+
+ # TypeError: BNotMeta is neither a
+ # subclass, nor a superclass of int
+ with self.assertRaises(TypeError):
+ class X(C, int()):
+ pass
+ with self.assertRaises(TypeError):
+ class X(int(), C):
+ pass
def test_module_subclasses(self):
# Testing Python subclass of module...
@@ -676,7 +830,7 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.fail("inheriting from ModuleType and str at the same time "
"should fail")
- def test_multiple_inheritence(self):
+ def test_multiple_inheritance(self):
# Testing multiple inheritance...
class C(object):
def __init__(self):
@@ -694,9 +848,9 @@ class ClassPropertiesAndMethods(unittest.TestCase):
type({}).__init__(self)
C.__init__(self)
d = D()
- self.assertEqual(d.keys(), [])
+ self.assertEqual(list(d.keys()), [])
d["hello"] = "world"
- self.assertEqual(d.items(), [("hello", "world")])
+ self.assertEqual(list(d.items()), [("hello", "world")])
self.assertEqual(d["hello"], "world")
self.assertEqual(d.getstate(), 0)
d.setstate(10)
@@ -717,96 +871,6 @@ class ClassPropertiesAndMethods(unittest.TestCase):
self.assertEqual(Frag().__int__(), 42)
self.assertEqual(int(Frag()), 42)
- # MI mixing classic and new-style classes.
-
- class A:
- x = 1
-
- class B(A):
- pass
-
- class C(A):
- x = 2
-
- class D(B, C):
- pass
- self.assertEqual(D.x, 1)
-
- # Classic MRO is preserved for a classic base class.
- class E(D, object):
- pass
- self.assertEqual(E.__mro__, (E, D, B, A, C, object))
- self.assertEqual(E.x, 1)
-
- # But with a mix of classic bases, their MROs are combined using
- # new-style MRO.
- class F(B, C, object):
- pass
- self.assertEqual(F.__mro__, (F, B, C, A, object))
- self.assertEqual(F.x, 2)
-
- # Try something else.
- class C:
- def cmethod(self):
- return "C a"
- def all_method(self):
- return "C b"
-
- class M1(C, object):
- def m1method(self):
- return "M1 a"
- def all_method(self):
- return "M1 b"
-
- self.assertEqual(M1.__mro__, (M1, C, object))
- m = M1()
- self.assertEqual(m.cmethod(), "C a")
- self.assertEqual(m.m1method(), "M1 a")
- self.assertEqual(m.all_method(), "M1 b")
-
- class D(C):
- def dmethod(self):
- return "D a"
- def all_method(self):
- return "D b"
-
- class M2(D, object):
- def m2method(self):
- return "M2 a"
- def all_method(self):
- return "M2 b"
-
- self.assertEqual(M2.__mro__, (M2, D, C, object))
- m = M2()
- self.assertEqual(m.cmethod(), "C a")
- self.assertEqual(m.dmethod(), "D a")
- self.assertEqual(m.m2method(), "M2 a")
- self.assertEqual(m.all_method(), "M2 b")
-
- class M3(M1, M2, object):
- def m3method(self):
- return "M3 a"
- def all_method(self):
- return "M3 b"
- self.assertEqual(M3.__mro__, (M3, M1, M2, D, C, object))
- m = M3()
- self.assertEqual(m.cmethod(), "C a")
- self.assertEqual(m.dmethod(), "D a")
- self.assertEqual(m.m1method(), "M1 a")
- self.assertEqual(m.m2method(), "M2 a")
- self.assertEqual(m.m3method(), "M3 a")
- self.assertEqual(m.all_method(), "M3 b")
-
- class Classic:
- pass
- try:
- class New(Classic):
- __metaclass__ = type
- except TypeError:
- pass
- else:
- self.fail("new class with only classic bases - shouldn't be")
-
def test_diamond_inheritence(self):
# Testing multiple inheritance special cases...
class A(object):
@@ -898,9 +962,9 @@ order (MRO) for bases """
def raises(exc, expected, callable, *args):
try:
callable(*args)
- except exc, msg:
+ except exc as msg:
# the exact msg is generally considered an impl detail
- if test_support.check_impl_detail():
+ if support.check_impl_detail():
if not str(msg).startswith(expected):
self.fail("Message %r, expected %r" %
(str(msg), expected))
@@ -1052,34 +1116,29 @@ order (MRO) for bases """
self.assertEqual(c.abc, 5)
# Test unicode slot names
+ # Test a single unicode string is not expanded as a sequence.
+ class C(object):
+ __slots__ = "abc"
+ c = C()
+ c.abc = 5
+ self.assertEqual(c.abc, 5)
+
+ # _unicode_to_string used to modify slots in certain circumstances
+ slots = ("foo", "bar")
+ class C(object):
+ __slots__ = slots
+ x = C()
+ x.foo = 5
+ self.assertEqual(x.foo, 5)
+ self.assertTrue(type(slots[0]) is str)
+ # this used to leak references
try:
- unicode
- except NameError:
+ class C(object):
+ __slots__ = [chr(128)]
+ except (TypeError, UnicodeEncodeError):
pass
else:
- # Test a single unicode string is not expanded as a sequence.
- class C(object):
- __slots__ = unicode("abc")
- c = C()
- c.abc = 5
- self.assertEqual(c.abc, 5)
-
- # _unicode_to_string used to modify slots in certain circumstances
- slots = (unicode("foo"), unicode("bar"))
- class C(object):
- __slots__ = slots
- x = C()
- x.foo = 5
- self.assertEqual(x.foo, 5)
- self.assertEqual(type(slots[0]), unicode)
- # this used to leak references
- try:
- class C(object):
- __slots__ = [unichr(128)]
- except (TypeError, UnicodeEncodeError):
- pass
- else:
- self.fail("[unichr(128)] slots not caught")
+ raise TestFailed("[chr(128)] slots not caught")
# Test leaks
class Counted(object):
@@ -1096,7 +1155,7 @@ order (MRO) for bases """
x.c = Counted()
self.assertEqual(Counted.counter, 3)
del x
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(Counted.counter, 0)
class D(C):
pass
@@ -1105,7 +1164,7 @@ order (MRO) for bases """
x.z = Counted()
self.assertEqual(Counted.counter, 2)
del x
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(Counted.counter, 0)
class E(D):
__slots__ = ['e']
@@ -1115,7 +1174,7 @@ order (MRO) for bases """
x.e = Counted()
self.assertEqual(Counted.counter, 3)
del x
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(Counted.counter, 0)
# Test cyclical leaks [SF bug 519621]
@@ -1125,18 +1184,17 @@ order (MRO) for bases """
s.a = [Counted(), s]
self.assertEqual(Counted.counter, 1)
s = None
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(Counted.counter, 0)
# Test lookup leaks [SF bug 572567]
if hasattr(gc, 'get_objects'):
class G(object):
- def __cmp__(self, other):
- return 0
- __hash__ = None # Silence Py3k warning
+ def __eq__(self, other):
+ return False
g = G()
orig_objects = len(gc.get_objects())
- for i in xrange(10):
+ for i in range(10):
g==g
new_objects = len(gc.get_objects())
self.assertEqual(orig_objects, new_objects)
@@ -1149,7 +1207,7 @@ order (MRO) for bases """
def __del__(self_):
self.assertEqual(self_.a, 1)
self.assertEqual(self_.b, 2)
- with test_support.captured_output('stderr') as s:
+ with support.captured_output('stderr') as s:
h = H()
del h
self.assertEqual(s.getvalue(), '')
@@ -1201,8 +1259,7 @@ order (MRO) for bases """
# Issue2115: slot descriptors did not correctly check
# the type of the given object
import abc
- class MyABC:
- __metaclass__ = abc.ABCMeta
+ class MyABC(metaclass=abc.ABCMeta):
__slots__ = "a"
class Unrelated(object):
@@ -1215,15 +1272,6 @@ order (MRO) for bases """
# This used to crash
self.assertRaises(TypeError, MyABC.a.__set__, u, 3)
- def test_metaclass_cmp(self):
- # See bug 7491.
- class M(type):
- def __cmp__(self, other):
- return -1
- class X(object):
- __metaclass__ = M
- self.assertTrue(X < M)
-
def test_dynamics(self):
# Testing class attribute propagation...
class D(object):
@@ -1287,20 +1335,11 @@ order (MRO) for bases """
self.assertEqual(I(3)*2, 6)
self.assertEqual(I(3)*I(2), 6)
- # Test handling of long*seq and seq*long
- class L(long):
- pass
- self.assertEqual("a"*L(2L), "aa")
- self.assertEqual(L(2L)*"a", "aa")
- self.assertEqual(2*L(3), 6)
- self.assertEqual(L(3)*2, 6)
- self.assertEqual(L(3)*L(2), 6)
-
# Test comparison of classes with dynamic metaclasses
class dynamicmetaclass(type):
pass
- class someclass:
- __metaclass__ = dynamicmetaclass
+ class someclass(metaclass=dynamicmetaclass):
+ pass
self.assertNotEqual(someclass, object)
def test_errors(self):
@@ -1351,10 +1390,10 @@ order (MRO) for bases """
pass
class M2(type):
pass
- class A1(object):
- __metaclass__ = M1
- class A2(object):
- __metaclass__ = M2
+ class A1(object, metaclass=M1):
+ pass
+ class A2(object, metaclass=M2):
+ pass
try:
class B(A1, A2):
pass
@@ -1386,10 +1425,10 @@ order (MRO) for bases """
self.assertEqual(ff.__get__(0)(42), (int, 42))
# Test super() with classmethods (SF bug 535444)
- self.assertEqual(C.goo.im_self, C)
- self.assertEqual(D.goo.im_self, D)
- self.assertEqual(super(D,D).goo.im_self, D)
- self.assertEqual(super(D,d).goo.im_self, D)
+ self.assertEqual(C.goo.__self__, C)
+ self.assertEqual(D.goo.__self__, D)
+ self.assertEqual(super(D,D).goo.__self__, D)
+ self.assertEqual(super(D,d).goo.__self__, D)
self.assertEqual(super(D,D).goo(), (D,))
self.assertEqual(super(D,d).goo(), (D,))
@@ -1405,7 +1444,7 @@ order (MRO) for bases """
else:
self.fail("classmethod shouldn't accept keyword args")
- @test_support.impl_detail("the module 'xxsubtype' is internal")
+ @support.impl_detail("the module 'xxsubtype' is internal")
def test_classmethods_in_c(self):
# Testing C-based class methods...
import xxsubtype as spam
@@ -1453,7 +1492,7 @@ order (MRO) for bases """
self.assertEqual(d.foo(1), (d, 1))
self.assertEqual(D.foo(d, 1), (d, 1))
- @test_support.impl_detail("the module 'xxsubtype' is internal")
+ @support.impl_detail("the module 'xxsubtype' is internal")
def test_staticmethods_in_c(self):
# Testing C-based static methods...
import xxsubtype as spam
@@ -1486,7 +1525,7 @@ order (MRO) for bases """
self.assertEqual(D.foo(d, 1), (d, 1))
class E: # *not* subclassing from C
foo = C.foo
- self.assertEqual(E().foo, C.foo) # i.e., unbound
+ self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
self.assertTrue(repr(C.foo.__get__(C())).startswith("<bound method "))
def test_compattr(self):
@@ -1560,16 +1599,17 @@ order (MRO) for bases """
L = type.mro(cls)
L.reverse()
return L
- class X(D,B,C,A):
- __metaclass__ = PerverseMetaType
+ class X(D,B,C,A, metaclass=PerverseMetaType):
+ pass
self.assertEqual(X.__mro__, (object, A, C, B, D, X))
self.assertEqual(X().f(), "A")
try:
- class X(object):
- class __metaclass__(type):
- def mro(self):
- return [self, dict, object]
+ class _metaclass(type):
+ def mro(self):
+ return [self, dict, object]
+ class X(object, metaclass=_metaclass):
+ pass
# In CPython, the class creation above already raises
# TypeError, as a protection against the fact that
# instances of X would segfault it. In other Python
@@ -1584,20 +1624,22 @@ order (MRO) for bases """
self.fail("devious mro() return not caught")
try:
- class X(object):
- class __metaclass__(type):
- def mro(self):
- return [1]
+ class _metaclass(type):
+ def mro(self):
+ return [1]
+ class X(object, metaclass=_metaclass):
+ pass
except TypeError:
pass
else:
self.fail("non-class mro() return not caught")
try:
- class X(object):
- class __metaclass__(type):
- def mro(self):
- return 1
+ class _metaclass(type):
+ def mro(self):
+ return 1
+ class X(object, metaclass=_metaclass):
+ pass
except TypeError:
pass
else:
@@ -1633,13 +1675,6 @@ order (MRO) for bases """
def __delitem__(self, key):
self.delitem = key
- def __getslice__(self, i, j):
- return ("getslice", i, j)
- def __setslice__(self, i, j, value):
- self.setslice = (i, j, value)
- def __delslice__(self, i, j):
- self.delslice = (i, j)
-
a = C()
self.assertEqual(a.foo, ("getattr", "foo"))
a.foo = 12
@@ -1653,11 +1688,11 @@ order (MRO) for bases """
del a[12]
self.assertEqual(a.delitem, 12)
- self.assertEqual(a[0:10], ("getslice", 0, 10))
+ self.assertEqual(a[0:10], ("getitem", slice(0, 10)))
a[0:10] = "foo"
- self.assertEqual(a.setslice, (0, 10, "foo"))
+ self.assertEqual(a.setitem, (slice(0, 10), "foo"))
del a[0:10]
- self.assertEqual(a.delslice, (0, 10))
+ self.assertEqual(a.delitem, (slice(0, 10)))
def test_methods(self):
# Testing methods...
@@ -1677,7 +1712,7 @@ order (MRO) for bases """
self.assertEqual(d2.goo(), 1)
class E(object):
foo = C.foo
- self.assertEqual(E().foo, C.foo) # i.e., unbound
+ self.assertEqual(E().foo.__func__, C.foo) # i.e., unbound
self.assertTrue(repr(C.foo.__get__(C(1))).startswith("<bound method "))
def test_special_method_lookup(self):
@@ -1690,7 +1725,7 @@ order (MRO) for bases """
def iden(self):
return self
def hello(self):
- return "hello"
+ return b"hello"
def empty_seq(self):
return []
def zero(self):
@@ -1705,8 +1740,6 @@ order (MRO) for bases """
return isinstance(int, obj)
def do_issubclass(obj):
return issubclass(int, obj)
- def swallow(*args):
- pass
def do_dict_missing(checker):
class DictSub(checker.__class__, dict):
pass
@@ -1714,6 +1747,7 @@ order (MRO) for bases """
def some_number(self_, key):
self.assertEqual(key, "hi")
return 4
+ def swallow(*args): pass
def format_impl(self, spec):
return "hello"
@@ -1721,10 +1755,10 @@ order (MRO) for bases """
# only listing the ones I can remember outside of typeobject.c, since it
# does it right.
specials = [
- ("__unicode__", unicode, hello, set(), {}),
+ ("__bytes__", bytes, hello, set(), {}),
("__reversed__", reversed, empty_seq, set(), {}),
("__length_hint__", list, zero, set(),
- {"__iter__" : iden, "next" : stop}),
+ {"__iter__" : iden, "__next__" : stop}),
("__sizeof__", sys.getsizeof, zero, set(), {}),
("__instancecheck__", do_isinstance, return_true, set(), {}),
("__missing__", do_dict_missing, some_number,
@@ -1735,6 +1769,9 @@ order (MRO) for bases """
("__exit__", run_context, swallow, set(), {"__enter__" : iden}),
("__complex__", complex, complex_num, set(), {}),
("__format__", format, format_impl, set(), {}),
+ ("__floor__", math.floor, zero, set(), {}),
+ ("__trunc__", math.trunc, zero, set(), {}),
+ ("__ceil__", math.ceil, zero, set(), {}),
("__dir__", dir, empty_seq, set(), {}),
]
@@ -1760,7 +1797,7 @@ order (MRO) for bases """
for name, runner, meth_impl, ok, env in specials:
class X(Checker):
pass
- for attr, obj in env.iteritems():
+ for attr, obj in env.items():
setattr(X, attr, obj)
setattr(X, name, meth_impl)
runner(X())
@@ -1768,7 +1805,7 @@ order (MRO) for bases """
record = []
class X(Checker):
pass
- for attr, obj in env.iteritems():
+ for attr, obj in env.items():
setattr(X, attr, obj)
setattr(X, name, SpecialDescr(meth_impl))
runner(X())
@@ -1776,7 +1813,7 @@ order (MRO) for bases """
class X(Checker):
pass
- for attr, obj in env.iteritems():
+ for attr, obj in env.items():
setattr(X, attr, obj)
setattr(X, name, ErrDescr())
try:
@@ -1801,7 +1838,6 @@ order (MRO) for bases """
self.assertNotEqual(id(c1), id(c2))
hash(c1)
hash(c2)
- self.assertEqual(cmp(c1, c2), cmp(id(c1), id(c2)))
self.assertEqual(c1, c1)
self.assertTrue(c1 != c2)
self.assertTrue(not c1 != c1)
@@ -1825,7 +1861,6 @@ order (MRO) for bases """
self.assertNotEqual(id(d1), id(d2))
hash(d1)
hash(d2)
- self.assertEqual(cmp(d1, d2), cmp(id(d1), id(d2)))
self.assertEqual(d1, d1)
self.assertNotEqual(d1, d2)
self.assertTrue(not d1 != d1)
@@ -1838,11 +1873,11 @@ order (MRO) for bases """
for i in range(10):
self.assertIn(i, d1)
self.assertNotIn(10, d1)
- # Test overridden behavior for static classes
+ # Test overridden behavior
class Proxy(object):
def __init__(self, x):
self.x = x
- def __nonzero__(self):
+ def __bool__(self):
return not not self.x
def __hash__(self):
return hash(self.x)
@@ -1850,8 +1885,14 @@ order (MRO) for bases """
return self.x == other
def __ne__(self, other):
return self.x != other
- def __cmp__(self, other):
- return cmp(self.x, other.x)
+ def __ge__(self, other):
+ return self.x >= other
+ def __gt__(self, other):
+ return self.x > other
+ def __le__(self, other):
+ return self.x <= other
+ def __lt__(self, other):
+ return self.x < other
def __str__(self):
return "Proxy:%s" % self.x
def __repr__(self):
@@ -1868,9 +1909,10 @@ order (MRO) for bases """
self.assertNotEqual(p0, p1)
self.assertTrue(not p0 != p0)
self.assertEqual(not p0, p1)
- self.assertEqual(cmp(p0, p1), -1)
- self.assertEqual(cmp(p0, p0), 0)
- self.assertEqual(cmp(p0, p_1), 1)
+ self.assertTrue(p0 < p1)
+ self.assertTrue(p0 <= p1)
+ self.assertTrue(p1 > p0)
+ self.assertTrue(p1 >= p0)
self.assertEqual(str(p0), "Proxy:0")
self.assertEqual(repr(p0), "Proxy(0)")
p10 = Proxy(range(10))
@@ -1878,104 +1920,6 @@ order (MRO) for bases """
for i in range(10):
self.assertIn(i, p10)
self.assertNotIn(10, p10)
- # Test overridden behavior for dynamic classes
- class DProxy(object):
- def __init__(self, x):
- self.x = x
- def __nonzero__(self):
- return not not self.x
- def __hash__(self):
- return hash(self.x)
- def __eq__(self, other):
- return self.x == other
- def __ne__(self, other):
- return self.x != other
- def __cmp__(self, other):
- return cmp(self.x, other.x)
- def __str__(self):
- return "DProxy:%s" % self.x
- def __repr__(self):
- return "DProxy(%r)" % self.x
- def __contains__(self, value):
- return value in self.x
- p0 = DProxy(0)
- p1 = DProxy(1)
- p_1 = DProxy(-1)
- self.assertFalse(p0)
- self.assertTrue(not not p1)
- self.assertEqual(hash(p0), hash(0))
- self.assertEqual(p0, p0)
- self.assertNotEqual(p0, p1)
- self.assertNotEqual(not p0, p0)
- self.assertEqual(not p0, p1)
- self.assertEqual(cmp(p0, p1), -1)
- self.assertEqual(cmp(p0, p0), 0)
- self.assertEqual(cmp(p0, p_1), 1)
- self.assertEqual(str(p0), "DProxy:0")
- self.assertEqual(repr(p0), "DProxy(0)")
- p10 = DProxy(range(10))
- self.assertNotIn(-1, p10)
- for i in range(10):
- self.assertIn(i, p10)
- self.assertNotIn(10, p10)
-
- # Safety test for __cmp__
- def unsafecmp(a, b):
- if not hasattr(a, '__cmp__'):
- return # some types don't have a __cmp__ any more (so the
- # test doesn't make sense any more), or maybe they
- # never had a __cmp__ at all, e.g. in PyPy
- try:
- a.__class__.__cmp__(a, b)
- except TypeError:
- pass
- else:
- self.fail("shouldn't allow %s.__cmp__(%r, %r)" % (
- a.__class__, a, b))
-
- unsafecmp(u"123", "123")
- unsafecmp("123", u"123")
- unsafecmp(1, 1.0)
- unsafecmp(1.0, 1)
- unsafecmp(1, 1L)
- unsafecmp(1L, 1)
-
- @test_support.impl_detail("custom logic for printing to real file objects")
- def test_recursions_1(self):
- # Testing recursion checks ...
- class Letter(str):
- def __new__(cls, letter):
- if letter == 'EPS':
- return str.__new__(cls)
- return str.__new__(cls, letter)
- def __str__(self):
- if not self:
- return 'EPS'
- return self
- # sys.stdout needs to be the original to trigger the recursion bug
- test_stdout = sys.stdout
- sys.stdout = test_support.get_original_stdout()
- try:
- # nothing should actually be printed, this should raise an exception
- print Letter('w')
- except RuntimeError:
- pass
- else:
- self.fail("expected a RuntimeError for print recursion")
- finally:
- sys.stdout = test_stdout
-
- def test_recursions_2(self):
- # Bug #1202533.
- class A(object):
- pass
- A.__mul__ = types.MethodType(lambda self, x: self * x, None, A)
- try:
- A()*2
- except RuntimeError:
- pass
- else:
- self.fail("expected a RuntimeError")
def test_weakrefs(self):
# Testing weak references...
@@ -1986,7 +1930,7 @@ order (MRO) for bases """
r = weakref.ref(c)
self.assertEqual(r(), c)
del c
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(r(), None)
del r
class NoWeak(object):
@@ -1994,7 +1938,7 @@ order (MRO) for bases """
no = NoWeak()
try:
weakref.ref(no)
- except TypeError, msg:
+ except TypeError as msg:
self.assertTrue(str(msg).find("weak reference") >= 0)
else:
self.fail("weakref.ref(no) should be illegal")
@@ -2004,7 +1948,7 @@ order (MRO) for bases """
r = weakref.ref(yes)
self.assertEqual(r(), yes)
del yes
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(r(), None)
del r
@@ -2048,13 +1992,13 @@ order (MRO) for bases """
for attr in "__doc__", "fget", "fset", "fdel":
try:
setattr(raw, attr, 42)
- except TypeError, msg:
+ except AttributeError as msg:
if str(msg).find('readonly') < 0:
self.fail("when setting readonly attr %r on a property, "
- "got unexpected TypeError msg %r" % (attr, str(msg)))
+ "got unexpected AttributeError msg %r" % (attr, str(msg)))
else:
- self.fail("expected TypeError from trying to set readonly %r "
- "attr on a property" % attr)
+ self.fail("expected AttributeError from trying to set readonly %r "
+ "attr on a property" % attr)
class D(object):
__getitem__ = property(lambda s: 1/0)
@@ -2168,8 +2112,8 @@ order (MRO) for bases """
self.assertEqual(d, {})
d = dict({1: 2, 'a': 'b'})
self.assertEqual(d, {1: 2, 'a': 'b'})
- self.assertEqual(d, dict(d.items()))
- self.assertEqual(d, dict(d.iteritems()))
+ self.assertEqual(d, dict(list(d.items())))
+ self.assertEqual(d, dict(iter(d.items())))
d = dict({'one':1, 'two':2})
self.assertEqual(d, dict(one=1, two=2))
self.assertEqual(d, dict(**d))
@@ -2178,7 +2122,7 @@ order (MRO) for bases """
self.assertEqual(d, dict([("one", 100), ("two", 200)], **d))
self.assertEqual(d, dict(**d))
- for badarg in 0, 0L, 0j, "0", [0], (0,):
+ for badarg in 0, 0, 0j, "0", [0], (0,):
try:
dict(badarg)
except TypeError:
@@ -2212,7 +2156,7 @@ order (MRO) for bases """
else:
self.fail("no TypeError from dict(incomplete mapping)")
- Mapping.keys = lambda self: self.dict.keys()
+ Mapping.keys = lambda self: list(self.dict.keys())
Mapping.__getitem__ = lambda self, i: self.dict[i]
d = dict(Mapping())
self.assertEqual(d, Mapping.dict)
@@ -2250,41 +2194,10 @@ order (MRO) for bases """
del junk
# Just make sure these don't blow up!
- for arg in 2, 2L, 2j, 2e0, [2], "2", u"2", (2,), {2:2}, type, self.test_dir:
+ for arg in 2, 2, 2j, 2e0, [2], "2", b"2", (2,), {2:2}, type, self.test_dir:
dir(arg)
- # Try classic classes.
- class C:
- Cdata = 1
- def Cmethod(self): pass
-
- cstuff = ['Cdata', 'Cmethod', '__doc__', '__module__']
- self.assertEqual(dir(C), cstuff)
- self.assertIn('im_self', dir(C.Cmethod))
-
- c = C() # c.__doc__ is an odd thing to see here; ditto c.__module__.
- self.assertEqual(dir(c), cstuff)
-
- c.cdata = 2
- c.cmethod = lambda self: 0
- self.assertEqual(dir(c), cstuff + ['cdata', 'cmethod'])
- self.assertIn('im_self', dir(c.Cmethod))
-
- class A(C):
- Adata = 1
- def Amethod(self): pass
-
- astuff = ['Adata', 'Amethod'] + cstuff
- self.assertEqual(dir(A), astuff)
- self.assertIn('im_self', dir(A.Amethod))
- a = A()
- self.assertEqual(dir(a), astuff)
- self.assertIn('im_self', dir(a.Amethod))
- a.adata = 42
- a.amethod = lambda self: 3
- self.assertEqual(dir(a), astuff + ['adata', 'amethod'])
-
- # The same, but with new-style classes. Since these have object as a
+ # Test dir on new-style classes. Since these have object as a
# base class, a lot more gets sucked in.
def interesting(strings):
return [s for s in strings if not s.startswith('_')]
@@ -2298,12 +2211,12 @@ order (MRO) for bases """
c = C()
self.assertEqual(interesting(dir(c)), cstuff)
- self.assertIn('im_self', dir(C.Cmethod))
+ ## self.assertIn('__self__', dir(C.Cmethod))
c.cdata = 2
c.cmethod = lambda self: 0
self.assertEqual(interesting(dir(c)), cstuff + ['cdata', 'cmethod'])
- self.assertIn('im_self', dir(c.Cmethod))
+ ## self.assertIn('__self__', dir(c.Cmethod))
class A(C):
Adata = 1
@@ -2311,13 +2224,13 @@ order (MRO) for bases """
astuff = ['Adata', 'Amethod'] + cstuff
self.assertEqual(interesting(dir(A)), astuff)
- self.assertIn('im_self', dir(A.Amethod))
+ ## self.assertIn('__self__', dir(A.Amethod))
a = A()
self.assertEqual(interesting(dir(a)), astuff)
a.adata = 42
a.amethod = lambda self: 3
self.assertEqual(interesting(dir(a)), astuff + ['adata', 'amethod'])
- self.assertIn('im_self', dir(a.Amethod))
+ ## self.assertIn('__self__', dir(a.Amethod))
# Try a module subclass.
class M(type(sys)):
@@ -2345,7 +2258,7 @@ order (MRO) for bases """
# Two essentially featureless objects, just inheriting stuff from
# object.
self.assertEqual(dir(NotImplemented), dir(Ellipsis))
- if test_support.check_impl_detail():
+ if support.check_impl_detail():
# None differs in PyPy: it has a __nonzero__
self.assertEqual(dir(None), dir(Ellipsis))
@@ -2508,54 +2421,51 @@ order (MRO) for bases """
self.assertTrue((hexint(0) << 12).__class__ is int)
self.assertTrue((hexint(0) >> 12).__class__ is int)
- class octlong(long):
+ class octlong(int):
__slots__ = []
def __str__(self):
- s = oct(self)
- if s[-1] == 'L':
- s = s[:-1]
- return s
+ return oct(self)
def __add__(self, other):
return self.__class__(super(octlong, self).__add__(other))
__radd__ = __add__
- self.assertEqual(str(octlong(3) + 5), "010")
+ self.assertEqual(str(octlong(3) + 5), "0o10")
# (Note that overriding __radd__ here only seems to work
# because the example uses a short int left argument.)
- self.assertEqual(str(5 + octlong(3000)), "05675")
+ self.assertEqual(str(5 + octlong(3000)), "0o5675")
a = octlong(12345)
- self.assertEqual(a, 12345L)
- self.assertEqual(long(a), 12345L)
- self.assertEqual(hash(a), hash(12345L))
- self.assertTrue(long(a).__class__ is long)
- self.assertTrue((+a).__class__ is long)
- self.assertTrue((-a).__class__ is long)
- self.assertTrue((-octlong(0)).__class__ is long)
- self.assertTrue((a >> 0).__class__ is long)
- self.assertTrue((a << 0).__class__ is long)
- self.assertTrue((a - 0).__class__ is long)
- self.assertTrue((a * 1).__class__ is long)
- self.assertTrue((a ** 1).__class__ is long)
- self.assertTrue((a // 1).__class__ is long)
- self.assertTrue((1 * a).__class__ is long)
- self.assertTrue((a | 0).__class__ is long)
- self.assertTrue((a ^ 0).__class__ is long)
- self.assertTrue((a & -1L).__class__ is long)
- self.assertTrue((octlong(0) << 12).__class__ is long)
- self.assertTrue((octlong(0) >> 12).__class__ is long)
- self.assertTrue(abs(octlong(0)).__class__ is long)
+ self.assertEqual(a, 12345)
+ self.assertEqual(int(a), 12345)
+ self.assertEqual(hash(a), hash(12345))
+ self.assertTrue(int(a).__class__ is int)
+ self.assertTrue((+a).__class__ is int)
+ self.assertTrue((-a).__class__ is int)
+ self.assertTrue((-octlong(0)).__class__ is int)
+ self.assertTrue((a >> 0).__class__ is int)
+ self.assertTrue((a << 0).__class__ is int)
+ self.assertTrue((a - 0).__class__ is int)
+ self.assertTrue((a * 1).__class__ is int)
+ self.assertTrue((a ** 1).__class__ is int)
+ self.assertTrue((a // 1).__class__ is int)
+ self.assertTrue((1 * a).__class__ is int)
+ self.assertTrue((a | 0).__class__ is int)
+ self.assertTrue((a ^ 0).__class__ is int)
+ self.assertTrue((a & -1).__class__ is int)
+ self.assertTrue((octlong(0) << 12).__class__ is int)
+ self.assertTrue((octlong(0) >> 12).__class__ is int)
+ self.assertTrue(abs(octlong(0)).__class__ is int)
# Because octlong overrides __add__, we can't check the absence of +0
# optimizations using octlong.
- class longclone(long):
+ class longclone(int):
pass
a = longclone(1)
- self.assertTrue((a + 0).__class__ is long)
- self.assertTrue((0 + a).__class__ is long)
+ self.assertTrue((a + 0).__class__ is int)
+ self.assertTrue((0 + a).__class__ is int)
# Check that negative clones don't segfault
a = longclone(-1)
self.assertEqual(a.__dict__, {})
- self.assertEqual(long(a), -1) # self.assertTrue PyNumber_Long() copies the sign bit
+ self.assertEqual(int(a), -1) # self.assertTrue PyNumber_Long() copies the sign bit
class precfloat(float):
__slots__ = ['prec']
@@ -2682,12 +2592,9 @@ order (MRO) for bases """
self.assertEqual(s.lstrip(), base)
self.assertTrue(s.rstrip().__class__ is str)
self.assertEqual(s.rstrip(), base)
- identitytab = ''.join([chr(i) for i in range(256)])
+ identitytab = {}
self.assertTrue(s.translate(identitytab).__class__ is str)
self.assertEqual(s.translate(identitytab), base)
- self.assertTrue(s.translate(identitytab, "x").__class__ is str)
- self.assertEqual(s.translate(identitytab, "x"), base)
- self.assertEqual(s.translate(identitytab, "\x00"), "")
self.assertTrue(s.replace("x", "x").__class__ is str)
self.assertEqual(s.replace("x", "x"), base)
self.assertTrue(s.ljust(len(s)).__class__ is str)
@@ -2699,144 +2606,144 @@ order (MRO) for bases """
self.assertTrue(s.lower().__class__ is str)
self.assertEqual(s.lower(), base)
- class madunicode(unicode):
+ class madunicode(str):
_rev = None
def rev(self):
if self._rev is not None:
return self._rev
L = list(self)
L.reverse()
- self._rev = self.__class__(u"".join(L))
+ self._rev = self.__class__("".join(L))
return self._rev
u = madunicode("ABCDEF")
- self.assertEqual(u, u"ABCDEF")
- self.assertEqual(u.rev(), madunicode(u"FEDCBA"))
- self.assertEqual(u.rev().rev(), madunicode(u"ABCDEF"))
- base = u"12345"
+ self.assertEqual(u, "ABCDEF")
+ self.assertEqual(u.rev(), madunicode("FEDCBA"))
+ self.assertEqual(u.rev().rev(), madunicode("ABCDEF"))
+ base = "12345"
u = madunicode(base)
- self.assertEqual(unicode(u), base)
- self.assertTrue(unicode(u).__class__ is unicode)
+ self.assertEqual(str(u), base)
+ self.assertTrue(str(u).__class__ is str)
self.assertEqual(hash(u), hash(base))
self.assertEqual({u: 1}[base], 1)
self.assertEqual({base: 1}[u], 1)
- self.assertTrue(u.strip().__class__ is unicode)
+ self.assertTrue(u.strip().__class__ is str)
self.assertEqual(u.strip(), base)
- self.assertTrue(u.lstrip().__class__ is unicode)
+ self.assertTrue(u.lstrip().__class__ is str)
self.assertEqual(u.lstrip(), base)
- self.assertTrue(u.rstrip().__class__ is unicode)
+ self.assertTrue(u.rstrip().__class__ is str)
self.assertEqual(u.rstrip(), base)
- self.assertTrue(u.replace(u"x", u"x").__class__ is unicode)
- self.assertEqual(u.replace(u"x", u"x"), base)
- self.assertTrue(u.replace(u"xy", u"xy").__class__ is unicode)
- self.assertEqual(u.replace(u"xy", u"xy"), base)
- self.assertTrue(u.center(len(u)).__class__ is unicode)
+ self.assertTrue(u.replace("x", "x").__class__ is str)
+ self.assertEqual(u.replace("x", "x"), base)
+ self.assertTrue(u.replace("xy", "xy").__class__ is str)
+ self.assertEqual(u.replace("xy", "xy"), base)
+ self.assertTrue(u.center(len(u)).__class__ is str)
self.assertEqual(u.center(len(u)), base)
- self.assertTrue(u.ljust(len(u)).__class__ is unicode)
+ self.assertTrue(u.ljust(len(u)).__class__ is str)
self.assertEqual(u.ljust(len(u)), base)
- self.assertTrue(u.rjust(len(u)).__class__ is unicode)
+ self.assertTrue(u.rjust(len(u)).__class__ is str)
self.assertEqual(u.rjust(len(u)), base)
- self.assertTrue(u.lower().__class__ is unicode)
+ self.assertTrue(u.lower().__class__ is str)
self.assertEqual(u.lower(), base)
- self.assertTrue(u.upper().__class__ is unicode)
+ self.assertTrue(u.upper().__class__ is str)
self.assertEqual(u.upper(), base)
- self.assertTrue(u.capitalize().__class__ is unicode)
+ self.assertTrue(u.capitalize().__class__ is str)
self.assertEqual(u.capitalize(), base)
- self.assertTrue(u.title().__class__ is unicode)
+ self.assertTrue(u.title().__class__ is str)
self.assertEqual(u.title(), base)
- self.assertTrue((u + u"").__class__ is unicode)
- self.assertEqual(u + u"", base)
- self.assertTrue((u"" + u).__class__ is unicode)
- self.assertEqual(u"" + u, base)
- self.assertTrue((u * 0).__class__ is unicode)
- self.assertEqual(u * 0, u"")
- self.assertTrue((u * 1).__class__ is unicode)
+ self.assertTrue((u + "").__class__ is str)
+ self.assertEqual(u + "", base)
+ self.assertTrue(("" + u).__class__ is str)
+ self.assertEqual("" + u, base)
+ self.assertTrue((u * 0).__class__ is str)
+ self.assertEqual(u * 0, "")
+ self.assertTrue((u * 1).__class__ is str)
self.assertEqual(u * 1, base)
- self.assertTrue((u * 2).__class__ is unicode)
+ self.assertTrue((u * 2).__class__ is str)
self.assertEqual(u * 2, base + base)
- self.assertTrue(u[:].__class__ is unicode)
+ self.assertTrue(u[:].__class__ is str)
self.assertEqual(u[:], base)
- self.assertTrue(u[0:0].__class__ is unicode)
- self.assertEqual(u[0:0], u"")
+ self.assertTrue(u[0:0].__class__ is str)
+ self.assertEqual(u[0:0], "")
class sublist(list):
pass
a = sublist(range(5))
- self.assertEqual(a, range(5))
+ self.assertEqual(a, list(range(5)))
a.append("hello")
- self.assertEqual(a, range(5) + ["hello"])
+ self.assertEqual(a, list(range(5)) + ["hello"])
a[5] = 5
- self.assertEqual(a, range(6))
+ self.assertEqual(a, list(range(6)))
a.extend(range(6, 20))
- self.assertEqual(a, range(20))
+ self.assertEqual(a, list(range(20)))
a[-5:] = []
- self.assertEqual(a, range(15))
+ self.assertEqual(a, list(range(15)))
del a[10:15]
self.assertEqual(len(a), 10)
- self.assertEqual(a, range(10))
- self.assertEqual(list(a), range(10))
+ self.assertEqual(a, list(range(10)))
+ self.assertEqual(list(a), list(range(10)))
self.assertEqual(a[0], 0)
self.assertEqual(a[9], 9)
self.assertEqual(a[-10], 0)
self.assertEqual(a[-1], 9)
- self.assertEqual(a[:5], range(5))
-
- class CountedInput(file):
- """Counts lines read by self.readline().
-
- self.lineno is the 0-based ordinal of the last line read, up to
- a maximum of one greater than the number of lines in the file.
-
- self.ateof is true if and only if the final "" line has been read,
- at which point self.lineno stops incrementing, and further calls
- to readline() continue to return "".
- """
-
- lineno = 0
- ateof = 0
- def readline(self):
- if self.ateof:
- return ""
- s = file.readline(self)
- # Next line works too.
- # s = super(CountedInput, self).readline()
- self.lineno += 1
- if s == "":
- self.ateof = 1
- return s
-
- f = file(name=test_support.TESTFN, mode='w')
- lines = ['a\n', 'b\n', 'c\n']
- try:
- f.writelines(lines)
- f.close()
- f = CountedInput(test_support.TESTFN)
- for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]):
- got = f.readline()
- self.assertEqual(expected, got)
- self.assertEqual(f.lineno, i)
- self.assertEqual(f.ateof, (i > len(lines)))
- f.close()
- finally:
- try:
- f.close()
- except:
- pass
- test_support.unlink(test_support.TESTFN)
+ self.assertEqual(a[:5], list(range(5)))
+
+ ## class CountedInput(file):
+ ## """Counts lines read by self.readline().
+ ##
+ ## self.lineno is the 0-based ordinal of the last line read, up to
+ ## a maximum of one greater than the number of lines in the file.
+ ##
+ ## self.ateof is true if and only if the final "" line has been read,
+ ## at which point self.lineno stops incrementing, and further calls
+ ## to readline() continue to return "".
+ ## """
+ ##
+ ## lineno = 0
+ ## ateof = 0
+ ## def readline(self):
+ ## if self.ateof:
+ ## return ""
+ ## s = file.readline(self)
+ ## # Next line works too.
+ ## # s = super(CountedInput, self).readline()
+ ## self.lineno += 1
+ ## if s == "":
+ ## self.ateof = 1
+ ## return s
+ ##
+ ## f = file(name=support.TESTFN, mode='w')
+ ## lines = ['a\n', 'b\n', 'c\n']
+ ## try:
+ ## f.writelines(lines)
+ ## f.close()
+ ## f = CountedInput(support.TESTFN)
+ ## for (i, expected) in zip(range(1, 5) + [4], lines + 2 * [""]):
+ ## got = f.readline()
+ ## self.assertEqual(expected, got)
+ ## self.assertEqual(f.lineno, i)
+ ## self.assertEqual(f.ateof, (i > len(lines)))
+ ## f.close()
+ ## finally:
+ ## try:
+ ## f.close()
+ ## except:
+ ## pass
+ ## support.unlink(support.TESTFN)
def test_keywords(self):
# Testing keyword args to basic type constructors ...
self.assertEqual(int(x=1), 1)
self.assertEqual(float(x=2), 2.0)
- self.assertEqual(long(x=3), 3L)
+ self.assertEqual(int(x=3), 3)
self.assertEqual(complex(imag=42, real=666), complex(666, 42))
self.assertEqual(str(object=500), '500')
- self.assertEqual(unicode(string='abc', errors='strict'), u'abc')
+ self.assertEqual(str(object=b'abc', errors='strict'), 'abc')
self.assertEqual(tuple(sequence=range(3)), (0, 1, 2))
- self.assertEqual(list(sequence=(0, 1, 2)), range(3))
+ self.assertEqual(list(sequence=(0, 1, 2)), list(range(3)))
# note: as of Python 2.3, dict() no longer has an "items" keyword arg
- for constructor in (int, float, long, complex, str, unicode,
- tuple, list, file):
+ for constructor in (int, float, int, complex, str, str,
+ tuple, list):
try:
constructor(bogus_keyword_arg=1)
except TypeError:
@@ -2886,13 +2793,42 @@ order (MRO) for bases """
class C(base):
def __init__(self, value):
self.value = int(value)
- def __cmp__(self, other):
+ def __eq__(self, other):
+ if isinstance(other, C):
+ return self.value == other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value == other
+ return NotImplemented
+ def __ne__(self, other):
+ if isinstance(other, C):
+ return self.value != other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value != other
+ return NotImplemented
+ def __lt__(self, other):
+ if isinstance(other, C):
+ return self.value < other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value < other
+ return NotImplemented
+ def __le__(self, other):
+ if isinstance(other, C):
+ return self.value <= other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value <= other
+ return NotImplemented
+ def __gt__(self, other):
+ if isinstance(other, C):
+ return self.value > other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value > other
+ return NotImplemented
+ def __ge__(self, other):
if isinstance(other, C):
- return cmp(self.value, other.value)
- if isinstance(other, int) or isinstance(other, long):
- return cmp(self.value, other)
+ return self.value >= other.value
+ if isinstance(other, int) or isinstance(other, int):
+ return self.value >= other
return NotImplemented
- __hash__ = None # Silence Py3k warning
c1 = C(1)
c2 = C(2)
@@ -2901,12 +2837,16 @@ order (MRO) for bases """
c = {1: c1, 2: c2, 3: c3}
for x in 1, 2, 3:
for y in 1, 2, 3:
- self.assertTrue(cmp(c[x], c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y))
for op in "<", "<=", "==", "!=", ">", ">=":
- self.assertTrue(eval("c[x] %s c[y]" % op) == eval("x %s y" % op),
- "x=%d, y=%d" % (x, y))
- self.assertTrue(cmp(c[x], y) == cmp(x, y), "x=%d, y=%d" % (x, y))
- self.assertTrue(cmp(x, c[y]) == cmp(x, y), "x=%d, y=%d" % (x, y))
+ self.assertTrue(eval("c[x] %s c[y]" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
+ self.assertTrue(eval("c[x] %s y" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
+ self.assertTrue(eval("x %s c[y]" % op) ==
+ eval("x %s y" % op),
+ "x=%d, y=%d" % (x, y))
def test_rich_comparisons(self):
# Testing rich comparisons...
@@ -2921,7 +2861,6 @@ order (MRO) for bases """
return abs(self - other) <= 1e-6
except:
return NotImplemented
- __hash__ = None # Silence Py3k warning
zz = ZZ(1.0000003)
self.assertEqual(zz, 1+0j)
self.assertEqual(1+0j, zz)
@@ -2934,41 +2873,40 @@ order (MRO) for bases """
self.value = int(value)
def __cmp__(self_, other):
self.fail("shouldn't call __cmp__")
- __hash__ = None # Silence Py3k warning
def __eq__(self, other):
if isinstance(other, C):
return self.value == other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value == other
return NotImplemented
def __ne__(self, other):
if isinstance(other, C):
return self.value != other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value != other
return NotImplemented
def __lt__(self, other):
if isinstance(other, C):
return self.value < other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value < other
return NotImplemented
def __le__(self, other):
if isinstance(other, C):
return self.value <= other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value <= other
return NotImplemented
def __gt__(self, other):
if isinstance(other, C):
return self.value > other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value > other
return NotImplemented
def __ge__(self, other):
if isinstance(other, C):
return self.value >= other.value
- if isinstance(other, int) or isinstance(other, long):
+ if isinstance(other, int) or isinstance(other, int):
return self.value >= other
return NotImplemented
c1 = C(1)
@@ -2986,39 +2924,13 @@ order (MRO) for bases """
self.assertTrue(eval("x %s c[y]" % op) == eval("x %s y" % op),
"x=%d, y=%d" % (x, y))
- def test_coercions(self):
- # Testing coercions...
- class I(int): pass
- coerce(I(0), 0)
- coerce(0, I(0))
- class L(long): pass
- coerce(L(0), 0)
- coerce(L(0), 0L)
- coerce(0, L(0))
- coerce(0L, L(0))
- class F(float): pass
- coerce(F(0), 0)
- coerce(F(0), 0L)
- coerce(F(0), 0.)
- coerce(0, F(0))
- coerce(0L, F(0))
- coerce(0., F(0))
- class C(complex): pass
- coerce(C(0), 0)
- coerce(C(0), 0L)
- coerce(C(0), 0.)
- coerce(C(0), 0j)
- coerce(0, C(0))
- coerce(0L, C(0))
- coerce(0., C(0))
- coerce(0j, C(0))
-
def test_descrdoc(self):
# Testing descriptor doc strings...
+ from _io import FileIO
def check(descr, what):
self.assertEqual(descr.__doc__, what)
- check(file.closed, "True if the file is closed") # getset descriptor
- check(file.name, "file name") # member descriptor
+ check(FileIO.closed, "True if the file is closed") # getset descriptor
+ check(complex.real, "the real part of a complex number") # member descriptor
def test_doc_descriptor(self):
# Testing __doc__ descriptor...
@@ -3084,14 +2996,8 @@ order (MRO) for bases """
__slots__ = ["a", "b"]
class H(object):
__slots__ = ["b", "a"]
- try:
- unicode
- except NameError:
- class I(object):
- __slots__ = ["a", "b"]
- else:
- class I(object):
- __slots__ = [unicode("a"), unicode("b")]
+ class I(object):
+ __slots__ = ["a", "b"]
class J(object):
__slots__ = ["c", "b"]
class K(object):
@@ -3180,10 +3086,10 @@ order (MRO) for bases """
pass
class Meta2(Base, type):
pass
- class D(object):
- __metaclass__ = Meta1
- class E(object):
- __metaclass__ = Meta2
+ class D(object, metaclass=Meta1):
+ pass
+ class E(object, metaclass=Meta2):
+ pass
for cls in C, D, E:
verify_dict_readonly(cls)
class_dict = cls.__dict__
@@ -3227,10 +3133,10 @@ order (MRO) for bases """
def test_pickles(self):
# Testing pickling and copying new-style classes and objects...
- import pickle, cPickle
+ import pickle
def sorteditems(d):
- L = d.items()
+ L = list(d.items())
L.sort()
return L
@@ -3282,36 +3188,35 @@ order (MRO) for bases """
class C4(C4classic, object): # mixed inheritance
pass
- for p in pickle, cPickle:
- for bin in 0, 1:
- for cls in C, C1, C2:
- s = p.dumps(cls, bin)
- cls2 = p.loads(s)
- self.assertTrue(cls2 is cls)
-
- a = C1(1, 2); a.append(42); a.append(24)
- b = C2("hello", "world", 42)
- s = p.dumps((a, b), bin)
- x, y = p.loads(s)
- self.assertEqual(x.__class__, a.__class__)
- self.assertEqual(sorteditems(x.__dict__), sorteditems(a.__dict__))
- self.assertEqual(y.__class__, b.__class__)
- self.assertEqual(sorteditems(y.__dict__), sorteditems(b.__dict__))
- self.assertEqual(repr(x), repr(a))
- self.assertEqual(repr(y), repr(b))
- # Test for __getstate__ and __setstate__ on new style class
- u = C3(42)
- s = p.dumps(u, bin)
- v = p.loads(s)
- self.assertEqual(u.__class__, v.__class__)
- self.assertEqual(u.foo, v.foo)
- # Test for picklability of hybrid class
- u = C4()
- u.foo = 42
- s = p.dumps(u, bin)
- v = p.loads(s)
- self.assertEqual(u.__class__, v.__class__)
- self.assertEqual(u.foo, v.foo)
+ for bin in 0, 1:
+ for cls in C, C1, C2:
+ s = pickle.dumps(cls, bin)
+ cls2 = pickle.loads(s)
+ self.assertTrue(cls2 is cls)
+
+ a = C1(1, 2); a.append(42); a.append(24)
+ b = C2("hello", "world", 42)
+ s = pickle.dumps((a, b), bin)
+ x, y = pickle.loads(s)
+ self.assertEqual(x.__class__, a.__class__)
+ self.assertEqual(sorteditems(x.__dict__), sorteditems(a.__dict__))
+ self.assertEqual(y.__class__, b.__class__)
+ self.assertEqual(sorteditems(y.__dict__), sorteditems(b.__dict__))
+ self.assertEqual(repr(x), repr(a))
+ self.assertEqual(repr(y), repr(b))
+ # Test for __getstate__ and __setstate__ on new style class
+ u = C3(42)
+ s = pickle.dumps(u, bin)
+ v = pickle.loads(s)
+ self.assertEqual(u.__class__, v.__class__)
+ self.assertEqual(u.foo, v.foo)
+ # Test for picklability of hybrid class
+ u = C4()
+ u.foo = 42
+ s = pickle.dumps(u, bin)
+ v = pickle.loads(s)
+ self.assertEqual(u.__class__, v.__class__)
+ self.assertEqual(u.foo, v.foo)
# Testing copy.deepcopy()
import copy
@@ -3331,8 +3236,9 @@ order (MRO) for bases """
def test_pickle_slots(self):
# Testing pickling of classes with __slots__ ...
- import pickle, cPickle
+ import pickle
# Pickling of classes with __slots__ but without __getstate__ should fail
+ # (if using protocol 0 or 1)
global B, C, D, E
class B(object):
pass
@@ -3342,29 +3248,17 @@ order (MRO) for bases """
class D(C):
pass
try:
- pickle.dumps(C())
+ pickle.dumps(C(), 0)
except TypeError:
pass
else:
self.fail("should fail: pickle C instance - %s" % base)
try:
- cPickle.dumps(C())
- except TypeError:
- pass
- else:
- self.fail("should fail: cPickle C instance - %s" % base)
- try:
- pickle.dumps(C())
+ pickle.dumps(C(), 0)
except TypeError:
pass
else:
self.fail("should fail: pickle D instance - %s" % base)
- try:
- cPickle.dumps(D())
- except TypeError:
- pass
- else:
- self.fail("should fail: cPickle D instance - %s" % base)
# Give C a nice generic __getstate__ and __setstate__
class C(base):
__slots__ = ['a']
@@ -3381,7 +3275,7 @@ order (MRO) for bases """
pass
return d
def __setstate__(self, d):
- for k, v in d.items():
+ for k, v in list(d.items()):
setattr(self, k, v)
class D(C):
pass
@@ -3389,20 +3283,14 @@ order (MRO) for bases """
x = C()
y = pickle.loads(pickle.dumps(x))
self.assertEqual(hasattr(y, 'a'), 0)
- y = cPickle.loads(cPickle.dumps(x))
- self.assertEqual(hasattr(y, 'a'), 0)
x.a = 42
y = pickle.loads(pickle.dumps(x))
self.assertEqual(y.a, 42)
- y = cPickle.loads(cPickle.dumps(x))
- self.assertEqual(y.a, 42)
x = D()
x.a = 42
x.b = 100
y = pickle.loads(pickle.dumps(x))
self.assertEqual(y.a + y.b, 142)
- y = cPickle.loads(cPickle.dumps(x))
- self.assertEqual(y.a + y.b, 142)
# A subclass that adds a slot should also work
class E(C):
__slots__ = ['b']
@@ -3412,9 +3300,6 @@ order (MRO) for bases """
y = pickle.loads(pickle.dumps(x))
self.assertEqual(y.a, x.a)
self.assertEqual(y.b, x.b)
- y = cPickle.loads(cPickle.dumps(x))
- self.assertEqual(y.a, x.a)
- self.assertEqual(y.b, x.b)
def test_binary_operator_override(self):
# Testing overrides of binary operations...
@@ -3445,7 +3330,6 @@ order (MRO) for bases """
class S(str):
def __eq__(self, other):
return self.lower() == other.lower()
- __hash__ = None # Silence Py3k warning
def test_subclass_propagation(self):
# Testing propagation of slot functions to subclasses...
@@ -3497,7 +3381,7 @@ order (MRO) for bases """
def __getattr__(self, name):
if name in ("spam", "foo", "bar"):
return "hello"
- raise AttributeError, name
+ raise AttributeError(name)
B.__getattr__ = __getattr__
self.assertEqual(d.spam, "hello")
self.assertEqual(d.foo, 24)
@@ -3521,7 +3405,7 @@ order (MRO) for bases """
class B(A):
pass
del B
- test_support.gc_collect()
+ support.gc_collect()
A.__setitem__ = lambda *a: None # crash
def test_buffer_inheritance(self):
@@ -3530,22 +3414,14 @@ order (MRO) for bases """
import binascii
# SF bug [#470040] ParseTuple t# vs subclasses.
- class MyStr(str):
+ class MyBytes(bytes):
pass
- base = 'abc'
- m = MyStr(base)
+ base = b'abc'
+ m = MyBytes(base)
# b2a_hex uses the buffer interface to get its argument's value, via
# PyArg_ParseTuple 't#' code.
self.assertEqual(binascii.b2a_hex(m), binascii.b2a_hex(base))
- # It's not clear that unicode will continue to support the character
- # buffer interface, and this test will fail if that's taken away.
- class MyUni(unicode):
- pass
- base = u'abc'
- m = MyUni(base)
- self.assertEqual(binascii.b2a_hex(m), binascii.b2a_hex(base))
-
class MyInt(int):
pass
m = MyInt(42)
@@ -3558,11 +3434,11 @@ order (MRO) for bases """
def test_str_of_str_subclass(self):
# Testing __str__ defined in subclass of str ...
import binascii
- import cStringIO
+ import io
class octetstring(str):
def __str__(self):
- return binascii.b2a_hex(self)
+ return binascii.b2a_hex(self.encode('ascii')).decode("ascii")
def __repr__(self):
return self + " repr"
@@ -3576,10 +3452,10 @@ order (MRO) for bases """
self.assertEqual(o.__str__(), '41')
self.assertEqual(o.__repr__(), 'A repr')
- capture = cStringIO.StringIO()
+ capture = io.StringIO()
# Calling str() or not exercises different internal paths.
- print >> capture, o
- print >> capture, str(o)
+ print(o, file=capture)
+ print(str(o), file=capture)
self.assertEqual(capture.getvalue(), '41\n41\n')
capture.close()
@@ -3613,7 +3489,7 @@ order (MRO) for bases """
c = C()
self.assertEqual(log, [])
del c
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(log, [1])
class D(object): pass
@@ -3728,10 +3604,10 @@ order (MRO) for bases """
d = D(None)
self.assertEqual(d.foo, None)
d = C(1)
- self.assertEqual(isinstance(d, D), True)
+ self.assertIsInstance(d, D)
self.assertEqual(d.foo, 1)
d = D(1)
- self.assertEqual(isinstance(d, D), True)
+ self.assertIsInstance(d, D)
self.assertEqual(d.foo, 1)
def test_imul_bug(self):
@@ -3748,11 +3624,11 @@ order (MRO) for bases """
y *= 2
self.assertEqual(y, (x, 2))
y = x
- y *= 3L
- self.assertEqual(y, (x, 3L))
+ y *= 3
+ self.assertEqual(y, (x, 3))
y = x
- y *= 1L<<100
- self.assertEqual(y, (x, 1L<<100))
+ y *= 1<<100
+ self.assertEqual(y, (x, 1<<100))
y = x
y *= None
self.assertEqual(y, (x, None))
@@ -3854,11 +3730,11 @@ order (MRO) for bases """
# which will cause c to get appended back to the container again
# "during" the del. (On non-CPython implementations, however, __del__
# is typically not called again.)
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(len(C.container), 1)
del C.container[-1]
- if test_support.check_impl_detail():
- test_support.gc_collect()
+ if support.check_impl_detail():
+ support.gc_collect()
self.assertEqual(len(C.container), 1)
self.assertEqual(C.container[-1].attr, 42)
@@ -3874,7 +3750,7 @@ order (MRO) for bases """
def __init__(self, x):
self.x = x
o = None
- for i in xrange(50000):
+ for i in range(50000):
o = trash(o)
del o
@@ -3886,7 +3762,7 @@ order (MRO) for bases """
pass
class C(A,B) :
__slots__=()
- if test_support.check_impl_detail():
+ if support.check_impl_detail():
self.assertEqual(C.__basicsize__, B.__basicsize__)
self.assertTrue(hasattr(C, '__dict__'))
self.assertTrue(hasattr(C, '__weakref__'))
@@ -3952,7 +3828,7 @@ order (MRO) for bases """
try:
D.__bases__ = ()
- except TypeError, msg:
+ except TypeError as msg:
if str(msg) == "a new-style class can't have only classic bases":
self.fail("wrong error message for .__bases__ = ()")
else:
@@ -3980,33 +3856,10 @@ order (MRO) for bases """
else:
self.fail("shouldn't be able to create inheritance cycles")
- # let's throw a classic class into the mix:
- class Classic:
- def meth2(self):
- return 3
-
- D.__bases__ = (C, Classic)
-
- self.assertEqual(d.meth2(), 3)
- self.assertEqual(e.meth2(), 3)
- try:
- d.a
- except AttributeError:
- pass
- else:
- self.fail("attribute should have vanished")
-
- try:
- D.__bases__ = (Classic,)
- except TypeError:
- pass
- else:
- self.fail("new-style class must have a new-style base")
-
def test_builtin_bases(self):
# Make sure all the builtin types can have their base queried without
# segfaulting. See issue #5787.
- builtin_types = [tp for tp in __builtin__.__dict__.itervalues()
+ builtin_types = [tp for tp in builtins.__dict__.values()
if isinstance(tp, type)]
for tp in builtin_types:
object.__getattribute__(tp, "__bases__")
@@ -4052,7 +3905,7 @@ order (MRO) for bases """
return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
def mro(self):
if self.flag > 0:
- raise RuntimeError, "bozo"
+ raise RuntimeError("bozo")
else:
self.flag += 1
return type.mro(self)
@@ -4077,11 +3930,11 @@ order (MRO) for bases """
class E(D):
pass
- class F(D):
- __metaclass__ = WorkOnce
+ class F(D, metaclass=WorkOnce):
+ pass
- class G(D):
- __metaclass__ = WorkAlways
+ class G(D, metaclass=WorkAlways):
+ pass
# Immediate subclasses have their mro's adjusted in alphabetical
# order, so E's will get adjusted before adjusting F's fails. We
@@ -4187,7 +4040,7 @@ order (MRO) for bases """
self.assertEqual(E() // C(), "C.__floordiv__")
self.assertEqual(C() // E(), "C.__floordiv__") # This one would fail
- @test_support.impl_detail("testing an internal kind of method object")
+ @support.impl_detail("testing an internal kind of method object")
def test_meth_class_get(self):
# Testing __get__ method of METH_CLASS C methods...
# Full coverage of descrobject.c::classmethod_get()
@@ -4330,7 +4183,7 @@ order (MRO) for bases """
def test_wrapper_segfault(self):
# SF 927248: deeply nested wrappers could cause stack overflow
f = lambda:None
- for i in xrange(1000000):
+ for i in range(1000000):
f = f.__call__
f = None
@@ -4343,7 +4196,7 @@ order (MRO) for bases """
raise RuntimeError("Premature access to sys.stdout.%s" % attr)
sys.stdout = StdoutGuard()
try:
- print "Oops!"
+ print("Oops!")
except RuntimeError:
pass
finally:
@@ -4375,7 +4228,7 @@ order (MRO) for bases """
self.assertEqual(c.attr, 1)
# this makes a crash more likely:
- test_support.gc_collect()
+ support.gc_collect()
self.assertEqual(hasattr(c, 'attr'), False)
def test_init(self):
@@ -4394,6 +4247,8 @@ order (MRO) for bases """
# Testing method-wrapper objects...
# <type 'method-wrapper'> did not support any reflection before 2.5
+ # XXX should methods really support __eq__?
+
l = []
self.assertEqual(l.__add__, l.__add__)
self.assertEqual(l.__add__, [].__add__)
@@ -4431,63 +4286,47 @@ order (MRO) for bases """
def check(expr, x, y):
try:
- exec expr in {'x': x, 'y': y, 'operator': operator}
+ exec(expr, {'x': x, 'y': y, 'operator': operator})
except TypeError:
pass
else:
self.fail("no TypeError from %r" % (expr,))
- N1 = sys.maxint + 1L # might trigger OverflowErrors instead of
+ N1 = sys.maxsize + 1 # might trigger OverflowErrors instead of
# TypeErrors
- N2 = sys.maxint # if sizeof(int) < sizeof(long), might trigger
+ N2 = sys.maxsize # if sizeof(int) < sizeof(long), might trigger
# ValueErrors instead of TypeErrors
- for metaclass in [type, types.ClassType]:
- for name, expr, iexpr in [
- ('__add__', 'x + y', 'x += y'),
- ('__sub__', 'x - y', 'x -= y'),
- ('__mul__', 'x * y', 'x *= y'),
- ('__truediv__', 'operator.truediv(x, y)', None),
- ('__floordiv__', 'operator.floordiv(x, y)', None),
- ('__div__', 'x / y', 'x /= y'),
- ('__mod__', 'x % y', 'x %= y'),
- ('__divmod__', 'divmod(x, y)', None),
- ('__pow__', 'x ** y', 'x **= y'),
- ('__lshift__', 'x << y', 'x <<= y'),
- ('__rshift__', 'x >> y', 'x >>= y'),
- ('__and__', 'x & y', 'x &= y'),
- ('__or__', 'x | y', 'x |= y'),
- ('__xor__', 'x ^ y', 'x ^= y'),
- ('__coerce__', 'coerce(x, y)', None)]:
- if name == '__coerce__':
- rname = name
- else:
- rname = '__r' + name[2:]
- A = metaclass('A', (), {name: specialmethod})
- B = metaclass('B', (), {rname: specialmethod})
- a = A()
- b = B()
- check(expr, a, a)
- check(expr, a, b)
- check(expr, b, a)
- check(expr, b, b)
- check(expr, a, N1)
- check(expr, a, N2)
- check(expr, N1, b)
- check(expr, N2, b)
- if iexpr:
- check(iexpr, a, a)
- check(iexpr, a, b)
- check(iexpr, b, a)
- check(iexpr, b, b)
- check(iexpr, a, N1)
- check(iexpr, a, N2)
- iname = '__i' + name[2:]
- C = metaclass('C', (), {iname: specialmethod})
- c = C()
- check(iexpr, c, a)
- check(iexpr, c, b)
- check(iexpr, c, N1)
- check(iexpr, c, N2)
+ for name, expr, iexpr in [
+ ('__add__', 'x + y', 'x += y'),
+ ('__sub__', 'x - y', 'x -= y'),
+ ('__mul__', 'x * y', 'x *= y'),
+ ('__truediv__', 'operator.truediv(x, y)', None),
+ ('__floordiv__', 'operator.floordiv(x, y)', None),
+ ('__div__', 'x / y', 'x /= y'),
+ ('__mod__', 'x % y', 'x %= y'),
+ ('__divmod__', 'divmod(x, y)', None),
+ ('__pow__', 'x ** y', 'x **= y'),
+ ('__lshift__', 'x << y', 'x <<= y'),
+ ('__rshift__', 'x >> y', 'x >>= y'),
+ ('__and__', 'x & y', 'x &= y'),
+ ('__or__', 'x | y', 'x |= y'),
+ ('__xor__', 'x ^ y', 'x ^= y')]:
+ rname = '__r' + name[2:]
+ A = type('A', (), {name: specialmethod})
+ a = A()
+ check(expr, a, a)
+ check(expr, a, N1)
+ check(expr, a, N2)
+ if iexpr:
+ check(iexpr, a, a)
+ check(iexpr, a, N1)
+ check(iexpr, a, N2)
+ iname = '__i' + name[2:]
+ C = type('C', (), {iname: specialmethod})
+ c = C()
+ check(iexpr, c, a)
+ check(iexpr, c, N1)
+ check(iexpr, c, N2)
def test_assign_slice(self):
# ceval.c's assign_slice used to check for
@@ -4495,7 +4334,7 @@ order (MRO) for bases """
# tp->tp_as_sequence->sq_ass_slice
class C(object):
- def __setslice__(self, start, stop, value):
+ def __setitem__(self, idx, value):
self.value = value
c = C()
@@ -4585,11 +4424,11 @@ order (MRO) for bases """
del X.__abstractmethods__
def test_proxy_call(self):
- class FakeStr(object):
+ class FakeStr:
__class__ = str
fake_str = FakeStr()
- # isinstance() reads __class__ on new style classes
+ # isinstance() reads __class__
self.assertTrue(isinstance(fake_str, str))
# call a method descriptor
@@ -4603,7 +4442,7 @@ order (MRO) for bases """
def test_repr_as_str(self):
# Issue #11603: crash or infinite loop when rebinding __str__ as
# __repr__.
- class Foo(object):
+ class Foo:
pass
Foo.__repr__ = Foo.__str__
foo = Foo()
@@ -4627,7 +4466,7 @@ order (MRO) for bases """
x.attr = 42
wr = weakref.ref(x)
del x
- test_support.gc_collect()
+ support.gc_collect()
self.assertIsNone(wr())
for o in gc.get_objects():
self.assertIsNot(type(o), X)
@@ -4639,40 +4478,57 @@ class DictProxyTests(unittest.TestCase):
pass
self.C = C
- def test_repr(self):
- self.assertIn('dict_proxy({', repr(vars(self.C)))
- self.assertIn("'meth':", repr(vars(self.C)))
-
def test_iter_keys(self):
- # Testing dict-proxy iterkeys...
- keys = [ key for key in self.C.__dict__.iterkeys() ]
+ # Testing dict-proxy keys...
+ it = self.C.__dict__.keys()
+ self.assertNotIsInstance(it, list)
+ keys = list(it)
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
'__weakref__', 'meth'])
def test_iter_values(self):
- # Testing dict-proxy itervalues...
- values = [ values for values in self.C.__dict__.itervalues() ]
+ # Testing dict-proxy values...
+ it = self.C.__dict__.values()
+ self.assertNotIsInstance(it, list)
+ values = list(it)
self.assertEqual(len(values), 5)
def test_iter_items(self):
# Testing dict-proxy iteritems...
- keys = [ key for (key, value) in self.C.__dict__.iteritems() ]
+ it = self.C.__dict__.items()
+ self.assertNotIsInstance(it, list)
+ keys = [item[0] for item in it]
keys.sort()
self.assertEqual(keys, ['__dict__', '__doc__', '__module__',
'__weakref__', 'meth'])
def test_dict_type_with_metaclass(self):
- # Testing type of __dict__ when __metaclass__ set...
+ # Testing type of __dict__ when metaclass set...
class B(object):
pass
class M(type):
pass
- class C:
+ class C(metaclass=M):
# In 2.3a1, C.__dict__ was a real dict rather than a dict proxy
- __metaclass__ = M
+ pass
self.assertEqual(type(C.__dict__), type(B.__dict__))
+ def test_repr(self):
+ # Testing dict_proxy.__repr__
+ def sorted_dict_repr(repr_):
+ # Given the repr of a dict, sort the keys
+ assert repr_.startswith('{')
+ assert repr_.endswith('}')
+ kvs = repr_[1:-1].split(', ')
+ return '{' + ', '.join(sorted(kvs)) + '}'
+ dict_ = {k: v for k, v in self.C.__dict__.items()}
+ repr_ = repr(self.C.__dict__)
+ self.assertTrue(repr_.startswith('dict_proxy('))
+ self.assertTrue(repr_.endswith(')'))
+ self.assertEqual(sorted_dict_repr(repr_[len('dict_proxy('):-len(')')]),
+ sorted_dict_repr('{!r}'.format(dict_)))
+
class PTypesLongInitTest(unittest.TestCase):
# This is in its own TestCase so that it can be run before any other tests.
@@ -4687,7 +4543,7 @@ class PTypesLongInitTest(unittest.TestCase):
def __pow__(self, *args):
pass
try:
- pow(0L, UserLong(), 0L)
+ pow(0, UserLong(), 0)
except:
pass
@@ -4697,17 +4553,9 @@ class PTypesLongInitTest(unittest.TestCase):
def test_main():
- deprecations = [(r'complex divmod\(\), // and % are deprecated$',
- DeprecationWarning)]
- if sys.py3kwarning:
- deprecations += [
- ("classic (int|long) division", DeprecationWarning),
- ("coerce.. not supported", DeprecationWarning),
- (".+__(get|set|del)slice__ has been removed", DeprecationWarning)]
- with test_support.check_warnings(*deprecations):
- # Run all local test cases, with PTypesLongInitTest first.
- test_support.run_unittest(PTypesLongInitTest, OperatorsTest,
- ClassPropertiesAndMethods, DictProxyTests)
+ # Run all local test cases, with PTypesLongInitTest first.
+ support.run_unittest(PTypesLongInitTest, OperatorsTest,
+ ClassPropertiesAndMethods, DictProxyTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py
index 157b9f4fe9c..2db3d33226f 100644
--- a/Lib/test/test_descrtut.py
+++ b/Lib/test/test_descrtut.py
@@ -8,7 +8,7 @@
# of much interest anymore), and a few were fiddled to make the output
# deterministic.
-from test.test_support import sortdict
+from test.support import sortdict
import pprint
class defaultdict(dict):
@@ -36,28 +36,28 @@ test_1 = """
Here's the new type at work:
- >>> print defaultdict # show our type
+ >>> print(defaultdict) # show our type
<class 'test.test_descrtut.defaultdict'>
- >>> print type(defaultdict) # its metatype
- <type 'type'>
+ >>> print(type(defaultdict)) # its metatype
+ <class 'type'>
>>> a = defaultdict(default=0.0) # create an instance
- >>> print a # show the instance
+ >>> print(a) # show the instance
{}
- >>> print type(a) # show its type
+ >>> print(type(a)) # show its type
<class 'test.test_descrtut.defaultdict'>
- >>> print a.__class__ # show its class
+ >>> print(a.__class__) # show its class
<class 'test.test_descrtut.defaultdict'>
- >>> print type(a) is a.__class__ # its type is its class
+ >>> print(type(a) is a.__class__) # its type is its class
True
>>> a[1] = 3.25 # modify the instance
- >>> print a # show the new value
+ >>> print(a) # show the new value
{1: 3.25}
- >>> print a[1] # show the new item
+ >>> print(a[1]) # show the new item
3.25
- >>> print a[0] # a non-existent item
+ >>> print(a[0]) # a non-existent item
0.0
>>> a.merge({1:100, 2:200}) # use a dict method
- >>> print sortdict(a) # show the result
+ >>> print(sortdict(a)) # show the result
{1: 3.25, 2: 200}
>>>
@@ -65,16 +65,14 @@ We can also use the new type in contexts where classic only allows "real"
dictionaries, such as the locals/globals dictionaries for the exec
statement or the built-in function eval():
- >>> def sorted(seq):
- ... seq.sort(key=str)
- ... return seq
- >>> print sorted(a.keys())
+ >>> print(sorted(a.keys()))
[1, 2]
- >>> exec "x = 3; print x" in a
+ >>> a['print'] = print # need the print function here
+ >>> exec("x = 3; print(x)", a)
3
- >>> print sorted(a.keys())
- [1, 2, '__builtins__', 'x']
- >>> print a['x']
+ >>> print(sorted(a.keys(), key=lambda x: (str(type(x)), x)))
+ [1, 2, '__builtins__', 'print', 'x']
+ >>> print(a['x'])
3
>>>
@@ -82,21 +80,21 @@ Now I'll show that defaultdict instances have dynamic instance variables,
just like classic classes:
>>> a.default = -1
- >>> print a["noway"]
+ >>> print(a["noway"])
-1
>>> a.default = -1000
- >>> print a["noway"]
+ >>> print(a["noway"])
-1000
>>> 'default' in dir(a)
True
>>> a.x1 = 100
>>> a.x2 = 200
- >>> print a.x1
+ >>> print(a.x1)
100
>>> d = dir(a)
>>> 'default' in d and 'x1' in d and 'x2' in d
True
- >>> print sortdict(a.__dict__)
+ >>> print(sortdict(a.__dict__))
{'default': -1000, 'x1': 100, 'x2': 200}
>>>
"""
@@ -151,11 +149,11 @@ Introspecting instances of built-in types
For instance of built-in types, x.__class__ is now the same as type(x):
>>> type([])
- <type 'list'>
+ <class 'list'>
>>> [].__class__
- <type 'list'>
+ <class 'list'>
>>> list
- <type 'list'>
+ <class 'list'>
>>> isinstance([], list)
True
>>> isinstance([], dict)
@@ -164,15 +162,7 @@ For instance of built-in types, x.__class__ is now the same as type(x):
True
>>>
-Under the new proposal, the __methods__ attribute no longer exists:
-
- >>> [].__methods__
- Traceback (most recent call last):
- File "<stdin>", line 1, in ?
- AttributeError: 'list' object has no attribute '__methods__'
- >>>
-
-Instead, you can get the same information from the list type:
+You can get the information from the list type:
>>> pprint.pprint(dir(list)) # like list.__dict__.keys(), but sorted
['__add__',
@@ -180,14 +170,12 @@ Instead, you can get the same information from the list type:
'__contains__',
'__delattr__',
'__delitem__',
- '__delslice__',
'__doc__',
'__eq__',
'__format__',
'__ge__',
'__getattribute__',
'__getitem__',
- '__getslice__',
'__gt__',
'__hash__',
'__iadd__',
@@ -207,7 +195,6 @@ Instead, you can get the same information from the list type:
'__rmul__',
'__setattr__',
'__setitem__',
- '__setslice__',
'__sizeof__',
'__str__',
'__subclasshook__',
@@ -251,7 +238,7 @@ static methods in C++ or Java. Here's an example:
...
... @staticmethod
... def foo(x, y):
- ... print "staticmethod", x, y
+ ... print("staticmethod", x, y)
>>> C.foo(1, 2)
staticmethod 1 2
@@ -265,22 +252,22 @@ implicit first argument that is the *class* for which they are invoked.
>>> class C:
... @classmethod
... def foo(cls, y):
- ... print "classmethod", cls, y
+ ... print("classmethod", cls, y)
>>> C.foo(1)
- classmethod test.test_descrtut.C 1
+ classmethod <class 'test.test_descrtut.C'> 1
>>> c = C()
>>> c.foo(1)
- classmethod test.test_descrtut.C 1
+ classmethod <class 'test.test_descrtut.C'> 1
>>> class D(C):
... pass
>>> D.foo(1)
- classmethod test.test_descrtut.D 1
+ classmethod <class 'test.test_descrtut.D'> 1
>>> d = D()
>>> d.foo(1)
- classmethod test.test_descrtut.D 1
+ classmethod <class 'test.test_descrtut.D'> 1
This prints "classmethod __main__.D 1" both times; in other words, the
class passed as the first argument of foo() is the class involved in the
@@ -291,16 +278,16 @@ But notice this:
>>> class E(C):
... @classmethod
... def foo(cls, y): # override C.foo
- ... print "E.foo() called"
+ ... print("E.foo() called")
... C.foo(y)
>>> E.foo(1)
E.foo() called
- classmethod test.test_descrtut.C 1
+ classmethod <class 'test.test_descrtut.C'> 1
>>> e = E()
>>> e.foo(1)
E.foo() called
- classmethod test.test_descrtut.C 1
+ classmethod <class 'test.test_descrtut.C'> 1
In this example, the call to C.foo() from E.foo() will see class C as its
first argument, not class E. This is to be expected, since the call
@@ -325,7 +312,7 @@ Attributes defined by get/set methods
...
... def __set__(self, inst, value):
... if self.__set is None:
- ... raise AttributeError, "this attribute is read-only"
+ ... raise AttributeError("this attribute is read-only")
... return self.__set(inst, value)
Now let's define a class with an attribute x defined by a pair of methods,
@@ -349,10 +336,10 @@ Here's a small demonstration:
>>> a = C()
>>> a.x = 10
- >>> print a.x
+ >>> print(a.x)
10
>>> a.x = -10
- >>> print a.x
+ >>> print(a.x)
0
>>>
@@ -360,7 +347,7 @@ Hmm -- property is builtin now, so let's try it that way too.
>>> del property # unmask the builtin
>>> property
- <type 'property'>
+ <class 'property'>
>>> class C(object):
... def __init__(self):
@@ -375,10 +362,10 @@ Hmm -- property is builtin now, so let's try it that way too.
>>> a = C()
>>> a.x = 10
- >>> print a.x
+ >>> print(a.x)
10
>>> a.x = -10
- >>> print a.x
+ >>> print(a.x)
0
>>>
"""
@@ -389,28 +376,28 @@ Method resolution order
This example is implicit in the writeup.
->>> class A: # classic class
+>>> class A: # implicit new-style class
... def save(self):
-... print "called A.save()"
+... print("called A.save()")
>>> class B(A):
... pass
>>> class C(A):
... def save(self):
-... print "called C.save()"
+... print("called C.save()")
>>> class D(B, C):
... pass
>>> D().save()
-called A.save()
+called C.save()
->>> class A(object): # new class
+>>> class A(object): # explicit new-style class
... def save(self):
-... print "called A.save()"
+... print("called A.save()")
>>> class B(A):
... pass
>>> class C(A):
... def save(self):
-... print "called C.save()"
+... print("called C.save()")
>>> class D(B, C):
... pass
@@ -439,7 +426,7 @@ test_7 = """
Cooperative methods and "super"
->>> print D().m() # "DCBA"
+>>> print(D().m()) # "DCBA"
DCBA
"""
@@ -449,7 +436,7 @@ Backwards incompatibilities
>>> class A:
... def foo(self):
-... print "called A.foo()"
+... print("called A.foo()")
>>> class B(A):
... pass
@@ -459,9 +446,7 @@ Backwards incompatibilities
... B.foo(self)
>>> C().foo()
-Traceback (most recent call last):
- ...
-TypeError: unbound method foo() must be called with B instance as first argument (got C instance instead)
+called A.foo()
>>> class C(A):
... def foo(self):
@@ -489,8 +474,8 @@ def test_main(verbose=None):
# into the doctest examples, and unless the full test.test_descrtut
# business is used the name can change depending on how the test is
# invoked.
- from test import test_support, test_descrtut
- test_support.run_doctest(test_descrtut, verbose)
+ from test import support, test_descrtut
+ support.run_doctest(test_descrtut, verbose)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
index 0840f59799b..9666f9a31cf 100644
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -1,11 +1,21 @@
import unittest
-from test import test_support
+from test import support
-import UserDict, random, string
+import collections, random, string
import gc, weakref
class DictTest(unittest.TestCase):
+
+ def test_invalid_keyword_arguments(self):
+ class Custom(dict):
+ pass
+ for invalid in {1 : 2}, Custom({1 : 2}):
+ with self.assertRaises(TypeError):
+ dict(**invalid)
+ with self.assertRaises(TypeError):
+ {}.update(**invalid)
+
def test_constructor(self):
# calling built-in types without argument must return empty
self.assertEqual(dict(), {})
@@ -15,7 +25,7 @@ class DictTest(unittest.TestCase):
# check literal constructor for different sized dicts
# (to exercise the BUILD_MAP oparg).
for n in (0, 1, 6, 256, 400):
- items = [(''.join(random.sample(string.letters, 8)), i)
+ items = [(''.join(random.sample(string.ascii_letters, 8)), i)
for i in range(n)]
random.shuffle(items)
formatted_items = ('{!r}: {:d}'.format(k, v) for k, v in items)
@@ -30,40 +40,30 @@ class DictTest(unittest.TestCase):
def test_keys(self):
d = {}
- self.assertEqual(d.keys(), [])
+ self.assertEqual(set(d.keys()), set())
d = {'a': 1, 'b': 2}
k = d.keys()
- self.assertTrue(d.has_key('a'))
- self.assertTrue(d.has_key('b'))
-
+ self.assertIn('a', d)
+ self.assertIn('b', d)
self.assertRaises(TypeError, d.keys, None)
+ self.assertEqual(repr(dict(a=1).keys()), "dict_keys(['a'])")
def test_values(self):
d = {}
- self.assertEqual(d.values(), [])
+ self.assertEqual(set(d.values()), set())
d = {1:2}
- self.assertEqual(d.values(), [2])
-
+ self.assertEqual(set(d.values()), {2})
self.assertRaises(TypeError, d.values, None)
+ self.assertEqual(repr(dict(a=1).values()), "dict_values([1])")
def test_items(self):
d = {}
- self.assertEqual(d.items(), [])
+ self.assertEqual(set(d.items()), set())
d = {1:2}
- self.assertEqual(d.items(), [(1, 2)])
-
+ self.assertEqual(set(d.items()), {(1, 2)})
self.assertRaises(TypeError, d.items, None)
-
- def test_has_key(self):
- d = {}
- self.assertFalse(d.has_key('a'))
- d = {'a': 1, 'b': 2}
- k = d.keys()
- k.sort()
- self.assertEqual(k, ['a', 'b'])
-
- self.assertRaises(TypeError, d.has_key)
+ self.assertEqual(repr(dict(a=1).items()), "dict_items([('a', 1)])")
def test_contains(self):
d = {}
@@ -166,7 +166,7 @@ class DictTest(unittest.TestCase):
self.i = 1
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i:
self.i = 0
return 'a'
@@ -183,7 +183,7 @@ class DictTest(unittest.TestCase):
self.i = ord('a')
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i <= ord('z'):
rtn = chr(self.i)
self.i += 1
@@ -197,7 +197,7 @@ class DictTest(unittest.TestCase):
class badseq(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise Exc()
self.assertRaises(Exc, {}.update, badseq())
@@ -222,10 +222,10 @@ class DictTest(unittest.TestCase):
self.assertIsInstance(dictlike().fromkeys('a'), dictlike)
class mydict(dict):
def __new__(cls):
- return UserDict.UserDict()
+ return collections.UserDict()
ud = mydict.fromkeys('ab')
self.assertEqual(ud, {'a':None, 'b':None})
- self.assertIsInstance(ud, UserDict.UserDict)
+ self.assertIsInstance(ud, collections.UserDict)
self.assertRaises(TypeError, dict.fromkeys)
class Exc(Exception): pass
@@ -239,7 +239,7 @@ class DictTest(unittest.TestCase):
class BadSeq(object):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise Exc()
self.assertRaises(Exc, dict.fromkeys, BadSeq())
@@ -366,13 +366,6 @@ class DictTest(unittest.TestCase):
self.assertRaises(KeyError, d.pop, k)
- # verify longs/ints get same value when key > 32 bits
- # (for 64-bit archs). See SF bug #689659.
- x = 4503599627370496L
- y = 4503599627370496
- h = {x: 'anything', y: 'something else'}
- self.assertEqual(h[x], h[y])
-
self.assertEqual(d.pop(k, v), v)
d[k] = v
self.assertEqual(d.pop(k, 1), v)
@@ -420,9 +413,9 @@ class DictTest(unittest.TestCase):
d = {1: BadRepr()}
self.assertRaises(Exc, repr, d)
- def test_le(self):
- self.assertFalse({} < {})
- self.assertFalse({1: 2} < {1L: 2L})
+ def test_eq(self):
+ self.assertEqual({}, {})
+ self.assertEqual({1: 2}, {1: 2})
class Exc(Exception): pass
@@ -430,13 +423,125 @@ class DictTest(unittest.TestCase):
def __eq__(self, other):
raise Exc()
def __hash__(self):
- return 42
+ return 1
d1 = {BadCmp(): 1}
d2 = {1: 1}
with self.assertRaises(Exc):
- d1 < d2
+ d1 == d2
+
+ def test_keys_contained(self):
+ self.helper_keys_contained(lambda x: x.keys())
+ self.helper_keys_contained(lambda x: x.items())
+
+ def helper_keys_contained(self, fn):
+ # Test rich comparisons against dict key views, which should behave the
+ # same as sets.
+ empty = fn(dict())
+ empty2 = fn(dict())
+ smaller = fn({1:1, 2:2})
+ larger = fn({1:1, 2:2, 3:3})
+ larger2 = fn({1:1, 2:2, 3:3})
+ larger3 = fn({4:1, 2:2, 3:3})
+
+ self.assertTrue(smaller < larger)
+ self.assertTrue(smaller <= larger)
+ self.assertTrue(larger > smaller)
+ self.assertTrue(larger >= smaller)
+
+ self.assertFalse(smaller >= larger)
+ self.assertFalse(smaller > larger)
+ self.assertFalse(larger <= smaller)
+ self.assertFalse(larger < smaller)
+
+ self.assertFalse(smaller < larger3)
+ self.assertFalse(smaller <= larger3)
+ self.assertFalse(larger3 > smaller)
+ self.assertFalse(larger3 >= smaller)
+
+ # Inequality strictness
+ self.assertTrue(larger2 >= larger)
+ self.assertTrue(larger2 <= larger)
+ self.assertFalse(larger2 > larger)
+ self.assertFalse(larger2 < larger)
+
+ self.assertTrue(larger == larger2)
+ self.assertTrue(smaller != larger)
+
+ # There is an optimization on the zero-element case.
+ self.assertTrue(empty == empty2)
+ self.assertFalse(empty != empty2)
+ self.assertFalse(empty == smaller)
+ self.assertTrue(empty != smaller)
+
+ # With the same size, an elementwise compare happens
+ self.assertTrue(larger != larger3)
+ self.assertFalse(larger == larger3)
+
+ def test_errors_in_view_containment_check(self):
+ class C:
+ def __eq__(self, other):
+ raise RuntimeError
+
+ d1 = {1: C()}
+ d2 = {1: C()}
+ with self.assertRaises(RuntimeError):
+ d1.items() == d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() != d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() <= d2.items()
+ with self.assertRaises(RuntimeError):
+ d1.items() >= d2.items()
+
+ d3 = {1: C(), 2: C()}
+ with self.assertRaises(RuntimeError):
+ d2.items() < d3.items()
+ with self.assertRaises(RuntimeError):
+ d3.items() > d2.items()
+
+ def test_dictview_set_operations_on_keys(self):
+ k1 = {1:1, 2:2}.keys()
+ k2 = {1:1, 2:2, 3:3}.keys()
+ k3 = {4:4}.keys()
+
+ self.assertEqual(k1 - k2, set())
+ self.assertEqual(k1 - k3, {1,2})
+ self.assertEqual(k2 - k1, {3})
+ self.assertEqual(k3 - k1, {4})
+ self.assertEqual(k1 & k2, {1,2})
+ self.assertEqual(k1 & k3, set())
+ self.assertEqual(k1 | k2, {1,2,3})
+ self.assertEqual(k1 ^ k2, {3})
+ self.assertEqual(k1 ^ k3, {1,2,4})
+
+ def test_dictview_set_operations_on_items(self):
+ k1 = {1:1, 2:2}.items()
+ k2 = {1:1, 2:2, 3:3}.items()
+ k3 = {4:4}.items()
+
+ self.assertEqual(k1 - k2, set())
+ self.assertEqual(k1 - k3, {(1,1), (2,2)})
+ self.assertEqual(k2 - k1, {(3,3)})
+ self.assertEqual(k3 - k1, {(4,4)})
+ self.assertEqual(k1 & k2, {(1,1), (2,2)})
+ self.assertEqual(k1 & k3, set())
+ self.assertEqual(k1 | k2, {(1,1), (2,2), (3,3)})
+ self.assertEqual(k1 ^ k2, {(3,3)})
+ self.assertEqual(k1 ^ k3, {(1,1), (2,2), (4,4)})
+
+ def test_dictview_mixed_set_operations(self):
+ # Just a few for .keys()
+ self.assertTrue({1:1}.keys() == {1})
+ self.assertTrue({1} == {1:1}.keys())
+ self.assertEqual({1:1}.keys() | {2}, {1, 2})
+ self.assertEqual({2} | {1:1}.keys(), {1, 2})
+ # And a few for .items()
+ self.assertTrue({1:1}.items() == {(1,1)})
+ self.assertTrue({(1,1)} == {1:1}.items())
+ self.assertEqual({1:1}.items() | {2}, {(1,1), 2})
+ self.assertEqual({2} | {1:1}.items(), {(1,1), 2})
def test_missing(self):
# Make sure dict doesn't have a __missing__ method
@@ -489,7 +594,7 @@ class DictTest(unittest.TestCase):
self.assertEqual(c.exception.args, ((1,),))
def test_bad_key(self):
- # Dictionary lookups should fail if __cmp__() raises an exception.
+ # Dictionary lookups should fail if __eq__() raises an exception.
class CustomException(Exception):
pass
@@ -497,7 +602,7 @@ class DictTest(unittest.TestCase):
def __hash__(self):
return hash(self.__class__)
- def __cmp__(self, other):
+ def __eq__(self, other):
if isinstance(other, self.__class__):
raise CustomException
return other
@@ -509,13 +614,12 @@ class DictTest(unittest.TestCase):
for stmt in ['d[x2] = 2',
'z = d[x2]',
'x2 in d',
- 'd.has_key(x2)',
'd.get(x2)',
'd.setdefault(x2, 42)',
'd.pop(x2)',
'd.update({x2: 2})']:
with self.assertRaises(CustomException):
- exec stmt in locals()
+ exec(stmt, locals())
def test_resize1(self):
# Dict resizing bug, found by Jack Jansen in 2.2 CVS development.
@@ -564,15 +668,17 @@ class DictTest(unittest.TestCase):
d = {}
def test_container_iterator(self):
- # Bug #3680: tp_traverse was not implemented for dictiter objects
+ # Bug #3680: tp_traverse was not implemented for dictiter and
+ # dictview objects.
class C(object):
pass
- iterators = (dict.iteritems, dict.itervalues, dict.iterkeys)
- for i in iterators:
+ views = (dict.items, dict.values, dict.keys)
+ for v in views:
obj = C()
ref = weakref.ref(obj)
container = {obj: 1}
- obj.x = i(container)
+ obj.v = v(container)
+ obj.x = iter(obj.v)
del obj, container
gc.collect()
self.assertIs(ref(), None, "Cycle was not collected")
@@ -589,7 +695,7 @@ class DictTest(unittest.TestCase):
gc.collect()
self.assertTrue(gc.is_tracked(t), t)
- @test_support.cpython_only
+ @support.cpython_only
def test_track_literals(self):
# Test GC-optimization of dict literals
x, y, z, w = 1.5, "a", (1, None), []
@@ -607,7 +713,7 @@ class DictTest(unittest.TestCase):
self._tracked({1: {}})
self._tracked({1: set()})
- @test_support.cpython_only
+ @support.cpython_only
def test_track_dynamic(self):
# Test GC-optimization of dynamically-created dicts
class MyObject(object):
@@ -671,7 +777,7 @@ class DictTest(unittest.TestCase):
d.update([(x, y), (z, w)])
self._tracked(d)
- @test_support.cpython_only
+ @support.cpython_only
def test_track_subtypes(self):
# Dict subtypes are always tracked
class MyDict(dict):
@@ -691,14 +797,11 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
type2test = Dict
def test_main():
- with test_support.check_py3k_warnings(
- ('dict(.has_key..| inequality comparisons) not supported in 3.x',
- DeprecationWarning)):
- test_support.run_unittest(
- DictTest,
- GeneralMappingTests,
- SubclassMappingTests,
- )
+ support.run_unittest(
+ DictTest,
+ GeneralMappingTests,
+ SubclassMappingTests,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_dictcomps.py b/Lib/test/test_dictcomps.py
index 9af9e48b2cc..a3b22dc4506 100644
--- a/Lib/test/test_dictcomps.py
+++ b/Lib/test/test_dictcomps.py
@@ -36,16 +36,16 @@ __test__ = {'doctests' : doctests}
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_dictcomps
- test_support.run_doctest(test_dictcomps, verbose)
+ support.run_doctest(test_dictcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_dictcomps, verbose)
+ support.run_doctest(test_dictcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
diff --git a/Lib/test/test_dictviews.py b/Lib/test/test_dictviews.py
index f90367660c5..4c040796f5e 100644
--- a/Lib/test/test_dictviews.py
+++ b/Lib/test/test_dictviews.py
@@ -1,48 +1,48 @@
import unittest
-from test import test_support
+from test import support
class DictSetTest(unittest.TestCase):
def test_constructors_not_callable(self):
- kt = type({}.viewkeys())
+ kt = type({}.keys())
self.assertRaises(TypeError, kt, {})
self.assertRaises(TypeError, kt)
- it = type({}.viewitems())
+ it = type({}.items())
self.assertRaises(TypeError, it, {})
self.assertRaises(TypeError, it)
- vt = type({}.viewvalues())
+ vt = type({}.values())
self.assertRaises(TypeError, vt, {})
self.assertRaises(TypeError, vt)
def test_dict_keys(self):
d = {1: 10, "a": "ABC"}
- keys = d.viewkeys()
+ keys = d.keys()
self.assertEqual(len(keys), 2)
- self.assertEqual(set(keys), set([1, "a"]))
- self.assertEqual(keys, set([1, "a"]))
- self.assertNotEqual(keys, set([1, "a", "b"]))
- self.assertNotEqual(keys, set([1, "b"]))
- self.assertNotEqual(keys, set([1]))
+ self.assertEqual(set(keys), {1, "a"})
+ self.assertEqual(keys, {1, "a"})
+ self.assertNotEqual(keys, {1, "a", "b"})
+ self.assertNotEqual(keys, {1, "b"})
+ self.assertNotEqual(keys, {1})
self.assertNotEqual(keys, 42)
self.assertIn(1, keys)
self.assertIn("a", keys)
self.assertNotIn(10, keys)
self.assertNotIn("Z", keys)
- self.assertEqual(d.viewkeys(), d.viewkeys())
+ self.assertEqual(d.keys(), d.keys())
e = {1: 11, "a": "def"}
- self.assertEqual(d.viewkeys(), e.viewkeys())
+ self.assertEqual(d.keys(), e.keys())
del e["a"]
- self.assertNotEqual(d.viewkeys(), e.viewkeys())
+ self.assertNotEqual(d.keys(), e.keys())
def test_dict_items(self):
d = {1: 10, "a": "ABC"}
- items = d.viewitems()
+ items = d.items()
self.assertEqual(len(items), 2)
- self.assertEqual(set(items), set([(1, 10), ("a", "ABC")]))
- self.assertEqual(items, set([(1, 10), ("a", "ABC")]))
- self.assertNotEqual(items, set([(1, 10), ("a", "ABC"), "junk"]))
- self.assertNotEqual(items, set([(1, 10), ("a", "def")]))
- self.assertNotEqual(items, set([(1, 10)]))
+ self.assertEqual(set(items), {(1, 10), ("a", "ABC")})
+ self.assertEqual(items, {(1, 10), ("a", "ABC")})
+ self.assertNotEqual(items, {(1, 10), ("a", "ABC"), "junk"})
+ self.assertNotEqual(items, {(1, 10), ("a", "def")})
+ self.assertNotEqual(items, {(1, 10)})
self.assertNotEqual(items, 42)
self.assertIn((1, 10), items)
self.assertIn(("a", "ABC"), items)
@@ -51,36 +51,36 @@ class DictSetTest(unittest.TestCase):
self.assertNotIn((), items)
self.assertNotIn((1,), items)
self.assertNotIn((1, 2, 3), items)
- self.assertEqual(d.viewitems(), d.viewitems())
+ self.assertEqual(d.items(), d.items())
e = d.copy()
- self.assertEqual(d.viewitems(), e.viewitems())
+ self.assertEqual(d.items(), e.items())
e["a"] = "def"
- self.assertNotEqual(d.viewitems(), e.viewitems())
+ self.assertNotEqual(d.items(), e.items())
def test_dict_mixed_keys_items(self):
d = {(1, 1): 11, (2, 2): 22}
e = {1: 1, 2: 2}
- self.assertEqual(d.viewkeys(), e.viewitems())
- self.assertNotEqual(d.viewitems(), e.viewkeys())
+ self.assertEqual(d.keys(), e.items())
+ self.assertNotEqual(d.items(), e.keys())
def test_dict_values(self):
d = {1: 10, "a": "ABC"}
- values = d.viewvalues()
- self.assertEqual(set(values), set([10, "ABC"]))
+ values = d.values()
+ self.assertEqual(set(values), {10, "ABC"})
self.assertEqual(len(values), 2)
def test_dict_repr(self):
d = {1: 10, "a": "ABC"}
self.assertIsInstance(repr(d), str)
- r = repr(d.viewitems())
+ r = repr(d.items())
self.assertIsInstance(r, str)
self.assertTrue(r == "dict_items([('a', 'ABC'), (1, 10)])" or
r == "dict_items([(1, 10), ('a', 'ABC')])")
- r = repr(d.viewkeys())
+ r = repr(d.keys())
self.assertIsInstance(r, str)
self.assertTrue(r == "dict_keys(['a', 1])" or
r == "dict_keys([1, 'a'])")
- r = repr(d.viewvalues())
+ r = repr(d.values())
self.assertIsInstance(r, str)
self.assertTrue(r == "dict_values(['ABC', 10])" or
r == "dict_values([10, 'ABC'])")
@@ -89,66 +89,99 @@ class DictSetTest(unittest.TestCase):
d1 = {'a': 1, 'b': 2}
d2 = {'b': 3, 'c': 2}
d3 = {'d': 4, 'e': 5}
- self.assertEqual(d1.viewkeys() & d1.viewkeys(), {'a', 'b'})
- self.assertEqual(d1.viewkeys() & d2.viewkeys(), {'b'})
- self.assertEqual(d1.viewkeys() & d3.viewkeys(), set())
- self.assertEqual(d1.viewkeys() & set(d1.viewkeys()), {'a', 'b'})
- self.assertEqual(d1.viewkeys() & set(d2.viewkeys()), {'b'})
- self.assertEqual(d1.viewkeys() & set(d3.viewkeys()), set())
-
- self.assertEqual(d1.viewkeys() | d1.viewkeys(), {'a', 'b'})
- self.assertEqual(d1.viewkeys() | d2.viewkeys(), {'a', 'b', 'c'})
- self.assertEqual(d1.viewkeys() | d3.viewkeys(), {'a', 'b', 'd', 'e'})
- self.assertEqual(d1.viewkeys() | set(d1.viewkeys()), {'a', 'b'})
- self.assertEqual(d1.viewkeys() | set(d2.viewkeys()), {'a', 'b', 'c'})
- self.assertEqual(d1.viewkeys() | set(d3.viewkeys()),
+ self.assertEqual(d1.keys() & d1.keys(), {'a', 'b'})
+ self.assertEqual(d1.keys() & d2.keys(), {'b'})
+ self.assertEqual(d1.keys() & d3.keys(), set())
+ self.assertEqual(d1.keys() & set(d1.keys()), {'a', 'b'})
+ self.assertEqual(d1.keys() & set(d2.keys()), {'b'})
+ self.assertEqual(d1.keys() & set(d3.keys()), set())
+
+ self.assertEqual(d1.keys() | d1.keys(), {'a', 'b'})
+ self.assertEqual(d1.keys() | d2.keys(), {'a', 'b', 'c'})
+ self.assertEqual(d1.keys() | d3.keys(), {'a', 'b', 'd', 'e'})
+ self.assertEqual(d1.keys() | set(d1.keys()), {'a', 'b'})
+ self.assertEqual(d1.keys() | set(d2.keys()), {'a', 'b', 'c'})
+ self.assertEqual(d1.keys() | set(d3.keys()),
{'a', 'b', 'd', 'e'})
- self.assertEqual(d1.viewkeys() ^ d1.viewkeys(), set())
- self.assertEqual(d1.viewkeys() ^ d2.viewkeys(), {'a', 'c'})
- self.assertEqual(d1.viewkeys() ^ d3.viewkeys(), {'a', 'b', 'd', 'e'})
- self.assertEqual(d1.viewkeys() ^ set(d1.viewkeys()), set())
- self.assertEqual(d1.viewkeys() ^ set(d2.viewkeys()), {'a', 'c'})
- self.assertEqual(d1.viewkeys() ^ set(d3.viewkeys()),
+ self.assertEqual(d1.keys() ^ d1.keys(), set())
+ self.assertEqual(d1.keys() ^ d2.keys(), {'a', 'c'})
+ self.assertEqual(d1.keys() ^ d3.keys(), {'a', 'b', 'd', 'e'})
+ self.assertEqual(d1.keys() ^ set(d1.keys()), set())
+ self.assertEqual(d1.keys() ^ set(d2.keys()), {'a', 'c'})
+ self.assertEqual(d1.keys() ^ set(d3.keys()),
{'a', 'b', 'd', 'e'})
+ self.assertFalse(d1.keys().isdisjoint(d1.keys()))
+ self.assertFalse(d1.keys().isdisjoint(d2.keys()))
+ self.assertFalse(d1.keys().isdisjoint(list(d2.keys())))
+ self.assertFalse(d1.keys().isdisjoint(set(d2.keys())))
+ self.assertTrue(d1.keys().isdisjoint({'x', 'y', 'z'}))
+ self.assertTrue(d1.keys().isdisjoint(['x', 'y', 'z']))
+ self.assertTrue(d1.keys().isdisjoint(set(['x', 'y', 'z'])))
+ self.assertTrue(d1.keys().isdisjoint(set(['x', 'y'])))
+ self.assertTrue(d1.keys().isdisjoint(['x', 'y']))
+ self.assertTrue(d1.keys().isdisjoint({}))
+ self.assertTrue(d1.keys().isdisjoint(d3.keys()))
+
+ de = {}
+ self.assertTrue(de.keys().isdisjoint(set()))
+ self.assertTrue(de.keys().isdisjoint([]))
+ self.assertTrue(de.keys().isdisjoint(de.keys()))
+ self.assertTrue(de.keys().isdisjoint([1]))
+
def test_items_set_operations(self):
d1 = {'a': 1, 'b': 2}
d2 = {'a': 2, 'b': 2}
d3 = {'d': 4, 'e': 5}
self.assertEqual(
- d1.viewitems() & d1.viewitems(), {('a', 1), ('b', 2)})
- self.assertEqual(d1.viewitems() & d2.viewitems(), {('b', 2)})
- self.assertEqual(d1.viewitems() & d3.viewitems(), set())
- self.assertEqual(d1.viewitems() & set(d1.viewitems()),
+ d1.items() & d1.items(), {('a', 1), ('b', 2)})
+ self.assertEqual(d1.items() & d2.items(), {('b', 2)})
+ self.assertEqual(d1.items() & d3.items(), set())
+ self.assertEqual(d1.items() & set(d1.items()),
{('a', 1), ('b', 2)})
- self.assertEqual(d1.viewitems() & set(d2.viewitems()), {('b', 2)})
- self.assertEqual(d1.viewitems() & set(d3.viewitems()), set())
+ self.assertEqual(d1.items() & set(d2.items()), {('b', 2)})
+ self.assertEqual(d1.items() & set(d3.items()), set())
- self.assertEqual(d1.viewitems() | d1.viewitems(),
+ self.assertEqual(d1.items() | d1.items(),
{('a', 1), ('b', 2)})
- self.assertEqual(d1.viewitems() | d2.viewitems(),
+ self.assertEqual(d1.items() | d2.items(),
{('a', 1), ('a', 2), ('b', 2)})
- self.assertEqual(d1.viewitems() | d3.viewitems(),
+ self.assertEqual(d1.items() | d3.items(),
{('a', 1), ('b', 2), ('d', 4), ('e', 5)})
- self.assertEqual(d1.viewitems() | set(d1.viewitems()),
+ self.assertEqual(d1.items() | set(d1.items()),
{('a', 1), ('b', 2)})
- self.assertEqual(d1.viewitems() | set(d2.viewitems()),
+ self.assertEqual(d1.items() | set(d2.items()),
{('a', 1), ('a', 2), ('b', 2)})
- self.assertEqual(d1.viewitems() | set(d3.viewitems()),
+ self.assertEqual(d1.items() | set(d3.items()),
{('a', 1), ('b', 2), ('d', 4), ('e', 5)})
- self.assertEqual(d1.viewitems() ^ d1.viewitems(), set())
- self.assertEqual(d1.viewitems() ^ d2.viewitems(),
+ self.assertEqual(d1.items() ^ d1.items(), set())
+ self.assertEqual(d1.items() ^ d2.items(),
{('a', 1), ('a', 2)})
- self.assertEqual(d1.viewitems() ^ d3.viewitems(),
+ self.assertEqual(d1.items() ^ d3.items(),
{('a', 1), ('b', 2), ('d', 4), ('e', 5)})
+ self.assertFalse(d1.items().isdisjoint(d1.items()))
+ self.assertFalse(d1.items().isdisjoint(d2.items()))
+ self.assertFalse(d1.items().isdisjoint(list(d2.items())))
+ self.assertFalse(d1.items().isdisjoint(set(d2.items())))
+ self.assertTrue(d1.items().isdisjoint({'x', 'y', 'z'}))
+ self.assertTrue(d1.items().isdisjoint(['x', 'y', 'z']))
+ self.assertTrue(d1.items().isdisjoint(set(['x', 'y', 'z'])))
+ self.assertTrue(d1.items().isdisjoint(set(['x', 'y'])))
+ self.assertTrue(d1.items().isdisjoint({}))
+ self.assertTrue(d1.items().isdisjoint(d3.items()))
+ de = {}
+ self.assertTrue(de.items().isdisjoint(set()))
+ self.assertTrue(de.items().isdisjoint([]))
+ self.assertTrue(de.items().isdisjoint(de.items()))
+ self.assertTrue(de.items().isdisjoint([1]))
def test_main():
- test_support.run_unittest(DictSetTest)
+ support.run_unittest(DictSetTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_difflib.py b/Lib/test/test_difflib.py
index 310bf997825..325449aa557 100644
--- a/Lib/test/test_difflib.py
+++ b/Lib/test/test_difflib.py
@@ -1,5 +1,5 @@
import difflib
-from test.test_support import run_unittest, findfile
+from test.support import run_unittest, findfile
import unittest
import doctest
import sys
@@ -12,12 +12,14 @@ class TestWithAscii(unittest.TestCase):
self.assertEqual(list(sm.get_opcodes()),
[ ('insert', 0, 0, 0, 1),
('equal', 0, 100, 1, 101)])
+ self.assertEqual(sm.bpopular, set())
sm = difflib.SequenceMatcher(None, 'b' * 100, 'b' * 50 + 'a' + 'b' * 50)
self.assertAlmostEqual(sm.ratio(), 0.995, places=3)
self.assertEqual(list(sm.get_opcodes()),
[ ('equal', 0, 50, 0, 50),
('insert', 50, 50, 50, 51),
('equal', 50, 100, 51, 101)])
+ self.assertEqual(sm.bpopular, set())
def test_one_delete(self):
sm = difflib.SequenceMatcher(None, 'a' * 40 + 'c' + 'b' * 40, 'a' * 40 + 'b' * 40)
@@ -27,6 +29,19 @@ class TestWithAscii(unittest.TestCase):
('delete', 40, 41, 40, 40),
('equal', 41, 81, 40, 80)])
+ def test_bjunk(self):
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40)
+ self.assertEqual(sm.bjunk, set())
+
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x == ' ',
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+ self.assertEqual(sm.bjunk, {' '})
+
+ sm = difflib.SequenceMatcher(isjunk=lambda x: x in [' ', 'b'],
+ a='a' * 40 + 'b' * 40, b='a' * 44 + 'b' * 40 + ' ' * 20)
+ self.assertEqual(sm.bjunk, {' ', 'b'})
+
class TestAutojunk(unittest.TestCase):
"""Tests for the autojunk parameter added in 2.7"""
@@ -38,10 +53,12 @@ class TestAutojunk(unittest.TestCase):
sm = difflib.SequenceMatcher(None, seq1, seq2)
self.assertAlmostEqual(sm.ratio(), 0, places=3)
+ self.assertEqual(sm.bpopular, {'b'})
# Now turn the heuristic off
sm = difflib.SequenceMatcher(None, seq1, seq2, autojunk=False)
self.assertAlmostEqual(sm.ratio(), 0.9975, places=3)
+ self.assertEqual(sm.bpopular, set())
class TestSFbugs(unittest.TestCase):
@@ -55,9 +72,9 @@ class TestSFbugs(unittest.TestCase):
def test_comparing_empty_lists(self):
# Check fix for bug #979794
group_gen = difflib.SequenceMatcher(None, [], []).get_grouped_opcodes()
- self.assertRaises(StopIteration, group_gen.next)
+ self.assertRaises(StopIteration, next, group_gen)
diff_gen = difflib.unified_diff([], [])
- self.assertRaises(StopIteration, diff_gen.next)
+ self.assertRaises(StopIteration, next, diff_gen)
def test_added_tab_hint(self):
# Check fix for bug #1488943
diff --git a/Lib/test/test_dircache.py b/Lib/test/test_dircache.py
deleted file mode 100644
index c6ad31c56cb..00000000000
--- a/Lib/test/test_dircache.py
+++ /dev/null
@@ -1,77 +0,0 @@
-"""
- Test cases for the dircache module
- Nick Mathewson
-"""
-
-import unittest
-from test.test_support import run_unittest, import_module
-dircache = import_module('dircache', deprecated=True)
-import os, time, sys, tempfile
-
-
-class DircacheTests(unittest.TestCase):
- def setUp(self):
- self.tempdir = tempfile.mkdtemp()
-
- def tearDown(self):
- for fname in os.listdir(self.tempdir):
- self.delTemp(fname)
- os.rmdir(self.tempdir)
-
- def writeTemp(self, fname):
- f = open(os.path.join(self.tempdir, fname), 'w')
- f.close()
-
- def mkdirTemp(self, fname):
- os.mkdir(os.path.join(self.tempdir, fname))
-
- def delTemp(self, fname):
- fname = os.path.join(self.tempdir, fname)
- if os.path.isdir(fname):
- os.rmdir(fname)
- else:
- os.unlink(fname)
-
- def test_listdir(self):
- ## SUCCESSFUL CASES
- entries = dircache.listdir(self.tempdir)
- self.assertEqual(entries, [])
-
- # Check that cache is actually caching, not just passing through.
- self.assertTrue(dircache.listdir(self.tempdir) is entries)
-
- # Directories aren't "files" on Windows, and directory mtime has
- # nothing to do with when files under a directory get created.
- # That is, this test can't possibly work under Windows -- dircache
- # is only good for capturing a one-shot snapshot there.
-
- if sys.platform[:3] not in ('win', 'os2'):
- # Sadly, dircache has the same granularity as stat.mtime, and so
- # can't notice any changes that occurred within 1 sec of the last
- # time it examined a directory.
- time.sleep(1)
- self.writeTemp("test1")
- entries = dircache.listdir(self.tempdir)
- self.assertEqual(entries, ['test1'])
- self.assertTrue(dircache.listdir(self.tempdir) is entries)
-
- ## UNSUCCESSFUL CASES
- self.assertRaises(OSError, dircache.listdir, self.tempdir+"_nonexistent")
-
- def test_annotate(self):
- self.writeTemp("test2")
- self.mkdirTemp("A")
- lst = ['A', 'test2', 'test_nonexistent']
- dircache.annotate(self.tempdir, lst)
- self.assertEqual(lst, ['A/', 'test2', 'test_nonexistent'])
-
-
-def test_main():
- try:
- run_unittest(DircacheTests)
- finally:
- dircache.reset()
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 6ce4b79b466..5c59eaa01c8 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -1,25 +1,26 @@
# Minimal tests for dis module
-from test.test_support import run_unittest
+from test.support import run_unittest, captured_stdout
import unittest
import sys
import dis
-import StringIO
+import io
def _f(a):
- print a
+ print(a)
return 1
dis_f = """\
- %-4d 0 LOAD_FAST 0 (a)
- 3 PRINT_ITEM
- 4 PRINT_NEWLINE
+ %-4d 0 LOAD_GLOBAL 0 (print)
+ 3 LOAD_FAST 0 (a)
+ 6 CALL_FUNCTION 1
+ 9 POP_TOP
- %-4d 5 LOAD_CONST 1 (1)
- 8 RETURN_VALUE
-"""%(_f.func_code.co_firstlineno + 1,
- _f.func_code.co_firstlineno + 2)
+ %-4d 10 LOAD_CONST 1 (1)
+ 13 RETURN_VALUE
+""" % (_f.__code__.co_firstlineno + 1,
+ _f.__code__.co_firstlineno + 2)
def bug708901():
@@ -42,9 +43,9 @@ dis_bug708901 = """\
>> 25 POP_BLOCK
>> 26 LOAD_CONST 0 (None)
29 RETURN_VALUE
-"""%(bug708901.func_code.co_firstlineno + 1,
- bug708901.func_code.co_firstlineno + 2,
- bug708901.func_code.co_firstlineno + 3)
+""" % (bug708901.__code__.co_firstlineno + 1,
+ bug708901.__code__.co_firstlineno + 2,
+ bug708901.__code__.co_firstlineno + 3)
def bug1333982(x=[]):
@@ -54,27 +55,28 @@ def bug1333982(x=[]):
dis_bug1333982 = """\
%-4d 0 LOAD_CONST 1 (0)
- 3 POP_JUMP_IF_TRUE 41
- 6 LOAD_GLOBAL 0 (AssertionError)
- 9 BUILD_LIST 0
- 12 LOAD_FAST 0 (x)
- 15 GET_ITER
- >> 16 FOR_ITER 12 (to 31)
- 19 STORE_FAST 1 (s)
- 22 LOAD_FAST 1 (s)
- 25 LIST_APPEND 2
- 28 JUMP_ABSOLUTE 16
-
- %-4d >> 31 LOAD_CONST 2 (1)
- 34 BINARY_ADD
- 35 CALL_FUNCTION 1
- 38 RAISE_VARARGS 1
-
- %-4d >> 41 LOAD_CONST 0 (None)
- 44 RETURN_VALUE
-"""%(bug1333982.func_code.co_firstlineno + 1,
- bug1333982.func_code.co_firstlineno + 2,
- bug1333982.func_code.co_firstlineno + 3)
+ 3 JUMP_IF_TRUE 33 (to 39)
+ 6 POP_TOP
+ 7 LOAD_GLOBAL 0 (AssertionError)
+ 10 BUILD_LIST 0
+ 13 LOAD_FAST 0 (x)
+ 16 GET_ITER
+ >> 17 FOR_ITER 12 (to 32)
+ 20 STORE_FAST 1 (s)
+ 23 LOAD_FAST 1 (s)
+ 26 LIST_APPEND 2
+ 29 JUMP_ABSOLUTE 17
+
+ %-4d >> 32 LOAD_CONST 2 (1)
+ 35 BINARY_ADD
+ 36 RAISE_VARARGS 2
+ >> 39 POP_TOP
+
+ %-4d 40 LOAD_CONST 0 (None)
+ 43 RETURN_VALUE
+""" % (bug1333982.__code__.co_firstlineno + 1,
+ bug1333982.__code__.co_firstlineno + 2,
+ bug1333982.__code__.co_firstlineno + 3)
_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
@@ -83,9 +85,61 @@ _BIG_LINENO_FORMAT = """\
7 RETURN_VALUE
"""
+dis_module_expected_results = """\
+Disassembly of f:
+ 4 0 LOAD_CONST 0 (None)
+ 3 RETURN_VALUE
+
+Disassembly of g:
+ 5 0 LOAD_CONST 0 (None)
+ 3 RETURN_VALUE
+
+"""
+
+expr_str = "x + 1"
+
+dis_expr_str = """\
+ 1 0 LOAD_NAME 0 (x)
+ 3 LOAD_CONST 0 (1)
+ 6 BINARY_ADD
+ 7 RETURN_VALUE
+"""
+
+simple_stmt_str = "x = x + 1"
+
+dis_simple_stmt_str = """\
+ 1 0 LOAD_NAME 0 (x)
+ 3 LOAD_CONST 0 (1)
+ 6 BINARY_ADD
+ 7 STORE_NAME 0 (x)
+ 10 LOAD_CONST 1 (None)
+ 13 RETURN_VALUE
+"""
+
+compound_stmt_str = """\
+x = 0
+while 1:
+ x += 1"""
+# Trailing newline has been deliberately omitted
+
+dis_compound_stmt_str = """\
+ 1 0 LOAD_CONST 0 (0)
+ 3 STORE_NAME 0 (x)
+
+ 2 6 SETUP_LOOP 13 (to 22)
+
+ 3 >> 9 LOAD_NAME 0 (x)
+ 12 LOAD_CONST 1 (1)
+ 15 INPLACE_ADD
+ 16 STORE_NAME 0 (x)
+ 19 JUMP_ABSOLUTE 9
+ >> 22 LOAD_CONST 2 (None)
+ 25 RETURN_VALUE
+"""
+
class DisTests(unittest.TestCase):
def do_disassembly_test(self, func, expected):
- s = StringIO.StringIO()
+ s = io.StringIO()
save_stdout = sys.stdout
sys.stdout = s
dis.dis(func)
@@ -121,31 +175,197 @@ class DisTests(unittest.TestCase):
self.do_disassembly_test(bug708901, dis_bug708901)
def test_bug_1333982(self):
+ # XXX: re-enable this test!
# This one is checking bytecodes generated for an `assert` statement,
# so fails if the tests are run with -O. Skip this test then.
- if __debug__:
- self.do_disassembly_test(bug1333982, dis_bug1333982)
+ pass # Test has been disabled due to change in the way
+ # list comps are handled. The byte code now includes
+ # a memory address and a file location, so they change from
+ # run to run.
+ # if __debug__:
+ # self.do_disassembly_test(bug1333982, dis_bug1333982)
def test_big_linenos(self):
def func(count):
namespace = {}
func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])
- exec func in namespace
+ exec(func, namespace)
return namespace['foo']
# Test all small ranges
- for i in xrange(1, 300):
+ for i in range(1, 300):
expected = _BIG_LINENO_FORMAT % (i + 2)
self.do_disassembly_test(func(i), expected)
# Test some larger ranges too
- for i in xrange(300, 5000, 10):
+ for i in range(300, 5000, 10):
expected = _BIG_LINENO_FORMAT % (i + 2)
self.do_disassembly_test(func(i), expected)
-def test_main():
- run_unittest(DisTests)
+ def test_big_linenos(self):
+ from test import dis_module
+ self.do_disassembly_test(dis_module, dis_module_expected_results)
+
+ def test_disassemble_str(self):
+ self.do_disassembly_test(expr_str, dis_expr_str)
+ self.do_disassembly_test(simple_stmt_str, dis_simple_stmt_str)
+ self.do_disassembly_test(compound_stmt_str, dis_compound_stmt_str)
+
+code_info_code_info = """\
+Name: code_info
+Filename: (.*)
+Argument count: 1
+Kw-only arguments: 0
+Number of locals: 1
+Stack size: 4
+Flags: OPTIMIZED, NEWLOCALS, NOFREE
+Constants:
+ 0: %r
+ 1: '__func__'
+ 2: '__code__'
+ 3: '<code_info>'
+ 4: 'co_code'
+ 5: "don't know how to disassemble %%s objects"
+%sNames:
+ 0: hasattr
+ 1: __func__
+ 2: __code__
+ 3: isinstance
+ 4: str
+ 5: _try_compile
+ 6: _format_code_info
+ 7: TypeError
+ 8: type
+ 9: __name__
+Variable names:
+ 0: x""" % (('Formatted details of methods, functions, or code.', ' 6: None\n')
+ if sys.flags.optimize < 2 else (None, ''))
+
+@staticmethod
+def tricky(x, y, z=True, *args, c, d, e=[], **kwds):
+ def f(c=c):
+ print(x, y, z, c, d, e, f)
+ yield x, y, z, c, d, e, f
+
+code_info_tricky = """\
+Name: tricky
+Filename: (.*)
+Argument count: 3
+Kw-only arguments: 3
+Number of locals: 8
+Stack size: 7
+Flags: OPTIMIZED, NEWLOCALS, VARARGS, VARKEYWORDS, GENERATOR
+Constants:
+ 0: None
+ 1: <code object f at (.*), file "(.*)", line (.*)>
+Variable names:
+ 0: x
+ 1: y
+ 2: z
+ 3: c
+ 4: d
+ 5: e
+ 6: args
+ 7: kwds
+Cell variables:
+ 0: [edfxyz]
+ 1: [edfxyz]
+ 2: [edfxyz]
+ 3: [edfxyz]
+ 4: [edfxyz]
+ 5: [edfxyz]"""
+# NOTE: the order of the cell variables above depends on dictionary order!
+
+co_tricky_nested_f = tricky.__func__.__code__.co_consts[1]
+code_info_tricky_nested_f = """\
+Name: f
+Filename: (.*)
+Argument count: 1
+Kw-only arguments: 0
+Number of locals: 1
+Stack size: 8
+Flags: OPTIMIZED, NEWLOCALS, NESTED
+Constants:
+ 0: None
+Names:
+ 0: print
+Variable names:
+ 0: c
+Free variables:
+ 0: [edfxyz]
+ 1: [edfxyz]
+ 2: [edfxyz]
+ 3: [edfxyz]
+ 4: [edfxyz]
+ 5: [edfxyz]"""
+
+code_info_expr_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 1
+Names:
+ 0: x"""
+
+code_info_simple_stmt_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 1
+ 1: None
+Names:
+ 0: x"""
+
+code_info_compound_stmt_str = """\
+Name: <module>
+Filename: <code_info>
+Argument count: 0
+Kw-only arguments: 0
+Number of locals: 0
+Stack size: 2
+Flags: NOFREE
+Constants:
+ 0: 0
+ 1: 1
+ 2: None
+Names:
+ 0: x"""
+
+class CodeInfoTests(unittest.TestCase):
+ test_pairs = [
+ (dis.code_info, code_info_code_info),
+ (tricky, code_info_tricky),
+ (co_tricky_nested_f, code_info_tricky_nested_f),
+ (expr_str, code_info_expr_str),
+ (simple_stmt_str, code_info_simple_stmt_str),
+ (compound_stmt_str, code_info_compound_stmt_str),
+ ]
+
+ def test_code_info(self):
+ self.maxDiff = 1000
+ for x, expected in self.test_pairs:
+ self.assertRegex(dis.code_info(x), expected)
+
+ def test_show_code(self):
+ self.maxDiff = 1000
+ for x, expected in self.test_pairs:
+ with captured_stdout() as output:
+ dis.show_code(x)
+ self.assertRegex(output.getvalue(), expected+"\n")
+
+def test_main():
+ run_unittest(DisTests, CodeInfoTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_distutils.py b/Lib/test/test_distutils.py
index a9cbbb46a03..d613abe453b 100644
--- a/Lib/test/test_distutils.py
+++ b/Lib/test/test_distutils.py
@@ -5,13 +5,13 @@ the test_suite() function there returns a test suite that's ready to
be run.
"""
-from test import test_support
import distutils.tests
+import test.support
def test_main():
- test_support.run_unittest(distutils.tests.test_suite())
- test_support.reap_children()
+ test.support.run_unittest(distutils.tests.test_suite())
+ test.support.reap_children()
if __name__ == "__main__":
diff --git a/Lib/test/test_dl.py b/Lib/test/test_dl.py
deleted file mode 100755
index 6069a77bf1a..00000000000
--- a/Lib/test/test_dl.py
+++ /dev/null
@@ -1,39 +0,0 @@
-#! /usr/bin/env python
-"""Test dlmodule.c
- Roger E. Masse revised strategy by Barry Warsaw
-"""
-import unittest
-from test.test_support import verbose, import_module
-dl = import_module('dl', deprecated=True)
-
-sharedlibs = [
- ('/usr/lib/libc.so', 'getpid'),
- ('/lib/libc.so.6', 'getpid'),
- ('/usr/bin/cygwin1.dll', 'getpid'),
- ('/usr/lib/libc.dylib', 'getpid'),
- ]
-
-def test_main():
- for s, func in sharedlibs:
- try:
- if verbose:
- print 'trying to open:', s,
- l = dl.open(s)
- except dl.error, err:
- if verbose:
- print 'failed', repr(str(err))
- pass
- else:
- if verbose:
- print 'succeeded...',
- l.call(func)
- l.close()
- if verbose:
- print 'worked!'
- break
- else:
- raise unittest.SkipTest, 'Could not open any shared libraries'
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index 45057c87078..a6c17cc4320 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1,11 +1,11 @@
-# -*- coding: utf-8 -*-
"""
Test script for doctest.
"""
-import sys
-from test import test_support
+from test import support
import doctest
+import os
+
# NOTE: There are some additional tests relating to interaction with
# zipimport in the test_zipimport_support test module.
@@ -18,7 +18,7 @@ def sample_func(v):
"""
Blah blah
- >>> print sample_func(22)
+ >>> print(sample_func(22))
44
Yee ha!
@@ -27,7 +27,7 @@ def sample_func(v):
class SampleClass:
"""
- >>> print 1
+ >>> print(1)
1
>>> # comments get ignored. so are empty PS1 and PS2 prompts:
@@ -38,33 +38,33 @@ class SampleClass:
>>> sc = SampleClass(3)
>>> for i in range(10):
... sc = sc.double()
- ... print sc.get(),
- 6 12 24 48 96 192 384 768 1536 3072
+ ... print(' ', sc.get(), sep='', end='')
+ 6 12 24 48 96 192 384 768 1536 3072
"""
def __init__(self, val):
"""
- >>> print SampleClass(12).get()
+ >>> print(SampleClass(12).get())
12
"""
self.val = val
def double(self):
"""
- >>> print SampleClass(12).double().get()
+ >>> print(SampleClass(12).double().get())
24
"""
return SampleClass(self.val + self.val)
def get(self):
"""
- >>> print SampleClass(-5).get()
+ >>> print(SampleClass(-5).get())
-5
"""
return self.val
def a_staticmethod(v):
"""
- >>> print SampleClass.a_staticmethod(10)
+ >>> print(SampleClass.a_staticmethod(10))
11
"""
return v+1
@@ -72,16 +72,16 @@ class SampleClass:
def a_classmethod(cls, v):
"""
- >>> print SampleClass.a_classmethod(10)
+ >>> print(SampleClass.a_classmethod(10))
12
- >>> print SampleClass(0).a_classmethod(10)
+ >>> print(SampleClass(0).a_classmethod(10))
12
"""
return v+2
a_classmethod = classmethod(a_classmethod)
a_property = property(get, doc="""
- >>> print SampleClass(22).a_property
+ >>> print(SampleClass(22).a_property)
22
""")
@@ -89,12 +89,12 @@ class SampleClass:
"""
>>> x = SampleClass.NestedClass(5)
>>> y = x.square()
- >>> print y.get()
+ >>> print(y.get())
25
"""
def __init__(self, val=0):
"""
- >>> print SampleClass.NestedClass().get()
+ >>> print(SampleClass.NestedClass().get())
0
"""
self.val = val
@@ -105,28 +105,28 @@ class SampleClass:
class SampleNewStyleClass(object):
r"""
- >>> print '1\n2\n3'
+ >>> print('1\n2\n3')
1
2
3
"""
def __init__(self, val):
"""
- >>> print SampleNewStyleClass(12).get()
+ >>> print(SampleNewStyleClass(12).get())
12
"""
self.val = val
def double(self):
"""
- >>> print SampleNewStyleClass(12).double().get()
+ >>> print(SampleNewStyleClass(12).double().get())
24
"""
return SampleNewStyleClass(self.val + self.val)
def get(self):
"""
- >>> print SampleNewStyleClass(-5).get()
+ >>> print(SampleNewStyleClass(-5).get())
-5
"""
return self.val
@@ -147,7 +147,7 @@ class _FakeInput:
def readline(self):
line = self.lines.pop(0)
- print line
+ print(line)
return line+'\n'
######################################################################
@@ -170,10 +170,10 @@ Example is a simple container class that holds:
These attributes are set by the constructor. `source` and `want` are
required; the other attributes all have default values:
- >>> example = doctest.Example('print 1', '1\n')
+ >>> example = doctest.Example('print(1)', '1\n')
>>> (example.source, example.want, example.exc_msg,
... example.lineno, example.indent, example.options)
- ('print 1\n', '1\n', None, 0, 0, {})
+ ('print(1)\n', '1\n', None, 0, 0, {})
The first three attributes (`source`, `want`, and `exc_msg`) may be
specified positionally; the remaining arguments should be specified as
@@ -190,22 +190,22 @@ keyword arguments:
The constructor normalizes the `source` string to end in a newline:
Source spans a single line: no terminating newline.
- >>> e = doctest.Example('print 1', '1\n')
+ >>> e = doctest.Example('print(1)', '1\n')
>>> e.source, e.want
- ('print 1\n', '1\n')
+ ('print(1)\n', '1\n')
- >>> e = doctest.Example('print 1\n', '1\n')
+ >>> e = doctest.Example('print(1)\n', '1\n')
>>> e.source, e.want
- ('print 1\n', '1\n')
+ ('print(1)\n', '1\n')
Source spans multiple lines: require terminating newline.
- >>> e = doctest.Example('print 1;\nprint 2\n', '1\n2\n')
+ >>> e = doctest.Example('print(1);\nprint(2)\n', '1\n2\n')
>>> e.source, e.want
- ('print 1;\nprint 2\n', '1\n2\n')
+ ('print(1);\nprint(2)\n', '1\n2\n')
- >>> e = doctest.Example('print 1;\nprint 2', '1\n2\n')
+ >>> e = doctest.Example('print(1);\nprint(2)', '1\n2\n')
>>> e.source, e.want
- ('print 1;\nprint 2\n', '1\n2\n')
+ ('print(1);\nprint(2)\n', '1\n2\n')
Empty source string (which should never appear in real examples)
>>> e = doctest.Example('', '')
@@ -215,13 +215,13 @@ The constructor normalizes the `source` string to end in a newline:
The constructor normalizes the `want` string to end in a newline,
unless it's the empty string:
- >>> e = doctest.Example('print 1', '1\n')
+ >>> e = doctest.Example('print(1)', '1\n')
>>> e.source, e.want
- ('print 1\n', '1\n')
+ ('print(1)\n', '1\n')
- >>> e = doctest.Example('print 1', '1')
+ >>> e = doctest.Example('print(1)', '1')
>>> e.source, e.want
- ('print 1\n', '1\n')
+ ('print(1)\n', '1\n')
>>> e = doctest.Example('print', '')
>>> e.source, e.want
@@ -284,12 +284,12 @@ filename, and line number). The docstring is parsed by the `DocTest`
constructor:
>>> docstring = '''
- ... >>> print 12
+ ... >>> print(12)
... 12
...
... Non-example text.
...
- ... >>> print 'another\example'
+ ... >>> print('another\example')
... another
... example
... '''
@@ -297,15 +297,15 @@ constructor:
>>> parser = doctest.DocTestParser()
>>> test = parser.get_doctest(docstring, globs, 'some_test',
... 'some_file', 20)
- >>> print test
+ >>> print(test)
<DocTest some_test from some_file:20 (2 examples)>
>>> len(test.examples)
2
>>> e1, e2 = test.examples
>>> (e1.source, e1.want, e1.lineno)
- ('print 12\n', '12\n', 1)
+ ('print(12)\n', '12\n', 1)
>>> (e2.source, e2.want, e2.lineno)
- ("print 'another\\example'\n", 'another\nexample\n', 6)
+ ("print('another\\example')\n", 'another\nexample\n', 6)
Source information (name, filename, and line number) is available as
attributes on the doctest object:
@@ -326,7 +326,7 @@ If the docstring contains inconsistant leading whitespace in the
expected output of an example, then `DocTest` will raise a ValueError:
>>> docstring = r'''
- ... >>> print 'bad\nindentation'
+ ... >>> print('bad\nindentation')
... bad
... indentation
... '''
@@ -338,29 +338,29 @@ If the docstring contains inconsistent leading whitespace on
continuation lines, then `DocTest` will raise a ValueError:
>>> docstring = r'''
- ... >>> print ('bad indentation',
- ... ... 2)
+ ... >>> print(('bad indentation',
+ ... ... 2))
... ('bad', 'indentation')
... '''
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
- ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2)'
+ ValueError: line 2 of the docstring for some_test has inconsistent leading whitespace: '... 2))'
If there's no blank space after a PS1 prompt ('>>>'), then `DocTest`
will raise a ValueError:
- >>> docstring = '>>>print 1\n1'
+ >>> docstring = '>>>print(1)\n1'
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
- ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print 1'
+ ValueError: line 1 of the docstring for some_test lacks blank after >>>: '>>>print(1)'
If there's no blank space after a PS2 prompt ('...'), then `DocTest`
will raise a ValueError:
- >>> docstring = '>>> if 1:\n...print 1\n1'
+ >>> docstring = '>>> if 1:\n...print(1)\n1'
>>> parser.get_doctest(docstring, globs, 'some_test', 'filename', 0)
Traceback (most recent call last):
- ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print 1'
+ ValueError: line 2 of the docstring for some_test lacks blank after ...: '...print(1)'
Compare `DocTest`:
@@ -431,7 +431,7 @@ We'll simulate a __file__ attr that ends in pyc:
>>> tests = finder.find(sample_func)
- >>> print tests # doctest: +ELLIPSIS
+ >>> print(tests) # doctest: +ELLIPSIS
[<DocTest sample_func from ...:17 (1 example)>]
The exact name depends on how test_doctest was invoked, so allow for
@@ -445,7 +445,7 @@ leading path components.
>>> e = tests[0].examples[0]
>>> (e.source, e.want, e.lineno)
- ('print sample_func(22)\n', '44\n', 3)
+ ('print(sample_func(22))\n', '44\n', 3)
By default, tests are created for objects with no docstring:
@@ -483,7 +483,7 @@ methods, classmethods, staticmethods, properties, and nested classes.
>>> finder = doctest.DocTestFinder()
>>> tests = finder.find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -498,7 +498,7 @@ New-style classes are also supported:
>>> tests = finder.find(SampleNewStyleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
1 SampleNewStyleClass
1 SampleNewStyleClass.__init__
1 SampleNewStyleClass.double
@@ -515,7 +515,7 @@ functions, classes, and the `__test__` dictionary, if it exists:
>>> m = types.ModuleType('some_module')
>>> def triple(val):
... '''
- ... >>> print triple(11)
+ ... >>> print(triple(11))
... 33
... '''
... return val*3
@@ -524,11 +524,11 @@ functions, classes, and the `__test__` dictionary, if it exists:
... 'SampleClass': SampleClass,
... '__doc__': '''
... Module docstring.
- ... >>> print 'module'
+ ... >>> print('module')
... module
... ''',
... '__test__': {
- ... 'd': '>>> print 6\n6\n>>> print 7\n7\n',
+ ... 'd': '>>> print(6)\n6\n>>> print(7)\n7\n',
... 'c': triple}})
>>> finder = doctest.DocTestFinder()
@@ -537,7 +537,7 @@ functions, classes, and the `__test__` dictionary, if it exists:
>>> import test.test_doctest
>>> tests = finder.find(m, module=test.test_doctest)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
1 some_module
3 some_module.SampleClass
3 some_module.SampleClass.NestedClass
@@ -561,9 +561,9 @@ will only be generated for it once:
>>> assert doctest_aliases.TwoNames.f
>>> assert doctest_aliases.TwoNames.g
>>> tests = excl_empty_finder.find(doctest_aliases)
- >>> print len(tests)
+ >>> print(len(tests))
2
- >>> print tests[0].name
+ >>> print(tests[0].name)
test.doctest_aliases.TwoNames
TwoNames.f and TwoNames.g are bound to the same object.
@@ -579,7 +579,7 @@ By default, an object with no doctests doesn't create any tests:
>>> tests = doctest.DocTestFinder().find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -597,7 +597,7 @@ displays.
>>> tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
3 SampleClass.NestedClass
1 SampleClass.NestedClass.__init__
@@ -617,7 +617,7 @@ using the `recurse` flag:
>>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass)
>>> for t in tests:
- ... print '%2s %s' % (len(t.examples), t.name)
+ ... print('%2s %s' % (len(t.examples), t.name))
3 SampleClass
Line numbers
@@ -635,7 +635,7 @@ DocTestFinder finds the line number of each example:
... ...
...
... >>> for x in range(10):
- ... ... print x,
+ ... ... print(x, end=' ')
... 0 1 2 3 4 5 6 7 8 9
... >>> x//2
... 6
@@ -656,8 +656,8 @@ text:
>>> s = '''
... >>> x, y = 2, 3 # no output expected
... >>> if 1:
- ... ... print x
- ... ... print y
+ ... ... print(x)
+ ... ... print(y)
... 2
... 3
...
@@ -668,13 +668,13 @@ text:
>>> parser = doctest.DocTestParser()
>>> for piece in parser.parse(s):
... if isinstance(piece, doctest.Example):
- ... print 'Example:', (piece.source, piece.want, piece.lineno)
+ ... print('Example:', (piece.source, piece.want, piece.lineno))
... else:
- ... print ' Text:', `piece`
+ ... print(' Text:', repr(piece))
Text: '\n'
Example: ('x, y = 2, 3 # no output expected\n', '', 1)
Text: ''
- Example: ('if 1:\n print x\n print y\n', '2\n3\n', 2)
+ Example: ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
Text: '\nSome text.\n'
Example: ('x+y\n', '5\n', 9)
Text: ''
@@ -682,9 +682,9 @@ text:
The `get_examples` method returns just the examples:
>>> for piece in parser.get_examples(s):
- ... print (piece.source, piece.want, piece.lineno)
+ ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1)
- ('if 1:\n print x\n print y\n', '2\n3\n', 2)
+ ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
('x+y\n', '5\n', 9)
The `get_doctest` method creates a Test from the examples, along with the
@@ -694,9 +694,9 @@ given arguments:
>>> (test.name, test.filename, test.lineno)
('name', 'filename', 5)
>>> for piece in test.examples:
- ... print (piece.source, piece.want, piece.lineno)
+ ... print((piece.source, piece.want, piece.lineno))
('x, y = 2, 3 # no output expected\n', '', 1)
- ('if 1:\n print x\n print y\n', '2\n3\n', 2)
+ ('if 1:\n print(x)\n print(y)\n', '2\n3\n', 2)
('x+y\n', '5\n', 9)
"""
@@ -710,7 +710,7 @@ statistics. Here's a simple DocTest case we can use:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... >>> x//2
... 6
@@ -731,7 +731,7 @@ the failure and proceeds to the next example:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 14
... >>> x//2
... 6
@@ -744,13 +744,13 @@ the failure and proceeds to the next example:
Expecting nothing
ok
Trying:
- print x
+ print(x)
Expecting:
14
**********************************************************************
File ..., line 4, in f
Failed example:
- print x
+ print(x)
Expected:
14
Got:
@@ -769,7 +769,7 @@ output:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... >>> x//2
... 6
@@ -782,7 +782,7 @@ output:
Expecting nothing
ok
Trying:
- print x
+ print(x)
Expecting:
12
ok
@@ -812,7 +812,7 @@ iff `-v` appears in sys.argv:
Expecting nothing
ok
Trying:
- print x
+ print(x)
Expecting:
12
ok
@@ -839,7 +839,7 @@ replaced with any other string:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print x//0
+ ... >>> print(x//0)
... Traceback (most recent call last):
... ZeroDivisionError: integer division or modulo by zero
... '''
@@ -855,7 +855,7 @@ unexpected exception:
>>> def f(x):
... '''
... >>> x = 12
- ... >>> print 'pre-exception output', x//0
+ ... >>> print('pre-exception output', x//0)
... pre-exception output
... Traceback (most recent call last):
... ZeroDivisionError: integer division or modulo by zero
@@ -866,7 +866,7 @@ unexpected exception:
**********************************************************************
File ..., line 4, in f
Failed example:
- print 'pre-exception output', x//0
+ print('pre-exception output', x//0)
Exception raised:
...
ZeroDivisionError: integer division or modulo by zero
@@ -876,7 +876,7 @@ Exception messages may contain newlines:
>>> def f(x):
... r'''
- ... >>> raise ValueError, 'multi\nline\nmessage'
+ ... >>> raise ValueError('multi\nline\nmessage')
... Traceback (most recent call last):
... ValueError: multi
... line
@@ -891,7 +891,7 @@ message is raised, then it is reported as a failure:
>>> def f(x):
... r'''
- ... >>> raise ValueError, 'message'
+ ... >>> raise ValueError('message')
... Traceback (most recent call last):
... ValueError: wrong message
... '''
@@ -901,7 +901,7 @@ message is raised, then it is reported as a failure:
**********************************************************************
File ..., line 3, in f
Failed example:
- raise ValueError, 'message'
+ raise ValueError('message')
Expected:
Traceback (most recent call last):
ValueError: wrong message
@@ -916,7 +916,7 @@ detail:
>>> def f(x):
... r'''
- ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL
+ ... >>> raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... ValueError: wrong message
... '''
@@ -925,15 +925,15 @@ detail:
TestResults(failed=0, attempted=1)
IGNORE_EXCEPTION_DETAIL also ignores difference in exception formatting
-between Python versions. For example, in Python 3.x, the module path of
-the exception is in the output, but this will fail under Python 2:
+between Python versions. For example, in Python 2.x, the module path of
+the exception is not in the output, but this will fail under Python 3:
>>> def f(x):
... r'''
- ... >>> from httplib import HTTPException
+ ... >>> from http.client import HTTPException
... >>> raise HTTPException('message')
... Traceback (most recent call last):
- ... httplib.HTTPException: message
+ ... HTTPException: message
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
@@ -944,34 +944,34 @@ the exception is in the output, but this will fail under Python 2:
raise HTTPException('message')
Expected:
Traceback (most recent call last):
- httplib.HTTPException: message
+ HTTPException: message
Got:
Traceback (most recent call last):
...
- HTTPException: message
+ http.client.HTTPException: message
TestResults(failed=1, attempted=2)
-But in Python 2 the module path is not included, an therefore a test must look
-like the following test to succeed in Python 2. But that test will fail under
-Python 3.
+But in Python 3 the module path is included, and therefore a test must look
+like the following test to succeed in Python 3. But that test will fail under
+Python 2.
>>> def f(x):
... r'''
- ... >>> from httplib import HTTPException
+ ... >>> from http.client import HTTPException
... >>> raise HTTPException('message')
... Traceback (most recent call last):
- ... HTTPException: message
+ ... http.client.HTTPException: message
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
TestResults(failed=0, attempted=2)
However, with IGNORE_EXCEPTION_DETAIL, the module name of the exception
-(if any) will be ignored:
+(or its unexpected absence) will be ignored:
>>> def f(x):
... r'''
- ... >>> from httplib import HTTPException
+ ... >>> from http.client import HTTPException
... >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... HTTPException: message
@@ -986,7 +986,7 @@ be used when exceptions have changed module.
>>> def f(x):
... r'''
- ... >>> from httplib import HTTPException
+ ... >>> from http.client import HTTPException
... >>> raise HTTPException('message') #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... foo.bar.HTTPException: message
@@ -999,7 +999,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
>>> def f(x):
... r'''
- ... >>> raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL
+ ... >>> raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... TypeError: wrong type
... '''
@@ -1009,7 +1009,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
**********************************************************************
File ..., line 3, in f
Failed example:
- raise ValueError, 'message' #doctest: +IGNORE_EXCEPTION_DETAIL
+ raise ValueError('message') #doctest: +IGNORE_EXCEPTION_DETAIL
Expected:
Traceback (most recent call last):
TypeError: wrong type
@@ -1107,7 +1107,7 @@ The DONT_ACCEPT_BLANKLINE flag disables the match between blank lines
and the '<BLANKLINE>' marker:
>>> def f(x):
- ... '>>> print "a\\n\\nb"\na\n<BLANKLINE>\nb\n'
+ ... '>>> print("a\\n\\nb")\na\n<BLANKLINE>\nb\n'
>>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1122,7 +1122,7 @@ and the '<BLANKLINE>' marker:
**********************************************************************
File ..., line 2, in f
Failed example:
- print "a\n\nb"
+ print("a\n\nb")
Expected:
a
<BLANKLINE>
@@ -1137,7 +1137,7 @@ The NORMALIZE_WHITESPACE flag causes all sequences of whitespace to be
treated as equal:
>>> def f(x):
- ... '>>> print 1, 2, 3\n 1 2\n 3'
+ ... '>>> print(1, 2, 3)\n 1 2\n 3'
>>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1146,7 +1146,7 @@ treated as equal:
**********************************************************************
File ..., line 2, in f
Failed example:
- print 1, 2, 3
+ print(1, 2, 3)
Expected:
1 2
3
@@ -1161,7 +1161,7 @@ treated as equal:
TestResults(failed=0, attempted=1)
An example from the docs:
- >>> print range(20) #doctest: +NORMALIZE_WHITESPACE
+ >>> print(list(range(20))) #doctest: +NORMALIZE_WHITESPACE
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
@@ -1169,7 +1169,7 @@ The ELLIPSIS flag causes ellipsis marker ("...") in the expected
output to match any substring in the actual output:
>>> def f(x):
- ... '>>> print range(15)\n[0, 1, 2, ..., 14]\n'
+ ... '>>> print(list(range(15)))\n[0, 1, 2, ..., 14]\n'
>>> # Without the flag:
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1178,7 +1178,7 @@ output to match any substring in the actual output:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(15)
+ print(list(range(15)))
Expected:
[0, 1, 2, ..., 14]
Got:
@@ -1193,22 +1193,26 @@ output to match any substring in the actual output:
... also matches nothing:
- >>> for i in range(100):
- ... print i**2, #doctest: +ELLIPSIS
- 0 1...4...9 16 ... 36 49 64 ... 9801
+ >>> if 1:
+ ... for i in range(100):
+ ... print(i**2, end=' ') #doctest: +ELLIPSIS
+ ... print('!')
+ 0 1...4...9 16 ... 36 49 64 ... 9801 !
... can be surprising; e.g., this test passes:
- >>> for i in range(21): #doctest: +ELLIPSIS
- ... print i,
+ >>> if 1: #doctest: +ELLIPSIS
+ ... for i in range(20):
+ ... print(i, end=' ')
+ ... print(20)
0 1 2 ...1...2...0
Examples from the docs:
- >>> print range(20) # doctest:+ELLIPSIS
+ >>> print(list(range(20))) # doctest:+ELLIPSIS
[0, 1, ..., 18, 19]
- >>> print range(20) # doctest: +ELLIPSIS
+ >>> print(list(range(20))) # doctest: +ELLIPSIS
... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
@@ -1228,7 +1232,7 @@ which would be unavailable.) The SKIP flag can also be used for
UncheckedBlowUpError: Nobody checks me.
>>> import random
- >>> print random.random() # doctest: +SKIP
+ >>> print(random.random()) # doctest: +SKIP
0.721216923889
The REPORT_UDIFF flag causes failures that involve multi-line expected
@@ -1236,7 +1240,7 @@ and actual outputs to be displayed using a unified diff:
>>> def f(x):
... r'''
- ... >>> print '\n'.join('abcdefg')
+ ... >>> print('\n'.join('abcdefg'))
... a
... B
... c
@@ -1253,7 +1257,7 @@ and actual outputs to be displayed using a unified diff:
**********************************************************************
File ..., line 3, in f
Failed example:
- print '\n'.join('abcdefg')
+ print('\n'.join('abcdefg'))
Expected:
a
B
@@ -1280,7 +1284,7 @@ and actual outputs to be displayed using a unified diff:
**********************************************************************
File ..., line 3, in f
Failed example:
- print '\n'.join('abcdefg')
+ print('\n'.join('abcdefg'))
Differences (unified diff with -expected +actual):
@@ -1,7 +1,7 @@
a
@@ -1305,7 +1309,7 @@ and actual outputs to be displayed using a context diff:
**********************************************************************
File ..., line 3, in f
Failed example:
- print '\n'.join('abcdefg')
+ print('\n'.join('abcdefg'))
Differences (context diff with expected followed by actual):
***************
*** 1,7 ****
@@ -1333,7 +1337,7 @@ marking, as well as interline differences.
>>> def f(x):
... r'''
- ... >>> print "a b c d e f g h i j k l m"
+ ... >>> print("a b c d e f g h i j k l m")
... a b c d e f g h i j k 1 m
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1343,7 +1347,7 @@ marking, as well as interline differences.
**********************************************************************
File ..., line 3, in f
Failed example:
- print "a b c d e f g h i j k l m"
+ print("a b c d e f g h i j k l m")
Differences (ndiff with -expected +actual):
- a b c d e f g h i j k 1 m
? ^
@@ -1356,15 +1360,15 @@ failing example:
>>> def f(x):
... r'''
- ... >>> print 1 # first success
+ ... >>> print(1) # first success
... 1
- ... >>> print 2 # first failure
+ ... >>> print(2) # first failure
... 200
- ... >>> print 3 # second failure
+ ... >>> print(3) # second failure
... 300
- ... >>> print 4 # second success
+ ... >>> print(4) # second success
... 4
- ... >>> print 5 # third failure
+ ... >>> print(5) # third failure
... 500
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1374,7 +1378,7 @@ failing example:
**********************************************************************
File ..., line 5, in f
Failed example:
- print 2 # first failure
+ print(2) # first failure
Expected:
200
Got:
@@ -1386,18 +1390,18 @@ However, output from `report_start` is not suppressed:
>>> doctest.DocTestRunner(verbose=True, optionflags=flags).run(test)
... # doctest: +ELLIPSIS
Trying:
- print 1 # first success
+ print(1) # first success
Expecting:
1
ok
Trying:
- print 2 # first failure
+ print(2) # first failure
Expecting:
200
**********************************************************************
File ..., line 5, in f
Failed example:
- print 2 # first failure
+ print(2) # first failure
Expected:
200
Got:
@@ -1409,15 +1413,15 @@ count as failures:
>>> def f(x):
... r'''
- ... >>> print 1 # first success
+ ... >>> print(1) # first success
... 1
... >>> raise ValueError(2) # first failure
... 200
- ... >>> print 3 # second failure
+ ... >>> print(3) # second failure
... 300
- ... >>> print 4 # second success
+ ... >>> print(4) # second success
... 4
- ... >>> print 5 # third failure
+ ... >>> print(5) # third failure
... 500
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1463,10 +1467,10 @@ single example. To turn an option on for an example, follow that
example with a comment of the form ``# doctest: +OPTION``:
>>> def f(x): r'''
- ... >>> print range(10) # should fail: no ellipsis
+ ... >>> print(list(range(10))) # should fail: no ellipsis
... [0, 1, ..., 9]
...
- ... >>> print range(10) # doctest: +ELLIPSIS
+ ... >>> print(list(range(10))) # doctest: +ELLIPSIS
... [0, 1, ..., 9]
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1475,7 +1479,7 @@ example with a comment of the form ``# doctest: +OPTION``:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(10) # should fail: no ellipsis
+ print(list(range(10))) # should fail: no ellipsis
Expected:
[0, 1, ..., 9]
Got:
@@ -1486,11 +1490,11 @@ To turn an option off for an example, follow that example with a
comment of the form ``# doctest: -OPTION``:
>>> def f(x): r'''
- ... >>> print range(10)
+ ... >>> print(list(range(10)))
... [0, 1, ..., 9]
...
... >>> # should fail: no ellipsis
- ... >>> print range(10) # doctest: -ELLIPSIS
+ ... >>> print(list(range(10))) # doctest: -ELLIPSIS
... [0, 1, ..., 9]
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1500,7 +1504,7 @@ comment of the form ``# doctest: -OPTION``:
**********************************************************************
File ..., line 6, in f
Failed example:
- print range(10) # doctest: -ELLIPSIS
+ print(list(range(10))) # doctest: -ELLIPSIS
Expected:
[0, 1, ..., 9]
Got:
@@ -1511,13 +1515,13 @@ Option directives affect only the example that they appear with; they
do not change the options for surrounding examples:
>>> def f(x): r'''
- ... >>> print range(10) # Should fail: no ellipsis
+ ... >>> print(list(range(10))) # Should fail: no ellipsis
... [0, 1, ..., 9]
...
- ... >>> print range(10) # doctest: +ELLIPSIS
+ ... >>> print(list(range(10))) # doctest: +ELLIPSIS
... [0, 1, ..., 9]
...
- ... >>> print range(10) # Should fail: no ellipsis
+ ... >>> print(list(range(10))) # Should fail: no ellipsis
... [0, 1, ..., 9]
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1526,7 +1530,7 @@ do not change the options for surrounding examples:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(10) # Should fail: no ellipsis
+ print(list(range(10))) # Should fail: no ellipsis
Expected:
[0, 1, ..., 9]
Got:
@@ -1534,7 +1538,7 @@ do not change the options for surrounding examples:
**********************************************************************
File ..., line 8, in f
Failed example:
- print range(10) # Should fail: no ellipsis
+ print(list(range(10))) # Should fail: no ellipsis
Expected:
[0, 1, ..., 9]
Got:
@@ -1545,9 +1549,9 @@ Multiple options may be modified by a single option directive. They
may be separated by whitespace, commas, or both:
>>> def f(x): r'''
- ... >>> print range(10) # Should fail
+ ... >>> print(list(range(10))) # Should fail
... [0, 1, ..., 9]
- ... >>> print range(10) # Should succeed
+ ... >>> print(list(range(10))) # Should succeed
... ... # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
... [0, 1, ..., 9]
... '''
@@ -1557,7 +1561,7 @@ may be separated by whitespace, commas, or both:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(10) # Should fail
+ print(list(range(10))) # Should fail
Expected:
[0, 1, ..., 9]
Got:
@@ -1565,9 +1569,9 @@ may be separated by whitespace, commas, or both:
TestResults(failed=1, attempted=2)
>>> def f(x): r'''
- ... >>> print range(10) # Should fail
+ ... >>> print(list(range(10))) # Should fail
... [0, 1, ..., 9]
- ... >>> print range(10) # Should succeed
+ ... >>> print(list(range(10))) # Should succeed
... ... # doctest: +ELLIPSIS,+NORMALIZE_WHITESPACE
... [0, 1, ..., 9]
... '''
@@ -1577,7 +1581,7 @@ may be separated by whitespace, commas, or both:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(10) # Should fail
+ print(list(range(10))) # Should fail
Expected:
[0, 1, ..., 9]
Got:
@@ -1585,9 +1589,9 @@ may be separated by whitespace, commas, or both:
TestResults(failed=1, attempted=2)
>>> def f(x): r'''
- ... >>> print range(10) # Should fail
+ ... >>> print(list(range(10))) # Should fail
... [0, 1, ..., 9]
- ... >>> print range(10) # Should succeed
+ ... >>> print(list(range(10))) # Should succeed
... ... # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
... [0, 1, ..., 9]
... '''
@@ -1597,7 +1601,7 @@ may be separated by whitespace, commas, or both:
**********************************************************************
File ..., line 2, in f
Failed example:
- print range(10) # Should fail
+ print(list(range(10))) # Should fail
Expected:
[0, 1, ..., 9]
Got:
@@ -1608,7 +1612,7 @@ The option directive may be put on the line following the source, as
long as a continuation prompt is used:
>>> def f(x): r'''
- ... >>> print range(10)
+ ... >>> print(list(range(10)))
... ... # doctest: +ELLIPSIS
... [0, 1, ..., 9]
... '''
@@ -1621,12 +1625,12 @@ at the end of any line:
>>> def f(x): r'''
... >>> for x in range(10): # doctest: +ELLIPSIS
- ... ... print x,
- ... 0 1 2 ... 9
+ ... ... print(' ', x, end='', sep='')
+ ... 0 1 2 ... 9
...
... >>> for x in range(10):
- ... ... print x, # doctest: +ELLIPSIS
- ... 0 1 2 ... 9
+ ... ... print(' ', x, end='', sep='') # doctest: +ELLIPSIS
+ ... 0 1 2 ... 9
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
>>> doctest.DocTestRunner(verbose=False).run(test)
@@ -1638,7 +1642,7 @@ option directive, then they are combined:
>>> def f(x): r'''
... Should fail (option directive not on the last line):
... >>> for x in range(10): # doctest: +ELLIPSIS
- ... ... print x, # doctest: +NORMALIZE_WHITESPACE
+ ... ... print(x, end=' ') # doctest: +NORMALIZE_WHITESPACE
... 0 1 2...9
... '''
>>> test = doctest.DocTestFinder().find(f)[0]
@@ -1651,13 +1655,13 @@ It is an error to have a comment of the form ``# doctest:`` that is
`register_option`:
>>> # Error: Option not registered
- >>> s = '>>> print 12 #doctest: +BADOPTION'
+ >>> s = '>>> print(12) #doctest: +BADOPTION'
>>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
Traceback (most recent call last):
ValueError: line 1 of the doctest for s has an invalid option: '+BADOPTION'
>>> # Error: No + or - prefix
- >>> s = '>>> print 12 #doctest: ELLIPSIS'
+ >>> s = '>>> print(12) #doctest: ELLIPSIS'
>>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
Traceback (most recent call last):
ValueError: line 1 of the doctest for s has an invalid option: 'ELLIPSIS'
@@ -1669,33 +1673,7 @@ source:
>>> test = doctest.DocTestParser().get_doctest(s, {}, 's', 's.py', 0)
Traceback (most recent call last):
ValueError: line 0 of the doctest for s has an option directive on a line with no example: '# doctest: +ELLIPSIS'
-
- """
-
- def test_unicode_output(self): r"""
-
-Check that unicode output works:
-
- >>> u'\xe9'
- u'\xe9'
-
-If we return unicode, SpoofOut's buf variable becomes automagically
-converted to unicode. This means all subsequent output becomes converted
-to unicode, and if the output contains non-ascii characters that failed.
-It used to be that this state change carried on between tests, meaning
-tests would fail if unicode has been output previously in the testrun.
-This test tests that this is no longer so:
-
- >>> print u'abc'
- abc
-
-And then return a string with non-ascii characters:
-
- >>> print u'\xe9'.encode('utf-8')
- é
-
- """
-
+"""
def test_testsource(): r"""
Unit tests for `testsource()`.
@@ -1707,10 +1685,10 @@ words and expected output are converted to comments:
>>> import test.test_doctest
>>> name = 'test.test_doctest.sample_func'
- >>> print doctest.testsource(test.test_doctest, name)
+ >>> print(doctest.testsource(test.test_doctest, name))
# Blah blah
#
- print sample_func(22)
+ print(sample_func(22))
# Expected:
## 44
#
@@ -1718,8 +1696,8 @@ words and expected output are converted to comments:
<BLANKLINE>
>>> name = 'test.test_doctest.SampleNewStyleClass'
- >>> print doctest.testsource(test.test_doctest, name)
- print '1\n2\n3'
+ >>> print(doctest.testsource(test.test_doctest, name))
+ print('1\n2\n3')
# Expected:
## 1
## 2
@@ -1727,11 +1705,11 @@ words and expected output are converted to comments:
<BLANKLINE>
>>> name = 'test.test_doctest.SampleClass.a_classmethod'
- >>> print doctest.testsource(test.test_doctest, name)
- print SampleClass.a_classmethod(10)
+ >>> print(doctest.testsource(test.test_doctest, name))
+ print(SampleClass.a_classmethod(10))
# Expected:
## 12
- print SampleClass(0).a_classmethod(10)
+ print(SampleClass(0).a_classmethod(10))
# Expected:
## 12
<BLANKLINE>
@@ -1743,15 +1721,14 @@ Create a docstring that we want to debug:
>>> s = '''
... >>> x = 12
- ... >>> print x
+ ... >>> print(x)
... 12
... '''
Create some fake stdin input, to feed to the debugger:
- >>> import tempfile
>>> real_stdin = sys.stdin
- >>> sys.stdin = _FakeInput(['next', 'print x', 'continue'])
+ >>> sys.stdin = _FakeInput(['next', 'print(x)', 'continue'])
Run the debugger on the docstring, and then restore sys.stdin.
@@ -1762,7 +1739,7 @@ Run the debugger on the docstring, and then restore sys.stdin.
12
--Return--
> <string>(1)<module>()->None
- (Pdb) print x
+ (Pdb) print(x)
12
(Pdb) continue
@@ -1786,7 +1763,7 @@ def test_pdb_set_trace():
... >>> import pdb; pdb.set_trace()
... '''
>>> parser = doctest.DocTestParser()
- >>> test = parser.get_doctest(doc, {}, "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test = parser.get_doctest(doc, {}, "foo-bar@baz", "foo-bar@baz.py", 0)
>>> runner = doctest.DocTestRunner(verbose=False)
To demonstrate this, we'll create a fake standard input that
@@ -1795,16 +1772,16 @@ def test_pdb_set_trace():
>>> import tempfile
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
- ... 'print x', # print data defined by the example
+ ... 'print(x)', # print data defined by the example
... 'continue', # stop debugging
... ''])
>>> try: runner.run(test)
... finally: sys.stdin = real_stdin
--Return--
- > <doctest foo-bär@baz[2]>(1)<module>()->None
+ > <doctest foo-bar@baz[2]>(1)<module>()->None
-> import pdb; pdb.set_trace()
- (Pdb) print x
+ (Pdb) print(x)
42
(Pdb) continue
TestResults(failed=0, attempted=3)
@@ -1819,12 +1796,12 @@ def test_pdb_set_trace():
... >>> x=1
... >>> calls_set_trace()
... '''
- >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
- ... 'print y', # print data defined in the function
+ ... 'print(y)', # print data defined in the function
... 'up', # out of function
- ... 'print x', # print data defined by the example
+ ... 'print(x)', # print data defined by the example
... 'continue', # stop debugging
... ''])
@@ -1835,12 +1812,12 @@ def test_pdb_set_trace():
--Return--
> <doctest test.test_doctest.test_pdb_set_trace[8]>(3)calls_set_trace()->None
-> import pdb; pdb.set_trace()
- (Pdb) print y
+ (Pdb) print(y)
2
(Pdb) up
- > <doctest foo-bär@baz[1]>(1)<module>()
+ > <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
- (Pdb) print x
+ (Pdb) print(x)
1
(Pdb) continue
TestResults(failed=0, attempted=2)
@@ -1852,11 +1829,11 @@ def test_pdb_set_trace():
... >>> def f(x):
... ... g(x*2)
... >>> def g(x):
- ... ... print x+3
+ ... ... print(x+3)
... ... import pdb; pdb.set_trace()
... >>> f(3)
... '''
- >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
... 'list', # list source from example 2
@@ -1870,16 +1847,16 @@ def test_pdb_set_trace():
... finally: sys.stdin = real_stdin
... # doctest: +NORMALIZE_WHITESPACE
--Return--
- > <doctest foo-bär@baz[1]>(3)g()->None
+ > <doctest foo-bar@baz[1]>(3)g()->None
-> import pdb; pdb.set_trace()
(Pdb) list
1 def g(x):
- 2 print x+3
+ 2 print(x+3)
3 -> import pdb; pdb.set_trace()
[EOF]
(Pdb) next
--Return--
- > <doctest foo-bär@baz[0]>(2)f()->None
+ > <doctest foo-bar@baz[0]>(2)f()->None
-> g(x*2)
(Pdb) list
1 def f(x):
@@ -1887,14 +1864,14 @@ def test_pdb_set_trace():
[EOF]
(Pdb) next
--Return--
- > <doctest foo-bär@baz[2]>(1)<module>()->None
+ > <doctest foo-bar@baz[2]>(1)<module>()->None
-> f(3)
(Pdb) list
1 -> f(3)
[EOF]
(Pdb) continue
**********************************************************************
- File "foo-bär@baz.py", line 7, in foo-bär@baz
+ File "foo-bar@baz.py", line 7, in foo-bar@baz
Failed example:
f(3)
Expected nothing
@@ -1928,14 +1905,14 @@ def test_pdb_set_trace_nested():
... '''
>>> parser = doctest.DocTestParser()
>>> runner = doctest.DocTestRunner(verbose=False)
- >>> test = parser.get_doctest(doc, globals(), "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test = parser.get_doctest(doc, globals(), "foo-bar@baz", "foo-bar@baz.py", 0)
>>> real_stdin = sys.stdin
>>> sys.stdin = _FakeInput([
- ... 'print y', # print data defined in the function
- ... 'step', 'step', 'step', 'step', 'step', 'step', 'print z',
- ... 'up', 'print x',
- ... 'up', 'print y',
- ... 'up', 'print foo',
+ ... 'print(y)', # print data defined in the function
+ ... 'step', 'step', 'step', 'step', 'step', 'step', 'print(z)',
+ ... 'up', 'print(x)',
+ ... 'up', 'print(y)',
+ ... 'up', 'print(foo)',
... 'continue', # stop debugging
... ''])
@@ -1943,9 +1920,10 @@ def test_pdb_set_trace_nested():
... runner.run(test)
... finally:
... sys.stdin = real_stdin
+ ... # doctest: +REPORT_NDIFF
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1()
- (Pdb) print y
+ (Pdb) print(y)
1
(Pdb) step
--Call--
@@ -1967,22 +1945,22 @@ def test_pdb_set_trace_nested():
(Pdb) step
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(13)f2()
-> z = 2
- (Pdb) print z
+ (Pdb) print(z)
1
(Pdb) up
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(9)f1()
-> self.f2()
- (Pdb) print x
+ (Pdb) print(x)
1
(Pdb) up
> <doctest test.test_doctest.test_pdb_set_trace_nested[0]>(5)calls_set_trace()
-> self.f1()
- (Pdb) print y
+ (Pdb) print(y)
1
(Pdb) up
- > <doctest foo-bär@baz[1]>(1)<module>()
+ > <doctest foo-bar@baz[1]>(1)<module>()
-> calls_set_trace()
- (Pdb) print foo
+ (Pdb) print(foo)
*** NameError: name 'foo' is not defined
(Pdb) continue
TestResults(failed=0, attempted=2)
@@ -2113,7 +2091,7 @@ def test_DocFileSuite():
... 'test_doctest2.txt',
... 'test_doctest4.txt')
>>> suite.run(unittest.TestResult())
- <unittest.result.TestResult run=3 errors=0 failures=3>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
The test files are looked for in the directory containing the
calling module. A package keyword argument can be provided to
@@ -2125,7 +2103,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... package='test')
>>> suite.run(unittest.TestResult())
- <unittest.result.TestResult run=3 errors=0 failures=3>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
Support for using a package's __loader__.get_data() is also
provided.
@@ -2144,7 +2122,7 @@ def test_DocFileSuite():
... finally:
... if added_loader:
... del test.__loader__
- <unittest.result.TestResult run=3 errors=0 failures=3>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
'/' should be used as a path separator. It will be converted
to a native separator at run time:
@@ -2192,7 +2170,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... globs={'favorite_color': 'blue'})
>>> suite.run(unittest.TestResult())
- <unittest.result.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=1>
In this case, we supplied a missing favorite color. You can
provide doctest options:
@@ -2203,7 +2181,7 @@ def test_DocFileSuite():
... optionflags=doctest.DONT_ACCEPT_BLANKLINE,
... globs={'favorite_color': 'blue'})
>>> suite.run(unittest.TestResult())
- <unittest.result.TestResult run=3 errors=0 failures=3>
+ <unittest.result.TestResult run=3 errors=0 failures=2>
And, you can provide setUp and tearDown functions:
@@ -2222,7 +2200,7 @@ def test_DocFileSuite():
... 'test_doctest4.txt',
... setUp=setUp, tearDown=tearDown)
>>> suite.run(unittest.TestResult())
- <unittest.result.TestResult run=3 errors=0 failures=2>
+ <unittest.result.TestResult run=3 errors=0 failures=1>
But the tearDown restores sanity:
@@ -2273,7 +2251,7 @@ def test_trailing_space_in_test():
Trailing spaces in expected output are significant:
>>> x, y = 'foo', ''
- >>> print x, y
+ >>> print(x, y)
foo \n
"""
@@ -2290,7 +2268,7 @@ def test_unittest_reportflags():
... optionflags=doctest.DONT_ACCEPT_BLANKLINE)
>>> import unittest
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
@@ -2307,7 +2285,7 @@ def test_unittest_reportflags():
Now, when we run the test:
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
@@ -2328,16 +2306,16 @@ def test_unittest_reportflags():
Then the default eporting options are ignored:
>>> result = suite.run(unittest.TestResult())
- >>> print result.failures[0][1] # doctest: +ELLIPSIS
+ >>> print(result.failures[0][1]) # doctest: +ELLIPSIS
Traceback ...
Failed example:
favorite_color
...
Failed example:
if 1:
- print 'a'
- print
- print 'b'
+ print('a')
+ print()
+ print('b')
Differences (ndiff with -expected +actual):
a
- <BLANKLINE>
@@ -2428,9 +2406,9 @@ Verbosity can be increased with the optional `verbose` parameter:
ok
Trying:
if 1:
- print 'a'
- print
- print 'b'
+ print('a')
+ print()
+ print('b')
Expecting:
a
<BLANKLINE>
@@ -2477,190 +2455,101 @@ debugging):
>>> doctest.testfile('test_doctest.txt', raise_on_error=True)
... # doctest: +ELLIPSIS
Traceback (most recent call last):
- UnexpectedException: ...
+ doctest.UnexpectedException: ...
>>> doctest.master = None # Reset master.
If the tests contain non-ASCII characters, the tests might fail, since
it's unknown which encoding is used. The encoding can be specified
using the optional keyword argument `encoding`:
- >>> doctest.testfile('test_doctest4.txt') # doctest: +ELLIPSIS
+ >>> doctest.testfile('test_doctest4.txt', encoding='latin-1') # doctest: +ELLIPSIS
**********************************************************************
File "...", line 7, in test_doctest4.txt
Failed example:
- u'...'
+ '...'
Expected:
- u'f\xf6\xf6'
+ 'f\xf6\xf6'
Got:
- u'f\xc3\xb6\xc3\xb6'
+ 'f\xc3\xb6\xc3\xb6'
**********************************************************************
...
**********************************************************************
1 items had failures:
- 2 of 4 in test_doctest4.txt
+ 2 of 2 in test_doctest4.txt
***Test Failed*** 2 failures.
- TestResults(failed=2, attempted=4)
+ TestResults(failed=2, attempted=2)
>>> doctest.master = None # Reset master.
>>> doctest.testfile('test_doctest4.txt', encoding='utf-8')
- TestResults(failed=0, attempted=4)
+ TestResults(failed=0, attempted=2)
>>> doctest.master = None # Reset master.
-Switch the module encoding to 'utf-8' to test the verbose output without
-bothering with the current sys.stdout encoding.
+Test the verbose output:
- >>> doctest._encoding, saved_encoding = 'utf-8', doctest._encoding
>>> doctest.testfile('test_doctest4.txt', encoding='utf-8', verbose=True)
Trying:
- u'föö'
- Expecting:
- u'f\xf6\xf6'
- ok
- Trying:
- u'bÄ…r'
- Expecting:
- u'b\u0105r'
- ok
- Trying:
'föö'
Expecting:
- 'f\xc3\xb6\xc3\xb6'
+ 'f\xf6\xf6'
ok
Trying:
'bÄ…r'
Expecting:
- 'b\xc4\x85r'
+ 'b\u0105r'
ok
1 items passed all tests:
- 4 tests in test_doctest4.txt
- 4 tests in 1 items.
- 4 passed and 0 failed.
+ 2 tests in test_doctest4.txt
+ 2 tests in 1 items.
+ 2 passed and 0 failed.
Test passed.
- TestResults(failed=0, attempted=4)
- >>> doctest._encoding = saved_encoding
+ TestResults(failed=0, attempted=2)
>>> doctest.master = None # Reset master.
>>> sys.argv = save_argv
"""
-# old_test1, ... used to live in doctest.py, but cluttered it. Note
-# that these use the deprecated doctest.Tester, so should go away (or
-# be rewritten) someday.
-
-def old_test1(): r"""
->>> from doctest import Tester
->>> t = Tester(globs={'x': 42}, verbose=0)
->>> t.runstring(r'''
-... >>> x = x * 2
-... >>> print x
-... 42
-... ''', 'XYZ')
-**********************************************************************
-Line 3, in XYZ
-Failed example:
- print x
-Expected:
- 42
-Got:
- 84
-TestResults(failed=1, attempted=2)
->>> t.runstring(">>> x = x * 2\n>>> print x\n84\n", 'example2')
-TestResults(failed=0, attempted=2)
->>> t.summarize()
-**********************************************************************
-1 items had failures:
- 1 of 2 in XYZ
-***Test Failed*** 1 failures.
-TestResults(failed=1, attempted=4)
->>> t.summarize(verbose=1)
-1 items passed all tests:
- 2 tests in example2
-**********************************************************************
-1 items had failures:
- 1 of 2 in XYZ
-4 tests in 2 items.
-3 passed and 1 failed.
-***Test Failed*** 1 failures.
-TestResults(failed=1, attempted=4)
-"""
+def test_testmod(): r"""
+Tests for the testmod function. More might be useful, but for now we're just
+testing the case raised by Issue 6195, where trying to doctest a C module would
+fail with a UnicodeDecodeError because doctest tried to read the "source" lines
+out of the binary module.
-def old_test2(): r"""
- >>> from doctest import Tester
- >>> t = Tester(globs={}, verbose=1)
- >>> test = r'''
- ... # just an example
- ... >>> x = 1 + 2
- ... >>> x
- ... 3
- ... '''
- >>> t.runstring(test, "Example")
- Running string Example
- Trying:
- x = 1 + 2
- Expecting nothing
- ok
- Trying:
- x
- Expecting:
- 3
- ok
- 0 of 2 examples failed in string Example
- TestResults(failed=0, attempted=2)
+ >>> import unicodedata
+ >>> doctest.testmod(unicodedata, verbose=False)
+ TestResults(failed=0, attempted=0)
"""
-def old_test3(): r"""
- >>> from doctest import Tester
- >>> t = Tester(globs={}, verbose=0)
- >>> def _f():
- ... '''Trivial docstring example.
- ... >>> assert 2 == 2
- ... '''
- ... return 32
- ...
- >>> t.rundoc(_f) # expect 0 failures in 1 example
- TestResults(failed=0, attempted=1)
-"""
+try:
+ os.fsencode("foo-bär@baz.py")
+except UnicodeEncodeError:
+ # Skip the test: the filesystem encoding is unable to encode the filename
+ pass
+else:
+ def test_unicode(): """
+Check doctest with a non-ascii filename:
-def old_test4(): """
- >>> import types
- >>> m1 = types.ModuleType('_m1')
- >>> m2 = types.ModuleType('_m2')
- >>> test_data = \"""
- ... def _f():
- ... '''>>> assert 1 == 1
- ... '''
- ... def g():
- ... '''>>> assert 2 != 1
- ... '''
- ... class H:
- ... '''>>> assert 2 > 1
- ... '''
- ... def bar(self):
- ... '''>>> assert 1 < 2
- ... '''
- ... \"""
- >>> exec test_data in m1.__dict__
- >>> exec test_data in m2.__dict__
- >>> m1.__dict__.update({"f2": m2._f, "g2": m2.g, "h2": m2.H})
-
- Tests that objects outside m1 are excluded:
-
- >>> from doctest import Tester
- >>> t = Tester(globs={}, verbose=0)
- >>> t.rundict(m1.__dict__, "rundict_test", m1) # f2 and g2 and h2 skipped
- TestResults(failed=0, attempted=4)
-
- Once more, not excluding stuff outside m1:
-
- >>> t = Tester(globs={}, verbose=0)
- >>> t.rundict(m1.__dict__, "rundict_test_pvt") # None are skipped.
- TestResults(failed=0, attempted=8)
-
- The exclusion of objects from outside the designated module is
- meant to be invoked automagically by testmod.
-
- >>> doctest.testmod(m1, verbose=False)
- TestResults(failed=0, attempted=4)
-"""
+ >>> doc = '''
+ ... >>> raise Exception('clé')
+ ... '''
+ ...
+ >>> parser = doctest.DocTestParser()
+ >>> test = parser.get_doctest(doc, {}, "foo-bär@baz", "foo-bär@baz.py", 0)
+ >>> test
+ <DocTest foo-bär@baz from foo-bär@baz.py:0 (1 example)>
+ >>> runner = doctest.DocTestRunner(verbose=False)
+ >>> runner.run(test) # doctest: +ELLIPSIS
+ **********************************************************************
+ File "foo-bär@baz.py", line 2, in foo-bär@baz
+ Failed example:
+ raise Exception('clé')
+ Exception raised:
+ Traceback (most recent call last):
+ File ...
+ compileflags, 1), test.globs)
+ File "<doctest foo-bär@baz[0]>", line 1, in <module>
+ raise Exception('clé')
+ Exception: clé
+ TestResults(failed=1, attempted=1)
+ """
######################################################################
## Main
@@ -2668,29 +2557,20 @@ def old_test4(): """
def test_main():
# Check the doctest cases in doctest itself:
- test_support.run_doctest(doctest, verbosity=True)
-
+ support.run_doctest(doctest, verbosity=True)
+ # Check the doctest cases defined here:
from test import test_doctest
+ support.run_doctest(test_doctest, verbosity=True)
+
+import sys, re, io
- # Ignore all warnings about the use of class Tester in this module.
- deprecations = []
- if __debug__:
- deprecations.append(("class Tester is deprecated", DeprecationWarning))
- if sys.py3kwarning:
- deprecations += [("backquote not supported", SyntaxWarning),
- ("execfile.. not supported", DeprecationWarning)]
- with test_support.check_warnings(*deprecations):
- # Check the doctest cases defined here:
- test_support.run_doctest(test_doctest, verbosity=True)
-
-import sys
def test_coverage(coverdir):
- trace = test_support.import_module('trace')
+ trace = support.import_module('trace')
tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,],
trace=0, count=1)
- tracer.run('reload(doctest); test_main()')
+ tracer.run('test_main()')
r = tracer.results()
- print 'Writing coverage results...'
+ print('Writing coverage results...')
r.write_results(show_missing=True, summary=True,
coverdir=coverdir)
diff --git a/Lib/test/test_doctest.txt b/Lib/test/test_doctest.txt
index f8e851e1a5f..23446d1d224 100644
--- a/Lib/test/test_doctest.txt
+++ b/Lib/test/test_doctest.txt
@@ -9,9 +9,9 @@ already:
We can make this fail by disabling the blank-line feature.
>>> if 1:
- ... print 'a'
- ... print
- ... print 'b'
+ ... print('a')
+ ... print()
+ ... print('b')
a
<BLANKLINE>
b
diff --git a/Lib/test/test_doctest2.py b/Lib/test/test_doctest2.py
index 8c043baf5d1..347a1436410 100644
--- a/Lib/test/test_doctest2.py
+++ b/Lib/test/test_doctest2.py
@@ -1,8 +1,7 @@
-# -*- coding: utf-8 -*-
-u"""A module to test whether doctest recognizes some 2.2 features,
+"""A module to test whether doctest recognizes some 2.2 features,
like static and class methods.
->>> print 'yup' # 1
+>>> print('yup') # 1
yup
We include some (random) encoded (utf-8) text in the text surrounding
@@ -14,14 +13,14 @@ the example. It should be ignored:
import sys
import unittest
-from test import test_support
+from test import support
if sys.flags.optimize >= 2:
raise unittest.SkipTest("Cannot test docstrings with -O2")
class C(object):
- u"""Class C.
+ """Class C.
- >>> print C() # 2
+ >>> print(C()) # 2
42
@@ -35,13 +34,13 @@ class C(object):
def __init__(self):
"""C.__init__.
- >>> print C() # 3
+ >>> print(C()) # 3
42
"""
def __str__(self):
"""
- >>> print C() # 4
+ >>> print(C()) # 4
42
"""
return "42"
@@ -49,13 +48,13 @@ class C(object):
class D(object):
"""A nested D class.
- >>> print "In D!" # 5
+ >>> print("In D!") # 5
In D!
"""
def nested(self):
"""
- >>> print 3 # 6
+ >>> print(3) # 6
3
"""
@@ -63,7 +62,7 @@ class C(object):
"""
>>> c = C() # 7
>>> c.x = 12 # 8
- >>> print c.x # 9
+ >>> print(c.x) # 9
-12
"""
return -self._x
@@ -72,7 +71,7 @@ class C(object):
"""
>>> c = C() # 10
>>> c.x = 12 # 11
- >>> print c.x # 12
+ >>> print(c.x) # 12
-12
"""
self._x = value
@@ -80,7 +79,7 @@ class C(object):
x = property(getx, setx, doc="""\
>>> c = C() # 13
>>> c.x = 12 # 14
- >>> print c.x # 15
+ >>> print(c.x) # 15
-12
""")
@@ -89,9 +88,9 @@ class C(object):
"""
A static method.
- >>> print C.statm() # 16
+ >>> print(C.statm()) # 16
666
- >>> print C().statm() # 17
+ >>> print(C().statm()) # 17
666
"""
return 666
@@ -101,9 +100,9 @@ class C(object):
"""
A class method.
- >>> print C.clsm(22) # 18
+ >>> print(C.clsm(22)) # 18
22
- >>> print C().clsm(23) # 19
+ >>> print(C().clsm(23)) # 19
23
"""
return val
@@ -111,9 +110,9 @@ class C(object):
def test_main():
from test import test_doctest2
EXPECTED = 19
- f, t = test_support.run_doctest(test_doctest2)
+ f, t = support.run_doctest(test_doctest2)
if t != EXPECTED:
- raise test_support.TestFailed("expected %d tests to run, not %d" %
+ raise support.TestFailed("expected %d tests to run, not %d" %
(EXPECTED, t))
# Pollute the namespace with a bunch of imported functions and classes,
diff --git a/Lib/test/test_doctest3.txt b/Lib/test/test_doctest3.txt
index 54a96d58e14..dd8557e57a5 100644
--- a/Lib/test/test_doctest3.txt
+++ b/Lib/test/test_doctest3.txt
@@ -2,4 +2,4 @@
Here we check that `__file__` is provided:
>>> type(__file__)
- <type 'str'>
+ <class 'str'>
diff --git a/Lib/test/test_doctest4.txt b/Lib/test/test_doctest4.txt
index a219d16a6ea..0428e6f9632 100644
--- a/Lib/test/test_doctest4.txt
+++ b/Lib/test/test_doctest4.txt
@@ -4,14 +4,8 @@ This file is encoded using UTF-8.
In order to get this test to pass, we have to manually specify the
encoding.
- >>> u'föö'
- u'f\xf6\xf6'
-
- >>> u'bÄ…r'
- u'b\u0105r'
-
>>> 'föö'
- 'f\xc3\xb6\xc3\xb6'
+ 'f\xf6\xf6'
>>> 'bÄ…r'
- 'b\xc4\x85r'
+ 'b\u0105r'
diff --git a/Lib/test/test_docxmlrpc.py b/Lib/test/test_docxmlrpc.py
index 80d18036adf..d6ca45847ec 100644
--- a/Lib/test/test_docxmlrpc.py
+++ b/Lib/test/test_docxmlrpc.py
@@ -1,8 +1,8 @@
-from DocXMLRPCServer import DocXMLRPCServer
-import httplib
+from xmlrpc.server import DocXMLRPCServer
+import http.client
import sys
-from test import test_support
-threading = test_support.import_module('threading')
+from test import support
+threading = support.import_module('threading')
import time
import socket
import unittest
@@ -69,7 +69,7 @@ def server(evt, numrequests):
class DocXMLRPCHTTPGETServer(unittest.TestCase):
def setUp(self):
- self._threads = test_support.threading_setup()
+ self._threads = support.threading_setup()
# Enable server feedback
DocXMLRPCServer._send_traceback_header = True
@@ -82,7 +82,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
time.sleep(0.001)
n -= 1
- self.client = httplib.HTTPConnection("localhost:%d" % PORT)
+ self.client = http.client.HTTPConnection("localhost:%d" % PORT)
def tearDown(self):
self.client.close()
@@ -91,7 +91,7 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
# Disable server feedback
DocXMLRPCServer._send_traceback_header = False
- test_support.threading_cleanup(*self._threads)
+ support.threading_cleanup(*self._threads)
def test_valid_get_response(self):
self.client.request("GET", "/")
@@ -122,8 +122,8 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assertIn('<dl><dt><a name="-&lt;lambda&gt;"><strong>'
- '&lt;lambda&gt;</strong></a>(x, y)</dt></dl>',
+ self.assertIn((b'<dl><dt><a name="-&lt;lambda&gt;"><strong>'
+ b'&lt;lambda&gt;</strong></a>(x, y)</dt></dl>'),
response.read())
@make_request_and_skipIf(sys.flags.optimize >= 2,
@@ -136,19 +136,19 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
The documentation for the "add" method contains the test material.
"""
self.client.request("GET", "/")
- response = self.client.getresponse()
+ response = self.client.getresponse().read()
self.assertIn(
- ('<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>'
- '<tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;'
- 'follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">'
- 'PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>\nto&nbsp;do&nbsp;'
- 'with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">'
- 'RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;'
- 'and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>\nthat&nbsp;start&nbsp;'
- 'with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;'
- 'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">'
- 'http://google.com</a>.</tt></dd></dl>'), response.read())
+ (b'<dl><dt><a name="-add"><strong>add</strong></a>(x, y)</dt><dd>'
+ b'<tt>Add&nbsp;two&nbsp;instances&nbsp;together.&nbsp;This&nbsp;'
+ b'follows&nbsp;<a href="http://www.python.org/dev/peps/pep-0008/">'
+ b'PEP008</a>,&nbsp;but&nbsp;has&nbsp;nothing<br>\nto&nbsp;do&nbsp;'
+ b'with&nbsp;<a href="http://www.rfc-editor.org/rfc/rfc1952.txt">'
+ b'RFC1952</a>.&nbsp;Case&nbsp;should&nbsp;matter:&nbsp;pEp008&nbsp;'
+ b'and&nbsp;rFC1952.&nbsp;&nbsp;Things<br>\nthat&nbsp;start&nbsp;'
+ b'with&nbsp;http&nbsp;and&nbsp;ftp&nbsp;should&nbsp;be&nbsp;'
+ b'auto-linked,&nbsp;too:<br>\n<a href="http://google.com">'
+ b'http://google.com</a>.</tt></dd></dl>'), response)
@make_request_and_skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@@ -159,31 +159,28 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
systems related to that process.
"""
self.client.request("GET", "/")
- response = self.client.getresponse()
+ response = self.client.getresponse().read()
self.assertIn(
- ('<dl><dt><a name="-system.listMethods"><strong>system.listMethods'
- '</strong></a>()</dt><dd><tt><a href="#-system.listMethods">system'
- '.listMethods</a>()&nbsp;=&gt;&nbsp;[\'add\',&nbsp;\'subtract\','
- '&nbsp;\'multiple\']<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;list'
- '&nbsp;of&nbsp;the&nbsp;methods&nbsp;supported&nbsp;by&nbsp;the'
- '&nbsp;server.</tt></dd></dl>\n <dl><dt><a name="-system.methodHelp">'
- '<strong>system.methodHelp</strong></a>(method_name)</dt><dd><tt>'
- '<a href="#-system.methodHelp">system.methodHelp</a>(\'add\')&nbsp;'
- '=&gt;&nbsp;"Adds&nbsp;two&nbsp;integers&nbsp;together"<br>\n&nbsp;'
- '<br>\nReturns&nbsp;a&nbsp;string&nbsp;containing&nbsp;documentation'
- '&nbsp;for&nbsp;the&nbsp;specified&nbsp;method.</tt></dd></dl>\n '
- '<dl><dt><a name="-system.methodSignature"><strong>system.'
- 'methodSignature</strong></a>(method_name)</dt><dd><tt><a href="#-'
- 'system.methodSignature">system.methodSignature</a>(\'add\')&nbsp;'
- '=&gt;&nbsp;[double,&nbsp;int,&nbsp;int]<br>\n&nbsp;<br>\nReturns'
- '&nbsp;a&nbsp;list&nbsp;describing&nbsp;the&nbsp;signature&nbsp;of'
- '&nbsp;the&nbsp;method.&nbsp;In&nbsp;the<br>\nabove&nbsp;example,'
- '&nbsp;the&nbsp;add&nbsp;method&nbsp;takes&nbsp;two&nbsp;integers'
- '&nbsp;as&nbsp;arguments<br>\nand&nbsp;returns&nbsp;a&nbsp;double'
- '&nbsp;result.<br>\n&nbsp;<br>\nThis&nbsp;server&nbsp;does&nbsp;'
- 'NOT&nbsp;support&nbsp;system.methodSignature.</tt></dd></dl>'),
- response.read())
+ (b'<dl><dt><a name="-system.methodHelp"><strong>system.methodHelp'
+ b'</strong></a>(method_name)</dt><dd><tt><a href="#-system.method'
+ b'Help">system.methodHelp</a>(\'add\')&nbsp;=&gt;&nbsp;"Adds&nbsp;'
+ b'two&nbsp;integers&nbsp;together"<br>\n&nbsp;<br>\nReturns&nbsp;a'
+ b'&nbsp;string&nbsp;containing&nbsp;documentation&nbsp;for&nbsp;'
+ b'the&nbsp;specified&nbsp;method.</tt></dd></dl>\n<dl><dt><a name'
+ b'="-system.methodSignature"><strong>system.methodSignature</strong>'
+ b'</a>(method_name)</dt><dd><tt><a href="#-system.methodSignature">'
+ b'system.methodSignature</a>(\'add\')&nbsp;=&gt;&nbsp;[double,&nbsp;'
+ b'int,&nbsp;int]<br>\n&nbsp;<br>\nReturns&nbsp;a&nbsp;list&nbsp;'
+ b'describing&nbsp;the&nbsp;signature&nbsp;of&nbsp;the&nbsp;method.'
+ b'&nbsp;In&nbsp;the<br>\nabove&nbsp;example,&nbsp;the&nbsp;add&nbsp;'
+ b'method&nbsp;takes&nbsp;two&nbsp;integers&nbsp;as&nbsp;arguments'
+ b'<br>\nand&nbsp;returns&nbsp;a&nbsp;double&nbsp;result.<br>\n&nbsp;'
+ b'<br>\nThis&nbsp;server&nbsp;does&nbsp;NOT&nbsp;support&nbsp;system'
+ b'.methodSignature.</tt></dd></dl>\n<dl><dt><a name="-test_method">'
+ b'<strong>test_method</strong></a>(arg)</dt><dd><tt>Test&nbsp;'
+ b'method\'s&nbsp;docs.&nbsp;This&nbsp;method&nbsp;truly&nbsp;does'
+ b'&nbsp;very&nbsp;little.</tt></dd></dl>'), response)
def test_autolink_dotted_methods(self):
"""Test that selfdot values are made strong automatically in the
@@ -191,11 +188,11 @@ class DocXMLRPCHTTPGETServer(unittest.TestCase):
self.client.request("GET", "/")
response = self.client.getresponse()
- self.assertIn("""Try&nbsp;self.<strong>add</strong>,&nbsp;too.""",
+ self.assertIn(b"""Try&nbsp;self.<strong>add</strong>,&nbsp;too.""",
response.read())
def test_main():
- test_support.run_unittest(DocXMLRPCHTTPGETServer)
+ support.run_unittest(DocXMLRPCHTTPGETServer)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_dummy_thread.py b/Lib/test/test_dummy_thread.py
index d9bdd3c3c08..c61078d6201 100644
--- a/Lib/test/test_dummy_thread.py
+++ b/Lib/test/test_dummy_thread.py
@@ -5,15 +5,15 @@ to be used, test_main() can be called with the module to use as the thread
implementation as its sole argument.
"""
-import dummy_thread as _thread
+import _dummy_thread as _thread
import time
-import Queue
+import queue
import random
import unittest
-from test import test_support
+from test import support
-DELAY = 0 # Set > 0 when testing a module other than dummy_thread, such as
- # the 'thread' module.
+DELAY = 0 # Set > 0 when testing a module other than _dummy_thread, such as
+ # the '_thread' module.
class LockTests(unittest.TestCase):
"""Test lock objects."""
@@ -72,14 +72,14 @@ class LockTests(unittest.TestCase):
self.lock.acquire()
start_time = int(time.time())
_thread.start_new_thread(delay_unlock,(self.lock, DELAY))
- if test_support.verbose:
- print
- print "*** Waiting for thread to release the lock "\
- "(approx. %s sec.) ***" % DELAY
+ if support.verbose:
+ print()
+ print("*** Waiting for thread to release the lock "\
+ "(approx. %s sec.) ***" % DELAY)
self.lock.acquire()
end_time = int(time.time())
- if test_support.verbose:
- print "done"
+ if support.verbose:
+ print("done")
self.assertTrue((end_time - start_time) >= DELAY,
"Blocking by unconditional acquiring failed.")
@@ -125,7 +125,7 @@ class ThreadTests(unittest.TestCase):
"""Use to test _thread.start_new_thread() passes args properly."""
queue.put((arg1, arg2))
- testing_queue = Queue.Queue(1)
+ testing_queue = queue.Queue(1)
_thread.start_new_thread(arg_tester, (testing_queue, True, True))
result = testing_queue.get()
self.assertTrue(result[0] and result[1],
@@ -149,12 +149,12 @@ class ThreadTests(unittest.TestCase):
queue.put(_thread.get_ident())
thread_count = 5
- testing_queue = Queue.Queue(thread_count)
- if test_support.verbose:
- print
- print "*** Testing multiple thread creation "\
- "(will take approx. %s to %s sec.) ***" % (DELAY, thread_count)
- for count in xrange(thread_count):
+ testing_queue = queue.Queue(thread_count)
+ if support.verbose:
+ print()
+ print("*** Testing multiple thread creation "\
+ "(will take approx. %s to %s sec.) ***" % (DELAY, thread_count))
+ for count in range(thread_count):
if DELAY:
local_delay = round(random.random(), 1)
else:
@@ -162,8 +162,8 @@ class ThreadTests(unittest.TestCase):
_thread.start_new_thread(queue_mark,
(testing_queue, local_delay))
time.sleep(DELAY)
- if test_support.verbose:
- print 'done'
+ if support.verbose:
+ print('done')
self.assertTrue(testing_queue.qsize() == thread_count,
"Not all %s threads executed properly after %s sec." %
(thread_count, DELAY))
@@ -173,10 +173,10 @@ def test_main(imported_module=None):
if imported_module:
_thread = imported_module
DELAY = 2
- if test_support.verbose:
- print
- print "*** Using %s as _thread module ***" % _thread
- test_support.run_unittest(LockTests, MiscTests, ThreadTests)
+ if support.verbose:
+ print()
+ print("*** Using %s as _thread module ***" % _thread)
+ support.run_unittest(LockTests, MiscTests, ThreadTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_dummy_threading.py b/Lib/test/test_dummy_threading.py
index 2f59d5f9811..6ec5da3835a 100644
--- a/Lib/test/test_dummy_threading.py
+++ b/Lib/test/test_dummy_threading.py
@@ -1,4 +1,4 @@
-from test import test_support
+from test import support
import unittest
import dummy_threading as _threading
import time
@@ -15,21 +15,21 @@ class DummyThreadingTestCase(unittest.TestCase):
# module.
#delay = random.random() * 2
delay = 0
- if test_support.verbose:
- print 'task', self.name, 'will run for', delay, 'sec'
+ if support.verbose:
+ print('task', self.name, 'will run for', delay, 'sec')
sema.acquire()
mutex.acquire()
running += 1
- if test_support.verbose:
- print running, 'tasks are running'
+ if support.verbose:
+ print(running, 'tasks are running')
mutex.release()
time.sleep(delay)
- if test_support.verbose:
- print 'task', self.name, 'done'
+ if support.verbose:
+ print('task', self.name, 'done')
mutex.acquire()
running -= 1
- if test_support.verbose:
- print self.name, 'is finished.', running, 'tasks are running'
+ if support.verbose:
+ print(self.name, 'is finished.', running, 'tasks are running')
mutex.release()
sema.release()
@@ -49,15 +49,16 @@ class DummyThreadingTestCase(unittest.TestCase):
self.threads.append(t)
t.start()
- if test_support.verbose:
- print 'waiting for all tasks to complete'
+ if support.verbose:
+ print('waiting for all tasks to complete')
for t in self.threads:
t.join()
- if test_support.verbose:
- print 'all tasks done'
+ if support.verbose:
+ print('all tasks done')
def test_main():
- test_support.run_unittest(DummyThreadingTestCase)
+ support.run_unittest(DummyThreadingTestCase)
+
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_dynamic.py b/Lib/test/test_dynamic.py
new file mode 100644
index 00000000000..beb7b1cdf1c
--- /dev/null
+++ b/Lib/test/test_dynamic.py
@@ -0,0 +1,143 @@
+# Test the most dynamic corner cases of Python's runtime semantics.
+
+import builtins
+import contextlib
+import unittest
+
+from test.support import run_unittest, swap_item, swap_attr
+
+
+class RebindBuiltinsTests(unittest.TestCase):
+
+ """Test all the ways that we can change/shadow globals/builtins."""
+
+ def configure_func(self, func, *args):
+ """Perform TestCase-specific configuration on a function before testing.
+
+ By default, this does nothing. Example usage: spinning a function so
+ that a JIT will optimize it. Subclasses should override this as needed.
+
+ Args:
+ func: function to configure.
+ *args: any arguments that should be passed to func, if calling it.
+
+ Returns:
+ Nothing. Work will be performed on func in-place.
+ """
+ pass
+
+ def test_globals_shadow_builtins(self):
+ # Modify globals() to shadow an entry in builtins.
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_item(globals(), "len", lambda x: 7):
+ self.assertEqual(foo(), 7)
+
+ def test_modify_builtins(self):
+ # Modify the builtins module directly.
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_attr(builtins, "len", lambda x: 7):
+ self.assertEqual(foo(), 7)
+
+ def test_modify_builtins_while_generator_active(self):
+ # Modify the builtins out from under a live generator.
+ def foo():
+ x = range(3)
+ yield len(x)
+ yield len(x)
+ self.configure_func(foo)
+
+ g = foo()
+ self.assertEqual(next(g), 3)
+ with swap_attr(builtins, "len", lambda x: 7):
+ self.assertEqual(next(g), 7)
+
+ def test_modify_builtins_from_leaf_function(self):
+ # Verify that modifications made by leaf functions percolate up the
+ # callstack.
+ with swap_attr(builtins, "len", len):
+ def bar():
+ builtins.len = lambda x: 4
+
+ def foo(modifier):
+ l = []
+ l.append(len(range(7)))
+ modifier()
+ l.append(len(range(7)))
+ return l
+ self.configure_func(foo, lambda: None)
+
+ self.assertEqual(foo(bar), [7, 4])
+
+ def test_cannot_change_globals_or_builtins_with_eval(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ # Note that this *doesn't* change the definition of len() seen by foo().
+ builtins_dict = {"len": lambda x: 7}
+ globals_dict = {"foo": foo, "__builtins__": builtins_dict,
+ "len": lambda x: 8}
+ self.assertEqual(eval("foo()", globals_dict), 3)
+
+ self.assertEqual(eval("foo()", {"foo": foo}), 3)
+
+ def test_cannot_change_globals_or_builtins_with_exec(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ globals_dict = {"foo": foo}
+ exec("x = foo()", globals_dict)
+ self.assertEqual(globals_dict["x"], 3)
+
+ # Note that this *doesn't* change the definition of len() seen by foo().
+ builtins_dict = {"len": lambda x: 7}
+ globals_dict = {"foo": foo, "__builtins__": builtins_dict,
+ "len": lambda x: 8}
+
+ exec("x = foo()", globals_dict)
+ self.assertEqual(globals_dict["x"], 3)
+
+ def test_cannot_replace_builtins_dict_while_active(self):
+ def foo():
+ x = range(3)
+ yield len(x)
+ yield len(x)
+ self.configure_func(foo)
+
+ g = foo()
+ self.assertEqual(next(g), 3)
+ with swap_item(globals(), "__builtins__", {"len": lambda x: 7}):
+ self.assertEqual(next(g), 3)
+
+ def test_cannot_replace_builtins_dict_between_calls(self):
+ def foo():
+ return len([1, 2, 3])
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 3)
+ with swap_item(globals(), "__builtins__", {"len": lambda x: 7}):
+ self.assertEqual(foo(), 3)
+
+ def test_eval_gives_lambda_custom_globals(self):
+ globals_dict = {"len": lambda x: 7}
+ foo = eval("lambda: len([])", globals_dict)
+ self.configure_func(foo)
+
+ self.assertEqual(foo(), 7)
+
+
+def test_main():
+ run_unittest(RebindBuiltinsTests)
+
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index cb4ee6083e4..5eebba5590c 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -1,12 +1,14 @@
-# Copyright (C) 2001,2002 Python Software Foundation
+# Copyright (C) 2001-2007 Python Software Foundation
# email package unit tests
# The specific tests now live in Lib/email/test
from email.test.test_email import suite
-from test import test_support
+from email.test.test_email_codecs import suite as codecs_suite
+from test import support
def test_main():
- test_support.run_unittest(suite())
+ support.run_unittest(suite())
+ support.run_unittest(codecs_suite())
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_email_codecs.py b/Lib/test/test_email_codecs.py
deleted file mode 100644
index 8951f81b119..00000000000
--- a/Lib/test/test_email_codecs.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (C) 2002 Python Software Foundation
-# email package unit tests for (optional) Asian codecs
-
-# The specific tests now live in Lib/email/test
-from email.test import test_email_codecs
-from email.test import test_email_codecs_renamed
-from test import test_support
-
-def test_main():
- suite = test_email_codecs.suite()
- suite.addTest(test_email_codecs_renamed.suite())
- test_support.run_unittest(suite)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_email_renamed.py b/Lib/test/test_email_renamed.py
deleted file mode 100644
index 2c814dfdec8..00000000000
--- a/Lib/test/test_email_renamed.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (C) 2001-2006 Python Software Foundation
-# email package unit tests
-
-# The specific tests now live in Lib/email/test
-from email.test.test_email_renamed import suite
-from test import test_support
-
-def test_main():
- test_support.run_unittest(suite())
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py
index 6b9ff79aa1a..095820b45fb 100644
--- a/Lib/test/test_enumerate.py
+++ b/Lib/test/test_enumerate.py
@@ -1,7 +1,7 @@
import unittest
import sys
-from test import test_support
+from test import support
class G:
'Sequence using __getitem__'
@@ -17,7 +17,7 @@ class I:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -37,7 +37,7 @@ class X:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -50,11 +50,11 @@ class E:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
3 // 0
class N:
- 'Iterator missing next()'
+ 'Iterator missing __next__()'
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
@@ -76,23 +76,23 @@ class EnumerateTestCase(unittest.TestCase):
def test_getitemseqn(self):
self.assertEqual(list(self.enum(G(self.seq))), self.res)
e = self.enum(G(''))
- self.assertRaises(StopIteration, e.next)
+ self.assertRaises(StopIteration, next, e)
def test_iteratorseqn(self):
self.assertEqual(list(self.enum(I(self.seq))), self.res)
e = self.enum(I(''))
- self.assertRaises(StopIteration, e.next)
+ self.assertRaises(StopIteration, next, e)
def test_iteratorgenerator(self):
self.assertEqual(list(self.enum(Ig(self.seq))), self.res)
e = self.enum(Ig(''))
- self.assertRaises(StopIteration, e.next)
+ self.assertRaises(StopIteration, next, e)
def test_noniterable(self):
self.assertRaises(TypeError, self.enum, X(self.seq))
def test_illformediterable(self):
- self.assertRaises(TypeError, list, self.enum(N(self.seq)))
+ self.assertRaises(TypeError, self.enum, N(self.seq))
def test_exception_propagation(self):
self.assertRaises(ZeroDivisionError, list, self.enum(E(self.seq)))
@@ -103,7 +103,7 @@ class EnumerateTestCase(unittest.TestCase):
self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type
self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
- @test_support.cpython_only
+ @support.cpython_only
def test_tuple_reuse(self):
# Tests an implementation detail where tuple is reused
# whenever nothing else holds a reference to it
@@ -124,7 +124,7 @@ class TestEmpty(EnumerateTestCase):
class TestBig(EnumerateTestCase):
seq = range(10,20000,2)
- res = zip(range(20000), seq)
+ res = list(zip(range(20000), seq))
class TestReversed(unittest.TestCase):
@@ -136,27 +136,21 @@ class TestReversed(unittest.TestCase):
raise StopIteration
def __len__(self):
return 5
- for data in 'abc', range(5), tuple(enumerate('abc')), A(), xrange(1,17,5):
+ for data in 'abc', range(5), tuple(enumerate('abc')), A(), range(1,17,5):
self.assertEqual(list(data)[::-1], list(reversed(data)))
self.assertRaises(TypeError, reversed, {})
# don't allow keyword arguments
self.assertRaises(TypeError, reversed, [], a=1)
- def test_classic_class(self):
- class A:
- def __reversed__(self):
- return [2, 1]
- self.assertEqual(list(reversed(A())), [2, 1])
-
- def test_xrange_optimization(self):
- x = xrange(1)
+ def test_range_optimization(self):
+ x = range(1)
self.assertEqual(type(reversed(x)), type(iter(x)))
- @test_support.cpython_only
+ @support.cpython_only
def test_len(self):
# This is an implementation detail, not an interface requirement
from test.test_iterlen import len
- for s in ('hello', tuple('hello'), list('hello'), xrange(5)):
+ for s in ('hello', tuple('hello'), list('hello'), range(5)):
self.assertEqual(len(reversed(s)), len(s))
r = reversed(s)
list(r)
@@ -235,21 +229,21 @@ class TestStart(EnumerateStartTestCase):
class TestLongStart(EnumerateStartTestCase):
- enum = lambda self, i: enumerate(i, start=sys.maxint+1)
- seq, res = 'abc', [(sys.maxint+1,'a'), (sys.maxint+2,'b'),
- (sys.maxint+3,'c')]
+ enum = lambda self, i: enumerate(i, start=sys.maxsize+1)
+ seq, res = 'abc', [(sys.maxsize+1,'a'), (sys.maxsize+2,'b'),
+ (sys.maxsize+3,'c')]
def test_main(verbose=None):
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(__name__)
+ for i in range(len(counts)):
+ support.run_unittest(__name__)
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py
index 763917f0dfc..fb4ac9a639f 100644
--- a/Lib/test/test_eof.py
+++ b/Lib/test/test_eof.py
@@ -1,8 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""test script for a few new invalid token catches"""
import unittest
-from test import test_support
+from test import support
class EOFTestCase(unittest.TestCase):
def test_EOFC(self):
@@ -10,23 +10,23 @@ class EOFTestCase(unittest.TestCase):
try:
eval("""'this is a test\
""")
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(str(msg), expect)
else:
- raise test_support.TestFailed
+ raise support.TestFailed
def test_EOFS(self):
expect = ("EOF while scanning triple-quoted string literal "
"(<string>, line 1)")
try:
eval("""'''this is a test""")
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(str(msg), expect)
else:
- raise test_support.TestFailed
+ raise support.TestFailed
def test_main():
- test_support.run_unittest(EOFTestCase)
+ support.run_unittest(EOFTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_epoll.py b/Lib/test/test_epoll.py
index b66d9ea7ac4..083fd7f79d9 100644
--- a/Lib/test/test_epoll.py
+++ b/Lib/test/test_epoll.py
@@ -27,13 +27,13 @@ import time
import select
import unittest
-from test import test_support
+from test import support
if not hasattr(select, "epoll"):
raise unittest.SkipTest("test works only on Linux 2.6")
try:
select.epoll()
-except IOError, e:
+except IOError as e:
if e.errno == errno.ENOSYS:
raise unittest.SkipTest("kernel doesn't support epoll()")
raise
@@ -56,7 +56,7 @@ class TestEPoll(unittest.TestCase):
client.setblocking(False)
try:
client.connect(('127.0.0.1', self.serverSocket.getsockname()[1]))
- except socket.error, e:
+ except socket.error as e:
self.assertEqual(e.args[0], errno.EINPROGRESS)
else:
raise AssertionError("Connect should have raised EINPROGRESS")
@@ -68,7 +68,7 @@ class TestEPoll(unittest.TestCase):
def test_create(self):
try:
ep = select.epoll(16)
- except OSError, e:
+ except OSError as e:
raise AssertionError(str(e))
self.assertTrue(ep.fileno() > 0, ep.fileno())
self.assertTrue(not ep.closed)
@@ -139,7 +139,7 @@ class TestEPoll(unittest.TestCase):
ep.close()
try:
ep2.poll(1, 4)
- except IOError, e:
+ except IOError as e:
self.assertEqual(e.args[0], errno.EBADF, e)
else:
self.fail("epoll on closed fd didn't raise EBADF")
@@ -171,8 +171,8 @@ class TestEPoll(unittest.TestCase):
then = time.time()
self.assertFalse(events)
- client.send("Hello!")
- server.send("world!!!")
+ client.send(b"Hello!")
+ server.send(b"world!!!")
now = time.time()
events = ep.poll(1, 4)
@@ -216,7 +216,7 @@ class TestEPoll(unittest.TestCase):
ep.unregister(fd)
def test_main():
- test_support.run_unittest(TestEPoll)
+ support.run_unittest(TestEPoll)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_errno.py b/Lib/test/test_errno.py
index bb8918f32f3..f414a87796f 100755
--- a/Lib/test/test_errno.py
+++ b/Lib/test/test_errno.py
@@ -1,10 +1,10 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test the errno module
Roger E. Masse
"""
import errno
-from test import test_support
+from test import support
import unittest
std_c_errors = frozenset(['EDOM', 'ERANGE'])
@@ -19,21 +19,22 @@ class ErrnoAttributeTests(unittest.TestCase):
def test_using_errorcode(self):
# Every key value in errno.errorcode should be on the module.
- for value in errno.errorcode.itervalues():
- self.assertTrue(hasattr(errno, value), 'no %s attr in errno' % value)
+ for value in errno.errorcode.values():
+ self.assertTrue(hasattr(errno, value),
+ 'no %s attr in errno' % value)
class ErrorcodeTests(unittest.TestCase):
def test_attributes_in_errorcode(self):
- for attribute in errno.__dict__.iterkeys():
+ for attribute in errno.__dict__.keys():
if attribute.isupper():
self.assertIn(getattr(errno, attribute), errno.errorcode,
'no %s attr in errno.errorcode' % attribute)
def test_main():
- test_support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
+ support.run_unittest(ErrnoAttributeTests, ErrorcodeTests)
if __name__ == '__main__':
diff --git a/Lib/test/test_exception_variations.py b/Lib/test/test_exception_variations.py
index 8fe75e8fcc4..11f5e5c84e3 100644
--- a/Lib/test/test_exception_variations.py
+++ b/Lib/test/test_exception_variations.py
@@ -1,5 +1,5 @@
-from test.test_support import run_unittest
+from test.support import run_unittest
import unittest
class ExceptionTestCase(unittest.TestCase):
@@ -9,7 +9,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_finally = False
try:
- raise Exception, 'nyaa!'
+ raise Exception('nyaa!')
except:
hit_except = True
else:
@@ -44,7 +44,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_finally = False
try:
- raise Exception, 'yarr!'
+ raise Exception('yarr!')
except:
hit_except = True
finally:
@@ -71,7 +71,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_except = False
try:
- raise Exception, 'ahoy!'
+ raise Exception('ahoy!')
except:
hit_except = True
@@ -92,7 +92,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_else = False
try:
- raise Exception, 'foo!'
+ raise Exception('foo!')
except:
hit_except = True
else:
@@ -132,7 +132,7 @@ class ExceptionTestCase(unittest.TestCase):
try:
try:
- raise Exception, 'inner exception'
+ raise Exception('inner exception')
except:
hit_inner_except = True
finally:
@@ -159,7 +159,7 @@ class ExceptionTestCase(unittest.TestCase):
else:
hit_inner_else = True
- raise Exception, 'outer exception'
+ raise Exception('outer exception')
except:
hit_except = True
else:
diff --git a/Lib/test/test_exceptions.py b/Lib/test/test_exceptions.py
index 216064161cb..79bd7ffd3a0 100644
--- a/Lib/test/test_exceptions.py
+++ b/Lib/test/test_exceptions.py
@@ -3,34 +3,25 @@
import os
import sys
import unittest
-import pickle, cPickle
+import pickle
+import weakref
+import errno
-from test.test_support import (TESTFN, unlink, run_unittest, captured_output,
- check_warnings, cpython_only)
-from test.test_pep352 import ignore_deprecation_warnings
+from test.support import (TESTFN, captured_output, check_impl_detail,
+ cpython_only, gc_collect, run_unittest, unlink)
# XXX This is not really enough, each *operation* should be tested!
class ExceptionTests(unittest.TestCase):
- def testReload(self):
- # Reloading the built-in exceptions module failed prior to Py2.2, while it
- # should act the same as reloading built-in sys.
- try:
- from imp import reload
- import exceptions
- reload(exceptions)
- except ImportError, e:
- self.fail("reloading exceptions: %s" % e)
-
def raise_catch(self, exc, excname):
try:
- raise exc, "spam"
- except exc, err:
+ raise exc("spam")
+ except exc as err:
buf1 = str(err)
try:
raise exc("spam")
- except exc, err:
+ except exc as err:
buf2 = str(err)
self.assertEqual(buf1, buf2)
self.assertEqual(exc.__name__, excname)
@@ -46,8 +37,8 @@ class ExceptionTests(unittest.TestCase):
savestdin = sys.stdin
try:
try:
- sys.stdin = fp
- x = raw_input()
+ import marshal
+ marshal.loads(b'')
except EOFError:
pass
finally:
@@ -85,16 +76,16 @@ class ExceptionTests(unittest.TestCase):
self.raise_catch(RuntimeError, "RuntimeError")
self.raise_catch(SyntaxError, "SyntaxError")
- try: exec '/\n'
+ try: exec('/\n')
except SyntaxError: pass
self.raise_catch(IndentationError, "IndentationError")
self.raise_catch(TabError, "TabError")
- # can only be tested under -tt, and is the only test for -tt
- #try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n", '<string>', 'exec')
- #except TabError: pass
- #else: self.fail("TabError not raised")
+ try: compile("try:\n\t1/0\n \t1/0\nfinally:\n pass\n",
+ '<string>', 'exec')
+ except TabError: pass
+ else: self.fail("TabError not raised")
self.raise_catch(SystemError, "SystemError")
@@ -106,15 +97,15 @@ class ExceptionTests(unittest.TestCase):
except TypeError: pass
self.raise_catch(ValueError, "ValueError")
- self.assertRaises(ValueError, chr, 10000)
+ self.assertRaises(ValueError, chr, 17<<16)
self.raise_catch(ZeroDivisionError, "ZeroDivisionError")
- try: x = 1 // 0
+ try: x = 1/0
except ZeroDivisionError: pass
self.raise_catch(Exception, "Exception")
- try: x = 1 // 0
- except Exception, e: pass
+ try: x = 1/0
+ except Exception as e: pass
def testSyntaxErrorMessage(self):
# make sure the right exception message is raised for each of
@@ -123,7 +114,7 @@ class ExceptionTests(unittest.TestCase):
def ckmsg(src, msg):
try:
compile(src, '<fragment>', 'exec')
- except SyntaxError, e:
+ except SyntaxError as e:
if e.msg != msg:
self.fail("expected %s, got %s" % (msg, e.msg))
else:
@@ -152,19 +143,22 @@ class ExceptionTests(unittest.TestCase):
# test that setting an exception at the C level works even if the
# exception object can't be constructed.
- class BadException:
+ class BadException(Exception):
def __init__(self_):
- raise RuntimeError, "can't instantiate BadException"
+ raise RuntimeError("can't instantiate BadException")
+
+ class InvalidException:
+ pass
def test_capi1():
import _testcapi
try:
_testcapi.raise_exception(BadException, 1)
- except TypeError, err:
+ except TypeError as err:
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
self.assertEqual(co.co_name, "test_capi1")
- self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py'))
+ self.assertTrue(co.co_filename.endswith('test_exceptions.py'))
else:
self.fail("Expected exception")
@@ -172,19 +166,25 @@ class ExceptionTests(unittest.TestCase):
import _testcapi
try:
_testcapi.raise_exception(BadException, 0)
- except RuntimeError, err:
+ except RuntimeError as err:
exc, err, tb = sys.exc_info()
co = tb.tb_frame.f_code
self.assertEqual(co.co_name, "__init__")
- self.assertTrue(co.co_filename.endswith('test_exceptions'+os.extsep+'py'))
+ self.assertTrue(co.co_filename.endswith('test_exceptions.py'))
co2 = tb.tb_frame.f_back.f_code
self.assertEqual(co2.co_name, "test_capi2")
else:
self.fail("Expected exception")
+ def test_capi3():
+ import _testcapi
+ self.assertRaises(SystemError, _testcapi.raise_exception,
+ InvalidException, 1)
+
if not sys.platform.startswith('java'):
test_capi1()
test_capi2()
+ test_capi3()
def test_WindowsError(self):
try:
@@ -192,85 +192,91 @@ class ExceptionTests(unittest.TestCase):
except NameError:
pass
else:
- self.assertEqual(str(WindowsError(1001)),
- "1001")
+ self.assertEqual(str(WindowsError(1001)), "1001")
self.assertEqual(str(WindowsError(1001, "message")),
- "[Error 1001] message")
+ "[Error 1001] message")
self.assertEqual(WindowsError(1001, "message").errno, 22)
self.assertEqual(WindowsError(1001, "message").winerror, 1001)
- @ignore_deprecation_warnings
def testAttributes(self):
# test that exception attributes are happy
exceptionList = [
- (BaseException, (), {'message' : '', 'args' : ()}),
- (BaseException, (1, ), {'message' : 1, 'args' : (1,)}),
+ (BaseException, (), {'args' : ()}),
+ (BaseException, (1, ), {'args' : (1,)}),
(BaseException, ('foo',),
- {'message' : 'foo', 'args' : ('foo',)}),
+ {'args' : ('foo',)}),
(BaseException, ('foo', 1),
- {'message' : '', 'args' : ('foo', 1)}),
+ {'args' : ('foo', 1)}),
(SystemExit, ('foo',),
- {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}),
+ {'args' : ('foo',), 'code' : 'foo'}),
(IOError, ('foo',),
- {'message' : 'foo', 'args' : ('foo',), 'filename' : None,
+ {'args' : ('foo',), 'filename' : None,
'errno' : None, 'strerror' : None}),
(IOError, ('foo', 'bar'),
- {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None,
+ {'args' : ('foo', 'bar'), 'filename' : None,
'errno' : 'foo', 'strerror' : 'bar'}),
(IOError, ('foo', 'bar', 'baz'),
- {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz',
+ {'args' : ('foo', 'bar'), 'filename' : 'baz',
'errno' : 'foo', 'strerror' : 'bar'}),
(IOError, ('foo', 'bar', 'baz', 'quux'),
- {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}),
+ {'args' : ('foo', 'bar', 'baz', 'quux')}),
(EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'),
- {'message' : '', 'args' : ('errnoStr', 'strErrorStr'),
+ {'args' : ('errnoStr', 'strErrorStr'),
'strerror' : 'strErrorStr', 'errno' : 'errnoStr',
'filename' : 'filenameStr'}),
(EnvironmentError, (1, 'strErrorStr', 'filenameStr'),
- {'message' : '', 'args' : (1, 'strErrorStr'), 'errno' : 1,
+ {'args' : (1, 'strErrorStr'), 'errno' : 1,
'strerror' : 'strErrorStr', 'filename' : 'filenameStr'}),
- (SyntaxError, (), {'message' : '', 'msg' : None, 'text' : None,
+ (SyntaxError, (), {'msg' : None, 'text' : None,
'filename' : None, 'lineno' : None, 'offset' : None,
'print_file_and_line' : None}),
(SyntaxError, ('msgStr',),
- {'message' : 'msgStr', 'args' : ('msgStr',), 'text' : None,
+ {'args' : ('msgStr',), 'text' : None,
'print_file_and_line' : None, 'msg' : 'msgStr',
'filename' : None, 'lineno' : None, 'offset' : None}),
(SyntaxError, ('msgStr', ('filenameStr', 'linenoStr', 'offsetStr',
'textStr')),
- {'message' : '', 'offset' : 'offsetStr', 'text' : 'textStr',
+ {'offset' : 'offsetStr', 'text' : 'textStr',
'args' : ('msgStr', ('filenameStr', 'linenoStr',
'offsetStr', 'textStr')),
'print_file_and_line' : None, 'msg' : 'msgStr',
'filename' : 'filenameStr', 'lineno' : 'linenoStr'}),
(SyntaxError, ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr',
'textStr', 'print_file_and_lineStr'),
- {'message' : '', 'text' : None,
+ {'text' : None,
'args' : ('msgStr', 'filenameStr', 'linenoStr', 'offsetStr',
'textStr', 'print_file_and_lineStr'),
'print_file_and_line' : None, 'msg' : 'msgStr',
'filename' : None, 'lineno' : None, 'offset' : None}),
- (UnicodeError, (), {'message' : '', 'args' : (),}),
- (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'),
- {'message' : '', 'args' : ('ascii', u'a', 0, 1,
+ (UnicodeError, (), {'args' : (),}),
+ (UnicodeEncodeError, ('ascii', 'a', 0, 1,
+ 'ordinal not in range'),
+ {'args' : ('ascii', 'a', 0, 1,
'ordinal not in range'),
- 'encoding' : 'ascii', 'object' : u'a',
+ 'encoding' : 'ascii', 'object' : 'a',
'start' : 0, 'reason' : 'ordinal not in range'}),
- (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'),
- {'message' : '', 'args' : ('ascii', '\xff', 0, 1,
+ (UnicodeDecodeError, ('ascii', bytearray(b'\xff'), 0, 1,
+ 'ordinal not in range'),
+ {'args' : ('ascii', bytearray(b'\xff'), 0, 1,
'ordinal not in range'),
- 'encoding' : 'ascii', 'object' : '\xff',
+ 'encoding' : 'ascii', 'object' : b'\xff',
'start' : 0, 'reason' : 'ordinal not in range'}),
- (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"),
- {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'),
- 'object' : u'\u3042', 'reason' : 'ouch',
+ (UnicodeDecodeError, ('ascii', b'\xff', 0, 1,
+ 'ordinal not in range'),
+ {'args' : ('ascii', b'\xff', 0, 1,
+ 'ordinal not in range'),
+ 'encoding' : 'ascii', 'object' : b'\xff',
+ 'start' : 0, 'reason' : 'ordinal not in range'}),
+ (UnicodeTranslateError, ("\u3042", 0, 1, "ouch"),
+ {'args' : ('\u3042', 0, 1, 'ouch'),
+ 'object' : '\u3042', 'reason' : 'ouch',
'start' : 0, 'end' : 1}),
]
try:
exceptionList.append(
(WindowsError, (1, 'strErrorStr', 'filenameStr'),
- {'message' : '', 'args' : (1, 'strErrorStr'),
+ {'args' : (1, 'strErrorStr'),
'strerror' : 'strErrorStr', 'winerror' : 1,
'errno' : 22, 'filename' : 'filenameStr'})
)
@@ -279,74 +285,96 @@ class ExceptionTests(unittest.TestCase):
for exc, args, expected in exceptionList:
try:
- raise exc(*args)
- except BaseException, e:
- if type(e) is not exc:
- raise
+ e = exc(*args)
+ except:
+ print("\nexc=%r, args=%r" % (exc, args), file=sys.stderr)
+ raise
+ else:
# Verify module name
- self.assertEqual(type(e).__module__, 'exceptions')
+ self.assertEqual(type(e).__module__, 'builtins')
# Verify no ref leaks in Exc_str()
s = str(e)
for checkArgName in expected:
- self.assertEqual(repr(getattr(e, checkArgName)),
+ value = getattr(e, checkArgName)
+ self.assertEqual(repr(value),
repr(expected[checkArgName]),
- 'exception "%s", attribute "%s"' %
- (repr(e), checkArgName))
+ '%r.%s == %r, expected %r' % (
+ e, checkArgName,
+ value, expected[checkArgName]))
# test for pickling support
- for p in pickle, cPickle:
+ for p in [pickle]:
for protocol in range(p.HIGHEST_PROTOCOL + 1):
- new = p.loads(p.dumps(e, protocol))
+ s = p.dumps(e, protocol)
+ new = p.loads(s)
for checkArgName in expected:
got = repr(getattr(new, checkArgName))
want = repr(expected[checkArgName])
self.assertEqual(got, want,
- 'pickled "%r", attribute "%s"' %
+ 'pickled "%r", attribute "%s' %
(e, checkArgName))
+ def testWithTraceback(self):
+ try:
+ raise IndexError(4)
+ except:
+ tb = sys.exc_info()[2]
+
+ e = BaseException().with_traceback(tb)
+ self.assertIsInstance(e, BaseException)
+ self.assertEqual(e.__traceback__, tb)
+
+ e = IndexError(5).with_traceback(tb)
+ self.assertIsInstance(e, IndexError)
+ self.assertEqual(e.__traceback__, tb)
+
+ class MyException(Exception):
+ pass
+
+ e = MyException().with_traceback(tb)
+ self.assertIsInstance(e, MyException)
+ self.assertEqual(e.__traceback__, tb)
+
+ def testInvalidTraceback(self):
+ try:
+ Exception().__traceback__ = 5
+ except TypeError as e:
+ self.assertIn("__traceback__ must be a traceback", str(e))
+ else:
+ self.fail("No exception raised")
+
+ def testInvalidAttrs(self):
+ self.assertRaises(TypeError, setattr, Exception(), '__cause__', 1)
+ self.assertRaises(TypeError, delattr, Exception(), '__cause__')
+ self.assertRaises(TypeError, setattr, Exception(), '__context__', 1)
+ self.assertRaises(TypeError, delattr, Exception(), '__context__')
+
+ def testNoneClearsTracebackAttr(self):
+ try:
+ raise IndexError(4)
+ except:
+ tb = sys.exc_info()[2]
+
+ e = Exception()
+ e.__traceback__ = tb
+ e.__traceback__ = None
+ self.assertEqual(e.__traceback__, None)
+
+ def testChainingAttrs(self):
+ e = Exception()
+ self.assertEqual(e.__context__, None)
+ self.assertEqual(e.__cause__, None)
+
+ e = TypeError()
+ self.assertEqual(e.__context__, None)
+ self.assertEqual(e.__cause__, None)
- def testDeprecatedMessageAttribute(self):
- # Accessing BaseException.message and relying on its value set by
- # BaseException.__init__ triggers a deprecation warning.
- exc = BaseException("foo")
- with check_warnings(("BaseException.message has been deprecated "
- "as of Python 2.6", DeprecationWarning)) as w:
- self.assertEqual(exc.message, "foo")
- self.assertEqual(len(w.warnings), 1)
-
- def testRegularMessageAttribute(self):
- # Accessing BaseException.message after explicitly setting a value
- # for it does not trigger a deprecation warning.
- exc = BaseException("foo")
- exc.message = "bar"
- with check_warnings(quiet=True) as w:
- self.assertEqual(exc.message, "bar")
- self.assertEqual(len(w.warnings), 0)
- # Deleting the message is supported, too.
- del exc.message
- with self.assertRaises(AttributeError):
- exc.message
-
- @ignore_deprecation_warnings
- def testPickleMessageAttribute(self):
- # Pickling with message attribute must work, as well.
- e = Exception("foo")
- f = Exception("foo")
- f.message = "bar"
- for p in pickle, cPickle:
- ep = p.loads(p.dumps(e))
- self.assertEqual(ep.message, "foo")
- fp = p.loads(p.dumps(f))
- self.assertEqual(fp.message, "bar")
-
- @ignore_deprecation_warnings
- def testSlicing(self):
- # Test that you can slice an exception directly instead of requiring
- # going through the 'args' attribute.
- args = (1, 2, 3)
- exc = BaseException(*args)
- self.assertEqual(exc[:], args)
- self.assertEqual(exc.args[:], args)
+ class MyException(EnvironmentError):
+ pass
+
+ e = MyException()
+ self.assertEqual(e.__context__, None)
+ self.assertEqual(e.__cause__, None)
def testKeywordArgs(self):
# test that builtin exception don't take keyword args,
@@ -371,36 +399,305 @@ class ExceptionTests(unittest.TestCase):
return g()
except ValueError:
return -1
+ self.assertRaises(RuntimeError, g)
+
+ def test_str(self):
+ # Make sure both instances and classes have a str representation.
+ self.assertTrue(str(Exception))
+ self.assertTrue(str(Exception('a')))
+ self.assertTrue(str(Exception('a', 'b')))
+
+ def testExceptionCleanupNames(self):
+ # Make sure the local variable bound to the exception instance by
+ # an "except" statement is only visible inside the except block.
+ try:
+ raise Exception()
+ except Exception as e:
+ self.assertTrue(e)
+ del e
+ self.assertNotIn('e', locals())
+
+ def testExceptionCleanupState(self):
+ # Make sure exception state is cleaned up as soon as the except
+ # block is left. See #2507
+
+ class MyException(Exception):
+ def __init__(self, obj):
+ self.obj = obj
+ class MyObj:
+ pass
+
+ def inner_raising_func():
+ # Create some references in exception value and traceback
+ local_ref = obj
+ raise MyException(obj)
+
+ # Qualified "except" with "as"
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ try:
+ inner_raising_func()
+ except MyException as e:
+ pass
+ obj = None
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
- # The test prints an unraisable recursion error when
- # doing "except ValueError", this is because subclass
- # checking has recursion checking too.
- with captured_output("stderr"):
+ # Qualified "except" without "as"
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ try:
+ inner_raising_func()
+ except MyException:
+ pass
+ obj = None
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ # Bare "except"
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ try:
+ inner_raising_func()
+ except:
+ pass
+ obj = None
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ # "except" with premature block leave
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ for i in [0]:
try:
- g()
+ inner_raising_func()
+ except:
+ break
+ obj = None
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ # "except" block raising another exception
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ try:
+ try:
+ inner_raising_func()
+ except:
+ raise KeyError
+ except KeyError as e:
+ # We want to test that the except block above got rid of
+ # the exception raised in inner_raising_func(), but it
+ # also ends up in the __context__ of the KeyError, so we
+ # must clear the latter manually for our test to succeed.
+ e.__context__ = None
+ obj = None
+ obj = wr()
+ # guarantee no ref cycles on CPython (don't gc_collect)
+ if check_impl_detail(cpython=False):
+ gc_collect()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ # Some complicated construct
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ try:
+ inner_raising_func()
+ except MyException:
+ try:
+ try:
+ raise
+ finally:
+ raise
+ except MyException:
+ pass
+ obj = None
+ if check_impl_detail(cpython=False):
+ gc_collect()
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ # Inside an exception-silencing "with" block
+ class Context:
+ def __enter__(self):
+ return self
+ def __exit__ (self, exc_type, exc_value, exc_tb):
+ return True
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ with Context():
+ inner_raising_func()
+ obj = None
+ if check_impl_detail(cpython=False):
+ gc_collect()
+ obj = wr()
+ self.assertTrue(obj is None, "%s" % obj)
+
+ def test_exception_target_in_nested_scope(self):
+ # issue 4617: This used to raise a SyntaxError
+ # "can not delete variable 'e' referenced in nested scope"
+ def print_error():
+ e
+ try:
+ something
+ except Exception as e:
+ print_error()
+ # implicit "del e" here
+
+ def test_generator_leaking(self):
+ # Test that generator exception state doesn't leak into the calling
+ # frame
+ def yield_raise():
+ try:
+ raise KeyError("caught")
+ except KeyError:
+ yield sys.exc_info()[0]
+ yield sys.exc_info()[0]
+ yield sys.exc_info()[0]
+ g = yield_raise()
+ self.assertEqual(next(g), KeyError)
+ self.assertEqual(sys.exc_info()[0], None)
+ self.assertEqual(next(g), KeyError)
+ self.assertEqual(sys.exc_info()[0], None)
+ self.assertEqual(next(g), None)
+
+ # Same test, but inside an exception handler
+ try:
+ raise TypeError("foo")
+ except TypeError:
+ g = yield_raise()
+ self.assertEqual(next(g), KeyError)
+ self.assertEqual(sys.exc_info()[0], TypeError)
+ self.assertEqual(next(g), KeyError)
+ self.assertEqual(sys.exc_info()[0], TypeError)
+ self.assertEqual(next(g), TypeError)
+ del g
+ self.assertEqual(sys.exc_info()[0], TypeError)
+
+ def test_generator_leaking2(self):
+ # See issue 12475.
+ def g():
+ yield
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ it = g()
+ next(it)
+ try:
+ next(it)
+ except StopIteration:
+ pass
+ self.assertEqual(sys.exc_info(), (None, None, None))
+
+ def test_generator_doesnt_retain_old_exc(self):
+ def g():
+ self.assertIsInstance(sys.exc_info()[1], RuntimeError)
+ yield
+ self.assertEqual(sys.exc_info(), (None, None, None))
+ it = g()
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ next(it)
+ self.assertRaises(StopIteration, next, it)
+
+ def test_generator_finalizing_and_exc_info(self):
+ # See #7173
+ def simple_gen():
+ yield 1
+ def run_gen():
+ gen = simple_gen()
+ try:
+ raise RuntimeError
+ except RuntimeError:
+ return next(gen)
+ run_gen()
+ gc_collect()
+ self.assertEqual(sys.exc_info(), (None, None, None))
+
+ def _check_generator_cleanup_exc_state(self, testfunc):
+ # Issue #12791: exception state is cleaned up as soon as a generator
+ # is closed (reference cycles are broken).
+ class MyException(Exception):
+ def __init__(self, obj):
+ self.obj = obj
+ class MyObj:
+ pass
+
+ def raising_gen():
+ try:
+ raise MyException(obj)
+ except MyException:
+ yield
+
+ obj = MyObj()
+ wr = weakref.ref(obj)
+ g = raising_gen()
+ next(g)
+ testfunc(g)
+ g = obj = None
+ obj = wr()
+ self.assertIs(obj, None)
+
+ def test_generator_throw_cleanup_exc_state(self):
+ def do_throw(g):
+ try:
+ g.throw(RuntimeError())
except RuntimeError:
pass
- except:
- self.fail("Should have raised KeyError")
+ self._check_generator_cleanup_exc_state(do_throw)
+
+ def test_generator_close_cleanup_exc_state(self):
+ def do_close(g):
+ g.close()
+ self._check_generator_cleanup_exc_state(do_close)
+
+ def test_generator_del_cleanup_exc_state(self):
+ def do_del(g):
+ g = None
+ self._check_generator_cleanup_exc_state(do_del)
+
+ def test_generator_next_cleanup_exc_state(self):
+ def do_next(g):
+ try:
+ next(g)
+ except StopIteration:
+ pass
else:
- self.fail("Should have raised KeyError")
+ self.fail("should have raised StopIteration")
+ self._check_generator_cleanup_exc_state(do_next)
- def testUnicodeStrUsage(self):
- # Make sure both instances and classes have a str and unicode
- # representation.
- self.assertTrue(str(Exception))
- self.assertTrue(unicode(Exception))
- self.assertTrue(str(Exception('a')))
- self.assertTrue(unicode(Exception(u'a')))
- self.assertTrue(unicode(Exception(u'\xe1')))
+ def test_generator_send_cleanup_exc_state(self):
+ def do_send(g):
+ try:
+ g.send(None)
+ except StopIteration:
+ pass
+ else:
+ self.fail("should have raised StopIteration")
+ self._check_generator_cleanup_exc_state(do_send)
+
+ def test_3114(self):
+ # Bug #3114: in its destructor, MyObject retrieves a pointer to
+ # obsolete and/or deallocated objects.
+ class MyObject:
+ def __del__(self):
+ nonlocal e
+ e = sys.exc_info()
+ e = ()
+ try:
+ raise Exception(MyObject())
+ except:
+ pass
+ self.assertEqual(e, (None, None, None))
def testUnicodeChangeAttributes(self):
# See issue 7309. This was a crasher.
- u = UnicodeEncodeError('baz', u'xxxxx', 1, 5, 'foo')
+ u = UnicodeEncodeError('baz', 'xxxxx', 1, 5, 'foo')
self.assertEqual(str(u), "'baz' codec can't encode characters in position 1-4: foo")
u.end = 2
- self.assertEqual(str(u), "'baz' codec can't encode character u'\\x78' in position 1: foo")
+ self.assertEqual(str(u), "'baz' codec can't encode character '\\x78' in position 1: foo")
u.end = 5
u.reason = 0x345345345345345345
self.assertEqual(str(u), "'baz' codec can't encode characters in position 1-4: 965230951443685724997")
@@ -409,7 +706,7 @@ class ExceptionTests(unittest.TestCase):
u.start = 1000
self.assertEqual(str(u), "'4000' codec can't encode characters in position 1000-4: 965230951443685724997")
- u = UnicodeDecodeError('baz', 'xxxxx', 1, 5, 'foo')
+ u = UnicodeDecodeError('baz', b'xxxxx', 1, 5, 'foo')
self.assertEqual(str(u), "'baz' codec can't decode bytes in position 1-4: foo")
u.end = 2
self.assertEqual(str(u), "'baz' codec can't decode byte 0x78 in position 1: foo")
@@ -421,10 +718,10 @@ class ExceptionTests(unittest.TestCase):
u.start = 1000
self.assertEqual(str(u), "'4000' codec can't decode bytes in position 1000-4: 965230951443685724997")
- u = UnicodeTranslateError(u'xxxx', 1, 5, 'foo')
+ u = UnicodeTranslateError('xxxx', 1, 5, 'foo')
self.assertEqual(str(u), "can't translate characters in position 1-4: foo")
u.end = 2
- self.assertEqual(str(u), "can't translate character u'\\x78' in position 1: foo")
+ self.assertEqual(str(u), "can't translate character '\\x78' in position 1: foo")
u.end = 5
u.reason = 0x345345345345345345
self.assertEqual(str(u), "can't translate characters in position 1-4: 965230951443685724997")
@@ -437,15 +734,13 @@ class ExceptionTests(unittest.TestCase):
class Meta(type):
def __subclasscheck__(cls, subclass):
raise ValueError()
-
- class MyException(Exception):
- __metaclass__ = Meta
+ class MyException(Exception, metaclass=Meta):
pass
with captured_output("stderr") as stderr:
try:
raise KeyError()
- except MyException, e:
+ except MyException as e:
self.fail("exception should not be a MyException")
except KeyError:
pass
@@ -454,137 +749,33 @@ class ExceptionTests(unittest.TestCase):
else:
self.fail("Should have raised KeyError")
- with captured_output("stderr") as stderr:
- def g():
- try:
- return g()
- except RuntimeError:
- return sys.exc_info()
- e, v, tb = g()
- self.assertTrue(e is RuntimeError, e)
- self.assertIn("maximum recursion depth exceeded", str(v))
-
- def test_new_returns_invalid_instance(self):
- # See issue #11627.
- class MyException(Exception):
- def __new__(cls, *args):
- return object()
-
- with self.assertRaises(TypeError):
- raise MyException
+ def g():
+ try:
+ return g()
+ except RuntimeError:
+ return sys.exc_info()
+ e, v, tb = g()
+ self.assertTrue(isinstance(v, RuntimeError), type(v))
+ self.assertIn("maximum recursion depth exceeded", str(v))
+
+
+ def test_MemoryError(self):
+ # PyErr_NoMemory always raises the same exception instance.
+ # Check that the traceback is not doubled.
+ import traceback
+ from _testcapi import raise_memoryerror
+ def raiseMemError():
+ try:
+ raise_memoryerror()
+ except MemoryError as e:
+ tb = e.__traceback__
+ else:
+ self.fail("Should have raises a MemoryError")
+ return traceback.format_tb(tb)
- def test_assert_with_tuple_arg(self):
- try:
- assert False, (3,)
- except AssertionError as e:
- self.assertEqual(str(e), "(3,)")
-
-
-# Helper class used by TestSameStrAndUnicodeMsg
-class ExcWithOverriddenStr(Exception):
- """Subclass of Exception that accepts a keyword 'msg' arg that is
- returned by __str__. 'msg' won't be included in self.args"""
- def __init__(self, *args, **kwargs):
- self.msg = kwargs.pop('msg') # msg should always be present
- super(ExcWithOverriddenStr, self).__init__(*args, **kwargs)
- def __str__(self):
- return self.msg
-
-
-class TestSameStrAndUnicodeMsg(unittest.TestCase):
- """unicode(err) should return the same message of str(err). See #6108"""
-
- def check_same_msg(self, exc, msg):
- """Helper function that checks if str(exc) == unicode(exc) == msg"""
- self.assertEqual(str(exc), msg)
- self.assertEqual(str(exc), unicode(exc))
-
- def test_builtin_exceptions(self):
- """Check same msg for built-in exceptions"""
- # These exceptions implement a __str__ method that uses the args
- # to create a better error message. unicode(e) should return the same
- # message.
- exceptions = [
- SyntaxError('invalid syntax', ('<string>', 1, 3, '2+*3')),
- IOError(2, 'No such file or directory'),
- KeyError('both should have the same quotes'),
- UnicodeDecodeError('ascii', '\xc3\xa0', 0, 1,
- 'ordinal not in range(128)'),
- UnicodeEncodeError('ascii', u'\u1234', 0, 1,
- 'ordinal not in range(128)')
- ]
- for exception in exceptions:
- self.assertEqual(str(exception), unicode(exception))
-
- def test_0_args(self):
- """Check same msg for Exception with 0 args"""
- # str() and unicode() on an Exception with no args should return an
- # empty string
- self.check_same_msg(Exception(), '')
-
- def test_0_args_with_overridden___str__(self):
- """Check same msg for exceptions with 0 args and overridden __str__"""
- # str() and unicode() on an exception with overridden __str__ that
- # returns an ascii-only string should return the same string
- for msg in ('foo', u'foo'):
- self.check_same_msg(ExcWithOverriddenStr(msg=msg), msg)
-
- # if __str__ returns a non-ascii unicode string str() should fail
- # but unicode() should return the unicode string
- e = ExcWithOverriddenStr(msg=u'f\xf6\xf6') # no args
- self.assertRaises(UnicodeEncodeError, str, e)
- self.assertEqual(unicode(e), u'f\xf6\xf6')
-
- def test_1_arg(self):
- """Check same msg for Exceptions with 1 arg"""
- for arg in ('foo', u'foo'):
- self.check_same_msg(Exception(arg), arg)
-
- # if __str__ is not overridden and self.args[0] is a non-ascii unicode
- # string, str() should try to return str(self.args[0]) and fail.
- # unicode() should return unicode(self.args[0]) and succeed.
- e = Exception(u'f\xf6\xf6')
- self.assertRaises(UnicodeEncodeError, str, e)
- self.assertEqual(unicode(e), u'f\xf6\xf6')
-
- def test_1_arg_with_overridden___str__(self):
- """Check same msg for exceptions with overridden __str__ and 1 arg"""
- # when __str__ is overridden and __unicode__ is not implemented
- # unicode(e) returns the same as unicode(e.__str__()).
- for msg in ('foo', u'foo'):
- self.check_same_msg(ExcWithOverriddenStr('arg', msg=msg), msg)
-
- # if __str__ returns a non-ascii unicode string, str() should fail
- # but unicode() should succeed.
- e = ExcWithOverriddenStr('arg', msg=u'f\xf6\xf6') # 1 arg
- self.assertRaises(UnicodeEncodeError, str, e)
- self.assertEqual(unicode(e), u'f\xf6\xf6')
-
- def test_many_args(self):
- """Check same msg for Exceptions with many args"""
- argslist = [
- (3, 'foo'),
- (1, u'foo', 'bar'),
- (4, u'f\xf6\xf6', u'bar', 'baz')
- ]
- # both str() and unicode() should return a repr() of the args
- for args in argslist:
- self.check_same_msg(Exception(*args), repr(args))
-
- def test_many_args_with_overridden___str__(self):
- """Check same msg for exceptions with overridden __str__ and many args"""
- # if __str__ returns an ascii string / ascii unicode string
- # both str() and unicode() should succeed
- for msg in ('foo', u'foo'):
- e = ExcWithOverriddenStr('arg1', u'arg2', u'f\xf6\xf6', msg=msg)
- self.check_same_msg(e, msg)
-
- # if __str__ returns a non-ascii unicode string, str() should fail
- # but unicode() should succeed
- e = ExcWithOverriddenStr('arg1', u'f\xf6\xf6', u'arg3', # 3 args
- msg=u'f\xf6\xf6')
- self.assertRaises(UnicodeEncodeError, str, e)
- self.assertEqual(unicode(e), u'f\xf6\xf6')
+ tb1 = raiseMemError()
+ tb2 = raiseMemError()
+ self.assertEqual(tb1, tb2)
@cpython_only
def test_exception_with_doc(self):
@@ -626,9 +817,55 @@ class TestSameStrAndUnicodeMsg(unittest.TestCase):
self.assertEqual(error5.a, 1)
self.assertEqual(error5.__doc__, "")
+ def test_memory_error_cleanup(self):
+ # Issue #5437: preallocated MemoryError instances should not keep
+ # traceback objects alive.
+ from _testcapi import raise_memoryerror
+ class C:
+ pass
+ wr = None
+ def inner():
+ nonlocal wr
+ c = C()
+ wr = weakref.ref(c)
+ raise_memoryerror()
+ # We cannot use assertRaises since it manually deletes the traceback
+ try:
+ inner()
+ except MemoryError as e:
+ self.assertNotEqual(wr(), None)
+ else:
+ self.fail("MemoryError not raised")
+ self.assertEqual(wr(), None)
+
+ def test_recursion_error_cleanup(self):
+ # Same test as above, but with "recursion exceeded" errors
+ class C:
+ pass
+ wr = None
+ def inner():
+ nonlocal wr
+ c = C()
+ wr = weakref.ref(c)
+ inner()
+ # We cannot use assertRaises since it manually deletes the traceback
+ try:
+ inner()
+ except RuntimeError as e:
+ self.assertNotEqual(wr(), None)
+ else:
+ self.fail("RuntimeError not raised")
+ self.assertEqual(wr(), None)
+
+ def test_errno_ENOTDIR(self):
+ # Issue #12802: "not a directory" errors are ENOTDIR even on Windows
+ with self.assertRaises(OSError) as cm:
+ os.listdir(__file__)
+ self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
+
def test_main():
- run_unittest(ExceptionTests, TestSameStrAndUnicodeMsg)
+ run_unittest(ExceptionTests)
if __name__ == '__main__':
- test_main()
+ unittest.main()
diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py
index 80e09a0ec2f..1f7f63042e7 100644
--- a/Lib/test/test_extcall.py
+++ b/Lib/test/test_extcall.py
@@ -1,25 +1,24 @@
-# -*- coding: utf-8 -*-
"""Doctest for method/function calls.
We're going the use these types for extra testing
- >>> from UserList import UserList
- >>> from UserDict import UserDict
+ >>> from collections import UserList
+ >>> from collections import UserDict
We're defining four helper functions
>>> def e(a,b):
- ... print a, b
+ ... print(a, b)
>>> def f(*a, **k):
- ... print a, test_support.sortdict(k)
+ ... print(a, support.sortdict(k))
>>> def g(x, *y, **z):
- ... print x, y, test_support.sortdict(z)
+ ... print(x, y, support.sortdict(z))
>>> def h(j=1, a=2, h=3):
- ... print j, a, h
+ ... print(j, a, h)
Argument list examples
@@ -93,7 +92,7 @@ Verify clearing of SF bug #733667
>>> g(*Nothing())
Traceback (most recent call last):
...
- TypeError: g() argument after * must be a sequence, not instance
+ TypeError: g() argument after * must be a sequence, not Nothing
>>> class Nothing:
... def __len__(self): return 5
@@ -102,7 +101,7 @@ Verify clearing of SF bug #733667
>>> g(*Nothing())
Traceback (most recent call last):
...
- TypeError: g() argument after * must be a sequence, not instance
+ TypeError: g() argument after * must be a sequence, not Nothing
>>> class Nothing():
... def __len__(self): return 5
@@ -117,7 +116,7 @@ Verify clearing of SF bug #733667
>>> class Nothing:
... def __init__(self): self.c = 0
... def __iter__(self): return self
- ... def next(self):
+ ... def __next__(self):
... if self.c == 4:
... raise StopIteration
... c = self.c
@@ -208,7 +207,7 @@ Another helper function
>>> d = {}
- >>> for i in xrange(512):
+ >>> for i in range(512):
... key = 'k%d' % i
... d[key] = i
>>> a, b = f2(1, *(2,3), **d)
@@ -225,16 +224,9 @@ Another helper function
>>> Foo.method(x, *(1, 2))
3
>>> Foo.method(*(1, 2, 3))
- Traceback (most recent call last):
- ...
- TypeError: unbound method method() must be called with Foo instance as \
-first argument (got int instance instead)
-
+ 5
>>> Foo.method(1, *[2, 3])
- Traceback (most recent call last):
- ...
- TypeError: unbound method method() must be called with Foo instance as \
-first argument (got int instance instead)
+ 5
A PyCFunction that takes only positional parameters should allow an
empty keyword dictionary to pass without a complaint, but raise a
@@ -267,7 +259,7 @@ the function call setup. See <http://bugs.python.org/issue2016>.
>>> x = {Name("a"):1, Name("b"):2}
>>> def f(a, b):
- ... print a,b
+ ... print(a,b)
>>> f(**x)
1 2
@@ -287,33 +279,20 @@ The number of arguments passed in includes keywords:
>>> f(6, a=4, *(1, 2, 3))
Traceback (most recent call last):
...
- TypeError: f() takes exactly 1 argument (5 given)
+ TypeError: f() takes exactly 1 positional argument (5 given)
+ >>> def f(a, *, kw):
+ ... pass
+ >>> f(6, 4, kw=4)
+ Traceback (most recent call last):
+ ...
+ TypeError: f() takes exactly 1 positional argument (3 given)
"""
-import unittest
import sys
-from test import test_support
-
-
-class ExtCallTest(unittest.TestCase):
-
- def test_unicode_keywords(self):
- def f(a):
- return a
- self.assertEqual(f(**{u'a': 4}), 4)
- self.assertRaises(TypeError, f, **{u'stören': 4})
- self.assertRaises(TypeError, f, **{u'someLongString':2})
- try:
- f(a=4, **{u'a': 4})
- except TypeError:
- pass
- else:
- self.fail("duplicate arguments didn't raise")
-
+from test import support
def test_main():
- test_support.run_doctest(sys.modules[__name__], True)
- test_support.run_unittest(ExtCallTest)
+ support.run_doctest(sys.modules[__name__], True)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py
index df0939151f0..29af99cf162 100644
--- a/Lib/test/test_fcntl.py
+++ b/Lib/test/test_fcntl.py
@@ -7,8 +7,7 @@ import os
import struct
import sys
import unittest
-from test.test_support import (verbose, TESTFN, unlink, run_unittest,
- import_module)
+from test.support import verbose, TESTFN, unlink, run_unittest, import_module
# Skip test if no fnctl module.
fcntl = import_module('fcntl')
@@ -17,15 +16,12 @@ fcntl = import_module('fcntl')
# TODO - Write tests for flock() and lockf().
def get_lockdata():
- if sys.platform.startswith('atheos'):
- start_len = "qq"
+ try:
+ os.O_LARGEFILE
+ except AttributeError:
+ start_len = "ll"
else:
- try:
- os.O_LARGEFILE
- except AttributeError:
- start_len = "ll"
- else:
- start_len = "qq"
+ start_len = "qq"
if (sys.platform.startswith(('netbsd', 'freebsd', 'openbsd', 'bsdos'))
or sys.platform == 'darwin'):
@@ -45,12 +41,11 @@ def get_lockdata():
lockdata = struct.pack('hh'+start_len+'hh', fcntl.F_WRLCK, 0, 0, 0, 0, 0)
if lockdata:
if verbose:
- print 'struct.pack: ', repr(lockdata)
+ print('struct.pack: ', repr(lockdata))
return lockdata
lockdata = get_lockdata()
-
class TestFcntl(unittest.TestCase):
def setUp(self):
@@ -63,19 +58,19 @@ class TestFcntl(unittest.TestCase):
def test_fcntl_fileno(self):
# the example from the library docs
- self.f = open(TESTFN, 'w')
+ self.f = open(TESTFN, 'wb')
rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETFL, os.O_NONBLOCK)
if verbose:
- print 'Status from fcntl with O_NONBLOCK: ', rv
+ print('Status from fcntl with O_NONBLOCK: ', rv)
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(self.f.fileno(), fcntl.F_SETLKW, lockdata)
if verbose:
- print 'String from fcntl with F_SETLKW: ', repr(rv)
+ print('String from fcntl with F_SETLKW: ', repr(rv))
self.f.close()
def test_fcntl_file_descriptor(self):
# again, but pass the file rather than numeric descriptor
- self.f = open(TESTFN, 'w')
+ self.f = open(TESTFN, 'wb')
rv = fcntl.fcntl(self.f, fcntl.F_SETFL, os.O_NONBLOCK)
if sys.platform not in ['os2emx']:
rv = fcntl.fcntl(self.f, fcntl.F_SETLKW, lockdata)
diff --git a/Lib/test/test_file.py b/Lib/test/test_file.py
index dffa4b56eb6..bb0da792f55 100644
--- a/Lib/test/test_file.py
+++ b/Lib/test/test_file.py
@@ -1,8 +1,3 @@
-# NOTE: this file tests the new `io` library backported from Python 3.x.
-# Similar tests for the builtin file object can be found in test_file2k.py.
-
-from __future__ import print_function
-
import sys
import os
import unittest
@@ -12,8 +7,8 @@ from weakref import proxy
import io
import _pyio as pyio
-from test.test_support import TESTFN, run_unittest
-from UserList import UserList
+from test.support import TESTFN, run_unittest
+from collections import UserList
class AutoFileTests(unittest.TestCase):
# file tests for which a test file is automatically set up
@@ -49,7 +44,7 @@ class AutoFileTests(unittest.TestCase):
a = array('b', b'x'*10)
self.f = self.open(TESTFN, 'rb')
n = self.f.readinto(a)
- self.assertEqual(b'12', a.tostring()[:n])
+ self.assertEqual(b'12', a.tobytes()[:n])
def testReadinto_text(self):
# verify readinto refuses text files
@@ -100,7 +95,7 @@ class AutoFileTests(unittest.TestCase):
methods = [('fileno', ()),
('flush', ()),
('isatty', ()),
- ('next', ()),
+ ('__next__', ()),
('read', ()),
('write', (b"",)),
('readline', ()),
@@ -111,8 +106,7 @@ class AutoFileTests(unittest.TestCase):
('writelines', ([],)),
('__iter__', ()),
]
- if not sys.platform.startswith('atheos'):
- methods.append(('truncate', ()))
+ methods.append(('truncate', ()))
# __exit__ should close the file
self.f.__exit__(None, None, None)
@@ -127,7 +121,7 @@ class AutoFileTests(unittest.TestCase):
self.assertEqual(self.f.__exit__(None, None, None), None)
# it must also return None if an exception was given
try:
- 1 // 0
+ 1/0
except:
self.assertEqual(self.f.__exit__(*sys.exc_info()), None)
@@ -287,7 +281,7 @@ class OtherFileTests(unittest.TestCase):
except ValueError:
self.fail("readinto() after next() with supposedly empty "
"iteration-buffer failed anyway")
- line = buf.tostring()
+ line = buf.tobytes()
if line != testline:
self.fail("readinto() after next() with empty buffer "
"failed. Got %r, expected %r" % (line, testline))
@@ -309,6 +303,8 @@ class OtherFileTests(unittest.TestCase):
if lines != testlines:
self.fail("readlines() after next() with empty buffer "
"failed. Got %r, expected %r" % (line, testline))
+ f.close()
+
# Reading after iteration hit EOF shouldn't hurt either
f = self.open(TESTFN, 'rb')
try:
diff --git a/Lib/test/test_file2k.py b/Lib/test/test_file2k.py
deleted file mode 100644
index 0c633b4e8fa..00000000000
--- a/Lib/test/test_file2k.py
+++ /dev/null
@@ -1,832 +0,0 @@
-import sys
-import os
-import unittest
-import itertools
-import select
-import signal
-import subprocess
-import time
-from array import array
-from weakref import proxy
-try:
- import threading
-except ImportError:
- threading = None
-
-from test import test_support
-from test.test_support import TESTFN, run_unittest
-from UserList import UserList
-
-class AutoFileTests(unittest.TestCase):
- # file tests for which a test file is automatically set up
-
- def setUp(self):
- self.f = open(TESTFN, 'wb')
-
- def tearDown(self):
- if self.f:
- self.f.close()
- os.remove(TESTFN)
-
- def testWeakRefs(self):
- # verify weak references
- p = proxy(self.f)
- p.write('teststring')
- self.assertEqual(self.f.tell(), p.tell())
- self.f.close()
- self.f = None
- self.assertRaises(ReferenceError, getattr, p, 'tell')
-
- def testAttributes(self):
- # verify expected attributes exist
- f = self.f
- with test_support.check_py3k_warnings():
- softspace = f.softspace
- f.name # merely shouldn't blow up
- f.mode # ditto
- f.closed # ditto
-
- with test_support.check_py3k_warnings():
- # verify softspace is writable
- f.softspace = softspace # merely shouldn't blow up
-
- # verify the others aren't
- for attr in 'name', 'mode', 'closed':
- self.assertRaises((AttributeError, TypeError), setattr, f, attr, 'oops')
-
- def testReadinto(self):
- # verify readinto
- self.f.write('12')
- self.f.close()
- a = array('c', 'x'*10)
- self.f = open(TESTFN, 'rb')
- n = self.f.readinto(a)
- self.assertEqual('12', a.tostring()[:n])
-
- def testWritelinesUserList(self):
- # verify writelines with instance sequence
- l = UserList(['1', '2'])
- self.f.writelines(l)
- self.f.close()
- self.f = open(TESTFN, 'rb')
- buf = self.f.read()
- self.assertEqual(buf, '12')
-
- def testWritelinesIntegers(self):
- # verify writelines with integers
- self.assertRaises(TypeError, self.f.writelines, [1, 2, 3])
-
- def testWritelinesIntegersUserList(self):
- # verify writelines with integers in UserList
- l = UserList([1,2,3])
- self.assertRaises(TypeError, self.f.writelines, l)
-
- def testWritelinesNonString(self):
- # verify writelines with non-string object
- class NonString:
- pass
-
- self.assertRaises(TypeError, self.f.writelines,
- [NonString(), NonString()])
-
- def testRepr(self):
- # verify repr works
- self.assertTrue(repr(self.f).startswith("<open file '" + TESTFN))
- # see issue #14161
- # Windows doesn't like \r\n\t" in the file name, but ' is ok
- fname = 'xx\rxx\nxx\'xx"xx' if sys.platform != "win32" else "xx'xx"
- with open(fname, 'w') as f:
- self.addCleanup(os.remove, fname)
- self.assertTrue(repr(f).startswith(
- "<open file %r, mode 'w' at" % fname))
-
- def testErrors(self):
- self.f.close()
- self.f = open(TESTFN, 'rb')
- f = self.f
- self.assertEqual(f.name, TESTFN)
- self.assertTrue(not f.isatty())
- self.assertTrue(not f.closed)
-
- self.assertRaises(TypeError, f.readinto, "")
- f.close()
- self.assertTrue(f.closed)
-
- def testMethods(self):
- methods = ['fileno', 'flush', 'isatty', 'next', 'read', 'readinto',
- 'readline', 'readlines', 'seek', 'tell', 'truncate',
- 'write', '__iter__']
- deprecated_methods = ['xreadlines']
- if sys.platform.startswith('atheos'):
- methods.remove('truncate')
-
- # __exit__ should close the file
- self.f.__exit__(None, None, None)
- self.assertTrue(self.f.closed)
-
- for methodname in methods:
- method = getattr(self.f, methodname)
- # should raise on closed file
- self.assertRaises(ValueError, method)
- with test_support.check_py3k_warnings():
- for methodname in deprecated_methods:
- method = getattr(self.f, methodname)
- self.assertRaises(ValueError, method)
- self.assertRaises(ValueError, self.f.writelines, [])
-
- # file is closed, __exit__ shouldn't do anything
- self.assertEqual(self.f.__exit__(None, None, None), None)
- # it must also return None if an exception was given
- try:
- 1 // 0
- except:
- self.assertEqual(self.f.__exit__(*sys.exc_info()), None)
-
- def testReadWhenWriting(self):
- self.assertRaises(IOError, self.f.read)
-
- def testNastyWritelinesGenerator(self):
- def nasty():
- for i in range(5):
- if i == 3:
- self.f.close()
- yield str(i)
- self.assertRaises(ValueError, self.f.writelines, nasty())
-
- def testIssue5677(self):
- # Remark: Do not perform more than one test per open file,
- # since that does NOT catch the readline error on Windows.
- data = 'xxx'
- for mode in ['w', 'wb', 'a', 'ab']:
- for attr in ['read', 'readline', 'readlines']:
- self.f = open(TESTFN, mode)
- self.f.write(data)
- self.assertRaises(IOError, getattr(self.f, attr))
- self.f.close()
-
- self.f = open(TESTFN, mode)
- self.f.write(data)
- self.assertRaises(IOError, lambda: [line for line in self.f])
- self.f.close()
-
- self.f = open(TESTFN, mode)
- self.f.write(data)
- self.assertRaises(IOError, self.f.readinto, bytearray(len(data)))
- self.f.close()
-
- for mode in ['r', 'rb', 'U', 'Ub', 'Ur', 'rU', 'rbU', 'rUb']:
- self.f = open(TESTFN, mode)
- self.assertRaises(IOError, self.f.write, data)
- self.f.close()
-
- self.f = open(TESTFN, mode)
- self.assertRaises(IOError, self.f.writelines, [data, data])
- self.f.close()
-
- self.f = open(TESTFN, mode)
- self.assertRaises(IOError, self.f.truncate)
- self.f.close()
-
-class OtherFileTests(unittest.TestCase):
-
- def testOpenDir(self):
- this_dir = os.path.dirname(__file__) or os.curdir
- for mode in (None, "w"):
- try:
- if mode:
- f = open(this_dir, mode)
- else:
- f = open(this_dir)
- except IOError as e:
- self.assertEqual(e.filename, this_dir)
- else:
- self.fail("opening a directory didn't raise an IOError")
-
- def testModeStrings(self):
- # check invalid mode strings
- for mode in ("", "aU", "wU+"):
- try:
- f = open(TESTFN, mode)
- except ValueError:
- pass
- else:
- f.close()
- self.fail('%r is an invalid file mode' % mode)
-
- # Some invalid modes fail on Windows, but pass on Unix
- # Issue3965: avoid a crash on Windows when filename is unicode
- for name in (TESTFN, unicode(TESTFN), unicode(TESTFN + '\t')):
- try:
- f = open(name, "rr")
- except (IOError, ValueError):
- pass
- else:
- f.close()
-
- def testStdin(self):
- # This causes the interpreter to exit on OSF1 v5.1.
- if sys.platform != 'osf1V5':
- self.assertRaises(IOError, sys.stdin.seek, -1)
- else:
- print >>sys.__stdout__, (
- ' Skipping sys.stdin.seek(-1), it may crash the interpreter.'
- ' Test manually.')
- self.assertRaises(IOError, sys.stdin.truncate)
-
- def testUnicodeOpen(self):
- # verify repr works for unicode too
- f = open(unicode(TESTFN), "w")
- self.assertTrue(repr(f).startswith("<open file u'" + TESTFN))
- f.close()
- os.unlink(TESTFN)
-
- def testBadModeArgument(self):
- # verify that we get a sensible error message for bad mode argument
- bad_mode = "qwerty"
- try:
- f = open(TESTFN, bad_mode)
- except ValueError, msg:
- if msg.args[0] != 0:
- s = str(msg)
- if TESTFN in s or bad_mode not in s:
- self.fail("bad error message for invalid mode: %s" % s)
- # if msg.args[0] == 0, we're probably on Windows where there may
- # be no obvious way to discover why open() failed.
- else:
- f.close()
- self.fail("no error for invalid mode: %s" % bad_mode)
-
- def testSetBufferSize(self):
- # make sure that explicitly setting the buffer size doesn't cause
- # misbehaviour especially with repeated close() calls
- for s in (-1, 0, 1, 512):
- try:
- f = open(TESTFN, 'w', s)
- f.write(str(s))
- f.close()
- f.close()
- f = open(TESTFN, 'r', s)
- d = int(f.read())
- f.close()
- f.close()
- except IOError, msg:
- self.fail('error setting buffer size %d: %s' % (s, str(msg)))
- self.assertEqual(d, s)
-
- def testTruncateOnWindows(self):
- os.unlink(TESTFN)
-
- def bug801631():
- # SF bug <http://www.python.org/sf/801631>
- # "file.truncate fault on windows"
- f = open(TESTFN, 'wb')
- f.write('12345678901') # 11 bytes
- f.close()
-
- f = open(TESTFN,'rb+')
- data = f.read(5)
- if data != '12345':
- self.fail("Read on file opened for update failed %r" % data)
- if f.tell() != 5:
- self.fail("File pos after read wrong %d" % f.tell())
-
- f.truncate()
- if f.tell() != 5:
- self.fail("File pos after ftruncate wrong %d" % f.tell())
-
- f.close()
- size = os.path.getsize(TESTFN)
- if size != 5:
- self.fail("File size after ftruncate wrong %d" % size)
-
- try:
- bug801631()
- finally:
- os.unlink(TESTFN)
-
- def testIteration(self):
- # Test the complex interaction when mixing file-iteration and the
- # various read* methods. Ostensibly, the mixture could just be tested
- # to work when it should work according to the Python language,
- # instead of fail when it should fail according to the current CPython
- # implementation. People don't always program Python the way they
- # should, though, and the implemenation might change in subtle ways,
- # so we explicitly test for errors, too; the test will just have to
- # be updated when the implementation changes.
- dataoffset = 16384
- filler = "ham\n"
- assert not dataoffset % len(filler), \
- "dataoffset must be multiple of len(filler)"
- nchunks = dataoffset // len(filler)
- testlines = [
- "spam, spam and eggs\n",
- "eggs, spam, ham and spam\n",
- "saussages, spam, spam and eggs\n",
- "spam, ham, spam and eggs\n",
- "spam, spam, spam, spam, spam, ham, spam\n",
- "wonderful spaaaaaam.\n"
- ]
- methods = [("readline", ()), ("read", ()), ("readlines", ()),
- ("readinto", (array("c", " "*100),))]
-
- try:
- # Prepare the testfile
- bag = open(TESTFN, "w")
- bag.write(filler * nchunks)
- bag.writelines(testlines)
- bag.close()
- # Test for appropriate errors mixing read* and iteration
- for methodname, args in methods:
- f = open(TESTFN)
- if f.next() != filler:
- self.fail, "Broken testfile"
- meth = getattr(f, methodname)
- try:
- meth(*args)
- except ValueError:
- pass
- else:
- self.fail("%s%r after next() didn't raise ValueError" %
- (methodname, args))
- f.close()
-
- # Test to see if harmless (by accident) mixing of read* and
- # iteration still works. This depends on the size of the internal
- # iteration buffer (currently 8192,) but we can test it in a
- # flexible manner. Each line in the bag o' ham is 4 bytes
- # ("h", "a", "m", "\n"), so 4096 lines of that should get us
- # exactly on the buffer boundary for any power-of-2 buffersize
- # between 4 and 16384 (inclusive).
- f = open(TESTFN)
- for i in range(nchunks):
- f.next()
- testline = testlines.pop(0)
- try:
- line = f.readline()
- except ValueError:
- self.fail("readline() after next() with supposedly empty "
- "iteration-buffer failed anyway")
- if line != testline:
- self.fail("readline() after next() with empty buffer "
- "failed. Got %r, expected %r" % (line, testline))
- testline = testlines.pop(0)
- buf = array("c", "\x00" * len(testline))
- try:
- f.readinto(buf)
- except ValueError:
- self.fail("readinto() after next() with supposedly empty "
- "iteration-buffer failed anyway")
- line = buf.tostring()
- if line != testline:
- self.fail("readinto() after next() with empty buffer "
- "failed. Got %r, expected %r" % (line, testline))
-
- testline = testlines.pop(0)
- try:
- line = f.read(len(testline))
- except ValueError:
- self.fail("read() after next() with supposedly empty "
- "iteration-buffer failed anyway")
- if line != testline:
- self.fail("read() after next() with empty buffer "
- "failed. Got %r, expected %r" % (line, testline))
- try:
- lines = f.readlines()
- except ValueError:
- self.fail("readlines() after next() with supposedly empty "
- "iteration-buffer failed anyway")
- if lines != testlines:
- self.fail("readlines() after next() with empty buffer "
- "failed. Got %r, expected %r" % (line, testline))
- # Reading after iteration hit EOF shouldn't hurt either
- f = open(TESTFN)
- try:
- for line in f:
- pass
- try:
- f.readline()
- f.readinto(buf)
- f.read()
- f.readlines()
- except ValueError:
- self.fail("read* failed after next() consumed file")
- finally:
- f.close()
- finally:
- os.unlink(TESTFN)
-
-class FileSubclassTests(unittest.TestCase):
-
- def testExit(self):
- # test that exiting with context calls subclass' close
- class C(file):
- def __init__(self, *args):
- self.subclass_closed = False
- file.__init__(self, *args)
- def close(self):
- self.subclass_closed = True
- file.close(self)
-
- with C(TESTFN, 'w') as f:
- pass
- self.assertTrue(f.subclass_closed)
-
-
-@unittest.skipUnless(threading, 'Threading required for this test.')
-class FileThreadingTests(unittest.TestCase):
- # These tests check the ability to call various methods of file objects
- # (including close()) concurrently without crashing the Python interpreter.
- # See #815646, #595601
-
- def setUp(self):
- self._threads = test_support.threading_setup()
- self.f = None
- self.filename = TESTFN
- with open(self.filename, "w") as f:
- f.write("\n".join("0123456789"))
- self._count_lock = threading.Lock()
- self.close_count = 0
- self.close_success_count = 0
- self.use_buffering = False
-
- def tearDown(self):
- if self.f:
- try:
- self.f.close()
- except (EnvironmentError, ValueError):
- pass
- try:
- os.remove(self.filename)
- except EnvironmentError:
- pass
- test_support.threading_cleanup(*self._threads)
-
- def _create_file(self):
- if self.use_buffering:
- self.f = open(self.filename, "w+", buffering=1024*16)
- else:
- self.f = open(self.filename, "w+")
-
- def _close_file(self):
- with self._count_lock:
- self.close_count += 1
- self.f.close()
- with self._count_lock:
- self.close_success_count += 1
-
- def _close_and_reopen_file(self):
- self._close_file()
- # if close raises an exception thats fine, self.f remains valid so
- # we don't need to reopen.
- self._create_file()
-
- def _run_workers(self, func, nb_workers, duration=0.2):
- with self._count_lock:
- self.close_count = 0
- self.close_success_count = 0
- self.do_continue = True
- threads = []
- try:
- for i in range(nb_workers):
- t = threading.Thread(target=func)
- t.start()
- threads.append(t)
- for _ in xrange(100):
- time.sleep(duration/100)
- with self._count_lock:
- if self.close_count-self.close_success_count > nb_workers+1:
- if test_support.verbose:
- print 'Q',
- break
- time.sleep(duration)
- finally:
- self.do_continue = False
- for t in threads:
- t.join()
-
- def _test_close_open_io(self, io_func, nb_workers=5):
- def worker():
- self._create_file()
- funcs = itertools.cycle((
- lambda: io_func(),
- lambda: self._close_and_reopen_file(),
- ))
- for f in funcs:
- if not self.do_continue:
- break
- try:
- f()
- except (IOError, ValueError):
- pass
- self._run_workers(worker, nb_workers)
- if test_support.verbose:
- # Useful verbose statistics when tuning this test to take
- # less time to run but still ensuring that its still useful.
- #
- # the percent of close calls that raised an error
- percent = 100. - 100.*self.close_success_count/self.close_count
- print self.close_count, ('%.4f ' % percent),
-
- def test_close_open(self):
- def io_func():
- pass
- self._test_close_open_io(io_func)
-
- def test_close_open_flush(self):
- def io_func():
- self.f.flush()
- self._test_close_open_io(io_func)
-
- def test_close_open_iter(self):
- def io_func():
- list(iter(self.f))
- self._test_close_open_io(io_func)
-
- def test_close_open_isatty(self):
- def io_func():
- self.f.isatty()
- self._test_close_open_io(io_func)
-
- def test_close_open_print(self):
- def io_func():
- print >> self.f, ''
- self._test_close_open_io(io_func)
-
- def test_close_open_print_buffered(self):
- self.use_buffering = True
- def io_func():
- print >> self.f, ''
- self._test_close_open_io(io_func)
-
- def test_close_open_read(self):
- def io_func():
- self.f.read(0)
- self._test_close_open_io(io_func)
-
- def test_close_open_readinto(self):
- def io_func():
- a = array('c', 'xxxxx')
- self.f.readinto(a)
- self._test_close_open_io(io_func)
-
- def test_close_open_readline(self):
- def io_func():
- self.f.readline()
- self._test_close_open_io(io_func)
-
- def test_close_open_readlines(self):
- def io_func():
- self.f.readlines()
- self._test_close_open_io(io_func)
-
- def test_close_open_seek(self):
- def io_func():
- self.f.seek(0, 0)
- self._test_close_open_io(io_func)
-
- def test_close_open_tell(self):
- def io_func():
- self.f.tell()
- self._test_close_open_io(io_func)
-
- def test_close_open_truncate(self):
- def io_func():
- self.f.truncate()
- self._test_close_open_io(io_func)
-
- def test_close_open_write(self):
- def io_func():
- self.f.write('')
- self._test_close_open_io(io_func)
-
- def test_close_open_writelines(self):
- def io_func():
- self.f.writelines('')
- self._test_close_open_io(io_func)
-
-
-@unittest.skipUnless(os.name == 'posix', 'test requires a posix system.')
-class TestFileSignalEINTR(unittest.TestCase):
- def _test_reading(self, data_to_write, read_and_verify_code, method_name,
- universal_newlines=False):
- """Generic buffered read method test harness to verify EINTR behavior.
-
- Also validates that Python signal handlers are run during the read.
-
- Args:
- data_to_write: String to write to the child process for reading
- before sending it a signal, confirming the signal was handled,
- writing a final newline char and closing the infile pipe.
- read_and_verify_code: Single "line" of code to read from a file
- object named 'infile' and validate the result. This will be
- executed as part of a python subprocess fed data_to_write.
- method_name: The name of the read method being tested, for use in
- an error message on failure.
- universal_newlines: If True, infile will be opened in universal
- newline mode in the child process.
- """
- if universal_newlines:
- # Test the \r\n -> \n conversion while we're at it.
- data_to_write = data_to_write.replace('\n', '\r\n')
- infile_setup_code = 'infile = os.fdopen(sys.stdin.fileno(), "rU")'
- else:
- infile_setup_code = 'infile = sys.stdin'
- # Total pipe IO in this function is smaller than the minimum posix OS
- # pipe buffer size of 512 bytes. No writer should block.
- assert len(data_to_write) < 512, 'data_to_write must fit in pipe buf.'
-
- child_code = (
- 'import os, signal, sys ;'
- 'signal.signal('
- 'signal.SIGINT, lambda s, f: sys.stderr.write("$\\n")) ;'
- + infile_setup_code + ' ;' +
- 'assert isinstance(infile, file) ;'
- 'sys.stderr.write("Go.\\n") ;'
- + read_and_verify_code)
- reader_process = subprocess.Popen(
- [sys.executable, '-c', child_code],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- # Wait for the signal handler to be installed.
- go = reader_process.stderr.read(4)
- if go != 'Go.\n':
- reader_process.kill()
- self.fail('Error from %s process while awaiting "Go":\n%s' % (
- method_name, go+reader_process.stderr.read()))
- reader_process.stdin.write(data_to_write)
- signals_sent = 0
- rlist = []
- # We don't know when the read_and_verify_code in our child is actually
- # executing within the read system call we want to interrupt. This
- # loop waits for a bit before sending the first signal to increase
- # the likelihood of that. Implementations without correct EINTR
- # and signal handling usually fail this test.
- while not rlist:
- rlist, _, _ = select.select([reader_process.stderr], (), (), 0.05)
- reader_process.send_signal(signal.SIGINT)
- # Give the subprocess time to handle it before we loop around and
- # send another one. On OSX the second signal happening close to
- # immediately after the first was causing the subprocess to crash
- # via the OS's default SIGINT handler.
- time.sleep(0.1)
- signals_sent += 1
- if signals_sent > 200:
- reader_process.kill()
- self.fail("failed to handle signal during %s." % method_name)
- # This assumes anything unexpected that writes to stderr will also
- # write a newline. That is true of the traceback printing code.
- signal_line = reader_process.stderr.readline()
- if signal_line != '$\n':
- reader_process.kill()
- self.fail('Error from %s process while awaiting signal:\n%s' % (
- method_name, signal_line+reader_process.stderr.read()))
- # We append a newline to our input so that a readline call can
- # end on its own before the EOF is seen.
- stdout, stderr = reader_process.communicate(input='\n')
- if reader_process.returncode != 0:
- self.fail('%s() process exited rc=%d.\nSTDOUT:\n%s\nSTDERR:\n%s' % (
- method_name, reader_process.returncode, stdout, stderr))
-
- def test_readline(self, universal_newlines=False):
- """file.readline must handle signals and not lose data."""
- self._test_reading(
- data_to_write='hello, world!',
- read_and_verify_code=(
- 'line = infile.readline() ;'
- 'expected_line = "hello, world!\\n" ;'
- 'assert line == expected_line, ('
- '"read %r expected %r" % (line, expected_line))'
- ),
- method_name='readline',
- universal_newlines=universal_newlines)
-
- def test_readline_with_universal_newlines(self):
- self.test_readline(universal_newlines=True)
-
- def test_readlines(self, universal_newlines=False):
- """file.readlines must handle signals and not lose data."""
- self._test_reading(
- data_to_write='hello\nworld!',
- read_and_verify_code=(
- 'lines = infile.readlines() ;'
- 'expected_lines = ["hello\\n", "world!\\n"] ;'
- 'assert lines == expected_lines, ('
- '"readlines returned wrong data.\\n" '
- '"got lines %r\\nexpected %r" '
- '% (lines, expected_lines))'
- ),
- method_name='readlines',
- universal_newlines=universal_newlines)
-
- def test_readlines_with_universal_newlines(self):
- self.test_readlines(universal_newlines=True)
-
- def test_readall(self):
- """Unbounded file.read() must handle signals and not lose data."""
- self._test_reading(
- data_to_write='hello, world!abcdefghijklm',
- read_and_verify_code=(
- 'data = infile.read() ;'
- 'expected_data = "hello, world!abcdefghijklm\\n";'
- 'assert data == expected_data, ('
- '"read %r expected %r" % (data, expected_data))'
- ),
- method_name='unbounded read')
-
- def test_readinto(self):
- """file.readinto must handle signals and not lose data."""
- self._test_reading(
- data_to_write='hello, world!',
- read_and_verify_code=(
- 'data = bytearray(50) ;'
- 'num_read = infile.readinto(data) ;'
- 'expected_data = "hello, world!\\n";'
- 'assert data[:num_read] == expected_data, ('
- '"read %r expected %r" % (data, expected_data))'
- ),
- method_name='readinto')
-
-
-class StdoutTests(unittest.TestCase):
-
- def test_move_stdout_on_write(self):
- # Issue 3242: sys.stdout can be replaced (and freed) during a
- # print statement; prevent a segfault in this case
- save_stdout = sys.stdout
-
- class File:
- def write(self, data):
- if '\n' in data:
- sys.stdout = save_stdout
-
- try:
- sys.stdout = File()
- print "some text"
- finally:
- sys.stdout = save_stdout
-
- def test_del_stdout_before_print(self):
- # Issue 4597: 'print' with no argument wasn't reporting when
- # sys.stdout was deleted.
- save_stdout = sys.stdout
- del sys.stdout
- try:
- print
- except RuntimeError as e:
- self.assertEqual(str(e), "lost sys.stdout")
- else:
- self.fail("Expected RuntimeError")
- finally:
- sys.stdout = save_stdout
-
- def test_unicode(self):
- import subprocess
-
- def get_message(encoding, *code):
- code = '\n'.join(code)
- env = os.environ.copy()
- env['PYTHONIOENCODING'] = encoding
- process = subprocess.Popen([sys.executable, "-c", code],
- stdout=subprocess.PIPE, env=env)
- stdout, stderr = process.communicate()
- self.assertEqual(process.returncode, 0)
- return stdout
-
- def check_message(text, encoding, expected):
- stdout = get_message(encoding,
- "import sys",
- "sys.stdout.write(%r)" % text,
- "sys.stdout.flush()")
- self.assertEqual(stdout, expected)
-
- # test the encoding
- check_message(u'15\u20ac', "iso-8859-15", "15\xa4")
- check_message(u'15\u20ac', "utf-8", '15\xe2\x82\xac')
- check_message(u'15\u20ac', "utf-16-le", '1\x005\x00\xac\x20')
-
- # test the error handler
- check_message(u'15\u20ac', "iso-8859-1:ignore", "15")
- check_message(u'15\u20ac', "iso-8859-1:replace", "15?")
- check_message(u'15\u20ac', "iso-8859-1:backslashreplace", "15\\u20ac")
-
- # test the buffer API
- for objtype in ('buffer', 'bytearray'):
- stdout = get_message('ascii',
- 'import sys',
- r'sys.stdout.write(%s("\xe9"))' % objtype,
- 'sys.stdout.flush()')
- self.assertEqual(stdout, "\xe9")
-
-
-def test_main():
- # Historically, these tests have been sloppy about removing TESTFN.
- # So get rid of it no matter what.
- try:
- run_unittest(AutoFileTests, OtherFileTests, FileSubclassTests,
- FileThreadingTests, TestFileSignalEINTR, StdoutTests)
- finally:
- if os.path.exists(TESTFN):
- os.unlink(TESTFN)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_file_eintr.py b/Lib/test/test_file_eintr.py
index 76bff3aed41..b4e18ce17d1 100644
--- a/Lib/test/test_file_eintr.py
+++ b/Lib/test/test_file_eintr.py
@@ -1,9 +1,6 @@
# Written to test interrupted system calls interfering with our many buffered
# IO implementations. http://bugs.python.org/issue12268
#
-# This tests the '_io' module. Similar tests for Python 2.x's older
-# default file I/O implementation exist within test_file2k.py.
-#
# It was suggested that this code could be merged into test_io and the tests
# made to work using the same method as the existing signal tests in test_io.
# I was unable to get single process tests using alarm or setitimer that way
@@ -16,7 +13,7 @@ import select
import signal
import subprocess
import sys
-from test.test_support import run_unittest
+from test.support import run_unittest
import time
import unittest
@@ -92,7 +89,7 @@ class TestFileIOSignalInterrupt(unittest.TestCase):
# Start a subprocess to call our read method while handling a signal.
self._process = subprocess.Popen(
[sys.executable, '-u', '-c',
- 'import io, signal, sys ;'
+ 'import signal, sys ;'
'signal.signal(signal.SIGINT, '
'lambda s, f: sys.stderr.write("$\\n")) ;'
+ infile_setup_code + ' ;' +
@@ -185,7 +182,7 @@ class TestFileIOSignalInterrupt(unittest.TestCase):
class TestBufferedIOSignalInterrupt(TestFileIOSignalInterrupt):
def _generate_infile_setup_code(self):
"""Returns the infile = ... line of code to make a BufferedReader."""
- return ('infile = io.open(sys.stdin.fileno(), "rb") ;'
+ return ('infile = open(sys.stdin.fileno(), "rb") ;'
'import _io ;assert isinstance(infile, _io.BufferedReader)')
def test_readall(self):
@@ -200,7 +197,7 @@ class TestBufferedIOSignalInterrupt(TestFileIOSignalInterrupt):
class TestTextIOSignalInterrupt(TestFileIOSignalInterrupt):
def _generate_infile_setup_code(self):
"""Returns the infile = ... line of code to make a TextIOWrapper."""
- return ('infile = io.open(sys.stdin.fileno(), "rt", newline=None) ;'
+ return ('infile = open(sys.stdin.fileno(), "rt", newline=None) ;'
'import _io ;assert isinstance(infile, _io.TextIOWrapper)')
def test_readline(self):
diff --git a/Lib/test/test_filecmp.py b/Lib/test/test_filecmp.py
index 4739ede4eae..09599794ad9 100644
--- a/Lib/test/test_filecmp.py
+++ b/Lib/test/test_filecmp.py
@@ -1,13 +1,13 @@
import os, filecmp, shutil, tempfile
import unittest
-from test import test_support
+from test import support
class FileCompareTestCase(unittest.TestCase):
def setUp(self):
- self.name = test_support.TESTFN
- self.name_same = test_support.TESTFN + '-same'
- self.name_diff = test_support.TESTFN + '-diff'
+ self.name = support.TESTFN
+ self.name_same = support.TESTFN + '-same'
+ self.name_diff = support.TESTFN + '-diff'
data = 'Contents of file go here.\n'
for name in [self.name, self.name_same, self.name_diff]:
output = open(name, 'w')
@@ -98,37 +98,43 @@ class DirCompareTestCase(unittest.TestCase):
def test_dircmp(self):
# Check attributes for comparison of two identical directories
- d = filecmp.dircmp(self.dir, self.dir_same)
+ left_dir, right_dir = self.dir, self.dir_same
+ d = filecmp.dircmp(left_dir, right_dir)
+ self.assertEqual(d.left, left_dir)
+ self.assertEqual(d.right, right_dir)
if self.caseinsensitive:
self.assertEqual([d.left_list, d.right_list],[['file'], ['FiLe']])
else:
self.assertEqual([d.left_list, d.right_list],[['file'], ['file']])
- self.assertTrue(d.common == ['file'])
+ self.assertEqual(d.common, ['file'])
self.assertTrue(d.left_only == d.right_only == [])
- self.assertTrue(d.same_files == ['file'])
- self.assertTrue(d.diff_files == [])
+ self.assertEqual(d.same_files, ['file'])
+ self.assertEqual(d.diff_files, [])
# Check attributes for comparison of two different directories
- d = filecmp.dircmp(self.dir, self.dir_diff)
- self.assertTrue(d.left_list == ['file'])
+ left_dir, right_dir = self.dir, self.dir_diff
+ d = filecmp.dircmp(left_dir, right_dir)
+ self.assertEqual(d.left, left_dir)
+ self.assertEqual(d.right, right_dir)
+ self.assertEqual(d.left_list, ['file'])
self.assertTrue(d.right_list == ['file', 'file2'])
- self.assertTrue(d.common == ['file'])
- self.assertTrue(d.left_only == [])
- self.assertTrue(d.right_only == ['file2'])
- self.assertTrue(d.same_files == ['file'])
- self.assertTrue(d.diff_files == [])
+ self.assertEqual(d.common, ['file'])
+ self.assertEqual(d.left_only, [])
+ self.assertEqual(d.right_only, ['file2'])
+ self.assertEqual(d.same_files, ['file'])
+ self.assertEqual(d.diff_files, [])
# Add different file2
output = open(os.path.join(self.dir, 'file2'), 'w')
output.write('Different contents.\n')
output.close()
d = filecmp.dircmp(self.dir, self.dir_diff)
- self.assertTrue(d.same_files == ['file'])
- self.assertTrue(d.diff_files == ['file2'])
+ self.assertEqual(d.same_files, ['file'])
+ self.assertEqual(d.diff_files, ['file2'])
def test_main():
- test_support.run_unittest(FileCompareTestCase, DirCompareTestCase)
+ support.run_unittest(FileCompareTestCase, DirCompareTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_fileinput.py b/Lib/test/test_fileinput.py
index 84aed1ab0ca..f312882b2ab 100644
--- a/Lib/test/test_fileinput.py
+++ b/Lib/test/test_fileinput.py
@@ -4,10 +4,10 @@ Nick Mathewson
'''
import unittest
-from test.test_support import verbose, TESTFN, run_unittest
-from test.test_support import unlink as safe_unlink
+from test.support import verbose, TESTFN, run_unittest
+from test.support import unlink as safe_unlink
import sys, re
-from StringIO import StringIO
+from io import StringIO
from fileinput import FileInput, hook_encoded
# The fileinput module has 2 interfaces: the FileInput class which does
@@ -20,18 +20,21 @@ from fileinput import FileInput, hook_encoded
def writeTmp(i, lines, mode='w'): # opening in text mode is the default
name = TESTFN + str(i)
f = open(name, mode)
- f.writelines(lines)
+ for line in lines:
+ f.write(line)
f.close()
return name
def remove_tempfiles(*names):
for name in names:
- safe_unlink(name)
+ if name:
+ safe_unlink(name)
class BufferSizesTests(unittest.TestCase):
def test_buffer_sizes(self):
# First, run the tests with default and teeny buffer size.
for round, bs in (0, 0), (1, 30):
+ t1 = t2 = t3 = t4 = None
try:
t1 = writeTmp(1, ["Line %s of file 1\n" % (i+1) for i in range(15)])
t2 = writeTmp(2, ["Line %s of file 2\n" % (i+1) for i in range(10)])
@@ -46,7 +49,7 @@ class BufferSizesTests(unittest.TestCase):
start = 1 + round*6
if verbose:
- print '%s. Simple iteration (bs=%s)' % (start+0, bs)
+ print('%s. Simple iteration (bs=%s)' % (start+0, bs))
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs)
lines = list(fi)
fi.close()
@@ -57,7 +60,7 @@ class BufferSizesTests(unittest.TestCase):
self.assertEqual(fi.filename(), t4)
if verbose:
- print '%s. Status variables (bs=%s)' % (start+1, bs)
+ print('%s. Status variables (bs=%s)' % (start+1, bs))
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs)
s = "x"
while s and s != 'Line 6 of file 2\n':
@@ -69,14 +72,14 @@ class BufferSizesTests(unittest.TestCase):
self.assertFalse(fi.isstdin())
if verbose:
- print '%s. Nextfile (bs=%s)' % (start+2, bs)
+ print('%s. Nextfile (bs=%s)' % (start+2, bs))
fi.nextfile()
self.assertEqual(fi.readline(), 'Line 1 of file 3\n')
self.assertEqual(fi.lineno(), 22)
fi.close()
if verbose:
- print '%s. Stdin (bs=%s)' % (start+3, bs)
+ print('%s. Stdin (bs=%s)' % (start+3, bs))
fi = FileInput(files=(t1, t2, t3, t4, '-'), bufsize=bs)
savestdin = sys.stdin
try:
@@ -90,7 +93,7 @@ class BufferSizesTests(unittest.TestCase):
sys.stdin = savestdin
if verbose:
- print '%s. Boundary conditions (bs=%s)' % (start+4, bs)
+ print('%s. Boundary conditions (bs=%s)' % (start+4, bs))
fi = FileInput(files=(t1, t2, t3, t4), bufsize=bs)
self.assertEqual(fi.lineno(), 0)
self.assertEqual(fi.filename(), None)
@@ -99,13 +102,13 @@ class BufferSizesTests(unittest.TestCase):
self.assertEqual(fi.filename(), None)
if verbose:
- print '%s. Inplace (bs=%s)' % (start+5, bs)
+ print('%s. Inplace (bs=%s)' % (start+5, bs))
savestdout = sys.stdout
try:
fi = FileInput(files=(t1, t2, t3, t4), inplace=1, bufsize=bs)
for line in fi:
line = line[:-1].upper()
- print line
+ print(line)
fi.close()
finally:
sys.stdout = savestdout
@@ -120,6 +123,7 @@ class BufferSizesTests(unittest.TestCase):
class FileInputTests(unittest.TestCase):
def test_zero_byte_files(self):
+ t1 = t2 = t3 = t4 = None
try:
t1 = writeTmp(1, [""])
t2 = writeTmp(2, [""])
@@ -143,6 +147,7 @@ class FileInputTests(unittest.TestCase):
remove_tempfiles(t1, t2, t3, t4)
def test_files_that_dont_end_with_newline(self):
+ t1 = t2 = None
try:
t1 = writeTmp(1, ["A\nB\nC"])
t2 = writeTmp(2, ["D\nE\nF"])
@@ -154,25 +159,28 @@ class FileInputTests(unittest.TestCase):
finally:
remove_tempfiles(t1, t2)
- def test_unicode_filenames(self):
- try:
- t1 = writeTmp(1, ["A\nB"])
- encoding = sys.getfilesystemencoding()
- if encoding is None:
- encoding = 'ascii'
- fi = FileInput(files=unicode(t1, encoding))
- lines = list(fi)
- self.assertEqual(lines, ["A\n", "B"])
- finally:
- remove_tempfiles(t1)
+## def test_unicode_filenames(self):
+## # XXX A unicode string is always returned by writeTmp.
+## # So is this needed?
+## try:
+## t1 = writeTmp(1, ["A\nB"])
+## encoding = sys.getfilesystemencoding()
+## if encoding is None:
+## encoding = 'ascii'
+## fi = FileInput(files=str(t1, encoding))
+## lines = list(fi)
+## self.assertEqual(lines, ["A\n", "B"])
+## finally:
+## remove_tempfiles(t1)
def test_fileno(self):
+ t1 = t2 = None
try:
t1 = writeTmp(1, ["A\nB"])
t2 = writeTmp(2, ["C\nD"])
fi = FileInput(files=(t1, t2))
self.assertEqual(fi.fileno(), -1)
- line = fi.next()
+ line =next( fi)
self.assertNotEqual(fi.fileno(), -1)
fi.nextfile()
self.assertEqual(fi.fileno(), -1)
@@ -188,9 +196,10 @@ class FileInputTests(unittest.TestCase):
self.fail("FileInput should reject invalid mode argument")
except ValueError:
pass
+ t1 = None
try:
# try opening in universal newline mode
- t1 = writeTmp(1, ["A\nB\r\nC\rD"], mode="wb")
+ t1 = writeTmp(1, [b"A\nB\r\nC\rD"], mode="wb")
fi = FileInput(files=t1, mode="U")
lines = list(fi)
self.assertEqual(lines, ["A\n", "B\n", "C\n", "D"])
@@ -200,7 +209,7 @@ class FileInputTests(unittest.TestCase):
def test_file_opening_hook(self):
try:
# cannot use openhook and inplace mode
- fi = FileInput(inplace=1, openhook=lambda f,m: None)
+ fi = FileInput(inplace=1, openhook=lambda f, m: None)
self.fail("FileInput should raise if both inplace "
"and openhook arguments are given")
except ValueError:
@@ -210,14 +219,42 @@ class FileInputTests(unittest.TestCase):
self.fail("FileInput should check openhook for being callable")
except ValueError:
pass
+ # XXX The rot13 codec was removed.
+ # So this test needs to be changed to use something else.
+ # (Or perhaps the API needs to change so we can just pass
+ # an encoding rather than using a hook?)
+## try:
+## t1 = writeTmp(1, ["A\nB"], mode="wb")
+## fi = FileInput(files=t1, openhook=hook_encoded("rot13"))
+## lines = list(fi)
+## self.assertEqual(lines, ["N\n", "O"])
+## finally:
+## remove_tempfiles(t1)
+
+ def test_context_manager(self):
try:
- t1 = writeTmp(1, ["A\nB"], mode="wb")
- fi = FileInput(files=t1, openhook=hook_encoded("rot13"))
- lines = list(fi)
- self.assertEqual(lines, ["N\n", "O"])
+ t1 = writeTmp(1, ["A\nB\nC"])
+ t2 = writeTmp(2, ["D\nE\nF"])
+ with FileInput(files=(t1, t2)) as fi:
+ lines = list(fi)
+ self.assertEqual(lines, ["A\n", "B\n", "C", "D\n", "E\n", "F"])
+ self.assertEqual(fi.filelineno(), 3)
+ self.assertEqual(fi.lineno(), 6)
+ self.assertEqual(fi._files, ())
+ finally:
+ remove_tempfiles(t1, t2)
+
+ def test_close_on_exception(self):
+ try:
+ t1 = writeTmp(1, [""])
+ with FileInput(files=t1) as fi:
+ raise IOError
+ except IOError:
+ self.assertEqual(fi._files, ())
finally:
remove_tempfiles(t1)
+
def test_main():
run_unittest(BufferSizesTests, FileInputTests)
diff --git a/Lib/test/test_fileio.py b/Lib/test/test_fileio.py
index 71ec44c31e7..b5bd8d45ad8 100644
--- a/Lib/test/test_fileio.py
+++ b/Lib/test/test_fileio.py
@@ -1,7 +1,5 @@
# Adapted from test_file.py by Daniel Stutzbach
-from __future__ import unicode_literals
-
import sys
import os
import errno
@@ -9,11 +7,9 @@ import unittest
from array import array
from weakref import proxy
from functools import wraps
-from UserList import UserList
-from test.test_support import TESTFN, check_warnings, run_unittest, make_bad_fd
-from test.test_support import py3k_bytes as bytes
-from test.script_helper import run_python
+from test.support import TESTFN, check_warnings, run_unittest, make_bad_fd
+from collections import UserList
from _io import FileIO as _FileIO
@@ -65,12 +61,12 @@ class AutoFileTests(unittest.TestCase):
def testReadinto(self):
# verify readinto
- self.f.write(b"\x01\x02")
+ self.f.write(bytes([1, 2]))
self.f.close()
- a = array(b'b', b'x'*10)
+ a = array('b', b'x'*10)
self.f = _FileIO(TESTFN, 'r')
n = self.f.readinto(a)
- self.assertEqual(array(b'b', [1, 2]), a[:n])
+ self.assertEqual(array('b', [1, 2]), a[:n])
def testWritelinesList(self):
l = [b'123', b'456']
@@ -91,6 +87,7 @@ class AutoFileTests(unittest.TestCase):
def testWritelinesError(self):
self.assertRaises(TypeError, self.f.writelines, [1, 2, 3])
self.assertRaises(TypeError, self.f.writelines, None)
+ self.assertRaises(TypeError, self.f.writelines, "abc")
def test_none_args(self):
self.f.write(b"hi\nbye\nabc")
@@ -101,12 +98,15 @@ class AutoFileTests(unittest.TestCase):
self.assertEqual(self.f.readline(None), b"hi\n")
self.assertEqual(self.f.readlines(None), [b"bye\n", b"abc"])
+ def test_reject(self):
+ self.assertRaises(TypeError, self.f.write, "Hello!")
+
def testRepr(self):
- self.assertEqual(repr(self.f), "<_io.FileIO name=%r mode='%s'>"
- % (self.f.name, self.f.mode))
+ self.assertEqual(repr(self.f), "<_io.FileIO name=%r mode=%r>"
+ % (self.f.name, self.f.mode))
del self.f.name
- self.assertEqual(repr(self.f), "<_io.FileIO fd=%r mode='%s'>"
- % (self.f.fileno(), self.f.mode))
+ self.assertEqual(repr(self.f), "<_io.FileIO fd=%r mode=%r>"
+ % (self.f.fileno(), self.f.mode))
self.f.close()
self.assertEqual(repr(self.f), "<_io.FileIO [closed]>")
@@ -128,8 +128,6 @@ class AutoFileTests(unittest.TestCase):
methods = ['fileno', 'isatty', 'read', 'readinto',
'seek', 'tell', 'truncate', 'write', 'seekable',
'readable', 'writable']
- if sys.platform.startswith('atheos'):
- methods.remove('truncate')
self.f.close()
self.assertTrue(self.f.closed)
@@ -201,7 +199,7 @@ class AutoFileTests(unittest.TestCase):
@ClosedFDRaises
def testErrnoOnClosedWrite(self, f):
- f.write('a')
+ f.write(b'a')
@ClosedFDRaises
def testErrnoOnClosedSeek(self, f):
@@ -257,7 +255,7 @@ class AutoFileTests(unittest.TestCase):
@ClosedFDRaises
def testErrnoOnClosedReadinto(self, f):
f = self.ReopenForRead()
- a = array(b'b', b'x'*10)
+ a = array('b', b'x'*10)
f.readinto(a)
class OtherFileTests(unittest.TestCase):
@@ -337,6 +335,11 @@ class OtherFileTests(unittest.TestCase):
finally:
os.unlink(TESTFN)
+ def testConstructorHandlesNULChars(self):
+ fn_with_NUL = 'foo\0bar'
+ self.assertRaises(TypeError, _FileIO, fn_with_NUL, 'w')
+ self.assertRaises(TypeError, _FileIO, bytes(fn_with_NUL, 'ascii'), 'w')
+
def testInvalidFd(self):
self.assertRaises(ValueError, _FileIO, -10)
self.assertRaises(OSError, _FileIO, make_bad_fd())
@@ -430,26 +433,6 @@ class OtherFileTests(unittest.TestCase):
self.assertRaises(ValueError, _FileIO, "/some/invalid/name", "rt")
self.assertEqual(w.warnings, [])
- def test_surrogates(self):
- # Issue #8438: try to open a filename containing surrogates.
- # It should either fail because the file doesn't exist or the filename
- # can't be represented using the filesystem encoding, but not because
- # of a LookupError for the error handler "surrogateescape".
- filename = u'\udc80.txt'
- try:
- with _FileIO(filename):
- pass
- except (UnicodeEncodeError, IOError):
- pass
- # Spawn a separate Python process with a different "file system
- # default encoding", to exercise this further.
- env = dict(os.environ)
- env[b'LC_CTYPE'] = b'C'
- _, out = run_python('-c', 'import _io; _io.FileIO(%r)' % filename, env=env)
- if ('UnicodeEncodeError' not in out and
- 'IOError: [Errno 2] No such file or directory' not in out):
- self.fail('Bad output: %r' % out)
-
def testUnclosedFDOnException(self):
class MyException(Exception): pass
class MyFileIO(_FileIO):
@@ -461,6 +444,7 @@ class OtherFileTests(unittest.TestCase):
self.assertRaises(MyException, MyFileIO, fd)
os.close(fd) # should not raise OSError(EBADF)
+
def test_main():
# Historically, these tests have been sloppy about removing TESTFN.
# So get rid of it no matter what.
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 42463713cdc..4d7bbbae170 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -1,13 +1,12 @@
import unittest, struct
import os
-from test import test_support
+import sys
+from test import support
import math
from math import isinf, isnan, copysign, ldexp
import operator
-import random
-import fractions
-import sys
+import random, fractions
INF = float("inf")
NAN = float("nan")
@@ -17,10 +16,6 @@ requires_getformat = unittest.skipUnless(have_getformat,
"requires __getformat__")
requires_setformat = unittest.skipUnless(hasattr(float, "__setformat__"),
"requires __setformat__")
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(have_getformat and
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
#locate file with float format test values
test_dir = os.path.dirname(__file__) or os.curdir
@@ -31,8 +26,8 @@ class GeneralFloatCases(unittest.TestCase):
def test_float(self):
self.assertEqual(float(3.14), 3.14)
self.assertEqual(float(314), 314.0)
- self.assertEqual(float(314L), 314.0)
self.assertEqual(float(" 3.14 "), 3.14)
+ self.assertEqual(float(b" 3.14 "), 3.14)
self.assertRaises(ValueError, float, " 0x3.1 ")
self.assertRaises(ValueError, float, " -0x3.p-1 ")
self.assertRaises(ValueError, float, " +0x3.p-1 ")
@@ -40,61 +35,35 @@ class GeneralFloatCases(unittest.TestCase):
self.assertRaises(ValueError, float, "+-3.14")
self.assertRaises(ValueError, float, "-+3.14")
self.assertRaises(ValueError, float, "--3.14")
+ self.assertRaises(ValueError, float, ".nan")
+ self.assertRaises(ValueError, float, "+.inf")
+ self.assertRaises(ValueError, float, ".")
+ self.assertRaises(ValueError, float, "-.")
+ self.assertRaises(ValueError, float, b"-")
+ self.assertRaises(TypeError, float, {})
+ # Lone surrogate
+ self.assertRaises(UnicodeEncodeError, float, '\uD8F0')
# check that we don't accept alternate exponent markers
self.assertRaises(ValueError, float, "-1.7d29")
self.assertRaises(ValueError, float, "3D-14")
- if test_support.have_unicode:
- self.assertEqual(float(unicode(" 3.14 ")), 3.14)
- self.assertEqual(float(unicode(" \u0663.\u0661\u0664 ",'raw-unicode-escape')), 3.14)
-
- # extra long strings should no longer be a problem
- # (in 2.6, long unicode inputs to float raised ValueError)
+ self.assertEqual(float(" \u0663.\u0661\u0664 "), 3.14)
+ self.assertEqual(float("\N{EM SPACE}3.14\N{EN SPACE}"), 3.14)
+ # extra long strings should not be a problem
+ float(b'.' + b'1'*1000)
float('.' + '1'*1000)
- float(unicode('.' + '1'*1000))
-
- def check_conversion_to_int(self, x):
- """Check that int(x) has the correct value and type, for a float x."""
- n = int(x)
- if x >= 0.0:
- # x >= 0 and n = int(x) ==> n <= x < n + 1
- self.assertLessEqual(n, x)
- self.assertLess(x, n + 1)
- else:
- # x < 0 and n = int(x) ==> n >= x > n - 1
- self.assertGreaterEqual(n, x)
- self.assertGreater(x, n - 1)
-
- # Result should be an int if within range, else a long.
- if -sys.maxint-1 <= n <= sys.maxint:
- self.assertEqual(type(n), int)
- else:
- self.assertEqual(type(n), long)
-
- # Double check.
- self.assertEqual(type(int(n)), type(n))
-
- def test_conversion_to_int(self):
- # Check that floats within the range of an int convert to type
- # int, not long. (issue #11144.)
- boundary = float(sys.maxint + 1)
- epsilon = 2**-sys.float_info.mant_dig * boundary
-
- # These 2 floats are either side of the positive int/long boundary on
- # both 32-bit and 64-bit systems.
- self.check_conversion_to_int(boundary - epsilon)
- self.check_conversion_to_int(boundary)
-
- # These floats are either side of the negative long/int boundary on
- # 64-bit systems...
- self.check_conversion_to_int(-boundary - 2*epsilon)
- self.check_conversion_to_int(-boundary)
-
- # ... and these ones are either side of the negative long/int
- # boundary on 32-bit systems.
- self.check_conversion_to_int(-boundary - 1.0)
- self.check_conversion_to_int(-boundary - 1.0 + 2*epsilon)
-
- @test_support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
+
+ def test_error_message(self):
+ testlist = ('\xbd', '123\xbd', ' 123 456 ')
+ for s in testlist:
+ try:
+ float(s)
+ except ValueError as e:
+ self.assertIn(s.strip(), e.args[0])
+ else:
+ self.fail("Expected int(%r) to raise a ValueError", s)
+
+
+ @support.run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
def test_float_with_comma(self):
# set locale to something that doesn't use '.' for the decimal point
# float must not accept the locale specific decimal point but
@@ -119,7 +88,7 @@ class GeneralFloatCases(unittest.TestCase):
self.assertRaises(ValueError, float, " -0x3.p-1 ")
self.assertRaises(ValueError, float, " +0x3.p-1 ")
self.assertEqual(float(" 25.e-1 "), 2.5)
- self.assertEqual(test_support.fcmp(float(" .25e-1 "), .025), 0)
+ self.assertEqual(support.fcmp(float(" .25e-1 "), .025), 0)
def test_floatconversion(self):
# Make sure that calls to __float__() work properly
@@ -152,16 +121,11 @@ class GeneralFloatCases(unittest.TestCase):
def __float__(self):
return float(str(self)) + 1
- class FooUnicode(unicode):
- def __float__(self):
- return float(unicode(self)) + 1
-
self.assertAlmostEqual(float(Foo0()), 42.)
self.assertAlmostEqual(float(Foo1()), 42.)
self.assertAlmostEqual(float(Foo2()), 42.)
self.assertAlmostEqual(float(Foo3(21)), 42.)
self.assertRaises(TypeError, float, Foo4(42))
- self.assertAlmostEqual(float(FooUnicode('8')), 9.)
self.assertAlmostEqual(float(FooStr('8')), 9.)
def test_is_integer(self):
@@ -203,13 +167,38 @@ class GeneralFloatCases(unittest.TestCase):
self.assertRaises(OverflowError, float('-inf').as_integer_ratio)
self.assertRaises(ValueError, float('nan').as_integer_ratio)
+ def test_float_containment(self):
+ floats = (INF, -INF, 0.0, 1.0, NAN)
+ for f in floats:
+ self.assertIn(f, [f])
+ self.assertIn(f, (f,))
+ self.assertIn(f, {f})
+ self.assertIn(f, {f: None})
+ self.assertEqual([f].count(f), 1, "[].count('%r') != 1" % f)
+ self.assertIn(f, floats)
+
+ for f in floats:
+ # nonidentical containers, same type, same contents
+ self.assertTrue([f] == [f], "[%r] != [%r]" % (f, f))
+ self.assertTrue((f,) == (f,), "(%r,) != (%r,)" % (f, f))
+ self.assertTrue({f} == {f}, "{%r} != {%r}" % (f, f))
+ self.assertTrue({f : None} == {f: None}, "{%r : None} != "
+ "{%r : None}" % (f, f))
+
+ # identical containers
+ l, t, s, d = [f], (f,), {f}, {f: None}
+ self.assertTrue(l == l, "[%r] not equal to itself" % f)
+ self.assertTrue(t == t, "(%r,) not equal to itself" % f)
+ self.assertTrue(s == s, "{%r} not equal to itself" % f)
+ self.assertTrue(d == d, "{%r : None} not equal to itself" % f)
+
def assertEqualAndEqualSign(self, a, b):
# fail unless a == b and a and b have the same sign bit;
# the only difference from assertEqual is that this test
# distinguishes -0.0 and 0.0.
self.assertEqual((a, copysign(1.0, a)), (b, copysign(1.0, b)))
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_float_mod(self):
# Check behaviour of % operator for IEEE 754 special cases.
# In particular, check signs of zeros.
@@ -229,7 +218,7 @@ class GeneralFloatCases(unittest.TestCase):
self.assertEqualAndEqualSign(mod(1e-100, -1.0), -1.0)
self.assertEqualAndEqualSign(mod(1.0, -1.0), -0.0)
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_float_pow(self):
# test builtin pow and ** operator for IEEE 754 special cases.
# Special cases taken from section F.9.4.4 of the C99 specification
@@ -319,13 +308,14 @@ class GeneralFloatCases(unittest.TestCase):
self.assertEqualAndEqualSign(pow_op(INF, -0.0), 1.0)
self.assertEqualAndEqualSign(pow_op(NAN, -0.0), 1.0)
- # x**y raises ValueError for finite negative x and non-integral y
- self.assertRaises(ValueError, pow_op, -2.0, -0.5)
- self.assertRaises(ValueError, pow_op, -2.0, 0.5)
- self.assertRaises(ValueError, pow_op, -1.0, -0.5)
- self.assertRaises(ValueError, pow_op, -1.0, 0.5)
- self.assertRaises(ValueError, pow_op, -0.5, -0.5)
- self.assertRaises(ValueError, pow_op, -0.5, 0.5)
+ # x**y defers to complex pow for finite negative x and
+ # non-integral y.
+ self.assertEqual(type(pow_op(-2.0, -0.5)), complex)
+ self.assertEqual(type(pow_op(-2.0, 0.5)), complex)
+ self.assertEqual(type(pow_op(-1.0, -0.5)), complex)
+ self.assertEqual(type(pow_op(-1.0, 0.5)), complex)
+ self.assertEqual(type(pow_op(-0.5, -0.5)), complex)
+ self.assertEqual(type(pow_op(-0.5, 0.5)), complex)
# x**-INF is INF for abs(x) < 1
self.assertEqualAndEqualSign(pow_op(-0.5, -INF), INF)
@@ -404,13 +394,13 @@ class GeneralFloatCases(unittest.TestCase):
# check sign for results that underflow to 0
self.assertEqualAndEqualSign(pow_op(-2.0, -2000.0), 0.0)
- self.assertRaises(ValueError, pow_op, -2.0, -2000.5)
+ self.assertEqual(type(pow_op(-2.0, -2000.5)), complex)
self.assertEqualAndEqualSign(pow_op(-2.0, -2001.0), -0.0)
self.assertEqualAndEqualSign(pow_op(2.0, -2000.0), 0.0)
self.assertEqualAndEqualSign(pow_op(2.0, -2000.5), 0.0)
self.assertEqualAndEqualSign(pow_op(2.0, -2001.0), 0.0)
self.assertEqualAndEqualSign(pow_op(-0.5, 2000.0), 0.0)
- self.assertRaises(ValueError, pow_op, -0.5, 2000.5)
+ self.assertEqual(type(pow_op(-0.5, 2000.5)), complex)
self.assertEqualAndEqualSign(pow_op(-0.5, 2001.0), -0.0)
self.assertEqualAndEqualSign(pow_op(0.5, 2000.0), 0.0)
self.assertEqualAndEqualSign(pow_op(0.5, 2000.5), 0.0)
@@ -468,15 +458,15 @@ class FormatFunctionsTestCase(unittest.TestCase):
self.assertRaises(ValueError, float.__setformat__,
'chicken', 'unknown')
-BE_DOUBLE_INF = '\x7f\xf0\x00\x00\x00\x00\x00\x00'
-LE_DOUBLE_INF = ''.join(reversed(BE_DOUBLE_INF))
-BE_DOUBLE_NAN = '\x7f\xf8\x00\x00\x00\x00\x00\x00'
-LE_DOUBLE_NAN = ''.join(reversed(BE_DOUBLE_NAN))
+BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00'
+LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF))
+BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00'
+LE_DOUBLE_NAN = bytes(reversed(BE_DOUBLE_NAN))
-BE_FLOAT_INF = '\x7f\x80\x00\x00'
-LE_FLOAT_INF = ''.join(reversed(BE_FLOAT_INF))
-BE_FLOAT_NAN = '\x7f\xc0\x00\x00'
-LE_FLOAT_NAN = ''.join(reversed(BE_FLOAT_NAN))
+BE_FLOAT_INF = b'\x7f\x80\x00\x00'
+LE_FLOAT_INF = bytes(reversed(BE_FLOAT_INF))
+BE_FLOAT_NAN = b'\x7f\xc0\x00\x00'
+LE_FLOAT_NAN = bytes(reversed(BE_FLOAT_NAN))
# on non-IEEE platforms, attempting to unpack a bit pattern
# representing an infinity or a NaN should raise an exception.
@@ -515,7 +505,7 @@ class UnknownFormatTestCase(unittest.TestCase):
class IEEEFormatTestCase(unittest.TestCase):
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_double_specials_do_unpack(self):
for fmt, data in [('>d', BE_DOUBLE_INF),
('>d', BE_DOUBLE_NAN),
@@ -523,7 +513,7 @@ class IEEEFormatTestCase(unittest.TestCase):
('<d', LE_DOUBLE_NAN)]:
struct.unpack(fmt, data)
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_float_specials_do_unpack(self):
for fmt, data in [('>f', BE_FLOAT_INF),
('>f', BE_FLOAT_NAN),
@@ -531,25 +521,7 @@ class IEEEFormatTestCase(unittest.TestCase):
('<f', LE_FLOAT_NAN)]:
struct.unpack(fmt, data)
- @requires_IEEE_754
- def test_negative_zero(self):
- def pos_pos():
- return 0.0, math.atan2(0.0, -1)
- def pos_neg():
- return 0.0, math.atan2(-0.0, -1)
- def neg_pos():
- return -0.0, math.atan2(0.0, -1)
- def neg_neg():
- return -0.0, math.atan2(-0.0, -1)
- self.assertEqual(pos_pos(), neg_pos())
- self.assertEqual(pos_neg(), neg_neg())
-
- @requires_IEEE_754
- def test_underflow_sign(self):
- # check that -1e-1000 gives -0.0, not 0.0
- self.assertEqual(math.atan2(-1e-1000, -1), math.atan2(-0.0, -1))
- self.assertEqual(math.atan2(float('-1e-1000'), -1),
- math.atan2(-0.0, -1))
+class FormatTestCase(unittest.TestCase):
def test_format(self):
# these should be rewritten to use both format(x, spec) and
@@ -598,18 +570,16 @@ class IEEEFormatTestCase(unittest.TestCase):
self.assertRaises(ValueError, format, 1e-100, format_spec)
self.assertRaises(ValueError, format, -1e-100, format_spec)
- # issue 3382: 'f' and 'F' with inf's and nan's
- self.assertEqual('{0:f}'.format(INF), 'inf')
- self.assertEqual('{0:F}'.format(INF), 'INF')
- self.assertEqual('{0:f}'.format(-INF), '-inf')
- self.assertEqual('{0:F}'.format(-INF), '-INF')
- self.assertEqual('{0:f}'.format(NAN), 'nan')
- self.assertEqual('{0:F}'.format(NAN), 'NAN')
+ # issue 3382
+ self.assertEqual(format(NAN, 'f'), 'nan')
+ self.assertEqual(format(NAN, 'F'), 'NAN')
+ self.assertEqual(format(INF, 'f'), 'inf')
+ self.assertEqual(format(INF, 'F'), 'INF')
- @requires_IEEE_754
+ @support.requires_IEEE_754
def test_format_testfile(self):
with open(format_testfile) as testfile:
- for line in open(format_testfile):
+ for line in testfile:
if line.startswith('--'):
continue
line = line.strip()
@@ -618,10 +588,8 @@ class IEEEFormatTestCase(unittest.TestCase):
lhs, rhs = map(str.strip, line.split('->'))
fmt, arg = lhs.split()
- arg = float(arg)
- self.assertEqual(fmt % arg, rhs)
- if not math.isnan(arg) and copysign(1.0, arg) > 0.0:
- self.assertEqual(fmt % -arg, '-' + rhs)
+ self.assertEqual(fmt % float(arg), rhs)
+ self.assertEqual(fmt % -float(arg), '-' + rhs)
def test_issue5864(self):
self.assertEqual(format(123.456, '.4'), '123.5')
@@ -688,33 +656,17 @@ class ReprTestCase(unittest.TestCase):
negs = '-'+s
self.assertEqual(s, repr(float(s)))
self.assertEqual(negs, repr(float(negs)))
+ # Since Python 3.2, repr and str are identical
+ self.assertEqual(repr(float(s)), str(float(s)))
+ self.assertEqual(repr(float(negs)), str(float(negs)))
-
-@requires_IEEE_754
+@support.requires_IEEE_754
class RoundTestCase(unittest.TestCase):
- def test_second_argument_type(self):
- # any type with an __index__ method should be permitted as
- # a second argument
- self.assertAlmostEqual(round(12.34, True), 12.3)
-
- class MyIndex(object):
- def __index__(self): return 4
- self.assertAlmostEqual(round(-0.123456, MyIndex()), -0.1235)
- # but floats should be illegal
- self.assertRaises(TypeError, round, 3.14159, 2.0)
def test_inf_nan(self):
- # rounding an infinity or nan returns the same number;
- # (in py3k, rounding an infinity or nan raises an error,
- # since the result can't be represented as a long).
- self.assertEqual(round(INF), INF)
- self.assertEqual(round(-INF), -INF)
- self.assertTrue(math.isnan(round(NAN)))
- for n in range(-5, 5):
- self.assertEqual(round(INF, n), INF)
- self.assertEqual(round(-INF, n), -INF)
- self.assertTrue(math.isnan(round(NAN, n)))
-
+ self.assertRaises(OverflowError, round, INF)
+ self.assertRaises(OverflowError, round, -INF)
+ self.assertRaises(ValueError, round, NAN)
self.assertRaises(TypeError, round, INF, 0.0)
self.assertRaises(TypeError, round, -INF, 1.0)
self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer")
@@ -744,103 +696,56 @@ class RoundTestCase(unittest.TestCase):
self.assertRaises(OverflowError, round, -1.7e308, -308)
@unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
- "test applies only when using short float repr style")
+ "applies only when using short float repr style")
def test_previous_round_bugs(self):
# particular cases that have occurred in bug reports
self.assertEqual(round(562949953421312.5, 1),
562949953421312.5)
self.assertEqual(round(56294995342131.5, 3),
56294995342131.5)
-
- @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
- "test applies only when using short float repr style")
- def test_halfway_cases(self):
- # Halfway cases need special attention, since the current
- # implementation has to deal with them specially. Note that
- # 2.x rounds halfway values up (i.e., away from zero) while
- # 3.x does round-half-to-even.
- self.assertAlmostEqual(round(0.125, 2), 0.13)
- self.assertAlmostEqual(round(0.375, 2), 0.38)
- self.assertAlmostEqual(round(0.625, 2), 0.63)
- self.assertAlmostEqual(round(0.875, 2), 0.88)
- self.assertAlmostEqual(round(-0.125, 2), -0.13)
- self.assertAlmostEqual(round(-0.375, 2), -0.38)
- self.assertAlmostEqual(round(-0.625, 2), -0.63)
- self.assertAlmostEqual(round(-0.875, 2), -0.88)
-
- self.assertAlmostEqual(round(0.25, 1), 0.3)
- self.assertAlmostEqual(round(0.75, 1), 0.8)
- self.assertAlmostEqual(round(-0.25, 1), -0.3)
- self.assertAlmostEqual(round(-0.75, 1), -0.8)
-
- self.assertEqual(round(-6.5, 0), -7.0)
- self.assertEqual(round(-5.5, 0), -6.0)
- self.assertEqual(round(-1.5, 0), -2.0)
- self.assertEqual(round(-0.5, 0), -1.0)
- self.assertEqual(round(0.5, 0), 1.0)
- self.assertEqual(round(1.5, 0), 2.0)
- self.assertEqual(round(2.5, 0), 3.0)
- self.assertEqual(round(3.5, 0), 4.0)
- self.assertEqual(round(4.5, 0), 5.0)
- self.assertEqual(round(5.5, 0), 6.0)
- self.assertEqual(round(6.5, 0), 7.0)
-
- # same but without an explicit second argument; in 3.x these
- # will give integers
- self.assertEqual(round(-6.5), -7.0)
- self.assertEqual(round(-5.5), -6.0)
- self.assertEqual(round(-1.5), -2.0)
- self.assertEqual(round(-0.5), -1.0)
- self.assertEqual(round(0.5), 1.0)
- self.assertEqual(round(1.5), 2.0)
- self.assertEqual(round(2.5), 3.0)
- self.assertEqual(round(3.5), 4.0)
- self.assertEqual(round(4.5), 5.0)
- self.assertEqual(round(5.5), 6.0)
- self.assertEqual(round(6.5), 7.0)
-
- self.assertEqual(round(-25.0, -1), -30.0)
- self.assertEqual(round(-15.0, -1), -20.0)
- self.assertEqual(round(-5.0, -1), -10.0)
- self.assertEqual(round(5.0, -1), 10.0)
- self.assertEqual(round(15.0, -1), 20.0)
- self.assertEqual(round(25.0, -1), 30.0)
+ # round-half-even
+ self.assertEqual(round(25.0, -1), 20.0)
self.assertEqual(round(35.0, -1), 40.0)
- self.assertEqual(round(45.0, -1), 50.0)
+ self.assertEqual(round(45.0, -1), 40.0)
self.assertEqual(round(55.0, -1), 60.0)
- self.assertEqual(round(65.0, -1), 70.0)
+ self.assertEqual(round(65.0, -1), 60.0)
self.assertEqual(round(75.0, -1), 80.0)
- self.assertEqual(round(85.0, -1), 90.0)
+ self.assertEqual(round(85.0, -1), 80.0)
self.assertEqual(round(95.0, -1), 100.0)
- self.assertEqual(round(12325.0, -1), 12330.0)
-
- self.assertEqual(round(350.0, -2), 400.0)
- self.assertEqual(round(450.0, -2), 500.0)
-
- self.assertAlmostEqual(round(0.5e21, -21), 1e21)
- self.assertAlmostEqual(round(1.5e21, -21), 2e21)
- self.assertAlmostEqual(round(2.5e21, -21), 3e21)
- self.assertAlmostEqual(round(5.5e21, -21), 6e21)
- self.assertAlmostEqual(round(8.5e21, -21), 9e21)
-
- self.assertAlmostEqual(round(-1.5e22, -22), -2e22)
- self.assertAlmostEqual(round(-0.5e22, -22), -1e22)
- self.assertAlmostEqual(round(0.5e22, -22), 1e22)
- self.assertAlmostEqual(round(1.5e22, -22), 2e22)
+ @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short',
+ "applies only when using short float repr style")
+ def test_matches_float_format(self):
+ # round should give the same results as float formatting
+ for i in range(500):
+ x = i/1000.
+ self.assertEqual(float(format(x, '.0f')), round(x, 0))
+ self.assertEqual(float(format(x, '.1f')), round(x, 1))
+ self.assertEqual(float(format(x, '.2f')), round(x, 2))
+ self.assertEqual(float(format(x, '.3f')), round(x, 3))
+
+ for i in range(5, 5000, 10):
+ x = i/1000.
+ self.assertEqual(float(format(x, '.0f')), round(x, 0))
+ self.assertEqual(float(format(x, '.1f')), round(x, 1))
+ self.assertEqual(float(format(x, '.2f')), round(x, 2))
+ self.assertEqual(float(format(x, '.3f')), round(x, 3))
+
+ for i in range(500):
+ x = random.random()
+ self.assertEqual(float(format(x, '.0f')), round(x, 0))
+ self.assertEqual(float(format(x, '.1f')), round(x, 1))
+ self.assertEqual(float(format(x, '.2f')), round(x, 2))
+ self.assertEqual(float(format(x, '.3f')), round(x, 3))
- @requires_IEEE_754
def test_format_specials(self):
# Test formatting of nans and infs.
def test(fmt, value, expected):
# Test with both % and format().
self.assertEqual(fmt % value, expected, fmt)
- if not '#' in fmt:
- # Until issue 7094 is implemented, format() for floats doesn't
- # support '#' formatting
- fmt = fmt[1:] # strip off the %
- self.assertEqual(format(value, fmt), expected, fmt)
+ fmt = fmt[1:] # strip off the %
+ self.assertEqual(format(value, fmt), expected, fmt)
for fmt in ['%e', '%f', '%g', '%.0e', '%.6f', '%.20g',
'%#e', '%#f', '%#g', '%#.20e', '%#.15f', '%#.3g']:
@@ -907,6 +812,11 @@ class InfNanTest(unittest.TestCase):
self.assertRaises(ValueError, float, "-INFI")
self.assertRaises(ValueError, float, "infinitys")
+ self.assertRaises(ValueError, float, "++Inf")
+ self.assertRaises(ValueError, float, "-+inf")
+ self.assertRaises(ValueError, float, "+-infinity")
+ self.assertRaises(ValueError, float, "--Infinity")
+
def test_inf_as_str(self):
self.assertEqual(repr(1e300 * 1e300), "inf")
self.assertEqual(repr(-1e300 * 1e300), "-inf")
@@ -938,6 +848,11 @@ class InfNanTest(unittest.TestCase):
self.assertRaises(ValueError, float, "+na")
self.assertRaises(ValueError, float, "-na")
+ self.assertRaises(ValueError, float, "++nan")
+ self.assertRaises(ValueError, float, "-+NAN")
+ self.assertRaises(ValueError, float, "+-NaN")
+ self.assertRaises(ValueError, float, "--nAn")
+
def test_nan_as_str(self):
self.assertEqual(repr(1e300 * 1e300 * 0), "nan")
self.assertEqual(repr(-1e300 * 1e300 * 0), "nan")
@@ -955,15 +870,6 @@ class InfNanTest(unittest.TestCase):
self.assertFalse(NAN.is_inf())
self.assertFalse((0.).is_inf())
- def test_hash_inf(self):
- # the actual values here should be regarded as an
- # implementation detail, but they need to be
- # identical to those used in the Decimal module.
- self.assertEqual(hash(float('inf')), 314159)
- self.assertEqual(hash(float('-inf')), -271828)
- self.assertEqual(hash(float('nan')), 0)
-
-
fromHex = float.fromhex
toHex = float.hex
class HexFloatTestCase(unittest.TestCase):
@@ -1035,10 +941,10 @@ class HexFloatTestCase(unittest.TestCase):
'0x.p0', # no hex digits before or after point
'0x1,p0', # wrong decimal point character
'0x1pa',
- u'0x1p\uff10', # fullwidth Unicode digits
- u'\uff10x1p0',
- u'0x\uff11p0',
- u'0x1.\uff10p0',
+ '0x1p\uff10', # fullwidth Unicode digits
+ '\uff10x1p0',
+ '0x\uff11p0',
+ '0x1.\uff10p0',
'0x1p0 \n 0x2p0',
'0x1p0\0 0x1p0', # embedded null byte is not end of string
]
@@ -1126,7 +1032,6 @@ class HexFloatTestCase(unittest.TestCase):
self.identical(fromHex('+0x1p0'), 1.0)
self.identical(fromHex('0x01p0'), 1.0)
self.identical(fromHex('0x1p00'), 1.0)
- self.identical(fromHex(u'0x1p0'), 1.0)
self.identical(fromHex(' 0x1p0 '), 1.0)
self.identical(fromHex('\n 0x1p0'), 1.0)
self.identical(fromHex('0x1p0 \t'), 1.0)
@@ -1374,7 +1279,7 @@ class HexFloatTestCase(unittest.TestCase):
# fromHex(toHex(x)) should exactly recover x, for any non-NaN float x.
import random
- for i in xrange(10000):
+ for i in range(10000):
e = random.randrange(-1200, 1200)
m = random.random()
s = random.choice([1.0, -1.0])
@@ -1387,11 +1292,12 @@ class HexFloatTestCase(unittest.TestCase):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
GeneralFloatCases,
FormatFunctionsTestCase,
UnknownFormatTestCase,
IEEEFormatTestCase,
+ FormatTestCase,
ReprTestCase,
RoundTestCase,
InfNanTest,
diff --git a/Lib/test/test_flufl.py b/Lib/test/test_flufl.py
new file mode 100644
index 00000000000..5a709bc5f5d
--- /dev/null
+++ b/Lib/test/test_flufl.py
@@ -0,0 +1,27 @@
+import __future__
+import unittest
+
+class FLUFLTests(unittest.TestCase):
+
+ def test_barry_as_bdfl(self):
+ code = "from __future__ import barry_as_FLUFL; 2 {0} 3"
+ compile(code.format('<>'), '<BDFL test>', 'exec',
+ __future__.CO_FUTURE_BARRY_AS_BDFL)
+ self.assertRaises(SyntaxError, compile, code.format('!='),
+ '<FLUFL test>', 'exec',
+ __future__.CO_FUTURE_BARRY_AS_BDFL)
+
+ def test_guido_as_bdfl(self):
+ code = '2 {0} 3'
+ compile(code.format('!='), '<BDFL test>', 'exec')
+ self.assertRaises(SyntaxError, compile, code.format('<>'),
+ '<FLUFL test>', 'exec')
+
+
+def test_main():
+ from test.support import run_unittest
+ run_unittest(FLUFLTests)
+
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_fnmatch.py b/Lib/test/test_fnmatch.py
index 37ec50d71a5..482835d42ef 100644
--- a/Lib/test/test_fnmatch.py
+++ b/Lib/test/test_fnmatch.py
@@ -1,17 +1,12 @@
"""Test cases for the fnmatch module."""
-from test import test_support
+from test import support
import unittest
-from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache
-from fnmatch import fnmatch, fnmatchcase, _MAXCACHE, _cache, _purge
-
+from fnmatch import fnmatch, fnmatchcase, translate, filter
class FnmatchTestCase(unittest.TestCase):
- def tearDown(self):
- _purge()
-
def check_match(self, filename, pattern, should_match=1, fn=fnmatch):
if should_match:
self.assertTrue(fn(filename, pattern),
@@ -49,23 +44,45 @@ class FnmatchTestCase(unittest.TestCase):
check('\nfoo', 'foo*', False)
check('\n', '*')
+ def test_mix_bytes_str(self):
+ self.assertRaises(TypeError, fnmatch, 'test', b'*')
+ self.assertRaises(TypeError, fnmatch, b'test', '*')
+ self.assertRaises(TypeError, fnmatchcase, 'test', b'*')
+ self.assertRaises(TypeError, fnmatchcase, b'test', '*')
+
def test_fnmatchcase(self):
check = self.check_match
check('AbC', 'abc', 0, fnmatchcase)
check('abc', 'AbC', 0, fnmatchcase)
- def test_cache_clearing(self):
- # check that caches do not grow too large
- # http://bugs.python.org/issue7846
+ def test_bytes(self):
+ self.check_match(b'test', b'te*')
+ self.check_match(b'test\xff', b'te*\xff')
+ self.check_match(b'foo\nbar', b'foo*')
+
+class TranslateTestCase(unittest.TestCase):
+
+ def test_translate(self):
+ self.assertEqual(translate('*'), '.*\Z(?ms)')
+ self.assertEqual(translate('?'), '.\Z(?ms)')
+ self.assertEqual(translate('a?b*'), 'a.b.*\Z(?ms)')
+ self.assertEqual(translate('[abc]'), '[abc]\Z(?ms)')
+ self.assertEqual(translate('[]]'), '[]]\Z(?ms)')
+ self.assertEqual(translate('[!x]'), '[^x]\Z(?ms)')
+ self.assertEqual(translate('[^x]'), '[\\^x]\Z(?ms)')
+ self.assertEqual(translate('[x'), '\\[x\Z(?ms)')
+
+
+class FilterTestCase(unittest.TestCase):
- # string pattern cache
- for i in range(_MAXCACHE + 1):
- fnmatch('foo', '?' * i)
+ def test_filter(self):
+ self.assertEqual(filter(['a', 'b'], 'a'), ['a'])
- self.assertLessEqual(len(_cache), _MAXCACHE)
def test_main():
- test_support.run_unittest(FnmatchTestCase)
+ support.run_unittest(FnmatchTestCase,
+ TranslateTestCase,
+ FilterTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_fork1.py b/Lib/test/test_fork1.py
index 3930667d5c1..8192c38a449 100644
--- a/Lib/test/test_fork1.py
+++ b/Lib/test/test_fork1.py
@@ -8,13 +8,14 @@ import sys
import time
from test.fork_wait import ForkWait
-from test.test_support import run_unittest, reap_children, get_attribute, import_module
+from test.support import (run_unittest, reap_children, get_attribute,
+ import_module, verbose)
+
threading = import_module('threading')
-#Skip test if fork does not exist.
+# Skip test if fork does not exist.
get_attribute(os, 'fork')
-
class ForkTest(ForkWait):
def wait_impl(self, cpid):
for i in range(10):
@@ -28,7 +29,8 @@ class ForkTest(ForkWait):
self.assertEqual(spid, cpid)
self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
- def test_import_lock_fork(self):
+ def test_threaded_import_lock_fork(self):
+ """Check fork() in main thread works while a subthread is doing an import"""
import_started = threading.Event()
fake_module_name = "fake test module"
partial_module = "partial"
@@ -45,11 +47,16 @@ class ForkTest(ForkWait):
import_started.wait()
pid = os.fork()
try:
+ # PyOS_BeforeFork should have waited for the import to complete
+ # before forking, so the child can recreate the import lock
+ # correctly, but also won't see a partially initialised module
if not pid:
m = __import__(fake_module_name)
if m == complete_module:
os._exit(0)
else:
+ if verbose > 1:
+ print("Child encountered partial module")
os._exit(1)
else:
t.join()
@@ -63,6 +70,39 @@ class ForkTest(ForkWait):
except OSError:
pass
+
+ def test_nested_import_lock_fork(self):
+ """Check fork() in main thread works while the main thread is doing an import"""
+ # Issue 9573: this used to trigger RuntimeError in the child process
+ def fork_with_import_lock(level):
+ release = 0
+ in_child = False
+ try:
+ try:
+ for i in range(level):
+ imp.acquire_lock()
+ release += 1
+ pid = os.fork()
+ in_child = not pid
+ finally:
+ for i in range(release):
+ imp.release_lock()
+ except RuntimeError:
+ if in_child:
+ if verbose > 1:
+ print("RuntimeError in child")
+ os._exit(1)
+ raise
+ if in_child:
+ os._exit(0)
+ self.wait_impl(pid)
+
+ # Check this works with various levels of nested
+ # import in the main thread
+ for level in range(5):
+ fork_with_import_lock(level)
+
+
def test_main():
run_unittest(ForkTest)
reap_children()
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index f39426b82bb..7fa950d9ef5 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -1,9 +1,9 @@
+from test.support import verbose, TestFailed
import sys
-from test.test_support import verbose, have_unicode, TestFailed
-import test.test_support as test_support
+import test.support as support
import unittest
-maxsize = test_support.MAX_Py_ssize_t
+maxsize = support.MAX_Py_ssize_t
# test string formatting operator (I am not sure if this is being tested
# elsewhere but, surely, some of the given cases are *not* tested because
@@ -13,21 +13,21 @@ maxsize = test_support.MAX_Py_ssize_t
def testformat(formatstr, args, output=None, limit=None, overflowok=False):
if verbose:
if output:
- print "%s %% %s =? %s ..." %\
- (repr(formatstr), repr(args), repr(output)),
+ print("%r %% %r =? %r ..." %\
+ (formatstr, args, output), end=' ')
else:
- print "%s %% %s works? ..." % (repr(formatstr), repr(args)),
+ print("%r %% %r works? ..." % (formatstr, args), end=' ')
try:
result = formatstr % args
except OverflowError:
if not overflowok:
raise
if verbose:
- print 'overflow (this is fine)'
+ print('overflow (this is fine)')
else:
if output and limit is None and result != output:
if verbose:
- print 'no'
+ print('no')
raise AssertionError("%r %% %r == %r != %r" %
(formatstr, args, result, output))
# when 'limit' is specified, it determines how many characters
@@ -38,197 +38,187 @@ def testformat(formatstr, args, output=None, limit=None, overflowok=False):
elif output and limit is not None and (
len(result)!=len(output) or result[:limit]!=output[:limit]):
if verbose:
- print 'no'
- print "%s %% %s == %s != %s" % \
- (repr(formatstr), repr(args), repr(result), repr(output))
+ print('no')
+ print("%s %% %s == %s != %s" % \
+ (repr(formatstr), repr(args), repr(result), repr(output)))
else:
if verbose:
- print 'yes'
-
-
-def testboth(formatstr, *args, **kwargs):
- testformat(formatstr, *args, **kwargs)
- if have_unicode:
- testformat(unicode(formatstr), *args, **kwargs)
+ print('yes')
class FormatTest(unittest.TestCase):
def test_format(self):
- testboth("%.1d", (1,), "1")
- testboth("%.*d", (sys.maxint,1), overflowok=True) # expect overflow
- testboth("%.100d", (1,), '00000000000000000000000000000000000000'
+ testformat("%.1d", (1,), "1")
+ testformat("%.*d", (sys.maxsize,1), overflowok=True) # expect overflow
+ testformat("%.100d", (1,), '00000000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000'
'00000001', overflowok=True)
- testboth("%#.117x", (1,), '0x00000000000000000000000000000000000'
+ testformat("%#.117x", (1,), '0x00000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000'
'0000000000000000000000000001',
overflowok=True)
- testboth("%#.118x", (1,), '0x00000000000000000000000000000000000'
+ testformat("%#.118x", (1,), '0x00000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000'
'00000000000000000000000000001',
overflowok=True)
- testboth("%f", (1.0,), "1.000000")
+ testformat("%f", (1.0,), "1.000000")
# these are trying to test the limits of the internal magic-number-length
# formatting buffer, if that number changes then these tests are less
# effective
- testboth("%#.*g", (109, -1.e+49/3.))
- testboth("%#.*g", (110, -1.e+49/3.))
- testboth("%#.*g", (110, -1.e+100/3.))
-
+ testformat("%#.*g", (109, -1.e+49/3.))
+ testformat("%#.*g", (110, -1.e+49/3.))
+ testformat("%#.*g", (110, -1.e+100/3.))
# test some ridiculously large precision, expect overflow
- testboth('%12.*f', (123456, 1.0))
+ testformat('%12.*f', (123456, 1.0))
# check for internal overflow validation on length of precision
# these tests should no longer cause overflow in Python
# 2.7/3.1 and later.
- testboth("%#.*g", (110, -1.e+100/3.))
- testboth("%#.*G", (110, -1.e+100/3.))
- testboth("%#.*f", (110, -1.e+100/3.))
- testboth("%#.*F", (110, -1.e+100/3.))
-
- # Formatting of long integers. Overflow is not ok
- testboth("%x", 10L, "a")
- testboth("%x", 100000000000L, "174876e800")
- testboth("%o", 10L, "12")
- testboth("%o", 100000000000L, "1351035564000")
- testboth("%d", 10L, "10")
- testboth("%d", 100000000000L, "100000000000")
-
- big = 123456789012345678901234567890L
- testboth("%d", big, "123456789012345678901234567890")
- testboth("%d", -big, "-123456789012345678901234567890")
- testboth("%5d", -big, "-123456789012345678901234567890")
- testboth("%31d", -big, "-123456789012345678901234567890")
- testboth("%32d", -big, " -123456789012345678901234567890")
- testboth("%-32d", -big, "-123456789012345678901234567890 ")
- testboth("%032d", -big, "-0123456789012345678901234567890")
- testboth("%-032d", -big, "-123456789012345678901234567890 ")
- testboth("%034d", -big, "-000123456789012345678901234567890")
- testboth("%034d", big, "0000123456789012345678901234567890")
- testboth("%0+34d", big, "+000123456789012345678901234567890")
- testboth("%+34d", big, " +123456789012345678901234567890")
- testboth("%34d", big, " 123456789012345678901234567890")
- testboth("%.2d", big, "123456789012345678901234567890")
- testboth("%.30d", big, "123456789012345678901234567890")
- testboth("%.31d", big, "0123456789012345678901234567890")
- testboth("%32.31d", big, " 0123456789012345678901234567890")
- testboth("%d", float(big), "123456________________________", 6)
-
- big = 0x1234567890abcdef12345L # 21 hex digits
- testboth("%x", big, "1234567890abcdef12345")
- testboth("%x", -big, "-1234567890abcdef12345")
- testboth("%5x", -big, "-1234567890abcdef12345")
- testboth("%22x", -big, "-1234567890abcdef12345")
- testboth("%23x", -big, " -1234567890abcdef12345")
- testboth("%-23x", -big, "-1234567890abcdef12345 ")
- testboth("%023x", -big, "-01234567890abcdef12345")
- testboth("%-023x", -big, "-1234567890abcdef12345 ")
- testboth("%025x", -big, "-0001234567890abcdef12345")
- testboth("%025x", big, "00001234567890abcdef12345")
- testboth("%0+25x", big, "+0001234567890abcdef12345")
- testboth("%+25x", big, " +1234567890abcdef12345")
- testboth("%25x", big, " 1234567890abcdef12345")
- testboth("%.2x", big, "1234567890abcdef12345")
- testboth("%.21x", big, "1234567890abcdef12345")
- testboth("%.22x", big, "01234567890abcdef12345")
- testboth("%23.22x", big, " 01234567890abcdef12345")
- testboth("%-23.22x", big, "01234567890abcdef12345 ")
- testboth("%X", big, "1234567890ABCDEF12345")
- testboth("%#X", big, "0X1234567890ABCDEF12345")
- testboth("%#x", big, "0x1234567890abcdef12345")
- testboth("%#x", -big, "-0x1234567890abcdef12345")
- testboth("%#.23x", -big, "-0x001234567890abcdef12345")
- testboth("%#+.23x", big, "+0x001234567890abcdef12345")
- testboth("%# .23x", big, " 0x001234567890abcdef12345")
- testboth("%#+.23X", big, "+0X001234567890ABCDEF12345")
- testboth("%#-+.23X", big, "+0X001234567890ABCDEF12345")
- testboth("%#-+26.23X", big, "+0X001234567890ABCDEF12345")
- testboth("%#-+27.23X", big, "+0X001234567890ABCDEF12345 ")
- testboth("%#+27.23X", big, " +0X001234567890ABCDEF12345")
+ testformat("%#.*g", (110, -1.e+100/3.))
+ testformat("%#.*G", (110, -1.e+100/3.))
+ testformat("%#.*f", (110, -1.e+100/3.))
+ testformat("%#.*F", (110, -1.e+100/3.))
+ # Formatting of integers. Overflow is not ok
+ testformat("%x", 10, "a")
+ testformat("%x", 100000000000, "174876e800")
+ testformat("%o", 10, "12")
+ testformat("%o", 100000000000, "1351035564000")
+ testformat("%d", 10, "10")
+ testformat("%d", 100000000000, "100000000000")
+ big = 123456789012345678901234567890
+ testformat("%d", big, "123456789012345678901234567890")
+ testformat("%d", -big, "-123456789012345678901234567890")
+ testformat("%5d", -big, "-123456789012345678901234567890")
+ testformat("%31d", -big, "-123456789012345678901234567890")
+ testformat("%32d", -big, " -123456789012345678901234567890")
+ testformat("%-32d", -big, "-123456789012345678901234567890 ")
+ testformat("%032d", -big, "-0123456789012345678901234567890")
+ testformat("%-032d", -big, "-123456789012345678901234567890 ")
+ testformat("%034d", -big, "-000123456789012345678901234567890")
+ testformat("%034d", big, "0000123456789012345678901234567890")
+ testformat("%0+34d", big, "+000123456789012345678901234567890")
+ testformat("%+34d", big, " +123456789012345678901234567890")
+ testformat("%34d", big, " 123456789012345678901234567890")
+ testformat("%.2d", big, "123456789012345678901234567890")
+ testformat("%.30d", big, "123456789012345678901234567890")
+ testformat("%.31d", big, "0123456789012345678901234567890")
+ testformat("%32.31d", big, " 0123456789012345678901234567890")
+ testformat("%d", float(big), "123456________________________", 6)
+ big = 0x1234567890abcdef12345 # 21 hex digits
+ testformat("%x", big, "1234567890abcdef12345")
+ testformat("%x", -big, "-1234567890abcdef12345")
+ testformat("%5x", -big, "-1234567890abcdef12345")
+ testformat("%22x", -big, "-1234567890abcdef12345")
+ testformat("%23x", -big, " -1234567890abcdef12345")
+ testformat("%-23x", -big, "-1234567890abcdef12345 ")
+ testformat("%023x", -big, "-01234567890abcdef12345")
+ testformat("%-023x", -big, "-1234567890abcdef12345 ")
+ testformat("%025x", -big, "-0001234567890abcdef12345")
+ testformat("%025x", big, "00001234567890abcdef12345")
+ testformat("%0+25x", big, "+0001234567890abcdef12345")
+ testformat("%+25x", big, " +1234567890abcdef12345")
+ testformat("%25x", big, " 1234567890abcdef12345")
+ testformat("%.2x", big, "1234567890abcdef12345")
+ testformat("%.21x", big, "1234567890abcdef12345")
+ testformat("%.22x", big, "01234567890abcdef12345")
+ testformat("%23.22x", big, " 01234567890abcdef12345")
+ testformat("%-23.22x", big, "01234567890abcdef12345 ")
+ testformat("%X", big, "1234567890ABCDEF12345")
+ testformat("%#X", big, "0X1234567890ABCDEF12345")
+ testformat("%#x", big, "0x1234567890abcdef12345")
+ testformat("%#x", -big, "-0x1234567890abcdef12345")
+ testformat("%#.23x", -big, "-0x001234567890abcdef12345")
+ testformat("%#+.23x", big, "+0x001234567890abcdef12345")
+ testformat("%# .23x", big, " 0x001234567890abcdef12345")
+ testformat("%#+.23X", big, "+0X001234567890ABCDEF12345")
+ testformat("%#-+.23X", big, "+0X001234567890ABCDEF12345")
+ testformat("%#-+26.23X", big, "+0X001234567890ABCDEF12345")
+ testformat("%#-+27.23X", big, "+0X001234567890ABCDEF12345 ")
+ testformat("%#+27.23X", big, " +0X001234567890ABCDEF12345")
# next one gets two leading zeroes from precision, and another from the
# 0 flag and the width
- testboth("%#+027.23X", big, "+0X0001234567890ABCDEF12345")
+ testformat("%#+027.23X", big, "+0X0001234567890ABCDEF12345")
# same, except no 0 flag
- testboth("%#+27.23X", big, " +0X001234567890ABCDEF12345")
- testboth("%x", float(big), "123456_______________", 6)
-
- big = 012345670123456701234567012345670L # 32 octal digits
- testboth("%o", big, "12345670123456701234567012345670")
- testboth("%o", -big, "-12345670123456701234567012345670")
- testboth("%5o", -big, "-12345670123456701234567012345670")
- testboth("%33o", -big, "-12345670123456701234567012345670")
- testboth("%34o", -big, " -12345670123456701234567012345670")
- testboth("%-34o", -big, "-12345670123456701234567012345670 ")
- testboth("%034o", -big, "-012345670123456701234567012345670")
- testboth("%-034o", -big, "-12345670123456701234567012345670 ")
- testboth("%036o", -big, "-00012345670123456701234567012345670")
- testboth("%036o", big, "000012345670123456701234567012345670")
- testboth("%0+36o", big, "+00012345670123456701234567012345670")
- testboth("%+36o", big, " +12345670123456701234567012345670")
- testboth("%36o", big, " 12345670123456701234567012345670")
- testboth("%.2o", big, "12345670123456701234567012345670")
- testboth("%.32o", big, "12345670123456701234567012345670")
- testboth("%.33o", big, "012345670123456701234567012345670")
- testboth("%34.33o", big, " 012345670123456701234567012345670")
- testboth("%-34.33o", big, "012345670123456701234567012345670 ")
- testboth("%o", big, "12345670123456701234567012345670")
- testboth("%#o", big, "012345670123456701234567012345670")
- testboth("%#o", -big, "-012345670123456701234567012345670")
- testboth("%#.34o", -big, "-0012345670123456701234567012345670")
- testboth("%#+.34o", big, "+0012345670123456701234567012345670")
- testboth("%# .34o", big, " 0012345670123456701234567012345670")
- testboth("%#+.34o", big, "+0012345670123456701234567012345670")
- testboth("%#-+.34o", big, "+0012345670123456701234567012345670")
- testboth("%#-+37.34o", big, "+0012345670123456701234567012345670 ")
- testboth("%#+37.34o", big, " +0012345670123456701234567012345670")
+ testformat("%#+27.23X", big, " +0X001234567890ABCDEF12345")
+ testformat("%x", float(big), "123456_______________", 6)
+ big = 0o12345670123456701234567012345670 # 32 octal digits
+ testformat("%o", big, "12345670123456701234567012345670")
+ testformat("%o", -big, "-12345670123456701234567012345670")
+ testformat("%5o", -big, "-12345670123456701234567012345670")
+ testformat("%33o", -big, "-12345670123456701234567012345670")
+ testformat("%34o", -big, " -12345670123456701234567012345670")
+ testformat("%-34o", -big, "-12345670123456701234567012345670 ")
+ testformat("%034o", -big, "-012345670123456701234567012345670")
+ testformat("%-034o", -big, "-12345670123456701234567012345670 ")
+ testformat("%036o", -big, "-00012345670123456701234567012345670")
+ testformat("%036o", big, "000012345670123456701234567012345670")
+ testformat("%0+36o", big, "+00012345670123456701234567012345670")
+ testformat("%+36o", big, " +12345670123456701234567012345670")
+ testformat("%36o", big, " 12345670123456701234567012345670")
+ testformat("%.2o", big, "12345670123456701234567012345670")
+ testformat("%.32o", big, "12345670123456701234567012345670")
+ testformat("%.33o", big, "012345670123456701234567012345670")
+ testformat("%34.33o", big, " 012345670123456701234567012345670")
+ testformat("%-34.33o", big, "012345670123456701234567012345670 ")
+ testformat("%o", big, "12345670123456701234567012345670")
+ testformat("%#o", big, "0o12345670123456701234567012345670")
+ testformat("%#o", -big, "-0o12345670123456701234567012345670")
+ testformat("%#.34o", -big, "-0o0012345670123456701234567012345670")
+ testformat("%#+.34o", big, "+0o0012345670123456701234567012345670")
+ testformat("%# .34o", big, " 0o0012345670123456701234567012345670")
+ testformat("%#+.34o", big, "+0o0012345670123456701234567012345670")
+ testformat("%#-+.34o", big, "+0o0012345670123456701234567012345670")
+ testformat("%#-+37.34o", big, "+0o0012345670123456701234567012345670")
+ testformat("%#+37.34o", big, "+0o0012345670123456701234567012345670")
# next one gets one leading zero from precision
- testboth("%.33o", big, "012345670123456701234567012345670")
+ testformat("%.33o", big, "012345670123456701234567012345670")
# base marker shouldn't change that, since "0" is redundant
- testboth("%#.33o", big, "012345670123456701234567012345670")
+ testformat("%#.33o", big, "0o012345670123456701234567012345670")
# but reduce precision, and base marker should add a zero
- testboth("%#.32o", big, "012345670123456701234567012345670")
+ testformat("%#.32o", big, "0o12345670123456701234567012345670")
# one leading zero from precision, and another from "0" flag & width
- testboth("%034.33o", big, "0012345670123456701234567012345670")
+ testformat("%034.33o", big, "0012345670123456701234567012345670")
# base marker shouldn't change that
- testboth("%0#34.33o", big, "0012345670123456701234567012345670")
- testboth("%o", float(big), "123456__________________________", 6)
-
- # Some small ints, in both Python int and long flavors).
- testboth("%d", 42, "42")
- testboth("%d", -42, "-42")
- testboth("%d", 42L, "42")
- testboth("%d", -42L, "-42")
- testboth("%d", 42.0, "42")
- testboth("%#x", 1, "0x1")
- testboth("%#x", 1L, "0x1")
- testboth("%#X", 1, "0X1")
- testboth("%#X", 1L, "0X1")
- testboth("%#x", 1.0, "0x1")
- testboth("%#o", 1, "01")
- testboth("%#o", 1L, "01")
- testboth("%#o", 0, "0")
- testboth("%#o", 0L, "0")
- testboth("%o", 0, "0")
- testboth("%o", 0L, "0")
- testboth("%d", 0, "0")
- testboth("%d", 0L, "0")
- testboth("%#x", 0, "0x0")
- testboth("%#x", 0L, "0x0")
- testboth("%#X", 0, "0X0")
- testboth("%#X", 0L, "0X0")
-
- testboth("%x", 0x42, "42")
- testboth("%x", -0x42, "-42")
- testboth("%x", 0x42L, "42")
- testboth("%x", -0x42L, "-42")
- testboth("%x", float(0x42), "42")
-
- testboth("%o", 042, "42")
- testboth("%o", -042, "-42")
- testboth("%o", 042L, "42")
- testboth("%o", -042L, "-42")
- testboth("%o", float(042), "42")
+ testformat("%0#34.33o", big, "0o012345670123456701234567012345670")
+ testformat("%o", float(big), "123456__________________________", 6)
+ # Some small ints, in both Python int and flavors).
+ testformat("%d", 42, "42")
+ testformat("%d", -42, "-42")
+ testformat("%d", 42, "42")
+ testformat("%d", -42, "-42")
+ testformat("%d", 42.0, "42")
+ testformat("%#x", 1, "0x1")
+ testformat("%#x", 1, "0x1")
+ testformat("%#X", 1, "0X1")
+ testformat("%#X", 1, "0X1")
+ testformat("%#x", 1.0, "0x1")
+ testformat("%#o", 1, "0o1")
+ testformat("%#o", 1, "0o1")
+ testformat("%#o", 0, "0o0")
+ testformat("%#o", 0, "0o0")
+ testformat("%o", 0, "0")
+ testformat("%o", 0, "0")
+ testformat("%d", 0, "0")
+ testformat("%d", 0, "0")
+ testformat("%#x", 0, "0x0")
+ testformat("%#x", 0, "0x0")
+ testformat("%#X", 0, "0X0")
+ testformat("%#X", 0, "0X0")
+ testformat("%x", 0x42, "42")
+ testformat("%x", -0x42, "-42")
+ testformat("%x", 0x42, "42")
+ testformat("%x", -0x42, "-42")
+ testformat("%x", float(0x42), "42")
+ testformat("%o", 0o42, "42")
+ testformat("%o", -0o42, "-42")
+ testformat("%o", 0o42, "42")
+ testformat("%o", -0o42, "-42")
+ testformat("%o", float(0o42), "42")
+ testformat("%r", "\u0378", "'\\u0378'") # non printable
+ testformat("%a", "\u0378", "'\\u0378'") # non printable
+ testformat("%r", "\u0374", "'\u0374'") # printable
+ testformat("%a", "\u0374", "'\\u0374'") # printable
# alternate float formatting
testformat('%g', 1.1, '1.1')
@@ -236,50 +226,34 @@ class FormatTest(unittest.TestCase):
# Test exception for unknown format characters
if verbose:
- print 'Testing exceptions'
-
+ print('Testing exceptions')
def test_exc(formatstr, args, exception, excmsg):
try:
testformat(formatstr, args)
- except exception, exc:
+ except exception as exc:
if str(exc) == excmsg:
if verbose:
- print "yes"
+ print("yes")
else:
- if verbose: print 'no'
- print 'Unexpected ', exception, ':', repr(str(exc))
+ if verbose: print('no')
+ print('Unexpected ', exception, ':', repr(str(exc)))
except:
- if verbose: print 'no'
- print 'Unexpected exception'
+ if verbose: print('no')
+ print('Unexpected exception')
raise
else:
- raise TestFailed, 'did not get expected exception: %s' % excmsg
-
- test_exc('abc %a', 1, ValueError,
- "unsupported format character 'a' (0x61) at index 5")
- if have_unicode:
- test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
- "unsupported format character '?' (0x3000) at index 5")
-
+ raise TestFailed('did not get expected exception: %s' % excmsg)
+ test_exc('abc %b', 1, ValueError,
+ "unsupported format character 'b' (0x62) at index 5")
+ #test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
+ # "unsupported format character '?' (0x3000) at index 5")
test_exc('%d', '1', TypeError, "%d format: a number is required, not str")
- test_exc('%g', '1', TypeError, "float argument required, not str")
+ test_exc('%g', '1', TypeError, "a float is required")
test_exc('no format', '1', TypeError,
"not all arguments converted during string formatting")
- test_exc('no format', u'1', TypeError,
- "not all arguments converted during string formatting")
- test_exc(u'no format', '1', TypeError,
- "not all arguments converted during string formatting")
- test_exc(u'no format', u'1', TypeError,
+ test_exc('no format', '1', TypeError,
"not all arguments converted during string formatting")
- class Foobar(long):
- def __oct__(self):
- # Returning a non-string should not blow up.
- return self + 1
-
- test_exc('%o', Foobar(), TypeError,
- "expected string or Unicode object, long found")
-
if maxsize == 2**31-1:
# crashes 2.2.1 and earlier:
try:
@@ -287,10 +261,10 @@ class FormatTest(unittest.TestCase):
except MemoryError:
pass
else:
- raise TestFailed, '"%*d"%(maxsize, -127) should fail'
+ raise TestFailed('"%*d"%(maxsize, -127) should fail')
def test_main():
- test_support.run_unittest(FormatTest)
+ support.run_unittest(FormatTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_fpformat.py b/Lib/test/test_fpformat.py
deleted file mode 100644
index e6de3b0c11b..00000000000
--- a/Lib/test/test_fpformat.py
+++ /dev/null
@@ -1,76 +0,0 @@
-'''
- Tests for fpformat module
- Nick Mathewson
-'''
-from test.test_support import run_unittest, import_module
-import unittest
-fpformat = import_module('fpformat', deprecated=True)
-fix, sci, NotANumber = fpformat.fix, fpformat.sci, fpformat.NotANumber
-
-StringType = type('')
-
-# Test the old and obsolescent fpformat module.
-#
-# (It's obsolescent because fix(n,d) == "%.*f"%(d,n) and
-# sci(n,d) == "%.*e"%(d,n)
-# for all reasonable numeric n and d, except that sci gives 3 exponent
-# digits instead of 2.
-#
-# Differences only occur for unreasonable n and d. <.2 wink>)
-
-class FpformatTest(unittest.TestCase):
-
- def checkFix(self, n, digits):
- result = fix(n, digits)
- if isinstance(n, StringType):
- n = repr(n)
- expected = "%.*f" % (digits, float(n))
-
- self.assertEqual(result, expected)
-
- def checkSci(self, n, digits):
- result = sci(n, digits)
- if isinstance(n, StringType):
- n = repr(n)
- expected = "%.*e" % (digits, float(n))
- # add the extra 0 if needed
- num, exp = expected.split("e")
- if len(exp) < 4:
- exp = exp[0] + "0" + exp[1:]
- expected = "%se%s" % (num, exp)
-
- self.assertEqual(result, expected)
-
- def test_basic_cases(self):
- self.assertEqual(fix(100.0/3, 3), '33.333')
- self.assertEqual(sci(100.0/3, 3), '3.333e+001')
-
- def test_reasonable_values(self):
- for d in range(7):
- for val in (1000.0/3, 1000, 1000.0, .002, 1.0/3, 1e10):
- for realVal in (val, 1.0/val, -val, -1.0/val):
- self.checkFix(realVal, d)
- self.checkSci(realVal, d)
-
- def test_failing_values(self):
- # Now for 'unreasonable n and d'
- self.assertEqual(fix(1.0, 1000), '1.'+('0'*1000))
- self.assertEqual(sci("1"+('0'*1000), 0), '1e+1000')
-
- # This behavior is inconsistent. sci raises an exception; fix doesn't.
- yacht = "Throatwobbler Mangrove"
- self.assertEqual(fix(yacht, 10), yacht)
- try:
- sci(yacht, 10)
- except NotANumber:
- pass
- else:
- self.fail("No exception on non-numeric sci")
-
-
-def test_main():
- run_unittest(FpformatTest)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py
index de09bb0cf26..084ae0cce5d 100644
--- a/Lib/test/test_fractions.py
+++ b/Lib/test/test_fractions.py
@@ -1,7 +1,7 @@
"""Tests for Lib/fractions.py."""
from decimal import Decimal
-from test.test_support import run_unittest
+from test.support import run_unittest, requires_IEEE_754
import math
import numbers
import operator
@@ -9,15 +9,10 @@ import fractions
import sys
import unittest
from copy import copy, deepcopy
-from cPickle import dumps, loads
+from pickle import dumps, loads
F = fractions.Fraction
gcd = fractions.gcd
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
-
class DummyFloat(object):
"""Dummy float class for testing comparisons with Fractions"""
@@ -49,9 +44,6 @@ class DummyFloat(object):
assert False, "__sub__ should not be invoked for comparisons"
__rsub__ = __sub__
- # Silence Py3k warning
- __hash__ = None
-
class DummyRational(object):
"""Test comparison of Fraction with a naive rational implementation."""
@@ -85,10 +77,6 @@ class DummyRational(object):
def __float__(self):
assert False, "__float__ should not be invoked"
- # Silence Py3k warning
- __hash__ = None
-
-
class DummyFraction(fractions.Fraction):
"""Dummy Fraction subclass for copy and deepcopy testing."""
@@ -123,7 +111,7 @@ class FractionTest(unittest.TestCase):
"""Asserts that callable(*args, **kwargs) raises exc_type(message)."""
try:
callable(*args, **kwargs)
- except exc_type, e:
+ except exc_type as e:
self.assertEqual(message, str(e))
else:
self.fail("%s not raised" % exc_type.__name__)
@@ -180,19 +168,16 @@ class FractionTest(unittest.TestCase):
self.assertEqual((3, 2), _components(F(" \n +3/2")))
self.assertEqual((-3, 2), _components(F("-3/2 ")))
self.assertEqual((13, 2), _components(F(" 013/02 \n ")))
- self.assertEqual((13, 2), _components(F(u" 013/02 \n ")))
-
self.assertEqual((16, 5), _components(F(" 3.2 ")))
- self.assertEqual((-16, 5), _components(F(u" -3.2 ")))
- self.assertEqual((-3, 1), _components(F(u" -3. ")))
- self.assertEqual((3, 5), _components(F(u" .6 ")))
+ self.assertEqual((-16, 5), _components(F(" -3.2 ")))
+ self.assertEqual((-3, 1), _components(F(" -3. ")))
+ self.assertEqual((3, 5), _components(F(" .6 ")))
self.assertEqual((1, 3125), _components(F("32.e-5")))
self.assertEqual((1000000, 1), _components(F("1E+06")))
self.assertEqual((-12300, 1), _components(F("-1.23e4")))
self.assertEqual((0, 1), _components(F(" .0e+0\t")))
self.assertEqual((0, 1), _components(F("-0.000e0")))
-
self.assertRaisesMessage(
ZeroDivisionError, "Fraction(3, 0)",
F, "3/0")
@@ -218,11 +203,11 @@ class FractionTest(unittest.TestCase):
ValueError, "Invalid literal for Fraction: '3a2'",
F, "3a2")
self.assertRaisesMessage(
- # Don't accept combinations of decimals and fractions.
+ # Don't accept combinations of decimals and rationals.
ValueError, "Invalid literal for Fraction: '3/7.2'",
F, "3/7.2")
self.assertRaisesMessage(
- # Don't accept combinations of decimals and fractions.
+ # Don't accept combinations of decimals and rationals.
ValueError, "Invalid literal for Fraction: '3.2/7'",
F, "3.2/7")
self.assertRaisesMessage(
@@ -312,20 +297,35 @@ class FractionTest(unittest.TestCase):
def testConversions(self):
self.assertTypedEquals(-1, math.trunc(F(-11, 10)))
- self.assertTypedEquals(-1, int(F(-11, 10)))
self.assertTypedEquals(1, math.trunc(F(11, 10)))
+ self.assertTypedEquals(-2, math.floor(F(-11, 10)))
+ self.assertTypedEquals(-1, math.ceil(F(-11, 10)))
+ self.assertTypedEquals(-1, math.ceil(F(-10, 10)))
+ self.assertTypedEquals(-1, int(F(-11, 10)))
+ self.assertTypedEquals(0, round(F(-1, 10)))
+ self.assertTypedEquals(0, round(F(-5, 10)))
+ self.assertTypedEquals(-2, round(F(-15, 10)))
+ self.assertTypedEquals(-1, round(F(-7, 10)))
+
self.assertEqual(False, bool(F(0, 1)))
self.assertEqual(True, bool(F(3, 2)))
self.assertTypedEquals(0.1, float(F(1, 10)))
# Check that __float__ isn't implemented by converting the
# numerator and denominator to float before dividing.
- self.assertRaises(OverflowError, float, long('2'*400+'7'))
+ self.assertRaises(OverflowError, float, int('2'*400+'7'))
self.assertAlmostEqual(2.0/3,
- float(F(long('2'*400+'7'), long('3'*400+'1'))))
+ float(F(int('2'*400+'7'), int('3'*400+'1'))))
self.assertTypedEquals(0.1+0j, complex(F(1,10)))
+ def testRound(self):
+ self.assertTypedEquals(F(-200), round(F(-150), -2))
+ self.assertTypedEquals(F(-200), round(F(-250), -2))
+ self.assertTypedEquals(F(30), round(F(26), -1))
+ self.assertTypedEquals(F(-2, 10), round(F(-15, 100), 1))
+ self.assertTypedEquals(F(-2, 10), round(F(-25, 100), 1))
+
def testArithmetic(self):
self.assertEqual(F(1, 2), F(1, 10) + F(2, 5))
@@ -339,8 +339,9 @@ class FractionTest(unittest.TestCase):
self.assertEqual(F(27, 8), F(2, 3) ** F(-3))
self.assertTypedEquals(2.0, F(4) ** F(1, 2))
self.assertEqual(F(1, 1), +F(1, 1))
- # Will return 1j in 3.0:
- self.assertRaises(ValueError, pow, F(-1), F(1, 2))
+ z = pow(F(-1), F(1, 2))
+ self.assertAlmostEqual(z.real, 0)
+ self.assertEqual(z.imag, 1)
def testMixedArithmetic(self):
self.assertTypedEquals(F(11, 10), F(1, 10) + 1)
@@ -372,10 +373,10 @@ class FractionTest(unittest.TestCase):
self.assertTypedEquals(10.0 + 0j, (1.0 + 0j) / F(1, 10))
self.assertTypedEquals(0, F(1, 10) // 1)
- self.assertTypedEquals(0.0, F(1, 10) // 1.0)
+ self.assertTypedEquals(0, F(1, 10) // 1.0)
self.assertTypedEquals(10, 1 // F(1, 10))
self.assertTypedEquals(10**23, 10**22 // F(1, 10))
- self.assertTypedEquals(10.0, 1.0 // F(1, 10))
+ self.assertTypedEquals(10, 1.0 // F(1, 10))
self.assertTypedEquals(F(1, 10), F(1, 10) % 1)
self.assertTypedEquals(0.1, F(1, 10) % 1.0)
@@ -390,15 +391,16 @@ class FractionTest(unittest.TestCase):
self.assertTypedEquals(0.1, F(1, 10) ** 1.0)
self.assertTypedEquals(0.1 + 0j, F(1, 10) ** (1.0 + 0j))
self.assertTypedEquals(4 , 2 ** F(2, 1))
- # Will return 1j in 3.0:
- self.assertRaises(ValueError, pow, (-1), F(1, 2))
+ z = pow(-1, F(1, 2))
+ self.assertAlmostEqual(0, z.real)
+ self.assertEqual(1, z.imag)
self.assertTypedEquals(F(1, 4) , 2 ** F(-2, 1))
self.assertTypedEquals(2.0 , 4 ** F(1, 2))
self.assertTypedEquals(0.25, 2.0 ** F(-2, 1))
self.assertTypedEquals(1.0 + 0j, (1.0 + 0j) ** F(1, 10))
def testMixingWithDecimal(self):
- # Decimal refuses mixed comparisons.
+ # Decimal refuses mixed arithmetic (but not mixed comparisons)
self.assertRaisesMessage(
TypeError,
"unsupported operand type(s) for +: 'Fraction' and 'Decimal'",
@@ -407,7 +409,6 @@ class FractionTest(unittest.TestCase):
TypeError,
"unsupported operand type(s) for +: 'Decimal' and 'Fraction'",
operator.add, Decimal('3.1415926'), F(3,11))
- self.assertNotEqual(F(5, 2), Decimal('2.5'))
def testComparisons(self):
self.assertTrue(F(1, 2) < F(2, 3))
@@ -551,9 +552,15 @@ class FractionTest(unittest.TestCase):
self.assertEqual("7", str(F(7, 1)))
def testHash(self):
+ hmod = sys.hash_info.modulus
+ hinf = sys.hash_info.inf
self.assertEqual(hash(2.5), hash(F(5, 2)))
self.assertEqual(hash(10**50), hash(F(10**50)))
self.assertNotEqual(hash(float(10**23)), hash(F(10**23)))
+ self.assertEqual(hinf, hash(F(1, hmod)))
+ # Check that __hash__ produces the same value as hash(), for
+ # consistency with int and Decimal. (See issue #10356.)
+ self.assertEqual(hash(F(-1)), F(-1).__hash__())
def testApproximatePi(self):
# Algorithm borrowed from
diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py
index 771f5999742..5243ebb1658 100644
--- a/Lib/test/test_frozen.py
+++ b/Lib/test/test_frozen.py
@@ -1,27 +1,49 @@
# Test the frozen module defined in frozen.c.
-from test.test_support import captured_stdout, run_unittest
+from test.support import captured_stdout, run_unittest
import unittest
import sys
class FrozenTests(unittest.TestCase):
def test_frozen(self):
-
with captured_stdout() as stdout:
try:
import __hello__
- except ImportError, x:
+ except ImportError as x:
self.fail("import __hello__ failed:" + str(x))
+ self.assertEqual(__hello__.initialized, True)
+ self.assertEqual(len(dir(__hello__)), 7, dir(__hello__))
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+ with captured_stdout() as stdout:
try:
import __phello__
- except ImportError, x:
+ except ImportError as x:
self.fail("import __phello__ failed:" + str(x))
+ self.assertEqual(__phello__.initialized, True)
+ if not "__phello__.spam" in sys.modules:
+ self.assertEqual(len(dir(__phello__)), 8, dir(__phello__))
+ else:
+ self.assertEqual(len(dir(__phello__)), 9, dir(__phello__))
+ self.assertEqual(__phello__.__path__, [__phello__.__name__])
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+ with captured_stdout() as stdout:
try:
import __phello__.spam
- except ImportError, x:
+ except ImportError as x:
self.fail("import __phello__.spam failed:" + str(x))
+ self.assertEqual(__phello__.spam.initialized, True)
+ self.assertEqual(len(dir(__phello__.spam)), 7)
+ self.assertEqual(len(dir(__phello__)), 9)
+ self.assertEqual(stdout.getvalue(), 'Hello world!\n')
+
+ try:
+ import __phello__.foo
+ except ImportError:
+ pass
+ else:
+ self.fail("import __phello__.foo should have failed")
try:
import __phello__.foo
@@ -30,18 +52,12 @@ class FrozenTests(unittest.TestCase):
else:
self.fail("import __phello__.foo should have failed")
- self.assertEqual(stdout.getvalue(),
- 'Hello world...\nHello world...\nHello world...\n')
-
del sys.modules['__hello__']
del sys.modules['__phello__']
del sys.modules['__phello__.spam']
-
def test_main():
run_unittest(FrozenTests)
-
-
-if __name__ == '__main__':
+if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_ftplib.py b/Lib/test/test_ftplib.py
index c82e8a69bf3..71bc23e615a 100644
--- a/Lib/test/test_ftplib.py
+++ b/Lib/test/test_ftplib.py
@@ -7,19 +7,19 @@ import ftplib
import asyncore
import asynchat
import socket
-import StringIO
+import io
import errno
import os
+import time
try:
import ssl
except ImportError:
ssl = None
from unittest import TestCase
-from test import test_support
-from test.test_support import HOST
-threading = test_support.import_module('threading')
-
+from test import support
+from test.support import HOST
+threading = support.import_module('threading')
# the dummy data returned by server over the data channel when
# RETR, LIST and NLST commands are issued
@@ -37,7 +37,7 @@ class DummyDTPHandler(asynchat.async_chat):
self.baseclass.last_received_data = ''
def handle_read(self):
- self.baseclass.last_received_data += self.recv(1024)
+ self.baseclass.last_received_data += self.recv(1024).decode('ascii')
def handle_close(self):
# XXX: this method can be called many times in a row for a single
@@ -48,6 +48,9 @@ class DummyDTPHandler(asynchat.async_chat):
self.close()
self.dtp_conn_closed = True
+ def push(self, what):
+ super(DummyDTPHandler, self).push(what.encode('ascii'))
+
def handle_error(self):
raise
@@ -58,7 +61,9 @@ class DummyFTPHandler(asynchat.async_chat):
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
- self.set_terminator("\r\n")
+ # tells the socket to handle urgent data inline (ABOR command)
+ self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_OOBINLINE, 1)
+ self.set_terminator(b"\r\n")
self.in_buffer = []
self.dtp = None
self.last_received_cmd = None
@@ -71,7 +76,7 @@ class DummyFTPHandler(asynchat.async_chat):
self.in_buffer.append(data)
def found_terminator(self):
- line = ''.join(self.in_buffer)
+ line = b''.join(self.in_buffer).decode('ascii')
self.in_buffer = []
if self.next_response:
self.push(self.next_response)
@@ -93,10 +98,10 @@ class DummyFTPHandler(asynchat.async_chat):
raise
def push(self, data):
- asynchat.async_chat.push(self, data + '\r\n')
+ asynchat.async_chat.push(self, data.encode('ascii') + b'\r\n')
def cmd_port(self, arg):
- addr = map(int, arg.split(','))
+ addr = list(map(int, arg.split(',')))
ip = '%d.%d.%d.%d' %tuple(addr[:4])
port = (addr[4] * 256) + addr[5]
s = socket.create_connection((ip, port), timeout=10)
@@ -104,16 +109,15 @@ class DummyFTPHandler(asynchat.async_chat):
self.push('200 active data connection established')
def cmd_pasv(self, arg):
- sock = socket.socket()
- sock.bind((self.socket.getsockname()[0], 0))
- sock.listen(5)
- sock.settimeout(10)
- ip, port = sock.getsockname()[:2]
- ip = ip.replace('.', ',')
- p1, p2 = divmod(port, 256)
- self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
- conn, addr = sock.accept()
- self.dtp = self.dtp_handler(conn, baseclass=self)
+ with socket.socket() as sock:
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(10)
+ ip, port = sock.getsockname()[:2]
+ ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256
+ self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
+ conn, addr = sock.accept()
+ self.dtp = self.dtp_handler(conn, baseclass=self)
def cmd_eprt(self, arg):
af, ip, port = arg.split(arg[0])[1:-1]
@@ -123,19 +127,22 @@ class DummyFTPHandler(asynchat.async_chat):
self.push('200 active data connection established')
def cmd_epsv(self, arg):
- sock = socket.socket(socket.AF_INET6)
- sock.bind((self.socket.getsockname()[0], 0))
- sock.listen(5)
- sock.settimeout(10)
- port = sock.getsockname()[1]
- self.push('229 entering extended passive mode (|||%d|)' %port)
- conn, addr = sock.accept()
- self.dtp = self.dtp_handler(conn, baseclass=self)
+ with socket.socket(socket.AF_INET6) as sock:
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(10)
+ port = sock.getsockname()[1]
+ self.push('229 entering extended passive mode (|||%d|)' %port)
+ conn, addr = sock.accept()
+ self.dtp = self.dtp_handler(conn, baseclass=self)
def cmd_echo(self, arg):
# sends back the received string (used by the test suite)
self.push(arg)
+ def cmd_noop(self, arg):
+ self.push('200 noop ok')
+
def cmd_user(self, arg):
self.push('331 username ok')
@@ -176,6 +183,9 @@ class DummyFTPHandler(asynchat.async_chat):
self.push('221 quit ok')
self.close()
+ def cmd_abor(self, arg):
+ self.push('226 abor ok')
+
def cmd_stor(self, arg):
self.push('125 stor ok')
@@ -217,6 +227,7 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
self.active = False
self.active_lock = threading.Lock()
self.host, self.port = self.socket.getsockname()[:2]
+ self.handler_instance = None
def start(self):
assert not self.active
@@ -238,10 +249,8 @@ class DummyFTPServer(asyncore.dispatcher, threading.Thread):
self.active = False
self.join()
- def handle_accept(self):
- conn, addr = self.accept()
- self.handler = self.handler(conn)
- self.close()
+ def handle_accepted(self, conn, addr):
+ self.handler_instance = self.handler(conn)
def handle_connect(self):
self.close()
@@ -258,30 +267,32 @@ if ssl is not None:
CERTFILE = os.path.join(os.path.dirname(__file__), "keycert.pem")
- class SSLConnection(object, asyncore.dispatcher):
+ class SSLConnection(asyncore.dispatcher):
"""An asyncore.dispatcher subclass supporting TLS/SSL."""
_ssl_accepting = False
_ssl_closing = False
def secure_connection(self):
- self.socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False,
- certfile=CERTFILE, server_side=True,
- do_handshake_on_connect=False,
- ssl_version=ssl.PROTOCOL_SSLv23)
+ self.del_channel()
+ socket = ssl.wrap_socket(self.socket, suppress_ragged_eofs=False,
+ certfile=CERTFILE, server_side=True,
+ do_handshake_on_connect=False,
+ ssl_version=ssl.PROTOCOL_SSLv23)
+ self.set_socket(socket)
self._ssl_accepting = True
def _do_ssl_handshake(self):
try:
self.socket.do_handshake()
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
return
elif err.args[0] == ssl.SSL_ERROR_EOF:
return self.handle_close()
raise
- except socket.error, err:
+ except socket.error as err:
if err.args[0] == errno.ECONNABORTED:
return self.handle_close()
else:
@@ -291,11 +302,11 @@ if ssl is not None:
self._ssl_closing = True
try:
self.socket = self.socket.unwrap()
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
return
- except socket.error, err:
+ except socket.error as err:
# Any "socket error" corresponds to a SSL_ERROR_SYSCALL return
# from OpenSSL's SSL_shutdown(), corresponding to a
# closed socket condition. See also:
@@ -323,7 +334,7 @@ if ssl is not None:
def send(self, data):
try:
return super(SSLConnection, self).send(data)
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN,
ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
@@ -333,13 +344,13 @@ if ssl is not None:
def recv(self, buffer_size):
try:
return super(SSLConnection, self).recv(buffer_size)
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
- return ''
+ return b''
if err.args[0] in (ssl.SSL_ERROR_EOF, ssl.SSL_ERROR_ZERO_RETURN):
self.handle_close()
- return ''
+ return b''
raise
def handle_error(self):
@@ -349,6 +360,8 @@ if ssl is not None:
if (isinstance(self.socket, ssl.SSLSocket) and
self.socket._sslobj is not None):
self._do_ssl_shutdown()
+ else:
+ super(SSLConnection, self).close()
class DummyTLS_DTPHandler(SSLConnection, DummyDTPHandler):
@@ -456,12 +469,12 @@ class TestFTPClass(TestCase):
def test_rename(self):
self.client.rename('a', 'b')
- self.server.handler.next_response = '200'
+ self.server.handler_instance.next_response = '200'
self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b')
def test_delete(self):
self.client.delete('foo')
- self.server.handler.next_response = '199'
+ self.server.handler_instance.next_response = '199'
self.assertRaises(ftplib.error_reply, self.client.delete, 'foo')
def test_size(self):
@@ -483,15 +496,22 @@ class TestFTPClass(TestCase):
# Ensure the connection gets closed; sock attribute should be None
self.assertEqual(self.client.sock, None)
+ def test_abort(self):
+ self.client.abort()
+
def test_retrbinary(self):
+ def callback(data):
+ received.append(data.decode('ascii'))
received = []
- self.client.retrbinary('retr', received.append)
+ self.client.retrbinary('retr', callback)
self.assertEqual(''.join(received), RETR_DATA)
def test_retrbinary_rest(self):
+ def callback(data):
+ received.append(data.decode('ascii'))
for rest in (0, 10, 20):
received = []
- self.client.retrbinary('retr', received.append, rest=rest)
+ self.client.retrbinary('retr', callback, rest=rest)
self.assertEqual(''.join(received), RETR_DATA[rest:],
msg='rest test case %d %d %d' % (rest,
len(''.join(received)),
@@ -503,9 +523,9 @@ class TestFTPClass(TestCase):
self.assertEqual(''.join(received), RETR_DATA.replace('\r\n', ''))
def test_storbinary(self):
- f = StringIO.StringIO(RETR_DATA)
+ f = io.BytesIO(RETR_DATA.encode('ascii'))
self.client.storbinary('stor', f)
- self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA)
# test new callback arg
flag = []
f.seek(0)
@@ -513,16 +533,16 @@ class TestFTPClass(TestCase):
self.assertTrue(flag)
def test_storbinary_rest(self):
- f = StringIO.StringIO(RETR_DATA)
+ f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii'))
for r in (30, '30'):
f.seek(0)
self.client.storbinary('stor', f, rest=r)
- self.assertEqual(self.server.handler.rest, str(r))
+ self.assertEqual(self.server.handler_instance.rest, str(r))
def test_storlines(self):
- f = StringIO.StringIO(RETR_DATA.replace('\r\n', '\n'))
+ f = io.BytesIO(RETR_DATA.replace('\r\n', '\n').encode('ascii'))
self.client.storlines('stor', f)
- self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ self.assertEqual(self.server.handler_instance.last_received_data, RETR_DATA)
# test new callback arg
flag = []
f.seek(0)
@@ -539,16 +559,74 @@ class TestFTPClass(TestCase):
self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', ''))
def test_makeport(self):
- self.client.makeport()
- # IPv4 is in use, just make sure send_eprt has not been used
- self.assertEqual(self.server.handler.last_received_cmd, 'port')
+ with self.client.makeport():
+ # IPv4 is in use, just make sure send_eprt has not been used
+ self.assertEqual(self.server.handler_instance.last_received_cmd,
+ 'port')
def test_makepasv(self):
host, port = self.client.makepasv()
conn = socket.create_connection((host, port), 10)
conn.close()
# IPv4 is in use, just make sure send_epsv has not been used
- self.assertEqual(self.server.handler.last_received_cmd, 'pasv')
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'pasv')
+
+ def test_with_statement(self):
+ self.client.quit()
+
+ def is_client_connected():
+ if self.client.sock is None:
+ return False
+ try:
+ self.client.sendcmd('noop')
+ except (socket.error, EOFError):
+ return False
+ return True
+
+ # base test
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.assertTrue(is_client_connected())
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ # QUIT sent inside the with block
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.client.quit()
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ # force a wrong response code to be sent on QUIT: error_perm
+ # is expected and the connection is supposed to be closed
+ try:
+ with ftplib.FTP(timeout=10) as self.client:
+ self.client.connect(self.server.host, self.server.port)
+ self.client.sendcmd('noop')
+ self.server.handler_instance.next_response = '550 error on quit'
+ except ftplib.error_perm as err:
+ self.assertEqual(str(err), '550 error on quit')
+ else:
+ self.fail('Exception not raised')
+ # needed to give the threaded server some time to set the attribute
+ # which otherwise would still be == 'noop'
+ time.sleep(0.1)
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'quit')
+ self.assertFalse(is_client_connected())
+
+ def test_parse257(self):
+ self.assertEqual(ftplib.parse257('257 "/foo/bar"'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 "/foo/bar" created'), '/foo/bar')
+ self.assertEqual(ftplib.parse257('257 ""'), '')
+ self.assertEqual(ftplib.parse257('257 "" created'), '')
+ self.assertRaises(ftplib.error_reply, ftplib.parse257, '250 "/foo/bar"')
+ # The 257 response is supposed to include the directory
+ # name and in case it contains embedded double-quotes
+ # they must be doubled (see RFC-959, chapter 7, appendix 2).
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar"'), '/foo/b"ar')
+ self.assertEqual(ftplib.parse257('257 "/foo/b""ar" created'), '/foo/b"ar')
class TestIPv6Environment(TestCase):
@@ -567,19 +645,22 @@ class TestIPv6Environment(TestCase):
self.assertEqual(self.client.af, socket.AF_INET6)
def test_makeport(self):
- self.client.makeport()
- self.assertEqual(self.server.handler.last_received_cmd, 'eprt')
+ with self.client.makeport():
+ self.assertEqual(self.server.handler_instance.last_received_cmd,
+ 'eprt')
def test_makepasv(self):
host, port = self.client.makepasv()
conn = socket.create_connection((host, port), 10)
conn.close()
- self.assertEqual(self.server.handler.last_received_cmd, 'epsv')
+ self.assertEqual(self.server.handler_instance.last_received_cmd, 'epsv')
def test_transfer(self):
def retr():
+ def callback(data):
+ received.append(data.decode('ascii'))
received = []
- self.client.retrbinary('retr', received.append)
+ self.client.retrbinary('retr', callback)
self.assertEqual(''.join(received), RETR_DATA)
self.client.set_pasv(True)
retr()
@@ -622,23 +703,20 @@ class TestTLS_FTPClass(TestCase):
def test_data_connection(self):
# clear text
- sock = self.client.transfercmd('list')
- self.assertNotIsInstance(sock, ssl.SSLSocket)
- sock.close()
+ with self.client.transfercmd('list') as sock:
+ self.assertNotIsInstance(sock, ssl.SSLSocket)
self.assertEqual(self.client.voidresp(), "226 transfer complete")
# secured, after PROT P
self.client.prot_p()
- sock = self.client.transfercmd('list')
- self.assertIsInstance(sock, ssl.SSLSocket)
- sock.close()
+ with self.client.transfercmd('list') as sock:
+ self.assertIsInstance(sock, ssl.SSLSocket)
self.assertEqual(self.client.voidresp(), "226 transfer complete")
# PROT C is issued, the connection must be in cleartext again
self.client.prot_c()
- sock = self.client.transfercmd('list')
- self.assertNotIsInstance(sock, ssl.SSLSocket)
- sock.close()
+ with self.client.transfercmd('list') as sock:
+ self.assertNotIsInstance(sock, ssl.SSLSocket)
self.assertEqual(self.client.voidresp(), "226 transfer complete")
def test_login(self):
@@ -661,6 +739,28 @@ class TestTLS_FTPClass(TestCase):
finally:
self.client.ssl_version = ssl.PROTOCOL_TLSv1
+ def test_context(self):
+ self.client.quit()
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, keyfile=CERTFILE,
+ context=ctx)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+ context=ctx)
+ self.assertRaises(ValueError, ftplib.FTP_TLS, certfile=CERTFILE,
+ keyfile=CERTFILE, context=ctx)
+
+ self.client = ftplib.FTP_TLS(context=ctx, timeout=10)
+ self.client.connect(self.server.host, self.server.port)
+ self.assertNotIsInstance(self.client.sock, ssl.SSLSocket)
+ self.client.auth()
+ self.assertIs(self.client.sock.context, ctx)
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+
+ self.client.prot_p()
+ with self.client.transfercmd('list') as sock:
+ self.assertIs(sock.context, ctx)
+ self.assertIsInstance(sock, ssl.SSLSocket)
+
class TestTimeouts(TestCase):
@@ -668,7 +768,7 @@ class TestTimeouts(TestCase):
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(10)
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
# Wait for the server to be ready.
self.evt.wait()
@@ -677,6 +777,7 @@ class TestTimeouts(TestCase):
def tearDown(self):
self.evt.wait()
+ self.sock.close()
def server(self, evt, serv):
# This method sets the evt 3 times:
@@ -691,7 +792,7 @@ class TestTimeouts(TestCase):
except socket.timeout:
pass
else:
- conn.send("1 Hola mundo\n")
+ conn.send(b"1 Hola mundo\n")
# (2) Signal the caller that it is safe to close the socket.
evt.set()
conn.close()
@@ -767,11 +868,11 @@ def test_main():
if ssl is not None:
tests.extend([TestTLS_FTPClassMixin, TestTLS_FTPClass])
- thread_info = test_support.threading_setup()
+ thread_info = support.threading_setup()
try:
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
finally:
- test_support.threading_cleanup(*thread_info)
+ support.threading_cleanup(*thread_info)
if __name__ == '__main__':
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py
index b639ca20425..4d1936879ec 100644
--- a/Lib/test/test_funcattrs.py
+++ b/Lib/test/test_funcattrs.py
@@ -1,4 +1,4 @@
-from test import test_support
+from test import support
import types
import unittest
@@ -9,12 +9,11 @@ class FuncAttrsTest(unittest.TestCase):
pass
def b():
return 3
- self.f = F
self.fi = F()
+ self.F = F
self.b = b
def cannot_set_attr(self, obj, name, value, exceptions):
- # Helper method for other tests.
try:
setattr(obj, name, value)
except exceptions:
@@ -37,15 +36,11 @@ class FunctionPropertiesTest(FuncAttrsTest):
def test_dir_includes_correct_attrs(self):
self.b.known_attr = 7
self.assertIn('known_attr', dir(self.b),
- "set attributes not in dir listing of method")
+ "set attributes not in dir listing of method")
# Test on underlying function object of method
- self.f.a.im_func.known_attr = 7
- self.assertIn('known_attr', dir(self.f.a),
- "set attribute on unbound method implementation in "
- "class not in dir")
- self.assertIn('known_attr', dir(self.fi.a),
- "set attribute on unbound method implementations, "
- "should show up in next dir")
+ self.F.a.known_attr = 7
+ self.assertIn('known_attr', dir(self.fi.a), "set attribute on function "
+ "implementations, should show up in next dir")
def test_duplicate_function_equality(self):
# Body of `duplicate' is the exact same as self.b
@@ -54,59 +49,54 @@ class FunctionPropertiesTest(FuncAttrsTest):
return 3
self.assertNotEqual(self.b, duplicate)
- def test_copying_func_code(self):
+ def test_copying___code__(self):
def test(): pass
self.assertEqual(test(), None)
- test.func_code = self.b.func_code
+ test.__code__ = self.b.__code__
self.assertEqual(test(), 3) # self.b always returns 3, arbitrarily
- def test_func_globals(self):
- self.assertIs(self.b.func_globals, globals())
- self.cannot_set_attr(self.b, 'func_globals', 2, TypeError)
+ def test___globals__(self):
+ self.assertIs(self.b.__globals__, globals())
+ self.cannot_set_attr(self.b, '__globals__', 2,
+ (AttributeError, TypeError))
- def test_func_closure(self):
+ def test___closure__(self):
a = 12
- def f(): print a
- c = f.func_closure
+ def f(): print(a)
+ c = f.__closure__
self.assertIsInstance(c, tuple)
self.assertEqual(len(c), 1)
# don't have a type object handy
self.assertEqual(c[0].__class__.__name__, "cell")
- self.cannot_set_attr(f, "func_closure", c, TypeError)
+ self.cannot_set_attr(f, "__closure__", c, AttributeError)
def test_empty_cell(self):
- def f(): print a
+ def f(): print(a)
try:
- f.func_closure[0].cell_contents
+ f.__closure__[0].cell_contents
except ValueError:
pass
else:
self.fail("shouldn't be able to read an empty cell")
a = 12
- def test_func_name(self):
+ def test___name__(self):
self.assertEqual(self.b.__name__, 'b')
- self.assertEqual(self.b.func_name, 'b')
self.b.__name__ = 'c'
self.assertEqual(self.b.__name__, 'c')
- self.assertEqual(self.b.func_name, 'c')
- self.b.func_name = 'd'
+ self.b.__name__ = 'd'
self.assertEqual(self.b.__name__, 'd')
- self.assertEqual(self.b.func_name, 'd')
- # __name__ and func_name must be a string
+ # __name__ and __name__ must be a string
self.cannot_set_attr(self.b, '__name__', 7, TypeError)
- self.cannot_set_attr(self.b, 'func_name', 7, TypeError)
# __name__ must be available when in restricted mode. Exec will raise
# AttributeError if __name__ is not available on f.
s = """def f(): pass\nf.__name__"""
- exec s in {'__builtins__': {}}
+ exec(s, {'__builtins__': {}})
# Test on methods, too
- self.assertEqual(self.f.a.__name__, 'a')
self.assertEqual(self.fi.a.__name__, 'a')
- self.cannot_set_attr(self.f.a, "__name__", 'a', AttributeError)
self.cannot_set_attr(self.fi.a, "__name__", 'a', AttributeError)
- def test_func_code(self):
+ def test___code__(self):
num_one, num_two = 7, 8
def a(): pass
def b(): return 12
@@ -114,134 +104,107 @@ class FunctionPropertiesTest(FuncAttrsTest):
def d(): return num_two
def e(): return num_one, num_two
for func in [a, b, c, d, e]:
- self.assertEqual(type(func.func_code), types.CodeType)
+ self.assertEqual(type(func.__code__), types.CodeType)
self.assertEqual(c(), 7)
self.assertEqual(d(), 8)
- d.func_code = c.func_code
- self.assertEqual(c.func_code, d.func_code)
+ d.__code__ = c.__code__
+ self.assertEqual(c.__code__, d.__code__)
self.assertEqual(c(), 7)
# self.assertEqual(d(), 7)
try:
- b.func_code = c.func_code
+ b.__code__ = c.__code__
except ValueError:
pass
else:
- self.fail("func_code with different numbers of free vars should "
+ self.fail("__code__ with different numbers of free vars should "
"not be possible")
try:
- e.func_code = d.func_code
+ e.__code__ = d.__code__
except ValueError:
pass
else:
- self.fail("func_code with different numbers of free vars should "
+ self.fail("__code__ with different numbers of free vars should "
"not be possible")
def test_blank_func_defaults(self):
- self.assertEqual(self.b.func_defaults, None)
- del self.b.func_defaults
- self.assertEqual(self.b.func_defaults, None)
+ self.assertEqual(self.b.__defaults__, None)
+ del self.b.__defaults__
+ self.assertEqual(self.b.__defaults__, None)
def test_func_default_args(self):
def first_func(a, b):
return a+b
def second_func(a=1, b=2):
return a+b
- self.assertEqual(first_func.func_defaults, None)
- self.assertEqual(second_func.func_defaults, (1, 2))
- first_func.func_defaults = (1, 2)
- self.assertEqual(first_func.func_defaults, (1, 2))
+ self.assertEqual(first_func.__defaults__, None)
+ self.assertEqual(second_func.__defaults__, (1, 2))
+ first_func.__defaults__ = (1, 2)
+ self.assertEqual(first_func.__defaults__, (1, 2))
self.assertEqual(first_func(), 3)
self.assertEqual(first_func(3), 5)
self.assertEqual(first_func(3, 5), 8)
- del second_func.func_defaults
- self.assertEqual(second_func.func_defaults, None)
+ del second_func.__defaults__
+ self.assertEqual(second_func.__defaults__, None)
try:
second_func()
except TypeError:
pass
else:
- self.fail("func_defaults does not update; deleting it does not "
+ self.fail("__defaults__ does not update; deleting it does not "
"remove requirement")
class InstancemethodAttrTest(FuncAttrsTest):
- def test_im_class(self):
- self.assertEqual(self.f.a.im_class, self.f)
- self.assertEqual(self.fi.a.im_class, self.f)
- self.cannot_set_attr(self.f.a, "im_class", self.f, TypeError)
- self.cannot_set_attr(self.fi.a, "im_class", self.f, TypeError)
-
- def test_im_func(self):
- self.f.b = self.b
- self.assertEqual(self.f.b.im_func, self.b)
- self.assertEqual(self.fi.b.im_func, self.b)
- self.cannot_set_attr(self.f.b, "im_func", self.b, TypeError)
- self.cannot_set_attr(self.fi.b, "im_func", self.b, TypeError)
-
- def test_im_self(self):
- self.assertEqual(self.f.a.im_self, None)
- self.assertEqual(self.fi.a.im_self, self.fi)
- self.cannot_set_attr(self.f.a, "im_self", None, TypeError)
- self.cannot_set_attr(self.fi.a, "im_self", self.fi, TypeError)
-
- def test_im_func_non_method(self):
+
+ def test___class__(self):
+ self.assertEqual(self.fi.a.__self__.__class__, self.F)
+ self.cannot_set_attr(self.fi.a, "__class__", self.F, TypeError)
+
+ def test___func__(self):
+ self.assertEqual(self.fi.a.__func__, self.F.a)
+ self.cannot_set_attr(self.fi.a, "__func__", self.F.a, AttributeError)
+
+ def test___self__(self):
+ self.assertEqual(self.fi.a.__self__, self.fi)
+ self.cannot_set_attr(self.fi.a, "__self__", self.fi, AttributeError)
+
+ def test___func___non_method(self):
# Behavior should be the same when a method is added via an attr
# assignment
- self.f.id = types.MethodType(id, None, self.f)
+ self.fi.id = types.MethodType(id, self.fi)
self.assertEqual(self.fi.id(), id(self.fi))
- self.assertNotEqual(self.fi.id(), id(self.f))
# Test usage
try:
- self.f.id.unknown_attr
+ self.fi.id.unknown_attr
except AttributeError:
pass
else:
self.fail("using unknown attributes should raise AttributeError")
# Test assignment and deletion
- self.cannot_set_attr(self.f.id, 'unknown_attr', 2, AttributeError)
self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError)
- def test_implicit_method_properties(self):
- self.f.a.im_func.known_attr = 7
- self.assertEqual(self.f.a.known_attr, 7)
- self.assertEqual(self.fi.a.known_attr, 7)
-
class ArbitraryFunctionAttrTest(FuncAttrsTest):
def test_set_attr(self):
- # setting attributes only works on function objects
self.b.known_attr = 7
self.assertEqual(self.b.known_attr, 7)
- for func in [self.f.a, self.fi.a]:
- try:
- func.known_attr = 7
- except AttributeError:
- pass
- else:
- self.fail("setting attributes on methods should raise error")
-
- def test_delete_unknown_attr(self):
try:
- del self.b.unknown_attr
+ self.fi.a.known_attr = 7
except AttributeError:
pass
else:
- self.fail("deleting unknown attribute should raise TypeError")
+ self.fail("setting attributes on methods should raise error")
- def test_setting_attrs_duplicates(self):
+ def test_delete_unknown_attr(self):
try:
- self.f.a.klass = self.f
+ del self.b.unknown_attr
except AttributeError:
pass
else:
- self.fail("setting arbitrary attribute in unbound function "
- " should raise AttributeError")
- self.f.a.im_func.klass = self.f
- for method in [self.f.a, self.fi.a, self.fi.a.im_func]:
- self.assertEqual(method.klass, self.f)
+ self.fail("deleting unknown attribute should raise TypeError")
def test_unset_attr(self):
- for func in [self.b, self.f.a, self.fi.a]:
+ for func in [self.b, self.fi.a]:
try:
func.non_existent_attr
except AttributeError:
@@ -254,48 +217,33 @@ class ArbitraryFunctionAttrTest(FuncAttrsTest):
class FunctionDictsTest(FuncAttrsTest):
def test_setting_dict_to_invalid(self):
self.cannot_set_attr(self.b, '__dict__', None, TypeError)
- self.cannot_set_attr(self.b, 'func_dict', None, TypeError)
- from UserDict import UserDict
+ from collections import UserDict
d = UserDict({'known_attr': 7})
- self.cannot_set_attr(self.f.a.im_func, '__dict__', d, TypeError)
- self.cannot_set_attr(self.fi.a.im_func, '__dict__', d, TypeError)
+ self.cannot_set_attr(self.fi.a.__func__, '__dict__', d, TypeError)
def test_setting_dict_to_valid(self):
d = {'known_attr': 7}
self.b.__dict__ = d
- # Setting dict is only possible on the underlying function objects
- self.f.a.im_func.__dict__ = d
# Test assignment
self.assertIs(d, self.b.__dict__)
- self.assertIs(d, self.b.func_dict)
# ... and on all the different ways of referencing the method's func
- self.assertIs(d, self.f.a.im_func.__dict__)
- self.assertIs(d, self.f.a.__dict__)
- self.assertIs(d, self.fi.a.im_func.__dict__)
+ self.F.a.__dict__ = d
+ self.assertIs(d, self.fi.a.__func__.__dict__)
self.assertIs(d, self.fi.a.__dict__)
# Test value
self.assertEqual(self.b.known_attr, 7)
self.assertEqual(self.b.__dict__['known_attr'], 7)
- self.assertEqual(self.b.func_dict['known_attr'], 7)
# ... and again, on all the different method's names
- self.assertEqual(self.f.a.im_func.known_attr, 7)
- self.assertEqual(self.f.a.known_attr, 7)
- self.assertEqual(self.fi.a.im_func.known_attr, 7)
+ self.assertEqual(self.fi.a.__func__.known_attr, 7)
self.assertEqual(self.fi.a.known_attr, 7)
- def test_delete_func_dict(self):
+ def test_delete___dict__(self):
try:
del self.b.__dict__
except TypeError:
pass
else:
self.fail("deleting function dictionary should raise TypeError")
- try:
- del self.b.func_dict
- except TypeError:
- pass
- else:
- self.fail("deleting function dictionary should raise TypeError")
def test_unassigned_dict(self):
self.assertEqual(self.b.__dict__, {})
@@ -310,25 +258,49 @@ class FunctionDictsTest(FuncAttrsTest):
class FunctionDocstringTest(FuncAttrsTest):
def test_set_docstring_attr(self):
self.assertEqual(self.b.__doc__, None)
- self.assertEqual(self.b.func_doc, None)
docstr = "A test method that does nothing"
- self.b.__doc__ = self.f.a.im_func.__doc__ = docstr
+ self.b.__doc__ = docstr
+ self.F.a.__doc__ = docstr
self.assertEqual(self.b.__doc__, docstr)
- self.assertEqual(self.b.func_doc, docstr)
- self.assertEqual(self.f.a.__doc__, docstr)
self.assertEqual(self.fi.a.__doc__, docstr)
- self.cannot_set_attr(self.f.a, "__doc__", docstr, AttributeError)
self.cannot_set_attr(self.fi.a, "__doc__", docstr, AttributeError)
def test_delete_docstring(self):
self.b.__doc__ = "The docstring"
del self.b.__doc__
self.assertEqual(self.b.__doc__, None)
- self.assertEqual(self.b.func_doc, None)
- self.b.func_doc = "The docstring"
- del self.b.func_doc
- self.assertEqual(self.b.__doc__, None)
- self.assertEqual(self.b.func_doc, None)
+
+
+def cell(value):
+ """Create a cell containing the given value."""
+ def f():
+ print(a)
+ a = value
+ return f.__closure__[0]
+
+def empty_cell(empty=True):
+ """Create an empty cell."""
+ def f():
+ print(a)
+ # the intent of the following line is simply "if False:"; it's
+ # spelt this way to avoid the danger that a future optimization
+ # might simply remove an "if False:" code block.
+ if not empty:
+ a = 1729
+ return f.__closure__[0]
+
+
+class CellTest(unittest.TestCase):
+ def test_comparison(self):
+ # These tests are here simply to exercise the comparison code;
+ # their presence should not be interpreted as providing any
+ # guarantees about the semantics (or even existence) of cell
+ # comparisons in future versions of CPython.
+ self.assertTrue(cell(2) < cell(3))
+ self.assertTrue(empty_cell() < cell('saturday'))
+ self.assertTrue(empty_cell() == empty_cell())
+ self.assertTrue(cell(-36) == cell(-36.0))
+ self.assertTrue(cell(True) > empty_cell())
class StaticMethodAttrsTest(unittest.TestCase):
@@ -344,9 +316,9 @@ class StaticMethodAttrsTest(unittest.TestCase):
def test_main():
- test_support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest,
+ support.run_unittest(FunctionPropertiesTest, InstancemethodAttrTest,
ArbitraryFunctionAttrTest, FunctionDictsTest,
- FunctionDocstringTest,
+ FunctionDocstringTest, CellTest,
StaticMethodAttrsTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_functools.py b/Lib/test/test_functools.py
index a713314f160..270cab00756 100644
--- a/Lib/test/test_functools.py
+++ b/Lib/test/test_functools.py
@@ -1,9 +1,11 @@
import functools
+import collections
import sys
import unittest
-from test import test_support
+from test import support
from weakref import proxy
import pickle
+from random import choice
@staticmethod
def PythonPartial(func, *args, **keywords):
@@ -34,7 +36,7 @@ class TestPartial(unittest.TestCase):
self.assertEqual(p(3, 4, b=30, c=40),
((1, 2, 3, 4), dict(a=10, b=30, c=40)))
p = self.thetype(map, lambda x: x*10)
- self.assertEqual(p([1,2,3,4]), [10, 20, 30, 40])
+ self.assertEqual(list(p([1,2,3,4])), [10, 20, 30, 40])
def test_attributes(self):
p = self.thetype(capture, 1, 2, a=10, b=20)
@@ -45,9 +47,9 @@ class TestPartial(unittest.TestCase):
# attributes should not be writable
if not isinstance(self.thetype, type):
return
- self.assertRaises(TypeError, setattr, p, 'func', map)
- self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
- self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))
+ self.assertRaises(AttributeError, setattr, p, 'func', map)
+ self.assertRaises(AttributeError, setattr, p, 'args', (1, 2))
+ self.assertRaises(AttributeError, setattr, p, 'keywords', dict(a=1, b=2))
p = self.thetype(hex)
try:
@@ -125,7 +127,7 @@ class TestPartial(unittest.TestCase):
def test_error_propagation(self):
def f(x, y):
- x // y
+ x / y
self.assertRaises(ZeroDivisionError, self.thetype(f, 1, 0))
self.assertRaises(ZeroDivisionError, self.thetype(f, 1), 0)
self.assertRaises(ZeroDivisionError, self.thetype(f), 1, 0)
@@ -139,12 +141,38 @@ class TestPartial(unittest.TestCase):
self.assertRaises(ReferenceError, getattr, p, 'func')
def test_with_bound_and_unbound_methods(self):
- data = map(str, range(10))
+ data = list(map(str, range(10)))
join = self.thetype(str.join, '')
self.assertEqual(join(data), '0123456789')
join = self.thetype(''.join)
self.assertEqual(join(data), '0123456789')
+ def test_repr(self):
+ args = (object(), object())
+ args_repr = ', '.join(repr(a) for a in args)
+ kwargs = {'a': object(), 'b': object()}
+ kwargs_repr = ', '.join("%s=%r" % (k, v) for k, v in kwargs.items())
+ if self.thetype is functools.partial:
+ name = 'functools.partial'
+ else:
+ name = self.thetype.__name__
+
+ f = self.thetype(capture)
+ self.assertEqual('{}({!r})'.format(name, capture),
+ repr(f))
+
+ f = self.thetype(capture, *args)
+ self.assertEqual('{}({!r}, {})'.format(name, capture, args_repr),
+ repr(f))
+
+ f = self.thetype(capture, **kwargs)
+ self.assertEqual('{}({!r}, {})'.format(name, capture, kwargs_repr),
+ repr(f))
+
+ f = self.thetype(capture, *args, **kwargs)
+ self.assertEqual('{}({!r}, {}, {})'.format(name, capture, args_repr, kwargs_repr),
+ repr(f))
+
def test_pickle(self):
f = self.thetype(signature, 'asdf', bar=True)
f.add_something_to__dict__ = True
@@ -162,6 +190,9 @@ class TestPythonPartial(TestPartial):
thetype = PythonPartial
+ # the python version hasn't a nice repr
+ def test_repr(self): pass
+
# the python version isn't picklable
def test_pickle(self): pass
@@ -181,11 +212,11 @@ class TestUpdateWrapper(unittest.TestCase):
self.assertTrue(wrapped_attr[key] is wrapper_attr[key])
def _default_update(self):
- def f():
+ def f(a:'This is a new annotation'):
"""This is a test"""
pass
f.attr = 'This is also a test'
- def wrapper():
+ def wrapper(b:'This is the prior annotation'):
pass
functools.update_wrapper(wrapper, f)
return wrapper, f
@@ -193,8 +224,11 @@ class TestUpdateWrapper(unittest.TestCase):
def test_default_update(self):
wrapper, f = self._default_update()
self.check_wrapper(wrapper, f)
+ self.assertIs(wrapper.__wrapped__, f)
self.assertEqual(wrapper.__name__, 'f')
self.assertEqual(wrapper.attr, 'This is also a test')
+ self.assertEqual(wrapper.__annotations__['a'], 'This is a new annotation')
+ self.assertNotIn('b', wrapper.__annotations__)
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@@ -213,6 +247,7 @@ class TestUpdateWrapper(unittest.TestCase):
self.check_wrapper(wrapper, f, (), ())
self.assertEqual(wrapper.__name__, 'wrapper')
self.assertEqual(wrapper.__doc__, None)
+ self.assertEqual(wrapper.__annotations__, {})
self.assertFalse(hasattr(wrapper, 'attr'))
def test_selective_update(self):
@@ -232,6 +267,28 @@ class TestUpdateWrapper(unittest.TestCase):
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)
+ def test_missing_attributes(self):
+ def f():
+ pass
+ def wrapper():
+ pass
+ wrapper.dict_attr = {}
+ assign = ('attr',)
+ update = ('dict_attr',)
+ # Missing attributes on wrapped object are ignored
+ functools.update_wrapper(wrapper, f, assign, update)
+ self.assertNotIn('attr', wrapper.__dict__)
+ self.assertEqual(wrapper.dict_attr, {})
+ # Wrapper must have expected attributes for updating
+ del wrapper.dict_attr
+ with self.assertRaises(AttributeError):
+ functools.update_wrapper(wrapper, f, assign, update)
+ wrapper.dict_attr = 1
+ with self.assertRaises(AttributeError):
+ functools.update_wrapper(wrapper, f, assign, update)
+
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ "Docstrings are omitted with -O2 and above")
def test_builtin_update(self):
# Test for bug #1576241
def wrapper():
@@ -239,6 +296,7 @@ class TestUpdateWrapper(unittest.TestCase):
functools.update_wrapper(wrapper, max)
self.assertEqual(wrapper.__name__, 'max')
self.assertTrue(wrapper.__doc__.startswith('max('))
+ self.assertEqual(wrapper.__annotations__, {})
class TestWraps(TestUpdateWrapper):
@@ -297,17 +355,17 @@ class TestWraps(TestUpdateWrapper):
self.assertEqual(wrapper.attr, 'This is a different test')
self.assertEqual(wrapper.dict_attr, f.dict_attr)
-
class TestReduce(unittest.TestCase):
+ func = functools.reduce
def test_reduce(self):
class Squares:
-
def __init__(self, max):
self.max = max
self.sofar = []
- def __len__(self): return len(self.sofar)
+ def __len__(self):
+ return len(self.sofar)
def __getitem__(self, i):
if not 0 <= i < self.max: raise IndexError
@@ -316,27 +374,66 @@ class TestReduce(unittest.TestCase):
self.sofar.append(n*n)
n += 1
return self.sofar[i]
-
- reduce = functools.reduce
- self.assertEqual(reduce(lambda x, y: x+y, ['a', 'b', 'c'], ''), 'abc')
+ def add(x, y):
+ return x + y
+ self.assertEqual(self.func(add, ['a', 'b', 'c'], ''), 'abc')
self.assertEqual(
- reduce(lambda x, y: x+y, [['a', 'c'], [], ['d', 'w']], []),
+ self.func(add, [['a', 'c'], [], ['d', 'w']], []),
['a','c','d','w']
)
- self.assertEqual(reduce(lambda x, y: x*y, range(2,8), 1), 5040)
+ self.assertEqual(self.func(lambda x, y: x*y, range(2,8), 1), 5040)
self.assertEqual(
- reduce(lambda x, y: x*y, range(2,21), 1L),
- 2432902008176640000L
+ self.func(lambda x, y: x*y, range(2,21), 1),
+ 2432902008176640000
)
- self.assertEqual(reduce(lambda x, y: x+y, Squares(10)), 285)
- self.assertEqual(reduce(lambda x, y: x+y, Squares(10), 0), 285)
- self.assertEqual(reduce(lambda x, y: x+y, Squares(0), 0), 0)
- self.assertRaises(TypeError, reduce)
- self.assertRaises(TypeError, reduce, 42, 42)
- self.assertRaises(TypeError, reduce, 42, 42, 42)
- self.assertEqual(reduce(42, "1"), "1") # func is never called with one item
- self.assertEqual(reduce(42, "", "1"), "1") # func is never called with one item
- self.assertRaises(TypeError, reduce, 42, (42, 42))
+ self.assertEqual(self.func(add, Squares(10)), 285)
+ self.assertEqual(self.func(add, Squares(10), 0), 285)
+ self.assertEqual(self.func(add, Squares(0), 0), 0)
+ self.assertRaises(TypeError, self.func)
+ self.assertRaises(TypeError, self.func, 42, 42)
+ self.assertRaises(TypeError, self.func, 42, 42, 42)
+ self.assertEqual(self.func(42, "1"), "1") # func is never called with one item
+ self.assertEqual(self.func(42, "", "1"), "1") # func is never called with one item
+ self.assertRaises(TypeError, self.func, 42, (42, 42))
+ self.assertRaises(TypeError, self.func, add, []) # arg 2 must not be empty sequence with no initial value
+ self.assertRaises(TypeError, self.func, add, "")
+ self.assertRaises(TypeError, self.func, add, ())
+ self.assertRaises(TypeError, self.func, add, object())
+
+ class TestFailingIter:
+ def __iter__(self):
+ raise RuntimeError
+ self.assertRaises(RuntimeError, self.func, add, TestFailingIter())
+
+ self.assertEqual(self.func(add, [], None), None)
+ self.assertEqual(self.func(add, [], 42), 42)
+
+ class BadSeq:
+ def __getitem__(self, index):
+ raise ValueError
+ self.assertRaises(ValueError, self.func, 42, BadSeq())
+
+ # Test reduce()'s use of iterators.
+ def test_iterator_usage(self):
+ class SequenceClass:
+ def __init__(self, n):
+ self.n = n
+ def __getitem__(self, i):
+ if 0 <= i < self.n:
+ return i
+ else:
+ raise IndexError
+
+ from operator import add
+ self.assertEqual(self.func(add, SequenceClass(5)), 10)
+ self.assertEqual(self.func(add, SequenceClass(5), 42), 52)
+ self.assertRaises(TypeError, self.func, add, SequenceClass(0))
+ self.assertEqual(self.func(add, SequenceClass(0), 42), 42)
+ self.assertEqual(self.func(add, SequenceClass(1)), 0)
+ self.assertEqual(self.func(add, SequenceClass(1), 42), 42)
+
+ d = {"one": 1, "two": 2, "three": 3}
+ self.assertEqual(self.func(add, d), "".join(d.keys()))
class TestCmpToKey(unittest.TestCase):
def test_cmp_to_key(self):
@@ -350,7 +447,8 @@ class TestCmpToKey(unittest.TestCase):
return y - x
key = functools.cmp_to_key(mycmp)
k = key(10)
- self.assertRaises(TypeError, hash(k))
+ self.assertRaises(TypeError, hash, k)
+ self.assertFalse(isinstance(k, collections.Hashable))
class TestTotalOrdering(unittest.TestCase):
@@ -421,14 +519,14 @@ class TestTotalOrdering(unittest.TestCase):
def test_total_ordering_no_overwrite(self):
# new methods should not overwrite existing
@functools.total_ordering
- class A(str):
+ class A(int):
pass
- self.assertTrue(A("a") < A("b"))
- self.assertTrue(A("b") > A("a"))
- self.assertTrue(A("a") <= A("b"))
- self.assertTrue(A("b") >= A("a"))
- self.assertTrue(A("b") <= A("b"))
- self.assertTrue(A("b") >= A("b"))
+ self.assertTrue(A(1) < A(2))
+ self.assertTrue(A(2) > A(1))
+ self.assertTrue(A(1) <= A(2))
+ self.assertTrue(A(2) >= A(1))
+ self.assertTrue(A(2) <= A(2))
+ self.assertTrue(A(2) >= A(2))
def test_no_operations_defined(self):
with self.assertRaises(ValueError):
@@ -452,6 +550,127 @@ class TestTotalOrdering(unittest.TestCase):
with self.assertRaises(TypeError):
TestTO(8) <= ()
+class TestLRU(unittest.TestCase):
+
+ def test_lru(self):
+ def orig(x, y):
+ return 3*x+y
+ f = functools.lru_cache(maxsize=20)(orig)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(maxsize, 20)
+ self.assertEqual(currsize, 0)
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 0)
+
+ domain = range(5)
+ for i in range(1000):
+ x, y = choice(domain), choice(domain)
+ actual = f(x, y)
+ expected = orig(x, y)
+ self.assertEqual(actual, expected)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertTrue(hits > misses)
+ self.assertEqual(hits + misses, 1000)
+ self.assertEqual(currsize, 20)
+
+ f.cache_clear() # test clearing
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 0)
+ self.assertEqual(currsize, 0)
+ f(x, y)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # Test bypassing the cache
+ self.assertIs(f.__wrapped__, orig)
+ f.__wrapped__(x, y)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # test size zero (which means "never-cache")
+ @functools.lru_cache(0)
+ def f():
+ nonlocal f_cnt
+ f_cnt += 1
+ return 20
+ self.assertEqual(f.cache_info().maxsize, 0)
+ f_cnt = 0
+ for i in range(5):
+ self.assertEqual(f(), 20)
+ self.assertEqual(f_cnt, 5)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 0)
+ self.assertEqual(misses, 5)
+ self.assertEqual(currsize, 0)
+
+ # test size one
+ @functools.lru_cache(1)
+ def f():
+ nonlocal f_cnt
+ f_cnt += 1
+ return 20
+ self.assertEqual(f.cache_info().maxsize, 1)
+ f_cnt = 0
+ for i in range(5):
+ self.assertEqual(f(), 20)
+ self.assertEqual(f_cnt, 1)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 4)
+ self.assertEqual(misses, 1)
+ self.assertEqual(currsize, 1)
+
+ # test size two
+ @functools.lru_cache(2)
+ def f(x):
+ nonlocal f_cnt
+ f_cnt += 1
+ return x*10
+ self.assertEqual(f.cache_info().maxsize, 2)
+ f_cnt = 0
+ for x in 7, 9, 7, 9, 7, 9, 8, 8, 8, 9, 9, 9, 8, 8, 8, 7:
+ # * * * *
+ self.assertEqual(f(x), x*10)
+ self.assertEqual(f_cnt, 4)
+ hits, misses, maxsize, currsize = f.cache_info()
+ self.assertEqual(hits, 12)
+ self.assertEqual(misses, 4)
+ self.assertEqual(currsize, 2)
+
+ def test_lru_with_maxsize_none(self):
+ @functools.lru_cache(maxsize=None)
+ def fib(n):
+ if n < 2:
+ return n
+ return fib(n-1) + fib(n-2)
+ self.assertEqual([fib(n) for n in range(16)],
+ [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610])
+ self.assertEqual(fib.cache_info(),
+ functools._CacheInfo(hits=28, misses=16, maxsize=None, currsize=16))
+ fib.cache_clear()
+ self.assertEqual(fib.cache_info(),
+ functools._CacheInfo(hits=0, misses=0, maxsize=None, currsize=0))
+
+ def test_lru_with_exceptions(self):
+ # Verify that user_function exceptions get passed through without
+ # creating a hard-to-read chained exception.
+ # http://bugs.python.org/issue13177
+ for maxsize in (None, 100):
+ @functools.lru_cache(maxsize)
+ def func(i):
+ return 'abc'[i]
+ self.assertEqual(func(0), 'a')
+ with self.assertRaises(IndexError) as cm:
+ func(15)
+ self.assertIsNone(cm.exception.__context__)
+ # Verify that the previous exception did not result in a cached entry
+ with self.assertRaises(IndexError):
+ func(15)
+
def test_main(verbose=None):
test_classes = (
TestPartial,
@@ -459,20 +678,22 @@ def test_main(verbose=None):
TestPythonPartial,
TestUpdateWrapper,
TestTotalOrdering,
+ TestCmpToKey,
TestWraps,
TestReduce,
+ TestLRU,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == '__main__':
test_main(verbose=True)
diff --git a/Lib/test/test_future.py b/Lib/test/test_future.py
index 84f9c47d00b..c6689a1a18d 100644
--- a/Lib/test/test_future.py
+++ b/Lib/test/test_future.py
@@ -1,7 +1,7 @@
# Test various flavors of legal and illegal future statements
import unittest
-from test import test_support
+from test import support
import re
rx = re.compile('\((\S+).py, line (\d+)')
@@ -13,23 +13,23 @@ def get_error_location(msg):
class FutureTest(unittest.TestCase):
def test_future1(self):
- test_support.unload('test_future1')
+ support.unload('test_future1')
from test import test_future1
self.assertEqual(test_future1.result, 6)
def test_future2(self):
- test_support.unload('test_future2')
+ support.unload('test_future2')
from test import test_future2
self.assertEqual(test_future2.result, 6)
def test_future3(self):
- test_support.unload('test_future3')
+ support.unload('test_future3')
from test import test_future3
def test_badfuture3(self):
try:
from test import badsyntax_future3
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future3", '3'))
else:
self.fail("expected exception didn't occur")
@@ -37,7 +37,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture4(self):
try:
from test import badsyntax_future4
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future4", '3'))
else:
self.fail("expected exception didn't occur")
@@ -45,7 +45,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture5(self):
try:
from test import badsyntax_future5
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future5", '4'))
else:
self.fail("expected exception didn't occur")
@@ -53,7 +53,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture6(self):
try:
from test import badsyntax_future6
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future6", '3'))
else:
self.fail("expected exception didn't occur")
@@ -61,7 +61,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture7(self):
try:
from test import badsyntax_future7
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future7", '3'))
else:
self.fail("expected exception didn't occur")
@@ -69,7 +69,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture8(self):
try:
from test import badsyntax_future8
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future8", '3'))
else:
self.fail("expected exception didn't occur")
@@ -77,7 +77,7 @@ class FutureTest(unittest.TestCase):
def test_badfuture9(self):
try:
from test import badsyntax_future9
- except SyntaxError, msg:
+ except SyntaxError as msg:
self.assertEqual(get_error_location(msg), ("badsyntax_future9", '3'))
else:
self.fail("expected exception didn't occur")
@@ -89,31 +89,31 @@ class FutureTest(unittest.TestCase):
# the parser hack disabled. If a new keyword is introduced in
# 2.6, change this to refer to the new future import.
try:
- exec "from __future__ import print_function; print 0"
+ exec("from __future__ import print_function; print 0")
except SyntaxError:
pass
else:
self.fail("syntax error didn't occur")
try:
- exec "from __future__ import (print_function); print 0"
+ exec("from __future__ import (print_function); print 0")
except SyntaxError:
pass
else:
self.fail("syntax error didn't occur")
def test_multiple_features(self):
- test_support.unload("test.test_future5")
+ support.unload("test.test_future5")
from test import test_future5
def test_unicode_literals_exec(self):
scope = {}
- exec "from __future__ import unicode_literals; x = ''" in scope
- self.assertIsInstance(scope["x"], unicode)
+ exec("from __future__ import unicode_literals; x = ''", {}, scope)
+ self.assertIsInstance(scope["x"], str)
def test_main():
- test_support.run_unittest(FutureTest)
+ support.run_unittest(FutureTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_future2.py b/Lib/test/test_future2.py
index 79eb73179de..3d7fc860a37 100644
--- a/Lib/test/test_future2.py
+++ b/Lib/test/test_future2.py
@@ -1,6 +1,6 @@
"""This is a test"""
-from __future__ import nested_scopes; import string
+from __future__ import nested_scopes; import site
def f(x):
def g(y):
diff --git a/Lib/test/test_future3.py b/Lib/test/test_future3.py
index ed23567a769..b1552a5e8e0 100644
--- a/Lib/test/test_future3.py
+++ b/Lib/test/test_future3.py
@@ -2,7 +2,7 @@ from __future__ import nested_scopes
from __future__ import division
import unittest
-from test import test_support
+from test import support
x = 2
def nester():
@@ -24,7 +24,7 @@ class TestFuture(unittest.TestCase):
self.assertEqual(nester(), 3)
def test_main():
- test_support.run_unittest(TestFuture)
+ support.run_unittest(TestFuture)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_future4.py b/Lib/test/test_future4.py
index 53f8adde228..c32f27f6161 100644
--- a/Lib/test/test_future4.py
+++ b/Lib/test/test_future4.py
@@ -1,47 +1,10 @@
from __future__ import unicode_literals
import unittest
-from test import test_support
-
-class TestFuture(unittest.TestCase):
- def assertType(self, obj, typ):
- self.assertTrue(type(obj) is typ,
- "type(%r) is %r, not %r" % (obj, type(obj), typ))
-
- def test_unicode_strings(self):
- self.assertType("", unicode)
- self.assertType('', unicode)
- self.assertType(r"", unicode)
- self.assertType(r'', unicode)
- self.assertType(""" """, unicode)
- self.assertType(''' ''', unicode)
- self.assertType(r""" """, unicode)
- self.assertType(r''' ''', unicode)
- self.assertType(u"", unicode)
- self.assertType(u'', unicode)
- self.assertType(ur"", unicode)
- self.assertType(ur'', unicode)
- self.assertType(u""" """, unicode)
- self.assertType(u''' ''', unicode)
- self.assertType(ur""" """, unicode)
- self.assertType(ur''' ''', unicode)
-
- self.assertType(b"", str)
- self.assertType(b'', str)
- self.assertType(br"", str)
- self.assertType(br'', str)
- self.assertType(b""" """, str)
- self.assertType(b''' ''', str)
- self.assertType(br""" """, str)
- self.assertType(br''' ''', str)
-
- self.assertType('' '', unicode)
- self.assertType('' u'', unicode)
- self.assertType(u'' '', unicode)
- self.assertType(u'' u'', unicode)
+from test import support
def test_main():
- test_support.run_unittest(TestFuture)
+ pass
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_future5.py b/Lib/test/test_future5.py
index 4984070c47b..ed03a07037a 100644
--- a/Lib/test/test_future5.py
+++ b/Lib/test/test_future5.py
@@ -3,19 +3,19 @@ from __future__ import unicode_literals, print_function
import sys
import unittest
-from . import test_support
+from test import support
class TestMultipleFeatures(unittest.TestCase):
def test_unicode_literals(self):
- self.assertIsInstance("", unicode)
+ self.assertIsInstance("", str)
def test_print_function(self):
- with test_support.captured_output("stderr") as s:
+ with support.captured_output("stderr") as s:
print("foo", file=sys.stderr)
self.assertEqual(s.getvalue(), "foo\n")
def test_main():
- test_support.run_unittest(TestMultipleFeatures)
+ support.run_unittest(TestMultipleFeatures)
diff --git a/Lib/test/test_future_builtins.py b/Lib/test/test_future_builtins.py
deleted file mode 100644
index 96c37885866..00000000000
--- a/Lib/test/test_future_builtins.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import test.test_support, unittest
-
-# we're testing the behavior of these future builtins:
-from future_builtins import hex, oct, map, zip, filter
-
-class BuiltinTest(unittest.TestCase):
- def test_hex(self):
- self.assertEqual(hex(0), '0x0')
- self.assertEqual(hex(16), '0x10')
- self.assertEqual(hex(16L), '0x10')
- self.assertEqual(hex(-16), '-0x10')
- self.assertEqual(hex(-16L), '-0x10')
- self.assertRaises(TypeError, hex, {})
-
- def test_oct(self):
- self.assertEqual(oct(0), '0o0')
- self.assertEqual(oct(100), '0o144')
- self.assertEqual(oct(100L), '0o144')
- self.assertEqual(oct(-100), '-0o144')
- self.assertEqual(oct(-100L), '-0o144')
- self.assertRaises(TypeError, oct, ())
-
- def test_itertools(self):
- from itertools import imap, izip, ifilter
- # We will assume that the itertools functions work, so provided
- # that we've got identical coppies, we will work!
- self.assertEqual(map, imap)
- self.assertEqual(zip, izip)
- self.assertEqual(filter, ifilter)
- # Testing that filter(None, stuff) raises a warning lives in
- # test_py3kwarn.py
-
-
-def test_main(verbose=None):
- test.test_support.run_unittest(BuiltinTest)
-
-if __name__ == "__main__":
- test_main(verbose=True)
diff --git a/Lib/test/test_gc.py b/Lib/test/test_gc.py
index fd874c3a2c3..e1c124d160f 100644
--- a/Lib/test/test_gc.py
+++ b/Lib/test/test_gc.py
@@ -1,5 +1,5 @@
import unittest
-from test.test_support import verbose, run_unittest
+from test.support import verbose, run_unittest, strip_python_stderr
import sys
import time
import gc
@@ -176,7 +176,7 @@ class GCTests(unittest.TestCase):
# Tricky: f -> d -> f, code should call d.clear() after the exec to
# break the cycle.
d = {}
- exec("def f(): pass\n") in d
+ exec("def f(): pass\n", d)
gc.collect()
del d
self.assertEqual(gc.collect(), 2)
@@ -245,30 +245,41 @@ class GCTests(unittest.TestCase):
# The following two tests are fragile:
# They precisely count the number of allocations,
# which is highly implementation-dependent.
- # For example:
- # - disposed tuples are not freed, but reused
- # - the call to assertEqual somehow avoids building its args tuple
+ # For example, disposed tuples are not freed, but reused.
+ # To minimize variations, though, we first store the get_count() results
+ # and check them at the end.
def test_get_count(self):
- # Avoid future allocation of method object
- assertEqual = self._baseAssertEqual
gc.collect()
- assertEqual(gc.get_count(), (0, 0, 0))
- a = dict()
- # since gc.collect(), we created two objects:
- # the dict, and the tuple returned by get_count()
- assertEqual(gc.get_count(), (2, 0, 0))
+ a, b, c = gc.get_count()
+ x = []
+ d, e, f = gc.get_count()
+ self.assertEqual((b, c), (0, 0))
+ self.assertEqual((e, f), (0, 0))
+ # This is less fragile than asserting that a equals 0.
+ self.assertLess(a, 5)
+ # Between the two calls to get_count(), at least one object was
+ # created (the list).
+ self.assertGreater(d, a)
def test_collect_generations(self):
- # Avoid future allocation of method object
- assertEqual = self.assertEqual
gc.collect()
- a = dict()
+ # This object will "trickle" into generation N + 1 after
+ # each call to collect(N)
+ x = []
gc.collect(0)
- assertEqual(gc.get_count(), (0, 1, 0))
+ # x is now in gen 1
+ a, b, c = gc.get_count()
gc.collect(1)
- assertEqual(gc.get_count(), (0, 0, 1))
+ # x is now in gen 2
+ d, e, f = gc.get_count()
gc.collect(2)
- assertEqual(gc.get_count(), (0, 0, 0))
+ # x is now in gen 3
+ g, h, i = gc.get_count()
+ # We don't check a, d, g since their exact values depends on
+ # internal implementation details of the interpreter.
+ self.assertEqual((b, c), (1, 0))
+ self.assertEqual((e, f), (0, 1))
+ self.assertEqual((h, i), (0, 0))
def test_trashcan(self):
class Ouch:
@@ -349,8 +360,8 @@ class GCTests(unittest.TestCase):
while not exit:
make_nested()
- old_checkinterval = sys.getcheckinterval()
- sys.setcheckinterval(3)
+ old_switchinterval = sys.getswitchinterval()
+ sys.setswitchinterval(1e-5)
try:
exit = False
threads = []
@@ -364,7 +375,7 @@ class GCTests(unittest.TestCase):
for t in threads:
t.join()
finally:
- sys.setcheckinterval(old_checkinterval)
+ sys.setswitchinterval(old_switchinterval)
gc.collect()
self.assertEqual(len(C.inits), len(C.dels))
@@ -480,7 +491,7 @@ class GCTests(unittest.TestCase):
got = gc.get_referents([1, 2], {3: 4}, (0, 0, 0))
got.sort()
- self.assertEqual(got, [0, 0] + range(5))
+ self.assertEqual(got, [0, 0] + list(range(5)))
self.assertEqual(gc.get_referents(1, 'a', 4j), [])
@@ -495,23 +506,19 @@ class GCTests(unittest.TestCase):
self.assertFalse(gc.is_tracked(1.0 + 5.0j))
self.assertFalse(gc.is_tracked(True))
self.assertFalse(gc.is_tracked(False))
+ self.assertFalse(gc.is_tracked(b"a"))
self.assertFalse(gc.is_tracked("a"))
- self.assertFalse(gc.is_tracked(u"a"))
- self.assertFalse(gc.is_tracked(bytearray("a")))
+ self.assertFalse(gc.is_tracked(bytearray(b"a")))
self.assertFalse(gc.is_tracked(type))
self.assertFalse(gc.is_tracked(int))
self.assertFalse(gc.is_tracked(object))
self.assertFalse(gc.is_tracked(object()))
- class OldStyle:
- pass
- class NewStyle(object):
+ class UserClass:
pass
self.assertTrue(gc.is_tracked(gc))
- self.assertTrue(gc.is_tracked(OldStyle))
- self.assertTrue(gc.is_tracked(OldStyle()))
- self.assertTrue(gc.is_tracked(NewStyle))
- self.assertTrue(gc.is_tracked(NewStyle()))
+ self.assertTrue(gc.is_tracked(UserClass))
+ self.assertTrue(gc.is_tracked(UserClass()))
self.assertTrue(gc.is_tracked([]))
self.assertTrue(gc.is_tracked(set()))
@@ -539,6 +546,53 @@ class GCTests(unittest.TestCase):
# would be damaged, with an empty __dict__.
self.assertEqual(x, None)
+ def test_garbage_at_shutdown(self):
+ import subprocess
+ code = """if 1:
+ import gc
+ class X:
+ def __init__(self, name):
+ self.name = name
+ def __repr__(self):
+ return "<X %%r>" %% self.name
+ def __del__(self):
+ pass
+
+ x = X('first')
+ x.x = x
+ x.y = X('second')
+ del x
+ gc.set_debug(%s)
+ """
+ def run_command(code):
+ p = subprocess.Popen([sys.executable, "-Wd", "-c", code],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ p.stdout.close()
+ p.stderr.close()
+ self.assertEqual(p.returncode, 0)
+ self.assertEqual(stdout.strip(), b"")
+ return strip_python_stderr(stderr)
+
+ stderr = run_command(code % "0")
+ self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
+ b"shutdown; use", stderr)
+ self.assertNotIn(b"<X 'first'>", stderr)
+ # With DEBUG_UNCOLLECTABLE, the garbage list gets printed
+ stderr = run_command(code % "gc.DEBUG_UNCOLLECTABLE")
+ self.assertIn(b"ResourceWarning: gc: 2 uncollectable objects at "
+ b"shutdown", stderr)
+ self.assertTrue(
+ (b"[<X 'first'>, <X 'second'>]" in stderr) or
+ (b"[<X 'second'>, <X 'first'>]" in stderr), stderr)
+ # With DEBUG_SAVEALL, no additional message should get printed
+ # (because gc.garbage also contains normally reclaimable cyclic
+ # references, and its elements get printed at runtime anyway).
+ stderr = run_command(code % "gc.DEBUG_SAVEALL")
+ self.assertNotIn(b"uncollectable objects at shutdown", stderr)
+
+
class GCTogglingTests(unittest.TestCase):
def setUp(self):
gc.enable()
@@ -697,7 +751,7 @@ def test_main():
gc.set_debug(debug)
# test gc.enable() even if GC is disabled by default
if verbose:
- print "restoring automatic collection"
+ print("restoring automatic collection")
# make sure to always test gc.enable()
gc.enable()
assert gc.isenabled()
diff --git a/Lib/test/test_gdb.py b/Lib/test/test_gdb.py
index 9d8ff8ed8a1..6d96550a9bc 100644
--- a/Lib/test/test_gdb.py
+++ b/Lib/test/test_gdb.py
@@ -8,9 +8,9 @@ import re
import subprocess
import sys
import unittest
-import sysconfig
+import locale
-from test.test_support import run_unittest, findfile
+from test.support import run_unittest, findfile, python_is_optimized
try:
gdb_version, _ = subprocess.Popen(["gdb", "--version"],
@@ -19,12 +19,12 @@ except OSError:
# This is what "no gdb" looks like. There may, however, be other
# errors that manifest this way too.
raise unittest.SkipTest("Couldn't find gdb on the path")
-gdb_version_number = re.search("^GNU gdb [^\d]*(\d+)\.(\d)", gdb_version)
+gdb_version_number = re.search(b"^GNU gdb [^\d]*(\d+)\.(\d)", gdb_version)
gdb_major_version = int(gdb_version_number.group(1))
gdb_minor_version = int(gdb_version_number.group(2))
if gdb_major_version < 7:
raise unittest.SkipTest("gdb versions before 7.0 didn't support python embedding"
- " Saw:\n" + gdb_version)
+ " Saw:\n" + gdb_version.decode('ascii', 'replace'))
# Location of custom hooks file in a repository checkout.
checkout_hook_path = os.path.join(os.path.dirname(sys.executable),
@@ -33,7 +33,7 @@ checkout_hook_path = os.path.join(os.path.dirname(sys.executable),
def run_gdb(*args, **env_vars):
"""Runs gdb in --batch mode with the additional arguments given by *args.
- Returns its (stdout, stderr)
+ Returns its (stdout, stderr) decoded from utf-8 using the replace handler.
"""
if env_vars:
env = os.environ.copy()
@@ -46,7 +46,7 @@ def run_gdb(*args, **env_vars):
out, err = subprocess.Popen(base_cmd + args,
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,
).communicate()
- return out, err
+ return out.decode('utf-8', 'replace'), err.decode('utf-8', 'replace')
# Verify that "gdb" was built with the embedded python support enabled:
gdbpy_version, _ = run_gdb("--eval-command=python import sys; print sys.version_info")
@@ -60,14 +60,7 @@ cmd = ['--args', sys.executable]
_, gdbpy_errors = run_gdb('--args', sys.executable)
if "auto-loading has been declined" in gdbpy_errors:
msg = "gdb security settings prevent use of custom hooks: "
-
-def python_is_optimized():
- cflags = sysconfig.get_config_vars()['PY_CFLAGS']
- final_opt = ""
- for opt in cflags.split():
- if opt.startswith('-O'):
- final_opt = opt
- return (final_opt and final_opt != '-O0')
+ raise unittest.SkipTest(msg + gdbpy_errors.rstrip())
def gdb_has_frame_select():
# Does this build of gdb have gdb.Frame.select ?
@@ -80,12 +73,14 @@ def gdb_has_frame_select():
HAS_PYUP_PYDOWN = gdb_has_frame_select()
+BREAKPOINT_FN='builtin_id'
+
class DebuggerTests(unittest.TestCase):
"""Test that the debugger can debug Python."""
def get_stack_trace(self, source=None, script=None,
- breakpoint='PyObject_Print',
+ breakpoint=BREAKPOINT_FN,
cmds_after_breakpoint=None,
import_site=False):
'''
@@ -103,7 +98,7 @@ class DebuggerTests(unittest.TestCase):
# error, which typically happens python is dynamically linked (the
# breakpoints of interest are to be found in the shared library)
# When this happens, we still get:
- # Function "PyObject_Print" not defined.
+ # Function "textiowrapper_write" not defined.
# emitted to stderr each time, alas.
# Initially I had "--eval-command=continue" here, but removed it to
@@ -172,19 +167,21 @@ class DebuggerTests(unittest.TestCase):
cmds_after_breakpoint=None,
import_site=False):
# Given an input python source representation of data,
- # run "python -c'print DATA'" under gdb with a breakpoint on
- # PyObject_Print and scrape out gdb's representation of the "op"
+ # run "python -c'id(DATA)'" under gdb with a breakpoint on
+ # builtin_id and scrape out gdb's representation of the "op"
# parameter, and verify that the gdb displays the same string
#
+ # Verify that the gdb displays the expected string
+ #
# For a nested structure, the first time we hit the breakpoint will
# give us the top-level structure
- gdb_output = self.get_stack_trace(source, breakpoint='PyObject_Print',
+ gdb_output = self.get_stack_trace(source, breakpoint=BREAKPOINT_FN,
cmds_after_breakpoint=cmds_after_breakpoint,
import_site=import_site)
# gdb can insert additional '\n' and space characters in various places
# in its output, depending on the width of the terminal it's connected
# to (using its "wrap_here" function)
- m = re.match('.*#0\s+PyObject_Print\s+\(\s*op\=\s*(.*?),\s+fp=.*\).*',
+ m = re.match('.*#0\s+builtin_id\s+\(self\=.*,\s+v=\s*(.*?)\)\s+at\s+Python/bltinmodule.c.*',
gdb_output, re.DOTALL)
if not m:
self.fail('Unexpected gdb output: %r\n%s' % (gdb_output, gdb_output))
@@ -197,37 +194,35 @@ class DebuggerTests(unittest.TestCase):
def assertMultilineMatches(self, actual, pattern):
m = re.match(pattern, actual, re.DOTALL)
- self.assertTrue(m, msg='%r did not match %r' % (actual, pattern))
+ if not m:
+ self.fail(msg='%r did not match %r' % (actual, pattern))
def get_sample_script(self):
return findfile('gdb_sample.py')
class PrettyPrintTests(DebuggerTests):
def test_getting_backtrace(self):
- gdb_output = self.get_stack_trace('print 42')
- self.assertTrue('PyObject_Print' in gdb_output)
+ gdb_output = self.get_stack_trace('id(42)')
+ self.assertTrue(BREAKPOINT_FN in gdb_output)
- def assertGdbRepr(self, val, cmds_after_breakpoint=None):
+ def assertGdbRepr(self, val, exp_repr=None, cmds_after_breakpoint=None):
# Ensure that gdb's rendering of the value in a debugged process
# matches repr(value) in this process:
- gdb_repr, gdb_output = self.get_gdb_repr('print ' + repr(val),
+ gdb_repr, gdb_output = self.get_gdb_repr('id(' + ascii(val) + ')',
cmds_after_breakpoint)
- self.assertEqual(gdb_repr, repr(val), gdb_output)
+ if not exp_repr:
+ exp_repr = repr(val)
+ self.assertEqual(gdb_repr, exp_repr,
+ ('%r did not equal expected %r; full output was:\n%s'
+ % (gdb_repr, exp_repr, gdb_output)))
def test_int(self):
- 'Verify the pretty-printing of various "int" values'
+ 'Verify the pretty-printing of various "int"/long values'
self.assertGdbRepr(42)
self.assertGdbRepr(0)
self.assertGdbRepr(-7)
- self.assertGdbRepr(sys.maxint)
- self.assertGdbRepr(-sys.maxint)
-
- def test_long(self):
- 'Verify the pretty-printing of various "long" values'
- self.assertGdbRepr(0L)
- self.assertGdbRepr(1000000000000L)
- self.assertGdbRepr(-1L)
- self.assertGdbRepr(-1000000000000000L)
+ self.assertGdbRepr(1000000000000)
+ self.assertGdbRepr(-1000000000000000)
def test_singletons(self):
'Verify the pretty-printing of True, False and None'
@@ -239,123 +234,115 @@ class PrettyPrintTests(DebuggerTests):
'Verify the pretty-printing of dictionaries'
self.assertGdbRepr({})
self.assertGdbRepr({'foo': 'bar'})
- self.assertGdbRepr("{'foo': 'bar', 'douglas':42}")
+ self.assertGdbRepr({'foo': 'bar', 'douglas': 42},
+ "{'foo': 'bar', 'douglas': 42}")
def test_lists(self):
'Verify the pretty-printing of lists'
self.assertGdbRepr([])
- self.assertGdbRepr(range(5))
+ self.assertGdbRepr(list(range(5)))
+
+ def test_bytes(self):
+ 'Verify the pretty-printing of bytes'
+ self.assertGdbRepr(b'')
+ self.assertGdbRepr(b'And now for something hopefully the same')
+ self.assertGdbRepr(b'string with embedded NUL here \0 and then some more text')
+ self.assertGdbRepr(b'this is a tab:\t'
+ b' this is a slash-N:\n'
+ b' this is a slash-R:\r'
+ )
+
+ self.assertGdbRepr(b'this is byte 255:\xff and byte 128:\x80')
+
+ self.assertGdbRepr(bytes([b for b in range(255)]))
def test_strings(self):
- 'Verify the pretty-printing of strings'
+ 'Verify the pretty-printing of unicode strings'
+ encoding = locale.getpreferredencoding()
+ def check_repr(text):
+ try:
+ text.encode(encoding)
+ printable = True
+ except UnicodeEncodeError:
+ self.assertGdbRepr(text, ascii(text))
+ else:
+ self.assertGdbRepr(text)
+
self.assertGdbRepr('')
self.assertGdbRepr('And now for something hopefully the same')
self.assertGdbRepr('string with embedded NUL here \0 and then some more text')
- self.assertGdbRepr('this is byte 255:\xff and byte 128:\x80')
-
- def test_tuples(self):
- 'Verify the pretty-printing of tuples'
- self.assertGdbRepr(tuple())
- self.assertGdbRepr((1,))
- self.assertGdbRepr(('foo', 'bar', 'baz'))
-
- def test_unicode(self):
- 'Verify the pretty-printing of unicode values'
- # Test the empty unicode string:
- self.assertGdbRepr(u'')
-
- self.assertGdbRepr(u'hello world')
# Test printing a single character:
# U+2620 SKULL AND CROSSBONES
- self.assertGdbRepr(u'\u2620')
+ check_repr('\u2620')
# Test printing a Japanese unicode string
# (I believe this reads "mojibake", using 3 characters from the CJK
# Unified Ideographs area, followed by U+3051 HIRAGANA LETTER KE)
- self.assertGdbRepr(u'\u6587\u5b57\u5316\u3051')
+ check_repr('\u6587\u5b57\u5316\u3051')
# Test a character outside the BMP:
# U+1D121 MUSICAL SYMBOL C CLEF
# This is:
# UTF-8: 0xF0 0x9D 0x84 0xA1
# UTF-16: 0xD834 0xDD21
- # This will only work on wide-unicode builds:
- self.assertGdbRepr(u"\U0001D121")
+ check_repr(chr(0x1D121))
+
+ def test_tuples(self):
+ 'Verify the pretty-printing of tuples'
+ self.assertGdbRepr(tuple())
+ self.assertGdbRepr((1,), '(1,)')
+ self.assertGdbRepr(('foo', 'bar', 'baz'))
def test_sets(self):
'Verify the pretty-printing of sets'
self.assertGdbRepr(set())
- rep = self.get_gdb_repr("print set(['a', 'b'])")[0]
- self.assertTrue(rep.startswith("set(["))
- self.assertTrue(rep.endswith("])"))
- self.assertEqual(eval(rep), {'a', 'b'})
- rep = self.get_gdb_repr("print set([4, 5])")[0]
- self.assertTrue(rep.startswith("set(["))
- self.assertTrue(rep.endswith("])"))
- self.assertEqual(eval(rep), {4, 5})
-
- # Ensure that we handled sets containing the "dummy" key value,
+ self.assertGdbRepr(set(['a', 'b']), "{'a', 'b'}")
+ self.assertGdbRepr(set([4, 5, 6]), "{4, 5, 6}")
+
+ # Ensure that we handle sets containing the "dummy" key value,
# which happens on deletion:
gdb_repr, gdb_output = self.get_gdb_repr('''s = set(['a','b'])
s.pop()
-print s''')
- self.assertEqual(gdb_repr, "set(['b'])")
+id(s)''')
+ self.assertEqual(gdb_repr, "{'b'}")
def test_frozensets(self):
'Verify the pretty-printing of frozensets'
self.assertGdbRepr(frozenset())
- rep = self.get_gdb_repr("print frozenset(['a', 'b'])")[0]
- self.assertTrue(rep.startswith("frozenset(["))
- self.assertTrue(rep.endswith("])"))
- self.assertEqual(eval(rep), {'a', 'b'})
- rep = self.get_gdb_repr("print frozenset([4, 5])")[0]
- self.assertTrue(rep.startswith("frozenset(["))
- self.assertTrue(rep.endswith("])"))
- self.assertEqual(eval(rep), {4, 5})
+ self.assertGdbRepr(frozenset(['a', 'b']), "frozenset({'a', 'b'})")
+ self.assertGdbRepr(frozenset([4, 5, 6]), "frozenset({4, 5, 6})")
def test_exceptions(self):
# Test a RuntimeError
gdb_repr, gdb_output = self.get_gdb_repr('''
try:
raise RuntimeError("I am an error")
-except RuntimeError, e:
- print e
+except RuntimeError as e:
+ id(e)
''')
self.assertEqual(gdb_repr,
- "exceptions.RuntimeError('I am an error',)")
+ "RuntimeError('I am an error',)")
# Test division by zero:
gdb_repr, gdb_output = self.get_gdb_repr('''
try:
a = 1 / 0
-except ZeroDivisionError, e:
- print e
+except ZeroDivisionError as e:
+ id(e)
''')
self.assertEqual(gdb_repr,
- "exceptions.ZeroDivisionError('integer division or modulo by zero',)")
-
- def test_classic_class(self):
- 'Verify the pretty-printing of classic class instances'
- gdb_repr, gdb_output = self.get_gdb_repr('''
-class Foo:
- pass
-foo = Foo()
-foo.an_int = 42
-print foo''')
- m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
- self.assertTrue(m,
- msg='Unexpected classic-class rendering %r' % gdb_repr)
+ "ZeroDivisionError('division by zero',)")
def test_modern_class(self):
'Verify the pretty-printing of new-style class instances'
gdb_repr, gdb_output = self.get_gdb_repr('''
-class Foo(object):
+class Foo:
pass
foo = Foo()
foo.an_int = 42
-print foo''')
+id(foo)''')
m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
self.assertTrue(m,
msg='Unexpected new-style class rendering %r' % gdb_repr)
@@ -368,8 +355,9 @@ class Foo(list):
foo = Foo()
foo += [1, 2, 3]
foo.an_int = 42
-print foo''')
+id(foo)''')
m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+
self.assertTrue(m,
msg='Unexpected new-style class rendering %r' % gdb_repr)
@@ -382,12 +370,13 @@ class Foo(tuple):
pass
foo = Foo((1, 2, 3))
foo.an_int = 42
-print foo''')
+id(foo)''')
m = re.match(r'<Foo\(an_int=42\) at remote 0x[0-9a-f]+>', gdb_repr)
+
self.assertTrue(m,
msg='Unexpected new-style class rendering %r' % gdb_repr)
- def assertSane(self, source, corruption, expvalue=None, exptype=None):
+ def assertSane(self, source, corruption, exprepr=None):
'''Run Python under gdb, corrupting variables in the inferior process
immediately before taking a backtrace.
@@ -401,19 +390,15 @@ print foo''')
gdb_repr, gdb_output = \
self.get_gdb_repr(source,
cmds_after_breakpoint=cmds_after_breakpoint)
-
- if expvalue:
- if gdb_repr == repr(expvalue):
+ if exprepr:
+ if gdb_repr == exprepr:
# gdb managed to print the value in spite of the corruption;
# this is good (see http://bugs.python.org/issue8330)
return
- if exptype:
- pattern = '<' + exptype + ' at remote 0x[0-9a-f]+>'
- else:
- # Match anything for the type name; 0xDEADBEEF could point to
- # something arbitrary (see http://bugs.python.org/issue8330)
- pattern = '<.* at remote 0x[0-9a-f]+>'
+ # Match anything for the type name; 0xDEADBEEF could point to
+ # something arbitrary (see http://bugs.python.org/issue8330)
+ pattern = '<.* at remote 0x[0-9a-f]+>'
m = re.match(pattern, gdb_repr)
if not m:
@@ -423,8 +408,8 @@ print foo''')
def test_NULL_ptr(self):
'Ensure that a NULL PyObject* is handled gracefully'
gdb_repr, gdb_output = (
- self.get_gdb_repr('print 42',
- cmds_after_breakpoint=['set variable op=0',
+ self.get_gdb_repr('id(42)',
+ cmds_after_breakpoint=['set variable v=0',
'backtrace'])
)
@@ -432,44 +417,33 @@ print foo''')
def test_NULL_ob_type(self):
'Ensure that a PyObject* with NULL ob_type is handled gracefully'
- self.assertSane('print 42',
- 'set op->ob_type=0')
+ self.assertSane('id(42)',
+ 'set v->ob_type=0')
def test_corrupt_ob_type(self):
'Ensure that a PyObject* with a corrupt ob_type is handled gracefully'
- self.assertSane('print 42',
- 'set op->ob_type=0xDEADBEEF',
- expvalue=42)
+ self.assertSane('id(42)',
+ 'set v->ob_type=0xDEADBEEF',
+ exprepr='42')
def test_corrupt_tp_flags(self):
'Ensure that a PyObject* with a type with corrupt tp_flags is handled'
- self.assertSane('print 42',
- 'set op->ob_type->tp_flags=0x0',
- expvalue=42)
+ self.assertSane('id(42)',
+ 'set v->ob_type->tp_flags=0x0',
+ exprepr='42')
def test_corrupt_tp_name(self):
'Ensure that a PyObject* with a type with corrupt tp_name is handled'
- self.assertSane('print 42',
- 'set op->ob_type->tp_name=0xDEADBEEF',
- expvalue=42)
-
- def test_NULL_instance_dict(self):
- 'Ensure that a PyInstanceObject with with a NULL in_dict is handled'
- self.assertSane('''
-class Foo:
- pass
-foo = Foo()
-foo.an_int = 42
-print foo''',
- 'set ((PyInstanceObject*)op)->in_dict = 0',
- exptype='Foo')
+ self.assertSane('id(42)',
+ 'set v->ob_type->tp_name=0xDEADBEEF',
+ exprepr='42')
def test_builtins_help(self):
'Ensure that the new-style class _Helper in site.py can be handled'
# (this was the issue causing tracebacks in
# http://bugs.python.org/issue8032#msg100537 )
+ gdb_repr, gdb_output = self.get_gdb_repr('id(__builtins__.help)', import_site=True)
- gdb_repr, gdb_output = self.get_gdb_repr('print __builtins__.help', import_site=True)
m = re.match(r'<_Helper at remote 0x[0-9a-f]+>', gdb_repr)
self.assertTrue(m,
msg='Unexpected rendering %r' % gdb_repr)
@@ -478,20 +452,18 @@ print foo''',
'''Ensure that a reference loop involving a list doesn't lead proxyval
into an infinite loop:'''
gdb_repr, gdb_output = \
- self.get_gdb_repr("a = [3, 4, 5] ; a.append(a) ; print a")
-
+ self.get_gdb_repr("a = [3, 4, 5] ; a.append(a) ; id(a)")
self.assertEqual(gdb_repr, '[3, 4, 5, [...]]')
gdb_repr, gdb_output = \
- self.get_gdb_repr("a = [3, 4, 5] ; b = [a] ; a.append(b) ; print a")
-
+ self.get_gdb_repr("a = [3, 4, 5] ; b = [a] ; a.append(b) ; id(a)")
self.assertEqual(gdb_repr, '[3, 4, 5, [[...]]]')
def test_selfreferential_dict(self):
'''Ensure that a reference loop involving a dict doesn't lead proxyval
into an infinite loop:'''
gdb_repr, gdb_output = \
- self.get_gdb_repr("a = {} ; b = {'bar':a} ; a['foo'] = b ; print a")
+ self.get_gdb_repr("a = {} ; b = {'bar':a} ; a['foo'] = b ; id(a)")
self.assertEqual(gdb_repr, "{'foo': {'bar': {...}}}")
@@ -502,7 +474,7 @@ class Foo:
pass
foo = Foo()
foo.an_attr = foo
-print foo''')
+id(foo)''')
self.assertTrue(re.match('<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>',
gdb_repr),
'Unexpected gdb representation: %r\n%s' % \
@@ -515,7 +487,7 @@ class Foo(object):
pass
foo = Foo()
foo.an_attr = foo
-print foo''')
+id(foo)''')
self.assertTrue(re.match('<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>',
gdb_repr),
'Unexpected gdb representation: %r\n%s' % \
@@ -529,7 +501,7 @@ a = Foo()
b = Foo()
a.an_attr = b
b.an_attr = a
-print a''')
+id(a)''')
self.assertTrue(re.match('<Foo\(an_attr=<Foo\(an_attr=<\.\.\.>\) at remote 0x[0-9a-f]+>\) at remote 0x[0-9a-f]+>',
gdb_repr),
'Unexpected gdb representation: %r\n%s' % \
@@ -537,7 +509,7 @@ print a''')
def test_truncation(self):
'Verify that very long output is truncated'
- gdb_repr, gdb_output = self.get_gdb_repr('print range(1000)')
+ gdb_repr, gdb_output = self.get_gdb_repr('id(list(range(1000)))')
self.assertEqual(gdb_repr,
"[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, "
"14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, "
@@ -563,13 +535,9 @@ print a''')
self.assertEqual(len(gdb_repr),
1024 + len('...(truncated)'))
- def test_builtin_function(self):
- gdb_repr, gdb_output = self.get_gdb_repr('print len')
- self.assertEqual(gdb_repr, '<built-in function len>')
-
def test_builtin_method(self):
- gdb_repr, gdb_output = self.get_gdb_repr('import sys; print sys.stdout.readlines')
- self.assertTrue(re.match('<built-in method readlines of file object at remote 0x[0-9a-f]+>',
+ gdb_repr, gdb_output = self.get_gdb_repr('import sys; id(sys.stdout.readlines)')
+ self.assertTrue(re.match('<built-in method readlines of _io.TextIOWrapper object at remote 0x[0-9a-f]+>',
gdb_repr),
'Unexpected gdb representation: %r\n%s' % \
(gdb_repr, gdb_output))
@@ -580,11 +548,11 @@ def foo(a, b, c):
pass
foo(3, 4, 5)
-print foo.__code__''',
- breakpoint='PyObject_Print',
- cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)op)->co_zombieframe)']
+id(foo.__code__)''',
+ breakpoint='builtin_id',
+ cmds_after_breakpoint=['print (PyFrameObject*)(((PyCodeObject*)v)->co_zombieframe)']
)
- self.assertTrue(re.match(r'.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*',
+ self.assertTrue(re.match('.*\s+\$1 =\s+Frame 0x[0-9a-f]+, for file <string>, line 3, in foo \(\)\s+.*',
gdb_output,
re.DOTALL),
'Unexpected gdb representation: %r\n%s' % (gdb_output, gdb_output))
@@ -605,7 +573,7 @@ class PyListTests(DebuggerTests):
' 7 baz(a, b, c)\n'
' 8 \n'
' 9 def baz(*args):\n'
- ' >10 print(42)\n'
+ ' >10 id(42)\n'
' 11 \n'
' 12 foo(1, 2, 3)\n',
bt)
@@ -616,7 +584,7 @@ class PyListTests(DebuggerTests):
cmds_after_breakpoint=['py-list 9'])
self.assertListing(' 9 def baz(*args):\n'
- ' >10 print(42)\n'
+ ' >10 id(42)\n'
' 11 \n'
' 12 foo(1, 2, 3)\n',
bt)
@@ -673,18 +641,37 @@ $''')
#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 10, in baz \(args=\(1, 2, 3\)\)
- print\(42\)
+ id\(42\)
$''')
class PyBtTests(DebuggerTests):
@unittest.skipIf(python_is_optimized(),
"Python was compiled with optimizations")
- def test_basic_command(self):
+ def test_bt(self):
'Verify that the "py-bt" command works'
bt = self.get_stack_trace(script=self.get_sample_script(),
cmds_after_breakpoint=['py-bt'])
self.assertMultilineMatches(bt,
r'''^.*
+Traceback \(most recent call first\):
+ File ".*gdb_sample.py", line 10, in baz
+ id\(42\)
+ File ".*gdb_sample.py", line 7, in bar
+ baz\(a, b, c\)
+ File ".*gdb_sample.py", line 4, in foo
+ bar\(a, b, c\)
+ File ".*gdb_sample.py", line 12, in <module>
+ foo\(1, 2, 3\)
+''')
+
+ @unittest.skipIf(python_is_optimized(),
+ "Python was compiled with optimizations")
+ def test_bt_full(self):
+ 'Verify that the "py-bt-full" command works'
+ bt = self.get_stack_trace(script=self.get_sample_script(),
+ cmds_after_breakpoint=['py-bt-full'])
+ self.assertMultilineMatches(bt,
+ r'''^.*
#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 7, in bar \(a=1, b=2, c=3\)
baz\(a, b, c\)
#[0-9]+ Frame 0x[0-9a-f]+, for file .*gdb_sample.py, line 4, in foo \(a=1, b=2, c=3\)
@@ -703,9 +690,9 @@ class PyPrintTests(DebuggerTests):
self.assertMultilineMatches(bt,
r".*\nlocal 'args' = \(1, 2, 3\)\n.*")
- @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
@unittest.skipIf(python_is_optimized(),
"Python was compiled with optimizations")
+ @unittest.skipUnless(HAS_PYUP_PYDOWN, "test requires py-up/py-down commands")
def test_print_after_up(self):
bt = self.get_stack_trace(script=self.get_sample_script(),
cmds_after_breakpoint=['py-up', 'py-print c', 'py-print b', 'py-print a'])
@@ -726,7 +713,7 @@ class PyPrintTests(DebuggerTests):
bt = self.get_stack_trace(script=self.get_sample_script(),
cmds_after_breakpoint=['py-print len'])
self.assertMultilineMatches(bt,
- r".*\nbuiltin 'len' = <built-in function len>\n.*")
+ r".*\nbuiltin 'len' = <built-in method len of module object at remote 0x[0-9a-f]+>\n.*")
class PyLocalsTests(DebuggerTests):
@unittest.skipIf(python_is_optimized(),
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 19bfe074c4e..5f47b3eae03 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -6,18 +6,18 @@ Let's try a simple generator:
... yield 2
>>> for i in f():
- ... print i
+ ... print(i)
1
2
>>> g = f()
- >>> g.next()
+ >>> next(g)
1
- >>> g.next()
+ >>> next(g)
2
"Falling off the end" stops the generator:
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in g
@@ -31,14 +31,14 @@ Let's try a simple generator:
... yield 2 # never reached
...
>>> g = f()
- >>> g.next()
+ >>> next(g)
1
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 3, in f
StopIteration
- >>> g.next() # once stopped, can't be resumed
+ >>> next(g) # once stopped, can't be resumed
Traceback (most recent call last):
File "<stdin>", line 1, in ?
StopIteration
@@ -51,13 +51,13 @@ Let's try a simple generator:
... yield 2 # never reached
...
>>> g = f()
- >>> g.next()
+ >>> next(g)
1
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
StopIteration
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
StopIteration
@@ -78,7 +78,7 @@ However, they are not exactly equivalent:
... raise StopIteration
... except:
... yield 42
- >>> print list(g2())
+ >>> print(list(g2()))
[42]
This may be surprising at first:
@@ -105,13 +105,13 @@ Generators always return to the most recent caller:
>>> def creator():
... r = yrange(5)
- ... print "creator", r.next()
+ ... print("creator", next(r))
... return r
...
>>> def caller():
... r = creator()
... for i in r:
- ... print "caller", i
+ ... print("caller", i)
...
>>> caller()
creator 0
@@ -141,10 +141,10 @@ Specification: Yield
running:
>>> def g():
- ... i = me.next()
+ ... i = next(me)
... yield i
>>> me = g()
- >>> me.next()
+ >>> next(me)
Traceback (most recent call last):
...
File "<string>", line 2, in g
@@ -161,7 +161,7 @@ Specification: Return
... return
... except:
... yield 1
- >>> print list(f1())
+ >>> print(list(f1()))
[]
because, as in any function, return simply exits, but
@@ -171,7 +171,7 @@ Specification: Return
... raise StopIteration
... except:
... yield 42
- >>> print list(f2())
+ >>> print(list(f2()))
[42]
because StopIteration is captured by a bare "except", as is any
@@ -185,13 +185,13 @@ Specification: Generators and Exception Propagation
... yield f() # the zero division exception propagates
... yield 42 # and we'll never get here
>>> k = g()
- >>> k.next()
+ >>> next(k)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in g
File "<stdin>", line 2, in f
ZeroDivisionError: integer division or modulo by zero
- >>> k.next() # and the generator cannot be resumed
+ >>> next(k) # and the generator cannot be resumed
Traceback (most recent call last):
File "<stdin>", line 1, in ?
StopIteration
@@ -221,7 +221,7 @@ Specification: Try/Except/Finally
... finally:
... yield 10
... yield 11
- >>> print list(f())
+ >>> print(list(f()))
[1, 2, 4, 5, 8, 9, 10, 11]
>>>
@@ -270,8 +270,8 @@ Guido's binary tree example.
>>> t = tree("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
>>> # Print the nodes of the tree in in-order.
>>> for x in t:
- ... print x,
- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+ ... print(' '+x, end='')
+ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
>>> # A non-recursive generator.
>>> def inorder(node):
@@ -291,8 +291,8 @@ Guido's binary tree example.
>>> # Exercise the non-recursive generator.
>>> for x in t:
- ... print x,
- A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
+ ... print(' '+x, end='')
+ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
"""
@@ -343,11 +343,11 @@ Next one was posted to c.l.py.
... for c in gcomb(rest, k):
... yield c
->>> seq = range(1, 5)
+>>> seq = list(range(1, 5))
>>> for k in range(len(seq) + 2):
-... print "%d-combs of %s:" % (k, seq)
+... print("%d-combs of %s:" % (k, seq))
... for c in gcomb(seq, k):
-... print " ", c
+... print(" ", c)
0-combs of [1, 2, 3, 4]:
[]
1-combs of [1, 2, 3, 4]:
@@ -377,14 +377,14 @@ From the Iterators list, about the types of these things.
... yield 1
...
>>> type(g)
-<type 'function'>
+<class 'function'>
>>> i = g()
>>> type(i)
-<type 'generator'>
+<class 'generator'>
>>> [s for s in dir(i) if not s.startswith('_')]
-['close', 'gi_code', 'gi_frame', 'gi_running', 'next', 'send', 'throw']
->>> print i.next.__doc__
-x.next() -> the next value, or raise StopIteration
+['close', 'gi_code', 'gi_frame', 'gi_running', 'send', 'throw']
+>>> print(i.__next__.__doc__)
+x.__next__() <==> next(x)
>>> iter(i) is i
True
>>> import types
@@ -396,17 +396,17 @@ And more, added later.
>>> i.gi_running
0
>>> type(i.gi_frame)
-<type 'frame'>
+<class 'frame'>
>>> i.gi_running = 42
Traceback (most recent call last):
...
-TypeError: readonly attribute
+AttributeError: readonly attribute
>>> def g():
... yield me.gi_running
>>> me = g()
>>> me.gi_running
0
->>> me.next()
+>>> next(me)
1
>>> me.gi_running
0
@@ -429,7 +429,7 @@ Subject: Re: PEP 255: Simple Generators
... yield x
...
... def find(self):
-... return self.generator.next()
+... return next(self.generator)
...
... def union(self, parent):
... if self.parent:
@@ -444,44 +444,44 @@ Subject: Re: PEP 255: Simple Generators
>>> roots = sets[:]
>>> import random
->>> gen = random.WichmannHill(42)
+>>> gen = random.Random(42)
>>> while 1:
... for s in sets:
-... print "%s->%s" % (s, s.find()),
-... print
+... print(" %s->%s" % (s, s.find()), end='')
+... print()
... if len(roots) > 1:
... s1 = gen.choice(roots)
... roots.remove(s1)
... s2 = gen.choice(roots)
... s1.union(s2)
-... print "merged", s1, "into", s2
+... print("merged", s1, "into", s2)
... else:
... break
-A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged D into G
-A->A B->B C->C D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged C into F
-A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->L M->M
-merged L into A
-A->A B->B C->F D->G E->E F->F G->G H->H I->I J->J K->K L->A M->M
-merged H into E
-A->A B->B C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
-merged B into E
-A->A B->E C->F D->G E->E F->F G->G H->E I->I J->J K->K L->A M->M
-merged J into G
-A->A B->E C->F D->G E->E F->F G->G H->E I->I J->G K->K L->A M->M
-merged E into G
-A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->M
-merged M into G
-A->A B->G C->F D->G E->G F->F G->G H->G I->I J->G K->K L->A M->G
-merged I into K
-A->A B->G C->F D->G E->G F->F G->G H->G I->K J->G K->K L->A M->G
-merged K into A
-A->A B->G C->F D->G E->G F->F G->G H->G I->A J->G K->A L->A M->G
-merged F into A
-A->A B->G C->A D->G E->G F->A G->G H->G I->A J->G K->A L->A M->G
-merged A into G
-A->G B->G C->G D->G E->G F->G G->G H->G I->G J->G K->G L->G M->G
+ A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->K L->L M->M
+merged K into B
+ A->A B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M
+merged A into F
+ A->F B->B C->C D->D E->E F->F G->G H->H I->I J->J K->B L->L M->M
+merged E into F
+ A->F B->B C->C D->D E->F F->F G->G H->H I->I J->J K->B L->L M->M
+merged D into C
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->M
+merged M into C
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->J K->B L->L M->C
+merged J into B
+ A->F B->B C->C D->C E->F F->F G->G H->H I->I J->B K->B L->L M->C
+merged B into C
+ A->F B->C C->C D->C E->F F->F G->G H->H I->I J->C K->C L->L M->C
+merged F into G
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->L M->C
+merged L into C
+ A->G B->C C->C D->C E->G F->G G->G H->H I->I J->C K->C L->C M->C
+merged G into I
+ A->I B->C C->C D->C E->I F->I G->I H->H I->I J->C K->C L->C M->C
+merged I into H
+ A->H B->C C->C D->C E->H F->H G->H H->H I->H J->C K->C L->C M->C
+merged C into H
+ A->H B->H C->H D->H E->H F->H G->H H->H I->H J->H K->H L->H M->H
"""
# Emacs turd '
@@ -493,7 +493,7 @@ fun_tests = """
Build up to a recursive Sieve of Eratosthenes generator.
>>> def firstn(g, n):
-... return [g.next() for i in range(n)]
+... return [next(g) for i in range(n)]
>>> def intsfrom(i):
... while 1:
@@ -512,7 +512,7 @@ Build up to a recursive Sieve of Eratosthenes generator.
[1, 2, 4, 5, 7, 8]
>>> def sieve(ints):
-... prime = ints.next()
+... prime = next(ints)
... yield prime
... not_divisible_by_prime = exclude_multiples(prime, ints)
... for p in sieve(not_divisible_by_prime):
@@ -536,19 +536,19 @@ Try writing it without generators, and correctly, and without generating
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
>>> def merge(g, h):
-... ng = g.next()
-... nh = h.next()
+... ng = next(g)
+... nh = next(h)
... while 1:
... if ng < nh:
... yield ng
-... ng = g.next()
+... ng = next(g)
... elif ng > nh:
... yield nh
-... nh = h.next()
+... nh = next(h)
... else:
... yield ng
-... ng = g.next()
-... nh = h.next()
+... ng = next(g)
+... nh = next(h)
The following works, but is doing a whale of a lot of redundant work --
it's not clear how to get the internal uses of m235 to share a single
@@ -576,7 +576,7 @@ address space, and it *looked* like a very slow leak.
>>> result = m235()
>>> for i in range(3):
-... print firstn(result, 15)
+... print(firstn(result, 15))
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -589,7 +589,7 @@ arguments are iterable -- a LazyList is the same as a generator to times().
>>> class LazyList:
... def __init__(self, g):
... self.sofar = []
-... self.fetch = g.next
+... self.fetch = g.__next__
...
... def __getitem__(self, i):
... sofar, fetch = self.sofar, self.fetch
@@ -613,7 +613,7 @@ efficient.
>>> m235 = LazyList(m235())
>>> for i in range(5):
-... print [m235[j] for j in range(15*i, 15*(i+1))]
+... print([m235[j] for j in range(15*i, 15*(i+1))])
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -626,10 +626,10 @@ Ye olde Fibonacci generator, LazyList style.
...
... def sum(g, h):
... while 1:
-... yield g.next() + h.next()
+... yield next(g) + next(h)
...
... def tail(g):
-... g.next() # throw first away
+... next(g) # throw first away
... for x in g:
... yield x
...
@@ -684,7 +684,7 @@ m235 to share a single generator".
>>> it = m235()
>>> for i in range(5):
-... print firstn(it, 15)
+... print(firstn(it, 15))
[1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24]
[25, 27, 30, 32, 36, 40, 45, 48, 50, 54, 60, 64, 72, 75, 80]
[81, 90, 96, 100, 108, 120, 125, 128, 135, 144, 150, 160, 162, 180, 192]
@@ -705,12 +705,12 @@ Ye olde Fibonacci generator, tee style.
...
... def _isum(g, h):
... while 1:
-... yield g.next() + h.next()
+... yield next(g) + next(h)
...
... def _fib():
... yield 1
... yield 2
-... fibTail.next() # throw first away
+... next(fibTail) # throw first away
... for res in _isum(fibHead, fibTail):
... yield res
...
@@ -733,14 +733,14 @@ syntax_tests = """
... yield 1
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[0]>, line 3)
+SyntaxError: 'return' with argument inside generator
>>> def f():
... yield 1
... return 22
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[1]>, line 3)
+SyntaxError: 'return' with argument inside generator
"return None" is not the same as "return" in a generator:
@@ -749,7 +749,7 @@ SyntaxError: 'return' with argument inside generator (<doctest test.test_generat
... return None
Traceback (most recent call last):
..
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[2]>, line 3)
+SyntaxError: 'return' with argument inside generator
These are fine:
@@ -794,27 +794,27 @@ These are fine:
>>> def f():
... yield
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
... if 0:
... yield
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
... if 0:
... yield 1
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
... if "":
... yield None
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
... return
@@ -838,7 +838,7 @@ These are fine:
... x = 1
... return
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
... if 0:
@@ -846,7 +846,7 @@ These are fine:
... yield 1
...
>>> type(f())
-<type 'NoneType'>
+<class 'NoneType'>
>>> def f():
... if 0:
@@ -856,7 +856,7 @@ These are fine:
... def f(self):
... yield 2
>>> type(f())
-<type 'NoneType'>
+<class 'NoneType'>
>>> def f():
... if 0:
@@ -864,7 +864,7 @@ These are fine:
... if 0:
... yield 2
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f():
@@ -878,7 +878,7 @@ These are fine:
... if 0:
... yield 2 # because it's a generator (line 10)
Traceback (most recent call last):
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.syntax[24]>, line 10)
+SyntaxError: 'return' with argument inside generator
This one caused a crash (see SF bug 567538):
@@ -890,13 +890,13 @@ This one caused a crash (see SF bug 567538):
... yield i
...
>>> g = f()
->>> print g.next()
+>>> print(next(g))
0
->>> print g.next()
+>>> print(next(g))
1
->>> print g.next()
+>>> print(next(g))
2
->>> print g.next()
+>>> print(next(g))
Traceback (most recent call last):
StopIteration
@@ -907,14 +907,14 @@ Test the gi_code attribute
... yield 5
...
>>> g = f()
->>> g.gi_code is f.func_code
+>>> g.gi_code is f.__code__
True
->>> g.next()
+>>> next(g)
5
->>> g.next()
+>>> next(g)
Traceback (most recent call last):
StopIteration
->>> g.gi_code is f.func_code
+>>> g.gi_code is f.__code__
True
@@ -1052,7 +1052,7 @@ def flat_conjoin(gs): # rename to conjoin to run tests with this instead
# Descend.
try:
while i < n:
- it = iters[i] = gs[i]().next
+ it = iters[i] = gs[i]().__next__
values[i] = it()
i += 1
except _StopIteration:
@@ -1096,9 +1096,9 @@ class Queens:
# generates the possiblities for the columns in that row.
self.rowgenerators = []
for i in rangen:
- rowuses = [(1L << j) | # column ordinal
- (1L << (n + i-j + n-1)) | # NW-SE ordinal
- (1L << (n + 2*n-1 + i+j)) # NE-SW ordinal
+ rowuses = [(1 << j) | # column ordinal
+ (1 << (n + i-j + n-1)) | # NW-SE ordinal
+ (1 << (n + 2*n-1 + i+j)) # NE-SW ordinal
for j in rangen]
def rowgen(rowuses=rowuses):
@@ -1121,12 +1121,12 @@ class Queens:
n = self.n
assert n == len(row2col)
sep = "+" + "-+" * n
- print sep
+ print(sep)
for i in range(n):
squares = [" " for j in range(n)]
squares[row2col[i]] = "Q"
- print "|" + "|".join(squares) + "|"
- print sep
+ print("|" + "|".join(squares) + "|")
+ print(sep)
# A conjoin-based Knight's Tour solver. This is pretty sophisticated
# (e.g., when used with flat_conjoin above, and passing hard=1 to the
@@ -1318,11 +1318,11 @@ class Knights:
k += 1
sep = "+" + ("-" * w + "+") * n
- print sep
+ print(sep)
for i in range(m):
row = squares[i]
- print "|" + "|".join(row) + "|"
- print sep
+ print("|" + "|".join(row) + "|")
+ print(sep)
conjoin_tests = """
@@ -1330,7 +1330,7 @@ Generate the 3-bit binary numbers in order. This illustrates dumbest-
possible use of conjoin, just to generate the full cross-product.
>>> for c in conjoin([lambda: iter((0, 1))] * 3):
-... print c
+... print(c)
[0, 0, 0]
[0, 0, 1]
[0, 1, 0]
@@ -1350,7 +1350,7 @@ generated sequence, you need to copy its results.
>>> for n in range(10):
... all = list(gencopy(conjoin([lambda: iter((0, 1))] * n)))
-... print n, len(all), all[0] == [0] * n, all[-1] == [1] * n
+... print(n, len(all), all[0] == [0] * n, all[-1] == [1] * n)
0 1 True True
1 2 True True
2 4 True True
@@ -1370,7 +1370,7 @@ And run an 8-queens solver.
>>> for row2col in q.solve():
... count += 1
... if count <= LIMIT:
-... print "Solution", count
+... print("Solution", count)
... q.printsolution(row2col)
Solution 1
+-+-+-+-+-+-+-+-+
@@ -1409,7 +1409,7 @@ Solution 2
| | | | |Q| | | |
+-+-+-+-+-+-+-+-+
->>> print count, "solutions in all."
+>>> print(count, "solutions in all.")
92 solutions in all.
And run a Knight's Tour on a 10x10 board. Note that there are about
@@ -1421,7 +1421,7 @@ And run a Knight's Tour on a 10x10 board. Note that there are about
>>> for x in k.solve():
... count += 1
... if count <= LIMIT:
-... print "Solution", count
+... print("Solution", count)
... k.printsolution(x)
... else:
... break
@@ -1499,10 +1499,10 @@ coroutine_tests = """\
Sending a value into a started generator:
>>> def f():
-... print (yield 1)
+... print((yield 1))
... yield 2
>>> g = f()
->>> g.next()
+>>> next(g)
1
>>> g.send(42)
42
@@ -1533,7 +1533,7 @@ And a more sane, but still weird usage:
>>> def f(): list(i for i in [(yield 26)])
>>> type(f())
-<type 'generator'>
+<class 'generator'>
A yield expression with augmented assignment.
@@ -1545,17 +1545,17 @@ A yield expression with augmented assignment.
... seq.append(count)
>>> seq = []
>>> c = coroutine(seq)
->>> c.next()
->>> print seq
+>>> next(c)
+>>> print(seq)
[]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10, 20]
>>> c.send(10)
->>> print seq
+>>> print(seq)
[10, 20, 30]
@@ -1564,30 +1564,26 @@ Check some syntax errors for yield expressions:
>>> f=lambda: (yield 1),(yield 2)
Traceback (most recent call last):
...
- File "<doctest test.test_generators.__test__.coroutine[21]>", line 1
SyntaxError: 'yield' outside function
>>> def f(): return lambda x=(yield): 1
Traceback (most recent call last):
...
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
+SyntaxError: 'return' with argument inside generator
>>> def f(): x = yield = y
Traceback (most recent call last):
...
- File "<doctest test.test_generators.__test__.coroutine[23]>", line 1
SyntaxError: assignment to yield expression not possible
>>> def f(): (yield bar) = y
Traceback (most recent call last):
...
- File "<doctest test.test_generators.__test__.coroutine[24]>", line 1
SyntaxError: can't assign to yield expression
>>> def f(): (yield bar) += y
Traceback (most recent call last):
...
- File "<doctest test.test_generators.__test__.coroutine[25]>", line 1
SyntaxError: can't assign to yield expression
@@ -1596,12 +1592,12 @@ Now check some throw() conditions:
>>> def f():
... while True:
... try:
-... print (yield)
-... except ValueError,v:
-... print "caught ValueError (%s)" % (v),
+... print((yield))
+... except ValueError as v:
+... print("caught ValueError (%s)" % (v))
>>> import sys
>>> g = f()
->>> g.next()
+>>> next(g)
>>> g.throw(ValueError) # type only
caught ValueError ()
@@ -1628,6 +1624,21 @@ Traceback (most recent call last):
...
TypeError: throw() third argument must be a traceback object
+>>> g.throw("abc")
+Traceback (most recent call last):
+ ...
+TypeError: exceptions must be classes or instances deriving from BaseException, not str
+
+>>> g.throw(0)
+Traceback (most recent call last):
+ ...
+TypeError: exceptions must be classes or instances deriving from BaseException, not int
+
+>>> g.throw(list)
+Traceback (most recent call last):
+ ...
+TypeError: exceptions must be classes or instances deriving from BaseException, not type
+
>>> def throw(g,exc):
... try:
... raise exc
@@ -1644,7 +1655,7 @@ Traceback (most recent call last):
...
TypeError
->>> print g.gi_frame
+>>> print(g.gi_frame)
None
>>> g.send(2)
@@ -1662,20 +1673,41 @@ Traceback (most recent call last):
...
ValueError: 7
->>> f().throw("abc") # throw on just-opened generator
-Traceback (most recent call last):
- ...
-TypeError: exceptions must be classes, or instances, not str
+Plain "raise" inside a generator should preserve the traceback (#13188).
+The traceback should have 3 levels:
+- g.throw()
+- f()
+- 1/0
+
+>>> def f():
+... try:
+... yield
+... except:
+... raise
+>>> g = f()
+>>> try:
+... 1/0
+... except ZeroDivisionError as v:
+... try:
+... g.throw(v)
+... except Exception as w:
+... tb = w.__traceback__
+>>> levels = 0
+>>> while tb:
+... levels += 1
+... tb = tb.tb_next
+>>> levels
+3
Now let's try closing a generator:
>>> def f():
... try: yield
... except GeneratorExit:
-... print "exiting"
+... print("exiting")
>>> g = f()
->>> g.next()
+>>> next(g)
>>> g.close()
exiting
>>> g.close() # should be no-op now
@@ -1685,7 +1717,7 @@ exiting
>>> def f(): yield # an even simpler generator
>>> f().close() # close before opening
>>> g = f()
->>> g.next()
+>>> next(g)
>>> g.close() # close normally
And finalization:
@@ -1693,21 +1725,10 @@ And finalization:
>>> def f():
... try: yield
... finally:
-... print "exiting"
+... print("exiting")
>>> g = f()
->>> g.next()
->>> del g
-exiting
-
->>> class context(object):
-... def __enter__(self): pass
-... def __exit__(self, *args): print 'exiting'
->>> def f():
-... with context():
-... yield
->>> g = f()
->>> g.next()
+>>> next(g)
>>> del g
exiting
@@ -1716,11 +1737,13 @@ GeneratorExit is not caught by except Exception:
>>> def f():
... try: yield
-... except Exception: print 'except'
-... finally: print 'finally'
+... except Exception:
+... print('except')
+... finally:
+... print('finally')
>>> g = f()
->>> g.next()
+>>> next(g)
>>> del g
finally
@@ -1732,7 +1755,7 @@ Now let's try some ill-behaved generators:
... except GeneratorExit:
... yield "foo!"
>>> g = f()
->>> g.next()
+>>> next(g)
>>> g.close()
Traceback (most recent call last):
...
@@ -1742,10 +1765,10 @@ RuntimeError: generator ignored GeneratorExit
Our ill-behaved code should be invoked during GC:
->>> import sys, StringIO
->>> old, sys.stderr = sys.stderr, StringIO.StringIO()
+>>> import sys, io
+>>> old, sys.stderr = sys.stderr, io.StringIO()
>>> g = f()
->>> g.next()
+>>> next(g)
>>> del g
>>> sys.stderr.getvalue().startswith(
... "Exception RuntimeError: 'generator ignored GeneratorExit' in "
@@ -1761,7 +1784,7 @@ And errors thrown during closing should propagate:
... except GeneratorExit:
... raise TypeError("fie!")
>>> g = f()
->>> g.next()
+>>> next(g)
>>> g.close()
Traceback (most recent call last):
...
@@ -1773,25 +1796,25 @@ enclosing function a generator:
>>> def f(): x += yield
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f(): x = yield
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f(): lambda x=(yield): 1
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f(): x=(i for i in (yield) if (yield))
>>> type(f())
-<type 'generator'>
+<class 'generator'>
>>> def f(d): d[(yield "a")] = d[(yield "b")] = 27
>>> data = [1,2]
>>> g = f(data)
>>> type(g)
-<type 'generator'>
+<class 'generator'>
>>> g.send(None)
'a'
>>> data
@@ -1817,7 +1840,7 @@ would trigger if it starts being uncleanable again.
... class gen:
... def __iter__(self):
... return self
-... def next(self):
+... def __next__(self):
... return self.item
... g = gen()
... head, tail = itertools.tee(g)
@@ -1828,7 +1851,7 @@ would trigger if it starts being uncleanable again.
Make sure to also test the involvement of the tee-internal teedataobject,
which stores returned items.
->>> item = it.next()
+>>> item = next(it)
@@ -1853,10 +1876,10 @@ explicitly, without generators. We do have to redirect stderr to avoid
printing warnings and to doublecheck that we actually tested what we wanted
to test.
->>> import sys, StringIO
+>>> import sys, io
>>> old = sys.stderr
>>> try:
-... sys.stderr = StringIO.StringIO()
+... sys.stderr = io.StringIO()
... class Leaker:
... def __del__(self):
... raise RuntimeError
@@ -1898,8 +1921,8 @@ __test__ = {"tut": tutorial_tests,
# Note that doctest and regrtest both look in sys.argv for a "-v" argument,
# so this works as expected in both ways of running regrtest.
def test_main(verbose=None):
- from test import test_support, test_generators
- test_support.run_doctest(test_generators, verbose)
+ from test import support, test_generators
+ support.run_doctest(test_generators, verbose)
# This part isn't needed for regrtest, but for running the test directly.
if __name__ == "__main__":
diff --git a/Lib/test/test_genericpath.py b/Lib/test/test_genericpath.py
index 3975b56ab87..50638a1cf0f 100644
--- a/Lib/test/test_genericpath.py
+++ b/Lib/test/test_genericpath.py
@@ -3,7 +3,7 @@ Tests common to genericpath, macpath, ntpath and posixpath
"""
import unittest
-from test import test_support
+from test import support
import os
import genericpath
import sys
@@ -61,6 +61,31 @@ class GenericTest(unittest.TestCase):
":home:swen:spam"
)
+ self.assertEqual(
+ commonprefix([b"/home/swenson/spam", b"/home/swen/spam"]),
+ b"/home/swen"
+ )
+ self.assertEqual(
+ commonprefix([b"/home/swen/spam", b"/home/swen/eggs"]),
+ b"/home/swen/"
+ )
+ self.assertEqual(
+ commonprefix([b"/home/swen/spam", b"/home/swen/spam"]),
+ b"/home/swen/spam"
+ )
+ self.assertEqual(
+ commonprefix([b"home:swenson:spam", b"home:swen:spam"]),
+ b"home:swen"
+ )
+ self.assertEqual(
+ commonprefix([b":home:swen:spam", b":home:swen:eggs"]),
+ b":home:swen:"
+ )
+ self.assertEqual(
+ commonprefix([b":home:swen:spam", b":home:swen:spam"]),
+ b":home:swen:spam"
+ )
+
testlist = ['', 'abc', 'Xbcd', 'Xb', 'XY', 'abcd',
'aXc', 'abd', 'ab', 'aX', 'abcX']
for s1 in testlist:
@@ -73,86 +98,86 @@ class GenericTest(unittest.TestCase):
self.assertNotEqual(s1[n:n+1], s2[n:n+1])
def test_getsize(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- self.assertEqual(self.pathmodule.getsize(test_support.TESTFN), 3)
+ self.assertEqual(self.pathmodule.getsize(support.TESTFN), 3)
finally:
if not f.closed:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_time(self):
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- f = open(test_support.TESTFN, "ab")
- f.write("bar")
+ f = open(support.TESTFN, "ab")
+ f.write(b"bar")
f.close()
- f = open(test_support.TESTFN, "rb")
+ f = open(support.TESTFN, "rb")
d = f.read()
f.close()
- self.assertEqual(d, "foobar")
+ self.assertEqual(d, b"foobar")
self.assertLessEqual(
- self.pathmodule.getctime(test_support.TESTFN),
- self.pathmodule.getmtime(test_support.TESTFN)
+ self.pathmodule.getctime(support.TESTFN),
+ self.pathmodule.getmtime(support.TESTFN)
)
finally:
if not f.closed:
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_exists(self):
- self.assertIs(self.pathmodule.exists(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(self.pathmodule.exists(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- self.assertIs(self.pathmodule.exists(test_support.TESTFN), True)
+ self.assertIs(self.pathmodule.exists(support.TESTFN), True)
if not self.pathmodule == genericpath:
- self.assertIs(self.pathmodule.lexists(test_support.TESTFN),
+ self.assertIs(self.pathmodule.lexists(support.TESTFN),
True)
finally:
if not f.close():
f.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_isdir(self):
- self.assertIs(self.pathmodule.isdir(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- self.assertIs(self.pathmodule.isdir(test_support.TESTFN), False)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(self.pathmodule.isdir(test_support.TESTFN), True)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), False)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(self.pathmodule.isdir(support.TESTFN), True)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
- test_support.unlink(test_support.TESTFN)
- safe_rmdir(test_support.TESTFN)
+ support.unlink(support.TESTFN)
+ safe_rmdir(support.TESTFN)
def test_isfile(self):
- self.assertIs(self.pathmodule.isfile(test_support.TESTFN), False)
- f = open(test_support.TESTFN, "wb")
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
+ f = open(support.TESTFN, "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- self.assertIs(self.pathmodule.isfile(test_support.TESTFN), True)
- os.remove(test_support.TESTFN)
- os.mkdir(test_support.TESTFN)
- self.assertIs(self.pathmodule.isfile(test_support.TESTFN), False)
- os.rmdir(test_support.TESTFN)
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), True)
+ os.remove(support.TESTFN)
+ os.mkdir(support.TESTFN)
+ self.assertIs(self.pathmodule.isfile(support.TESTFN), False)
+ os.rmdir(support.TESTFN)
finally:
if not f.close():
f.close()
- test_support.unlink(test_support.TESTFN)
- safe_rmdir(test_support.TESTFN)
+ support.unlink(support.TESTFN)
+ safe_rmdir(support.TESTFN)
# Following TestCase is not supposed to be run from test_genericpath.
@@ -172,10 +197,18 @@ class CommonTest(GenericTest):
]
def test_normcase(self):
- # Check that normcase() is idempotent
- p = "FoO/./BaR"
- p = self.pathmodule.normcase(p)
- self.assertEqual(p, self.pathmodule.normcase(p))
+ normcase = self.pathmodule.normcase
+ # check that normcase() is idempotent
+ for p in ["FoO/./BaR", b"FoO/./BaR"]:
+ p = normcase(p)
+ self.assertEqual(p, normcase(p))
+
+ self.assertEqual(normcase(''), '')
+ self.assertEqual(normcase(b''), b'')
+
+ # check that normcase raises a TypeError for invalid types
+ for path in (None, True, 0, 2.5, [], bytearray(b''), {'o','o'}):
+ self.assertRaises(TypeError, normcase, path)
def test_splitdrive(self):
# splitdrive for non-NT paths
@@ -184,11 +217,15 @@ class CommonTest(GenericTest):
self.assertEqual(splitdrive("foo:bar"), ("", "foo:bar"))
self.assertEqual(splitdrive(":foo:bar"), ("", ":foo:bar"))
+ self.assertEqual(splitdrive(b"/foo/bar"), (b"", b"/foo/bar"))
+ self.assertEqual(splitdrive(b"foo:bar"), (b"", b"foo:bar"))
+ self.assertEqual(splitdrive(b":foo:bar"), (b"", b":foo:bar"))
+
def test_expandvars(self):
if self.pathmodule.__name__ == 'macpath':
self.skipTest('macpath.expandvars is a stub')
expandvars = self.pathmodule.expandvars
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env.clear()
env["foo"] = "bar"
env["{foo"] = "baz1"
@@ -206,50 +243,65 @@ class CommonTest(GenericTest):
self.assertEqual(expandvars("$foo$foo"), "barbar")
self.assertEqual(expandvars("$bar$bar"), "$bar$bar")
+ self.assertEqual(expandvars(b"foo"), b"foo")
+ self.assertEqual(expandvars(b"$foo bar"), b"bar bar")
+ self.assertEqual(expandvars(b"${foo}bar"), b"barbar")
+ self.assertEqual(expandvars(b"$[foo]bar"), b"$[foo]bar")
+ self.assertEqual(expandvars(b"$bar bar"), b"$bar bar")
+ self.assertEqual(expandvars(b"$?bar"), b"$?bar")
+ self.assertEqual(expandvars(b"${foo}bar"), b"barbar")
+ self.assertEqual(expandvars(b"$foo}bar"), b"bar}bar")
+ self.assertEqual(expandvars(b"${foo"), b"${foo")
+ self.assertEqual(expandvars(b"${{foo}}"), b"baz1}")
+ self.assertEqual(expandvars(b"$foo$foo"), b"barbar")
+ self.assertEqual(expandvars(b"$bar$bar"), b"$bar$bar")
+
def test_abspath(self):
self.assertIn("foo", self.pathmodule.abspath("foo"))
+ self.assertIn(b"foo", self.pathmodule.abspath(b"foo"))
# Abspath returns bytes when the arg is bytes
- for path in ('', 'foo', 'f\xf2\xf2', '/foo', 'C:\\'):
- self.assertIsInstance(self.pathmodule.abspath(path), str)
+ for path in (b'', b'foo', b'f\xf2\xf2', b'/foo', b'C:\\'):
+ self.assertIsInstance(self.pathmodule.abspath(path), bytes)
def test_realpath(self):
self.assertIn("foo", self.pathmodule.realpath("foo"))
+ self.assertIn(b"foo", self.pathmodule.realpath(b"foo"))
def test_normpath_issue5827(self):
# Make sure normpath preserves unicode
- for path in (u'', u'.', u'/', u'\\', u'///foo/.//bar//'):
- self.assertIsInstance(self.pathmodule.normpath(path), unicode)
+ for path in ('', '.', '/', '\\', '///foo/.//bar//'):
+ self.assertIsInstance(self.pathmodule.normpath(path), str)
def test_abspath_issue3426(self):
# Check that abspath returns unicode when the arg is unicode
# with both ASCII and non-ASCII cwds.
abspath = self.pathmodule.abspath
- for path in (u'', u'fuu', u'f\xf9\xf9', u'/fuu', u'U:\\'):
- self.assertIsInstance(abspath(path), unicode)
+ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
+ self.assertIsInstance(abspath(path), str)
- unicwd = u'\xe7w\xf0'
+ unicwd = '\xe7w\xf0'
try:
- fsencoding = test_support.TESTFN_ENCODING or "ascii"
+ fsencoding = support.TESTFN_ENCODING or "ascii"
unicwd.encode(fsencoding)
except (AttributeError, UnicodeEncodeError):
# FS encoding is probably ASCII
pass
else:
- with test_support.temp_cwd(unicwd):
- for path in (u'', u'fuu', u'f\xf9\xf9', u'/fuu', u'U:\\'):
- self.assertIsInstance(abspath(path), unicode)
+ with support.temp_cwd(unicwd):
+ for path in ('', 'fuu', 'f\xf9\xf9', '/fuu', 'U:\\'):
+ self.assertIsInstance(abspath(path), str)
@unittest.skipIf(sys.platform == 'darwin',
"Mac OS X denies the creation of a directory with an invalid utf8 name")
def test_nonascii_abspath(self):
# Test non-ASCII, non-UTF8 bytes in the path.
- with test_support.temp_cwd('\xe7w\xf0'):
+ with support.temp_cwd(b'\xe7w\xf0'):
self.test_abspath()
def test_main():
- test_support.run_unittest(GenericTest)
+ support.run_unittest(GenericTest)
if __name__=="__main__":
diff --git a/Lib/test/test_genexps.py b/Lib/test/test_genexps.py
index 3d896a530f8..1f46af13e34 100644
--- a/Lib/test/test_genexps.py
+++ b/Lib/test/test_genexps.py
@@ -27,31 +27,31 @@ Test first class
>>> g = (i*i for i in range(4))
>>> type(g)
- <type 'generator'>
+ <class 'generator'>
>>> list(g)
[0, 1, 4, 9]
Test direct calls to next()
>>> g = (i*i for i in range(3))
- >>> g.next()
+ >>> next(g)
0
- >>> g.next()
+ >>> next(g)
1
- >>> g.next()
+ >>> next(g)
4
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in -toplevel-
- g.next()
+ next(g)
StopIteration
Does it stay stopped?
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<pyshell#21>", line 1, in -toplevel-
- g.next()
+ next(g)
StopIteration
>>> list(g)
[]
@@ -59,16 +59,16 @@ Does it stay stopped?
Test running gen when defining function is out of scope
>>> def f(n):
- ... return (i*i for i in xrange(n))
+ ... return (i*i for i in range(n))
>>> list(f(10))
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
>>> def f(n):
- ... return ((i,j) for i in xrange(3) for j in xrange(n))
+ ... return ((i,j) for i in range(3) for j in range(n))
>>> list(f(4))
[(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]
>>> def f(n):
- ... return ((i,j) for i in xrange(3) for j in xrange(4) if j in xrange(n))
+ ... return ((i,j) for i in range(3) for j in range(4) if j in range(n))
>>> list(f(4))
[(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]
>>> list(f(2))
@@ -77,21 +77,21 @@ Test running gen when defining function is out of scope
Verify that parenthesis are required in a statement
>>> def f(n):
- ... return i*i for i in xrange(n)
+ ... return i*i for i in range(n)
Traceback (most recent call last):
...
SyntaxError: invalid syntax
Verify that parenthesis are required when used as a keyword argument value
- >>> dict(a = i for i in xrange(10))
+ >>> dict(a = i for i in range(10))
Traceback (most recent call last):
...
SyntaxError: invalid syntax
Verify that parenthesis are required when used as a keyword argument value
- >>> dict(a = (i for i in xrange(10))) #doctest: +ELLIPSIS
+ >>> dict(a = (i for i in range(10))) #doctest: +ELLIPSIS
{'a': <generator object <genexpr> at ...>}
Verify early binding for the outermost for-expression
@@ -128,7 +128,7 @@ Verify late binding for the innermost for-expression
Verify re-use of tuples (a side benefit of using genexps over listcomps)
- >>> tupleids = map(id, ((i,i) for i in xrange(10)))
+ >>> tupleids = list(map(id, ((i,i) for i in range(10))))
>>> int(max(tupleids) - min(tupleids))
0
@@ -137,13 +137,11 @@ Verify that syntax error's are raised for genexps used as lvalues
>>> (y for y in (1,2)) = 10
Traceback (most recent call last):
...
- File "<doctest test.test_genexps.__test__.doctests[40]>", line 1
SyntaxError: can't assign to generator expression
>>> (y for y in (1,2)) += 10
Traceback (most recent call last):
...
- File "<doctest test.test_genexps.__test__.doctests[41]>", line 1
SyntaxError: can't assign to generator expression
@@ -151,7 +149,7 @@ Verify that syntax error's are raised for genexps used as lvalues
Make a generator that acts like range()
- >>> yrange = lambda n: (i for i in xrange(n))
+ >>> yrange = lambda n: (i for i in range(n))
>>> list(yrange(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@@ -159,12 +157,12 @@ Generators always return to the most recent caller:
>>> def creator():
... r = yrange(5)
- ... print "creator", r.next()
+ ... print("creator", next(r))
... return r
>>> def caller():
... r = creator()
... for i in r:
- ... print "caller", i
+ ... print("caller", i)
>>> caller()
creator 0
caller 1
@@ -183,48 +181,48 @@ Generators can call other generators:
Verify that a gen exp cannot be resumed while it is actively running:
- >>> g = (me.next() for i in xrange(10))
+ >>> g = (next(me) for i in range(10))
>>> me = g
- >>> me.next()
+ >>> next(me)
Traceback (most recent call last):
File "<pyshell#30>", line 1, in -toplevel-
- me.next()
+ next(me)
File "<pyshell#28>", line 1, in <generator expression>
- g = (me.next() for i in xrange(10))
+ g = (next(me) for i in range(10))
ValueError: generator already executing
Verify exception propagation
>>> g = (10 // i for i in (5, 0, 2))
- >>> g.next()
+ >>> next(g)
2
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<pyshell#37>", line 1, in -toplevel-
- g.next()
+ next(g)
File "<pyshell#35>", line 1, in <generator expression>
g = (10 // i for i in (5, 0, 2))
ZeroDivisionError: integer division or modulo by zero
- >>> g.next()
+ >>> next(g)
Traceback (most recent call last):
File "<pyshell#38>", line 1, in -toplevel-
- g.next()
+ next(g)
StopIteration
Make sure that None is a valid return value
- >>> list(None for i in xrange(10))
+ >>> list(None for i in range(10))
[None, None, None, None, None, None, None, None, None, None]
Check that generator attributes are present
>>> g = (i*i for i in range(3))
- >>> expected = set(['gi_frame', 'gi_running', 'next'])
+ >>> expected = set(['gi_frame', 'gi_running'])
>>> set(attr for attr in dir(g) if not attr.startswith('__')) >= expected
True
- >>> print g.next.__doc__
- x.next() -> the next value, or raise StopIteration
+ >>> print(g.__next__.__doc__)
+ x.__next__() <==> next(x)
>>> import types
>>> isinstance(g, types.GeneratorType)
True
@@ -240,7 +238,7 @@ Verify that the running flag is set properly
>>> me = g
>>> me.gi_running
0
- >>> me.next()
+ >>> next(me)
1
>>> me.gi_running
0
@@ -264,19 +262,19 @@ __test__ = {'doctests' : doctests}
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_genexps
- test_support.run_doctest(test_genexps, verbose)
+ support.run_doctest(test_genexps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_doctest(test_genexps, verbose)
+ for i in range(len(counts)):
+ support.run_doctest(test_genexps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_getargs.py b/Lib/test/test_getargs.py
deleted file mode 100644
index 4ac5aa2f7ab..00000000000
--- a/Lib/test/test_getargs.py
+++ /dev/null
@@ -1,31 +0,0 @@
-"""
-Test the internal getargs.c implementation
-
- PyArg_ParseTuple() is defined here.
-
-The test here is not intended to test all of the module, just the
-single case that failed between 2.1 and 2.2a2.
-"""
-
-# marshal.loads() uses PyArg_ParseTuple(args, "s#:loads")
-# The s code will cause a Unicode conversion to occur. This test
-# verify that the error is propagated properly from the C code back to
-# Python.
-
-import marshal
-import unittest
-from test import test_support
-
-class GetArgsTest(unittest.TestCase):
- # If the encoding succeeds using the current default encoding,
- # this test will fail because it does not test the right part of the
- # PyArg_ParseTuple() implementation.
- def test_with_marshal(self):
- arg = unicode(r'\222', 'unicode-escape')
- self.assertRaises(UnicodeError, marshal.loads, arg)
-
-def test_main():
- test_support.run_unittest(GetArgsTest)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_getargs2.py b/Lib/test/test_getargs2.py
index d06296b0293..3d9c06a4607 100644
--- a/Lib/test/test_getargs2.py
+++ b/Lib/test/test_getargs2.py
@@ -1,7 +1,6 @@
import unittest
-from test import test_support
+from test import support
from _testcapi import getargs_keywords
-import warnings
"""
> How about the following counterproposal. This also changes some of
@@ -36,7 +35,7 @@ long long (if that exists).
"""
LARGE = 0x7FFFFFFF
-VERY_LARGE = 0xFF0000121212121212121242L
+VERY_LARGE = 0xFF0000121212121212121242
from _testcapi import UCHAR_MAX, USHRT_MAX, UINT_MAX, ULONG_MAX, INT_MAX, \
INT_MIN, LONG_MIN, LONG_MAX, PY_SSIZE_T_MIN, PY_SSIZE_T_MAX, \
@@ -47,10 +46,6 @@ LLONG_MAX = 2**63-1
LLONG_MIN = -2**63
ULLONG_MAX = 2**64-1
-class Long:
- def __int__(self):
- return 99L
-
class Int:
def __int__(self):
return 99
@@ -60,7 +55,6 @@ class Unsigned_TestCase(unittest.TestCase):
from _testcapi import getargs_b
# b returns 'unsigned char', and does range checking (0 ... UCHAR_MAX)
self.assertRaises(TypeError, getargs_b, 3.14)
- self.assertEqual(99, getargs_b(Long()))
self.assertEqual(99, getargs_b(Int()))
self.assertRaises(OverflowError, getargs_b, -1)
@@ -69,31 +63,26 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_b, UCHAR_MAX + 1)
self.assertEqual(42, getargs_b(42))
- self.assertEqual(42, getargs_b(42L))
self.assertRaises(OverflowError, getargs_b, VERY_LARGE)
def test_B(self):
from _testcapi import getargs_B
# B returns 'unsigned char', no range checking
self.assertRaises(TypeError, getargs_B, 3.14)
- self.assertEqual(99, getargs_B(Long()))
self.assertEqual(99, getargs_B(Int()))
self.assertEqual(UCHAR_MAX, getargs_B(-1))
- self.assertEqual(UCHAR_MAX, getargs_B(-1L))
self.assertEqual(0, getargs_B(0))
self.assertEqual(UCHAR_MAX, getargs_B(UCHAR_MAX))
self.assertEqual(0, getargs_B(UCHAR_MAX+1))
self.assertEqual(42, getargs_B(42))
- self.assertEqual(42, getargs_B(42L))
self.assertEqual(UCHAR_MAX & VERY_LARGE, getargs_B(VERY_LARGE))
def test_H(self):
from _testcapi import getargs_H
# H returns 'unsigned short', no range checking
self.assertRaises(TypeError, getargs_H, 3.14)
- self.assertEqual(99, getargs_H(Long()))
self.assertEqual(99, getargs_H(Int()))
self.assertEqual(USHRT_MAX, getargs_H(-1))
@@ -102,7 +91,6 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_H(USHRT_MAX+1))
self.assertEqual(42, getargs_H(42))
- self.assertEqual(42, getargs_H(42L))
self.assertEqual(VERY_LARGE & USHRT_MAX, getargs_H(VERY_LARGE))
@@ -110,7 +98,6 @@ class Unsigned_TestCase(unittest.TestCase):
from _testcapi import getargs_I
# I returns 'unsigned int', no range checking
self.assertRaises(TypeError, getargs_I, 3.14)
- self.assertEqual(99, getargs_I(Long()))
self.assertEqual(99, getargs_I(Int()))
self.assertEqual(UINT_MAX, getargs_I(-1))
@@ -119,7 +106,6 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_I(UINT_MAX+1))
self.assertEqual(42, getargs_I(42))
- self.assertEqual(42, getargs_I(42L))
self.assertEqual(VERY_LARGE & UINT_MAX, getargs_I(VERY_LARGE))
@@ -128,7 +114,6 @@ class Unsigned_TestCase(unittest.TestCase):
# k returns 'unsigned long', no range checking
# it does not accept float, or instances with __int__
self.assertRaises(TypeError, getargs_k, 3.14)
- self.assertRaises(TypeError, getargs_k, Long())
self.assertRaises(TypeError, getargs_k, Int())
self.assertEqual(ULONG_MAX, getargs_k(-1))
@@ -137,7 +122,6 @@ class Unsigned_TestCase(unittest.TestCase):
self.assertEqual(0, getargs_k(ULONG_MAX+1))
self.assertEqual(42, getargs_k(42))
- self.assertEqual(42, getargs_k(42L))
self.assertEqual(VERY_LARGE & ULONG_MAX, getargs_k(VERY_LARGE))
@@ -146,7 +130,6 @@ class Signed_TestCase(unittest.TestCase):
from _testcapi import getargs_h
# h returns 'short', and does range checking (SHRT_MIN ... SHRT_MAX)
self.assertRaises(TypeError, getargs_h, 3.14)
- self.assertEqual(99, getargs_h(Long()))
self.assertEqual(99, getargs_h(Int()))
self.assertRaises(OverflowError, getargs_h, SHRT_MIN-1)
@@ -155,14 +138,12 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_h, SHRT_MAX+1)
self.assertEqual(42, getargs_h(42))
- self.assertEqual(42, getargs_h(42L))
self.assertRaises(OverflowError, getargs_h, VERY_LARGE)
def test_i(self):
from _testcapi import getargs_i
# i returns 'int', and does range checking (INT_MIN ... INT_MAX)
self.assertRaises(TypeError, getargs_i, 3.14)
- self.assertEqual(99, getargs_i(Long()))
self.assertEqual(99, getargs_i(Int()))
self.assertRaises(OverflowError, getargs_i, INT_MIN-1)
@@ -171,14 +152,12 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_i, INT_MAX+1)
self.assertEqual(42, getargs_i(42))
- self.assertEqual(42, getargs_i(42L))
self.assertRaises(OverflowError, getargs_i, VERY_LARGE)
def test_l(self):
from _testcapi import getargs_l
# l returns 'long', and does range checking (LONG_MIN ... LONG_MAX)
self.assertRaises(TypeError, getargs_l, 3.14)
- self.assertEqual(99, getargs_l(Long()))
self.assertEqual(99, getargs_l(Int()))
self.assertRaises(OverflowError, getargs_l, LONG_MIN-1)
@@ -187,7 +166,6 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_l, LONG_MAX+1)
self.assertEqual(42, getargs_l(42))
- self.assertEqual(42, getargs_l(42L))
self.assertRaises(OverflowError, getargs_l, VERY_LARGE)
def test_n(self):
@@ -195,8 +173,7 @@ class Signed_TestCase(unittest.TestCase):
# n returns 'Py_ssize_t', and does range checking
# (PY_SSIZE_T_MIN ... PY_SSIZE_T_MAX)
self.assertRaises(TypeError, getargs_n, 3.14)
- self.assertEqual(99, getargs_n(Long()))
- self.assertEqual(99, getargs_n(Int()))
+ self.assertRaises(TypeError, getargs_n, Int())
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MIN-1)
self.assertEqual(PY_SSIZE_T_MIN, getargs_n(PY_SSIZE_T_MIN))
@@ -204,7 +181,6 @@ class Signed_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_n, PY_SSIZE_T_MAX+1)
self.assertEqual(42, getargs_n(42))
- self.assertEqual(42, getargs_n(42L))
self.assertRaises(OverflowError, getargs_n, VERY_LARGE)
@@ -213,23 +189,8 @@ class LongLong_TestCase(unittest.TestCase):
from _testcapi import getargs_L
# L returns 'long long', and does range checking (LLONG_MIN
# ... LLONG_MAX)
- with warnings.catch_warnings():
- warnings.filterwarnings(
- "ignore",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module=__name__)
- self.assertEqual(3, getargs_L(3.14))
- with warnings.catch_warnings():
- warnings.filterwarnings(
- "error",
- category=DeprecationWarning,
- message=".*integer argument expected, got float",
- module="unittest")
- self.assertRaises(DeprecationWarning, getargs_L, 3.14)
-
+ self.assertRaises(TypeError, getargs_L, 3.14)
self.assertRaises(TypeError, getargs_L, "Hello")
- self.assertEqual(99, getargs_L(Long()))
self.assertEqual(99, getargs_L(Int()))
self.assertRaises(OverflowError, getargs_L, LLONG_MIN-1)
@@ -238,21 +199,18 @@ class LongLong_TestCase(unittest.TestCase):
self.assertRaises(OverflowError, getargs_L, LLONG_MAX+1)
self.assertEqual(42, getargs_L(42))
- self.assertEqual(42, getargs_L(42L))
self.assertRaises(OverflowError, getargs_L, VERY_LARGE)
def test_K(self):
from _testcapi import getargs_K
# K return 'unsigned long long', no range checking
self.assertRaises(TypeError, getargs_K, 3.14)
- self.assertRaises(TypeError, getargs_K, Long())
self.assertRaises(TypeError, getargs_K, Int())
self.assertEqual(ULLONG_MAX, getargs_K(ULLONG_MAX))
self.assertEqual(0, getargs_K(0))
self.assertEqual(0, getargs_K(ULLONG_MAX+1))
self.assertEqual(42, getargs_K(42))
- self.assertEqual(42, getargs_K(42L))
self.assertEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
@@ -279,57 +237,211 @@ class Keywords_TestCase(unittest.TestCase):
getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), 10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_mixed_args(self):
# positional and keyword args
self.assertEqual(
getargs_keywords((1,2), 3, (4,(5,6)), arg4=(7,8,9), arg5=10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_keyword_args(self):
# all keywords
self.assertEqual(
getargs_keywords(arg1=(1,2), arg2=3, arg3=(4,(5,6)), arg4=(7,8,9), arg5=10),
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
)
+
def test_optional_args(self):
# missing optional keyword args, skipping tuples
self.assertEqual(
getargs_keywords(arg1=(1,2), arg2=3, arg5=10),
(1, 2, 3, -1, -1, -1, -1, -1, -1, 10)
)
+
def test_required_args(self):
# required arg missing
try:
getargs_keywords(arg1=(1,2))
- except TypeError, err:
+ except TypeError as err:
self.assertEqual(str(err), "Required argument 'arg2' (pos 2) not found")
else:
self.fail('TypeError should have been raised')
+
def test_too_many_args(self):
try:
getargs_keywords((1,2),3,(4,(5,6)),(7,8,9),10,111)
- except TypeError, err:
+ except TypeError as err:
self.assertEqual(str(err), "function takes at most 5 arguments (6 given)")
else:
self.fail('TypeError should have been raised')
+
def test_invalid_keyword(self):
# extraneous keyword arg
try:
getargs_keywords((1,2),3,arg5=10,arg666=666)
- except TypeError, err:
+ except TypeError as err:
self.assertEqual(str(err), "'arg666' is an invalid keyword argument for this function")
else:
self.fail('TypeError should have been raised')
+ def test_surrogate_keyword(self):
+ try:
+ getargs_keywords((1,2), 3, (4,(5,6)), (7,8,9), **{'\uDC80': 10})
+ except TypeError as err:
+ self.assertEqual(str(err), "'\udc80' is an invalid keyword argument for this function")
+ else:
+ self.fail('TypeError should have been raised')
+
+class Bytes_TestCase(unittest.TestCase):
+ def test_s(self):
+ from _testcapi import getargs_s
+ self.assertEqual(getargs_s('abc\xe9'), b'abc\xc3\xa9')
+ self.assertRaises(TypeError, getargs_s, 'nul:\0')
+ self.assertRaises(TypeError, getargs_s, b'bytes')
+ self.assertRaises(TypeError, getargs_s, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_s, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_s, None)
+
+ def test_s_star(self):
+ from _testcapi import getargs_s_star
+ self.assertEqual(getargs_s_star('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_s_star('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_s_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_s_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_s_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertRaises(TypeError, getargs_s_star, None)
+
+ def test_s_hash(self):
+ from _testcapi import getargs_s_hash
+ self.assertEqual(getargs_s_hash('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_s_hash('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_s_hash(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_s_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_s_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_s_hash, None)
+
+ def test_z(self):
+ from _testcapi import getargs_z
+ self.assertEqual(getargs_z('abc\xe9'), b'abc\xc3\xa9')
+ self.assertRaises(TypeError, getargs_z, 'nul:\0')
+ self.assertRaises(TypeError, getargs_z, b'bytes')
+ self.assertRaises(TypeError, getargs_z, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_z, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_z(None))
+
+ def test_z_star(self):
+ from _testcapi import getargs_z_star
+ self.assertEqual(getargs_z_star('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_z_star('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_z_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_z_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_z_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertIsNone(getargs_z_star(None))
+
+ def test_z_hash(self):
+ from _testcapi import getargs_z_hash
+ self.assertEqual(getargs_z_hash('abc\xe9'), b'abc\xc3\xa9')
+ self.assertEqual(getargs_z_hash('nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_z_hash(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_z_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_z_hash, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_z_hash(None))
+
+ def test_y(self):
+ from _testcapi import getargs_y
+ self.assertRaises(TypeError, getargs_y, 'abc\xe9')
+ self.assertEqual(getargs_y(b'bytes'), b'bytes')
+ self.assertRaises(TypeError, getargs_y, b'nul:\0')
+ self.assertRaises(TypeError, getargs_y, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_y, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_y, None)
+
+ def test_y_star(self):
+ from _testcapi import getargs_y_star
+ self.assertRaises(TypeError, getargs_y_star, 'abc\xe9')
+ self.assertEqual(getargs_y_star(b'bytes'), b'bytes')
+ self.assertEqual(getargs_y_star(b'nul:\0'), b'nul:\0')
+ self.assertEqual(getargs_y_star(bytearray(b'bytearray')), b'bytearray')
+ self.assertEqual(getargs_y_star(memoryview(b'memoryview')), b'memoryview')
+ self.assertRaises(TypeError, getargs_y_star, None)
+
+ def test_y_hash(self):
+ from _testcapi import getargs_y_hash
+ self.assertRaises(TypeError, getargs_y_hash, 'abc\xe9')
+ self.assertEqual(getargs_y_hash(b'bytes'), b'bytes')
+ self.assertEqual(getargs_y_hash(b'nul:\0'), b'nul:\0')
+ self.assertRaises(TypeError, getargs_y_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_y_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_y_hash, None)
+
+ def test_w_star(self):
+ # getargs_w_star() modifies first and last byte
+ from _testcapi import getargs_w_star
+ self.assertRaises(TypeError, getargs_w_star, 'abc\xe9')
+ self.assertRaises(TypeError, getargs_w_star, b'bytes')
+ self.assertRaises(TypeError, getargs_w_star, b'nul:\0')
+ self.assertRaises(TypeError, getargs_w_star, memoryview(b'bytes'))
+ self.assertEqual(getargs_w_star(bytearray(b'bytearray')), b'[ytearra]')
+ self.assertEqual(getargs_w_star(memoryview(bytearray(b'memoryview'))),
+ b'[emoryvie]')
+ self.assertRaises(TypeError, getargs_w_star, None)
+
+
+class Unicode_TestCase(unittest.TestCase):
+ def test_u(self):
+ from _testcapi import getargs_u
+ self.assertEqual(getargs_u('abc\xe9'), 'abc\xe9')
+ self.assertRaises(TypeError, getargs_u, 'nul:\0')
+ self.assertRaises(TypeError, getargs_u, b'bytes')
+ self.assertRaises(TypeError, getargs_u, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_u, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_u, None)
+
+ def test_u_hash(self):
+ from _testcapi import getargs_u_hash
+ self.assertEqual(getargs_u_hash('abc\xe9'), 'abc\xe9')
+ self.assertEqual(getargs_u_hash('nul:\0'), 'nul:\0')
+ self.assertRaises(TypeError, getargs_u_hash, b'bytes')
+ self.assertRaises(TypeError, getargs_u_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_u_hash, memoryview(b'memoryview'))
+ self.assertRaises(TypeError, getargs_u_hash, None)
+
+ def test_Z(self):
+ from _testcapi import getargs_Z
+ self.assertEqual(getargs_Z('abc\xe9'), 'abc\xe9')
+ self.assertRaises(TypeError, getargs_Z, 'nul:\0')
+ self.assertRaises(TypeError, getargs_Z, b'bytes')
+ self.assertRaises(TypeError, getargs_Z, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_Z, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_Z(None))
+
+ def test_Z_hash(self):
+ from _testcapi import getargs_Z_hash
+ self.assertEqual(getargs_Z_hash('abc\xe9'), 'abc\xe9')
+ self.assertEqual(getargs_Z_hash('nul:\0'), 'nul:\0')
+ self.assertRaises(TypeError, getargs_Z_hash, b'bytes')
+ self.assertRaises(TypeError, getargs_Z_hash, bytearray(b'bytearray'))
+ self.assertRaises(TypeError, getargs_Z_hash, memoryview(b'memoryview'))
+ self.assertIsNone(getargs_Z_hash(None))
+
+
def test_main():
- tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase, Keywords_TestCase]
+ tests = [
+ Signed_TestCase,
+ Unsigned_TestCase,
+ Tuple_TestCase,
+ Keywords_TestCase,
+ Bytes_TestCase,
+ Unicode_TestCase,
+ ]
try:
from _testcapi import getargs_L, getargs_K
except ImportError:
pass # PY_LONG_LONG not available
else:
tests.append(LongLong_TestCase)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_getopt.py b/Lib/test/test_getopt.py
index f924287bd31..fa5701f310b 100644
--- a/Lib/test/test_getopt.py
+++ b/Lib/test/test_getopt.py
@@ -1,7 +1,7 @@
# test_getopt.py
# David Goodger <dgoodger@bigfoot.com> 2000-08-19
-from test.test_support import verbose, run_doctest, run_unittest, EnvironmentVarGuard
+from test.support import verbose, run_doctest, run_unittest, EnvironmentVarGuard
import unittest
import getopt
diff --git a/Lib/test/test_gettext.py b/Lib/test/test_gettext.py
index f0369543e0f..5456948ca4b 100644
--- a/Lib/test/test_gettext.py
+++ b/Lib/test/test_gettext.py
@@ -4,7 +4,7 @@ import shutil
import gettext
import unittest
-from test import test_support
+from test import support
# TODO:
@@ -13,7 +13,7 @@ from test import test_support
# has no sense, it would have if we were testing a parser (i.e. pygettext)
# - Tests should have only one assert.
-GNU_MO_DATA = '''\
+GNU_MO_DATA = b'''\
3hIElQAAAAAGAAAAHAAAAEwAAAALAAAAfAAAAAAAAACoAAAAFQAAAKkAAAAjAAAAvwAAAKEAAADj
AAAABwAAAIUBAAALAAAAjQEAAEUBAACZAQAAFgAAAN8CAAAeAAAA9gIAAKEAAAAVAwAABQAAALcD
AAAJAAAAvQMAAAEAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAABQAAAAYAAAACAAAAAFJh
@@ -33,7 +33,7 @@ IHNiZSBsYmhlIENsZ3ViYSBjZWJ0ZW56ZiBvbCBjZWJpdnF2YXQgbmEgdmFncmVzbnByIGdiIGd1
ciBUQUgKdHJnZ3JrZyB6cmZmbnRyIHBuZ255YnQgeXZvZW5lbC4AYmFjb24Ad2luayB3aW5rAA==
'''
-UMO_DATA = '''\
+UMO_DATA = b'''\
3hIElQAAAAACAAAAHAAAACwAAAAFAAAAPAAAAAAAAABQAAAABAAAAFEAAAAPAQAAVgAAAAQAAABm
AQAAAQAAAAIAAAAAAAAAAAAAAAAAAAAAYWLDngBQcm9qZWN0LUlkLVZlcnNpb246IDIuMApQTy1S
ZXZpc2lvbi1EYXRlOiAyMDAzLTA0LTExIDEyOjQyLTA0MDAKTGFzdC1UcmFuc2xhdG9yOiBCYXJy
@@ -43,7 +43,7 @@ bjsgY2hhcnNldD11dGYtOApDb250ZW50LVRyYW5zZmVyLUVuY29kaW5nOiA3Yml0CkdlbmVyYXRl
ZC1CeTogbWFudWFsbHkKAMKkeXoA
'''
-MMO_DATA = '''\
+MMO_DATA = b'''\
3hIElQAAAAABAAAAHAAAACQAAAADAAAALAAAAAAAAAA4AAAAeAEAADkAAAABAAAAAAAAAAAAAAAA
UHJvamVjdC1JZC1WZXJzaW9uOiBObyBQcm9qZWN0IDAuMApQT1QtQ3JlYXRpb24tRGF0ZTogV2Vk
IERlYyAxMSAwNzo0NDoxNSAyMDAyClBPLVJldmlzaW9uLURhdGU6IDIwMDItMDgtMTQgMDE6MTg6
@@ -65,13 +65,12 @@ class GettextBaseTest(unittest.TestCase):
if not os.path.isdir(LOCALEDIR):
os.makedirs(LOCALEDIR)
with open(MOFILE, 'wb') as fp:
- fp.write(base64.decodestring(GNU_MO_DATA))
+ fp.write(base64.decodebytes(GNU_MO_DATA))
with open(UMOFILE, 'wb') as fp:
- fp.write(base64.decodestring(UMO_DATA))
+ fp.write(base64.decodebytes(UMO_DATA))
with open(MMOFILE, 'wb') as fp:
- fp.write(base64.decodestring(MMO_DATA))
-
- self.env = test_support.EnvironmentVarGuard()
+ fp.write(base64.decodebytes(MMO_DATA))
+ self.env = support.EnvironmentVarGuard()
self.env['LANGUAGE'] = 'xx'
gettext._translations.clear()
@@ -92,33 +91,33 @@ class GettextTestCase1(GettextBaseTest):
eq = self.assertEqual
# test some translations
eq(_('albatross'), 'albatross')
- eq(_(u'mullusk'), 'bacon')
+ eq(_('mullusk'), 'bacon')
eq(_(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
- eq(_(ur'nudge nudge'), 'wink wink')
+ eq(_(r'nudge nudge'), 'wink wink')
def test_double_quotes(self):
eq = self.assertEqual
# double quotes
eq(_("albatross"), 'albatross')
- eq(_(u"mullusk"), 'bacon')
+ eq(_("mullusk"), 'bacon')
eq(_(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
- eq(_(ur"nudge nudge"), 'wink wink')
+ eq(_(r"nudge nudge"), 'wink wink')
def test_triple_single_quotes(self):
eq = self.assertEqual
# triple single quotes
eq(_('''albatross'''), 'albatross')
- eq(_(u'''mullusk'''), 'bacon')
+ eq(_('''mullusk'''), 'bacon')
eq(_(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
- eq(_(ur'''nudge nudge'''), 'wink wink')
+ eq(_(r'''nudge nudge'''), 'wink wink')
def test_triple_double_quotes(self):
eq = self.assertEqual
# triple double quotes
eq(_("""albatross"""), 'albatross')
- eq(_(u"""mullusk"""), 'bacon')
+ eq(_("""mullusk"""), 'bacon')
eq(_(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
- eq(_(ur"""nudge nudge"""), 'wink wink')
+ eq(_(r"""nudge nudge"""), 'wink wink')
def test_multiline_strings(self):
eq = self.assertEqual
@@ -139,16 +138,16 @@ trggrkg zrffntr pngnybt yvoenel.''')
t.install()
eq(_('nudge nudge'), 'wink wink')
# Try unicode return type
- t.install(unicode=True)
+ t.install()
eq(_('mullusk'), 'bacon')
# Test installation of other methods
- import __builtin__
- t.install(unicode=True, names=["gettext", "lgettext"])
- eq(_, t.ugettext)
- eq(__builtin__.gettext, t.ugettext)
+ import builtins
+ t.install(names=["gettext", "lgettext"])
+ eq(_, t.gettext)
+ eq(builtins.gettext, t.gettext)
eq(lgettext, t.lgettext)
- del __builtin__.gettext
- del __builtin__.lgettext
+ del builtins.gettext
+ del builtins.lgettext
class GettextTestCase2(GettextBaseTest):
@@ -171,33 +170,33 @@ class GettextTestCase2(GettextBaseTest):
eq = self.assertEqual
# test some translations
eq(self._('albatross'), 'albatross')
- eq(self._(u'mullusk'), 'bacon')
+ eq(self._('mullusk'), 'bacon')
eq(self._(r'Raymond Luxury Yach-t'), 'Throatwobbler Mangrove')
- eq(self._(ur'nudge nudge'), 'wink wink')
+ eq(self._(r'nudge nudge'), 'wink wink')
def test_double_quotes(self):
eq = self.assertEqual
# double quotes
eq(self._("albatross"), 'albatross')
- eq(self._(u"mullusk"), 'bacon')
+ eq(self._("mullusk"), 'bacon')
eq(self._(r"Raymond Luxury Yach-t"), 'Throatwobbler Mangrove')
- eq(self._(ur"nudge nudge"), 'wink wink')
+ eq(self._(r"nudge nudge"), 'wink wink')
def test_triple_single_quotes(self):
eq = self.assertEqual
# triple single quotes
eq(self._('''albatross'''), 'albatross')
- eq(self._(u'''mullusk'''), 'bacon')
+ eq(self._('''mullusk'''), 'bacon')
eq(self._(r'''Raymond Luxury Yach-t'''), 'Throatwobbler Mangrove')
- eq(self._(ur'''nudge nudge'''), 'wink wink')
+ eq(self._(r'''nudge nudge'''), 'wink wink')
def test_triple_double_quotes(self):
eq = self.assertEqual
# triple double quotes
eq(self._("""albatross"""), 'albatross')
- eq(self._(u"""mullusk"""), 'bacon')
+ eq(self._("""mullusk"""), 'bacon')
eq(self._(r"""Raymond Luxury Yach-t"""), 'Throatwobbler Mangrove')
- eq(self._(ur"""nudge nudge"""), 'wink wink')
+ eq(self._(r"""nudge nudge"""), 'wink wink')
def test_multiline_strings(self):
eq = self.assertEqual
@@ -297,16 +296,16 @@ class UnicodeTranslationsTest(GettextBaseTest):
GettextBaseTest.setUp(self)
with open(UMOFILE, 'rb') as fp:
self.t = gettext.GNUTranslations(fp)
- self._ = self.t.ugettext
+ self._ = self.t.gettext
def test_unicode_msgid(self):
unless = self.assertTrue
- unless(isinstance(self._(''), unicode))
- unless(isinstance(self._(u''), unicode))
+ unless(isinstance(self._(''), str))
+ unless(isinstance(self._(''), str))
def test_unicode_msgstr(self):
eq = self.assertEqual
- eq(self._(u'ab\xde'), u'\xa4yz')
+ eq(self._('ab\xde'), '\xa4yz')
class WeirdMetadataTest(GettextBaseTest):
@@ -321,6 +320,7 @@ class WeirdMetadataTest(GettextBaseTest):
def test_weird_metadata(self):
info = self.t.info()
+ self.assertEqual(len(info), 9)
self.assertEqual(info['last-translator'],
'John Doe <jdoe@example.com>\nJane Foobar <jfoobar@example.com>')
@@ -357,7 +357,7 @@ class GettextCacheTestCase(GettextBaseTest):
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_gl.py b/Lib/test/test_gl.py
deleted file mode 100755
index c9264ee6bcb..00000000000
--- a/Lib/test/test_gl.py
+++ /dev/null
@@ -1,155 +0,0 @@
-#! /usr/bin/env python
-"""Very simple test script for the SGI gl library extension module
- taken mostly from the documentation.
- Roger E. Masse
-"""
-import unittest
-from test.test_support import verbose, import_module
-import time
-gl = import_module('gl')
-GL = import_module('GL')
-
-glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
-'__doc__', '__name__', 'addtopup', 'altgetmatrix', 'arc', 'arcf',
-'arcfi', 'arcfs', 'arci', 'arcs', 'attachcursor', 'backbuffer',
-'backface', 'bbox2', 'bbox2i', 'bbox2s', 'bgnclosedline', 'bgnline',
-'bgnpoint', 'bgnpolygon', 'bgnsurface', 'bgntmesh', 'bgntrim',
-'blankscreen', 'blanktime', 'blendfunction', 'blink', 'c3f', 'c3i',
-'c3s', 'c4f', 'c4i', 'c4s', 'callobj', 'charstr', 'chunksize', 'circ',
-'circf', 'circfi', 'circfs', 'circi', 'circs', 'clear',
-'clearhitcode', 'clkoff', 'clkon', 'closeobj', 'cmode', 'cmov',
-'cmov2', 'cmov2i', 'cmov2s', 'cmovi', 'cmovs', 'color', 'colorf',
-'compactify', 'concave', 'cpack', 'crv', 'crvn', 'curorigin',
-'cursoff', 'curson', 'curstype', 'curvebasis', 'curveit',
-'curveprecision', 'cyclemap', 'czclear', 'defbasis', 'defcursor',
-'deflinestyle', 'delobj', 'deltag', 'depthcue', 'devport', 'dglclose',
-'dglopen', 'dither', 'dopup', 'doublebuffer', 'draw', 'draw2',
-'draw2i', 'draw2s', 'drawi', 'drawmode', 'draws', 'editobj',
-'endclosedline', 'endfullscrn', 'endline', 'endpick', 'endpoint',
-'endpolygon', 'endpupmode', 'endselect', 'endsurface', 'endtmesh',
-'endtrim', 'finish', 'font', 'foreground', 'freepup', 'frontbuffer',
-'fudge', 'fullscrn', 'gRGBcolor', 'gRGBmask', 'gammaramp', 'gbegin',
-'gconfig', 'genobj', 'gentag', 'getbackface', 'getbuffer',
-'getbutton', 'getcmmode', 'getcolor', 'getcpos', 'getcursor',
-'getdcm', 'getdepth', 'getdescender', 'getdisplaymode', 'getdrawmode',
-'getfont', 'getgdesc', 'getgpos', 'getheight', 'gethitcode',
-'getlsbackup', 'getlsrepeat', 'getlstyle', 'getlwidth', 'getmap',
-'getmatrix', 'getmcolor', 'getmmode', 'getmonitor',
-'getnurbsproperty', 'getopenobj', 'getorigin', 'getothermonitor',
-'getpattern', 'getplanes', 'getport', 'getresetls', 'getscrmask',
-'getshade', 'getsize', 'getsm', 'gettp', 'getvaluator', 'getvideo',
-'getviewport', 'getwritemask', 'getzbuffer', 'gewrite', 'gflush',
-'ginit', 'glcompat', 'greset', 'gselect', 'gsync', 'gversion',
-'iconsize', 'icontitle', 'imakebackground', 'initnames', 'ismex',
-'isobj', 'isqueued', 'istag', 'keepaspect', 'lRGBrange', 'lampoff',
-'lampon', 'linesmooth', 'linewidth', 'lmbind', 'lmcolor', 'lmdef',
-'loadmatrix', 'loadname', 'logicop', 'lookat', 'lrectread',
-'lrectwrite', 'lsbackup', 'lsetdepth', 'lshaderange', 'lsrepeat',
-'makeobj', 'maketag', 'mapcolor', 'mapw', 'mapw2', 'maxsize',
-'minsize', 'mmode', 'move', 'move2', 'move2i', 'move2s', 'movei',
-'moves', 'multimap', 'multmatrix', 'n3f', 'newpup', 'newtag',
-'noborder', 'noise', 'noport', 'normal', 'nurbscurve', 'nurbssurface',
-'nvarray', 'objdelete', 'objinsert', 'objreplace', 'onemap', 'ortho',
-'ortho2', 'overlay', 'packrect', 'pagecolor', 'pagewritemask',
-'passthrough', 'patch', 'patchbasis', 'patchcurves', 'patchprecision',
-'pclos', 'pdr', 'pdr2', 'pdr2i', 'pdr2s', 'pdri', 'pdrs',
-'perspective', 'pick', 'picksize', 'pixmode', 'pmv', 'pmv2', 'pmv2i',
-'pmv2s', 'pmvi', 'pmvs', 'pnt', 'pnt2', 'pnt2i', 'pnt2s', 'pnti',
-'pnts', 'pntsmooth', 'polarview', 'polf', 'polf2', 'polf2i', 'polf2s',
-'polfi', 'polfs', 'poly', 'poly2', 'poly2i', 'poly2s', 'polyi',
-'polys', 'popattributes', 'popmatrix', 'popname', 'popviewport',
-'prefposition', 'prefsize', 'pupmode', 'pushattributes', 'pushmatrix',
-'pushname', 'pushviewport', 'pwlcurve', 'qdevice', 'qenter', 'qgetfd',
-'qread', 'qreset', 'qtest', 'rcrv', 'rcrvn', 'rdr', 'rdr2', 'rdr2i',
-'rdr2s', 'rdri', 'rdrs', 'readdisplay', 'readsource', 'rect',
-'rectcopy', 'rectf', 'rectfi', 'rectfs', 'recti', 'rects', 'rectzoom',
-'resetls', 'reshapeviewport', 'ringbell', 'rmv', 'rmv2', 'rmv2i',
-'rmv2s', 'rmvi', 'rmvs', 'rot', 'rotate', 'rpatch', 'rpdr', 'rpdr2',
-'rpdr2i', 'rpdr2s', 'rpdri', 'rpdrs', 'rpmv', 'rpmv2', 'rpmv2i',
-'rpmv2s', 'rpmvi', 'rpmvs', 'sbox', 'sboxf', 'sboxfi', 'sboxfs',
-'sboxi', 'sboxs', 'scale', 'screenspace', 'scrmask', 'setbell',
-'setcursor', 'setdepth', 'setlinestyle', 'setmap', 'setmonitor',
-'setnurbsproperty', 'setpattern', 'setpup', 'setshade', 'setvaluator',
-'setvideo', 'shademodel', 'shaderange', 'singlebuffer', 'smoothline',
-'spclos', 'splf', 'splf2', 'splf2i', 'splf2s', 'splfi', 'splfs',
-'stepunit', 'strwidth', 'subpixel', 'swapbuffers', 'swapinterval',
-'swaptmesh', 'swinopen', 'textcolor', 'textinit', 'textport',
-'textwritemask', 'tie', 'tpoff', 'tpon', 'translate', 'underlay',
-'unpackrect', 'unqdevice', 'v2d', 'v2f', 'v2i', 'v2s', 'v3d', 'v3f',
-'v3i', 'v3s', 'v4d', 'v4f', 'v4i', 'v4s', 'varray', 'videocmd',
-'viewport', 'vnarray', 'winattach', 'winclose', 'winconstraints',
-'windepth', 'window', 'winget', 'winmove', 'winopen', 'winpop',
-'winposition', 'winpush', 'winset', 'wintitle', 'wmpack', 'writemask',
-'writepixels', 'xfpt', 'xfpt2', 'xfpt2i', 'xfpt2s', 'xfpt4', 'xfpt4i',
-'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction',
-'zsource', 'zwritemask']
-
-def test_main():
- # insure that we at least have an X display before continuing.
- import os
- try:
- display = os.environ['DISPLAY']
- except:
- raise unittest.SkipTest, "No $DISPLAY -- skipping gl test"
-
- # touch all the attributes of gl without doing anything
- if verbose:
- print 'Touching gl module attributes...'
- for attr in glattrs:
- if verbose:
- print 'touching: ', attr
- getattr(gl, attr)
-
- # create a small 'Crisscross' window
- if verbose:
- print 'Creating a small "CrissCross" window...'
- print 'foreground'
- gl.foreground()
- if verbose:
- print 'prefposition'
- gl.prefposition(500, 900, 500, 900)
- if verbose:
- print 'winopen "CrissCross"'
- w = gl.winopen('CrissCross')
- if verbose:
- print 'clear'
- gl.clear()
- if verbose:
- print 'ortho2'
- gl.ortho2(0.0, 400.0, 0.0, 400.0)
- if verbose:
- print 'color WHITE'
- gl.color(GL.WHITE)
- if verbose:
- print 'color RED'
- gl.color(GL.RED)
- if verbose:
- print 'bgnline'
- gl.bgnline()
- if verbose:
- print 'v2f'
- gl.v2f(0.0, 0.0)
- gl.v2f(400.0, 400.0)
- if verbose:
- print 'endline'
- gl.endline()
- if verbose:
- print 'bgnline'
- gl.bgnline()
- if verbose:
- print 'v2i'
- gl.v2i(400, 0)
- gl.v2i(0, 400)
- if verbose:
- print 'endline'
- gl.endline()
- if verbose:
- print 'Displaying window for 2 seconds...'
- time.sleep(2)
- if verbose:
- print 'winclose'
- gl.winclose(w)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_glob.py b/Lib/test/test_glob.py
index b360d09dfa6..1cdc24acf2d 100644
--- a/Lib/test/test_glob.py
+++ b/Lib/test/test_glob.py
@@ -4,11 +4,7 @@ import shutil
import sys
import unittest
-from test.test_support import run_unittest, TESTFN
-
-
-def fsdecode(s):
- return unicode(s, sys.getfilesystemencoding())
+from test.support import run_unittest, TESTFN, skip_unless_symlink, can_symlink
class GlobTests(unittest.TestCase):
@@ -34,7 +30,7 @@ class GlobTests(unittest.TestCase):
self.mktemp('ZZZ')
self.mktemp('a', 'bcd', 'EF')
self.mktemp('a', 'bcd', 'efg', 'ha')
- if hasattr(os, 'symlink'):
+ if can_symlink():
os.symlink(self.norm('broken'), self.norm('sym1'))
os.symlink('broken', self.norm('sym2'))
os.symlink(os.path.join('a', 'bcd'), self.norm('sym3'))
@@ -50,9 +46,9 @@ class GlobTests(unittest.TestCase):
p = os.path.join(self.tempdir, pattern)
res = glob.glob(p)
self.assertEqual(list(glob.iglob(p)), res)
- ures = [fsdecode(x) for x in res]
- self.assertEqual(glob.glob(fsdecode(p)), ures)
- self.assertEqual(list(glob.iglob(fsdecode(p))), ures)
+ bres = [os.fsencode(x) for x in res]
+ self.assertEqual(glob.glob(os.fsencode(p)), bres)
+ self.assertEqual(list(glob.iglob(os.fsencode(p))), bres)
return res
def assertSequencesEqual_noorder(self, l1, l2):
@@ -73,14 +69,10 @@ class GlobTests(unittest.TestCase):
res = glob.glob(os.path.join(os.curdir, '*'))
self.assertEqual({type(r) for r in res}, {str})
- # test return types are unicode, but only if os.listdir
- # returns unicode filenames
- tmp = os.listdir(fsdecode(os.curdir))
- if {type(x) for x in tmp} == {unicode}:
- res = glob.glob(u'*')
- self.assertEqual({type(r) for r in res}, {unicode})
- res = glob.glob(os.path.join(fsdecode(os.curdir), u'*'))
- self.assertEqual({type(r) for r in res}, {unicode})
+ res = glob.glob(b'*')
+ self.assertEqual({type(r) for r in res}, {bytes})
+ res = glob.glob(os.path.join(os.fsencode(os.curdir), b'*'))
+ self.assertEqual({type(r) for r in res}, {bytes})
def test_glob_one_directory(self):
eq = self.assertSequencesEqual_noorder
@@ -128,23 +120,24 @@ class GlobTests(unittest.TestCase):
{self.norm('aaa') + os.sep, self.norm('aab') + os.sep},
])
- def test_glob_unicode_directory_with_trailing_slash(self):
- # Same as test_glob_directory_with_trailing_slash, but with an
- # unicode argument.
- res = glob.glob(fsdecode(self.norm('Z*Z') + os.sep))
+ def test_glob_bytes_directory_with_trailing_slash(self):
+ # Same as test_glob_directory_with_trailing_slash, but with a
+ # bytes argument.
+ res = glob.glob(os.fsencode(self.norm('Z*Z') + os.sep))
self.assertEqual(res, [])
- res = glob.glob(fsdecode(self.norm('ZZZ') + os.sep))
+ res = glob.glob(os.fsencode(self.norm('ZZZ') + os.sep))
self.assertEqual(res, [])
- res = glob.glob(fsdecode(self.norm('aa*') + os.sep))
+ res = glob.glob(os.fsencode(self.norm('aa*') + os.sep))
self.assertEqual(len(res), 2)
# either of these results is reasonable
self.assertIn(set(res), [
- {fsdecode(self.norm('aaa')), fsdecode(self.norm('aab'))},
- {fsdecode(self.norm('aaa') + os.sep),
- fsdecode(self.norm('aab') + os.sep)},
+ {os.fsencode(self.norm('aaa')),
+ os.fsencode(self.norm('aab'))},
+ {os.fsencode(self.norm('aaa') + os.sep),
+ os.fsencode(self.norm('aab') + os.sep)},
])
- @unittest.skipUnless(hasattr(os, 'symlink'), "Requires symlink support")
+ @skip_unless_symlink
def test_glob_symlinks(self):
eq = self.assertSequencesEqual_noorder
eq(self.glob('sym3'), [self.norm('sym3')])
@@ -153,10 +146,10 @@ class GlobTests(unittest.TestCase):
self.assertIn(self.glob('sym3' + os.sep),
[[self.norm('sym3')], [self.norm('sym3') + os.sep]])
eq(self.glob('*', '*F'),
- [self.norm('aaa', 'zzzF'), self.norm('aab', 'F'),
- self.norm('sym3', 'EF')])
+ [self.norm('aaa', 'zzzF'),
+ self.norm('aab', 'F'), self.norm('sym3', 'EF')])
- @unittest.skipUnless(hasattr(os, 'symlink'), "Requires symlink support")
+ @skip_unless_symlink
def test_glob_broken_symlinks(self):
eq = self.assertSequencesEqual_noorder
eq(self.glob('sym*'), [self.norm('sym1'), self.norm('sym2'),
@@ -168,9 +161,13 @@ class GlobTests(unittest.TestCase):
def test_glob_magic_in_drive(self):
eq = self.assertSequencesEqual_noorder
eq(glob.glob('*:'), [])
- eq(glob.glob(u'*:'), [])
+ eq(glob.glob(b'*:'), [])
eq(glob.glob('?:'), [])
- eq(glob.glob(u'?:'), [])
+ eq(glob.glob(b'?:'), [])
+ eq(glob.glob('\\\\?\\c:\\'), ['\\\\?\\c:\\'])
+ eq(glob.glob(b'\\\\?\\c:\\'), [b'\\\\?\\c:\\'])
+ eq(glob.glob('\\\\*\\*\\'), [])
+ eq(glob.glob(b'\\\\*\\*\\'), [])
def test_main():
diff --git a/Lib/test/test_global.py b/Lib/test/test_global.py
index abcb193e5ee..37ec67255a5 100644
--- a/Lib/test/test_global.py
+++ b/Lib/test/test_global.py
@@ -1,12 +1,21 @@
"""Verify that warnings are issued for global statements following use."""
-from test.test_support import run_unittest, check_syntax_error
+from test.support import run_unittest, check_syntax_error, check_warnings
import unittest
import warnings
class GlobalTests(unittest.TestCase):
+ def setUp(self):
+ self._warnings_manager = check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("error", module="<test string>")
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+
def test1(self):
prog_text_1 = """\
def wrong1():
@@ -20,7 +29,7 @@ def wrong1():
def test2(self):
prog_text_2 = """\
def wrong2():
- print x
+ print(x)
global x
"""
check_syntax_error(self, prog_text_2)
@@ -28,7 +37,7 @@ def wrong2():
def test3(self):
prog_text_3 = """\
def wrong3():
- print x
+ print(x)
x = 2
global x
"""
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 86cc0843eef..268a633b2c7 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1,8 +1,7 @@
# Python test set -- part 1, grammar.
# This just tests whether the parser accepts them all.
-from test.test_support import run_unittest, check_syntax_error, \
- check_py3k_warnings
+from test.support import run_unittest, check_syntax_error
import unittest
import sys
# testing import *
@@ -22,44 +21,50 @@ class TokenTests(unittest.TestCase):
self.assertEqual(x, 0, 'backslash ending comment')
def testPlainIntegers(self):
+ self.assertEqual(type(000), type(0))
self.assertEqual(0xff, 255)
- self.assertEqual(0377, 255)
- self.assertEqual(2147483647, 017777777777)
+ self.assertEqual(0o377, 255)
+ self.assertEqual(2147483647, 0o17777777777)
+ self.assertEqual(0b1001, 9)
# "0x" is not a valid literal
self.assertRaises(SyntaxError, eval, "0x")
- from sys import maxint
- if maxint == 2147483647:
- self.assertEqual(-2147483647-1, -020000000000)
+ from sys import maxsize
+ if maxsize == 2147483647:
+ self.assertEqual(-2147483647-1, -0o20000000000)
# XXX -2147483648
- self.assertTrue(037777777777 > 0)
+ self.assertTrue(0o37777777777 > 0)
self.assertTrue(0xffffffff > 0)
- for s in '2147483648', '040000000000', '0x100000000':
+ self.assertTrue(0b1111111111111111111111111111111 > 0)
+ for s in ('2147483648', '0o40000000000', '0x100000000',
+ '0b10000000000000000000000000000000'):
try:
x = eval(s)
except OverflowError:
self.fail("OverflowError on huge integer literal %r" % s)
- elif maxint == 9223372036854775807:
- self.assertEqual(-9223372036854775807-1, -01000000000000000000000)
- self.assertTrue(01777777777777777777777 > 0)
+ elif maxsize == 9223372036854775807:
+ self.assertEqual(-9223372036854775807-1, -0o1000000000000000000000)
+ self.assertTrue(0o1777777777777777777777 > 0)
self.assertTrue(0xffffffffffffffff > 0)
- for s in '9223372036854775808', '02000000000000000000000', \
- '0x10000000000000000':
+ self.assertTrue(0b11111111111111111111111111111111111111111111111111111111111111 > 0)
+ for s in '9223372036854775808', '0o2000000000000000000000', \
+ '0x10000000000000000', \
+ '0b100000000000000000000000000000000000000000000000000000000000000':
try:
x = eval(s)
except OverflowError:
self.fail("OverflowError on huge integer literal %r" % s)
else:
- self.fail('Weird maxint value %r' % maxint)
+ self.fail('Weird maxsize value %r' % maxsize)
def testLongIntegers(self):
- x = 0L
- x = 0l
- x = 0xffffffffffffffffL
- x = 0xffffffffffffffffl
- x = 077777777777777777L
- x = 077777777777777777l
- x = 123456789012345678901234567890L
- x = 123456789012345678901234567890l
+ x = 0
+ x = 0xffffffffffffffff
+ x = 0Xffffffffffffffff
+ x = 0o77777777777777777
+ x = 0O77777777777777777
+ x = 123456789012345678901234567890
+ x = 0b100000000000000000000000000000000000000000000000000000000000000000000
+ x = 0B111111111111111111111111111111111111111111111111111111111111111111111
def testFloats(self):
x = 3.14
@@ -115,6 +120,10 @@ the \'lazy\' dog.\n\
'
self.assertEqual(x, y)
+ def testEllipsis(self):
+ x = ...
+ self.assertTrue(x is Ellipsis)
+ self.assertRaises(SyntaxError, eval, ".. .")
class GrammarTests(unittest.TestCase):
@@ -132,51 +141,37 @@ class GrammarTests(unittest.TestCase):
x = eval('1, 0 or 1')
def testFuncdef(self):
- ### 'def' NAME parameters ':' suite
- ### parameters: '(' [varargslist] ')'
- ### varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' ('**'|'*' '*') NAME]
- ### | ('**'|'*' '*') NAME)
- ### | fpdef ['=' test] (',' fpdef ['=' test])* [',']
- ### fpdef: NAME | '(' fplist ')'
- ### fplist: fpdef (',' fpdef)* [',']
- ### arglist: (argument ',')* (argument | *' test [',' '**' test] | '**' test)
- ### argument: [test '='] test # Really [keyword '='] test
+ ### [decorators] 'def' NAME parameters ['->' test] ':' suite
+ ### decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
+ ### decorators: decorator+
+ ### parameters: '(' [typedargslist] ')'
+ ### typedargslist: ((tfpdef ['=' test] ',')*
+ ### ('*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
+ ### | tfpdef ['=' test] (',' tfpdef ['=' test])* [','])
+ ### tfpdef: NAME [':' test]
+ ### varargslist: ((vfpdef ['=' test] ',')*
+ ### ('*' [vfpdef] (',' vfpdef ['=' test])* [',' '**' vfpdef] | '**' vfpdef)
+ ### | vfpdef ['=' test] (',' vfpdef ['=' test])* [','])
+ ### vfpdef: NAME
def f1(): pass
f1()
f1(*())
f1(*(), **{})
def f2(one_argument): pass
def f3(two, arguments): pass
- # Silence Py3k warning
- exec('def f4(two, (compound, (argument, list))): pass')
- exec('def f5((compound, first), two): pass')
- self.assertEqual(f2.func_code.co_varnames, ('one_argument',))
- self.assertEqual(f3.func_code.co_varnames, ('two', 'arguments'))
- if sys.platform.startswith('java'):
- self.assertEqual(f4.func_code.co_varnames,
- ('two', '(compound, (argument, list))', 'compound', 'argument',
- 'list',))
- self.assertEqual(f5.func_code.co_varnames,
- ('(compound, first)', 'two', 'compound', 'first'))
- else:
- self.assertEqual(f4.func_code.co_varnames,
- ('two', '.1', 'compound', 'argument', 'list'))
- self.assertEqual(f5.func_code.co_varnames,
- ('.0', 'two', 'compound', 'first'))
+ self.assertEqual(f2.__code__.co_varnames, ('one_argument',))
+ self.assertEqual(f3.__code__.co_varnames, ('two', 'arguments'))
def a1(one_arg,): pass
def a2(two, args,): pass
def v0(*rest): pass
def v1(a, *rest): pass
def v2(a, b, *rest): pass
- # Silence Py3k warning
- exec('def v3(a, (b, c), *rest): return a, b, c, rest')
f1()
f2(1)
f2(1,)
f3(1, 2)
f3(1, 2,)
- f4(1, (2, (3, 4)))
v0()
v0(1)
v0(1,)
@@ -191,17 +186,7 @@ class GrammarTests(unittest.TestCase):
v2(1,2,3)
v2(1,2,3,4)
v2(1,2,3,4,5,6,7,8,9,0)
- v3(1,(2,3))
- v3(1,(2,3),4)
- v3(1,(2,3),4,5,6,7,8,9,0)
-
- # ceval unpacks the formal arguments into the first argcount names;
- # thus, the names nested inside tuples must appear after these names.
- if sys.platform.startswith('java'):
- self.assertEqual(v3.func_code.co_varnames, ('a', '(b, c)', 'rest', 'b', 'c'))
- else:
- self.assertEqual(v3.func_code.co_varnames, ('a', '.1', 'rest', 'b', 'c'))
- self.assertEqual(v3(1, (2, 3), 4), (1, 2, 3, (4,)))
+
def d01(a=1): pass
d01()
d01(1)
@@ -274,11 +259,24 @@ class GrammarTests(unittest.TestCase):
d22v(*(1, 2, 3, 4))
d22v(1, 2, *(3, 4, 5))
d22v(1, *(2, 3), **{'d': 4})
- # Silence Py3k warning
- exec('def d31v((x)): pass')
- exec('def d32v((x,)): pass')
- d31v(1)
- d32v((1,))
+
+ # keyword argument type tests
+ try:
+ str('x', **{b'foo':1 })
+ except TypeError:
+ pass
+ else:
+ self.fail('Bytes should not work as keyword argument names')
+ # keyword only argument tests
+ def pos0key1(*, key): return key
+ pos0key1(key=100)
+ def pos2key2(p1, p2, *, k1, k2=100): return p1,p2,k1,k2
+ pos2key2(1, 2, k1=100)
+ pos2key2(1, 2, k1=100, k2=200)
+ pos2key2(1, 2, k2=100, k1=200)
+ def pos2key2dict(p1, p2, *, k1=100, k2, **kwarg): return p1,p2,k1,k2,kwarg
+ pos2key2dict(1,2,k2=100,tokwarg1=100,tokwarg2=200)
+ pos2key2dict(1,2,tokwarg1=100,tokwarg2=200, k2=100)
# keyword arguments after *arglist
def f(*args, **kwargs):
@@ -288,6 +286,40 @@ class GrammarTests(unittest.TestCase):
self.assertRaises(SyntaxError, eval, "f(1, *(2,3), 4)")
self.assertRaises(SyntaxError, eval, "f(1, x=2, *(3,4), x=5)")
+ # argument annotation tests
+ def f(x) -> list: pass
+ self.assertEqual(f.__annotations__, {'return': list})
+ def f(x:int): pass
+ self.assertEqual(f.__annotations__, {'x': int})
+ def f(*x:str): pass
+ self.assertEqual(f.__annotations__, {'x': str})
+ def f(**x:float): pass
+ self.assertEqual(f.__annotations__, {'x': float})
+ def f(x, y:1+2): pass
+ self.assertEqual(f.__annotations__, {'y': 3})
+ def f(a, b:1, c:2, d): pass
+ self.assertEqual(f.__annotations__, {'b': 1, 'c': 2})
+ def f(a, b:1, c:2, d, e:3=4, f=5, *g:6): pass
+ self.assertEqual(f.__annotations__,
+ {'b': 1, 'c': 2, 'e': 3, 'g': 6})
+ def f(a, b:1, c:2, d, e:3=4, f=5, *g:6, h:7, i=8, j:9=10,
+ **k:11) -> 12: pass
+ self.assertEqual(f.__annotations__,
+ {'b': 1, 'c': 2, 'e': 3, 'g': 6, 'h': 7, 'j': 9,
+ 'k': 11, 'return': 12})
+ # Check for SF Bug #1697248 - mixing decorators and a return annotation
+ def null(x): return x
+ @null
+ def f(x) -> list: pass
+ self.assertEqual(f.__annotations__, {'return': list})
+
+ # test MAKE_CLOSURE with a variety of oparg's
+ closure = 1
+ def f(): return closure
+ def f(x=1): return closure
+ def f(*, k=1): return closure
+ def f() -> int: return closure
+
# Check ast errors in *args and *kwargs
check_syntax_error(self, "f(*g(1=2))")
check_syntax_error(self, "f(**g(1=2))")
@@ -297,7 +329,7 @@ class GrammarTests(unittest.TestCase):
l1 = lambda : 0
self.assertEqual(l1(), 0)
l2 = lambda : a[d] # XXX just testing the expression
- l3 = lambda : [2 < x for x in [-1, 3, 0L]]
+ l3 = lambda : [2 < x for x in [-1, 3, 0]]
self.assertEqual(l3(), [0, 1, 0])
l4 = lambda x = lambda y = lambda z=1 : z : y() : x()
self.assertEqual(l4(), 1)
@@ -306,6 +338,10 @@ class GrammarTests(unittest.TestCase):
self.assertEqual(l5(1, 2, 3), 6)
check_syntax_error(self, "lambda x: x = 2")
check_syntax_error(self, "lambda (None,): None")
+ l6 = lambda x, y, *, k=20: x+y+k
+ self.assertEqual(l6(1,2), 1+2+20)
+ self.assertEqual(l6(1,2,k=10), 1+2+10)
+
### stmt: simple_stmt | compound_stmt
# Tested below
@@ -318,7 +354,7 @@ class GrammarTests(unittest.TestCase):
x = 1; pass; del x;
foo()
- ### small_stmt: expr_stmt | print_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt | exec_stmt
+ ### small_stmt: expr_stmt | pass_stmt | del_stmt | flow_stmt | import_stmt | global_stmt | access_stmt
# Tested below
def testExprStmt(self):
@@ -334,76 +370,6 @@ class GrammarTests(unittest.TestCase):
check_syntax_error(self, "x + 1 = 1")
check_syntax_error(self, "a + 1 = b + 2")
- def testPrintStmt(self):
- # 'print' (test ',')* [test]
- import StringIO
-
- # Can't test printing to real stdout without comparing output
- # which is not available in unittest.
- save_stdout = sys.stdout
- sys.stdout = StringIO.StringIO()
-
- print 1, 2, 3
- print 1, 2, 3,
- print
- print 0 or 1, 0 or 1,
- print 0 or 1
-
- # 'print' '>>' test ','
- print >> sys.stdout, 1, 2, 3
- print >> sys.stdout, 1, 2, 3,
- print >> sys.stdout
- print >> sys.stdout, 0 or 1, 0 or 1,
- print >> sys.stdout, 0 or 1
-
- # test printing to an instance
- class Gulp:
- def write(self, msg): pass
-
- gulp = Gulp()
- print >> gulp, 1, 2, 3
- print >> gulp, 1, 2, 3,
- print >> gulp
- print >> gulp, 0 or 1, 0 or 1,
- print >> gulp, 0 or 1
-
- # test print >> None
- def driver():
- oldstdout = sys.stdout
- sys.stdout = Gulp()
- try:
- tellme(Gulp())
- tellme()
- finally:
- sys.stdout = oldstdout
-
- # we should see this once
- def tellme(file=sys.stdout):
- print >> file, 'hello world'
-
- driver()
-
- # we should not see this at all
- def tellme(file=None):
- print >> file, 'goodbye universe'
-
- driver()
-
- self.assertEqual(sys.stdout.getvalue(), '''\
-1 2 3
-1 2 3
-1 1 1
-1 2 3
-1 2 3
-1 1 1
-hello world
-''')
- sys.stdout = save_stdout
-
- # syntax errors
- check_syntax_error(self, 'print ,')
- check_syntax_error(self, 'print >> x,')
-
def testDelStmt(self):
# 'del' exprlist
abc = [1,2,3]
@@ -489,7 +455,7 @@ hello world
def testRaise(self):
# 'raise' test [',' test]
- try: raise RuntimeError, 'just testing'
+ try: raise RuntimeError('just testing')
except RuntimeError: pass
try: raise KeyboardInterrupt
except KeyboardInterrupt: pass
@@ -513,37 +479,13 @@ hello world
global a, b
global one, two, three, four, five, six, seven, eight, nine, ten
- def testExec(self):
- # 'exec' expr ['in' expr [',' expr]]
- z = None
- del z
- exec 'z=1+1\n'
- if z != 2: self.fail('exec \'z=1+1\'\\n')
- del z
- exec 'z=1+1'
- if z != 2: self.fail('exec \'z=1+1\'')
- z = None
- del z
- import types
- if hasattr(types, "UnicodeType"):
- exec r"""if 1:
- exec u'z=1+1\n'
- if z != 2: self.fail('exec u\'z=1+1\'\\n')
- del z
- exec u'z=1+1'
- if z != 2: self.fail('exec u\'z=1+1\'')"""
- g = {}
- exec 'z = 1' in g
- if '__builtins__' in g: del g['__builtins__']
- if g != {'z': 1}: self.fail('exec \'z = 1\' in g')
- g = {}
- l = {}
-
- exec 'global a; a = 1; b = 2' in g, l
- if '__builtins__' in g: del g['__builtins__']
- if '__builtins__' in l: del l['__builtins__']
- if (g, l) != ({'a':1}, {'b':2}):
- self.fail('exec ... in g (%s), l (%s)' %(g,l))
+ def testNonlocal(self):
+ # 'nonlocal' NAME (',' NAME)*
+ x = 0
+ y = 0
+ def f():
+ nonlocal x
+ nonlocal x, y
def testAssert(self):
# assertTruestmt: 'assert' test [',' test]
@@ -568,7 +510,7 @@ hello world
def testAssert2(self):
try:
assert 0, "msg"
- except AssertionError, e:
+ except AssertionError as e:
self.assertEqual(e.args[0], "msg")
else:
self.fail("AssertionError not raised by assert 0")
@@ -642,7 +584,7 @@ hello world
def testTry(self):
### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
### | 'try' ':' suite 'finally' ':' suite
- ### except_clause: 'except' [expr [('as' | ',') expr]]
+ ### except_clause: 'except' [expr ['as' expr]]
try:
1/0
except ZeroDivisionError:
@@ -652,13 +594,13 @@ hello world
try: 1/0
except EOFError: pass
except TypeError as msg: pass
- except RuntimeError, msg: pass
+ except RuntimeError as msg: pass
except: pass
else: pass
try: 1/0
except (EOFError, TypeError, ZeroDivisionError): pass
try: 1/0
- except (EOFError, TypeError, ZeroDivisionError), msg: pass
+ except (EOFError, TypeError, ZeroDivisionError) as msg: pass
try: pass
finally: pass
@@ -690,7 +632,7 @@ hello world
def testComparison(self):
### comparison: expr (comp_op expr)*
- ### comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
+ ### comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not'
if 1: pass
x = (1 == 1)
if 1 == 1: pass
@@ -704,9 +646,6 @@ hello world
if 1 in (): pass
if 1 not in (): pass
if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
- # Silence Py3k warning
- if eval('1 <> 1'): pass
- if eval('1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1'): pass
def testBinaryMaskOps(self):
x = 1 & 1
@@ -764,12 +703,12 @@ hello world
d[1,2] = 3
d[1,2,3] = 4
L = list(d)
- L.sort()
+ L.sort(key=lambda x: x if isinstance(x, tuple) else ())
self.assertEqual(str(L), '[1, (1,), (1, 2), (1, 2, 3)]')
def testAtoms(self):
- ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictmaker] '}' | '`' testlist '`' | NAME | NUMBER | STRING
- ### dictorsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [','])
+ ### atom: '(' [testlist] ')' | '[' [testlist] ']' | '{' [dictsetmaker] '}' | NAME | NUMBER | STRING
+ ### dictsetmaker: (test ':' test (',' test ':' test)* [',']) | (test (',' test)* [','])
x = (1)
x = (1 or 2 or 3)
@@ -794,11 +733,6 @@ hello world
x = {'one', 'two', 'three'}
x = {2, 3, 4,}
- # Silence Py3k warning
- x = eval('`x`')
- x = eval('`1 or 2 or 3`')
- self.assertEqual(eval('`1,2`'), '(1, 2)')
-
x = x
x = 'x'
x = 123
@@ -818,16 +752,13 @@ hello world
def meth1(self): pass
def meth2(self, arg): pass
def meth3(self, a1, a2): pass
+
# decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
# decorators: decorator+
# decorated: decorators (classdef | funcdef)
- def class_decorator(x):
- x.decorated = True
- return x
+ def class_decorator(x): return x
@class_decorator
- class G:
- pass
- self.assertEqual(G.decorated, True)
+ class G: pass
def testDictcomps(self):
# dictorsetmaker: ( (test ':' test (comp_for |
@@ -859,7 +790,7 @@ hello world
[[1], [1, 1], [1, 2, 4], [1, 3, 9, 27], [1, 4, 16, 64, 256]])
def test_in_func(l):
- return [None < x < 3 for x in l if x > 2]
+ return [0 < x < 3 for x in l if x > 2]
self.assertEqual(test_in_func(nums), [False, False, False])
@@ -902,9 +833,9 @@ hello world
def testGenexps(self):
# generator expression tests
g = ([x for x in range(10)] for x in range(1))
- self.assertEqual(g.next(), [x for x in range(10)])
+ self.assertEqual(next(g), [x for x in range(10)])
try:
- g.next()
+ next(g)
self.fail('should produce StopIteration exception')
except StopIteration:
pass
@@ -912,7 +843,7 @@ hello world
a = 1
try:
g = (a for d in a)
- g.next()
+ next(g)
self.fail('should produce TypeError')
except TypeError:
pass
@@ -977,10 +908,11 @@ hello world
# Test ifelse expressions in various cases
def _checkeval(msg, ret):
"helper to check that evaluation of expressions is done correctly"
- print x
+ print(x)
return ret
- self.assertEqual([ x() for x in lambda: True, lambda: False if x() ], [True])
+ # the next line is not allowed anymore
+ #self.assertEqual([ x() for x in lambda: True, lambda: False if x() ], [True])
self.assertEqual([ x() for x in (lambda: True, lambda: False) if x() ], [True])
self.assertEqual([ x(False) for x in (lambda x: False if x else True, lambda x: True if x else False) if x(False) ], [True])
self.assertEqual((5 if 1 else _checkeval("check 1", 0)), 5)
@@ -1009,13 +941,7 @@ hello world
def test_main():
- with check_py3k_warnings(
- ("backquote not supported", SyntaxWarning),
- ("tuple parameter unpacking has been removed", SyntaxWarning),
- ("parenthesized argument names are invalid", SyntaxWarning),
- ("classic int division", DeprecationWarning),
- (".+ not supported in 3.x", DeprecationWarning)):
- run_unittest(TokenTests, GrammarTests)
+ run_unittest(TokenTests, GrammarTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py
index e9e17582636..04a8af6ac9b 100644
--- a/Lib/test/test_grp.py
+++ b/Lib/test/test_grp.py
@@ -1,9 +1,9 @@
"""Test script for the grp module."""
import unittest
-from test import test_support
+from test import support
-grp = test_support.import_module('grp')
+grp = support.import_module('grp')
class GroupDatabaseTestCase(unittest.TestCase):
@@ -12,9 +12,9 @@ class GroupDatabaseTestCase(unittest.TestCase):
# attributes promised by the docs
self.assertEqual(len(value), 4)
self.assertEqual(value[0], value.gr_name)
- self.assertIsInstance(value.gr_name, basestring)
+ self.assertIsInstance(value.gr_name, str)
self.assertEqual(value[1], value.gr_passwd)
- self.assertIsInstance(value.gr_passwd, basestring)
+ self.assertIsInstance(value.gr_passwd, str)
self.assertEqual(value[2], value.gr_gid)
self.assertIsInstance(value.gr_gid, int)
self.assertEqual(value[3], value.gr_mem)
@@ -58,12 +58,12 @@ class GroupDatabaseTestCase(unittest.TestCase):
bynames[n] = g
bygids[g] = n
- allnames = bynames.keys()
+ allnames = list(bynames.keys())
namei = 0
fakename = allnames[namei]
while fakename in bynames:
chars = list(fakename)
- for i in xrange(len(chars)):
+ for i in range(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
break
@@ -91,7 +91,7 @@ class GroupDatabaseTestCase(unittest.TestCase):
self.assertRaises(KeyError, grp.getgrgid, fakegid)
def test_main():
- test_support.run_unittest(GroupDatabaseTestCase)
+ support.run_unittest(GroupDatabaseTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py
index 9f7bfd2ed55..ced226f3dce 100644
--- a/Lib/test/test_gzip.py
+++ b/Lib/test/test_gzip.py
@@ -1,35 +1,46 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Test script for the gzip module.
"""
import unittest
-from test import test_support
+from test import support
import os
import io
import struct
-gzip = test_support.import_module('gzip')
+gzip = support.import_module('gzip')
-data1 = """ int length=DEFAULTALLOC, err = Z_OK;
+data1 = b""" int length=DEFAULTALLOC, err = Z_OK;
PyObject *RetVal;
int flushmode = Z_FINISH;
unsigned long start_total_out;
"""
-data2 = """/* zlibmodule.c -- gzip-compatible data compression */
+data2 = b"""/* zlibmodule.c -- gzip-compatible data compression */
/* See http://www.gzip.org/zlib/
/* See http://www.winimage.com/zLibDll for Windows */
"""
+class UnseekableIO(io.BytesIO):
+ def seekable(self):
+ return False
+
+ def tell(self):
+ raise io.UnsupportedOperation
+
+ def seek(self, *args):
+ raise io.UnsupportedOperation
+
+
class TestGzip(unittest.TestCase):
- filename = test_support.TESTFN
+ filename = support.TESTFN
def setUp(self):
- test_support.unlink(self.filename)
+ support.unlink(self.filename)
def tearDown(self):
- test_support.unlink(self.filename)
+ support.unlink(self.filename)
def test_write(self):
@@ -53,13 +64,6 @@ class TestGzip(unittest.TestCase):
d = f.read()
self.assertEqual(d, data1*50)
- def test_read_universal_newlines(self):
- # Issue #5148: Reading breaks when mode contains 'U'.
- self.test_write()
- with gzip.GzipFile(self.filename, 'rU') as f:
- d = f.read()
- self.assertEqual(d, data1*50)
-
def test_io_on_closed_object(self):
# Test that I/O operations on closed GzipFile objects raise a
# ValueError, just like the corresponding functions on file objects.
@@ -78,7 +82,7 @@ class TestGzip(unittest.TestCase):
f = gzip.GzipFile(self.filename, 'w')
f.close()
with self.assertRaises(ValueError):
- f.write('')
+ f.write(b'')
with self.assertRaises(ValueError):
f.flush()
@@ -97,19 +101,19 @@ class TestGzip(unittest.TestCase):
# many, many members. Create such a file and verify that reading it
# works.
with gzip.open(self.filename, 'wb', 9) as f:
- f.write('a')
+ f.write(b'a')
for i in range(0, 200):
with gzip.open(self.filename, "ab", 9) as f: # append
- f.write('a')
+ f.write(b'a')
# Try reading the file
with gzip.open(self.filename, "rb") as zgfile:
- contents = ""
+ contents = b""
while 1:
ztxt = zgfile.read(8192)
contents += ztxt
if not ztxt: break
- self.assertEqual(contents, 'a'*201)
+ self.assertEqual(contents, b'a'*201)
def test_buffered_reader(self):
# Issue #7471: a GzipFile can be wrapped in a BufferedReader for
@@ -180,7 +184,7 @@ class TestGzip(unittest.TestCase):
with gzip.GzipFile(self.filename, 'w') as f:
for pos in range(0, 256, 16):
f.seek(pos)
- f.write('GZ\n')
+ f.write(b'GZ\n')
def test_mode(self):
self.test_write()
@@ -193,6 +197,12 @@ class TestGzip(unittest.TestCase):
self.assertTrue(hasattr(f, "name"))
self.assertEqual(f.name, self.filename)
+ def test_paddedfile_getattr(self):
+ self.test_write()
+ with gzip.GzipFile(self.filename, 'rb') as f:
+ self.assertTrue(hasattr(f.fileobj, "name"))
+ self.assertEqual(f.fileobj.name, self.filename)
+
def test_mtime(self):
mtime = 123456789
with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
@@ -213,28 +223,28 @@ class TestGzip(unittest.TestCase):
# see RFC 1952: http://www.faqs.org/rfcs/rfc1952.html
idBytes = fRead.read(2)
- self.assertEqual(idBytes, '\x1f\x8b') # gzip ID
+ self.assertEqual(idBytes, b'\x1f\x8b') # gzip ID
cmByte = fRead.read(1)
- self.assertEqual(cmByte, '\x08') # deflate
+ self.assertEqual(cmByte, b'\x08') # deflate
flagsByte = fRead.read(1)
- self.assertEqual(flagsByte, '\x08') # only the FNAME flag is set
+ self.assertEqual(flagsByte, b'\x08') # only the FNAME flag is set
mtimeBytes = fRead.read(4)
self.assertEqual(mtimeBytes, struct.pack('<i', mtime)) # little-endian
xflByte = fRead.read(1)
- self.assertEqual(xflByte, '\x02') # maximum compression
+ self.assertEqual(xflByte, b'\x02') # maximum compression
osByte = fRead.read(1)
- self.assertEqual(osByte, '\xff') # OS "unknown" (OS-independent)
+ self.assertEqual(osByte, b'\xff') # OS "unknown" (OS-independent)
# Since the FNAME flag is set, the zero-terminated filename follows.
# RFC 1952 specifies that this is the name of the input file, if any.
# However, the gzip module defaults to storing the name of the output
# file in this field.
- expected = self.filename.encode('Latin-1') + '\x00'
+ expected = self.filename.encode('Latin-1') + b'\x00'
nameBytes = fRead.read(len(expected))
self.assertEqual(nameBytes, expected)
@@ -243,7 +253,7 @@ class TestGzip(unittest.TestCase):
fRead.seek(os.stat(self.filename).st_size - 8)
crc32Bytes = fRead.read(4) # CRC32 of uncompressed data [data1]
- self.assertEqual(crc32Bytes, '\xaf\xd7d\x83')
+ self.assertEqual(crc32Bytes, b'\xaf\xd7d\x83')
isizeBytes = fRead.read(4)
self.assertEqual(isizeBytes, struct.pack('<i', len(data1)))
@@ -263,11 +273,11 @@ class TestGzip(unittest.TestCase):
self.fail("__enter__ on a closed file didn't raise an exception")
try:
with gzip.GzipFile(self.filename, "wb") as f:
- 1 // 0
+ 1/0
except ZeroDivisionError:
pass
else:
- self.fail("1 // 0 didn't raise an exception")
+ self.fail("1/0 didn't raise an exception")
def test_zero_padded_file(self):
with gzip.GzipFile(self.filename, "wb") as f:
@@ -275,22 +285,88 @@ class TestGzip(unittest.TestCase):
# Pad the file with zeroes
with open(self.filename, "ab") as f:
- f.write("\x00" * 50)
+ f.write(b"\x00" * 50)
with gzip.GzipFile(self.filename, "rb") as f:
d = f.read()
self.assertEqual(d, data1 * 50, "Incorrect data in file")
+ def test_non_seekable_file(self):
+ uncompressed = data1 * 50
+ buf = UnseekableIO()
+ with gzip.GzipFile(fileobj=buf, mode="wb") as f:
+ f.write(uncompressed)
+ compressed = buf.getvalue()
+ buf = UnseekableIO(compressed)
+ with gzip.GzipFile(fileobj=buf, mode="rb") as f:
+ self.assertEqual(f.read(), uncompressed)
+
+ def test_peek(self):
+ uncompressed = data1 * 200
+ with gzip.GzipFile(self.filename, "wb") as f:
+ f.write(uncompressed)
+
+ def sizes():
+ while True:
+ for n in range(5, 50, 10):
+ yield n
+
+ with gzip.GzipFile(self.filename, "rb") as f:
+ f.max_read_chunk = 33
+ nread = 0
+ for n in sizes():
+ s = f.peek(n)
+ if s == b'':
+ break
+ self.assertEqual(f.read(len(s)), s)
+ nread += len(s)
+ self.assertEqual(f.read(100), b'')
+ self.assertEqual(nread, len(uncompressed))
+
def test_fileobj_from_fdopen(self):
- # Issue #13781: Creating a GzipFile using a fileobj from os.fdopen()
- # should not embed the fake filename "<fdopen>" in the output file.
+ # Issue #13781: Opening a GzipFile for writing fails when using a
+ # fileobj created with os.fdopen().
fd = os.open(self.filename, os.O_WRONLY | os.O_CREAT)
with os.fdopen(fd, "wb") as f:
with gzip.GzipFile(fileobj=f, mode="w") as g:
- self.assertEqual(g.name, "")
+ pass
+
+ def test_bytes_filename(self):
+ str_filename = self.filename
+ try:
+ bytes_filename = str_filename.encode("ascii")
+ except UnicodeEncodeError:
+ self.skipTest("Temporary file name needs to be ASCII")
+ with gzip.GzipFile(bytes_filename, "wb") as f:
+ f.write(data1 * 50)
+ with gzip.GzipFile(bytes_filename, "rb") as f:
+ self.assertEqual(f.read(), data1 * 50)
+ # Sanity check that we are actually operating on the right file.
+ with gzip.GzipFile(str_filename, "rb") as f:
+ self.assertEqual(f.read(), data1 * 50)
+
+ # Testing compress/decompress shortcut functions
+
+ def test_compress(self):
+ for data in [data1, data2]:
+ for args in [(), (1,), (6,), (9,)]:
+ datac = gzip.compress(data, *args)
+ self.assertEqual(type(datac), bytes)
+ with gzip.GzipFile(fileobj=io.BytesIO(datac), mode="rb") as f:
+ self.assertEqual(f.read(), data)
+
+ def test_decompress(self):
+ for data in (data1, data2):
+ buf = io.BytesIO()
+ with gzip.GzipFile(fileobj=buf, mode="wb") as f:
+ f.write(data)
+ self.assertEqual(gzip.decompress(buf.getvalue()), data)
+ # Roundtrip with compress
+ datac = gzip.compress(data)
+ self.assertEqual(gzip.decompress(datac), data)
def test_main(verbose=None):
- test_support.run_unittest(TestGzip)
+ support.run_unittest(TestGzip)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_hash.py b/Lib/test/test_hash.py
index dec7dcbd7c8..c0dd34dc7ff 100644
--- a/Lib/test/test_hash.py
+++ b/Lib/test/test_hash.py
@@ -3,17 +3,15 @@
#
# Also test that hash implementations are inherited as expected
+import datetime
import os
import sys
-import struct
-import datetime
import unittest
-import subprocess
-
-from test import test_support
+from test import support
+from test.script_helper import assert_python_ok
from collections import Hashable
-IS_64BIT = (struct.calcsize('l') == 8)
+IS_64BIT = sys.maxsize > 2**32
class HashEqualityTestCase(unittest.TestCase):
@@ -21,32 +19,30 @@ class HashEqualityTestCase(unittest.TestCase):
def same_hash(self, *objlist):
# Hash each object given and fail if
# the hash values are not all the same.
- hashed = map(hash, objlist)
+ hashed = list(map(hash, objlist))
for h in hashed[1:]:
if h != hashed[0]:
self.fail("hashed values differ: %r" % (objlist,))
def test_numeric_literals(self):
- self.same_hash(1, 1L, 1.0, 1.0+0.0j)
- self.same_hash(0, 0L, 0.0, 0.0+0.0j)
- self.same_hash(-1, -1L, -1.0, -1.0+0.0j)
- self.same_hash(-2, -2L, -2.0, -2.0+0.0j)
+ self.same_hash(1, 1, 1.0, 1.0+0.0j)
+ self.same_hash(0, 0.0, 0.0+0.0j)
+ self.same_hash(-1, -1.0, -1.0+0.0j)
+ self.same_hash(-2, -2.0, -2.0+0.0j)
def test_coerced_integers(self):
- self.same_hash(int(1), long(1), float(1), complex(1),
+ self.same_hash(int(1), int(1), float(1), complex(1),
int('1'), float('1.0'))
- self.same_hash(int(-2**31), long(-2**31), float(-2**31))
- self.same_hash(int(1-2**31), long(1-2**31), float(1-2**31))
- self.same_hash(int(2**31-1), long(2**31-1), float(2**31-1))
+ self.same_hash(int(-2**31), float(-2**31))
+ self.same_hash(int(1-2**31), float(1-2**31))
+ self.same_hash(int(2**31-1), float(2**31-1))
# for 64-bit platforms
- self.same_hash(int(2**31), long(2**31), float(2**31))
- self.same_hash(int(-2**63), long(-2**63), float(-2**63))
- self.same_hash(int(1-2**63), long(1-2**63))
- self.same_hash(int(2**63-1), long(2**63-1))
- self.same_hash(long(2**63), float(2**63))
+ self.same_hash(int(2**31), float(2**31))
+ self.same_hash(int(-2**63), float(-2**63))
+ self.same_hash(int(2**63), float(2**63))
def test_coerced_floats(self):
- self.same_hash(long(1.23e300), float(1.23e300))
+ self.same_hash(int(1.23e300), float(1.23e300))
self.same_hash(float(0.5), complex(0.5, 0.0))
@@ -61,24 +57,13 @@ class FixedHash(object):
class OnlyEquality(object):
def __eq__(self, other):
return self is other
- # Trick to suppress Py3k warning in 2.x
- __hash__ = None
-del OnlyEquality.__hash__
class OnlyInequality(object):
def __ne__(self, other):
return self is not other
-class OnlyCmp(object):
- def __cmp__(self, other):
- return cmp(id(self), id(other))
- # Trick to suppress Py3k warning in 2.x
- __hash__ = None
-del OnlyCmp.__hash__
-
class InheritedHashWithEquality(FixedHash, OnlyEquality): pass
class InheritedHashWithInequality(FixedHash, OnlyInequality): pass
-class InheritedHashWithCmp(FixedHash, OnlyCmp): pass
class NoHash(object):
__hash__ = None
@@ -86,16 +71,15 @@ class NoHash(object):
class HashInheritanceTestCase(unittest.TestCase):
default_expected = [object(),
DefaultHash(),
- OnlyEquality(),
OnlyInequality(),
- OnlyCmp(),
]
fixed_expected = [FixedHash(),
InheritedHashWithEquality(),
InheritedHashWithInequality(),
- InheritedHashWithCmp(),
]
- error_expected = [NoHash()]
+ error_expected = [NoHash(),
+ OnlyEquality(),
+ ]
def test_default_hash(self):
for obj in self.default_expected:
@@ -121,8 +105,6 @@ class HashInheritanceTestCase(unittest.TestCase):
# Issue #4701: Check that some builtin types are correctly hashable
-# (This test only used to fail in Python 3.0, but has been included
-# in 2.x along with the lazy call to PyType_Ready in PyObject_Hash)
class DefaultIterSeq(object):
seq = range(10)
def __len__(self):
@@ -131,8 +113,8 @@ class DefaultIterSeq(object):
return self.seq[index]
class HashBuiltinsTestCase(unittest.TestCase):
- hashes_to_check = [xrange(10),
- enumerate(xrange(10)),
+ hashes_to_check = [range(10),
+ enumerate(range(10)),
iter(DefaultIterSeq()),
iter(lambda: 0, 0),
]
@@ -152,17 +134,17 @@ class HashRandomizationTests(unittest.TestCase):
def get_hash(self, repr_, seed=None):
env = os.environ.copy()
+ env['__cleanenv'] = True # signal to assert_python not to do a copy
+ # of os.environ on its own
if seed is not None:
env['PYTHONHASHSEED'] = str(seed)
else:
env.pop('PYTHONHASHSEED', None)
- cmd_line = [sys.executable, '-c', self.get_hash_command(repr_)]
- p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
- env=env)
- out, err = p.communicate()
- out = test_support.strip_python_stderr(out)
- return int(out.strip())
+ out = assert_python_ok(
+ '-c', self.get_hash_command(repr_),
+ **env)
+ stdout = out[1].strip()
+ return int(stdout)
def test_randomized_hash(self):
# two runs should return different hashes
@@ -205,17 +187,11 @@ class StrHashRandomizationTests(StringlikeHashRandomizationTests):
def test_empty_string(self):
self.assertEqual(hash(""), 0)
-class UnicodeHashRandomizationTests(StringlikeHashRandomizationTests):
- repr_ = repr(u'abc')
+class BytesHashRandomizationTests(StringlikeHashRandomizationTests):
+ repr_ = repr(b'abc')
def test_empty_string(self):
- self.assertEqual(hash(u""), 0)
-
-class BufferHashRandomizationTests(StringlikeHashRandomizationTests):
- repr_ = 'buffer("abc")'
-
- def test_empty_string(self):
- self.assertEqual(hash(buffer("")), 0)
+ self.assertEqual(hash(b""), 0)
class DatetimeTests(HashRandomizationTests):
def get_hash_command(self, repr_):
@@ -232,16 +208,14 @@ class DatetimeTimeTests(DatetimeTests):
def test_main():
- test_support.run_unittest(HashEqualityTestCase,
- HashInheritanceTestCase,
- HashBuiltinsTestCase,
- StrHashRandomizationTests,
- UnicodeHashRandomizationTests,
- BufferHashRandomizationTests,
- DatetimeDateTests,
- DatetimeDatetimeTests,
- DatetimeTimeTests)
-
+ support.run_unittest(HashEqualityTestCase,
+ HashInheritanceTestCase,
+ HashBuiltinsTestCase,
+ StrHashRandomizationTests,
+ BytesHashRandomizationTests,
+ DatetimeDateTests,
+ DatetimeDatetimeTests,
+ DatetimeTimeTests)
if __name__ == "__main__":
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index e6365c5c5f3..29d3a1cc44f 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -16,20 +16,19 @@ except ImportError:
threading = None
import unittest
import warnings
-from test import test_support
-from test.test_support import _4G, precisionbigmemtest
+from test import support
+from test.support import _4G, bigmemtest
# Were we compiled --with-pydebug or with #define Py_DEBUG?
COMPILED_WITH_PYDEBUG = hasattr(sys, 'gettotalrefcount')
def hexstr(s):
- import string
- h = string.hexdigits
+ assert isinstance(s, bytes), repr(s)
+ h = "0123456789abcdef"
r = ''
- for c in s:
- i = ord(c)
- r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
+ for i in s:
+ r += h[(i >> 4) & 0xF] + h[i & 0xF]
return r
@@ -44,7 +43,7 @@ class HashLibTestCase(unittest.TestCase):
"""Import a module and return a reference to it or None on failure."""
try:
exec('import '+module_name)
- except ImportError, error:
+ except ImportError as error:
if self._warn_on_extension_import:
warnings.warn('Did a C extension fail to compile? %s' % error)
return locals().get(module_name)
@@ -80,10 +79,10 @@ class HashLibTestCase(unittest.TestCase):
_md5 = self._conditional_import_module('_md5')
if _md5:
- self.constructors_to_test['md5'].add(_md5.new)
- _sha = self._conditional_import_module('_sha')
- if _sha:
- self.constructors_to_test['sha1'].add(_sha.new)
+ self.constructors_to_test['md5'].add(_md5.md5)
+ _sha1 = self._conditional_import_module('_sha1')
+ if _sha1:
+ self.constructors_to_test['sha1'].add(_sha1.sha1)
_sha256 = self._conditional_import_module('_sha256')
if _sha256:
self.constructors_to_test['sha224'].add(_sha256.sha224)
@@ -97,15 +96,19 @@ class HashLibTestCase(unittest.TestCase):
def test_hash_array(self):
a = array.array("b", range(10))
- constructors = self.constructors_to_test.itervalues()
+ constructors = self.constructors_to_test.values()
for cons in itertools.chain.from_iterable(constructors):
c = cons(a)
c.hexdigest()
- def test_algorithms_attribute(self):
- self.assertEqual(hashlib.algorithms,
- tuple([_algo for _algo in self.supported_hash_names if
- _algo.islower()]))
+ def test_algorithms_guaranteed(self):
+ self.assertEqual(hashlib.algorithms_guaranteed,
+ set(_algo for _algo in self.supported_hash_names
+ if _algo.islower()))
+
+ def test_algorithms_available(self):
+ self.assertTrue(set(hashlib.algorithms_guaranteed).
+ issubset(hashlib.algorithms_available))
def test_unknown_hash(self):
self.assertRaises(ValueError, hashlib.new, 'spam spam spam spam spam')
@@ -133,13 +136,14 @@ class HashLibTestCase(unittest.TestCase):
def test_hexdigest(self):
for name in self.supported_hash_names:
h = hashlib.new(name)
- self.assertTrue(hexstr(h.digest()) == h.hexdigest())
+ assert isinstance(h.digest(), bytes), name
+ self.assertEqual(hexstr(h.digest()), h.hexdigest())
+
def test_large_update(self):
- aas = 'a' * 128
- bees = 'b' * 127
- cees = 'c' * 126
- abcs = aas + bees + cees
+ aas = b'a' * 128
+ bees = b'b' * 127
+ cees = b'c' * 126
for name in self.supported_hash_names:
m1 = hashlib.new(name)
@@ -148,11 +152,8 @@ class HashLibTestCase(unittest.TestCase):
m1.update(cees)
m2 = hashlib.new(name)
- m2.update(abcs)
- self.assertEqual(m1.digest(), m2.digest(), name+' update problem.')
-
- m3 = hashlib.new(name, abcs)
- self.assertEqual(m1.digest(), m3.digest(), name+' new problem.')
+ m2.update(aas + bees + cees)
+ self.assertEqual(m1.digest(), m2.digest())
def check(self, name, data, digest):
constructors = self.constructors_to_test[name]
@@ -167,68 +168,44 @@ class HashLibTestCase(unittest.TestCase):
% (name, hash_object_constructor,
computed, len(data), digest))
- def check_update(self, name, data, digest):
- constructors = self.constructors_to_test[name]
- # 2 is for hashlib.name(...) and hashlib.new(name, ...)
- self.assertGreaterEqual(len(constructors), 2)
+ def check_no_unicode(self, algorithm_name):
+ # Unicode objects are not allowed as input.
+ constructors = self.constructors_to_test[algorithm_name]
for hash_object_constructor in constructors:
- h = hash_object_constructor()
- h.update(data)
- computed = h.hexdigest()
- self.assertEqual(
- computed, digest,
- "Hash algorithm %s using %s when updated returned hexdigest"
- " %r for %d byte input data that should have hashed to %r."
- % (name, hash_object_constructor,
- computed, len(data), digest))
+ self.assertRaises(TypeError, hash_object_constructor, 'spam')
- def check_unicode(self, algorithm_name):
- # Unicode objects are not allowed as input.
- expected = hashlib.new(algorithm_name, str(u'spam')).hexdigest()
- self.check(algorithm_name, u'spam', expected)
-
- def test_unicode(self):
- # In python 2.x unicode is auto-encoded to the system default encoding
- # when passed to hashlib functions.
- self.check_unicode('md5')
- self.check_unicode('sha1')
- self.check_unicode('sha224')
- self.check_unicode('sha256')
- self.check_unicode('sha384')
- self.check_unicode('sha512')
+ def test_no_unicode(self):
+ self.check_no_unicode('md5')
+ self.check_no_unicode('sha1')
+ self.check_no_unicode('sha224')
+ self.check_no_unicode('sha256')
+ self.check_no_unicode('sha384')
+ self.check_no_unicode('sha512')
def test_case_md5_0(self):
- self.check('md5', '', 'd41d8cd98f00b204e9800998ecf8427e')
+ self.check('md5', b'', 'd41d8cd98f00b204e9800998ecf8427e')
def test_case_md5_1(self):
- self.check('md5', 'abc', '900150983cd24fb0d6963f7d28e17f72')
+ self.check('md5', b'abc', '900150983cd24fb0d6963f7d28e17f72')
def test_case_md5_2(self):
- self.check('md5', 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
+ self.check('md5',
+ b'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
'd174ab98d277d9f5a5611c2c9f419d9f')
- @precisionbigmemtest(size=_4G + 5, memuse=1)
+ @bigmemtest(size=_4G + 5, memuse=1)
def test_case_md5_huge(self, size):
if size == _4G + 5:
try:
- self.check('md5', 'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
- except OverflowError:
- pass # 32-bit arch
-
- @precisionbigmemtest(size=_4G + 5, memuse=1)
- def test_case_md5_huge_update(self, size):
- if size == _4G + 5:
- try:
- self.check_update('md5', 'A'*size,
- 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
+ self.check('md5', b'A'*size, 'c9af2dff37468ce5dfee8f2cfc0a9c6d')
except OverflowError:
pass # 32-bit arch
- @precisionbigmemtest(size=_4G - 1, memuse=1)
+ @bigmemtest(size=_4G - 1, memuse=1)
def test_case_md5_uintmax(self, size):
if size == _4G - 1:
try:
- self.check('md5', 'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')
+ self.check('md5', b'A'*size, '28138d306ff1b8281f1a9067e1a1a2b3')
except OverflowError:
pass # 32-bit arch
@@ -237,126 +214,124 @@ class HashLibTestCase(unittest.TestCase):
# http://www.itl.nist.gov/div897/pubs/fip180-1.htm
def test_case_sha1_0(self):
- self.check('sha1', "",
+ self.check('sha1', b"",
"da39a3ee5e6b4b0d3255bfef95601890afd80709")
def test_case_sha1_1(self):
- self.check('sha1', "abc",
+ self.check('sha1', b"abc",
"a9993e364706816aba3e25717850c26c9cd0d89d")
def test_case_sha1_2(self):
- self.check('sha1', "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ self.check('sha1',
+ b"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"84983e441c3bd26ebaae4aa1f95129e5e54670f1")
def test_case_sha1_3(self):
- self.check('sha1', "a" * 1000000,
+ self.check('sha1', b"a" * 1000000,
"34aa973cd4c4daa4f61eeb2bdbad27316534016f")
- @precisionbigmemtest(size=_4G + 5, memuse=1)
- def test_case_sha1_huge(self, size):
- if size == _4G + 5:
- try:
- self.check('sha1', 'A'*size,
- '87d745c50e6b2879ffa0fb2c930e9fbfe0dc9a5b')
- except OverflowError:
- pass # 32-bit arch
-
- @precisionbigmemtest(size=_4G + 5, memuse=1)
- def test_case_sha1_huge_update(self, size):
- if size == _4G + 5:
- try:
- self.check_update('sha1', 'A'*size,
- '87d745c50e6b2879ffa0fb2c930e9fbfe0dc9a5b')
- except OverflowError:
- pass # 32-bit arch
# use the examples from Federal Information Processing Standards
# Publication 180-2, Secure Hash Standard, 2002 August 1
# http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
def test_case_sha224_0(self):
- self.check('sha224', "",
+ self.check('sha224', b"",
"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f")
def test_case_sha224_1(self):
- self.check('sha224', "abc",
+ self.check('sha224', b"abc",
"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7")
def test_case_sha224_2(self):
self.check('sha224',
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ b"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525")
def test_case_sha224_3(self):
- self.check('sha224', "a" * 1000000,
+ self.check('sha224', b"a" * 1000000,
"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67")
def test_case_sha256_0(self):
- self.check('sha256', "",
+ self.check('sha256', b"",
"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
def test_case_sha256_1(self):
- self.check('sha256', "abc",
+ self.check('sha256', b"abc",
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad")
def test_case_sha256_2(self):
self.check('sha256',
- "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
+ b"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1")
def test_case_sha256_3(self):
- self.check('sha256', "a" * 1000000,
+ self.check('sha256', b"a" * 1000000,
"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0")
def test_case_sha384_0(self):
- self.check('sha384', "",
+ self.check('sha384', b"",
"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da"+
"274edebfe76f65fbd51ad2f14898b95b")
def test_case_sha384_1(self):
- self.check('sha384', "abc",
+ self.check('sha384', b"abc",
"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed"+
"8086072ba1e7cc2358baeca134c825a7")
def test_case_sha384_2(self):
self.check('sha384',
- "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
- "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ b"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
+ b"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"09330c33f71147e83d192fc782cd1b4753111b173b3b05d22fa08086e3b0f712"+
"fcc7c71a557e2db966c3e9fa91746039")
def test_case_sha384_3(self):
- self.check('sha384', "a" * 1000000,
+ self.check('sha384', b"a" * 1000000,
"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b"+
"07b8b3dc38ecc4ebae97ddd87f3d8985")
def test_case_sha512_0(self):
- self.check('sha512', "",
+ self.check('sha512', b"",
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"+
"47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e")
def test_case_sha512_1(self):
- self.check('sha512', "abc",
+ self.check('sha512', b"abc",
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"+
"2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f")
def test_case_sha512_2(self):
self.check('sha512',
- "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
- "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
+ b"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"+
+ b"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"+
"501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909")
def test_case_sha512_3(self):
- self.check('sha512', "a" * 1000000,
+ self.check('sha512', b"a" * 1000000,
"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"+
"de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b")
+ def test_gil(self):
+ # Check things work fine with an input larger than the size required
+ # for multithreaded operation (which is hardwired to 2048).
+ gil_minsize = 2048
+
+ m = hashlib.md5()
+ m.update(b'1')
+ m.update(b'#' * gil_minsize)
+ m.update(b'1')
+ self.assertEqual(m.hexdigest(), 'cb1e1a2cbc80be75e19935d621fb9b21')
+
+ m = hashlib.md5(b'x' * gil_minsize)
+ self.assertEqual(m.hexdigest(), 'cfb767f225d58469c5de3632a8803958')
+
@unittest.skipUnless(threading, 'Threading required for this test.')
- @test_support.reap_threads
+ @support.reap_threads
def test_threaded_hashing(self):
# Updating the same hash object from several threads at once
# using data chunk sizes containing the same byte sequences.
@@ -366,7 +341,7 @@ class HashLibTestCase(unittest.TestCase):
# hash will be the same as doing it single threaded upfront.
hasher = hashlib.sha1()
num_threads = 5
- smallest_data = 'swineflu'
+ smallest_data = b'swineflu'
data = smallest_data*200000
expected_hash = hashlib.sha1(data*num_threads).hexdigest()
@@ -378,7 +353,7 @@ class HashLibTestCase(unittest.TestCase):
event.set()
events = []
- for threadnum in xrange(num_threads):
+ for threadnum in range(num_threads):
chunk_size = len(data) // (10**threadnum)
assert chunk_size > 0
assert chunk_size % len(smallest_data) == 0
@@ -393,7 +368,7 @@ class HashLibTestCase(unittest.TestCase):
self.assertEqual(expected_hash, hasher.hexdigest())
def test_main():
- test_support.run_unittest(HashLibTestCase)
+ support.run_unittest(HashLibTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_heapq.py b/Lib/test/test_heapq.py
index 5932a40c28a..e0c49c110f6 100644
--- a/Lib/test/test_heapq.py
+++ b/Lib/test/test_heapq.py
@@ -3,11 +3,11 @@
import sys
import random
-from test import test_support
+from test import support
from unittest import TestCase, skipUnless
-py_heapq = test_support.import_fresh_module('heapq', blocked=['_heapq'])
-c_heapq = test_support.import_fresh_module('heapq', fresh=['_heapq'])
+py_heapq = support.import_fresh_module('heapq', blocked=['_heapq'])
+c_heapq = support.import_fresh_module('heapq', fresh=['_heapq'])
# _heapq.nlargest/nsmallest are saved in heapq._nlargest/_smallest when
# _heapq is imported, so check them there
@@ -137,7 +137,7 @@ class TestHeap(TestCase):
def test_heapsort(self):
# Exercise everything with repeated heapsort checks
- for trial in xrange(100):
+ for trial in range(100):
size = random.randrange(50)
data = [random.randrange(25) for i in range(size)]
if trial & 1: # Half of the time, use heapify
@@ -152,7 +152,7 @@ class TestHeap(TestCase):
def test_merge(self):
inputs = []
- for i in xrange(random.randrange(5)):
+ for i in range(random.randrange(5)):
row = sorted(random.randrange(1000) for j in range(random.randrange(10)))
inputs.append(row)
self.assertEqual(sorted(chain(*inputs)), list(self.module.merge(*inputs)))
@@ -177,23 +177,25 @@ class TestHeap(TestCase):
data = [(random.randrange(2000), i) for i in range(1000)]
for f in (None, lambda x: x[0] * 547 % 2000):
for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(self.module.nsmallest(n, data), sorted(data)[:n])
- self.assertEqual(self.module.nsmallest(n, data, key=f),
+ self.assertEqual(list(self.module.nsmallest(n, data)),
+ sorted(data)[:n])
+ self.assertEqual(list(self.module.nsmallest(n, data, key=f)),
sorted(data, key=f)[:n])
def test_nlargest(self):
data = [(random.randrange(2000), i) for i in range(1000)]
for f in (None, lambda x: x[0] * 547 % 2000):
for n in (0, 1, 2, 10, 100, 400, 999, 1000, 1100):
- self.assertEqual(self.module.nlargest(n, data),
+ self.assertEqual(list(self.module.nlargest(n, data)),
sorted(data, reverse=True)[:n])
- self.assertEqual(self.module.nlargest(n, data, key=f),
+ self.assertEqual(list(self.module.nlargest(n, data, key=f)),
sorted(data, key=f, reverse=True)[:n])
def test_comparison_operator(self):
- # Issue 3051: Make sure heapq works with both __lt__ and __le__
+ # Issue 3051: Make sure heapq works with both __lt__
+ # For python 3.0, __le__ alone is not enough
def hsort(data, comp):
- data = map(comp, data)
+ data = [comp(x) for x in data]
self.module.heapify(data)
return [self.module.heappop(data).x for i in range(len(data))]
class LT:
@@ -209,7 +211,7 @@ class TestHeap(TestCase):
data = [random.random() for i in range(100)]
target = sorted(data, reverse=True)
self.assertEqual(hsort(data, LT), target)
- self.assertEqual(hsort(data, LE), target)
+ self.assertRaises(TypeError, data, LE)
class TestHeapPython(TestHeap):
@@ -235,8 +237,9 @@ class GetOnly:
class CmpErr:
"Dummy element that always raises an error during comparison"
- def __cmp__(self, other):
+ def __eq__(self, other):
raise ZeroDivisionError
+ __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __eq__
def R(seqn):
'Regular generator'
@@ -257,7 +260,7 @@ class I:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -277,14 +280,14 @@ class X:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
return v
class N:
- 'Iterator missing next()'
+ 'Iterator missing __next__()'
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
@@ -298,7 +301,7 @@ class E:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
3 // 0
class S:
@@ -307,13 +310,14 @@ class S:
pass
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
-from itertools import chain, imap
+from itertools import chain
def L(seqn):
'Test multiple tiers of iterators'
- return chain(imap(lambda x:x, R(Ig(G(seqn)))))
+ return chain(map(lambda x:x, R(Ig(G(seqn)))))
+
class TestErrorHandling(TestCase):
module = None
@@ -334,6 +338,14 @@ class TestErrorHandling(TestCase):
self.assertRaises(TypeError, f, 2, LenOnly())
def test_get_only(self):
+ for f in (self.module.heapify, self.module.heappop):
+ self.assertRaises(TypeError, f, GetOnly())
+ for f in (self.module.heappush, self.module.heapreplace):
+ self.assertRaises(TypeError, f, GetOnly(), 10)
+ for f in (self.module.nlargest, self.module.nsmallest):
+ self.assertRaises(TypeError, f, 2, GetOnly())
+
+ def test_get_only(self):
seq = [CmpErr(), CmpErr(), CmpErr()]
for f in (self.module.heapify, self.module.heappop):
self.assertRaises(ZeroDivisionError, f, seq)
@@ -350,13 +362,10 @@ class TestErrorHandling(TestCase):
def test_iterable_args(self):
for f in (self.module.nlargest, self.module.nsmallest):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), (1, 1.2), range(2000,2200,5)):
for g in (G, I, Ig, L, R):
- with test_support.check_py3k_warnings(
- ("comparing unequal types not supported",
- DeprecationWarning), quiet=True):
- self.assertEqual(f(2, g(s)), f(2,s))
- self.assertEqual(f(2, S(s)), [])
+ self.assertEqual(list(f(2, g(s))), list(f(2,s)))
+ self.assertEqual(list(f(2, S(s))), [])
self.assertRaises(TypeError, f, 2, X(s))
self.assertRaises(TypeError, f, 2, N(s))
self.assertRaises(ZeroDivisionError, f, 2, E(s))
@@ -365,7 +374,6 @@ class TestErrorHandling(TestCase):
class TestErrorHandlingPython(TestErrorHandling):
module = py_heapq
-
@skipUnless(c_heapq, 'requires _heapq')
class TestErrorHandlingC(TestErrorHandling):
module = c_heapq
@@ -377,17 +385,17 @@ class TestErrorHandlingC(TestErrorHandling):
def test_main(verbose=None):
test_classes = [TestModules, TestHeapPython, TestHeapC,
TestErrorHandlingPython, TestErrorHandlingC]
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index cd148e9d0a1..4de0620e1a9 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -2,7 +2,7 @@ import hmac
import hashlib
import unittest
import warnings
-from test import test_support
+from test import support
class TestVectorsTestCase(unittest.TestCase):
@@ -13,33 +13,33 @@ class TestVectorsTestCase(unittest.TestCase):
h = hmac.HMAC(key, data)
self.assertEqual(h.hexdigest().upper(), digest.upper())
- md5test(chr(0x0b) * 16,
- "Hi There",
+ md5test(b"\x0b" * 16,
+ b"Hi There",
"9294727A3638BB1C13F48EF8158BFC9D")
- md5test("Jefe",
- "what do ya want for nothing?",
+ md5test(b"Jefe",
+ b"what do ya want for nothing?",
"750c783e6ab0b503eaa86e310a5db738")
- md5test(chr(0xAA)*16,
- chr(0xDD)*50,
+ md5test(b"\xaa" * 16,
+ b"\xdd" * 50,
"56be34521d144c88dbb8c733f0e8b3f6")
- md5test("".join([chr(i) for i in range(1, 26)]),
- chr(0xCD) * 50,
+ md5test(bytes(range(1, 26)),
+ b"\xcd" * 50,
"697eaf0aca3a3aea3a75164746ffaa79")
- md5test(chr(0x0C) * 16,
- "Test With Truncation",
+ md5test(b"\x0C" * 16,
+ b"Test With Truncation",
"56461ef2342edc00f9bab995690efd4c")
- md5test(chr(0xAA) * 80,
- "Test Using Larger Than Block-Size Key - Hash Key First",
+ md5test(b"\xaa" * 80,
+ b"Test Using Larger Than Block-Size Key - Hash Key First",
"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd")
- md5test(chr(0xAA) * 80,
- ("Test Using Larger Than Block-Size Key "
- "and Larger Than One Block-Size Data"),
+ md5test(b"\xaa" * 80,
+ (b"Test Using Larger Than Block-Size Key "
+ b"and Larger Than One Block-Size Data"),
"6f630fad67cda0ee1fb1f562db3aa53e")
def test_sha_vectors(self):
@@ -47,33 +47,33 @@ class TestVectorsTestCase(unittest.TestCase):
h = hmac.HMAC(key, data, digestmod=hashlib.sha1)
self.assertEqual(h.hexdigest().upper(), digest.upper())
- shatest(chr(0x0b) * 20,
- "Hi There",
+ shatest(b"\x0b" * 20,
+ b"Hi There",
"b617318655057264e28bc0b6fb378c8ef146be00")
- shatest("Jefe",
- "what do ya want for nothing?",
+ shatest(b"Jefe",
+ b"what do ya want for nothing?",
"effcdf6ae5eb2fa2d27416d5f184df9c259a7c79")
- shatest(chr(0xAA)*20,
- chr(0xDD)*50,
+ shatest(b"\xAA" * 20,
+ b"\xDD" * 50,
"125d7342b9ac11cd91a39af48aa17b4f63f175d3")
- shatest("".join([chr(i) for i in range(1, 26)]),
- chr(0xCD) * 50,
+ shatest(bytes(range(1, 26)),
+ b"\xCD" * 50,
"4c9007f4026250c6bc8414f9bf50c86c2d7235da")
- shatest(chr(0x0C) * 20,
- "Test With Truncation",
+ shatest(b"\x0C" * 20,
+ b"Test With Truncation",
"4c1a03424b55e07fe7f27be1d58bb9324a9a5a04")
- shatest(chr(0xAA) * 80,
- "Test Using Larger Than Block-Size Key - Hash Key First",
+ shatest(b"\xAA" * 80,
+ b"Test Using Larger Than Block-Size Key - Hash Key First",
"aa4ae5e15272d00e95705637ce8a3b55ed402112")
- shatest(chr(0xAA) * 80,
- ("Test Using Larger Than Block-Size Key "
- "and Larger Than One Block-Size Data"),
+ shatest(b"\xAA" * 80,
+ (b"Test Using Larger Than Block-Size Key "
+ b"and Larger Than One Block-Size Data"),
"e8e99d0f45237d786d6bbaa7965c7808bbff1a91")
def _rfc4231_test_cases(self, hashfunc):
@@ -82,8 +82,8 @@ class TestVectorsTestCase(unittest.TestCase):
self.assertEqual(h.hexdigest().lower(), hexdigests[hashfunc])
# 4.2. Test Case 1
- hmactest(key = '\x0b'*20,
- data = 'Hi There',
+ hmactest(key = b'\x0b'*20,
+ data = b'Hi There',
hexdigests = {
hashlib.sha224: '896fb1128abbdf196832107cd49df33f'
'47b4b1169912ba4f53684b22',
@@ -99,8 +99,8 @@ class TestVectorsTestCase(unittest.TestCase):
})
# 4.3. Test Case 2
- hmactest(key = 'Jefe',
- data = 'what do ya want for nothing?',
+ hmactest(key = b'Jefe',
+ data = b'what do ya want for nothing?',
hexdigests = {
hashlib.sha224: 'a30e01098bc6dbbf45690f3a7e9e6d0f'
'8bbea2a39e6148008fd05e44',
@@ -116,8 +116,8 @@ class TestVectorsTestCase(unittest.TestCase):
})
# 4.4. Test Case 3
- hmactest(key = '\xaa'*20,
- data = '\xdd'*50,
+ hmactest(key = b'\xaa'*20,
+ data = b'\xdd'*50,
hexdigests = {
hashlib.sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad264'
'9365b0c1f65d69d1ec8333ea',
@@ -133,8 +133,8 @@ class TestVectorsTestCase(unittest.TestCase):
})
# 4.5. Test Case 4
- hmactest(key = ''.join([chr(x) for x in xrange(0x01, 0x19+1)]),
- data = '\xcd'*50,
+ hmactest(key = bytes(x for x in range(0x01, 0x19+1)),
+ data = b'\xcd'*50,
hexdigests = {
hashlib.sha224: '6c11506874013cac6a2abc1bb382627c'
'ec6a90d86efc012de7afec5a',
@@ -150,9 +150,9 @@ class TestVectorsTestCase(unittest.TestCase):
})
# 4.7. Test Case 6
- hmactest(key = '\xaa'*131,
- data = 'Test Using Larger Than Block-Siz'
- 'e Key - Hash Key First',
+ hmactest(key = b'\xaa'*131,
+ data = b'Test Using Larger Than Block-Siz'
+ b'e Key - Hash Key First',
hexdigests = {
hashlib.sha224: '95e9a0db962095adaebe9b2d6f0dbce2'
'd499f112f2d2b7273fa6870e',
@@ -168,12 +168,12 @@ class TestVectorsTestCase(unittest.TestCase):
})
# 4.8. Test Case 7
- hmactest(key = '\xaa'*131,
- data = 'This is a test using a larger th'
- 'an block-size key and a larger t'
- 'han block-size data. The key nee'
- 'ds to be hashed before being use'
- 'd by the HMAC algorithm.',
+ hmactest(key = b'\xaa'*131,
+ data = b'This is a test using a larger th'
+ b'an block-size key and a larger t'
+ b'han block-size data. The key nee'
+ b'ds to be hashed before being use'
+ b'd by the HMAC algorithm.',
hexdigests = {
hashlib.sha224: '3a854166ac5d9f023f54d517d0b39dbd'
'946770db9c2b95c9f6f565d1',
@@ -214,12 +214,12 @@ class TestVectorsTestCase(unittest.TestCase):
with warnings.catch_warnings():
warnings.simplefilter('error', RuntimeWarning)
with self.assertRaises(RuntimeWarning):
- hmac.HMAC('a', 'b', digestmod=MockCrazyHash)
+ hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
self.fail('Expected warning about missing block_size')
MockCrazyHash.block_size = 1
with self.assertRaises(RuntimeWarning):
- hmac.HMAC('a', 'b', digestmod=MockCrazyHash)
+ hmac.HMAC(b'a', b'b', digestmod=MockCrazyHash)
self.fail('Expected warning about small block_size')
@@ -230,21 +230,21 @@ class ConstructorTestCase(unittest.TestCase):
# Standard constructor call.
failed = 0
try:
- h = hmac.HMAC("key")
+ h = hmac.HMAC(b"key")
except:
self.fail("Standard constructor call raised exception.")
def test_withtext(self):
# Constructor call with text.
try:
- h = hmac.HMAC("key", "hash this!")
+ h = hmac.HMAC(b"key", b"hash this!")
except:
self.fail("Constructor call with text argument raised exception.")
def test_withmodule(self):
# Constructor call with text and digest module.
try:
- h = hmac.HMAC("key", "", hashlib.sha1)
+ h = hmac.HMAC(b"key", b"", hashlib.sha1)
except:
self.fail("Constructor call with hashlib.sha1 raised exception.")
@@ -253,15 +253,15 @@ class SanityTestCase(unittest.TestCase):
def test_default_is_md5(self):
# Testing if HMAC defaults to MD5 algorithm.
# NOTE: this whitebox test depends on the hmac class internals
- h = hmac.HMAC("key")
- self.assertTrue(h.digest_cons == hashlib.md5)
+ h = hmac.HMAC(b"key")
+ self.assertEqual(h.digest_cons, hashlib.md5)
def test_exercise_all_methods(self):
# Exercising all methods once.
# This must not raise any exceptions
try:
- h = hmac.HMAC("my secret key")
- h.update("compute the hash of this text!")
+ h = hmac.HMAC(b"my secret key")
+ h.update(b"compute the hash of this text!")
dig = h.digest()
dig = h.hexdigest()
h2 = h.copy()
@@ -272,20 +272,20 @@ class CopyTestCase(unittest.TestCase):
def test_attributes(self):
# Testing if attributes are of same type.
- h1 = hmac.HMAC("key")
+ h1 = hmac.HMAC(b"key")
h2 = h1.copy()
self.assertTrue(h1.digest_cons == h2.digest_cons,
"digest constructors don't match.")
- self.assertTrue(type(h1.inner) == type(h2.inner),
+ self.assertEqual(type(h1.inner), type(h2.inner),
"Types of inner don't match.")
- self.assertTrue(type(h1.outer) == type(h2.outer),
+ self.assertEqual(type(h1.outer), type(h2.outer),
"Types of outer don't match.")
def test_realcopy(self):
# Testing if the copy method created a real copy.
- h1 = hmac.HMAC("key")
+ h1 = hmac.HMAC(b"key")
h2 = h1.copy()
- # Using id() in case somebody has overridden __cmp__.
+ # Using id() in case somebody has overridden __eq__/__ne__.
self.assertTrue(id(h1) != id(h2), "No real copy of the HMAC instance.")
self.assertTrue(id(h1.inner) != id(h2.inner),
"No real copy of the attribute 'inner'.")
@@ -294,16 +294,16 @@ class CopyTestCase(unittest.TestCase):
def test_equality(self):
# Testing if the copy has the same digests.
- h1 = hmac.HMAC("key")
- h1.update("some random text")
+ h1 = hmac.HMAC(b"key")
+ h1.update(b"some random text")
h2 = h1.copy()
- self.assertTrue(h1.digest() == h2.digest(),
+ self.assertEqual(h1.digest(), h2.digest(),
"Digest of copy doesn't match original digest.")
- self.assertTrue(h1.hexdigest() == h2.hexdigest(),
+ self.assertEqual(h1.hexdigest(), h2.hexdigest(),
"Hexdigest of copy doesn't match original hexdigest.")
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestVectorsTestCase,
ConstructorTestCase,
SanityTestCase,
diff --git a/Lib/test/test_hotshot.py b/Lib/test/test_hotshot.py
deleted file mode 100644
index 7da9746d789..00000000000
--- a/Lib/test/test_hotshot.py
+++ /dev/null
@@ -1,158 +0,0 @@
-import os
-import pprint
-import unittest
-import tempfile
-import _hotshot
-import gc
-
-from test import test_support
-
-# Silence Py3k warning
-hotshot = test_support.import_module('hotshot', deprecated=True)
-from hotshot.log import ENTER, EXIT, LINE
-from hotshot import stats
-
-
-def shortfilename(fn):
- # We use a really shortened filename since an exact match is made,
- # and the source may be either a Python source file or a
- # pre-compiled bytecode file.
- if fn:
- return os.path.splitext(os.path.basename(fn))[0]
- else:
- return fn
-
-
-class UnlinkingLogReader(hotshot.log.LogReader):
- """Extend the LogReader so the log file is unlinked when we're
- done with it."""
-
- def __init__(self, logfn):
- self.__logfn = logfn
- hotshot.log.LogReader.__init__(self, logfn)
-
- def next(self, index=None):
- try:
- return hotshot.log.LogReader.next(self)
- except StopIteration:
- self.close()
- os.unlink(self.__logfn)
- raise
-
-
-class HotShotTestCase(unittest.TestCase):
- def new_profiler(self, lineevents=0, linetimings=1):
- self.logfn = test_support.TESTFN
- return hotshot.Profile(self.logfn, lineevents, linetimings)
-
- def get_logreader(self):
- return UnlinkingLogReader(self.logfn)
-
- def get_events_wotime(self):
- L = []
- for event in self.get_logreader():
- what, (filename, lineno, funcname), tdelta = event
- L.append((what, (shortfilename(filename), lineno, funcname)))
- return L
-
- def check_events(self, expected):
- events = self.get_events_wotime()
- if events != expected:
- self.fail(
- "events did not match expectation; got:\n%s\nexpected:\n%s"
- % (pprint.pformat(events), pprint.pformat(expected)))
-
- def run_test(self, callable, events, profiler=None):
- if profiler is None:
- profiler = self.new_profiler()
- self.assertTrue(not profiler._prof.closed)
- profiler.runcall(callable)
- self.assertTrue(not profiler._prof.closed)
- profiler.close()
- self.assertTrue(profiler._prof.closed)
- self.check_events(events)
-
- def test_addinfo(self):
- def f(p):
- p.addinfo("test-key", "test-value")
- profiler = self.new_profiler()
- profiler.runcall(f, profiler)
- profiler.close()
- log = self.get_logreader()
- info = log._info
- list(log)
- self.assertTrue(info["test-key"] == ["test-value"])
-
- def test_line_numbers(self):
- def f():
- y = 2
- x = 1
- def g():
- f()
- f_lineno = f.func_code.co_firstlineno
- g_lineno = g.func_code.co_firstlineno
- events = [(ENTER, ("test_hotshot", g_lineno, "g")),
- (LINE, ("test_hotshot", g_lineno+1, "g")),
- (ENTER, ("test_hotshot", f_lineno, "f")),
- (LINE, ("test_hotshot", f_lineno+1, "f")),
- (LINE, ("test_hotshot", f_lineno+2, "f")),
- (EXIT, ("test_hotshot", f_lineno, "f")),
- (EXIT, ("test_hotshot", g_lineno, "g")),
- ]
- self.run_test(g, events, self.new_profiler(lineevents=1))
-
- def test_start_stop(self):
- # Make sure we don't return NULL in the start() and stop()
- # methods when there isn't an error. Bug in 2.2 noted by
- # Anthony Baxter.
- profiler = self.new_profiler()
- profiler.start()
- profiler.stop()
- profiler.close()
- os.unlink(self.logfn)
-
- def test_bad_sys_path(self):
- import sys
- import os
- orig_path = sys.path
- coverage = hotshot._hotshot.coverage
- try:
- # verify we require a list for sys.path
- sys.path = 'abc'
- self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
- # verify that we require sys.path exists
- del sys.path
- self.assertRaises(RuntimeError, coverage, test_support.TESTFN)
- finally:
- sys.path = orig_path
- if os.path.exists(test_support.TESTFN):
- os.remove(test_support.TESTFN)
-
- def test_logreader_eof_error(self):
- emptyfile = tempfile.NamedTemporaryFile()
- try:
- self.assertRaises((IOError, EOFError), _hotshot.logreader,
- emptyfile.name)
- finally:
- emptyfile.close()
- gc.collect()
-
- def test_load_stats(self):
- def start(prof):
- prof.start()
- # Make sure stats can be loaded when start and stop of profiler
- # are not executed in the same stack frame.
- profiler = self.new_profiler()
- start(profiler)
- profiler.stop()
- profiler.close()
- stats.load(self.logfn)
- os.unlink(self.logfn)
-
-
-def test_main():
- test_support.run_unittest(HotShotTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_html.py b/Lib/test/test_html.py
new file mode 100644
index 00000000000..30dac58e6d0
--- /dev/null
+++ b/Lib/test/test_html.py
@@ -0,0 +1,24 @@
+"""
+Tests for the html module functions.
+"""
+
+import html
+import unittest
+from test.support import run_unittest
+
+
+class HtmlTests(unittest.TestCase):
+ def test_escape(self):
+ self.assertEqual(
+ html.escape('\'<script>"&foo;"</script>\''),
+ '&#x27;&lt;script&gt;&quot;&amp;foo;&quot;&lt;/script&gt;&#x27;')
+ self.assertEqual(
+ html.escape('\'<script>"&foo;"</script>\'', False),
+ '\'&lt;script&gt;"&amp;foo;"&lt;/script&gt;\'')
+
+
+def test_main():
+ run_unittest(HtmlTests)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_htmllib.py b/Lib/test/test_htmllib.py
deleted file mode 100644
index 03813b0a7c6..00000000000
--- a/Lib/test/test_htmllib.py
+++ /dev/null
@@ -1,69 +0,0 @@
-import formatter
-import unittest
-
-from test import test_support
-htmllib = test_support.import_module('htmllib', deprecated=True)
-
-
-class AnchorCollector(htmllib.HTMLParser):
- def __init__(self, *args, **kw):
- self.__anchors = []
- htmllib.HTMLParser.__init__(self, *args, **kw)
-
- def get_anchor_info(self):
- return self.__anchors
-
- def anchor_bgn(self, *args):
- self.__anchors.append(args)
-
-class DeclCollector(htmllib.HTMLParser):
- def __init__(self, *args, **kw):
- self.__decls = []
- htmllib.HTMLParser.__init__(self, *args, **kw)
-
- def get_decl_info(self):
- return self.__decls
-
- def unknown_decl(self, data):
- self.__decls.append(data)
-
-
-class HTMLParserTestCase(unittest.TestCase):
- def test_anchor_collection(self):
- # See SF bug #467059.
- parser = AnchorCollector(formatter.NullFormatter(), verbose=1)
- parser.feed(
- """<a href='http://foo.org/' name='splat'> </a>
- <a href='http://www.python.org/'> </a>
- <a name='frob'> </a>
- """)
- parser.close()
- self.assertEqual(parser.get_anchor_info(),
- [('http://foo.org/', 'splat', ''),
- ('http://www.python.org/', '', ''),
- ('', 'frob', ''),
- ])
-
- def test_decl_collection(self):
- # See SF patch #545300
- parser = DeclCollector(formatter.NullFormatter(), verbose=1)
- parser.feed(
- """<html>
- <body>
- hallo
- <![if !supportEmptyParas]>&nbsp;<![endif]>
- </body>
- </html>
- """)
- parser.close()
- self.assertEqual(parser.get_decl_info(),
- ["if !supportEmptyParas",
- "endif"
- ])
-
-def test_main():
- test_support.run_unittest(HTMLParserTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py
index 8cc461f1ee3..c4f80cca30e 100644
--- a/Lib/test/test_htmlparser.py
+++ b/Lib/test/test_htmlparser.py
@@ -1,17 +1,17 @@
"""Tests for HTMLParser.py."""
-import HTMLParser
+import html.parser
import pprint
import unittest
-from test import test_support
+from test import support
-class EventCollector(HTMLParser.HTMLParser):
+class EventCollector(html.parser.HTMLParser):
- def __init__(self):
+ def __init__(self, *args, **kw):
self.events = []
self.append = self.events.append
- HTMLParser.HTMLParser.__init__(self)
+ html.parser.HTMLParser.__init__(self, *args, **kw)
def get_events(self):
# Normalize the list of events so that buffer artefacts don't
@@ -72,8 +72,13 @@ class EventCollectorExtra(EventCollector):
class TestCaseBase(unittest.TestCase):
- def _run_check(self, source, expected_events, collector=EventCollector):
- parser = collector()
+ def get_collector(self):
+ raise NotImplementedError
+
+ def _run_check(self, source, expected_events, collector=None):
+ if collector is None:
+ collector = self.get_collector()
+ parser = collector
for s in source:
parser.feed(s)
parser.close()
@@ -84,17 +89,20 @@ class TestCaseBase(unittest.TestCase):
"\nReceived:\n" + pprint.pformat(events))
def _run_check_extra(self, source, events):
- self._run_check(source, events, EventCollectorExtra)
+ self._run_check(source, events, EventCollectorExtra())
def _parse_error(self, source):
def parse(source=source):
- parser = HTMLParser.HTMLParser()
+ parser = self.get_collector()
parser.feed(source)
parser.close()
- self.assertRaises(HTMLParser.HTMLParseError, parse)
+ self.assertRaises(html.parser.HTMLParseError, parse)
+
+class HTMLParserStrictTestCase(TestCaseBase):
-class HTMLParserTestCase(TestCaseBase):
+ def get_collector(self):
+ return EventCollector(strict=True)
def test_processing_instruction_only(self):
self._run_check("<?processing instruction>", [
@@ -136,6 +144,13 @@ text
("data", "\n"),
])
+ def test_malformatted_charref(self):
+ self._run_check("<p>&#bad;</p>", [
+ ("starttag", "p", []),
+ ("data", "&#bad;"),
+ ("endtag", "p"),
+ ])
+
def test_unclosed_entityref(self):
self._run_check("&entityref foo", [
("entityref", "entityref"),
@@ -164,8 +179,7 @@ text
])
def test_illegal_declarations(self):
- self._run_check('<!spacer type="block" height="25">',
- [('comment', 'spacer type="block" height="25"')])
+ self._parse_error('<!spacer type="block" height="25">')
def test_starttag_end_boundary(self):
self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])])
@@ -202,19 +216,18 @@ text
self._run_check(["<!--abc-->", ""], output)
def test_starttag_junk_chars(self):
- self._run_check("</>", [])
- self._run_check("</$>", [('comment', '$')])
- self._run_check("</", [('data', '</')])
- self._run_check("</a", [('data', '</a')])
- # XXX this might be wrong
- self._run_check("<a<a>", [('data', '<a'), ('starttag', 'a', [])])
- self._run_check("</a<a>", [('endtag', 'a<a')])
- self._run_check("<!", [('data', '<!')])
- self._run_check("<a", [('data', '<a')])
- self._run_check("<a foo='bar'", [('data', "<a foo='bar'")])
- self._run_check("<a foo='bar", [('data', "<a foo='bar")])
- self._run_check("<a foo='>'", [('data', "<a foo='>'")])
- self._run_check("<a foo='>", [('data', "<a foo='>")])
+ self._parse_error("</>")
+ self._parse_error("</$>")
+ self._parse_error("</")
+ self._parse_error("</a")
+ self._parse_error("<a<a>")
+ self._parse_error("</a<a>")
+ self._parse_error("<!")
+ self._parse_error("<a")
+ self._parse_error("<a foo='bar'")
+ self._parse_error("<a foo='bar")
+ self._parse_error("<a foo='>'")
+ self._parse_error("<a foo='>")
def test_valid_doctypes(self):
# from http://www.w3.org/QA/2002/04/valid-dtd-list.html
@@ -240,6 +253,142 @@ text
self._run_check("<!DOCTYPE %s>" % dtd,
[('decl', 'DOCTYPE ' + dtd)])
+ def test_declaration_junk_chars(self):
+ self._parse_error("<!DOCTYPE foo $ >")
+
+ def test_startendtag(self):
+ self._run_check("<p/>", [
+ ("startendtag", "p", []),
+ ])
+ self._run_check("<p></p>", [
+ ("starttag", "p", []),
+ ("endtag", "p"),
+ ])
+ self._run_check("<p><img src='foo' /></p>", [
+ ("starttag", "p", []),
+ ("startendtag", "img", [("src", "foo")]),
+ ("endtag", "p"),
+ ])
+
+ def test_get_starttag_text(self):
+ s = """<foo:bar \n one="1"\ttwo=2 >"""
+ self._run_check_extra(s, [
+ ("starttag", "foo:bar", [("one", "1"), ("two", "2")]),
+ ("starttag_text", s)])
+
+ def test_cdata_content(self):
+ contents = [
+ '<!-- not a comment --> &not-an-entity-ref;',
+ "<not a='start tag'>",
+ '<a href="" /> <p> <span></span>',
+ 'foo = "</scr" + "ipt>";',
+ 'foo = "</SCRIPT" + ">";',
+ 'foo = <\n/script> ',
+ '<!-- document.write("</scr" + "ipt>"); -->',
+ ('\n//<![CDATA[\n'
+ 'document.write(\'<s\'+\'cript type="text/javascript" '
+ 'src="http://www.example.org/r=\'+new '
+ 'Date().getTime()+\'"><\\/s\'+\'cript>\');\n//]]>'),
+ '\n<!-- //\nvar foo = 3.14;\n// -->\n',
+ 'foo = "</sty" + "le>";',
+ '<!-- \u2603 -->',
+ # these two should be invalid according to the HTML 5 spec,
+ # section 8.1.2.2
+ #'foo = </\nscript>',
+ #'foo = </ script>',
+ ]
+ elements = ['script', 'style', 'SCRIPT', 'STYLE', 'Script', 'Style']
+ for content in contents:
+ for element in elements:
+ element_lower = element.lower()
+ s = '<{element}>{content}</{element}>'.format(element=element,
+ content=content)
+ self._run_check(s, [("starttag", element_lower, []),
+ ("data", content),
+ ("endtag", element_lower)])
+
+ def test_cdata_with_closing_tags(self):
+ # see issue #13358
+ # make sure that HTMLParser calls handle_data only once for each CDATA.
+ # The normal event collector normalizes the events in get_events,
+ # so we override it to return the original list of events.
+ class Collector(EventCollector):
+ def get_events(self):
+ return self.events
+
+ content = """<!-- not a comment --> &not-an-entity-ref;
+ <a href="" /> </p><p> <span></span></style>
+ '</script' + '>'"""
+ for element in [' script', 'script ', ' script ',
+ '\nscript', 'script\n', '\nscript\n']:
+ element_lower = element.lower().strip()
+ s = '<script>{content}</{element}>'.format(element=element,
+ content=content)
+ self._run_check(s, [("starttag", element_lower, []),
+ ("data", content),
+ ("endtag", element_lower)],
+ collector=Collector())
+
+ def test_comments(self):
+ html = ("<!-- I'm a valid comment -->"
+ '<!--me too!-->'
+ '<!------>'
+ '<!---->'
+ '<!----I have many hyphens---->'
+ '<!-- I have a > in the middle -->'
+ '<!-- and I have -- in the middle! -->')
+ expected = [('comment', " I'm a valid comment "),
+ ('comment', 'me too!'),
+ ('comment', '--'),
+ ('comment', ''),
+ ('comment', '--I have many hyphens--'),
+ ('comment', ' I have a > in the middle '),
+ ('comment', ' and I have -- in the middle! ')]
+ self._run_check(html, expected)
+
+ def test_condcoms(self):
+ html = ('<!--[if IE & !(lte IE 8)]>aren\'t<![endif]-->'
+ '<!--[if IE 8]>condcoms<![endif]-->'
+ '<!--[if lte IE 7]>pretty?<![endif]-->')
+ expected = [('comment', "[if IE & !(lte IE 8)]>aren't<![endif]"),
+ ('comment', '[if IE 8]>condcoms<![endif]'),
+ ('comment', '[if lte IE 7]>pretty?<![endif]')]
+ self._run_check(html, expected)
+
+
+class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
+
+ def get_collector(self):
+ return EventCollector(strict=False)
+
+ def test_tolerant_parsing(self):
+ self._run_check('<html <html>te>>xt&a<<bc</a></html>\n'
+ '<img src="URL><//img></html</html>', [
+ ('starttag', 'html', [('<html', None)]),
+ ('data', 'te>>xt'),
+ ('entityref', 'a'),
+ ('data', '<<bc'),
+ ('endtag', 'a'),
+ ('endtag', 'html'),
+ ('data', '\n<img src="URL>'),
+ ('comment', '/img'),
+ ('endtag', 'html<')])
+
+ def test_starttag_junk_chars(self):
+ self._run_check("</>", [])
+ self._run_check("</$>", [('comment', '$')])
+ self._run_check("</", [('data', '</')])
+ self._run_check("</a", [('data', '</a')])
+ # XXX this might be wrong
+ self._run_check("<a<a>", [('data', '<a'), ('starttag', 'a', [])])
+ self._run_check("</a<a>", [('endtag', 'a<a')])
+ self._run_check("<!", [('data', '<!')])
+ self._run_check("<a", [('data', '<a')])
+ self._run_check("<a foo='bar'", [('data', "<a foo='bar'")])
+ self._run_check("<a foo='bar", [('data', "<a foo='bar")])
+ self._run_check("<a foo='>'", [('data', "<a foo='>'")])
+ self._run_check("<a foo='>", [('data', "<a foo='>")])
+
def test_slashes_in_starttag(self):
self._run_check('<a foo="var"/>', [('startendtag', 'a', [('foo', 'var')])])
html = ('<img width=902 height=250px '
@@ -274,19 +423,45 @@ text
def test_declaration_junk_chars(self):
self._run_check("<!DOCTYPE foo $ >", [('decl', 'DOCTYPE foo $ ')])
- def test_startendtag(self):
- self._run_check("<p/>", [
- ("startendtag", "p", []),
- ])
- self._run_check("<p></p>", [
- ("starttag", "p", []),
- ("endtag", "p"),
- ])
- self._run_check("<p><img src='foo' /></p>", [
- ("starttag", "p", []),
- ("startendtag", "img", [("src", "foo")]),
- ("endtag", "p"),
- ])
+ def test_illegal_declarations(self):
+ self._run_check('<!spacer type="block" height="25">',
+ [('comment', 'spacer type="block" height="25"')])
+
+ def test_with_unquoted_attributes(self):
+ # see #12008
+ html = ("<html><body bgcolor=d0ca90 text='181008'>"
+ "<table cellspacing=0 cellpadding=1 width=100% ><tr>"
+ "<td align=left><font size=-1>"
+ "- <a href=/rabota/><span class=en> software-and-i</span></a>"
+ "- <a href='/1/'><span class=en> library</span></a></table>")
+ expected = [
+ ('starttag', 'html', []),
+ ('starttag', 'body', [('bgcolor', 'd0ca90'), ('text', '181008')]),
+ ('starttag', 'table',
+ [('cellspacing', '0'), ('cellpadding', '1'), ('width', '100%')]),
+ ('starttag', 'tr', []),
+ ('starttag', 'td', [('align', 'left')]),
+ ('starttag', 'font', [('size', '-1')]),
+ ('data', '- '), ('starttag', 'a', [('href', '/rabota/')]),
+ ('starttag', 'span', [('class', 'en')]), ('data', ' software-and-i'),
+ ('endtag', 'span'), ('endtag', 'a'),
+ ('data', '- '), ('starttag', 'a', [('href', '/1/')]),
+ ('starttag', 'span', [('class', 'en')]), ('data', ' library'),
+ ('endtag', 'span'), ('endtag', 'a'), ('endtag', 'table')
+ ]
+ self._run_check(html, expected)
+
+ def test_comma_between_attributes(self):
+ self._run_check('<form action="/xxx.php?a=1&amp;b=2&amp", '
+ 'method="post">', [
+ ('starttag', 'form',
+ [('action', '/xxx.php?a=1&b=2&amp'),
+ (',', None), ('method', 'post')])])
+
+ def test_weird_chars_in_unquoted_attribute_values(self):
+ self._run_check('<form action=bogus|&#()value>', [
+ ('starttag', 'form',
+ [('action', 'bogus|&#()value')])])
def test_invalid_end_tags(self):
# A collection of broken end tags. <br> is used as separator.
@@ -326,79 +501,100 @@ text
('data', '"> confuses the parser')]
self._run_check(html, expected)
- def test_get_starttag_text(self):
- s = """<foo:bar \n one="1"\ttwo=2 >"""
- self._run_check_extra(s, [
- ("starttag", "foo:bar", [("one", "1"), ("two", "2")]),
- ("starttag_text", s)])
-
- def test_cdata_content(self):
- contents = [
- '<!-- not a comment --> &not-an-entity-ref;',
- "<not a='start tag'>",
- '<a href="" /> <p> <span></span>',
- 'foo = "</scr" + "ipt>";',
- 'foo = "</SCRIPT" + ">";',
- 'foo = <\n/script> ',
- '<!-- document.write("</scr" + "ipt>"); -->',
- ('\n//<![CDATA[\n'
- 'document.write(\'<s\'+\'cript type="text/javascript" '
- 'src="http://www.example.org/r=\'+new '
- 'Date().getTime()+\'"><\\/s\'+\'cript>\');\n//]]>'),
- '\n<!-- //\nvar foo = 3.14;\n// -->\n',
- 'foo = "</sty" + "le>";',
- u'<!-- \u2603 -->',
- # these two should be invalid according to the HTML 5 spec,
- # section 8.1.2.2
- #'foo = </\nscript>',
- #'foo = </ script>',
+ def test_correct_detection_of_start_tags(self):
+ # see #13273
+ html = ('<div style="" ><b>The <a href="some_url">rain</a> '
+ '<br /> in <span>Spain</span></b></div>')
+ expected = [
+ ('starttag', 'div', [('style', '')]),
+ ('starttag', 'b', []),
+ ('data', 'The '),
+ ('starttag', 'a', [('href', 'some_url')]),
+ ('data', 'rain'),
+ ('endtag', 'a'),
+ ('data', ' '),
+ ('startendtag', 'br', []),
+ ('data', ' in '),
+ ('starttag', 'span', []),
+ ('data', 'Spain'),
+ ('endtag', 'span'),
+ ('endtag', 'b'),
+ ('endtag', 'div')
]
- elements = ['script', 'style', 'SCRIPT', 'STYLE', 'Script', 'Style']
- for content in contents:
- for element in elements:
- element_lower = element.lower()
- s = u'<{element}>{content}</{element}>'.format(element=element,
- content=content)
- self._run_check(s, [("starttag", element_lower, []),
- ("data", content),
- ("endtag", element_lower)])
+ self._run_check(html, expected)
- def test_cdata_with_closing_tags(self):
- # see issue #13358
- # make sure that HTMLParser calls handle_data only once for each CDATA.
- # The normal event collector normalizes the events in get_events,
- # so we override it to return the original list of events.
- class Collector(EventCollector):
- def get_events(self):
- return self.events
+ html = '<div style="", foo = "bar" ><b>The <a href="some_url">rain</a>'
+ expected = [
+ ('starttag', 'div', [('style', ''), (',', None), ('foo', 'bar')]),
+ ('starttag', 'b', []),
+ ('data', 'The '),
+ ('starttag', 'a', [('href', 'some_url')]),
+ ('data', 'rain'),
+ ('endtag', 'a'),
+ ]
+ self._run_check(html, expected)
- content = """<!-- not a comment --> &not-an-entity-ref;
- <a href="" /> </p><p> &amp; <span></span></style>
- '</script' + '>' </html> </head> </scripter>!"""
- for element in [' script', 'script ', ' script ',
- '\nscript', 'script\n', '\nscript\n']:
- s = u'<script>{content}</{element}>'.format(element=element,
- content=content)
- self._run_check(s, [("starttag", "script", []),
- ("data", content),
- ("endtag", "script")],
- collector=Collector)
+ def test_unescape_function(self):
+ p = self.get_collector()
+ self.assertEqual(p.unescape('&#bad;'),'&#bad;')
+ self.assertEqual(p.unescape('&#0038;'),'&')
+ # see #12888
+ self.assertEqual(p.unescape('&#123; ' * 1050), '{ ' * 1050)
- def test_malformatted_charref(self):
- self._run_check("<p>&#bad;</p>", [
- ("starttag", "p", []),
- ("data", "&#bad;"),
- ("endtag", "p"),
- ])
+ def test_broken_comments(self):
+ html = ('<! not really a comment >'
+ '<! not a comment either -->'
+ '<! -- close enough -->'
+ '<!><!<-- this was an empty comment>'
+ '<!!! another bogus comment !!!>')
+ expected = [
+ ('comment', ' not really a comment '),
+ ('comment', ' not a comment either --'),
+ ('comment', ' -- close enough --'),
+ ('comment', ''),
+ ('comment', '<-- this was an empty comment'),
+ ('comment', '!! another bogus comment !!!'),
+ ]
+ self._run_check(html, expected)
- def test_unescape_function(self):
- parser = HTMLParser.HTMLParser()
- self.assertEqual(parser.unescape('&#bad;'),'&#bad;')
- self.assertEqual(parser.unescape('&#0038;'),'&')
+ def test_broken_condcoms(self):
+ # these condcoms are missing the '--' after '<!' and before the '>'
+ html = ('<![if !(IE)]>broken condcom<![endif]>'
+ '<![if ! IE]><link href="favicon.tiff"/><![endif]>'
+ '<![if !IE 6]><img src="firefox.png" /><![endif]>'
+ '<![if !ie 6]><b>foo</b><![endif]>'
+ '<![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>')
+ # According to the HTML5 specs sections "8.2.4.44 Bogus comment state"
+ # and "8.2.4.45 Markup declaration open state", comment tokens should
+ # be emitted instead of 'unknown decl', but calling unknown_decl
+ # provides more flexibility.
+ # See also Lib/_markupbase.py:parse_declaration
+ expected = [
+ ('unknown decl', 'if !(IE)'),
+ ('data', 'broken condcom'),
+ ('unknown decl', 'endif'),
+ ('unknown decl', 'if ! IE'),
+ ('startendtag', 'link', [('href', 'favicon.tiff')]),
+ ('unknown decl', 'endif'),
+ ('unknown decl', 'if !IE 6'),
+ ('startendtag', 'img', [('src', 'firefox.png')]),
+ ('unknown decl', 'endif'),
+ ('unknown decl', 'if !ie 6'),
+ ('starttag', 'b', []),
+ ('data', 'foo'),
+ ('endtag', 'b'),
+ ('unknown decl', 'endif'),
+ ('unknown decl', 'if (!IE)|(lt IE 9)'),
+ ('startendtag', 'img', [('src', 'mammoth.bmp')]),
+ ('unknown decl', 'endif')
+ ]
+ self._run_check(html, expected)
+class AttributesStrictTestCase(TestCaseBase):
-class AttributesTestCase(TestCaseBase):
+ def get_collector(self):
+ return EventCollector(strict=True)
def test_attr_syntax(self):
output = [
@@ -427,17 +623,17 @@ class AttributesTestCase(TestCaseBase):
def test_attr_nonascii(self):
# see issue 7311
self._run_check(
- u"<img src=/foo/bar.png alt=\u4e2d\u6587>",
+ "<img src=/foo/bar.png alt=\u4e2d\u6587>",
[("starttag", "img", [("src", "/foo/bar.png"),
- ("alt", u"\u4e2d\u6587")])])
+ ("alt", "\u4e2d\u6587")])])
self._run_check(
- u"<a title='\u30c6\u30b9\u30c8' href='\u30c6\u30b9\u30c8.html'>",
- [("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
- ("href", u"\u30c6\u30b9\u30c8.html")])])
+ "<a title='\u30c6\u30b9\u30c8' href='\u30c6\u30b9\u30c8.html'>",
+ [("starttag", "a", [("title", "\u30c6\u30b9\u30c8"),
+ ("href", "\u30c6\u30b9\u30c8.html")])])
self._run_check(
- u'<a title="\u30c6\u30b9\u30c8" href="\u30c6\u30b9\u30c8.html">',
- [("starttag", "a", [("title", u"\u30c6\u30b9\u30c8"),
- ("href", u"\u30c6\u30b9\u30c8.html")])])
+ '<a title="\u30c6\u30b9\u30c8" href="\u30c6\u30b9\u30c8.html">',
+ [("starttag", "a", [("title", "\u30c6\u30b9\u30c8"),
+ ("href", "\u30c6\u30b9\u30c8.html")])])
def test_attr_entity_replacement(self):
self._run_check(
@@ -448,17 +644,26 @@ class AttributesTestCase(TestCaseBase):
self._run_check(
"<a a.b='v' c:d=v e-f=v>",
[("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")])])
+
+ def test_entityrefs_in_attributes(self):
+ self._run_check(
+ "<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>",
+ [("starttag", "html", [("foo", "\u20AC&aa&unsupported;")])])
+
+
+
+class AttributesTolerantTestCase(AttributesStrictTestCase):
+
+ def get_collector(self):
+ return EventCollector(strict=False)
+
+ def test_attr_funky_names2(self):
self._run_check(
"<a $><b $=%><c \=/>",
[("starttag", "a", [("$", None)]),
("starttag", "b", [("$", "%")]),
("starttag", "c", [("\\", "/")])])
- def test_entityrefs_in_attributes(self):
- self._run_check(
- "<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>",
- [("starttag", "html", [("foo", u"\u20AC&aa&unsupported;")])])
-
def test_entities_in_attribute_value(self):
# see #1200313
for entity in ['&', '&amp;', '&#38;', '&#x26;']:
@@ -482,9 +687,9 @@ class AttributesTestCase(TestCaseBase):
('data', 'test - bad1'), ('endtag', 'a'),
('starttag', 'a', [('href', "test'+style='color:red;ba2'")]),
('data', 'test - bad2'), ('endtag', 'a'),
- ('starttag', 'a', [('href', u"test'\xa0style='color:red;bad3'")]),
+ ('starttag', 'a', [('href', "test'\xa0style='color:red;bad3'")]),
('data', 'test - bad3'), ('endtag', 'a'),
- ('starttag', 'a', [('href', u"test'\xa0style='color:red;bad4'")]),
+ ('starttag', 'a', [('href', "test'\xa0style='color:red;bad4'")]),
('data', 'test - bad4'), ('endtag', 'a')
]
self._run_check(html, expected)
@@ -526,84 +731,11 @@ class AttributesTestCase(TestCaseBase):
[("href", "http://www.example.org/\">;")]),
("data", "spam"), ("endtag", "a")])
- def test_comments(self):
- html = ("<!-- I'm a valid comment -->"
- '<!--me too!-->'
- '<!------>'
- '<!---->'
- '<!----I have many hyphens---->'
- '<!-- I have a > in the middle -->'
- '<!-- and I have -- in the middle! -->')
- expected = [('comment', " I'm a valid comment "),
- ('comment', 'me too!'),
- ('comment', '--'),
- ('comment', ''),
- ('comment', '--I have many hyphens--'),
- ('comment', ' I have a > in the middle '),
- ('comment', ' and I have -- in the middle! ')]
- self._run_check(html, expected)
-
- def test_broken_comments(self):
- html = ('<! not really a comment >'
- '<! not a comment either -->'
- '<! -- close enough -->'
- '<!><!<-- this was an empty comment>'
- '<!!! another bogus comment !!!>')
- expected = [
- ('comment', ' not really a comment '),
- ('comment', ' not a comment either --'),
- ('comment', ' -- close enough --'),
- ('comment', ''),
- ('comment', '<-- this was an empty comment'),
- ('comment', '!! another bogus comment !!!'),
- ]
- self._run_check(html, expected)
-
- def test_condcoms(self):
- html = ('<!--[if IE & !(lte IE 8)]>aren\'t<![endif]-->'
- '<!--[if IE 8]>condcoms<![endif]-->'
- '<!--[if lte IE 7]>pretty?<![endif]-->')
- expected = [('comment', "[if IE & !(lte IE 8)]>aren't<![endif]"),
- ('comment', '[if IE 8]>condcoms<![endif]'),
- ('comment', '[if lte IE 7]>pretty?<![endif]')]
- self._run_check(html, expected)
-
- def test_broken_condcoms(self):
- # these condcoms are missing the '--' after '<!' and before the '>'
- html = ('<![if !(IE)]>broken condcom<![endif]>'
- '<![if ! IE]><link href="favicon.tiff"/><![endif]>'
- '<![if !IE 6]><img src="firefox.png" /><![endif]>'
- '<![if !ie 6]><b>foo</b><![endif]>'
- '<![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>')
- # According to the HTML5 specs sections "8.2.4.44 Bogus comment state"
- # and "8.2.4.45 Markup declaration open state", comment tokens should
- # be emitted instead of 'unknown decl', but calling unknown_decl
- # provides more flexibility.
- # See also Lib/_markupbase.py:parse_declaration
- expected = [
- ('unknown decl', 'if !(IE)'),
- ('data', 'broken condcom'),
- ('unknown decl', 'endif'),
- ('unknown decl', 'if ! IE'),
- ('startendtag', 'link', [('href', 'favicon.tiff')]),
- ('unknown decl', 'endif'),
- ('unknown decl', 'if !IE 6'),
- ('startendtag', 'img', [('src', 'firefox.png')]),
- ('unknown decl', 'endif'),
- ('unknown decl', 'if !ie 6'),
- ('starttag', 'b', []),
- ('data', 'foo'),
- ('endtag', 'b'),
- ('unknown decl', 'endif'),
- ('unknown decl', 'if (!IE)|(lt IE 9)'),
- ('startendtag', 'img', [('src', 'mammoth.bmp')]),
- ('unknown decl', 'endif')
- ]
- self._run_check(html, expected)
def test_main():
- test_support.run_unittest(HTMLParserTestCase, AttributesTestCase)
+ support.run_unittest(HTMLParserStrictTestCase, HTMLParserTolerantTestCase,
+ AttributesStrictTestCase, AttributesTolerantTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_cookielib.py b/Lib/test/test_http_cookiejar.py
index dd0ad325d96..41e0dfde330 100644
--- a/Lib/test/test_cookielib.py
+++ b/Lib/test/test_http_cookiejar.py
@@ -1,21 +1,23 @@
-# -*- coding: latin-1 -*-
-"""Tests for cookielib.py."""
+"""Tests for http/cookiejar.py."""
-import cookielib
import os
import re
+import test.support
import time
+import unittest
+import urllib.request
-from unittest import TestCase
+from http.cookiejar import (time2isoz, http2time, time2netscape,
+ parse_ns_headers, join_header_words, split_header_words, Cookie,
+ CookieJar, DefaultCookiePolicy, LWPCookieJar, MozillaCookieJar,
+ LoadError, lwp_cookie_str, DEFAULT_HTTP_PORT, escape_path,
+ reach, is_HDN, domain_match, user_domain_match, request_path,
+ request_port, request_host)
-from test import test_support
-
-class DateTimeTests(TestCase):
+class DateTimeTests(unittest.TestCase):
def test_time2isoz(self):
- from cookielib import time2isoz
-
base = 1019227000
day = 24*3600
self.assertEqual(time2isoz(base), "2002-04-19 14:36:40Z")
@@ -27,11 +29,9 @@ class DateTimeTests(TestCase):
bz = time2isoz(500000)
for text in (az, bz):
self.assertTrue(re.search(r"^\d{4}-\d\d-\d\d \d\d:\d\d:\d\dZ$", text),
- "bad time2isoz format: %s %s" % (az, bz))
+ "bad time2isoz format: %s %s" % (az, bz))
def test_http2time(self):
- from cookielib import http2time
-
def parse_date(text):
return time.gmtime(http2time(text))[:6]
@@ -44,8 +44,6 @@ class DateTimeTests(TestCase):
self.assertEqual(parse_date("03-Feb-98"), (1998, 2, 3, 0, 0, 0.0))
def test_http2time_formats(self):
- from cookielib import http2time, time2isoz
-
# test http2time for supported dates. Test cases with 2 digit year
# will probably break in year 2044.
tests = [
@@ -83,8 +81,6 @@ class DateTimeTests(TestCase):
"'%s' => %s, %s, %s (%s)" % (s, t, t2, t3, test_t))
def test_http2time_garbage(self):
- from cookielib import http2time
-
for test in [
'',
'Garbage',
@@ -103,13 +99,11 @@ class DateTimeTests(TestCase):
)
-class HeaderTests(TestCase):
-
- def test_parse_ns_headers_expires(self):
- from cookielib import parse_ns_headers
+class HeaderTests(unittest.TestCase):
+ def test_parse_ns_headers(self):
# quotes should be stripped
- expected = [[('foo', 'bar'), ('expires', 2209069412L), ('version', '0')]]
+ expected = [[('foo', 'bar'), ('expires', 2209069412), ('version', '0')]]
for hdr in [
'foo=bar; expires=01 Jan 2040 22:23:32 GMT',
'foo=bar; expires="01 Jan 2040 22:23:32 GMT"',
@@ -117,7 +111,6 @@ class HeaderTests(TestCase):
self.assertEqual(parse_ns_headers([hdr]), expected)
def test_parse_ns_headers_version(self):
- from cookielib import parse_ns_headers
# quotes should be stripped
expected = [[('foo', 'bar'), ('version', '1')]]
@@ -130,24 +123,18 @@ class HeaderTests(TestCase):
def test_parse_ns_headers_special_names(self):
# names such as 'expires' are not special in first name=value pair
# of Set-Cookie: header
- from cookielib import parse_ns_headers
-
# Cookie with name 'expires'
hdr = 'expires=01 Jan 2040 22:23:32 GMT'
expected = [[("expires", "01 Jan 2040 22:23:32 GMT"), ("version", "0")]]
self.assertEqual(parse_ns_headers([hdr]), expected)
def test_join_header_words(self):
- from cookielib import join_header_words
-
joined = join_header_words([[("foo", None), ("bar", "baz")]])
self.assertEqual(joined, "foo; bar=baz")
self.assertEqual(join_header_words([[]]), "")
def test_split_header_words(self):
- from cookielib import split_header_words
-
tests = [
("foo", [[("foo", None)]]),
("foo=bar", [[("foo", "bar")]]),
@@ -171,8 +158,8 @@ class HeaderTests(TestCase):
try:
result = split_header_words([arg])
except:
- import traceback, StringIO
- f = StringIO.StringIO()
+ import traceback, io
+ f = io.StringIO()
traceback.print_exc(None, f)
result = "(error -- traceback follows)\n\n%s" % f.getvalue()
self.assertEqual(result, expect, """
@@ -182,8 +169,6 @@ Got: '%s'
""" % (arg, expect, result))
def test_roundtrip(self):
- from cookielib import split_header_words, join_header_words
-
tests = [
("foo", "foo"),
("foo=bar", "foo=bar"),
@@ -222,9 +207,8 @@ class FakeResponse:
"""
headers: list of RFC822-style 'Key: value' strings
"""
- import mimetools, StringIO
- f = StringIO.StringIO("\n".join(headers))
- self._headers = mimetools.Message(f)
+ import email
+ self._headers = email.message_from_string("\n".join(headers))
self._url = url
def info(self): return self._headers
@@ -236,8 +220,7 @@ def interact_netscape(cookiejar, url, *set_cookie_hdrs):
def _interact(cookiejar, url, set_cookie_hdrs, hdr_name):
"""Perform a single request / response cycle, returning Cookie: header."""
- from urllib2 import Request
- req = Request(url)
+ req = urllib.request.Request(url)
cookiejar.add_cookie_header(req)
cookie_hdr = req.get_header("Cookie", "")
headers = []
@@ -248,11 +231,10 @@ def _interact(cookiejar, url, set_cookie_hdrs, hdr_name):
return cookie_hdr
-class FileCookieJarTests(TestCase):
+class FileCookieJarTests(unittest.TestCase):
def test_lwp_valueless_cookie(self):
# cookies with no value should be saved and loaded consistently
- from cookielib import LWPCookieJar
- filename = test_support.TESTFN
+ filename = test.support.TESTFN
c = LWPCookieJar()
interact_netscape(c, "http://www.acme.com/", 'boo')
self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
@@ -266,32 +248,31 @@ class FileCookieJarTests(TestCase):
self.assertEqual(c._cookies["www.acme.com"]["/"]["boo"].value, None)
def test_bad_magic(self):
- from cookielib import LWPCookieJar, MozillaCookieJar, LoadError
# IOErrors (eg. file doesn't exist) are allowed to propagate
- filename = test_support.TESTFN
+ filename = test.support.TESTFN
for cookiejar_class in LWPCookieJar, MozillaCookieJar:
c = cookiejar_class()
try:
c.load(filename="for this test to work, a file with this "
"filename should not exist")
- except IOError, exc:
+ except IOError as exc:
# exactly IOError, not LoadError
- self.assertEqual(exc.__class__, IOError)
+ self.assertIs(exc.__class__, IOError)
else:
self.fail("expected IOError for invalid filename")
# Invalid contents of cookies file (eg. bad magic string)
# causes a LoadError.
try:
- f = open(filename, "w")
- f.write("oops\n")
- for cookiejar_class in LWPCookieJar, MozillaCookieJar:
- c = cookiejar_class()
- self.assertRaises(LoadError, c.load, filename)
+ with open(filename, "w") as f:
+ f.write("oops\n")
+ for cookiejar_class in LWPCookieJar, MozillaCookieJar:
+ c = cookiejar_class()
+ self.assertRaises(LoadError, c.load, filename)
finally:
try: os.unlink(filename)
except OSError: pass
-class CookieTests(TestCase):
+class CookieTests(unittest.TestCase):
# XXX
# Get rid of string comparisons where not actually testing str / repr.
# .clear() etc.
@@ -344,8 +325,7 @@ class CookieTests(TestCase):
# may require disk access -- in particular, with MSIECookieJar)
# This is only a rough check for performance reasons, so it's not too
# critical as long as it's sufficiently liberal.
- import cookielib, urllib2
- pol = cookielib.DefaultCookiePolicy()
+ pol = DefaultCookiePolicy()
for url, domain, ok in [
("http://foo.bar.com/", "blah.com", False),
("http://foo.bar.com/", "rhubarb.blah.com", False),
@@ -364,17 +344,15 @@ class CookieTests(TestCase):
("http://foo/", "foo.local", True),
("http://foo/", ".local", True),
]:
- request = urllib2.Request(url)
+ request = urllib.request.Request(url)
r = pol.domain_return_ok(domain, request)
if ok: self.assertTrue(r)
else: self.assertTrue(not r)
def test_missing_value(self):
- from cookielib import MozillaCookieJar, lwp_cookie_str
-
# missing = sign in Cookie: header is regarded by Mozilla as a missing
- # name, and by cookielib as a missing value
- filename = test_support.TESTFN
+ # name, and by http.cookiejar as a missing value
+ filename = test.support.TESTFN
c = MozillaCookieJar(filename)
interact_netscape(c, "http://www.acme.com/", 'eggs')
interact_netscape(c, "http://www.acme.com/", '"spam"; path=/foo/')
@@ -406,8 +384,6 @@ class CookieTests(TestCase):
def test_rfc2109_handling(self):
# RFC 2109 cookies are handled as RFC 2965 or Netscape cookies,
# dependent on policy settings
- from cookielib import CookieJar, DefaultCookiePolicy
-
for rfc2109_as_netscape, rfc2965, version in [
# default according to rfc2965 if not explicitly specified
(None, False, 0),
@@ -437,8 +413,6 @@ class CookieTests(TestCase):
self.assertEqual(cookie2965.version, 1)
def test_ns_parser(self):
- from cookielib import CookieJar, DEFAULT_HTTP_PORT
-
c = CookieJar()
interact_netscape(c, "http://www.acme.com/",
'spam=eggs; DoMain=.acme.com; port; blArgh="feep"')
@@ -476,19 +450,15 @@ class CookieTests(TestCase):
def test_ns_parser_special_names(self):
# names such as 'expires' are not special in first name=value pair
# of Set-Cookie: header
- from cookielib import CookieJar
-
c = CookieJar()
interact_netscape(c, "http://www.acme.com/", 'expires=eggs')
interact_netscape(c, "http://www.acme.com/", 'version=eggs; spam=eggs')
cookies = c._cookies["www.acme.com"]["/"]
- self.assertTrue('expires' in cookies)
- self.assertTrue('version' in cookies)
+ self.assertIn('expires', cookies)
+ self.assertIn('version', cookies)
def test_expires(self):
- from cookielib import time2netscape, CookieJar
-
# if expires is in future, keep cookie...
c = CookieJar()
future = time2netscape(time.time()+3600)
@@ -501,7 +471,8 @@ class CookieTests(TestCase):
now)
h = interact_netscape(c, "http://www.acme.com/")
self.assertEqual(len(c), 1)
- self.assertTrue('spam="bar"' in h and "foo" not in h)
+ self.assertIn('spam="bar"', h)
+ self.assertNotIn("foo", h)
# max-age takes precedence over expires, and zero max-age is request to
# delete both new cookie and any old matching cookie
@@ -527,8 +498,6 @@ class CookieTests(TestCase):
# XXX RFC 2965 expiry rules (some apply to V0 too)
def test_default_path(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
# RFC 2965
pol = DefaultCookiePolicy(rfc2965=True)
@@ -569,17 +538,16 @@ class CookieTests(TestCase):
self.assertIn("/blah/rhubarb", c._cookies["www.acme.com"])
def test_default_path_with_query(self):
- cj = cookielib.CookieJar()
+ cj = CookieJar()
uri = "http://example.com/?spam/eggs"
value = 'eggs="bar"'
interact_netscape(cj, uri, value)
- # default path does not include query, so is "/", not "/?spam"
+ # Default path does not include query, so is "/", not "/?spam".
self.assertIn("/", cj._cookies["example.com"])
- # cookie is sent back to the same URI
+ # Cookie is sent back to the same URI.
self.assertEqual(interact_netscape(cj, uri), value)
def test_escape_path(self):
- from cookielib import escape_path
cases = [
# quoted safe
("/foo%2f/bar", "/foo%2F/bar"),
@@ -596,63 +564,55 @@ class CookieTests(TestCase):
# unquoted unsafe
("/foo\031/bar", "/foo%19/bar"),
("/\175foo/bar", "/%7Dfoo/bar"),
+ # unicode, latin-1 range
+ ("/foo/bar\u00fc", "/foo/bar%C3%BC"), # UTF-8 encoded
# unicode
- (u"/foo/bar\uabcd", "/foo/bar%EA%AF%8D"), # UTF-8 encoded
+ ("/foo/bar\uabcd", "/foo/bar%EA%AF%8D"), # UTF-8 encoded
]
for arg, result in cases:
self.assertEqual(escape_path(arg), result)
def test_request_path(self):
- from urllib2 import Request
- from cookielib import request_path
# with parameters
- req = Request("http://www.example.com/rheum/rhaponticum;"
- "foo=bar;sing=song?apples=pears&spam=eggs#ni")
+ req = urllib.request.Request(
+ "http://www.example.com/rheum/rhaponticum;"
+ "foo=bar;sing=song?apples=pears&spam=eggs#ni")
self.assertEqual(request_path(req),
"/rheum/rhaponticum;foo=bar;sing=song")
# without parameters
- req = Request("http://www.example.com/rheum/rhaponticum?"
- "apples=pears&spam=eggs#ni")
+ req = urllib.request.Request(
+ "http://www.example.com/rheum/rhaponticum?"
+ "apples=pears&spam=eggs#ni")
self.assertEqual(request_path(req), "/rheum/rhaponticum")
# missing final slash
- req = Request("http://www.example.com")
+ req = urllib.request.Request("http://www.example.com")
self.assertEqual(request_path(req), "/")
def test_request_port(self):
- from urllib2 import Request
- from cookielib import request_port, DEFAULT_HTTP_PORT
- req = Request("http://www.acme.com:1234/",
- headers={"Host": "www.acme.com:4321"})
+ req = urllib.request.Request("http://www.acme.com:1234/",
+ headers={"Host": "www.acme.com:4321"})
self.assertEqual(request_port(req), "1234")
- req = Request("http://www.acme.com/",
- headers={"Host": "www.acme.com:4321"})
+ req = urllib.request.Request("http://www.acme.com/",
+ headers={"Host": "www.acme.com:4321"})
self.assertEqual(request_port(req), DEFAULT_HTTP_PORT)
def test_request_host(self):
- from urllib2 import Request
- from cookielib import request_host
# this request is illegal (RFC2616, 14.2.3)
- req = Request("http://1.1.1.1/",
- headers={"Host": "www.acme.com:80"})
+ req = urllib.request.Request("http://1.1.1.1/",
+ headers={"Host": "www.acme.com:80"})
# libwww-perl wants this response, but that seems wrong (RFC 2616,
# section 5.2, point 1., and RFC 2965 section 1, paragraph 3)
#self.assertEqual(request_host(req), "www.acme.com")
self.assertEqual(request_host(req), "1.1.1.1")
- req = Request("http://www.acme.com/",
- headers={"Host": "irrelevant.com"})
- self.assertEqual(request_host(req), "www.acme.com")
- # not actually sure this one is valid Request object, so maybe should
- # remove test for no host in url in request_host function?
- req = Request("/resource.html",
- headers={"Host": "www.acme.com"})
+ req = urllib.request.Request("http://www.acme.com/",
+ headers={"Host": "irrelevant.com"})
self.assertEqual(request_host(req), "www.acme.com")
# port shouldn't be in request-host
- req = Request("http://www.acme.com:2345/resource.html",
- headers={"Host": "www.acme.com:5432"})
+ req = urllib.request.Request("http://www.acme.com:2345/resource.html",
+ headers={"Host": "www.acme.com:5432"})
self.assertEqual(request_host(req), "www.acme.com")
def test_is_HDN(self):
- from cookielib import is_HDN
self.assertTrue(is_HDN("foo.bar.com"))
self.assertTrue(is_HDN("1foo2.3bar4.5com"))
self.assertTrue(not is_HDN("192.168.1.1"))
@@ -663,7 +623,6 @@ class CookieTests(TestCase):
self.assertTrue(not is_HDN("foo."))
def test_reach(self):
- from cookielib import reach
self.assertEqual(reach("www.acme.com"), ".acme.com")
self.assertEqual(reach("acme.com"), "acme.com")
self.assertEqual(reach("acme.local"), ".local")
@@ -674,7 +633,6 @@ class CookieTests(TestCase):
self.assertEqual(reach("192.168.0.1"), "192.168.0.1")
def test_domain_match(self):
- from cookielib import domain_match, user_domain_match
self.assertTrue(domain_match("192.168.1.1", "192.168.1.1"))
self.assertTrue(not domain_match("192.168.1.1", ".168.1.1"))
self.assertTrue(domain_match("x.y.com", "x.Y.com"))
@@ -715,7 +673,6 @@ class CookieTests(TestCase):
# domain are rejected.
# XXX far from complete
- from cookielib import CookieJar
c = CookieJar()
interact_2965(c, "http://www.nasty.com/",
'foo=bar; domain=friendly.org; Version="1"')
@@ -724,8 +681,6 @@ class CookieTests(TestCase):
def test_strict_domain(self):
# Cookies whose domain is a country-code tld like .co.uk should
# not be set if CookiePolicy.strict_domain is true.
- from cookielib import CookieJar, DefaultCookiePolicy
-
cp = DefaultCookiePolicy(strict_domain=True)
cj = CookieJar(policy=cp)
interact_netscape(cj, "http://example.co.uk/", 'no=problemo')
@@ -741,8 +696,6 @@ class CookieTests(TestCase):
# Netscape: .www.bar.com, www.bar.com, .bar.com, bar.com, no domain
# should all get accepted, as should .acme.com, acme.com and no domain
# for 2-component domains like acme.com.
- from cookielib import CookieJar, DefaultCookiePolicy
-
c = CookieJar()
# two-component V0 domain is OK
@@ -788,8 +741,6 @@ class CookieTests(TestCase):
self.assertEqual(len(c), 4)
def test_two_component_domain_rfc2965(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
pol = DefaultCookiePolicy(rfc2965=True)
c = CookieJar(pol)
@@ -834,31 +785,28 @@ class CookieTests(TestCase):
self.assertEqual(len(c), 3)
def test_domain_allow(self):
- from cookielib import CookieJar, DefaultCookiePolicy
- from urllib2 import Request
-
c = CookieJar(policy=DefaultCookiePolicy(
blocked_domains=["acme.com"],
allowed_domains=["www.acme.com"]))
- req = Request("http://acme.com/")
+ req = urllib.request.Request("http://acme.com/")
headers = ["Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/"]
res = FakeResponse(headers, "http://acme.com/")
c.extract_cookies(res, req)
self.assertEqual(len(c), 0)
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
self.assertEqual(len(c), 1)
- req = Request("http://www.coyote.com/")
+ req = urllib.request.Request("http://www.coyote.com/")
res = FakeResponse(headers, "http://www.coyote.com/")
c.extract_cookies(res, req)
self.assertEqual(len(c), 1)
# set a cookie with non-allowed domain...
- req = Request("http://www.coyote.com/")
+ req = urllib.request.Request("http://www.coyote.com/")
res = FakeResponse(headers, "http://www.coyote.com/")
cookies = c.make_cookies(res, req)
c.set_cookie(cookies[0])
@@ -868,15 +816,12 @@ class CookieTests(TestCase):
self.assertTrue(not req.has_header("Cookie"))
def test_domain_block(self):
- from cookielib import CookieJar, DefaultCookiePolicy
- from urllib2 import Request
-
pol = DefaultCookiePolicy(
rfc2965=True, blocked_domains=[".acme.com"])
c = CookieJar(policy=pol)
headers = ["Set-Cookie: CUSTOMER=WILE_E_COYOTE; path=/"]
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
self.assertEqual(len(c), 0)
@@ -886,11 +831,11 @@ class CookieTests(TestCase):
self.assertEqual(len(c), 1)
c.clear()
- req = Request("http://www.roadrunner.net/")
+ req = urllib.request.Request("http://www.roadrunner.net/")
res = FakeResponse(headers, "http://www.roadrunner.net/")
c.extract_cookies(res, req)
self.assertEqual(len(c), 1)
- req = Request("http://www.roadrunner.net/")
+ req = urllib.request.Request("http://www.roadrunner.net/")
c.add_cookie_header(req)
self.assertTrue((req.has_header("Cookie") and
req.has_header("Cookie2")))
@@ -901,7 +846,7 @@ class CookieTests(TestCase):
self.assertEqual(len(c), 1)
# set a cookie with blocked domain...
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
res = FakeResponse(headers, "http://www.acme.com/")
cookies = c.make_cookies(res, req)
c.set_cookie(cookies[0])
@@ -911,8 +856,6 @@ class CookieTests(TestCase):
self.assertTrue(not req.has_header("Cookie"))
def test_secure(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
for ns in True, False:
for whitespace in " ", "":
c = CookieJar()
@@ -936,7 +879,6 @@ class CookieTests(TestCase):
"secure cookie registered non-secure")
def test_quote_cookie_value(self):
- from cookielib import CookieJar, DefaultCookiePolicy
c = CookieJar(policy=DefaultCookiePolicy(rfc2965=True))
interact_2965(c, "http://www.acme.com/", r'foo=\b"a"r; Version=1')
h = interact_2965(c, "http://www.acme.com/")
@@ -944,19 +886,15 @@ class CookieTests(TestCase):
def test_missing_final_slash(self):
# Missing slash from request URL's abs_path should be assumed present.
- from cookielib import CookieJar, DefaultCookiePolicy
- from urllib2 import Request
url = "http://www.acme.com"
c = CookieJar(DefaultCookiePolicy(rfc2965=True))
interact_2965(c, url, "foo=bar; Version=1")
- req = Request(url)
+ req = urllib.request.Request(url)
self.assertEqual(len(c), 1)
c.add_cookie_header(req)
self.assertTrue(req.has_header("Cookie"))
def test_domain_mirror(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
pol = DefaultCookiePolicy(rfc2965=True)
c = CookieJar(pol)
@@ -964,7 +902,7 @@ class CookieTests(TestCase):
interact_2965(c, url, "spam=eggs; Version=1")
h = interact_2965(c, url)
self.assertNotIn("Domain", h,
- "absent domain returned with domain present")
+ "absent domain returned with domain present")
c = CookieJar(pol)
url = "http://foo.bar.com/"
@@ -980,8 +918,6 @@ class CookieTests(TestCase):
self.assertIn('$Domain="bar.com"', h, "domain not returned")
def test_path_mirror(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
pol = DefaultCookiePolicy(rfc2965=True)
c = CookieJar(pol)
@@ -997,8 +933,6 @@ class CookieTests(TestCase):
self.assertIn('$Path="/"', h, "path not returned")
def test_port_mirror(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
pol = DefaultCookiePolicy(rfc2965=True)
c = CookieJar(pol)
@@ -1030,8 +964,6 @@ class CookieTests(TestCase):
"values")
def test_no_return_comment(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
c = CookieJar(DefaultCookiePolicy(rfc2965=True))
url = "http://foo.bar.com/"
interact_2965(c, url, 'spam=eggs; Version=1; '
@@ -1043,8 +975,6 @@ class CookieTests(TestCase):
"Comment or CommentURL cookie-attributes returned to server")
def test_Cookie_iterator(self):
- from cookielib import CookieJar, Cookie, DefaultCookiePolicy
-
cs = CookieJar(DefaultCookiePolicy(rfc2965=True))
# add some random cookies
interact_2965(cs, "http://blah.spam.org/", 'foo=eggs; Version=1; '
@@ -1069,7 +999,7 @@ class CookieTests(TestCase):
for i in range(4):
i = 0
for c in cs:
- self.assertIsInstance(c, Cookie)
+ self.assertTrue(isinstance(c, Cookie))
self.assertEqual(c.version, versions[i])
self.assertEqual(c.name, names[i])
self.assertEqual(c.domain, domains[i])
@@ -1077,8 +1007,6 @@ class CookieTests(TestCase):
i = i + 1
def test_parse_ns_headers(self):
- from cookielib import parse_ns_headers
-
# missing domain value (invalid cookie)
self.assertEqual(
parse_ns_headers(["foo=bar; path=/; domain"]),
@@ -1101,10 +1029,8 @@ class CookieTests(TestCase):
def test_bad_cookie_header(self):
def cookiejar_from_cookie_headers(headers):
- from cookielib import CookieJar
- from urllib2 import Request
c = CookieJar()
- req = Request("http://www.example.com/")
+ req = urllib.request.Request("http://www.example.com/")
r = FakeResponse(headers, "http://www.example.com/")
c.extract_cookies(r, req)
return c
@@ -1131,13 +1057,10 @@ class CookieTests(TestCase):
self.assertTrue(cookie.expires is None)
-class LWPCookieTests(TestCase):
+class LWPCookieTests(unittest.TestCase):
# Tests taken from libwww-perl, with a few modifications and additions.
def test_netscape_example_1(self):
- from cookielib import CookieJar, DefaultCookiePolicy
- from urllib2 import Request
-
#-------------------------------------------------------------------
# First we check that it works for the original example at
# http://www.netscape.com/newsref/std/cookie_spec.html
@@ -1180,9 +1103,9 @@ class LWPCookieTests(TestCase):
c = CookieJar(DefaultCookiePolicy(rfc2965 = True))
- #req = Request("http://1.1.1.1/",
+ #req = urllib.request.Request("http://1.1.1.1/",
# headers={"Host": "www.acme.com:80"})
- req = Request("http://www.acme.com:80/",
+ req = urllib.request.Request("http://www.acme.com:80/",
headers={"Host": "www.acme.com:80"})
headers.append(
@@ -1191,7 +1114,7 @@ class LWPCookieTests(TestCase):
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
c.add_cookie_header(req)
self.assertEqual(req.get_header("Cookie"), "CUSTOMER=WILE_E_COYOTE")
@@ -1201,7 +1124,7 @@ class LWPCookieTests(TestCase):
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
- req = Request("http://www.acme.com/foo/bar")
+ req = urllib.request.Request("http://www.acme.com/foo/bar")
c.add_cookie_header(req)
h = req.get_header("Cookie")
@@ -1212,7 +1135,7 @@ class LWPCookieTests(TestCase):
res = FakeResponse(headers, "http://www.acme.com")
c.extract_cookies(res, req)
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
c.add_cookie_header(req)
h = req.get_header("Cookie")
@@ -1220,7 +1143,7 @@ class LWPCookieTests(TestCase):
self.assertIn("CUSTOMER=WILE_E_COYOTE", h)
self.assertNotIn("SHIPPING=FEDEX", h)
- req = Request("http://www.acme.com/foo/")
+ req = urllib.request.Request("http://www.acme.com/foo/")
c.add_cookie_header(req)
h = req.get_header("Cookie")
@@ -1229,9 +1152,6 @@ class LWPCookieTests(TestCase):
self.assertTrue(h.startswith("SHIPPING=FEDEX;"))
def test_netscape_example_2(self):
- from cookielib import CookieJar
- from urllib2 import Request
-
# Second Example transaction sequence:
#
# Assume all mappings from above have been cleared.
@@ -1258,24 +1178,24 @@ class LWPCookieTests(TestCase):
c = CookieJar()
headers = []
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
headers.append("Set-Cookie: PART_NUMBER=ROCKET_LAUNCHER_0001; path=/")
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
- req = Request("http://www.acme.com/")
+ req = urllib.request.Request("http://www.acme.com/")
c.add_cookie_header(req)
self.assertEqual(req.get_header("Cookie"),
- "PART_NUMBER=ROCKET_LAUNCHER_0001")
+ "PART_NUMBER=ROCKET_LAUNCHER_0001")
headers.append(
"Set-Cookie: PART_NUMBER=RIDING_ROCKET_0023; path=/ammo")
res = FakeResponse(headers, "http://www.acme.com/")
c.extract_cookies(res, req)
- req = Request("http://www.acme.com/ammo")
+ req = urllib.request.Request("http://www.acme.com/ammo")
c.add_cookie_header(req)
self.assertTrue(re.search(r"PART_NUMBER=RIDING_ROCKET_0023;\s*"
@@ -1283,7 +1203,6 @@ class LWPCookieTests(TestCase):
req.get_header("Cookie")))
def test_ietf_example_1(self):
- from cookielib import CookieJar, DefaultCookiePolicy
#-------------------------------------------------------------------
# Then we test with the examples from draft-ietf-http-state-man-mec-03.txt
#
@@ -1398,8 +1317,6 @@ class LWPCookieTests(TestCase):
# contains all the cookies received so far.
def test_ietf_example_2(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
# 5.2 Example 2
#
# This example illustrates the effect of the Path attribute. All detail
@@ -1455,8 +1372,6 @@ class LWPCookieTests(TestCase):
def test_rejection(self):
# Test rejection of Set-Cookie2 responses based on domain, path, port.
- from cookielib import DefaultCookiePolicy, LWPCookieJar
-
pol = DefaultCookiePolicy(rfc2965=True)
c = LWPCookieJar(policy=pol)
@@ -1532,7 +1447,7 @@ class LWPCookieTests(TestCase):
self.assertEqual(len(c), 6)
# save and restore
- filename = test_support.TESTFN
+ filename = test.support.TESTFN
try:
c.save(filename, ignore_discard=True)
@@ -1549,32 +1464,30 @@ class LWPCookieTests(TestCase):
def test_url_encoding(self):
# Try some URL encodings of the PATHs.
# (the behaviour here has changed from libwww-perl)
- from cookielib import CookieJar, DefaultCookiePolicy
-
c = CookieJar(DefaultCookiePolicy(rfc2965=True))
- interact_2965(c, "http://www.acme.com/foo%2f%25/%3c%3c%0Anew%E5/%E5",
+ interact_2965(c, "http://www.acme.com/foo%2f%25/"
+ "%3c%3c%0Anew%C3%A5/%C3%A5",
"foo = bar; version = 1")
cookie = interact_2965(
- c, "http://www.acme.com/foo%2f%25/<<%0anewå/æøå",
+ c, "http://www.acme.com/foo%2f%25/<<%0anew\345/\346\370\345",
'bar=baz; path="/foo/"; version=1');
version_re = re.compile(r'^\$version=\"?1\"?', re.I)
- self.assertTrue("foo=bar" in cookie and version_re.search(cookie))
+ self.assertIn("foo=bar", cookie)
+ self.assertTrue(version_re.search(cookie))
cookie = interact_2965(
- c, "http://www.acme.com/foo/%25/<<%0anewå/æøå")
+ c, "http://www.acme.com/foo/%25/<<%0anew\345/\346\370\345")
self.assertTrue(not cookie)
# unicode URL doesn't raise exception
- cookie = interact_2965(c, u"http://www.acme.com/\xfc")
+ cookie = interact_2965(c, "http://www.acme.com/\xfc")
def test_mozilla(self):
# Save / load Mozilla/Netscape cookie file format.
- from cookielib import MozillaCookieJar, DefaultCookiePolicy
-
year_plus_one = time.localtime()[0] + 1
- filename = test_support.TESTFN
+ filename = test.support.TESTFN
c = MozillaCookieJar(filename,
policy=DefaultCookiePolicy(rfc2965=True))
@@ -1613,12 +1526,9 @@ class LWPCookieTests(TestCase):
def test_netscape_misc(self):
# Some additional Netscape cookies tests.
- from cookielib import CookieJar
- from urllib2 import Request
-
c = CookieJar()
headers = []
- req = Request("http://foo.bar.acme.com/foo")
+ req = urllib.request.Request("http://foo.bar.acme.com/foo")
# Netscape allows a host part that contains dots
headers.append("Set-Cookie: Customer=WILE_E_COYOTE; domain=.acme.com")
@@ -1632,16 +1542,13 @@ class LWPCookieTests(TestCase):
res = FakeResponse(headers, "http://www.acme.com/foo")
c.extract_cookies(res, req)
- req = Request("http://foo.bar.acme.com/foo")
+ req = urllib.request.Request("http://foo.bar.acme.com/foo")
c.add_cookie_header(req)
- self.assertTrue(
- "PART_NUMBER=3,4" in req.get_header("Cookie") and
- "Customer=WILE_E_COYOTE" in req.get_header("Cookie"))
+ self.assertIn("PART_NUMBER=3,4", req.get_header("Cookie"))
+ self.assertIn("Customer=WILE_E_COYOTE",req.get_header("Cookie"))
def test_intranet_domains_2965(self):
# Test handling of local intranet hostnames without a dot.
- from cookielib import CookieJar, DefaultCookiePolicy
-
c = CookieJar(DefaultCookiePolicy(rfc2965=True))
interact_2965(c, "http://example/",
"foo1=bar; PORT; Discard; Version=1;")
@@ -1655,8 +1562,6 @@ class LWPCookieTests(TestCase):
self.assertEqual(len(c), 3)
def test_intranet_domains_ns(self):
- from cookielib import CookieJar, DefaultCookiePolicy
-
c = CookieJar(DefaultCookiePolicy(rfc2965 = False))
interact_netscape(c, "http://example/", "foo1=bar")
cookie = interact_netscape(c, "http://example/",
@@ -1669,9 +1574,6 @@ class LWPCookieTests(TestCase):
self.assertEqual(len(c), 2)
def test_empty_path(self):
- from cookielib import CookieJar, DefaultCookiePolicy
- from urllib2 import Request
-
# Test for empty path
# Broken web-server ORION/1.3.38 returns to the client response like
#
@@ -1682,12 +1584,12 @@ class LWPCookieTests(TestCase):
c = CookieJar(DefaultCookiePolicy(rfc2965 = True))
headers = []
- req = Request("http://www.ants.com/")
+ req = urllib.request.Request("http://www.ants.com/")
headers.append("Set-Cookie: JSESSIONID=ABCDERANDOM123; Path=")
res = FakeResponse(headers, "http://www.ants.com/")
c.extract_cookies(res, req)
- req = Request("http://www.ants.com/")
+ req = urllib.request.Request("http://www.ants.com/")
c.add_cookie_header(req)
self.assertEqual(req.get_header("Cookie"),
@@ -1695,7 +1597,7 @@ class LWPCookieTests(TestCase):
self.assertEqual(req.get_header("Cookie2"), '$Version="1"')
# missing path in the request URI
- req = Request("http://www.ants.com:8080")
+ req = urllib.request.Request("http://www.ants.com:8080")
c.add_cookie_header(req)
self.assertEqual(req.get_header("Cookie"),
@@ -1703,15 +1605,12 @@ class LWPCookieTests(TestCase):
self.assertEqual(req.get_header("Cookie2"), '$Version="1"')
def test_session_cookies(self):
- from cookielib import CookieJar
- from urllib2 import Request
-
year_plus_one = time.localtime()[0] + 1
# Check session cookies are deleted properly by
# CookieJar.clear_session_cookies method
- req = Request('http://www.perlmeister.com/scripts')
+ req = urllib.request.Request('http://www.perlmeister.com/scripts')
headers = []
headers.append("Set-Cookie: s1=session;Path=/scripts")
headers.append("Set-Cookie: p1=perm; Domain=.perlmeister.com;"
@@ -1741,7 +1640,7 @@ class LWPCookieTests(TestCase):
counter[key] = counter[key] + 1
self.assertTrue(not (
- # a permanent cookie got lost accidentally
+ # a permanent cookie got lost accidently
counter["perm_after"] != counter["perm_before"] or
# a session cookie hasn't been cleared
counter["session_after"] != 0 or
@@ -1750,7 +1649,7 @@ class LWPCookieTests(TestCase):
def test_main(verbose=None):
- test_support.run_unittest(
+ test.support.run_unittest(
DateTimeTests,
HeaderTests,
CookieTests,
diff --git a/Lib/test/test_http_cookies.py b/Lib/test/test_http_cookies.py
new file mode 100644
index 00000000000..1f1ca5852ef
--- /dev/null
+++ b/Lib/test/test_http_cookies.py
@@ -0,0 +1,187 @@
+# Simple test suite for http/cookies.py
+
+from test.support import run_unittest, run_doctest, check_warnings
+import unittest
+from http import cookies
+
+import warnings
+
+class CookieTests(unittest.TestCase):
+
+ def setUp(self):
+ self._warnings_manager = check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("ignore", ".* class is insecure.*",
+ DeprecationWarning)
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+ def test_basic(self):
+ cases = [
+ {'data': 'chips=ahoy; vienna=finger',
+ 'dict': {'chips':'ahoy', 'vienna':'finger'},
+ 'repr': "<SimpleCookie: chips='ahoy' vienna='finger'>",
+ 'output': 'Set-Cookie: chips=ahoy\nSet-Cookie: vienna=finger'},
+
+ {'data': 'keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"',
+ 'dict': {'keebler' : 'E=mc2; L="Loves"; fudge=\012;'},
+ 'repr': '''<SimpleCookie: keebler='E=mc2; L="Loves"; fudge=\\n;'>''',
+ 'output': 'Set-Cookie: keebler="E=mc2; L=\\"Loves\\"; fudge=\\012;"'},
+
+ # Check illegal cookies that have an '=' char in an unquoted value
+ {'data': 'keebler=E=mc2',
+ 'dict': {'keebler' : 'E=mc2'},
+ 'repr': "<SimpleCookie: keebler='E=mc2'>",
+ 'output': 'Set-Cookie: keebler=E=mc2'},
+ ]
+
+ for case in cases:
+ C = cookies.SimpleCookie()
+ C.load(case['data'])
+ self.assertEqual(repr(C), case['repr'])
+ self.assertEqual(C.output(sep='\n'), case['output'])
+ for k, v in sorted(case['dict'].items()):
+ self.assertEqual(C[k].value, v)
+
+ def test_load(self):
+ C = cookies.SimpleCookie()
+ C.load('Customer="WILE_E_COYOTE"; Version=1; Path=/acme')
+
+ self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE')
+ self.assertEqual(C['Customer']['version'], '1')
+ self.assertEqual(C['Customer']['path'], '/acme')
+
+ self.assertEqual(C.output(['path']),
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
+ self.assertEqual(C.js_output(), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
+ // end hiding -->
+ </script>
+ """)
+ self.assertEqual(C.js_output(['path']), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
+ // end hiding -->
+ </script>
+ """)
+
+ def test_extended_encode(self):
+ # Issue 9824: some browsers don't follow the standard; we now
+ # encode , and ; to keep them from tripping up.
+ C = cookies.SimpleCookie()
+ C['val'] = "some,funky;stuff"
+ self.assertEqual(C.output(['val']),
+ 'Set-Cookie: val="some\\054funky\\073stuff"')
+
+ def test_special_attrs(self):
+ # 'expires'
+ C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
+ C['Customer']['expires'] = 0
+ # can't test exact output, it always depends on current date/time
+ self.assertTrue(C.output().endswith('GMT'))
+
+ # loading 'expires'
+ C = cookies.SimpleCookie()
+ C.load('Customer="W"; expires=Wed, 01 Jan 2010 00:00:00 GMT')
+ self.assertEqual(C['Customer']['expires'],
+ 'Wed, 01 Jan 2010 00:00:00 GMT')
+ C = cookies.SimpleCookie()
+ C.load('Customer="W"; expires=Wed, 01 Jan 98 00:00:00 GMT')
+ self.assertEqual(C['Customer']['expires'],
+ 'Wed, 01 Jan 98 00:00:00 GMT')
+
+ # 'max-age'
+ C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
+ C['Customer']['max-age'] = 10
+ self.assertEqual(C.output(),
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; Max-Age=10')
+
+ # others
+ C = cookies.SimpleCookie('Customer="WILE_E_COYOTE"')
+ C['Customer']['secure'] = True
+ C['Customer']['httponly'] = True
+ self.assertEqual(C.output(),
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; httponly; secure')
+
+ def test_quoted_meta(self):
+ # Try cookie with quoted meta-data
+ C = cookies.SimpleCookie()
+ C.load('Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"')
+ self.assertEqual(C['Customer'].value, 'WILE_E_COYOTE')
+ self.assertEqual(C['Customer']['version'], '1')
+ self.assertEqual(C['Customer']['path'], '/acme')
+
+ self.assertEqual(C.output(['path']),
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; Path=/acme')
+ self.assertEqual(C.js_output(), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme; Version=1";
+ // end hiding -->
+ </script>
+ """)
+ self.assertEqual(C.js_output(['path']), r"""
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "Customer=\"WILE_E_COYOTE\"; Path=/acme";
+ // end hiding -->
+ </script>
+ """)
+
+class MorselTests(unittest.TestCase):
+ """Tests for the Morsel object."""
+
+ def test_reserved_keys(self):
+ M = cookies.Morsel()
+ # tests valid and invalid reserved keys for Morsels
+ for i in M._reserved:
+ # Test that all valid keys are reported as reserved and set them
+ self.assertTrue(M.isReservedKey(i))
+ M[i] = '%s_value' % i
+ for i in M._reserved:
+ # Test that valid key values come out fine
+ self.assertEqual(M[i], '%s_value' % i)
+ for i in "the holy hand grenade".split():
+ # Test that invalid keys raise CookieError
+ self.assertRaises(cookies.CookieError,
+ M.__setitem__, i, '%s_value' % i)
+
+ def test_setter(self):
+ M = cookies.Morsel()
+ # tests the .set method to set keys and their values
+ for i in M._reserved:
+ # Makes sure that all reserved keys can't be set this way
+ self.assertRaises(cookies.CookieError,
+ M.set, i, '%s_value' % i, '%s_value' % i)
+ for i in "thou cast _the- !holy! ^hand| +*grenade~".split():
+ # Try typical use case. Setting decent values.
+ # Check output and js_output.
+ M['path'] = '/foo' # Try a reserved key as well
+ M.set(i, "%s_val" % i, "%s_coded_val" % i)
+ self.assertEqual(
+ M.output(),
+ "Set-Cookie: %s=%s; Path=/foo" % (i, "%s_coded_val" % i))
+ expected_js_output = """
+ <script type="text/javascript">
+ <!-- begin hiding
+ document.cookie = "%s=%s; Path=/foo";
+ // end hiding -->
+ </script>
+ """ % (i, "%s_coded_val" % i)
+ self.assertEqual(M.js_output(), expected_js_output)
+ for i in ["foo bar", "foo@bar"]:
+ # Try some illegal characters
+ self.assertRaises(cookies.CookieError,
+ M.set, i, '%s_value' % i, '%s_value' % i)
+
+
+def test_main():
+ run_unittest(CookieTests, MorselTests)
+ run_doctest(cookies)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py
index bd48fea2412..b0777d42867 100644
--- a/Lib/test/test_httplib.py
+++ b/Lib/test/test_httplib.py
@@ -1,29 +1,39 @@
-import httplib
+import errno
+from http import client
+import io
+import os
import array
-import httplib
-import StringIO
import socket
-import errno
import unittest
TestCase = unittest.TestCase
-from test import test_support
+from test import support
+
+here = os.path.dirname(__file__)
+# Self-signed cert file for 'localhost'
+CERT_localhost = os.path.join(here, 'keycert.pem')
+# Self-signed cert file for 'fakehostname'
+CERT_fakehostname = os.path.join(here, 'keycert2.pem')
+# Root cert file (CA) for svn.python.org's cert
+CACERT_svn_python_org = os.path.join(here, 'https_svn_python_org_root.pem')
-HOST = test_support.HOST
+HOST = support.HOST
class FakeSocket:
- def __init__(self, text, fileclass=StringIO.StringIO):
+ def __init__(self, text, fileclass=io.BytesIO):
+ if isinstance(text, str):
+ text = text.encode("ascii")
self.text = text
self.fileclass = fileclass
- self.data = ''
+ self.data = b''
def sendall(self, data):
- self.data += ''.join(data)
+ self.data += data
def makefile(self, mode, bufsize=None):
if mode != 'r' and mode != 'rb':
- raise httplib.UnimplementedFileMode()
+ raise client.UnimplementedFileMode()
return self.fileclass(self.text)
class EPipeSocket(FakeSocket):
@@ -41,25 +51,24 @@ class EPipeSocket(FakeSocket):
def close(self):
pass
-class NoEOFStringIO(StringIO.StringIO):
+class NoEOFStringIO(io.BytesIO):
"""Like StringIO, but raises AssertionError on EOF.
- This is used below to test that httplib doesn't try to read
+ This is used below to test that http.client doesn't try to read
more from the underlying file than it should.
"""
def read(self, n=-1):
- data = StringIO.StringIO.read(self, n)
- if data == '':
+ data = io.BytesIO.read(self, n)
+ if data == b'':
raise AssertionError('caller tried to read past EOF')
return data
def readline(self, length=None):
- data = StringIO.StringIO.readline(self, length)
- if data == '':
+ data = io.BytesIO.readline(self, length)
+ if data == b'':
raise AssertionError('caller tried to read past EOF')
return data
-
class HeaderTests(TestCase):
def test_auto_headers(self):
# Some headers are added automatically, but should not be added by
@@ -69,17 +78,17 @@ class HeaderTests(TestCase):
def __init__(self):
self.count = {}
def append(self, item):
- kv = item.split(':')
+ kv = item.split(b':')
if len(kv) > 1:
# item is a 'Key: Value' header string
- lcKey = kv[0].lower()
+ lcKey = kv[0].decode('ascii').lower()
self.count.setdefault(lcKey, 0)
self.count[lcKey] += 1
list.append(self, item)
for explicit_header in True, False:
for header in 'Content-length', 'Host', 'Accept-encoding':
- conn = httplib.HTTPConnection('example.com')
+ conn = client.HTTPConnection('example.com')
conn.sock = FakeSocket('blahblahblah')
conn._buffer = HeaderCountingBuffer()
@@ -97,48 +106,48 @@ class HeaderTests(TestCase):
list.__init__(self)
self.content_length = None
def append(self, item):
- kv = item.split(':', 1)
- if len(kv) > 1 and kv[0].lower() == 'content-length':
+ kv = item.split(b':', 1)
+ if len(kv) > 1 and kv[0].lower() == b'content-length':
self.content_length = kv[1].strip()
list.append(self, item)
# POST with empty body
- conn = httplib.HTTPConnection('example.com')
+ conn = client.HTTPConnection('example.com')
conn.sock = FakeSocket(None)
conn._buffer = ContentLengthChecker()
conn.request('POST', '/', '')
- self.assertEqual(conn._buffer.content_length, '0',
+ self.assertEqual(conn._buffer.content_length, b'0',
'Header Content-Length not set')
# PUT request with empty body
- conn = httplib.HTTPConnection('example.com')
+ conn = client.HTTPConnection('example.com')
conn.sock = FakeSocket(None)
conn._buffer = ContentLengthChecker()
conn.request('PUT', '/', '')
- self.assertEqual(conn._buffer.content_length, '0',
+ self.assertEqual(conn._buffer.content_length, b'0',
'Header Content-Length not set')
def test_putheader(self):
- conn = httplib.HTTPConnection('example.com')
+ conn = client.HTTPConnection('example.com')
conn.sock = FakeSocket(None)
conn.putrequest('GET','/')
- conn.putheader('Content-length',42)
- self.assertTrue('Content-length: 42' in conn._buffer)
+ conn.putheader('Content-length', 42)
+ self.assertTrue(b'Content-length: 42' in conn._buffer)
def test_ipv6host_header(self):
# Default host header on IPv6 transaction should wrapped by [] if
# its actual IPv6 address
- expected = 'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \
- 'Accept-Encoding: identity\r\n\r\n'
- conn = httplib.HTTPConnection('[2001::]:81')
+ expected = b'GET /foo HTTP/1.1\r\nHost: [2001::]:81\r\n' \
+ b'Accept-Encoding: identity\r\n\r\n'
+ conn = client.HTTPConnection('[2001::]:81')
sock = FakeSocket('')
conn.sock = sock
conn.request('GET', '/foo')
self.assertTrue(sock.data.startswith(expected))
- expected = 'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \
- 'Accept-Encoding: identity\r\n\r\n'
- conn = httplib.HTTPConnection('[2001:102A::]')
+ expected = b'GET /foo HTTP/1.1\r\nHost: [2001:102A::]\r\n' \
+ b'Accept-Encoding: identity\r\n\r\n'
+ conn = client.HTTPConnection('[2001:102A::]')
sock = FakeSocket('')
conn.sock = sock
conn.request('GET', '/foo')
@@ -151,18 +160,18 @@ class BasicTest(TestCase):
body = "HTTP/1.1 200 Ok\r\n\r\nText"
sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
+ resp = client.HTTPResponse(sock)
resp.begin()
- self.assertEqual(resp.read(), 'Text')
+ self.assertEqual(resp.read(), b"Text")
self.assertTrue(resp.isclosed())
body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
- self.assertRaises(httplib.BadStatusLine, resp.begin)
+ resp = client.HTTPResponse(sock)
+ self.assertRaises(client.BadStatusLine, resp.begin)
def test_bad_status_repr(self):
- exc = httplib.BadStatusLine('')
+ exc = client.BadStatusLine('')
self.assertEqual(repr(exc), '''BadStatusLine("\'\'",)''')
def test_partial_reads(self):
@@ -170,11 +179,11 @@ class BasicTest(TestCase):
# same behaviour than when we read the whole thing with read()
body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
+ resp = client.HTTPResponse(sock)
resp.begin()
- self.assertEqual(resp.read(2), 'Te')
+ self.assertEqual(resp.read(2), b'Te')
self.assertFalse(resp.isclosed())
- self.assertEqual(resp.read(2), 'xt')
+ self.assertEqual(resp.read(2), b'xt')
self.assertTrue(resp.isclosed())
def test_partial_reads_no_content_length(self):
@@ -182,39 +191,36 @@ class BasicTest(TestCase):
# all data was read
body = "HTTP/1.1 200 Ok\r\n\r\nText"
sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
+ resp = client.HTTPResponse(sock)
resp.begin()
- self.assertEqual(resp.read(2), 'Te')
+ self.assertEqual(resp.read(2), b'Te')
self.assertFalse(resp.isclosed())
- self.assertEqual(resp.read(2), 'xt')
- self.assertEqual(resp.read(1), '')
+ self.assertEqual(resp.read(2), b'xt')
+ self.assertEqual(resp.read(1), b'')
self.assertTrue(resp.isclosed())
def test_host_port(self):
# Check invalid host_port
- # Note that httplib does not accept user:password@ in the host-port.
for hp in ("www.python.org:abc", "user:password@www.python.org"):
- self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)
+ self.assertRaises(client.InvalidURL, client.HTTPConnection, hp)
- for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
- 8000),
+ for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000",
+ "fe80::207:e9ff:fe9b", 8000),
("www.python.org:80", "www.python.org", 80),
- ("www.python.org", "www.python.org", 80),
("www.python.org:", "www.python.org", 80),
- ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)):
- http = httplib.HTTP(hp)
- c = http._conn
- if h != c.host:
- self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
- if p != c.port:
- self.fail("Port incorrectly parsed: %s != %s" % (p, c.host))
+ ("www.python.org", "www.python.org", 80),
+ ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80),
+ ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b", 80)):
+ c = client.HTTPConnection(hp)
+ self.assertEqual(h, c.host)
+ self.assertEqual(p, c.port)
def test_response_headers(self):
# test response with multiple message headers with the same field name.
text = ('HTTP/1.1 200 OK\r\n'
- 'Set-Cookie: Customer="WILE_E_COYOTE";'
- ' Version="1"; Path="/acme"\r\n'
+ 'Set-Cookie: Customer="WILE_E_COYOTE"; '
+ 'Version="1"; Path="/acme"\r\n'
'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";'
' Path="/acme"\r\n'
'\r\n'
@@ -223,11 +229,10 @@ class BasicTest(TestCase):
', '
'Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"')
s = FakeSocket(text)
- r = httplib.HTTPResponse(s)
+ r = client.HTTPResponse(s)
r.begin()
cookies = r.getheader("Set-Cookie")
- if cookies != hdr:
- self.fail("multiple headers not combined properly")
+ self.assertEqual(cookies, hdr)
def test_read_head(self):
# Test that the library doesn't attempt to read any data
@@ -237,36 +242,60 @@ class BasicTest(TestCase):
'Content-Length: 14432\r\n'
'\r\n',
NoEOFStringIO)
- resp = httplib.HTTPResponse(sock, method="HEAD")
+ resp = client.HTTPResponse(sock, method="HEAD")
resp.begin()
- if resp.read() != "":
+ if resp.read():
self.fail("Did not expect response from HEAD request")
def test_send_file(self):
- expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
- 'Accept-Encoding: identity\r\nContent-Length:'
+ expected = (b'GET /foo HTTP/1.1\r\nHost: example.com\r\n'
+ b'Accept-Encoding: identity\r\nContent-Length:')
- body = open(__file__, 'rb')
- conn = httplib.HTTPConnection('example.com')
- sock = FakeSocket(body)
- conn.sock = sock
- conn.request('GET', '/foo', body)
- self.assertTrue(sock.data.startswith(expected))
+ with open(__file__, 'rb') as body:
+ conn = client.HTTPConnection('example.com')
+ sock = FakeSocket(body)
+ conn.sock = sock
+ conn.request('GET', '/foo', body)
+ self.assertTrue(sock.data.startswith(expected), '%r != %r' %
+ (sock.data[:len(expected)], expected))
def test_send(self):
- expected = 'this is a test this is only a test'
- conn = httplib.HTTPConnection('example.com')
+ expected = b'this is a test this is only a test'
+ conn = client.HTTPConnection('example.com')
sock = FakeSocket(None)
conn.sock = sock
conn.send(expected)
self.assertEqual(expected, sock.data)
- sock.data = ''
- conn.send(array.array('c', expected))
+ sock.data = b''
+ conn.send(array.array('b', expected))
self.assertEqual(expected, sock.data)
- sock.data = ''
- conn.send(StringIO.StringIO(expected))
+ sock.data = b''
+ conn.send(io.BytesIO(expected))
self.assertEqual(expected, sock.data)
+ def test_send_iter(self):
+ expected = b'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \
+ b'Accept-Encoding: identity\r\nContent-Length: 11\r\n' \
+ b'\r\nonetwothree'
+
+ def body():
+ yield b"one"
+ yield b"two"
+ yield b"three"
+
+ conn = client.HTTPConnection('example.com')
+ sock = FakeSocket("")
+ conn.sock = sock
+ conn.request('GET', '/foo', body(), {'Content-Length': '11'})
+ self.assertEqual(sock.data, expected)
+
+ def test_send_type_error(self):
+ # See: Issue #12676
+ conn = client.HTTPConnection('example.com')
+ conn.sock = FakeSocket('')
+ with self.assertRaises(TypeError):
+ conn.request('POST', 'test', conn)
+
def test_chunked(self):
chunked_start = (
'HTTP/1.1 200 OK\r\n'
@@ -277,19 +306,19 @@ class BasicTest(TestCase):
'd\r\n'
)
sock = FakeSocket(chunked_start + '0\r\n')
- resp = httplib.HTTPResponse(sock, method="GET")
+ resp = client.HTTPResponse(sock, method="GET")
resp.begin()
- self.assertEqual(resp.read(), 'hello world')
+ self.assertEqual(resp.read(), b'hello world')
resp.close()
for x in ('', 'foo\r\n'):
sock = FakeSocket(chunked_start + x)
- resp = httplib.HTTPResponse(sock, method="GET")
+ resp = client.HTTPResponse(sock, method="GET")
resp.begin()
try:
resp.read()
- except httplib.IncompleteRead, i:
- self.assertEqual(i.partial, 'hello world')
+ except client.IncompleteRead as i:
+ self.assertEqual(i.partial, b'hello world')
self.assertEqual(repr(i),'IncompleteRead(11 bytes read)')
self.assertEqual(str(i),'IncompleteRead(11 bytes read)')
else:
@@ -307,29 +336,29 @@ class BasicTest(TestCase):
'd\r\n'
)
sock = FakeSocket(chunked_start + '0\r\n')
- resp = httplib.HTTPResponse(sock, method="HEAD")
+ resp = client.HTTPResponse(sock, method="HEAD")
resp.begin()
- self.assertEqual(resp.read(), '')
+ self.assertEqual(resp.read(), b'')
self.assertEqual(resp.status, 200)
self.assertEqual(resp.reason, 'OK')
self.assertTrue(resp.isclosed())
def test_negative_content_length(self):
- sock = FakeSocket('HTTP/1.1 200 OK\r\n'
- 'Content-Length: -1\r\n\r\nHello\r\n')
- resp = httplib.HTTPResponse(sock, method="GET")
+ sock = FakeSocket(
+ 'HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n')
+ resp = client.HTTPResponse(sock, method="GET")
resp.begin()
- self.assertEqual(resp.read(), 'Hello\r\n')
+ self.assertEqual(resp.read(), b'Hello\r\n')
resp.close()
def test_incomplete_read(self):
sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: 10\r\n\r\nHello\r\n')
- resp = httplib.HTTPResponse(sock, method="GET")
+ resp = client.HTTPResponse(sock, method="GET")
resp.begin()
try:
resp.read()
- except httplib.IncompleteRead as i:
- self.assertEqual(i.partial, 'Hello\r\n')
+ except client.IncompleteRead as i:
+ self.assertEqual(i.partial, b'Hello\r\n')
self.assertEqual(repr(i),
"IncompleteRead(7 bytes read, 3 more expected)")
self.assertEqual(str(i),
@@ -345,7 +374,7 @@ class BasicTest(TestCase):
"Content-type: text/html\r\n"
"WWW-Authenticate: Basic realm=\"example\"\r\n",
b"Content-Length")
- conn = httplib.HTTPConnection("example.com")
+ conn = client.HTTPConnection("example.com")
conn.sock = sock
self.assertRaises(socket.error,
lambda: conn.request("PUT", "/url", "body"))
@@ -354,29 +383,20 @@ class BasicTest(TestCase):
self.assertEqual("Basic realm=\"example\"",
resp.getheader("www-authenticate"))
- def test_filenoattr(self):
- # Just test the fileno attribute in the HTTPResponse Object.
- body = "HTTP/1.1 200 Ok\r\n\r\nText"
- sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
- self.assertTrue(hasattr(resp,'fileno'),
- 'HTTPResponse should expose a fileno attribute')
-
# Test lines overflowing the max line size (_MAXLINE in http.client)
def test_overflowing_status_line(self):
- self.skipTest("disabled for HTTP 0.9 support")
body = "HTTP/1.1 200 Ok" + "k" * 65536 + "\r\n"
- resp = httplib.HTTPResponse(FakeSocket(body))
- self.assertRaises((httplib.LineTooLong, httplib.BadStatusLine), resp.begin)
+ resp = client.HTTPResponse(FakeSocket(body))
+ self.assertRaises((client.LineTooLong, client.BadStatusLine), resp.begin)
def test_overflowing_header_line(self):
body = (
'HTTP/1.1 200 OK\r\n'
'X-Foo: bar' + 'r' * 65536 + '\r\n\r\n'
)
- resp = httplib.HTTPResponse(FakeSocket(body))
- self.assertRaises(httplib.LineTooLong, resp.begin)
+ resp = client.HTTPResponse(FakeSocket(body))
+ self.assertRaises(client.LineTooLong, resp.begin)
def test_overflowing_chunked_line(self):
body = (
@@ -386,29 +406,29 @@ class BasicTest(TestCase):
'hello world\r\n'
'0\r\n'
)
- resp = httplib.HTTPResponse(FakeSocket(body))
+ resp = client.HTTPResponse(FakeSocket(body))
resp.begin()
- self.assertRaises(httplib.LineTooLong, resp.read)
+ self.assertRaises(client.LineTooLong, resp.read)
def test_early_eof(self):
# Test httpresponse with no \r\n termination,
body = "HTTP/1.1 200 Ok"
sock = FakeSocket(body)
- resp = httplib.HTTPResponse(sock)
+ resp = client.HTTPResponse(sock)
resp.begin()
- self.assertEqual(resp.read(), '')
+ self.assertEqual(resp.read(), b'')
self.assertTrue(resp.isclosed())
class OfflineTest(TestCase):
def test_responses(self):
- self.assertEqual(httplib.responses[httplib.NOT_FOUND], "Not Found")
+ self.assertEqual(client.responses[client.NOT_FOUND], "Not Found")
class SourceAddressTest(TestCase):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.serv)
- self.source_port = test_support.find_unused_port()
+ self.port = support.bind_port(self.serv)
+ self.source_port = support.find_unused_port()
self.serv.listen(5)
self.conn = None
@@ -420,15 +440,15 @@ class SourceAddressTest(TestCase):
self.serv = None
def testHTTPConnectionSourceAddress(self):
- self.conn = httplib.HTTPConnection(HOST, self.port,
+ self.conn = client.HTTPConnection(HOST, self.port,
source_address=('', self.source_port))
self.conn.connect()
self.assertEqual(self.conn.sock.getsockname()[1], self.source_port)
- @unittest.skipIf(not hasattr(httplib, 'HTTPSConnection'),
- 'httplib.HTTPSConnection not defined')
+ @unittest.skipIf(not hasattr(client, 'HTTPSConnection'),
+ 'http.client.HTTPSConnection not defined')
def testHTTPSConnectionSourceAddress(self):
- self.conn = httplib.HTTPSConnection(HOST, self.port,
+ self.conn = client.HTTPSConnection(HOST, self.port,
source_address=('', self.source_port))
# We don't test anything here other the constructor not barfing as
# this code doesn't deal with setting up an active running SSL server
@@ -440,7 +460,7 @@ class TimeoutTest(TestCase):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- TimeoutTest.PORT = test_support.bind_port(self.serv)
+ TimeoutTest.PORT = support.bind_port(self.serv)
self.serv.listen(5)
def tearDown(self):
@@ -448,14 +468,14 @@ class TimeoutTest(TestCase):
self.serv = None
def testTimeoutAttribute(self):
- '''This will prove that the timeout gets through
- HTTPConnection and into the socket.
- '''
+ # This will prove that the timeout gets through HTTPConnection
+ # and into the socket.
+
# default -- use global socket timeout
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
- httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT)
+ httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT)
httpConn.connect()
finally:
socket.setdefaulttimeout(None)
@@ -466,7 +486,7 @@ class TimeoutTest(TestCase):
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
- httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT,
+ httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT,
timeout=None)
httpConn.connect()
finally:
@@ -475,46 +495,234 @@ class TimeoutTest(TestCase):
httpConn.close()
# a value
- httpConn = httplib.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30)
+ httpConn = client.HTTPConnection(HOST, TimeoutTest.PORT, timeout=30)
httpConn.connect()
self.assertEqual(httpConn.sock.gettimeout(), 30)
httpConn.close()
-class HTTPSTimeoutTest(TestCase):
-# XXX Here should be tests for HTTPS, there isn't any right now!
+class HTTPSTest(TestCase):
- def test_attributes(self):
- # simple test to check it's storing it
- if hasattr(httplib, 'HTTPSConnection'):
- h = httplib.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
- self.assertEqual(h.timeout, 30)
+ def setUp(self):
+ if not hasattr(client, 'HTTPSConnection'):
+ self.skipTest('ssl support required')
- @unittest.skipIf(not hasattr(httplib, 'HTTPS'), 'httplib.HTTPS not available')
+ def make_server(self, certfile):
+ from test.ssl_servers import make_https_server
+ return make_https_server(self, certfile)
+
+ def test_attributes(self):
+ # simple test to check it's storing the timeout
+ h = client.HTTPSConnection(HOST, TimeoutTest.PORT, timeout=30)
+ self.assertEqual(h.timeout, 30)
+
+ def _check_svn_python_org(self, resp):
+ # Just a simple check that everything went fine
+ server_string = resp.getheader('server')
+ self.assertIn('Apache', server_string)
+
+ def test_networked(self):
+ # Default settings: no cert verification is done
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ h = client.HTTPSConnection('svn.python.org', 443)
+ h.request('GET', '/')
+ resp = h.getresponse()
+ self._check_svn_python_org(resp)
+
+ def test_networked_good_cert(self):
+ # We feed a CA cert that validates the server's cert
+ import ssl
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CACERT_svn_python_org)
+ h = client.HTTPSConnection('svn.python.org', 443, context=context)
+ h.request('GET', '/')
+ resp = h.getresponse()
+ self._check_svn_python_org(resp)
+
+ def test_networked_bad_cert(self):
+ # We feed a "CA" cert that is unrelated to the server's cert
+ import ssl
+ support.requires('network')
+ with support.transient_internet('svn.python.org'):
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_localhost)
+ h = client.HTTPSConnection('svn.python.org', 443, context=context)
+ with self.assertRaises(ssl.SSLError):
+ h.request('GET', '/')
+
+ def test_local_good_hostname(self):
+ # The (valid) cert validates the HTTP hostname
+ import ssl
+ from test.ssl_servers import make_https_server
+ server = make_https_server(self, CERT_localhost)
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_localhost)
+ h = client.HTTPSConnection('localhost', server.port, context=context)
+ h.request('GET', '/nonexistent')
+ resp = h.getresponse()
+ self.assertEqual(resp.status, 404)
+
+ def test_local_bad_hostname(self):
+ # The (valid) cert doesn't validate the HTTP hostname
+ import ssl
+ from test.ssl_servers import make_https_server
+ server = make_https_server(self, CERT_fakehostname)
+ context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERT_fakehostname)
+ h = client.HTTPSConnection('localhost', server.port, context=context)
+ with self.assertRaises(ssl.CertificateError):
+ h.request('GET', '/')
+ # Same with explicit check_hostname=True
+ h = client.HTTPSConnection('localhost', server.port, context=context,
+ check_hostname=True)
+ with self.assertRaises(ssl.CertificateError):
+ h.request('GET', '/')
+ # With check_hostname=False, the mismatching is ignored
+ h = client.HTTPSConnection('localhost', server.port, context=context,
+ check_hostname=False)
+ h.request('GET', '/nonexistent')
+ resp = h.getresponse()
+ self.assertEqual(resp.status, 404)
+
+ @unittest.skipIf(not hasattr(client, 'HTTPSConnection'),
+ 'http.client.HTTPSConnection not available')
def test_host_port(self):
# Check invalid host_port
- # Note that httplib does not accept user:password@ in the host-port.
for hp in ("www.python.org:abc", "user:password@www.python.org"):
- self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)
-
- for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
- 8000),
- ("pypi.python.org:443", "pypi.python.org", 443),
- ("pypi.python.org", "pypi.python.org", 443),
- ("pypi.python.org:", "pypi.python.org", 443),
- ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443)):
- http = httplib.HTTPS(hp)
- c = http._conn
- if h != c.host:
- self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
- if p != c.port:
- self.fail("Port incorrectly parsed: %s != %s" % (p, c.host))
+ self.assertRaises(client.InvalidURL, client.HTTPSConnection, hp)
+
+ for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000",
+ "fe80::207:e9ff:fe9b", 8000),
+ ("www.python.org:443", "www.python.org", 443),
+ ("www.python.org:", "www.python.org", 443),
+ ("www.python.org", "www.python.org", 443),
+ ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 443),
+ ("[fe80::207:e9ff:fe9b]:", "fe80::207:e9ff:fe9b",
+ 443)):
+ c = client.HTTPSConnection(hp)
+ self.assertEqual(h, c.host)
+ self.assertEqual(p, c.port)
+
+
+class RequestBodyTest(TestCase):
+ """Test cases where a request includes a message body."""
+
+ def setUp(self):
+ self.conn = client.HTTPConnection('example.com')
+ self.conn.sock = self.sock = FakeSocket("")
+ self.conn.sock = self.sock
+
+ def get_headers_and_fp(self):
+ f = io.BytesIO(self.sock.data)
+ f.readline() # read the request line
+ message = client.parse_headers(f)
+ return message, f
+
+ def test_manual_content_length(self):
+ # Set an incorrect content-length so that we can verify that
+ # it will not be over-ridden by the library.
+ self.conn.request("PUT", "/url", "body",
+ {"Content-Length": "42"})
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("42", message.get("content-length"))
+ self.assertEqual(4, len(f.read()))
+
+ def test_ascii_body(self):
+ self.conn.request("PUT", "/url", "body")
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("4", message.get("content-length"))
+ self.assertEqual(b'body', f.read())
+
+ def test_latin1_body(self):
+ self.conn.request("PUT", "/url", "body\xc1")
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("5", message.get("content-length"))
+ self.assertEqual(b'body\xc1', f.read())
+
+ def test_bytes_body(self):
+ self.conn.request("PUT", "/url", b"body\xc1")
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("5", message.get("content-length"))
+ self.assertEqual(b'body\xc1', f.read())
+
+ def test_file_body(self):
+ self.addCleanup(support.unlink, support.TESTFN)
+ with open(support.TESTFN, "w") as f:
+ f.write("body")
+ with open(support.TESTFN) as f:
+ self.conn.request("PUT", "/url", f)
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("4", message.get("content-length"))
+ self.assertEqual(b'body', f.read())
+
+ def test_binary_file_body(self):
+ self.addCleanup(support.unlink, support.TESTFN)
+ with open(support.TESTFN, "wb") as f:
+ f.write(b"body\xc1")
+ with open(support.TESTFN, "rb") as f:
+ self.conn.request("PUT", "/url", f)
+ message, f = self.get_headers_and_fp()
+ self.assertEqual("text/plain", message.get_content_type())
+ self.assertIsNone(message.get_charset())
+ self.assertEqual("5", message.get("content-length"))
+ self.assertEqual(b'body\xc1', f.read())
+
+
+class HTTPResponseTest(TestCase):
+
+ def setUp(self):
+ body = "HTTP/1.1 200 Ok\r\nMy-Header: first-value\r\nMy-Header: \
+ second-value\r\n\r\nText"
+ sock = FakeSocket(body)
+ self.resp = client.HTTPResponse(sock)
+ self.resp.begin()
+
+ def test_getting_header(self):
+ header = self.resp.getheader('My-Header')
+ self.assertEqual(header, 'first-value, second-value')
+
+ header = self.resp.getheader('My-Header', 'some default')
+ self.assertEqual(header, 'first-value, second-value')
+
+ def test_getting_nonexistent_header_with_string_default(self):
+ header = self.resp.getheader('No-Such-Header', 'default-value')
+ self.assertEqual(header, 'default-value')
+
+ def test_getting_nonexistent_header_with_iterable_default(self):
+ header = self.resp.getheader('No-Such-Header', ['default', 'values'])
+ self.assertEqual(header, 'default, values')
+
+ header = self.resp.getheader('No-Such-Header', ('default', 'values'))
+ self.assertEqual(header, 'default, values')
+
+ def test_getting_nonexistent_header_without_default(self):
+ header = self.resp.getheader('No-Such-Header')
+ self.assertEqual(header, None)
+ def test_getting_header_defaultint(self):
+ header = self.resp.getheader('No-Such-Header',default=42)
+ self.assertEqual(header, 42)
def test_main(verbose=None):
- test_support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
- HTTPSTimeoutTest, SourceAddressTest)
+ support.run_unittest(HeaderTests, OfflineTest, BasicTest, TimeoutTest,
+ HTTPSTest, RequestBodyTest, SourceAddressTest,
+ HTTPResponseTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 5dcedc0fe8b..d9e40634100 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -4,47 +4,31 @@ Written by Cody A.W. Somerville <cody-somerville@ubuntu.com>,
Josip Dzolonga, and Michael Otteneder for the 2007/08 GHOP contest.
"""
+from http.server import BaseHTTPRequestHandler, HTTPServer, \
+ SimpleHTTPRequestHandler, CGIHTTPRequestHandler
+from http import server
+
import os
import sys
import re
import base64
import shutil
-import urllib
-import httplib
+import urllib.parse
+import http.client
import tempfile
-import unittest
-import CGIHTTPServer
-
-
-from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
-from SimpleHTTPServer import SimpleHTTPRequestHandler
-from CGIHTTPServer import CGIHTTPRequestHandler
-from StringIO import StringIO
-from test import test_support
-
-
-threading = test_support.import_module('threading')
+from io import BytesIO
+import unittest
+from test import support
+threading = support.import_module('threading')
class NoLogRequestHandler:
def log_message(self, *args):
# don't write log messages to stderr
pass
-class SocketlessRequestHandler(SimpleHTTPRequestHandler):
- def __init__(self):
- self.get_called = False
- self.protocol_version = "HTTP/1.1"
-
- def do_GET(self):
- self.get_called = True
- self.send_response(200)
- self.send_header('Content-Type', 'text/html')
- self.end_headers()
- self.wfile.write(b'<html><body>Data</body></html>\r\n')
-
- def log_message(self, fmt, *args):
- pass
+ def read(self, n=None):
+ return ''
class TestServerThread(threading.Thread):
@@ -54,8 +38,8 @@ class TestServerThread(threading.Thread):
self.test_object = test_object
def run(self):
- self.server = HTTPServer(('', 0), self.request_handler)
- self.test_object.PORT = self.server.socket.getsockname()[1]
+ self.server = HTTPServer(('localhost', 0), self.request_handler)
+ self.test_object.HOST, self.test_object.PORT = self.server.socket.getsockname()
self.test_object.server_started.set()
self.test_object = None
try:
@@ -69,8 +53,8 @@ class TestServerThread(threading.Thread):
class BaseTestCase(unittest.TestCase):
def setUp(self):
- self._threads = test_support.threading_setup()
- os.environ = test_support.EnvironmentVarGuard()
+ self._threads = support.threading_setup()
+ os.environ = support.EnvironmentVarGuard()
self.server_started = threading.Event()
self.thread = TestServerThread(self, self.request_handler)
self.thread.start()
@@ -78,78 +62,15 @@ class BaseTestCase(unittest.TestCase):
def tearDown(self):
self.thread.stop()
+ self.thread = None
os.environ.__exit__()
- test_support.threading_cleanup(*self._threads)
+ support.threading_cleanup(*self._threads)
def request(self, uri, method='GET', body=None, headers={}):
- self.connection = httplib.HTTPConnection('localhost', self.PORT)
+ self.connection = http.client.HTTPConnection(self.HOST, self.PORT)
self.connection.request(method, uri, body, headers)
return self.connection.getresponse()
-class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
- """Test the functionality of the BaseHTTPServer focussing on
- BaseHTTPRequestHandler.
- """
-
- HTTPResponseMatch = re.compile('HTTP/1.[0-9]+ 200 OK')
-
- def setUp (self):
- self.handler = SocketlessRequestHandler()
-
- def send_typical_request(self, message):
- input_msg = StringIO(message)
- output = StringIO()
- self.handler.rfile = input_msg
- self.handler.wfile = output
- self.handler.handle_one_request()
- output.seek(0)
- return output.readlines()
-
- def verify_get_called(self):
- self.assertTrue(self.handler.get_called)
-
- def verify_expected_headers(self, headers):
- for fieldName in 'Server: ', 'Date: ', 'Content-Type: ':
- self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1)
-
- def verify_http_server_response(self, response):
- match = self.HTTPResponseMatch.search(response)
- self.assertTrue(match is not None)
-
- def test_http_1_1(self):
- result = self.send_typical_request('GET / HTTP/1.1\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], '<html><body>Data</body></html>\r\n')
-
- def test_http_1_0(self):
- result = self.send_typical_request('GET / HTTP/1.0\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], '<html><body>Data</body></html>\r\n')
-
- def test_http_0_9(self):
- result = self.send_typical_request('GET / HTTP/0.9\r\n\r\n')
- self.assertEqual(len(result), 1)
- self.assertEqual(result[0], '<html><body>Data</body></html>\r\n')
- self.verify_get_called()
-
- def test_with_continue_1_0(self):
- result = self.send_typical_request('GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n')
- self.verify_http_server_response(result[0])
- self.verify_expected_headers(result[1:-1])
- self.verify_get_called()
- self.assertEqual(result[-1], '<html><body>Data</body></html>\r\n')
-
- def test_request_length(self):
- # Issue #10714: huge request lines are discarded, to avoid Denial
- # of Service attacks.
- result = self.send_typical_request(b'GET ' + b'x' * 65537)
- self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n')
- self.assertFalse(self.handler.get_called)
-
class BaseHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, BaseHTTPRequestHandler):
@@ -177,9 +98,17 @@ class BaseHTTPServerTestCase(BaseTestCase):
self.send_header('Connection', 'close')
self.end_headers()
+ def do_LATINONEHEADER(self):
+ self.send_response(999)
+ self.send_header('X-Special', 'Dängerous Mind')
+ self.send_header('Connection', 'close')
+ self.end_headers()
+ body = self.headers['x-special-incoming'].encode('utf-8')
+ self.wfile.write(body)
+
def setUp(self):
BaseTestCase.setUp(self)
- self.con = httplib.HTTPConnection('localhost', self.PORT)
+ self.con = http.client.HTTPConnection(self.HOST, self.PORT)
self.con.connect()
def test_command(self):
@@ -274,6 +203,14 @@ class BaseHTTPServerTestCase(BaseTestCase):
res = self.con.getresponse()
self.assertEqual(res.status, 999)
+ def test_latin1_header(self):
+ self.con.request('LATINONEHEADER', '/', headers={
+ 'X-Special-Incoming': 'Ärger mit Unicode'
+ })
+ res = self.con.getresponse()
+ self.assertEqual(res.getheader('X-Special'), 'Dängerous Mind')
+ self.assertEqual(res.read(), 'Ärger mit Unicode'.encode('utf-8'))
+
class SimpleHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, SimpleHTTPRequestHandler):
@@ -284,19 +221,18 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.cwd = os.getcwd()
basetempdir = tempfile.gettempdir()
os.chdir(basetempdir)
- self.data = 'We are the knights who say Ni!'
+ self.data = b'We are the knights who say Ni!'
self.tempdir = tempfile.mkdtemp(dir=basetempdir)
self.tempdir_name = os.path.basename(self.tempdir)
- temp = open(os.path.join(self.tempdir, 'test'), 'wb')
- temp.write(self.data)
- temp.close()
+ with open(os.path.join(self.tempdir, 'test'), 'wb') as temp:
+ temp.write(self.data)
def tearDown(self):
try:
os.chdir(self.cwd)
try:
shutil.rmtree(self.tempdir)
- except OSError:
+ except:
pass
finally:
BaseTestCase.tearDown(self)
@@ -321,17 +257,16 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.check_status_and_reason(response, 404)
response = self.request('/' + 'ThisDoesNotExist' + '/')
self.check_status_and_reason(response, 404)
- f = open(os.path.join(self.tempdir_name, 'index.html'), 'w')
- response = self.request('/' + self.tempdir_name + '/')
- self.check_status_and_reason(response, 200)
-
- # chmod() doesn't work as expected on Windows, and filesystem
- # permissions are ignored by root on Unix.
- if os.name == 'posix' and os.geteuid() != 0:
- os.chmod(self.tempdir, 0)
- response = self.request(self.tempdir_name + '/')
- self.check_status_and_reason(response, 404)
- os.chmod(self.tempdir, 0755)
+ with open(os.path.join(self.tempdir_name, 'index.html'), 'w') as f:
+ response = self.request('/' + self.tempdir_name + '/')
+ self.check_status_and_reason(response, 200)
+ # chmod() doesn't work as expected on Windows, and filesystem
+ # permissions are ignored by root on Unix.
+ if os.name == 'posix' and os.geteuid() != 0:
+ os.chmod(self.tempdir, 0)
+ response = self.request(self.tempdir_name + '/')
+ self.check_status_and_reason(response, 404)
+ os.chmod(self.tempdir, 0o755)
def test_head(self):
response = self.request(
@@ -355,21 +290,21 @@ class SimpleHTTPServerTestCase(BaseTestCase):
cgi_file1 = """\
#!%s
-print "Content-type: text/html"
-print
-print "Hello World"
+print("Content-type: text/html")
+print()
+print("Hello World")
"""
cgi_file2 = """\
#!%s
import cgi
-print "Content-type: text/html"
-print
+print("Content-type: text/html")
+print()
form = cgi.FieldStorage()
-print "%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
- form.getfirst("bacon"))
+print("%%s, %%s, %%s" %% (form.getfirst("spam"), form.getfirst("eggs"),
+ form.getfirst("bacon")))
"""
@@ -379,31 +314,45 @@ class CGIHTTPServerTestCase(BaseTestCase):
class request_handler(NoLogRequestHandler, CGIHTTPRequestHandler):
pass
+ linesep = os.linesep.encode('ascii')
+
def setUp(self):
BaseTestCase.setUp(self)
+ self.cwd = os.getcwd()
self.parent_dir = tempfile.mkdtemp()
self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin')
os.mkdir(self.cgi_dir)
+ self.file1_path = None
+ self.file2_path = None
# The shebang line should be pure ASCII: use symlink if possible.
# See issue #7668.
- if hasattr(os, 'symlink'):
+ if support.can_symlink():
self.pythonexe = os.path.join(self.parent_dir, 'python')
os.symlink(sys.executable, self.pythonexe)
else:
self.pythonexe = sys.executable
+ try:
+ # The python executable path is written as the first line of the
+ # CGI Python script. The encoding cookie cannot be used, and so the
+ # path should be encodable to the default script encoding (utf-8)
+ self.pythonexe.encode('utf-8')
+ except UnicodeEncodeError:
+ self.tearDown()
+ raise self.skipTest(
+ "Python executable path is not encodable to utf-8")
+
self.file1_path = os.path.join(self.cgi_dir, 'file1.py')
- with open(self.file1_path, 'w') as file1:
+ with open(self.file1_path, 'w', encoding='utf-8') as file1:
file1.write(cgi_file1 % self.pythonexe)
- os.chmod(self.file1_path, 0777)
+ os.chmod(self.file1_path, 0o777)
self.file2_path = os.path.join(self.cgi_dir, 'file2.py')
- with open(self.file2_path, 'w') as file2:
+ with open(self.file2_path, 'w', encoding='utf-8') as file2:
file2.write(cgi_file2 % self.pythonexe)
- os.chmod(self.file2_path, 0777)
+ os.chmod(self.file2_path, 0o777)
- self.cwd = os.getcwd()
os.chdir(self.parent_dir)
def tearDown(self):
@@ -411,8 +360,10 @@ class CGIHTTPServerTestCase(BaseTestCase):
os.chdir(self.cwd)
if self.pythonexe != sys.executable:
os.remove(self.pythonexe)
- os.remove(self.file1_path)
- os.remove(self.file2_path)
+ if self.file1_path:
+ os.remove(self.file1_path)
+ if self.file2_path:
+ os.remove(self.file2_path)
os.rmdir(self.cgi_dir)
os.rmdir(self.parent_dir)
finally:
@@ -450,27 +401,28 @@ class CGIHTTPServerTestCase(BaseTestCase):
'/a/b/c/../d/e/../../../../f/..': '//',
'/a/b/c/../d/e/../../../../f/../.': '//',
}
- for path, expected in test_vectors.iteritems():
+ for path, expected in test_vectors.items():
if isinstance(expected, type) and issubclass(expected, Exception):
self.assertRaises(expected,
- CGIHTTPServer._url_collapse_path, path)
+ server._url_collapse_path, path)
else:
- actual = CGIHTTPServer._url_collapse_path(path)
+ actual = server._url_collapse_path(path)
self.assertEqual(expected, actual,
msg='path = %r\nGot: %r\nWanted: %r' %
(path, actual, expected))
def test_headers_and_content(self):
res = self.request('/cgi-bin/file1.py')
- self.assertEqual(('Hello World\n', 'text/html', 200),
+ self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))
def test_post(self):
- params = urllib.urlencode({'spam' : 1, 'eggs' : 'python', 'bacon' : 123456})
+ params = urllib.parse.urlencode(
+ {'spam' : 1, 'eggs' : 'python', 'bacon' : 123456})
headers = {'Content-type' : 'application/x-www-form-urlencoded'}
res = self.request('/cgi-bin/file2.py', 'POST', params, headers)
- self.assertEqual(res.read(), '1, python, 123456\n')
+ self.assertEqual(res.read(), b'1, python, 123456' + self.linesep)
def test_invaliduri(self):
res = self.request('/cgi-bin/invalid')
@@ -478,27 +430,182 @@ class CGIHTTPServerTestCase(BaseTestCase):
self.assertEqual(res.status, 404)
def test_authorization(self):
- headers = {'Authorization' : 'Basic %s' %
- base64.b64encode('username:pass')}
+ headers = {b'Authorization' : b'Basic ' +
+ base64.b64encode(b'username:pass')}
res = self.request('/cgi-bin/file1.py', 'GET', headers=headers)
- self.assertEqual(('Hello World\n', 'text/html', 200),
+ self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))
def test_no_leading_slash(self):
# http://bugs.python.org/issue2254
res = self.request('cgi-bin/file1.py')
- self.assertEqual(('Hello World\n', 'text/html', 200),
+ self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))
def test_os_environ_is_not_altered(self):
signature = "Test CGI Server"
os.environ['SERVER_SOFTWARE'] = signature
res = self.request('/cgi-bin/file1.py')
- self.assertEqual((b'Hello World\n', 'text/html', 200),
+ self.assertEqual((b'Hello World' + self.linesep, 'text/html', 200),
(res.read(), res.getheader('Content-type'), res.status))
self.assertEqual(os.environ['SERVER_SOFTWARE'], signature)
+class SocketlessRequestHandler(SimpleHTTPRequestHandler):
+ def __init__(self):
+ self.get_called = False
+ self.protocol_version = "HTTP/1.1"
+
+ def do_GET(self):
+ self.get_called = True
+ self.send_response(200)
+ self.send_header('Content-Type', 'text/html')
+ self.end_headers()
+ self.wfile.write(b'<html><body>Data</body></html>\r\n')
+
+ def log_message(self, format, *args):
+ pass
+
+class RejectingSocketlessRequestHandler(SocketlessRequestHandler):
+ def handle_expect_100(self):
+ self.send_error(417)
+ return False
+
+class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
+ """Test the functionality of the BaseHTTPServer.
+
+ Test the support for the Expect 100-continue header.
+ """
+
+ HTTPResponseMatch = re.compile(b'HTTP/1.[0-9]+ 200 OK')
+
+ def setUp (self):
+ self.handler = SocketlessRequestHandler()
+
+ def send_typical_request(self, message):
+ input = BytesIO(message)
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.handle_one_request()
+ output.seek(0)
+ return output.readlines()
+
+ def verify_get_called(self):
+ self.assertTrue(self.handler.get_called)
+
+ def verify_expected_headers(self, headers):
+ for fieldName in b'Server: ', b'Date: ', b'Content-Type: ':
+ self.assertEqual(sum(h.startswith(fieldName) for h in headers), 1)
+
+ def verify_http_server_response(self, response):
+ match = self.HTTPResponseMatch.search(response)
+ self.assertTrue(match is not None)
+
+ def test_http_1_1(self):
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_http_1_0(self):
+ result = self.send_typical_request(b'GET / HTTP/1.0\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_http_0_9(self):
+ result = self.send_typical_request(b'GET / HTTP/0.9\r\n\r\n')
+ self.assertEqual(len(result), 1)
+ self.assertEqual(result[0], b'<html><body>Data</body></html>\r\n')
+ self.verify_get_called()
+
+ def test_with_continue_1_0(self):
+ result = self.send_typical_request(b'GET / HTTP/1.0\r\nExpect: 100-continue\r\n\r\n')
+ self.verify_http_server_response(result[0])
+ self.verify_expected_headers(result[1:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_with_continue_1_1(self):
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 100 Continue\r\n')
+ self.assertEqual(result[1], b'HTTP/1.1 200 OK\r\n')
+ self.verify_expected_headers(result[2:-1])
+ self.verify_get_called()
+ self.assertEqual(result[-1], b'<html><body>Data</body></html>\r\n')
+
+ def test_header_buffering(self):
+
+ def _readAndReseek(f):
+ pos = f.tell()
+ f.seek(0)
+ data = f.read()
+ f.seek(pos)
+ return data
+
+ input = BytesIO(b'GET / HTTP/1.1\r\n\r\n')
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.request_version = 'HTTP/1.1'
+
+ self.handler.send_header('Foo', 'foo')
+ self.handler.send_header('bar', 'bar')
+ self.assertEqual(_readAndReseek(output), b'')
+ self.handler.end_headers()
+ self.assertEqual(_readAndReseek(output),
+ b'Foo: foo\r\nbar: bar\r\n\r\n')
+
+ def test_header_unbuffered_when_continue(self):
+
+ def _readAndReseek(f):
+ pos = f.tell()
+ f.seek(0)
+ data = f.read()
+ f.seek(pos)
+ return data
+
+ input = BytesIO(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ output = BytesIO()
+ self.handler.rfile = input
+ self.handler.wfile = output
+ self.handler.request_version = 'HTTP/1.1'
+
+ self.handler.handle_one_request()
+ self.assertNotEqual(_readAndReseek(output), b'')
+ result = _readAndReseek(output).split(b'\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 100 Continue')
+ self.assertEqual(result[1], b'HTTP/1.1 200 OK')
+
+ def test_with_continue_rejected(self):
+ usual_handler = self.handler # Save to avoid breaking any subsequent tests.
+ self.handler = RejectingSocketlessRequestHandler()
+ result = self.send_typical_request(b'GET / HTTP/1.1\r\nExpect: 100-continue\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 417 Expectation Failed\r\n')
+ self.verify_expected_headers(result[1:-1])
+ # The expect handler should short circuit the usual get method by
+ # returning false here, so get_called should be false
+ self.assertFalse(self.handler.get_called)
+ self.assertEqual(sum(r == b'Connection: close\r\n' for r in result[1:-1]), 1)
+ self.handler = usual_handler # Restore to avoid breaking any subsequent tests.
+
+ def test_request_length(self):
+ # Issue #10714: huge request lines are discarded, to avoid Denial
+ # of Service attacks.
+ result = self.send_typical_request(b'GET ' + b'x' * 65537)
+ self.assertEqual(result[0], b'HTTP/1.1 414 Request-URI Too Long\r\n')
+ self.assertFalse(self.handler.get_called)
+
+ def test_header_length(self):
+ # Issue #6791: same for headers
+ result = self.send_typical_request(
+ b'GET / HTTP/1.1\r\nX-Foo: bar' + b'r' * 65537 + b'\r\n\r\n')
+ self.assertEqual(result[0], b'HTTP/1.1 400 Line too long\r\n')
+ self.assertFalse(self.handler.get_called)
+
class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
""" Test url parsing """
def setUp(self):
@@ -522,14 +629,15 @@ class SimpleHTTPRequestHandlerTestCase(unittest.TestCase):
def test_main(verbose=None):
+ cwd = os.getcwd()
try:
- cwd = os.getcwd()
- test_support.run_unittest(BaseHTTPRequestHandlerTestCase,
- SimpleHTTPRequestHandlerTestCase,
- BaseHTTPServerTestCase,
- SimpleHTTPServerTestCase,
- CGIHTTPServerTestCase
- )
+ support.run_unittest(
+ BaseHTTPRequestHandlerTestCase,
+ BaseHTTPServerTestCase,
+ SimpleHTTPServerTestCase,
+ CGIHTTPServerTestCase,
+ SimpleHTTPRequestHandlerTestCase,
+ )
finally:
os.chdir(cwd)
diff --git a/Lib/test/test_imageop.py b/Lib/test/test_imageop.py
deleted file mode 100755
index 56320fb8973..00000000000
--- a/Lib/test/test_imageop.py
+++ /dev/null
@@ -1,211 +0,0 @@
-#! /usr/bin/env python
-
-"""Test script for the imageop module. This has the side
- effect of partially testing the imgfile module as well.
- Roger E. Masse
-"""
-
-from test.test_support import verbose, unlink, import_module, run_unittest
-
-imageop = import_module('imageop', deprecated=True)
-import uu, os, unittest
-
-
-SIZES = (1, 2, 3, 4)
-_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
-VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
-AAAAA = "A" * 1024
-MAX_LEN = 2**20
-
-
-class InputValidationTests(unittest.TestCase):
-
- def _check(self, name, size=None, *extra):
- func = getattr(imageop, name)
- for height in VALUES:
- for width in VALUES:
- strlen = abs(width * height)
- if size:
- strlen *= size
- if strlen < MAX_LEN:
- data = "A" * strlen
- else:
- data = AAAAA
- if size:
- arguments = (data, size, width, height) + extra
- else:
- arguments = (data, width, height) + extra
- try:
- func(*arguments)
- except (ValueError, imageop.error):
- pass
-
- def check_size(self, name, *extra):
- for size in SIZES:
- self._check(name, size, *extra)
-
- def check(self, name, *extra):
- self._check(name, None, *extra)
-
- def test_input_validation(self):
- self.check_size("crop", 0, 0, 0, 0)
- self.check_size("scale", 1, 0)
- self.check_size("scale", -1, -1)
- self.check_size("tovideo")
- self.check("grey2mono", 128)
- self.check("grey2grey4")
- self.check("grey2grey2")
- self.check("dither2mono")
- self.check("dither2grey2")
- self.check("mono2grey", 0, 0)
- self.check("grey22grey")
- self.check("rgb2rgb8") # nlen*4 == len
- self.check("rgb82rgb")
- self.check("rgb2grey")
- self.check("grey2rgb")
-
-
-def test_main():
-
- run_unittest(InputValidationTests)
-
- try:
- import imgfile
- except ImportError:
- return
-
- # Create binary test files
- uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
-
- image, width, height = getimage('test'+os.extsep+'rgb')
-
- # Return the selected part of image, which should by width by height
- # in size and consist of pixels of psize bytes.
- if verbose:
- print 'crop'
- newimage = imageop.crop (image, 4, width, height, 0, 0, 1, 1)
-
- # Return image scaled to size newwidth by newheight. No interpolation
- # is done, scaling is done by simple-minded pixel duplication or removal.
- # Therefore, computer-generated images or dithered images will
- # not look nice after scaling.
- if verbose:
- print 'scale'
- scaleimage = imageop.scale(image, 4, width, height, 1, 1)
-
- # Run a vertical low-pass filter over an image. It does so by computing
- # each destination pixel as the average of two vertically-aligned source
- # pixels. The main use of this routine is to forestall excessive flicker
- # if the image two vertically-aligned source pixels, hence the name.
- if verbose:
- print 'tovideo'
- videoimage = imageop.tovideo (image, 4, width, height)
-
- # Convert an rgb image to an 8 bit rgb
- if verbose:
- print 'rgb2rgb8'
- greyimage = imageop.rgb2rgb8(image, width, height)
-
- # Convert an 8 bit rgb image to a 24 bit rgb image
- if verbose:
- print 'rgb82rgb'
- image = imageop.rgb82rgb(greyimage, width, height)
-
- # Convert an rgb image to an 8 bit greyscale image
- if verbose:
- print 'rgb2grey'
- greyimage = imageop.rgb2grey(image, width, height)
-
- # Convert an 8 bit greyscale image to a 24 bit rgb image
- if verbose:
- print 'grey2rgb'
- image = imageop.grey2rgb(greyimage, width, height)
-
- # Convert a 8-bit deep greyscale image to a 1-bit deep image by
- # thresholding all the pixels. The resulting image is tightly packed
- # and is probably only useful as an argument to mono2grey.
- if verbose:
- print 'grey2mono'
- monoimage = imageop.grey2mono (greyimage, width, height, 0)
-
- # monoimage, width, height = getimage('monotest.rgb')
- # Convert a 1-bit monochrome image to an 8 bit greyscale or color image.
- # All pixels that are zero-valued on input get value p0 on output and
- # all one-value input pixels get value p1 on output. To convert a
- # monochrome black-and-white image to greyscale pass the values 0 and
- # 255 respectively.
- if verbose:
- print 'mono2grey'
- greyimage = imageop.mono2grey (monoimage, width, height, 0, 255)
-
- # Convert an 8-bit greyscale image to a 1-bit monochrome image using a
- # (simple-minded) dithering algorithm.
- if verbose:
- print 'dither2mono'
- monoimage = imageop.dither2mono (greyimage, width, height)
-
- # Convert an 8-bit greyscale image to a 4-bit greyscale image without
- # dithering.
- if verbose:
- print 'grey2grey4'
- grey4image = imageop.grey2grey4 (greyimage, width, height)
-
- # Convert an 8-bit greyscale image to a 2-bit greyscale image without
- # dithering.
- if verbose:
- print 'grey2grey2'
- grey2image = imageop.grey2grey2 (greyimage, width, height)
-
- # Convert an 8-bit greyscale image to a 2-bit greyscale image with
- # dithering. As for dither2mono, the dithering algorithm is currently
- # very simple.
- if verbose:
- print 'dither2grey2'
- grey2image = imageop.dither2grey2 (greyimage, width, height)
-
- # Convert a 4-bit greyscale image to an 8-bit greyscale image.
- if verbose:
- print 'grey42grey'
- greyimage = imageop.grey42grey (grey4image, width, height)
-
- # Convert a 2-bit greyscale image to an 8-bit greyscale image.
- if verbose:
- print 'grey22grey'
- image = imageop.grey22grey (grey2image, width, height)
-
- # Cleanup
- unlink('test'+os.extsep+'rgb')
-
-def getimage(name):
- """return a tuple consisting of
- image (in 'imgfile' format) width and height
- """
- import imgfile
- try:
- sizes = imgfile.getsizes(name)
- except imgfile.error:
- name = get_qualified_path(name)
- sizes = imgfile.getsizes(name)
- if verbose:
- print 'imgfile opening test image: %s, sizes: %s' % (name, str(sizes))
-
- image = imgfile.read(name)
- return (image, sizes[0], sizes[1])
-
-def get_qualified_path(name):
- """ return a more qualified path to name"""
- import sys
- import os
- path = sys.path
- try:
- path = [os.path.dirname(__file__)] + path
- except NameError:
- pass
- for dir in path:
- fullname = os.path.join(dir, name)
- if os.path.exists(fullname):
- return fullname
- return name
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py
index 2b2213dea90..43ee7df3c43 100644
--- a/Lib/test/test_imaplib.py
+++ b/Lib/test/test_imaplib.py
@@ -1,4 +1,4 @@
-from test import test_support as support
+from test import support
# If we end up with a significant number of tests that don't require
# threading, this test module should be split. Right now we skip
# them all if we don't have threading.
@@ -7,10 +7,11 @@ threading = support.import_module('threading')
from contextlib import contextmanager
import imaplib
import os.path
-import SocketServer
+import socketserver
import time
+import calendar
-from test_support import reap_threads, verbose, transient_internet
+from test.support import reap_threads, verbose, transient_internet, run_with_tz
import unittest
try:
@@ -23,6 +24,25 @@ CERTFILE = None
class TestImaplib(unittest.TestCase):
+ def test_Internaldate2tuple(self):
+ t0 = calendar.timegm((2000, 1, 1, 0, 0, 0, -1, -1, -1))
+ tt = imaplib.Internaldate2tuple(
+ b'25 (INTERNALDATE "01-Jan-2000 00:00:00 +0000")')
+ self.assertEqual(time.mktime(tt), t0)
+ tt = imaplib.Internaldate2tuple(
+ b'25 (INTERNALDATE "01-Jan-2000 11:30:00 +1130")')
+ self.assertEqual(time.mktime(tt), t0)
+ tt = imaplib.Internaldate2tuple(
+ b'25 (INTERNALDATE "31-Dec-1999 12:30:00 -1130")')
+ self.assertEqual(time.mktime(tt), t0)
+
+ @run_with_tz('MST+07MDT,M4.1.0,M10.5.0')
+ def test_Internaldate2tuple_issue10941(self):
+ self.assertNotEqual(imaplib.Internaldate2tuple(
+ b'25 (INTERNALDATE "02-Apr-2000 02:30:00 +0000")'),
+ imaplib.Internaldate2tuple(
+ b'25 (INTERNALDATE "02-Apr-2000 03:30:00 +0000")'))
+
def test_that_Time2Internaldate_returns_a_result(self):
# We can check only that it successfully produces a result,
# not the correctness of the result itself, since the result
@@ -36,7 +56,7 @@ class TestImaplib(unittest.TestCase):
if ssl:
- class SecureTCPServer(SocketServer.TCPServer):
+ class SecureTCPServer(socketserver.TCPServer):
def get_request(self):
newsocket, fromaddr = self.socket.accept()
@@ -55,49 +75,49 @@ else:
IMAP4_SSL = None
-class SimpleIMAPHandler(SocketServer.StreamRequestHandler):
+class SimpleIMAPHandler(socketserver.StreamRequestHandler):
timeout = 1
def _send(self, message):
- if verbose: print "SENT:", message.strip()
+ if verbose: print("SENT: %r" % message.strip())
self.wfile.write(message)
def handle(self):
# Send a welcome message.
- self._send('* OK IMAP4rev1\r\n')
+ self._send(b'* OK IMAP4rev1\r\n')
while 1:
# Gather up input until we receive a line terminator or we timeout.
# Accumulate read(1) because it's simpler to handle the differences
# between naked sockets and SSL sockets.
- line = ''
+ line = b''
while 1:
try:
part = self.rfile.read(1)
- if part == '':
+ if part == b'':
# Naked sockets return empty strings..
return
line += part
except IOError:
# ..but SSLSockets raise exceptions.
return
- if line.endswith('\r\n'):
+ if line.endswith(b'\r\n'):
break
- if verbose: print 'GOT:', line.strip()
+ if verbose: print('GOT: %r' % line.strip())
splitline = line.split()
- tag = splitline[0]
- cmd = splitline[1]
+ tag = splitline[0].decode('ASCII')
+ cmd = splitline[1].decode('ASCII')
args = splitline[2:]
- if hasattr(self, 'cmd_%s' % (cmd,)):
- getattr(self, 'cmd_%s' % (cmd,))(tag, args)
+ if hasattr(self, 'cmd_'+cmd):
+ getattr(self, 'cmd_'+cmd)(tag, args)
else:
- self._send('%s BAD %s unknown\r\n' % (tag, cmd))
+ self._send('{} BAD {} unknown\r\n'.format(tag, cmd).encode('ASCII'))
def cmd_CAPABILITY(self, tag, args):
- self._send('* CAPABILITY IMAP4rev1\r\n')
- self._send('%s OK CAPABILITY completed\r\n' % (tag,))
+ self._send(b'* CAPABILITY IMAP4rev1\r\n')
+ self._send('{} OK CAPABILITY completed\r\n'.format(tag).encode('ASCII'))
class BaseThreadedNetworkedTests(unittest.TestCase):
@@ -110,15 +130,15 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
self.server_close()
raise
- if verbose: print "creating server"
+ if verbose: print("creating server")
server = MyServer(addr, hdlr)
self.assertEqual(server.server_address, server.socket.getsockname())
if verbose:
- print "server created"
- print "ADDR =", addr
- print "CLASS =", self.server_class
- print "HDLR =", server.RequestHandlerClass
+ print("server created")
+ print("ADDR =", addr)
+ print("CLASS =", self.server_class)
+ print("HDLR =", server.RequestHandlerClass)
t = threading.Thread(
name='%s serving' % self.server_class,
@@ -129,14 +149,15 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
kwargs={'poll_interval':0.01})
t.daemon = True # In case this function raises.
t.start()
- if verbose: print "server running"
+ if verbose: print("server running")
return server, t
def reap_server(self, server, thread):
- if verbose: print "waiting for server"
+ if verbose: print("waiting for server")
server.shutdown()
+ server.server_close()
thread.join()
- if verbose: print "done"
+ if verbose: print("done")
@contextmanager
def reaped_server(self, hdlr):
@@ -155,19 +176,33 @@ class BaseThreadedNetworkedTests(unittest.TestCase):
@reap_threads
def test_issue5949(self):
- class EOFHandler(SocketServer.StreamRequestHandler):
+ class EOFHandler(socketserver.StreamRequestHandler):
def handle(self):
# EOF without sending a complete welcome message.
- self.wfile.write('* OK')
+ self.wfile.write(b'* OK')
with self.reaped_server(EOFHandler) as server:
self.assertRaises(imaplib.IMAP4.abort,
self.imap_class, *server.server_address)
+ @reap_threads
+ def test_line_termination(self):
+
+ class BadNewlineHandler(SimpleIMAPHandler):
+
+ def cmd_CAPABILITY(self, tag, args):
+ self._send(b'* CAPABILITY IMAP4rev1 AUTH\n')
+ self._send('{} OK CAPABILITY completed\r\n'.format(tag).encode('ASCII'))
+
+ with self.reaped_server(BadNewlineHandler) as server:
+ self.assertRaises(imaplib.IMAP4.abort,
+ self.imap_class, *server.server_address)
+
+
class ThreadedNetworkedTests(BaseThreadedNetworkedTests):
- server_class = SocketServer.TCPServer
+ server_class = socketserver.TCPServer
imap_class = imaplib.IMAP4
@@ -191,20 +226,38 @@ class RemoteIMAPTest(unittest.TestCase):
def tearDown(self):
if self.server is not None:
- self.server.logout()
+ with transient_internet(self.host):
+ self.server.logout()
def test_logincapa(self):
- self.assertTrue('LOGINDISABLED' in self.server.capabilities)
-
- def test_anonlogin(self):
- self.assertTrue('AUTH=ANONYMOUS' in self.server.capabilities)
- rs = self.server.login(self.username, self.password)
- self.assertEqual(rs[0], 'OK')
+ with transient_internet(self.host):
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
+ self.assertIn('LOGINDISABLED', self.server.capabilities)
+ self.assertIn('AUTH=ANONYMOUS', self.server.capabilities)
+ rs = self.server.login(self.username, self.password)
+ self.assertEqual(rs[0], 'OK')
def test_logout(self):
- rs = self.server.logout()
- self.server = None
- self.assertEqual(rs[0], 'BYE')
+ with transient_internet(self.host):
+ rs = self.server.logout()
+ self.server = None
+ self.assertEqual(rs[0], 'BYE')
+
+
+@unittest.skipUnless(ssl, "SSL not available")
+class RemoteIMAP_STARTTLSTest(RemoteIMAPTest):
+
+ def setUp(self):
+ super().setUp()
+ with transient_internet(self.host):
+ rs = self.server.starttls()
+ self.assertEqual(rs[0], 'OK')
+
+ def test_logincapa(self):
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
+ self.assertNotIn('LOGINDISABLED', self.server.capabilities)
@unittest.skipUnless(ssl, "SSL not available")
@@ -213,8 +266,10 @@ class RemoteIMAP_SSLTest(RemoteIMAPTest):
imap_class = IMAP4_SSL
def test_logincapa(self):
- self.assertFalse('LOGINDISABLED' in self.server.capabilities)
- self.assertTrue('AUTH=PLAIN' in self.server.capabilities)
+ for cap in self.server.capabilities:
+ self.assertIsInstance(cap, str)
+ self.assertNotIn('LOGINDISABLED', self.server.capabilities)
+ self.assertIn('AUTH=PLAIN', self.server.capabilities)
def test_main():
@@ -229,7 +284,7 @@ def test_main():
raise support.TestFailed("Can't read certificate files!")
tests.extend([
ThreadedNetworkedTests, ThreadedNetworkedTestsSSL,
- RemoteIMAPTest, RemoteIMAP_SSLTest,
+ RemoteIMAPTest, RemoteIMAP_SSLTest, RemoteIMAP_STARTTLSTest,
])
support.run_unittest(*tests)
diff --git a/Lib/test/test_imgfile.py b/Lib/test/test_imgfile.py
deleted file mode 100755
index 39e891769d1..00000000000
--- a/Lib/test/test_imgfile.py
+++ /dev/null
@@ -1,119 +0,0 @@
-#! /usr/bin/env python
-
-"""Simple test script for imgfile.c
- Roger E. Masse
-"""
-
-from test.test_support import verbose, unlink, findfile, import_module
-
-imgfile = import_module('imgfile', deprecated=True)
-import uu
-
-
-def testimage(name):
- """Run through the imgfile's battery of possible methods
- on the image passed in name.
- """
-
- import sys
- import os
-
- outputfile = '/tmp/deleteme'
-
- # try opening the name directly
- try:
- # This function returns a tuple (x, y, z) where x and y are the size
- # of the image in pixels and z is the number of bytes per pixel. Only
- # 3 byte RGB pixels and 1 byte greyscale pixels are supported.
- sizes = imgfile.getsizes(name)
- except imgfile.error:
- # get a more qualified path component of the script...
- if __name__ == '__main__':
- ourname = sys.argv[0]
- else: # ...or the full path of the module
- ourname = sys.modules[__name__].__file__
-
- parts = ourname.split(os.sep)
- parts[-1] = name
- name = os.sep.join(parts)
- sizes = imgfile.getsizes(name)
- if verbose:
- print 'Opening test image: %s, sizes: %s' % (name, str(sizes))
- # This function reads and decodes the image on the specified file,
- # and returns it as a python string. The string has either 1 byte
- # greyscale pixels or 4 byte RGBA pixels. The bottom left pixel
- # is the first in the string. This format is suitable to pass
- # to gl.lrectwrite, for instance.
- image = imgfile.read(name)
-
- # This function writes the RGB or greyscale data in data to
- # image file file. x and y give the size of the image, z is
- # 1 for 1 byte greyscale images or 3 for RGB images (which
- # are stored as 4 byte values of which only the lower three
- # bytes are used). These are the formats returned by gl.lrectread.
- if verbose:
- print 'Writing output file'
- imgfile.write (outputfile, image, sizes[0], sizes[1], sizes[2])
-
-
- if verbose:
- print 'Opening scaled test image: %s, sizes: %s' % (name, str(sizes))
- # This function is identical to read but it returns an image that
- # is scaled to the given x and y sizes. If the filter and blur
- # parameters are omitted scaling is done by simply dropping
- # or duplicating pixels, so the result will be less than perfect,
- # especially for computer-generated images. Alternatively,
- # you can specify a filter to use to smoothen the image after
- # scaling. The filter forms supported are 'impulse', 'box',
- # 'triangle', 'quadratic' and 'gaussian'. If a filter is
- # specified blur is an optional parameter specifying the
- # blurriness of the filter. It defaults to 1.0. readscaled
- # makes no attempt to keep the aspect ratio correct, so that
- # is the users' responsibility.
- if verbose:
- print 'Filtering with "impulse"'
- simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'impulse', 2.0)
-
- # This function sets a global flag which defines whether the
- # scan lines of the image are read or written from bottom to
- # top (flag is zero, compatible with SGI GL) or from top to
- # bottom(flag is one, compatible with X). The default is zero.
- if verbose:
- print 'Switching to X compatibility'
- imgfile.ttob (1)
-
- if verbose:
- print 'Filtering with "triangle"'
- simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'triangle', 3.0)
- if verbose:
- print 'Switching back to SGI compatibility'
- imgfile.ttob (0)
-
- if verbose: print 'Filtering with "quadratic"'
- simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'quadratic')
- if verbose: print 'Filtering with "gaussian"'
- simage = imgfile.readscaled (name, sizes[0]/2, sizes[1]/2, 'gaussian', 1.0)
-
- if verbose:
- print 'Writing output file'
- imgfile.write (outputfile, simage, sizes[0]/2, sizes[1]/2, sizes[2])
-
- os.unlink(outputfile)
-
-
-def test_main():
-
- uu.decode(findfile('testrgb.uue'), 'test.rgb')
- uu.decode(findfile('greyrgb.uue'), 'greytest.rgb')
-
- # Test a 3 byte color image
- testimage('test.rgb')
-
- # Test a 1 byte greyscale image
- testimage('greytest.rgb')
-
- unlink('test.rgb')
- unlink('greytest.rgb')
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
index 77e44bec923..551ad1b85cc 100644
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -1,7 +1,11 @@
import imp
+import os
+import os.path
+import shutil
+import sys
import unittest
-from test import test_support
-
+from test import support
+import importlib
class LockTests(unittest.TestCase):
@@ -37,45 +41,315 @@ class LockTests(unittest.TestCase):
self.fail("release_lock() without lock should raise "
"RuntimeError")
+class ImportTests(unittest.TestCase):
+ def setUp(self):
+ mod = importlib.import_module('test.encoded_modules')
+ self.test_strings = mod.test_strings
+ self.test_path = mod.__path__
+
+ def test_import_encoded_module(self):
+ for modname, encoding, teststr in self.test_strings:
+ mod = importlib.import_module('test.encoded_modules.'
+ 'module_' + modname)
+ self.assertEqual(teststr, mod.test)
+
+ def test_find_module_encoding(self):
+ for mod, encoding, _ in self.test_strings:
+ with imp.find_module('module_' + mod, self.test_path)[0] as fd:
+ self.assertEqual(fd.encoding, encoding)
+
+ def test_issue1267(self):
+ for mod, encoding, _ in self.test_strings:
+ fp, filename, info = imp.find_module('module_' + mod,
+ self.test_path)
+ with fp:
+ self.assertNotEqual(fp, None)
+ self.assertEqual(fp.encoding, encoding)
+ self.assertEqual(fp.tell(), 0)
+ self.assertEqual(fp.readline(), '# test %s encoding\n'
+ % encoding)
+
+ fp, filename, info = imp.find_module("tokenize")
+ with fp:
+ self.assertNotEqual(fp, None)
+ self.assertEqual(fp.encoding, "utf-8")
+ self.assertEqual(fp.tell(), 0)
+ self.assertEqual(fp.readline(),
+ '"""Tokenization help for Python programs.\n')
+
+ def test_issue3594(self):
+ temp_mod_name = 'test_imp_helper'
+ sys.path.insert(0, '.')
+ try:
+ with open(temp_mod_name + '.py', 'w') as file:
+ file.write("# coding: cp1252\nu = 'test.test_imp'\n")
+ file, filename, info = imp.find_module(temp_mod_name)
+ file.close()
+ self.assertEqual(file.encoding, 'cp1252')
+ finally:
+ del sys.path[0]
+ support.unlink(temp_mod_name + '.py')
+ support.unlink(temp_mod_name + '.pyc')
+ support.unlink(temp_mod_name + '.pyo')
+
+ def test_issue5604(self):
+ # Test cannot cover imp.load_compiled function.
+ # Martin von Loewis note what shared library cannot have non-ascii
+ # character because init_xxx function cannot be compiled
+ # and issue never happens for dynamic modules.
+ # But sources modified to follow generic way for processing pathes.
+
+ # the return encoding could be uppercase or None
+ fs_encoding = sys.getfilesystemencoding()
+
+ # covers utf-8 and Windows ANSI code pages
+ # one non-space symbol from every page
+ # (http://en.wikipedia.org/wiki/Code_page)
+ known_locales = {
+ 'utf-8' : b'\xc3\xa4',
+ 'cp1250' : b'\x8C',
+ 'cp1251' : b'\xc0',
+ 'cp1252' : b'\xc0',
+ 'cp1253' : b'\xc1',
+ 'cp1254' : b'\xc0',
+ 'cp1255' : b'\xe0',
+ 'cp1256' : b'\xe0',
+ 'cp1257' : b'\xc0',
+ 'cp1258' : b'\xc0',
+ }
+
+ if sys.platform == 'darwin':
+ self.assertEqual(fs_encoding, 'utf-8')
+ # Mac OS X uses the Normal Form D decomposition
+ # http://developer.apple.com/mac/library/qa/qa2001/qa1173.html
+ special_char = b'a\xcc\x88'
+ else:
+ special_char = known_locales.get(fs_encoding)
+
+ if not special_char:
+ self.skipTest("can't run this test with %s as filesystem encoding"
+ % fs_encoding)
+ decoded_char = special_char.decode(fs_encoding)
+ temp_mod_name = 'test_imp_helper_' + decoded_char
+ test_package_name = 'test_imp_helper_package_' + decoded_char
+ init_file_name = os.path.join(test_package_name, '__init__.py')
+ try:
+ # if the curdir is not in sys.path the test fails when run with
+ # ./python ./Lib/test/regrtest.py test_imp
+ sys.path.insert(0, os.curdir)
+ with open(temp_mod_name + '.py', 'w') as file:
+ file.write('a = 1\n')
+ file, filename, info = imp.find_module(temp_mod_name)
+ with file:
+ self.assertIsNotNone(file)
+ self.assertTrue(filename[:-3].endswith(temp_mod_name))
+ self.assertEqual(info[0], '.py')
+ self.assertEqual(info[1], 'U')
+ self.assertEqual(info[2], imp.PY_SOURCE)
+
+ mod = imp.load_module(temp_mod_name, file, filename, info)
+ self.assertEqual(mod.a, 1)
+
+ mod = imp.load_source(temp_mod_name, temp_mod_name + '.py')
+ self.assertEqual(mod.a, 1)
+
+ mod = imp.load_compiled(
+ temp_mod_name, imp.cache_from_source(temp_mod_name + '.py'))
+ self.assertEqual(mod.a, 1)
+
+ if not os.path.exists(test_package_name):
+ os.mkdir(test_package_name)
+ with open(init_file_name, 'w') as file:
+ file.write('b = 2\n')
+ package = imp.load_package(test_package_name, test_package_name)
+ self.assertEqual(package.b, 2)
+ finally:
+ del sys.path[0]
+ for ext in ('.py', '.pyc', '.pyo'):
+ support.unlink(temp_mod_name + ext)
+ support.unlink(init_file_name + ext)
+ support.rmtree(test_package_name)
+
+ def test_issue9319(self):
+ path = os.path.dirname(__file__)
+ self.assertRaises(SyntaxError,
+ imp.find_module, "badsyntax_pep3120", [path])
+
+
class ReloadTests(unittest.TestCase):
"""Very basic tests to make sure that imp.reload() operates just like
reload()."""
def test_source(self):
- # XXX (ncoghlan): It would be nice to use test_support.CleanImport
+ # XXX (ncoghlan): It would be nice to use test.support.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
# revert that registration, the module is left in a broken
# state after reversion. Reinitialising the module contents
# and just reverting os.environ to its previous state is an OK
# workaround
- with test_support.EnvironmentVarGuard():
+ with support.EnvironmentVarGuard():
import os
imp.reload(os)
def test_extension(self):
- with test_support.CleanImport('time'):
+ with support.CleanImport('time'):
import time
imp.reload(time)
def test_builtin(self):
- with test_support.CleanImport('marshal'):
+ with support.CleanImport('marshal'):
import marshal
imp.reload(marshal)
+class PEP3147Tests(unittest.TestCase):
+ """Tests of PEP 3147."""
+
+ tag = imp.get_tag()
+
+ def test_cache_from_source(self):
+ # Given the path to a .py file, return the path to its PEP 3147
+ # defined .pyc file (i.e. under __pycache__).
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz/qux.py', True),
+ '/foo/bar/baz/__pycache__/qux.{}.pyc'.format(self.tag))
+
+ def test_cache_from_source_optimized(self):
+ # Given the path to a .py file, return the path to its PEP 3147
+ # defined .pyo file (i.e. under __pycache__).
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz/qux.py', False),
+ '/foo/bar/baz/__pycache__/qux.{}.pyo'.format(self.tag))
+
+ def test_cache_from_source_cwd(self):
+ self.assertEqual(imp.cache_from_source('foo.py', True),
+ os.sep.join(('__pycache__',
+ 'foo.{}.pyc'.format(self.tag))))
+
+ def test_cache_from_source_override(self):
+ # When debug_override is not None, it can be any true-ish or false-ish
+ # value.
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz.py', []),
+ '/foo/bar/__pycache__/baz.{}.pyo'.format(self.tag))
+ self.assertEqual(
+ imp.cache_from_source('/foo/bar/baz.py', [17]),
+ '/foo/bar/__pycache__/baz.{}.pyc'.format(self.tag))
+ # However if the bool-ishness can't be determined, the exception
+ # propagates.
+ class Bearish:
+ def __bool__(self): raise RuntimeError
+ self.assertRaises(
+ RuntimeError,
+ imp.cache_from_source, '/foo/bar/baz.py', Bearish())
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_altsep_cache_from_source(self):
+ # Windows path and PEP 3147.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar\\baz\\qux.py', True),
+ '\\foo\\bar\\baz\\__pycache__\\qux.{}.pyc'.format(self.tag))
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_altsep_and_sep_cache_from_source(self):
+ # Windows path and PEP 3147 where altsep is right of sep.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar/baz\\qux.py', True),
+ '\\foo\\bar/baz\\__pycache__\\qux.{}.pyc'.format(self.tag))
+
+ @unittest.skipIf(os.altsep is None,
+ 'test meaningful only where os.altsep is defined')
+ def test_sep_altsep_and_sep_cache_from_source(self):
+ # Windows path and PEP 3147 where sep is right of altsep.
+ self.assertEqual(
+ imp.cache_from_source('\\foo\\bar\\baz/qux.py', True),
+ '\\foo\\bar\\baz/__pycache__/qux.{}.pyc'.format(self.tag))
+
+ def test_source_from_cache(self):
+ # Given the path to a PEP 3147 defined .pyc file, return the path to
+ # its source. This tests the good path.
+ self.assertEqual(imp.source_from_cache(
+ '/foo/bar/baz/__pycache__/qux.{}.pyc'.format(self.tag)),
+ '/foo/bar/baz/qux.py')
+
+ def test_source_from_cache_bad_path(self):
+ # When the path to a pyc file is not in PEP 3147 format, a ValueError
+ # is raised.
+ self.assertRaises(
+ ValueError, imp.source_from_cache, '/foo/bar/bazqux.pyc')
+
+ def test_source_from_cache_no_slash(self):
+ # No slashes at all in path -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache, 'foo.cpython-32.pyc')
+
+ def test_source_from_cache_too_few_dots(self):
+ # Too few dots in final path component -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache, '__pycache__/foo.pyc')
+
+ def test_source_from_cache_too_many_dots(self):
+ # Too many dots in final path component -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache,
+ '__pycache__/foo.cpython-32.foo.pyc')
+
+ def test_source_from_cache_no__pycache__(self):
+ # Another problem with the path -> ValueError
+ self.assertRaises(
+ ValueError, imp.source_from_cache,
+ '/foo/bar/foo.cpython-32.foo.pyc')
+
+ def test_package___file__(self):
+ # Test that a package's __file__ points to the right source directory.
+ os.mkdir('pep3147')
+ sys.path.insert(0, os.curdir)
+ def cleanup():
+ if sys.path[0] == os.curdir:
+ del sys.path[0]
+ shutil.rmtree('pep3147')
+ self.addCleanup(cleanup)
+ # Touch the __init__.py file.
+ with open('pep3147/__init__.py', 'w'):
+ pass
+ m = __import__('pep3147')
+ # Ensure we load the pyc file.
+ support.forget('pep3147')
+ m = __import__('pep3147')
+ self.assertEqual(m.__file__,
+ os.sep.join(('.', 'pep3147', '__init__.py')))
+
+
+class NullImporterTests(unittest.TestCase):
+ @unittest.skipIf(support.TESTFN_UNENCODABLE is None,
+ "Need an undecodeable filename")
+ def test_unencodeable(self):
+ name = support.TESTFN_UNENCODABLE
+ os.mkdir(name)
+ try:
+ self.assertRaises(ImportError, imp.NullImporter, name)
+ finally:
+ os.rmdir(name)
+
+
def test_main():
tests = [
+ ImportTests,
+ PEP3147Tests,
ReloadTests,
- ]
+ NullImporterTests,
+ ]
try:
- import thread
+ import _thread
except ImportError:
pass
else:
tests.append(LockTests)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py
index ea50d34626a..b10f350e1e9 100644
--- a/Lib/test/test_import.py
+++ b/Lib/test/test_import.py
@@ -1,21 +1,25 @@
-import errno
+import builtins
import imp
+from importlib.test.import_ import test_relative_imports
+from importlib.test.import_ import util as importlib_util
import marshal
import os
+import platform
import py_compile
import random
import stat
-import struct
import sys
import unittest
import textwrap
-import shutil
+import errno
-from test.test_support import (unlink, TESTFN, unload, run_unittest, rmtree,
- is_jython, check_warnings, EnvironmentVarGuard)
-from test import symlink_support
+from test.support import (
+ EnvironmentVarGuard, TESTFN, check_warnings, forget, is_jython,
+ make_legacy_pyc, rmtree, run_unittest, swap_attr, swap_item, temp_umask,
+ unlink, unload)
from test import script_helper
+
def _files(name):
return (name + os.extsep + "py",
name + os.extsep + "pyc",
@@ -26,7 +30,7 @@ def _files(name):
def chmod_files(name):
for f in _files(name):
try:
- os.chmod(f, 0600)
+ os.chmod(f, 0o600)
except OSError as exc:
if exc.errno != errno.ENOENT:
raise
@@ -34,23 +38,24 @@ def chmod_files(name):
def remove_files(name):
for f in _files(name):
unlink(f)
+ rmtree('__pycache__')
class ImportTests(unittest.TestCase):
+ def setUp(self):
+ remove_files(TESTFN)
+
def tearDown(self):
unload(TESTFN)
+
setUp = tearDown
def test_case_sensitivity(self):
# Brief digression to test that import is case-sensitive: if we got
# this far, we know for sure that "random" exists.
- try:
+ with self.assertRaises(ImportError):
import RAnDoM
- except ImportError:
- pass
- else:
- self.fail("import of RAnDoM should have failed (case mismatch)")
def test_double_const(self):
# Another brief digression to test the accuracy of manifest float
@@ -61,76 +66,72 @@ class ImportTests(unittest.TestCase):
def test_with_extension(ext):
# The extension is normally ".py", perhaps ".pyw".
source = TESTFN + ext
- pyo = TESTFN + os.extsep + "pyo"
+ pyo = TESTFN + ".pyo"
if is_jython:
pyc = TESTFN + "$py.class"
else:
- pyc = TESTFN + os.extsep + "pyc"
+ pyc = TESTFN + ".pyc"
with open(source, "w") as f:
- print >> f, ("# This tests Python's ability to import a", ext,
- "file.")
+ print("# This tests Python's ability to import a",
+ ext, "file.", file=f)
a = random.randrange(1000)
b = random.randrange(1000)
- print >> f, "a =", a
- print >> f, "b =", b
+ print("a =", a, file=f)
+ print("b =", b, file=f)
+ if TESTFN in sys.modules:
+ del sys.modules[TESTFN]
try:
- mod = __import__(TESTFN)
- except ImportError, err:
- self.fail("import from %s failed: %s" % (ext, err))
- else:
+ try:
+ mod = __import__(TESTFN)
+ except ImportError as err:
+ self.fail("import from %s failed: %s" % (ext, err))
+
self.assertEqual(mod.a, a,
"module loaded (%s) but contents invalid" % mod)
self.assertEqual(mod.b, b,
"module loaded (%s) but contents invalid" % mod)
finally:
+ forget(TESTFN)
unlink(source)
-
- try:
- imp.reload(mod)
- except ImportError, err:
- self.fail("import from .pyc/.pyo failed: %s" % err)
- finally:
unlink(pyc)
unlink(pyo)
- unload(TESTFN)
sys.path.insert(0, os.curdir)
try:
- test_with_extension(os.extsep + "py")
+ test_with_extension(".py")
if sys.platform.startswith("win"):
for ext in [".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw"]:
test_with_extension(ext)
finally:
del sys.path[0]
- @unittest.skipUnless(os.name == 'posix', "test meaningful only on posix systems")
+ @unittest.skipUnless(os.name == 'posix',
+ "test meaningful only on posix systems")
def test_execute_bit_not_copied(self):
# Issue 6070: under posix .pyc files got their execute bit set if
# the .py file had the execute bit set, but they aren't executable.
- oldmask = os.umask(022)
- sys.path.insert(0, os.curdir)
- try:
- fname = TESTFN + os.extsep + "py"
- f = open(fname, 'w').close()
- os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
- stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
- __import__(TESTFN)
- fn = fname + 'c'
- if not os.path.exists(fn):
- fn = fname + 'o'
+ with temp_umask(0o022):
+ sys.path.insert(0, os.curdir)
+ try:
+ fname = TESTFN + os.extsep + "py"
+ open(fname, 'w').close()
+ os.chmod(fname, (stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
+ stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH))
+ fn = imp.cache_from_source(fname)
+ unlink(fn)
+ __import__(TESTFN)
if not os.path.exists(fn):
self.fail("__import__ did not result in creation of "
"either a .pyc or .pyo file")
- s = os.stat(fn)
- self.assertEqual(stat.S_IMODE(s.st_mode),
- stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
- finally:
- os.umask(oldmask)
- remove_files(TESTFN)
- unload(TESTFN)
- del sys.path[0]
+ s = os.stat(fn)
+ self.assertEqual(stat.S_IMODE(s.st_mode),
+ stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)
+ finally:
+ del sys.path[0]
+ remove_files(TESTFN)
+ unload(TESTFN)
def test_rewrite_pyc_with_read_only_source(self):
# Issue 6074: a long time ago on posix, and more recently on Windows,
@@ -145,11 +146,11 @@ class ImportTests(unittest.TestCase):
# Tweak the mtime of the source to ensure pyc gets updated later
s = os.stat(fname)
os.utime(fname, (s.st_atime, s.st_mtime-100000000))
- os.chmod(fname, 0400)
+ os.chmod(fname, 0o400)
m1 = __import__(TESTFN)
self.assertEqual(m1.x, 'original')
# Change the file and then reimport it
- os.chmod(fname, 0600)
+ os.chmod(fname, 0o600)
with open(fname, 'w') as f:
f.write("x = 'rewritten'\n")
unload(TESTFN)
@@ -158,6 +159,11 @@ class ImportTests(unittest.TestCase):
# Now delete the source file and check the pyc was rewritten
unlink(fname)
unload(TESTFN)
+ if __debug__:
+ bytecode_name = fname + "c"
+ else:
+ bytecode_name = fname + "o"
+ os.rename(imp.cache_from_source(fname), bytecode_name)
m3 = __import__(TESTFN)
self.assertEqual(m3.x, 'rewritten')
finally:
@@ -168,8 +174,7 @@ class ImportTests(unittest.TestCase):
def test_imp_module(self):
# Verify that the imp module can correctly load and find .py files
-
- # XXX (ncoghlan): It would be nice to use test_support.CleanImport
+ # XXX (ncoghlan): It would be nice to use support.CleanImport
# here, but that breaks because the os module registers some
# handlers in copy_reg on import. Since CleanImport doesn't
# revert that registration, the module is left in a broken
@@ -180,46 +185,62 @@ class ImportTests(unittest.TestCase):
orig_getenv = os.getenv
with EnvironmentVarGuard():
x = imp.find_module("os")
+ self.addCleanup(x[0].close)
new_os = imp.load_module("os", *x)
self.assertIs(os, new_os)
self.assertIs(orig_path, new_os.path)
self.assertIsNot(orig_getenv, new_os.getenv)
+ def test_bug7732(self):
+ source = TESTFN + '.py'
+ os.mkdir(source)
+ try:
+ self.assertRaisesRegex(ImportError, '^No module',
+ imp.find_module, TESTFN, ["."])
+ finally:
+ os.rmdir(source)
+
def test_module_with_large_stack(self, module='longlist'):
# Regression test for http://bugs.python.org/issue561858.
- filename = module + os.extsep + 'py'
+ filename = module + '.py'
# Create a file with a list of 65000 elements.
- with open(filename, 'w+') as f:
+ with open(filename, 'w') as f:
f.write('d = [\n')
for i in range(65000):
f.write('"",\n')
f.write(']')
- # Compile & remove .py file, we only need .pyc (or .pyo).
- with open(filename, 'r') as f:
+ try:
+ # Compile & remove .py file; we only need .pyc (or .pyo).
+ # Bytecode must be relocated from the PEP 3147 bytecode-only location.
py_compile.compile(filename)
- unlink(filename)
+ finally:
+ unlink(filename)
# Need to be able to load from current dir.
sys.path.append('')
- # This used to crash.
- exec 'import ' + module
-
- # Cleanup.
- del sys.path[-1]
- unlink(filename + 'c')
- unlink(filename + 'o')
+ try:
+ make_legacy_pyc(filename)
+ # This used to crash.
+ exec('import ' + module)
+ finally:
+ # Cleanup.
+ del sys.path[-1]
+ unlink(filename + 'c')
+ unlink(filename + 'o')
def test_failing_import_sticks(self):
- source = TESTFN + os.extsep + "py"
+ source = TESTFN + ".py"
with open(source, "w") as f:
- print >> f, "a = 1 // 0"
+ print("a = 1/0", file=f)
# New in 2.4, we shouldn't be able to import that no matter how often
# we try.
sys.path.insert(0, os.curdir)
+ if TESTFN in sys.modules:
+ del sys.modules[TESTFN]
try:
for i in [1, 2, 3]:
self.assertRaises(ZeroDivisionError, __import__, TESTFN)
@@ -229,12 +250,22 @@ class ImportTests(unittest.TestCase):
del sys.path[0]
remove_files(TESTFN)
+ def test_import_name_binding(self):
+ # import x.y.z binds x in the current namespace
+ import test as x
+ import test.support
+ self.assertTrue(x is test, x.__name__)
+ self.assertTrue(hasattr(test.support, "__file__"))
+
+ # import x.y.z as w binds z as w
+ import test.support as y
+ self.assertTrue(y is test.support, y.__name__)
+
def test_failing_reload(self):
# A failing reload should leave the module object in sys.modules.
source = TESTFN + os.extsep + "py"
with open(source, "w") as f:
- print >> f, "a = 1"
- print >> f, "b = 2"
+ f.write("a = 1\nb=2\n")
sys.path.insert(0, os.curdir)
try:
@@ -251,11 +282,9 @@ class ImportTests(unittest.TestCase):
# Now damage the module.
with open(source, "w") as f:
- print >> f, "a = 10"
- print >> f, "b = 20//0"
+ f.write("a = 10\nb=20//0\n")
self.assertRaises(ZeroDivisionError, imp.reload, mod)
-
# But we still expect the module to be in sys.modules.
mod = sys.modules.get(TESTFN)
self.assertIsNot(mod, None, "expected module to be in sys.modules")
@@ -270,26 +299,38 @@ class ImportTests(unittest.TestCase):
remove_files(TESTFN)
unload(TESTFN)
- def test_infinite_reload(self):
- # http://bugs.python.org/issue742342 reports that Python segfaults
- # (infinite recursion in C) when faced with self-recursive reload()ing.
+ def test_file_to_source(self):
+ # check if __file__ points to the source file where available
+ source = TESTFN + ".py"
+ with open(source, "w") as f:
+ f.write("test = None\n")
- sys.path.insert(0, os.path.dirname(__file__))
+ sys.path.insert(0, os.curdir)
try:
- import infinite_reload
+ mod = __import__(TESTFN)
+ self.assertTrue(mod.__file__.endswith('.py'))
+ os.remove(source)
+ del sys.modules[TESTFN]
+ make_legacy_pyc(source)
+ mod = __import__(TESTFN)
+ base, ext = os.path.splitext(mod.__file__)
+ self.assertIn(ext, ('.pyc', '.pyo'))
finally:
del sys.path[0]
+ remove_files(TESTFN)
+ if TESTFN in sys.modules:
+ del sys.modules[TESTFN]
def test_import_name_binding(self):
# import x.y.z binds x in the current namespace.
import test as x
- import test.test_support
+ import test.support
self.assertIs(x, test, x.__name__)
- self.assertTrue(hasattr(test.test_support, "__file__"))
+ self.assertTrue(hasattr(test.support, "__file__"))
# import x.y.z as w binds z as w.
- import test.test_support as y
- self.assertIs(y, test.test_support, y.__name__)
+ import test.support as y
+ self.assertIs(y, test.support, y.__name__)
def test_import_initless_directory_warning(self):
with check_warnings(('', ImportWarning)):
@@ -299,6 +340,11 @@ class ImportTests(unittest.TestCase):
def test_import_by_filename(self):
path = os.path.abspath(TESTFN)
+ encoding = sys.getfilesystemencoding()
+ try:
+ path.encode(encoding)
+ except UnicodeEncodeError:
+ self.skipTest('path is not encodable to {}'.format(encoding))
with self.assertRaises(ImportError) as c:
__import__(path)
self.assertEqual("Import by filename is not supported.",
@@ -313,19 +359,7 @@ class ImportTests(unittest.TestCase):
import imp
sys.argv.insert(0, C())
"""))
- try:
- script_helper.assert_python_ok(testfn)
- finally:
- unlink(testfn)
-
- def test_bug7732(self):
- source = TESTFN + '.py'
- os.mkdir(source)
- try:
- self.assertRaises((ImportError, IOError),
- imp.find_module, TESTFN, ["."])
- finally:
- os.rmdir(source)
+ script_helper.assert_python_ok(testfn)
def test_timestamp_overflow(self):
# A modification timestamp larger than 2**32 should not be a problem
@@ -333,7 +367,7 @@ class ImportTests(unittest.TestCase):
sys.path.insert(0, os.curdir)
try:
source = TESTFN + ".py"
- compiled = source + ('c' if __debug__ else 'o')
+ compiled = imp.cache_from_source(source)
with open(source, 'w') as f:
pass
try:
@@ -351,46 +385,6 @@ class ImportTests(unittest.TestCase):
del sys.path[0]
remove_files(TESTFN)
- def test_pyc_mtime(self):
- # Test for issue #13863: .pyc timestamp sometimes incorrect on Windows.
- sys.path.insert(0, os.curdir)
- try:
- # Jan 1, 2012; Jul 1, 2012.
- mtimes = 1325376000, 1341100800
-
- # Different names to avoid running into import caching.
- tails = "spam", "eggs"
- for mtime, tail in zip(mtimes, tails):
- module = TESTFN + tail
- source = module + ".py"
- compiled = source + ('c' if __debug__ else 'o')
-
- # Create a new Python file with the given mtime.
- with open(source, 'w') as f:
- f.write("# Just testing\nx=1, 2, 3\n")
- os.utime(source, (mtime, mtime))
-
- # Generate the .pyc/o file; if it couldn't be created
- # for some reason, skip the test.
- m = __import__(module)
- if not os.path.exists(compiled):
- unlink(source)
- self.skipTest("Couldn't create .pyc/.pyo file.")
-
- # Actual modification time of .py file.
- mtime1 = int(os.stat(source).st_mtime) & 0xffffffff
-
- # mtime that was encoded in the .pyc file.
- with open(compiled, 'rb') as f:
- mtime2 = struct.unpack('<L', f.read(8)[4:])[0]
-
- unlink(compiled)
- unlink(source)
-
- self.assertEqual(mtime1, mtime2)
- finally:
- sys.path.pop(0)
-
class PycRewritingTests(unittest.TestCase):
# Test that the `co_filename` attribute on code objects always points
@@ -405,11 +399,11 @@ module_filename = __file__
constant = 1
def func():
pass
-func_filename = func.func_code.co_filename
+func_filename = func.__code__.co_filename
"""
dir_name = os.path.abspath(TESTFN)
file_name = os.path.join(dir_name, module_name) + os.extsep + "py"
- compiled_name = file_name + ("c" if __debug__ else "o")
+ compiled_name = imp.cache_from_source(file_name)
def setUp(self):
self.sys_path = sys.path[:]
@@ -441,14 +435,14 @@ func_filename = func.func_code.co_filename
self.assertEqual(mod.func_filename, self.file_name)
del sys.modules[self.module_name]
mod = self.import_module()
- self.assertEqual(mod.module_filename, self.compiled_name)
+ self.assertEqual(mod.module_filename, self.file_name)
self.assertEqual(mod.code_filename, self.file_name)
self.assertEqual(mod.func_filename, self.file_name)
def test_incorrect_code_name(self):
py_compile.compile(self.file_name, dfile="another_module.py")
mod = self.import_module()
- self.assertEqual(mod.module_filename, self.compiled_name)
+ self.assertEqual(mod.module_filename, self.file_name)
self.assertEqual(mod.code_filename, self.file_name)
self.assertEqual(mod.func_filename, self.file_name)
@@ -456,8 +450,9 @@ func_filename = func.func_code.co_filename
target = "another_module.py"
py_compile.compile(self.file_name, dfile=target)
os.remove(self.file_name)
+ pyc_file = make_legacy_pyc(self.file_name)
mod = self.import_module()
- self.assertEqual(mod.module_filename, self.compiled_name)
+ self.assertEqual(mod.module_filename, pyc_file)
self.assertEqual(mod.code_filename, target)
self.assertEqual(mod.func_filename, target)
@@ -467,10 +462,11 @@ func_filename = func.func_code.co_filename
header = f.read(8)
code = marshal.load(f)
constants = list(code.co_consts)
- foreign_code = test_main.func_code
+ foreign_code = test_main.__code__
pos = constants.index(1)
constants[pos] = foreign_code
- code = type(code)(code.co_argcount, code.co_nlocals, code.co_stacksize,
+ code = type(code)(code.co_argcount, code.co_kwonlyargcount,
+ code.co_nlocals, code.co_stacksize,
code.co_flags, code.co_code, tuple(constants),
code.co_names, code.co_varnames, code.co_filename,
code.co_name, code.co_firstlineno, code.co_lnotab,
@@ -483,6 +479,8 @@ func_filename = func.func_code.co_filename
class PathsTests(unittest.TestCase):
+ SAMPLES = ('test', 'test\u00e4\u00f6\u00fc\u00df', 'test\u00e9\u00e8',
+ 'test\u00b0\u00b3\u00b2')
path = TESTFN
def setUp(self):
@@ -541,37 +539,32 @@ class RelativeImportTests(unittest.TestCase):
self.assertTrue(hasattr(relimport, "RelativeImportTests"))
def test_issue3221(self):
+ # Note for mergers: the 'absolute' tests from the 2.x branch
+ # are missing in Py3k because implicit relative imports are
+ # a thing of the past
+ #
# Regression test for http://bugs.python.org/issue3221.
- def check_absolute():
- exec "from os import path" in ns
def check_relative():
- exec "from . import relimport" in ns
+ exec("from . import relimport", ns)
- # Check both OK with __package__ and __name__ correct
+ # Check relative import OK with __package__ and __name__ correct
ns = dict(__package__='test', __name__='test.notarealmodule')
- check_absolute()
check_relative()
- # Check both OK with only __name__ wrong
+ # Check relative import OK with only __name__ wrong
ns = dict(__package__='test', __name__='notarealpkg.notarealmodule')
- check_absolute()
check_relative()
- # Check relative fails with only __package__ wrong
+ # Check relative import fails with only __package__ wrong
ns = dict(__package__='foo', __name__='test.notarealmodule')
- with check_warnings(('.+foo', RuntimeWarning)):
- check_absolute()
self.assertRaises(SystemError, check_relative)
- # Check relative fails with __package__ and __name__ wrong
+ # Check relative import fails with __package__ and __name__ wrong
ns = dict(__package__='foo', __name__='notarealpkg.notarealmodule')
- with check_warnings(('.+foo', RuntimeWarning)):
- check_absolute()
self.assertRaises(SystemError, check_relative)
- # Check both fail with package set to a non-string
+ # Check relative import fails with package set to a non-string
ns = dict(__package__=object())
- self.assertRaises(ValueError, check_absolute)
self.assertRaises(ValueError, check_relative)
def test_absolute_import_without_future(self):
@@ -584,58 +577,176 @@ class RelativeImportTests(unittest.TestCase):
"implicit absolute import")
-class TestSymbolicallyLinkedPackage(unittest.TestCase):
- package_name = 'sample'
+class OverridingImportBuiltinTests(unittest.TestCase):
+ def test_override_builtin(self):
+ # Test that overriding builtins.__import__ can bypass sys.modules.
+ import os
+
+ def foo():
+ import os
+ return os
+ self.assertEqual(foo(), os) # Quick sanity check.
+
+ with swap_attr(builtins, "__import__", lambda *x: 5):
+ self.assertEqual(foo(), 5)
+
+ # Test what happens when we shadow __import__ in globals(); this
+ # currently does not impact the import process, but if this changes,
+ # other code will need to change, so keep this test as a tripwire.
+ with swap_item(globals(), "__import__", lambda *x: 5):
+ self.assertEqual(foo(), os)
+
+
+class PycacheTests(unittest.TestCase):
+ # Test the various PEP 3147 related behaviors.
+
+ tag = imp.get_tag()
+
+ def _clean(self):
+ forget(TESTFN)
+ rmtree('__pycache__')
+ unlink(self.source)
def setUp(self):
- if os.path.exists(self.tagged):
- shutil.rmtree(self.tagged)
- if os.path.exists(self.package_name):
- symlink_support.remove_symlink(self.package_name)
- self.orig_sys_path = sys.path[:]
-
- # create a sample package; imagine you have a package with a tag and
- # you want to symbolically link it from its untagged name.
- os.mkdir(self.tagged)
- init_file = os.path.join(self.tagged, '__init__.py')
- open(init_file, 'w').close()
- assert os.path.exists(init_file)
-
- # now create a symlink to the tagged package
- # sample -> sample-tagged
- symlink_support.symlink(self.tagged, self.package_name)
-
- assert os.path.isdir(self.package_name)
- assert os.path.isfile(os.path.join(self.package_name, '__init__.py'))
-
- @property
- def tagged(self):
- return self.package_name + '-tagged'
-
- # regression test for issue6727
- @unittest.skipUnless(
- not hasattr(sys, 'getwindowsversion')
- or sys.getwindowsversion() >= (6, 0),
- "Windows Vista or later required")
- @symlink_support.skip_unless_symlink
- def test_symlinked_dir_importable(self):
- # make sure sample can only be imported from the current directory.
- sys.path[:] = ['.']
-
- # and try to import the package
- __import__(self.package_name)
+ self.source = TESTFN + '.py'
+ self._clean()
+ with open(self.source, 'w') as fp:
+ print('# This is a test file written by test_import.py', file=fp)
+ sys.path.insert(0, os.curdir)
def tearDown(self):
- # now cleanup
- if os.path.exists(self.package_name):
- symlink_support.remove_symlink(self.package_name)
- if os.path.exists(self.tagged):
- shutil.rmtree(self.tagged)
- sys.path[:] = self.orig_sys_path
+ assert sys.path[0] == os.curdir, 'Unexpected sys.path[0]'
+ del sys.path[0]
+ self._clean()
+
+ def test_import_pyc_path(self):
+ self.assertFalse(os.path.exists('__pycache__'))
+ __import__(TESTFN)
+ self.assertTrue(os.path.exists('__pycache__'))
+ self.assertTrue(os.path.exists(os.path.join(
+ '__pycache__', '{}.{}.py{}'.format(
+ TESTFN, self.tag, 'c' if __debug__ else 'o'))))
+
+ @unittest.skipUnless(os.name == 'posix',
+ "test meaningful only on posix systems")
+ @unittest.skipIf(hasattr(os, 'geteuid') and os.geteuid() == 0,
+ "due to varying filesystem permission semantics (issue #11956)")
+ def test_unwritable_directory(self):
+ # When the umask causes the new __pycache__ directory to be
+ # unwritable, the import still succeeds but no .pyc file is written.
+ with temp_umask(0o222):
+ __import__(TESTFN)
+ self.assertTrue(os.path.exists('__pycache__'))
+ self.assertFalse(os.path.exists(os.path.join(
+ '__pycache__', '{}.{}.pyc'.format(TESTFN, self.tag))))
+
+ def test_missing_source(self):
+ # With PEP 3147 cache layout, removing the source but leaving the pyc
+ # file does not satisfy the import.
+ __import__(TESTFN)
+ pyc_file = imp.cache_from_source(self.source)
+ self.assertTrue(os.path.exists(pyc_file))
+ os.remove(self.source)
+ forget(TESTFN)
+ self.assertRaises(ImportError, __import__, TESTFN)
+
+ def test_missing_source_legacy(self):
+ # Like test_missing_source() except that for backward compatibility,
+ # when the pyc file lives where the py file would have been (and named
+ # without the tag), it is importable. The __file__ of the imported
+ # module is the pyc location.
+ __import__(TESTFN)
+ # pyc_file gets removed in _clean() via tearDown().
+ pyc_file = make_legacy_pyc(self.source)
+ os.remove(self.source)
+ unload(TESTFN)
+ m = __import__(TESTFN)
+ self.assertEqual(m.__file__,
+ os.path.join(os.curdir, os.path.relpath(pyc_file)))
+
+ def test___cached__(self):
+ # Modules now also have an __cached__ that points to the pyc file.
+ m = __import__(TESTFN)
+ pyc_file = imp.cache_from_source(TESTFN + '.py')
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, pyc_file))
+
+ def test___cached___legacy_pyc(self):
+ # Like test___cached__() except that for backward compatibility,
+ # when the pyc file lives where the py file would have been (and named
+ # without the tag), it is importable. The __cached__ of the imported
+ # module is the pyc location.
+ __import__(TESTFN)
+ # pyc_file gets removed in _clean() via tearDown().
+ pyc_file = make_legacy_pyc(self.source)
+ os.remove(self.source)
+ unload(TESTFN)
+ m = __import__(TESTFN)
+ self.assertEqual(m.__cached__,
+ os.path.join(os.curdir, os.path.relpath(pyc_file)))
+
+ def test_package___cached__(self):
+ # Like test___cached__ but for packages.
+ def cleanup():
+ rmtree('pep3147')
+ os.mkdir('pep3147')
+ self.addCleanup(cleanup)
+ # Touch the __init__.py
+ with open(os.path.join('pep3147', '__init__.py'), 'w'):
+ pass
+ with open(os.path.join('pep3147', 'foo.py'), 'w'):
+ pass
+ unload('pep3147.foo')
+ unload('pep3147')
+ m = __import__('pep3147.foo')
+ init_pyc = imp.cache_from_source(
+ os.path.join('pep3147', '__init__.py'))
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, init_pyc))
+ foo_pyc = imp.cache_from_source(os.path.join('pep3147', 'foo.py'))
+ self.assertEqual(sys.modules['pep3147.foo'].__cached__,
+ os.path.join(os.curdir, foo_pyc))
+
+ def test_package___cached___from_pyc(self):
+ # Like test___cached__ but ensuring __cached__ when imported from a
+ # PEP 3147 pyc file.
+ def cleanup():
+ rmtree('pep3147')
+ os.mkdir('pep3147')
+ self.addCleanup(cleanup)
+ unload('pep3147.foo')
+ unload('pep3147')
+ # Touch the __init__.py
+ with open(os.path.join('pep3147', '__init__.py'), 'w'):
+ pass
+ with open(os.path.join('pep3147', 'foo.py'), 'w'):
+ pass
+ m = __import__('pep3147.foo')
+ unload('pep3147.foo')
+ unload('pep3147')
+ m = __import__('pep3147.foo')
+ init_pyc = imp.cache_from_source(
+ os.path.join('pep3147', '__init__.py'))
+ self.assertEqual(m.__cached__, os.path.join(os.curdir, init_pyc))
+ foo_pyc = imp.cache_from_source(os.path.join('pep3147', 'foo.py'))
+ self.assertEqual(sys.modules['pep3147.foo'].__cached__,
+ os.path.join(os.curdir, foo_pyc))
+
+
+class RelativeImportFromImportlibTests(test_relative_imports.RelativeImports):
+
+ def setUp(self):
+ self._importlib_util_flag = importlib_util.using___import__
+ importlib_util.using___import__ = True
+
+ def tearDown(self):
+ importlib_util.using___import__ = self._importlib_util_flag
+
def test_main(verbose=None):
- run_unittest(ImportTests, PycRewritingTests, PathsTests,
- RelativeImportTests, TestSymbolicallyLinkedPackage)
+ run_unittest(ImportTests, PycacheTests,
+ PycRewritingTests, PathsTests, RelativeImportTests,
+ OverridingImportBuiltinTests,
+ RelativeImportFromImportlibTests)
+
if __name__ == '__main__':
# Test needs to be a package, so we can do relative imports.
diff --git a/Lib/test/test_importhooks.py b/Lib/test/test_importhooks.py
index cfab1f28545..ec6730e9ba3 100644
--- a/Lib/test/test_importhooks.py
+++ b/Lib/test/test_importhooks.py
@@ -2,7 +2,7 @@ import sys
import imp
import os
import unittest
-from test import test_support
+from test import support
test_src = """\
@@ -72,7 +72,7 @@ class TestImporter:
mod.__loader__ = self
if ispkg:
mod.__path__ = self._get__path__()
- exec code in mod.__dict__
+ exec(code, mod.__dict__)
return mod
@@ -96,7 +96,7 @@ class ImportBlocker:
return self
return None
def load_module(self, fullname):
- raise ImportError, "I dare you"
+ raise ImportError("I dare you")
class ImpWrapper:
@@ -143,15 +143,14 @@ class ImportHooksBaseTestCase(unittest.TestCase):
self.meta_path = sys.meta_path[:]
self.path_hooks = sys.path_hooks[:]
sys.path_importer_cache.clear()
- self.modules_before = sys.modules.copy()
+ self.modules_before = support.modules_setup()
def tearDown(self):
sys.path[:] = self.path
sys.meta_path[:] = self.meta_path
sys.path_hooks[:] = self.path_hooks
sys.path_importer_cache.clear()
- sys.modules.clear()
- sys.modules.update(self.modules_before)
+ support.modules_cleanup(*self.modules_before)
class ImportHooksTestCase(ImportHooksBaseTestCase):
@@ -179,16 +178,6 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
import reloadmodule
self.assertFalse(hasattr(reloadmodule,'reloaded'))
- TestImporter.modules['reloadmodule'] = (False, reload_co)
- imp.reload(reloadmodule)
- self.assertTrue(hasattr(reloadmodule,'reloaded'))
-
- import hooktestpackage.oldabs
- self.assertEqual(hooktestpackage.oldabs.get_name(),
- "hooktestpackage.oldabs")
- self.assertEqual(hooktestpackage.oldabs.sub,
- hooktestpackage.sub)
-
import hooktestpackage.newrel
self.assertEqual(hooktestpackage.newrel.get_name(),
"hooktestpackage.newrel")
@@ -210,6 +199,11 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
import sub
self.assertEqual(sub.get_name(), "sub")
+ import hooktestpackage.oldabs
+ self.assertEqual(hooktestpackage.oldabs.get_name(),
+ "hooktestpackage.oldabs")
+ self.assertEqual(hooktestpackage.oldabs.sub, sub)
+
import hooktestpackage.newabs
self.assertEqual(hooktestpackage.newabs.get_name(),
"hooktestpackage.newabs")
@@ -227,7 +221,7 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
def testBlocker(self):
mname = "exceptions" # an arbitrary harmless builtin module
- test_support.unload(mname)
+ support.unload(mname)
sys.meta_path.append(ImportBlocker(mname))
self.assertRaises(ImportError, __import__, mname)
@@ -235,21 +229,19 @@ class ImportHooksTestCase(ImportHooksBaseTestCase):
i = ImpWrapper()
sys.meta_path.append(i)
sys.path_hooks.append(ImpWrapper)
- mnames = ("colorsys", "urlparse", "distutils.core", "compiler.misc")
+ mnames = ("colorsys", "urllib.parse", "distutils.core")
for mname in mnames:
parent = mname.split(".")[0]
- for n in sys.modules.keys():
+ for n in list(sys.modules):
if n.startswith(parent):
del sys.modules[n]
- with test_support.check_warnings(("The compiler package is deprecated "
- "and removed", DeprecationWarning)):
- for mname in mnames:
- m = __import__(mname, globals(), locals(), ["__dummy__"])
- m.__loader__ # to make sure we actually handled the import
+ for mname in mnames:
+ m = __import__(mname, globals(), locals(), ["__dummy__"])
+ m.__loader__ # to make sure we actually handled the import
def test_main():
- test_support.run_unittest(ImportHooksTestCase)
+ support.run_unittest(ImportHooksTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_importlib.py b/Lib/test/test_importlib.py
index 51d8da601a9..6ed05859c93 100644
--- a/Lib/test/test_importlib.py
+++ b/Lib/test/test_importlib.py
@@ -1,175 +1,4 @@
-import contextlib
-import imp
-import importlib
-import sys
-import unittest
-
-
-@contextlib.contextmanager
-def uncache(*names):
- """Uncache a module from sys.modules.
-
- A basic sanity check is performed to prevent uncaching modules that either
- cannot/shouldn't be uncached.
-
- """
- for name in names:
- if name in ('sys', 'marshal', 'imp'):
- raise ValueError(
- "cannot uncache {0} as it will break _importlib".format(name))
- try:
- del sys.modules[name]
- except KeyError:
- pass
- try:
- yield
- finally:
- for name in names:
- try:
- del sys.modules[name]
- except KeyError:
- pass
-
-
-@contextlib.contextmanager
-def import_state(**kwargs):
- """Context manager to manage the various importers and stored state in the
- sys module.
-
- The 'modules' attribute is not supported as the interpreter state stores a
- pointer to the dict that the interpreter uses internally;
- reassigning to sys.modules does not have the desired effect.
-
- """
- originals = {}
- try:
- for attr, default in (('meta_path', []), ('path', []),
- ('path_hooks', []),
- ('path_importer_cache', {})):
- originals[attr] = getattr(sys, attr)
- if attr in kwargs:
- new_value = kwargs[attr]
- del kwargs[attr]
- else:
- new_value = default
- setattr(sys, attr, new_value)
- if len(kwargs):
- raise ValueError(
- 'unrecognized arguments: {0}'.format(kwargs.keys()))
- yield
- finally:
- for attr, value in originals.items():
- setattr(sys, attr, value)
-
-
-class mock_modules(object):
-
- """A mock importer/loader."""
-
- def __init__(self, *names):
- self.modules = {}
- for name in names:
- if not name.endswith('.__init__'):
- import_name = name
- else:
- import_name = name[:-len('.__init__')]
- if '.' not in name:
- package = None
- elif import_name == name:
- package = name.rsplit('.', 1)[0]
- else:
- package = import_name
- module = imp.new_module(import_name)
- module.__loader__ = self
- module.__file__ = '<mock __file__>'
- module.__package__ = package
- module.attr = name
- if import_name != name:
- module.__path__ = ['<mock __path__>']
- self.modules[import_name] = module
-
- def __getitem__(self, name):
- return self.modules[name]
-
- def find_module(self, fullname, path=None):
- if fullname not in self.modules:
- return None
- else:
- return self
-
- def load_module(self, fullname):
- if fullname not in self.modules:
- raise ImportError
- else:
- sys.modules[fullname] = self.modules[fullname]
- return self.modules[fullname]
-
- def __enter__(self):
- self._uncache = uncache(*self.modules.keys())
- self._uncache.__enter__()
- return self
-
- def __exit__(self, *exc_info):
- self._uncache.__exit__(None, None, None)
-
-
-
-class ImportModuleTests(unittest.TestCase):
-
- """Test importlib.import_module."""
-
- def test_module_import(self):
- # Test importing a top-level module.
- with mock_modules('top_level') as mock:
- with import_state(meta_path=[mock]):
- module = importlib.import_module('top_level')
- self.assertEqual(module.__name__, 'top_level')
-
- def test_absolute_package_import(self):
- # Test importing a module from a package with an absolute name.
- pkg_name = 'pkg'
- pkg_long_name = '{0}.__init__'.format(pkg_name)
- name = '{0}.mod'.format(pkg_name)
- with mock_modules(pkg_long_name, name) as mock:
- with import_state(meta_path=[mock]):
- module = importlib.import_module(name)
- self.assertEqual(module.__name__, name)
-
- def test_shallow_relative_package_import(self):
- modules = ['a.__init__', 'a.b.__init__', 'a.b.c.__init__', 'a.b.c.d']
- with mock_modules(*modules) as mock:
- with import_state(meta_path=[mock]):
- module = importlib.import_module('.d', 'a.b.c')
- self.assertEqual(module.__name__, 'a.b.c.d')
-
- def test_deep_relative_package_import(self):
- # Test importing a module from a package through a relatve import.
- modules = ['a.__init__', 'a.b.__init__', 'a.c']
- with mock_modules(*modules) as mock:
- with import_state(meta_path=[mock]):
- module = importlib.import_module('..c', 'a.b')
- self.assertEqual(module.__name__, 'a.c')
-
- def test_absolute_import_with_package(self):
- # Test importing a module from a package with an absolute name with
- # the 'package' argument given.
- pkg_name = 'pkg'
- pkg_long_name = '{0}.__init__'.format(pkg_name)
- name = '{0}.mod'.format(pkg_name)
- with mock_modules(pkg_long_name, name) as mock:
- with import_state(meta_path=[mock]):
- module = importlib.import_module(name, pkg_name)
- self.assertEqual(module.__name__, name)
-
- def test_relative_import_wo_package(self):
- # Relative imports cannot happen without the 'package' argument being
- # set.
- self.assertRaises(TypeError, importlib.import_module, '.support')
-
-
-def test_main():
- from test.test_support import run_unittest
- run_unittest(ImportModuleTests)
+from importlib.test.__main__ import test_main
if __name__ == '__main__':
diff --git a/Lib/test/test_index.py b/Lib/test/test_index.py
index a92b4428a32..7a94af1b0ad 100644
--- a/Lib/test/test_index.py
+++ b/Lib/test/test_index.py
@@ -1,15 +1,9 @@
import unittest
-from test import test_support
+from test import support
import operator
-from sys import maxint
-maxsize = test_support.MAX_Py_ssize_t
-minsize = -maxsize-1
+maxsize = support.MAX_Py_ssize_t
-class oldstyle:
- def __index__(self):
- return self.ind
-
-class newstyle(object):
+class newstyle:
def __index__(self):
return self.ind
@@ -17,13 +11,9 @@ class TrapInt(int):
def __index__(self):
return self
-class TrapLong(long):
- def __index__(self):
- return self
-
class BaseTestCase(unittest.TestCase):
def setUp(self):
- self.o = oldstyle()
+ self.o = newstyle()
self.n = newstyle()
def test_basic(self):
@@ -46,18 +36,16 @@ class BaseTestCase(unittest.TestCase):
self.o.ind = 4
self.n.ind = 5
self.assertEqual(6 .__index__(), 6)
- self.assertEqual(-7L.__index__(), -7)
+ self.assertEqual(-7 .__index__(), -7)
self.assertEqual(self.o.__index__(), 4)
self.assertEqual(self.n.__index__(), 5)
self.assertEqual(True.__index__(), 1)
self.assertEqual(False.__index__(), 0)
def test_subclasses(self):
- r = range(10)
+ r = list(range(10))
self.assertEqual(r[TrapInt(5):TrapInt(10)], r[5:10])
- self.assertEqual(r[TrapLong(5):TrapLong(10)], r[5:10])
self.assertEqual(slice(TrapInt()).indices(0), (0,0,1))
- self.assertEqual(slice(TrapLong(0)).indices(0), (0,0,1))
def test_error(self):
self.o.ind = 'dumb'
@@ -72,9 +60,9 @@ class SeqTestCase(unittest.TestCase):
# This test case isn't run directly. It just defines common tests
# to the different sequence types below
def setUp(self):
- self.o = oldstyle()
+ self.o = newstyle()
self.n = newstyle()
- self.o2 = oldstyle()
+ self.o2 = newstyle()
self.n2 = newstyle()
def test_index(self):
@@ -99,9 +87,6 @@ class SeqTestCase(unittest.TestCase):
self.assertEqual(self.seq[:self.o], self.seq)
self.assertEqual(self.seq[self.n:], self.seq[0:0])
self.assertEqual(self.seq[:self.n], self.seq)
- if isinstance(self.seq, ClassicSeq):
- return
- # These tests fail for ClassicSeq (see bug #7532)
self.o2.ind = -seqlen - 2
self.n2.ind = -int(seqlen * 1.5)
self.assertEqual(self.seq[self.o2:], self.seq)
@@ -129,7 +114,6 @@ class SeqTestCase(unittest.TestCase):
def test_subclasses(self):
self.assertEqual(self.seq[TrapInt()], self.seq[0])
- self.assertEqual(self.seq[TrapLong()], self.seq[0])
def test_error(self):
self.o.ind = 'dumb'
@@ -176,7 +160,7 @@ class ListTestCase(SeqTestCase):
self.assertEqual(lst, [5, 6, 7, 8, 9, 11] * 3)
-class _BaseSeq:
+class NewSeq:
def __init__(self, iterable):
self._list = list(iterable)
@@ -198,50 +182,31 @@ class _BaseSeq:
return self._list[index]
-class _GetSliceMixin:
-
- def __getslice__(self, i, j):
- return self._list.__getslice__(i, j)
-
-
-class ClassicSeq(_BaseSeq): pass
-class NewSeq(_BaseSeq, object): pass
-class ClassicSeqDeprecated(_GetSliceMixin, ClassicSeq): pass
-class NewSeqDeprecated(_GetSliceMixin, NewSeq): pass
-
-
class TupleTestCase(SeqTestCase):
seq = (0,10,20,30,40,50)
-class StringTestCase(SeqTestCase):
- seq = "this is a test"
-
class ByteArrayTestCase(SeqTestCase):
- seq = bytearray("this is a test")
+ seq = bytearray(b"this is a test")
-class UnicodeTestCase(SeqTestCase):
- seq = u"this is a test"
+class BytesTestCase(SeqTestCase):
+ seq = b"this is a test"
-class ClassicSeqTestCase(SeqTestCase):
- seq = ClassicSeq((0,10,20,30,40,50))
+class StringTestCase(SeqTestCase):
+ seq = "this is a test"
class NewSeqTestCase(SeqTestCase):
seq = NewSeq((0,10,20,30,40,50))
-class ClassicSeqDeprecatedTestCase(SeqTestCase):
- seq = ClassicSeqDeprecated((0,10,20,30,40,50))
-class NewSeqDeprecatedTestCase(SeqTestCase):
- seq = NewSeqDeprecated((0,10,20,30,40,50))
+class RangeTestCase(unittest.TestCase):
-class XRangeTestCase(unittest.TestCase):
-
- def test_xrange(self):
+ def test_range(self):
n = newstyle()
n.ind = 5
- self.assertEqual(xrange(1, 20)[n], 6)
- self.assertEqual(xrange(1, 20).__getitem__(n), 6)
+ self.assertEqual(range(1, 20)[n], 6)
+ self.assertEqual(range(1, 20).__getitem__(n), 6)
+
class OverflowTestCase(unittest.TestCase):
@@ -253,10 +218,10 @@ class OverflowTestCase(unittest.TestCase):
self.assertEqual(self.pos.__index__(), self.pos)
self.assertEqual(self.neg.__index__(), self.neg)
- def _getitem_helper(self, base):
- class GetItem(base):
+ def test_getitem(self):
+ class GetItem:
def __len__(self):
- return maxint # cannot return long here
+ assert False, "__len__ should not be invoked"
def __getitem__(self, key):
return key
x = GetItem()
@@ -267,57 +232,23 @@ class OverflowTestCase(unittest.TestCase):
self.assertEqual(x[self.neg:self.pos:1].indices(maxsize),
(0, maxsize, 1))
- def _getslice_helper_deprecated(self, base):
- class GetItem(base):
- def __len__(self):
- return maxint # cannot return long here
- def __getitem__(self, key):
- return key
- def __getslice__(self, i, j):
- return i, j
- x = GetItem()
- self.assertEqual(x[self.pos], self.pos)
- self.assertEqual(x[self.neg], self.neg)
- self.assertEqual(x[self.neg:self.pos], (maxint+minsize, maxsize))
- self.assertEqual(x[self.neg:self.pos:1].indices(maxsize),
- (0, maxsize, 1))
-
- def test_getitem(self):
- self._getitem_helper(object)
- with test_support.check_py3k_warnings():
- self._getslice_helper_deprecated(object)
-
- def test_getitem_classic(self):
- class Empty: pass
- # XXX This test fails (see bug #7532)
- #self._getitem_helper(Empty)
- with test_support.check_py3k_warnings():
- self._getslice_helper_deprecated(Empty)
-
def test_sequence_repeat(self):
self.assertRaises(OverflowError, lambda: "a" * self.pos)
self.assertRaises(OverflowError, lambda: "a" * self.neg)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
BaseTestCase,
ListTestCase,
TupleTestCase,
+ BytesTestCase,
ByteArrayTestCase,
StringTestCase,
- UnicodeTestCase,
- ClassicSeqTestCase,
NewSeqTestCase,
- XRangeTestCase,
+ RangeTestCase,
OverflowTestCase,
)
- with test_support.check_py3k_warnings():
- test_support.run_unittest(
- ClassicSeqDeprecatedTestCase,
- NewSeqDeprecatedTestCase,
- )
-
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_inspect.py b/Lib/test/test_inspect.py
index 30b1556cbfb..4b7ee4ed682 100644
--- a/Lib/test/test_inspect.py
+++ b/Lib/test/test_inspect.py
@@ -5,16 +5,15 @@ import unittest
import inspect
import linecache
import datetime
-from UserList import UserList
-from UserDict import UserDict
+import collections
+import os
+import shutil
+from os.path import normcase
-from test.test_support import run_unittest, check_py3k_warnings
+from test.support import run_unittest, TESTFN, DirsOnSysPath
-with check_py3k_warnings(
- ("tuple parameter unpacking has been removed", SyntaxWarning),
- quiet=True):
- from test import inspect_fodder as mod
- from test import inspect_fodder2 as mod2
+from test import inspect_fodder as mod
+from test import inspect_fodder2 as mod2
# C module for test_findsource_binary
import unicodedata
@@ -33,12 +32,19 @@ modfile = mod.__file__
if modfile.endswith(('c', 'o')):
modfile = modfile[:-1]
-import __builtin__
+# Normalize file names: on Windows, the case of file names of compiled
+# modules depends on the path used to start the python executable.
+modfile = normcase(modfile)
+
+def revise(filename, *args):
+ return (normcase(filename),) + args
+
+import builtins
try:
- 1 // 0
+ 1/0
except:
- tb = sys.exc_traceback
+ tb = sys.exc_info()[2]
git = mod.StupidGit()
@@ -59,12 +65,12 @@ class IsTestBase(unittest.TestCase):
self.assertFalse(other(obj), 'not %s(%s)' % (other.__name__, exp))
def generator_function_example(self):
- for i in xrange(2):
+ for i in range(2):
yield i
class TestPredicates(IsTestBase):
def test_sixteen(self):
- count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
+ count = len([x for x in dir(inspect) if x.startswith('is')])
# This test is here for remember you to update Doc/library/inspect.rst
# which claims there are 16 such functions
expected = 16
@@ -75,16 +81,15 @@ class TestPredicates(IsTestBase):
def test_excluding_predicates(self):
self.istest(inspect.isbuiltin, 'sys.exit')
self.istest(inspect.isbuiltin, '[].append')
- self.istest(inspect.iscode, 'mod.spam.func_code')
+ self.istest(inspect.iscode, 'mod.spam.__code__')
self.istest(inspect.isframe, 'tb.tb_frame')
self.istest(inspect.isfunction, 'mod.spam')
- self.istest(inspect.ismethod, 'mod.StupidGit.abuse')
+ self.istest(inspect.isfunction, 'mod.StupidGit.abuse')
self.istest(inspect.ismethod, 'git.argue')
self.istest(inspect.ismodule, 'mod')
self.istest(inspect.istraceback, 'tb')
- self.istest(inspect.isdatadescriptor, '__builtin__.file.closed')
- self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace')
- self.istest(inspect.isgenerator, '(x for x in xrange(2))')
+ self.istest(inspect.isdatadescriptor, 'collections.defaultdict.default_factory')
+ self.istest(inspect.isgenerator, '(x for x in range(2))')
self.istest(inspect.isgeneratorfunction, 'generator_function_example')
if hasattr(types, 'GetSetDescriptorType'):
self.istest(inspect.isgetsetdescriptor,
@@ -104,9 +109,6 @@ class TestPredicates(IsTestBase):
self.istest(inspect.isclass, 'mod.StupidGit')
self.assertTrue(inspect.isclass(list))
- class newstyle(object): pass
- self.assertTrue(inspect.isclass(newstyle))
-
class CustomGetattr(object):
def __getattr__(self, attr):
return None
@@ -125,8 +127,7 @@ class TestPredicates(IsTestBase):
def test_isabstract(self):
from abc import ABCMeta, abstractmethod
- class AbstractClassExample(object):
- __metaclass__ = ABCMeta
+ class AbstractClassExample(metaclass=ABCMeta):
@abstractmethod
def foo(self):
@@ -158,23 +159,23 @@ class TestInterpreterStack(IsTestBase):
def test_stack(self):
self.assertTrue(len(mod.st) >= 5)
- self.assertEqual(mod.st[0][1:],
+ self.assertEqual(revise(*mod.st[0][1:]),
(modfile, 16, 'eggs', [' st = inspect.stack()\n'], 0))
- self.assertEqual(mod.st[1][1:],
+ self.assertEqual(revise(*mod.st[1][1:]),
(modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0))
- self.assertEqual(mod.st[2][1:],
+ self.assertEqual(revise(*mod.st[2][1:]),
(modfile, 43, 'argue', [' spam(a, b, c)\n'], 0))
- self.assertEqual(mod.st[3][1:],
+ self.assertEqual(revise(*mod.st[3][1:]),
(modfile, 39, 'abuse', [' self.argue(a, b, c)\n'], 0))
def test_trace(self):
self.assertEqual(len(git.tr), 3)
- self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue',
- [' spam(a, b, c)\n'], 0))
- self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam',
- [' eggs(b + d, c + f)\n'], 0))
- self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs',
- [' q = y // 0\n'], 0))
+ self.assertEqual(revise(*git.tr[0][1:]),
+ (modfile, 43, 'argue', [' spam(a, b, c)\n'], 0))
+ self.assertEqual(revise(*git.tr[1][1:]),
+ (modfile, 9, 'spam', [' eggs(b + d, c + f)\n'], 0))
+ self.assertEqual(revise(*git.tr[2][1:]),
+ (modfile, 18, 'eggs', [' q = y / 0\n'], 0))
def test_frame(self):
args, varargs, varkw, locals = inspect.getargvalues(mod.fr)
@@ -187,20 +188,20 @@ class TestInterpreterStack(IsTestBase):
def test_previous_frame(self):
args, varargs, varkw, locals = inspect.getargvalues(mod.fr.f_back)
- self.assertEqual(args, ['a', 'b', 'c', 'd', ['e', ['f']]])
+ self.assertEqual(args, ['a', 'b', 'c', 'd', 'e', 'f'])
self.assertEqual(varargs, 'g')
self.assertEqual(varkw, 'h')
self.assertEqual(inspect.formatargvalues(args, varargs, varkw, locals),
- '(a=7, b=8, c=9, d=3, (e=4, (f=5,)), *g=(), **h={})')
+ '(a=7, b=8, c=9, d=3, e=4, f=5, *g=(), **h={})')
class GetSourceBase(unittest.TestCase):
# Subclasses must override.
- fodderFile = None
+ fodderModule = None
def __init__(self, *args, **kwargs):
unittest.TestCase.__init__(self, *args, **kwargs)
- with open(inspect.getsourcefile(self.fodderFile)) as fp:
+ with open(inspect.getsourcefile(self.fodderModule)) as fp:
self.source = fp.read()
def sourcerange(self, top, bottom):
@@ -212,7 +213,7 @@ class GetSourceBase(unittest.TestCase):
self.sourcerange(top, bottom))
class TestRetrievingSourceCode(GetSourceBase):
- fodderFile = mod
+ fodderModule = mod
def test_getclasses(self):
classes = inspect.getmembers(mod, inspect.isclass)
@@ -223,11 +224,13 @@ class TestRetrievingSourceCode(GetSourceBase):
('StupidGit', mod.StupidGit)])
tree = inspect.getclasstree([cls[1] for cls in classes], 1)
self.assertEqual(tree,
- [(mod.ParrotDroppings, ()),
- (mod.StupidGit, ()),
- [(mod.MalodorousPervert, (mod.StupidGit,)),
- [(mod.FesteringGob, (mod.MalodorousPervert,
- mod.ParrotDroppings))
+ [(object, ()),
+ [(mod.ParrotDroppings, (object,)),
+ (mod.StupidGit, (object,)),
+ [(mod.MalodorousPervert, (mod.StupidGit,)),
+ [(mod.FesteringGob, (mod.MalodorousPervert,
+ mod.ParrotDroppings))
+ ]
]
]
])
@@ -264,7 +267,7 @@ class TestRetrievingSourceCode(GetSourceBase):
# Do it again (check the caching isn't broken)
self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod)
# Check a builtin
- self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"])
+ self.assertEqual(inspect.getmodule(str), sys.modules["builtins"])
# Check filename override
self.assertEqual(inspect.getmodule(None, modfile), mod)
@@ -273,13 +276,13 @@ class TestRetrievingSourceCode(GetSourceBase):
self.assertSourceEqual(mod.StupidGit, 21, 46)
def test_getsourcefile(self):
- self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
- self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
+ self.assertEqual(normcase(inspect.getsourcefile(mod.spam)), modfile)
+ self.assertEqual(normcase(inspect.getsourcefile(git.abuse)), modfile)
fn = "_non_existing_filename_used_for_sourcefile_test.py"
co = compile("None", fn, "exec")
self.assertEqual(inspect.getsourcefile(co), None)
linecache.cache[co.co_filename] = (1, None, "None", co.co_filename)
- self.assertEqual(inspect.getsourcefile(co), fn)
+ self.assertEqual(normcase(inspect.getsourcefile(co)), fn)
def test_getfile(self):
self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
@@ -290,8 +293,8 @@ class TestRetrievingSourceCode(GetSourceBase):
m = sys.modules[name] = ModuleType(name)
m.__file__ = "<string>" # hopefully not a real filename...
m.__loader__ = "dummy" # pretend the filename is understood by a loader
- exec "def x(): pass" in m.__dict__
- self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
+ exec("def x(): pass", m.__dict__)
+ self.assertEqual(inspect.getsourcefile(m.x.__code__), '<string>')
del sys.modules[name]
inspect.getmodule(compile('a=10','','single'))
@@ -307,13 +310,13 @@ class TestRetrievingSourceCode(GetSourceBase):
linecache.getlines = monkey
try:
ns = {}
- exec compile(source, fn, 'single') in ns
+ exec(compile(source, fn, 'single'), ns)
inspect.getsource(ns["x"])
finally:
linecache.getlines = getlines
class TestDecorators(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_wrapped_decorator(self):
self.assertSourceEqual(mod2.wrapped, 14, 17)
@@ -322,7 +325,7 @@ class TestDecorators(GetSourceBase):
self.assertSourceEqual(mod2.gone, 9, 10)
class TestOneliners(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_oneline_lambda(self):
# Test inspect.getsource with a one-line lambda function.
self.assertSourceEqual(mod2.oll, 25, 25)
@@ -364,7 +367,7 @@ class TestOneliners(GetSourceBase):
self.assertSourceEqual(mod2.anonymous, 55, 55)
class TestBuggyCases(GetSourceBase):
- fodderFile = mod2
+ fodderModule = mod2
def test_with_comment(self):
self.assertSourceEqual(mod2.with_comment, 58, 59)
@@ -404,6 +407,24 @@ class TestBuggyCases(GetSourceBase):
self.assertEqual(inspect.findsource(co), (lines,0))
self.assertEqual(inspect.getsource(co), lines[0])
+class TestNoEOL(GetSourceBase):
+ def __init__(self, *args, **kwargs):
+ self.tempdir = TESTFN + '_dir'
+ os.mkdir(self.tempdir)
+ with open(os.path.join(self.tempdir,
+ 'inspect_fodder3%spy' % os.extsep), 'w') as f:
+ f.write("class X:\n pass # No EOL")
+ with DirsOnSysPath(self.tempdir):
+ import inspect_fodder3 as mod3
+ self.fodderModule = mod3
+ GetSourceBase.__init__(self, *args, **kwargs)
+
+ def tearDown(self):
+ shutil.rmtree(self.tempdir)
+
+ def test_class(self):
+ self.assertSourceEqual(self.fodderModule.X, 1, 2)
+
class _BrokenDataDescriptor(object):
"""
@@ -436,17 +457,6 @@ def attrs_wo_objs(cls):
class TestClassesAndFunctions(unittest.TestCase):
- def test_classic_mro(self):
- # Test classic-class method resolution order.
- class A: pass
- class B(A): pass
- class C(A): pass
- class D(B, C): pass
-
- expected = (D, B, A, C)
- got = inspect.getmro(D)
- self.assertEqual(expected, got)
-
def test_newstyle_mro(self):
# The same w/ new-class MRO.
class A(object): pass
@@ -458,9 +468,8 @@ class TestClassesAndFunctions(unittest.TestCase):
got = inspect.getmro(D)
self.assertEqual(expected, got)
- def assertArgSpecEquals(self, routine, args_e, varargs_e = None,
- varkw_e = None, defaults_e = None,
- formatted = None):
+ def assertArgSpecEquals(self, routine, args_e, varargs_e=None,
+ varkw_e=None, defaults_e=None, formatted=None):
args, varargs, varkw, defaults = inspect.getargspec(routine)
self.assertEqual(args, args_e)
self.assertEqual(varargs, varargs_e)
@@ -470,13 +479,54 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults),
formatted)
+ def assertFullArgSpecEquals(self, routine, args_e, varargs_e=None,
+ varkw_e=None, defaults_e=None,
+ kwonlyargs_e=[], kwonlydefaults_e=None,
+ ann_e={}, formatted=None):
+ args, varargs, varkw, defaults, kwonlyargs, kwonlydefaults, ann = \
+ inspect.getfullargspec(routine)
+ self.assertEqual(args, args_e)
+ self.assertEqual(varargs, varargs_e)
+ self.assertEqual(varkw, varkw_e)
+ self.assertEqual(defaults, defaults_e)
+ self.assertEqual(kwonlyargs, kwonlyargs_e)
+ self.assertEqual(kwonlydefaults, kwonlydefaults_e)
+ self.assertEqual(ann, ann_e)
+ if formatted is not None:
+ self.assertEqual(inspect.formatargspec(args, varargs, varkw, defaults,
+ kwonlyargs, kwonlydefaults, ann),
+ formatted)
+
def test_getargspec(self):
- self.assertArgSpecEquals(mod.eggs, ['x', 'y'], formatted = '(x, y)')
+ self.assertArgSpecEquals(mod.eggs, ['x', 'y'], formatted='(x, y)')
self.assertArgSpecEquals(mod.spam,
- ['a', 'b', 'c', 'd', ['e', ['f']]],
- 'g', 'h', (3, (4, (5,))),
- '(a, b, c, d=3, (e, (f,))=(4, (5,)), *g, **h)')
+ ['a', 'b', 'c', 'd', 'e', 'f'],
+ 'g', 'h', (3, 4, 5),
+ '(a, b, c, d=3, e=4, f=5, *g, **h)')
+
+ self.assertRaises(ValueError, self.assertArgSpecEquals,
+ mod2.keyworded, [])
+
+ self.assertRaises(ValueError, self.assertArgSpecEquals,
+ mod2.annotated, [])
+ self.assertRaises(ValueError, self.assertArgSpecEquals,
+ mod2.keyword_only_arg, [])
+
+
+ def test_getfullargspec(self):
+ self.assertFullArgSpecEquals(mod2.keyworded, [], varargs_e='arg1',
+ kwonlyargs_e=['arg2'],
+ kwonlydefaults_e={'arg2':1},
+ formatted='(*arg1, arg2=1)')
+
+ self.assertFullArgSpecEquals(mod2.annotated, ['arg1'],
+ ann_e={'arg1' : list},
+ formatted='(arg1: list)')
+ self.assertFullArgSpecEquals(mod2.keyword_only_arg, [],
+ kwonlyargs_e=['arg'],
+ formatted='(*, arg)')
+
def test_getargspec_method(self):
class A(object):
@@ -484,28 +534,9 @@ class TestClassesAndFunctions(unittest.TestCase):
pass
self.assertArgSpecEquals(A.m, ['self'])
- def test_getargspec_sublistofone(self):
- with check_py3k_warnings(
- ("tuple parameter unpacking has been removed", SyntaxWarning),
- ("parenthesized argument names are invalid", SyntaxWarning)):
- exec 'def sublistOfOne((foo,)): return 1'
- self.assertArgSpecEquals(sublistOfOne, [['foo']])
-
- exec 'def fakeSublistOfOne((foo)): return 1'
- self.assertArgSpecEquals(fakeSublistOfOne, ['foo'])
-
-
- def _classify_test(self, newstyle):
- """Helper for testing that classify_class_attrs finds a bunch of
- different kinds of attributes on a given class.
- """
- if newstyle:
- base = object
- else:
- class base:
- pass
+ def test_classify_newstyle(self):
+ class A(object):
- class A(base):
def s(): pass
s = staticmethod(s)
@@ -528,13 +559,15 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertIn(('s', 'static method', A), attrs, 'missing static method')
self.assertIn(('c', 'class method', A), attrs, 'missing class method')
self.assertIn(('p', 'property', A), attrs, 'missing property')
- self.assertIn(('m', 'method', A), attrs, 'missing plain method')
+ self.assertIn(('m', 'method', A), attrs,
+ 'missing plain method: %r' % attrs)
self.assertIn(('m1', 'method', A), attrs, 'missing plain method')
self.assertIn(('datablob', 'data', A), attrs, 'missing data')
self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
class B(A):
+
def m(self): pass
attrs = attrs_wo_objs(B)
@@ -549,6 +582,7 @@ class TestClassesAndFunctions(unittest.TestCase):
class C(A):
+
def m(self): pass
def c(self): pass
@@ -563,14 +597,12 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
class D(B, C):
+
def m1(self): pass
attrs = attrs_wo_objs(D)
self.assertIn(('s', 'static method', A), attrs, 'missing static method')
- if newstyle:
- self.assertIn(('c', 'method', C), attrs, 'missing plain method')
- else:
- self.assertIn(('c', 'class method', A), attrs, 'missing class method')
+ self.assertIn(('c', 'method', C), attrs, 'missing plain method')
self.assertIn(('p', 'property', A), attrs, 'missing property')
self.assertIn(('m', 'method', B), attrs, 'missing plain method')
self.assertIn(('m1', 'method', D), attrs, 'missing plain method')
@@ -578,49 +610,53 @@ class TestClassesAndFunctions(unittest.TestCase):
self.assertIn(('md', 'method', A), attrs, 'missing method descriptor')
self.assertIn(('dd', 'data', A), attrs, 'missing data descriptor')
-
- def test_classify_oldstyle(self):
- """classify_class_attrs finds static methods, class methods,
- properties, normal methods, and data attributes on an old-style
- class.
- """
- self._classify_test(False)
-
-
- def test_classify_newstyle(self):
- """Just like test_classify_oldstyle, but for a new-style class.
- """
- self._classify_test(True)
-
def test_classify_builtin_types(self):
# Simple sanity check that all built-in types can have their
# attributes classified.
- for name in dir(__builtin__):
- builtin = getattr(__builtin__, name)
+ for name in dir(__builtins__):
+ builtin = getattr(__builtins__, name)
if isinstance(builtin, type):
inspect.classify_class_attrs(builtin)
- def test_getmembers_method(self):
- # Old-style classes
- class B:
- def f(self):
+ def test_getmembers_descriptors(self):
+ class A(object):
+ dd = _BrokenDataDescriptor()
+ md = _BrokenMethodDescriptor()
+
+ def pred_wrapper(pred):
+ # A quick'n'dirty way to discard standard attributes of new-style
+ # classes.
+ class Empty(object):
pass
+ def wrapped(x):
+ if '__name__' in dir(x) and hasattr(Empty, x.__name__):
+ return False
+ return pred(x)
+ return wrapped
- self.assertIn(('f', B.f), inspect.getmembers(B))
- # contrary to spec, ismethod() is also True for unbound methods
- # (see #1785)
- self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
- b = B()
- self.assertIn(('f', b.f), inspect.getmembers(b))
- self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
+ ismethoddescriptor = pred_wrapper(inspect.ismethoddescriptor)
+ isdatadescriptor = pred_wrapper(inspect.isdatadescriptor)
+
+ self.assertEqual(inspect.getmembers(A, ismethoddescriptor),
+ [('md', A.__dict__['md'])])
+ self.assertEqual(inspect.getmembers(A, isdatadescriptor),
+ [('dd', A.__dict__['dd'])])
+
+ class B(A):
+ pass
+
+ self.assertEqual(inspect.getmembers(B, ismethoddescriptor),
+ [('md', A.__dict__['md'])])
+ self.assertEqual(inspect.getmembers(B, isdatadescriptor),
+ [('dd', A.__dict__['dd'])])
- # New-style classes
- class B(object):
+ def test_getmembers_method(self):
+ class B:
def f(self):
pass
self.assertIn(('f', B.f), inspect.getmembers(B))
- self.assertIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
+ self.assertNotIn(('f', B.f), inspect.getmembers(B, inspect.ismethod))
b = B()
self.assertIn(('f', b.f), inspect.getmembers(b))
self.assertIn(('f', b.f), inspect.getmembers(b, inspect.ismethod))
@@ -628,9 +664,6 @@ class TestClassesAndFunctions(unittest.TestCase):
class TestGetcallargsFunctions(unittest.TestCase):
- # tuple parameters are named '.1', '.2', etc.
- is_tuplename = re.compile(r'^\.\d+$').match
-
def assertEqualCallArgs(self, func, call_params_string, locs=None):
locs = dict(locs or {}, func=func)
r1 = eval('func(%s)' % call_params_string, None, locs)
@@ -642,29 +675,25 @@ class TestGetcallargsFunctions(unittest.TestCase):
locs = dict(locs or {}, func=func)
try:
eval('func(%s)' % call_param_string, None, locs)
- except Exception, ex1:
- pass
+ except Exception as e:
+ ex1 = e
else:
self.fail('Exception not raised')
try:
eval('inspect.getcallargs(func, %s)' % call_param_string, None,
locs)
- except Exception, ex2:
- pass
+ except Exception as e:
+ ex2 = e
else:
self.fail('Exception not raised')
self.assertIs(type(ex1), type(ex2))
self.assertEqual(str(ex1), str(ex2))
+ del ex1, ex2
def makeCallable(self, signature):
- """Create a function that returns its locals(), excluding the
- autogenerated '.1', '.2', etc. tuple param names (if any)."""
- with check_py3k_warnings(
- ("tuple parameter unpacking has been removed", SyntaxWarning),
- quiet=True):
- code = ("lambda %s: dict(i for i in locals().items() "
- "if not is_tuplename(i[0]))")
- return eval(code % signature, {'is_tuplename' : self.is_tuplename})
+ """Create a function that returns its locals()"""
+ code = "lambda %s: locals()"
+ return eval(code % signature)
def test_plain(self):
f = self.makeCallable('a, b=1')
@@ -683,16 +712,11 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualCallArgs(f, '2, **{"b":3}')
self.assertEqualCallArgs(f, '**{"b":3, "a":2}')
# expand UserList / UserDict
- self.assertEqualCallArgs(f, '*UserList([2])')
- self.assertEqualCallArgs(f, '*UserList([2, 3])')
- self.assertEqualCallArgs(f, '**UserDict(a=2)')
- self.assertEqualCallArgs(f, '2, **UserDict(b=3)')
- self.assertEqualCallArgs(f, 'b=2, **UserDict(a=3)')
- # unicode keyword args
- self.assertEqualCallArgs(f, '**{u"a":2}')
- self.assertEqualCallArgs(f, 'b=3, **{u"a":2}')
- self.assertEqualCallArgs(f, '2, **{u"b":3}')
- self.assertEqualCallArgs(f, '**{u"b":3, u"a":2}')
+ self.assertEqualCallArgs(f, '*collections.UserList([2])')
+ self.assertEqualCallArgs(f, '*collections.UserList([2, 3])')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=2)')
+ self.assertEqualCallArgs(f, '2, **collections.UserDict(b=3)')
+ self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3)')
def test_varargs(self):
f = self.makeCallable('a, b=1, *c')
@@ -701,7 +725,7 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualCallArgs(f, '2, 3, 4')
self.assertEqualCallArgs(f, '*(2,3,4)')
self.assertEqualCallArgs(f, '2, *[3,4]')
- self.assertEqualCallArgs(f, '2, 3, *UserList([4])')
+ self.assertEqualCallArgs(f, '2, 3, *collections.UserList([4])')
def test_varkw(self):
f = self.makeCallable('a, b=1, **c')
@@ -711,13 +735,9 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualCallArgs(f, 'c=4, **{"a":2, "b":3}')
self.assertEqualCallArgs(f, '2, c=4, **{"b":3}')
self.assertEqualCallArgs(f, 'b=2, **{"a":3, "c":4}')
- self.assertEqualCallArgs(f, '**UserDict(a=2, b=3, c=4)')
- self.assertEqualCallArgs(f, '2, c=4, **UserDict(b=3)')
- self.assertEqualCallArgs(f, 'b=2, **UserDict(a=3, c=4)')
- # unicode keyword args
- self.assertEqualCallArgs(f, 'c=4, **{u"a":2, u"b":3}')
- self.assertEqualCallArgs(f, '2, c=4, **{u"b":3}')
- self.assertEqualCallArgs(f, 'b=2, **{u"a":3, u"c":4}')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=2, b=3, c=4)')
+ self.assertEqualCallArgs(f, '2, c=4, **collections.UserDict(b=3)')
+ self.assertEqualCallArgs(f, 'b=2, **collections.UserDict(a=3, c=4)')
def test_varkw_only(self):
# issue11256:
@@ -726,29 +746,48 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualCallArgs(f, 'a=1')
self.assertEqualCallArgs(f, 'a=1, b=2')
self.assertEqualCallArgs(f, 'c=3, **{"a": 1, "b": 2}')
- self.assertEqualCallArgs(f, '**UserDict(a=1, b=2)')
- self.assertEqualCallArgs(f, 'c=3, **UserDict(a=1, b=2)')
-
- def test_tupleargs(self):
- f = self.makeCallable('(b,c), (d,(e,f))=(0,[1,2])')
- self.assertEqualCallArgs(f, '(2,3)')
- self.assertEqualCallArgs(f, '[2,3]')
- self.assertEqualCallArgs(f, 'UserList([2,3])')
- self.assertEqualCallArgs(f, '(2,3), (4,(5,6))')
- self.assertEqualCallArgs(f, '(2,3), (4,[5,6])')
- self.assertEqualCallArgs(f, '(2,3), [4,UserList([5,6])]')
+ self.assertEqualCallArgs(f, '**collections.UserDict(a=1, b=2)')
+ self.assertEqualCallArgs(f, 'c=3, **collections.UserDict(a=1, b=2)')
+
+ def test_keyword_only(self):
+ f = self.makeCallable('a=3, *, c, d=2')
+ self.assertEqualCallArgs(f, 'c=3')
+ self.assertEqualCallArgs(f, 'c=3, a=3')
+ self.assertEqualCallArgs(f, 'a=2, c=4')
+ self.assertEqualCallArgs(f, '4, c=4')
+ self.assertEqualException(f, '')
+ self.assertEqualException(f, '3')
+ self.assertEqualException(f, 'a=3')
+ self.assertEqualException(f, 'd=4')
+
+ f = self.makeCallable('*, c, d=2')
+ self.assertEqualCallArgs(f, 'c=3')
+ self.assertEqualCallArgs(f, 'c=3, d=4')
+ self.assertEqualCallArgs(f, 'd=4, c=3')
def test_multiple_features(self):
- f = self.makeCallable('a, b=2, (c,(d,e))=(3,[4,5]), *f, **g')
- self.assertEqualCallArgs(f, '2, 3, (4,[5,6]), 7')
- self.assertEqualCallArgs(f, '2, 3, *[(4,[5,6]), 7], x=8')
+ f = self.makeCallable('a, b=2, *f, **g')
+ self.assertEqualCallArgs(f, '2, 3, 7')
+ self.assertEqualCallArgs(f, '2, 3, x=8')
self.assertEqualCallArgs(f, '2, 3, x=8, *[(4,[5,6]), 7]')
self.assertEqualCallArgs(f, '2, x=8, *[3, (4,[5,6]), 7], y=9')
self.assertEqualCallArgs(f, 'x=8, *[2, 3, (4,[5,6])], y=9')
- self.assertEqualCallArgs(f, 'x=8, *UserList([2, 3, (4,[5,6])]), '
- '**{"y":9, "z":10}')
- self.assertEqualCallArgs(f, '2, x=8, *UserList([3, (4,[5,6])]), '
- '**UserDict(y=9, z=10)')
+ self.assertEqualCallArgs(f, 'x=8, *collections.UserList('
+ '[2, 3, (4,[5,6])]), **{"y":9, "z":10}')
+ self.assertEqualCallArgs(f, '2, x=8, *collections.UserList([3, '
+ '(4,[5,6])]), **collections.UserDict('
+ 'y=9, z=10)')
+
+ f = self.makeCallable('a, b=2, *f, x, y=99, **g')
+ self.assertEqualCallArgs(f, '2, 3, x=8')
+ self.assertEqualCallArgs(f, '2, 3, x=8, *[(4,[5,6]), 7]')
+ self.assertEqualCallArgs(f, '2, x=8, *[3, (4,[5,6]), 7], y=9, z=10')
+ self.assertEqualCallArgs(f, 'x=8, *[2, 3, (4,[5,6])], y=9, z=10')
+ self.assertEqualCallArgs(f, 'x=8, *collections.UserList('
+ '[2, 3, (4,[5,6])]), q=0, **{"y":9, "z":10}')
+ self.assertEqualCallArgs(f, '2, x=8, *collections.UserList([3, '
+ '(4,[5,6])]), q=0, **collections.UserDict('
+ 'y=9, z=10)')
def test_errors(self):
f0 = self.makeCallable('')
@@ -771,7 +810,8 @@ class TestGetcallargsFunctions(unittest.TestCase):
self.assertEqualException(f, '2, 3, 4')
self.assertEqualException(f, '1, 2, 3, a=1')
self.assertEqualException(f, '2, 3, 4, c=5')
- self.assertEqualException(f, '2, 3, 4, a=1, c=5')
+ # XXX: success of this one depends on dict order
+ ## self.assertEqualException(f, '2, 3, 4, a=1, c=5')
# f got an unexpected keyword argument
self.assertEqualException(f, 'c=2')
self.assertEqualException(f, '2, c=3')
@@ -786,14 +826,13 @@ class TestGetcallargsFunctions(unittest.TestCase):
# - for functions and bound methods: unexpected keyword 'c'
# - for unbound methods: multiple values for keyword 'a'
#self.assertEqualException(f, '1, c=3, a=2')
- f = self.makeCallable('(a,b)=(0,1)')
- self.assertEqualException(f, '1')
- self.assertEqualException(f, '[1]')
- self.assertEqualException(f, '(1,2,3)')
# issue11256:
f3 = self.makeCallable('**c')
self.assertEqualException(f3, '1, 2')
self.assertEqualException(f3, '1, 2, a=1, b=2')
+ f4 = self.makeCallable('*, a, b=0')
+ self.assertEqualException(f3, '1, 2')
+ self.assertEqualException(f3, '1, 2, a=1, b=2')
class TestGetcallargsMethods(TestGetcallargsFunctions):
@@ -828,12 +867,317 @@ class TestGetcallargsUnboundMethods(TestGetcallargsMethods):
locs = dict(locs or {}, inst=self.inst)
return (func, 'inst,' + call_params_string, locs)
+
+class TestGetattrStatic(unittest.TestCase):
+
+ def test_basic(self):
+ class Thing(object):
+ x = object()
+
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+ self.assertEqual(inspect.getattr_static(thing, 'x', None), Thing.x)
+ with self.assertRaises(AttributeError):
+ inspect.getattr_static(thing, 'y')
+
+ self.assertEqual(inspect.getattr_static(thing, 'y', 3), 3)
+
+ def test_inherited(self):
+ class Thing(object):
+ x = object()
+ class OtherThing(Thing):
+ pass
+
+ something = OtherThing()
+ self.assertEqual(inspect.getattr_static(something, 'x'), Thing.x)
+
+ def test_instance_attr(self):
+ class Thing(object):
+ x = 2
+ def __init__(self, x):
+ self.x = x
+ thing = Thing(3)
+ self.assertEqual(inspect.getattr_static(thing, 'x'), 3)
+ del thing.x
+ self.assertEqual(inspect.getattr_static(thing, 'x'), 2)
+
+ def test_property(self):
+ class Thing(object):
+ @property
+ def x(self):
+ raise AttributeError("I'm pretending not to exist")
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+
+ def test_descriptor_raises_AttributeError(self):
+ class descriptor(object):
+ def __get__(*_):
+ raise AttributeError("I'm pretending not to exist")
+ desc = descriptor()
+ class Thing(object):
+ x = desc
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), desc)
+
+ def test_classAttribute(self):
+ class Thing(object):
+ x = object()
+
+ self.assertEqual(inspect.getattr_static(Thing, 'x'), Thing.x)
+
+ def test_inherited_classattribute(self):
+ class Thing(object):
+ x = object()
+ class OtherThing(Thing):
+ pass
+
+ self.assertEqual(inspect.getattr_static(OtherThing, 'x'), Thing.x)
+
+ def test_slots(self):
+ class Thing(object):
+ y = 'bar'
+ __slots__ = ['x']
+ def __init__(self):
+ self.x = 'foo'
+ thing = Thing()
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+ self.assertEqual(inspect.getattr_static(thing, 'y'), 'bar')
+
+ del thing.x
+ self.assertEqual(inspect.getattr_static(thing, 'x'), Thing.x)
+
+ def test_metaclass(self):
+ class meta(type):
+ attr = 'foo'
+ class Thing(object, metaclass=meta):
+ pass
+ self.assertEqual(inspect.getattr_static(Thing, 'attr'), 'foo')
+
+ class sub(meta):
+ pass
+ class OtherThing(object, metaclass=sub):
+ x = 3
+ self.assertEqual(inspect.getattr_static(OtherThing, 'attr'), 'foo')
+
+ class OtherOtherThing(OtherThing):
+ pass
+ # this test is odd, but it was added as it exposed a bug
+ self.assertEqual(inspect.getattr_static(OtherOtherThing, 'x'), 3)
+
+ def test_no_dict_no_slots(self):
+ self.assertEqual(inspect.getattr_static(1, 'foo', None), None)
+ self.assertNotEqual(inspect.getattr_static('foo', 'lower'), None)
+
+ def test_no_dict_no_slots_instance_member(self):
+ # returns descriptor
+ with open(__file__) as handle:
+ self.assertEqual(inspect.getattr_static(handle, 'name'), type(handle).name)
+
+ def test_inherited_slots(self):
+ # returns descriptor
+ class Thing(object):
+ __slots__ = ['x']
+ def __init__(self):
+ self.x = 'foo'
+
+ class OtherThing(Thing):
+ pass
+ # it would be nice if this worked...
+ # we get the descriptor instead of the instance attribute
+ self.assertEqual(inspect.getattr_static(OtherThing(), 'x'), Thing.x)
+
+ def test_descriptor(self):
+ class descriptor(object):
+ def __get__(self, instance, owner):
+ return 3
+ class Foo(object):
+ d = descriptor()
+
+ foo = Foo()
+
+ # for a non data descriptor we return the instance attribute
+ foo.__dict__['d'] = 1
+ self.assertEqual(inspect.getattr_static(foo, 'd'), 1)
+
+ # if the descriptor is a data-desciptor we should return the
+ # descriptor
+ descriptor.__set__ = lambda s, i, v: None
+ self.assertEqual(inspect.getattr_static(foo, 'd'), Foo.__dict__['d'])
+
+
+ def test_metaclass_with_descriptor(self):
+ class descriptor(object):
+ def __get__(self, instance, owner):
+ return 3
+ class meta(type):
+ d = descriptor()
+ class Thing(object, metaclass=meta):
+ pass
+ self.assertEqual(inspect.getattr_static(Thing, 'd'), meta.__dict__['d'])
+
+
+ def test_class_as_property(self):
+ class Base(object):
+ foo = 3
+
+ class Something(Base):
+ executed = False
+ @property
+ def __class__(self):
+ self.executed = True
+ return object
+
+ instance = Something()
+ self.assertEqual(inspect.getattr_static(instance, 'foo'), 3)
+ self.assertFalse(instance.executed)
+ self.assertEqual(inspect.getattr_static(Something, 'foo'), 3)
+
+ def test_mro_as_property(self):
+ class Meta(type):
+ @property
+ def __mro__(self):
+ return (object,)
+
+ class Base(object):
+ foo = 3
+
+ class Something(Base, metaclass=Meta):
+ pass
+
+ self.assertEqual(inspect.getattr_static(Something(), 'foo'), 3)
+ self.assertEqual(inspect.getattr_static(Something, 'foo'), 3)
+
+ def test_dict_as_property(self):
+ test = self
+ test.called = False
+
+ class Foo(dict):
+ a = 3
+ @property
+ def __dict__(self):
+ test.called = True
+ return {}
+
+ foo = Foo()
+ foo.a = 4
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_custom_object_dict(self):
+ test = self
+ test.called = False
+
+ class Custom(dict):
+ def get(self, key, default=None):
+ test.called = True
+ super().get(key, default)
+
+ class Foo(object):
+ a = 3
+ foo = Foo()
+ foo.__dict__ = Custom()
+ self.assertEqual(inspect.getattr_static(foo, 'a'), 3)
+ self.assertFalse(test.called)
+
+ def test_metaclass_dict_as_property(self):
+ class Meta(type):
+ @property
+ def __dict__(self):
+ self.executed = True
+
+ class Thing(metaclass=Meta):
+ executed = False
+
+ def __init__(self):
+ self.spam = 42
+
+ instance = Thing()
+ self.assertEqual(inspect.getattr_static(instance, "spam"), 42)
+ self.assertFalse(Thing.executed)
+
+ def test_module(self):
+ sentinel = object()
+ self.assertIsNot(inspect.getattr_static(sys, "version", sentinel),
+ sentinel)
+
+ def test_metaclass_with_metaclass_with_dict_as_property(self):
+ class MetaMeta(type):
+ @property
+ def __dict__(self):
+ self.executed = True
+ return dict(spam=42)
+
+ class Meta(type, metaclass=MetaMeta):
+ executed = False
+
+ class Thing(metaclass=Meta):
+ pass
+
+ with self.assertRaises(AttributeError):
+ inspect.getattr_static(Thing, "spam")
+ self.assertFalse(Thing.executed)
+
+class TestGetGeneratorState(unittest.TestCase):
+
+ def setUp(self):
+ def number_generator():
+ for number in range(5):
+ yield number
+ self.generator = number_generator()
+
+ def _generatorstate(self):
+ return inspect.getgeneratorstate(self.generator)
+
+ def test_created(self):
+ self.assertEqual(self._generatorstate(), inspect.GEN_CREATED)
+
+ def test_suspended(self):
+ next(self.generator)
+ self.assertEqual(self._generatorstate(), inspect.GEN_SUSPENDED)
+
+ def test_closed_after_exhaustion(self):
+ for i in self.generator:
+ pass
+ self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)
+
+ def test_closed_after_immediate_exception(self):
+ with self.assertRaises(RuntimeError):
+ self.generator.throw(RuntimeError)
+ self.assertEqual(self._generatorstate(), inspect.GEN_CLOSED)
+
+ def test_running(self):
+ # As mentioned on issue #10220, checking for the RUNNING state only
+ # makes sense inside the generator itself.
+ # The following generator checks for this by using the closure's
+ # reference to self and the generator state checking helper method
+ def running_check_generator():
+ for number in range(5):
+ self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
+ yield number
+ self.assertEqual(self._generatorstate(), inspect.GEN_RUNNING)
+ self.generator = running_check_generator()
+ # Running up to the first yield
+ next(self.generator)
+ # Running after the first yield
+ next(self.generator)
+
+ def test_easy_debugging(self):
+ # repr() and str() of a generator state should contain the state name
+ names = 'GEN_CREATED GEN_RUNNING GEN_SUSPENDED GEN_CLOSED'.split()
+ for name in names:
+ state = getattr(inspect, name)
+ self.assertIn(name, repr(state))
+ self.assertIn(name, str(state))
+
+
def test_main():
run_unittest(
TestDecorators, TestRetrievingSourceCode, TestOneliners, TestBuggyCases,
TestInterpreterStack, TestClassesAndFunctions, TestPredicates,
TestGetcallargsFunctions, TestGetcallargsMethods,
- TestGetcallargsUnboundMethods)
+ TestGetcallargsUnboundMethods, TestGetattrStatic, TestGetGeneratorState,
+ TestNoEOL
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_int.py b/Lib/test/test_int.py
index 365f9a247c9..671b20a5841 100644
--- a/Lib/test/test_int.py
+++ b/Lib/test/test_int.py
@@ -1,9 +1,8 @@
import sys
import unittest
-from test import test_support
-from test.test_support import run_unittest, have_unicode
-import math
+from test import support
+from test.support import run_unittest
L = [
('0', 0),
@@ -16,71 +15,32 @@ L = [
(' 314', 314),
('314 ', 314),
(' \t\t 314 \t\t ', 314),
- (repr(sys.maxint), sys.maxint),
+ (repr(sys.maxsize), sys.maxsize),
(' 1x', ValueError),
(' 1 ', 1),
(' 1\02 ', ValueError),
('', ValueError),
(' ', ValueError),
- (' \t\t ', ValueError)
+ (' \t\t ', ValueError),
+ ("\u0200", ValueError)
]
-if have_unicode:
- L += [
- (unicode('0'), 0),
- (unicode('1'), 1),
- (unicode('9'), 9),
- (unicode('10'), 10),
- (unicode('99'), 99),
- (unicode('100'), 100),
- (unicode('314'), 314),
- (unicode(' 314'), 314),
- (unicode('\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
- (unicode(' \t\t 314 \t\t '), 314),
- (unicode(' 1x'), ValueError),
- (unicode(' 1 '), 1),
- (unicode(' 1\02 '), ValueError),
- (unicode(''), ValueError),
- (unicode(' '), ValueError),
- (unicode(' \t\t '), ValueError),
- (unichr(0x200), ValueError),
-]
-
-class IntLongCommonTests(object):
-
- """Mixin of test cases to share between both test_int and test_long."""
-
- # Change to int or long in the TestCase subclass.
- ntype = None
-
- def test_no_args(self):
- self.assertEqual(self.ntype(), 0)
-
- def test_keyword_args(self):
- # Test invoking constructor using keyword arguments.
- self.assertEqual(self.ntype(x=1.2), 1)
- self.assertEqual(self.ntype('100', base=2), 4)
- self.assertEqual(self.ntype(x='100', base=2), 4)
- self.assertRaises(TypeError, self.ntype, base=10)
- self.assertRaises(TypeError, self.ntype, base=0)
-class IntTestCases(IntLongCommonTests, unittest.TestCase):
-
- ntype = int
+class IntTestCases(unittest.TestCase):
def test_basic(self):
self.assertEqual(int(314), 314)
self.assertEqual(int(3.14), 3)
- self.assertEqual(int(314L), 314)
# Check that conversion from float truncates towards zero
self.assertEqual(int(-3.14), -3)
self.assertEqual(int(3.9), 3)
self.assertEqual(int(-3.9), -3)
self.assertEqual(int(3.5), 3)
self.assertEqual(int(-3.5), -3)
+ self.assertEqual(int("-3"), -3)
+ self.assertEqual(int(" -3 "), -3)
+ self.assertEqual(int("\N{EM SPACE}-3\N{EN SPACE}"), -3)
# Different base:
- self.assertEqual(int("10",16), 16L)
- if have_unicode:
- self.assertEqual(int(unicode("10"),16), 16L)
+ self.assertEqual(int("10",16), 16)
# Test conversion from strings and various anomalies
for s, v in L:
for sign in "", "+", "-":
@@ -91,27 +51,27 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
vv = -v
try:
self.assertEqual(int(ss), vv)
- except v:
+ except ValueError:
pass
- s = repr(-1-sys.maxint)
+ s = repr(-1-sys.maxsize)
x = int(s)
- self.assertEqual(x+1, -sys.maxint)
+ self.assertEqual(x+1, -sys.maxsize)
self.assertIsInstance(x, int)
- # should return long
- self.assertEqual(int(s[1:]), sys.maxint+1)
+ # should return int
+ self.assertEqual(int(s[1:]), sys.maxsize+1)
- # should return long
+ # should return int
x = int(1e100)
- self.assertIsInstance(x, long)
+ self.assertIsInstance(x, int)
x = int(-1e100)
- self.assertIsInstance(x, long)
+ self.assertIsInstance(x, int)
# SF bug 434186: 0x80000000/2 != 0x80000000>>1.
# Worked by accident in Windows release build, but failed in debug build.
# Failed in all Linux builds.
- x = -1-sys.maxint
+ x = -1-sys.maxsize
self.assertEqual(x >> 1, x//2)
self.assertRaises(ValueError, int, '123\0')
@@ -123,15 +83,12 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.assertRaises(ValueError, int, '123\x00 245', 20)
x = int('1' * 600)
- self.assertIsInstance(x, long)
+ self.assertIsInstance(x, int)
- if have_unicode:
- x = int(unichr(0x661) * 600)
- self.assertIsInstance(x, long)
self.assertRaises(TypeError, int, 1, 12)
- self.assertEqual(int('0123', 0), 83)
+ self.assertEqual(int('0o123', 0), 83)
self.assertEqual(int('0x123', 16), 291)
# Bug 1679: "0x" is not a valid hex literal
@@ -144,51 +101,50 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.assertRaises(ValueError, int, "0b", 2)
self.assertRaises(ValueError, int, "0b", 0)
-
# SF bug 1334662: int(string, base) wrong answers
# Various representations of 2**32 evaluated to 0
# rather than 2**32 in previous versions
- self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296L)
- self.assertEqual(int('102002022201221111211', 3), 4294967296L)
- self.assertEqual(int('10000000000000000', 4), 4294967296L)
- self.assertEqual(int('32244002423141', 5), 4294967296L)
- self.assertEqual(int('1550104015504', 6), 4294967296L)
- self.assertEqual(int('211301422354', 7), 4294967296L)
- self.assertEqual(int('40000000000', 8), 4294967296L)
- self.assertEqual(int('12068657454', 9), 4294967296L)
- self.assertEqual(int('4294967296', 10), 4294967296L)
- self.assertEqual(int('1904440554', 11), 4294967296L)
- self.assertEqual(int('9ba461594', 12), 4294967296L)
- self.assertEqual(int('535a79889', 13), 4294967296L)
- self.assertEqual(int('2ca5b7464', 14), 4294967296L)
- self.assertEqual(int('1a20dcd81', 15), 4294967296L)
- self.assertEqual(int('100000000', 16), 4294967296L)
- self.assertEqual(int('a7ffda91', 17), 4294967296L)
- self.assertEqual(int('704he7g4', 18), 4294967296L)
- self.assertEqual(int('4f5aff66', 19), 4294967296L)
- self.assertEqual(int('3723ai4g', 20), 4294967296L)
- self.assertEqual(int('281d55i4', 21), 4294967296L)
- self.assertEqual(int('1fj8b184', 22), 4294967296L)
- self.assertEqual(int('1606k7ic', 23), 4294967296L)
- self.assertEqual(int('mb994ag', 24), 4294967296L)
- self.assertEqual(int('hek2mgl', 25), 4294967296L)
- self.assertEqual(int('dnchbnm', 26), 4294967296L)
- self.assertEqual(int('b28jpdm', 27), 4294967296L)
- self.assertEqual(int('8pfgih4', 28), 4294967296L)
- self.assertEqual(int('76beigg', 29), 4294967296L)
- self.assertEqual(int('5qmcpqg', 30), 4294967296L)
- self.assertEqual(int('4q0jto4', 31), 4294967296L)
- self.assertEqual(int('4000000', 32), 4294967296L)
- self.assertEqual(int('3aokq94', 33), 4294967296L)
- self.assertEqual(int('2qhxjli', 34), 4294967296L)
- self.assertEqual(int('2br45qb', 35), 4294967296L)
- self.assertEqual(int('1z141z4', 36), 4294967296L)
+ self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296)
+ self.assertEqual(int('102002022201221111211', 3), 4294967296)
+ self.assertEqual(int('10000000000000000', 4), 4294967296)
+ self.assertEqual(int('32244002423141', 5), 4294967296)
+ self.assertEqual(int('1550104015504', 6), 4294967296)
+ self.assertEqual(int('211301422354', 7), 4294967296)
+ self.assertEqual(int('40000000000', 8), 4294967296)
+ self.assertEqual(int('12068657454', 9), 4294967296)
+ self.assertEqual(int('4294967296', 10), 4294967296)
+ self.assertEqual(int('1904440554', 11), 4294967296)
+ self.assertEqual(int('9ba461594', 12), 4294967296)
+ self.assertEqual(int('535a79889', 13), 4294967296)
+ self.assertEqual(int('2ca5b7464', 14), 4294967296)
+ self.assertEqual(int('1a20dcd81', 15), 4294967296)
+ self.assertEqual(int('100000000', 16), 4294967296)
+ self.assertEqual(int('a7ffda91', 17), 4294967296)
+ self.assertEqual(int('704he7g4', 18), 4294967296)
+ self.assertEqual(int('4f5aff66', 19), 4294967296)
+ self.assertEqual(int('3723ai4g', 20), 4294967296)
+ self.assertEqual(int('281d55i4', 21), 4294967296)
+ self.assertEqual(int('1fj8b184', 22), 4294967296)
+ self.assertEqual(int('1606k7ic', 23), 4294967296)
+ self.assertEqual(int('mb994ag', 24), 4294967296)
+ self.assertEqual(int('hek2mgl', 25), 4294967296)
+ self.assertEqual(int('dnchbnm', 26), 4294967296)
+ self.assertEqual(int('b28jpdm', 27), 4294967296)
+ self.assertEqual(int('8pfgih4', 28), 4294967296)
+ self.assertEqual(int('76beigg', 29), 4294967296)
+ self.assertEqual(int('5qmcpqg', 30), 4294967296)
+ self.assertEqual(int('4q0jto4', 31), 4294967296)
+ self.assertEqual(int('4000000', 32), 4294967296)
+ self.assertEqual(int('3aokq94', 33), 4294967296)
+ self.assertEqual(int('2qhxjli', 34), 4294967296)
+ self.assertEqual(int('2br45qb', 35), 4294967296)
+ self.assertEqual(int('1z141z4', 36), 4294967296)
# tests with base 0
# this fails on 3.0, but in 2.x the old octal syntax is allowed
- self.assertEqual(int(' 0123 ', 0), 83)
- self.assertEqual(int(' 0123 ', 0), 83)
+ self.assertEqual(int(' 0o123 ', 0), 83)
+ self.assertEqual(int(' 0o123 ', 0), 83)
self.assertEqual(int('000', 0), 0)
self.assertEqual(int('0o123', 0), 83)
self.assertEqual(int('0x123', 0), 291)
@@ -196,12 +152,6 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.assertEqual(int(' 0O123 ', 0), 83)
self.assertEqual(int(' 0X123 ', 0), 291)
self.assertEqual(int(' 0B100 ', 0), 4)
- self.assertEqual(int('0', 0), 0)
- self.assertEqual(int('+0', 0), 0)
- self.assertEqual(int('-0', 0), 0)
- self.assertEqual(int('00', 0), 0)
- self.assertRaises(ValueError, int, '08', 0)
- self.assertRaises(ValueError, int, '-012395', 0)
# without base still base 10
self.assertEqual(int('0123'), 123)
@@ -232,155 +182,63 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
# SF bug 1334662: int(string, base) wrong answers
# Checks for proper evaluation of 2**32 + 1
- self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297L)
- self.assertEqual(int('102002022201221111212', 3), 4294967297L)
- self.assertEqual(int('10000000000000001', 4), 4294967297L)
- self.assertEqual(int('32244002423142', 5), 4294967297L)
- self.assertEqual(int('1550104015505', 6), 4294967297L)
- self.assertEqual(int('211301422355', 7), 4294967297L)
- self.assertEqual(int('40000000001', 8), 4294967297L)
- self.assertEqual(int('12068657455', 9), 4294967297L)
- self.assertEqual(int('4294967297', 10), 4294967297L)
- self.assertEqual(int('1904440555', 11), 4294967297L)
- self.assertEqual(int('9ba461595', 12), 4294967297L)
- self.assertEqual(int('535a7988a', 13), 4294967297L)
- self.assertEqual(int('2ca5b7465', 14), 4294967297L)
- self.assertEqual(int('1a20dcd82', 15), 4294967297L)
- self.assertEqual(int('100000001', 16), 4294967297L)
- self.assertEqual(int('a7ffda92', 17), 4294967297L)
- self.assertEqual(int('704he7g5', 18), 4294967297L)
- self.assertEqual(int('4f5aff67', 19), 4294967297L)
- self.assertEqual(int('3723ai4h', 20), 4294967297L)
- self.assertEqual(int('281d55i5', 21), 4294967297L)
- self.assertEqual(int('1fj8b185', 22), 4294967297L)
- self.assertEqual(int('1606k7id', 23), 4294967297L)
- self.assertEqual(int('mb994ah', 24), 4294967297L)
- self.assertEqual(int('hek2mgm', 25), 4294967297L)
- self.assertEqual(int('dnchbnn', 26), 4294967297L)
- self.assertEqual(int('b28jpdn', 27), 4294967297L)
- self.assertEqual(int('8pfgih5', 28), 4294967297L)
- self.assertEqual(int('76beigh', 29), 4294967297L)
- self.assertEqual(int('5qmcpqh', 30), 4294967297L)
- self.assertEqual(int('4q0jto5', 31), 4294967297L)
- self.assertEqual(int('4000001', 32), 4294967297L)
- self.assertEqual(int('3aokq95', 33), 4294967297L)
- self.assertEqual(int('2qhxjlj', 34), 4294967297L)
- self.assertEqual(int('2br45qc', 35), 4294967297L)
- self.assertEqual(int('1z141z5', 36), 4294967297L)
-
- def test_bit_length(self):
- tiny = 1e-10
- for x in xrange(-65000, 65000):
- k = x.bit_length()
- # Check equivalence with Python version
- self.assertEqual(k, len(bin(x).lstrip('-0b')))
- # Behaviour as specified in the docs
- if x != 0:
- self.assertTrue(2**(k-1) <= abs(x) < 2**k)
- else:
- self.assertEqual(k, 0)
- # Alternative definition: x.bit_length() == 1 + floor(log_2(x))
- if x != 0:
- # When x is an exact power of 2, numeric errors can
- # cause floor(log(x)/log(2)) to be one too small; for
- # small x this can be fixed by adding a small quantity
- # to the quotient before taking the floor.
- self.assertEqual(k, 1 + math.floor(
- math.log(abs(x))/math.log(2) + tiny))
-
- self.assertEqual((0).bit_length(), 0)
- self.assertEqual((1).bit_length(), 1)
- self.assertEqual((-1).bit_length(), 1)
- self.assertEqual((2).bit_length(), 2)
- self.assertEqual((-2).bit_length(), 2)
- for i in [2, 3, 15, 16, 17, 31, 32, 33, 63, 64]:
- a = 2**i
- self.assertEqual((a-1).bit_length(), i)
- self.assertEqual((1-a).bit_length(), i)
- self.assertEqual((a).bit_length(), i+1)
- self.assertEqual((-a).bit_length(), i+1)
- self.assertEqual((a+1).bit_length(), i+1)
- self.assertEqual((-a-1).bit_length(), i+1)
-
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
- def test_float_conversion(self):
- # values exactly representable as floats
- exact_values = [-2, -1, 0, 1, 2, 2**52, 2**53-1, 2**53, 2**53+2,
- 2**53+4, 2**54-4, 2**54-2, 2**63, -2**63, 2**64,
- -2**64, 10**20, 10**21, 10**22]
- for value in exact_values:
- self.assertEqual(int(float(int(value))), value)
-
- # test round-half-to-even
- self.assertEqual(int(float(2**53+1)), 2**53)
- self.assertEqual(int(float(2**53+2)), 2**53+2)
- self.assertEqual(int(float(2**53+3)), 2**53+4)
- self.assertEqual(int(float(2**53+5)), 2**53+4)
- self.assertEqual(int(float(2**53+6)), 2**53+6)
- self.assertEqual(int(float(2**53+7)), 2**53+8)
-
- self.assertEqual(int(float(-2**53-1)), -2**53)
- self.assertEqual(int(float(-2**53-2)), -2**53-2)
- self.assertEqual(int(float(-2**53-3)), -2**53-4)
- self.assertEqual(int(float(-2**53-5)), -2**53-4)
- self.assertEqual(int(float(-2**53-6)), -2**53-6)
- self.assertEqual(int(float(-2**53-7)), -2**53-8)
-
- self.assertEqual(int(float(2**54-2)), 2**54-2)
- self.assertEqual(int(float(2**54-1)), 2**54)
- self.assertEqual(int(float(2**54+2)), 2**54)
- self.assertEqual(int(float(2**54+3)), 2**54+4)
- self.assertEqual(int(float(2**54+5)), 2**54+4)
- self.assertEqual(int(float(2**54+6)), 2**54+8)
- self.assertEqual(int(float(2**54+10)), 2**54+8)
- self.assertEqual(int(float(2**54+11)), 2**54+12)
-
- def test_valid_non_numeric_input_types_for_x(self):
- # Test possible valid non-numeric types for x, including subclasses
- # of the allowed built-in types.
- class CustomStr(str): pass
- values = ['100', CustomStr('100')]
-
- if have_unicode:
- class CustomUnicode(unicode): pass
- values += [unicode('100'), CustomUnicode(unicode('100'))]
-
- for x in values:
- msg = 'x has value %s and type %s' % (x, type(x).__name__)
- try:
- self.assertEqual(int(x), 100, msg=msg)
- self.assertEqual(int(x, 2), 4, msg=msg)
- except TypeError, err:
- raise AssertionError('For %s got TypeError: %s' %
- (type(x).__name__, err))
-
- def test_error_on_string_float_for_x(self):
- self.assertRaises(ValueError, int, '1.2')
-
- def test_error_on_bytearray_for_x(self):
- self.assertRaises(TypeError, int, bytearray('100'), 2)
-
- def test_error_on_invalid_int_bases(self):
- for base in [-1, 1, 1000]:
- self.assertRaises(ValueError, int, '100', base)
-
- def test_error_on_string_base(self):
- self.assertRaises(TypeError, int, 100, base='foo')
-
- @test_support.cpython_only
+ self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297)
+ self.assertEqual(int('102002022201221111212', 3), 4294967297)
+ self.assertEqual(int('10000000000000001', 4), 4294967297)
+ self.assertEqual(int('32244002423142', 5), 4294967297)
+ self.assertEqual(int('1550104015505', 6), 4294967297)
+ self.assertEqual(int('211301422355', 7), 4294967297)
+ self.assertEqual(int('40000000001', 8), 4294967297)
+ self.assertEqual(int('12068657455', 9), 4294967297)
+ self.assertEqual(int('4294967297', 10), 4294967297)
+ self.assertEqual(int('1904440555', 11), 4294967297)
+ self.assertEqual(int('9ba461595', 12), 4294967297)
+ self.assertEqual(int('535a7988a', 13), 4294967297)
+ self.assertEqual(int('2ca5b7465', 14), 4294967297)
+ self.assertEqual(int('1a20dcd82', 15), 4294967297)
+ self.assertEqual(int('100000001', 16), 4294967297)
+ self.assertEqual(int('a7ffda92', 17), 4294967297)
+ self.assertEqual(int('704he7g5', 18), 4294967297)
+ self.assertEqual(int('4f5aff67', 19), 4294967297)
+ self.assertEqual(int('3723ai4h', 20), 4294967297)
+ self.assertEqual(int('281d55i5', 21), 4294967297)
+ self.assertEqual(int('1fj8b185', 22), 4294967297)
+ self.assertEqual(int('1606k7id', 23), 4294967297)
+ self.assertEqual(int('mb994ah', 24), 4294967297)
+ self.assertEqual(int('hek2mgm', 25), 4294967297)
+ self.assertEqual(int('dnchbnn', 26), 4294967297)
+ self.assertEqual(int('b28jpdn', 27), 4294967297)
+ self.assertEqual(int('8pfgih5', 28), 4294967297)
+ self.assertEqual(int('76beigh', 29), 4294967297)
+ self.assertEqual(int('5qmcpqh', 30), 4294967297)
+ self.assertEqual(int('4q0jto5', 31), 4294967297)
+ self.assertEqual(int('4000001', 32), 4294967297)
+ self.assertEqual(int('3aokq95', 33), 4294967297)
+ self.assertEqual(int('2qhxjlj', 34), 4294967297)
+ self.assertEqual(int('2br45qc', 35), 4294967297)
+ self.assertEqual(int('1z141z5', 36), 4294967297)
+
+ @support.cpython_only
def test_small_ints(self):
+ # Bug #3236: Return small longs from PyLong_FromString
self.assertIs(int('10'), 10)
self.assertIs(int('-1'), -1)
- if have_unicode:
- self.assertIs(int(u'10'), 10)
- self.assertIs(int(u'-1'), -1)
+ self.assertIs(int(b'10'), 10)
+ self.assertIs(int(b'-1'), -1)
+
+ def test_keyword_args(self):
+ # Test invoking int() using keyword arguments.
+ self.assertEqual(int(x=1.2), 1)
+ self.assertEqual(int('100', base=2), 4)
+ self.assertEqual(int(x='100', base=2), 4)
+ self.assertRaises(TypeError, int, base=10)
+ self.assertRaises(TypeError, int, base=0)
def test_intconversion(self):
# Test __int__()
class ClassicMissingMethods:
pass
- self.assertRaises(AttributeError, int, ClassicMissingMethods())
+ self.assertRaises(TypeError, int, ClassicMissingMethods())
class MissingMethods(object):
pass
@@ -404,7 +262,7 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
class Foo4(int):
def __int__(self):
- return 42L
+ return 42
class Foo5(int):
def __int__(self):
@@ -414,7 +272,7 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.assertEqual(int(Foo1()), 42)
self.assertEqual(int(Foo2()), 42)
self.assertEqual(int(Foo3()), 0)
- self.assertEqual(int(Foo4()), 42L)
+ self.assertEqual(int(Foo4()), 42)
self.assertRaises(TypeError, int, Foo5())
class Classic:
@@ -460,6 +318,16 @@ class IntTestCases(IntLongCommonTests, unittest.TestCase):
self.fail("Failed to raise TypeError with %s" %
((base, trunc_result_base),))
+ def test_error_message(self):
+ testlist = ('\xbd', '123\xbd', ' 123 456 ')
+ for s in testlist:
+ try:
+ int(s)
+ except ValueError as e:
+ self.assertIn(s.strip(), e.args[0])
+ else:
+ self.fail("Expected int(%r) to raise a ValueError", s)
+
def test_main():
run_unittest(IntTestCases)
diff --git a/Lib/test/test_int_literal.py b/Lib/test/test_int_literal.py
index e65cc7c7c04..1d578a7d716 100644
--- a/Lib/test/test_int_literal.py
+++ b/Lib/test/test_int_literal.py
@@ -4,8 +4,7 @@ This is complex because of changes due to PEP 237.
"""
import unittest
-from test import test_support
-
+from test import support
class TestHexOctBin(unittest.TestCase):
@@ -32,45 +31,28 @@ class TestHexOctBin(unittest.TestCase):
def test_hex_unsigned(self):
# Positive constants
- self.assertEqual(0x80000000, 2147483648L)
- self.assertEqual(0xffffffff, 4294967295L)
+ self.assertEqual(0x80000000, 2147483648)
+ self.assertEqual(0xffffffff, 4294967295)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0x80000000), -2147483648L)
- self.assertEqual(-(0xffffffff), -4294967295L)
+ self.assertEqual(-(0x80000000), -2147483648)
+ self.assertEqual(-(0xffffffff), -4294967295)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0x80000000, -2147483648L)
- self.assertEqual(-0xffffffff, -4294967295L)
+ self.assertEqual(-0x80000000, -2147483648)
+ self.assertEqual(-0xffffffff, -4294967295)
# Positive constants
- self.assertEqual(0x8000000000000000, 9223372036854775808L)
- self.assertEqual(0xffffffffffffffff, 18446744073709551615L)
+ self.assertEqual(0x8000000000000000, 9223372036854775808)
+ self.assertEqual(0xffffffffffffffff, 18446744073709551615)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0x8000000000000000), -9223372036854775808L)
- self.assertEqual(-(0xffffffffffffffff), -18446744073709551615L)
+ self.assertEqual(-(0x8000000000000000), -9223372036854775808)
+ self.assertEqual(-(0xffffffffffffffff), -18446744073709551615)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0x8000000000000000, -9223372036854775808L)
- self.assertEqual(-0xffffffffffffffff, -18446744073709551615L)
+ self.assertEqual(-0x8000000000000000, -9223372036854775808)
+ self.assertEqual(-0xffffffffffffffff, -18446744073709551615)
def test_oct_baseline(self):
- # Baseline tests
- self.assertEqual(00, 0)
- self.assertEqual(020, 16)
- self.assertEqual(017777777777, 2147483647)
- self.assertEqual(0777777777777777777777, 9223372036854775807)
- # Ditto with a minus sign and parentheses
- self.assertEqual(-(00), 0)
- self.assertEqual(-(020), -16)
- self.assertEqual(-(017777777777), -2147483647)
- self.assertEqual(-(0777777777777777777777), -9223372036854775807)
- # Ditto with a minus sign and NO parentheses
- self.assertEqual(-00, 0)
- self.assertEqual(-020, -16)
- self.assertEqual(-017777777777, -2147483647)
- self.assertEqual(-0777777777777777777777, -9223372036854775807)
-
- def test_oct_baseline_new(self):
# A few upper/lowercase tests
self.assertEqual(0o0, 0O0)
self.assertEqual(0o1, 0O1)
@@ -93,49 +75,26 @@ class TestHexOctBin(unittest.TestCase):
def test_oct_unsigned(self):
# Positive constants
- self.assertEqual(020000000000, 2147483648L)
- self.assertEqual(037777777777, 4294967295L)
- # Ditto with a minus sign and parentheses
- self.assertEqual(-(020000000000), -2147483648L)
- self.assertEqual(-(037777777777), -4294967295L)
- # Ditto with a minus sign and NO parentheses
- # This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-020000000000, -2147483648L)
- self.assertEqual(-037777777777, -4294967295L)
-
- # Positive constants
- self.assertEqual(01000000000000000000000, 9223372036854775808L)
- self.assertEqual(01777777777777777777777, 18446744073709551615L)
- # Ditto with a minus sign and parentheses
- self.assertEqual(-(01000000000000000000000), -9223372036854775808L)
- self.assertEqual(-(01777777777777777777777), -18446744073709551615L)
- # Ditto with a minus sign and NO parentheses
- # This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-01000000000000000000000, -9223372036854775808L)
- self.assertEqual(-01777777777777777777777, -18446744073709551615L)
-
- def test_oct_unsigned_new(self):
- # Positive constants
- self.assertEqual(0o20000000000, 2147483648L)
- self.assertEqual(0o37777777777, 4294967295L)
+ self.assertEqual(0o20000000000, 2147483648)
+ self.assertEqual(0o37777777777, 4294967295)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0o20000000000), -2147483648L)
- self.assertEqual(-(0o37777777777), -4294967295L)
+ self.assertEqual(-(0o20000000000), -2147483648)
+ self.assertEqual(-(0o37777777777), -4294967295)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0o20000000000, -2147483648L)
- self.assertEqual(-0o37777777777, -4294967295L)
+ self.assertEqual(-0o20000000000, -2147483648)
+ self.assertEqual(-0o37777777777, -4294967295)
# Positive constants
- self.assertEqual(0o1000000000000000000000, 9223372036854775808L)
- self.assertEqual(0o1777777777777777777777, 18446744073709551615L)
+ self.assertEqual(0o1000000000000000000000, 9223372036854775808)
+ self.assertEqual(0o1777777777777777777777, 18446744073709551615)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0o1000000000000000000000), -9223372036854775808L)
- self.assertEqual(-(0o1777777777777777777777), -18446744073709551615L)
+ self.assertEqual(-(0o1000000000000000000000), -9223372036854775808)
+ self.assertEqual(-(0o1777777777777777777777), -18446744073709551615)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0o1000000000000000000000, -9223372036854775808L)
- self.assertEqual(-0o1777777777777777777777, -18446744073709551615L)
+ self.assertEqual(-0o1000000000000000000000, -9223372036854775808)
+ self.assertEqual(-0o1777777777777777777777, -18446744073709551615)
def test_bin_baseline(self):
# A few upper/lowercase tests
@@ -160,29 +119,29 @@ class TestHexOctBin(unittest.TestCase):
def test_bin_unsigned(self):
# Positive constants
- self.assertEqual(0b10000000000000000000000000000000, 2147483648L)
- self.assertEqual(0b11111111111111111111111111111111, 4294967295L)
+ self.assertEqual(0b10000000000000000000000000000000, 2147483648)
+ self.assertEqual(0b11111111111111111111111111111111, 4294967295)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0b10000000000000000000000000000000), -2147483648L)
- self.assertEqual(-(0b11111111111111111111111111111111), -4294967295L)
+ self.assertEqual(-(0b10000000000000000000000000000000), -2147483648)
+ self.assertEqual(-(0b11111111111111111111111111111111), -4294967295)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0b10000000000000000000000000000000, -2147483648L)
- self.assertEqual(-0b11111111111111111111111111111111, -4294967295L)
+ self.assertEqual(-0b10000000000000000000000000000000, -2147483648)
+ self.assertEqual(-0b11111111111111111111111111111111, -4294967295)
# Positive constants
- self.assertEqual(0b1000000000000000000000000000000000000000000000000000000000000000, 9223372036854775808L)
- self.assertEqual(0b1111111111111111111111111111111111111111111111111111111111111111, 18446744073709551615L)
+ self.assertEqual(0b1000000000000000000000000000000000000000000000000000000000000000, 9223372036854775808)
+ self.assertEqual(0b1111111111111111111111111111111111111111111111111111111111111111, 18446744073709551615)
# Ditto with a minus sign and parentheses
- self.assertEqual(-(0b1000000000000000000000000000000000000000000000000000000000000000), -9223372036854775808L)
- self.assertEqual(-(0b1111111111111111111111111111111111111111111111111111111111111111), -18446744073709551615L)
+ self.assertEqual(-(0b1000000000000000000000000000000000000000000000000000000000000000), -9223372036854775808)
+ self.assertEqual(-(0b1111111111111111111111111111111111111111111111111111111111111111), -18446744073709551615)
# Ditto with a minus sign and NO parentheses
# This failed in Python 2.2 through 2.2.2 and in 2.3a1
- self.assertEqual(-0b1000000000000000000000000000000000000000000000000000000000000000, -9223372036854775808L)
- self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615L)
+ self.assertEqual(-0b1000000000000000000000000000000000000000000000000000000000000000, -9223372036854775808)
+ self.assertEqual(-0b1111111111111111111111111111111111111111111111111111111111111111, -18446744073709551615)
def test_main():
- test_support.run_unittest(TestHexOctBin)
+ support.run_unittest(TestHexOctBin)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 6132bae82f3..56ac2c8a792 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -19,9 +19,6 @@
# test both implementations. This file has lots of examples.
################################################################################
-from __future__ import print_function
-from __future__ import unicode_literals
-
import os
import sys
import time
@@ -32,10 +29,11 @@ import weakref
import abc
import signal
import errno
+import warnings
+import pickle
from itertools import cycle, count
-from collections import deque
-from UserList import UserList
-from test import test_support as support
+from collections import deque, UserList
+from test import support
import codecs
import io # C implementation of io
@@ -49,12 +47,9 @@ try:
except ImportError:
fcntl = None
-__metaclass__ = type
-bytes = support.py3k_bytes
-
def _default_chunk_size():
"""Get the default TextIOWrapper chunk size"""
- with io.open(__file__, "r", encoding="latin1") as f:
+ with open(__file__, "r", encoding="latin1") as f:
return f._CHUNK_SIZE
@@ -140,10 +135,10 @@ class PyMockRawIO(MockRawIO, pyio.RawIOBase):
class MisbehavedRawIO(MockRawIO):
def write(self, b):
- return MockRawIO.write(self, b) * 2
+ return super().write(b) * 2
def read(self, n=None):
- return MockRawIO.read(self, n) * 2
+ return super().read(n) * 2
def seek(self, pos, whence):
return -123
@@ -152,7 +147,7 @@ class MisbehavedRawIO(MockRawIO):
return -456
def readinto(self, buf):
- MockRawIO.readinto(self, buf)
+ super().readinto(buf)
return len(buf) * 5
class CMisbehavedRawIO(MisbehavedRawIO, io.RawIOBase):
@@ -181,15 +176,15 @@ class MockFileIO:
def __init__(self, data):
self.read_history = []
- super(MockFileIO, self).__init__(data)
+ super().__init__(data)
def read(self, n=None):
- res = super(MockFileIO, self).read(n)
+ res = super().read(n)
self.read_history.append(None if res is None else len(res))
return res
def readinto(self, b):
- res = super(MockFileIO, self).readinto(b)
+ res = super().readinto(b)
self.read_history.append(res)
return res
@@ -200,6 +195,23 @@ class PyMockFileIO(MockFileIO, pyio.BytesIO):
pass
+class MockUnseekableIO:
+ def seekable(self):
+ return False
+
+ def seek(self, *args):
+ raise self.UnsupportedOperation("not seekable")
+
+ def tell(self, *args):
+ raise self.UnsupportedOperation("not seekable")
+
+class CMockUnseekableIO(MockUnseekableIO, io.BytesIO):
+ UnsupportedOperation = io.UnsupportedOperation
+
+class PyMockUnseekableIO(MockUnseekableIO, pyio.BytesIO):
+ UnsupportedOperation = pyio.UnsupportedOperation
+
+
class MockNonBlockWriterIO:
def __init__(self):
@@ -330,16 +342,31 @@ class IOTest(unittest.TestCase):
def test_invalid_operations(self):
# Try writing on a file opened in read mode and vice-versa.
+ exc = self.UnsupportedOperation
for mode in ("w", "wb"):
with self.open(support.TESTFN, mode) as fp:
- self.assertRaises(IOError, fp.read)
- self.assertRaises(IOError, fp.readline)
+ self.assertRaises(exc, fp.read)
+ self.assertRaises(exc, fp.readline)
+ with self.open(support.TESTFN, "wb", buffering=0) as fp:
+ self.assertRaises(exc, fp.read)
+ self.assertRaises(exc, fp.readline)
+ with self.open(support.TESTFN, "rb", buffering=0) as fp:
+ self.assertRaises(exc, fp.write, b"blah")
+ self.assertRaises(exc, fp.writelines, [b"blah\n"])
with self.open(support.TESTFN, "rb") as fp:
- self.assertRaises(IOError, fp.write, b"blah")
- self.assertRaises(IOError, fp.writelines, [b"blah\n"])
+ self.assertRaises(exc, fp.write, b"blah")
+ self.assertRaises(exc, fp.writelines, [b"blah\n"])
with self.open(support.TESTFN, "r") as fp:
- self.assertRaises(IOError, fp.write, "blah")
- self.assertRaises(IOError, fp.writelines, ["blah\n"])
+ self.assertRaises(exc, fp.write, "blah")
+ self.assertRaises(exc, fp.writelines, ["blah\n"])
+ # Non-zero seeking from current or end pos
+ self.assertRaises(exc, fp.seek, 1, self.SEEK_CUR)
+ self.assertRaises(exc, fp.seek, -1, self.SEEK_END)
+
+ def test_open_handles_NUL_chars(self):
+ fn_with_NUL = 'foo\0bar'
+ self.assertRaises(TypeError, self.open, fn_with_NUL, 'w')
+ self.assertRaises(TypeError, self.open, bytes(fn_with_NUL, 'ascii'), 'w')
def test_raw_file_io(self):
with self.open(support.TESTFN, "wb", buffering=0) as f:
@@ -414,11 +441,11 @@ class IOTest(unittest.TestCase):
f = None
try:
with self.open(support.TESTFN, "wb", bufsize) as f:
- 1 // 0
+ 1/0
except ZeroDivisionError:
self.assertEqual(f.closed, True)
else:
- self.fail("1 // 0 didn't raise an exception")
+ self.fail("1/0 didn't raise an exception")
# issue 5008
def test_append_mode_tell(self):
@@ -437,24 +464,25 @@ class IOTest(unittest.TestCase):
def __del__(self):
record.append(1)
try:
- f = super(MyFileIO, self).__del__
+ f = super().__del__
except AttributeError:
pass
else:
f()
def close(self):
record.append(2)
- super(MyFileIO, self).close()
+ super().close()
def flush(self):
record.append(3)
- super(MyFileIO, self).flush()
- f = MyFileIO(support.TESTFN, "wb")
- f.write(b"xxx")
- del f
- support.gc_collect()
- self.assertEqual(record, [1, 2, 3])
- with self.open(support.TESTFN, "rb") as f:
- self.assertEqual(f.read(), b"xxx")
+ super().flush()
+ with support.check_warnings(('', ResourceWarning)):
+ f = MyFileIO(support.TESTFN, "wb")
+ f.write(b"xxx")
+ del f
+ support.gc_collect()
+ self.assertEqual(record, [1, 2, 3])
+ with self.open(support.TESTFN, "rb") as f:
+ self.assertEqual(f.read(), b"xxx")
def _check_base_destructor(self, base):
record = []
@@ -470,17 +498,17 @@ class IOTest(unittest.TestCase):
def __del__(self):
record.append(self.on_del)
try:
- f = super(MyIO, self).__del__
+ f = super().__del__
except AttributeError:
pass
else:
f()
def close(self):
record.append(self.on_close)
- super(MyIO, self).close()
+ super().close()
def flush(self):
record.append(self.on_flush)
- super(MyIO, self).flush()
+ super().flush()
f = MyIO()
del f
support.gc_collect()
@@ -505,8 +533,8 @@ class IOTest(unittest.TestCase):
self.assertEqual(f.read(), b"xxx")
def test_array_writes(self):
- a = array.array(b'i', range(10))
- n = len(a.tostring())
+ a = array.array('i', range(10))
+ n = len(a.tobytes())
with self.open(support.TESTFN, "wb", 0) as f:
self.assertEqual(f.write(a), n)
with self.open(support.TESTFN, "wb") as f:
@@ -541,12 +569,13 @@ class IOTest(unittest.TestCase):
def test_garbage_collection(self):
# FileIO objects are collected, and collecting them flushes
# all data to disk.
- f = self.FileIO(support.TESTFN, "wb")
- f.write(b"abcxxx")
- f.f = f
- wr = weakref.ref(f)
- del f
- support.gc_collect()
+ with support.check_warnings(('', ResourceWarning)):
+ f = self.FileIO(support.TESTFN, "wb")
+ f.write(b"abcxxx")
+ f.f = f
+ wr = weakref.ref(f)
+ del f
+ support.gc_collect()
self.assertTrue(wr() is None, wr)
with self.open(support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"abcxxx")
@@ -573,7 +602,6 @@ class IOTest(unittest.TestCase):
raise IOError()
f.flush = bad_flush
self.assertRaises(IOError, f.close) # exception not swallowed
- self.assertTrue(f.closed)
def test_multi_close(self):
f = self.open(support.TESTFN, "wb", buffering=0)
@@ -595,6 +623,17 @@ class IOTest(unittest.TestCase):
self.assertEqual(rawio.read(2), None)
self.assertEqual(rawio.read(2), b"")
+ def test_types_have_dict(self):
+ test = (
+ self.IOBase(),
+ self.RawIOBase(),
+ self.TextIOBase(),
+ self.StringIO(),
+ self.BytesIO()
+ )
+ for obj in test:
+ self.assertTrue(hasattr(obj, "__dict__"))
+
def test_fileio_closefd(self):
# Issue #4841
with self.open(__file__, 'rb') as f1, \
@@ -629,9 +668,7 @@ class CIOTest(IOTest):
self.assertTrue(wr() is None, wr)
class PyIOTest(IOTest):
- test_array_writes = unittest.skip(
- "len(array.array) returns number of elements rather than bytelength"
- )(IOTest.test_array_writes)
+ pass
class CommonBufferedTests:
@@ -668,17 +705,17 @@ class CommonBufferedTests:
def __del__(self):
record.append(1)
try:
- f = super(MyBufferedIO, self).__del__
+ f = super().__del__
except AttributeError:
pass
else:
f()
def close(self):
record.append(2)
- super(MyBufferedIO, self).close()
+ super().close()
def flush(self):
record.append(3)
- super(MyBufferedIO, self).flush()
+ super().flush()
rawio = self.MockRawIO()
bufio = MyBufferedIO(rawio)
writable = bufio.writable()
@@ -722,9 +759,9 @@ class CommonBufferedTests:
clsname = "%s.%s" % (self.tp.__module__, self.tp.__name__)
self.assertEqual(repr(b), "<%s>" % clsname)
raw.name = "dummy"
- self.assertEqual(repr(b), "<%s name=u'dummy'>" % clsname)
- raw.name = b"dummy"
self.assertEqual(repr(b), "<%s name='dummy'>" % clsname)
+ raw.name = b"dummy"
+ self.assertEqual(repr(b), "<%s name=b'dummy'>" % clsname)
def test_flush_error_on_close(self):
raw = self.MockRawIO()
@@ -733,21 +770,6 @@ class CommonBufferedTests:
raw.flush = bad_flush
b = self.tp(raw)
self.assertRaises(IOError, b.close) # exception not swallowed
- self.assertTrue(b.closed)
-
- def test_close_error_on_close(self):
- raw = self.MockRawIO()
- def bad_flush():
- raise IOError('flush')
- def bad_close():
- raise IOError('close')
- raw.close = bad_close
- b = self.tp(raw)
- b.flush = bad_flush
- with self.assertRaises(IOError) as err: # exception not swallowed
- b.close()
- self.assertEqual(err.exception.args, ('close',))
- self.assertFalse(b.closed)
def test_multi_close(self):
raw = self.MockRawIO()
@@ -757,11 +779,16 @@ class CommonBufferedTests:
b.close()
self.assertRaises(ValueError, b.flush)
+ def test_unseekable(self):
+ bufio = self.tp(self.MockUnseekableIO(b"A" * 10))
+ self.assertRaises(self.UnsupportedOperation, bufio.tell)
+ self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+
def test_readonly_attributes(self):
raw = self.MockRawIO()
buf = self.tp(raw)
x = self.MockRawIO()
- with self.assertRaises((AttributeError, TypeError)):
+ with self.assertRaises(AttributeError):
buf.raw = x
@@ -935,6 +962,14 @@ class BufferedReaderTest(unittest.TestCase, CommonBufferedTests):
finally:
support.unlink(support.TESTFN)
+ def test_unseekable(self):
+ bufio = self.tp(self.MockUnseekableIO(b"A" * 10))
+ self.assertRaises(self.UnsupportedOperation, bufio.tell)
+ self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+ bufio.read(1)
+ self.assertRaises(self.UnsupportedOperation, bufio.seek, 0)
+ self.assertRaises(self.UnsupportedOperation, bufio.tell)
+
def test_misbehaved_io(self):
rawio = self.MisbehavedRawIO((b"abc", b"d", b"efg"))
bufio = self.tp(rawio)
@@ -1070,8 +1105,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
intermediate_func(bufio)
n += size
bufio.flush()
- self.assertEqual(contents,
- b"".join(writer._write_stack))
+ self.assertEqual(contents, b"".join(writer._write_stack))
def test_writes(self):
self.check_writes(lambda bufio: None)
@@ -1164,6 +1198,7 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
bufio = self.tp(writer, 8)
self.assertRaises(TypeError, bufio.writelines, [1, 2, 3])
self.assertRaises(TypeError, bufio.writelines, None)
+ self.assertRaises(TypeError, bufio.writelines, 'abc')
def test_destructor(self):
writer = self.MockRawIO()
@@ -1246,16 +1281,6 @@ class BufferedWriterTest(unittest.TestCase, CommonBufferedTests):
DeprecationWarning)):
self.tp(self.MockRawIO(), 8, 12)
- def test_write_error_on_close(self):
- raw = self.MockRawIO()
- def bad_write(b):
- raise IOError()
- raw.write = bad_write
- b = self.tp(raw)
- b.write(b'spam')
- self.assertRaises(IOError, b.close) # exception not swallowed
- self.assertTrue(b.closed)
-
class CBufferedWriterTest(BufferedWriterTest, SizeofTest):
tp = io.BufferedWriter
@@ -1645,8 +1670,10 @@ class BufferedRandomTest(BufferedReaderTest, BufferedWriterTest):
f.flush()
self.assertEqual(raw.getvalue(), b'1b\n2def\n3\n')
-class CBufferedRandomTest(CBufferedReaderTest, CBufferedWriterTest,
- BufferedRandomTest, SizeofTest):
+ # You can't construct a BufferedRandom over a non-seekable stream.
+ test_unseekable = None
+
+class CBufferedRandomTest(BufferedRandomTest, SizeofTest):
tp = io.BufferedRandom
def test_constructor(self):
@@ -1722,7 +1749,7 @@ class StatefulIncrementalDecoder(codecs.IncrementalDecoder):
output = ''
for b in input:
if self.i == 0: # variable-length, terminated with period
- if b == '.':
+ if b == ord('.'):
if self.buffer:
output += self.process_word()
else:
@@ -1857,10 +1884,13 @@ class TextIOWrapperTest(unittest.TestCase):
"<%s.TextIOWrapper encoding='utf-8'>" % modname)
raw.name = "dummy"
self.assertEqual(repr(t),
- "<%s.TextIOWrapper name=u'dummy' encoding='utf-8'>" % modname)
+ "<%s.TextIOWrapper name='dummy' encoding='utf-8'>" % modname)
+ t.mode = "r"
+ self.assertEqual(repr(t),
+ "<%s.TextIOWrapper name='dummy' mode='r' encoding='utf-8'>" % modname)
raw.name = b"dummy"
self.assertEqual(repr(t),
- "<%s.TextIOWrapper name='dummy' encoding='utf-8'>" % modname)
+ "<%s.TextIOWrapper name=b'dummy' mode='r' encoding='utf-8'>" % modname)
def test_line_buffering(self):
r = self.BytesIO()
@@ -2020,17 +2050,17 @@ class TextIOWrapperTest(unittest.TestCase):
def __del__(self):
record.append(1)
try:
- f = super(MyTextIO, self).__del__
+ f = super().__del__
except AttributeError:
pass
else:
f()
def close(self):
record.append(2)
- super(MyTextIO, self).close()
+ super().close()
def flush(self):
record.append(3)
- super(MyTextIO, self).flush()
+ super().flush()
b = self.BytesIO()
t = MyTextIO(b, encoding="ascii")
del t
@@ -2134,26 +2164,24 @@ class TextIOWrapperTest(unittest.TestCase):
u_suffix = "\u8888\n"
suffix = bytes(u_suffix.encode("utf-8"))
line = prefix + suffix
- f = self.open(support.TESTFN, "wb")
- f.write(line*2)
- f.close()
- f = self.open(support.TESTFN, "r", encoding="utf-8")
- s = f.read(prefix_size)
- self.assertEqual(s, prefix.decode("ascii"))
- self.assertEqual(f.tell(), prefix_size)
- self.assertEqual(f.readline(), u_suffix)
+ with self.open(support.TESTFN, "wb") as f:
+ f.write(line*2)
+ with self.open(support.TESTFN, "r", encoding="utf-8") as f:
+ s = f.read(prefix_size)
+ self.assertEqual(s, str(prefix, "ascii"))
+ self.assertEqual(f.tell(), prefix_size)
+ self.assertEqual(f.readline(), u_suffix)
def test_seeking_too(self):
# Regression test for a specific bug
data = b'\xe0\xbf\xbf\n'
- f = self.open(support.TESTFN, "wb")
- f.write(data)
- f.close()
- f = self.open(support.TESTFN, "r", encoding="utf-8")
- f._CHUNK_SIZE # Just test that it exists
- f._CHUNK_SIZE = 2
- f.readline()
- f.tell()
+ with self.open(support.TESTFN, "wb") as f:
+ f.write(data)
+ with self.open(support.TESTFN, "r", encoding="utf-8") as f:
+ f._CHUNK_SIZE # Just test that it exists
+ f._CHUNK_SIZE = 2
+ f.readline()
+ f.tell()
def test_seek_and_tell(self):
#Test seek/tell using the StatefulIncrementalDecoder.
@@ -2404,7 +2432,6 @@ class TextIOWrapperTest(unittest.TestCase):
raise IOError()
txt.flush = bad_flush
self.assertRaises(IOError, txt.close) # exception not swallowed
- self.assertTrue(txt.closed)
def test_multi_close(self):
txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
@@ -2413,12 +2440,38 @@ class TextIOWrapperTest(unittest.TestCase):
txt.close()
self.assertRaises(ValueError, txt.flush)
+ def test_unseekable(self):
+ txt = self.TextIOWrapper(self.MockUnseekableIO(self.testdata))
+ self.assertRaises(self.UnsupportedOperation, txt.tell)
+ self.assertRaises(self.UnsupportedOperation, txt.seek, 0)
+
def test_readonly_attributes(self):
txt = self.TextIOWrapper(self.BytesIO(self.testdata), encoding="ascii")
buf = self.BytesIO(self.testdata)
- with self.assertRaises((AttributeError, TypeError)):
+ with self.assertRaises(AttributeError):
txt.buffer = buf
+ def test_rawio(self):
+ # Issue #12591: TextIOWrapper must work with raw I/O objects, so
+ # that subprocess.Popen() can have the required unbuffered
+ # semantics with universal_newlines=True.
+ raw = self.MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n'])
+ txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n')
+ # Reads
+ self.assertEqual(txt.read(4), 'abcd')
+ self.assertEqual(txt.readline(), 'efghi\n')
+ self.assertEqual(list(txt), ['jkl\n', 'opq\n'])
+
+ def test_rawio_write_through(self):
+ # Issue #12591: with write_through=True, writes don't need a flush
+ raw = self.MockRawIO([b'abc', b'def', b'ghi\njkl\nopq\n'])
+ txt = self.TextIOWrapper(raw, encoding='ascii', newline='\n',
+ write_through=True)
+ txt.write('1')
+ txt.write('23\n4')
+ txt.write('5')
+ self.assertEqual(b''.join(raw._write_stack), b'123\n45')
+
class CTextIOWrapperTest(TextIOWrapperTest):
def test_initialization(self):
@@ -2516,7 +2569,7 @@ class IncrementalNewlineDecoderTest(unittest.TestCase):
def _decode_bytewise(s):
# Decode one byte at a time
for b in encoder.encode(s):
- result.append(decoder.decode(b))
+ result.append(decoder.decode(bytes([b])))
else:
encoder = None
def _decode_bytewise(s):
@@ -2674,7 +2727,7 @@ class MiscIOTest(unittest.TestCase):
self.assertRaises(TypeError, self.BlockingIOError, 1, "", None)
b = self.BlockingIOError(1, "")
self.assertEqual(b.characters_written, 0)
- class C(unicode):
+ class C(str):
pass
c = C("")
b = self.BlockingIOError(1, c)
@@ -2718,6 +2771,63 @@ class MiscIOTest(unittest.TestCase):
# baseline "io" module.
self._check_abc_inheritance(io)
+ def _check_warn_on_dealloc(self, *args, **kwargs):
+ f = open(*args, **kwargs)
+ r = repr(f)
+ with self.assertWarns(ResourceWarning) as cm:
+ f = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+
+ def test_warn_on_dealloc(self):
+ self._check_warn_on_dealloc(support.TESTFN, "wb", buffering=0)
+ self._check_warn_on_dealloc(support.TESTFN, "wb")
+ self._check_warn_on_dealloc(support.TESTFN, "w")
+
+ def _check_warn_on_dealloc_fd(self, *args, **kwargs):
+ fds = []
+ def cleanup_fds():
+ for fd in fds:
+ try:
+ os.close(fd)
+ except EnvironmentError as e:
+ if e.errno != errno.EBADF:
+ raise
+ self.addCleanup(cleanup_fds)
+ r, w = os.pipe()
+ fds += r, w
+ self._check_warn_on_dealloc(r, *args, **kwargs)
+ # When using closefd=False, there's no warning
+ r, w = os.pipe()
+ fds += r, w
+ with warnings.catch_warnings(record=True) as recorded:
+ open(r, *args, closefd=False, **kwargs)
+ support.gc_collect()
+ self.assertEqual(recorded, [])
+
+ def test_warn_on_dealloc_fd(self):
+ self._check_warn_on_dealloc_fd("rb", buffering=0)
+ self._check_warn_on_dealloc_fd("rb")
+ self._check_warn_on_dealloc_fd("r")
+
+
+ def test_pickling(self):
+ # Pickling file objects is forbidden
+ for kwargs in [
+ {"mode": "w"},
+ {"mode": "wb"},
+ {"mode": "wb", "buffering": 0},
+ {"mode": "r"},
+ {"mode": "rb"},
+ {"mode": "rb", "buffering": 0},
+ {"mode": "w+"},
+ {"mode": "w+b"},
+ {"mode": "w+b", "buffering": 0},
+ ]:
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+ with self.open(support.TESTFN, **kwargs) as f:
+ self.assertRaises(TypeError, pickle.dumps, f, protocol)
+
@unittest.skipUnless(fcntl, 'fcntl required for this test')
def test_nonblock_pipe_write_bigbuf(self):
self._test_nonblock_pipe_write(16*1024)
@@ -2797,7 +2907,7 @@ class SignalsTest(unittest.TestCase):
signal.signal(signal.SIGALRM, self.oldalrm)
def alarm_interrupt(self, sig, frame):
- 1 // 0
+ 1/0
@unittest.skipUnless(threading, 'Threading required for this test.')
@unittest.skipIf(sys.platform in ('freebsd5', 'freebsd6', 'freebsd7'),
@@ -2813,6 +2923,7 @@ class SignalsTest(unittest.TestCase):
t = threading.Thread(target=_read)
t.daemon = True
r, w = os.pipe()
+ fdopen_kwargs["closefd"] = False
try:
wio = self.io.open(w, **fdopen_kwargs)
t.start()
@@ -2855,7 +2966,7 @@ class SignalsTest(unittest.TestCase):
def on_alarm(*args):
# Will be called reentrantly from the same thread
wio.write(data)
- 1//0
+ 1/0
signal.signal(signal.SIGALRM, on_alarm)
r, w = os.pipe()
wio = self.io.open(w, **fdopen_kwargs)
@@ -2906,11 +3017,11 @@ class SignalsTest(unittest.TestCase):
os.close(w)
os.close(r)
- def test_interrupterd_read_retry_buffered(self):
+ def test_interrupted_read_retry_buffered(self):
self.check_interrupted_read_retry(lambda x: x.decode('latin1'),
mode="rb")
- def test_interrupterd_read_retry_text(self):
+ def test_interrupted_read_retry_text(self):
self.check_interrupted_read_retry(lambda x: x,
mode="r")
@@ -2969,10 +3080,10 @@ class SignalsTest(unittest.TestCase):
if e.errno != errno.EBADF:
raise
- def test_interrupterd_write_retry_buffered(self):
+ def test_interrupted_write_retry_buffered(self):
self.check_interrupted_write_retry(b"x", mode="wb")
- def test_interrupterd_write_retry_text(self):
+ def test_interrupted_write_retry_text(self):
self.check_interrupted_write_retry("x", mode="w", encoding="latin1")
@@ -3004,10 +3115,10 @@ def test_main():
# Put the namespaces of the IO module we are testing and some useful mock
# classes in the __dict__ of each test.
mocks = (MockRawIO, MisbehavedRawIO, MockFileIO, CloseFailureIO,
- MockNonBlockWriterIO, MockRawIOWithoutRead)
+ MockNonBlockWriterIO, MockUnseekableIO, MockRawIOWithoutRead)
all_members = io.__all__ + ["IncrementalNewlineDecoder"]
- c_io_ns = dict((name, getattr(io, name)) for name in all_members)
- py_io_ns = dict((name, getattr(pyio, name)) for name in all_members)
+ c_io_ns = {name : getattr(io, name) for name in all_members}
+ py_io_ns = {name : getattr(pyio, name) for name in all_members}
globs = globals()
c_io_ns.update((x.__name__, globs["C" + x.__name__]) for x in mocks)
py_io_ns.update((x.__name__, globs["Py" + x.__name__]) for x in mocks)
diff --git a/Lib/test/test_ioctl.py b/Lib/test/test_ioctl.py
index ae965d8242b..531c9afbb58 100644
--- a/Lib/test/test_ioctl.py
+++ b/Lib/test/test_ioctl.py
@@ -1,13 +1,13 @@
import array
import unittest
-from test.test_support import run_unittest, import_module, get_attribute
+from test.support import run_unittest, import_module, get_attribute
import os, struct
fcntl = import_module('fcntl')
termios = import_module('termios')
get_attribute(termios, 'TIOCGPGRP') #Can't run tests without this feature
try:
- tty = open("/dev/tty", "r")
+ tty = open("/dev/tty", "rb")
except IOError:
raise unittest.SkipTest("Unable to open /dev/tty")
else:
@@ -30,10 +30,10 @@ class IoctlTests(unittest.TestCase):
# If this process has been put into the background, TIOCGPGRP returns
# the session ID instead of the process group id.
ids = (os.getpgrp(), os.getsid(0))
- tty = open("/dev/tty", "r")
- r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
- rpgrp = struct.unpack("i", r)[0]
- self.assertIn(rpgrp, ids)
+ with open("/dev/tty", "rb") as tty:
+ r = fcntl.ioctl(tty, termios.TIOCGPGRP, " ")
+ rpgrp = struct.unpack("i", r)[0]
+ self.assertIn(rpgrp, ids)
def _check_ioctl_mutate_len(self, nbytes=None):
buf = array.array('i')
@@ -47,7 +47,7 @@ class IoctlTests(unittest.TestCase):
self.assertEqual(len(buf) * intsize, nbytes) # sanity check
else:
buf.append(fill)
- with open("/dev/tty", "r") as tty:
+ with open("/dev/tty", "rb") as tty:
r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
rpgrp = buf[0]
self.assertEqual(r, 0)
@@ -72,7 +72,7 @@ class IoctlTests(unittest.TestCase):
try:
if termios.TIOCSWINSZ < 0:
set_winsz_opcode_maybe_neg = termios.TIOCSWINSZ
- set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffffL
+ set_winsz_opcode_pos = termios.TIOCSWINSZ & 0xffffffff
else:
set_winsz_opcode_pos = termios.TIOCSWINSZ
set_winsz_opcode_maybe_neg, = struct.unpack("i",
diff --git a/Lib/test/test_isinstance.py b/Lib/test/test_isinstance.py
index 25b0816713b..dc2d07467aa 100644
--- a/Lib/test/test_isinstance.py
+++ b/Lib/test/test_isinstance.py
@@ -3,7 +3,7 @@
# testing of error conditions uncovered when using extension types.
import unittest
-from test import test_support
+from test import support
import sys
@@ -15,8 +15,7 @@ class TestIsInstanceExceptions(unittest.TestCase):
# (leading to an "undetected error" in the debug build). Set up is,
# isinstance(inst, cls) where:
#
- # - inst isn't an InstanceType
- # - cls isn't a ClassType, a TypeType, or a TupleType
+ # - cls isn't a a type, or a tuple
# - cls has a __bases__ attribute
# - inst has a __class__ attribute
# - inst.__class__ as no __bases__ attribute
@@ -82,6 +81,20 @@ class TestIsInstanceExceptions(unittest.TestCase):
self.assertRaises(TypeError, isinstance, I(), C())
+ # check that we don't mask non AttributeErrors
+ # see: http://bugs.python.org/issue1574217
+ def test_isinstance_dont_mask_non_attribute_error(self):
+ class C(object):
+ def getclass(self):
+ raise RuntimeError
+ __class__ = property(getclass)
+
+ c = C()
+ self.assertRaises(RuntimeError, isinstance, c, bool)
+
+ # test another code path
+ class D: pass
+ self.assertRaises(RuntimeError, isinstance, c, D)
# These tests are similar to above, but tickle certain code paths in
@@ -242,9 +255,8 @@ class TestIsInstanceIsSubclass(unittest.TestCase):
self.assertEqual(False, issubclass(NewChild, ()))
self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,))))
- self.assertEqual(True, issubclass(int, (long, (float, int))))
- if test_support.have_unicode:
- self.assertEqual(True, issubclass(str, (unicode, (Child, NewChild, basestring))))
+ self.assertEqual(True, issubclass(int, (int, (float, int))))
+ self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str))))
def test_subclass_recursion_limit(self):
# make sure that issubclass raises RuntimeError before the C stack is
@@ -260,13 +272,13 @@ def blowstack(fxn, arg, compare_to):
# Make sure that calling isinstance with a deeply nested tuple for its
# argument will raise RuntimeError eventually.
tuple_arg = (compare_to,)
- for cnt in xrange(sys.getrecursionlimit()+5):
+ for cnt in range(sys.getrecursionlimit()+5):
tuple_arg = (tuple_arg,)
fxn(arg, tuple_arg)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestIsInstanceExceptions,
TestIsSubclassExceptions,
TestIsInstanceIsSubclass
diff --git a/Lib/test/test_iter.py b/Lib/test/test_iter.py
index 8dc39d2e43f..4d971835cb1 100644
--- a/Lib/test/test_iter.py
+++ b/Lib/test/test_iter.py
@@ -1,8 +1,7 @@
# Test iterators.
import unittest
-from test.test_support import run_unittest, TESTFN, unlink, have_unicode, \
- check_py3k_warnings, cpython_only
+from test.support import run_unittest, TESTFN, unlink, cpython_only
# Test result of triple loop (too big to inline)
TRIPLETS = [(0, 0, 0), (0, 0, 1), (0, 0, 2),
@@ -23,7 +22,7 @@ class BasicIterClass:
def __init__(self, n):
self.n = n
self.i = 0
- def next(self):
+ def __next__(self):
res = self.i
if res >= self.n:
raise StopIteration
@@ -54,7 +53,7 @@ class TestCase(unittest.TestCase):
res = []
while 1:
try:
- val = it.next()
+ val = next(it)
except StopIteration:
break
res.append(val)
@@ -69,18 +68,18 @@ class TestCase(unittest.TestCase):
# Test basic use of iter() function
def test_iter_basic(self):
- self.check_iterator(iter(range(10)), range(10))
+ self.check_iterator(iter(range(10)), list(range(10)))
# Test that iter(iter(x)) is the same as iter(x)
def test_iter_idempotency(self):
- seq = range(10)
+ seq = list(range(10))
it = iter(seq)
it2 = iter(it)
self.assertTrue(it is it2)
# Test that for loops over iterators work
def test_iter_for_loop(self):
- self.check_for_loop(iter(range(10)), range(10))
+ self.check_for_loop(iter(range(10)), list(range(10)))
# Test several independent iterators over the same list
def test_iter_independence(self):
@@ -107,19 +106,19 @@ class TestCase(unittest.TestCase):
# Test a class with __iter__ in a for loop
def test_iter_class_for(self):
- self.check_for_loop(IteratingSequenceClass(10), range(10))
+ self.check_for_loop(IteratingSequenceClass(10), list(range(10)))
# Test a class with __iter__ with explicit iter()
def test_iter_class_iter(self):
- self.check_iterator(iter(IteratingSequenceClass(10)), range(10))
+ self.check_iterator(iter(IteratingSequenceClass(10)), list(range(10)))
# Test for loop on a sequence class without __iter__
def test_seq_class_for(self):
- self.check_for_loop(SequenceClass(10), range(10))
+ self.check_for_loop(SequenceClass(10), list(range(10)))
# Test iter() on a sequence class without __iter__
def test_seq_class_iter(self):
- self.check_iterator(iter(SequenceClass(10)), range(10))
+ self.check_iterator(iter(SequenceClass(10)), list(range(10)))
# Test a new_style class with __iter__ but no next() method
def test_new_style_iter_class(self):
@@ -139,7 +138,7 @@ class TestCase(unittest.TestCase):
if i > 100:
raise IndexError # Emergency stop
return i
- self.check_iterator(iter(C(), 10), range(10))
+ self.check_iterator(iter(C(), 10), list(range(10)))
# Test two-argument iter() with function
def test_iter_function(self):
@@ -147,7 +146,7 @@ class TestCase(unittest.TestCase):
i = state[0]
state[0] = i+1
return i
- self.check_iterator(iter(spam, 10), range(10))
+ self.check_iterator(iter(spam, 10), list(range(10)))
# Test two-argument iter() with function that raises StopIteration
def test_iter_function_stop(self):
@@ -157,7 +156,7 @@ class TestCase(unittest.TestCase):
raise StopIteration
state[0] = i+1
return i
- self.check_iterator(iter(spam, 20), range(10))
+ self.check_iterator(iter(spam, 20), list(range(10)))
# Test exception propagation through function iterator
def test_exception_function(self):
@@ -172,7 +171,7 @@ class TestCase(unittest.TestCase):
for x in iter(spam, 20):
res.append(x)
except RuntimeError:
- self.assertEqual(res, range(10))
+ self.assertEqual(res, list(range(10)))
else:
self.fail("should have raised RuntimeError")
@@ -188,7 +187,7 @@ class TestCase(unittest.TestCase):
for x in MySequenceClass(20):
res.append(x)
except RuntimeError:
- self.assertEqual(res, range(10))
+ self.assertEqual(res, list(range(10)))
else:
self.fail("should have raised RuntimeError")
@@ -199,11 +198,11 @@ class TestCase(unittest.TestCase):
if i == 10:
raise StopIteration
return SequenceClass.__getitem__(self, i)
- self.check_for_loop(MySequenceClass(20), range(10))
+ self.check_for_loop(MySequenceClass(20), list(range(10)))
# Test a big range
def test_iter_big_range(self):
- self.check_for_loop(iter(range(10000)), range(10000))
+ self.check_for_loop(iter(range(10000)), list(range(10000)))
# Test an empty list
def test_iter_empty(self):
@@ -211,29 +210,22 @@ class TestCase(unittest.TestCase):
# Test a tuple
def test_iter_tuple(self):
- self.check_for_loop(iter((0,1,2,3,4,5,6,7,8,9)), range(10))
+ self.check_for_loop(iter((0,1,2,3,4,5,6,7,8,9)), list(range(10)))
- # Test an xrange
- def test_iter_xrange(self):
- self.check_for_loop(iter(xrange(10)), range(10))
+ # Test a range
+ def test_iter_range(self):
+ self.check_for_loop(iter(range(10)), list(range(10)))
# Test a string
def test_iter_string(self):
self.check_for_loop(iter("abcde"), ["a", "b", "c", "d", "e"])
- # Test a Unicode string
- if have_unicode:
- def test_iter_unicode(self):
- self.check_for_loop(iter(unicode("abcde")),
- [unicode("a"), unicode("b"), unicode("c"),
- unicode("d"), unicode("e")])
-
# Test a directory
def test_iter_dict(self):
dict = {}
for i in range(10):
dict[i] = None
- self.check_for_loop(dict, dict.keys())
+ self.check_for_loop(dict, list(dict.keys()))
# Test a file
def test_iter_file(self):
@@ -256,13 +248,12 @@ class TestCase(unittest.TestCase):
# Test list()'s use of iterators.
def test_builtin_list(self):
- self.assertEqual(list(SequenceClass(5)), range(5))
+ self.assertEqual(list(SequenceClass(5)), list(range(5)))
self.assertEqual(list(SequenceClass(0)), [])
self.assertEqual(list(()), [])
- self.assertEqual(list(range(10, -1, -1)), range(10, -1, -1))
d = {"one": 1, "two": 2, "three": 3}
- self.assertEqual(list(d), d.keys())
+ self.assertEqual(list(d), list(d.keys()))
self.assertRaises(TypeError, list, list)
self.assertRaises(TypeError, list, 42)
@@ -321,13 +312,14 @@ class TestCase(unittest.TestCase):
# Test filter()'s use of iterators.
def test_builtin_filter(self):
- self.assertEqual(filter(None, SequenceClass(5)), range(1, 5))
- self.assertEqual(filter(None, SequenceClass(0)), [])
- self.assertEqual(filter(None, ()), ())
- self.assertEqual(filter(None, "abc"), "abc")
+ self.assertEqual(list(filter(None, SequenceClass(5))),
+ list(range(1, 5)))
+ self.assertEqual(list(filter(None, SequenceClass(0))), [])
+ self.assertEqual(list(filter(None, ())), [])
+ self.assertEqual(list(filter(None, "abc")), ["a", "b", "c"])
d = {"one": 1, "two": 2, "three": 3}
- self.assertEqual(filter(None, d), d.keys())
+ self.assertEqual(list(filter(None, d)), list(d.keys()))
self.assertRaises(TypeError, filter, None, list)
self.assertRaises(TypeError, filter, None, 42)
@@ -335,10 +327,10 @@ class TestCase(unittest.TestCase):
class Boolean:
def __init__(self, truth):
self.truth = truth
- def __nonzero__(self):
+ def __bool__(self):
return self.truth
- bTrue = Boolean(1)
- bFalse = Boolean(0)
+ bTrue = Boolean(True)
+ bFalse = Boolean(False)
class Seq:
def __init__(self, *args):
@@ -350,7 +342,7 @@ class TestCase(unittest.TestCase):
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
i = self.i
self.i = i + 1
if i < len(self.vals):
@@ -360,8 +352,8 @@ class TestCase(unittest.TestCase):
return SeqIter(self.vals)
seq = Seq(*([bTrue, bFalse] * 25))
- self.assertEqual(filter(lambda x: not x, seq), [bFalse]*25)
- self.assertEqual(filter(lambda x: not x, iter(seq)), [bFalse]*25)
+ self.assertEqual(list(filter(lambda x: not x, seq)), [bFalse]*25)
+ self.assertEqual(list(filter(lambda x: not x, iter(seq))), [bFalse]*25)
# Test max() and min()'s use of iterators.
def test_builtin_max_min(self):
@@ -373,8 +365,8 @@ class TestCase(unittest.TestCase):
d = {"one": 1, "two": 2, "three": 3}
self.assertEqual(max(d), "two")
self.assertEqual(min(d), "one")
- self.assertEqual(max(d.itervalues()), 3)
- self.assertEqual(min(iter(d.itervalues())), 1)
+ self.assertEqual(max(d.values()), 3)
+ self.assertEqual(min(iter(d.values())), 1)
f = open(TESTFN, "w")
try:
@@ -397,24 +389,17 @@ class TestCase(unittest.TestCase):
# Test map()'s use of iterators.
def test_builtin_map(self):
- self.assertEqual(map(lambda x: x+1, SequenceClass(5)), range(1, 6))
+ self.assertEqual(list(map(lambda x: x+1, SequenceClass(5))),
+ list(range(1, 6)))
d = {"one": 1, "two": 2, "three": 3}
- self.assertEqual(map(lambda k, d=d: (k, d[k]), d), d.items())
- dkeys = d.keys()
+ self.assertEqual(list(map(lambda k, d=d: (k, d[k]), d)),
+ list(d.items()))
+ dkeys = list(d.keys())
expected = [(i < len(d) and dkeys[i] or None,
i,
i < len(d) and dkeys[i] or None)
- for i in range(5)]
-
- # Deprecated map(None, ...)
- with check_py3k_warnings():
- self.assertEqual(map(None, SequenceClass(5)), range(5))
- self.assertEqual(map(None, d), d.keys())
- self.assertEqual(map(None, d,
- SequenceClass(5),
- iter(d.iterkeys())),
- expected)
+ for i in range(3)]
f = open(TESTFN, "w")
try:
@@ -424,7 +409,7 @@ class TestCase(unittest.TestCase):
f.close()
f = open(TESTFN, "r")
try:
- self.assertEqual(map(len, f), range(1, 21, 2))
+ self.assertEqual(list(map(len, f)), list(range(1, 21, 2)))
finally:
f.close()
try:
@@ -434,21 +419,21 @@ class TestCase(unittest.TestCase):
# Test zip()'s use of iterators.
def test_builtin_zip(self):
- self.assertEqual(zip(), [])
- self.assertEqual(zip(*[]), [])
- self.assertEqual(zip(*[(1, 2), 'ab']), [(1, 'a'), (2, 'b')])
+ self.assertEqual(list(zip()), [])
+ self.assertEqual(list(zip(*[])), [])
+ self.assertEqual(list(zip(*[(1, 2), 'ab'])), [(1, 'a'), (2, 'b')])
self.assertRaises(TypeError, zip, None)
self.assertRaises(TypeError, zip, range(10), 42)
self.assertRaises(TypeError, zip, range(10), zip)
- self.assertEqual(zip(IteratingSequenceClass(3)),
+ self.assertEqual(list(zip(IteratingSequenceClass(3))),
[(0,), (1,), (2,)])
- self.assertEqual(zip(SequenceClass(3)),
+ self.assertEqual(list(zip(SequenceClass(3))),
[(0,), (1,), (2,)])
d = {"one": 1, "two": 2, "three": 3}
- self.assertEqual(d.items(), zip(d, d.itervalues()))
+ self.assertEqual(list(d.items()), list(zip(d, d.values())))
# Generate all ints starting at constructor arg.
class IntsFrom:
@@ -458,7 +443,7 @@ class TestCase(unittest.TestCase):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
i = self.i
self.i = i+1
return i
@@ -470,7 +455,7 @@ class TestCase(unittest.TestCase):
f.close()
f = open(TESTFN, "r")
try:
- self.assertEqual(zip(IntsFrom(0), f, IntsFrom(-100)),
+ self.assertEqual(list(zip(IntsFrom(0), f, IntsFrom(-100))),
[(0, "a\n", -100),
(1, "bbb\n", -99),
(2, "cc\n", -98)])
@@ -481,7 +466,7 @@ class TestCase(unittest.TestCase):
except OSError:
pass
- self.assertEqual(zip(xrange(5)), [(i,) for i in range(5)])
+ self.assertEqual(list(zip(range(5))), [(i,) for i in range(5)])
# Classes that lie about their lengths.
class NoGuessLen5:
@@ -498,35 +483,20 @@ class TestCase(unittest.TestCase):
def __len__(self):
return 30
+ def lzip(*args):
+ return list(zip(*args))
+
self.assertEqual(len(Guess3Len5()), 3)
self.assertEqual(len(Guess30Len5()), 30)
- self.assertEqual(zip(NoGuessLen5()), zip(range(5)))
- self.assertEqual(zip(Guess3Len5()), zip(range(5)))
- self.assertEqual(zip(Guess30Len5()), zip(range(5)))
+ self.assertEqual(lzip(NoGuessLen5()), lzip(range(5)))
+ self.assertEqual(lzip(Guess3Len5()), lzip(range(5)))
+ self.assertEqual(lzip(Guess30Len5()), lzip(range(5)))
expected = [(i, i) for i in range(5)]
for x in NoGuessLen5(), Guess3Len5(), Guess30Len5():
for y in NoGuessLen5(), Guess3Len5(), Guess30Len5():
- self.assertEqual(zip(x, y), expected)
-
- # Test reduces()'s use of iterators.
- def test_deprecated_builtin_reduce(self):
- with check_py3k_warnings():
- self._test_builtin_reduce()
-
- def _test_builtin_reduce(self):
- from operator import add
- self.assertEqual(reduce(add, SequenceClass(5)), 10)
- self.assertEqual(reduce(add, SequenceClass(5), 42), 52)
- self.assertRaises(TypeError, reduce, add, SequenceClass(0))
- self.assertEqual(reduce(add, SequenceClass(0), 42), 42)
- self.assertEqual(reduce(add, SequenceClass(1)), 0)
- self.assertEqual(reduce(add, SequenceClass(1), 42), 42)
-
- d = {"one": 1, "two": 2, "three": 3}
- self.assertEqual(reduce(add, d), "".join(d.keys()))
+ self.assertEqual(lzip(x, y), expected)
- # This test case will be removed if we don't have Unicode
def test_unicode_join_endcase(self):
# This class inserts a Unicode object into its argument's natural
@@ -539,12 +509,12 @@ class TestCase(unittest.TestCase):
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
i = self.i
self.i = i+1
if i == 2:
- return unicode("fooled you!")
- return self.it.next()
+ return "fooled you!"
+ return next(self.it)
f = open(TESTFN, "w")
try:
@@ -560,15 +530,13 @@ class TestCase(unittest.TestCase):
# and pass that on to unicode.join().
try:
got = " - ".join(OhPhooey(f))
- self.assertEqual(got, unicode("a\n - b\n - fooled you! - c\n"))
+ self.assertEqual(got, "a\n - b\n - fooled you! - c\n")
finally:
f.close()
try:
unlink(TESTFN)
except OSError:
pass
- if not have_unicode:
- def test_unicode_join_endcase(self): pass
# Test iterators with 'x in y' and 'x not in y'.
def test_in_and_not_in(self):
@@ -584,13 +552,13 @@ class TestCase(unittest.TestCase):
d = {"one": 1, "two": 2, "three": 3, 1j: 2j}
for k in d:
self.assertIn(k, d)
- self.assertNotIn(k, d.itervalues())
+ self.assertNotIn(k, d.values())
for v in d.values():
- self.assertIn(v, d.itervalues())
+ self.assertIn(v, d.values())
self.assertNotIn(v, d)
- for k, v in d.iteritems():
- self.assertIn((k, v), d.iteritems())
- self.assertNotIn((v, k), d.iteritems())
+ for k, v in d.items():
+ self.assertIn((k, v), d.items())
+ self.assertNotIn((v, k), d.items())
f = open(TESTFN, "w")
try:
@@ -625,9 +593,9 @@ class TestCase(unittest.TestCase):
d = {"one": 3, "two": 3, "three": 3, 1j: 2j}
for k in d:
self.assertEqual(countOf(d, k), 1)
- self.assertEqual(countOf(d.itervalues(), 3), 3)
- self.assertEqual(countOf(d.itervalues(), 2j), 1)
- self.assertEqual(countOf(d.itervalues(), 1j), 0)
+ self.assertEqual(countOf(d.values(), 3), 3)
+ self.assertEqual(countOf(d.values(), 2j), 1)
+ self.assertEqual(countOf(d.values(), 1j), 0)
f = open(TESTFN, "w")
try:
@@ -689,7 +657,7 @@ class TestCase(unittest.TestCase):
# Test iterators with file.writelines().
def test_writelines(self):
- f = file(TESTFN, "w")
+ f = open(TESTFN, "w")
try:
self.assertRaises(TypeError, f.writelines, None)
@@ -707,7 +675,7 @@ class TestCase(unittest.TestCase):
self.finish = finish
self.i = self.start
- def next(self):
+ def __next__(self):
if self.i >= self.finish:
raise StopIteration
result = str(self.i) + '\n'
@@ -728,7 +696,7 @@ class TestCase(unittest.TestCase):
f.writelines(Whatever(6, 6+2000))
f.close()
- f = file(TESTFN)
+ f = open(TESTFN)
expected = [str(i) + "\n" for i in range(1, 2006)]
self.assertEqual(list(f), expected)
@@ -769,7 +737,7 @@ class TestCase(unittest.TestCase):
else:
self.fail("should have raised TypeError")
- a, b, c = {1: 42, 2: 42, 3: 42}.itervalues()
+ a, b, c = {1: 42, 2: 42, 3: 42}.values()
self.assertEqual((a, b, c), (42, 42, 42))
f = open(TESTFN, "w")
@@ -825,16 +793,16 @@ class TestCase(unittest.TestCase):
def test_sinkstate_list(self):
# This used to fail
- a = range(5)
+ a = list(range(5))
b = iter(a)
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
a.extend(range(5, 10))
self.assertEqual(list(b), [])
def test_sinkstate_tuple(self):
a = (0, 1, 2, 3, 4)
b = iter(a)
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
self.assertEqual(list(b), [])
def test_sinkstate_string(self):
@@ -847,7 +815,7 @@ class TestCase(unittest.TestCase):
# This used to fail
a = SequenceClass(5)
b = iter(a)
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
a.n = 10
self.assertEqual(list(b), [])
@@ -857,17 +825,17 @@ class TestCase(unittest.TestCase):
i = state[0]
state[0] = i+1
if i == 10:
- raise AssertionError, "shouldn't have gotten this far"
+ raise AssertionError("shouldn't have gotten this far")
return i
b = iter(spam, 5)
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
self.assertEqual(list(b), [])
def test_sinkstate_dict(self):
# XXX For a more thorough test, see towards the end of:
# http://mail.python.org/pipermail/python-dev/2002-July/026512.html
a = {1:1, 2:2, 0:0, 4:4, 3:3}
- for b in iter(a), a.iterkeys(), a.iteritems(), a.itervalues():
+ for b in iter(a), a.keys(), a.items(), a.values():
b = iter(a)
self.assertEqual(len(list(b)), 5)
self.assertEqual(list(b), [])
@@ -877,20 +845,20 @@ class TestCase(unittest.TestCase):
for i in range(5):
yield i
b = gen()
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
self.assertEqual(list(b), [])
def test_sinkstate_range(self):
- a = xrange(5)
+ a = range(5)
b = iter(a)
- self.assertEqual(list(b), range(5))
+ self.assertEqual(list(b), list(range(5)))
self.assertEqual(list(b), [])
def test_sinkstate_enumerate(self):
a = range(5)
e = enumerate(a)
b = iter(e)
- self.assertEqual(list(b), zip(range(5), range(5)))
+ self.assertEqual(list(b), list(zip(range(5), range(5))))
self.assertEqual(list(b), [])
def test_3720(self):
@@ -898,8 +866,8 @@ class TestCase(unittest.TestCase):
class BadIterator(object):
def __iter__(self):
return self
- def next(self):
- del BadIterator.next
+ def __next__(self):
+ del BadIterator.__next__
return 1
try:
diff --git a/Lib/test/test_iterlen.py b/Lib/test/test_iterlen.py
index 88f43c7ffbc..7469a319f7a 100644
--- a/Lib/test/test_iterlen.py
+++ b/Lib/test/test_iterlen.py
@@ -9,14 +9,14 @@ The desired invariant is: len(it)==len(list(it)).
A complication is that an iterable and iterator can be the same object. To
maintain the invariant, an iterator needs to dynamically update its length.
-For instance, an iterable such as xrange(10) always reports its length as ten,
-but it=iter(xrange(10)) starts at ten, and then goes to nine after it.next().
+For instance, an iterable such as range(10) always reports its length as ten,
+but it=iter(range(10)) starts at ten, and then goes to nine after next(it).
Having this capability means that map() can ignore the distinction between
map(func, iterable) and map(func, iter(iterable)).
When the iterable is immutable, the implementation can straight-forwardly
report the original length minus the cumulative number of calls to next().
-This is the case for tuples, xrange objects, and itertools.repeat().
+This is the case for tuples, range objects, and itertools.repeat().
Some containers become temporarily immutable during iteration. This includes
dicts, sets, and collections.deque. Their implementation is equally simple
@@ -42,10 +42,10 @@ enumerate(iter('abc')).
"""
import unittest
-from test import test_support
+from test import support
from itertools import repeat
from collections import deque
-from __builtin__ import len as _len
+from builtins import len as _len
n = 10
@@ -64,11 +64,11 @@ class TestInvariantWithoutMutations(unittest.TestCase):
def test_invariant(self):
it = self.it
- for i in reversed(xrange(1, n+1)):
+ for i in reversed(range(1, n+1)):
self.assertEqual(len(it), i)
- it.next()
+ next(it)
self.assertEqual(len(it), 0)
- self.assertRaises(StopIteration, it.next)
+ self.assertRaises(StopIteration, next, it)
self.assertEqual(len(it), 0)
class TestTemporarilyImmutable(TestInvariantWithoutMutations):
@@ -79,10 +79,10 @@ class TestTemporarilyImmutable(TestInvariantWithoutMutations):
it = self.it
self.assertEqual(len(it), n)
- it.next()
+ next(it)
self.assertEqual(len(it), n-1)
self.mutate()
- self.assertRaises(RuntimeError, it.next)
+ self.assertRaises(RuntimeError, next, it)
self.assertEqual(len(it), 0)
## ------- Concrete Type Tests -------
@@ -99,59 +99,59 @@ class TestRepeat(TestInvariantWithoutMutations):
class TestXrange(TestInvariantWithoutMutations):
def setUp(self):
- self.it = iter(xrange(n))
+ self.it = iter(range(n))
class TestXrangeCustomReversed(TestInvariantWithoutMutations):
def setUp(self):
- self.it = reversed(xrange(n))
+ self.it = reversed(range(n))
class TestTuple(TestInvariantWithoutMutations):
def setUp(self):
- self.it = iter(tuple(xrange(n)))
+ self.it = iter(tuple(range(n)))
## ------- Types that should not be mutated during iteration -------
class TestDeque(TestTemporarilyImmutable):
def setUp(self):
- d = deque(xrange(n))
+ d = deque(range(n))
self.it = iter(d)
self.mutate = d.pop
class TestDequeReversed(TestTemporarilyImmutable):
def setUp(self):
- d = deque(xrange(n))
+ d = deque(range(n))
self.it = reversed(d)
self.mutate = d.pop
class TestDictKeys(TestTemporarilyImmutable):
def setUp(self):
- d = dict.fromkeys(xrange(n))
+ d = dict.fromkeys(range(n))
self.it = iter(d)
self.mutate = d.popitem
class TestDictItems(TestTemporarilyImmutable):
def setUp(self):
- d = dict.fromkeys(xrange(n))
- self.it = d.iteritems()
+ d = dict.fromkeys(range(n))
+ self.it = iter(d.items())
self.mutate = d.popitem
class TestDictValues(TestTemporarilyImmutable):
def setUp(self):
- d = dict.fromkeys(xrange(n))
- self.it = d.itervalues()
+ d = dict.fromkeys(range(n))
+ self.it = iter(d.values())
self.mutate = d.popitem
class TestSet(TestTemporarilyImmutable):
def setUp(self):
- d = set(xrange(n))
+ d = set(range(n))
self.it = iter(d)
self.mutate = d.pop
@@ -163,17 +163,17 @@ class TestList(TestInvariantWithoutMutations):
self.it = iter(range(n))
def test_mutation(self):
- d = range(n)
+ d = list(range(n))
it = iter(d)
- it.next()
- it.next()
+ next(it)
+ next(it)
self.assertEqual(len(it), n-2)
d.append(n)
self.assertEqual(len(it), n-1) # grow with append
d[1:] = []
self.assertEqual(len(it), 0)
self.assertEqual(list(it), [])
- d.extend(xrange(20))
+ d.extend(range(20))
self.assertEqual(len(it), 0)
class TestListReversed(TestInvariantWithoutMutations):
@@ -182,17 +182,17 @@ class TestListReversed(TestInvariantWithoutMutations):
self.it = reversed(range(n))
def test_mutation(self):
- d = range(n)
+ d = list(range(n))
it = reversed(d)
- it.next()
- it.next()
+ next(it)
+ next(it)
self.assertEqual(len(it), n-2)
d.append(n)
self.assertEqual(len(it), n-2) # ignore append
d[1:] = []
self.assertEqual(len(it), 0)
self.assertEqual(list(it), []) # confirm invariant
- d.extend(xrange(20))
+ d.extend(range(20))
self.assertEqual(len(it), 0)
## -- Check to make sure exceptions are not suppressed by __length_hint__()
@@ -220,12 +220,6 @@ class TestLengthHintExceptions(unittest.TestCase):
self.assertRaises(RuntimeError, list, BadLengthHint())
self.assertRaises(RuntimeError, [].extend, BadLen())
self.assertRaises(RuntimeError, [].extend, BadLengthHint())
- self.assertRaises(RuntimeError, zip, BadLen())
- self.assertRaises(RuntimeError, zip, BadLengthHint())
- self.assertRaises(RuntimeError, filter, None, BadLen())
- self.assertRaises(RuntimeError, filter, None, BadLengthHint())
- self.assertRaises(RuntimeError, map, chr, BadLen())
- self.assertRaises(RuntimeError, map, chr, BadLengthHint())
b = bytearray(range(10))
self.assertRaises(RuntimeError, b.extend, BadLen())
self.assertRaises(RuntimeError, b.extend, BadLengthHint())
@@ -251,7 +245,7 @@ def test_main():
TestListReversed,
TestLengthHintExceptions,
]
- test_support.run_unittest(*unittests)
+ support.run_unittest(*unittests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py
index ccdbf8abcbf..8cdc597e58b 100644
--- a/Lib/test/test_itertools.py
+++ b/Lib/test/test_itertools.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support
+from test import support
from itertools import *
from weakref import proxy
from decimal import Decimal
@@ -10,9 +10,12 @@ import random
import copy
import pickle
from functools import reduce
-maxsize = test_support.MAX_Py_ssize_t
+maxsize = support.MAX_Py_ssize_t
minsize = -maxsize-1
+def lzip(*args):
+ return list(zip(*args))
+
def onearg(x):
'Test function of one argument'
return 2*x
@@ -38,7 +41,7 @@ class StopNow:
'Class emulating an empty iterable.'
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
def take(n, seq):
@@ -53,6 +56,24 @@ def fact(n):
return prod(range(1, n+1))
class TestBasicOps(unittest.TestCase):
+
+ def test_accumulate(self):
+ self.assertEqual(list(accumulate(range(10))), # one positional arg
+ [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+ self.assertEqual(list(accumulate(iterable=range(10))), # kw arg
+ [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])
+ for typ in int, complex, Decimal, Fraction: # multiple types
+ self.assertEqual(
+ list(accumulate(map(typ, range(10)))),
+ list(map(typ, [0, 1, 3, 6, 10, 15, 21, 28, 36, 45])))
+ self.assertEqual(list(accumulate('abc')), ['a', 'ab', 'abc']) # works with non-numeric
+ self.assertEqual(list(accumulate([])), []) # empty iterable
+ self.assertEqual(list(accumulate([7])), [7]) # iterable of length one
+ self.assertRaises(TypeError, accumulate, range(10), 5) # too many args
+ self.assertRaises(TypeError, accumulate) # too few args
+ self.assertRaises(TypeError, accumulate, x=range(10)) # unexpected kwd arg
+ self.assertRaises(TypeError, list, accumulate([1, []])) # args that don't add
+
def test_chain(self):
def chain2(*iterables):
@@ -90,7 +111,7 @@ class TestBasicOps(unittest.TestCase):
n = len(pool)
if r > n:
return
- indices = range(r)
+ indices = list(range(r))
yield tuple(pool[i] for i in indices)
while 1:
for i in reversed(range(r)):
@@ -123,7 +144,7 @@ class TestBasicOps(unittest.TestCase):
values = [5*x-12 for x in range(n)]
for r in range(n+2):
result = list(combinations(values, r))
- self.assertEqual(len(result), 0 if r>n else fact(n) // fact(r) // fact(n-r)) # right number of combs
+ self.assertEqual(len(result), 0 if r>n else fact(n) / fact(r) / fact(n-r)) # right number of combs
self.assertEqual(len(result), len(set(result))) # no repeats
self.assertEqual(result, sorted(result)) # lexicographic order
for c in result:
@@ -137,8 +158,7 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(result, list(combinations2(values, r))) # matches second pure python version
self.assertEqual(result, list(combinations3(values, r))) # matches second pure python version
- @test_support.impl_detail("tuple reuse is specific to CPython")
- def test_combinations_tuple_reuse(self):
+ # Test implementation detail: tuple re-use
self.assertEqual(len(set(map(id, combinations('abcde', 3)))), 1)
self.assertNotEqual(len(set(map(id, list(combinations('abcde', 3))))), 1)
@@ -180,7 +200,7 @@ class TestBasicOps(unittest.TestCase):
def numcombs(n, r):
if not n:
return 0 if r else 1
- return fact(n+r-1) // fact(r) // fact(n-1)
+ return fact(n+r-1) / fact(r)/ fact(n-1)
for n in range(7):
values = [5*x-12 for x in range(n)]
@@ -208,9 +228,7 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(result, list(cwr1(values, r))) # matches first pure python version
self.assertEqual(result, list(cwr2(values, r))) # matches second pure python version
- @test_support.impl_detail("tuple reuse is specific to CPython")
- def test_combinations_with_replacement_tuple_reuse(self):
- cwr = combinations_with_replacement
+ # Test implementation detail: tuple re-use
self.assertEqual(len(set(map(id, cwr('abcde', 3)))), 1)
self.assertNotEqual(len(set(map(id, list(cwr('abcde', 3))))), 1)
@@ -231,8 +249,8 @@ class TestBasicOps(unittest.TestCase):
r = n if r is None else r
if r > n:
return
- indices = range(n)
- cycles = range(n, n-r, -1)
+ indices = list(range(n))
+ cycles = list(range(n-r+1, n+1))[::-1]
yield tuple(pool[i] for i in indices[:r])
while n:
for i in reversed(range(r)):
@@ -261,7 +279,7 @@ class TestBasicOps(unittest.TestCase):
values = [5*x-12 for x in range(n)]
for r in range(n+2):
result = list(permutations(values, r))
- self.assertEqual(len(result), 0 if r>n else fact(n) // fact(n-r)) # right number of perms
+ self.assertEqual(len(result), 0 if r>n else fact(n) / fact(n-r)) # right number of perms
self.assertEqual(len(result), len(set(result))) # no repeats
self.assertEqual(result, sorted(result)) # lexicographic order
for p in result:
@@ -274,8 +292,7 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(result, list(permutations(values, None))) # test r as None
self.assertEqual(result, list(permutations(values))) # test default r
- @test_support.impl_detail("tuple resuse is CPython specific")
- def test_permutations_tuple_reuse(self):
+ # Test implementation detail: tuple re-use
self.assertEqual(len(set(map(id, permutations('abcde', 3)))), 1)
self.assertNotEqual(len(set(map(id, list(permutations('abcde', 3))))), 1)
@@ -293,9 +310,9 @@ class TestBasicOps(unittest.TestCase):
# Check size
self.assertEqual(len(prod), n**r)
- self.assertEqual(len(cwr), (fact(n+r-1) // fact(r) // fact(n-1)) if n else (not r))
- self.assertEqual(len(perm), 0 if r>n else fact(n) // fact(n-r))
- self.assertEqual(len(comb), 0 if r>n else fact(n) // fact(r) // fact(n-r))
+ self.assertEqual(len(cwr), (fact(n+r-1) / fact(r)/ fact(n-1)) if n else (not r))
+ self.assertEqual(len(perm), 0 if r>n else fact(n) / fact(n-r))
+ self.assertEqual(len(comb), 0 if r>n else fact(n) / fact(r) / fact(n-r))
# Check lexicographic order without repeated tuples
self.assertEqual(prod, sorted(set(prod)))
@@ -308,8 +325,8 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(perm, [t for t in prod if len(set(t))==r]) # perm: prods with no dups
self.assertEqual(comb, [t for t in perm if sorted(t)==list(t)]) # comb: perms that are sorted
self.assertEqual(comb, [t for t in cwr if len(set(t))==r]) # comb: cwrs without dups
- self.assertEqual(comb, filter(set(cwr).__contains__, perm)) # comb: perm that is a cwr
- self.assertEqual(comb, filter(set(perm).__contains__, cwr)) # comb: cwr that is a perm
+ self.assertEqual(comb, list(filter(set(cwr).__contains__, perm))) # comb: perm that is a cwr
+ self.assertEqual(comb, list(filter(set(perm).__contains__, cwr))) # comb: cwr that is a perm
self.assertEqual(comb, sorted(set(cwr) & set(perm))) # comb: both a cwr and a perm
def test_compress(self):
@@ -329,45 +346,53 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, compress, range(6), None) # too many args
def test_count(self):
- self.assertEqual(zip('abc',count()), [('a', 0), ('b', 1), ('c', 2)])
- self.assertEqual(zip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)])
- self.assertEqual(take(2, zip('abc',count(3))), [('a', 3), ('b', 4)])
+ self.assertEqual(lzip('abc',count()), [('a', 0), ('b', 1), ('c', 2)])
+ self.assertEqual(lzip('abc',count(3)), [('a', 3), ('b', 4), ('c', 5)])
+ self.assertEqual(take(2, lzip('abc',count(3))), [('a', 3), ('b', 4)])
self.assertEqual(take(2, zip('abc',count(-1))), [('a', -1), ('b', 0)])
self.assertEqual(take(2, zip('abc',count(-3))), [('a', -3), ('b', -2)])
self.assertRaises(TypeError, count, 2, 3, 4)
self.assertRaises(TypeError, count, 'a')
- self.assertEqual(list(islice(count(maxsize-5), 10)), range(maxsize-5, maxsize+5))
- self.assertEqual(list(islice(count(-maxsize-5), 10)), range(-maxsize-5, -maxsize+5))
+ self.assertEqual(list(islice(count(maxsize-5), 10)),
+ list(range(maxsize-5, maxsize+5)))
+ self.assertEqual(list(islice(count(-maxsize-5), 10)),
+ list(range(-maxsize-5, -maxsize+5)))
+ self.assertEqual(list(islice(count(10, maxsize+5), 3)),
+ list(range(10, 10+3*(maxsize+5), maxsize+5)))
c = count(3)
self.assertEqual(repr(c), 'count(3)')
- c.next()
+ next(c)
self.assertEqual(repr(c), 'count(4)')
c = count(-9)
self.assertEqual(repr(c), 'count(-9)')
- c.next()
+ next(c)
self.assertEqual(repr(count(10.25)), 'count(10.25)')
- self.assertEqual(c.next(), -8)
- for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5):
+ self.assertEqual(next(c), -8)
+ for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5):
# Test repr (ignoring the L in longs)
r1 = repr(count(i)).replace('L', '')
r2 = 'count(%r)'.__mod__(i).replace('L', '')
self.assertEqual(r1, r2)
# check copy, deepcopy, pickle
- for value in -3, 3, sys.maxint-5, sys.maxint+5:
+ for value in -3, 3, maxsize-5, maxsize+5:
c = count(value)
self.assertEqual(next(copy.copy(c)), value)
self.assertEqual(next(copy.deepcopy(c)), value)
self.assertEqual(next(pickle.loads(pickle.dumps(c))), value)
+ #check proper internal error handling for large "step' sizes
+ count(1, maxsize+5); sys.exc_info()
+
def test_count_with_stride(self):
- self.assertEqual(zip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)])
- self.assertEqual(zip('abc',count(start=2,step=3)),
+ self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)])
+ self.assertEqual(lzip('abc',count(start=2,step=3)),
[('a', 2), ('b', 5), ('c', 8)])
- self.assertEqual(zip('abc',count(step=-1)),
+ self.assertEqual(lzip('abc',count(step=-1)),
[('a', 0), ('b', -1), ('c', -2)])
- self.assertEqual(zip('abc',count(2,0)), [('a', 2), ('b', 2), ('c', 2)])
- self.assertEqual(zip('abc',count(2,1)), [('a', 2), ('b', 3), ('c', 4)])
+ self.assertEqual(lzip('abc',count(2,0)), [('a', 2), ('b', 2), ('c', 2)])
+ self.assertEqual(lzip('abc',count(2,1)), [('a', 2), ('b', 3), ('c', 4)])
+ self.assertEqual(lzip('abc',count(2,3)), [('a', 2), ('b', 5), ('c', 8)])
self.assertEqual(take(20, count(maxsize-15, 3)), take(20, range(maxsize-15, maxsize+100, 3)))
self.assertEqual(take(20, count(-maxsize-15, 3)), take(20, range(-maxsize-15,-maxsize+100, 3)))
self.assertEqual(take(3, count(2, 3.25-4j)), [2, 5.25-4j, 8.5-8j])
@@ -378,22 +403,22 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(repr(take(3, count(10, 2.5))), repr([10, 12.5, 15.0]))
c = count(3, 5)
self.assertEqual(repr(c), 'count(3, 5)')
- c.next()
+ next(c)
self.assertEqual(repr(c), 'count(8, 5)')
c = count(-9, 0)
self.assertEqual(repr(c), 'count(-9, 0)')
- c.next()
+ next(c)
self.assertEqual(repr(c), 'count(-9, 0)')
c = count(-9, -3)
self.assertEqual(repr(c), 'count(-9, -3)')
- c.next()
+ next(c)
self.assertEqual(repr(c), 'count(-12, -3)')
self.assertEqual(repr(c), 'count(-12, -3)')
self.assertEqual(repr(count(10.5, 1.25)), 'count(10.5, 1.25)')
self.assertEqual(repr(count(10.5, 1)), 'count(10.5)') # suppress step=1 when it's an int
self.assertEqual(repr(count(10.5, 1.00)), 'count(10.5, 1.0)') # do show float values lilke 1.0
- for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5):
- for j in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 1, 10, sys.maxint-5, sys.maxint+5):
+ for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5):
+ for j in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 1, 10, sys.maxsize-5, sys.maxsize+5):
# Test repr (ignoring the L in longs)
r1 = repr(count(i, j)).replace('L', '')
if j == 1:
@@ -458,7 +483,7 @@ class TestBasicOps(unittest.TestCase):
r = sorted([(len(list(g)) , k) for k, g in groupby(sorted(s))], reverse=True)[:3]
self.assertEqual(r, [(5, 'a'), (2, 'r'), (2, 'b')])
- # iter.next failure
+ # iter.__next__ failure
class ExpectedError(Exception):
pass
def delayed_raise(n=0):
@@ -468,20 +493,20 @@ class TestBasicOps(unittest.TestCase):
def gulp(iterable, keyp=None, func=list):
return [func(g) for k, g in groupby(iterable, keyp)]
- # iter.next failure on outer object
+ # iter.__next__ failure on outer object
self.assertRaises(ExpectedError, gulp, delayed_raise(0))
- # iter.next failure on inner object
+ # iter.__next__ failure on inner object
self.assertRaises(ExpectedError, gulp, delayed_raise(1))
# __cmp__ failure
class DummyCmp:
- def __cmp__(self, dst):
+ def __eq__(self, dst):
raise ExpectedError
s = [DummyCmp(), DummyCmp(), None]
- # __cmp__ failure on outer object
+ # __eq__ failure on outer object
self.assertRaises(ExpectedError, gulp, s, func=id)
- # __cmp__ failure on inner object
+ # __eq__ failure on inner object
self.assertRaises(ExpectedError, gulp, s)
# keyfunc failure
@@ -498,51 +523,50 @@ class TestBasicOps(unittest.TestCase):
keyfunc.skip = 1
self.assertRaises(ExpectedError, gulp, [None, None], keyfunc)
- def test_ifilter(self):
- self.assertEqual(list(ifilter(isEven, range(6))), [0,2,4])
- self.assertEqual(list(ifilter(None, [0,1,0,2,0])), [1,2])
- self.assertEqual(list(ifilter(bool, [0,1,0,2,0])), [1,2])
- self.assertEqual(take(4, ifilter(isEven, count())), [0,2,4,6])
- self.assertRaises(TypeError, ifilter)
- self.assertRaises(TypeError, ifilter, lambda x:x)
- self.assertRaises(TypeError, ifilter, lambda x:x, range(6), 7)
- self.assertRaises(TypeError, ifilter, isEven, 3)
- self.assertRaises(TypeError, ifilter(range(6), range(6)).next)
-
- def test_ifilterfalse(self):
- self.assertEqual(list(ifilterfalse(isEven, range(6))), [1,3,5])
- self.assertEqual(list(ifilterfalse(None, [0,1,0,2,0])), [0,0,0])
- self.assertEqual(list(ifilterfalse(bool, [0,1,0,2,0])), [0,0,0])
- self.assertEqual(take(4, ifilterfalse(isEven, count())), [1,3,5,7])
- self.assertRaises(TypeError, ifilterfalse)
- self.assertRaises(TypeError, ifilterfalse, lambda x:x)
- self.assertRaises(TypeError, ifilterfalse, lambda x:x, range(6), 7)
- self.assertRaises(TypeError, ifilterfalse, isEven, 3)
- self.assertRaises(TypeError, ifilterfalse(range(6), range(6)).next)
-
- def test_izip(self):
- ans = [(x,y) for x, y in izip('abc',count())]
+ def test_filter(self):
+ self.assertEqual(list(filter(isEven, range(6))), [0,2,4])
+ self.assertEqual(list(filter(None, [0,1,0,2,0])), [1,2])
+ self.assertEqual(list(filter(bool, [0,1,0,2,0])), [1,2])
+ self.assertEqual(take(4, filter(isEven, count())), [0,2,4,6])
+ self.assertRaises(TypeError, filter)
+ self.assertRaises(TypeError, filter, lambda x:x)
+ self.assertRaises(TypeError, filter, lambda x:x, range(6), 7)
+ self.assertRaises(TypeError, filter, isEven, 3)
+ self.assertRaises(TypeError, next, filter(range(6), range(6)))
+
+ def test_filterfalse(self):
+ self.assertEqual(list(filterfalse(isEven, range(6))), [1,3,5])
+ self.assertEqual(list(filterfalse(None, [0,1,0,2,0])), [0,0,0])
+ self.assertEqual(list(filterfalse(bool, [0,1,0,2,0])), [0,0,0])
+ self.assertEqual(take(4, filterfalse(isEven, count())), [1,3,5,7])
+ self.assertRaises(TypeError, filterfalse)
+ self.assertRaises(TypeError, filterfalse, lambda x:x)
+ self.assertRaises(TypeError, filterfalse, lambda x:x, range(6), 7)
+ self.assertRaises(TypeError, filterfalse, isEven, 3)
+ self.assertRaises(TypeError, next, filterfalse(range(6), range(6)))
+
+ def test_zip(self):
+ # XXX This is rather silly now that builtin zip() calls zip()...
+ ans = [(x,y) for x, y in zip('abc',count())]
self.assertEqual(ans, [('a', 0), ('b', 1), ('c', 2)])
- self.assertEqual(list(izip('abc', range(6))), zip('abc', range(6)))
- self.assertEqual(list(izip('abcdef', range(3))), zip('abcdef', range(3)))
- self.assertEqual(take(3,izip('abcdef', count())), zip('abcdef', range(3)))
- self.assertEqual(list(izip('abcdef')), zip('abcdef'))
- self.assertEqual(list(izip()), zip())
- self.assertRaises(TypeError, izip, 3)
- self.assertRaises(TypeError, izip, range(3), 3)
- self.assertEqual([tuple(list(pair)) for pair in izip('abc', 'def')],
- zip('abc', 'def'))
- self.assertEqual([pair for pair in izip('abc', 'def')],
- zip('abc', 'def'))
-
- @test_support.impl_detail("tuple reuse is specific to CPython")
- def test_izip_tuple_resuse(self):
- ids = map(id, izip('abc', 'def'))
+ self.assertEqual(list(zip('abc', range(6))), lzip('abc', range(6)))
+ self.assertEqual(list(zip('abcdef', range(3))), lzip('abcdef', range(3)))
+ self.assertEqual(take(3,zip('abcdef', count())), lzip('abcdef', range(3)))
+ self.assertEqual(list(zip('abcdef')), lzip('abcdef'))
+ self.assertEqual(list(zip()), lzip())
+ self.assertRaises(TypeError, zip, 3)
+ self.assertRaises(TypeError, zip, range(3), 3)
+ # Check tuple re-use (implementation detail)
+ self.assertEqual([tuple(list(pair)) for pair in zip('abc', 'def')],
+ lzip('abc', 'def'))
+ self.assertEqual([pair for pair in zip('abc', 'def')],
+ lzip('abc', 'def'))
+ ids = list(map(id, zip('abc', 'def')))
self.assertEqual(min(ids), max(ids))
- ids = map(id, list(izip('abc', 'def')))
+ ids = list(map(id, list(zip('abc', 'def'))))
self.assertEqual(len(dict.fromkeys(ids)), len(ids))
- def test_iziplongest(self):
+ def test_ziplongest(self):
for args in [
['abc', range(6)],
[range(6), 'abc'],
@@ -550,29 +574,27 @@ class TestBasicOps(unittest.TestCase):
[range(1000), range(0), range(3000,3050), range(1200), range(1500)],
[range(1000), range(0), range(3000,3050), range(1200), range(1500), range(0)],
]:
- # target = map(None, *args) <- this raises a py3k warning
- # this is the replacement:
target = [tuple([arg[i] if i < len(arg) else None for arg in args])
for i in range(max(map(len, args)))]
- self.assertEqual(list(izip_longest(*args)), target)
- self.assertEqual(list(izip_longest(*args, **{})), target)
+ self.assertEqual(list(zip_longest(*args)), target)
+ self.assertEqual(list(zip_longest(*args, **{})), target)
target = [tuple((e is None and 'X' or e) for e in t) for t in target] # Replace None fills with 'X'
- self.assertEqual(list(izip_longest(*args, **dict(fillvalue='X'))), target)
+ self.assertEqual(list(zip_longest(*args, **dict(fillvalue='X'))), target)
- self.assertEqual(take(3,izip_longest('abcdef', count())), zip('abcdef', range(3))) # take 3 from infinite input
+ self.assertEqual(take(3,zip_longest('abcdef', count())), list(zip('abcdef', range(3)))) # take 3 from infinite input
- self.assertEqual(list(izip_longest()), zip())
- self.assertEqual(list(izip_longest([])), zip([]))
- self.assertEqual(list(izip_longest('abcdef')), zip('abcdef'))
+ self.assertEqual(list(zip_longest()), list(zip()))
+ self.assertEqual(list(zip_longest([])), list(zip([])))
+ self.assertEqual(list(zip_longest('abcdef')), list(zip('abcdef')))
- self.assertEqual(list(izip_longest('abc', 'defg', **{})),
- zip(list('abc') + [None], 'defg')) # empty keyword dict
- self.assertRaises(TypeError, izip_longest, 3)
- self.assertRaises(TypeError, izip_longest, range(3), 3)
+ self.assertEqual(list(zip_longest('abc', 'defg', **{})),
+ list(zip(list('abc')+[None], 'defg'))) # empty keyword dict
+ self.assertRaises(TypeError, zip_longest, 3)
+ self.assertRaises(TypeError, zip_longest, range(3), 3)
for stmt in [
- "izip_longest('abc', fv=1)",
- "izip_longest('abc', fillvalue=1, bogus_keyword=None)",
+ "zip_longest('abc', fv=1)",
+ "zip_longest('abc', fillvalue=1, bogus_keyword=None)",
]:
try:
eval(stmt, globals(), locals())
@@ -581,21 +603,19 @@ class TestBasicOps(unittest.TestCase):
else:
self.fail('Did not raise Type in: ' + stmt)
- self.assertEqual([tuple(list(pair)) for pair in izip_longest('abc', 'def')],
- zip('abc', 'def'))
- self.assertEqual([pair for pair in izip_longest('abc', 'def')],
- zip('abc', 'def'))
-
- @test_support.impl_detail("tuple reuse is specific to CPython")
- def test_izip_longest_tuple_reuse(self):
- ids = map(id, izip_longest('abc', 'def'))
+ # Check tuple re-use (implementation detail)
+ self.assertEqual([tuple(list(pair)) for pair in zip_longest('abc', 'def')],
+ list(zip('abc', 'def')))
+ self.assertEqual([pair for pair in zip_longest('abc', 'def')],
+ list(zip('abc', 'def')))
+ ids = list(map(id, zip_longest('abc', 'def')))
self.assertEqual(min(ids), max(ids))
- ids = map(id, list(izip_longest('abc', 'def')))
+ ids = list(map(id, list(zip_longest('abc', 'def'))))
self.assertEqual(len(dict.fromkeys(ids)), len(ids))
def test_bug_7244(self):
- class Repeater(object):
+ class Repeater:
# this class is similar to itertools.repeat
def __init__(self, o, t, e):
self.o = o
@@ -603,7 +623,7 @@ class TestBasicOps(unittest.TestCase):
self.e = e
def __iter__(self): # its iterator is itself
return self
- def next(self):
+ def __next__(self):
if self.t > 0:
self.t -= 1
return self.o
@@ -616,9 +636,9 @@ class TestBasicOps(unittest.TestCase):
r2 = Repeater(2, 4, StopIteration)
def run(r1, r2):
result = []
- for i, j in izip_longest(r1, r2, fillvalue=0):
- with test_support.captured_output('stdout'):
- print (i, j)
+ for i, j in zip_longest(r1, r2, fillvalue=0):
+ with support.captured_output('stdout'):
+ print((i, j))
result.append((i, j))
return result
self.assertEqual(run(r1, r2), [(1,2), (1,2), (1,2), (0,2)])
@@ -627,7 +647,7 @@ class TestBasicOps(unittest.TestCase):
# and StopIteration would stop as expected
r1 = Repeater(1, 3, RuntimeError)
r2 = Repeater(2, 4, StopIteration)
- it = izip_longest(r1, r2, fillvalue=0)
+ it = zip_longest(r1, r2, fillvalue=0)
self.assertEqual(next(it), (1, 2))
self.assertEqual(next(it), (1, 2))
self.assertEqual(next(it), (1, 2))
@@ -650,7 +670,7 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, product, range(6), None)
def product1(*args, **kwds):
- pools = map(tuple, args) * kwds.get('repeat', 1)
+ pools = list(map(tuple, args)) * kwds.get('repeat', 1)
n = len(pools)
if n == 0:
yield ()
@@ -673,14 +693,14 @@ class TestBasicOps(unittest.TestCase):
def product2(*args, **kwds):
'Pure python version used in docs'
- pools = map(tuple, args) * kwds.get('repeat', 1)
+ pools = list(map(tuple, args)) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
result = [x+[y] for x in result for y in pool]
for prod in result:
yield tuple(prod)
- argtypes = ['', 'abc', '', xrange(0), xrange(4), dict(a=1, b=2, c=3),
+ argtypes = ['', 'abc', '', range(0), range(4), dict(a=1, b=2, c=3),
set('abcdefg'), range(11), tuple(range(13))]
for i in range(100):
args = [random.choice(argtypes) for j in range(random.randrange(5))]
@@ -691,14 +711,13 @@ class TestBasicOps(unittest.TestCase):
args = map(iter, args)
self.assertEqual(len(list(product(*args))), expected_len)
- @test_support.impl_detail("tuple reuse is specific to CPython")
- def test_product_tuple_reuse(self):
+ # Test implementation detail: tuple re-use
self.assertEqual(len(set(map(id, product('abc', 'def')))), 1)
self.assertNotEqual(len(set(map(id, list(product('abc', 'def'))))), 1)
def test_repeat(self):
self.assertEqual(list(repeat(object='a', times=3)), ['a', 'a', 'a'])
- self.assertEqual(zip(xrange(3),repeat('a')),
+ self.assertEqual(lzip(range(3),repeat('a')),
[(0, 'a'), (1, 'a'), (2, 'a')])
self.assertEqual(list(repeat('a', 3)), ['a', 'a', 'a'])
self.assertEqual(take(3, repeat('a')), ['a', 'a', 'a'])
@@ -714,35 +733,38 @@ class TestBasicOps(unittest.TestCase):
list(r)
self.assertEqual(repr(r), 'repeat((1+0j), 0)')
- def test_imap(self):
- self.assertEqual(list(imap(operator.pow, range(3), range(1,7))),
+ def test_map(self):
+ self.assertEqual(list(map(operator.pow, range(3), range(1,7))),
[0**1, 1**2, 2**3])
- self.assertEqual(list(imap(None, 'abc', range(5))),
+ def tupleize(*args):
+ return args
+ self.assertEqual(list(map(tupleize, 'abc', range(5))),
[('a',0),('b',1),('c',2)])
- self.assertEqual(list(imap(None, 'abc', count())),
+ self.assertEqual(list(map(tupleize, 'abc', count())),
[('a',0),('b',1),('c',2)])
- self.assertEqual(take(2,imap(None, 'abc', count())),
+ self.assertEqual(take(2,map(tupleize, 'abc', count())),
[('a',0),('b',1)])
- self.assertEqual(list(imap(operator.pow, [])), [])
- self.assertRaises(TypeError, imap)
- self.assertRaises(TypeError, imap, operator.neg)
- self.assertRaises(TypeError, imap(10, range(5)).next)
- self.assertRaises(ValueError, imap(errfunc, [4], [5]).next)
- self.assertRaises(TypeError, imap(onearg, [4], [5]).next)
+ self.assertEqual(list(map(operator.pow, [])), [])
+ self.assertRaises(TypeError, map)
+ self.assertRaises(TypeError, list, map(None, range(3), range(3)))
+ self.assertRaises(TypeError, map, operator.neg)
+ self.assertRaises(TypeError, next, map(10, range(5)))
+ self.assertRaises(ValueError, next, map(errfunc, [4], [5]))
+ self.assertRaises(TypeError, next, map(onearg, [4], [5]))
def test_starmap(self):
self.assertEqual(list(starmap(operator.pow, zip(range(3), range(1,7)))),
[0**1, 1**2, 2**3])
- self.assertEqual(take(3, starmap(operator.pow, izip(count(), count(1)))),
+ self.assertEqual(take(3, starmap(operator.pow, zip(count(), count(1)))),
[0**1, 1**2, 2**3])
self.assertEqual(list(starmap(operator.pow, [])), [])
self.assertEqual(list(starmap(operator.pow, [iter([4,5])])), [4**5])
self.assertRaises(TypeError, list, starmap(operator.pow, [None]))
self.assertRaises(TypeError, starmap)
self.assertRaises(TypeError, starmap, operator.pow, [(4,5)], 'extra')
- self.assertRaises(TypeError, starmap(10, [(4,5)]).next)
- self.assertRaises(ValueError, starmap(errfunc, [(4,5)]).next)
- self.assertRaises(TypeError, starmap(onearg, [(4,5)]).next)
+ self.assertRaises(TypeError, next, starmap(10, [(4,5)]))
+ self.assertRaises(ValueError, next, starmap(errfunc, [(4,5)]))
+ self.assertRaises(TypeError, next, starmap(onearg, [(4,5)]))
def test_islice(self):
for args in [ # islice(args) should agree with range(args)
@@ -752,39 +774,41 @@ class TestBasicOps(unittest.TestCase):
(10, 3),
(20,)
]:
- self.assertEqual(list(islice(xrange(100), *args)), range(*args))
+ self.assertEqual(list(islice(range(100), *args)),
+ list(range(*args)))
for args, tgtargs in [ # Stop when seqn is exhausted
((10, 110, 3), ((10, 100, 3))),
((10, 110), ((10, 100))),
((110,), (100,))
]:
- self.assertEqual(list(islice(xrange(100), *args)), range(*tgtargs))
+ self.assertEqual(list(islice(range(100), *args)),
+ list(range(*tgtargs)))
# Test stop=None
- self.assertEqual(list(islice(xrange(10), None)), range(10))
- self.assertEqual(list(islice(xrange(10), None, None)), range(10))
- self.assertEqual(list(islice(xrange(10), None, None, None)), range(10))
- self.assertEqual(list(islice(xrange(10), 2, None)), range(2, 10))
- self.assertEqual(list(islice(xrange(10), 1, None, 2)), range(1, 10, 2))
+ self.assertEqual(list(islice(range(10), None)), list(range(10)))
+ self.assertEqual(list(islice(range(10), None, None)), list(range(10)))
+ self.assertEqual(list(islice(range(10), None, None, None)), list(range(10)))
+ self.assertEqual(list(islice(range(10), 2, None)), list(range(2, 10)))
+ self.assertEqual(list(islice(range(10), 1, None, 2)), list(range(1, 10, 2)))
# Test number of items consumed SF #1171417
it = iter(range(10))
- self.assertEqual(list(islice(it, 3)), range(3))
- self.assertEqual(list(it), range(3, 10))
+ self.assertEqual(list(islice(it, 3)), list(range(3)))
+ self.assertEqual(list(it), list(range(3, 10)))
# Test invalid arguments
- self.assertRaises(TypeError, islice, xrange(10))
- self.assertRaises(TypeError, islice, xrange(10), 1, 2, 3, 4)
- self.assertRaises(ValueError, islice, xrange(10), -5, 10, 1)
- self.assertRaises(ValueError, islice, xrange(10), 1, -5, -1)
- self.assertRaises(ValueError, islice, xrange(10), 1, 10, -1)
- self.assertRaises(ValueError, islice, xrange(10), 1, 10, 0)
- self.assertRaises(ValueError, islice, xrange(10), 'a')
- self.assertRaises(ValueError, islice, xrange(10), 'a', 1)
- self.assertRaises(ValueError, islice, xrange(10), 1, 'a')
- self.assertRaises(ValueError, islice, xrange(10), 'a', 1, 1)
- self.assertRaises(ValueError, islice, xrange(10), 1, 'a', 1)
+ self.assertRaises(TypeError, islice, range(10))
+ self.assertRaises(TypeError, islice, range(10), 1, 2, 3, 4)
+ self.assertRaises(ValueError, islice, range(10), -5, 10, 1)
+ self.assertRaises(ValueError, islice, range(10), 1, -5, -1)
+ self.assertRaises(ValueError, islice, range(10), 1, 10, -1)
+ self.assertRaises(ValueError, islice, range(10), 1, 10, 0)
+ self.assertRaises(ValueError, islice, range(10), 'a')
+ self.assertRaises(ValueError, islice, range(10), 'a', 1)
+ self.assertRaises(ValueError, islice, range(10), 1, 'a')
+ self.assertRaises(ValueError, islice, range(10), 'a', 1, 1)
+ self.assertRaises(ValueError, islice, range(10), 1, 'a', 1)
self.assertEqual(len(list(islice(count(), 1, 10, maxsize))), 1)
# Issue #10323: Less islice in a predictable state
@@ -800,11 +824,11 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, takewhile)
self.assertRaises(TypeError, takewhile, operator.pow)
self.assertRaises(TypeError, takewhile, operator.pow, [(4,5)], 'extra')
- self.assertRaises(TypeError, takewhile(10, [(4,5)]).next)
- self.assertRaises(ValueError, takewhile(errfunc, [(4,5)]).next)
+ self.assertRaises(TypeError, next, takewhile(10, [(4,5)]))
+ self.assertRaises(ValueError, next, takewhile(errfunc, [(4,5)]))
t = takewhile(bool, [1, 1, 1, 0, 0, 0])
self.assertEqual(list(t), [1, 1, 1])
- self.assertRaises(StopIteration, t.next)
+ self.assertRaises(StopIteration, next, t)
def test_dropwhile(self):
data = [1, 3, 5, 20, 2, 4, 6, 8]
@@ -814,13 +838,13 @@ class TestBasicOps(unittest.TestCase):
self.assertRaises(TypeError, dropwhile)
self.assertRaises(TypeError, dropwhile, operator.pow)
self.assertRaises(TypeError, dropwhile, operator.pow, [(4,5)], 'extra')
- self.assertRaises(TypeError, dropwhile(10, [(4,5)]).next)
- self.assertRaises(ValueError, dropwhile(errfunc, [(4,5)]).next)
+ self.assertRaises(TypeError, next, dropwhile(10, [(4,5)]))
+ self.assertRaises(ValueError, next, dropwhile(errfunc, [(4,5)]))
def test_tee(self):
n = 200
def irange(n):
- for i in xrange(n):
+ for i in range(n):
yield i
a, b = tee([]) # test empty iterator
@@ -828,34 +852,34 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(list(b), [])
a, b = tee(irange(n)) # test 100% interleaved
- self.assertEqual(zip(a,b), zip(range(n),range(n)))
+ self.assertEqual(lzip(a,b), lzip(range(n), range(n)))
a, b = tee(irange(n)) # test 0% interleaved
- self.assertEqual(list(a), range(n))
- self.assertEqual(list(b), range(n))
+ self.assertEqual(list(a), list(range(n)))
+ self.assertEqual(list(b), list(range(n)))
a, b = tee(irange(n)) # test dealloc of leading iterator
- for i in xrange(100):
- self.assertEqual(a.next(), i)
+ for i in range(100):
+ self.assertEqual(next(a), i)
del a
- self.assertEqual(list(b), range(n))
+ self.assertEqual(list(b), list(range(n)))
a, b = tee(irange(n)) # test dealloc of trailing iterator
- for i in xrange(100):
- self.assertEqual(a.next(), i)
+ for i in range(100):
+ self.assertEqual(next(a), i)
del b
- self.assertEqual(list(a), range(100, n))
+ self.assertEqual(list(a), list(range(100, n)))
- for j in xrange(5): # test randomly interleaved
+ for j in range(5): # test randomly interleaved
order = [0]*n + [1]*n
random.shuffle(order)
lists = ([], [])
its = tee(irange(n))
for i in order:
- value = its[i].next()
+ value = next(its[i])
lists[i].append(value)
- self.assertEqual(lists[0], range(n))
- self.assertEqual(lists[1], range(n))
+ self.assertEqual(lists[0], list(range(n)))
+ self.assertEqual(lists[1], list(range(n)))
# test argument format checking
self.assertRaises(TypeError, tee)
@@ -869,22 +893,22 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(list(c), list('def'))
# test long-lagged and multi-way split
- a, b, c = tee(xrange(2000), 3)
- for i in xrange(100):
- self.assertEqual(a.next(), i)
- self.assertEqual(list(b), range(2000))
- self.assertEqual([c.next(), c.next()], range(2))
- self.assertEqual(list(a), range(100,2000))
- self.assertEqual(list(c), range(2,2000))
+ a, b, c = tee(range(2000), 3)
+ for i in range(100):
+ self.assertEqual(next(a), i)
+ self.assertEqual(list(b), list(range(2000)))
+ self.assertEqual([next(c), next(c)], list(range(2)))
+ self.assertEqual(list(a), list(range(100,2000)))
+ self.assertEqual(list(c), list(range(2,2000)))
# test values of n
self.assertRaises(TypeError, tee, 'abc', 'invalid')
self.assertRaises(ValueError, tee, [], -1)
- for n in xrange(5):
+ for n in range(5):
result = tee('abc', n)
self.assertEqual(type(result), tuple)
self.assertEqual(len(result), n)
- self.assertEqual(map(list, result), [list('abc')]*n)
+ self.assertEqual([list(x) for x in result], [list('abc')]*n)
# tee pass-through to copyable iterator
a, b = tee('abc')
@@ -900,37 +924,40 @@ class TestBasicOps(unittest.TestCase):
self.assertTrue(list(t1) == list(t2) == list(t3) == list('abc'))
# test that tee objects are weak referencable
- a, b = tee(xrange(10))
+ a, b = tee(range(10))
p = proxy(a)
self.assertEqual(getattr(p, '__class__'), type(b))
del a
self.assertRaises(ReferenceError, getattr, p, '__class__')
def test_StopIteration(self):
- self.assertRaises(StopIteration, izip().next)
+ self.assertRaises(StopIteration, next, zip())
- for f in (chain, cycle, izip, groupby):
- self.assertRaises(StopIteration, f([]).next)
- self.assertRaises(StopIteration, f(StopNow()).next)
+ for f in (chain, cycle, zip, groupby):
+ self.assertRaises(StopIteration, next, f([]))
+ self.assertRaises(StopIteration, next, f(StopNow()))
- self.assertRaises(StopIteration, islice([], None).next)
- self.assertRaises(StopIteration, islice(StopNow(), None).next)
+ self.assertRaises(StopIteration, next, islice([], None))
+ self.assertRaises(StopIteration, next, islice(StopNow(), None))
p, q = tee([])
- self.assertRaises(StopIteration, p.next)
- self.assertRaises(StopIteration, q.next)
+ self.assertRaises(StopIteration, next, p)
+ self.assertRaises(StopIteration, next, q)
p, q = tee(StopNow())
- self.assertRaises(StopIteration, p.next)
- self.assertRaises(StopIteration, q.next)
+ self.assertRaises(StopIteration, next, p)
+ self.assertRaises(StopIteration, next, q)
- self.assertRaises(StopIteration, repeat(None, 0).next)
+ self.assertRaises(StopIteration, next, repeat(None, 0))
- for f in (ifilter, ifilterfalse, imap, takewhile, dropwhile, starmap):
- self.assertRaises(StopIteration, f(lambda x:x, []).next)
- self.assertRaises(StopIteration, f(lambda x:x, StopNow()).next)
+ for f in (filter, filterfalse, map, takewhile, dropwhile, starmap):
+ self.assertRaises(StopIteration, next, f(lambda x:x, []))
+ self.assertRaises(StopIteration, next, f(lambda x:x, StopNow()))
class TestExamples(unittest.TestCase):
+ def test_accumlate(self):
+ self.assertEqual(list(accumulate([1,2,3,4,5])), [1, 3, 6, 10, 15])
+
def test_chain(self):
self.assertEqual(''.join(chain('ABC', 'DEF')), 'ABCDEF')
@@ -965,14 +992,14 @@ class TestExamples(unittest.TestCase):
self.assertEqual([(list(g)) for k, g in groupby('AAAABBBCCD')],
[list('AAAA'), list('BBB'), list('CC'), list('D')])
- def test_ifilter(self):
- self.assertEqual(list(ifilter(lambda x: x%2, range(10))), [1,3,5,7,9])
+ def test_filter(self):
+ self.assertEqual(list(filter(lambda x: x%2, range(10))), [1,3,5,7,9])
- def test_ifilterfalse(self):
- self.assertEqual(list(ifilterfalse(lambda x: x%2, range(10))), [0,2,4,6,8])
+ def test_filterfalse(self):
+ self.assertEqual(list(filterfalse(lambda x: x%2, range(10))), [0,2,4,6,8])
- def test_imap(self):
- self.assertEqual(list(imap(pow, (2,3,10), (5,2,3))), [32, 9, 1000])
+ def test_map(self):
+ self.assertEqual(list(map(pow, (2,3,10), (5,2,3))), [32, 9, 1000])
def test_islice(self):
self.assertEqual(list(islice('ABCDEFG', 2)), list('AB'))
@@ -980,22 +1007,22 @@ class TestExamples(unittest.TestCase):
self.assertEqual(list(islice('ABCDEFG', 2, None)), list('CDEFG'))
self.assertEqual(list(islice('ABCDEFG', 0, None, 2)), list('ACEG'))
- def test_izip(self):
- self.assertEqual(list(izip('ABCD', 'xy')), [('A', 'x'), ('B', 'y')])
+ def test_zip(self):
+ self.assertEqual(list(zip('ABCD', 'xy')), [('A', 'x'), ('B', 'y')])
- def test_izip_longest(self):
- self.assertEqual(list(izip_longest('ABCD', 'xy', fillvalue='-')),
+ def test_zip_longest(self):
+ self.assertEqual(list(zip_longest('ABCD', 'xy', fillvalue='-')),
[('A', 'x'), ('B', 'y'), ('C', '-'), ('D', '-')])
def test_permutations(self):
self.assertEqual(list(permutations('ABCD', 2)),
- map(tuple, 'AB AC AD BA BC BD CA CB CD DA DB DC'.split()))
+ list(map(tuple, 'AB AC AD BA BC BD CA CB CD DA DB DC'.split())))
self.assertEqual(list(permutations(range(3))),
[(0,1,2), (0,2,1), (1,0,2), (1,2,0), (2,0,1), (2,1,0)])
def test_product(self):
self.assertEqual(list(product('ABCD', 'xy')),
- map(tuple, 'Ax Ay Bx By Cx Cy Dx Dy'.split()))
+ list(map(tuple, 'Ax Ay Bx By Cx Cy Dx Dy'.split())))
self.assertEqual(list(product(range(2), repeat=3)),
[(0,0,0), (0,0,1), (0,1,0), (0,1,1),
(1,0,0), (1,0,1), (1,1,0), (1,1,1)])
@@ -1015,9 +1042,13 @@ class TestGC(unittest.TestCase):
def makecycle(self, iterator, container):
container.append(iterator)
- iterator.next()
+ next(iterator)
del container, iterator
+ def test_accumulate(self):
+ a = []
+ self.makecycle(accumulate([1,2,a,3]), a)
+
def test_chain(self):
a = []
self.makecycle(chain(a), a)
@@ -1059,30 +1090,30 @@ class TestGC(unittest.TestCase):
# Issue 2246 -- the _grouper iterator was not included in GC
n = 10
keyfunc = lambda x: x
- for i, j in groupby(xrange(n), key=keyfunc):
+ for i, j in groupby(range(n), key=keyfunc):
keyfunc.__dict__.setdefault('x',[]).append(j)
- def test_ifilter(self):
+ def test_filter(self):
a = []
- self.makecycle(ifilter(lambda x:True, [a]*2), a)
+ self.makecycle(filter(lambda x:True, [a]*2), a)
- def test_ifilterfalse(self):
+ def test_filterfalse(self):
a = []
- self.makecycle(ifilterfalse(lambda x:False, a), a)
+ self.makecycle(filterfalse(lambda x:False, a), a)
- def test_izip(self):
+ def test_zip(self):
a = []
- self.makecycle(izip([a]*2, [a]*3), a)
+ self.makecycle(zip([a]*2, [a]*3), a)
- def test_izip_longest(self):
+ def test_zip_longest(self):
a = []
- self.makecycle(izip_longest([a]*2, [a]*3), a)
+ self.makecycle(zip_longest([a]*2, [a]*3), a)
b = [a, None]
- self.makecycle(izip_longest([a]*2, [a]*3, fillvalue=b), a)
+ self.makecycle(zip_longest([a]*2, [a]*3, fillvalue=b), a)
- def test_imap(self):
+ def test_map(self):
a = []
- self.makecycle(imap(lambda x:x, [a]*2), a)
+ self.makecycle(map(lambda x:x, [a]*2), a)
def test_islice(self):
a = []
@@ -1127,7 +1158,7 @@ class I:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -1147,14 +1178,14 @@ class X:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
return v
class N:
- 'Iterator missing next()'
+ 'Iterator missing __next__()'
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
@@ -1168,7 +1199,7 @@ class E:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
3 // 0
class S:
@@ -1177,18 +1208,29 @@ class S:
pass
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
def L(seqn):
'Test multiple tiers of iterators'
- return chain(imap(lambda x:x, R(Ig(G(seqn)))))
+ return chain(map(lambda x:x, R(Ig(G(seqn)))))
class TestVariousIteratorArgs(unittest.TestCase):
+ def test_accumulate(self):
+ s = [1,2,3,4,5]
+ r = [1,3,6,10,15]
+ n = len(s)
+ for g in (G, I, Ig, L, R):
+ self.assertEqual(list(accumulate(g(s))), r)
+ self.assertEqual(list(accumulate(S(s))), [])
+ self.assertRaises(TypeError, accumulate, X(s))
+ self.assertRaises(TypeError, accumulate, N(s))
+ self.assertRaises(ZeroDivisionError, list, accumulate(E(s)))
+
def test_chain(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
self.assertEqual(list(chain(g(s))), list(g(s)))
self.assertEqual(list(chain(g(s), g(s))), list(g(s))+list(g(s)))
@@ -1197,101 +1239,106 @@ class TestVariousIteratorArgs(unittest.TestCase):
self.assertRaises(ZeroDivisionError, list, chain(E(s)))
def test_compress(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
n = len(s)
for g in (G, I, Ig, S, L, R):
self.assertEqual(list(compress(g(s), repeat(1))), list(g(s)))
self.assertRaises(TypeError, compress, X(s), repeat(1))
- self.assertRaises(TypeError, list, compress(N(s), repeat(1)))
+ self.assertRaises(TypeError, compress, N(s), repeat(1))
self.assertRaises(ZeroDivisionError, list, compress(E(s), repeat(1)))
def test_product(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
self.assertRaises(TypeError, product, X(s))
self.assertRaises(TypeError, product, N(s))
self.assertRaises(ZeroDivisionError, product, E(s))
def test_cycle(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
tgtlen = len(s) * 3
expected = list(g(s))*3
actual = list(islice(cycle(g(s)), tgtlen))
self.assertEqual(actual, expected)
self.assertRaises(TypeError, cycle, X(s))
- self.assertRaises(TypeError, list, cycle(N(s)))
+ self.assertRaises(TypeError, cycle, N(s))
self.assertRaises(ZeroDivisionError, list, cycle(E(s)))
def test_groupby(self):
- for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)):
+ for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
self.assertEqual([k for k, sb in groupby(g(s))], list(g(s)))
self.assertRaises(TypeError, groupby, X(s))
- self.assertRaises(TypeError, list, groupby(N(s)))
+ self.assertRaises(TypeError, groupby, N(s))
self.assertRaises(ZeroDivisionError, list, groupby(E(s)))
- def test_ifilter(self):
- for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)):
+ def test_filter(self):
+ for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(list(ifilter(isEven, g(s))), filter(isEven, g(s)))
- self.assertRaises(TypeError, ifilter, isEven, X(s))
- self.assertRaises(TypeError, list, ifilter(isEven, N(s)))
- self.assertRaises(ZeroDivisionError, list, ifilter(isEven, E(s)))
-
- def test_ifilterfalse(self):
- for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)):
+ self.assertEqual(list(filter(isEven, g(s))),
+ [x for x in g(s) if isEven(x)])
+ self.assertRaises(TypeError, filter, isEven, X(s))
+ self.assertRaises(TypeError, filter, isEven, N(s))
+ self.assertRaises(ZeroDivisionError, list, filter(isEven, E(s)))
+
+ def test_filterfalse(self):
+ for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(list(ifilterfalse(isEven, g(s))), filter(isOdd, g(s)))
- self.assertRaises(TypeError, ifilterfalse, isEven, X(s))
- self.assertRaises(TypeError, list, ifilterfalse(isEven, N(s)))
- self.assertRaises(ZeroDivisionError, list, ifilterfalse(isEven, E(s)))
-
- def test_izip(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ self.assertEqual(list(filterfalse(isEven, g(s))),
+ [x for x in g(s) if isOdd(x)])
+ self.assertRaises(TypeError, filterfalse, isEven, X(s))
+ self.assertRaises(TypeError, filterfalse, isEven, N(s))
+ self.assertRaises(ZeroDivisionError, list, filterfalse(isEven, E(s)))
+
+ def test_zip(self):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(list(izip(g(s))), zip(g(s)))
- self.assertEqual(list(izip(g(s), g(s))), zip(g(s), g(s)))
- self.assertRaises(TypeError, izip, X(s))
- self.assertRaises(TypeError, list, izip(N(s)))
- self.assertRaises(ZeroDivisionError, list, izip(E(s)))
-
- def test_iziplongest(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ self.assertEqual(list(zip(g(s))), lzip(g(s)))
+ self.assertEqual(list(zip(g(s), g(s))), lzip(g(s), g(s)))
+ self.assertRaises(TypeError, zip, X(s))
+ self.assertRaises(TypeError, zip, N(s))
+ self.assertRaises(ZeroDivisionError, list, zip(E(s)))
+
+ def test_ziplongest(self):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(list(izip_longest(g(s))), zip(g(s)))
- self.assertEqual(list(izip_longest(g(s), g(s))), zip(g(s), g(s)))
- self.assertRaises(TypeError, izip_longest, X(s))
- self.assertRaises(TypeError, list, izip_longest(N(s)))
- self.assertRaises(ZeroDivisionError, list, izip_longest(E(s)))
-
- def test_imap(self):
- for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)):
+ self.assertEqual(list(zip_longest(g(s))), list(zip(g(s))))
+ self.assertEqual(list(zip_longest(g(s), g(s))), list(zip(g(s), g(s))))
+ self.assertRaises(TypeError, zip_longest, X(s))
+ self.assertRaises(TypeError, zip_longest, N(s))
+ self.assertRaises(ZeroDivisionError, list, zip_longest(E(s)))
+
+ def test_map(self):
+ for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
for g in (G, I, Ig, S, L, R):
- self.assertEqual(list(imap(onearg, g(s))), map(onearg, g(s)))
- self.assertEqual(list(imap(operator.pow, g(s), g(s))), map(operator.pow, g(s), g(s)))
- self.assertRaises(TypeError, imap, onearg, X(s))
- self.assertRaises(TypeError, list, imap(onearg, N(s)))
- self.assertRaises(ZeroDivisionError, list, imap(onearg, E(s)))
+ self.assertEqual(list(map(onearg, g(s))),
+ [onearg(x) for x in g(s)])
+ self.assertEqual(list(map(operator.pow, g(s), g(s))),
+ [x**x for x in g(s)])
+ self.assertRaises(TypeError, map, onearg, X(s))
+ self.assertRaises(TypeError, map, onearg, N(s))
+ self.assertRaises(ZeroDivisionError, list, map(onearg, E(s)))
def test_islice(self):
- for s in ("12345", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("12345", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
self.assertEqual(list(islice(g(s),1,None,2)), list(g(s))[1::2])
self.assertRaises(TypeError, islice, X(s), 10)
- self.assertRaises(TypeError, list, islice(N(s), 10))
+ self.assertRaises(TypeError, islice, N(s), 10)
self.assertRaises(ZeroDivisionError, list, islice(E(s), 10))
def test_starmap(self):
- for s in (range(10), range(0), range(100), (7,11), xrange(20,50,5)):
+ for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
for g in (G, I, Ig, S, L, R):
- ss = zip(s, s)
- self.assertEqual(list(starmap(operator.pow, g(ss))), map(operator.pow, g(s), g(s)))
+ ss = lzip(s, s)
+ self.assertEqual(list(starmap(operator.pow, g(ss))),
+ [x**x for x in g(s)])
self.assertRaises(TypeError, starmap, operator.pow, X(ss))
- self.assertRaises(TypeError, list, starmap(operator.pow, N(ss)))
+ self.assertRaises(TypeError, starmap, operator.pow, N(ss))
self.assertRaises(ZeroDivisionError, list, starmap(operator.pow, E(ss)))
def test_takewhile(self):
- for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)):
+ for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
tgt = []
for elem in g(s):
@@ -1299,11 +1346,11 @@ class TestVariousIteratorArgs(unittest.TestCase):
tgt.append(elem)
self.assertEqual(list(takewhile(isEven, g(s))), tgt)
self.assertRaises(TypeError, takewhile, isEven, X(s))
- self.assertRaises(TypeError, list, takewhile(isEven, N(s)))
+ self.assertRaises(TypeError, takewhile, isEven, N(s))
self.assertRaises(ZeroDivisionError, list, takewhile(isEven, E(s)))
def test_dropwhile(self):
- for s in (range(10), range(0), range(1000), (7,11), xrange(2000,2200,5)):
+ for s in (range(10), range(0), range(1000), (7,11), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
tgt = []
for elem in g(s):
@@ -1311,17 +1358,17 @@ class TestVariousIteratorArgs(unittest.TestCase):
tgt.append(elem)
self.assertEqual(list(dropwhile(isOdd, g(s))), tgt)
self.assertRaises(TypeError, dropwhile, isOdd, X(s))
- self.assertRaises(TypeError, list, dropwhile(isOdd, N(s)))
+ self.assertRaises(TypeError, dropwhile, isOdd, N(s))
self.assertRaises(ZeroDivisionError, list, dropwhile(isOdd, E(s)))
def test_tee(self):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
it1, it2 = tee(g(s))
self.assertEqual(list(it1), list(g(s)))
self.assertEqual(list(it2), list(g(s)))
self.assertRaises(TypeError, tee, X(s))
- self.assertRaises(TypeError, list, tee(N(s))[0])
+ self.assertRaises(TypeError, tee, N(s))
self.assertRaises(ZeroDivisionError, list, tee(E(s))[0])
class LengthTransparency(unittest.TestCase):
@@ -1343,13 +1390,13 @@ class RegressionTests(unittest.TestCase):
def g(value, first=[1]):
if first:
del first[:]
- f(z.next())
+ f(next(z))
return value
items = list(tuple2)
items[1:1] = list(tuple1)
- gen = imap(g, items)
- z = izip(*[gen]*len(tuple1))
- z.next()
+ gen = map(g, items)
+ z = zip(*[gen]*len(tuple1))
+ next(z)
def f(t):
global T
@@ -1395,14 +1442,14 @@ class RegressionTests(unittest.TestCase):
class SubclassWithKwargsTest(unittest.TestCase):
def test_keywords_in_subclass(self):
# count is not subclassable...
- for cls in (repeat, izip, ifilter, ifilterfalse, chain, imap,
+ for cls in (repeat, zip, filter, filterfalse, chain, map,
starmap, islice, takewhile, dropwhile, cycle, compress):
class Subclass(cls):
def __init__(self, newarg=None, *args):
cls.__init__(self, *args)
try:
Subclass(newarg=1)
- except TypeError, err:
+ except TypeError as err:
# we expect type errors because of wrong argument count
self.assertNotIn("does not take keyword arguments", err.args[0])
@@ -1411,16 +1458,16 @@ libreftest = """ Doctest for examples in the library reference: libitertools.tex
>>> amounts = [120.15, 764.05, 823.14]
->>> for checknum, amount in izip(count(1200), amounts):
-... print 'Check %d is for $%.2f' % (checknum, amount)
+>>> for checknum, amount in zip(count(1200), amounts):
+... print('Check %d is for $%.2f' % (checknum, amount))
...
Check 1200 is for $120.15
Check 1201 is for $764.05
Check 1202 is for $823.14
>>> import operator
->>> for cube in imap(operator.pow, xrange(1,4), repeat(3)):
-... print cube
+>>> for cube in map(operator.pow, range(1,4), repeat(3)):
+... print(cube)
...
1
8
@@ -1428,7 +1475,7 @@ Check 1202 is for $823.14
>>> reportlines = ['EuroPython', 'Roster', '', 'alex', '', 'laura', '', 'martin', '', 'walter', '', 'samuele']
>>> for name in islice(reportlines, 3, None, 2):
-... print name.title()
+... print(name.title())
...
Alex
Laura
@@ -1438,9 +1485,9 @@ Samuele
>>> from operator import itemgetter
>>> d = dict(a=1, b=2, c=1, d=2, e=1, f=2, g=3)
->>> di = sorted(sorted(d.iteritems()), key=itemgetter(1))
+>>> di = sorted(sorted(d.items()), key=itemgetter(1))
>>> for k, g in groupby(di, itemgetter(1)):
-... print k, map(itemgetter(0), g)
+... print(k, list(map(itemgetter(0), g)))
...
1 ['a', 'c', 'e']
2 ['b', 'd', 'f']
@@ -1451,7 +1498,7 @@ Samuele
# same group.
>>> data = [ 1, 4,5,6, 10, 15,16,17,18, 22, 25,26,27,28]
>>> for k, g in groupby(enumerate(data), lambda t:t[0]-t[1]):
-... print map(operator.itemgetter(1), g)
+... print(list(map(operator.itemgetter(1), g)))
...
[1]
[4, 5, 6]
@@ -1465,11 +1512,11 @@ Samuele
... return list(islice(iterable, n))
>>> def enumerate(iterable, start=0):
-... return izip(count(start), iterable)
+... return zip(count(start), iterable)
>>> def tabulate(function, start=0):
... "Return function(0), function(1), ..."
-... return imap(function, count(start))
+... return map(function, count(start))
>>> def nth(iterable, n, default=None):
... "Returns the nth item or a default value"
@@ -1477,7 +1524,7 @@ Samuele
>>> def quantify(iterable, pred=bool):
... "Count how many times the predicate is true"
-... return sum(imap(pred, iterable))
+... return sum(map(pred, iterable))
>>> def padnone(iterable):
... "Returns the sequence elements and then returns None indefinitely"
@@ -1488,7 +1535,7 @@ Samuele
... return chain(*repeat(iterable, n))
>>> def dotproduct(vec1, vec2):
-... return sum(imap(operator.mul, vec1, vec2))
+... return sum(map(operator.mul, vec1, vec2))
>>> def flatten(listOfLists):
... return list(chain.from_iterable(listOfLists))
@@ -1504,20 +1551,22 @@ Samuele
>>> def pairwise(iterable):
... "s -> (s0,s1), (s1,s2), (s2, s3), ..."
... a, b = tee(iterable)
-... for elem in b:
-... break
-... return izip(a, b)
+... try:
+... next(b)
+... except StopIteration:
+... pass
+... return zip(a, b)
>>> def grouper(n, iterable, fillvalue=None):
... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
... args = [iter(iterable)] * n
-... return izip_longest(fillvalue=fillvalue, *args)
+... return zip_longest(*args, fillvalue=fillvalue)
>>> def roundrobin(*iterables):
... "roundrobin('ABC', 'D', 'EF') --> A D E B F C"
... # Recipe credited to George Sakkis
... pending = len(iterables)
-... nexts = cycle(iter(it).next for it in iterables)
+... nexts = cycle(iter(it).__next__ for it in iterables)
... while pending:
... try:
... for next in nexts:
@@ -1553,7 +1602,7 @@ Samuele
... "List unique elements, preserving order. Remember only the element just seen."
... # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
... # unique_justseen('ABBCcAD', str.lower) --> A B C A D
-... return imap(next, imap(itemgetter(1), groupby(iterable, key)))
+... return map(next, map(itemgetter(1), groupby(iterable, key)))
This is not part of the examples but it tests to make sure the definitions
perform as purported.
@@ -1573,7 +1622,7 @@ perform as purported.
>>> nth('abcde', 9) is None
True
->>> quantify(xrange(99), lambda x: x%2==0)
+>>> quantify(range(99), lambda x: x%2==0)
50
>>> a = [[1, 2, 3], [4, 5, 6]]
@@ -1584,7 +1633,7 @@ True
[8, 8, 8, 8, 8]
>>> import random
->>> take(5, imap(int, repeatfunc(random.random)))
+>>> take(5, map(int, repeatfunc(random.random)))
[0, 0, 0, 0, 0]
>>> list(pairwise('abcd'))
@@ -1640,20 +1689,20 @@ def test_main(verbose=None):
test_classes = (TestBasicOps, TestVariousIteratorArgs, TestGC,
RegressionTests, LengthTransparency,
SubclassWithKwargsTest, TestExamples)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
# doctest the examples in the library reference
- test_support.run_doctest(sys.modules[__name__], verbose)
+ support.run_doctest(sys.modules[__name__], verbose)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_json.py b/Lib/test/test_json.py
index 7b8f3de8a98..41ff8974fc7 100644
--- a/Lib/test/test_json.py
+++ b/Lib/test/test_json.py
@@ -5,12 +5,12 @@ the test_suite() function there returns a test suite that's ready to
be run.
"""
-import json.tests
-import test.test_support
+from test import json_tests
+import test.support
def test_main():
- test.test_support.run_unittest(json.tests.test_suite())
+ test.support.run_unittest(json_tests.test_suite())
if __name__ == "__main__":
diff --git a/Lib/test/test_keywordonlyarg.py b/Lib/test/test_keywordonlyarg.py
new file mode 100644
index 00000000000..108ed18c59f
--- /dev/null
+++ b/Lib/test/test_keywordonlyarg.py
@@ -0,0 +1,183 @@
+#!/usr/bin/env python3
+
+"""Unit tests for the keyword only argument specified in PEP 3102."""
+
+__author__ = "Jiwon Seo"
+__email__ = "seojiwon at gmail dot com"
+
+import unittest
+from test.support import run_unittest
+
+def posonly_sum(pos_arg1, *arg, **kwarg):
+ return pos_arg1 + sum(arg) + sum(kwarg.values())
+def keywordonly_sum(*, k1=0, k2):
+ return k1 + k2
+def keywordonly_nodefaults_sum(*, k1, k2):
+ return k1 + k2
+def keywordonly_and_kwarg_sum(*, k1, k2, **kwarg):
+ return k1 + k2 + sum(kwarg.values())
+def mixedargs_sum(a, b=0, *arg, k1, k2=0):
+ return a + b + k1 + k2 + sum(arg)
+def mixedargs_sum2(a, b=0, *arg, k1, k2=0, **kwargs):
+ return a + b + k1 + k2 + sum(arg) + sum(kwargs.values())
+
+def sortnum(*nums, reverse=False):
+ return sorted(list(nums), reverse=reverse)
+
+def sortwords(*words, reverse=False, **kwargs):
+ return sorted(list(words), reverse=reverse)
+
+class Foo:
+ def __init__(self, *, k1, k2=0):
+ self.k1 = k1
+ self.k2 = k2
+ def set(self, p1, *, k1, k2):
+ self.k1 = k1
+ self.k2 = k2
+ def sum(self):
+ return self.k1 + self.k2
+
+class KeywordOnlyArgTestCase(unittest.TestCase):
+ def assertRaisesSyntaxError(self, codestr):
+ def shouldRaiseSyntaxError(s):
+ compile(s, "<test>", "single")
+ self.assertRaises(SyntaxError, shouldRaiseSyntaxError, codestr)
+
+ def testSyntaxErrorForFunctionDefinition(self):
+ self.assertRaisesSyntaxError("def f(p, *):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *, p1=100):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *k1, k1=100):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *, k1, k1=100):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *, **k1):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *, k1, **k1):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p1, *, None, **k1):\n pass\n")
+ self.assertRaisesSyntaxError("def f(p, *, (k1, k2), **kw):\n pass\n")
+
+ def testSyntaxForManyArguments(self):
+ fundef = "def f("
+ for i in range(255):
+ fundef += "i%d, "%i
+ fundef += "*, key=100):\n pass\n"
+ self.assertRaisesSyntaxError(fundef)
+
+ fundef2 = "def foo(i,*,"
+ for i in range(255):
+ fundef2 += "i%d, "%i
+ fundef2 += "lastarg):\n pass\n"
+ self.assertRaisesSyntaxError(fundef2)
+
+ # exactly 255 arguments, should compile ok
+ fundef3 = "def f(i,*,"
+ for i in range(253):
+ fundef3 += "i%d, "%i
+ fundef3 += "lastarg):\n pass\n"
+ compile(fundef3, "<test>", "single")
+
+ def testTooManyPositionalErrorMessage(self):
+ def f(a, b=None, *, c=None):
+ pass
+ with self.assertRaises(TypeError) as exc:
+ f(1, 2, 3)
+ expected = "f() takes at most 2 positional arguments (3 given)"
+ self.assertEqual(str(exc.exception), expected)
+
+ def testSyntaxErrorForFunctionCall(self):
+ self.assertRaisesSyntaxError("f(p, k=1, p2)")
+ self.assertRaisesSyntaxError("f(p, k1=50, *(1,2), k1=100)")
+
+ def testRaiseErrorFuncallWithUnexpectedKeywordArgument(self):
+ self.assertRaises(TypeError, keywordonly_sum, ())
+ self.assertRaises(TypeError, keywordonly_nodefaults_sum, ())
+ self.assertRaises(TypeError, Foo, ())
+ try:
+ keywordonly_sum(k2=100, non_existing_arg=200)
+ self.fail("should raise TypeError")
+ except TypeError:
+ pass
+ try:
+ keywordonly_nodefaults_sum(k2=2)
+ self.fail("should raise TypeError")
+ except TypeError:
+ pass
+
+ def testFunctionCall(self):
+ self.assertEqual(1, posonly_sum(1))
+ self.assertEqual(1+2, posonly_sum(1,**{"2":2}))
+ self.assertEqual(1+2+3, posonly_sum(1,*(2,3)))
+ self.assertEqual(1+2+3+4, posonly_sum(1,*(2,3),**{"4":4}))
+
+ self.assertEqual(1, keywordonly_sum(k2=1))
+ self.assertEqual(1+2, keywordonly_sum(k1=1, k2=2))
+
+ self.assertEqual(1+2, keywordonly_and_kwarg_sum(k1=1, k2=2))
+ self.assertEqual(1+2+3, keywordonly_and_kwarg_sum(k1=1, k2=2, k3=3))
+ self.assertEqual(1+2+3+4,
+ keywordonly_and_kwarg_sum(k1=1, k2=2,
+ **{"a":3,"b":4}))
+
+ self.assertEqual(1+2, mixedargs_sum(1, k1=2))
+ self.assertEqual(1+2+3, mixedargs_sum(1, 2, k1=3))
+ self.assertEqual(1+2+3+4, mixedargs_sum(1, 2, k1=3, k2=4))
+ self.assertEqual(1+2+3+4+5, mixedargs_sum(1, 2, 3, k1=4, k2=5))
+
+ self.assertEqual(1+2, mixedargs_sum2(1, k1=2))
+ self.assertEqual(1+2+3, mixedargs_sum2(1, 2, k1=3))
+ self.assertEqual(1+2+3+4, mixedargs_sum2(1, 2, k1=3, k2=4))
+ self.assertEqual(1+2+3+4+5, mixedargs_sum2(1, 2, 3, k1=4, k2=5))
+ self.assertEqual(1+2+3+4+5+6,
+ mixedargs_sum2(1, 2, 3, k1=4, k2=5, k3=6))
+ self.assertEqual(1+2+3+4+5+6,
+ mixedargs_sum2(1, 2, 3, k1=4, **{'k2':5, 'k3':6}))
+
+ self.assertEqual(1, Foo(k1=1).sum())
+ self.assertEqual(1+2, Foo(k1=1,k2=2).sum())
+
+ self.assertEqual([1,2,3], sortnum(3,2,1))
+ self.assertEqual([3,2,1], sortnum(1,2,3, reverse=True))
+
+ self.assertEqual(['a','b','c'], sortwords('a','c','b'))
+ self.assertEqual(['c','b','a'], sortwords('a','c','b', reverse=True))
+ self.assertEqual(['c','b','a'],
+ sortwords('a','c','b', reverse=True, ignore='ignore'))
+
+ def testKwDefaults(self):
+ def foo(p1,p2=0, *, k1, k2=0):
+ return p1 + p2 + k1 + k2
+
+ self.assertEqual(2, foo.__code__.co_kwonlyargcount)
+ self.assertEqual({"k2":0}, foo.__kwdefaults__)
+ foo.__kwdefaults__ = {"k1":0}
+ try:
+ foo(1,k1=10)
+ self.fail("__kwdefaults__ is not properly changed")
+ except TypeError:
+ pass
+
+ def test_kwonly_methods(self):
+ class Example:
+ def f(self, *, k1=1, k2=2):
+ return k1, k2
+
+ self.assertEqual(Example().f(k1=1, k2=2), (1, 2))
+ self.assertEqual(Example.f(Example(), k1=1, k2=2), (1, 2))
+ self.assertRaises(TypeError, Example.f, k1=1, k2=2)
+
+ def test_issue13343(self):
+ # The Python compiler must scan all symbols of a function to
+ # determine their scope: global, local, cell...
+ # This was not done for the default values of keyword
+ # arguments in a lambda definition, and the following line
+ # used to fail with a SystemError.
+ lambda *, k1=unittest: None
+
+ def test_mangling(self):
+ class X:
+ def f(self, *, __a=42):
+ return __a
+ self.assertEqual(X().f(), 42)
+
+def test_main():
+ run_unittest(KeywordOnlyArgTestCase)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_kqueue.py b/Lib/test/test_kqueue.py
index e5eecfa5748..4e9301307ce 100644
--- a/Lib/test/test_kqueue.py
+++ b/Lib/test/test_kqueue.py
@@ -1,14 +1,15 @@
"""
Tests for kqueue wrapper.
"""
-import socket
import errno
-import time
+import os
import select
+import socket
import sys
+import time
import unittest
-from test import test_support
+from test import support
if not hasattr(select, "kqueue"):
raise unittest.SkipTest("test works only on BSD")
@@ -22,7 +23,11 @@ class TestKQueue(unittest.TestCase):
self.assertRaises(ValueError, kq.fileno)
def test_create_event(self):
- fd = sys.stderr.fileno()
+ from operator import lt, le, gt, ge
+
+ fd = os.open(os.devnull, os.O_WRONLY)
+ self.addCleanup(os.close, fd)
+
ev = select.kevent(fd)
other = select.kevent(1000)
self.assertEqual(ev.ident, fd)
@@ -33,12 +38,12 @@ class TestKQueue(unittest.TestCase):
self.assertEqual(ev.udata, 0)
self.assertEqual(ev, ev)
self.assertNotEqual(ev, other)
- self.assertEqual(cmp(ev, other), -1)
self.assertTrue(ev < other)
self.assertTrue(other >= ev)
- self.assertRaises(TypeError, cmp, ev, None)
- self.assertRaises(TypeError, cmp, ev, 1)
- self.assertRaises(TypeError, cmp, ev, "ev")
+ for op in lt, le, gt, ge:
+ self.assertRaises(TypeError, op, ev, None)
+ self.assertRaises(TypeError, op, ev, 1)
+ self.assertRaises(TypeError, op, ev, "ev")
ev = select.kevent(fd, select.KQ_FILTER_WRITE)
self.assertEqual(ev.ident, fd)
@@ -89,7 +94,7 @@ class TestKQueue(unittest.TestCase):
client.setblocking(False)
try:
client.connect(('127.0.0.1', serverSocket.getsockname()[1]))
- except socket.error, e:
+ except socket.error as e:
self.assertEqual(e.args[0], errno.EINPROGRESS)
else:
#raise AssertionError("Connect should have raised EINPROGRESS")
@@ -128,8 +133,8 @@ class TestKQueue(unittest.TestCase):
(client.fileno(), select.KQ_FILTER_WRITE, flags),
(server.fileno(), select.KQ_FILTER_WRITE, flags)])
- client.send("Hello!")
- server.send("world!!!")
+ client.send(b"Hello!")
+ server.send(b"world!!!")
# We may need to call it several times
for i in range(10):
@@ -190,7 +195,7 @@ class TestKQueue(unittest.TestCase):
kq.close()
def test_main():
- test_support.run_unittest(TestKQueue)
+ support.run_unittest(TestKQueue)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_largefile.py b/Lib/test/test_largefile.py
index 16da8d8f174..1c6297ac7c0 100644
--- a/Lib/test/test_largefile.py
+++ b/Lib/test/test_largefile.py
@@ -1,13 +1,11 @@
"""Test largefile support on system where this makes sense.
"""
-from __future__ import print_function
-
import os
import stat
import sys
import unittest
-from test.test_support import run_unittest, TESTFN, verbose, requires, \
+from test.support import run_unittest, TESTFN, verbose, requires, \
unlink
import io # C implementation of io
import _pyio as pyio # Python implementation of io
@@ -124,24 +122,20 @@ class LargeFileTest(unittest.TestCase):
newsize -= 1
f.seek(42)
f.truncate(newsize)
- if self.new_io:
- self.assertEqual(f.tell(), 42)
+ self.assertEqual(f.tell(), 42)
f.seek(0, 2)
self.assertEqual(f.tell(), newsize)
# XXX truncate(larger than true size) is ill-defined
# across platform; cut it waaaaay back
f.seek(0)
f.truncate(1)
- if self.new_io:
- self.assertEqual(f.tell(), 0) # else pointer moved
+ self.assertEqual(f.tell(), 0) # else pointer moved
f.seek(0)
self.assertEqual(len(f.read()), 1) # else wasn't truncated
def test_seekable(self):
# Issue #5016; seekable() can return False when the current position
# is negative when truncated to an int.
- if not self.new_io:
- self.skipTest("builtin file doesn't have seekable()")
for pos in (2**31-1, 2**31, 2**31+1):
with self.open(TESTFN, 'rb') as f:
f.seek(pos)
@@ -175,12 +169,10 @@ def test_main():
else:
f.close()
suite = unittest.TestSuite()
- for _open, prefix in [(io.open, 'C'), (pyio.open, 'Py'),
- (open, 'Builtin')]:
+ for _open, prefix in [(io.open, 'C'), (pyio.open, 'Py')]:
class TestCase(LargeFileTest):
pass
TestCase.open = staticmethod(_open)
- TestCase.new_io = _open is not open
TestCase.__name__ = prefix + LargeFileTest.__name__
suite.addTest(TestCase('test_seek'))
suite.addTest(TestCase('test_osstat'))
diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py
index 109a26cb670..1afaf70ffa4 100644
--- a/Lib/test/test_lib2to3.py
+++ b/Lib/test/test_lib2to3.py
@@ -1,15 +1,16 @@
# Skipping test_parser and test_all_fixers
# because of running
from lib2to3.tests import (test_fixers, test_pytree, test_util, test_refactor,
- test_parser, test_main as test_main_)
+ test_parser,
+ test_main as test_main_)
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
def suite():
tests = unittest.TestSuite()
loader = unittest.TestLoader()
- for m in (test_fixers, test_pytree,test_util, test_refactor, test_parser,
- test_main_):
+ for m in (test_fixers, test_pytree,test_util, test_refactor,
+ test_parser, test_main_):
tests.addTests(loader.loadTestsFromModule(m))
return tests
diff --git a/Lib/test/test_linecache.py b/Lib/test/test_linecache.py
index b5f80a4f43e..7d14534d35b 100644
--- a/Lib/test/test_linecache.py
+++ b/Lib/test/test_linecache.py
@@ -3,7 +3,7 @@
import linecache
import unittest
import os.path
-from test import test_support as support
+from test import support
FILENAME = linecache.__file__
@@ -55,14 +55,16 @@ class LineCacheTests(unittest.TestCase):
# Check whether lines correspond to those from file iteration
for entry in TESTS:
filename = os.path.join(TEST_PATH, entry) + '.py'
- for index, line in enumerate(open(filename)):
- self.assertEqual(line, getline(filename, index + 1))
+ with open(filename) as file:
+ for index, line in enumerate(file):
+ self.assertEqual(line, getline(filename, index + 1))
# Check module loading
for entry in MODULES:
filename = os.path.join(MODULE_PATH, entry) + '.py'
- for index, line in enumerate(open(filename)):
- self.assertEqual(line, getline(filename, index + 1))
+ with open(filename) as file:
+ for index, line in enumerate(file):
+ self.assertEqual(line, getline(filename, index + 1))
# Check that bogus data isn't returned (issue #1309567)
empty = linecache.getlines('a/b/c/__init__.py')
diff --git a/Lib/test/test_linuxaudiodev.py b/Lib/test/test_linuxaudiodev.py
deleted file mode 100644
index fef46b45503..00000000000
--- a/Lib/test/test_linuxaudiodev.py
+++ /dev/null
@@ -1,99 +0,0 @@
-from test import test_support
-test_support.requires('audio')
-
-from test.test_support import findfile, run_unittest
-
-import errno
-import sys
-import audioop
-import unittest
-
-linuxaudiodev = test_support.import_module('linuxaudiodev', deprecated=True)
-sunaudio = test_support.import_module('sunaudio', deprecated=True)
-
-SND_FORMAT_MULAW_8 = 1
-
-class LinuxAudioDevTests(unittest.TestCase):
-
- def setUp(self):
- self.dev = linuxaudiodev.open('w')
-
- def tearDown(self):
- self.dev.close()
-
- def test_methods(self):
- # at least check that these methods can be invoked
- self.dev.bufsize()
- self.dev.obufcount()
- self.dev.obuffree()
- self.dev.getptr()
- self.dev.fileno()
-
- def test_play_sound_file(self):
- path = findfile("audiotest.au")
- fp = open(path, 'r')
- size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
- data = fp.read()
- fp.close()
-
- if enc != SND_FORMAT_MULAW_8:
- self.fail("Expect .au file with 8-bit mu-law samples")
-
- # convert the data to 16-bit signed
- data = audioop.ulaw2lin(data, 2)
-
- # set the data format
- if sys.byteorder == 'little':
- fmt = linuxaudiodev.AFMT_S16_LE
- else:
- fmt = linuxaudiodev.AFMT_S16_BE
-
- # set parameters based on .au file headers
- self.dev.setparameters(rate, 16, nchannels, fmt)
- self.dev.write(data)
- self.dev.flush()
-
- def test_errors(self):
- size = 8
- fmt = linuxaudiodev.AFMT_U8
- rate = 8000
- nchannels = 1
- try:
- self.dev.setparameters(-1, size, nchannels, fmt)
- except ValueError, err:
- self.assertEqual(err.args[0], "expected rate >= 0, not -1")
- try:
- self.dev.setparameters(rate, -2, nchannels, fmt)
- except ValueError, err:
- self.assertEqual(err.args[0], "expected sample size >= 0, not -2")
- try:
- self.dev.setparameters(rate, size, 3, fmt)
- except ValueError, err:
- self.assertEqual(err.args[0], "nchannels must be 1 or 2, not 3")
- try:
- self.dev.setparameters(rate, size, nchannels, 177)
- except ValueError, err:
- self.assertEqual(err.args[0], "unknown audio encoding: 177")
- try:
- self.dev.setparameters(rate, size, nchannels, linuxaudiodev.AFMT_U16_LE)
- except ValueError, err:
- self.assertEqual(err.args[0], "for linear unsigned 16-bit little-endian "
- "audio, expected sample size 16, not 8")
- try:
- self.dev.setparameters(rate, 16, nchannels, fmt)
- except ValueError, err:
- self.assertEqual(err.args[0], "for linear unsigned 8-bit audio, expected "
- "sample size 8, not 16")
-
-def test_main():
- try:
- dsp = linuxaudiodev.open('w')
- except linuxaudiodev.error, msg:
- if msg.args[0] in (errno.EACCES, errno.ENOENT, errno.ENODEV, errno.EBUSY):
- raise unittest.SkipTest(msg)
- raise
- dsp.close()
- run_unittest(LinuxAudioDevTests)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_list.py b/Lib/test/test_list.py
index 6e080dc342e..84b8afe3a43 100644
--- a/Lib/test/test_list.py
+++ b/Lib/test/test_list.py
@@ -1,5 +1,5 @@
import sys
-from test import test_support, list_tests
+from test import support, list_tests
class ListTest(list_tests.CommonTest):
type2test = list
@@ -30,7 +30,7 @@ class ListTest(list_tests.CommonTest):
# thread for the details:
# http://sources.redhat.com/ml/newlib/2002/msg00369.html
- self.assertRaises(MemoryError, list, xrange(sys.maxint // 2))
+ self.assertRaises(MemoryError, list, range(sys.maxsize // 2))
# This code used to segfault in Py2.4a3
x = []
@@ -38,7 +38,7 @@ class ListTest(list_tests.CommonTest):
self.assertEqual(x, [])
def test_truth(self):
- super(ListTest, self).test_truth()
+ super().test_truth()
self.assertTrue(not [])
self.assertTrue([42])
@@ -46,32 +46,51 @@ class ListTest(list_tests.CommonTest):
self.assertTrue([] is not [])
def test_len(self):
- super(ListTest, self).test_len()
+ super().test_len()
self.assertEqual(len([]), 0)
self.assertEqual(len([0]), 1)
self.assertEqual(len([0, 1, 2]), 3)
def test_overflow(self):
lst = [4, 5, 6, 7]
- n = int((sys.maxint*2+2) // len(lst))
+ n = int((sys.maxsize*2+2) // len(lst))
def mul(a, b): return a * b
def imul(a, b): a *= b
self.assertRaises((MemoryError, OverflowError), mul, lst, n)
self.assertRaises((MemoryError, OverflowError), imul, lst, n)
+ def test_repr_large(self):
+ # Check the repr of large list objects
+ def check(n):
+ l = [0] * n
+ s = repr(l)
+ self.assertEqual(s,
+ '[' + ', '.join(['0'] * n) + ']')
+ check(10) # check our checking code
+ check(1000000)
+
+
+ def test_no_comdat_folding(self):
+ # Issue 8847: In the PGO build, the MSVC linker's COMDAT folding
+ # optimization causes failures in code that relies on distinct
+ # function addresses.
+ class L(list): pass
+ with self.assertRaises(TypeError):
+ (3,) + L([1,2])
+
def test_main(verbose=None):
- test_support.run_unittest(ListTest)
+ support.run_unittest(ListTest)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(ListTest)
+ for i in range(len(counts)):
+ support.run_unittest(ListTest)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
diff --git a/Lib/test/test_listcomps.py b/Lib/test/test_listcomps.py
new file mode 100644
index 00000000000..1f8265f077e
--- /dev/null
+++ b/Lib/test/test_listcomps.py
@@ -0,0 +1,148 @@
+doctests = """
+########### Tests borrowed from or inspired by test_genexps.py ############
+
+Test simple loop with conditional
+
+ >>> sum([i*i for i in range(100) if i&1 == 1])
+ 166650
+
+Test simple nesting
+
+ >>> [(i,j) for i in range(3) for j in range(4)]
+ [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3), (2, 0), (2, 1), (2, 2), (2, 3)]
+
+Test nesting with the inner expression dependent on the outer
+
+ >>> [(i,j) for i in range(4) for j in range(i)]
+ [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2)]
+
+Make sure the induction variable is not exposed
+
+ >>> i = 20
+ >>> sum([i*i for i in range(100)])
+ 328350
+
+ >>> i
+ 20
+
+Verify that syntax error's are raised for listcomps used as lvalues
+
+ >>> [y for y in (1,2)] = 10 # doctest: +IGNORE_EXCEPTION_DETAIL
+ Traceback (most recent call last):
+ ...
+ SyntaxError: ...
+
+ >>> [y for y in (1,2)] += 10 # doctest: +IGNORE_EXCEPTION_DETAIL
+ Traceback (most recent call last):
+ ...
+ SyntaxError: ...
+
+
+########### Tests borrowed from or inspired by test_generators.py ############
+
+Make a nested list comprehension that acts like range()
+
+ >>> def frange(n):
+ ... return [i for i in range(n)]
+ >>> frange(10)
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+Same again, only as a lambda expression instead of a function definition
+
+ >>> lrange = lambda n: [i for i in range(n)]
+ >>> lrange(10)
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+
+Generators can call other generators:
+
+ >>> def grange(n):
+ ... for x in [i for i in range(n)]:
+ ... yield x
+ >>> list(grange(5))
+ [0, 1, 2, 3, 4]
+
+
+Make sure that None is a valid return value
+
+ >>> [None for i in range(10)]
+ [None, None, None, None, None, None, None, None, None, None]
+
+########### Tests for various scoping corner cases ############
+
+Return lambdas that use the iteration variable as a default argument
+
+ >>> items = [(lambda i=i: i) for i in range(5)]
+ >>> [x() for x in items]
+ [0, 1, 2, 3, 4]
+
+Same again, only this time as a closure variable
+
+ >>> items = [(lambda: i) for i in range(5)]
+ >>> [x() for x in items]
+ [4, 4, 4, 4, 4]
+
+Another way to test that the iteration variable is local to the list comp
+
+ >>> items = [(lambda: i) for i in range(5)]
+ >>> i = 20
+ >>> [x() for x in items]
+ [4, 4, 4, 4, 4]
+
+And confirm that a closure can jump over the list comp scope
+
+ >>> items = [(lambda: y) for i in range(5)]
+ >>> y = 2
+ >>> [x() for x in items]
+ [2, 2, 2, 2, 2]
+
+We also repeat each of the above scoping tests inside a function
+
+ >>> def test_func():
+ ... items = [(lambda i=i: i) for i in range(5)]
+ ... return [x() for x in items]
+ >>> test_func()
+ [0, 1, 2, 3, 4]
+
+ >>> def test_func():
+ ... items = [(lambda: i) for i in range(5)]
+ ... return [x() for x in items]
+ >>> test_func()
+ [4, 4, 4, 4, 4]
+
+ >>> def test_func():
+ ... items = [(lambda: i) for i in range(5)]
+ ... i = 20
+ ... return [x() for x in items]
+ >>> test_func()
+ [4, 4, 4, 4, 4]
+
+ >>> def test_func():
+ ... items = [(lambda: y) for i in range(5)]
+ ... y = 2
+ ... return [x() for x in items]
+ >>> test_func()
+ [2, 2, 2, 2, 2]
+
+"""
+
+
+__test__ = {'doctests' : doctests}
+
+def test_main(verbose=None):
+ import sys
+ from test import support
+ from test import test_listcomps
+ support.run_doctest(test_listcomps, verbose)
+
+ # verify reference counting
+ if verbose and hasattr(sys, "gettotalrefcount"):
+ import gc
+ counts = [None] * 5
+ for i in range(len(counts)):
+ support.run_doctest(test_genexps, verbose)
+ gc.collect()
+ counts[i] = sys.gettotalrefcount()
+ print(counts)
+
+if __name__ == "__main__":
+ test_main(verbose=True)
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index 4575592a260..8f7574b9047 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -1,10 +1,9 @@
-from test.test_support import run_unittest, verbose
+from test.support import run_unittest, verbose
import unittest
import locale
import sys
import codecs
-
enUS_locale = None
def get_enUS_locale():
@@ -17,10 +16,10 @@ def get_enUS_locale():
# haven't had time yet to verify if tests work on OSX 10.5
# (10.4 is known to be bad)
raise unittest.SkipTest("Locale support on MacOSX is minimal")
- if sys.platform.startswith("win"):
+ elif sys.platform.startswith("win"):
tlocs = ("En", "English")
else:
- tlocs = ("en_US.UTF-8", "en_US.US-ASCII", "en_US")
+ tlocs = ("en_US.UTF-8", "en_US.ISO8859-1", "en_US.US-ASCII", "en_US")
oldlocale = locale.setlocale(locale.LC_NUMERIC)
for tloc in tlocs:
try:
@@ -44,7 +43,7 @@ class BaseLocalizedTest(unittest.TestCase):
self.oldlocale = locale.setlocale(self.locale_type)
locale.setlocale(self.locale_type, enUS_locale)
if verbose:
- print "testing with \"%s\"..." % enUS_locale,
+ print("testing with \"%s\"..." % enUS_locale, end=' ')
def tearDown(self):
locale.setlocale(self.locale_type, self.oldlocale)
@@ -61,7 +60,6 @@ class BaseCookedTest(unittest.TestCase):
def tearDown(self):
locale._override_localeconv = {}
-
class CCookedTest(BaseCookedTest):
# A cooked "C" locale
@@ -116,7 +114,7 @@ class FrFRCookedTest(BaseCookedTest):
# and a non-ASCII currency symbol.
cooked_values = {
- 'currency_symbol': '\xe2\x82\xac',
+ 'currency_symbol': '\u20ac',
'decimal_point': ',',
'frac_digits': 2,
'grouping': [3, 3, 0],
@@ -328,7 +326,7 @@ class TestFrFRNumberFormatting(FrFRCookedTest, BaseFormattingTest):
self._test_format("%-10d", 4200, grouping=True, out='4 200'.ljust(10))
def test_currency(self):
- euro = u'\u20ac'.encode('utf-8')
+ euro = '\u20ac'
self._test_currency(50000, "50000,00 " + euro)
self._test_currency(50000, "50 000,00 " + euro, grouping=True)
# XXX is the trailing space a bug?
@@ -336,40 +334,37 @@ class TestFrFRNumberFormatting(FrFRCookedTest, BaseFormattingTest):
grouping=True, international=True)
-class TestStringMethods(BaseLocalizedTest):
- locale_type = locale.LC_CTYPE
-
- if sys.platform != 'sunos5' and not sys.platform.startswith("win"):
- # Test BSD Rune locale's bug for isctype functions.
-
- def test_isspace(self):
- self.assertEqual('\x20'.isspace(), True)
- self.assertEqual('\xa0'.isspace(), False)
- self.assertEqual('\xa1'.isspace(), False)
+class TestCollation(unittest.TestCase):
+ # Test string collation functions
- def test_isalpha(self):
- self.assertEqual('\xc0'.isalpha(), False)
+ def test_strcoll(self):
+ self.assertLess(locale.strcoll('a', 'b'), 0)
+ self.assertEqual(locale.strcoll('a', 'a'), 0)
+ self.assertGreater(locale.strcoll('b', 'a'), 0)
- def test_isalnum(self):
- self.assertEqual('\xc0'.isalnum(), False)
+ def test_strxfrm(self):
+ self.assertLess(locale.strxfrm('a'), locale.strxfrm('b'))
- def test_isupper(self):
- self.assertEqual('\xc0'.isupper(), False)
- def test_islower(self):
- self.assertEqual('\xc0'.islower(), False)
+class TestEnUSCollation(BaseLocalizedTest, TestCollation):
+ # Test string collation functions with a real English locale
- def test_lower(self):
- self.assertEqual('\xcc\x85'.lower(), '\xcc\x85')
+ locale_type = locale.LC_ALL
- def test_upper(self):
- self.assertEqual('\xed\x95\xa0'.upper(), '\xed\x95\xa0')
+ def setUp(self):
+ enc = codecs.lookup(locale.getpreferredencoding(False) or 'ascii').name
+ if enc not in ('utf-8', 'iso8859-1', 'cp1252'):
+ raise unittest.SkipTest('encoding not suitable')
+ if enc != 'iso8859-1' and (sys.platform == 'darwin' or
+ sys.platform.startswith('freebsd')):
+ raise unittest.SkipTest('wcscoll/wcsxfrm have known bugs')
+ BaseLocalizedTest.setUp(self)
- def test_strip(self):
- self.assertEqual('\xed\x95\xa0'.strip(), '\xed\x95\xa0')
+ def test_strcoll_with_diacritic(self):
+ self.assertLess(locale.strcoll('à', 'b'), 0)
- def test_split(self):
- self.assertEqual('\xec\xa0\xbc'.split(), ['\xec\xa0\xbc'])
+ def test_strxfrm_with_diacritic(self):
+ self.assertLess(locale.strxfrm('à'), locale.strxfrm('b'))
class TestMiscellaneous(unittest.TestCase):
@@ -380,10 +375,10 @@ class TestMiscellaneous(unittest.TestCase):
# If encoding non-empty, make sure it is valid
codecs.lookup(enc)
- if hasattr(locale, "strcoll"):
- def test_strcoll_3303(self):
- # test crasher from bug #3303
- self.assertRaises(TypeError, locale.strcoll, u"a", None)
+ def test_strcoll_3303(self):
+ # test crasher from bug #3303
+ self.assertRaises(TypeError, locale.strcoll, "a", None)
+ self.assertRaises(TypeError, locale.strcoll, b"a", None)
def test_setlocale_category(self):
locale.setlocale(locale.LC_ALL)
@@ -398,21 +393,24 @@ class TestMiscellaneous(unittest.TestCase):
def test_getsetlocale_issue1813(self):
# Issue #1813: setting and getting the locale under a Turkish locale
- oldlocale = locale.getlocale()
+ oldlocale = locale.setlocale(locale.LC_CTYPE)
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
try:
locale.setlocale(locale.LC_CTYPE, 'tr_TR')
except locale.Error:
# Unsupported locale on this system
self.skipTest('test needs Turkish locale')
- loc = locale.getlocale()
+ loc = locale.getlocale(locale.LC_CTYPE)
locale.setlocale(locale.LC_CTYPE, loc)
- self.assertEqual(loc, locale.getlocale())
+ self.assertEqual(loc, locale.getlocale(locale.LC_CTYPE))
+
+ def test_invalid_locale_format_in_localetuple(self):
+ with self.assertRaises(TypeError):
+ locale.setlocale(locale.LC_ALL, b'fi_FI')
- def test_normalize_issue12752(self):
- # Issue #1813 caused a regression where locale.normalize() would no
- # longer accept unicode strings.
- self.assertEqual(locale.normalize(u'en_US'), 'en_US.ISO8859-1')
+ def test_invalid_iterable_in_localetuple(self):
+ with self.assertRaises(TypeError):
+ locale.setlocale(locale.LC_ALL, (b'not', b'valid'))
def test_main():
@@ -423,15 +421,16 @@ def test_main():
TestEnUSNumberFormatting,
TestCNumberFormatting,
TestFrFRNumberFormatting,
+ TestCollation
]
# SkipTest can't be raised inside unittests, handle it manually instead
try:
get_enUS_locale()
except unittest.SkipTest as e:
if verbose:
- print "Some tests will be disabled: %s" % e
+ print("Some tests will be disabled: %s" % e)
else:
- tests += [TestNumberFormatting, TestStringMethods]
+ tests += [TestNumberFormatting, TestEnUSCollation]
run_unittest(*tests)
if __name__ == '__main__':
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 88332b5a854..2a3c780d2c4 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -26,20 +26,23 @@ import logging.handlers
import logging.config
import codecs
-import cPickle
-import cStringIO
+import datetime
+import pickle
+import io
import gc
import json
import os
+import queue
import random
import re
import select
import socket
-from SocketServer import ThreadingTCPServer, StreamRequestHandler
+from socketserver import ThreadingTCPServer, StreamRequestHandler
import struct
import sys
import tempfile
-from test.test_support import captured_stdout, run_with_locale, run_unittest
+from test.support import captured_stdout, run_with_locale, run_unittest, patch
+from test.support import TestHandler, Matcher
import textwrap
import time
import unittest
@@ -50,6 +53,7 @@ try:
except ImportError:
threading = None
+
class BaseTest(unittest.TestCase):
"""Base class for logging tests."""
@@ -66,26 +70,38 @@ class BaseTest(unittest.TestCase):
try:
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
- self.saved_loggers = logger_dict.copy()
+ self.saved_loggers = saved_loggers = logger_dict.copy()
self.saved_level_names = logging._levelNames.copy()
+ self.logger_states = logger_states = {}
+ for name in saved_loggers:
+ logger_states[name] = getattr(saved_loggers[name],
+ 'disabled', None)
finally:
logging._releaseLock()
# Set two unused loggers: one non-ASCII and one Unicode.
# This is to test correct operation when sorting existing
# loggers in the configuration code. See issue 8201.
- logging.getLogger("\xab\xd7\xbb")
- logging.getLogger(u"\u013f\u00d6\u0047")
+ self.logger1 = logging.getLogger("\xab\xd7\xbb")
+ self.logger2 = logging.getLogger("\u013f\u00d6\u0047")
self.root_logger = logging.getLogger("")
self.original_logging_level = self.root_logger.getEffectiveLevel()
- self.stream = cStringIO.StringIO()
+ self.stream = io.StringIO()
self.root_logger.setLevel(logging.DEBUG)
self.root_hdlr = logging.StreamHandler(self.stream)
self.root_formatter = logging.Formatter(self.log_format)
self.root_hdlr.setFormatter(self.root_formatter)
+ if self.logger1.hasHandlers():
+ hlist = self.logger1.handlers + self.root_logger.handlers
+ raise AssertionError('Unexpected handlers: %s' % hlist)
+ if self.logger2.hasHandlers():
+ hlist = self.logger2.handlers + self.root_logger.handlers
+ raise AssertionError('Unexpected handlers: %s' % hlist)
self.root_logger.addHandler(self.root_hdlr)
+ self.assertTrue(self.logger1.hasHandlers())
+ self.assertTrue(self.logger2.hasHandlers())
def tearDown(self):
"""Remove our logging stream, and restore the original logging
@@ -107,6 +123,10 @@ class BaseTest(unittest.TestCase):
loggerDict = logging.getLogger().manager.loggerDict
loggerDict.clear()
loggerDict.update(self.saved_loggers)
+ logger_states = self.logger_states
+ for name in self.logger_states:
+ if logger_states[name] is not None:
+ self.saved_loggers[name].disabled = logger_states[name]
finally:
logging._releaseLock()
@@ -122,7 +142,8 @@ class BaseTest(unittest.TestCase):
except AttributeError:
# StringIO.StringIO lacks a reset() method.
actual_lines = stream.getvalue().splitlines()
- self.assertEqual(len(actual_lines), len(expected_values))
+ self.assertEqual(len(actual_lines), len(expected_values),
+ '%s vs. %s' % (actual_lines, expected_values))
for actual, expected in zip(actual_lines, expected_values):
match = pat.search(actual)
if not match:
@@ -149,7 +170,7 @@ class BuiltinLevelsTest(BaseTest):
ERR = logging.getLogger("ERR")
ERR.setLevel(logging.ERROR)
- INF = logging.getLogger("INF")
+ INF = logging.LoggerAdapter(logging.getLogger("INF"), {})
INF.setLevel(logging.INFO)
DEB = logging.getLogger("DEB")
DEB.setLevel(logging.DEBUG)
@@ -305,6 +326,35 @@ class BasicFilterTest(BaseTest):
finally:
handler.removeFilter(filter_)
+ def test_callable_filter(self):
+ # Only messages satisfying the specified criteria pass through the
+ # filter.
+
+ def filterfunc(record):
+ parts = record.name.split('.')
+ prefix = '.'.join(parts[:2])
+ return prefix == 'spam.eggs'
+
+ handler = self.root_logger.handlers[0]
+ try:
+ handler.addFilter(filterfunc)
+ spam = logging.getLogger("spam")
+ spam_eggs = logging.getLogger("spam.eggs")
+ spam_eggs_fish = logging.getLogger("spam.eggs.fish")
+ spam_bakedbeans = logging.getLogger("spam.bakedbeans")
+
+ spam.info(self.next_message())
+ spam_eggs.info(self.next_message()) # Good.
+ spam_eggs_fish.info(self.next_message()) # Good.
+ spam_bakedbeans.info(self.next_message())
+
+ self.assert_log_lines([
+ ('spam.eggs', 'INFO', '2'),
+ ('spam.eggs.fish', 'INFO', '3'),
+ ])
+ finally:
+ handler.removeFilter(filterfunc)
+
#
# First, we define our levels. There can be as many as you want - the only
@@ -715,7 +765,7 @@ class ConfigFileTest(BaseTest):
"""
def apply_config(self, conf):
- file = cStringIO.StringIO(textwrap.dedent(conf))
+ file = io.StringIO(textwrap.dedent(conf))
logging.config.fileConfig(file)
def test_config0_ok(self):
@@ -750,11 +800,11 @@ class ConfigFileTest(BaseTest):
def test_config2_failure(self):
# A simple config file which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config2)
+ self.assertRaises(Exception, self.apply_config, self.config2)
def test_config3_failure(self):
# A simple config file which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config3)
+ self.assertRaises(Exception, self.apply_config, self.config3)
def test_config4_ok(self):
# A config file specifying a custom formatter class.
@@ -844,7 +894,7 @@ class LogRecordStreamHandler(StreamRequestHandler):
self.handle_log_record(record)
def unpickle(self, data):
- return cPickle.loads(data)
+ return pickle.loads(data)
def handle_log_record(self, record):
# If the end-of-messages sentinel is seen, tell the server to
@@ -987,11 +1037,12 @@ class EncodingTest(BaseTest):
def test_encoding_plain_file(self):
# In Python 2.x, a plain file object is treated as having no encoding.
log = logging.getLogger("test")
- fn = tempfile.mktemp(".log")
+ fd, fn = tempfile.mkstemp(".log", "test_logging-1-")
+ os.close(fd)
# the non-ascii data we write to the log.
data = "foo\x80"
try:
- handler = logging.FileHandler(fn)
+ handler = logging.FileHandler(fn, encoding="utf-8")
log.addHandler(handler)
try:
# write non-ascii data to the log.
@@ -1000,7 +1051,7 @@ class EncodingTest(BaseTest):
log.removeHandler(handler)
handler.close()
# check we wrote exactly those bytes, ignoring trailing \n etc
- f = open(fn)
+ f = open(fn, encoding="utf-8")
try:
self.assertEqual(f.read().rstrip(), data)
finally:
@@ -1012,11 +1063,11 @@ class EncodingTest(BaseTest):
def test_encoding_cyrillic_unicode(self):
log = logging.getLogger("test")
#Get a message in Unicode: Do svidanya in Cyrillic (meaning goodbye)
- message = u'\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
+ message = '\u0434\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'
#Ensure it's written in a Cyrillic encoding
writer_class = codecs.getwriter('cp1251')
writer_class.encoding = 'cp1251'
- stream = cStringIO.StringIO()
+ stream = io.BytesIO()
writer = writer_class(stream, 'strict')
handler = logging.StreamHandler(writer)
log.addHandler(handler)
@@ -1028,7 +1079,7 @@ class EncodingTest(BaseTest):
# check we wrote exactly those bytes, ignoring trailing \n etc
s = stream.getvalue()
#Compare against what the data should be when encoded in CP-1251
- self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
+ self.assertEqual(s, b'\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
class WarningsTest(BaseTest):
@@ -1038,7 +1089,7 @@ class WarningsTest(BaseTest):
logging.captureWarnings(True)
try:
warnings.filterwarnings("always", category=UserWarning)
- file = cStringIO.StringIO()
+ file = io.StringIO()
h = logging.StreamHandler(file)
logger = logging.getLogger("py.warnings")
logger.addHandler(h)
@@ -1049,7 +1100,7 @@ class WarningsTest(BaseTest):
self.assertTrue(s.find("UserWarning: I'm warning you...\n") > 0)
#See if an explicit file uses the original implementation
- file = cStringIO.StringIO()
+ file = io.StringIO()
warnings.showwarning("Explicit", UserWarning, "dummy.py", 42,
file, "Dummy line")
s = file.getvalue()
@@ -1124,6 +1175,33 @@ class ConfigDictTest(BaseTest):
},
}
+ # config1a moves the handler to the root. Used with config8a
+ config1a = {
+ 'version': 1,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler.parser' : {
+ 'level' : 'DEBUG',
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ 'handlers' : ['hand1'],
+ },
+ }
+
# config2 has a subtle configuration error that should be reported
config2 = {
'version': 1,
@@ -1374,6 +1452,9 @@ class ConfigDictTest(BaseTest):
},
}
+ # config8 defines both compiler and compiler.lexer
+ # so compiler.parser should not be disabled (since
+ # compiler is defined)
config8 = {
'version': 1,
'disable_existing_loggers' : False,
@@ -1403,6 +1484,36 @@ class ConfigDictTest(BaseTest):
},
}
+ # config8a disables existing loggers
+ config8a = {
+ 'version': 1,
+ 'disable_existing_loggers' : True,
+ 'formatters': {
+ 'form1' : {
+ 'format' : '%(levelname)s ++ %(message)s',
+ },
+ },
+ 'handlers' : {
+ 'hand1' : {
+ 'class' : 'logging.StreamHandler',
+ 'formatter' : 'form1',
+ 'level' : 'NOTSET',
+ 'stream' : 'ext://sys.stdout',
+ },
+ },
+ 'loggers' : {
+ 'compiler' : {
+ 'level' : 'DEBUG',
+ 'handlers' : ['hand1'],
+ },
+ 'compiler.lexer' : {
+ },
+ },
+ 'root' : {
+ 'level' : 'WARNING',
+ },
+ }
+
config9 = {
'version': 1,
'formatters': {
@@ -1620,19 +1731,19 @@ class ConfigDictTest(BaseTest):
def test_config2_failure(self):
# A simple config which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config2)
+ self.assertRaises(Exception, self.apply_config, self.config2)
def test_config2a_failure(self):
# A simple config which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config2a)
+ self.assertRaises(Exception, self.apply_config, self.config2a)
def test_config2b_failure(self):
# A simple config which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config2b)
+ self.assertRaises(Exception, self.apply_config, self.config2b)
def test_config3_failure(self):
# A simple config which overrides the default settings.
- self.assertRaises(StandardError, self.apply_config, self.config3)
+ self.assertRaises(Exception, self.apply_config, self.config3)
def test_config4_ok(self):
# A config specifying a custom formatter class.
@@ -1668,7 +1779,7 @@ class ConfigDictTest(BaseTest):
self.test_config1_ok(config=self.config5)
def test_config6_failure(self):
- self.assertRaises(StandardError, self.apply_config, self.config6)
+ self.assertRaises(Exception, self.apply_config, self.config6)
def test_config7_ok(self):
with captured_stdout() as output:
@@ -1703,7 +1814,7 @@ class ConfigDictTest(BaseTest):
with captured_stdout() as output:
self.apply_config(self.config1)
logger = logging.getLogger("compiler.parser")
- # Both will output a message
+ # All will output a message
logger.info(self.next_message())
logger.error(self.next_message())
self.assert_log_lines([
@@ -1732,6 +1843,49 @@ class ConfigDictTest(BaseTest):
# Original logger output is empty.
self.assert_log_lines([])
+ def test_config_8a_ok(self):
+ with captured_stdout() as output:
+ self.apply_config(self.config1a)
+ logger = logging.getLogger("compiler.parser")
+ # See issue #11424. compiler-hyphenated sorts
+ # between compiler and compiler.xyz and this
+ # was preventing compiler.xyz from being included
+ # in the child loggers of compiler because of an
+ # overzealous loop termination condition.
+ hyphenated = logging.getLogger('compiler-hyphenated')
+ # All will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ hyphenated.critical(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '1'),
+ ('ERROR', '2'),
+ ('CRITICAL', '3'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+ with captured_stdout() as output:
+ self.apply_config(self.config8a)
+ logger = logging.getLogger("compiler.parser")
+ self.assertFalse(logger.disabled)
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ logger = logging.getLogger("compiler.lexer")
+ # Both will output a message
+ logger.info(self.next_message())
+ logger.error(self.next_message())
+ # Will not appear
+ hyphenated.critical(self.next_message())
+ self.assert_log_lines([
+ ('INFO', '4'),
+ ('ERROR', '5'),
+ ('INFO', '6'),
+ ('ERROR', '7'),
+ ], stream=output)
+ # Original logger output is empty.
+ self.assert_log_lines([])
+
def test_config_9_ok(self):
with captured_stdout() as output:
self.apply_config(self.config9)
@@ -1773,13 +1927,14 @@ class ConfigDictTest(BaseTest):
self.test_config1_ok(self.config11)
def test_config12_failure(self):
- self.assertRaises(StandardError, self.apply_config, self.config12)
+ self.assertRaises(Exception, self.apply_config, self.config12)
def test_config13_failure(self):
- self.assertRaises(StandardError, self.apply_config, self.config13)
+ self.assertRaises(Exception, self.apply_config, self.config13)
@unittest.skipUnless(threading, 'listen() needs threading to work')
def setup_via_listener(self, text):
+ text = text.encode("utf-8")
# Ask for a randomly assigned port (by using port 0)
t = logging.config.listen(0)
t.start()
@@ -1875,6 +2030,305 @@ class ChildLoggerTest(BaseTest):
self.assertTrue(c2 is c3)
+class DerivedLogRecord(logging.LogRecord):
+ pass
+
+class LogRecordFactoryTest(BaseTest):
+
+ def setUp(self):
+ class CheckingFilter(logging.Filter):
+ def __init__(self, cls):
+ self.cls = cls
+
+ def filter(self, record):
+ t = type(record)
+ if t is not self.cls:
+ msg = 'Unexpected LogRecord type %s, expected %s' % (t,
+ self.cls)
+ raise TypeError(msg)
+ return True
+
+ BaseTest.setUp(self)
+ self.filter = CheckingFilter(DerivedLogRecord)
+ self.root_logger.addFilter(self.filter)
+ self.orig_factory = logging.getLogRecordFactory()
+
+ def tearDown(self):
+ self.root_logger.removeFilter(self.filter)
+ BaseTest.tearDown(self)
+ logging.setLogRecordFactory(self.orig_factory)
+
+ def test_logrecord_class(self):
+ self.assertRaises(TypeError, self.root_logger.warning,
+ self.next_message())
+ logging.setLogRecordFactory(DerivedLogRecord)
+ self.root_logger.error(self.next_message())
+ self.assert_log_lines([
+ ('root', 'ERROR', '2'),
+ ])
+
+
+class QueueHandlerTest(BaseTest):
+ # Do not bother with a logger name group.
+ expected_log_pat = r"^[\w.]+ -> ([\w]+): ([\d]+)$"
+
+ def setUp(self):
+ BaseTest.setUp(self)
+ self.queue = queue.Queue(-1)
+ self.que_hdlr = logging.handlers.QueueHandler(self.queue)
+ self.que_logger = logging.getLogger('que')
+ self.que_logger.propagate = False
+ self.que_logger.setLevel(logging.WARNING)
+ self.que_logger.addHandler(self.que_hdlr)
+
+ def tearDown(self):
+ self.que_hdlr.close()
+ BaseTest.tearDown(self)
+
+ def test_queue_handler(self):
+ self.que_logger.debug(self.next_message())
+ self.assertRaises(queue.Empty, self.queue.get_nowait)
+ self.que_logger.info(self.next_message())
+ self.assertRaises(queue.Empty, self.queue.get_nowait)
+ msg = self.next_message()
+ self.que_logger.warning(msg)
+ data = self.queue.get_nowait()
+ self.assertTrue(isinstance(data, logging.LogRecord))
+ self.assertEqual(data.name, self.que_logger.name)
+ self.assertEqual((data.msg, data.args), (msg, None))
+
+ @unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
+ 'logging.handlers.QueueListener required for this test')
+ def test_queue_listener(self):
+ handler = TestHandler(Matcher())
+ listener = logging.handlers.QueueListener(self.queue, handler)
+ listener.start()
+ try:
+ self.que_logger.warning(self.next_message())
+ self.que_logger.error(self.next_message())
+ self.que_logger.critical(self.next_message())
+ finally:
+ listener.stop()
+ self.assertTrue(handler.matches(levelno=logging.WARNING, message='1'))
+ self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
+ self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))
+
+
+class FormatterTest(unittest.TestCase):
+ def setUp(self):
+ self.common = {
+ 'name': 'formatter.test',
+ 'level': logging.DEBUG,
+ 'pathname': os.path.join('path', 'to', 'dummy.ext'),
+ 'lineno': 42,
+ 'exc_info': None,
+ 'func': None,
+ 'msg': 'Message with %d %s',
+ 'args': (2, 'placeholders'),
+ }
+ self.variants = {
+ }
+
+ def get_record(self, name=None):
+ result = dict(self.common)
+ if name is not None:
+ result.update(self.variants[name])
+ return logging.makeLogRecord(result)
+
+ def test_percent(self):
+ # Test %-formatting
+ r = self.get_record()
+ f = logging.Formatter('${%(message)s}')
+ self.assertEqual(f.format(r), '${Message with 2 placeholders}')
+ f = logging.Formatter('%(random)s')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('%(asctime)s')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('%(asctime)-15s')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime')
+ self.assertFalse(f.usesTime())
+
+ def test_braces(self):
+ # Test {}-formatting
+ r = self.get_record()
+ f = logging.Formatter('$%{message}%$', style='{')
+ self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
+ f = logging.Formatter('{random}', style='{')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('{asctime}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('{asctime!s:15}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('{asctime:15}', style='{')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime', style='{')
+ self.assertFalse(f.usesTime())
+
+ def test_dollars(self):
+ # Test $-formatting
+ r = self.get_record()
+ f = logging.Formatter('$message', style='$')
+ self.assertEqual(f.format(r), 'Message with 2 placeholders')
+ f = logging.Formatter('$$%${message}%$$', style='$')
+ self.assertEqual(f.format(r), '$%Message with 2 placeholders%$')
+ f = logging.Formatter('${random}', style='$')
+ self.assertRaises(KeyError, f.format, r)
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('${asctime}', style='$')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('${asctime', style='$')
+ self.assertFalse(f.usesTime())
+ f = logging.Formatter('$asctime', style='$')
+ self.assertTrue(f.usesTime())
+ f = logging.Formatter('asctime', style='$')
+ self.assertFalse(f.usesTime())
+
+class LastResortTest(BaseTest):
+ def test_last_resort(self):
+ # Test the last resort handler
+ root = self.root_logger
+ root.removeHandler(self.root_hdlr)
+ old_stderr = sys.stderr
+ old_lastresort = logging.lastResort
+ old_raise_exceptions = logging.raiseExceptions
+ try:
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), 'This is your final chance!\n')
+ #No handlers and no last resort, so 'No handlers' message
+ logging.lastResort = None
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), 'No handlers could be found for logger "root"\n')
+ # 'No handlers' message only printed once
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), '')
+ root.manager.emittedNoHandlerWarning = False
+ #If raiseExceptions is False, no message is printed
+ logging.raiseExceptions = False
+ sys.stderr = sio = io.StringIO()
+ root.warning('This is your final chance!')
+ self.assertEqual(sio.getvalue(), '')
+ finally:
+ sys.stderr = old_stderr
+ root.addHandler(self.root_hdlr)
+ logging.lastResort = old_lastresort
+ logging.raiseExceptions = old_raise_exceptions
+
+
+class BaseFileTest(BaseTest):
+ "Base class for handler tests that write log files"
+
+ def setUp(self):
+ BaseTest.setUp(self)
+ fd, self.fn = tempfile.mkstemp(".log", "test_logging-2-")
+ os.close(fd)
+ self.rmfiles = []
+
+ def tearDown(self):
+ for fn in self.rmfiles:
+ os.unlink(fn)
+ if os.path.exists(self.fn):
+ os.unlink(self.fn)
+ BaseTest.tearDown(self)
+
+ def assertLogFile(self, filename):
+ "Assert a log file is there and register it for deletion"
+ self.assertTrue(os.path.exists(filename),
+ msg="Log file %r does not exist")
+ self.rmfiles.append(filename)
+
+
+class RotatingFileHandlerTest(BaseFileTest):
+ def next_rec(self):
+ return logging.LogRecord('n', logging.DEBUG, 'p', 1,
+ self.next_message(), None, None, None)
+
+ def test_should_not_rollover(self):
+ # If maxbytes is zero rollover never occurs
+ rh = logging.handlers.RotatingFileHandler(self.fn, maxBytes=0)
+ self.assertFalse(rh.shouldRollover(None))
+ rh.close()
+
+ def test_should_rollover(self):
+ rh = logging.handlers.RotatingFileHandler(self.fn, maxBytes=1)
+ self.assertTrue(rh.shouldRollover(self.next_rec()))
+ rh.close()
+
+ def test_file_created(self):
+ # checks that the file is created and assumes it was created
+ # by us
+ rh = logging.handlers.RotatingFileHandler(self.fn)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn)
+ rh.close()
+
+ def test_rollover_filenames(self):
+ rh = logging.handlers.RotatingFileHandler(
+ self.fn, backupCount=2, maxBytes=1)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn)
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn + ".1")
+ rh.emit(self.next_rec())
+ self.assertLogFile(self.fn + ".2")
+ self.assertFalse(os.path.exists(self.fn + ".3"))
+ rh.close()
+
+class TimedRotatingFileHandlerTest(BaseFileTest):
+ # test methods added below
+ pass
+
+def secs(**kw):
+ return datetime.timedelta(**kw) // datetime.timedelta(seconds=1)
+
+for when, exp in (('S', 1),
+ ('M', 60),
+ ('H', 60 * 60),
+ ('D', 60 * 60 * 24),
+ ('MIDNIGHT', 60 * 60 * 24),
+ # current time (epoch start) is a Thursday, W0 means Monday
+ ('W0', secs(days=4, hours=24)),
+ ):
+ def test_compute_rollover(self, when=when, exp=exp):
+ rh = logging.handlers.TimedRotatingFileHandler(
+ self.fn, when=when, interval=1, backupCount=0, utc=True)
+ currentTime = 0.0
+ actual = rh.computeRollover(currentTime)
+ if exp != actual:
+ # Failures occur on some systems for MIDNIGHT and W0.
+ # Print detailed calculation for MIDNIGHT so we can try to see
+ # what's going on
+ if when == 'MIDNIGHT':
+ try:
+ if rh.utc:
+ t = time.gmtime(currentTime)
+ else:
+ t = time.localtime(currentTime)
+ currentHour = t[3]
+ currentMinute = t[4]
+ currentSecond = t[5]
+ # r is the number of seconds left between now and midnight
+ r = logging.handlers._MIDNIGHT - ((currentHour * 60 +
+ currentMinute) * 60 +
+ currentSecond)
+ result = currentTime + r
+ print('t: %s (%s)' % (t, rh.utc), file=sys.stderr)
+ print('currentHour: %s' % currentHour, file=sys.stderr)
+ print('currentMinute: %s' % currentMinute, file=sys.stderr)
+ print('currentSecond: %s' % currentSecond, file=sys.stderr)
+ print('r: %s' % r, file=sys.stderr)
+ print('result: %s' % result, file=sys.stderr)
+ except Exception:
+ print('exception in diagnostic code: %s' % sys.exc_info()[1], file=sys.stderr)
+ self.assertEqual(exp, actual)
+ rh.close()
+ setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover)
+
class HandlerTest(BaseTest):
@unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
@@ -1908,14 +2362,167 @@ class HandlerTest(BaseTest):
h.handle(r)
finally:
remover.join()
- try:
- h.close()
- except ValueError:
- pass
+ h.close()
if os.path.exists(fn):
os.unlink(fn)
+class BasicConfigTest(unittest.TestCase):
+
+ """Test suite for logging.basicConfig."""
+
+ def setUp(self):
+ super(BasicConfigTest, self).setUp()
+ self.handlers = logging.root.handlers
+ self.saved_handlers = logging._handlers.copy()
+ self.saved_handler_list = logging._handlerList[:]
+ self.original_logging_level = logging.root.level
+ self.addCleanup(self.cleanup)
+ logging.root.handlers = []
+
+ def tearDown(self):
+ for h in logging.root.handlers[:]:
+ logging.root.removeHandler(h)
+ h.close()
+ super(BasicConfigTest, self).tearDown()
+
+ def cleanup(self):
+ setattr(logging.root, 'handlers', self.handlers)
+ logging._handlers.clear()
+ logging._handlers.update(self.saved_handlers)
+ logging._handlerList[:] = self.saved_handler_list
+ logging.root.level = self.original_logging_level
+
+ def test_no_kwargs(self):
+ logging.basicConfig()
+
+ # handler defaults to a StreamHandler to sys.stderr
+ self.assertEqual(len(logging.root.handlers), 1)
+ handler = logging.root.handlers[0]
+ self.assertIsInstance(handler, logging.StreamHandler)
+ self.assertEqual(handler.stream, sys.stderr)
+
+ formatter = handler.formatter
+ # format defaults to logging.BASIC_FORMAT
+ self.assertEqual(formatter._style._fmt, logging.BASIC_FORMAT)
+ # datefmt defaults to None
+ self.assertIsNone(formatter.datefmt)
+ # style defaults to %
+ self.assertIsInstance(formatter._style, logging.PercentStyle)
+
+ # level is not explicitly set
+ self.assertEqual(logging.root.level, self.original_logging_level)
+
+ def test_filename(self):
+ logging.basicConfig(filename='test.log')
+
+ self.assertEqual(len(logging.root.handlers), 1)
+ handler = logging.root.handlers[0]
+ self.assertIsInstance(handler, logging.FileHandler)
+
+ expected = logging.FileHandler('test.log', 'a')
+ self.addCleanup(expected.close)
+ self.assertEqual(handler.stream.mode, expected.stream.mode)
+ self.assertEqual(handler.stream.name, expected.stream.name)
+
+ def test_filemode(self):
+ logging.basicConfig(filename='test.log', filemode='wb')
+
+ handler = logging.root.handlers[0]
+ expected = logging.FileHandler('test.log', 'wb')
+ self.addCleanup(expected.close)
+ self.assertEqual(handler.stream.mode, expected.stream.mode)
+
+ def test_stream(self):
+ stream = io.StringIO()
+ self.addCleanup(stream.close)
+ logging.basicConfig(stream=stream)
+
+ self.assertEqual(len(logging.root.handlers), 1)
+ handler = logging.root.handlers[0]
+ self.assertIsInstance(handler, logging.StreamHandler)
+ self.assertEqual(handler.stream, stream)
+
+ def test_format(self):
+ logging.basicConfig(format='foo')
+
+ formatter = logging.root.handlers[0].formatter
+ self.assertEqual(formatter._style._fmt, 'foo')
+
+ def test_datefmt(self):
+ logging.basicConfig(datefmt='bar')
+
+ formatter = logging.root.handlers[0].formatter
+ self.assertEqual(formatter.datefmt, 'bar')
+
+ def test_style(self):
+ logging.basicConfig(style='$')
+
+ formatter = logging.root.handlers[0].formatter
+ self.assertIsInstance(formatter._style, logging.StringTemplateStyle)
+
+ def test_level(self):
+ old_level = logging.root.level
+ self.addCleanup(logging.root.setLevel, old_level)
+
+ logging.basicConfig(level=57)
+ self.assertEqual(logging.root.level, 57)
+ # Test that second call has no effect
+ logging.basicConfig(level=58)
+ self.assertEqual(logging.root.level, 57)
+
+ def test_handlers(self):
+ handlers = [
+ logging.StreamHandler(),
+ logging.StreamHandler(sys.stdout),
+ logging.StreamHandler(),
+ ]
+ f = logging.Formatter()
+ handlers[2].setFormatter(f)
+ self.assertRaises(ValueError, logging.basicConfig, level=logging.DEBUG,
+ format='%(asctime)s %(message)s', handlers=handlers)
+
+ def _test_log(self, method, level=None):
+ # logging.root has no handlers so basicConfig should be called
+ called = []
+
+ old_basic_config = logging.basicConfig
+ def my_basic_config(*a, **kw):
+ old_basic_config()
+ old_level = logging.root.level
+ logging.root.setLevel(100) # avoid having messages in stderr
+ self.addCleanup(logging.root.setLevel, old_level)
+ called.append((a, kw))
+
+ patch(self, logging, 'basicConfig', my_basic_config)
+
+ log_method = getattr(logging, method)
+ if level is not None:
+ log_method(level, "test me")
+ else:
+ log_method("test me")
+
+ # basicConfig was called with no arguments
+ self.assertEqual(called, [((), {})])
+
+ def test_log(self):
+ self._test_log('log', logging.WARNING)
+
+ def test_debug(self):
+ self._test_log('debug')
+
+ def test_info(self):
+ self._test_log('info')
+
+ def test_warning(self):
+ self._test_log('warning')
+
+ def test_error(self):
+ self._test_log('error')
+
+ def test_critical(self):
+ self._test_log('critical')
+
# Set the locale to the platform-dependent default. I have no idea
# why the test does this, but in any case we save the current locale
# first and restore it at the end.
@@ -1925,7 +2532,12 @@ def test_main():
CustomLevelsAndFiltersTest, MemoryHandlerTest,
ConfigFileTest, SocketHandlerTest, MemoryTest,
EncodingTest, WarningsTest, ConfigDictTest, ManagerTest,
- ChildLoggerTest, HandlerTest)
+ FormatterTest,
+ LogRecordFactoryTest, ChildLoggerTest, QueueHandlerTest,
+ RotatingFileHandlerTest,
+ LastResortTest,
+ TimedRotatingFileHandlerTest, HandlerTest, BasicConfigTest,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index f0847e7ab43..3ebc1f7fed0 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -1,10 +1,11 @@
import unittest
+from test import support
+
import sys
import random
import math
-
-from test import test_int, test_support
+import array
# Used for lazy formatting of failure messages
class Frm(object):
@@ -16,7 +17,7 @@ class Frm(object):
return self.format % self.args
# SHIFT should match the value in longintrepr.h for best testing.
-SHIFT = sys.long_info.bits_per_digit
+SHIFT = sys.int_info.bits_per_digit
BASE = 2 ** SHIFT
MASK = BASE - 1
KARATSUBA_CUTOFF = 70 # from longobject.c
@@ -26,62 +27,54 @@ KARATSUBA_CUTOFF = 70 # from longobject.c
MAXDIGITS = 15
# build some special values
-special = map(long, [0, 1, 2, BASE, BASE >> 1])
-special.append(0x5555555555555555L)
-special.append(0xaaaaaaaaaaaaaaaaL)
+special = [0, 1, 2, BASE, BASE >> 1, 0x5555555555555555, 0xaaaaaaaaaaaaaaaa]
# some solid strings of one bits
-p2 = 4L # 0 and 1 already added
+p2 = 4 # 0 and 1 already added
for i in range(2*SHIFT):
special.append(p2 - 1)
p2 = p2 << 1
del p2
# add complements & negations
-special = special + map(lambda x: ~x, special) + \
- map(lambda x: -x, special)
-
-L = [
- ('0', 0),
- ('1', 1),
- ('9', 9),
- ('10', 10),
- ('99', 99),
- ('100', 100),
- ('314', 314),
- (' 314', 314),
- ('314 ', 314),
- (' \t\t 314 \t\t ', 314),
- (repr(sys.maxint), sys.maxint),
- (' 1x', ValueError),
- (' 1 ', 1),
- (' 1\02 ', ValueError),
- ('', ValueError),
- (' ', ValueError),
- (' \t\t ', ValueError)
-]
-if test_support.have_unicode:
- L += [
- (unicode('0'), 0),
- (unicode('1'), 1),
- (unicode('9'), 9),
- (unicode('10'), 10),
- (unicode('99'), 99),
- (unicode('100'), 100),
- (unicode('314'), 314),
- (unicode(' 314'), 314),
- (unicode('\u0663\u0661\u0664 ','raw-unicode-escape'), 314),
- (unicode(' \t\t 314 \t\t '), 314),
- (unicode(' 1x'), ValueError),
- (unicode(' 1 '), 1),
- (unicode(' 1\02 '), ValueError),
- (unicode(''), ValueError),
- (unicode(' '), ValueError),
- (unicode(' \t\t '), ValueError),
- (unichr(0x200), ValueError),
-]
-
-class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
-
- ntype = long
+special += [~x for x in special] + [-x for x in special]
+
+DBL_MAX = sys.float_info.max
+DBL_MAX_EXP = sys.float_info.max_exp
+DBL_MIN_EXP = sys.float_info.min_exp
+DBL_MANT_DIG = sys.float_info.mant_dig
+DBL_MIN_OVERFLOW = 2**DBL_MAX_EXP - 2**(DBL_MAX_EXP - DBL_MANT_DIG - 1)
+
+# pure Python version of correctly-rounded true division
+def truediv(a, b):
+ """Correctly-rounded true division for integers."""
+ negative = a^b < 0
+ a, b = abs(a), abs(b)
+
+ # exceptions: division by zero, overflow
+ if not b:
+ raise ZeroDivisionError("division by zero")
+ if a >= DBL_MIN_OVERFLOW * b:
+ raise OverflowError("int/int too large to represent as a float")
+
+ # find integer d satisfying 2**(d - 1) <= a/b < 2**d
+ d = a.bit_length() - b.bit_length()
+ if d >= 0 and a >= 2**d * b or d < 0 and a * 2**-d >= b:
+ d += 1
+
+ # compute 2**-exp * a / b for suitable exp
+ exp = max(d, DBL_MIN_EXP) - DBL_MANT_DIG
+ a, b = a << max(-exp, 0), b << max(exp, 0)
+ q, r = divmod(a, b)
+
+ # round-half-to-even: fractional part is r/b, which is > 0.5 iff
+ # 2*r > b, and == 0.5 iff 2*r == b.
+ if 2*r > b or 2*r == b and q % 2 == 1:
+ q += 1
+
+ result = math.ldexp(q, exp)
+ return -result if negative else result
+
+
+class LongTest(unittest.TestCase):
# Get quasi-random long consisting of ndigits digits (in base BASE).
# quasi == the most-significant digit will not be 0, and the number
@@ -93,7 +86,7 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.assertTrue(ndigits > 0)
nbits_hi = ndigits * SHIFT
nbits_lo = nbits_hi - SHIFT + 1
- answer = 0L
+ answer = 0
nbits = 0
r = int(random.random() * (SHIFT * 2)) | 1 # force 1 bits to start
while nbits < nbits_lo:
@@ -114,8 +107,8 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
# BASE). The sign bit is also random.
def getran2(ndigits):
- answer = 0L
- for i in xrange(ndigits):
+ answer = 0
+ for i in range(ndigits):
answer = (answer << SHIFT) | random.randint(0, MASK)
if random.random() < 0.5:
answer = -answer
@@ -136,46 +129,47 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.assertTrue(y < r <= 0, Frm("bad mod from divmod on %r and %r", x, y))
def test_division(self):
- digits = range(1, MAXDIGITS+1) + range(KARATSUBA_CUTOFF,
- KARATSUBA_CUTOFF + 14)
+ digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF,
+ KARATSUBA_CUTOFF + 14))
digits.append(KARATSUBA_CUTOFF * 3)
for lenx in digits:
x = self.getran(lenx)
for leny in digits:
- y = self.getran(leny) or 1L
+ y = self.getran(leny) or 1
self.check_division(x, y)
# specific numbers chosen to exercise corner cases of the
# current long division implementation
# 30-bit cases involving a quotient digit estimate of BASE+1
- self.check_division(1231948412290879395966702881L,
- 1147341367131428698L)
- self.check_division(815427756481275430342312021515587883L,
- 707270836069027745L)
- self.check_division(627976073697012820849443363563599041L,
- 643588798496057020L)
- self.check_division(1115141373653752303710932756325578065L,
- 1038556335171453937726882627L)
+ self.check_division(1231948412290879395966702881,
+ 1147341367131428698)
+ self.check_division(815427756481275430342312021515587883,
+ 707270836069027745)
+ self.check_division(627976073697012820849443363563599041,
+ 643588798496057020)
+ self.check_division(1115141373653752303710932756325578065,
+ 1038556335171453937726882627)
# 30-bit cases that require the post-subtraction correction step
- self.check_division(922498905405436751940989320930368494L,
- 949985870686786135626943396L)
- self.check_division(768235853328091167204009652174031844L,
- 1091555541180371554426545266L)
+ self.check_division(922498905405436751940989320930368494,
+ 949985870686786135626943396)
+ self.check_division(768235853328091167204009652174031844,
+ 1091555541180371554426545266)
# 15-bit cases involving a quotient digit estimate of BASE+1
- self.check_division(20172188947443L, 615611397L)
- self.check_division(1020908530270155025L, 950795710L)
- self.check_division(128589565723112408L, 736393718L)
- self.check_division(609919780285761575L, 18613274546784L)
+ self.check_division(20172188947443, 615611397)
+ self.check_division(1020908530270155025, 950795710)
+ self.check_division(128589565723112408, 736393718)
+ self.check_division(609919780285761575, 18613274546784)
# 15-bit cases that require the post-subtraction correction step
- self.check_division(710031681576388032L, 26769404391308L)
- self.check_division(1933622614268221L, 30212853348836L)
+ self.check_division(710031681576388032, 26769404391308)
+ self.check_division(1933622614268221, 30212853348836)
def test_karatsuba(self):
- digits = range(1, 5) + range(KARATSUBA_CUTOFF, KARATSUBA_CUTOFF + 10)
+ digits = list(range(1, 5)) + list(range(KARATSUBA_CUTOFF,
+ KARATSUBA_CUTOFF + 10))
digits.extend([KARATSUBA_CUTOFF * 10, KARATSUBA_CUTOFF * 100])
bits = [digit * SHIFT for digit in digits]
@@ -183,15 +177,15 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
# Test products of long strings of 1 bits -- (2**x-1)*(2**y-1) ==
# 2**(x+y) - 2**x - 2**y + 1, so the proper result is easy to check.
for abits in bits:
- a = (1L << abits) - 1
+ a = (1 << abits) - 1
for bbits in bits:
if bbits < abits:
continue
- b = (1L << bbits) - 1
+ b = (1 << bbits) - 1
x = a * b
- y = ((1L << (abits + bbits)) -
- (1L << abits) -
- (1L << bbits) +
+ y = ((1 << (abits + bbits)) -
+ (1 << abits) -
+ (1 << bbits) +
1)
self.assertEqual(x, y,
Frm("bad result for a*b: a=%r, b=%r, x=%r, y=%r", a, b, x, y))
@@ -213,8 +207,8 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
eq(x ^ ~x, -1, Frm("x ^ ~x != -1 for x=%r", x))
eq(-x, 1 + ~x, Frm("not -x == 1 + ~x for x=%r", x))
eq(-x, ~(x-1), Frm("not -x == ~(x-1) forx =%r", x))
- for n in xrange(2*SHIFT):
- p2 = 2L ** n
+ for n in range(2*SHIFT):
+ p2 = 2 ** n
eq(x << n >> n, x,
Frm("x << n >> n != x for x=%r, n=%r", (x, n)))
eq(x // p2, x >> n,
@@ -257,7 +251,7 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
def test_bitop_identities(self):
for x in special:
self.check_bitop_identities_1(x)
- digits = xrange(1, MAXDIGITS+1)
+ digits = range(1, MAXDIGITS+1)
for lenx in digits:
x = self.getran(lenx)
self.check_bitop_identities_1(x)
@@ -267,9 +261,6 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.check_bitop_identities_3(x, y, self.getran((lenx + leny)//2))
def slow_format(self, x, base):
- if (x, base) == (0, 8):
- # this is an oddball!
- return "0L"
digits = []
sign = 0
if x < 0:
@@ -280,8 +271,8 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
digits.reverse()
digits = digits or [0]
return '-'[:sign] + \
- {8: '0', 10: '', 16: '0x'}[base] + \
- "".join(map(lambda i: "0123456789abcdef"[i], digits)) + "L"
+ {2: '0b', 8: '0o', 10: '', 16: '0x'}[base] + \
+ "".join("0123456789abcdef"[i] for i in digits)
def check_format_1(self, x):
for base, mapper in (8, oct), (10, repr), (16, hex):
@@ -290,11 +281,11 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
msg = Frm("%s returned %r but expected %r for %r",
mapper.__name__, got, expected, x)
self.assertEqual(got, expected, msg)
- self.assertEqual(long(got, 0), x, Frm('long("%s", 0) != %r', got, x))
+ self.assertEqual(int(got, 0), x, Frm('int("%s", 0) != %r', got, x))
# str() has to be checked a little differently since there's no
# trailing "L"
got = str(x)
- expected = self.slow_format(x, 10)[:-1]
+ expected = self.slow_format(x, 10)
msg = Frm("%s returned %r but expected %r for %r",
mapper.__name__, got, expected, x)
self.assertEqual(got, expected, msg)
@@ -302,47 +293,18 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
def test_format(self):
for x in special:
self.check_format_1(x)
- for i in xrange(10):
- for lenx in xrange(1, MAXDIGITS+1):
+ for i in range(10):
+ for lenx in range(1, MAXDIGITS+1):
x = self.getran(lenx)
self.check_format_1(x)
def test_long(self):
- self.assertEqual(long(314), 314L)
- self.assertEqual(long(3.14), 3L)
- self.assertEqual(long(314L), 314L)
- # Check that long() of basic types actually returns a long
- self.assertEqual(type(long(314)), long)
- self.assertEqual(type(long(3.14)), long)
- self.assertEqual(type(long(314L)), long)
- # Check that conversion from float truncates towards zero
- self.assertEqual(long(-3.14), -3L)
- self.assertEqual(long(3.9), 3L)
- self.assertEqual(long(-3.9), -3L)
- self.assertEqual(long(3.5), 3L)
- self.assertEqual(long(-3.5), -3L)
- self.assertEqual(long("-3"), -3L)
- self.assertEqual(long("0b10", 2), 2L)
- self.assertEqual(long("0o10", 8), 8L)
- self.assertEqual(long("0x10", 16), 16L)
- if test_support.have_unicode:
- self.assertEqual(long(unicode("-3")), -3L)
- # Different base:
- self.assertEqual(long("10",16), 16L)
- if test_support.have_unicode:
- self.assertEqual(long(unicode("10"),16), 16L)
- # Check conversions from string (same test set as for int(), and then some)
+ # Check conversions from string
LL = [
- ('1' + '0'*20, 10L**20),
- ('1' + '0'*100, 10L**100)
+ ('1' + '0'*20, 10**20),
+ ('1' + '0'*100, 10**100)
]
- L2 = L[:]
- if test_support.have_unicode:
- L2 += [
- (unicode('1') + unicode('0')*20, 10L**20),
- (unicode('1') + unicode('0')*100, 10L**100),
- ]
- for s, v in L2 + LL:
+ for s, v in LL:
for sign in "", "+", "-":
for prefix in "", " ", "\t", " \t\t ":
ss = prefix + sign + s
@@ -350,377 +312,95 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
if sign == "-" and v is not ValueError:
vv = -v
try:
- self.assertEqual(long(ss), long(vv))
- except v:
+ self.assertEqual(int(ss), vv)
+ except ValueError:
pass
- self.assertRaises(ValueError, long, '123\0')
- self.assertRaises(ValueError, long, '53', 40)
- self.assertRaises(TypeError, long, 1, 12)
+ # trailing L should no longer be accepted...
+ self.assertRaises(ValueError, int, '123L')
+ self.assertRaises(ValueError, int, '123l')
+ self.assertRaises(ValueError, int, '0L')
+ self.assertRaises(ValueError, int, '-37L')
+ self.assertRaises(ValueError, int, '0x32L', 16)
+ self.assertRaises(ValueError, int, '1L', 21)
+ # ... but it's just a normal digit if base >= 22
+ self.assertEqual(int('1L', 22), 43)
# tests with base 0
- self.assertEqual(long(' 0123 ', 0), 83)
- self.assertEqual(long(' 0123 ', 0), 83)
- self.assertEqual(long('000', 0), 0)
- self.assertEqual(long('0o123', 0), 83)
- self.assertEqual(long('0x123', 0), 291)
- self.assertEqual(long('0b100', 0), 4)
- self.assertEqual(long(' 0O123 ', 0), 83)
- self.assertEqual(long(' 0X123 ', 0), 291)
- self.assertEqual(long(' 0B100 ', 0), 4)
- self.assertEqual(long('0', 0), 0)
- self.assertEqual(long('+0', 0), 0)
- self.assertEqual(long('-0', 0), 0)
- self.assertEqual(long('00', 0), 0)
- self.assertRaises(ValueError, long, '08', 0)
- self.assertRaises(ValueError, long, '-012395', 0)
-
- # SF patch #1638879: embedded NULs were not detected with
- # explicit base
- self.assertRaises(ValueError, long, '123\0', 10)
- self.assertRaises(ValueError, long, '123\x00 245', 20)
-
- self.assertEqual(long('100000000000000000000000000000000', 2),
- 4294967296)
- self.assertEqual(long('102002022201221111211', 3), 4294967296)
- self.assertEqual(long('10000000000000000', 4), 4294967296)
- self.assertEqual(long('32244002423141', 5), 4294967296)
- self.assertEqual(long('1550104015504', 6), 4294967296)
- self.assertEqual(long('211301422354', 7), 4294967296)
- self.assertEqual(long('40000000000', 8), 4294967296)
- self.assertEqual(long('12068657454', 9), 4294967296)
- self.assertEqual(long('4294967296', 10), 4294967296)
- self.assertEqual(long('1904440554', 11), 4294967296)
- self.assertEqual(long('9ba461594', 12), 4294967296)
- self.assertEqual(long('535a79889', 13), 4294967296)
- self.assertEqual(long('2ca5b7464', 14), 4294967296)
- self.assertEqual(long('1a20dcd81', 15), 4294967296)
- self.assertEqual(long('100000000', 16), 4294967296)
- self.assertEqual(long('a7ffda91', 17), 4294967296)
- self.assertEqual(long('704he7g4', 18), 4294967296)
- self.assertEqual(long('4f5aff66', 19), 4294967296)
- self.assertEqual(long('3723ai4g', 20), 4294967296)
- self.assertEqual(long('281d55i4', 21), 4294967296)
- self.assertEqual(long('1fj8b184', 22), 4294967296)
- self.assertEqual(long('1606k7ic', 23), 4294967296)
- self.assertEqual(long('mb994ag', 24), 4294967296)
- self.assertEqual(long('hek2mgl', 25), 4294967296)
- self.assertEqual(long('dnchbnm', 26), 4294967296)
- self.assertEqual(long('b28jpdm', 27), 4294967296)
- self.assertEqual(long('8pfgih4', 28), 4294967296)
- self.assertEqual(long('76beigg', 29), 4294967296)
- self.assertEqual(long('5qmcpqg', 30), 4294967296)
- self.assertEqual(long('4q0jto4', 31), 4294967296)
- self.assertEqual(long('4000000', 32), 4294967296)
- self.assertEqual(long('3aokq94', 33), 4294967296)
- self.assertEqual(long('2qhxjli', 34), 4294967296)
- self.assertEqual(long('2br45qb', 35), 4294967296)
- self.assertEqual(long('1z141z4', 36), 4294967296)
-
- self.assertEqual(long('100000000000000000000000000000001', 2),
- 4294967297)
- self.assertEqual(long('102002022201221111212', 3), 4294967297)
- self.assertEqual(long('10000000000000001', 4), 4294967297)
- self.assertEqual(long('32244002423142', 5), 4294967297)
- self.assertEqual(long('1550104015505', 6), 4294967297)
- self.assertEqual(long('211301422355', 7), 4294967297)
- self.assertEqual(long('40000000001', 8), 4294967297)
- self.assertEqual(long('12068657455', 9), 4294967297)
- self.assertEqual(long('4294967297', 10), 4294967297)
- self.assertEqual(long('1904440555', 11), 4294967297)
- self.assertEqual(long('9ba461595', 12), 4294967297)
- self.assertEqual(long('535a7988a', 13), 4294967297)
- self.assertEqual(long('2ca5b7465', 14), 4294967297)
- self.assertEqual(long('1a20dcd82', 15), 4294967297)
- self.assertEqual(long('100000001', 16), 4294967297)
- self.assertEqual(long('a7ffda92', 17), 4294967297)
- self.assertEqual(long('704he7g5', 18), 4294967297)
- self.assertEqual(long('4f5aff67', 19), 4294967297)
- self.assertEqual(long('3723ai4h', 20), 4294967297)
- self.assertEqual(long('281d55i5', 21), 4294967297)
- self.assertEqual(long('1fj8b185', 22), 4294967297)
- self.assertEqual(long('1606k7id', 23), 4294967297)
- self.assertEqual(long('mb994ah', 24), 4294967297)
- self.assertEqual(long('hek2mgm', 25), 4294967297)
- self.assertEqual(long('dnchbnn', 26), 4294967297)
- self.assertEqual(long('b28jpdn', 27), 4294967297)
- self.assertEqual(long('8pfgih5', 28), 4294967297)
- self.assertEqual(long('76beigh', 29), 4294967297)
- self.assertEqual(long('5qmcpqh', 30), 4294967297)
- self.assertEqual(long('4q0jto5', 31), 4294967297)
- self.assertEqual(long('4000001', 32), 4294967297)
- self.assertEqual(long('3aokq95', 33), 4294967297)
- self.assertEqual(long('2qhxjlj', 34), 4294967297)
- self.assertEqual(long('2br45qc', 35), 4294967297)
- self.assertEqual(long('1z141z5', 36), 4294967297)
+ self.assertEqual(int('000', 0), 0)
+ self.assertEqual(int('0o123', 0), 83)
+ self.assertEqual(int('0x123', 0), 291)
+ self.assertEqual(int('0b100', 0), 4)
+ self.assertEqual(int(' 0O123 ', 0), 83)
+ self.assertEqual(int(' 0X123 ', 0), 291)
+ self.assertEqual(int(' 0B100 ', 0), 4)
+ self.assertEqual(int('0', 0), 0)
+ self.assertEqual(int('+0', 0), 0)
+ self.assertEqual(int('-0', 0), 0)
+ self.assertEqual(int('00', 0), 0)
+ self.assertRaises(ValueError, int, '08', 0)
+ self.assertRaises(ValueError, int, '-012395', 0)
+
+ # invalid bases
+ invalid_bases = [-909,
+ 2**31-1, 2**31, -2**31, -2**31-1,
+ 2**63-1, 2**63, -2**63, -2**63-1,
+ 2**100, -2**100,
+ ]
+ for base in invalid_bases:
+ self.assertRaises(ValueError, int, '42', base)
def test_conversion(self):
- # Test __long__()
- class ClassicMissingMethods:
- pass
- self.assertRaises(AttributeError, long, ClassicMissingMethods())
-
- class MissingMethods(object):
- pass
- self.assertRaises(TypeError, long, MissingMethods())
-
- class Foo0:
- def __long__(self):
- return 42L
- class Foo1(object):
- def __long__(self):
- return 42L
-
- class Foo2(long):
- def __long__(self):
- return 42L
-
- class Foo3(long):
- def __long__(self):
- return self
-
- class Foo4(long):
+ class JustLong:
+ # test that __long__ no longer used in 3.x
def __long__(self):
return 42
+ self.assertRaises(TypeError, int, JustLong())
- class Foo5(long):
+ class LongTrunc:
+ # __long__ should be ignored in 3.x
def __long__(self):
- return 42.
-
- self.assertEqual(long(Foo0()), 42L)
- self.assertEqual(long(Foo1()), 42L)
- self.assertEqual(long(Foo2()), 42L)
- self.assertEqual(long(Foo3()), 0)
- self.assertEqual(long(Foo4()), 42)
- self.assertRaises(TypeError, long, Foo5())
-
- class Classic:
- pass
- for base in (object, Classic):
- class LongOverridesTrunc(base):
- def __long__(self):
- return 42
- def __trunc__(self):
- return -12
- self.assertEqual(long(LongOverridesTrunc()), 42)
-
- class JustTrunc(base):
- def __trunc__(self):
- return 42
- self.assertEqual(long(JustTrunc()), 42)
-
- for trunc_result_base in (object, Classic):
- class Integral(trunc_result_base):
- def __int__(self):
- return 42
-
- class TruncReturnsNonLong(base):
- def __trunc__(self):
- return Integral()
- self.assertEqual(long(TruncReturnsNonLong()), 42)
-
- class NonIntegral(trunc_result_base):
- def __trunc__(self):
- # Check that we avoid infinite recursion.
- return NonIntegral()
-
- class TruncReturnsNonIntegral(base):
- def __trunc__(self):
- return NonIntegral()
- try:
- long(TruncReturnsNonIntegral())
- except TypeError as e:
- self.assertEqual(str(e),
- "__trunc__ returned non-Integral"
- " (type NonIntegral)")
- else:
- self.fail("Failed to raise TypeError with %s" %
- ((base, trunc_result_base),))
-
- def test_misc(self):
-
- # check the extremes in int<->long conversion
- hugepos = sys.maxint
- hugeneg = -hugepos - 1
- hugepos_aslong = long(hugepos)
- hugeneg_aslong = long(hugeneg)
- self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxint) != sys.maxint")
- self.assertEqual(hugeneg, hugeneg_aslong,
- "long(-sys.maxint-1) != -sys.maxint-1")
-
- # long -> int should not fail for hugepos_aslong or hugeneg_aslong
- x = int(hugepos_aslong)
- try:
- self.assertEqual(x, hugepos,
- "converting sys.maxint to long and back to int fails")
- except OverflowError:
- self.fail("int(long(sys.maxint)) overflowed!")
- if not isinstance(x, int):
- self.fail("int(long(sys.maxint)) should have returned int")
- x = int(hugeneg_aslong)
- try:
- self.assertEqual(x, hugeneg,
- "converting -sys.maxint-1 to long and back to int fails")
- except OverflowError:
- self.fail("int(long(-sys.maxint-1)) overflowed!")
- if not isinstance(x, int):
- self.fail("int(long(-sys.maxint-1)) should have returned int")
- # but long -> int should overflow for hugepos+1 and hugeneg-1
- x = hugepos_aslong + 1
- try:
- y = int(x)
- except OverflowError:
- self.fail("int(long(sys.maxint) + 1) mustn't overflow")
- self.assertIsInstance(y, long,
- "int(long(sys.maxint) + 1) should have returned long")
-
- x = hugeneg_aslong - 1
- try:
- y = int(x)
- except OverflowError:
- self.fail("int(long(-sys.maxint-1) - 1) mustn't overflow")
- self.assertIsInstance(y, long,
- "int(long(-sys.maxint-1) - 1) should have returned long")
-
- class long2(long):
- pass
- x = long2(1L<<100)
- y = int(x)
- self.assertTrue(type(y) is long,
- "overflowing int conversion must return long not long subtype")
-
- # long -> Py_ssize_t conversion
- class X(object):
- def __getslice__(self, i, j):
- return i, j
-
- with test_support.check_py3k_warnings():
- self.assertEqual(X()[-5L:7L], (-5, 7))
- # use the clamping effect to test the smallest and largest longs
- # that fit a Py_ssize_t
- slicemin, slicemax = X()[-2L**100:2L**100]
- self.assertEqual(X()[slicemin:slicemax], (slicemin, slicemax))
-
- def test_issue9869(self):
- # Issue 9869: Interpreter crash when initializing an instance
- # of a long subclass from an object whose __long__ method returns
- # a plain int.
- class BadLong(object):
- def __long__(self):
- return 1000000
-
- class MyLong(long):
- pass
-
- x = MyLong(BadLong())
- self.assertIsInstance(x, long)
- self.assertEqual(x, 1000000)
-
-
-# ----------------------------------- tests of auto int->long conversion
-
- def test_auto_overflow(self):
- special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1]
- sqrt = int(math.sqrt(sys.maxint))
- special.extend([sqrt-1, sqrt, sqrt+1])
- special.extend([-i for i in special])
-
- def checkit(*args):
- # Heavy use of nested scopes here!
- self.assertEqual(got, expected,
- Frm("for %r expected %r got %r", args, expected, got))
+ return 42
+ def __trunc__(self):
+ return 1729
+ self.assertEqual(int(LongTrunc()), 1729)
- for x in special:
- longx = long(x)
-
- expected = -longx
- got = -x
- checkit('-', x)
-
- for y in special:
- longy = long(y)
-
- expected = longx + longy
- got = x + y
- checkit(x, '+', y)
-
- expected = longx - longy
- got = x - y
- checkit(x, '-', y)
-
- expected = longx * longy
- got = x * y
- checkit(x, '*', y)
-
- if y:
- with test_support.check_py3k_warnings():
- expected = longx / longy
- got = x / y
- checkit(x, '/', y)
-
- expected = longx // longy
- got = x // y
- checkit(x, '//', y)
-
- expected = divmod(longx, longy)
- got = divmod(longx, longy)
- checkit(x, 'divmod', y)
-
- if abs(y) < 5 and not (x == 0 and y < 0):
- expected = longx ** longy
- got = x ** y
- checkit(x, '**', y)
-
- for z in special:
- if z != 0 :
- if y >= 0:
- expected = pow(longx, longy, long(z))
- got = pow(x, y, z)
- checkit('pow', x, y, '%', z)
- else:
- self.assertRaises(TypeError, pow,longx, longy, long(z))
-
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @support.requires_IEEE_754
def test_float_conversion(self):
- import sys
- DBL_MAX = sys.float_info.max
- DBL_MAX_EXP = sys.float_info.max_exp
- DBL_MANT_DIG = sys.float_info.mant_dig
-
- exact_values = [0L, 1L, 2L,
- long(2**53-3),
- long(2**53-2),
- long(2**53-1),
- long(2**53),
- long(2**53+2),
- long(2**54-4),
- long(2**54-2),
- long(2**54),
- long(2**54+4)]
+
+ exact_values = [0, 1, 2,
+ 2**53-3,
+ 2**53-2,
+ 2**53-1,
+ 2**53,
+ 2**53+2,
+ 2**54-4,
+ 2**54-2,
+ 2**54,
+ 2**54+4]
for x in exact_values:
- self.assertEqual(long(float(x)), x)
- self.assertEqual(long(float(-x)), -x)
+ self.assertEqual(float(x), x)
+ self.assertEqual(float(-x), -x)
# test round-half-even
for x, y in [(1, 0), (2, 2), (3, 4), (4, 4), (5, 4), (6, 6), (7, 8)]:
- for p in xrange(15):
- self.assertEqual(long(float(2L**p*(2**53+x))), 2L**p*(2**53+y))
+ for p in range(15):
+ self.assertEqual(int(float(2**p*(2**53+x))), 2**p*(2**53+y))
for x, y in [(0, 0), (1, 0), (2, 0), (3, 4), (4, 4), (5, 4), (6, 8),
(7, 8), (8, 8), (9, 8), (10, 8), (11, 12), (12, 12),
(13, 12), (14, 16), (15, 16)]:
- for p in xrange(15):
- self.assertEqual(long(float(2L**p*(2**54+x))), 2L**p*(2**54+y))
+ for p in range(15):
+ self.assertEqual(int(float(2**p*(2**54+x))), 2**p*(2**54+y))
# behaviour near extremes of floating-point range
- long_dbl_max = long(DBL_MAX)
+ int_dbl_max = int(DBL_MAX)
top_power = 2**DBL_MAX_EXP
- halfway = (long_dbl_max + top_power)//2
- self.assertEqual(float(long_dbl_max), DBL_MAX)
- self.assertEqual(float(long_dbl_max+1), DBL_MAX)
+ halfway = (int_dbl_max + top_power)//2
+ self.assertEqual(float(int_dbl_max), DBL_MAX)
+ self.assertEqual(float(int_dbl_max+1), DBL_MAX)
self.assertEqual(float(halfway-1), DBL_MAX)
self.assertRaises(OverflowError, float, halfway)
self.assertEqual(float(1-halfway), -DBL_MAX)
@@ -732,21 +412,21 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.assertRaises(OverflowError, float, 2*top_power)
self.assertRaises(OverflowError, float, top_power*top_power)
- for p in xrange(100):
- x = long(2**p * (2**53 + 1) + 1)
- y = long(2**p * (2**53+ 2))
- self.assertEqual(long(float(x)), y)
+ for p in range(100):
+ x = 2**p * (2**53 + 1) + 1
+ y = 2**p * (2**53 + 2)
+ self.assertEqual(int(float(x)), y)
- x = long(2**p * (2**53 + 1))
- y = long(2**p * 2**53)
- self.assertEqual(long(float(x)), y)
+ x = 2**p * (2**53 + 1)
+ y = 2**p * 2**53
+ self.assertEqual(int(float(x)), y)
def test_float_overflow(self):
for x in -2.0, -1.0, 0.0, 1.0, 2.0:
- self.assertEqual(float(long(x)), x)
+ self.assertEqual(float(int(x)), x)
shuge = '12345' * 120
- huge = 1L << 30000
+ huge = 1 << 30000
mhuge = -huge
namespace = {'huge': huge, 'mhuge': mhuge, 'shuge': shuge, 'math': math}
for test in ["float(huge)", "float(mhuge)",
@@ -761,19 +441,21 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
"1. ** huge", "huge ** 1.", "1. ** mhuge", "mhuge ** 1.",
"math.sin(huge)", "math.sin(mhuge)",
"math.sqrt(huge)", "math.sqrt(mhuge)", # should do better
- "math.floor(huge)", "math.floor(mhuge)"]:
+ # math.floor() of an int returns an int now
+ ##"math.floor(huge)", "math.floor(mhuge)",
+ ]:
self.assertRaises(OverflowError, eval, test, namespace)
- # XXX Perhaps float(shuge) can raise OverflowError on some box?
- # The comparison should not.
- self.assertNotEqual(float(shuge), int(shuge),
- "float(shuge) should not equal int(shuge)")
+ # XXX Perhaps float(shuge) can raise OverflowError on some box?
+ # The comparison should not.
+ self.assertNotEqual(float(shuge), int(shuge),
+ "float(shuge) should not equal int(shuge)")
def test_logs(self):
LOG10E = math.log10(math.e)
- for exp in range(10) + [100, 1000, 10000]:
+ for exp in list(range(10)) + [100, 1000, 10000]:
value = 10 ** exp
log10 = math.log10(value)
self.assertAlmostEqual(log10, exp)
@@ -784,7 +466,7 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
log = math.log(value)
self.assertAlmostEqual(log, expected)
- for bad in -(1L << 10000), -2L, 0L:
+ for bad in -(1 << 10000), -2, 0:
self.assertRaises(ValueError, math.log, bad)
self.assertRaises(ValueError, math.log10, bad)
@@ -798,7 +480,7 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
# represents all Python ints, longs and floats exactly).
class Rat:
def __init__(self, value):
- if isinstance(value, (int, long)):
+ if isinstance(value, int):
self.n = value
self.d = 1
elif isinstance(value, float):
@@ -837,29 +519,42 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
else:
raise TypeError("can't deal with %r" % value)
- def __cmp__(self, other):
+ def _cmp__(self, other):
if not isinstance(other, Rat):
other = Rat(other)
- return cmp(self.n * other.d, self.d * other.n)
+ x, y = self.n * other.d, self.d * other.n
+ return (x > y) - (x < y)
+ def __eq__(self, other):
+ return self._cmp__(other) == 0
+ def __ne__(self, other):
+ return self._cmp__(other) != 0
+ def __ge__(self, other):
+ return self._cmp__(other) >= 0
+ def __gt__(self, other):
+ return self._cmp__(other) > 0
+ def __le__(self, other):
+ return self._cmp__(other) <= 0
+ def __lt__(self, other):
+ return self._cmp__(other) < 0
cases = [0, 0.001, 0.99, 1.0, 1.5, 1e20, 1e200]
# 2**48 is an important boundary in the internals. 2**53 is an
# important boundary for IEEE double precision.
for t in 2.0**48, 2.0**50, 2.0**53:
cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0,
- long(t-1), long(t), long(t+1)])
- cases.extend([0, 1, 2, sys.maxint, float(sys.maxint)])
- # 1L<<20000 should exceed all double formats. long(1e200) is to
+ int(t-1), int(t), int(t+1)])
+ cases.extend([0, 1, 2, sys.maxsize, float(sys.maxsize)])
+ # 1 << 20000 should exceed all double formats. int(1e200) is to
# check that we get equality with 1e200 above.
- t = long(1e200)
- cases.extend([0L, 1L, 2L, 1L << 20000, t-1, t, t+1])
+ t = int(1e200)
+ cases.extend([0, 1, 2, 1 << 20000, t-1, t, t+1])
cases.extend([-x for x in cases])
for x in cases:
Rx = Rat(x)
for y in cases:
Ry = Rat(y)
- Rcmp = cmp(Rx, Ry)
- xycmp = cmp(x, y)
+ Rcmp = (Rx > Ry) - (Rx < Ry)
+ xycmp = (x > y) - (x < y)
eq(Rcmp, xycmp, Frm("%r %r %d %d", x, y, Rcmp, xycmp))
eq(x == y, Rcmp == 0, Frm("%r == %r %d", x, y, Rcmp))
eq(x != y, Rcmp != 0, Frm("%r != %r %d", x, y, Rcmp))
@@ -868,15 +563,254 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
eq(x > y, Rcmp > 0, Frm("%r > %r %d", x, y, Rcmp))
eq(x >= y, Rcmp >= 0, Frm("%r >= %r %d", x, y, Rcmp))
+ def test__format__(self):
+ self.assertEqual(format(123456789, 'd'), '123456789')
+ self.assertEqual(format(123456789, 'd'), '123456789')
+
+ # sign and aligning are interdependent
+ self.assertEqual(format(1, "-"), '1')
+ self.assertEqual(format(-1, "-"), '-1')
+ self.assertEqual(format(1, "-3"), ' 1')
+ self.assertEqual(format(-1, "-3"), ' -1')
+ self.assertEqual(format(1, "+3"), ' +1')
+ self.assertEqual(format(-1, "+3"), ' -1')
+ self.assertEqual(format(1, " 3"), ' 1')
+ self.assertEqual(format(-1, " 3"), ' -1')
+ self.assertEqual(format(1, " "), ' 1')
+ self.assertEqual(format(-1, " "), '-1')
+
+ # hex
+ self.assertEqual(format(3, "x"), "3")
+ self.assertEqual(format(3, "X"), "3")
+ self.assertEqual(format(1234, "x"), "4d2")
+ self.assertEqual(format(-1234, "x"), "-4d2")
+ self.assertEqual(format(1234, "8x"), " 4d2")
+ self.assertEqual(format(-1234, "8x"), " -4d2")
+ self.assertEqual(format(1234, "x"), "4d2")
+ self.assertEqual(format(-1234, "x"), "-4d2")
+ self.assertEqual(format(-3, "x"), "-3")
+ self.assertEqual(format(-3, "X"), "-3")
+ self.assertEqual(format(int('be', 16), "x"), "be")
+ self.assertEqual(format(int('be', 16), "X"), "BE")
+ self.assertEqual(format(-int('be', 16), "x"), "-be")
+ self.assertEqual(format(-int('be', 16), "X"), "-BE")
+
+ # octal
+ self.assertEqual(format(3, "b"), "11")
+ self.assertEqual(format(-3, "b"), "-11")
+ self.assertEqual(format(1234, "b"), "10011010010")
+ self.assertEqual(format(-1234, "b"), "-10011010010")
+ self.assertEqual(format(1234, "-b"), "10011010010")
+ self.assertEqual(format(-1234, "-b"), "-10011010010")
+ self.assertEqual(format(1234, " b"), " 10011010010")
+ self.assertEqual(format(-1234, " b"), "-10011010010")
+ self.assertEqual(format(1234, "+b"), "+10011010010")
+ self.assertEqual(format(-1234, "+b"), "-10011010010")
+
+ # make sure these are errors
+ self.assertRaises(ValueError, format, 3, "1.3") # precision disallowed
+ self.assertRaises(ValueError, format, 3, "+c") # sign not allowed
+ # with 'c'
+
+ # ensure that only int and float type specifiers work
+ for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
+ [chr(x) for x in range(ord('A'), ord('Z')+1)]):
+ if not format_spec in 'bcdoxXeEfFgGn%':
+ self.assertRaises(ValueError, format, 0, format_spec)
+ self.assertRaises(ValueError, format, 1, format_spec)
+ self.assertRaises(ValueError, format, -1, format_spec)
+ self.assertRaises(ValueError, format, 2**100, format_spec)
+ self.assertRaises(ValueError, format, -(2**100), format_spec)
+
+ # ensure that float type specifiers work; format converts
+ # the int to a float
+ for format_spec in 'eEfFgG%':
+ for value in [0, 1, -1, 100, -100, 1234567890, -1234567890]:
+ self.assertEqual(format(value, format_spec),
+ format(float(value), format_spec))
+
def test_nan_inf(self):
- self.assertRaises(OverflowError, long, float('inf'))
- self.assertRaises(OverflowError, long, float('-inf'))
- self.assertRaises(ValueError, long, float('nan'))
+ self.assertRaises(OverflowError, int, float('inf'))
+ self.assertRaises(OverflowError, int, float('-inf'))
+ self.assertRaises(ValueError, int, float('nan'))
+
+ def test_true_division(self):
+ huge = 1 << 40000
+ mhuge = -huge
+ self.assertEqual(huge / huge, 1.0)
+ self.assertEqual(mhuge / mhuge, 1.0)
+ self.assertEqual(huge / mhuge, -1.0)
+ self.assertEqual(mhuge / huge, -1.0)
+ self.assertEqual(1 / huge, 0.0)
+ self.assertEqual(1 / huge, 0.0)
+ self.assertEqual(1 / mhuge, 0.0)
+ self.assertEqual(1 / mhuge, 0.0)
+ self.assertEqual((666 * huge + (huge >> 1)) / huge, 666.5)
+ self.assertEqual((666 * mhuge + (mhuge >> 1)) / mhuge, 666.5)
+ self.assertEqual((666 * huge + (huge >> 1)) / mhuge, -666.5)
+ self.assertEqual((666 * mhuge + (mhuge >> 1)) / huge, -666.5)
+ self.assertEqual(huge / (huge << 1), 0.5)
+ self.assertEqual((1000000 * huge) / huge, 1000000)
+
+ namespace = {'huge': huge, 'mhuge': mhuge}
+
+ for overflow in ["float(huge)", "float(mhuge)",
+ "huge / 1", "huge / 2", "huge / -1", "huge / -2",
+ "mhuge / 100", "mhuge / 200"]:
+ self.assertRaises(OverflowError, eval, overflow, namespace)
+
+ for underflow in ["1 / huge", "2 / huge", "-1 / huge", "-2 / huge",
+ "100 / mhuge", "200 / mhuge"]:
+ result = eval(underflow, namespace)
+ self.assertEqual(result, 0.0,
+ "expected underflow to 0 from %r" % underflow)
+
+ for zero in ["huge / 0", "mhuge / 0"]:
+ self.assertRaises(ZeroDivisionError, eval, zero, namespace)
+
+ def check_truediv(self, a, b, skip_small=True):
+ """Verify that the result of a/b is correctly rounded, by
+ comparing it with a pure Python implementation of correctly
+ rounded division. b should be nonzero."""
+
+ # skip check for small a and b: in this case, the current
+ # implementation converts the arguments to float directly and
+ # then applies a float division. This can give doubly-rounded
+ # results on x87-using machines (particularly 32-bit Linux).
+ if skip_small and max(abs(a), abs(b)) < 2**DBL_MANT_DIG:
+ return
+
+ try:
+ # use repr so that we can distinguish between -0.0 and 0.0
+ expected = repr(truediv(a, b))
+ except OverflowError:
+ expected = 'overflow'
+ except ZeroDivisionError:
+ expected = 'zerodivision'
+
+ try:
+ got = repr(a / b)
+ except OverflowError:
+ got = 'overflow'
+ except ZeroDivisionError:
+ got = 'zerodivision'
+
+ self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: "
+ "expected {}, got {}".format(a, b, expected, got))
+
+ @support.requires_IEEE_754
+ def test_correctly_rounded_true_division(self):
+ # more stringent tests than those above, checking that the
+ # result of true division of ints is always correctly rounded.
+ # This test should probably be considered CPython-specific.
+
+ # Exercise all the code paths not involving Gb-sized ints.
+ # ... divisions involving zero
+ self.check_truediv(123, 0)
+ self.check_truediv(-456, 0)
+ self.check_truediv(0, 3)
+ self.check_truediv(0, -3)
+ self.check_truediv(0, 0)
+ # ... overflow or underflow by large margin
+ self.check_truediv(671 * 12345 * 2**DBL_MAX_EXP, 12345)
+ self.check_truediv(12345, 345678 * 2**(DBL_MANT_DIG - DBL_MIN_EXP))
+ # ... a much larger or smaller than b
+ self.check_truediv(12345*2**100, 98765)
+ self.check_truediv(12345*2**30, 98765*7**81)
+ # ... a / b near a boundary: one of 1, 2**DBL_MANT_DIG, 2**DBL_MIN_EXP,
+ # 2**DBL_MAX_EXP, 2**(DBL_MIN_EXP-DBL_MANT_DIG)
+ bases = (0, DBL_MANT_DIG, DBL_MIN_EXP,
+ DBL_MAX_EXP, DBL_MIN_EXP - DBL_MANT_DIG)
+ for base in bases:
+ for exp in range(base - 15, base + 15):
+ self.check_truediv(75312*2**max(exp, 0), 69187*2**max(-exp, 0))
+ self.check_truediv(69187*2**max(exp, 0), 75312*2**max(-exp, 0))
+
+ # overflow corner case
+ for m in [1, 2, 7, 17, 12345, 7**100,
+ -1, -2, -5, -23, -67891, -41**50]:
+ for n in range(-10, 10):
+ self.check_truediv(m*DBL_MIN_OVERFLOW + n, m)
+ self.check_truediv(m*DBL_MIN_OVERFLOW + n, -m)
+
+ # check detection of inexactness in shifting stage
+ for n in range(250):
+ # (2**DBL_MANT_DIG+1)/(2**DBL_MANT_DIG) lies halfway
+ # between two representable floats, and would usually be
+ # rounded down under round-half-to-even. The tiniest of
+ # additions to the numerator should cause it to be rounded
+ # up instead.
+ self.check_truediv((2**DBL_MANT_DIG + 1)*12345*2**200 + 2**n,
+ 2**DBL_MANT_DIG*12345)
+
+ # 1/2731 is one of the smallest division cases that's subject
+ # to double rounding on IEEE 754 machines working internally with
+ # 64-bit precision. On such machines, the next check would fail,
+ # were it not explicitly skipped in check_truediv.
+ self.check_truediv(1, 2731)
+
+ # a particularly bad case for the old algorithm: gives an
+ # error of close to 3.5 ulps.
+ self.check_truediv(295147931372582273023, 295147932265116303360)
+ for i in range(1000):
+ self.check_truediv(10**(i+1), 10**i)
+ self.check_truediv(10**i, 10**(i+1))
+
+ # test round-half-to-even behaviour, normal result
+ for m in [1, 2, 4, 7, 8, 16, 17, 32, 12345, 7**100,
+ -1, -2, -5, -23, -67891, -41**50]:
+ for n in range(-10, 10):
+ self.check_truediv(2**DBL_MANT_DIG*m + n, m)
+
+ # test round-half-to-even, subnormal result
+ for n in range(-20, 20):
+ self.check_truediv(n, 2**1076)
+
+ # largeish random divisions: a/b where |a| <= |b| <=
+ # 2*|a|; |ans| is between 0.5 and 1.0, so error should
+ # always be bounded by 2**-54 with equality possible only
+ # if the least significant bit of q=ans*2**53 is zero.
+ for M in [10**10, 10**100, 10**1000]:
+ for i in range(1000):
+ a = random.randrange(1, M)
+ b = random.randrange(a, 2*a+1)
+ self.check_truediv(a, b)
+ self.check_truediv(-a, b)
+ self.check_truediv(a, -b)
+ self.check_truediv(-a, -b)
+
+ # and some (genuinely) random tests
+ for _ in range(10000):
+ a_bits = random.randrange(1000)
+ b_bits = random.randrange(1, 1000)
+ x = random.randrange(2**a_bits)
+ y = random.randrange(1, 2**b_bits)
+ self.check_truediv(x, y)
+ self.check_truediv(x, -y)
+ self.check_truediv(-x, y)
+ self.check_truediv(-x, -y)
+
+ def test_small_ints(self):
+ for i in range(-5, 257):
+ self.assertTrue(i is i + 0)
+ self.assertTrue(i is i * 1)
+ self.assertTrue(i is i - 0)
+ self.assertTrue(i is i // 1)
+ self.assertTrue(i is i & -1)
+ self.assertTrue(i is i | 0)
+ self.assertTrue(i is i ^ 0)
+ self.assertTrue(i is ~~i)
+ self.assertTrue(i is i**1)
+ self.assertTrue(i is int(str(i)))
+ self.assertTrue(i is i<<2>>2, str(i))
+ # corner cases
+ i = 1 << 70
+ self.assertTrue(i - i is 0)
+ self.assertTrue(0 * i is 0)
def test_bit_length(self):
tiny = 1e-10
- for x in xrange(-65000, 65000):
- x = long(x)
+ for x in range(-65000, 65000):
k = x.bit_length()
# Check equivalence with Python version
self.assertEqual(k, len(bin(x).lstrip('-0b')))
@@ -894,13 +828,13 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.assertEqual(k, 1 + math.floor(
math.log(abs(x))/math.log(2) + tiny))
- self.assertEqual((0L).bit_length(), 0)
- self.assertEqual((1L).bit_length(), 1)
- self.assertEqual((-1L).bit_length(), 1)
- self.assertEqual((2L).bit_length(), 2)
- self.assertEqual((-2L).bit_length(), 2)
+ self.assertEqual((0).bit_length(), 0)
+ self.assertEqual((1).bit_length(), 1)
+ self.assertEqual((-1).bit_length(), 1)
+ self.assertEqual((2).bit_length(), 2)
+ self.assertEqual((-2).bit_length(), 2)
for i in [2, 3, 15, 16, 17, 31, 32, 33, 63, 64, 234]:
- a = 2L**i
+ a = 2**i
self.assertEqual((a-1).bit_length(), i)
self.assertEqual((1-a).bit_length(), i)
self.assertEqual((a).bit_length(), i+1)
@@ -908,9 +842,329 @@ class LongTest(test_int.IntLongCommonTests, unittest.TestCase):
self.assertEqual((a+1).bit_length(), i+1)
self.assertEqual((-a-1).bit_length(), i+1)
+ def test_round(self):
+ # check round-half-even algorithm. For round to nearest ten;
+ # rounding map is invariant under adding multiples of 20
+ test_dict = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0,
+ 6:10, 7:10, 8:10, 9:10, 10:10, 11:10, 12:10, 13:10, 14:10,
+ 15:20, 16:20, 17:20, 18:20, 19:20}
+ for offset in range(-520, 520, 20):
+ for k, v in test_dict.items():
+ got = round(k+offset, -1)
+ expected = v+offset
+ self.assertEqual(got, expected)
+ self.assertTrue(type(got) is int)
+
+ # larger second argument
+ self.assertEqual(round(-150, -2), -200)
+ self.assertEqual(round(-149, -2), -100)
+ self.assertEqual(round(-51, -2), -100)
+ self.assertEqual(round(-50, -2), 0)
+ self.assertEqual(round(-49, -2), 0)
+ self.assertEqual(round(-1, -2), 0)
+ self.assertEqual(round(0, -2), 0)
+ self.assertEqual(round(1, -2), 0)
+ self.assertEqual(round(49, -2), 0)
+ self.assertEqual(round(50, -2), 0)
+ self.assertEqual(round(51, -2), 100)
+ self.assertEqual(round(149, -2), 100)
+ self.assertEqual(round(150, -2), 200)
+ self.assertEqual(round(250, -2), 200)
+ self.assertEqual(round(251, -2), 300)
+ self.assertEqual(round(172500, -3), 172000)
+ self.assertEqual(round(173500, -3), 174000)
+ self.assertEqual(round(31415926535, -1), 31415926540)
+ self.assertEqual(round(31415926535, -2), 31415926500)
+ self.assertEqual(round(31415926535, -3), 31415927000)
+ self.assertEqual(round(31415926535, -4), 31415930000)
+ self.assertEqual(round(31415926535, -5), 31415900000)
+ self.assertEqual(round(31415926535, -6), 31416000000)
+ self.assertEqual(round(31415926535, -7), 31420000000)
+ self.assertEqual(round(31415926535, -8), 31400000000)
+ self.assertEqual(round(31415926535, -9), 31000000000)
+ self.assertEqual(round(31415926535, -10), 30000000000)
+ self.assertEqual(round(31415926535, -11), 0)
+ self.assertEqual(round(31415926535, -12), 0)
+ self.assertEqual(round(31415926535, -999), 0)
+
+ # should get correct results even for huge inputs
+ for k in range(10, 100):
+ got = round(10**k + 324678, -3)
+ expect = 10**k + 325000
+ self.assertEqual(got, expect)
+ self.assertTrue(type(got) is int)
+
+ # nonnegative second argument: round(x, n) should just return x
+ for n in range(5):
+ for i in range(100):
+ x = random.randrange(-10000, 10000)
+ got = round(x, n)
+ self.assertEqual(got, x)
+ self.assertTrue(type(got) is int)
+ for huge_n in 2**31-1, 2**31, 2**63-1, 2**63, 2**100, 10**100:
+ self.assertEqual(round(8979323, huge_n), 8979323)
+
+ # omitted second argument
+ for i in range(100):
+ x = random.randrange(-10000, 10000)
+ got = round(x)
+ self.assertEqual(got, x)
+ self.assertTrue(type(got) is int)
+
+ # bad second argument
+ bad_exponents = ('brian', 2.0, 0j, None)
+ for e in bad_exponents:
+ self.assertRaises(TypeError, round, 3, e)
+
+ def test_to_bytes(self):
+ def check(tests, byteorder, signed=False):
+ for test, expected in tests.items():
+ try:
+ self.assertEqual(
+ test.to_bytes(len(expected), byteorder, signed=signed),
+ expected)
+ except Exception as err:
+ raise AssertionError(
+ "failed to convert {0} with byteorder={1} and signed={2}"
+ .format(test, byteorder, signed)) from err
+
+ # Convert integers to signed big-endian byte arrays.
+ tests1 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ -1: b'\xff',
+ -127: b'\x81',
+ -128: b'\x80',
+ -129: b'\xff\x7f',
+ 127: b'\x7f',
+ 129: b'\x00\x81',
+ -255: b'\xff\x01',
+ -256: b'\xff\x00',
+ 255: b'\x00\xff',
+ 256: b'\x01\x00',
+ 32767: b'\x7f\xff',
+ -32768: b'\xff\x80\x00',
+ 65535: b'\x00\xff\xff',
+ -65536: b'\xff\x00\x00',
+ -8388608: b'\x80\x00\x00'
+ }
+ check(tests1, 'big', signed=True)
+
+ # Convert integers to signed little-endian byte arrays.
+ tests2 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ -1: b'\xff',
+ -127: b'\x81',
+ -128: b'\x80',
+ -129: b'\x7f\xff',
+ 127: b'\x7f',
+ 129: b'\x81\x00',
+ -255: b'\x01\xff',
+ -256: b'\x00\xff',
+ 255: b'\xff\x00',
+ 256: b'\x00\x01',
+ 32767: b'\xff\x7f',
+ -32768: b'\x00\x80',
+ 65535: b'\xff\xff\x00',
+ -65536: b'\x00\x00\xff',
+ -8388608: b'\x00\x00\x80'
+ }
+ check(tests2, 'little', signed=True)
+
+ # Convert integers to unsigned big-endian byte arrays.
+ tests3 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ 127: b'\x7f',
+ 128: b'\x80',
+ 255: b'\xff',
+ 256: b'\x01\x00',
+ 32767: b'\x7f\xff',
+ 32768: b'\x80\x00',
+ 65535: b'\xff\xff',
+ 65536: b'\x01\x00\x00'
+ }
+ check(tests3, 'big', signed=False)
+
+ # Convert integers to unsigned little-endian byte arrays.
+ tests4 = {
+ 0: b'\x00',
+ 1: b'\x01',
+ 127: b'\x7f',
+ 128: b'\x80',
+ 255: b'\xff',
+ 256: b'\x00\x01',
+ 32767: b'\xff\x7f',
+ 32768: b'\x00\x80',
+ 65535: b'\xff\xff',
+ 65536: b'\x00\x00\x01'
+ }
+ check(tests4, 'little', signed=False)
+
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=False)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'big', signed=True)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=False)
+ self.assertRaises(OverflowError, (256).to_bytes, 1, 'little', signed=True)
+ self.assertRaises(OverflowError, (-1).to_bytes, 2, 'big', signed=False),
+ self.assertRaises(OverflowError, (-1).to_bytes, 2, 'little', signed=False)
+ self.assertEqual((0).to_bytes(0, 'big'), b'')
+ self.assertEqual((1).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x01')
+ self.assertEqual((0).to_bytes(5, 'big'), b'\x00\x00\x00\x00\x00')
+ self.assertEqual((-1).to_bytes(5, 'big', signed=True),
+ b'\xff\xff\xff\xff\xff')
+ self.assertRaises(OverflowError, (1).to_bytes, 0, 'big')
+
+ def test_from_bytes(self):
+ def check(tests, byteorder, signed=False):
+ for test, expected in tests.items():
+ try:
+ self.assertEqual(
+ int.from_bytes(test, byteorder, signed=signed),
+ expected)
+ except Exception as err:
+ raise AssertionError(
+ "failed to convert {0} with byteorder={1!r} and signed={2}"
+ .format(test, byteorder, signed)) from err
+
+ # Convert signed big-endian byte arrays to integers.
+ tests1 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x00\x00': 0,
+ b'\x01': 1,
+ b'\x00\x01': 1,
+ b'\xff': -1,
+ b'\xff\xff': -1,
+ b'\x81': -127,
+ b'\x80': -128,
+ b'\xff\x7f': -129,
+ b'\x7f': 127,
+ b'\x00\x81': 129,
+ b'\xff\x01': -255,
+ b'\xff\x00': -256,
+ b'\x00\xff': 255,
+ b'\x01\x00': 256,
+ b'\x7f\xff': 32767,
+ b'\x80\x00': -32768,
+ b'\x00\xff\xff': 65535,
+ b'\xff\x00\x00': -65536,
+ b'\x80\x00\x00': -8388608
+ }
+ check(tests1, 'big', signed=True)
+
+ # Convert signed little-endian byte arrays to integers.
+ tests2 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x00\x00': 0,
+ b'\x01': 1,
+ b'\x00\x01': 256,
+ b'\xff': -1,
+ b'\xff\xff': -1,
+ b'\x81': -127,
+ b'\x80': -128,
+ b'\x7f\xff': -129,
+ b'\x7f': 127,
+ b'\x81\x00': 129,
+ b'\x01\xff': -255,
+ b'\x00\xff': -256,
+ b'\xff\x00': 255,
+ b'\x00\x01': 256,
+ b'\xff\x7f': 32767,
+ b'\x00\x80': -32768,
+ b'\xff\xff\x00': 65535,
+ b'\x00\x00\xff': -65536,
+ b'\x00\x00\x80': -8388608
+ }
+ check(tests2, 'little', signed=True)
+
+ # Convert unsigned big-endian byte arrays to integers.
+ tests3 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x01': 1,
+ b'\x7f': 127,
+ b'\x80': 128,
+ b'\xff': 255,
+ b'\x01\x00': 256,
+ b'\x7f\xff': 32767,
+ b'\x80\x00': 32768,
+ b'\xff\xff': 65535,
+ b'\x01\x00\x00': 65536,
+ }
+ check(tests3, 'big', signed=False)
+
+ # Convert integers to unsigned little-endian byte arrays.
+ tests4 = {
+ b'': 0,
+ b'\x00': 0,
+ b'\x01': 1,
+ b'\x7f': 127,
+ b'\x80': 128,
+ b'\xff': 255,
+ b'\x00\x01': 256,
+ b'\xff\x7f': 32767,
+ b'\x00\x80': 32768,
+ b'\xff\xff': 65535,
+ b'\x00\x00\x01': 65536,
+ }
+ check(tests4, 'little', signed=False)
+
+ class myint(int):
+ pass
+
+ self.assertTrue(type(myint.from_bytes(b'\x00', 'big')) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'big'), 1)
+ self.assertTrue(
+ type(myint.from_bytes(b'\x00', 'big', signed=False)) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'big', signed=False), 1)
+ self.assertTrue(type(myint.from_bytes(b'\x00', 'little')) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'little'), 1)
+ self.assertTrue(type(myint.from_bytes(
+ b'\x00', 'little', signed=False)) is myint)
+ self.assertEqual(myint.from_bytes(b'\x01', 'little', signed=False), 1)
+ self.assertEqual(
+ int.from_bytes([255, 0, 0], 'big', signed=True), -65536)
+ self.assertEqual(
+ int.from_bytes((255, 0, 0), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ bytearray(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ array.array('B', b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertEqual(int.from_bytes(
+ memoryview(b'\xff\x00\x00'), 'big', signed=True), -65536)
+ self.assertRaises(ValueError, int.from_bytes, [256], 'big')
+ self.assertRaises(ValueError, int.from_bytes, [0], 'big\x00')
+ self.assertRaises(ValueError, int.from_bytes, [0], 'little\x00')
+ self.assertRaises(TypeError, int.from_bytes, "", 'big')
+ self.assertRaises(TypeError, int.from_bytes, "\x00", 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
+ self.assertRaises(TypeError, myint.from_bytes, "", 'big')
+ self.assertRaises(TypeError, myint.from_bytes, "\x00", 'big')
+ self.assertRaises(TypeError, myint.from_bytes, 0, 'big')
+ self.assertRaises(TypeError, int.from_bytes, 0, 'big', True)
+
+ def test_access_to_nonexistent_digit_0(self):
+ # http://bugs.python.org/issue14630: A bug in _PyLong_Copy meant that
+ # ob_digit[0] was being incorrectly accessed for instances of a
+ # subclass of int, with value 0.
+ class Integer(int):
+ def __new__(cls, value=0):
+ self = int.__new__(cls, value)
+ self.foo = 'foo'
+ return self
+
+ integers = [Integer(0) for i in range(1000)]
+ for n in map(int, integers):
+ self.assertEqual(n, 0)
+
def test_main():
- test_support.run_unittest(LongTest)
+ support.run_unittest(LongTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_long_future.py b/Lib/test/test_long_future.py
deleted file mode 100644
index 76c3bfbdbc5..00000000000
--- a/Lib/test/test_long_future.py
+++ /dev/null
@@ -1,221 +0,0 @@
-from __future__ import division
-# When true division is the default, get rid of this and add it to
-# test_long.py instead. In the meantime, it's too obscure to try to
-# trick just part of test_long into using future division.
-
-import sys
-import random
-import math
-import unittest
-from test.test_support import run_unittest
-
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
-
-DBL_MAX = sys.float_info.max
-DBL_MAX_EXP = sys.float_info.max_exp
-DBL_MIN_EXP = sys.float_info.min_exp
-DBL_MANT_DIG = sys.float_info.mant_dig
-DBL_MIN_OVERFLOW = 2**DBL_MAX_EXP - 2**(DBL_MAX_EXP - DBL_MANT_DIG - 1)
-
-# pure Python version of correctly-rounded true division
-def truediv(a, b):
- """Correctly-rounded true division for integers."""
- negative = a^b < 0
- a, b = abs(a), abs(b)
-
- # exceptions: division by zero, overflow
- if not b:
- raise ZeroDivisionError("division by zero")
- if a >= DBL_MIN_OVERFLOW * b:
- raise OverflowError("int/int too large to represent as a float")
-
- # find integer d satisfying 2**(d - 1) <= a/b < 2**d
- d = a.bit_length() - b.bit_length()
- if d >= 0 and a >= 2**d * b or d < 0 and a * 2**-d >= b:
- d += 1
-
- # compute 2**-exp * a / b for suitable exp
- exp = max(d, DBL_MIN_EXP) - DBL_MANT_DIG
- a, b = a << max(-exp, 0), b << max(exp, 0)
- q, r = divmod(a, b)
-
- # round-half-to-even: fractional part is r/b, which is > 0.5 iff
- # 2*r > b, and == 0.5 iff 2*r == b.
- if 2*r > b or 2*r == b and q % 2 == 1:
- q += 1
-
- result = math.ldexp(float(q), exp)
- return -result if negative else result
-
-class TrueDivisionTests(unittest.TestCase):
- def test(self):
- huge = 1L << 40000
- mhuge = -huge
- self.assertEqual(huge / huge, 1.0)
- self.assertEqual(mhuge / mhuge, 1.0)
- self.assertEqual(huge / mhuge, -1.0)
- self.assertEqual(mhuge / huge, -1.0)
- self.assertEqual(1 / huge, 0.0)
- self.assertEqual(1L / huge, 0.0)
- self.assertEqual(1 / mhuge, 0.0)
- self.assertEqual(1L / mhuge, 0.0)
- self.assertEqual((666 * huge + (huge >> 1)) / huge, 666.5)
- self.assertEqual((666 * mhuge + (mhuge >> 1)) / mhuge, 666.5)
- self.assertEqual((666 * huge + (huge >> 1)) / mhuge, -666.5)
- self.assertEqual((666 * mhuge + (mhuge >> 1)) / huge, -666.5)
- self.assertEqual(huge / (huge << 1), 0.5)
- self.assertEqual((1000000 * huge) / huge, 1000000)
-
- namespace = {'huge': huge, 'mhuge': mhuge}
-
- for overflow in ["float(huge)", "float(mhuge)",
- "huge / 1", "huge / 2L", "huge / -1", "huge / -2L",
- "mhuge / 100", "mhuge / 100L"]:
- # If the "eval" does not happen in this module,
- # true division is not enabled
- with self.assertRaises(OverflowError):
- eval(overflow, namespace)
-
- for underflow in ["1 / huge", "2L / huge", "-1 / huge", "-2L / huge",
- "100 / mhuge", "100L / mhuge"]:
- result = eval(underflow, namespace)
- self.assertEqual(result, 0.0, 'expected underflow to 0 '
- 'from {!r}'.format(underflow))
-
- for zero in ["huge / 0", "huge / 0L", "mhuge / 0", "mhuge / 0L"]:
- with self.assertRaises(ZeroDivisionError):
- eval(zero, namespace)
-
- def check_truediv(self, a, b, skip_small=True):
- """Verify that the result of a/b is correctly rounded, by
- comparing it with a pure Python implementation of correctly
- rounded division. b should be nonzero."""
-
- a, b = long(a), long(b)
-
- # skip check for small a and b: in this case, the current
- # implementation converts the arguments to float directly and
- # then applies a float division. This can give doubly-rounded
- # results on x87-using machines (particularly 32-bit Linux).
- if skip_small and max(abs(a), abs(b)) < 2**DBL_MANT_DIG:
- return
-
- try:
- # use repr so that we can distinguish between -0.0 and 0.0
- expected = repr(truediv(a, b))
- except OverflowError:
- expected = 'overflow'
- except ZeroDivisionError:
- expected = 'zerodivision'
-
- try:
- got = repr(a / b)
- except OverflowError:
- got = 'overflow'
- except ZeroDivisionError:
- got = 'zerodivision'
-
- self.assertEqual(expected, got, "Incorrectly rounded division {}/{}: "
- "expected {}, got {}".format(a, b, expected, got))
-
- @requires_IEEE_754
- def test_correctly_rounded_true_division(self):
- # more stringent tests than those above, checking that the
- # result of true division of ints is always correctly rounded.
- # This test should probably be considered CPython-specific.
-
- # Exercise all the code paths not involving Gb-sized ints.
- # ... divisions involving zero
- self.check_truediv(123, 0)
- self.check_truediv(-456, 0)
- self.check_truediv(0, 3)
- self.check_truediv(0, -3)
- self.check_truediv(0, 0)
- # ... overflow or underflow by large margin
- self.check_truediv(671 * 12345 * 2**DBL_MAX_EXP, 12345)
- self.check_truediv(12345, 345678 * 2**(DBL_MANT_DIG - DBL_MIN_EXP))
- # ... a much larger or smaller than b
- self.check_truediv(12345*2**100, 98765)
- self.check_truediv(12345*2**30, 98765*7**81)
- # ... a / b near a boundary: one of 1, 2**DBL_MANT_DIG, 2**DBL_MIN_EXP,
- # 2**DBL_MAX_EXP, 2**(DBL_MIN_EXP-DBL_MANT_DIG)
- bases = (0, DBL_MANT_DIG, DBL_MIN_EXP,
- DBL_MAX_EXP, DBL_MIN_EXP - DBL_MANT_DIG)
- for base in bases:
- for exp in range(base - 15, base + 15):
- self.check_truediv(75312*2**max(exp, 0), 69187*2**max(-exp, 0))
- self.check_truediv(69187*2**max(exp, 0), 75312*2**max(-exp, 0))
-
- # overflow corner case
- for m in [1, 2, 7, 17, 12345, 7**100,
- -1, -2, -5, -23, -67891, -41**50]:
- for n in range(-10, 10):
- self.check_truediv(m*DBL_MIN_OVERFLOW + n, m)
- self.check_truediv(m*DBL_MIN_OVERFLOW + n, -m)
-
- # check detection of inexactness in shifting stage
- for n in range(250):
- # (2**DBL_MANT_DIG+1)/(2**DBL_MANT_DIG) lies halfway
- # between two representable floats, and would usually be
- # rounded down under round-half-to-even. The tiniest of
- # additions to the numerator should cause it to be rounded
- # up instead.
- self.check_truediv((2**DBL_MANT_DIG + 1)*12345*2**200 + 2**n,
- 2**DBL_MANT_DIG*12345)
-
- # 1/2731 is one of the smallest division cases that's subject
- # to double rounding on IEEE 754 machines working internally with
- # 64-bit precision. On such machines, the next check would fail,
- # were it not explicitly skipped in check_truediv.
- self.check_truediv(1, 2731)
-
- # a particularly bad case for the old algorithm: gives an
- # error of close to 3.5 ulps.
- self.check_truediv(295147931372582273023, 295147932265116303360)
- for i in range(1000):
- self.check_truediv(10**(i+1), 10**i)
- self.check_truediv(10**i, 10**(i+1))
-
- # test round-half-to-even behaviour, normal result
- for m in [1, 2, 4, 7, 8, 16, 17, 32, 12345, 7**100,
- -1, -2, -5, -23, -67891, -41**50]:
- for n in range(-10, 10):
- self.check_truediv(2**DBL_MANT_DIG*m + n, m)
-
- # test round-half-to-even, subnormal result
- for n in range(-20, 20):
- self.check_truediv(n, 2**1076)
-
- # largeish random divisions: a/b where |a| <= |b| <=
- # 2*|a|; |ans| is between 0.5 and 1.0, so error should
- # always be bounded by 2**-54 with equality possible only
- # if the least significant bit of q=ans*2**53 is zero.
- for M in [10**10, 10**100, 10**1000]:
- for i in range(1000):
- a = random.randrange(1, M)
- b = random.randrange(a, 2*a+1)
- self.check_truediv(a, b)
- self.check_truediv(-a, b)
- self.check_truediv(a, -b)
- self.check_truediv(-a, -b)
-
- # and some (genuinely) random tests
- for _ in range(10000):
- a_bits = random.randrange(1000)
- b_bits = random.randrange(1, 1000)
- x = random.randrange(2**a_bits)
- y = random.randrange(1, 2**b_bits)
- self.check_truediv(x, y)
- self.check_truediv(x, -y)
- self.check_truediv(-x, y)
- self.check_truediv(-x, -y)
-
-
-def test_main():
- run_unittest(TrueDivisionTests)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_longexp.py b/Lib/test/test_longexp.py
index dd222a19bff..1b40d029831 100644
--- a/Lib/test/test_longexp.py
+++ b/Lib/test/test_longexp.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support
+from test import support
class LongExpText(unittest.TestCase):
def test_longexp(self):
@@ -8,7 +8,7 @@ class LongExpText(unittest.TestCase):
self.assertEqual(len(l), REPS)
def test_main():
- test_support.run_unittest(LongExpText)
+ support.run_unittest(LongExpText)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_macos.py b/Lib/test/test_macos.py
deleted file mode 100644
index 5af51053ce4..00000000000
--- a/Lib/test/test_macos.py
+++ /dev/null
@@ -1,98 +0,0 @@
-import unittest
-from test import test_support
-import os
-import subprocess
-
-MacOS = test_support.import_module('MacOS')
-
-TESTFN2 = test_support.TESTFN + '2'
-
-class TestMacOS(unittest.TestCase):
-
- def testGetCreatorAndType(self):
- if not os.path.exists('/Developer/Tools/SetFile'):
- return
-
- try:
- fp = open(test_support.TESTFN, 'w')
- fp.write('\n')
- fp.close()
-
- subprocess.call(
- ['/Developer/Tools/SetFile', '-t', 'ABCD', '-c', 'EFGH',
- test_support.TESTFN])
-
- cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN)
- self.assertEqual(tp, 'ABCD')
- self.assertEqual(cr, 'EFGH')
-
- finally:
- os.unlink(test_support.TESTFN)
-
- def testSetCreatorAndType(self):
- if not os.path.exists('/Developer/Tools/GetFileInfo'):
- return
-
- try:
- fp = open(test_support.TESTFN, 'w')
- fp.write('\n')
- fp.close()
-
- MacOS.SetCreatorAndType(test_support.TESTFN,
- 'ABCD', 'EFGH')
-
- cr, tp = MacOS.GetCreatorAndType(test_support.TESTFN)
- self.assertEqual(cr, 'ABCD')
- self.assertEqual(tp, 'EFGH')
-
- data = subprocess.Popen(["/Developer/Tools/GetFileInfo", test_support.TESTFN],
- stdout=subprocess.PIPE).communicate()[0]
-
- tp = None
- cr = None
- for ln in data.splitlines():
- if ln.startswith('type:'):
- tp = ln.split()[-1][1:-1]
- if ln.startswith('creator:'):
- cr = ln.split()[-1][1:-1]
-
- self.assertEqual(cr, 'ABCD')
- self.assertEqual(tp, 'EFGH')
-
- finally:
- os.unlink(test_support.TESTFN)
-
-
- def testOpenRF(self):
- try:
- fp = open(test_support.TESTFN, 'w')
- fp.write('hello world\n')
- fp.close()
-
- rfp = MacOS.openrf(test_support.TESTFN, '*wb')
- rfp.write('goodbye world\n')
- rfp.close()
-
-
- fp = open(test_support.TESTFN, 'r')
- data = fp.read()
- fp.close()
- self.assertEqual(data, 'hello world\n')
-
- rfp = MacOS.openrf(test_support.TESTFN, '*rb')
- data = rfp.read(100)
- data2 = rfp.read(100)
- rfp.close()
- self.assertEqual(data, 'goodbye world\n')
- self.assertEqual(data2, '')
-
-
- finally:
- os.unlink(test_support.TESTFN)
-
-def test_main():
- test_support.run_unittest(TestMacOS)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_macostools.py b/Lib/test/test_macostools.py
deleted file mode 100644
index 4f159829795..00000000000
--- a/Lib/test/test_macostools.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Copyright (C) 2003 Python Software Foundation
-
-import unittest
-import os
-import sys
-from test import test_support
-
-MacOS = test_support.import_module('MacOS')
-#The following modules should exist if MacOS exists.
-import Carbon.File
-import macostools
-
-TESTFN2 = test_support.TESTFN + '2'
-
-class TestMacostools(unittest.TestCase):
-
- def setUp(self):
- fp = open(test_support.TESTFN, 'w')
- fp.write('hello world\n')
- fp.close()
- rfp = MacOS.openrf(test_support.TESTFN, '*wb')
- rfp.write('goodbye world\n')
- rfp.close()
-
- def tearDown(self):
- test_support.unlink(test_support.TESTFN)
- test_support.unlink(TESTFN2)
-
- def compareData(self):
- fp = open(test_support.TESTFN, 'r')
- data1 = fp.read()
- fp.close()
- fp = open(TESTFN2, 'r')
- data2 = fp.read()
- fp.close()
- if data1 != data2:
- return 'Data forks differ'
- rfp = MacOS.openrf(test_support.TESTFN, '*rb')
- data1 = rfp.read(1000)
- rfp.close()
- rfp = MacOS.openrf(TESTFN2, '*rb')
- data2 = rfp.read(1000)
- rfp.close()
- if data1 != data2:
- return 'Resource forks differ'
- return ''
-
- def test_touched(self):
- # This really only tests that nothing unforeseen happens.
- with test_support.check_warnings(('macostools.touched*',
- DeprecationWarning), quiet=True):
- macostools.touched(test_support.TESTFN)
-
- if sys.maxint < 2**32:
- def test_copy(self):
- test_support.unlink(TESTFN2)
- macostools.copy(test_support.TESTFN, TESTFN2)
- self.assertEqual(self.compareData(), '')
-
- if sys.maxint < 2**32:
- def test_mkalias(self):
- test_support.unlink(TESTFN2)
- macostools.mkalias(test_support.TESTFN, TESTFN2)
- fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
- self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
-
- def test_mkalias_relative(self):
- test_support.unlink(TESTFN2)
- # If the directory doesn't exist, then chances are this is a new
- # install of Python so don't create it since the user might end up
- # running ``sudo make install`` and creating the directory here won't
- # leave it with the proper permissions.
- if not os.path.exists(sys.prefix):
- return
- macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix)
- fss, _, _ = Carbon.File.ResolveAliasFile(TESTFN2, 0)
- self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
-
-
-def test_main():
- # Skip on wide unicode
- if len(u'\0'.encode('unicode-internal')) == 4:
- raise unittest.SkipTest("test_macostools is broken in USC4")
- test_support.run_unittest(TestMacostools)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_macpath.py b/Lib/test/test_macpath.py
index 2c86c532c7e..d732e14a3a4 100644
--- a/Lib/test/test_macpath.py
+++ b/Lib/test/test_macpath.py
@@ -1,5 +1,5 @@
import macpath
-from test import test_support, test_genericpath
+from test import support, test_genericpath
import unittest
@@ -18,6 +18,14 @@ class MacPathTestCase(unittest.TestCase):
self.assertFalse(isabs(":foo:bar"))
self.assertFalse(isabs(":foo:bar:"))
+ self.assertTrue(isabs(b"xx:yy"))
+ self.assertTrue(isabs(b"xx:yy:"))
+ self.assertTrue(isabs(b"xx:"))
+ self.assertFalse(isabs(b"foo"))
+ self.assertFalse(isabs(b":foo"))
+ self.assertFalse(isabs(b":foo:bar"))
+ self.assertFalse(isabs(b":foo:bar:"))
+
def test_split(self):
split = macpath.split
self.assertEqual(split("foo:bar"),
@@ -29,6 +37,29 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(split(":conky:mountpoint:"),
(':conky:mountpoint', ''))
+ self.assertEqual(split(b"foo:bar"),
+ (b'foo:', b'bar'))
+ self.assertEqual(split(b"conky:mountpoint:foo:bar"),
+ (b'conky:mountpoint:foo', b'bar'))
+
+ self.assertEqual(split(b":"), (b'', b''))
+ self.assertEqual(split(b":conky:mountpoint:"),
+ (b':conky:mountpoint', b''))
+
+ def test_join(self):
+ join = macpath.join
+ self.assertEqual(join('a', 'b'), ':a:b')
+ self.assertEqual(join('', 'a:b'), 'a:b')
+ self.assertEqual(join('a:b', 'c'), 'a:b:c')
+ self.assertEqual(join('a:b', ':c'), 'a:b:c')
+ self.assertEqual(join('a', ':b', ':c'), ':a:b:c')
+
+ self.assertEqual(join(b'a', b'b'), b':a:b')
+ self.assertEqual(join(b'', b'a:b'), b'a:b')
+ self.assertEqual(join(b'a:b', b'c'), b'a:b:c')
+ self.assertEqual(join(b'a:b', b':c'), b'a:b:c')
+ self.assertEqual(join(b'a', b':b', b':c'), b':a:b:c')
+
def test_splitext(self):
splitext = macpath.splitext
self.assertEqual(splitext(":foo.ext"), (':foo', '.ext'))
@@ -39,18 +70,57 @@ class MacPathTestCase(unittest.TestCase):
self.assertEqual(splitext(""), ('', ''))
self.assertEqual(splitext("foo.bar.ext"), ('foo.bar', '.ext'))
+ self.assertEqual(splitext(b":foo.ext"), (b':foo', b'.ext'))
+ self.assertEqual(splitext(b"foo:foo.ext"), (b'foo:foo', b'.ext'))
+ self.assertEqual(splitext(b".ext"), (b'.ext', b''))
+ self.assertEqual(splitext(b"foo.ext:foo"), (b'foo.ext:foo', b''))
+ self.assertEqual(splitext(b":foo.ext:"), (b':foo.ext:', b''))
+ self.assertEqual(splitext(b""), (b'', b''))
+ self.assertEqual(splitext(b"foo.bar.ext"), (b'foo.bar', b'.ext'))
+
+ def test_ismount(self):
+ ismount = macpath.ismount
+ self.assertEqual(ismount("a:"), True)
+ self.assertEqual(ismount("a:b"), False)
+ self.assertEqual(ismount("a:b:"), True)
+ self.assertEqual(ismount(""), False)
+ self.assertEqual(ismount(":"), False)
+
+ self.assertEqual(ismount(b"a:"), True)
+ self.assertEqual(ismount(b"a:b"), False)
+ self.assertEqual(ismount(b"a:b:"), True)
+ self.assertEqual(ismount(b""), False)
+ self.assertEqual(ismount(b":"), False)
+
def test_normpath(self):
- # Issue 5827: Make sure normpath preserves unicode
- for path in (u'', u'.', u'/', u'\\', u':', u'///foo/.//bar//'):
- self.assertIsInstance(macpath.normpath(path), unicode,
- 'normpath() returned str instead of unicode')
+ normpath = macpath.normpath
+ self.assertEqual(normpath("a:b"), "a:b")
+ self.assertEqual(normpath("a"), ":a")
+ self.assertEqual(normpath("a:b::c"), "a:c")
+ self.assertEqual(normpath("a:b:c:::d"), "a:d")
+ self.assertRaises(macpath.norm_error, normpath, "a::b")
+ self.assertRaises(macpath.norm_error, normpath, "a:b:::c")
+ self.assertEqual(normpath(":"), ":")
+ self.assertEqual(normpath("a:"), "a:")
+ self.assertEqual(normpath("a:b:"), "a:b")
+
+ self.assertEqual(normpath(b"a:b"), b"a:b")
+ self.assertEqual(normpath(b"a"), b":a")
+ self.assertEqual(normpath(b"a:b::c"), b"a:c")
+ self.assertEqual(normpath(b"a:b:c:::d"), b"a:d")
+ self.assertRaises(macpath.norm_error, normpath, b"a::b")
+ self.assertRaises(macpath.norm_error, normpath, b"a:b:::c")
+ self.assertEqual(normpath(b":"), b":")
+ self.assertEqual(normpath(b"a:"), b"a:")
+ self.assertEqual(normpath(b"a:b:"), b"a:b")
+
class MacCommonTest(test_genericpath.CommonTest):
pathmodule = macpath
def test_main():
- test_support.run_unittest(MacPathTestCase, MacCommonTest)
+ support.run_unittest(MacPathTestCase, MacCommonTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_mailbox.py b/Lib/test/test_mailbox.py
index 01c4373fade..c72eb1c949c 100644
--- a/Lib/test/test_mailbox.py
+++ b/Lib/test/test_mailbox.py
@@ -6,11 +6,12 @@ import socket
import email
import email.message
import re
+import io
import shutil
-import StringIO
import tempfile
-from test import test_support
+from test import support
import unittest
+import textwrap
import mailbox
import glob
try:
@@ -18,8 +19,6 @@ try:
except ImportError:
pass
-# Silence Py3k warning
-rfc822 = test_support.import_module('rfc822', deprecated=True)
class TestBase:
@@ -27,7 +26,7 @@ class TestBase:
# Inspect a mailbox.Message representation of the sample message
self.assertIsInstance(msg, email.message.Message)
self.assertIsInstance(msg, mailbox.Message)
- for key, value in _sample_headers.iteritems():
+ for key, value in _sample_headers.items():
self.assertIn(value, msg.get_all(key))
self.assertTrue(msg.is_multipart())
self.assertEqual(len(msg.get_payload()), len(_sample_payloads))
@@ -47,11 +46,13 @@ class TestBase:
class TestMailbox(TestBase):
+ maxDiff = None
+
_factory = None # Overridden by subclasses to reuse tests
_template = 'From: foo\n\n%s\n'
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._delete_recursively(self._path)
self._box = self._factory(self._path)
@@ -68,26 +69,118 @@ class TestMailbox(TestBase):
self.assertEqual(len(self._box), 2)
keys.append(self._box.add(email.message_from_string(_sample_message)))
self.assertEqual(len(self._box), 3)
- keys.append(self._box.add(StringIO.StringIO(_sample_message)))
+ keys.append(self._box.add(io.BytesIO(_bytes_sample_message)))
self.assertEqual(len(self._box), 4)
keys.append(self._box.add(_sample_message))
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.assertEqual(self._box.get_string(keys[0]), self._template % 0)
- for i in (1, 2, 3, 4):
+ for i in (1, 2, 3, 4, 5, 6):
self._check_sample(self._box[keys[i]])
- def test_add_file(self):
- with tempfile.TemporaryFile('w+') as f:
- f.write(_sample_message)
+ _nonascii_msg = textwrap.dedent("""\
+ From: foo
+ Subject: Falinaptár házhozszállítással. Már rendeltél?
+
+ 0
+ """)
+
+ def test_add_invalid_8bit_bytes_header(self):
+ key = self._box.add(self._nonascii_msg.encode('latin1'))
+ self.assertEqual(len(self._box), 1)
+ self.assertEqual(self._box.get_bytes(key),
+ self._nonascii_msg.encode('latin1'))
+
+ def test_invalid_nonascii_header_as_string(self):
+ subj = self._nonascii_msg.splitlines()[1]
+ key = self._box.add(subj.encode('latin1'))
+ self.assertEqual(self._box.get_string(key),
+ 'Subject: =?unknown-8bit?b?RmFsaW5hcHThciBo4Xpob3pzeuFsbO104XNz'
+ 'YWwuIE3hciByZW5kZWx06Ww/?=\n\n')
+
+ def test_add_nonascii_string_header_raises(self):
+ with self.assertRaisesRegex(ValueError, "ASCII-only"):
+ self._box.add(self._nonascii_msg)
+ self._box.flush()
+ self.assertEqual(len(self._box), 0)
+ self.assertMailboxEmpty()
+
+ def test_add_that_raises_leaves_mailbox_empty(self):
+ def raiser(*args, **kw):
+ raise Exception("a fake error")
+ support.patch(self, email.generator.BytesGenerator, 'flatten', raiser)
+ with self.assertRaises(Exception):
+ self._box.add(email.message_from_string("From: Alphöso"))
+ self.assertEqual(len(self._box), 0)
+ self._box.close()
+ self.assertMailboxEmpty()
+
+ _non_latin_bin_msg = textwrap.dedent("""\
+ From: foo@bar.com
+ To: báz
+ Subject: Maintenant je vous présente mon collègue, le pouf célèbre
+ \tJean de Baddie
+ Mime-Version: 1.0
+ Content-Type: text/plain; charset="utf-8"
+ Content-Transfer-Encoding: 8bit
+
+ Да, они летÑÑ‚.
+ """).encode('utf-8')
+
+ def test_add_8bit_body(self):
+ key = self._box.add(self._non_latin_bin_msg)
+ self.assertEqual(self._box.get_bytes(key),
+ self._non_latin_bin_msg)
+ with self._box.get_file(key) as f:
+ self.assertEqual(f.read(),
+ self._non_latin_bin_msg.replace(b'\n',
+ os.linesep.encode()))
+ self.assertEqual(self._box[key].get_payload(),
+ "Да, они летÑÑ‚.\n")
+
+ def test_add_binary_file(self):
+ with tempfile.TemporaryFile('wb+') as f:
+ f.write(_bytes_sample_message)
f.seek(0)
key = self._box.add(f)
- self.assertEqual(self._box.get_string(key).split('\n'),
- _sample_message.split('\n'))
+ self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+ _bytes_sample_message.split(b'\n'))
- def test_add_StringIO(self):
- key = self._box.add(StringIO.StringIO(self._template % "0"))
+ def test_add_binary_nonascii_file(self):
+ with tempfile.TemporaryFile('wb+') as f:
+ f.write(self._non_latin_bin_msg)
+ f.seek(0)
+ key = self._box.add(f)
+ 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):
+ with tempfile.TemporaryFile('w+') as f:
+ f.write(_sample_message)
+ f.seek(0)
+ with self.assertWarns(DeprecationWarning):
+ key = self._box.add(f)
+ self.assertEqual(self._box.get_bytes(key).split(b'\n'),
+ _bytes_sample_message.split(b'\n'))
+
+ 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))
+ self.assertEqual(len(self._box), 0)
+ self._box.close()
+ self.assertMailboxEmpty()
+
def test_remove(self):
# Remove messages using remove()
self._test_remove_or_delitem(self._box.remove)
@@ -102,16 +195,14 @@ class TestMailbox(TestBase):
key1 = self._box.add(self._template % 1)
self.assertEqual(len(self._box), 2)
method(key0)
- l = len(self._box)
- self.assertEqual(l, 1)
+ self.assertEqual(len(self._box), 1)
self.assertRaises(KeyError, lambda: self._box[key0])
self.assertRaises(KeyError, lambda: method(key0))
self.assertEqual(self._box.get_string(key1), self._template % 1)
key2 = self._box.add(self._template % 2)
self.assertEqual(len(self._box), 2)
method(key2)
- l = len(self._box)
- self.assertEqual(l, 1)
+ self.assertEqual(len(self._box), 1)
self.assertRaises(KeyError, lambda: self._box[key2])
self.assertRaises(KeyError, lambda: method(key2))
self.assertEqual(self._box.get_string(key1), self._template % 1)
@@ -139,14 +230,13 @@ class TestMailbox(TestBase):
self.assertEqual(msg['from'], 'foo')
self.assertEqual(msg.get_payload(), '0\n')
self.assertIs(self._box.get('foo'), None)
- self.assertFalse(self._box.get('foo', False))
+ self.assertIs(self._box.get('foo', False), False)
self._box.close()
- self._box = self._factory(self._path, factory=rfc822.Message)
+ self._box = self._factory(self._path)
key1 = self._box.add(self._template % 1)
msg = self._box.get(key1)
self.assertEqual(msg['from'], 'foo')
- self.assertEqual(msg.fp.read(), '1' + os.linesep)
- msg.fp.close()
+ self.assertEqual(msg.get_payload(), '1\n')
def test_getitem(self):
# Retrieve message using __getitem__()
@@ -168,25 +258,34 @@ class TestMailbox(TestBase):
self.assertEqual(msg0.get_payload(), '0\n')
self._check_sample(self._box.get_message(key1))
+ def test_get_bytes(self):
+ # Get bytes representations of messages
+ key0 = self._box.add(self._template % 0)
+ key1 = self._box.add(_sample_message)
+ self.assertEqual(self._box.get_bytes(key0),
+ (self._template % 0).encode('ascii'))
+ self.assertEqual(self._box.get_bytes(key1), _bytes_sample_message)
+
def test_get_string(self):
# Get string representations of messages
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
self.assertEqual(self._box.get_string(key0), self._template % 0)
- self.assertEqual(self._box.get_string(key1), _sample_message)
+ self.assertEqual(self._box.get_string(key1).split('\n'),
+ _sample_message.split('\n'))
def test_get_file(self):
# Get file representations of messages
key0 = self._box.add(self._template % 0)
key1 = self._box.add(_sample_message)
- msg0 = self._box.get_file(key0)
- self.assertEqual(msg0.read().replace(os.linesep, '\n'),
+ with self._box.get_file(key0) as file:
+ data0 = file.read()
+ with self._box.get_file(key1) as file:
+ data1 = file.read()
+ self.assertEqual(data0.decode('ascii').replace(os.linesep, '\n'),
self._template % 0)
- msg1 = self._box.get_file(key1)
- self.assertEqual(msg1.read().replace(os.linesep, '\n'),
+ self.assertEqual(data1.decode('ascii').replace(os.linesep, '\n'),
_sample_message)
- msg0.close()
- msg1.close()
def test_get_file_can_be_closed_twice(self):
# Issue 11700
@@ -197,7 +296,7 @@ class TestMailbox(TestBase):
def test_iterkeys(self):
# Get keys using iterkeys()
- self._check_iteration(self._box.iterkeys, do_keys=True, do_values=False)
+ self._check_iteration(self._box.keys, do_keys=True, do_values=False)
def test_keys(self):
# Get keys using keys()
@@ -205,7 +304,7 @@ class TestMailbox(TestBase):
def test_itervalues(self):
# Get values using itervalues()
- self._check_iteration(self._box.itervalues, do_keys=False,
+ self._check_iteration(self._box.values, do_keys=False,
do_values=True)
def test_iter(self):
@@ -219,7 +318,7 @@ class TestMailbox(TestBase):
def test_iteritems(self):
# Get keys and values using iteritems()
- self._check_iteration(self._box.iteritems, do_keys=True,
+ self._check_iteration(self._box.items, do_keys=True,
do_values=True)
def test_items(self):
@@ -230,7 +329,7 @@ class TestMailbox(TestBase):
for value in method():
self.fail("Not empty")
keys, values = [], []
- for i in xrange(repetitions):
+ for i in range(repetitions):
keys.append(self._box.add(self._template % i))
values.append(self._template % i)
if do_keys and not do_values:
@@ -249,46 +348,37 @@ class TestMailbox(TestBase):
count = 0
for value in returned_values:
self.assertEqual(value['from'], 'foo')
- self.assertTrue(int(value.get_payload()) < repetitions,
- (value.get_payload(), repetitions))
+ self.assertLess(int(value.get_payload()), repetitions)
count += 1
self.assertEqual(len(values), count)
- def test_has_key(self):
- # Check existence of keys using has_key()
- self._test_has_key_or_contains(self._box.has_key)
-
def test_contains(self):
# Check existence of keys using __contains__()
- self._test_has_key_or_contains(self._box.__contains__)
-
- def _test_has_key_or_contains(self, method):
- # (Used by test_has_key() and test_contains().)
- self.assertFalse(method('foo'))
+ self.assertNotIn('foo', self._box)
key0 = self._box.add(self._template % 0)
- self.assertTrue(method(key0))
- self.assertFalse(method('foo'))
+ self.assertIn(key0, self._box)
+ self.assertNotIn('foo', self._box)
key1 = self._box.add(self._template % 1)
- self.assertTrue(method(key1))
- self.assertTrue(method(key0))
- self.assertFalse(method('foo'))
+ self.assertIn(key1, self._box)
+ self.assertIn(key0, self._box)
+ self.assertNotIn('foo', self._box)
self._box.remove(key0)
- self.assertFalse(method(key0))
- self.assertTrue(method(key1))
- self.assertFalse(method('foo'))
+ self.assertNotIn(key0, self._box)
+ self.assertIn(key1, self._box)
+ self.assertNotIn('foo', self._box)
self._box.remove(key1)
- self.assertFalse(method(key1))
- self.assertFalse(method(key0))
- self.assertFalse(method('foo'))
+ self.assertNotIn(key1, self._box)
+ self.assertNotIn(key0, self._box)
+ self.assertNotIn('foo', self._box)
def test_len(self, repetitions=10):
# Get message count
keys = []
- for i in xrange(repetitions):
+ for i in range(repetitions):
self.assertEqual(len(self._box), i)
keys.append(self._box.add(self._template % i))
- self.assertEqual(len(self._box), i + 1)
- for i in xrange(repetitions):
+ self.assertEqual(len(self._box), i + 1)
+ for i in range(repetitions):
self.assertEqual(len(self._box), repetitions - i)
self._box.remove(keys[i])
self.assertEqual(len(self._box), repetitions - i - 1)
@@ -313,7 +403,7 @@ class TestMailbox(TestBase):
self._check_sample(self._box[key1])
self._box[key0] = self._template % 'original 0'
self.assertEqual(self._box.get_string(key0),
- self._template % 'original 0')
+ self._template % 'original 0')
self._check_sample(self._box[key1])
self.assertRaises(KeyError,
lambda: self._box.__setitem__('foo', 'bar'))
@@ -323,7 +413,7 @@ class TestMailbox(TestBase):
def test_clear(self, iterations=10):
# Remove all messages using clear()
keys = []
- for i in xrange(iterations):
+ for i in range(iterations):
self._box.add(self._template % i)
for i, key in enumerate(keys):
self.assertEqual(self._box.get_string(key), self._template % i)
@@ -353,10 +443,10 @@ class TestMailbox(TestBase):
def test_popitem(self, iterations=10):
# Get and remove an arbitrary (key, message) using popitem()
keys = []
- for i in xrange(10):
+ for i in range(10):
keys.append(self._box.add(self._template % i))
seen = []
- for i in xrange(10):
+ for i in range(10):
key, msg = self._box.popitem()
self.assertIn(key, keys)
self.assertNotIn(key, seen)
@@ -375,30 +465,30 @@ class TestMailbox(TestBase):
key2: _sample_message})
self.assertEqual(len(self._box), 3)
self.assertEqual(self._box.get_string(key0),
- self._template % 'changed 0')
+ self._template % 'changed 0')
self.assertEqual(self._box.get_string(key1),
- self._template % 'original 1')
+ self._template % 'original 1')
self._check_sample(self._box[key2])
self._box.update([(key2, self._template % 'changed 2'),
(key1, self._template % 'changed 1'),
(key0, self._template % 'original 0')])
self.assertEqual(len(self._box), 3)
self.assertEqual(self._box.get_string(key0),
- self._template % 'original 0')
+ self._template % 'original 0')
self.assertEqual(self._box.get_string(key1),
- self._template % 'changed 1')
+ self._template % 'changed 1')
self.assertEqual(self._box.get_string(key2),
- self._template % 'changed 2')
+ self._template % 'changed 2')
self.assertRaises(KeyError,
lambda: self._box.update({'foo': 'bar',
key0: self._template % "changed 0"}))
self.assertEqual(len(self._box), 3)
self.assertEqual(self._box.get_string(key0),
- self._template % "changed 0")
+ self._template % "changed 0")
self.assertEqual(self._box.get_string(key1),
- self._template % "changed 1")
+ self._template % "changed 1")
self.assertEqual(self._box.get_string(key2),
- self._template % "changed 2")
+ self._template % "changed 2")
def test_flush(self):
# Write changes to disk
@@ -428,7 +518,7 @@ class TestMailbox(TestBase):
self._test_flush_or_close(self._box.close, False)
def _test_flush_or_close(self, method, should_call_close):
- contents = [self._template % i for i in xrange(3)]
+ contents = [self._template % i for i in range(3)]
self._box.add(contents[0])
self._box.add(contents[1])
self._box.add(contents[2])
@@ -446,12 +536,12 @@ class TestMailbox(TestBase):
def test_dump_message(self):
# Write message representations to disk
for input in (email.message_from_string(_sample_message),
- _sample_message, StringIO.StringIO(_sample_message)):
- output = StringIO.StringIO()
+ _sample_message, io.BytesIO(_bytes_sample_message)):
+ output = io.BytesIO()
self._box._dump_message(input, output)
self.assertEqual(output.getvalue(),
- _sample_message.replace('\n', os.linesep))
- output = StringIO.StringIO()
+ _bytes_sample_message.replace(b'\n', os.linesep.encode()))
+ output = io.BytesIO()
self.assertRaises(TypeError,
lambda: self._box._dump_message(None, output))
@@ -470,19 +560,20 @@ class TestMailboxSuperclass(TestBase, unittest.TestCase):
self.assertRaises(NotImplementedError, lambda: box.__delitem__(''))
self.assertRaises(NotImplementedError, lambda: box.discard(''))
self.assertRaises(NotImplementedError, lambda: box.__setitem__('', ''))
- self.assertRaises(NotImplementedError, lambda: box.iterkeys())
self.assertRaises(NotImplementedError, lambda: box.keys())
- self.assertRaises(NotImplementedError, lambda: box.itervalues().next())
- self.assertRaises(NotImplementedError, lambda: box.__iter__().next())
+ self.assertRaises(NotImplementedError, lambda: box.keys())
+ self.assertRaises(NotImplementedError, lambda: box.values().__next__())
+ self.assertRaises(NotImplementedError, lambda: box.__iter__().__next__())
self.assertRaises(NotImplementedError, lambda: box.values())
- self.assertRaises(NotImplementedError, lambda: box.iteritems().next())
+ self.assertRaises(NotImplementedError, lambda: box.items().next())
self.assertRaises(NotImplementedError, lambda: box.items())
self.assertRaises(NotImplementedError, lambda: box.get(''))
self.assertRaises(NotImplementedError, lambda: box.__getitem__(''))
self.assertRaises(NotImplementedError, lambda: box.get_message(''))
self.assertRaises(NotImplementedError, lambda: box.get_string(''))
+ self.assertRaises(NotImplementedError, lambda: box.get_bytes(''))
self.assertRaises(NotImplementedError, lambda: box.get_file(''))
- self.assertRaises(NotImplementedError, lambda: box.has_key(''))
+ self.assertRaises(NotImplementedError, lambda: '' in box)
self.assertRaises(NotImplementedError, lambda: box.__contains__(''))
self.assertRaises(NotImplementedError, lambda: box.__len__())
self.assertRaises(NotImplementedError, lambda: box.clear())
@@ -504,6 +595,9 @@ class TestMaildir(TestMailbox, unittest.TestCase):
if os.name in ('nt', 'os2') or sys.platform == 'cygwin':
self._box.colon = '!'
+ def assertMailboxEmpty(self):
+ self.assertEqual(os.listdir(os.path.join(self._path, 'tmp')), [])
+
def test_add_MM(self):
# Add a MaildirMessage instance
msg = mailbox.MaildirMessage(self._template % 0)
@@ -566,7 +660,7 @@ class TestMaildir(TestMailbox, unittest.TestCase):
# Initialize a non-existent mailbox
self.tearDown()
self._box = mailbox.Maildir(self._path)
- self._check_basics(factory=rfc822.Message)
+ self._check_basics()
self._delete_recursively(self._path)
self._box = self._factory(self._path, factory=None)
self._check_basics()
@@ -577,8 +671,6 @@ class TestMaildir(TestMailbox, unittest.TestCase):
for subdir in '', 'tmp', 'new', 'cur':
os.mkdir(os.path.normpath(os.path.join(self._path, subdir)))
self._box = mailbox.Maildir(self._path)
- self._check_basics(factory=rfc822.Message)
- self._box = mailbox.Maildir(self._path, factory=None)
self._check_basics()
def _check_basics(self, factory=None):
@@ -597,7 +689,7 @@ class TestMaildir(TestMailbox, unittest.TestCase):
self._box.add_folder('three')
self.assertEqual(len(self._box.list_folders()), 3)
self.assertEqual(set(self._box.list_folders()),
- set(('one', 'two', 'three')))
+ set(('one', 'two', 'three')))
def test_get_folder(self):
# Open folders
@@ -657,14 +749,14 @@ class TestMaildir(TestMailbox, unittest.TestCase):
pattern = re.compile(r"(?P<time>\d+)\.M(?P<M>\d{1,6})P(?P<P>\d+)"
r"Q(?P<Q>\d+)\.(?P<host>[^:/]+)")
previous_groups = None
- for x in xrange(repetitions):
+ for x in range(repetitions):
tmp_file = self._box._create_tmp()
head, tail = os.path.split(tmp_file.name)
self.assertEqual(head, os.path.abspath(os.path.join(self._path,
"tmp")),
"File in wrong location: '%s'" % head)
match = pattern.match(tail)
- self.assertTrue(match is not None, "Invalid file name: '%s'" % tail)
+ self.assertIsNot(match, None, "Invalid file name: '%s'" % tail)
groups = match.groups()
if previous_groups is not None:
self.assertGreaterEqual(int(groups[0]), int(previous_groups[0]),
@@ -674,22 +766,22 @@ class TestMaildir(TestMailbox, unittest.TestCase):
self.assertGreaterEqual(int(groups[1]), int(previous_groups[1]),
"Non-monotonic milliseconds: '%s' before '%s'" %
(previous_groups[1], groups[1]))
- self.assertTrue(int(groups[2]) == pid,
+ self.assertEqual(int(groups[2]), pid,
"Process ID mismatch: '%s' should be '%s'" %
(groups[2], pid))
- self.assertTrue(int(groups[3]) == int(previous_groups[3]) + 1,
+ self.assertEqual(int(groups[3]), int(previous_groups[3]) + 1,
"Non-sequential counter: '%s' before '%s'" %
(previous_groups[3], groups[3]))
- self.assertTrue(groups[4] == hostname,
+ self.assertEqual(groups[4], hostname,
"Host name mismatch: '%s' should be '%s'" %
(groups[4], hostname))
previous_groups = groups
- tmp_file.write(_sample_message)
+ tmp_file.write(_bytes_sample_message)
tmp_file.seek(0)
- self.assertTrue(tmp_file.read() == _sample_message)
+ self.assertEqual(tmp_file.read(), _bytes_sample_message)
tmp_file.close()
file_count = len(os.listdir(os.path.join(self._path, "tmp")))
- self.assertTrue(file_count == repetitions,
+ self.assertEqual(file_count, repetitions,
"Wrong file count: '%s' should be '%s'" %
(file_count, repetitions))
@@ -784,7 +876,7 @@ class TestMaildir(TestMailbox, unittest.TestCase):
os.umask(orig_umask)
path = os.path.join(self._path, self._box._lookup(key))
mode = os.stat(path).st_mode
- self.assertEqual(mode & 0111, 0)
+ self.assertFalse(mode & 0o111)
def test_folder_file_perms(self):
# From bug #3228, we want to verify that the file created inside a Maildir
@@ -801,14 +893,14 @@ class TestMaildir(TestMailbox, unittest.TestCase):
path = os.path.join(subfolder._path, 'maildirfolder')
st = os.stat(path)
perms = st.st_mode
- self.assertFalse((perms & 0111)) # Execute bits should all be off.
+ self.assertFalse((perms & 0o111)) # Execute bits should all be off.
def test_reread(self):
# Do an initial unconditional refresh
self._box._refresh()
# Put the last modified times more than two seconds into the past
- # (because mtime may have only a two second granularity).
+ # (because mtime may have a two second granularity)
for subdir in ('cur', 'new'):
os.utime(os.path.join(self._box._path, subdir),
(time.time()-5,)*2)
@@ -889,10 +981,15 @@ class _TestSingleFile(TestMailbox):
class _TestMboxMMDF(_TestSingleFile):
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
- test_support.unlink(lock_remnant)
+ support.unlink(lock_remnant)
+
+ def assertMailboxEmpty(self):
+ with open(self._path) as f:
+ self.assertEqual(f.readlines(), [])
def test_add_from_string(self):
# Add a string starting with 'From ' to the mailbox
@@ -900,6 +997,12 @@ class _TestMboxMMDF(_TestSingleFile):
self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
self.assertEqual(self._box[key].get_payload(), '0\n')
+ def test_add_from_bytes(self):
+ # Add a byte string starting with 'From ' to the mailbox
+ key = self._box.add(b'From foo@bar blah\nFrom: foo\n\n0\n')
+ self.assertEqual(self._box[key].get_from(), 'foo@bar blah')
+ self.assertEqual(self._box[key].get_payload(), '0\n')
+
def test_add_mbox_or_mmdf_message(self):
# Add an mboxMessage or MMDFMessage
for class_ in (mailbox.mboxMessage, mailbox.MMDFMessage):
@@ -908,14 +1011,14 @@ class _TestMboxMMDF(_TestSingleFile):
def test_open_close_open(self):
# Open and inspect previously-created mailbox
- values = [self._template % i for i in xrange(3)]
+ values = [self._template % i for i in range(3)]
for value in values:
self._box.add(value)
self._box.close()
mtime = os.path.getmtime(self._path)
self._box = self._factory(self._path)
self.assertEqual(len(self._box), 3)
- for key in self._box.iterkeys():
+ for key in self._box.keys():
self.assertIn(self._box.get_string(key), values)
self._box.close()
self.assertEqual(mtime, os.path.getmtime(self._path))
@@ -923,7 +1026,7 @@ class _TestMboxMMDF(_TestSingleFile):
def test_add_and_close(self):
# Verifying that closing a mailbox doesn't change added items
self._box.add(_sample_message)
- for i in xrange(3):
+ for i in range(3):
self._box.add(self._template % i)
self._box.add(_sample_message)
self._box._file.flush()
@@ -997,7 +1100,7 @@ class TestMbox(_TestMboxMMDF, unittest.TestCase):
# We only run this test on platforms that support umask.
if hasattr(os, 'umask') and hasattr(os, 'stat'):
try:
- old_umask = os.umask(0077)
+ old_umask = os.umask(0o077)
self._box.close()
os.unlink(self._path)
self._box = mailbox.mbox(self._path, create=True)
@@ -1008,7 +1111,7 @@ class TestMbox(_TestMboxMMDF, unittest.TestCase):
st = os.stat(self._path)
perms = st.st_mode
- self.assertFalse((perms & 0111)) # Execute bits should all be off.
+ self.assertFalse((perms & 0o111)) # Execute bits should all be off.
def test_terminating_newline(self):
message = email.message.Message()
@@ -1042,6 +1145,9 @@ class TestMH(TestMailbox, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.MH(path, factory)
+ def assertMailboxEmpty(self):
+ self.assertEqual(os.listdir(self._path), ['.mh_sequences'])
+
def test_list_folders(self):
# List folders
self._box.add_folder('one')
@@ -1049,7 +1155,7 @@ class TestMH(TestMailbox, unittest.TestCase):
self._box.add_folder('three')
self.assertEqual(len(self._box.list_folders()), 3)
self.assertEqual(set(self._box.list_folders()),
- set(('one', 'two', 'three')))
+ set(('one', 'two', 'three')))
def test_get_folder(self):
# Open folders
@@ -1078,13 +1184,13 @@ class TestMH(TestMailbox, unittest.TestCase):
self.assertEqual(set(self._box.list_folders()), set(('one', 'two')))
self._box.remove_folder('one')
self.assertEqual(len(self._box.list_folders()), 1)
- self.assertEqual(set(self._box.list_folders()), set(('two', )))
+ self.assertEqual(set(self._box.list_folders()), set(('two',)))
self._box.add_folder('three')
self.assertEqual(len(self._box.list_folders()), 2)
self.assertEqual(set(self._box.list_folders()), set(('two', 'three')))
self._box.remove_folder('three')
self.assertEqual(len(self._box.list_folders()), 1)
- self.assertEqual(set(self._box.list_folders()), set(('two', )))
+ self.assertEqual(set(self._box.list_folders()), set(('two',)))
self._box.remove_folder('two')
self.assertEqual(len(self._box.list_folders()), 0)
self.assertEqual(self._box.list_folders(), [])
@@ -1100,12 +1206,12 @@ class TestMH(TestMailbox, unittest.TestCase):
msg1.set_sequences(['bar', 'replied', 'foo'])
key1 = self._box.add(msg1)
self.assertEqual(self._box.get_sequences(),
- {'foo':[key0, key1], 'bar':[key1], 'replied':[key1]})
+ {'foo':[key0, key1], 'bar':[key1], 'replied':[key1]})
msg0.set_sequences(['flagged'])
self._box[key0] = msg0
self.assertEqual(self._box.get_sequences(),
- {'foo':[key1], 'bar':[key1], 'replied':[key1],
- 'flagged':[key0]})
+ {'foo':[key1], 'bar':[key1], 'replied':[key1],
+ 'flagged':[key0]})
self._box.remove(key1)
self.assertEqual(self._box.get_sequences(), {'flagged':[key0]})
@@ -1137,12 +1243,12 @@ class TestMH(TestMailbox, unittest.TestCase):
key2 = self._box.add(msg2)
key3 = self._box.add(msg3)
self.assertEqual(self._box.get_sequences(),
- {'foo':[key0,key1,key2,key3], 'unseen':[key0],
- 'flagged':[key2], 'bar':[key3], 'replied':[key3]})
+ {'foo':[key0,key1,key2,key3], 'unseen':[key0],
+ 'flagged':[key2], 'bar':[key3], 'replied':[key3]})
self._box.remove(key2)
self.assertEqual(self._box.get_sequences(),
- {'foo':[key0,key1,key3], 'unseen':[key0], 'bar':[key3],
- 'replied':[key3]})
+ {'foo':[key0,key1,key3], 'unseen':[key0], 'bar':[key3],
+ 'replied':[key3]})
self._box.pack()
self.assertEqual(self._box.keys(), [1, 2, 3])
key0 = key0
@@ -1163,8 +1269,8 @@ class TestMH(TestMailbox, unittest.TestCase):
self._box.pack()
self._box.unlock()
self.assertEqual(self._box.get_sequences(),
- {'foo':[1, 2, 3, 4, 5],
- 'unseen':[1], 'bar':[3], 'replied':[3]})
+ {'foo':[1, 2, 3, 4, 5],
+ 'unseen':[1], 'bar':[3], 'replied':[3]})
def _get_lock_path(self):
return os.path.join(self._path, '.mh_sequences.lock')
@@ -1174,11 +1280,16 @@ class TestBabyl(_TestSingleFile, unittest.TestCase):
_factory = lambda self, path, factory=None: mailbox.Babyl(path, factory)
+ def assertMailboxEmpty(self):
+ with open(self._path) as f:
+ self.assertEqual(f.readlines(), [])
+
def tearDown(self):
+ super().tearDown()
self._box.close()
self._delete_recursively(self._path)
for lock_remnant in glob.glob(self._path + '.*'):
- test_support.unlink(lock_remnant)
+ support.unlink(lock_remnant)
def test_labels(self):
# Get labels from the mailbox
@@ -1194,17 +1305,48 @@ class TestBabyl(_TestSingleFile, unittest.TestCase):
msg0.set_labels(['blah', 'filed'])
self._box[key0] = msg0
self.assertEqual(set(self._box.get_labels()),
- set(['foo', 'bar', 'blah']))
+ set(['foo', 'bar', 'blah']))
self._box.remove(key1)
self.assertEqual(set(self._box.get_labels()), set(['blah']))
+class FakeFileLikeObject:
+
+ def __init__(self):
+ self.closed = False
+
+ def close(self):
+ self.closed = True
+
+
+class FakeMailBox(mailbox.Mailbox):
+
+ def __init__(self):
+ mailbox.Mailbox.__init__(self, '', lambda file: None)
+ self.files = [FakeFileLikeObject() for i in range(10)]
+
+ def get_file(self, key):
+ return self.files[key]
+
+
+class TestFakeMailBox(unittest.TestCase):
+
+ def test_closing_fd(self):
+ box = FakeMailBox()
+ for i in range(10):
+ self.assertFalse(box.files[i].closed)
+ for i in range(10):
+ box[i]
+ for i in range(10):
+ self.assertTrue(box.files[i].closed)
+
+
class TestMessage(TestBase, unittest.TestCase):
_factory = mailbox.Message # Overridden by subclasses to reuse tests
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
def tearDown(self):
self._delete_recursively(self._path)
@@ -1231,6 +1373,15 @@ class TestMessage(TestBase, unittest.TestCase):
self._post_initialize_hook(msg)
self._check_sample(msg)
+ def test_initialize_with_binary_file(self):
+ # Initialize based on contents of binary file
+ with open(self._path, 'wb+') as f:
+ f.write(_bytes_sample_message)
+ f.seek(0)
+ msg = self._factory(f)
+ self._post_initialize_hook(msg)
+ self._check_sample(msg)
+
def test_initialize_with_nothing(self):
# Initialize without arguments
msg = self._factory()
@@ -1276,7 +1427,7 @@ class TestMaildirMessage(TestMessage, unittest.TestCase):
def _post_initialize_hook(self, msg):
self.assertEqual(msg._subdir, 'new')
- self.assertEqual(msg._info,'')
+ self.assertEqual(msg._info, '')
def test_subdir(self):
# Use get_subdir() and set_subdir()
@@ -1312,8 +1463,7 @@ class TestMaildirMessage(TestMessage, unittest.TestCase):
def test_date(self):
# Use get_date() and set_date()
msg = mailbox.MaildirMessage(_sample_message)
- diff = msg.get_date() - time.time()
- self.assertTrue(abs(diff) < 60, diff)
+ self.assertLess(abs(msg.get_date() - time.time()), 60)
msg.set_date(0.0)
self.assertEqual(msg.get_date(), 0.0)
@@ -1357,7 +1507,7 @@ class _TestMboxMMDFMessage:
msg = mailbox.Message(_sample_message)
msg.set_unixfrom('From foo@bar blah')
msg = mailbox.mboxMessage(msg)
- self.assertEqual(msg.get_from(), 'foo@bar blah')
+ self.assertEqual(msg.get_from(), 'foo@bar blah', msg.get_from())
def test_from(self):
# Get and set "From " line
@@ -1389,7 +1539,7 @@ class _TestMboxMMDFMessage:
if sender is None:
sender = "MAILER-DAEMON"
self.assertTrue(re.match(sender + r" \w{3} \w{3} [\d ]\d [\d ]\d:\d{2}:"
- r"\d{2} \d{4}", msg.get_from()))
+ r"\d{2} \d{4}", msg.get_from()) is not None)
class TestMboxMessage(_TestMboxMMDFMessage, TestMessage):
@@ -1469,8 +1619,8 @@ class TestBabylMessage(TestMessage, unittest.TestCase):
self.assertEqual(msg.get_visible().keys(), [])
msg.set_visible(visible)
visible = msg.get_visible()
- self.assertEqual(visible.keys(), ['User-Agent', 'X-Whatever'])
- self.assertEqual(visible['User-Agent'], 'FooBar 1.0')
+ self.assertTrue(visible.keys() == ['User-Agent', 'X-Whatever'])
+ self.assertTrue(visible['User-Agent'] == 'FooBar 1.0')
self.assertEqual(visible['X-Whatever'], 'Blah')
self.assertIs(visible.get_payload(), None)
msg.update_visible()
@@ -1508,6 +1658,14 @@ class TestMessageConversion(TestBase, unittest.TestCase):
msg_plain = mailbox.Message(msg)
self._check_sample(msg_plain)
+ def test_x_from_bytes(self):
+ # Convert all formats to Message
+ for class_ in (mailbox.Message, mailbox.MaildirMessage,
+ mailbox.mboxMessage, mailbox.MHMessage,
+ mailbox.BabylMessage, mailbox.MMDFMessage):
+ msg = class_(_bytes_sample_message)
+ self._check_sample(msg)
+
def test_x_to_invalid(self):
# Convert all formats to an invalid format
for class_ in (mailbox.Message, mailbox.MaildirMessage,
@@ -1539,7 +1697,7 @@ class TestMessageConversion(TestBase, unittest.TestCase):
msg = class_(msg_maildir)
self.assertEqual(msg.get_flags(), result)
self.assertEqual(msg.get_from(), 'MAILER-DAEMON %s' %
- time.asctime(time.gmtime(0.0)))
+ time.asctime(time.gmtime(0.0)))
msg_maildir.set_subdir('cur')
self.assertEqual(class_(msg_maildir).get_flags(), 'RODFA')
@@ -1743,78 +1901,88 @@ class TestProxyFileBase(TestBase):
def _test_read(self, proxy):
# Read by byte
proxy.seek(0)
- self.assertEqual(proxy.read(), 'bar')
+ self.assertEqual(proxy.read(), b'bar')
proxy.seek(1)
- self.assertEqual(proxy.read(), 'ar')
+ self.assertEqual(proxy.read(), b'ar')
proxy.seek(0)
- self.assertEqual(proxy.read(2), 'ba')
+ self.assertEqual(proxy.read(2), b'ba')
proxy.seek(1)
- self.assertEqual(proxy.read(-1), 'ar')
+ self.assertEqual(proxy.read(-1), b'ar')
proxy.seek(2)
- self.assertEqual(proxy.read(1000), 'r')
+ self.assertEqual(proxy.read(1000), b'r')
def _test_readline(self, proxy):
# Read by line
+ linesep = os.linesep.encode()
proxy.seek(0)
- self.assertEqual(proxy.readline(), 'foo' + os.linesep)
- self.assertEqual(proxy.readline(), 'bar' + os.linesep)
- self.assertEqual(proxy.readline(), 'fred' + os.linesep)
- self.assertEqual(proxy.readline(), 'bob')
+ self.assertEqual(proxy.readline(), b'foo' + linesep)
+ self.assertEqual(proxy.readline(), b'bar' + linesep)
+ self.assertEqual(proxy.readline(), b'fred' + linesep)
+ self.assertEqual(proxy.readline(), b'bob')
proxy.seek(2)
- self.assertEqual(proxy.readline(), 'o' + os.linesep)
+ self.assertEqual(proxy.readline(), b'o' + linesep)
proxy.seek(6 + 2 * len(os.linesep))
- self.assertEqual(proxy.readline(), 'fred' + os.linesep)
+ self.assertEqual(proxy.readline(), b'fred' + linesep)
proxy.seek(6 + 2 * len(os.linesep))
- self.assertEqual(proxy.readline(2), 'fr')
- self.assertEqual(proxy.readline(-10), 'ed' + os.linesep)
+ self.assertEqual(proxy.readline(2), b'fr')
+ self.assertEqual(proxy.readline(-10), b'ed' + linesep)
def _test_readlines(self, proxy):
# Read multiple lines
+ linesep = os.linesep.encode()
proxy.seek(0)
- self.assertEqual(proxy.readlines(), ['foo' + os.linesep,
- 'bar' + os.linesep,
- 'fred' + os.linesep, 'bob'])
+ self.assertEqual(proxy.readlines(), [b'foo' + linesep,
+ b'bar' + linesep,
+ b'fred' + linesep, b'bob'])
proxy.seek(0)
- self.assertEqual(proxy.readlines(2), ['foo' + os.linesep])
- proxy.seek(3 + len(os.linesep))
- self.assertEqual(proxy.readlines(4 + len(os.linesep)),
- ['bar' + os.linesep, 'fred' + os.linesep])
+ self.assertEqual(proxy.readlines(2), [b'foo' + linesep])
+ proxy.seek(3 + len(linesep))
+ self.assertEqual(proxy.readlines(4 + len(linesep)),
+ [b'bar' + linesep, b'fred' + linesep])
proxy.seek(3)
- self.assertEqual(proxy.readlines(1000), [os.linesep, 'bar' + os.linesep,
- 'fred' + os.linesep, 'bob'])
+ self.assertEqual(proxy.readlines(1000), [linesep, b'bar' + linesep,
+ b'fred' + linesep, b'bob'])
def _test_iteration(self, proxy):
# Iterate by line
+ linesep = os.linesep.encode()
proxy.seek(0)
iterator = iter(proxy)
- self.assertEqual(list(iterator),
- ['foo' + os.linesep, 'bar' + os.linesep, 'fred' + os.linesep, 'bob'])
+ self.assertEqual(next(iterator), b'foo' + linesep)
+ self.assertEqual(next(iterator), b'bar' + linesep)
+ self.assertEqual(next(iterator), b'fred' + linesep)
+ self.assertEqual(next(iterator), b'bob')
+ self.assertRaises(StopIteration, next, iterator)
def _test_seek_and_tell(self, proxy):
# Seek and use tell to check position
+ linesep = os.linesep.encode()
proxy.seek(3)
self.assertEqual(proxy.tell(), 3)
- self.assertEqual(proxy.read(len(os.linesep)), os.linesep)
+ self.assertEqual(proxy.read(len(linesep)), linesep)
proxy.seek(2, 1)
- self.assertEqual(proxy.read(1 + len(os.linesep)), 'r' + os.linesep)
- proxy.seek(-3 - len(os.linesep), 2)
- self.assertEqual(proxy.read(3), 'bar')
+ self.assertEqual(proxy.read(1 + len(linesep)), b'r' + linesep)
+ proxy.seek(-3 - len(linesep), 2)
+ self.assertEqual(proxy.read(3), b'bar')
proxy.seek(2, 0)
- self.assertEqual(proxy.read(), 'o' + os.linesep + 'bar' + os.linesep)
+ self.assertEqual(proxy.read(), b'o' + linesep + b'bar' + linesep)
proxy.seek(100)
- self.assertEqual(proxy.read(), '')
+ self.assertFalse(proxy.read())
def _test_close(self, proxy):
# Close a file
+ self.assertFalse(proxy.closed)
proxy.close()
- # Issue 11700 subsequent closes should be a no-op, not an error.
+ self.assertTrue(proxy.closed)
+ # Issue 11700 subsequent closes should be a no-op.
proxy.close()
+ self.assertTrue(proxy.closed)
class TestProxyFile(TestProxyFileBase, unittest.TestCase):
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._file = open(self._path, 'wb+')
def tearDown(self):
@@ -1823,7 +1991,7 @@ class TestProxyFile(TestProxyFileBase, unittest.TestCase):
def test_initialize(self):
# Initialize and check position
- self._file.write('foo')
+ self._file.write(b'foo')
pos = self._file.tell()
proxy0 = mailbox._ProxyFile(self._file)
self.assertEqual(proxy0.tell(), pos)
@@ -1833,37 +2001,37 @@ class TestProxyFile(TestProxyFileBase, unittest.TestCase):
self.assertEqual(self._file.tell(), pos)
def test_read(self):
- self._file.write('bar')
+ self._file.write(b'bar')
self._test_read(mailbox._ProxyFile(self._file))
def test_readline(self):
- self._file.write('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
- os.linesep))
+ self._file.write(bytes('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
+ os.linesep), 'ascii'))
self._test_readline(mailbox._ProxyFile(self._file))
def test_readlines(self):
- self._file.write('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
- os.linesep))
+ self._file.write(bytes('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
+ os.linesep), 'ascii'))
self._test_readlines(mailbox._ProxyFile(self._file))
def test_iteration(self):
- self._file.write('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
- os.linesep))
+ self._file.write(bytes('foo%sbar%sfred%sbob' % (os.linesep, os.linesep,
+ os.linesep), 'ascii'))
self._test_iteration(mailbox._ProxyFile(self._file))
def test_seek_and_tell(self):
- self._file.write('foo%sbar%s' % (os.linesep, os.linesep))
+ self._file.write(bytes('foo%sbar%s' % (os.linesep, os.linesep), 'ascii'))
self._test_seek_and_tell(mailbox._ProxyFile(self._file))
def test_close(self):
- self._file.write('foo%sbar%s' % (os.linesep, os.linesep))
+ self._file.write(bytes('foo%sbar%s' % (os.linesep, os.linesep), 'ascii'))
self._test_close(mailbox._ProxyFile(self._file))
class TestPartialFile(TestProxyFileBase, unittest.TestCase):
def setUp(self):
- self._path = test_support.TESTFN
+ self._path = support.TESTFN
self._file = open(self._path, 'wb+')
def tearDown(self):
@@ -1872,41 +2040,41 @@ class TestPartialFile(TestProxyFileBase, unittest.TestCase):
def test_initialize(self):
# Initialize and check position
- self._file.write('foo' + os.linesep + 'bar')
+ self._file.write(bytes('foo' + os.linesep + 'bar', 'ascii'))
pos = self._file.tell()
proxy = mailbox._PartialFile(self._file, 2, 5)
self.assertEqual(proxy.tell(), 0)
self.assertEqual(self._file.tell(), pos)
def test_read(self):
- self._file.write('***bar***')
+ self._file.write(bytes('***bar***', 'ascii'))
self._test_read(mailbox._PartialFile(self._file, 3, 6))
def test_readline(self):
- self._file.write('!!!!!foo%sbar%sfred%sbob!!!!!' %
- (os.linesep, os.linesep, os.linesep))
+ self._file.write(bytes('!!!!!foo%sbar%sfred%sbob!!!!!' %
+ (os.linesep, os.linesep, os.linesep), 'ascii'))
self._test_readline(mailbox._PartialFile(self._file, 5,
18 + 3 * len(os.linesep)))
def test_readlines(self):
- self._file.write('foo%sbar%sfred%sbob?????' %
- (os.linesep, os.linesep, os.linesep))
+ self._file.write(bytes('foo%sbar%sfred%sbob?????' %
+ (os.linesep, os.linesep, os.linesep), 'ascii'))
self._test_readlines(mailbox._PartialFile(self._file, 0,
13 + 3 * len(os.linesep)))
def test_iteration(self):
- self._file.write('____foo%sbar%sfred%sbob####' %
- (os.linesep, os.linesep, os.linesep))
+ self._file.write(bytes('____foo%sbar%sfred%sbob####' %
+ (os.linesep, os.linesep, os.linesep), 'ascii'))
self._test_iteration(mailbox._PartialFile(self._file, 4,
17 + 3 * len(os.linesep)))
def test_seek_and_tell(self):
- self._file.write('(((foo%sbar%s$$$' % (os.linesep, os.linesep))
+ self._file.write(bytes('(((foo%sbar%s$$$' % (os.linesep, os.linesep), 'ascii'))
self._test_seek_and_tell(mailbox._PartialFile(self._file, 3,
9 + 2 * len(os.linesep)))
def test_close(self):
- self._file.write('&foo%sbar%s^' % (os.linesep, os.linesep))
+ self._file.write(bytes('&foo%sbar%s^' % (os.linesep, os.linesep), 'ascii'))
self._test_close(mailbox._PartialFile(self._file, 1,
6 + 3 * len(os.linesep)))
@@ -1926,7 +2094,11 @@ class MaildirTestCase(unittest.TestCase):
def setUp(self):
# create a new maildir mailbox to work with:
- self._dir = test_support.TESTFN
+ self._dir = support.TESTFN
+ if os.path.isdir(self._dir):
+ shutil.rmtree(self._dir)
+ elif os.path.isfile(self._dir):
+ os.unlink(self._dir)
os.mkdir(self._dir)
os.mkdir(os.path.join(self._dir, "cur"))
os.mkdir(os.path.join(self._dir, "tmp"))
@@ -1935,7 +2107,7 @@ class MaildirTestCase(unittest.TestCase):
self._msgfiles = []
def tearDown(self):
- map(os.unlink, self._msgfiles)
+ list(map(os.unlink, self._msgfiles))
os.rmdir(os.path.join(self._dir, "cur"))
os.rmdir(os.path.join(self._dir, "tmp"))
os.rmdir(os.path.join(self._dir, "new"))
@@ -1945,7 +2117,7 @@ class MaildirTestCase(unittest.TestCase):
t = int(time.time() % 1000000)
pid = self._counter
self._counter += 1
- filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain"))
+ filename = ".".join((str(t), str(pid), "myhostname", "mydomain"))
tmpname = os.path.join(self._dir, "tmp", filename)
newname = os.path.join(self._dir, dir, filename)
with open(tmpname, "w") as fp:
@@ -1965,61 +2137,39 @@ class MaildirTestCase(unittest.TestCase):
"""Test an empty maildir mailbox"""
# Test for regression on bug #117490:
# Make sure the boxes attribute actually gets set.
- self.mbox = mailbox.Maildir(test_support.TESTFN)
+ self.mbox = mailbox.Maildir(support.TESTFN)
#self.assertTrue(hasattr(self.mbox, "boxes"))
- #self.assertTrue(len(self.mbox.boxes) == 0)
+ #self.assertEqual(len(self.mbox.boxes), 0)
self.assertIs(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
def test_nonempty_maildir_cur(self):
self.createMessage("cur")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- #self.assertTrue(len(self.mbox.boxes) == 1)
- msg = self.mbox.next()
- self.assertIsNot(msg, None)
- msg.fp.close()
+ self.mbox = mailbox.Maildir(support.TESTFN)
+ #self.assertEqual(len(self.mbox.boxes), 1)
+ self.assertIsNot(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
def test_nonempty_maildir_new(self):
self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- #self.assertTrue(len(self.mbox.boxes) == 1)
- msg = self.mbox.next()
- self.assertIsNot(msg, None)
- msg.fp.close()
+ self.mbox = mailbox.Maildir(support.TESTFN)
+ #self.assertEqual(len(self.mbox.boxes), 1)
+ self.assertIsNot(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
def test_nonempty_maildir_both(self):
self.createMessage("cur")
self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- #self.assertTrue(len(self.mbox.boxes) == 2)
- msg = self.mbox.next()
- self.assertIsNot(msg, None)
- msg.fp.close()
- msg = self.mbox.next()
- self.assertIsNot(msg, None)
- msg.fp.close()
+ self.mbox = mailbox.Maildir(support.TESTFN)
+ #self.assertEqual(len(self.mbox.boxes), 2)
+ self.assertIsNot(self.mbox.next(), None)
+ self.assertIsNot(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
self.assertIs(self.mbox.next(), None)
- def test_unix_mbox(self):
- ### should be better!
- import email.parser
- fname = self.createMessage("cur", True)
- n = 0
- fid = open(fname)
- for msg in mailbox.PortableUnixMailbox(fid,
- email.parser.Parser().parse):
- n += 1
- self.assertEqual(msg["subject"], "Simple Test")
- self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
- fid.close()
- self.assertEqual(n, 1)
-
-## End: classes from the original module (for backward compatibility).
+## End: tests from the original module (for backward compatibility).
_sample_message = """\
@@ -2069,6 +2219,8 @@ H4sICM2D1UIAA3RleHQAC8nILFYAokSFktSKEoW0zJxUPa7wzJIMhZLyfIWczLzUYj0uAHTs
--NMuMz9nt05w80d4+--
"""
+_bytes_sample_message = _sample_message.encode('ascii')
+
_sample_headers = {
"Return-Path":"<gkj@gregorykjohnson.com>",
"X-Original-To":"gkj+person@localhost",
@@ -2109,9 +2261,9 @@ def test_main():
TestBabyl, TestMessage, TestMaildirMessage, TestMboxMessage,
TestMHMessage, TestBabylMessage, TestMMDFMessage,
TestMessageConversion, TestProxyFile, TestPartialFile,
- MaildirTestCase)
- test_support.run_unittest(*tests)
- test_support.reap_children()
+ MaildirTestCase, TestFakeMailBox)
+ support.run_unittest(*tests)
+ support.reap_children()
if __name__ == '__main__':
diff --git a/Lib/test/test_marshal.py b/Lib/test/test_marshal.py
index 744f93c7aff..96a70ecc2ab 100644
--- a/Lib/test/test_marshal.py
+++ b/Lib/test/test_marshal.py
@@ -1,44 +1,51 @@
-#!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+#!/usr/bin/env python3
-from test import test_support
+from test import support
+import array
import marshal
import sys
import unittest
import os
-class IntTestCase(unittest.TestCase):
+class HelperMixin:
+ def helper(self, sample, *extra):
+ new = marshal.loads(marshal.dumps(sample, *extra))
+ self.assertEqual(sample, new)
+ try:
+ with open(support.TESTFN, "wb") as f:
+ marshal.dump(sample, f, *extra)
+ with open(support.TESTFN, "rb") as f:
+ new = marshal.load(f)
+ self.assertEqual(sample, new)
+ finally:
+ support.unlink(support.TESTFN)
+
+class IntTestCase(unittest.TestCase, HelperMixin):
def test_ints(self):
# Test the full range of Python ints.
- n = sys.maxint
+ n = sys.maxsize
while n:
for expected in (-n, n):
- s = marshal.dumps(expected)
- got = marshal.loads(s)
- self.assertEqual(expected, got)
- marshal.dump(expected, file(test_support.TESTFN, "wb"))
- got = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(expected, got)
+ self.helper(expected)
n = n >> 1
- os.unlink(test_support.TESTFN)
def test_int64(self):
# Simulate int marshaling on a 64-bit box. This is most interesting if
# we're running the test on a 32-bit box, of course.
def to_little_endian_string(value, nbytes):
- bytes = []
+ b = bytearray()
for i in range(nbytes):
- bytes.append(chr(value & 0xff))
+ b.append(value & 0xff)
value >>= 8
- return ''.join(bytes)
+ return b
- maxint64 = (1L << 63) - 1
+ maxint64 = (1 << 63) - 1
minint64 = -maxint64-1
for base in maxint64, minint64, -maxint64, -(minint64 >> 1):
while base:
- s = 'I' + to_little_endian_string(base, 8)
+ s = b'I' + to_little_endian_string(base, 8)
got = marshal.loads(s)
self.assertEqual(base, got)
if base == -1: # a fixed-point for shifting right 1
@@ -48,28 +55,16 @@ class IntTestCase(unittest.TestCase):
def test_bool(self):
for b in (True, False):
- new = marshal.loads(marshal.dumps(b))
- self.assertEqual(b, new)
- self.assertEqual(type(b), type(new))
- marshal.dump(b, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(b, new)
- self.assertEqual(type(b), type(new))
-
-class FloatTestCase(unittest.TestCase):
+ self.helper(b)
+
+class FloatTestCase(unittest.TestCase, HelperMixin):
def test_floats(self):
# Test a few floats
small = 1e-25
- n = sys.maxint * 3.7e250
+ n = sys.maxsize * 3.7e250
while n > small:
for expected in (-n, n):
- f = float(expected)
- s = marshal.dumps(f)
- got = marshal.loads(s)
- self.assertEqual(f, got)
- marshal.dump(f, file(test_support.TESTFN, "wb"))
- got = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(f, got)
+ self.helper(float(expected))
n /= 123.4567
f = 0.0
@@ -81,63 +76,26 @@ class FloatTestCase(unittest.TestCase):
got = marshal.loads(s)
self.assertEqual(f, got)
- n = sys.maxint * 3.7e-250
+ n = sys.maxsize * 3.7e-250
while n < small:
for expected in (-n, n):
f = float(expected)
-
- s = marshal.dumps(f)
- got = marshal.loads(s)
- self.assertEqual(f, got)
-
- s = marshal.dumps(f, 1)
- got = marshal.loads(s)
- self.assertEqual(f, got)
-
- marshal.dump(f, file(test_support.TESTFN, "wb"))
- got = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(f, got)
-
- marshal.dump(f, file(test_support.TESTFN, "wb"), 1)
- got = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(f, got)
+ self.helper(f)
+ self.helper(f, 1)
n *= 123.4567
- os.unlink(test_support.TESTFN)
-class StringTestCase(unittest.TestCase):
+class StringTestCase(unittest.TestCase, HelperMixin):
def test_unicode(self):
- for s in [u"", u"Andrè Previn", u"abc", u" "*10000]:
- new = marshal.loads(marshal.dumps(s))
- self.assertEqual(s, new)
- self.assertEqual(type(s), type(new))
- marshal.dump(s, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(s, new)
- self.assertEqual(type(s), type(new))
- os.unlink(test_support.TESTFN)
+ for s in ["", "Andr\xe8 Previn", "abc", " "*10000]:
+ self.helper(marshal.loads(marshal.dumps(s)))
def test_string(self):
- for s in ["", "Andrè Previn", "abc", " "*10000]:
- new = marshal.loads(marshal.dumps(s))
- self.assertEqual(s, new)
- self.assertEqual(type(s), type(new))
- marshal.dump(s, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(s, new)
- self.assertEqual(type(s), type(new))
- os.unlink(test_support.TESTFN)
-
- def test_buffer(self):
- for s in ["", "Andrè Previn", "abc", " "*10000]:
- with test_support.check_py3k_warnings(("buffer.. not supported",
- DeprecationWarning)):
- b = buffer(s)
- new = marshal.loads(marshal.dumps(b))
- self.assertEqual(s, new)
- marshal.dump(b, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(s, new)
- os.unlink(test_support.TESTFN)
+ for s in ["", "Andr\xe8 Previn", "abc", " "*10000]:
+ self.helper(s)
+
+ def test_bytes(self):
+ for s in [b"", b"Andr\xe8 Previn", b"abc", b" "*10000]:
+ self.helper(s)
class ExceptionTestCase(unittest.TestCase):
def test_exceptions(self):
@@ -146,57 +104,60 @@ class ExceptionTestCase(unittest.TestCase):
class CodeTestCase(unittest.TestCase):
def test_code(self):
- co = ExceptionTestCase.test_exceptions.func_code
+ co = ExceptionTestCase.test_exceptions.__code__
new = marshal.loads(marshal.dumps(co))
self.assertEqual(co, new)
-class ContainerTestCase(unittest.TestCase):
+ def test_many_codeobjects(self):
+ # Issue2957: bad recursion count on code objects
+ count = 5000 # more than MAX_MARSHAL_STACK_DEPTH
+ codes = (ExceptionTestCase.test_exceptions.__code__,) * count
+ marshal.loads(marshal.dumps(codes))
+
+class ContainerTestCase(unittest.TestCase, HelperMixin):
d = {'astring': 'foo@bar.baz.spam',
'afloat': 7283.43,
'anint': 2**20,
- 'ashortlong': 2L,
+ 'ashortlong': 2,
'alist': ['.zyx.41'],
'atuple': ('.zyx.41',)*10,
'aboolean': False,
- 'aunicode': u"Andrè Previn"
+ 'aunicode': "Andr\xe8 Previn"
}
+
def test_dict(self):
- new = marshal.loads(marshal.dumps(self.d))
- self.assertEqual(self.d, new)
- marshal.dump(self.d, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(self.d, new)
- os.unlink(test_support.TESTFN)
+ self.helper(self.d)
def test_list(self):
- lst = self.d.items()
- new = marshal.loads(marshal.dumps(lst))
- self.assertEqual(lst, new)
- marshal.dump(lst, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(lst, new)
- os.unlink(test_support.TESTFN)
+ self.helper(list(self.d.items()))
def test_tuple(self):
- t = tuple(self.d.keys())
- new = marshal.loads(marshal.dumps(t))
- self.assertEqual(t, new)
- marshal.dump(t, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(t, new)
- os.unlink(test_support.TESTFN)
+ self.helper(tuple(self.d.keys()))
def test_sets(self):
for constructor in (set, frozenset):
- t = constructor(self.d.keys())
- new = marshal.loads(marshal.dumps(t))
- self.assertEqual(t, new)
- self.assertTrue(isinstance(new, constructor))
- self.assertNotEqual(id(t), id(new))
- marshal.dump(t, file(test_support.TESTFN, "wb"))
- new = marshal.load(file(test_support.TESTFN, "rb"))
- self.assertEqual(t, new)
- os.unlink(test_support.TESTFN)
+ self.helper(constructor(self.d.keys()))
+
+
+class BufferTestCase(unittest.TestCase, HelperMixin):
+
+ def test_bytearray(self):
+ b = bytearray(b"abc")
+ self.helper(b)
+ new = marshal.loads(marshal.dumps(b))
+ self.assertEqual(type(new), bytes)
+
+ def test_memoryview(self):
+ b = memoryview(b"abc")
+ self.helper(b)
+ new = marshal.loads(marshal.dumps(b))
+ self.assertEqual(type(new), bytes)
+
+ def test_array(self):
+ a = array.array('B', b"abc")
+ new = marshal.loads(marshal.dumps(a))
+ self.assertEqual(new, b"abc")
+
class BugsTestCase(unittest.TestCase):
def test_bug_5888452(self):
@@ -206,7 +167,7 @@ class BugsTestCase(unittest.TestCase):
def test_patch_873224(self):
self.assertRaises(Exception, marshal.loads, '0')
self.assertRaises(Exception, marshal.loads, 'f')
- self.assertRaises(Exception, marshal.loads, marshal.dumps(5L)[:-1])
+ self.assertRaises(Exception, marshal.loads, marshal.dumps(2**65)[:-1])
def test_version_argument(self):
# Python 2.4.0 crashes for any call to marshal.dumps(x, y)
@@ -223,14 +184,17 @@ class BugsTestCase(unittest.TestCase):
pass
def test_loads_recursion(self):
- s = 'c' + ('X' * 4*4) + '{' * 2**20
+ s = b'c' + (b'X' * 4*4) + b'{' * 2**20
self.assertRaises(ValueError, marshal.loads, s)
def test_recursion_limit(self):
# Create a deeply nested structure.
head = last = []
# The max stack depth should match the value in Python/marshal.c.
- MAX_MARSHAL_STACK_DEPTH = 2000
+ if os.name == 'nt' and hasattr(sys, 'gettotalrefcount'):
+ MAX_MARSHAL_STACK_DEPTH = 1500
+ else:
+ MAX_MARSHAL_STACK_DEPTH = 2000
for i in range(MAX_MARSHAL_STACK_DEPTH - 2):
last.append([0])
last = last[-1]
@@ -251,8 +215,8 @@ class BugsTestCase(unittest.TestCase):
# >>> class Int(int): pass
# >>> type(loads(dumps(Int())))
# <type 'int'>
- for typ in (int, long, float, complex, tuple, list, dict, set, frozenset):
- # Note: str and unicode subclasses are not tested because they get handled
+ for typ in (int, float, complex, tuple, list, dict, set, frozenset):
+ # Note: str subclasses are not tested because they get handled
# by marshal's routines for objects supporting the buffer API.
subtyp = type('subtyp', (typ,), {})
self.assertRaises(ValueError, marshal.dumps, subtyp())
@@ -266,17 +230,47 @@ class BugsTestCase(unittest.TestCase):
def test_invalid_longs(self):
# Issue #7019: marshal.loads shouldn't produce unnormalized PyLongs
- invalid_string = 'l\x02\x00\x00\x00\x00\x00\x00\x00'
+ invalid_string = b'l\x02\x00\x00\x00\x00\x00\x00\x00'
self.assertRaises(ValueError, marshal.loads, invalid_string)
+ def test_multiple_dumps_and_loads(self):
+ # Issue 12291: marshal.load() should be callable multiple times
+ # with interleaved data written by non-marshal code
+ # Adapted from a patch by Engelbert Gruber.
+ data = (1, 'abc', b'def', 1.0, (2, 'a', ['b', b'c']))
+ for interleaved in (b'', b'0123'):
+ ilen = len(interleaved)
+ positions = []
+ try:
+ with open(support.TESTFN, 'wb') as f:
+ for d in data:
+ marshal.dump(d, f)
+ if ilen:
+ f.write(interleaved)
+ positions.append(f.tell())
+ with open(support.TESTFN, 'rb') as f:
+ for i, d in enumerate(data):
+ self.assertEqual(d, marshal.load(f))
+ if ilen:
+ f.read(ilen)
+ self.assertEqual(positions[i], f.tell())
+ finally:
+ support.unlink(support.TESTFN)
+
+ def test_loads_reject_unicode_strings(self):
+ # Issue #14177: marshal.loads() should not accept unicode strings
+ unicode_string = 'T'
+ self.assertRaises(TypeError, marshal.loads, unicode_string)
+
def test_main():
- test_support.run_unittest(IntTestCase,
+ support.run_unittest(IntTestCase,
FloatTestCase,
StringTestCase,
CodeTestCase,
ContainerTestCase,
ExceptionTestCase,
+ BufferTestCase,
BugsTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_math.py b/Lib/test/test_math.py
index ac4475e2e53..dddc889375c 100644
--- a/Lib/test/test_math.py
+++ b/Lib/test/test_math.py
@@ -1,24 +1,20 @@
# Python test set -- math module
# XXXX Should not do tests around zero only
-from test.test_support import run_unittest, verbose
+from test.support import run_unittest, verbose, requires_IEEE_754
import unittest
import math
import os
import sys
import random
import struct
+import sysconfig
eps = 1E-05
NAN = float('nan')
INF = float('inf')
NINF = float('-inf')
-# decorator for skipping tests on non-IEEE 754 platforms
-requires_IEEE_754 = unittest.skipUnless(
- float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
-
# detect evidence of double-rounding: fsum is not always correctly
# rounded on machines that suffer from double rounding.
x, y = 1e16, 2.9999 # use temporary values to defeat peephole optimizer
@@ -60,6 +56,56 @@ def ulps_check(expected, got, ulps=20):
return "error = {} ulps; permitted error = {} ulps".format(ulps_error,
ulps)
+# Here's a pure Python version of the math.factorial algorithm, for
+# documentation and comparison purposes.
+#
+# Formula:
+#
+# factorial(n) = factorial_odd_part(n) << (n - count_set_bits(n))
+#
+# where
+#
+# factorial_odd_part(n) = product_{i >= 0} product_{0 < j <= n >> i; j odd} j
+#
+# The outer product above is an infinite product, but once i >= n.bit_length,
+# (n >> i) < 1 and the corresponding term of the product is empty. So only the
+# finitely many terms for 0 <= i < n.bit_length() contribute anything.
+#
+# We iterate downwards from i == n.bit_length() - 1 to i == 0. The inner
+# product in the formula above starts at 1 for i == n.bit_length(); for each i
+# < n.bit_length() we get the inner product for i from that for i + 1 by
+# multiplying by all j in {n >> i+1 < j <= n >> i; j odd}. In Python terms,
+# this set is range((n >> i+1) + 1 | 1, (n >> i) + 1 | 1, 2).
+
+def count_set_bits(n):
+ """Number of '1' bits in binary expansion of a nonnnegative integer."""
+ return 1 + count_set_bits(n & n - 1) if n else 0
+
+def partial_product(start, stop):
+ """Product of integers in range(start, stop, 2), computed recursively.
+ start and stop should both be odd, with start <= stop.
+
+ """
+ numfactors = (stop - start) >> 1
+ if not numfactors:
+ return 1
+ elif numfactors == 1:
+ return start
+ else:
+ mid = (start + numfactors) | 1
+ return partial_product(start, mid) * partial_product(mid, stop)
+
+def py_factorial(n):
+ """Factorial of nonnegative integer n, via "Binary Split Factorial Formula"
+ described at http://www.luschny.de/math/factorial/binarysplitfact.html
+
+ """
+ inner = outer = 1
+ for i in reversed(range(n.bit_length())):
+ inner *= partial_product((n >> i + 1) + 1 | 1, (n >> i) + 1 | 1)
+ outer *= inner
+ return outer << (n - count_set_bits(n))
+
def acc_check(expected, got, rel_err=2e-15, abs_err = 5e-323):
"""Determine whether non-NaN floats a and b are equal to within a
(small) rounding error. The default values for rel_err and
@@ -263,24 +309,21 @@ class MathTests(unittest.TestCase):
def testCeil(self):
self.assertRaises(TypeError, math.ceil)
- # These types will be int in py3k.
- self.assertEqual(float, type(math.ceil(1)))
- self.assertEqual(float, type(math.ceil(1L)))
- self.assertEqual(float, type(math.ceil(1.0)))
+ self.assertEqual(int, type(math.ceil(0.5)))
self.ftest('ceil(0.5)', math.ceil(0.5), 1)
self.ftest('ceil(1.0)', math.ceil(1.0), 1)
self.ftest('ceil(1.5)', math.ceil(1.5), 2)
self.ftest('ceil(-0.5)', math.ceil(-0.5), 0)
self.ftest('ceil(-1.0)', math.ceil(-1.0), -1)
self.ftest('ceil(-1.5)', math.ceil(-1.5), -1)
- self.assertEqual(math.ceil(INF), INF)
- self.assertEqual(math.ceil(NINF), NINF)
- self.assertTrue(math.isnan(math.ceil(NAN)))
-
- class TestCeil(object):
- def __float__(self):
- return 41.3
- class TestNoCeil(object):
+ #self.assertEqual(math.ceil(INF), INF)
+ #self.assertEqual(math.ceil(NINF), NINF)
+ #self.assertTrue(math.isnan(math.ceil(NAN)))
+
+ class TestCeil:
+ def __ceil__(self):
+ return 42
+ class TestNoCeil:
pass
self.ftest('ceil(TestCeil())', math.ceil(TestCeil()), 42)
self.assertRaises(TypeError, math.ceil, TestNoCeil())
@@ -368,25 +411,23 @@ class MathTests(unittest.TestCase):
self.ftest('fabs(1)', math.fabs(1), 1)
def testFactorial(self):
- def fact(n):
- result = 1
- for i in range(1, int(n)+1):
- result *= i
- return result
- values = range(10) + [50, 100, 500]
- random.shuffle(values)
- for x in values:
- for cast in (int, long, float):
- self.assertEqual(math.factorial(cast(x)), fact(x), (x, fact(x), math.factorial(x)))
+ self.assertEqual(math.factorial(0), 1)
+ self.assertEqual(math.factorial(0.0), 1)
+ total = 1
+ for i in range(1, 1000):
+ total *= i
+ self.assertEqual(math.factorial(i), total)
+ self.assertEqual(math.factorial(float(i)), total)
+ self.assertEqual(math.factorial(i), py_factorial(i))
self.assertRaises(ValueError, math.factorial, -1)
+ self.assertRaises(ValueError, math.factorial, -1.0)
self.assertRaises(ValueError, math.factorial, math.pi)
+ self.assertRaises(OverflowError, math.factorial, sys.maxsize+1)
+ self.assertRaises(OverflowError, math.factorial, 10e100)
def testFloor(self):
self.assertRaises(TypeError, math.floor)
- # These types will be int in py3k.
- self.assertEqual(float, type(math.floor(1)))
- self.assertEqual(float, type(math.floor(1L)))
- self.assertEqual(float, type(math.floor(1.0)))
+ self.assertEqual(int, type(math.floor(0.5)))
self.ftest('floor(0.5)', math.floor(0.5), 0)
self.ftest('floor(1.0)', math.floor(1.0), 1)
self.ftest('floor(1.5)', math.floor(1.5), 1)
@@ -397,14 +438,14 @@ class MathTests(unittest.TestCase):
# This fails on some platforms - so check it here
self.ftest('floor(1.23e167)', math.floor(1.23e167), 1.23e167)
self.ftest('floor(-1.23e167)', math.floor(-1.23e167), -1.23e167)
- self.assertEqual(math.ceil(INF), INF)
- self.assertEqual(math.ceil(NINF), NINF)
- self.assertTrue(math.isnan(math.floor(NAN)))
-
- class TestFloor(object):
- def __float__(self):
- return 42.3
- class TestNoFloor(object):
+ #self.assertEqual(math.ceil(INF), INF)
+ #self.assertEqual(math.ceil(NINF), NINF)
+ #self.assertTrue(math.isnan(math.floor(NAN)))
+
+ class TestFloor:
+ def __floor__(self):
+ return 42
+ class TestNoFloor:
pass
self.ftest('floor(TestFloor())', math.floor(TestFloor()), 42)
self.assertRaises(TypeError, math.floor, TestNoFloor())
@@ -443,7 +484,7 @@ class MathTests(unittest.TestCase):
(mant, exp), (emant, eexp) = result, expected
if abs(mant-emant) > eps or exp != eexp:
self.fail('%s returned %r, expected %r'%\
- (name, (mant, exp), (emant,eexp)))
+ (name, result, expected))
testfrexp('frexp(-1)', math.frexp(-1), (-0.5, 1))
testfrexp('frexp(0)', math.frexp(0), (0, 0))
@@ -533,10 +574,10 @@ class MathTests(unittest.TestCase):
self.assertEqual(actual, expected)
from random import random, gauss, shuffle
- for j in xrange(1000):
+ for j in range(1000):
vals = [7, 1e100, -7, -1e100, -9e-20, 8e-20] * 10
s = 0
- for i in xrange(200):
+ for i in range(200):
v = gauss(0, random()) ** 7 - s
s += v
vals.append(v)
@@ -571,7 +612,7 @@ class MathTests(unittest.TestCase):
self.assertTrue(math.isnan(math.ldexp(NAN, 0)))
# large second argument
- for n in [10**5, 10L**5, 10**10, 10L**10, 10**20, 10**40]:
+ for n in [10**5, 10**10, 10**20, 10**40]:
self.assertEqual(math.ldexp(INF, -n), INF)
self.assertEqual(math.ldexp(NINF, -n), NINF)
self.assertEqual(math.ldexp(1., -n), 0.)
@@ -596,21 +637,17 @@ class MathTests(unittest.TestCase):
self.ftest('log(32,2)', math.log(32,2), 5)
self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
- self.assertEqual(math.log(INF), INF)
+ self.ftest('log(10**1000)', math.log(10**1000),
+ 2302.5850929940457)
+ self.assertRaises(ValueError, math.log, -1.5)
+ self.assertRaises(ValueError, math.log, -10**1000)
self.assertRaises(ValueError, math.log, NINF)
+ self.assertEqual(math.log(INF), INF)
self.assertTrue(math.isnan(math.log(NAN)))
def testLog1p(self):
self.assertRaises(TypeError, math.log1p)
- self.ftest('log1p(1/e -1)', math.log1p(1/math.e-1), -1)
- self.ftest('log1p(0)', math.log1p(0), 0)
- self.ftest('log1p(e-1)', math.log1p(math.e-1), 1)
- self.ftest('log1p(1)', math.log1p(1), math.log(2))
- self.assertEqual(math.log1p(INF), INF)
- self.assertRaises(ValueError, math.log1p, NINF)
- self.assertTrue(math.isnan(math.log1p(NAN)))
n= 2**90
- self.assertAlmostEqual(math.log1p(n), 62.383246250395075)
self.assertAlmostEqual(math.log1p(n), math.log1p(float(n)))
def testLog10(self):
@@ -618,8 +655,11 @@ class MathTests(unittest.TestCase):
self.ftest('log10(0.1)', math.log10(0.1), -1)
self.ftest('log10(1)', math.log10(1), 0)
self.ftest('log10(10)', math.log10(10), 1)
- self.assertEqual(math.log(INF), INF)
+ self.ftest('log10(10**1000)', math.log10(10**1000), 1000.0)
+ self.assertRaises(ValueError, math.log10, -1.5)
+ self.assertRaises(ValueError, math.log10, -10**1000)
self.assertRaises(ValueError, math.log10, NINF)
+ self.assertEqual(math.log(INF), INF)
self.assertTrue(math.isnan(math.log10(NAN)))
def testModf(self):
@@ -629,7 +669,7 @@ class MathTests(unittest.TestCase):
(v1, v2), (e1, e2) = result, expected
if abs(v1-e1) > eps or abs(v2-e2):
self.fail('%s returned %r, expected %r'%\
- (name, (v1,v2), (e1,e2)))
+ (name, result, expected))
testmodf('modf(1.5)', math.modf(1.5), (0.5, 1.0))
testmodf('modf(-1.5)', math.modf(-1.5), (-0.5, -1.0))
@@ -847,11 +887,15 @@ class MathTests(unittest.TestCase):
self.ftest('tanh(inf)', math.tanh(INF), 1)
self.ftest('tanh(-inf)', math.tanh(NINF), -1)
self.assertTrue(math.isnan(math.tanh(NAN)))
+
+ @requires_IEEE_754
+ @unittest.skipIf(sysconfig.get_config_var('TANH_PRESERVES_ZERO_SIGN') == 0,
+ "system tanh() function doesn't copy the sign")
+ def testTanhSign(self):
# check that tanh(-0.) == -0. on IEEE 754 systems
- if float.__getformat__("double").startswith("IEEE"):
- self.assertEqual(math.tanh(-0.), -0.)
- self.assertEqual(math.copysign(1., math.tanh(-0.)),
- math.copysign(1., -0.))
+ self.assertEqual(math.tanh(-0.), -0.)
+ self.assertEqual(math.copysign(1., math.tanh(-0.)),
+ math.copysign(1., -0.))
def test_trunc(self):
self.assertEqual(math.trunc(1), 1)
@@ -876,8 +920,16 @@ class MathTests(unittest.TestCase):
self.assertRaises(TypeError, math.trunc)
self.assertRaises(TypeError, math.trunc, 1, 2)
- self.assertRaises((AttributeError, TypeError), math.trunc,
- TestNoTrunc())
+ self.assertRaises(TypeError, math.trunc, TestNoTrunc())
+
+ def testIsfinite(self):
+ self.assertTrue(math.isfinite(0.0))
+ self.assertTrue(math.isfinite(-0.0))
+ self.assertTrue(math.isfinite(1.0))
+ self.assertTrue(math.isfinite(-1.0))
+ self.assertFalse(math.isfinite(float("nan")))
+ self.assertFalse(math.isfinite(float("inf")))
+ self.assertFalse(math.isfinite(float("-inf")))
def testIsnan(self):
self.assertTrue(math.isnan(float("nan")))
@@ -946,9 +998,9 @@ class MathTests(unittest.TestCase):
func = getattr(math, fn)
try:
result = func(ar)
- except ValueError:
- message = ("Unexpected ValueError in " +
- "test %s:%s(%r)\n" % (id, fn, ar))
+ except ValueError as exc:
+ message = (("Unexpected ValueError: %s\n " +
+ "in test %s:%s(%r)\n") % (exc.args[0], id, fn, ar))
self.fail(message)
except OverflowError:
message = ("Unexpected OverflowError in " +
@@ -956,8 +1008,7 @@ class MathTests(unittest.TestCase):
self.fail(message)
self.ftest("%s:%s(%r)" % (id, fn, ar), result, er)
- @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
- "test requires IEEE 754 doubles")
+ @requires_IEEE_754
def test_mtestfile(self):
ALLOWED_ERROR = 20 # permitted error, in ulps
fail_fmt = "{}:{}({!r}): expected {!r}, got {!r}"
diff --git a/Lib/test/test_md5.py b/Lib/test/test_md5.py
deleted file mode 100644
index 2c0e8e2ca92..00000000000
--- a/Lib/test/test_md5.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# Testing md5 module
-import warnings
-warnings.filterwarnings("ignore", "the md5 module is deprecated.*",
- DeprecationWarning)
-
-import unittest
-from md5 import md5
-from test import test_support
-
-def hexstr(s):
- import string
- h = string.hexdigits
- r = ''
- for c in s:
- i = ord(c)
- r = r + h[(i >> 4) & 0xF] + h[i & 0xF]
- return r
-
-class MD5_Test(unittest.TestCase):
-
- def md5test(self, s, expected):
- self.assertEqual(hexstr(md5(s).digest()), expected)
- self.assertEqual(md5(s).hexdigest(), expected)
-
- def test_basics(self):
- eq = self.md5test
- eq('', 'd41d8cd98f00b204e9800998ecf8427e')
- eq('a', '0cc175b9c0f1b6a831c399e269772661')
- eq('abc', '900150983cd24fb0d6963f7d28e17f72')
- eq('message digest', 'f96b697d7cb7938d525a2f31aaf161d0')
- eq('abcdefghijklmnopqrstuvwxyz', 'c3fcd3d76192e4007dfb496cca67e13b')
- eq('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789',
- 'd174ab98d277d9f5a5611c2c9f419d9f')
- eq('12345678901234567890123456789012345678901234567890123456789012345678901234567890',
- '57edf4a22be3c955ac49da2e2107b67a')
-
- def test_hexdigest(self):
- # hexdigest is new with Python 2.0
- m = md5('testing the hexdigest method')
- h = m.hexdigest()
- self.assertEqual(hexstr(m.digest()), h)
-
- def test_large_update(self):
- aas = 'a' * 64
- bees = 'b' * 64
- cees = 'c' * 64
-
- m1 = md5()
- m1.update(aas)
- m1.update(bees)
- m1.update(cees)
-
- m2 = md5()
- m2.update(aas + bees + cees)
- self.assertEqual(m1.digest(), m2.digest())
-
-def test_main():
- test_support.run_unittest(MD5_Test)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_memoryio.py b/Lib/test/test_memoryio.py
index c3d559d6c43..7c0c84f0d95 100644
--- a/Lib/test/test_memoryio.py
+++ b/Lib/test/test_memoryio.py
@@ -3,11 +3,8 @@ StringIO -- for unicode strings
BytesIO -- for bytes
"""
-from __future__ import unicode_literals
-from __future__ import print_function
-
import unittest
-from test import test_support as support
+from test import support
import io
import _pyio as pyio
@@ -123,9 +120,6 @@ class MemoryTestMixin:
self.assertEqual(memio.getvalue(), buf[:6])
self.assertEqual(memio.truncate(4), 4)
self.assertEqual(memio.getvalue(), buf[:4])
- # truncate() accepts long objects
- self.assertEqual(memio.truncate(4L), 4)
- self.assertEqual(memio.getvalue(), buf[:4])
self.assertEqual(memio.tell(), 6)
memio.seek(0, 2)
memio.write(buf)
@@ -147,6 +141,7 @@ class MemoryTestMixin:
self.assertEqual(memio.getvalue(), buf * 2)
memio.__init__(buf)
self.assertEqual(memio.getvalue(), buf)
+ self.assertRaises(TypeError, memio.__init__, [])
def test_read(self):
buf = self.buftype("1234567890")
@@ -154,8 +149,7 @@ class MemoryTestMixin:
self.assertEqual(memio.read(0), self.EOF)
self.assertEqual(memio.read(1), buf[:1])
- # read() accepts long objects
- self.assertEqual(memio.read(4L), buf[1:5])
+ self.assertEqual(memio.read(4), buf[1:5])
self.assertEqual(memio.read(900), buf[5:])
self.assertEqual(memio.read(), self.EOF)
memio.seek(0)
@@ -184,8 +178,7 @@ class MemoryTestMixin:
self.assertEqual(memio.readline(), self.EOF)
memio.seek(0)
self.assertEqual(memio.readline(5), buf[:5])
- # readline() accepts long objects
- self.assertEqual(memio.readline(5L), buf[5:10])
+ self.assertEqual(memio.readline(5), buf[5:10])
self.assertEqual(memio.readline(5), buf[10:15])
memio.seek(0)
self.assertEqual(memio.readline(-1), buf)
@@ -213,8 +206,7 @@ class MemoryTestMixin:
memio.seek(5)
self.assertEqual(memio.readlines(), [buf[5:]] + [buf] * 9)
memio.seek(0)
- # readlines() accepts long objects
- self.assertEqual(memio.readlines(15L), [buf] * 2)
+ self.assertEqual(memio.readlines(15), [buf] * 2)
memio.seek(0)
self.assertEqual(memio.readlines(-1), [buf] * 10)
memio.seek(0)
@@ -233,7 +225,7 @@ class MemoryTestMixin:
self.assertEqual(iter(memio), memio)
self.assertTrue(hasattr(memio, '__iter__'))
- self.assertTrue(hasattr(memio, 'next'))
+ self.assertTrue(hasattr(memio, '__next__'))
i = 0
for line in memio:
self.assertEqual(line, buf)
@@ -247,7 +239,7 @@ class MemoryTestMixin:
self.assertEqual(i, 10)
memio = self.ioclass(buf * 2)
memio.close()
- self.assertRaises(ValueError, next, memio)
+ self.assertRaises(ValueError, memio.__next__)
def test_getvalue(self):
buf = self.buftype("1234567890")
@@ -275,8 +267,6 @@ class MemoryTestMixin:
self.assertEqual(memio.seek(0, 0), 0)
self.assertEqual(memio.read(), buf)
self.assertEqual(memio.seek(3), 3)
- # seek() accepts long objects
- self.assertEqual(memio.seek(3L), 3)
self.assertEqual(memio.seek(0, 1), 3)
self.assertEqual(memio.read(), buf[3:])
self.assertEqual(memio.seek(len(buf)), len(buf))
@@ -372,7 +362,7 @@ class MemoryTestMixin:
# Pickle expects the class to be on the module level. Here we use a
# little hack to allow the PickleTestMemIO class to derive from
- # self.ioclass without having to define all combinations explicitly on
+ # self.ioclass without having to define all combinations explictly on
# the module-level.
import __main__
PickleTestMemIO.__module__ = '__main__'
@@ -394,7 +384,31 @@ class MemoryTestMixin:
del __main__.PickleTestMemIO
-class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
+class BytesIOMixin:
+
+ def test_getbuffer(self):
+ memio = self.ioclass(b"1234567890")
+ buf = memio.getbuffer()
+ self.assertEqual(bytes(buf), b"1234567890")
+ memio.seek(5)
+ buf = memio.getbuffer()
+ self.assertEqual(bytes(buf), b"1234567890")
+ # Trying to change the size of the BytesIO while a buffer is exported
+ # raises a BufferError.
+ self.assertRaises(BufferError, memio.write, b'x' * 100)
+ self.assertRaises(BufferError, memio.truncate)
+ # Mutating the buffer updates the BytesIO
+ buf[3:6] = b"abc"
+ self.assertEqual(bytes(buf), b"123abc7890")
+ self.assertEqual(memio.getvalue(), b"123abc7890")
+ # After the buffer gets released, we can resize the BytesIO again
+ del buf
+ support.gc_collect()
+ memio.truncate()
+
+
+class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin,
+ BytesIOMixin, unittest.TestCase):
UnsupportedOperation = pyio.UnsupportedOperation
@@ -432,10 +446,10 @@ class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
self.assertEqual(b, b"")
self.assertRaises(TypeError, memio.readinto, '')
import array
- a = array.array(b'b', b"hello world")
+ a = array.array('b', b"hello world")
memio = self.ioclass(buf)
memio.readinto(a)
- self.assertEqual(a.tostring(), b"1234567890d")
+ self.assertEqual(a.tobytes(), b"1234567890d")
memio.close()
self.assertRaises(ValueError, memio.readinto, b)
memio = self.ioclass(b"123")
@@ -470,7 +484,7 @@ class PyBytesIOTest(MemoryTestMixin, MemorySeekTestMixin, unittest.TestCase):
def test_bytes_array(self):
buf = b"1234567890"
import array
- a = array.array(b'b', buf)
+ a = array.array('b', list(buf))
memio = self.ioclass(a)
self.assertEqual(memio.getvalue(), buf)
self.assertEqual(memio.write(a), 10)
@@ -580,10 +594,17 @@ class TextIOTestMixin:
memio = self.ioclass("a\r\nb\r\n", newline=None)
self.assertEqual(memio.read(5), "a\nb\n")
+ def test_newline_argument(self):
+ self.assertRaises(TypeError, self.ioclass, newline=b"\n")
+ self.assertRaises(ValueError, self.ioclass, newline="error")
+ # These should not raise an error
+ for newline in (None, "", "\n", "\r", "\r\n"):
+ self.ioclass(newline=newline)
+
class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin,
TextIOTestMixin, unittest.TestCase):
- buftype = unicode
+ buftype = str
ioclass = pyio.StringIO
UnsupportedOperation = pyio.UnsupportedOperation
EOF = ""
@@ -592,7 +613,7 @@ class PyStringIOTest(MemoryTestMixin, MemorySeekTestMixin,
class PyStringIOPickleTest(TextIOTestMixin, unittest.TestCase):
"""Test if pickle restores properly the internal state of StringIO.
"""
- buftype = unicode
+ buftype = str
UnsupportedOperation = pyio.UnsupportedOperation
EOF = ""
@@ -607,11 +628,6 @@ class CBytesIOTest(PyBytesIOTest):
ioclass = io.BytesIO
UnsupportedOperation = io.UnsupportedOperation
- test_bytes_array = unittest.skip(
- "array.array() does not have the new buffer API"
- )(PyBytesIOTest.test_bytes_array)
-
-
def test_getstate(self):
memio = self.ioclass()
state = memio.__getstate__()
@@ -642,7 +658,7 @@ class CBytesIOTest(PyBytesIOTest):
@support.cpython_only
def test_sizeof(self):
- basesize = support.calcobjsize(b'P2PP2P')
+ basesize = support.calcobjsize('P2PP2PP')
check = self.check_sizeof
self.assertEqual(object.__sizeof__(io.BytesIO()), basesize)
check(io.BytesIO(), basesize )
@@ -671,7 +687,7 @@ class CStringIOTest(PyStringIOTest):
memio = self.ioclass()
state = memio.__getstate__()
self.assertEqual(len(state), 4)
- self.assertIsInstance(state[0], unicode)
+ self.assertIsInstance(state[0], str)
self.assertIsInstance(state[1], str)
self.assertIsInstance(state[2], int)
self.assertTrue(isinstance(state[3], dict) or state[3] is None)
@@ -686,8 +702,7 @@ class CStringIOTest(PyStringIOTest):
self.assertRaises(ValueError, memio.__setstate__, ("", "f", 0, None))
self.assertRaises(ValueError, memio.__setstate__, ("", "", -1, None))
self.assertRaises(TypeError, memio.__setstate__, (b"", "", 0, None))
- # trunk is more tolerant than py3k on the type of the newline param
- #self.assertRaises(TypeError, memio.__setstate__, ("", b"", 0, None))
+ self.assertRaises(TypeError, memio.__setstate__, ("", b"", 0, None))
self.assertRaises(TypeError, memio.__setstate__, ("", "", 0.0, None))
self.assertRaises(TypeError, memio.__setstate__, ("", "", 0, 0))
self.assertRaises(TypeError, memio.__setstate__, ("len-test", 0))
@@ -702,8 +717,7 @@ class CStringIOPickleTest(PyStringIOPickleTest):
class ioclass(io.StringIO):
def __new__(cls, *args, **kwargs):
- return pickle.loads(pickle.dumps(io.StringIO(*args, **kwargs),
- protocol=2))
+ return pickle.loads(pickle.dumps(io.StringIO(*args, **kwargs)))
def __init__(self, *args, **kwargs):
pass
diff --git a/Lib/test/test_memoryview.py b/Lib/test/test_memoryview.py
index 525ddeab23d..0bfddd97ed6 100644
--- a/Lib/test/test_memoryview.py
+++ b/Lib/test/test_memoryview.py
@@ -4,11 +4,11 @@ XXX We need more tests! Some tests are in test_bytes
"""
import unittest
+import test.support
import sys
import gc
import weakref
import array
-from test import test_support
import io
@@ -55,12 +55,6 @@ class AbstractMemoryTests:
m = self._view(b)
self.assertEqual(list(m), [m[i] for i in range(len(m))])
- def test_repr(self):
- for tp in self._types:
- b = tp(self._source)
- m = self._view(b)
- self.assertIsInstance(m.__repr__(), str)
-
def test_setitem_readonly(self):
if not self.ro_type:
return
@@ -133,7 +127,7 @@ class AbstractMemoryTests:
b = m.tobytes()
# This calls self.getitem_type() on each separate byte of b"abcdef"
expected = b"".join(
- self.getitem_type(c) for c in b"abcdef")
+ self.getitem_type(bytes([c])) for c in b"abcdef")
self.assertEqual(b, expected)
self.assertIsInstance(b, bytes)
@@ -141,7 +135,7 @@ class AbstractMemoryTests:
for tp in self._types:
m = self._view(tp(self._source))
l = m.tolist()
- self.assertEqual(l, map(ord, b"abcdef"))
+ self.assertEqual(l, list(b"abcdef"))
def test_compare(self):
# memoryviews can compare for equality with other objects
@@ -161,18 +155,21 @@ class AbstractMemoryTests:
self.assertFalse(m[0:5] == m)
# Comparison with objects which don't support the buffer API
- self.assertFalse(m == u"abcdef")
- self.assertTrue(m != u"abcdef")
- self.assertFalse(u"abcdef" == m)
- self.assertTrue(u"abcdef" != m)
-
- # Unordered comparisons are unimplemented, and therefore give
- # arbitrary results (they raise a TypeError in py3k)
+ self.assertFalse(m == "abcdef")
+ self.assertTrue(m != "abcdef")
+ self.assertFalse("abcdef" == m)
+ self.assertTrue("abcdef" != m)
+
+ # Unordered comparisons
+ for c in (m, b"abcdef"):
+ self.assertRaises(TypeError, lambda: m < c)
+ self.assertRaises(TypeError, lambda: c <= m)
+ self.assertRaises(TypeError, lambda: m >= c)
+ self.assertRaises(TypeError, lambda: c > m)
def check_attributes_with_type(self, tp):
m = self._view(tp(self._source))
self.assertEqual(m.format, self.format)
- self.assertIsInstance(m.format, str)
self.assertEqual(m.itemsize, self.itemsize)
self.assertEqual(m.ndim, 1)
self.assertEqual(m.shape, (6,))
@@ -193,20 +190,18 @@ class AbstractMemoryTests:
m = self.check_attributes_with_type(self.rw_type)
self.assertEqual(m.readonly, False)
- # Disabled: unicode uses the old buffer API in 2.x
-
- #def test_getbuffer(self):
- ## Test PyObject_GetBuffer() on a memoryview object.
- #for tp in self._types:
- #b = tp(self._source)
- #oldrefcount = sys.getrefcount(b)
- #m = self._view(b)
- #oldviewrefcount = sys.getrefcount(m)
- #s = unicode(m, "utf-8")
- #self._check_contents(tp, b, s.encode("utf-8"))
- #self.assertEqual(sys.getrefcount(m), oldviewrefcount)
- #m = None
- #self.assertEqual(sys.getrefcount(b), oldrefcount)
+ def test_getbuffer(self):
+ # Test PyObject_GetBuffer() on a memoryview object.
+ for tp in self._types:
+ b = tp(self._source)
+ oldrefcount = sys.getrefcount(b)
+ m = self._view(b)
+ oldviewrefcount = sys.getrefcount(m)
+ s = str(m, "utf-8")
+ self._check_contents(tp, b, s.encode("utf-8"))
+ self.assertEqual(sys.getrefcount(m), oldviewrefcount)
+ m = None
+ self.assertEqual(sys.getrefcount(b), oldrefcount)
def test_gc(self):
for tp in self._types:
@@ -231,6 +226,52 @@ class AbstractMemoryTests:
gc.collect()
self.assertTrue(wr() is None, wr())
+ def _check_released(self, m, tp):
+ check = self.assertRaisesRegex(ValueError, "released")
+ with check: bytes(m)
+ with check: m.tobytes()
+ with check: m.tolist()
+ with check: m[0]
+ with check: m[0] = b'x'
+ with check: len(m)
+ with check: m.format
+ with check: m.itemsize
+ with check: m.ndim
+ with check: m.readonly
+ with check: m.shape
+ with check: m.strides
+ with check:
+ with m:
+ pass
+ # str() and repr() still function
+ self.assertIn("released memory", str(m))
+ self.assertIn("released memory", repr(m))
+ self.assertEqual(m, m)
+ self.assertNotEqual(m, memoryview(tp(self._source)))
+ self.assertNotEqual(m, tp(self._source))
+
+ def test_contextmanager(self):
+ for tp in self._types:
+ b = tp(self._source)
+ m = self._view(b)
+ with m as cm:
+ self.assertIs(cm, m)
+ self._check_released(m, tp)
+ m = self._view(b)
+ # Can release explicitly inside the context manager
+ with m:
+ m.release()
+
+ def test_release(self):
+ for tp in self._types:
+ b = tp(self._source)
+ m = self._view(b)
+ m.release()
+ self._check_released(m, tp)
+ # Can be called a second time (it's a no-op)
+ m.release()
+ self._check_released(m, tp)
+
def test_writable_readonly(self):
# Issue #10451: memoryview incorrectly exposes a readonly
# buffer as writable causing a segfault if using mmap
@@ -253,22 +294,20 @@ class BaseBytesMemoryTests(AbstractMemoryTests):
itemsize = 1
format = 'B'
-# Disabled: array.array() does not support the new buffer API in 2.x
-
-#class BaseArrayMemoryTests(AbstractMemoryTests):
- #ro_type = None
- #rw_type = lambda self, b: array.array('i', map(ord, b))
- #getitem_type = lambda self, b: array.array('i', map(ord, b)).tostring()
- #itemsize = array.array('i').itemsize
- #format = 'i'
+class BaseArrayMemoryTests(AbstractMemoryTests):
+ ro_type = None
+ rw_type = lambda self, b: array.array('i', list(b))
+ getitem_type = lambda self, b: array.array('i', list(b)).tobytes()
+ itemsize = array.array('i').itemsize
+ format = 'i'
- #def test_getbuffer(self):
- ## XXX Test should be adapted for non-byte buffers
- #pass
+ def test_getbuffer(self):
+ # XXX Test should be adapted for non-byte buffers
+ pass
- #def test_tolist(self):
- ## XXX NotImplementedError: tolist() only supports byte views
- #pass
+ def test_tolist(self):
+ # XXX NotImplementedError: tolist() only supports byte views
+ pass
# Variations on indirection levels: memoryview, slice of memoryview,
@@ -325,37 +364,37 @@ class BytesMemoryviewTest(unittest.TestCase,
self.assertRaises(TypeError, memoryview, argument=ob)
self.assertRaises(TypeError, memoryview, ob, argument=True)
-#class ArrayMemoryviewTest(unittest.TestCase,
- #BaseMemoryviewTests, BaseArrayMemoryTests):
+class ArrayMemoryviewTest(unittest.TestCase,
+ BaseMemoryviewTests, BaseArrayMemoryTests):
- #def test_array_assign(self):
- ## Issue #4569: segfault when mutating a memoryview with itemsize != 1
- #a = array.array('i', range(10))
- #m = memoryview(a)
- #new_a = array.array('i', range(9, -1, -1))
- #m[:] = new_a
- #self.assertEqual(a, new_a)
+ def test_array_assign(self):
+ # Issue #4569: segfault when mutating a memoryview with itemsize != 1
+ a = array.array('i', range(10))
+ m = memoryview(a)
+ new_a = array.array('i', range(9, -1, -1))
+ m[:] = new_a
+ self.assertEqual(a, new_a)
class BytesMemorySliceTest(unittest.TestCase,
BaseMemorySliceTests, BaseBytesMemoryTests):
pass
-#class ArrayMemorySliceTest(unittest.TestCase,
- #BaseMemorySliceTests, BaseArrayMemoryTests):
- #pass
+class ArrayMemorySliceTest(unittest.TestCase,
+ BaseMemorySliceTests, BaseArrayMemoryTests):
+ pass
class BytesMemorySliceSliceTest(unittest.TestCase,
BaseMemorySliceSliceTests, BaseBytesMemoryTests):
pass
-#class ArrayMemorySliceSliceTest(unittest.TestCase,
- #BaseMemorySliceSliceTests, BaseArrayMemoryTests):
- #pass
+class ArrayMemorySliceSliceTest(unittest.TestCase,
+ BaseMemorySliceSliceTests, BaseArrayMemoryTests):
+ pass
def test_main():
- test_support.run_unittest(__name__)
+ test.support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_metaclass.py b/Lib/test/test_metaclass.py
new file mode 100644
index 00000000000..219ab99840b
--- /dev/null
+++ b/Lib/test/test_metaclass.py
@@ -0,0 +1,257 @@
+doctests = """
+
+Basic class construction.
+
+ >>> class C:
+ ... def meth(self): print("Hello")
+ ...
+ >>> C.__class__ is type
+ True
+ >>> a = C()
+ >>> a.__class__ is C
+ True
+ >>> a.meth()
+ Hello
+ >>>
+
+Use *args notation for the bases.
+
+ >>> class A: pass
+ >>> class B: pass
+ >>> bases = (A, B)
+ >>> class C(*bases): pass
+ >>> C.__bases__ == bases
+ True
+ >>>
+
+Use a trivial metaclass.
+
+ >>> class M(type):
+ ... pass
+ ...
+ >>> class C(metaclass=M):
+ ... def meth(self): print("Hello")
+ ...
+ >>> C.__class__ is M
+ True
+ >>> a = C()
+ >>> a.__class__ is C
+ True
+ >>> a.meth()
+ Hello
+ >>>
+
+Use **kwds notation for the metaclass keyword.
+
+ >>> kwds = {'metaclass': M}
+ >>> class C(**kwds): pass
+ ...
+ >>> C.__class__ is M
+ True
+ >>> a = C()
+ >>> a.__class__ is C
+ True
+ >>>
+
+Use a metaclass with a __prepare__ static method.
+
+ >>> class M(type):
+ ... @staticmethod
+ ... def __prepare__(*args, **kwds):
+ ... print("Prepare called:", args, kwds)
+ ... return dict()
+ ... def __new__(cls, name, bases, namespace, **kwds):
+ ... print("New called:", kwds)
+ ... return type.__new__(cls, name, bases, namespace)
+ ... def __init__(cls, *args, **kwds):
+ ... pass
+ ...
+ >>> class C(metaclass=M):
+ ... def meth(self): print("Hello")
+ ...
+ Prepare called: ('C', ()) {}
+ New called: {}
+ >>>
+
+Also pass another keyword.
+
+ >>> class C(object, metaclass=M, other="haha"):
+ ... pass
+ ...
+ Prepare called: ('C', (<class 'object'>,)) {'other': 'haha'}
+ New called: {'other': 'haha'}
+ >>> C.__class__ is M
+ True
+ >>> C.__bases__ == (object,)
+ True
+ >>> a = C()
+ >>> a.__class__ is C
+ True
+ >>>
+
+Check that build_class doesn't mutate the kwds dict.
+
+ >>> kwds = {'metaclass': type}
+ >>> class C(**kwds): pass
+ ...
+ >>> kwds == {'metaclass': type}
+ True
+ >>>
+
+Use various combinations of explicit keywords and **kwds.
+
+ >>> bases = (object,)
+ >>> kwds = {'metaclass': M, 'other': 'haha'}
+ >>> class C(*bases, **kwds): pass
+ ...
+ Prepare called: ('C', (<class 'object'>,)) {'other': 'haha'}
+ New called: {'other': 'haha'}
+ >>> C.__class__ is M
+ True
+ >>> C.__bases__ == (object,)
+ True
+ >>> class B: pass
+ >>> kwds = {'other': 'haha'}
+ >>> class C(B, metaclass=M, *bases, **kwds): pass
+ ...
+ Prepare called: ('C', (<class 'test.test_metaclass.B'>, <class 'object'>)) {'other': 'haha'}
+ New called: {'other': 'haha'}
+ >>> C.__class__ is M
+ True
+ >>> C.__bases__ == (B, object)
+ True
+ >>>
+
+Check for duplicate keywords.
+
+ >>> class C(metaclass=type, metaclass=type): pass
+ ...
+ Traceback (most recent call last):
+ [...]
+ SyntaxError: keyword argument repeated
+ >>>
+
+Another way.
+
+ >>> kwds = {'metaclass': type}
+ >>> class C(metaclass=type, **kwds): pass
+ ...
+ Traceback (most recent call last):
+ [...]
+ TypeError: __build_class__() got multiple values for keyword argument 'metaclass'
+ >>>
+
+Use a __prepare__ method that returns an instrumented dict.
+
+ >>> class LoggingDict(dict):
+ ... def __setitem__(self, key, value):
+ ... print("d[%r] = %r" % (key, value))
+ ... dict.__setitem__(self, key, value)
+ ...
+ >>> class Meta(type):
+ ... @staticmethod
+ ... def __prepare__(name, bases):
+ ... return LoggingDict()
+ ...
+ >>> class C(metaclass=Meta):
+ ... foo = 2+2
+ ... foo = 42
+ ... bar = 123
+ ...
+ d['__module__'] = 'test.test_metaclass'
+ d['foo'] = 4
+ d['foo'] = 42
+ d['bar'] = 123
+ >>>
+
+Use a metaclass that doesn't derive from type.
+
+ >>> def meta(name, bases, namespace, **kwds):
+ ... print("meta:", name, bases)
+ ... print("ns:", sorted(namespace.items()))
+ ... print("kw:", sorted(kwds.items()))
+ ... return namespace
+ ...
+ >>> class C(metaclass=meta):
+ ... a = 42
+ ... b = 24
+ ...
+ meta: C ()
+ ns: [('__module__', 'test.test_metaclass'), ('a', 42), ('b', 24)]
+ kw: []
+ >>> type(C) is dict
+ True
+ >>> print(sorted(C.items()))
+ [('__module__', 'test.test_metaclass'), ('a', 42), ('b', 24)]
+ >>>
+
+And again, with a __prepare__ attribute.
+
+ >>> def prepare(name, bases, **kwds):
+ ... print("prepare:", name, bases, sorted(kwds.items()))
+ ... return LoggingDict()
+ ...
+ >>> meta.__prepare__ = prepare
+ >>> class C(metaclass=meta, other="booh"):
+ ... a = 1
+ ... a = 2
+ ... b = 3
+ ...
+ prepare: C () [('other', 'booh')]
+ d['__module__'] = 'test.test_metaclass'
+ d['a'] = 1
+ d['a'] = 2
+ d['b'] = 3
+ meta: C ()
+ ns: [('__module__', 'test.test_metaclass'), ('a', 2), ('b', 3)]
+ kw: [('other', 'booh')]
+ >>>
+
+The default metaclass must define a __prepare__() method.
+
+ >>> type.__prepare__()
+ {}
+ >>>
+
+Make sure it works with subclassing.
+
+ >>> class M(type):
+ ... @classmethod
+ ... def __prepare__(cls, *args, **kwds):
+ ... d = super().__prepare__(*args, **kwds)
+ ... d["hello"] = 42
+ ... return d
+ ...
+ >>> class C(metaclass=M):
+ ... print(hello)
+ ...
+ 42
+ >>> print(C.hello)
+ 42
+ >>>
+
+Test failures in looking up the __prepare__ method work.
+ >>> class ObscureException(Exception):
+ ... pass
+ >>> class FailDescr:
+ ... def __get__(self, instance, owner):
+ ... raise ObscureException
+ >>> class Meta(type):
+ ... __prepare__ = FailDescr()
+ >>> class X(metaclass=Meta):
+ ... pass
+ Traceback (most recent call last):
+ [...]
+ test.test_metaclass.ObscureException
+
+"""
+
+__test__ = {'doctests' : doctests}
+
+def test_main(verbose=False):
+ from test import support
+ from test import test_metaclass
+ support.run_doctest(test_metaclass, verbose)
+
+if __name__ == "__main__":
+ test_main(verbose=True)
diff --git a/Lib/test/test_mhlib.py b/Lib/test/test_mhlib.py
deleted file mode 100644
index 996df444152..00000000000
--- a/Lib/test/test_mhlib.py
+++ /dev/null
@@ -1,348 +0,0 @@
-"""
- Tests for the mhlib module
- Nick Mathewson
-"""
-
-### BUG: This suite doesn't currently test the mime functionality of
-### mhlib. It should.
-
-import unittest
-from test.test_support import run_unittest, TESTFN, import_module
-import os, StringIO
-import sys
-mhlib = import_module('mhlib', deprecated=True)
-
-if (sys.platform.startswith("win") or sys.platform=="riscos" or
- sys.platform.startswith("atheos")):
- # mhlib.updateline() renames a file to the name of a file that already
- # exists. That causes a reasonable OS <wink> to complain in test_sequence
- # here, like the "OSError: [Errno 17] File exists" raised on Windows.
- # mhlib's listsubfolders() and listallfolders() do something with
- # link counts, and that causes test_listfolders() here to get back
- # an empty list from its call of listallfolders().
- # The other tests here pass on Windows.
- raise unittest.SkipTest("skipped on %s -- " % sys.platform +
- "too many Unix assumptions")
-
-_mhroot = TESTFN+"_MH"
-_mhpath = os.path.join(_mhroot, "MH")
-_mhprofile = os.path.join(_mhroot, ".mh_profile")
-
-def normF(f):
- return os.path.join(*f.split('/'))
-
-def writeFile(fname, contents):
- dir = os.path.split(fname)[0]
- if dir and not os.path.exists(dir):
- mkdirs(dir)
- f = open(fname, 'w')
- f.write(contents)
- f.close()
-
-def readFile(fname):
- f = open(fname)
- r = f.read()
- f.close()
- return r
-
-def writeProfile(dict):
- contents = [ "%s: %s\n" % (k, v) for k, v in dict.iteritems() ]
- writeFile(_mhprofile, "".join(contents))
-
-def writeContext(folder):
- folder = normF(folder)
- writeFile(os.path.join(_mhpath, "context"),
- "Current-Folder: %s\n" % folder)
-
-def writeCurMessage(folder, cur):
- folder = normF(folder)
- writeFile(os.path.join(_mhpath, folder, ".mh_sequences"),
- "cur: %s\n"%cur)
-
-def writeMessage(folder, n, headers, body):
- folder = normF(folder)
- headers = "".join([ "%s: %s\n" % (k, v) for k, v in headers.iteritems() ])
- contents = "%s\n%s\n" % (headers,body)
- mkdirs(os.path.join(_mhpath, folder))
- writeFile(os.path.join(_mhpath, folder, str(n)), contents)
-
-def getMH():
- return mhlib.MH(os.path.abspath(_mhpath), _mhprofile)
-
-def sortLines(s):
- lines = s.split("\n")
- lines = [ line.strip() for line in lines if len(line) >= 2 ]
- lines.sort()
- return lines
-
-# These next 2 functions are copied from test_glob.py.
-def mkdirs(fname):
- if os.path.exists(fname) or fname == '':
- return
- base, file = os.path.split(fname)
- mkdirs(base)
- os.mkdir(fname)
-
-def deltree(fname):
- if not os.path.exists(fname):
- return
- for f in os.listdir(fname):
- fullname = os.path.join(fname, f)
- if os.path.isdir(fullname):
- deltree(fullname)
- else:
- try:
- os.unlink(fullname)
- except:
- pass
- try:
- os.rmdir(fname)
- except:
- pass
-
-class MhlibTests(unittest.TestCase):
- def setUp(self):
- deltree(_mhroot)
- mkdirs(_mhpath)
- writeProfile({'Path' : os.path.abspath(_mhpath),
- 'Editor': 'emacs',
- 'ignored-attribute': 'camping holiday'})
- # Note: These headers aren't really conformant to RFC822, but
- # mhlib shouldn't care about that.
-
- # An inbox with a couple of messages.
- writeMessage('inbox', 1,
- {'From': 'Mrs. Premise',
- 'To': 'Mrs. Conclusion',
- 'Date': '18 July 2001'}, "Hullo, Mrs. Conclusion!\n")
- writeMessage('inbox', 2,
- {'From': 'Mrs. Conclusion',
- 'To': 'Mrs. Premise',
- 'Date': '29 July 2001'}, "Hullo, Mrs. Premise!\n")
-
- # A folder with many messages
- for i in range(5, 101)+range(101, 201, 2):
- writeMessage('wide', i,
- {'From': 'nowhere', 'Subject': 'message #%s' % i},
- "This is message number %s\n" % i)
-
- # A deeply nested folder
- def deep(folder, n):
- writeMessage(folder, n,
- {'Subject': 'Message %s/%s' % (folder, n) },
- "This is message number %s in %s\n" % (n, folder) )
- deep('deep/f1', 1)
- deep('deep/f1', 2)
- deep('deep/f1', 3)
- deep('deep/f2', 4)
- deep('deep/f2', 6)
- deep('deep', 3)
- deep('deep/f2/f3', 1)
- deep('deep/f2/f3', 2)
-
- def tearDown(self):
- deltree(_mhroot)
-
- def test_basic(self):
- writeContext('inbox')
- writeCurMessage('inbox', 2)
- mh = getMH()
-
- eq = self.assertEqual
- eq(mh.getprofile('Editor'), 'emacs')
- eq(mh.getprofile('not-set'), None)
- eq(mh.getpath(), os.path.abspath(_mhpath))
- eq(mh.getcontext(), 'inbox')
-
- mh.setcontext('wide')
- eq(mh.getcontext(), 'wide')
- eq(readFile(os.path.join(_mhpath, 'context')),
- "Current-Folder: wide\n")
-
- mh.setcontext('inbox')
-
- inbox = mh.openfolder('inbox')
- eq(inbox.getfullname(),
- os.path.join(os.path.abspath(_mhpath), 'inbox'))
- eq(inbox.getsequencesfilename(),
- os.path.join(os.path.abspath(_mhpath), 'inbox', '.mh_sequences'))
- eq(inbox.getmessagefilename(1),
- os.path.join(os.path.abspath(_mhpath), 'inbox', '1'))
-
- def test_listfolders(self):
- mh = getMH()
- eq = self.assertEqual
-
- folders = mh.listfolders()
- folders.sort()
- eq(folders, ['deep', 'inbox', 'wide'])
-
- folders = mh.listallfolders()
- folders.sort()
- tfolders = map(normF, ['deep', 'deep/f1', 'deep/f2', 'deep/f2/f3',
- 'inbox', 'wide'])
- tfolders.sort()
- eq(folders, tfolders)
-
- folders = mh.listsubfolders('deep')
- folders.sort()
- eq(folders, map(normF, ['deep/f1', 'deep/f2']))
-
- folders = mh.listallsubfolders('deep')
- folders.sort()
- eq(folders, map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3']))
- eq(mh.listsubfolders(normF('deep/f2')), [normF('deep/f2/f3')])
-
- eq(mh.listsubfolders('inbox'), [])
- eq(mh.listallsubfolders('inbox'), [])
-
- def test_sequence(self):
- mh = getMH()
- eq = self.assertEqual
- writeCurMessage('wide', 55)
-
- f = mh.openfolder('wide')
- all = f.listmessages()
- eq(all, range(5, 101)+range(101, 201, 2))
- eq(f.getcurrent(), 55)
- f.setcurrent(99)
- eq(readFile(os.path.join(_mhpath, 'wide', '.mh_sequences')),
- 'cur: 99\n')
-
- def seqeq(seq, val):
- eq(f.parsesequence(seq), val)
-
- seqeq('5-55', range(5, 56))
- seqeq('90-108', range(90, 101)+range(101, 109, 2))
- seqeq('90-108', range(90, 101)+range(101, 109, 2))
-
- seqeq('10:10', range(10, 20))
- seqeq('10:+10', range(10, 20))
- seqeq('101:10', range(101, 121, 2))
-
- seqeq('cur', [99])
- seqeq('.', [99])
- seqeq('prev', [98])
- seqeq('next', [100])
- seqeq('cur:-3', [97, 98, 99])
- seqeq('first-cur', range(5, 100))
- seqeq('150-last', range(151, 201, 2))
- seqeq('prev-next', [98, 99, 100])
-
- lowprimes = [5, 7, 11, 13, 17, 19, 23, 29]
- lowcompos = [x for x in range(5, 31) if not x in lowprimes ]
- f.putsequences({'cur': [5],
- 'lowprime': lowprimes,
- 'lowcompos': lowcompos})
- seqs = readFile(os.path.join(_mhpath, 'wide', '.mh_sequences'))
- seqs = sortLines(seqs)
- eq(seqs, ["cur: 5",
- "lowcompos: 6 8-10 12 14-16 18 20-22 24-28 30",
- "lowprime: 5 7 11 13 17 19 23 29"])
-
- seqeq('lowprime', lowprimes)
- seqeq('lowprime:1', [5])
- seqeq('lowprime:2', [5, 7])
- seqeq('lowprime:-2', [23, 29])
-
- ## Not supported
- #seqeq('lowprime:first', [5])
- #seqeq('lowprime:last', [29])
- #seqeq('lowprime:prev', [29])
- #seqeq('lowprime:next', [29])
-
- def test_modify(self):
- mh = getMH()
- eq = self.assertEqual
-
- mh.makefolder("dummy1")
- self.assertIn("dummy1", mh.listfolders())
- path = os.path.join(_mhpath, "dummy1")
- self.assertTrue(os.path.exists(path))
-
- f = mh.openfolder('dummy1')
- def create(n):
- msg = "From: foo\nSubject: %s\n\nDummy Message %s\n" % (n,n)
- f.createmessage(n, StringIO.StringIO(msg))
-
- create(7)
- create(8)
- create(9)
-
- eq(readFile(f.getmessagefilename(9)),
- "From: foo\nSubject: 9\n\nDummy Message 9\n")
-
- eq(f.listmessages(), [7, 8, 9])
- files = os.listdir(path)
- files.sort()
- eq(files, ['7', '8', '9'])
-
- f.removemessages(['7', '8'])
- files = os.listdir(path)
- files.sort()
- eq(files, [',7', ',8', '9'])
- eq(f.listmessages(), [9])
- create(10)
- create(11)
- create(12)
-
- mh.makefolder("dummy2")
- f2 = mh.openfolder("dummy2")
- eq(f2.listmessages(), [])
- f.movemessage(10, f2, 3)
- f.movemessage(11, f2, 5)
- eq(f.listmessages(), [9, 12])
- eq(f2.listmessages(), [3, 5])
- eq(readFile(f2.getmessagefilename(3)),
- "From: foo\nSubject: 10\n\nDummy Message 10\n")
-
- f.copymessage(9, f2, 4)
- eq(f.listmessages(), [9, 12])
- eq(readFile(f2.getmessagefilename(4)),
- "From: foo\nSubject: 9\n\nDummy Message 9\n")
-
- f.refilemessages([9, 12], f2)
- eq(f.listmessages(), [])
- eq(f2.listmessages(), [3, 4, 5, 6, 7])
- eq(readFile(f2.getmessagefilename(7)),
- "From: foo\nSubject: 12\n\nDummy Message 12\n")
- # XXX This should check that _copysequences does the right thing.
-
- mh.deletefolder('dummy1')
- mh.deletefolder('dummy2')
- self.assertNotIn('dummy1', mh.listfolders())
- self.assertTrue(not os.path.exists(path))
-
- def test_read(self):
- mh = getMH()
- eq = self.assertEqual
-
- f = mh.openfolder('inbox')
- msg = f.openmessage(1)
- # Check some basic stuff from rfc822
- eq(msg.getheader('From'), "Mrs. Premise")
- eq(msg.getheader('To'), "Mrs. Conclusion")
-
- # Okay, we have the right message. Let's check the stuff from
- # mhlib.
- lines = sortLines(msg.getheadertext())
- eq(lines, ["Date: 18 July 2001",
- "From: Mrs. Premise",
- "To: Mrs. Conclusion"])
- lines = sortLines(msg.getheadertext(lambda h: len(h)==4))
- eq(lines, ["Date: 18 July 2001",
- "From: Mrs. Premise"])
- eq(msg.getbodytext(), "Hullo, Mrs. Conclusion!\n\n")
- eq(msg.getbodytext(0), "Hullo, Mrs. Conclusion!\n\n")
-
- # XXXX there should be a better way to reclaim the file handle
- msg.fp.close()
- del msg
-
-
-def test_main():
- run_unittest(MhlibTests)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_mimetools.py b/Lib/test/test_mimetools.py
deleted file mode 100644
index 86a26dc7e5a..00000000000
--- a/Lib/test/test_mimetools.py
+++ /dev/null
@@ -1,53 +0,0 @@
-import unittest
-from test import test_support
-
-import string
-import StringIO
-
-mimetools = test_support.import_module("mimetools", deprecated=True)
-
-msgtext1 = mimetools.Message(StringIO.StringIO(
-"""Content-Type: text/plain; charset=iso-8859-1; format=flowed
-Content-Transfer-Encoding: 8bit
-
-Foo!
-"""))
-
-class MimeToolsTest(unittest.TestCase):
-
- def test_decodeencode(self):
- start = string.ascii_letters + "=" + string.digits + "\n"
- for enc in ['7bit','8bit','base64','quoted-printable',
- 'uuencode', 'x-uuencode', 'uue', 'x-uue']:
- i = StringIO.StringIO(start)
- o = StringIO.StringIO()
- mimetools.encode(i, o, enc)
- i = StringIO.StringIO(o.getvalue())
- o = StringIO.StringIO()
- mimetools.decode(i, o, enc)
- self.assertEqual(o.getvalue(), start)
-
- def test_boundary(self):
- s = set([""])
- for i in xrange(100):
- nb = mimetools.choose_boundary()
- self.assertNotIn(nb, s)
- s.add(nb)
-
- def test_message(self):
- msg = mimetools.Message(StringIO.StringIO(msgtext1))
- self.assertEqual(msg.gettype(), "text/plain")
- self.assertEqual(msg.getmaintype(), "text")
- self.assertEqual(msg.getsubtype(), "plain")
- self.assertEqual(msg.getplist(), ["charset=iso-8859-1", "format=flowed"])
- self.assertEqual(msg.getparamnames(), ["charset", "format"])
- self.assertEqual(msg.getparam("charset"), "iso-8859-1")
- self.assertEqual(msg.getparam("format"), "flowed")
- self.assertEqual(msg.getparam("spam"), None)
- self.assertEqual(msg.getencoding(), "8bit")
-
-def test_main():
- test_support.run_unittest(MimeToolsTest)
-
-if __name__=="__main__":
- test_main()
diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py
index 3508b560568..91da28927dc 100644
--- a/Lib/test/test_mimetypes.py
+++ b/Lib/test/test_mimetypes.py
@@ -1,9 +1,10 @@
+import io
+import locale
import mimetypes
-import StringIO
-import unittest
import sys
+import unittest
-from test import test_support
+from test import support
# Tell it we don't know about external files:
mimetypes.knownfiles = []
@@ -31,7 +32,7 @@ class MimeTypesTestCase(unittest.TestCase):
def test_file_parsing(self):
eq = self.assertEqual
- sio = StringIO.StringIO("x-application/x-unittest pyunit\n")
+ sio = io.StringIO("x-application/x-unittest pyunit\n")
self.db.readfp(sio)
eq(self.db.guess_type("foo.pyunit"),
("x-application/x-unittest", None))
@@ -62,6 +63,18 @@ class MimeTypesTestCase(unittest.TestCase):
all = self.db.guess_all_extensions('image/jpg', strict=True)
eq(all, [])
+ def test_encoding(self):
+ getpreferredencoding = locale.getpreferredencoding
+ self.addCleanup(setattr, locale, 'getpreferredencoding',
+ getpreferredencoding)
+ locale.getpreferredencoding = lambda: 'ascii'
+
+ filename = support.findfile("mime.types")
+ mimes = mimetypes.MimeTypes([filename])
+ exts = mimes.guess_all_extensions('application/vnd.geocube+xml',
+ strict=True)
+ self.assertEqual(exts, ['.g3', '.g\xb3'])
+
@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
class Win32MimeTypesTestCase(unittest.TestCase):
@@ -84,8 +97,9 @@ class Win32MimeTypesTestCase(unittest.TestCase):
eq = self.assertEqual
eq(self.db.guess_type("foo.txt"), ("text/plain", None))
+
def test_main():
- test_support.run_unittest(MimeTypesTestCase,
+ support.run_unittest(MimeTypesTestCase,
Win32MimeTypesTestCase
)
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index ca0f0f77ebd..80812c8cfae 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1,8 +1,7 @@
# test for xml.dom.minidom
import pickle
-from StringIO import StringIO
-from test.test_support import verbose, run_unittest, findfile
+from test.support import verbose, run_unittest, findfile
import unittest
import xml.dom
@@ -54,9 +53,10 @@ class MinidomTest(unittest.TestCase):
self.confirm(t == s, "looking for %s, found %s" % (repr(s), repr(t)))
def testParseFromFile(self):
- dom = parse(StringIO(open(tstfile).read()))
- dom.unlink()
- self.confirm(isinstance(dom,Document))
+ with open(tstfile) as file:
+ dom = parse(file)
+ dom.unlink()
+ self.confirm(isinstance(dom, Document))
def testGetElementsByTagName(self):
dom = parse(tstfile)
@@ -139,7 +139,7 @@ class MinidomTest(unittest.TestCase):
def testAppendChild(self):
dom = parse(tstfile)
- dom.documentElement.appendChild(dom.createComment(u"Hello"))
+ dom.documentElement.appendChild(dom.createComment("Hello"))
self.confirm(dom.documentElement.childNodes[-1].nodeName == "#comment")
self.confirm(dom.documentElement.childNodes[-1].data == "Hello")
dom.unlink()
@@ -209,7 +209,14 @@ class MinidomTest(unittest.TestCase):
def testUnlink(self):
dom = parse(tstfile)
+ self.assertTrue(dom.childNodes)
dom.unlink()
+ self.assertFalse(dom.childNodes)
+
+ def testContext(self):
+ with parse(tstfile) as dom:
+ self.assertTrue(dom.childNodes)
+ self.assertFalse(dom.childNodes)
def testElement(self):
dom = Document()
@@ -343,13 +350,31 @@ class MinidomTest(unittest.TestCase):
def testGetAttrList(self):
pass
- def testGetAttrValues(self): pass
+ def testGetAttrValues(self):
+ pass
- def testGetAttrLength(self): pass
+ def testGetAttrLength(self):
+ pass
- def testGetAttribute(self): pass
+ def testGetAttribute(self):
+ dom = Document()
+ child = dom.appendChild(
+ dom.createElementNS("http://www.python.org", "python:abc"))
+ self.assertEqual(child.getAttribute('missing'), '')
- def testGetAttributeNS(self): pass
+ def testGetAttributeNS(self):
+ dom = Document()
+ child = dom.appendChild(
+ dom.createElementNS("http://www.python.org", "python:abc"))
+ child.setAttributeNS("http://www.w3.org", "xmlns:python",
+ "http://www.python.org")
+ self.assertEqual(child.getAttributeNS("http://www.w3.org", "python"),
+ 'http://www.python.org')
+ self.assertEqual(child.getAttributeNS("http://www.w3.org", "other"),
+ '')
+ child2 = child.appendChild(dom.createElement('abc'))
+ self.assertEqual(child2.getAttributeNS("http://www.python.org", "missing"),
+ '')
def testGetAttributeNode(self): pass
@@ -400,7 +425,7 @@ class MinidomTest(unittest.TestCase):
def testElementReprAndStrUnicode(self):
dom = Document()
- el = dom.appendChild(dom.createElement(u"abc"))
+ el = dom.appendChild(dom.createElement("abc"))
string1 = repr(el)
string2 = str(el)
self.confirm(string1 == string2)
@@ -409,7 +434,7 @@ class MinidomTest(unittest.TestCase):
def testElementReprAndStrUnicodeNS(self):
dom = Document()
el = dom.appendChild(
- dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
+ dom.createElementNS("http://www.slashdot.org", "slash:abc"))
string1 = repr(el)
string2 = str(el)
self.confirm(string1 == string2)
@@ -418,7 +443,7 @@ class MinidomTest(unittest.TestCase):
def testAttributeRepr(self):
dom = Document()
- el = dom.appendChild(dom.createElement(u"abc"))
+ el = dom.appendChild(dom.createElement("abc"))
node = el.setAttribute("abc", "def")
self.confirm(str(node) == repr(node))
dom.unlink()
@@ -456,9 +481,9 @@ class MinidomTest(unittest.TestCase):
def test_toprettyxml_with_adjacent_text_nodes(self):
# see issue #4147, adjacent text nodes are indented normally
dom = Document()
- elem = dom.createElement(u'elem')
- elem.appendChild(dom.createTextNode(u'TEXT'))
- elem.appendChild(dom.createTextNode(u'TEXT'))
+ elem = dom.createElement('elem')
+ elem.appendChild(dom.createTextNode('TEXT'))
+ elem.appendChild(dom.createTextNode('TEXT'))
dom.appendChild(elem)
decl = '<?xml version="1.0" ?>\n'
self.assertEqual(dom.toprettyxml(),
@@ -572,8 +597,8 @@ class MinidomTest(unittest.TestCase):
def _testCloneElementCopiesAttributes(self, e1, e2, test):
attrs1 = e1.attributes
attrs2 = e2.attributes
- keys1 = attrs1.keys()
- keys2 = attrs2.keys()
+ keys1 = list(attrs1.keys())
+ keys2 = list(attrs2.keys())
keys1.sort()
keys2.sort()
self.confirm(keys1 == keys2, "clone of element has same attribute keys")
@@ -1053,17 +1078,17 @@ class MinidomTest(unittest.TestCase):
def testEncodings(self):
doc = parseString('<foo>&#x20ac;</foo>')
- self.confirm(doc.toxml() == u'<?xml version="1.0" ?><foo>\u20ac</foo>'
- and doc.toxml('utf-8') ==
- '<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>'
- and doc.toxml('iso-8859-15') ==
- '<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>',
- "testEncodings - encoding EURO SIGN")
+ self.assertEqual(doc.toxml(),
+ '<?xml version="1.0" ?><foo>\u20ac</foo>')
+ self.assertEqual(doc.toxml('utf-8'),
+ b'<?xml version="1.0" encoding="utf-8"?><foo>\xe2\x82\xac</foo>')
+ self.assertEqual(doc.toxml('iso-8859-15'),
+ b'<?xml version="1.0" encoding="iso-8859-15"?><foo>\xa4</foo>')
# Verify that character decoding errors raise exceptions instead
# of crashing
self.assertRaises(UnicodeDecodeError, parseString,
- '<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
+ b'<fran\xe7ais>Comment \xe7a va ? Tr\xe8s bien ?</fran\xe7ais>')
doc.unlink()
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 0701b9621d8..28b52a98e6e 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -1,8 +1,13 @@
-from test.test_support import (TESTFN, run_unittest, import_module, unlink,
- requires, _2G, _4G)
+from test.support import (TESTFN, run_unittest, import_module, unlink,
+ requires, _2G, _4G)
import unittest
-import os, re, itertools, socket, sys
+import os
+import re
+import itertools
+import socket
+import sys
+# Skip test if we can't import mmap.
mmap = import_module('mmap')
PAGESIZE = mmap.PAGESIZE
@@ -23,222 +28,212 @@ class MmapTests(unittest.TestCase):
# Test mmap module on Unix systems and Windows
# Create a file to be mmap'ed.
- f = open(TESTFN, 'w+')
+ f = open(TESTFN, 'bw+')
try:
# Write 2 pages worth of data to the file
- f.write('\0'* PAGESIZE)
- f.write('foo')
- f.write('\0'* (PAGESIZE-3) )
+ f.write(b'\0'* PAGESIZE)
+ f.write(b'foo')
+ f.write(b'\0'* (PAGESIZE-3) )
f.flush()
m = mmap.mmap(f.fileno(), 2 * PAGESIZE)
+ finally:
f.close()
- # Simple sanity checks
+ # Simple sanity checks
- tp = str(type(m)) # SF bug 128713: segfaulted on Linux
- self.assertEqual(m.find('foo'), PAGESIZE)
+ tp = str(type(m)) # SF bug 128713: segfaulted on Linux
+ self.assertEqual(m.find(b'foo'), PAGESIZE)
- self.assertEqual(len(m), 2*PAGESIZE)
+ self.assertEqual(len(m), 2*PAGESIZE)
- self.assertEqual(m[0], '\0')
- self.assertEqual(m[0:3], '\0\0\0')
+ self.assertEqual(m[0], 0)
+ self.assertEqual(m[0:3], b'\0\0\0')
- # Shouldn't crash on boundary (Issue #5292)
- self.assertRaises(IndexError, m.__getitem__, len(m))
- self.assertRaises(IndexError, m.__setitem__, len(m), '\0')
+ # Shouldn't crash on boundary (Issue #5292)
+ self.assertRaises(IndexError, m.__getitem__, len(m))
+ self.assertRaises(IndexError, m.__setitem__, len(m), b'\0')
- # Modify the file's content
- m[0] = '3'
- m[PAGESIZE +3: PAGESIZE +3+3] = 'bar'
+ # Modify the file's content
+ m[0] = b'3'[0]
+ m[PAGESIZE +3: PAGESIZE +3+3] = b'bar'
- # Check that the modification worked
- self.assertEqual(m[0], '3')
- self.assertEqual(m[0:3], '3\0\0')
- self.assertEqual(m[PAGESIZE-1 : PAGESIZE + 7], '\0foobar\0')
+ # Check that the modification worked
+ self.assertEqual(m[0], b'3'[0])
+ self.assertEqual(m[0:3], b'3\0\0')
+ self.assertEqual(m[PAGESIZE-1 : PAGESIZE + 7], b'\0foobar\0')
- m.flush()
+ m.flush()
- # Test doing a regular expression match in an mmap'ed file
- match = re.search('[A-Za-z]+', m)
- if match is None:
- self.fail('regex match on mmap failed!')
- else:
- start, end = match.span(0)
- length = end - start
+ # Test doing a regular expression match in an mmap'ed file
+ match = re.search(b'[A-Za-z]+', m)
+ if match is None:
+ self.fail('regex match on mmap failed!')
+ else:
+ start, end = match.span(0)
+ length = end - start
- self.assertEqual(start, PAGESIZE)
- self.assertEqual(end, PAGESIZE + 6)
+ self.assertEqual(start, PAGESIZE)
+ self.assertEqual(end, PAGESIZE + 6)
- # test seeking around (try to overflow the seek implementation)
- m.seek(0,0)
- self.assertEqual(m.tell(), 0)
- m.seek(42,1)
- self.assertEqual(m.tell(), 42)
- m.seek(0,2)
- self.assertEqual(m.tell(), len(m))
+ # test seeking around (try to overflow the seek implementation)
+ m.seek(0,0)
+ self.assertEqual(m.tell(), 0)
+ m.seek(42,1)
+ self.assertEqual(m.tell(), 42)
+ m.seek(0,2)
+ self.assertEqual(m.tell(), len(m))
- # Try to seek to negative position...
- self.assertRaises(ValueError, m.seek, -1)
+ # Try to seek to negative position...
+ self.assertRaises(ValueError, m.seek, -1)
- # Try to seek beyond end of mmap...
- self.assertRaises(ValueError, m.seek, 1, 2)
+ # Try to seek beyond end of mmap...
+ self.assertRaises(ValueError, m.seek, 1, 2)
- # Try to seek to negative position...
- self.assertRaises(ValueError, m.seek, -len(m)-1, 2)
+ # Try to seek to negative position...
+ self.assertRaises(ValueError, m.seek, -len(m)-1, 2)
- # Try resizing map
+ # Try resizing map
+ try:
+ m.resize(512)
+ except SystemError:
+ # resize() not supported
+ # No messages are printed, since the output of this test suite
+ # would then be different across platforms.
+ pass
+ else:
+ # resize() is supported
+ self.assertEqual(len(m), 512)
+ # Check that we can no longer seek beyond the new size.
+ self.assertRaises(ValueError, m.seek, 513, 0)
+
+ # Check that the underlying file is truncated too
+ # (bug #728515)
+ f = open(TESTFN, 'rb')
try:
- m.resize(512)
- except SystemError:
- # resize() not supported
- # No messages are printed, since the output of this test suite
- # would then be different across platforms.
- pass
- else:
- # resize() is supported
- self.assertEqual(len(m), 512)
- # Check that we can no longer seek beyond the new size.
- self.assertRaises(ValueError, m.seek, 513, 0)
-
- # Check that the underlying file is truncated too
- # (bug #728515)
- f = open(TESTFN)
f.seek(0, 2)
self.assertEqual(f.tell(), 512)
+ finally:
f.close()
- self.assertEqual(m.size(), 512)
-
- m.close()
+ self.assertEqual(m.size(), 512)
- finally:
- try:
- f.close()
- except OSError:
- pass
+ m.close()
def test_access_parameter(self):
# Test for "access" keyword parameter
mapsize = 10
- open(TESTFN, "wb").write("a"*mapsize)
- f = open(TESTFN, "rb")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
- self.assertEqual(m[:], 'a'*mapsize, "Readonly memory map data incorrect.")
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"a"*mapsize)
+ with open(TESTFN, "rb") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_READ)
+ self.assertEqual(m[:], b'a'*mapsize, "Readonly memory map data incorrect.")
- # Ensuring that readonly mmap can't be slice assigned
- try:
- m[:] = 'b'*mapsize
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be slice assigned
+ try:
+ m[:] = b'b'*mapsize
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be item assigned
- try:
- m[0] = 'b'
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be item assigned
+ try:
+ m[0] = b'b'
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be write() to
- try:
- m.seek(0,0)
- m.write('abc')
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be write() to
+ try:
+ m.seek(0,0)
+ m.write(b'abc')
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be write_byte() to
- try:
- m.seek(0,0)
- m.write_byte('d')
- except TypeError:
- pass
- else:
- self.fail("Able to write to readonly memory map")
+ # Ensuring that readonly mmap can't be write_byte() to
+ try:
+ m.seek(0,0)
+ m.write_byte(b'd')
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to write to readonly memory map")
- # Ensuring that readonly mmap can't be resized
- try:
- m.resize(2*mapsize)
- except SystemError: # resize is not universally supported
- pass
- except TypeError:
- pass
- else:
- self.fail("Able to resize readonly memory map")
- f.close()
- del m, f
- self.assertEqual(open(TESTFN, "rb").read(), 'a'*mapsize,
- "Readonly memory map data file was modified")
+ # Ensuring that readonly mmap can't be resized
+ try:
+ m.resize(2*mapsize)
+ except SystemError: # resize is not universally supported
+ pass
+ except TypeError:
+ pass
+ else:
+ self.fail("Able to resize readonly memory map")
+ with open(TESTFN, "rb") as fp:
+ self.assertEqual(fp.read(), b'a'*mapsize,
+ "Readonly memory map data file was modified")
# Opening mmap with size too big
- import sys
- f = open(TESTFN, "r+b")
- try:
- m = mmap.mmap(f.fileno(), mapsize+1)
- except ValueError:
- # we do not expect a ValueError on Windows
- # CAUTION: This also changes the size of the file on disk, and
- # later tests assume that the length hasn't changed. We need to
- # repair that.
+ with open(TESTFN, "r+b") as f:
+ try:
+ m = mmap.mmap(f.fileno(), mapsize+1)
+ except ValueError:
+ # we do not expect a ValueError on Windows
+ # CAUTION: This also changes the size of the file on disk, and
+ # later tests assume that the length hasn't changed. We need to
+ # repair that.
+ if sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should work on Windows.")
+ else:
+ # we expect a ValueError on Unix, but not on Windows
+ if not sys.platform.startswith('win'):
+ self.fail("Opening mmap with size+1 should raise ValueError.")
+ m.close()
if sys.platform.startswith('win'):
- self.fail("Opening mmap with size+1 should work on Windows.")
- else:
- # we expect a ValueError on Unix, but not on Windows
- if not sys.platform.startswith('win'):
- self.fail("Opening mmap with size+1 should raise ValueError.")
- m.close()
- f.close()
- if sys.platform.startswith('win'):
- # Repair damage from the resizing test.
- f = open(TESTFN, 'r+b')
- f.truncate(mapsize)
- f.close()
+ # Repair damage from the resizing test.
+ with open(TESTFN, 'r+b') as f:
+ f.truncate(mapsize)
# Opening mmap with access=ACCESS_WRITE
- f = open(TESTFN, "r+b")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE)
- # Modifying write-through memory map
- m[:] = 'c'*mapsize
- self.assertEqual(m[:], 'c'*mapsize,
- "Write-through memory map memory not updated properly.")
- m.flush()
- m.close()
- f.close()
- f = open(TESTFN, 'rb')
- stuff = f.read()
- f.close()
- self.assertEqual(stuff, 'c'*mapsize,
+ with open(TESTFN, "r+b") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE)
+ # Modifying write-through memory map
+ m[:] = b'c'*mapsize
+ self.assertEqual(m[:], b'c'*mapsize,
+ "Write-through memory map memory not updated properly.")
+ m.flush()
+ m.close()
+ with open(TESTFN, 'rb') as f:
+ stuff = f.read()
+ self.assertEqual(stuff, b'c'*mapsize,
"Write-through memory map data file not updated properly.")
# Opening mmap with access=ACCESS_COPY
- f = open(TESTFN, "r+b")
- m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY)
- # Modifying copy-on-write memory map
- m[:] = 'd'*mapsize
- self.assertEqual(m[:], 'd' * mapsize,
- "Copy-on-write memory map data not written correctly.")
- m.flush()
- self.assertEqual(open(TESTFN, "rb").read(), 'c'*mapsize,
- "Copy-on-write test data file should not be modified.")
- # Ensuring copy-on-write maps cannot be resized
- self.assertRaises(TypeError, m.resize, 2*mapsize)
- f.close()
- del m, f
+ with open(TESTFN, "r+b") as f:
+ m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_COPY)
+ # Modifying copy-on-write memory map
+ m[:] = b'd'*mapsize
+ self.assertEqual(m[:], b'd' * mapsize,
+ "Copy-on-write memory map data not written correctly.")
+ m.flush()
+ with open(TESTFN, "rb") as fp:
+ self.assertEqual(fp.read(), b'c'*mapsize,
+ "Copy-on-write test data file should not be modified.")
+ # Ensuring copy-on-write maps cannot be resized
+ self.assertRaises(TypeError, m.resize, 2*mapsize)
+ m.close()
# Ensuring invalid access parameter raises exception
- f = open(TESTFN, "r+b")
- self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4)
- f.close()
+ with open(TESTFN, "r+b") as f:
+ self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize, access=4)
if os.name == "posix":
# Try incompatible flags, prot and access parameters.
- f = open(TESTFN, "r+b")
- self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
- flags=mmap.MAP_PRIVATE,
- prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
- f.close()
+ with open(TESTFN, "r+b") as f:
+ self.assertRaises(ValueError, mmap.mmap, f.fileno(), mapsize,
+ flags=mmap.MAP_PRIVATE,
+ prot=mmap.PROT_READ, access=mmap.ACCESS_WRITE)
# Try writing with PROT_EXEC and without PROT_WRITE
prot = mmap.PROT_READ | getattr(mmap, 'PROT_EXEC', 0)
@@ -255,66 +250,65 @@ class MmapTests(unittest.TestCase):
def test_tougher_find(self):
# Do a tougher .find() test. SF bug 515943 pointed out that, in 2.2,
# searching for data with embedded \0 bytes didn't work.
- f = open(TESTFN, 'w+')
+ with open(TESTFN, 'wb+') as f:
- data = 'aabaac\x00deef\x00\x00aa\x00'
- n = len(data)
- f.write(data)
- f.flush()
- m = mmap.mmap(f.fileno(), n)
- f.close()
+ data = b'aabaac\x00deef\x00\x00aa\x00'
+ n = len(data)
+ f.write(data)
+ f.flush()
+ m = mmap.mmap(f.fileno(), n)
for start in range(n+1):
for finish in range(start, n+1):
slice = data[start : finish]
self.assertEqual(m.find(slice), data.find(slice))
- self.assertEqual(m.find(slice + 'x'), -1)
+ self.assertEqual(m.find(slice + b'x'), -1)
m.close()
def test_find_end(self):
# test the new 'end' parameter works as expected
- f = open(TESTFN, 'w+')
- data = 'one two ones'
+ f = open(TESTFN, 'wb+')
+ data = b'one two ones'
n = len(data)
f.write(data)
f.flush()
m = mmap.mmap(f.fileno(), n)
f.close()
- self.assertEqual(m.find('one'), 0)
- self.assertEqual(m.find('ones'), 8)
- self.assertEqual(m.find('one', 0, -1), 0)
- self.assertEqual(m.find('one', 1), 8)
- self.assertEqual(m.find('one', 1, -1), 8)
- self.assertEqual(m.find('one', 1, -2), -1)
+ self.assertEqual(m.find(b'one'), 0)
+ self.assertEqual(m.find(b'ones'), 8)
+ self.assertEqual(m.find(b'one', 0, -1), 0)
+ self.assertEqual(m.find(b'one', 1), 8)
+ self.assertEqual(m.find(b'one', 1, -1), 8)
+ self.assertEqual(m.find(b'one', 1, -2), -1)
def test_rfind(self):
# test the new 'end' parameter works as expected
- f = open(TESTFN, 'w+')
- data = 'one two ones'
+ f = open(TESTFN, 'wb+')
+ data = b'one two ones'
n = len(data)
f.write(data)
f.flush()
m = mmap.mmap(f.fileno(), n)
f.close()
- self.assertEqual(m.rfind('one'), 8)
- self.assertEqual(m.rfind('one '), 0)
- self.assertEqual(m.rfind('one', 0, -1), 8)
- self.assertEqual(m.rfind('one', 0, -2), 0)
- self.assertEqual(m.rfind('one', 1, -1), 8)
- self.assertEqual(m.rfind('one', 1, -2), -1)
+ self.assertEqual(m.rfind(b'one'), 8)
+ self.assertEqual(m.rfind(b'one '), 0)
+ self.assertEqual(m.rfind(b'one', 0, -1), 8)
+ self.assertEqual(m.rfind(b'one', 0, -2), 0)
+ self.assertEqual(m.rfind(b'one', 1, -1), 8)
+ self.assertEqual(m.rfind(b'one', 1, -2), -1)
def test_double_close(self):
# make sure a double close doesn't crash on Solaris (Bug# 665913)
- f = open(TESTFN, 'w+')
+ f = open(TESTFN, 'wb+')
- f.write(2**16 * 'a') # Arbitrary character
+ f.write(2**16 * b'a') # Arbitrary character
f.close()
- f = open(TESTFN)
+ f = open(TESTFN, 'rb')
mf = mmap.mmap(f.fileno(), 2**16, access=mmap.ACCESS_READ)
mf.close()
mf.close()
@@ -323,15 +317,15 @@ class MmapTests(unittest.TestCase):
def test_entire_file(self):
# test mapping of entire file by passing 0 for map length
if hasattr(os, "stat"):
- f = open(TESTFN, "w+")
+ f = open(TESTFN, "wb+")
- f.write(2**16 * 'm') # Arbitrary character
+ f.write(2**16 * b'm') # Arbitrary character
f.close()
f = open(TESTFN, "rb+")
mf = mmap.mmap(f.fileno(), 0)
self.assertEqual(len(mf), 2**16, "Map size should equal file size.")
- self.assertEqual(mf.read(2**16), 2**16 * "m")
+ self.assertEqual(mf.read(2**16), 2**16 * b"m")
mf.close()
f.close()
@@ -346,11 +340,8 @@ class MmapTests(unittest.TestCase):
f.write((65536 * 2) * b'm') # Arbitrary character
with open(TESTFN, "rb") as f:
- mf = mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ) as mf:
self.assertRaises(IndexError, mf.__getitem__, 80000)
- finally:
- mf.close()
def test_length_0_large_offset(self):
# Issue #10959: test mapping of a file by passing 0 for
@@ -367,19 +358,19 @@ class MmapTests(unittest.TestCase):
def test_move(self):
# make move works everywhere (64-bit format problem earlier)
- f = open(TESTFN, 'w+')
+ f = open(TESTFN, 'wb+')
- f.write("ABCDEabcde") # Arbitrary character
+ f.write(b"ABCDEabcde") # Arbitrary character
f.flush()
mf = mmap.mmap(f.fileno(), 10)
mf.move(5, 0, 5)
- self.assertEqual(mf[:], "ABCDEABCDE", "Map move should have duplicated front 5")
+ self.assertEqual(mf[:], b"ABCDEABCDE", "Map move should have duplicated front 5")
mf.close()
f.close()
# more excessive test
- data = "0123456789"
+ data = b"0123456789"
for dest in range(len(data)):
for src in range(len(data)):
for count in range(len(data) - max(dest, src)):
@@ -417,16 +408,18 @@ class MmapTests(unittest.TestCase):
def test_anonymous(self):
# anonymous mmap.mmap(-1, PAGE)
m = mmap.mmap(-1, PAGESIZE)
- for x in xrange(PAGESIZE):
- self.assertEqual(m[x], '\0', "anonymously mmap'ed contents should be zero")
+ for x in range(PAGESIZE):
+ self.assertEqual(m[x], 0,
+ "anonymously mmap'ed contents should be zero")
- for x in xrange(PAGESIZE):
- m[x] = ch = chr(x & 255)
- self.assertEqual(m[x], ch)
+ for x in range(PAGESIZE):
+ b = x & 0xff
+ m[x] = b
+ self.assertEqual(m[x], b)
def test_extended_getslice(self):
# Test extended slicing by comparing with list slicing.
- s = "".join(chr(c) for c in reversed(range(256)))
+ s = bytes(reversed(range(256)))
m = mmap.mmap(-1, len(s))
m[:] = s
self.assertEqual(m[:], s)
@@ -440,7 +433,7 @@ class MmapTests(unittest.TestCase):
def test_extended_set_del_slice(self):
# Test extended slicing by comparing with list slicing.
- s = "".join(chr(c) for c in reversed(range(256)))
+ s = bytes(reversed(range(256)))
m = mmap.mmap(-1, len(s))
indices = (0, None, 1, 3, 19, 300, -1, -2, -31, -300)
for start in indices:
@@ -453,16 +446,16 @@ class MmapTests(unittest.TestCase):
# Make sure we have a slice of exactly the right length,
# but with different data.
data = L[start:stop:step]
- data = "".join(reversed(data))
+ data = bytes(reversed(data))
L[start:stop:step] = data
m[start:stop:step] = data
- self.assertEqual(m[:], "".join(L))
+ self.assertEqual(m[:], bytes(L))
def make_mmap_file (self, f, halfsize):
# Write 2 pages worth of data to the file
- f.write ('\0' * halfsize)
- f.write ('foo')
- f.write ('\0' * (halfsize - 3))
+ f.write (b'\0' * halfsize)
+ f.write (b'foo')
+ f.write (b'\0' * (halfsize - 3))
f.flush ()
return mmap.mmap (f.fileno(), 0)
@@ -470,14 +463,10 @@ class MmapTests(unittest.TestCase):
f = open (TESTFN, 'w+b')
f.close()
with open(TESTFN, "rb") as f :
- try:
- m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
- m.close()
- self.fail("should not have been able to mmap empty file")
- except ValueError as e:
- self.assertEqual(e.message, "cannot mmap an empty file")
- except:
- self.fail("unexpected exception: " + str(e))
+ self.assertRaisesRegex(ValueError,
+ "cannot mmap an empty file",
+ mmap.mmap, f.fileno(), 0,
+ access=mmap.ACCESS_READ)
def test_offset (self):
f = open (TESTFN, 'w+b')
@@ -504,7 +493,7 @@ class MmapTests(unittest.TestCase):
# Try valid offset, hopefully 8192 works on all OSes
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize)
- self.assertEqual(m[0:3], 'foo')
+ self.assertEqual(m[0:3], b'foo')
f.close()
# Try resizing map
@@ -518,10 +507,10 @@ class MmapTests(unittest.TestCase):
# Check that we can no longer seek beyond the new size.
self.assertRaises(ValueError, m.seek, 513, 0)
# Check that the content is not changed
- self.assertEqual(m[0:3], 'foo')
+ self.assertEqual(m[0:3], b'foo')
# Check that the underlying file is truncated too
- f = open(TESTFN)
+ f = open(TESTFN, 'rb')
f.seek(0, 2)
self.assertEqual(f.tell(), halfsize + 512)
f.close()
@@ -546,7 +535,8 @@ class MmapTests(unittest.TestCase):
if not hasattr(mmap, 'PROT_READ'):
return
mapsize = 10
- open(TESTFN, "wb").write("a"*mapsize)
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"a"*mapsize)
f = open(TESTFN, "rb")
m = mmap.mmap(f.fileno(), mapsize, prot=mmap.PROT_READ)
self.assertRaises(TypeError, m.write, "foo")
@@ -557,41 +547,51 @@ class MmapTests(unittest.TestCase):
self.assertIn("mmap.error", str(mmap.error))
def test_io_methods(self):
- data = "0123456789"
- open(TESTFN, "wb").write("x"*len(data))
+ data = b"0123456789"
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"x"*len(data))
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), len(data))
f.close()
# Test write_byte()
- for i in xrange(len(data)):
+ for i in range(len(data)):
self.assertEqual(m.tell(), i)
m.write_byte(data[i])
self.assertEqual(m.tell(), i+1)
- self.assertRaises(ValueError, m.write_byte, "x")
+ self.assertRaises(ValueError, m.write_byte, b"x"[0])
self.assertEqual(m[:], data)
# Test read_byte()
m.seek(0)
- for i in xrange(len(data)):
+ for i in range(len(data)):
self.assertEqual(m.tell(), i)
self.assertEqual(m.read_byte(), data[i])
self.assertEqual(m.tell(), i+1)
self.assertRaises(ValueError, m.read_byte)
# Test read()
m.seek(3)
- self.assertEqual(m.read(3), "345")
+ self.assertEqual(m.read(3), b"345")
self.assertEqual(m.tell(), 6)
# Test write()
m.seek(3)
- m.write("bar")
+ m.write(b"bar")
self.assertEqual(m.tell(), 6)
- self.assertEqual(m[:], "012bar6789")
+ self.assertEqual(m[:], b"012bar6789")
m.seek(8)
- self.assertRaises(ValueError, m.write, "bar")
+ self.assertRaises(ValueError, m.write, b"bar")
+
+ def test_non_ascii_byte(self):
+ for b in (129, 200, 255): # > 128
+ m = mmap.mmap(-1, 1)
+ m.write_byte(b)
+ self.assertEqual(m[0], b)
+ m.seek(0)
+ self.assertEqual(m.read_byte(), b)
+ m.close()
if os.name == 'nt':
def test_tagname(self):
- data1 = "0123456789"
- data2 = "abcdefghij"
+ data1 = b"0123456789"
+ data2 = b"abcdefghij"
assert len(data1) == len(data2)
# Test same tag
@@ -624,7 +624,8 @@ class MmapTests(unittest.TestCase):
m.close()
# Should not crash (Issue 5385)
- open(TESTFN, "wb").write("x"*10)
+ with open(TESTFN, "wb") as fp:
+ fp.write(b"x"*10)
f = open(TESTFN, "r+b")
m = mmap.mmap(f.fileno(), 0)
f.close()
@@ -649,6 +650,19 @@ class MmapTests(unittest.TestCase):
finally:
s.close()
+ def test_context_manager(self):
+ with mmap.mmap(-1, 10) as m:
+ self.assertFalse(m.closed)
+ self.assertTrue(m.closed)
+
+ def test_context_manager_exception(self):
+ # Test that the IOError gets passed through
+ with self.assertRaises(Exception) as exc:
+ with mmap.mmap(-1, 10) as m:
+ raise IOError
+ self.assertIsInstance(exc.exception, IOError,
+ "wrong exception raised in context manager")
+ self.assertTrue(m.closed, "context manager failed")
class LargeMmapTests(unittest.TestCase):
@@ -674,19 +688,13 @@ class LargeMmapTests(unittest.TestCase):
def test_large_offset(self):
with self._make_test_file(0x14FFFFFFF, b" ") as f:
- m = mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ)
- try:
- self.assertEqual(m[0xFFFFFFF], b" ")
- finally:
- m.close()
+ with mmap.mmap(f.fileno(), 0, offset=0x140000000, access=mmap.ACCESS_READ) as m:
+ self.assertEqual(m[0xFFFFFFF], 32)
def test_large_filesize(self):
with self._make_test_file(0x17FFFFFFF, b" ") as f:
- m = mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0x10000, access=mmap.ACCESS_READ) as m:
self.assertEqual(m.size(), 0x180000000)
- finally:
- m.close()
# Issue 11277: mmap() with large (~4GB) sparse files crashes on OS X.
@@ -695,11 +703,8 @@ class LargeMmapTests(unittest.TestCase):
start = boundary - len(tail) // 2
end = start + len(tail)
with self._make_test_file(start, tail) as f:
- m = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
- try:
+ with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as m:
self.assertEqual(m[start:end], tail)
- finally:
- m.close()
@unittest.skipUnless(sys.maxsize > _4G, "test cannot run on 32-bit systems")
def test_around_2GB(self):
diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py
index 21eaf3ed721..15836cac93e 100644
--- a/Lib/test/test_module.py
+++ b/Lib/test/test_module.py
@@ -1,6 +1,6 @@
# Test the module type
import unittest
-from test.test_support import run_unittest, gc_collect
+from test.support import run_unittest, gc_collect
import sys
ModuleType = type(sys)
@@ -36,15 +36,15 @@ class ModuleTests(unittest.TestCase):
def test_unicode_docstring(self):
# Unicode docstring
- foo = ModuleType("foo", u"foodoc\u1234")
+ foo = ModuleType("foo", "foodoc\u1234")
self.assertEqual(foo.__name__, "foo")
- self.assertEqual(foo.__doc__, u"foodoc\u1234")
+ self.assertEqual(foo.__doc__, "foodoc\u1234")
self.assertEqual(foo.__dict__,
- {"__name__": "foo", "__doc__": u"foodoc\u1234"})
+ {"__name__": "foo", "__doc__": "foodoc\u1234"})
def test_reinit(self):
# Reinitialization should not replace the __dict__
- foo = ModuleType("foo", u"foodoc\u1234")
+ foo = ModuleType("foo", "foodoc\u1234")
foo.bar = 42
d = foo.__dict__
foo.__init__("foo", "foodoc")
diff --git a/Lib/test/test_modulefinder.py b/Lib/test/test_modulefinder.py
index e71d1e0aeb6..a1842178df1 100644
--- a/Lib/test/test_modulefinder.py
+++ b/Lib/test/test_modulefinder.py
@@ -4,17 +4,10 @@ import unittest
import distutils.dir_util
import tempfile
-from test import test_support
-
-try: set
-except NameError: from sets import Set as set
+from test import support
import modulefinder
-# Note: To test modulefinder with Python 2.2, sets.py and
-# modulefinder.py must be available - they are not in the standard
-# library.
-
TEST_DIR = tempfile.mkdtemp()
TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)]
@@ -65,7 +58,7 @@ b/__init__.py
package_test = [
"a.module",
["a", "a.b", "a.c", "a.module", "mymodule", "sys"],
- ["blahblah"], [],
+ ["blahblah", "c"], [],
"""\
mymodule.py
a/__init__.py
@@ -87,8 +80,8 @@ absolute_import_test = [
"a.module",
["a", "a.module",
"b", "b.x", "b.y", "b.z",
- "__future__", "sys", "exceptions"],
- ["blahblah"], [],
+ "__future__", "sys", "gc"],
+ ["blahblah", "z"], [],
"""\
mymodule.py
a/__init__.py
@@ -96,11 +89,11 @@ a/module.py
from __future__ import absolute_import
import sys # sys
import blahblah # fails
- import exceptions # exceptions
+ import gc # gc
import b.x # b.x
from b import y # b.y
from b.z import * # b.z.*
-a/exceptions.py
+a/gc.py
a/sys.py
import mymodule
a/b/__init__.py
@@ -123,7 +116,7 @@ relative_import_test = [
"a.b.c", "a.b.c.moduleC",
"a.b.c.d", "a.b.c.e",
"a.b.x",
- "exceptions"],
+ "gc"],
[], [],
"""\
mymodule.py
@@ -131,8 +124,8 @@ a/__init__.py
from .b import y, z # a.b.y, a.b.z
a/module.py
from __future__ import absolute_import # __future__
- import exceptions # exceptions
-a/exceptions.py
+ import gc # gc
+a/gc.py
a/sys.py
a/b/__init__.py
from ..b import x # a.b.x
@@ -170,7 +163,7 @@ a/__init__.py
a/another.py
a/module.py
from .b import y, z # a.b.y, a.b.z
-a/exceptions.py
+a/gc.py
a/sys.py
a/b/__init__.py
from .c import moduleC # a.b.c.moduleC
@@ -280,7 +273,7 @@ class ModuleFinderTest(unittest.TestCase):
def test_main():
distutils.log.set_threshold(distutils.log.WARN)
- test_support.run_unittest(ModuleFinderTest)
+ support.run_unittest(ModuleFinderTest)
if __name__ == "__main__":
unittest.main()
diff --git a/Lib/test/test_msilib.py b/Lib/test/test_msilib.py
index 5d5b0c48fea..ccdaec76ede 100644
--- a/Lib/test/test_msilib.py
+++ b/Lib/test/test_msilib.py
@@ -1,7 +1,7 @@
""" Test suite for the code in msilib """
import unittest
import os
-from test_support import run_unittest, import_module
+from test.support import run_unittest, import_module
msilib = import_module('msilib')
class Test_make_id(unittest.TestCase):
diff --git a/Lib/test/test_multibytecodec.py b/Lib/test/test_multibytecodec.py
index 5e86ca2aae8..86c68dcd9a6 100644
--- a/Lib/test/test_multibytecodec.py
+++ b/Lib/test/test_multibytecodec.py
@@ -1,12 +1,12 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_multibytecodec.py
# Unit test for multibytecodec itself
#
-from test import test_support
-from test.test_support import TESTFN
-import unittest, StringIO, codecs, sys, os
+from test import support
+from test.support import TESTFN
+import unittest, io, codecs, sys, os
import _multibytecodec
ALL_CJKENCODINGS = [
@@ -30,25 +30,28 @@ class Test_MultibyteCodec(unittest.TestCase):
def test_nullcoding(self):
for enc in ALL_CJKENCODINGS:
- self.assertEqual(''.decode(enc), u'')
- self.assertEqual(unicode('', enc), u'')
- self.assertEqual(u''.encode(enc), '')
+ self.assertEqual(b''.decode(enc), '')
+ self.assertEqual(str(b'', enc), '')
+ self.assertEqual(''.encode(enc), b'')
def test_str_decode(self):
for enc in ALL_CJKENCODINGS:
- self.assertEqual('abcd'.encode(enc), 'abcd')
+ self.assertEqual('abcd'.encode(enc), b'abcd')
def test_errorcallback_longindex(self):
dec = codecs.getdecoder('euc-kr')
- myreplace = lambda exc: (u'', sys.maxint+1)
+ myreplace = lambda exc: ('', sys.maxsize+1)
codecs.register_error('test.cjktest', myreplace)
self.assertRaises(IndexError, dec,
- 'apple\x92ham\x93spam', 'test.cjktest')
+ b'apple\x92ham\x93spam', 'test.cjktest')
def test_codingspec(self):
- for enc in ALL_CJKENCODINGS:
- code = '# coding: {}\n'.format(enc)
- exec code
+ try:
+ for enc in ALL_CJKENCODINGS:
+ code = '# coding: {}\n'.format(enc)
+ exec(code)
+ finally:
+ support.unlink(TESTFN)
def test_init_segfault(self):
# bug #3305: this used to segfault
@@ -57,20 +60,24 @@ class Test_MultibyteCodec(unittest.TestCase):
self.assertRaises(AttributeError,
_multibytecodec.MultibyteStreamWriter, None)
+ def test_decode_unicode(self):
+ # Trying to decode an unicode string should raise a TypeError
+ for enc in ALL_CJKENCODINGS:
+ self.assertRaises(TypeError, codecs.getdecoder(enc), "")
class Test_IncrementalEncoder(unittest.TestCase):
def test_stateless(self):
# cp949 encoder isn't stateful at all.
encoder = codecs.getincrementalencoder('cp949')()
- self.assertEqual(encoder.encode(u'\ud30c\uc774\uc36c \ub9c8\uc744'),
- '\xc6\xc4\xc0\xcc\xbd\xe3 \xb8\xb6\xc0\xbb')
+ self.assertEqual(encoder.encode('\ud30c\uc774\uc36c \ub9c8\uc744'),
+ b'\xc6\xc4\xc0\xcc\xbd\xe3 \xb8\xb6\xc0\xbb')
self.assertEqual(encoder.reset(), None)
- self.assertEqual(encoder.encode(u'\u2606\u223c\u2606', True),
- '\xa1\xd9\xa1\xad\xa1\xd9')
+ self.assertEqual(encoder.encode('\u2606\u223c\u2606', True),
+ b'\xa1\xd9\xa1\xad\xa1\xd9')
self.assertEqual(encoder.reset(), None)
- self.assertEqual(encoder.encode(u'', True), '')
- self.assertEqual(encoder.encode(u'', False), '')
+ self.assertEqual(encoder.encode('', True), b'')
+ self.assertEqual(encoder.encode('', False), b'')
self.assertEqual(encoder.reset(), None)
def test_stateful(self):
@@ -80,165 +87,177 @@ class Test_IncrementalEncoder(unittest.TestCase):
# U+0300 => ABDC
encoder = codecs.getincrementalencoder('jisx0213')()
- self.assertEqual(encoder.encode(u'\u00e6\u0300'), '\xab\xc4')
- self.assertEqual(encoder.encode(u'\u00e6'), '')
- self.assertEqual(encoder.encode(u'\u0300'), '\xab\xc4')
- self.assertEqual(encoder.encode(u'\u00e6', True), '\xa9\xdc')
+ self.assertEqual(encoder.encode('\u00e6\u0300'), b'\xab\xc4')
+ self.assertEqual(encoder.encode('\u00e6'), b'')
+ self.assertEqual(encoder.encode('\u0300'), b'\xab\xc4')
+ self.assertEqual(encoder.encode('\u00e6', True), b'\xa9\xdc')
self.assertEqual(encoder.reset(), None)
- self.assertEqual(encoder.encode(u'\u0300'), '\xab\xdc')
+ self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc')
- self.assertEqual(encoder.encode(u'\u00e6'), '')
- self.assertEqual(encoder.encode('', True), '\xa9\xdc')
- self.assertEqual(encoder.encode('', True), '')
+ self.assertEqual(encoder.encode('\u00e6'), b'')
+ self.assertEqual(encoder.encode('', True), b'\xa9\xdc')
+ self.assertEqual(encoder.encode('', True), b'')
def test_stateful_keep_buffer(self):
encoder = codecs.getincrementalencoder('jisx0213')()
- self.assertEqual(encoder.encode(u'\u00e6'), '')
- self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
- self.assertEqual(encoder.encode(u'\u0300\u00e6'), '\xab\xc4')
- self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
+ self.assertEqual(encoder.encode('\u00e6'), b'')
+ self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
+ self.assertEqual(encoder.encode('\u0300\u00e6'), b'\xab\xc4')
+ self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
self.assertEqual(encoder.reset(), None)
- self.assertEqual(encoder.encode(u'\u0300'), '\xab\xdc')
- self.assertEqual(encoder.encode(u'\u00e6'), '')
- self.assertRaises(UnicodeEncodeError, encoder.encode, u'\u0123')
- self.assertEqual(encoder.encode(u'', True), '\xa9\xdc')
+ self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc')
+ self.assertEqual(encoder.encode('\u00e6'), b'')
+ self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
+ self.assertEqual(encoder.encode('', True), b'\xa9\xdc')
def test_issue5640(self):
encoder = codecs.getincrementalencoder('shift-jis')('backslashreplace')
- self.assertEqual(encoder.encode(u'\xff'), b'\\xff')
- self.assertEqual(encoder.encode(u'\n'), b'\n')
+ self.assertEqual(encoder.encode('\xff'), b'\\xff')
+ self.assertEqual(encoder.encode('\n'), b'\n')
class Test_IncrementalDecoder(unittest.TestCase):
def test_dbcs(self):
# cp949 decoder is simple with only 1 or 2 bytes sequences.
decoder = codecs.getincrementaldecoder('cp949')()
- self.assertEqual(decoder.decode('\xc6\xc4\xc0\xcc\xbd'),
- u'\ud30c\uc774')
- self.assertEqual(decoder.decode('\xe3 \xb8\xb6\xc0\xbb'),
- u'\uc36c \ub9c8\uc744')
- self.assertEqual(decoder.decode(''), u'')
+ self.assertEqual(decoder.decode(b'\xc6\xc4\xc0\xcc\xbd'),
+ '\ud30c\uc774')
+ self.assertEqual(decoder.decode(b'\xe3 \xb8\xb6\xc0\xbb'),
+ '\uc36c \ub9c8\uc744')
+ self.assertEqual(decoder.decode(b''), '')
def test_dbcs_keep_buffer(self):
decoder = codecs.getincrementaldecoder('cp949')()
- self.assertEqual(decoder.decode('\xc6\xc4\xc0'), u'\ud30c')
- self.assertRaises(UnicodeDecodeError, decoder.decode, '', True)
- self.assertEqual(decoder.decode('\xcc'), u'\uc774')
+ self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c')
+ self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True)
+ self.assertEqual(decoder.decode(b'\xcc'), '\uc774')
- self.assertEqual(decoder.decode('\xc6\xc4\xc0'), u'\ud30c')
- self.assertRaises(UnicodeDecodeError, decoder.decode, '\xcc\xbd', True)
- self.assertEqual(decoder.decode('\xcc'), u'\uc774')
+ self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c')
+ self.assertRaises(UnicodeDecodeError, decoder.decode,
+ b'\xcc\xbd', True)
+ self.assertEqual(decoder.decode(b'\xcc'), '\uc774')
def test_iso2022(self):
decoder = codecs.getincrementaldecoder('iso2022-jp')()
- ESC = '\x1b'
- self.assertEqual(decoder.decode(ESC + '('), u'')
- self.assertEqual(decoder.decode('B', True), u'')
- self.assertEqual(decoder.decode(ESC + '$'), u'')
- self.assertEqual(decoder.decode('B@$'), u'\u4e16')
- self.assertEqual(decoder.decode('@$@'), u'\u4e16')
- self.assertEqual(decoder.decode('$', True), u'\u4e16')
+ ESC = b'\x1b'
+ self.assertEqual(decoder.decode(ESC + b'('), '')
+ self.assertEqual(decoder.decode(b'B', True), '')
+ self.assertEqual(decoder.decode(ESC + b'$'), '')
+ self.assertEqual(decoder.decode(b'B@$'), '\u4e16')
+ self.assertEqual(decoder.decode(b'@$@'), '\u4e16')
+ self.assertEqual(decoder.decode(b'$', True), '\u4e16')
self.assertEqual(decoder.reset(), None)
- self.assertEqual(decoder.decode('@$'), u'@$')
- self.assertEqual(decoder.decode(ESC + '$'), u'')
- self.assertRaises(UnicodeDecodeError, decoder.decode, '', True)
- self.assertEqual(decoder.decode('B@$'), u'\u4e16')
+ self.assertEqual(decoder.decode(b'@$'), '@$')
+ self.assertEqual(decoder.decode(ESC + b'$'), '')
+ self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True)
+ self.assertEqual(decoder.decode(b'B@$'), '\u4e16')
+
+ def test_decode_unicode(self):
+ # Trying to decode an unicode string should raise a TypeError
+ for enc in ALL_CJKENCODINGS:
+ decoder = codecs.getincrementaldecoder(enc)()
+ self.assertRaises(TypeError, decoder.decode, "")
class Test_StreamReader(unittest.TestCase):
def test_bug1728403(self):
try:
- open(TESTFN, 'w').write('\xa1')
+ f = open(TESTFN, 'wb')
+ try:
+ f.write(b'\xa1')
+ finally:
+ f.close()
f = codecs.open(TESTFN, encoding='cp949')
- self.assertRaises(UnicodeDecodeError, f.read, 2)
+ try:
+ self.assertRaises(UnicodeDecodeError, f.read, 2)
+ finally:
+ f.close()
finally:
- try: f.close()
- except: pass
- os.unlink(TESTFN)
+ support.unlink(TESTFN)
class Test_StreamWriter(unittest.TestCase):
- if len(u'\U00012345') == 2: # UCS2
+ if len('\U00012345') == 2: # UCS2
def test_gb18030(self):
- s = StringIO.StringIO()
+ s= io.BytesIO()
c = codecs.getwriter('gb18030')(s)
- c.write(u'123')
- self.assertEqual(s.getvalue(), '123')
- c.write(u'\U00012345')
- self.assertEqual(s.getvalue(), '123\x907\x959')
- c.write(u'\U00012345'[0])
- self.assertEqual(s.getvalue(), '123\x907\x959')
- c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac')
+ c.write('123')
+ self.assertEqual(s.getvalue(), b'123')
+ c.write('\U00012345')
+ self.assertEqual(s.getvalue(), b'123\x907\x959')
+ c.write('\U00012345'[0])
+ self.assertEqual(s.getvalue(), b'123\x907\x959')
+ c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
self.assertEqual(s.getvalue(),
- '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
- c.write(u'\U00012345'[0])
+ b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
+ c.write('\U00012345'[0])
self.assertEqual(s.getvalue(),
- '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
+ b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
self.assertRaises(UnicodeError, c.reset)
self.assertEqual(s.getvalue(),
- '123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
+ b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
def test_utf_8(self):
- s= StringIO.StringIO()
+ s= io.BytesIO()
c = codecs.getwriter('utf-8')(s)
- c.write(u'123')
- self.assertEqual(s.getvalue(), '123')
- c.write(u'\U00012345')
- self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85')
+ c.write('123')
+ self.assertEqual(s.getvalue(), b'123')
+ c.write('\U00012345')
+ self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
# Python utf-8 codec can't buffer surrogate pairs yet.
if 0:
- c.write(u'\U00012345'[0])
- self.assertEqual(s.getvalue(), '123\xf0\x92\x8d\x85')
- c.write(u'\U00012345'[1] + u'\U00012345' + u'\uac00\u00ac')
+ c.write('\U00012345'[0])
+ self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
+ c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
self.assertEqual(s.getvalue(),
- '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
- '\xea\xb0\x80\xc2\xac')
- c.write(u'\U00012345'[0])
+ b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
+ b'\xea\xb0\x80\xc2\xac')
+ c.write('\U00012345'[0])
self.assertEqual(s.getvalue(),
- '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
- '\xea\xb0\x80\xc2\xac')
+ b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
+ b'\xea\xb0\x80\xc2\xac')
c.reset()
self.assertEqual(s.getvalue(),
- '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
- '\xea\xb0\x80\xc2\xac\xed\xa0\x88')
- c.write(u'\U00012345'[1])
+ b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
+ b'\xea\xb0\x80\xc2\xac\xed\xa0\x88')
+ c.write('\U00012345'[1])
self.assertEqual(s.getvalue(),
- '123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
- '\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85')
+ b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
+ b'\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85')
else: # UCS4
pass
def test_streamwriter_strwrite(self):
- s = StringIO.StringIO()
+ s = io.BytesIO()
wr = codecs.getwriter('gb18030')(s)
wr.write('abcd')
- self.assertEqual(s.getvalue(), 'abcd')
+ self.assertEqual(s.getvalue(), b'abcd')
class Test_ISO2022(unittest.TestCase):
def test_g2(self):
- iso2022jp2 = '\x1b(B:hu4:unit\x1b.A\x1bNi de famille'
- uni = u':hu4:unit\xe9 de famille'
+ iso2022jp2 = b'\x1b(B:hu4:unit\x1b.A\x1bNi de famille'
+ uni = ':hu4:unit\xe9 de famille'
self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni)
def test_iso2022_jp_g0(self):
- self.assertNotIn('\x0e', u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
+ self.assertNotIn(b'\x0e', '\N{SOFT HYPHEN}'.encode('iso-2022-jp-2'))
for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'):
- e = u'\u3406'.encode(encoding)
- self.assertFalse(filter(lambda x: x >= '\x80', e))
+ e = '\u3406'.encode(encoding)
+ self.assertFalse(any(x > 0x80 for x in e))
def test_bug1572832(self):
if sys.maxunicode >= 0x10000:
- myunichr = unichr
+ myunichr = chr
else:
- myunichr = lambda x: unichr(0xD7C0+(x>>10)) + unichr(0xDC00+(x&0x3FF))
+ myunichr = lambda x: chr(0xD7C0+(x>>10)) + chr(0xDC00+(x&0x3FF))
- for x in xrange(0x10000, 0x110000):
+ for x in range(0x10000, 0x110000):
# Any ISO 2022 codec will cause the segfault
myunichr(x).encode('iso_2022_jp', 'ignore')
class TestStateful(unittest.TestCase):
- text = u'\u4E16\u4E16'
+ text = '\u4E16\u4E16'
encoding = 'iso-2022-jp'
expected = b'\x1b$B@$@$'
expected_reset = b'\x1b$B@$@$\x1b(B'
@@ -262,13 +281,13 @@ class TestStateful(unittest.TestCase):
self.assertEqual(output, self.expected_reset)
class TestHZStateful(TestStateful):
- text = u'\u804a\u804a'
+ text = '\u804a\u804a'
encoding = 'hz'
expected = b'~{ADAD'
expected_reset = b'~{ADAD~}'
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_multibytecodec_support.py b/Lib/test/test_multibytecodec_support.py
index 52a2e503722..ef63b6934d5 100644
--- a/Lib/test/test_multibytecodec_support.py
+++ b/Lib/test/test_multibytecodec_support.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# test_multibytecodec_support.py
# Common Unittest Routines for CJK codecs
@@ -9,20 +9,20 @@ import os
import re
import sys
import unittest
-from httplib import HTTPException
-from test import test_support
-from StringIO import StringIO
+from http.client import HTTPException
+from test import support
+from io import BytesIO
class TestBase:
encoding = '' # codec name
codec = None # codec tuple (with 4 elements)
- tstring = '' # string to test StreamReader
+ tstring = None # must set. 2 strings to test StreamReader
codectests = None # must set. codec test tuple
roundtriptest = 1 # set if roundtrip is possible with unicode
has_iso10646 = 0 # set if this encoding contains whole iso10646 map
xmlcharnametest = None # string to test xmlcharrefreplace
- unmappedunicode = u'\udeee' # a unicode codepoint that is not mapped.
+ unmappedunicode = '\udeee' # a unicode codepoint that is not mapped.
def setUp(self):
if self.codec is None:
@@ -35,8 +35,14 @@ class TestBase:
self.incrementaldecoder = self.codec.incrementaldecoder
def test_chunkcoding(self):
- for native, utf8 in zip(*[StringIO(f).readlines()
- for f in self.tstring]):
+ tstring_lines = []
+ for b in self.tstring:
+ lines = b.split(b"\n")
+ last = lines.pop()
+ assert last == b""
+ lines = [line + b"\n" for line in lines]
+ tstring_lines.append(lines)
+ for native, utf8 in zip(*tstring_lines):
u = self.decode(native)[0]
self.assertEqual(u, utf8.decode('utf-8'))
if self.roundtriptest:
@@ -51,15 +57,15 @@ class TestBase:
if expected:
result = func(source, scheme)[0]
if func is self.decode:
- self.assertTrue(type(result) is unicode, type(result))
+ self.assertTrue(type(result) is str, type(result))
self.assertEqual(result, expected,
- '%r.decode(%r, %r)=%r != %r'
+ '%a.decode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
self.assertTrue(type(result) is bytes, type(result))
self.assertEqual(result, expected,
- '%r.encode(%r, %r)=%r != %r'
+ '%a.encode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
@@ -69,17 +75,17 @@ class TestBase:
if self.has_iso10646:
return
- s = u"\u0b13\u0b23\u0b60 nd eggs"
+ s = "\u0b13\u0b23\u0b60 nd eggs"
self.assertEqual(
self.encode(s, "xmlcharrefreplace")[0],
- "&#2835;&#2851;&#2912; nd eggs"
+ b"&#2835;&#2851;&#2912; nd eggs"
)
def test_customreplace_encode(self):
if self.has_iso10646:
return
- from htmlentitydefs import codepoint2name
+ from html.entities import codepoint2name
def xmlcharnamereplace(exc):
if not isinstance(exc, UnicodeEncodeError):
@@ -87,18 +93,18 @@ class TestBase:
l = []
for c in exc.object[exc.start:exc.end]:
if ord(c) in codepoint2name:
- l.append(u"&%s;" % codepoint2name[ord(c)])
+ l.append("&%s;" % codepoint2name[ord(c)])
else:
- l.append(u"&#%d;" % ord(c))
- return (u"".join(l), exc.end)
+ l.append("&#%d;" % ord(c))
+ return ("".join(l), exc.end)
codecs.register_error("test.xmlcharnamereplace", xmlcharnamereplace)
if self.xmlcharnametest:
sin, sout = self.xmlcharnametest
else:
- sin = u"\xab\u211c\xbb = \u2329\u1234\u232a"
- sout = "&laquo;&real;&raquo; = &lang;&#4660;&rang;"
+ sin = "\xab\u211c\xbb = \u2329\u1234\u232a"
+ sout = b"&laquo;&real;&raquo; = &lang;&#4660;&rang;"
self.assertEqual(self.encode(sin,
"test.xmlcharnamereplace")[0], sout)
@@ -107,26 +113,26 @@ class TestBase:
return (ret, exc.end)
codecs.register_error("test.cjktest", myreplace)
- for ret in ([1, 2, 3], [], None, object(), 'string', ''):
+ for ret in ([1, 2, 3], [], None, object(), b'string', b''):
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_callback_long_index(self):
def myreplace(exc):
- return (u'x', long(exc.end))
+ return ('x', int(exc.end))
codecs.register_error("test.cjktest", myreplace)
- self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
- 'test.cjktest'), ('abcdxefgh', 9))
+ self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
+ 'test.cjktest'), (b'abcdxefgh', 9))
def myreplace(exc):
- return (u'x', sys.maxint + 1)
+ return ('x', sys.maxsize + 1)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_callback_None_index(self):
def myreplace(exc):
- return (u'x', None)
+ return ('x', None)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
'test.cjktest')
@@ -135,35 +141,35 @@ class TestBase:
def myreplace(exc):
if myreplace.limit > 0:
myreplace.limit -= 1
- return (u'REPLACED', 0)
+ return ('REPLACED', 0)
else:
- return (u'TERMINAL', exc.end)
+ return ('TERMINAL', exc.end)
myreplace.limit = 3
codecs.register_error("test.cjktest", myreplace)
- self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
+ self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
'test.cjktest'),
- ('abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9))
+ (b'abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9))
def test_callback_forward_index(self):
def myreplace(exc):
- return (u'REPLACED', exc.end + 2)
+ return ('REPLACED', exc.end + 2)
codecs.register_error("test.cjktest", myreplace)
- self.assertEqual(self.encode(u'abcd' + self.unmappedunicode + u'efgh',
- 'test.cjktest'), ('abcdREPLACEDgh', 9))
+ self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
+ 'test.cjktest'), (b'abcdREPLACEDgh', 9))
def test_callback_index_outofbound(self):
def myreplace(exc):
- return (u'TERM', 100)
+ return ('TERM', 100)
codecs.register_error("test.cjktest", myreplace)
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
'test.cjktest')
def test_incrementalencoder(self):
UTF8Reader = codecs.getreader('utf-8')
- for sizehint in [None] + range(1, 33) + \
+ for sizehint in [None] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
- istream = UTF8Reader(StringIO(self.tstring[1]))
- ostream = StringIO()
+ istream = UTF8Reader(BytesIO(self.tstring[1]))
+ ostream = BytesIO()
encoder = self.incrementalencoder()
while 1:
if sizehint is not None:
@@ -180,10 +186,10 @@ class TestBase:
def test_incrementaldecoder(self):
UTF8Writer = codecs.getwriter('utf-8')
- for sizehint in [None, -1] + range(1, 33) + \
+ for sizehint in [None, -1] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
- istream = StringIO(self.tstring[0])
- ostream = UTF8Writer(StringIO())
+ istream = BytesIO(self.tstring[0])
+ ostream = UTF8Writer(BytesIO())
decoder = self.incrementaldecoder()
while 1:
data = istream.read(sizehint)
@@ -202,26 +208,26 @@ class TestBase:
self.assertRaises(UnicodeEncodeError, e.encode, inv, True)
e.errors = 'ignore'
- self.assertEqual(e.encode(inv, True), '')
+ self.assertEqual(e.encode(inv, True), b'')
e.reset()
def tempreplace(exc):
- return (u'called', exc.end)
+ return ('called', exc.end)
codecs.register_error('test.incremental_error_callback', tempreplace)
e.errors = 'test.incremental_error_callback'
- self.assertEqual(e.encode(inv, True), 'called')
+ self.assertEqual(e.encode(inv, True), b'called')
# again
e.errors = 'ignore'
- self.assertEqual(e.encode(inv, True), '')
+ self.assertEqual(e.encode(inv, True), b'')
def test_streamreader(self):
UTF8Writer = codecs.getwriter('utf-8')
for name in ["read", "readline", "readlines"]:
- for sizehint in [None, -1] + range(1, 33) + \
+ for sizehint in [None, -1] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
- istream = self.reader(StringIO(self.tstring[0]))
- ostream = UTF8Writer(StringIO())
+ istream = self.reader(BytesIO(self.tstring[0]))
+ ostream = UTF8Writer(BytesIO())
func = getattr(istream, name)
while 1:
data = func(sizehint)
@@ -238,10 +244,10 @@ class TestBase:
readfuncs = ('read', 'readline', 'readlines')
UTF8Reader = codecs.getreader('utf-8')
for name in readfuncs:
- for sizehint in [None] + range(1, 33) + \
+ for sizehint in [None] + list(range(1, 33)) + \
[64, 128, 256, 512, 1024]:
- istream = UTF8Reader(StringIO(self.tstring[1]))
- ostream = self.writer(StringIO())
+ istream = UTF8Reader(BytesIO(self.tstring[1]))
+ ostream = self.writer(BytesIO())
func = getattr(istream, name)
while 1:
if sizehint is not None:
@@ -258,6 +264,22 @@ class TestBase:
self.assertEqual(ostream.getvalue(), self.tstring[0])
+if len('\U00012345') == 2: # ucs2 build
+ _unichr = chr
+ def chr(v):
+ if v >= 0x10000:
+ return _unichr(0xd800 + ((v - 0x10000) >> 10)) + \
+ _unichr(0xdc00 + ((v - 0x10000) & 0x3ff))
+ else:
+ return _unichr(v)
+ _ord = ord
+ def ord(c):
+ if len(c) == 2:
+ return 0x10000 + ((_ord(c[0]) - 0xd800) << 10) + \
+ (ord(c[1]) - 0xdc00)
+ else:
+ return _ord(c)
+
class TestBase_Mapping(unittest.TestCase):
pass_enctest = []
pass_dectest = []
@@ -272,7 +294,7 @@ class TestBase_Mapping(unittest.TestCase):
self.skipTest("Could not retrieve "+self.mapfileurl)
def open_mapping_file(self):
- return test_support.open_urlresource(self.mapfileurl)
+ return support.open_urlresource(self.mapfileurl)
def test_mapping_file(self):
if self.mapfileurl.endswith('.xml'):
@@ -281,8 +303,7 @@ class TestBase_Mapping(unittest.TestCase):
self._test_mapping_file_plain()
def _test_mapping_file_plain(self):
- _unichr = lambda c: eval("u'\\U%08x'" % int(c, 16))
- unichrs = lambda s: u''.join(_unichr(c) for c in s.split('+'))
+ unichrs = lambda s: ''.join(map(chr, map(eval, s.split('+'))))
urt_wa = {}
with self.open_mapping_file() as f:
@@ -295,20 +316,20 @@ class TestBase_Mapping(unittest.TestCase):
csetval = eval(data[0])
if csetval <= 0x7F:
- csetch = chr(csetval & 0xff)
+ csetch = bytes([csetval & 0xff])
elif csetval >= 0x1000000:
- csetch = chr(csetval >> 24) + chr((csetval >> 16) & 0xff) + \
- chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
+ csetch = bytes([(csetval >> 24), ((csetval >> 16) & 0xff),
+ ((csetval >> 8) & 0xff), (csetval & 0xff)])
elif csetval >= 0x10000:
- csetch = chr(csetval >> 16) + \
- chr((csetval >> 8) & 0xff) + chr(csetval & 0xff)
+ csetch = bytes([(csetval >> 16), ((csetval >> 8) & 0xff),
+ (csetval & 0xff)])
elif csetval >= 0x100:
- csetch = chr(csetval >> 8) + chr(csetval & 0xff)
+ csetch = bytes([(csetval >> 8), (csetval & 0xff)])
else:
continue
unich = unichrs(data[1])
- if unich == u'\ufffd' or unich in urt_wa:
+ if ord(unich) == 0xfffd or unich in urt_wa:
continue
urt_wa[unich] = csetch
@@ -319,8 +340,8 @@ class TestBase_Mapping(unittest.TestCase):
ucmdata = f.read()
uc = re.findall('<a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>', ucmdata)
for uni, coded in uc:
- unich = unichr(int(uni, 16))
- codech = ''.join(chr(int(c, 16)) for c in coded.split())
+ unich = chr(int(uni, 16))
+ codech = bytes(int(c, 16) for c in coded.split())
self._testpoint(codech, unich)
def test_mapping_supplemental(self):
@@ -329,17 +350,9 @@ class TestBase_Mapping(unittest.TestCase):
def _testpoint(self, csetch, unich):
if (csetch, unich) not in self.pass_enctest:
- try:
- self.assertEqual(unich.encode(self.encoding), csetch)
- except UnicodeError, exc:
- self.fail('Encoding failed while testing %s -> %s: %s' % (
- repr(unich), repr(csetch), exc.reason))
+ self.assertEqual(unich.encode(self.encoding), csetch)
if (csetch, unich) not in self.pass_dectest:
- try:
- self.assertEqual(csetch.decode(self.encoding), unich)
- except UnicodeError, exc:
- self.fail('Decoding failed while testing %s -> %s: %s' % (
- repr(csetch), repr(unich), exc.reason))
+ self.assertEqual(str(csetch, self.encoding), unich)
def test_errorhandle(self):
for source, scheme, expected in self.codectests:
@@ -350,16 +363,16 @@ class TestBase_Mapping(unittest.TestCase):
if expected:
if isinstance(source, bytes):
result = func(self.encoding, scheme)
- self.assertTrue(type(result) is unicode, type(result))
+ self.assertTrue(type(result) is str, type(result))
self.assertEqual(result, expected,
- '%r.decode(%r, %r)=%r != %r'
+ '%a.decode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
result = func(self.encoding, scheme)
self.assertTrue(type(result) is bytes, type(result))
self.assertEqual(result, expected,
- '%r.encode(%r, %r)=%r != %r'
+ '%a.encode(%r, %r)=%a != %a'
% (source, self.encoding, scheme, result,
expected))
else:
diff --git a/Lib/test/test_multifile.py b/Lib/test/test_multifile.py
deleted file mode 100644
index 043075b72f2..00000000000
--- a/Lib/test/test_multifile.py
+++ /dev/null
@@ -1,67 +0,0 @@
-from test import test_support
-mimetools = test_support.import_module('mimetools', deprecated=True)
-multifile = test_support.import_module('multifile', deprecated=True)
-import cStringIO
-
-msg = """Mime-Version: 1.0
-Content-Type: multipart/mixed;
- boundary="=====================_590453667==_"
-X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7]
-
---=====================_590453667==_
-Content-Type: multipart/alternative;
- boundary="=====================_590453677==_.ALT"
-
---=====================_590453677==_.ALT
-Content-Type: text/plain; charset="us-ascii"; format=flowed
-
-test A
---=====================_590453677==_.ALT
-Content-Type: text/html; charset="us-ascii"
-
-<html>
-<b>test B</font></b></html>
-
---=====================_590453677==_.ALT--
-
---=====================_590453667==_
-Content-Type: text/plain; charset="us-ascii"
-Content-Disposition: attachment; filename="att.txt"
-
-Attached Content.
-Attached Content.
-Attached Content.
-Attached Content.
-
---=====================_590453667==_--
-
-"""
-
-def getMIMEMsg(mf):
- global boundaries, linecount
- msg = mimetools.Message(mf)
-
- #print "TYPE: %s" % msg.gettype()
- if msg.getmaintype() == 'multipart':
- boundary = msg.getparam("boundary")
- boundaries += 1
-
- mf.push(boundary)
- while mf.next():
- getMIMEMsg(mf)
- mf.pop()
- else:
- lines = mf.readlines()
- linecount += len(lines)
-
-def test_main():
- global boundaries, linecount
- boundaries = 0
- linecount = 0
- f = cStringIO.StringIO(msg)
- getMIMEMsg(multifile.MultiFile(f))
- assert boundaries == 2
- assert linecount == 9
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py
index 15870570db0..ab6d36a0f09 100644
--- a/Lib/test/test_multiprocessing.py
+++ b/Lib/test/test_multiprocessing.py
@@ -1,33 +1,35 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Unit tests for the multiprocessing package
#
import unittest
-import Queue
+import queue as pyqueue
import time
+import io
import sys
import os
import gc
+import errno
import signal
import array
import socket
import random
import logging
-import errno
+import test.support
import test.script_helper
-from test import test_support
-from StringIO import StringIO
-_multiprocessing = test_support.import_module('_multiprocessing')
-# import threading after _multiprocessing to raise a more relevant error
+
+
+# Skip tests if _multiprocessing wasn't built.
+_multiprocessing = test.support.import_module('_multiprocessing')
+# Skip tests if sem_open implementation is broken.
+test.support.import_module('multiprocessing.synchronize')
+# import threading after _multiprocessing to raise a more revelant error
# message: "No module named _multiprocessing". _multiprocessing is not compiled
# without thread support.
import threading
-# Work around broken sem_open implementations
-test_support.import_module('multiprocessing.synchronize')
-
import multiprocessing.dummy
import multiprocessing.connection
import multiprocessing.managers
@@ -57,7 +59,8 @@ except ImportError:
#
#
-latin = str
+def latin(s):
+ return s.encode('latin')
#
# Constants
@@ -326,36 +329,6 @@ class _TestProcess(BaseTestCase):
]
self.assertEqual(result, expected)
- @classmethod
- def _test_sys_exit(cls, reason, testfn):
- sys.stderr = open(testfn, 'w')
- sys.exit(reason)
-
- def test_sys_exit(self):
- # See Issue 13854
- if self.TYPE == 'threads':
- return
-
- testfn = test_support.TESTFN
- self.addCleanup(test_support.unlink, testfn)
-
- for reason, code in (([1, 2, 3], 1), ('ignore this', 0)):
- p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
- p.daemon = True
- p.start()
- p.join(5)
- self.assertEqual(p.exitcode, code)
-
- with open(testfn, 'r') as f:
- self.assertEqual(f.read().rstrip(), str(reason))
-
- for reason in (True, False, 8):
- p = self.Process(target=sys.exit, args=(reason,))
- p.daemon = True
- p.start()
- p.join(5)
- self.assertEqual(p.exitcode, reason)
-
#
#
#
@@ -395,6 +368,59 @@ class _TestSubclassingProcess(BaseTestCase):
uppercaser.stop()
uppercaser.join()
+ def test_stderr_flush(self):
+ # sys.stderr is flushed at process shutdown (issue #13812)
+ if self.TYPE == "threads":
+ return
+
+ testfn = test.support.TESTFN
+ self.addCleanup(test.support.unlink, testfn)
+ proc = self.Process(target=self._test_stderr_flush, args=(testfn,))
+ proc.start()
+ proc.join()
+ with open(testfn, 'r') as f:
+ err = f.read()
+ # The whole traceback was printed
+ self.assertIn("ZeroDivisionError", err)
+ self.assertIn("test_multiprocessing.py", err)
+ self.assertIn("1/0 # MARKER", err)
+
+ @classmethod
+ def _test_stderr_flush(cls, testfn):
+ sys.stderr = open(testfn, 'w')
+ 1/0 # MARKER
+
+
+ @classmethod
+ def _test_sys_exit(cls, reason, testfn):
+ sys.stderr = open(testfn, 'w')
+ sys.exit(reason)
+
+ def test_sys_exit(self):
+ # See Issue 13854
+ if self.TYPE == 'threads':
+ return
+
+ testfn = test.support.TESTFN
+ self.addCleanup(test.support.unlink, testfn)
+
+ for reason, code in (([1, 2, 3], 1), ('ignore this', 0)):
+ p = self.Process(target=self._test_sys_exit, args=(reason, testfn))
+ p.daemon = True
+ p.start()
+ p.join(5)
+ self.assertEqual(p.exitcode, code)
+
+ with open(testfn, 'r') as f:
+ self.assertEqual(f.read().rstrip(), str(reason))
+
+ for reason in (True, False, 8):
+ p = self.Process(target=sys.exit, args=(reason,))
+ p.daemon = True
+ p.start()
+ p.join(5)
+ self.assertEqual(p.exitcode, reason)
+
#
#
#
@@ -454,22 +480,22 @@ class _TestQueue(BaseTestCase):
put = TimingWrapper(queue.put)
put_nowait = TimingWrapper(queue.put_nowait)
- self.assertRaises(Queue.Full, put, 7, False)
+ self.assertRaises(pyqueue.Full, put, 7, False)
self.assertTimingAlmostEqual(put.elapsed, 0)
- self.assertRaises(Queue.Full, put, 7, False, None)
+ self.assertRaises(pyqueue.Full, put, 7, False, None)
self.assertTimingAlmostEqual(put.elapsed, 0)
- self.assertRaises(Queue.Full, put_nowait, 7)
+ self.assertRaises(pyqueue.Full, put_nowait, 7)
self.assertTimingAlmostEqual(put_nowait.elapsed, 0)
- self.assertRaises(Queue.Full, put, 7, True, TIMEOUT1)
+ self.assertRaises(pyqueue.Full, put, 7, True, TIMEOUT1)
self.assertTimingAlmostEqual(put.elapsed, TIMEOUT1)
- self.assertRaises(Queue.Full, put, 7, False, TIMEOUT2)
+ self.assertRaises(pyqueue.Full, put, 7, False, TIMEOUT2)
self.assertTimingAlmostEqual(put.elapsed, 0)
- self.assertRaises(Queue.Full, put, 7, True, timeout=TIMEOUT3)
+ self.assertRaises(pyqueue.Full, put, 7, True, timeout=TIMEOUT3)
self.assertTimingAlmostEqual(put.elapsed, TIMEOUT3)
child_can_start.set()
@@ -522,22 +548,22 @@ class _TestQueue(BaseTestCase):
get = TimingWrapper(queue.get)
get_nowait = TimingWrapper(queue.get_nowait)
- self.assertRaises(Queue.Empty, get, False)
+ self.assertRaises(pyqueue.Empty, get, False)
self.assertTimingAlmostEqual(get.elapsed, 0)
- self.assertRaises(Queue.Empty, get, False, None)
+ self.assertRaises(pyqueue.Empty, get, False, None)
self.assertTimingAlmostEqual(get.elapsed, 0)
- self.assertRaises(Queue.Empty, get_nowait)
+ self.assertRaises(pyqueue.Empty, get_nowait)
self.assertTimingAlmostEqual(get_nowait.elapsed, 0)
- self.assertRaises(Queue.Empty, get, True, TIMEOUT1)
+ self.assertRaises(pyqueue.Empty, get, True, TIMEOUT1)
self.assertTimingAlmostEqual(get.elapsed, TIMEOUT1)
- self.assertRaises(Queue.Empty, get, False, TIMEOUT2)
+ self.assertRaises(pyqueue.Empty, get, False, TIMEOUT2)
self.assertTimingAlmostEqual(get.elapsed, 0)
- self.assertRaises(Queue.Empty, get, timeout=TIMEOUT3)
+ self.assertRaises(pyqueue.Empty, get, timeout=TIMEOUT3)
self.assertTimingAlmostEqual(get.elapsed, TIMEOUT3)
proc.join()
@@ -573,7 +599,7 @@ class _TestQueue(BaseTestCase):
# check that all expected items are in the queue
for i in range(20):
self.assertEqual(queue.get(), i)
- self.assertRaises(Queue.Empty, queue.get, False)
+ self.assertRaises(pyqueue.Empty, queue.get, False)
p.join()
@@ -605,13 +631,13 @@ class _TestQueue(BaseTestCase):
self.skipTest("requires 'queue.task_done()' method")
workers = [self.Process(target=self._test_task_done, args=(queue,))
- for i in xrange(4)]
+ for i in range(4)]
for p in workers:
p.daemon = True
p.start()
- for i in xrange(10):
+ for i in range(10):
queue.put(i)
queue.join()
@@ -786,11 +812,11 @@ class _TestCondition(BaseTestCase):
t.start()
# wait for them all to sleep
- for i in xrange(6):
+ for i in range(6):
sleeping.acquire()
# check they have all timed out
- for i in xrange(6):
+ for i in range(6):
woken.acquire()
self.assertReturnsIfImplemented(0, get_value, woken)
@@ -808,7 +834,7 @@ class _TestCondition(BaseTestCase):
t.start()
# wait for them to all sleep
- for i in xrange(6):
+ for i in range(6):
sleeping.acquire()
# check no process/thread has woken up
@@ -821,7 +847,13 @@ class _TestCondition(BaseTestCase):
cond.release()
# check they have all woken
- time.sleep(DELTA)
+ for i in range(10):
+ try:
+ if get_value(woken) == 6:
+ break
+ except NotImplementedError:
+ break
+ time.sleep(DELTA)
self.assertReturnsIfImplemented(6, get_value, woken)
# check state is not mucked up
@@ -833,7 +865,7 @@ class _TestCondition(BaseTestCase):
cond.acquire()
res = wait(TIMEOUT1)
cond.release()
- self.assertEqual(res, None)
+ self.assertEqual(res, False)
self.assertTimingAlmostEqual(wait.elapsed, TIMEOUT1)
@@ -997,7 +1029,7 @@ class _TestArray(BaseTestCase):
self.assertEqual(len(arr), size)
self.assertEqual(list(arr), [0] * size)
arr[:] = range(10)
- self.assertEqual(list(arr), range(10))
+ self.assertEqual(list(arr), list(range(10)))
del arr
@unittest.skipIf(c_int is None, "requires _ctypes")
@@ -1005,24 +1037,17 @@ class _TestArray(BaseTestCase):
self.test_array(raw=True)
@unittest.skipIf(c_int is None, "requires _ctypes")
- def test_array_accepts_long(self):
- arr = self.Array('i', 10L)
- self.assertEqual(len(arr), 10)
- raw_arr = self.RawArray('i', 10L)
- self.assertEqual(len(raw_arr), 10)
-
- @unittest.skipIf(c_int is None, "requires _ctypes")
def test_getobj_getlock_obj(self):
- arr1 = self.Array('i', range(10))
+ arr1 = self.Array('i', list(range(10)))
lock1 = arr1.get_lock()
obj1 = arr1.get_obj()
- arr2 = self.Array('i', range(10), lock=None)
+ arr2 = self.Array('i', list(range(10)), lock=None)
lock2 = arr2.get_lock()
obj2 = arr2.get_obj()
lock = self.Lock()
- arr3 = self.Array('i', range(10), lock=lock)
+ arr3 = self.Array('i', list(range(10)), lock=lock)
lock3 = arr3.get_lock()
obj3 = arr3.get_obj()
self.assertEqual(lock, lock3)
@@ -1046,14 +1071,14 @@ class _TestContainers(BaseTestCase):
ALLOWED_TYPES = ('manager',)
def test_list(self):
- a = self.list(range(10))
- self.assertEqual(a[:], range(10))
+ a = self.list(list(range(10)))
+ self.assertEqual(a[:], list(range(10)))
b = self.list()
self.assertEqual(b[:], [])
- b.extend(range(5))
- self.assertEqual(b[:], range(5))
+ b.extend(list(range(5)))
+ self.assertEqual(b[:], list(range(5)))
self.assertEqual(b[2], 2)
self.assertEqual(b[2:10], [2,3,4])
@@ -1063,7 +1088,7 @@ class _TestContainers(BaseTestCase):
self.assertEqual(b + [5, 6], [0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 5, 6])
- self.assertEqual(a[:], range(10))
+ self.assertEqual(a[:], list(range(10)))
d = [a, b]
e = self.list(d)
@@ -1078,7 +1103,7 @@ class _TestContainers(BaseTestCase):
def test_dict(self):
d = self.dict()
- indices = range(65, 70)
+ indices = list(range(65, 70))
for i in indices:
d[i] = chr(i)
self.assertEqual(d.copy(), dict((i, chr(i)) for i in indices))
@@ -1104,6 +1129,7 @@ class _TestContainers(BaseTestCase):
def sqr(x, wait=0.0):
time.sleep(wait)
return x*x
+
class _TestPool(BaseTestCase):
def test_apply(self):
@@ -1113,9 +1139,9 @@ class _TestPool(BaseTestCase):
def test_map(self):
pmap = self.pool.map
- self.assertEqual(pmap(sqr, range(10)), map(sqr, range(10)))
- self.assertEqual(pmap(sqr, range(100), chunksize=20),
- map(sqr, range(100)))
+ self.assertEqual(pmap(sqr, list(range(10))), list(map(sqr, list(range(10)))))
+ self.assertEqual(pmap(sqr, list(range(100)), chunksize=20),
+ list(map(sqr, list(range(100)))))
def test_map_chunksize(self):
try:
@@ -1136,25 +1162,25 @@ class _TestPool(BaseTestCase):
self.assertTimingAlmostEqual(get.elapsed, TIMEOUT2)
def test_imap(self):
- it = self.pool.imap(sqr, range(10))
- self.assertEqual(list(it), map(sqr, range(10)))
+ it = self.pool.imap(sqr, list(range(10)))
+ self.assertEqual(list(it), list(map(sqr, list(range(10)))))
- it = self.pool.imap(sqr, range(10))
+ it = self.pool.imap(sqr, list(range(10)))
for i in range(10):
- self.assertEqual(it.next(), i*i)
- self.assertRaises(StopIteration, it.next)
+ self.assertEqual(next(it), i*i)
+ self.assertRaises(StopIteration, it.__next__)
- it = self.pool.imap(sqr, range(1000), chunksize=100)
+ it = self.pool.imap(sqr, list(range(1000)), chunksize=100)
for i in range(1000):
- self.assertEqual(it.next(), i*i)
- self.assertRaises(StopIteration, it.next)
+ self.assertEqual(next(it), i*i)
+ self.assertRaises(StopIteration, it.__next__)
def test_imap_unordered(self):
- it = self.pool.imap_unordered(sqr, range(1000))
- self.assertEqual(sorted(it), map(sqr, range(1000)))
+ it = self.pool.imap_unordered(sqr, list(range(1000)))
+ self.assertEqual(sorted(it), list(map(sqr, list(range(1000)))))
- it = self.pool.imap_unordered(sqr, range(1000), chunksize=53)
- self.assertEqual(sorted(it), map(sqr, range(1000)))
+ it = self.pool.imap_unordered(sqr, list(range(1000)), chunksize=53)
+ self.assertEqual(sorted(it), list(map(sqr, list(range(1000)))))
def test_make_pool(self):
self.assertRaises(ValueError, multiprocessing.Pool, -1)
@@ -1181,7 +1207,7 @@ class _TestPool(BaseTestCase):
self.pool.terminate()
join = TimingWrapper(self.pool.join)
join()
- self.assertTrue(join.elapsed < 0.2)
+ self.assertLess(join.elapsed, 0.5)
def test_empty_iterable(self):
# See Issue 12157
@@ -1195,27 +1221,55 @@ class _TestPool(BaseTestCase):
p.close()
p.join()
+def raising():
+ raise KeyError("key")
+
def unpickleable_result():
return lambda: 42
class _TestPoolWorkerErrors(BaseTestCase):
ALLOWED_TYPES = ('processes', )
+ def test_async_error_callback(self):
+ p = multiprocessing.Pool(2)
+
+ scratchpad = [None]
+ def errback(exc):
+ scratchpad[0] = exc
+
+ res = p.apply_async(raising, error_callback=errback)
+ self.assertRaises(KeyError, res.get)
+ self.assertTrue(scratchpad[0])
+ self.assertIsInstance(scratchpad[0], KeyError)
+
+ p.close()
+ p.join()
+
def test_unpickleable_result(self):
from multiprocessing.pool import MaybeEncodingError
p = multiprocessing.Pool(2)
# Make sure we don't lose pool processes because of encoding errors.
for iteration in range(20):
- res = p.apply_async(unpickleable_result)
+
+ scratchpad = [None]
+ def errback(exc):
+ scratchpad[0] = exc
+
+ res = p.apply_async(unpickleable_result, error_callback=errback)
self.assertRaises(MaybeEncodingError, res.get)
+ wrapped = scratchpad[0]
+ self.assertTrue(wrapped)
+ self.assertIsInstance(scratchpad[0], MaybeEncodingError)
+ self.assertIsNotNone(wrapped.exc)
+ self.assertIsNotNone(wrapped.value)
p.close()
p.join()
class _TestPoolWorkerLifetime(BaseTestCase):
-
ALLOWED_TYPES = ('processes', )
+
def test_pool_worker_lifetime(self):
p = multiprocessing.Pool(3, maxtasksperchild=10)
self.assertEqual(3, len(p._pool))
@@ -1277,8 +1331,8 @@ class _TestZZZNumberOfObjects(BaseTestCase):
refs = self.manager._number_of_objects()
debug_info = self.manager._debug_info()
if refs != EXPECTED_NUMBER:
- print self.manager._debug_info()
- print debug_info
+ print(self.manager._debug_info())
+ print(debug_info)
self.assertEqual(refs, EXPECTED_NUMBER)
@@ -1297,15 +1351,13 @@ class FooBar(object):
return '_h()'
def baz():
- for i in xrange(10):
+ for i in range(10):
yield i*i
class IteratorProxy(BaseProxy):
- _exposed_ = ('next', '__next__')
+ _exposed_ = ('__next__',)
def __iter__(self):
return self
- def next(self):
- return self._callmethod('next')
def __next__(self):
return self._callmethod('__next__')
@@ -1353,7 +1405,7 @@ class _TestMyManager(BaseTestCase):
# Test of connecting to a remote server and using xmlrpclib for serialization
#
-_queue = Queue.Queue()
+_queue = pyqueue.Queue()
def get_queue():
return _queue
@@ -1440,7 +1492,16 @@ class _TestManagerRestart(BaseTestCase):
manager.shutdown()
manager = QueueManager(
address=addr, authkey=authkey, serializer=SERIALIZER)
- manager.start()
+ try:
+ manager.start()
+ except IOError as e:
+ if e.errno != errno.EADDRINUSE:
+ raise
+ # Retry after some time, in case the old socket was lingering
+ # (sporadic failure on buildbots)
+ time.sleep(1.0)
+ manager = QueueManager(
+ address=addr, authkey=authkey, serializer=SERIALIZER)
manager.shutdown()
#
@@ -1469,7 +1530,7 @@ class _TestConnection(BaseTestCase):
seq = [1, 2.25, None]
msg = latin('hello world')
longmsg = msg * 10
- arr = array.array('i', range(4))
+ arr = array.array('i', list(range(4)))
if self.TYPE == 'processes':
self.assertEqual(type(conn.fileno()), int)
@@ -1499,7 +1560,7 @@ class _TestConnection(BaseTestCase):
self.assertEqual(conn.send_bytes(longmsg), None)
try:
res = conn.recv_bytes_into(buffer)
- except multiprocessing.BufferTooShort, e:
+ except multiprocessing.BufferTooShort as e:
self.assertEqual(e.args, (longmsg,))
else:
self.fail('expected BufferTooShort, got %s' % res)
@@ -1632,13 +1693,14 @@ class _TestConnection(BaseTestCase):
p = self.Process(target=self._writefd, args=(child_conn, b"foo"))
p.daemon = True
p.start()
- with open(test_support.TESTFN, "wb") as f:
+ self.addCleanup(test.support.unlink, test.support.TESTFN)
+ with open(test.support.TESTFN, "wb") as f:
fd = f.fileno()
if msvcrt:
fd = msvcrt.get_osfhandle(fd)
reduction.send_handle(conn, fd, p.pid)
p.join()
- with open(test_support.TESTFN, "rb") as f:
+ with open(test.support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"foo")
@unittest.skipUnless(HAS_REDUCTION, "test needs multiprocessing.reduction")
@@ -1657,7 +1719,8 @@ class _TestConnection(BaseTestCase):
p = self.Process(target=self._writefd, args=(child_conn, b"bar", True))
p.daemon = True
p.start()
- with open(test_support.TESTFN, "wb") as f:
+ self.addCleanup(test.support.unlink, test.support.TESTFN)
+ with open(test.support.TESTFN, "wb") as f:
fd = f.fileno()
for newfd in range(256, MAXFD):
if not self._is_fd_assigned(newfd):
@@ -1670,7 +1733,7 @@ class _TestConnection(BaseTestCase):
finally:
os.close(newfd)
p.join()
- with open(test_support.TESTFN, "rb") as f:
+ with open(test.support.TESTFN, "rb") as f:
self.assertEqual(f.read(), b"bar")
@classmethod
@@ -1831,7 +1894,7 @@ class _TestHeap(BaseTestCase):
blocks = []
# create and destroy lots of blocks of different sizes
- for i in xrange(iterations):
+ for i in range(iterations):
size = int(random.lognormvariate(0, 1) * 1000)
b = multiprocessing.heap.BufferWrapper(size)
blocks.append(b)
@@ -1847,7 +1910,7 @@ class _TestHeap(BaseTestCase):
occupied = 0
heap._lock.acquire()
self.addCleanup(heap._lock.release)
- for L in heap._len_to_seq.values():
+ for L in list(heap._len_to_seq.values()):
for arena, start, stop in L:
all.append((heap._arenas.index(arena), start, stop,
stop-start, 'free'))
@@ -1918,7 +1981,7 @@ class _TestSharedCTypes(BaseTestCase):
x = Value('i', 7, lock=lock)
y = Value(c_double, 1.0/3.0, lock=lock)
foo = Value(_Foo, 3, 2, lock=lock)
- arr = self.Array('d', range(10), lock=lock)
+ arr = self.Array('d', list(range(10)), lock=lock)
string = self.Array('c', 20, lock=lock)
string.value = latin('hello')
@@ -2133,7 +2196,7 @@ def create_test_cases(Mixin, type):
glob = globals()
Type = type.capitalize()
- for name in glob.keys():
+ for name in list(glob.keys()):
if name.startswith('_Test'):
base = glob[name]
if type in base.ALLOWED_TYPES:
@@ -2257,7 +2320,7 @@ class TestInitializers(unittest.TestCase):
def _ThisSubProcess(q):
try:
item = q.get(block=False)
- except Queue.Empty:
+ except pyqueue.Empty:
pass
def _TestProcess(q):
@@ -2309,13 +2372,30 @@ class TestStdinBadfiledescriptor(unittest.TestCase):
p.join()
def test_flushing(self):
- sio = StringIO()
+ sio = io.StringIO()
flike = _file_like(sio)
flike.write('foo')
proc = multiprocessing.Process(target=lambda: flike.flush())
flike.flush()
assert sio.getvalue() == 'foo'
+
+#
+# Issue 14151: Test invalid family on invalid environment
+#
+
+class TestInvalidFamily(unittest.TestCase):
+
+ @unittest.skipIf(WIN32, "skipped on Windows")
+ def test_invalid_family(self):
+ with self.assertRaises(ValueError):
+ multiprocessing.connection.Listener(r'\\.\test')
+
+ @unittest.skipUnless(WIN32, "skipped on non-Windows platforms")
+ def test_invalid_family_win32(self):
+ with self.assertRaises(ValueError):
+ multiprocessing.connection.Listener('/var/test.pipe')
+
#
# Test interaction with socket timeouts - see Issue #6056
#
@@ -2371,7 +2451,8 @@ class TestNoForkBomb(unittest.TestCase):
#
testcases_other = [OtherTest, TestInvalidHandle, TestInitializers,
- TestStdinBadfiledescriptor, TestTimeouts, TestNoForkBomb]
+ TestStdinBadfiledescriptor, TestInvalidFamily,
+ TestTimeouts, TestNoForkBomb]
#
#
@@ -2387,7 +2468,7 @@ def test_main(run=None):
check_enough_semaphores()
if run is None:
- from test.test_support import run_unittest as run
+ from test.support import run_unittest as run
util.get_temp_dir() # creates temp directory for use by all processes
@@ -2408,15 +2489,7 @@ def test_main(run=None):
loadTestsFromTestCase = unittest.defaultTestLoader.loadTestsFromTestCase
suite = unittest.TestSuite(loadTestsFromTestCase(tc) for tc in testcases)
- # (ncoghlan): Whether or not sys.exc_clear is executed by the threading
- # module during these tests is at least platform dependent and possibly
- # non-deterministic on any given platform. So we don't mind if the listed
- # warnings aren't actually raised.
- with test_support.check_py3k_warnings(
- (".+__(get|set)slice__ has been removed", DeprecationWarning),
- (r"sys.exc_clear\(\) not supported", DeprecationWarning),
- quiet=True):
- run(suite)
+ run(suite)
ThreadsMixin.pool.terminate()
ProcessesMixin.pool.terminate()
diff --git a/Lib/test/test_mutants.py b/Lib/test/test_mutants.py
index 69c381e0607..b43fa47626b 100644
--- a/Lib/test/test_mutants.py
+++ b/Lib/test/test_mutants.py
@@ -1,4 +1,4 @@
-from test.test_support import verbose, TESTFN
+from test.support import verbose, TESTFN
import random
import os
@@ -88,20 +88,22 @@ class Horrid:
# have any systematic relationship between comparison outcomes
# (based on self.i and other.i) and relative position within the
# hash vector (based on hashcode).
- self.hashcode = random.randrange(1000000000)
+ # XXX This is no longer effective.
+ ##self.hashcode = random.randrange(1000000000)
def __hash__(self):
return 42
return self.hashcode
- def __cmp__(self, other):
- maybe_mutate() # The point of the test.
- return cmp(self.i, other.i)
-
def __eq__(self, other):
maybe_mutate() # The point of the test.
return self.i == other.i
+ def __ne__(self, other):
+ raise RuntimeError("I didn't expect some kind of Spanish inquisition!")
+
+ __lt__ = __le__ = __gt__ = __ge__ = __ne__
+
def __repr__(self):
return "Horrid(%d)" % self.i
@@ -111,10 +113,10 @@ class Horrid:
def fill_dict(d, candidates, numentries):
d.clear()
- for i in xrange(numentries):
+ for i in range(numentries):
d[Horrid(random.choice(candidates))] = \
Horrid(random.choice(candidates))
- return d.keys()
+ return list(d.keys())
# Test one pair of randomly generated dicts, each with n entries.
# Note that dict comparison is trivial if they don't have the same number
@@ -133,16 +135,13 @@ def test_one(n):
# same size.
mutate = 1
if verbose:
- print "trying w/ lengths", len(dict1), len(dict2),
+ print("trying w/ lengths", len(dict1), len(dict2), end=' ')
while dict1 and len(dict1) == len(dict2):
if verbose:
- print ".",
- if random.random() < 0.5:
- c = cmp(dict1, dict2)
- else:
- c = dict1 == dict2
+ print(".", end=' ')
+ c = dict1 == dict2
if verbose:
- print
+ print()
# Run test_one n times. At the start (before the bugs were fixed), 20
# consecutive runs of this test each blew up on or before the sixth time
@@ -153,7 +152,7 @@ def test_one(n):
# leak).
def test(n):
- for i in xrange(n):
+ for i in range(n):
test_one(random.randrange(1, 100))
# See last comment block for clues about good values for n.
@@ -187,7 +186,7 @@ class Parent:
# the expected-output file doesn't need to change.
f = open(TESTFN, "w")
-print >> f, Parent().__dict__
+print(Parent().__dict__, file=f)
f.close()
os.unlink(TESTFN)
@@ -208,7 +207,7 @@ class Machiavelli:
# Michael sez: "doesn't crash without this. don't know why."
# Tim sez: "luck of the draw; crashes with or without for me."
- print >> f
+ print(file=f)
return repr("machiavelli")
@@ -217,7 +216,7 @@ class Machiavelli:
dict[Machiavelli()] = Machiavelli()
-print >> f, str(dict)
+print(str(dict), file=f)
f.close()
os.unlink(TESTFN)
del f, dict
@@ -281,7 +280,7 @@ dict[Machiavelli3(2)] = Machiavelli3(0)
f = open(TESTFN, "w")
try:
try:
- print >> f, dict[Machiavelli3(2)]
+ print(dict[Machiavelli3(2)], file=f)
except KeyError:
pass
finally:
diff --git a/Lib/test/test_mutex.py b/Lib/test/test_mutex.py
deleted file mode 100644
index 030080e3a4a..00000000000
--- a/Lib/test/test_mutex.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import unittest
-import test.test_support
-
-mutex = test.test_support.import_module("mutex", deprecated=True)
-
-class MutexTest(unittest.TestCase):
-
- def test_lock_and_unlock(self):
-
- def called_by_mutex(some_data):
- self.assertEqual(some_data, "spam")
- self.assertTrue(m.test(), "mutex not held")
- # Nested locking
- m.lock(called_by_mutex2, "eggs")
-
- def called_by_mutex2(some_data):
- self.assertEqual(some_data, "eggs")
- self.assertTrue(m.test(), "mutex not held")
- self.assertTrue(ready_for_2,
- "called_by_mutex2 called too soon")
-
- m = mutex.mutex()
- read_for_2 = False
- m.lock(called_by_mutex, "spam")
- ready_for_2 = True
- # unlock both locks
- m.unlock()
- m.unlock()
- self.assertFalse(m.test(), "mutex still held")
-
-def test_main():
- test.test_support.run_unittest(MutexTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_netrc.py b/Lib/test/test_netrc.py
index 27954563263..ef70e3754a3 100644
--- a/Lib/test/test_netrc.py
+++ b/Lib/test/test_netrc.py
@@ -1,7 +1,7 @@
import netrc, os, unittest, sys, textwrap
-from test import test_support
+from test import support
-temp_filename = test_support.TESTFN
+temp_filename = support.TESTFN
class NetrcTestCase(unittest.TestCase):
@@ -104,7 +104,7 @@ class NetrcTestCase(unittest.TestCase):
def test_main():
- test_support.run_unittest(NetrcTestCase)
+ support.run_unittest(NetrcTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_new.py b/Lib/test/test_new.py
deleted file mode 100644
index a84b3d10d40..00000000000
--- a/Lib/test/test_new.py
+++ /dev/null
@@ -1,163 +0,0 @@
-import unittest
-from test import test_support
-import sys
-new = test_support.import_module('new', deprecated=True)
-
-class NewTest(unittest.TestCase):
- def test_spam(self):
- class Eggs:
- def get_yolks(self):
- return self.yolks
-
- m = new.module('Spam')
- m.Eggs = Eggs
- sys.modules['Spam'] = m
- import Spam
-
- def get_more_yolks(self):
- return self.yolks + 3
-
- # new.classobj()
- C = new.classobj('Spam', (Spam.Eggs,), {'get_more_yolks': get_more_yolks})
-
- # new.instance()
- c = new.instance(C, {'yolks': 3})
-
- o = new.instance(C)
- self.assertEqual(o.__dict__, {}, "new __dict__ should be empty")
- del o
- o = new.instance(C, None)
- self.assertEqual(o.__dict__, {}, "new __dict__ should be empty")
- del o
-
- def break_yolks(self):
- self.yolks = self.yolks - 2
-
- # new.instancemethod()
- im = new.instancemethod(break_yolks, c, C)
-
- self.assertEqual(c.get_yolks(), 3,
- 'Broken call of hand-crafted class instance')
- self.assertEqual(c.get_more_yolks(), 6,
- 'Broken call of hand-crafted class instance')
-
- im()
- self.assertEqual(c.get_yolks(), 1,
- 'Broken call of hand-crafted instance method')
- self.assertEqual(c.get_more_yolks(), 4,
- 'Broken call of hand-crafted instance method')
-
- im = new.instancemethod(break_yolks, c)
- im()
- self.assertEqual(c.get_yolks(), -1)
-
- # Verify that dangerous instance method creation is forbidden
- self.assertRaises(TypeError, new.instancemethod, break_yolks, None)
-
- # Verify that instancemethod() doesn't allow keyword args
- self.assertRaises(TypeError, new.instancemethod, break_yolks, c, kw=1)
-
- def test_scope(self):
- # It's unclear what the semantics should be for a code object compiled
- # at module scope, but bound and run in a function. In CPython, `c' is
- # global (by accident?) while in Jython, `c' is local. The intent of
- # the test clearly is to make `c' global, so let's be explicit about it.
- codestr = '''
- global c
- a = 1
- b = 2
- c = a + b
- '''
-
- codestr = "\n".join(l.strip() for l in codestr.splitlines())
-
- ccode = compile(codestr, '<string>', 'exec')
- # Jython doesn't have a __builtins__, so use a portable alternative
- import __builtin__
- g = {'c': 0, '__builtins__': __builtin__}
-
- # this test could be more robust
- func = new.function(ccode, g)
- func()
- self.assertEqual(g['c'], 3, 'Could not create a proper function object')
-
- def test_function(self):
- # test the various extended flavors of function.new
- def f(x):
- def g(y):
- return x + y
- return g
- g = f(4)
- new.function(f.func_code, {}, "blah")
- g2 = new.function(g.func_code, {}, "blah", (2,), g.func_closure)
- self.assertEqual(g2(), 6)
- g3 = new.function(g.func_code, {}, "blah", None, g.func_closure)
- self.assertEqual(g3(5), 9)
- def test_closure(func, closure, exc):
- self.assertRaises(exc, new.function, func.func_code, {}, "", None, closure)
-
- test_closure(g, None, TypeError) # invalid closure
- test_closure(g, (1,), TypeError) # non-cell in closure
- test_closure(g, (1, 1), ValueError) # closure is wrong size
- test_closure(f, g.func_closure, ValueError) # no closure needed
-
- # Note: Jython will never have new.code()
- if hasattr(new, 'code'):
- def test_code(self):
- # bogus test of new.code()
- def f(a): pass
-
- c = f.func_code
- argcount = c.co_argcount
- nlocals = c.co_nlocals
- stacksize = c.co_stacksize
- flags = c.co_flags
- codestring = c.co_code
- constants = c.co_consts
- names = c.co_names
- varnames = c.co_varnames
- filename = c.co_filename
- name = c.co_name
- firstlineno = c.co_firstlineno
- lnotab = c.co_lnotab
- freevars = c.co_freevars
- cellvars = c.co_cellvars
-
- d = new.code(argcount, nlocals, stacksize, flags, codestring,
- constants, names, varnames, filename, name,
- firstlineno, lnotab, freevars, cellvars)
-
- # test backwards-compatibility version with no freevars or cellvars
- d = new.code(argcount, nlocals, stacksize, flags, codestring,
- constants, names, varnames, filename, name,
- firstlineno, lnotab)
-
- # negative co_argcount used to trigger a SystemError
- self.assertRaises(ValueError, new.code,
- -argcount, nlocals, stacksize, flags, codestring,
- constants, names, varnames, filename, name, firstlineno, lnotab)
-
- # negative co_nlocals used to trigger a SystemError
- self.assertRaises(ValueError, new.code,
- argcount, -nlocals, stacksize, flags, codestring,
- constants, names, varnames, filename, name, firstlineno, lnotab)
-
- # non-string co_name used to trigger a Py_FatalError
- self.assertRaises(TypeError, new.code,
- argcount, nlocals, stacksize, flags, codestring,
- constants, (5,), varnames, filename, name, firstlineno, lnotab)
-
- # new.code used to be a way to mutate a tuple...
- class S(str):
- pass
- t = (S("ab"),)
- d = new.code(argcount, nlocals, stacksize, flags, codestring,
- constants, t, varnames, filename, name,
- firstlineno, lnotab)
- self.assertTrue(type(t[0]) is S, "eek, tuple changed under us!")
-
-def test_main():
- test_support.run_unittest(NewTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_nis.py b/Lib/test/test_nis.py
index 8d495505d13..830c24d7813 100644
--- a/Lib/test/test_nis.py
+++ b/Lib/test/test_nis.py
@@ -1,16 +1,19 @@
-from test import test_support
+from test import support
import unittest
+import sys
+
+# Skip test if nis module does not exist.
+nis = support.import_module('nis')
-nis = test_support.import_module('nis')
class NisTests(unittest.TestCase):
def test_maps(self):
try:
maps = nis.maps()
- except nis.error, msg:
+ except nis.error as msg:
# NIS is probably not active, so this test isn't useful
- if test_support.verbose:
- print "Test Skipped:", msg
+ if support.verbose:
+ print("Test Skipped:", msg)
# Can't raise SkipTest as regrtest only recognizes the exception
# import time.
return
@@ -38,7 +41,7 @@ class NisTests(unittest.TestCase):
break
def test_main():
- test_support.run_unittest(NisTests)
+ support.run_unittest(NisTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_nntplib.py b/Lib/test/test_nntplib.py
new file mode 100644
index 00000000000..7335b23b2d4
--- /dev/null
+++ b/Lib/test/test_nntplib.py
@@ -0,0 +1,1389 @@
+import io
+import datetime
+import textwrap
+import unittest
+import functools
+import contextlib
+from test import support
+from nntplib import NNTP, GroupInfo, _have_ssl
+import nntplib
+if _have_ssl:
+ import ssl
+
+TIMEOUT = 30
+
+# TODO:
+# - test the `file` arg to more commands
+# - test error conditions
+# - test auth and `usenetrc`
+
+
+class NetworkedNNTPTestsMixin:
+
+ def test_welcome(self):
+ welcome = self.server.getwelcome()
+ self.assertEqual(str, type(welcome))
+
+ def test_help(self):
+ resp, lines = self.server.help()
+ self.assertTrue(resp.startswith("100 "), resp)
+ for line in lines:
+ self.assertEqual(str, type(line))
+
+ def test_list(self):
+ resp, groups = self.server.list()
+ if len(groups) > 0:
+ self.assertEqual(GroupInfo, type(groups[0]))
+ self.assertEqual(str, type(groups[0].group))
+
+ def test_list_active(self):
+ resp, groups = self.server.list(self.GROUP_PAT)
+ if len(groups) > 0:
+ self.assertEqual(GroupInfo, type(groups[0]))
+ self.assertEqual(str, type(groups[0].group))
+
+ def test_unknown_command(self):
+ with self.assertRaises(nntplib.NNTPPermanentError) as cm:
+ self.server._shortcmd("XYZZY")
+ resp = cm.exception.response
+ self.assertTrue(resp.startswith("500 "), resp)
+
+ def test_newgroups(self):
+ # gmane gets a constant influx of new groups. In order not to stress
+ # the server too much, we choose a recent date in the past.
+ dt = datetime.date.today() - datetime.timedelta(days=7)
+ resp, groups = self.server.newgroups(dt)
+ if len(groups) > 0:
+ self.assertIsInstance(groups[0], GroupInfo)
+ self.assertIsInstance(groups[0].group, str)
+
+ def test_description(self):
+ def _check_desc(desc):
+ # Sanity checks
+ self.assertIsInstance(desc, str)
+ self.assertNotIn(self.GROUP_NAME, desc)
+ desc = self.server.description(self.GROUP_NAME)
+ _check_desc(desc)
+ # Another sanity check
+ self.assertIn("Python", desc)
+ # With a pattern
+ desc = self.server.description(self.GROUP_PAT)
+ _check_desc(desc)
+ # Shouldn't exist
+ desc = self.server.description("zk.brrtt.baz")
+ self.assertEqual(desc, '')
+
+ def test_descriptions(self):
+ resp, descs = self.server.descriptions(self.GROUP_PAT)
+ # 215 for LIST NEWSGROUPS, 282 for XGTITLE
+ self.assertTrue(
+ resp.startswith("215 ") or resp.startswith("282 "), resp)
+ self.assertIsInstance(descs, dict)
+ desc = descs[self.GROUP_NAME]
+ self.assertEqual(desc, self.server.description(self.GROUP_NAME))
+
+ def test_group(self):
+ result = self.server.group(self.GROUP_NAME)
+ self.assertEqual(5, len(result))
+ resp, count, first, last, group = result
+ self.assertEqual(group, self.GROUP_NAME)
+ self.assertIsInstance(count, int)
+ self.assertIsInstance(first, int)
+ self.assertIsInstance(last, int)
+ self.assertLessEqual(first, last)
+ self.assertTrue(resp.startswith("211 "), resp)
+
+ def test_date(self):
+ resp, date = self.server.date()
+ self.assertIsInstance(date, datetime.datetime)
+ # Sanity check
+ self.assertGreaterEqual(date.year, 1995)
+ self.assertLessEqual(date.year, 2030)
+
+ def _check_art_dict(self, art_dict):
+ # Some sanity checks for a field dictionary returned by OVER / XOVER
+ self.assertIsInstance(art_dict, dict)
+ # NNTP has 7 mandatory fields
+ self.assertGreaterEqual(art_dict.keys(),
+ {"subject", "from", "date", "message-id",
+ "references", ":bytes", ":lines"}
+ )
+ for v in art_dict.values():
+ self.assertIsInstance(v, (str, type(None)))
+
+ def test_xover(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ resp, lines = self.server.xover(last - 5, last)
+ if len(lines) == 0:
+ self.skipTest("no articles retrieved")
+ # The 'last' article is not necessarily part of the output (cancelled?)
+ art_num, art_dict = lines[0]
+ self.assertGreaterEqual(art_num, last - 5)
+ self.assertLessEqual(art_num, last)
+ self._check_art_dict(art_dict)
+
+ def test_over(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ start = last - 10
+ # The "start-" article range form
+ resp, lines = self.server.over((start, None))
+ art_num, art_dict = lines[0]
+ self._check_art_dict(art_dict)
+ # The "start-end" article range form
+ resp, lines = self.server.over((start, last))
+ art_num, art_dict = lines[-1]
+ # The 'last' article is not necessarily part of the output (cancelled?)
+ self.assertGreaterEqual(art_num, start)
+ self.assertLessEqual(art_num, last)
+ self._check_art_dict(art_dict)
+ # XXX The "message_id" form is unsupported by gmane
+ # 503 Overview by message-ID unsupported
+
+ def test_xhdr(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ resp, lines = self.server.xhdr('subject', last)
+ for line in lines:
+ self.assertEqual(str, type(line[1]))
+
+ def check_article_resp(self, resp, article, art_num=None):
+ self.assertIsInstance(article, nntplib.ArticleInfo)
+ if art_num is not None:
+ self.assertEqual(article.number, art_num)
+ for line in article.lines:
+ self.assertIsInstance(line, bytes)
+ # XXX this could exceptionally happen...
+ self.assertNotIn(article.lines[-1], (b".", b".\n", b".\r\n"))
+
+ def test_article_head_body(self):
+ resp, count, first, last, name = self.server.group(self.GROUP_NAME)
+ # Try to find an available article
+ for art_num in (last, first, last - 1):
+ try:
+ resp, head = self.server.head(art_num)
+ except nntplib.NNTPTemporaryError as e:
+ if not e.response.startswith("423 "):
+ raise
+ # "423 No such article" => choose another one
+ continue
+ break
+ else:
+ self.skipTest("could not find a suitable article number")
+ self.assertTrue(resp.startswith("221 "), resp)
+ self.check_article_resp(resp, head, art_num)
+ resp, body = self.server.body(art_num)
+ self.assertTrue(resp.startswith("222 "), resp)
+ self.check_article_resp(resp, body, art_num)
+ resp, article = self.server.article(art_num)
+ self.assertTrue(resp.startswith("220 "), resp)
+ self.check_article_resp(resp, article, art_num)
+ # Tolerate running the tests from behind a NNTP virus checker
+ blacklist = lambda line: line.startswith(b'X-Antivirus')
+ filtered_head_lines = [line for line in head.lines
+ if not blacklist(line)]
+ filtered_lines = [line for line in article.lines
+ if not blacklist(line)]
+ self.assertEqual(filtered_lines, filtered_head_lines + [b''] + body.lines)
+
+ def test_capabilities(self):
+ # The server under test implements NNTP version 2 and has a
+ # couple of well-known capabilities. Just sanity check that we
+ # got them.
+ def _check_caps(caps):
+ caps_list = caps['LIST']
+ self.assertIsInstance(caps_list, (list, tuple))
+ self.assertIn('OVERVIEW.FMT', caps_list)
+ self.assertGreaterEqual(self.server.nntp_version, 2)
+ _check_caps(self.server.getcapabilities())
+ # This re-emits the command
+ resp, caps = self.server.capabilities()
+ _check_caps(caps)
+
+ if _have_ssl:
+ def test_starttls(self):
+ file = self.server.file
+ sock = self.server.sock
+ try:
+ self.server.starttls()
+ except nntplib.NNTPPermanentError:
+ self.skipTest("STARTTLS not supported by server.")
+ else:
+ # Check that the socket and internal pseudo-file really were
+ # changed.
+ self.assertNotEqual(file, self.server.file)
+ self.assertNotEqual(sock, self.server.sock)
+ # Check that the new socket really is an SSL one
+ self.assertIsInstance(self.server.sock, ssl.SSLSocket)
+ # Check that trying starttls when it's already active fails.
+ self.assertRaises(ValueError, self.server.starttls)
+
+ def test_zlogin(self):
+ # This test must be the penultimate because further commands will be
+ # refused.
+ baduser = "notarealuser"
+ badpw = "notarealpassword"
+ # Check that bogus credentials cause failure
+ self.assertRaises(nntplib.NNTPError, self.server.login,
+ user=baduser, password=badpw, usenetrc=False)
+ # FIXME: We should check that correct credentials succeed, but that
+ # would require valid details for some server somewhere to be in the
+ # test suite, I think. Gmane is anonymous, at least as used for the
+ # other tests.
+
+ def test_zzquit(self):
+ # This test must be called last, hence the name
+ cls = type(self)
+ try:
+ self.server.quit()
+ finally:
+ cls.server = None
+
+ @classmethod
+ def wrap_methods(cls):
+ # Wrap all methods in a transient_internet() exception catcher
+ # XXX put a generic version in test.support?
+ def wrap_meth(meth):
+ @functools.wraps(meth)
+ def wrapped(self):
+ with support.transient_internet(self.NNTP_HOST):
+ meth(self)
+ return wrapped
+ for name in dir(cls):
+ if not name.startswith('test_'):
+ continue
+ meth = getattr(cls, name)
+ if not callable(meth):
+ continue
+ # Need to use a closure so that meth remains bound to its current
+ # value
+ setattr(cls, name, wrap_meth(meth))
+
+NetworkedNNTPTestsMixin.wrap_methods()
+
+
+class NetworkedNNTPTests(NetworkedNNTPTestsMixin, unittest.TestCase):
+ # This server supports STARTTLS (gmane doesn't)
+ NNTP_HOST = 'news.trigofacile.com'
+ GROUP_NAME = 'fr.comp.lang.python'
+ GROUP_PAT = 'fr.comp.lang.*'
+
+ NNTP_CLASS = NNTP
+
+ @classmethod
+ def setUpClass(cls):
+ support.requires("network")
+ with support.transient_internet(cls.NNTP_HOST):
+ cls.server = cls.NNTP_CLASS(cls.NNTP_HOST, timeout=TIMEOUT, usenetrc=False)
+
+ @classmethod
+ def tearDownClass(cls):
+ if cls.server is not None:
+ cls.server.quit()
+
+
+if _have_ssl:
+ class NetworkedNNTP_SSLTests(NetworkedNNTPTests):
+
+ # Technical limits for this public NNTP server (see http://www.aioe.org):
+ # "Only two concurrent connections per IP address are allowed and
+ # 400 connections per day are accepted from each IP address."
+
+ NNTP_HOST = 'nntp.aioe.org'
+ GROUP_NAME = 'comp.lang.python'
+ GROUP_PAT = 'comp.lang.*'
+
+ NNTP_CLASS = nntplib.NNTP_SSL
+
+ # Disabled as it produces too much data
+ test_list = None
+
+ # Disabled as the connection will already be encrypted.
+ test_starttls = None
+
+
+#
+# Non-networked tests using a local server (or something mocking it).
+#
+
+class _NNTPServerIO(io.RawIOBase):
+ """A raw IO object allowing NNTP commands to be received and processed
+ by a handler. The handler can push responses which can then be read
+ from the IO object."""
+
+ def __init__(self, handler):
+ io.RawIOBase.__init__(self)
+ # The channel from the client
+ self.c2s = io.BytesIO()
+ # The channel to the client
+ self.s2c = io.BytesIO()
+ self.handler = handler
+ self.handler.start(self.c2s.readline, self.push_data)
+
+ def readable(self):
+ return True
+
+ def writable(self):
+ return True
+
+ def push_data(self, data):
+ """Push (buffer) some data to send to the client."""
+ pos = self.s2c.tell()
+ self.s2c.seek(0, 2)
+ self.s2c.write(data)
+ self.s2c.seek(pos)
+
+ def write(self, b):
+ """The client sends us some data"""
+ pos = self.c2s.tell()
+ self.c2s.write(b)
+ self.c2s.seek(pos)
+ self.handler.process_pending()
+ return len(b)
+
+ def readinto(self, buf):
+ """The client wants to read a response"""
+ self.handler.process_pending()
+ b = self.s2c.read(len(buf))
+ n = len(b)
+ buf[:n] = b
+ return n
+
+
+class MockedNNTPTestsMixin:
+ # Override in derived classes
+ handler_class = None
+
+ def setUp(self):
+ super().setUp()
+ self.make_server()
+
+ def tearDown(self):
+ super().tearDown()
+ del self.server
+
+ def make_server(self, *args, **kwargs):
+ self.handler = self.handler_class()
+ self.sio = _NNTPServerIO(self.handler)
+ # Using BufferedRWPair instead of BufferedRandom ensures the file
+ # isn't seekable.
+ file = io.BufferedRWPair(self.sio, self.sio)
+ self.server = nntplib._NNTPBase(file, 'test.server', *args, **kwargs)
+ return self.server
+
+
+class MockedNNTPWithReaderModeMixin(MockedNNTPTestsMixin):
+ def setUp(self):
+ super().setUp()
+ self.make_server(readermode=True)
+
+
+class NNTPv1Handler:
+ """A handler for RFC 977"""
+
+ welcome = "200 NNTP mock server"
+
+ def start(self, readline, push_data):
+ self.in_body = False
+ self.allow_posting = True
+ self._readline = readline
+ self._push_data = push_data
+ self._logged_in = False
+ self._user_sent = False
+ # Our welcome
+ self.handle_welcome()
+
+ def _decode(self, data):
+ return str(data, "utf-8", "surrogateescape")
+
+ def process_pending(self):
+ if self.in_body:
+ while True:
+ line = self._readline()
+ if not line:
+ return
+ self.body.append(line)
+ if line == b".\r\n":
+ break
+ try:
+ meth, tokens = self.body_callback
+ meth(*tokens, body=self.body)
+ finally:
+ self.body_callback = None
+ self.body = None
+ self.in_body = False
+ while True:
+ line = self._decode(self._readline())
+ if not line:
+ return
+ if not line.endswith("\r\n"):
+ raise ValueError("line doesn't end with \\r\\n: {!r}".format(line))
+ line = line[:-2]
+ cmd, *tokens = line.split()
+ #meth = getattr(self.handler, "handle_" + cmd.upper(), None)
+ meth = getattr(self, "handle_" + cmd.upper(), None)
+ if meth is None:
+ self.handle_unknown()
+ else:
+ try:
+ meth(*tokens)
+ except Exception as e:
+ raise ValueError("command failed: {!r}".format(line)) from e
+ else:
+ if self.in_body:
+ self.body_callback = meth, tokens
+ self.body = []
+
+ def expect_body(self):
+ """Flag that the client is expected to post a request body"""
+ self.in_body = True
+
+ def push_data(self, data):
+ """Push some binary data"""
+ self._push_data(data)
+
+ def push_lit(self, lit):
+ """Push a string literal"""
+ lit = textwrap.dedent(lit)
+ lit = "\r\n".join(lit.splitlines()) + "\r\n"
+ lit = lit.encode('utf-8')
+ self.push_data(lit)
+
+ def handle_unknown(self):
+ self.push_lit("500 What?")
+
+ def handle_welcome(self):
+ self.push_lit(self.welcome)
+
+ def handle_QUIT(self):
+ self.push_lit("205 Bye!")
+
+ def handle_DATE(self):
+ self.push_lit("111 20100914001155")
+
+ def handle_GROUP(self, group):
+ if group == "fr.comp.lang.python":
+ self.push_lit("211 486 761 1265 fr.comp.lang.python")
+ else:
+ self.push_lit("411 No such group {}".format(group))
+
+ def handle_HELP(self):
+ self.push_lit("""\
+ 100 Legal commands
+ authinfo user Name|pass Password|generic <prog> <args>
+ date
+ help
+ Report problems to <root@example.org>
+ .""")
+
+ def handle_STAT(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("412 No newsgroup selected")
+ elif message_spec == "3000234":
+ self.push_lit("223 3000234 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("223 0 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+
+ def handle_NEXT(self):
+ self.push_lit("223 3000237 <668929@example.org> retrieved")
+
+ def handle_LAST(self):
+ self.push_lit("223 3000234 <45223423@example.com> retrieved")
+
+ def handle_LIST(self, action=None, param=None):
+ if action is None:
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags".
+ comp.lang.python 0000052340 0000002828 y
+ comp.lang.python.announce 0000001153 0000000993 m
+ free.it.comp.lang.python 0000000002 0000000002 y
+ fr.comp.lang.python 0000001254 0000000760 y
+ free.it.comp.lang.python.learner 0000000000 0000000001 y
+ tw.bbs.comp.lang.python 0000000304 0000000304 y
+ .""")
+ elif action == "ACTIVE":
+ if param == "*distutils*":
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags"
+ gmane.comp.python.distutils.devel 0000014104 0000000001 m
+ gmane.comp.python.distutils.cvs 0000000000 0000000001 m
+ .""")
+ else:
+ self.push_lit("""\
+ 215 Newsgroups in form "group high low flags"
+ .""")
+ elif action == "OVERVIEW.FMT":
+ self.push_lit("""\
+ 215 Order of fields in overview database.
+ Subject:
+ From:
+ Date:
+ Message-ID:
+ References:
+ Bytes:
+ Lines:
+ Xref:full
+ .""")
+ elif action == "NEWSGROUPS":
+ assert param is not None
+ if param == "comp.lang.python":
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ comp.lang.python\tThe Python computer language.
+ .""")
+ elif param == "comp.lang.python*":
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ comp.lang.python.announce\tAnnouncements about the Python language. (Moderated)
+ comp.lang.python\tThe Python computer language.
+ .""")
+ else:
+ self.push_lit("""\
+ 215 Descriptions in form "group description".
+ .""")
+ else:
+ self.push_lit('501 Unknown LIST keyword')
+
+ def handle_NEWNEWS(self, group, date_str, time_str):
+ # We hard code different return messages depending on passed
+ # argument and date syntax.
+ if (group == "comp.lang.python" and date_str == "20100913"
+ and time_str == "082004"):
+ # Date was passed in RFC 3977 format (NNTP "v2")
+ self.push_lit("""\
+ 230 list of newsarticles (NNTP v2) created after Mon Sep 13 08:20:04 2010 follows
+ <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
+ <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
+ .""")
+ elif (group == "comp.lang.python" and date_str == "100913"
+ and time_str == "082004"):
+ # Date was passed in RFC 977 format (NNTP "v1")
+ self.push_lit("""\
+ 230 list of newsarticles (NNTP v1) created after Mon Sep 13 08:20:04 2010 follows
+ <a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>
+ <f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>
+ .""")
+ else:
+ self.push_lit("""\
+ 230 An empty list of newsarticles follows
+ .""")
+ # (Note for experiments: many servers disable NEWNEWS.
+ # As of this writing, sicinfo3.epfl.ch doesn't.)
+
+ def handle_XOVER(self, message_spec):
+ if message_spec == "57-59":
+ self.push_lit(
+ "224 Overview information for 57-58 follows\n"
+ "57\tRe: ANN: New Plone book with strong Python (and Zope) themes throughout"
+ "\tDoug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>"
+ "\tSat, 19 Jun 2010 18:04:08 -0400"
+ "\t<4FD05F05-F98B-44DC-8111-C6009C925F0C@gmail.com>"
+ "\t<hvalf7$ort$1@dough.gmane.org>\t7103\t16"
+ "\tXref: news.gmane.org gmane.comp.python.authors:57"
+ "\n"
+ "58\tLooking for a few good bloggers"
+ "\tDoug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>"
+ "\tThu, 22 Jul 2010 09:14:14 -0400"
+ "\t<A29863FA-F388-40C3-AA25-0FD06B09B5BF@gmail.com>"
+ "\t\t6683\t16"
+ "\t"
+ "\n"
+ # An UTF-8 overview line from fr.comp.lang.python
+ "59\tRe: Message d'erreur incompréhensible (par moi)"
+ "\tEric Brunel <eric.brunel@pragmadev.nospam.com>"
+ "\tWed, 15 Sep 2010 18:09:15 +0200"
+ "\t<eric.brunel-2B8B56.18091515092010@news.wanadoo.fr>"
+ "\t<4c90ec87$0$32425$ba4acef3@reader.news.orange.fr>\t1641\t27"
+ "\tXref: saria.nerim.net fr.comp.lang.python:1265"
+ "\n"
+ ".\n")
+ else:
+ self.push_lit("""\
+ 224 No articles
+ .""")
+
+ def handle_POST(self, *, body=None):
+ if body is None:
+ if self.allow_posting:
+ self.push_lit("340 Input article; end with <CR-LF>.<CR-LF>")
+ self.expect_body()
+ else:
+ self.push_lit("440 Posting not permitted")
+ else:
+ assert self.allow_posting
+ self.push_lit("240 Article received OK")
+ self.posted_body = body
+
+ def handle_IHAVE(self, message_id, *, body=None):
+ if body is None:
+ if (self.allow_posting and
+ message_id == "<i.am.an.article.you.will.want@example.com>"):
+ self.push_lit("335 Send it; end with <CR-LF>.<CR-LF>")
+ self.expect_body()
+ else:
+ self.push_lit("435 Article not wanted")
+ else:
+ assert self.allow_posting
+ self.push_lit("235 Article transferred OK")
+ self.posted_body = body
+
+ sample_head = """\
+ From: "Demo User" <nobody@example.net>
+ Subject: I am just a test article
+ Content-Type: text/plain; charset=UTF-8; format=flowed
+ Message-ID: <i.am.an.article.you.will.want@example.com>"""
+
+ sample_body = """\
+ This is just a test article.
+ ..Here is a dot-starting line.
+
+ -- Signed by Andr\xe9."""
+
+ sample_article = sample_head + "\n\n" + sample_body
+
+ def handle_ARTICLE(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("220 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("220 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("220 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_article)
+ self.push_lit(".")
+
+ def handle_HEAD(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("221 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("221 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("221 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_head)
+ self.push_lit(".")
+
+ def handle_BODY(self, message_spec=None):
+ if message_spec is None:
+ self.push_lit("222 3000237 <45223423@example.com>")
+ elif message_spec == "<45223423@example.com>":
+ self.push_lit("222 0 <45223423@example.com>")
+ elif message_spec == "3000234":
+ self.push_lit("222 3000234 <45223423@example.com>")
+ else:
+ self.push_lit("430 No Such Article Found")
+ return
+ self.push_lit(self.sample_body)
+ self.push_lit(".")
+
+ def handle_AUTHINFO(self, cred_type, data):
+ if self._logged_in:
+ self.push_lit('502 Already Logged In')
+ elif cred_type == 'user':
+ if self._user_sent:
+ self.push_lit('482 User Credential Already Sent')
+ else:
+ self.push_lit('381 Password Required')
+ self._user_sent = True
+ elif cred_type == 'pass':
+ self.push_lit('281 Login Successful')
+ self._logged_in = True
+ else:
+ raise Exception('Unknown cred type {}'.format(cred_type))
+
+
+class NNTPv2Handler(NNTPv1Handler):
+ """A handler for RFC 3977 (NNTP "v2")"""
+
+ def handle_CAPABILITIES(self):
+ fmt = """\
+ 101 Capability list:
+ VERSION 2 3
+ IMPLEMENTATION INN 2.5.1{}
+ HDR
+ LIST ACTIVE ACTIVE.TIMES DISTRIB.PATS HEADERS NEWSGROUPS OVERVIEW.FMT
+ OVER
+ POST
+ READER
+ ."""
+
+ if not self._logged_in:
+ self.push_lit(fmt.format('\n AUTHINFO USER'))
+ else:
+ self.push_lit(fmt.format(''))
+
+ def handle_MODE(self, _):
+ raise Exception('MODE READER sent despite READER has been advertised')
+
+ def handle_OVER(self, message_spec=None):
+ return self.handle_XOVER(message_spec)
+
+
+class CapsAfterLoginNNTPv2Handler(NNTPv2Handler):
+ """A handler that allows CAPABILITIES only after login"""
+
+ def handle_CAPABILITIES(self):
+ if not self._logged_in:
+ self.push_lit('480 You must log in.')
+ else:
+ super().handle_CAPABILITIES()
+
+
+class ModeSwitchingNNTPv2Handler(NNTPv2Handler):
+ """A server that starts in transit mode"""
+
+ def __init__(self):
+ self._switched = False
+
+ def handle_CAPABILITIES(self):
+ fmt = """\
+ 101 Capability list:
+ VERSION 2 3
+ IMPLEMENTATION INN 2.5.1
+ HDR
+ LIST ACTIVE ACTIVE.TIMES DISTRIB.PATS HEADERS NEWSGROUPS OVERVIEW.FMT
+ OVER
+ POST
+ {}READER
+ ."""
+ if self._switched:
+ self.push_lit(fmt.format(''))
+ else:
+ self.push_lit(fmt.format('MODE-'))
+
+ def handle_MODE(self, what):
+ assert not self._switched and what == 'reader'
+ self._switched = True
+ self.push_lit('200 Posting allowed')
+
+
+class NNTPv1v2TestsMixin:
+
+ def setUp(self):
+ super().setUp()
+
+ def test_welcome(self):
+ self.assertEqual(self.server.welcome, self.handler.welcome)
+
+ def test_authinfo(self):
+ if self.nntp_version == 2:
+ self.assertIn('AUTHINFO', self.server._caps)
+ self.server.login('testuser', 'testpw')
+ # if AUTHINFO is gone from _caps we also know that getcapabilities()
+ # has been called after login as it should
+ self.assertNotIn('AUTHINFO', self.server._caps)
+
+ def test_date(self):
+ resp, date = self.server.date()
+ self.assertEqual(resp, "111 20100914001155")
+ self.assertEqual(date, datetime.datetime(2010, 9, 14, 0, 11, 55))
+
+ def test_quit(self):
+ self.assertFalse(self.sio.closed)
+ resp = self.server.quit()
+ self.assertEqual(resp, "205 Bye!")
+ self.assertTrue(self.sio.closed)
+
+ def test_help(self):
+ resp, help = self.server.help()
+ self.assertEqual(resp, "100 Legal commands")
+ self.assertEqual(help, [
+ ' authinfo user Name|pass Password|generic <prog> <args>',
+ ' date',
+ ' help',
+ 'Report problems to <root@example.org>',
+ ])
+
+ def test_list(self):
+ resp, groups = self.server.list()
+ self.assertEqual(len(groups), 6)
+ g = groups[1]
+ self.assertEqual(g,
+ GroupInfo("comp.lang.python.announce", "0000001153",
+ "0000000993", "m"))
+ resp, groups = self.server.list("*distutils*")
+ self.assertEqual(len(groups), 2)
+ g = groups[0]
+ self.assertEqual(g,
+ GroupInfo("gmane.comp.python.distutils.devel", "0000014104",
+ "0000000001", "m"))
+
+ def test_stat(self):
+ resp, art_num, message_id = self.server.stat(3000234)
+ self.assertEqual(resp, "223 3000234 <45223423@example.com>")
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ resp, art_num, message_id = self.server.stat("<45223423@example.com>")
+ self.assertEqual(resp, "223 0 <45223423@example.com>")
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.stat("<non.existent.id>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.stat()
+ self.assertEqual(cm.exception.response, "412 No newsgroup selected")
+
+ def test_next(self):
+ resp, art_num, message_id = self.server.next()
+ self.assertEqual(resp, "223 3000237 <668929@example.org> retrieved")
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<668929@example.org>")
+
+ def test_last(self):
+ resp, art_num, message_id = self.server.last()
+ self.assertEqual(resp, "223 3000234 <45223423@example.com> retrieved")
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+
+ def test_description(self):
+ desc = self.server.description("comp.lang.python")
+ self.assertEqual(desc, "The Python computer language.")
+ desc = self.server.description("comp.lang.pythonx")
+ self.assertEqual(desc, "")
+
+ def test_descriptions(self):
+ resp, groups = self.server.descriptions("comp.lang.python")
+ self.assertEqual(resp, '215 Descriptions in form "group description".')
+ self.assertEqual(groups, {
+ "comp.lang.python": "The Python computer language.",
+ })
+ resp, groups = self.server.descriptions("comp.lang.python*")
+ self.assertEqual(groups, {
+ "comp.lang.python": "The Python computer language.",
+ "comp.lang.python.announce": "Announcements about the Python language. (Moderated)",
+ })
+ resp, groups = self.server.descriptions("comp.lang.pythonx")
+ self.assertEqual(groups, {})
+
+ def test_group(self):
+ resp, count, first, last, group = self.server.group("fr.comp.lang.python")
+ self.assertTrue(resp.startswith("211 "), resp)
+ self.assertEqual(first, 761)
+ self.assertEqual(last, 1265)
+ self.assertEqual(count, 486)
+ self.assertEqual(group, "fr.comp.lang.python")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.group("comp.lang.python.devel")
+ exc = cm.exception
+ self.assertTrue(exc.response.startswith("411 No such group"),
+ exc.response)
+
+ def test_newnews(self):
+ # NEWNEWS comp.lang.python [20]100913 082004
+ dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
+ resp, ids = self.server.newnews("comp.lang.python", dt)
+ expected = (
+ "230 list of newsarticles (NNTP v{0}) "
+ "created after Mon Sep 13 08:20:04 2010 follows"
+ ).format(self.nntp_version)
+ self.assertEqual(resp, expected)
+ self.assertEqual(ids, [
+ "<a4929a40-6328-491a-aaaf-cb79ed7309a2@q2g2000vbk.googlegroups.com>",
+ "<f30c0419-f549-4218-848f-d7d0131da931@y3g2000vbm.googlegroups.com>",
+ ])
+ # NEWNEWS fr.comp.lang.python [20]100913 082004
+ dt = datetime.datetime(2010, 9, 13, 8, 20, 4)
+ resp, ids = self.server.newnews("fr.comp.lang.python", dt)
+ self.assertEqual(resp, "230 An empty list of newsarticles follows")
+ self.assertEqual(ids, [])
+
+ def _check_article_body(self, lines):
+ self.assertEqual(len(lines), 4)
+ self.assertEqual(lines[-1].decode('utf8'), "-- Signed by André.")
+ self.assertEqual(lines[-2], b"")
+ self.assertEqual(lines[-3], b".Here is a dot-starting line.")
+ self.assertEqual(lines[-4], b"This is just a test article.")
+
+ def _check_article_head(self, lines):
+ self.assertEqual(len(lines), 4)
+ self.assertEqual(lines[0], b'From: "Demo User" <nobody@example.net>')
+ self.assertEqual(lines[3], b"Message-ID: <i.am.an.article.you.will.want@example.com>")
+
+ def _check_article_data(self, lines):
+ self.assertEqual(len(lines), 9)
+ self._check_article_head(lines[:4])
+ self._check_article_body(lines[-4:])
+ self.assertEqual(lines[4], b"")
+
+ def test_article(self):
+ # ARTICLE
+ resp, info = self.server.article()
+ self.assertEqual(resp, "220 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # ARTICLE num
+ resp, info = self.server.article(3000234)
+ self.assertEqual(resp, "220 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # ARTICLE id
+ resp, info = self.server.article("<45223423@example.com>")
+ self.assertEqual(resp, "220 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_data(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.article("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def test_article_file(self):
+ # With a "file" argument
+ f = io.BytesIO()
+ resp, info = self.server.article(file=f)
+ self.assertEqual(resp, "220 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self.assertEqual(lines, [])
+ data = f.getvalue()
+ self.assertTrue(data.startswith(
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ ), ascii(data))
+ self.assertTrue(data.endswith(
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ ), ascii(data))
+
+ def test_head(self):
+ # HEAD
+ resp, info = self.server.head()
+ self.assertEqual(resp, "221 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # HEAD num
+ resp, info = self.server.head(3000234)
+ self.assertEqual(resp, "221 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # HEAD id
+ resp, info = self.server.head("<45223423@example.com>")
+ self.assertEqual(resp, "221 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_head(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.head("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def test_head_file(self):
+ f = io.BytesIO()
+ resp, info = self.server.head(file=f)
+ self.assertEqual(resp, "221 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self.assertEqual(lines, [])
+ data = f.getvalue()
+ self.assertTrue(data.startswith(
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ ), ascii(data))
+ self.assertFalse(data.endswith(
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ ), ascii(data))
+
+ def test_body(self):
+ # BODY
+ resp, info = self.server.body()
+ self.assertEqual(resp, "222 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # BODY num
+ resp, info = self.server.body(3000234)
+ self.assertEqual(resp, "222 3000234 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # BODY id
+ resp, info = self.server.body("<45223423@example.com>")
+ self.assertEqual(resp, "222 0 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 0)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self._check_article_body(lines)
+ # Non-existent id
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.body("<non-existent@example.com>")
+ self.assertEqual(cm.exception.response, "430 No Such Article Found")
+
+ def test_body_file(self):
+ f = io.BytesIO()
+ resp, info = self.server.body(file=f)
+ self.assertEqual(resp, "222 3000237 <45223423@example.com>")
+ art_num, message_id, lines = info
+ self.assertEqual(art_num, 3000237)
+ self.assertEqual(message_id, "<45223423@example.com>")
+ self.assertEqual(lines, [])
+ data = f.getvalue()
+ self.assertFalse(data.startswith(
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ ), ascii(data))
+ self.assertTrue(data.endswith(
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ ), ascii(data))
+
+ def check_over_xover_resp(self, resp, overviews):
+ self.assertTrue(resp.startswith("224 "), resp)
+ self.assertEqual(len(overviews), 3)
+ art_num, over = overviews[0]
+ self.assertEqual(art_num, 57)
+ self.assertEqual(over, {
+ "from": "Doug Hellmann <doug.hellmann-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>",
+ "subject": "Re: ANN: New Plone book with strong Python (and Zope) themes throughout",
+ "date": "Sat, 19 Jun 2010 18:04:08 -0400",
+ "message-id": "<4FD05F05-F98B-44DC-8111-C6009C925F0C@gmail.com>",
+ "references": "<hvalf7$ort$1@dough.gmane.org>",
+ ":bytes": "7103",
+ ":lines": "16",
+ "xref": "news.gmane.org gmane.comp.python.authors:57"
+ })
+ art_num, over = overviews[1]
+ self.assertEqual(over["xref"], None)
+ art_num, over = overviews[2]
+ self.assertEqual(over["subject"],
+ "Re: Message d'erreur incompréhensible (par moi)")
+
+ def test_xover(self):
+ resp, overviews = self.server.xover(57, 59)
+ self.check_over_xover_resp(resp, overviews)
+
+ def test_over(self):
+ # In NNTP "v1", this will fallback on XOVER
+ resp, overviews = self.server.over((57, 59))
+ self.check_over_xover_resp(resp, overviews)
+
+ sample_post = (
+ b'From: "Demo User" <nobody@example.net>\r\n'
+ b'Subject: I am just a test article\r\n'
+ b'Content-Type: text/plain; charset=UTF-8; format=flowed\r\n'
+ b'Message-ID: <i.am.an.article.you.will.want@example.com>\r\n'
+ b'\r\n'
+ b'This is just a test article.\r\n'
+ b'.Here is a dot-starting line.\r\n'
+ b'\r\n'
+ b'-- Signed by Andr\xc3\xa9.\r\n'
+ )
+
+ def _check_posted_body(self):
+ # Check the raw body as received by the server
+ lines = self.handler.posted_body
+ # One additional line for the "." terminator
+ self.assertEqual(len(lines), 10)
+ self.assertEqual(lines[-1], b'.\r\n')
+ self.assertEqual(lines[-2], b'-- Signed by Andr\xc3\xa9.\r\n')
+ self.assertEqual(lines[-3], b'\r\n')
+ self.assertEqual(lines[-4], b'..Here is a dot-starting line.\r\n')
+ self.assertEqual(lines[0], b'From: "Demo User" <nobody@example.net>\r\n')
+
+ def _check_post_ihave_sub(self, func, *args, file_factory):
+ # First the prepared post with CRLF endings
+ post = self.sample_post
+ func_args = args + (file_factory(post),)
+ self.handler.posted_body = None
+ resp = func(*func_args)
+ self._check_posted_body()
+ # Then the same post with "normal" line endings - they should be
+ # converted by NNTP.post and NNTP.ihave.
+ post = self.sample_post.replace(b"\r\n", b"\n")
+ func_args = args + (file_factory(post),)
+ self.handler.posted_body = None
+ resp = func(*func_args)
+ self._check_posted_body()
+ return resp
+
+ def check_post_ihave(self, func, success_resp, *args):
+ # With a bytes object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=bytes)
+ self.assertEqual(resp, success_resp)
+ # With a bytearray object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=bytearray)
+ self.assertEqual(resp, success_resp)
+ # With a file object
+ resp = self._check_post_ihave_sub(func, *args, file_factory=io.BytesIO)
+ self.assertEqual(resp, success_resp)
+ # With an iterable of terminated lines
+ def iterlines(b):
+ return iter(b.splitlines(True))
+ resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines)
+ self.assertEqual(resp, success_resp)
+ # With an iterable of non-terminated lines
+ def iterlines(b):
+ return iter(b.splitlines(False))
+ resp = self._check_post_ihave_sub(func, *args, file_factory=iterlines)
+ self.assertEqual(resp, success_resp)
+
+ def test_post(self):
+ self.check_post_ihave(self.server.post, "240 Article received OK")
+ self.handler.allow_posting = False
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.post(self.sample_post)
+ self.assertEqual(cm.exception.response,
+ "440 Posting not permitted")
+
+ def test_ihave(self):
+ self.check_post_ihave(self.server.ihave, "235 Article transferred OK",
+ "<i.am.an.article.you.will.want@example.com>")
+ with self.assertRaises(nntplib.NNTPTemporaryError) as cm:
+ self.server.ihave("<another.message.id>", self.sample_post)
+ self.assertEqual(cm.exception.response,
+ "435 Article not wanted")
+
+
+class NNTPv1Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
+ """Tests an NNTP v1 server (no capabilities)."""
+
+ nntp_version = 1
+ handler_class = NNTPv1Handler
+
+ def test_caps(self):
+ caps = self.server.getcapabilities()
+ self.assertEqual(caps, {})
+ self.assertEqual(self.server.nntp_version, 1)
+ self.assertEqual(self.server.nntp_implementation, None)
+
+
+class NNTPv2Tests(NNTPv1v2TestsMixin, MockedNNTPTestsMixin, unittest.TestCase):
+ """Tests an NNTP v2 server (with capabilities)."""
+
+ nntp_version = 2
+ handler_class = NNTPv2Handler
+
+ def test_caps(self):
+ caps = self.server.getcapabilities()
+ self.assertEqual(caps, {
+ 'VERSION': ['2', '3'],
+ 'IMPLEMENTATION': ['INN', '2.5.1'],
+ 'AUTHINFO': ['USER'],
+ 'HDR': [],
+ 'LIST': ['ACTIVE', 'ACTIVE.TIMES', 'DISTRIB.PATS',
+ 'HEADERS', 'NEWSGROUPS', 'OVERVIEW.FMT'],
+ 'OVER': [],
+ 'POST': [],
+ 'READER': [],
+ })
+ self.assertEqual(self.server.nntp_version, 3)
+ self.assertEqual(self.server.nntp_implementation, 'INN 2.5.1')
+
+
+class CapsAfterLoginNNTPv2Tests(MockedNNTPTestsMixin, unittest.TestCase):
+ """Tests a probably NNTP v2 server with capabilities only after login."""
+
+ nntp_version = 2
+ handler_class = CapsAfterLoginNNTPv2Handler
+
+ def test_caps_only_after_login(self):
+ self.assertEqual(self.server._caps, {})
+ self.server.login('testuser', 'testpw')
+ self.assertIn('VERSION', self.server._caps)
+
+
+class SendReaderNNTPv2Tests(MockedNNTPWithReaderModeMixin,
+ unittest.TestCase):
+ """Same tests as for v2 but we tell NTTP to send MODE READER to a server
+ that isn't in READER mode by default."""
+
+ nntp_version = 2
+ handler_class = ModeSwitchingNNTPv2Handler
+
+ def test_we_are_in_reader_mode_after_connect(self):
+ self.assertIn('READER', self.server._caps)
+
+
+class MiscTests(unittest.TestCase):
+
+ def test_decode_header(self):
+ def gives(a, b):
+ self.assertEqual(nntplib.decode_header(a), b)
+ gives("" , "")
+ gives("a plain header", "a plain header")
+ gives(" with extra spaces ", " with extra spaces ")
+ gives("=?ISO-8859-15?Q?D=E9buter_en_Python?=", "Débuter en Python")
+ gives("=?utf-8?q?Re=3A_=5Bsqlite=5D_probl=C3=A8me_avec_ORDER_BY_sur_des_cha?="
+ " =?utf-8?q?=C3=AEnes_de_caract=C3=A8res_accentu=C3=A9es?=",
+ "Re: [sqlite] problème avec ORDER BY sur des chaînes de caractères accentuées")
+ gives("Re: =?UTF-8?B?cHJvYmzDqG1lIGRlIG1hdHJpY2U=?=",
+ "Re: problème de matrice")
+ # A natively utf-8 header (found in the real world!)
+ gives("Re: Message d'erreur incompréhensible (par moi)",
+ "Re: Message d'erreur incompréhensible (par moi)")
+
+ def test_parse_overview_fmt(self):
+ # The minimal (default) response
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", ":bytes", ":lines"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # The minimal response using alternative names
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # Variations in casing
+ lines = ["subject:", "FROM:", "DaTe:", "message-ID:",
+ "References:", "BYTES:", "Lines:"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines"])
+ # First example from RFC 3977
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", ":bytes", ":lines", "Xref:full",
+ "Distribution:full"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref", "distribution"])
+ # Second example from RFC 3977
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:", "Xref:FULL",
+ "Distribution:FULL"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref", "distribution"])
+ # A classic response from INN
+ lines = ["Subject:", "From:", "Date:", "Message-ID:",
+ "References:", "Bytes:", "Lines:", "Xref:full"]
+ self.assertEqual(nntplib._parse_overview_fmt(lines),
+ ["subject", "from", "date", "message-id", "references",
+ ":bytes", ":lines", "xref"])
+
+ def test_parse_overview(self):
+ fmt = nntplib._DEFAULT_OVERVIEW_FMT + ["xref"]
+ # First example from RFC 3977
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t<45454@example.net>\t1234\t'
+ '17\tXref: news.example.com misc.test:3000363',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(art_num, 3000234)
+ self.assertEqual(fields, {
+ 'subject': 'I am just a test article',
+ 'from': '"Demo User" <nobody@example.com>',
+ 'date': '6 Oct 1998 04:38:40 -0500',
+ 'message-id': '<45223423@example.com>',
+ 'references': '<45454@example.net>',
+ ':bytes': '1234',
+ ':lines': '17',
+ 'xref': 'news.example.com misc.test:3000363',
+ })
+ # Second example; here the "Xref" field is totally absent (including
+ # the header name) and comes out as None
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t<45454@example.net>\t1234\t'
+ '17\t\t',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(fields['xref'], None)
+ # Third example; the "Xref" is an empty string, while "references"
+ # is a single space.
+ lines = [
+ '3000234\tI am just a test article\t"Demo User" '
+ '<nobody@example.com>\t6 Oct 1998 04:38:40 -0500\t'
+ '<45223423@example.com>\t \t1234\t'
+ '17\tXref: \t',
+ ]
+ overview = nntplib._parse_overview(lines, fmt)
+ (art_num, fields), = overview
+ self.assertEqual(fields['references'], ' ')
+ self.assertEqual(fields['xref'], '')
+
+ def test_parse_datetime(self):
+ def gives(a, b, *c):
+ self.assertEqual(nntplib._parse_datetime(a, b),
+ datetime.datetime(*c))
+ # Output of DATE command
+ gives("19990623135624", None, 1999, 6, 23, 13, 56, 24)
+ # Variations
+ gives("19990623", "135624", 1999, 6, 23, 13, 56, 24)
+ gives("990623", "135624", 1999, 6, 23, 13, 56, 24)
+ gives("090623", "135624", 2009, 6, 23, 13, 56, 24)
+
+ def test_unparse_datetime(self):
+ # Test non-legacy mode
+ # 1) with a datetime
+ def gives(y, M, d, h, m, s, date_str, time_str):
+ dt = datetime.datetime(y, M, d, h, m, s)
+ self.assertEqual(nntplib._unparse_datetime(dt),
+ (date_str, time_str))
+ self.assertEqual(nntplib._unparse_datetime(dt, False),
+ (date_str, time_str))
+ gives(1999, 6, 23, 13, 56, 24, "19990623", "135624")
+ gives(2000, 6, 23, 13, 56, 24, "20000623", "135624")
+ gives(2010, 6, 5, 1, 2, 3, "20100605", "010203")
+ # 2) with a date
+ def gives(y, M, d, date_str, time_str):
+ dt = datetime.date(y, M, d)
+ self.assertEqual(nntplib._unparse_datetime(dt),
+ (date_str, time_str))
+ self.assertEqual(nntplib._unparse_datetime(dt, False),
+ (date_str, time_str))
+ gives(1999, 6, 23, "19990623", "000000")
+ gives(2000, 6, 23, "20000623", "000000")
+ gives(2010, 6, 5, "20100605", "000000")
+
+ def test_unparse_datetime_legacy(self):
+ # Test legacy mode (RFC 977)
+ # 1) with a datetime
+ def gives(y, M, d, h, m, s, date_str, time_str):
+ dt = datetime.datetime(y, M, d, h, m, s)
+ self.assertEqual(nntplib._unparse_datetime(dt, True),
+ (date_str, time_str))
+ gives(1999, 6, 23, 13, 56, 24, "990623", "135624")
+ gives(2000, 6, 23, 13, 56, 24, "000623", "135624")
+ gives(2010, 6, 5, 1, 2, 3, "100605", "010203")
+ # 2) with a date
+ def gives(y, M, d, date_str, time_str):
+ dt = datetime.date(y, M, d)
+ self.assertEqual(nntplib._unparse_datetime(dt, True),
+ (date_str, time_str))
+ gives(1999, 6, 23, "990623", "000000")
+ gives(2000, 6, 23, "000623", "000000")
+ gives(2010, 6, 5, "100605", "000000")
+
+
+def test_main():
+ tests = [MiscTests, NNTPv1Tests, NNTPv2Tests, CapsAfterLoginNNTPv2Tests,
+ SendReaderNNTPv2Tests, NetworkedNNTPTests]
+ if _have_ssl:
+ tests.append(NetworkedNNTP_SSLTests)
+ support.run_unittest(*tests)
+
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_normalization.py b/Lib/test/test_normalization.py
index 3040a086187..e3e25603564 100644
--- a/Lib/test/test_normalization.py
+++ b/Lib/test/test_normalization.py
@@ -1,7 +1,7 @@
-from test.test_support import run_unittest, open_urlresource
+from test.support import run_unittest, open_urlresource
import unittest
-from httplib import HTTPException
+from http.client import HTTPException
import sys
import os
from unicodedata import normalize, unidata_version
@@ -33,7 +33,7 @@ def unistr(data):
for x in data:
if x > sys.maxunicode:
raise RangeError
- return u"".join([unichr(x) for x in data])
+ return "".join([chr(x) for x in data])
class NormalizationTest(unittest.TestCase):
def test_main(self):
@@ -41,9 +41,11 @@ class NormalizationTest(unittest.TestCase):
part1_data = {}
# Hit the exception early
try:
- testdata = open_urlresource(TESTDATAURL, check_version)
+ testdata = open_urlresource(TESTDATAURL, encoding="utf-8",
+ check=check_version)
except (IOError, HTTPException):
self.skipTest("Could not retrieve " + TESTDATAURL)
+ self.addCleanup(testdata.close)
for line in testdata:
if '#' in line:
line = line.split('#')[0]
@@ -85,14 +87,14 @@ class NormalizationTest(unittest.TestCase):
# Perform tests for all other data
for c in range(sys.maxunicode+1):
- X = unichr(c)
+ X = chr(c)
if X in part1_data:
continue
self.assertTrue(X == NFC(X) == NFD(X) == NFKC(X) == NFKD(X), c)
def test_bug_834676(self):
# Check for bug 834676
- normalize('NFC', u'\ud55c\uae00')
+ normalize('NFC', '\ud55c\uae00')
def test_main():
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index e1852c0eb7f..64649509823 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -1,7 +1,9 @@
import ntpath
import os
-from test.test_support import TestFailed
-from test import test_support, test_genericpath
+import sys
+from test.support import TestFailed
+from test import support, test_genericpath
+from tempfile import TemporaryFile
import unittest
@@ -9,8 +11,26 @@ def tester(fn, wantResult):
fn = fn.replace("\\", "\\\\")
gotResult = eval(fn)
if wantResult != gotResult:
- raise TestFailed, "%s should return: %s but returned: %s" \
- %(str(fn), str(wantResult), str(gotResult))
+ raise TestFailed("%s should return: %s but returned: %s" \
+ %(str(fn), str(wantResult), str(gotResult)))
+
+ # then with bytes
+ fn = fn.replace("('", "(b'")
+ fn = fn.replace('("', '(b"')
+ fn = fn.replace("['", "[b'")
+ fn = fn.replace('["', '[b"')
+ fn = fn.replace(", '", ", b'")
+ fn = fn.replace(', "', ', b"')
+ gotResult = eval(fn)
+ if isinstance(wantResult, str):
+ wantResult = wantResult.encode('ascii')
+ elif isinstance(wantResult, tuple):
+ wantResult = tuple(r.encode('ascii') for r in wantResult)
+
+ gotResult = eval(fn)
+ if wantResult != gotResult:
+ raise TestFailed("%s should return: %s but returned: %s" \
+ %(str(fn), str(wantResult), repr(gotResult)))
class TestNtpath(unittest.TestCase):
@@ -31,12 +51,18 @@ class TestNtpath(unittest.TestCase):
('c:', '\\foo\\bar'))
tester('ntpath.splitdrive("c:/foo/bar")',
('c:', '/foo/bar'))
-
- def test_splitunc(self):
- tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")',
+ tester('ntpath.splitdrive("\\\\conky\\mountpoint\\foo\\bar")',
('\\\\conky\\mountpoint', '\\foo\\bar'))
- tester('ntpath.splitunc("//conky/mountpoint/foo/bar")',
+ tester('ntpath.splitdrive("//conky/mountpoint/foo/bar")',
('//conky/mountpoint', '/foo/bar'))
+ tester('ntpath.splitdrive("\\\\\\conky\\mountpoint\\foo\\bar")',
+ ('', '\\\\\\conky\\mountpoint\\foo\\bar'))
+ tester('ntpath.splitdrive("///conky/mountpoint/foo/bar")',
+ ('', '///conky/mountpoint/foo/bar'))
+ tester('ntpath.splitdrive("\\\\conky\\\\mountpoint\\foo\\bar")',
+ ('', '\\\\conky\\\\mountpoint\\foo\\bar'))
+ tester('ntpath.splitdrive("//conky//mountpoint/foo/bar")',
+ ('', '//conky//mountpoint/foo/bar'))
def test_split(self):
tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar'))
@@ -45,10 +71,10 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.split("c:\\")', ('c:\\', ''))
tester('ntpath.split("\\\\conky\\mountpoint\\")',
- ('\\\\conky\\mountpoint', ''))
+ ('\\\\conky\\mountpoint\\', ''))
tester('ntpath.split("c:/")', ('c:/', ''))
- tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint', ''))
+ tester('ntpath.split("//conky/mountpoint/")', ('//conky/mountpoint/', ''))
def test_isabs(self):
tester('ntpath.isabs("c:\\")', 1)
@@ -99,6 +125,33 @@ class TestNtpath(unittest.TestCase):
tester("ntpath.join('a\\', '')", 'a\\')
tester("ntpath.join('a\\', '', '', '', '')", 'a\\')
+ # from comment in ntpath.join
+ tester("ntpath.join('c:', '/a')", 'c:/a')
+ tester("ntpath.join('//computer/share', '/a')", '//computer/share/a')
+ tester("ntpath.join('c:/', '/a')", 'c:/a')
+ tester("ntpath.join('//computer/share/', '/a')", '//computer/share/a')
+ tester("ntpath.join('c:/a', '/b')", '/b')
+ tester("ntpath.join('//computer/share/a', '/b')", '/b')
+ tester("ntpath.join('c:', 'd:/')", 'd:/')
+ tester("ntpath.join('c:', '//computer/share/')", '//computer/share/')
+ tester("ntpath.join('//computer/share', 'd:/')", 'd:/')
+ tester("ntpath.join('//computer/share', '//computer/share/')", '//computer/share/')
+ tester("ntpath.join('c:/', 'd:/')", 'd:/')
+ tester("ntpath.join('c:/', '//computer/share/')", '//computer/share/')
+ tester("ntpath.join('//computer/share/', 'd:/')", 'd:/')
+ tester("ntpath.join('//computer/share/', '//computer/share/')", '//computer/share/')
+
+ tester("ntpath.join('c:', '//computer/share/')", '//computer/share/')
+ tester("ntpath.join('c:/', '//computer/share/')", '//computer/share/')
+ tester("ntpath.join('c:/', '//computer/share/a/b')", '//computer/share/a/b')
+
+ tester("ntpath.join('\\\\computer\\share\\', 'a', 'b')", '\\\\computer\\share\\a\\b')
+ tester("ntpath.join('\\\\computer\\share', 'a', 'b')", '\\\\computer\\share\\a\\b')
+ tester("ntpath.join('\\\\computer\\share', 'a\\b')", '\\\\computer\\share\\a\\b')
+ tester("ntpath.join('//computer/share/', 'a', 'b')", '//computer/share/a\\b')
+ tester("ntpath.join('//computer/share', 'a', 'b')", '//computer/share\\a\\b')
+ tester("ntpath.join('//computer/share', 'a/b')", '//computer/share\\a/b')
+
def test_normpath(self):
tester("ntpath.normpath('A//////././//.//B')", r'A\B')
tester("ntpath.normpath('A/./B')", r'A\B')
@@ -127,7 +180,7 @@ class TestNtpath(unittest.TestCase):
tester("ntpath.normpath('\\\\?\\D:/XY\\Z')", r'\\?\D:/XY\Z')
def test_expandvars(self):
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env.clear()
env["foo"] = "bar"
env["{foo"] = "baz1"
@@ -158,14 +211,11 @@ class TestNtpath(unittest.TestCase):
# the rest of the tests for the ntpath module to be run to completion
# on any platform, since most of the module is intended to be usable
# from any platform.
- # XXX this needs more tests
try:
import nt
- except ImportError:
- # check that the function is there even if we are not on Windows
- ntpath.abspath
- else:
tester('ntpath.abspath("C:\\")', "C:\\")
+ except ImportError:
+ pass
def test_relpath(self):
currentdir = os.path.split(os.getcwd())[-1]
@@ -176,6 +226,7 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.relpath("a", "../b")', '..\\'+currentdir+'\\a')
tester('ntpath.relpath("a/b", "../c")', '..\\'+currentdir+'\\a\\b')
tester('ntpath.relpath("a", "b/c")', '..\\..\\a')
+ tester('ntpath.relpath("c:/foo/bar/bat", "c:/x/y")', '..\\..\\foo\\bar\\bat')
tester('ntpath.relpath("//conky/mountpoint/a", "//conky/mountpoint/b/c")', '..\\..\\a')
tester('ntpath.relpath("a", "a")', '.')
tester('ntpath.relpath("/foo/bar/bat", "/x/y/z")', '..\\..\\..\\foo\\bar\\bat')
@@ -189,6 +240,19 @@ class TestNtpath(unittest.TestCase):
tester('ntpath.relpath("/a/b", "/a/b")', '.')
tester('ntpath.relpath("c:/foo", "C:/FOO")', '.')
+ def test_sameopenfile(self):
+ with TemporaryFile() as tf1, TemporaryFile() as tf2:
+ # Make sure the same file is really the same
+ self.assertTrue(ntpath.sameopenfile(tf1.fileno(), tf1.fileno()))
+ # Make sure different files are really different
+ self.assertFalse(ntpath.sameopenfile(tf1.fileno(), tf2.fileno()))
+ # Make sure invalid values don't cause issues on win32
+ if sys.platform == "win32":
+ with self.assertRaises(OSError):
+ # Invalid file descriptors shouldn't display assert
+ # dialogs (#4804)
+ ntpath.sameopenfile(-1, -1)
+
class NtCommonTest(test_genericpath.CommonTest):
pathmodule = ntpath
@@ -196,7 +260,7 @@ class NtCommonTest(test_genericpath.CommonTest):
def test_main():
- test_support.run_unittest(TestNtpath, NtCommonTest)
+ support.run_unittest(TestNtpath, NtCommonTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_numeric_tower.py b/Lib/test/test_numeric_tower.py
new file mode 100644
index 00000000000..bef3d4c35de
--- /dev/null
+++ b/Lib/test/test_numeric_tower.py
@@ -0,0 +1,206 @@
+# test interactions between int, float, Decimal and Fraction
+
+import unittest
+import random
+import math
+import sys
+import operator
+from test.support import run_unittest
+
+from decimal import Decimal as D
+from fractions import Fraction as F
+
+# Constants related to the hash implementation; hash(x) is based
+# on the reduction of x modulo the prime _PyHASH_MODULUS.
+_PyHASH_MODULUS = sys.hash_info.modulus
+_PyHASH_INF = sys.hash_info.inf
+
+class HashTest(unittest.TestCase):
+ def check_equal_hash(self, x, y):
+ # check both that x and y are equal and that their hashes are equal
+ self.assertEqual(hash(x), hash(y),
+ "got different hashes for {!r} and {!r}".format(x, y))
+ self.assertEqual(x, y)
+
+ def test_bools(self):
+ self.check_equal_hash(False, 0)
+ self.check_equal_hash(True, 1)
+
+ def test_integers(self):
+ # check that equal values hash equal
+
+ # exact integers
+ for i in range(-1000, 1000):
+ self.check_equal_hash(i, float(i))
+ self.check_equal_hash(i, D(i))
+ self.check_equal_hash(i, F(i))
+
+ # the current hash is based on reduction modulo 2**n-1 for some
+ # n, so pay special attention to numbers of the form 2**n and 2**n-1.
+ for i in range(100):
+ n = 2**i - 1
+ if n == int(float(n)):
+ self.check_equal_hash(n, float(n))
+ self.check_equal_hash(-n, -float(n))
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ self.check_equal_hash(-n, D(-n))
+ self.check_equal_hash(-n, F(-n))
+
+ n = 2**i
+ self.check_equal_hash(n, float(n))
+ self.check_equal_hash(-n, -float(n))
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ self.check_equal_hash(-n, D(-n))
+ self.check_equal_hash(-n, F(-n))
+
+ # random values of various sizes
+ for _ in range(1000):
+ e = random.randrange(300)
+ n = random.randrange(-10**e, 10**e)
+ self.check_equal_hash(n, D(n))
+ self.check_equal_hash(n, F(n))
+ if n == int(float(n)):
+ self.check_equal_hash(n, float(n))
+
+ def test_binary_floats(self):
+ # check that floats hash equal to corresponding Fractions and Decimals
+
+ # floats that are distinct but numerically equal should hash the same
+ self.check_equal_hash(0.0, -0.0)
+
+ # zeros
+ self.check_equal_hash(0.0, D(0))
+ self.check_equal_hash(-0.0, D(0))
+ self.check_equal_hash(-0.0, D('-0.0'))
+ self.check_equal_hash(0.0, F(0))
+
+ # infinities and nans
+ self.check_equal_hash(float('inf'), D('inf'))
+ self.check_equal_hash(float('-inf'), D('-inf'))
+
+ for _ in range(1000):
+ x = random.random() * math.exp(random.random()*200.0 - 100.0)
+ self.check_equal_hash(x, D.from_float(x))
+ self.check_equal_hash(x, F.from_float(x))
+
+ def test_complex(self):
+ # complex numbers with zero imaginary part should hash equal to
+ # the corresponding float
+
+ test_values = [0.0, -0.0, 1.0, -1.0, 0.40625, -5136.5,
+ float('inf'), float('-inf')]
+
+ for zero in -0.0, 0.0:
+ for value in test_values:
+ self.check_equal_hash(value, complex(value, zero))
+
+ def test_decimals(self):
+ # check that Decimal instances that have different representations
+ # but equal values give the same hash
+ zeros = ['0', '-0', '0.0', '-0.0e10', '000e-10']
+ for zero in zeros:
+ self.check_equal_hash(D(zero), D(0))
+
+ self.check_equal_hash(D('1.00'), D(1))
+ self.check_equal_hash(D('1.00000'), D(1))
+ self.check_equal_hash(D('-1.00'), D(-1))
+ self.check_equal_hash(D('-1.00000'), D(-1))
+ self.check_equal_hash(D('123e2'), D(12300))
+ self.check_equal_hash(D('1230e1'), D(12300))
+ self.check_equal_hash(D('12300'), D(12300))
+ self.check_equal_hash(D('12300.0'), D(12300))
+ self.check_equal_hash(D('12300.00'), D(12300))
+ self.check_equal_hash(D('12300.000'), D(12300))
+
+ def test_fractions(self):
+ # check special case for fractions where either the numerator
+ # or the denominator is a multiple of _PyHASH_MODULUS
+ self.assertEqual(hash(F(1, _PyHASH_MODULUS)), _PyHASH_INF)
+ self.assertEqual(hash(F(-1, 3*_PyHASH_MODULUS)), -_PyHASH_INF)
+ self.assertEqual(hash(F(7*_PyHASH_MODULUS, 1)), 0)
+ self.assertEqual(hash(F(-_PyHASH_MODULUS, 1)), 0)
+
+ def test_hash_normalization(self):
+ # Test for a bug encountered while changing long_hash.
+ #
+ # Given objects x and y, it should be possible for y's
+ # __hash__ method to return hash(x) in order to ensure that
+ # hash(x) == hash(y). But hash(x) is not exactly equal to the
+ # result of x.__hash__(): there's some internal normalization
+ # to make sure that the result fits in a C long, and is not
+ # equal to the invalid hash value -1. This internal
+ # normalization must therefore not change the result of
+ # hash(x) for any x.
+
+ class HalibutProxy:
+ def __hash__(self):
+ return hash('halibut')
+ def __eq__(self, other):
+ return other == 'halibut'
+
+ x = {'halibut', HalibutProxy()}
+ self.assertEqual(len(x), 1)
+
+class ComparisonTest(unittest.TestCase):
+ def test_mixed_comparisons(self):
+
+ # ordered list of distinct test values of various types:
+ # int, float, Fraction, Decimal
+ test_values = [
+ float('-inf'),
+ D('-1e999999999'),
+ -1e308,
+ F(-22, 7),
+ -3.14,
+ -2,
+ 0.0,
+ 1e-320,
+ True,
+ F('1.2'),
+ D('1.3'),
+ float('1.4'),
+ F(275807, 195025),
+ D('1.414213562373095048801688724'),
+ F(114243, 80782),
+ F(473596569, 84615),
+ 7e200,
+ D('infinity'),
+ ]
+ for i, first in enumerate(test_values):
+ for second in test_values[i+1:]:
+ self.assertLess(first, second)
+ self.assertLessEqual(first, second)
+ self.assertGreater(second, first)
+ self.assertGreaterEqual(second, first)
+
+ def test_complex(self):
+ # comparisons with complex are special: equality and inequality
+ # comparisons should always succeed, but order comparisons should
+ # raise TypeError.
+ z = 1.0 + 0j
+ w = -3.14 + 2.7j
+
+ for v in 1, 1.0, F(1), D(1), complex(1):
+ self.assertEqual(z, v)
+ self.assertEqual(v, z)
+
+ for v in 2, 2.0, F(2), D(2), complex(2):
+ self.assertNotEqual(z, v)
+ self.assertNotEqual(v, z)
+ self.assertNotEqual(w, v)
+ self.assertNotEqual(v, w)
+
+ for v in (1, 1.0, F(1), D(1), complex(1),
+ 2, 2.0, F(2), D(2), complex(2), w):
+ for op in operator.le, operator.lt, operator.ge, operator.gt:
+ self.assertRaises(TypeError, op, z, v)
+ self.assertRaises(TypeError, op, v, z)
+
+
+def test_main():
+ run_unittest(HashTest, ComparisonTest)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_old_mailbox.py b/Lib/test/test_old_mailbox.py
deleted file mode 100644
index 14ba9c08631..00000000000
--- a/Lib/test/test_old_mailbox.py
+++ /dev/null
@@ -1,160 +0,0 @@
-# This set of tests exercises the backward-compatibility class
-# in mailbox.py (the ones without write support).
-
-import mailbox
-import os
-import time
-import unittest
-from test import test_support
-
-# cleanup earlier tests
-try:
- os.unlink(test_support.TESTFN)
-except os.error:
- pass
-
-FROM_ = "From some.body@dummy.domain Sat Jul 24 13:43:35 2004\n"
-DUMMY_MESSAGE = """\
-From: some.body@dummy.domain
-To: me@my.domain
-Subject: Simple Test
-
-This is a dummy message.
-"""
-
-class MaildirTestCase(unittest.TestCase):
-
- def setUp(self):
- # create a new maildir mailbox to work with:
- self._dir = test_support.TESTFN
- os.mkdir(self._dir)
- os.mkdir(os.path.join(self._dir, "cur"))
- os.mkdir(os.path.join(self._dir, "tmp"))
- os.mkdir(os.path.join(self._dir, "new"))
- self._counter = 1
- self._msgfiles = []
-
- def tearDown(self):
- map(os.unlink, self._msgfiles)
- os.rmdir(os.path.join(self._dir, "cur"))
- os.rmdir(os.path.join(self._dir, "tmp"))
- os.rmdir(os.path.join(self._dir, "new"))
- os.rmdir(self._dir)
-
- def createMessage(self, dir, mbox=False):
- t = int(time.time() % 1000000)
- pid = self._counter
- self._counter += 1
- filename = os.extsep.join((str(t), str(pid), "myhostname", "mydomain"))
- tmpname = os.path.join(self._dir, "tmp", filename)
- newname = os.path.join(self._dir, dir, filename)
- with open(tmpname, "w") as fp:
- self._msgfiles.append(tmpname)
- if mbox:
- fp.write(FROM_)
- fp.write(DUMMY_MESSAGE)
- if hasattr(os, "link"):
- os.link(tmpname, newname)
- else:
- with open(newname, "w") as fp:
- fp.write(DUMMY_MESSAGE)
- self._msgfiles.append(newname)
- return tmpname
-
- def test_empty_maildir(self):
- """Test an empty maildir mailbox"""
- # Test for regression on bug #117490:
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- self.assertTrue(len(self.mbox) == 0)
- self.assertTrue(self.mbox.next() is None)
- self.assertTrue(self.mbox.next() is None)
-
- def test_nonempty_maildir_cur(self):
- self.createMessage("cur")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- self.assertTrue(len(self.mbox) == 1)
- msg = self.mbox.next()
- self.assertTrue(msg is not None)
- msg.fp.close()
- self.assertTrue(self.mbox.next() is None)
- self.assertTrue(self.mbox.next() is None)
-
- def test_nonempty_maildir_new(self):
- self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- self.assertTrue(len(self.mbox) == 1)
- msg = self.mbox.next()
- self.assertTrue(msg is not None)
- msg.fp.close()
- self.assertTrue(self.mbox.next() is None)
- self.assertTrue(self.mbox.next() is None)
-
- def test_nonempty_maildir_both(self):
- self.createMessage("cur")
- self.createMessage("new")
- self.mbox = mailbox.Maildir(test_support.TESTFN)
- self.assertTrue(len(self.mbox) == 2)
- msg = self.mbox.next()
- self.assertTrue(msg is not None)
- msg.fp.close()
- msg = self.mbox.next()
- self.assertTrue(msg is not None)
- msg.fp.close()
- self.assertTrue(self.mbox.next() is None)
- self.assertTrue(self.mbox.next() is None)
-
- def test_unix_mbox(self):
- ### should be better!
- import email.parser
- fname = self.createMessage("cur", True)
- n = 0
- with open(fname) as f:
- for msg in mailbox.PortableUnixMailbox(f,
- email.parser.Parser().parse):
- n += 1
- self.assertEqual(msg["subject"], "Simple Test")
- self.assertEqual(len(str(msg)), len(FROM_)+len(DUMMY_MESSAGE))
- self.assertEqual(n, 1)
-
-class MboxTestCase(unittest.TestCase):
- def setUp(self):
- # create a new maildir mailbox to work with:
- self._path = test_support.TESTFN
-
- def tearDown(self):
- os.unlink(self._path)
-
- def test_from_regex (self):
- # Testing new regex from bug #1633678
- with open(self._path, 'w') as f:
- f.write("""From fred@example.com Mon May 31 13:24:50 2004 +0200
-Subject: message 1
-
-body1
-From fred@example.com Mon May 31 13:24:50 2004 -0200
-Subject: message 2
-
-body2
-From fred@example.com Mon May 31 13:24:50 2004
-Subject: message 3
-
-body3
-From fred@example.com Mon May 31 13:24:50 2004
-Subject: message 4
-
-body4
-""")
- with open(self._path, 'r') as f:
- box = mailbox.UnixMailbox(f)
- self.assertTrue(len(list(iter(box))) == 4)
-
-
- # XXX We still need more tests!
-
-
-def test_main():
- test_support.run_unittest(MaildirTestCase, MboxTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py
index 6d117d62b1b..f510bac9f02 100644
--- a/Lib/test/test_opcodes.py
+++ b/Lib/test/test_opcodes.py
@@ -1,6 +1,6 @@
# Python test set -- part 2, opcodes
-from test.test_support import run_unittest, check_py3k_warnings
+from test.support import run_unittest
import unittest
class OpcodeTest(unittest.TestCase):
@@ -9,7 +9,7 @@ class OpcodeTest(unittest.TestCase):
n = 0
for i in range(10):
n = n+i
- try: 1 // 0
+ try: 1/0
except NameError: pass
except ZeroDivisionError: pass
except TypeError: pass
@@ -23,9 +23,9 @@ class OpcodeTest(unittest.TestCase):
def test_raise_class_exceptions(self):
- class AClass: pass
+ class AClass(Exception): pass
class BClass(AClass): pass
- class CClass: pass
+ class CClass(Exception): pass
class DClass(AClass):
def __init__(self, ignore):
pass
@@ -46,24 +46,20 @@ class OpcodeTest(unittest.TestCase):
a = AClass()
b = BClass()
- try: raise AClass, b
- except BClass, v:
- self.assertEqual(v, b)
- else: self.fail("no exception")
-
- try: raise b
- except AClass, v:
+ try:
+ raise b
+ except AClass as v:
self.assertEqual(v, b)
else:
self.fail("no exception")
# not enough arguments
- try: raise BClass, a
- except TypeError: pass
- else: self.fail("no exception")
+ ##try: raise BClass, a
+ ##except TypeError: pass
+ ##else: self.fail("no exception")
- try: raise DClass, a
- except DClass, v:
+ try: raise DClass(a)
+ except DClass as v:
self.assertIsInstance(v, DClass)
else:
self.fail("no exception")
@@ -110,12 +106,7 @@ class OpcodeTest(unittest.TestCase):
def test_main():
- with check_py3k_warnings(("exceptions must derive from BaseException",
- DeprecationWarning),
- ("catching classes that don't inherit "
- "from BaseException is not allowed",
- DeprecationWarning)):
- run_unittest(OpcodeTest)
+ run_unittest(OpcodeTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_openpty.py b/Lib/test/test_openpty.py
index 20c4fe239c2..e8175ff094d 100644
--- a/Lib/test/test_openpty.py
+++ b/Lib/test/test_openpty.py
@@ -1,10 +1,10 @@
# Test to see if openpty works. (But don't worry if it isn't available.)
import os, unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
if not hasattr(os, "openpty"):
- raise unittest.SkipTest, "No openpty() available."
+ raise unittest.SkipTest("No openpty() available.")
class OpenptyTest(unittest.TestCase):
@@ -13,8 +13,8 @@ class OpenptyTest(unittest.TestCase):
if not os.isatty(slave):
self.fail("Slave-end of pty is not a terminal.")
- os.write(slave, 'Ping!')
- self.assertEqual(os.read(master, 1024), 'Ping!')
+ os.write(slave, b'Ping!')
+ self.assertEqual(os.read(master, 1024), b'Ping!')
def test_main():
run_unittest(OpenptyTest)
diff --git a/Lib/test/test_operator.py b/Lib/test/test_operator.py
index 81a80201d44..fa608b9a52d 100644
--- a/Lib/test/test_operator.py
+++ b/Lib/test/test_operator.py
@@ -1,7 +1,7 @@
import operator
import unittest
-from test import test_support
+from test import support
class Seq1:
def __init__(self, lst):
@@ -57,7 +57,6 @@ class OperatorTestCase(unittest.TestCase):
class C(object):
def __eq__(self, other):
raise SyntaxError
- __hash__ = None # Silence Py3k warning
self.assertRaises(TypeError, operator.eq)
self.assertRaises(SyntaxError, operator.eq, C(), C())
self.assertFalse(operator.eq(1, 0))
@@ -103,8 +102,8 @@ class OperatorTestCase(unittest.TestCase):
def test_abs(self):
self.assertRaises(TypeError, operator.abs)
self.assertRaises(TypeError, operator.abs, None)
- self.assertTrue(operator.abs(-1) == 1)
- self.assertTrue(operator.abs(1) == 1)
+ self.assertEqual(operator.abs(-1), 1)
+ self.assertEqual(operator.abs(1), 1)
def test_add(self):
self.assertRaises(TypeError, operator.add)
@@ -138,20 +137,6 @@ class OperatorTestCase(unittest.TestCase):
self.assertTrue(operator.delitem(a, 1) is None)
self.assertTrue(a == [4, 2, 1])
- def test_delslice(self):
- a = range(10)
- self.assertRaises(TypeError, operator.delslice, a)
- self.assertRaises(TypeError, operator.delslice, a, None, None)
- self.assertTrue(operator.delslice(a, 2, 8) is None)
- self.assertTrue(a == [0, 1, 8, 9])
- operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
- self.assertTrue(a == [])
-
- def test_div(self):
- self.assertRaises(TypeError, operator.div, 5)
- self.assertRaises(TypeError, operator.div, None, None)
- self.assertTrue(operator.floordiv(5, 2) == 2)
-
def test_floordiv(self):
self.assertRaises(TypeError, operator.floordiv, 5)
self.assertRaises(TypeError, operator.floordiv, None, None)
@@ -168,14 +153,6 @@ class OperatorTestCase(unittest.TestCase):
self.assertRaises(TypeError, operator.getitem, a, None)
self.assertTrue(operator.getitem(a, 2) == 2)
- def test_getslice(self):
- a = range(10)
- self.assertRaises(TypeError, operator.getslice)
- self.assertRaises(TypeError, operator.getslice, a, None, None)
- self.assertTrue(operator.getslice(a, 4, 6) == [4, 5])
- b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
- self.assertTrue(b == a)
-
def test_indexOf(self):
self.assertRaises(TypeError, operator.indexOf)
self.assertRaises(TypeError, operator.indexOf, None, None)
@@ -185,45 +162,7 @@ class OperatorTestCase(unittest.TestCase):
def test_invert(self):
self.assertRaises(TypeError, operator.invert)
self.assertRaises(TypeError, operator.invert, None)
- self.assertTrue(operator.inv(4) == -5)
-
- def test_isCallable(self):
- self.assertRaises(TypeError, operator.isCallable)
- class C:
- pass
- def check(self, o, v):
- with test_support.check_py3k_warnings():
- self.assertEqual(operator.isCallable(o), v)
- self.assertEqual(callable(o), v)
- check(self, 4, 0)
- check(self, operator.isCallable, 1)
- check(self, C, 1)
- check(self, C(), 0)
-
- def test_isMappingType(self):
- self.assertRaises(TypeError, operator.isMappingType)
- self.assertFalse(operator.isMappingType(1))
- self.assertFalse(operator.isMappingType(operator.isMappingType))
- self.assertTrue(operator.isMappingType(operator.__dict__))
- self.assertTrue(operator.isMappingType({}))
-
- def test_isNumberType(self):
- self.assertRaises(TypeError, operator.isNumberType)
- self.assertTrue(operator.isNumberType(8))
- self.assertTrue(operator.isNumberType(8j))
- self.assertTrue(operator.isNumberType(8L))
- self.assertTrue(operator.isNumberType(8.3))
- self.assertFalse(operator.isNumberType(dir()))
-
- def test_isSequenceType(self):
- self.assertRaises(TypeError, operator.isSequenceType)
- self.assertTrue(operator.isSequenceType(dir()))
- self.assertTrue(operator.isSequenceType(()))
- self.assertTrue(operator.isSequenceType(xrange(10)))
- self.assertTrue(operator.isSequenceType('yeahbuddy'))
- self.assertFalse(operator.isSequenceType(3))
- class Dict(dict): pass
- self.assertFalse(operator.isSequenceType(Dict()))
+ self.assertEqual(operator.inv(4), -5)
def test_lshift(self):
self.assertRaises(TypeError, operator.lshift)
@@ -245,10 +184,10 @@ class OperatorTestCase(unittest.TestCase):
def test_neg(self):
self.assertRaises(TypeError, operator.neg)
self.assertRaises(TypeError, operator.neg, None)
- self.assertTrue(operator.neg(5) == -5)
- self.assertTrue(operator.neg(-5) == 5)
- self.assertTrue(operator.neg(0) == 0)
- self.assertTrue(operator.neg(-0) == 0)
+ self.assertEqual(operator.neg(5), -5)
+ self.assertEqual(operator.neg(-5), 5)
+ self.assertEqual(operator.neg(0), 0)
+ self.assertEqual(operator.neg(-0), 0)
def test_bitwise_or(self):
self.assertRaises(TypeError, operator.or_)
@@ -258,44 +197,19 @@ class OperatorTestCase(unittest.TestCase):
def test_pos(self):
self.assertRaises(TypeError, operator.pos)
self.assertRaises(TypeError, operator.pos, None)
- self.assertTrue(operator.pos(5) == 5)
- self.assertTrue(operator.pos(-5) == -5)
- self.assertTrue(operator.pos(0) == 0)
- self.assertTrue(operator.pos(-0) == 0)
+ self.assertEqual(operator.pos(5), 5)
+ self.assertEqual(operator.pos(-5), -5)
+ self.assertEqual(operator.pos(0), 0)
+ self.assertEqual(operator.pos(-0), 0)
def test_pow(self):
self.assertRaises(TypeError, operator.pow)
self.assertRaises(TypeError, operator.pow, None, None)
- self.assertTrue(operator.pow(3,5) == 3**5)
- self.assertTrue(operator.__pow__(3,5) == 3**5)
+ self.assertEqual(operator.pow(3,5), 3**5)
+ self.assertEqual(operator.__pow__(3,5), 3**5)
self.assertRaises(TypeError, operator.pow, 1)
self.assertRaises(TypeError, operator.pow, 1, 2, 3)
- def test_repeat(self):
- a = range(3)
- self.assertRaises(TypeError, operator.repeat)
- self.assertRaises(TypeError, operator.repeat, a, None)
- self.assertTrue(operator.repeat(a, 2) == a+a)
- self.assertTrue(operator.repeat(a, 1) == a)
- self.assertTrue(operator.repeat(a, 0) == [])
- a = (1, 2, 3)
- self.assertTrue(operator.repeat(a, 2) == a+a)
- self.assertTrue(operator.repeat(a, 1) == a)
- self.assertTrue(operator.repeat(a, 0) == ())
- a = '123'
- self.assertTrue(operator.repeat(a, 2) == a+a)
- self.assertTrue(operator.repeat(a, 1) == a)
- self.assertTrue(operator.repeat(a, 0) == '')
- a = Seq1([4, 5, 6])
- self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6])
- self.assertTrue(operator.repeat(a, 1) == [4, 5, 6])
- self.assertTrue(operator.repeat(a, 0) == [])
- a = Seq2([4, 5, 6])
- self.assertTrue(operator.repeat(a, 2) == [4, 5, 6, 4, 5, 6])
- self.assertTrue(operator.repeat(a, 1) == [4, 5, 6])
- self.assertTrue(operator.repeat(a, 0) == [])
- self.assertRaises(TypeError, operator.repeat, 6, 7)
-
def test_rshift(self):
self.assertRaises(TypeError, operator.rshift)
self.assertRaises(TypeError, operator.rshift, None, 42)
@@ -308,27 +222,15 @@ class OperatorTestCase(unittest.TestCase):
self.assertRaises(TypeError, operator.contains, None, None)
self.assertTrue(operator.contains(range(4), 2))
self.assertFalse(operator.contains(range(4), 5))
- with test_support.check_py3k_warnings():
- self.assertTrue(operator.sequenceIncludes(range(4), 2))
- self.assertFalse(operator.sequenceIncludes(range(4), 5))
def test_setitem(self):
- a = range(3)
+ a = list(range(3))
self.assertRaises(TypeError, operator.setitem, a)
self.assertRaises(TypeError, operator.setitem, a, None, None)
self.assertTrue(operator.setitem(a, 0, 2) is None)
self.assertTrue(a == [2, 1, 2])
self.assertRaises(IndexError, operator.setitem, a, 4, 2)
- def test_setslice(self):
- a = range(4)
- self.assertRaises(TypeError, operator.setslice, a)
- self.assertRaises(TypeError, operator.setslice, a, None, None, None)
- self.assertTrue(operator.setslice(a, 1, 3, [2, 1]) is None)
- self.assertTrue(a == [0, 2, 1, 3])
- operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
- self.assertTrue(a == [])
-
def test_sub(self):
self.assertRaises(TypeError, operator.sub)
self.assertRaises(TypeError, operator.sub, None, None)
@@ -336,7 +238,7 @@ class OperatorTestCase(unittest.TestCase):
def test_truth(self):
class C(object):
- def __nonzero__(self):
+ def __bool__(self):
raise SyntaxError
self.assertRaises(TypeError, operator.truth)
self.assertRaises(SyntaxError, operator.truth, C())
@@ -373,8 +275,7 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(f(a), 'arthur')
f = operator.attrgetter('rank')
self.assertRaises(AttributeError, f, a)
- f = operator.attrgetter(2)
- self.assertRaises(TypeError, f, a)
+ self.assertRaises(TypeError, operator.attrgetter, 2)
self.assertRaises(TypeError, operator.attrgetter)
# multiple gets
@@ -383,7 +284,7 @@ class OperatorTestCase(unittest.TestCase):
record.y = 'Y'
record.z = 'Z'
self.assertEqual(operator.attrgetter('x','z','y')(record), ('X', 'Z', 'Y'))
- self.assertRaises(TypeError, operator.attrgetter('x', (), 'y'), record)
+ self.assertRaises(TypeError, operator.attrgetter, ('x', (), 'y'))
class C(object):
def __getattr__(self, name):
@@ -402,6 +303,10 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(f(a), ('arthur', 'thomas'))
f = operator.attrgetter('name', 'child.name', 'child.child.name')
self.assertRaises(AttributeError, f, a)
+ f = operator.attrgetter('child.')
+ self.assertRaises(AttributeError, f, a)
+ f = operator.attrgetter('.child')
+ self.assertRaises(AttributeError, f, a)
a.child.child = A()
a.child.child.name = 'johnson'
@@ -435,12 +340,12 @@ class OperatorTestCase(unittest.TestCase):
# example used in the docs
inventory = [('apple', 3), ('banana', 2), ('pear', 5), ('orange', 1)]
getcount = operator.itemgetter(1)
- self.assertEqual(map(getcount, inventory), [3, 2, 5, 1])
+ self.assertEqual(list(map(getcount, inventory)), [3, 2, 5, 1])
self.assertEqual(sorted(inventory, key=getcount),
[('orange', 1), ('banana', 2), ('apple', 3), ('pear', 5)])
# multiple gets
- data = map(str, range(20))
+ data = list(map(str, range(20)))
self.assertEqual(operator.itemgetter(2,10,5)(data), ('2', '10', '5'))
self.assertRaises(TypeError, operator.itemgetter(2, 'x', 5), data)
@@ -466,7 +371,6 @@ class OperatorTestCase(unittest.TestCase):
class C(object):
def __iadd__ (self, other): return "iadd"
def __iand__ (self, other): return "iand"
- def __idiv__ (self, other): return "idiv"
def __ifloordiv__(self, other): return "ifloordiv"
def __ilshift__ (self, other): return "ilshift"
def __imod__ (self, other): return "imod"
@@ -481,7 +385,6 @@ class OperatorTestCase(unittest.TestCase):
c = C()
self.assertEqual(operator.iadd (c, 5), "iadd")
self.assertEqual(operator.iand (c, 5), "iand")
- self.assertEqual(operator.idiv (c, 5), "idiv")
self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
self.assertEqual(operator.ilshift (c, 5), "ilshift")
self.assertEqual(operator.imod (c, 5), "imod")
@@ -493,10 +396,8 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(operator.itruediv (c, 5), "itruediv")
self.assertEqual(operator.ixor (c, 5), "ixor")
self.assertEqual(operator.iconcat (c, c), "iadd")
- self.assertEqual(operator.irepeat (c, 5), "imul")
self.assertEqual(operator.__iadd__ (c, 5), "iadd")
self.assertEqual(operator.__iand__ (c, 5), "iand")
- self.assertEqual(operator.__idiv__ (c, 5), "idiv")
self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv")
self.assertEqual(operator.__ilshift__ (c, 5), "ilshift")
self.assertEqual(operator.__imod__ (c, 5), "imod")
@@ -508,7 +409,6 @@ class OperatorTestCase(unittest.TestCase):
self.assertEqual(operator.__itruediv__ (c, 5), "itruediv")
self.assertEqual(operator.__ixor__ (c, 5), "ixor")
self.assertEqual(operator.__iconcat__ (c, c), "iadd")
- self.assertEqual(operator.__irepeat__ (c, 5), "imul")
def test_main(verbose=None):
import sys
@@ -516,17 +416,17 @@ def test_main(verbose=None):
OperatorTestCase,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_optparse.py b/Lib/test/test_optparse.py
index d4e5bb9b664..7b956120243 100644
--- a/Lib/test/test_optparse.py
+++ b/Lib/test/test_optparse.py
@@ -10,11 +10,10 @@ import sys
import os
import re
import copy
-import types
import unittest
-from StringIO import StringIO
-from test import test_support
+from io import StringIO
+from test import support
from optparse import make_option, Option, \
@@ -105,7 +104,7 @@ Args were %(args)s.""" % locals ())
try:
func(*args, **kwargs)
- except expected_exception, err:
+ except expected_exception as err:
actual_message = str(err)
if isinstance(expected_message, retype):
self.assertTrue(expected_message.search(actual_message),
@@ -143,7 +142,7 @@ and kwargs %(kwargs)r
"""
try:
self.parser.parse_args(cmdline_args)
- except InterceptedError, err:
+ except InterceptedError as err:
self.assertEqual(err.error_message, expected_output)
else:
self.assertFalse("expected parse failure")
@@ -155,20 +154,17 @@ and kwargs %(kwargs)r
expected_error=None):
"""Assert the parser prints the expected output on stdout."""
save_stdout = sys.stdout
- encoding = getattr(save_stdout, 'encoding', None)
try:
try:
sys.stdout = StringIO()
- if encoding:
- sys.stdout.encoding = encoding
self.parser.parse_args(cmdline_args)
finally:
output = sys.stdout.getvalue()
sys.stdout = save_stdout
- except InterceptedError, err:
+ except InterceptedError as err:
self.assertTrue(
- type(output) is types.StringType,
+ isinstance(output, str),
"expected output to be an ordinary string, not %r"
% type(output))
@@ -429,18 +425,12 @@ class TestTypeAliases(BaseTest):
self.parser.add_option("-s", type="str")
self.assertEqual(self.parser.get_option("-s").type, "string")
- def test_new_type_object(self):
+ def test_type_object(self):
self.parser.add_option("-s", type=str)
self.assertEqual(self.parser.get_option("-s").type, "string")
self.parser.add_option("-x", type=int)
self.assertEqual(self.parser.get_option("-x").type, "int")
- def test_old_type_object(self):
- self.parser.add_option("-s", type=types.StringType)
- self.assertEqual(self.parser.get_option("-s").type, "string")
- self.parser.add_option("-x", type=types.IntType)
- self.assertEqual(self.parser.get_option("-x").type, "int")
-
# Custom type for testing processing of default values.
_time_units = { 's' : 1, 'm' : 60, 'h' : 60*60, 'd' : 60*60*24 }
@@ -769,13 +759,6 @@ class TestStandard(BaseTest):
self.assertParseFail(["-test"],
"no such option: -e")
- def test_add_option_accepts_unicode(self):
- self.parser.add_option(u"-u", u"--unicode", action="store_true")
- self.assertParseOK(["-u"],
- {'a': None, 'boo': None, 'foo': None, 'unicode': True},
- [])
-
-
class TestBool(BaseTest):
def setUp(self):
options = [make_option("-v",
@@ -1022,10 +1005,10 @@ class TestExtendAddTypes(BaseTest):
self.parser.add_option("-f", "--file", type="file", dest="file")
def tearDown(self):
- if os.path.isdir(test_support.TESTFN):
- os.rmdir(test_support.TESTFN)
- elif os.path.isfile(test_support.TESTFN):
- os.unlink(test_support.TESTFN)
+ if os.path.isdir(support.TESTFN):
+ os.rmdir(support.TESTFN)
+ elif os.path.isfile(support.TESTFN):
+ os.unlink(support.TESTFN)
class MyOption (Option):
def check_file(option, opt, value):
@@ -1040,21 +1023,21 @@ class TestExtendAddTypes(BaseTest):
TYPE_CHECKER["file"] = check_file
def test_filetype_ok(self):
- open(test_support.TESTFN, "w").close()
- self.assertParseOK(["--file", test_support.TESTFN, "-afoo"],
- {'file': test_support.TESTFN, 'a': 'foo'},
+ open(support.TESTFN, "w").close()
+ self.assertParseOK(["--file", support.TESTFN, "-afoo"],
+ {'file': support.TESTFN, 'a': 'foo'},
[])
def test_filetype_noexist(self):
- self.assertParseFail(["--file", test_support.TESTFN, "-afoo"],
+ self.assertParseFail(["--file", support.TESTFN, "-afoo"],
"%s: file does not exist" %
- test_support.TESTFN)
+ support.TESTFN)
def test_filetype_notfile(self):
- os.mkdir(test_support.TESTFN)
- self.assertParseFail(["--file", test_support.TESTFN, "-afoo"],
+ os.mkdir(support.TESTFN)
+ self.assertParseFail(["--file", support.TESTFN, "-afoo"],
"%s: not a regular file" %
- test_support.TESTFN)
+ support.TESTFN)
class TestExtendAddActions(BaseTest):
@@ -1465,15 +1448,11 @@ class TestHelp(BaseTest):
# we must restore its original value -- otherwise, this test
# screws things up for other tests when it's part of the Python
# test suite.
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env['COLUMNS'] = str(columns)
return InterceptingOptionParser(option_list=options)
def assertHelpEquals(self, expected_output):
- if type(expected_output) is types.UnicodeType:
- encoding = self.parser._get_encoding(sys.stdout)
- expected_output = expected_output.encode(encoding, "replace")
-
save_argv = sys.argv[:]
try:
# Make optparse believe bar.py is being executed.
@@ -1494,7 +1473,7 @@ class TestHelp(BaseTest):
self.assertHelpEquals(_expected_help_long_opts_first)
def test_help_title_formatter(self):
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env["COLUMNS"] = "80"
self.parser.formatter = TitledHelpFormatter()
self.assertHelpEquals(_expected_help_title_formatter)
@@ -1508,8 +1487,8 @@ class TestHelp(BaseTest):
def test_help_unicode(self):
self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE)
- self.parser.add_option("-a", action="store_true", help=u"ol\u00E9!")
- expect = u"""\
+ self.parser.add_option("-a", action="store_true", help="ol\u00E9!")
+ expect = """\
Options:
-h, --help show this help message and exit
-a ol\u00E9!
@@ -1518,8 +1497,8 @@ Options:
def test_help_unicode_description(self):
self.parser = InterceptingOptionParser(usage=SUPPRESS_USAGE,
- description=u"ol\u00E9!")
- expect = u"""\
+ description="ol\u00E9!")
+ expect = """\
ol\u00E9!
Options:
@@ -1586,7 +1565,7 @@ class TestParseNumber(BaseTest):
def setUp(self):
self.parser = InterceptingOptionParser()
self.parser.add_option("-n", type=int)
- self.parser.add_option("-l", type=long)
+ self.parser.add_option("-l", type=int)
def test_parse_num_fail(self):
self.assertRaises(
@@ -1594,17 +1573,17 @@ class TestParseNumber(BaseTest):
ValueError,
re.compile(r"invalid literal for int().*: '?'?"))
self.assertRaises(
- _parse_num, ("0xOoops", long), {},
+ _parse_num, ("0xOoops", int), {},
ValueError,
- re.compile(r"invalid literal for long().*: '?0xOoops'?"))
+ re.compile(r"invalid literal for int().*: s?'?0xOoops'?"))
def test_parse_num_ok(self):
self.assertEqual(_parse_num("0", int), 0)
self.assertEqual(_parse_num("0x10", int), 16)
- self.assertEqual(_parse_num("0XA", long), 10L)
- self.assertEqual(_parse_num("010", long), 8L)
+ self.assertEqual(_parse_num("0XA", int), 10)
+ self.assertEqual(_parse_num("010", int), 8)
self.assertEqual(_parse_num("0b11", int), 3)
- self.assertEqual(_parse_num("0b", long), 0L)
+ self.assertEqual(_parse_num("0b", int), 0)
def test_numeric_options(self):
self.assertParseOK(["-n", "42", "-l", "0x20"],
@@ -1614,13 +1593,13 @@ class TestParseNumber(BaseTest):
self.assertParseFail(["-n008"],
"option -n: invalid integer value: '008'")
self.assertParseFail(["-l0b0123"],
- "option -l: invalid long integer value: '0b0123'")
+ "option -l: invalid integer value: '0b0123'")
self.assertParseFail(["-l", "0x12x"],
- "option -l: invalid long integer value: '0x12x'")
+ "option -l: invalid integer value: '0x12x'")
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index bdbeb0107bb..5b67da17baa 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -10,28 +10,39 @@ import sys
import signal
import subprocess
import time
-
-from test import test_support
+import shutil
+from test import support
+import contextlib
import mmap
import uuid
-
-warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
-warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
+import stat
+from test.script_helper import assert_python_ok
+
+# Detect whether we're on a Linux system that uses the (now outdated
+# and unmaintained) linuxthreads threading library. There's an issue
+# when combining linuxthreads with a failed execv call: see
+# http://bugs.python.org/issue4970.
+if (hasattr(os, "confstr_names") and
+ "CS_GNU_LIBPTHREAD_VERSION" in os.confstr_names):
+ libpthread = os.confstr("CS_GNU_LIBPTHREAD_VERSION")
+ USING_LINUXTHREADS= libpthread.startswith("linuxthreads")
+else:
+ USING_LINUXTHREADS= False
# Tests creating TESTFN
class FileTests(unittest.TestCase):
def setUp(self):
- if os.path.exists(test_support.TESTFN):
- os.unlink(test_support.TESTFN)
+ if os.path.exists(support.TESTFN):
+ os.unlink(support.TESTFN)
tearDown = setUp
def test_access(self):
- f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+ f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
os.close(f)
- self.assertTrue(os.access(test_support.TESTFN, os.W_OK))
+ self.assertTrue(os.access(support.TESTFN, os.W_OK))
def test_closerange(self):
- first = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+ first = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
# We must allocate two consecutive file descriptors, otherwise
# it will mess up other file descriptors (perhaps even the three
# standard ones).
@@ -49,151 +60,90 @@ class FileTests(unittest.TestCase):
os.close(second)
# close a fd that is open, and one that isn't
os.closerange(first, first + 2)
- self.assertRaises(OSError, os.write, first, "a")
+ self.assertRaises(OSError, os.write, first, b"a")
- @test_support.cpython_only
+ @support.cpython_only
def test_rename(self):
- path = unicode(test_support.TESTFN)
+ path = support.TESTFN
old = sys.getrefcount(path)
self.assertRaises(TypeError, os.rename, path, 0)
new = sys.getrefcount(path)
self.assertEqual(old, new)
+ def test_read(self):
+ with open(support.TESTFN, "w+b") as fobj:
+ fobj.write(b"spam")
+ fobj.flush()
+ fd = fobj.fileno()
+ os.lseek(fd, 0, 0)
+ s = os.read(fd, 4)
+ self.assertEqual(type(s), bytes)
+ self.assertEqual(s, b"spam")
-class TemporaryFileTests(unittest.TestCase):
- def setUp(self):
- self.files = []
- os.mkdir(test_support.TESTFN)
+ def test_write(self):
+ # os.write() accepts bytes- and buffer-like objects but not strings
+ fd = os.open(support.TESTFN, os.O_CREAT | os.O_WRONLY)
+ self.assertRaises(TypeError, os.write, fd, "beans")
+ os.write(fd, b"bacon\n")
+ os.write(fd, bytearray(b"eggs\n"))
+ os.write(fd, memoryview(b"spam\n"))
+ os.close(fd)
+ with open(support.TESTFN, "rb") as fobj:
+ self.assertEqual(fobj.read().splitlines(),
+ [b"bacon", b"eggs", b"spam"])
+
+ def write_windows_console(self, *args):
+ retcode = subprocess.call(args,
+ # use a new console to not flood the test output
+ creationflags=subprocess.CREATE_NEW_CONSOLE,
+ # use a shell to hide the console window (SW_HIDE)
+ shell=True)
+ self.assertEqual(retcode, 0)
+
+ @unittest.skipUnless(sys.platform == 'win32',
+ 'test specific to the Windows console')
+ def test_write_windows_console(self):
+ # Issue #11395: the Windows console returns an error (12: not enough
+ # space error) on writing into stdout if stdout mode is binary and the
+ # length is greater than 66,000 bytes (or less, depending on heap
+ # usage).
+ code = "print('x' * 100000)"
+ self.write_windows_console(sys.executable, "-c", code)
+ self.write_windows_console(sys.executable, "-u", "-c", code)
+
+ def fdopen_helper(self, *args):
+ fd = os.open(support.TESTFN, os.O_RDONLY)
+ f = os.fdopen(fd, *args)
+ f.close()
- def tearDown(self):
- for name in self.files:
- os.unlink(name)
- os.rmdir(test_support.TESTFN)
-
- def check_tempfile(self, name):
- # make sure it doesn't already exist:
- self.assertFalse(os.path.exists(name),
- "file already exists for temporary file")
- # make sure we can create the file
- open(name, "w")
- self.files.append(name)
-
- def test_tempnam(self):
- if not hasattr(os, "tempnam"):
- return
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "tempnam", RuntimeWarning,
- r"test_os$")
- warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
- self.check_tempfile(os.tempnam())
+ def test_fdopen(self):
+ fd = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
+ os.close(fd)
- name = os.tempnam(test_support.TESTFN)
- self.check_tempfile(name)
+ self.fdopen_helper()
+ self.fdopen_helper('r')
+ self.fdopen_helper('r', 100)
- name = os.tempnam(test_support.TESTFN, "pfx")
- self.assertTrue(os.path.basename(name)[:3] == "pfx")
- self.check_tempfile(name)
-
- def test_tmpfile(self):
- if not hasattr(os, "tmpfile"):
- return
- # As with test_tmpnam() below, the Windows implementation of tmpfile()
- # attempts to create a file in the root directory of the current drive.
- # On Vista and Server 2008, this test will always fail for normal users
- # as writing to the root directory requires elevated privileges. With
- # XP and below, the semantics of tmpfile() are the same, but the user
- # running the test is more likely to have administrative privileges on
- # their account already. If that's the case, then os.tmpfile() should
- # work. In order to make this test as useful as possible, rather than
- # trying to detect Windows versions or whether or not the user has the
- # right permissions, just try and create a file in the root directory
- # and see if it raises a 'Permission denied' OSError. If it does, then
- # test that a subsequent call to os.tmpfile() raises the same error. If
- # it doesn't, assume we're on XP or below and the user running the test
- # has administrative privileges, and proceed with the test as normal.
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning)
-
- if sys.platform == 'win32':
- name = '\\python_test_os_test_tmpfile.txt'
- if os.path.exists(name):
- os.remove(name)
- try:
- fp = open(name, 'w')
- except IOError, first:
- # open() failed, assert tmpfile() fails in the same way.
- # Although open() raises an IOError and os.tmpfile() raises an
- # OSError(), 'args' will be (13, 'Permission denied') in both
- # cases.
- try:
- fp = os.tmpfile()
- except OSError, second:
- self.assertEqual(first.args, second.args)
- else:
- self.fail("expected os.tmpfile() to raise OSError")
- return
- else:
- # open() worked, therefore, tmpfile() should work. Close our
- # dummy file and proceed with the test as normal.
- fp.close()
- os.remove(name)
-
- fp = os.tmpfile()
- fp.write("foobar")
- fp.seek(0,0)
- s = fp.read()
- fp.close()
- self.assertTrue(s == "foobar")
-
- def test_tmpnam(self):
- if not hasattr(os, "tmpnam"):
- return
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning,
- r"test_os$")
- warnings.filterwarnings("ignore", "tmpnam", DeprecationWarning)
-
- name = os.tmpnam()
- if sys.platform in ("win32",):
- # The Windows tmpnam() seems useless. From the MS docs:
- #
- # The character string that tmpnam creates consists of
- # the path prefix, defined by the entry P_tmpdir in the
- # file STDIO.H, followed by a sequence consisting of the
- # digit characters '0' through '9'; the numerical value
- # of this string is in the range 1 - 65,535. Changing the
- # definitions of L_tmpnam or P_tmpdir in STDIO.H does not
- # change the operation of tmpnam.
- #
- # The really bizarre part is that, at least under MSVC6,
- # P_tmpdir is "\\". That is, the path returned refers to
- # the root of the current drive. That's a terrible place to
- # put temp files, and, depending on privileges, the user
- # may not even be able to open a file in the root directory.
- self.assertFalse(os.path.exists(name),
- "file already exists for temporary file")
- else:
- self.check_tempfile(name)
# Test attributes on return values from os.*stat* family.
class StatAttributeTests(unittest.TestCase):
def setUp(self):
- os.mkdir(test_support.TESTFN)
- self.fname = os.path.join(test_support.TESTFN, "f1")
+ os.mkdir(support.TESTFN)
+ self.fname = os.path.join(support.TESTFN, "f1")
f = open(self.fname, 'wb')
- f.write("ABC")
+ f.write(b"ABC")
f.close()
def tearDown(self):
os.unlink(self.fname)
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
- def test_stat_attributes(self):
+ def check_stat_attributes(self, fname):
if not hasattr(os, "stat"):
return
import stat
- result = os.stat(self.fname)
+ result = os.stat(fname)
# Make sure direct access works
self.assertEqual(result[stat.ST_SIZE], 3)
@@ -209,7 +159,7 @@ class StatAttributeTests(unittest.TestCase):
else:
def trunc(x): return x
self.assertEqual(trunc(getattr(result, attr)),
- result[getattr(stat, name)])
+ result[getattr(stat, name)])
self.assertIn(attr, members)
try:
@@ -222,7 +172,7 @@ class StatAttributeTests(unittest.TestCase):
try:
result.st_mode = 1
self.fail("No exception raised")
- except (AttributeError, TypeError):
+ except AttributeError:
pass
try:
@@ -250,6 +200,15 @@ class StatAttributeTests(unittest.TestCase):
except TypeError:
pass
+ def test_stat_attributes(self):
+ self.check_stat_attributes(self.fname)
+
+ def test_stat_attributes_bytes(self):
+ try:
+ fname = self.fname.encode(sys.getfilesystemencoding())
+ except UnicodeEncodeError:
+ self.skipTest("cannot encode %a for the filesystem" % self.fname)
+ self.check_stat_attributes(fname)
def test_statvfs_attributes(self):
if not hasattr(os, "statvfs"):
@@ -257,7 +216,7 @@ class StatAttributeTests(unittest.TestCase):
try:
result = os.statvfs(self.fname)
- except OSError, e:
+ except OSError as e:
# On AtheOS, glibc always returns ENOSYS
if e.errno == errno.ENOSYS:
return
@@ -275,7 +234,7 @@ class StatAttributeTests(unittest.TestCase):
try:
result.f_bfree = 1
self.fail("No exception raised")
- except TypeError:
+ except AttributeError:
pass
try:
@@ -299,11 +258,11 @@ class StatAttributeTests(unittest.TestCase):
def test_utime_dir(self):
delta = 1000000
- st = os.stat(test_support.TESTFN)
+ st = os.stat(support.TESTFN)
# round to int, because some systems may support sub-second
# time stamps in stat, but not in utime.
- os.utime(test_support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
- st2 = os.stat(test_support.TESTFN)
+ os.utime(support.TESTFN, (st.st_atime, int(st.st_mtime-delta)))
+ st2 = os.stat(support.TESTFN)
self.assertEqual(st2.st_mtime, int(st.st_mtime-delta))
# Restrict test to Win32, since there is no guarantee other
@@ -313,11 +272,11 @@ class StatAttributeTests(unittest.TestCase):
root = os.path.splitdrive(os.path.abspath(path))[0] + '\\'
import ctypes
kernel32 = ctypes.windll.kernel32
- buf = ctypes.create_string_buffer("", 100)
- if kernel32.GetVolumeInformationA(root, None, 0, None, None, None, buf, len(buf)):
+ buf = ctypes.create_unicode_buffer("", 100)
+ if kernel32.GetVolumeInformationW(root, None, 0, None, None, None, buf, len(buf)):
return buf.value
- if get_file_system(test_support.TESTFN) == "NTFS":
+ if get_file_system(support.TESTFN) == "NTFS":
def test_1565150(self):
t1 = 1159195039.25
os.utime(self.fname, (t1, t1))
@@ -332,7 +291,7 @@ class StatAttributeTests(unittest.TestCase):
# Verify that an open file can be stat'ed
try:
os.stat(r"c:\pagefile.sys")
- except WindowsError, e:
+ except WindowsError as e:
if e.errno == 2: # file does not exist; cannot run test
return
self.fail("Could not stat pagefile.sys")
@@ -342,26 +301,130 @@ from test import mapping_tests
class EnvironTests(mapping_tests.BasicTestMappingProtocol):
"""check that os.environ object conform to mapping protocol"""
type2test = None
- def _reference(self):
- return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
- def _empty_mapping(self):
- os.environ.clear()
- return os.environ
+
def setUp(self):
self.__save = dict(os.environ)
- os.environ.clear()
+ if os.supports_bytes_environ:
+ self.__saveb = dict(os.environb)
+ for key, value in self._reference().items():
+ os.environ[key] = value
+
def tearDown(self):
os.environ.clear()
os.environ.update(self.__save)
+ if os.supports_bytes_environ:
+ os.environb.clear()
+ os.environb.update(self.__saveb)
+
+ def _reference(self):
+ return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
+
+ def _empty_mapping(self):
+ os.environ.clear()
+ return os.environ
# Bug 1110478
def test_update2(self):
+ os.environ.clear()
if os.path.exists("/bin/sh"):
os.environ.update(HELLO="World")
with os.popen("/bin/sh -c 'echo $HELLO'") as popen:
value = popen.read().strip()
self.assertEqual(value, "World")
+ def test_os_popen_iter(self):
+ if os.path.exists("/bin/sh"):
+ with os.popen(
+ "/bin/sh -c 'echo \"line1\nline2\nline3\"'") as popen:
+ it = iter(popen)
+ self.assertEqual(next(it), "line1\n")
+ self.assertEqual(next(it), "line2\n")
+ self.assertEqual(next(it), "line3\n")
+ self.assertRaises(StopIteration, next, it)
+
+ # Verify environ keys and values from the OS are of the
+ # correct str type.
+ def test_keyvalue_types(self):
+ for key, val in os.environ.items():
+ self.assertEqual(type(key), str)
+ self.assertEqual(type(val), str)
+
+ def test_items(self):
+ for key, value in self._reference().items():
+ self.assertEqual(os.environ.get(key), value)
+
+ # Issue 7310
+ def test___repr__(self):
+ """Check that the repr() of os.environ looks like environ({...})."""
+ env = os.environ
+ self.assertEqual(repr(env), 'environ({{{}}})'.format(', '.join(
+ '{!r}: {!r}'.format(key, value)
+ for key, value in env.items())))
+
+ def test_get_exec_path(self):
+ defpath_list = os.defpath.split(os.pathsep)
+ test_path = ['/monty', '/python', '', '/flying/circus']
+ test_env = {'PATH': os.pathsep.join(test_path)}
+
+ saved_environ = os.environ
+ try:
+ os.environ = dict(test_env)
+ # Test that defaulting to os.environ works.
+ self.assertSequenceEqual(test_path, os.get_exec_path())
+ self.assertSequenceEqual(test_path, os.get_exec_path(env=None))
+ finally:
+ os.environ = saved_environ
+
+ # No PATH environment variable
+ self.assertSequenceEqual(defpath_list, os.get_exec_path({}))
+ # Empty PATH environment variable
+ self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''}))
+ # Supplied PATH environment variable
+ self.assertSequenceEqual(test_path, os.get_exec_path(test_env))
+
+ if os.supports_bytes_environ:
+ # env cannot contain 'PATH' and b'PATH' keys
+ try:
+ # ignore BytesWarning warning
+ with warnings.catch_warnings(record=True):
+ mixed_env = {'PATH': '1', b'PATH': b'2'}
+ except BytesWarning:
+ # mixed_env cannot be created with python -bb
+ pass
+ else:
+ self.assertRaises(ValueError, os.get_exec_path, mixed_env)
+
+ # bytes key and/or value
+ self.assertSequenceEqual(os.get_exec_path({b'PATH': b'abc'}),
+ ['abc'])
+ self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}),
+ ['abc'])
+ self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}),
+ ['abc'])
+
+ @unittest.skipUnless(os.supports_bytes_environ,
+ "os.environb required for this test.")
+ def test_environb(self):
+ # os.environ -> os.environb
+ value = 'euro\u20ac'
+ try:
+ value_bytes = value.encode(sys.getfilesystemencoding(),
+ 'surrogateescape')
+ except UnicodeEncodeError:
+ msg = "U+20AC character is not encodable to %s" % (
+ sys.getfilesystemencoding(),)
+ self.skipTest(msg)
+ os.environ['unicode'] = value
+ self.assertEqual(os.environ['unicode'], value)
+ self.assertEqual(os.environb[b'unicode'], value_bytes)
+
+ # os.environb -> os.environ
+ value = b'\xff'
+ os.environb[b'bytes'] = value
+ self.assertEqual(os.environb[b'bytes'], value)
+ value_str = value.decode(sys.getfilesystemencoding(), 'surrogateescape')
+ self.assertEqual(os.environ['bytes'], value_str)
+
# On FreeBSD < 7 and OS X < 10.6, unsetenv() doesn't return a value (issue
# #13415).
@unittest.skipIf(sys.platform.startswith(('freebsd', 'darwin')),
@@ -395,7 +458,7 @@ class WalkTests(unittest.TestCase):
# link/ a symlink to TESTFN.2
# TEST2/
# tmp4 a lone file
- walk_path = join(test_support.TESTFN, "TEST1")
+ walk_path = join(support.TESTFN, "TEST1")
sub1_path = join(walk_path, "SUB1")
sub11_path = join(sub1_path, "SUB11")
sub2_path = join(walk_path, "SUB2")
@@ -403,19 +466,24 @@ class WalkTests(unittest.TestCase):
tmp2_path = join(sub1_path, "tmp2")
tmp3_path = join(sub2_path, "tmp3")
link_path = join(sub2_path, "link")
- t2_path = join(test_support.TESTFN, "TEST2")
- tmp4_path = join(test_support.TESTFN, "TEST2", "tmp4")
+ t2_path = join(support.TESTFN, "TEST2")
+ tmp4_path = join(support.TESTFN, "TEST2", "tmp4")
# Create stuff.
os.makedirs(sub11_path)
os.makedirs(sub2_path)
os.makedirs(t2_path)
for path in tmp1_path, tmp2_path, tmp3_path, tmp4_path:
- f = file(path, "w")
+ f = open(path, "w")
f.write("I'm " + path + " and proud of it. Blame test_os.\n")
f.close()
- if hasattr(os, "symlink"):
- os.symlink(os.path.abspath(t2_path), link_path)
+ if support.can_symlink():
+ if os.name == 'nt':
+ def symlink_to_dir(src, dest):
+ os.symlink(src, dest, True)
+ else:
+ symlink_to_dir = os.symlink
+ symlink_to_dir(os.path.abspath(t2_path), link_path)
sub2_tree = (sub2_path, ["link"], ["tmp3"])
else:
sub2_tree = (sub2_path, [], ["tmp3"])
@@ -458,7 +526,7 @@ class WalkTests(unittest.TestCase):
self.assertEqual(all[flipped + 1], (sub1_path, ["SUB11"], ["tmp2"]))
self.assertEqual(all[2 - 2 * flipped], sub2_tree)
- if hasattr(os, "symlink"):
+ if support.can_symlink():
# Walk, following symlinks.
for root, dirs, files in os.walk(walk_path, followlinks=True):
if root == link_path:
@@ -473,7 +541,7 @@ class WalkTests(unittest.TestCase):
# Windows, which doesn't have a recursive delete command. The
# (not so) subtlety is that rmdir will fail unless the dir's
# kids are removed first, so bottom up is essential.
- for root, dirs, files in os.walk(test_support.TESTFN, topdown=False):
+ for root, dirs, files in os.walk(support.TESTFN, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
@@ -482,14 +550,14 @@ class WalkTests(unittest.TestCase):
os.rmdir(dirname)
else:
os.remove(dirname)
- os.rmdir(test_support.TESTFN)
+ os.rmdir(support.TESTFN)
-class MakedirTests (unittest.TestCase):
+class MakedirTests(unittest.TestCase):
def setUp(self):
- os.mkdir(test_support.TESTFN)
+ os.mkdir(support.TESTFN)
def test_makedir(self):
- base = test_support.TESTFN
+ base = support.TESTFN
path = os.path.join(base, 'dir1', 'dir2', 'dir3')
os.makedirs(path) # Should work
path = os.path.join(base, 'dir1', 'dir2', 'dir3', 'dir4')
@@ -503,31 +571,123 @@ class MakedirTests (unittest.TestCase):
'dir5', 'dir6')
os.makedirs(path)
+ def test_exist_ok_existing_directory(self):
+ path = os.path.join(support.TESTFN, 'dir1')
+ mode = 0o777
+ old_mask = os.umask(0o022)
+ try:
+ os.makedirs(path, mode)
+ self.assertRaises(OSError, os.makedirs, path, mode)
+ self.assertRaises(OSError, os.makedirs, path, mode, exist_ok=False)
+ self.assertRaises(OSError, os.makedirs, path, 0o776, exist_ok=True)
+ os.makedirs(path, mode=mode, exist_ok=True)
+ finally:
+ os.umask(old_mask)
+ def test_exist_ok_s_isgid_directory(self):
+ path = os.path.join(support.TESTFN, 'dir1')
+ S_ISGID = stat.S_ISGID
+ mode = 0o777
+ old_mask = os.umask(0o022)
+ try:
+ existing_testfn_mode = stat.S_IMODE(
+ os.lstat(support.TESTFN).st_mode)
+ try:
+ os.chmod(support.TESTFN, existing_testfn_mode | S_ISGID)
+ except OSError:
+ raise unittest.SkipTest('Cannot set S_ISGID for dir.')
+ if (os.lstat(support.TESTFN).st_mode & S_ISGID != S_ISGID):
+ raise unittest.SkipTest('No support for S_ISGID dir mode.')
+ # The os should apply S_ISGID from the parent dir for us, but
+ # this test need not depend on that behavior. Be explicit.
+ os.makedirs(path, mode | S_ISGID)
+ # http://bugs.python.org/issue14992
+ # Should not fail when the bit is already set.
+ os.makedirs(path, mode, exist_ok=True)
+ # remove the bit.
+ os.chmod(path, stat.S_IMODE(os.lstat(path).st_mode) & ~S_ISGID)
+ with self.assertRaises(OSError):
+ # Should fail when the bit is not already set when demanded.
+ os.makedirs(path, mode | S_ISGID, exist_ok=True)
+ finally:
+ os.umask(old_mask)
+ def test_exist_ok_existing_regular_file(self):
+ base = support.TESTFN
+ path = os.path.join(support.TESTFN, 'dir1')
+ f = open(path, 'w')
+ f.write('abc')
+ f.close()
+ self.assertRaises(OSError, os.makedirs, path)
+ self.assertRaises(OSError, os.makedirs, path, exist_ok=False)
+ self.assertRaises(OSError, os.makedirs, path, exist_ok=True)
+ os.remove(path)
def tearDown(self):
- path = os.path.join(test_support.TESTFN, 'dir1', 'dir2', 'dir3',
+ path = os.path.join(support.TESTFN, 'dir1', 'dir2', 'dir3',
'dir4', 'dir5', 'dir6')
# If the tests failed, the bottom-most directory ('../dir6')
# may not have been created, so we look for the outermost directory
# that exists.
- while not os.path.exists(path) and path != test_support.TESTFN:
+ while not os.path.exists(path) and path != support.TESTFN:
path = os.path.dirname(path)
os.removedirs(path)
-class DevNullTests (unittest.TestCase):
+
+class RemoveDirsTests(unittest.TestCase):
+ def setUp(self):
+ os.makedirs(support.TESTFN)
+
+ def tearDown(self):
+ support.rmtree(support.TESTFN)
+
+ def test_remove_all(self):
+ dira = os.path.join(support.TESTFN, 'dira')
+ os.mkdir(dira)
+ dirb = os.path.join(dira, 'dirb')
+ os.mkdir(dirb)
+ os.removedirs(dirb)
+ self.assertFalse(os.path.exists(dirb))
+ self.assertFalse(os.path.exists(dira))
+ self.assertFalse(os.path.exists(support.TESTFN))
+
+ def test_remove_partial(self):
+ dira = os.path.join(support.TESTFN, 'dira')
+ os.mkdir(dira)
+ dirb = os.path.join(dira, 'dirb')
+ os.mkdir(dirb)
+ with open(os.path.join(dira, 'file.txt'), 'w') as f:
+ f.write('text')
+ os.removedirs(dirb)
+ self.assertFalse(os.path.exists(dirb))
+ self.assertTrue(os.path.exists(dira))
+ self.assertTrue(os.path.exists(support.TESTFN))
+
+ def test_remove_nothing(self):
+ dira = os.path.join(support.TESTFN, 'dira')
+ os.mkdir(dira)
+ dirb = os.path.join(dira, 'dirb')
+ os.mkdir(dirb)
+ with open(os.path.join(dirb, 'file.txt'), 'w') as f:
+ f.write('text')
+ with self.assertRaises(OSError):
+ os.removedirs(dirb)
+ self.assertTrue(os.path.exists(dirb))
+ self.assertTrue(os.path.exists(dira))
+ self.assertTrue(os.path.exists(support.TESTFN))
+
+
+class DevNullTests(unittest.TestCase):
def test_devnull(self):
- f = file(os.devnull, 'w')
- f.write('hello')
- f.close()
- f = file(os.devnull, 'r')
- self.assertEqual(f.read(), '')
- f.close()
+ with open(os.devnull, 'wb') as f:
+ f.write(b'hello')
+ f.close()
+ with open(os.devnull, 'rb') as f:
+ self.assertEqual(f.read(), b'')
-class URandomTests (unittest.TestCase):
+class URandomTests(unittest.TestCase):
def test_urandom_length(self):
self.assertEqual(len(os.urandom(0)), 0)
self.assertEqual(len(os.urandom(1)), 1)
@@ -541,57 +701,145 @@ class URandomTests (unittest.TestCase):
self.assertNotEqual(data1, data2)
def get_urandom_subprocess(self, count):
- # We need to use repr() and eval() to avoid line ending conversions
- # under Windows.
code = '\n'.join((
'import os, sys',
'data = os.urandom(%s)' % count,
- 'sys.stdout.write(repr(data))',
- 'sys.stdout.flush()',
- 'print >> sys.stderr, (len(data), data)'))
- cmd_line = [sys.executable, '-c', code]
- p = subprocess.Popen(cmd_line, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- out, err = p.communicate()
- self.assertEqual(p.wait(), 0, (p.wait(), err))
- out = eval(out)
- self.assertEqual(len(out), count, err)
- return out
+ 'sys.stdout.buffer.write(data)',
+ 'sys.stdout.buffer.flush()'))
+ out = assert_python_ok('-c', code)
+ stdout = out[1]
+ self.assertEqual(len(stdout), 16)
+ return stdout
def test_urandom_subprocess(self):
data1 = self.get_urandom_subprocess(16)
data2 = self.get_urandom_subprocess(16)
self.assertNotEqual(data1, data2)
+@contextlib.contextmanager
+def _execvpe_mockup(defpath=None):
+ """
+ Stubs out execv and execve functions when used as context manager.
+ Records exec calls. The mock execv and execve functions always raise an
+ exception as they would normally never return.
+ """
+ # A list of tuples containing (function name, first arg, args)
+ # of calls to execv or execve that have been made.
+ calls = []
+
+ def mock_execv(name, *args):
+ calls.append(('execv', name, args))
+ raise RuntimeError("execv called")
+
+ def mock_execve(name, *args):
+ calls.append(('execve', name, args))
+ raise OSError(errno.ENOTDIR, "execve called")
+
+ try:
+ orig_execv = os.execv
+ orig_execve = os.execve
+ orig_defpath = os.defpath
+ os.execv = mock_execv
+ os.execve = mock_execve
+ if defpath is not None:
+ os.defpath = defpath
+ yield calls
+ finally:
+ os.execv = orig_execv
+ os.execve = orig_execve
+ os.defpath = orig_defpath
+
+class ExecTests(unittest.TestCase):
+ @unittest.skipIf(USING_LINUXTHREADS,
+ "avoid triggering a linuxthreads bug: see issue #4970")
+ def test_execvpe_with_bad_program(self):
+ self.assertRaises(OSError, os.execvpe, 'no such app-',
+ ['no such app-'], None)
+
def test_execvpe_with_bad_arglist(self):
self.assertRaises(ValueError, os.execvpe, 'notepad', [], None)
+ @unittest.skipUnless(hasattr(os, '_execvpe'),
+ "No internal os._execvpe function to test.")
+ def _test_internal_execvpe(self, test_type):
+ program_path = os.sep + 'absolutepath'
+ if test_type is bytes:
+ program = b'executable'
+ fullpath = os.path.join(os.fsencode(program_path), program)
+ native_fullpath = fullpath
+ arguments = [b'progname', 'arg1', 'arg2']
+ else:
+ program = 'executable'
+ arguments = ['progname', 'arg1', 'arg2']
+ fullpath = os.path.join(program_path, program)
+ if os.name != "nt":
+ native_fullpath = os.fsencode(fullpath)
+ else:
+ native_fullpath = fullpath
+ env = {'spam': 'beans'}
+
+ # test os._execvpe() with an absolute path
+ with _execvpe_mockup() as calls:
+ self.assertRaises(RuntimeError,
+ os._execvpe, fullpath, arguments)
+ self.assertEqual(len(calls), 1)
+ self.assertEqual(calls[0], ('execv', fullpath, (arguments,)))
+
+ # test os._execvpe() with a relative path:
+ # os.get_exec_path() returns defpath
+ with _execvpe_mockup(defpath=program_path) as calls:
+ self.assertRaises(OSError,
+ os._execvpe, program, arguments, env=env)
+ self.assertEqual(len(calls), 1)
+ self.assertSequenceEqual(calls[0],
+ ('execve', native_fullpath, (arguments, env)))
+
+ # test os._execvpe() with a relative path:
+ # os.get_exec_path() reads the 'PATH' variable
+ with _execvpe_mockup() as calls:
+ env_path = env.copy()
+ if test_type is bytes:
+ env_path[b'PATH'] = program_path
+ else:
+ env_path['PATH'] = program_path
+ self.assertRaises(OSError,
+ os._execvpe, program, arguments, env=env_path)
+ self.assertEqual(len(calls), 1)
+ self.assertSequenceEqual(calls[0],
+ ('execve', native_fullpath, (arguments, env_path)))
+
+ def test_internal_execvpe_str(self):
+ self._test_internal_execvpe(str)
+ if os.name != "nt":
+ self._test_internal_execvpe(bytes)
+
+
class Win32ErrorTests(unittest.TestCase):
def test_rename(self):
- self.assertRaises(WindowsError, os.rename, test_support.TESTFN, test_support.TESTFN+".bak")
+ self.assertRaises(WindowsError, os.rename, support.TESTFN, support.TESTFN+".bak")
def test_remove(self):
- self.assertRaises(WindowsError, os.remove, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.remove, support.TESTFN)
def test_chdir(self):
- self.assertRaises(WindowsError, os.chdir, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.chdir, support.TESTFN)
def test_mkdir(self):
- f = open(test_support.TESTFN, "w")
+ f = open(support.TESTFN, "w")
try:
- self.assertRaises(WindowsError, os.mkdir, test_support.TESTFN)
+ self.assertRaises(WindowsError, os.mkdir, support.TESTFN)
finally:
f.close()
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
def test_utime(self):
- self.assertRaises(WindowsError, os.utime, test_support.TESTFN, None)
+ self.assertRaises(WindowsError, os.utime, support.TESTFN, None)
def test_chmod(self):
- self.assertRaises(WindowsError, os.chmod, test_support.TESTFN, 0)
+ self.assertRaises(WindowsError, os.chmod, support.TESTFN, 0)
class TestInvalidFD(unittest.TestCase):
- singles = ["fchdir", "fdopen", "dup", "fdatasync", "fstat",
+ singles = ["fchdir", "dup", "fdopen", "fdatasync", "fstat",
"fstatvfs", "fsync", "tcgetpgrp", "ttyname"]
#singles.append("close")
#We omit close because it doesn'r raise an exception on some platforms
@@ -605,7 +853,7 @@ class TestInvalidFD(unittest.TestCase):
def check(self, f, *args):
try:
- f(test_support.make_bad_fd(), *args)
+ f(support.make_bad_fd(), *args)
except OSError as e:
self.assertEqual(e.errno, errno.EBADF)
else:
@@ -614,11 +862,11 @@ class TestInvalidFD(unittest.TestCase):
def test_isatty(self):
if hasattr(os, "isatty"):
- self.assertEqual(os.isatty(test_support.make_bad_fd()), False)
+ self.assertEqual(os.isatty(support.make_bad_fd()), False)
def test_closerange(self):
if hasattr(os, "closerange"):
- fd = test_support.make_bad_fd()
+ fd = support.make_bad_fd()
# Make sure none of the descriptors we are about to close are
# currently valid (issue 6542).
for i in range(10):
@@ -666,7 +914,43 @@ class TestInvalidFD(unittest.TestCase):
def test_write(self):
if hasattr(os, "write"):
- self.check(os.write, " ")
+ self.check(os.write, b" ")
+
+
+class LinkTests(unittest.TestCase):
+ def setUp(self):
+ self.file1 = support.TESTFN
+ self.file2 = os.path.join(support.TESTFN + "2")
+
+ def tearDown(self):
+ for file in (self.file1, self.file2):
+ if os.path.exists(file):
+ os.unlink(file)
+
+ def _test_link(self, file1, file2):
+ with open(file1, "w") as f1:
+ f1.write("test")
+
+ os.link(file1, file2)
+ with open(file1, "r") as f1, open(file2, "r") as f2:
+ self.assertTrue(os.path.sameopenfile(f1.fileno(), f2.fileno()))
+
+ def test_link(self):
+ self._test_link(self.file1, self.file2)
+
+ def test_link_bytes(self):
+ self._test_link(bytes(self.file1, sys.getfilesystemencoding()),
+ bytes(self.file2, sys.getfilesystemencoding()))
+
+ def test_unicode_name(self):
+ try:
+ os.fsencode("\xf1")
+ except UnicodeError:
+ raise unittest.SkipTest("Unable to encode for this platform.")
+
+ self.file1 += "\xf1"
+ self.file2 = self.file1 + "2"
+ self._test_link(self.file1, self.file2)
if sys.platform != 'win32':
class Win32ErrorTests(unittest.TestCase):
@@ -724,9 +1008,63 @@ if sys.platform != 'win32':
subprocess.check_call([
sys.executable, '-c',
'import os,sys;os.setregid(-1,-1);sys.exit(0)'])
+
+ class Pep383Tests(unittest.TestCase):
+ def setUp(self):
+ if support.TESTFN_UNENCODABLE:
+ self.dir = support.TESTFN_UNENCODABLE
+ else:
+ self.dir = support.TESTFN
+ self.bdir = os.fsencode(self.dir)
+
+ bytesfn = []
+ def add_filename(fn):
+ try:
+ fn = os.fsencode(fn)
+ except UnicodeEncodeError:
+ return
+ bytesfn.append(fn)
+ add_filename(support.TESTFN_UNICODE)
+ if support.TESTFN_UNENCODABLE:
+ add_filename(support.TESTFN_UNENCODABLE)
+ if not bytesfn:
+ self.skipTest("couldn't create any non-ascii filename")
+
+ self.unicodefn = set()
+ os.mkdir(self.dir)
+ try:
+ for fn in bytesfn:
+ f = open(os.path.join(self.bdir, fn), "w")
+ f.close()
+ fn = os.fsdecode(fn)
+ if fn in self.unicodefn:
+ raise ValueError("duplicate filename")
+ self.unicodefn.add(fn)
+ except:
+ shutil.rmtree(self.dir)
+ raise
+
+ def tearDown(self):
+ shutil.rmtree(self.dir)
+
+ def test_listdir(self):
+ expected = self.unicodefn
+ found = set(os.listdir(self.dir))
+ self.assertEqual(found, expected)
+
+ def test_open(self):
+ for fn in self.unicodefn:
+ f = open(os.path.join(self.dir, fn), 'rb')
+ f.close()
+
+ def test_stat(self):
+ for fn in self.unicodefn:
+ os.stat(os.path.join(self.dir, fn))
else:
class PosixUidGidTests(unittest.TestCase):
pass
+ class Pep383Tests(unittest.TestCase):
+ pass
@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
class Win32KillTests(unittest.TestCase):
@@ -774,7 +1112,7 @@ class Win32KillTests(unittest.TestCase):
buf, ctypes.sizeof(buf), None, None, None)
self.assertNotEqual(rslt, 0, "PeekNamedPipe failed")
if buf.value:
- self.assertEqual(msg, buf.value)
+ self.assertEqual(msg, buf.value.decode())
break
time.sleep(0.1)
count += 1
@@ -795,20 +1133,22 @@ class Win32KillTests(unittest.TestCase):
def _kill_with_event(self, event, name):
tagname = "test_os_%s" % uuid.uuid1()
m = mmap.mmap(-1, 1, tagname)
- m[0] = '0'
+ m[0] = 0
# Run a script which has console control handling enabled.
proc = subprocess.Popen([sys.executable,
os.path.join(os.path.dirname(__file__),
"win_console_handler.py"), tagname],
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
# Let the interpreter startup before we send signals. See #3137.
- count, max = 0, 20
+ count, max = 0, 100
while count < max and proc.poll() is None:
- if m[0] == '1':
+ if m[0] == 1:
break
- time.sleep(0.5)
+ time.sleep(0.1)
count += 1
else:
+ # Forcefully kill the process if we weren't able to signal it.
+ os.kill(proc.pid, signal.SIGINT)
self.fail("Subprocess didn't finish initialization")
os.kill(proc.pid, event)
# proc.send_signal(event) could also be done here.
@@ -842,20 +1182,180 @@ class Win32KillTests(unittest.TestCase):
self._kill_with_event(signal.CTRL_BREAK_EVENT, "CTRL_BREAK_EVENT")
+@unittest.skipUnless(sys.platform == "win32", "Win32 specific tests")
+@support.skip_unless_symlink
+class Win32SymlinkTests(unittest.TestCase):
+ filelink = 'filelinktest'
+ filelink_target = os.path.abspath(__file__)
+ dirlink = 'dirlinktest'
+ dirlink_target = os.path.dirname(filelink_target)
+ missing_link = 'missing link'
+
+ def setUp(self):
+ assert os.path.exists(self.dirlink_target)
+ assert os.path.exists(self.filelink_target)
+ assert not os.path.exists(self.dirlink)
+ assert not os.path.exists(self.filelink)
+ assert not os.path.exists(self.missing_link)
+
+ def tearDown(self):
+ if os.path.exists(self.filelink):
+ os.remove(self.filelink)
+ if os.path.exists(self.dirlink):
+ os.rmdir(self.dirlink)
+ if os.path.lexists(self.missing_link):
+ os.remove(self.missing_link)
+
+ def test_directory_link(self):
+ os.symlink(self.dirlink_target, self.dirlink, True)
+ self.assertTrue(os.path.exists(self.dirlink))
+ self.assertTrue(os.path.isdir(self.dirlink))
+ self.assertTrue(os.path.islink(self.dirlink))
+ self.check_stat(self.dirlink, self.dirlink_target)
+
+ def test_file_link(self):
+ os.symlink(self.filelink_target, self.filelink)
+ self.assertTrue(os.path.exists(self.filelink))
+ self.assertTrue(os.path.isfile(self.filelink))
+ self.assertTrue(os.path.islink(self.filelink))
+ self.check_stat(self.filelink, self.filelink_target)
+
+ def _create_missing_dir_link(self):
+ 'Create a "directory" link to a non-existent target'
+ linkname = self.missing_link
+ if os.path.lexists(linkname):
+ os.remove(linkname)
+ target = r'c:\\target does not exist.29r3c740'
+ assert not os.path.exists(target)
+ target_is_dir = True
+ os.symlink(target, linkname, target_is_dir)
+
+ def test_remove_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # For compatibility with Unix, os.remove will check the
+ # directory status and call RemoveDirectory if the symlink
+ # was created with target_is_dir==True.
+ os.remove(self.missing_link)
+
+ @unittest.skip("currently fails; consider for improvement")
+ def test_isdir_on_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # consider having isdir return true for directory links
+ self.assertTrue(os.path.isdir(self.missing_link))
+
+ @unittest.skip("currently fails; consider for improvement")
+ def test_rmdir_on_directory_link_to_missing_target(self):
+ self._create_missing_dir_link()
+ # consider allowing rmdir to remove directory links
+ os.rmdir(self.missing_link)
+
+ def check_stat(self, link, target):
+ self.assertEqual(os.stat(link), os.stat(target))
+ self.assertNotEqual(os.lstat(link), os.stat(link))
+
+ bytes_link = os.fsencode(link)
+ self.assertEqual(os.stat(bytes_link), os.stat(target))
+ self.assertNotEqual(os.lstat(bytes_link), os.stat(bytes_link))
+
+ def test_12084(self):
+ level1 = os.path.abspath(support.TESTFN)
+ level2 = os.path.join(level1, "level2")
+ level3 = os.path.join(level2, "level3")
+ try:
+ os.mkdir(level1)
+ os.mkdir(level2)
+ os.mkdir(level3)
+
+ file1 = os.path.abspath(os.path.join(level1, "file1"))
+
+ with open(file1, "w") as f:
+ f.write("file1")
+
+ orig_dir = os.getcwd()
+ try:
+ os.chdir(level2)
+ link = os.path.join(level2, "link")
+ os.symlink(os.path.relpath(file1), "link")
+ self.assertIn("link", os.listdir(os.getcwd()))
+
+ # Check os.stat calls from the same dir as the link
+ self.assertEqual(os.stat(file1), os.stat("link"))
+
+ # Check os.stat calls from a dir below the link
+ os.chdir(level1)
+ self.assertEqual(os.stat(file1),
+ os.stat(os.path.relpath(link)))
+
+ # Check os.stat calls from a dir above the link
+ os.chdir(level3)
+ self.assertEqual(os.stat(file1),
+ os.stat(os.path.relpath(link)))
+ finally:
+ os.chdir(orig_dir)
+ except OSError as err:
+ self.fail(err)
+ finally:
+ os.remove(file1)
+ shutil.rmtree(level1)
+
+
+class FSEncodingTests(unittest.TestCase):
+ def test_nop(self):
+ self.assertEqual(os.fsencode(b'abc\xff'), b'abc\xff')
+ self.assertEqual(os.fsdecode('abc\u0141'), 'abc\u0141')
+
+ def test_identity(self):
+ # assert fsdecode(fsencode(x)) == x
+ for fn in ('unicode\u0141', 'latin\xe9', 'ascii'):
+ try:
+ bytesfn = os.fsencode(fn)
+ except UnicodeEncodeError:
+ continue
+ self.assertEqual(os.fsdecode(bytesfn), fn)
+
+
+class PidTests(unittest.TestCase):
+ @unittest.skipUnless(hasattr(os, 'getppid'), "test needs os.getppid")
+ def test_getppid(self):
+ p = subprocess.Popen([sys.executable, '-c',
+ 'import os; print(os.getppid())'],
+ stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ # We are the parent of our subprocess
+ self.assertEqual(int(stdout), os.getpid())
+
+
+# The introduction of this TestCase caused at least two different errors on
+# *nix buildbots. Temporarily skip this to let the buildbots move along.
+@unittest.skip("Skip due to platform/environment differences on *NIX buildbots")
+@unittest.skipUnless(hasattr(os, 'getlogin'), "test needs os.getlogin")
+class LoginTests(unittest.TestCase):
+ def test_getlogin(self):
+ user_name = os.getlogin()
+ self.assertNotEqual(len(user_name), 0)
+
+
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
FileTests,
- TemporaryFileTests,
StatAttributeTests,
EnvironTests,
WalkTests,
MakedirTests,
DevNullTests,
URandomTests,
+ ExecTests,
Win32ErrorTests,
TestInvalidFD,
PosixUidGidTests,
- Win32KillTests
+ Pep383Tests,
+ Win32KillTests,
+ Win32SymlinkTests,
+ FSEncodingTests,
+ PidTests,
+ LoginTests,
+ LinkTests,
+ RemoveDirsTests,
)
if __name__ == "__main__":
diff --git a/Lib/test/test_ossaudiodev.py b/Lib/test/test_ossaudiodev.py
index 7a357a01ef9..9cb89d69a6d 100644
--- a/Lib/test/test_ossaudiodev.py
+++ b/Lib/test/test_ossaudiodev.py
@@ -1,9 +1,9 @@
-from test import test_support
-test_support.requires('audio')
+from test import support
+support.requires('audio')
-from test.test_support import findfile
+from test.support import findfile
-ossaudiodev = test_support.import_module('ossaudiodev')
+ossaudiodev = support.import_module('ossaudiodev')
import errno
import sys
@@ -44,7 +44,7 @@ class OSSAudioDevTests(unittest.TestCase):
def play_sound_file(self, data, rate, ssize, nchannels):
try:
dsp = ossaudiodev.open('w')
- except IOError, msg:
+ except IOError as msg:
if msg.args[0] in (errno.EACCES, errno.ENOENT,
errno.ENODEV, errno.EBUSY):
raise unittest.SkipTest(msg)
@@ -66,13 +66,13 @@ class OSSAudioDevTests(unittest.TestCase):
for attr in ('closed', 'name', 'mode'):
try:
setattr(dsp, attr, 42)
- except TypeError:
+ except (TypeError, AttributeError):
pass
else:
self.fail("dsp.%s not read-only" % attr)
# Compute expected running time of sound sample (in seconds).
- expected_time = float(len(data)) / (ssize//8) / nchannels / rate
+ expected_time = float(len(data)) / (ssize/8) / nchannels / rate
# set parameters based on .au file headers
dsp.setparameters(AFMT_S16_NE, nchannels, rate)
@@ -85,7 +85,8 @@ class OSSAudioDevTests(unittest.TestCase):
percent_diff = (abs(elapsed_time - expected_time) / expected_time) * 100
self.assertTrue(percent_diff <= 10.0,
- "elapsed time > 10% off of expected time")
+ "elapsed time (%s) > 10%% off of expected time (%s)" %
+ (elapsed_time, expected_time))
def set_parameters(self, dsp):
# Two configurations for testing:
@@ -137,7 +138,7 @@ class OSSAudioDevTests(unittest.TestCase):
try:
result = dsp.setparameters(fmt, channels, rate, True)
- except ossaudiodev.OSSAudioError, err:
+ except ossaudiodev.OSSAudioError as err:
pass
else:
self.fail("expected OSSAudioError")
@@ -158,17 +159,28 @@ class OSSAudioDevTests(unittest.TestCase):
dsp.close()
self.assertTrue(dsp.closed)
+ def test_mixer_methods(self):
+ # Issue #8139: ossaudiodev didn't initialize its types properly,
+ # therefore some methods were unavailable.
+ with ossaudiodev.openmixer() as mixer:
+ self.assertGreaterEqual(mixer.fileno(), 0)
+
+ def test_with(self):
+ with ossaudiodev.open('w') as dsp:
+ pass
+ self.assertTrue(dsp.closed)
+
def test_main():
try:
dsp = ossaudiodev.open('w')
- except (ossaudiodev.error, IOError), msg:
+ except (ossaudiodev.error, IOError) as msg:
if msg.args[0] in (errno.EACCES, errno.ENOENT,
errno.ENODEV, errno.EBUSY):
raise unittest.SkipTest(msg)
raise
dsp.close()
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_osx_env.py b/Lib/test/test_osx_env.py
new file mode 100644
index 00000000000..8b3df3783bd
--- /dev/null
+++ b/Lib/test/test_osx_env.py
@@ -0,0 +1,36 @@
+"""
+Test suite for OS X interpreter environment variables.
+"""
+
+from test.support import EnvironmentVarGuard, run_unittest
+import subprocess
+import sys
+import unittest
+
+class OSXEnvironmentVariableTestCase(unittest.TestCase):
+ def _check_sys(self, ev, cond, sv, val = sys.executable + 'dummy'):
+ with EnvironmentVarGuard() as evg:
+ subpc = [str(sys.executable), '-c',
+ 'import sys; sys.exit(2 if "%s" %s %s else 3)' % (val, cond, sv)]
+ # ensure environment variable does not exist
+ evg.unset(ev)
+ # test that test on sys.xxx normally fails
+ rc = subprocess.call(subpc)
+ self.assertEqual(rc, 3, "expected %s not %s %s" % (ev, cond, sv))
+ # set environ variable
+ evg.set(ev, val)
+ # test that sys.xxx has been influenced by the environ value
+ rc = subprocess.call(subpc)
+ self.assertEqual(rc, 2, "expected %s %s %s" % (ev, cond, sv))
+
+ def test_pythonexecutable_sets_sys_executable(self):
+ self._check_sys('PYTHONEXECUTABLE', '==', 'sys.executable')
+
+def test_main():
+ from distutils import sysconfig
+
+ if sys.platform == 'darwin' and sysconfig.get_config_var('WITH_NEXT_FRAMEWORK'):
+ run_unittest(OSXEnvironmentVariableTestCase)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_parser.py b/Lib/test/test_parser.py
index 12fa89cd464..70eb9c0cc2b 100644
--- a/Lib/test/test_parser.py
+++ b/Lib/test/test_parser.py
@@ -1,8 +1,9 @@
import parser
import unittest
import sys
+import operator
import struct
-from test import test_support as support
+from test import support
#
# First, we test that we can generate trees from valid source fragments,
@@ -17,7 +18,7 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
t = st1.totuple()
try:
st2 = parser.sequence2st(t)
- except parser.ParserError, why:
+ except parser.ParserError as why:
self.fail("could not roundtrip %r: %s" % (s, why))
self.assertEqual(t, st2.totuple(),
@@ -32,8 +33,8 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
suite = parser.suite("from __future__ import unicode_literals; x = ''")
code = suite.compile()
scope = {}
- exec code in scope
- self.assertIsInstance(scope["x"], unicode)
+ exec(code, {}, scope)
+ self.assertIsInstance(scope["x"], str)
def check_suite(self, s):
self.roundtrip(parser.suite, s)
@@ -57,39 +58,25 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
" if (yield):\n"
" yield x\n")
+ def test_nonlocal_statement(self):
+ self.check_suite("def f():\n"
+ " x = 0\n"
+ " def g():\n"
+ " nonlocal x\n")
+ self.check_suite("def f():\n"
+ " x = y = 0\n"
+ " def g():\n"
+ " nonlocal x, y\n")
+
def test_expressions(self):
self.check_expr("foo(1)")
- self.check_expr("{1:1}")
- self.check_expr("{1:1, 2:2, 3:3}")
- self.check_expr("{1:1, 2:2, 3:3,}")
- self.check_expr("{1}")
- self.check_expr("{1, 2, 3}")
- self.check_expr("{1, 2, 3,}")
- self.check_expr("[]")
- self.check_expr("[1]")
self.check_expr("[1, 2, 3]")
- self.check_expr("[1, 2, 3,]")
- self.check_expr("()")
- self.check_expr("(1,)")
- self.check_expr("(1, 2, 3)")
- self.check_expr("(1, 2, 3,)")
self.check_expr("[x**3 for x in range(20)]")
self.check_expr("[x**3 for x in range(20) if x % 3]")
self.check_expr("[x**3 for x in range(20) if x % 2 if x % 3]")
- self.check_expr("[x+y for x in range(30) for y in range(20) if x % 2 if y % 3]")
- #self.check_expr("[x for x in lambda: True, lambda: False if x()]")
self.check_expr("list(x**3 for x in range(20))")
self.check_expr("list(x**3 for x in range(20) if x % 3)")
self.check_expr("list(x**3 for x in range(20) if x % 2 if x % 3)")
- self.check_expr("list(x+y for x in range(30) for y in range(20) if x % 2 if y % 3)")
- self.check_expr("{x**3 for x in range(30)}")
- self.check_expr("{x**3 for x in range(30) if x % 3}")
- self.check_expr("{x**3 for x in range(30) if x % 2 if x % 3}")
- self.check_expr("{x+y for x in range(30) for y in range(20) if x % 2 if y % 3}")
- self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30))}")
- self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30)) if x % 3}")
- self.check_expr("{x**3: y**2 for x, y in zip(range(30), range(30)) if x % 3 if y % 3}")
- self.check_expr("{x:y for x in range(30) for y in range(20) if x % 2 if y % 3}")
self.check_expr("foo(*args)")
self.check_expr("foo(*args, **kw)")
self.check_expr("foo(**kw)")
@@ -118,17 +105,10 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_expr("lambda foo=bar, blaz=blat+2, **z: 0")
self.check_expr("lambda foo=bar, blaz=blat+2, *y, **z: 0")
self.check_expr("lambda x, *y, **z: 0")
- self.check_expr("lambda x: 5 if x else 2")
self.check_expr("(x for x in range(10))")
self.check_expr("foo(x for x in range(10))")
-
- def test_print(self):
- self.check_suite("print")
- self.check_suite("print 1")
- self.check_suite("print 1,")
- self.check_suite("print >>fp")
- self.check_suite("print >>fp, 1")
- self.check_suite("print >>fp, 1,")
+ self.check_expr("...")
+ self.check_expr("a[...]")
def test_simple_expression(self):
# expr_stmt
@@ -179,8 +159,30 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_suite("@funcattrs()\n"
"def f(): pass")
+ # keyword-only arguments
+ self.check_suite("def f(*, a): pass")
+ self.check_suite("def f(*, a = 5): pass")
+ self.check_suite("def f(*, a = 5, b): pass")
+ self.check_suite("def f(*, a, b = 5): pass")
+ self.check_suite("def f(*, a, b = 5, **kwds): pass")
+ self.check_suite("def f(*args, a): pass")
+ self.check_suite("def f(*args, a = 5): pass")
+ self.check_suite("def f(*args, a = 5, b): pass")
+ self.check_suite("def f(*args, a, b = 5): pass")
+ self.check_suite("def f(*args, a, b = 5, **kwds): pass")
+
+ # function annotations
+ self.check_suite("def f(a: int): pass")
+ self.check_suite("def f(a: int = 5): pass")
+ self.check_suite("def f(*args: list): pass")
+ self.check_suite("def f(**kwds: dict): pass")
+ self.check_suite("def f(*, a: int): pass")
+ self.check_suite("def f(*, a: int = 5): pass")
+ self.check_suite("def f() -> int: pass")
+
def test_class_defs(self):
self.check_suite("class foo():pass")
+ self.check_suite("class foo(object):pass")
self.check_suite("@class_decorator\n"
"class foo():pass")
self.check_suite("@class_decorator(arg)\n"
@@ -189,7 +191,6 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
"@decorator2\n"
"class foo():pass")
-
def test_import_from_statement(self):
self.check_suite("from sys.path import *")
self.check_suite("from sys.path import dirname")
@@ -225,8 +226,14 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
def test_relative_imports(self):
self.check_suite("from . import name")
self.check_suite("from .. import name")
+ # check all the way up to '....', since '...' is tokenized
+ # differently from '.' (it's an ellipsis token).
+ self.check_suite("from ... import name")
+ self.check_suite("from .... import name")
self.check_suite("from .pkg import name")
self.check_suite("from ..pkg import name")
+ self.check_suite("from ...pkg import name")
+ self.check_suite("from ....pkg import name")
def test_pep263(self):
self.check_suite("# -*- coding: iso-8859-1 -*-\n"
@@ -250,12 +257,6 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
self.check_suite("try: pass\nexcept: pass\nelse: pass\n"
"finally: pass\n")
- def test_except_clause(self):
- self.check_suite("try: pass\nexcept: pass\n")
- self.check_suite("try: pass\nexcept A: pass\n")
- self.check_suite("try: pass\nexcept A, e: pass\n")
- self.check_suite("try: pass\nexcept A as e: pass\n")
-
def test_position(self):
# An absolutely minimal test of position information. Better
# tests would be a big project.
@@ -293,6 +294,43 @@ class RoundtripLegalSyntaxTestCase(unittest.TestCase):
(0, '', 2, -1)],
terminals)
+ def test_extended_unpacking(self):
+ self.check_suite("*a = y")
+ self.check_suite("x, *b, = m")
+ self.check_suite("[*a, *b] = y")
+ self.check_suite("for [*x, b] in x: pass")
+
+ def test_raise_statement(self):
+ self.check_suite("raise\n")
+ self.check_suite("raise e\n")
+ self.check_suite("try:\n"
+ " suite\n"
+ "except Exception as e:\n"
+ " raise ValueError from e\n")
+
+ def test_set_displays(self):
+ self.check_expr('{2}')
+ self.check_expr('{2,}')
+ self.check_expr('{2, 3}')
+ self.check_expr('{2, 3,}')
+
+ def test_dict_displays(self):
+ self.check_expr('{}')
+ self.check_expr('{a:b}')
+ self.check_expr('{a:b,}')
+ self.check_expr('{a:b, c:d}')
+ self.check_expr('{a:b, c:d,}')
+
+ def test_set_comprehensions(self):
+ self.check_expr('{x for x in seq}')
+ self.check_expr('{f(x) for x in seq}')
+ self.check_expr('{f(x) for x in seq if condition(x)}')
+
+ def test_dict_comprehensions(self):
+ self.check_expr('{x:x for x in seq}')
+ self.check_expr('{x**2:x[3] for x in seq if condition(x)}')
+ self.check_expr('{x:x for x in seq1 for y in seq2 if condition(x, y)}')
+
#
# Second, we take *invalid* trees and make sure we get ParserError
@@ -432,29 +470,6 @@ class IllegalSyntaxTestCase(unittest.TestCase):
(0, ''))))
self.check_bad_tree(tree, "def f():\n return 1\n yield 1")
- def test_print_chevron_comma(self):
- # Illegal input: print >>fp,
- tree = \
- (257,
- (264,
- (265,
- (266,
- (268,
- (1, 'print'),
- (35, '>>'),
- (290,
- (291,
- (292,
- (293,
- (295,
- (296,
- (297,
- (298, (299, (300, (301, (302, (303, (1, 'fp')))))))))))))),
- (12, ','))),
- (4, ''))),
- (0, ''))
- self.check_bad_tree(tree, "print >>fp,")
-
def test_a_comma_comma_c(self):
# Illegal input: a,,c
tree = \
@@ -527,18 +542,18 @@ class IllegalSyntaxTestCase(unittest.TestCase):
self.check_bad_tree(tree, "malformed global ast")
def test_missing_import_source(self):
- # from import a
+ # from import fred
tree = \
(257,
- (267,
- (268,
- (269,
- (281,
- (283, (1, 'from'), (1, 'import'),
- (286, (284, (1, 'fred')))))),
+ (268,
+ (269,
+ (270,
+ (282,
+ (284, (1, 'from'), (1, 'import'),
+ (287, (285, (1, 'fred')))))),
(4, ''))),
(4, ''), (0, ''))
- self.check_bad_tree(tree, "from import a")
+ self.check_bad_tree(tree, "from import fred")
class CompileTestCase(unittest.TestCase):
@@ -554,7 +569,7 @@ class CompileTestCase(unittest.TestCase):
st = parser.suite('x = 2; y = x + 3')
code = parser.compilest(st)
globs = {}
- exec code in globs
+ exec(code, globs)
self.assertEqual(globs['y'], 5)
def test_compile_error(self):
@@ -562,9 +577,9 @@ class CompileTestCase(unittest.TestCase):
self.assertRaises(SyntaxError, parser.compilest, st)
def test_compile_badunicode(self):
- st = parser.suite('a = u"\U12345678"')
+ st = parser.suite('a = "\\U12345678"')
self.assertRaises(SyntaxError, parser.compilest, st)
- st = parser.suite('a = u"\u1"')
+ st = parser.suite('a = "\\u1"')
self.assertRaises(SyntaxError, parser.compilest, st)
def test_issue_9011(self):
@@ -577,27 +592,90 @@ class CompileTestCase(unittest.TestCase):
code2 = parser.compilest(st)
self.assertEqual(eval(code2), -3)
-
class ParserStackLimitTestCase(unittest.TestCase):
- """try to push the parser to/over it's limits.
+ """try to push the parser to/over its limits.
see http://bugs.python.org/issue1881 for a discussion
"""
def _nested_expression(self, level):
return "["*level+"]"*level
def test_deeply_nested_list(self):
- e = self._nested_expression(99)
+ # XXX used to be 99 levels in 2.x
+ e = self._nested_expression(93)
st = parser.expr(e)
st.compile()
def test_trigger_memory_error(self):
e = self._nested_expression(100)
- print >>sys.stderr, "Expecting 's_push: parser stack overflow' in next line"
+ print("Expecting 's_push: parser stack overflow' in next line",
+ file=sys.stderr)
+ sys.stderr.flush()
self.assertRaises(MemoryError, parser.expr, e)
class STObjectTestCase(unittest.TestCase):
"""Test operations on ST objects themselves"""
+ def test_comparisons(self):
+ # ST objects should support order and equality comparisons
+ st1 = parser.expr('2 + 3')
+ st2 = parser.suite('x = 2; y = x + 3')
+ st3 = parser.expr('list(x**3 for x in range(20))')
+ st1_copy = parser.expr('2 + 3')
+ st2_copy = parser.suite('x = 2; y = x + 3')
+ st3_copy = parser.expr('list(x**3 for x in range(20))')
+
+ # exercise fast path for object identity
+ self.assertEqual(st1 == st1, True)
+ self.assertEqual(st2 == st2, True)
+ self.assertEqual(st3 == st3, True)
+ # slow path equality
+ self.assertEqual(st1, st1_copy)
+ self.assertEqual(st2, st2_copy)
+ self.assertEqual(st3, st3_copy)
+ self.assertEqual(st1 == st2, False)
+ self.assertEqual(st1 == st3, False)
+ self.assertEqual(st2 == st3, False)
+ self.assertEqual(st1 != st1, False)
+ self.assertEqual(st2 != st2, False)
+ self.assertEqual(st3 != st3, False)
+ self.assertEqual(st1 != st1_copy, False)
+ self.assertEqual(st2 != st2_copy, False)
+ self.assertEqual(st3 != st3_copy, False)
+ self.assertEqual(st2 != st1, True)
+ self.assertEqual(st1 != st3, True)
+ self.assertEqual(st3 != st2, True)
+ # we don't particularly care what the ordering is; just that
+ # it's usable and self-consistent
+ self.assertEqual(st1 < st2, not (st2 <= st1))
+ self.assertEqual(st1 < st3, not (st3 <= st1))
+ self.assertEqual(st2 < st3, not (st3 <= st2))
+ self.assertEqual(st1 < st2, st2 > st1)
+ self.assertEqual(st1 < st3, st3 > st1)
+ self.assertEqual(st2 < st3, st3 > st2)
+ self.assertEqual(st1 <= st2, st2 >= st1)
+ self.assertEqual(st3 <= st1, st1 >= st3)
+ self.assertEqual(st2 <= st3, st3 >= st2)
+ # transitivity
+ bottom = min(st1, st2, st3)
+ top = max(st1, st2, st3)
+ mid = sorted([st1, st2, st3])[1]
+ self.assertTrue(bottom < mid)
+ self.assertTrue(bottom < top)
+ self.assertTrue(mid < top)
+ self.assertTrue(bottom <= mid)
+ self.assertTrue(bottom <= top)
+ self.assertTrue(mid <= top)
+ self.assertTrue(bottom <= bottom)
+ self.assertTrue(mid <= mid)
+ self.assertTrue(top <= top)
+ # interaction with other types
+ self.assertEqual(st1 == 1588.602459, False)
+ self.assertEqual('spanish armada' != st2, True)
+ self.assertRaises(TypeError, operator.ge, st3, None)
+ self.assertRaises(TypeError, operator.le, False, st1)
+ self.assertRaises(TypeError, operator.lt, st1, 1815)
+ self.assertRaises(TypeError, operator.gt, b'waterloo', st2)
+
check_sizeof = support.check_sizeof
@support.cpython_only
@@ -639,6 +717,7 @@ class STObjectTestCase(unittest.TestCase):
# XXX tests for pickling and unpickling of ST objects should go here
+
def test_main():
support.run_unittest(
RoundtripLegalSyntaxTestCase,
diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
index 559f75623f4..8355e7d9558 100644
--- a/Lib/test/test_pdb.py
+++ b/Lib/test/test_pdb.py
@@ -1,72 +1,15 @@
-# A test suite for pdb; at the moment, this only validates skipping of
-# specified test modules (RFE #5142).
+# A test suite for pdb; not very comprehensive at the moment.
import imp
+import pdb
import sys
-import os
import unittest
import subprocess
import textwrap
-from test import test_support
+from test import support
# This little helper class is essential for testing pdb under doctest.
-from test_doctest import _FakeInput
-
-
-class PdbTestCase(unittest.TestCase):
-
- def run_pdb(self, script, commands):
- """Run 'script' lines with pdb and the pdb 'commands'."""
- filename = 'main.py'
- with open(filename, 'w') as f:
- f.write(textwrap.dedent(script))
- self.addCleanup(test_support.unlink, filename)
- cmd = [sys.executable, '-m', 'pdb', filename]
- stdout = stderr = None
- proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
- stdin=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- )
- stdout, stderr = proc.communicate(commands)
- proc.stdout.close()
- proc.stdin.close()
- return stdout, stderr
-
- def test_issue13183(self):
- script = """
- from bar import bar
-
- def foo():
- bar()
-
- def nope():
- pass
-
- def foobar():
- foo()
- nope()
-
- foobar()
- """
- commands = """
- from bar import bar
- break bar
- continue
- step
- step
- quit
- """
- bar = """
- def bar():
- pass
- """
- with open('bar.py', 'w') as f:
- f.write(textwrap.dedent(bar))
- self.addCleanup(test_support.unlink, 'bar.py')
- stdout, stderr = self.run_pdb(script, commands)
- self.assertTrue(
- any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
- 'Fail to step into the caller after a return')
+from test.test_doctest import _FakeInput
class PdbTestInput(object):
@@ -83,20 +26,17 @@ class PdbTestInput(object):
sys.stdin = self.real_stdin
-def write(x):
- print x
-
def test_pdb_displayhook():
"""This tests the custom displayhook for pdb.
>>> def test_function(foo, bar):
- ... import pdb; pdb.Pdb().set_trace()
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
... pass
>>> with PdbTestInput([
... 'foo',
... 'bar',
- ... 'for i in range(5): write(i)',
+ ... 'for i in range(5): print(i)',
... 'continue',
... ]):
... test_function(1, None)
@@ -105,20 +45,131 @@ def test_pdb_displayhook():
(Pdb) foo
1
(Pdb) bar
- (Pdb) for i in range(5): write(i)
+ (Pdb) for i in range(5): print(i)
+ 0
+ 1
+ 2
+ 3
+ 4
+ (Pdb) continue
+ """
+
+
+def test_pdb_basic_commands():
+ """Test the basic commands of pdb.
+
+ >>> def test_function_2(foo, bar='default'):
+ ... print(foo)
+ ... for i in range(5):
+ ... print(i)
+ ... print(bar)
+ ... for i in range(10):
+ ... never_executed
+ ... print('after for')
+ ... print('...')
+ ... return foo.upper()
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... ret = test_function_2('baz')
+ ... print(ret)
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'step', # entering the function call
+ ... 'args', # display function args
+ ... 'list', # list function source
+ ... 'bt', # display backtrace
+ ... 'up', # step up to test_function()
+ ... 'down', # step down to test_function_2() again
+ ... 'next', # stepping to print(foo)
+ ... 'next', # stepping to the for loop
+ ... 'step', # stepping into the for loop
+ ... 'until', # continuing until out of the for loop
+ ... 'next', # executing the print(bar)
+ ... 'jump 8', # jump over second for loop
+ ... 'return', # return out of function
+ ... 'retval', # display return value
+ ... 'continue',
+ ... ]):
+ ... test_function()
+ > <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) args
+ foo = 'baz'
+ bar = 'default'
+ (Pdb) list
+ 1 -> def test_function_2(foo, bar='default'):
+ 2 print(foo)
+ 3 for i in range(5):
+ 4 print(i)
+ 5 print(bar)
+ 6 for i in range(10):
+ 7 never_executed
+ 8 print('after for')
+ 9 print('...')
+ 10 return foo.upper()
+ [EOF]
+ (Pdb) bt
+ ...
+ <doctest test.test_pdb.test_pdb_basic_commands[2]>(18)<module>()
+ -> test_function()
+ <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) up
+ > <doctest test.test_pdb.test_pdb_basic_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) down
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo, bar='default'):
+ (Pdb) next
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(2)test_function_2()
+ -> print(foo)
+ (Pdb) next
+ baz
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(3)test_function_2()
+ -> for i in range(5):
+ (Pdb) step
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(4)test_function_2()
+ -> print(i)
+ (Pdb) until
0
1
2
3
4
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(5)test_function_2()
+ -> print(bar)
+ (Pdb) next
+ default
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(6)test_function_2()
+ -> for i in range(10):
+ (Pdb) jump 8
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(8)test_function_2()
+ -> print('after for')
+ (Pdb) return
+ after for
+ ...
+ --Return--
+ > <doctest test.test_pdb.test_pdb_basic_commands[0]>(10)test_function_2()->'BAZ'
+ -> return foo.upper()
+ (Pdb) retval
+ 'BAZ'
(Pdb) continue
+ BAZ
"""
+
def test_pdb_breakpoint_commands():
"""Test basic commands related to breakpoints.
>>> def test_function():
- ... import pdb; pdb.Pdb().set_trace()
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
... print(1)
... print(2)
... print(3)
@@ -166,9 +217,11 @@ def test_pdb_breakpoint_commands():
(Pdb) break 3
Breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) disable 1
+ Disabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) ignore 1 10
Will ignore next 10 crossings of breakpoint 1.
(Pdb) condition 1 1 < 2
+ New condition set for breakpoint 1.
(Pdb) break 4
Breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break 4
@@ -181,7 +234,7 @@ def test_pdb_breakpoint_commands():
2 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
3 breakpoint keep yes at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) clear 3
- Deleted breakpoint 3
+ Deleted breakpoint 3 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) break
Num Type Disp Enb Where
1 breakpoint keep no at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
@@ -191,8 +244,9 @@ def test_pdb_breakpoint_commands():
(Pdb) condition 1
Breakpoint 1 is now unconditional.
(Pdb) enable 1
+ Enabled breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) clear 1
- Deleted breakpoint 1
+ Deleted breakpoint 1 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:3
(Pdb) commands 2
(com) print 42
(com) end
@@ -203,11 +257,12 @@ def test_pdb_breakpoint_commands():
-> print(2)
(Pdb) clear
Clear all breaks? y
+ Deleted breakpoint 2 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:4
(Pdb) tbreak 5
Breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
(Pdb) continue
2
- Deleted breakpoint 4
+ Deleted breakpoint 4 at <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>:5
> <doctest test.test_pdb.test_pdb_breakpoint_commands[0]>(5)test_function()
-> print(3)
(Pdb) break
@@ -217,13 +272,177 @@ def test_pdb_breakpoint_commands():
"""
+def do_nothing():
+ pass
+
+def do_something():
+ print(42)
+
+def test_list_commands():
+ """Test the list and source commands of pdb.
+
+ >>> def test_function_2(foo):
+ ... import test.test_pdb
+ ... test.test_pdb.do_nothing()
+ ... 'some...'
+ ... 'more...'
+ ... 'code...'
+ ... 'to...'
+ ... 'make...'
+ ... 'a...'
+ ... 'long...'
+ ... 'listing...'
+ ... 'useful...'
+ ... '...'
+ ... '...'
+ ... return foo
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... ret = test_function_2('baz')
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'list', # list first function
+ ... 'step', # step into second function
+ ... 'list', # list second function
+ ... 'list', # continue listing to EOF
+ ... 'list 1,3', # list specific lines
+ ... 'list x', # invalid argument
+ ... 'next', # step to import
+ ... 'next', # step over import
+ ... 'step', # step into do_nothing
+ ... 'longlist', # list all lines
+ ... 'source do_something', # list all lines of function
+ ... 'source fooxxx', # something that doesn't exit
+ ... 'continue',
+ ... ]):
+ ... test_function()
+ > <doctest test.test_pdb.test_list_commands[1]>(3)test_function()
+ -> ret = test_function_2('baz')
+ (Pdb) list
+ 1 def test_function():
+ 2 import pdb; pdb.Pdb(nosigint=True).set_trace()
+ 3 -> ret = test_function_2('baz')
+ [EOF]
+ (Pdb) step
+ --Call--
+ > <doctest test.test_pdb.test_list_commands[0]>(1)test_function_2()
+ -> def test_function_2(foo):
+ (Pdb) list
+ 1 -> def test_function_2(foo):
+ 2 import test.test_pdb
+ 3 test.test_pdb.do_nothing()
+ 4 'some...'
+ 5 'more...'
+ 6 'code...'
+ 7 'to...'
+ 8 'make...'
+ 9 'a...'
+ 10 'long...'
+ 11 'listing...'
+ (Pdb) list
+ 12 'useful...'
+ 13 '...'
+ 14 '...'
+ 15 return foo
+ [EOF]
+ (Pdb) list 1,3
+ 1 -> def test_function_2(foo):
+ 2 import test.test_pdb
+ 3 test.test_pdb.do_nothing()
+ (Pdb) list x
+ *** ...
+ (Pdb) next
+ > <doctest test.test_pdb.test_list_commands[0]>(2)test_function_2()
+ -> import test.test_pdb
+ (Pdb) next
+ > <doctest test.test_pdb.test_list_commands[0]>(3)test_function_2()
+ -> test.test_pdb.do_nothing()
+ (Pdb) step
+ --Call--
+ > ...test_pdb.py(...)do_nothing()
+ -> def do_nothing():
+ (Pdb) longlist
+ ... -> def do_nothing():
+ ... pass
+ (Pdb) source do_something
+ ... def do_something():
+ ... print(42)
+ (Pdb) source fooxxx
+ *** ...
+ (Pdb) continue
+ """
+
+
+def test_post_mortem():
+ """Test post mortem traceback debugging.
+
+ >>> def test_function_2():
+ ... try:
+ ... 1/0
+ ... finally:
+ ... print('Exception!')
+
+ >>> def test_function():
+ ... import pdb; pdb.Pdb(nosigint=True).set_trace()
+ ... test_function_2()
+ ... print('Not reached.')
+
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ... 'next', # step over exception-raising call
+ ... 'bt', # get a backtrace
+ ... 'list', # list code of test_function()
+ ... 'down', # step into test_function_2()
+ ... 'list', # list code of test_function_2()
+ ... 'continue',
+ ... ]):
+ ... try:
+ ... test_function()
+ ... except ZeroDivisionError:
+ ... print('Correctly reraised.')
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ (Pdb) next
+ Exception!
+ ZeroDivisionError: division by zero
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ (Pdb) bt
+ ...
+ <doctest test.test_pdb.test_post_mortem[2]>(10)<module>()
+ -> test_function()
+ > <doctest test.test_pdb.test_post_mortem[1]>(3)test_function()
+ -> test_function_2()
+ <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2()
+ -> 1/0
+ (Pdb) list
+ 1 def test_function():
+ 2 import pdb; pdb.Pdb(nosigint=True).set_trace()
+ 3 -> test_function_2()
+ 4 print('Not reached.')
+ [EOF]
+ (Pdb) down
+ > <doctest test.test_pdb.test_post_mortem[0]>(3)test_function_2()
+ -> 1/0
+ (Pdb) list
+ 1 def test_function_2():
+ 2 try:
+ 3 >> 1/0
+ 4 finally:
+ 5 -> print('Exception!')
+ [EOF]
+ (Pdb) continue
+ Correctly reraised.
+ """
+
+
def test_pdb_skip_modules():
"""This illustrates the simple case of module skipping.
>>> def skip_module():
... import string
- ... import pdb; pdb.Pdb(skip=['string*']).set_trace()
- ... string.lower('FOO')
+ ... import pdb; pdb.Pdb(skip=['stri*'], nosigint=True).set_trace()
+ ... string.capwords('FOO')
>>> with PdbTestInput([
... 'step',
@@ -231,18 +450,18 @@ def test_pdb_skip_modules():
... ]):
... skip_module()
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()
- -> string.lower('FOO')
+ -> string.capwords('FOO')
(Pdb) step
--Return--
> <doctest test.test_pdb.test_pdb_skip_modules[0]>(4)skip_module()->None
- -> string.lower('FOO')
+ -> string.capwords('FOO')
(Pdb) continue
"""
# Module for testing skipping of module that makes a callback
mod = imp.new_module('module_to_skip')
-exec 'def foo_pony(callback): x = 1; callback(); return None' in mod.__dict__
+exec('def foo_pony(callback): x = 1; callback(); return None', mod.__dict__)
def test_pdb_skip_modules_with_callback():
@@ -251,7 +470,7 @@ def test_pdb_skip_modules_with_callback():
>>> def skip_module():
... def callback():
... return None
- ... import pdb; pdb.Pdb(skip=['module_to_skip*']).set_trace()
+ ... import pdb; pdb.Pdb(skip=['module_to_skip*'], nosigint=True).set_trace()
... mod.foo_pony(callback)
>>> with PdbTestInput([
@@ -292,7 +511,7 @@ def test_pdb_continue_in_bottomframe():
"""Test that "continue" and "next" work properly in bottom frame (issue #5294).
>>> def test_function():
- ... import pdb, sys; inst = pdb.Pdb()
+ ... import pdb, sys; inst = pdb.Pdb(nosigint=True)
... inst.set_trace()
... inst.botframe = sys._getframe() # hackery to get the right botframe
... print(1)
@@ -300,15 +519,7 @@ def test_pdb_continue_in_bottomframe():
... print(3)
... print(4)
- First, need to clear bdb state that might be left over from previous tests.
- Otherwise, the new breakpoints might get assigned different numbers.
-
- >>> from bdb import Breakpoint
- >>> Breakpoint.next = 1
- >>> Breakpoint.bplist = {}
- >>> Breakpoint.bpbynumber = [None]
-
- >>> with PdbTestInput([
+ >>> with PdbTestInput([ # doctest: +ELLIPSIS
... 'next',
... 'break 7',
... 'continue',
@@ -323,7 +534,7 @@ def test_pdb_continue_in_bottomframe():
> <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>(5)test_function()
-> print(1)
(Pdb) break 7
- Breakpoint 1 at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7
+ Breakpoint ... at <doctest test.test_pdb.test_pdb_continue_in_bottomframe[0]>:7
(Pdb) continue
1
2
@@ -337,38 +548,161 @@ def test_pdb_continue_in_bottomframe():
4
"""
-class ModuleInitTester(unittest.TestCase):
- def test_filename_correct(self):
+def pdb_invoke(method, arg):
+ """Run pdb.method(arg)."""
+ import pdb
+ getattr(pdb.Pdb(nosigint=True), method)(arg)
+
+
+def test_pdb_run_with_incorrect_argument():
+ """Testing run and runeval with incorrect first argument.
+
+ >>> pti = PdbTestInput(['continue',])
+ >>> with pti:
+ ... pdb_invoke('run', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: exec() arg 1 must be a string, bytes or code object
+
+ >>> with pti:
+ ... pdb_invoke('runeval', lambda x: x)
+ Traceback (most recent call last):
+ TypeError: eval() arg 1 must be a string, bytes or code object
+ """
+
+
+def test_pdb_run_with_code_object():
+ """Testing run and runeval with code object as a first argument.
+
+ >>> with PdbTestInput(['step','x', 'continue']): # doctest: +ELLIPSIS
+ ... pdb_invoke('run', compile('x=1', '<string>', 'exec'))
+ > <string>(1)<module>()...
+ (Pdb) step
+ --Return--
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+
+ >>> with PdbTestInput(['x', 'continue']):
+ ... x=0
+ ... pdb_invoke('runeval', compile('x+1', '<string>', 'eval'))
+ > <string>(1)<module>()->None
+ (Pdb) x
+ 1
+ (Pdb) continue
+ """
+
+
+class PdbTestCase(unittest.TestCase):
+
+ def run_pdb(self, script, commands):
+ """Run 'script' lines with pdb and the pdb 'commands'."""
+ filename = 'main.py'
+ with open(filename, 'w') as f:
+ f.write(textwrap.dedent(script))
+ self.addCleanup(support.unlink, filename)
+ cmd = [sys.executable, '-m', 'pdb', filename]
+ stdout = stderr = None
+ with subprocess.Popen(cmd, stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ ) as proc:
+ stdout, stderr = proc.communicate(str.encode(commands))
+ stdout = stdout and bytes.decode(stdout)
+ stderr = stderr and bytes.decode(stderr)
+ return stdout, stderr
+
+ def test_issue7964(self):
+ # open the file as binary so we can force \r\n newline
+ with open(support.TESTFN, 'wb') as f:
+ f.write(b'print("testing my pdb")\r\n')
+ cmd = [sys.executable, '-m', 'pdb', support.TESTFN]
+ proc = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ )
+ self.addCleanup(proc.stdout.close)
+ stdout, stderr = proc.communicate(b'quit\n')
+ self.assertNotIn(b'SyntaxError', stdout,
+ "Got a syntax error running test script under PDB")
+
+ def test_issue13183(self):
+ script = """
+ from bar import bar
+
+ def foo():
+ bar()
+
+ def nope():
+ pass
+
+ def foobar():
+ foo()
+ nope()
+
+ foobar()
+ """
+ commands = """
+ from bar import bar
+ break bar
+ continue
+ step
+ step
+ quit
"""
- In issue 7750, it was found that if the filename has a sequence that
- resolves to an escape character in a Python string (such as \t), it
- will be treated as the escaped character.
+ bar = """
+ def bar():
+ pass
"""
- # the test_fn must contain something like \t
- # on Windows, this will create 'test_mod.py' in the current directory.
- # on Unix, this will create '.\test_mod.py' in the current directory.
- test_fn = '.\\test_mod.py'
- code = 'print("testing pdb")'
- with open(test_fn, 'w') as f:
- f.write(code)
- self.addCleanup(os.remove, test_fn)
- cmd = [sys.executable, '-m', 'pdb', test_fn,]
+ with open('bar.py', 'w') as f:
+ f.write(textwrap.dedent(bar))
+ self.addCleanup(support.unlink, 'bar.py')
+ stdout, stderr = self.run_pdb(script, commands)
+ self.assertTrue(
+ any('main.py(5)foo()->None' in l for l in stdout.splitlines()),
+ 'Fail to step into the caller after a return')
+
+ def test_issue13210(self):
+ # invoking "continue" on a non-main thread triggered an exception
+ # inside signal.signal
+
+ # raises SkipTest if python was built without threads
+ support.import_module('threading')
+
+ with open(support.TESTFN, 'wb') as f:
+ f.write(textwrap.dedent("""
+ import threading
+ import pdb
+
+ def start_pdb():
+ pdb.Pdb().set_trace()
+ x = 1
+ y = 1
+
+ t = threading.Thread(target=start_pdb)
+ t.start()""").encode('ascii'))
+ cmd = [sys.executable, '-u', support.TESTFN]
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
stderr=subprocess.STDOUT,
)
- stdout, stderr = proc.communicate('quit\n')
- self.assertIn(code, stdout, "pdb munged the filename")
+ self.addCleanup(proc.stdout.close)
+ stdout, stderr = proc.communicate(b'cont\n')
+ self.assertNotIn('Error', stdout.decode(),
+ "Got an error running test script under PDB")
+
+ def tearDown(self):
+ support.unlink(support.TESTFN)
def test_main():
from test import test_pdb
- test_support.run_doctest(test_pdb, verbosity=True)
- test_support.run_unittest(
- PdbTestCase,
- ModuleInitTester)
+ support.run_doctest(test_pdb, verbosity=True)
+ support.run_unittest(PdbTestCase)
+
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_peepholer.py b/Lib/test/test_peepholer.py
index 7e05f49737f..e268ae288d3 100644
--- a/Lib/test/test_peepholer.py
+++ b/Lib/test/test_peepholer.py
@@ -1,6 +1,7 @@
import dis
+import re
import sys
-from cStringIO import StringIO
+from io import StringIO
import unittest
def disassemble(func):
@@ -19,14 +20,15 @@ def dis_single(line):
class TestTranforms(unittest.TestCase):
def test_unot(self):
- # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE
+ # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE'
def unot(x):
if not x == 2:
del x
asm = disassemble(unot)
for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'):
self.assertNotIn(elem, asm)
- self.assertIn('POP_JUMP_IF_TRUE', asm)
+ for elem in ('POP_JUMP_IF_TRUE',):
+ self.assertIn(elem, asm)
def test_elim_inversion_of_is_or_in(self):
for line, elem in (
@@ -38,16 +40,24 @@ class TestTranforms(unittest.TestCase):
asm = dis_single(line)
self.assertIn(elem, asm)
- def test_none_as_constant(self):
- # LOAD_GLOBAL None --> LOAD_CONST None
+ def test_global_as_constant(self):
+ # LOAD_GLOBAL None/True/False --> LOAD_CONST None/True/False
def f(x):
None
+ None
return x
- asm = disassemble(f)
- for elem in ('LOAD_GLOBAL',):
- self.assertNotIn(elem, asm)
- for elem in ('LOAD_CONST', '(None)'):
- self.assertIn(elem, asm)
+ def g(x):
+ True
+ return x
+ def h(x):
+ False
+ return x
+ for func, name in ((f, 'None'), (g, 'True'), (h, 'False')):
+ asm = disassemble(func)
+ for elem in ('LOAD_GLOBAL',):
+ self.assertNotIn(elem, asm)
+ for elem in ('LOAD_CONST', '('+name+')'):
+ self.assertIn(elem, asm)
def f():
'Adding a docstring made this test fail in Py2.5.0'
return None
@@ -106,6 +116,54 @@ class TestTranforms(unittest.TestCase):
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
],)
+ def test_folding_of_lists_of_constants(self):
+ for line, elem in (
+ # in/not in constants with BUILD_LIST should be folded to a tuple:
+ ('a in [1,2,3]', '(1, 2, 3)'),
+ ('a not in ["a","b","c"]', "(('a', 'b', 'c'))"),
+ ('a in [None, 1, None]', '((None, 1, None))'),
+ ('a not in [(1, 2), 3, 4]', '(((1, 2), 3, 4))'),
+ ):
+ asm = dis_single(line)
+ self.assertIn(elem, asm)
+ self.assertNotIn('BUILD_LIST', asm)
+
+ def test_folding_of_sets_of_constants(self):
+ for line, elem in (
+ # in/not in constants with BUILD_SET should be folded to a frozenset:
+ ('a in {1,2,3}', frozenset({1, 2, 3})),
+ ('a not in {"a","b","c"}', frozenset({'a', 'c', 'b'})),
+ ('a in {None, 1, None}', frozenset({1, None})),
+ ('a not in {(1, 2), 3, 4}', frozenset({(1, 2), 3, 4})),
+ ('a in {1, 2, 3, 3, 2, 1}', frozenset({1, 2, 3})),
+ ):
+ asm = dis_single(line)
+ self.assertNotIn('BUILD_SET', asm)
+
+ # Verify that the frozenset 'elem' is in the disassembly
+ # The ordering of the elements in repr( frozenset ) isn't
+ # guaranteed, so we jump through some hoops to ensure that we have
+ # the frozenset we expect:
+ self.assertIn('frozenset', asm)
+ # Extract the frozenset literal from the disassembly:
+ m = re.match(r'.*(frozenset\({.*}\)).*', asm, re.DOTALL)
+ self.assertTrue(m)
+ self.assertEqual(eval(m.group(1)), elem)
+
+ # Ensure that the resulting code actually works:
+ def f(a):
+ return a in {1, 2, 3}
+
+ def g(a):
+ return a not in {1, 2, 3}
+
+ self.assertTrue(f(3))
+ self.assertTrue(not f(4))
+
+ self.assertTrue(not g(3))
+ self.assertTrue(g(4))
+
+
def test_folding_of_binops_on_constants(self):
for line, elem in (
('a = 2+3+4', '(9)'), # chained fold
@@ -139,28 +197,28 @@ class TestTranforms(unittest.TestCase):
def test_binary_subscr_on_unicode(self):
# unicode strings don't get optimized
- asm = dis_single('u"foo"[0]')
- self.assertNotIn("(u'f')", asm)
+ asm = dis_single('"foo"[0]')
+ self.assertNotIn("('f')", asm)
self.assertIn('BINARY_SUBSCR', asm)
- asm = dis_single('u"\u0061\uffff"[1]')
- self.assertNotIn("(u'\\uffff')", asm)
+ asm = dis_single('"\u0061\uffff"[1]')
+ self.assertNotIn("('\\uffff')", asm)
self.assertIn('BINARY_SUBSCR', asm)
# out of range
- asm = dis_single('u"fuu"[10]')
+ asm = dis_single('"fuu"[10]')
self.assertIn('BINARY_SUBSCR', asm)
# non-BMP char (see #5057)
- asm = dis_single('u"\U00012345"[0]')
+ asm = dis_single('"\U00012345"[0]')
self.assertIn('BINARY_SUBSCR', asm)
- asm = dis_single('u"\U00012345abcdef"[3]')
+ asm = dis_single('"\U00012345abcdef"[3]')
self.assertIn('BINARY_SUBSCR', asm)
def test_folding_of_unaryops_on_constants(self):
for line, elem in (
- ('`1`', "('1')"), # unary convert
('-0.5', '(-0.5)'), # unary negative
('~-2', '(1)'), # unary invert
+ ('+1', '(1)'), # unary positive
):
asm = dis_single(line)
self.assertIn(elem, asm, asm)
@@ -220,25 +278,42 @@ class TestTranforms(unittest.TestCase):
self.assertEqual(asm.split().count('JUMP_ABSOLUTE'), 1)
self.assertEqual(asm.split().count('RETURN_VALUE'), 2)
+ def test_make_function_doesnt_bail(self):
+ def f():
+ def g()->1+1:
+ pass
+ return g
+ asm = disassemble(f)
+ self.assertNotIn('BINARY_ADD', asm)
+
+class TestBuglets(unittest.TestCase):
+
+ def test_bug_11510(self):
+ # folded constant set optimization was commingled with the tuple
+ # unpacking optimization which would fail if the set had duplicate
+ # elements so that the set length was unexpected
+ def f():
+ x, y = {1, 1}
+ return x, y
+ with self.assertRaises(ValueError):
+ f()
+
def test_main(verbose=None):
import sys
- from test import test_support
- test_classes = (TestTranforms,)
-
- with test_support.check_py3k_warnings(
- ("backquote not supported", SyntaxWarning)):
- test_support.run_unittest(*test_classes)
-
- # verify reference counting
- if verbose and hasattr(sys, "gettotalrefcount"):
- import gc
- counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
- gc.collect()
- counts[i] = sys.gettotalrefcount()
- print counts
+ from test import support
+ test_classes = (TestTranforms, TestBuglets)
+ support.run_unittest(*test_classes)
+
+ # verify reference counting
+ if verbose and hasattr(sys, "gettotalrefcount"):
+ import gc
+ counts = [None] * 5
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
+ gc.collect()
+ counts[i] = sys.gettotalrefcount()
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_pep247.py b/Lib/test/test_pep247.py
index 423d33383f8..7f104728565 100644
--- a/Lib/test/test_pep247.py
+++ b/Lib/test/test_pep247.py
@@ -3,51 +3,41 @@ Test suite to check compilance with PEP 247, the standard API
for hashing algorithms
"""
-import warnings
-warnings.filterwarnings('ignore', 'the md5 module is deprecated.*',
- DeprecationWarning)
-warnings.filterwarnings('ignore', 'the sha module is deprecated.*',
- DeprecationWarning)
-
import hmac
-import md5
-import sha
-
import unittest
-from test import test_support
+from hashlib import md5, sha1, sha224, sha256, sha384, sha512
+from test import support
class Pep247Test(unittest.TestCase):
def check_module(self, module, key=None):
self.assertTrue(hasattr(module, 'digest_size'))
self.assertTrue(module.digest_size is None or module.digest_size > 0)
-
- if not key is None:
- obj1 = module.new(key)
- obj2 = module.new(key, 'string')
-
- h1 = module.new(key, 'string').digest()
- obj3 = module.new(key)
- obj3.update('string')
+ self.check_object(module.new, module.digest_size, key)
+
+ def check_object(self, cls, digest_size, key):
+ if key is not None:
+ obj1 = cls(key)
+ obj2 = cls(key, b'string')
+ h1 = cls(key, b'string').digest()
+ obj3 = cls(key)
+ obj3.update(b'string')
h2 = obj3.digest()
else:
- obj1 = module.new()
- obj2 = module.new('string')
-
- h1 = module.new('string').digest()
- obj3 = module.new()
- obj3.update('string')
+ obj1 = cls()
+ obj2 = cls(b'string')
+ h1 = cls(b'string').digest()
+ obj3 = cls()
+ obj3.update(b'string')
h2 = obj3.digest()
-
self.assertEqual(h1, h2)
-
self.assertTrue(hasattr(obj1, 'digest_size'))
- if not module.digest_size is None:
- self.assertEqual(obj1.digest_size, module.digest_size)
+ if digest_size is not None:
+ self.assertEqual(obj1.digest_size, digest_size)
self.assertEqual(obj1.digest_size, len(h1))
- obj1.update('string')
+ obj1.update(b'string')
obj_copy = obj1.copy()
self.assertEqual(obj1.digest(), obj_copy.digest())
self.assertEqual(obj1.hexdigest(), obj_copy.hexdigest())
@@ -55,20 +45,24 @@ class Pep247Test(unittest.TestCase):
digest, hexdigest = obj1.digest(), obj1.hexdigest()
hd2 = ""
for byte in digest:
- hd2 += '%02x' % ord(byte)
+ hd2 += '%02x' % byte
self.assertEqual(hd2, hexdigest)
def test_md5(self):
- self.check_module(md5)
+ self.check_object(md5, None, None)
def test_sha(self):
- self.check_module(sha)
+ self.check_object(sha1, None, None)
+ self.check_object(sha224, None, None)
+ self.check_object(sha256, None, None)
+ self.check_object(sha384, None, None)
+ self.check_object(sha512, None, None)
def test_hmac(self):
- self.check_module(hmac, key='abc')
+ self.check_module(hmac, key=b'abc')
def test_main():
- test_support.run_unittest(Pep247Test)
+ support.run_unittest(Pep247Test)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_pep263.py b/Lib/test/test_pep263.py
index 9286467adf3..598d980b2a6 100644
--- a/Lib/test/test_pep263.py
+++ b/Lib/test/test_pep263.py
@@ -1,27 +1,40 @@
# -*- coding: koi8-r -*-
import unittest
-from test import test_support
+from test import support
class PEP263Test(unittest.TestCase):
def test_pep263(self):
self.assertEqual(
- u"ðÉÔÏÎ".encode("utf-8"),
- '\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
+ "ðÉÔÏÎ".encode("utf-8"),
+ b'\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
)
self.assertEqual(
- u"\ð".encode("utf-8"),
- '\\\xd0\x9f'
+ "\ð".encode("utf-8"),
+ b'\\\xd0\x9f'
)
def test_compilestring(self):
# see #1882
- c = compile("\n# coding: utf-8\nu = u'\xc3\xb3'\n", "dummy", "exec")
+ c = compile(b"\n# coding: utf-8\nu = '\xc3\xb3'\n", "dummy", "exec")
d = {}
- exec c in d
- self.assertEqual(d['u'], u'\xf3')
-
+ exec(c, d)
+ self.assertEqual(d['u'], '\xf3')
+
+ def test_issue2301(self):
+ try:
+ compile(b"# coding: cp932\nprint '\x94\x4e'", "dummy", "exec")
+ except SyntaxError as v:
+ self.assertEqual(v.text, "print '\u5e74'\n")
+ else:
+ self.fail()
+
+ def test_issue4626(self):
+ c = compile("# coding=latin-1\n\u00c6 = '\u00c6'", "dummy", "exec")
+ d = {}
+ exec(c, d)
+ self.assertEqual(d['\xc6'], '\xc6')
def test_issue3297(self):
c = compile("a, b = '\U0001010F', '\\U0001010F'", "dummy", "exec")
@@ -29,6 +42,7 @@ class PEP263Test(unittest.TestCase):
exec(c, d)
self.assertEqual(d['a'], d['b'])
self.assertEqual(len(d['a']), len(d['b']))
+ self.assertEqual(ascii(d['a']), ascii(d['b']))
def test_issue7820(self):
# Ensure that check_bom() restores all bytes in the right order if
@@ -36,13 +50,13 @@ class PEP263Test(unittest.TestCase):
# byte of a valid BOM, but next bytes are different
# one byte in common with the UTF-16-LE BOM
- self.assertRaises(SyntaxError, eval, '\xff\x20')
+ self.assertRaises(SyntaxError, eval, b'\xff\x20')
# two bytes in common with the UTF-8 BOM
- self.assertRaises(SyntaxError, eval, '\xef\xbb\x20')
+ self.assertRaises(SyntaxError, eval, b'\xef\xbb\x20')
def test_main():
- test_support.run_unittest(PEP263Test)
+ support.run_unittest(PEP263Test)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_pep277.py b/Lib/test/test_pep277.py
index 92b82d0f7d2..6d891e541ee 100644
--- a/Lib/test/test_pep277.py
+++ b/Lib/test/test_pep277.py
@@ -2,20 +2,20 @@
# open, os.open, os.stat. os.listdir, os.rename, os.remove, os.mkdir, os.chdir, os.rmdir
import sys, os, unittest
from unicodedata import normalize
-from test import test_support
+from test import support
filenames = [
'1_abc',
- u'2_ascii',
- u'3_Gr\xfc\xdf-Gott',
- u'4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2',
- u'5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435',
- u'6_\u306b\u307d\u3093',
- u'7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1',
- u'8_\u66e8\u66e9\u66eb',
- u'9_\u66e8\u05e9\u3093\u0434\u0393\xdf',
+ '2_ascii',
+ '3_Gr\xfc\xdf-Gott',
+ '4_\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2',
+ '5_\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435',
+ '6_\u306b\u307d\u3093',
+ '7_\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1',
+ '8_\u66e8\u66e9\u66eb',
+ '9_\u66e8\u05e9\u3093\u0434\u0393\xdf',
# Specific code points: fn, NFC(fn) and NFKC(fn) all differents
- u'10_\u1fee\u1ffd',
+ '10_\u1fee\u1ffd',
]
# Mac OS X decomposes Unicode names, using Normal Form D.
@@ -27,24 +27,24 @@ filenames = [
if sys.platform != 'darwin':
filenames.extend([
# Specific code points: NFC(fn), NFD(fn), NFKC(fn) and NFKD(fn) all differents
- u'11_\u0385\u03d3\u03d4',
- u'12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD(u'\u0385\u03d3\u03d4')
- u'13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC(u'\u0385\u03d3\u03d4')
- u'14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed',
+ '11_\u0385\u03d3\u03d4',
+ '12_\u00a8\u0301\u03d2\u0301\u03d2\u0308', # == NFD('\u0385\u03d3\u03d4')
+ '13_\u0020\u0308\u0301\u038e\u03ab', # == NFKC('\u0385\u03d3\u03d4')
+ '14_\u1e9b\u1fc1\u1fcd\u1fce\u1fcf\u1fdd\u1fde\u1fdf\u1fed',
# Specific code points: fn, NFC(fn) and NFKC(fn) all differents
- u'15_\u1fee\u1ffd\ufad1',
- u'16_\u2000\u2000\u2000A',
- u'17_\u2001\u2001\u2001A',
- u'18_\u2003\u2003\u2003A', # == NFC(u'\u2001\u2001\u2001A')
- u'19_\u0020\u0020\u0020A', # u'\u0020' == u' ' == NFKC(u'\u2000') ==
- # NFKC(u'\u2001') == NFKC(u'\u2003')
+ '15_\u1fee\u1ffd\ufad1',
+ '16_\u2000\u2000\u2000A',
+ '17_\u2001\u2001\u2001A',
+ '18_\u2003\u2003\u2003A', # == NFC('\u2001\u2001\u2001A')
+ '19_\u0020\u0020\u0020A', # '\u0020' == ' ' == NFKC('\u2000') ==
+ # NFKC('\u2001') == NFKC('\u2003')
])
# Is it Unicode-friendly?
if not os.path.supports_unicode_filenames:
- fsencoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
+ fsencoding = sys.getfilesystemencoding()
try:
for name in filenames:
name.encode(fsencoding)
@@ -59,7 +59,7 @@ def deltree(dirname):
# an error if we can't remove it.
if os.path.exists(dirname):
# must pass unicode to os.listdir() so we get back unicode results.
- for fname in os.listdir(unicode(dirname)):
+ for fname in os.listdir(str(dirname)):
os.unlink(os.path.join(dirname, fname))
os.rmdir(dirname)
@@ -70,23 +70,23 @@ class UnicodeFileTests(unittest.TestCase):
def setUp(self):
try:
- os.mkdir(test_support.TESTFN)
+ os.mkdir(support.TESTFN)
except OSError:
pass
files = set()
for name in self.files:
- name = os.path.join(test_support.TESTFN, self.norm(name))
- with open(name, 'w') as f:
+ name = os.path.join(support.TESTFN, self.norm(name))
+ with open(name, 'wb') as f:
f.write((name+'\n').encode("utf-8"))
os.stat(name)
files.add(name)
self.files = files
def tearDown(self):
- deltree(test_support.TESTFN)
+ deltree(support.TESTFN)
def norm(self, s):
- if self.normal_form and isinstance(s, unicode):
+ if self.normal_form:
return normalize(self.normal_form, s)
return s
@@ -96,11 +96,11 @@ class UnicodeFileTests(unittest.TestCase):
fn(filename)
exc_filename = c.exception.filename
# the "filename" exception attribute may be encoded
- if isinstance(exc_filename, str):
+ if isinstance(exc_filename, bytes):
filename = filename.encode(sys.getfilesystemencoding())
if check_fn_in_exception:
- self.assertEqual(exc_filename, filename, "Function '%s(%r) failed "
- "with bad filename in the exception: %r" %
+ self.assertEqual(exc_filename, filename, "Function '%s(%a) failed "
+ "with bad filename in the exception: %a" %
(fn.__name__, filename, exc_filename))
def test_failures(self):
@@ -117,7 +117,7 @@ class UnicodeFileTests(unittest.TestCase):
def test_open(self):
for name in self.files:
- f = open(name, 'w')
+ f = open(name, 'wb')
f.write((name+'\n').encode("utf-8"))
f.close()
os.stat(name)
@@ -126,9 +126,9 @@ class UnicodeFileTests(unittest.TestCase):
# NFD (a variant of Unicode NFD form). Normalize the filename to NFC, NFKC,
# NFKD in Python is useless, because darwin will normalize it later and so
# open(), os.stat(), etc. don't raise any exception.
- @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X')
+ @unittest.skipIf(sys.platform == 'darwin', 'irrevelant test on Mac OS X')
def test_normalize(self):
- files = set(f for f in self.files if isinstance(f, unicode))
+ files = set(self.files)
others = set()
for nf in set(['NFC', 'NFD', 'NFKC', 'NFKD']):
others |= set(normalize(nf, file) for file in files)
@@ -145,14 +145,13 @@ class UnicodeFileTests(unittest.TestCase):
# Skip the test on darwin, because darwin uses a normalization different
# than Python NFD normalization: filenames are different even if we use
# Python NFD normalization.
- @unittest.skipIf(sys.platform == 'darwin', 'irrelevant test on Mac OS X')
+ @unittest.skipIf(sys.platform == 'darwin', 'irrevelant test on Mac OS X')
def test_listdir(self):
sf0 = set(self.files)
- f1 = os.listdir(test_support.TESTFN)
- f2 = os.listdir(unicode(test_support.TESTFN,
- sys.getfilesystemencoding()))
- sf2 = set(os.path.join(unicode(test_support.TESTFN), f) for f in f2)
- self.assertEqual(sf0, sf2)
+ f1 = os.listdir(support.TESTFN.encode(sys.getfilesystemencoding()))
+ f2 = os.listdir(support.TESTFN)
+ sf2 = set(os.path.join(support.TESTFN, f) for f in f2)
+ self.assertEqual(sf0, sf2, "%a != %a" % (sf0, sf2))
self.assertEqual(len(f1), len(f2))
def test_rename(self):
@@ -161,14 +160,13 @@ class UnicodeFileTests(unittest.TestCase):
os.rename("tmp", name)
def test_directory(self):
- dirname = os.path.join(test_support.TESTFN,
- u'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
- filename = u'\xdf-\u66e8\u66e9\u66eb'
+ dirname = os.path.join(support.TESTFN, 'Gr\xfc\xdf-\u66e8\u66e9\u66eb')
+ filename = '\xdf-\u66e8\u66e9\u66eb'
oldwd = os.getcwd()
os.mkdir(dirname)
os.chdir(dirname)
try:
- with open(filename, 'w') as f:
+ with open(filename, 'wb') as f:
f.write((filename + '\n').encode("utf-8"))
os.access(filename,os.R_OK)
os.remove(filename)
@@ -195,7 +193,7 @@ class UnicodeNFKDFileTests(UnicodeFileTests):
def test_main():
try:
- test_support.run_unittest(
+ support.run_unittest(
UnicodeFileTests,
UnicodeNFCFileTests,
UnicodeNFDFileTests,
@@ -203,7 +201,7 @@ def test_main():
UnicodeNFKDFileTests,
)
finally:
- deltree(test_support.TESTFN)
+ deltree(support.TESTFN)
if __name__ == "__main__":
diff --git a/Lib/test/test_pep292.py b/Lib/test/test_pep292.py
index cb8a244dc0e..119c7ea8a1f 100644
--- a/Lib/test/test_pep292.py
+++ b/Lib/test/test_pep292.py
@@ -42,6 +42,19 @@ class TestTemplate(unittest.TestCase):
s = Template('$who likes $$')
eq(s.substitute(dict(who='tim', what='ham')), 'tim likes $')
+ def test_invalid(self):
+ class MyPattern(Template):
+ pattern = r"""
+ (?:
+ (?P<invalid>) |
+ (?P<escaped>%(delim)s) |
+ @(?P<named>%(id)s) |
+ @{(?P<braced>%(id)s)}
+ )
+ """
+ s = MyPattern('$')
+ self.assertRaises(ValueError, s.substitute, dict())
+
def test_percents(self):
eq = self.assertEqual
s = Template('%(foo)s $foo ${foo}')
@@ -125,10 +138,44 @@ class TestTemplate(unittest.TestCase):
self.assertRaises(ValueError, s.substitute, {})
self.assertRaises(ValueError, s.safe_substitute, {})
+ def test_braced_override(self):
+ class MyTemplate(Template):
+ pattern = r"""
+ \$(?:
+ (?P<escaped>$) |
+ (?P<named>[_a-z][_a-z0-9]*) |
+ @@(?P<braced>[_a-z][_a-z0-9]*)@@ |
+ (?P<invalid>) |
+ )
+ """
+
+ tmpl = 'PyCon in $@@location@@'
+ t = MyTemplate(tmpl)
+ self.assertRaises(KeyError, t.substitute, {})
+ val = t.substitute({'location': 'Cleveland'})
+ self.assertEqual(val, 'PyCon in Cleveland')
+
+ def test_braced_override_safe(self):
+ class MyTemplate(Template):
+ pattern = r"""
+ \$(?:
+ (?P<escaped>$) |
+ (?P<named>[_a-z][_a-z0-9]*) |
+ @@(?P<braced>[_a-z][_a-z0-9]*)@@ |
+ (?P<invalid>) |
+ )
+ """
+
+ tmpl = 'PyCon in $@@location@@'
+ t = MyTemplate(tmpl)
+ self.assertEqual(t.safe_substitute(), tmpl)
+ val = t.safe_substitute({'location': 'Cleveland'})
+ self.assertEqual(val, 'PyCon in Cleveland')
+
def test_unicode_values(self):
s = Template('$who likes $what')
- d = dict(who=u't\xffm', what=u'f\xfe\fed')
- self.assertEqual(s.substitute(d), u't\xffm likes f\xfe\x0ced')
+ d = dict(who='t\xffm', what='f\xfe\fed')
+ self.assertEqual(s.substitute(d), 't\xffm likes f\xfe\x0ced')
def test_keyword_arguments(self):
eq = self.assertEqual
@@ -184,9 +231,9 @@ class TestTemplate(unittest.TestCase):
def test_main():
- from test import test_support
+ from test import support
test_classes = [TestTemplate,]
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
if __name__ == '__main__':
diff --git a/Lib/test/test_pep3120.py b/Lib/test/test_pep3120.py
new file mode 100644
index 00000000000..5b63998cf59
--- /dev/null
+++ b/Lib/test/test_pep3120.py
@@ -0,0 +1,47 @@
+# This file is marked as binary in the CVS, to prevent MacCVS from recoding it.
+
+import unittest
+from test import support
+
+class PEP3120Test(unittest.TestCase):
+
+ def test_pep3120(self):
+ self.assertEqual(
+ "Питон".encode("utf-8"),
+ b'\xd0\x9f\xd0\xb8\xd1\x82\xd0\xbe\xd0\xbd'
+ )
+ self.assertEqual(
+ "\П".encode("utf-8"),
+ b'\\\xd0\x9f'
+ )
+
+ def test_badsyntax(self):
+ try:
+ import test.badsyntax_pep3120
+ except SyntaxError as msg:
+ msg = str(msg).lower()
+ self.assertTrue('utf-8' in msg)
+ else:
+ self.fail("expected exception didn't occur")
+
+
+class BuiltinCompileTests(unittest.TestCase):
+
+ # Issue 3574.
+ def test_latin1(self):
+ # Allow compile() to read Latin-1 source.
+ source_code = '# coding: Latin-1\nu = "Ç"\n'.encode("Latin-1")
+ try:
+ code = compile(source_code, '<dummy>', 'exec')
+ except SyntaxError:
+ self.fail("compile() cannot handle Latin-1 source")
+ ns = {}
+ exec(code, ns)
+ self.assertEqual('Ç', ns['u'])
+
+
+def test_main():
+ support.run_unittest(PEP3120Test, BuiltinCompileTests)
+
+if __name__=="__main__":
+ test_main()
diff --git a/Lib/test/test_pep3131.py b/Lib/test/test_pep3131.py
new file mode 100644
index 00000000000..df0f64d86ac
--- /dev/null
+++ b/Lib/test/test_pep3131.py
@@ -0,0 +1,40 @@
+import unittest
+import sys
+from test import support
+
+class PEP3131Test(unittest.TestCase):
+
+ def test_valid(self):
+ class T:
+ ä = 1
+ µ = 2 # this is a compatibility character
+ 蟒 = 3
+ xó „€ = 4
+ self.assertEqual(getattr(T, "\xe4"), 1)
+ self.assertEqual(getattr(T, "\u03bc"), 2)
+ self.assertEqual(getattr(T, '\u87d2'), 3)
+ self.assertEqual(getattr(T, 'x\U000E0100'), 4)
+
+ def test_non_bmp_normalized(self):
+ ð”˜ð”«ð”¦ð” ð”¬ð”¡ð”¢ = 1
+ # On wide builds, this is normalized, but on narrow ones it is not. See
+ # #12746.
+ try:
+ self.assertIn("ð”˜ð”«ð”¦ð” ð”¬ð”¡ð”¢", dir())
+ except AssertionError:
+ raise unittest.case._ExpectedFailure(sys.exc_info())
+
+ def test_invalid(self):
+ try:
+ from test import badsyntax_3131
+ except SyntaxError as s:
+ self.assertEqual(str(s),
+ "invalid character in identifier (badsyntax_3131.py, line 2)")
+ else:
+ self.fail("expected exception didn't occur")
+
+def test_main():
+ support.run_unittest(PEP3131Test)
+
+if __name__=="__main__":
+ test_main()
diff --git a/Lib/test/test_pep352.py b/Lib/test/test_pep352.py
index 88b3136651e..558cdb56d26 100644
--- a/Lib/test/test_pep352.py
+++ b/Lib/test/test_pep352.py
@@ -1,29 +1,10 @@
import unittest
-import __builtin__
-import exceptions
+import builtins
import warnings
-from test.test_support import run_unittest, check_warnings
+from test.support import run_unittest
import os
-import sys
from platform import system as platform_system
-DEPRECATION_WARNINGS = ["BaseException.message has been deprecated"]
-
-if sys.py3kwarning:
- DEPRECATION_WARNINGS.extend(
- ["exceptions must derive from BaseException",
- "catching classes that don't inherit from BaseException is not allowed",
- "__get(item|slice)__ not supported for exception classes"])
-
-_deprecations = [(msg, DeprecationWarning) for msg in DEPRECATION_WARNINGS]
-
-# Silence Py3k and other deprecation warnings
-def ignore_deprecation_warnings(func):
- """Ignore the known DeprecationWarnings."""
- def wrapper(*args, **kw):
- with check_warnings(*_deprecations, quiet=True):
- return func(*args, **kw)
- return wrapper
class ExceptionClassTests(unittest.TestCase):
@@ -33,25 +14,32 @@ class ExceptionClassTests(unittest.TestCase):
def test_builtins_new_style(self):
self.assertTrue(issubclass(Exception, object))
- @ignore_deprecation_warnings
def verify_instance_interface(self, ins):
- for attr in ("args", "message", "__str__", "__repr__", "__getitem__"):
+ for attr in ("args", "__str__", "__repr__"):
self.assertTrue(hasattr(ins, attr),
- "%s missing %s attribute" %
- (ins.__class__.__name__, attr))
+ "%s missing %s attribute" %
+ (ins.__class__.__name__, attr))
def test_inheritance(self):
# Make sure the inheritance hierarchy matches the documentation
- exc_set = set(x for x in dir(exceptions) if not x.startswith('_'))
+ exc_set = set()
+ for object_ in builtins.__dict__.values():
+ try:
+ if issubclass(object_, BaseException):
+ exc_set.add(object_.__name__)
+ except TypeError:
+ pass
+
inheritance_tree = open(os.path.join(os.path.split(__file__)[0],
'exception_hierarchy.txt'))
try:
superclass_name = inheritance_tree.readline().rstrip()
try:
- last_exc = getattr(__builtin__, superclass_name)
+ last_exc = getattr(builtins, superclass_name)
except AttributeError:
self.fail("base class %s not a built-in" % superclass_name)
- self.assertIn(superclass_name, exc_set)
+ self.assertIn(superclass_name, exc_set,
+ '%s not found' % superclass_name)
exc_set.discard(superclass_name)
superclasses = [] # Loop will insert base exception
last_depth = 0
@@ -70,7 +58,7 @@ class ExceptionClassTests(unittest.TestCase):
left_bracket = exc_name.index('[')
exc_name = exc_name[:left_bracket-1] # cover space
try:
- exc = getattr(__builtin__, exc_name)
+ exc = getattr(builtins, exc_name)
except AttributeError:
self.fail("%s not a built-in exception" % exc_name)
if last_depth < depth:
@@ -93,55 +81,40 @@ class ExceptionClassTests(unittest.TestCase):
inheritance_tree.close()
self.assertEqual(len(exc_set), 0, "%s not accounted for" % exc_set)
- interface_tests = ("length", "args", "message", "str", "unicode", "repr",
- "indexing")
+ interface_tests = ("length", "args", "str", "repr")
def interface_test_driver(self, results):
for test_name, (given, expected) in zip(self.interface_tests, results):
self.assertEqual(given, expected, "%s: %s != %s" % (test_name,
given, expected))
- @ignore_deprecation_warnings
def test_interface_single_arg(self):
# Make sure interface works properly when given a single argument
arg = "spam"
exc = Exception(arg)
- results = ([len(exc.args), 1], [exc.args[0], arg], [exc.message, arg],
- [str(exc), str(arg)], [unicode(exc), unicode(arg)],
- [repr(exc), exc.__class__.__name__ + repr(exc.args)],
- [exc[0], arg])
+ results = ([len(exc.args), 1], [exc.args[0], arg],
+ [str(exc), str(arg)],
+ [repr(exc), exc.__class__.__name__ + repr(exc.args)])
self.interface_test_driver(results)
- @ignore_deprecation_warnings
def test_interface_multi_arg(self):
# Make sure interface correct when multiple arguments given
arg_count = 3
args = tuple(range(arg_count))
exc = Exception(*args)
results = ([len(exc.args), arg_count], [exc.args, args],
- [exc.message, ''], [str(exc), str(args)],
- [unicode(exc), unicode(args)],
- [repr(exc), exc.__class__.__name__ + repr(exc.args)],
- [exc[-1], args[-1]])
+ [str(exc), str(args)],
+ [repr(exc), exc.__class__.__name__ + repr(exc.args)])
self.interface_test_driver(results)
- @ignore_deprecation_warnings
def test_interface_no_arg(self):
# Make sure that with no args that interface is correct
exc = Exception()
results = ([len(exc.args), 0], [exc.args, tuple()],
- [exc.message, ''],
- [str(exc), ''], [unicode(exc), u''],
- [repr(exc), exc.__class__.__name__ + '()'], [True, True])
+ [str(exc), ''],
+ [repr(exc), exc.__class__.__name__ + '()'])
self.interface_test_driver(results)
-
- def test_message_deprecation(self):
- # As of Python 2.6, BaseException.message is deprecated.
- with check_warnings(("", DeprecationWarning)):
- BaseException().message
-
-
class UsageTests(unittest.TestCase):
"""Test usage of exceptions"""
@@ -158,43 +131,25 @@ class UsageTests(unittest.TestCase):
"""Catching 'object_' should raise a TypeError."""
try:
try:
- raise StandardError
+ raise Exception
except object_:
pass
except TypeError:
pass
- except StandardError:
+ except Exception:
self.fail("TypeError expected when catching %s" % type(object_))
try:
try:
- raise StandardError
+ raise Exception
except (object_,):
pass
except TypeError:
return
- except StandardError:
+ except Exception:
self.fail("TypeError expected when catching %s as specified in a "
"tuple" % type(object_))
- @ignore_deprecation_warnings
- def test_raise_classic(self):
- # Raising a classic class is okay (for now).
- class ClassicClass:
- pass
- try:
- raise ClassicClass
- except ClassicClass:
- pass
- except:
- self.fail("unable to raise classic class")
- try:
- raise ClassicClass()
- except ClassicClass:
- pass
- except:
- self.fail("unable to raise classic class instance")
-
def test_raise_new_style_non_exception(self):
# You cannot raise a new-style class that does not inherit from
# BaseException; the ability was not possible until BaseException's
@@ -209,31 +164,24 @@ class UsageTests(unittest.TestCase):
# Raising a string raises TypeError.
self.raise_fails("spam")
- def test_catch_string(self):
- # Catching a string should trigger a DeprecationWarning.
- with warnings.catch_warnings():
- warnings.resetwarnings()
- warnings.filterwarnings("error")
- str_exc = "spam"
- with self.assertRaises(DeprecationWarning):
- try:
- raise StandardError
- except str_exc:
- pass
+ def test_catch_non_BaseException(self):
+ # Tryinng to catch an object that does not inherit from BaseException
+ # is not allowed.
+ class NonBaseException(object):
+ pass
+ self.catch_fails(NonBaseException)
+ self.catch_fails(NonBaseException())
- # Make sure that even if the string exception is listed in a tuple
- # that a warning is raised.
- with self.assertRaises(DeprecationWarning):
- try:
- raise StandardError
- except (AssertionError, str_exc):
- pass
+ def test_catch_BaseException_instance(self):
+ # Catching an instance of a BaseException subclass won't work.
+ self.catch_fails(BaseException())
+ def test_catch_string(self):
+ # Catching a string is bad.
+ self.catch_fails("spam")
def test_main():
run_unittest(ExceptionClassTests, UsageTests)
-
-
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_pickle.py b/Lib/test/test_pickle.py
index 6c83811be82..9da2cae86b8 100644
--- a/Lib/test/test_pickle.py
+++ b/Lib/test/test_pickle.py
@@ -1,80 +1,117 @@
import pickle
-from cStringIO import StringIO
+import io
-from test import test_support
+from test import support
from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests
from test.pickletester import AbstractPersistentPicklerTests
from test.pickletester import AbstractPicklerUnpicklerObjectTests
+from test.pickletester import BigmemPickleTests
-class PickleTests(AbstractPickleTests, AbstractPickleModuleTests):
+try:
+ import _pickle
+ has_c_implementation = True
+except ImportError:
+ has_c_implementation = False
- def dumps(self, arg, proto=0, fast=0):
- # Ignore fast
- return pickle.dumps(arg, proto)
- def loads(self, buf):
- # Ignore fast
- return pickle.loads(buf)
+class PickleTests(AbstractPickleModuleTests):
+ pass
- module = pickle
- error = KeyError
-class PicklerTests(AbstractPickleTests):
+class PyPicklerTests(AbstractPickleTests):
- error = KeyError
+ pickler = pickle._Pickler
+ unpickler = pickle._Unpickler
- def dumps(self, arg, proto=0, fast=0):
- f = StringIO()
- p = pickle.Pickler(f, proto)
- if fast:
- p.fast = fast
+ def dumps(self, arg, proto=None):
+ f = io.BytesIO()
+ p = self.pickler(f, proto)
p.dump(arg)
f.seek(0)
- return f.read()
+ return bytes(f.read())
- def loads(self, buf):
- f = StringIO(buf)
- u = pickle.Unpickler(f)
+ def loads(self, buf, **kwds):
+ f = io.BytesIO(buf)
+ u = self.unpickler(f, **kwds)
return u.load()
-class PersPicklerTests(AbstractPersistentPicklerTests):
- def dumps(self, arg, proto=0, fast=0):
- class PersPickler(pickle.Pickler):
+class InMemoryPickleTests(AbstractPickleTests, BigmemPickleTests):
+
+ pickler = pickle._Pickler
+ unpickler = pickle._Unpickler
+
+ def dumps(self, arg, protocol=None):
+ return pickle.dumps(arg, protocol)
+
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
+
+
+class PyPersPicklerTests(AbstractPersistentPicklerTests):
+
+ pickler = pickle._Pickler
+ unpickler = pickle._Unpickler
+
+ def dumps(self, arg, proto=None):
+ class PersPickler(self.pickler):
def persistent_id(subself, obj):
return self.persistent_id(obj)
- f = StringIO()
+ f = io.BytesIO()
p = PersPickler(f, proto)
- if fast:
- p.fast = fast
p.dump(arg)
f.seek(0)
return f.read()
- def loads(self, buf):
- class PersUnpickler(pickle.Unpickler):
+ def loads(self, buf, **kwds):
+ class PersUnpickler(self.unpickler):
def persistent_load(subself, obj):
return self.persistent_load(obj)
- f = StringIO(buf)
- u = PersUnpickler(f)
+ f = io.BytesIO(buf)
+ u = PersUnpickler(f, **kwds)
return u.load()
-class PicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
- pickler_class = pickle.Pickler
- unpickler_class = pickle.Unpickler
+class PyPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
+
+ pickler_class = pickle._Pickler
+ unpickler_class = pickle._Unpickler
+
+
+if has_c_implementation:
+ class CPicklerTests(PyPicklerTests):
+ pickler = _pickle.Pickler
+ unpickler = _pickle.Unpickler
+
+ class CPersPicklerTests(PyPersPicklerTests):
+ pickler = _pickle.Pickler
+ unpickler = _pickle.Unpickler
+
+ class CDumpPickle_LoadPickle(PyPicklerTests):
+ pickler = _pickle.Pickler
+ unpickler = pickle._Unpickler
+
+ class DumpPickle_CLoadPickle(PyPicklerTests):
+ pickler = pickle._Pickler
+ unpickler = _pickle.Unpickler
+
+ class CPicklerUnpicklerObjectTests(AbstractPicklerUnpicklerObjectTests):
+ pickler_class = _pickle.Pickler
+ unpickler_class = _pickle.Unpickler
def test_main():
- test_support.run_unittest(
- PickleTests,
- PicklerTests,
- PersPicklerTests,
- PicklerUnpicklerObjectTests,
- )
- test_support.run_doctest(pickle)
+ tests = [PickleTests, PyPicklerTests, PyPersPicklerTests]
+ if has_c_implementation:
+ tests.extend([CPicklerTests, CPersPicklerTests,
+ CDumpPickle_LoadPickle, DumpPickle_CLoadPickle,
+ PyPicklerUnpicklerObjectTests,
+ CPicklerUnpicklerObjectTests,
+ InMemoryPickleTests])
+ support.run_unittest(*tests)
+ support.run_doctest(pickle)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pickletools.py b/Lib/test/test_pickletools.py
index 3e5b35ab588..d37ac263c4c 100644
--- a/Lib/test/test_pickletools.py
+++ b/Lib/test/test_pickletools.py
@@ -1,23 +1,24 @@
import pickle
import pickletools
-from test import test_support
+from test import support
from test.pickletester import AbstractPickleTests
from test.pickletester import AbstractPickleModuleTests
class OptimizedPickleTests(AbstractPickleTests, AbstractPickleModuleTests):
- def dumps(self, arg, proto=0, fast=0):
+ def dumps(self, arg, proto=None):
return pickletools.optimize(pickle.dumps(arg, proto))
- def loads(self, buf):
- return pickle.loads(buf)
+ def loads(self, buf, **kwds):
+ return pickle.loads(buf, **kwds)
+
+ # Test relies on precise output of dumps()
+ test_pickle_to_2x = None
- module = pickle
- error = KeyError
def test_main():
- test_support.run_unittest(OptimizedPickleTests)
- test_support.run_doctest(pickletools)
+ support.run_unittest(OptimizedPickleTests)
+ support.run_doctest(pickletools)
if __name__ == "__main__":
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index c8b8be106c2..d5b886f87ef 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -2,7 +2,7 @@ import pipes
import os
import string
import unittest
-from test.test_support import TESTFN, run_unittest, unlink, reap_children
+from test.support import TESTFN, run_unittest, unlink, reap_children
if os.name != 'posix':
raise unittest.SkipTest('pipes module only works on posix')
@@ -40,8 +40,11 @@ class SimplePipeTests(unittest.TestCase):
f.write('hello world #2')
t = pipes.Template()
t.append(s_command + ' < $IN', pipes.FILEIN_STDOUT)
- with t.open(TESTFN, 'r') as f:
+ f = t.open(TESTFN, 'r')
+ try:
self.assertEqual(f.read(), 'HELLO WORLD #2')
+ finally:
+ f.close()
def testEmptyPipeline1(self):
# copy through empty pipe
@@ -61,8 +64,11 @@ class SimplePipeTests(unittest.TestCase):
with open(TESTFN, 'w') as f:
f.write(d)
t=pipes.Template()
- with t.open(TESTFN, 'r') as f:
+ f = t.open(TESTFN, 'r')
+ try:
self.assertEqual(f.read(), d)
+ finally:
+ f.close()
def testEmptyPipeline3(self):
# write through empty pipe
@@ -75,7 +81,8 @@ class SimplePipeTests(unittest.TestCase):
def testQuoting(self):
safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./'
- unsafe = '"`$\\!'
+ unicode_sample = '\xe9\xe0\xdf' # e + acute accent, a + grave, sharp s
+ unsafe = '"`$\\!' + unicode_sample
self.assertEqual(pipes.quote(''), "''")
self.assertEqual(pipes.quote(safeunquoted), safeunquoted)
diff --git a/Lib/test/test_pkg.py b/Lib/test/test_pkg.py
index 5f1659b0f6d..a4ddb15875c 100644
--- a/Lib/test/test_pkg.py
+++ b/Lib/test/test_pkg.py
@@ -5,7 +5,7 @@ import os
import tempfile
import textwrap
import unittest
-from test import test_support
+from test import support
# Helpers to create and destroy hierarchies.
@@ -42,15 +42,17 @@ def fixdir(lst):
# from package import * (defined in __init__)
-class Test(unittest.TestCase):
+class TestPkg(unittest.TestCase):
def setUp(self):
self.root = None
self.pkgname = None
self.syspath = list(sys.path)
+ self.modules_before = support.modules_setup()
def tearDown(self):
sys.path[:] = self.syspath
+ support.modules_cleanup(*self.modules_before)
if self.root: # Only clean if the test was actually run
cleanout(self.root)
@@ -87,18 +89,18 @@ class Test(unittest.TestCase):
self.pkgname = descr[0][0]
def test_1(self):
- hier = [("t1", None), ("t1 __init__"+os.extsep+"py", "")]
+ hier = [("t1", None), ("t1 __init__.py", "")]
self.mkhier(hier)
import t1
def test_2(self):
hier = [
("t2", None),
- ("t2 __init__"+os.extsep+"py", "'doc for t2'"),
+ ("t2 __init__.py", "'doc for t2'"),
("t2 sub", None),
- ("t2 sub __init__"+os.extsep+"py", ""),
+ ("t2 sub __init__.py", ""),
("t2 sub subsub", None),
- ("t2 sub subsub __init__"+os.extsep+"py", "spam = 1"),
+ ("t2 sub subsub __init__.py", "spam = 1"),
]
self.mkhier(hier)
@@ -141,11 +143,11 @@ class Test(unittest.TestCase):
def test_3(self):
hier = [
("t3", None),
- ("t3 __init__"+os.extsep+"py", ""),
+ ("t3 __init__.py", ""),
("t3 sub", None),
- ("t3 sub __init__"+os.extsep+"py", ""),
+ ("t3 sub __init__.py", ""),
("t3 sub subsub", None),
- ("t3 sub subsub __init__"+os.extsep+"py", "spam = 1"),
+ ("t3 sub subsub __init__.py", "spam = 1"),
]
self.mkhier(hier)
@@ -158,14 +160,14 @@ class Test(unittest.TestCase):
hier = [
("t4.py", "raise RuntimeError('Shouldnt load t4.py')"),
("t4", None),
- ("t4 __init__"+os.extsep+"py", ""),
+ ("t4 __init__.py", ""),
("t4 sub.py", "raise RuntimeError('Shouldnt load sub.py')"),
("t4 sub", None),
- ("t4 sub __init__"+os.extsep+"py", ""),
- ("t4 sub subsub"+os.extsep+"py",
+ ("t4 sub __init__.py", ""),
+ ("t4 sub subsub.py",
"raise RuntimeError('Shouldnt load subsub.py')"),
("t4 sub subsub", None),
- ("t4 sub subsub __init__"+os.extsep+"py", "spam = 1"),
+ ("t4 sub subsub __init__.py", "spam = 1"),
]
self.mkhier(hier)
@@ -178,9 +180,9 @@ class Test(unittest.TestCase):
def test_5(self):
hier = [
("t5", None),
- ("t5 __init__"+os.extsep+"py", "import t5.foo"),
- ("t5 string"+os.extsep+"py", "spam = 1"),
- ("t5 foo"+os.extsep+"py",
+ ("t5 __init__.py", "import t5.foo"),
+ ("t5 string.py", "spam = 1"),
+ ("t5 foo.py",
"from . import string; assert string.spam == 1"),
]
self.mkhier(hier)
@@ -194,35 +196,35 @@ class Test(unittest.TestCase):
import t5
self.assertEqual(fixdir(dir(t5)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__', 'foo', 'string', 't5'])
self.assertEqual(fixdir(dir(t5.foo)),
- ['__doc__', '__file__', '__name__', '__package__',
- 'string'])
+ ['__cached__', '__doc__', '__file__', '__name__',
+ '__package__', 'string'])
self.assertEqual(fixdir(dir(t5.string)),
- ['__doc__', '__file__', '__name__','__package__',
- 'spam'])
+ ['__cached__', '__doc__', '__file__', '__name__',
+ '__package__', 'spam'])
def test_6(self):
hier = [
("t6", None),
- ("t6 __init__"+os.extsep+"py",
+ ("t6 __init__.py",
"__all__ = ['spam', 'ham', 'eggs']"),
- ("t6 spam"+os.extsep+"py", ""),
- ("t6 ham"+os.extsep+"py", ""),
- ("t6 eggs"+os.extsep+"py", ""),
+ ("t6 spam.py", ""),
+ ("t6 ham.py", ""),
+ ("t6 eggs.py", ""),
]
self.mkhier(hier)
import t6
self.assertEqual(fixdir(dir(t6)),
- ['__all__', '__doc__', '__file__',
+ ['__all__', '__cached__', '__doc__', '__file__',
'__name__', '__package__', '__path__'])
s = """
import t6
from t6 import *
self.assertEqual(fixdir(dir(t6)),
- ['__all__', '__doc__', '__file__',
+ ['__all__', '__cached__', '__doc__', '__file__',
'__name__', '__package__', '__path__',
'eggs', 'ham', 'spam'])
self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6'])
@@ -231,17 +233,17 @@ class Test(unittest.TestCase):
def test_7(self):
hier = [
+ ("t7.py", ""),
("t7", None),
- ("t7"+os.extsep+"py", ""),
- ("t7 __init__"+os.extsep+"py", ""),
- ("t7 sub"+os.extsep+"py",
+ ("t7 __init__.py", ""),
+ ("t7 sub.py",
"raise RuntimeError('Shouldnt load sub.py')"),
("t7 sub", None),
- ("t7 sub __init__"+os.extsep+"py", ""),
- ("t7 sub "+os.extsep+"py",
+ ("t7 sub __init__.py", ""),
+ ("t7 sub .py",
"raise RuntimeError('Shouldnt load subsub.py')"),
("t7 sub subsub", None),
- ("t7 sub subsub __init__"+os.extsep+"py",
+ ("t7 sub subsub __init__.py",
"spam = 1"),
]
self.mkhier(hier)
@@ -250,18 +252,18 @@ class Test(unittest.TestCase):
t7, sub, subsub = None, None, None
import t7 as tas
self.assertEqual(fixdir(dir(tas)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__'])
self.assertFalse(t7)
from t7 import sub as subpar
self.assertEqual(fixdir(dir(subpar)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__'])
self.assertFalse(t7)
self.assertFalse(sub)
from t7.sub import subsub as subsubsub
self.assertEqual(fixdir(dir(subsubsub)),
- ['__doc__', '__file__', '__name__',
+ ['__cached__', '__doc__', '__file__', '__name__',
'__package__', '__path__', 'spam'])
self.assertFalse(t7)
self.assertFalse(sub)
@@ -285,7 +287,7 @@ class Test(unittest.TestCase):
self.assertEqual(t8.__doc__, "doc for t8")
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
diff --git a/Lib/test/test_pkgimport.py b/Lib/test/test_pkgimport.py
index 30d48cdcbb9..c37e9362b00 100644
--- a/Lib/test/test_pkgimport.py
+++ b/Lib/test/test_pkgimport.py
@@ -1,13 +1,20 @@
-import os, sys, string, random, tempfile, unittest
+import os
+import sys
+import shutil
+import string
+import random
+import tempfile
+import unittest
-from test.test_support import run_unittest
+from imp import cache_from_source
+from test.support import run_unittest
class TestImport(unittest.TestCase):
def __init__(self, *args, **kw):
self.package_name = 'PACKAGE_'
while self.package_name in sys.modules:
- self.package_name += random.choose(string.letters)
+ self.package_name += random.choose(string.ascii_letters)
self.module_name = self.package_name + '.foo'
unittest.TestCase.__init__(self, *args, **kw)
@@ -22,27 +29,21 @@ class TestImport(unittest.TestCase):
self.package_dir = os.path.join(self.test_dir,
self.package_name)
os.mkdir(self.package_dir)
- open(os.path.join(
- self.package_dir, '__init__'+os.extsep+'py'), 'w').close()
- self.module_path = os.path.join(self.package_dir, 'foo'+os.extsep+'py')
+ open(os.path.join(self.package_dir, '__init__.py'), 'w').close()
+ self.module_path = os.path.join(self.package_dir, 'foo.py')
def tearDown(self):
- for file in os.listdir(self.package_dir):
- os.remove(os.path.join(self.package_dir, file))
- os.rmdir(self.package_dir)
- os.rmdir(self.test_dir)
+ shutil.rmtree(self.test_dir)
self.assertNotEqual(sys.path.count(self.test_dir), 0)
sys.path.remove(self.test_dir)
self.remove_modules()
def rewrite_file(self, contents):
- for extension in "co":
- compiled_path = self.module_path + extension
- if os.path.exists(compiled_path):
- os.remove(compiled_path)
- f = open(self.module_path, 'w')
- f.write(contents)
- f.close()
+ compiled_path = cache_from_source(self.module_path)
+ if os.path.exists(compiled_path):
+ os.remove(compiled_path)
+ with open(self.module_path, 'w') as f:
+ f.write(contents)
def test_package_import__semantics(self):
@@ -52,21 +53,21 @@ class TestImport(unittest.TestCase):
self.rewrite_file('for')
try: __import__(self.module_name)
except SyntaxError: pass
- else: raise RuntimeError, 'Failed to induce SyntaxError'
+ else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?
self.assertNotIn(self.module_name, sys.modules)
self.assertFalse(hasattr(sys.modules[self.package_name], 'foo'))
# ...make up a variable name that isn't bound in __builtins__
var = 'a'
while var in dir(__builtins__):
- var += random.choose(string.letters)
+ var += random.choose(string.ascii_letters)
# ...make a module that just contains that
self.rewrite_file(var)
try: __import__(self.module_name)
except NameError: pass
- else: raise RuntimeError, 'Failed to induce NameError.'
+ else: raise RuntimeError('Failed to induce NameError.')
# ...now change the module so that the NameError doesn't
# happen
diff --git a/Lib/test/test_pkgutil.py b/Lib/test/test_pkgutil.py
index f665e960d40..3b72f060f99 100644
--- a/Lib/test/test_pkgutil.py
+++ b/Lib/test/test_pkgutil.py
@@ -1,4 +1,4 @@
-from test.test_support import run_unittest
+from test.support import run_unittest, unload
import unittest
import sys
import imp
@@ -25,7 +25,7 @@ class PkgutilTests(unittest.TestCase):
pkg = 'test_getdata_filesys'
# Include a LF and a CRLF, to test that binary data is read back
- RESOURCE_DATA = 'Hello, world!\nSecond line\r\nThird line'
+ RESOURCE_DATA = b'Hello, world!\nSecond line\r\nThird line'
# Make a package with some resources
package_dir = os.path.join(self.dirname, pkg)
@@ -55,7 +55,7 @@ class PkgutilTests(unittest.TestCase):
pkg = 'test_getdata_zipfile'
# Include a LF and a CRLF, to test that binary data is read back
- RESOURCE_DATA = 'Hello, world!\nSecond line\r\nThird line'
+ RESOURCE_DATA = b'Hello, world!\nSecond line\r\nThird line'
# Make a package with some resources
zip_file = os.path.join(self.dirname, zip)
@@ -74,6 +74,12 @@ class PkgutilTests(unittest.TestCase):
self.assertEqual(res1, RESOURCE_DATA)
res2 = pkgutil.get_data(pkg, 'sub/res.txt')
self.assertEqual(res2, RESOURCE_DATA)
+
+ names = []
+ for loader, name, ispkg in pkgutil.iter_modules([zip_file]):
+ names.append(name)
+ self.assertEqual(names, ['test_getdata_zipfile'])
+
del sys.path[0]
del sys.modules[pkg]
@@ -131,8 +137,99 @@ class PkgutilPEP302Tests(unittest.TestCase):
self.assertEqual(foo.loads, 1)
del sys.modules['foo']
+
+class ExtendPathTests(unittest.TestCase):
+ def create_init(self, pkgname):
+ dirname = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, dirname)
+ sys.path.insert(0, dirname)
+
+ pkgdir = os.path.join(dirname, pkgname)
+ os.mkdir(pkgdir)
+ with open(os.path.join(pkgdir, '__init__.py'), 'w') as fl:
+ fl.write('from pkgutil import extend_path\n__path__ = extend_path(__path__, __name__)\n')
+
+ return dirname
+
+ def create_submodule(self, dirname, pkgname, submodule_name, value):
+ module_name = os.path.join(dirname, pkgname, submodule_name + '.py')
+ with open(module_name, 'w') as fl:
+ print('value={}'.format(value), file=fl)
+
+ def setUp(self):
+ # Create 2 directories on sys.path
+ self.pkgname = 'foo'
+ self.dirname_0 = self.create_init(self.pkgname)
+ self.dirname_1 = self.create_init(self.pkgname)
+
+ def tearDown(self):
+ del sys.path[0]
+ del sys.path[0]
+ del sys.modules['foo']
+ del sys.modules['foo.bar']
+ del sys.modules['foo.baz']
+
+ def test_simple(self):
+ self.create_submodule(self.dirname_0, self.pkgname, 'bar', 0)
+ self.create_submodule(self.dirname_1, self.pkgname, 'baz', 1)
+ import foo.bar
+ import foo.baz
+ # Ensure we read the expected values
+ self.assertEqual(foo.bar.value, 0)
+ self.assertEqual(foo.baz.value, 1)
+
+ # Ensure the path is set up correctly
+ self.assertEqual(sorted(foo.__path__),
+ sorted([os.path.join(self.dirname_0, self.pkgname),
+ os.path.join(self.dirname_1, self.pkgname)]))
+
+ # XXX: test .pkg files
+
+
+class NestedNamespacePackageTest(unittest.TestCase):
+
+ def setUp(self):
+ self.basedir = tempfile.mkdtemp()
+ self.old_path = sys.path[:]
+
+ def tearDown(self):
+ sys.path[:] = self.old_path
+ shutil.rmtree(self.basedir)
+
+ def create_module(self, name, contents):
+ base, final = name.rsplit('.', 1)
+ base_path = os.path.join(self.basedir, base.replace('.', os.path.sep))
+ os.makedirs(base_path, exist_ok=True)
+ with open(os.path.join(base_path, final + ".py"), 'w') as f:
+ f.write(contents)
+
+ def test_nested(self):
+ pkgutil_boilerplate = (
+ 'import pkgutil; '
+ '__path__ = pkgutil.extend_path(__path__, __name__)')
+ self.create_module('a.pkg.__init__', pkgutil_boilerplate)
+ self.create_module('b.pkg.__init__', pkgutil_boilerplate)
+ self.create_module('a.pkg.subpkg.__init__', pkgutil_boilerplate)
+ self.create_module('b.pkg.subpkg.__init__', pkgutil_boilerplate)
+ self.create_module('a.pkg.subpkg.c', 'c = 1')
+ self.create_module('b.pkg.subpkg.d', 'd = 2')
+ sys.path.insert(0, os.path.join(self.basedir, 'a'))
+ sys.path.insert(0, os.path.join(self.basedir, 'b'))
+ import pkg
+ self.addCleanup(unload, 'pkg')
+ self.assertEqual(len(pkg.__path__), 2)
+ import pkg.subpkg
+ self.addCleanup(unload, 'pkg.subpkg')
+ self.assertEqual(len(pkg.subpkg.__path__), 2)
+ from pkg.subpkg.c import c
+ from pkg.subpkg.d import d
+ self.assertEqual(c, 1)
+ self.assertEqual(d, 2)
+
+
def test_main():
- run_unittest(PkgutilTests, PkgutilPEP302Tests)
+ run_unittest(PkgutilTests, PkgutilPEP302Tests, ExtendPathTests,
+ NestedNamespacePackageTest)
# this is necessary if test is run repeated (like when finding leaks)
import zipimport
zipimport._zip_directory_cache.clear()
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
index 941d428c19e..8751aa86ba8 100644
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -4,26 +4,32 @@ import unittest
import platform
import subprocess
-from test import test_support
+from test import support
class PlatformTest(unittest.TestCase):
def test_architecture(self):
res = platform.architecture()
- if hasattr(os, "symlink"):
- def test_architecture_via_symlink(self): # issue3762
- def get(python):
- cmd = [python, '-c',
- 'import platform; print platform.architecture()']
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
- return p.communicate()
- real = os.path.realpath(sys.executable)
- link = os.path.abspath(test_support.TESTFN)
- os.symlink(real, link)
- try:
- self.assertEqual(get(real), get(link))
- finally:
- os.remove(link)
+ @support.skip_unless_symlink
+ def test_architecture_via_symlink(self): # issue3762
+ # On Windows, the EXE needs to know where pythonXY.dll is at so we have
+ # to add the directory to the path.
+ if sys.platform == "win32":
+ os.environ["Path"] = "{};{}".format(
+ os.path.dirname(sys.executable), os.environ["Path"])
+
+ def get(python):
+ cmd = [python, '-c',
+ 'import platform; print(platform.architecture())']
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ return p.communicate()
+ real = os.path.realpath(sys.executable)
+ link = os.path.abspath(support.TESTFN)
+ os.symlink(real, link)
+ try:
+ self.assertEqual(get(real), get(link))
+ finally:
+ os.remove(link)
def test_platform(self):
for aliased in (False, True):
@@ -51,11 +57,13 @@ class PlatformTest(unittest.TestCase):
def setUp(self):
self.save_version = sys.version
self.save_subversion = sys.subversion
+ self.save_mercurial = sys._mercurial
self.save_platform = sys.platform
def tearDown(self):
sys.version = self.save_version
sys.subversion = self.save_subversion
+ sys._mercurial = self.save_mercurial
sys.platform = self.save_platform
def test_sys_version(self):
@@ -100,13 +108,15 @@ class PlatformTest(unittest.TestCase):
"")
}
for (version_tag, subversion, sys_platform), info in \
- sys_versions.iteritems():
+ sys_versions.items():
sys.version = version_tag
if subversion is None:
+ if hasattr(sys, "_mercurial"):
+ del sys._mercurial
if hasattr(sys, "subversion"):
del sys.subversion
else:
- sys.subversion = subversion
+ sys._mercurial = subversion
if sys_platform is not None:
sys.platform = sys_platform
self.assertEqual(platform.python_implementation(), info[0])
@@ -134,7 +144,7 @@ class PlatformTest(unittest.TestCase):
# using it, per
# http://blogs.msdn.com/david.wang/archive/2006/03/26/HOWTO-Detect-Process-Bitness.aspx
try:
- with test_support.EnvironmentVarGuard() as environ:
+ with support.EnvironmentVarGuard() as environ:
if 'PROCESSOR_ARCHITEW6432' in environ:
del environ['PROCESSOR_ARCHITEW6432']
environ['PROCESSOR_ARCHITECTURE'] = 'foo'
@@ -159,14 +169,7 @@ class PlatformTest(unittest.TestCase):
def test_mac_ver(self):
res = platform.mac_ver()
- try:
- import gestalt
- except ImportError:
- have_toolbox_glue = False
- else:
- have_toolbox_glue = True
-
- if have_toolbox_glue and platform.uname()[0] == 'Darwin':
+ if platform.uname()[0] == 'Darwin':
# We're on a MacOSX system, check that
# the right version information is returned
fd = os.popen('sw_vers', 'r')
@@ -246,7 +249,7 @@ class PlatformTest(unittest.TestCase):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
PlatformTest
)
diff --git a/Lib/test/test_plistlib.py b/Lib/test/test_plistlib.py
index e6e0f868d3b..5f980d0a2d6 100644
--- a/Lib/test/test_plistlib.py
+++ b/Lib/test/test_plistlib.py
@@ -4,11 +4,11 @@ import unittest
import plistlib
import os
import datetime
-from test import test_support
+from test import support
# This test data was generated through Cocoa's NSDictionary class
-TESTDATA = """<?xml version="1.0" encoding="UTF-8"?>
+TESTDATA = b"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@@ -84,14 +84,14 @@ TESTDATA = """<?xml version="1.0" encoding="UTF-8"?>
<string>That was a unicode key.</string>
</dict>
</plist>
-""".replace(" " * 8, "\t") # Apple as well as plistlib.py output hard tabs
+""".replace(b" " * 8, b"\t") # Apple as well as plistlib.py output hard tabs
class TestPlistlib(unittest.TestCase):
def tearDown(self):
try:
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
except:
pass
@@ -103,17 +103,17 @@ class TestPlistlib(unittest.TestCase):
anInt = 728,
aDict=dict(
anotherString="<hello & 'hi' there!>",
- aUnicodeValue=u'M\xe4ssig, Ma\xdf',
+ aUnicodeValue='M\xe4ssig, Ma\xdf',
aTrueValue=True,
aFalseValue=False,
deeperDict=dict(a=17, b=32.5, c=[1, 2, "text"]),
),
- someData = plistlib.Data("<binary gunk>"),
- someMoreData = plistlib.Data("<lots of binary gunk>\0\1\2\3" * 10),
- nestedData = [plistlib.Data("<lots of binary gunk>\0\1\2\3" * 10)],
+ someData = plistlib.Data(b"<binary gunk>"),
+ someMoreData = plistlib.Data(b"<lots of binary gunk>\0\1\2\3" * 10),
+ nestedData = [plistlib.Data(b"<lots of binary gunk>\0\1\2\3" * 10)],
aDate = datetime.datetime(2004, 10, 26, 10, 33, 33),
)
- pl[u'\xc5benraa'] = "That was a unicode key."
+ pl['\xc5benraa'] = "That was a unicode key."
return pl
def test_create(self):
@@ -123,44 +123,36 @@ class TestPlistlib(unittest.TestCase):
def test_io(self):
pl = self._create()
- plistlib.writePlist(pl, test_support.TESTFN)
- pl2 = plistlib.readPlist(test_support.TESTFN)
+ plistlib.writePlist(pl, support.TESTFN)
+ pl2 = plistlib.readPlist(support.TESTFN)
self.assertEqual(dict(pl), dict(pl2))
- def test_string(self):
+ def test_bytes(self):
pl = self._create()
- data = plistlib.writePlistToString(pl)
- pl2 = plistlib.readPlistFromString(data)
+ data = plistlib.writePlistToBytes(pl)
+ pl2 = plistlib.readPlistFromBytes(data)
self.assertEqual(dict(pl), dict(pl2))
- data2 = plistlib.writePlistToString(pl2)
+ data2 = plistlib.writePlistToBytes(pl2)
self.assertEqual(data, data2)
def test_appleformatting(self):
- pl = plistlib.readPlistFromString(TESTDATA)
- data = plistlib.writePlistToString(pl)
+ pl = plistlib.readPlistFromBytes(TESTDATA)
+ data = plistlib.writePlistToBytes(pl)
self.assertEqual(data, TESTDATA,
"generated data was not identical to Apple's output")
def test_appleformattingfromliteral(self):
pl = self._create()
- pl2 = plistlib.readPlistFromString(TESTDATA)
+ pl2 = plistlib.readPlistFromBytes(TESTDATA)
self.assertEqual(dict(pl), dict(pl2),
"generated data was not identical to Apple's output")
- def test_stringio(self):
- from StringIO import StringIO
- f = StringIO()
+ def test_bytesio(self):
+ from io import BytesIO
+ b = BytesIO()
pl = self._create()
- plistlib.writePlist(pl, f)
- pl2 = plistlib.readPlist(StringIO(f.getvalue()))
- self.assertEqual(dict(pl), dict(pl2))
-
- def test_cstringio(self):
- from cStringIO import StringIO
- f = StringIO()
- pl = self._create()
- plistlib.writePlist(pl, f)
- pl2 = plistlib.readPlist(StringIO(f.getvalue()))
+ plistlib.writePlist(pl, b)
+ pl2 = plistlib.readPlist(BytesIO(b.getvalue()))
self.assertEqual(dict(pl), dict(pl2))
def test_controlcharacters(self):
@@ -169,23 +161,49 @@ class TestPlistlib(unittest.TestCase):
testString = "string containing %s" % c
if i >= 32 or c in "\r\n\t":
# \r, \n and \t are the only legal control chars in XML
- plistlib.writePlistToString(testString)
+ plistlib.writePlistToBytes(testString)
else:
self.assertRaises(ValueError,
- plistlib.writePlistToString,
+ plistlib.writePlistToBytes,
testString)
def test_nondictroot(self):
test1 = "abc"
test2 = [1, 2, 3, "abc"]
- result1 = plistlib.readPlistFromString(plistlib.writePlistToString(test1))
- result2 = plistlib.readPlistFromString(plistlib.writePlistToString(test2))
+ result1 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test1))
+ result2 = plistlib.readPlistFromBytes(plistlib.writePlistToBytes(test2))
self.assertEqual(test1, result1)
self.assertEqual(test2, result2)
+ def test_invalidarray(self):
+ for i in ["<key>key inside an array</key>",
+ "<key>key inside an array2</key><real>3</real>",
+ "<true/><key>key inside an array3</key>"]:
+ self.assertRaises(ValueError, plistlib.readPlistFromBytes,
+ ("<plist><array>%s</array></plist>"%i).encode())
+
+ def test_invaliddict(self):
+ for i in ["<key><true/>k</key><string>compound key</string>",
+ "<key>single key</key>",
+ "<string>missing key</string>",
+ "<key>k1</key><string>v1</string><real>5.3</real>"
+ "<key>k1</key><key>k2</key><string>double key</string>"]:
+ self.assertRaises(ValueError, plistlib.readPlistFromBytes,
+ ("<plist><dict>%s</dict></plist>"%i).encode())
+ self.assertRaises(ValueError, plistlib.readPlistFromBytes,
+ ("<plist><array><dict>%s</dict></array></plist>"%i).encode())
+
+ def test_invalidinteger(self):
+ self.assertRaises(ValueError, plistlib.readPlistFromBytes,
+ b"<plist><integer>not integer</integer></plist>")
+
+ def test_invalidreal(self):
+ self.assertRaises(ValueError, plistlib.readPlistFromBytes,
+ b"<plist><integer>not real</integer></plist>")
+
def test_main():
- test_support.run_unittest(TestPlistlib)
+ support.run_unittest(TestPlistlib)
if __name__ == '__main__':
diff --git a/Lib/test/test_poll.py b/Lib/test/test_poll.py
index d33af911e80..7ab3b84a97d 100644
--- a/Lib/test/test_poll.py
+++ b/Lib/test/test_poll.py
@@ -1,12 +1,12 @@
# Test case for the os.poll() function
import os, select, random, unittest
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
try:
select.poll
except AttributeError:
- raise unittest.SkipTest, "select.poll not defined -- skipping test_poll"
+ raise unittest.SkipTest("select.poll not defined -- skipping test_poll")
def find_ready_matching(ready, flag):
@@ -25,7 +25,7 @@ class PollTests(unittest.TestCase):
p = select.poll()
NUM_PIPES = 12
- MSG = " This is a test."
+ MSG = b" This is a test."
MSG_LEN = len(MSG)
readers = []
writers = []
@@ -48,14 +48,14 @@ class PollTests(unittest.TestCase):
ready = p.poll()
ready_writers = find_ready_matching(ready, select.POLLOUT)
if not ready_writers:
- raise RuntimeError, "no pipes ready for writing"
+ raise RuntimeError("no pipes ready for writing")
wr = random.choice(ready_writers)
os.write(wr, MSG)
ready = p.poll()
ready_readers = find_ready_matching(ready, select.POLLIN)
if not ready_readers:
- raise RuntimeError, "no pipes ready for reading"
+ raise RuntimeError("no pipes ready for reading")
rd = random.choice(ready_readers)
buf = os.read(rd, MSG_LEN)
self.assertEqual(len(buf), MSG_LEN)
@@ -144,7 +144,7 @@ class PollTests(unittest.TestCase):
pollster = select.poll()
pollster.register(1)
- self.assertRaises(OverflowError, pollster.poll, 1L << 64)
+ self.assertRaises(OverflowError, pollster.poll, 1 << 64)
x = 2 + 3
if x != 5:
diff --git a/Lib/test/test_popen.py b/Lib/test/test_popen.py
index 92b5e92ad58..accf187b54d 100644
--- a/Lib/test/test_popen.py
+++ b/Lib/test/test_popen.py
@@ -1,24 +1,29 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Basic tests for os.popen()
Particularly useful for platforms that fake popen.
"""
import unittest
-from test import test_support
+from test import support
import os, sys
# Test that command-lines get down as we expect.
# To do this we execute:
-# python -c "import sys;print sys.argv" {rest_of_commandline}
+# python -c "import sys;print(sys.argv)" {rest_of_commandline}
# This results in Python being spawned and printing the sys.argv list.
# We can then eval() the result of this, and see what each argv was.
python = sys.executable
+if ' ' in python:
+ python = '"' + python + '"' # quote embedded space for cmdline
class PopenTest(unittest.TestCase):
+
def _do_test_commandline(self, cmdline, expected):
- cmd = '%s -c "import sys;print sys.argv" %s' % (python, cmdline)
- data = os.popen(cmd).read() + '\n'
+ cmd = '%s -c "import sys; print(sys.argv)" %s'
+ cmd = cmd % (python, cmdline)
+ with os.popen(cmd) as p:
+ data = p.read()
got = eval(data)[1:] # strip off argv[0]
self.assertEqual(got, expected)
@@ -36,7 +41,7 @@ class PopenTest(unittest.TestCase):
'foo "a \\"quoted\\" arg" bar',
["foo", 'a "quoted" arg', "bar"]
)
- test_support.reap_children()
+ support.reap_children()
def test_return_code(self):
self.assertEqual(os.popen("exit 0").close(), None)
@@ -45,8 +50,16 @@ class PopenTest(unittest.TestCase):
else:
self.assertEqual(os.popen("exit 42").close(), 42 << 8)
+ def test_contextmanager(self):
+ with os.popen("echo hello") as f:
+ self.assertEqual(f.read(), "hello\n")
+
+ def test_iterating(self):
+ with os.popen("echo hello") as f:
+ self.assertEqual(list(f), ["hello\n"])
+
def test_main():
- test_support.run_unittest(PopenTest)
+ support.run_unittest(PopenTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_popen2.py b/Lib/test/test_popen2.py
deleted file mode 100644
index ea4107534fd..00000000000
--- a/Lib/test/test_popen2.py
+++ /dev/null
@@ -1,130 +0,0 @@
-#! /usr/bin/env python
-"""Test script for popen2.py"""
-
-import warnings
-warnings.filterwarnings("ignore", ".*popen2 module is deprecated.*",
- DeprecationWarning)
-warnings.filterwarnings("ignore", "os\.popen. is deprecated.*",
- DeprecationWarning)
-
-import os
-import sys
-import unittest
-import popen2
-
-from test.test_support import run_unittest, reap_children
-
-if sys.platform[:4] == 'beos' or sys.platform[:6] == 'atheos':
- # Locks get messed up or something. Generally we're supposed
- # to avoid mixing "posix" fork & exec with native threads, and
- # they may be right about that after all.
- raise unittest.SkipTest("popen2() doesn't work on " + sys.platform)
-
-# if we don't have os.popen, check that
-# we have os.fork. if not, skip the test
-# (by raising an ImportError)
-try:
- from os import popen
- del popen
-except ImportError:
- from os import fork
- del fork
-
-class Popen2Test(unittest.TestCase):
- cmd = "cat"
- if os.name == "nt":
- cmd = "more"
- teststr = "ab cd\n"
- # "more" doesn't act the same way across Windows flavors,
- # sometimes adding an extra newline at the start or the
- # end. So we strip whitespace off both ends for comparison.
- expected = teststr.strip()
-
- def setUp(self):
- popen2._cleanup()
- # When the test runs, there shouldn't be any open pipes
- self.assertFalse(popen2._active, "Active pipes when test starts" +
- repr([c.cmd for c in popen2._active]))
-
- def tearDown(self):
- for inst in popen2._active:
- inst.wait()
- popen2._cleanup()
- self.assertFalse(popen2._active, "popen2._active not empty")
- # The os.popen*() API delegates to the subprocess module (on Unix)
- import subprocess
- for inst in subprocess._active:
- inst.wait()
- subprocess._cleanup()
- self.assertFalse(subprocess._active, "subprocess._active not empty")
- reap_children()
-
- def validate_output(self, teststr, expected_out, r, w, e=None):
- w.write(teststr)
- w.close()
- got = r.read()
- self.assertEqual(expected_out, got.strip(), "wrote %r read %r" %
- (teststr, got))
-
- if e is not None:
- got = e.read()
- self.assertFalse(got, "unexpected %r on stderr" % got)
-
- def test_popen2(self):
- r, w = popen2.popen2(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w)
-
- def test_popen3(self):
- if os.name == 'posix':
- r, w, e = popen2.popen3([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- r, w, e = popen2.popen3(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- def test_os_popen2(self):
- # same test as test_popen2(), but using the os.popen*() API
- if os.name == 'posix':
- w, r = os.popen2([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w)
-
- w, r = os.popen2(["echo", self.teststr])
- got = r.read()
- self.assertEqual(got, self.teststr + "\n")
-
- w, r = os.popen2(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w)
-
- def test_os_popen3(self):
- # same test as test_popen3(), but using the os.popen*() API
- if os.name == 'posix':
- w, r, e = os.popen3([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- w, r, e = os.popen3(["echo", self.teststr])
- got = r.read()
- self.assertEqual(got, self.teststr + "\n")
- got = e.read()
- self.assertFalse(got, "unexpected %r on stderr" % got)
-
- w, r, e = os.popen3(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w, e)
-
- def test_os_popen4(self):
- if os.name == 'posix':
- w, r = os.popen4([self.cmd])
- self.validate_output(self.teststr, self.expected, r, w)
-
- w, r = os.popen4(["echo", self.teststr])
- got = r.read()
- self.assertEqual(got, self.teststr + "\n")
-
- w, r = os.popen4(self.cmd)
- self.validate_output(self.teststr, self.expected, r, w)
-
-
-def test_main():
- run_unittest(Popen2Test)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py
index 9505c2250a3..e3901b886ca 100644
--- a/Lib/test/test_poplib.py
+++ b/Lib/test/test_poplib.py
@@ -12,14 +12,15 @@ import time
import errno
from unittest import TestCase
-from test import test_support
-from test.test_support import HOST
+from test import support as test_support
threading = test_support.import_module('threading')
+HOST = test_support.HOST
+PORT = 0
# the dummy data returned by server when LIST and RETR commands are issued
-LIST_RESP = '1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n.\r\n'
-RETR_RESP = """From: postmaster@python.org\
+LIST_RESP = b'1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n.\r\n'
+RETR_RESP = b"""From: postmaster@python.org\
\r\nContent-Type: text/plain\r\n\
MIME-Version: 1.0\r\n\
Subject: Dummy\r\n\
@@ -34,15 +35,16 @@ class DummyPOP3Handler(asynchat.async_chat):
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
- self.set_terminator("\r\n")
+ self.set_terminator(b"\r\n")
self.in_buffer = []
- self.push('+OK dummy pop3 server ready.')
+ self.push('+OK dummy pop3 server ready. <timestamp>')
def collect_incoming_data(self, data):
self.in_buffer.append(data)
def found_terminator(self):
- line = ''.join(self.in_buffer)
+ line = b''.join(self.in_buffer)
+ line = str(line, 'ISO-8859-1')
self.in_buffer = []
cmd = line.split(' ')[0].lower()
space = line.find(' ')
@@ -60,7 +62,7 @@ class DummyPOP3Handler(asynchat.async_chat):
raise
def push(self, data):
- asynchat.async_chat.push(self, data + '\r\n')
+ asynchat.async_chat.push(self, data.encode("ISO-8859-1") + b'\r\n')
def cmd_echo(self, arg):
# sends back the received string (used by the test suite)
@@ -103,6 +105,9 @@ class DummyPOP3Handler(asynchat.async_chat):
def cmd_rpop(self, arg):
self.push('+OK done nothing.')
+ def cmd_apop(self, arg):
+ self.push('+OK done nothing.')
+
class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
@@ -117,6 +122,7 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
self.active = False
self.active_lock = threading.Lock()
self.host, self.port = self.socket.getsockname()[:2]
+ self.handler_instance = None
def start(self):
assert not self.active
@@ -138,10 +144,8 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
self.active = False
self.join()
- def handle_accept(self):
- conn, addr = self.accept()
- self.handler = self.handler(conn)
- self.close()
+ def handle_accepted(self, conn, addr):
+ self.handler_instance = self.handler(conn)
def handle_connect(self):
self.close()
@@ -155,12 +159,11 @@ class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
class TestPOP3Class(TestCase):
-
def assertOK(self, resp):
- self.assertTrue(resp.startswith("+OK"))
+ self.assertTrue(resp.startswith(b"+OK"))
def setUp(self):
- self.server = DummyPOP3Server((HOST, 0))
+ self.server = DummyPOP3Server((HOST, PORT))
self.server.start()
self.client = poplib.POP3(self.server.host, self.server.port)
@@ -169,7 +172,8 @@ class TestPOP3Class(TestCase):
self.server.stop()
def test_getwelcome(self):
- self.assertEqual(self.client.getwelcome(), '+OK dummy pop3 server ready.')
+ self.assertEqual(self.client.getwelcome(),
+ b'+OK dummy pop3 server ready. <timestamp>')
def test_exceptions(self):
self.assertRaises(poplib.error_proto, self.client._shortcmd, 'echo -err')
@@ -187,16 +191,18 @@ class TestPOP3Class(TestCase):
def test_list(self):
self.assertEqual(self.client.list()[1:],
- (['1 1', '2 2', '3 3', '4 4', '5 5'], 25))
- self.assertTrue(self.client.list('1').endswith("OK 1 1"))
+ ([b'1 1', b'2 2', b'3 3', b'4 4', b'5 5'],
+ 25))
+ self.assertTrue(self.client.list('1').endswith(b"OK 1 1"))
def test_retr(self):
- expected = ('+OK 116 bytes',
- ['From: postmaster@python.org', 'Content-Type: text/plain',
- 'MIME-Version: 1.0', 'Subject: Dummy',
- '', 'line1', 'line2', 'line3'],
+ expected = (b'+OK 116 bytes',
+ [b'From: postmaster@python.org', b'Content-Type: text/plain',
+ b'MIME-Version: 1.0', b'Subject: Dummy',
+ b'', b'line1', b'line2', b'line3'],
113)
- self.assertEqual(self.client.retr('foo'), expected)
+ foo = self.client.retr('foo')
+ self.assertEqual(foo, expected)
def test_dele(self):
self.assertOK(self.client.dele('foo'))
@@ -207,11 +213,14 @@ class TestPOP3Class(TestCase):
def test_rpop(self):
self.assertOK(self.client.rpop('foo'))
+ def test_apop(self):
+ self.assertOK(self.client.apop('foo', 'dummypassword'))
+
def test_top(self):
- expected = ('+OK 116 bytes',
- ['From: postmaster@python.org', 'Content-Type: text/plain',
- 'MIME-Version: 1.0', 'Subject: Dummy', '',
- 'line1', 'line2', 'line3'],
+ expected = (b'+OK 116 bytes',
+ [b'From: postmaster@python.org', b'Content-Type: text/plain',
+ b'MIME-Version: 1.0', b'Subject: Dummy', b'',
+ b'line1', b'line2', b'line3'],
113)
self.assertEqual(self.client.top(1, 1), expected)
@@ -231,27 +240,29 @@ if hasattr(poplib, 'POP3_SSL'):
def __init__(self, conn):
asynchat.async_chat.__init__(self, conn)
- self.socket = ssl.wrap_socket(self.socket, certfile=CERTFILE,
+ ssl_socket = ssl.wrap_socket(self.socket, certfile=CERTFILE,
server_side=True,
do_handshake_on_connect=False)
+ self.del_channel()
+ self.set_socket(ssl_socket)
# Must try handshake before calling push()
self._ssl_accepting = True
self._do_ssl_handshake()
- self.set_terminator("\r\n")
+ self.set_terminator(b"\r\n")
self.in_buffer = []
- self.push('+OK dummy pop3 server ready.')
+ self.push('+OK dummy pop3 server ready. <timestamp>')
def _do_ssl_handshake(self):
try:
self.socket.do_handshake()
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
return
elif err.args[0] == ssl.SSL_ERROR_EOF:
return self.handle_close()
raise
- except socket.error, err:
+ except socket.error as err:
if err.args[0] == errno.ECONNABORTED:
return self.handle_close()
else:
@@ -267,7 +278,7 @@ if hasattr(poplib, 'POP3_SSL'):
# repeat previous tests by using poplib.POP3_SSL
def setUp(self):
- self.server = DummyPOP3Server((HOST, 0))
+ self.server = DummyPOP3Server((HOST, PORT))
self.server.handler = DummyPOP3_SSLHandler
self.server.start()
self.client = poplib.POP3_SSL(self.server.host, self.server.port)
@@ -275,6 +286,23 @@ if hasattr(poplib, 'POP3_SSL'):
def test__all__(self):
self.assertIn('POP3_SSL', poplib.__all__)
+ def test_context(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, keyfile=CERTFILE, context=ctx)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, certfile=CERTFILE, context=ctx)
+ self.assertRaises(ValueError, poplib.POP3_SSL, self.server.host,
+ self.server.port, keyfile=CERTFILE,
+ certfile=CERTFILE, context=ctx)
+
+ self.client.quit()
+ self.client = poplib.POP3_SSL(self.server.host, self.server.port,
+ context=ctx)
+ self.assertIsInstance(self.client.sock, ssl.SSLSocket)
+ self.assertIs(self.client.sock.context, ctx)
+ self.assertTrue(self.client.noop().startswith(b'+OK'))
+
class TestTimeouts(TestCase):
@@ -297,7 +325,7 @@ class TestTimeouts(TestCase):
evt.set()
try:
conn, addr = serv.accept()
- conn.send("+ Hola mundo\n")
+ conn.send(b"+ Hola mundo\n")
conn.close()
except socket.timeout:
pass
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 7214efa323d..b936dda44bc 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -1,9 +1,9 @@
"Test posix functions"
-from test import test_support
+from test import support
# Skip these tests if there is no posix module.
-posix = test_support.import_module('posix')
+posix = support.import_module('posix')
import errno
import sys
@@ -13,45 +13,44 @@ import platform
import pwd
import shutil
import stat
-import sys
import tempfile
import unittest
import warnings
_DUMMY_SYMLINK = os.path.join(tempfile.gettempdir(),
- test_support.TESTFN + '-dummy-symlink')
-
-warnings.filterwarnings('ignore', '.* potential security risk .*',
- RuntimeWarning)
+ support.TESTFN + '-dummy-symlink')
class PosixTester(unittest.TestCase):
def setUp(self):
# create empty file
- fp = open(test_support.TESTFN, 'w+')
+ fp = open(support.TESTFN, 'w+')
fp.close()
- self.teardown_files = [ test_support.TESTFN ]
+ self.teardown_files = [ support.TESTFN ]
+ self._warnings_manager = support.check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings('ignore', '.* potential security risk .*',
+ RuntimeWarning)
def tearDown(self):
for teardown_file in self.teardown_files:
- os.unlink(teardown_file)
+ support.unlink(teardown_file)
+ self._warnings_manager.__exit__(None, None, None)
def testNoArgFunctions(self):
# test posix functions which take no arguments and have
# no side-effects which we need to cleanup (e.g., fork, wait, abort)
- NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdu", "uname",
- "times", "getloadavg", "tmpnam",
+ NO_ARG_FUNCTIONS = [ "ctermid", "getcwd", "getcwdb", "uname",
+ "times", "getloadavg",
"getegid", "geteuid", "getgid", "getgroups",
"getpid", "getpgrp", "getppid", "getuid",
]
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "", DeprecationWarning)
- for name in NO_ARG_FUNCTIONS:
- posix_func = getattr(posix, name, None)
- if posix_func is not None:
- posix_func()
- self.assertRaises(TypeError, posix_func, 1)
+ for name in NO_ARG_FUNCTIONS:
+ posix_func = getattr(posix, name, None)
+ if posix_func is not None:
+ posix_func()
+ self.assertRaises(TypeError, posix_func, 1)
if hasattr(posix, 'getresuid'):
def test_getresuid(self):
@@ -126,7 +125,7 @@ class PosixTester(unittest.TestCase):
def test_fstatvfs(self):
if hasattr(posix, 'fstatvfs'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
self.assertTrue(posix.fstatvfs(fp.fileno()))
finally:
@@ -134,7 +133,7 @@ class PosixTester(unittest.TestCase):
def test_ftruncate(self):
if hasattr(posix, 'ftruncate'):
- fp = open(test_support.TESTFN, 'w+')
+ fp = open(support.TESTFN, 'w+')
try:
# we need to have some data to truncate
fp.write('test')
@@ -145,7 +144,7 @@ class PosixTester(unittest.TestCase):
def test_dup(self):
if hasattr(posix, 'dup'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
fd = posix.dup(fp.fileno())
self.assertIsInstance(fd, int)
@@ -160,59 +159,48 @@ class PosixTester(unittest.TestCase):
def test_dup2(self):
if hasattr(posix, 'dup2'):
- fp1 = open(test_support.TESTFN)
- fp2 = open(test_support.TESTFN)
+ fp1 = open(support.TESTFN)
+ fp2 = open(support.TESTFN)
try:
posix.dup2(fp1.fileno(), fp2.fileno())
finally:
fp1.close()
fp2.close()
- def fdopen_helper(self, *args):
- fd = os.open(test_support.TESTFN, os.O_RDONLY)
- fp2 = posix.fdopen(fd, *args)
- fp2.close()
-
- def test_fdopen(self):
- if hasattr(posix, 'fdopen'):
- self.fdopen_helper()
- self.fdopen_helper('r')
- self.fdopen_helper('r', 100)
-
def test_osexlock(self):
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
if hasattr(posix, "O_SHLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_WRONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_osshlock(self):
if hasattr(posix, "O_SHLOCK"):
- fd1 = os.open(test_support.TESTFN,
+ fd1 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- fd2 = os.open(test_support.TESTFN,
+ fd2 = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
os.close(fd2)
os.close(fd1)
if hasattr(posix, "O_EXLOCK"):
- fd = os.open(test_support.TESTFN,
+ fd = os.open(support.TESTFN,
os.O_WRONLY|os.O_SHLOCK|os.O_CREAT)
- self.assertRaises(OSError, os.open, test_support.TESTFN,
+ self.assertRaises(OSError, os.open, support.TESTFN,
os.O_RDONLY|os.O_EXLOCK|os.O_NONBLOCK)
os.close(fd)
def test_fstat(self):
if hasattr(posix, 'fstat'):
- fp = open(test_support.TESTFN)
+ fp = open(support.TESTFN)
try:
self.assertTrue(posix.fstat(fp.fileno()))
finally:
@@ -220,7 +208,29 @@ class PosixTester(unittest.TestCase):
def test_stat(self):
if hasattr(posix, 'stat'):
- self.assertTrue(posix.stat(test_support.TESTFN))
+ self.assertTrue(posix.stat(support.TESTFN))
+
+ @unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
+ def test_mkfifo(self):
+ support.unlink(support.TESTFN)
+ posix.mkfifo(support.TESTFN, stat.S_IRUSR | stat.S_IWUSR)
+ self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode))
+
+ @unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
+ "don't have mknod()/S_IFIFO")
+ def test_mknod(self):
+ # Test using mknod() to create a FIFO (the only use specified
+ # by POSIX).
+ support.unlink(support.TESTFN)
+ mode = stat.S_IFIFO | stat.S_IRUSR | stat.S_IWUSR
+ try:
+ posix.mknod(support.TESTFN, mode, 0)
+ except OSError as e:
+ # Some old systems don't allow unprivileged users to use
+ # mknod(), or only support creating device nodes.
+ self.assertIn(e.errno, (errno.EPERM, errno.EINVAL))
+ else:
+ self.assertTrue(stat.S_ISFIFO(posix.stat(support.TESTFN).st_mode))
def _test_all_chown_common(self, chown_func, first_param):
"""Common code for chown, fchown and lchown tests."""
@@ -251,19 +261,19 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'chown'), "test needs os.chown()")
def test_chown(self):
# raise an OSError if the file does not exist
- os.unlink(test_support.TESTFN)
- self.assertRaises(OSError, posix.chown, test_support.TESTFN, -1, -1)
+ os.unlink(support.TESTFN)
+ self.assertRaises(OSError, posix.chown, support.TESTFN, -1, -1)
# re-create the file
- open(test_support.TESTFN, 'w').close()
- self._test_all_chown_common(posix.chown, test_support.TESTFN)
+ open(support.TESTFN, 'w').close()
+ self._test_all_chown_common(posix.chown, support.TESTFN)
@unittest.skipUnless(hasattr(posix, 'fchown'), "test needs os.fchown()")
def test_fchown(self):
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
# re-create the file
- test_file = open(test_support.TESTFN, 'w')
+ test_file = open(support.TESTFN, 'w')
try:
fd = test_file.fileno()
self._test_all_chown_common(posix.fchown, fd)
@@ -272,23 +282,28 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'lchown'), "test needs os.lchown()")
def test_lchown(self):
- os.unlink(test_support.TESTFN)
+ os.unlink(support.TESTFN)
# create a symlink
- os.symlink(_DUMMY_SYMLINK, test_support.TESTFN)
- self._test_all_chown_common(posix.lchown, test_support.TESTFN)
+ os.symlink(_DUMMY_SYMLINK, support.TESTFN)
+ self._test_all_chown_common(posix.lchown, support.TESTFN)
def test_chdir(self):
if hasattr(posix, 'chdir'):
posix.chdir(os.curdir)
- self.assertRaises(OSError, posix.chdir, test_support.TESTFN)
+ self.assertRaises(OSError, posix.chdir, support.TESTFN)
- def test_lsdir(self):
- if hasattr(posix, 'lsdir'):
- self.assertIn(test_support.TESTFN, posix.lsdir(os.curdir))
+ def test_listdir(self):
+ if hasattr(posix, 'listdir'):
+ self.assertTrue(support.TESTFN in posix.listdir(os.curdir))
+
+ def test_listdir_default(self):
+ # When listdir is called without argument, it's the same as listdir(os.curdir)
+ if hasattr(posix, 'listdir'):
+ self.assertTrue(support.TESTFN in posix.listdir())
def test_access(self):
if hasattr(posix, 'access'):
- self.assertTrue(posix.access(test_support.TESTFN, os.R_OK))
+ self.assertTrue(posix.access(support.TESTFN, os.R_OK))
def test_umask(self):
if hasattr(posix, 'umask'):
@@ -306,30 +321,15 @@ class PosixTester(unittest.TestCase):
os.close(reader)
os.close(writer)
- def test_tempnam(self):
- if hasattr(posix, 'tempnam'):
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "tempnam", DeprecationWarning)
- self.assertTrue(posix.tempnam())
- self.assertTrue(posix.tempnam(os.curdir))
- self.assertTrue(posix.tempnam(os.curdir, 'blah'))
-
- def test_tmpfile(self):
- if hasattr(posix, 'tmpfile'):
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", "tmpfile", DeprecationWarning)
- fp = posix.tmpfile()
- fp.close()
-
def test_utime(self):
if hasattr(posix, 'utime'):
now = time.time()
- posix.utime(test_support.TESTFN, None)
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (now, None))
- self.assertRaises(TypeError, posix.utime, test_support.TESTFN, (None, now))
- posix.utime(test_support.TESTFN, (int(now), int(now)))
- posix.utime(test_support.TESTFN, (now, now))
+ posix.utime(support.TESTFN, None)
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (now, None))
+ self.assertRaises(TypeError, posix.utime, support.TESTFN, (None, now))
+ posix.utime(support.TESTFN, (int(now), int(now)))
+ posix.utime(support.TESTFN, (now, now))
def _test_chflags_regular_file(self, chflags_func, target_file):
st = os.stat(target_file)
@@ -356,19 +356,19 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'chflags'), 'test needs os.chflags()')
def test_chflags(self):
- self._test_chflags_regular_file(posix.chflags, test_support.TESTFN)
+ self._test_chflags_regular_file(posix.chflags, support.TESTFN)
@unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
def test_lchflags_regular_file(self):
- self._test_chflags_regular_file(posix.lchflags, test_support.TESTFN)
+ self._test_chflags_regular_file(posix.lchflags, support.TESTFN)
@unittest.skipUnless(hasattr(posix, 'lchflags'), 'test needs os.lchflags()')
def test_lchflags_symlink(self):
- testfn_st = os.stat(test_support.TESTFN)
+ testfn_st = os.stat(support.TESTFN)
self.assertTrue(hasattr(testfn_st, 'st_flags'))
- os.symlink(test_support.TESTFN, _DUMMY_SYMLINK)
+ os.symlink(support.TESTFN, _DUMMY_SYMLINK)
self.teardown_files.append(_DUMMY_SYMLINK)
dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
@@ -383,7 +383,7 @@ class PosixTester(unittest.TestCase):
self.skipTest(msg)
try:
- new_testfn_st = os.stat(test_support.TESTFN)
+ new_testfn_st = os.stat(support.TESTFN)
new_dummy_symlink_st = os.lstat(_DUMMY_SYMLINK)
self.assertEqual(testfn_st.st_flags, new_testfn_st.st_flags)
@@ -392,11 +392,20 @@ class PosixTester(unittest.TestCase):
finally:
posix.lchflags(_DUMMY_SYMLINK, dummy_symlink_st.st_flags)
+ def test_environ(self):
+ if os.name == "nt":
+ item_type = str
+ else:
+ item_type = bytes
+ for k, v in posix.environ.items():
+ self.assertEqual(type(k), item_type)
+ self.assertEqual(type(v), item_type)
+
def test_getcwd_long_pathnames(self):
if hasattr(posix, 'getcwd'):
dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'
curdir = os.getcwd()
- base_path = os.path.abspath(test_support.TESTFN) + '.getcwd'
+ base_path = os.path.abspath(support.TESTFN) + '.getcwd'
try:
os.mkdir(base_path)
@@ -405,34 +414,20 @@ class PosixTester(unittest.TestCase):
# Just returning nothing instead of the SkipTest exception,
# because the test results in Error in that case.
# Is that ok?
-# raise unittest.SkipTest, "cannot create directory for testing"
+# raise unittest.SkipTest("cannot create directory for testing")
return
- try:
def _create_and_do_getcwd(dirname, current_path_length = 0):
try:
os.mkdir(dirname)
except:
- raise unittest.SkipTest, "mkdir cannot create directory sufficiently deep for getcwd test"
+ raise unittest.SkipTest("mkdir cannot create directory sufficiently deep for getcwd test")
os.chdir(dirname)
try:
os.getcwd()
- if current_path_length < 4099:
+ if current_path_length < 1027:
_create_and_do_getcwd(dirname, current_path_length + len(dirname) + 1)
- except OSError as e:
- expected_errno = errno.ENAMETOOLONG
- # The following platforms have quirky getcwd()
- # behaviour -- see issue 9185 and 15765 for
- # more information.
- quirky_platform = (
- 'sunos' in sys.platform or
- 'netbsd' in sys.platform or
- 'openbsd' in sys.platform
- )
- if quirky_platform:
- expected_errno = errno.ERANGE
- self.assertEqual(e.errno, expected_errno)
finally:
os.chdir('..')
os.rmdir(dirname)
@@ -441,7 +436,7 @@ class PosixTester(unittest.TestCase):
finally:
os.chdir(curdir)
- shutil.rmtree(base_path)
+ support.rmtree(base_path)
@unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
def test_getgroups(self):
@@ -491,13 +486,13 @@ class PosixGroupsTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'setgroups'),
"test needs posix.setgroups()")
def test_setgroups(self):
- for groups in [[0], range(16)]:
+ for groups in [[0], list(range(16))]:
posix.setgroups(groups)
self.assertListEqual(groups, posix.getgroups())
def test_main():
- test_support.run_unittest(PosixTester, PosixGroupsTester)
+ support.run_unittest(PosixTester, PosixGroupsTester)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_posixpath.py b/Lib/test/test_posixpath.py
index 8562d2bc85a..599c85a4771 100644
--- a/Lib/test/test_posixpath.py
+++ b/Lib/test/test_posixpath.py
@@ -1,13 +1,31 @@
import unittest
-from test import test_support, test_genericpath
+from test import support, test_genericpath
-import posixpath, os
+import itertools
+import posixpath
+import os
+import sys
from posixpath import realpath, abspath, dirname, basename
+try:
+ import posix
+except ImportError:
+ posix = None
+
# An absolute path to a temporary filename for testing. We can't rely on TESTFN
# being an absolute path, so we need this.
-ABSTFN = abspath(test_support.TESTFN)
+ABSTFN = abspath(support.TESTFN)
+
+def skip_if_ABSTFN_contains_backslash(test):
+ """
+ On Windows, posixpath.abspath still returns paths with backslashes
+ instead of posix forward slashes. If this is the case, several tests
+ fail, so skip them.
+ """
+ found_backslash = '\\' in ABSTFN
+ msg = "ABSTFN is not a posix path - tests fail"
+ return [test, unittest.skip(msg)(test)][found_backslash]
def safe_rmdir(dirname):
try:
@@ -22,13 +40,38 @@ class PosixPathTest(unittest.TestCase):
def tearDown(self):
for suffix in ["", "1", "2"]:
- test_support.unlink(test_support.TESTFN + suffix)
- safe_rmdir(test_support.TESTFN + suffix)
+ support.unlink(support.TESTFN + suffix)
+ safe_rmdir(support.TESTFN + suffix)
def test_join(self):
- self.assertEqual(posixpath.join("/foo", "bar", "/bar", "baz"), "/bar/baz")
+ self.assertEqual(posixpath.join("/foo", "bar", "/bar", "baz"),
+ "/bar/baz")
self.assertEqual(posixpath.join("/foo", "bar", "baz"), "/foo/bar/baz")
- self.assertEqual(posixpath.join("/foo/", "bar/", "baz/"), "/foo/bar/baz/")
+ self.assertEqual(posixpath.join("/foo/", "bar/", "baz/"),
+ "/foo/bar/baz/")
+
+ self.assertEqual(posixpath.join(b"/foo", b"bar", b"/bar", b"baz"),
+ b"/bar/baz")
+ self.assertEqual(posixpath.join(b"/foo", b"bar", b"baz"),
+ b"/foo/bar/baz")
+ self.assertEqual(posixpath.join(b"/foo/", b"bar/", b"baz/"),
+ b"/foo/bar/baz/")
+
+ def check_error_msg(list_of_args, msg):
+ """Check posixpath.join raises friendly TypeErrors."""
+ for args in (item for perm in list_of_args
+ for item in itertools.permutations(perm)):
+ with self.assertRaises(TypeError) as cm:
+ posixpath.join(*args)
+ self.assertEqual(msg, cm.exception.args[0])
+
+ check_error_msg([[b'bytes', 'str'], [bytearray(b'bytes'), 'str']],
+ "Can't mix strings and bytes in path components.")
+ # regression, see #15377
+ with self.assertRaises(TypeError) as cm:
+ posixpath.join(None, 'str')
+ self.assertNotEqual("Can't mix strings and bytes in path components.",
+ cm.exception.args[0])
def test_split(self):
self.assertEqual(posixpath.split("/foo/bar"), ("/foo", "bar"))
@@ -37,13 +80,39 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.split("////foo"), ("////", "foo"))
self.assertEqual(posixpath.split("//foo//bar"), ("//foo", "bar"))
+ self.assertEqual(posixpath.split(b"/foo/bar"), (b"/foo", b"bar"))
+ self.assertEqual(posixpath.split(b"/"), (b"/", b""))
+ self.assertEqual(posixpath.split(b"foo"), (b"", b"foo"))
+ self.assertEqual(posixpath.split(b"////foo"), (b"////", b"foo"))
+ self.assertEqual(posixpath.split(b"//foo//bar"), (b"//foo", b"bar"))
+
def splitextTest(self, path, filename, ext):
self.assertEqual(posixpath.splitext(path), (filename, ext))
self.assertEqual(posixpath.splitext("/" + path), ("/" + filename, ext))
- self.assertEqual(posixpath.splitext("abc/" + path), ("abc/" + filename, ext))
- self.assertEqual(posixpath.splitext("abc.def/" + path), ("abc.def/" + filename, ext))
- self.assertEqual(posixpath.splitext("/abc.def/" + path), ("/abc.def/" + filename, ext))
- self.assertEqual(posixpath.splitext(path + "/"), (filename + ext + "/", ""))
+ self.assertEqual(posixpath.splitext("abc/" + path),
+ ("abc/" + filename, ext))
+ self.assertEqual(posixpath.splitext("abc.def/" + path),
+ ("abc.def/" + filename, ext))
+ self.assertEqual(posixpath.splitext("/abc.def/" + path),
+ ("/abc.def/" + filename, ext))
+ self.assertEqual(posixpath.splitext(path + "/"),
+ (filename + ext + "/", ""))
+
+ path = bytes(path, "ASCII")
+ filename = bytes(filename, "ASCII")
+ ext = bytes(ext, "ASCII")
+
+ self.assertEqual(posixpath.splitext(path), (filename, ext))
+ self.assertEqual(posixpath.splitext(b"/" + path),
+ (b"/" + filename, ext))
+ self.assertEqual(posixpath.splitext(b"abc/" + path),
+ (b"abc/" + filename, ext))
+ self.assertEqual(posixpath.splitext(b"abc.def/" + path),
+ (b"abc.def/" + filename, ext))
+ self.assertEqual(posixpath.splitext(b"/abc.def/" + path),
+ (b"/abc.def/" + filename, ext))
+ self.assertEqual(posixpath.splitext(path + b"/"),
+ (filename + ext + b"/", b""))
def test_splitext(self):
self.splitextTest("foo.bar", "foo", ".bar")
@@ -66,6 +135,12 @@ class PosixPathTest(unittest.TestCase):
self.assertIs(posixpath.isabs("/foo/bar"), True)
self.assertIs(posixpath.isabs("foo/bar"), False)
+ self.assertIs(posixpath.isabs(b""), False)
+ self.assertIs(posixpath.isabs(b"/"), True)
+ self.assertIs(posixpath.isabs(b"/foo"), True)
+ self.assertIs(posixpath.isabs(b"/foo/bar"), True)
+ self.assertIs(posixpath.isabs(b"foo/bar"), False)
+
def test_basename(self):
self.assertEqual(posixpath.basename("/foo/bar"), "bar")
self.assertEqual(posixpath.basename("/"), "")
@@ -73,6 +148,12 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.basename("////foo"), "foo")
self.assertEqual(posixpath.basename("//foo//bar"), "bar")
+ self.assertEqual(posixpath.basename(b"/foo/bar"), b"bar")
+ self.assertEqual(posixpath.basename(b"/"), b"")
+ self.assertEqual(posixpath.basename(b"foo"), b"foo")
+ self.assertEqual(posixpath.basename(b"////foo"), b"foo")
+ self.assertEqual(posixpath.basename(b"//foo//bar"), b"bar")
+
def test_dirname(self):
self.assertEqual(posixpath.dirname("/foo/bar"), "/foo")
self.assertEqual(posixpath.dirname("/"), "/")
@@ -80,130 +161,162 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.dirname("////foo"), "////")
self.assertEqual(posixpath.dirname("//foo//bar"), "//foo")
+ self.assertEqual(posixpath.dirname(b"/foo/bar"), b"/foo")
+ self.assertEqual(posixpath.dirname(b"/"), b"/")
+ self.assertEqual(posixpath.dirname(b"foo"), b"")
+ self.assertEqual(posixpath.dirname(b"////foo"), b"////")
+ self.assertEqual(posixpath.dirname(b"//foo//bar"), b"//foo")
+
def test_islink(self):
- self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
- f = open(test_support.TESTFN + "1", "wb")
+ self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), False)
+ f = open(support.TESTFN + "1", "wb")
try:
- f.write("foo")
+ f.write(b"foo")
f.close()
- self.assertIs(posixpath.islink(test_support.TESTFN + "1"), False)
- if hasattr(os, "symlink"):
- os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2")
- self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
- os.remove(test_support.TESTFN + "1")
- self.assertIs(posixpath.islink(test_support.TESTFN + "2"), True)
- self.assertIs(posixpath.exists(test_support.TESTFN + "2"), False)
- self.assertIs(posixpath.lexists(test_support.TESTFN + "2"), True)
+ self.assertIs(posixpath.islink(support.TESTFN + "1"), False)
+ if support.can_symlink():
+ os.symlink(support.TESTFN + "1", support.TESTFN + "2")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ os.remove(support.TESTFN + "1")
+ self.assertIs(posixpath.islink(support.TESTFN + "2"), True)
+ self.assertIs(posixpath.exists(support.TESTFN + "2"), False)
+ self.assertIs(posixpath.lexists(support.TESTFN + "2"), True)
finally:
if not f.close():
f.close()
+ @staticmethod
+ def _create_file(filename):
+ with open(filename, 'wb') as f:
+ f.write(b'foo')
+
def test_samefile(self):
- f = open(test_support.TESTFN + "1", "wb")
- try:
- f.write("foo")
- f.close()
- self.assertIs(
- posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "1"
- ),
- True
- )
-
- # If we don't have links, assume that os.stat doesn't return
- # reasonable inode information and thus, that samefile() doesn't
- # work.
- if hasattr(os, "symlink"):
- os.symlink(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
- )
- self.assertIs(
- posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
- ),
- True
- )
- os.remove(test_support.TESTFN + "2")
- f = open(test_support.TESTFN + "2", "wb")
- f.write("bar")
- f.close()
- self.assertIs(
- posixpath.samefile(
- test_support.TESTFN + "1",
- test_support.TESTFN + "2"
- ),
- False
- )
- finally:
- if not f.close():
- f.close()
+ test_fn = support.TESTFN + "1"
+ self._create_file(test_fn)
+ self.assertTrue(posixpath.samefile(test_fn, test_fn))
+ self.assertRaises(TypeError, posixpath.samefile)
+
+ @unittest.skipIf(
+ sys.platform.startswith('win'),
+ "posixpath.samefile does not work on links in Windows")
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ def test_samefile_on_links(self):
+ test_fn1 = support.TESTFN + "1"
+ test_fn2 = support.TESTFN + "2"
+ self._create_file(test_fn1)
+
+ os.symlink(test_fn1, test_fn2)
+ self.assertTrue(posixpath.samefile(test_fn1, test_fn2))
+ os.remove(test_fn2)
+
+ self._create_file(test_fn2)
+ self.assertFalse(posixpath.samefile(test_fn1, test_fn2))
+
def test_samestat(self):
- f = open(test_support.TESTFN + "1", "wb")
- try:
- f.write("foo")
- f.close()
- self.assertIs(
- posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "1")
- ),
- True
- )
- # If we don't have links, assume that os.stat() doesn't return
- # reasonable inode information and thus, that samestat() doesn't
- # work.
- if hasattr(os, "symlink"):
- os.symlink(test_support.TESTFN + "1", test_support.TESTFN + "2")
- self.assertIs(
- posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "2")
- ),
- True
- )
- os.remove(test_support.TESTFN + "2")
- f = open(test_support.TESTFN + "2", "wb")
- f.write("bar")
- f.close()
- self.assertIs(
- posixpath.samestat(
- os.stat(test_support.TESTFN + "1"),
- os.stat(test_support.TESTFN + "2")
- ),
- False
- )
- finally:
- if not f.close():
- f.close()
+ test_fn = support.TESTFN + "1"
+ self._create_file(test_fn)
+ test_fns = [test_fn]*2
+ stats = map(os.stat, test_fns)
+ self.assertTrue(posixpath.samestat(*stats))
+
+ @unittest.skipIf(
+ sys.platform.startswith('win'),
+ "posixpath.samestat does not work on links in Windows")
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ def test_samestat_on_links(self):
+ test_fn1 = support.TESTFN + "1"
+ test_fn2 = support.TESTFN + "2"
+ self._create_file(test_fn1)
+ test_fns = (test_fn1, test_fn2)
+ os.symlink(*test_fns)
+ stats = map(os.stat, test_fns)
+ self.assertTrue(posixpath.samestat(*stats))
+ os.remove(test_fn2)
+
+ self._create_file(test_fn2)
+ stats = map(os.stat, test_fns)
+ self.assertFalse(posixpath.samestat(*stats))
+
+ self.assertRaises(TypeError, posixpath.samestat)
def test_ismount(self):
self.assertIs(posixpath.ismount("/"), True)
+ self.assertIs(posixpath.ismount(b"/"), True)
+
+ def test_ismount_non_existent(self):
+ # Non-existent mountpoint.
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ try:
+ os.mkdir(ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(support.can_symlink(),
+ "Test requires symlink support")
+ def test_ismount_symlinks(self):
+ # Symlinks are never mountpoints.
+ try:
+ os.symlink("/", ABSTFN)
+ self.assertIs(posixpath.ismount(ABSTFN), False)
+ finally:
+ os.unlink(ABSTFN)
+
+ @unittest.skipIf(posix is None, "Test requires posix module")
+ def test_ismount_different_device(self):
+ # Simulate the path being on a different device from its parent by
+ # mocking out st_dev.
+ save_lstat = os.lstat
+ def fake_lstat(path):
+ st_ino = 0
+ st_dev = 0
+ if path == ABSTFN:
+ st_dev = 1
+ st_ino = 1
+ return posix.stat_result((0, st_ino, st_dev, 0, 0, 0, 0, 0, 0, 0))
+ try:
+ os.lstat = fake_lstat
+ self.assertIs(posixpath.ismount(ABSTFN), True)
+ finally:
+ os.lstat = save_lstat
def test_expanduser(self):
self.assertEqual(posixpath.expanduser("foo"), "foo")
+ self.assertEqual(posixpath.expanduser(b"foo"), b"foo")
try:
import pwd
except ImportError:
pass
else:
- self.assertIsInstance(posixpath.expanduser("~/"), basestring)
+ self.assertIsInstance(posixpath.expanduser("~/"), str)
+ self.assertIsInstance(posixpath.expanduser(b"~/"), bytes)
# if home directory == root directory, this test makes no sense
if posixpath.expanduser("~") != '/':
self.assertEqual(
posixpath.expanduser("~") + "/",
posixpath.expanduser("~/")
)
- self.assertIsInstance(posixpath.expanduser("~root/"), basestring)
- self.assertIsInstance(posixpath.expanduser("~foo/"), basestring)
+ self.assertEqual(
+ posixpath.expanduser(b"~") + b"/",
+ posixpath.expanduser(b"~/")
+ )
+ self.assertIsInstance(posixpath.expanduser("~root/"), str)
+ self.assertIsInstance(posixpath.expanduser("~foo/"), str)
+ self.assertIsInstance(posixpath.expanduser(b"~root/"), bytes)
+ self.assertIsInstance(posixpath.expanduser(b"~foo/"), bytes)
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env['HOME'] = '/'
self.assertEqual(posixpath.expanduser("~"), "/")
self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
+ # expanduser should fall back to using the password database
+ del env['HOME']
+ home = pwd.getpwuid(os.getuid()).pw_dir
+ self.assertEqual(posixpath.expanduser("~"), home)
def test_normpath(self):
self.assertEqual(posixpath.normpath(""), ".")
@@ -211,106 +324,141 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.normpath("//"), "//")
self.assertEqual(posixpath.normpath("///"), "/")
self.assertEqual(posixpath.normpath("///foo/.//bar//"), "/foo/bar")
- self.assertEqual(posixpath.normpath("///foo/.//bar//.//..//.//baz"), "/foo/baz")
+ self.assertEqual(posixpath.normpath("///foo/.//bar//.//..//.//baz"),
+ "/foo/baz")
self.assertEqual(posixpath.normpath("///..//./foo/.//bar"), "/foo/bar")
- if hasattr(os, "symlink"):
- def test_realpath_basic(self):
- # Basic operation.
- try:
- os.symlink(ABSTFN+"1", ABSTFN)
- self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
- finally:
- test_support.unlink(ABSTFN)
-
- def test_realpath_symlink_loops(self):
- # Bug #930024, return the path unchanged if we get into an infinite
- # symlink loop.
- try:
- old_path = abspath('.')
- os.symlink(ABSTFN, ABSTFN)
- self.assertEqual(realpath(ABSTFN), ABSTFN)
-
- os.symlink(ABSTFN+"1", ABSTFN+"2")
- os.symlink(ABSTFN+"2", ABSTFN+"1")
- self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1")
- self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2")
-
- # Test using relative path as well.
- os.chdir(dirname(ABSTFN))
- self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
- finally:
- os.chdir(old_path)
- test_support.unlink(ABSTFN)
- test_support.unlink(ABSTFN+"1")
- test_support.unlink(ABSTFN+"2")
-
- def test_realpath_resolve_parents(self):
- # We also need to resolve any symlinks in the parents of a relative
- # path passed to realpath. E.g.: current working directory is
- # /usr/doc with 'doc' being a symlink to /usr/share/doc. We call
- # realpath("a"). This should return /usr/share/doc/a/.
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/y")
- os.symlink(ABSTFN + "/y", ABSTFN + "/k")
-
- os.chdir(ABSTFN + "/k")
- self.assertEqual(realpath("a"), ABSTFN + "/y/a")
- finally:
- os.chdir(old_path)
- test_support.unlink(ABSTFN + "/k")
- safe_rmdir(ABSTFN + "/y")
- safe_rmdir(ABSTFN)
-
- def test_realpath_resolve_before_normalizing(self):
- # Bug #990669: Symbolic links should be resolved before we
- # normalize the path. E.g.: if we have directories 'a', 'k' and 'y'
- # in the following hierarchy:
- # a/k/y
- #
- # and a symbolic link 'link-y' pointing to 'y' in directory 'a',
- # then realpath("link-y/..") should return 'k', not 'a'.
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/k")
- os.mkdir(ABSTFN + "/k/y")
- os.symlink(ABSTFN + "/k/y", ABSTFN + "/link-y")
-
- # Absolute path.
- self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
- # Relative path.
- os.chdir(dirname(ABSTFN))
- self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."),
- ABSTFN + "/k")
- finally:
- os.chdir(old_path)
- test_support.unlink(ABSTFN + "/link-y")
- safe_rmdir(ABSTFN + "/k/y")
- safe_rmdir(ABSTFN + "/k")
- safe_rmdir(ABSTFN)
-
- def test_realpath_resolve_first(self):
- # Bug #1213894: The first component of the path, if not absolute,
- # must be resolved too.
-
- try:
- old_path = abspath('.')
- os.mkdir(ABSTFN)
- os.mkdir(ABSTFN + "/k")
- os.symlink(ABSTFN, ABSTFN + "link")
- os.chdir(dirname(ABSTFN))
-
- base = basename(ABSTFN)
- self.assertEqual(realpath(base + "link"), ABSTFN)
- self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
- finally:
- os.chdir(old_path)
- test_support.unlink(ABSTFN + "link")
- safe_rmdir(ABSTFN + "/k")
- safe_rmdir(ABSTFN)
+ self.assertEqual(posixpath.normpath(b""), b".")
+ self.assertEqual(posixpath.normpath(b"/"), b"/")
+ self.assertEqual(posixpath.normpath(b"//"), b"//")
+ self.assertEqual(posixpath.normpath(b"///"), b"/")
+ self.assertEqual(posixpath.normpath(b"///foo/.//bar//"), b"/foo/bar")
+ self.assertEqual(posixpath.normpath(b"///foo/.//bar//.//..//.//baz"),
+ b"/foo/baz")
+ self.assertEqual(posixpath.normpath(b"///..//./foo/.//bar"),
+ b"/foo/bar")
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_basic(self):
+ # Basic operation.
+ try:
+ os.symlink(ABSTFN+"1", ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
+ finally:
+ support.unlink(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_relative(self):
+ try:
+ os.symlink(posixpath.relpath(ABSTFN+"1"), ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN+"1")
+ finally:
+ support.unlink(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_symlink_loops(self):
+ # Bug #930024, return the path unchanged if we get into an infinite
+ # symlink loop.
+ try:
+ old_path = abspath('.')
+ os.symlink(ABSTFN, ABSTFN)
+ self.assertEqual(realpath(ABSTFN), ABSTFN)
+
+ os.symlink(ABSTFN+"1", ABSTFN+"2")
+ os.symlink(ABSTFN+"2", ABSTFN+"1")
+ self.assertEqual(realpath(ABSTFN+"1"), ABSTFN+"1")
+ self.assertEqual(realpath(ABSTFN+"2"), ABSTFN+"2")
+
+ # Test using relative path as well.
+ os.chdir(dirname(ABSTFN))
+ self.assertEqual(realpath(basename(ABSTFN)), ABSTFN)
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN)
+ support.unlink(ABSTFN+"1")
+ support.unlink(ABSTFN+"2")
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_parents(self):
+ # We also need to resolve any symlinks in the parents of a relative
+ # path passed to realpath. E.g.: current working directory is
+ # /usr/doc with 'doc' being a symlink to /usr/share/doc. We call
+ # realpath("a"). This should return /usr/share/doc/a/.
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/y")
+ os.symlink(ABSTFN + "/y", ABSTFN + "/k")
+
+ os.chdir(ABSTFN + "/k")
+ self.assertEqual(realpath("a"), ABSTFN + "/y/a")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "/k")
+ safe_rmdir(ABSTFN + "/y")
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_before_normalizing(self):
+ # Bug #990669: Symbolic links should be resolved before we
+ # normalize the path. E.g.: if we have directories 'a', 'k' and 'y'
+ # in the following hierarchy:
+ # a/k/y
+ #
+ # and a symbolic link 'link-y' pointing to 'y' in directory 'a',
+ # then realpath("link-y/..") should return 'k', not 'a'.
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/k")
+ os.mkdir(ABSTFN + "/k/y")
+ os.symlink(ABSTFN + "/k/y", ABSTFN + "/link-y")
+
+ # Absolute path.
+ self.assertEqual(realpath(ABSTFN + "/link-y/.."), ABSTFN + "/k")
+ # Relative path.
+ os.chdir(dirname(ABSTFN))
+ self.assertEqual(realpath(basename(ABSTFN) + "/link-y/.."),
+ ABSTFN + "/k")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "/link-y")
+ safe_rmdir(ABSTFN + "/k/y")
+ safe_rmdir(ABSTFN + "/k")
+ safe_rmdir(ABSTFN)
+
+ @unittest.skipUnless(hasattr(os, "symlink"),
+ "Missing symlink implementation")
+ @skip_if_ABSTFN_contains_backslash
+ def test_realpath_resolve_first(self):
+ # Bug #1213894: The first component of the path, if not absolute,
+ # must be resolved too.
+
+ try:
+ old_path = abspath('.')
+ os.mkdir(ABSTFN)
+ os.mkdir(ABSTFN + "/k")
+ os.symlink(ABSTFN, ABSTFN + "link")
+ os.chdir(dirname(ABSTFN))
+
+ base = basename(ABSTFN)
+ self.assertEqual(realpath(base + "link"), ABSTFN)
+ self.assertEqual(realpath(base + "link/k"), ABSTFN + "/k")
+ finally:
+ os.chdir(old_path)
+ support.unlink(ABSTFN + "link")
+ safe_rmdir(ABSTFN + "/k")
+ safe_rmdir(ABSTFN)
def test_relpath(self):
(real_getcwd, os.getcwd) = (os.getcwd, lambda: r"/home/user/bar")
@@ -322,7 +470,8 @@ class PosixPathTest(unittest.TestCase):
self.assertEqual(posixpath.relpath("a/b"), "a/b")
self.assertEqual(posixpath.relpath("../a/b"), "../a/b")
self.assertEqual(posixpath.relpath("a", "../b"), "../"+curdir+"/a")
- self.assertEqual(posixpath.relpath("a/b", "../c"), "../"+curdir+"/a/b")
+ self.assertEqual(posixpath.relpath("a/b", "../c"),
+ "../"+curdir+"/a/b")
self.assertEqual(posixpath.relpath("a", "b/c"), "../../a")
self.assertEqual(posixpath.relpath("a", "a"), ".")
self.assertEqual(posixpath.relpath("/foo/bar/bat", "/x/y/z"), '../../../foo/bar/bat')
@@ -337,6 +486,41 @@ class PosixPathTest(unittest.TestCase):
finally:
os.getcwd = real_getcwd
+ def test_relpath_bytes(self):
+ (real_getcwdb, os.getcwdb) = (os.getcwdb, lambda: br"/home/user/bar")
+ try:
+ curdir = os.path.split(os.getcwdb())[-1]
+ self.assertRaises(ValueError, posixpath.relpath, b"")
+ self.assertEqual(posixpath.relpath(b"a"), b"a")
+ self.assertEqual(posixpath.relpath(posixpath.abspath(b"a")), b"a")
+ self.assertEqual(posixpath.relpath(b"a/b"), b"a/b")
+ self.assertEqual(posixpath.relpath(b"../a/b"), b"../a/b")
+ self.assertEqual(posixpath.relpath(b"a", b"../b"),
+ b"../"+curdir+b"/a")
+ self.assertEqual(posixpath.relpath(b"a/b", b"../c"),
+ b"../"+curdir+b"/a/b")
+ self.assertEqual(posixpath.relpath(b"a", b"b/c"), b"../../a")
+ self.assertEqual(posixpath.relpath(b"a", b"a"), b".")
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/x/y/z"), b'../../../foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/foo/bar"), b'bat')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/"), b'foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/", b"/foo/bar/bat"), b'../../..')
+ self.assertEqual(posixpath.relpath(b"/foo/bar/bat", b"/x"), b'../foo/bar/bat')
+ self.assertEqual(posixpath.relpath(b"/x", b"/foo/bar/bat"), b'../../../x')
+ self.assertEqual(posixpath.relpath(b"/", b"/"), b'.')
+ self.assertEqual(posixpath.relpath(b"/a", b"/a"), b'.')
+ self.assertEqual(posixpath.relpath(b"/a/b", b"/a/b"), b'.')
+
+ self.assertRaises(TypeError, posixpath.relpath, b"bytes", "str")
+ self.assertRaises(TypeError, posixpath.relpath, "str", b"bytes")
+ finally:
+ os.getcwdb = real_getcwdb
+
+ def test_sameopenfile(self):
+ fname = support.TESTFN + "1"
+ with open(fname, "wb") as a, open(fname, "wb") as b:
+ self.assertTrue(posixpath.sameopenfile(a.fileno(), b.fileno()))
+
class PosixCommonTest(test_genericpath.CommonTest):
pathmodule = posixpath
@@ -344,7 +528,7 @@ class PosixCommonTest(test_genericpath.CommonTest):
def test_main():
- test_support.run_unittest(PosixPathTest, PosixCommonTest)
+ support.run_unittest(PosixPathTest, PosixCommonTest)
if __name__=="__main__":
diff --git a/Lib/test/test_pow.py b/Lib/test/test_pow.py
index 1ee67bc452f..20b10663a2e 100644
--- a/Lib/test/test_pow.py
+++ b/Lib/test/test_pow.py
@@ -1,4 +1,4 @@
-import test.test_support, unittest
+import test.support, unittest
class PowTest(unittest.TestCase):
@@ -14,18 +14,18 @@ class PowTest(unittest.TestCase):
self.assertEqual(pow(type(i), 3), i*i*i)
pow2 = 1
- for i in range(0,31):
+ for i in range(0, 31):
self.assertEqual(pow(2, i), pow2)
if i != 30 : pow2 = pow2*2
- for othertype in int, long:
- for i in range(-10, 0) + range(1, 10):
+ for othertype in (int,):
+ for i in list(range(-10, 0)) + list(range(1, 10)):
ii = type(i)
for j in range(1, 11):
jj = -othertype(j)
pow(ii, jj)
- for othertype in int, long, float:
+ for othertype in int, float:
for i in range(1, 100):
zero = type(0)
exp = -othertype(i/10.0)
@@ -42,7 +42,7 @@ class PowTest(unittest.TestCase):
asseq = self.assertAlmostEqual
elif type == int:
jl = 0
- elif type == long:
+ elif type == int:
jl, jh = 0, 15
for i in range(il, ih+1):
for j in range(jl, jh+1):
@@ -60,7 +60,7 @@ class PowTest(unittest.TestCase):
self.powtest(int)
def test_powlong(self):
- self.powtest(long)
+ self.powtest(int)
def test_powfloat(self):
self.powtest(float)
@@ -74,12 +74,12 @@ class PowTest(unittest.TestCase):
self.assertEqual(pow(-3,3) % -8, pow(-3,3,-8))
self.assertEqual(pow(5,2) % -8, pow(5,2,-8))
- self.assertEqual(pow(3L,3L) % 8, pow(3L,3L,8))
- self.assertEqual(pow(3L,3L) % -8, pow(3L,3L,-8))
- self.assertEqual(pow(3L,2) % -2, pow(3L,2,-2))
- self.assertEqual(pow(-3L,3L) % 8, pow(-3L,3L,8))
- self.assertEqual(pow(-3L,3L) % -8, pow(-3L,3L,-8))
- self.assertEqual(pow(5L,2) % -8, pow(5L,2,-8))
+ self.assertEqual(pow(3,3) % 8, pow(3,3,8))
+ self.assertEqual(pow(3,3) % -8, pow(3,3,-8))
+ self.assertEqual(pow(3,2) % -2, pow(3,2,-2))
+ self.assertEqual(pow(-3,3) % 8, pow(-3,3,8))
+ self.assertEqual(pow(-3,3) % -8, pow(-3,3,-8))
+ self.assertEqual(pow(5,2) % -8, pow(5,2,-8))
for i in range(-10, 11):
for j in range(0, 6):
@@ -91,8 +91,8 @@ class PowTest(unittest.TestCase):
)
if j >= 0 and k != 0:
self.assertEqual(
- pow(long(i),j) % k,
- pow(long(i),j,k)
+ pow(int(i),j) % k,
+ pow(int(i),j,k)
)
def test_bug643260(self):
@@ -123,7 +123,7 @@ class PowTest(unittest.TestCase):
eq(expected, 1.0) # else we didn't push fiveto to evenness
def test_main():
- test.test_support.run_unittest(PowTest)
+ test.support.run_unittest(PowTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pprint.py b/Lib/test/test_pprint.py
index e0137dfc59f..0c93d0e59b7 100644
--- a/Lib/test/test_pprint.py
+++ b/Lib/test/test_pprint.py
@@ -1,13 +1,10 @@
import pprint
-import test.test_support
+import test.support
import unittest
import test.test_set
-
-try:
- uni = unicode
-except NameError:
- def uni(x):
- return x
+import random
+import collections
+import itertools
# list, tuple and dict subclasses that do or don't overwrite __repr__
class list2(list):
@@ -31,17 +28,21 @@ class dict3(dict):
def __repr__(self):
return dict.__repr__(self)
+class Unorderable:
+ def __repr__(self):
+ return str(id(self))
+
class QueryTestCase(unittest.TestCase):
def setUp(self):
- self.a = range(100)
- self.b = range(200)
+ self.a = list(range(100))
+ self.b = list(range(200))
self.a[-12] = self.b
def test_basic(self):
# Verify .isrecursive() and .isreadable() w/o recursion
pp = pprint.PrettyPrinter()
- for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, uni("yaddayadda"),
+ for safe in (2, 2.0, 2j, "abc", [3], (2,2), {3: 3}, "yaddayadda",
self.a, self.b):
# module-level convenience functions
self.assertFalse(pprint.isrecursive(safe),
@@ -111,12 +112,12 @@ class QueryTestCase(unittest.TestCase):
# it sorted a dict display if and only if the display required
# multiple lines. For that reason, dicts with more than one element
# aren't tested here.
- for simple in (0, 0L, 0+0j, 0.0, "", uni(""),
+ for simple in (0, 0, 0+0j, 0.0, "", b"",
(), tuple2(), tuple3(),
[], list2(), list3(),
{}, dict2(), dict3(),
self.assertTrue, pprint,
- -6, -6L, -6-6j, -1.5, "x", uni("x"), (3,), [3], {3: 6},
+ -6, -6, -6-6j, -1.5, "x", b"x", (3,), [3], {3: 6},
(1,2), [3,4], {5: 6},
tuple2((1,2)), tuple3((1,2)), tuple3(range(100)),
[3,4], list2([3,4]), list3([3,4]), list3(range(100)),
@@ -196,6 +197,20 @@ class QueryTestCase(unittest.TestCase):
self.assertEqual(pprint.pformat({"xy\tab\n": (3,), 5: [[]], (): {}}),
r"{5: [[]], 'xy\tab\n': (3,), (): {}}")
+ def test_ordered_dict(self):
+ words = 'the quick brown fox jumped over a lazy dog'.split()
+ d = collections.OrderedDict(zip(words, itertools.count()))
+ self.assertEqual(pprint.pformat(d),
+"""\
+{'the': 0,
+ 'quick': 1,
+ 'brown': 2,
+ 'fox': 3,
+ 'jumped': 4,
+ 'over': 5,
+ 'a': 6,
+ 'lazy': 7,
+ 'dog': 8}""")
def test_subclassing(self):
o = {'names with spaces': 'should be presented using repr()',
'others.should.not.be': 'like.this'}
@@ -204,193 +219,215 @@ class QueryTestCase(unittest.TestCase):
others.should.not.be: like.this}"""
self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
+ @test.support.cpython_only
def test_set_reprs(self):
+ # This test creates a complex arrangement of frozensets and
+ # compares the pretty-printed repr against a string hard-coded in
+ # the test. The hard-coded repr depends on the sort order of
+ # frozensets.
+ #
+ # However, as the docs point out: "Since sets only define
+ # partial ordering (subset relationships), the output of the
+ # list.sort() method is undefined for lists of sets."
+ #
+ # In a nutshell, the test assumes frozenset({0}) will always
+ # sort before frozenset({1}), but:
+ #
+ # >>> frozenset({0}) < frozenset({1})
+ # False
+ # >>> frozenset({1}) < frozenset({0})
+ # False
+ #
+ # Consequently, this test is fragile and
+ # implementation-dependent. Small changes to Python's sort
+ # algorithm cause the test to fail when it should pass.
+
self.assertEqual(pprint.pformat(set()), 'set()')
- self.assertEqual(pprint.pformat(set(range(3))), 'set([0, 1, 2])')
+ self.assertEqual(pprint.pformat(set(range(3))), '{0, 1, 2}')
self.assertEqual(pprint.pformat(frozenset()), 'frozenset()')
- self.assertEqual(pprint.pformat(frozenset(range(3))), 'frozenset([0, 1, 2])')
+ self.assertEqual(pprint.pformat(frozenset(range(3))), 'frozenset({0, 1, 2})')
cube_repr_tgt = """\
-{frozenset([]): frozenset([frozenset([2]), frozenset([0]), frozenset([1])]),
- frozenset([0]): frozenset([frozenset(),
- frozenset([0, 2]),
- frozenset([0, 1])]),
- frozenset([1]): frozenset([frozenset(),
- frozenset([1, 2]),
- frozenset([0, 1])]),
- frozenset([2]): frozenset([frozenset(),
- frozenset([1, 2]),
- frozenset([0, 2])]),
- frozenset([1, 2]): frozenset([frozenset([2]),
- frozenset([1]),
- frozenset([0, 1, 2])]),
- frozenset([0, 2]): frozenset([frozenset([2]),
- frozenset([0]),
- frozenset([0, 1, 2])]),
- frozenset([0, 1]): frozenset([frozenset([0]),
- frozenset([1]),
- frozenset([0, 1, 2])]),
- frozenset([0, 1, 2]): frozenset([frozenset([1, 2]),
- frozenset([0, 2]),
- frozenset([0, 1])])}"""
+{frozenset(): frozenset({frozenset({2}), frozenset({0}), frozenset({1})}),
+ frozenset({0}): frozenset({frozenset(),
+ frozenset({0, 2}),
+ frozenset({0, 1})}),
+ frozenset({1}): frozenset({frozenset(),
+ frozenset({1, 2}),
+ frozenset({0, 1})}),
+ frozenset({2}): frozenset({frozenset(),
+ frozenset({1, 2}),
+ frozenset({0, 2})}),
+ frozenset({1, 2}): frozenset({frozenset({2}),
+ frozenset({1}),
+ frozenset({0, 1, 2})}),
+ frozenset({0, 2}): frozenset({frozenset({2}),
+ frozenset({0}),
+ frozenset({0, 1, 2})}),
+ frozenset({0, 1}): frozenset({frozenset({0}),
+ frozenset({1}),
+ frozenset({0, 1, 2})}),
+ frozenset({0, 1, 2}): frozenset({frozenset({1, 2}),
+ frozenset({0, 2}),
+ frozenset({0, 1})})}"""
cube = test.test_set.cube(3)
self.assertEqual(pprint.pformat(cube), cube_repr_tgt)
cubo_repr_tgt = """\
-{frozenset([frozenset([0, 2]), frozenset([0])]): frozenset([frozenset([frozenset([0,
- 2]),
- frozenset([0,
+{frozenset({frozenset({0, 2}), frozenset({0})}): frozenset({frozenset({frozenset({0,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 1])]),
- frozenset([frozenset(),
- frozenset([0])]),
- frozenset([frozenset([2]),
- frozenset([0,
- 2])])]),
- frozenset([frozenset([0, 1]), frozenset([1])]): frozenset([frozenset([frozenset([0,
- 1]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 1})}),
+ frozenset({frozenset(),
+ frozenset({0})}),
+ frozenset({frozenset({2}),
+ frozenset({0,
+ 2})})}),
+ frozenset({frozenset({0, 1}), frozenset({1})}): frozenset({frozenset({frozenset({0,
+ 1}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 1])]),
- frozenset([frozenset([1]),
- frozenset([1,
- 2])]),
- frozenset([frozenset(),
- frozenset([1])])]),
- frozenset([frozenset([1, 2]), frozenset([1])]): frozenset([frozenset([frozenset([1,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 1})}),
+ frozenset({frozenset({1}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({1})})}),
+ frozenset({frozenset({1, 2}), frozenset({1})}): frozenset({frozenset({frozenset({1,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([2]),
- frozenset([1,
- 2])]),
- frozenset([frozenset(),
- frozenset([1])]),
- frozenset([frozenset([1]),
- frozenset([0,
- 1])])]),
- frozenset([frozenset([1, 2]), frozenset([2])]): frozenset([frozenset([frozenset([1,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({2}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({1})}),
+ frozenset({frozenset({1}),
+ frozenset({0,
+ 1})})}),
+ frozenset({frozenset({1, 2}), frozenset({2})}): frozenset({frozenset({frozenset({1,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([1]),
- frozenset([1,
- 2])]),
- frozenset([frozenset([2]),
- frozenset([0,
- 2])]),
- frozenset([frozenset(),
- frozenset([2])])]),
- frozenset([frozenset([]), frozenset([0])]): frozenset([frozenset([frozenset([0]),
- frozenset([0,
- 1])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 2])]),
- frozenset([frozenset(),
- frozenset([1])]),
- frozenset([frozenset(),
- frozenset([2])])]),
- frozenset([frozenset([]), frozenset([1])]): frozenset([frozenset([frozenset(),
- frozenset([0])]),
- frozenset([frozenset([1]),
- frozenset([1,
- 2])]),
- frozenset([frozenset(),
- frozenset([2])]),
- frozenset([frozenset([1]),
- frozenset([0,
- 1])])]),
- frozenset([frozenset([2]), frozenset([])]): frozenset([frozenset([frozenset([2]),
- frozenset([1,
- 2])]),
- frozenset([frozenset(),
- frozenset([0])]),
- frozenset([frozenset(),
- frozenset([1])]),
- frozenset([frozenset([2]),
- frozenset([0,
- 2])])]),
- frozenset([frozenset([0, 1, 2]), frozenset([0, 1])]): frozenset([frozenset([frozenset([1,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({1}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset({2}),
+ frozenset({0,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({2})})}),
+ frozenset({frozenset(), frozenset({0})}): frozenset({frozenset({frozenset({0}),
+ frozenset({0,
+ 1})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({1})}),
+ frozenset({frozenset(),
+ frozenset({2})})}),
+ frozenset({frozenset(), frozenset({1})}): frozenset({frozenset({frozenset(),
+ frozenset({0})}),
+ frozenset({frozenset({1}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({2})}),
+ frozenset({frozenset({1}),
+ frozenset({0,
+ 1})})}),
+ frozenset({frozenset({2}), frozenset()}): frozenset({frozenset({frozenset({2}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({0})}),
+ frozenset({frozenset(),
+ frozenset({1})}),
+ frozenset({frozenset({2}),
+ frozenset({0,
+ 2})})}),
+ frozenset({frozenset({0, 1, 2}), frozenset({0, 1})}): frozenset({frozenset({frozenset({1,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 1])]),
- frozenset([frozenset([1]),
- frozenset([0,
- 1])])]),
- frozenset([frozenset([0]), frozenset([0, 1])]): frozenset([frozenset([frozenset(),
- frozenset([0])]),
- frozenset([frozenset([0,
- 1]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 1})}),
+ frozenset({frozenset({1}),
+ frozenset({0,
+ 1})})}),
+ frozenset({frozenset({0}), frozenset({0, 1})}): frozenset({frozenset({frozenset(),
+ frozenset({0})}),
+ frozenset({frozenset({0,
+ 1}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 2])]),
- frozenset([frozenset([1]),
- frozenset([0,
- 1])])]),
- frozenset([frozenset([2]), frozenset([0, 2])]): frozenset([frozenset([frozenset([0,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 2})}),
+ frozenset({frozenset({1}),
+ frozenset({0,
+ 1})})}),
+ frozenset({frozenset({2}), frozenset({0, 2})}): frozenset({frozenset({frozenset({0,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([2]),
- frozenset([1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 2])]),
- frozenset([frozenset(),
- frozenset([2])])]),
- frozenset([frozenset([0, 1, 2]), frozenset([0, 2])]): frozenset([frozenset([frozenset([1,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({2}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 2})}),
+ frozenset({frozenset(),
+ frozenset({2})})}),
+ frozenset({frozenset({0, 1, 2}), frozenset({0, 2})}): frozenset({frozenset({frozenset({1,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0,
- 1]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0,
+ 1}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0]),
- frozenset([0,
- 2])]),
- frozenset([frozenset([2]),
- frozenset([0,
- 2])])]),
- frozenset([frozenset([1, 2]), frozenset([0, 1, 2])]): frozenset([frozenset([frozenset([0,
- 2]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0}),
+ frozenset({0,
+ 2})}),
+ frozenset({frozenset({2}),
+ frozenset({0,
+ 2})})}),
+ frozenset({frozenset({1, 2}), frozenset({0, 1, 2})}): frozenset({frozenset({frozenset({0,
+ 2}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([0,
- 1]),
- frozenset([0,
+ 2})}),
+ frozenset({frozenset({0,
+ 1}),
+ frozenset({0,
1,
- 2])]),
- frozenset([frozenset([2]),
- frozenset([1,
- 2])]),
- frozenset([frozenset([1]),
- frozenset([1,
- 2])])])}"""
+ 2})}),
+ frozenset({frozenset({2}),
+ frozenset({1,
+ 2})}),
+ frozenset({frozenset({1}),
+ frozenset({1,
+ 2})})})}"""
cubo = test.test_set.linegraph(cube)
self.assertEqual(pprint.pformat(cubo), cubo_repr_tgt)
@@ -410,6 +447,30 @@ class QueryTestCase(unittest.TestCase):
self.assertEqual(pprint.pformat(nested_dict, depth=1), lv1_dict)
self.assertEqual(pprint.pformat(nested_list, depth=1), lv1_list)
+ def test_sort_unorderable_values(self):
+ # Issue 3976: sorted pprints fail for unorderable values.
+ n = 20
+ keys = [Unorderable() for i in range(n)]
+ random.shuffle(keys)
+ skeys = sorted(keys, key=id)
+ clean = lambda s: s.replace(' ', '').replace('\n','')
+
+ self.assertEqual(clean(pprint.pformat(set(keys))),
+ '{' + ','.join(map(repr, skeys)) + '}')
+ self.assertEqual(clean(pprint.pformat(frozenset(keys))),
+ 'frozenset({' + ','.join(map(repr, skeys)) + '})')
+ self.assertEqual(clean(pprint.pformat(dict.fromkeys(keys))),
+ '{' + ','.join('%r:None' % k for k in skeys) + '}')
+
+ # Issue 10017: TypeError on user-defined types as dict keys.
+ self.assertEqual(pprint.pformat({Unorderable: 0, 1: 0}),
+ '{1: 0, ' + repr(Unorderable) +': 0}')
+
+ # Issue 14998: TypeError on tuples with NoneTypes as dict keys.
+ keys = [(1,), (None,)]
+ self.assertEqual(pprint.pformat(dict.fromkeys(keys, 0)),
+ '{%r: 0, %r: 0}' % tuple(sorted(keys, key=id)))
+
class DottedPrettyPrinter(pprint.PrettyPrinter):
@@ -425,7 +486,7 @@ class DottedPrettyPrinter(pprint.PrettyPrinter):
def test_main():
- test.test_support.run_unittest(QueryTestCase)
+ test.support.run_unittest(QueryTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py
index b7263470e2d..8d37bbc4d61 100644
--- a/Lib/test/test_print.py
+++ b/Lib/test/test_print.py
@@ -6,9 +6,14 @@
from __future__ import print_function
import unittest
-from test import test_support
+from test import support
-from StringIO import StringIO
+try:
+ # 3.x
+ from io import StringIO
+except ImportError:
+ # 2.x
+ from StringIO import StringIO
NotDefined = object()
@@ -56,7 +61,7 @@ class TestPrint(unittest.TestCase):
end is not NotDefined,
file is not NotDefined)]
- with test_support.captured_stdout() as t:
+ with support.captured_stdout() as t:
fn(args, sep, end, file)
self.assertEqual(t.getvalue(), expected)
@@ -96,46 +101,18 @@ class TestPrint(unittest.TestCase):
x('*\n', (ClassWith__str__('*'),))
x('abc 1\n', (ClassWith__str__('abc'), 1))
- # 2.x unicode tests
- x(u'1 2\n', ('1', u'2'))
- x(u'u\1234\n', (u'u\1234',))
- x(u' abc 1\n', (' ', ClassWith__str__(u'abc'), 1))
+# # 2.x unicode tests
+# x(u'1 2\n', ('1', u'2'))
+# x(u'u\1234\n', (u'u\1234',))
+# x(u' abc 1\n', (' ', ClassWith__str__(u'abc'), 1))
# errors
self.assertRaises(TypeError, print, '', sep=3)
self.assertRaises(TypeError, print, '', end=3)
self.assertRaises(AttributeError, print, '', file='')
- def test_mixed_args(self):
- # If an unicode arg is passed, sep and end should be unicode, too.
- class Recorder(object):
-
- def __init__(self, must_be_unicode):
- self.buf = []
- self.force_unicode = must_be_unicode
-
- def write(self, what):
- if self.force_unicode and not isinstance(what, unicode):
- raise AssertionError("{0!r} is not unicode".format(what))
- self.buf.append(what)
-
- buf = Recorder(True)
- print(u'hi', file=buf)
- self.assertEqual(u''.join(buf.buf), 'hi\n')
- del buf.buf[:]
- print(u'hi', u'nothing', file=buf)
- self.assertEqual(u''.join(buf.buf), 'hi nothing\n')
- buf = Recorder(False)
- print('hi', 'bye', end=u'\n', file=buf)
- self.assertIsInstance(buf.buf[1], unicode)
- self.assertIsInstance(buf.buf[3], unicode)
- del buf.buf[:]
- print(sep=u'x', file=buf)
- self.assertIsInstance(buf.buf[-1], unicode)
-
-
def test_main():
- test_support.run_unittest(TestPrint)
+ support.run_unittest(TestPrint)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py
index aa93d399e84..cd7ec58e231 100644
--- a/Lib/test/test_profile.py
+++ b/Lib/test/test_profile.py
@@ -3,8 +3,9 @@
import sys
import pstats
import unittest
-from StringIO import StringIO
-from test.test_support import run_unittest
+from difflib import unified_diff
+from io import StringIO
+from test.support import run_unittest
import profile
from test.profilee import testfunc, timer
@@ -14,8 +15,10 @@ class ProfileTest(unittest.TestCase):
profilerclass = profile.Profile
methodnames = ['print_stats', 'print_callers', 'print_callees']
- expected_output = {}
- expected_list_sort_output = ':0(sort)'
+ expected_max_output = ':0(max)'
+
+ def get_expected_output(self):
+ return _ProfileOutput
@classmethod
def do_profiling(cls):
@@ -29,25 +32,37 @@ class ProfileTest(unittest.TestCase):
stats = pstats.Stats(prof, stream=s)
stats.strip_dirs().sort_stats("stdname")
getattr(stats, methodname)()
- results.append(s.getvalue())
+ output = s.getvalue().splitlines()
+ mod_name = testfunc.__module__.rsplit('.', 1)[1]
+ # Only compare against stats originating from the test file.
+ # Prevents outside code (e.g., the io module) from causing
+ # unexpected output.
+ output = [line.rstrip() for line in output if mod_name in line]
+ results.append('\n'.join(output))
return results
def test_cprofile(self):
results = self.do_profiling()
+ expected = self.get_expected_output()
self.assertEqual(results[0], 1000)
for i, method in enumerate(self.methodnames):
- self.assertEqual(results[i+1], self.expected_output[method],
- "Stats.%s output for %s doesn't fit expectation!" %
- (method, self.profilerclass.__name__))
+ if results[i+1] != expected[method]:
+ print("Stats.%s output for %s doesn't fit expectation!" %
+ (method, self.profilerclass.__name__))
+ print('\n'.join(unified_diff(
+ results[i+1].split('\n'),
+ expected[method].split('\n'))))
def test_calling_conventions(self):
# Issue #5330: profile and cProfile wouldn't report C functions called
# with keyword arguments. We test all calling conventions.
stmts = [
- "[].sort()",
- "[].sort(reverse=True)",
- "[].sort(*(None, None, True))",
- "[].sort(**dict(reverse=True))",
+ "max([0])",
+ "max([0], key=int)",
+ "max([0], **dict(key=int))",
+ "max(*([0],))",
+ "max(*([0],), key=int)",
+ "max(*([0],), **dict(key=int))",
]
for stmt in stmts:
s = StringIO()
@@ -56,27 +71,28 @@ class ProfileTest(unittest.TestCase):
stats = pstats.Stats(prof, stream=s)
stats.print_stats()
res = s.getvalue()
- self.assertIn(self.expected_list_sort_output, res,
- "Profiling {0!r} didn't report list.sort:\n{1}".format(stmt, res))
+ self.assertIn(self.expected_max_output, res,
+ "Profiling {0!r} didn't report max:\n{1}".format(stmt, res))
def regenerate_expected_output(filename, cls):
filename = filename.rstrip('co')
- print 'Regenerating %s...' % filename
+ print('Regenerating %s...' % filename)
results = cls.do_profiling()
newfile = []
with open(filename, 'r') as f:
for line in f:
newfile.append(line)
- if line[:6] == '#--cut':
+ if line.startswith('#--cut'):
break
with open(filename, 'w') as f:
f.writelines(newfile)
+ f.write("_ProfileOutput = {}\n")
for i, method in enumerate(cls.methodnames):
- f.write('%s.expected_output[%r] = """\\\n%s"""\n' % (
- cls.__name__, method, results[i+1]))
+ f.write('_ProfileOutput[%r] = """\\\n%s"""\n' % (
+ method, results[i+1]))
f.write('\nif __name__ == "__main__":\n main()\n')
@@ -92,95 +108,53 @@ def main():
# Don't remove this comment. Everything below it is auto-generated.
#--cut--------------------------------------------------------------------------
-ProfileTest.expected_output['print_stats'] = """\
- 127 function calls (107 primitive calls) in 999.749 seconds
-
- Ordered by: standard name
-
- ncalls tottime percall cumtime percall filename:lineno(function)
- 4 -0.004 -0.001 -0.004 -0.001 :0(append)
- 4 -0.004 -0.001 -0.004 -0.001 :0(exc_info)
- 12 -0.024 -0.002 11.964 0.997 :0(hasattr)
- 8 -0.008 -0.001 -0.008 -0.001 :0(range)
- 1 0.000 0.000 0.000 0.000 :0(setprofile)
- 1 -0.002 -0.002 999.751 999.751 <string>:1(<module>)
- 0 0.000 0.000 profile:0(profiler)
- 1 -0.002 -0.002 999.749 999.749 profile:0(testfunc())
+_ProfileOutput = {}
+_ProfileOutput['print_stats'] = """\
28 27.972 0.999 27.972 0.999 profilee.py:110(__getattr__)
- 1 269.996 269.996 999.753 999.753 profilee.py:25(testfunc)
+ 1 269.996 269.996 999.769 999.769 profilee.py:25(testfunc)
23/3 149.937 6.519 169.917 56.639 profilee.py:35(factorial)
20 19.980 0.999 19.980 0.999 profilee.py:48(mul)
- 2 39.986 19.993 599.814 299.907 profilee.py:55(helper)
+ 2 39.986 19.993 599.830 299.915 profilee.py:55(helper)
4 115.984 28.996 119.964 29.991 profilee.py:73(helper1)
- 2 -0.006 -0.003 139.942 69.971 profilee.py:84(helper2_indirect)
- 8 311.976 38.997 399.896 49.987 profilee.py:88(helper2)
- 8 63.968 7.996 79.944 9.993 profilee.py:98(subhelper)
-
-
-"""
-ProfileTest.expected_output['print_callers'] = """\
- Ordered by: standard name
-
-Function was called by...
+ 2 -0.006 -0.003 139.946 69.973 profilee.py:84(helper2_indirect)
+ 8 311.976 38.997 399.912 49.989 profilee.py:88(helper2)
+ 8 63.976 7.997 79.960 9.995 profilee.py:98(subhelper)"""
+_ProfileOutput['print_callers'] = """\
:0(append) <- profilee.py:73(helper1)(4) 119.964
:0(exc_info) <- profilee.py:73(helper1)(4) 119.964
:0(hasattr) <- profilee.py:73(helper1)(4) 119.964
- profilee.py:88(helper2)(8) 399.896
-:0(range) <- profilee.py:98(subhelper)(8) 79.944
-:0(setprofile) <- profile:0(testfunc())(1) 999.749
-<string>:1(<module>) <- profile:0(testfunc())(1) 999.749
-profile:0(profiler) <-
-profile:0(testfunc()) <- profile:0(profiler)(1) 0.000
+ profilee.py:88(helper2)(8) 399.912
profilee.py:110(__getattr__) <- :0(hasattr)(12) 11.964
- profilee.py:98(subhelper)(16) 79.944
-profilee.py:25(testfunc) <- <string>:1(<module>)(1) 999.751
-profilee.py:35(factorial) <- profilee.py:25(testfunc)(1) 999.753
+ profilee.py:98(subhelper)(16) 79.960
+profilee.py:25(testfunc) <- <string>:1(<module>)(1) 999.767
+profilee.py:35(factorial) <- profilee.py:25(testfunc)(1) 999.769
profilee.py:35(factorial)(20) 169.917
- profilee.py:84(helper2_indirect)(2) 139.942
+ profilee.py:84(helper2_indirect)(2) 139.946
profilee.py:48(mul) <- profilee.py:35(factorial)(20) 169.917
-profilee.py:55(helper) <- profilee.py:25(testfunc)(2) 999.753
-profilee.py:73(helper1) <- profilee.py:55(helper)(4) 599.814
-profilee.py:84(helper2_indirect) <- profilee.py:55(helper)(2) 599.814
-profilee.py:88(helper2) <- profilee.py:55(helper)(6) 599.814
- profilee.py:84(helper2_indirect)(2) 139.942
-profilee.py:98(subhelper) <- profilee.py:88(helper2)(8) 399.896
-
-
-"""
-ProfileTest.expected_output['print_callees'] = """\
- Ordered by: standard name
-
-Function called...
-:0(append) ->
-:0(exc_info) ->
+profilee.py:55(helper) <- profilee.py:25(testfunc)(2) 999.769
+profilee.py:73(helper1) <- profilee.py:55(helper)(4) 599.830
+profilee.py:84(helper2_indirect) <- profilee.py:55(helper)(2) 599.830
+profilee.py:88(helper2) <- profilee.py:55(helper)(6) 599.830
+ profilee.py:84(helper2_indirect)(2) 139.946
+profilee.py:98(subhelper) <- profilee.py:88(helper2)(8) 399.912"""
+_ProfileOutput['print_callees'] = """\
:0(hasattr) -> profilee.py:110(__getattr__)(12) 27.972
-:0(range) ->
-:0(setprofile) ->
-<string>:1(<module>) -> profilee.py:25(testfunc)(1) 999.753
-profile:0(profiler) -> profile:0(testfunc())(1) 999.749
-profile:0(testfunc()) -> :0(setprofile)(1) 0.000
- <string>:1(<module>)(1) 999.751
+<string>:1(<module>) -> profilee.py:25(testfunc)(1) 999.769
profilee.py:110(__getattr__) ->
profilee.py:25(testfunc) -> profilee.py:35(factorial)(1) 169.917
- profilee.py:55(helper)(2) 599.814
+ profilee.py:55(helper)(2) 599.830
profilee.py:35(factorial) -> profilee.py:35(factorial)(20) 169.917
profilee.py:48(mul)(20) 19.980
profilee.py:48(mul) ->
profilee.py:55(helper) -> profilee.py:73(helper1)(4) 119.964
- profilee.py:84(helper2_indirect)(2) 139.942
- profilee.py:88(helper2)(6) 399.896
+ profilee.py:84(helper2_indirect)(2) 139.946
+ profilee.py:88(helper2)(6) 399.912
profilee.py:73(helper1) -> :0(append)(4) -0.004
- :0(exc_info)(4) -0.004
- :0(hasattr)(4) 11.964
profilee.py:84(helper2_indirect) -> profilee.py:35(factorial)(2) 169.917
- profilee.py:88(helper2)(2) 399.896
+ profilee.py:88(helper2)(2) 399.912
profilee.py:88(helper2) -> :0(hasattr)(8) 11.964
- profilee.py:98(subhelper)(8) 79.944
-profilee.py:98(subhelper) -> :0(range)(8) -0.008
- profilee.py:110(__getattr__)(16) 27.972
-
-
-"""
+ profilee.py:98(subhelper)(8) 79.960
+profilee.py:98(subhelper) -> profilee.py:110(__getattr__)(16) 27.972"""
if __name__ == "__main__":
main()
diff --git a/Lib/test/test_property.py b/Lib/test/test_property.py
index e5fc1745a0f..cc6a872179c 100644
--- a/Lib/test/test_property.py
+++ b/Lib/test/test_property.py
@@ -3,7 +3,7 @@
import sys
import unittest
-from test.test_support import run_unittest
+from test.support import run_unittest
class PropertyBase(Exception):
pass
diff --git a/Lib/test/test_pstats.py b/Lib/test/test_pstats.py
index 6ad9418deb2..9ebeebbfee6 100644
--- a/Lib/test/test_pstats.py
+++ b/Lib/test/test_pstats.py
@@ -1,5 +1,6 @@
import unittest
-from test import test_support
+from test import support
+from io import StringIO
import pstats
@@ -8,8 +9,8 @@ class AddCallersTestCase(unittest.TestCase):
"""Tests for pstats.add_callers helper."""
def test_combine_results(self):
- """pstats.add_callers should combine the call results of both target
- and source by adding the call time. See issue1269."""
+ # pstats.add_callers should combine the call results of both target
+ # and source by adding the call time. See issue1269.
# new format: used by the cProfile module
target = {"a": (1, 2, 3, 4)}
source = {"a": (1, 2, 3, 4), "b": (5, 6, 7, 8)}
@@ -22,9 +23,21 @@ class AddCallersTestCase(unittest.TestCase):
self.assertEqual(new_callers, {'a': 2, 'b': 5})
+class StatsTestCase(unittest.TestCase):
+ def setUp(self):
+ stats_file = support.findfile('pstats.pck')
+ self.stats = pstats.Stats(stats_file)
+
+ def test_add(self):
+ stream = StringIO()
+ stats = pstats.Stats(stream=stream)
+ stats.add(self.stats, self.stats)
+
+
def test_main():
- test_support.run_unittest(
- AddCallersTestCase
+ support.run_unittest(
+ AddCallersTestCase,
+ StatsTestCase,
)
diff --git a/Lib/test/test_pty.py b/Lib/test/test_pty.py
index bec38c45456..4d471d534ee 100644
--- a/Lib/test/test_pty.py
+++ b/Lib/test/test_pty.py
@@ -1,4 +1,4 @@
-from test.test_support import verbose, run_unittest, import_module
+from test.support import verbose, run_unittest, import_module, reap_children
#Skip these tests if either fcntl or termios is not available
fcntl = import_module('fcntl')
@@ -13,12 +13,12 @@ import signal
import socket
import unittest
-TEST_STRING_1 = "I wish to buy a fish license.\n"
-TEST_STRING_2 = "For my pet fish, Eric.\n"
+TEST_STRING_1 = b"I wish to buy a fish license.\n"
+TEST_STRING_2 = b"For my pet fish, Eric.\n"
if verbose:
def debug(msg):
- print msg
+ print(msg)
else:
def debug(msg):
pass
@@ -36,12 +36,12 @@ def normalize_output(data):
# from someone more knowledgable.
# OSF/1 (Tru64) apparently turns \n into \r\r\n.
- if data.endswith('\r\r\n'):
- return data.replace('\r\r\n', '\n')
+ if data.endswith(b'\r\r\n'):
+ return data.replace(b'\r\r\n', b'\n')
# IRIX apparently turns \n into \r\n.
- if data.endswith('\r\n'):
- return data.replace('\r\n', '\n')
+ if data.endswith(b'\r\n'):
+ return data.replace(b'\r\n', b'\n')
return data
@@ -75,7 +75,7 @@ class PtyTest(unittest.TestCase):
debug("Got slave_fd '%d'" % slave_fd)
except OSError:
# " An optional feature could not be imported " ... ?
- raise unittest.SkipTest, "Pseudo-terminals (seemingly) not functional."
+ raise unittest.SkipTest("Pseudo-terminals (seemingly) not functional.")
self.assertTrue(os.isatty(slave_fd), 'slave_fd is not a tty')
@@ -88,8 +88,8 @@ class PtyTest(unittest.TestCase):
fcntl.fcntl(master_fd, fcntl.F_SETFL, orig_flags | os.O_NONBLOCK)
try:
s1 = os.read(master_fd, 1024)
- self.assertEqual('', s1)
- except OSError, e:
+ self.assertEqual(b'', s1)
+ except OSError as e:
if e.errno != errno.EAGAIN:
raise
# Restore the original flags.
@@ -98,14 +98,14 @@ class PtyTest(unittest.TestCase):
debug("Writing to slave_fd")
os.write(slave_fd, TEST_STRING_1)
s1 = os.read(master_fd, 1024)
- self.assertEqual('I wish to buy a fish license.\n',
+ self.assertEqual(b'I wish to buy a fish license.\n',
normalize_output(s1))
debug("Writing chunked output")
os.write(slave_fd, TEST_STRING_2[:5])
os.write(slave_fd, TEST_STRING_2[5:])
s2 = os.read(master_fd, 1024)
- self.assertEqual('For my pet fish, Eric.\n', normalize_output(s2))
+ self.assertEqual(b'For my pet fish, Eric.\n', normalize_output(s2))
os.close(slave_fd)
os.close(master_fd)
@@ -163,7 +163,8 @@ class PtyTest(unittest.TestCase):
break
if not data:
break
- sys.stdout.write(data.replace('\r\n', '\n'))
+ sys.stdout.write(str(data.replace(b'\r\n', b'\n'),
+ encoding='ascii'))
##line = os.read(master_fd, 80)
##lines = line.replace('\r\n', '\n').split('\n')
@@ -214,7 +215,7 @@ class SmallPtyTests(unittest.TestCase):
for fd in self.fds:
try:
os.close(fd)
- except:
+ except OSError:
pass
def _pipe(self):
@@ -234,8 +235,9 @@ class SmallPtyTests(unittest.TestCase):
mock_stdin_fd, write_to_stdin_fd = self._pipe()
pty.STDIN_FILENO = mock_stdin_fd
socketpair = socket.socketpair()
+ for s in socketpair:
+ self.addCleanup(s.close)
masters = [s.fileno() for s in socketpair]
- self.fds.extend(masters)
# Feed data. Smaller than PIPEBUF. These writes will not block.
os.write(masters[1], b'from master')
@@ -263,8 +265,9 @@ class SmallPtyTests(unittest.TestCase):
mock_stdin_fd, write_to_stdin_fd = self._pipe()
pty.STDIN_FILENO = mock_stdin_fd
socketpair = socket.socketpair()
+ for s in socketpair:
+ self.addCleanup(s.close)
masters = [s.fileno() for s in socketpair]
- self.fds.extend(masters)
os.close(masters[1])
socketpair[1].close()
@@ -283,7 +286,10 @@ class SmallPtyTests(unittest.TestCase):
def test_main(verbose=None):
- run_unittest(SmallPtyTests, PtyTest)
+ try:
+ run_unittest(SmallPtyTests, PtyTest)
+ finally:
+ reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pwd.py b/Lib/test/test_pwd.py
index 67e11b6859d..ae1c8feca6a 100644
--- a/Lib/test/test_pwd.py
+++ b/Lib/test/test_pwd.py
@@ -1,8 +1,8 @@
import sys
import unittest
-from test import test_support
+from test import support
-pwd = test_support.import_module('pwd')
+pwd = support.import_module('pwd')
class PwdTest(unittest.TestCase):
@@ -14,19 +14,19 @@ class PwdTest(unittest.TestCase):
for e in entries:
self.assertEqual(len(e), 7)
self.assertEqual(e[0], e.pw_name)
- self.assertIsInstance(e.pw_name, basestring)
+ self.assertIsInstance(e.pw_name, str)
self.assertEqual(e[1], e.pw_passwd)
- self.assertIsInstance(e.pw_passwd, basestring)
+ self.assertIsInstance(e.pw_passwd, str)
self.assertEqual(e[2], e.pw_uid)
self.assertIsInstance(e.pw_uid, int)
self.assertEqual(e[3], e.pw_gid)
self.assertIsInstance(e.pw_gid, int)
self.assertEqual(e[4], e.pw_gecos)
- self.assertIsInstance(e.pw_gecos, basestring)
+ self.assertIsInstance(e.pw_gecos, str)
self.assertEqual(e[5], e.pw_dir)
- self.assertIsInstance(e.pw_dir, basestring)
+ self.assertIsInstance(e.pw_dir, str)
self.assertEqual(e[6], e.pw_shell)
- self.assertIsInstance(e.pw_shell, basestring)
+ self.assertIsInstance(e.pw_shell, str)
# The following won't work, because of duplicate entries
# for one uid
@@ -59,12 +59,12 @@ class PwdTest(unittest.TestCase):
bynames[n] = u
byuids[u] = n
- allnames = bynames.keys()
+ allnames = list(bynames.keys())
namei = 0
fakename = allnames[namei]
while fakename in bynames:
chars = list(fakename)
- for i in xrange(len(chars)):
+ for i in range(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
break
@@ -89,12 +89,12 @@ class PwdTest(unittest.TestCase):
# loop, say), pwd.getpwuid() might still be able to find data for that
# uid. Using sys.maxint may provoke the same problems, but hopefully
# it will be a more repeatable failure.
- fakeuid = sys.maxint
+ fakeuid = sys.maxsize
self.assertNotIn(fakeuid, byuids)
self.assertRaises(KeyError, pwd.getpwuid, fakeuid)
def test_main():
- test_support.run_unittest(PwdTest)
+ support.run_unittest(PwdTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_py3kwarn.py b/Lib/test/test_py3kwarn.py
deleted file mode 100644
index 2afd8a1593b..00000000000
--- a/Lib/test/test_py3kwarn.py
+++ /dev/null
@@ -1,426 +0,0 @@
-import unittest
-import sys
-from test.test_support import check_py3k_warnings, CleanImport, run_unittest
-import warnings
-
-if not sys.py3kwarning:
- raise unittest.SkipTest('%s must be run with the -3 flag' % __name__)
-
-try:
- from test.test_support import __warningregistry__ as _registry
-except ImportError:
- def check_deprecated_module(module_name):
- return False
-else:
- past_warnings = _registry.keys()
- del _registry
- def check_deprecated_module(module_name):
- """Lookup the past warnings for module already loaded using
- test_support.import_module(..., deprecated=True)
- """
- return any(module_name in msg and ' removed' in msg
- and issubclass(cls, DeprecationWarning)
- and (' module' in msg or ' package' in msg)
- for (msg, cls, line) in past_warnings)
-
-def reset_module_registry(module):
- try:
- registry = module.__warningregistry__
- except AttributeError:
- pass
- else:
- registry.clear()
-
-class TestPy3KWarnings(unittest.TestCase):
-
- def assertWarning(self, _, warning, expected_message):
- self.assertEqual(str(warning.message), expected_message)
-
- def assertNoWarning(self, _, recorder):
- self.assertEqual(len(recorder.warnings), 0)
-
- def test_backquote(self):
- expected = 'backquote not supported in 3.x; use repr()'
- with check_py3k_warnings((expected, SyntaxWarning)):
- exec "`2`" in {}
-
- def test_paren_arg_names(self):
- expected = 'parenthesized argument names are invalid in 3.x'
- def check(s):
- with check_py3k_warnings((expected, SyntaxWarning)):
- exec s in {}
- check("def f((x)): pass")
- check("def f((((x))), (y)): pass")
- check("def f((x), (((y))), m=32): pass")
- # Something like def f((a, (b))): pass will raise the tuple
- # unpacking warning.
-
- def test_forbidden_names(self):
- # So we don't screw up our globals
- def safe_exec(expr):
- def f(**kwargs): pass
- exec expr in {'f' : f}
-
- tests = [("True", "assignment to True or False is forbidden in 3.x"),
- ("False", "assignment to True or False is forbidden in 3.x"),
- ("nonlocal", "nonlocal is a keyword in 3.x")]
- with check_py3k_warnings(('', SyntaxWarning)) as w:
- for keyword, expected in tests:
- safe_exec("{0} = False".format(keyword))
- self.assertWarning(None, w, expected)
- w.reset()
- try:
- safe_exec("obj.{0} = True".format(keyword))
- except NameError:
- pass
- self.assertWarning(None, w, expected)
- w.reset()
- safe_exec("def {0}(): pass".format(keyword))
- self.assertWarning(None, w, expected)
- w.reset()
- safe_exec("class {0}: pass".format(keyword))
- self.assertWarning(None, w, expected)
- w.reset()
- safe_exec("def f({0}=43): pass".format(keyword))
- self.assertWarning(None, w, expected)
- w.reset()
-
-
- def test_type_inequality_comparisons(self):
- expected = 'type inequality comparisons not supported in 3.x'
- with check_py3k_warnings() as w:
- self.assertWarning(int < str, w, expected)
- w.reset()
- self.assertWarning(type < object, w, expected)
-
- def test_object_inequality_comparisons(self):
- expected = 'comparing unequal types not supported in 3.x'
- with check_py3k_warnings() as w:
- self.assertWarning(str < [], w, expected)
- w.reset()
- self.assertWarning(object() < (1, 2), w, expected)
-
- def test_dict_inequality_comparisons(self):
- expected = 'dict inequality comparisons not supported in 3.x'
- with check_py3k_warnings() as w:
- self.assertWarning({} < {2:3}, w, expected)
- w.reset()
- self.assertWarning({} <= {}, w, expected)
- w.reset()
- self.assertWarning({} > {2:3}, w, expected)
- w.reset()
- self.assertWarning({2:3} >= {}, w, expected)
-
- def test_cell_inequality_comparisons(self):
- expected = 'cell comparisons not supported in 3.x'
- def f(x):
- def g():
- return x
- return g
- cell0, = f(0).func_closure
- cell1, = f(1).func_closure
- with check_py3k_warnings() as w:
- self.assertWarning(cell0 == cell1, w, expected)
- w.reset()
- self.assertWarning(cell0 < cell1, w, expected)
-
- def test_code_inequality_comparisons(self):
- expected = 'code inequality comparisons not supported in 3.x'
- def f(x):
- pass
- def g(x):
- pass
- with check_py3k_warnings() as w:
- self.assertWarning(f.func_code < g.func_code, w, expected)
- w.reset()
- self.assertWarning(f.func_code <= g.func_code, w, expected)
- w.reset()
- self.assertWarning(f.func_code >= g.func_code, w, expected)
- w.reset()
- self.assertWarning(f.func_code > g.func_code, w, expected)
-
- def test_builtin_function_or_method_comparisons(self):
- expected = ('builtin_function_or_method '
- 'order comparisons not supported in 3.x')
- func = eval
- meth = {}.get
- with check_py3k_warnings() as w:
- self.assertWarning(func < meth, w, expected)
- w.reset()
- self.assertWarning(func > meth, w, expected)
- w.reset()
- self.assertWarning(meth <= func, w, expected)
- w.reset()
- self.assertWarning(meth >= func, w, expected)
- w.reset()
- self.assertNoWarning(meth == func, w)
- self.assertNoWarning(meth != func, w)
- lam = lambda x: x
- self.assertNoWarning(lam == func, w)
- self.assertNoWarning(lam != func, w)
-
- def test_frame_attributes(self):
- template = "%s has been removed in 3.x"
- f = sys._getframe(0)
- for attr in ("f_exc_traceback", "f_exc_value", "f_exc_type"):
- expected = template % attr
- with check_py3k_warnings() as w:
- self.assertWarning(getattr(f, attr), w, expected)
- w.reset()
- self.assertWarning(setattr(f, attr, None), w, expected)
-
- def test_sort_cmp_arg(self):
- expected = "the cmp argument is not supported in 3.x"
- lst = range(5)
- cmp = lambda x,y: -1
-
- with check_py3k_warnings() as w:
- self.assertWarning(lst.sort(cmp=cmp), w, expected)
- w.reset()
- self.assertWarning(sorted(lst, cmp=cmp), w, expected)
- w.reset()
- self.assertWarning(lst.sort(cmp), w, expected)
- w.reset()
- self.assertWarning(sorted(lst, cmp), w, expected)
-
- def test_sys_exc_clear(self):
- expected = 'sys.exc_clear() not supported in 3.x; use except clauses'
- with check_py3k_warnings() as w:
- self.assertWarning(sys.exc_clear(), w, expected)
-
- def test_methods_members(self):
- expected = '__members__ and __methods__ not supported in 3.x'
- class C:
- __methods__ = ['a']
- __members__ = ['b']
- c = C()
- with check_py3k_warnings() as w:
- self.assertWarning(dir(c), w, expected)
-
- def test_softspace(self):
- expected = 'file.softspace not supported in 3.x'
- with file(__file__) as f:
- with check_py3k_warnings() as w:
- self.assertWarning(f.softspace, w, expected)
- def set():
- f.softspace = 0
- with check_py3k_warnings() as w:
- self.assertWarning(set(), w, expected)
-
- def test_slice_methods(self):
- class Spam(object):
- def __getslice__(self, i, j): pass
- def __setslice__(self, i, j, what): pass
- def __delslice__(self, i, j): pass
- class Egg:
- def __getslice__(self, i, h): pass
- def __setslice__(self, i, j, what): pass
- def __delslice__(self, i, j): pass
-
- expected = "in 3.x, __{0}slice__ has been removed; use __{0}item__"
-
- for obj in (Spam(), Egg()):
- with check_py3k_warnings() as w:
- self.assertWarning(obj[1:2], w, expected.format('get'))
- w.reset()
- del obj[3:4]
- self.assertWarning(None, w, expected.format('del'))
- w.reset()
- obj[4:5] = "eggs"
- self.assertWarning(None, w, expected.format('set'))
-
- def test_tuple_parameter_unpacking(self):
- expected = "tuple parameter unpacking has been removed in 3.x"
- with check_py3k_warnings((expected, SyntaxWarning)):
- exec "def f((a, b)): pass"
-
- def test_buffer(self):
- expected = 'buffer() not supported in 3.x'
- with check_py3k_warnings() as w:
- self.assertWarning(buffer('a'), w, expected)
-
- def test_file_xreadlines(self):
- expected = ("f.xreadlines() not supported in 3.x, "
- "try 'for line in f' instead")
- with file(__file__) as f:
- with check_py3k_warnings() as w:
- self.assertWarning(f.xreadlines(), w, expected)
-
- def test_hash_inheritance(self):
- with check_py3k_warnings() as w:
- # With object as the base class
- class WarnOnlyCmp(object):
- def __cmp__(self, other): pass
- self.assertEqual(len(w.warnings), 0)
- w.reset()
- class WarnOnlyEq(object):
- def __eq__(self, other): pass
- self.assertEqual(len(w.warnings), 1)
- self.assertWarning(None, w,
- "Overriding __eq__ blocks inheritance of __hash__ in 3.x")
- w.reset()
- class WarnCmpAndEq(object):
- def __cmp__(self, other): pass
- def __eq__(self, other): pass
- self.assertEqual(len(w.warnings), 1)
- self.assertWarning(None, w,
- "Overriding __eq__ blocks inheritance of __hash__ in 3.x")
- w.reset()
- class NoWarningOnlyHash(object):
- def __hash__(self): pass
- self.assertEqual(len(w.warnings), 0)
- # With an intermediate class in the heirarchy
- class DefinesAllThree(object):
- def __cmp__(self, other): pass
- def __eq__(self, other): pass
- def __hash__(self): pass
- class WarnOnlyCmp(DefinesAllThree):
- def __cmp__(self, other): pass
- self.assertEqual(len(w.warnings), 0)
- w.reset()
- class WarnOnlyEq(DefinesAllThree):
- def __eq__(self, other): pass
- self.assertEqual(len(w.warnings), 1)
- self.assertWarning(None, w,
- "Overriding __eq__ blocks inheritance of __hash__ in 3.x")
- w.reset()
- class WarnCmpAndEq(DefinesAllThree):
- def __cmp__(self, other): pass
- def __eq__(self, other): pass
- self.assertEqual(len(w.warnings), 1)
- self.assertWarning(None, w,
- "Overriding __eq__ blocks inheritance of __hash__ in 3.x")
- w.reset()
- class NoWarningOnlyHash(DefinesAllThree):
- def __hash__(self): pass
- self.assertEqual(len(w.warnings), 0)
-
- def test_operator(self):
- from operator import isCallable, sequenceIncludes
-
- callable_warn = ("operator.isCallable() is not supported in 3.x. "
- "Use hasattr(obj, '__call__').")
- seq_warn = ("operator.sequenceIncludes() is not supported "
- "in 3.x. Use operator.contains().")
- with check_py3k_warnings() as w:
- self.assertWarning(isCallable(self), w, callable_warn)
- w.reset()
- self.assertWarning(sequenceIncludes(range(3), 2), w, seq_warn)
-
-
-class TestStdlibRemovals(unittest.TestCase):
-
- # test.testall not tested as it executes all unit tests as an
- # import side-effect.
- all_platforms = ('audiodev', 'imputil', 'mutex', 'user', 'new', 'rexec',
- 'Bastion', 'compiler', 'dircache', 'mimetools',
- 'fpformat', 'ihooks', 'mhlib', 'statvfs', 'htmllib',
- 'sgmllib', 'rfc822', 'sunaudio')
- inclusive_platforms = {'irix' : ('pure', 'AL', 'al', 'CD', 'cd', 'cddb',
- 'cdplayer', 'CL', 'cl', 'DEVICE', 'GL',
- 'gl', 'ERRNO', 'FILE', 'FL', 'flp', 'fl',
- 'fm', 'GET', 'GLWS', 'imgfile', 'IN',
- 'IOCTL', 'jpeg', 'panel', 'panelparser',
- 'readcd', 'SV', 'torgb', 'WAIT'),
- 'darwin' : ('autoGIL', 'Carbon', 'OSATerminology',
- 'icglue', 'Nav',
- # MacOS should (and does) give a Py3kWarning, but one of the
- # earlier tests already imports the MacOS extension which causes
- # this test to fail. Disabling the test for 'MacOS' avoids this
- # spurious test failure.
- #'MacOS',
- 'aepack',
- 'aetools', 'aetypes', 'applesingle',
- 'appletrawmain', 'appletrunner',
- 'argvemulator', 'bgenlocations',
- 'EasyDialogs', 'macerrors', 'macostools',
- 'findertools', 'FrameWork', 'ic',
- 'gensuitemodule', 'icopen', 'macresource',
- 'MiniAEFrame', 'pimp', 'PixMapWrapper',
- 'terminalcommand', 'videoreader',
- '_builtinSuites', 'CodeWarrior',
- 'Explorer', 'Finder', 'Netscape',
- 'StdSuites', 'SystemEvents', 'Terminal',
- 'cfmfile', 'bundlebuilder', 'buildtools',
- 'ColorPicker', 'Audio_mac'),
- 'sunos5' : ('sunaudiodev', 'SUNAUDIODEV'),
- }
- optional_modules = ('bsddb185', 'Canvas', 'dl', 'linuxaudiodev', 'imageop',
- 'sv', 'bsddb', 'dbhash')
-
- def check_removal(self, module_name, optional=False):
- """Make sure the specified module, when imported, raises a
- DeprecationWarning and specifies itself in the message."""
- with CleanImport(module_name), warnings.catch_warnings():
- warnings.filterwarnings("error", ".+ (module|package) .+ removed",
- DeprecationWarning, __name__)
- warnings.filterwarnings("error", ".+ removed .+ (module|package)",
- DeprecationWarning, __name__)
- try:
- __import__(module_name, level=0)
- except DeprecationWarning as exc:
- self.assertIn(module_name, exc.args[0],
- "%s warning didn't contain module name"
- % module_name)
- except ImportError:
- if not optional:
- self.fail("Non-optional module {0} raised an "
- "ImportError.".format(module_name))
- else:
- # For extension modules, check the __warningregistry__.
- # They won't rerun their init code even with CleanImport.
- if not check_deprecated_module(module_name):
- self.fail("DeprecationWarning not raised for {0}"
- .format(module_name))
-
- def test_platform_independent_removals(self):
- # Make sure that the modules that are available on all platforms raise
- # the proper DeprecationWarning.
- for module_name in self.all_platforms:
- self.check_removal(module_name)
-
- def test_platform_specific_removals(self):
- # Test the removal of platform-specific modules.
- for module_name in self.inclusive_platforms.get(sys.platform, []):
- self.check_removal(module_name, optional=True)
-
- def test_optional_module_removals(self):
- # Test the removal of modules that may or may not be built.
- for module_name in self.optional_modules:
- self.check_removal(module_name, optional=True)
-
- def test_os_path_walk(self):
- msg = "In 3.x, os.path.walk is removed in favor of os.walk."
- def dumbo(where, names, args): pass
- for path_mod in ("ntpath", "macpath", "os2emxpath", "posixpath"):
- mod = __import__(path_mod)
- reset_module_registry(mod)
- with check_py3k_warnings() as w:
- mod.walk("crashers", dumbo, None)
- self.assertEqual(str(w.message), msg)
-
- def test_reduce_move(self):
- from operator import add
- # reduce tests may have already triggered this warning
- reset_module_registry(unittest.case)
- with warnings.catch_warnings():
- warnings.filterwarnings("error", "reduce")
- self.assertRaises(DeprecationWarning, reduce, add, range(10))
-
- def test_mutablestring_removal(self):
- # UserString.MutableString has been removed in 3.0.
- import UserString
- # UserString tests may have already triggered this warning
- reset_module_registry(UserString)
- with warnings.catch_warnings():
- warnings.filterwarnings("error", ".*MutableString",
- DeprecationWarning)
- self.assertRaises(DeprecationWarning, UserString.MutableString)
-
-
-def test_main():
- run_unittest(TestPy3KWarnings,
- TestStdlibRemovals)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py
index b919da2221a..f3c1a6a44b6 100644
--- a/Lib/test/test_py_compile.py
+++ b/Lib/test/test_py_compile.py
@@ -5,7 +5,7 @@ import shutil
import tempfile
import unittest
-from test import test_support
+from test import support, script_helper
class PyCompileTests(unittest.TestCase):
@@ -13,6 +13,7 @@ class PyCompileTests(unittest.TestCase):
self.directory = tempfile.mkdtemp()
self.source_path = os.path.join(self.directory, '_test.py')
self.pyc_path = self.source_path + 'c'
+ self.cache_path = imp.cache_from_source(self.source_path)
self.cwd_drive = os.path.splitdrive(os.getcwd())[0]
# In these tests we compute relative paths. When using Windows, the
# current working directory path and the 'self.source_path' might be
@@ -21,7 +22,6 @@ class PyCompileTests(unittest.TestCase):
drive = os.path.splitdrive(self.source_path)[0]
if drive:
os.chdir(drive)
-
with open(self.source_path, 'w') as file:
file.write('x = 123\n')
@@ -33,6 +33,11 @@ class PyCompileTests(unittest.TestCase):
def test_absolute_path(self):
py_compile.compile(self.source_path, self.pyc_path)
self.assertTrue(os.path.exists(self.pyc_path))
+ self.assertFalse(os.path.exists(self.cache_path))
+
+ def test_cache_path(self):
+ py_compile.compile(self.source_path)
+ self.assertTrue(os.path.exists(self.cache_path))
def test_cwd(self):
cwd = os.getcwd()
@@ -41,14 +46,16 @@ class PyCompileTests(unittest.TestCase):
os.path.basename(self.pyc_path))
os.chdir(cwd)
self.assertTrue(os.path.exists(self.pyc_path))
+ self.assertFalse(os.path.exists(self.cache_path))
def test_relative_path(self):
py_compile.compile(os.path.relpath(self.source_path),
os.path.relpath(self.pyc_path))
self.assertTrue(os.path.exists(self.pyc_path))
+ self.assertFalse(os.path.exists(self.cache_path))
def test_main():
- test_support.run_unittest(PyCompileTests)
+ support.run_unittest(PyCompileTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_pyclbr.py b/Lib/test/test_pyclbr.py
index 7bdc555cd27..e83989e2d8e 100644
--- a/Lib/test/test_pyclbr.py
+++ b/Lib/test/test_pyclbr.py
@@ -2,21 +2,15 @@
Test cases for pyclbr.py
Nick Mathewson
'''
-from test.test_support import run_unittest, import_module
+from test.support import run_unittest
import sys
-from types import ClassType, FunctionType, MethodType, BuiltinFunctionType
+from types import FunctionType, MethodType, BuiltinFunctionType
import pyclbr
from unittest import TestCase
StaticMethodType = type(staticmethod(lambda: None))
ClassMethodType = type(classmethod(lambda c: None))
-# Silence Py3k warning
-import_module('commands', deprecated=True)
-
-# This next line triggers an error on old versions of pyclbr.
-from commands import getstatus
-
# Here we test the python class browser code.
#
# The main function in this suite, 'testModule', compares the output
@@ -30,13 +24,13 @@ class PyclbrTest(TestCase):
''' succeed iff {l1} - {ignore} == {l2} - {ignore} '''
missing = (set(l1) ^ set(l2)) - set(ignore)
if missing:
- print >>sys.stderr, "l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore)
+ print("l1=%r\nl2=%r\nignore=%r" % (l1, l2, ignore), file=sys.stderr)
self.fail("%r missing" % missing.pop())
def assertHasattr(self, obj, attr, ignore):
''' succeed iff hasattr(obj,attr) or attr in ignore. '''
if attr in ignore: return
- if not hasattr(obj, attr): print "???", attr
+ if not hasattr(obj, attr): print("???", attr)
self.assertTrue(hasattr(obj, attr),
'expected hasattr(%r, %r)' % (obj, attr))
@@ -45,7 +39,7 @@ class PyclbrTest(TestCase):
''' succeed iff key in obj or key in ignore. '''
if key in ignore: return
if key not in obj:
- print >>sys.stderr, "***", key
+ print("***",key, file=sys.stderr)
self.assertIn(key, obj)
def assertEqualsOrIgnored(self, a, b, ignore):
@@ -59,6 +53,8 @@ class PyclbrTest(TestCase):
ignore are ignored. If no module is provided, the appropriate
module is loaded with __import__.'''
+ ignore = set(ignore) | set(['object'])
+
if module is None:
# Import it.
# ('<silly>' is to work around an API silliness in __import__)
@@ -68,23 +64,17 @@ class PyclbrTest(TestCase):
def ismethod(oclass, obj, name):
classdict = oclass.__dict__
- if isinstance(obj, FunctionType):
- if not isinstance(classdict[name], StaticMethodType):
- return False
- else:
- if not isinstance(obj, MethodType):
+ if isinstance(obj, MethodType):
+ # could be a classmethod
+ if (not isinstance(classdict[name], ClassMethodType) or
+ obj.__self__ is not oclass):
return False
- if obj.im_self is not None:
- if (not isinstance(classdict[name], ClassMethodType) or
- obj.im_self is not oclass):
- return False
- else:
- if not isinstance(classdict[name], FunctionType):
- return False
+ elif not isinstance(obj, FunctionType):
+ return False
objname = obj.__name__
if objname.startswith("__") and not objname.endswith("__"):
- objname = "_%s%s" % (obj.im_class.__name__, objname)
+ objname = "_%s%s" % (oclass.__name__, objname)
return objname == name
# Make sure the toplevel functions and classes are the same.
@@ -99,7 +89,7 @@ class PyclbrTest(TestCase):
continue # skip functions that came from somewhere else
self.assertEqual(py_item.__module__, value.module)
else:
- self.assertIsInstance(py_item, (ClassType, type))
+ self.assertIsInstance(py_item, type)
if py_item.__module__ != moduleName:
continue # skip classes that came from somewhere else
@@ -110,7 +100,7 @@ class PyclbrTest(TestCase):
try:
self.assertListEq(real_bases, pyclbr_bases, ignore)
except:
- print >>sys.stderr, "class=%s" % py_item
+ print("class=%s" % py_item, file=sys.stderr)
raise
actualMethods = []
@@ -132,35 +122,34 @@ class PyclbrTest(TestCase):
ignore)
# can't check file or lineno
except:
- print >>sys.stderr, "class=%s" % py_item
+ print("class=%s" % py_item, file=sys.stderr)
raise
# Now check for missing stuff.
def defined_in(item, module):
- if isinstance(item, ClassType):
+ if isinstance(item, type):
return item.__module__ == module.__name__
if isinstance(item, FunctionType):
- return item.func_globals is module.__dict__
+ return item.__globals__ is module.__dict__
return False
for name in dir(module):
item = getattr(module, name)
- if isinstance(item, (ClassType, FunctionType)):
+ if isinstance(item, (type, FunctionType)):
if defined_in(item, module):
self.assertHaskey(dict, name, ignore)
def test_easy(self):
self.checkModule('pyclbr')
- self.checkModule('doctest', ignore=("DocTestCase",))
- # Silence Py3k warning
- rfc822 = import_module('rfc822', deprecated=True)
- self.checkModule('rfc822', rfc822)
- self.checkModule('difflib')
+ self.checkModule('ast')
+ self.checkModule('doctest', ignore=("TestResults", "_SpoofOut",
+ "DocTestCase"))
+ self.checkModule('difflib', ignore=("Match",))
def test_decorators(self):
# XXX: See comment in pyclbr_input.py for a test that would fail
# if it were not commented out.
#
- self.checkModule('test.pyclbr_input')
+ self.checkModule('test.pyclbr_input', ignore=['om'])
def test_others(self):
cm = self.checkModule
@@ -168,18 +157,8 @@ class PyclbrTest(TestCase):
# These were once about the 10 longest modules
cm('random', ignore=('Random',)) # from _random import Random as CoreGenerator
cm('cgi', ignore=('log',)) # set with = in module
- cm('urllib', ignore=('_CFNumberToInt32',
- '_CStringFromCFString',
- '_CFSetup',
- 'getproxies_registry',
- 'proxy_bypass_registry',
- 'proxy_bypass_macosx_sysconf',
- 'open_https',
- 'getproxies_macosx_sysconf',
- 'getproxies_internetconfig',)) # not on all platforms
cm('pickle')
cm('aifc', ignore=('openfp',)) # set with = in module
- cm('Cookie')
cm('sre_parse', ignore=('dump',)) # from sre_constants import *
cm('pdb')
cm('pydoc')
diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py
index d95e7069ce1..c5a8e983568 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -1,43 +1,62 @@
import os
import sys
+import builtins
import difflib
-import __builtin__
-import re
-import pydoc
import inspect
+import pydoc
import keyword
+import re
+import string
+import test.support
+import time
import unittest
import xml.etree
-import test.test_support
+import textwrap
+from io import StringIO
from collections import namedtuple
from test.script_helper import assert_python_ok
-from test.test_support import (
- TESTFN, rmtree, reap_children, captured_stdout)
-
+from test.support import (
+ TESTFN, rmtree,
+ reap_children, reap_threads, captured_output, captured_stdout, unlink
+)
from test import pydoc_mod
-expected_text_pattern = \
-"""
+try:
+ import threading
+except ImportError:
+ threading = None
+
+# Just in case sys.modules["test"] has the optional attribute __loader__.
+if hasattr(pydoc_mod, "__loader__"):
+ del pydoc_mod.__loader__
+
+expected_text_pattern = """
NAME
test.pydoc_mod - This is a test module for test_pydoc
-
-FILE
- %s
%s
CLASSES
- __builtin__.object
+ builtins.object
+ A
B
- A
\x20\x20\x20\x20
- class A
+ class A(builtins.object)
| Hello and goodbye
|\x20\x20
| Methods defined here:
|\x20\x20
| __init__()
| Wow, I have no function!
+ |\x20\x20
+ | ----------------------------------------------------------------------
+ | Data descriptors defined here:
+ |\x20\x20
+ | __dict__
+ | dictionary for instance variables (if defined)
+ |\x20\x20
+ | __weakref__
+ | list of weak references to the object (if defined)
\x20\x20\x20\x20
- class B(__builtin__.object)
+ class B(builtins.object)
| Data descriptors defined here:
|\x20\x20
| __dict__
@@ -61,9 +80,7 @@ FUNCTIONS
nodoc_func()
DATA
- __author__ = 'Benjamin Peterson'
- __credits__ = 'Nobody'
- __version__ = '1.2.3.4'
+ __xyz__ = 'X, Y and Z'
VERSION
1.2.3.4
@@ -73,10 +90,12 @@ AUTHOR
CREDITS
Nobody
+
+FILE
+ %s
""".strip()
-expected_html_pattern = \
-"""
+expected_html_pattern = """
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
@@ -92,19 +111,19 @@ expected_html_pattern = \
\x20\x20\x20\x20
<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%"><dl>
-<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
+<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
</font></dt><dd>
<dl>
-<dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#B">B</a>
-</font></dt></dl>
-</dd>
<dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#A">A</a>
+</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#B">B</a>
</font></dt></dl>
+</dd>
+</dl>
<p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
-<font color="#000000" face="helvetica, arial"><a name="A">class <strong>A</strong></a></font></td></tr>
+<font color="#000000" face="helvetica, arial"><a name="A">class <strong>A</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
\x20\x20\x20\x20
<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
<td colspan=2><tt>Hello&nbsp;and&nbsp;goodbye<br>&nbsp;</tt></td></tr>
@@ -112,11 +131,19 @@ expected_html_pattern = \
<td width="100%%">Methods defined here:<br>
<dl><dt><a name="A-__init__"><strong>__init__</strong></a>()</dt><dd><tt>Wow,&nbsp;I&nbsp;have&nbsp;no&nbsp;function!</tt></dd></dl>
+<hr>
+Data descriptors defined here:<br>
+<dl><dt><strong>__dict__</strong></dt>
+<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
+</dl>
+<dl><dt><strong>__weakref__</strong></dt>
+<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
+</dl>
</td></tr></table> <p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#ffc8d8">
<td colspan=3 valign=bottom>&nbsp;<br>
-<font color="#000000" face="helvetica, arial"><a name="B">class <strong>B</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
+<font color="#000000" face="helvetica, arial"><a name="B">class <strong>B</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
\x20\x20\x20\x20
<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Data descriptors defined here:<br>
@@ -149,9 +176,7 @@ war</tt></dd></dl>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
\x20\x20\x20\x20
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
-<td width="100%%"><strong>__author__</strong> = 'Benjamin Peterson'<br>
-<strong>__credits__</strong> = 'Nobody'<br>
-<strong>__version__</strong> = '1.2.3.4'</td></tr></table><p>
+<td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'</td></tr></table><p>
<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#7799ee">
<td colspan=3 valign=bottom>&nbsp;<br>
@@ -166,14 +191,14 @@ war</tt></dd></dl>
\x20\x20\x20\x20
<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%%">Nobody</td></tr></table>
-""".strip()
+""".strip() # ' <- emacs turd
# output pattern for missing module
missing_pattern = "no Python documentation found for '%s'"
# output pattern for module with bad imports
-badimport_pattern = "problem in %s - <type 'exceptions.ImportError'>: No module named %s"
+badimport_pattern = "problem in %s - ImportError: No module named %s"
def run_pydoc(module_name, *args, **env):
"""
@@ -203,21 +228,29 @@ def get_pydoc_text(module):
output = doc.docmodule(module)
- # cleanup the extra text formatting that pydoc preforms
+ # clean up the extra text formatting that pydoc performs
patt = re.compile('\b.')
output = patt.sub('', output)
return output.strip(), loc
def print_diffs(text1, text2):
"Prints unified diffs for two texts"
+ # XXX now obsolete, use unittest built-in support
lines1 = text1.splitlines(True)
lines2 = text2.splitlines(True)
diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected',
tofile='got')
- print '\n' + ''.join(diffs)
+ print('\n' + ''.join(diffs))
+
+def get_html_title(text):
+ # Bit of hack, but good enough for test purposes
+ header, _, _ = text.partition("</head>")
+ _, _, title = header.partition("<title>")
+ title, _, _ = title.partition("</title>")
+ return title
-class PyDocDocTest(unittest.TestCase):
+class PydocDocTest(unittest.TestCase):
@unittest.skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
@@ -239,7 +272,7 @@ class PyDocDocTest(unittest.TestCase):
def test_text_doc(self):
result, doc_loc = get_pydoc_text(pydoc_mod)
expected_text = expected_text_pattern % \
- (inspect.getabsfile(pydoc_mod), doc_loc)
+ (doc_loc, inspect.getabsfile(pydoc_mod))
if result != expected_text:
print_diffs(expected_text, result)
self.fail("outputs are not equal, see diff above")
@@ -262,18 +295,16 @@ class PyDocDocTest(unittest.TestCase):
def test_not_here(self):
missing_module = "test.i_am_not_here"
- result = run_pydoc(missing_module)
+ result = str(run_pydoc(missing_module), 'ascii')
expected = missing_pattern % missing_module
self.assertEqual(expected, result,
"documentation for missing module found")
def test_input_strip(self):
missing_module = " test.i_am_not_here "
- result = run_pydoc(missing_module)
+ result = str(run_pydoc(missing_module), 'ascii')
expected = missing_pattern % missing_module.strip()
- self.assertEqual(expected, result,
- "white space was not stripped from module name "
- "or other error output mismatch")
+ self.assertEqual(expected, result)
def test_stripid(self):
# test with strings, other implementations might have different repr()
@@ -288,6 +319,61 @@ class PyDocDocTest(unittest.TestCase):
self.assertEqual(stripid("<type 'exceptions.Exception'>"),
"<type 'exceptions.Exception'>")
+ @unittest.skipIf(sys.flags.optimize >= 2,
+ 'Docstrings are omitted with -O2 and above')
+ def test_help_output_redirect(self):
+ # issue 940286, if output is set in Helper, then all output from
+ # Helper.help should be redirected
+ old_pattern = expected_text_pattern
+ getpager_old = pydoc.getpager
+ getpager_new = lambda: (lambda x: x)
+ self.maxDiff = None
+
+ buf = StringIO()
+ helper = pydoc.Helper(output=buf)
+ unused, doc_loc = get_pydoc_text(pydoc_mod)
+ module = "test.pydoc_mod"
+ help_header = """
+ Help on module test.pydoc_mod in test:
+
+ """.lstrip()
+ help_header = textwrap.dedent(help_header)
+ expected_help_pattern = help_header + expected_text_pattern
+
+ pydoc.getpager = getpager_new
+ try:
+ with captured_output('stdout') as output, \
+ captured_output('stderr') as err:
+ helper.help(module)
+ result = buf.getvalue().strip()
+ expected_text = expected_help_pattern % \
+ (doc_loc, inspect.getabsfile(pydoc_mod))
+ self.assertEqual('', output.getvalue())
+ self.assertEqual('', err.getvalue())
+ self.assertEqual(expected_text, result)
+ finally:
+ pydoc.getpager = getpager_old
+
+ def test_namedtuple_public_underscore(self):
+ NT = namedtuple('NT', ['abc', 'def'], rename=True)
+ with captured_stdout() as help_io:
+ help(NT)
+ helptext = help_io.getvalue()
+ self.assertIn('_1', helptext)
+ self.assertIn('_replace', helptext)
+ self.assertIn('_asdict', helptext)
+
+ def test_synopsis(self):
+ self.addCleanup(unlink, TESTFN)
+ for encoding in ('ISO-8859-1', 'UTF-8'):
+ with open(TESTFN, 'w', encoding=encoding) as script:
+ if encoding != 'UTF-8':
+ print('#coding: {}'.format(encoding), file=script)
+ print('"""line 1: h\xe9', file=script)
+ print('line 2: hi"""', file=script)
+ synopsis = pydoc.synopsis(TESTFN, {})
+ self.assertEqual(synopsis, 'line 1: h\xe9')
+
class PydocImportTest(unittest.TestCase):
@@ -313,7 +399,7 @@ class PydocImportTest(unittest.TestCase):
for importstring, expectedinmsg in testpairs:
with open(sourcefn, 'w') as f:
f.write("import {}\n".format(importstring))
- result = run_pydoc(modname, PYTHONPATH=TESTFN)
+ result = run_pydoc(modname, PYTHONPATH=TESTFN).decode("ascii")
expected = badimport_pattern % (modname, expectedinmsg)
self.assertEqual(expected, result)
@@ -325,7 +411,7 @@ class PydocImportTest(unittest.TestCase):
with open(badsyntax, 'w') as f:
f.write("invalid python syntax = $1\n")
result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
- self.assertEqual('', result)
+ self.assertEqual(b'', result)
def test_apropos_with_unreadable_dir(self):
# Issue 7367 - pydoc -k failed when unreadable dir on path
@@ -335,7 +421,7 @@ class PydocImportTest(unittest.TestCase):
# Note, on Windows the directory appears to be still
# readable so this is not really testing the issue there
result = run_pydoc('zqwykjv', '-k', PYTHONPATH=TESTFN)
- self.assertEqual('', result)
+ self.assertEqual(b'', result)
class TestDescriptions(unittest.TestCase):
@@ -346,16 +432,8 @@ class TestDescriptions(unittest.TestCase):
doc = pydoc.render_doc(pydocfodder)
self.assertIn("pydocfodder", doc)
- def test_classic_class(self):
- class C: "Classic class"
- c = C()
- self.assertEqual(pydoc.describe(C), 'class C')
- self.assertEqual(pydoc.describe(c), 'instance of C')
- expected = 'instance of C in module %s' % __name__
- self.assertIn(expected, pydoc.render_doc(c))
-
def test_class(self):
- class C(object): "New-style class"
+ class C: "New-style class"
c = C()
self.assertEqual(pydoc.describe(C), 'class C')
@@ -363,24 +441,9 @@ class TestDescriptions(unittest.TestCase):
expected = 'C in module %s object' % __name__
self.assertIn(expected, pydoc.render_doc(c))
- def test_namedtuple_public_underscore(self):
- NT = namedtuple('NT', ['abc', 'def'], rename=True)
- with captured_stdout() as help_io:
- help(NT)
- helptext = help_io.getvalue()
- self.assertIn('_1', helptext)
- self.assertIn('_replace', helptext)
- self.assertIn('_asdict', helptext)
-
-
-class TestHelper(unittest.TestCase):
- def test_keywords(self):
- self.assertEqual(sorted(pydoc.Helper.keywords),
- sorted(keyword.kwlist))
-
def test_builtin(self):
- for name in ('str', 'str.translate', '__builtin__.str',
- '__builtin__.str.translate'):
+ for name in ('str', 'str.translate', 'builtins.str',
+ 'builtins.str.translate'):
# test low-level function
self.assertIsNotNone(pydoc.locate(name))
# test high-level function
@@ -389,19 +452,92 @@ class TestHelper(unittest.TestCase):
except ImportError:
self.fail('finding the doc of {!r} failed'.format(o))
- for name in ('not__builtin__', 'strrr', 'strr.translate',
- 'str.trrrranslate', '__builtin__.strrr',
- '__builtin__.str.trrranslate'):
+ for name in ('notbuiltins', 'strrr', 'strr.translate',
+ 'str.trrrranslate', 'builtins.strrr',
+ 'builtins.str.trrranslate'):
self.assertIsNone(pydoc.locate(name))
self.assertRaises(ImportError, pydoc.render_doc, name)
+@unittest.skipUnless(threading, 'Threading required for this test.')
+class PydocServerTest(unittest.TestCase):
+ """Tests for pydoc._start_server"""
+
+ def test_server(self):
+
+ # Minimal test that starts the server, then stops it.
+ def my_url_handler(url, content_type):
+ text = 'the URL sent was: (%s, %s)' % (url, content_type)
+ return text
+
+ serverthread = pydoc._start_server(my_url_handler, port=0)
+ starttime = time.time()
+ timeout = 1 #seconds
+
+ while serverthread.serving:
+ time.sleep(.01)
+ if serverthread.serving and time.time() - starttime > timeout:
+ serverthread.stop()
+ break
+
+ self.assertEqual(serverthread.error, None)
+
+
+class PydocUrlHandlerTest(unittest.TestCase):
+ """Tests for pydoc._url_handler"""
+
+ def test_content_type_err(self):
+ f = pydoc._url_handler
+ self.assertRaises(TypeError, f, 'A', '')
+ self.assertRaises(TypeError, f, 'B', 'foobar')
+
+ def test_url_requests(self):
+ # Test for the correct title in the html pages returned.
+ # This tests the different parts of the URL handler without
+ # getting too picky about the exact html.
+ requests = [
+ ("", "Pydoc: Index of Modules"),
+ ("get?key=", "Pydoc: Index of Modules"),
+ ("index", "Pydoc: Index of Modules"),
+ ("topics", "Pydoc: Topics"),
+ ("keywords", "Pydoc: Keywords"),
+ ("pydoc", "Pydoc: module pydoc"),
+ ("get?key=pydoc", "Pydoc: module pydoc"),
+ ("search?key=pydoc", "Pydoc: Search Results"),
+ ("topic?key=def", "Pydoc: KEYWORD def"),
+ ("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"),
+ ("foobar", "Pydoc: Error - foobar"),
+ ("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"),
+ ]
+
+ for url, title in requests:
+ text = pydoc._url_handler(url, "text/html")
+ result = get_html_title(text)
+ self.assertEqual(result, title)
+
+ path = string.__file__
+ title = "Pydoc: getfile " + path
+ url = "getfile?key=" + path
+ text = pydoc._url_handler(url, "text/html")
+ result = get_html_title(text)
+ self.assertEqual(result, title)
+
+
+class TestHelper(unittest.TestCase):
+ def test_keywords(self):
+ self.assertEqual(sorted(pydoc.Helper.keywords),
+ sorted(keyword.kwlist))
+
+@reap_threads
def test_main():
try:
- test.test_support.run_unittest(PyDocDocTest,
- PydocImportTest,
- TestDescriptions,
- TestHelper)
+ test.support.run_unittest(PydocDocTest,
+ PydocImportTest,
+ TestDescriptions,
+ PydocServerTest,
+ PydocUrlHandlerTest,
+ TestHelper,
+ )
finally:
reap_children()
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index b911a2058cc..117bda0c9d5 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -1,13 +1,13 @@
# XXX TypeErrors on calling handlers, or on bad return values from a
# handler, are obscure and unhelpful.
-import StringIO, sys
+from io import BytesIO
import unittest
from xml.parsers import expat
+from xml.parsers.expat import errors
-from test import test_support
-from test.test_support import sortdict, run_unittest
+from test.support import sortdict, run_unittest
class SetAttributeTest(unittest.TestCase):
@@ -20,11 +20,6 @@ class SetAttributeTest(unittest.TestCase):
[0, 0],
]
- def test_returns_unicode(self):
- for x, y in self.set_get_pairs:
- self.parser.returns_unicode = x
- self.assertEqual(self.parser.returns_unicode, y)
-
def test_ordered_attributes(self):
for x, y in self.set_get_pairs:
self.parser.ordered_attributes = x
@@ -36,12 +31,13 @@ class SetAttributeTest(unittest.TestCase):
self.assertEqual(self.parser.specified_attributes, y)
-data = '''\
+data = b'''\
<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<?xml-stylesheet href="stylesheet.css"?>
<!-- comment data -->
<!DOCTYPE quotations SYSTEM "quotations.dtd" [
<!ELEMENT root ANY>
+<!ATTLIST root attr1 CDATA #REQUIRED attr2 CDATA #IMPLIED>
<!NOTATION notation SYSTEM "notation.jpeg">
<!ENTITY acirc "&#226;">
<!ENTITY external_entity SYSTEM "entity.file">
@@ -55,6 +51,7 @@ data = '''\
</myns:subelement>
<sub2><![CDATA[contents of CDATA section]]></sub2>
&external_entity;
+&skipped_entity;
</root>
'''
@@ -103,7 +100,7 @@ class ParseTest(unittest.TestCase):
entityName, base, systemId, publicId, notationName = args
self.out.append('Unparsed entity decl: %s' %(args,))
- def NotStandaloneHandler(self, userData):
+ def NotStandaloneHandler(self):
self.out.append('Not standalone')
return 1
@@ -112,6 +109,34 @@ class ParseTest(unittest.TestCase):
self.out.append('External entity ref: %s' %(args[1:],))
return 1
+ def StartDoctypeDeclHandler(self, *args):
+ self.out.append(('Start doctype', args))
+ return 1
+
+ def EndDoctypeDeclHandler(self):
+ self.out.append("End doctype")
+ return 1
+
+ def EntityDeclHandler(self, *args):
+ self.out.append(('Entity declaration', args))
+ return 1
+
+ def XmlDeclHandler(self, *args):
+ self.out.append(('XML declaration', args))
+ return 1
+
+ def ElementDeclHandler(self, *args):
+ self.out.append(('Element declaration', args))
+ return 1
+
+ def AttlistDeclHandler(self, *args):
+ self.out.append(('Attribute list declaration', args))
+ return 1
+
+ def SkippedEntityHandler(self, *args):
+ self.out.append(("Skipped entity", args))
+ return 1
+
def DefaultHandler(self, userData):
pass
@@ -119,115 +144,86 @@ class ParseTest(unittest.TestCase):
pass
handler_names = [
- 'StartElementHandler', 'EndElementHandler',
- 'CharacterDataHandler', 'ProcessingInstructionHandler',
- 'UnparsedEntityDeclHandler', 'NotationDeclHandler',
- 'StartNamespaceDeclHandler', 'EndNamespaceDeclHandler',
- 'CommentHandler', 'StartCdataSectionHandler',
- 'EndCdataSectionHandler',
- 'DefaultHandler', 'DefaultHandlerExpand',
- #'NotStandaloneHandler',
- 'ExternalEntityRefHandler'
+ 'StartElementHandler', 'EndElementHandler', 'CharacterDataHandler',
+ 'ProcessingInstructionHandler', 'UnparsedEntityDeclHandler',
+ 'NotationDeclHandler', 'StartNamespaceDeclHandler',
+ 'EndNamespaceDeclHandler', 'CommentHandler',
+ 'StartCdataSectionHandler', 'EndCdataSectionHandler', 'DefaultHandler',
+ 'DefaultHandlerExpand', 'NotStandaloneHandler',
+ 'ExternalEntityRefHandler', 'StartDoctypeDeclHandler',
+ 'EndDoctypeDeclHandler', 'EntityDeclHandler', 'XmlDeclHandler',
+ 'ElementDeclHandler', 'AttlistDeclHandler', 'SkippedEntityHandler',
]
- def test_utf8(self):
-
- out = self.Outputter()
- parser = expat.ParserCreate(namespace_separator='!')
+ def _hookup_callbacks(self, parser, handler):
+ """
+ Set each of the callbacks defined on handler and named in
+ self.handler_names on the given parser.
+ """
for name in self.handler_names:
- setattr(parser, name, getattr(out, name))
- parser.returns_unicode = 0
- parser.Parse(data, 1)
-
- # Verify output
- op = out.out
- self.assertEqual(op[0], 'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'')
- self.assertEqual(op[1], "Comment: ' comment data '")
- self.assertEqual(op[2], "Notation declared: ('notation', None, 'notation.jpeg', None)")
- self.assertEqual(op[3], "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')")
- self.assertEqual(op[4], "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\\xe1\\xbd\\x80'}")
- self.assertEqual(op[5], "NS decl: 'myns' 'http://www.python.org/namespace'")
- self.assertEqual(op[6], "Start element: 'http://www.python.org/namespace!subelement' {}")
- self.assertEqual(op[7], "Character data: 'Contents of subelements'")
- self.assertEqual(op[8], "End element: 'http://www.python.org/namespace!subelement'")
- self.assertEqual(op[9], "End of NS decl: 'myns'")
- self.assertEqual(op[10], "Start element: 'sub2' {}")
- self.assertEqual(op[11], 'Start of CDATA section')
- self.assertEqual(op[12], "Character data: 'contents of CDATA section'")
- self.assertEqual(op[13], 'End of CDATA section')
- self.assertEqual(op[14], "End element: 'sub2'")
- self.assertEqual(op[15], "External entity ref: (None, 'entity.file', None)")
- self.assertEqual(op[16], "End element: 'root'")
+ setattr(parser, name, getattr(handler, name))
+
+ def _verify_parse_output(self, operations):
+ expected_operations = [
+ ('XML declaration', ('1.0', 'iso-8859-1', 0)),
+ 'PI: \'xml-stylesheet\' \'href="stylesheet.css"\'',
+ "Comment: ' comment data '",
+ "Not standalone",
+ ("Start doctype", ('quotations', 'quotations.dtd', None, 1)),
+ ('Element declaration', ('root', (2, 0, None, ()))),
+ ('Attribute list declaration', ('root', 'attr1', 'CDATA', None,
+ 1)),
+ ('Attribute list declaration', ('root', 'attr2', 'CDATA', None,
+ 0)),
+ "Notation declared: ('notation', None, 'notation.jpeg', None)",
+ ('Entity declaration', ('acirc', 0, '\xe2', None, None, None, None)),
+ ('Entity declaration', ('external_entity', 0, None, None,
+ 'entity.file', None, None)),
+ "Unparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')",
+ "Not standalone",
+ "End doctype",
+ "Start element: 'root' {'attr1': 'value1', 'attr2': 'value2\u1f40'}",
+ "NS decl: 'myns' 'http://www.python.org/namespace'",
+ "Start element: 'http://www.python.org/namespace!subelement' {}",
+ "Character data: 'Contents of subelements'",
+ "End element: 'http://www.python.org/namespace!subelement'",
+ "End of NS decl: 'myns'",
+ "Start element: 'sub2' {}",
+ 'Start of CDATA section',
+ "Character data: 'contents of CDATA section'",
+ 'End of CDATA section',
+ "End element: 'sub2'",
+ "External entity ref: (None, 'entity.file', None)",
+ ('Skipped entity', ('skipped_entity', 0)),
+ "End element: 'root'",
+ ]
+ for operation, expected_operation in zip(operations, expected_operations):
+ self.assertEqual(operation, expected_operation)
def test_unicode(self):
# Try the parse again, this time producing Unicode output
out = self.Outputter()
parser = expat.ParserCreate(namespace_separator='!')
- parser.returns_unicode = 1
- for name in self.handler_names:
- setattr(parser, name, getattr(out, name))
+ self._hookup_callbacks(parser, out)
parser.Parse(data, 1)
- op = out.out
- self.assertEqual(op[0], 'PI: u\'xml-stylesheet\' u\'href="stylesheet.css"\'')
- self.assertEqual(op[1], "Comment: u' comment data '")
- self.assertEqual(op[2], "Notation declared: (u'notation', None, u'notation.jpeg', None)")
- self.assertEqual(op[3], "Unparsed entity decl: (u'unparsed_entity', None, u'entity.file', None, u'notation')")
- self.assertEqual(op[4], "Start element: u'root' {u'attr1': u'value1', u'attr2': u'value2\\u1f40'}")
- self.assertEqual(op[5], "NS decl: u'myns' u'http://www.python.org/namespace'")
- self.assertEqual(op[6], "Start element: u'http://www.python.org/namespace!subelement' {}")
- self.assertEqual(op[7], "Character data: u'Contents of subelements'")
- self.assertEqual(op[8], "End element: u'http://www.python.org/namespace!subelement'")
- self.assertEqual(op[9], "End of NS decl: u'myns'")
- self.assertEqual(op[10], "Start element: u'sub2' {}")
- self.assertEqual(op[11], 'Start of CDATA section')
- self.assertEqual(op[12], "Character data: u'contents of CDATA section'")
- self.assertEqual(op[13], 'End of CDATA section')
- self.assertEqual(op[14], "End element: u'sub2'")
- self.assertEqual(op[15], "External entity ref: (None, u'entity.file', None)")
- self.assertEqual(op[16], "End element: u'root'")
+ operations = out.out
+ self._verify_parse_output(operations)
+ # Issue #6697.
+ self.assertRaises(AttributeError, getattr, parser, '\uD800')
def test_parse_file(self):
# Try parsing a file
out = self.Outputter()
parser = expat.ParserCreate(namespace_separator='!')
- parser.returns_unicode = 1
- for name in self.handler_names:
- setattr(parser, name, getattr(out, name))
- file = StringIO.StringIO(data)
+ self._hookup_callbacks(parser, out)
+ file = BytesIO(data)
parser.ParseFile(file)
- op = out.out
- self.assertEqual(op[0], 'PI: u\'xml-stylesheet\' u\'href="stylesheet.css"\'')
- self.assertEqual(op[1], "Comment: u' comment data '")
- self.assertEqual(op[2], "Notation declared: (u'notation', None, u'notation.jpeg', None)")
- self.assertEqual(op[3], "Unparsed entity decl: (u'unparsed_entity', None, u'entity.file', None, u'notation')")
- self.assertEqual(op[4], "Start element: u'root' {u'attr1': u'value1', u'attr2': u'value2\\u1f40'}")
- self.assertEqual(op[5], "NS decl: u'myns' u'http://www.python.org/namespace'")
- self.assertEqual(op[6], "Start element: u'http://www.python.org/namespace!subelement' {}")
- self.assertEqual(op[7], "Character data: u'Contents of subelements'")
- self.assertEqual(op[8], "End element: u'http://www.python.org/namespace!subelement'")
- self.assertEqual(op[9], "End of NS decl: u'myns'")
- self.assertEqual(op[10], "Start element: u'sub2' {}")
- self.assertEqual(op[11], 'Start of CDATA section')
- self.assertEqual(op[12], "Character data: u'contents of CDATA section'")
- self.assertEqual(op[13], 'End of CDATA section')
- self.assertEqual(op[14], "End element: u'sub2'")
- self.assertEqual(op[15], "External entity ref: (None, u'entity.file', None)")
- self.assertEqual(op[16], "End element: u'root'")
-
- # Issue 4877: expat.ParseFile causes segfault on a closed file.
- fp = open(test_support.TESTFN, 'wb')
- try:
- fp.close()
- parser = expat.ParserCreate()
- with self.assertRaises(ValueError):
- parser.ParseFile(fp)
- finally:
- test_support.unlink(test_support.TESTFN)
-
+ operations = out.out
+ self._verify_parse_output(operations)
class NamespaceSeparatorTest(unittest.TestCase):
def test_legal(self):
@@ -241,14 +237,14 @@ class NamespaceSeparatorTest(unittest.TestCase):
try:
expat.ParserCreate(namespace_separator=42)
self.fail()
- except TypeError, e:
+ except TypeError as e:
self.assertEqual(str(e),
- 'ParserCreate() argument 2 must be string or None, not int')
+ 'ParserCreate() argument 2 must be str or None, not int')
try:
expat.ParserCreate(namespace_separator='too long')
self.fail()
- except ValueError, e:
+ except ValueError as e:
self.assertEqual(str(e),
'namespace_separator must be at most one character, omitted, or None')
@@ -280,6 +276,25 @@ class InterningTest(unittest.TestCase):
# L should have the same string repeated over and over.
self.assertTrue(tag is entry)
+ def test_issue9402(self):
+ # create an ExternalEntityParserCreate with buffer text
+ class ExternalOutputter:
+ def __init__(self, parser):
+ self.parser = parser
+ self.parser_result = None
+
+ def ExternalEntityRefHandler(self, context, base, sysId, pubId):
+ external_parser = self.parser.ExternalEntityParserCreate("")
+ self.parser_result = external_parser.Parse("", 1)
+ return 1
+
+ parser = expat.ParserCreate(namespace_separator='!')
+ parser.buffer_text = 1
+ out = ExternalOutputter(parser)
+ parser.ExternalEntityRefHandler = out.ExternalEntityRefHandler
+ parser.Parse(data, 1)
+ self.assertEqual(out.parser_result, 1)
+
class BufferTextTest(unittest.TestCase):
def setUp(self):
@@ -291,7 +306,7 @@ class BufferTextTest(unittest.TestCase):
def check(self, expected, label):
self.assertEqual(self.stuff, expected,
"%s\nstuff = %r\nexpected = %r"
- % (label, self.stuff, map(unicode, expected)))
+ % (label, self.stuff, map(str, expected)))
def CharacterDataHandler(self, text):
self.stuff.append(text)
@@ -343,7 +358,7 @@ class BufferTextTest(unittest.TestCase):
self.setHandlers(["StartElementHandler"])
self.parser.Parse("<a>1<b/>2<c/>3</a>", 1)
self.assertEqual(self.stuff, ["<a>", "1", "<b>", "2", "<c>", "3"],
- "buffered text not properly split")
+ "buffered text not properly split")
def test4(self):
self.setHandlers(["StartElementHandler", "EndElementHandler"])
@@ -387,7 +402,7 @@ class HandlerExceptionTest(unittest.TestCase):
try:
parser.Parse("<a><b><c/></b></a>", 1)
self.fail()
- except RuntimeError, e:
+ except RuntimeError as e:
self.assertEqual(e.args[0], 'a',
"Expected RuntimeError for element 'a', but" + \
" found %r" % e.args[0])
@@ -461,7 +476,6 @@ class ChardataBufferTest(unittest.TestCase):
def f(size):
parser.buffer_size = size
- self.assertRaises(TypeError, f, sys.maxint+1)
self.assertRaises(ValueError, f, -1)
self.assertRaises(ValueError, f, 0)
@@ -564,12 +578,12 @@ class ChardataBufferTest(unittest.TestCase):
self.n=0
parser.Parse(xml1, 0)
- parser.buffer_size //= 2
+ parser.buffer_size = parser.buffer_size // 2
self.assertEqual(parser.buffer_size, 1024)
parser.Parse(xml2, 1)
self.assertEqual(self.n, 4)
-class MalformedInputText(unittest.TestCase):
+class MalformedInputTest(unittest.TestCase):
def test1(self):
xml = "\0\r\n"
parser = expat.ParserCreate()
@@ -588,6 +602,23 @@ class MalformedInputText(unittest.TestCase):
except expat.ExpatError as e:
self.assertEqual(str(e), 'XML declaration not well-formed: line 1, column 14')
+class ErrorMessageTest(unittest.TestCase):
+ def test_codes(self):
+ # verify mapping of errors.codes and errors.messages
+ self.assertEqual(errors.XML_ERROR_SYNTAX,
+ errors.messages[errors.codes[errors.XML_ERROR_SYNTAX]])
+
+ def test_expaterror(self):
+ xml = '<'
+ parser = expat.ParserCreate()
+ try:
+ parser.Parse(xml, True)
+ self.fail()
+ except expat.ExpatError as e:
+ self.assertEqual(e.code,
+ errors.codes[errors.XML_ERROR_UNCLOSED_TOKEN])
+
+
class ForeignDTDTests(unittest.TestCase):
"""
Tests for the UseForeignDTD method of expat parser objects.
@@ -650,7 +681,8 @@ def test_main():
PositionTest,
sf1296433Test,
ChardataBufferTest,
- MalformedInputText,
+ MalformedInputTest,
+ ErrorMessageTest,
ForeignDTDTests)
if __name__ == "__main__":
diff --git a/Lib/test/test_queue.py b/Lib/test/test_queue.py
index f821db689c1..86ad9c07655 100644
--- a/Lib/test/test_queue.py
+++ b/Lib/test/test_queue.py
@@ -1,13 +1,16 @@
# Some simple queue module tests, plus some failure conditions
# to ensure the Queue locks remain stable.
-import Queue
+import queue
import time
import unittest
-from test import test_support
-threading = test_support.import_module('threading')
+from test import support
+threading = support.import_module('threading')
QUEUE_SIZE = 5
+def qfull(q):
+ return q.maxsize > 0 and q.qsize() == q.maxsize
+
# A thread to run a function that unclogs a blocked Queue.
class _TriggerThread(threading.Thread):
def __init__(self, fn, args):
@@ -79,14 +82,16 @@ class BlockingTestMixin:
self.fail("trigger thread ended but event never set")
-class BaseQueueTest(BlockingTestMixin):
+class BaseQueueTestMixin(BlockingTestMixin):
def setUp(self):
self.cum = 0
self.cumlock = threading.Lock()
def simple_queue_test(self, q):
- if not q.empty():
- raise RuntimeError, "Call this function with an empty queue"
+ if q.qsize():
+ raise RuntimeError("Call this function with an empty queue")
+ self.assertTrue(q.empty())
+ self.assertFalse(q.full())
# I guess we better check things actually queue correctly a little :)
q.put(111)
q.put(333)
@@ -99,21 +104,23 @@ class BaseQueueTest(BlockingTestMixin):
"Didn't seem to queue the correct data!")
for i in range(QUEUE_SIZE-1):
q.put(i)
- self.assertTrue(not q.empty(), "Queue should not be empty")
- self.assertTrue(not q.full(), "Queue should not be full")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
+ self.assertTrue(not qfull(q), "Queue should not be full")
last = 2 * QUEUE_SIZE
full = 3 * 2 * QUEUE_SIZE
q.put(last)
- self.assertTrue(q.full(), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
+ self.assertFalse(q.empty())
+ self.assertTrue(q.full())
try:
q.put(full, block=0)
self.fail("Didn't appear to block with a full queue")
- except Queue.Full:
+ except queue.Full:
pass
try:
q.put(full, timeout=0.01)
self.fail("Didn't appear to time-out with a full queue")
- except Queue.Full:
+ except queue.Full:
pass
# Test a blocking put
self.do_blocking_test(q.put, (full,), q.get, ())
@@ -121,16 +128,16 @@ class BaseQueueTest(BlockingTestMixin):
# Empty it
for i in range(QUEUE_SIZE):
q.get()
- self.assertTrue(q.empty(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
try:
q.get(block=0)
self.fail("Didn't appear to block with an empty queue")
- except Queue.Empty:
+ except queue.Empty:
pass
try:
q.get(timeout=0.01)
self.fail("Didn't appear to time-out with an empty queue")
- except Queue.Empty:
+ except queue.Empty:
pass
# Test a blocking get
self.do_blocking_test(q.get, (), q.put, ('empty',))
@@ -140,7 +147,7 @@ class BaseQueueTest(BlockingTestMixin):
def worker(self, q):
while True:
x = q.get()
- if x is None:
+ if x < 0:
q.task_done()
return
with self.cumlock:
@@ -151,13 +158,13 @@ class BaseQueueTest(BlockingTestMixin):
self.cum = 0
for i in (0,1):
threading.Thread(target=self.worker, args=(q,)).start()
- for i in xrange(100):
+ for i in range(100):
q.put(i)
q.join()
self.assertEqual(self.cum, sum(range(100)),
"q.join() did not block until all tasks were done")
for i in (0,1):
- q.put(None) # instruct the threads to close
+ q.put(-1) # instruct the threads to close
q.join() # verify that you can join twice
def test_queue_task_done(self):
@@ -190,15 +197,46 @@ class BaseQueueTest(BlockingTestMixin):
self.simple_queue_test(q)
self.simple_queue_test(q)
+ def test_negative_timeout_raises_exception(self):
+ q = self.type2test(QUEUE_SIZE)
+ with self.assertRaises(ValueError):
+ q.put(1, timeout=-1)
+ with self.assertRaises(ValueError):
+ q.get(1, timeout=-1)
+
+ def test_nowait(self):
+ q = self.type2test(QUEUE_SIZE)
+ for i in range(QUEUE_SIZE):
+ q.put_nowait(1)
+ with self.assertRaises(queue.Full):
+ q.put_nowait(1)
+
+ for i in range(QUEUE_SIZE):
+ q.get_nowait()
+ with self.assertRaises(queue.Empty):
+ q.get_nowait()
+
+ def test_shrinking_queue(self):
+ # issue 10110
+ q = self.type2test(3)
+ q.put(1)
+ q.put(2)
+ q.put(3)
+ with self.assertRaises(queue.Full):
+ q.put_nowait(4)
+ self.assertEqual(q.qsize(), 3)
+ q.maxsize = 2 # shrink the queue
+ with self.assertRaises(queue.Full):
+ q.put_nowait(4)
-class QueueTest(BaseQueueTest, unittest.TestCase):
- type2test = Queue.Queue
+class QueueTest(BaseQueueTestMixin, unittest.TestCase):
+ type2test = queue.Queue
-class LifoQueueTest(BaseQueueTest, unittest.TestCase):
- type2test = Queue.LifoQueue
+class LifoQueueTest(BaseQueueTestMixin, unittest.TestCase):
+ type2test = queue.LifoQueue
-class PriorityQueueTest(BaseQueueTest, unittest.TestCase):
- type2test = Queue.PriorityQueue
+class PriorityQueueTest(BaseQueueTestMixin, unittest.TestCase):
+ type2test = queue.PriorityQueue
@@ -206,27 +244,27 @@ class PriorityQueueTest(BaseQueueTest, unittest.TestCase):
class FailingQueueException(Exception):
pass
-class FailingQueue(Queue.Queue):
+class FailingQueue(queue.Queue):
def __init__(self, *args):
self.fail_next_put = False
self.fail_next_get = False
- Queue.Queue.__init__(self, *args)
+ queue.Queue.__init__(self, *args)
def _put(self, item):
if self.fail_next_put:
self.fail_next_put = False
- raise FailingQueueException, "You Lose"
- return Queue.Queue._put(self, item)
+ raise FailingQueueException("You Lose")
+ return queue.Queue._put(self, item)
def _get(self):
if self.fail_next_get:
self.fail_next_get = False
- raise FailingQueueException, "You Lose"
- return Queue.Queue._get(self)
+ raise FailingQueueException("You Lose")
+ return queue.Queue._get(self)
class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
def failing_queue_test(self, q):
- if not q.empty():
- raise RuntimeError, "Call this function with an empty queue"
+ if q.qsize():
+ raise RuntimeError("Call this function with an empty queue")
for i in range(QUEUE_SIZE-1):
q.put(i)
# Test a failing non-blocking put.
@@ -243,7 +281,7 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
except FailingQueueException:
pass
q.put("last")
- self.assertTrue(q.full(), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
# Test a failing blocking put
q.fail_next_put = True
try:
@@ -265,17 +303,17 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
# Check the Queue isn't damaged.
# put failed, but get succeeded - re-add
q.put("last")
- self.assertTrue(q.full(), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
q.get()
- self.assertTrue(not q.full(), "Queue should not be full")
+ self.assertTrue(not qfull(q), "Queue should not be full")
q.put("last")
- self.assertTrue(q.full(), "Queue should be full")
+ self.assertTrue(qfull(q), "Queue should be full")
# Test a blocking put
self.do_blocking_test(q.put, ("full",), q.get, ())
# Empty it
for i in range(QUEUE_SIZE):
q.get()
- self.assertTrue(q.empty(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
q.put("first")
q.fail_next_get = True
try:
@@ -283,16 +321,16 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
self.fail("The queue didn't fail when it should have")
except FailingQueueException:
pass
- self.assertTrue(not q.empty(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.fail_next_get = True
try:
q.get(timeout=0.1)
self.fail("The queue didn't fail when it should have")
except FailingQueueException:
pass
- self.assertTrue(not q.empty(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.get()
- self.assertTrue(q.empty(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
q.fail_next_get = True
try:
self.do_exceptional_blocking_test(q.get, (), q.put, ('empty',),
@@ -301,9 +339,9 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
except FailingQueueException:
pass
# put succeeded, but get failed.
- self.assertTrue(not q.empty(), "Queue should not be empty")
+ self.assertTrue(q.qsize(), "Queue should not be empty")
q.get()
- self.assertTrue(q.empty(), "Queue should be empty")
+ self.assertTrue(not q.qsize(), "Queue should be empty")
def test_failing_queue(self):
# Test to make sure a queue is functioning correctly.
@@ -314,7 +352,7 @@ class FailingQueueTest(unittest.TestCase, BlockingTestMixin):
def test_main():
- test_support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest,
+ support.run_unittest(QueueTest, LifoQueueTest, PriorityQueueTest,
FailingQueueTest)
diff --git a/Lib/test/test_quopri.py b/Lib/test/test_quopri.py
index c3c4d1432e8..583fd456a48 100644
--- a/Lib/test/test_quopri.py
+++ b/Lib/test/test_quopri.py
@@ -1,12 +1,12 @@
-from test import test_support
+from test import support
import unittest
-import sys, cStringIO, subprocess
+import sys, os, io, subprocess
import quopri
-ENCSAMPLE = """\
+ENCSAMPLE = b"""\
Here's a bunch of special=20
=A1=A2=A3=A4=A5=A6=A7=A8=A9
@@ -25,8 +25,8 @@ characters... have fun!
"""
# First line ends with a space
-DECSAMPLE = "Here's a bunch of special \n" + \
-"""\
+DECSAMPLE = b"Here's a bunch of special \n" + \
+b"""\
\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9
\xaa\xab\xac\xad\xae\xaf\xb0\xb1\xb2\xb3
@@ -67,48 +67,48 @@ class QuopriTestCase(unittest.TestCase):
# used in the "quotetabs=0" tests.
STRINGS = (
# Some normal strings
- ('hello', 'hello'),
- ('''hello
+ (b'hello', b'hello'),
+ (b'''hello
there
- world''', '''hello
+ world''', b'''hello
there
world'''),
- ('''hello
+ (b'''hello
there
world
-''', '''hello
+''', b'''hello
there
world
'''),
- ('\201\202\203', '=81=82=83'),
+ (b'\201\202\203', b'=81=82=83'),
# Add some trailing MUST QUOTE strings
- ('hello ', 'hello=20'),
- ('hello\t', 'hello=09'),
+ (b'hello ', b'hello=20'),
+ (b'hello\t', b'hello=09'),
# Some long lines. First, a single line of 108 characters
- ('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xd8\xd9\xda\xdb\xdc\xdd\xde\xdfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
- '''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=D8=D9=DA=DB=DC=DD=DE=DFx=
+ (b'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\xd8\xd9\xda\xdb\xdc\xdd\xde\xdfxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
+ b'''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=D8=D9=DA=DB=DC=DD=DE=DFx=
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'''),
# A line of exactly 76 characters, no soft line break should be needed
- ('yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
- 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'),
+ (b'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy',
+ b'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'),
# A line of 77 characters, forcing a soft line break at position 75,
# and a second line of exactly 2 characters (because the soft line
# break `=' sign counts against the line length limit).
- ('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
- '''zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=
+ (b'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
+ b'''zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=
zz'''),
# A line of 151 characters, forcing a soft line break at position 75,
# with a second line of exactly 76 characters and no trailing =
- ('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
- '''zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=
+ (b'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz',
+ b'''zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz=
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'''),
# A string containing a hard line break, but which the first line is
# 151 characters and the second line is exactly 76 characters. This
# should leave us with three lines, the first which has a soft line
# break, and which the second and third do not.
- ('''yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
+ (b'''yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''',
- '''yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=
+ b'''yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'''),
# Now some really complex stuff ;)
@@ -117,62 +117,62 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
# These are used in the "quotetabs=1" tests.
ESTRINGS = (
- ('hello world', 'hello=20world'),
- ('hello\tworld', 'hello=09world'),
+ (b'hello world', b'hello=20world'),
+ (b'hello\tworld', b'hello=09world'),
)
# These are used in the "header=1" tests.
HSTRINGS = (
- ('hello world', 'hello_world'),
- ('hello_world', 'hello=5Fworld'),
+ (b'hello world', b'hello_world'),
+ (b'hello_world', b'hello=5Fworld'),
)
@withpythonimplementation
def test_encodestring(self):
for p, e in self.STRINGS:
- self.assertTrue(quopri.encodestring(p) == e)
+ self.assertEqual(quopri.encodestring(p), e)
@withpythonimplementation
def test_decodestring(self):
for p, e in self.STRINGS:
- self.assertTrue(quopri.decodestring(e) == p)
+ self.assertEqual(quopri.decodestring(e), p)
@withpythonimplementation
def test_idempotent_string(self):
for p, e in self.STRINGS:
- self.assertTrue(quopri.decodestring(quopri.encodestring(e)) == e)
+ self.assertEqual(quopri.decodestring(quopri.encodestring(e)), e)
@withpythonimplementation
def test_encode(self):
for p, e in self.STRINGS:
- infp = cStringIO.StringIO(p)
- outfp = cStringIO.StringIO()
+ infp = io.BytesIO(p)
+ outfp = io.BytesIO()
quopri.encode(infp, outfp, quotetabs=False)
- self.assertTrue(outfp.getvalue() == e)
+ self.assertEqual(outfp.getvalue(), e)
@withpythonimplementation
def test_decode(self):
for p, e in self.STRINGS:
- infp = cStringIO.StringIO(e)
- outfp = cStringIO.StringIO()
+ infp = io.BytesIO(e)
+ outfp = io.BytesIO()
quopri.decode(infp, outfp)
- self.assertTrue(outfp.getvalue() == p)
+ self.assertEqual(outfp.getvalue(), p)
@withpythonimplementation
def test_embedded_ws(self):
for p, e in self.ESTRINGS:
- self.assertTrue(quopri.encodestring(p, quotetabs=True) == e)
- self.assertTrue(quopri.decodestring(e) == p)
+ self.assertEqual(quopri.encodestring(p, quotetabs=True), e)
+ self.assertEqual(quopri.decodestring(e), p)
@withpythonimplementation
def test_encode_header(self):
for p, e in self.HSTRINGS:
- self.assertTrue(quopri.encodestring(p, header=True) == e)
+ self.assertEqual(quopri.encodestring(p, header=True), e)
@withpythonimplementation
def test_decode_header(self):
for p, e in self.HSTRINGS:
- self.assertTrue(quopri.decodestring(e, header=True) == p)
+ self.assertEqual(quopri.decodestring(e, header=True), p)
def test_scriptencode(self):
(p, e) = self.STRINGS[-1]
@@ -183,7 +183,12 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
# On Windows, Python will output the result to stdout using
# CRLF, as the mode of stdout is text mode. To compare this
# with the expected result, we need to do a line-by-line comparison.
- self.assertEqual(cout.splitlines(), e.splitlines())
+ cout = cout.decode('latin-1').splitlines()
+ e = e.decode('latin-1').splitlines()
+ assert len(cout)==len(e)
+ for i in range(len(cout)):
+ self.assertEqual(cout[i], e[i])
+ self.assertEqual(cout, e)
def test_scriptdecode(self):
(p, e) = self.STRINGS[-1]
@@ -191,10 +196,12 @@ zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz''')
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
self.addCleanup(process.stdout.close)
cout, cerr = process.communicate(e)
+ cout = cout.decode('latin-1')
+ p = p.decode('latin-1')
self.assertEqual(cout.splitlines(), p.splitlines())
def test_main():
- test_support.run_unittest(QuopriTestCase)
+ support.run_unittest(QuopriTestCase)
if __name__ == "__main__":
diff --git a/Lib/test/test_raise.py b/Lib/test/test_raise.py
new file mode 100644
index 00000000000..e02c1af1314
--- /dev/null
+++ b/Lib/test/test_raise.py
@@ -0,0 +1,383 @@
+# Copyright 2007 Google, Inc. All Rights Reserved.
+# Licensed to PSF under a Contributor Agreement.
+
+"""Tests for the raise statement."""
+
+from test import support
+import sys
+import types
+import unittest
+
+
+def get_tb():
+ try:
+ raise OSError()
+ except:
+ return sys.exc_info()[2]
+
+
+class Context:
+ def __enter__(self):
+ return self
+ def __exit__(self, exc_type, exc_value, exc_tb):
+ return True
+
+
+class TestRaise(unittest.TestCase):
+ def test_invalid_reraise(self):
+ try:
+ raise
+ except RuntimeError as e:
+ self.assertIn("No active exception", str(e))
+ else:
+ self.fail("No exception raised")
+
+ def test_reraise(self):
+ try:
+ try:
+ raise IndexError()
+ except IndexError as e:
+ exc1 = e
+ raise
+ except IndexError as exc2:
+ self.assertTrue(exc1 is exc2)
+ else:
+ self.fail("No exception raised")
+
+ def test_except_reraise(self):
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ try:
+ raise KeyError("caught")
+ except KeyError:
+ pass
+ raise
+ self.assertRaises(TypeError, reraise)
+
+ def test_finally_reraise(self):
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ try:
+ raise KeyError("caught")
+ finally:
+ raise
+ self.assertRaises(KeyError, reraise)
+
+ def test_nested_reraise(self):
+ def nested_reraise():
+ raise
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ nested_reraise()
+ self.assertRaises(TypeError, reraise)
+
+ def test_with_reraise1(self):
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ with Context():
+ pass
+ raise
+ self.assertRaises(TypeError, reraise)
+
+ def test_with_reraise2(self):
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ with Context():
+ raise KeyError("caught")
+ raise
+ self.assertRaises(TypeError, reraise)
+
+ def test_yield_reraise(self):
+ def reraise():
+ try:
+ raise TypeError("foo")
+ except:
+ yield 1
+ raise
+ g = reraise()
+ next(g)
+ self.assertRaises(TypeError, lambda: next(g))
+ self.assertRaises(StopIteration, lambda: next(g))
+
+ def test_erroneous_exception(self):
+ class MyException(Exception):
+ def __init__(self):
+ raise RuntimeError()
+
+ try:
+ raise MyException
+ except RuntimeError:
+ pass
+ else:
+ self.fail("No exception raised")
+
+ def test_new_returns_invalid_instance(self):
+ # See issue #11627.
+ class MyException(Exception):
+ def __new__(cls, *args):
+ return object()
+
+ with self.assertRaises(TypeError):
+ raise MyException
+
+
+class TestCause(unittest.TestCase):
+ def test_invalid_cause(self):
+ try:
+ raise IndexError from 5
+ except TypeError as e:
+ self.assertIn("exception cause", str(e))
+ else:
+ self.fail("No exception raised")
+
+ def test_class_cause(self):
+ try:
+ raise IndexError from KeyError
+ except IndexError as e:
+ self.assertIsInstance(e.__cause__, KeyError)
+ else:
+ self.fail("No exception raised")
+
+ def test_instance_cause(self):
+ cause = KeyError()
+ try:
+ raise IndexError from cause
+ except IndexError as e:
+ self.assertTrue(e.__cause__ is cause)
+ else:
+ self.fail("No exception raised")
+
+ def test_erroneous_cause(self):
+ class MyException(Exception):
+ def __init__(self):
+ raise RuntimeError()
+
+ try:
+ raise IndexError from MyException
+ except RuntimeError:
+ pass
+ else:
+ self.fail("No exception raised")
+
+
+class TestTraceback(unittest.TestCase):
+ def test_sets_traceback(self):
+ try:
+ raise IndexError()
+ except IndexError as e:
+ self.assertIsInstance(e.__traceback__, types.TracebackType)
+ else:
+ self.fail("No exception raised")
+
+ def test_accepts_traceback(self):
+ tb = get_tb()
+ try:
+ raise IndexError().with_traceback(tb)
+ except IndexError as e:
+ self.assertNotEqual(e.__traceback__, tb)
+ self.assertEqual(e.__traceback__.tb_next, tb)
+ else:
+ self.fail("No exception raised")
+
+
+class TestContext(unittest.TestCase):
+ def test_instance_context_instance_raise(self):
+ context = IndexError()
+ try:
+ try:
+ raise context
+ except:
+ raise OSError()
+ except OSError as e:
+ self.assertEqual(e.__context__, context)
+ else:
+ self.fail("No exception raised")
+
+ def test_class_context_instance_raise(self):
+ context = IndexError
+ try:
+ try:
+ raise context
+ except:
+ raise OSError()
+ except OSError as e:
+ self.assertNotEqual(e.__context__, context)
+ self.assertIsInstance(e.__context__, context)
+ else:
+ self.fail("No exception raised")
+
+ def test_class_context_class_raise(self):
+ context = IndexError
+ try:
+ try:
+ raise context
+ except:
+ raise OSError
+ except OSError as e:
+ self.assertNotEqual(e.__context__, context)
+ self.assertIsInstance(e.__context__, context)
+ else:
+ self.fail("No exception raised")
+
+ def test_c_exception_context(self):
+ try:
+ try:
+ 1/0
+ except:
+ raise OSError
+ except OSError as e:
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
+ else:
+ self.fail("No exception raised")
+
+ def test_c_exception_raise(self):
+ try:
+ try:
+ 1/0
+ except:
+ xyzzy
+ except NameError as e:
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
+ else:
+ self.fail("No exception raised")
+
+ def test_noraise_finally(self):
+ try:
+ try:
+ pass
+ finally:
+ raise OSError
+ except OSError as e:
+ self.assertTrue(e.__context__ is None)
+ else:
+ self.fail("No exception raised")
+
+ def test_raise_finally(self):
+ try:
+ try:
+ 1/0
+ finally:
+ raise OSError
+ except OSError as e:
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
+ else:
+ self.fail("No exception raised")
+
+ def test_context_manager(self):
+ class ContextManager:
+ def __enter__(self):
+ pass
+ def __exit__(self, t, v, tb):
+ xyzzy
+ try:
+ with ContextManager():
+ 1/0
+ except NameError as e:
+ self.assertIsInstance(e.__context__, ZeroDivisionError)
+ else:
+ self.fail("No exception raised")
+
+ def test_cycle_broken(self):
+ # Self-cycles (when re-raising a caught exception) are broken
+ try:
+ try:
+ 1/0
+ except ZeroDivisionError as e:
+ raise e
+ except ZeroDivisionError as e:
+ self.assertTrue(e.__context__ is None, e.__context__)
+
+ def test_reraise_cycle_broken(self):
+ # Non-trivial context cycles (through re-raising a previous exception)
+ # are broken too.
+ try:
+ try:
+ xyzzy
+ except NameError as a:
+ try:
+ 1/0
+ except ZeroDivisionError:
+ raise a
+ except NameError as e:
+ self.assertTrue(e.__context__.__context__ is None)
+
+ def test_3118(self):
+ # deleting the generator caused the __context__ to be cleared
+ def gen():
+ try:
+ yield 1
+ finally:
+ pass
+
+ def f():
+ g = gen()
+ next(g)
+ try:
+ try:
+ raise ValueError
+ except:
+ del g
+ raise KeyError
+ except Exception as e:
+ self.assertIsInstance(e.__context__, ValueError)
+
+ f()
+
+ def test_3611(self):
+ # A re-raised exception in a __del__ caused the __context__
+ # to be cleared
+ class C:
+ def __del__(self):
+ try:
+ 1/0
+ except:
+ raise
+
+ def f():
+ x = C()
+ try:
+ try:
+ x.x
+ except AttributeError:
+ del x
+ raise TypeError
+ except Exception as e:
+ self.assertNotEqual(e.__context__, None)
+ self.assertIsInstance(e.__context__, AttributeError)
+
+ with support.captured_output("stderr"):
+ f()
+
+class TestRemovedFunctionality(unittest.TestCase):
+ def test_tuples(self):
+ try:
+ raise (IndexError, KeyError) # This should be a tuple!
+ except TypeError:
+ pass
+ else:
+ self.fail("No exception raised")
+
+ def test_strings(self):
+ try:
+ raise "foo"
+ except TypeError:
+ pass
+ else:
+ self.fail("No exception raised")
+
+
+def test_main():
+ support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/test_random.py b/Lib/test/test_random.py
index caa4f289add..776d0c4163e 100644
--- a/Lib/test/test_random.py
+++ b/Lib/test/test_random.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
import random
@@ -6,8 +6,7 @@ import time
import pickle
import warnings
from math import log, exp, pi, fsum, sin
-from functools import reduce
-from test import test_support
+from test import support
class TestBasicOps(unittest.TestCase):
# Superclass with tests common to all generators.
@@ -16,7 +15,7 @@ class TestBasicOps(unittest.TestCase):
def randomlist(self, n):
"""Helper function to make a list of random numbers"""
- return [self.gen.random() for i in xrange(n)]
+ return [self.gen.random() for i in range(n)]
def test_autoseed(self):
self.gen.seed()
@@ -35,42 +34,27 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(randseq, self.randomlist(N))
def test_seedargs(self):
- for arg in [None, 0, 0L, 1, 1L, -1, -1L, 10**20, -(10**20),
+ for arg in [None, 0, 0, 1, 1, -1, -1, 10**20, -(10**20),
3.14, 1+2j, 'a', tuple('abc')]:
self.gen.seed(arg)
- for arg in [range(3), dict(one=1)]:
+ for arg in [list(range(3)), dict(one=1)]:
self.assertRaises(TypeError, self.gen.seed, arg)
- self.assertRaises(TypeError, self.gen.seed, 1, 2)
+ self.assertRaises(TypeError, self.gen.seed, 1, 2, 3, 4)
self.assertRaises(TypeError, type(self.gen), [])
- def test_jumpahead(self):
- self.gen.seed()
- state1 = self.gen.getstate()
- self.gen.jumpahead(100)
- state2 = self.gen.getstate() # s/b distinct from state1
- self.assertNotEqual(state1, state2)
- self.gen.jumpahead(100)
- state3 = self.gen.getstate() # s/b distinct from state2
- self.assertNotEqual(state2, state3)
-
- with test_support.check_py3k_warnings(quiet=True):
- self.assertRaises(TypeError, self.gen.jumpahead) # needs an arg
- self.assertRaises(TypeError, self.gen.jumpahead, 2, 3) # too many
-
- def test_jumpahead_produces_valid_state(self):
- # From http://bugs.python.org/issue14591.
- self.gen.seed(199210368)
- self.gen.jumpahead(13550674232554645900)
- for i in range(500):
- val = self.gen.random()
- self.assertLess(val, 1.0)
+ def test_choice(self):
+ choice = self.gen.choice
+ with self.assertRaises(IndexError):
+ choice([])
+ self.assertEqual(choice([50]), 50)
+ self.assertIn(choice([25, 75]), [25, 75])
def test_sample(self):
# For the entire allowable range of 0 <= k <= N, validate that
# the sample is of the correct length and contains only unique items
N = 100
- population = xrange(N)
- for k in xrange(N+1):
+ population = range(N)
+ for k in range(N+1):
s = self.gen.sample(population, k)
self.assertEqual(len(s), k)
uniq = set(s)
@@ -85,11 +69,13 @@ class TestBasicOps(unittest.TestCase):
pop = range(n)
trials = 10000 # large num prevents false negatives without slowing normal case
def factorial(n):
- return reduce(int.__mul__, xrange(1, n), 1)
- for k in xrange(n):
+ if n == 0:
+ return 1
+ return n * factorial(n - 1)
+ for k in range(n):
expected = factorial(n) // factorial(n-k)
perms = {}
- for i in xrange(trials):
+ for i in range(trials):
perms[tuple(self.gen.sample(pop, k))] = None
if len(perms) == expected:
break
@@ -100,29 +86,12 @@ class TestBasicOps(unittest.TestCase):
# SF bug #801342 -- population can be any iterable defining __len__()
self.gen.sample(set(range(20)), 2)
self.gen.sample(range(20), 2)
- self.gen.sample(xrange(20), 2)
+ self.gen.sample(range(20), 2)
self.gen.sample(str('abcdefghijklmnopqrst'), 2)
self.gen.sample(tuple('abcdefghijklmnopqrst'), 2)
def test_sample_on_dicts(self):
- self.gen.sample(dict.fromkeys('abcdefghijklmnopqrst'), 2)
-
- # SF bug #1460340 -- random.sample can raise KeyError
- a = dict.fromkeys(range(10)+range(10,100,2)+range(100,110))
- self.gen.sample(a, 3)
-
- # A followup to bug #1460340: sampling from a dict could return
- # a subset of its keys or of its values, depending on the size of
- # the subset requested.
- N = 30
- d = dict((i, complex(i, i)) for i in xrange(N))
- for k in xrange(N+1):
- samp = self.gen.sample(d, k)
- # Verify that we got ints back (keys); the values are complex.
- for x in samp:
- self.assertTrue(type(x) is int)
- samp.sort()
- self.assertEqual(samp, range(N))
+ self.assertRaises(TypeError, self.gen.sample, dict.fromkeys('abcdef'), 2)
def test_gauss(self):
# Ensure that the seed() method initializes all the hidden state. In
@@ -143,9 +112,9 @@ class TestBasicOps(unittest.TestCase):
def test_pickling(self):
state = pickle.dumps(self.gen)
- origseq = [self.gen.random() for i in xrange(10)]
+ origseq = [self.gen.random() for i in range(10)]
newgen = pickle.loads(state)
- restoredseq = [newgen.random() for i in xrange(10)]
+ restoredseq = [newgen.random() for i in range(10)]
self.assertEqual(origseq, restoredseq)
def test_bug_1727780(self):
@@ -156,52 +125,18 @@ class TestBasicOps(unittest.TestCase):
("randv2_64.pck", 866),
("randv3.pck", 343)]
for file, value in files:
- f = open(test_support.findfile(file),"rb")
+ f = open(support.findfile(file),"rb")
r = pickle.load(f)
f.close()
- self.assertEqual(r.randrange(1000), value)
-
-class WichmannHill_TestBasicOps(TestBasicOps):
- gen = random.WichmannHill()
-
- def test_setstate_first_arg(self):
- self.assertRaises(ValueError, self.gen.setstate, (2, None, None))
-
- def test_strong_jumpahead(self):
- # tests that jumpahead(n) semantics correspond to n calls to random()
- N = 1000
- s = self.gen.getstate()
- self.gen.jumpahead(N)
- r1 = self.gen.random()
- # now do it the slow way
- self.gen.setstate(s)
- for i in xrange(N):
- self.gen.random()
- r2 = self.gen.random()
- self.assertEqual(r1, r2)
-
- def test_gauss_with_whseed(self):
- # Ensure that the seed() method initializes all the hidden state. In
- # particular, through 2.2.1 it failed to reset a piece of state used
- # by (and only by) the .gauss() method.
-
- for seed in 1, 12, 123, 1234, 12345, 123456, 654321:
- self.gen.whseed(seed)
- x1 = self.gen.random()
- y1 = self.gen.gauss(0, 1)
+ self.assertEqual(int(r.random()*1000), value)
- self.gen.whseed(seed)
- x2 = self.gen.random()
- y2 = self.gen.gauss(0, 1)
-
- self.assertEqual(x1, x2)
- self.assertEqual(y1, y2)
-
- def test_bigrand(self):
- # Verify warnings are raised when randrange is too large for random()
- with warnings.catch_warnings():
- warnings.filterwarnings("error", "Underlying random")
- self.assertRaises(UserWarning, self.gen.randrange, 2**60)
+ def test_bug_9025(self):
+ # Had problem with an uneven distribution in int(n*random())
+ # Verify the fix by checking that distributions fall within expectations.
+ n = 100000
+ randrange = self.gen.randrange
+ k = sum(randrange(6755399441055744) % 3 == 2 for i in range(n))
+ self.assertTrue(0.30 < k/n < .37, (k/n))
class SystemRandom_TestBasicOps(TestBasicOps):
gen = random.SystemRandom()
@@ -218,10 +153,6 @@ class SystemRandom_TestBasicOps(TestBasicOps):
# Doesn't need to do anything except not fail
self.gen.seed(100)
- def test_jumpahead(self):
- # Doesn't need to do anything except not fail
- self.gen.jumpahead(100)
-
def test_gauss(self):
self.gen.gauss_next = None
self.gen.seed(100)
@@ -234,7 +165,7 @@ class SystemRandom_TestBasicOps(TestBasicOps):
# This should pass whenever a C double has 53 bit precision.
span = 2 ** 53
cum = 0
- for i in xrange(100):
+ for i in range(100):
cum |= int(self.gen.random() * span)
self.assertEqual(cum, span-1)
@@ -243,7 +174,7 @@ class SystemRandom_TestBasicOps(TestBasicOps):
# in stages so that all bit positions are active.
span = 2 ** 500
cum = 0
- for i in xrange(100):
+ for i in range(100):
r = self.gen.randrange(span)
self.assertTrue(0 <= r < span)
cum |= r
@@ -260,18 +191,18 @@ class SystemRandom_TestBasicOps(TestBasicOps):
def test_rangelimits(self):
for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]:
self.assertEqual(set(range(start,stop)),
- set([self.gen.randrange(start,stop) for i in xrange(100)]))
+ set([self.gen.randrange(start,stop) for i in range(100)]))
def test_genrandbits(self):
# Verify ranges
- for k in xrange(1, 1000):
+ for k in range(1, 1000):
self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
# Verify all bits active
getbits = self.gen.getrandbits
for span in [1, 2, 3, 4, 31, 32, 32, 52, 53, 54, 119, 127, 128, 129]:
cum = 0
- for i in xrange(100):
+ for i in range(100):
cum |= getbits(span)
self.assertEqual(cum, 2**span-1)
@@ -286,12 +217,12 @@ class SystemRandom_TestBasicOps(TestBasicOps):
# check bitcount transition points: 2**i and 2**(i+1)-1
# show that: k = int(1.001 + _log(n, 2))
# is equal to or one greater than the number of bits in n
- for i in xrange(1, 1000):
- n = 1L << i # check an exact power of two
+ for i in range(1, 1000):
+ n = 1 << i # check an exact power of two
numbits = i+1
k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits)
- self.assertTrue(n == 2**(k-1))
+ self.assertEqual(n, 2**(k-1))
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
@@ -307,6 +238,17 @@ class SystemRandom_TestBasicOps(TestBasicOps):
class MersenneTwister_TestBasicOps(TestBasicOps):
gen = random.Random()
+ def test_guaranteed_stable(self):
+ # These sequences are guaranteed to stay the same across versions of python
+ self.gen.seed(3456147, version=1)
+ self.assertEqual([self.gen.random().hex() for i in range(4)],
+ ['0x1.ac362300d90d2p-1', '0x1.9d16f74365005p-1',
+ '0x1.1ebb4352e4c4dp-1', '0x1.1a7422abf9c11p-1'])
+ self.gen.seed("the quick brown fox", version=2)
+ self.assertEqual([self.gen.random().hex() for i in range(4)],
+ ['0x1.1239ddfb11b7cp-3', '0x1.b3cbb5c51b120p-4',
+ '0x1.8c4f55116b60fp-1', '0x1.63eb525174a27p-1'])
+
def test_setstate_first_arg(self):
self.assertRaises(ValueError, self.gen.setstate, (1, None, None))
@@ -346,7 +288,7 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
0.089215024911993401,
0.78486196105372907]
- self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96))
+ self.gen.seed(61731 + (24903<<32) + (614<<64) + (42143<<96))
actual = self.randomlist(2000)[-10:]
for a, e in zip(actual, expected):
self.assertAlmostEqual(a,e,places=14)
@@ -358,20 +300,20 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
# no rounding errors -- all results are exact).
from math import ldexp
- expected = [0x0eab3258d2231fL,
- 0x1b89db315277a5L,
- 0x1db622a5518016L,
- 0x0b7f9af0d575bfL,
- 0x029e4c4db82240L,
- 0x04961892f5d673L,
- 0x02b291598e4589L,
- 0x11388382c15694L,
- 0x02dad977c9e1feL,
- 0x191d96d4d334c6L]
- self.gen.seed(61731L + (24903L<<32) + (614L<<64) + (42143L<<96))
+ expected = [0x0eab3258d2231f,
+ 0x1b89db315277a5,
+ 0x1db622a5518016,
+ 0x0b7f9af0d575bf,
+ 0x029e4c4db82240,
+ 0x04961892f5d673,
+ 0x02b291598e4589,
+ 0x11388382c15694,
+ 0x02dad977c9e1fe,
+ 0x191d96d4d334c6]
+ self.gen.seed(61731 + (24903<<32) + (614<<64) + (42143<<96))
actual = self.randomlist(2000)[-10:]
for a, e in zip(actual, expected):
- self.assertEqual(long(ldexp(a, 53)), e)
+ self.assertEqual(int(ldexp(a, 53)), e)
def test_long_seed(self):
# This is most interesting to run in debug mode, just to make sure
@@ -379,14 +321,14 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
# is allocated, consuming space proportional to the number of bits
# in the seed. Unfortunately, that's a quadratic-time algorithm,
# so don't make this horribly big.
- seed = (1L << (10000 * 8)) - 1 # about 10K bytes
+ seed = (1 << (10000 * 8)) - 1 # about 10K bytes
self.gen.seed(seed)
def test_53_bits_per_float(self):
# This should pass whenever a C double has 53 bit precision.
span = 2 ** 53
cum = 0
- for i in xrange(100):
+ for i in range(100):
cum |= int(self.gen.random() * span)
self.assertEqual(cum, span-1)
@@ -395,7 +337,7 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
# in stages so that all bit positions are active.
span = 2 ** 500
cum = 0
- for i in xrange(100):
+ for i in range(100):
r = self.gen.randrange(span)
self.assertTrue(0 <= r < span)
cum |= r
@@ -412,22 +354,22 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
def test_rangelimits(self):
for start, stop in [(-2,0), (-(2**60)-2,-(2**60)), (2**60,2**60+2)]:
self.assertEqual(set(range(start,stop)),
- set([self.gen.randrange(start,stop) for i in xrange(100)]))
+ set([self.gen.randrange(start,stop) for i in range(100)]))
def test_genrandbits(self):
# Verify cross-platform repeatability
self.gen.seed(1234567)
self.assertEqual(self.gen.getrandbits(100),
- 97904845777343510404718956115L)
+ 97904845777343510404718956115)
# Verify ranges
- for k in xrange(1, 1000):
+ for k in range(1, 1000):
self.assertTrue(0 <= self.gen.getrandbits(k) < 2**k)
# Verify all bits active
getbits = self.gen.getrandbits
for span in [1, 2, 3, 4, 31, 32, 32, 52, 53, 54, 119, 127, 128, 129]:
cum = 0
- for i in xrange(100):
+ for i in range(100):
cum |= getbits(span)
self.assertEqual(cum, 2**span-1)
@@ -442,12 +384,12 @@ class MersenneTwister_TestBasicOps(TestBasicOps):
# check bitcount transition points: 2**i and 2**(i+1)-1
# show that: k = int(1.001 + _log(n, 2))
# is equal to or one greater than the number of bits in n
- for i in xrange(1, 1000):
- n = 1L << i # check an exact power of two
+ for i in range(1, 1000):
+ n = 1 << i # check an exact power of two
numbits = i+1
k = int(1.00001 + _log(n, 2))
self.assertEqual(k, numbits)
- self.assertTrue(n == 2**(k-1))
+ self.assertEqual(n, 2**(k-1))
n += n - 1 # check 1 below the next power of two
k = int(1.00001 + _log(n, 2))
@@ -489,7 +431,7 @@ class TestDistributions(unittest.TestCase):
def test_zeroinputs(self):
# Verify that distributions can handle a series of zero inputs'
g = random.Random()
- x = [g.random() for i in xrange(50)] + [0.0]*5
+ x = [g.random() for i in range(50)] + [0.0]*5
g.random = x[:].pop; g.uniform(1,10)
g.random = x[:].pop; g.paretovariate(1.0)
g.random = x[:].pop; g.expovariate(1.0)
@@ -509,7 +451,7 @@ class TestDistributions(unittest.TestCase):
# Only works for distributions which do not consume variates in pairs
g = random.Random()
N = 5000
- x = [i/float(N) for i in xrange(1,N)]
+ x = [i/float(N) for i in range(1,N)]
for variate, args, mu, sigmasqrd in [
(g.uniform, (1.0,10.0), (10.0+1.0)/2, (10.0-1.0)**2/12),
(g.triangular, (0.0, 1.0, 1.0/3.0), 4.0/9.0, 7.0/9.0/18.0),
@@ -520,7 +462,7 @@ class TestDistributions(unittest.TestCase):
gamma(1+2/3.0)-gamma(1+1/3.0)**2) ]:
g.random = x[:].pop
y = []
- for i in xrange(len(x)):
+ for i in range(len(x)):
try:
y.append(variate(*args))
except IndexError:
@@ -530,8 +472,8 @@ class TestDistributions(unittest.TestCase):
s1 += e
s2 += (e - mu) ** 2
N = len(y)
- self.assertAlmostEqual(s1/N, mu, 2)
- self.assertAlmostEqual(s2/(N-1), sigmasqrd, 2)
+ self.assertAlmostEqual(s1/N, mu, places=2)
+ self.assertAlmostEqual(s2/(N-1), sigmasqrd, places=2)
class TestModule(unittest.TestCase):
def testMagicConstants(self):
@@ -553,8 +495,7 @@ class TestModule(unittest.TestCase):
def test_main(verbose=None):
- testclasses = [WichmannHill_TestBasicOps,
- MersenneTwister_TestBasicOps,
+ testclasses = [MersenneTwister_TestBasicOps,
TestDistributions,
TestModule]
@@ -565,16 +506,16 @@ def test_main(verbose=None):
else:
testclasses.append(SystemRandom_TestBasicOps)
- test_support.run_unittest(*testclasses)
+ support.run_unittest(*testclasses)
# verify reference counting
import sys
if verbose and hasattr(sys, "gettotalrefcount"):
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*testclasses)
+ for i in range(len(counts)):
+ support.run_unittest(*testclasses)
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_range.py b/Lib/test/test_range.py
new file mode 100644
index 00000000000..4dab448d5a0
--- /dev/null
+++ b/Lib/test/test_range.py
@@ -0,0 +1,524 @@
+# Python test set -- built-in functions
+
+import test.support, unittest
+import sys
+import pickle
+import itertools
+
+# pure Python implementations (3 args only), for comparison
+def pyrange(start, stop, step):
+ if (start - stop) // step < 0:
+ # replace stop with next element in the sequence of integers
+ # that are congruent to start modulo step.
+ stop += (start - stop) % step
+ while start != stop:
+ yield start
+ start += step
+
+def pyrange_reversed(start, stop, step):
+ stop += (start - stop) % step
+ return pyrange(stop - step, start - step, -step)
+
+
+class RangeTest(unittest.TestCase):
+ def assert_iterators_equal(self, xs, ys, test_id, limit=None):
+ # check that an iterator xs matches the expected results ys,
+ # up to a given limit.
+ if limit is not None:
+ xs = itertools.islice(xs, limit)
+ ys = itertools.islice(ys, limit)
+ sentinel = object()
+ pairs = itertools.zip_longest(xs, ys, fillvalue=sentinel)
+ for i, (x, y) in enumerate(pairs):
+ if x == y:
+ continue
+ elif x == sentinel:
+ self.fail('{}: iterator ended unexpectedly '
+ 'at position {}; expected {}'.format(test_id, i, y))
+ elif y == sentinel:
+ self.fail('{}: unexpected excess element {} at '
+ 'position {}'.format(test_id, x, i))
+ else:
+ self.fail('{}: wrong element at position {};'
+ 'expected {}, got {}'.format(test_id, i, y, x))
+
+ def test_range(self):
+ self.assertEqual(list(range(3)), [0, 1, 2])
+ self.assertEqual(list(range(1, 5)), [1, 2, 3, 4])
+ self.assertEqual(list(range(0)), [])
+ self.assertEqual(list(range(-3)), [])
+ self.assertEqual(list(range(1, 10, 3)), [1, 4, 7])
+ self.assertEqual(list(range(5, -5, -3)), [5, 2, -1, -4])
+
+ a = 10
+ b = 100
+ c = 50
+
+ self.assertEqual(list(range(a, a+2)), [a, a+1])
+ self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
+ self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
+
+ seq = list(range(a, b, c))
+ self.assertIn(a, seq)
+ self.assertNotIn(b, seq)
+ self.assertEqual(len(seq), 2)
+
+ seq = list(range(b, a, -c))
+ self.assertIn(b, seq)
+ self.assertNotIn(a, seq)
+ self.assertEqual(len(seq), 2)
+
+ seq = list(range(-a, -b, -c))
+ self.assertIn(-a, seq)
+ self.assertNotIn(-b, seq)
+ self.assertEqual(len(seq), 2)
+
+ self.assertRaises(TypeError, range)
+ self.assertRaises(TypeError, range, 1, 2, 3, 4)
+ self.assertRaises(ValueError, range, 1, 2, 0)
+
+ self.assertRaises(TypeError, range, 0.0, 2, 1)
+ self.assertRaises(TypeError, range, 1, 2.0, 1)
+ self.assertRaises(TypeError, range, 1, 2, 1.0)
+ self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
+
+ self.assertRaises(TypeError, range, 0, "spam")
+ self.assertRaises(TypeError, range, 0, 42, "spam")
+
+ self.assertEqual(len(range(0, sys.maxsize, sys.maxsize-1)), 2)
+
+ r = range(-sys.maxsize, sys.maxsize, 2)
+ self.assertEqual(len(r), sys.maxsize)
+
+ def test_large_operands(self):
+ x = range(10**20, 10**20+10, 3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
+ x = range(10**20+10, 10**20, 3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20, 10**20+10, -3)
+ self.assertEqual(len(x), 0)
+ self.assertEqual(len(list(x)), 0)
+
+ x = range(10**20+10, 10**20, -3)
+ self.assertEqual(len(x), 4)
+ self.assertEqual(len(list(x)), 4)
+
+ # Now test range() with longs
+ self.assertEqual(list(range(-2**100)), [])
+ self.assertEqual(list(range(0, -2**100)), [])
+ self.assertEqual(list(range(0, 2**100, -1)), [])
+ self.assertEqual(list(range(0, 2**100, -1)), [])
+
+ a = int(10 * sys.maxsize)
+ b = int(100 * sys.maxsize)
+ c = int(50 * sys.maxsize)
+
+ self.assertEqual(list(range(a, a+2)), [a, a+1])
+ self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1])
+ self.assertEqual(list(range(a+4, a, -2)), [a+4, a+2])
+
+ seq = list(range(a, b, c))
+ self.assertIn(a, seq)
+ self.assertNotIn(b, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], a)
+ self.assertEqual(seq[-1], a+c)
+
+ seq = list(range(b, a, -c))
+ self.assertIn(b, seq)
+ self.assertNotIn(a, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], b)
+ self.assertEqual(seq[-1], b-c)
+
+ seq = list(range(-a, -b, -c))
+ self.assertIn(-a, seq)
+ self.assertNotIn(-b, seq)
+ self.assertEqual(len(seq), 2)
+ self.assertEqual(seq[0], -a)
+ self.assertEqual(seq[-1], -a-c)
+
+ def test_large_range(self):
+ # Check long ranges (len > sys.maxsize)
+ # len() is expected to fail due to limitations of the __len__ protocol
+ def _range_len(x):
+ try:
+ length = len(x)
+ except OverflowError:
+ step = x[1] - x[0]
+ length = 1 + ((x[-1] - x[0]) // step)
+ return length
+ a = -sys.maxsize
+ b = sys.maxsize
+ expected_len = b - a
+ x = range(a, b)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+idx)
+ self.assertEqual(x[idx:idx+1][0], a+idx)
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = 0
+ b = 2 * sys.maxsize
+ expected_len = b - a
+ x = range(a, b)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+idx)
+ self.assertEqual(x[idx:idx+1][0], a+idx)
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = 0
+ b = sys.maxsize**10
+ c = 2*sys.maxsize
+ expected_len = 1 + (b - a) // c
+ x = range(a, b, c)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+(idx*c))
+ self.assertEqual(x[idx:idx+1][0], a+(idx*c))
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ a = sys.maxsize**10
+ b = 0
+ c = -2*sys.maxsize
+ expected_len = 1 + (b - a) // c
+ x = range(a, b, c)
+ self.assertIn(a, x)
+ self.assertNotIn(b, x)
+ self.assertRaises(OverflowError, len, x)
+ self.assertEqual(_range_len(x), expected_len)
+ self.assertEqual(x[0], a)
+ idx = sys.maxsize+1
+ self.assertEqual(x[idx], a+(idx*c))
+ self.assertEqual(x[idx:idx+1][0], a+(idx*c))
+ with self.assertRaises(IndexError):
+ x[-expected_len-1]
+ with self.assertRaises(IndexError):
+ x[expected_len]
+
+ def test_invalid_invocation(self):
+ self.assertRaises(TypeError, range)
+ self.assertRaises(TypeError, range, 1, 2, 3, 4)
+ self.assertRaises(ValueError, range, 1, 2, 0)
+ a = int(10 * sys.maxsize)
+ self.assertRaises(ValueError, range, a, a + 1, int(0))
+ self.assertRaises(TypeError, range, 1., 1., 1.)
+ self.assertRaises(TypeError, range, 1e100, 1e101, 1e101)
+ self.assertRaises(TypeError, range, 0, "spam")
+ self.assertRaises(TypeError, range, 0, 42, "spam")
+ # Exercise various combinations of bad arguments, to check
+ # refcounting logic
+ self.assertRaises(TypeError, range, 0.0)
+ self.assertRaises(TypeError, range, 0, 0.0)
+ self.assertRaises(TypeError, range, 0.0, 0)
+ self.assertRaises(TypeError, range, 0.0, 0.0)
+ self.assertRaises(TypeError, range, 0, 0, 1.0)
+ self.assertRaises(TypeError, range, 0, 0.0, 1)
+ self.assertRaises(TypeError, range, 0, 0.0, 1.0)
+ self.assertRaises(TypeError, range, 0.0, 0, 1)
+ self.assertRaises(TypeError, range, 0.0, 0, 1.0)
+ self.assertRaises(TypeError, range, 0.0, 0.0, 1)
+ self.assertRaises(TypeError, range, 0.0, 0.0, 1.0)
+
+ def test_index(self):
+ u = range(2)
+ self.assertEqual(u.index(0), 0)
+ self.assertEqual(u.index(1), 1)
+ self.assertRaises(ValueError, u.index, 2)
+
+ u = range(-2, 3)
+ self.assertEqual(u.count(0), 1)
+ self.assertEqual(u.index(0), 2)
+ self.assertRaises(TypeError, u.index)
+
+ class BadExc(Exception):
+ pass
+
+ class BadCmp:
+ def __eq__(self, other):
+ if other == 2:
+ raise BadExc()
+ return False
+
+ a = range(4)
+ self.assertRaises(BadExc, a.index, BadCmp())
+
+ a = range(-2, 3)
+ self.assertEqual(a.index(0), 2)
+ self.assertEqual(range(1, 10, 3).index(4), 1)
+ self.assertEqual(range(1, -10, -3).index(-5), 2)
+
+ self.assertEqual(range(10**20).index(1), 1)
+ self.assertEqual(range(10**20).index(10**20 - 1), 10**20 - 1)
+
+ self.assertRaises(ValueError, range(1, 2**100, 2).index, 2**87)
+ self.assertEqual(range(1, 2**100, 2).index(2**87+1), 2**86)
+
+ class AlwaysEqual(object):
+ def __eq__(self, other):
+ return True
+ always_equal = AlwaysEqual()
+ self.assertEqual(range(10).index(always_equal), 0)
+
+ def test_user_index_method(self):
+ bignum = 2*sys.maxsize
+ smallnum = 42
+
+ # User-defined class with an __index__ method
+ class I:
+ def __init__(self, n):
+ self.n = int(n)
+ def __index__(self):
+ return self.n
+ self.assertEqual(list(range(I(bignum), I(bignum + 1))), [bignum])
+ self.assertEqual(list(range(I(smallnum), I(smallnum + 1))), [smallnum])
+
+ # User-defined class with a failing __index__ method
+ class IX:
+ def __index__(self):
+ raise RuntimeError
+ self.assertRaises(RuntimeError, range, IX())
+
+ # User-defined class with an invalid __index__ method
+ class IN:
+ def __index__(self):
+ return "not a number"
+
+ self.assertRaises(TypeError, range, IN())
+
+ # Test use of user-defined classes in slice indices.
+ self.assertEqual(list(range(10)[:I(5)]), list(range(5)))
+
+ with self.assertRaises(RuntimeError):
+ range(0, 10)[:IX()]
+
+ with self.assertRaises(TypeError):
+ range(0, 10)[:IN()]
+
+ def test_count(self):
+ self.assertEqual(range(3).count(-1), 0)
+ self.assertEqual(range(3).count(0), 1)
+ self.assertEqual(range(3).count(1), 1)
+ self.assertEqual(range(3).count(2), 1)
+ self.assertEqual(range(3).count(3), 0)
+ self.assertIs(type(range(3).count(-1)), int)
+ self.assertIs(type(range(3).count(1)), int)
+ self.assertEqual(range(10**20).count(1), 1)
+ self.assertEqual(range(10**20).count(10**20), 0)
+ self.assertEqual(range(3).index(1), 1)
+ self.assertEqual(range(1, 2**100, 2).count(2**87), 0)
+ self.assertEqual(range(1, 2**100, 2).count(2**87+1), 1)
+
+ class AlwaysEqual(object):
+ def __eq__(self, other):
+ return True
+ always_equal = AlwaysEqual()
+ self.assertEqual(range(10).count(always_equal), 10)
+
+ self.assertEqual(len(range(sys.maxsize, sys.maxsize+10)), 10)
+
+ def test_repr(self):
+ self.assertEqual(repr(range(1)), 'range(0, 1)')
+ self.assertEqual(repr(range(1, 2)), 'range(1, 2)')
+ self.assertEqual(repr(range(1, 2, 3)), 'range(1, 2, 3)')
+
+ def test_pickling(self):
+ testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
+ (13, 21, 3), (-2, 2, 2)]
+ for proto in range(pickle.HIGHEST_PROTOCOL + 1):
+ for t in testcases:
+ r = range(*t)
+ self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))),
+ list(r))
+
+ def test_odd_bug(self):
+ # This used to raise a "SystemError: NULL result without error"
+ # because the range validation step was eating the exception
+ # before NULL was returned.
+ with self.assertRaises(TypeError):
+ range([], 1, -1)
+
+ def test_types(self):
+ # Non-integer objects *equal* to any of the range's items are supposed
+ # to be contained in the range.
+ self.assertIn(1.0, range(3))
+ self.assertIn(True, range(3))
+ self.assertIn(1+0j, range(3))
+
+ class C1:
+ def __eq__(self, other): return True
+ self.assertIn(C1(), range(3))
+
+ # Objects are never coerced into other types for comparison.
+ class C2:
+ def __int__(self): return 1
+ def __index__(self): return 1
+ self.assertNotIn(C2(), range(3))
+ # ..except if explicitly told so.
+ self.assertIn(int(C2()), range(3))
+
+ # Check that the range.__contains__ optimization is only
+ # used for ints, not for instances of subclasses of int.
+ class C3(int):
+ def __eq__(self, other): return True
+ self.assertIn(C3(11), range(10))
+ self.assertIn(C3(11), list(range(10)))
+
+ def test_strided_limits(self):
+ r = range(0, 101, 2)
+ self.assertIn(0, r)
+ self.assertNotIn(1, r)
+ self.assertIn(2, r)
+ self.assertNotIn(99, r)
+ self.assertIn(100, r)
+ self.assertNotIn(101, r)
+
+ r = range(0, -20, -1)
+ self.assertIn(0, r)
+ self.assertIn(-1, r)
+ self.assertIn(-19, r)
+ self.assertNotIn(-20, r)
+
+ r = range(0, -20, -2)
+ self.assertIn(-18, r)
+ self.assertNotIn(-19, r)
+ self.assertNotIn(-20, r)
+
+ def test_empty(self):
+ r = range(0)
+ self.assertNotIn(0, r)
+ self.assertNotIn(1, r)
+
+ r = range(0, -10)
+ self.assertNotIn(0, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(1, r)
+
+ def test_range_iterators(self):
+ # exercise 'fast' iterators, that use a rangeiterobject internally.
+ # see issue 7298
+ limits = [base + jiggle
+ for M in (2**32, 2**64)
+ for base in (-M, -M//2, 0, M//2, M)
+ for jiggle in (-2, -1, 0, 1, 2)]
+ test_ranges = [(start, end, step)
+ for start in limits
+ for end in limits
+ for step in (-2**63, -2**31, -2, -1, 1, 2)]
+
+ for start, end, step in test_ranges:
+ iter1 = range(start, end, step)
+ iter2 = pyrange(start, end, step)
+ test_id = "range({}, {}, {})".format(start, end, step)
+ # check first 100 entries
+ self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
+
+ iter1 = reversed(range(start, end, step))
+ iter2 = pyrange_reversed(start, end, step)
+ test_id = "reversed(range({}, {}, {}))".format(start, end, step)
+ self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
+
+ def test_slice(self):
+ def check(start, stop, step=None):
+ i = slice(start, stop, step)
+ self.assertEqual(list(r[i]), list(r)[i])
+ self.assertEqual(len(r[i]), len(list(r)[i]))
+ for r in [range(10),
+ range(0),
+ range(1, 9, 3),
+ range(8, 0, -3),
+ range(sys.maxsize+1, sys.maxsize+10),
+ ]:
+ check(0, 2)
+ check(0, 20)
+ check(1, 2)
+ check(20, 30)
+ check(-30, -20)
+ check(-1, 100, 2)
+ check(0, -1)
+ check(-1, -3, -1)
+
+ def test_contains(self):
+ r = range(10)
+ self.assertIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(9, -1, -1)
+ self.assertIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(0, 10, 2)
+ self.assertIn(0, r)
+ self.assertNotIn(1, r)
+ self.assertNotIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+ r = range(9, -1, -2)
+ self.assertNotIn(0, r)
+ self.assertIn(1, r)
+ self.assertIn(5.0, r)
+ self.assertNotIn(5.1, r)
+ self.assertNotIn(-1, r)
+ self.assertNotIn(10, r)
+ self.assertNotIn("", r)
+
+ def test_reverse_iteration(self):
+ for r in [range(10),
+ range(0),
+ range(1, 9, 3),
+ range(8, 0, -3),
+ range(sys.maxsize+1, sys.maxsize+10),
+ ]:
+ self.assertEqual(list(reversed(r)), list(r)[::-1])
+
+ def test_issue11845(self):
+ r = range(*slice(1, 18, 2).indices(20))
+ values = {None, 0, 1, -1, 2, -2, 5, -5, 19, -19,
+ 20, -20, 21, -21, 30, -30, 99, -99}
+ for i in values:
+ for j in values:
+ for k in values - {0}:
+ r[i:j:k]
+
+
+def test_main():
+ test.support.run_unittest(RangeTest)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 70702e63483..0c8c676ed8b 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,5 +1,5 @@
-from test.test_support import verbose, run_unittest, import_module
-from test.test_support import precisionbigmemtest, _2G
+from test.support import verbose, run_unittest, gc_collect, bigmemtest, _2G
+import io
import re
from re import Scanner
import sys
@@ -7,6 +7,8 @@ import string
import traceback
from weakref import proxy
+from test.test_bigmem import character_size
+
# Misc tests from Tim Peters' re.doc
@@ -18,6 +20,17 @@ import unittest
class ReTests(unittest.TestCase):
+ def test_keep_buffer(self):
+ # See bug 14212
+ b = bytearray(b'x')
+ it = re.finditer(b'a', b)
+ with self.assertRaises(BufferError):
+ b.extend(b'x'*400)
+ list(it)
+ del it
+ gc_collect()
+ b.extend(b'x'*400)
+
def test_weakref(self):
s = 'QabbbcR'
x = re.compile('ab+c')
@@ -84,31 +97,6 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.sub('\r\n', '\n', 'abc\r\ndef\r\n'),
'abc\ndef\n')
- def test_bug_1140(self):
- # re.sub(x, y, u'') should return u'', not '', and
- # re.sub(x, y, '') should return '', not u''.
- # Also:
- # re.sub(x, y, unicode(x)) should return unicode(y), and
- # re.sub(x, y, str(x)) should return
- # str(y) if isinstance(y, str) else unicode(y).
- for x in 'x', u'x':
- for y in 'y', u'y':
- z = re.sub(x, y, u'')
- self.assertEqual(z, u'')
- self.assertEqual(type(z), unicode)
- #
- z = re.sub(x, y, '')
- self.assertEqual(z, '')
- self.assertEqual(type(z), str)
- #
- z = re.sub(x, y, unicode(x))
- self.assertEqual(z, y)
- self.assertEqual(type(z), unicode)
- #
- z = re.sub(x, y, str(x))
- self.assertEqual(z, y)
- self.assertEqual(type(z), type(y))
-
def test_bug_1661(self):
# Verify that flags do not get silently ignored with compiled patterns
pattern = re.compile('.')
@@ -359,6 +347,13 @@ class ReTests(unittest.TestCase):
self.assertNotEqual(re.match("^x{}$", "x{}"), None)
def test_getattr(self):
+ self.assertEqual(re.compile("(?i)(a)(b)").pattern, "(?i)(a)(b)")
+ self.assertEqual(re.compile("(?i)(a)(b)").flags, re.I | re.U)
+ self.assertEqual(re.compile("(?i)(a)(b)").groups, 2)
+ self.assertEqual(re.compile("(?i)(a)(b)").groupindex, {})
+ self.assertEqual(re.compile("(?i)(?P<first>a)(?P<other>b)").groupindex,
+ {'first': 1, 'other': 2})
+
self.assertEqual(re.match("(a)", "a").pos, 0)
self.assertEqual(re.match("(a)", "a").endpos, 1)
self.assertEqual(re.match("(a)", "a").string, "a")
@@ -382,12 +377,12 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.search(r"^\Aabc\Z$", "abc", re.M).group(0), "abc")
self.assertEqual(re.search(r"^\Aabc\Z$", "\nabc\n", re.M), None)
self.assertEqual(re.search(r"\b(b.)\b",
- u"abcd abc bcd bx").group(1), "bx")
+ "abcd abc bcd bx").group(1), "bx")
self.assertEqual(re.search(r"\B(b.)\B",
- u"abc bcd bc abxd").group(1), "bx")
- self.assertEqual(re.search(r"^abc$", u"\nabc\n", re.M).group(0), "abc")
- self.assertEqual(re.search(r"^\Aabc\Z$", u"abc", re.M).group(0), "abc")
- self.assertEqual(re.search(r"^\Aabc\Z$", u"\nabc\n", re.M), None)
+ "abc bcd bc abxd").group(1), "bx")
+ self.assertEqual(re.search(r"^abc$", "\nabc\n", re.M).group(0), "abc")
+ self.assertEqual(re.search(r"^\Aabc\Z$", "abc", re.M).group(0), "abc")
+ self.assertEqual(re.search(r"^\Aabc\Z$", "\nabc\n", re.M), None)
self.assertEqual(re.search(r"\d\D\w\W\s\S",
"1aa! a").group(0), "1aa! a")
self.assertEqual(re.search(r"\d\D\w\W\s\S",
@@ -422,10 +417,10 @@ class ReTests(unittest.TestCase):
self.assertEqual(len(re.findall(r"\B", " ")), 2)
def test_bigcharset(self):
- self.assertEqual(re.match(u"([\u2222\u2223])",
- u"\u2222").group(1), u"\u2222")
- self.assertEqual(re.match(u"([\u2222\u2223])",
- u"\u2222", re.UNICODE).group(1), u"\u2222")
+ self.assertEqual(re.match("([\u2222\u2223])",
+ "\u2222").group(1), "\u2222")
+ self.assertEqual(re.match("([\u2222\u2223])",
+ "\u2222", re.UNICODE).group(1), "\u2222")
def test_big_codesize(self):
# Issue #1160
@@ -455,7 +450,7 @@ class ReTests(unittest.TestCase):
def test_ignore_case(self):
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
- self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC")
+ self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
self.assertEqual(re.match(r"(a\s[^a])", "a b", re.I).group(1), "a b")
self.assertEqual(re.match(r"(a\s[^a]*)", "a bb", re.I).group(1), "a bb")
self.assertEqual(re.match(r"(a\s[abc])", "a b", re.I).group(1), "a b")
@@ -475,7 +470,7 @@ class ReTests(unittest.TestCase):
self.assertEqual(_sre.getlower(ord('A'), re.UNICODE), ord('a'))
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
- self.assertEqual(re.match("abc", u"ABC", re.I).group(0), "ABC")
+ self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
def test_not_literal(self):
self.assertEqual(re.search("\s([^a])", " b").group(1), "b")
@@ -501,24 +496,25 @@ class ReTests(unittest.TestCase):
def test_re_escape(self):
alnum_chars = string.ascii_letters + string.digits
- p = u''.join(unichr(i) for i in range(256))
+ p = ''.join(chr(i) for i in range(256))
for c in p:
if c in alnum_chars:
self.assertEqual(re.escape(c), c)
- elif c == u'\x00':
- self.assertEqual(re.escape(c), u'\\000')
+ elif c == '\x00':
+ self.assertEqual(re.escape(c), '\\000')
else:
- self.assertEqual(re.escape(c), u'\\' + c)
+ self.assertEqual(re.escape(c), '\\' + c)
self.assertMatch(re.escape(c), c)
self.assertMatch(re.escape(p), p)
def test_re_escape_byte(self):
alnum_chars = (string.ascii_letters + string.digits).encode('ascii')
- p = ''.join(chr(i) for i in range(256))
- for b in p:
+ p = bytes(range(256))
+ for i in p:
+ b = bytes([i])
if b in alnum_chars:
self.assertEqual(re.escape(b), b)
- elif b == b'\x00':
+ elif i == 0:
self.assertEqual(re.escape(b), b'\\000')
else:
self.assertEqual(re.escape(b), b'\\' + b)
@@ -526,30 +522,21 @@ class ReTests(unittest.TestCase):
self.assertMatch(re.escape(p), p)
def test_re_escape_non_ascii(self):
- s = u'xxx\u2620\u2620\u2620xxx'
+ s = 'xxx\u2620\u2620\u2620xxx'
s_escaped = re.escape(s)
- self.assertEqual(s_escaped, u'xxx\\\u2620\\\u2620\\\u2620xxx')
+ self.assertEqual(s_escaped, 'xxx\\\u2620\\\u2620\\\u2620xxx')
self.assertMatch(s_escaped, s)
- self.assertMatch(u'.%s+.' % re.escape(u'\u2620'), s,
- u'x\u2620\u2620\u2620x', (2, 7), re.search)
+ self.assertMatch('.%s+.' % re.escape('\u2620'), s,
+ 'x\u2620\u2620\u2620x', (2, 7), re.search)
def test_re_escape_non_ascii_bytes(self):
- b = u'y\u2620y\u2620y'.encode('utf-8')
+ b = 'y\u2620y\u2620y'.encode('utf-8')
b_escaped = re.escape(b)
self.assertEqual(b_escaped, b'y\\\xe2\\\x98\\\xa0y\\\xe2\\\x98\\\xa0y')
self.assertMatch(b_escaped, b)
- res = re.findall(re.escape(u'\u2620'.encode('utf-8')), b)
+ res = re.findall(re.escape('\u2620'.encode('utf-8')), b)
self.assertEqual(len(res), 2)
- def test_pickling(self):
- import pickle
- self.pickle_test(pickle)
- import cPickle
- self.pickle_test(cPickle)
- # old pickles expect the _compile() reconstructor in sre module
- import_module("sre", deprecated=True)
- from sre import _compile
-
def pickle_test(self, pickle):
oldpat = re.compile('a(?:b|(c|e){1,2}?|d)+?(.)')
s = pickle.dumps(oldpat)
@@ -618,7 +605,7 @@ class ReTests(unittest.TestCase):
self.assertEqual(re.search('(a|b)*?c', 10000*'ab'+'cd').end(0), 20001)
def test_bug_612074(self):
- pat=u"["+re.escape(u"\u2039")+u"]"
+ pat="["+re.escape("\u2039")+"]"
self.assertEqual(re.compile(pat) and 1, 1)
def test_stack_overflow(self):
@@ -685,11 +672,7 @@ class ReTests(unittest.TestCase):
def test_bug_764548(self):
# bug 764548, re.compile() barfs on str/unicode subclasses
- try:
- unicode
- except NameError:
- return # no problem if we have no unicode
- class my_unicode(unicode): pass
+ class my_unicode(str): pass
pat = re.compile(my_unicode("abc"))
self.assertEqual(pat.match("xyz"), None)
@@ -699,26 +682,18 @@ class ReTests(unittest.TestCase):
[":", "::", ":::"])
def test_bug_926075(self):
- try:
- unicode
- except NameError:
- return # no problem if we have no unicode
self.assertTrue(re.compile('bug_926075') is not
- re.compile(eval("u'bug_926075'")))
+ re.compile(b'bug_926075'))
def test_bug_931848(self):
- try:
- unicode
- except NameError:
- pass
- pattern = eval('u"[\u002E\u3002\uFF0E\uFF61]"')
+ pattern = eval('"[\u002E\u3002\uFF0E\uFF61]"')
self.assertEqual(re.compile(pattern).split("a.b.c"),
['a','b','c'])
def test_bug_581080(self):
iter = re.finditer(r"\s", "a b")
- self.assertEqual(iter.next().span(), (1,2))
- self.assertRaises(StopIteration, iter.next)
+ self.assertEqual(next(iter).span(), (1,2))
+ self.assertRaises(StopIteration, next, iter)
scanner = re.compile(r"\s").scanner("a b")
self.assertEqual(scanner.search().span(), (1, 2))
@@ -726,43 +701,43 @@ class ReTests(unittest.TestCase):
def test_bug_817234(self):
iter = re.finditer(r".*", "asdf")
- self.assertEqual(iter.next().span(), (0, 4))
- self.assertEqual(iter.next().span(), (4, 4))
- self.assertRaises(StopIteration, iter.next)
+ self.assertEqual(next(iter).span(), (0, 4))
+ self.assertEqual(next(iter).span(), (4, 4))
+ self.assertRaises(StopIteration, next, iter)
def test_bug_6561(self):
# '\d' should match characters in Unicode category 'Nd'
# (Number, Decimal Digit), but not those in 'Nl' (Number,
# Letter) or 'No' (Number, Other).
decimal_digits = [
- u'\u0037', # '\N{DIGIT SEVEN}', category 'Nd'
- u'\u0e58', # '\N{THAI DIGIT SIX}', category 'Nd'
- u'\uff10', # '\N{FULLWIDTH DIGIT ZERO}', category 'Nd'
+ '\u0037', # '\N{DIGIT SEVEN}', category 'Nd'
+ '\u0e58', # '\N{THAI DIGIT SIX}', category 'Nd'
+ '\uff10', # '\N{FULLWIDTH DIGIT ZERO}', category 'Nd'
]
for x in decimal_digits:
- self.assertEqual(re.match('^\d$', x, re.UNICODE).group(0), x)
+ self.assertEqual(re.match('^\d$', x).group(0), x)
not_decimal_digits = [
- u'\u2165', # '\N{ROMAN NUMERAL SIX}', category 'Nl'
- u'\u3039', # '\N{HANGZHOU NUMERAL TWENTY}', category 'Nl'
- u'\u2082', # '\N{SUBSCRIPT TWO}', category 'No'
- u'\u32b4', # '\N{CIRCLED NUMBER THIRTY NINE}', category 'No'
+ '\u2165', # '\N{ROMAN NUMERAL SIX}', category 'Nl'
+ '\u3039', # '\N{HANGZHOU NUMERAL TWENTY}', category 'Nl'
+ '\u2082', # '\N{SUBSCRIPT TWO}', category 'No'
+ '\u32b4', # '\N{CIRCLED NUMBER THIRTY NINE}', category 'No'
]
for x in not_decimal_digits:
- self.assertIsNone(re.match('^\d$', x, re.UNICODE))
+ self.assertIsNone(re.match('^\d$', x))
def test_empty_array(self):
# SF buf 1647541
import array
- for typecode in 'cbBuhHiIlLfd':
+ for typecode in 'bBuhHiIlLfd':
a = array.array(typecode)
- self.assertEqual(re.compile("bla").match(a), None)
- self.assertEqual(re.compile("").match(a).groups(), ())
+ self.assertEqual(re.compile(b"bla").match(a), None)
+ self.assertEqual(re.compile(b"").match(a).groups(), ())
def test_inline_flags(self):
# Bug #1700
- upper_char = unichr(0x1ea0) # Latin Capital Letter A with Dot Bellow
- lower_char = unichr(0x1ea1) # Latin Small Letter A with Dot Bellow
+ upper_char = chr(0x1ea0) # Latin Capital Letter A with Dot Bellow
+ lower_char = chr(0x1ea1) # Latin Small Letter A with Dot Bellow
p = re.compile(upper_char, re.I | re.U)
q = p.match(lower_char)
@@ -800,6 +775,66 @@ class ReTests(unittest.TestCase):
self.assertEqual(pattern.sub('#', 'a\nb\nc'), 'a#\nb#\nc#')
self.assertEqual(pattern.sub('#', '\n'), '#\n#')
+ def test_bytes_str_mixing(self):
+ # Mixing str and bytes is disallowed
+ pat = re.compile('.')
+ bpat = re.compile(b'.')
+ self.assertRaises(TypeError, pat.match, b'b')
+ self.assertRaises(TypeError, bpat.match, 'b')
+ self.assertRaises(TypeError, pat.sub, b'b', 'c')
+ self.assertRaises(TypeError, pat.sub, 'b', b'c')
+ self.assertRaises(TypeError, pat.sub, b'b', b'c')
+ self.assertRaises(TypeError, bpat.sub, b'b', 'c')
+ self.assertRaises(TypeError, bpat.sub, 'b', b'c')
+ self.assertRaises(TypeError, bpat.sub, 'b', 'c')
+
+ def test_ascii_and_unicode_flag(self):
+ # String patterns
+ for flags in (0, re.UNICODE):
+ pat = re.compile('\xc0', flags | re.IGNORECASE)
+ self.assertNotEqual(pat.match('\xe0'), None)
+ pat = re.compile('\w', flags)
+ self.assertNotEqual(pat.match('\xe0'), None)
+ pat = re.compile('\xc0', re.ASCII | re.IGNORECASE)
+ self.assertEqual(pat.match('\xe0'), None)
+ pat = re.compile('(?a)\xc0', re.IGNORECASE)
+ self.assertEqual(pat.match('\xe0'), None)
+ pat = re.compile('\w', re.ASCII)
+ self.assertEqual(pat.match('\xe0'), None)
+ pat = re.compile('(?a)\w')
+ self.assertEqual(pat.match('\xe0'), None)
+ # Bytes patterns
+ for flags in (0, re.ASCII):
+ pat = re.compile(b'\xc0', re.IGNORECASE)
+ self.assertEqual(pat.match(b'\xe0'), None)
+ pat = re.compile(b'\w')
+ self.assertEqual(pat.match(b'\xe0'), None)
+ # Incompatibilities
+ self.assertRaises(ValueError, re.compile, b'\w', re.UNICODE)
+ self.assertRaises(ValueError, re.compile, b'(?u)\w')
+ self.assertRaises(ValueError, re.compile, '\w', re.UNICODE | re.ASCII)
+ self.assertRaises(ValueError, re.compile, '(?u)\w', re.ASCII)
+ self.assertRaises(ValueError, re.compile, '(?a)\w', re.UNICODE)
+ self.assertRaises(ValueError, re.compile, '(?au)\w')
+
+ def test_bug_6509(self):
+ # Replacement strings of both types must parse properly.
+ # all strings
+ pat = re.compile('a(\w)')
+ self.assertEqual(pat.sub('b\\1', 'ac'), 'bc')
+ pat = re.compile('a(.)')
+ self.assertEqual(pat.sub('b\\1', 'a\u1234'), 'b\u1234')
+ pat = re.compile('..')
+ self.assertEqual(pat.sub(lambda m: 'str', 'a5'), 'str')
+
+ # all bytes
+ pat = re.compile(b'a(\w)')
+ self.assertEqual(pat.sub(b'b\\1', b'ac'), b'bc')
+ pat = re.compile(b'a(.)')
+ self.assertEqual(pat.sub(b'b\\1', b'a\xCD'), b'b\xCD')
+ pat = re.compile(b'..')
+ self.assertEqual(pat.sub(lambda m: b'bytes', b'a5'), b'bytes')
+
def test_dealloc(self):
# issue 3299: check for segfault in debug build
import _sre
@@ -810,6 +845,7 @@ class ReTests(unittest.TestCase):
long_overflow = 2**128
self.assertRaises(TypeError, re.finditer, "a", {})
self.assertRaises(OverflowError, _sre.compile, "abc", 0, [long_overflow])
+ self.assertRaises(TypeError, _sre.compile, {}, 0, [])
def test_compile(self):
# Test return value when given string and pattern as parameter
@@ -821,7 +857,7 @@ class ReTests(unittest.TestCase):
# Test behaviour when not given a string or pattern as parameter
self.assertRaises(TypeError, re.compile, 0)
- @precisionbigmemtest(size=_2G, memuse=1)
+ @bigmemtest(size=_2G, memuse=character_size)
def test_large_search(self, size):
# Issue #10182: indices were 32-bit-truncated.
s = 'a' * size
@@ -832,7 +868,7 @@ class ReTests(unittest.TestCase):
# The huge memuse is because of re.sub() using a list and a join()
# to create the replacement result.
- @precisionbigmemtest(size=_2G, memuse=16 + 2)
+ @bigmemtest(size=_2G, memuse=16 + 2 * character_size)
def test_large_subn(self, size):
# Issue #10182: indices were 32-bit-truncated.
s = 'a' * size
@@ -844,7 +880,7 @@ class ReTests(unittest.TestCase):
def run_re_tests():
from test.re_tests import tests, SUCCEED, FAIL, SYNTAX_ERROR
if verbose:
- print 'Running re_tests test suite'
+ print('Running re_tests test suite')
else:
# To save time, only run the first and last 10 tests
#tests = tests[:10] + tests[-10:]
@@ -858,30 +894,30 @@ def run_re_tests():
elif len(t) == 3:
pattern, s, outcome = t
else:
- raise ValueError, ('Test tuples should have 3 or 5 fields', t)
+ raise ValueError('Test tuples should have 3 or 5 fields', t)
try:
obj = re.compile(pattern)
except re.error:
if outcome == SYNTAX_ERROR: pass # Expected a syntax error
else:
- print '=== Syntax error:', t
+ print('=== Syntax error:', t)
except KeyboardInterrupt: raise KeyboardInterrupt
except:
- print '*** Unexpected error ***', t
+ print('*** Unexpected error ***', t)
if verbose:
traceback.print_exc(file=sys.stdout)
else:
try:
result = obj.search(s)
- except re.error, msg:
- print '=== Unexpected exception', t, repr(msg)
+ except re.error as msg:
+ print('=== Unexpected exception', t, repr(msg))
if outcome == SYNTAX_ERROR:
# This should have been a syntax error; forget it.
pass
elif outcome == FAIL:
if result is None: pass # No match, as expected
- else: print '=== Succeeded incorrectly', t
+ else: print('=== Succeeded incorrectly', t)
elif outcome == SUCCEED:
if result is not None:
# Matched, as expected, so now we compute the
@@ -909,28 +945,30 @@ def run_re_tests():
vardict[i] = gi
repl = eval(repl, vardict)
if repl != expected:
- print '=== grouping error', t,
- print repr(repl) + ' should be ' + repr(expected)
+ print('=== grouping error', t, end=' ')
+ print(repr(repl) + ' should be ' + repr(expected))
else:
- print '=== Failed incorrectly', t
+ print('=== Failed incorrectly', t)
- # Try the match on a unicode string, and check that it
- # still succeeds.
+ # Try the match with both pattern and string converted to
+ # bytes, and check that it still succeeds.
try:
- result = obj.search(unicode(s, "latin-1"))
- if result is None:
- print '=== Fails on unicode match', t
- except NameError:
- continue # 1.5.2
- except TypeError:
- continue # unicode test case
-
- # Try the match on a unicode pattern, and check that it
- # still succeeds.
- obj=re.compile(unicode(pattern, "latin-1"))
- result = obj.search(s)
- if result is None:
- print '=== Fails on unicode pattern match', t
+ bpat = bytes(pattern, "ascii")
+ bs = bytes(s, "ascii")
+ except UnicodeEncodeError:
+ # skip non-ascii tests
+ pass
+ else:
+ try:
+ bpat = re.compile(bpat)
+ except Exception:
+ print('=== Fails on bytes pattern compile', t)
+ if verbose:
+ traceback.print_exc(file=sys.stdout)
+ else:
+ bytes_result = bpat.search(bs)
+ if bytes_result is None:
+ print('=== Fails on bytes pattern match', t)
# Try the match with the search area limited to the extent
# of the match and see if it still succeeds. \B will
@@ -942,28 +980,30 @@ def run_re_tests():
obj = re.compile(pattern)
result = obj.search(s, result.start(0), result.end(0) + 1)
if result is None:
- print '=== Failed on range-limited match', t
+ print('=== Failed on range-limited match', t)
# Try the match with IGNORECASE enabled, and check that it
# still succeeds.
obj = re.compile(pattern, re.IGNORECASE)
result = obj.search(s)
if result is None:
- print '=== Fails on case-insensitive match', t
+ print('=== Fails on case-insensitive match', t)
# Try the match with LOCALE enabled, and check that it
# still succeeds.
- obj = re.compile(pattern, re.LOCALE)
- result = obj.search(s)
- if result is None:
- print '=== Fails on locale-sensitive match', t
+ if '(?u)' not in pattern:
+ obj = re.compile(pattern, re.LOCALE)
+ result = obj.search(s)
+ if result is None:
+ print('=== Fails on locale-sensitive match', t)
# Try the match with UNICODE locale enabled, and check
# that it still succeeds.
obj = re.compile(pattern, re.UNICODE)
result = obj.search(s)
if result is None:
- print '=== Fails on unicode-sensitive match', t
+ print('=== Fails on unicode-sensitive match', t)
+
def test_main():
run_unittest(ReTests)
diff --git a/Lib/test/test_readline.py b/Lib/test/test_readline.py
index 945c7f40fb7..5483dd31b80 100644
--- a/Lib/test/test_readline.py
+++ b/Lib/test/test_readline.py
@@ -6,7 +6,7 @@ the "real" readline have the same interface for history manipulation. That's
why the tests cover only a small subset of the interface.
"""
import unittest
-from test.test_support import run_unittest, import_module
+from test.support import run_unittest, import_module
# Skip tests if there is no readline module
readline = import_module('readline')
diff --git a/Lib/test/test_repr.py b/Lib/test/test_reprlib.py
index 062fccf9e09..b0dc4d78134 100644
--- a/Lib/test/test_repr.py
+++ b/Lib/test/test_reprlib.py
@@ -8,9 +8,10 @@ import os
import shutil
import unittest
-from test.test_support import run_unittest, check_py3k_warnings
-from repr import repr as r # Don't shadow builtin repr
-from repr import Repr
+from test.support import run_unittest
+from reprlib import repr as r # Don't shadow builtin repr
+from reprlib import Repr
+from reprlib import recursive_repr
def nestedTuple(nesting):
@@ -103,10 +104,10 @@ class ReprTests(unittest.TestCase):
def test_numbers(self):
eq = self.assertEqual
eq(r(123), repr(123))
- eq(r(123L), repr(123L))
+ eq(r(123), repr(123))
eq(r(1.0/3), repr(1.0/3))
- n = 10L**100
+ n = 10**100
expected = repr(n)[:18] + "..." + repr(n)[-19:]
eq(r(n), expected)
@@ -125,15 +126,7 @@ class ReprTests(unittest.TestCase):
s = r(ClassWithFailingRepr)
self.assertTrue(s.startswith("<class "))
self.assertTrue(s.endswith(">"))
- self.assertTrue(s.find("...") == 8)
-
- def test_file(self):
- fp = open(unittest.__file__)
- self.assertTrue(repr(fp).startswith(
- "<open file %r, mode 'r' at 0x" % unittest.__file__))
- fp.close()
- self.assertTrue(repr(fp).startswith(
- "<closed file %r, mode 'r' at 0x" % unittest.__file__))
+ self.assertIn(s.find("..."), [12, 13])
def test_lambda(self):
self.assertTrue(repr(lambda x: x).startswith(
@@ -148,11 +141,11 @@ class ReprTests(unittest.TestCase):
self.assertTrue(repr(''.split).startswith(
'<built-in method split of str object at 0x'))
- def test_xrange(self):
+ def test_range(self):
eq = self.assertEqual
- eq(repr(xrange(1)), 'xrange(1)')
- eq(repr(xrange(1, 2)), 'xrange(1, 2)')
- eq(repr(xrange(1, 2, 3)), 'xrange(1, 4, 3)')
+ eq(repr(range(1)), 'range(0, 1)')
+ eq(repr(range(1, 2)), 'range(1, 2)')
+ eq(repr(range(1, 4, 3)), 'range(1, 4, 3)')
def test_nesting(self):
eq = self.assertEqual
@@ -171,13 +164,6 @@ class ReprTests(unittest.TestCase):
eq(r([[[[[[{}]]]]]]), "[[[[[[{}]]]]]]")
eq(r([[[[[[[{}]]]]]]]), "[[[[[[[...]]]]]]]")
- def test_buffer(self):
- # XXX doesn't test buffers with no b_base or read-write buffers (see
- # bufferobject.c). The test is fairly incomplete too. Sigh.
- with check_py3k_warnings():
- x = buffer('foo')
- self.assertTrue(repr(x).startswith('<read-only buffer for 0x'))
-
def test_cell(self):
# XXX Hmm? How to get at a cell object?
pass
@@ -220,10 +206,10 @@ class LongReprTest(unittest.TestCase):
# Make the package and subpackage
shutil.rmtree(self.pkgname, ignore_errors=True)
os.mkdir(self.pkgname)
- touch(os.path.join(self.pkgname, '__init__'+os.extsep+'py'))
+ touch(os.path.join(self.pkgname, '__init__.py'))
shutil.rmtree(self.subpkgname, ignore_errors=True)
os.mkdir(self.subpkgname)
- touch(os.path.join(self.subpkgname, '__init__'+os.extsep+'py'))
+ touch(os.path.join(self.subpkgname, '__init__.py'))
# Remember where we are
self.here = os.getcwd()
sys.path.insert(0, self.here)
@@ -245,7 +231,7 @@ class LongReprTest(unittest.TestCase):
def test_module(self):
eq = self.assertEqual
- touch(os.path.join(self.subpkgname, self.pkgname + os.extsep + 'py'))
+ touch(os.path.join(self.subpkgname, self.pkgname + '.py'))
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import areallylongpackageandmodulenametotestreprtruncation
eq(repr(areallylongpackageandmodulenametotestreprtruncation),
"<module '%s' from '%s'>" % (areallylongpackageandmodulenametotestreprtruncation.__name__, areallylongpackageandmodulenametotestreprtruncation.__file__))
@@ -253,7 +239,7 @@ class LongReprTest(unittest.TestCase):
def test_type(self):
eq = self.assertEqual
- touch(os.path.join(self.subpkgname, 'foo'+os.extsep+'py'), '''\
+ touch(os.path.join(self.subpkgname, 'foo.py'), '''\
class foo(object):
pass
''')
@@ -267,39 +253,38 @@ class foo(object):
pass
def test_class(self):
- touch(os.path.join(self.subpkgname, 'bar'+os.extsep+'py'), '''\
+ touch(os.path.join(self.subpkgname, 'bar.py'), '''\
class bar:
pass
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import bar
# Module name may be prefixed with "test.", depending on how run.
- self.assertTrue(repr(bar.bar).startswith(
- "<class %s.bar at 0x" % bar.__name__))
+ self.assertEqual(repr(bar.bar), "<class '%s.bar'>" % bar.__name__)
def test_instance(self):
- touch(os.path.join(self.subpkgname, 'baz'+os.extsep+'py'), '''\
+ touch(os.path.join(self.subpkgname, 'baz.py'), '''\
class baz:
pass
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import baz
ibaz = baz.baz()
self.assertTrue(repr(ibaz).startswith(
- "<%s.baz instance at 0x" % baz.__name__))
+ "<%s.baz object at 0x" % baz.__name__))
def test_method(self):
eq = self.assertEqual
- touch(os.path.join(self.subpkgname, 'qux'+os.extsep+'py'), '''\
+ touch(os.path.join(self.subpkgname, 'qux.py'), '''\
class aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:
def amethod(self): pass
''')
from areallylongpackageandmodulenametotestreprtruncation.areallylongpackageandmodulenametotestreprtruncation import qux
# Unbound methods first
- eq(repr(qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod),
- '<unbound method aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod>')
+ self.assertTrue(repr(qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod).startswith(
+ '<function amethod'))
# Bound method next
iqux = qux.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa()
self.assertTrue(repr(iqux.amethod).startswith(
- '<bound method aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa instance at 0x' \
+ '<bound method aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.amethod of <%s.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa object at 0x' \
% (qux.__name__,) ))
def test_builtin_function(self):
@@ -310,17 +295,45 @@ class ClassWithRepr:
def __init__(self, s):
self.s = s
def __repr__(self):
- return "ClassWithLongRepr(%r)" % self.s
+ return "ClassWithRepr(%r)" % self.s
class ClassWithFailingRepr:
def __repr__(self):
raise Exception("This should be caught by Repr.repr_instance")
+class MyContainer:
+ 'Helper class for TestRecursiveRepr'
+ def __init__(self, values):
+ self.values = list(values)
+ def append(self, value):
+ self.values.append(value)
+ @recursive_repr()
+ def __repr__(self):
+ return '<' + ', '.join(map(str, self.values)) + '>'
+
+class MyContainer2(MyContainer):
+ @recursive_repr('+++')
+ def __repr__(self):
+ return '<' + ', '.join(map(str, self.values)) + '>'
+
+class TestRecursiveRepr(unittest.TestCase):
+ def test_recursive_repr(self):
+ m = MyContainer(list('abcde'))
+ m.append(m)
+ m.append('x')
+ m.append(m)
+ self.assertEqual(repr(m), '<a, b, c, d, e, ..., x, ...>')
+ m = MyContainer2(list('abcde'))
+ m.append(m)
+ m.append('x')
+ m.append(m)
+ self.assertEqual(repr(m), '<a, b, c, d, e, +++, x, +++>')
def test_main():
run_unittest(ReprTests)
run_unittest(LongReprTest)
+ run_unittest(TestRecursiveRepr)
if __name__ == "__main__":
diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
index 52692a71ce3..3c9b6207026 100644
--- a/Lib/test/test_resource.py
+++ b/Lib/test/test_resource.py
@@ -1,8 +1,8 @@
import unittest
-from test import test_support
+from test import support
import time
-resource = test_support.import_module('resource')
+resource = support.import_module('resource')
# This test is checking a few specific problem spots with the resource module.
@@ -47,11 +47,11 @@ class ResourceTest(unittest.TestCase):
limit_set = True
except ValueError:
limit_set = False
- f = open(test_support.TESTFN, "wb")
+ f = open(support.TESTFN, "wb")
try:
- f.write("X" * 1024)
+ f.write(b"X" * 1024)
try:
- f.write("Y")
+ f.write(b"Y")
f.flush()
# On some systems (e.g., Ubuntu on hppa) the flush()
# doesn't always cause the exception, but the close()
@@ -73,11 +73,11 @@ class ResourceTest(unittest.TestCase):
finally:
if limit_set:
resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_fsize_toobig(self):
# Be sure that setrlimit is checking for really large values
- too_big = 10L**50
+ too_big = 10**50
try:
(cur, max) = resource.getrlimit(resource.RLIMIT_FSIZE)
except AttributeError:
@@ -102,9 +102,13 @@ class ResourceTest(unittest.TestCase):
usageboth = resource.getrusage(resource.RUSAGE_BOTH)
except (ValueError, AttributeError):
pass
+ try:
+ usage_thread = resource.getrusage(resource.RUSAGE_THREAD)
+ except (ValueError, AttributeError):
+ pass
def test_main(verbose=None):
- test_support.run_unittest(ResourceTest)
+ support.run_unittest(ResourceTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py
deleted file mode 100644
index d8a0280f51e..00000000000
--- a/Lib/test/test_rfc822.py
+++ /dev/null
@@ -1,257 +0,0 @@
-import unittest
-from test import test_support
-
-rfc822 = test_support.import_module("rfc822", deprecated=True)
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-
-class MessageTestCase(unittest.TestCase):
- def create_message(self, msg):
- return rfc822.Message(StringIO(msg))
-
- def test_get(self):
- msg = self.create_message(
- 'To: "last, first" <userid@foo.net>\n\ntest\n')
- self.assertTrue(msg.get("to") == '"last, first" <userid@foo.net>')
- self.assertTrue(msg.get("TO") == '"last, first" <userid@foo.net>')
- self.assertTrue(msg.get("No-Such-Header") is None)
- self.assertTrue(msg.get("No-Such-Header", "No-Such-Value")
- == "No-Such-Value")
-
- def test_setdefault(self):
- msg = self.create_message(
- 'To: "last, first" <userid@foo.net>\n\ntest\n')
- self.assertTrue(not msg.has_key("New-Header"))
- self.assertTrue(msg.setdefault("New-Header", "New-Value") == "New-Value")
- self.assertTrue(msg.setdefault("New-Header", "Different-Value")
- == "New-Value")
- self.assertTrue(msg["new-header"] == "New-Value")
-
- self.assertTrue(msg.setdefault("Another-Header") == "")
- self.assertTrue(msg["another-header"] == "")
-
- def check(self, msg, results):
- """Check addresses and the date."""
- m = self.create_message(msg)
- i = 0
- for n, a in m.getaddrlist('to') + m.getaddrlist('cc'):
- try:
- mn, ma = results[i][0], results[i][1]
- except IndexError:
- print 'extra parsed address:', repr(n), repr(a)
- continue
- i = i + 1
- self.assertEqual(mn, n,
- "Un-expected name: %r != %r" % (mn, n))
- self.assertEqual(ma, a,
- "Un-expected address: %r != %r" % (ma, a))
- if mn == n and ma == a:
- pass
- else:
- print 'not found:', repr(n), repr(a)
-
- out = m.getdate('date')
- if out:
- self.assertEqual(out,
- (1999, 1, 13, 23, 57, 35, 0, 1, 0),
- "date conversion failed")
-
-
- # Note: all test cases must have the same date (in various formats),
- # or no date!
-
- def test_basic(self):
- self.check(
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- 'From: Guido van Rossum <guido@CNRI.Reston.VA.US>\n'
- 'To: "Guido van\n'
- '\t : Rossum" <guido@python.org>\n'
- 'Subject: test2\n'
- '\n'
- 'test2\n',
- [('Guido van\n\t : Rossum', 'guido@python.org')])
-
- self.check(
- 'From: Barry <bwarsaw@python.org\n'
- 'To: guido@python.org (Guido: the Barbarian)\n'
- 'Subject: nonsense\n'
- 'Date: Wednesday, January 13 1999 23:57:35 -0500\n'
- '\n'
- 'test',
- [('Guido: the Barbarian', 'guido@python.org')])
-
- self.check(
- 'From: Barry <bwarsaw@python.org\n'
- 'To: guido@python.org (Guido: the Barbarian)\n'
- 'Cc: "Guido: the Madman" <guido@python.org>\n'
- 'Date: 13-Jan-1999 23:57:35 EST\n'
- '\n'
- 'test',
- [('Guido: the Barbarian', 'guido@python.org'),
- ('Guido: the Madman', 'guido@python.org')
- ])
-
- self.check(
- 'To: "The monster with\n'
- ' the very long name: Guido" <guido@python.org>\n'
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- '\n'
- 'test',
- [('The monster with\n the very long name: Guido',
- 'guido@python.org')])
-
- self.check(
- 'To: "Amit J. Patel" <amitp@Theory.Stanford.EDU>\n'
- 'CC: Mike Fletcher <mfletch@vrtelecom.com>,\n'
- ' "\'string-sig@python.org\'" <string-sig@python.org>\n'
- 'Cc: fooz@bat.com, bart@toof.com\n'
- 'Cc: goit@lip.com\n'
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- '\n'
- 'test',
- [('Amit J. Patel', 'amitp@Theory.Stanford.EDU'),
- ('Mike Fletcher', 'mfletch@vrtelecom.com'),
- ("'string-sig@python.org'", 'string-sig@python.org'),
- ('', 'fooz@bat.com'),
- ('', 'bart@toof.com'),
- ('', 'goit@lip.com'),
- ])
-
- self.check(
- 'To: Some One <someone@dom.ain>\n'
- 'From: Anudder Persin <subuddy.else@dom.ain>\n'
- 'Date:\n'
- '\n'
- 'test',
- [('Some One', 'someone@dom.ain')])
-
- self.check(
- 'To: person@dom.ain (User J. Person)\n\n',
- [('User J. Person', 'person@dom.ain')])
-
- def test_doublecomment(self):
- # The RFC allows comments within comments in an email addr
- self.check(
- 'To: person@dom.ain ((User J. Person)), John Doe <foo@bar.com>\n\n',
- [('User J. Person', 'person@dom.ain'), ('John Doe', 'foo@bar.com')])
-
- def test_twisted(self):
- # This one is just twisted. I don't know what the proper
- # result should be, but it shouldn't be to infloop, which is
- # what used to happen!
- self.check(
- 'To: <[smtp:dd47@mail.xxx.edu]_at_hmhq@hdq-mdm1-imgout.companay.com>\n'
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- '\n'
- 'test',
- [('', ''),
- ('', 'dd47@mail.xxx.edu'),
- ('', '_at_hmhq@hdq-mdm1-imgout.companay.com'),
- ])
-
- def test_commas_in_full_name(self):
- # This exercises the old commas-in-a-full-name bug, which
- # should be doing the right thing in recent versions of the
- # module.
- self.check(
- 'To: "last, first" <userid@foo.net>\n'
- '\n'
- 'test',
- [('last, first', 'userid@foo.net')])
-
- def test_quoted_name(self):
- self.check(
- 'To: (Comment stuff) "Quoted name"@somewhere.com\n'
- '\n'
- 'test',
- [('Comment stuff', '"Quoted name"@somewhere.com')])
-
- def test_bogus_to_header(self):
- self.check(
- 'To: :\n'
- 'Cc: goit@lip.com\n'
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- '\n'
- 'test',
- [('', 'goit@lip.com')])
-
- def test_addr_ipquad(self):
- self.check(
- 'To: guido@[132.151.1.21]\n'
- '\n'
- 'foo',
- [('', 'guido@[132.151.1.21]')])
-
- def test_iter(self):
- m = rfc822.Message(StringIO(
- 'Date: Wed, 13 Jan 1999 23:57:35 -0500\n'
- 'From: Guido van Rossum <guido@CNRI.Reston.VA.US>\n'
- 'To: "Guido van\n'
- '\t : Rossum" <guido@python.org>\n'
- 'Subject: test2\n'
- '\n'
- 'test2\n' ))
- self.assertEqual(sorted(m), ['date', 'from', 'subject', 'to'])
-
- def test_rfc2822_phrases(self):
- # RFC 2822 (the update to RFC 822) specifies that dots in phrases are
- # obsolete syntax, which conforming programs MUST recognize but NEVER
- # generate (see $4.1 Miscellaneous obsolete tokens). This is a
- # departure from RFC 822 which did not allow dots in non-quoted
- # phrases.
- self.check('To: User J. Person <person@dom.ain>\n\n',
- [('User J. Person', 'person@dom.ain')])
-
- # This takes too long to add to the test suite
-## def test_an_excrutiatingly_long_address_field(self):
-## OBSCENELY_LONG_HEADER_MULTIPLIER = 10000
-## oneaddr = ('Person' * 10) + '@' + ('.'.join(['dom']*10)) + '.com'
-## addr = ', '.join([oneaddr] * OBSCENELY_LONG_HEADER_MULTIPLIER)
-## lst = rfc822.AddrlistClass(addr).getaddrlist()
-## self.assertEqual(len(lst), OBSCENELY_LONG_HEADER_MULTIPLIER)
-
- def test_2getaddrlist(self):
- eq = self.assertEqual
- msg = self.create_message("""\
-To: aperson@dom.ain
-Cc: bperson@dom.ain
-Cc: cperson@dom.ain
-Cc: dperson@dom.ain
-
-A test message.
-""")
- ccs = [('', a) for a in
- ['bperson@dom.ain', 'cperson@dom.ain', 'dperson@dom.ain']]
- addrs = msg.getaddrlist('cc')
- addrs.sort()
- eq(addrs, ccs)
- # Try again, this one used to fail
- addrs = msg.getaddrlist('cc')
- addrs.sort()
- eq(addrs, ccs)
-
- def test_parseaddr(self):
- eq = self.assertEqual
- eq(rfc822.parseaddr('<>'), ('', ''))
- eq(rfc822.parseaddr('aperson@dom.ain'), ('', 'aperson@dom.ain'))
- eq(rfc822.parseaddr('bperson@dom.ain (Bea A. Person)'),
- ('Bea A. Person', 'bperson@dom.ain'))
- eq(rfc822.parseaddr('Cynthia Person <cperson@dom.ain>'),
- ('Cynthia Person', 'cperson@dom.ain'))
-
- def test_quote_unquote(self):
- eq = self.assertEqual
- eq(rfc822.quote('foo\\wacky"name'), 'foo\\\\wacky\\"name')
- eq(rfc822.unquote('"foo\\\\wacky\\"name"'), 'foo\\wacky"name')
-
-
-def test_main():
- test_support.run_unittest(MessageTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_richcmp.py b/Lib/test/test_richcmp.py
index 70fa0d8289f..f8f3717b641 100644
--- a/Lib/test/test_richcmp.py
+++ b/Lib/test/test_richcmp.py
@@ -1,7 +1,7 @@
# Tests for rich comparisons
import unittest
-from test import test_support
+from test import support
import operator
@@ -29,7 +29,7 @@ class Number:
return self.x >= other
def __cmp__(self, other):
- raise test_support.TestFailed, "Number.__cmp__() should not be called"
+ raise support.TestFailed("Number.__cmp__() should not be called")
def __repr__(self):
return "Number(%r)" % (self.x, )
@@ -50,11 +50,11 @@ class Vector:
__hash__ = None # Vectors cannot be hashed
- def __nonzero__(self):
- raise TypeError, "Vectors cannot be used in Boolean contexts"
+ def __bool__(self):
+ raise TypeError("Vectors cannot be used in Boolean contexts")
def __cmp__(self, other):
- raise test_support.TestFailed, "Vector.__cmp__() should not be called"
+ raise support.TestFailed("Vector.__cmp__() should not be called")
def __repr__(self):
return "Vector(%r)" % (self.data, )
@@ -81,7 +81,7 @@ class Vector:
if isinstance(other, Vector):
other = other.data
if len(self.data) != len(other):
- raise ValueError, "Cannot compare vectors of different length"
+ raise ValueError("Cannot compare vectors of different length")
return other
opmap = {
@@ -104,7 +104,7 @@ class VectorTest(unittest.TestCase):
realres = op(a, b)
# can't use assertEqual(realres, expres) here
self.assertEqual(len(realres), len(expres))
- for i in xrange(len(realres)):
+ for i in range(len(realres)):
# results are bool, so we can use "is" here
self.assertTrue(realres[i] is expres[i])
@@ -118,7 +118,7 @@ class VectorTest(unittest.TestCase):
for opname in opmap:
self.checkfail(ValueError, opname, a, b)
- a = range(5)
+ a = list(range(5))
b = 5 * [2]
# try mixed arguments (but not (a, b) as that won't return a bool vector)
args = [(a, Vector(b)), (Vector(a), b), (Vector(a), Vector(b))]
@@ -130,9 +130,9 @@ class VectorTest(unittest.TestCase):
self.checkequal("gt", a, b, [False, False, False, True, True ])
self.checkequal("ge", a, b, [False, False, True, True, True ])
- for ops in opmap.itervalues():
+ for ops in opmap.values():
for op in ops:
- # calls __nonzero__, which should fail
+ # calls __bool__, which should fail
self.assertRaises(TypeError, bool, op(a, b))
class NumberTest(unittest.TestCase):
@@ -141,15 +141,15 @@ class NumberTest(unittest.TestCase):
# Check that comparisons involving Number objects
# give the same results give as comparing the
# corresponding ints
- for a in xrange(3):
- for b in xrange(3):
+ for a in range(3):
+ for b in range(3):
for typea in (int, Number):
for typeb in (int, Number):
if typea==typeb==int:
continue # the combination int, int is useless
ta = typea(a)
tb = typeb(b)
- for ops in opmap.itervalues():
+ for ops in opmap.values():
for op in ops:
realoutcome = op(a, b)
testoutcome = op(ta, tb)
@@ -198,22 +198,20 @@ class MiscTest(unittest.TestCase):
def __le__(self_, other): self.fail("This shouldn't happen")
def __ge__(self_, other): self.fail("This shouldn't happen")
def __ne__(self_, other): self.fail("This shouldn't happen")
- def __cmp__(self_, other): raise RuntimeError, "expected"
a = Misb()
b = Misb()
self.assertEqual(a<b, 0)
self.assertEqual(a==b, 0)
self.assertEqual(a>b, 0)
- self.assertRaises(RuntimeError, cmp, a, b)
def test_not(self):
- # Check that exceptions in __nonzero__ are properly
+ # Check that exceptions in __bool__ are properly
# propagated by the not operator
import operator
class Exc(Exception):
pass
class Bad:
- def __nonzero__(self):
+ def __bool__(self):
raise Exc
def do(bad):
@@ -224,7 +222,7 @@ class MiscTest(unittest.TestCase):
def test_recursion(self):
# Check that comparison for recursive objects fails gracefully
- from UserList import UserList
+ from collections import UserList
a = UserList()
b = UserList()
a.append(b)
@@ -264,16 +262,16 @@ class DictTest(unittest.TestCase):
imag1a = {}
for i in range(50):
imag1a[random.randrange(100)*1j] = random.randrange(100)*1j
- items = imag1a.items()
+ items = list(imag1a.items())
random.shuffle(items)
imag1b = {}
for k, v in items:
imag1b[k] = v
imag2 = imag1b.copy()
imag2[k] = v + 1.0
- self.assertTrue(imag1a == imag1a)
- self.assertTrue(imag1a == imag1b)
- self.assertTrue(imag2 == imag2)
+ self.assertEqual(imag1a, imag1a)
+ self.assertEqual(imag1a, imag1b)
+ self.assertEqual(imag2, imag2)
self.assertTrue(imag1a != imag2)
for opname in ("lt", "le", "gt", "ge"):
for op in opmap[opname]:
@@ -326,13 +324,9 @@ class ListTest(unittest.TestCase):
for op in opmap["lt"]:
self.assertIs(op(x, y), True)
-def test_main():
- test_support.run_unittest(VectorTest, NumberTest, MiscTest, ListTest)
- with test_support.check_py3k_warnings(("dict inequality comparisons "
- "not supported in 3.x",
- DeprecationWarning)):
- test_support.run_unittest(DictTest)
+def test_main():
+ support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_rlcompleter.py b/Lib/test/test_rlcompleter.py
index ac0e70dbcbe..11a7bd2f719 100644
--- a/Lib/test/test_rlcompleter.py
+++ b/Lib/test/test_rlcompleter.py
@@ -1,9 +1,9 @@
-from test import test_support as support
+from test import support
import unittest
-import __builtin__ as builtins
+import builtins
import rlcompleter
-class CompleteMe(object):
+class CompleteMe:
""" Trivial class used in testing rlcompleter.Completer. """
spam = 1
diff --git a/Lib/test/test_robotparser.py b/Lib/test/test_robotparser.py
index b3d4a46056b..178761dd381 100644
--- a/Lib/test/test_robotparser.py
+++ b/Lib/test/test_robotparser.py
@@ -1,6 +1,9 @@
-import unittest, StringIO, robotparser
-from test import test_support
-from urllib2 import urlopen, HTTPError
+import io
+import unittest
+import urllib.robotparser
+from urllib.error import URLError, HTTPError
+from urllib.request import urlopen
+from test import support
class RobotTestCase(unittest.TestCase):
def __init__(self, index, parser, url, good, agent):
@@ -33,8 +36,8 @@ tests = unittest.TestSuite()
def RobotTest(index, robots_txt, good_urls, bad_urls,
agent="test_robotparser"):
- lines = StringIO.StringIO(robots_txt).readlines()
- parser = robotparser.RobotFileParser()
+ lines = io.StringIO(robots_txt).readlines()
+ parser = urllib.robotparser.RobotFileParser()
parser.parse(lines)
for url in good_urls:
tests.addTest(RobotTestCase(index, parser, url, 1, agent))
@@ -232,8 +235,8 @@ RobotTest(15, doc, good, bad)
class NetworkTestCase(unittest.TestCase):
def testPasswordProtectedSite(self):
- test_support.requires('network')
- with test_support.transient_internet('mueblesmoraleda.com'):
+ support.requires('network')
+ with support.transient_internet('mueblesmoraleda.com'):
url = 'http://mueblesmoraleda.com'
robots_url = url + "/robots.txt"
# First check the URL is usable for our purposes, since the
@@ -249,28 +252,27 @@ class NetworkTestCase(unittest.TestCase):
self.skipTest(
"%r should return a 401 or 403 HTTP error, not succeed"
% (robots_url))
- parser = robotparser.RobotFileParser()
+ parser = urllib.robotparser.RobotFileParser()
parser.set_url(url)
try:
parser.read()
- except IOError:
+ except URLError:
self.skipTest('%s is unavailable' % url)
self.assertEqual(parser.can_fetch("*", robots_url), False)
def testPythonOrg(self):
- test_support.requires('network')
- with test_support.transient_internet('www.python.org'):
- parser = robotparser.RobotFileParser(
+ support.requires('network')
+ with support.transient_internet('www.python.org'):
+ parser = urllib.robotparser.RobotFileParser(
"http://www.python.org/robots.txt")
parser.read()
self.assertTrue(
parser.can_fetch("*", "http://www.python.org/robots.txt"))
-
def test_main():
- test_support.run_unittest(tests)
- test_support.run_unittest(NetworkTestCase)
+ support.run_unittest(NetworkTestCase)
+ support.run_unittest(tests)
if __name__=='__main__':
- test_support.verbose = 1
+ support.verbose = 1
test_main()
diff --git a/Lib/test/test_runpy.py b/Lib/test/test_runpy.py
index dbcb23d3300..96d2bebbc44 100644
--- a/Lib/test/test_runpy.py
+++ b/Lib/test/test_runpy.py
@@ -5,82 +5,148 @@ import os.path
import sys
import re
import tempfile
-from test.test_support import verbose, run_unittest, forget
-from test.script_helper import (temp_dir, make_script, compile_script,
- make_pkg, make_zip_script, make_zip_pkg)
-
+import py_compile
+from test.support import forget, make_legacy_pyc, run_unittest, unload, verbose
+from test.script_helper import (
+ make_pkg, make_script, make_zip_pkg, make_zip_script, temp_dir)
+import runpy
from runpy import _run_code, _run_module_code, run_module, run_path
# Note: This module can't safely test _run_module_as_main as it
# runs its tests in the current process, which would mess with the
# real __main__ module (usually test.regrtest)
# See test_cmd_line_script for a test that executes that code path
-# Set up the test code and expected results
-
-class RunModuleCodeTest(unittest.TestCase):
- """Unit tests for runpy._run_code and runpy._run_module_code"""
- expected_result = ["Top level assignment", "Lower level reference"]
- test_source = (
- "# Check basic code execution\n"
- "result = ['Top level assignment']\n"
- "def f():\n"
- " result.append('Lower level reference')\n"
- "f()\n"
- "# Check the sys module\n"
- "import sys\n"
- "run_argv0 = sys.argv[0]\n"
- "run_name_in_sys_modules = __name__ in sys.modules\n"
- "if run_name_in_sys_modules:\n"
- " module_in_sys_modules = globals() is sys.modules[__name__].__dict__\n"
- "# Check nested operation\n"
- "import runpy\n"
- "nested = runpy._run_module_code('x=1\\n', mod_name='<run>')\n"
- )
+# Set up the test code and expected results
+example_source = """\
+# Check basic code execution
+result = ['Top level assignment']
+def f():
+ result.append('Lower level reference')
+f()
+del f
+# Check the sys module
+import sys
+run_argv0 = sys.argv[0]
+run_name_in_sys_modules = __name__ in sys.modules
+module_in_sys_modules = (run_name_in_sys_modules and
+ globals() is sys.modules[__name__].__dict__)
+# Check nested operation
+import runpy
+nested = runpy._run_module_code('x=1\\n', mod_name='<run>')
+"""
- def test_run_code(self):
+implicit_namespace = {
+ "__name__": None,
+ "__file__": None,
+ "__cached__": None,
+ "__package__": None,
+ "__doc__": None,
+}
+example_namespace = {
+ "sys": sys,
+ "runpy": runpy,
+ "result": ["Top level assignment", "Lower level reference"],
+ "run_argv0": sys.argv[0],
+ "run_name_in_sys_modules": False,
+ "module_in_sys_modules": False,
+ "nested": dict(implicit_namespace,
+ x=1, __name__="<run>", __loader__=None),
+}
+example_namespace.update(implicit_namespace)
+
+class CodeExecutionMixin:
+ # Issue #15230 (run_path not handling run_name correctly) highlighted a
+ # problem with the way arguments were being passed from higher level APIs
+ # down to lower level code. This mixin makes it easier to ensure full
+ # testing occurs at those upper layers as well, not just at the utility
+ # layer
+
+ def assertNamespaceMatches(self, result_ns, expected_ns):
+ """Check two namespaces match.
+
+ Ignores any unspecified interpreter created names
+ """
+ # Impls are permitted to add extra names, so filter them out
+ for k in list(result_ns):
+ if k.startswith("__") and k.endswith("__"):
+ if k not in expected_ns:
+ result_ns.pop(k)
+ if k not in expected_ns["nested"]:
+ result_ns["nested"].pop(k)
+ # Don't use direct dict comparison - the diffs are too hard to debug
+ self.assertEqual(set(result_ns), set(expected_ns))
+ for k in result_ns:
+ actual = (k, result_ns[k])
+ expected = (k, expected_ns[k])
+ self.assertEqual(actual, expected)
+
+ def check_code_execution(self, create_namespace, expected_namespace):
+ """Check that an interface runs the example code correctly
+
+ First argument is a callable accepting the initial globals and
+ using them to create the actual namespace
+ Second argument is the expected result
+ """
+ sentinel = object()
+ expected_ns = expected_namespace.copy()
+ run_name = expected_ns["__name__"]
saved_argv0 = sys.argv[0]
- d = _run_code(self.test_source, {})
- self.assertEqual(d["result"], self.expected_result)
- self.assertIs(d["__name__"], None)
- self.assertIs(d["__file__"], None)
- self.assertIs(d["__loader__"], None)
- self.assertIs(d["__package__"], None)
- self.assertIs(d["run_argv0"], saved_argv0)
- self.assertNotIn("run_name", d)
+ saved_mod = sys.modules.get(run_name, sentinel)
+ # Check without initial globals
+ result_ns = create_namespace(None)
+ self.assertNamespaceMatches(result_ns, expected_ns)
self.assertIs(sys.argv[0], saved_argv0)
-
- def test_run_module_code(self):
- initial = object()
- name = "<Nonsense>"
- file = "Some other nonsense"
- loader = "Now you're just being silly"
- package = '' # Treat as a top level module
- d1 = dict(initial=initial)
- saved_argv0 = sys.argv[0]
- d2 = _run_module_code(self.test_source,
- d1,
- name,
- file,
- loader,
- package)
- self.assertNotIn("result", d1)
- self.assertIs(d2["initial"], initial)
- self.assertEqual(d2["result"], self.expected_result)
- self.assertEqual(d2["nested"]["x"], 1)
- self.assertIs(d2["__name__"], name)
- self.assertTrue(d2["run_name_in_sys_modules"])
- self.assertTrue(d2["module_in_sys_modules"])
- self.assertIs(d2["__file__"], file)
- self.assertIs(d2["run_argv0"], file)
- self.assertIs(d2["__loader__"], loader)
- self.assertIs(d2["__package__"], package)
+ self.assertIs(sys.modules.get(run_name, sentinel), saved_mod)
+ # And then with initial globals
+ initial_ns = {"sentinel": sentinel}
+ expected_ns["sentinel"] = sentinel
+ result_ns = create_namespace(initial_ns)
+ self.assertIsNot(result_ns, initial_ns)
+ self.assertNamespaceMatches(result_ns, expected_ns)
self.assertIs(sys.argv[0], saved_argv0)
- self.assertNotIn(name, sys.modules)
+ self.assertIs(sys.modules.get(run_name, sentinel), saved_mod)
+
+class ExecutionLayerTestCase(unittest.TestCase, CodeExecutionMixin):
+ """Unit tests for runpy._run_code and runpy._run_module_code"""
+
+ def test_run_code(self):
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__loader__": None,
+ })
+ def create_ns(init_globals):
+ return _run_code(example_source, {}, init_globals)
+ self.check_code_execution(create_ns, expected_ns)
-class RunModuleTest(unittest.TestCase):
+ def test_run_module_code(self):
+ mod_name = "<Nonsense>"
+ mod_fname = "Some other nonsense"
+ mod_loader = "Now you're just being silly"
+ mod_package = '' # Treat as a top level module
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__name__": mod_name,
+ "__file__": mod_fname,
+ "__loader__": mod_loader,
+ "__package__": mod_package,
+ "run_argv0": mod_fname,
+ "run_name_in_sys_modules": True,
+ "module_in_sys_modules": True,
+ })
+ def create_ns(init_globals):
+ return _run_module_code(example_source,
+ init_globals,
+ mod_name,
+ mod_fname,
+ mod_loader,
+ mod_package)
+ self.check_code_execution(create_ns, expected_ns)
+
+
+class RunModuleTestCase(unittest.TestCase, CodeExecutionMixin):
"""Unit tests for runpy.run_module"""
def expect_import_error(self, mod_name):
@@ -104,11 +170,11 @@ class RunModuleTest(unittest.TestCase):
self.expect_import_error("multiprocessing")
def test_library_module(self):
- run_module("runpy")
+ self.assertEqual(run_module("runpy")["__name__"], "runpy")
def _add_pkg_dir(self, pkg_dir):
os.mkdir(pkg_dir)
- pkg_fname = os.path.join(pkg_dir, "__init__"+os.extsep+"py")
+ pkg_fname = os.path.join(pkg_dir, "__init__.py")
pkg_file = open(pkg_fname, "w")
pkg_file.close()
return pkg_fname
@@ -116,20 +182,20 @@ class RunModuleTest(unittest.TestCase):
def _make_pkg(self, source, depth, mod_base="runpy_test"):
pkg_name = "__runpy_pkg__"
test_fname = mod_base+os.extsep+"py"
- pkg_dir = sub_dir = tempfile.mkdtemp()
- if verbose: print " Package tree in:", sub_dir
+ pkg_dir = sub_dir = os.path.realpath(tempfile.mkdtemp())
+ if verbose > 1: print(" Package tree in:", sub_dir)
sys.path.insert(0, pkg_dir)
- if verbose: print " Updated sys.path:", sys.path[0]
+ if verbose > 1: print(" Updated sys.path:", sys.path[0])
for i in range(depth):
sub_dir = os.path.join(sub_dir, pkg_name)
pkg_fname = self._add_pkg_dir(sub_dir)
- if verbose: print " Next level in:", sub_dir
- if verbose: print " Created:", pkg_fname
+ if verbose > 1: print(" Next level in:", sub_dir)
+ if verbose > 1: print(" Created:", pkg_fname)
mod_fname = os.path.join(sub_dir, test_fname)
mod_file = open(mod_fname, "w")
mod_file.write(source)
mod_file.close()
- if verbose: print " Created:", mod_fname
+ if verbose > 1: print(" Created:", mod_fname)
mod_name = (pkg_name+".")*depth + mod_base
return pkg_dir, mod_fname, mod_name
@@ -137,69 +203,98 @@ class RunModuleTest(unittest.TestCase):
for entry in list(sys.modules):
if entry.startswith("__runpy_pkg__"):
del sys.modules[entry]
- if verbose: print " Removed sys.modules entries"
+ if verbose > 1: print(" Removed sys.modules entries")
del sys.path[0]
- if verbose: print " Removed sys.path entry"
+ if verbose > 1: print(" Removed sys.path entry")
for root, dirs, files in os.walk(top, topdown=False):
for name in files:
try:
os.remove(os.path.join(root, name))
- except OSError, ex:
- if verbose: print ex # Persist with cleaning up
+ except OSError as ex:
+ if verbose > 1: print(ex) # Persist with cleaning up
for name in dirs:
fullname = os.path.join(root, name)
try:
os.rmdir(fullname)
- except OSError, ex:
- if verbose: print ex # Persist with cleaning up
+ except OSError as ex:
+ if verbose > 1: print(ex) # Persist with cleaning up
try:
os.rmdir(top)
- if verbose: print " Removed package tree"
- except OSError, ex:
- if verbose: print ex # Persist with cleaning up
+ if verbose > 1: print(" Removed package tree")
+ except OSError as ex:
+ if verbose > 1: print(ex) # Persist with cleaning up
+
+ def _fix_ns_for_legacy_pyc(self, ns, alter_sys):
+ char_to_add = "c" if __debug__ else "o"
+ ns["__file__"] += char_to_add
+ if alter_sys:
+ ns["run_argv0"] += char_to_add
+
- def _check_module(self, depth):
+ def _check_module(self, depth, alter_sys=False):
pkg_dir, mod_fname, mod_name = (
- self._make_pkg("x=1\n", depth))
+ self._make_pkg(example_source, depth))
forget(mod_name)
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__name__": mod_name,
+ "__file__": mod_fname,
+ "__package__": mod_name.rpartition(".")[0],
+ })
+ if alter_sys:
+ expected_ns.update({
+ "run_argv0": mod_fname,
+ "run_name_in_sys_modules": True,
+ "module_in_sys_modules": True,
+ })
+ def create_ns(init_globals):
+ return run_module(mod_name, init_globals, alter_sys=alter_sys)
try:
- if verbose: print "Running from source:", mod_name
- d1 = run_module(mod_name) # Read from source
- self.assertIn("x", d1)
- self.assertTrue(d1["x"] == 1)
- del d1 # Ensure __loader__ entry doesn't keep file open
+ if verbose > 1: print("Running from source:", mod_name)
+ self.check_code_execution(create_ns, expected_ns)
__import__(mod_name)
os.remove(mod_fname)
- if verbose: print "Running from compiled:", mod_name
- d2 = run_module(mod_name) # Read from bytecode
- self.assertIn("x", d2)
- self.assertTrue(d2["x"] == 1)
- del d2 # Ensure __loader__ entry doesn't keep file open
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case loader caches paths
+ if verbose > 1: print("Running from compiled:", mod_name)
+ self._fix_ns_for_legacy_pyc(expected_ns, alter_sys)
+ self.check_code_execution(create_ns, expected_ns)
finally:
self._del_pkg(pkg_dir, depth, mod_name)
- if verbose: print "Module executed successfully"
+ if verbose > 1: print("Module executed successfully")
- def _check_package(self, depth):
+ def _check_package(self, depth, alter_sys=False):
pkg_dir, mod_fname, mod_name = (
- self._make_pkg("x=1\n", depth, "__main__"))
- pkg_name, _, _ = mod_name.rpartition(".")
+ self._make_pkg(example_source, depth, "__main__"))
+ pkg_name = mod_name.rpartition(".")[0]
forget(mod_name)
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__name__": mod_name,
+ "__file__": mod_fname,
+ "__package__": pkg_name,
+ })
+ if alter_sys:
+ expected_ns.update({
+ "run_argv0": mod_fname,
+ "run_name_in_sys_modules": True,
+ "module_in_sys_modules": True,
+ })
+ def create_ns(init_globals):
+ return run_module(pkg_name, init_globals, alter_sys=alter_sys)
try:
- if verbose: print "Running from source:", pkg_name
- d1 = run_module(pkg_name) # Read from source
- self.assertIn("x", d1)
- self.assertTrue(d1["x"] == 1)
- del d1 # Ensure __loader__ entry doesn't keep file open
+ if verbose > 1: print("Running from source:", pkg_name)
+ self.check_code_execution(create_ns, expected_ns)
__import__(mod_name)
os.remove(mod_fname)
- if verbose: print "Running from compiled:", pkg_name
- d2 = run_module(pkg_name) # Read from bytecode
- self.assertIn("x", d2)
- self.assertTrue(d2["x"] == 1)
- del d2 # Ensure __loader__ entry doesn't keep file open
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case loader caches paths
+ if verbose > 1: print("Running from compiled:", pkg_name)
+ self._fix_ns_for_legacy_pyc(expected_ns, alter_sys)
+ self.check_code_execution(create_ns, expected_ns)
finally:
self._del_pkg(pkg_dir, depth, pkg_name)
- if verbose: print "Package executed successfully"
+ if verbose > 1: print("Package executed successfully")
def _add_relative_modules(self, base_dir, source, depth):
if depth <= 1:
@@ -210,21 +305,21 @@ class RunModuleTest(unittest.TestCase):
parent_dir = module_dir
module_dir = os.path.join(module_dir, pkg_name)
# Add sibling module
- sibling_fname = os.path.join(module_dir, "sibling"+os.extsep+"py")
+ sibling_fname = os.path.join(module_dir, "sibling.py")
sibling_file = open(sibling_fname, "w")
sibling_file.close()
- if verbose: print " Added sibling module:", sibling_fname
+ if verbose > 1: print(" Added sibling module:", sibling_fname)
# Add nephew module
uncle_dir = os.path.join(parent_dir, "uncle")
self._add_pkg_dir(uncle_dir)
- if verbose: print " Added uncle package:", uncle_dir
+ if verbose > 1: print(" Added uncle package:", uncle_dir)
cousin_dir = os.path.join(uncle_dir, "cousin")
self._add_pkg_dir(cousin_dir)
- if verbose: print " Added cousin package:", cousin_dir
- nephew_fname = os.path.join(cousin_dir, "nephew"+os.extsep+"py")
+ if verbose > 1: print(" Added cousin package:", cousin_dir)
+ nephew_fname = os.path.join(cousin_dir, "nephew.py")
nephew_file = open(nephew_fname, "w")
nephew_file.close()
- if verbose: print " Added nephew module:", nephew_fname
+ if verbose > 1: print(" Added nephew module:", nephew_fname)
def _check_relative_imports(self, depth, run_name=None):
contents = r"""\
@@ -234,124 +329,152 @@ from ..uncle.cousin import nephew
"""
pkg_dir, mod_fname, mod_name = (
self._make_pkg(contents, depth))
+ if run_name is None:
+ expected_name = mod_name
+ else:
+ expected_name = run_name
try:
self._add_relative_modules(pkg_dir, contents, depth)
pkg_name = mod_name.rpartition('.')[0]
- if verbose: print "Running from source:", mod_name
+ if verbose > 1: print("Running from source:", mod_name)
d1 = run_module(mod_name, run_name=run_name) # Read from source
- self.assertIn("__package__", d1)
- self.assertTrue(d1["__package__"] == pkg_name)
+ self.assertEqual(d1["__name__"], expected_name)
+ self.assertEqual(d1["__package__"], pkg_name)
self.assertIn("sibling", d1)
self.assertIn("nephew", d1)
del d1 # Ensure __loader__ entry doesn't keep file open
__import__(mod_name)
os.remove(mod_fname)
- if verbose: print "Running from compiled:", mod_name
+ make_legacy_pyc(mod_fname)
+ unload(mod_name) # In case the loader caches paths
+ if verbose > 1: print("Running from compiled:", mod_name)
d2 = run_module(mod_name, run_name=run_name) # Read from bytecode
- self.assertIn("__package__", d2)
- self.assertTrue(d2["__package__"] == pkg_name)
+ self.assertEqual(d2["__name__"], expected_name)
+ self.assertEqual(d2["__package__"], pkg_name)
self.assertIn("sibling", d2)
self.assertIn("nephew", d2)
del d2 # Ensure __loader__ entry doesn't keep file open
finally:
self._del_pkg(pkg_dir, depth, mod_name)
- if verbose: print "Module executed successfully"
+ if verbose > 1: print("Module executed successfully")
def test_run_module(self):
for depth in range(4):
- if verbose: print "Testing package depth:", depth
+ if verbose > 1: print("Testing package depth:", depth)
self._check_module(depth)
def test_run_package(self):
for depth in range(1, 4):
- if verbose: print "Testing package depth:", depth
+ if verbose > 1: print("Testing package depth:", depth)
self._check_package(depth)
+ def test_run_module_alter_sys(self):
+ for depth in range(4):
+ if verbose > 1: print("Testing package depth:", depth)
+ self._check_module(depth, alter_sys=True)
+
+ def test_run_package_alter_sys(self):
+ for depth in range(1, 4):
+ if verbose > 1: print("Testing package depth:", depth)
+ self._check_package(depth, alter_sys=True)
+
def test_explicit_relative_import(self):
for depth in range(2, 5):
- if verbose: print "Testing relative imports at depth:", depth
+ if verbose > 1: print("Testing relative imports at depth:", depth)
self._check_relative_imports(depth)
def test_main_relative_import(self):
for depth in range(2, 5):
- if verbose: print "Testing main relative imports at depth:", depth
+ if verbose > 1: print("Testing main relative imports at depth:", depth)
self._check_relative_imports(depth, "__main__")
+ def test_run_name(self):
+ depth = 1
+ run_name = "And now for something completely different"
+ pkg_dir, mod_fname, mod_name = (
+ self._make_pkg(example_source, depth))
+ forget(mod_name)
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__name__": run_name,
+ "__file__": mod_fname,
+ "__package__": mod_name.rpartition(".")[0],
+ })
+ def create_ns(init_globals):
+ return run_module(mod_name, init_globals, run_name)
+ try:
+ self.check_code_execution(create_ns, expected_ns)
+ finally:
+ self._del_pkg(pkg_dir, depth, mod_name)
+
-class RunPathTest(unittest.TestCase):
+class RunPathTestCase(unittest.TestCase, CodeExecutionMixin):
"""Unit tests for runpy.run_path"""
- # Based on corresponding tests in test_cmd_line_script
-
- test_source = """\
-# Script may be run with optimisation enabled, so don't rely on assert
-# statements being executed
-def assertEqual(lhs, rhs):
- if lhs != rhs:
- raise AssertionError('%r != %r' % (lhs, rhs))
-def assertIs(lhs, rhs):
- if lhs is not rhs:
- raise AssertionError('%r is not %r' % (lhs, rhs))
-# Check basic code execution
-result = ['Top level assignment']
-def f():
- result.append('Lower level reference')
-f()
-assertEqual(result, ['Top level assignment', 'Lower level reference'])
-# Check the sys module
-import sys
-assertIs(globals(), sys.modules[__name__].__dict__)
-argv0 = sys.argv[0]
-"""
def _make_test_script(self, script_dir, script_basename, source=None):
if source is None:
- source = self.test_source
+ source = example_source
return make_script(script_dir, script_basename, source)
def _check_script(self, script_name, expected_name, expected_file,
- expected_argv0, expected_package):
- result = run_path(script_name)
- self.assertEqual(result["__name__"], expected_name)
- self.assertEqual(result["__file__"], expected_file)
- self.assertIn("argv0", result)
- self.assertEqual(result["argv0"], expected_argv0)
- self.assertEqual(result["__package__"], expected_package)
+ expected_argv0):
+ # First check is without run_name
+ def create_ns(init_globals):
+ return run_path(script_name, init_globals)
+ expected_ns = example_namespace.copy()
+ expected_ns.update({
+ "__name__": expected_name,
+ "__file__": expected_file,
+ "__package__": "",
+ "run_argv0": expected_argv0,
+ "run_name_in_sys_modules": True,
+ "module_in_sys_modules": True,
+ })
+ self.check_code_execution(create_ns, expected_ns)
+ # Second check makes sure run_name works in all cases
+ run_name = "prove.issue15230.is.fixed"
+ def create_ns(init_globals):
+ return run_path(script_name, init_globals, run_name)
+ expected_ns["__name__"] = run_name
+ expected_ns["__package__"] = run_name.rpartition(".")[0]
+ self.check_code_execution(create_ns, expected_ns)
def _check_import_error(self, script_name, msg):
msg = re.escape(msg)
- self.assertRaisesRegexp(ImportError, msg, run_path, script_name)
+ self.assertRaisesRegex(ImportError, msg, run_path, script_name)
def test_basic_script(self):
with temp_dir() as script_dir:
mod_name = 'script'
script_name = self._make_test_script(script_dir, mod_name)
self._check_script(script_name, "<run_path>", script_name,
- script_name, None)
+ script_name)
def test_script_compiled(self):
with temp_dir() as script_dir:
mod_name = 'script'
script_name = self._make_test_script(script_dir, mod_name)
- compiled_name = compile_script(script_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
os.remove(script_name)
self._check_script(compiled_name, "<run_path>", compiled_name,
- compiled_name, None)
+ compiled_name)
def test_directory(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
self._check_script(script_dir, "<run_path>", script_name,
- script_dir, '')
+ script_dir)
def test_directory_compiled(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
- compiled_name = compile_script(script_name)
+ compiled_name = py_compile.compile(script_name, doraise=True)
os.remove(script_name)
- self._check_script(script_dir, "<run_path>", compiled_name,
- script_dir, '')
+ legacy_pyc = make_legacy_pyc(script_name)
+ self._check_script(script_dir, "<run_path>", legacy_pyc,
+ script_dir)
def test_directory_error(self):
with temp_dir() as script_dir:
@@ -365,15 +488,16 @@ argv0 = sys.argv[0]
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
- self._check_script(zip_name, "<run_path>", fname, zip_name, '')
+ self._check_script(zip_name, "<run_path>", fname, zip_name)
def test_zipfile_compiled(self):
with temp_dir() as script_dir:
mod_name = '__main__'
script_name = self._make_test_script(script_dir, mod_name)
- compiled_name = compile_script(script_name)
- zip_name, fname = make_zip_script(script_dir, 'test_zip', compiled_name)
- self._check_script(zip_name, "<run_path>", fname, zip_name, '')
+ compiled_name = py_compile.compile(script_name, doraise=True)
+ zip_name, fname = make_zip_script(script_dir, 'test_zip',
+ compiled_name)
+ self._check_script(zip_name, "<run_path>", fname, zip_name)
def test_zipfile_error(self):
with temp_dir() as script_dir:
@@ -391,12 +515,26 @@ argv0 = sys.argv[0]
script_name = self._make_test_script(script_dir, mod_name, source)
zip_name, fname = make_zip_script(script_dir, 'test_zip', script_name)
msg = "recursion depth exceeded"
- self.assertRaisesRegexp(RuntimeError, msg, run_path, zip_name)
+ self.assertRaisesRegex(RuntimeError, msg, run_path, zip_name)
+ def test_encoding(self):
+ with temp_dir() as script_dir:
+ filename = os.path.join(script_dir, 'script.py')
+ with open(filename, 'w', encoding='latin1') as f:
+ f.write("""
+#coding:latin1
+s = "non-ASCII: h\xe9"
+""")
+ result = run_path(filename)
+ self.assertEqual(result['s'], "non-ASCII: h\xe9")
def test_main():
- run_unittest(RunModuleCodeTest, RunModuleTest, RunPathTest)
+ run_unittest(
+ ExecutionLayerTestCase,
+ RunModuleTestCase,
+ RunPathTestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index c3b44f82dc4..d6ed6db9429 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -1,4 +1,4 @@
-# regression test for SAX 2.0 -*- coding: utf-8 -*-
+# regression test for SAX 2.0
# $Id$
from xml.sax import make_parser, ContentHandler, \
@@ -13,12 +13,17 @@ from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
from xml.sax.expatreader import create_parser
from xml.sax.handler import feature_namespaces
from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
-from cStringIO import StringIO
-from test.test_support import findfile, run_unittest
+from io import StringIO
+from test.support import findfile, run_unittest
import unittest
TEST_XMLFILE = findfile("test.xml", subdir="xmltestdata")
TEST_XMLFILE_OUT = findfile("test.xml.out", subdir="xmltestdata")
+try:
+ TEST_XMLFILE.encode("utf8")
+ TEST_XMLFILE_OUT.encode("utf8")
+except UnicodeEncodeError:
+ raise unittest.SkipTest("filename is not encodable to utf8")
ns_uri = "http://www.python.org/xml-ns/saxtest/"
@@ -33,12 +38,12 @@ class XmlTestBase(unittest.TestCase):
self.assertEqual(attrs.getNames(), [])
self.assertEqual(attrs.getQNames(), [])
self.assertEqual(len(attrs), 0)
- self.assertFalse(attrs.has_key("attr"))
- self.assertEqual(attrs.keys(), [])
+ self.assertNotIn("attr", attrs)
+ self.assertEqual(list(attrs.keys()), [])
self.assertEqual(attrs.get("attrs"), None)
self.assertEqual(attrs.get("attrs", 25), 25)
- self.assertEqual(attrs.items(), [])
- self.assertEqual(attrs.values(), [])
+ self.assertEqual(list(attrs.items()), [])
+ self.assertEqual(list(attrs.values()), [])
def verify_empty_nsattrs(self, attrs):
self.assertRaises(KeyError, attrs.getValue, (ns_uri, "attr"))
@@ -50,24 +55,24 @@ class XmlTestBase(unittest.TestCase):
self.assertEqual(attrs.getNames(), [])
self.assertEqual(attrs.getQNames(), [])
self.assertEqual(len(attrs), 0)
- self.assertFalse(attrs.has_key((ns_uri, "attr")))
- self.assertEqual(attrs.keys(), [])
+ self.assertNotIn((ns_uri, "attr"), attrs)
+ self.assertEqual(list(attrs.keys()), [])
self.assertEqual(attrs.get((ns_uri, "attr")), None)
self.assertEqual(attrs.get((ns_uri, "attr"), 25), 25)
- self.assertEqual(attrs.items(), [])
- self.assertEqual(attrs.values(), [])
+ self.assertEqual(list(attrs.items()), [])
+ self.assertEqual(list(attrs.values()), [])
def verify_attrs_wattr(self, attrs):
self.assertEqual(attrs.getLength(), 1)
self.assertEqual(attrs.getNames(), ["attr"])
self.assertEqual(attrs.getQNames(), ["attr"])
self.assertEqual(len(attrs), 1)
- self.assertTrue(attrs.has_key("attr"))
- self.assertEqual(attrs.keys(), ["attr"])
+ self.assertIn("attr", attrs)
+ self.assertEqual(list(attrs.keys()), ["attr"])
self.assertEqual(attrs.get("attr"), "val")
self.assertEqual(attrs.get("attr", 25), "val")
- self.assertEqual(attrs.items(), [("attr", "val")])
- self.assertEqual(attrs.values(), ["val"])
+ self.assertEqual(list(attrs.items()), [("attr", "val")])
+ self.assertEqual(list(attrs.values()), ["val"])
self.assertEqual(attrs.getValue("attr"), "val")
self.assertEqual(attrs.getValueByQName("attr"), "val")
self.assertEqual(attrs.getNameByQName("attr"), "attr")
@@ -166,6 +171,16 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc></doc>")
+ def test_xmlgen_basic_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc/>")
+
def test_xmlgen_content(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -178,6 +193,18 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc>huhei</doc>")
+ def test_xmlgen_content_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.characters("huhei")
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc>huhei</doc>")
+
def test_xmlgen_pi(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -235,6 +262,18 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start + "<doc> </doc>")
+ def test_xmlgen_ignorable_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElement("doc", {})
+ gen.ignorableWhitespace(" ")
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + "<doc> </doc>")
+
def test_xmlgen_ns(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -253,6 +292,24 @@ class XmlgenTest(unittest.TestCase):
('<ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>' %
ns_uri))
+ def test_xmlgen_ns_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping("ns1", ns_uri)
+ gen.startElementNS((ns_uri, "doc"), "ns1:doc", {})
+ # add an unqualified name
+ gen.startElementNS((None, "udoc"), None, {})
+ gen.endElementNS((None, "udoc"), None)
+ gen.endElementNS((ns_uri, "doc"), "ns1:doc")
+ gen.endPrefixMapping("ns1")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start + \
+ ('<ns1:doc xmlns:ns1="%s"><udoc/></ns1:doc>' %
+ ns_uri))
+
def test_1463026_1(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -264,6 +321,17 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start+'<a b="c"></a>')
+ def test_1463026_1_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startElementNS((None, 'a'), 'a', {(None, 'b'):'c'})
+ gen.endElementNS((None, 'a'), 'a')
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start+'<a b="c"/>')
+
def test_1463026_2(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -277,6 +345,19 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(), start+'<a xmlns="qux"></a>')
+ def test_1463026_2_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping(None, 'qux')
+ gen.startElementNS(('qux', 'a'), 'a', {})
+ gen.endElementNS(('qux', 'a'), 'a')
+ gen.endPrefixMapping(None)
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(), start+'<a xmlns="qux"/>')
+
def test_1463026_3(self):
result = StringIO()
gen = XMLGenerator(result)
@@ -291,6 +372,20 @@ class XmlgenTest(unittest.TestCase):
self.assertEqual(result.getvalue(),
start+'<my:a xmlns:my="qux" b="c"></my:a>')
+ def test_1463026_3_empty(self):
+ result = StringIO()
+ gen = XMLGenerator(result, short_empty_elements=True)
+
+ gen.startDocument()
+ gen.startPrefixMapping('my', 'qux')
+ gen.startElementNS(('qux', 'a'), 'a', {(None, 'b'):'c'})
+ gen.endElementNS(('qux', 'a'), 'a')
+ gen.endPrefixMapping('my')
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(),
+ start+'<my:a xmlns:my="qux" b="c"/>')
+
def test_5027_1(self):
# The xml prefix (as in xml:lang below) is reserved and bound by
# definition to http://www.w3.org/XML/1998/namespace. XMLGenerator had
@@ -368,7 +463,8 @@ class XMLFilterBaseTest(unittest.TestCase):
#
# ===========================================================================
-xml_test_out = open(TEST_XMLFILE_OUT).read()
+with open(TEST_XMLFILE_OUT) as f:
+ xml_test_out = f.read()
class ExpatReaderTest(XmlTestBase):
@@ -380,7 +476,8 @@ class ExpatReaderTest(XmlTestBase):
xmlgen = XMLGenerator(result)
parser.setContentHandler(xmlgen)
- parser.parse(open(TEST_XMLFILE))
+ with open(TEST_XMLFILE) as f:
+ parser.parse(f)
self.assertEqual(result.getvalue(), xml_test_out)
@@ -493,11 +590,11 @@ class ExpatReaderTest(XmlTestBase):
self.assertTrue((attrs.getQNames() == [] or
attrs.getQNames() == ["ns:attr"]))
self.assertEqual(len(attrs), 1)
- self.assertTrue(attrs.has_key((ns_uri, "attr")))
+ self.assertIn((ns_uri, "attr"), attrs)
self.assertEqual(attrs.get((ns_uri, "attr")), "val")
self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
- self.assertEqual(attrs.items(), [((ns_uri, "attr"), "val")])
- self.assertEqual(attrs.values(), ["val"])
+ self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")])
+ self.assertEqual(list(attrs.values()), ["val"])
self.assertEqual(attrs.getValue((ns_uri, "attr")), "val")
self.assertEqual(attrs[(ns_uri, "attr")], "val")
@@ -530,8 +627,9 @@ class ExpatReaderTest(XmlTestBase):
parser.setContentHandler(xmlgen)
inpsrc = InputSource()
- inpsrc.setByteStream(open(TEST_XMLFILE))
- parser.parse(inpsrc)
+ with open(TEST_XMLFILE) as f:
+ inpsrc.setByteStream(f)
+ parser.parse(inpsrc)
self.assertEqual(result.getvalue(), xml_test_out)
@@ -614,7 +712,7 @@ class ErrorReportingTest(unittest.TestCase):
try:
parser.parse(source)
self.fail()
- except SAXException, e:
+ except SAXException as e:
self.assertEqual(e.getSystemId(), name)
def test_expat_incomplete(self):
@@ -683,12 +781,12 @@ class XmlReaderTest(XmlTestBase):
self.assertEqual(attrs.getNames(), [(ns_uri, "attr")])
self.assertEqual(attrs.getQNames(), ["ns:attr"])
self.assertEqual(len(attrs), 1)
- self.assertTrue(attrs.has_key((ns_uri, "attr")))
- self.assertEqual(attrs.keys(), [(ns_uri, "attr")])
+ self.assertIn((ns_uri, "attr"), attrs)
+ self.assertEqual(list(attrs.keys()), [(ns_uri, "attr")])
self.assertEqual(attrs.get((ns_uri, "attr")), "val")
self.assertEqual(attrs.get((ns_uri, "attr"), 25), "val")
- self.assertEqual(attrs.items(), [((ns_uri, "attr"), "val")])
- self.assertEqual(attrs.values(), ["val"])
+ self.assertEqual(list(attrs.items()), [((ns_uri, "attr"), "val")])
+ self.assertEqual(list(attrs.values()), ["val"])
self.assertEqual(attrs.getValue((ns_uri, "attr")), "val")
self.assertEqual(attrs.getValueByQName("ns:attr"), "val")
self.assertEqual(attrs.getNameByQName("ns:attr"), (ns_uri, "attr"))
@@ -696,51 +794,6 @@ class XmlReaderTest(XmlTestBase):
self.assertEqual(attrs.getQNameByName((ns_uri, "attr")), "ns:attr")
- # During the development of Python 2.5, an attempt to move the "xml"
- # package implementation to a new package ("xmlcore") proved painful.
- # The goal of this change was to allow applications to be able to
- # obtain and rely on behavior in the standard library implementation
- # of the XML support without needing to be concerned about the
- # availability of the PyXML implementation.
- #
- # While the existing import hackery in Lib/xml/__init__.py can cause
- # PyXML's _xmlpus package to supplant the "xml" package, that only
- # works because either implementation uses the "xml" package name for
- # imports.
- #
- # The move resulted in a number of problems related to the fact that
- # the import machinery's "package context" is based on the name that's
- # being imported rather than the __name__ of the actual package
- # containment; it wasn't possible for the "xml" package to be replaced
- # by a simple module that indirected imports to the "xmlcore" package.
- #
- # The following two tests exercised bugs that were introduced in that
- # attempt. Keeping these tests around will help detect problems with
- # other attempts to provide reliable access to the standard library's
- # implementation of the XML support.
-
- def test_sf_1511497(self):
- # Bug report: http://www.python.org/sf/1511497
- import sys
- old_modules = sys.modules.copy()
- for modname in sys.modules.keys():
- if modname.startswith("xml."):
- del sys.modules[modname]
- try:
- import xml.sax.expatreader
- module = xml.sax.expatreader
- self.assertEqual(module.__name__, "xml.sax.expatreader")
- finally:
- sys.modules.update(old_modules)
-
- def test_sf_1513611(self):
- # Bug report: http://www.python.org/sf/1513611
- sio = StringIO("invalid")
- parser = make_parser()
- from xml.sax import SAXParseException
- self.assertRaises(SAXParseException, parser.parse, sio)
-
-
def test_main():
run_unittest(MakeParserTest,
SaxutilsTest,
diff --git a/Lib/test/test_sched.py b/Lib/test/test_sched.py
new file mode 100644
index 00000000000..91b8f0c939d
--- /dev/null
+++ b/Lib/test/test_sched.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+
+import sched
+import time
+import unittest
+from test import support
+
+
+class TestCase(unittest.TestCase):
+
+ def test_enter(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for x in [0.5, 0.4, 0.3, 0.2, 0.1]:
+ z = scheduler.enter(x, 1, fun, (x,))
+ scheduler.run()
+ self.assertEqual(l, [0.1, 0.2, 0.3, 0.4, 0.5])
+
+ def test_enterabs(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ z = scheduler.enterabs(x, 1, fun, (x,))
+ scheduler.run()
+ self.assertEqual(l, [0.01, 0.02, 0.03, 0.04, 0.05])
+
+ def test_priority(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ for priority in [1, 2, 3, 4, 5]:
+ z = scheduler.enterabs(0.01, priority, fun, (priority,))
+ scheduler.run()
+ self.assertEqual(l, [1, 2, 3, 4, 5])
+
+ def test_cancel(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ now = time.time()
+ event1 = scheduler.enterabs(now + 0.01, 1, fun, (0.01,))
+ event2 = scheduler.enterabs(now + 0.02, 1, fun, (0.02,))
+ event3 = scheduler.enterabs(now + 0.03, 1, fun, (0.03,))
+ event4 = scheduler.enterabs(now + 0.04, 1, fun, (0.04,))
+ event5 = scheduler.enterabs(now + 0.05, 1, fun, (0.05,))
+ scheduler.cancel(event1)
+ scheduler.cancel(event5)
+ scheduler.run()
+ self.assertEqual(l, [0.02, 0.03, 0.04])
+
+ def test_empty(self):
+ l = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ self.assertTrue(scheduler.empty())
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ z = scheduler.enterabs(x, 1, fun, (x,))
+ self.assertFalse(scheduler.empty())
+ scheduler.run()
+ self.assertTrue(scheduler.empty())
+
+ def test_queue(self):
+ l = []
+ events = []
+ fun = lambda x: l.append(x)
+ scheduler = sched.scheduler(time.time, time.sleep)
+ self.assertEqual(scheduler._queue, [])
+ for x in [0.05, 0.04, 0.03, 0.02, 0.01]:
+ events.append(scheduler.enterabs(x, 1, fun, (x,)))
+ self.assertEqual(scheduler._queue.sort(), events.sort())
+ scheduler.run()
+ self.assertEqual(scheduler._queue, [])
+
+
+def test_main():
+ support.run_unittest(TestCase)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py
index 94583e192a8..fbc87aa80c7 100644
--- a/Lib/test/test_scope.py
+++ b/Lib/test/test_scope.py
@@ -1,6 +1,5 @@
import unittest
-from test.test_support import check_syntax_error, check_py3k_warnings, \
- check_warnings, run_unittest
+from test.support import check_syntax_error, run_unittest
class ScopeTests(unittest.TestCase):
@@ -164,6 +163,17 @@ class ScopeTests(unittest.TestCase):
self.assertEqual(t.method_and_var(), "method")
self.assertEqual(t.actual_global(), "global")
+ def testCellIsKwonlyArg(self):
+ # Issue 1409: Initialisation of a cell value,
+ # when it comes from a keyword-only parameter
+ def foo(*, a=17):
+ def bar():
+ return a + 5
+ return bar() + 3
+
+ self.assertEqual(foo(a=42), 50)
+ self.assertEqual(foo(), 25)
+
def testRecursion(self):
def f(x):
@@ -175,79 +185,44 @@ class ScopeTests(unittest.TestCase):
if x >= 0:
return fact(x)
else:
- raise ValueError, "x must be >= 0"
+ raise ValueError("x must be >= 0")
self.assertEqual(f(6), 720)
def testUnoptimizedNamespaces(self):
- check_syntax_error(self, """\
-def unoptimized_clash1(strip):
- def f(s):
- from string import *
- return strip(s) # ambiguity: free or local
- return f
-""")
-
- check_syntax_error(self, """\
-def unoptimized_clash2():
- from string import *
- def f(s):
- return strip(s) # ambiguity: global or local
- return f
-""")
-
- check_syntax_error(self, """\
-def unoptimized_clash2():
- from string import *
- def g():
- def f(s):
- return strip(s) # ambiguity: global or local
- return f
-""")
-
- # XXX could allow this for exec with const argument, but what's the point
- check_syntax_error(self, """\
-def error(y):
- exec "a = 1"
- def f(x):
- return x + y
- return f
-""")
-
- check_syntax_error(self, """\
-def f(x):
- def g():
- return x
- del x # can't del name
-""")
-
- check_syntax_error(self, """\
-def f():
- def g():
- from string import *
- return strip # global or local?
-""")
-
- # and verify a few cases that should work
-
- exec """
-def noproblem1():
- from string import *
- f = lambda x:x
-
-def noproblem2():
- from string import *
- def f(x):
- return x + 1
-
-def noproblem3():
- from string import *
- def f(x):
- global y
- y = x
-"""
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash1(strip):
+ def f(s):
+ from sys import *
+ return getrefcount(s) # ambiguity: free or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash2():
+ from sys import *
+ def f(s):
+ return getrefcount(s) # ambiguity: global or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def unoptimized_clash2():
+ from sys import *
+ def g():
+ def f(s):
+ return getrefcount(s) # ambiguity: global or local
+ return f
+ """)
+
+ check_syntax_error(self, """if 1:
+ def f():
+ def g():
+ from sys import *
+ return getrefcount # global or local?
+ """)
def testLambdas(self):
@@ -276,7 +251,7 @@ def noproblem3():
def testUnboundLocal(self):
def errorInOuter():
- print y
+ print(y)
def inner():
return y
y = 1
@@ -290,18 +265,40 @@ def noproblem3():
self.assertRaises(UnboundLocalError, errorInOuter)
self.assertRaises(NameError, errorInInner)
+ def testUnboundLocal_AfterDel(self):
+ # #4617: It is now legal to delete a cell variable.
+ # The following functions must obviously compile,
+ # and give the correct error when accessing the deleted name.
+ def errorInOuter():
+ y = 1
+ del y
+ print(y)
+ def inner():
+ return y
+
+ def errorInInner():
+ def inner():
+ return y
+ y = 1
+ del y
+ inner()
+
+ self.assertRaises(UnboundLocalError, errorInOuter)
+ self.assertRaises(NameError, errorInInner)
+
+ def testUnboundLocal_AugAssign(self):
# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation
- exec """
-global_x = 1
-def f():
- global_x += 1
-try:
- f()
-except UnboundLocalError:
- pass
-else:
- fail('scope of global_x not correctly determined')
-""" in {'fail': self.fail}
+ exec("""if 1:
+ global_x = 1
+ def f():
+ global_x += 1
+ try:
+ f()
+ except UnboundLocalError:
+ pass
+ else:
+ fail('scope of global_x not correctly determined')
+ """, {'fail': self.fail})
def testComplexDefinitions(self):
@@ -319,99 +316,89 @@ else:
self.assertEqual(makeReturner2(a=11)()['a'], 11)
- with check_py3k_warnings(("tuple parameter unpacking has been removed",
- SyntaxWarning)):
- exec """\
-def makeAddPair((a, b)):
- def addPair((c, d)):
- return (a + c, b + d)
- return addPair
-""" in locals()
- self.assertEqual(makeAddPair((1, 2))((100, 200)), (101,202))
-
def testScopeOfGlobalStmt(self):
-# Examples posted by Samuele Pedroni to python-dev on 3/1/2001
-
- exec """\
-# I
-x = 7
-def f():
- x = 1
- def g():
- global x
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 7)
-self.assertEqual(x, 7)
-
-# II
-x = 7
-def f():
- x = 1
- def g():
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 7)
-
-# III
-x = 7
-def f():
- x = 1
- def g():
- global x
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 2)
-
-# IV
-x = 7
-def f():
- x = 3
- def g():
- global x
- x = 2
- def i():
- def h():
- return x
- return h()
- return i()
- return g()
-self.assertEqual(f(), 2)
-self.assertEqual(x, 2)
-
-# XXX what about global statements in class blocks?
-# do they affect methods?
-
-x = 12
-class Global:
- global x
- x = 13
- def set(self, val):
- x = val
- def get(self):
- return x
-
-g = Global()
-self.assertEqual(g.get(), 13)
-g.set(15)
-self.assertEqual(g.get(), 13)
-"""
+ # Examples posted by Samuele Pedroni to python-dev on 3/1/2001
+
+ exec("""if 1:
+ # I
+ x = 7
+ def f():
+ x = 1
+ def g():
+ global x
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 7)
+ self.assertEqual(x, 7)
+
+ # II
+ x = 7
+ def f():
+ x = 1
+ def g():
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 7)
+
+ # III
+ x = 7
+ def f():
+ x = 1
+ def g():
+ global x
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 2)
+
+ # IV
+ x = 7
+ def f():
+ x = 3
+ def g():
+ global x
+ x = 2
+ def i():
+ def h():
+ return x
+ return h()
+ return i()
+ return g()
+ self.assertEqual(f(), 2)
+ self.assertEqual(x, 2)
+
+ # XXX what about global statements in class blocks?
+ # do they affect methods?
+
+ x = 12
+ class Global:
+ global x
+ x = 13
+ def set(self, val):
+ x = val
+ def get(self):
+ return x
+
+ g = Global()
+ self.assertEqual(g.get(), 13)
+ g.set(15)
+ self.assertEqual(g.get(), 13)
+ """)
def testLeaks(self):
@@ -437,28 +424,28 @@ self.assertEqual(g.get(), 13)
def testClassAndGlobal(self):
- exec """\
-def test(x):
- class Foo:
- global x
- def __call__(self, y):
- return x + y
- return Foo()
-
-x = 0
-self.assertEqual(test(6)(2), 8)
-x = -1
-self.assertEqual(test(3)(2), 5)
-
-looked_up_by_load_name = False
-class X:
- # Implicit globals inside classes are be looked up by LOAD_NAME, not
- # LOAD_GLOBAL.
- locals()['looked_up_by_load_name'] = True
- passed = looked_up_by_load_name
-
-self.assertTrue(X.passed)
-"""
+ exec("""if 1:
+ def test(x):
+ class Foo:
+ global x
+ def __call__(self, y):
+ return x + y
+ return Foo()
+
+ x = 0
+ self.assertEqual(test(6)(2), 8)
+ x = -1
+ self.assertEqual(test(3)(2), 5)
+
+ looked_up_by_load_name = False
+ class X:
+ # Implicit globals inside classes are be looked up by LOAD_NAME, not
+ # LOAD_GLOBAL.
+ locals()['looked_up_by_load_name'] = True
+ passed = looked_up_by_load_name
+
+ self.assertTrue(X.passed)
+ """)
def testLocalsFunction(self):
@@ -568,10 +555,10 @@ self.assertTrue(X.passed)
return lambda: x + 1
g = f(3)
- self.assertRaises(TypeError, eval, g.func_code)
+ self.assertRaises(TypeError, eval, g.__code__)
try:
- exec g.func_code in {}
+ exec(g.__code__, {})
except TypeError:
pass
else:
@@ -580,18 +567,18 @@ self.assertTrue(X.passed)
def testListCompLocalVars(self):
try:
- print bad
+ print(bad)
except NameError:
pass
else:
- print "bad should not be defined"
+ print("bad should not be defined")
def x():
[bad for s in 'a b' for bad in s.split()]
x()
try:
- print bad
+ print(bad)
except NameError:
pass
@@ -612,41 +599,112 @@ self.assertTrue(X.passed)
def __del__(self):
nestedcell_get()
- def f():
- global nestedcell_get
- def nestedcell_get():
- return c
+ def testNonLocalFunction(self):
+
+ def f(x):
+ def inc():
+ nonlocal x
+ x += 1
+ return x
+ def dec():
+ nonlocal x
+ x -= 1
+ return x
+ return inc, dec
- c = (Special(),)
- c = 2
+ inc, dec = f(0)
+ self.assertEqual(inc(), 1)
+ self.assertEqual(inc(), 2)
+ self.assertEqual(dec(), 1)
+ self.assertEqual(dec(), 0)
- f() # used to crash the interpreter...
+ def testNonLocalMethod(self):
+ def f(x):
+ class c:
+ def inc(self):
+ nonlocal x
+ x += 1
+ return x
+ def dec(self):
+ nonlocal x
+ x -= 1
+ return x
+ return c()
+ c = f(0)
+ self.assertEqual(c.inc(), 1)
+ self.assertEqual(c.inc(), 2)
+ self.assertEqual(c.dec(), 1)
+ self.assertEqual(c.dec(), 0)
def testGlobalInParallelNestedFunctions(self):
# A symbol table bug leaked the global statement from one
# function to other nested functions in the same block.
# This test verifies that a global statement in the first
# function does not affect the second function.
- CODE = """def f():
- y = 1
- def g():
- global y
- return y
- def h():
- return y + 1
- return g, h
-
-y = 9
-g, h = f()
-result9 = g()
-result2 = h()
-"""
local_ns = {}
global_ns = {}
- exec CODE in local_ns, global_ns
+ exec("""if 1:
+ def f():
+ y = 1
+ def g():
+ global y
+ return y
+ def h():
+ return y + 1
+ return g, h
+ y = 9
+ g, h = f()
+ result9 = g()
+ result2 = h()
+ """, local_ns, global_ns)
self.assertEqual(2, global_ns["result2"])
self.assertEqual(9, global_ns["result9"])
+ def testNonLocalClass(self):
+
+ def f(x):
+ class c:
+ nonlocal x
+ x += 1
+ def get(self):
+ return x
+ return c()
+
+ c = f(0)
+ self.assertEqual(c.get(), 1)
+ self.assertNotIn("x", c.__class__.__dict__)
+
+
+ def testNonLocalGenerator(self):
+
+ def f(x):
+ def g(y):
+ nonlocal x
+ for i in range(y):
+ x += 1
+ yield x
+ return g
+
+ g = f(0)
+ self.assertEqual(list(g(5)), [1, 2, 3, 4, 5])
+
+ def testNestedNonLocal(self):
+
+ def f(x):
+ def g():
+ nonlocal x
+ x -= 2
+ def h():
+ nonlocal x
+ x += 4
+ return x
+ return h
+ return g
+
+ g = f(1)
+ h = g()
+ self.assertEqual(h(), 3)
+
def testTopIsNotSignificant(self):
# See #9997.
def top(a):
@@ -655,10 +713,9 @@ result2 = h()
global a
+
def test_main():
- with check_warnings(("import \* only allowed at module level",
- SyntaxWarning)):
- run_unittest(ScopeTests)
+ run_unittest(ScopeTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_scriptpackages.py b/Lib/test/test_scriptpackages.py
deleted file mode 100644
index 7e02fa02f54..00000000000
--- a/Lib/test/test_scriptpackages.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# Copyright (C) 2003 Python Software Foundation
-
-import unittest
-from test import test_support
-
-# Skip this test if aetools does not exist.
-test_support.import_module('aetools')
-
-class TestScriptpackages(unittest.TestCase):
-
- def _test_scriptpackage(self, package, testobject=1):
- # Check that we can import the package
- mod = __import__(package)
- # Test that we can get the main event class
- klass = getattr(mod, package)
- # Test that we can instantiate that class
- talker = klass()
- if testobject:
- # Test that we can get an application object
- obj = mod.application(0)
-
- def test__builtinSuites(self):
- self._test_scriptpackage('_builtinSuites', testobject=0)
-
- def test_StdSuites(self):
- self._test_scriptpackage('StdSuites')
-
- def test_SystemEvents(self):
- self._test_scriptpackage('SystemEvents')
-
- def test_Finder(self):
- self._test_scriptpackage('Finder')
-
- def test_Terminal(self):
- self._test_scriptpackage('Terminal')
-
- def test_Netscape(self):
- self._test_scriptpackage('Netscape')
-
- def test_Explorer(self):
- self._test_scriptpackage('Explorer')
-
- def test_CodeWarrior(self):
- self._test_scriptpackage('CodeWarrior')
-
-def test_main():
- test_support.run_unittest(TestScriptpackages)
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 175bbdac500..4ddc2176caf 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -1,4 +1,4 @@
-from test import test_support
+from test import support
import unittest
import select
import os
@@ -32,18 +32,18 @@ class SelectTestCase(unittest.TestCase):
cmd = 'for i in 0 1 2 3 4 5 6 7 8 9; do echo testing...; sleep 1; done'
p = os.popen(cmd, 'r')
for tout in (0, 1, 2, 4, 8, 16) + (None,)*10:
- if test_support.verbose:
- print 'timeout =', tout
+ if support.verbose:
+ print('timeout =', tout)
rfd, wfd, xfd = select.select([p], [], [], tout)
if (rfd, wfd, xfd) == ([], [], []):
continue
if (rfd, wfd, xfd) == ([p], [], []):
line = p.readline()
- if test_support.verbose:
- print repr(line)
+ if support.verbose:
+ print(repr(line))
if not line:
- if test_support.verbose:
- print 'EOF'
+ if support.verbose:
+ print('EOF')
break
continue
self.fail('Unexpected return values from select():', rfd, wfd, xfd)
@@ -60,8 +60,8 @@ class SelectTestCase(unittest.TestCase):
self.assertEqual(select.select([], a, []), ([], a[:5], []))
def test_main():
- test_support.run_unittest(SelectTestCase)
- test_support.reap_children()
+ support.run_unittest(SelectTestCase)
+ support.reap_children()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_set.py b/Lib/test/test_set.py
index 8db26ed7253..6642440deae 100644
--- a/Lib/test/test_set.py
+++ b/Lib/test/test_set.py
@@ -1,6 +1,5 @@
-
import unittest
-from test import test_support
+from test import support
import gc
import weakref
import operator
@@ -8,6 +7,7 @@ import copy
import pickle
from random import randrange, shuffle
import sys
+import warnings
import collections
class PassThru(Exception):
@@ -20,7 +20,7 @@ def check_pass_thru():
class BadCmp:
def __hash__(self):
return 1
- def __cmp__(self, other):
+ def __eq__(self, other):
raise RuntimeError
class ReprWrapper:
@@ -72,10 +72,10 @@ class TestJointOps(unittest.TestCase):
for c in self.letters:
self.assertEqual(c in u, c in self.d or c in self.otherword)
self.assertEqual(self.s, self.thetype(self.word))
- self.assertEqual(type(u), self.thetype)
+ self.assertEqual(type(u), self.basetype)
self.assertRaises(PassThru, self.s.union, check_pass_thru())
self.assertRaises(TypeError, self.s.union, [[]])
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').union(C('cdc')), set('abcd'))
self.assertEqual(self.thetype('abcba').union(C('efgfe')), set('abcefg'))
self.assertEqual(self.thetype('abcba').union(C('ccb')), set('abc'))
@@ -102,9 +102,9 @@ class TestJointOps(unittest.TestCase):
for c in self.letters:
self.assertEqual(c in i, c in self.d and c in self.otherword)
self.assertEqual(self.s, self.thetype(self.word))
- self.assertEqual(type(i), self.thetype)
+ self.assertEqual(type(i), self.basetype)
self.assertRaises(PassThru, self.s.intersection, check_pass_thru())
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').intersection(C('cdc')), set('cc'))
self.assertEqual(self.thetype('abcba').intersection(C('efgfe')), set(''))
self.assertEqual(self.thetype('abcba').intersection(C('ccb')), set('bc'))
@@ -124,7 +124,7 @@ class TestJointOps(unittest.TestCase):
for larg in '', 'a', 'ab', 'abc', 'ababac', 'cdc', 'cc', 'efgfe', 'ccb', 'ef':
s1 = self.thetype(larg)
for rarg in '', 'a', 'ab', 'abc', 'ababac', 'cdc', 'cc', 'efgfe', 'ccb', 'ef':
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s2 = C(rarg)
actual = s1.isdisjoint(s2)
expected = f(s1, s2)
@@ -147,10 +147,10 @@ class TestJointOps(unittest.TestCase):
for c in self.letters:
self.assertEqual(c in i, c in self.d and c not in self.otherword)
self.assertEqual(self.s, self.thetype(self.word))
- self.assertEqual(type(i), self.thetype)
+ self.assertEqual(type(i), self.basetype)
self.assertRaises(PassThru, self.s.difference, check_pass_thru())
self.assertRaises(TypeError, self.s.difference, [[]])
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').difference(C('cdc')), set('ab'))
self.assertEqual(self.thetype('abcba').difference(C('efgfe')), set('abc'))
self.assertEqual(self.thetype('abcba').difference(C('ccb')), set('a'))
@@ -174,10 +174,10 @@ class TestJointOps(unittest.TestCase):
for c in self.letters:
self.assertEqual(c in i, (c in self.d) ^ (c in self.otherword))
self.assertEqual(self.s, self.thetype(self.word))
- self.assertEqual(type(i), self.thetype)
+ self.assertEqual(type(i), self.basetype)
self.assertRaises(PassThru, self.s.symmetric_difference, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference, [[]])
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
self.assertEqual(self.thetype('abcba').symmetric_difference(C('cdc')), set('abd'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('efgfe')), set('abcefg'))
self.assertEqual(self.thetype('abcba').symmetric_difference(C('ccb')), set('a'))
@@ -207,9 +207,6 @@ class TestJointOps(unittest.TestCase):
s = self.thetype(t)
self.assertEqual(len(s), 3)
- def test_compare(self):
- self.assertRaises(TypeError, self.s.__cmp__, self.s)
-
def test_sub_and_super(self):
p, q, r = map(self.thetype, ['ab', 'abcde', 'def'])
self.assertTrue(p < q)
@@ -258,7 +255,7 @@ class TestJointOps(unittest.TestCase):
# Create a nest of cycles to exercise overall ref count check
class A:
pass
- s = set(A() for i in xrange(1000))
+ s = set(A() for i in range(1000))
for elem in s:
elem.cycle = s
elem.sub = elem
@@ -292,26 +289,29 @@ class TestJointOps(unittest.TestCase):
w = ReprWrapper()
s = self.thetype([w])
w.value = s
- name = repr(s).partition('(')[0] # strip class name from repr string
- self.assertEqual(repr(s), '%s([%s(...)])' % (name, name))
+ if self.thetype == set:
+ self.assertEqual(repr(s), '{set(...)}')
+ else:
+ name = repr(s).partition('(')[0] # strip class name
+ self.assertEqual(repr(s), '%s({%s(...)})' % (name, name))
def test_cyclical_print(self):
w = ReprWrapper()
s = self.thetype([w])
w.value = s
- fo = open(test_support.TESTFN, "wb")
+ fo = open(support.TESTFN, "w")
try:
- print >> fo, s,
+ fo.write(str(s))
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(s))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_do_not_rehash_dict_keys(self):
n = 10
- d = dict.fromkeys(map(HashCountingInt, xrange(n)))
+ d = dict.fromkeys(map(HashCountingInt, range(n)))
self.assertEqual(sum(elem.hash_count for elem in d), n)
s = self.thetype(d)
self.assertEqual(sum(elem.hash_count for elem in d), n)
@@ -342,6 +342,7 @@ class TestJointOps(unittest.TestCase):
class TestSet(TestJointOps):
thetype = set
+ basetype = set
def test_init(self):
s = self.thetype()
@@ -357,6 +358,11 @@ class TestSet(TestJointOps):
t = self.thetype(s)
self.assertNotEqual(id(s), id(t))
+ def test_set_literal(self):
+ s = set([1,2,3])
+ t = {1,2,3}
+ self.assertEqual(s, t)
+
def test_hash(self):
self.assertRaises(TypeError, hash, self.s)
@@ -369,6 +375,7 @@ class TestSet(TestJointOps):
dup = self.s.copy()
self.assertEqual(self.s, dup)
self.assertNotEqual(id(self.s), id(dup))
+ self.assertEqual(type(dup), self.basetype)
def test_add(self):
self.s.add('Q')
@@ -394,7 +401,7 @@ class TestSet(TestJointOps):
for v1 in ['Q', (1,)]:
try:
self.s.remove(v1)
- except KeyError, e:
+ except KeyError as e:
v2 = e.args[0]
self.assertEqual(v1, v2)
else:
@@ -423,7 +430,7 @@ class TestSet(TestJointOps):
s.discard(self.thetype(self.word))
def test_pop(self):
- for i in xrange(len(self.s)):
+ for i in range(len(self.s)):
elem = self.s.pop()
self.assertNotIn(elem, self.s)
self.assertRaises(KeyError, self.s.pop)
@@ -436,13 +443,13 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.update, check_pass_thru())
self.assertRaises(TypeError, self.s.update, [[]])
for p, q in (('cdc', 'abcd'), ('efgfe', 'abcefg'), ('ccb', 'abc'), ('ef', 'abcef')):
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.update(C(p)), None)
self.assertEqual(s, set(q))
for p in ('cdc', 'efgfe', 'ccb', 'ef', 'abcda'):
q = 'ahi'
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.update(C(p), C(q)), None)
self.assertEqual(s, set(s) | set(p) | set(q))
@@ -463,7 +470,7 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.intersection_update, check_pass_thru())
self.assertRaises(TypeError, self.s.intersection_update, [[]])
for p, q in (('cdc', 'c'), ('efgfe', ''), ('ccb', 'bc'), ('ef', '')):
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.intersection_update(C(p)), None)
self.assertEqual(s, set(q))
@@ -493,7 +500,7 @@ class TestSet(TestJointOps):
self.assertRaises(TypeError, self.s.difference_update, [[]])
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'ab'), ('efgfe', 'abc'), ('ccb', 'a'), ('ef', 'abc')):
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.difference_update(C(p)), None)
self.assertEqual(s, set(q))
@@ -529,7 +536,7 @@ class TestSet(TestJointOps):
self.assertRaises(PassThru, self.s.symmetric_difference_update, check_pass_thru())
self.assertRaises(TypeError, self.s.symmetric_difference_update, [[]])
for p, q in (('cdc', 'abd'), ('efgfe', 'abcefg'), ('ccb', 'a'), ('ef', 'abcef')):
- for C in set, frozenset, dict.fromkeys, str, unicode, list, tuple:
+ for C in set, frozenset, dict.fromkeys, str, list, tuple:
s = self.thetype('abcba')
self.assertEqual(s.symmetric_difference_update(C(p)), None)
self.assertEqual(s, set(q))
@@ -561,6 +568,42 @@ class TestSet(TestJointOps):
s = None
self.assertRaises(ReferenceError, str, p)
+ def test_rich_compare(self):
+ class TestRichSetCompare:
+ def __gt__(self, some_set):
+ self.gt_called = True
+ return False
+ def __lt__(self, some_set):
+ self.lt_called = True
+ return False
+ def __ge__(self, some_set):
+ self.ge_called = True
+ return False
+ def __le__(self, some_set):
+ self.le_called = True
+ return False
+
+ # This first tries the builtin rich set comparison, which doesn't know
+ # how to handle the custom object. Upon returning NotImplemented, the
+ # corresponding comparison on the right object is invoked.
+ myset = {1, 2, 3}
+
+ myobj = TestRichSetCompare()
+ myset < myobj
+ self.assertTrue(myobj.gt_called)
+
+ myobj = TestRichSetCompare()
+ myset > myobj
+ self.assertTrue(myobj.lt_called)
+
+ myobj = TestRichSetCompare()
+ myset <= myobj
+ self.assertTrue(myobj.ge_called)
+
+ myobj = TestRichSetCompare()
+ myset >= myobj
+ self.assertTrue(myobj.le_called)
+
# C API test only available in a debug build
if hasattr(set, "test_c_api"):
def test_c_api(self):
@@ -571,6 +614,7 @@ class SetSubclass(set):
class TestSetSubclass(TestSet):
thetype = SetSubclass
+ basetype = set
class SetSubclassWithKeywordArgs(set):
def __init__(self, iterable=[], newarg=None):
@@ -584,6 +628,7 @@ class TestSetSubclassWithKeywordArgs(TestSet):
class TestFrozenSet(TestJointOps):
thetype = frozenset
+ basetype = frozenset
def test_init(self):
s = self.thetype(self.word)
@@ -594,7 +639,7 @@ class TestFrozenSet(TestJointOps):
f = frozenset()
efs = [frozenset(), frozenset([]), frozenset(()), frozenset(''),
frozenset(), frozenset([]), frozenset(()), frozenset(''),
- frozenset(xrange(0)), frozenset(frozenset()),
+ frozenset(range(0)), frozenset(frozenset()),
frozenset(f), f]
# All of the empty frozensets should have just one id()
self.assertEqual(len(set(map(id, efs))), 1)
@@ -610,9 +655,9 @@ class TestFrozenSet(TestJointOps):
# make sure that all permutations give the same hash value
n = 100
- seq = [randrange(n) for i in xrange(n)]
+ seq = [randrange(n) for i in range(n)]
results = set()
- for i in xrange(200):
+ for i in range(200):
shuffle(seq)
results.add(hash(self.thetype(seq)))
self.assertEqual(len(results), 1)
@@ -622,7 +667,7 @@ class TestFrozenSet(TestJointOps):
self.assertEqual(id(self.s), id(dup))
def test_frozen_as_dictkey(self):
- seq = range(10) + list('abcdefg') + ['apple']
+ seq = list(range(10)) + list('abcdefg') + ['apple']
key1 = self.thetype(seq)
key2 = self.thetype(reversed(seq))
self.assertEqual(key1, key2)
@@ -640,7 +685,7 @@ class TestFrozenSet(TestJointOps):
hashvalues = set()
addhashvalue = hashvalues.add
elemmasks = [(i+1, 1<<i) for i in range(n)]
- for i in xrange(2**n):
+ for i in range(2**n):
addhashvalue(hash(frozenset([e for e, m in elemmasks if m&i])))
self.assertEqual(len(hashvalues), 2**n)
@@ -649,6 +694,7 @@ class FrozenSetSubclass(frozenset):
class TestFrozenSetSubclass(TestFrozenSet):
thetype = FrozenSetSubclass
+ basetype = frozenset
def test_constructor_identity(self):
s = self.thetype(range(3))
@@ -670,7 +716,7 @@ class TestFrozenSetSubclass(TestFrozenSet):
F = Frozenset()
efs = [Frozenset(), Frozenset([]), Frozenset(()), Frozenset(''),
Frozenset(), Frozenset([]), Frozenset(()), Frozenset(''),
- Frozenset(xrange(0)), Frozenset(Frozenset()),
+ Frozenset(range(0)), Frozenset(Frozenset()),
Frozenset(frozenset()), f, F, Frozenset(f), Frozenset(F)]
# All empty frozenset subclass instances should have different ids
self.assertEqual(len(set(map(id, efs))), len(efs))
@@ -699,15 +745,15 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(result, sorted_repr_values)
def test_print(self):
- fo = open(test_support.TESTFN, "wb")
try:
- print >> fo, self.set,
+ fo = open(support.TESTFN, "w")
+ fo.write(str(self.set))
fo.close()
- fo = open(test_support.TESTFN, "rb")
+ fo = open(support.TESTFN, "r")
self.assertEqual(fo.read(), repr(self.set))
finally:
fo.close()
- test_support.unlink(test_support.TESTFN)
+ support.unlink(support.TESTFN)
def test_length(self):
self.assertEqual(len(self.set), self.length)
@@ -800,7 +846,7 @@ class TestBasicOpsEmpty(TestBasicOps):
self.set = set(self.values)
self.dup = set(self.values)
self.length = 0
- self.repr = "set([])"
+ self.repr = "set()"
#------------------------------------------------------------------------------
@@ -811,7 +857,7 @@ class TestBasicOpsSingleton(TestBasicOps):
self.set = set(self.values)
self.dup = set(self.values)
self.length = 1
- self.repr = "set([3])"
+ self.repr = "{3}"
def test_in(self):
self.assertIn(3, self.set)
@@ -828,7 +874,7 @@ class TestBasicOpsTuple(TestBasicOps):
self.set = set(self.values)
self.dup = set(self.values)
self.length = 1
- self.repr = "set([(0, 'zero')])"
+ self.repr = "{(0, 'zero')}"
def test_in(self):
self.assertIn((0, "zero"), self.set)
@@ -862,10 +908,10 @@ class TestBasicOpsString(TestBasicOps):
#------------------------------------------------------------------------------
-class TestBasicOpsUnicode(TestBasicOps):
+class TestBasicOpsBytes(TestBasicOps):
def setUp(self):
- self.case = "unicode set"
- self.values = [u"a", u"b", u"c"]
+ self.case = "string set"
+ self.values = [b"a", b"b", b"c"]
self.set = set(self.values)
self.dup = set(self.values)
self.length = 3
@@ -875,17 +921,22 @@ class TestBasicOpsUnicode(TestBasicOps):
#------------------------------------------------------------------------------
-class TestBasicOpsMixedStringUnicode(TestBasicOps):
+class TestBasicOpsMixedStringBytes(TestBasicOps):
def setUp(self):
+ self._warning_filters = support.check_warnings()
+ self._warning_filters.__enter__()
+ warnings.simplefilter('ignore', BytesWarning)
self.case = "string and bytes set"
- self.values = ["a", "b", u"a", u"b"]
+ self.values = ["a", "b", b"a", b"b"]
self.set = set(self.values)
self.dup = set(self.values)
self.length = 4
+ def tearDown(self):
+ self._warning_filters.__exit__(None, None, None)
+
def test_repr(self):
- with test_support.check_warnings():
- self.check_repr_against_values()
+ self.check_repr_against_values()
#==============================================================================
@@ -907,7 +958,7 @@ class TestExceptionPropagation(unittest.TestCase):
set([1,2,3])
set((1,2,3))
set({'one':1, 'two':2, 'three':3})
- set(xrange(3))
+ set(range(3))
set('abc')
set(gooditer())
@@ -1007,19 +1058,6 @@ class TestBinaryOps(unittest.TestCase):
result = self.set ^ set([8])
self.assertEqual(result, set([2, 4, 6, 8]))
- def test_cmp(self):
- a, b = set('a'), set('b')
- self.assertRaises(TypeError, cmp, a, b)
-
- # You can view this as a buglet: cmp(a, a) does not raise TypeError,
- # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True,
- # which Python thinks is good enough to synthesize a cmp() result
- # without calling __cmp__.
- self.assertEqual(cmp(a, a), 0)
-
- self.assertRaises(TypeError, cmp, a, 12)
- self.assertRaises(TypeError, cmp, "abc", a)
-
#==============================================================================
class TestUpdateOps(unittest.TestCase):
@@ -1398,10 +1436,6 @@ class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
self.other = operator.add
self.otherIsIterable = False
- def test_ge_gt_le_lt(self):
- with test_support.check_py3k_warnings():
- super(TestOnlySetsOperator, self).test_ge_gt_le_lt()
-
#------------------------------------------------------------------------------
class TestOnlySetsTuple(TestOnlySetsInBinaryOps):
@@ -1423,7 +1457,7 @@ class TestOnlySetsString(TestOnlySetsInBinaryOps):
class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
def setUp(self):
def gen():
- for i in xrange(0, 10, 2):
+ for i in range(0, 10, 2):
yield i
self.set = set((1, 2, 3))
self.other = gen()
@@ -1434,17 +1468,21 @@ class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
class TestCopying(unittest.TestCase):
def test_copy(self):
- dup = list(self.set.copy())
- self.assertEqual(len(dup), len(self.set))
- for el in self.set:
- self.assertIn(el, dup)
- pos = dup.index(el)
- self.assertIs(el, dup.pop(pos))
- self.assertFalse(dup)
+ dup = self.set.copy()
+ dup_list = sorted(dup, key=repr)
+ set_list = sorted(self.set, key=repr)
+ self.assertEqual(len(dup_list), len(set_list))
+ for i in range(len(dup_list)):
+ self.assertTrue(dup_list[i] is set_list[i])
def test_deep_copy(self):
dup = copy.deepcopy(self.set)
- self.assertSetEqual(dup, self.set)
+ ##print type(dup), repr(dup)
+ dup_list = sorted(dup, key=repr)
+ set_list = sorted(self.set, key=repr)
+ self.assertEqual(len(dup_list), len(set_list))
+ for i in range(len(dup_list)):
+ self.assertEqual(dup_list[i], set_list[i])
#------------------------------------------------------------------------------
@@ -1540,7 +1578,7 @@ class I:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -1560,14 +1598,14 @@ class X:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def next(self):
+ def __next__(self):
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
return v
class N:
- 'Iterator missing next()'
+ 'Iterator missing __next__()'
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
@@ -1581,7 +1619,7 @@ class E:
self.i = 0
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
3 // 0
class S:
@@ -1590,28 +1628,28 @@ class S:
pass
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
raise StopIteration
-from itertools import chain, imap
+from itertools import chain
def L(seqn):
'Test multiple tiers of iterators'
- return chain(imap(lambda x:x, R(Ig(G(seqn)))))
+ return chain(map(lambda x:x, R(Ig(G(seqn)))))
class TestVariousIteratorArgs(unittest.TestCase):
def test_constructor(self):
for cons in (set, frozenset):
- for s in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5)):
+ for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
- self.assertSetEqual(cons(g(s)), set(g(s)))
+ self.assertEqual(sorted(cons(g(s)), key=repr), sorted(g(s), key=repr))
self.assertRaises(TypeError, cons , X(s))
self.assertRaises(TypeError, cons , N(s))
self.assertRaises(ZeroDivisionError, cons , E(s))
def test_inline_methods(self):
s = set('november')
- for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'):
+ for data in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5), 'december'):
for meth in (s.union, s.intersection, s.difference, s.symmetric_difference, s.isdisjoint):
for g in (G, I, Ig, L, R):
expected = meth(data)
@@ -1619,13 +1657,13 @@ class TestVariousIteratorArgs(unittest.TestCase):
if isinstance(expected, bool):
self.assertEqual(actual, expected)
else:
- self.assertSetEqual(actual, expected)
+ self.assertEqual(sorted(actual, key=repr), sorted(expected, key=repr))
self.assertRaises(TypeError, meth, X(s))
self.assertRaises(TypeError, meth, N(s))
self.assertRaises(ZeroDivisionError, meth, E(s))
def test_inplace_methods(self):
- for data in ("123", "", range(1000), ('do', 1.2), xrange(2000,2200,5), 'december'):
+ for data in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5), 'december'):
for methname in ('update', 'intersection_update',
'difference_update', 'symmetric_difference_update'):
for g in (G, I, Ig, S, L, R):
@@ -1633,7 +1671,7 @@ class TestVariousIteratorArgs(unittest.TestCase):
t = s.copy()
getattr(s, methname)(list(g(data)))
getattr(t, methname)(g(data))
- self.assertSetEqual(s, t)
+ self.assertEqual(sorted(s, key=repr), sorted(t, key=repr))
self.assertRaises(TypeError, getattr(set('january'), methname), X(data))
self.assertRaises(TypeError, getattr(set('january'), methname), N(data))
@@ -1678,7 +1716,7 @@ def powerset(U):
"""Generates all subsets of a set or sequence U."""
U = iter(U)
try:
- x = frozenset([U.next()])
+ x = frozenset([next(U)])
for S in powerset(U):
yield S
yield S | x
@@ -1791,6 +1829,9 @@ def test_main(verbose=None):
TestBasicOpsSingleton,
TestBasicOpsTuple,
TestBasicOpsTriple,
+ TestBasicOpsString,
+ TestBasicOpsBytes,
+ TestBasicOpsMixedStringBytes,
TestBinaryOps,
TestUpdateOps,
TestMutate,
@@ -1816,17 +1857,17 @@ def test_main(verbose=None):
TestWeirdBugs,
)
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
gc.collect()
counts[i] = sys.gettotalrefcount()
- print counts
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_setcomps.py b/Lib/test/test_setcomps.py
index db5e6f7c970..fb7cde03d78 100644
--- a/Lib/test/test_setcomps.py
+++ b/Lib/test/test_setcomps.py
@@ -9,7 +9,7 @@ Test simple loop with conditional
Test simple case
>>> {2*y + x + 1 for x in (0,) for y in (1,)}
- set([3])
+ {3}
Test simple nesting
@@ -68,7 +68,7 @@ Generators can call other generators:
Make sure that None is a valid return value
>>> {None for i in range(10)}
- set([None])
+ {None}
########### Tests for various scoping corner cases ############
@@ -82,21 +82,21 @@ Same again, only this time as a closure variable
>>> items = {(lambda: i) for i in range(5)}
>>> {x() for x in items}
- set([4])
+ {4}
Another way to test that the iteration variable is local to the list comp
>>> items = {(lambda: i) for i in range(5)}
>>> i = 20
>>> {x() for x in items}
- set([4])
+ {4}
And confirm that a closure can jump over the list comp scope
>>> items = {(lambda: y) for i in range(5)}
>>> y = 2
>>> {x() for x in items}
- set([2])
+ {2}
We also repeat each of the above scoping tests inside a function
@@ -110,21 +110,21 @@ We also repeat each of the above scoping tests inside a function
... items = {(lambda: i) for i in range(5)}
... return {x() for x in items}
>>> test_func()
- set([4])
+ {4}
>>> def test_func():
... items = {(lambda: i) for i in range(5)}
... i = 20
... return {x() for x in items}
>>> test_func()
- set([4])
+ {4}
>>> def test_func():
... items = {(lambda: y) for i in range(5)}
... y = 2
... return {x() for x in items}
>>> test_func()
- set([2])
+ {2}
"""
@@ -133,16 +133,16 @@ __test__ = {'doctests' : doctests}
def test_main(verbose=None):
import sys
- from test import test_support
+ from test import support
from test import test_setcomps
- test_support.run_doctest(test_setcomps, verbose)
+ support.run_doctest(test_setcomps, verbose)
# verify reference counting
if verbose and hasattr(sys, "gettotalrefcount"):
import gc
counts = [None] * 5
for i in range(len(counts)):
- test_support.run_doctest(test_setcomps, verbose)
+ support.run_doctest(test_setcomps, verbose)
gc.collect()
counts[i] = sys.gettotalrefcount()
print(counts)
diff --git a/Lib/test/test_sets.py b/Lib/test/test_sets.py
deleted file mode 100644
index 0754ed74fc7..00000000000
--- a/Lib/test/test_sets.py
+++ /dev/null
@@ -1,862 +0,0 @@
-#!/usr/bin/env python
-
-import unittest, operator, copy, pickle, random
-from test import test_support
-
-test_support.import_module("sets", deprecated=True)
-from sets import Set, ImmutableSet
-
-empty_set = Set()
-
-#==============================================================================
-
-class TestBasicOps(unittest.TestCase):
-
- def test_repr(self):
- if self.repr is not None:
- self.assertEqual(repr(self.set), self.repr)
-
- def test_length(self):
- self.assertEqual(len(self.set), self.length)
-
- def test_self_equality(self):
- self.assertEqual(self.set, self.set)
-
- def test_equivalent_equality(self):
- self.assertEqual(self.set, self.dup)
-
- def test_copy(self):
- self.assertEqual(self.set.copy(), self.dup)
-
- def test_self_union(self):
- result = self.set | self.set
- self.assertEqual(result, self.dup)
-
- def test_empty_union(self):
- result = self.set | empty_set
- self.assertEqual(result, self.dup)
-
- def test_union_empty(self):
- result = empty_set | self.set
- self.assertEqual(result, self.dup)
-
- def test_self_intersection(self):
- result = self.set & self.set
- self.assertEqual(result, self.dup)
-
- def test_empty_intersection(self):
- result = self.set & empty_set
- self.assertEqual(result, empty_set)
-
- def test_intersection_empty(self):
- result = empty_set & self.set
- self.assertEqual(result, empty_set)
-
- def test_self_symmetric_difference(self):
- result = self.set ^ self.set
- self.assertEqual(result, empty_set)
-
- def checkempty_symmetric_difference(self):
- result = self.set ^ empty_set
- self.assertEqual(result, self.set)
-
- def test_self_difference(self):
- result = self.set - self.set
- self.assertEqual(result, empty_set)
-
- def test_empty_difference(self):
- result = self.set - empty_set
- self.assertEqual(result, self.dup)
-
- def test_empty_difference_rev(self):
- result = empty_set - self.set
- self.assertEqual(result, empty_set)
-
- def test_iteration(self):
- for v in self.set:
- self.assertIn(v, self.values)
-
- def test_pickling(self):
- p = pickle.dumps(self.set)
- copy = pickle.loads(p)
- self.assertEqual(self.set, copy,
- "%s != %s" % (self.set, copy))
-
-#------------------------------------------------------------------------------
-
-class TestBasicOpsEmpty(TestBasicOps):
- def setUp(self):
- self.case = "empty set"
- self.values = []
- self.set = Set(self.values)
- self.dup = Set(self.values)
- self.length = 0
- self.repr = "Set([])"
-
-#------------------------------------------------------------------------------
-
-class TestBasicOpsSingleton(TestBasicOps):
- def setUp(self):
- self.case = "unit set (number)"
- self.values = [3]
- self.set = Set(self.values)
- self.dup = Set(self.values)
- self.length = 1
- self.repr = "Set([3])"
-
- def test_in(self):
- self.assertTrue(3 in self.set)
-
- def test_not_in(self):
- self.assertTrue(2 not in self.set)
-
-#------------------------------------------------------------------------------
-
-class TestBasicOpsTuple(TestBasicOps):
- def setUp(self):
- self.case = "unit set (tuple)"
- self.values = [(0, "zero")]
- self.set = Set(self.values)
- self.dup = Set(self.values)
- self.length = 1
- self.repr = "Set([(0, 'zero')])"
-
- def test_in(self):
- self.assertTrue((0, "zero") in self.set)
-
- def test_not_in(self):
- self.assertTrue(9 not in self.set)
-
-#------------------------------------------------------------------------------
-
-class TestBasicOpsTriple(TestBasicOps):
- def setUp(self):
- self.case = "triple set"
- self.values = [0, "zero", operator.add]
- self.set = Set(self.values)
- self.dup = Set(self.values)
- self.length = 3
- self.repr = None
-
-#==============================================================================
-
-def baditer():
- raise TypeError
- yield True
-
-def gooditer():
- yield True
-
-class TestExceptionPropagation(unittest.TestCase):
- """SF 628246: Set constructor should not trap iterator TypeErrors"""
-
- def test_instanceWithException(self):
- self.assertRaises(TypeError, Set, baditer())
-
- def test_instancesWithoutException(self):
- # All of these iterables should load without exception.
- Set([1,2,3])
- Set((1,2,3))
- Set({'one':1, 'two':2, 'three':3})
- Set(xrange(3))
- Set('abc')
- Set(gooditer())
-
-#==============================================================================
-
-class TestSetOfSets(unittest.TestCase):
- def test_constructor(self):
- inner = Set([1])
- outer = Set([inner])
- element = outer.pop()
- self.assertEqual(type(element), ImmutableSet)
- outer.add(inner) # Rebuild set of sets with .add method
- outer.remove(inner)
- self.assertEqual(outer, Set()) # Verify that remove worked
- outer.discard(inner) # Absence of KeyError indicates working fine
-
-#==============================================================================
-
-class TestBinaryOps(unittest.TestCase):
- def setUp(self):
- self.set = Set((2, 4, 6))
-
- def test_eq(self): # SF bug 643115
- self.assertEqual(self.set, Set({2:1,4:3,6:5}))
-
- def test_union_subset(self):
- result = self.set | Set([2])
- self.assertEqual(result, Set((2, 4, 6)))
-
- def test_union_superset(self):
- result = self.set | Set([2, 4, 6, 8])
- self.assertEqual(result, Set([2, 4, 6, 8]))
-
- def test_union_overlap(self):
- result = self.set | Set([3, 4, 5])
- self.assertEqual(result, Set([2, 3, 4, 5, 6]))
-
- def test_union_non_overlap(self):
- result = self.set | Set([8])
- self.assertEqual(result, Set([2, 4, 6, 8]))
-
- def test_intersection_subset(self):
- result = self.set & Set((2, 4))
- self.assertEqual(result, Set((2, 4)))
-
- def test_intersection_superset(self):
- result = self.set & Set([2, 4, 6, 8])
- self.assertEqual(result, Set([2, 4, 6]))
-
- def test_intersection_overlap(self):
- result = self.set & Set([3, 4, 5])
- self.assertEqual(result, Set([4]))
-
- def test_intersection_non_overlap(self):
- result = self.set & Set([8])
- self.assertEqual(result, empty_set)
-
- def test_sym_difference_subset(self):
- result = self.set ^ Set((2, 4))
- self.assertEqual(result, Set([6]))
-
- def test_sym_difference_superset(self):
- result = self.set ^ Set((2, 4, 6, 8))
- self.assertEqual(result, Set([8]))
-
- def test_sym_difference_overlap(self):
- result = self.set ^ Set((3, 4, 5))
- self.assertEqual(result, Set([2, 3, 5, 6]))
-
- def test_sym_difference_non_overlap(self):
- result = self.set ^ Set([8])
- self.assertEqual(result, Set([2, 4, 6, 8]))
-
- def test_cmp(self):
- a, b = Set('a'), Set('b')
- self.assertRaises(TypeError, cmp, a, b)
-
- # You can view this as a buglet: cmp(a, a) does not raise TypeError,
- # because __eq__ is tried before __cmp__, and a.__eq__(a) returns True,
- # which Python thinks is good enough to synthesize a cmp() result
- # without calling __cmp__.
- self.assertEqual(cmp(a, a), 0)
-
- self.assertRaises(TypeError, cmp, a, 12)
- self.assertRaises(TypeError, cmp, "abc", a)
-
- def test_inplace_on_self(self):
- t = self.set.copy()
- t |= t
- self.assertEqual(t, self.set)
- t &= t
- self.assertEqual(t, self.set)
- t -= t
- self.assertEqual(len(t), 0)
- t = self.set.copy()
- t ^= t
- self.assertEqual(len(t), 0)
-
-
-#==============================================================================
-
-class TestUpdateOps(unittest.TestCase):
- def setUp(self):
- self.set = Set((2, 4, 6))
-
- def test_union_subset(self):
- self.set |= Set([2])
- self.assertEqual(self.set, Set((2, 4, 6)))
-
- def test_union_superset(self):
- self.set |= Set([2, 4, 6, 8])
- self.assertEqual(self.set, Set([2, 4, 6, 8]))
-
- def test_union_overlap(self):
- self.set |= Set([3, 4, 5])
- self.assertEqual(self.set, Set([2, 3, 4, 5, 6]))
-
- def test_union_non_overlap(self):
- self.set |= Set([8])
- self.assertEqual(self.set, Set([2, 4, 6, 8]))
-
- def test_union_method_call(self):
- self.set.union_update(Set([3, 4, 5]))
- self.assertEqual(self.set, Set([2, 3, 4, 5, 6]))
-
- def test_intersection_subset(self):
- self.set &= Set((2, 4))
- self.assertEqual(self.set, Set((2, 4)))
-
- def test_intersection_superset(self):
- self.set &= Set([2, 4, 6, 8])
- self.assertEqual(self.set, Set([2, 4, 6]))
-
- def test_intersection_overlap(self):
- self.set &= Set([3, 4, 5])
- self.assertEqual(self.set, Set([4]))
-
- def test_intersection_non_overlap(self):
- self.set &= Set([8])
- self.assertEqual(self.set, empty_set)
-
- def test_intersection_method_call(self):
- self.set.intersection_update(Set([3, 4, 5]))
- self.assertEqual(self.set, Set([4]))
-
- def test_sym_difference_subset(self):
- self.set ^= Set((2, 4))
- self.assertEqual(self.set, Set([6]))
-
- def test_sym_difference_superset(self):
- self.set ^= Set((2, 4, 6, 8))
- self.assertEqual(self.set, Set([8]))
-
- def test_sym_difference_overlap(self):
- self.set ^= Set((3, 4, 5))
- self.assertEqual(self.set, Set([2, 3, 5, 6]))
-
- def test_sym_difference_non_overlap(self):
- self.set ^= Set([8])
- self.assertEqual(self.set, Set([2, 4, 6, 8]))
-
- def test_sym_difference_method_call(self):
- self.set.symmetric_difference_update(Set([3, 4, 5]))
- self.assertEqual(self.set, Set([2, 3, 5, 6]))
-
- def test_difference_subset(self):
- self.set -= Set((2, 4))
- self.assertEqual(self.set, Set([6]))
-
- def test_difference_superset(self):
- self.set -= Set((2, 4, 6, 8))
- self.assertEqual(self.set, Set([]))
-
- def test_difference_overlap(self):
- self.set -= Set((3, 4, 5))
- self.assertEqual(self.set, Set([2, 6]))
-
- def test_difference_non_overlap(self):
- self.set -= Set([8])
- self.assertEqual(self.set, Set([2, 4, 6]))
-
- def test_difference_method_call(self):
- self.set.difference_update(Set([3, 4, 5]))
- self.assertEqual(self.set, Set([2, 6]))
-
-#==============================================================================
-
-class TestMutate(unittest.TestCase):
- def setUp(self):
- self.values = ["a", "b", "c"]
- self.set = Set(self.values)
-
- def test_add_present(self):
- self.set.add("c")
- self.assertEqual(self.set, Set("abc"))
-
- def test_add_absent(self):
- self.set.add("d")
- self.assertEqual(self.set, Set("abcd"))
-
- def test_add_until_full(self):
- tmp = Set()
- expected_len = 0
- for v in self.values:
- tmp.add(v)
- expected_len += 1
- self.assertEqual(len(tmp), expected_len)
- self.assertEqual(tmp, self.set)
-
- def test_remove_present(self):
- self.set.remove("b")
- self.assertEqual(self.set, Set("ac"))
-
- def test_remove_absent(self):
- try:
- self.set.remove("d")
- self.fail("Removing missing element should have raised LookupError")
- except LookupError:
- pass
-
- def test_remove_until_empty(self):
- expected_len = len(self.set)
- for v in self.values:
- self.set.remove(v)
- expected_len -= 1
- self.assertEqual(len(self.set), expected_len)
-
- def test_discard_present(self):
- self.set.discard("c")
- self.assertEqual(self.set, Set("ab"))
-
- def test_discard_absent(self):
- self.set.discard("d")
- self.assertEqual(self.set, Set("abc"))
-
- def test_clear(self):
- self.set.clear()
- self.assertEqual(len(self.set), 0)
-
- def test_pop(self):
- popped = {}
- while self.set:
- popped[self.set.pop()] = None
- self.assertEqual(len(popped), len(self.values))
- for v in self.values:
- self.assertIn(v, popped)
-
- def test_update_empty_tuple(self):
- self.set.union_update(())
- self.assertEqual(self.set, Set(self.values))
-
- def test_update_unit_tuple_overlap(self):
- self.set.union_update(("a",))
- self.assertEqual(self.set, Set(self.values))
-
- def test_update_unit_tuple_non_overlap(self):
- self.set.union_update(("a", "z"))
- self.assertEqual(self.set, Set(self.values + ["z"]))
-
-#==============================================================================
-
-class TestSubsets(unittest.TestCase):
-
- case2method = {"<=": "issubset",
- ">=": "issuperset",
- }
-
- reverse = {"==": "==",
- "!=": "!=",
- "<": ">",
- ">": "<",
- "<=": ">=",
- ">=": "<=",
- }
-
- def test_issubset(self):
- x = self.left
- y = self.right
- for case in "!=", "==", "<", "<=", ">", ">=":
- expected = case in self.cases
- # Test the binary infix spelling.
- result = eval("x" + case + "y", locals())
- self.assertEqual(result, expected)
- # Test the "friendly" method-name spelling, if one exists.
- if case in TestSubsets.case2method:
- method = getattr(x, TestSubsets.case2method[case])
- result = method(y)
- self.assertEqual(result, expected)
-
- # Now do the same for the operands reversed.
- rcase = TestSubsets.reverse[case]
- result = eval("y" + rcase + "x", locals())
- self.assertEqual(result, expected)
- if rcase in TestSubsets.case2method:
- method = getattr(y, TestSubsets.case2method[rcase])
- result = method(x)
- self.assertEqual(result, expected)
-#------------------------------------------------------------------------------
-
-class TestSubsetEqualEmpty(TestSubsets):
- left = Set()
- right = Set()
- name = "both empty"
- cases = "==", "<=", ">="
-
-#------------------------------------------------------------------------------
-
-class TestSubsetEqualNonEmpty(TestSubsets):
- left = Set([1, 2])
- right = Set([1, 2])
- name = "equal pair"
- cases = "==", "<=", ">="
-
-#------------------------------------------------------------------------------
-
-class TestSubsetEmptyNonEmpty(TestSubsets):
- left = Set()
- right = Set([1, 2])
- name = "one empty, one non-empty"
- cases = "!=", "<", "<="
-
-#------------------------------------------------------------------------------
-
-class TestSubsetPartial(TestSubsets):
- left = Set([1])
- right = Set([1, 2])
- name = "one a non-empty proper subset of other"
- cases = "!=", "<", "<="
-
-#------------------------------------------------------------------------------
-
-class TestSubsetNonOverlap(TestSubsets):
- left = Set([1])
- right = Set([2])
- name = "neither empty, neither contains"
- cases = "!="
-
-#==============================================================================
-
-class TestOnlySetsInBinaryOps(unittest.TestCase):
-
- def test_eq_ne(self):
- # Unlike the others, this is testing that == and != *are* allowed.
- self.assertEqual(self.other == self.set, False)
- self.assertEqual(self.set == self.other, False)
- self.assertEqual(self.other != self.set, True)
- self.assertEqual(self.set != self.other, True)
-
- def test_ge_gt_le_lt(self):
- self.assertRaises(TypeError, lambda: self.set < self.other)
- self.assertRaises(TypeError, lambda: self.set <= self.other)
- self.assertRaises(TypeError, lambda: self.set > self.other)
- self.assertRaises(TypeError, lambda: self.set >= self.other)
-
- self.assertRaises(TypeError, lambda: self.other < self.set)
- self.assertRaises(TypeError, lambda: self.other <= self.set)
- self.assertRaises(TypeError, lambda: self.other > self.set)
- self.assertRaises(TypeError, lambda: self.other >= self.set)
-
- def test_union_update_operator(self):
- try:
- self.set |= self.other
- except TypeError:
- pass
- else:
- self.fail("expected TypeError")
-
- def test_union_update(self):
- if self.otherIsIterable:
- self.set.union_update(self.other)
- else:
- self.assertRaises(TypeError, self.set.union_update, self.other)
-
- def test_union(self):
- self.assertRaises(TypeError, lambda: self.set | self.other)
- self.assertRaises(TypeError, lambda: self.other | self.set)
- if self.otherIsIterable:
- self.set.union(self.other)
- else:
- self.assertRaises(TypeError, self.set.union, self.other)
-
- def test_intersection_update_operator(self):
- try:
- self.set &= self.other
- except TypeError:
- pass
- else:
- self.fail("expected TypeError")
-
- def test_intersection_update(self):
- if self.otherIsIterable:
- self.set.intersection_update(self.other)
- else:
- self.assertRaises(TypeError,
- self.set.intersection_update,
- self.other)
-
- def test_intersection(self):
- self.assertRaises(TypeError, lambda: self.set & self.other)
- self.assertRaises(TypeError, lambda: self.other & self.set)
- if self.otherIsIterable:
- self.set.intersection(self.other)
- else:
- self.assertRaises(TypeError, self.set.intersection, self.other)
-
- def test_sym_difference_update_operator(self):
- try:
- self.set ^= self.other
- except TypeError:
- pass
- else:
- self.fail("expected TypeError")
-
- def test_sym_difference_update(self):
- if self.otherIsIterable:
- self.set.symmetric_difference_update(self.other)
- else:
- self.assertRaises(TypeError,
- self.set.symmetric_difference_update,
- self.other)
-
- def test_sym_difference(self):
- self.assertRaises(TypeError, lambda: self.set ^ self.other)
- self.assertRaises(TypeError, lambda: self.other ^ self.set)
- if self.otherIsIterable:
- self.set.symmetric_difference(self.other)
- else:
- self.assertRaises(TypeError, self.set.symmetric_difference, self.other)
-
- def test_difference_update_operator(self):
- try:
- self.set -= self.other
- except TypeError:
- pass
- else:
- self.fail("expected TypeError")
-
- def test_difference_update(self):
- if self.otherIsIterable:
- self.set.difference_update(self.other)
- else:
- self.assertRaises(TypeError,
- self.set.difference_update,
- self.other)
-
- def test_difference(self):
- self.assertRaises(TypeError, lambda: self.set - self.other)
- self.assertRaises(TypeError, lambda: self.other - self.set)
- if self.otherIsIterable:
- self.set.difference(self.other)
- else:
- self.assertRaises(TypeError, self.set.difference, self.other)
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsNumeric(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = 19
- self.otherIsIterable = False
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsDict(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = {1:2, 3:4}
- self.otherIsIterable = True
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsOperator(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = operator.add
- self.otherIsIterable = False
-
- def test_ge_gt_le_lt(self):
- with test_support.check_py3k_warnings():
- super(TestOnlySetsOperator, self).test_ge_gt_le_lt()
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsTuple(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = (2, 4, 6)
- self.otherIsIterable = True
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsString(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = 'abc'
- self.otherIsIterable = True
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsGenerator(TestOnlySetsInBinaryOps):
- def setUp(self):
- def gen():
- for i in xrange(0, 10, 2):
- yield i
- self.set = Set((1, 2, 3))
- self.other = gen()
- self.otherIsIterable = True
-
-#------------------------------------------------------------------------------
-
-class TestOnlySetsofSets(TestOnlySetsInBinaryOps):
- def setUp(self):
- self.set = Set((1, 2, 3))
- self.other = [Set('ab'), ImmutableSet('cd')]
- self.otherIsIterable = True
-
-#==============================================================================
-
-class TestCopying(unittest.TestCase):
-
- def test_copy(self):
- dup = self.set.copy()
- self.assertEqual(len(dup), len(self.set))
- dup_list = sorted(dup)
- set_list = sorted(self.set)
- self.assertEqual(len(dup_list), len(set_list))
- for i, el in enumerate(dup_list):
- self.assertIs(el, set_list[i])
-
- def test_deep_copy(self):
- dup = copy.deepcopy(self.set)
- self.assertSetEqual(dup, self.set)
-
-#------------------------------------------------------------------------------
-
-class TestCopyingEmpty(TestCopying):
- def setUp(self):
- self.set = Set()
-
-#------------------------------------------------------------------------------
-
-class TestCopyingSingleton(TestCopying):
- def setUp(self):
- self.set = Set(["hello"])
-
-#------------------------------------------------------------------------------
-
-class TestCopyingTriple(TestCopying):
- def setUp(self):
- self.set = Set(["zero", 0, None])
-
- def test_copy(self):
- with test_support.check_py3k_warnings():
- super(TestCopyingTriple, self).test_copy()
-
-#------------------------------------------------------------------------------
-
-class TestCopyingTuple(TestCopying):
- def setUp(self):
- self.set = Set([(1, 2)])
-
-#------------------------------------------------------------------------------
-
-class TestCopyingNested(TestCopying):
- def setUp(self):
- self.set = Set([((1, 2), (3, 4))])
-
-#==============================================================================
-
-class TestIdentities(unittest.TestCase):
- def setUp(self):
- self.a = Set([random.randrange(100) for i in xrange(50)])
- self.b = Set([random.randrange(100) for i in xrange(50)])
-
- def test_binopsVsSubsets(self):
- a, b = self.a, self.b
- self.assertTrue(a - b <= a)
- self.assertTrue(b - a <= b)
- self.assertTrue(a & b <= a)
- self.assertTrue(a & b <= b)
- self.assertTrue(a | b >= a)
- self.assertTrue(a | b >= b)
- self.assertTrue(a ^ b <= a | b)
-
- def test_commutativity(self):
- a, b = self.a, self.b
- self.assertEqual(a&b, b&a)
- self.assertEqual(a|b, b|a)
- self.assertEqual(a^b, b^a)
- if a != b:
- self.assertNotEqual(a-b, b-a)
-
- def test_reflexsive_relations(self):
- a, zero = self.a, Set()
- self.assertEqual(a ^ a, zero)
- self.assertEqual(a - a, zero)
- self.assertEqual(a | a, a)
- self.assertEqual(a & a, a)
- self.assertTrue(a <= a)
- self.assertTrue(a >= a)
- self.assertTrue(a == a)
-
- def test_summations(self):
- # check that sums of parts equal the whole
- a, b = self.a, self.b
- self.assertEqual((a-b)|(a&b)|(b-a), a|b)
- self.assertEqual((a&b)|(a^b), a|b)
- self.assertEqual(a|(b-a), a|b)
- self.assertEqual((a-b)|b, a|b)
- self.assertEqual((a-b)|(a&b), a)
- self.assertEqual((b-a)|(a&b), b)
- self.assertEqual((a-b)|(b-a), a^b)
-
- def test_exclusion(self):
- # check that inverse operations do not overlap
- a, b, zero = self.a, self.b, Set()
- self.assertEqual((a-b)&b, zero)
- self.assertEqual((b-a)&a, zero)
- self.assertEqual((a&b)&(a^b), zero)
-
- def test_cardinality_relations(self):
- a, b = self.a, self.b
- self.assertEqual(len(a), len(a-b) + len(a&b))
- self.assertEqual(len(b), len(b-a) + len(a&b))
- self.assertEqual(len(a^b), len(a-b) + len(b-a))
- self.assertEqual(len(a|b), len(a-b) + len(a&b) + len(b-a))
- self.assertEqual(len(a^b) + len(a&b), len(a|b))
-
-#==============================================================================
-
-libreftest = """
-Example from the Library Reference: Doc/lib/libsets.tex
-
->>> from sets import Set as Base # override _repr to get sorted output
->>> class Set(Base):
-... def _repr(self):
-... return Base._repr(self, sorted=True)
->>> engineers = Set(['John', 'Jane', 'Jack', 'Janice'])
->>> programmers = Set(['Jack', 'Sam', 'Susan', 'Janice'])
->>> managers = Set(['Jane', 'Jack', 'Susan', 'Zack'])
->>> employees = engineers | programmers | managers # union
->>> engineering_management = engineers & managers # intersection
->>> fulltime_management = managers - engineers - programmers # difference
->>> engineers.add('Marvin')
->>> print engineers
-Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
->>> employees.issuperset(engineers) # superset test
-False
->>> employees.union_update(engineers) # update from another set
->>> employees.issuperset(engineers)
-True
->>> for group in [engineers, programmers, managers, employees]:
-... group.discard('Susan') # unconditionally remove element
-... print group
-...
-Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin'])
-Set(['Jack', 'Janice', 'Sam'])
-Set(['Jack', 'Jane', 'Zack'])
-Set(['Jack', 'Jane', 'Janice', 'John', 'Marvin', 'Sam', 'Zack'])
-"""
-
-#==============================================================================
-
-__test__ = {'libreftest' : libreftest}
-
-def test_main(verbose=None):
- import doctest
- from test import test_sets
- test_support.run_unittest(
- TestSetOfSets,
- TestExceptionPropagation,
- TestBasicOpsEmpty,
- TestBasicOpsSingleton,
- TestBasicOpsTuple,
- TestBasicOpsTriple,
- TestBinaryOps,
- TestUpdateOps,
- TestMutate,
- TestSubsetEqualEmpty,
- TestSubsetEqualNonEmpty,
- TestSubsetEmptyNonEmpty,
- TestSubsetPartial,
- TestSubsetNonOverlap,
- TestOnlySetsNumeric,
- TestOnlySetsDict,
- TestOnlySetsOperator,
- TestOnlySetsTuple,
- TestOnlySetsString,
- TestOnlySetsGenerator,
- TestOnlySetsofSets,
- TestCopyingEmpty,
- TestCopyingSingleton,
- TestCopyingTriple,
- TestCopyingTuple,
- TestCopyingNested,
- TestIdentities,
- doctest.DocTestSuite(test_sets),
- )
-
-if __name__ == "__main__":
- test_main(verbose=True)
diff --git a/Lib/test/test_sgmllib.py b/Lib/test/test_sgmllib.py
deleted file mode 100644
index c18bcc337d5..00000000000
--- a/Lib/test/test_sgmllib.py
+++ /dev/null
@@ -1,439 +0,0 @@
-import pprint
-import re
-import unittest
-from test import test_support
-sgmllib = test_support.import_module('sgmllib', deprecated=True)
-
-
-class EventCollector(sgmllib.SGMLParser):
-
- def __init__(self):
- self.events = []
- self.append = self.events.append
- sgmllib.SGMLParser.__init__(self)
-
- def get_events(self):
- # Normalize the list of events so that buffer artefacts don't
- # separate runs of contiguous characters.
- L = []
- prevtype = None
- for event in self.events:
- type = event[0]
- if type == prevtype == "data":
- L[-1] = ("data", L[-1][1] + event[1])
- else:
- L.append(event)
- prevtype = type
- self.events = L
- return L
-
- # structure markup
-
- def unknown_starttag(self, tag, attrs):
- self.append(("starttag", tag, attrs))
-
- def unknown_endtag(self, tag):
- self.append(("endtag", tag))
-
- # all other markup
-
- def handle_comment(self, data):
- self.append(("comment", data))
-
- def handle_charref(self, data):
- self.append(("charref", data))
-
- def handle_data(self, data):
- self.append(("data", data))
-
- def handle_decl(self, decl):
- self.append(("decl", decl))
-
- def handle_entityref(self, data):
- self.append(("entityref", data))
-
- def handle_pi(self, data):
- self.append(("pi", data))
-
- def unknown_decl(self, decl):
- self.append(("unknown decl", decl))
-
-
-class CDATAEventCollector(EventCollector):
- def start_cdata(self, attrs):
- self.append(("starttag", "cdata", attrs))
- self.setliteral()
-
-
-class HTMLEntityCollector(EventCollector):
-
- entity_or_charref = re.compile('(?:&([a-zA-Z][-.a-zA-Z0-9]*)'
- '|&#(x[0-9a-zA-Z]+|[0-9]+))(;?)')
-
- def convert_charref(self, name):
- self.append(("charref", "convert", name))
- if name[0] != "x":
- return EventCollector.convert_charref(self, name)
-
- def convert_codepoint(self, codepoint):
- self.append(("codepoint", "convert", codepoint))
- EventCollector.convert_codepoint(self, codepoint)
-
- def convert_entityref(self, name):
- self.append(("entityref", "convert", name))
- return EventCollector.convert_entityref(self, name)
-
- # These to record that they were called, then pass the call along
- # to the default implementation so that it's actions can be
- # recorded.
-
- def handle_charref(self, data):
- self.append(("charref", data))
- sgmllib.SGMLParser.handle_charref(self, data)
-
- def handle_entityref(self, data):
- self.append(("entityref", data))
- sgmllib.SGMLParser.handle_entityref(self, data)
-
-
-class SGMLParserTestCase(unittest.TestCase):
-
- collector = EventCollector
-
- def get_events(self, source):
- parser = self.collector()
- try:
- for s in source:
- parser.feed(s)
- parser.close()
- except:
- #self.events = parser.events
- raise
- return parser.get_events()
-
- def check_events(self, source, expected_events):
- try:
- events = self.get_events(source)
- except:
- #import sys
- #print >>sys.stderr, pprint.pformat(self.events)
- raise
- if events != expected_events:
- self.fail("received events did not match expected events\n"
- "Expected:\n" + pprint.pformat(expected_events) +
- "\nReceived:\n" + pprint.pformat(events))
-
- def check_parse_error(self, source):
- parser = EventCollector()
- try:
- parser.feed(source)
- parser.close()
- except sgmllib.SGMLParseError:
- pass
- else:
- self.fail("expected SGMLParseError for %r\nReceived:\n%s"
- % (source, pprint.pformat(parser.get_events())))
-
- def test_doctype_decl_internal(self):
- inside = """\
-DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'
- SYSTEM 'http://www.w3.org/TR/html401/strict.dtd' [
- <!ELEMENT html - O EMPTY>
- <!ATTLIST html
- version CDATA #IMPLIED
- profile CDATA 'DublinCore'>
- <!NOTATION datatype SYSTEM 'http://xml.python.org/notations/python-module'>
- <!ENTITY myEntity 'internal parsed entity'>
- <!ENTITY anEntity SYSTEM 'http://xml.python.org/entities/something.xml'>
- <!ENTITY % paramEntity 'name|name|name'>
- %paramEntity;
- <!-- comment -->
-]"""
- self.check_events(["<!%s>" % inside], [
- ("decl", inside),
- ])
-
- def test_doctype_decl_external(self):
- inside = "DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'"
- self.check_events("<!%s>" % inside, [
- ("decl", inside),
- ])
-
- def test_underscore_in_attrname(self):
- # SF bug #436621
- """Make sure attribute names with underscores are accepted"""
- self.check_events("<a has_under _under>", [
- ("starttag", "a", [("has_under", "has_under"),
- ("_under", "_under")]),
- ])
-
- def test_underscore_in_tagname(self):
- # SF bug #436621
- """Make sure tag names with underscores are accepted"""
- self.check_events("<has_under></has_under>", [
- ("starttag", "has_under", []),
- ("endtag", "has_under"),
- ])
-
- def test_quotes_in_unquoted_attrs(self):
- # SF bug #436621
- """Be sure quotes in unquoted attributes are made part of the value"""
- self.check_events("<a href=foo'bar\"baz>", [
- ("starttag", "a", [("href", "foo'bar\"baz")]),
- ])
-
- def test_xhtml_empty_tag(self):
- """Handling of XHTML-style empty start tags"""
- self.check_events("<br />text<i></i>", [
- ("starttag", "br", []),
- ("data", "text"),
- ("starttag", "i", []),
- ("endtag", "i"),
- ])
-
- def test_processing_instruction_only(self):
- self.check_events("<?processing instruction>", [
- ("pi", "processing instruction"),
- ])
-
- def test_bad_nesting(self):
- self.check_events("<a><b></a></b>", [
- ("starttag", "a", []),
- ("starttag", "b", []),
- ("endtag", "a"),
- ("endtag", "b"),
- ])
-
- def test_bare_ampersands(self):
- self.check_events("this text & contains & ampersands &", [
- ("data", "this text & contains & ampersands &"),
- ])
-
- def test_bare_pointy_brackets(self):
- self.check_events("this < text > contains < bare>pointy< brackets", [
- ("data", "this < text > contains < bare>pointy< brackets"),
- ])
-
- def test_attr_syntax(self):
- output = [
- ("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", "e")])
- ]
- self.check_events("""<a b='v' c="v" d=v e>""", output)
- self.check_events("""<a b = 'v' c = "v" d = v e>""", output)
- self.check_events("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output)
- self.check_events("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output)
-
- def test_attr_values(self):
- self.check_events("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
- [("starttag", "a", [("b", "xxx\n\txxx"),
- ("c", "yyy\t\nyyy"),
- ("d", "\txyz\n")])
- ])
- self.check_events("""<a b='' c="">""", [
- ("starttag", "a", [("b", ""), ("c", "")]),
- ])
- # URL construction stuff from RFC 1808:
- safe = "$-_.+"
- extra = "!*'(),"
- reserved = ";/?:@&="
- url = "http://example.com:8080/path/to/file?%s%s%s" % (
- safe, extra, reserved)
- self.check_events("""<e a=%s>""" % url, [
- ("starttag", "e", [("a", url)]),
- ])
- # Regression test for SF patch #669683.
- self.check_events("<e a=rgb(1,2,3)>", [
- ("starttag", "e", [("a", "rgb(1,2,3)")]),
- ])
-
- def test_attr_values_entities(self):
- """Substitution of entities and charrefs in attribute values"""
- # SF bug #1452246
- self.check_events("""<a b=&lt; c=&lt;&gt; d=&lt-&gt; e='&lt; '
- f="&xxx;" g='&#32;&#33;' h='&#500;'
- i='x?a=b&c=d;'
- j='&amp;#42;' k='&#38;#42;'>""",
- [("starttag", "a", [("b", "<"),
- ("c", "<>"),
- ("d", "&lt->"),
- ("e", "< "),
- ("f", "&xxx;"),
- ("g", " !"),
- ("h", "&#500;"),
- ("i", "x?a=b&c=d;"),
- ("j", "&#42;"),
- ("k", "&#42;"),
- ])])
-
- def test_convert_overrides(self):
- # This checks that the character and entity reference
- # conversion helpers are called at the documented times. No
- # attempt is made to really change what the parser accepts.
- #
- self.collector = HTMLEntityCollector
- self.check_events(('<a title="&ldquo;test&#x201d;">foo</a>'
- '&foobar;&#42;'), [
- ('entityref', 'convert', 'ldquo'),
- ('charref', 'convert', 'x201d'),
- ('starttag', 'a', [('title', '&ldquo;test&#x201d;')]),
- ('data', 'foo'),
- ('endtag', 'a'),
- ('entityref', 'foobar'),
- ('entityref', 'convert', 'foobar'),
- ('charref', '42'),
- ('charref', 'convert', '42'),
- ('codepoint', 'convert', 42),
- ])
-
- def test_attr_funky_names(self):
- self.check_events("""<a a.b='v' c:d=v e-f=v>""", [
- ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
- ])
-
- def test_attr_value_ip6_url(self):
- # http://www.python.org/sf/853506
- self.check_events(("<a href='http://[1080::8:800:200C:417A]/'>"
- "<a href=http://[1080::8:800:200C:417A]/>"), [
- ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
- ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
- ])
-
- def test_weird_starttags(self):
- self.check_events("<a<a>", [
- ("starttag", "a", []),
- ("starttag", "a", []),
- ])
- self.check_events("</a<a>", [
- ("endtag", "a"),
- ("starttag", "a", []),
- ])
-
- def test_declaration_junk_chars(self):
- self.check_parse_error("<!DOCTYPE foo $ >")
-
- def test_get_starttag_text(self):
- s = """<foobar \n one="1"\ttwo=2 >"""
- self.check_events(s, [
- ("starttag", "foobar", [("one", "1"), ("two", "2")]),
- ])
-
- def test_cdata_content(self):
- s = ("<cdata> <!-- not a comment --> &not-an-entity-ref; </cdata>"
- "<notcdata> <!-- comment --> </notcdata>")
- self.collector = CDATAEventCollector
- self.check_events(s, [
- ("starttag", "cdata", []),
- ("data", " <!-- not a comment --> &not-an-entity-ref; "),
- ("endtag", "cdata"),
- ("starttag", "notcdata", []),
- ("data", " "),
- ("comment", " comment "),
- ("data", " "),
- ("endtag", "notcdata"),
- ])
- s = """<cdata> <not a='start tag'> </cdata>"""
- self.check_events(s, [
- ("starttag", "cdata", []),
- ("data", " <not a='start tag'> "),
- ("endtag", "cdata"),
- ])
-
- def test_illegal_declarations(self):
- s = 'abc<!spacer type="block" height="25">def'
- self.check_events(s, [
- ("data", "abc"),
- ("unknown decl", 'spacer type="block" height="25"'),
- ("data", "def"),
- ])
-
- def test_enumerated_attr_type(self):
- s = "<!DOCTYPE doc [<!ATTLIST doc attr (a | b) >]>"
- self.check_events(s, [
- ('decl', 'DOCTYPE doc [<!ATTLIST doc attr (a | b) >]'),
- ])
-
- def test_read_chunks(self):
- # SF bug #1541697, this caused sgml parser to hang
- # Just verify this code doesn't cause a hang.
- CHUNK = 1024 # increasing this to 8212 makes the problem go away
-
- f = open(test_support.findfile('sgml_input.html'))
- fp = sgmllib.SGMLParser()
- while 1:
- data = f.read(CHUNK)
- fp.feed(data)
- if len(data) != CHUNK:
- break
-
- def test_only_decode_ascii(self):
- # SF bug #1651995, make sure non-ascii character references are not decoded
- s = '<signs exclamation="&#33" copyright="&#169" quoteleft="&#8216;">'
- self.check_events(s, [
- ('starttag', 'signs',
- [('exclamation', '!'), ('copyright', '&#169'),
- ('quoteleft', '&#8216;')]),
- ])
-
- # XXX These tests have been disabled by prefixing their names with
- # an underscore. The first two exercise outstanding bugs in the
- # sgmllib module, and the third exhibits questionable behavior
- # that needs to be carefully considered before changing it.
-
- def _test_starttag_end_boundary(self):
- self.check_events("<a b='<'>", [("starttag", "a", [("b", "<")])])
- self.check_events("<a b='>'>", [("starttag", "a", [("b", ">")])])
-
- def _test_buffer_artefacts(self):
- output = [("starttag", "a", [("b", "<")])]
- self.check_events(["<a b='<'>"], output)
- self.check_events(["<a ", "b='<'>"], output)
- self.check_events(["<a b", "='<'>"], output)
- self.check_events(["<a b=", "'<'>"], output)
- self.check_events(["<a b='<", "'>"], output)
- self.check_events(["<a b='<'", ">"], output)
-
- output = [("starttag", "a", [("b", ">")])]
- self.check_events(["<a b='>'>"], output)
- self.check_events(["<a ", "b='>'>"], output)
- self.check_events(["<a b", "='>'>"], output)
- self.check_events(["<a b=", "'>'>"], output)
- self.check_events(["<a b='>", "'>"], output)
- self.check_events(["<a b='>'", ">"], output)
-
- output = [("comment", "abc")]
- self.check_events(["", "<!--abc-->"], output)
- self.check_events(["<", "!--abc-->"], output)
- self.check_events(["<!", "--abc-->"], output)
- self.check_events(["<!-", "-abc-->"], output)
- self.check_events(["<!--", "abc-->"], output)
- self.check_events(["<!--a", "bc-->"], output)
- self.check_events(["<!--ab", "c-->"], output)
- self.check_events(["<!--abc", "-->"], output)
- self.check_events(["<!--abc-", "->"], output)
- self.check_events(["<!--abc--", ">"], output)
- self.check_events(["<!--abc-->", ""], output)
-
- def _test_starttag_junk_chars(self):
- self.check_parse_error("<")
- self.check_parse_error("<>")
- self.check_parse_error("</$>")
- self.check_parse_error("</")
- self.check_parse_error("</a")
- self.check_parse_error("<$")
- self.check_parse_error("<$>")
- self.check_parse_error("<!")
- self.check_parse_error("<a $>")
- self.check_parse_error("<a")
- self.check_parse_error("<a foo='bar'")
- self.check_parse_error("<a foo='bar")
- self.check_parse_error("<a foo='>'")
- self.check_parse_error("<a foo='>")
- self.check_parse_error("<a foo=>")
-
-
-def test_main():
- test_support.run_unittest(SGMLParserTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_sha.py b/Lib/test/test_sha.py
deleted file mode 100644
index 6b38435548c..00000000000
--- a/Lib/test/test_sha.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Testing sha module (NIST's Secure Hash Algorithm)
-
-# use the three examples from Federal Information Processing Standards
-# Publication 180-1, Secure Hash Standard, 1995 April 17
-# http://www.itl.nist.gov/div897/pubs/fip180-1.htm
-
-import warnings
-warnings.filterwarnings("ignore", "the sha module is deprecated.*",
- DeprecationWarning)
-
-import sha
-import unittest
-from test import test_support
-
-
-class SHATestCase(unittest.TestCase):
- def check(self, data, digest):
- # Check digest matches the expected value
- obj = sha.new(data)
- computed = obj.hexdigest()
- self.assertTrue(computed == digest)
-
- # Verify that the value doesn't change between two consecutive
- # digest operations.
- computed_again = obj.hexdigest()
- self.assertTrue(computed == computed_again)
-
- # Check hexdigest() output matches digest()'s output
- digest = obj.digest()
- hexd = ""
- for c in digest:
- hexd += '%02x' % ord(c)
- self.assertTrue(computed == hexd)
-
- def test_case_1(self):
- self.check("abc",
- "a9993e364706816aba3e25717850c26c9cd0d89d")
-
- def test_case_2(self):
- self.check("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
- "84983e441c3bd26ebaae4aa1f95129e5e54670f1")
-
- def test_case_3(self):
- self.check("a" * 1000000,
- "34aa973cd4c4daa4f61eeb2bdbad27316534016f")
-
- def test_case_4(self):
- self.check(chr(0xAA) * 80,
- '4ca0ef38f1794b28a8f8ee110ee79d48ce13be25')
-
-def test_main():
- test_support.run_unittest(SHATestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_shelve.py b/Lib/test/test_shelve.py
index df56625a599..3e73f52b87b 100644
--- a/Lib/test/test_shelve.py
+++ b/Lib/test/test_shelve.py
@@ -1,14 +1,51 @@
-import os
import unittest
import shelve
import glob
-from test import test_support
+from test import support
+from collections import MutableMapping
+from test.test_dbm import dbm_iterator
+
+def L1(s):
+ return s.decode("latin-1")
+
+class byteskeydict(MutableMapping):
+ "Mapping that supports bytes keys"
+
+ def __init__(self):
+ self.d = {}
+
+ def __getitem__(self, key):
+ return self.d[L1(key)]
+
+ def __setitem__(self, key, value):
+ self.d[L1(key)] = value
+
+ def __delitem__(self, key):
+ del self.d[L1(key)]
+
+ def __len__(self):
+ return len(self.d)
+
+ def iterkeys(self):
+ for k in self.d.keys():
+ yield k.encode("latin-1")
+
+ __iter__ = iterkeys
+
+ def keys(self):
+ return list(self.iterkeys())
+
+ def copy(self):
+ return byteskeydict(self.d)
-test_support.import_module('anydbm', deprecated=True)
class TestCase(unittest.TestCase):
- fn = "shelftemp" + os.extsep + "db"
+ fn = "shelftemp.db"
+
+ def tearDown(self):
+ for f in glob.glob(self.fn+"*"):
+ support.unlink(f)
def test_close(self):
d1 = {}
@@ -26,52 +63,47 @@ class TestCase(unittest.TestCase):
self.fail('Closed shelf should not find a key')
def test_ascii_file_shelf(self):
+ s = shelve.open(self.fn, protocol=0)
try:
- s = shelve.open(self.fn, protocol=0)
s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4))
- s.close()
finally:
- for f in glob.glob(self.fn+"*"):
- os.unlink(f)
+ s.close()
def test_binary_file_shelf(self):
+ s = shelve.open(self.fn, protocol=1)
try:
- s = shelve.open(self.fn, protocol=1)
s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4))
- s.close()
finally:
- for f in glob.glob(self.fn+"*"):
- os.unlink(f)
+ s.close()
def test_proto2_file_shelf(self):
+ s = shelve.open(self.fn, protocol=2)
try:
- s = shelve.open(self.fn, protocol=2)
s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4))
- s.close()
finally:
- for f in glob.glob(self.fn+"*"):
- os.unlink(f)
+ s.close()
def test_in_memory_shelf(self):
- d1 = {}
+ d1 = byteskeydict()
s = shelve.Shelf(d1, protocol=0)
s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4))
s.close()
- d2 = {}
+ d2 = byteskeydict()
s = shelve.Shelf(d2, protocol=1)
s['key1'] = (1,2,3,4)
self.assertEqual(s['key1'], (1,2,3,4))
s.close()
self.assertEqual(len(d1), 1)
- self.assertNotEqual(d1, d2)
+ self.assertEqual(len(d2), 1)
+ self.assertNotEqual(d1.items(), d2.items())
def test_mutable_entry(self):
- d1 = {}
+ d1 = byteskeydict()
s = shelve.Shelf(d1, protocol=2, writeback=False)
s['key1'] = [1,2,3,4]
self.assertEqual(s['key1'], [1,2,3,4])
@@ -79,7 +111,7 @@ class TestCase(unittest.TestCase):
self.assertEqual(s['key1'], [1,2,3,4])
s.close()
- d2 = {}
+ d2 = byteskeydict()
s = shelve.Shelf(d2, protocol=2, writeback=True)
s['key1'] = [1,2,3,4]
self.assertEqual(s['key1'], [1,2,3,4])
@@ -90,15 +122,30 @@ class TestCase(unittest.TestCase):
self.assertEqual(len(d1), 1)
self.assertEqual(len(d2), 1)
+ def test_keyencoding(self):
+ d = {}
+ key = 'Pöp'
+ # the default keyencoding is utf-8
+ shelve.Shelf(d)[key] = [1]
+ self.assertIn(key.encode('utf-8'), d)
+ # but a different one can be given
+ shelve.Shelf(d, keyencoding='latin1')[key] = [1]
+ self.assertIn(key.encode('latin1'), d)
+ # with all consequences
+ s = shelve.Shelf(d, keyencoding='ascii')
+ self.assertRaises(UnicodeEncodeError, s.__setitem__, key, [1])
+
def test_writeback_also_writes_immediately(self):
# Issue 5754
d = {}
+ key = 'key'
+ encodedkey = key.encode('utf-8')
s = shelve.Shelf(d, writeback=True)
- s['key'] = [1]
- p1 = d['key'] # Will give a KeyError if backing store not updated
+ s[key] = [1]
+ p1 = d[encodedkey] # Will give a KeyError if backing store not updated
s['key'].append(2)
s.close()
- p2 = d['key']
+ p2 = d[encodedkey]
self.assertNotEqual(p1, p2) # Write creates new object in store
@@ -115,7 +162,7 @@ class TestShelveBase(mapping_tests.BasicTestMappingProtocol):
return {"key1":"value1", "key2":2, "key3":(1,2,3)}
def _empty_mapping(self):
if self._in_mem:
- x= shelve.Shelf({}, **self._args)
+ x= shelve.Shelf(byteskeydict(), **self._args)
else:
self.counter+=1
x= shelve.open(self.fn+str(self.counter), **self._args)
@@ -127,7 +174,7 @@ class TestShelveBase(mapping_tests.BasicTestMappingProtocol):
self._db = []
if not self._in_mem:
for f in glob.glob(self.fn+"*"):
- test_support.unlink(f)
+ support.unlink(f)
class TestAsciiFileShelve(TestShelveBase):
_args={'protocol':0}
@@ -149,15 +196,16 @@ class TestProto2MemShelve(TestShelveBase):
_in_mem = True
def test_main():
- test_support.run_unittest(
- TestAsciiFileShelve,
- TestBinaryFileShelve,
- TestProto2FileShelve,
- TestAsciiMemShelve,
- TestBinaryMemShelve,
- TestProto2MemShelve,
- TestCase
- )
+ for module in dbm_iterator():
+ support.run_unittest(
+ TestAsciiFileShelve,
+ TestBinaryFileShelve,
+ TestProto2FileShelve,
+ TestAsciiMemShelve,
+ TestBinaryMemShelve,
+ TestProto2MemShelve,
+ TestCase
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_shlex.py b/Lib/test/test_shlex.py
index 6c35f491b5b..25e4b6df6c5 100644
--- a/Lib/test/test_shlex.py
+++ b/Lib/test/test_shlex.py
@@ -1,13 +1,8 @@
-# -*- coding: iso-8859-1 -*-
import unittest
+import os, sys, io
import shlex
-from test import test_support
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
+from test import support
# The original test data set was from shellwords, by Hartmut Goebel.
@@ -72,7 +67,7 @@ foo\ x\x\""|foo|\|x|\|x|\|""|
foo\ bar|foo|\|bar|
foo#bar\nbaz|foobaz|
:-) ;-)|:|-|)|;|-|)|
-áéíóú|á|é|í|ó|ú|
+áéíóú|á|é|í|ó|ú|
"""
posix_data = r"""x|x|
@@ -136,7 +131,7 @@ foo\ x\x\"|foo xx"|
foo\ bar|foo bar|
foo#bar\nbaz|foo|baz|
:-) ;-)|:-)|;-)|
-áéíóú|áéíóú|
+áéíóú|áéíóú|
"""
class ShlexTest(unittest.TestCase):
@@ -159,7 +154,7 @@ class ShlexTest(unittest.TestCase):
def oldSplit(self, s):
ret = []
- lex = shlex.shlex(StringIO(s))
+ lex = shlex.shlex(io.StringIO(s))
tok = lex.get_token()
while tok:
ret.append(tok)
@@ -185,7 +180,7 @@ if not getattr(shlex, "split", None):
delattr(ShlexTest, methname)
def test_main():
- test_support.run_unittest(ShlexTest)
+ support.run_unittest(ShlexTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
index 9bdb7243d3d..a9b4676dfff 100644
--- a/Lib/test/test_shutil.py
+++ b/Lib/test/test_shutil.py
@@ -7,17 +7,28 @@ import sys
import stat
import os
import os.path
+import functools
import errno
+from test import support
+from test.support import TESTFN
from os.path import splitdrive
from distutils.spawn import find_executable, spawn
from shutil import (_make_tarball, _make_zipfile, make_archive,
register_archive_format, unregister_archive_format,
- get_archive_formats)
+ get_archive_formats, Error, unpack_archive,
+ register_unpack_format, RegistryError,
+ unregister_unpack_format, get_unpack_formats)
import tarfile
import warnings
-from test import test_support
-from test.test_support import TESTFN, check_warnings, captured_stdout
+from test import support
+from test.support import TESTFN, check_warnings, captured_stdout
+
+try:
+ import bz2
+ BZ2_SUPPORTED = True
+except ImportError:
+ BZ2_SUPPORTED = False
TESTFN2 = TESTFN + "2"
@@ -39,6 +50,21 @@ try:
except ImportError:
ZIP_SUPPORT = find_executable('zip')
+def _fake_rename(*args, **kwargs):
+ # Pretend the destination path is on a different filesystem.
+ raise OSError()
+
+def mock_rename(func):
+ @functools.wraps(func)
+ def wrap(*args, **kwargs):
+ try:
+ builtin_rename = os.rename
+ os.rename = _fake_rename
+ return func(*args, **kwargs)
+ finally:
+ os.rename = builtin_rename
+ return wrap
+
class TestShutil(unittest.TestCase):
def setUp(self):
@@ -73,10 +99,60 @@ class TestShutil(unittest.TestCase):
d = tempfile.mkdtemp()
self.tempdirs.append(d)
return d
+
+ @support.skip_unless_symlink
+ def test_rmtree_fails_on_symlink(self):
+ tmp = self.mkdtemp()
+ dir_ = os.path.join(tmp, 'dir')
+ os.mkdir(dir_)
+ link = os.path.join(tmp, 'link')
+ os.symlink(dir_, link)
+ self.assertRaises(OSError, shutil.rmtree, link)
+ self.assertTrue(os.path.exists(dir_))
+ self.assertTrue(os.path.lexists(link))
+ errors = []
+ def onerror(*args):
+ errors.append(args)
+ shutil.rmtree(link, onerror=onerror)
+ self.assertEqual(len(errors), 1)
+ self.assertIs(errors[0][0], os.path.islink)
+ self.assertEqual(errors[0][1], link)
+ self.assertIsInstance(errors[0][2][1], OSError)
+
def test_rmtree_errors(self):
# filename is guaranteed not to exist
filename = tempfile.mktemp()
self.assertRaises(OSError, shutil.rmtree, filename)
+ # test that ignore_errors option is honoured
+ shutil.rmtree(filename, ignore_errors=True)
+
+ # existing file
+ tmpdir = self.mkdtemp()
+ self.write_file((tmpdir, "tstfile"), "")
+ filename = os.path.join(tmpdir, "tstfile")
+ with self.assertRaises(OSError) as cm:
+ shutil.rmtree(filename)
+ # The reason for this rather odd construct is that Windows sprinkles
+ # a \*.* at the end of file names. But only sometimes on some buildbots
+ possible_args = [filename, os.path.join(filename, '*.*')]
+ self.assertIn(cm.exception.filename, possible_args)
+ self.assertTrue(os.path.exists(filename))
+ # test that ignore_errors option is honored
+ shutil.rmtree(filename, ignore_errors=True)
+ self.assertTrue(os.path.exists(filename))
+ errors = []
+ def onerror(*args):
+ errors.append(args)
+ shutil.rmtree(filename, onerror=onerror)
+ self.assertEqual(len(errors), 2)
+ self.assertIs(errors[0][0], os.listdir)
+ self.assertEqual(errors[0][1], filename)
+ self.assertIsInstance(errors[0][2][1], OSError)
+ self.assertIn(errors[0][2][1].filename, possible_args)
+ self.assertIs(errors[1][0], os.rmdir)
+ self.assertEqual(errors[1][1], filename)
+ self.assertIsInstance(errors[1][2][1], OSError)
+ self.assertIn(errors[1][2][1].filename, possible_args)
# See bug #1071513 for why we don't run this on cygwin
# and bug #1076467 for why we don't run this as root.
@@ -139,11 +215,12 @@ class TestShutil(unittest.TestCase):
self.assertRaises(OSError, shutil.rmtree, path)
os.remove(path)
+ def _write_data(self, path, data):
+ f = open(path, "w")
+ f.write(data)
+ f.close()
+
def test_copytree_simple(self):
- def write_data(path, data):
- f = open(path, "w")
- f.write(data)
- f.close()
def read_data(path):
f = open(path)
@@ -153,11 +230,9 @@ class TestShutil(unittest.TestCase):
src_dir = tempfile.mkdtemp()
dst_dir = os.path.join(tempfile.mkdtemp(), 'destination')
-
- write_data(os.path.join(src_dir, 'test.txt'), '123')
-
+ self._write_data(os.path.join(src_dir, 'test.txt'), '123')
os.mkdir(os.path.join(src_dir, 'test_dir'))
- write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
try:
shutil.copytree(src_dir, dst_dir)
@@ -186,11 +261,6 @@ class TestShutil(unittest.TestCase):
def test_copytree_with_exclude(self):
- def write_data(path, data):
- f = open(path, "w")
- f.write(data)
- f.close()
-
def read_data(path):
f = open(path)
data = f.read()
@@ -203,16 +273,18 @@ class TestShutil(unittest.TestCase):
src_dir = tempfile.mkdtemp()
try:
dst_dir = join(tempfile.mkdtemp(), 'destination')
- write_data(join(src_dir, 'test.txt'), '123')
- write_data(join(src_dir, 'test.tmp'), '123')
+ self._write_data(join(src_dir, 'test.txt'), '123')
+ self._write_data(join(src_dir, 'test.tmp'), '123')
os.mkdir(join(src_dir, 'test_dir'))
- write_data(join(src_dir, 'test_dir', 'test.txt'), '456')
+ self._write_data(join(src_dir, 'test_dir', 'test.txt'), '456')
os.mkdir(join(src_dir, 'test_dir2'))
- write_data(join(src_dir, 'test_dir2', 'test.txt'), '456')
+ self._write_data(join(src_dir, 'test_dir2', 'test.txt'), '456')
os.mkdir(join(src_dir, 'test_dir2', 'subdir'))
os.mkdir(join(src_dir, 'test_dir2', 'subdir2'))
- write_data(join(src_dir, 'test_dir2', 'subdir', 'test.txt'), '456')
- write_data(join(src_dir, 'test_dir2', 'subdir2', 'test.py'), '456')
+ self._write_data(join(src_dir, 'test_dir2', 'subdir', 'test.txt'),
+ '456')
+ self._write_data(join(src_dir, 'test_dir2', 'subdir2', 'test.py'),
+ '456')
# testing glob-like patterns
@@ -265,48 +337,87 @@ class TestShutil(unittest.TestCase):
shutil.rmtree(src_dir)
shutil.rmtree(os.path.dirname(dst_dir))
- if hasattr(os, "symlink"):
- def test_dont_copy_file_onto_link_to_itself(self):
- # bug 851123.
- os.mkdir(TESTFN)
- src = os.path.join(TESTFN, 'cheese')
- dst = os.path.join(TESTFN, 'shop')
- try:
- f = open(src, 'w')
+ @unittest.skipUnless(hasattr(os, 'link'), 'requires os.link')
+ def test_dont_copy_file_onto_link_to_itself(self):
+ # Temporarily disable test on Windows.
+ if os.name == 'nt':
+ return
+ # bug 851123.
+ os.mkdir(TESTFN)
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ try:
+ with open(src, 'w') as f:
f.write('cheddar')
- f.close()
-
- os.link(src, dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- with open(src, 'r') as f:
- self.assertEqual(f.read(), 'cheddar')
- os.remove(dst)
-
- # Using `src` here would mean we end up with a symlink pointing
- # to TESTFN/TESTFN/cheese, while it should point at
- # TESTFN/cheese.
- os.symlink('cheese', dst)
- self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
- with open(src, 'r') as f:
- self.assertEqual(f.read(), 'cheddar')
- os.remove(dst)
- finally:
- try:
- shutil.rmtree(TESTFN)
- except OSError:
- pass
+ os.link(src, dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
+ os.remove(dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
- def test_rmtree_on_symlink(self):
- # bug 1669.
- os.mkdir(TESTFN)
- try:
- src = os.path.join(TESTFN, 'cheese')
- dst = os.path.join(TESTFN, 'shop')
- os.mkdir(src)
- os.symlink(src, dst)
- self.assertRaises(OSError, shutil.rmtree, dst)
- finally:
- shutil.rmtree(TESTFN, ignore_errors=True)
+ @unittest.skipUnless(hasattr(os, 'chflags') and
+ hasattr(errno, 'EOPNOTSUPP') and
+ hasattr(errno, 'ENOTSUP'),
+ "requires os.chflags, EOPNOTSUPP & ENOTSUP")
+ def test_copystat_handles_harmless_chflags_errors(self):
+ tmpdir = self.mkdtemp()
+ file1 = os.path.join(tmpdir, 'file1')
+ file2 = os.path.join(tmpdir, 'file2')
+ self.write_file(file1, 'xxx')
+ self.write_file(file2, 'xxx')
+
+ def make_chflags_raiser(err):
+ ex = OSError()
+
+ def _chflags_raiser(path, flags):
+ ex.errno = err
+ raise ex
+ return _chflags_raiser
+ old_chflags = os.chflags
+ try:
+ for err in errno.EOPNOTSUPP, errno.ENOTSUP:
+ os.chflags = make_chflags_raiser(err)
+ shutil.copystat(file1, file2)
+ # assert others errors break it
+ os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
+ self.assertRaises(OSError, shutil.copystat, file1, file2)
+ finally:
+ os.chflags = old_chflags
+
+ @support.skip_unless_symlink
+ def test_dont_copy_file_onto_symlink_to_itself(self):
+ # bug 851123.
+ os.mkdir(TESTFN)
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ try:
+ with open(src, 'w') as f:
+ f.write('cheddar')
+ # Using `src` here would mean we end up with a symlink pointing
+ # to TESTFN/TESTFN/cheese, while it should point at
+ # TESTFN/cheese.
+ os.symlink('cheese', dst)
+ self.assertRaises(shutil.Error, shutil.copyfile, src, dst)
+ with open(src, 'r') as f:
+ self.assertEqual(f.read(), 'cheddar')
+ os.remove(dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
+
+ @support.skip_unless_symlink
+ def test_rmtree_on_symlink(self):
+ # bug 1669.
+ os.mkdir(TESTFN)
+ try:
+ src = os.path.join(TESTFN, 'cheese')
+ dst = os.path.join(TESTFN, 'shop')
+ os.mkdir(src)
+ os.symlink(src, dst)
+ self.assertRaises(OSError, shutil.rmtree, dst)
+ finally:
+ shutil.rmtree(TESTFN, ignore_errors=True)
if hasattr(os, "mkfifo"):
# Issue #3002: copyfile and copytree block indefinitely on named pipes
@@ -320,6 +431,7 @@ class TestShutil(unittest.TestCase):
finally:
os.remove(TESTFN)
+ @support.skip_unless_symlink
def test_copytree_named_pipe(self):
os.mkdir(TESTFN)
try:
@@ -340,34 +452,76 @@ class TestShutil(unittest.TestCase):
shutil.rmtree(TESTFN, ignore_errors=True)
shutil.rmtree(TESTFN2, ignore_errors=True)
- @unittest.skipUnless(hasattr(os, 'chflags') and
- hasattr(errno, 'EOPNOTSUPP') and
- hasattr(errno, 'ENOTSUP'),
- "requires os.chflags, EOPNOTSUPP & ENOTSUP")
- def test_copystat_handles_harmless_chflags_errors(self):
- tmpdir = self.mkdtemp()
- file1 = os.path.join(tmpdir, 'file1')
- file2 = os.path.join(tmpdir, 'file2')
- self.write_file(file1, 'xxx')
- self.write_file(file2, 'xxx')
+ def test_copytree_special_func(self):
- def make_chflags_raiser(err):
- ex = OSError()
+ src_dir = self.mkdtemp()
+ dst_dir = os.path.join(self.mkdtemp(), 'destination')
+ self._write_data(os.path.join(src_dir, 'test.txt'), '123')
+ os.mkdir(os.path.join(src_dir, 'test_dir'))
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
- def _chflags_raiser(path, flags):
- ex.errno = err
- raise ex
- return _chflags_raiser
- old_chflags = os.chflags
- try:
- for err in errno.EOPNOTSUPP, errno.ENOTSUP:
- os.chflags = make_chflags_raiser(err)
- shutil.copystat(file1, file2)
- # assert others errors break it
- os.chflags = make_chflags_raiser(errno.EOPNOTSUPP + errno.ENOTSUP)
- self.assertRaises(OSError, shutil.copystat, file1, file2)
- finally:
- os.chflags = old_chflags
+ copied = []
+ def _copy(src, dst):
+ copied.append((src, dst))
+
+ shutil.copytree(src_dir, dst_dir, copy_function=_copy)
+ self.assertEqual(len(copied), 2)
+
+ @support.skip_unless_symlink
+ def test_copytree_dangling_symlinks(self):
+
+ # a dangling symlink raises an error at the end
+ src_dir = self.mkdtemp()
+ dst_dir = os.path.join(self.mkdtemp(), 'destination')
+ os.symlink('IDONTEXIST', os.path.join(src_dir, 'test.txt'))
+ os.mkdir(os.path.join(src_dir, 'test_dir'))
+ self._write_data(os.path.join(src_dir, 'test_dir', 'test.txt'), '456')
+ self.assertRaises(Error, shutil.copytree, src_dir, dst_dir)
+
+ # a dangling symlink is ignored with the proper flag
+ dst_dir = os.path.join(self.mkdtemp(), 'destination2')
+ shutil.copytree(src_dir, dst_dir, ignore_dangling_symlinks=True)
+ self.assertNotIn('test.txt', os.listdir(dst_dir))
+
+ # a dangling symlink is copied if symlinks=True
+ dst_dir = os.path.join(self.mkdtemp(), 'destination3')
+ shutil.copytree(src_dir, dst_dir, symlinks=True)
+ self.assertIn('test.txt', os.listdir(dst_dir))
+
+ def _copy_file(self, method):
+ fname = 'test.txt'
+ tmpdir = self.mkdtemp()
+ self.write_file([tmpdir, fname])
+ file1 = os.path.join(tmpdir, fname)
+ tmpdir2 = self.mkdtemp()
+ method(file1, tmpdir2)
+ file2 = os.path.join(tmpdir2, fname)
+ return (file1, file2)
+
+ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
+ def test_copy(self):
+ # Ensure that the copied file exists and has the same mode bits.
+ file1, file2 = self._copy_file(shutil.copy)
+ self.assertTrue(os.path.exists(file2))
+ self.assertEqual(os.stat(file1).st_mode, os.stat(file2).st_mode)
+
+ @unittest.skipUnless(hasattr(os, 'chmod'), 'requires os.chmod')
+ @unittest.skipUnless(hasattr(os, 'utime'), 'requires os.utime')
+ def test_copy2(self):
+ # Ensure that the copied file exists and has the same mode and
+ # modification time bits.
+ file1, file2 = self._copy_file(shutil.copy2)
+ self.assertTrue(os.path.exists(file2))
+ file1_stat = os.stat(file1)
+ file2_stat = os.stat(file2)
+ self.assertEqual(file1_stat.st_mode, file2_stat.st_mode)
+ for attr in 'st_atime', 'st_mtime':
+ # The modification times may be truncated in the new file.
+ self.assertLessEqual(getattr(file1_stat, attr),
+ getattr(file2_stat, attr) + 1)
+ if hasattr(os, 'chflags') and hasattr(file1_stat, 'st_flags'):
+ self.assertEqual(getattr(file1_stat, 'st_flags'),
+ getattr(file2_stat, 'st_flags'))
@unittest.skipUnless(zlib, "requires zlib")
def test_make_tarball(self):
@@ -538,6 +692,7 @@ class TestShutil(unittest.TestCase):
owner='kjhkjhkjg', group='oihohoh')
self.assertTrue(os.path.exists(res))
+
@unittest.skipUnless(zlib, "Requires zlib")
@unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
def test_tarfile_root_owner(self):
@@ -595,6 +750,69 @@ class TestShutil(unittest.TestCase):
formats = [name for name, params in get_archive_formats()]
self.assertNotIn('xxx', formats)
+ def _compare_dirs(self, dir1, dir2):
+ # check that dir1 and dir2 are equivalent,
+ # return the diff
+ diff = []
+ for root, dirs, files in os.walk(dir1):
+ for file_ in files:
+ path = os.path.join(root, file_)
+ target_path = os.path.join(dir2, os.path.split(path)[-1])
+ if not os.path.exists(target_path):
+ diff.append(file_)
+ return diff
+
+ @unittest.skipUnless(zlib, "Requires zlib")
+ def test_unpack_archive(self):
+ formats = ['tar', 'gztar', 'zip']
+ if BZ2_SUPPORTED:
+ formats.append('bztar')
+
+ for format in formats:
+ tmpdir = self.mkdtemp()
+ base_dir, root_dir, base_name = self._create_files()
+ tmpdir2 = self.mkdtemp()
+ filename = make_archive(base_name, format, root_dir, base_dir)
+
+ # let's try to unpack it now
+ unpack_archive(filename, tmpdir2)
+ diff = self._compare_dirs(tmpdir, tmpdir2)
+ self.assertEqual(diff, [])
+
+ # and again, this time with the format specified
+ tmpdir3 = self.mkdtemp()
+ unpack_archive(filename, tmpdir3, format=format)
+ diff = self._compare_dirs(tmpdir, tmpdir3)
+ self.assertEqual(diff, [])
+ self.assertRaises(shutil.ReadError, unpack_archive, TESTFN)
+ self.assertRaises(ValueError, unpack_archive, TESTFN, format='xxx')
+
+ def test_unpack_registery(self):
+
+ formats = get_unpack_formats()
+
+ def _boo(filename, extract_dir, extra):
+ self.assertEqual(extra, 1)
+ self.assertEqual(filename, 'stuff.boo')
+ self.assertEqual(extract_dir, 'xx')
+
+ register_unpack_format('Boo', ['.boo', '.b2'], _boo, [('extra', 1)])
+ unpack_archive('stuff.boo', 'xx')
+
+ # trying to register a .boo unpacker again
+ self.assertRaises(RegistryError, register_unpack_format, 'Boo2',
+ ['.boo'], _boo)
+
+ # should work now
+ unregister_unpack_format('Boo')
+ register_unpack_format('Boo2', ['.boo'], _boo)
+ self.assertIn(('Boo2', ['.boo'], ''), get_unpack_formats())
+ self.assertNotIn(('Boo', ['.boo'], ''), get_unpack_formats())
+
+ # let's leave a clean state
+ unregister_unpack_format('Boo2')
+ self.assertEqual(get_unpack_formats(), formats)
+
class TestMove(unittest.TestCase):
@@ -604,20 +822,11 @@ class TestMove(unittest.TestCase):
self.dst_dir = tempfile.mkdtemp()
self.src_file = os.path.join(self.src_dir, filename)
self.dst_file = os.path.join(self.dst_dir, filename)
- # Try to create a dir in the current directory, hoping that it is
- # not located on the same filesystem as the system tmp dir.
- try:
- self.dir_other_fs = tempfile.mkdtemp(
- dir=os.path.dirname(__file__))
- self.file_other_fs = os.path.join(self.dir_other_fs,
- filename)
- except OSError:
- self.dir_other_fs = None
with open(self.src_file, "wb") as f:
- f.write("spam")
+ f.write(b"spam")
def tearDown(self):
- for d in (self.src_dir, self.dst_dir, self.dir_other_fs):
+ for d in (self.src_dir, self.dst_dir):
try:
if d:
shutil.rmtree(d)
@@ -646,21 +855,15 @@ class TestMove(unittest.TestCase):
# Move a file inside an existing dir on the same filesystem.
self._check_move_file(self.src_file, self.dst_dir, self.dst_file)
+ @mock_rename
def test_move_file_other_fs(self):
# Move a file to an existing dir on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_file(self.src_file, self.file_other_fs,
- self.file_other_fs)
+ self.test_move_file()
+ @mock_rename
def test_move_file_to_dir_other_fs(self):
# Move a file to another location on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_file(self.src_file, self.dir_other_fs,
- self.file_other_fs)
+ self.test_move_file_to_dir()
def test_move_dir(self):
# Move a dir to another location on the same filesystem.
@@ -673,32 +876,20 @@ class TestMove(unittest.TestCase):
except:
pass
+ @mock_rename
def test_move_dir_other_fs(self):
# Move a dir to another location on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- dst_dir = tempfile.mktemp(dir=self.dir_other_fs)
- try:
- self._check_move_dir(self.src_dir, dst_dir, dst_dir)
- finally:
- try:
- shutil.rmtree(dst_dir)
- except:
- pass
+ self.test_move_dir()
def test_move_dir_to_dir(self):
# Move a dir inside an existing dir on the same filesystem.
self._check_move_dir(self.src_dir, self.dst_dir,
os.path.join(self.dst_dir, os.path.basename(self.src_dir)))
+ @mock_rename
def test_move_dir_to_dir_other_fs(self):
# Move a dir inside an existing dir on another filesystem.
- if not self.dir_other_fs:
- # skip
- return
- self._check_move_dir(self.src_dir, self.dir_other_fs,
- os.path.join(self.dir_other_fs, os.path.basename(self.src_dir)))
+ self.test_move_dir_to_dir()
def test_existing_file_inside_dest_dir(self):
# A file with the same name inside the destination dir already exists.
@@ -859,7 +1050,7 @@ class TestCopyFile(unittest.TestCase):
def test_main():
- test_support.run_unittest(TestShutil, TestMove, TestCopyFile)
+ support.run_unittest(TestShutil, TestMove, TestCopyFile)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
index 28037858b02..4a1b4a654f7 100644
--- a/Lib/test/test_signal.py
+++ b/Lib/test/test_signal.py
@@ -1,13 +1,17 @@
-import unittest
-from test import test_support
-from contextlib import closing
+import errno
import gc
+import os
import pickle
import select
import signal
import subprocess
+import sys
+import time
import traceback
-import sys, os, time, errno
+import unittest
+from test import support
+from contextlib import closing
+from test.script_helper import assert_python_ok, spawn_python
if sys.platform in ('os2', 'riscos'):
raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
@@ -53,15 +57,15 @@ class InterProcessSignalTests(unittest.TestCase):
def handlerA(self, signum, frame):
self.a_called = True
- if test_support.verbose:
- print "handlerA invoked from signal %s at:\n%s" % (
- signum, self.format_frame(frame, limit=1))
+ if support.verbose:
+ print("handlerA invoked from signal %s at:\n%s" % (
+ signum, self.format_frame(frame, limit=1)))
def handlerB(self, signum, frame):
self.b_called = True
- if test_support.verbose:
- print "handlerB invoked from signal %s at:\n%s" % (
- signum, self.format_frame(frame, limit=1))
+ if support.verbose:
+ print ("handlerB invoked from signal %s at:\n%s" % (
+ signum, self.format_frame(frame, limit=1)))
raise HandlerBCalled(signum, self.format_frame(frame))
def wait(self, child):
@@ -88,8 +92,8 @@ class InterProcessSignalTests(unittest.TestCase):
# Let the sub-processes know who to send signals to.
pid = os.getpid()
- if test_support.verbose:
- print "test runner's pid is", pid
+ if support.verbose:
+ print("test runner's pid is", pid)
child = ignoring_eintr(subprocess.Popen, ['kill', '-HUP', str(pid)])
if child:
@@ -113,8 +117,8 @@ class InterProcessSignalTests(unittest.TestCase):
except HandlerBCalled:
self.assertTrue(self.b_called)
self.assertFalse(self.a_called)
- if test_support.verbose:
- print "HandlerBCalled exception caught"
+ if support.verbose:
+ print("HandlerBCalled exception caught")
child = ignoring_eintr(subprocess.Popen, ['kill', '-USR2', str(pid)])
if child:
@@ -130,8 +134,8 @@ class InterProcessSignalTests(unittest.TestCase):
# may return early.
time.sleep(1)
except KeyboardInterrupt:
- if test_support.verbose:
- print "KeyboardInterrupt (the alarm() went off)"
+ if support.verbose:
+ print("KeyboardInterrupt (the alarm() went off)")
except:
self.fail("Some other exception woke us from pause: %s" %
traceback.format_exc())
@@ -139,7 +143,7 @@ class InterProcessSignalTests(unittest.TestCase):
self.fail("pause returned of its own accord, and the signal"
" didn't arrive after another second.")
- # Issue 3864. Unknown if this affects earlier versions of freebsd also.
+ # Issue 3864, unknown if this affects earlier versions of freebsd also
@unittest.skipIf(sys.platform=='freebsd6',
'inter process signals not reliable (do not mix well with threading) '
'on freebsd6')
@@ -150,8 +154,8 @@ class InterProcessSignalTests(unittest.TestCase):
# re-raises information about any exceptions the child
# raises. The real work happens in self.run_test().
os_done_r, os_done_w = os.pipe()
- with closing(os.fdopen(os_done_r)) as done_r, \
- closing(os.fdopen(os_done_w, 'w')) as done_w:
+ with closing(os.fdopen(os_done_r, 'rb')) as done_r, \
+ closing(os.fdopen(os_done_w, 'wb')) as done_w:
child = os.fork()
if child == 0:
# In the child process; run the test and report results
@@ -168,7 +172,7 @@ class InterProcessSignalTests(unittest.TestCase):
else:
pickle.dump(None, done_w)
except:
- print 'Uh oh, raised from pickle.'
+ print('Uh oh, raised from pickle.')
traceback.print_exc()
finally:
exit_subprocess()
@@ -229,150 +233,174 @@ class WindowsSignalTests(unittest.TestCase):
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class WakeupSignalTests(unittest.TestCase):
- TIMEOUT_FULL = 10
- TIMEOUT_HALF = 5
+ def check_wakeup(self, test_body):
+ # use a subprocess to have only one thread and to not change signal
+ # handling of the parent process
+ code = """if 1:
+ import fcntl
+ import os
+ import signal
+
+ def handler(signum, frame):
+ pass
+
+ {}
+
+ signal.signal(signal.SIGALRM, handler)
+ read, write = os.pipe()
+ flags = fcntl.fcntl(write, fcntl.F_GETFL, 0)
+ flags = flags | os.O_NONBLOCK
+ fcntl.fcntl(write, fcntl.F_SETFL, flags)
+ signal.set_wakeup_fd(write)
+
+ test()
+
+ os.close(read)
+ os.close(write)
+ """.format(test_body)
+
+ assert_python_ok('-c', code)
def test_wakeup_fd_early(self):
- import select
-
- signal.alarm(1)
- before_time = time.time()
- # We attempt to get a signal during the sleep,
- # before select is called
- time.sleep(self.TIMEOUT_FULL)
- mid_time = time.time()
- self.assertTrue(mid_time - before_time < self.TIMEOUT_HALF)
- select.select([self.read], [], [], self.TIMEOUT_FULL)
- after_time = time.time()
- self.assertTrue(after_time - mid_time < self.TIMEOUT_HALF)
+ self.check_wakeup("""def test():
+ import select
+ import time
- def test_wakeup_fd_during(self):
- import select
+ TIMEOUT_FULL = 10
+ TIMEOUT_HALF = 5
- signal.alarm(1)
- before_time = time.time()
- # We attempt to get a signal during the select call
- self.assertRaises(select.error, select.select,
- [self.read], [], [], self.TIMEOUT_FULL)
- after_time = time.time()
- self.assertTrue(after_time - before_time < self.TIMEOUT_HALF)
+ signal.alarm(1)
+ before_time = time.time()
+ # We attempt to get a signal during the sleep,
+ # before select is called
+ time.sleep(TIMEOUT_FULL)
+ mid_time = time.time()
+ dt = mid_time - before_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ select.select([read], [], [], TIMEOUT_FULL)
+ after_time = time.time()
+ dt = after_time - mid_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ """)
- def setUp(self):
- import fcntl
+ def test_wakeup_fd_during(self):
+ self.check_wakeup("""def test():
+ import select
+ import time
- self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None)
- self.read, self.write = os.pipe()
- flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0)
- flags = flags | os.O_NONBLOCK
- fcntl.fcntl(self.write, fcntl.F_SETFL, flags)
- self.old_wakeup = signal.set_wakeup_fd(self.write)
+ TIMEOUT_FULL = 10
+ TIMEOUT_HALF = 5
- def tearDown(self):
- signal.set_wakeup_fd(self.old_wakeup)
- os.close(self.read)
- os.close(self.write)
- signal.signal(signal.SIGALRM, self.alrm)
+ signal.alarm(1)
+ before_time = time.time()
+ # We attempt to get a signal during the select call
+ try:
+ select.select([read], [], [], TIMEOUT_FULL)
+ except select.error:
+ pass
+ else:
+ raise Exception("select.error not raised")
+ after_time = time.time()
+ dt = after_time - before_time
+ if dt >= TIMEOUT_HALF:
+ raise Exception("%s >= %s" % (dt, TIMEOUT_HALF))
+ """)
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
class SiginterruptTest(unittest.TestCase):
- def setUp(self):
- """Install a no-op signal handler that can be set to allow
- interrupts or not, and arrange for the original signal handler to be
- re-installed when the test is finished.
- """
- self.signum = signal.SIGUSR1
- oldhandler = signal.signal(self.signum, lambda x,y: None)
- self.addCleanup(signal.signal, self.signum, oldhandler)
-
- def readpipe_interrupted(self):
+ def readpipe_interrupted(self, interrupt):
"""Perform a read during which a signal will arrive. Return True if the
read is interrupted by the signal and raises an exception. Return False
if it returns normally.
"""
- # Create a pipe that can be used for the read. Also clean it up
- # when the test is over, since nothing else will (but see below for
- # the write end).
- r, w = os.pipe()
- self.addCleanup(os.close, r)
-
- # Create another process which can send a signal to this one to try
- # to interrupt the read.
- ppid = os.getpid()
- pid = os.fork()
-
- if pid == 0:
- # Child code: sleep to give the parent enough time to enter the
- # read() call (there's a race here, but it's really tricky to
- # eliminate it); then signal the parent process. Also, sleep
- # again to make it likely that the signal is delivered to the
- # parent process before the child exits. If the child exits
- # first, the write end of the pipe will be closed and the test
- # is invalid.
- try:
- time.sleep(0.2)
- os.kill(ppid, self.signum)
- time.sleep(0.2)
- finally:
- # No matter what, just exit as fast as possible now.
- exit_subprocess()
- else:
- # Parent code.
- # Make sure the child is eventually reaped, else it'll be a
- # zombie for the rest of the test suite run.
- self.addCleanup(os.waitpid, pid, 0)
-
- # Close the write end of the pipe. The child has a copy, so
- # it's not really closed until the child exits. We need it to
- # close when the child exits so that in the non-interrupt case
- # the read eventually completes, otherwise we could just close
- # it *after* the test.
- os.close(w)
-
- # Try the read and report whether it is interrupted or not to
- # the caller.
+ class Timeout(Exception):
+ pass
+
+ # use a subprocess to have only one thread, to have a timeout on the
+ # blocking read and to not touch signal handling in this process
+ code = """if 1:
+ import errno
+ import os
+ import signal
+ import sys
+
+ interrupt = %r
+ r, w = os.pipe()
+
+ def handler(signum, frame):
+ pass
+
+ signal.signal(signal.SIGALRM, handler)
+ if interrupt is not None:
+ signal.siginterrupt(signal.SIGALRM, interrupt)
+
+ print("ready")
+ sys.stdout.flush()
+
+ # run the test twice
+ for loop in range(2):
+ # send a SIGALRM in a second (during the read)
+ signal.alarm(1)
+ try:
+ # blocking call: read from a pipe without data
+ os.read(r, 1)
+ except OSError as err:
+ if err.errno != errno.EINTR:
+ raise
+ else:
+ sys.exit(2)
+ sys.exit(3)
+ """ % (interrupt,)
+ with spawn_python('-c', code) as process:
try:
- d = os.read(r, 1)
+ # wait until the child process is loaded and has started
+ first_line = process.stdout.readline()
+
+ # Wait the process with a timeout of 5 seconds
+ timeout = time.time() + 5.0
+ while True:
+ if timeout < time.time():
+ raise Timeout()
+ status = process.poll()
+ if status is not None:
+ break
+ time.sleep(0.1)
+
+ stdout, stderr = process.communicate()
+ except Timeout:
+ process.kill()
return False
- except OSError, err:
- if err.errno != errno.EINTR:
- raise
- return True
+ else:
+ stdout = first_line + stdout
+ exitcode = process.wait()
+ if exitcode not in (2, 3):
+ raise Exception("Child error (exit code %s): %s"
+ % (exitcode, stdout))
+ return (exitcode == 3)
def test_without_siginterrupt(self):
- """If a signal handler is installed and siginterrupt is not called
- at all, when that signal arrives, it interrupts a syscall that's in
- progress.
- """
- i = self.readpipe_interrupted()
- self.assertTrue(i)
- # Arrival of the signal shouldn't have changed anything.
- i = self.readpipe_interrupted()
- self.assertTrue(i)
+ # If a signal handler is installed and siginterrupt is not called
+ # at all, when that signal arrives, it interrupts a syscall that's in
+ # progress.
+ interrupted = self.readpipe_interrupted(None)
+ self.assertTrue(interrupted)
def test_siginterrupt_on(self):
- """If a signal handler is installed and siginterrupt is called with
- a true value for the second argument, when that signal arrives, it
- interrupts a syscall that's in progress.
- """
- signal.siginterrupt(self.signum, 1)
- i = self.readpipe_interrupted()
- self.assertTrue(i)
- # Arrival of the signal shouldn't have changed anything.
- i = self.readpipe_interrupted()
- self.assertTrue(i)
+ # If a signal handler is installed and siginterrupt is called with
+ # a true value for the second argument, when that signal arrives, it
+ # interrupts a syscall that's in progress.
+ interrupted = self.readpipe_interrupted(True)
+ self.assertTrue(interrupted)
def test_siginterrupt_off(self):
- """If a signal handler is installed and siginterrupt is called with
- a false value for the second argument, when that signal arrives, it
- does not interrupt a syscall that's in progress.
- """
- signal.siginterrupt(self.signum, 0)
- i = self.readpipe_interrupted()
- self.assertFalse(i)
- # Arrival of the signal shouldn't have changed anything.
- i = self.readpipe_interrupted()
- self.assertFalse(i)
+ # If a signal handler is installed and siginterrupt is called with
+ # a false value for the second argument, when that signal arrives, it
+ # does not interrupt a syscall that's in progress.
+ interrupted = self.readpipe_interrupted(False)
+ self.assertFalse(interrupted)
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
@@ -391,7 +419,7 @@ class ItimerTest(unittest.TestCase):
def sig_alrm(self, *args):
self.hndl_called = True
- if test_support.verbose:
+ if support.verbose:
print("SIGALRM handler invoked", args)
def sig_vtalrm(self, *args):
@@ -404,19 +432,19 @@ class ItimerTest(unittest.TestCase):
elif self.hndl_count == 3:
# disable ITIMER_VIRTUAL, this function shouldn't be called anymore
signal.setitimer(signal.ITIMER_VIRTUAL, 0)
- if test_support.verbose:
+ if support.verbose:
print("last SIGVTALRM handler call")
self.hndl_count += 1
- if test_support.verbose:
+ if support.verbose:
print("SIGVTALRM handler invoked", args)
def sig_prof(self, *args):
self.hndl_called = True
signal.setitimer(signal.ITIMER_PROF, 0)
- if test_support.verbose:
+ if support.verbose:
print("SIGPROF handler invoked", args)
def test_itimer_exc(self):
@@ -431,13 +459,13 @@ class ItimerTest(unittest.TestCase):
def test_itimer_real(self):
self.itimer = signal.ITIMER_REAL
signal.setitimer(self.itimer, 1.0)
- if test_support.verbose:
+ if support.verbose:
print("\ncall pause()...")
signal.pause()
self.assertEqual(self.hndl_called, True)
- # Issue 3864. Unknown if this affects earlier versions of freebsd also.
+ # Issue 3864, unknown if this affects earlier versions of freebsd also
@unittest.skipIf(sys.platform in ('freebsd6', 'netbsd5'),
'itimer not reliable (does not mix well with threading) on some BSDs.')
def test_itimer_virtual(self):
@@ -460,7 +488,7 @@ class ItimerTest(unittest.TestCase):
# and the handler should have been called
self.assertEqual(self.hndl_called, True)
- # Issue 3864. Unknown if this affects earlier versions of freebsd also.
+ # Issue 3864, unknown if this affects earlier versions of freebsd also
@unittest.skipIf(sys.platform=='freebsd6',
'itimer not reliable (does not mix well with threading) on freebsd6')
def test_itimer_prof(self):
@@ -484,9 +512,12 @@ class ItimerTest(unittest.TestCase):
self.assertEqual(self.hndl_called, True)
def test_main():
- test_support.run_unittest(BasicSignalTests, InterProcessSignalTests,
- WakeupSignalTests, SiginterruptTest,
- ItimerTest, WindowsSignalTests)
+ try:
+ support.run_unittest(BasicSignalTests, InterProcessSignalTests,
+ WakeupSignalTests, SiginterruptTest,
+ ItimerTest, WindowsSignalTests)
+ finally:
+ support.reap_children()
if __name__ == "__main__":
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index f4b5fc67347..ba426494fb4 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -5,9 +5,9 @@ executing have not been removed.
"""
import unittest
-from test.test_support import run_unittest, TESTFN, EnvironmentVarGuard
-from test.test_support import captured_output
-import __builtin__
+from test.support import run_unittest, TESTFN, EnvironmentVarGuard
+from test.support import captured_stderr
+import builtins
import os
import sys
import re
@@ -31,10 +31,6 @@ if site.ENABLE_USER_SITE and not os.path.isdir(site.USER_SITE):
class HelperFunctionsTests(unittest.TestCase):
"""Tests for helper functions.
-
- The setting of the encoding (set using sys.setdefaultencoding) used by
- the Unicode implementation is not tested.
-
"""
def setUp(self):
@@ -101,7 +97,7 @@ class HelperFunctionsTests(unittest.TestCase):
pth_dir = os.path.abspath(pth_dir)
pth_basename = pth_name + '.pth'
pth_fn = os.path.join(pth_dir, pth_basename)
- pth_file = open(pth_fn, 'w')
+ pth_file = open(pth_fn, 'w', encoding='utf-8')
self.addCleanup(lambda: os.remove(pth_fn))
pth_file.write(contents)
pth_file.close()
@@ -110,43 +106,43 @@ class HelperFunctionsTests(unittest.TestCase):
def test_addpackage_import_bad_syntax(self):
# Issue 10642
pth_dir, pth_fn = self.make_pth("import bad)syntax\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 1")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 1")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: the previous two should be independent checks so that the
# order doesn't matter. The next three could be a single check
# but my regex foo isn't good enough to write it.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), r'import bad\)syntax')
- self.assertRegexpMatches(err_out.getvalue(), 'SyntaxError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), r'import bad\)syntax')
+ self.assertRegex(err_out.getvalue(), 'SyntaxError')
def test_addpackage_import_bad_exec(self):
# Issue 10642
pth_dir, pth_fn = self.make_pth("randompath\nimport nosuchmodule\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 2")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 2")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), 'ImportError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), 'ImportError')
@unittest.skipIf(sys.platform == "win32", "Windows does not raise an "
"error for file paths containing null characters")
def test_addpackage_import_bad_pth_file(self):
# Issue 5258
pth_dir, pth_fn = self.make_pth("abc\x00def\n")
- with captured_output("stderr") as err_out:
+ with captured_stderr() as err_out:
site.addpackage(pth_dir, pth_fn, set())
- self.assertRegexpMatches(err_out.getvalue(), "line 1")
- self.assertRegexpMatches(err_out.getvalue(),
+ self.assertRegex(err_out.getvalue(), "line 1")
+ self.assertRegex(err_out.getvalue(),
re.escape(os.path.join(pth_dir, pth_fn)))
# XXX: ditto previous XXX comment.
- self.assertRegexpMatches(err_out.getvalue(), 'Traceback')
- self.assertRegexpMatches(err_out.getvalue(), 'TypeError')
+ self.assertRegex(err_out.getvalue(), 'Traceback')
+ self.assertRegex(err_out.getvalue(), 'TypeError')
def test_addsitedir(self):
# Same tests for test_addpackage since addsitedir() essentially just
@@ -171,8 +167,7 @@ class HelperFunctionsTests(unittest.TestCase):
rc = subprocess.call([sys.executable, '-c',
'import sys; sys.exit(%r in sys.path)' % usersite],
env=env)
- self.assertEqual(rc, 1, "%r is not in sys.path (sys.exit returned %r)"
- % (usersite, rc))
+ self.assertEqual(rc, 1)
env = os.environ.copy()
rc = subprocess.call([sys.executable, '-s', '-c',
@@ -282,11 +277,11 @@ class PthFile(object):
"""
FILE = open(self.file_path, 'w')
try:
- print>>FILE, "#import @bad module name"
- print>>FILE, "\n"
- print>>FILE, "import %s" % self.imported
- print>>FILE, self.good_dirname
- print>>FILE, self.bad_dirname
+ print("#import @bad module name", file=FILE)
+ print("\n", file=FILE)
+ print("import %s" % self.imported, file=FILE)
+ print(self.good_dirname, file=FILE)
+ print(self.bad_dirname, file=FILE)
finally:
FILE.close()
os.mkdir(self.good_dir_path)
@@ -320,19 +315,43 @@ class ImportSideEffectTests(unittest.TestCase):
"""Restore sys.path"""
sys.path[:] = self.sys_path
- def test_abs__file__(self):
- # Make sure all imported modules have their __file__ attribute
- # as an absolute path.
- # Handled by abs__file__()
- site.abs__file__()
- for module in (sys, os, __builtin__):
- try:
- self.assertTrue(os.path.isabs(module.__file__), repr(module))
- except AttributeError:
- continue
- # We could try everything in sys.modules; however, when regrtest.py
- # runs something like test_frozen before test_site, then we will
- # be testing things loaded *after* test_site did path normalization
+ def test_abs_paths(self):
+ # Make sure all imported modules have their __file__ and __cached__
+ # attributes as absolute paths. Arranging to put the Lib directory on
+ # PYTHONPATH would cause the os module to have a relative path for
+ # __file__ if abs_paths() does not get run. sys and builtins (the
+ # only other modules imported before site.py runs) do not have
+ # __file__ or __cached__ because they are built-in.
+ parent = os.path.relpath(os.path.dirname(os.__file__))
+ env = os.environ.copy()
+ env['PYTHONPATH'] = parent
+ code = ('import os, sys',
+ # use ASCII to avoid locale issues with non-ASCII directories
+ 'os_file = os.__file__.encode("ascii", "backslashreplace")',
+ r'sys.stdout.buffer.write(os_file + b"\n")',
+ 'os_cached = os.__cached__.encode("ascii", "backslashreplace")',
+ r'sys.stdout.buffer.write(os_cached + b"\n")')
+ command = '\n'.join(code)
+ # First, prove that with -S (no 'import site'), the paths are
+ # relative.
+ proc = subprocess.Popen([sys.executable, '-S', '-c', command],
+ env=env,
+ stdout=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+
+ self.assertEqual(proc.returncode, 0)
+ os__file__, os__cached__ = stdout.splitlines()[:2]
+ self.assertFalse(os.path.isabs(os__file__))
+ self.assertFalse(os.path.isabs(os__cached__))
+ # Now, with 'import site', it works.
+ proc = subprocess.Popen([sys.executable, '-c', command],
+ env=env,
+ stdout=subprocess.PIPE)
+ stdout, stderr = proc.communicate()
+ self.assertEqual(proc.returncode, 0)
+ os__file__, os__cached__ = stdout.splitlines()[:2]
+ self.assertTrue(os.path.isabs(os__file__))
+ self.assertTrue(os.path.isabs(os__cached__))
def test_no_duplicate_paths(self):
# No duplicate paths should exist in sys.path
@@ -350,33 +369,29 @@ class ImportSideEffectTests(unittest.TestCase):
pass
def test_setting_quit(self):
- # 'quit' and 'exit' should be injected into __builtin__
- self.assertTrue(hasattr(__builtin__, "quit"))
- self.assertTrue(hasattr(__builtin__, "exit"))
+ # 'quit' and 'exit' should be injected into builtins
+ self.assertTrue(hasattr(builtins, "quit"))
+ self.assertTrue(hasattr(builtins, "exit"))
def test_setting_copyright(self):
- # 'copyright' and 'credits' should be in __builtin__
- self.assertTrue(hasattr(__builtin__, "copyright"))
- self.assertTrue(hasattr(__builtin__, "credits"))
+ # 'copyright' and 'credits' should be in builtins
+ self.assertTrue(hasattr(builtins, "copyright"))
+ self.assertTrue(hasattr(builtins, "credits"))
def test_setting_help(self):
- # 'help' should be set in __builtin__
- self.assertTrue(hasattr(__builtin__, "help"))
+ # 'help' should be set in builtins
+ self.assertTrue(hasattr(builtins, "help"))
def test_aliasing_mbcs(self):
if sys.platform == "win32":
import locale
if locale.getdefaultlocale()[1].startswith('cp'):
- for value in encodings.aliases.aliases.itervalues():
+ for value in encodings.aliases.aliases.values():
if value == "mbcs":
break
else:
self.fail("did not alias mbcs")
- def test_setdefaultencoding_removed(self):
- # Make sure sys.setdefaultencoding is gone
- self.assertTrue(not hasattr(sys, "setdefaultencoding"))
-
def test_sitecustomize_executed(self):
# If sitecustomize is available, it should have been imported.
if "sitecustomize" not in sys.modules:
diff --git a/Lib/test/test_slice.py b/Lib/test/test_slice.py
index 3304d6b4e3b..2df9271da7c 100644
--- a/Lib/test/test_slice.py
+++ b/Lib/test/test_slice.py
@@ -1,8 +1,8 @@
# tests for slice objects; in particular the indices method.
import unittest
-from test import test_support
-from cPickle import loads, dumps
+from test import support
+from pickle import loads, dumps
import sys
@@ -26,6 +26,9 @@ class SliceTest(unittest.TestCase):
s3 = slice(1, 2, 4)
self.assertEqual(s1, s2)
self.assertNotEqual(s1, s3)
+ self.assertNotEqual(s1, None)
+ self.assertNotEqual(s1, (1, 2, 3))
+ self.assertNotEqual(s1, "")
class Exc(Exception):
pass
@@ -33,22 +36,21 @@ class SliceTest(unittest.TestCase):
class BadCmp(object):
def __eq__(self, other):
raise Exc
- __hash__ = None # Silence Py3k warning
s1 = slice(BadCmp())
s2 = slice(BadCmp())
- self.assertRaises(Exc, cmp, s1, s2)
self.assertEqual(s1, s1)
+ self.assertRaises(Exc, lambda: s1 == s2)
s1 = slice(1, BadCmp())
s2 = slice(1, BadCmp())
self.assertEqual(s1, s1)
- self.assertRaises(Exc, cmp, s1, s2)
+ self.assertRaises(Exc, lambda: s1 == s2)
s1 = slice(1, 2, BadCmp())
s2 = slice(1, 2, BadCmp())
self.assertEqual(s1, s1)
- self.assertRaises(Exc, cmp, s1, s2)
+ self.assertRaises(Exc, lambda: s1 == s2)
def test_members(self):
s = slice(1)
@@ -102,22 +104,21 @@ class SliceTest(unittest.TestCase):
slice(100, -100, -1).indices(10),
slice(None, None, -1).indices(10)
)
- self.assertEqual(slice(-100L, 100L, 2L).indices(10), (0, 10, 2))
+ self.assertEqual(slice(-100, 100, 2).indices(10), (0, 10, 2))
- self.assertEqual(range(10)[::sys.maxint - 1], [0])
+ self.assertEqual(list(range(10))[::sys.maxsize - 1], [0])
- self.assertRaises(OverflowError, slice(None).indices, 1L<<100)
+ self.assertRaises(OverflowError, slice(None).indices, 1<<100)
def test_setslice_without_getslice(self):
tmp = []
class X(object):
- def __setslice__(self, i, j, k):
- tmp.append((i, j, k))
+ def __setitem__(self, i, k):
+ tmp.append((i, k))
x = X()
- with test_support.check_py3k_warnings():
- x[1:2] = 42
- self.assertEqual(tmp, [(1, 2, 42)])
+ x[1:2] = 42
+ self.assertEqual(tmp, [(slice(1, 2), 42)])
def test_pickle(self):
s = slice(10, 20, 3)
@@ -128,7 +129,7 @@ class SliceTest(unittest.TestCase):
self.assertNotEqual(id(s), id(t))
def test_main():
- test_support.run_unittest(SliceTest)
+ support.run_unittest(SliceTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_smtpd.py b/Lib/test/test_smtpd.py
new file mode 100644
index 00000000000..68ccc29036a
--- /dev/null
+++ b/Lib/test/test_smtpd.py
@@ -0,0 +1,291 @@
+from unittest import TestCase
+from test import support, mock_socket
+import socket
+import io
+import smtpd
+import asyncore
+
+
+class DummyServer(smtpd.SMTPServer):
+ def __init__(self, localaddr, remoteaddr):
+ smtpd.SMTPServer.__init__(self, localaddr, remoteaddr)
+ self.messages = []
+
+ def process_message(self, peer, mailfrom, rcpttos, data):
+ self.messages.append((peer, mailfrom, rcpttos, data))
+ if data == 'return status':
+ return '250 Okish'
+
+
+class DummyDispatcherBroken(Exception):
+ pass
+
+
+class BrokenDummyServer(DummyServer):
+ def listen(self, num):
+ raise DummyDispatcherBroken()
+
+
+class SMTPDServerTest(TestCase):
+ def setUp(self):
+ smtpd.socket = asyncore.socket = mock_socket
+
+ def test_process_message_unimplemented(self):
+ server = smtpd.SMTPServer('a', 'b')
+ conn, addr = server.accept()
+ channel = smtpd.SMTPChannel(server, conn, addr)
+
+ def write_line(line):
+ channel.socket.queue_recv(line)
+ channel.handle_read()
+
+ write_line(b'MAIL From:eggs@example')
+ write_line(b'RCPT To:spam@example')
+ write_line(b'DATA')
+ self.assertRaises(NotImplementedError, write_line, b'spam\r\n.\r\n')
+
+ def tearDown(self):
+ asyncore.close_all()
+ asyncore.socket = smtpd.socket = socket
+
+
+class SMTPDChannelTest(TestCase):
+ def setUp(self):
+ smtpd.socket = asyncore.socket = mock_socket
+ self.old_debugstream = smtpd.DEBUGSTREAM
+ self.debug = smtpd.DEBUGSTREAM = io.StringIO()
+ self.server = DummyServer('a', 'b')
+ conn, addr = self.server.accept()
+ self.channel = smtpd.SMTPChannel(self.server, conn, addr)
+
+ def tearDown(self):
+ asyncore.close_all()
+ asyncore.socket = smtpd.socket = socket
+ smtpd.DEBUGSTREAM = self.old_debugstream
+
+ def write_line(self, line):
+ self.channel.socket.queue_recv(line)
+ self.channel.handle_read()
+
+ def test_broken_connect(self):
+ self.assertRaises(DummyDispatcherBroken, BrokenDummyServer, 'a', 'b')
+
+ def test_server_accept(self):
+ self.server.handle_accept()
+
+ def test_missing_data(self):
+ self.write_line(b'')
+ self.assertEqual(self.channel.socket.last,
+ b'500 Error: bad syntax\r\n')
+
+ def test_EHLO_not_implemented(self):
+ self.write_line(b'EHLO test.example')
+ self.assertEqual(self.channel.socket.last,
+ b'502 Error: command "EHLO" not implemented\r\n')
+
+ def test_HELO(self):
+ name = smtpd.socket.getfqdn()
+ self.write_line(b'HELO test.example')
+ self.assertEqual(self.channel.socket.last,
+ '250 {}\r\n'.format(name).encode('ascii'))
+
+ def test_HELO_bad_syntax(self):
+ self.write_line(b'HELO')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: HELO hostname\r\n')
+
+ def test_HELO_duplicate(self):
+ self.write_line(b'HELO test.example')
+ self.write_line(b'HELO test.example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Duplicate HELO/EHLO\r\n')
+
+ def test_NOOP(self):
+ self.write_line(b'NOOP')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ def test_NOOP_bad_syntax(self):
+ self.write_line(b'NOOP hi')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: NOOP\r\n')
+
+ def test_QUIT(self):
+ self.write_line(b'QUIT')
+ self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')
+
+ def test_QUIT_arg_ignored(self):
+ self.write_line(b'QUIT bye bye')
+ self.assertEqual(self.channel.socket.last, b'221 Bye\r\n')
+
+ def test_bad_state(self):
+ self.channel.smtp_state = 'BAD STATE'
+ self.write_line(b'HELO')
+ self.assertEqual(self.channel.socket.last,
+ b'451 Internal confusion\r\n')
+
+ def test_command_too_long(self):
+ self.write_line(b'MAIL from ' +
+ b'a' * self.channel.command_size_limit +
+ b'@example')
+ self.assertEqual(self.channel.socket.last,
+ b'500 Error: line too long\r\n')
+
+ def test_data_too_long(self):
+ # Small hack. Setting limit to 2K octets here will save us some time.
+ self.channel.data_size_limit = 2048
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'A' * self.channel.data_size_limit +
+ b'A\r\n.')
+ self.assertEqual(self.channel.socket.last,
+ b'552 Error: Too much mail data\r\n')
+
+ def test_need_MAIL(self):
+ self.write_line(b'RCPT to:spam@example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: need MAIL command\r\n')
+
+ def test_MAIL_syntax(self):
+ self.write_line(b'MAIL from eggs@example')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: MAIL FROM:<address>\r\n')
+
+ def test_MAIL_missing_from(self):
+ self.write_line(b'MAIL from:')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: MAIL FROM:<address>\r\n')
+
+ def test_MAIL_chevrons(self):
+ self.write_line(b'MAIL from:<eggs@example>')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ def test_nested_MAIL(self):
+ self.write_line(b'MAIL from:eggs@example')
+ self.write_line(b'MAIL from:spam@example')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: nested MAIL command\r\n')
+
+ def test_need_RCPT(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'DATA')
+ self.assertEqual(self.channel.socket.last,
+ b'503 Error: need RCPT command\r\n')
+
+ def test_RCPT_syntax(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT to eggs@example')
+ self.assertEqual(self.channel.socket.last,
+ b'501 Syntax: RCPT TO: <address>\r\n')
+
+ def test_data_dialog(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.write_line(b'RCPT To:spam@example')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+
+ self.write_line(b'DATA')
+ self.assertEqual(self.channel.socket.last,
+ b'354 End data with <CR><LF>.<CR><LF>\r\n')
+ self.write_line(b'data\r\nmore\r\n.')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.assertEqual(self.server.messages,
+ [('peer', 'eggs@example', ['spam@example'], 'data\nmore')])
+
+ def test_DATA_syntax(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA spam')
+ self.assertEqual(self.channel.socket.last, b'501 Syntax: DATA\r\n')
+
+ def test_data_transparency_section_4_5_2(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'..\r\n.\r\n')
+ self.assertEqual(self.channel.received_data, '.')
+
+ def test_multiple_RCPT(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'RCPT To:ham@example')
+ self.write_line(b'DATA')
+ self.write_line(b'data\r\n.')
+ self.assertEqual(self.server.messages,
+ [('peer', 'eggs@example', ['spam@example','ham@example'], 'data')])
+
+ def test_manual_status(self):
+ # checks that the Channel is able to return a custom status message
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'DATA')
+ self.write_line(b'return status\r\n.')
+ self.assertEqual(self.channel.socket.last, b'250 Okish\r\n')
+
+ def test_RSET(self):
+ self.write_line(b'MAIL From:eggs@example')
+ self.write_line(b'RCPT To:spam@example')
+ self.write_line(b'RSET')
+ self.assertEqual(self.channel.socket.last, b'250 Ok\r\n')
+ self.write_line(b'MAIL From:foo@example')
+ self.write_line(b'RCPT To:eggs@example')
+ self.write_line(b'DATA')
+ self.write_line(b'data\r\n.')
+ self.assertEqual(self.server.messages,
+ [('peer', 'foo@example', ['eggs@example'], 'data')])
+
+ def test_RSET_syntax(self):
+ self.write_line(b'RSET hi')
+ self.assertEqual(self.channel.socket.last, b'501 Syntax: RSET\r\n')
+
+ def test_attribute_deprecations(self):
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__server
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__server = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__line
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__line = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__state
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__state = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__greeting
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__greeting = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__mailfrom
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__mailfrom = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__rcpttos
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__rcpttos = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__data
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__data = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__fqdn
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__fqdn = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__peer
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__peer = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__conn
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__conn = 'spam'
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ spam = self.channel._SMTPChannel__addr
+ with support.check_warnings(('', PendingDeprecationWarning)):
+ self.channel._SMTPChannel__addr = 'spam'
+
+def test_main():
+ support.run_unittest(SMTPDServerTest, SMTPDChannelTest)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_smtplib.py b/Lib/test/test_smtplib.py
index 81806c9898d..2cb0d1ab52b 100644
--- a/Lib/test/test_smtplib.py
+++ b/Lib/test/test_smtplib.py
@@ -1,22 +1,32 @@
import asyncore
+import email.mime.text
import email.utils
import socket
import smtpd
import smtplib
-import StringIO
+import io
+import re
import sys
import time
import select
import unittest
-from test import test_support
+from test import support, mock_socket
try:
import threading
except ImportError:
threading = None
-HOST = test_support.HOST
+HOST = support.HOST
+
+if sys.platform == 'darwin':
+ # select.poll returns a select.POLLHUP at the end of the tests
+ # on darwin, so just ignore it
+ def handle_expt(self):
+ pass
+ smtpd.SMTPChannel.handle_expt = handle_expt
+
def server(evt, buf, serv):
serv.listen(5)
@@ -40,53 +50,55 @@ def server(evt, buf, serv):
serv.close()
evt.set()
-@unittest.skipUnless(threading, 'Threading required for this test.')
class GeneralTests(unittest.TestCase):
def setUp(self):
- self._threads = test_support.threading_setup()
- self.evt = threading.Event()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(15)
- self.port = test_support.bind_port(self.sock)
- servargs = (self.evt, "220 Hola mundo\n", self.sock)
- self.thread = threading.Thread(target=server, args=servargs)
- self.thread.start()
- self.evt.wait()
- self.evt.clear()
+ smtplib.socket = mock_socket
+ self.port = 25
def tearDown(self):
- self.evt.wait()
- self.thread.join()
- test_support.threading_cleanup(*self._threads)
+ smtplib.socket = socket
+
+ # This method is no longer used but is retained for backward compatibility,
+ # so test to make sure it still works.
+ def testQuoteData(self):
+ teststr = "abc\n.jkl\rfoo\r\n..blue"
+ expected = "abc\r\n..jkl\r\nfoo\r\n...blue"
+ self.assertEqual(expected, smtplib.quotedata(teststr))
def testBasic1(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# connects
smtp = smtplib.SMTP(HOST, self.port)
smtp.close()
def testBasic2(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# connects, include port in host name
smtp = smtplib.SMTP("%s:%s" % (HOST, self.port))
smtp.close()
def testLocalHostName(self):
+ mock_socket.reply_with(b"220 Hola mundo")
# check that supplied local_hostname is used
smtp = smtplib.SMTP(HOST, self.port, local_hostname="testhost")
self.assertEqual(smtp.local_hostname, "testhost")
smtp.close()
def testTimeoutDefault(self):
- self.assertTrue(socket.getdefaulttimeout() is None)
- socket.setdefaulttimeout(30)
+ mock_socket.reply_with(b"220 Hola mundo")
+ self.assertTrue(mock_socket.getdefaulttimeout() is None)
+ mock_socket.setdefaulttimeout(30)
+ self.assertEqual(mock_socket.getdefaulttimeout(), 30)
try:
smtp = smtplib.SMTP(HOST, self.port)
finally:
- socket.setdefaulttimeout(None)
+ mock_socket.setdefaulttimeout(None)
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
def testTimeoutNone(self):
+ mock_socket.reply_with(b"220 Hola mundo")
self.assertTrue(socket.getdefaulttimeout() is None)
socket.setdefaulttimeout(30)
try:
@@ -97,6 +109,7 @@ class GeneralTests(unittest.TestCase):
smtp.close()
def testTimeoutValue(self):
+ mock_socket.reply_with(b"220 Hola mundo")
smtp = smtplib.SMTP(HOST, self.port, timeout=30)
self.assertEqual(smtp.sock.gettimeout(), 30)
smtp.close()
@@ -146,15 +159,21 @@ MSG_END = '------------ END MESSAGE ------------\n'
@unittest.skipUnless(threading, 'Threading required for this test.')
class DebuggingServerTests(unittest.TestCase):
+ maxDiff = None
+
def setUp(self):
+ self.real_getfqdn = socket.getfqdn
+ socket.getfqdn = mock_socket.getfqdn
# temporarily replace sys.stdout to capture DebuggingServer output
self.old_stdout = sys.stdout
- self.output = StringIO.StringIO()
+ self.output = io.StringIO()
sys.stdout = self.output
- self._threads = test_support.threading_setup()
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
+ # Capture SMTPChannel debug output
+ self.old_DEBUGSTREAM = smtpd.DEBUGSTREAM
+ smtpd.DEBUGSTREAM = io.StringIO()
# Pick a random unused port by passing 0 for the port number
self.serv = smtpd.DebuggingServer((HOST, 0), ('nowhere', -1))
# Keep a note of what port was assigned
@@ -168,14 +187,17 @@ class DebuggingServerTests(unittest.TestCase):
self.serv_evt.clear()
def tearDown(self):
+ socket.getfqdn = self.real_getfqdn
# indicate that the client is finished
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
self.thread.join()
- test_support.threading_cleanup(*self._threads)
# restore sys.stdout
sys.stdout = self.old_stdout
+ # restore DEBUGSTREAM
+ smtpd.DEBUGSTREAM.close()
+ smtpd.DEBUGSTREAM = self.old_DEBUGSTREAM
def testBasic(self):
# connect
@@ -184,27 +206,27 @@ class DebuggingServerTests(unittest.TestCase):
def testNOOP(self):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
- expected = (250, 'Ok')
+ expected = (250, b'Ok')
self.assertEqual(smtp.noop(), expected)
smtp.quit()
def testRSET(self):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
- expected = (250, 'Ok')
+ expected = (250, b'Ok')
self.assertEqual(smtp.rset(), expected)
smtp.quit()
def testNotImplemented(self):
# EHLO isn't implemented in DebuggingServer
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
- expected = (502, 'Error: command "EHLO" not implemented')
+ expected = (502, b'Error: command "EHLO" not implemented')
self.assertEqual(smtp.ehlo(), expected)
smtp.quit()
def testVRFY(self):
# VRFY isn't implemented in DebuggingServer
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
- expected = (502, 'Error: command "VRFY" not implemented')
+ expected = (502, b'Error: command "VRFY" not implemented')
self.assertEqual(smtp.vrfy('nobody@nowhere.com'), expected)
self.assertEqual(smtp.verify('nobody@nowhere.com'), expected)
smtp.quit()
@@ -214,13 +236,13 @@ class DebuggingServerTests(unittest.TestCase):
# (this behavior is specific to smtpd.SMTPChannel)
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
smtp.helo()
- expected = (503, 'Duplicate HELO/EHLO')
+ expected = (503, b'Duplicate HELO/EHLO')
self.assertEqual(smtp.helo(), expected)
smtp.quit()
def testHELP(self):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
- self.assertEqual(smtp.help(), 'Error: command "HELP" not implemented')
+ self.assertEqual(smtp.help(), b'Error: command "HELP" not implemented')
smtp.quit()
def testSend(self):
@@ -240,9 +262,242 @@ class DebuggingServerTests(unittest.TestCase):
mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
self.assertEqual(self.output.getvalue(), mexpect)
+ def testSendBinary(self):
+ m = b'A test message'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.sendmail('John', 'Sally', m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.decode('ascii'), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
+ def testSendNeedingDotQuote(self):
+ # Issue 12283
+ m = '.A test\n.mes.sage.'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.sendmail('John', 'Sally', m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
+ def testSendNullSender(self):
+ m = 'A test message'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.sendmail('<>', 'Sally', m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m, MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: <>$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+
+ def testSendMessage(self):
+ m = email.mime.text.MIMEText('A test message')
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m, from_addr='John', to_addrs='Sally')
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+
+ def testSendMessageWithAddresses(self):
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John'
+ m['CC'] = 'Sally, Fred'
+ m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+ # make sure the Bcc header is still in the message.
+ self.assertEqual(m['Bcc'], 'John Root <root@localhost>, "Dinsdale" '
+ '<warped@silly.walks.com>')
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ # The Bcc header should not be transmitted.
+ del m['Bcc']
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Sally', 'Fred', 'root@localhost',
+ 'warped@silly.walks.com'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+ def testSendMessageWithSomeAddresses(self):
+ # Make sure nothing breaks if not all of the three 'to' headers exist
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John, Dinsdale'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: foo@bar.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Dinsdale'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+ def testSendMessageWithSpecifiedAddresses(self):
+ # Make sure addresses specified in call override those in message.
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John, Dinsdale'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m, from_addr='joe@example.com', to_addrs='foo@example.net')
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: joe@example.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Dinsdale'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertNotRegex(debugout, to_addr)
+ recip = re.compile(r"^recips: .*'foo@example.net'.*$", re.MULTILINE)
+ self.assertRegex(debugout, recip)
+
+ def testSendMessageWithMultipleFrom(self):
+ # Sender overrides To
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'Bernard, Bianca'
+ m['Sender'] = 'the_rescuers@Rescue-Aid-Society.com'
+ m['To'] = 'John, Dinsdale'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: the_rescuers@Rescue-Aid-Society.com$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('John', 'Dinsdale'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+ def testSendMessageResent(self):
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John'
+ m['CC'] = 'Sally, Fred'
+ m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
+ m['Resent-Date'] = 'Thu, 1 Jan 1970 17:42:00 +0000'
+ m['Resent-From'] = 'holy@grail.net'
+ m['Resent-To'] = 'Martha <my_mom@great.cooker.com>, Jeff'
+ m['Resent-Bcc'] = 'doe@losthope.net'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ smtp.send_message(m)
+ # XXX (see comment in testSend)
+ time.sleep(0.01)
+ smtp.quit()
+
+ self.client_evt.set()
+ self.serv_evt.wait()
+ self.output.flush()
+ # The Resent-Bcc headers are deleted before serialization.
+ del m['Bcc']
+ del m['Resent-Bcc']
+ # Add the X-Peer header that DebuggingServer adds
+ m['X-Peer'] = socket.gethostbyname('localhost')
+ mexpect = '%s%s\n%s' % (MSG_BEGIN, m.as_string(), MSG_END)
+ self.assertEqual(self.output.getvalue(), mexpect)
+ debugout = smtpd.DEBUGSTREAM.getvalue()
+ sender = re.compile("^sender: holy@grail.net$", re.MULTILINE)
+ self.assertRegex(debugout, sender)
+ for addr in ('my_mom@great.cooker.com', 'Jeff', 'doe@losthope.net'):
+ to_addr = re.compile(r"^recips: .*'{}'.*$".format(addr),
+ re.MULTILINE)
+ self.assertRegex(debugout, to_addr)
+
+ def testSendMessageMultipleResentRaises(self):
+ m = email.mime.text.MIMEText('A test message')
+ m['From'] = 'foo@bar.com'
+ m['To'] = 'John'
+ m['CC'] = 'Sally, Fred'
+ m['Bcc'] = 'John Root <root@localhost>, "Dinsdale" <warped@silly.walks.com>'
+ m['Resent-Date'] = 'Thu, 1 Jan 1970 17:42:00 +0000'
+ m['Resent-From'] = 'holy@grail.net'
+ m['Resent-To'] = 'Martha <my_mom@great.cooker.com>, Jeff'
+ m['Resent-Bcc'] = 'doe@losthope.net'
+ m['Resent-Date'] = 'Thu, 2 Jan 1970 17:42:00 +0000'
+ m['Resent-To'] = 'holy@grail.net'
+ m['Resent-From'] = 'Martha <my_mom@great.cooker.com>, Jeff'
+ smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=3)
+ with self.assertRaises(ValueError):
+ smtp.send_message(m)
+ smtp.close()
class NonConnectingTests(unittest.TestCase):
+ def setUp(self):
+ smtplib.socket = mock_socket
+
+ def tearDown(self):
+ smtplib.socket = socket
+
def testNotConnected(self):
# Test various operations on an unconnected SMTP object that
# should raise exceptions (at present the attempt in SMTP.send
@@ -255,9 +510,9 @@ class NonConnectingTests(unittest.TestCase):
def testNonnumericPort(self):
# check that non-numeric port raises socket.error
- self.assertRaises(socket.error, smtplib.SMTP,
+ self.assertRaises(mock_socket.error, smtplib.SMTP,
"localhost", "bogus")
- self.assertRaises(socket.error, smtplib.SMTP,
+ self.assertRaises(mock_socket.error, smtplib.SMTP,
"localhost:bogus")
@@ -266,25 +521,15 @@ class NonConnectingTests(unittest.TestCase):
class BadHELOServerTests(unittest.TestCase):
def setUp(self):
+ smtplib.socket = mock_socket
+ mock_socket.reply_with(b"199 no hello for you!")
self.old_stdout = sys.stdout
- self.output = StringIO.StringIO()
+ self.output = io.StringIO()
sys.stdout = self.output
-
- self._threads = test_support.threading_setup()
- self.evt = threading.Event()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(15)
- self.port = test_support.bind_port(self.sock)
- servargs = (self.evt, "199 no hello for you!\n", self.sock)
- self.thread = threading.Thread(target=server, args=servargs)
- self.thread.start()
- self.evt.wait()
- self.evt.clear()
+ self.port = 25
def tearDown(self):
- self.evt.wait()
- self.thread.join()
- test_support.threading_cleanup(*self._threads)
+ smtplib.socket = socket
sys.stdout = self.old_stdout
def testFailingHELO(self):
@@ -293,7 +538,7 @@ class BadHELOServerTests(unittest.TestCase):
sim_users = {'Mr.A@somewhere.com':'John A',
- 'Ms.B@somewhere.com':'Sally B',
+ 'Ms.B@xn--fo-fka.com':'Sally B',
'Mrs.C@somewhereesle.com':'Ruth C',
}
@@ -309,7 +554,7 @@ sim_auth_credentials = {
sim_auth_login_password = 'C29TZXBHC3N3B3JK'
sim_lists = {'list-1':['Mr.A@somewhere.com','Mrs.C@somewhereesle.com'],
- 'list-2':['Ms.B@somewhere.com',],
+ 'list-2':['Ms.B@xn--fo-fka.com',],
}
# Simulated SMTP channel & server
@@ -318,7 +563,7 @@ class SimSMTPChannel(smtpd.SMTPChannel):
def __init__(self, extra_features, *args, **kw):
self._extrafeatures = ''.join(
[ "250-{0}\r\n".format(x) for x in extra_features ])
- smtpd.SMTPChannel.__init__(self, *args, **kw)
+ super(SimSMTPChannel, self).__init__(*args, **kw)
def smtp_EHLO(self, arg):
resp = ('250-testhost\r\n'
@@ -351,7 +596,7 @@ class SimSMTPChannel(smtpd.SMTPChannel):
def smtp_AUTH(self, arg):
if arg.strip().lower()=='cram-md5':
- self.push('334 {0}'.format(sim_cram_md5_challenge))
+ self.push('334 {}'.format(sim_cram_md5_challenge))
return
mech, auth = arg.split()
mech = mech.lower()
@@ -375,8 +620,7 @@ class SimSMTPServer(smtpd.SMTPServer):
self._extra_features = []
smtpd.SMTPServer.__init__(self, *args, **kw)
- def handle_accept(self):
- conn, addr = self.accept()
+ def handle_accepted(self, conn, addr):
self._SMTPchannel = SimSMTPChannel(self._extra_features,
self, conn, addr)
@@ -396,7 +640,8 @@ class SimSMTPServer(smtpd.SMTPServer):
class SMTPSimTests(unittest.TestCase):
def setUp(self):
- self._threads = test_support.threading_setup()
+ self.real_getfqdn = socket.getfqdn
+ socket.getfqdn = mock_socket.getfqdn
self.serv_evt = threading.Event()
self.client_evt = threading.Event()
# Pick a random unused port by passing 0 for the port number
@@ -412,12 +657,12 @@ class SMTPSimTests(unittest.TestCase):
self.serv_evt.clear()
def tearDown(self):
+ socket.getfqdn = self.real_getfqdn
# indicate that the client is finished
self.client_evt.set()
# wait for the server thread to terminate
self.serv_evt.wait()
self.thread.join()
- test_support.threading_cleanup(*self._threads)
def testBasic(self):
# smoke test
@@ -449,11 +694,13 @@ class SMTPSimTests(unittest.TestCase):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
for email, name in sim_users.items():
- expected_known = (250, '%s %s' % (name, smtplib.quoteaddr(email)))
+ expected_known = (250, bytes('%s %s' %
+ (name, smtplib.quoteaddr(email)),
+ "ascii"))
self.assertEqual(smtp.vrfy(email), expected_known)
u = 'nobody@nowhere.com'
- expected_unknown = (550, 'No such user: %s' % u)
+ expected_unknown = (550, ('No such user: %s' % u).encode('ascii'))
self.assertEqual(smtp.vrfy(u), expected_unknown)
smtp.quit()
@@ -464,11 +711,11 @@ class SMTPSimTests(unittest.TestCase):
users = []
for m in members:
users.append('%s %s' % (sim_users[m], smtplib.quoteaddr(m)))
- expected_known = (250, '\n'.join(users))
+ expected_known = (250, bytes('\n'.join(users), "ascii"))
self.assertEqual(smtp.expn(listname), expected_known)
u = 'PSU-Members-List'
- expected_unknown = (550, 'No access for you!')
+ expected_unknown = (550, b'No access for you!')
self.assertEqual(smtp.expn(u), expected_unknown)
smtp.quit()
@@ -478,6 +725,7 @@ class SMTPSimTests(unittest.TestCase):
expected_auth_ok = (235, b'plain auth ok')
self.assertEqual(smtp.login(sim_auth[0], sim_auth[1]), expected_auth_ok)
+ smtp.close()
# SimSMTPChannel doesn't fully support LOGIN or CRAM-MD5 auth because they
# require a synchronous read to obtain the credentials...so instead smtpd
@@ -492,8 +740,8 @@ class SMTPSimTests(unittest.TestCase):
smtp = smtplib.SMTP(HOST, self.port, local_hostname='localhost', timeout=15)
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
- if sim_auth_login_password not in str(err):
- raise "expected encoded password not found in error message"
+ self.assertIn(sim_auth_login_password, str(err))
+ smtp.close()
def testAUTH_CRAM_MD5(self):
self.serv.add_feature("AUTH CRAM-MD5")
@@ -501,15 +749,16 @@ class SMTPSimTests(unittest.TestCase):
try: smtp.login(sim_auth[0], sim_auth[1])
except smtplib.SMTPAuthenticationError as err:
- if sim_auth_credentials['cram-md5'] not in str(err):
- raise "expected encoded credentials not found in error message"
+ self.assertIn(sim_auth_credentials['cram-md5'], str(err))
+ smtp.close()
#TODO: add tests for correct AUTH method fallback now that the
#test infrastructure can support it.
+@support.reap_threads
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests, DebuggingServerTests,
+ support.run_unittest(GeneralTests, DebuggingServerTests,
NonConnectingTests,
BadHELOServerTests, SMTPSimTests)
diff --git a/Lib/test/test_smtpnet.py b/Lib/test/test_smtpnet.py
index 2dc39eb8f70..0198ab669e0 100644
--- a/Lib/test/test_smtpnet.py
+++ b/Lib/test/test_smtpnet.py
@@ -1,31 +1,31 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
-from test import test_support
+from test import support
import smtplib
-test_support.requires("network")
+support.requires("network")
class SmtpSSLTest(unittest.TestCase):
testServer = 'smtp.gmail.com'
remotePort = 465
def test_connect(self):
- test_support.get_attribute(smtplib, 'SMTP_SSL')
- with test_support.transient_internet(self.testServer):
+ support.get_attribute(smtplib, 'SMTP_SSL')
+ with support.transient_internet(self.testServer):
server = smtplib.SMTP_SSL(self.testServer, self.remotePort)
server.ehlo()
server.quit()
def test_connect_default_port(self):
- test_support.get_attribute(smtplib, 'SMTP_SSL')
- with test_support.transient_internet(self.testServer):
+ support.get_attribute(smtplib, 'SMTP_SSL')
+ with support.transient_internet(self.testServer):
server = smtplib.SMTP_SSL(self.testServer)
server.ehlo()
server.quit()
def test_main():
- test_support.run_unittest(SmtpSSLTest)
+ support.run_unittest(SmtpSSLTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sndhdr.py b/Lib/test/test_sndhdr.py
new file mode 100644
index 00000000000..10046887d70
--- /dev/null
+++ b/Lib/test/test_sndhdr.py
@@ -0,0 +1,23 @@
+import sndhdr
+import unittest
+from test.support import findfile
+
+class TestFormats(unittest.TestCase):
+ def test_data(self):
+ for filename, expected in (
+ ('sndhdr.8svx', ('8svx', 0, 1, 0, 8)),
+ ('sndhdr.aifc', ('aifc', 44100, 2, 5, 16)),
+ ('sndhdr.aiff', ('aiff', 44100, 2, 5, 16)),
+ ('sndhdr.au', ('au', 44100, 2, 5.0, 16)),
+ ('sndhdr.hcom', ('hcom', 22050.0, 1, -1, 8)),
+ ('sndhdr.sndt', ('sndt', 44100, 1, 5, 8)),
+ ('sndhdr.voc', ('voc', 0, 1, -1, 8)),
+ ('sndhdr.wav', ('wav', 44100, 2, -1, 16)),
+ ):
+ filename = findfile(filename, subdir="sndhdrdata")
+ what = sndhdr.what(filename)
+ self.assertNotEqual(what, None, filename)
+ self.assertSequenceEqual(what, expected)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index fec62efe038..e40b21e83cb 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -1,21 +1,27 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
-from test import test_support
+from test import support
import errno
+import io
import socket
import select
import time
import traceback
-import Queue
+import queue
import sys
import os
import array
+import platform
import contextlib
from weakref import proxy
import signal
import math
+try:
+ import fcntl
+except ImportError:
+ fcntl = False
def try_address(host, port=0, family=socket.AF_INET):
"""Try to bind a socket on the given host:port and return True
@@ -29,25 +35,30 @@ def try_address(host, port=0, family=socket.AF_INET):
sock.close()
return True
-HOST = test_support.HOST
-MSG = b'Michael Gilfix was here\n'
+def linux_version():
+ try:
+ # platform.release() is something like '2.6.33.7-desktop-2mnb'
+ version_string = platform.release().split('-')[0]
+ return tuple(map(int, version_string.split('.')))
+ except ValueError:
+ return 0, 0, 0
+
+HOST = support.HOST
+MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf8') ## test unicode string and carriage return
SUPPORTS_IPV6 = socket.has_ipv6 and try_address('::1', family=socket.AF_INET6)
try:
- import thread
+ import _thread as thread
import threading
except ImportError:
thread = None
threading = None
-HOST = test_support.HOST
-MSG = 'Michael Gilfix was here\n'
-
class SocketTCPTest(unittest.TestCase):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.serv)
+ self.port = support.bind_port(self.serv)
self.serv.listen(1)
def tearDown(self):
@@ -58,7 +69,7 @@ class SocketUDPTest(unittest.TestCase):
def setUp(self):
self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- self.port = test_support.bind_port(self.serv)
+ self.port = support.bind_port(self.serv)
def tearDown(self):
self.serv.close()
@@ -120,7 +131,7 @@ class ThreadableTest:
self.server_ready = threading.Event()
self.client_ready = threading.Event()
self.done = threading.Event()
- self.queue = Queue.Queue(1)
+ self.queue = queue.Queue(1)
# Do some munging to start the client test.
methodname = self.id()
@@ -139,21 +150,22 @@ class ThreadableTest:
self.__tearDown()
self.done.wait()
- if not self.queue.empty():
- msg = self.queue.get()
- self.fail(msg)
+ if self.queue.qsize():
+ exc = self.queue.get()
+ raise exc
def clientRun(self, test_func):
self.server_ready.wait()
self.clientSetUp()
self.client_ready.set()
- if not callable(test_func):
- raise TypeError("test_func must be a callable function.")
+ if not hasattr(test_func, '__call__'):
+ raise TypeError("test_func must be a callable function")
try:
test_func()
- except Exception, strerror:
- self.queue.put(strerror)
- self.clientTearDown()
+ except BaseException as e:
+ self.queue.put(e)
+ finally:
+ self.clientTearDown()
def clientSetUp(self):
raise NotImplementedError("clientSetUp must be implemented.")
@@ -191,6 +203,11 @@ class ThreadedUDPSocketTest(SocketUDPTest, ThreadableTest):
ThreadableTest.clientTearDown(self)
class SocketConnectedTest(ThreadedTCPSocketTest):
+ """Socket tests for client-server connection.
+
+ self.cli_conn is a client socket connected to the server. The
+ setUp() method guarantees that it is connected to the server.
+ """
def __init__(self, methodName='runTest'):
ThreadedTCPSocketTest.__init__(self, methodName=methodName)
@@ -245,6 +262,11 @@ class SocketPairTest(unittest.TestCase, ThreadableTest):
class GeneralModuleTests(unittest.TestCase):
+ def test_repr(self):
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.addCleanup(s.close)
+ self.assertTrue(repr(s).startswith("<socket.socket object"))
+
def test_weakref(self):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
p = proxy(s)
@@ -280,38 +302,43 @@ class GeneralModuleTests(unittest.TestCase):
s.bind(('', 0))
sockname = s.getsockname()
# 2 args
- with self.assertRaises(UnicodeEncodeError):
- s.sendto(u'\u2620', sockname)
+ with self.assertRaises(TypeError) as cm:
+ s.sendto('\u2620', sockname)
+ self.assertEqual(str(cm.exception),
+ "'str' does not support the buffer interface")
with self.assertRaises(TypeError) as cm:
s.sendto(5j, sockname)
- self.assertIn('not complex', str(cm.exception))
+ self.assertEqual(str(cm.exception),
+ "'complex' does not support the buffer interface")
with self.assertRaises(TypeError) as cm:
- s.sendto('foo', None)
- self.assertIn('not NoneType', str(cm.exception))
+ s.sendto(b'foo', None)
+ self.assertIn('not NoneType',str(cm.exception))
# 3 args
- with self.assertRaises(UnicodeEncodeError):
- s.sendto(u'\u2620', 0, sockname)
+ with self.assertRaises(TypeError) as cm:
+ s.sendto('\u2620', 0, sockname)
+ self.assertEqual(str(cm.exception),
+ "'str' does not support the buffer interface")
with self.assertRaises(TypeError) as cm:
s.sendto(5j, 0, sockname)
- self.assertIn('not complex', str(cm.exception))
+ self.assertEqual(str(cm.exception),
+ "'complex' does not support the buffer interface")
with self.assertRaises(TypeError) as cm:
- s.sendto('foo', 0, None)
+ s.sendto(b'foo', 0, None)
self.assertIn('not NoneType', str(cm.exception))
with self.assertRaises(TypeError) as cm:
- s.sendto('foo', 'bar', sockname)
+ s.sendto(b'foo', 'bar', sockname)
self.assertIn('an integer is required', str(cm.exception))
with self.assertRaises(TypeError) as cm:
- s.sendto('foo', None, None)
+ s.sendto(b'foo', None, None)
self.assertIn('an integer is required', str(cm.exception))
# wrong number of args
with self.assertRaises(TypeError) as cm:
- s.sendto('foo')
+ s.sendto(b'foo')
self.assertIn('(1 given)', str(cm.exception))
with self.assertRaises(TypeError) as cm:
- s.sendto('foo', 0, sockname, 4)
+ s.sendto(b'foo', 0, sockname, 4)
self.assertIn('(4 given)', str(cm.exception))
-
def testCrucialConstants(self):
# Testing for mission critical constants
socket.AF_INET
@@ -350,8 +377,8 @@ class GeneralModuleTests(unittest.TestCase):
orig = sys.getrefcount(__name__)
socket.getnameinfo(__name__,0)
except TypeError:
- self.assertEqual(sys.getrefcount(__name__), orig,
- "socket.getnameinfo loses a reference")
+ if sys.getrefcount(__name__) != orig:
+ self.fail("socket.getnameinfo loses a reference")
def testInterpreterCrash(self):
# Making sure getnameinfo doesn't crash the interpreter
@@ -367,17 +394,17 @@ class GeneralModuleTests(unittest.TestCase):
sizes = {socket.htonl: 32, socket.ntohl: 32,
socket.htons: 16, socket.ntohs: 16}
for func, size in sizes.items():
- mask = (1L<<size) - 1
+ mask = (1<<size) - 1
for i in (0, 1, 0xffff, ~0xffff, 2, 0x01234567, 0x76543210):
self.assertEqual(i & mask, func(func(i&mask)) & mask)
swapped = func(mask)
self.assertEqual(swapped & mask, mask)
- self.assertRaises(OverflowError, func, 1L<<34)
+ self.assertRaises(OverflowError, func, 1<<34)
def testNtoHErrors(self):
- good_values = [ 1, 2, 3, 1L, 2L, 3L ]
- bad_values = [ -1, -2, -3, -1L, -2L, -3L ]
+ good_values = [ 1, 2, 3, 1, 2, 3 ]
+ bad_values = [ -1, -2, -3, -1, -2, -3 ]
for k in good_values:
socket.ntohl(k)
socket.ntohs(k)
@@ -463,8 +490,8 @@ class GeneralModuleTests(unittest.TestCase):
return # No inet_aton, nothing to check
# Test that issue1008086 and issue767150 are fixed.
# It must return 4 bytes.
- self.assertEqual('\x00'*4, socket.inet_aton('0.0.0.0'))
- self.assertEqual('\xff'*4, socket.inet_aton('255.255.255.255'))
+ self.assertEqual(b'\x00'*4, socket.inet_aton('0.0.0.0'))
+ self.assertEqual(b'\xff'*4, socket.inet_aton('255.255.255.255'))
def testIPv4toString(self):
if not hasattr(socket, 'inet_pton'):
@@ -472,16 +499,30 @@ class GeneralModuleTests(unittest.TestCase):
from socket import inet_aton as f, inet_pton, AF_INET
g = lambda a: inet_pton(AF_INET, a)
- self.assertEqual('\x00\x00\x00\x00', f('0.0.0.0'))
- self.assertEqual('\xff\x00\xff\x00', f('255.0.255.0'))
- self.assertEqual('\xaa\xaa\xaa\xaa', f('170.170.170.170'))
- self.assertEqual('\x01\x02\x03\x04', f('1.2.3.4'))
- self.assertEqual('\xff\xff\xff\xff', f('255.255.255.255'))
+ assertInvalid = lambda func,a: self.assertRaises(
+ (socket.error, ValueError), func, a
+ )
- self.assertEqual('\x00\x00\x00\x00', g('0.0.0.0'))
- self.assertEqual('\xff\x00\xff\x00', g('255.0.255.0'))
- self.assertEqual('\xaa\xaa\xaa\xaa', g('170.170.170.170'))
- self.assertEqual('\xff\xff\xff\xff', g('255.255.255.255'))
+ self.assertEqual(b'\x00\x00\x00\x00', f('0.0.0.0'))
+ self.assertEqual(b'\xff\x00\xff\x00', f('255.0.255.0'))
+ self.assertEqual(b'\xaa\xaa\xaa\xaa', f('170.170.170.170'))
+ self.assertEqual(b'\x01\x02\x03\x04', f('1.2.3.4'))
+ self.assertEqual(b'\xff\xff\xff\xff', f('255.255.255.255'))
+ assertInvalid(f, '0.0.0.')
+ assertInvalid(f, '300.0.0.0')
+ assertInvalid(f, 'a.0.0.0')
+ assertInvalid(f, '1.2.3.4.5')
+ assertInvalid(f, '::1')
+
+ self.assertEqual(b'\x00\x00\x00\x00', g('0.0.0.0'))
+ self.assertEqual(b'\xff\x00\xff\x00', g('255.0.255.0'))
+ self.assertEqual(b'\xaa\xaa\xaa\xaa', g('170.170.170.170'))
+ self.assertEqual(b'\xff\xff\xff\xff', g('255.255.255.255'))
+ assertInvalid(g, '0.0.0.')
+ assertInvalid(g, '300.0.0.0')
+ assertInvalid(g, 'a.0.0.0')
+ assertInvalid(g, '1.2.3.4.5')
+ assertInvalid(g, '::1')
def testIPv6toString(self):
if not hasattr(socket, 'inet_pton'):
@@ -493,29 +534,73 @@ class GeneralModuleTests(unittest.TestCase):
except ImportError:
return
f = lambda a: inet_pton(AF_INET6, a)
+ assertInvalid = lambda a: self.assertRaises(
+ (socket.error, ValueError), f, a
+ )
- self.assertEqual('\x00' * 16, f('::'))
- self.assertEqual('\x00' * 16, f('0::0'))
- self.assertEqual('\x00\x01' + '\x00' * 14, f('1::'))
+ self.assertEqual(b'\x00' * 16, f('::'))
+ self.assertEqual(b'\x00' * 16, f('0::0'))
+ self.assertEqual(b'\x00\x01' + b'\x00' * 14, f('1::'))
self.assertEqual(
- '\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae',
+ b'\x45\xef\x76\xcb\x00\x1a\x56\xef\xaf\xeb\x0b\xac\x19\x24\xae\xae',
f('45ef:76cb:1a:56ef:afeb:bac:1924:aeae')
)
+ self.assertEqual(
+ b'\xad\x42\x0a\xbc' + b'\x00' * 4 + b'\x01\x27\x00\x00\x02\x54\x00\x02',
+ f('ad42:abc::127:0:254:2')
+ )
+ self.assertEqual(b'\x00\x12\x00\x0a' + b'\x00' * 12, f('12:a::'))
+ assertInvalid('0x20::')
+ assertInvalid(':::')
+ assertInvalid('::0::')
+ assertInvalid('1::abc::')
+ assertInvalid('1::abc::def')
+ assertInvalid('1:2:3:4:5:6:')
+ assertInvalid('1:2:3:4:5:6')
+ assertInvalid('1:2:3:4:5:6:7:8:')
+ assertInvalid('1:2:3:4:5:6:7:8:0')
+
+ self.assertEqual(b'\x00' * 12 + b'\xfe\x2a\x17\x40',
+ f('::254.42.23.64')
+ )
+ self.assertEqual(
+ b'\x00\x42' + b'\x00' * 8 + b'\xa2\x9b\xfe\x2a\x17\x40',
+ f('42::a29b:254.42.23.64')
+ )
+ self.assertEqual(
+ b'\x00\x42\xa8\xb9\x00\x00\x00\x02\xff\xff\xa2\x9b\xfe\x2a\x17\x40',
+ f('42:a8b9:0:2:ffff:a29b:254.42.23.64')
+ )
+ assertInvalid('255.254.253.252')
+ assertInvalid('1::260.2.3.0')
+ assertInvalid('1::0.be.e.0')
+ assertInvalid('1:2:3:4:5:6:7:1.2.3.4')
+ assertInvalid('::1.2.3.4:0')
+ assertInvalid('0.100.200.0:3:4:5:6:7:8')
def testStringToIPv4(self):
if not hasattr(socket, 'inet_ntop'):
return # No inet_ntop() on this platform
from socket import inet_ntoa as f, inet_ntop, AF_INET
g = lambda a: inet_ntop(AF_INET, a)
+ assertInvalid = lambda func,a: self.assertRaises(
+ (socket.error, ValueError), func, a
+ )
- self.assertEqual('1.0.1.0', f('\x01\x00\x01\x00'))
- self.assertEqual('170.85.170.85', f('\xaa\x55\xaa\x55'))
- self.assertEqual('255.255.255.255', f('\xff\xff\xff\xff'))
- self.assertEqual('1.2.3.4', f('\x01\x02\x03\x04'))
-
- self.assertEqual('1.0.1.0', g('\x01\x00\x01\x00'))
- self.assertEqual('170.85.170.85', g('\xaa\x55\xaa\x55'))
- self.assertEqual('255.255.255.255', g('\xff\xff\xff\xff'))
+ self.assertEqual('1.0.1.0', f(b'\x01\x00\x01\x00'))
+ self.assertEqual('170.85.170.85', f(b'\xaa\x55\xaa\x55'))
+ self.assertEqual('255.255.255.255', f(b'\xff\xff\xff\xff'))
+ self.assertEqual('1.2.3.4', f(b'\x01\x02\x03\x04'))
+ assertInvalid(f, b'\x00' * 3)
+ assertInvalid(f, b'\x00' * 5)
+ assertInvalid(f, b'\x00' * 16)
+
+ self.assertEqual('1.0.1.0', g(b'\x01\x00\x01\x00'))
+ self.assertEqual('170.85.170.85', g(b'\xaa\x55\xaa\x55'))
+ self.assertEqual('255.255.255.255', g(b'\xff\xff\xff\xff'))
+ assertInvalid(g, b'\x00' * 3)
+ assertInvalid(g, b'\x00' * 5)
+ assertInvalid(g, b'\x00' * 16)
def testStringToIPv6(self):
if not hasattr(socket, 'inet_ntop'):
@@ -527,33 +612,26 @@ class GeneralModuleTests(unittest.TestCase):
except ImportError:
return
f = lambda a: inet_ntop(AF_INET6, a)
+ assertInvalid = lambda a: self.assertRaises(
+ (socket.error, ValueError), f, a
+ )
- self.assertEqual('::', f('\x00' * 16))
- self.assertEqual('::1', f('\x00' * 15 + '\x01'))
+ self.assertEqual('::', f(b'\x00' * 16))
+ self.assertEqual('::1', f(b'\x00' * 15 + b'\x01'))
self.assertEqual(
'aef:b01:506:1001:ffff:9997:55:170',
- f('\x0a\xef\x0b\x01\x05\x06\x10\x01\xff\xff\x99\x97\x00\x55\x01\x70')
+ f(b'\x0a\xef\x0b\x01\x05\x06\x10\x01\xff\xff\x99\x97\x00\x55\x01\x70')
)
- # XXX The following don't test module-level functionality...
-
- def _get_unused_port(self, bind_address='0.0.0.0'):
- """Use a temporary socket to elicit an unused ephemeral port.
+ assertInvalid(b'\x12' * 15)
+ assertInvalid(b'\x12' * 17)
+ assertInvalid(b'\x12' * 4)
- Args:
- bind_address: Hostname or IP address to search for a port on.
-
- Returns: A most likely to be unused port.
- """
- tempsock = socket.socket()
- tempsock.bind((bind_address, 0))
- host, port = tempsock.getsockname()
- tempsock.close()
- return port
+ # XXX The following don't test module-level functionality...
def testSockName(self):
# Testing getsockname()
- port = self._get_unused_port()
+ port = support.find_unused_port()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.addCleanup(sock.close)
sock.bind(("0.0.0.0", port))
@@ -590,7 +668,7 @@ class GeneralModuleTests(unittest.TestCase):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
sock.close()
- self.assertRaises(socket.error, sock.send, "spam")
+ self.assertRaises(socket.error, sock.send, b"spam")
def testNewAttributes(self):
# testing .family, .type and .protocol
@@ -602,7 +680,7 @@ class GeneralModuleTests(unittest.TestCase):
def test_getsockaddrarg(self):
host = '0.0.0.0'
- port = self._get_unused_port(bind_address=host)
+ port = support.find_unused_port()
big_port = port + 65536
neg_port = port - 65536
sock = socket.socket()
@@ -644,10 +722,9 @@ class GeneralModuleTests(unittest.TestCase):
if SUPPORTS_IPV6:
socket.getaddrinfo('::1', 80)
# port can be a string service name such as "http", a numeric
- # port number (int or long), or None
+ # port number or None
socket.getaddrinfo(HOST, "http")
socket.getaddrinfo(HOST, 80)
- socket.getaddrinfo(HOST, 80L)
socket.getaddrinfo(HOST, None)
# test family and socktype filters
infos = socket.getaddrinfo(HOST, None, socket.AF_INET)
@@ -663,7 +740,46 @@ class GeneralModuleTests(unittest.TestCase):
# usually do this
socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0,
socket.AI_PASSIVE)
-
+ # test keyword arguments
+ a = socket.getaddrinfo(HOST, None)
+ b = socket.getaddrinfo(host=HOST, port=None)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, socket.AF_INET)
+ b = socket.getaddrinfo(HOST, None, family=socket.AF_INET)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, socket.SOCK_STREAM)
+ b = socket.getaddrinfo(HOST, None, type=socket.SOCK_STREAM)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, 0, socket.SOL_TCP)
+ b = socket.getaddrinfo(HOST, None, proto=socket.SOL_TCP)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(HOST, None, 0, 0, 0, socket.AI_PASSIVE)
+ b = socket.getaddrinfo(HOST, None, flags=socket.AI_PASSIVE)
+ self.assertEqual(a, b)
+ a = socket.getaddrinfo(None, 0, socket.AF_UNSPEC, socket.SOCK_STREAM, 0,
+ socket.AI_PASSIVE)
+ b = socket.getaddrinfo(host=None, port=0, family=socket.AF_UNSPEC,
+ type=socket.SOCK_STREAM, proto=0,
+ flags=socket.AI_PASSIVE)
+ self.assertEqual(a, b)
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
+
+ def test_getnameinfo(self):
+ # only IP addresses are allowed
+ self.assertRaises(socket.error, socket.getnameinfo, ('mail.python.org',0), 0)
+
+ @unittest.skipUnless(support.is_resource_enabled('network'),
+ 'network is not enabled')
+ def test_idna(self):
+ support.requires('network')
+ # these should all be successful
+ socket.gethostbyname('иÑпытание.python.org')
+ socket.gethostbyname_ex('иÑпытание.python.org')
+ socket.getaddrinfo('иÑпытание.python.org',0,socket.AF_UNSPEC,socket.SOCK_STREAM)
+ # this may not work if the forward lookup choses the IPv6 address, as that doesn't
+ # have a reverse entry yet
+ # socket.gethostbyaddr('иÑпытание.python.org')
def check_sendall_interrupted(self, with_timeout):
# socketpair() is not stricly required, but it makes things easier.
@@ -700,6 +816,40 @@ class GeneralModuleTests(unittest.TestCase):
def test_sendall_interrupted_with_timeout(self):
self.check_sendall_interrupted(True)
+ def test_dealloc_warn(self):
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ r = repr(sock)
+ with self.assertWarns(ResourceWarning) as cm:
+ sock = None
+ support.gc_collect()
+ self.assertIn(r, str(cm.warning.args[0]))
+ # An open socket file object gets dereferenced after the socket
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ f = sock.makefile('rb')
+ r = repr(sock)
+ sock = None
+ support.gc_collect()
+ with self.assertWarns(ResourceWarning):
+ f = None
+ support.gc_collect()
+
+ def test_name_closed_socketio(self):
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
+ fp = sock.makefile("rb")
+ fp.close()
+ self.assertEqual(repr(fp), "<_io.BufferedReader name=-1>")
+
+ def test_unusable_closed_socketio(self):
+ with socket.socket() as sock:
+ fp = sock.makefile("rb", buffering=0)
+ self.assertTrue(fp.readable())
+ self.assertFalse(fp.writable())
+ self.assertFalse(fp.seekable())
+ fp.close()
+ self.assertRaises(ValueError, fp.readable)
+ self.assertRaises(ValueError, fp.writable)
+ self.assertRaises(ValueError, fp.seekable)
+
def testListenBacklog0(self):
srv = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
srv.bind((HOST, 0))
@@ -711,11 +861,8 @@ class GeneralModuleTests(unittest.TestCase):
def test_flowinfo(self):
self.assertRaises(OverflowError, socket.getnameinfo,
('::1',0, 0xffffffff), 0)
- s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
- try:
+ with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as s:
self.assertRaises(OverflowError, s.bind, ('::1', 0, -10))
- finally:
- s.close()
@unittest.skipUnless(thread, 'Threading required for this test.')
@@ -762,25 +909,24 @@ class BasicTCPTest(SocketConnectedTest):
def testSendAll(self):
# Testing sendall() with a 2048 byte string over TCP
- msg = ''
+ msg = b''
while 1:
read = self.cli_conn.recv(1024)
if not read:
break
msg += read
- self.assertEqual(msg, 'f' * 2048)
+ self.assertEqual(msg, b'f' * 2048)
def _testSendAll(self):
- big_chunk = 'f' * 2048
+ big_chunk = b'f' * 2048
self.serv_conn.sendall(big_chunk)
def testFromFd(self):
# Testing fromfd()
- if not hasattr(socket, "fromfd"):
- return # On Windows, this doesn't exist
fd = self.cli_conn.fileno()
sock = socket.fromfd(fd, socket.AF_INET, socket.SOCK_STREAM)
self.addCleanup(sock.close)
+ self.assertIsInstance(sock, socket.socket)
msg = sock.recv(1024)
self.assertEqual(msg, MSG)
@@ -810,6 +956,25 @@ class BasicTCPTest(SocketConnectedTest):
self.serv_conn.send(MSG)
self.serv_conn.shutdown(2)
+ def testDetach(self):
+ # Testing detach()
+ fileno = self.cli_conn.fileno()
+ f = self.cli_conn.detach()
+ self.assertEqual(f, fileno)
+ # cli_conn cannot be used anymore...
+ self.assertTrue(self.cli_conn._closed)
+ self.assertRaises(socket.error, self.cli_conn.recv, 1024)
+ self.cli_conn.close()
+ # ...but we can create another socket using the (still open)
+ # file descriptor
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, fileno=f)
+ self.addCleanup(sock.close)
+ msg = sock.recv(1024)
+ self.assertEqual(msg, MSG)
+
+ def _testDetach(self):
+ self.serv_conn.send(MSG)
+
@unittest.skipUnless(thread, 'Threading required for this test.')
class BasicUDPTest(ThreadedUDPSocketTest):
@@ -849,7 +1014,11 @@ class TCPCloserTest(ThreadedTCPSocketTest):
sd = self.cli
read, write, err = select.select([sd], [], [], 1.0)
self.assertEqual(read, [sd])
- self.assertEqual(sd.recv(1), '')
+ self.assertEqual(sd.recv(1), b'')
+
+ # Calling close() many times should be safe.
+ conn.close()
+ conn.close()
def _testClose(self):
self.cli.connect((HOST, self.port))
@@ -861,6 +1030,21 @@ class BasicSocketPairTest(SocketPairTest):
def __init__(self, methodName='runTest'):
SocketPairTest.__init__(self, methodName=methodName)
+ def _check_defaults(self, sock):
+ self.assertIsInstance(sock, socket.socket)
+ if hasattr(socket, 'AF_UNIX'):
+ self.assertEqual(sock.family, socket.AF_UNIX)
+ else:
+ self.assertEqual(sock.family, socket.AF_INET)
+ self.assertEqual(sock.type, socket.SOCK_STREAM)
+ self.assertEqual(sock.proto, 0)
+
+ def _testDefaults(self):
+ self._check_defaults(self.cli)
+
+ def testDefaults(self):
+ self._check_defaults(self.serv)
+
def testRecv(self):
msg = self.serv.recv(1024)
self.assertEqual(msg, MSG)
@@ -895,6 +1079,47 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
def _testSetBlocking(self):
pass
+ if hasattr(socket, "SOCK_NONBLOCK"):
+ def testInitNonBlocking(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ # reinit server socket
+ self.serv.close()
+ self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM |
+ socket.SOCK_NONBLOCK)
+ self.port = support.bind_port(self.serv)
+ self.serv.listen(1)
+ # actual testing
+ start = time.time()
+ try:
+ self.serv.accept()
+ except socket.error:
+ pass
+ end = time.time()
+ self.assertTrue((end - start) < 1.0, "Error creating with non-blocking mode.")
+
+ def _testInitNonBlocking(self):
+ pass
+
+ def testInheritFlags(self):
+ # Issue #7995: when calling accept() on a listening socket with a
+ # timeout, the resulting socket should not be non-blocking.
+ self.serv.settimeout(10)
+ try:
+ conn, addr = self.serv.accept()
+ message = conn.recv(len(MSG))
+ finally:
+ conn.close()
+ self.serv.settimeout(None)
+
+ def _testInheritFlags(self):
+ time.sleep(0.1)
+ self.cli.connect((HOST, self.port))
+ time.sleep(0.5)
+ self.cli.send(MSG)
+
def testAccept(self):
# Testing non-blocking accept
self.serv.setblocking(0)
@@ -949,107 +1174,166 @@ class NonBlockingTCPTests(ThreadedTCPSocketTest):
@unittest.skipUnless(thread, 'Threading required for this test.')
class FileObjectClassTestCase(SocketConnectedTest):
+ """Unit tests for the object returned by socket.makefile()
+
+ self.read_file is the io object returned by makefile() on
+ the client connection. You can read from this file to
+ get output from the server.
+
+ self.write_file is the io object returned by makefile() on the
+ server connection. You can write to this file to send output
+ to the client.
+ """
bufsize = -1 # Use default buffer size
+ encoding = 'utf8'
+ errors = 'strict'
+ newline = None
+
+ read_mode = 'rb'
+ read_msg = MSG
+ write_mode = 'wb'
+ write_msg = MSG
def __init__(self, methodName='runTest'):
SocketConnectedTest.__init__(self, methodName=methodName)
def setUp(self):
+ self.evt1, self.evt2, self.serv_finished, self.cli_finished = [
+ threading.Event() for i in range(4)]
SocketConnectedTest.setUp(self)
- self.serv_file = self.cli_conn.makefile('rb', self.bufsize)
+ self.read_file = self.cli_conn.makefile(
+ self.read_mode, self.bufsize,
+ encoding = self.encoding,
+ errors = self.errors,
+ newline = self.newline)
def tearDown(self):
- self.serv_file.close()
- self.assertTrue(self.serv_file.closed)
+ self.serv_finished.set()
+ self.read_file.close()
+ self.assertTrue(self.read_file.closed)
+ self.read_file = None
SocketConnectedTest.tearDown(self)
- self.serv_file = None
def clientSetUp(self):
SocketConnectedTest.clientSetUp(self)
- self.cli_file = self.serv_conn.makefile('wb')
+ self.write_file = self.serv_conn.makefile(
+ self.write_mode, self.bufsize,
+ encoding = self.encoding,
+ errors = self.errors,
+ newline = self.newline)
def clientTearDown(self):
- self.cli_file.close()
- self.assertTrue(self.cli_file.closed)
- self.cli_file = None
+ self.cli_finished.set()
+ self.write_file.close()
+ self.assertTrue(self.write_file.closed)
+ self.write_file = None
SocketConnectedTest.clientTearDown(self)
+ def testReadAfterTimeout(self):
+ # Issue #7322: A file object must disallow further reads
+ # after a timeout has occurred.
+ self.cli_conn.settimeout(1)
+ self.read_file.read(3)
+ # First read raises a timeout
+ self.assertRaises(socket.timeout, self.read_file.read, 1)
+ # Second read is disallowed
+ with self.assertRaises(IOError) as ctx:
+ self.read_file.read(1)
+ self.assertIn("cannot read from timed out object", str(ctx.exception))
+
+ def _testReadAfterTimeout(self):
+ self.write_file.write(self.write_msg[0:3])
+ self.write_file.flush()
+ self.serv_finished.wait()
+
def testSmallRead(self):
# Performing small file read test
- first_seg = self.serv_file.read(len(MSG)-3)
- second_seg = self.serv_file.read(3)
+ first_seg = self.read_file.read(len(self.read_msg)-3)
+ second_seg = self.read_file.read(3)
msg = first_seg + second_seg
- self.assertEqual(msg, MSG)
+ self.assertEqual(msg, self.read_msg)
def _testSmallRead(self):
- self.cli_file.write(MSG)
- self.cli_file.flush()
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
def testFullRead(self):
# read until EOF
- msg = self.serv_file.read()
- self.assertEqual(msg, MSG)
+ msg = self.read_file.read()
+ self.assertEqual(msg, self.read_msg)
def _testFullRead(self):
- self.cli_file.write(MSG)
- self.cli_file.close()
+ self.write_file.write(self.write_msg)
+ self.write_file.close()
def testUnbufferedRead(self):
# Performing unbuffered file read test
- buf = ''
+ buf = type(self.read_msg)()
while 1:
- char = self.serv_file.read(1)
+ char = self.read_file.read(1)
if not char:
break
buf += char
- self.assertEqual(buf, MSG)
+ self.assertEqual(buf, self.read_msg)
def _testUnbufferedRead(self):
- self.cli_file.write(MSG)
- self.cli_file.flush()
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
def testReadline(self):
# Performing file readline test
- line = self.serv_file.readline()
- self.assertEqual(line, MSG)
+ line = self.read_file.readline()
+ self.assertEqual(line, self.read_msg)
def _testReadline(self):
- self.cli_file.write(MSG)
- self.cli_file.flush()
-
- def testReadlineAfterRead(self):
- a_baloo_is = self.serv_file.read(len("A baloo is"))
- self.assertEqual("A baloo is", a_baloo_is)
- _a_bear = self.serv_file.read(len(" a bear"))
- self.assertEqual(" a bear", _a_bear)
- line = self.serv_file.readline()
- self.assertEqual("\n", line)
- line = self.serv_file.readline()
- self.assertEqual("A BALOO IS A BEAR.\n", line)
- line = self.serv_file.readline()
- self.assertEqual(MSG, line)
-
- def _testReadlineAfterRead(self):
- self.cli_file.write("A baloo is a bear\n")
- self.cli_file.write("A BALOO IS A BEAR.\n")
- self.cli_file.write(MSG)
- self.cli_file.flush()
-
- def testReadlineAfterReadNoNewline(self):
- end_of_ = self.serv_file.read(len("End Of "))
- self.assertEqual("End Of ", end_of_)
- line = self.serv_file.readline()
- self.assertEqual("Line", line)
-
- def _testReadlineAfterReadNoNewline(self):
- self.cli_file.write("End Of Line")
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
+
+ def testCloseAfterMakefile(self):
+ # The file returned by makefile should keep the socket open.
+ self.cli_conn.close()
+ # read until EOF
+ msg = self.read_file.read()
+ self.assertEqual(msg, self.read_msg)
+
+ def _testCloseAfterMakefile(self):
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
+
+ def testMakefileAfterMakefileClose(self):
+ self.read_file.close()
+ msg = self.cli_conn.recv(len(MSG))
+ if isinstance(self.read_msg, str):
+ msg = msg.decode()
+ self.assertEqual(msg, self.read_msg)
+
+ def _testMakefileAfterMakefileClose(self):
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
def testClosedAttr(self):
- self.assertTrue(not self.serv_file.closed)
+ self.assertTrue(not self.read_file.closed)
def _testClosedAttr(self):
- self.assertTrue(not self.cli_file.closed)
+ self.assertTrue(not self.write_file.closed)
+
+ def testAttributes(self):
+ self.assertEqual(self.read_file.mode, self.read_mode)
+ self.assertEqual(self.read_file.name, self.cli_conn.fileno())
+
+ def _testAttributes(self):
+ self.assertEqual(self.write_file.mode, self.write_mode)
+ self.assertEqual(self.write_file.name, self.serv_conn.fileno())
+
+ def testRealClose(self):
+ self.read_file.close()
+ self.assertRaises(ValueError, self.read_file.fileno)
+ self.cli_conn.close()
+ self.assertRaises(socket.error, self.cli_conn.getsockname)
+
+ def _testRealClose(self):
+ pass
class FileObjectInterruptedTestCase(unittest.TestCase):
@@ -1061,34 +1345,75 @@ class FileObjectInterruptedTestCase(unittest.TestCase):
# call to recv().
self._recv_step = iter(recv_funcs)
- def recv(self, size):
- return self._recv_step.next()()
+ def recv_into(self, buffer):
+ data = next(self._recv_step)()
+ assert len(buffer) >= len(data)
+ buffer[:len(data)] = data
+ return len(data)
+
+ def _decref_socketios(self):
+ pass
+
+ def _textiowrap_for_test(self, buffering=-1):
+ raw = socket.SocketIO(self, "r")
+ if buffering < 0:
+ buffering = io.DEFAULT_BUFFER_SIZE
+ if buffering == 0:
+ return raw
+ buffer = io.BufferedReader(raw, buffering)
+ text = io.TextIOWrapper(buffer, None, None)
+ text.mode = "rb"
+ return text
@staticmethod
def _raise_eintr():
raise socket.error(errno.EINTR)
- def _test_readline(self, size=-1, **kwargs):
+ def _textiowrap_mock_socket(self, mock, buffering=-1):
+ raw = socket.SocketIO(mock, "r")
+ if buffering < 0:
+ buffering = io.DEFAULT_BUFFER_SIZE
+ if buffering == 0:
+ return raw
+ buffer = io.BufferedReader(raw, buffering)
+ text = io.TextIOWrapper(buffer, None, None)
+ text.mode = "rb"
+ return text
+
+ def _test_readline(self, size=-1, buffering=-1):
mock_sock = self.MockSocket(recv_funcs=[
- lambda : "This is the first line\nAnd the sec",
+ lambda : b"This is the first line\nAnd the sec",
self._raise_eintr,
- lambda : "ond line is here\n",
- lambda : "",
+ lambda : b"ond line is here\n",
+ lambda : b"",
+ lambda : b"", # XXX(gps): io library does an extra EOF read
])
- fo = socket._fileobject(mock_sock, **kwargs)
+ fo = mock_sock._textiowrap_for_test(buffering=buffering)
self.assertEqual(fo.readline(size), "This is the first line\n")
self.assertEqual(fo.readline(size), "And the second line is here\n")
- def _test_read(self, size=-1, **kwargs):
+ def _test_read(self, size=-1, buffering=-1):
mock_sock = self.MockSocket(recv_funcs=[
- lambda : "This is the first line\nAnd the sec",
+ lambda : b"This is the first line\nAnd the sec",
self._raise_eintr,
- lambda : "ond line is here\n",
- lambda : "",
+ lambda : b"ond line is here\n",
+ lambda : b"",
+ lambda : b"", # XXX(gps): io library does an extra EOF read
])
- fo = socket._fileobject(mock_sock, **kwargs)
- self.assertEqual(fo.read(size), "This is the first line\n"
- "And the second line is here\n")
+ expecting = (b"This is the first line\n"
+ b"And the second line is here\n")
+ fo = mock_sock._textiowrap_for_test(buffering=buffering)
+ if buffering == 0:
+ data = b''
+ else:
+ data = ''
+ expecting = expecting.decode('utf8')
+ while len(data) != len(expecting):
+ part = fo.read(size)
+ if not part:
+ break
+ data += part
+ self.assertEqual(data, expecting)
def test_default(self):
self._test_readline()
@@ -1097,29 +1422,29 @@ class FileObjectInterruptedTestCase(unittest.TestCase):
self._test_read(size=100)
def test_with_1k_buffer(self):
- self._test_readline(bufsize=1024)
- self._test_readline(size=100, bufsize=1024)
- self._test_read(bufsize=1024)
- self._test_read(size=100, bufsize=1024)
+ self._test_readline(buffering=1024)
+ self._test_readline(size=100, buffering=1024)
+ self._test_read(buffering=1024)
+ self._test_read(size=100, buffering=1024)
def _test_readline_no_buffer(self, size=-1):
mock_sock = self.MockSocket(recv_funcs=[
- lambda : "aa",
- lambda : "\n",
- lambda : "BB",
+ lambda : b"a",
+ lambda : b"\n",
+ lambda : b"B",
self._raise_eintr,
- lambda : "bb",
- lambda : "",
+ lambda : b"b",
+ lambda : b"",
])
- fo = socket._fileobject(mock_sock, bufsize=0)
- self.assertEqual(fo.readline(size), "aa\n")
- self.assertEqual(fo.readline(size), "BBbb")
+ fo = mock_sock._textiowrap_for_test(buffering=0)
+ self.assertEqual(fo.readline(size), b"a\n")
+ self.assertEqual(fo.readline(size), b"Bb")
def test_no_buffer(self):
self._test_readline_no_buffer()
self._test_readline_no_buffer(size=4)
- self._test_read(bufsize=0)
- self._test_read(size=100, bufsize=0)
+ self._test_read(buffering=0)
+ self._test_read(size=100, buffering=0)
class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
@@ -1129,94 +1454,150 @@ class UnbufferedFileObjectClassTestCase(FileObjectClassTestCase):
In this case (and in this case only), it should be possible to
create a file object, read a line from it, create another file
object, read another line from it, without loss of data in the
- first file object's buffer. Note that httplib relies on this
+ first file object's buffer. Note that http.client relies on this
when reading multiple requests from the same socket."""
bufsize = 0 # Use unbuffered mode
def testUnbufferedReadline(self):
# Read a line, create a new file object, read another line with it
- line = self.serv_file.readline() # first line
- self.assertEqual(line, "A. " + MSG) # first line
- self.serv_file = self.cli_conn.makefile('rb', 0)
- line = self.serv_file.readline() # second line
- self.assertEqual(line, "B. " + MSG) # second line
+ line = self.read_file.readline() # first line
+ self.assertEqual(line, b"A. " + self.write_msg) # first line
+ self.read_file = self.cli_conn.makefile('rb', 0)
+ line = self.read_file.readline() # second line
+ self.assertEqual(line, b"B. " + self.write_msg) # second line
def _testUnbufferedReadline(self):
- self.cli_file.write("A. " + MSG)
- self.cli_file.write("B. " + MSG)
- self.cli_file.flush()
+ self.write_file.write(b"A. " + self.write_msg)
+ self.write_file.write(b"B. " + self.write_msg)
+ self.write_file.flush()
+
+ def testMakefileClose(self):
+ # The file returned by makefile should keep the socket open...
+ self.cli_conn.close()
+ msg = self.cli_conn.recv(1024)
+ self.assertEqual(msg, self.read_msg)
+ # ...until the file is itself closed
+ self.read_file.close()
+ self.assertRaises(socket.error, self.cli_conn.recv, 1024)
+
+ def _testMakefileClose(self):
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
+
+ def testMakefileCloseSocketDestroy(self):
+ refcount_before = sys.getrefcount(self.cli_conn)
+ self.read_file.close()
+ refcount_after = sys.getrefcount(self.cli_conn)
+ self.assertEqual(refcount_before - 1, refcount_after)
+
+ def _testMakefileCloseSocketDestroy(self):
+ pass
+
+ # Non-blocking ops
+ # NOTE: to set `read_file` as non-blocking, we must call
+ # `cli_conn.setblocking` and vice-versa (see setUp / clientSetUp).
+
+ def testSmallReadNonBlocking(self):
+ self.cli_conn.setblocking(False)
+ self.assertEqual(self.read_file.readinto(bytearray(10)), None)
+ self.assertEqual(self.read_file.read(len(self.read_msg) - 3), None)
+ self.evt1.set()
+ self.evt2.wait(1.0)
+ first_seg = self.read_file.read(len(self.read_msg) - 3)
+ if first_seg is None:
+ # Data not arrived (can happen under Windows), wait a bit
+ time.sleep(0.5)
+ first_seg = self.read_file.read(len(self.read_msg) - 3)
+ buf = bytearray(10)
+ n = self.read_file.readinto(buf)
+ self.assertEqual(n, 3)
+ msg = first_seg + buf[:n]
+ self.assertEqual(msg, self.read_msg)
+ self.assertEqual(self.read_file.readinto(bytearray(16)), None)
+ self.assertEqual(self.read_file.read(1), None)
+
+ def _testSmallReadNonBlocking(self):
+ self.evt1.wait(1.0)
+ self.write_file.write(self.write_msg)
+ self.write_file.flush()
+ self.evt2.set()
+ # Avoid cloding the socket before the server test has finished,
+ # otherwise system recv() will return 0 instead of EWOULDBLOCK.
+ self.serv_finished.wait(5.0)
+
+ def testWriteNonBlocking(self):
+ self.cli_finished.wait(5.0)
+ # The client thread can't skip directly - the SkipTest exception
+ # would appear as a failure.
+ if self.serv_skipped:
+ self.skipTest(self.serv_skipped)
+
+ def _testWriteNonBlocking(self):
+ self.serv_skipped = None
+ self.serv_conn.setblocking(False)
+ # Try to saturate the socket buffer pipe with repeated large writes.
+ BIG = b"x" * (1024 ** 2)
+ LIMIT = 10
+ # The first write() succeeds since a chunk of data can be buffered
+ n = self.write_file.write(BIG)
+ self.assertGreater(n, 0)
+ for i in range(LIMIT):
+ n = self.write_file.write(BIG)
+ if n is None:
+ # Succeeded
+ break
+ self.assertGreater(n, 0)
+ else:
+ # Let us know that this test didn't manage to establish
+ # the expected conditions. This is not a failure in itself but,
+ # if it happens repeatedly, the test should be fixed.
+ self.serv_skipped = "failed to saturate the socket buffer"
+
class LineBufferedFileObjectClassTestCase(FileObjectClassTestCase):
bufsize = 1 # Default-buffered for reading; line-buffered for writing
- class SocketMemo(object):
- """A wrapper to keep track of sent data, needed to examine write behaviour"""
- def __init__(self, sock):
- self._sock = sock
- self.sent = []
- def send(self, data, flags=0):
- n = self._sock.send(data, flags)
- self.sent.append(data[:n])
- return n
+class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase):
- def sendall(self, data, flags=0):
- self._sock.sendall(data, flags)
- self.sent.append(data)
+ bufsize = 2 # Exercise the buffering code
- def __getattr__(self, attr):
- return getattr(self._sock, attr)
- def getsent(self):
- return [e.tobytes() if isinstance(e, memoryview) else e for e in self.sent]
+class UnicodeReadFileObjectClassTestCase(FileObjectClassTestCase):
+ """Tests for socket.makefile() in text mode (rather than binary)"""
- def setUp(self):
- FileObjectClassTestCase.setUp(self)
- self.serv_file._sock = self.SocketMemo(self.serv_file._sock)
-
- def testLinebufferedWrite(self):
- # Write two lines, in small chunks
- msg = MSG.strip()
- print >> self.serv_file, msg,
- print >> self.serv_file, msg
-
- # second line:
- print >> self.serv_file, msg,
- print >> self.serv_file, msg,
- print >> self.serv_file, msg
-
- # third line
- print >> self.serv_file, ''
-
- self.serv_file.flush()
-
- msg1 = "%s %s\n"%(msg, msg)
- msg2 = "%s %s %s\n"%(msg, msg, msg)
- msg3 = "\n"
- self.assertEqual(self.serv_file._sock.getsent(), [msg1, msg2, msg3])
-
- def _testLinebufferedWrite(self):
- msg = MSG.strip()
- msg1 = "%s %s\n"%(msg, msg)
- msg2 = "%s %s %s\n"%(msg, msg, msg)
- msg3 = "\n"
- l1 = self.cli_file.readline()
- self.assertEqual(l1, msg1)
- l2 = self.cli_file.readline()
- self.assertEqual(l2, msg2)
- l3 = self.cli_file.readline()
- self.assertEqual(l3, msg3)
+ read_mode = 'r'
+ read_msg = MSG.decode('utf8')
+ write_mode = 'wb'
+ write_msg = MSG
+ newline = ''
-class SmallBufferedFileObjectClassTestCase(FileObjectClassTestCase):
+class UnicodeWriteFileObjectClassTestCase(FileObjectClassTestCase):
+ """Tests for socket.makefile() in text mode (rather than binary)"""
+
+ read_mode = 'rb'
+ read_msg = MSG
+ write_mode = 'w'
+ write_msg = MSG.decode('utf8')
+ newline = ''
- bufsize = 2 # Exercise the buffering code
+
+class UnicodeReadWriteFileObjectClassTestCase(FileObjectClassTestCase):
+ """Tests for socket.makefile() in text mode (rather than binary)"""
+
+ read_mode = 'r'
+ read_msg = MSG.decode('utf8')
+ write_mode = 'w'
+ write_msg = MSG.decode('utf8')
+ newline = ''
class NetworkConnectionTest(object):
"""Prove network connection."""
+
def clientSetUp(self):
# We're inherited below by BasicTCPTest2, which also inherits
# BasicTCPTest, which defines self.port referenced below.
@@ -1228,6 +1609,7 @@ class BasicTCPTest2(NetworkConnectionTest, BasicTCPTest):
"""
class NetworkConnectionNoServer(unittest.TestCase):
+
class MockSocket(socket.socket):
def connect(self, *args):
raise socket.timeout('timed out')
@@ -1243,7 +1625,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
socket.socket = old_socket
def test_connect(self):
- port = test_support.find_unused_port()
+ port = support.find_unused_port()
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.addCleanup(cli.close)
with self.assertRaises(socket.error) as cm:
@@ -1253,7 +1635,7 @@ class NetworkConnectionNoServer(unittest.TestCase):
def test_create_connection(self):
# Issue #9792: errors raised by create_connection() should have
# a proper errno attribute.
- port = test_support.find_unused_port()
+ port = support.find_unused_port()
with self.assertRaises(socket.error) as cm:
socket.create_connection((HOST, port))
@@ -1293,7 +1675,7 @@ class NetworkConnectionAttributesTest(SocketTCPTest, ThreadableTest):
ThreadableTest.__init__(self)
def clientSetUp(self):
- self.source_port = test_support.find_unused_port()
+ self.source_port = support.find_unused_port()
def clientTearDown(self):
self.cli.close()
@@ -1373,43 +1755,19 @@ class NetworkConnectionBehaviourTest(SocketTCPTest, ThreadableTest):
conn, addr = self.serv.accept()
self.addCleanup(conn.close)
time.sleep(3)
- conn.send("done!")
+ conn.send(b"done!")
testOutsideTimeout = testInsideTimeout
def _testInsideTimeout(self):
self.cli = sock = socket.create_connection((HOST, self.port))
data = sock.recv(5)
- self.assertEqual(data, "done!")
+ self.assertEqual(data, b"done!")
def _testOutsideTimeout(self):
self.cli = sock = socket.create_connection((HOST, self.port), timeout=1)
self.assertRaises(socket.timeout, lambda: sock.recv(5))
-class Urllib2FileobjectTest(unittest.TestCase):
-
- # urllib2.HTTPHandler has "borrowed" socket._fileobject, and requires that
- # it close the socket if the close c'tor argument is true
-
- def testClose(self):
- class MockSocket:
- closed = False
- def flush(self): pass
- def close(self): self.closed = True
-
- # must not close unless we request it: the original use of _fileobject
- # by module socket requires that the underlying socket not be closed until
- # the _socketobject that created the _fileobject is closed
- s = MockSocket()
- f = socket._fileobject(s)
- f.close()
- self.assertTrue(not s.closed)
-
- s = MockSocket()
- f = socket._fileobject(s, close=True)
- f.close()
- self.assertTrue(s.closed)
-
class TCPTimeoutTest(SocketTCPTest):
def testTCPTimeout(self):
@@ -1503,26 +1861,26 @@ class TestLinuxAbstractNamespace(unittest.TestCase):
UNIX_PATH_MAX = 108
def testLinuxAbstractNamespace(self):
- address = "\x00python-test-hello\x00\xff"
- s1 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s1.bind(address)
- s1.listen(1)
- s2 = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s2.connect(s1.getsockname())
- s1.accept()
- self.assertEqual(s1.getsockname(), address)
- self.assertEqual(s2.getpeername(), address)
+ address = b"\x00python-test-hello\x00\xff"
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s1:
+ s1.bind(address)
+ s1.listen(1)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s2:
+ s2.connect(s1.getsockname())
+ with s1.accept()[0] as s3:
+ self.assertEqual(s1.getsockname(), address)
+ self.assertEqual(s2.getpeername(), address)
def testMaxName(self):
- address = "\x00" + "h" * (self.UNIX_PATH_MAX - 1)
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.bind(address)
- self.assertEqual(s.getsockname(), address)
+ address = b"\x00" + b"h" * (self.UNIX_PATH_MAX - 1)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
+ s.bind(address)
+ self.assertEqual(s.getsockname(), address)
def testNameOverflow(self):
address = "\x00" + "h" * self.UNIX_PATH_MAX
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- self.assertRaises(socket.error, s.bind, address)
+ with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as s:
+ self.assertRaises(socket.error, s.bind, address)
@unittest.skipUnless(thread, 'Threading required for this test.')
@@ -1534,15 +1892,14 @@ class BufferIOTest(SocketConnectedTest):
SocketConnectedTest.__init__(self, methodName=methodName)
def testRecvIntoArray(self):
- buf = array.array('c', ' '*1024)
+ buf = bytearray(1024)
nbytes = self.cli_conn.recv_into(buf)
self.assertEqual(nbytes, len(MSG))
- msg = buf.tostring()[:len(MSG)]
+ msg = buf[:len(MSG)]
self.assertEqual(msg, MSG)
def _testRecvIntoArray(self):
- with test_support.check_py3k_warnings():
- buf = buffer(MSG)
+ buf = bytes(MSG)
self.serv_conn.send(buf)
def testRecvIntoBytearray(self):
@@ -1564,15 +1921,14 @@ class BufferIOTest(SocketConnectedTest):
_testRecvIntoMemoryview = _testRecvIntoArray
def testRecvFromIntoArray(self):
- buf = array.array('c', ' '*1024)
+ buf = bytearray(1024)
nbytes, addr = self.cli_conn.recvfrom_into(buf)
self.assertEqual(nbytes, len(MSG))
- msg = buf.tostring()[:len(MSG)]
+ msg = buf[:len(MSG)]
self.assertEqual(msg, MSG)
def _testRecvFromIntoArray(self):
- with test_support.check_py3k_warnings():
- buf = buffer(MSG)
+ buf = bytes(MSG)
self.serv_conn.send(buf)
def testRecvFromIntoBytearray(self):
@@ -1612,14 +1968,16 @@ def isTipcAvailable():
for line in f:
if line.startswith("tipc "):
return True
- if test_support.verbose:
- print "TIPC module is not loaded, please 'sudo modprobe tipc'"
+ if support.verbose:
+ print("TIPC module is not loaded, please 'sudo modprobe tipc'")
return False
-class TIPCTest (unittest.TestCase):
+class TIPCTest(unittest.TestCase):
def testRDM(self):
srv = socket.socket(socket.AF_TIPC, socket.SOCK_RDM)
cli = socket.socket(socket.AF_TIPC, socket.SOCK_RDM)
+ self.addCleanup(srv.close)
+ self.addCleanup(cli.close)
srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE,
@@ -1627,7 +1985,7 @@ class TIPCTest (unittest.TestCase):
srv.bind(srvaddr)
sendaddr = (socket.TIPC_ADDR_NAME, TIPC_STYPE,
- TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0)
+ TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0)
cli.sendto(MSG, sendaddr)
msg, recvaddr = srv.recvfrom(1024)
@@ -1636,13 +1994,14 @@ class TIPCTest (unittest.TestCase):
self.assertEqual(msg, MSG)
-class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
+class TIPCThreadableTest(unittest.TestCase, ThreadableTest):
def __init__(self, methodName = 'runTest'):
unittest.TestCase.__init__(self, methodName = methodName)
ThreadableTest.__init__(self)
def setUp(self):
self.srv = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
+ self.addCleanup(self.srv.close)
self.srv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
srvaddr = (socket.TIPC_ADDR_NAMESEQ, TIPC_STYPE,
TIPC_LOWER, TIPC_UPPER)
@@ -1650,6 +2009,7 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
self.srv.listen(5)
self.serverExplicitReady()
self.conn, self.connaddr = self.srv.accept()
+ self.addCleanup(self.conn.close)
def clientSetUp(self):
# The is a hittable race between serverExplicitReady() and the
@@ -1657,8 +2017,9 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
# we could get an exception
time.sleep(0.1)
self.cli = socket.socket(socket.AF_TIPC, socket.SOCK_STREAM)
+ self.addCleanup(self.cli.close)
addr = (socket.TIPC_ADDR_NAME, TIPC_STYPE,
- TIPC_LOWER + (TIPC_UPPER - TIPC_LOWER) / 2, 0)
+ TIPC_LOWER + int((TIPC_UPPER - TIPC_LOWER) / 2), 0)
self.cli.connect(addr)
self.cliaddr = self.cli.getsockname()
@@ -1672,10 +2033,117 @@ class TIPCThreadableTest (unittest.TestCase, ThreadableTest):
self.cli.close()
+@unittest.skipUnless(thread, 'Threading required for this test.')
+class ContextManagersTest(ThreadedTCPSocketTest):
+
+ def _testSocketClass(self):
+ # base test
+ with socket.socket() as sock:
+ self.assertFalse(sock._closed)
+ self.assertTrue(sock._closed)
+ # close inside with block
+ with socket.socket() as sock:
+ sock.close()
+ self.assertTrue(sock._closed)
+ # exception inside with block
+ with socket.socket() as sock:
+ self.assertRaises(socket.error, sock.sendall, b'foo')
+ self.assertTrue(sock._closed)
+
+ def testCreateConnectionBase(self):
+ conn, addr = self.serv.accept()
+ self.addCleanup(conn.close)
+ data = conn.recv(1024)
+ conn.sendall(data)
+
+ def _testCreateConnectionBase(self):
+ address = self.serv.getsockname()
+ with socket.create_connection(address) as sock:
+ self.assertFalse(sock._closed)
+ sock.sendall(b'foo')
+ self.assertEqual(sock.recv(1024), b'foo')
+ self.assertTrue(sock._closed)
+
+ def testCreateConnectionClose(self):
+ conn, addr = self.serv.accept()
+ self.addCleanup(conn.close)
+ data = conn.recv(1024)
+ conn.sendall(data)
+
+ def _testCreateConnectionClose(self):
+ address = self.serv.getsockname()
+ with socket.create_connection(address) as sock:
+ sock.close()
+ self.assertTrue(sock._closed)
+ self.assertRaises(socket.error, sock.sendall, b'foo')
+
+
+@unittest.skipUnless(hasattr(socket, "SOCK_CLOEXEC"),
+ "SOCK_CLOEXEC not defined")
+@unittest.skipUnless(fcntl, "module fcntl not available")
+class CloexecConstantTest(unittest.TestCase):
+ def test_SOCK_CLOEXEC(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ with socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM | socket.SOCK_CLOEXEC) as s:
+ self.assertTrue(s.type & socket.SOCK_CLOEXEC)
+ self.assertTrue(fcntl.fcntl(s, fcntl.F_GETFD) & fcntl.FD_CLOEXEC)
+
+
+@unittest.skipUnless(hasattr(socket, "SOCK_NONBLOCK"),
+ "SOCK_NONBLOCK not defined")
+class NonblockConstantTest(unittest.TestCase):
+ def checkNonblock(self, s, nonblock=True, timeout=0.0):
+ if nonblock:
+ self.assertTrue(s.type & socket.SOCK_NONBLOCK)
+ self.assertEqual(s.gettimeout(), timeout)
+ else:
+ self.assertFalse(s.type & socket.SOCK_NONBLOCK)
+ self.assertEqual(s.gettimeout(), None)
+
+ def test_SOCK_NONBLOCK(self):
+ v = linux_version()
+ if v < (2, 6, 28):
+ self.skipTest("Linux kernel 2.6.28 or higher required, not %s"
+ % ".".join(map(str, v)))
+ # a lot of it seems silly and redundant, but I wanted to test that
+ # changing back and forth worked ok
+ with socket.socket(socket.AF_INET,
+ socket.SOCK_STREAM | socket.SOCK_NONBLOCK) as s:
+ self.checkNonblock(s)
+ s.setblocking(1)
+ self.checkNonblock(s, False)
+ s.setblocking(0)
+ self.checkNonblock(s)
+ s.settimeout(None)
+ self.checkNonblock(s, False)
+ s.settimeout(2.0)
+ self.checkNonblock(s, timeout=2.0)
+ s.setblocking(1)
+ self.checkNonblock(s, False)
+ # defaulttimeout
+ t = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(0.0)
+ with socket.socket() as s:
+ self.checkNonblock(s)
+ socket.setdefaulttimeout(None)
+ with socket.socket() as s:
+ self.checkNonblock(s, False)
+ socket.setdefaulttimeout(2.0)
+ with socket.socket() as s:
+ self.checkNonblock(s, timeout=2.0)
+ socket.setdefaulttimeout(None)
+ with socket.socket() as s:
+ self.checkNonblock(s, False)
+ socket.setdefaulttimeout(t)
+
+
def test_main():
tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
- TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest,
- UDPTimeoutTest ]
+ TestExceptions, BufferIOTest, BasicTCPTest2, BasicUDPTest, UDPTimeoutTest ]
tests.extend([
NonBlockingTCPTests,
@@ -1684,10 +2152,15 @@ def test_main():
UnbufferedFileObjectClassTestCase,
LineBufferedFileObjectClassTestCase,
SmallBufferedFileObjectClassTestCase,
- Urllib2FileobjectTest,
+ UnicodeReadFileObjectClassTestCase,
+ UnicodeWriteFileObjectClassTestCase,
+ UnicodeReadWriteFileObjectClassTestCase,
NetworkConnectionNoServer,
NetworkConnectionAttributesTest,
NetworkConnectionBehaviourTest,
+ ContextManagersTest,
+ CloexecConstantTest,
+ NonblockConstantTest
])
if hasattr(socket, "socketpair"):
tests.append(BasicSocketPairTest)
@@ -1697,9 +2170,9 @@ def test_main():
tests.append(TIPCTest)
tests.append(TIPCThreadableTest)
- thread_info = test_support.threading_setup()
- test_support.run_unittest(*tests)
- test_support.threading_cleanup(*thread_info)
+ thread_info = support.threading_setup()
+ support.run_unittest(*tests)
+ support.threading_cleanup(*thread_info)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_socketserver.py b/Lib/test/test_socketserver.py
index 0dbb8e2ed0d..160f5b83dd6 100644
--- a/Lib/test/test_socketserver.py
+++ b/Lib/test/test_socketserver.py
@@ -1,5 +1,5 @@
"""
-Test suite for SocketServer.py.
+Test suite for socketserver.
"""
import contextlib
@@ -12,19 +12,19 @@ import select
import errno
import tempfile
import unittest
-import SocketServer
+import socketserver
-import test.test_support
-from test.test_support import reap_children, reap_threads, verbose
+import test.support
+from test.support import reap_children, reap_threads, verbose
try:
import threading
except ImportError:
threading = None
-test.test_support.requires("network")
+test.support.requires("network")
-TEST_STR = "hello world\n"
-HOST = test.test_support.HOST
+TEST_STR = b"hello world\n"
+HOST = test.support.HOST
HAVE_UNIX_SOCKETS = hasattr(socket, "AF_UNIX")
HAVE_FORKING = hasattr(os, "fork") and os.name != "os2"
@@ -42,15 +42,15 @@ def receive(sock, n, timeout=20):
if sock in r:
return sock.recv(n)
else:
- raise RuntimeError, "timed out on %r" % (sock,)
+ raise RuntimeError("timed out on %r" % (sock,))
if HAVE_UNIX_SOCKETS:
- class ForkingUnixStreamServer(SocketServer.ForkingMixIn,
- SocketServer.UnixStreamServer):
+ class ForkingUnixStreamServer(socketserver.ForkingMixIn,
+ socketserver.UnixStreamServer):
pass
- class ForkingUnixDatagramServer(SocketServer.ForkingMixIn,
- SocketServer.UnixDatagramServer):
+ class ForkingUnixDatagramServer(socketserver.ForkingMixIn,
+ socketserver.UnixDatagramServer):
pass
@@ -123,7 +123,7 @@ class SocketServerTest(unittest.TestCase):
line = self.rfile.readline()
self.wfile.write(line)
- if verbose: print "creating server"
+ if verbose: print("creating server")
server = MyServer(addr, MyHandler)
self.assertEqual(server.server_address, server.socket.getsockname())
return server
@@ -136,9 +136,9 @@ class SocketServerTest(unittest.TestCase):
# the server.
addr = server.server_address
if verbose:
- print "server created"
- print "ADDR =", addr
- print "CLASS =", svrcls
+ print("ADDR =", addr)
+ print("CLASS =", svrcls)
+
t = threading.Thread(
name='%s serving' % svrcls,
target=server.serve_forever,
@@ -148,21 +148,22 @@ class SocketServerTest(unittest.TestCase):
kwargs={'poll_interval':0.01})
t.daemon = True # In case this function raises.
t.start()
- if verbose: print "server running"
+ if verbose: print("server running")
for i in range(3):
- if verbose: print "test client", i
+ if verbose: print("test client", i)
testfunc(svrcls.address_family, addr)
- if verbose: print "waiting for server"
+ if verbose: print("waiting for server")
server.shutdown()
t.join()
- if verbose: print "done"
+ server.server_close()
+ if verbose: print("done")
def stream_examine(self, proto, addr):
s = socket.socket(proto, socket.SOCK_STREAM)
s.connect(addr)
s.sendall(TEST_STR)
buf = data = receive(s, 100)
- while data and '\n' not in buf:
+ while data and b'\n' not in buf:
data = receive(s, 100)
buf += data
self.assertEqual(buf, TEST_STR)
@@ -172,62 +173,62 @@ class SocketServerTest(unittest.TestCase):
s = socket.socket(proto, socket.SOCK_DGRAM)
s.sendto(TEST_STR, addr)
buf = data = receive(s, 100)
- while data and '\n' not in buf:
+ while data and b'\n' not in buf:
data = receive(s, 100)
buf += data
self.assertEqual(buf, TEST_STR)
s.close()
def test_TCPServer(self):
- self.run_server(SocketServer.TCPServer,
- SocketServer.StreamRequestHandler,
+ self.run_server(socketserver.TCPServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
def test_ThreadingTCPServer(self):
- self.run_server(SocketServer.ThreadingTCPServer,
- SocketServer.StreamRequestHandler,
+ self.run_server(socketserver.ThreadingTCPServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
if HAVE_FORKING:
def test_ForkingTCPServer(self):
with simple_subprocess(self):
- self.run_server(SocketServer.ForkingTCPServer,
- SocketServer.StreamRequestHandler,
+ self.run_server(socketserver.ForkingTCPServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
if HAVE_UNIX_SOCKETS:
def test_UnixStreamServer(self):
- self.run_server(SocketServer.UnixStreamServer,
- SocketServer.StreamRequestHandler,
+ self.run_server(socketserver.UnixStreamServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
def test_ThreadingUnixStreamServer(self):
- self.run_server(SocketServer.ThreadingUnixStreamServer,
- SocketServer.StreamRequestHandler,
+ self.run_server(socketserver.ThreadingUnixStreamServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
if HAVE_FORKING:
def test_ForkingUnixStreamServer(self):
with simple_subprocess(self):
self.run_server(ForkingUnixStreamServer,
- SocketServer.StreamRequestHandler,
+ socketserver.StreamRequestHandler,
self.stream_examine)
def test_UDPServer(self):
- self.run_server(SocketServer.UDPServer,
- SocketServer.DatagramRequestHandler,
+ self.run_server(socketserver.UDPServer,
+ socketserver.DatagramRequestHandler,
self.dgram_examine)
def test_ThreadingUDPServer(self):
- self.run_server(SocketServer.ThreadingUDPServer,
- SocketServer.DatagramRequestHandler,
+ self.run_server(socketserver.ThreadingUDPServer,
+ socketserver.DatagramRequestHandler,
self.dgram_examine)
if HAVE_FORKING:
def test_ForkingUDPServer(self):
with simple_subprocess(self):
- self.run_server(SocketServer.ForkingUDPServer,
- SocketServer.DatagramRequestHandler,
+ self.run_server(socketserver.ForkingUDPServer,
+ socketserver.DatagramRequestHandler,
self.dgram_examine)
@contextlib.contextmanager
@@ -256,8 +257,8 @@ class SocketServerTest(unittest.TestCase):
def test_InterruptServerSelectCall(self):
with self.mocked_select_module() as mock_select:
- pid = self.run_server(SocketServer.TCPServer,
- SocketServer.StreamRequestHandler,
+ pid = self.run_server(socketserver.TCPServer,
+ socketserver.StreamRequestHandler,
self.stream_examine)
# Make sure select was called again:
self.assertGreater(mock_select.called, 1)
@@ -267,29 +268,29 @@ class SocketServerTest(unittest.TestCase):
# if HAVE_UNIX_SOCKETS:
# def test_UnixDatagramServer(self):
- # self.run_server(SocketServer.UnixDatagramServer,
- # SocketServer.DatagramRequestHandler,
+ # self.run_server(socketserver.UnixDatagramServer,
+ # socketserver.DatagramRequestHandler,
# self.dgram_examine)
#
# def test_ThreadingUnixDatagramServer(self):
- # self.run_server(SocketServer.ThreadingUnixDatagramServer,
- # SocketServer.DatagramRequestHandler,
+ # self.run_server(socketserver.ThreadingUnixDatagramServer,
+ # socketserver.DatagramRequestHandler,
# self.dgram_examine)
#
# if HAVE_FORKING:
# def test_ForkingUnixDatagramServer(self):
- # self.run_server(SocketServer.ForkingUnixDatagramServer,
- # SocketServer.DatagramRequestHandler,
+ # self.run_server(socketserver.ForkingUnixDatagramServer,
+ # socketserver.DatagramRequestHandler,
# self.dgram_examine)
@reap_threads
def test_shutdown(self):
# Issue #2302: shutdown() should always succeed in making an
# other thread leave serve_forever().
- class MyServer(SocketServer.TCPServer):
+ class MyServer(socketserver.TCPServer):
pass
- class MyHandler(SocketServer.StreamRequestHandler):
+ class MyHandler(socketserver.StreamRequestHandler):
pass
threads = []
@@ -306,6 +307,7 @@ class SocketServerTest(unittest.TestCase):
s.shutdown()
for t, s in threads:
t.join()
+ s.server_close()
def test_main():
@@ -313,7 +315,7 @@ def test_main():
# If the import lock is held, the threads will hang
raise unittest.SkipTest("can't run when import lock is held")
- test.test_support.run_unittest(SocketServerTest)
+ test.support.run_unittest(SocketServerTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_softspace.py b/Lib/test/test_softspace.py
deleted file mode 100644
index 719a035c45d..00000000000
--- a/Lib/test/test_softspace.py
+++ /dev/null
@@ -1,23 +0,0 @@
-from test.test_support import run_unittest
-import unittest
-import StringIO
-
-class SoftspaceTests(unittest.TestCase):
- def test_bug_480215(self):
- # SF bug 480215: softspace confused in nested print
- f = StringIO.StringIO()
- class C:
- def __str__(self):
- print >> f, 'a'
- return 'b'
-
- print >> f, C(), 'c ', 'd\t', 'e'
- print >> f, 'f', 'g'
- # In 2.2 & earlier, this printed ' a\nbc d\te\nf g\n'
- self.assertEqual(f.getvalue(), 'a\nb c d\te\nf g\n')
-
-def test_main():
- run_unittest(SoftspaceTests)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_sort.py b/Lib/test/test_sort.py
index d75abc49173..8f6af644702 100644
--- a/Lib/test/test_sort.py
+++ b/Lib/test/test_sort.py
@@ -1,40 +1,42 @@
-from test import test_support
+from test import support
import random
import sys
import unittest
+from functools import cmp_to_key
-verbose = test_support.verbose
+verbose = support.verbose
nerrors = 0
+
def check(tag, expected, raw, compare=None):
global nerrors
if verbose:
- print " checking", tag
+ print(" checking", tag)
orig = raw[:] # save input in case of error
if compare:
- raw.sort(compare)
+ raw.sort(key=cmp_to_key(compare))
else:
raw.sort()
if len(expected) != len(raw):
- print "error in", tag
- print "length mismatch;", len(expected), len(raw)
- print expected
- print orig
- print raw
+ print("error in", tag)
+ print("length mismatch;", len(expected), len(raw))
+ print(expected)
+ print(orig)
+ print(raw)
nerrors += 1
return
for i, good in enumerate(expected):
maybe = raw[i]
if good is not maybe:
- print "error in", tag
- print "out of order at index", i, good, maybe
- print expected
- print orig
- print raw
+ print("error in", tag)
+ print("out of order at index", i, good, maybe)
+ print(expected)
+ print(orig)
+ print(raw)
nerrors += 1
return
@@ -56,7 +58,7 @@ class TestBase(unittest.TestCase):
def __lt__(self, other):
if Complains.maybe_complain and random.random() < 0.001:
if verbose:
- print " complaining at", self, other
+ print(" complaining at", self, other)
raise RuntimeError
return self.i < other.i
@@ -68,17 +70,16 @@ class TestBase(unittest.TestCase):
self.key = key
self.index = i
- def __cmp__(self, other):
- return cmp(self.key, other.key)
- __hash__ = None # Silence Py3k warning
+ def __lt__(self, other):
+ return self.key < other.key
def __repr__(self):
return "Stable(%d, %d)" % (self.key, self.index)
for n in sizes:
- x = range(n)
+ x = list(range(n))
if verbose:
- print "Testing size", n
+ print("Testing size", n)
s = x[:]
check("identity", x, s)
@@ -94,15 +95,21 @@ class TestBase(unittest.TestCase):
y = x[:]
y.reverse()
s = x[:]
- check("reversed via function", y, s, lambda a, b: cmp(b, a))
+ check("reversed via function", y, s, lambda a, b: (b>a)-(b<a))
if verbose:
- print " Checking against an insane comparison function."
- print " If the implementation isn't careful, this may segfault."
+ print(" Checking against an insane comparison function.")
+ print(" If the implementation isn't careful, this may segfault.")
s = x[:]
- s.sort(lambda a, b: int(random.random() * 3) - 1)
+ s.sort(key=cmp_to_key(lambda a, b: int(random.random() * 3) - 1))
check("an insane function left some permutation", x, s)
+ if len(x) >= 2:
+ def bad_key(x):
+ raise RuntimeError
+ s = x[:]
+ self.assertRaises(RuntimeError, s.sort, key=bad_key)
+
x = [Complains(i) for i in x]
s = x[:]
random.shuffle(s)
@@ -116,7 +123,7 @@ class TestBase(unittest.TestCase):
Complains.maybe_complain = False
check("exception during sort left some permutation", x, s)
- s = [Stable(random.randrange(10), i) for i in xrange(n)]
+ s = [Stable(random.randrange(10), i) for i in range(n)]
augmented = [(e, e.index) for e in s]
augmented.sort() # forced stable because ties broken by index
x = [e for e, i in augmented] # a stable sort of s
@@ -142,14 +149,6 @@ class TestBugs(unittest.TestCase):
L = [C() for i in range(50)]
self.assertRaises(ValueError, L.sort)
- def test_cmpNone(self):
- # Testing None as a comparison function.
-
- L = range(50)
- random.shuffle(L)
- L.sort(None)
- self.assertEqual(L, range(50))
-
def test_undetected_mutation(self):
# Python 2.4a1 did not always detect mutation
memorywaster = []
@@ -157,14 +156,14 @@ class TestBugs(unittest.TestCase):
def mutating_cmp(x, y):
L.append(3)
L.pop()
- return cmp(x, y)
+ return (x > y) - (x < y)
L = [1,2]
- self.assertRaises(ValueError, L.sort, mutating_cmp)
+ self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
def mutating_cmp(x, y):
L.append(3)
del L[:]
- return cmp(x, y)
- self.assertRaises(ValueError, L.sort, mutating_cmp)
+ return (x > y) - (x < y)
+ self.assertRaises(ValueError, L.sort, key=cmp_to_key(mutating_cmp))
memorywaster = [memorywaster]
#==============================================================================
@@ -176,42 +175,31 @@ class TestDecorateSortUndecorate(unittest.TestCase):
copy = data[:]
random.shuffle(data)
data.sort(key=str.lower)
- copy.sort(cmp=lambda x,y: cmp(x.lower(), y.lower()))
+ def my_cmp(x, y):
+ xlower, ylower = x.lower(), y.lower()
+ return (xlower > ylower) - (xlower < ylower)
+ copy.sort(key=cmp_to_key(my_cmp))
def test_baddecorator(self):
data = 'The quick Brown fox Jumped over The lazy Dog'.split()
- self.assertRaises(TypeError, data.sort, None, lambda x,y: 0)
+ self.assertRaises(TypeError, data.sort, key=lambda x,y: 0)
def test_stability(self):
- data = [(random.randrange(100), i) for i in xrange(200)]
+ data = [(random.randrange(100), i) for i in range(200)]
copy = data[:]
- data.sort(key=lambda x: x[0]) # sort on the random first field
+ data.sort(key=lambda t: t[0]) # sort on the random first field
copy.sort() # sort using both fields
self.assertEqual(data, copy) # should get the same result
- def test_cmp_and_key_combination(self):
- # Verify that the wrapper has been removed
- def compare(x, y):
- self.assertEqual(type(x), str)
- self.assertEqual(type(x), str)
- return cmp(x, y)
- data = 'The quick Brown fox Jumped over The lazy Dog'.split()
- data.sort(cmp=compare, key=str.lower)
-
- def test_badcmp_with_key(self):
- # Verify that the wrapper has been removed
- data = 'The quick Brown fox Jumped over The lazy Dog'.split()
- self.assertRaises(TypeError, data.sort, "bad", str.lower)
-
def test_key_with_exception(self):
# Verify that the wrapper has been removed
- data = range(-2,2)
+ data = list(range(-2, 2))
dup = data[:]
- self.assertRaises(ZeroDivisionError, data.sort, None, lambda x: 1 // x)
+ self.assertRaises(ZeroDivisionError, data.sort, key=lambda x: 1/x)
self.assertEqual(data, dup)
def test_key_with_mutation(self):
- data = range(10)
+ data = list(range(10))
def k(x):
del data[:]
data[:] = range(20)
@@ -219,17 +207,19 @@ class TestDecorateSortUndecorate(unittest.TestCase):
self.assertRaises(ValueError, data.sort, key=k)
def test_key_with_mutating_del(self):
- data = range(10)
+ data = list(range(10))
class SortKiller(object):
def __init__(self, x):
pass
def __del__(self):
del data[:]
data[:] = range(20)
+ def __lt__(self, other):
+ return id(self) < id(other)
self.assertRaises(ValueError, data.sort, key=SortKiller)
def test_key_with_mutating_del_and_exception(self):
- data = range(10)
+ data = list(range(10))
## dup = data[:]
class SortKiller(object):
def __init__(self, x):
@@ -237,7 +227,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
raise RuntimeError
def __del__(self):
del data[:]
- data[:] = range(20)
+ data[:] = list(range(20))
self.assertRaises(RuntimeError, data.sort, key=SortKiller)
## major honking subtlety: we *can't* do:
##
@@ -249,18 +239,23 @@ class TestDecorateSortUndecorate(unittest.TestCase):
## date (this cost some brain cells to figure out...).
def test_reverse(self):
- data = range(100)
+ data = list(range(100))
random.shuffle(data)
data.sort(reverse=True)
- self.assertEqual(data, range(99,-1,-1))
- self.assertRaises(TypeError, data.sort, "wrong type")
+ self.assertEqual(data, list(range(99,-1,-1)))
def test_reverse_stability(self):
- data = [(random.randrange(100), i) for i in xrange(200)]
+ data = [(random.randrange(100), i) for i in range(200)]
copy1 = data[:]
copy2 = data[:]
- data.sort(cmp=lambda x,y: cmp(x[0],y[0]), reverse=True)
- copy1.sort(cmp=lambda x,y: cmp(y[0],x[0]))
+ def my_cmp(x, y):
+ x0, y0 = x[0], y[0]
+ return (x0 > y0) - (x0 < y0)
+ def my_cmp_reversed(x, y):
+ x0, y0 = x[0], y[0]
+ return (y0 > x0) - (y0 < x0)
+ data.sort(key=cmp_to_key(my_cmp), reverse=True)
+ copy1.sort(key=cmp_to_key(my_cmp_reversed))
self.assertEqual(data, copy1)
copy2.sort(key=lambda x: x[0], reverse=True)
self.assertEqual(data, copy2)
@@ -274,19 +269,17 @@ def test_main(verbose=None):
TestBugs,
)
- with test_support.check_py3k_warnings(
- ("the cmp argument is not supported", DeprecationWarning)):
- test_support.run_unittest(*test_classes)
-
- # verify reference counting
- if verbose and hasattr(sys, "gettotalrefcount"):
- import gc
- counts = [None] * 5
- for i in xrange(len(counts)):
- test_support.run_unittest(*test_classes)
- gc.collect()
- counts[i] = sys.gettotalrefcount()
- print counts
+ support.run_unittest(*test_classes)
+
+ # verify reference counting
+ if verbose and hasattr(sys, "gettotalrefcount"):
+ import gc
+ counts = [None] * 5
+ for i in range(len(counts)):
+ support.run_unittest(*test_classes)
+ gc.collect()
+ counts[i] = sys.gettotalrefcount()
+ print(counts)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_sqlite.py b/Lib/test/test_sqlite.py
index db273316eaa..1086330ab09 100644
--- a/Lib/test/test_sqlite.py
+++ b/Lib/test/test_sqlite.py
@@ -1,16 +1,23 @@
-from test.test_support import run_unittest, import_module
+import test.support
-# Skip test if _sqlite3 module was not built.
-import_module('_sqlite3')
+# Skip test if _sqlite3 module not installed
+test.support.import_module('_sqlite3')
-from sqlite3.test import (dbapi, types, userfunctions, py25tests,
+import sqlite3
+from sqlite3.test import (dbapi, types, userfunctions,
factory, transactions, hooks, regression,
dump)
def test_main():
- run_unittest(dbapi.suite(), types.suite(), userfunctions.suite(),
- py25tests.suite(), factory.suite(), transactions.suite(),
- hooks.suite(), regression.suite(), dump.suite())
+ if test.support.verbose:
+ print("test_sqlite: testing with version",
+ "{!r}, sqlite_version {!r}".format(sqlite3.version,
+ sqlite3.sqlite_version))
+ test.support.run_unittest(dbapi.suite(), types.suite(),
+ userfunctions.suite(),
+ factory.suite(), transactions.suite(),
+ hooks.suite(), regression.suite(),
+ dump.suite())
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_ssl.py b/Lib/test/test_ssl.py
index 9f5138719e8..4f254a98f32 100644
--- a/Lib/test/test_ssl.py
+++ b/Lib/test/test_ssl.py
@@ -2,8 +2,7 @@
import sys
import unittest
-from test import test_support
-import asyncore
+from test import support
import socket
import select
import time
@@ -11,66 +10,74 @@ import gc
import os
import errno
import pprint
-import urllib, urlparse
+import tempfile
+import urllib.request
import traceback
+import asyncore
import weakref
-import functools
import platform
+import functools
+
+ssl = support.import_module("ssl")
+
+PROTOCOLS = [
+ ssl.PROTOCOL_SSLv3,
+ ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1
+]
+if hasattr(ssl, 'PROTOCOL_SSLv2'):
+ PROTOCOLS.append(ssl.PROTOCOL_SSLv2)
+
+HOST = support.HOST
+
+data_file = lambda name: os.path.join(os.path.dirname(__file__), name)
-from BaseHTTPServer import HTTPServer
-from SimpleHTTPServer import SimpleHTTPRequestHandler
+# The custom key and certificate files used in test_ssl are generated
+# using Lib/test/make_ssl_certs.py.
+# Other certificates are simply fetched from the Internet servers they
+# are meant to authenticate.
-ssl = test_support.import_module("ssl")
+CERTFILE = data_file("keycert.pem")
+BYTES_CERTFILE = os.fsencode(CERTFILE)
+ONLYCERT = data_file("ssl_cert.pem")
+ONLYKEY = data_file("ssl_key.pem")
+BYTES_ONLYCERT = os.fsencode(ONLYCERT)
+BYTES_ONLYKEY = os.fsencode(ONLYKEY)
+CAPATH = data_file("capath")
+BYTES_CAPATH = os.fsencode(CAPATH)
+
+SVN_PYTHON_ORG_ROOT_CERT = data_file("https_svn_python_org_root.pem")
+
+EMPTYCERT = data_file("nullcert.pem")
+BADCERT = data_file("badcert.pem")
+WRONGCERT = data_file("XXXnonexisting.pem")
+BADKEY = data_file("badkey.pem")
+NOKIACERT = data_file("nokia.pem")
-HOST = test_support.HOST
-CERTFILE = None
-SVN_PYTHON_ORG_ROOT_CERT = None
def handle_error(prefix):
exc_format = ' '.join(traceback.format_exception(*sys.exc_info()))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(prefix + exc_format)
+def can_clear_options():
+ # 0.9.8m or higher
+ return ssl._OPENSSL_API_VERSION >= (0, 9, 8, 13, 15)
-class BasicTests(unittest.TestCase):
+def no_sslv2_implies_sslv3_hello():
+ # 0.9.7h or higher
+ return ssl.OPENSSL_VERSION_INFO >= (0, 9, 7, 8, 15)
- def test_sslwrap_simple(self):
- # A crude test for the legacy API
- try:
- ssl.sslwrap_simple(socket.socket(socket.AF_INET))
- except IOError, e:
- if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that
- pass
- else:
- raise
- try:
- ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock)
- except IOError, e:
- if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that
- pass
- else:
- raise
# Issue #9415: Ubuntu hijacks their OpenSSL and forcefully disables SSLv2
def skip_if_broken_ubuntu_ssl(func):
if hasattr(ssl, 'PROTOCOL_SSLv2'):
- # We need to access the lower-level wrapper in order to create an
- # implicit SSL context without trying to connect or listen.
- try:
- import _ssl
- except ImportError:
- # The returned function won't get executed, just ignore the error
- pass
@functools.wraps(func)
def f(*args, **kwargs):
try:
- s = socket.socket(socket.AF_INET)
- _ssl.sslwrap(s._sock, 0, None, None,
- ssl.CERT_NONE, ssl.PROTOCOL_SSLv2, None, None)
- except ssl.SSLError as e:
+ ssl.SSLContext(ssl.PROTOCOL_SSLv2)
+ except ssl.SSLError:
if (ssl.OPENSSL_VERSION_INFO == (0, 9, 8, 15, 15) and
- platform.linux_distribution() == ('debian', 'squeeze/sid', '')
- and 'Invalid SSL protocol variant specified' in str(e)):
+ platform.linux_distribution() == ('debian', 'squeeze/sid', '')):
raise unittest.SkipTest("Patched Ubuntu OpenSSL breaks behaviour")
return func(*args, **kwargs)
return f
@@ -88,10 +95,11 @@ class BasicSocketTests(unittest.TestCase):
ssl.CERT_NONE
ssl.CERT_OPTIONAL
ssl.CERT_REQUIRED
+ self.assertIn(ssl.HAS_SNI, {True, False})
def test_random(self):
v = ssl.RAND_status()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n RAND_status is %d (%s)\n"
% (v, (v and "sufficient randomness") or
"insufficient randomness"))
@@ -103,21 +111,29 @@ class BasicSocketTests(unittest.TestCase):
# note that this uses an 'unofficial' function in _ssl.c,
# provided solely for this test, to exercise the certificate
# parsing code
- p = ssl._ssl._test_decode_cert(CERTFILE, False)
- if test_support.verbose:
+ p = ssl._ssl._test_decode_cert(CERTFILE)
+ if support.verbose:
sys.stdout.write("\n" + pprint.pformat(p) + "\n")
+ self.assertEqual(p['issuer'],
+ ((('countryName', 'XY'),),
+ (('localityName', 'Castle Anthrax'),),
+ (('organizationName', 'Python Software Foundation'),),
+ (('commonName', 'localhost'),))
+ )
+ self.assertEqual(p['notAfter'], 'Oct 5 23:01:56 2020 GMT')
+ self.assertEqual(p['notBefore'], 'Oct 8 23:01:56 2010 GMT')
+ self.assertEqual(p['serialNumber'], 'D7C7381919AFC24E')
self.assertEqual(p['subject'],
- ((('countryName', u'US'),),
- (('stateOrProvinceName', u'Delaware'),),
- (('localityName', u'Wilmington'),),
- (('organizationName', u'Python Software Foundation'),),
- (('organizationalUnitName', u'SSL'),),
- (('commonName', u'somemachine.python.org'),)),
+ ((('countryName', 'XY'),),
+ (('localityName', 'Castle Anthrax'),),
+ (('organizationName', 'Python Software Foundation'),),
+ (('commonName', 'localhost'),))
)
+ self.assertEqual(p['subjectAltName'], (('DNS', 'localhost'),))
# Issue #13034: the subjectAltName in some certificates
# (notably projects.developer.nokia.com:443) wasn't parsed
p = ssl._ssl._test_decode_cert(NOKIACERT)
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n" + pprint.pformat(p) + "\n")
self.assertEqual(p['subjectAltName'],
(('DNS', 'projects.developer.nokia.com'),
@@ -140,7 +156,7 @@ class BasicSocketTests(unittest.TestCase):
n = ssl.OPENSSL_VERSION_NUMBER
t = ssl.OPENSSL_VERSION_INFO
s = ssl.OPENSSL_VERSION
- self.assertIsInstance(n, (int, long))
+ self.assertIsInstance(n, int)
self.assertIsInstance(t, tuple)
self.assertIsInstance(s, str)
# Some sanity checks follow
@@ -163,25 +179,7 @@ class BasicSocketTests(unittest.TestCase):
self.assertTrue(s.startswith("OpenSSL {:d}.{:d}.{:d}".format(major, minor, fix)),
(s, t))
- def test_ciphers(self):
- if not test_support.is_resource_enabled('network'):
- return
- remote = ("svn.python.org", 443)
- with test_support.transient_internet(remote[0]):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE, ciphers="ALL")
- s.connect(remote)
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
- s.connect(remote)
- # Error checking occurs when connecting, because the SSL context
- # isn't created before.
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
- with self.assertRaisesRegexp(ssl.SSLError, "No cipher can be selected"):
- s.connect(remote)
-
- @test_support.cpython_only
+ @support.cpython_only
def test_refcycle(self):
# Issue #7943: an SSL object doesn't create reference cycles with
# itself.
@@ -192,9 +190,8 @@ class BasicSocketTests(unittest.TestCase):
self.assertEqual(wr(), None)
def test_wrapped_unconnected(self):
- # The _delegate_methods in socket.py are correctly delegated to by an
- # unconnected SSLSocket, so they will raise a socket.error rather than
- # something unexpected like TypeError.
+ # Methods on an unconnected SSLSocket propagate the original
+ # socket.error raise by the underlying socket object.
s = socket.socket(socket.AF_INET)
ss = ssl.wrap_socket(s)
self.assertRaises(socket.error, ss.recv, 1)
@@ -204,41 +201,305 @@ class BasicSocketTests(unittest.TestCase):
self.assertRaises(socket.error, ss.send, b'x')
self.assertRaises(socket.error, ss.sendto, b'x', ('0.0.0.0', 0))
+ def test_timeout(self):
+ # Issue #8524: when creating an SSL socket, the timeout of the
+ # original socket should be retained.
+ for timeout in (None, 0.0, 5.0):
+ s = socket.socket(socket.AF_INET)
+ s.settimeout(timeout)
+ ss = ssl.wrap_socket(s)
+ self.assertEqual(timeout, ss.gettimeout())
+
+ def test_errors(self):
+ sock = socket.socket()
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified",
+ ssl.wrap_socket, sock, keyfile=CERTFILE)
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified for server-side operations",
+ ssl.wrap_socket, sock, server_side=True)
+ self.assertRaisesRegex(ValueError,
+ "certfile must be specified for server-side operations",
+ ssl.wrap_socket, sock, server_side=True, certfile="")
+ s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
+ self.assertRaisesRegex(ValueError, "can't connect in server-side mode",
+ s.connect, (HOST, 8080))
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=CERTFILE, keyfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaises(IOError) as cm:
+ with socket.socket() as sock:
+ ssl.wrap_socket(sock, certfile=WRONGCERT, keyfile=WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+
+ def test_match_hostname(self):
+ def ok(cert, hostname):
+ ssl.match_hostname(cert, hostname)
+ def fail(cert, hostname):
+ self.assertRaises(ssl.CertificateError,
+ ssl.match_hostname, cert, hostname)
+
+ cert = {'subject': ((('commonName', 'example.com'),),)}
+ ok(cert, 'example.com')
+ ok(cert, 'ExAmple.cOm')
+ fail(cert, 'www.example.com')
+ fail(cert, '.example.com')
+ fail(cert, 'example.org')
+ fail(cert, 'exampleXcom')
+
+ cert = {'subject': ((('commonName', '*.a.com'),),)}
+ ok(cert, 'foo.a.com')
+ fail(cert, 'bar.foo.a.com')
+ fail(cert, 'a.com')
+ fail(cert, 'Xa.com')
+ fail(cert, '.a.com')
+
+ cert = {'subject': ((('commonName', 'a.*.com'),),)}
+ ok(cert, 'a.foo.com')
+ fail(cert, 'a..com')
+ fail(cert, 'a.com')
+
+ cert = {'subject': ((('commonName', 'f*.com'),),)}
+ ok(cert, 'foo.com')
+ ok(cert, 'f.com')
+ fail(cert, 'bar.com')
+ fail(cert, 'foo.a.com')
+ fail(cert, 'bar.foo.com')
+
+ # Slightly fake real-world example
+ cert = {'notAfter': 'Jun 26 21:41:46 2011 GMT',
+ 'subject': ((('commonName', 'linuxfrz.org'),),),
+ 'subjectAltName': (('DNS', 'linuxfr.org'),
+ ('DNS', 'linuxfr.com'),
+ ('othername', '<unsupported>'))}
+ ok(cert, 'linuxfr.org')
+ ok(cert, 'linuxfr.com')
+ # Not a "DNS" entry
+ fail(cert, '<unsupported>')
+ # When there is a subjectAltName, commonName isn't used
+ fail(cert, 'linuxfrz.org')
+
+ # A pristine real-world example
+ cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('organizationName', 'Google Inc'),),
+ (('commonName', 'mail.google.com'),))}
+ ok(cert, 'mail.google.com')
+ fail(cert, 'gmail.com')
+ # Only commonName is considered
+ fail(cert, 'California')
+
+ # Neither commonName nor subjectAltName
+ cert = {'notAfter': 'Dec 18 23:59:59 2011 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('organizationName', 'Google Inc'),))}
+ fail(cert, 'mail.google.com')
+
+ # No DNS entry in subjectAltName but a commonName
+ cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('commonName', 'mail.google.com'),)),
+ 'subjectAltName': (('othername', 'blabla'), )}
+ ok(cert, 'mail.google.com')
+
+ # No DNS entry subjectAltName and no commonName
+ cert = {'notAfter': 'Dec 18 23:59:59 2099 GMT',
+ 'subject': ((('countryName', 'US'),),
+ (('stateOrProvinceName', 'California'),),
+ (('localityName', 'Mountain View'),),
+ (('organizationName', 'Google Inc'),)),
+ 'subjectAltName': (('othername', 'blabla'),)}
+ fail(cert, 'google.com')
+
+ # Empty cert / no cert
+ self.assertRaises(ValueError, ssl.match_hostname, None, 'example.com')
+ self.assertRaises(ValueError, ssl.match_hostname, {}, 'example.com')
+
+ def test_server_side(self):
+ # server_hostname doesn't work for server sockets
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ with socket.socket() as sock:
+ self.assertRaises(ValueError, ctx.wrap_socket, sock, True,
+ server_hostname="some.hostname")
+
+class ContextTests(unittest.TestCase):
+
+ @skip_if_broken_ubuntu_ssl
+ def test_constructor(self):
+ if hasattr(ssl, 'PROTOCOL_SSLv2'):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv2)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv3)
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ self.assertRaises(TypeError, ssl.SSLContext)
+ self.assertRaises(ValueError, ssl.SSLContext, -1)
+ self.assertRaises(ValueError, ssl.SSLContext, 42)
+
+ @skip_if_broken_ubuntu_ssl
+ def test_protocol(self):
+ for proto in PROTOCOLS:
+ ctx = ssl.SSLContext(proto)
+ self.assertEqual(ctx.protocol, proto)
+
+ def test_ciphers(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.set_ciphers("ALL")
+ ctx.set_ciphers("DEFAULT")
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
+ ctx.set_ciphers("^$:,;?*'dorothyx")
+
+ @skip_if_broken_ubuntu_ssl
+ def test_options(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # OP_ALL is the default value
+ self.assertEqual(ssl.OP_ALL, ctx.options)
+ ctx.options |= ssl.OP_NO_SSLv2
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2,
+ ctx.options)
+ ctx.options |= ssl.OP_NO_SSLv3
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3,
+ ctx.options)
+ if can_clear_options():
+ ctx.options = (ctx.options & ~ssl.OP_NO_SSLv2) | ssl.OP_NO_TLSv1
+ self.assertEqual(ssl.OP_ALL | ssl.OP_NO_TLSv1 | ssl.OP_NO_SSLv3,
+ ctx.options)
+ ctx.options = 0
+ self.assertEqual(0, ctx.options)
+ else:
+ with self.assertRaises(ValueError):
+ ctx.options = 0
+
+ def test_verify(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # Default value
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ ctx.verify_mode = ssl.CERT_OPTIONAL
+ self.assertEqual(ctx.verify_mode, ssl.CERT_OPTIONAL)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ self.assertEqual(ctx.verify_mode, ssl.CERT_REQUIRED)
+ ctx.verify_mode = ssl.CERT_NONE
+ self.assertEqual(ctx.verify_mode, ssl.CERT_NONE)
+ with self.assertRaises(TypeError):
+ ctx.verify_mode = None
+ with self.assertRaises(ValueError):
+ ctx.verify_mode = 42
+
+ def test_load_cert_chain(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # Combined key and cert in a single file
+ ctx.load_cert_chain(CERTFILE)
+ ctx.load_cert_chain(CERTFILE, keyfile=CERTFILE)
+ self.assertRaises(TypeError, ctx.load_cert_chain, keyfile=CERTFILE)
+ with self.assertRaises(IOError) as cm:
+ ctx.load_cert_chain(WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(BADCERT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(EMPTYCERT)
+ # Separate key and cert
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.load_cert_chain(ONLYCERT, ONLYKEY)
+ ctx.load_cert_chain(certfile=ONLYCERT, keyfile=ONLYKEY)
+ ctx.load_cert_chain(certfile=BYTES_ONLYCERT, keyfile=BYTES_ONLYKEY)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(ONLYCERT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(ONLYKEY)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_cert_chain(certfile=ONLYKEY, keyfile=ONLYCERT)
+ # Mismatching key and cert
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ with self.assertRaisesRegex(ssl.SSLError, "key values mismatch"):
+ ctx.load_cert_chain(SVN_PYTHON_ORG_ROOT_CERT, ONLYKEY)
+
+ def test_load_verify_locations(self):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.load_verify_locations(CERTFILE)
+ ctx.load_verify_locations(cafile=CERTFILE, capath=None)
+ ctx.load_verify_locations(BYTES_CERTFILE)
+ ctx.load_verify_locations(cafile=BYTES_CERTFILE, capath=None)
+ self.assertRaises(TypeError, ctx.load_verify_locations)
+ self.assertRaises(TypeError, ctx.load_verify_locations, None, None)
+ with self.assertRaises(IOError) as cm:
+ ctx.load_verify_locations(WRONGCERT)
+ self.assertEqual(cm.exception.errno, errno.ENOENT)
+ with self.assertRaisesRegex(ssl.SSLError, "PEM lib"):
+ ctx.load_verify_locations(BADCERT)
+ ctx.load_verify_locations(CERTFILE, CAPATH)
+ ctx.load_verify_locations(CERTFILE, capath=BYTES_CAPATH)
+
+ # Issue #10989: crash if the second argument type is invalid
+ self.assertRaises(TypeError, ctx.load_verify_locations, None, True)
+
+ @skip_if_broken_ubuntu_ssl
+ def test_session_stats(self):
+ for proto in PROTOCOLS:
+ ctx = ssl.SSLContext(proto)
+ self.assertEqual(ctx.session_stats(), {
+ 'number': 0,
+ 'connect': 0,
+ 'connect_good': 0,
+ 'connect_renegotiate': 0,
+ 'accept': 0,
+ 'accept_good': 0,
+ 'accept_renegotiate': 0,
+ 'hits': 0,
+ 'misses': 0,
+ 'timeouts': 0,
+ 'cache_full': 0,
+ })
+
+ def test_set_default_verify_paths(self):
+ # There's not much we can do to test that it acts as expected,
+ # so just check it doesn't crash or raise an exception.
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.set_default_verify_paths()
+
class NetworkedTests(unittest.TestCase):
def test_connect(self):
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_NONE)
- s.connect(("svn.python.org", 443))
- c = s.getpeercert()
- if c:
- self.fail("Peer cert %s shouldn't be here!")
- s.close()
-
- # this should fail because we have no verification certs
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED)
try:
s.connect(("svn.python.org", 443))
- except ssl.SSLError:
- pass
+ self.assertEqual({}, s.getpeercert())
finally:
s.close()
+ # this should fail because we have no verification certs
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_REQUIRED)
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, ("svn.python.org", 443))
+ s.close()
+
# this should succeed because we specify the root cert
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
try:
s.connect(("svn.python.org", 443))
+ self.assertTrue(s.getpeercert())
finally:
s.close()
def test_connect_ex(self):
# Issue #11326: check connect_ex() implementation
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
@@ -251,7 +512,7 @@ class NetworkedTests(unittest.TestCase):
def test_non_blocking_connect_ex(self):
# Issue #11326: non-blocking connect_ex() should allow handshake
# to proceed after the socket gets ready.
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT,
@@ -283,7 +544,7 @@ class NetworkedTests(unittest.TestCase):
def test_timeout_connect_ex(self):
# Issue #12065: on a timeout, connect_ex() should return the original
# errno (mimicking the behaviour of non-SSL sockets).
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT,
@@ -298,7 +559,7 @@ class NetworkedTests(unittest.TestCase):
s.close()
def test_connect_ex_error(self):
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = ssl.wrap_socket(socket.socket(socket.AF_INET),
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
@@ -308,12 +569,75 @@ class NetworkedTests(unittest.TestCase):
finally:
s.close()
+ def test_connect_with_context(self):
+ with support.transient_internet("svn.python.org"):
+ # Same as test_connect, but with a separately created context
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ self.assertEqual({}, s.getpeercert())
+ finally:
+ s.close()
+ # Same with a server hostname
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="svn.python.org")
+ if ssl.HAS_SNI:
+ s.connect(("svn.python.org", 443))
+ s.close()
+ else:
+ self.assertRaises(ValueError, s.connect, ("svn.python.org", 443))
+ # This should fail because we have no verification certs
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ self.assertRaisesRegex(ssl.SSLError, "certificate verify failed",
+ s.connect, ("svn.python.org", 443))
+ s.close()
+ # This should succeed because we specify the root cert
+ ctx.load_verify_locations(SVN_PYTHON_ORG_ROOT_CERT)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ finally:
+ s.close()
+
+ def test_connect_capath(self):
+ # Verify server certificates using the `capath` argument
+ # NOTE: the subject hashing algorithm has been changed between
+ # OpenSSL 0.9.8n and 1.0.0, as a result the capath directory must
+ # contain both versions of each certificate (same content, different
+ # filename) for this test to be portable across OpenSSL releases.
+ with support.transient_internet("svn.python.org"):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=CAPATH)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ finally:
+ s.close()
+ # Same with a bytes `capath` argument
+ ctx = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(capath=BYTES_CAPATH)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET))
+ s.connect(("svn.python.org", 443))
+ try:
+ cert = s.getpeercert()
+ self.assertTrue(cert)
+ finally:
+ s.close()
+
@unittest.skipIf(os.name == "nt", "Can't use a socket as a file under Windows")
def test_makefile_close(self):
# Issue #5238: creating a file-like object with makefile() shouldn't
# delay closing the underlying "real socket" (here tested with its
# file descriptor, hence skipping the test under Windows).
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
ss = ssl.wrap_socket(socket.socket(socket.AF_INET))
ss.connect(("svn.python.org", 443))
fd = ss.fileno()
@@ -329,7 +653,7 @@ class NetworkedTests(unittest.TestCase):
self.assertEqual(e.exception.errno, errno.EBADF)
def test_non_blocking_handshake(self):
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
s = socket.socket(socket.AF_INET)
s.connect(("svn.python.org", 443))
s.setblocking(False)
@@ -342,7 +666,7 @@ class NetworkedTests(unittest.TestCase):
count += 1
s.do_handshake()
break
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] == ssl.SSL_ERROR_WANT_READ:
select.select([s], [], [])
elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE:
@@ -350,46 +674,67 @@ class NetworkedTests(unittest.TestCase):
else:
raise
s.close()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count)
def test_get_server_certificate(self):
- with test_support.transient_internet("svn.python.org"):
+ with support.transient_internet("svn.python.org"):
pem = ssl.get_server_certificate(("svn.python.org", 443))
if not pem:
self.fail("No server certificate on svn.python.org:443!")
try:
pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE)
- except ssl.SSLError:
+ except ssl.SSLError as x:
#should fail
- pass
+ if support.verbose:
+ sys.stdout.write("%s\n" % x)
else:
self.fail("Got server certificate %s for svn.python.org!" % pem)
pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT)
if not pem:
self.fail("No server certificate on svn.python.org:443!")
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem)
+ def test_ciphers(self):
+ remote = ("svn.python.org", 443)
+ with support.transient_internet(remote[0]):
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="ALL")
+ s.connect(remote)
+ s = ssl.wrap_socket(socket.socket(socket.AF_INET),
+ cert_reqs=ssl.CERT_NONE, ciphers="DEFAULT")
+ s.connect(remote)
+ # Error checking can happen at instantiation or when connecting
+ with self.assertRaisesRegex(ssl.SSLError, "No cipher can be selected"):
+ with socket.socket(socket.AF_INET) as sock:
+ s = ssl.wrap_socket(sock,
+ cert_reqs=ssl.CERT_NONE, ciphers="^$:,;?*'dorothyx")
+ s.connect(remote)
+
def test_algorithms(self):
# Issue #8484: all algorithms should be available when verifying a
# certificate.
# SHA256 was added in OpenSSL 0.9.8
if ssl.OPENSSL_VERSION_INFO < (0, 9, 8, 0, 15):
self.skipTest("SHA256 not available on %r" % ssl.OPENSSL_VERSION)
- self.skipTest("remote host needs SNI, only available on Python 3.2+")
- # NOTE: https://sha2.hboeck.de is another possible test host
+ # sha256.tbs-internet.com needs SNI to use the correct certificate
+ if not ssl.HAS_SNI:
+ self.skipTest("SNI needed for this test")
+ # https://sha2.hboeck.de/ was used until 2011-01-08 (no route to host)
remote = ("sha256.tbs-internet.com", 443)
sha256_cert = os.path.join(os.path.dirname(__file__), "sha256.pem")
- with test_support.transient_internet("sha256.tbs-internet.com"):
- s = ssl.wrap_socket(socket.socket(socket.AF_INET),
- cert_reqs=ssl.CERT_REQUIRED,
- ca_certs=sha256_cert,)
+ with support.transient_internet("sha256.tbs-internet.com"):
+ ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ ctx.verify_mode = ssl.CERT_REQUIRED
+ ctx.load_verify_locations(sha256_cert)
+ s = ctx.wrap_socket(socket.socket(socket.AF_INET),
+ server_hostname="sha256.tbs-internet.com")
try:
s.connect(remote)
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\nCipher with %r is %r\n" %
(remote, s.cipher()))
sys.stdout.write("Certificate is:\n%s\n" %
@@ -405,6 +750,8 @@ except ImportError:
else:
_have_threads = True
+ from test.ssl_servers import make_https_server
+
class ThreadedEchoServer(threading.Thread):
class ConnectionHandler(threading.Thread):
@@ -413,48 +760,42 @@ else:
with and without the SSL wrapper around the socket connection, so
that we can test the STARTTLS functionality."""
- def __init__(self, server, connsock):
+ def __init__(self, server, connsock, addr):
self.server = server
self.running = False
self.sock = connsock
+ self.addr = addr
self.sock.setblocking(1)
self.sslconn = None
threading.Thread.__init__(self)
self.daemon = True
- def show_conn_details(self):
- if self.server.certreqs == ssl.CERT_REQUIRED:
- cert = self.sslconn.getpeercert()
- if test_support.verbose and self.server.chatty:
- sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
- cert_binary = self.sslconn.getpeercert(True)
- if test_support.verbose and self.server.chatty:
- sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n")
- cipher = self.sslconn.cipher()
- if test_support.verbose and self.server.chatty:
- sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n")
-
def wrap_conn(self):
try:
- self.sslconn = ssl.wrap_socket(self.sock, server_side=True,
- certfile=self.server.certificate,
- ssl_version=self.server.protocol,
- ca_certs=self.server.cacerts,
- cert_reqs=self.server.certreqs,
- ciphers=self.server.ciphers)
+ self.sslconn = self.server.context.wrap_socket(
+ self.sock, server_side=True)
except ssl.SSLError as e:
# XXX Various errors can have happened here, for example
# a mismatching protocol version, an invalid certificate,
# or a low-level bug. This should be made more discriminating.
self.server.conn_errors.append(e)
if self.server.chatty:
- handle_error("\n server: bad connection attempt from " +
- str(self.sock.getpeername()) + ":\n")
- self.close()
+ handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n")
self.running = False
self.server.stop()
+ self.close()
return False
else:
+ if self.server.context.verify_mode == ssl.CERT_REQUIRED:
+ cert = self.sslconn.getpeercert()
+ if support.verbose and self.server.chatty:
+ sys.stdout.write(" client cert is " + pprint.pformat(cert) + "\n")
+ cert_binary = self.sslconn.getpeercert(True)
+ if support.verbose and self.server.chatty:
+ sys.stdout.write(" cert binary is " + str(len(cert_binary)) + " bytes\n")
+ cipher = self.sslconn.cipher()
+ if support.verbose and self.server.chatty:
+ sys.stdout.write(" server: connection cipher is now " + str(cipher) + "\n")
return True
def read(self):
@@ -473,50 +814,50 @@ else:
if self.sslconn:
self.sslconn.close()
else:
- self.sock._sock.close()
+ self.sock.close()
def run(self):
self.running = True
if not self.server.starttls_server:
- if isinstance(self.sock, ssl.SSLSocket):
- self.sslconn = self.sock
- elif not self.wrap_conn():
+ if not self.wrap_conn():
return
- self.show_conn_details()
while self.running:
try:
msg = self.read()
- if not msg:
+ stripped = msg.strip()
+ if not stripped:
# eof, so quit this handler
self.running = False
self.close()
- elif msg.strip() == 'over':
- if test_support.verbose and self.server.connectionchatty:
+ elif stripped == b'over':
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: client closed connection\n")
self.close()
return
- elif self.server.starttls_server and msg.strip() == 'STARTTLS':
- if test_support.verbose and self.server.connectionchatty:
+ elif (self.server.starttls_server and
+ stripped == b'STARTTLS'):
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: read STARTTLS from client, sending OK...\n")
- self.write("OK\n")
+ self.write(b"OK\n")
if not self.wrap_conn():
return
- elif self.server.starttls_server and self.sslconn and msg.strip() == 'ENDTLS':
- if test_support.verbose and self.server.connectionchatty:
+ elif (self.server.starttls_server and self.sslconn
+ and stripped == b'ENDTLS'):
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: read ENDTLS from client, sending OK...\n")
- self.write("OK\n")
- self.sslconn.unwrap()
+ self.write(b"OK\n")
+ self.sock = self.sslconn.unwrap()
self.sslconn = None
- if test_support.verbose and self.server.connectionchatty:
+ if support.verbose and self.server.connectionchatty:
sys.stdout.write(" server: connection is now unencrypted...\n")
else:
- if (test_support.verbose and
+ if (support.verbose and
self.server.connectionchatty):
ctype = (self.sslconn and "encrypted") or "unencrypted"
- sys.stdout.write(" server: read %s (%s), sending back %s (%s)...\n"
- % (repr(msg), ctype, repr(msg.lower()), ctype))
+ sys.stdout.write(" server: read %r (%s), sending back %r (%s)...\n"
+ % (msg, ctype, msg.lower(), ctype))
self.write(msg.lower())
- except ssl.SSLError:
+ except socket.error:
if self.server.chatty:
handle_error("Test server failure:\n")
self.close()
@@ -525,35 +866,30 @@ else:
# harness, we want to stop the server
self.server.stop()
- def __init__(self, certificate, ssl_version=None,
+ def __init__(self, certificate=None, ssl_version=None,
certreqs=None, cacerts=None,
chatty=True, connectionchatty=False, starttls_server=False,
- wrap_accepting_socket=False, ciphers=None):
-
- if ssl_version is None:
- ssl_version = ssl.PROTOCOL_TLSv1
- if certreqs is None:
- certreqs = ssl.CERT_NONE
- self.certificate = certificate
- self.protocol = ssl_version
- self.certreqs = certreqs
- self.cacerts = cacerts
- self.ciphers = ciphers
+ ciphers=None, context=None):
+ if context:
+ self.context = context
+ else:
+ self.context = ssl.SSLContext(ssl_version
+ if ssl_version is not None
+ else ssl.PROTOCOL_TLSv1)
+ self.context.verify_mode = (certreqs if certreqs is not None
+ else ssl.CERT_NONE)
+ if cacerts:
+ self.context.load_verify_locations(cacerts)
+ if certificate:
+ self.context.load_cert_chain(certificate)
+ if ciphers:
+ self.context.set_ciphers(ciphers)
self.chatty = chatty
self.connectionchatty = connectionchatty
self.starttls_server = starttls_server
self.sock = socket.socket()
+ self.port = support.bind_port(self.sock)
self.flag = None
- if wrap_accepting_socket:
- self.sock = ssl.wrap_socket(self.sock, server_side=True,
- certfile=self.certificate,
- cert_reqs = self.certreqs,
- ca_certs = self.cacerts,
- ssl_version = self.protocol,
- ciphers = self.ciphers)
- if test_support.verbose and self.chatty:
- sys.stdout.write(' server: wrapped server socket as %s\n' % str(self.sock))
- self.port = test_support.bind_port(self.sock)
self.active = False
self.conn_errors = []
threading.Thread.__init__(self)
@@ -582,10 +918,10 @@ else:
while self.active:
try:
newconn, connaddr = self.sock.accept()
- if test_support.verbose and self.chatty:
+ if support.verbose and self.chatty:
sys.stdout.write(' server: new connection from '
- + str(connaddr) + '\n')
- handler = self.ConnectionHandler(self, newconn)
+ + repr(connaddr) + '\n')
+ handler = self.ConnectionHandler(self, newconn, connaddr)
handler.start()
handler.join()
except socket.timeout:
@@ -599,16 +935,19 @@ else:
class AsyncoreEchoServer(threading.Thread):
- class EchoServer(asyncore.dispatcher):
+ # this one's based on asyncore.dispatcher
- class ConnectionHandler(asyncore.dispatcher_with_send):
+ class EchoServer (asyncore.dispatcher):
+
+ class ConnectionHandler (asyncore.dispatcher_with_send):
def __init__(self, conn, certfile):
- asyncore.dispatcher_with_send.__init__(self, conn)
self.socket = ssl.wrap_socket(conn, server_side=True,
certfile=certfile,
do_handshake_on_connect=False)
+ asyncore.dispatcher_with_send.__init__(self, self.socket)
self._ssl_accepting = True
+ self._do_ssl_handshake()
def readable(self):
if isinstance(self.socket, ssl.SSLSocket):
@@ -619,14 +958,14 @@ else:
def _do_ssl_handshake(self):
try:
self.socket.do_handshake()
- except ssl.SSLError, err:
+ except ssl.SSLError as err:
if err.args[0] in (ssl.SSL_ERROR_WANT_READ,
ssl.SSL_ERROR_WANT_WRITE):
return
elif err.args[0] == ssl.SSL_ERROR_EOF:
return self.handle_close()
raise
- except socket.error, err:
+ except socket.error as err:
if err.args[0] == errno.ECONNABORTED:
return self.handle_close()
else:
@@ -637,12 +976,16 @@ else:
self._do_ssl_handshake()
else:
data = self.recv(1024)
- if data and data.strip() != 'over':
+ if support.verbose:
+ sys.stdout.write(" server: read %s from client\n" % repr(data))
+ if not data:
+ self.close()
+ else:
self.send(data.lower())
def handle_close(self):
self.close()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" server: closed connection %s\n" % self.socket)
def handle_error(self):
@@ -650,14 +993,13 @@ else:
def __init__(self, certfile):
self.certfile = certfile
- asyncore.dispatcher.__init__(self)
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
- self.port = test_support.bind_port(self.socket)
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.port = support.bind_port(sock, '')
+ asyncore.dispatcher.__init__(self, sock)
self.listen(5)
- def handle_accept(self):
- sock_obj, addr = self.accept()
- if test_support.verbose:
+ def handle_accepted(self, sock_obj, addr):
+ if support.verbose:
sys.stdout.write(" server: new connection from %s:%s\n" %addr)
self.ConnectionHandler(sock_obj, self.certfile)
@@ -681,16 +1023,16 @@ else:
return self
def __exit__(self, *args):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" cleanup: stopping server.\n")
self.stop()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" cleanup: joining server thread.\n")
self.join()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(" cleanup: successfully joined.\n")
- def start(self, flag=None):
+ def start (self, flag=None):
self.flag = flag
threading.Thread.start(self)
@@ -699,103 +1041,15 @@ else:
if self.flag:
self.flag.set()
while self.active:
- asyncore.loop(0.05)
+ try:
+ asyncore.loop(1)
+ except:
+ pass
def stop(self):
self.active = False
self.server.close()
- class SocketServerHTTPSServer(threading.Thread):
-
- class HTTPSServer(HTTPServer):
-
- def __init__(self, server_address, RequestHandlerClass, certfile):
- HTTPServer.__init__(self, server_address, RequestHandlerClass)
- # we assume the certfile contains both private key and certificate
- self.certfile = certfile
- self.allow_reuse_address = True
-
- def __str__(self):
- return ('<%s %s:%s>' %
- (self.__class__.__name__,
- self.server_name,
- self.server_port))
-
- def get_request(self):
- # override this to wrap socket with SSL
- sock, addr = self.socket.accept()
- sslconn = ssl.wrap_socket(sock, server_side=True,
- certfile=self.certfile)
- return sslconn, addr
-
- class RootedHTTPRequestHandler(SimpleHTTPRequestHandler):
- # need to override translate_path to get a known root,
- # instead of using os.curdir, since the test could be
- # run from anywhere
-
- server_version = "TestHTTPS/1.0"
-
- root = None
-
- def translate_path(self, path):
- """Translate a /-separated PATH to the local filename syntax.
-
- Components that mean special things to the local file system
- (e.g. drive or directory names) are ignored. (XXX They should
- probably be diagnosed.)
-
- """
- # abandon query parameters
- path = urlparse.urlparse(path)[2]
- path = os.path.normpath(urllib.unquote(path))
- words = path.split('/')
- words = filter(None, words)
- path = self.root
- for word in words:
- drive, word = os.path.splitdrive(word)
- head, word = os.path.split(word)
- if word in self.root: continue
- path = os.path.join(path, word)
- return path
-
- def log_message(self, format, *args):
-
- # we override this to suppress logging unless "verbose"
-
- if test_support.verbose:
- sys.stdout.write(" server (%s:%d %s):\n [%s] %s\n" %
- (self.server.server_address,
- self.server.server_port,
- self.request.cipher(),
- self.log_date_time_string(),
- format%args))
-
-
- def __init__(self, certfile):
- self.flag = None
- self.RootedHTTPRequestHandler.root = os.path.split(CERTFILE)[0]
- self.server = self.HTTPSServer(
- (HOST, 0), self.RootedHTTPRequestHandler, certfile)
- self.port = self.server.server_port
- threading.Thread.__init__(self)
- self.daemon = True
-
- def __str__(self):
- return "<%s %s>" % (self.__class__.__name__, self.server)
-
- def start(self, flag=None):
- self.flag = flag
- threading.Thread.start(self)
-
- def run(self):
- if self.flag:
- self.flag.set()
- self.server.serve_forever(0.05)
-
- def stop(self):
- self.server.shutdown()
-
-
def bad_cert_test(certfile):
"""
Launch a server with CERT_REQUIRED, and check that trying to
@@ -803,74 +1057,64 @@ else:
"""
server = ThreadedEchoServer(CERTFILE,
certreqs=ssl.CERT_REQUIRED,
- cacerts=CERTFILE, chatty=False)
+ cacerts=CERTFILE, chatty=False,
+ connectionchatty=False)
with server:
try:
- s = ssl.wrap_socket(socket.socket(),
- certfile=certfile,
- ssl_version=ssl.PROTOCOL_TLSv1)
- s.connect((HOST, server.port))
- except ssl.SSLError, x:
- if test_support.verbose:
- sys.stdout.write("\nSSLError is %s\n" % x[1])
- except socket.error, x:
- if test_support.verbose:
- sys.stdout.write("\nsocket.error is %s\n" % x[1])
+ with socket.socket() as sock:
+ s = ssl.wrap_socket(sock,
+ certfile=certfile,
+ ssl_version=ssl.PROTOCOL_TLSv1)
+ s.connect((HOST, server.port))
+ except ssl.SSLError as x:
+ if support.verbose:
+ sys.stdout.write("\nSSLError is %s\n" % x.args[1])
+ except socket.error as x:
+ if support.verbose:
+ sys.stdout.write("\nsocket.error is %s\n" % x.args[1])
+ except IOError as x:
+ if x.errno != errno.ENOENT:
+ raise
+ if support.verbose:
+ sys.stdout.write("\IOError is %s\n" % str(x))
else:
raise AssertionError("Use of invalid cert should have failed!")
- def server_params_test(certfile, protocol, certreqs, cacertsfile,
- client_certfile, client_protocol=None, indata="FOO\n",
- ciphers=None, chatty=True, connectionchatty=False,
- wrap_accepting_socket=False):
+ def server_params_test(client_context, server_context, indata=b"FOO\n",
+ chatty=True, connectionchatty=False):
"""
Launch a server, connect a client to it and try various reads
and writes.
"""
- server = ThreadedEchoServer(certfile,
- certreqs=certreqs,
- ssl_version=protocol,
- cacerts=cacertsfile,
- ciphers=ciphers,
+ server = ThreadedEchoServer(context=server_context,
chatty=chatty,
- connectionchatty=connectionchatty,
- wrap_accepting_socket=wrap_accepting_socket)
+ connectionchatty=False)
with server:
- # try to connect
- if client_protocol is None:
- client_protocol = protocol
- s = ssl.wrap_socket(socket.socket(),
- certfile=client_certfile,
- ca_certs=cacertsfile,
- ciphers=ciphers,
- cert_reqs=certreqs,
- ssl_version=client_protocol)
- s.connect((HOST, server.port))
- for arg in [indata, bytearray(indata), memoryview(indata)]:
- if connectionchatty:
- if test_support.verbose:
- sys.stdout.write(
- " client: sending %s...\n" % (repr(arg)))
- s.write(arg)
- outdata = s.read()
+ with client_context.wrap_socket(socket.socket()) as s:
+ s.connect((HOST, server.port))
+ for arg in [indata, bytearray(indata), memoryview(indata)]:
+ if connectionchatty:
+ if support.verbose:
+ sys.stdout.write(
+ " client: sending %r...\n" % indata)
+ s.write(arg)
+ outdata = s.read()
+ if connectionchatty:
+ if support.verbose:
+ sys.stdout.write(" client: read %r\n" % outdata)
+ if outdata != indata.lower():
+ raise AssertionError(
+ "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
+ % (outdata[:20], len(outdata),
+ indata[:20].lower(), len(indata)))
+ s.write(b"over\n")
if connectionchatty:
- if test_support.verbose:
- sys.stdout.write(" client: read %s\n" % repr(outdata))
- if outdata != indata.lower():
- raise AssertionError(
- "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n"
- % (outdata[:min(len(outdata),20)], len(outdata),
- indata[:min(len(indata),20)].lower(), len(indata)))
- s.write("over\n")
- if connectionchatty:
- if test_support.verbose:
- sys.stdout.write(" client: closing connection.\n")
- s.close()
+ if support.verbose:
+ sys.stdout.write(" client: closing connection.\n")
+ s.close()
- def try_protocol_combo(server_protocol,
- client_protocol,
- expect_success,
- certsreqs=None):
+ def try_protocol_combo(server_protocol, client_protocol, expect_success,
+ certsreqs=None, server_options=0, client_options=0):
if certsreqs is None:
certsreqs = ssl.CERT_NONE
certtype = {
@@ -878,19 +1122,27 @@ else:
ssl.CERT_OPTIONAL: "CERT_OPTIONAL",
ssl.CERT_REQUIRED: "CERT_REQUIRED",
}[certsreqs]
- if test_support.verbose:
+ if support.verbose:
formatstr = (expect_success and " %s->%s %s\n") or " {%s->%s} %s\n"
sys.stdout.write(formatstr %
(ssl.get_protocol_name(client_protocol),
ssl.get_protocol_name(server_protocol),
certtype))
- try:
+ client_context = ssl.SSLContext(client_protocol)
+ client_context.options = ssl.OP_ALL | client_options
+ server_context = ssl.SSLContext(server_protocol)
+ server_context.options = ssl.OP_ALL | server_options
+ for ctx in (client_context, server_context):
+ ctx.verify_mode = certsreqs
# NOTE: we must enable "ALL" ciphers, otherwise an SSLv23 client
# will send an SSLv3 hello (rather than SSLv2) starting from
# OpenSSL 1.0.0 (see issue #8322).
- server_params_test(CERTFILE, server_protocol, certsreqs,
- CERTFILE, CERTFILE, client_protocol,
- ciphers="ALL", chatty=False)
+ ctx.set_ciphers("ALL")
+ ctx.load_cert_chain(CERTFILE)
+ ctx.load_verify_locations(CERTFILE)
+ try:
+ server_params_test(client_context, server_context,
+ chatty=False, connectionchatty=False)
# Protocol mismatch can result in either an SSLError, or a
# "Connection reset by peer" error.
except ssl.SSLError:
@@ -909,75 +1161,32 @@ else:
class ThreadedTests(unittest.TestCase):
- def test_rude_shutdown(self):
- """A brutal shutdown of an SSL server should raise an IOError
- in the client when attempting handshake.
- """
- listener_ready = threading.Event()
- listener_gone = threading.Event()
-
- s = socket.socket()
- port = test_support.bind_port(s, HOST)
-
- # `listener` runs in a thread. It sits in an accept() until
- # the main thread connects. Then it rudely closes the socket,
- # and sets Event `listener_gone` to let the main thread know
- # the socket is gone.
- def listener():
- s.listen(5)
- listener_ready.set()
- s.accept()
- s.close()
- listener_gone.set()
-
- def connector():
- listener_ready.wait()
- c = socket.socket()
- c.connect((HOST, port))
- listener_gone.wait()
- try:
- ssl_sock = ssl.wrap_socket(c)
- except IOError:
- pass
- else:
- self.fail('connecting to closed SSL socket should have failed')
-
- t = threading.Thread(target=listener)
- t.start()
- try:
- connector()
- finally:
- t.join()
-
@skip_if_broken_ubuntu_ssl
def test_echo(self):
"""Basic test of an SSL client connecting to a server"""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
- server_params_test(CERTFILE, ssl.PROTOCOL_TLSv1, ssl.CERT_NONE,
- CERTFILE, CERTFILE, ssl.PROTOCOL_TLSv1,
- chatty=True, connectionchatty=True)
+ for protocol in PROTOCOLS:
+ context = ssl.SSLContext(protocol)
+ context.load_cert_chain(CERTFILE)
+ server_params_test(context, context,
+ chatty=True, connectionchatty=True)
def test_getpeercert(self):
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
- s2 = socket.socket()
- server = ThreadedEchoServer(CERTFILE,
- certreqs=ssl.CERT_NONE,
- ssl_version=ssl.PROTOCOL_SSLv23,
- cacerts=CERTFILE,
- chatty=False)
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERTFILE)
+ context.load_cert_chain(CERTFILE)
+ server = ThreadedEchoServer(context=context, chatty=False)
with server:
- s = ssl.wrap_socket(socket.socket(),
- certfile=CERTFILE,
- ca_certs=CERTFILE,
- cert_reqs=ssl.CERT_REQUIRED,
- ssl_version=ssl.PROTOCOL_SSLv23)
+ s = context.wrap_socket(socket.socket())
s.connect((HOST, server.port))
cert = s.getpeercert()
self.assertTrue(cert, "Can't get peer certificate.")
cipher = s.cipher()
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(pprint.pformat(cert) + '\n')
sys.stdout.write("Connection cipher is " + str(cipher) + '.\n')
if 'subject' not in cert:
@@ -988,6 +1197,11 @@ else:
self.fail(
"Missing or invalid 'organizationName' field in certificate subject; "
"should be 'Python Software Foundation'.")
+ self.assertIn('notBefore', cert)
+ self.assertIn('notAfter', cert)
+ before = ssl.cert_time_to_seconds(cert['notBefore'])
+ after = ssl.cert_time_to_seconds(cert['notAfter'])
+ self.assertLess(before, after)
s.close()
def test_empty_cert(self):
@@ -1007,25 +1221,83 @@ else:
bad_cert_test(os.path.join(os.path.dirname(__file__) or os.curdir,
"badkey.pem"))
+ def test_rude_shutdown(self):
+ """A brutal shutdown of an SSL server should raise an IOError
+ in the client when attempting handshake.
+ """
+ listener_ready = threading.Event()
+ listener_gone = threading.Event()
+
+ s = socket.socket()
+ port = support.bind_port(s, HOST)
+
+ # `listener` runs in a thread. It sits in an accept() until
+ # the main thread connects. Then it rudely closes the socket,
+ # and sets Event `listener_gone` to let the main thread know
+ # the socket is gone.
+ def listener():
+ s.listen(5)
+ listener_ready.set()
+ newsock, addr = s.accept()
+ newsock.close()
+ s.close()
+ listener_gone.set()
+
+ def connector():
+ listener_ready.wait()
+ with socket.socket() as c:
+ c.connect((HOST, port))
+ listener_gone.wait()
+ try:
+ ssl_sock = ssl.wrap_socket(c)
+ except IOError:
+ pass
+ else:
+ self.fail('connecting to closed SSL socket should have failed')
+
+ t = threading.Thread(target=listener)
+ t.start()
+ try:
+ connector()
+ finally:
+ t.join()
+
@skip_if_broken_ubuntu_ssl
+ @unittest.skipUnless(hasattr(ssl, 'PROTOCOL_SSLv2'), "need SSLv2")
def test_protocol_sslv2(self):
"""Connecting to an SSLv2 server with various client options"""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
- if not hasattr(ssl, 'PROTOCOL_SSLv2'):
- self.skipTest("PROTOCOL_SSLv2 needed")
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_OPTIONAL)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True, ssl.CERT_REQUIRED)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv3, False)
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_TLSv1, False)
+ # SSLv23 client with specific SSL options
+ if no_sslv2_implies_sslv3_hello():
+ # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, False,
+ client_options=ssl.OP_NO_SSLv2)
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_SSLv3)
+ try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_TLSv1)
@skip_if_broken_ubuntu_ssl
def test_protocol_sslv23(self):
"""Connecting to an SSLv23 server with various client options"""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
+ if hasattr(ssl, 'PROTOCOL_SSLv2'):
+ try:
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv2, True)
+ except (ssl.SSLError, socket.error) as x:
+ # this fails on some older versions of OpenSSL (0.9.7l, for instance)
+ if support.verbose:
+ sys.stdout.write(
+ " SSL2 client to SSL23 server test unexpectedly failed:\n %s\n"
+ % str(x))
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, True)
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True)
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True)
@@ -1038,22 +1310,38 @@ else:
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True, ssl.CERT_REQUIRED)
try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, True, ssl.CERT_REQUIRED)
+ # Server with specific SSL options
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv3, False,
+ server_options=ssl.OP_NO_SSLv3)
+ # Will choose TLSv1
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_SSLv23, True,
+ server_options=ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3)
+ try_protocol_combo(ssl.PROTOCOL_SSLv23, ssl.PROTOCOL_TLSv1, False,
+ server_options=ssl.OP_NO_TLSv1)
+
+
@skip_if_broken_ubuntu_ssl
def test_protocol_sslv3(self):
"""Connecting to an SSLv3 server with various client options"""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_OPTIONAL)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv3, True, ssl.CERT_REQUIRED)
if hasattr(ssl, 'PROTOCOL_SSLv2'):
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv2, False)
+ try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, False,
+ client_options=ssl.OP_NO_SSLv3)
try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_TLSv1, False)
+ if no_sslv2_implies_sslv3_hello():
+ # No SSLv2 => client will use an SSLv3 hello on recent OpenSSLs
+ try_protocol_combo(ssl.PROTOCOL_SSLv3, ssl.PROTOCOL_SSLv23, True,
+ client_options=ssl.OP_NO_SSLv2)
@skip_if_broken_ubuntu_ssl
def test_protocol_tlsv1(self):
"""Connecting to a TLSv1 server with various client options"""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True)
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_TLSv1, True, ssl.CERT_OPTIONAL)
@@ -1061,10 +1349,12 @@ else:
if hasattr(ssl, 'PROTOCOL_SSLv2'):
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv2, False)
try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv3, False)
+ try_protocol_combo(ssl.PROTOCOL_TLSv1, ssl.PROTOCOL_SSLv23, False,
+ client_options=ssl.OP_NO_TLSv1)
def test_starttls(self):
"""Switching from clear text to encrypted and back again."""
- msgs = ("msg 1", "MSG 2", "STARTTLS", "MSG 3", "msg 4", "ENDTLS", "msg 5", "msg 6")
+ msgs = (b"msg 1", b"MSG 2", b"STARTTLS", b"MSG 3", b"msg 4", b"ENDTLS", b"msg 5", b"msg 6")
server = ThreadedEchoServer(CERTFILE,
ssl_version=ssl.PROTOCOL_TLSv1,
@@ -1076,119 +1366,109 @@ else:
s = socket.socket()
s.setblocking(1)
s.connect((HOST, server.port))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
for indata in msgs:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
- " client: sending %s...\n" % repr(indata))
+ " client: sending %r...\n" % indata)
if wrapped:
conn.write(indata)
outdata = conn.read()
else:
s.send(indata)
outdata = s.recv(1024)
- if (indata == "STARTTLS" and
- outdata.strip().lower().startswith("ok")):
+ msg = outdata.strip().lower()
+ if indata == b"STARTTLS" and msg.startswith(b"ok"):
# STARTTLS ok, switch to secure mode
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
- " client: read %s from server, starting TLS...\n"
- % repr(outdata))
+ " client: read %r from server, starting TLS...\n"
+ % msg)
conn = ssl.wrap_socket(s, ssl_version=ssl.PROTOCOL_TLSv1)
wrapped = True
- elif (indata == "ENDTLS" and
- outdata.strip().lower().startswith("ok")):
+ elif indata == b"ENDTLS" and msg.startswith(b"ok"):
# ENDTLS ok, switch back to clear text
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
- " client: read %s from server, ending TLS...\n"
- % repr(outdata))
+ " client: read %r from server, ending TLS...\n"
+ % msg)
s = conn.unwrap()
wrapped = False
else:
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
- " client: read %s from server\n" % repr(outdata))
- if test_support.verbose:
+ " client: read %r from server\n" % msg)
+ if support.verbose:
sys.stdout.write(" client: closing connection.\n")
if wrapped:
- conn.write("over\n")
+ conn.write(b"over\n")
else:
- s.send("over\n")
- s.close()
+ s.send(b"over\n")
+ if wrapped:
+ conn.close()
+ else:
+ s.close()
def test_socketserver(self):
"""Using a SocketServer to create and manage SSL connections."""
- server = SocketServerHTTPSServer(CERTFILE)
- flag = threading.Event()
- server.start(flag)
- # wait for it to start
- flag.wait()
+ server = make_https_server(self, CERTFILE)
# try to connect
+ if support.verbose:
+ sys.stdout.write('\n')
+ with open(CERTFILE, 'rb') as f:
+ d1 = f.read()
+ d2 = ''
+ # now fetch the same data from the HTTPS server
+ url = 'https://%s:%d/%s' % (
+ HOST, server.port, os.path.split(CERTFILE)[1])
+ f = urllib.request.urlopen(url)
try:
- if test_support.verbose:
- sys.stdout.write('\n')
- with open(CERTFILE, 'rb') as f:
- d1 = f.read()
- d2 = ''
- # now fetch the same data from the HTTPS server
- url = 'https://127.0.0.1:%d/%s' % (
- server.port, os.path.split(CERTFILE)[1])
- with test_support.check_py3k_warnings():
- f = urllib.urlopen(url)
- dlen = f.info().getheader("content-length")
+ dlen = f.info().get("content-length")
if dlen and (int(dlen) > 0):
d2 = f.read(int(dlen))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
" client: read %d bytes from remote server '%s'\n"
% (len(d2), server))
- f.close()
- self.assertEqual(d1, d2)
finally:
- server.stop()
- server.join()
-
- def test_wrapped_accept(self):
- """Check the accept() method on SSL sockets."""
- if test_support.verbose:
- sys.stdout.write("\n")
- server_params_test(CERTFILE, ssl.PROTOCOL_SSLv23, ssl.CERT_REQUIRED,
- CERTFILE, CERTFILE, ssl.PROTOCOL_SSLv23,
- chatty=True, connectionchatty=True,
- wrap_accepting_socket=True)
+ f.close()
+ self.assertEqual(d1, d2)
def test_asyncore_server(self):
"""Check the example asyncore integration."""
indata = "TEST MESSAGE of mixed case\n"
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
+
+ indata = b"FOO\n"
server = AsyncoreEchoServer(CERTFILE)
with server:
s = ssl.wrap_socket(socket.socket())
s.connect(('127.0.0.1', server.port))
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write(
- " client: sending %s...\n" % (repr(indata)))
+ " client: sending %r...\n" % indata)
s.write(indata)
outdata = s.read()
- if test_support.verbose:
- sys.stdout.write(" client: read %s\n" % repr(outdata))
+ if support.verbose:
+ sys.stdout.write(" client: read %r\n" % outdata)
if outdata != indata.lower():
self.fail(
- "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n"
- % (outdata[:min(len(outdata),20)], len(outdata),
- indata[:min(len(indata),20)].lower(), len(indata)))
- s.write("over\n")
- if test_support.verbose:
+ "bad data <<%r>> (%d) received; expected <<%r>> (%d)\n"
+ % (outdata[:20], len(outdata),
+ indata[:20].lower(), len(indata)))
+ s.write(b"over\n")
+ if support.verbose:
sys.stdout.write(" client: closing connection.\n")
s.close()
+ if support.verbose:
+ sys.stdout.write(" client: connection closed.\n")
def test_recv_send(self):
"""Test recv(), send() and friends."""
- if test_support.verbose:
+ if support.verbose:
sys.stdout.write("\n")
server = ThreadedEchoServer(CERTFILE,
@@ -1207,12 +1487,12 @@ else:
s.connect((HOST, server.port))
# helper methods for standardising recv* method signatures
def _recv_into():
- b = bytearray("\0"*100)
+ b = bytearray(b"\0"*100)
count = s.recv_into(b)
return b[:count]
def _recvfrom_into():
- b = bytearray("\0"*100)
+ b = bytearray(b"\0"*100)
count, addr = s.recvfrom_into(b)
return b[:count]
@@ -1228,76 +1508,75 @@ else:
('recv_into', _recv_into, True, []),
('recvfrom_into', _recvfrom_into, False, []),
]
- data_prefix = u"PREFIX_"
+ data_prefix = "PREFIX_"
for meth_name, send_meth, expect_success, args in send_methods:
- indata = data_prefix + meth_name
+ indata = (data_prefix + meth_name).encode('ascii')
try:
- send_meth(indata.encode('ASCII', 'strict'), *args)
+ send_meth(indata, *args)
outdata = s.read()
- outdata = outdata.decode('ASCII', 'strict')
if outdata != indata.lower():
self.fail(
- "While sending with <<%s>> bad data "
- "<<%r>> (%d) received; "
- "expected <<%r>> (%d)\n" % (
- meth_name, outdata[:20], len(outdata),
- indata[:20], len(indata)
+ "While sending with <<{name:s}>> bad data "
+ "<<{outdata:r}>> ({nout:d}) received; "
+ "expected <<{indata:r}>> ({nin:d})\n".format(
+ name=meth_name, outdata=outdata[:20],
+ nout=len(outdata),
+ indata=indata[:20], nin=len(indata)
)
)
except ValueError as e:
if expect_success:
self.fail(
- "Failed to send with method <<%s>>; "
- "expected to succeed.\n" % (meth_name,)
+ "Failed to send with method <<{name:s}>>; "
+ "expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
self.fail(
- "Method <<%s>> failed with unexpected "
- "exception message: %s\n" % (
- meth_name, e
+ "Method <<{name:s}>> failed with unexpected "
+ "exception message: {exp:s}\n".format(
+ name=meth_name, exp=e
)
)
for meth_name, recv_meth, expect_success, args in recv_methods:
- indata = data_prefix + meth_name
+ indata = (data_prefix + meth_name).encode('ascii')
try:
- s.send(indata.encode('ASCII', 'strict'))
+ s.send(indata)
outdata = recv_meth(*args)
- outdata = outdata.decode('ASCII', 'strict')
if outdata != indata.lower():
self.fail(
- "While receiving with <<%s>> bad data "
- "<<%r>> (%d) received; "
- "expected <<%r>> (%d)\n" % (
- meth_name, outdata[:20], len(outdata),
- indata[:20], len(indata)
+ "While receiving with <<{name:s}>> bad data "
+ "<<{outdata:r}>> ({nout:d}) received; "
+ "expected <<{indata:r}>> ({nin:d})\n".format(
+ name=meth_name, outdata=outdata[:20],
+ nout=len(outdata),
+ indata=indata[:20], nin=len(indata)
)
)
except ValueError as e:
if expect_success:
self.fail(
- "Failed to receive with method <<%s>>; "
- "expected to succeed.\n" % (meth_name,)
+ "Failed to receive with method <<{name:s}>>; "
+ "expected to succeed.\n".format(name=meth_name)
)
if not str(e).startswith(meth_name):
self.fail(
- "Method <<%s>> failed with unexpected "
- "exception message: %s\n" % (
- meth_name, e
+ "Method <<{name:s}>> failed with unexpected "
+ "exception message: {exp:s}\n".format(
+ name=meth_name, exp=e
)
)
# consume data
s.read()
-
- s.write("over\n".encode("ASCII", "strict"))
+ s.write(b"over\n")
s.close()
def test_handshake_timeout(self):
# Issue #5103: SSL handshake must respect the socket timeout
server = socket.socket(socket.AF_INET)
host = "127.0.0.1"
- port = test_support.bind_port(server)
+ port = support.bind_port(server)
started = threading.Event()
finish = False
@@ -1311,6 +1590,8 @@ else:
# Let the socket hang around rather than having
# it closed by garbage collection.
conns.append(server.accept()[0])
+ for sock in conns:
+ sock.close()
t = threading.Thread(target=serve)
t.start()
@@ -1322,17 +1603,17 @@ else:
c.settimeout(0.2)
c.connect((host, port))
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- ssl.wrap_socket, c)
+ self.assertRaisesRegex(socket.timeout, "timed out",
+ ssl.wrap_socket, c)
finally:
c.close()
try:
c = socket.socket(socket.AF_INET)
- c.settimeout(0.2)
c = ssl.wrap_socket(c)
+ c.settimeout(0.2)
# Will attempt handshake and time out
- self.assertRaisesRegexp(ssl.SSLError, "timed out",
- c.connect, (host, port))
+ self.assertRaisesRegex(socket.timeout, "timed out",
+ c.connect, (host, port))
finally:
c.close()
finally:
@@ -1340,56 +1621,100 @@ else:
t.join()
server.close()
+ def test_server_accept(self):
+ # Issue #16357: accept() on a SSLSocket created through
+ # SSLContext.wrap_socket().
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(CERTFILE)
+ context.load_cert_chain(CERTFILE)
+ server = socket.socket(socket.AF_INET)
+ host = "127.0.0.1"
+ port = support.bind_port(server)
+ server = context.wrap_socket(server, server_side=True)
+
+ evt = threading.Event()
+ remote = None
+ peer = None
+ def serve():
+ nonlocal remote, peer
+ server.listen(5)
+ # Block on the accept and wait on the connection to close.
+ evt.set()
+ remote, peer = server.accept()
+ remote.recv(1)
+
+ t = threading.Thread(target=serve)
+ t.start()
+ # Client wait until server setup and perform a connect.
+ evt.wait()
+ client = context.wrap_socket(socket.socket())
+ client.connect((host, port))
+ client_addr = client.getsockname()
+ client.close()
+ t.join()
+ # Sanity checks.
+ self.assertIsInstance(remote, ssl.SSLSocket)
+ self.assertEqual(peer, client_addr)
+
def test_default_ciphers(self):
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ try:
+ # Force a set of weak ciphers on our client context
+ context.set_ciphers("DES")
+ except ssl.SSLError:
+ self.skipTest("no DES cipher available")
with ThreadedEchoServer(CERTFILE,
ssl_version=ssl.PROTOCOL_SSLv23,
chatty=False) as server:
- sock = socket.socket()
- try:
- # Force a set of weak ciphers on our client socket
- try:
- s = ssl.wrap_socket(sock,
- ssl_version=ssl.PROTOCOL_SSLv23,
- ciphers="DES")
- except ssl.SSLError:
- self.skipTest("no DES cipher available")
+ with socket.socket() as sock:
+ s = context.wrap_socket(sock)
with self.assertRaises((OSError, ssl.SSLError)):
s.connect((HOST, server.port))
- finally:
- sock.close()
self.assertIn("no shared cipher", str(server.conn_errors[0]))
def test_main(verbose=False):
- global CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, NOKIACERT
- CERTFILE = os.path.join(os.path.dirname(__file__) or os.curdir,
- "keycert.pem")
- SVN_PYTHON_ORG_ROOT_CERT = os.path.join(
- os.path.dirname(__file__) or os.curdir,
- "https_svn_python_org_root.pem")
- NOKIACERT = os.path.join(os.path.dirname(__file__) or os.curdir,
- "nokia.pem")
-
- if (not os.path.exists(CERTFILE) or
- not os.path.exists(SVN_PYTHON_ORG_ROOT_CERT) or
- not os.path.exists(NOKIACERT)):
- raise test_support.TestFailed("Can't read certificate files!")
-
- tests = [BasicTests, BasicSocketTests]
-
- if test_support.is_resource_enabled('network'):
+ if support.verbose:
+ plats = {
+ 'Linux': platform.linux_distribution,
+ 'Mac': platform.mac_ver,
+ 'Windows': platform.win32_ver,
+ }
+ for name, func in plats.items():
+ plat = func()
+ if plat and plat[0]:
+ plat = '%s %r' % (name, plat)
+ break
+ else:
+ plat = repr(platform.platform())
+ print("test_ssl: testing with %r %r" %
+ (ssl.OPENSSL_VERSION, ssl.OPENSSL_VERSION_INFO))
+ print(" under %s" % plat)
+ print(" HAS_SNI = %r" % ssl.HAS_SNI)
+
+ for filename in [
+ CERTFILE, SVN_PYTHON_ORG_ROOT_CERT, BYTES_CERTFILE,
+ ONLYCERT, ONLYKEY, BYTES_ONLYCERT, BYTES_ONLYKEY,
+ BADCERT, BADKEY, EMPTYCERT]:
+ if not os.path.exists(filename):
+ raise support.TestFailed("Can't read certificate file %r" % filename)
+
+ tests = [ContextTests, BasicSocketTests]
+
+ if support.is_resource_enabled('network'):
tests.append(NetworkedTests)
if _have_threads:
- thread_info = test_support.threading_setup()
- if thread_info and test_support.is_resource_enabled('network'):
+ thread_info = support.threading_setup()
+ if thread_info and support.is_resource_enabled('network'):
tests.append(ThreadedTests)
try:
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
finally:
if _have_threads:
- test_support.threading_cleanup(*thread_info)
+ support.threading_cleanup(*thread_info)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_startfile.py b/Lib/test/test_startfile.py
index 9dce8fd6acb..ae9aeb9b6ce 100644
--- a/Lib/test/test_startfile.py
+++ b/Lib/test/test_startfile.py
@@ -8,38 +8,28 @@
# call succeeded, but also the the script actually has run.
import unittest
-from test import test_support
+from test import support
import os
+import sys
from os import path
-from time import sleep
-startfile = test_support.get_attribute(os, 'startfile')
+startfile = support.get_attribute(os, 'startfile')
class TestCase(unittest.TestCase):
def test_nonexisting(self):
self.assertRaises(OSError, startfile, "nonexisting.vbs")
- def test_nonexisting_u(self):
- self.assertRaises(OSError, startfile, u"nonexisting.vbs")
-
def test_empty(self):
- empty = path.join(path.dirname(__file__), "empty.vbs")
- startfile(empty)
- startfile(empty, "open")
- # Give the child process some time to exit before we finish.
- # Otherwise the cleanup code will not be able to delete the cwd,
- # because it is still in use.
- sleep(0.1)
-
- def test_empty_u(self):
- empty = path.join(path.dirname(__file__), "empty.vbs")
- startfile(unicode(empty, "mbcs"))
- startfile(unicode(empty, "mbcs"), "open")
- sleep(0.1)
+ # Switch to an existing, but safe, working directory to let the
+ # cleanup code do its thing without permission errors.
+ with support.temp_cwd(path=path.dirname(sys.executable)):
+ empty = path.join(path.dirname(__file__), "empty.vbs")
+ startfile(empty)
+ startfile(empty, "open")
def test_main():
- test_support.run_unittest(TestCase)
+ support.run_unittest(TestCase)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_str.py b/Lib/test/test_str.py
deleted file mode 100644
index eb704ead4f9..00000000000
--- a/Lib/test/test_str.py
+++ /dev/null
@@ -1,461 +0,0 @@
-
-import struct
-import sys
-from test import test_support, string_tests
-
-
-class StrTest(
- string_tests.CommonTest,
- string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrUserStringTest,
- string_tests.MixinStrUnicodeTest,
- ):
-
- type2test = str
-
- # We don't need to propagate to str
- def fixtype(self, obj):
- return obj
-
- def test_basic_creation(self):
- self.assertEqual(str(''), '')
- self.assertEqual(str(0), '0')
- self.assertEqual(str(0L), '0')
- self.assertEqual(str(()), '()')
- self.assertEqual(str([]), '[]')
- self.assertEqual(str({}), '{}')
- a = []
- a.append(a)
- self.assertEqual(str(a), '[[...]]')
- a = {}
- a[0] = a
- self.assertEqual(str(a), '{0: {...}}')
-
- def test_formatting(self):
- string_tests.MixinStrUnicodeUserStringTest.test_formatting(self)
- self.assertRaises(OverflowError, '%c'.__mod__, 0x1234)
-
- @test_support.cpython_only
- def test_formatting_huge_precision(self):
- from _testcapi import INT_MAX
- format_string = "%.{}f".format(INT_MAX + 1)
- with self.assertRaises(ValueError):
- result = format_string % 2.34
-
- def test_formatting_huge_width(self):
- format_string = "%{}f".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format_string % 2.34
-
- def test_conversion(self):
- # Make sure __str__() behaves properly
- class Foo0:
- def __unicode__(self):
- return u"foo"
-
- class Foo1:
- def __str__(self):
- return "foo"
-
- class Foo2(object):
- def __str__(self):
- return "foo"
-
- class Foo3(object):
- def __str__(self):
- return u"foo"
-
- class Foo4(unicode):
- def __str__(self):
- return u"foo"
-
- class Foo5(str):
- def __str__(self):
- return u"foo"
-
- class Foo6(str):
- def __str__(self):
- return "foos"
-
- def __unicode__(self):
- return u"foou"
-
- class Foo7(unicode):
- def __str__(self):
- return "foos"
- def __unicode__(self):
- return u"foou"
-
- class Foo8(str):
- def __new__(cls, content=""):
- return str.__new__(cls, 2*content)
- def __str__(self):
- return self
-
- class Foo9(str):
- def __str__(self):
- return "string"
- def __unicode__(self):
- return "not unicode"
-
- self.assertTrue(str(Foo0()).startswith("<")) # this is different from __unicode__
- self.assertEqual(str(Foo1()), "foo")
- self.assertEqual(str(Foo2()), "foo")
- self.assertEqual(str(Foo3()), "foo")
- self.assertEqual(str(Foo4("bar")), "foo")
- self.assertEqual(str(Foo5("bar")), "foo")
- self.assertEqual(str(Foo6("bar")), "foos")
- self.assertEqual(str(Foo7("bar")), "foos")
- self.assertEqual(str(Foo8("foo")), "foofoo")
- self.assertEqual(str(Foo9("foo")), "string")
- self.assertEqual(unicode(Foo9("foo")), u"not unicode")
-
- def test_expandtabs_overflows_gracefully(self):
- # This test only affects 32-bit platforms because expandtabs can only take
- # an int as the max value, not a 64-bit C long. If expandtabs is changed
- # to take a 64-bit long, this test should apply to all platforms.
- if sys.maxint > (1 << 32) or struct.calcsize('P') != 4:
- return
- self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint)
-
- def test__format__(self):
- def test(value, format, expected):
- # test both with and without the trailing 's'
- self.assertEqual(value.__format__(format), expected)
- self.assertEqual(value.__format__(format + 's'), expected)
-
- test('', '', '')
- test('abc', '', 'abc')
- test('abc', '.3', 'abc')
- test('ab', '.3', 'ab')
- test('abcdef', '.3', 'abc')
- test('abcdef', '.0', '')
- test('abc', '3.3', 'abc')
- test('abc', '2.3', 'abc')
- test('abc', '2.2', 'ab')
- test('abc', '3.2', 'ab ')
- test('result', 'x<0', 'result')
- test('result', 'x<5', 'result')
- test('result', 'x<6', 'result')
- test('result', 'x<7', 'resultx')
- test('result', 'x<8', 'resultxx')
- test('result', ' <7', 'result ')
- test('result', '<7', 'result ')
- test('result', '>7', ' result')
- test('result', '>8', ' result')
- test('result', '^8', ' result ')
- test('result', '^9', ' result ')
- test('result', '^10', ' result ')
- test('a', '10000', 'a' + ' ' * 9999)
- test('', '10000', ' ' * 10000)
- test('', '10000000', ' ' * 10000000)
-
- def test_format(self):
- self.assertEqual(''.format(), '')
- self.assertEqual('a'.format(), 'a')
- self.assertEqual('ab'.format(), 'ab')
- self.assertEqual('a{{'.format(), 'a{')
- self.assertEqual('a}}'.format(), 'a}')
- self.assertEqual('{{b'.format(), '{b')
- self.assertEqual('}}b'.format(), '}b')
- self.assertEqual('a{{b'.format(), 'a{b')
-
- # examples from the PEP:
- import datetime
- self.assertEqual("My name is {0}".format('Fred'), "My name is Fred")
- self.assertEqual("My name is {0[name]}".format(dict(name='Fred')),
- "My name is Fred")
- self.assertEqual("My name is {0} :-{{}}".format('Fred'),
- "My name is Fred :-{}")
-
- d = datetime.date(2007, 8, 18)
- self.assertEqual("The year is {0.year}".format(d),
- "The year is 2007")
-
- # classes we'll use for testing
- class C:
- def __init__(self, x=100):
- self._x = x
- def __format__(self, spec):
- return spec
-
- class D:
- def __init__(self, x):
- self.x = x
- def __format__(self, spec):
- return str(self.x)
-
- # class with __str__, but no __format__
- class E:
- def __init__(self, x):
- self.x = x
- def __str__(self):
- return 'E(' + self.x + ')'
-
- # class with __repr__, but no __format__ or __str__
- class F:
- def __init__(self, x):
- self.x = x
- def __repr__(self):
- return 'F(' + self.x + ')'
-
- # class with __format__ that forwards to string, for some format_spec's
- class G:
- def __init__(self, x):
- self.x = x
- def __str__(self):
- return "string is " + self.x
- def __format__(self, format_spec):
- if format_spec == 'd':
- return 'G(' + self.x + ')'
- return object.__format__(self, format_spec)
-
- # class that returns a bad type from __format__
- class H:
- def __format__(self, format_spec):
- return 1.0
-
- class I(datetime.date):
- def __format__(self, format_spec):
- return self.strftime(format_spec)
-
- class J(int):
- def __format__(self, format_spec):
- return int.__format__(self * 2, format_spec)
-
-
- self.assertEqual(''.format(), '')
- self.assertEqual('abc'.format(), 'abc')
- self.assertEqual('{0}'.format('abc'), 'abc')
- self.assertEqual('{0:}'.format('abc'), 'abc')
- self.assertEqual('X{0}'.format('abc'), 'Xabc')
- self.assertEqual('{0}X'.format('abc'), 'abcX')
- self.assertEqual('X{0}Y'.format('abc'), 'XabcY')
- self.assertEqual('{1}'.format(1, 'abc'), 'abc')
- self.assertEqual('X{1}'.format(1, 'abc'), 'Xabc')
- self.assertEqual('{1}X'.format(1, 'abc'), 'abcX')
- self.assertEqual('X{1}Y'.format(1, 'abc'), 'XabcY')
- self.assertEqual('{0}'.format(-15), '-15')
- self.assertEqual('{0}{1}'.format(-15, 'abc'), '-15abc')
- self.assertEqual('{0}X{1}'.format(-15, 'abc'), '-15Xabc')
- self.assertEqual('{{'.format(), '{')
- self.assertEqual('}}'.format(), '}')
- self.assertEqual('{{}}'.format(), '{}')
- self.assertEqual('{{x}}'.format(), '{x}')
- self.assertEqual('{{{0}}}'.format(123), '{123}')
- self.assertEqual('{{{{0}}}}'.format(), '{{0}}')
- self.assertEqual('}}{{'.format(), '}{')
- self.assertEqual('}}x{{'.format(), '}x{')
-
- # weird field names
- self.assertEqual("{0[foo-bar]}".format({'foo-bar':'baz'}), 'baz')
- self.assertEqual("{0[foo bar]}".format({'foo bar':'baz'}), 'baz')
- self.assertEqual("{0[ ]}".format({' ':3}), '3')
-
- self.assertEqual('{foo._x}'.format(foo=C(20)), '20')
- self.assertEqual('{1}{0}'.format(D(10), D(20)), '2010')
- self.assertEqual('{0._x.x}'.format(C(D('abc'))), 'abc')
- self.assertEqual('{0[0]}'.format(['abc', 'def']), 'abc')
- self.assertEqual('{0[1]}'.format(['abc', 'def']), 'def')
- self.assertEqual('{0[1][0]}'.format(['abc', ['def']]), 'def')
- self.assertEqual('{0[1][0].x}'.format(['abc', [D('def')]]), 'def')
-
- # strings
- self.assertEqual('{0:.3s}'.format('abc'), 'abc')
- self.assertEqual('{0:.3s}'.format('ab'), 'ab')
- self.assertEqual('{0:.3s}'.format('abcdef'), 'abc')
- self.assertEqual('{0:.0s}'.format('abcdef'), '')
- self.assertEqual('{0:3.3s}'.format('abc'), 'abc')
- self.assertEqual('{0:2.3s}'.format('abc'), 'abc')
- self.assertEqual('{0:2.2s}'.format('abc'), 'ab')
- self.assertEqual('{0:3.2s}'.format('abc'), 'ab ')
- self.assertEqual('{0:x<0s}'.format('result'), 'result')
- self.assertEqual('{0:x<5s}'.format('result'), 'result')
- self.assertEqual('{0:x<6s}'.format('result'), 'result')
- self.assertEqual('{0:x<7s}'.format('result'), 'resultx')
- self.assertEqual('{0:x<8s}'.format('result'), 'resultxx')
- self.assertEqual('{0: <7s}'.format('result'), 'result ')
- self.assertEqual('{0:<7s}'.format('result'), 'result ')
- self.assertEqual('{0:>7s}'.format('result'), ' result')
- self.assertEqual('{0:>8s}'.format('result'), ' result')
- self.assertEqual('{0:^8s}'.format('result'), ' result ')
- self.assertEqual('{0:^9s}'.format('result'), ' result ')
- self.assertEqual('{0:^10s}'.format('result'), ' result ')
- self.assertEqual('{0:10000}'.format('a'), 'a' + ' ' * 9999)
- self.assertEqual('{0:10000}'.format(''), ' ' * 10000)
- self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000)
-
- # format specifiers for user defined type
- self.assertEqual('{0:abc}'.format(C()), 'abc')
-
- # !r and !s coercions
- self.assertEqual('{0!s}'.format('Hello'), 'Hello')
- self.assertEqual('{0!s:}'.format('Hello'), 'Hello')
- self.assertEqual('{0!s:15}'.format('Hello'), 'Hello ')
- self.assertEqual('{0!s:15s}'.format('Hello'), 'Hello ')
- self.assertEqual('{0!r}'.format('Hello'), "'Hello'")
- self.assertEqual('{0!r:}'.format('Hello'), "'Hello'")
- self.assertEqual('{0!r}'.format(F('Hello')), 'F(Hello)')
-
- # test fallback to object.__format__
- self.assertEqual('{0}'.format({}), '{}')
- self.assertEqual('{0}'.format([]), '[]')
- self.assertEqual('{0}'.format([1]), '[1]')
- self.assertEqual('{0}'.format(E('data')), 'E(data)')
- 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 test_support.check_warnings((msg, PendingDeprecationWarning)):
- 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.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007,
- month=8,
- day=27)),
- "date: 2007-08-27")
-
- # test deriving from a builtin type and overriding __format__
- self.assertEqual("{0}".format(J(10)), "20")
-
-
- # string format specifiers
- self.assertEqual('{0:}'.format('a'), 'a')
-
- # computed format specifiers
- self.assertEqual("{0:.{1}}".format('hello world', 5), 'hello')
- self.assertEqual("{0:.{1}s}".format('hello world', 5), 'hello')
- self.assertEqual("{0:.{precision}s}".format('hello world', precision=5), 'hello')
- self.assertEqual("{0:{width}.{precision}s}".format('hello world', width=10, precision=5), 'hello ')
- self.assertEqual("{0:{width}.{precision}s}".format('hello world', width='10', precision='5'), 'hello ')
-
- # test various errors
- self.assertRaises(ValueError, '{'.format)
- self.assertRaises(ValueError, '}'.format)
- self.assertRaises(ValueError, 'a{'.format)
- self.assertRaises(ValueError, 'a}'.format)
- self.assertRaises(ValueError, '{a'.format)
- self.assertRaises(ValueError, '}a'.format)
- self.assertRaises(IndexError, '{0}'.format)
- self.assertRaises(IndexError, '{1}'.format, 'abc')
- self.assertRaises(KeyError, '{x}'.format)
- self.assertRaises(ValueError, "}{".format)
- self.assertRaises(ValueError, "{".format)
- self.assertRaises(ValueError, "}".format)
- self.assertRaises(ValueError, "abc{0:{}".format)
- self.assertRaises(ValueError, "{0".format)
- self.assertRaises(IndexError, "{0.}".format)
- self.assertRaises(ValueError, "{0.}".format, 0)
- self.assertRaises(IndexError, "{0[}".format)
- self.assertRaises(ValueError, "{0[}".format, [])
- self.assertRaises(KeyError, "{0]}".format)
- self.assertRaises(ValueError, "{0.[]}".format, 0)
- self.assertRaises(ValueError, "{0..foo}".format, 0)
- self.assertRaises(ValueError, "{0[0}".format, 0)
- self.assertRaises(ValueError, "{0[0:foo}".format, 0)
- self.assertRaises(KeyError, "{c]}".format)
- self.assertRaises(ValueError, "{{ {{{0}}".format, 0)
- self.assertRaises(ValueError, "{0}}".format, 0)
- self.assertRaises(KeyError, "{foo}".format, bar=3)
- self.assertRaises(ValueError, "{0!x}".format, 3)
- self.assertRaises(ValueError, "{0!}".format, 0)
- self.assertRaises(ValueError, "{0!rs}".format, 0)
- self.assertRaises(ValueError, "{!}".format)
- self.assertRaises(IndexError, "{:}".format)
- self.assertRaises(IndexError, "{:s}".format)
- self.assertRaises(IndexError, "{}".format)
-
- # issue 6089
- self.assertRaises(ValueError, "{0[0]x}".format, [None])
- self.assertRaises(ValueError, "{0[0](10)}".format, [None])
-
- # can't have a replacement on the field name portion
- self.assertRaises(TypeError, '{0[{1}]}'.format, 'abcdefg', 4)
-
- # exceed maximum recursion depth
- self.assertRaises(ValueError, "{0:{1:{2}}}".format, 'abc', 's', '')
- self.assertRaises(ValueError, "{0:{1:{2:{3:{4:{5:{6}}}}}}}".format,
- 0, 1, 2, 3, 4, 5, 6, 7)
-
- # string format spec errors
- self.assertRaises(ValueError, "{0:-s}".format, '')
- self.assertRaises(ValueError, format, "", "-")
- self.assertRaises(ValueError, "{0:=s}".format, '')
-
- def test_format_huge_precision(self):
- format_string = ".{}f".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format(2.34, format_string)
-
- def test_format_huge_width(self):
- format_string = "{}f".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format(2.34, format_string)
-
- def test_format_huge_item_number(self):
- format_string = "{{{}:.6f}}".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format_string.format(2.34)
-
- def test_format_auto_numbering(self):
- class C:
- def __init__(self, x=100):
- self._x = x
- def __format__(self, spec):
- return spec
-
- self.assertEqual('{}'.format(10), '10')
- self.assertEqual('{:5}'.format('s'), 's ')
- self.assertEqual('{!r}'.format('s'), "'s'")
- self.assertEqual('{._x}'.format(C(10)), '10')
- self.assertEqual('{[1]}'.format([1, 2]), '2')
- self.assertEqual('{[a]}'.format({'a':4, 'b':2}), '4')
- self.assertEqual('a{}b{}c'.format(0, 1), 'a0b1c')
-
- self.assertEqual('a{:{}}b'.format('x', '^10'), 'a x b')
- self.assertEqual('a{:{}x}b'.format(20, '#'), 'a0x14b')
-
- # can't mix and match numbering and auto-numbering
- self.assertRaises(ValueError, '{}{1}'.format, 1, 2)
- self.assertRaises(ValueError, '{1}{}'.format, 1, 2)
- self.assertRaises(ValueError, '{:{1}}'.format, 1, 2)
- self.assertRaises(ValueError, '{0:{}}'.format, 1, 2)
-
- # can mix and match auto-numbering and named
- self.assertEqual('{f}{}'.format(4, f='test'), 'test4')
- self.assertEqual('{}{f}'.format(4, f='test'), '4test')
- self.assertEqual('{:{f}}{g}{}'.format(1, 3, g='g', f=2), ' 1g3')
- self.assertEqual('{f:{}}{}{g}'.format(2, 4, f=1, g='g'), ' 14g')
-
- def test_buffer_is_readonly(self):
- self.assertRaises(TypeError, sys.stdin.readinto, b"")
-
- def test_encode_and_decode_kwargs(self):
- self.assertEqual('abcde'.encode('ascii', 'replace'),
- 'abcde'.encode('ascii', errors='replace'))
- self.assertEqual('abcde'.encode('ascii', 'ignore'),
- 'abcde'.encode(encoding='ascii', errors='ignore'))
- self.assertEqual('Andr\202 x'.decode('ascii', 'ignore'),
- 'Andr\202 x'.decode('ascii', errors='ignore'))
- self.assertEqual('Andr\202 x'.decode('ascii', 'replace'),
- 'Andr\202 x'.decode(encoding='ascii', errors='replace'))
-
- def test_startswith_endswith_errors(self):
- with self.assertRaises(UnicodeDecodeError):
- '\xff'.startswith(u'x')
- with self.assertRaises(UnicodeDecodeError):
- '\xff'.endswith(u'x')
- for meth in ('foo'.startswith, 'foo'.endswith):
- with self.assertRaises(TypeError) as cm:
- meth(['f'])
- exc = str(cm.exception)
- self.assertIn('unicode', exc)
- self.assertIn('str', exc)
- self.assertIn('tuple', exc)
-
-def test_main():
- test_support.run_unittest(StrTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_strftime.py b/Lib/test/test_strftime.py
index b26ebec93dc..14057eb34ac 100644
--- a/Lib/test/test_strftime.py
+++ b/Lib/test/test_strftime.py
@@ -5,7 +5,7 @@ Unittest for time.strftime
import calendar
import sys
import re
-from test import test_support
+from test import support
import time
import unittest
@@ -28,10 +28,8 @@ def escapestr(text, ampm):
new_text = new_text.replace('\?', '?')
return new_text
-class StrftimeTest(unittest.TestCase):
- def __init__(self, *k, **kw):
- unittest.TestCase.__init__(self, *k, **kw)
+class StrftimeTest(unittest.TestCase):
def _update_variables(self, now):
# we must update the local variables on every cycle
@@ -69,9 +67,9 @@ class StrftimeTest(unittest.TestCase):
self.strftest1(now)
self.strftest2(now)
- if test_support.verbose:
- print "Strftime test, platform: %s, Python version: %s" % \
- (sys.platform, sys.version.split()[0])
+ if support.verbose:
+ print("Strftime test, platform: %s, Python version: %s" % \
+ (sys.platform, sys.version.split()[0]))
for j in range(-5, 5):
for i in range(25):
@@ -81,8 +79,8 @@ class StrftimeTest(unittest.TestCase):
self.strftest2(arg)
def strftest1(self, now):
- if test_support.verbose:
- print "strftime test for", time.ctime(now)
+ if support.verbose:
+ print("strftime test for", time.ctime(now))
now = self.now
# Make sure any characters that could be taken as regex syntax is
# escaped in escapestr()
@@ -117,7 +115,7 @@ class StrftimeTest(unittest.TestCase):
# musn't raise a value error
try:
result = time.strftime(e[0], now)
- except ValueError, error:
+ except ValueError as error:
self.fail("strftime '%s' format gave error: %s" % (e[0], error))
if re.match(escapestr(e[1], self.ampm), result):
continue
@@ -129,7 +127,7 @@ class StrftimeTest(unittest.TestCase):
% (e[0], e[2], e[1], result))
def strftest2(self, now):
- nowsecs = str(long(now))[:-1]
+ nowsecs = str(int(now))[:-1]
now = self.now
nonstandard_expectations = (
@@ -155,31 +153,31 @@ class StrftimeTest(unittest.TestCase):
'year without century rendered using fieldwidth'),
)
+
for e in nonstandard_expectations:
try:
result = time.strftime(e[0], now)
- except ValueError, result:
+ except ValueError as result:
msg = "Error for nonstandard '%s' format (%s): %s" % \
(e[0], e[2], str(result))
- if test_support.verbose:
- print msg
+ if support.verbose:
+ print(msg)
continue
-
if re.match(escapestr(e[1], self.ampm), result):
- if test_support.verbose:
- print "Supports nonstandard '%s' format (%s)" % (e[0], e[2])
+ if support.verbose:
+ print("Supports nonstandard '%s' format (%s)" % (e[0], e[2]))
elif not result or result[0] == '%':
- if test_support.verbose:
- print "Does not appear to support '%s' format (%s)" % \
- (e[0], e[2])
+ if support.verbose:
+ print("Does not appear to support '%s' format (%s)" % \
+ (e[0], e[2]))
else:
- if test_support.verbose:
- print "Conflict for nonstandard '%s' format (%s):" % \
- (e[0], e[2])
- print " Expected %s, but got %s" % (e[1], result)
+ if support.verbose:
+ print("Conflict for nonstandard '%s' format (%s):" % \
+ (e[0], e[2]))
+ print(" Expected %s, but got %s" % (e[1], result))
def test_main():
- test_support.run_unittest(StrftimeTest)
+ support.run_unittest(StrftimeTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_string.py b/Lib/test/test_string.py
index 0d07b913942..34d1dcf3fe6 100644
--- a/Lib/test/test_string.py
+++ b/Lib/test/test_string.py
@@ -1,103 +1,20 @@
import unittest, string
-from test import test_support, string_tests
-from UserList import UserList
-
-class StringTest(
- string_tests.CommonTest,
- string_tests.MixinStrStringUserStringTest
- ):
-
- type2test = str
-
- def checkequal(self, result, object, methodname, *args):
- realresult = getattr(string, methodname)(object, *args)
- self.assertEqual(
- result,
- realresult
- )
-
- def checkraises(self, exc, object, methodname, *args):
- self.assertRaises(
- exc,
- getattr(string, methodname),
- object,
- *args
- )
-
- def checkcall(self, object, methodname, *args):
- getattr(string, methodname)(object, *args)
-
- def test_join(self):
- # These are the same checks as in string_test.ObjectTest.test_join
- # but the argument order ist different
- self.checkequal('a b c d', ['a', 'b', 'c', 'd'], 'join', ' ')
- self.checkequal('abcd', ('a', 'b', 'c', 'd'), 'join', '')
- self.checkequal('w x y z', string_tests.Sequence(), 'join', ' ')
- self.checkequal('abc', ('abc',), 'join', 'a')
- self.checkequal('z', UserList(['z']), 'join', 'a')
- if test_support.have_unicode:
- self.checkequal(unicode('a.b.c'), ['a', 'b', 'c'], 'join', unicode('.'))
- self.checkequal(unicode('a.b.c'), [unicode('a'), 'b', 'c'], 'join', '.')
- self.checkequal(unicode('a.b.c'), ['a', unicode('b'), 'c'], 'join', '.')
- self.checkequal(unicode('a.b.c'), ['a', 'b', unicode('c')], 'join', '.')
- self.checkraises(TypeError, ['a', unicode('b'), 3], 'join', '.')
- for i in [5, 25, 125]:
- self.checkequal(
- ((('a' * i) + '-') * i)[:-1],
- ['a' * i] * i, 'join', '-')
- self.checkequal(
- ((('a' * i) + '-') * i)[:-1],
- ('a' * i,) * i, 'join', '-')
-
- self.checkraises(TypeError, string_tests.BadSeq1(), 'join', ' ')
- self.checkequal('a b c', string_tests.BadSeq2(), 'join', ' ')
- try:
- def f():
- yield 4 + ""
- self.fixtype(' ').join(f())
- except TypeError, e:
- if '+' not in str(e):
- self.fail('join() ate exception message')
- else:
- self.fail('exception not raised')
-
-
+from test import support
class ModuleTest(unittest.TestCase):
def test_attrs(self):
string.whitespace
- string.lowercase
- string.uppercase
- string.letters
+ string.ascii_lowercase
+ string.ascii_uppercase
+ string.ascii_letters
string.digits
string.hexdigits
string.octdigits
string.punctuation
string.printable
- def test_atoi(self):
- self.assertEqual(string.atoi(" 1 "), 1)
- self.assertRaises(ValueError, string.atoi, " 1x")
- self.assertRaises(ValueError, string.atoi, " x1 ")
-
- def test_atol(self):
- self.assertEqual(string.atol(" 1 "), 1L)
- self.assertRaises(ValueError, string.atol, " 1x ")
- self.assertRaises(ValueError, string.atol, " x1 ")
-
- def test_atof(self):
- self.assertAlmostEqual(string.atof(" 1 "), 1.0)
- self.assertRaises(ValueError, string.atof, " 1x ")
- self.assertRaises(ValueError, string.atof, " x1 ")
-
- def test_maketrans(self):
- transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
-
- self.assertEqual(string.maketrans('abc', 'xyz'), transtable)
- self.assertRaises(ValueError, string.maketrans, 'abc', 'xyzq')
-
def test_capwords(self):
self.assertEqual(string.capwords('abc def ghi'), 'Abc Def Ghi')
self.assertEqual(string.capwords('abc\tdef\nghi'), 'Abc Def Ghi')
@@ -109,6 +26,18 @@ class ModuleTest(unittest.TestCase):
self.assertEqual(string.capwords('\taBc\tDeF\t'), 'Abc Def')
self.assertEqual(string.capwords('\taBc\tDeF\t', '\t'), '\tAbc\tDef\t')
+ def test_conversion_specifiers(self):
+ fmt = string.Formatter()
+ self.assertEqual(fmt.format("-{arg!r}-", arg='test'), "-'test'-")
+ self.assertEqual(fmt.format("{0!s}", 'test'), 'test')
+ self.assertRaises(ValueError, fmt.format, "{0!h}", 'test')
+ # issue13579
+ self.assertEqual(fmt.format("{0!a}", 42), '42')
+ self.assertEqual(fmt.format("{0!a}", string.ascii_letters),
+ "'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'")
+ self.assertEqual(fmt.format("{0!a}", chr(255)), "'\\xff'")
+ self.assertEqual(fmt.format("{0!a}", chr(256)), "'\\u0100'")
+
def test_formatter(self):
fmt = string.Formatter()
self.assertEqual(fmt.format("foo"), "foo")
@@ -195,23 +124,32 @@ class ModuleTest(unittest.TestCase):
self.assertRaises(ValueError, fmt.format, "{0}", 10, 20, i=100)
self.assertRaises(ValueError, fmt.format, "{i}", 10, 20, i=100)
- # Alternate formatting is not supported
- self.assertRaises(ValueError, format, '', '#')
- self.assertRaises(ValueError, format, '', '#20')
+ def test_vformat_assert(self):
+ cls = string.Formatter()
+ kwargs = {
+ "i": 100
+ }
+ self.assertRaises(ValueError, cls._vformat,
+ cls.format, "{0}", kwargs, set(), -2)
+
+ def test_convert_field(self):
+ cls = string.Formatter()
+ self.assertEqual(cls.format("{0!s}", 'foo'), 'foo')
+ self.assertRaises(ValueError, cls.format, "{0!h}", 'foo')
-class BytesAliasTest(unittest.TestCase):
+ def test_get_field(self):
+ cls = string.Formatter()
+ class MyClass:
+ name = 'lumberjack'
+ x = MyClass()
+ self.assertEqual(cls.format("{0.name}", x), 'lumberjack')
- def test_builtin(self):
- self.assertTrue(str is bytes)
+ lookup = ["eggs", "and", "spam"]
+ self.assertEqual(cls.format("{0[2]}", lookup), 'spam')
- def test_syntax(self):
- self.assertEqual(b"spam", "spam")
- self.assertEqual(br"egg\foo", "egg\\foo")
- self.assertTrue(type(b""), str)
- self.assertTrue(type(br""), str)
def test_main():
- test_support.run_unittest(StringTest, ModuleTest, BytesAliasTest)
+ support.run_unittest(ModuleTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_stringprep.py b/Lib/test/test_stringprep.py
index 15bdf876529..aa7122172f3 100644
--- a/Lib/test/test_stringprep.py
+++ b/Lib/test/test_stringprep.py
@@ -2,72 +2,72 @@
# Since we don't have them, this test checks only a few codepoints.
import unittest
-from test import test_support
+from test import support
from stringprep import *
class StringprepTests(unittest.TestCase):
def test(self):
- self.assertTrue(in_table_a1(u"\u0221"))
- self.assertFalse(in_table_a1(u"\u0222"))
+ self.assertTrue(in_table_a1("\u0221"))
+ self.assertFalse(in_table_a1("\u0222"))
- self.assertTrue(in_table_b1(u"\u00ad"))
- self.assertFalse(in_table_b1(u"\u00ae"))
+ self.assertTrue(in_table_b1("\u00ad"))
+ self.assertFalse(in_table_b1("\u00ae"))
- self.assertTrue(map_table_b2(u"\u0041"), u"\u0061")
- self.assertTrue(map_table_b2(u"\u0061"), u"\u0061")
+ self.assertTrue(map_table_b2("\u0041"), "\u0061")
+ self.assertTrue(map_table_b2("\u0061"), "\u0061")
- self.assertTrue(map_table_b3(u"\u0041"), u"\u0061")
- self.assertTrue(map_table_b3(u"\u0061"), u"\u0061")
+ self.assertTrue(map_table_b3("\u0041"), "\u0061")
+ self.assertTrue(map_table_b3("\u0061"), "\u0061")
- self.assertTrue(in_table_c11(u"\u0020"))
- self.assertFalse(in_table_c11(u"\u0021"))
+ self.assertTrue(in_table_c11("\u0020"))
+ self.assertFalse(in_table_c11("\u0021"))
- self.assertTrue(in_table_c12(u"\u00a0"))
- self.assertFalse(in_table_c12(u"\u00a1"))
+ self.assertTrue(in_table_c12("\u00a0"))
+ self.assertFalse(in_table_c12("\u00a1"))
- self.assertTrue(in_table_c12(u"\u00a0"))
- self.assertFalse(in_table_c12(u"\u00a1"))
+ self.assertTrue(in_table_c12("\u00a0"))
+ self.assertFalse(in_table_c12("\u00a1"))
- self.assertTrue(in_table_c11_c12(u"\u00a0"))
- self.assertFalse(in_table_c11_c12(u"\u00a1"))
+ self.assertTrue(in_table_c11_c12("\u00a0"))
+ self.assertFalse(in_table_c11_c12("\u00a1"))
- self.assertTrue(in_table_c21(u"\u001f"))
- self.assertFalse(in_table_c21(u"\u0020"))
+ self.assertTrue(in_table_c21("\u001f"))
+ self.assertFalse(in_table_c21("\u0020"))
- self.assertTrue(in_table_c22(u"\u009f"))
- self.assertFalse(in_table_c22(u"\u00a0"))
+ self.assertTrue(in_table_c22("\u009f"))
+ self.assertFalse(in_table_c22("\u00a0"))
- self.assertTrue(in_table_c21_c22(u"\u009f"))
- self.assertFalse(in_table_c21_c22(u"\u00a0"))
+ self.assertTrue(in_table_c21_c22("\u009f"))
+ self.assertFalse(in_table_c21_c22("\u00a0"))
- self.assertTrue(in_table_c3(u"\ue000"))
- self.assertFalse(in_table_c3(u"\uf900"))
+ self.assertTrue(in_table_c3("\ue000"))
+ self.assertFalse(in_table_c3("\uf900"))
- self.assertTrue(in_table_c4(u"\uffff"))
- self.assertFalse(in_table_c4(u"\u0000"))
+ self.assertTrue(in_table_c4("\uffff"))
+ self.assertFalse(in_table_c4("\u0000"))
- self.assertTrue(in_table_c5(u"\ud800"))
- self.assertFalse(in_table_c5(u"\ud7ff"))
+ self.assertTrue(in_table_c5("\ud800"))
+ self.assertFalse(in_table_c5("\ud7ff"))
- self.assertTrue(in_table_c6(u"\ufff9"))
- self.assertFalse(in_table_c6(u"\ufffe"))
+ self.assertTrue(in_table_c6("\ufff9"))
+ self.assertFalse(in_table_c6("\ufffe"))
- self.assertTrue(in_table_c7(u"\u2ff0"))
- self.assertFalse(in_table_c7(u"\u2ffc"))
+ self.assertTrue(in_table_c7("\u2ff0"))
+ self.assertFalse(in_table_c7("\u2ffc"))
- self.assertTrue(in_table_c8(u"\u0340"))
- self.assertFalse(in_table_c8(u"\u0342"))
+ self.assertTrue(in_table_c8("\u0340"))
+ self.assertFalse(in_table_c8("\u0342"))
# C.9 is not in the bmp
# self.assertTrue(in_table_c9(u"\U000E0001"))
# self.assertFalse(in_table_c8(u"\U000E0002"))
- self.assertTrue(in_table_d1(u"\u05be"))
- self.assertFalse(in_table_d1(u"\u05bf"))
+ self.assertTrue(in_table_d1("\u05be"))
+ self.assertFalse(in_table_d1("\u05bf"))
- self.assertTrue(in_table_d2(u"\u0041"))
- self.assertFalse(in_table_d2(u"\u0040"))
+ self.assertTrue(in_table_d2("\u0041"))
+ self.assertFalse(in_table_d2("\u0040"))
# This would generate a hash of all predicates. However, running
# it is quite expensive, and only serves to detect changes in the
@@ -90,7 +90,7 @@ class StringprepTests(unittest.TestCase):
# print p, h.hexdigest()
def test_main():
- test_support.run_unittest(StringprepTests)
+ support.run_unittest(StringprepTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_strlit.py b/Lib/test/test_strlit.py
new file mode 100644
index 00000000000..6bdc6e4e8a2
--- /dev/null
+++ b/Lib/test/test_strlit.py
@@ -0,0 +1,150 @@
+r"""Test correct treatment of various string literals by the parser.
+
+There are four types of string literals:
+
+ 'abc' -- normal str
+ r'abc' -- raw str
+ b'xyz' -- normal bytes
+ br'xyz' -- raw bytes
+
+The difference between normal and raw strings is of course that in a
+raw string, \ escapes (while still used to determine the end of the
+literal) are not interpreted, so that r'\x00' contains four
+characters: a backslash, an x, and two zeros; while '\x00' contains a
+single character (code point zero).
+
+The tricky thing is what should happen when non-ASCII bytes are used
+inside literals. For bytes literals, this is considered illegal. But
+for str literals, those bytes are supposed to be decoded using the
+encoding declared for the file (UTF-8 by default).
+
+We have to test this with various file encodings. We also test it with
+exec()/eval(), which uses a different code path.
+
+This file is really about correct treatment of encodings and
+backslashes. It doesn't concern itself with issues like single
+vs. double quotes or singly- vs. triply-quoted strings: that's dealt
+with elsewhere (I assume).
+"""
+
+import os
+import sys
+import shutil
+import tempfile
+import unittest
+import test.support
+
+
+TEMPLATE = r"""# coding: %s
+a = 'x'
+assert ord(a) == 120
+b = '\x01'
+assert ord(b) == 1
+c = r'\x01'
+assert list(map(ord, c)) == [92, 120, 48, 49]
+d = '\x81'
+assert ord(d) == 0x81
+e = r'\x81'
+assert list(map(ord, e)) == [92, 120, 56, 49]
+f = '\u1881'
+assert ord(f) == 0x1881
+g = r'\u1881'
+assert list(map(ord, g)) == [92, 117, 49, 56, 56, 49]
+"""
+
+
+def byte(i):
+ return bytes([i])
+
+
+class TestLiterals(unittest.TestCase):
+
+ def setUp(self):
+ self.save_path = sys.path[:]
+ self.tmpdir = tempfile.mkdtemp()
+ sys.path.insert(0, self.tmpdir)
+
+ def tearDown(self):
+ sys.path[:] = self.save_path
+ shutil.rmtree(self.tmpdir, ignore_errors=True)
+
+ def test_template(self):
+ # Check that the template doesn't contain any non-printables
+ # except for \n.
+ for c in TEMPLATE:
+ assert c == '\n' or ' ' <= c <= '~', repr(c)
+
+ def test_eval_str_normal(self):
+ self.assertEqual(eval(""" 'x' """), 'x')
+ self.assertEqual(eval(r""" '\x01' """), chr(1))
+ self.assertEqual(eval(""" '\x01' """), chr(1))
+ self.assertEqual(eval(r""" '\x81' """), chr(0x81))
+ self.assertEqual(eval(""" '\x81' """), chr(0x81))
+ self.assertEqual(eval(r""" '\u1881' """), chr(0x1881))
+ self.assertEqual(eval(""" '\u1881' """), chr(0x1881))
+
+ def test_eval_str_raw(self):
+ self.assertEqual(eval(""" r'x' """), 'x')
+ self.assertEqual(eval(r""" r'\x01' """), '\\' + 'x01')
+ self.assertEqual(eval(""" r'\x01' """), chr(1))
+ self.assertEqual(eval(r""" r'\x81' """), '\\' + 'x81')
+ self.assertEqual(eval(""" r'\x81' """), chr(0x81))
+ self.assertEqual(eval(r""" r'\u1881' """), '\\' + 'u1881')
+ self.assertEqual(eval(""" r'\u1881' """), chr(0x1881))
+
+ def test_eval_bytes_normal(self):
+ self.assertEqual(eval(""" b'x' """), b'x')
+ self.assertEqual(eval(r""" b'\x01' """), byte(1))
+ self.assertEqual(eval(""" b'\x01' """), byte(1))
+ self.assertEqual(eval(r""" b'\x81' """), byte(0x81))
+ self.assertRaises(SyntaxError, eval, """ b'\x81' """)
+ self.assertEqual(eval(r""" b'\u1881' """), b'\\' + b'u1881')
+ self.assertRaises(SyntaxError, eval, """ b'\u1881' """)
+
+ def test_eval_bytes_raw(self):
+ self.assertEqual(eval(""" br'x' """), b'x')
+ self.assertEqual(eval(r""" br'\x01' """), b'\\' + b'x01')
+ self.assertEqual(eval(""" br'\x01' """), byte(1))
+ self.assertEqual(eval(r""" br'\x81' """), b"\\" + b"x81")
+ self.assertRaises(SyntaxError, eval, """ br'\x81' """)
+ self.assertEqual(eval(r""" br'\u1881' """), b"\\" + b"u1881")
+ self.assertRaises(SyntaxError, eval, """ br'\u1881' """)
+
+ def check_encoding(self, encoding, extra=""):
+ modname = "xx_" + encoding.replace("-", "_")
+ fn = os.path.join(self.tmpdir, modname + ".py")
+ f = open(fn, "w", encoding=encoding)
+ try:
+ f.write(TEMPLATE % encoding)
+ f.write(extra)
+ finally:
+ f.close()
+ __import__(modname)
+ del sys.modules[modname]
+
+ def test_file_utf_8(self):
+ extra = "z = '\u1234'; assert ord(z) == 0x1234\n"
+ self.check_encoding("utf-8", extra)
+
+ def test_file_utf_8_error(self):
+ extra = "b'\x80'\n"
+ self.assertRaises(SyntaxError, self.check_encoding, "utf-8", extra)
+
+ def test_file_utf8(self):
+ self.check_encoding("utf8")
+
+ def test_file_iso_8859_1(self):
+ self.check_encoding("iso-8859-1")
+
+ def test_file_latin_1(self):
+ self.check_encoding("latin-1")
+
+ def test_file_latin9(self):
+ self.check_encoding("latin9")
+
+
+def test_main():
+ test.support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_strop.py b/Lib/test/test_strop.py
deleted file mode 100644
index 8ce29efeb1b..00000000000
--- a/Lib/test/test_strop.py
+++ /dev/null
@@ -1,153 +0,0 @@
-import warnings
-warnings.filterwarnings("ignore", "strop functions are obsolete;",
- DeprecationWarning,
- r'test.test_strop|unittest')
-import strop
-import unittest
-from test import test_support
-
-
-class StropFunctionTestCase(unittest.TestCase):
-
- def test_atoi(self):
- self.assertTrue(strop.atoi(" 1 ") == 1)
- self.assertRaises(ValueError, strop.atoi, " 1x")
- self.assertRaises(ValueError, strop.atoi, " x1 ")
-
- def test_atol(self):
- self.assertTrue(strop.atol(" 1 ") == 1L)
- self.assertRaises(ValueError, strop.atol, " 1x")
- self.assertRaises(ValueError, strop.atol, " x1 ")
-
- def test_atof(self):
- self.assertTrue(strop.atof(" 1 ") == 1.0)
- self.assertRaises(ValueError, strop.atof, " 1x")
- self.assertRaises(ValueError, strop.atof, " x1 ")
-
- def test_capitalize(self):
- self.assertTrue(strop.capitalize(" hello ") == " hello ")
- self.assertTrue(strop.capitalize("hello ") == "Hello ")
-
- def test_find(self):
- self.assertTrue(strop.find("abcdefghiabc", "abc") == 0)
- self.assertTrue(strop.find("abcdefghiabc", "abc", 1) == 9)
- self.assertTrue(strop.find("abcdefghiabc", "def", 4) == -1)
-
- def test_rfind(self):
- self.assertTrue(strop.rfind("abcdefghiabc", "abc") == 9)
-
- def test_lower(self):
- self.assertTrue(strop.lower("HeLLo") == "hello")
-
- def test_upper(self):
- self.assertTrue(strop.upper("HeLLo") == "HELLO")
-
- def test_swapcase(self):
- self.assertTrue(strop.swapcase("HeLLo cOmpUteRs") == "hEllO CoMPuTErS")
-
- def test_strip(self):
- self.assertTrue(strop.strip(" \t\n hello \t\n ") == "hello")
-
- def test_lstrip(self):
- self.assertTrue(strop.lstrip(" \t\n hello \t\n ") == "hello \t\n ")
-
- def test_rstrip(self):
- self.assertTrue(strop.rstrip(" \t\n hello \t\n ") == " \t\n hello")
-
- def test_replace(self):
- replace = strop.replace
- self.assertTrue(replace("one!two!three!", '!', '@', 1)
- == "one@two!three!")
- self.assertTrue(replace("one!two!three!", '!', '@', 2)
- == "one@two@three!")
- self.assertTrue(replace("one!two!three!", '!', '@', 3)
- == "one@two@three@")
- self.assertTrue(replace("one!two!three!", '!', '@', 4)
- == "one@two@three@")
-
- # CAUTION: a replace count of 0 means infinity only to strop,
- # not to the string .replace() method or to the
- # string.replace() function.
-
- self.assertTrue(replace("one!two!three!", '!', '@', 0)
- == "one@two@three@")
- self.assertTrue(replace("one!two!three!", '!', '@')
- == "one@two@three@")
- self.assertTrue(replace("one!two!three!", 'x', '@')
- == "one!two!three!")
- self.assertTrue(replace("one!two!three!", 'x', '@', 2)
- == "one!two!three!")
-
- def test_split(self):
- split = strop.split
- self.assertTrue(split("this is the split function")
- == ['this', 'is', 'the', 'split', 'function'])
- self.assertTrue(split("a|b|c|d", '|') == ['a', 'b', 'c', 'd'])
- self.assertTrue(split("a|b|c|d", '|', 2) == ['a', 'b', 'c|d'])
- self.assertTrue(split("a b c d", None, 1) == ['a', 'b c d'])
- self.assertTrue(split("a b c d", None, 2) == ['a', 'b', 'c d'])
- self.assertTrue(split("a b c d", None, 3) == ['a', 'b', 'c', 'd'])
- self.assertTrue(split("a b c d", None, 4) == ['a', 'b', 'c', 'd'])
- self.assertTrue(split("a b c d", None, 0) == ['a', 'b', 'c', 'd'])
- self.assertTrue(split("a b c d", None, 2) == ['a', 'b', 'c d'])
-
- def test_join(self):
- self.assertTrue(strop.join(['a', 'b', 'c', 'd']) == 'a b c d')
- self.assertTrue(strop.join(('a', 'b', 'c', 'd'), '') == 'abcd')
- self.assertTrue(strop.join(Sequence()) == 'w x y z')
-
- # try a few long ones
- self.assertTrue(strop.join(['x' * 100] * 100, ':')
- == (('x' * 100) + ":") * 99 + "x" * 100)
- self.assertTrue(strop.join(('x' * 100,) * 100, ':')
- == (('x' * 100) + ":") * 99 + "x" * 100)
-
- def test_maketrans(self):
- self.assertTrue(strop.maketrans("abc", "xyz") == transtable)
- self.assertRaises(ValueError, strop.maketrans, "abc", "xyzq")
-
- def test_translate(self):
- self.assertTrue(strop.translate("xyzabcdef", transtable, "def")
- == "xyzxyz")
-
- def test_data_attributes(self):
- strop.lowercase
- strop.uppercase
- strop.whitespace
-
- @test_support.precisionbigmemtest(size=test_support._2G - 1, memuse=5)
- def test_stropjoin_huge_list(self, size):
- a = "A" * size
- try:
- r = strop.join([a, a], a)
- except OverflowError:
- pass
- else:
- self.assertEqual(len(r), len(a) * 3)
-
- @test_support.precisionbigmemtest(size=test_support._2G - 1, memuse=1)
- def test_stropjoin_huge_tup(self, size):
- a = "A" * size
- try:
- r = strop.join((a, a), a)
- except OverflowError:
- pass # acceptable on 32-bit
- else:
- self.assertEqual(len(r), len(a) * 3)
-
-transtable = '\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037 !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`xyzdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377'
-
-
-# join() now works with any sequence type.
-class Sequence:
- def __init__(self): self.seq = 'wxyz'
- def __len__(self): return len(self.seq)
- def __getitem__(self, i): return self.seq[i]
-
-
-def test_main():
- test_support.run_unittest(StropFunctionTestCase)
-
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index 58e4309a0d7..90aac5b3f67 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -5,7 +5,7 @@ import time
import locale
import re
import sys
-from test import test_support
+from test import support
from datetime import date as datetime_date
import _strptime
@@ -212,7 +212,7 @@ class StrptimeTests(unittest.TestCase):
_strptime._strptime_time("2005", bad_format)
except ValueError:
continue
- except Exception, err:
+ except Exception as err:
self.fail("'%s' raised %s, not ValueError" %
(bad_format, err.__class__.__name__))
else:
@@ -479,8 +479,8 @@ class CalculationTests(unittest.TestCase):
"of the year")
test_helper((1917, 12, 31), "Dec 31 on Monday with year starting and "
"ending on Monday")
- test_helper((2007, 01, 07), "First Sunday of 2007")
- test_helper((2007, 01, 14), "Second Sunday of 2007")
+ test_helper((2007, 1, 7), "First Sunday of 2007")
+ test_helper((2007, 1, 14), "Second Sunday of 2007")
test_helper((2006, 12, 31), "Last Sunday of 2006")
test_helper((2006, 12, 24), "Second to last Sunday of 2006")
@@ -551,7 +551,7 @@ class CacheTests(unittest.TestCase):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
getlang_Tests,
LocaleTime_Tests,
TimeRETests,
diff --git a/Lib/test/test_strtod.py b/Lib/test/test_strtod.py
index 7bc595daf3a..7a42a893b17 100644
--- a/Lib/test/test_strtod.py
+++ b/Lib/test/test_strtod.py
@@ -2,11 +2,10 @@
# introduced in Python 2.7 and 3.1.
import random
-import struct
import unittest
import re
import sys
-from test import test_support
+import test.support
if getattr(sys, 'float_repr_style', '') != 'short':
raise unittest.SkipTest('correctly-rounded string->float conversions '
@@ -113,7 +112,7 @@ class StrtodTests(unittest.TestCase):
lower = -(-2**53//5**k)
if lower % 2 == 0:
lower += 1
- for i in xrange(TEST_SIZE):
+ for i in range(TEST_SIZE):
# Select a random odd n in [2**53/5**k,
# 2**54/5**k). Then n * 10**k gives a halfway case
# with small number of significant digits.
@@ -149,7 +148,7 @@ class StrtodTests(unittest.TestCase):
def test_halfway_cases(self):
# test halfway cases for the round-half-to-even rule
- for i in xrange(100 * TEST_SIZE):
+ for i in range(100 * TEST_SIZE):
# bit pattern for a random finite positive (or +0.0) float
bits = random.randrange(2047*2**52)
@@ -184,7 +183,7 @@ class StrtodTests(unittest.TestCase):
(0, -327, 4941), # zero
]
for n, e, u in boundaries:
- for j in xrange(1000):
+ for j in range(1000):
digits = n + random.randrange(-3*u, 3*u)
exponent = e
s = '{}e{}'.format(digits, exponent)
@@ -197,9 +196,9 @@ class StrtodTests(unittest.TestCase):
# test values close to 2**-1075, the underflow boundary; similar
# to boundary_tests, except that the random error doesn't scale
# with n
- for exponent in xrange(-400, -320):
+ for exponent in range(-400, -320):
base = 10**-exponent // 2**1075
- for j in xrange(TEST_SIZE):
+ for j in range(TEST_SIZE):
digits = base + random.randrange(-1000, 1000)
s = '{}e{}'.format(digits, exponent)
self.check_strtod(s)
@@ -207,7 +206,7 @@ class StrtodTests(unittest.TestCase):
def test_bigcomp(self):
for ndigs in 5, 10, 14, 15, 16, 17, 18, 19, 20, 40, 41, 50:
dig10 = 10**ndigs
- for i in xrange(10 * TEST_SIZE):
+ for i in range(10 * TEST_SIZE):
digits = random.randrange(dig10)
exponent = random.randrange(-400, 400)
s = '{}e{}'.format(digits, exponent)
@@ -220,16 +219,16 @@ class StrtodTests(unittest.TestCase):
# put together random short valid strings
# \d*[.\d*]?e
- for i in xrange(1000):
- for j in xrange(TEST_SIZE):
+ for i in range(1000):
+ for j in range(TEST_SIZE):
s = random.choice(signs)
intpart_len = random.randrange(5)
- s += ''.join(random.choice(digits) for _ in xrange(intpart_len))
+ s += ''.join(random.choice(digits) for _ in range(intpart_len))
if random.choice([True, False]):
s += '.'
fracpart_len = random.randrange(5)
s += ''.join(random.choice(digits)
- for _ in xrange(fracpart_len))
+ for _ in range(fracpart_len))
else:
fracpart_len = 0
if random.choice([True, False]):
@@ -237,7 +236,7 @@ class StrtodTests(unittest.TestCase):
s += random.choice(signs)
exponent_len = random.randrange(1, 4)
s += ''.join(random.choice(digits)
- for _ in xrange(exponent_len))
+ for _ in range(exponent_len))
if intpart_len + fracpart_len:
self.check_strtod(s)
@@ -388,12 +387,19 @@ class StrtodTests(unittest.TestCase):
'999999999999999944488848768742172978818416595458984375e-54',
'9999999999999999444888487687421729788184165954589843749999999e-54',
'9999999999999999444888487687421729788184165954589843750000001e-54',
+ # Value found by Rick Regan that gives a result of 2**-968
+ # under Gay's dtoa.c (as of Nov 04, 2010); since fixed.
+ # (Fixed some time ago in Python's dtoa.c.)
+ '0.0000000000000000000000000000000000000000100000000' #...
+ '000000000576129113423785429971690421191214034235435' #...
+ '087147763178149762956868991692289869941246658073194' #...
+ '51982237978882039897143840789794921875',
]
for s in test_strings:
self.check_strtod(s)
def test_main():
- test_support.run_unittest(StrtodTests)
+ test.support.run_unittest(StrtodTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index c8dc6f17042..dcc73ab8983 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -1,18 +1,16 @@
-import os
import array
import unittest
import struct
-import inspect
-from test import test_support as support
-from test.test_support import (check_warnings, check_py3k_warnings)
-
import sys
+
+from test import support
+
ISBIGENDIAN = sys.byteorder == "big"
IS32BIT = sys.maxsize == 0x7fffffff
integer_codes = 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q'
+byteorders = '', '@', '=', '<', '>', '!'
-testmod_filename = os.path.splitext(__file__)[0] + '.py'
# Native 'q' packing isn't available on systems that don't have the C
# long long type.
try:
@@ -23,7 +21,7 @@ else:
HAVE_LONG_LONG = True
def string_reverse(s):
- return "".join(reversed(s))
+ return s[::-1]
def bigendian_to_native(value):
if ISBIGENDIAN:
@@ -33,21 +31,8 @@ def bigendian_to_native(value):
class StructTest(unittest.TestCase):
- def check_float_coerce(self, format, number):
- # SF bug 1530559. struct.pack raises TypeError where it used
- # to convert.
- with check_warnings((".*integer argument expected, got float",
- DeprecationWarning)) as w:
- got = struct.pack(format, number)
- lineno = inspect.currentframe().f_lineno - 1
- self.assertEqual(w.filename, testmod_filename)
- self.assertEqual(w.lineno, lineno)
- self.assertEqual(len(w.warnings), 1)
- expected = struct.pack(format, int(number))
- self.assertEqual(got, expected)
-
def test_isbigendian(self):
- self.assertEqual((struct.pack('=i', 1)[0] == chr(0)), ISBIGENDIAN)
+ self.assertEqual((struct.pack('=i', 1)[0] == 0), ISBIGENDIAN)
def test_consistence(self):
self.assertRaises(struct.error, struct.calcsize, 'Z')
@@ -65,13 +50,13 @@ class StructTest(unittest.TestCase):
self.assertRaises(struct.error, struct.pack, 'i', 3, 3, 3)
self.assertRaises((TypeError, struct.error), struct.pack, 'i', 'foo')
self.assertRaises((TypeError, struct.error), struct.pack, 'P', 'foo')
- self.assertRaises(struct.error, struct.unpack, 'd', 'flap')
+ self.assertRaises(struct.error, struct.unpack, 'd', b'flap')
s = struct.pack('ii', 1, 2)
self.assertRaises(struct.error, struct.unpack, 'iii', s)
self.assertRaises(struct.error, struct.unpack, 'i', s)
def test_transitiveness(self):
- c = 'a'
+ c = b'a'
b = 1
h = 255
i = 65535
@@ -98,43 +83,43 @@ class StructTest(unittest.TestCase):
# Test some of the new features in detail
# (format, argument, big-endian result, little-endian result, asymmetric)
tests = [
- ('c', 'a', 'a', 'a', 0),
- ('xc', 'a', '\0a', '\0a', 0),
- ('cx', 'a', 'a\0', 'a\0', 0),
- ('s', 'a', 'a', 'a', 0),
- ('0s', 'helloworld', '', '', 1),
- ('1s', 'helloworld', 'h', 'h', 1),
- ('9s', 'helloworld', 'helloworl', 'helloworl', 1),
- ('10s', 'helloworld', 'helloworld', 'helloworld', 0),
- ('11s', 'helloworld', 'helloworld\0', 'helloworld\0', 1),
- ('20s', 'helloworld', 'helloworld'+10*'\0', 'helloworld'+10*'\0', 1),
- ('b', 7, '\7', '\7', 0),
- ('b', -7, '\371', '\371', 0),
- ('B', 7, '\7', '\7', 0),
- ('B', 249, '\371', '\371', 0),
- ('h', 700, '\002\274', '\274\002', 0),
- ('h', -700, '\375D', 'D\375', 0),
- ('H', 700, '\002\274', '\274\002', 0),
- ('H', 0x10000-700, '\375D', 'D\375', 0),
- ('i', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('i', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('I', 70000000L, '\004,\035\200', '\200\035,\004', 0),
- ('I', 0x100000000L-70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('l', 70000000, '\004,\035\200', '\200\035,\004', 0),
- ('l', -70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('L', 70000000L, '\004,\035\200', '\200\035,\004', 0),
- ('L', 0x100000000L-70000000, '\373\323\342\200', '\200\342\323\373', 0),
- ('f', 2.0, '@\000\000\000', '\000\000\000@', 0),
- ('d', 2.0, '@\000\000\000\000\000\000\000',
- '\000\000\000\000\000\000\000@', 0),
- ('f', -2.0, '\300\000\000\000', '\000\000\000\300', 0),
- ('d', -2.0, '\300\000\000\000\000\000\000\000',
- '\000\000\000\000\000\000\000\300', 0),
- ('?', 0, '\0', '\0', 0),
- ('?', 3, '\1', '\1', 1),
- ('?', True, '\1', '\1', 0),
- ('?', [], '\0', '\0', 1),
- ('?', (1,), '\1', '\1', 1),
+ ('c', b'a', b'a', b'a', 0),
+ ('xc', b'a', b'\0a', b'\0a', 0),
+ ('cx', b'a', b'a\0', b'a\0', 0),
+ ('s', b'a', b'a', b'a', 0),
+ ('0s', b'helloworld', b'', b'', 1),
+ ('1s', b'helloworld', b'h', b'h', 1),
+ ('9s', b'helloworld', b'helloworl', b'helloworl', 1),
+ ('10s', b'helloworld', b'helloworld', b'helloworld', 0),
+ ('11s', b'helloworld', b'helloworld\0', b'helloworld\0', 1),
+ ('20s', b'helloworld', b'helloworld'+10*b'\0', b'helloworld'+10*b'\0', 1),
+ ('b', 7, b'\7', b'\7', 0),
+ ('b', -7, b'\371', b'\371', 0),
+ ('B', 7, b'\7', b'\7', 0),
+ ('B', 249, b'\371', b'\371', 0),
+ ('h', 700, b'\002\274', b'\274\002', 0),
+ ('h', -700, b'\375D', b'D\375', 0),
+ ('H', 700, b'\002\274', b'\274\002', 0),
+ ('H', 0x10000-700, b'\375D', b'D\375', 0),
+ ('i', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('i', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('I', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('I', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('l', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('l', -70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('L', 70000000, b'\004,\035\200', b'\200\035,\004', 0),
+ ('L', 0x100000000-70000000, b'\373\323\342\200', b'\200\342\323\373', 0),
+ ('f', 2.0, b'@\000\000\000', b'\000\000\000@', 0),
+ ('d', 2.0, b'@\000\000\000\000\000\000\000',
+ b'\000\000\000\000\000\000\000@', 0),
+ ('f', -2.0, b'\300\000\000\000', b'\000\000\000\300', 0),
+ ('d', -2.0, b'\300\000\000\000\000\000\000\000',
+ b'\000\000\000\000\000\000\000\300', 0),
+ ('?', 0, b'\0', b'\0', 0),
+ ('?', 3, b'\1', b'\1', 1),
+ ('?', True, b'\1', b'\1', 0),
+ ('?', [], b'\0', b'\0', 1),
+ ('?', (1,), b'\1', b'\1', 1),
]
for fmt, arg, big, lil, asy in tests:
@@ -158,14 +143,17 @@ class StructTest(unittest.TestCase):
# standard integer sizes
for code in integer_codes:
- for byteorder in ('=', '<', '>', '!'):
+ for byteorder in '=', '<', '>', '!':
format = byteorder+code
size = struct.calcsize(format)
self.assertEqual(size, expected_size[code])
- # native integer sizes, except 'q' and 'Q'
- for format_pair in ('bB', 'hH', 'iI', 'lL'):
- for byteorder in ['', '@']:
+ # native integer sizes
+ native_pairs = 'bB', 'hH', 'iI', 'lL'
+ if HAVE_LONG_LONG:
+ native_pairs += 'qQ',
+ for format_pair in native_pairs:
+ for byteorder in '', '@':
signed_size = struct.calcsize(byteorder + format_pair[0])
unsigned_size = struct.calcsize(byteorder + format_pair[1])
self.assertEqual(signed_size, unsigned_size)
@@ -176,10 +164,7 @@ class StructTest(unittest.TestCase):
self.assertLessEqual(4, struct.calcsize('l'))
self.assertLessEqual(struct.calcsize('h'), struct.calcsize('i'))
self.assertLessEqual(struct.calcsize('i'), struct.calcsize('l'))
-
- # tests for native 'q' and 'Q' when applicable
if HAVE_LONG_LONG:
- self.assertEqual(struct.calcsize('q'), struct.calcsize('Q'))
self.assertLessEqual(8, struct.calcsize('q'))
self.assertLessEqual(struct.calcsize('l'), struct.calcsize('q'))
@@ -192,20 +177,20 @@ class StructTest(unittest.TestCase):
super(IntTester, self).__init__(methodName='test_one')
self.format = format
self.code = format[-1]
- self.direction = format[:-1]
- if not self.direction in ('', '@', '=', '<', '>', '!'):
- raise ValueError("unrecognized packing direction: %s" %
- self.direction)
+ self.byteorder = format[:-1]
+ if not self.byteorder in byteorders:
+ raise ValueError("unrecognized packing byteorder: %s" %
+ self.byteorder)
self.bytesize = struct.calcsize(format)
self.bitsize = self.bytesize * 8
if self.code in tuple('bhilq'):
self.signed = True
- self.min_value = -(2L**(self.bitsize-1))
- self.max_value = 2L**(self.bitsize-1) - 1
+ self.min_value = -(2**(self.bitsize-1))
+ self.max_value = 2**(self.bitsize-1) - 1
elif self.code in tuple('BHILQ'):
self.signed = False
self.min_value = 0
- self.max_value = 2L**self.bitsize - 1
+ self.max_value = 2**self.bitsize - 1
else:
raise ValueError("unrecognized format code: %s" %
self.code)
@@ -216,18 +201,19 @@ class StructTest(unittest.TestCase):
format = self.format
if self.min_value <= x <= self.max_value:
- expected = long(x)
+ expected = x
if self.signed and x < 0:
- expected += 1L << self.bitsize
+ expected += 1 << self.bitsize
self.assertGreaterEqual(expected, 0)
expected = '%x' % expected
if len(expected) & 1:
expected = "0" + expected
+ expected = expected.encode('ascii')
expected = unhexlify(expected)
- expected = ("\x00" * (self.bytesize - len(expected)) +
+ expected = (b"\x00" * (self.bytesize - len(expected)) +
expected)
- if (self.direction == '<' or
- self.direction in ('', '@', '=') and not ISBIGENDIAN):
+ if (self.byteorder == '<' or
+ self.byteorder in ('', '@', '=') and not ISBIGENDIAN):
expected = string_reverse(expected)
self.assertEqual(len(expected), self.bytesize)
@@ -241,7 +227,7 @@ class StructTest(unittest.TestCase):
# Adding any byte should cause a "too big" error.
self.assertRaises((struct.error, TypeError), unpack, format,
- '\x01' + got)
+ b'\x01' + got)
else:
# x is out of range -- verify pack realizes that.
self.assertRaises((OverflowError, ValueError, struct.error),
@@ -253,17 +239,17 @@ class StructTest(unittest.TestCase):
# Create all interesting powers of 2.
values = []
for exp in range(self.bitsize + 3):
- values.append(1L << exp)
+ values.append(1 << exp)
# Add some random values.
for i in range(self.bitsize):
- val = 0L
+ val = 0
for j in range(self.bytesize):
val = (val << 8) | randrange(256)
values.append(val)
# Values absorbed from other tests
- values.extend([300, 700000, sys.maxint*4])
+ values.extend([300, 700000, sys.maxsize*4])
# Try all those, and their negations, and +-1 from
# them. Note that this tests all power-of-2
@@ -273,24 +259,13 @@ class StructTest(unittest.TestCase):
for val in -base, base:
for incr in -1, 0, 1:
x = val + incr
- self.test_one(int(x))
- self.test_one(long(x))
+ self.test_one(x)
# Some error cases.
- class NotAnIntNS(object):
+ class NotAnInt:
def __int__(self):
return 42
- def __long__(self):
- return 1729L
-
- class NotAnIntOS:
- def __int__(self):
- return 85
-
- def __long__(self):
- return -163L
-
# Objects with an '__index__' method should be allowed
# to pack as integers. That is assuming the implemented
# '__index__' method returns and 'int' or 'long'.
@@ -316,24 +291,15 @@ class StructTest(unittest.TestCase):
self.assertRaises((TypeError, struct.error),
struct.pack, self.format,
randrange)
- with check_warnings(("integer argument expected, "
- "got non-integer", DeprecationWarning)):
- with self.assertRaises((TypeError, struct.error)):
- struct.pack(self.format, 3+42j)
-
- # an attempt to convert a non-integer (with an
- # implicit conversion via __int__) should succeed,
- # with a DeprecationWarning
- for nonint in NotAnIntNS(), NotAnIntOS(), BadIndex():
- with check_warnings((".*integer argument expected, got non"
- "-integer", DeprecationWarning)) as w:
- got = struct.pack(self.format, nonint)
- lineno = inspect.currentframe().f_lineno - 1
- self.assertEqual(w.filename, testmod_filename)
- self.assertEqual(w.lineno, lineno)
- self.assertEqual(len(w.warnings), 1)
- expected = struct.pack(self.format, int(nonint))
- self.assertEqual(got, expected)
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ 3+42j)
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ NotAnInt())
+ self.assertRaises((TypeError, struct.error),
+ struct.pack, self.format,
+ BadIndex())
# Check for legitimate values from '__index__'.
for obj in (Indexable(0), Indexable(10), Indexable(17),
@@ -345,13 +311,12 @@ class StructTest(unittest.TestCase):
"with '__index__' method")
# Check for bogus values from '__index__'.
- for obj in (Indexable('a'), Indexable(u'b'), Indexable(None),
+ for obj in (Indexable(b'a'), Indexable('b'), Indexable(None),
Indexable({'a': 1}), Indexable([1, 2, 3])):
self.assertRaises((TypeError, struct.error),
struct.pack, self.format,
obj)
- byteorders = '', '@', '=', '<', '>', '!'
for code in integer_codes:
for byteorder in byteorders:
if (byteorder in ('', '@') and code in ('q', 'Q') and
@@ -364,14 +329,14 @@ class StructTest(unittest.TestCase):
def test_p_code(self):
# Test p ("Pascal string") code.
for code, input, expected, expectedback in [
- ('p','abc', '\x00', ''),
- ('1p', 'abc', '\x00', ''),
- ('2p', 'abc', '\x01a', 'a'),
- ('3p', 'abc', '\x02ab', 'ab'),
- ('4p', 'abc', '\x03abc', 'abc'),
- ('5p', 'abc', '\x03abc\x00', 'abc'),
- ('6p', 'abc', '\x03abc\x00\x00', 'abc'),
- ('1000p', 'x'*1000, '\xff' + 'x'*999, 'x'*255)]:
+ ('p', b'abc', b'\x00', b''),
+ ('1p', b'abc', b'\x00', b''),
+ ('2p', b'abc', b'\x01a', b'a'),
+ ('3p', b'abc', b'\x02ab', b'ab'),
+ ('4p', b'abc', b'\x03abc', b'abc'),
+ ('5p', b'abc', b'\x03abc\x00', b'abc'),
+ ('6p', b'abc', b'\x03abc\x00\x00', b'abc'),
+ ('1000p', b'x'*1000, b'\xff' + b'x'*999, b'x'*255)]:
got = struct.pack(code, input)
self.assertEqual(got, expected)
(got,) = struct.unpack(code, got)
@@ -413,44 +378,58 @@ class StructTest(unittest.TestCase):
self.assertRaises(OverflowError, struct.pack, ">f", big)
def test_1530559(self):
- # SF bug 1530559. struct.pack raises TypeError where it used to convert.
- for endian in ('', '>', '<'):
- for fmt in integer_codes:
- self.check_float_coerce(endian + fmt, 1.0)
- self.check_float_coerce(endian + fmt, 1.5)
-
- def test_unpack_from(self, cls=str):
- data = cls('abcd01234')
+ for byteorder in '', '@', '=', '<', '>', '!':
+ for code in integer_codes:
+ if (byteorder in ('', '@') and code in ('q', 'Q') and
+ not HAVE_LONG_LONG):
+ continue
+ format = byteorder + code
+ self.assertRaises(struct.error, struct.pack, format, 1.0)
+ self.assertRaises(struct.error, struct.pack, format, 1.5)
+ self.assertRaises(struct.error, struct.pack, 'P', 1.0)
+ self.assertRaises(struct.error, struct.pack, 'P', 1.5)
+
+ def test_unpack_from(self):
+ test_string = b'abcd01234'
fmt = '4s'
s = struct.Struct(fmt)
-
- self.assertEqual(s.unpack_from(data), ('abcd',))
- self.assertEqual(struct.unpack_from(fmt, data), ('abcd',))
- for i in xrange(6):
- self.assertEqual(s.unpack_from(data, i), (data[i:i+4],))
- self.assertEqual(struct.unpack_from(fmt, data, i), (data[i:i+4],))
- for i in xrange(6, len(data) + 1):
- self.assertRaises(struct.error, s.unpack_from, data, i)
- self.assertRaises(struct.error, struct.unpack_from, fmt, data, i)
+ for cls in (bytes, bytearray):
+ data = cls(test_string)
+ self.assertEqual(s.unpack_from(data), (b'abcd',))
+ self.assertEqual(s.unpack_from(data, 2), (b'cd01',))
+ self.assertEqual(s.unpack_from(data, 4), (b'0123',))
+ for i in range(6):
+ self.assertEqual(s.unpack_from(data, i), (data[i:i+4],))
+ for i in range(6, len(test_string) + 1):
+ self.assertRaises(struct.error, s.unpack_from, data, i)
+ for cls in (bytes, bytearray):
+ data = cls(test_string)
+ self.assertEqual(struct.unpack_from(fmt, data), (b'abcd',))
+ self.assertEqual(struct.unpack_from(fmt, data, 2), (b'cd01',))
+ self.assertEqual(struct.unpack_from(fmt, data, 4), (b'0123',))
+ for i in range(6):
+ self.assertEqual(struct.unpack_from(fmt, data, i), (data[i:i+4],))
+ for i in range(6, len(test_string) + 1):
+ self.assertRaises(struct.error, struct.unpack_from, fmt, data, i)
def test_pack_into(self):
- test_string = 'Reykjavik rocks, eow!'
- writable_buf = array.array('c', ' '*100)
+ test_string = b'Reykjavik rocks, eow!'
+ writable_buf = array.array('b', b' '*100)
fmt = '21s'
s = struct.Struct(fmt)
# Test without offset
s.pack_into(writable_buf, 0, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)]
+ from_buf = writable_buf.tobytes()[:len(test_string)]
self.assertEqual(from_buf, test_string)
# Test with offset.
s.pack_into(writable_buf, 10, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)+10]
+ from_buf = writable_buf.tobytes()[:len(test_string)+10]
self.assertEqual(from_buf, test_string[:10] + test_string)
# Go beyond boundaries.
- small_buf = array.array('c', ' '*10)
+ small_buf = array.array('b', b' '*10)
self.assertRaises((ValueError, struct.error), s.pack_into, small_buf, 0,
test_string)
self.assertRaises((ValueError, struct.error), s.pack_into, small_buf, 2,
@@ -462,47 +441,43 @@ class StructTest(unittest.TestCase):
None)
def test_pack_into_fn(self):
- test_string = 'Reykjavik rocks, eow!'
- writable_buf = array.array('c', ' '*100)
+ test_string = b'Reykjavik rocks, eow!'
+ writable_buf = array.array('b', b' '*100)
fmt = '21s'
pack_into = lambda *args: struct.pack_into(fmt, *args)
# Test without offset.
pack_into(writable_buf, 0, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)]
+ from_buf = writable_buf.tobytes()[:len(test_string)]
self.assertEqual(from_buf, test_string)
# Test with offset.
pack_into(writable_buf, 10, test_string)
- from_buf = writable_buf.tostring()[:len(test_string)+10]
+ from_buf = writable_buf.tobytes()[:len(test_string)+10]
self.assertEqual(from_buf, test_string[:10] + test_string)
# Go beyond boundaries.
- small_buf = array.array('c', ' '*10)
+ small_buf = array.array('b', b' '*10)
self.assertRaises((ValueError, struct.error), pack_into, small_buf, 0,
test_string)
self.assertRaises((ValueError, struct.error), pack_into, small_buf, 2,
test_string)
def test_unpack_with_buffer(self):
- with check_py3k_warnings(("buffer.. not supported in 3.x",
- DeprecationWarning)):
- # SF bug 1563759: struct.unpack doesn't support buffer protocol objects
- data1 = array.array('B', '\x12\x34\x56\x78')
- data2 = buffer('......\x12\x34\x56\x78......', 6, 4)
- for data in [data1, data2]:
- value, = struct.unpack('>I', data)
- self.assertEqual(value, 0x12345678)
-
- self.test_unpack_from(cls=buffer)
+ # SF bug 1563759: struct.unpack doesn't support buffer protocol objects
+ data1 = array.array('B', b'\x12\x34\x56\x78')
+ data2 = memoryview(b'\x12\x34\x56\x78') # XXX b'......XXXX......', 6, 4
+ for data in [data1, data2]:
+ value, = struct.unpack('>I', data)
+ self.assertEqual(value, 0x12345678)
def test_bool(self):
class ExplodingBool(object):
- def __nonzero__(self):
+ def __bool__(self):
raise IOError
for prefix in tuple("<>!=")+('',):
false = (), [], [], '', 0
- true = [1], 'test', 5, -1, 0xffffffffL+1, 0xffffffff//2
+ true = [1], 'test', 5, -1, 0xffffffff+1, 0xffffffff/2
falseFormat = prefix + '?' * len(false)
packedFalse = struct.pack(falseFormat, *false)
@@ -528,16 +503,17 @@ class StructTest(unittest.TestCase):
self.assertFalse(prefix, msg='encoded bool is not one byte: %r'
%packed)
- self.assertRaises(IOError, struct.pack, prefix + '?',
- ExplodingBool())
+ try:
+ struct.pack(prefix + '?', ExplodingBool())
+ except IOError:
+ pass
+ else:
+ self.fail("Expected IOError: struct.pack(%r, "
+ "ExplodingBool())" % (prefix + '?'))
for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']:
self.assertTrue(struct.unpack('>?', c)[0])
- @unittest.skipUnless(IS32BIT, "Specific to 32bit machines")
- def test_crasher(self):
- self.assertRaises(MemoryError, struct.pack, "357913941c", "a")
-
def test_count_overflow(self):
hugecount = '{}b'.format(sys.maxsize+1)
self.assertRaises(struct.error, struct.calcsize, hugecount)
@@ -545,6 +521,42 @@ class StructTest(unittest.TestCase):
hugecount2 = '{}b{}H'.format(sys.maxsize//2, sys.maxsize//2)
self.assertRaises(struct.error, struct.calcsize, hugecount2)
+ if IS32BIT:
+ def test_crasher(self):
+ self.assertRaises(MemoryError, struct.pack, "357913941b", "a")
+
+ def test_trailing_counter(self):
+ store = array.array('b', b' '*100)
+
+ # format lists containing only count spec should result in an error
+ self.assertRaises(struct.error, struct.pack, '12345')
+ self.assertRaises(struct.error, struct.unpack, '12345', '')
+ self.assertRaises(struct.error, struct.pack_into, '12345', store, 0)
+ self.assertRaises(struct.error, struct.unpack_from, '12345', store, 0)
+
+ # Format lists with trailing count spec should result in an error
+ self.assertRaises(struct.error, struct.pack, 'c12345', 'x')
+ self.assertRaises(struct.error, struct.unpack, 'c12345', 'x')
+ self.assertRaises(struct.error, struct.pack_into, 'c12345', store, 0,
+ 'x')
+ self.assertRaises(struct.error, struct.unpack_from, 'c12345', store,
+ 0)
+
+ # Mixed format tests
+ self.assertRaises(struct.error, struct.pack, '14s42', 'spam and eggs')
+ self.assertRaises(struct.error, struct.unpack, '14s42',
+ 'spam and eggs')
+ self.assertRaises(struct.error, struct.pack_into, '14s42', store, 0,
+ 'spam and eggs')
+ self.assertRaises(struct.error, struct.unpack_from, '14s42', store, 0)
+
+ def test_Struct_reinitialization(self):
+ # Issue 9422: there was a memory leak when reinitializing a
+ # Struct instance. This test can be used to detect the leak
+ # when running with regrtest -L.
+ s = struct.Struct('i')
+ s.__init__('ii')
+
def check_sizeof(self, format_str, number_of_codes):
# The size of 'PyStructObject'
totalsize = support.calcobjsize('5P')
diff --git a/Lib/test/test_structmembers.py b/Lib/test/test_structmembers.py
index 0cc58c3c728..18fecc38290 100644
--- a/Lib/test/test_structmembers.py
+++ b/Lib/test/test_structmembers.py
@@ -3,13 +3,26 @@ from _testcapi import _test_structmembersType, \
SHRT_MAX, SHRT_MIN, USHRT_MAX, \
INT_MAX, INT_MIN, UINT_MAX, \
LONG_MAX, LONG_MIN, ULONG_MAX, \
- LLONG_MAX, LLONG_MIN, ULLONG_MAX
+ LLONG_MAX, LLONG_MIN, ULLONG_MAX, \
+ PY_SSIZE_T_MAX, PY_SSIZE_T_MIN
import unittest
-from test import test_support
-
-ts=_test_structmembersType(False, 1, 2, 3, 4, 5, 6, 7, 8,
- 9.99999, 10.1010101010, "hi")
+from test import support
+
+ts=_test_structmembersType(False, # T_BOOL
+ 1, # T_BYTE
+ 2, # T_UBYTE
+ 3, # T_SHORT
+ 4, # T_USHORT
+ 5, # T_INT
+ 6, # T_UINT
+ 7, # T_LONG
+ 8, # T_ULONG
+ 23, # T_PYSSIZET
+ 9.99999,# T_FLOAT
+ 10.1010101010, # T_DOUBLE
+ "hi" # T_STRING_INPLACE
+ )
class ReadWriteTests(unittest.TestCase):
@@ -52,6 +65,12 @@ class ReadWriteTests(unittest.TestCase):
ts.T_ULONG = ULONG_MAX
self.assertEqual(ts.T_ULONG, ULONG_MAX)
+ def test_py_ssize_t(self):
+ ts.T_PYSSIZET = PY_SSIZE_T_MAX
+ self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MAX)
+ ts.T_PYSSIZET = PY_SSIZE_T_MIN
+ self.assertEqual(ts.T_PYSSIZET, PY_SSIZE_T_MIN)
+
@unittest.skipUnless(hasattr(ts, "T_LONGLONG"), "long long not present")
def test_longlong(self):
ts.T_LONGLONG = LLONG_MAX
@@ -68,6 +87,24 @@ class ReadWriteTests(unittest.TestCase):
ts.T_ULONGLONG = 4
self.assertEqual(ts.T_ULONGLONG, 4)
+ def test_bad_assignments(self):
+ integer_attributes = [
+ 'T_BOOL',
+ 'T_BYTE', 'T_UBYTE',
+ 'T_SHORT', 'T_USHORT',
+ 'T_INT', 'T_UINT',
+ 'T_LONG', 'T_ULONG',
+ 'T_PYSSIZET'
+ ]
+ if hasattr(ts, 'T_LONGLONG'):
+ integer_attributes.extend(['T_LONGLONG', 'T_ULONGLONG'])
+
+ # issue8014: this produced 'bad argument to internal function'
+ # internal error
+ for nonint in None, 3.2j, "full of eels", {}, []:
+ for attr in integer_attributes:
+ self.assertRaises(TypeError, setattr, ts, attr, nonint)
+
def test_inplace_string(self):
self.assertEqual(ts.T_STRING_INPLACE, "hi")
self.assertRaises(TypeError, setattr, ts, "T_STRING_INPLACE", "s")
@@ -77,32 +114,32 @@ class ReadWriteTests(unittest.TestCase):
class TestWarnings(unittest.TestCase):
def test_byte_max(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_BYTE = CHAR_MAX+1
def test_byte_min(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_BYTE = CHAR_MIN-1
def test_ubyte_max(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_UBYTE = UCHAR_MAX+1
def test_short_max(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_SHORT = SHRT_MAX+1
def test_short_min(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_SHORT = SHRT_MIN-1
def test_ushort_max(self):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
ts.T_USHORT = USHRT_MAX+1
def test_main(verbose=None):
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_structseq.py b/Lib/test/test_structseq.py
index daa12aa4c02..d6c63b792fe 100644
--- a/Lib/test/test_structseq.py
+++ b/Lib/test/test_structseq.py
@@ -1,29 +1,31 @@
+import os
+import time
import unittest
-from test import test_support
+from test import support
-import time
class StructSeqTest(unittest.TestCase):
def test_tuple(self):
t = time.gmtime()
+ self.assertIsInstance(t, tuple)
astuple = tuple(t)
self.assertEqual(len(t), len(astuple))
self.assertEqual(t, astuple)
# Check that slicing works the same way; at one point, slicing t[i:j] with
# 0 < i < j could produce NULLs in the result.
- for i in xrange(-len(t), len(t)):
+ for i in range(-len(t), len(t)):
self.assertEqual(t[i:], astuple[i:])
- for j in xrange(-len(t), len(t)):
+ for j in range(-len(t), len(t)):
self.assertEqual(t[i:j], astuple[i:j])
- for j in xrange(-len(t), len(t)):
+ for j in range(-len(t), len(t)):
self.assertEqual(t[:j], astuple[:j])
self.assertRaises(IndexError, t.__getitem__, -len(t)-1)
self.assertRaises(IndexError, t.__getitem__, len(t))
- for i in xrange(-len(t), len(t)-1):
+ for i in range(-len(t), len(t)-1):
self.assertEqual(t[i], astuple[i])
def test_repr(self):
@@ -33,17 +35,24 @@ class StructSeqTest(unittest.TestCase):
self.assertEqual(repr(t),
"time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, "
"tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)")
+ # os.stat() gives a complicated struct sequence.
+ st = os.stat(__file__)
+ rep = repr(st)
+ self.assertTrue(rep.startswith(os.name + ".stat_result"))
+ self.assertIn("st_mode=", rep)
+ self.assertIn("st_ino=", rep)
+ self.assertIn("st_dev=", rep)
def test_concat(self):
t1 = time.gmtime()
t2 = t1 + tuple(t1)
- for i in xrange(len(t1)):
+ for i in range(len(t1)):
self.assertEqual(t2[i], t2[i+len(t1)])
def test_repeat(self):
t1 = time.gmtime()
t2 = 3 * t1
- for i in xrange(len(t1)):
+ for i in range(len(t1)):
self.assertEqual(t2[i], t2[i+len(t1)])
self.assertEqual(t2[i], t2[i+2*len(t1)])
@@ -114,7 +123,7 @@ class StructSeqTest(unittest.TestCase):
L[start:stop:step])
def test_main():
- test_support.run_unittest(StructSeqTest)
+ support.run_unittest(StructSeqTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index 38844888fdb..75eb852cc97 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1,14 +1,21 @@
import unittest
-from test import test_support
+from test import script_helper
+from test import support
import subprocess
import sys
import signal
+import io
+import locale
import os
import errno
import tempfile
import time
import re
import sysconfig
+import warnings
+import select
+import shutil
+import gc
try:
import resource
@@ -42,7 +49,7 @@ class BaseTestCase(unittest.TestCase):
def setUp(self):
# Try to minimize the number of children we have so this test
# doesn't crash on some buildbots (Alphas in particular).
- test_support.reap_children()
+ support.reap_children()
def tearDown(self):
for inst in subprocess._active:
@@ -54,7 +61,7 @@ class BaseTestCase(unittest.TestCase):
# In a debug build, stuff like "[6580 refs]" is printed to stderr at
# shutdown time. That frustrates tests trying to check stderr produced
# from a spawned Python process.
- actual = re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
+ actual = support.strip_python_stderr(stderr)
self.assertEqual(actual, expected, msg)
@@ -94,8 +101,8 @@ class ProcessTestCase(BaseTestCase):
def test_check_output(self):
# check_output() function with zero return code
output = subprocess.check_output(
- [sys.executable, "-c", "print 'BDFL'"])
- self.assertIn('BDFL', output)
+ [sys.executable, "-c", "print('BDFL')"])
+ self.assertIn(b'BDFL', output)
def test_check_output_nonzero(self):
# check_call() function with non-zero return code
@@ -109,13 +116,13 @@ class ProcessTestCase(BaseTestCase):
output = subprocess.check_output(
[sys.executable, "-c", "import sys; sys.stderr.write('BDFL')"],
stderr=subprocess.STDOUT)
- self.assertIn('BDFL', output)
+ self.assertIn(b'BDFL', output)
def test_check_output_stdout_arg(self):
# check_output() function stderr redirected to stdout
with self.assertRaises(ValueError) as c:
output = subprocess.check_output(
- [sys.executable, "-c", "print 'will not be run'"],
+ [sys.executable, "-c", "print('will not be run')"],
stdout=sys.stdout)
self.fail("Expected ValueError when stdout arg supplied.")
self.assertIn('stdout', c.exception.args[0])
@@ -133,7 +140,7 @@ class ProcessTestCase(BaseTestCase):
def test_invalid_args(self):
# Popen() called with invalid arguments should raise TypeError
# but Popen.__del__ should not complain (issue #12085)
- with test_support.captured_stderr() as s:
+ with support.captured_stderr() as s:
self.assertRaises(TypeError, subprocess.Popen, invalid_arg_name=1)
argcount = subprocess.Popen.__init__.__code__.co_argcount
too_many_args = [0] * (argcount + 1)
@@ -142,7 +149,7 @@ class ProcessTestCase(BaseTestCase):
def test_stdin_none(self):
# .stdin is None when not redirected
- p = subprocess.Popen([sys.executable, "-c", 'print "banana"'],
+ p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
@@ -152,9 +159,9 @@ class ProcessTestCase(BaseTestCase):
def test_stdout_none(self):
# .stdout is None when not redirected
p = subprocess.Popen([sys.executable, "-c",
- 'print " this bit of output is from a '
+ 'print(" this bit of output is from a '
'test of stdout in a different '
- 'process ..."'],
+ 'process ...")'],
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
self.addCleanup(p.stdin.close)
self.addCleanup(p.stderr.close)
@@ -163,38 +170,122 @@ class ProcessTestCase(BaseTestCase):
def test_stderr_none(self):
# .stderr is None when not redirected
- p = subprocess.Popen([sys.executable, "-c", 'print "banana"'],
+ p = subprocess.Popen([sys.executable, "-c", 'print("banana")'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stdin.close)
p.wait()
self.assertEqual(p.stderr, None)
- def test_executable_with_cwd(self):
- python_dir = os.path.dirname(os.path.realpath(sys.executable))
- p = subprocess.Popen(["somethingyoudonthave", "-c",
- "import sys; sys.exit(47)"],
- executable=sys.executable, cwd=python_dir)
+ # For use in the test_cwd* tests below.
+ def _normalize_cwd(self, cwd):
+ # Normalize an expected cwd (for Tru64 support).
+ # We can't use os.path.realpath since it doesn't expand Tru64 {memb}
+ # strings. See bug #1063571.
+ original_cwd = os.getcwd()
+ os.chdir(cwd)
+ cwd = os.getcwd()
+ os.chdir(original_cwd)
+ return cwd
+
+ # For use in the test_cwd* tests below.
+ def _split_python_path(self):
+ # Return normalized (python_dir, python_base).
+ python_path = os.path.realpath(sys.executable)
+ return os.path.split(python_path)
+
+ # For use in the test_cwd* tests below.
+ def _assert_cwd(self, expected_cwd, python_arg, **kwargs):
+ # Invoke Python via Popen, and assert that (1) the call succeeds,
+ # and that (2) the current working directory of the child process
+ # matches *expected_cwd*.
+ p = subprocess.Popen([python_arg, "-c",
+ "import os, sys; "
+ "sys.stdout.write(os.getcwd()); "
+ "sys.exit(47)"],
+ stdout=subprocess.PIPE,
+ **kwargs)
+ self.addCleanup(p.stdout.close)
p.wait()
- self.assertEqual(p.returncode, 47)
+ self.assertEqual(47, p.returncode)
+ normcase = os.path.normcase
+ self.assertEqual(normcase(expected_cwd),
+ normcase(p.stdout.read().decode("utf-8")))
+
+ def test_cwd(self):
+ # Check that cwd changes the cwd for the child process.
+ temp_dir = tempfile.gettempdir()
+ temp_dir = self._normalize_cwd(temp_dir)
+ self._assert_cwd(temp_dir, sys.executable, cwd=temp_dir)
+
+ @unittest.skipIf(mswindows, "pending resolution of issue #15533")
+ def test_cwd_with_relative_arg(self):
+ # Check that Popen looks for args[0] relative to cwd if args[0]
+ # is relative.
+ python_dir, python_base = self._split_python_path()
+ rel_python = os.path.join(os.curdir, python_base)
+ with support.temp_cwd() as wrong_dir:
+ # Before calling with the correct cwd, confirm that the call fails
+ # without cwd and with the wrong cwd.
+ self.assertRaises(OSError, subprocess.Popen,
+ [rel_python])
+ self.assertRaises(OSError, subprocess.Popen,
+ [rel_python], cwd=wrong_dir)
+ python_dir = self._normalize_cwd(python_dir)
+ self._assert_cwd(python_dir, rel_python, cwd=python_dir)
+
+ @unittest.skipIf(mswindows, "pending resolution of issue #15533")
+ def test_cwd_with_relative_executable(self):
+ # Check that Popen looks for executable relative to cwd if executable
+ # is relative (and that executable takes precedence over args[0]).
+ python_dir, python_base = self._split_python_path()
+ rel_python = os.path.join(os.curdir, python_base)
+ doesntexist = "somethingyoudonthave"
+ with support.temp_cwd() as wrong_dir:
+ # Before calling with the correct cwd, confirm that the call fails
+ # without cwd and with the wrong cwd.
+ self.assertRaises(OSError, subprocess.Popen,
+ [doesntexist], executable=rel_python)
+ self.assertRaises(OSError, subprocess.Popen,
+ [doesntexist], executable=rel_python,
+ cwd=wrong_dir)
+ python_dir = self._normalize_cwd(python_dir)
+ self._assert_cwd(python_dir, doesntexist, executable=rel_python,
+ cwd=python_dir)
+
+ def test_cwd_with_absolute_arg(self):
+ # Check that Popen can find the executable when the cwd is wrong
+ # if args[0] is an absolute path.
+ python_dir, python_base = self._split_python_path()
+ abs_python = os.path.join(python_dir, python_base)
+ rel_python = os.path.join(os.curdir, python_base)
+ with script_helper.temp_dir() as wrong_dir:
+ # Before calling with an absolute path, confirm that using a
+ # relative path fails.
+ self.assertRaises(OSError, subprocess.Popen,
+ [rel_python], cwd=wrong_dir)
+ wrong_dir = self._normalize_cwd(wrong_dir)
+ self._assert_cwd(wrong_dir, abs_python, cwd=wrong_dir)
+
+ def test_executable_with_cwd(self):
+ python_dir, python_base = self._split_python_path()
+ python_dir = self._normalize_cwd(python_dir)
+ self._assert_cwd(python_dir, "somethingyoudonthave",
+ executable=sys.executable, cwd=python_dir)
@unittest.skipIf(sysconfig.is_python_build(),
"need an installed Python. See #7774")
def test_executable_without_cwd(self):
# For a normal installation, it should work without 'cwd'
# argument. For test runs in the build directory, see #7774.
- p = subprocess.Popen(["somethingyoudonthave", "-c",
- "import sys; sys.exit(47)"],
- executable=sys.executable)
- p.wait()
- self.assertEqual(p.returncode, 47)
+ self._assert_cwd('', "somethingyoudonthave", executable=sys.executable)
def test_stdin_pipe(self):
# stdin redirection
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.exit(sys.stdin.read() == "pear")'],
stdin=subprocess.PIPE)
- p.stdin.write("pear")
+ p.stdin.write(b"pear")
p.stdin.close()
p.wait()
self.assertEqual(p.returncode, 1)
@@ -202,8 +293,9 @@ class ProcessTestCase(BaseTestCase):
def test_stdin_filedes(self):
# stdin is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
- os.write(d, "pear")
+ os.write(d, b"pear")
os.lseek(d, 0, 0)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.exit(sys.stdin.read() == "pear")'],
@@ -214,7 +306,8 @@ class ProcessTestCase(BaseTestCase):
def test_stdin_fileobj(self):
# stdin is set to open file object
tf = tempfile.TemporaryFile()
- tf.write("pear")
+ self.addCleanup(tf.close)
+ tf.write(b"pear")
tf.seek(0)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.exit(sys.stdin.read() == "pear")'],
@@ -228,28 +321,30 @@ class ProcessTestCase(BaseTestCase):
'import sys; sys.stdout.write("orange")'],
stdout=subprocess.PIPE)
self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read(), "orange")
+ self.assertEqual(p.stdout.read(), b"orange")
def test_stdout_filedes(self):
# stdout is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
stdout=d)
p.wait()
os.lseek(d, 0, 0)
- self.assertEqual(os.read(d, 1024), "orange")
+ self.assertEqual(os.read(d, 1024), b"orange")
def test_stdout_fileobj(self):
# stdout is set to open file object
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stdout.write("orange")'],
stdout=tf)
p.wait()
tf.seek(0)
- self.assertEqual(tf.read(), "orange")
+ self.assertEqual(tf.read(), b"orange")
def test_stderr_pipe(self):
# stderr redirection
@@ -257,95 +352,101 @@ class ProcessTestCase(BaseTestCase):
'import sys; sys.stderr.write("strawberry")'],
stderr=subprocess.PIPE)
self.addCleanup(p.stderr.close)
- self.assertStderrEqual(p.stderr.read(), "strawberry")
+ self.assertStderrEqual(p.stderr.read(), b"strawberry")
def test_stderr_filedes(self):
# stderr is set to open file descriptor
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
d = tf.fileno()
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=d)
p.wait()
os.lseek(d, 0, 0)
- self.assertStderrEqual(os.read(d, 1024), "strawberry")
+ self.assertStderrEqual(os.read(d, 1024), b"strawberry")
def test_stderr_fileobj(self):
# stderr is set to open file object
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
'import sys; sys.stderr.write("strawberry")'],
stderr=tf)
p.wait()
tf.seek(0)
- self.assertStderrEqual(tf.read(), "strawberry")
+ self.assertStderrEqual(tf.read(), b"strawberry")
def test_stdout_stderr_pipe(self):
# capture stdout and stderr to the same pipe
p = subprocess.Popen([sys.executable, "-c",
- 'import sys;'
- 'sys.stdout.write("apple");'
- 'sys.stdout.flush();'
- 'sys.stderr.write("orange")'],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ 'import sys;'
+ 'sys.stdout.write("apple");'
+ 'sys.stdout.flush();'
+ 'sys.stderr.write("orange")'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
self.addCleanup(p.stdout.close)
- self.assertStderrEqual(p.stdout.read(), "appleorange")
+ self.assertStderrEqual(p.stdout.read(), b"appleorange")
def test_stdout_stderr_file(self):
# capture stdout and stderr to the same open file
tf = tempfile.TemporaryFile()
+ self.addCleanup(tf.close)
p = subprocess.Popen([sys.executable, "-c",
- 'import sys;'
- 'sys.stdout.write("apple");'
- 'sys.stdout.flush();'
- 'sys.stderr.write("orange")'],
- stdout=tf,
- stderr=tf)
+ 'import sys;'
+ 'sys.stdout.write("apple");'
+ 'sys.stdout.flush();'
+ 'sys.stderr.write("orange")'],
+ stdout=tf,
+ stderr=tf)
p.wait()
tf.seek(0)
- self.assertStderrEqual(tf.read(), "appleorange")
+ self.assertStderrEqual(tf.read(), b"appleorange")
def test_stdout_filedes_of_stdout(self):
# stdout is set to 1 (#1531862).
- cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))"
+ cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), b'.\n'))"
rc = subprocess.call([sys.executable, "-c", cmd], stdout=1)
self.assertEqual(rc, 2)
- def test_cwd(self):
- tmpdir = tempfile.gettempdir()
- # We cannot use os.path.realpath to canonicalize the path,
- # since it doesn't expand Tru64 {memb} strings. See bug 1063571.
- cwd = os.getcwd()
- os.chdir(tmpdir)
- tmpdir = os.getcwd()
- os.chdir(cwd)
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(os.getcwd())'],
- stdout=subprocess.PIPE,
- cwd=tmpdir)
- self.addCleanup(p.stdout.close)
- normcase = os.path.normcase
- self.assertEqual(normcase(p.stdout.read()), normcase(tmpdir))
-
def test_env(self):
newenv = os.environ.copy()
newenv["FRUIT"] = "orange"
- p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(os.getenv("FRUIT"))'],
- stdout=subprocess.PIPE,
- env=newenv)
- self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read(), "orange")
+ with subprocess.Popen([sys.executable, "-c",
+ 'import sys,os;'
+ 'sys.stdout.write(os.getenv("FRUIT"))'],
+ stdout=subprocess.PIPE,
+ env=newenv) as p:
+ stdout, stderr = p.communicate()
+ self.assertEqual(stdout, b"orange")
+
+ # Windows requires at least the SYSTEMROOT environment variable to start
+ # Python
+ @unittest.skipIf(sys.platform == 'win32',
+ 'cannot test an empty env on Windows')
+ @unittest.skipIf(sysconfig.get_config_var('Py_ENABLE_SHARED') is not None,
+ 'the python library cannot be loaded '
+ 'with an empty environment')
+ def test_empty_env(self):
+ with subprocess.Popen([sys.executable, "-c",
+ 'import os; '
+ 'print(list(os.environ.keys()))'],
+ stdout=subprocess.PIPE,
+ env={}) as p:
+ stdout, stderr = p.communicate()
+ self.assertIn(stdout.strip(),
+ (b"[]",
+ # Mac OS X adds __CF_USER_TEXT_ENCODING variable to an empty
+ # environment
+ b"['__CF_USER_TEXT_ENCODING']"))
def test_communicate_stdin(self):
p = subprocess.Popen([sys.executable, "-c",
'import sys;'
'sys.exit(sys.stdin.read() == "pear")'],
stdin=subprocess.PIPE)
- p.communicate("pear")
+ p.communicate(b"pear")
self.assertEqual(p.returncode, 1)
def test_communicate_stdout(self):
@@ -353,7 +454,7 @@ class ProcessTestCase(BaseTestCase):
'import sys; sys.stdout.write("pineapple")'],
stdout=subprocess.PIPE)
(stdout, stderr) = p.communicate()
- self.assertEqual(stdout, "pineapple")
+ self.assertEqual(stdout, b"pineapple")
self.assertEqual(stderr, None)
def test_communicate_stderr(self):
@@ -362,39 +463,45 @@ class ProcessTestCase(BaseTestCase):
stderr=subprocess.PIPE)
(stdout, stderr) = p.communicate()
self.assertEqual(stdout, None)
- self.assertStderrEqual(stderr, "pineapple")
+ self.assertStderrEqual(stderr, b"pineapple")
def test_communicate(self):
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stderr.write("pineapple");'
- 'sys.stdout.write(sys.stdin.read())'],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ 'import sys,os;'
+ 'sys.stderr.write("pineapple");'
+ 'sys.stdout.write(sys.stdin.read())'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
self.addCleanup(p.stdin.close)
- (stdout, stderr) = p.communicate("banana")
- self.assertEqual(stdout, "banana")
- self.assertStderrEqual(stderr, "pineapple")
+ (stdout, stderr) = p.communicate(b"banana")
+ self.assertEqual(stdout, b"banana")
+ self.assertStderrEqual(stderr, b"pineapple")
- # This test is Linux specific for simplicity to at least have
- # some coverage. It is not a platform specific bug.
- @unittest.skipUnless(os.path.isdir('/proc/%d/fd' % os.getpid()),
- "Linux specific")
# Test for the fd leak reported in http://bugs.python.org/issue2791.
def test_communicate_pipe_fd_leak(self):
- fd_directory = '/proc/%d/fd' % os.getpid()
- num_fds_before_popen = len(os.listdir(fd_directory))
- p = subprocess.Popen([sys.executable, "-c", "print()"],
- stdout=subprocess.PIPE)
- p.communicate()
- num_fds_after_communicate = len(os.listdir(fd_directory))
- del p
- num_fds_after_destruction = len(os.listdir(fd_directory))
- self.assertEqual(num_fds_before_popen, num_fds_after_destruction)
- self.assertEqual(num_fds_before_popen, num_fds_after_communicate)
+ for stdin_pipe in (False, True):
+ for stdout_pipe in (False, True):
+ for stderr_pipe in (False, True):
+ options = {}
+ if stdin_pipe:
+ options['stdin'] = subprocess.PIPE
+ if stdout_pipe:
+ options['stdout'] = subprocess.PIPE
+ if stderr_pipe:
+ options['stderr'] = subprocess.PIPE
+ if not options:
+ continue
+ p = subprocess.Popen((sys.executable, "-c", "pass"), **options)
+ p.communicate()
+ if p.stdin is not None:
+ self.assertTrue(p.stdin.closed)
+ if p.stdout is not None:
+ self.assertTrue(p.stdout.closed)
+ if p.stderr is not None:
+ self.assertTrue(p.stderr.closed)
def test_communicate_returns(self):
# communicate() should return None if no redirection is active
@@ -416,91 +523,154 @@ class ProcessTestCase(BaseTestCase):
os.close(x)
os.close(y)
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(sys.stdin.read(47));'
- 'sys.stderr.write("xyz"*%d);'
- 'sys.stdout.write(sys.stdin.read())' % pipe_buf],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ 'import sys,os;'
+ 'sys.stdout.write(sys.stdin.read(47));'
+ 'sys.stderr.write("xyz"*%d);'
+ 'sys.stdout.write(sys.stdin.read())' % pipe_buf],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
self.addCleanup(p.stdin.close)
- string_to_write = "abc"*pipe_buf
+ string_to_write = b"abc"*pipe_buf
(stdout, stderr) = p.communicate(string_to_write)
self.assertEqual(stdout, string_to_write)
def test_writes_before_communicate(self):
# stdin.write before communicate()
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;'
- 'sys.stdout.write(sys.stdin.read())'],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ 'import sys,os;'
+ 'sys.stdout.write(sys.stdin.read())'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
self.addCleanup(p.stdin.close)
- p.stdin.write("banana")
- (stdout, stderr) = p.communicate("split")
- self.assertEqual(stdout, "bananasplit")
- self.assertStderrEqual(stderr, "")
+ p.stdin.write(b"banana")
+ (stdout, stderr) = p.communicate(b"split")
+ self.assertEqual(stdout, b"bananasplit")
+ self.assertStderrEqual(stderr, b"")
def test_universal_newlines(self):
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
- 'sys.stdout.write("line1\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line2\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line3\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline5");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline6");'],
- stdout=subprocess.PIPE,
- universal_newlines=1)
+ 'import sys,os;' + SETBINARY +
+ 'buf = sys.stdout.buffer;'
+ 'buf.write(sys.stdin.readline().encode());'
+ 'buf.flush();'
+ 'buf.write(b"line2\\n");'
+ 'buf.flush();'
+ 'buf.write(sys.stdin.read().encode());'
+ 'buf.flush();'
+ 'buf.write(b"line4\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line5\\r\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line6\\r");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline7");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline8");'],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=1)
+ p.stdin.write("line1\n")
+ self.assertEqual(p.stdout.readline(), "line1\n")
+ p.stdin.write("line3\n")
+ p.stdin.close()
self.addCleanup(p.stdout.close)
- stdout = p.stdout.read()
- if hasattr(file, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout,
- "line1\nline2\rline3\r\nline4\r\nline5\nline6")
+ self.assertEqual(p.stdout.readline(),
+ "line2\n")
+ self.assertEqual(p.stdout.read(6),
+ "line3\n")
+ self.assertEqual(p.stdout.read(),
+ "line4\nline5\nline6\nline7\nline8")
def test_universal_newlines_communicate(self):
# universal newlines through communicate()
p = subprocess.Popen([sys.executable, "-c",
- 'import sys,os;' + SETBINARY +
- 'sys.stdout.write("line1\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line2\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line3\\r\\n");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("line4\\r");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline5");'
- 'sys.stdout.flush();'
- 'sys.stdout.write("\\nline6");'],
- stdout=subprocess.PIPE, stderr=subprocess.PIPE,
- universal_newlines=1)
+ 'import sys,os;' + SETBINARY +
+ 'buf = sys.stdout.buffer;'
+ 'buf.write(b"line2\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line4\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line5\\r\\n");'
+ 'buf.flush();'
+ 'buf.write(b"line6\\r");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline7");'
+ 'buf.flush();'
+ 'buf.write(b"\\nline8");'],
+ stderr=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=1)
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
+ # BUG: can't give a non-empty stdin because it breaks both the
+ # select- and poll-based communicate() implementations.
(stdout, stderr) = p.communicate()
- if hasattr(file, 'newlines'):
- # Interpreter with universal newline support
- self.assertEqual(stdout,
- "line1\nline2\nline3\nline4\nline5\nline6")
- else:
- # Interpreter without universal newline support
- self.assertEqual(stdout,
- "line1\nline2\rline3\r\nline4\r\nline5\nline6")
+ self.assertEqual(stdout,
+ "line2\nline4\nline5\nline6\nline7\nline8")
+
+ def test_universal_newlines_communicate_stdin(self):
+ # universal newlines through communicate(), with only stdin
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys,os;' + SETBINARY + '''\nif True:
+ s = sys.stdin.readline()
+ assert s == "line1\\n", repr(s)
+ s = sys.stdin.read()
+ assert s == "line3\\n", repr(s)
+ '''],
+ stdin=subprocess.PIPE,
+ universal_newlines=1)
+ (stdout, stderr) = p.communicate("line1\nline3\n")
+ self.assertEqual(p.returncode, 0)
+
+ def test_universal_newlines_communicate_input_none(self):
+ # Test communicate(input=None) with universal newlines.
+ #
+ # We set stdout to PIPE because, as of this writing, a different
+ # code path is tested when the number of pipes is zero or one.
+ p = subprocess.Popen([sys.executable, "-c", "pass"],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ universal_newlines=True)
+ p.communicate()
+ self.assertEqual(p.returncode, 0)
+
+ def test_universal_newlines_communicate_encodings(self):
+ # Check that universal newlines mode works for various encodings,
+ # in particular for encodings in the UTF-16 and UTF-32 families.
+ # See issue #15595.
+ #
+ # UTF-16 and UTF-32-BE are sufficient to check both with BOM and
+ # without, and UTF-16 and UTF-32.
+ for encoding in ['utf-16', 'utf-32-be']:
+ old_getpreferredencoding = locale.getpreferredencoding
+ # Indirectly via io.TextIOWrapper, Popen() defaults to
+ # locale.getpreferredencoding(False) and earlier in Python 3.2 to
+ # locale.getpreferredencoding().
+ def getpreferredencoding(do_setlocale=True):
+ return encoding
+ code = ("import sys; "
+ r"sys.stdout.buffer.write('1\r\n2\r3\n4'.encode('%s'))" %
+ encoding)
+ args = [sys.executable, '-c', code]
+ try:
+ locale.getpreferredencoding = getpreferredencoding
+ # We set stdin to be non-None because, as of this writing,
+ # a different code path is used when the number of pipes is
+ # zero or one.
+ popen = subprocess.Popen(args, universal_newlines=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ stdout, stderr = popen.communicate(input='')
+ finally:
+ locale.getpreferredencoding = old_getpreferredencoding
+
+ self.assertEqual(stdout, '1\n2\n3\n4')
def test_no_leaking(self):
# Make sure we leak no resources
@@ -509,11 +679,12 @@ class ProcessTestCase(BaseTestCase):
else:
max_handles = 2050 # too much for (at least some) Windows setups
handles = []
+ tmpdir = tempfile.mkdtemp()
try:
for i in range(max_handles):
try:
- handles.append(os.open(test_support.TESTFN,
- os.O_WRONLY | os.O_CREAT))
+ tmpfile = os.path.join(tmpdir, support.TESTFN)
+ handles.append(os.open(tmpfile, os.O_WRONLY|os.O_CREAT))
except OSError as e:
if e.errno != errno.EMFILE:
raise
@@ -538,7 +709,7 @@ class ProcessTestCase(BaseTestCase):
finally:
for h in handles:
os.close(h)
- test_support.unlink(test_support.TESTFN)
+ shutil.rmtree(tmpdir)
def test_list2cmdline(self):
self.assertEqual(subprocess.list2cmdline(['a b c', 'd', 'e']),
@@ -589,6 +760,14 @@ class ProcessTestCase(BaseTestCase):
with self.assertRaises(TypeError):
subprocess.Popen([sys.executable, "-c", "pass"], "orange")
+ def test_bufsize_is_none(self):
+ # bufsize=None should be the same as bufsize=0.
+ p = subprocess.Popen([sys.executable, "-c", "pass"], None)
+ self.assertEqual(p.wait(), 0)
+ # Again with keyword arg
+ p = subprocess.Popen([sys.executable, "-c", "pass"], bufsize=None)
+ self.assertEqual(p.wait(), 0)
+
def test_leaking_fds_on_error(self):
# see bug #5179: Popen leaks file descriptors to PIPEs if
# the child fails to execute; this will eventually exhaust
@@ -605,6 +784,17 @@ class ProcessTestCase(BaseTestCase):
if c.exception.errno not in (errno.ENOENT, errno.EACCES):
raise c.exception
+ def test_issue8780(self):
+ # Ensure that stdout is inherited from the parent
+ # if stdout=PIPE is not used
+ code = ';'.join((
+ 'import subprocess, sys',
+ 'retcode = subprocess.call('
+ "[sys.executable, '-c', 'print(\"Hello World!\")'])",
+ 'assert retcode == 0'))
+ output = subprocess.check_output([sys.executable, '-c', code])
+ self.assertTrue(output.startswith(b'Hello World!'), ascii(output))
+
def test_handles_closed_on_exception(self):
# If CreateProcess exits with an error, ensure the
# duplicate output handles are released
@@ -634,7 +824,7 @@ class ProcessTestCase(BaseTestCase):
self.addCleanup(p.stdout.close)
self.addCleanup(p.stderr.close)
self.addCleanup(p.stdin.close)
- p.communicate("x" * 2**20)
+ p.communicate(b"x" * 2**20)
def test_communicate_epipe_only_stdin(self):
# Issue 10963: communicate() should hide EPIPE
@@ -642,7 +832,26 @@ class ProcessTestCase(BaseTestCase):
stdin=subprocess.PIPE)
self.addCleanup(p.stdin.close)
time.sleep(2)
- p.communicate("x" * 2**20)
+ p.communicate(b"x" * 2**20)
+
+ @unittest.skipUnless(hasattr(signal, 'SIGALRM'),
+ "Requires signal.SIGALRM")
+ def test_communicate_eintr(self):
+ # Issue #12493: communicate() should handle EINTR
+ def handler(signum, frame):
+ pass
+ old_handler = signal.signal(signal.SIGALRM, handler)
+ self.addCleanup(signal.signal, signal.SIGALRM, old_handler)
+
+ # the process is running for 2 seconds
+ args = [sys.executable, "-c", 'import time; time.sleep(2)']
+ for stream in ('stdout', 'stderr'):
+ kw = {stream: subprocess.PIPE}
+ with subprocess.Popen(args, **kw) as process:
+ signal.alarm(1)
+ # communicate() will be interrupted by SIGALRM
+ process.communicate()
+
# This test is Linux-ish specific for simplicity to at least have
# some coverage. It is not a platform specific bug.
@@ -690,7 +899,8 @@ class _SuppressCoreFiles(object):
'com.apple.CrashReporter', 'DialogType'],
stdout=subprocess.PIPE).communicate()[0]
if value.strip() == b'developer':
- print "this tests triggers the Crash Reporter, that is intentional"
+ print("this tests triggers the Crash Reporter, "
+ "that is intentional", end='')
sys.stdout.flush()
def __exit__(self, *args):
@@ -703,53 +913,127 @@ class _SuppressCoreFiles(object):
except (ValueError, resource.error):
pass
- @unittest.skipUnless(hasattr(signal, 'SIGALRM'),
- "Requires signal.SIGALRM")
- def test_communicate_eintr(self):
- # Issue #12493: communicate() should handle EINTR
- def handler(signum, frame):
- pass
- old_handler = signal.signal(signal.SIGALRM, handler)
- self.addCleanup(signal.signal, signal.SIGALRM, old_handler)
-
- # the process is running for 2 seconds
- args = [sys.executable, "-c", 'import time; time.sleep(2)']
- for stream in ('stdout', 'stderr'):
- kw = {stream: subprocess.PIPE}
- with subprocess.Popen(args, **kw) as process:
- signal.alarm(1)
- # communicate() will be interrupted by SIGALRM
- process.communicate()
-
@unittest.skipIf(mswindows, "POSIX specific tests")
class POSIXProcessTestCase(BaseTestCase):
- def test_exceptions(self):
- # caught & re-raised exceptions
- with self.assertRaises(OSError) as c:
+ def setUp(self):
+ super().setUp()
+ self._nonexistent_dir = "/_this/pa.th/does/not/exist"
+
+ def _get_chdir_exception(self):
+ try:
+ os.chdir(self._nonexistent_dir)
+ except OSError as e:
+ # This avoids hard coding the errno value or the OS perror()
+ # string and instead capture the exception that we want to see
+ # below for comparison.
+ desired_exception = e
+ desired_exception.strerror += ': ' + repr(self._nonexistent_dir)
+ else:
+ self.fail("chdir to nonexistant directory %s succeeded." %
+ self._nonexistent_dir)
+ return desired_exception
+
+ def test_exception_cwd(self):
+ """Test error in the child raised in the parent for a bad cwd."""
+ desired_exception = self._get_chdir_exception()
+ try:
p = subprocess.Popen([sys.executable, "-c", ""],
- cwd="/this/path/does/not/exist")
- # The attribute child_traceback should contain "os.chdir" somewhere.
- self.assertIn("os.chdir", c.exception.child_traceback)
+ cwd=self._nonexistent_dir)
+ except OSError as e:
+ # Test that the child process chdir failure actually makes
+ # it up to the parent process as the correct exception.
+ self.assertEqual(desired_exception.errno, e.errno)
+ self.assertEqual(desired_exception.strerror, e.strerror)
+ else:
+ self.fail("Expected OSError: %s" % desired_exception)
+
+ def test_exception_bad_executable(self):
+ """Test error in the child raised in the parent for a bad executable."""
+ desired_exception = self._get_chdir_exception()
+ try:
+ p = subprocess.Popen([sys.executable, "-c", ""],
+ executable=self._nonexistent_dir)
+ except OSError as e:
+ # Test that the child process exec failure actually makes
+ # it up to the parent process as the correct exception.
+ self.assertEqual(desired_exception.errno, e.errno)
+ self.assertEqual(desired_exception.strerror, e.strerror)
+ else:
+ self.fail("Expected OSError: %s" % desired_exception)
+
+ def test_exception_bad_args_0(self):
+ """Test error in the child raised in the parent for a bad args[0]."""
+ desired_exception = self._get_chdir_exception()
+ try:
+ p = subprocess.Popen([self._nonexistent_dir, "-c", ""])
+ except OSError as e:
+ # Test that the child process exec failure actually makes
+ # it up to the parent process as the correct exception.
+ self.assertEqual(desired_exception.errno, e.errno)
+ self.assertEqual(desired_exception.strerror, e.strerror)
+ else:
+ self.fail("Expected OSError: %s" % desired_exception)
+
+ def test_restore_signals(self):
+ # Code coverage for both values of restore_signals to make sure it
+ # at least does not blow up.
+ # A test for behavior would be complex. Contributions welcome.
+ subprocess.call([sys.executable, "-c", ""], restore_signals=True)
+ subprocess.call([sys.executable, "-c", ""], restore_signals=False)
+
+ def test_start_new_session(self):
+ # For code coverage of calling setsid(). We don't care if we get an
+ # EPERM error from it depending on the test execution environment, that
+ # still indicates that it was called.
+ try:
+ output = subprocess.check_output(
+ [sys.executable, "-c",
+ "import os; print(os.getpgid(os.getpid()))"],
+ start_new_session=True)
+ except OSError as e:
+ if e.errno != errno.EPERM:
+ raise
+ else:
+ parent_pgid = os.getpgid(os.getpid())
+ child_pgid = int(output)
+ self.assertNotEqual(parent_pgid, child_pgid)
def test_run_abort(self):
# returncode handles signal termination
with _SuppressCoreFiles():
p = subprocess.Popen([sys.executable, "-c",
- "import os; os.abort()"])
+ 'import os; os.abort()'])
p.wait()
self.assertEqual(-p.returncode, signal.SIGABRT)
def test_preexec(self):
- # preexec function
+ # DISCLAIMER: Setting environment variables is *not* a good use
+ # of a preexec_fn. This is merely a test.
p = subprocess.Popen([sys.executable, "-c",
- "import sys, os;"
- "sys.stdout.write(os.getenv('FRUIT'))"],
+ 'import sys,os;'
+ 'sys.stdout.write(os.getenv("FRUIT"))'],
stdout=subprocess.PIPE,
preexec_fn=lambda: os.putenv("FRUIT", "apple"))
self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read(), "apple")
+ self.assertEqual(p.stdout.read(), b"apple")
+
+ def test_preexec_exception(self):
+ def raise_it():
+ raise ValueError("What if two swallows carried a coconut?")
+ try:
+ p = subprocess.Popen([sys.executable, "-c", ""],
+ preexec_fn=raise_it)
+ except RuntimeError as e:
+ self.assertTrue(
+ subprocess._posixsubprocess,
+ "Expected a ValueError from the preexec_fn")
+ except ValueError as e:
+ self.assertIn("coconut", e.args[0])
+ else:
+ self.fail("Exception raised by preexec_fn did not make it "
+ "to the parent process.")
class _TestExecuteChildPopen(subprocess.Popen):
"""Used to test behavior at the end of _execute_child."""
@@ -757,20 +1041,9 @@ class POSIXProcessTestCase(BaseTestCase):
self._testcase = testcase
subprocess.Popen.__init__(self, *args, **kwargs)
- def _execute_child(
- self, args, executable, preexec_fn, close_fds, cwd, env,
- universal_newlines, startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite):
+ def _execute_child(self, *args, **kwargs):
try:
- subprocess.Popen._execute_child(
- self, args, executable, preexec_fn, close_fds,
- cwd, env, universal_newlines,
- startupinfo, creationflags, shell,
- p2cread, p2cwrite,
- c2pread, c2pwrite,
- errread, errwrite)
+ subprocess.Popen._execute_child(self, *args, **kwargs)
finally:
# Open a bunch of file descriptors and verify that
# none of them are the same as the ones the Popen
@@ -780,7 +1053,9 @@ class POSIXProcessTestCase(BaseTestCase):
try:
for fd in devzero_fds:
self._testcase.assertNotIn(
- fd, (p2cwrite, c2pread, errread))
+ fd, (self.stdin.fileno(), self.stdout.fileno(),
+ self.stderr.fileno()),
+ msg="At least one fd was closed early.")
finally:
map(os.close, devzero_fds)
@@ -793,17 +1068,55 @@ class POSIXProcessTestCase(BaseTestCase):
with self.assertRaises(RuntimeError):
self._TestExecuteChildPopen(
- self, [sys.executable, "-c", "pass"],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, preexec_fn=raise_it)
+ self, [sys.executable, "-c", "pass"],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, preexec_fn=raise_it)
+
+ def test_preexec_gc_module_failure(self):
+ # This tests the code that disables garbage collection if the child
+ # process will execute any Python.
+ def raise_runtime_error():
+ raise RuntimeError("this shouldn't escape")
+ enabled = gc.isenabled()
+ orig_gc_disable = gc.disable
+ orig_gc_isenabled = gc.isenabled
+ try:
+ gc.disable()
+ self.assertFalse(gc.isenabled())
+ subprocess.call([sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ self.assertFalse(gc.isenabled(),
+ "Popen enabled gc when it shouldn't.")
+
+ gc.enable()
+ self.assertTrue(gc.isenabled())
+ subprocess.call([sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ self.assertTrue(gc.isenabled(), "Popen left gc disabled.")
+
+ gc.disable = raise_runtime_error
+ self.assertRaises(RuntimeError, subprocess.Popen,
+ [sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+
+ del gc.isenabled # force an AttributeError
+ self.assertRaises(AttributeError, subprocess.Popen,
+ [sys.executable, '-c', ''],
+ preexec_fn=lambda: None)
+ finally:
+ gc.disable = orig_gc_disable
+ gc.isenabled = orig_gc_isenabled
+ if not enabled:
+ gc.disable()
def test_args_string(self):
# args is a string
- f, fname = mkstemp()
- os.write(f, "#!/bin/sh\n")
- os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.close(f)
+ fd, fname = mkstemp()
+ # reopen in text mode
+ with open(fd, "w", errors="surrogateescape") as fobj:
+ fobj.write("#!/bin/sh\n")
+ fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
+ sys.executable)
os.chmod(fname, 0o700)
p = subprocess.Popen(fname)
p.wait()
@@ -829,7 +1142,7 @@ class POSIXProcessTestCase(BaseTestCase):
stdout=subprocess.PIPE,
env=newenv)
self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(), "apple")
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
def test_shell_string(self):
# Run command through the shell (string)
@@ -839,16 +1152,17 @@ class POSIXProcessTestCase(BaseTestCase):
stdout=subprocess.PIPE,
env=newenv)
self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(), "apple")
+ self.assertEqual(p.stdout.read().strip(b" \t\r\n\f"), b"apple")
def test_call_string(self):
# call() function with string argument on UNIX
- f, fname = mkstemp()
- os.write(f, "#!/bin/sh\n")
- os.write(f, "exec '%s' -c 'import sys; sys.exit(47)'\n" %
- sys.executable)
- os.close(f)
- os.chmod(fname, 0700)
+ fd, fname = mkstemp()
+ # reopen in text mode
+ with open(fd, "w", errors="surrogateescape") as fobj:
+ fobj.write("#!/bin/sh\n")
+ fobj.write("exec '%s' -c 'import sys; sys.exit(47)'\n" %
+ sys.executable)
+ os.chmod(fname, 0o700)
rc = subprocess.call(fname)
os.remove(fname)
self.assertEqual(rc, 47)
@@ -871,7 +1185,7 @@ class POSIXProcessTestCase(BaseTestCase):
p = subprocess.Popen("echo $0", executable=sh, shell=True,
stdout=subprocess.PIPE)
self.addCleanup(p.stdout.close)
- self.assertEqual(p.stdout.read().strip(), sh)
+ self.assertEqual(p.stdout.read().strip(), bytes(sh, 'ascii'))
def _kill_process(self, method, *args):
# Do not inherit file handles from the parent.
@@ -916,19 +1230,19 @@ class POSIXProcessTestCase(BaseTestCase):
def test_send_signal(self):
p = self._kill_process('send_signal', signal.SIGINT)
_, stderr = p.communicate()
- self.assertIn('KeyboardInterrupt', stderr)
+ self.assertIn(b'KeyboardInterrupt', stderr)
self.assertNotEqual(p.wait(), 0)
def test_kill(self):
p = self._kill_process('kill')
_, stderr = p.communicate()
- self.assertStderrEqual(stderr, '')
+ self.assertStderrEqual(stderr, b'')
self.assertEqual(p.wait(), -signal.SIGKILL)
def test_terminate(self):
p = self._kill_process('terminate')
_, stderr = p.communicate()
- self.assertStderrEqual(stderr, '')
+ self.assertStderrEqual(stderr, b'')
self.assertEqual(p.wait(), -signal.SIGTERM)
def test_send_signal_dead(self):
@@ -964,7 +1278,7 @@ class POSIXProcessTestCase(BaseTestCase):
stdin=stdin,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).communicate()
- err = test_support.strip_python_stderr(err)
+ err = support.strip_python_stderr(err)
self.assertEqual((out, err), (b'apple', b'orange'))
finally:
for b, a in zip(newfds, fds):
@@ -995,6 +1309,54 @@ class POSIXProcessTestCase(BaseTestCase):
# all standard fds closed.
self.check_close_std_fds([0, 1, 2])
+ def test_remapping_std_fds(self):
+ # open up some temporary files
+ temps = [mkstemp() for i in range(3)]
+ try:
+ temp_fds = [fd for fd, fname in temps]
+
+ # unlink the files -- we won't need to reopen them
+ for fd, fname in temps:
+ os.unlink(fname)
+
+ # write some data to what will become stdin, and rewind
+ os.write(temp_fds[1], b"STDIN")
+ os.lseek(temp_fds[1], 0, 0)
+
+ # move the standard file descriptors out of the way
+ saved_fds = [os.dup(fd) for fd in range(3)]
+ try:
+ # duplicate the file objects over the standard fd's
+ for fd, temp_fd in enumerate(temp_fds):
+ os.dup2(temp_fd, fd)
+
+ # now use those files in the "wrong" order, so that subprocess
+ # has to rearrange them in the child
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys; got = sys.stdin.read();'
+ 'sys.stdout.write("got %s"%got); sys.stderr.write("err")'],
+ stdin=temp_fds[1],
+ stdout=temp_fds[2],
+ stderr=temp_fds[0])
+ p.wait()
+ finally:
+ # restore the original fd's underneath sys.stdin, etc.
+ for std, saved in enumerate(saved_fds):
+ os.dup2(saved, std)
+ os.close(saved)
+
+ for fd in temp_fds:
+ os.lseek(fd, 0, 0)
+
+ out = os.read(temp_fds[2], 1024)
+ err = support.strip_python_stderr(os.read(temp_fds[0], 1024))
+ self.assertEqual(out, b"got STDIN")
+ self.assertEqual(err, b"err")
+
+ finally:
+ for fd in temp_fds:
+ os.close(fd)
+
def check_swap_fds(self, stdin_no, stdout_no, stderr_no):
# open up some temporary files
temps = [mkstemp() for i in range(3)]
@@ -1029,7 +1391,7 @@ class POSIXProcessTestCase(BaseTestCase):
os.lseek(fd, 0, 0)
out = os.read(stdout_no, 1024)
- err = test_support.strip_python_stderr(os.read(stderr_no, 1024))
+ err = support.strip_python_stderr(os.read(stderr_no, 1024))
finally:
for std, saved in enumerate(saved_fds):
os.dup2(saved, std)
@@ -1053,15 +1415,263 @@ class POSIXProcessTestCase(BaseTestCase):
self.check_swap_fds(2, 0, 1)
self.check_swap_fds(2, 1, 0)
+ def test_surrogates_error_message(self):
+ def prepare():
+ raise ValueError("surrogate:\uDCff")
+
+ try:
+ subprocess.call(
+ [sys.executable, "-c", "pass"],
+ preexec_fn=prepare)
+ except ValueError as err:
+ # Pure Python implementations keeps the message
+ self.assertIsNone(subprocess._posixsubprocess)
+ self.assertEqual(str(err), "surrogate:\uDCff")
+ except RuntimeError as err:
+ # _posixsubprocess uses a default message
+ self.assertIsNotNone(subprocess._posixsubprocess)
+ self.assertEqual(str(err), "Exception occurred in preexec_fn.")
+ else:
+ self.fail("Expected ValueError or RuntimeError")
+
+ def test_undecodable_env(self):
+ for key, value in (('test', 'abc\uDCFF'), ('test\uDCFF', '42')):
+ # test str with surrogates
+ script = "import os; print(ascii(os.getenv(%s)))" % repr(key)
+ env = os.environ.copy()
+ env[key] = value
+ # Use C locale to get ascii for the locale encoding to force
+ # surrogate-escaping of \xFF in the child process; otherwise it can
+ # be decoded as-is if the default locale is latin-1.
+ env['LC_ALL'] = 'C'
+ stdout = subprocess.check_output(
+ [sys.executable, "-c", script],
+ env=env)
+ stdout = stdout.rstrip(b'\n\r')
+ self.assertEqual(stdout.decode('ascii'), ascii(value))
+
+ # test bytes
+ key = key.encode("ascii", "surrogateescape")
+ value = value.encode("ascii", "surrogateescape")
+ script = "import os; print(ascii(os.getenvb(%s)))" % repr(key)
+ env = os.environ.copy()
+ env[key] = value
+ stdout = subprocess.check_output(
+ [sys.executable, "-c", script],
+ env=env)
+ stdout = stdout.rstrip(b'\n\r')
+ self.assertEqual(stdout.decode('ascii'), ascii(value))
+
+ def test_bytes_program(self):
+ abs_program = os.fsencode(sys.executable)
+ path, program = os.path.split(sys.executable)
+ program = os.fsencode(program)
+
+ # absolute bytes path
+ exitcode = subprocess.call([abs_program, "-c", "pass"])
+ self.assertEqual(exitcode, 0)
+
+ # bytes program, unicode PATH
+ env = os.environ.copy()
+ env["PATH"] = path
+ exitcode = subprocess.call([program, "-c", "pass"], env=env)
+ self.assertEqual(exitcode, 0)
+
+ # bytes program, bytes PATH
+ envb = os.environb.copy()
+ envb[b"PATH"] = os.fsencode(path)
+ exitcode = subprocess.call([program, "-c", "pass"], env=envb)
+ self.assertEqual(exitcode, 0)
+
+ def test_pipe_cloexec(self):
+ sleeper = support.findfile("input_reader.py", subdir="subprocessdata")
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ p1 = subprocess.Popen([sys.executable, sleeper],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE, close_fds=False)
+
+ self.addCleanup(p1.communicate, b'')
+
+ p2 = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=False)
+
+ output, error = p2.communicate()
+ result_fds = set(map(int, output.split(b',')))
+ unwanted_fds = set([p1.stdin.fileno(), p1.stdout.fileno(),
+ p1.stderr.fileno()])
+
+ self.assertFalse(result_fds & unwanted_fds,
+ "Expected no fds from %r to be open in child, "
+ "found %r" %
+ (unwanted_fds, result_fds & unwanted_fds))
+
+ def test_pipe_cloexec_real_tools(self):
+ qcat = support.findfile("qcat.py", subdir="subprocessdata")
+ qgrep = support.findfile("qgrep.py", subdir="subprocessdata")
+
+ subdata = b'zxcvbn'
+ data = subdata * 4 + b'\n'
+
+ p1 = subprocess.Popen([sys.executable, qcat],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+ close_fds=False)
+
+ p2 = subprocess.Popen([sys.executable, qgrep, subdata],
+ stdin=p1.stdout, stdout=subprocess.PIPE,
+ close_fds=False)
+
+ self.addCleanup(p1.wait)
+ self.addCleanup(p2.wait)
+ def kill_p1():
+ try:
+ p1.terminate()
+ except ProcessLookupError:
+ pass
+ def kill_p2():
+ try:
+ p2.terminate()
+ except ProcessLookupError:
+ pass
+ self.addCleanup(kill_p1)
+ self.addCleanup(kill_p2)
+
+ p1.stdin.write(data)
+ p1.stdin.close()
+
+ readfiles, ignored1, ignored2 = select.select([p2.stdout], [], [], 10)
+
+ self.assertTrue(readfiles, "The child hung")
+ self.assertEqual(p2.stdout.read(), data)
+
+ p1.stdout.close()
+ p2.stdout.close()
+
+ def test_close_fds(self):
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ fds = os.pipe()
+ self.addCleanup(os.close, fds[0])
+ self.addCleanup(os.close, fds[1])
+
+ open_fds = set(fds)
+ # add a bunch more fds
+ for _ in range(9):
+ fd = os.open("/dev/null", os.O_RDONLY)
+ self.addCleanup(os.close, fd)
+ open_fds.add(fd)
+
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=False)
+ output, ignored = p.communicate()
+ remaining_fds = set(map(int, output.split(b',')))
+
+ self.assertEqual(remaining_fds & open_fds, open_fds,
+ "Some fds were closed")
+
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=True)
+ output, ignored = p.communicate()
+ remaining_fds = set(map(int, output.split(b',')))
+
+ self.assertFalse(remaining_fds & open_fds,
+ "Some fds were left open")
+ self.assertIn(1, remaining_fds, "Subprocess failed")
+
+ # Keep some of the fd's we opened open in the subprocess.
+ # This tests _posixsubprocess.c's proper handling of fds_to_keep.
+ fds_to_keep = set(open_fds.pop() for _ in range(8))
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=True,
+ pass_fds=())
+ output, ignored = p.communicate()
+ remaining_fds = set(map(int, output.split(b',')))
+
+ self.assertFalse(remaining_fds & fds_to_keep & open_fds,
+ "Some fds not in pass_fds were left open")
+ self.assertIn(1, remaining_fds, "Subprocess failed")
+
+ # Mac OS X Tiger (10.4) has a kernel bug: sometimes, the file
+ # descriptor of a pipe closed in the parent process is valid in the
+ # child process according to fstat(), but the mode of the file
+ # descriptor is invalid, and read or write raise an error.
+ @support.requires_mac_ver(10, 5)
+ def test_pass_fds(self):
+ fd_status = support.findfile("fd_status.py", subdir="subprocessdata")
+
+ open_fds = set()
+
+ for x in range(5):
+ fds = os.pipe()
+ self.addCleanup(os.close, fds[0])
+ self.addCleanup(os.close, fds[1])
+ open_fds.update(fds)
+
+ for fd in open_fds:
+ p = subprocess.Popen([sys.executable, fd_status],
+ stdout=subprocess.PIPE, close_fds=True,
+ pass_fds=(fd, ))
+ output, ignored = p.communicate()
+
+ remaining_fds = set(map(int, output.split(b',')))
+ to_be_closed = open_fds - {fd}
+
+ self.assertIn(fd, remaining_fds, "fd to be passed not passed")
+ self.assertFalse(remaining_fds & to_be_closed,
+ "fd to be closed passed")
+
+ # pass_fds overrides close_fds with a warning.
+ with self.assertWarns(RuntimeWarning) as context:
+ self.assertFalse(subprocess.call(
+ [sys.executable, "-c", "import sys; sys.exit(0)"],
+ close_fds=False, pass_fds=(fd, )))
+ self.assertIn('overriding close_fds', str(context.warning))
+
+ def test_stdout_stdin_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stdout=inout, stdin=inout)
+ p.wait()
+
+ def test_stdout_stderr_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stdout=inout, stderr=inout)
+ p.wait()
+
+ def test_stderr_stdin_are_single_inout_fd(self):
+ with io.open(os.devnull, "r+") as inout:
+ p = subprocess.Popen([sys.executable, "-c", "import sys; sys.exit(0)"],
+ stderr=inout, stdin=inout)
+ p.wait()
+
def test_wait_when_sigchild_ignored(self):
# NOTE: sigchild_ignore.py may not be an effective test on all OSes.
- sigchild_ignore = test_support.findfile("sigchild_ignore.py",
- subdir="subprocessdata")
+ sigchild_ignore = support.findfile("sigchild_ignore.py",
+ subdir="subprocessdata")
p = subprocess.Popen([sys.executable, sigchild_ignore],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
self.assertEqual(0, p.returncode, "sigchild_ignore.py exited"
- " non-zero with this error:\n%s" % stderr)
+ " non-zero with this error:\n%s" %
+ stderr.decode('utf8'))
+
+ def test_select_unbuffered(self):
+ # Issue #11459: bufsize=0 should really set the pipes as
+ # unbuffered (and therefore let select() work properly).
+ select = support.import_module("select")
+ p = subprocess.Popen([sys.executable, "-c",
+ 'import sys;'
+ 'sys.stdout.write("apple")'],
+ stdout=subprocess.PIPE,
+ bufsize=0)
+ f = p.stdout
+ self.addCleanup(f.close)
+ try:
+ self.assertEqual(f.read(4), b"appl")
+ self.assertIn(f, select.select([f], [], [], 0.0)[0])
+ finally:
+ p.wait()
def test_zombie_fast_process_del(self):
# Issue #12650: on Unix, if Popen.__del__() was called before the
@@ -1113,37 +1723,6 @@ class POSIXProcessTestCase(BaseTestCase):
self.assertRaises(OSError, os.waitpid, pid, 0)
self.assertNotIn(ident, [id(o) for o in subprocess._active])
- def test_pipe_cloexec(self):
- # Issue 12786: check that the communication pipes' FDs are set CLOEXEC,
- # and are not inherited by another child process.
- p1 = subprocess.Popen([sys.executable, "-c",
- 'import os;'
- 'os.read(0, 1)'
- ],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
-
- p2 = subprocess.Popen([sys.executable, "-c", """if True:
- import os, errno, sys
- for fd in %r:
- try:
- os.close(fd)
- except OSError as e:
- if e.errno != errno.EBADF:
- raise
- else:
- sys.exit(1)
- sys.exit(0)
- """ % [f.fileno() for f in (p1.stdin, p1.stdout,
- p1.stderr)]
- ],
- stdin=subprocess.PIPE, stdout=subprocess.PIPE,
- stderr=subprocess.PIPE, close_fds=False)
- p1.communicate('foo')
- _, stderr = p2.communicate()
-
- self.assertEqual(p2.returncode, 0, "Unexpected error: " + repr(stderr))
-
@unittest.skipUnless(mswindows, "Windows specific tests")
class Win32ProcessTestCase(BaseTestCase):
@@ -1198,7 +1777,7 @@ class Win32ProcessTestCase(BaseTestCase):
stdout=subprocess.PIPE,
env=newenv)
self.addCleanup(p.stdout.close)
- self.assertIn("physalis", p.stdout.read())
+ self.assertIn(b"physalis", p.stdout.read())
def test_shell_string(self):
# Run command through the shell (string)
@@ -1208,7 +1787,7 @@ class Win32ProcessTestCase(BaseTestCase):
stdout=subprocess.PIPE,
env=newenv)
self.addCleanup(p.stdout.close)
- self.assertIn("physalis", p.stdout.read())
+ self.assertIn(b"physalis", p.stdout.read())
def test_call_string(self):
# call() function with string argument on Windows
@@ -1235,7 +1814,7 @@ class Win32ProcessTestCase(BaseTestCase):
p.stdout.read(1)
getattr(p, method)(*args)
_, stderr = p.communicate()
- self.assertStderrEqual(stderr, '')
+ self.assertStderrEqual(stderr, b'')
returncode = p.wait()
self.assertNotEqual(returncode, 0)
@@ -1283,6 +1862,33 @@ class Win32ProcessTestCase(BaseTestCase):
self._kill_dead_process('terminate')
+# The module says:
+# "NB This only works (and is only relevant) for UNIX."
+#
+# Actually, getoutput should work on any platform with an os.popen, but
+# I'll take the comment as given, and skip this suite.
+@unittest.skipUnless(os.name == 'posix', "only relevant for UNIX")
+class CommandTests(unittest.TestCase):
+ def test_getoutput(self):
+ self.assertEqual(subprocess.getoutput('echo xyzzy'), 'xyzzy')
+ self.assertEqual(subprocess.getstatusoutput('echo xyzzy'),
+ (0, 'xyzzy'))
+
+ # we use mkdtemp in the next line to create an empty directory
+ # under our exclusive control; from that, we can invent a pathname
+ # that we _know_ won't exist. This is guaranteed to fail.
+ dir = None
+ try:
+ dir = tempfile.mkdtemp()
+ name = os.path.join(dir, "foo")
+
+ status, output = subprocess.getstatusoutput('cat ' + name)
+ self.assertNotEqual(status, 0)
+ finally:
+ if dir is not None:
+ os.rmdir(dir)
+
+
@unittest.skipUnless(getattr(subprocess, '_has_poll', False),
"poll system call not supported")
class ProcessTestCaseNoPoll(ProcessTestCase):
@@ -1295,6 +1901,28 @@ class ProcessTestCaseNoPoll(ProcessTestCase):
ProcessTestCase.tearDown(self)
+@unittest.skipUnless(getattr(subprocess, '_posixsubprocess', False),
+ "_posixsubprocess extension module not found.")
+class ProcessTestCasePOSIXPurePython(ProcessTestCase, POSIXProcessTestCase):
+ @classmethod
+ def setUpClass(cls):
+ global subprocess
+ assert subprocess._posixsubprocess
+ # Reimport subprocess while forcing _posixsubprocess to not exist.
+ with support.check_warnings(('.*_posixsubprocess .* not being used.*',
+ RuntimeWarning)):
+ subprocess = support.import_fresh_module(
+ 'subprocess', blocked=['_posixsubprocess'])
+ assert not subprocess._posixsubprocess
+
+ @classmethod
+ def tearDownClass(cls):
+ global subprocess
+ # Reimport subprocess as it should be, restoring order to the universe.
+ subprocess = support.import_fresh_module('subprocess')
+ assert subprocess._posixsubprocess
+
+
class HelperFunctionTests(unittest.TestCase):
@unittest.skipIf(mswindows, "errno and EINTR make no sense on windows")
def test_eintr_retry_call(self):
@@ -1313,11 +1941,12 @@ class HelperFunctionTests(unittest.TestCase):
subprocess._eintr_retry_call(fake_os_func, 666))
self.assertEqual([(256, 999), (666,), (666,)], record_calls)
-@unittest.skipUnless(mswindows, "mswindows only")
+
+@unittest.skipUnless(mswindows, "Windows-specific tests")
class CommandsWithSpaces (BaseTestCase):
def setUp(self):
- super(CommandsWithSpaces, self).setUp()
+ super().setUp()
f, fname = mkstemp(".py", "te st")
self.fname = fname.lower ()
os.write(f, b"import sys;"
@@ -1327,7 +1956,7 @@ class CommandsWithSpaces (BaseTestCase):
def tearDown(self):
os.remove(self.fname)
- super(CommandsWithSpaces, self).tearDown()
+ super().tearDown()
def with_spaces(self, *args, **kwargs):
kwargs['stdout'] = subprocess.PIPE
@@ -1356,16 +1985,61 @@ class CommandsWithSpaces (BaseTestCase):
# call() function with sequence argument with spaces on Windows
self.with_spaces([sys.executable, self.fname, "ab cd"])
+
+class ContextManagerTests(BaseTestCase):
+
+ def test_pipe(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.stdout.write('stdout');"
+ "sys.stderr.write('stderr');"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE) as proc:
+ self.assertEqual(proc.stdout.read(), b"stdout")
+ self.assertStderrEqual(proc.stderr.read(), b"stderr")
+
+ self.assertTrue(proc.stdout.closed)
+ self.assertTrue(proc.stderr.closed)
+
+ def test_returncode(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys; sys.exit(100)"]) as proc:
+ pass
+ # __exit__ calls wait(), so the returncode should be set
+ self.assertEqual(proc.returncode, 100)
+
+ def test_communicate_stdin(self):
+ with subprocess.Popen([sys.executable, "-c",
+ "import sys;"
+ "sys.exit(sys.stdin.read() == 'context')"],
+ stdin=subprocess.PIPE) as proc:
+ proc.communicate(b"context")
+ self.assertEqual(proc.returncode, 1)
+
+ def test_invalid_args(self):
+ with self.assertRaises(EnvironmentError) as c:
+ with subprocess.Popen(['nonexisting_i_hope'],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE) as proc:
+ pass
+
+ self.assertEqual(c.exception.errno, errno.ENOENT)
+
+
def test_main():
unit_tests = (ProcessTestCase,
POSIXProcessTestCase,
Win32ProcessTestCase,
+ ProcessTestCasePOSIXPurePython,
+ CommandTests,
ProcessTestCaseNoPoll,
HelperFunctionTests,
- CommandsWithSpaces)
+ CommandsWithSpaces,
+ ContextManagerTests,
+ )
- test_support.run_unittest(*unit_tests)
- test_support.reap_children()
+ support.run_unittest(*unit_tests)
+ support.reap_children()
if __name__ == "__main__":
- test_main()
+ unittest.main()
diff --git a/Lib/test/test_sunau.py b/Lib/test/test_sunau.py
new file mode 100644
index 00000000000..339ab576d5c
--- /dev/null
+++ b/Lib/test/test_sunau.py
@@ -0,0 +1,70 @@
+from test.support import run_unittest, TESTFN
+import unittest
+import os
+
+import sunau
+
+nchannels = 2
+sampwidth = 2
+framerate = 8000
+nframes = 100
+
+class SunAUTest(unittest.TestCase):
+
+ def setUp(self):
+ self.f = None
+
+ def tearDown(self):
+ if self.f is not None:
+ self.f.close()
+ try:
+ os.remove(TESTFN)
+ except OSError:
+ pass
+
+ def test_lin(self):
+ self.f = sunau.open(TESTFN, 'w')
+ self.f.setnchannels(nchannels)
+ self.f.setsampwidth(sampwidth)
+ self.f.setframerate(framerate)
+ self.f.setcomptype('NONE', 'not compressed')
+ output = b'\xff\x00\x12\xcc' * (nframes * nchannels * sampwidth // 4)
+ self.f.writeframes(output)
+ self.f.close()
+
+ self.f = sunau.open(TESTFN, 'rb')
+ self.assertEqual(nchannels, self.f.getnchannels())
+ self.assertEqual(sampwidth, self.f.getsampwidth())
+ self.assertEqual(framerate, self.f.getframerate())
+ self.assertEqual(nframes, self.f.getnframes())
+ self.assertEqual('NONE', self.f.getcomptype())
+ self.assertEqual(self.f.readframes(nframes), output)
+ self.f.close()
+
+ def test_ulaw(self):
+ self.f = sunau.open(TESTFN, 'w')
+ self.f.setnchannels(nchannels)
+ self.f.setsampwidth(sampwidth)
+ self.f.setframerate(framerate)
+ self.f.setcomptype('ULAW', '')
+ # u-law compression is lossy, therefore we can't expect non-zero data
+ # to come back unchanged.
+ output = b'\0' * nframes * nchannels * sampwidth
+ self.f.writeframes(output)
+ self.f.close()
+
+ self.f = sunau.open(TESTFN, 'rb')
+ self.assertEqual(nchannels, self.f.getnchannels())
+ self.assertEqual(sampwidth, self.f.getsampwidth())
+ self.assertEqual(framerate, self.f.getframerate())
+ self.assertEqual(nframes, self.f.getnframes())
+ self.assertEqual('ULAW', self.f.getcomptype())
+ self.assertEqual(self.f.readframes(nframes), output)
+ self.f.close()
+
+
+def test_main():
+ run_unittest(SunAUTest)
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/test_sunaudiodev.py b/Lib/test/test_sunaudiodev.py
deleted file mode 100644
index c96f711819f..00000000000
--- a/Lib/test/test_sunaudiodev.py
+++ /dev/null
@@ -1,33 +0,0 @@
-from test.test_support import findfile, TestFailed, import_module
-import unittest
-sunaudiodev = import_module('sunaudiodev', deprecated=True)
-import os
-
-try:
- audiodev = os.environ["AUDIODEV"]
-except KeyError:
- audiodev = "/dev/audio"
-
-if not os.path.exists(audiodev):
- raise unittest.SkipTest("no audio device found!")
-
-def play_sound_file(path):
- fp = open(path, 'r')
- data = fp.read()
- fp.close()
- try:
- a = sunaudiodev.open('w')
- except sunaudiodev.error, msg:
- raise TestFailed, msg
- else:
- a.write(data)
- a.close()
-
-
-def test_main():
- play_sound_file(findfile('audiotest.au'))
-
-
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_sundry.py b/Lib/test/test_sundry.py
index 6e2b7971f72..07802d6263f 100644
--- a/Lib/test/test_sundry.py
+++ b/Lib/test/test_sundry.py
@@ -1,19 +1,15 @@
"""Do a minimal test of all the modules that aren't otherwise tested."""
-from test import test_support
+from test import support
import sys
import unittest
-
class TestUntestedModules(unittest.TestCase):
def test_at_least_import_untested_modules(self):
- with test_support.check_warnings(quiet=True):
- import CGIHTTPServer
- import audiodev
+ with support.check_warnings(quiet=True):
import bdb
import cgitb
import code
- import compileall
import distutils.bcppcompiler
import distutils.ccompiler
@@ -47,50 +43,26 @@ class TestUntestedModules(unittest.TestCase):
import encodings
import formatter
import getpass
- import htmlentitydefs
- import ihooks
+ import html.entities
import imghdr
- import imputil
import keyword
- import linecache
import macurl2path
import mailcap
- import mimify
- import nntplib
import nturl2path
- import opcode
import os2emxpath
- import pdb
- import posixfile
import pstats
import py_compile
- import rexec
- import sched
import sndhdr
- import statvfs
- import stringold
- import sunau
- import sunaudio
- import symbol
import tabnanny
- import timeit
- import toaiff
- import token
try:
import tty # not available on Windows
except ImportError:
- if test_support.verbose:
- print "skipping tty"
-
- # Can't test the "user" module -- if the user has a ~/.pythonrc.py, it
- # can screw up all sorts of things (esp. if it prints!).
- #import user
- import webbrowser
- import xml
+ if support.verbose:
+ print("skipping tty")
def test_main():
- test_support.run_unittest(TestUntestedModules)
+ support.run_unittest(TestUntestedModules)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_super.py b/Lib/test/test_super.py
new file mode 100644
index 00000000000..914216d2dab
--- /dev/null
+++ b/Lib/test/test_super.py
@@ -0,0 +1,90 @@
+"""Unit tests for new super() implementation."""
+
+import sys
+import unittest
+from test import support
+
+
+class A:
+ def f(self):
+ return 'A'
+ @classmethod
+ def cm(cls):
+ return (cls, 'A')
+
+class B(A):
+ def f(self):
+ return super().f() + 'B'
+ @classmethod
+ def cm(cls):
+ return (cls, super().cm(), 'B')
+
+class C(A):
+ def f(self):
+ return super().f() + 'C'
+ @classmethod
+ def cm(cls):
+ return (cls, super().cm(), 'C')
+
+class D(C, B):
+ def f(self):
+ return super().f() + 'D'
+ def cm(cls):
+ return (cls, super().cm(), 'D')
+
+class E(D):
+ pass
+
+class F(E):
+ f = E.f
+
+class G(A):
+ pass
+
+
+class TestSuper(unittest.TestCase):
+
+ def test_basics_working(self):
+ self.assertEqual(D().f(), 'ABCD')
+
+ def test_class_getattr_working(self):
+ self.assertEqual(D.f(D()), 'ABCD')
+
+ def test_subclass_no_override_working(self):
+ self.assertEqual(E().f(), 'ABCD')
+ self.assertEqual(E.f(E()), 'ABCD')
+
+ def test_unbound_method_transfer_working(self):
+ self.assertEqual(F().f(), 'ABCD')
+ self.assertEqual(F.f(F()), 'ABCD')
+
+ def test_class_methods_still_working(self):
+ self.assertEqual(A.cm(), (A, 'A'))
+ self.assertEqual(A().cm(), (A, 'A'))
+ self.assertEqual(G.cm(), (G, 'A'))
+ self.assertEqual(G().cm(), (G, 'A'))
+
+ def test_super_in_class_methods_working(self):
+ d = D()
+ self.assertEqual(d.cm(), (d, (D, (D, (D, 'A'), 'B'), 'C'), 'D'))
+ e = E()
+ self.assertEqual(e.cm(), (e, (E, (E, (E, 'A'), 'B'), 'C'), 'D'))
+
+ def test_super_with_closure(self):
+ # Issue4360: super() did not work in a function that
+ # contains a closure
+ class E(A):
+ def f(self):
+ def nested():
+ self
+ return super().f() + 'E'
+
+ self.assertEqual(E().f(), 'AE')
+
+
+def test_main():
+ support.run_unittest(TestSuper)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/Lib/test/test_symtable.py b/Lib/test/test_symtable.py
index c437e86d8bb..335b4dc15f2 100644
--- a/Lib/test/test_symtable.py
+++ b/Lib/test/test_symtable.py
@@ -4,7 +4,7 @@ Test the API of the symtable module.
import symtable
import unittest
-from test import test_support
+from test import support
TEST_CODE = """
@@ -27,8 +27,7 @@ def spam(a, b, *var, **kw):
return internal
def foo():
- exec 'm'
- from sys import *
+ pass
def namespace_test(): pass
def namespace_test(): pass
@@ -43,9 +42,7 @@ def find_block(block, name):
class SymtableTest(unittest.TestCase):
- with test_support.check_warnings(
- ("import \* only allowed at module level", SyntaxWarning)):
- top = symtable.symtable(TEST_CODE, "?", "exec")
+ top = symtable.symtable(TEST_CODE, "?", "exec")
# These correspond to scopes in TEST_CODE
Mine = find_block(top, "Mine")
a_method = find_block(Mine, "a_method")
@@ -63,14 +60,9 @@ class SymtableTest(unittest.TestCase):
def test_optimized(self):
self.assertFalse(self.top.is_optimized())
self.assertFalse(self.top.has_exec())
- self.assertFalse(self.top.has_import_star())
self.assertTrue(self.spam.is_optimized())
- self.assertFalse(self.foo.is_optimized())
- self.assertTrue(self.foo.has_exec())
- self.assertTrue(self.foo.has_import_star())
-
def test_nested(self):
self.assertFalse(self.top.is_nested())
self.assertFalse(self.Mine.is_nested())
@@ -178,7 +170,7 @@ class SymtableTest(unittest.TestCase):
def test_main():
- test_support.run_unittest(SymtableTest)
+ support.run_unittest(SymtableTest)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 7994fe67e72..5926b69c93b 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -5,7 +5,7 @@ Here's an example of the sort of thing that is tested.
>>> def f(x):
... global x
Traceback (most recent call last):
-SyntaxError: name 'x' is local and global (<doctest test.test_syntax[0]>, line 1)
+SyntaxError: name 'x' is parameter and global
The tests are all raise SyntaxErrors. They were created by checking
each C call that raises SyntaxError. There are several modules that
@@ -29,13 +29,11 @@ Errors from set_context():
>>> obj.None = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[1]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
>>> None = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[2]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: assignment to keyword
It's a syntax error to assign to the empty tuple. Why isn't it an
error to assign to the empty list? It will always raise some error at
@@ -43,43 +41,39 @@ runtime.
>>> () = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[3]>", line 1
SyntaxError: can't assign to ()
>>> f() = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[4]>", line 1
SyntaxError: can't assign to function call
>>> del f()
Traceback (most recent call last):
- File "<doctest test.test_syntax[5]>", line 1
SyntaxError: can't delete function call
>>> a + 1 = 2
Traceback (most recent call last):
- File "<doctest test.test_syntax[6]>", line 1
SyntaxError: can't assign to operator
>>> (x for x in x) = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[7]>", line 1
SyntaxError: can't assign to generator expression
>>> 1 = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[8]>", line 1
SyntaxError: can't assign to literal
>>> "abc" = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[8]>", line 1
+SyntaxError: can't assign to literal
+
+>>> b"" = 1
+Traceback (most recent call last):
SyntaxError: can't assign to literal
>>> `1` = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[10]>", line 1
-SyntaxError: can't assign to repr
+SyntaxError: invalid syntax
If the left-hand side of an assignment is a list or tuple, an illegal
expression inside that contain should still cause a syntax error.
@@ -88,17 +82,14 @@ them.
>>> (a, "b", c) = (1, 2, 3)
Traceback (most recent call last):
- File "<doctest test.test_syntax[11]>", line 1
SyntaxError: can't assign to literal
>>> [a, b, c + 1] = [1, 2, 3]
Traceback (most recent call last):
- File "<doctest test.test_syntax[12]>", line 1
SyntaxError: can't assign to operator
>>> a if 1 else b = 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[13]>", line 1
SyntaxError: can't assign to conditional expression
From compiler_complex_args():
@@ -106,8 +97,7 @@ From compiler_complex_args():
>>> def f(None=1):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[14]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
From ast_for_arguments():
@@ -115,26 +105,22 @@ From ast_for_arguments():
>>> def f(x, y=1, z):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[15]>", line 1
SyntaxError: non-default argument follows default argument
>>> def f(x, None):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[16]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
>>> def f(*None):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[17]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
>>> def f(**None):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[18]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
From ast_for_funcdef():
@@ -142,8 +128,7 @@ From ast_for_funcdef():
>>> def None(x):
... pass
Traceback (most recent call last):
- File "<doctest test.test_syntax[19]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: invalid syntax
From ast_for_call():
@@ -155,7 +140,6 @@ From ast_for_call():
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> f(x for x in L, 1)
Traceback (most recent call last):
- File "<doctest test.test_syntax[23]>", line 1
SyntaxError: Generator expression must be parenthesized if not sole argument
>>> f((x for x in L), 1)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@@ -188,7 +172,6 @@ SyntaxError: Generator expression must be parenthesized if not sole argument
... i244, i245, i246, i247, i248, i249, i250, i251, i252,
... i253, i254, i255)
Traceback (most recent call last):
- File "<doctest test.test_syntax[25]>", line 1
SyntaxError: more than 255 arguments
The actual error cases counts positional arguments, keyword arguments,
@@ -223,12 +206,10 @@ three.
... (x for x in i244), i245, i246, i247, i248, i249, i250, i251,
... i252=1, i253=1, i254=1, i255=1)
Traceback (most recent call last):
- File "<doctest test.test_syntax[26]>", line 1
SyntaxError: more than 255 arguments
>>> f(lambda x: x[0] = 3)
Traceback (most recent call last):
- File "<doctest test.test_syntax[27]>", line 1
SyntaxError: lambda cannot contain assignment
The grammar accepts any test (basically, any expression) in the
@@ -236,15 +217,12 @@ keyword slot of a call site. Test a few different options.
>>> f(x()=2)
Traceback (most recent call last):
- File "<doctest test.test_syntax[28]>", line 1
SyntaxError: keyword can't be an expression
>>> f(a or b=1)
Traceback (most recent call last):
- File "<doctest test.test_syntax[29]>", line 1
SyntaxError: keyword can't be an expression
>>> f(x.y=1)
Traceback (most recent call last):
- File "<doctest test.test_syntax[30]>", line 1
SyntaxError: keyword can't be an expression
@@ -252,15 +230,12 @@ More set_context():
>>> (x for x in x) += 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[31]>", line 1
SyntaxError: can't assign to generator expression
>>> None += 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[32]>", line 1
-SyntaxError: cannot assign to None
+SyntaxError: assignment to keyword
>>> f() += 1
Traceback (most recent call last):
- File "<doctest test.test_syntax[33]>", line 1
SyntaxError: can't assign to function call
@@ -274,7 +249,7 @@ continue in for loop under finally should be ok.
... finally:
... for abc in range(10):
... continue
- ... print abc
+ ... print(abc)
>>> test()
9
@@ -288,7 +263,6 @@ Start simple, a continue in a finally should not be allowed.
... continue
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[36]>", line 6
SyntaxError: 'continue' not supported inside 'finally' clause
This is essentially a continue in a finally which should not be allowed.
@@ -304,7 +278,6 @@ This is essentially a continue in a finally which should not be allowed.
... pass
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[37]>", line 6
SyntaxError: 'continue' not supported inside 'finally' clause
>>> def foo():
@@ -314,7 +287,6 @@ This is essentially a continue in a finally which should not be allowed.
... continue
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[38]>", line 5
SyntaxError: 'continue' not supported inside 'finally' clause
>>> def foo():
@@ -325,7 +297,6 @@ This is essentially a continue in a finally which should not be allowed.
... continue
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[39]>", line 6
SyntaxError: 'continue' not supported inside 'finally' clause
>>> def foo():
@@ -339,7 +310,6 @@ This is essentially a continue in a finally which should not be allowed.
... pass
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[40]>", line 7
SyntaxError: 'continue' not supported inside 'finally' clause
>>> def foo():
@@ -352,7 +322,6 @@ This is essentially a continue in a finally which should not be allowed.
... continue
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[41]>", line 8
SyntaxError: 'continue' not supported inside 'finally' clause
There is one test for a break that is not in a loop. The compiler
@@ -361,14 +330,13 @@ so we need to be sure that a break is actually inside a loop. If it
isn't, there should be a syntax error.
>>> try:
- ... print 1
+ ... print(1)
... break
- ... print 2
+ ... print(2)
... finally:
- ... print 3
+ ... print(3)
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[42]>", line 3
SyntaxError: 'break' outside loop
This should probably raise a better error than a SystemError (or none at all).
@@ -401,6 +369,51 @@ build. The number of blocks must be greater than CO_MAXBLOCKS. SF #1565514
...
SystemError: too many statically nested blocks
+Misuse of the nonlocal statement can lead to a few unique syntax errors.
+
+ >>> def f(x):
+ ... nonlocal x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: name 'x' is parameter and nonlocal
+
+ >>> def f():
+ ... global x
+ ... nonlocal x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: name 'x' is nonlocal and global
+
+ >>> def f():
+ ... nonlocal x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: no binding for nonlocal 'x' found
+
+From SF bug #1705365
+ >>> nonlocal x
+ Traceback (most recent call last):
+ ...
+ SyntaxError: nonlocal declaration not allowed at module level
+
+TODO(jhylton): Figure out how to test SyntaxWarning with doctest.
+
+## >>> def f(x):
+## ... def f():
+## ... print(x)
+## ... nonlocal x
+## Traceback (most recent call last):
+## ...
+## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
+
+## >>> def f():
+## ... x = 1
+## ... nonlocal x
+## Traceback (most recent call last):
+## ...
+## SyntaxWarning: name 'x' is assigned to before nonlocal declaration
+
+
This tests assignment-context; there was a bug in Python 2.5 where compiling
a complex 'if' (one with 'elif') would fail to notice an invalid suite,
leading to spurious errors.
@@ -411,7 +424,6 @@ leading to spurious errors.
... pass
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[44]>", line 2
SyntaxError: can't assign to function call
>>> if 1:
@@ -420,7 +432,6 @@ leading to spurious errors.
... x() = 1
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[45]>", line 4
SyntaxError: can't assign to function call
>>> if 1:
@@ -431,7 +442,6 @@ leading to spurious errors.
... pass
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[46]>", line 2
SyntaxError: can't assign to function call
>>> if 1:
@@ -442,7 +452,6 @@ leading to spurious errors.
... pass
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[47]>", line 4
SyntaxError: can't assign to function call
>>> if 1:
@@ -453,32 +462,59 @@ leading to spurious errors.
... x() = 1
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[48]>", line 6
SyntaxError: can't assign to function call
+Make sure that the old "raise X, Y[, Z]" form is gone:
+ >>> raise X, Y
+ Traceback (most recent call last):
+ ...
+ SyntaxError: invalid syntax
+ >>> raise X, Y, Z
+ Traceback (most recent call last):
+ ...
+ SyntaxError: invalid syntax
+
+
>>> f(a=23, a=234)
Traceback (most recent call last):
...
- File "<doctest test.test_syntax[49]>", line 1
SyntaxError: keyword argument repeated
>>> del ()
Traceback (most recent call last):
- ...
- File "<doctest test.test_syntax[50]>", line 1
SyntaxError: can't delete ()
>>> {1, 2, 3} = 42
Traceback (most recent call last):
- ...
- File "<doctest test.test_syntax[50]>", line 1
SyntaxError: can't assign to literal
-Corner-case that used to crash:
+Corner-cases that used to fail to raise the correct error:
+
+ >>> def f(*, x=lambda __debug__:0): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(*args:(lambda __debug__:0)): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(**kwargs:(lambda __debug__:0)): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> with (lambda *:0): pass
+ Traceback (most recent call last):
+ SyntaxError: named arguments must follow bare *
- >>> def f(*xx, **__debug__): pass
+Corner-cases that used to crash:
+
+ >>> def f(**__debug__): pass
+ Traceback (most recent call last):
+ SyntaxError: assignment to keyword
+
+ >>> def f(*xx, __debug__): pass
Traceback (most recent call last):
- SyntaxError: cannot assign to __debug__
+ SyntaxError: assignment to keyword
"""
@@ -486,7 +522,7 @@ import re
import unittest
import warnings
-from test import test_support
+from test import support
class SyntaxTestCase(unittest.TestCase):
@@ -500,19 +536,15 @@ class SyntaxTestCase(unittest.TestCase):
"""
try:
compile(code, filename, mode)
- except SyntaxError, err:
+ except SyntaxError as err:
if subclass and not isinstance(err, subclass):
self.fail("SyntaxError is not a %s" % subclass.__name__)
mo = re.search(errtext, str(err))
if mo is None:
- self.fail("%s did not contain '%r'" % (err, errtext,))
+ self.fail("SyntaxError did not contain '%r'" % (errtext,))
else:
self.fail("compile() did not raise SyntaxError")
- def test_paren_arg_with_default(self):
- self._check_error("def f((x)=23): pass",
- "parenthesized arg with default")
-
def test_assign_call(self):
self._check_error("f() = 1", "assign")
@@ -522,13 +554,13 @@ class SyntaxTestCase(unittest.TestCase):
def test_global_err_then_warn(self):
# Bug tickler: The SyntaxError raised for one global statement
# shouldn't be clobbered by a SyntaxWarning issued for a later one.
- source = re.sub('(?m)^ *:', '', """\
- :def error(a):
- : global a # SyntaxError
- :def warning():
- : b = 1
- : global b # SyntaxWarning
- :""")
+ source = """if 1:
+ def error(a):
+ global a # SyntaxError
+ def warning():
+ b = 1
+ global b # SyntaxWarning
+ """
warnings.filterwarnings(action='ignore', category=SyntaxWarning)
self._check_error(source, "global")
warnings.filters.pop(0)
@@ -536,15 +568,6 @@ class SyntaxTestCase(unittest.TestCase):
def test_break_outside_loop(self):
self._check_error("break", "outside loop")
- def test_delete_deref(self):
- source = re.sub('(?m)^ *:', '', """\
- :def foo(x):
- : def bar():
- : print x
- : del x
- :""")
- self._check_error(source, "nested scope")
-
def test_unexpected_indent(self):
self._check_error("foo()\n bar()\n", "unexpected indent",
subclass=IndentationError)
@@ -562,11 +585,9 @@ class SyntaxTestCase(unittest.TestCase):
self._check_error("int(base=10, '2')", "non-keyword arg")
def test_main():
- test_support.run_unittest(SyntaxTestCase)
+ support.run_unittest(SyntaxTestCase)
from test import test_syntax
- with test_support.check_py3k_warnings(("backquote not supported",
- SyntaxWarning)):
- test_support.run_doctest(test_syntax, verbosity=True)
+ support.run_doctest(test_syntax, verbosity=True)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index fbea655547a..a52767a1106 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -1,57 +1,69 @@
-# -*- coding: iso-8859-1 -*-
-import unittest, test.test_support
-import sys, os, cStringIO
+import unittest, test.support
+import sys, io, os
import struct
+import subprocess
+import textwrap
+import warnings
import operator
+import codecs
+
+# count the number of test runs, used to create unique
+# strings to intern in test_intern()
+numruns = 0
+
+try:
+ import threading
+except ImportError:
+ threading = None
class SysModuleTest(unittest.TestCase):
+ def setUp(self):
+ self.orig_stdout = sys.stdout
+ self.orig_stderr = sys.stderr
+ self.orig_displayhook = sys.displayhook
+
def tearDown(self):
- test.test_support.reap_children()
+ sys.stdout = self.orig_stdout
+ sys.stderr = self.orig_stderr
+ sys.displayhook = self.orig_displayhook
+ test.support.reap_children()
def test_original_displayhook(self):
- import __builtin__
- savestdout = sys.stdout
- out = cStringIO.StringIO()
+ import builtins
+ out = io.StringIO()
sys.stdout = out
dh = sys.__displayhook__
self.assertRaises(TypeError, dh)
- if hasattr(__builtin__, "_"):
- del __builtin__._
+ if hasattr(builtins, "_"):
+ del builtins._
dh(None)
self.assertEqual(out.getvalue(), "")
- self.assertTrue(not hasattr(__builtin__, "_"))
+ self.assertTrue(not hasattr(builtins, "_"))
dh(42)
self.assertEqual(out.getvalue(), "42\n")
- self.assertEqual(__builtin__._, 42)
+ self.assertEqual(builtins._, 42)
del sys.stdout
self.assertRaises(RuntimeError, dh, 42)
- sys.stdout = savestdout
-
def test_lost_displayhook(self):
- olddisplayhook = sys.displayhook
del sys.displayhook
code = compile("42", "<string>", "single")
self.assertRaises(RuntimeError, eval, code)
- sys.displayhook = olddisplayhook
def test_custom_displayhook(self):
- olddisplayhook = sys.displayhook
def baddisplayhook(obj):
raise ValueError
sys.displayhook = baddisplayhook
code = compile("42", "<string>", "single")
self.assertRaises(ValueError, eval, code)
- sys.displayhook = olddisplayhook
def test_original_excepthook(self):
- savestderr = sys.stderr
- err = cStringIO.StringIO()
+ err = io.StringIO()
sys.stderr = err
eh = sys.__excepthook__
@@ -59,67 +71,28 @@ class SysModuleTest(unittest.TestCase):
self.assertRaises(TypeError, eh)
try:
raise ValueError(42)
- except ValueError, exc:
+ except ValueError as exc:
eh(*sys.exc_info())
- sys.stderr = savestderr
self.assertTrue(err.getvalue().endswith("ValueError: 42\n"))
+ def test_excepthook(self):
+ with test.support.captured_output("stderr") as stderr:
+ sys.excepthook(1, '1', 1)
+ self.assertTrue("TypeError: print_exception(): Exception expected for " \
+ "value, str found" in stderr.getvalue())
+
# FIXME: testing the code for a lost or replaced excepthook in
# Python/pythonrun.c::PyErr_PrintEx() is tricky.
- def test_exc_clear(self):
- self.assertRaises(TypeError, sys.exc_clear, 42)
-
- # Verify that exc_info is present and matches exc, then clear it, and
- # check that it worked.
- def clear_check(exc):
- typ, value, traceback = sys.exc_info()
- self.assertTrue(typ is not None)
- self.assertTrue(value is exc)
- self.assertTrue(traceback is not None)
-
- with test.test_support.check_py3k_warnings():
- sys.exc_clear()
-
- typ, value, traceback = sys.exc_info()
- self.assertTrue(typ is None)
- self.assertTrue(value is None)
- self.assertTrue(traceback is None)
-
- def clear():
- try:
- raise ValueError, 42
- except ValueError, exc:
- clear_check(exc)
-
- # Raise an exception and check that it can be cleared
- clear()
-
- # Verify that a frame currently handling an exception is
- # unaffected by calling exc_clear in a nested frame.
- try:
- raise ValueError, 13
- except ValueError, exc:
- typ1, value1, traceback1 = sys.exc_info()
- clear()
- typ2, value2, traceback2 = sys.exc_info()
-
- self.assertTrue(typ1 is typ2)
- self.assertTrue(value1 is exc)
- self.assertTrue(value1 is value2)
- self.assertTrue(traceback1 is traceback2)
-
- # Check that an exception can be cleared outside of an except block
- clear_check(exc)
-
def test_exit(self):
+
self.assertRaises(TypeError, sys.exit, 42, 42)
# call without argument
try:
sys.exit(0)
- except SystemExit, exc:
+ except SystemExit as exc:
self.assertEqual(exc.code, 0)
except:
self.fail("wrong exception")
@@ -130,7 +103,7 @@ class SysModuleTest(unittest.TestCase):
# entry will be unpacked
try:
sys.exit(42)
- except SystemExit, exc:
+ except SystemExit as exc:
self.assertEqual(exc.code, 42)
except:
self.fail("wrong exception")
@@ -140,7 +113,7 @@ class SysModuleTest(unittest.TestCase):
# call with integer argument
try:
sys.exit((42,))
- except SystemExit, exc:
+ except SystemExit as exc:
self.assertEqual(exc.code, 42)
except:
self.fail("wrong exception")
@@ -150,7 +123,7 @@ class SysModuleTest(unittest.TestCase):
# call with string argument
try:
sys.exit("exit")
- except SystemExit, exc:
+ except SystemExit as exc:
self.assertEqual(exc.code, "exit")
except:
self.fail("wrong exception")
@@ -160,7 +133,7 @@ class SysModuleTest(unittest.TestCase):
# call with tuple argument with two entries
try:
sys.exit((17, 23))
- except SystemExit, exc:
+ except SystemExit as exc:
self.assertEqual(exc.code, (17, 23))
except:
self.fail("wrong exception")
@@ -168,12 +141,6 @@ class SysModuleTest(unittest.TestCase):
self.fail("no exception")
# test that the exit machinery handles SystemExits properly
- import subprocess
- # both unnormalized...
- rc = subprocess.call([sys.executable, "-c",
- "raise SystemExit, 46"])
- self.assertEqual(rc, 46)
- # ... and normalized
rc = subprocess.call([sys.executable, "-c",
"raise SystemExit(47)"])
self.assertEqual(rc, 47)
@@ -184,7 +151,7 @@ class SysModuleTest(unittest.TestCase):
stdout, stderr = process.communicate()
self.assertEqual(process.returncode, 1)
self.assertTrue(stderr.startswith(expected),
- "%s doesn't start with %s" % (repr(stderr), repr(expected)))
+ "%s doesn't start with %s" % (ascii(stderr), ascii(expected)))
# test that stderr buffer if flushed before the exit message is written
# into stderr
@@ -192,28 +159,52 @@ class SysModuleTest(unittest.TestCase):
r'import sys; sys.stderr.write("unflushed,"); sys.exit("message")',
b"unflushed,message")
+ # test that the exit message is written with backslashreplace error
+ # handler to stderr
+ check_exit_message(
+ r'import sys; sys.exit("surrogates:\uDCFF")',
+ b"surrogates:\\udcff")
+
# test that the unicode message is encoded to the stderr encoding
+ # instead of the default encoding (utf8)
env = os.environ.copy()
env['PYTHONIOENCODING'] = 'latin-1'
check_exit_message(
- r'import sys; sys.exit(u"h\xe9")',
+ r'import sys; sys.exit("h\xe9")',
b"h\xe9", env=env)
def test_getdefaultencoding(self):
- if test.test_support.have_unicode:
- self.assertRaises(TypeError, sys.getdefaultencoding, 42)
- # can't check more than the type, as the user might have changed it
- self.assertIsInstance(sys.getdefaultencoding(), str)
+ self.assertRaises(TypeError, sys.getdefaultencoding, 42)
+ # can't check more than the type, as the user might have changed it
+ self.assertIsInstance(sys.getdefaultencoding(), str)
# testing sys.settrace() is done in test_sys_settrace.py
# testing sys.setprofile() is done in test_sys_setprofile.py
def test_setcheckinterval(self):
- 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)
+ 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)
+
+ @unittest.skipUnless(threading, 'Threading required for this test.')
+ def test_switchinterval(self):
+ self.assertRaises(TypeError, sys.setswitchinterval)
+ self.assertRaises(TypeError, sys.setswitchinterval, "a")
+ self.assertRaises(ValueError, sys.setswitchinterval, -1.0)
+ self.assertRaises(ValueError, sys.setswitchinterval, 0.0)
+ orig = sys.getswitchinterval()
+ # sanity check
+ self.assertTrue(orig < 0.5, orig)
+ try:
+ for n in 0.00001, 0.05, 3.0, orig:
+ sys.setswitchinterval(n)
+ self.assertAlmostEqual(sys.getswitchinterval(), n)
+ finally:
+ sys.setswitchinterval(orig)
def test_recursionlimit(self):
self.assertRaises(TypeError, sys.getrecursionlimit, 42)
@@ -224,21 +215,54 @@ class SysModuleTest(unittest.TestCase):
self.assertEqual(sys.getrecursionlimit(), 10000)
sys.setrecursionlimit(oldlimit)
- self.assertRaises(OverflowError, sys.setrecursionlimit, 1 << 31)
+ @unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
+ 'fatal error if run with a trace function')
+ def test_recursionlimit_recovery(self):
+ # NOTE: this test is slightly fragile in that it depends on the current
+ # recursion count when executing the test being low enough so as to
+ # trigger the recursion recovery detection in the _Py_MakeEndRecCheck
+ # macro (see ceval.h).
+ oldlimit = sys.getrecursionlimit()
+ def f():
+ f()
try:
- sys.setrecursionlimit((1 << 31) - 5)
- try:
- # issue13546: isinstance(e, ValueError) used to fail
- # when the recursion limit is close to 1<<31
- raise ValueError()
- except ValueError, e:
- pass
+ for i in (50, 1000):
+ # Issue #5392: stack overflow after hitting recursion limit twice
+ sys.setrecursionlimit(i)
+ self.assertRaises(RuntimeError, f)
+ self.assertRaises(RuntimeError, f)
finally:
sys.setrecursionlimit(oldlimit)
+ def test_recursionlimit_fatalerror(self):
+ # A fatal error occurs if a second recursion limit is hit when recovering
+ # from a first one.
+ if os.name == "nt":
+ raise unittest.SkipTest(
+ "under Windows, test would generate a spurious crash dialog")
+ code = textwrap.dedent("""
+ import sys
+
+ def f():
+ try:
+ f()
+ except RuntimeError:
+ f()
+
+ sys.setrecursionlimit(%d)
+ f()""")
+ for i in (50, 1000):
+ sub = subprocess.Popen([sys.executable, '-c', code % i],
+ stderr=subprocess.PIPE)
+ err = sub.communicate()[1]
+ self.assertTrue(sub.returncode, sub.returncode)
+ self.assertTrue(
+ b"Fatal Python error: Cannot recover from stack overflow" in err,
+ err)
+
def test_getwindowsversion(self):
# Raise SkipTest if sys doesn't have getwindowsversion attribute
- test.test_support.get_attribute(sys, "getwindowsversion")
+ test.support.get_attribute(sys, "getwindowsversion")
v = sys.getwindowsversion()
self.assertEqual(len(v), 5)
self.assertIsInstance(v[0], int)
@@ -266,6 +290,9 @@ class SysModuleTest(unittest.TestCase):
# still has 5 elements
maj, min, buildno, plat, csd = sys.getwindowsversion()
+ def test_call_tracing(self):
+ self.assertRaises(TypeError, sys.call_tracing, type, 2)
+
def test_dlopenflags(self):
if hasattr(sys, "setdlopenflags"):
self.assertTrue(hasattr(sys, "getdlopenflags"))
@@ -295,7 +322,7 @@ class SysModuleTest(unittest.TestCase):
self.assertRaises(TypeError, sys._getframe, 42, 42)
self.assertRaises(ValueError, sys._getframe, 2000000000)
self.assertTrue(
- SysModuleTest.test_getframe.im_func.func_code \
+ SysModuleTest.test_getframe.__code__ \
is sys._getframe().f_code
)
@@ -303,7 +330,7 @@ class SysModuleTest(unittest.TestCase):
def test_current_frames(self):
have_threads = True
try:
- import thread
+ import _thread
except ImportError:
have_threads = False
@@ -313,9 +340,9 @@ class SysModuleTest(unittest.TestCase):
self.current_frames_without_threads()
# Test sys._current_frames() in a WITH_THREADS build.
- @test.test_support.reap_threads
+ @test.support.reap_threads
def current_frames_with_threads(self):
- import threading, thread
+ import threading, _thread
import traceback
# Spawn a thread that blocks at a known place. Then the main
@@ -329,7 +356,7 @@ class SysModuleTest(unittest.TestCase):
g456()
def g456():
- thread_info.append(thread.get_ident())
+ thread_info.append(_thread.get_ident())
entered_g.set()
leave_g.wait()
@@ -345,7 +372,7 @@ class SysModuleTest(unittest.TestCase):
d = sys._current_frames()
- main_id = thread.get_ident()
+ main_id = _thread.get_ident()
self.assertIn(main_id, d)
self.assertIn(thread_id, d)
@@ -389,23 +416,39 @@ class SysModuleTest(unittest.TestCase):
self.assertIsInstance(sys.argv, list)
self.assertIn(sys.byteorder, ("little", "big"))
self.assertIsInstance(sys.builtin_module_names, tuple)
- self.assertIsInstance(sys.copyright, basestring)
- self.assertIsInstance(sys.exec_prefix, basestring)
- self.assertIsInstance(sys.executable, basestring)
+ self.assertIsInstance(sys.copyright, str)
+ self.assertIsInstance(sys.exec_prefix, str)
+ self.assertIsInstance(sys.executable, str)
self.assertEqual(len(sys.float_info), 11)
self.assertEqual(sys.float_info.radix, 2)
- self.assertEqual(len(sys.long_info), 2)
- self.assertTrue(sys.long_info.bits_per_digit % 5 == 0)
- self.assertTrue(sys.long_info.sizeof_digit >= 1)
- self.assertEqual(type(sys.long_info.bits_per_digit), int)
- self.assertEqual(type(sys.long_info.sizeof_digit), int)
+ self.assertEqual(len(sys.int_info), 2)
+ self.assertTrue(sys.int_info.bits_per_digit % 5 == 0)
+ self.assertTrue(sys.int_info.sizeof_digit >= 1)
+ self.assertEqual(type(sys.int_info.bits_per_digit), int)
+ self.assertEqual(type(sys.int_info.sizeof_digit), int)
self.assertIsInstance(sys.hexversion, int)
- self.assertIsInstance(sys.maxint, int)
- if test.test_support.have_unicode:
- self.assertIsInstance(sys.maxunicode, int)
- self.assertIsInstance(sys.platform, basestring)
- self.assertIsInstance(sys.prefix, basestring)
- self.assertIsInstance(sys.version, basestring)
+
+ self.assertEqual(len(sys.hash_info), 5)
+ self.assertLess(sys.hash_info.modulus, 2**sys.hash_info.width)
+ # sys.hash_info.modulus should be a prime; we do a quick
+ # probable primality test (doesn't exclude the possibility of
+ # a Carmichael number)
+ for x in range(1, 100):
+ self.assertEqual(
+ pow(x, sys.hash_info.modulus-1, sys.hash_info.modulus),
+ 1,
+ "sys.hash_info.modulus {} is a non-prime".format(
+ sys.hash_info.modulus)
+ )
+ self.assertIsInstance(sys.hash_info.inf, int)
+ self.assertIsInstance(sys.hash_info.nan, int)
+ self.assertIsInstance(sys.hash_info.imag, int)
+
+ self.assertIsInstance(sys.maxsize, int)
+ self.assertIsInstance(sys.maxunicode, int)
+ self.assertIsInstance(sys.platform, str)
+ self.assertIsInstance(sys.prefix, str)
+ self.assertIsInstance(sys.version, str)
vi = sys.version_info
self.assertIsInstance(vi[:], tuple)
self.assertEqual(len(vi), 5)
@@ -427,48 +470,67 @@ class SysModuleTest(unittest.TestCase):
self.assertTrue(vi > (1,0,0))
self.assertIsInstance(sys.float_repr_style, str)
self.assertIn(sys.float_repr_style, ('short', 'legacy'))
+ if not sys.platform.startswith('win'):
+ self.assertIsInstance(sys.abiflags, str)
def test_43581(self):
- # Can't use sys.stdout, as this is a cStringIO object when
+ # Can't use sys.stdout, as this is a StringIO object when
# the test runs under regrtest.
- self.assertTrue(sys.__stdout__.encoding == sys.__stderr__.encoding)
+ self.assertEqual(sys.__stdout__.encoding, sys.__stderr__.encoding)
+
+ def test_intern(self):
+ global numruns
+ numruns += 1
+ self.assertRaises(TypeError, sys.intern)
+ s = "never interned before" + str(numruns)
+ self.assertTrue(sys.intern(s) is s)
+ s2 = s.swapcase().swapcase()
+ self.assertTrue(sys.intern(s2) is s)
+
+ # Subclasses of string can't be interned, because they
+ # provide too much opportunity for insane things to happen.
+ # We don't want them in the interned dict and if they aren't
+ # actually interned, we don't want to create the appearance
+ # that they are by allowing intern() to succeed.
+ class S(str):
+ def __hash__(self):
+ return 123
+
+ self.assertRaises(TypeError, sys.intern, S("abc"))
def test_sys_flags(self):
self.assertTrue(sys.flags)
- attrs = ("debug", "py3k_warning", "division_warning", "division_new",
+ attrs = ("debug", "division_warning",
"inspect", "interactive", "optimize", "dont_write_bytecode",
- "no_site", "ignore_environment", "tabcheck", "verbose",
- "unicode", "bytes_warning", "hash_randomization")
+ "no_user_site", "no_site", "ignore_environment", "verbose",
+ "bytes_warning", "quiet", "hash_randomization")
for attr in attrs:
self.assertTrue(hasattr(sys.flags, attr), attr)
self.assertEqual(type(getattr(sys.flags, attr)), int, attr)
self.assertTrue(repr(sys.flags))
+ self.assertEqual(len(sys.flags), len(attrs))
def test_clear_type_cache(self):
sys._clear_type_cache()
def test_ioencoding(self):
- import subprocess
env = dict(os.environ)
# Test character: cent sign, encoded as 0x4A (ASCII J) in CP424,
# not representable in ASCII.
env["PYTHONIOENCODING"] = "cp424"
- p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'],
+ p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
stdout = subprocess.PIPE, env=env)
out = p.communicate()[0].strip()
- self.assertEqual(out, unichr(0xa2).encode("cp424"))
+ expected = ("\xa2" + os.linesep).encode("cp424")
+ self.assertEqual(out, expected)
env["PYTHONIOENCODING"] = "ascii:replace"
- p = subprocess.Popen([sys.executable, "-c", 'print unichr(0xa2)'],
+ p = subprocess.Popen([sys.executable, "-c", 'print(chr(0xa2))'],
stdout = subprocess.PIPE, env=env)
out = p.communicate()[0].strip()
- self.assertEqual(out, '?')
-
- def test_call_tracing(self):
- self.assertEqual(sys.call_tracing(str, (2,)), "2")
- self.assertRaises(TypeError, sys.call_tracing, str, 2)
+ self.assertEqual(out, b'?')
def test_executable(self):
# sys.executable should be absolute
@@ -477,59 +539,78 @@ class SysModuleTest(unittest.TestCase):
# Issue #7774: Ensure that sys.executable is an empty string if argv[0]
# has been set to an non existent program name and Python is unable to
# retrieve the real program name
- import subprocess
+
# For a normal installation, it should work without 'cwd'
# argument. For test runs in the build directory, see #7774.
python_dir = os.path.dirname(os.path.realpath(sys.executable))
p = subprocess.Popen(
- ["nonexistent", "-c", 'import sys; print repr(sys.executable)'],
+ ["nonexistent", "-c",
+ 'import sys; print(sys.executable.encode("ascii", "backslashreplace"))'],
executable=sys.executable, stdout=subprocess.PIPE, cwd=python_dir)
- executable = p.communicate()[0].strip()
+ stdout = p.communicate()[0]
+ executable = stdout.strip().decode("ASCII")
p.wait()
- self.assertIn(executable, ["''", repr(sys.executable)])
+ self.assertIn(executable, ["b''", repr(sys.executable.encode("ascii", "backslashreplace"))])
+
+ def check_fsencoding(self, fs_encoding, expected=None):
+ self.assertIsNotNone(fs_encoding)
+ codecs.lookup(fs_encoding)
+ if expected:
+ self.assertEqual(fs_encoding, expected)
+
+ def test_getfilesystemencoding(self):
+ fs_encoding = sys.getfilesystemencoding()
+ if sys.platform == 'darwin':
+ expected = 'utf-8'
+ elif sys.platform == 'win32':
+ expected = 'mbcs'
+ else:
+ expected = None
+ self.check_fsencoding(fs_encoding, expected)
+
class SizeofTest(unittest.TestCase):
def setUp(self):
self.P = struct.calcsize('P')
- self.longdigit = sys.long_info.sizeof_digit
+ self.longdigit = sys.int_info.sizeof_digit
import _testcapi
self.gc_headsize = _testcapi.SIZEOF_PYGC_HEAD
- self.file = open(test.test_support.TESTFN, 'wb')
+ self.file = open(test.support.TESTFN, 'wb')
def tearDown(self):
self.file.close()
- test.test_support.unlink(test.test_support.TESTFN)
+ test.support.unlink(test.support.TESTFN)
- check_sizeof = test.test_support.check_sizeof
+ check_sizeof = test.support.check_sizeof
def test_gc_head_size(self):
# Check that the gc header size is added to objects tracked by the gc.
- size = test.test_support.calcobjsize
+ vsize = test.support.calcvobjsize
gc_header_size = self.gc_headsize
# bool objects are not gc tracked
- self.assertEqual(sys.getsizeof(True), size('l'))
+ self.assertEqual(sys.getsizeof(True), vsize('') + self.longdigit)
# but lists are
- self.assertEqual(sys.getsizeof([]), size('P PP') + gc_header_size)
+ self.assertEqual(sys.getsizeof([]), vsize('PP') + gc_header_size)
def test_default(self):
- size = test.test_support.calcobjsize
- self.assertEqual(sys.getsizeof(True, -1), size('l'))
+ vsize = test.support.calcvobjsize
+ self.assertEqual(sys.getsizeof(True), vsize('') + self.longdigit)
+ self.assertEqual(sys.getsizeof(True, -1), vsize('') + self.longdigit)
def test_objecttypes(self):
# check all types defined in Objects/
- size = test.test_support.calcobjsize
- vsize = test.test_support.calcvobjsize
+ size = test.support.calcobjsize
+ vsize = test.support.calcvobjsize
check = self.check_sizeof
# bool
- check(True, size('l'))
+ check(True, vsize('') + self.longdigit)
# buffer
- with test.test_support.check_py3k_warnings():
- check(buffer(''), size('2P2Pil'))
+ # XXX
# builtin_function_or_method
- check(len, size('3P'))
+ check(len, size('3P')) # XXX check layout
# bytearray
- samples = ['', 'u'*100000]
+ samples = [b'', b'u'*100000]
for sample in samples:
x = bytearray(sample)
check(x, vsize('iPP') + x.__alloc__())
@@ -541,28 +622,11 @@ class SizeofTest(unittest.TestCase):
def inner():
return x
return inner
- check(get_cell().func_closure[0], size('P'))
- # classobj (old-style class)
- class class_oldstyle():
- def method():
- pass
- check(class_oldstyle, size('7P'))
- # instance (old-style class)
- check(class_oldstyle(), size('3P'))
- # instancemethod (old-style class)
- check(class_oldstyle().method, size('4P'))
+ check(get_cell().__closure__[0], size('P'))
+ # code
+ check(get_cell().__code__, size('5i8Pi3P'))
# complex
check(complex(0,1), size('2d'))
- # code
- check(get_cell().func_code, size('4i8Pi3P'))
- # BaseException
- check(BaseException(), size('3P'))
- # UnicodeEncodeError
- check(UnicodeEncodeError("", u"", 0, 0, ""), size('5P2PP'))
- # UnicodeDecodeError
- check(UnicodeDecodeError("", "", 0, 0, ""), size('5P2PP'))
- # UnicodeTranslateError
- check(UnicodeTranslateError(u"", 0, 1, ""), size('5P2PP'))
# method_descriptor (descriptor object)
check(str.lower, size('2PP'))
# classmethod_descriptor (descriptor object)
@@ -571,25 +635,35 @@ class SizeofTest(unittest.TestCase):
import datetime
check(datetime.timedelta.days, size('2PP'))
# getset_descriptor (descriptor object)
- import __builtin__
- check(__builtin__.file.closed, size('2PP'))
+ import collections
+ check(collections.defaultdict.default_factory, size('2PP'))
# wrapper_descriptor (descriptor object)
check(int.__add__, size('2P2P'))
- # dictproxy
- class C(object): pass
- check(C.__dict__, size('P'))
# method-wrapper (descriptor object)
check({}.__iter__, size('2P'))
# dict
check({}, size('3P2P' + 8*'P2P'))
- x = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
- check(x, size('3P2P' + 8*'P2P') + 16*struct.calcsize('P2P'))
+ longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
+ check(longdict, size('3P2P' + 8*'P2P') + 16*struct.calcsize('P2P'))
# dictionary-keyiterator
- check({}.iterkeys(), size('P2PPP'))
+ check({}.keys(), size('P'))
# dictionary-valueiterator
- check({}.itervalues(), size('P2PPP'))
+ check({}.values(), size('P'))
# dictionary-itemiterator
- check({}.iteritems(), size('P2PPP'))
+ check({}.items(), size('P'))
+ # dictionary iterator
+ check(iter({}), size('P2PPP'))
+ # dictproxy
+ class C(object): pass
+ check(C.__dict__, size('P'))
+ # BaseException
+ check(BaseException(), size('5P'))
+ # UnicodeEncodeError
+ check(UnicodeEncodeError("", "", 0, 0, ""), size('5P 2P2PP'))
+ # UnicodeDecodeError
+ check(UnicodeDecodeError("", b"", 0, 0, ""), size('5P 2P2PP'))
+ # UnicodeTranslateError
+ check(UnicodeTranslateError("", 0, 1, ""), size('5P 2P2PP'))
# ellipses
check(Ellipsis, size(''))
# EncodingMap
@@ -598,8 +672,8 @@ class SizeofTest(unittest.TestCase):
check(x, size('32B2iB'))
# enumerate
check(enumerate([]), size('l3P'))
- # file
- check(self.file, size('4P2i4P3i3P3i'))
+ # reverse
+ check(reversed(''), size('PP'))
# float
check(float(0), size('d'))
# sys.floatinfo
@@ -611,11 +685,11 @@ class SizeofTest(unittest.TestCase):
ncells = len(x.f_code.co_cellvars)
nfrees = len(x.f_code.co_freevars)
extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
- ncells + nfrees - 1
+ ncells + nfrees - 1
check(x, vsize('12P3i' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P'))
# function
def func(): pass
- check(func, size('9P'))
+ check(func, size('11P'))
class c():
@staticmethod
def foo():
@@ -630,9 +704,6 @@ class SizeofTest(unittest.TestCase):
# generator
def get_gen(): yield 1
check(get_gen(), size('Pi2P'))
- # integer
- check(1, size('l'))
- check(100, size('l'))
# iterator
check(iter('abc'), size('lP'))
# callable-iterator
@@ -651,17 +722,21 @@ class SizeofTest(unittest.TestCase):
# listreverseiterator (list)
check(reversed([]), size('lP'))
# long
- check(0L, vsize(''))
- check(1L, vsize('') + self.longdigit)
- check(-1L, vsize('') + self.longdigit)
- PyLong_BASE = 2**sys.long_info.bits_per_digit
- check(long(PyLong_BASE), vsize('') + 2*self.longdigit)
- check(long(PyLong_BASE**2-1), vsize('') + 2*self.longdigit)
- check(long(PyLong_BASE**2), vsize('') + 3*self.longdigit)
+ check(0, vsize(''))
+ check(1, vsize('') + self.longdigit)
+ check(-1, vsize('') + self.longdigit)
+ PyLong_BASE = 2**sys.int_info.bits_per_digit
+ check(int(PyLong_BASE), vsize('') + 2*self.longdigit)
+ check(int(PyLong_BASE**2-1), vsize('') + 2*self.longdigit)
+ check(int(PyLong_BASE**2), vsize('') + 3*self.longdigit)
+ # memoryview
+ check(memoryview(b''), size('PP2P2i7P'))
# module
- check(unittest, size('P'))
+ check(unittest, size('3P'))
# None
check(None, size(''))
+ # NotImplementedType
+ check(NotImplemented, size(''))
# object
check(object(), size(''))
# property (descriptor object)
@@ -671,18 +746,20 @@ class SizeofTest(unittest.TestCase):
def delx(self): del self.__x
x = property(getx, setx, delx, "")
check(x, size('4Pi'))
- # PyCObject
# PyCapsule
# XXX
# rangeiterator
- check(iter(xrange(1)), size('4l'))
+ check(iter(range(1)), size('4l'))
# reverse
check(reversed(''), size('PP'))
+ # range
+ check(range(1), size('4P'))
+ check(range(66000), size('4P'))
# set
# frozenset
PySet_MINSIZE = 8
samples = [[], range(10), range(50)]
- s = size('3P2P' + PySet_MINSIZE*'lP' + 'lP')
+ s = size('3P2P' + PySet_MINSIZE*'PP' + 'PP')
for sample in samples:
minused = len(sample)
if minused == 0: tmp = 1
@@ -701,37 +778,28 @@ class SizeofTest(unittest.TestCase):
# setiterator
check(iter(set()), size('P3P'))
# slice
- check(slice(1), size('3P'))
- # str
- vh = test.test_support._vheader
- check('', struct.calcsize(vh + 'lic'))
- check('abc', struct.calcsize(vh + 'lic') + 3)
+ check(slice(0), size('3P'))
# super
check(super(int), size('3P'))
# tuple
check((), vsize(''))
check((1,2,3), vsize('') + 3*self.P)
- # tupleiterator
- check(iter(()), size('lP'))
# type
- # (PyTypeObject + PyNumberMethods + PyMappingMethods +
+ # (PyTypeObject + PyNumberMethods + PyMappingMethods +
# PySequenceMethods + PyBufferProcs)
- s = vsize('P2P15Pl4PP9PP11PI') + struct.calcsize('41P 10P 3P 6P')
- class newstyleclass(object):
- pass
- check(newstyleclass, s)
- # builtin type
+ s = vsize('P2P15Pl4PP9PP11PI') + struct.calcsize('16Pi17P 3P 10P 2P 2P')
check(int, s)
- # NotImplementedType
- import types
- check(types.NotImplementedType, s)
+ # class
+ class newstyleclass(object): pass
+ check(newstyleclass, s)
# unicode
- usize = len(u'\0'.encode('unicode-internal'))
- samples = [u'', u'1'*100]
+ usize = len('\0'.encode('unicode-internal'))
+ samples = ['', '1'*100]
# we need to test for both sizes, because we don't know if the string
# has been cached
for s in samples:
- check(s, size('PPlP') + usize * (len(s) + 1))
+ basicsize = size('PPPiP') + usize * (len(s) + 1)
+ check(s, basicsize)
# weakref
import weakref
check(weakref.ref(int), size('2Pl2P'))
@@ -739,14 +807,11 @@ class SizeofTest(unittest.TestCase):
# XXX
# weakcallableproxy
check(weakref.proxy(int), size('2Pl2P'))
- # xrange
- check(xrange(1), size('3l'))
- check(xrange(66000), size('3l'))
def test_pythontypes(self):
# check all types defined in Python/
- size = test.test_support.calcobjsize
- vsize = test.test_support.calcvobjsize
+ size = test.support.calcobjsize
+ vsize = test.support.calcvobjsize
check = self.check_sizeof
# _ast.AST
import _ast
@@ -768,9 +833,7 @@ class SizeofTest(unittest.TestCase):
def test_main():
- test_classes = (SysModuleTest, SizeofTest)
-
- test.test_support.run_unittest(*test_classes)
+ test.support.run_unittest(SysModuleTest, SizeofTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_sys_setprofile.py b/Lib/test/test_sys_setprofile.py
index e82559f8fc3..9816e3ed646 100644
--- a/Lib/test/test_sys_setprofile.py
+++ b/Lib/test/test_sys_setprofile.py
@@ -3,7 +3,7 @@ import pprint
import sys
import unittest
-from test import test_support
+from test import support
class TestGetProfile(unittest.TestCase):
def setUp(self):
@@ -48,7 +48,7 @@ class HookWatcher:
def get_events(self):
"""Remove calls to add_event()."""
- disallowed = [ident(self.add_event.im_func), ident(ident)]
+ disallowed = [ident(self.add_event.__func__), ident(ident)]
self.frames = None
return [item for item in self.events if item[2] not in disallowed]
@@ -111,7 +111,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_exception(self):
def f(p):
- 1./0
+ 1/0
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
(1, 'return', f_ident),
@@ -119,7 +119,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_caught_exception(self):
def f(p):
- try: 1./0
+ try: 1/0
except: pass
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
@@ -128,7 +128,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_caught_nested_exception(self):
def f(p):
- try: 1./0
+ try: 1/0
except: pass
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
@@ -137,7 +137,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_nested_exception(self):
def f(p):
- 1./0
+ 1/0
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
# This isn't what I expected:
@@ -148,7 +148,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_exception_in_except_clause(self):
def f(p):
- 1./0
+ 1/0
def g(p):
try:
f(p)
@@ -167,7 +167,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_exception_propogation(self):
def f(p):
- 1./0
+ 1/0
def g(p):
try: f(p)
finally: p.add_event("falling through")
@@ -182,8 +182,8 @@ class ProfileHookTestCase(TestCaseBase):
def test_raise_twice(self):
def f(p):
- try: 1./0
- except: 1./0
+ try: 1/0
+ except: 1/0
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
(1, 'return', f_ident),
@@ -191,7 +191,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_raise_reraise(self):
def f(p):
- try: 1./0
+ try: 1/0
except: raise
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
@@ -208,7 +208,7 @@ class ProfileHookTestCase(TestCaseBase):
def test_distant_exception(self):
def f():
- 1./0
+ 1/0
def g():
f()
def h():
@@ -293,7 +293,7 @@ class ProfileSimulatorTestCase(TestCaseBase):
def test_basic_exception(self):
def f(p):
- 1./0
+ 1/0
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
(1, 'return', f_ident),
@@ -301,7 +301,7 @@ class ProfileSimulatorTestCase(TestCaseBase):
def test_caught_exception(self):
def f(p):
- try: 1./0
+ try: 1/0
except: pass
f_ident = ident(f)
self.check_events(f, [(1, 'call', f_ident),
@@ -310,7 +310,7 @@ class ProfileSimulatorTestCase(TestCaseBase):
def test_distant_exception(self):
def f():
- 1./0
+ 1/0
def g():
f()
def h():
@@ -341,7 +341,7 @@ def ident(function):
if hasattr(function, "f_code"):
code = function.f_code
else:
- code = function.func_code
+ code = function.__code__
return code.co_firstlineno, code.co_name
@@ -375,7 +375,7 @@ def show_events(callable):
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TestGetProfile,
ProfileHookTestCase,
ProfileSimulatorTestCase
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
index 9c7bcef2e7e..ba3bc2e9114 100644
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -1,6 +1,6 @@
# Testing the line trace facility.
-from test import test_support
+from test import support
import unittest
import sys
import difflib
@@ -98,7 +98,7 @@ def raises():
def test_raise():
try:
raises()
- except Exception, exc:
+ except Exception as exc:
x = 1
test_raise.events = [(0, 'call'),
@@ -128,7 +128,7 @@ def _settrace_and_raise(tracefunc):
def settrace_and_raise(tracefunc):
try:
_settrace_and_raise(tracefunc)
- except RuntimeError, exc:
+ except RuntimeError as exc:
pass
settrace_and_raise.events = [(2, 'exception'),
@@ -269,7 +269,7 @@ class TraceTestCase(unittest.TestCase):
sys.settrace(tracer.trace)
func()
sys.settrace(None)
- self.compare_events(func.func_code.co_firstlineno,
+ self.compare_events(func.__code__.co_firstlineno,
tracer.events, events)
def run_test(self, func):
@@ -279,7 +279,7 @@ class TraceTestCase(unittest.TestCase):
tracer = Tracer()
func(tracer.trace)
sys.settrace(None)
- self.compare_events(func.func_code.co_firstlineno,
+ self.compare_events(func.__code__.co_firstlineno,
tracer.events, func.events)
def test_set_and_retrieve_none(self):
@@ -379,9 +379,10 @@ class TraceTestCase(unittest.TestCase):
(3, 'return')])
def test_16_blank_lines(self):
- exec("def f():\n" + "\n" * 256 + " pass")
+ namespace = {}
+ exec("def f():\n" + "\n" * 256 + " pass", namespace)
self.run_and_compare(
- f,
+ namespace["f"],
[(0, 'call'),
(257, 'line'),
(257, 'return')])
@@ -401,7 +402,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
we're testing, so that the 'exception' trace event fires."""
if self.raiseOnEvent == 'exception':
x = 0
- y = 1 // x
+ y = 1/x
else:
return 1
@@ -410,7 +411,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
handled OK."""
self.raiseOnEvent = event
try:
- for i in xrange(sys.getrecursionlimit() + 1):
+ for i in range(sys.getrecursionlimit() + 1):
sys.settrace(self.trace)
try:
self.f()
@@ -434,12 +435,12 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
def test_trash_stack(self):
def f():
for i in range(5):
- print i # line tracing will raise an exception at this line
+ print(i) # line tracing will raise an exception at this line
def g(frame, why, extra):
if (why == 'line' and
- frame.f_lineno == f.func_code.co_firstlineno + 2):
- raise RuntimeError, "i am crashing"
+ frame.f_lineno == f.__code__.co_firstlineno + 2):
+ raise RuntimeError("i am crashing")
return g
sys.settrace(g)
@@ -469,7 +470,7 @@ class JumpTracer:
self.done = False
def trace(self, frame, event, arg):
- if not self.done and frame.f_code == self.function.func_code:
+ if not self.done and frame.f_code == self.function.__code__:
firstLine = frame.f_code.co_firstlineno
if event == 'line' and frame.f_lineno == firstLine + self.jumpFrom:
# Cope with non-integer self.jumpTo (because of
@@ -557,7 +558,7 @@ def no_jump_too_far_forwards(output):
try:
output.append(2)
output.append(3)
- except ValueError, e:
+ except ValueError as e:
output.append('after' in str(e))
no_jump_too_far_forwards.jump = (3, 6)
@@ -567,7 +568,7 @@ def no_jump_too_far_backwards(output):
try:
output.append(2)
output.append(3)
- except ValueError, e:
+ except ValueError as e:
output.append('before' in str(e))
no_jump_too_far_backwards.jump = (3, -1)
@@ -597,7 +598,7 @@ no_jump_to_except_2.output = [True]
def no_jump_to_except_3(output):
try:
output.append(2)
- except ValueError, e:
+ except ValueError as e:
output.append('except' in str(e))
no_jump_to_except_3.jump = (2, 3)
@@ -606,7 +607,7 @@ no_jump_to_except_3.output = [True]
def no_jump_to_except_4(output):
try:
output.append(2)
- except (ValueError, RuntimeError), e:
+ except (ValueError, RuntimeError) as e:
output.append('except' in str(e))
no_jump_to_except_4.jump = (2, 3)
@@ -617,7 +618,7 @@ def no_jump_forwards_into_block(output):
output.append(2)
for i in 1, 2:
output.append(4)
- except ValueError, e:
+ except ValueError as e:
output.append('into' in str(e))
no_jump_forwards_into_block.jump = (2, 4)
@@ -628,7 +629,7 @@ def no_jump_backwards_into_block(output):
for i in 1, 2:
output.append(3)
output.append(4)
- except ValueError, e:
+ except ValueError as e:
output.append('into' in str(e))
no_jump_backwards_into_block.jump = (4, 3)
@@ -641,7 +642,7 @@ def no_jump_into_finally_block(output):
x = 1
finally:
output.append(6)
- except ValueError, e:
+ except ValueError as e:
output.append('finally' in str(e))
no_jump_into_finally_block.jump = (4, 6)
@@ -654,7 +655,7 @@ def no_jump_out_of_finally_block(output):
finally:
output.append(5)
output.append(6)
- except ValueError, e:
+ except ValueError as e:
output.append('finally' in str(e))
no_jump_out_of_finally_block.jump = (5, 1)
@@ -664,16 +665,16 @@ no_jump_out_of_finally_block.output = [3, True]
def no_jump_to_non_integers(output):
try:
output.append(2)
- except ValueError, e:
+ except ValueError as e:
output.append('integer' in str(e))
no_jump_to_non_integers.jump = (2, "Spam")
no_jump_to_non_integers.output = [True]
def jump_across_with(output):
- with open(test_support.TESTFN, "wb") as fp:
+ with open(support.TESTFN, "wb") as fp:
pass
- with open(test_support.TESTFN, "wb") as fp:
+ with open(support.TESTFN, "wb") as fp:
pass
jump_across_with.jump = (1, 3)
jump_across_with.output = []
@@ -684,14 +685,14 @@ def no_jump_without_trace_function():
try:
previous_frame = sys._getframe().f_back
previous_frame.f_lineno = previous_frame.f_lineno
- except ValueError, e:
+ except ValueError as e:
# This is the exception we wanted; make sure the error message
# talks about trace functions.
if 'trace' not in str(e):
raise
else:
# Something's wrong - the expected exception wasn't raised.
- raise RuntimeError, "Trace-function-less jump failed to fail"
+ raise RuntimeError("Trace-function-less jump failed to fail")
class JumpTestCase(unittest.TestCase):
@@ -748,7 +749,7 @@ class JumpTestCase(unittest.TestCase):
def test_19_no_jump_without_trace_function(self):
no_jump_without_trace_function()
def test_jump_across_with(self):
- self.addCleanup(test_support.unlink, test_support.TESTFN)
+ self.addCleanup(support.unlink, support.TESTFN)
self.run_test(jump_across_with)
def test_20_large_function(self):
@@ -779,18 +780,18 @@ output.append(3)
output.append(4)
""", "<fake module>", "exec")
class fake_function:
- func_code = code
+ __code__ = code
jump = (2, 0)
tracer = JumpTracer(fake_function)
sys.settrace(tracer.trace)
namespace = {"output": []}
- exec code in namespace
+ exec(code, namespace)
sys.settrace(None)
self.compare_jump_output([2, 3, 2, 3, 4], namespace["output"])
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
TraceTestCase,
RaisingTraceFuncTestCase,
JumpTestCase
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 716fa5e40e8..aabb6fa72a8 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -3,17 +3,18 @@
import unittest
import sys
import os
-import shutil
import subprocess
+import shutil
from copy import copy, deepcopy
-from test.test_support import run_unittest, TESTFN, unlink, get_attribute
+from test.support import (run_unittest, TESTFN, unlink,
+ captured_stdout, skip_unless_symlink)
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
get_path, get_path_names, _INSTALL_SCHEMES,
_get_default_scheme, _expand_vars,
- get_scheme_names, get_config_var)
+ get_scheme_names, get_config_var, _main)
class TestSysConfig(unittest.TestCase):
@@ -21,7 +22,6 @@ class TestSysConfig(unittest.TestCase):
"""Make a copy of sys.path"""
super(TestSysConfig, self).setUp()
self.sys_path = sys.path[:]
- self.makefile = None
# patching os.uname
if hasattr(os, 'uname'):
self.uname = os.uname
@@ -44,8 +44,6 @@ class TestSysConfig(unittest.TestCase):
def tearDown(self):
"""Restore sys.path"""
sys.path[:] = self.sys_path
- if self.makefile is not None:
- os.unlink(self.makefile)
self._cleanup_testfn()
if self.uname is not None:
os.uname = self.uname
@@ -63,7 +61,7 @@ class TestSysConfig(unittest.TestCase):
if os.environ.get(key) != value:
os.environ[key] = value
- for key in os.environ.keys():
+ for key in list(os.environ.keys()):
if key not in self.old_environ:
del os.environ[key]
@@ -89,9 +87,9 @@ class TestSysConfig(unittest.TestCase):
scheme = get_paths()
default_scheme = _get_default_scheme()
wanted = _expand_vars(default_scheme, None)
- wanted = wanted.items()
+ wanted = list(wanted.items())
wanted.sort()
- scheme = scheme.items()
+ scheme = list(scheme.items())
scheme.sort()
self.assertEqual(scheme, wanted)
@@ -103,7 +101,7 @@ class TestSysConfig(unittest.TestCase):
def test_get_config_vars(self):
cvars = get_config_vars()
- self.assertIsInstance(cvars, dict)
+ self.assertTrue(isinstance(cvars, dict))
self.assertTrue(cvars)
def test_get_platform(self):
@@ -137,19 +135,21 @@ class TestSysConfig(unittest.TestCase):
('Darwin Kernel Version 8.11.1: '
'Wed Oct 10 18:23:28 PDT 2007; '
'root:xnu-792.25.20~1/RELEASE_I386'), 'PowerPC'))
+
+
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
'-fwrapv -O3 -Wall -Wstrict-prototypes')
- maxint = sys.maxint
+ maxint = sys.maxsize
try:
- sys.maxint = 2147483647
+ sys.maxsize = 2147483647
self.assertEqual(get_platform(), 'macosx-10.3-ppc')
- sys.maxint = 9223372036854775807
+ sys.maxsize = 9223372036854775807
self.assertEqual(get_platform(), 'macosx-10.3-ppc64')
finally:
- sys.maxint = maxint
+ sys.maxsize = maxint
self._set_uname(('Darwin', 'macziade', '8.11.1',
@@ -157,18 +157,18 @@ class TestSysConfig(unittest.TestCase):
'Wed Oct 10 18:23:28 PDT 2007; '
'root:xnu-792.25.20~1/RELEASE_I386'), 'i386'))
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
+ get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.3'
get_config_vars()['CFLAGS'] = ('-fno-strict-aliasing -DNDEBUG -g '
'-fwrapv -O3 -Wall -Wstrict-prototypes')
-
- maxint = sys.maxint
+ maxint = sys.maxsize
try:
- sys.maxint = 2147483647
+ sys.maxsize = 2147483647
self.assertEqual(get_platform(), 'macosx-10.3-i386')
- sys.maxint = 9223372036854775807
+ sys.maxsize = 9223372036854775807
self.assertEqual(get_platform(), 'macosx-10.3-x86_64')
finally:
- sys.maxint = maxint
+ sys.maxsize = maxint
# macbook with fat binaries (fat, universal or fat64)
get_config_vars()['MACOSX_DEPLOYMENT_TARGET'] = '10.4'
@@ -234,17 +234,23 @@ class TestSysConfig(unittest.TestCase):
'posix_home', 'posix_prefix', 'posix_user')
self.assertEqual(get_scheme_names(), wanted)
+ @skip_unless_symlink
def test_symlink(self):
+ # On Windows, the EXE needs to know where pythonXY.dll is at so we have
+ # to add the directory to the path.
+ if sys.platform == "win32":
+ os.environ["Path"] = "{};{}".format(
+ os.path.dirname(sys.executable), os.environ["Path"])
+
# Issue 7880
- symlink = get_attribute(os, "symlink")
def get(python):
cmd = [python, '-c',
- 'import sysconfig; print sysconfig.get_platform()']
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ 'import sysconfig; print(sysconfig.get_platform())']
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=os.environ)
return p.communicate()
real = os.path.realpath(sys.executable)
link = os.path.abspath(TESTFN)
- symlink(real, link)
+ os.symlink(real, link)
try:
self.assertEqual(get(real), get(link))
finally:
@@ -267,6 +273,20 @@ class TestSysConfig(unittest.TestCase):
user_path = get_path(name, 'posix_user')
self.assertEqual(user_path, global_path.replace(base, user, 1))
+ def test_main(self):
+ # just making sure _main() runs and returns things in the stdout
+ with captured_stdout() as output:
+ _main()
+ self.assertTrue(len(output.getvalue().split('\n')) > 0)
+
+ @unittest.skipIf(sys.platform == "win32", "Does not apply to Windows")
+ def test_ldshared_value(self):
+ ldflags = sysconfig.get_config_var('LDFLAGS')
+ ldshared = sysconfig.get_config_var('LDSHARED')
+
+ self.assertIn(ldflags, ldshared)
+
+
@unittest.skipUnless(sys.platform == "darwin", "test only relevant on MacOSX")
def test_platform_in_subprocess(self):
my_platform = sysconfig.get_platform()
@@ -280,7 +300,7 @@ class TestSysConfig(unittest.TestCase):
with open('/dev/null', 'w') as devnull_fp:
p = subprocess.Popen([
sys.executable, '-c',
- 'import sysconfig; print(sysconfig.get_platform())',
+ 'import sysconfig; print(sysconfig.get_platform())',
],
stdout=subprocess.PIPE,
stderr=devnull_fp,
@@ -312,8 +332,34 @@ class TestSysConfig(unittest.TestCase):
self.assertEqual(status, 0)
self.assertEqual(my_platform, test_platform)
+
+class MakefileTests(unittest.TestCase):
+ @unittest.skipIf(sys.platform.startswith('win'),
+ 'Test is not Windows compatible')
+ def test_get_makefile_filename(self):
+ makefile = sysconfig.get_makefile_filename()
+ self.assertTrue(os.path.isfile(makefile), makefile)
+
+ def test_parse_makefile(self):
+ self.addCleanup(unlink, TESTFN)
+ with open(TESTFN, "w") as makefile:
+ print("var1=a$(VAR2)", file=makefile)
+ print("VAR2=b$(var3)", file=makefile)
+ print("var3=42", file=makefile)
+ print("var4=$/invalid", file=makefile)
+ print("var5=dollar$$5", file=makefile)
+ vars = sysconfig._parse_makefile(TESTFN)
+ self.assertEqual(vars, {
+ 'var1': 'ab42',
+ 'VAR2': 'b42',
+ 'var3': 42,
+ 'var4': '$/invalid',
+ 'var5': 'dollar$5',
+ })
+
+
def test_main():
- run_unittest(TestSysConfig)
+ run_unittest(TestSysConfig, MakefileTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py
new file mode 100644
index 00000000000..4e7621e5ec2
--- /dev/null
+++ b/Lib/test/test_syslog.py
@@ -0,0 +1,39 @@
+
+from test import support
+syslog = support.import_module("syslog") #skip if not supported
+import unittest
+
+# XXX(nnorwitz): This test sucks. I don't know of a platform independent way
+# to verify that the messages were really logged.
+# The only purpose of this test is to verify the code doesn't crash or leak.
+
+class Test(unittest.TestCase):
+
+ def test_openlog(self):
+ syslog.openlog('python')
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
+
+ def test_syslog(self):
+ syslog.openlog('python')
+ syslog.syslog('test message from python test_syslog')
+ syslog.syslog(syslog.LOG_ERR, 'test error from python test_syslog')
+
+ def test_closelog(self):
+ syslog.openlog('python')
+ syslog.closelog()
+
+ def test_setlogmask(self):
+ syslog.setlogmask(syslog.LOG_DEBUG)
+
+ def test_log_mask(self):
+ syslog.LOG_MASK(syslog.LOG_INFO)
+
+ def test_log_upto(self):
+ syslog.LOG_UPTO(syslog.LOG_INFO)
+
+def test_main():
+ support.run_unittest(__name__)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
index 9ec7744efbe..f32eb8c438d 100644
--- a/Lib/test/test_tarfile.py
+++ b/Lib/test/test_tarfile.py
@@ -1,16 +1,15 @@
-# -*- coding: iso-8859-15 -*-
-
import sys
import os
+import io
import shutil
-import StringIO
+import io
from hashlib import md5
import errno
import unittest
import tarfile
-from test import test_support
+from test import support
# Check for our compression modules.
try:
@@ -26,8 +25,8 @@ except ImportError:
def md5sum(data):
return md5(data).hexdigest()
-TEMPDIR = os.path.abspath(test_support.TESTFN)
-tarname = test_support.findfile("testtar.tar")
+TEMPDIR = os.path.abspath(support.TESTFN) + "-tardir"
+tarname = support.findfile("testtar.tar")
gzipname = os.path.join(TEMPDIR, "testtar.tar.gz")
bz2name = os.path.join(TEMPDIR, "testtar.tar.bz2")
tmpname = os.path.join(TEMPDIR, "tmp.tar")
@@ -53,69 +52,78 @@ class UstarReadTest(ReadTest):
def test_fileobj_regular_file(self):
tarinfo = self.tar.getmember("ustar/regtype")
fobj = self.tar.extractfile(tarinfo)
- data = fobj.read()
- self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
- "regular file extraction failed")
+ try:
+ data = fobj.read()
+ self.assertTrue((len(data), md5sum(data)) == (tarinfo.size, md5_regtype),
+ "regular file extraction failed")
+ finally:
+ fobj.close()
def test_fileobj_readlines(self):
self.tar.extract("ustar/regtype", TEMPDIR)
tarinfo = self.tar.getmember("ustar/regtype")
- fobj1 = open(os.path.join(TEMPDIR, "ustar/regtype"), "rU")
- fobj2 = self.tar.extractfile(tarinfo)
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "r") as fobj1:
+ lines1 = fobj1.readlines()
- lines1 = fobj1.readlines()
- lines2 = fobj2.readlines()
- self.assertTrue(lines1 == lines2,
- "fileobj.readlines() failed")
- self.assertTrue(len(lines2) == 114,
- "fileobj.readlines() failed")
- self.assertTrue(lines2[83] ==
- "I will gladly admit that Python is not the fastest running scripting language.\n",
- "fileobj.readlines() failed")
+ fobj = self.tar.extractfile(tarinfo)
+ try:
+ fobj2 = io.TextIOWrapper(fobj)
+ lines2 = fobj2.readlines()
+ self.assertTrue(lines1 == lines2,
+ "fileobj.readlines() failed")
+ self.assertTrue(len(lines2) == 114,
+ "fileobj.readlines() failed")
+ self.assertTrue(lines2[83] ==
+ "I will gladly admit that Python is not the fastest running scripting language.\n",
+ "fileobj.readlines() failed")
+ finally:
+ fobj.close()
def test_fileobj_iter(self):
self.tar.extract("ustar/regtype", TEMPDIR)
tarinfo = self.tar.getmember("ustar/regtype")
- fobj1 = open(os.path.join(TEMPDIR, "ustar/regtype"), "rU")
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "rU") as fobj1:
+ lines1 = fobj1.readlines()
fobj2 = self.tar.extractfile(tarinfo)
- lines1 = fobj1.readlines()
- lines2 = [line for line in fobj2]
- self.assertTrue(lines1 == lines2,
- "fileobj.__iter__() failed")
+ try:
+ lines2 = list(io.TextIOWrapper(fobj2))
+ self.assertTrue(lines1 == lines2,
+ "fileobj.__iter__() failed")
+ finally:
+ fobj2.close()
def test_fileobj_seek(self):
self.tar.extract("ustar/regtype", TEMPDIR)
- fobj = open(os.path.join(TEMPDIR, "ustar/regtype"), "rb")
- data = fobj.read()
- fobj.close()
+ with open(os.path.join(TEMPDIR, "ustar/regtype"), "rb") as fobj:
+ data = fobj.read()
tarinfo = self.tar.getmember("ustar/regtype")
fobj = self.tar.extractfile(tarinfo)
text = fobj.read()
fobj.seek(0)
- self.assertTrue(0 == fobj.tell(),
+ self.assertEqual(0, fobj.tell(),
"seek() to file's start failed")
fobj.seek(2048, 0)
- self.assertTrue(2048 == fobj.tell(),
+ self.assertEqual(2048, fobj.tell(),
"seek() to absolute position failed")
fobj.seek(-1024, 1)
- self.assertTrue(1024 == fobj.tell(),
+ self.assertEqual(1024, fobj.tell(),
"seek() to negative relative position failed")
fobj.seek(1024, 1)
- self.assertTrue(2048 == fobj.tell(),
+ self.assertEqual(2048, fobj.tell(),
"seek() to positive relative position failed")
s = fobj.read(10)
self.assertTrue(s == data[2048:2058],
"read() after seek failed")
fobj.seek(0, 2)
- self.assertTrue(tarinfo.size == fobj.tell(),
+ self.assertEqual(tarinfo.size, fobj.tell(),
"seek() to file's end failed")
- self.assertTrue(fobj.read() == "",
+ self.assertTrue(fobj.read() == b"",
"read() at file's end did not return empty string")
fobj.seek(-tarinfo.size, 2)
- self.assertTrue(0 == fobj.tell(),
- "relative seek() to file's start failed")
+ self.assertEqual(0, fobj.tell(),
+ "relative seek() to file's end failed")
fobj.seek(512)
s1 = fobj.readlines()
fobj.seek(512)
@@ -123,14 +131,14 @@ class UstarReadTest(ReadTest):
self.assertTrue(s1 == s2,
"readlines() after seek failed")
fobj.seek(0)
- self.assertTrue(len(fobj.readline()) == fobj.tell(),
+ self.assertEqual(len(fobj.readline()), fobj.tell(),
"tell() after readline() failed")
fobj.seek(512)
self.assertTrue(len(fobj.readline()) + 512 == fobj.tell(),
"tell() after seek() and readline() failed")
fobj.seek(0)
line = fobj.readline()
- self.assertTrue(fobj.read() == data[len(line):],
+ self.assertEqual(fobj.read(), data[len(line):],
"read() after readline() failed")
fobj.close()
@@ -140,7 +148,11 @@ class UstarReadTest(ReadTest):
def _test_fileobj_link(self, lnktype, regtype):
a = self.tar.extractfile(lnktype)
b = self.tar.extractfile(regtype)
- self.assertEqual(a.name, b.name)
+ try:
+ self.assertEqual(a.name, b.name)
+ finally:
+ a.close()
+ b.close()
def test_fileobj_link1(self):
self._test_fileobj_link("ustar/lnktype", "ustar/regtype")
@@ -165,19 +177,24 @@ class CommonReadTest(ReadTest):
# This test checks if tarfile.open() is able to open an empty tar
# archive successfully. Note that an empty tar archive is not the
# same as an empty file!
- tarfile.open(tmpname, self.mode.replace("r", "w")).close()
+ with tarfile.open(tmpname, self.mode.replace("r", "w")):
+ pass
try:
tar = tarfile.open(tmpname, self.mode)
tar.getnames()
except tarfile.ReadError:
self.fail("tarfile.open() failed on empty archive")
- self.assertListEqual(tar.getmembers(), [])
+ else:
+ self.assertListEqual(tar.getmembers(), [])
+ finally:
+ tar.close()
def test_null_tarfile(self):
# Test for issue6123: Allow opening empty archives.
# This test guarantees that tarfile.open() does not treat an empty
# file as an empty tar archive.
- open(tmpname, "wb").close()
+ with open(tmpname, "wb"):
+ pass
self.assertRaises(tarfile.ReadError, tarfile.open, tmpname, self.mode)
self.assertRaises(tarfile.ReadError, tarfile.open, tmpname)
@@ -190,51 +207,58 @@ class CommonReadTest(ReadTest):
else:
_open = open
- for char in ('\0', 'a'):
+ for char in (b'\0', b'a'):
# Test if EOFHeaderError ('\0') and InvalidHeaderError ('a')
# are ignored correctly.
- fobj = _open(tmpname, "wb")
- fobj.write(char * 1024)
- fobj.write(tarfile.TarInfo("foo").tobuf())
- fobj.close()
+ with _open(tmpname, "wb") as fobj:
+ fobj.write(char * 1024)
+ fobj.write(tarfile.TarInfo("foo").tobuf())
tar = tarfile.open(tmpname, mode="r", ignore_zeros=True)
- self.assertListEqual(tar.getnames(), ["foo"],
+ try:
+ self.assertListEqual(tar.getnames(), ["foo"],
"ignore_zeros=True should have skipped the %r-blocks" % char)
- tar.close()
+ finally:
+ tar.close()
class MiscReadTest(CommonReadTest):
def test_no_name_argument(self):
- fobj = open(self.tarname, "rb")
- tar = tarfile.open(fileobj=fobj, mode=self.mode)
- self.assertEqual(tar.name, os.path.abspath(fobj.name))
+ with open(self.tarname, "rb") as fobj:
+ tar = tarfile.open(fileobj=fobj, mode=self.mode)
+ self.assertEqual(tar.name, os.path.abspath(fobj.name))
def test_no_name_attribute(self):
- data = open(self.tarname, "rb").read()
- fobj = StringIO.StringIO(data)
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
+ fobj = io.BytesIO(data)
self.assertRaises(AttributeError, getattr, fobj, "name")
tar = tarfile.open(fileobj=fobj, mode=self.mode)
self.assertEqual(tar.name, None)
def test_empty_name_attribute(self):
- data = open(self.tarname, "rb").read()
- fobj = StringIO.StringIO(data)
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
+ fobj = io.BytesIO(data)
fobj.name = ""
- tar = tarfile.open(fileobj=fobj, mode=self.mode)
- self.assertEqual(tar.name, None)
+ with tarfile.open(fileobj=fobj, mode=self.mode) as tar:
+ self.assertEqual(tar.name, None)
def test_fileobj_with_offset(self):
# Skip the first member and store values from the second member
# of the testtar.
tar = tarfile.open(self.tarname, mode=self.mode)
- tar.next()
- t = tar.next()
- name = t.name
- offset = t.offset
- data = tar.extractfile(t).read()
- tar.close()
+ try:
+ tar.next()
+ t = tar.next()
+ name = t.name
+ offset = t.offset
+ f = tar.extractfile(t)
+ data = f.read()
+ f.close()
+ finally:
+ tar.close()
# Open the testtar and seek to the offset of the second member.
if self.mode.endswith(":gz"):
@@ -244,26 +268,30 @@ class MiscReadTest(CommonReadTest):
else:
_open = open
fobj = _open(self.tarname, "rb")
- fobj.seek(offset)
-
- # Test if the tarfile starts with the second member.
- tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
- t = tar.next()
- self.assertEqual(t.name, name)
- # Read to the end of fileobj and test if seeking back to the
- # beginning works.
- tar.getmembers()
- self.assertEqual(tar.extractfile(t).read(), data,
- "seek back did not work")
- tar.close()
+ try:
+ fobj.seek(offset)
+
+ # Test if the tarfile starts with the second member.
+ tar = tar.open(self.tarname, mode="r:", fileobj=fobj)
+ t = tar.next()
+ self.assertEqual(t.name, name)
+ # Read to the end of fileobj and test if seeking back to the
+ # beginning works.
+ tar.getmembers()
+ self.assertEqual(tar.extractfile(t).read(), data,
+ "seek back did not work")
+ tar.close()
+ finally:
+ fobj.close()
def test_fail_comp(self):
# For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file.
if self.mode == "r:":
return
self.assertRaises(tarfile.ReadError, tarfile.open, tarname, self.mode)
- fobj = open(tarname, "rb")
- self.assertRaises(tarfile.ReadError, tarfile.open, fileobj=fobj, mode=self.mode)
+ with open(tarname, "rb") as fobj:
+ self.assertRaises(tarfile.ReadError, tarfile.open,
+ fileobj=fobj, mode=self.mode)
def test_v7_dirtype(self):
# Test old style dirtype member (bug #1336623):
@@ -284,7 +312,7 @@ class MiscReadTest(CommonReadTest):
def test_check_members(self):
for tarinfo in self.tar:
- self.assertTrue(int(tarinfo.mtime) == 07606136617,
+ self.assertTrue(int(tarinfo.mtime) == 0o7606136617,
"wrong mtime for %s" % tarinfo.name)
if not tarinfo.name.startswith("ustar/"):
continue
@@ -295,49 +323,88 @@ class MiscReadTest(CommonReadTest):
self.assertTrue(self.tar.getmembers()[-1].name == "misc/eof",
"could not find all members")
+ @unittest.skipUnless(hasattr(os, "link"),
+ "Missing hardlink implementation")
+ @support.skip_unless_symlink
def test_extract_hardlink(self):
# Test hardlink extraction (e.g. bug #857297).
tar = tarfile.open(tarname, errorlevel=1, encoding="iso8859-1")
- tar.extract("ustar/regtype", TEMPDIR)
try:
- tar.extract("ustar/lnktype", TEMPDIR)
- except EnvironmentError, e:
- if e.errno == errno.ENOENT:
- self.fail("hardlink not extracted properly")
+ tar.extract("ustar/regtype", TEMPDIR)
+ try:
+ tar.extract("ustar/lnktype", TEMPDIR)
+ except EnvironmentError as e:
+ if e.errno == errno.ENOENT:
+ self.fail("hardlink not extracted properly")
- data = open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb").read()
- self.assertEqual(md5sum(data), md5_regtype)
+ with open(os.path.join(TEMPDIR, "ustar/lnktype"), "rb") as f:
+ data = f.read()
+ self.assertEqual(md5sum(data), md5_regtype)
- try:
- tar.extract("ustar/symtype", TEMPDIR)
- except EnvironmentError, e:
- if e.errno == errno.ENOENT:
- self.fail("symlink not extracted properly")
-
- data = open(os.path.join(TEMPDIR, "ustar/symtype"), "rb").read()
- self.assertEqual(md5sum(data), md5_regtype)
+ try:
+ tar.extract("ustar/symtype", TEMPDIR)
+ except EnvironmentError as e:
+ if e.errno == errno.ENOENT:
+ self.fail("symlink not extracted properly")
+
+ with open(os.path.join(TEMPDIR, "ustar/symtype"), "rb") as f:
+ data = f.read()
+ self.assertEqual(md5sum(data), md5_regtype)
+ finally:
+ tar.close()
def test_extractall(self):
# Test if extractall() correctly restores directory permissions
# and times (see issue1735).
tar = tarfile.open(tarname, encoding="iso8859-1")
- directories = [t for t in tar if t.isdir()]
- tar.extractall(TEMPDIR, directories)
- for tarinfo in directories:
- path = os.path.join(TEMPDIR, tarinfo.name)
- if sys.platform != "win32":
- # Win32 has no support for fine grained permissions.
- self.assertEqual(tarinfo.mode & 0777, os.stat(path).st_mode & 0777)
- self.assertEqual(tarinfo.mtime, os.path.getmtime(path))
- tar.close()
+ DIR = os.path.join(TEMPDIR, "extractall")
+ os.mkdir(DIR)
+ try:
+ directories = [t for t in tar if t.isdir()]
+ tar.extractall(DIR, directories)
+ for tarinfo in directories:
+ path = os.path.join(DIR, tarinfo.name)
+ if sys.platform != "win32":
+ # Win32 has no support for fine grained permissions.
+ self.assertEqual(tarinfo.mode & 0o777, os.stat(path).st_mode & 0o777)
+ def format_mtime(mtime):
+ if isinstance(mtime, float):
+ return "{} ({})".format(mtime, mtime.hex())
+ else:
+ return "{!r} (int)".format(mtime)
+ file_mtime = os.path.getmtime(path)
+ errmsg = "tar mtime {0} != file time {1} of path {2!a}".format(
+ format_mtime(tarinfo.mtime),
+ format_mtime(file_mtime),
+ path)
+ self.assertEqual(tarinfo.mtime, file_mtime, errmsg)
+ finally:
+ tar.close()
+ shutil.rmtree(DIR)
+
+ def test_extract_directory(self):
+ dirtype = "ustar/dirtype"
+ DIR = os.path.join(TEMPDIR, "extractdir")
+ os.mkdir(DIR)
+ try:
+ with tarfile.open(tarname, encoding="iso8859-1") as tar:
+ tarinfo = tar.getmember(dirtype)
+ tar.extract(tarinfo, path=DIR)
+ extracted = os.path.join(DIR, dirtype)
+ self.assertEqual(os.path.getmtime(extracted), tarinfo.mtime)
+ if sys.platform != "win32":
+ self.assertEqual(os.stat(extracted).st_mode & 0o777, 0o755)
+ finally:
+ shutil.rmtree(DIR)
def test_init_close_fobj(self):
# Issue #7341: Close the internal file object in the TarFile
# constructor in case of an error. For the test we rely on
# the fact that opening an empty file raises a ReadError.
empty = os.path.join(TEMPDIR, "empty")
- open(empty, "wb").write("")
+ with open(empty, "wb") as fobj:
+ fobj.write(b"")
try:
tar = object.__new__(tarfile.TarFile)
@@ -348,13 +415,29 @@ class MiscReadTest(CommonReadTest):
else:
self.fail("ReadError not raised")
finally:
- os.remove(empty)
+ support.unlink(empty)
class StreamReadTest(CommonReadTest):
mode="r|"
+ def test_read_through(self):
+ # Issue #11224: A poorly designed _FileInFile.read() method
+ # caused seeking errors with stream tar files.
+ for tarinfo in self.tar:
+ if not tarinfo.isreg():
+ continue
+ fobj = self.tar.extractfile(tarinfo)
+ while True:
+ try:
+ buf = fobj.read(512)
+ except tarfile.StreamError:
+ self.fail("simple read-through using TarFile.extractfile() failed")
+ if not buf:
+ break
+ fobj.close()
+
def test_fileobj_regular_file(self):
tarinfo = self.tar.next() # get "regtype" (can't use getmember)
fobj = self.tar.extractfile(tarinfo)
@@ -369,42 +452,48 @@ class StreamReadTest(CommonReadTest):
def test_compare_members(self):
tar1 = tarfile.open(tarname, encoding="iso8859-1")
- tar2 = self.tar
-
- while True:
- t1 = tar1.next()
- t2 = tar2.next()
- if t1 is None:
- break
- self.assertTrue(t2 is not None, "stream.next() failed.")
-
- if t2.islnk() or t2.issym():
- self.assertRaises(tarfile.StreamError, tar2.extractfile, t2)
- continue
-
- v1 = tar1.extractfile(t1)
- v2 = tar2.extractfile(t2)
- if v1 is None:
- continue
- self.assertTrue(v2 is not None, "stream.extractfile() failed")
- self.assertTrue(v1.read() == v2.read(), "stream extraction failed")
-
- tar1.close()
+ try:
+ tar2 = self.tar
+
+ while True:
+ t1 = tar1.next()
+ t2 = tar2.next()
+ if t1 is None:
+ break
+ self.assertTrue(t2 is not None, "stream.next() failed.")
+
+ if t2.islnk() or t2.issym():
+ self.assertRaises(tarfile.StreamError, tar2.extractfile, t2)
+ continue
+
+ v1 = tar1.extractfile(t1)
+ v2 = tar2.extractfile(t2)
+ if v1 is None:
+ continue
+ self.assertTrue(v2 is not None, "stream.extractfile() failed")
+ self.assertEqual(v1.read(), v2.read(), "stream extraction failed")
+ finally:
+ tar1.close()
class DetectReadTest(unittest.TestCase):
def _testfunc_file(self, name, mode):
try:
- tarfile.open(name, mode)
- except tarfile.ReadError:
+ tar = tarfile.open(name, mode)
+ except tarfile.ReadError as e:
self.fail()
+ else:
+ tar.close()
def _testfunc_fileobj(self, name, mode):
try:
- tarfile.open(name, mode, fileobj=open(name, "rb"))
- except tarfile.ReadError:
+ with open(name, "rb") as f:
+ tar = tarfile.open(name, mode, fileobj=f)
+ except tarfile.ReadError as e:
self.fail()
+ else:
+ tar.close()
def _test_modes(self, testfunc):
testfunc(tarname, "r")
@@ -468,14 +557,14 @@ class MemberReadTest(ReadTest):
self.assertTrue(md5sum(self.tar.extractfile(tarinfo).read()) == chksum,
"wrong md5sum for %s" % tarinfo.name)
- kwargs["mtime"] = 07606136617
+ kwargs["mtime"] = 0o7606136617
kwargs["uid"] = 1000
kwargs["gid"] = 100
if "old-v7" not in tarinfo.name:
# V7 tar can't handle alphabetic owners.
kwargs["uname"] = "tarfile"
kwargs["gname"] = "tarfile"
- for k, v in kwargs.iteritems():
+ for k, v in kwargs.items():
self.assertTrue(getattr(tarinfo, k) == v,
"wrong value in %s field of %s" % (k, tarinfo.name))
@@ -519,8 +608,24 @@ class MemberReadTest(ReadTest):
tarinfo = self.tar.getmember("ustar/sparse")
self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+ def test_find_gnusparse(self):
+ tarinfo = self.tar.getmember("gnu/sparse")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_00(self):
+ tarinfo = self.tar.getmember("gnu/sparse-0.0")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_01(self):
+ tarinfo = self.tar.getmember("gnu/sparse-0.1")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
+ def test_find_gnusparse_10(self):
+ tarinfo = self.tar.getmember("gnu/sparse-1.0")
+ self._test_member(tarinfo, size=86016, chksum=md5_sparse)
+
def test_find_umlauts(self):
- tarinfo = self.tar.getmember("ustar/umlauts-ÄÖÜäöüß")
+ tarinfo = self.tar.getmember("ustar/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
def test_find_ustar_longname(self):
@@ -532,8 +637,9 @@ class MemberReadTest(ReadTest):
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
def test_find_pax_umlauts(self):
+ self.tar.close()
self.tar = tarfile.open(self.tarname, mode=self.mode, encoding="iso8859-1")
- tarinfo = self.tar.getmember("pax/umlauts-ÄÖÜäöüß")
+ tarinfo = self.tar.getmember("pax/umlauts-\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
self._test_member(tarinfo, size=7011, chksum=md5_regtype)
@@ -562,7 +668,7 @@ class LongnameTest(ReadTest):
tarinfo = self.tar.getmember(longname)
offset = tarinfo.offset
self.tar.fileobj.seek(offset)
- fobj = StringIO.StringIO(self.tar.fileobj.read(3 * 512))
+ fobj = io.BytesIO(self.tar.fileobj.read(3 * 512))
self.assertRaises(tarfile.ReadError, tarfile.open, name="foo.tar", fileobj=fobj)
def test_header_offset(self):
@@ -570,10 +676,10 @@ class LongnameTest(ReadTest):
# the preceding extended header.
longname = self.subdir + "/" + "123/" * 125 + "longname"
offset = self.tar.getmember(longname).offset
- fobj = open(tarname)
- fobj.seek(offset)
- tarinfo = tarfile.TarInfo.frombuf(fobj.read(512))
- self.assertEqual(tarinfo.type, self.longnametype)
+ with open(tarname, "rb") as fobj:
+ fobj.seek(offset)
+ tarinfo = tarfile.TarInfo.frombuf(fobj.read(512), "iso8859-1", "strict")
+ self.assertEqual(tarinfo.type, self.longnametype)
class GNUReadTest(LongnameTest):
@@ -581,13 +687,53 @@ class GNUReadTest(LongnameTest):
subdir = "gnu"
longnametype = tarfile.GNUTYPE_LONGNAME
- def test_sparse_file(self):
- tarinfo1 = self.tar.getmember("ustar/sparse")
- fobj1 = self.tar.extractfile(tarinfo1)
- tarinfo2 = self.tar.getmember("gnu/sparse")
- fobj2 = self.tar.extractfile(tarinfo2)
- self.assertTrue(fobj1.read() == fobj2.read(),
- "sparse file extraction failed")
+ # Since 3.2 tarfile is supposed to accurately restore sparse members and
+ # produce files with holes. This is what we actually want to test here.
+ # Unfortunately, not all platforms/filesystems support sparse files, and
+ # even on platforms that do it is non-trivial to make reliable assertions
+ # about holes in files. Therefore, we first do one basic test which works
+ # an all platforms, and after that a test that will work only on
+ # platforms/filesystems that prove to support sparse files.
+ def _test_sparse_file(self, name):
+ self.tar.extract(name, TEMPDIR)
+ filename = os.path.join(TEMPDIR, name)
+ with open(filename, "rb") as fobj:
+ data = fobj.read()
+ self.assertEqual(md5sum(data), md5_sparse,
+ "wrong md5sum for %s" % name)
+
+ if self._fs_supports_holes():
+ s = os.stat(filename)
+ self.assertTrue(s.st_blocks * 512 < s.st_size)
+
+ def test_sparse_file_old(self):
+ self._test_sparse_file("gnu/sparse")
+
+ def test_sparse_file_00(self):
+ self._test_sparse_file("gnu/sparse-0.0")
+
+ def test_sparse_file_01(self):
+ self._test_sparse_file("gnu/sparse-0.1")
+
+ def test_sparse_file_10(self):
+ self._test_sparse_file("gnu/sparse-1.0")
+
+ @staticmethod
+ def _fs_supports_holes():
+ # Return True if the platform knows the st_blocks stat attribute and
+ # uses st_blocks units of 512 bytes, and if the filesystem is able to
+ # store holes in files.
+ if sys.platform == "linux2":
+ # Linux evidentially has 512 byte st_blocks units.
+ name = os.path.join(TEMPDIR, "sparse-test")
+ with open(name, "wb") as fobj:
+ fobj.seek(4096)
+ fobj.truncate()
+ s = os.stat(name)
+ os.remove(name)
+ return s.st_blocks == 0
+ else:
+ return False
class PaxReadTest(LongnameTest):
@@ -597,33 +743,38 @@ class PaxReadTest(LongnameTest):
def test_pax_global_headers(self):
tar = tarfile.open(tarname, encoding="iso8859-1")
-
- tarinfo = tar.getmember("pax/regtype1")
- self.assertEqual(tarinfo.uname, "foo")
- self.assertEqual(tarinfo.gname, "bar")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"ÄÖÜäöüß")
-
- tarinfo = tar.getmember("pax/regtype2")
- self.assertEqual(tarinfo.uname, "")
- self.assertEqual(tarinfo.gname, "bar")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"ÄÖÜäöüß")
-
- tarinfo = tar.getmember("pax/regtype3")
- self.assertEqual(tarinfo.uname, "tarfile")
- self.assertEqual(tarinfo.gname, "tarfile")
- self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), u"ÄÖÜäöüß")
+ try:
+ tarinfo = tar.getmember("pax/regtype1")
+ self.assertEqual(tarinfo.uname, "foo")
+ self.assertEqual(tarinfo.gname, "bar")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+
+ tarinfo = tar.getmember("pax/regtype2")
+ self.assertEqual(tarinfo.uname, "")
+ self.assertEqual(tarinfo.gname, "bar")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+
+ tarinfo = tar.getmember("pax/regtype3")
+ self.assertEqual(tarinfo.uname, "tarfile")
+ self.assertEqual(tarinfo.gname, "tarfile")
+ self.assertEqual(tarinfo.pax_headers.get("VENDOR.umlauts"), "\xc4\xd6\xdc\xe4\xf6\xfc\xdf")
+ finally:
+ tar.close()
def test_pax_number_fields(self):
# All following number fields are read from the pax header.
tar = tarfile.open(tarname, encoding="iso8859-1")
- tarinfo = tar.getmember("pax/regtype4")
- self.assertEqual(tarinfo.size, 7011)
- self.assertEqual(tarinfo.uid, 123)
- self.assertEqual(tarinfo.gid, 123)
- self.assertEqual(tarinfo.mtime, 1041808783.0)
- self.assertEqual(type(tarinfo.mtime), float)
- self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
- self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
+ try:
+ tarinfo = tar.getmember("pax/regtype4")
+ self.assertEqual(tarinfo.size, 7011)
+ self.assertEqual(tarinfo.uid, 123)
+ self.assertEqual(tarinfo.gid, 123)
+ self.assertEqual(tarinfo.mtime, 1041808783.0)
+ self.assertEqual(type(tarinfo.mtime), float)
+ self.assertEqual(float(tarinfo.pax_headers["atime"]), 1041808783.0)
+ self.assertEqual(float(tarinfo.pax_headers["ctime"]), 1041808783.0)
+ finally:
+ tar.close()
class WriteTestBase(unittest.TestCase):
@@ -631,7 +782,7 @@ class WriteTestBase(unittest.TestCase):
# in all possible mode combinations.
def test_fileobj_no_close(self):
- fobj = StringIO.StringIO()
+ fobj = io.BytesIO()
tar = tarfile.open(fileobj=fobj, mode=self.mode)
tar.addfile(tarfile.TarInfo("foo"))
tar.close()
@@ -649,52 +800,59 @@ class WriteTest(WriteTestBase):
# a trailing '\0'.
name = "0123456789" * 10
tar = tarfile.open(tmpname, self.mode)
- t = tarfile.TarInfo(name)
- tar.addfile(t)
- tar.close()
+ try:
+ t = tarfile.TarInfo(name)
+ tar.addfile(t)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- self.assertTrue(tar.getnames()[0] == name,
- "failed to store 100 char filename")
- tar.close()
+ try:
+ self.assertTrue(tar.getnames()[0] == name,
+ "failed to store 100 char filename")
+ finally:
+ tar.close()
def test_tar_size(self):
# Test for bug #1013882.
tar = tarfile.open(tmpname, self.mode)
- path = os.path.join(TEMPDIR, "file")
- fobj = open(path, "wb")
- fobj.write("aaa")
- fobj.close()
- tar.add(path)
- tar.close()
+ try:
+ path = os.path.join(TEMPDIR, "file")
+ with open(path, "wb") as fobj:
+ fobj.write(b"aaa")
+ tar.add(path)
+ finally:
+ tar.close()
self.assertTrue(os.path.getsize(tmpname) > 0,
"tarfile is empty")
# The test_*_size tests test for bug #1167128.
def test_file_size(self):
tar = tarfile.open(tmpname, self.mode)
+ try:
+ path = os.path.join(TEMPDIR, "file")
+ with open(path, "wb"):
+ pass
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
- path = os.path.join(TEMPDIR, "file")
- fobj = open(path, "wb")
- fobj.close()
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 0)
-
- fobj = open(path, "wb")
- fobj.write("aaa")
- fobj.close()
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 3)
-
- tar.close()
+ with open(path, "wb") as fobj:
+ fobj.write(b"aaa")
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 3)
+ finally:
+ tar.close()
def test_directory_size(self):
path = os.path.join(TEMPDIR, "directory")
os.mkdir(path)
try:
tar = tarfile.open(tmpname, self.mode)
- tarinfo = tar.gettarinfo(path)
- self.assertEqual(tarinfo.size, 0)
+ try:
+ tarinfo = tar.gettarinfo(path)
+ self.assertEqual(tarinfo.size, 0)
+ finally:
+ tar.close()
finally:
os.rmdir(path)
@@ -702,46 +860,52 @@ class WriteTest(WriteTestBase):
if hasattr(os, "link"):
link = os.path.join(TEMPDIR, "link")
target = os.path.join(TEMPDIR, "link_target")
- fobj = open(target, "wb")
- fobj.write("aaa")
- fobj.close()
+ with open(target, "wb") as fobj:
+ fobj.write(b"aaa")
os.link(target, link)
try:
tar = tarfile.open(tmpname, self.mode)
- # Record the link target in the inodes list.
- tar.gettarinfo(target)
- tarinfo = tar.gettarinfo(link)
- self.assertEqual(tarinfo.size, 0)
+ try:
+ # Record the link target in the inodes list.
+ tar.gettarinfo(target)
+ tarinfo = tar.gettarinfo(link)
+ self.assertEqual(tarinfo.size, 0)
+ finally:
+ tar.close()
finally:
os.remove(target)
os.remove(link)
+ @support.skip_unless_symlink
def test_symlink_size(self):
- if hasattr(os, "symlink"):
- path = os.path.join(TEMPDIR, "symlink")
- os.symlink("link_target", path)
+ path = os.path.join(TEMPDIR, "symlink")
+ os.symlink("link_target", path)
+ try:
+ tar = tarfile.open(tmpname, self.mode)
try:
- tar = tarfile.open(tmpname, self.mode)
tarinfo = tar.gettarinfo(path)
self.assertEqual(tarinfo.size, 0)
finally:
- os.remove(path)
+ tar.close()
+ finally:
+ os.remove(path)
def test_add_self(self):
# Test for #1257255.
dstname = os.path.abspath(tmpname)
-
tar = tarfile.open(tmpname, self.mode)
- self.assertTrue(tar.name == dstname, "archive name must be absolute")
-
- tar.add(dstname)
- self.assertTrue(tar.getnames() == [], "added the archive to itself")
+ try:
+ self.assertTrue(tar.name == dstname, "archive name must be absolute")
+ tar.add(dstname)
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
- cwd = os.getcwd()
- os.chdir(TEMPDIR)
- tar.add(dstname)
- os.chdir(cwd)
- self.assertTrue(tar.getnames() == [], "added the archive to itself")
+ cwd = os.getcwd()
+ os.chdir(TEMPDIR)
+ tar.add(dstname)
+ os.chdir(cwd)
+ self.assertTrue(tar.getnames() == [], "added the archive to itself")
+ finally:
+ tar.close()
def test_exclude(self):
tempdir = os.path.join(TEMPDIR, "exclude")
@@ -754,14 +918,19 @@ class WriteTest(WriteTestBase):
exclude = os.path.isfile
tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
- with test_support.check_warnings(("use the filter argument",
- DeprecationWarning)):
- tar.add(tempdir, arcname="empty_dir", exclude=exclude)
- tar.close()
+ 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")
- self.assertEqual(len(tar.getmembers()), 1)
- self.assertEqual(tar.getnames()[0], "empty_dir")
+ try:
+ self.assertEqual(len(tar.getmembers()), 1)
+ self.assertEqual(tar.getnames()[0], "empty_dir")
+ finally:
+ tar.close()
finally:
shutil.rmtree(tempdir)
@@ -781,15 +950,23 @@ class WriteTest(WriteTestBase):
return tarinfo
tar = tarfile.open(tmpname, self.mode, encoding="iso8859-1")
- tar.add(tempdir, arcname="empty_dir", filter=filter)
- tar.close()
+ try:
+ tar.add(tempdir, arcname="empty_dir", filter=filter)
+ finally:
+ tar.close()
+
+ # Verify that filter is a keyword-only argument
+ with self.assertRaises(TypeError):
+ tar.add(tempdir, "empty_dir", True, None, filter)
tar = tarfile.open(tmpname, "r")
- for tarinfo in tar:
- self.assertEqual(tarinfo.uid, 123)
- self.assertEqual(tarinfo.uname, "foo")
- self.assertEqual(len(tar.getmembers()), 3)
- tar.close()
+ try:
+ for tarinfo in tar:
+ self.assertEqual(tarinfo.uid, 123)
+ self.assertEqual(tarinfo.uname, "foo")
+ self.assertEqual(len(tar.getmembers()), 3)
+ finally:
+ tar.close()
finally:
shutil.rmtree(tempdir)
@@ -807,12 +984,16 @@ class WriteTest(WriteTestBase):
os.mkdir(foo)
tar = tarfile.open(tmpname, self.mode)
- tar.add(foo, arcname=path)
- tar.close()
+ try:
+ tar.add(foo, arcname=path)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, "r")
- t = tar.next()
- tar.close()
+ try:
+ t = tar.next()
+ finally:
+ tar.close()
if not dir:
os.remove(foo)
@@ -821,6 +1002,36 @@ class WriteTest(WriteTestBase):
self.assertEqual(t.name, cmp_path or path.replace(os.sep, "/"))
+
+ @support.skip_unless_symlink
+ def test_extractall_symlinks(self):
+ # Test if extractall works properly when tarfile contains symlinks
+ tempdir = os.path.join(TEMPDIR, "testsymlinks")
+ temparchive = os.path.join(TEMPDIR, "testsymlinks.tar")
+ os.mkdir(tempdir)
+ try:
+ source_file = os.path.join(tempdir,'source')
+ target_file = os.path.join(tempdir,'symlink')
+ with open(source_file,'w') as f:
+ f.write('something\n')
+ os.symlink(source_file, target_file)
+ tar = tarfile.open(temparchive,'w')
+ tar.add(source_file)
+ tar.add(target_file)
+ tar.close()
+ # Let's extract it to the location which contains the symlink
+ tar = tarfile.open(temparchive,'r')
+ # this should not raise OSError: [Errno 17] File exists
+ try:
+ tar.extractall(path=tempdir)
+ except OSError:
+ self.fail("extractall failed with symlinked files")
+ finally:
+ tar.close()
+ finally:
+ os.unlink(temparchive)
+ shutil.rmtree(tempdir)
+
def test_pathnames(self):
self._test_pathname("foo")
self._test_pathname(os.path.join("foo", ".", "bar"))
@@ -850,107 +1061,21 @@ class WriteTest(WriteTestBase):
cwd = os.getcwd()
os.chdir(TEMPDIR)
try:
- open("foo", "w").close()
-
tar = tarfile.open(tmpname, self.mode)
- tar.add(".")
- tar.close()
-
- tar = tarfile.open(tmpname, "r")
- for t in tar:
- self.assertTrue(t.name == "." or t.name.startswith("./"))
- tar.close()
- finally:
- os.chdir(cwd)
-
- @unittest.skipUnless(hasattr(os, 'symlink'), "needs os.symlink")
- def test_extractall_symlinks(self):
- # Test if extractall works properly when tarfile contains symlinks
- tempdir = os.path.join(TEMPDIR, "testsymlinks")
- temparchive = os.path.join(TEMPDIR, "testsymlinks.tar")
- os.mkdir(tempdir)
- try:
- source_file = os.path.join(tempdir,'source')
- target_file = os.path.join(tempdir,'symlink')
- with open(source_file,'w') as f:
- f.write('something\n')
- os.symlink(source_file, target_file)
- tar = tarfile.open(temparchive,'w')
- tar.add(source_file, arcname=os.path.basename(source_file))
- tar.add(target_file, arcname=os.path.basename(target_file))
- tar.close()
- # Let's extract it to the location which contains the symlink
- tar = tarfile.open(temparchive,'r')
- # this should not raise OSError: [Errno 17] File exists
try:
- tar.extractall(path=tempdir)
- except OSError:
- self.fail("extractall failed with symlinked files")
+ tar.add(".")
finally:
tar.close()
- finally:
- os.unlink(temparchive)
- shutil.rmtree(tempdir)
- @unittest.skipUnless(hasattr(os, 'symlink'), "needs os.symlink")
- def test_extractall_broken_symlinks(self):
- # Test if extractall works properly when tarfile contains broken
- # symlinks
- tempdir = os.path.join(TEMPDIR, "testsymlinks")
- temparchive = os.path.join(TEMPDIR, "testsymlinks.tar")
- os.mkdir(tempdir)
- try:
- source_file = os.path.join(tempdir,'source')
- target_file = os.path.join(tempdir,'symlink')
- with open(source_file,'w') as f:
- f.write('something\n')
- os.symlink(source_file, target_file)
- tar = tarfile.open(temparchive,'w')
- tar.add(target_file, arcname=os.path.basename(target_file))
- tar.close()
- # remove the real file
- os.unlink(source_file)
- # Let's extract it to the location which contains the symlink
- tar = tarfile.open(temparchive,'r')
- # this should not raise OSError: [Errno 17] File exists
+ tar = tarfile.open(tmpname, "r")
try:
- tar.extractall(path=tempdir)
- except OSError:
- self.fail("extractall failed with broken symlinked files")
+ for t in tar:
+ self.assertTrue(t.name == "." or t.name.startswith("./"))
finally:
tar.close()
finally:
- os.unlink(temparchive)
- shutil.rmtree(tempdir)
+ os.chdir(cwd)
- @unittest.skipUnless(hasattr(os, 'link'), "needs os.link")
- def test_extractall_hardlinks(self):
- # Test if extractall works properly when tarfile contains symlinks
- tempdir = os.path.join(TEMPDIR, "testsymlinks")
- temparchive = os.path.join(TEMPDIR, "testsymlinks.tar")
- os.mkdir(tempdir)
- try:
- source_file = os.path.join(tempdir,'source')
- target_file = os.path.join(tempdir,'symlink')
- with open(source_file,'w') as f:
- f.write('something\n')
- os.link(source_file, target_file)
- tar = tarfile.open(temparchive,'w')
- tar.add(source_file, arcname=os.path.basename(source_file))
- tar.add(target_file, arcname=os.path.basename(target_file))
- tar.close()
- # Let's extract it to the location which contains the symlink
- tar = tarfile.open(temparchive,'r')
- # this should not raise OSError: [Errno 17] File exists
- try:
- tar.extractall(path=tempdir)
- except OSError:
- self.fail("extractall failed with linked files")
- finally:
- tar.close()
- finally:
- os.unlink(temparchive)
- shutil.rmtree(tempdir)
class StreamWriteTest(WriteTestBase):
@@ -962,21 +1087,20 @@ class StreamWriteTest(WriteTestBase):
tar.close()
if self.mode.endswith("gz"):
- fobj = gzip.GzipFile(tmpname)
- data = fobj.read()
- fobj.close()
+ with gzip.GzipFile(tmpname) as fobj:
+ data = fobj.read()
elif self.mode.endswith("bz2"):
dec = bz2.BZ2Decompressor()
- data = open(tmpname, "rb").read()
+ with open(tmpname, "rb") as fobj:
+ data = fobj.read()
data = dec.decompress(data)
self.assertTrue(len(dec.unused_data) == 0,
"found trailing data")
else:
- fobj = open(tmpname, "rb")
- data = fobj.read()
- fobj.close()
+ with open(tmpname, "rb") as fobj:
+ data = fobj.read()
- self.assertTrue(data.count("\0") == tarfile.RECORDSIZE,
+ self.assertTrue(data.count(b"\0") == tarfile.RECORDSIZE,
"incorrect zero padding")
def test_file_mode(self):
@@ -988,22 +1112,15 @@ class StreamWriteTest(WriteTestBase):
if os.path.exists(tmpname):
os.remove(tmpname)
- original_umask = os.umask(0022)
+ original_umask = os.umask(0o022)
try:
tar = tarfile.open(tmpname, self.mode)
tar.close()
- mode = os.stat(tmpname).st_mode & 0777
- self.assertEqual(mode, 0644, "wrong file permissions")
+ mode = os.stat(tmpname).st_mode & 0o777
+ self.assertEqual(mode, 0o644, "wrong file permissions")
finally:
os.umask(original_umask)
- def test_issue13639(self):
- try:
- with tarfile.open(unicode(tmpname, sys.getfilesystemencoding()), self.mode):
- pass
- except UnicodeDecodeError:
- self.fail("_Stream failed to write unicode filename")
-
class GNUWriteTest(unittest.TestCase):
# This testcase checks for correct creation of GNU Longname
@@ -1036,23 +1153,27 @@ class GNUWriteTest(unittest.TestCase):
tarinfo.type = tarfile.LNKTYPE
tar = tarfile.open(tmpname, "w")
- tar.format = tarfile.GNU_FORMAT
- tar.addfile(tarinfo)
-
- v1 = self._calc_size(name, link)
- v2 = tar.offset
- self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")
+ try:
+ tar.format = tarfile.GNU_FORMAT
+ tar.addfile(tarinfo)
- tar.close()
+ v1 = self._calc_size(name, link)
+ v2 = tar.offset
+ self.assertTrue(v1 == v2, "GNU longname/longlink creation failed")
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- member = tar.next()
- self.assertIsNotNone(member,
- "unable to read longname member")
- self.assertEqual(tarinfo.name, member.name,
- "unable to read longname member")
- self.assertEqual(tarinfo.linkname, member.linkname,
- "unable to read longname member")
+ try:
+ member = tar.next()
+ self.assertIsNotNone(member,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.name, member.name,
+ "unable to read longname member")
+ self.assertEqual(tarinfo.linkname, member.linkname,
+ "unable to read longname member")
+ finally:
+ tar.close()
def test_longname_1023(self):
self._test(("longnam/" * 127) + "longnam")
@@ -1092,9 +1213,8 @@ class HardlinkTest(unittest.TestCase):
self.foo = os.path.join(TEMPDIR, "foo")
self.bar = os.path.join(TEMPDIR, "bar")
- fobj = open(self.foo, "wb")
- fobj.write("foo")
- fobj.close()
+ with open(self.foo, "wb") as fobj:
+ fobj.write(b"foo")
os.link(self.foo, self.bar)
@@ -1103,8 +1223,8 @@ class HardlinkTest(unittest.TestCase):
def tearDown(self):
self.tar.close()
- os.remove(self.foo)
- os.remove(self.bar)
+ support.unlink(self.foo)
+ support.unlink(self.bar)
def test_add_twice(self):
# The same name will be added as a REGTYPE every
@@ -1135,67 +1255,80 @@ class PaxWriteTest(GNUWriteTest):
tarinfo.type = tarfile.LNKTYPE
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT)
- tar.addfile(tarinfo)
- tar.close()
+ try:
+ tar.addfile(tarinfo)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname)
- if link:
- l = tar.getmembers()[0].linkname
- self.assertTrue(link == l, "PAX longlink creation failed")
- else:
- n = tar.getmembers()[0].name
- self.assertTrue(name == n, "PAX longname creation failed")
+ try:
+ if link:
+ l = tar.getmembers()[0].linkname
+ self.assertTrue(link == l, "PAX longlink creation failed")
+ else:
+ n = tar.getmembers()[0].name
+ self.assertTrue(name == n, "PAX longname creation failed")
+ finally:
+ tar.close()
def test_pax_global_header(self):
pax_headers = {
- u"foo": u"bar",
- u"uid": u"0",
- u"mtime": u"1.23",
- u"test": u"äöü",
- u"äöü": u"test"}
+ "foo": "bar",
+ "uid": "0",
+ "mtime": "1.23",
+ "test": "\xe4\xf6\xfc",
+ "\xe4\xf6\xfc": "test"}
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT,
pax_headers=pax_headers)
- tar.addfile(tarfile.TarInfo("test"))
- tar.close()
+ try:
+ tar.addfile(tarfile.TarInfo("test"))
+ finally:
+ tar.close()
# Test if the global header was written correctly.
tar = tarfile.open(tmpname, encoding="iso8859-1")
- self.assertEqual(tar.pax_headers, pax_headers)
- self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
-
- # Test if all the fields are unicode.
- for key, val in tar.pax_headers.iteritems():
- self.assertTrue(type(key) is unicode)
- self.assertTrue(type(val) is unicode)
- if key in tarfile.PAX_NUMBER_FIELDS:
- try:
- tarfile.PAX_NUMBER_FIELDS[key](val)
- except (TypeError, ValueError):
- self.fail("unable to convert pax header field")
+ try:
+ self.assertEqual(tar.pax_headers, pax_headers)
+ self.assertEqual(tar.getmembers()[0].pax_headers, pax_headers)
+ # Test if all the fields are strings.
+ for key, val in tar.pax_headers.items():
+ self.assertTrue(type(key) is not bytes)
+ self.assertTrue(type(val) is not bytes)
+ if key in tarfile.PAX_NUMBER_FIELDS:
+ try:
+ tarfile.PAX_NUMBER_FIELDS[key](val)
+ except (TypeError, ValueError):
+ self.fail("unable to convert pax header field")
+ finally:
+ tar.close()
def test_pax_extended_header(self):
# The fields from the pax header have priority over the
# TarInfo.
- pax_headers = {u"path": u"foo", u"uid": u"123"}
+ pax_headers = {"path": "foo", "uid": "123"}
tar = tarfile.open(tmpname, "w", format=tarfile.PAX_FORMAT, encoding="iso8859-1")
- t = tarfile.TarInfo()
- t.name = u"äöü" # non-ASCII
- t.uid = 8**8 # too large
- t.pax_headers = pax_headers
- tar.addfile(t)
- tar.close()
+ try:
+ t = tarfile.TarInfo()
+ t.name = "\xe4\xf6\xfc" # non-ASCII
+ t.uid = 8**8 # too large
+ t.pax_headers = pax_headers
+ tar.addfile(t)
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, encoding="iso8859-1")
- t = tar.getmembers()[0]
- self.assertEqual(t.pax_headers, pax_headers)
- self.assertEqual(t.name, "foo")
- self.assertEqual(t.uid, 123)
+ try:
+ t = tar.getmembers()[0]
+ self.assertEqual(t.pax_headers, pax_headers)
+ self.assertEqual(t.name, "foo")
+ self.assertEqual(t.uid, 123)
+ finally:
+ tar.close()
class UstarUnicodeTest(unittest.TestCase):
- # All *UnicodeTests FIXME
format = tarfile.USTAR_FORMAT
@@ -1210,97 +1343,103 @@ class UstarUnicodeTest(unittest.TestCase):
def _test_unicode_filename(self, encoding):
tar = tarfile.open(tmpname, "w", format=self.format, encoding=encoding, errors="strict")
- name = u"äöü"
- tar.addfile(tarfile.TarInfo(name))
- tar.close()
+ try:
+ name = "\xe4\xf6\xfc"
+ tar.addfile(tarfile.TarInfo(name))
+ finally:
+ tar.close()
tar = tarfile.open(tmpname, encoding=encoding)
- self.assertTrue(type(tar.getnames()[0]) is not unicode)
- self.assertEqual(tar.getmembers()[0].name, name.encode(encoding))
- tar.close()
+ try:
+ self.assertEqual(tar.getmembers()[0].name, name)
+ finally:
+ tar.close()
def test_unicode_filename_error(self):
+ if self.format == tarfile.PAX_FORMAT:
+ # PAX_FORMAT ignores encoding in write mode.
+ return
+
tar = tarfile.open(tmpname, "w", format=self.format, encoding="ascii", errors="strict")
- tarinfo = tarfile.TarInfo()
+ try:
+ tarinfo = tarfile.TarInfo()
- tarinfo.name = "äöü"
- if self.format == tarfile.PAX_FORMAT:
+ tarinfo.name = "\xe4\xf6\xfc"
self.assertRaises(UnicodeError, tar.addfile, tarinfo)
- else:
- tar.addfile(tarinfo)
- tarinfo.name = u"äöü"
- self.assertRaises(UnicodeError, tar.addfile, tarinfo)
-
- tarinfo.name = "foo"
- tarinfo.uname = u"äöü"
- self.assertRaises(UnicodeError, tar.addfile, tarinfo)
+ tarinfo.name = "foo"
+ tarinfo.uname = "\xe4\xf6\xfc"
+ self.assertRaises(UnicodeError, tar.addfile, tarinfo)
+ finally:
+ tar.close()
def test_unicode_argument(self):
tar = tarfile.open(tarname, "r", encoding="iso8859-1", errors="strict")
- for t in tar:
- self.assertTrue(type(t.name) is str)
- self.assertTrue(type(t.linkname) is str)
- self.assertTrue(type(t.uname) is str)
- self.assertTrue(type(t.gname) is str)
- tar.close()
+ try:
+ for t in tar:
+ self.assertTrue(type(t.name) is str)
+ self.assertTrue(type(t.linkname) is str)
+ self.assertTrue(type(t.uname) is str)
+ self.assertTrue(type(t.gname) is str)
+ finally:
+ tar.close()
def test_uname_unicode(self):
- for name in (u"äöü", "äöü"):
- t = tarfile.TarInfo("foo")
- t.uname = name
- t.gname = name
+ t = tarfile.TarInfo("foo")
+ t.uname = "\xe4\xf6\xfc"
+ t.gname = "\xe4\xf6\xfc"
- fobj = StringIO.StringIO()
- tar = tarfile.open("foo.tar", mode="w", fileobj=fobj, format=self.format, encoding="iso8859-1")
+ tar = tarfile.open(tmpname, mode="w", format=self.format, encoding="iso8859-1")
+ try:
tar.addfile(t)
+ finally:
tar.close()
- fobj.seek(0)
- tar = tarfile.open("foo.tar", fileobj=fobj, encoding="iso8859-1")
+ tar = tarfile.open(tmpname, encoding="iso8859-1")
+ try:
t = tar.getmember("foo")
- self.assertEqual(t.uname, "äöü")
- self.assertEqual(t.gname, "äöü")
+ self.assertEqual(t.uname, "\xe4\xf6\xfc")
+ self.assertEqual(t.gname, "\xe4\xf6\xfc")
+
+ if self.format != tarfile.PAX_FORMAT:
+ tar.close()
+ tar = tarfile.open(tmpname, encoding="ascii")
+ t = tar.getmember("foo")
+ self.assertEqual(t.uname, "\udce4\udcf6\udcfc")
+ self.assertEqual(t.gname, "\udce4\udcf6\udcfc")
+ finally:
+ tar.close()
class GNUUnicodeTest(UstarUnicodeTest):
format = tarfile.GNU_FORMAT
+ def test_bad_pax_header(self):
+ # Test for issue #8633. GNU tar <= 1.23 creates raw binary fields
+ # without a hdrcharset=BINARY header.
+ for encoding, name in (("utf8", "pax/bad-pax-\udce4\udcf6\udcfc"),
+ ("iso8859-1", "pax/bad-pax-\xe4\xf6\xfc"),):
+ with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+ try:
+ t = tar.getmember(name)
+ except KeyError:
+ self.fail("unable to read bad GNU tar pax header")
-class PaxUnicodeTest(UstarUnicodeTest):
-
- format = tarfile.PAX_FORMAT
-
- def _create_unicode_name(self, name):
- tar = tarfile.open(tmpname, "w", format=self.format)
- t = tarfile.TarInfo()
- t.pax_headers["path"] = name
- tar.addfile(t)
- tar.close()
-
- def test_error_handlers(self):
- # Test if the unicode error handlers work correctly for characters
- # that cannot be expressed in a given encoding.
- self._create_unicode_name(u"äöü")
-
- for handler, name in (("utf-8", u"äöü".encode("utf8")),
- ("replace", "???"), ("ignore", "")):
- tar = tarfile.open(tmpname, format=self.format, encoding="ascii",
- errors=handler)
- self.assertEqual(tar.getnames()[0], name)
- self.assertRaises(UnicodeError, tarfile.open, tmpname,
- encoding="ascii", errors="strict")
+class PAXUnicodeTest(UstarUnicodeTest):
- def test_error_handler_utf8(self):
- # Create a pathname that has one component representable using
- # iso8859-1 and the other only in iso8859-15.
- self._create_unicode_name(u"äöü/¤")
+ format = tarfile.PAX_FORMAT
- tar = tarfile.open(tmpname, format=self.format, encoding="iso8859-1",
- errors="utf-8")
- self.assertEqual(tar.getnames()[0], "äöü/" + u"¤".encode("utf8"))
+ def test_binary_header(self):
+ # Test a POSIX.1-2008 compatible header with a hdrcharset=BINARY field.
+ for encoding, name in (("utf8", "pax/hdrcharset-\udce4\udcf6\udcfc"),
+ ("iso8859-1", "pax/hdrcharset-\xe4\xf6\xfc"),):
+ with tarfile.open(tarname, encoding=encoding, errors="surrogateescape") as tar:
+ try:
+ t = tar.getmember(name)
+ except KeyError:
+ self.fail("unable to read POSIX.1-2008 binary header")
class AppendTest(unittest.TestCase):
@@ -1312,22 +1451,23 @@ class AppendTest(unittest.TestCase):
os.remove(self.tarname)
def _add_testfile(self, fileobj=None):
- tar = tarfile.open(self.tarname, "a", fileobj=fileobj)
- tar.addfile(tarfile.TarInfo("bar"))
- tar.close()
+ with tarfile.open(self.tarname, "a", fileobj=fileobj) as tar:
+ tar.addfile(tarfile.TarInfo("bar"))
def _create_testtar(self, mode="w:"):
- src = tarfile.open(tarname, encoding="iso8859-1")
- t = src.getmember("ustar/regtype")
- t.name = "foo"
- f = src.extractfile(t)
- tar = tarfile.open(self.tarname, mode)
- tar.addfile(t, f)
- tar.close()
+ with tarfile.open(tarname, encoding="iso8859-1") as src:
+ t = src.getmember("ustar/regtype")
+ t.name = "foo"
+ f = src.extractfile(t)
+ try:
+ with tarfile.open(self.tarname, mode) as tar:
+ tar.addfile(t, f)
+ finally:
+ f.close()
def _test(self, names=["bar"], fileobj=None):
- tar = tarfile.open(self.tarname, fileobj=fileobj)
- self.assertEqual(tar.getnames(), names)
+ with tarfile.open(self.tarname, fileobj=fileobj) as tar:
+ self.assertEqual(tar.getnames(), names)
def test_non_existing(self):
self._add_testfile()
@@ -1339,15 +1479,16 @@ class AppendTest(unittest.TestCase):
self._test()
def test_empty_fileobj(self):
- fobj = StringIO.StringIO("\0" * 1024)
+ fobj = io.BytesIO(b"\0" * 1024)
self._add_testfile(fobj)
fobj.seek(0)
self._test(fileobj=fobj)
def test_fileobj(self):
self._create_testtar()
- data = open(self.tarname).read()
- fobj = StringIO.StringIO(data)
+ with open(self.tarname, "rb") as fobj:
+ data = fobj.read()
+ fobj = io.BytesIO(data)
self._add_testfile(fobj)
fobj.seek(0)
self._test(names=["foo", "bar"], fileobj=fobj)
@@ -1372,14 +1513,15 @@ class AppendTest(unittest.TestCase):
# Append mode is supposed to fail if the tarfile to append to
# does not end with a zero block.
def _test_error(self, data):
- open(self.tarname, "wb").write(data)
+ with open(self.tarname, "wb") as fobj:
+ fobj.write(data)
self.assertRaises(tarfile.ReadError, self._add_testfile)
def test_null(self):
- self._test_error("")
+ self._test_error(b"")
def test_incomplete(self):
- self._test_error("\0" * 13)
+ self._test_error(b"\0" * 13)
def test_premature_eof(self):
data = tarfile.TarInfo("foo").tobuf()
@@ -1387,10 +1529,10 @@ class AppendTest(unittest.TestCase):
def test_trailing_garbage(self):
data = tarfile.TarInfo("foo").tobuf()
- self._test_error(data + "\0" * 13)
+ self._test_error(data + b"\0" * 13)
def test_invalid(self):
- self._test_error("a" * 512)
+ self._test_error(b"a" * 512)
class LimitsTest(unittest.TestCase):
@@ -1423,7 +1565,7 @@ class LimitsTest(unittest.TestCase):
# uid > 8 digits
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 010000000
+ tarinfo.uid = 0o10000000
self.assertRaises(ValueError, tarinfo.tobuf, tarfile.USTAR_FORMAT)
def test_gnu_limits(self):
@@ -1436,7 +1578,7 @@ class LimitsTest(unittest.TestCase):
# uid >= 256 ** 7
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 04000000000000000000L
+ tarinfo.uid = 0o4000000000000000000
self.assertRaises(ValueError, tarinfo.tobuf, tarfile.GNU_FORMAT)
def test_pax_limits(self):
@@ -1448,10 +1590,45 @@ class LimitsTest(unittest.TestCase):
tarinfo.tobuf(tarfile.PAX_FORMAT)
tarinfo = tarfile.TarInfo("name")
- tarinfo.uid = 04000000000000000000L
+ tarinfo.uid = 0o4000000000000000000
tarinfo.tobuf(tarfile.PAX_FORMAT)
+class MiscTest(unittest.TestCase):
+
+ def test_char_fields(self):
+ self.assertEqual(tarfile.stn("foo", 8, "ascii", "strict"), b"foo\0\0\0\0\0")
+ self.assertEqual(tarfile.stn("foobar", 3, "ascii", "strict"), b"foo")
+ self.assertEqual(tarfile.nts(b"foo\0\0\0\0\0", "ascii", "strict"), "foo")
+ self.assertEqual(tarfile.nts(b"foo\0bar\0", "ascii", "strict"), "foo")
+
+ def test_read_number_fields(self):
+ # Issue 13158: Test if GNU tar specific base-256 number fields
+ # are decoded correctly.
+ self.assertEqual(tarfile.nti(b"0000001\x00"), 1)
+ self.assertEqual(tarfile.nti(b"7777777\x00"), 0o7777777)
+ self.assertEqual(tarfile.nti(b"\x80\x00\x00\x00\x00\x20\x00\x00"), 0o10000000)
+ self.assertEqual(tarfile.nti(b"\x80\x00\x00\x00\xff\xff\xff\xff"), 0xffffffff)
+ self.assertEqual(tarfile.nti(b"\xff\xff\xff\xff\xff\xff\xff\xff"), -1)
+ self.assertEqual(tarfile.nti(b"\xff\xff\xff\xff\xff\xff\xff\x9c"), -100)
+ self.assertEqual(tarfile.nti(b"\xff\x00\x00\x00\x00\x00\x00\x00"), -0x100000000000000)
+
+ def test_write_number_fields(self):
+ self.assertEqual(tarfile.itn(1), b"0000001\x00")
+ self.assertEqual(tarfile.itn(0o7777777), b"7777777\x00")
+ self.assertEqual(tarfile.itn(0o10000000), b"\x80\x00\x00\x00\x00\x20\x00\x00")
+ self.assertEqual(tarfile.itn(0xffffffff), b"\x80\x00\x00\x00\xff\xff\xff\xff")
+ self.assertEqual(tarfile.itn(-1), b"\xff\xff\xff\xff\xff\xff\xff\xff")
+ self.assertEqual(tarfile.itn(-100), b"\xff\xff\xff\xff\xff\xff\xff\x9c")
+ self.assertEqual(tarfile.itn(-0x100000000000000), b"\xff\x00\x00\x00\x00\x00\x00\x00")
+
+ def test_number_field_limits(self):
+ self.assertRaises(ValueError, tarfile.itn, -1, 8, tarfile.USTAR_FORMAT)
+ self.assertRaises(ValueError, tarfile.itn, 0o10000000, 8, tarfile.USTAR_FORMAT)
+ self.assertRaises(ValueError, tarfile.itn, -0x10000000001, 6, tarfile.GNU_FORMAT)
+ self.assertRaises(ValueError, tarfile.itn, 0x10000000000, 6, tarfile.GNU_FORMAT)
+
+
class ContextManagerTest(unittest.TestCase):
def test_basic(self):
@@ -1500,15 +1677,14 @@ class ContextManagerTest(unittest.TestCase):
def test_fileobj(self):
# Test that __exit__() did not close the external file
# object.
- fobj = open(tmpname, "wb")
- try:
- with tarfile.open(fileobj=fobj, mode="w") as tar:
- raise Exception
- except:
- pass
- self.assertFalse(fobj.closed, "external file object was closed")
- self.assertTrue(tar.closed, "context manager failed")
- fobj.close()
+ with open(tmpname, "wb") as fobj:
+ try:
+ with tarfile.open(fileobj=fobj, mode="w") as tar:
+ raise Exception
+ except:
+ pass
+ self.assertFalse(fobj.closed, "external file object was closed")
+ self.assertTrue(tar.closed, "context manager failed")
class LinkEmulationTest(ReadTest):
@@ -1521,15 +1697,26 @@ class LinkEmulationTest(ReadTest):
data = open(os.path.join(TEMPDIR, name), "rb").read()
self.assertEqual(md5sum(data), md5_regtype)
+ # When 8879 gets fixed, this will need to change. Currently on Windows
+ # we have os.path.islink but no os.link, so these tests fail without the
+ # following skip until link is completed.
+ @unittest.skipIf(hasattr(os.path, "islink"),
+ "Skip emulation - has os.path.islink but not os.link")
def test_hardlink_extraction1(self):
self._test_link_extraction("ustar/lnktype")
+ @unittest.skipIf(hasattr(os.path, "islink"),
+ "Skip emulation - has os.path.islink but not os.link")
def test_hardlink_extraction2(self):
self._test_link_extraction("./ustar/linktest2/lnktype")
+ @unittest.skipIf(hasattr(os, "symlink"),
+ "Skip emulation if symlink exists")
def test_symlink_extraction1(self):
self._test_link_extraction("ustar/symtype")
+ @unittest.skipIf(hasattr(os, "symlink"),
+ "Skip emulation if symlink exists")
def test_symlink_extraction2(self):
self._test_link_extraction("./ustar/linktest2/symtype")
@@ -1537,6 +1724,14 @@ class LinkEmulationTest(ReadTest):
class GzipMiscReadTest(MiscReadTest):
tarname = gzipname
mode = "r:gz"
+
+ def test_non_existent_targz_file(self):
+ # Test for issue11513: prevent non-existent gzipped tarfiles raising
+ # multiple exceptions.
+ with self.assertRaisesRegex(IOError, "xxx") as ex:
+ tarfile.open("xxx", self.mode)
+ self.assertEqual(ex.exception.errno, errno.ENOENT)
+
class GzipUstarReadTest(UstarReadTest):
tarname = gzipname
mode = "r:gz"
@@ -1568,21 +1763,21 @@ class Bz2PartialReadTest(unittest.TestCase):
# on an empty or partial bzipped file.
def _test_partial_input(self, mode):
- class MyStringIO(StringIO.StringIO):
+ class MyBytesIO(io.BytesIO):
hit_eof = False
def read(self, n):
if self.hit_eof:
raise AssertionError("infinite loop detected in tarfile.open()")
- self.hit_eof = self.pos == self.len
- return StringIO.StringIO.read(self, n)
+ self.hit_eof = self.tell() == len(self.getvalue())
+ return super(MyBytesIO, self).read(n)
def seek(self, *args):
self.hit_eof = False
- return StringIO.StringIO.seek(self, *args)
+ return super(MyBytesIO, self).seek(*args)
data = bz2.compress(tarfile.TarInfo("foo").tobuf())
for x in range(len(data) + 1):
try:
- tarfile.open(fileobj=MyStringIO(data[:x]), mode=mode)
+ tarfile.open(fileobj=MyBytesIO(data[:x]), mode=mode)
except tarfile.ReadError:
pass # we have no interest in ReadErrors
@@ -1594,6 +1789,7 @@ class Bz2PartialReadTest(unittest.TestCase):
def test_main():
+ support.unlink(TEMPDIR)
os.makedirs(TEMPDIR)
tests = [
@@ -1610,9 +1806,10 @@ def test_main():
PaxWriteTest,
UstarUnicodeTest,
GNUUnicodeTest,
- PaxUnicodeTest,
+ PAXUnicodeTest,
AppendTest,
LimitsTest,
+ MiscTest,
ContextManagerTest,
]
@@ -1621,15 +1818,14 @@ def test_main():
else:
tests.append(LinkEmulationTest)
- fobj = open(tarname, "rb")
- data = fobj.read()
- fobj.close()
+ with open(tarname, "rb") as fobj:
+ data = fobj.read()
if gzip:
# Create testtar.tar.gz and add gzip-specific tests.
- tar = gzip.open(gzipname, "wb")
- tar.write(data)
- tar.close()
+ support.unlink(gzipname)
+ with gzip.open(gzipname, "wb") as tar:
+ tar.write(data)
tests += [
GzipMiscReadTest,
@@ -1641,9 +1837,9 @@ def test_main():
if bz2:
# Create testtar.tar.bz2 and add bz2-specific tests.
- tar = bz2.BZ2File(bz2name, "wb")
- tar.write(data)
- tar.close()
+ support.unlink(bz2name)
+ with bz2.BZ2File(bz2name, "wb") as tar:
+ tar.write(data)
tests += [
Bz2MiscReadTest,
@@ -1655,7 +1851,7 @@ def test_main():
]
try:
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
finally:
if os.path.exists(TEMPDIR):
shutil.rmtree(TEMPDIR)
diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py
index e8ba58fdd6c..d86246cbfb7 100644
--- a/Lib/test/test_tcl.py
+++ b/Lib/test/test_tcl.py
@@ -1,13 +1,14 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
+import sys
import os
-from test import test_support
+from test import support
# Skip this test if the _tkinter module wasn't built.
-_tkinter = test_support.import_module('_tkinter')
+_tkinter = support.import_module('_tkinter')
-from Tkinter import Tcl
+from tkinter import Tcl
from _tkinter import TclError
@@ -119,7 +120,7 @@ class TclTest(unittest.TestCase):
filename = "doesnotexists"
try:
os.remove(filename)
- except Exception,e:
+ except Exception as e:
pass
self.assertRaises(TclError,tcl.evalfile,filename)
@@ -127,34 +128,33 @@ class TclTest(unittest.TestCase):
tcl = self.interp
self.assertRaises(TclError,tcl.eval,'package require DNE')
+ @unittest.skipUnless(sys.platform == 'win32', 'Requires Windows')
def testLoadWithUNC(self):
- import sys
- if sys.platform != 'win32':
- return
-
# Build a UNC path from the regular path.
# Something like
# \\%COMPUTERNAME%\c$\python27\python.exe
fullname = os.path.abspath(sys.executable)
if fullname[1] != ':':
- return
+ raise unittest.SkipTest('Absolute path should have drive part')
unc_name = r'\\%s\%s$\%s' % (os.environ['COMPUTERNAME'],
fullname[0],
fullname[3:])
+ if not os.path.exists(unc_name):
+ raise unittest.SkipTest('Cannot connect to UNC Path')
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env.unset("TCL_LIBRARY")
- f = os.popen('%s -c "import Tkinter; print Tkinter"' % (unc_name,))
+ f = os.popen('%s -c "import tkinter; print(tkinter)"' % (unc_name,))
- self.assertTrue('Tkinter.py' in f.read())
+ self.assertIn('tkinter', f.read())
# exit code must be zero
self.assertEqual(f.close(), None)
def test_main():
- test_support.run_unittest(TclTest, TkinterTest)
+ support.run_unittest(TclTest, TkinterTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_telnetlib.py b/Lib/test/test_telnetlib.py
index 7fdb49e8e62..95eebf3cbc4 100644
--- a/Lib/test/test_telnetlib.py
+++ b/Lib/test/test_telnetlib.py
@@ -1,39 +1,21 @@
import socket
+import select
import telnetlib
import time
-import Queue
+import contextlib
import unittest
from unittest import TestCase
-from test import test_support
-threading = test_support.import_module('threading')
-
-HOST = test_support.HOST
-EOF_sigil = object()
-
-def server(evt, serv, dataq=None):
- """ Open a tcp server in three steps
- 1) set evt to true to let the parent know we are ready
- 2) [optional] if is not False, write the list of data from dataq.get()
- to the socket.
- """
+from test import support
+threading = support.import_module('threading')
+
+HOST = support.HOST
+
+def server(evt, serv):
serv.listen(5)
evt.set()
try:
conn, addr = serv.accept()
- if dataq:
- data = ''
- new_data = dataq.get(True, 0.5)
- dataq.task_done()
- for item in new_data:
- if item == EOF_sigil:
- break
- if type(item) in [int, float]:
- time.sleep(item)
- else:
- data += item
- written = conn.send(data)
- data = data[written:]
conn.close()
except socket.timeout:
pass
@@ -46,7 +28,7 @@ class GeneralTests(TestCase):
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(60) # Safety net. Look issue 11812
- self.port = test_support.bind_port(self.sock)
+ self.port = support.bind_port(self.sock)
self.thread = threading.Thread(target=server, args=(self.evt,self.sock))
self.thread.setDaemon(True)
self.thread.start()
@@ -92,184 +74,217 @@ class GeneralTests(TestCase):
self.assertEqual(telnet.sock.gettimeout(), 30)
telnet.sock.close()
-def _read_setUp(self):
- self.evt = threading.Event()
- self.dataq = Queue.Queue()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(10)
- self.port = test_support.bind_port(self.sock)
- self.thread = threading.Thread(target=server, args=(self.evt,self.sock, self.dataq))
- self.thread.start()
- self.evt.wait()
-
-def _read_tearDown(self):
- self.thread.join()
-
-class ReadTests(TestCase):
- setUp = _read_setUp
- tearDown = _read_tearDown
-
- # use a similar approach to testing timeouts as test_timeout.py
- # these will never pass 100% but make the fuzz big enough that it is rare
- block_long = 0.6
- block_short = 0.3
- def test_read_until_A(self):
+class SocketStub(object):
+ ''' a socket proxy that re-defines sendall() '''
+ def __init__(self, reads=()):
+ self.reads = list(reads) # Intentionally make a copy.
+ self.writes = []
+ self.block = False
+ def sendall(self, data):
+ self.writes.append(data)
+ def recv(self, size):
+ out = b''
+ while self.reads and len(out) < size:
+ out += self.reads.pop(0)
+ if len(out) > size:
+ self.reads.insert(0, out[size:])
+ out = out[:size]
+ return out
+
+class TelnetAlike(telnetlib.Telnet):
+ def fileno(self):
+ raise NotImplementedError()
+ def close(self): pass
+ def sock_avail(self):
+ return (not self.sock.block)
+ def msg(self, msg, *args):
+ with support.captured_stdout() as out:
+ telnetlib.Telnet.msg(self, msg, *args)
+ self._messages += out.getvalue()
+ return
+
+def mock_select(*s_args):
+ block = False
+ for l in s_args:
+ for fob in l:
+ if isinstance(fob, TelnetAlike):
+ block = fob.sock.block
+ if block:
+ return [[], [], []]
+ else:
+ return s_args
+
+class MockPoller(object):
+ test_case = None # Set during TestCase setUp.
+
+ def __init__(self):
+ self._file_objs = []
+
+ def register(self, fd, eventmask):
+ self.test_case.assertTrue(hasattr(fd, 'fileno'), fd)
+ self.test_case.assertEqual(eventmask, select.POLLIN|select.POLLPRI)
+ self._file_objs.append(fd)
+
+ def poll(self, timeout=None):
+ block = False
+ for fob in self._file_objs:
+ if isinstance(fob, TelnetAlike):
+ block = fob.sock.block
+ if block:
+ return []
+ else:
+ return zip(self._file_objs, [select.POLLIN]*len(self._file_objs))
+
+ def unregister(self, fd):
+ self._file_objs.remove(fd)
+
+@contextlib.contextmanager
+def test_socket(reads):
+ def new_conn(*ignored):
+ return SocketStub(reads)
+ try:
+ old_conn = socket.create_connection
+ socket.create_connection = new_conn
+ yield None
+ finally:
+ socket.create_connection = old_conn
+ return
+
+def test_telnet(reads=(), cls=TelnetAlike, use_poll=None):
+ ''' return a telnetlib.Telnet object that uses a SocketStub with
+ reads queued up to be read '''
+ for x in reads:
+ assert type(x) is bytes, x
+ with test_socket(reads):
+ telnet = cls('dummy', 0)
+ telnet._messages = '' # debuglevel output
+ if use_poll is not None:
+ if use_poll and not telnet._has_poll:
+ raise unittest.SkipTest('select.poll() required.')
+ telnet._has_poll = use_poll
+ return telnet
+
+
+class ExpectAndReadTestCase(TestCase):
+ def setUp(self):
+ self.old_select = select.select
+ select.select = mock_select
+ self.old_poll = False
+ if hasattr(select, 'poll'):
+ self.old_poll = select.poll
+ select.poll = MockPoller
+ MockPoller.test_case = self
+
+ def tearDown(self):
+ if self.old_poll:
+ MockPoller.test_case = None
+ select.poll = self.old_poll
+ select.select = self.old_select
+
+
+class ReadTests(ExpectAndReadTestCase):
+ def test_read_until(self):
"""
- read_until(expected, [timeout])
- Read until the expected string has been seen, or a timeout is
- hit (default is no timeout); may block.
+ read_until(expected, timeout=None)
+ test the blocking version of read_util
"""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- data = telnet.read_until('match')
- self.assertEqual(data, ''.join(want[:-2]))
-
- def test_read_until_B(self):
- # test the timeout - it does NOT raise socket.timeout
- want = ['hello', self.block_long, 'not seen', EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- data = telnet.read_until('not seen', self.block_short)
- self.assertEqual(data, want[0])
- self.assertEqual(telnet.read_all(), 'not seen')
+ want = [b'xxxmatchyyy']
+ telnet = test_telnet(want)
+ data = telnet.read_until(b'match')
+ self.assertEqual(data, b'xxxmatch', msg=(telnet.cookedq, telnet.rawq, telnet.sock.reads))
+
+ reads = [b'x' * 50, b'match', b'y' * 50]
+ expect = b''.join(reads[:-1])
+ telnet = test_telnet(reads)
+ data = telnet.read_until(b'match')
+ self.assertEqual(data, expect)
def test_read_until_with_poll(self):
"""Use select.poll() to implement telnet.read_until()."""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- if not telnet._has_poll:
- raise unittest.SkipTest('select.poll() is required')
- telnet._has_poll = True
- self.dataq.join()
- data = telnet.read_until('match')
- self.assertEqual(data, ''.join(want[:-2]))
+ want = [b'x' * 10, b'match', b'y' * 10]
+ telnet = test_telnet(want, use_poll=True)
+ select.select = lambda *_: self.fail('unexpected select() call.')
+ data = telnet.read_until(b'match')
+ self.assertEqual(data, b''.join(want[:-1]))
def test_read_until_with_select(self):
"""Use select.select() to implement telnet.read_until()."""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- telnet._has_poll = False
- self.dataq.join()
- data = telnet.read_until('match')
- self.assertEqual(data, ''.join(want[:-2]))
-
- def test_read_all_A(self):
+ want = [b'x' * 10, b'match', b'y' * 10]
+ telnet = test_telnet(want, use_poll=False)
+ if self.old_poll:
+ select.poll = lambda *_: self.fail('unexpected poll() call.')
+ data = telnet.read_until(b'match')
+ self.assertEqual(data, b''.join(want[:-1]))
+
+ def test_read_all(self):
"""
read_all()
Read all data until EOF; may block.
"""
- want = ['x' * 500, 'y' * 500, 'z' * 500, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
+ reads = [b'x' * 500, b'y' * 500, b'z' * 500]
+ expect = b''.join(reads)
+ telnet = test_telnet(reads)
data = telnet.read_all()
- self.assertEqual(data, ''.join(want[:-1]))
+ self.assertEqual(data, expect)
return
- def _test_blocking(self, func):
- self.dataq.put([self.block_long, EOF_sigil])
- self.dataq.join()
- start = time.time()
- data = func()
- self.assertTrue(self.block_short <= time.time() - start)
-
- def test_read_all_B(self):
- self._test_blocking(telnetlib.Telnet(HOST, self.port).read_all)
-
- def test_read_all_C(self):
- self.dataq.put([EOF_sigil])
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- telnet.read_all()
- telnet.read_all() # shouldn't raise
-
- def test_read_some_A(self):
+ def test_read_some(self):
"""
read_some()
Read at least one byte or EOF; may block.
"""
# test 'at least one byte'
- want = ['x' * 500, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- data = telnet.read_all()
+ telnet = test_telnet([b'x' * 500])
+ data = telnet.read_some()
self.assertTrue(len(data) >= 1)
-
- def test_read_some_B(self):
# test EOF
- self.dataq.put([EOF_sigil])
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- self.assertEqual('', telnet.read_some())
-
- def test_read_some_C(self):
- self._test_blocking(telnetlib.Telnet(HOST, self.port).read_some)
+ telnet = test_telnet()
+ data = telnet.read_some()
+ self.assertEqual(b'', data)
- def _test_read_any_eager_A(self, func_name):
+ def _read_eager(self, func_name):
"""
- read_very_eager()
+ read_*_eager()
Read all data available already queued or on the socket,
without blocking.
"""
- want = [self.block_long, 'x' * 100, 'y' * 100, EOF_sigil]
- expects = want[1] + want[2]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
+ want = b'x' * 100
+ telnet = test_telnet([want])
func = getattr(telnet, func_name)
- data = ''
+ telnet.sock.block = True
+ self.assertEqual(b'', func())
+ telnet.sock.block = False
+ data = b''
while True:
try:
data += func()
- self.assertTrue(expects.startswith(data))
except EOFError:
break
- self.assertEqual(expects, data)
-
- def _test_read_any_eager_B(self, func_name):
- # test EOF
- self.dataq.put([EOF_sigil])
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- time.sleep(self.block_short)
- func = getattr(telnet, func_name)
- self.assertRaises(EOFError, func)
-
- # read_eager and read_very_eager make the same gaurantees
- # (they behave differently but we only test the gaurantees)
- def test_read_very_eager_A(self):
- self._test_read_any_eager_A('read_very_eager')
- def test_read_very_eager_B(self):
- self._test_read_any_eager_B('read_very_eager')
- def test_read_eager_A(self):
- self._test_read_any_eager_A('read_eager')
- def test_read_eager_B(self):
- self._test_read_any_eager_B('read_eager')
- # NB -- we need to test the IAC block which is mentioned in the docstring
- # but not in the module docs
-
- def _test_read_any_lazy_B(self, func_name):
- self.dataq.put([EOF_sigil])
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- func = getattr(telnet, func_name)
- telnet.fill_rawq()
- self.assertRaises(EOFError, func)
-
- def test_read_lazy_A(self):
- want = ['x' * 100, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- time.sleep(self.block_short)
- self.assertEqual('', telnet.read_lazy())
- data = ''
+ self.assertEqual(data, want)
+
+ def test_read_eager(self):
+ # read_eager and read_very_eager make the same gaurantees
+ # (they behave differently but we only test the gaurantees)
+ self._read_eager('read_eager')
+ self._read_eager('read_very_eager')
+ # NB -- we need to test the IAC block which is mentioned in the
+ # docstring but not in the module docs
+
+ def read_very_lazy(self):
+ want = b'x' * 100
+ telnet = test_telnet([want])
+ self.assertEqual(b'', telnet.read_very_lazy())
+ while telnet.sock.reads:
+ telnet.fill_rawq()
+ data = telnet.read_very_lazy()
+ self.assertEqual(want, data)
+ self.assertRaises(EOFError, telnet.read_very_lazy)
+
+ def test_read_lazy(self):
+ want = b'x' * 100
+ telnet = test_telnet([want])
+ self.assertEqual(b'', telnet.read_lazy())
+ data = b''
while True:
try:
read_data = telnet.read_lazy()
@@ -278,41 +293,14 @@ class ReadTests(TestCase):
telnet.fill_rawq()
except EOFError:
break
- self.assertTrue(want[0].startswith(data))
- self.assertEqual(data, want[0])
-
- def test_read_lazy_B(self):
- self._test_read_any_lazy_B('read_lazy')
-
- def test_read_very_lazy_A(self):
- want = ['x' * 100, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- time.sleep(self.block_short)
- self.assertEqual('', telnet.read_very_lazy())
- data = ''
- while True:
- try:
- read_data = telnet.read_very_lazy()
- except EOFError:
- break
- data += read_data
- if not read_data:
- telnet.fill_rawq()
- self.assertEqual('', telnet.cookedq)
- telnet.process_rawq()
- self.assertTrue(want[0].startswith(data))
- self.assertEqual(data, want[0])
-
- def test_read_very_lazy_B(self):
- self._test_read_any_lazy_B('read_very_lazy')
+ self.assertTrue(want.startswith(data))
+ self.assertEqual(data, want)
class nego_collector(object):
def __init__(self, sb_getter=None):
- self.seen = ''
+ self.seen = b''
self.sb_getter = sb_getter
- self.sb_seen = ''
+ self.sb_seen = b''
def do_nego(self, sock, cmd, opt):
self.seen += cmd + opt
@@ -321,134 +309,136 @@ class nego_collector(object):
self.sb_seen += sb_data
tl = telnetlib
+
+class WriteTests(TestCase):
+ '''The only thing that write does is replace each tl.IAC for
+ tl.IAC+tl.IAC'''
+
+ def test_write(self):
+ data_sample = [b'data sample without IAC',
+ b'data sample with' + tl.IAC + b' one IAC',
+ b'a few' + tl.IAC + tl.IAC + b' iacs' + tl.IAC,
+ tl.IAC,
+ b'']
+ for data in data_sample:
+ telnet = test_telnet()
+ telnet.write(data)
+ written = b''.join(telnet.sock.writes)
+ self.assertEqual(data.replace(tl.IAC,tl.IAC+tl.IAC), written)
+
class OptionTests(TestCase):
- setUp = _read_setUp
- tearDown = _read_tearDown
# RFC 854 commands
cmds = [tl.AO, tl.AYT, tl.BRK, tl.EC, tl.EL, tl.GA, tl.IP, tl.NOP]
def _test_command(self, data):
""" helper for testing IAC + cmd """
- self.setUp()
- self.dataq.put(data)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
+ telnet = test_telnet(data)
+ data_len = len(b''.join(data))
nego = nego_collector()
telnet.set_option_negotiation_callback(nego.do_nego)
txt = telnet.read_all()
cmd = nego.seen
self.assertTrue(len(cmd) > 0) # we expect at least one command
- self.assertIn(cmd[0], self.cmds)
- self.assertEqual(cmd[1], tl.NOOPT)
- self.assertEqual(len(''.join(data[:-1])), len(txt + cmd))
+ self.assertIn(cmd[:1], self.cmds)
+ self.assertEqual(cmd[1:2], tl.NOOPT)
+ self.assertEqual(data_len, len(txt + cmd))
nego.sb_getter = None # break the nego => telnet cycle
- self.tearDown()
def test_IAC_commands(self):
- # reset our setup
- self.dataq.put([EOF_sigil])
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- self.tearDown()
-
for cmd in self.cmds:
- self._test_command(['x' * 100, tl.IAC + cmd, 'y'*100, EOF_sigil])
- self._test_command(['x' * 10, tl.IAC + cmd, 'y'*10, EOF_sigil])
- self._test_command([tl.IAC + cmd, EOF_sigil])
+ self._test_command([tl.IAC, cmd])
+ self._test_command([b'x' * 100, tl.IAC, cmd, b'y'*100])
+ self._test_command([b'x' * 10, tl.IAC, cmd, b'y'*10])
# all at once
- self._test_command([tl.IAC + cmd for (cmd) in self.cmds] + [EOF_sigil])
- self.assertEqual('', telnet.read_sb_data())
+ self._test_command([tl.IAC + cmd for (cmd) in self.cmds])
def test_SB_commands(self):
# RFC 855, subnegotiations portion
send = [tl.IAC + tl.SB + tl.IAC + tl.SE,
tl.IAC + tl.SB + tl.IAC + tl.IAC + tl.IAC + tl.SE,
- tl.IAC + tl.SB + tl.IAC + tl.IAC + 'aa' + tl.IAC + tl.SE,
- tl.IAC + tl.SB + 'bb' + tl.IAC + tl.IAC + tl.IAC + tl.SE,
- tl.IAC + tl.SB + 'cc' + tl.IAC + tl.IAC + 'dd' + tl.IAC + tl.SE,
- EOF_sigil,
+ tl.IAC + tl.SB + tl.IAC + tl.IAC + b'aa' + tl.IAC + tl.SE,
+ tl.IAC + tl.SB + b'bb' + tl.IAC + tl.IAC + tl.IAC + tl.SE,
+ tl.IAC + tl.SB + b'cc' + tl.IAC + tl.IAC + b'dd' + tl.IAC + tl.SE,
]
- self.dataq.put(send)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
+ telnet = test_telnet(send)
nego = nego_collector(telnet.read_sb_data)
telnet.set_option_negotiation_callback(nego.do_nego)
txt = telnet.read_all()
- self.assertEqual(txt, '')
- want_sb_data = tl.IAC + tl.IAC + 'aabb' + tl.IAC + 'cc' + tl.IAC + 'dd'
+ self.assertEqual(txt, b'')
+ want_sb_data = tl.IAC + tl.IAC + b'aabb' + tl.IAC + b'cc' + tl.IAC + b'dd'
self.assertEqual(nego.sb_seen, want_sb_data)
- self.assertEqual('', telnet.read_sb_data())
+ self.assertEqual(b'', telnet.read_sb_data())
nego.sb_getter = None # break the nego => telnet cycle
+ def test_debuglevel_reads(self):
+ # test all the various places that self.msg(...) is called
+ given_a_expect_b = [
+ # Telnet.fill_rawq
+ (b'a', ": recv b''\n"),
+ # Telnet.process_rawq
+ (tl.IAC + bytes([88]), ": IAC 88 not recognized\n"),
+ (tl.IAC + tl.DO + bytes([1]), ": IAC DO 1\n"),
+ (tl.IAC + tl.DONT + bytes([1]), ": IAC DONT 1\n"),
+ (tl.IAC + tl.WILL + bytes([1]), ": IAC WILL 1\n"),
+ (tl.IAC + tl.WONT + bytes([1]), ": IAC WONT 1\n"),
+ ]
+ for a, b in given_a_expect_b:
+ telnet = test_telnet([a])
+ telnet.set_debuglevel(1)
+ txt = telnet.read_all()
+ self.assertIn(b, telnet._messages)
+ return
-class ExpectTests(TestCase):
- def setUp(self):
- self.evt = threading.Event()
- self.dataq = Queue.Queue()
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- self.sock.settimeout(10)
- self.port = test_support.bind_port(self.sock)
- self.thread = threading.Thread(target=server, args=(self.evt,self.sock,
- self.dataq))
- self.thread.start()
- self.evt.wait()
-
- def tearDown(self):
- self.thread.join()
-
- # use a similar approach to testing timeouts as test_timeout.py
- # these will never pass 100% but make the fuzz big enough that it is rare
- block_long = 0.6
- block_short = 0.3
- def test_expect_A(self):
+ def test_debuglevel_write(self):
+ telnet = test_telnet()
+ telnet.set_debuglevel(1)
+ telnet.write(b'xxx')
+ expected = "send b'xxx'\n"
+ self.assertIn(expected, telnet._messages)
+
+ def test_debug_accepts_str_port(self):
+ # Issue 10695
+ with test_socket([]):
+ telnet = TelnetAlike('dummy', '0')
+ telnet._messages = ''
+ telnet.set_debuglevel(1)
+ telnet.msg('test')
+ self.assertRegex(telnet._messages, r'0.*test')
+
+
+class ExpectTests(ExpectAndReadTestCase):
+ def test_expect(self):
"""
expect(expected, [timeout])
Read until the expected string has been seen, or a timeout is
hit (default is no timeout); may block.
"""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- (_,_,data) = telnet.expect(['match'])
- self.assertEqual(data, ''.join(want[:-2]))
-
- def test_expect_B(self):
- # test the timeout - it does NOT raise socket.timeout
- want = ['hello', self.block_long, 'not seen', EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- self.dataq.join()
- (_,_,data) = telnet.expect(['not seen'], self.block_short)
- self.assertEqual(data, want[0])
- self.assertEqual(telnet.read_all(), 'not seen')
+ want = [b'x' * 10, b'match', b'y' * 10]
+ telnet = test_telnet(want)
+ (_,_,data) = telnet.expect([b'match'])
+ self.assertEqual(data, b''.join(want[:-1]))
def test_expect_with_poll(self):
"""Use select.poll() to implement telnet.expect()."""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- if not telnet._has_poll:
- raise unittest.SkipTest('select.poll() is required')
- telnet._has_poll = True
- self.dataq.join()
- (_,_,data) = telnet.expect(['match'])
- self.assertEqual(data, ''.join(want[:-2]))
+ want = [b'x' * 10, b'match', b'y' * 10]
+ telnet = test_telnet(want, use_poll=True)
+ select.select = lambda *_: self.fail('unexpected select() call.')
+ (_,_,data) = telnet.expect([b'match'])
+ self.assertEqual(data, b''.join(want[:-1]))
def test_expect_with_select(self):
"""Use select.select() to implement telnet.expect()."""
- want = ['x' * 10, 'match', 'y' * 10, EOF_sigil]
- self.dataq.put(want)
- telnet = telnetlib.Telnet(HOST, self.port)
- telnet._has_poll = False
- self.dataq.join()
- (_,_,data) = telnet.expect(['match'])
- self.assertEqual(data, ''.join(want[:-2]))
+ want = [b'x' * 10, b'match', b'y' * 10]
+ telnet = test_telnet(want, use_poll=False)
+ if self.old_poll:
+ select.poll = lambda *_: self.fail('unexpected poll() call.')
+ (_,_,data) = telnet.expect([b'match'])
+ self.assertEqual(data, b''.join(want[:-1]))
def test_main(verbose=None):
- test_support.run_unittest(GeneralTests, ReadTests, OptionTests,
- ExpectTests)
+ support.run_unittest(GeneralTests, ReadTests, WriteTests, OptionTests,
+ ExpectTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 2ddc04cedae..50cf3b49cb8 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -7,11 +7,8 @@ import re
import warnings
import unittest
-from test import test_support
+from test import support
-warnings.filterwarnings("ignore",
- category=RuntimeWarning,
- message="mktemp", module=__name__)
if hasattr(os, 'stat'):
import stat
@@ -38,6 +35,16 @@ class TC(unittest.TestCase):
str_check = re.compile(r"[a-zA-Z0-9_-]{6}$")
+ def setUp(self):
+ self._warnings_manager = support.check_warnings()
+ self._warnings_manager.__enter__()
+ warnings.filterwarnings("ignore", category=RuntimeWarning,
+ message="mktemp", module=__name__)
+
+ def tearDown(self):
+ self._warnings_manager.__exit__(None, None, None)
+
+
def failOnException(self, what, ei=None):
if ei is None:
ei = sys.exc_info()
@@ -79,7 +86,8 @@ class test_exports(TC):
"gettempdir" : 1,
"tempdir" : 1,
"template" : 1,
- "SpooledTemporaryFile" : 1
+ "SpooledTemporaryFile" : 1,
+ "TemporaryDirectory" : 1,
}
unexp = []
@@ -97,10 +105,11 @@ class test__RandomNameSequence(TC):
def setUp(self):
self.r = tempfile._RandomNameSequence()
+ super().setUp()
def test_get_six_char_str(self):
# _RandomNameSequence returns a six-character string
- s = self.r.next()
+ s = next(self.r)
self.nameCheck(s, '', '', '')
def test_many(self):
@@ -108,13 +117,13 @@ class test__RandomNameSequence(TC):
dict = {}
r = self.r
- for i in xrange(TEST_FILES):
- s = r.next()
+ for i in range(TEST_FILES):
+ s = next(r)
self.nameCheck(s, '', '', '')
self.assertNotIn(s, dict)
dict[s] = 1
- def test_supports_iter(self):
+ def supports_iter(self):
# _RandomNameSequence supports the iterator protocol
i = 0
@@ -171,13 +180,13 @@ class test__candidate_tempdir_list(TC):
self.assertFalse(len(cand) == 0)
for c in cand:
- self.assertIsInstance(c, basestring)
+ self.assertIsInstance(c, str)
def test_wanted_dirs(self):
# _candidate_tempdir_list contains the expected directories
# Make sure the interesting environment variables are all set.
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
for envname in 'TMPDIR', 'TEMP', 'TMP':
dirname = os.getenv(envname)
if not dirname:
@@ -259,15 +268,15 @@ class test__mkstemp_inner(TC):
def test_basic(self):
# _mkstemp_inner can create files
- self.do_create().write("blat")
- self.do_create(pre="a").write("blat")
- self.do_create(suf="b").write("blat")
- self.do_create(pre="a", suf="b").write("blat")
- self.do_create(pre="aa", suf=".txt").write("blat")
+ self.do_create().write(b"blat")
+ self.do_create(pre="a").write(b"blat")
+ self.do_create(suf="b").write(b"blat")
+ self.do_create(pre="a", suf="b").write(b"blat")
+ self.do_create(pre="aa", suf=".txt").write(b"blat")
def test_basic_many(self):
# _mkstemp_inner can create many files (stochastic)
- extant = range(TEST_FILES)
+ extant = list(range(TEST_FILES))
for i in extant:
extant[i] = self.do_create(pre="aa")
@@ -275,7 +284,7 @@ class test__mkstemp_inner(TC):
# _mkstemp_inner can create files in a user-selected directory
dir = tempfile.mkdtemp()
try:
- self.do_create(dir=dir).write("blat")
+ self.do_create(dir=dir).write(b"blat")
finally:
os.rmdir(dir)
@@ -286,7 +295,7 @@ class test__mkstemp_inner(TC):
file = self.do_create()
mode = stat.S_IMODE(os.stat(file.name).st_mode)
- expected = 0600
+ expected = 0o600
if sys.platform in ('win32', 'os2emx'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
@@ -299,7 +308,7 @@ class test__mkstemp_inner(TC):
if not has_spawnl:
return # ugh, can't use SkipTest.
- if test_support.verbose:
+ if support.verbose:
v="v"
else:
v="q"
@@ -337,8 +346,12 @@ class test__mkstemp_inner(TC):
if not has_textmode:
return # ugh, can't use SkipTest.
- self.do_create(bin=0).write("blat\n")
- # XXX should test that the file really is a text file
+ # A text file is truncated at the first Ctrl+Z byte
+ f = self.do_create(bin=0)
+ f.write(b"blat\x1a")
+ f.write(b"extra\n")
+ os.lseek(f.fd, 0, os.SEEK_SET)
+ self.assertEqual(os.read(f.fd, 20), b"blat")
test_classes.append(test__mkstemp_inner)
@@ -350,7 +363,7 @@ class test_gettempprefix(TC):
# gettempprefix returns a nonempty prefix string
p = tempfile.gettempprefix()
- self.assertIsInstance(p, basestring)
+ self.assertIsInstance(p, str)
self.assertTrue(len(p) > 0)
def test_usable_template(self):
@@ -395,7 +408,7 @@ class test_gettempdir(TC):
# gettempdir.
try:
file = tempfile.NamedTemporaryFile()
- file.write("blat")
+ file.write(b"blat")
file.close()
except:
self.failOnException("create file in %s" % tempfile.gettempdir())
@@ -479,13 +492,13 @@ class test_mkdtemp(TC):
def test_basic_many(self):
# mkdtemp can create many directories (stochastic)
- extant = range(TEST_FILES)
+ extant = list(range(TEST_FILES))
try:
for i in extant:
extant[i] = self.do_create(pre="aa")
finally:
for i in extant:
- if(isinstance(i, basestring)):
+ if(isinstance(i, str)):
os.rmdir(i)
def test_choose_directory(self):
@@ -504,8 +517,8 @@ class test_mkdtemp(TC):
dir = self.do_create()
try:
mode = stat.S_IMODE(os.stat(dir).st_mode)
- mode &= 0777 # Mask off sticky bits inherited from /tmp
- expected = 0700
+ mode &= 0o777 # Mask off sticky bits inherited from /tmp
+ expected = 0o700
if sys.platform in ('win32', 'os2emx'):
# There's no distinction among 'user', 'group' and 'world';
# replicate the 'user' bits.
@@ -525,11 +538,13 @@ class test_mktemp(TC):
# We must also suppress the RuntimeWarning it generates.
def setUp(self):
self.dir = tempfile.mkdtemp()
+ super().setUp()
def tearDown(self):
if self.dir:
os.rmdir(self.dir)
self.dir = None
+ super().tearDown()
class mktemped:
_unlink = os.unlink
@@ -539,7 +554,7 @@ class test_mktemp(TC):
self.name = tempfile.mktemp(dir=dir, prefix=pre, suffix=suf)
# Create the file. This will raise an exception if it's
# mysteriously appeared in the meanwhile.
- os.close(os.open(self.name, self._bflags, 0600))
+ os.close(os.open(self.name, self._bflags, 0o600))
def __del__(self):
self._unlink(self.name)
@@ -563,7 +578,7 @@ class test_mktemp(TC):
def test_many(self):
# mktemp can choose many usable file names (stochastic)
- extant = range(TEST_FILES)
+ extant = list(range(TEST_FILES))
for i in extant:
extant[i] = self.do_create(pre="aa")
@@ -616,7 +631,7 @@ class test_NamedTemporaryFile(TC):
dir = tempfile.mkdtemp()
try:
f = tempfile.NamedTemporaryFile(dir=dir)
- f.write('blat')
+ f.write(b'blat')
f.close()
self.assertFalse(os.path.exists(f.name),
"NamedTemporaryFile %s exists after close" % f.name)
@@ -630,7 +645,7 @@ class test_NamedTemporaryFile(TC):
try:
f = tempfile.NamedTemporaryFile(dir=dir, delete=False)
tmp = f.name
- f.write('blat')
+ f.write(b'blat')
f.close()
self.assertTrue(os.path.exists(f.name),
"NamedTemporaryFile %s missing after close" % f.name)
@@ -642,7 +657,7 @@ class test_NamedTemporaryFile(TC):
def test_multiple_close(self):
# A NamedTemporaryFile can be closed many times without error
f = tempfile.NamedTemporaryFile()
- f.write('abc\n')
+ f.write(b'abc\n')
f.close()
try:
f.close()
@@ -691,11 +706,11 @@ class test_SpooledTemporaryFile(TC):
try:
f = tempfile.SpooledTemporaryFile(max_size=10, dir=dir)
self.assertFalse(f._rolled)
- f.write('blat ' * 5)
+ f.write(b'blat ' * 5)
self.assertTrue(f._rolled)
filename = f.name
f.close()
- self.assertFalse(os.path.exists(filename),
+ self.assertFalse(isinstance(filename, str) and os.path.exists(filename),
"SpooledTemporaryFile %s exists after close" % filename)
finally:
os.rmdir(dir)
@@ -706,7 +721,7 @@ class test_SpooledTemporaryFile(TC):
self.assertFalse(f._rolled)
for i in range(5):
f.seek(0, 0)
- f.write('x' * 20)
+ f.write(b'x' * 20)
self.assertFalse(f._rolled)
def test_write_sequential(self):
@@ -714,11 +729,11 @@ class test_SpooledTemporaryFile(TC):
# over afterward
f = self.do_create(max_size=30)
self.assertFalse(f._rolled)
- f.write('x' * 20)
+ f.write(b'x' * 20)
self.assertFalse(f._rolled)
- f.write('x' * 10)
+ f.write(b'x' * 10)
self.assertFalse(f._rolled)
- f.write('x')
+ f.write(b'x')
self.assertTrue(f._rolled)
def test_writelines(self):
@@ -745,7 +760,7 @@ class test_SpooledTemporaryFile(TC):
self.assertFalse(f._rolled)
f.seek(100, 0)
self.assertFalse(f._rolled)
- f.write('x')
+ f.write(b'x')
self.assertTrue(f._rolled)
def test_fileno(self):
@@ -758,7 +773,7 @@ class test_SpooledTemporaryFile(TC):
def test_multiple_close_before_rollover(self):
# A SpooledTemporaryFile can be closed many times without error
f = tempfile.SpooledTemporaryFile()
- f.write('abc\n')
+ f.write(b'abc\n')
self.assertFalse(f._rolled)
f.close()
try:
@@ -770,7 +785,7 @@ class test_SpooledTemporaryFile(TC):
def test_multiple_close_after_rollover(self):
# A SpooledTemporaryFile can be closed many times without error
f = tempfile.SpooledTemporaryFile(max_size=1)
- f.write('abc\n')
+ f.write(b'abc\n')
self.assertTrue(f._rolled)
f.close()
try:
@@ -788,10 +803,41 @@ class test_SpooledTemporaryFile(TC):
write = f.write
seek = f.seek
- write("a" * 35)
- write("b" * 35)
+ write(b"a" * 35)
+ write(b"b" * 35)
seek(0, 0)
- self.assertTrue(read(70) == 'a'*35 + 'b'*35)
+ self.assertEqual(read(70), b'a'*35 + b'b'*35)
+
+ def test_text_mode(self):
+ # Creating a SpooledTemporaryFile with a text mode should produce
+ # a file object reading and writing (Unicode) text strings.
+ f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10)
+ f.write("abc\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "abc\n")
+ f.write("def\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "abc\ndef\n")
+ f.write("xyzzy\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "abc\ndef\nxyzzy\n")
+ # Check that Ctrl+Z doesn't truncate the file
+ f.write("foo\x1abar\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "abc\ndef\nxyzzy\nfoo\x1abar\n")
+
+ def test_text_newline_and_encoding(self):
+ f = tempfile.SpooledTemporaryFile(mode='w+', max_size=10,
+ newline='', encoding='utf-8')
+ f.write("\u039B\r\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "\u039B\r\n")
+ self.assertFalse(f._rolled)
+
+ f.write("\u039B" * 20 + "\r\n")
+ f.seek(0)
+ self.assertEqual(f.read(), "\u039B\r\n" + ("\u039B" * 20) + "\r\n")
+ self.assertTrue(f._rolled)
def test_context_manager_before_rollover(self):
# A SpooledTemporaryFile can be used as a context manager
@@ -808,7 +854,7 @@ class test_SpooledTemporaryFile(TC):
# A SpooledTemporaryFile can be used as a context manager
with tempfile.SpooledTemporaryFile(max_size=1) as f:
self.assertFalse(f._rolled)
- f.write('abc\n')
+ f.write(b'abc\n')
f.flush()
self.assertTrue(f._rolled)
self.assertFalse(f.closed)
@@ -821,7 +867,7 @@ class test_SpooledTemporaryFile(TC):
def test_context_manager_after_rollover(self):
# A SpooledTemporaryFile can be used as a context manager
f = tempfile.SpooledTemporaryFile(max_size=1)
- f.write('abc\n')
+ f.write(b'abc\n')
f.flush()
self.assertTrue(f._rolled)
with f:
@@ -851,7 +897,7 @@ class test_TemporaryFile(TC):
# TemporaryFile creates files with no names (on this system)
dir = tempfile.mkdtemp()
f = tempfile.TemporaryFile(dir=dir)
- f.write('blat')
+ f.write(b'blat')
# Sneaky: because this file has no name, it should not prevent
# us from removing the directory it was created in.
@@ -867,7 +913,7 @@ class test_TemporaryFile(TC):
def test_multiple_close(self):
# A TemporaryFile can be closed many times without error
f = tempfile.TemporaryFile()
- f.write('abc\n')
+ f.write(b'abc\n')
f.close()
try:
f.close()
@@ -876,13 +922,192 @@ class test_TemporaryFile(TC):
self.failOnException("close")
# How to test the mode and bufsize parameters?
+ def test_mode_and_encoding(self):
+
+ def roundtrip(input, *args, **kwargs):
+ with tempfile.TemporaryFile(*args, **kwargs) as fileobj:
+ fileobj.write(input)
+ fileobj.seek(0)
+ self.assertEqual(input, fileobj.read())
+
+ roundtrip(b"1234", "w+b")
+ roundtrip("abdc\n", "w+")
+ roundtrip("\u039B", "w+", encoding="utf-16")
+ roundtrip("foo\r\n", "w+", newline="")
if tempfile.NamedTemporaryFile is not tempfile.TemporaryFile:
test_classes.append(test_TemporaryFile)
+
+# Helper for test_del_on_shutdown
+class NulledModules:
+ def __init__(self, *modules):
+ self.refs = [mod.__dict__ for mod in modules]
+ self.contents = [ref.copy() for ref in self.refs]
+
+ def __enter__(self):
+ for d in self.refs:
+ for key in d:
+ d[key] = None
+
+ def __exit__(self, *exc_info):
+ for d, c in zip(self.refs, self.contents):
+ d.clear()
+ d.update(c)
+
+class test_TemporaryDirectory(TC):
+ """Test TemporaryDirectory()."""
+
+ def do_create(self, dir=None, pre="", suf="", recurse=1):
+ if dir is None:
+ dir = tempfile.gettempdir()
+ try:
+ tmp = tempfile.TemporaryDirectory(dir=dir, prefix=pre, suffix=suf)
+ except:
+ self.failOnException("TemporaryDirectory")
+ self.nameCheck(tmp.name, dir, pre, suf)
+ # Create a subdirectory and some files
+ if recurse:
+ self.do_create(tmp.name, pre, suf, recurse-1)
+ with open(os.path.join(tmp.name, "test.txt"), "wb") as f:
+ f.write(b"Hello world!")
+ return tmp
+
+ def test_mkdtemp_failure(self):
+ # Check no additional exception if mkdtemp fails
+ # Previously would raise AttributeError instead
+ # (noted as part of Issue #10188)
+ with tempfile.TemporaryDirectory() as nonexistent:
+ pass
+ with self.assertRaises(os.error):
+ tempfile.TemporaryDirectory(dir=nonexistent)
+
+ def test_explicit_cleanup(self):
+ # A TemporaryDirectory is deleted when cleaned up
+ dir = tempfile.mkdtemp()
+ try:
+ d = self.do_create(dir=dir)
+ self.assertTrue(os.path.exists(d.name),
+ "TemporaryDirectory %s does not exist" % d.name)
+ d.cleanup()
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after cleanup" % d.name)
+ finally:
+ os.rmdir(dir)
+
+ @support.skip_unless_symlink
+ def test_cleanup_with_symlink_to_a_directory(self):
+ # cleanup() should not follow symlinks to directories (issue #12464)
+ d1 = self.do_create()
+ d2 = self.do_create()
+
+ # Symlink d1/foo -> d2
+ os.symlink(d2.name, os.path.join(d1.name, "foo"))
+
+ # This call to cleanup() should not follow the "foo" symlink
+ d1.cleanup()
+
+ self.assertFalse(os.path.exists(d1.name),
+ "TemporaryDirectory %s exists after cleanup" % d1.name)
+ self.assertTrue(os.path.exists(d2.name),
+ "Directory pointed to by a symlink was deleted")
+ self.assertEqual(os.listdir(d2.name), ['test.txt'],
+ "Contents of the directory pointed to by a symlink "
+ "were deleted")
+ d2.cleanup()
+
+ @support.cpython_only
+ def test_del_on_collection(self):
+ # A TemporaryDirectory is deleted when garbage collected
+ dir = tempfile.mkdtemp()
+ try:
+ d = self.do_create(dir=dir)
+ name = d.name
+ del d # Rely on refcounting to invoke __del__
+ self.assertFalse(os.path.exists(name),
+ "TemporaryDirectory %s exists after __del__" % name)
+ finally:
+ os.rmdir(dir)
+
+ @unittest.expectedFailure # See issue #10188
+ def test_del_on_shutdown(self):
+ # A TemporaryDirectory may be cleaned up during shutdown
+ # Make sure it works with the relevant modules nulled out
+ with self.do_create() as dir:
+ d = self.do_create(dir=dir)
+ # Mimic the nulling out of modules that
+ # occurs during system shutdown
+ modules = [os, os.path]
+ if has_stat:
+ modules.append(stat)
+ # Currently broken, so suppress the warning
+ # that is otherwise emitted on stdout
+ with support.captured_stderr() as err:
+ with NulledModules(*modules):
+ d.cleanup()
+ # Currently broken, so stop spurious exception by
+ # indicating the object has already been closed
+ d._closed = True
+ # And this assert will fail, as expected by the
+ # unittest decorator...
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after cleanup" % d.name)
+
+ def test_warnings_on_cleanup(self):
+ # Two kinds of warning on shutdown
+ # Issue 10888: may write to stderr if modules are nulled out
+ # ResourceWarning will be triggered by __del__
+ with self.do_create() as dir:
+ if os.sep != '\\':
+ # Embed a backslash in order to make sure string escaping
+ # in the displayed error message is dealt with correctly
+ suffix = '\\check_backslash_handling'
+ else:
+ suffix = ''
+ d = self.do_create(dir=dir, suf=suffix)
+
+ #Check for the Issue 10888 message
+ modules = [os, os.path]
+ if has_stat:
+ modules.append(stat)
+ with support.captured_stderr() as err:
+ with NulledModules(*modules):
+ d.cleanup()
+ message = err.getvalue().replace('\\\\', '\\')
+ self.assertIn("while cleaning up", message)
+ self.assertIn(d.name, message)
+
+ # Check for the resource warning
+ with support.check_warnings(('Implicitly', ResourceWarning), quiet=False):
+ warnings.filterwarnings("always", category=ResourceWarning)
+ d.__del__()
+ self.assertFalse(os.path.exists(d.name),
+ "TemporaryDirectory %s exists after __del__" % d.name)
+
+ def test_multiple_close(self):
+ # Can be cleaned-up many times without error
+ d = self.do_create()
+ d.cleanup()
+ try:
+ d.cleanup()
+ d.cleanup()
+ except:
+ self.failOnException("cleanup")
+
+ def test_context_manager(self):
+ # Can be used as a context manager
+ d = self.do_create()
+ with d as name:
+ self.assertTrue(os.path.exists(name))
+ self.assertEqual(name, d.name)
+ self.assertFalse(os.path.exists(name))
+
+
+test_classes.append(test_TemporaryDirectory)
+
def test_main():
- test_support.run_unittest(*test_classes)
+ support.run_unittest(*test_classes)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py
index 7b726723769..3901120c879 100644
--- a/Lib/test/test_textwrap.py
+++ b/Lib/test/test_textwrap.py
@@ -9,7 +9,7 @@
#
import unittest
-from test import test_support
+from test import support
from textwrap import TextWrapper, wrap, fill, dedent
@@ -22,8 +22,8 @@ class BaseTestCase(unittest.TestCase):
result = []
for i in range(len(textin)):
result.append(" %d: %r" % (i, textin[i]))
- result = '\n'.join(result)
- elif isinstance(textin, basestring):
+ result = "\n".join(result) if result else " no lines"
+ elif isinstance(textin, str):
result = " %s\n" % repr(textin)
return result
@@ -183,7 +183,7 @@ What a mess!
text = ("Python 1.0.0 was released on 1994-01-26. Python 1.0.1 was\n"
"released on 1994-02-15.")
- self.check_wrap(text, 35, ['Python 1.0.0 was released on',
+ self.check_wrap(text, 30, ['Python 1.0.0 was released on',
'1994-01-26. Python 1.0.1 was',
'released on 1994-02-15.'])
self.check_wrap(text, 40, ['Python 1.0.0 was released on 1994-01-26.',
@@ -388,28 +388,6 @@ What a mess!
self.check_wrap("abcd efgh", 6, [" abcd", " efgh"],
initial_indent=" ", subsequent_indent=" ")
- if test_support.have_unicode:
- def test_unicode(self):
- # *Very* simple test of wrapping Unicode strings. I'm sure
- # there's more to it than this, but let's at least make
- # sure textwrap doesn't crash on Unicode input!
- text = u"Hello there, how are you today?"
- self.check_wrap(text, 50, [u"Hello there, how are you today?"])
- self.check_wrap(text, 20, [u"Hello there, how are", "you today?"])
- olines = self.wrapper.wrap(text)
- self.assertIsInstance(olines, list)
- self.assertIsInstance(olines[0], unicode)
- otext = self.wrapper.fill(text)
- self.assertIsInstance(otext, unicode)
-
- def test_no_split_at_umlaut(self):
- text = u"Die Empf\xe4nger-Auswahl"
- self.check_wrap(text, 13, [u"Die", u"Empf\xe4nger-", u"Auswahl"])
-
- def test_umlaut_followed_by_dash(self):
- text = u"aa \xe4\xe4-\xe4\xe4"
- self.check_wrap(text, 7, [u"aa \xe4\xe4-", u"\xe4\xe4"])
-
def test_split(self):
# Ensure that the standard _split() method works as advertised
# in the comments
@@ -435,6 +413,14 @@ What a mess!
self.assertRaises(ValueError, wrap, text, 0)
self.assertRaises(ValueError, wrap, text, -1)
+ def test_no_split_at_umlaut(self):
+ text = "Die Empf\xe4nger-Auswahl"
+ self.check_wrap(text, 13, ["Die", "Empf\xe4nger-", "Auswahl"])
+
+ def test_umlaut_followed_by_dash(self):
+ text = "aa \xe4\xe4-\xe4\xe4"
+ self.check_wrap(text, 7, ["aa \xe4\xe4-", "\xe4\xe4"])
+
class LongWordTestCase (BaseTestCase):
def setUp(self):
@@ -649,7 +635,7 @@ def foo():
def test_main():
- test_support.run_unittest(WrapTestCase,
+ support.run_unittest(WrapTestCase,
LongWordTestCase,
IndentTestCases,
DedentTestCase)
diff --git a/Lib/test/test_thread.py b/Lib/test/test_thread.py
index 413889ad226..a191e157bc3 100644
--- a/Lib/test/test_thread.py
+++ b/Lib/test/test_thread.py
@@ -1,8 +1,8 @@
import os
import unittest
import random
-from test import test_support
-thread = test_support.import_module('thread')
+from test import support
+thread = support.import_module('_thread')
import time
import sys
import weakref
@@ -12,15 +12,13 @@ from test import lock_tests
NUMTASKS = 10
NUMTRIPS = 3
-
_print_mutex = thread.allocate_lock()
def verbose_print(arg):
"""Helper function for printing out debugging output."""
- if test_support.verbose:
+ if support.verbose:
with _print_mutex:
- print arg
-
+ print(arg)
class BasicThreadTest(unittest.TestCase):
@@ -143,7 +141,7 @@ class ThreadRunningTests(BasicThreadTest):
real_write(self, *args)
c = thread._count()
started = thread.allocate_lock()
- with test_support.captured_output("stderr") as stderr:
+ with support.captured_output("stderr") as stderr:
real_write = stderr.write
stderr.write = mywrite
started.acquire()
@@ -215,7 +213,6 @@ class BarrierTest(BasicThreadTest):
if finished:
self.done_mutex.release()
-
class LockTests(lock_tests.LockTests):
locktype = thread.allocate_lock
@@ -226,23 +223,25 @@ class TestForkInThread(unittest.TestCase):
@unittest.skipIf(sys.platform.startswith('win'),
"This test is only appropriate for POSIX-like systems.")
- @test_support.reap_threads
+ @support.reap_threads
def test_forkinthread(self):
def thread1():
try:
pid = os.fork() # fork in a thread
except RuntimeError:
- sys.exit(0) # exit the child
+ os._exit(1) # exit the child
if pid == 0: # child
- os.close(self.read_fd)
- os.write(self.write_fd, "OK")
- sys.exit(0)
+ try:
+ os.close(self.read_fd)
+ os.write(self.write_fd, b"OK")
+ finally:
+ os._exit(0)
else: # parent
os.close(self.write_fd)
thread.start_new_thread(thread1, ())
- self.assertEqual(os.read(self.read_fd, 2), "OK",
+ self.assertEqual(os.read(self.read_fd, 2), b"OK",
"Unable to fork() in thread")
def tearDown(self):
@@ -258,8 +257,8 @@ class TestForkInThread(unittest.TestCase):
def test_main():
- test_support.run_unittest(ThreadRunningTests, BarrierTest, LockTests,
- TestForkInThread)
+ support.run_unittest(ThreadRunningTests, BarrierTest, LockTests,
+ TestForkInThread)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index b31fdf1363a..7791935fdf1 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -5,72 +5,206 @@
# complains several times about module random having no attribute
# randrange, and then Python hangs.
+import os
+import imp
+import sys
+import time
+import shutil
import unittest
-from test.test_support import verbose, TestFailed, import_module
-thread = import_module('thread')
-
-critical_section = thread.allocate_lock()
-done = thread.allocate_lock()
-
-def task():
- global N, critical_section, done
- import random
- x = random.randrange(1, 3)
- critical_section.acquire()
- N -= 1
- # Must release critical_section before releasing done, else the main
- # thread can exit and set critical_section to None as part of global
- # teardown; then critical_section.release() raises AttributeError.
- finished = N == 0
- critical_section.release()
- if finished:
- done.release()
-
-def test_import_hangers():
- import sys
- if verbose:
- print "testing import hangers ...",
-
- import test.threaded_import_hangers
+from test.support import verbose, import_module, run_unittest, TESTFN
+thread = import_module('_thread')
+threading = import_module('threading')
+
+def task(N, done, done_tasks, errors):
try:
- if test.threaded_import_hangers.errors:
- raise TestFailed(test.threaded_import_hangers.errors)
- elif verbose:
- print "OK."
+ # We don't use modulefinder but still import it in order to stress
+ # importing of different modules from several threads.
+ if len(done_tasks) % 2:
+ import modulefinder
+ import random
+ else:
+ import random
+ import modulefinder
+ # This will fail if random is not completely initialized
+ x = random.randrange(1, 3)
+ except Exception as e:
+ errors.append(e.with_traceback(None))
finally:
+ done_tasks.append(thread.get_ident())
+ finished = len(done_tasks) == N
+ if finished:
+ done.set()
+
+# Create a circular import structure: A -> C -> B -> D -> A
+# NOTE: `time` is already loaded and therefore doesn't threaten to deadlock.
+
+circular_imports_modules = {
+ 'A': """if 1:
+ import time
+ time.sleep(%(delay)s)
+ x = 'a'
+ import C
+ """,
+ 'B': """if 1:
+ import time
+ time.sleep(%(delay)s)
+ x = 'b'
+ import D
+ """,
+ 'C': """import B""",
+ 'D': """import A""",
+}
+
+class Finder:
+ """A dummy finder to detect concurrent access to its find_module()
+ method."""
+
+ def __init__(self):
+ self.numcalls = 0
+ self.x = 0
+ self.lock = thread.allocate_lock()
+
+ def find_module(self, name, path=None):
+ # Simulate some thread-unsafe behaviour. If calls to find_module()
+ # are properly serialized, `x` will end up the same as `numcalls`.
+ # Otherwise not.
+ with self.lock:
+ self.numcalls += 1
+ x = self.x
+ time.sleep(0.1)
+ self.x = x + 1
+
+class FlushingFinder:
+ """A dummy finder which flushes sys.path_importer_cache when it gets
+ called."""
+
+ def find_module(self, name, path=None):
+ sys.path_importer_cache.clear()
+
+
+class ThreadedImportTests(unittest.TestCase):
+
+ def setUp(self):
+ self.old_random = sys.modules.pop('random', None)
+
+ def tearDown(self):
+ # If the `random` module was already initialized, we restore the
+ # old module at the end so that pickling tests don't fail.
+ # See http://bugs.python.org/issue3657#msg110461
+ if self.old_random is not None:
+ sys.modules['random'] = self.old_random
+
+ def check_parallel_module_init(self):
+ if imp.lock_held():
+ # This triggers on, e.g., from test import autotest.
+ raise unittest.SkipTest("can't run when import lock is held")
+
+ done = threading.Event()
+ for N in (20, 50) * 3:
+ if verbose:
+ print("Trying", N, "threads ...", end=' ')
+ # Make sure that random and modulefinder get reimported freshly
+ for modname in ['random', 'modulefinder']:
+ try:
+ del sys.modules[modname]
+ except KeyError:
+ pass
+ errors = []
+ done_tasks = []
+ done.clear()
+ for i in range(N):
+ thread.start_new_thread(task, (N, done, done_tasks, errors,))
+ done.wait(60)
+ self.assertFalse(errors)
+ if verbose:
+ print("OK.")
+
+ def test_parallel_module_init(self):
+ self.check_parallel_module_init()
+
+ def test_parallel_meta_path(self):
+ finder = Finder()
+ sys.meta_path.append(finder)
+ try:
+ self.check_parallel_module_init()
+ self.assertGreater(finder.numcalls, 0)
+ self.assertEqual(finder.x, finder.numcalls)
+ finally:
+ sys.meta_path.remove(finder)
+
+ def test_parallel_path_hooks(self):
+ # Here the Finder instance is only used to check concurrent calls
+ # to path_hook().
+ finder = Finder()
+ # In order for our path hook to be called at each import, we need
+ # to flush the path_importer_cache, which we do by registering a
+ # dedicated meta_path entry.
+ flushing_finder = FlushingFinder()
+ def path_hook(path):
+ finder.find_module('')
+ raise ImportError
+ sys.path_hooks.append(path_hook)
+ sys.meta_path.append(flushing_finder)
+ try:
+ # Flush the cache a first time
+ flushing_finder.find_module('')
+ numtests = self.check_parallel_module_init()
+ self.assertGreater(finder.numcalls, 0)
+ self.assertEqual(finder.x, finder.numcalls)
+ finally:
+ sys.meta_path.remove(flushing_finder)
+ sys.path_hooks.remove(path_hook)
+
+ def test_import_hangers(self):
# In case this test is run again, make sure the helper module
# gets loaded from scratch again.
- del sys.modules['test.threaded_import_hangers']
-
-# Tricky: When regrtest imports this module, the thread running regrtest
-# grabs the import lock and won't let go of it until this module returns.
-# All other threads attempting an import hang for the duration. Since
-# this test spawns threads that do little *but* import, we can't do that
-# successfully until after this module finishes importing and regrtest
-# regains control. To make this work, a special case was added to
-# regrtest to invoke a module's "test_main" function (if any) after
-# importing it.
-
-def test_main(): # magic name! see above
- global N, done
-
- import imp
- if imp.lock_held():
- # This triggers on, e.g., from test import autotest.
- raise unittest.SkipTest("can't run when import lock is held")
-
- done.acquire()
- for N in (20, 50) * 3:
- if verbose:
- print "Trying", N, "threads ...",
- for i in range(N):
- thread.start_new_thread(task, ())
- done.acquire()
- if verbose:
- print "OK."
- done.release()
-
- test_import_hangers()
+ try:
+ del sys.modules['test.threaded_import_hangers']
+ except KeyError:
+ pass
+ import test.threaded_import_hangers
+ self.assertFalse(test.threaded_import_hangers.errors)
+
+ def test_circular_imports(self):
+ # The goal of this test is to exercise implementations of the import
+ # lock which use a per-module lock, rather than a global lock.
+ # In these implementations, there is a possible deadlock with
+ # circular imports, for example:
+ # - thread 1 imports A (grabbing the lock for A) which imports B
+ # - thread 2 imports B (grabbing the lock for B) which imports A
+ # Such implementations should be able to detect such situations and
+ # resolve them one way or the other, without freezing.
+ # NOTE: our test constructs a slightly less trivial import cycle,
+ # in order to better stress the deadlock avoidance mechanism.
+ delay = 0.5
+ os.mkdir(TESTFN)
+ self.addCleanup(shutil.rmtree, TESTFN)
+ sys.path.insert(0, TESTFN)
+ self.addCleanup(sys.path.remove, TESTFN)
+ for name, contents in circular_imports_modules.items():
+ contents = contents % {'delay': delay}
+ with open(os.path.join(TESTFN, name + ".py"), "wb") as f:
+ f.write(contents.encode('utf-8'))
+ self.addCleanup(sys.modules.pop, name, None)
+
+ results = []
+ def import_ab():
+ import A
+ results.append(getattr(A, 'x', None))
+ def import_ba():
+ import B
+ results.append(getattr(B, 'x', None))
+ t1 = threading.Thread(target=import_ab)
+ t2 = threading.Thread(target=import_ba)
+ t1.start()
+ t2.start()
+ t1.join()
+ t2.join()
+ self.assertEqual(set(results), {'a', 'b'})
+
+
+def test_main():
+ run_unittest(ThreadedImportTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_threadedtempfile.py b/Lib/test/test_threadedtempfile.py
index 81d9687be25..2dfd3a08db8 100644
--- a/Lib/test/test_threadedtempfile.py
+++ b/Lib/test/test_threadedtempfile.py
@@ -18,10 +18,10 @@ FILES_PER_THREAD = 50
import tempfile
-from test.test_support import threading_setup, threading_cleanup, run_unittest, import_module
+from test.support import threading_setup, threading_cleanup, run_unittest, import_module
threading = import_module('threading')
import unittest
-import StringIO
+import io
from traceback import print_exc
startEvent = threading.Event()
@@ -31,7 +31,7 @@ class TempFileGreedy(threading.Thread):
ok_count = 0
def run(self):
- self.errors = StringIO.StringIO()
+ self.errors = io.StringIO()
startEvent.wait()
for i in range(FILES_PER_THREAD):
try:
@@ -62,7 +62,7 @@ class ThreadedTempFileTest(unittest.TestCase):
t.join()
ok += t.ok_count
if t.error_count:
- errors.append(str(t.getName()) + str(t.errors.getvalue()))
+ errors.append(str(t.name) + str(t.errors.getvalue()))
threading_cleanup(*thread_info)
diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
index ef04cd360a4..17be84b0019 100644
--- a/Lib/test/test_threading.py
+++ b/Lib/test/test_threading.py
@@ -1,18 +1,19 @@
# Very rudimentary test of threading module
-import test.test_support
-from test.test_support import verbose
+import test.support
+from test.support import verbose, strip_python_stderr, import_module
from test.script_helper import assert_python_ok
import random
import re
import sys
-thread = test.test_support.import_module('thread')
-threading = test.test_support.import_module('threading')
+_thread = import_module('_thread')
+threading = import_module('threading')
import time
import unittest
import weakref
import os
+from test.script_helper import assert_python_ok, assert_python_failure
import subprocess
from test import lock_tests
@@ -39,34 +40,35 @@ class TestThread(threading.Thread):
def run(self):
delay = random.random() / 10000.0
if verbose:
- print 'task %s will run for %.1f usec' % (
- self.name, delay * 1e6)
+ print('task %s will run for %.1f usec' %
+ (self.name, delay * 1e6))
with self.sema:
with self.mutex:
self.nrunning.inc()
if verbose:
- print self.nrunning.get(), 'tasks are running'
+ print(self.nrunning.get(), 'tasks are running')
self.testcase.assertTrue(self.nrunning.get() <= 3)
time.sleep(delay)
if verbose:
- print 'task', self.name, 'done'
+ print('task', self.name, 'done')
with self.mutex:
self.nrunning.dec()
self.testcase.assertTrue(self.nrunning.get() >= 0)
if verbose:
- print '%s is finished. %d tasks are running' % (
- self.name, self.nrunning.get())
+ print('%s is finished. %d tasks are running' %
+ (self.name, self.nrunning.get()))
+
class BaseTestCase(unittest.TestCase):
def setUp(self):
- self._threads = test.test_support.threading_setup()
+ self._threads = test.support.threading_setup()
def tearDown(self):
- test.test_support.threading_cleanup(*self._threads)
- test.test_support.reap_children()
+ test.support.threading_cleanup(*self._threads)
+ test.support.reap_children()
class ThreadTests(BaseTestCase):
@@ -93,15 +95,16 @@ class ThreadTests(BaseTestCase):
t.start()
if verbose:
- print 'waiting for all tasks to complete'
+ print('waiting for all tasks to complete')
for t in threads:
t.join(NUMTASKS)
self.assertTrue(not t.is_alive())
self.assertNotEqual(t.ident, 0)
self.assertFalse(t.ident is None)
- self.assertTrue(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
+ self.assertTrue(re.match('<TestThread\(.*, stopped -?\d+\)>',
+ repr(t)))
if verbose:
- print 'all tasks done'
+ print('all tasks done')
self.assertEqual(numrunning.get(), 0)
def test_ident_of_no_threading_threads(self):
@@ -112,7 +115,7 @@ class ThreadTests(BaseTestCase):
done.set()
done = threading.Event()
ident = []
- thread.start_new_thread(f, ())
+ _thread.start_new_thread(f, ())
done.wait()
self.assertFalse(ident[0] is None)
# Kill the "immortal" _DummyThread
@@ -121,26 +124,24 @@ class ThreadTests(BaseTestCase):
# run with a small(ish) thread stack size (256kB)
def test_various_ops_small_stack(self):
if verbose:
- print 'with 256kB thread stack size...'
+ print('with 256kB thread stack size...')
try:
threading.stack_size(262144)
- except thread.error:
- if verbose:
- print 'platform does not support changing thread stack size'
- return
+ except _thread.error:
+ raise unittest.SkipTest(
+ 'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
# run with a large thread stack size (1MB)
def test_various_ops_large_stack(self):
if verbose:
- print 'with 1MB thread stack size...'
+ print('with 1MB thread stack size...')
try:
threading.stack_size(0x100000)
- except thread.error:
- if verbose:
- print 'platform does not support changing thread stack size'
- return
+ except _thread.error:
+ raise unittest.SkipTest(
+ 'platform does not support changing thread stack size')
self.test_various_ops()
threading.stack_size(0)
@@ -154,7 +155,7 @@ class ThreadTests(BaseTestCase):
mutex = threading.Lock()
mutex.acquire()
- tid = thread.start_new_thread(f, (mutex,))
+ tid = _thread.start_new_thread(f, (mutex,))
# Wait for the thread to finish.
mutex.acquire()
self.assertIn(tid, threading._active)
@@ -164,12 +165,7 @@ class ThreadTests(BaseTestCase):
# PyThreadState_SetAsyncExc() is a CPython-only gimmick, not (currently)
# exposed at the Python level. This test relies on ctypes to get at it.
def test_PyThreadState_SetAsyncExc(self):
- try:
- import ctypes
- except ImportError:
- if verbose:
- print "test_PyThreadState_SetAsyncExc can't import ctypes"
- return # can't do anything
+ ctypes = import_module("ctypes")
set_async_exc = ctypes.pythonapi.PyThreadState_SetAsyncExc
@@ -179,7 +175,7 @@ class ThreadTests(BaseTestCase):
exception = ctypes.py_object(AsyncExc)
# First check it works when setting the exception from the same thread.
- tid = thread.get_ident()
+ tid = _thread.get_ident()
try:
result = set_async_exc(ctypes.c_long(tid), exception)
@@ -208,7 +204,7 @@ class ThreadTests(BaseTestCase):
class Worker(threading.Thread):
def run(self):
- self.id = thread.get_ident()
+ self.id = _thread.get_ident()
self.finished = False
try:
@@ -223,32 +219,32 @@ class ThreadTests(BaseTestCase):
t.daemon = True # so if this fails, we don't hang Python at shutdown
t.start()
if verbose:
- print " started worker thread"
+ print(" started worker thread")
# Try a thread id that doesn't make sense.
if verbose:
- print " trying nonsensical thread id"
+ print(" trying nonsensical thread id")
result = set_async_exc(ctypes.c_long(-1), exception)
self.assertEqual(result, 0) # no thread states modified
# Now raise an exception in the worker thread.
if verbose:
- print " waiting for worker thread to get started"
+ print(" waiting for worker thread to get started")
ret = worker_started.wait()
self.assertTrue(ret)
if verbose:
- print " verifying worker hasn't exited"
+ print(" verifying worker hasn't exited")
self.assertTrue(not t.finished)
if verbose:
- print " attempting to raise asynch exception in worker"
+ print(" attempting to raise asynch exception in worker")
result = set_async_exc(ctypes.c_long(t.id), exception)
self.assertEqual(result, 1) # one thread state modified
if verbose:
- print " waiting for worker to say it caught the exception"
+ print(" waiting for worker to say it caught the exception")
worker_saw_exception.wait(timeout=10)
self.assertTrue(t.finished)
if verbose:
- print " all OK -- joining worker"
+ print(" all OK -- joining worker")
if t.finished:
t.join()
# else the thread is still running, and we have no way to kill it
@@ -256,12 +252,12 @@ class ThreadTests(BaseTestCase):
def test_limbo_cleanup(self):
# Issue 7481: Failure to start thread should cleanup the limbo map.
def fail_new_thread(*args):
- raise thread.error()
+ raise threading.ThreadError()
_start_new_thread = threading._start_new_thread
threading._start_new_thread = fail_new_thread
try:
t = threading.Thread(target=lambda: None)
- self.assertRaises(thread.error, t.start)
+ self.assertRaises(threading.ThreadError, t.start)
self.assertFalse(
t in threading._limbo,
"Failed to cleanup _limbo map on failure of Thread.start().")
@@ -272,18 +268,13 @@ class ThreadTests(BaseTestCase):
# Issue 1402: the PyGILState_Ensure / _Release functions may be called
# very late on python exit: on deallocation of a running thread for
# example.
- try:
- import ctypes
- except ImportError:
- if verbose:
- print("test_finalize_with_runnning_thread can't import ctypes")
- return # can't do anything
+ import_module("ctypes")
- rc = subprocess.call([sys.executable, "-c", """if 1:
- import ctypes, sys, time, thread
+ rc, out, err = assert_python_failure("-c", """if 1:
+ import ctypes, sys, time, _thread
# This lock is used as a simple event variable.
- ready = thread.allocate_lock()
+ ready = _thread.allocate_lock()
ready.acquire()
# Module globals are cleared before __del__ is run
@@ -300,16 +291,16 @@ class ThreadTests(BaseTestCase):
ready.release()
time.sleep(100)
- thread.start_new_thread(waitingThread, ())
+ _thread.start_new_thread(waitingThread, ())
ready.acquire() # Be sure the other thread is waiting.
sys.exit(42)
- """])
+ """)
self.assertEqual(rc, 42)
def test_finalize_with_trace(self):
# Issue1733757
# Avoid a deadlock when sys.settrace steps into threading._shutdown
- p = subprocess.Popen([sys.executable, "-c", """if 1:
+ assert_python_ok("-c", """if 1:
import sys, threading
# A deadlock-killer, to prevent the
@@ -317,7 +308,7 @@ class ThreadTests(BaseTestCase):
def killer():
import os, time
time.sleep(2)
- print 'program blocked; aborting'
+ print('program blocked; aborting')
os._exit(2)
t = threading.Thread(target=killer)
t.daemon = True
@@ -329,21 +320,12 @@ class ThreadTests(BaseTestCase):
return func
sys.settrace(func)
- """],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.addCleanup(p.stderr.close)
- stdout, stderr = p.communicate()
- rc = p.returncode
- self.assertFalse(rc == 2, "interpreted was blocked")
- self.assertTrue(rc == 0,
- "Unexpected error: " + repr(stderr))
+ """)
def test_join_nondaemon_on_shutdown(self):
# Issue 1722344
# Raising SystemExit skipped threading._shutdown
- p = subprocess.Popen([sys.executable, "-c", """if 1:
+ rc, out, err = assert_python_ok("-c", """if 1:
import threading
from time import sleep
@@ -351,31 +333,23 @@ class ThreadTests(BaseTestCase):
sleep(1)
# As a non-daemon thread we SHOULD wake up and nothing
# should be torn down yet
- print "Woke up, sleep function is:", sleep
+ print("Woke up, sleep function is:", sleep)
threading.Thread(target=child).start()
raise SystemExit
- """],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- self.addCleanup(p.stdout.close)
- self.addCleanup(p.stderr.close)
- stdout, stderr = p.communicate()
- self.assertEqual(stdout.strip(),
- "Woke up, sleep function is: <built-in function sleep>")
- stderr = re.sub(r"^\[\d+ refs\]", "", stderr, re.MULTILINE).strip()
- self.assertEqual(stderr, "")
+ """)
+ self.assertEqual(out.strip(),
+ b"Woke up, sleep function is: <built-in function sleep>")
+ self.assertEqual(err, b"")
def test_enumerate_after_join(self):
# Try hard to trigger #1703448: a thread is still returned in
# threading.enumerate() after it has been join()ed.
enum = threading.enumerate
- old_interval = sys.getcheckinterval()
+ old_interval = sys.getswitchinterval()
try:
- for i in xrange(1, 100):
- # Try a couple times at each thread-switching interval
- # to get more interleavings.
- sys.setcheckinterval(i // 5)
+ for i in range(1, 100):
+ sys.setswitchinterval(i * 0.0002)
t = threading.Thread(target=lambda: None)
t.start()
t.join()
@@ -383,7 +357,7 @@ class ThreadTests(BaseTestCase):
self.assertNotIn(t, l,
"#1703448 triggered after %d trials: %s" % (i, l))
finally:
- sys.setcheckinterval(old_interval)
+ sys.setswitchinterval(old_interval)
def test_no_refcycle_through_target(self):
class RunSelfFunction(object):
@@ -404,7 +378,7 @@ class ThreadTests(BaseTestCase):
weak_cyclic_object = weakref.ref(cyclic_object)
cyclic_object.thread.join()
del cyclic_object
- self.assertEqual(None, weak_cyclic_object(),
+ self.assertIsNone(weak_cyclic_object(),
msg=('%d references still around' %
sys.getrefcount(weak_cyclic_object())))
@@ -412,16 +386,35 @@ class ThreadTests(BaseTestCase):
weak_raising_cyclic_object = weakref.ref(raising_cyclic_object)
raising_cyclic_object.thread.join()
del raising_cyclic_object
- self.assertEqual(None, weak_raising_cyclic_object(),
+ self.assertIsNone(weak_raising_cyclic_object(),
msg=('%d references still around' %
sys.getrefcount(weak_raising_cyclic_object())))
+ def test_old_threading_api(self):
+ # Just a quick sanity check to make sure the old method names are
+ # still present
+ t = threading.Thread()
+ t.isDaemon()
+ t.setDaemon(True)
+ t.getName()
+ t.setName("name")
+ t.isAlive()
+ e = threading.Event()
+ e.isSet()
+ threading.activeCount()
+
+ def test_repr_daemon(self):
+ t = threading.Thread()
+ self.assertFalse('daemon' in repr(t))
+ t.daemon = True
+ self.assertTrue('daemon' in repr(t))
+
@unittest.skipUnless(hasattr(os, 'fork'), 'test needs fork()')
def test_dummy_thread_after_fork(self):
# Issue #14308: a dummy thread in the active list doesn't mess up
# the after-fork mechanism.
code = """if 1:
- import thread, threading, os, time
+ import _thread, threading, os, time
def background_thread(evt):
# Creates and registers the _DummyThread instance
@@ -430,7 +423,7 @@ class ThreadTests(BaseTestCase):
time.sleep(10)
evt = threading.Event()
- thread.start_new_thread(background_thread, (evt,))
+ _thread.start_new_thread(background_thread, (evt,))
evt.wait()
assert threading.active_count() == 2, threading.active_count()
if os.fork() == 0:
@@ -440,8 +433,8 @@ class ThreadTests(BaseTestCase):
os.wait()
"""
_, out, err = assert_python_ok("-c", code)
- self.assertEqual(out, '')
- self.assertEqual(err, '')
+ self.assertEqual(out, b'')
+ self.assertEqual(err, b'')
class ThreadJoinOnShutdown(BaseTestCase):
@@ -460,16 +453,15 @@ class ThreadJoinOnShutdown(BaseTestCase):
# a thread, which waits for the main program to terminate
def joiningfunc(mainthread):
mainthread.join()
- print 'end of thread'
+ print('end of thread')
+ # stdout is fully buffered because not a tty, we have to flush
+ # before exit.
+ sys.stdout.flush()
\n""" + script
- p = subprocess.Popen([sys.executable, "-c", script], stdout=subprocess.PIPE)
- rc = p.wait()
- data = p.stdout.read().replace('\r', '')
- p.stdout.close()
+ rc, out, err = assert_python_ok("-c", script)
+ data = out.decode().replace('\r', '')
self.assertEqual(data, "end of main\nend of thread\n")
- self.assertFalse(rc == 2, "interpreter was blocked")
- self.assertTrue(rc == 0, "Unexpected error")
def test_1_join_on_shutdown(self):
# The usual case: on exit, wait for a non-daemon thread
@@ -479,11 +471,10 @@ class ThreadJoinOnShutdown(BaseTestCase):
args=(threading.current_thread(),))
t.start()
time.sleep(0.1)
- print 'end of main'
+ print('end of main')
"""
self._run_and_join(script)
-
@unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
def test_2_join_in_forked_process(self):
@@ -497,7 +488,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
t = threading.Thread(target=joiningfunc,
args=(threading.current_thread(),))
t.start()
- print 'end of main'
+ print('end of main')
"""
self._run_and_join(script)
@@ -506,6 +497,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
def test_3_join_in_forked_from_thread(self):
# Like the test above, but fork() was called from a worker thread
# In the forked process, the main Thread object must be marked as stopped.
+
script = """if 1:
main_thread = threading.current_thread()
def worker():
@@ -516,7 +508,7 @@ class ThreadJoinOnShutdown(BaseTestCase):
t = threading.Thread(target=joiningfunc,
args=(main_thread,))
- print 'end of main'
+ print('end of main')
t.start()
t.join() # Should not block: main_thread is already stopped
@@ -526,11 +518,8 @@ class ThreadJoinOnShutdown(BaseTestCase):
self._run_and_join(script)
def assertScriptHasOutput(self, script, expected_output):
- p = subprocess.Popen([sys.executable, "-c", script],
- stdout=subprocess.PIPE)
- rc = p.wait()
- data = p.stdout.read().decode().replace('\r', '')
- self.assertEqual(rc, 0, "Unexpected error")
+ rc, out, err = assert_python_ok("-c", script)
+ data = out.decode().replace('\r', '')
self.assertEqual(data, expected_output)
@unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
@@ -664,6 +653,49 @@ class ThreadJoinOnShutdown(BaseTestCase):
output = "end of worker thread\nend of main thread\n"
self.assertScriptHasOutput(script, output)
+ @unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
+ def test_6_daemon_threads(self):
+ # Check that a daemon thread cannot crash the interpreter on shutdown
+ # by manipulating internal structures that are being disposed of in
+ # the main thread.
+ script = """if True:
+ import os
+ import random
+ import sys
+ import time
+ import threading
+
+ thread_has_run = set()
+
+ def random_io():
+ '''Loop for a while sleeping random tiny amounts and doing some I/O.'''
+ while True:
+ in_f = open(os.__file__, 'rb')
+ stuff = in_f.read(200)
+ null_f = open(os.devnull, 'wb')
+ null_f.write(stuff)
+ time.sleep(random.random() / 1995)
+ null_f.close()
+ in_f.close()
+ thread_has_run.add(threading.current_thread())
+
+ def main():
+ count = 0
+ for _ in range(40):
+ new_thread = threading.Thread(target=random_io)
+ new_thread.daemon = True
+ new_thread.start()
+ count += 1
+ while len(thread_has_run) < count:
+ time.sleep(0.001)
+ # Trigger process shutdown
+ sys.exit(0)
+
+ main()
+ """
+ rc, out, err = assert_python_ok('-c', script)
+ self.assertFalse(err)
+
@unittest.skipUnless(hasattr(os, 'fork'), "needs os.fork()")
@unittest.skipIf(sys.platform in platforms_to_skip, "due to known OS bug")
def test_reinit_tls_after_fork(self):
@@ -710,29 +742,6 @@ class ThreadingExceptionTests(BaseTestCase):
thread.start()
self.assertRaises(RuntimeError, setattr, thread, "daemon", True)
-
-class LockTests(lock_tests.LockTests):
- locktype = staticmethod(threading.Lock)
-
-class RLockTests(lock_tests.RLockTests):
- locktype = staticmethod(threading.RLock)
-
-class EventTests(lock_tests.EventTests):
- eventtype = staticmethod(threading.Event)
-
-class ConditionAsRLockTests(lock_tests.RLockTests):
- # An Condition uses an RLock by default and exports its API.
- locktype = staticmethod(threading.Condition)
-
-class ConditionTests(lock_tests.ConditionTests):
- condtype = staticmethod(threading.Condition)
-
-class SemaphoreTests(lock_tests.SemaphoreTests):
- semtype = staticmethod(threading.Semaphore)
-
-class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests):
- semtype = staticmethod(threading.BoundedSemaphore)
-
@unittest.skipUnless(sys.platform == 'darwin', 'test macosx problem')
def test_recursion_limit(self):
# Issue 9670
@@ -759,20 +768,50 @@ class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests):
"""
expected_output = "end of main thread\n"
p = subprocess.Popen([sys.executable, "-c", script],
- stdout=subprocess.PIPE)
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
data = stdout.decode().replace('\r', '')
- self.assertEqual(p.returncode, 0, "Unexpected error")
+ self.assertEqual(p.returncode, 0, "Unexpected error: " + stderr.decode())
self.assertEqual(data, expected_output)
+class LockTests(lock_tests.LockTests):
+ locktype = staticmethod(threading.Lock)
+
+class PyRLockTests(lock_tests.RLockTests):
+ locktype = staticmethod(threading._PyRLock)
+
+@unittest.skipIf(threading._CRLock is None, 'RLock not implemented in C')
+class CRLockTests(lock_tests.RLockTests):
+ locktype = staticmethod(threading._CRLock)
+
+class EventTests(lock_tests.EventTests):
+ eventtype = staticmethod(threading.Event)
+
+class ConditionAsRLockTests(lock_tests.RLockTests):
+ # An Condition uses an RLock by default and exports its API.
+ locktype = staticmethod(threading.Condition)
+
+class ConditionTests(lock_tests.ConditionTests):
+ condtype = staticmethod(threading.Condition)
+
+class SemaphoreTests(lock_tests.SemaphoreTests):
+ semtype = staticmethod(threading.Semaphore)
+
+class BoundedSemaphoreTests(lock_tests.BoundedSemaphoreTests):
+ semtype = staticmethod(threading.BoundedSemaphore)
+
+class BarrierTests(lock_tests.BarrierTests):
+ barriertype = staticmethod(threading.Barrier)
+
def test_main():
- test.test_support.run_unittest(LockTests, RLockTests, EventTests,
- ConditionAsRLockTests, ConditionTests,
- SemaphoreTests, BoundedSemaphoreTests,
- ThreadTests,
- ThreadJoinOnShutdown,
- ThreadingExceptionTests,
- )
+ test.support.run_unittest(LockTests, PyRLockTests, CRLockTests, EventTests,
+ ConditionAsRLockTests, ConditionTests,
+ SemaphoreTests, BoundedSemaphoreTests,
+ ThreadTests,
+ ThreadJoinOnShutdown,
+ ThreadingExceptionTests,
+ BarrierTests
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_threading_local.py b/Lib/test/test_threading_local.py
index 4c9f2961ae8..c886a25d8ab 100644
--- a/Lib/test/test_threading_local.py
+++ b/Lib/test/test_threading_local.py
@@ -1,12 +1,12 @@
import unittest
from doctest import DocTestSuite
-from test import test_support
+from test import support
import weakref
import gc
# Modules under test
-_thread = test_support.import_module('thread')
-threading = test_support.import_module('threading')
+_thread = support.import_module('_thread')
+threading = support.import_module('threading')
import _threading_local
@@ -18,6 +18,7 @@ def target(local, weaklist):
local.weak = weak
weaklist.append(weakref.ref(weak))
+
class BaseLocalTest:
def test_local_refs(self):
@@ -77,11 +78,12 @@ class BaseLocalTest:
class Local(self._local):
pass
locals = None
- passed = [False]
+ passed = False
e1 = threading.Event()
e2 = threading.Event()
def f():
+ nonlocal passed
# 1) Involve Local in a cycle
cycle = [Local()]
cycle.append(cycle)
@@ -95,7 +97,7 @@ class BaseLocalTest:
e2.wait()
# 4) New Locals should be empty
- passed[0] = all(not hasattr(local, 'foo') for local in locals)
+ passed = all(not hasattr(local, 'foo') for local in locals)
t = threading.Thread(target=f)
t.start()
@@ -108,22 +110,18 @@ class BaseLocalTest:
e2.set()
t.join()
- self.assertTrue(passed[0])
+ self.assertTrue(passed)
def test_arguments(self):
# Issue 1522237
- from thread import _local as local
- from _threading_local import local as py_local
-
- for cls in (local, py_local):
- class MyLocal(cls):
- def __init__(self, *args, **kwargs):
- pass
+ class MyLocal(self._local):
+ def __init__(self, *args, **kwargs):
+ pass
- MyLocal(a=1)
- MyLocal(1)
- self.assertRaises(TypeError, cls, a=1)
- self.assertRaises(TypeError, cls, 1)
+ MyLocal(a=1)
+ MyLocal(1)
+ self.assertRaises(TypeError, self._local, a=1)
+ self.assertRaises(TypeError, self._local, 1)
def _test_one_class(self, c):
self._failed = "No error message set or cleared."
@@ -186,11 +184,6 @@ class BaseLocalTest:
"""To test that subclasses behave properly."""
self._test_dict_attribute(LocalSubclass)
-
-class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
- _local = _thread._local
-
- # Fails for the pure Python implementation
def test_cycle_collection(self):
class X:
pass
@@ -203,6 +196,10 @@ class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
gc.collect()
self.assertIs(wr(), None)
+
+class ThreadLocalTest(unittest.TestCase, BaseLocalTest):
+ _local = _thread._local
+
class PyThreadingLocalTest(unittest.TestCase, BaseLocalTest):
_local = _threading_local.local
@@ -213,22 +210,16 @@ def test_main():
suite.addTest(unittest.makeSuite(ThreadLocalTest))
suite.addTest(unittest.makeSuite(PyThreadingLocalTest))
- try:
- from thread import _local
- except ImportError:
- pass
- else:
- import _threading_local
- local_orig = _threading_local.local
- def setUp(test):
- _threading_local.local = _local
- def tearDown(test):
- _threading_local.local = local_orig
- suite.addTest(DocTestSuite('_threading_local',
- setUp=setUp, tearDown=tearDown)
- )
-
- test_support.run_unittest(suite)
+ local_orig = _threading_local.local
+ def setUp(test):
+ _threading_local.local = _thread._local
+ def tearDown(test):
+ _threading_local.local = local_orig
+ suite.addTest(DocTestSuite('_threading_local',
+ setUp=setUp, tearDown=tearDown)
+ )
+
+ support.run_unittest(suite)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_threadsignals.py b/Lib/test/test_threadsignals.py
index 2f7eb607c7e..e0af31dae47 100644
--- a/Lib/test/test_threadsignals.py
+++ b/Lib/test/test_threadsignals.py
@@ -4,15 +4,20 @@ import unittest
import signal
import os
import sys
-from test.test_support import run_unittest, import_module, reap_threads
-thread = import_module('thread')
+from test.support import run_unittest, import_module
+thread = import_module('_thread')
+import time
if sys.platform[:3] in ('win', 'os2') or sys.platform=='riscos':
- raise unittest.SkipTest, "Can't test signal on %s" % sys.platform
+ raise unittest.SkipTest("Can't test signal on %s" % sys.platform)
process_pid = os.getpid()
signalled_all=thread.allocate_lock()
+# Issue #11223: Locks are implemented using a mutex and a condition variable of
+# the pthread library on FreeBSD6. POSIX condition variables cannot be
+# interrupted by signals (see pthread_cond_wait manual page).
+USING_PTHREAD_COND = (sys.platform == 'freebsd6')
def registerSignals(for_usr1, for_usr2, for_alrm):
usr1 = signal.signal(signal.SIGUSR1, for_usr1)
@@ -34,13 +39,12 @@ def send_signals():
signalled_all.release()
class ThreadSignals(unittest.TestCase):
- """Test signal handling semantics of threads.
- We spawn a thread, have the thread send two signals, and
- wait for it to finish. Check that we got both signals
- and that they were run by the main thread.
- """
- @reap_threads
+
def test_signals(self):
+ # Test signal handling semantics of threads.
+ # We spawn a thread, have the thread send two signals, and
+ # wait for it to finish. Check that we got both signals
+ # and that they were run by the main thread.
signalled_all.acquire()
self.spawnSignallingThread()
signalled_all.acquire()
@@ -67,6 +71,140 @@ class ThreadSignals(unittest.TestCase):
def spawnSignallingThread(self):
thread.start_new_thread(send_signals, ())
+ def alarm_interrupt(self, sig, frame):
+ raise KeyboardInterrupt
+
+ @unittest.skipIf(USING_PTHREAD_COND,
+ 'POSIX condition variables cannot be interrupted')
+ def test_lock_acquire_interruption(self):
+ # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+ # in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
+ oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+ try:
+ lock = thread.allocate_lock()
+ lock.acquire()
+ signal.alarm(1)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, lock.acquire, timeout=5)
+ dt = time.time() - t1
+ # Checking that KeyboardInterrupt was raised is not sufficient.
+ # We want to assert that lock.acquire() was interrupted because
+ # of the signal, not that the signal handler was called immediately
+ # after timeout return of lock.acquire() (which can fool assertRaises).
+ self.assertLess(dt, 3.0)
+ finally:
+ signal.signal(signal.SIGALRM, oldalrm)
+
+ @unittest.skipIf(USING_PTHREAD_COND,
+ 'POSIX condition variables cannot be interrupted')
+ def test_rlock_acquire_interruption(self):
+ # Mimic receiving a SIGINT (KeyboardInterrupt) with SIGALRM while stuck
+ # in a deadlock.
+ # XXX this test can fail when the legacy (non-semaphore) implementation
+ # of locks is used in thread_pthread.h, see issue #11223.
+ oldalrm = signal.signal(signal.SIGALRM, self.alarm_interrupt)
+ try:
+ rlock = thread.RLock()
+ # For reentrant locks, the initial acquisition must be in another
+ # thread.
+ def other_thread():
+ rlock.acquire()
+ thread.start_new_thread(other_thread, ())
+ # Wait until we can't acquire it without blocking...
+ while rlock.acquire(blocking=False):
+ rlock.release()
+ time.sleep(0.01)
+ signal.alarm(1)
+ t1 = time.time()
+ self.assertRaises(KeyboardInterrupt, rlock.acquire, timeout=5)
+ dt = time.time() - t1
+ # See rationale above in test_lock_acquire_interruption
+ self.assertLess(dt, 3.0)
+ finally:
+ signal.signal(signal.SIGALRM, oldalrm)
+
+ def acquire_retries_on_intr(self, lock):
+ self.sig_recvd = False
+ def my_handler(signal, frame):
+ self.sig_recvd = True
+ old_handler = signal.signal(signal.SIGUSR1, my_handler)
+ try:
+ def other_thread():
+ # Acquire the lock in a non-main thread, so this test works for
+ # RLocks.
+ lock.acquire()
+ # Wait until the main thread is blocked in the lock acquire, and
+ # then wake it up with this.
+ time.sleep(0.5)
+ os.kill(process_pid, signal.SIGUSR1)
+ # Let the main thread take the interrupt, handle it, and retry
+ # the lock acquisition. Then we'll let it run.
+ time.sleep(0.5)
+ lock.release()
+ thread.start_new_thread(other_thread, ())
+ # Wait until we can't acquire it without blocking...
+ while lock.acquire(blocking=False):
+ lock.release()
+ time.sleep(0.01)
+ result = lock.acquire() # Block while we receive a signal.
+ self.assertTrue(self.sig_recvd)
+ self.assertTrue(result)
+ finally:
+ signal.signal(signal.SIGUSR1, old_handler)
+
+ def test_lock_acquire_retries_on_intr(self):
+ self.acquire_retries_on_intr(thread.allocate_lock())
+
+ def test_rlock_acquire_retries_on_intr(self):
+ self.acquire_retries_on_intr(thread.RLock())
+
+ def test_interrupted_timed_acquire(self):
+ # Test to make sure we recompute lock acquisition timeouts when we
+ # receive a signal. Check this by repeatedly interrupting a lock
+ # acquire in the main thread, and make sure that the lock acquire times
+ # out after the right amount of time.
+ # NOTE: this test only behaves as expected if C signals get delivered
+ # to the main thread. Otherwise lock.acquire() itself doesn't get
+ # interrupted and the test trivially succeeds.
+ self.start = None
+ self.end = None
+ self.sigs_recvd = 0
+ done = thread.allocate_lock()
+ done.acquire()
+ lock = thread.allocate_lock()
+ lock.acquire()
+ def my_handler(signum, frame):
+ self.sigs_recvd += 1
+ old_handler = signal.signal(signal.SIGUSR1, my_handler)
+ try:
+ def timed_acquire():
+ self.start = time.time()
+ lock.acquire(timeout=0.5)
+ self.end = time.time()
+ def send_signals():
+ for _ in range(40):
+ time.sleep(0.02)
+ os.kill(process_pid, signal.SIGUSR1)
+ done.release()
+
+ # Send the signals from the non-main thread, since the main thread
+ # is the only one that can process signals.
+ thread.start_new_thread(send_signals, ())
+ timed_acquire()
+ # Wait for thread to finish
+ done.acquire()
+ # This allows for some timing and scheduling imprecision
+ self.assertLess(self.end - self.start, 2.0)
+ self.assertGreater(self.end - self.start, 0.3)
+ # If the signal is received several times before PyErr_CheckSignals()
+ # is called, the handler will get called less than 40 times. Just
+ # check it's been called at least once.
+ self.assertGreater(self.sigs_recvd, 0)
+ finally:
+ signal.signal(signal.SIGUSR1, old_handler)
+
def test_main():
global signal_blackboard
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index 4571c108d67..d3c49bb9221 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -1,8 +1,10 @@
-from test import test_support
+from test import support
import time
import unittest
+import locale
+import sysconfig
import sys
-
+import warnings
class TimeTestCase(unittest.TestCase):
@@ -19,10 +21,10 @@ class TimeTestCase(unittest.TestCase):
time.clock()
def test_conversions(self):
- self.assertTrue(time.ctime(self.t)
- == time.asctime(time.localtime(self.t)))
- self.assertTrue(long(time.mktime(time.localtime(self.t)))
- == long(self.t))
+ self.assertEqual(time.ctime(self.t),
+ time.asctime(time.localtime(self.t)))
+ self.assertEqual(int(time.mktime(time.localtime(self.t))),
+ int(self.t))
def test_sleep(self):
time.sleep(1.2)
@@ -45,63 +47,61 @@ class TimeTestCase(unittest.TestCase):
with self.assertRaises(ValueError):
time.strftime('%f')
- def test_strftime_bounds_checking(self):
+ def _bounds_checking(self, func=time.strftime):
# Make sure that strftime() checks the bounds of the various parts
#of the time tuple (0 is valid for *all* values).
- # Check year [1900, max(int)]
- self.assertRaises(ValueError, time.strftime, '',
- (1899, 1, 1, 0, 0, 0, 0, 1, -1))
- if time.accept2dyear:
- self.assertRaises(ValueError, time.strftime, '',
- (-1, 1, 1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
- (100, 1, 1, 0, 0, 0, 0, 1, -1))
+ # The year field is tested by other test cases above
+
# Check month [1, 12] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, -1, 1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 13, 1, 0, 0, 0, 0, 1, -1))
# Check day of month [1, 31] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, -1, 0, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 32, 0, 0, 0, 0, 1, -1))
# Check hour [0, 23]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, -1, 0, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 24, 0, 0, 0, 1, -1))
# Check minute [0, 59]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, -1, 0, 0, 1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 60, 0, 0, 1, -1))
# Check second [0, 61]
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, -1, 0, 1, -1))
# C99 only requires allowing for one leap second, but Python's docs say
# allow two leap seconds (0..61)
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 62, 0, 1, -1))
# No check for upper-bound day of week;
# value forced into range by a ``% 7`` calculation.
# Start check at -2 since gettmarg() increments value before taking
# modulo.
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, -2, 1, -1))
# Check day of the year [1, 366] + zero support
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, 0, -1, -1))
- self.assertRaises(ValueError, time.strftime, '',
+ self.assertRaises(ValueError, func,
(1900, 1, 1, 0, 0, 0, 0, 367, -1))
+ def test_strftime_bounding_check(self):
+ self._bounds_checking(lambda tup: time.strftime('', tup))
+
def test_default_values_for_zero(self):
# Make sure that using all zeros uses the proper default values.
# No test for daylight savings since strftime() does not change output
# based on its value.
expected = "2000 01 01 00 00 00 1 001"
- result = time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9)
+ with support.check_warnings():
+ result = time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9)
self.assertEqual(expected, result)
def test_strptime(self):
@@ -119,19 +119,41 @@ class TimeTestCase(unittest.TestCase):
self.fail("conversion specifier %r failed with '%s' input." %
(format, strf_output))
+ def test_strptime_bytes(self):
+ # Make sure only strings are accepted as arguments to strptime.
+ self.assertRaises(TypeError, time.strptime, b'2009', "%Y")
+ self.assertRaises(TypeError, time.strptime, '2009', b'%Y')
+
def test_asctime(self):
time.asctime(time.gmtime(self.t))
+
+ # Max year is only limited by the size of C int.
+ sizeof_int = sysconfig.get_config_var('SIZEOF_INT') or 4
+ bigyear = (1 << 8 * sizeof_int - 1) - 1
+ asc = time.asctime((bigyear, 6, 1) + (0,)*6)
+ self.assertEqual(asc[-len(str(bigyear)):], str(bigyear))
+ self.assertRaises(OverflowError, time.asctime, (bigyear + 1,) + (0,)*8)
self.assertRaises(TypeError, time.asctime, 0)
self.assertRaises(TypeError, time.asctime, ())
- # XXX: Posix compiant asctime should refuse to convert
- # year > 9999, but Linux implementation does not.
- # self.assertRaises(ValueError, time.asctime,
- # (12345, 1, 0, 0, 0, 0, 0, 0, 0))
- # XXX: For now, just make sure we don't have a crash:
- try:
- time.asctime((12345, 1, 1, 0, 0, 0, 0, 1, 0))
- except ValueError:
- pass
+ self.assertRaises(TypeError, time.asctime, (0,) * 10)
+
+ def test_asctime_bounding_check(self):
+ self._bounds_checking(time.asctime)
+
+ def test_ctime(self):
+ t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
+ self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
+ t = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, -1))
+ self.assertEqual(time.ctime(t), 'Sat Jan 1 00:00:00 2000')
+ for year in [-100, 100, 1000, 2000, 10000]:
+ try:
+ testval = time.mktime((year, 1, 10) + (0,)*6)
+ except (ValueError, OverflowError):
+ # If mktime fails, ctime will fail too. This may happen
+ # on some platforms.
+ pass
+ else:
+ self.assertEqual(time.ctime(testval)[20:], str(year))
@unittest.skipIf(not hasattr(time, "tzset"),
"time module has no attribute tzset")
@@ -202,7 +224,7 @@ class TimeTestCase(unittest.TestCase):
# rely on it.
if org_TZ is not None:
environ['TZ'] = org_TZ
- elif environ.has_key('TZ'):
+ elif 'TZ' in environ:
del environ['TZ']
time.tzset()
@@ -227,14 +249,105 @@ class TimeTestCase(unittest.TestCase):
gt1 = time.gmtime(None)
t0 = time.mktime(gt0)
t1 = time.mktime(gt1)
- self.assertTrue(0 <= (t1-t0) < 0.2)
+ self.assertAlmostEqual(t1, t0, delta=0.2)
def test_localtime_without_arg(self):
lt0 = time.localtime()
lt1 = time.localtime(None)
t0 = time.mktime(lt0)
t1 = time.mktime(lt1)
- self.assertTrue(0 <= (t1-t0) < 0.2)
+ self.assertAlmostEqual(t1, t0, delta=0.2)
+
+class TestLocale(unittest.TestCase):
+ def setUp(self):
+ self.oldloc = locale.setlocale(locale.LC_ALL)
+
+ def tearDown(self):
+ locale.setlocale(locale.LC_ALL, self.oldloc)
+
+ def test_bug_3061(self):
+ try:
+ tmp = locale.setlocale(locale.LC_ALL, "fr_FR")
+ except locale.Error:
+ # skip this test
+ return
+ # This should not cause an exception
+ time.strftime("%B", (2009,2,1,0,0,0,0,0,0))
+
+
+class _BaseYearTest(unittest.TestCase):
+ accept2dyear = None
+
+ def setUp(self):
+ self.saved_accept2dyear = time.accept2dyear
+ time.accept2dyear = self.accept2dyear
+
+ def tearDown(self):
+ time.accept2dyear = self.saved_accept2dyear
+
+ def yearstr(self, y):
+ raise NotImplementedError()
+
+class _TestAsctimeYear:
+ def yearstr(self, y):
+ return time.asctime((y,) + (0,) * 8).split()[-1]
+
+ def test_large_year(self):
+ # Check that it doesn't crash for year > 9999
+ self.assertEqual(self.yearstr(12345), '12345')
+ self.assertEqual(self.yearstr(123456789), '123456789')
+
+class _TestStrftimeYear:
+ def yearstr(self, y):
+ return time.strftime('%Y', (y,) + (0,) * 8).split()[-1]
+
+ def test_large_year(self):
+ # Check that it doesn't crash for year > 9999
+ try:
+ text = self.yearstr(12345)
+ except ValueError:
+ # strftime() is limited to [1; 9999] with Visual Studio
+ return
+ self.assertEqual(text, '12345')
+ self.assertEqual(self.yearstr(123456789), '123456789')
+
+class _Test2dYear(_BaseYearTest):
+ accept2dyear = 1
+
+ def test_year(self):
+ with support.check_warnings():
+ self.assertEqual(self.yearstr(0), '2000')
+ self.assertEqual(self.yearstr(69), '1969')
+ self.assertEqual(self.yearstr(68), '2068')
+ self.assertEqual(self.yearstr(99), '1999')
+
+ def test_invalid(self):
+ self.assertRaises(ValueError, self.yearstr, -1)
+ self.assertRaises(ValueError, self.yearstr, 100)
+ self.assertRaises(ValueError, self.yearstr, 999)
+
+class _Test4dYear(_BaseYearTest):
+ accept2dyear = 0
+
+ def test_year(self):
+ self.assertIn(self.yearstr(1), ('1', '0001'))
+ self.assertIn(self.yearstr(68), ('68', '0068'))
+ self.assertIn(self.yearstr(69), ('69', '0069'))
+ self.assertIn(self.yearstr(99), ('99', '0099'))
+ self.assertIn(self.yearstr(999), ('999', '0999'))
+ self.assertEqual(self.yearstr(9999), '9999')
+
+ def test_negative(self):
+ try:
+ text = self.yearstr(-1)
+ except ValueError:
+ # strftime() is limited to [1; 9999] with Visual Studio
+ return
+ self.assertIn(text, ('-1', '-001'))
+
+ self.assertEqual(self.yearstr(-1234), '-1234')
+ self.assertEqual(self.yearstr(-123456), '-123456')
+
def test_mktime(self):
# Issue #1726687
@@ -245,11 +358,54 @@ class TimeTestCase(unittest.TestCase):
pass
else:
self.assertEqual(time.mktime(tt), t)
+ # It may not be possible to reliably make mktime return error
+ # on all platfom. This will make sure that no other exception
+ # than OverflowError is raised for an extreme value.
+ try:
+ time.mktime((-1, 1, 1, 0, 0, 0, -1, -1, -1))
+ except OverflowError:
+ pass
+class TestAsctimeAccept2dYear(_TestAsctimeYear, _Test2dYear):
+ pass
-def test_main():
- test_support.run_unittest(TimeTestCase)
+class TestStrftimeAccept2dYear(_TestStrftimeYear, _Test2dYear):
+ pass
+
+class TestAsctime4dyear(_TestAsctimeYear, _Test4dYear):
+ pass
+
+class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear):
+ pass
+class Test2dyearBool(_TestAsctimeYear, _Test2dYear):
+ accept2dyear = True
+
+class Test4dyearBool(_TestAsctimeYear, _Test4dYear):
+ accept2dyear = False
+
+class TestAccept2YearBad(_TestAsctimeYear, _BaseYearTest):
+ class X:
+ def __bool__(self):
+ raise RuntimeError('boo')
+ accept2dyear = X()
+ def test_2dyear(self):
+ pass
+ def test_invalid(self):
+ self.assertRaises(RuntimeError, self.yearstr, 200)
+
+
+def test_main():
+ support.run_unittest(
+ TimeTestCase,
+ TestLocale,
+ TestAsctimeAccept2dYear,
+ TestStrftimeAccept2dYear,
+ TestAsctime4dyear,
+ TestStrftime4dyear,
+ Test2dyearBool,
+ Test4dyearBool,
+ TestAccept2YearBad)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_timeit.py b/Lib/test/test_timeit.py
new file mode 100644
index 00000000000..625fb8da90b
--- /dev/null
+++ b/Lib/test/test_timeit.py
@@ -0,0 +1,306 @@
+import timeit
+import unittest
+import sys
+import io
+import time
+from textwrap import dedent
+
+from test.support import run_unittest
+from test.support import captured_stdout
+from test.support import captured_stderr
+
+# timeit's default number of iterations.
+DEFAULT_NUMBER = 1000000
+
+# timeit's default number of repetitions.
+DEFAULT_REPEAT = 3
+
+# XXX: some tests are commented out that would improve the coverage but take a
+# long time to run because they test the default number of loops, which is
+# large. The tests could be enabled if there was a way to override the default
+# number of loops during testing, but this would require changing the signature
+# of some functions that use the default as a default argument.
+
+class FakeTimer:
+ BASE_TIME = 42.0
+ def __init__(self, seconds_per_increment=1.0):
+ self.count = 0
+ self.setup_calls = 0
+ self.seconds_per_increment=seconds_per_increment
+ timeit._fake_timer = self
+
+ def __call__(self):
+ return self.BASE_TIME + self.count * self.seconds_per_increment
+
+ def inc(self):
+ self.count += 1
+
+ def setup(self):
+ self.setup_calls += 1
+
+ def wrap_timer(self, timer):
+ """Records 'timer' and returns self as callable timer."""
+ self.saved_timer = timer
+ return self
+
+class TestTimeit(unittest.TestCase):
+
+ def tearDown(self):
+ try:
+ del timeit._fake_timer
+ except AttributeError:
+ pass
+
+ def test_reindent_empty(self):
+ self.assertEqual(timeit.reindent("", 0), "")
+ self.assertEqual(timeit.reindent("", 4), "")
+
+ def test_reindent_single(self):
+ self.assertEqual(timeit.reindent("pass", 0), "pass")
+ self.assertEqual(timeit.reindent("pass", 4), "pass")
+
+ def test_reindent_multi_empty(self):
+ self.assertEqual(timeit.reindent("\n\n", 0), "\n\n")
+ self.assertEqual(timeit.reindent("\n\n", 4), "\n \n ")
+
+ def test_reindent_multi(self):
+ self.assertEqual(timeit.reindent(
+ "print()\npass\nbreak", 0),
+ "print()\npass\nbreak")
+ self.assertEqual(timeit.reindent(
+ "print()\npass\nbreak", 4),
+ "print()\n pass\n break")
+
+ def test_timer_invalid_stmt(self):
+ self.assertRaises(ValueError, timeit.Timer, stmt=None)
+
+ def test_timer_invalid_setup(self):
+ self.assertRaises(ValueError, timeit.Timer, setup=None)
+
+ fake_setup = "import timeit; timeit._fake_timer.setup()"
+ fake_stmt = "import timeit; timeit._fake_timer.inc()"
+
+ def fake_callable_setup(self):
+ self.fake_timer.setup()
+
+ def fake_callable_stmt(self):
+ self.fake_timer.inc()
+
+ def timeit(self, stmt, setup, number=None):
+ self.fake_timer = FakeTimer()
+ t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer)
+ kwargs = {}
+ if number is None:
+ number = DEFAULT_NUMBER
+ else:
+ kwargs['number'] = number
+ delta_time = t.timeit(**kwargs)
+ self.assertEqual(self.fake_timer.setup_calls, 1)
+ self.assertEqual(self.fake_timer.count, number)
+ self.assertEqual(delta_time, number)
+
+ # Takes too long to run in debug build.
+ #def test_timeit_default_iters(self):
+ # self.timeit(self.fake_stmt, self.fake_setup)
+
+ def test_timeit_zero_iters(self):
+ self.timeit(self.fake_stmt, self.fake_setup, number=0)
+
+ def test_timeit_few_iters(self):
+ self.timeit(self.fake_stmt, self.fake_setup, number=3)
+
+ def test_timeit_callable_stmt(self):
+ self.timeit(self.fake_callable_stmt, self.fake_setup, number=3)
+
+ def test_timeit_callable_stmt_and_setup(self):
+ self.timeit(self.fake_callable_stmt,
+ self.fake_callable_setup, number=3)
+
+ # Takes too long to run in debug build.
+ #def test_timeit_function(self):
+ # delta_time = timeit.timeit(self.fake_stmt, self.fake_setup,
+ # timer=FakeTimer())
+ # self.assertEqual(delta_time, DEFAULT_NUMBER)
+
+ def test_timeit_function_zero_iters(self):
+ delta_time = timeit.timeit(self.fake_stmt, self.fake_setup, number=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_time, 0)
+
+ def repeat(self, stmt, setup, repeat=None, number=None):
+ self.fake_timer = FakeTimer()
+ t = timeit.Timer(stmt=stmt, setup=setup, timer=self.fake_timer)
+ kwargs = {}
+ if repeat is None:
+ repeat = DEFAULT_REPEAT
+ else:
+ kwargs['repeat'] = repeat
+ if number is None:
+ number = DEFAULT_NUMBER
+ else:
+ kwargs['number'] = number
+ delta_times = t.repeat(**kwargs)
+ self.assertEqual(self.fake_timer.setup_calls, repeat)
+ self.assertEqual(self.fake_timer.count, repeat * number)
+ self.assertEqual(delta_times, repeat * [float(number)])
+
+ # Takes too long to run in debug build.
+ #def test_repeat_default(self):
+ # self.repeat(self.fake_stmt, self.fake_setup)
+
+ def test_repeat_zero_reps(self):
+ self.repeat(self.fake_stmt, self.fake_setup, repeat=0)
+
+ def test_repeat_zero_iters(self):
+ self.repeat(self.fake_stmt, self.fake_setup, number=0)
+
+ def test_repeat_few_reps_and_iters(self):
+ self.repeat(self.fake_stmt, self.fake_setup, repeat=3, number=5)
+
+ def test_repeat_callable_stmt(self):
+ self.repeat(self.fake_callable_stmt, self.fake_setup,
+ repeat=3, number=5)
+
+ def test_repeat_callable_stmt_and_setup(self):
+ self.repeat(self.fake_callable_stmt, self.fake_callable_setup,
+ repeat=3, number=5)
+
+ # Takes too long to run in debug build.
+ #def test_repeat_function(self):
+ # delta_times = timeit.repeat(self.fake_stmt, self.fake_setup,
+ # timer=FakeTimer())
+ # self.assertEqual(delta_times, DEFAULT_REPEAT * [float(DEFAULT_NUMBER)])
+
+ def test_repeat_function_zero_reps(self):
+ delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, repeat=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_times, [])
+
+ def test_repeat_function_zero_iters(self):
+ delta_times = timeit.repeat(self.fake_stmt, self.fake_setup, number=0,
+ timer=FakeTimer())
+ self.assertEqual(delta_times, DEFAULT_REPEAT * [0.0])
+
+ def assert_exc_string(self, exc_string, expected_exc_name):
+ exc_lines = exc_string.splitlines()
+ self.assertGreater(len(exc_lines), 2)
+ self.assertTrue(exc_lines[0].startswith('Traceback'))
+ self.assertTrue(exc_lines[-1].startswith(expected_exc_name))
+
+ def test_print_exc(self):
+ s = io.StringIO()
+ t = timeit.Timer("1/0")
+ try:
+ t.timeit()
+ except:
+ t.print_exc(s)
+ self.assert_exc_string(s.getvalue(), 'ZeroDivisionError')
+
+ MAIN_DEFAULT_OUTPUT = "10 loops, best of 3: 1 sec per loop\n"
+
+ def run_main(self, seconds_per_increment=1.0, switches=None, timer=None):
+ if timer is None:
+ timer = FakeTimer(seconds_per_increment=seconds_per_increment)
+ if switches is None:
+ args = []
+ else:
+ args = switches[:]
+ args.append(self.fake_stmt)
+ # timeit.main() modifies sys.path, so save and restore it.
+ orig_sys_path = sys.path[:]
+ with captured_stdout() as s:
+ timeit.main(args=args, _wrap_timer=timer.wrap_timer)
+ sys.path[:] = orig_sys_path[:]
+ return s.getvalue()
+
+ def test_main_bad_switch(self):
+ s = self.run_main(switches=['--bad-switch'])
+ self.assertEqual(s, dedent("""\
+ option --bad-switch not recognized
+ use -h/--help for command line help
+ """))
+
+ def test_main_seconds(self):
+ s = self.run_main(seconds_per_increment=5.5)
+ self.assertEqual(s, "10 loops, best of 3: 5.5 sec per loop\n")
+
+ def test_main_milliseconds(self):
+ s = self.run_main(seconds_per_increment=0.0055)
+ self.assertEqual(s, "100 loops, best of 3: 5.5 msec per loop\n")
+
+ def test_main_microseconds(self):
+ s = self.run_main(seconds_per_increment=0.0000025, switches=['-n100'])
+ self.assertEqual(s, "100 loops, best of 3: 2.5 usec per loop\n")
+
+ def test_main_fixed_iters(self):
+ s = self.run_main(seconds_per_increment=2.0, switches=['-n35'])
+ self.assertEqual(s, "35 loops, best of 3: 2 sec per loop\n")
+
+ def test_main_setup(self):
+ s = self.run_main(seconds_per_increment=2.0,
+ switches=['-n35', '-s', 'print("CustomSetup")'])
+ self.assertEqual(s, "CustomSetup\n" * 3 +
+ "35 loops, best of 3: 2 sec per loop\n")
+
+ def test_main_fixed_reps(self):
+ s = self.run_main(seconds_per_increment=60.0, switches=['-r9'])
+ self.assertEqual(s, "10 loops, best of 9: 60 sec per loop\n")
+
+ def test_main_negative_reps(self):
+ s = self.run_main(seconds_per_increment=60.0, switches=['-r-5'])
+ self.assertEqual(s, "10 loops, best of 1: 60 sec per loop\n")
+
+ @unittest.skipIf(sys.flags.optimize >= 2, "need __doc__")
+ def test_main_help(self):
+ s = self.run_main(switches=['-h'])
+ # Note: It's not clear that the trailing space was intended as part of
+ # the help text, but since it's there, check for it.
+ self.assertEqual(s, timeit.__doc__ + ' ')
+
+ def test_main_using_time(self):
+ fake_timer = FakeTimer()
+ s = self.run_main(switches=['-t'], timer=fake_timer)
+ self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
+ self.assertIs(fake_timer.saved_timer, time.time)
+
+ def test_main_using_clock(self):
+ fake_timer = FakeTimer()
+ s = self.run_main(switches=['-c'], timer=fake_timer)
+ self.assertEqual(s, self.MAIN_DEFAULT_OUTPUT)
+ self.assertIs(fake_timer.saved_timer, time.clock)
+
+ def test_main_verbose(self):
+ s = self.run_main(switches=['-v'])
+ self.assertEqual(s, dedent("""\
+ 10 loops -> 10 secs
+ raw times: 10 10 10
+ 10 loops, best of 3: 1 sec per loop
+ """))
+
+ def test_main_very_verbose(self):
+ s = self.run_main(seconds_per_increment=0.000050, switches=['-vv'])
+ self.assertEqual(s, dedent("""\
+ 10 loops -> 0.0005 secs
+ 100 loops -> 0.005 secs
+ 1000 loops -> 0.05 secs
+ 10000 loops -> 0.5 secs
+ raw times: 0.5 0.5 0.5
+ 10000 loops, best of 3: 50 usec per loop
+ """))
+
+ def test_main_exception(self):
+ with captured_stderr() as error_stringio:
+ s = self.run_main(switches=['1/0'])
+ self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')
+
+ def test_main_exception_fixed_reps(self):
+ with captured_stderr() as error_stringio:
+ s = self.run_main(switches=['-n1', '1/0'])
+ self.assert_exc_string(error_stringio.getvalue(), 'ZeroDivisionError')
+
+
+def test_main():
+ run_unittest(TestTimeit)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_timeout.py b/Lib/test/test_timeout.py
index 4bc125e128a..c3c4acfb479 100644
--- a/Lib/test/test_timeout.py
+++ b/Lib/test/test_timeout.py
@@ -1,12 +1,13 @@
"""Unit tests for socket timeout feature."""
import unittest
-from test import test_support
+from test import support
# This requires the 'network' resource as given on the regrtest command line.
-skip_expected = not test_support.is_resource_enabled('network')
+skip_expected = not support.is_resource_enabled('network')
import time
+import errno
import socket
@@ -46,11 +47,11 @@ class CreationTestCase(unittest.TestCase):
def testTypeCheck(self):
# Test type checking by settimeout()
self.sock.settimeout(0)
- self.sock.settimeout(0L)
+ self.sock.settimeout(0)
self.sock.settimeout(0.0)
self.sock.settimeout(None)
self.assertRaises(TypeError, self.sock.settimeout, "")
- self.assertRaises(TypeError, self.sock.settimeout, u"")
+ self.assertRaises(TypeError, self.sock.settimeout, "")
self.assertRaises(TypeError, self.sock.settimeout, ())
self.assertRaises(TypeError, self.sock.settimeout, [])
self.assertRaises(TypeError, self.sock.settimeout, {})
@@ -59,7 +60,7 @@ class CreationTestCase(unittest.TestCase):
def testRangeCheck(self):
# Test range checking by settimeout()
self.assertRaises(ValueError, self.sock.settimeout, -1)
- self.assertRaises(ValueError, self.sock.settimeout, -1L)
+ self.assertRaises(ValueError, self.sock.settimeout, -1)
self.assertRaises(ValueError, self.sock.settimeout, -1.0)
def testTimeoutThenBlocking(self):
@@ -88,8 +89,6 @@ class CreationTestCase(unittest.TestCase):
class TimeoutTestCase(unittest.TestCase):
- """Test case for socket.socket() timeout functions"""
-
# There are a number of tests here trying to make sure that an operation
# doesn't take too much longer than expected. But competing machine
# activity makes it inevitable that such tests will fail at times.
@@ -98,105 +97,194 @@ class TimeoutTestCase(unittest.TestCase):
# solution.
fuzz = 2.0
+ localhost = '127.0.0.1'
+
+ def setUp(self):
+ raise NotImplementedError()
+
+ tearDown = setUp
+
+ def _sock_operation(self, count, timeout, method, *args):
+ """
+ Test the specified socket method.
+
+ The method is run at most `count` times and must raise a socket.timeout
+ within `timeout` + self.fuzz seconds.
+ """
+ self.sock.settimeout(timeout)
+ method = getattr(self.sock, method)
+ for i in range(count):
+ t1 = time.time()
+ try:
+ method(*args)
+ except socket.timeout as e:
+ delta = time.time() - t1
+ break
+ else:
+ self.fail('socket.timeout was not raised')
+ # These checks should account for timing unprecision
+ self.assertLess(delta, timeout + self.fuzz)
+ self.assertGreater(delta, timeout - 1.0)
+
+
+class TCPTimeoutTestCase(TimeoutTestCase):
+ """TCP test case for socket.socket() timeout functions"""
+
def setUp(self):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.addr_remote = ('www.python.org.', 80)
- self.localhost = '127.0.0.1'
def tearDown(self):
self.sock.close()
def testConnectTimeout(self):
- # Choose a private address that is unlikely to exist to prevent
- # failures due to the connect succeeding before the timeout.
- # Use a dotted IP address to avoid including the DNS lookup time
- # with the connect time. This avoids failing the assertion that
- # the timeout occurred fast enough.
- addr = ('10.0.0.0', 12345)
-
- # Test connect() timeout
- _timeout = 0.001
- self.sock.settimeout(_timeout)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.connect, addr)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is more than %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ # Testing connect timeout is tricky: we need to have IP connectivity
+ # to a host that silently drops our packets. We can't simulate this
+ # from Python because it's a function of the underlying TCP/IP stack.
+ # So, the following Snakebite host has been defined:
+ blackhole = ('blackhole.snakebite.net', 56666)
+
+ # Blackhole has been configured to silently drop any incoming packets.
+ # No RSTs (for TCP) or ICMP UNREACH (for UDP/ICMP) will be sent back
+ # to hosts that attempt to connect to this address: which is exactly
+ # what we need to confidently test connect timeout.
+
+ # However, we want to prevent false positives. It's not unreasonable
+ # to expect certain hosts may not be able to reach the blackhole, due
+ # to firewalling or general network configuration. In order to improve
+ # our confidence in testing the blackhole, a corresponding 'whitehole'
+ # has also been set up using one port higher:
+ whitehole = ('whitehole.snakebite.net', 56667)
+
+ # This address has been configured to immediately drop any incoming
+ # packets as well, but it does it respectfully with regards to the
+ # incoming protocol. RSTs are sent for TCP packets, and ICMP UNREACH
+ # is sent for UDP/ICMP packets. This means our attempts to connect to
+ # it should be met immediately with ECONNREFUSED. The test case has
+ # been structured around this premise: if we get an ECONNREFUSED from
+ # the whitehole, we proceed with testing connect timeout against the
+ # blackhole. If we don't, we skip the test (with a message about not
+ # getting the required RST from the whitehole within the required
+ # timeframe).
+
+ # For the records, the whitehole/blackhole configuration has been set
+ # up using the 'pf' firewall (available on BSDs), using the following:
+ #
+ # ext_if="bge0"
+ #
+ # blackhole_ip="35.8.247.6"
+ # whitehole_ip="35.8.247.6"
+ # blackhole_port="56666"
+ # whitehole_port="56667"
+ #
+ # block return in log quick on $ext_if proto { tcp udp } \
+ # from any to $whitehole_ip port $whitehole_port
+ # block drop in log quick on $ext_if proto { tcp udp } \
+ # from any to $blackhole_ip port $blackhole_port
+ #
+
+ skip = True
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ # Use a timeout of 3 seconds. Why 3? Because it's more than 1, and
+ # less than 5. i.e. no particular reason. Feel free to tweak it if
+ # you feel a different value would be more appropriate.
+ timeout = 3
+ sock.settimeout(timeout)
+ try:
+ sock.connect((whitehole))
+ except socket.timeout:
+ pass
+ except IOError as err:
+ if err.errno == errno.ECONNREFUSED:
+ skip = False
+ finally:
+ sock.close()
+ del sock
+
+ if skip:
+ self.skipTest(
+ "We didn't receive a connection reset (RST) packet from "
+ "{}:{} within {} seconds, so we're unable to test connect "
+ "timeout against the corresponding {}:{} (which is "
+ "configured to silently drop packets)."
+ .format(
+ whitehole[0],
+ whitehole[1],
+ timeout,
+ blackhole[0],
+ blackhole[1],
+ )
+ )
+
+ # All that hard work just to test if connect times out in 0.001s ;-)
+ self.addr_remote = blackhole
+ with support.transient_internet(self.addr_remote[0]):
+ self._sock_operation(1, 0.001, 'connect', self.addr_remote)
def testRecvTimeout(self):
# Test recv() timeout
- _timeout = 0.02
-
- with test_support.transient_internet(self.addr_remote[0]):
+ with support.transient_internet(self.addr_remote[0]):
self.sock.connect(self.addr_remote)
- self.sock.settimeout(_timeout)
-
- _t1 = time.time()
- self.assertRaises(socket.timeout, self.sock.recv, 1024)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ self._sock_operation(1, 1.5, 'recv', 1024)
def testAcceptTimeout(self):
# Test accept() timeout
- _timeout = 2
- self.sock.settimeout(_timeout)
- # Prevent "Address already in use" socket exceptions
- test_support.bind_port(self.sock, self.localhost)
+ support.bind_port(self.sock, self.localhost)
self.sock.listen(5)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.accept)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
-
- def testRecvfromTimeout(self):
- # Test recvfrom() timeout
- _timeout = 2
- self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
- self.sock.settimeout(_timeout)
- # Prevent "Address already in use" socket exceptions
- test_support.bind_port(self.sock, self.localhost)
-
- _t1 = time.time()
- self.assertRaises(socket.error, self.sock.recvfrom, 8192)
- _t2 = time.time()
-
- _delta = abs(_t1 - _t2)
- self.assertTrue(_delta < _timeout + self.fuzz,
- "timeout (%g) is %g seconds more than expected (%g)"
- %(_delta, self.fuzz, _timeout))
+ self._sock_operation(1, 1.5, 'accept')
def testSend(self):
# Test send() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # Send a lot of data in order to bypass buffering in the TCP stack.
+ self._sock_operation(100, 1.5, 'send', b"X" * 200000)
def testSendto(self):
# Test sendto() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # The address argument is ignored since we already connected.
+ self._sock_operation(100, 1.5, 'sendto', b"X" * 200000,
+ serv.getsockname())
def testSendall(self):
# Test sendall() timeout
- # couldn't figure out how to test it
- pass
+ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as serv:
+ support.bind_port(serv, self.localhost)
+ serv.listen(5)
+ self.sock.connect(serv.getsockname())
+ # Send a lot of data in order to bypass buffering in the TCP stack.
+ self._sock_operation(100, 1.5, 'sendall', b"X" * 200000)
+
+
+class UDPTimeoutTestCase(TimeoutTestCase):
+ """UDP test case for socket.socket() timeout functions"""
+
+ def setUp(self):
+ self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+
+ def tearDown(self):
+ self.sock.close()
+
+ def testRecvfromTimeout(self):
+ # Test recvfrom() timeout
+ # Prevent "Address already in use" socket exceptions
+ support.bind_port(self.sock, self.localhost)
+ self._sock_operation(1, 1.5, 'recvfrom', 1024)
def test_main():
- test_support.requires('network')
- test_support.run_unittest(CreationTestCase, TimeoutTestCase)
+ support.requires('network')
+ support.run_unittest(
+ CreationTestCase,
+ TCPTimeoutTestCase,
+ UDPTimeoutTestCase,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_tk.py b/Lib/test/test_tk.py
index 8625db27c47..f993c5358a8 100644
--- a/Lib/test/test_tk.py
+++ b/Lib/test/test_tk.py
@@ -1,28 +1,21 @@
-import os
-from test import test_support
-
+from test import support
# Skip test if _tkinter wasn't built.
-test_support.import_module('_tkinter')
-
-this_dir = os.path.dirname(os.path.abspath(__file__))
-lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
- 'lib-tk', 'test'))
-
-with test_support.DirsOnSysPath(lib_tk_test):
- import runtktests
+support.import_module('_tkinter')
# Skip test if tk cannot be initialized.
-runtktests.check_tk_availability()
+from tkinter.test.support import check_tk_availability
+check_tk_availability()
+
+from tkinter.test import runtktests
def test_main(enable_gui=False):
if enable_gui:
- if test_support.use_resources is None:
- test_support.use_resources = ['gui']
- elif 'gui' not in test_support.use_resources:
- test_support.use_resources.append('gui')
+ if support.use_resources is None:
+ support.use_resources = ['gui']
+ elif 'gui' not in support.use_resources:
+ support.use_resources.append('gui')
- with test_support.DirsOnSysPath(lib_tk_test):
- test_support.run_unittest(
+ support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_tkinter']))
if __name__ == '__main__':
diff --git a/Lib/test/test_tokenize.py b/Lib/test/test_tokenize.py
index 489f68fade9..f9652ce7b27 100644
--- a/Lib/test/test_tokenize.py
+++ b/Lib/test/test_tokenize.py
@@ -1,13 +1,12 @@
doctests = """
Tests for the tokenize module.
- >>> import glob, random, sys
-
The tests can be really simple. Given a small fragment of source
code, print out a table with tokens. The ENDMARK is omitted for
brevity.
>>> dump_tokens("1 + 1")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '1' (1, 0) (1, 1)
OP '+' (1, 2) (1, 3)
NUMBER '1' (1, 4) (1, 5)
@@ -15,6 +14,7 @@ brevity.
>>> dump_tokens("if False:\\n"
... " # NL\\n"
... " True = False # NEWLINE\\n")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'if' (1, 0) (1, 2)
NAME 'False' (1, 3) (1, 8)
OP ':' (1, 8) (1, 9)
@@ -34,32 +34,16 @@ brevity.
... x += 2
... x += 5
... \"""
-
- >>> for tok in generate_tokens(StringIO(indent_error_file).readline): pass
+ >>> readline = BytesIO(indent_error_file.encode('utf-8')).readline
+ >>> for tok in tokenize(readline): pass
Traceback (most recent call last):
...
IndentationError: unindent does not match any outer indentation level
-Test roundtrip for `untokenize`. `f` is an open file or a string. The source
-code in f is tokenized, converted back to source code via tokenize.untokenize(),
-and tokenized again from the latter. The test fails if the second tokenization
-doesn't match the first.
-
- >>> def roundtrip(f):
- ... if isinstance(f, str): f = StringIO(f)
- ... token_list = list(generate_tokens(f.readline))
- ... f.close()
- ... tokens1 = [tok[:2] for tok in token_list]
- ... new_text = untokenize(tokens1)
- ... readline = iter(new_text.splitlines(1)).next
- ... tokens2 = [tok[:2] for tok in generate_tokens(readline)]
- ... return tokens1 == tokens2
- ...
-
There are some standard formatting practices that are easy to get right.
>>> roundtrip("if x == 1:\\n"
- ... " print x\\n")
+ ... " print(x)\\n")
True
>>> roundtrip("# This is a comment\\n# This also")
@@ -68,26 +52,26 @@ There are some standard formatting practices that are easy to get right.
Some people use different formatting conventions, which makes
untokenize a little trickier. Note that this test involves trailing
whitespace after the colon. Note that we use hex escapes to make the
-two trailing blanks apperant in the expected output.
+two trailing blanks apparent in the expected output.
>>> roundtrip("if x == 1 : \\n"
- ... " print x\\n")
+ ... " print(x)\\n")
True
- >>> f = test_support.findfile("tokenize_tests" + os.extsep + "txt")
- >>> roundtrip(open(f))
+ >>> f = support.findfile("tokenize_tests.txt")
+ >>> roundtrip(open(f, 'rb'))
True
>>> roundtrip("if x == 1:\\n"
... " # A comment by itself.\\n"
- ... " print x # Comment here, too.\\n"
+ ... " print(x) # Comment here, too.\\n"
... " # Another comment.\\n"
... "after_if = True\\n")
True
>>> roundtrip("if (x # The comments need to go in the right place\\n"
... " == 1):\\n"
- ... " print 'x==1'\\n")
+ ... " print('x==1')\\n")
True
>>> roundtrip("class Test: # A comment here\\n"
@@ -102,8 +86,8 @@ Some error-handling code
>>> roundtrip("try: import somemodule\\n"
... "except ImportError: # comment\\n"
- ... " print 'Can not import' # comment2\\n"
- ... "else: print 'Loaded'\\n")
+ ... " print('Can not import' # comment2\\n)"
+ ... "else: print('Loaded')\\n")
True
Balancing continuation
@@ -123,27 +107,33 @@ Balancing continuation
Ordinary integers and binary operators
>>> dump_tokens("0xff <= 255")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0xff' (1, 0) (1, 4)
OP '<=' (1, 5) (1, 7)
NUMBER '255' (1, 8) (1, 11)
>>> dump_tokens("0b10 <= 255")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0b10' (1, 0) (1, 4)
OP '<=' (1, 5) (1, 7)
NUMBER '255' (1, 8) (1, 11)
- >>> dump_tokens("0o123 <= 0123")
+ >>> dump_tokens("0o123 <= 0O123")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0o123' (1, 0) (1, 5)
OP '<=' (1, 6) (1, 8)
- NUMBER '0123' (1, 9) (1, 13)
- >>> dump_tokens("01234567 > ~0x15")
- NUMBER '01234567' (1, 0) (1, 8)
- OP '>' (1, 9) (1, 10)
- OP '~' (1, 11) (1, 12)
- NUMBER '0x15' (1, 12) (1, 16)
- >>> dump_tokens("2134568 != 01231515")
+ NUMBER '0O123' (1, 9) (1, 14)
+ >>> dump_tokens("1234567 > ~0x15")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ NUMBER '1234567' (1, 0) (1, 7)
+ OP '>' (1, 8) (1, 9)
+ OP '~' (1, 10) (1, 11)
+ NUMBER '0x15' (1, 11) (1, 15)
+ >>> dump_tokens("2134568 != 1231515")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '2134568' (1, 0) (1, 7)
OP '!=' (1, 8) (1, 10)
- NUMBER '01231515' (1, 11) (1, 19)
- >>> dump_tokens("(-124561-1) & 0200000000")
+ NUMBER '1231515' (1, 11) (1, 18)
+ >>> dump_tokens("(-124561-1) & 200000000")
+ ENCODING 'utf-8' (0, 0) (0, 0)
OP '(' (1, 0) (1, 1)
OP '-' (1, 1) (1, 2)
NUMBER '124561' (1, 2) (1, 8)
@@ -151,17 +141,20 @@ Ordinary integers and binary operators
NUMBER '1' (1, 9) (1, 10)
OP ')' (1, 10) (1, 11)
OP '&' (1, 12) (1, 13)
- NUMBER '0200000000' (1, 14) (1, 24)
+ NUMBER '200000000' (1, 14) (1, 23)
>>> dump_tokens("0xdeadbeef != -1")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0xdeadbeef' (1, 0) (1, 10)
OP '!=' (1, 11) (1, 13)
OP '-' (1, 14) (1, 15)
NUMBER '1' (1, 15) (1, 16)
- >>> dump_tokens("0xdeadc0de & 012345")
+ >>> dump_tokens("0xdeadc0de & 12345")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0xdeadc0de' (1, 0) (1, 10)
OP '&' (1, 11) (1, 12)
- NUMBER '012345' (1, 13) (1, 19)
+ NUMBER '12345' (1, 13) (1, 18)
>>> dump_tokens("0xFF & 0x15 | 1234")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NUMBER '0xFF' (1, 0) (1, 4)
OP '&' (1, 5) (1, 6)
NUMBER '0x15' (1, 7) (1, 11)
@@ -170,53 +163,64 @@ Ordinary integers and binary operators
Long integers
- >>> dump_tokens("x = 0L")
+ >>> dump_tokens("x = 0")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- NUMBER '0L' (1, 4) (1, 6)
+ NUMBER '0' (1, 4) (1, 5)
>>> dump_tokens("x = 0xfffffffffff")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '0xffffffffff (1, 4) (1, 17)
- >>> dump_tokens("x = 123141242151251616110l")
+ >>> dump_tokens("x = 123141242151251616110")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- NUMBER '123141242151 (1, 4) (1, 26)
- >>> dump_tokens("x = -15921590215012591L")
+ NUMBER '123141242151 (1, 4) (1, 25)
+ >>> dump_tokens("x = -15921590215012591")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
OP '-' (1, 4) (1, 5)
- NUMBER '159215902150 (1, 5) (1, 23)
+ NUMBER '159215902150 (1, 5) (1, 22)
Floating point numbers
>>> dump_tokens("x = 3.14159")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '3.14159' (1, 4) (1, 11)
>>> dump_tokens("x = 314159.")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '314159.' (1, 4) (1, 11)
>>> dump_tokens("x = .314159")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '.314159' (1, 4) (1, 11)
>>> dump_tokens("x = 3e14159")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '3e14159' (1, 4) (1, 11)
>>> dump_tokens("x = 3E123")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '3E123' (1, 4) (1, 9)
>>> dump_tokens("x+y = 3e-1230")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '+' (1, 1) (1, 2)
NAME 'y' (1, 2) (1, 3)
OP '=' (1, 4) (1, 5)
NUMBER '3e-1230' (1, 6) (1, 13)
>>> dump_tokens("x = 3.14e159")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '3.14e159' (1, 4) (1, 12)
@@ -224,6 +228,7 @@ Floating point numbers
String literals
>>> dump_tokens("x = ''; y = \\\"\\\"")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
STRING "''" (1, 4) (1, 6)
@@ -232,6 +237,7 @@ String literals
OP '=' (1, 10) (1, 11)
STRING '""' (1, 12) (1, 14)
>>> dump_tokens("x = '\\\"'; y = \\\"'\\\"")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
STRING '\\'"\\'' (1, 4) (1, 7)
@@ -240,72 +246,53 @@ String literals
OP '=' (1, 11) (1, 12)
STRING '"\\'"' (1, 13) (1, 16)
>>> dump_tokens("x = \\\"doesn't \\\"shrink\\\", does it\\\"")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
STRING '"doesn\\'t "' (1, 4) (1, 14)
NAME 'shrink' (1, 14) (1, 20)
STRING '", does it"' (1, 20) (1, 31)
- >>> dump_tokens("x = u'abc' + U'ABC'")
+ >>> dump_tokens("x = 'abc' + 'ABC'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- STRING "u'abc'" (1, 4) (1, 10)
- OP '+' (1, 11) (1, 12)
- STRING "U'ABC'" (1, 13) (1, 19)
- >>> dump_tokens('y = u"ABC" + U"ABC"')
+ STRING "'abc'" (1, 4) (1, 9)
+ OP '+' (1, 10) (1, 11)
+ STRING "'ABC'" (1, 12) (1, 17)
+ >>> dump_tokens('y = "ABC" + "ABC"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'y' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- STRING 'u"ABC"' (1, 4) (1, 10)
- OP '+' (1, 11) (1, 12)
- STRING 'U"ABC"' (1, 13) (1, 19)
- >>> dump_tokens("x = ur'abc' + Ur'ABC' + uR'ABC' + UR'ABC'")
+ STRING '"ABC"' (1, 4) (1, 9)
+ OP '+' (1, 10) (1, 11)
+ STRING '"ABC"' (1, 12) (1, 17)
+ >>> dump_tokens("x = r'abc' + r'ABC' + R'ABC' + R'ABC'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- STRING "ur'abc'" (1, 4) (1, 11)
- OP '+' (1, 12) (1, 13)
- STRING "Ur'ABC'" (1, 14) (1, 21)
- OP '+' (1, 22) (1, 23)
- STRING "uR'ABC'" (1, 24) (1, 31)
- OP '+' (1, 32) (1, 33)
- STRING "UR'ABC'" (1, 34) (1, 41)
- >>> dump_tokens('y = ur"abc" + Ur"ABC" + uR"ABC" + UR"ABC"')
+ STRING "r'abc'" (1, 4) (1, 10)
+ OP '+' (1, 11) (1, 12)
+ STRING "r'ABC'" (1, 13) (1, 19)
+ OP '+' (1, 20) (1, 21)
+ STRING "R'ABC'" (1, 22) (1, 28)
+ OP '+' (1, 29) (1, 30)
+ STRING "R'ABC'" (1, 31) (1, 37)
+ >>> dump_tokens('y = r"abc" + r"ABC" + R"ABC" + R"ABC"')
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'y' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
- STRING 'ur"abc"' (1, 4) (1, 11)
- OP '+' (1, 12) (1, 13)
- STRING 'Ur"ABC"' (1, 14) (1, 21)
- OP '+' (1, 22) (1, 23)
- STRING 'uR"ABC"' (1, 24) (1, 31)
- OP '+' (1, 32) (1, 33)
- STRING 'UR"ABC"' (1, 34) (1, 41)
-
- >>> dump_tokens("b'abc' + B'abc'")
- STRING "b'abc'" (1, 0) (1, 6)
- OP '+' (1, 7) (1, 8)
- STRING "B'abc'" (1, 9) (1, 15)
- >>> dump_tokens('b"abc" + B"abc"')
- STRING 'b"abc"' (1, 0) (1, 6)
- OP '+' (1, 7) (1, 8)
- STRING 'B"abc"' (1, 9) (1, 15)
- >>> dump_tokens("br'abc' + bR'abc' + Br'abc' + BR'abc'")
- STRING "br'abc'" (1, 0) (1, 7)
- OP '+' (1, 8) (1, 9)
- STRING "bR'abc'" (1, 10) (1, 17)
- OP '+' (1, 18) (1, 19)
- STRING "Br'abc'" (1, 20) (1, 27)
- OP '+' (1, 28) (1, 29)
- STRING "BR'abc'" (1, 30) (1, 37)
- >>> dump_tokens('br"abc" + bR"abc" + Br"abc" + BR"abc"')
- STRING 'br"abc"' (1, 0) (1, 7)
- OP '+' (1, 8) (1, 9)
- STRING 'bR"abc"' (1, 10) (1, 17)
- OP '+' (1, 18) (1, 19)
- STRING 'Br"abc"' (1, 20) (1, 27)
- OP '+' (1, 28) (1, 29)
- STRING 'BR"abc"' (1, 30) (1, 37)
+ STRING 'r"abc"' (1, 4) (1, 10)
+ OP '+' (1, 11) (1, 12)
+ STRING 'r"ABC"' (1, 13) (1, 19)
+ OP '+' (1, 20) (1, 21)
+ STRING 'R"ABC"' (1, 22) (1, 28)
+ OP '+' (1, 29) (1, 30)
+ STRING 'R"ABC"' (1, 31) (1, 37)
Operators
>>> dump_tokens("def d22(a, b, c=2, d=2, *k): pass")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'def' (1, 0) (1, 3)
NAME 'd22' (1, 4) (1, 7)
OP '(' (1, 7) (1, 8)
@@ -327,6 +314,7 @@ Operators
OP ':' (1, 27) (1, 28)
NAME 'pass' (1, 29) (1, 33)
>>> dump_tokens("def d01v_(a=1, *k, **w): pass")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'def' (1, 0) (1, 3)
NAME 'd01v_' (1, 4) (1, 9)
OP '(' (1, 9) (1, 10)
@@ -347,6 +335,7 @@ Comparison
>>> dump_tokens("if 1 < 1 > 1 == 1 >= 5 <= 0x15 <= 0x12 != " +
... "1 and 5 in 1 not in 1 is 1 or 5 is not 1: pass")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'if' (1, 0) (1, 2)
NUMBER '1' (1, 3) (1, 4)
OP '<' (1, 5) (1, 6)
@@ -383,6 +372,7 @@ Comparison
Shift
>>> dump_tokens("x = 1 << 1 >> 5")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '1' (1, 4) (1, 5)
@@ -393,7 +383,8 @@ Shift
Additive
- >>> dump_tokens("x = 1 - y + 15 - 01 + 0x124 + z + a[5]")
+ >>> dump_tokens("x = 1 - y + 15 - 1 + 0x124 + z + a[5]")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '1' (1, 4) (1, 5)
@@ -402,20 +393,21 @@ Additive
OP '+' (1, 10) (1, 11)
NUMBER '15' (1, 12) (1, 14)
OP '-' (1, 15) (1, 16)
- NUMBER '01' (1, 17) (1, 19)
- OP '+' (1, 20) (1, 21)
- NUMBER '0x124' (1, 22) (1, 27)
- OP '+' (1, 28) (1, 29)
- NAME 'z' (1, 30) (1, 31)
- OP '+' (1, 32) (1, 33)
- NAME 'a' (1, 34) (1, 35)
- OP '[' (1, 35) (1, 36)
- NUMBER '5' (1, 36) (1, 37)
- OP ']' (1, 37) (1, 38)
+ NUMBER '1' (1, 17) (1, 18)
+ OP '+' (1, 19) (1, 20)
+ NUMBER '0x124' (1, 21) (1, 26)
+ OP '+' (1, 27) (1, 28)
+ NAME 'z' (1, 29) (1, 30)
+ OP '+' (1, 31) (1, 32)
+ NAME 'a' (1, 33) (1, 34)
+ OP '[' (1, 34) (1, 35)
+ NUMBER '5' (1, 35) (1, 36)
+ OP ']' (1, 36) (1, 37)
Multiplicative
>>> dump_tokens("x = 1//1*1/5*12%0x12")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'x' (1, 0) (1, 1)
OP '=' (1, 2) (1, 3)
NUMBER '1' (1, 4) (1, 5)
@@ -433,6 +425,7 @@ Multiplicative
Unary
>>> dump_tokens("~1 ^ 1 & 1 |1 ^ -1")
+ ENCODING 'utf-8' (0, 0) (0, 0)
OP '~' (1, 0) (1, 1)
NUMBER '1' (1, 1) (1, 2)
OP '^' (1, 3) (1, 4)
@@ -445,6 +438,7 @@ Unary
OP '-' (1, 16) (1, 17)
NUMBER '1' (1, 17) (1, 18)
>>> dump_tokens("-1*1/1+1*1//1 - ---1**1")
+ ENCODING 'utf-8' (0, 0) (0, 0)
OP '-' (1, 0) (1, 1)
NUMBER '1' (1, 1) (1, 2)
OP '*' (1, 2) (1, 3)
@@ -468,6 +462,7 @@ Unary
Selector
>>> dump_tokens("import sys, time\\nx = sys.modules['time'].time()")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'import' (1, 0) (1, 6)
NAME 'sys' (1, 7) (1, 10)
OP ',' (1, 10) (1, 11)
@@ -489,6 +484,7 @@ Selector
Methods
>>> dump_tokens("@staticmethod\\ndef foo(x,y): pass")
+ ENCODING 'utf-8' (0, 0) (0, 0)
OP '@' (1, 0) (1, 1)
NAME 'staticmethod (1, 1) (1, 13)
NEWLINE '\\n' (1, 13) (1, 14)
@@ -520,22 +516,27 @@ Two string literals on the same line
Test roundtrip on random python modules.
pass the '-ucpu' option to process the full directory.
- >>>
+ >>> import random
>>> tempdir = os.path.dirname(f) or os.curdir
>>> testfiles = glob.glob(os.path.join(tempdir, "test*.py"))
- >>> if not test_support.is_resource_enabled("cpu"):
+tokenize is broken on test_pep3131.py because regular expressions are broken on
+the obscure unicode identifiers in it. *sigh*
+ >>> testfiles.remove(os.path.join(tempdir, "test_pep3131.py"))
+ >>> if not support.is_resource_enabled("cpu"):
... testfiles = random.sample(testfiles, 10)
...
>>> for testfile in testfiles:
- ... if not roundtrip(open(testfile)):
- ... print "Roundtrip failed for file %s" % testfile
+ ... if not roundtrip(open(testfile, 'rb')):
+ ... print("Roundtrip failed for file %s" % testfile)
... break
... else: True
True
Evil tabs
+
>>> dump_tokens("def f():\\n\\tif x\\n \\tpass")
+ ENCODING 'utf-8' (0, 0) (0, 0)
NAME 'def' (1, 0) (1, 3)
NAME 'f' (1, 4) (1, 5)
OP '(' (1, 5) (1, 6)
@@ -553,44 +554,77 @@ Evil tabs
Pathological whitespace (http://bugs.python.org/issue16152)
>>> dump_tokens("@ ")
+ ENCODING 'utf-8' (0, 0) (0, 0)
OP '@' (1, 0) (1, 1)
-"""
+Non-ascii identifiers
+
+ >>> dump_tokens("Örter = 'places'\\ngrün = 'green'")
+ ENCODING 'utf-8' (0, 0) (0, 0)
+ NAME 'Örter' (1, 0) (1, 5)
+ OP '=' (1, 6) (1, 7)
+ STRING "'places'" (1, 8) (1, 16)
+ NEWLINE '\\n' (1, 16) (1, 17)
+ NAME 'grün' (2, 0) (2, 4)
+ OP '=' (2, 5) (2, 6)
+ STRING "'green'" (2, 7) (2, 14)
+"""
-from test import test_support
-from tokenize import (untokenize, generate_tokens, NUMBER, NAME, OP,
- STRING, ENDMARKER, tok_name)
-from StringIO import StringIO
-import os
+from test import support
+from tokenize import (tokenize, _tokenize, untokenize, NUMBER, NAME, OP,
+ STRING, ENDMARKER, tok_name, detect_encoding,
+ open as tokenize_open)
+from io import BytesIO
+from unittest import TestCase
+import os, sys, glob
def dump_tokens(s):
"""Print out the tokens in s in a table format.
The ENDMARKER is omitted.
"""
- f = StringIO(s)
- for type, token, start, end, line in generate_tokens(f.readline):
+ f = BytesIO(s.encode('utf-8'))
+ for type, token, start, end, line in tokenize(f.readline):
if type == ENDMARKER:
break
type = tok_name[type]
print("%(type)-10.10s %(token)-13.13r %(start)s %(end)s" % locals())
+def roundtrip(f):
+ """
+ Test roundtrip for `untokenize`. `f` is an open file or a string.
+ The source code in f is tokenized, converted back to source code via
+ tokenize.untokenize(), and tokenized again from the latter. The test
+ fails if the second tokenization doesn't match the first.
+ """
+ if isinstance(f, str):
+ f = BytesIO(f.encode('utf-8'))
+ try:
+ token_list = list(tokenize(f.readline))
+ finally:
+ f.close()
+ tokens1 = [tok[:2] for tok in token_list]
+ new_bytes = untokenize(tokens1)
+ readline = (line for line in new_bytes.splitlines(1)).__next__
+ tokens2 = [tok[:2] for tok in tokenize(readline)]
+ return tokens1 == tokens2
+
# This is an example from the docs, set up as a doctest.
def decistmt(s):
"""Substitute Decimals for floats in a string of statements.
>>> from decimal import Decimal
- >>> s = 'print +21.3e-5*-.1234/81.7'
+ >>> s = 'print(+21.3e-5*-.1234/81.7)'
>>> decistmt(s)
- "print +Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7')"
+ "print (+Decimal ('21.3e-5')*-Decimal ('.1234')/Decimal ('81.7'))"
The format of the exponent is inherited from the platform C library.
Known cases are "e-007" (Windows) and "e-07" (not Windows). Since
- we're only showing 12 digits, and the 13th isn't close to 5, the
+ we're only showing 11 digits, and the 12th isn't close to 5, the
rest of the output should be platform-independent.
>>> exec(s) #doctest: +ELLIPSIS
- -3.21716034272e-0...7
+ -3.2171603427...e-0...7
Output from calculations with Decimal should be identical across all
platforms.
@@ -598,9 +632,8 @@ def decistmt(s):
>>> exec(decistmt(s))
-3.217160342717258261933904529E-7
"""
-
result = []
- g = generate_tokens(StringIO(s).readline) # tokenize the string
+ g = tokenize(BytesIO(s.encode('utf-8')).readline) # tokenize the string
for toknum, tokval, _, _, _ in g:
if toknum == NUMBER and '.' in tokval: # replace NUMBER tokens
result.extend([
@@ -611,15 +644,313 @@ def decistmt(s):
])
else:
result.append((toknum, tokval))
- return untokenize(result)
+ return untokenize(result).decode('utf-8')
-__test__ = {"doctests" : doctests, 'decistmt': decistmt}
+class TestTokenizerAdheresToPep0263(TestCase):
+ """
+ Test that tokenizer adheres to the coding behaviour stipulated in PEP 0263.
+ """
+ def _testFile(self, filename):
+ path = os.path.join(os.path.dirname(__file__), filename)
+ return roundtrip(open(path, 'rb'))
+
+ def test_utf8_coding_cookie_and_no_utf8_bom(self):
+ f = 'tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt'
+ self.assertTrue(self._testFile(f))
+
+ def test_latin1_coding_cookie_and_utf8_bom(self):
+ """
+ As per PEP 0263, if a file starts with a utf-8 BOM signature, the only
+ allowed encoding for the comment is 'utf-8'. The text file used in
+ this test starts with a BOM signature, but specifies latin1 as the
+ coding, so verify that a SyntaxError is raised, which matches the
+ behaviour of the interpreter when it encounters a similar condition.
+ """
+ f = 'tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt'
+ self.assertRaises(SyntaxError, self._testFile, f)
+
+ def test_no_coding_cookie_and_utf8_bom(self):
+ f = 'tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt'
+ self.assertTrue(self._testFile(f))
+
+ def test_utf8_coding_cookie_and_utf8_bom(self):
+ f = 'tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt'
+ self.assertTrue(self._testFile(f))
+
+ def test_bad_coding_cookie(self):
+ self.assertRaises(SyntaxError, self._testFile, 'bad_coding.py')
+ self.assertRaises(SyntaxError, self._testFile, 'bad_coding2.py')
+
+
+class Test_Tokenize(TestCase):
+
+ def test__tokenize_decodes_with_specified_encoding(self):
+ literal = '"ЉЊЈÐЂ"'
+ line = literal.encode('utf-8')
+ first = False
+ def readline():
+ nonlocal first
+ if not first:
+ first = True
+ return line
+ else:
+ return b''
+
+ # skip the initial encoding token and the end token
+ tokens = list(_tokenize(readline, encoding='utf-8'))[1:-1]
+ expected_tokens = [(3, '"ЉЊЈÐЂ"', (1, 0), (1, 7), '"ЉЊЈÐЂ"')]
+ self.assertEqual(tokens, expected_tokens,
+ "bytes not decoded with encoding")
+
+ def test__tokenize_does_not_decode_with_encoding_none(self):
+ literal = '"ЉЊЈÐЂ"'
+ first = False
+ def readline():
+ nonlocal first
+ if not first:
+ first = True
+ return literal
+ else:
+ return b''
+
+ # skip the end token
+ tokens = list(_tokenize(readline, encoding=None))[:-1]
+ expected_tokens = [(3, '"ЉЊЈÐЂ"', (1, 0), (1, 7), '"ЉЊЈÐЂ"')]
+ self.assertEqual(tokens, expected_tokens,
+ "string not tokenized when encoding is None")
+
+
+class TestDetectEncoding(TestCase):
+
+ def get_readline(self, lines):
+ index = 0
+ def readline():
+ nonlocal index
+ if index == len(lines):
+ raise StopIteration
+ line = lines[index]
+ index += 1
+ return line
+ return readline
+
+ def test_no_bom_no_encoding_cookie(self):
+ lines = (
+ b'# something\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(consumed_lines, list(lines[:2]))
+
+ def test_bom_no_cookie(self):
+ lines = (
+ b'\xef\xbb\xbf# something\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'utf-8-sig')
+ self.assertEqual(consumed_lines,
+ [b'# something\n', b'print(something)\n'])
+
+ def test_cookie_first_line_no_bom(self):
+ lines = (
+ b'# -*- coding: latin-1 -*-\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'iso-8859-1')
+ self.assertEqual(consumed_lines, [b'# -*- coding: latin-1 -*-\n'])
+
+ def test_matched_bom_and_cookie_first_line(self):
+ lines = (
+ b'\xef\xbb\xbf# coding=utf-8\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'utf-8-sig')
+ self.assertEqual(consumed_lines, [b'# coding=utf-8\n'])
+
+ def test_mismatched_bom_and_cookie_first_line_raises_syntaxerror(self):
+ lines = (
+ b'\xef\xbb\xbf# vim: set fileencoding=ascii :\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ readline = self.get_readline(lines)
+ self.assertRaises(SyntaxError, detect_encoding, readline)
+
+ def test_cookie_second_line_no_bom(self):
+ lines = (
+ b'#! something\n',
+ b'# vim: set fileencoding=ascii :\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'ascii')
+ expected = [b'#! something\n', b'# vim: set fileencoding=ascii :\n']
+ self.assertEqual(consumed_lines, expected)
+
+ def test_matched_bom_and_cookie_second_line(self):
+ lines = (
+ b'\xef\xbb\xbf#! something\n',
+ b'f# coding=utf-8\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ encoding, consumed_lines = detect_encoding(self.get_readline(lines))
+ self.assertEqual(encoding, 'utf-8-sig')
+ self.assertEqual(consumed_lines,
+ [b'#! something\n', b'f# coding=utf-8\n'])
+
+ def test_mismatched_bom_and_cookie_second_line_raises_syntaxerror(self):
+ lines = (
+ b'\xef\xbb\xbf#! something\n',
+ b'# vim: set fileencoding=ascii :\n',
+ b'print(something)\n',
+ b'do_something(else)\n'
+ )
+ readline = self.get_readline(lines)
+ self.assertRaises(SyntaxError, detect_encoding, readline)
+
+ def test_latin1_normalization(self):
+ # See get_normal_name() in tokenizer.c.
+ encodings = ("latin-1", "iso-8859-1", "iso-latin-1", "latin-1-unix",
+ "iso-8859-1-unix", "iso-latin-1-mac")
+ for encoding in encodings:
+ for rep in ("-", "_"):
+ enc = encoding.replace("-", rep)
+ lines = (b"#!/usr/bin/python\n",
+ b"# coding: " + enc.encode("ascii") + b"\n",
+ b"print(things)\n",
+ b"do_something += 4\n")
+ rl = self.get_readline(lines)
+ found, consumed_lines = detect_encoding(rl)
+ self.assertEqual(found, "iso-8859-1")
+
+ def test_syntaxerror_latin1(self):
+ # Issue 14629: need to raise SyntaxError if the first
+ # line(s) have non-UTF-8 characters
+ lines = (
+ b'print("\xdf")', # Latin-1: LATIN SMALL LETTER SHARP S
+ )
+ readline = self.get_readline(lines)
+ self.assertRaises(SyntaxError, detect_encoding, readline)
+
+
+ def test_utf8_normalization(self):
+ # See get_normal_name() in tokenizer.c.
+ encodings = ("utf-8", "utf-8-mac", "utf-8-unix")
+ for encoding in encodings:
+ for rep in ("-", "_"):
+ enc = encoding.replace("-", rep)
+ lines = (b"#!/usr/bin/python\n",
+ b"# coding: " + enc.encode("ascii") + b"\n",
+ b"1 + 3\n")
+ rl = self.get_readline(lines)
+ found, consumed_lines = detect_encoding(rl)
+ self.assertEqual(found, "utf-8")
+
+ def test_short_files(self):
+ readline = self.get_readline((b'print(something)\n',))
+ encoding, consumed_lines = detect_encoding(readline)
+ self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(consumed_lines, [b'print(something)\n'])
+
+ encoding, consumed_lines = detect_encoding(self.get_readline(()))
+ self.assertEqual(encoding, 'utf-8')
+ self.assertEqual(consumed_lines, [])
+
+ readline = self.get_readline((b'\xef\xbb\xbfprint(something)\n',))
+ encoding, consumed_lines = detect_encoding(readline)
+ self.assertEqual(encoding, 'utf-8-sig')
+ self.assertEqual(consumed_lines, [b'print(something)\n'])
+
+ readline = self.get_readline((b'\xef\xbb\xbf',))
+ encoding, consumed_lines = detect_encoding(readline)
+ self.assertEqual(encoding, 'utf-8-sig')
+ self.assertEqual(consumed_lines, [])
+
+ readline = self.get_readline((b'# coding: bad\n',))
+ self.assertRaises(SyntaxError, detect_encoding, readline)
+
+ def test_open(self):
+ filename = support.TESTFN + '.py'
+ self.addCleanup(support.unlink, filename)
+
+ # test coding cookie
+ for encoding in ('iso-8859-15', 'utf-8'):
+ with open(filename, 'w', encoding=encoding) as fp:
+ print("# coding: %s" % encoding, file=fp)
+ print("print('euro:\u20ac')", file=fp)
+ with tokenize_open(filename) as fp:
+ self.assertEqual(fp.encoding, encoding)
+ self.assertEqual(fp.mode, 'r')
+
+ # test BOM (no coding cookie)
+ with open(filename, 'w', encoding='utf-8-sig') as fp:
+ print("print('euro:\u20ac')", file=fp)
+ with tokenize_open(filename) as fp:
+ self.assertEqual(fp.encoding, 'utf-8-sig')
+ self.assertEqual(fp.mode, 'r')
+
+class TestTokenize(TestCase):
+
+ def test_tokenize(self):
+ import tokenize as tokenize_module
+ encoding = object()
+ encoding_used = None
+ def mock_detect_encoding(readline):
+ return encoding, ['first', 'second']
+
+ def mock__tokenize(readline, encoding):
+ nonlocal encoding_used
+ encoding_used = encoding
+ out = []
+ while True:
+ next_line = readline()
+ if next_line:
+ out.append(next_line)
+ continue
+ return out
+
+ counter = 0
+ def mock_readline():
+ nonlocal counter
+ counter += 1
+ if counter == 5:
+ return b''
+ return counter
+
+ orig_detect_encoding = tokenize_module.detect_encoding
+ orig__tokenize = tokenize_module._tokenize
+ tokenize_module.detect_encoding = mock_detect_encoding
+ tokenize_module._tokenize = mock__tokenize
+ try:
+ results = tokenize(mock_readline)
+ self.assertEqual(list(results), ['first', 'second', 1, 2, 3, 4])
+ finally:
+ tokenize_module.detect_encoding = orig_detect_encoding
+ tokenize_module._tokenize = orig__tokenize
+
+ self.assertTrue(encoding_used, encoding)
+
+
+__test__ = {"doctests" : doctests, 'decistmt': decistmt}
def test_main():
from test import test_tokenize
- test_support.run_doctest(test_tokenize, True)
+ support.run_doctest(test_tokenize, True)
+ support.run_unittest(TestTokenizerAdheresToPep0263)
+ support.run_unittest(Test_Tokenize)
+ support.run_unittest(TestDetectEncoding)
+ support.run_unittest(TestTokenize)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_tools.py b/Lib/test/test_tools.py
index 10ee27ce08b..42816a2c4f6 100644
--- a/Lib/test/test_tools.py
+++ b/Lib/test/test_tools.py
@@ -5,9 +5,12 @@ Tools directory of a Python checkout or tarball, such as reindent.py.
"""
import os
+import sys
+import imp
import unittest
import sysconfig
-from test import test_support
+import tempfile
+from test import support
from test.script_helper import assert_python_ok
if not sysconfig.is_python_build():
@@ -17,10 +20,11 @@ if not sysconfig.is_python_build():
basepath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))),
'Tools')
+scriptsdir = os.path.join(basepath, 'scripts')
class ReindentTests(unittest.TestCase):
- script = os.path.join(basepath, 'scripts', 'reindent.py')
+ script = os.path.join(scriptsdir, 'reindent.py')
def test_noargs(self):
assert_python_ok(self.script)
@@ -31,8 +35,73 @@ class ReindentTests(unittest.TestCase):
self.assertGreater(err, b'')
+class TestSundryScripts(unittest.TestCase):
+ # At least make sure the rest don't have syntax errors. When tests are
+ # added for a script it should be added to the whitelist below.
+
+ # scripts that have independent tests.
+ whitelist = ['reindent.py']
+ # scripts that can't be imported without running
+ blacklist = ['make_ctype.py']
+ # scripts that use windows-only modules
+ windows_only = ['win_add2path.py']
+ # blacklisted for other reasons
+ other = ['analyze_dxp.py']
+
+ skiplist = blacklist + whitelist + windows_only + other
+
+ def setUp(self):
+ cm = support.DirsOnSysPath(scriptsdir)
+ cm.__enter__()
+ self.addCleanup(cm.__exit__)
+
+ def test_sundry(self):
+ for fn in os.listdir(scriptsdir):
+ if fn.endswith('.py') and fn not in self.skiplist:
+ __import__(fn[:-3])
+
+ @unittest.skipIf(sys.platform != "win32", "Windows-only test")
+ def test_sundry_windows(self):
+ for fn in self.windows_only:
+ __import__(fn[:-3])
+
+ @unittest.skipIf(not support.threading, "test requires _thread module")
+ def test_analyze_dxp_import(self):
+ if hasattr(sys, 'getdxp'):
+ import analyze_dxp
+ else:
+ with self.assertRaises(RuntimeError):
+ import analyze_dxp
+
+
+class PdepsTests(unittest.TestCase):
+
+ @classmethod
+ def setUpClass(self):
+ path = os.path.join(scriptsdir, 'pdeps.py')
+ self.pdeps = imp.load_source('pdeps', path)
+
+ @classmethod
+ def tearDownClass(self):
+ if 'pdeps' in sys.modules:
+ del sys.modules['pdeps']
+
+ def test_process_errors(self):
+ # Issue #14492: m_import.match(line) can be None.
+ with tempfile.TemporaryDirectory() as tmpdir:
+ fn = os.path.join(tmpdir, 'foo')
+ with open(fn, 'w') as stream:
+ stream.write("#!/this/will/fail")
+ self.pdeps.process(fn, {})
+
+ def test_inverse_attribute_error(self):
+ # Issue #14492: this used to fail with an AttributeError.
+ self.pdeps.inverse({'a': []})
+
+
def test_main():
- test_support.run_unittest(ReindentTests)
+ support.run_unittest(*[obj for obj in globals().values()
+ if isinstance(obj, type)])
if __name__ == '__main__':
diff --git a/Lib/test/test_trace.py b/Lib/test/test_trace.py
index 2292ad6155d..461d1d8e6a4 100644
--- a/Lib/test/test_trace.py
+++ b/Lib/test/test_trace.py
@@ -1,6 +1,6 @@
import os
import sys
-from test.test_support import (run_unittest, TESTFN, rmtree, unlink,
+from test.support import (run_unittest, TESTFN, rmtree, unlink,
captured_stdout)
import unittest
@@ -163,7 +163,9 @@ class TestLineCounts(unittest.TestCase):
firstlineno_called = get_firstlineno(traced_doubler)
expected = {
(self.my_py_filename, firstlineno_calling + 1): 1,
- (self.my_py_filename, firstlineno_calling + 2): 11,
+ # List compehentions work differently in 3.x, so the count
+ # below changed compared to 2.x.
+ (self.my_py_filename, firstlineno_calling + 2): 12,
(self.my_py_filename, firstlineno_calling + 3): 1,
(self.my_py_filename, firstlineno_called + 1): 10,
}
@@ -328,10 +330,25 @@ class TestCoverage(unittest.TestCase):
lines, cov, module = line.split()[:3]
coverage[module] = (int(lines), int(cov[:-1]))
# XXX This is needed to run regrtest.py as a script
- modname = trace.fullmodname(sys.modules[modname].__file__)
+ modname = trace._fullmodname(sys.modules[modname].__file__)
self.assertIn(modname, coverage)
self.assertEqual(coverage[modname], (5, 100))
+### Tests that don't mess with sys.settrace and can be traced
+### themselves TODO: Skip tests that do mess with sys.settrace when
+### regrtest is invoked with -T option.
+class Test_Ignore(unittest.TestCase):
+ def test_ignored(self):
+ jn = os.path.join
+ ignore = trace._Ignore(['x', 'y.z'], [jn('foo', 'bar')])
+ self.assertTrue(ignore.names('x.py', 'x'))
+ self.assertFalse(ignore.names('xy.py', 'xy'))
+ self.assertFalse(ignore.names('y.py', 'y'))
+ self.assertTrue(ignore.names(jn('foo', 'bar', 'baz.py'), 'baz'))
+ self.assertFalse(ignore.names(jn('bar', 'z.py'), 'z'))
+ # Matched before.
+ self.assertTrue(ignore.names(jn('bar', 'baz.py'), 'baz'))
+
def test_main():
run_unittest(__name__)
diff --git a/Lib/test/test_traceback.py b/Lib/test/test_traceback.py
index 8076be8a785..4752d37e5b3 100644
--- a/Lib/test/test_traceback.py
+++ b/Lib/test/test_traceback.py
@@ -1,26 +1,27 @@
"""Test cases for traceback module"""
-from _testcapi import traceback_print
-from StringIO import StringIO
+from _testcapi import traceback_print, exception_print
+from io import StringIO
import sys
import unittest
-from imp import reload
-from test.test_support import run_unittest, is_jython, Error
+import re
+from test.support import run_unittest, Error, captured_output
+from test.support import TESTFN, unlink
import traceback
-class TracebackCases(unittest.TestCase):
+class SyntaxTracebackCases(unittest.TestCase):
# For now, a very minimal set of tests. I want to be sure that
# formatting of SyntaxErrors works based on changes for 2.1.
def get_exception_format(self, func, exc):
try:
func()
- except exc, value:
+ except exc as value:
return traceback.format_exception_only(exc, value)
else:
- raise ValueError, "call did not raise exception"
+ raise ValueError("call did not raise exception")
def syntax_error_with_caret(self):
compile("def fact(x):\n\treturn x!\n", "?", "exec")
@@ -28,20 +29,16 @@ class TracebackCases(unittest.TestCase):
def syntax_error_with_caret_2(self):
compile("1 +\n", "?", "exec")
- def syntax_error_without_caret(self):
- # XXX why doesn't compile raise the same traceback?
- import test.badsyntax_nocaret
-
def syntax_error_bad_indentation(self):
- compile("def spam():\n print 1\n print 2", "?", "exec")
+ compile("def spam():\n print(1)\n print(2)", "?", "exec")
def test_caret(self):
err = self.get_exception_format(self.syntax_error_with_caret,
SyntaxError)
- self.assertTrue(len(err) == 4)
+ self.assertEqual(len(err), 4)
self.assertTrue(err[1].strip() == "return x!")
self.assertIn("^", err[2]) # third line has caret
- self.assertTrue(err[1].find("!") == err[2].find("^")) # in the right place
+ self.assertEqual(err[1].find("!"), err[2].find("^")) # in the right place
err = self.get_exception_format(self.syntax_error_with_caret_2,
SyntaxError)
@@ -50,66 +47,18 @@ class TracebackCases(unittest.TestCase):
self.assertTrue(err[1].find("+") == err[2].find("^")) # in the right place
def test_nocaret(self):
- if is_jython:
- # jython adds a caret in this case (why shouldn't it?)
- return
- err = self.get_exception_format(self.syntax_error_without_caret,
- SyntaxError)
- self.assertTrue(len(err) == 3)
- self.assertTrue(err[1].strip() == "[x for x in x] = x")
+ exc = SyntaxError("error", ("x.py", 23, None, "bad syntax"))
+ err = traceback.format_exception_only(SyntaxError, exc)
+ self.assertEqual(len(err), 3)
+ self.assertEqual(err[1].strip(), "bad syntax")
def test_bad_indentation(self):
err = self.get_exception_format(self.syntax_error_bad_indentation,
IndentationError)
- self.assertTrue(len(err) == 4)
- self.assertTrue(err[1].strip() == "print 2")
+ self.assertEqual(len(err), 4)
+ self.assertEqual(err[1].strip(), "print(2)")
self.assertIn("^", err[2])
- self.assertTrue(err[1].find("2") == err[2].find("^"))
-
- def test_bug737473(self):
- import os, tempfile, time
-
- savedpath = sys.path[:]
- testdir = tempfile.mkdtemp()
- try:
- sys.path.insert(0, testdir)
- testfile = os.path.join(testdir, 'test_bug737473.py')
- print >> open(testfile, 'w'), """
-def test():
- raise ValueError"""
-
- if 'test_bug737473' in sys.modules:
- del sys.modules['test_bug737473']
- import test_bug737473
-
- try:
- test_bug737473.test()
- except ValueError:
- # this loads source code to linecache
- traceback.extract_tb(sys.exc_traceback)
-
- # If this test runs too quickly, test_bug737473.py's mtime
- # attribute will remain unchanged even if the file is rewritten.
- # Consequently, the file would not reload. So, added a sleep()
- # delay to assure that a new, distinct timestamp is written.
- # Since WinME with FAT32 has multisecond resolution, more than
- # three seconds are needed for this test to pass reliably :-(
- time.sleep(4)
-
- print >> open(testfile, 'w'), """
-def test():
- raise NotImplementedError"""
- reload(test_bug737473)
- try:
- test_bug737473.test()
- except NotImplementedError:
- src = traceback.extract_tb(sys.exc_traceback)[-1][-1]
- self.assertEqual(src, 'raise NotImplementedError')
- finally:
- sys.path[:] = savedpath
- for f in os.listdir(testdir):
- os.unlink(os.path.join(testdir, f))
- os.rmdir(testdir)
+ self.assertEqual(err[1].find(")"), err[2].find("^"))
def test_base_exception(self):
# Test that exceptions derived from BaseException are formatted right
@@ -117,56 +66,86 @@ def test():
lst = traceback.format_exception_only(e.__class__, e)
self.assertEqual(lst, ['KeyboardInterrupt\n'])
- # String exceptions are deprecated, but legal. The quirky form with
- # separate "type" and "value" tends to break things, because
- # not isinstance(value, type)
- # and a string cannot be the first argument to issubclass.
- #
- # Note that sys.last_type and sys.last_value do not get set if an
- # exception is caught, so we sort of cheat and just emulate them.
- #
- # test_string_exception1 is equivalent to
- #
- # >>> raise "String Exception"
- #
- # test_string_exception2 is equivalent to
- #
- # >>> raise "String Exception", "String Value"
- #
- def test_string_exception1(self):
- str_type = "String Exception"
- err = traceback.format_exception_only(str_type, None)
- self.assertEqual(len(err), 1)
- self.assertEqual(err[0], str_type + '\n')
-
- def test_string_exception2(self):
- str_type = "String Exception"
- str_value = "String Value"
- err = traceback.format_exception_only(str_type, str_value)
- self.assertEqual(len(err), 1)
- self.assertEqual(err[0], str_type + ': ' + str_value + '\n')
-
def test_format_exception_only_bad__str__(self):
class X(Exception):
def __str__(self):
- 1 // 0
+ 1/0
err = traceback.format_exception_only(X, X())
self.assertEqual(len(err), 1)
str_value = '<unprintable %s object>' % X.__name__
- self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n')
+ if X.__module__ in ('__main__', 'builtins'):
+ str_name = X.__name__
+ else:
+ str_name = '.'.join([X.__module__, X.__name__])
+ self.assertEqual(err[0], "%s: %s\n" % (str_name, str_value))
def test_without_exception(self):
err = traceback.format_exception_only(None, None)
self.assertEqual(err, ['None\n'])
- def test_unicode(self):
- err = AssertionError('\xff')
- lines = traceback.format_exception_only(type(err), err)
- self.assertEqual(lines, ['AssertionError: \xff\n'])
-
- err = AssertionError(u'\xe9')
- lines = traceback.format_exception_only(type(err), err)
- self.assertEqual(lines, ['AssertionError: \\xe9\n'])
+ def test_encoded_file(self):
+ # Test that tracebacks are correctly printed for encoded source files:
+ # - correct line number (Issue2384)
+ # - respect file encoding (Issue3975)
+ import tempfile, sys, subprocess, os
+
+ # The spawned subprocess has its stdout redirected to a PIPE, and its
+ # encoding may be different from the current interpreter, on Windows
+ # at least.
+ process = subprocess.Popen([sys.executable, "-c",
+ "import sys; print(sys.stdout.encoding)"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT)
+ stdout, stderr = process.communicate()
+ output_encoding = str(stdout, 'ascii').splitlines()[0]
+
+ def do_test(firstlines, message, charset, lineno):
+ # Raise the message in a subprocess, and catch the output
+ try:
+ output = open(TESTFN, "w", encoding=charset)
+ output.write("""{0}if 1:
+ import traceback;
+ raise RuntimeError('{1}')
+ """.format(firstlines, message))
+ output.close()
+ process = subprocess.Popen([sys.executable, TESTFN],
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout, stderr = process.communicate()
+ stdout = stdout.decode(output_encoding).splitlines()
+ finally:
+ unlink(TESTFN)
+
+ # The source lines are encoded with the 'backslashreplace' handler
+ encoded_message = message.encode(output_encoding,
+ 'backslashreplace')
+ # and we just decoded them with the output_encoding.
+ message_ascii = encoded_message.decode(output_encoding)
+
+ err_line = "raise RuntimeError('{0}')".format(message_ascii)
+ err_msg = "RuntimeError: {0}".format(message_ascii)
+
+ self.assertIn(("line %s" % lineno), stdout[1],
+ "Invalid line number: {0!r} instead of {1}".format(
+ stdout[1], lineno))
+ self.assertTrue(stdout[2].endswith(err_line),
+ "Invalid traceback line: {0!r} instead of {1!r}".format(
+ stdout[2], err_line))
+ self.assertTrue(stdout[3] == err_msg,
+ "Invalid error message: {0!r} instead of {1!r}".format(
+ stdout[3], err_msg))
+
+ do_test("", "foo", "ascii", 3)
+ for charset in ("ascii", "iso-8859-1", "utf-8", "GBK"):
+ if charset == "ascii":
+ text = "foo"
+ elif charset == "GBK":
+ text = "\u4E02\u5100"
+ else:
+ text = "h\xe9 ho"
+ do_test("# coding: {0}\n".format(charset),
+ text, charset, 4)
+ do_test("#!shebang\n# coding: {0}\n".format(charset),
+ text, charset, 5)
class TracebackFormatTests(unittest.TestCase):
@@ -196,9 +175,162 @@ class TracebackFormatTests(unittest.TestCase):
self.assertTrue(source_line.startswith(' raise'))
-def test_main():
- run_unittest(TracebackCases, TracebackFormatTests)
+cause_message = (
+ "\nThe above exception was the direct cause "
+ "of the following exception:\n\n")
+
+context_message = (
+ "\nDuring handling of the above exception, "
+ "another exception occurred:\n\n")
+boundaries = re.compile(
+ '(%s|%s)' % (re.escape(cause_message), re.escape(context_message)))
+
+
+class BaseExceptionReportingTests:
+
+ def get_exception(self, exception_or_callable):
+ if isinstance(exception_or_callable, Exception):
+ return exception_or_callable
+ try:
+ exception_or_callable()
+ except Exception as e:
+ return e
+
+ def zero_div(self):
+ 1/0 # In zero_div
+
+ def check_zero_div(self, msg):
+ lines = msg.splitlines()
+ self.assertTrue(lines[-3].startswith(' File'))
+ self.assertIn('1/0 # In zero_div', lines[-2])
+ self.assertTrue(lines[-1].startswith('ZeroDivisionError'), lines[-1])
+
+ def test_simple(self):
+ try:
+ 1/0 # Marker
+ except ZeroDivisionError as _:
+ e = _
+ lines = self.get_report(e).splitlines()
+ self.assertEqual(len(lines), 4)
+ self.assertTrue(lines[0].startswith('Traceback'))
+ self.assertTrue(lines[1].startswith(' File'))
+ self.assertIn('1/0 # Marker', lines[2])
+ self.assertTrue(lines[3].startswith('ZeroDivisionError'))
+
+ def test_cause(self):
+ def inner_raise():
+ try:
+ self.zero_div()
+ except ZeroDivisionError as e:
+ raise KeyError from e
+ def outer_raise():
+ inner_raise() # Marker
+ blocks = boundaries.split(self.get_report(outer_raise))
+ self.assertEqual(len(blocks), 3)
+ self.assertEqual(blocks[1], cause_message)
+ self.check_zero_div(blocks[0])
+ self.assertIn('inner_raise() # Marker', blocks[2])
+
+ def test_context(self):
+ def inner_raise():
+ try:
+ self.zero_div()
+ except ZeroDivisionError:
+ raise KeyError
+ def outer_raise():
+ inner_raise() # Marker
+ blocks = boundaries.split(self.get_report(outer_raise))
+ self.assertEqual(len(blocks), 3)
+ self.assertEqual(blocks[1], context_message)
+ self.check_zero_div(blocks[0])
+ self.assertIn('inner_raise() # Marker', blocks[2])
+
+ def test_cause_and_context(self):
+ # When both a cause and a context are set, only the cause should be
+ # displayed and the context should be muted.
+ def inner_raise():
+ try:
+ self.zero_div()
+ except ZeroDivisionError as _e:
+ e = _e
+ try:
+ xyzzy
+ except NameError:
+ raise KeyError from e
+ def outer_raise():
+ inner_raise() # Marker
+ blocks = boundaries.split(self.get_report(outer_raise))
+ self.assertEqual(len(blocks), 3)
+ self.assertEqual(blocks[1], cause_message)
+ self.check_zero_div(blocks[0])
+ self.assertIn('inner_raise() # Marker', blocks[2])
+
+ def test_cause_recursive(self):
+ def inner_raise():
+ try:
+ try:
+ self.zero_div()
+ except ZeroDivisionError as e:
+ z = e
+ raise KeyError from e
+ except KeyError as e:
+ raise z from e
+ def outer_raise():
+ inner_raise() # Marker
+ blocks = boundaries.split(self.get_report(outer_raise))
+ self.assertEqual(len(blocks), 3)
+ self.assertEqual(blocks[1], cause_message)
+ # The first block is the KeyError raised from the ZeroDivisionError
+ self.assertIn('raise KeyError from e', blocks[0])
+ self.assertNotIn('1/0', blocks[0])
+ # The second block (apart from the boundary) is the ZeroDivisionError
+ # re-raised from the KeyError
+ self.assertIn('inner_raise() # Marker', blocks[2])
+ self.check_zero_div(blocks[2])
+
+ def test_syntax_error_offset_at_eol(self):
+ # See #10186.
+ def e():
+ raise SyntaxError('', ('', 0, 5, 'hello'))
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg[-2], " ^")
+ def e():
+ exec("x = 5 | 4 |")
+ msg = self.get_report(e).splitlines()
+ self.assertEqual(msg[-2], ' ^')
+
+
+class PyExcReportingTests(BaseExceptionReportingTests, unittest.TestCase):
+ #
+ # This checks reporting through the 'traceback' module, with both
+ # format_exception() and print_exception().
+ #
+
+ def get_report(self, e):
+ e = self.get_exception(e)
+ s = ''.join(
+ traceback.format_exception(type(e), e, e.__traceback__))
+ with captured_output("stderr") as sio:
+ traceback.print_exception(type(e), e, e.__traceback__)
+ self.assertEqual(sio.getvalue(), s)
+ return s
+
+
+class CExcReportingTests(BaseExceptionReportingTests, unittest.TestCase):
+ #
+ # This checks built-in reporting by the interpreter.
+ #
+
+ def get_report(self, e):
+ e = self.get_exception(e)
+ with captured_output("stderr") as s:
+ exception_print(e)
+ return s.getvalue()
+
+
+def test_main():
+ run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_transformer.py b/Lib/test/test_transformer.py
deleted file mode 100644
index 1891ac486e6..00000000000
--- a/Lib/test/test_transformer.py
+++ /dev/null
@@ -1,38 +0,0 @@
-import unittest
-from test import test_support
-
-# Silence Py3k warning
-test_support.import_module('compiler', deprecated=True)
-from compiler import transformer, ast
-from compiler import compile
-
-class Tests(unittest.TestCase):
-
- def testMultipleLHS(self):
- """ Test multiple targets on the left hand side. """
-
- snippets = ['a, b = 1, 2',
- '(a, b) = 1, 2',
- '((a, b), c) = (1, 2), 3']
-
- for s in snippets:
- a = transformer.parse(s)
- self.assertIsInstance(a, ast.Module)
- child1 = a.getChildNodes()[0]
- self.assertIsInstance(child1, ast.Stmt)
- child2 = child1.getChildNodes()[0]
- self.assertIsInstance(child2, ast.Assign)
-
- # This actually tests the compiler, but it's a way to assure the ast
- # is correct
- c = compile(s, '<string>', 'single')
- vals = {}
- exec c in vals
- assert vals['a'] == 1
- assert vals['b'] == 2
-
-def test_main():
- test_support.run_unittest(Tests)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_ttk_guionly.py b/Lib/test/test_ttk_guionly.py
index e0368be6a08..b8c1a4ca100 100644
--- a/Lib/test/test_ttk_guionly.py
+++ b/Lib/test/test_ttk_guionly.py
@@ -1,43 +1,37 @@
import os
import unittest
-from test import test_support
+from test import support
# Skip this test if _tkinter wasn't built.
-test_support.import_module('_tkinter')
-
-this_dir = os.path.dirname(os.path.abspath(__file__))
-lib_tk_test = os.path.abspath(os.path.join(this_dir, os.path.pardir,
- 'lib-tk', 'test'))
-
-with test_support.DirsOnSysPath(lib_tk_test):
- import runtktests
+support.import_module('_tkinter')
# Skip test if tk cannot be initialized.
-runtktests.check_tk_availability()
+from tkinter.test.support import check_tk_availability
+check_tk_availability()
-import ttk
from _tkinter import TclError
+from tkinter import ttk
+from tkinter.test import runtktests
+from tkinter.test.support import get_tk_root
try:
ttk.Button()
-except TclError, msg:
+except TclError as msg:
# assuming ttk is not available
raise unittest.SkipTest("ttk not available: %s" % msg)
def test_main(enable_gui=False):
if enable_gui:
- if test_support.use_resources is None:
- test_support.use_resources = ['gui']
- elif 'gui' not in test_support.use_resources:
- test_support.use_resources.append('gui')
+ if support.use_resources is None:
+ support.use_resources = ['gui']
+ elif 'gui' not in support.use_resources:
+ support.use_resources.append('gui')
- with test_support.DirsOnSysPath(lib_tk_test):
- from test_ttk.support import get_tk_root
- try:
- test_support.run_unittest(
+ try:
+ support.run_unittest(
*runtktests.get_tests(text=False, packages=['test_ttk']))
- finally:
- get_tk_root().destroy()
+ finally:
+ get_tk_root().destroy()
if __name__ == '__main__':
test_main(enable_gui=True)
diff --git a/Lib/test/test_ttk_textonly.py b/Lib/test/test_ttk_textonly.py
index ed92043d7bf..566fc9d09a0 100644
--- a/Lib/test/test_ttk_textonly.py
+++ b/Lib/test/test_ttk_textonly.py
@@ -1,18 +1,13 @@
import os
-from test import test_support
+from test import support
# Skip this test if _tkinter does not exist.
-test_support.import_module('_tkinter')
+support.import_module('_tkinter')
-this_dir = os.path.dirname(os.path.abspath(__file__))
-lib_tk_test = os.path.abspath(os.path.join(this_dir, '..', 'lib-tk', 'test'))
-
-with test_support.DirsOnSysPath(lib_tk_test):
- import runtktests
+from tkinter.test import runtktests
def test_main():
- with test_support.DirsOnSysPath(lib_tk_test):
- test_support.run_unittest(
+ support.run_unittest(
*runtktests.get_tests(gui=False, packages=['test_ttk']))
if __name__ == '__main__':
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
index 0c308f0e06c..6e934fb8825 100644
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -1,4 +1,4 @@
-from test import test_support, seq_tests
+from test import support, seq_tests
import gc
@@ -6,7 +6,7 @@ class TupleTest(seq_tests.CommonTest):
type2test = tuple
def test_constructors(self):
- super(TupleTest, self).test_constructors()
+ super().test_constructors()
# calling built-in types without argument must return empty
self.assertEqual(tuple(), ())
t0_3 = (0, 1, 2, 3)
@@ -18,25 +18,25 @@ class TupleTest(seq_tests.CommonTest):
self.assertEqual(tuple('spam'), ('s', 'p', 'a', 'm'))
def test_truth(self):
- super(TupleTest, self).test_truth()
+ super().test_truth()
self.assertTrue(not ())
self.assertTrue((42, ))
def test_len(self):
- super(TupleTest, self).test_len()
+ super().test_len()
self.assertEqual(len(()), 0)
self.assertEqual(len((0,)), 1)
self.assertEqual(len((0, 1, 2)), 3)
def test_iadd(self):
- super(TupleTest, self).test_iadd()
+ super().test_iadd()
u = (0, 1)
u2 = u
u += (2, 3)
self.assertTrue(u is not u2)
def test_imul(self):
- super(TupleTest, self).test_imul()
+ super().test_imul()
u = (0, 1)
u2 = u
u *= 3
@@ -47,7 +47,7 @@ class TupleTest(seq_tests.CommonTest):
def f():
for i in range(1000):
yield i
- self.assertEqual(list(tuple(f())), range(1000))
+ self.assertEqual(list(tuple(f())), list(range(1000)))
def test_hash(self):
# See SF bug 942952: Weakness in tuple hash
@@ -66,10 +66,10 @@ class TupleTest(seq_tests.CommonTest):
# is sorely suspect.
N=50
- base = range(N)
+ base = list(range(N))
xp = [(i, j) for i in base for j in base]
inps = base + [(i, j) for i in base for j in xp] + \
- [(i, j) for i in xp for j in base] + xp + zip(base)
+ [(i, j) for i in xp for j in base] + xp + list(zip(base))
collisions = len(inps) - len(set(map(hash, inps)))
self.assertTrue(collisions <= 15)
@@ -96,7 +96,7 @@ class TupleTest(seq_tests.CommonTest):
gc.collect()
self.assertTrue(gc.is_tracked(t), t)
- @test_support.cpython_only
+ @support.cpython_only
def test_track_literals(self):
# Test GC-optimization of tuple literals
x, y, z = 1.5, "a", []
@@ -137,25 +137,43 @@ class TupleTest(seq_tests.CommonTest):
self._tracked(tp(tuple([obj]) for obj in [x, y, z]))
self._tracked(tuple(tp([obj]) for obj in [x, y, z]))
- @test_support.cpython_only
+ @support.cpython_only
def test_track_dynamic(self):
# Test GC-optimization of dynamically constructed tuples.
self.check_track_dynamic(tuple, False)
- @test_support.cpython_only
+ @support.cpython_only
def test_track_subtypes(self):
# Tuple subtypes must always be tracked
class MyTuple(tuple):
pass
self.check_track_dynamic(MyTuple, True)
- @test_support.cpython_only
+ @support.cpython_only
def test_bug7466(self):
# Trying to untrack an unfinished tuple could crash Python
self._not_tracked(tuple(gc.collect() for i in range(101)))
+ def test_repr_large(self):
+ # Check the repr of large list objects
+ def check(n):
+ l = (0,) * n
+ s = repr(l)
+ self.assertEqual(s,
+ '(' + ', '.join(['0'] * n) + ')')
+ check(10) # check our checking code
+ check(1000000)
+
+ def test_no_comdat_folding(self):
+ # Issue 8847: In the PGO build, the MSVC linker's COMDAT folding
+ # optimization causes failures in code that relies on distinct
+ # function addresses.
+ class T(tuple): pass
+ with self.assertRaises(TypeError):
+ [3,] + T((1,2))
+
def test_main():
- test_support.run_unittest(TupleTest)
+ support.run_unittest(TupleTest)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_typechecks.py b/Lib/test/test_typechecks.py
index 83f0114b1b8..17cd5d32ede 100644
--- a/Lib/test/test_typechecks.py
+++ b/Lib/test/test_typechecks.py
@@ -1,7 +1,7 @@
"""Unit tests for __instancecheck__ and __subclasscheck__."""
import unittest
-from test import test_support
+from test import support
class ABC(type):
@@ -9,23 +9,19 @@ class ABC(type):
def __instancecheck__(cls, inst):
"""Implement isinstance(inst, cls)."""
return any(cls.__subclasscheck__(c)
- for c in set([type(inst), inst.__class__]))
+ for c in {type(inst), inst.__class__})
def __subclasscheck__(cls, sub):
"""Implement issubclass(sub, cls)."""
- candidates = cls.__dict__.get("__subclass__", set()) | set([cls])
+ candidates = cls.__dict__.get("__subclass__", set()) | {cls}
return any(c in candidates for c in sub.mro())
-class Integer:
-
- __metaclass__ = ABC
-
- __subclass__ = set([int])
+class Integer(metaclass=ABC):
+ __subclass__ = {int}
class SubInt(Integer):
-
pass
@@ -71,22 +67,9 @@ class TypeChecksTest(unittest.TestCase):
self.assertEqual(isinstance(42, SubInt), False)
self.assertEqual(isinstance(42, (SubInt,)), False)
- def test_oldstyle(self):
- # These should just be ignored.
- class X:
- def __instancecheck__(self, inst):
- return True
- def __subclasscheck__(self, cls):
- return True
- class Sub(X): pass
- self.assertNotIsInstance(3, X)
- self.assertIsInstance(X(), X)
- self.assertFalse(issubclass(int, X))
- self.assertTrue(issubclass(Sub, X))
-
def test_main():
- test_support.run_unittest(TypeChecksTest)
+ support.run_unittest(TypeChecksTest)
if __name__ == "__main__":
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py
index 60f6d2f1e29..8a98a035671 100644
--- a/Lib/test/test_types.py
+++ b/Lib/test/test_types.py
@@ -1,7 +1,6 @@
# Python test set -- part 6, built-in types
-from test.test_support import run_unittest, have_unicode, run_with_locale, \
- check_py3k_warnings
+from test.support import run_unittest, run_with_locale
import unittest
import sys
import locale
@@ -11,11 +10,9 @@ class TypesTests(unittest.TestCase):
def test_truth_values(self):
if None: self.fail('None is true instead of false')
if 0: self.fail('0 is true instead of false')
- if 0L: self.fail('0L is true instead of false')
if 0.0: self.fail('0.0 is true instead of false')
if '': self.fail('\'\' is true instead of false')
if not 1: self.fail('1 is false instead of true')
- if not 1L: self.fail('1L is false instead of true')
if not 1.0: self.fail('1.0 is false instead of true')
if not 'x': self.fail('\'x\' is false instead of true')
if not {'x': 1}: self.fail('{\'x\': 1} is false instead of true')
@@ -36,8 +33,6 @@ class TypesTests(unittest.TestCase):
def test_comparisons(self):
if 0 < 1 <= 1 == 1 >= 1 > 0 != 1: pass
else: self.fail('int comparisons failed')
- if 0L < 1L <= 1L == 1L >= 1L > 0L != 1L: pass
- else: self.fail('long int comparisons failed')
if 0.0 < 1.0 <= 1.0 == 1.0 >= 1.0 > 0.0 != 1.0: pass
else: self.fail('float comparisons failed')
if '' < 'a' <= 'a' == 'a' < 'abc' < 'abd' < 'b': pass
@@ -62,31 +57,26 @@ class TypesTests(unittest.TestCase):
except ZeroDivisionError: pass
else: self.fail("5.0 % 0.0 didn't raise ZeroDivisionError")
- try: 5 / 0L
+ try: 5 / 0
except ZeroDivisionError: pass
- else: self.fail("5 / 0L didn't raise ZeroDivisionError")
+ else: self.fail("5 / 0 didn't raise ZeroDivisionError")
- try: 5 // 0L
+ try: 5 // 0
except ZeroDivisionError: pass
- else: self.fail("5 // 0L didn't raise ZeroDivisionError")
+ else: self.fail("5 // 0 didn't raise ZeroDivisionError")
- try: 5 % 0L
+ try: 5 % 0
except ZeroDivisionError: pass
- else: self.fail("5 % 0L didn't raise ZeroDivisionError")
+ else: self.fail("5 % 0 didn't raise ZeroDivisionError")
def test_numeric_types(self):
- if 0 != 0L or 0 != 0.0 or 0L != 0.0: self.fail('mixed comparisons')
- if 1 != 1L or 1 != 1.0 or 1L != 1.0: self.fail('mixed comparisons')
- if -1 != -1L or -1 != -1.0 or -1L != -1.0:
- self.fail('int/long/float value not equal')
+ if 0 != 0.0 or 1 != 1.0 or -1 != -1.0:
+ self.fail('int/float value not equal')
# calling built-in types without argument must return 0
if int() != 0: self.fail('int() does not return 0')
- if long() != 0L: self.fail('long() does not return 0L')
if float() != 0.0: self.fail('float() does not return 0.0')
if int(1.9) == 1 == int(1.1) and int(-1.1) == -1 == int(-1.9): pass
else: self.fail('int() does not round properly')
- if long(1.9) == 1L == long(1.1) and long(-1.1) == -1L == long(-1.9): pass
- else: self.fail('long() does not round properly')
if float(1) == 1.0 and float(-1) == -1.0 and float(0) == 0.0: pass
else: self.fail('float() does not work properly')
@@ -132,7 +122,7 @@ class TypesTests(unittest.TestCase):
if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912):
self.fail('int mul commutativity')
# And another.
- m = -sys.maxint - 1
+ m = -sys.maxsize - 1
for divisor in 1, 2, 4, 8, 16, 32:
j = m // divisor
prod = divisor * j
@@ -141,58 +131,38 @@ class TypesTests(unittest.TestCase):
if type(prod) is not int:
self.fail("expected type(prod) to be int, not %r" %
type(prod))
- # Check for expected * overflow to long.
+ # Check for unified integral type
for divisor in 1, 2, 4, 8, 16, 32:
j = m // divisor - 1
prod = divisor * j
- if type(prod) is not long:
- self.fail("expected type(%r) to be long, not %r" %
+ if type(prod) is not int:
+ self.fail("expected type(%r) to be int, not %r" %
(prod, type(prod)))
- # Check for expected * overflow to long.
- m = sys.maxint
+ # Check for unified integral type
+ m = sys.maxsize
for divisor in 1, 2, 4, 8, 16, 32:
j = m // divisor + 1
prod = divisor * j
- if type(prod) is not long:
- self.fail("expected type(%r) to be long, not %r" %
+ if type(prod) is not int:
+ self.fail("expected type(%r) to be int, not %r" %
(prod, type(prod)))
- def test_long_integers(self):
- if 12L + 24L != 36L: self.fail('long op')
- if 12L + (-24L) != -12L: self.fail('long op')
- if (-12L) + 24L != 12L: self.fail('long op')
- if (-12L) + (-24L) != -36L: self.fail('long op')
- if not 12L < 24L: self.fail('long op')
- if not -24L < -12L: self.fail('long op')
- x = sys.maxint
- if int(long(x)) != x: self.fail('long op')
- try: y = int(long(x)+1L)
- except OverflowError: self.fail('long op')
- if not isinstance(y, long): self.fail('long op')
- x = -x
- if int(long(x)) != x: self.fail('long op')
- x = x-1
- if int(long(x)) != x: self.fail('long op')
- try: y = int(long(x)-1L)
- except OverflowError: self.fail('long op')
- if not isinstance(y, long): self.fail('long op')
+ x = sys.maxsize
+ self.assertIsInstance(x + 1, int,
+ "(sys.maxsize + 1) should have returned int")
+ self.assertIsInstance(-x - 1, int,
+ "(-sys.maxsize - 1) should have returned int")
+ self.assertIsInstance(-x - 2, int,
+ "(-sys.maxsize - 2) should have returned int")
try: 5 << -5
except ValueError: pass
else: self.fail('int negative shift <<')
- try: 5L << -5L
- except ValueError: pass
- else: self.fail('long negative shift <<')
-
try: 5 >> -5
except ValueError: pass
else: self.fail('int negative shift >>')
- try: 5L >> -5L
- except ValueError: pass
- else: self.fail('long negative shift >>')
-
def test_floats(self):
if 12.0 + 24.0 != 36.0: self.fail('float op')
if 12.0 + (-24.0) != -12.0: self.fail('float op')
@@ -224,82 +194,18 @@ class TypesTests(unittest.TestCase):
self.assertEqual(a[3::-2], '31')
self.assertEqual(a[-100:100:], a)
self.assertEqual(a[100:-100:-1], a[::-1])
- self.assertEqual(a[-100L:100L:2L], '02468')
-
- if have_unicode:
- a = unicode('0123456789', 'ascii')
- self.assertEqual(a[::], a)
- self.assertEqual(a[::2], unicode('02468', 'ascii'))
- self.assertEqual(a[1::2], unicode('13579', 'ascii'))
- self.assertEqual(a[::-1], unicode('9876543210', 'ascii'))
- self.assertEqual(a[::-2], unicode('97531', 'ascii'))
- self.assertEqual(a[3::-2], unicode('31', 'ascii'))
- self.assertEqual(a[-100:100:], a)
- self.assertEqual(a[100:-100:-1], a[::-1])
- self.assertEqual(a[-100L:100L:2L], unicode('02468', 'ascii'))
-
+ self.assertEqual(a[-100:100:2], '02468')
def test_type_function(self):
self.assertRaises(TypeError, type, 1, 2)
self.assertRaises(TypeError, type, 1, 2, 3, 4)
- def test_buffers(self):
- self.assertRaises(ValueError, buffer, 'asdf', -1)
- cmp(buffer("abc"), buffer("def")) # used to raise a warning: tp_compare didn't return -1, 0, or 1
-
- self.assertRaises(TypeError, buffer, None)
-
- a = buffer('asdf')
- hash(a)
- b = a * 5
- if a == b:
- self.fail('buffers should not be equal')
- if str(b) != ('asdf' * 5):
- self.fail('repeated buffer has wrong content')
- if str(a * 0) != '':
- self.fail('repeated buffer zero times has wrong content')
- if str(a + buffer('def')) != 'asdfdef':
- self.fail('concatenation of buffers yields wrong content')
- if str(buffer(a)) != 'asdf':
- self.fail('composing buffers failed')
- if str(buffer(a, 2)) != 'df':
- self.fail('specifying buffer offset failed')
- if str(buffer(a, 0, 2)) != 'as':
- self.fail('specifying buffer size failed')
- if str(buffer(a, 1, 2)) != 'sd':
- self.fail('specifying buffer offset and size failed')
- self.assertRaises(ValueError, buffer, buffer('asdf', 1), -1)
- if str(buffer(buffer('asdf', 0, 2), 0)) != 'as':
- self.fail('composing length-specified buffer failed')
- if str(buffer(buffer('asdf', 0, 2), 0, 5000)) != 'as':
- self.fail('composing length-specified buffer failed')
- if str(buffer(buffer('asdf', 0, 2), 0, -1)) != 'as':
- self.fail('composing length-specified buffer failed')
- if str(buffer(buffer('asdf', 0, 2), 1, 2)) != 's':
- self.fail('composing length-specified buffer failed')
-
- try: a[1] = 'g'
- except TypeError: pass
- else: self.fail("buffer assignment should raise TypeError")
-
- try: a[0:1] = 'g'
- except TypeError: pass
- else: self.fail("buffer slice assignment should raise TypeError")
-
- # array.array() returns an object that does not implement a char buffer,
- # something which int() uses for conversion.
- import array
- try: int(buffer(array.array('c')))
- except TypeError: pass
- else: self.fail("char buffer (at C level) not working")
-
def test_int__format__(self):
def test(i, format_spec, result):
- # just make sure I'm not accidentally checking longs
+ # just make sure we have the unified type for integers
assert type(i) == int
assert type(format_spec) == str
self.assertEqual(i.__format__(format_spec), result)
- self.assertEqual(i.__format__(unicode(format_spec)), result)
test(123456789, 'd', '123456789')
test(123456789, 'd', '123456789')
@@ -405,9 +311,22 @@ class TypesTests(unittest.TestCase):
test(123456, "#012X", '0X000001E240')
test(-123456, "#012X", '-0X00001E240')
+ test(123, ',', '123')
+ test(-123, ',', '-123')
+ test(1234, ',', '1,234')
+ test(-1234, ',', '-1,234')
+ test(123456, ',', '123,456')
+ test(-123456, ',', '-123,456')
+ test(1234567, ',', '1,234,567')
+ test(-1234567, ',', '-1,234,567')
+
# issue 5782, commas with no specifier type
test(1234, '010,', '00,001,234')
+ # Unified type for integers
+ test(10**100, 'd', '1' + '0' * 100)
+ test(10**100+100, 'd', '1' + '0' * 97 + '100')
+
# make sure these are errors
# precision disallowed
@@ -417,7 +336,8 @@ class TypesTests(unittest.TestCase):
# format spec must be string
self.assertRaises(TypeError, 3 .__format__, None)
self.assertRaises(TypeError, 3 .__format__, 0)
-
+ # can't have ',' with 'n'
+ self.assertRaises(ValueError, 3 .__format__, ",n")
# can't have ',' with 'c'
self.assertRaises(ValueError, 3 .__format__, ",c")
@@ -447,114 +367,6 @@ class TypesTests(unittest.TestCase):
test(123456, "1=20", '11111111111111123456')
test(123456, "*=20", '**************123456')
- def test_long__format__(self):
- def test(i, format_spec, result):
- # make sure we're not accidentally checking ints
- assert type(i) == long
- assert type(format_spec) == str
- self.assertEqual(i.__format__(format_spec), result)
- self.assertEqual(i.__format__(unicode(format_spec)), result)
-
- test(10**100, 'd', '1' + '0' * 100)
- test(10**100+100, 'd', '1' + '0' * 97 + '100')
-
- test(123456789L, 'd', '123456789')
- test(123456789L, 'd', '123456789')
-
- # sign and aligning are interdependent
- test(1L, "-", '1')
- test(-1L, "-", '-1')
- test(1L, "-3", ' 1')
- test(-1L, "-3", ' -1')
- test(1L, "+3", ' +1')
- test(-1L, "+3", ' -1')
- test(1L, " 3", ' 1')
- test(-1L, " 3", ' -1')
- test(1L, " ", ' 1')
- test(-1L, " ", '-1')
-
- test(1L, 'c', '\01')
-
- # hex
- test(3L, "x", "3")
- test(3L, "X", "3")
- test(1234L, "x", "4d2")
- test(-1234L, "x", "-4d2")
- test(1234L, "8x", " 4d2")
- test(-1234L, "8x", " -4d2")
- test(1234L, "x", "4d2")
- test(-1234L, "x", "-4d2")
- test(-3L, "x", "-3")
- test(-3L, "X", "-3")
- test(long('be', 16), "x", "be")
- test(long('be', 16), "X", "BE")
- test(-long('be', 16), "x", "-be")
- test(-long('be', 16), "X", "-BE")
-
- # octal
- test(3L, "o", "3")
- test(-3L, "o", "-3")
- test(65L, "o", "101")
- test(-65L, "o", "-101")
- test(1234L, "o", "2322")
- test(-1234L, "o", "-2322")
- test(1234L, "-o", "2322")
- test(-1234L, "-o", "-2322")
- test(1234L, " o", " 2322")
- test(-1234L, " o", "-2322")
- test(1234L, "+o", "+2322")
- test(-1234L, "+o", "-2322")
-
- # binary
- test(3L, "b", "11")
- test(-3L, "b", "-11")
- test(1234L, "b", "10011010010")
- test(-1234L, "b", "-10011010010")
- test(1234L, "-b", "10011010010")
- test(-1234L, "-b", "-10011010010")
- test(1234L, " b", " 10011010010")
- test(-1234L, " b", "-10011010010")
- test(1234L, "+b", "+10011010010")
- test(-1234L, "+b", "-10011010010")
-
- # make sure these are errors
-
- # precision disallowed
- self.assertRaises(ValueError, 3L .__format__, "1.3")
- # sign not allowed with 'c'
- self.assertRaises(ValueError, 3L .__format__, "+c")
- # format spec must be string
- self.assertRaises(TypeError, 3L .__format__, None)
- self.assertRaises(TypeError, 3L .__format__, 0)
- # alternate specifier in wrong place
- self.assertRaises(ValueError, 1L .__format__, "#+5x")
- self.assertRaises(ValueError, 1L .__format__, "+5#x")
-
- # ensure that only int and float type specifiers work
- for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] +
- [chr(x) for x in range(ord('A'), ord('Z')+1)]):
- if not format_spec in 'bcdoxXeEfFgGn%':
- self.assertRaises(ValueError, 0L .__format__, format_spec)
- self.assertRaises(ValueError, 1L .__format__, format_spec)
- self.assertRaises(ValueError, (-1L) .__format__, format_spec)
-
- # ensure that float type specifiers work; format converts
- # the long to a float
- for format_spec in 'eEfFgG%':
- for value in [0L, 1L, -1L, 100L, -100L, 1234567890L, -1234567890L]:
- self.assertEqual(value.__format__(format_spec),
- float(value).__format__(format_spec))
- # Issue 6902
- test(123456L, "0<20", '12345600000000000000')
- test(123456L, "1<20", '12345611111111111111')
- test(123456L, "*<20", '123456**************')
- test(123456L, "0>20", '00000000000000123456')
- test(123456L, "1>20", '11111111111111123456')
- test(123456L, "*>20", '**************123456')
- test(123456L, "0=20", '00000000000000123456')
- test(123456L, "1=20", '11111111111111123456')
- test(123456L, "*=20", '**************123456')
-
@run_with_locale('LC_NUMERIC', 'en_US.UTF8')
def test_float__format__locale(self):
# test locale support for __format__ code 'n'
@@ -584,14 +396,9 @@ class TypesTests(unittest.TestCase):
self.assertEqual(len(format(0, cfmt)), len(format(x, cfmt)))
def test_float__format__(self):
- # these should be rewritten to use both format(x, spec) and
- # x.__format__(spec)
-
def test(f, format_spec, result):
- assert type(f) == float
- assert type(format_spec) == str
self.assertEqual(f.__format__(format_spec), result)
- self.assertEqual(f.__format__(unicode(format_spec)), result)
+ self.assertEqual(format(f, format_spec), result)
test(0.0, 'f', '0.000000')
@@ -623,7 +430,7 @@ class TypesTests(unittest.TestCase):
test( 1.0, '+f', '+1.000000')
test(-1.0, '+f', '-1.000000')
- # Python versions <= 2.6 switched from 'f' to 'g' formatting for
+ # Python versions <= 3.0 switched from 'f' to 'g' formatting for
# values larger than 1e50. No longer.
f = 1.1234e90
for fmt in 'f', 'F':
@@ -655,8 +462,6 @@ class TypesTests(unittest.TestCase):
# So, just use a sign flag
test(1e200, '+g', '+1e+200')
test(1e200, '+', '+1e+200')
- test(1.1e200, '+g', '+1.1e+200')
- test(1.1e200, '+', '+1.1e+200')
test(1.1e200, '+g', '+1.1e+200')
test(1.1e200, '+', '+1.1e+200')
@@ -687,7 +492,7 @@ class TypesTests(unittest.TestCase):
test(-123456.12341234, '017,f', '-0,123,456.123412')
test(-123456.12341234, '013,.2f', '-0,123,456.12')
- # % formatting
+ # % formatting
test(-1.0, '%', '-100.000000%')
# format spec must be string
@@ -707,9 +512,27 @@ class TypesTests(unittest.TestCase):
self.assertRaises(ValueError, format, 1e-100, format_spec)
self.assertRaises(ValueError, format, -1e-100, format_spec)
- # Alternate formatting is not supported
- self.assertRaises(ValueError, format, 0.0, '#')
- self.assertRaises(ValueError, format, 0.0, '#20f')
+ # Alternate float formatting
+ test(1.0, '.0e', '1e+00')
+ test(1.0, '#.0e', '1.e+00')
+ test(1.0, '.0f', '1')
+ test(1.0, '#.0f', '1.')
+ test(1.1, 'g', '1.1')
+ test(1.1, '#g', '1.10000')
+ test(1.0, '.0%', '100%')
+ test(1.0, '#.0%', '100.%')
+
+ # Issue 7094: Alternate formatting (specified by #)
+ test(1.0, '0e', '1.000000e+00')
+ test(1.0, '#0e', '1.000000e+00')
+ test(1.0, '0f', '1.000000' )
+ test(1.0, '#0f', '1.000000')
+ test(1.0, '.1e', '1.0e+00')
+ test(1.0, '#.1e', '1.0e+00')
+ test(1.0, '.1f', '1.0')
+ test(1.0, '#.1f', '1.0')
+ test(1.0, '.1%', '100.0%')
+ test(1.0, '#.1%', '100.0%')
# Issue 6902
test(12345.6, "0<20", '12345.60000000000000')
@@ -747,10 +570,7 @@ class TypesTests(unittest.TestCase):
def test_main():
- with check_py3k_warnings(
- ("buffer.. not supported", DeprecationWarning),
- ("classic long division", DeprecationWarning)):
- run_unittest(TypesTests)
+ run_unittest(TypesTests)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_ucn.py b/Lib/test/test_ucn.py
index 775044b9915..fd620f01e47 100644
--- a/Lib/test/test_ucn.py
+++ b/Lib/test/test_ucn.py
@@ -9,7 +9,7 @@ Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
import unittest
-from test import test_support
+from test import support
class UnicodeNamesTest(unittest.TestCase):
@@ -17,7 +17,7 @@ class UnicodeNamesTest(unittest.TestCase):
# Helper that put all \N escapes inside eval'd raw strings,
# to make sure this script runs even if the compiler
# chokes on \N escapes
- res = eval(ur'u"\N{%s}"' % name)
+ res = eval(r'"\N{%s}"' % name)
self.assertEqual(res, code)
return res
@@ -51,94 +51,98 @@ class UnicodeNamesTest(unittest.TestCase):
"LATIN SMALL LETTER P",
"FULL STOP"
]
- string = u"The rEd fOx ate the sheep."
+ string = "The rEd fOx ate the sheep."
self.assertEqual(
- u"".join([self.checkletter(*args) for args in zip(chars, string)]),
+ "".join([self.checkletter(*args) for args in zip(chars, string)]),
string
)
def test_ascii_letters(self):
import unicodedata
- for char in "".join(map(chr, xrange(ord("a"), ord("z")))):
+ for char in "".join(map(chr, range(ord("a"), ord("z")))):
name = "LATIN SMALL LETTER %s" % char.upper()
code = unicodedata.lookup(name)
self.assertEqual(unicodedata.name(code), name)
def test_hangul_syllables(self):
- self.checkletter("HANGUL SYLLABLE GA", u"\uac00")
- self.checkletter("HANGUL SYLLABLE GGWEOSS", u"\uafe8")
- self.checkletter("HANGUL SYLLABLE DOLS", u"\ub3d0")
- self.checkletter("HANGUL SYLLABLE RYAN", u"\ub7b8")
- self.checkletter("HANGUL SYLLABLE MWIK", u"\ubba0")
- self.checkletter("HANGUL SYLLABLE BBWAEM", u"\ubf88")
- self.checkletter("HANGUL SYLLABLE SSEOL", u"\uc370")
- self.checkletter("HANGUL SYLLABLE YI", u"\uc758")
- self.checkletter("HANGUL SYLLABLE JJYOSS", u"\ucb40")
- self.checkletter("HANGUL SYLLABLE KYEOLS", u"\ucf28")
- self.checkletter("HANGUL SYLLABLE PAN", u"\ud310")
- self.checkletter("HANGUL SYLLABLE HWEOK", u"\ud6f8")
- self.checkletter("HANGUL SYLLABLE HIH", u"\ud7a3")
+ self.checkletter("HANGUL SYLLABLE GA", "\uac00")
+ self.checkletter("HANGUL SYLLABLE GGWEOSS", "\uafe8")
+ self.checkletter("HANGUL SYLLABLE DOLS", "\ub3d0")
+ self.checkletter("HANGUL SYLLABLE RYAN", "\ub7b8")
+ self.checkletter("HANGUL SYLLABLE MWIK", "\ubba0")
+ self.checkletter("HANGUL SYLLABLE BBWAEM", "\ubf88")
+ self.checkletter("HANGUL SYLLABLE SSEOL", "\uc370")
+ self.checkletter("HANGUL SYLLABLE YI", "\uc758")
+ self.checkletter("HANGUL SYLLABLE JJYOSS", "\ucb40")
+ self.checkletter("HANGUL SYLLABLE KYEOLS", "\ucf28")
+ self.checkletter("HANGUL SYLLABLE PAN", "\ud310")
+ self.checkletter("HANGUL SYLLABLE HWEOK", "\ud6f8")
+ self.checkletter("HANGUL SYLLABLE HIH", "\ud7a3")
import unicodedata
- self.assertRaises(ValueError, unicodedata.name, u"\ud7a4")
+ self.assertRaises(ValueError, unicodedata.name, "\ud7a4")
def test_cjk_unified_ideographs(self):
- self.checkletter("CJK UNIFIED IDEOGRAPH-3400", u"\u3400")
- self.checkletter("CJK UNIFIED IDEOGRAPH-4DB5", u"\u4db5")
- self.checkletter("CJK UNIFIED IDEOGRAPH-4E00", u"\u4e00")
- self.checkletter("CJK UNIFIED IDEOGRAPH-9FA5", u"\u9fa5")
- self.checkletter("CJK UNIFIED IDEOGRAPH-20000", u"\U00020000")
- self.checkletter("CJK UNIFIED IDEOGRAPH-2A6D6", u"\U0002a6d6")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-3400", "\u3400")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-4DB5", "\u4db5")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-4E00", "\u4e00")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-9FCB", "\u9fCB")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-20000", "\U00020000")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2A6D6", "\U0002a6d6")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2A700", "\U0002A700")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B734", "\U0002B734")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B740", "\U0002B740")
+ self.checkletter("CJK UNIFIED IDEOGRAPH-2B81D", "\U0002B81D")
def test_bmp_characters(self):
import unicodedata
count = 0
- for code in xrange(0x10000):
- char = unichr(code)
+ for code in range(0x10000):
+ char = chr(code)
name = unicodedata.name(char, None)
if name is not None:
self.assertEqual(unicodedata.lookup(name), char)
count += 1
def test_misc_symbols(self):
- self.checkletter("PILCROW SIGN", u"\u00b6")
- self.checkletter("REPLACEMENT CHARACTER", u"\uFFFD")
- self.checkletter("HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK", u"\uFF9F")
- self.checkletter("FULLWIDTH LATIN SMALL LETTER A", u"\uFF41")
+ self.checkletter("PILCROW SIGN", "\u00b6")
+ self.checkletter("REPLACEMENT CHARACTER", "\uFFFD")
+ self.checkletter("HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK", "\uFF9F")
+ self.checkletter("FULLWIDTH LATIN SMALL LETTER A", "\uFF41")
def test_errors(self):
import unicodedata
self.assertRaises(TypeError, unicodedata.name)
- self.assertRaises(TypeError, unicodedata.name, u'xx')
+ self.assertRaises(TypeError, unicodedata.name, 'xx')
self.assertRaises(TypeError, unicodedata.lookup)
- self.assertRaises(KeyError, unicodedata.lookup, u'unknown')
+ self.assertRaises(KeyError, unicodedata.lookup, 'unknown')
- def test_strict_eror_handling(self):
+ def test_strict_error_handling(self):
# bogus character name
self.assertRaises(
UnicodeError,
- unicode, "\\N{blah}", 'unicode-escape', 'strict'
+ str, b"\\N{blah}", 'unicode-escape', 'strict'
)
# long bogus character name
self.assertRaises(
UnicodeError,
- unicode, "\\N{%s}" % ("x" * 100000), 'unicode-escape', 'strict'
+ str, bytes("\\N{%s}" % ("x" * 100000), "ascii"), 'unicode-escape', 'strict'
)
# missing closing brace
self.assertRaises(
UnicodeError,
- unicode, "\\N{SPACE", 'unicode-escape', 'strict'
+ str, b"\\N{SPACE", 'unicode-escape', 'strict'
)
# missing opening brace
self.assertRaises(
UnicodeError,
- unicode, "\\NSPACE", 'unicode-escape', 'strict'
+ str, b"\\NSPACE", 'unicode-escape', 'strict'
)
def test_main():
- test_support.run_unittest(UnicodeNamesTest)
+ support.run_unittest(UnicodeNamesTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_unary.py b/Lib/test/test_unary.py
index 598fca8fcff..b8355647fdf 100644
--- a/Lib/test/test_unary.py
+++ b/Lib/test/test_unary.py
@@ -1,37 +1,37 @@
"""Test compiler changes for unary ops (+, -, ~) introduced in Python 2.2"""
import unittest
-from test.test_support import run_unittest, have_unicode
+from test.support import run_unittest
class UnaryOpTestCase(unittest.TestCase):
def test_negative(self):
self.assertTrue(-2 == 0 - 2)
- self.assertTrue(-0 == 0)
- self.assertTrue(--2 == 2)
- self.assertTrue(-2L == 0 - 2L)
+ self.assertEqual(-0, 0)
+ self.assertEqual(--2, 2)
+ self.assertTrue(-2 == 0 - 2)
self.assertTrue(-2.0 == 0 - 2.0)
self.assertTrue(-2j == 0 - 2j)
def test_positive(self):
- self.assertTrue(+2 == 2)
- self.assertTrue(+0 == 0)
- self.assertTrue(++2 == 2)
- self.assertTrue(+2L == 2L)
- self.assertTrue(+2.0 == 2.0)
- self.assertTrue(+2j == 2j)
+ self.assertEqual(+2, 2)
+ self.assertEqual(+0, 0)
+ self.assertEqual(++2, 2)
+ self.assertEqual(+2, 2)
+ self.assertEqual(+2.0, 2.0)
+ self.assertEqual(+2j, 2j)
def test_invert(self):
self.assertTrue(-2 == 0 - 2)
- self.assertTrue(-0 == 0)
- self.assertTrue(--2 == 2)
- self.assertTrue(-2L == 0 - 2L)
+ self.assertEqual(-0, 0)
+ self.assertEqual(--2, 2)
+ self.assertTrue(-2 == 0 - 2)
def test_no_overflow(self):
nines = "9" * 32
- self.assertTrue(eval("+" + nines) == eval("+" + nines + "L"))
- self.assertTrue(eval("-" + nines) == eval("-" + nines + "L"))
- self.assertTrue(eval("~" + nines) == eval("~" + nines + "L"))
+ self.assertTrue(eval("+" + nines) == 10**32-1)
+ self.assertTrue(eval("-" + nines) == -(10**32-1))
+ self.assertTrue(eval("~" + nines) == ~(10**32-1))
def test_negation_of_exponentiation(self):
# Make sure '**' does the right thing; these form a
@@ -43,9 +43,8 @@ class UnaryOpTestCase(unittest.TestCase):
def test_bad_types(self):
for op in '+', '-', '~':
+ self.assertRaises(TypeError, eval, op + "b'a'")
self.assertRaises(TypeError, eval, op + "'a'")
- if have_unicode:
- self.assertRaises(TypeError, eval, op + "u'a'")
self.assertRaises(TypeError, eval, "~2j")
self.assertRaises(TypeError, eval, "~2.0")
diff --git a/Lib/test/test_undocumented_details.py b/Lib/test/test_undocumented_details.py
deleted file mode 100644
index a8fc280c67a..00000000000
--- a/Lib/test/test_undocumented_details.py
+++ /dev/null
@@ -1,39 +0,0 @@
-from test.test_support import run_unittest, check_py3k_warnings
-import unittest
-
-class TestImplementationComparisons(unittest.TestCase):
-
- def test_type_comparisons(self):
- self.assertTrue(str < int or str > int)
- self.assertTrue(int <= str or int >= str)
- self.assertTrue(cmp(int, str) != 0)
- self.assertTrue(int is int)
- self.assertTrue(str == str)
- self.assertTrue(int != str)
-
- def test_cell_comparisons(self):
- def f(x):
- if x:
- y = 1
- def g():
- return x
- def h():
- return y
- return g, h
- g, h = f(0)
- g_cell, = g.func_closure
- h_cell, = h.func_closure
- self.assertTrue(h_cell < g_cell)
- self.assertTrue(g_cell >= h_cell)
- self.assertEqual(cmp(g_cell, h_cell), 1)
- self.assertTrue(g_cell is g_cell)
- self.assertTrue(g_cell == g_cell)
- self.assertTrue(h_cell == h_cell)
- self.assertTrue(g_cell != h_cell)
-
-def test_main():
- with check_py3k_warnings():
- run_unittest(TestImplementationComparisons)
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index e44fe03d240..47af8b938f9 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -5,11 +5,13 @@ Written by Marc-Andre Lemburg (mal@lemburg.com).
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
"""#"
-import sys
-import struct
import codecs
+import struct
+import sys
import unittest
-from test import test_support, string_tests
+import warnings
+from test import support, string_tests
+import _string
# decorator to skip tests on narrow builds
requires_wide_build = unittest.skipIf(sys.maxunicode == 65535,
@@ -33,22 +35,11 @@ def search_function(encoding):
return None
codecs.register(search_function)
-class UnicodeTest(
- string_tests.CommonTest,
- string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrUnicodeTest,
- ):
- type2test = unicode
-
- def assertEqual(self, first, second, msg=None):
- # strict assertEqual method: reject implicit bytes/unicode equality
- super(UnicodeTest, self).assertEqual(first, second, msg)
- if isinstance(first, unicode) or isinstance(second, unicode):
- self.assertIsInstance(first, unicode)
- self.assertIsInstance(second, unicode)
- elif isinstance(first, str) or isinstance(second, str):
- self.assertIsInstance(first, str)
- self.assertIsInstance(second, str)
+class UnicodeTest(string_tests.CommonTest,
+ string_tests.MixinStrUnicodeUserStringTest,
+ string_tests.MixinStrUnicodeTest):
+
+ type2test = str
def checkequalnofix(self, result, object, methodname, *args):
method = getattr(object, methodname)
@@ -59,9 +50,9 @@ class UnicodeTest(
# if the original is returned make sure that
# this doesn't happen with subclasses
if realresult is object:
- class usub(unicode):
+ class usub(str):
def __repr__(self):
- return 'usub(%r)' % unicode.__repr__(self)
+ return 'usub(%r)' % str.__repr__(self)
object = usub(object)
method = getattr(object, methodname)
realresult = method(*args)
@@ -69,30 +60,32 @@ class UnicodeTest(
self.assertTrue(object is not realresult)
def test_literals(self):
- self.assertEqual(u'\xff', u'\u00ff')
- self.assertEqual(u'\uffff', u'\U0000ffff')
- self.assertRaises(SyntaxError, eval, 'u\'\\Ufffffffe\'')
- self.assertRaises(SyntaxError, eval, 'u\'\\Uffffffff\'')
- self.assertRaises(SyntaxError, eval, 'u\'\\U%08x\'' % 0x110000)
-
- def test_repr(self):
+ self.assertEqual('\xff', '\u00ff')
+ self.assertEqual('\uffff', '\U0000ffff')
+ self.assertRaises(SyntaxError, eval, '\'\\Ufffffffe\'')
+ self.assertRaises(SyntaxError, eval, '\'\\Uffffffff\'')
+ self.assertRaises(SyntaxError, eval, '\'\\U%08x\'' % 0x110000)
+ # raw strings should not have unicode escapes
+ self.assertNotEqual(r"\u0020", " ")
+
+ def test_ascii(self):
if not sys.platform.startswith('java'):
# Test basic sanity of repr()
- self.assertEqual(repr(u'abc'), "u'abc'")
- self.assertEqual(repr(u'ab\\c'), "u'ab\\\\c'")
- self.assertEqual(repr(u'ab\\'), "u'ab\\\\'")
- self.assertEqual(repr(u'\\c'), "u'\\\\c'")
- self.assertEqual(repr(u'\\'), "u'\\\\'")
- self.assertEqual(repr(u'\n'), "u'\\n'")
- self.assertEqual(repr(u'\r'), "u'\\r'")
- self.assertEqual(repr(u'\t'), "u'\\t'")
- self.assertEqual(repr(u'\b'), "u'\\x08'")
- self.assertEqual(repr(u"'\""), """u'\\'"'""")
- self.assertEqual(repr(u"'\""), """u'\\'"'""")
- self.assertEqual(repr(u"'"), '''u"'"''')
- self.assertEqual(repr(u'"'), """u'"'""")
+ self.assertEqual(ascii('abc'), "'abc'")
+ self.assertEqual(ascii('ab\\c'), "'ab\\\\c'")
+ self.assertEqual(ascii('ab\\'), "'ab\\\\'")
+ self.assertEqual(ascii('\\c'), "'\\\\c'")
+ self.assertEqual(ascii('\\'), "'\\\\'")
+ self.assertEqual(ascii('\n'), "'\\n'")
+ self.assertEqual(ascii('\r'), "'\\r'")
+ self.assertEqual(ascii('\t'), "'\\t'")
+ self.assertEqual(ascii('\b'), "'\\x08'")
+ self.assertEqual(ascii("'\""), """'\\'"'""")
+ self.assertEqual(ascii("'\""), """'\\'"'""")
+ self.assertEqual(ascii("'"), '''"'"''')
+ self.assertEqual(ascii('"'), """'"'""")
latin1repr = (
- "u'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
+ "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
"\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
"\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
"JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
@@ -106,603 +99,958 @@ class UnicodeTest(
"\\xe2\\xe3\\xe4\\xe5\\xe6\\xe7\\xe8\\xe9\\xea\\xeb\\xec\\xed\\xee\\xef"
"\\xf0\\xf1\\xf2\\xf3\\xf4\\xf5\\xf6\\xf7\\xf8\\xf9\\xfa\\xfb\\xfc\\xfd"
"\\xfe\\xff'")
- testrepr = repr(u''.join(map(unichr, xrange(256))))
+ testrepr = ascii(''.join(map(chr, range(256))))
+ self.assertEqual(testrepr, latin1repr)
+ # Test ascii works on wide unicode escapes without overflow.
+ self.assertEqual(ascii("\U00010000" * 39 + "\uffff" * 4096),
+ ascii("\U00010000" * 39 + "\uffff" * 4096))
+
+ class WrongRepr:
+ def __repr__(self):
+ return b'byte-repr'
+ self.assertRaises(TypeError, ascii, WrongRepr())
+
+ def test_repr(self):
+ if not sys.platform.startswith('java'):
+ # Test basic sanity of repr()
+ self.assertEqual(repr('abc'), "'abc'")
+ self.assertEqual(repr('ab\\c'), "'ab\\\\c'")
+ self.assertEqual(repr('ab\\'), "'ab\\\\'")
+ self.assertEqual(repr('\\c'), "'\\\\c'")
+ self.assertEqual(repr('\\'), "'\\\\'")
+ self.assertEqual(repr('\n'), "'\\n'")
+ self.assertEqual(repr('\r'), "'\\r'")
+ self.assertEqual(repr('\t'), "'\\t'")
+ self.assertEqual(repr('\b'), "'\\x08'")
+ self.assertEqual(repr("'\""), """'\\'"'""")
+ self.assertEqual(repr("'\""), """'\\'"'""")
+ self.assertEqual(repr("'"), '''"'"''')
+ self.assertEqual(repr('"'), """'"'""")
+ latin1repr = (
+ "'\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\t\\n\\x0b\\x0c\\r"
+ "\\x0e\\x0f\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a"
+ "\\x1b\\x1c\\x1d\\x1e\\x1f !\"#$%&\\'()*+,-./0123456789:;<=>?@ABCDEFGHI"
+ "JKLMNOPQRSTUVWXYZ[\\\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\\x7f"
+ "\\x80\\x81\\x82\\x83\\x84\\x85\\x86\\x87\\x88\\x89\\x8a\\x8b\\x8c\\x8d"
+ "\\x8e\\x8f\\x90\\x91\\x92\\x93\\x94\\x95\\x96\\x97\\x98\\x99\\x9a\\x9b"
+ "\\x9c\\x9d\\x9e\\x9f\\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9"
+ "\xaa\xab\xac\\xad\xae\xaf\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7"
+ "\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf\xc0\xc1\xc2\xc3\xc4\xc5"
+ "\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf\xd0\xd1\xd2\xd3"
+ "\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xe0\xe1"
+ "\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
+ "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd"
+ "\xfe\xff'")
+ testrepr = repr(''.join(map(chr, range(256))))
self.assertEqual(testrepr, latin1repr)
# Test repr works on wide unicode escapes without overflow.
- self.assertEqual(repr(u"\U00010000" * 39 + u"\uffff" * 4096),
- repr(u"\U00010000" * 39 + u"\uffff" * 4096))
+ self.assertEqual(repr("\U00010000" * 39 + "\uffff" * 4096),
+ repr("\U00010000" * 39 + "\uffff" * 4096))
+
+ class WrongRepr:
+ def __repr__(self):
+ return b'byte-repr'
+ self.assertRaises(TypeError, repr, WrongRepr())
+ def test_iterators(self):
+ # Make sure unicode objects have an __iter__ method
+ it = "\u1111\u2222\u3333".__iter__()
+ self.assertEqual(next(it), "\u1111")
+ self.assertEqual(next(it), "\u2222")
+ self.assertEqual(next(it), "\u3333")
+ self.assertRaises(StopIteration, next, it)
def test_count(self):
string_tests.CommonTest.test_count(self)
# check mixed argument types
- self.checkequalnofix(3, 'aaa', 'count', u'a')
- self.checkequalnofix(0, 'aaa', 'count', u'b')
- self.checkequalnofix(3, u'aaa', 'count', 'a')
- self.checkequalnofix(0, u'aaa', 'count', 'b')
- self.checkequalnofix(0, u'aaa', 'count', 'b')
- self.checkequalnofix(1, u'aaa', 'count', 'a', -1)
- self.checkequalnofix(3, u'aaa', 'count', 'a', -10)
- self.checkequalnofix(2, u'aaa', 'count', 'a', 0, -1)
- self.checkequalnofix(0, u'aaa', 'count', 'a', 0, -10)
+ self.checkequalnofix(3, 'aaa', 'count', 'a')
+ self.checkequalnofix(0, 'aaa', 'count', 'b')
+ self.checkequalnofix(3, 'aaa', 'count', 'a')
+ self.checkequalnofix(0, 'aaa', 'count', 'b')
+ self.checkequalnofix(0, 'aaa', 'count', 'b')
+ self.checkequalnofix(1, 'aaa', 'count', 'a', -1)
+ self.checkequalnofix(3, 'aaa', 'count', 'a', -10)
+ self.checkequalnofix(2, 'aaa', 'count', 'a', 0, -1)
+ self.checkequalnofix(0, 'aaa', 'count', 'a', 0, -10)
def test_find(self):
- self.checkequalnofix(0, u'abcdefghiabc', 'find', u'abc')
- self.checkequalnofix(9, u'abcdefghiabc', 'find', u'abc', 1)
- self.checkequalnofix(-1, u'abcdefghiabc', 'find', u'def', 4)
+ string_tests.CommonTest.test_find(self)
+ self.checkequalnofix(0, 'abcdefghiabc', 'find', 'abc')
+ self.checkequalnofix(9, 'abcdefghiabc', 'find', 'abc', 1)
+ self.checkequalnofix(-1, 'abcdefghiabc', 'find', 'def', 4)
- self.assertRaises(TypeError, u'hello'.find)
- self.assertRaises(TypeError, u'hello'.find, 42)
+ self.assertRaises(TypeError, 'hello'.find)
+ self.assertRaises(TypeError, 'hello'.find, 42)
def test_rfind(self):
string_tests.CommonTest.test_rfind(self)
# check mixed argument types
- self.checkequalnofix(9, 'abcdefghiabc', 'rfind', u'abc')
- self.checkequalnofix(12, 'abcdefghiabc', 'rfind', u'')
- self.checkequalnofix(12, u'abcdefghiabc', 'rfind', '')
+ self.checkequalnofix(9, 'abcdefghiabc', 'rfind', 'abc')
+ self.checkequalnofix(12, 'abcdefghiabc', 'rfind', '')
+ self.checkequalnofix(12, 'abcdefghiabc', 'rfind', '')
def test_index(self):
string_tests.CommonTest.test_index(self)
- # check mixed argument types
- for (t1, t2) in ((str, unicode), (unicode, str)):
- self.checkequalnofix(0, t1('abcdefghiabc'), 'index', t2(''))
- self.checkequalnofix(3, t1('abcdefghiabc'), 'index', t2('def'))
- self.checkequalnofix(0, t1('abcdefghiabc'), 'index', t2('abc'))
- self.checkequalnofix(9, t1('abcdefghiabc'), 'index', t2('abc'), 1)
- self.assertRaises(ValueError, t1('abcdefghiabc').index, t2('hib'))
- self.assertRaises(ValueError, t1('abcdefghiab').index, t2('abc'), 1)
- self.assertRaises(ValueError, t1('abcdefghi').index, t2('ghi'), 8)
- self.assertRaises(ValueError, t1('abcdefghi').index, t2('ghi'), -1)
+ self.checkequalnofix(0, 'abcdefghiabc', 'index', '')
+ self.checkequalnofix(3, 'abcdefghiabc', 'index', 'def')
+ self.checkequalnofix(0, 'abcdefghiabc', 'index', 'abc')
+ self.checkequalnofix(9, 'abcdefghiabc', 'index', 'abc', 1)
+ self.assertRaises(ValueError, 'abcdefghiabc'.index, 'hib')
+ self.assertRaises(ValueError, 'abcdefghiab'.index, 'abc', 1)
+ self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', 8)
+ self.assertRaises(ValueError, 'abcdefghi'.index, 'ghi', -1)
def test_rindex(self):
string_tests.CommonTest.test_rindex(self)
- # check mixed argument types
- for (t1, t2) in ((str, unicode), (unicode, str)):
- self.checkequalnofix(12, t1('abcdefghiabc'), 'rindex', t2(''))
- self.checkequalnofix(3, t1('abcdefghiabc'), 'rindex', t2('def'))
- self.checkequalnofix(9, t1('abcdefghiabc'), 'rindex', t2('abc'))
- self.checkequalnofix(0, t1('abcdefghiabc'), 'rindex', t2('abc'), 0, -1)
-
- self.assertRaises(ValueError, t1('abcdefghiabc').rindex, t2('hib'))
- self.assertRaises(ValueError, t1('defghiabc').rindex, t2('def'), 1)
- self.assertRaises(ValueError, t1('defghiabc').rindex, t2('abc'), 0, -1)
- self.assertRaises(ValueError, t1('abcdefghi').rindex, t2('ghi'), 0, 8)
- self.assertRaises(ValueError, t1('abcdefghi').rindex, t2('ghi'), 0, -1)
-
- def test_translate(self):
- self.checkequalnofix(u'bbbc', u'abababc', 'translate', {ord('a'):None})
- self.checkequalnofix(u'iiic', u'abababc', 'translate', {ord('a'):None, ord('b'):ord('i')})
- self.checkequalnofix(u'iiix', u'abababc', 'translate', {ord('a'):None, ord('b'):ord('i'), ord('c'):u'x'})
- self.checkequalnofix(u'<i><i><i>c', u'abababc', 'translate', {ord('a'):None, ord('b'):u'<i>'})
- self.checkequalnofix(u'c', u'abababc', 'translate', {ord('a'):None, ord('b'):u''})
- self.checkequalnofix(u'xyyx', u'xzx', 'translate', {ord('z'):u'yy'})
-
- self.assertRaises(TypeError, u'hello'.translate)
- self.assertRaises(TypeError, u'abababc'.translate, {ord('a'):''})
+ self.checkequalnofix(12, 'abcdefghiabc', 'rindex', '')
+ self.checkequalnofix(3, 'abcdefghiabc', 'rindex', 'def')
+ self.checkequalnofix(9, 'abcdefghiabc', 'rindex', 'abc')
+ self.checkequalnofix(0, 'abcdefghiabc', 'rindex', 'abc', 0, -1)
+
+ self.assertRaises(ValueError, 'abcdefghiabc'.rindex, 'hib')
+ self.assertRaises(ValueError, 'defghiabc'.rindex, 'def', 1)
+ self.assertRaises(ValueError, 'defghiabc'.rindex, 'abc', 0, -1)
+ self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, 8)
+ self.assertRaises(ValueError, 'abcdefghi'.rindex, 'ghi', 0, -1)
+
+ def test_maketrans_translate(self):
+ # these work with plain translate()
+ self.checkequalnofix('bbbc', 'abababc', 'translate',
+ {ord('a'): None})
+ self.checkequalnofix('iiic', 'abababc', 'translate',
+ {ord('a'): None, ord('b'): ord('i')})
+ self.checkequalnofix('iiix', 'abababc', 'translate',
+ {ord('a'): None, ord('b'): ord('i'), ord('c'): 'x'})
+ self.checkequalnofix('c', 'abababc', 'translate',
+ {ord('a'): None, ord('b'): ''})
+ self.checkequalnofix('xyyx', 'xzx', 'translate',
+ {ord('z'): 'yy'})
+ # this needs maketrans()
+ self.checkequalnofix('abababc', 'abababc', 'translate',
+ {'b': '<i>'})
+ tbl = self.type2test.maketrans({'a': None, 'b': '<i>'})
+ self.checkequalnofix('<i><i><i>c', 'abababc', 'translate', tbl)
+ # test alternative way of calling maketrans()
+ tbl = self.type2test.maketrans('abc', 'xyz', 'd')
+ self.checkequalnofix('xyzzy', 'abdcdcbdddd', 'translate', tbl)
+
+ self.assertRaises(TypeError, self.type2test.maketrans)
+ self.assertRaises(ValueError, self.type2test.maketrans, 'abc', 'defg')
+ self.assertRaises(TypeError, self.type2test.maketrans, 2, 'def')
+ self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 2)
+ self.assertRaises(TypeError, self.type2test.maketrans, 'abc', 'def', 2)
+ self.assertRaises(ValueError, self.type2test.maketrans, {'xy': 2})
+ self.assertRaises(TypeError, self.type2test.maketrans, {(1,): 2})
+
+ self.assertRaises(TypeError, 'hello'.translate)
+ self.assertRaises(TypeError, 'abababc'.translate, 'abc', 'xyz')
def test_split(self):
string_tests.CommonTest.test_split(self)
# Mixed arguments
- self.checkequalnofix([u'a', u'b', u'c', u'd'], u'a//b//c//d', 'split', '//')
- self.checkequalnofix([u'a', u'b', u'c', u'd'], 'a//b//c//d', 'split', u'//')
- self.checkequalnofix([u'endcase ', u''], u'endcase test', 'split', 'test')
+ self.checkequalnofix(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//')
+ self.checkequalnofix(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//')
+ self.checkequalnofix(['endcase ', ''], 'endcase test', 'split', 'test')
def test_join(self):
string_tests.MixinStrUnicodeUserStringTest.test_join(self)
+ class MyWrapper:
+ def __init__(self, sval): self.sval = sval
+ def __str__(self): return self.sval
+
# mixed arguments
- self.checkequalnofix(u'a b c d', u' ', 'join', ['a', 'b', u'c', u'd'])
- self.checkequalnofix(u'abcd', u'', 'join', (u'a', u'b', u'c', u'd'))
- self.checkequalnofix(u'w x y z', u' ', 'join', string_tests.Sequence('wxyz'))
- self.checkequalnofix(u'a b c d', ' ', 'join', [u'a', u'b', u'c', u'd'])
- self.checkequalnofix(u'a b c d', ' ', 'join', ['a', 'b', u'c', u'd'])
- self.checkequalnofix(u'abcd', '', 'join', (u'a', u'b', u'c', u'd'))
- self.checkequalnofix(u'w x y z', ' ', 'join', string_tests.Sequence(u'wxyz'))
-
- def test_strip(self):
- string_tests.CommonTest.test_strip(self)
- self.assertRaises(UnicodeError, u"hello".strip, "\xff")
+ self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
+ self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
+ self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz'))
+ self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
+ self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
+ self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
+ self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz'))
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', MyWrapper('foo')])
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', '3', bytes()])
+ self.checkraises(TypeError, ' ', 'join', [1, 2, 3])
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', 3])
def test_replace(self):
string_tests.CommonTest.test_replace(self)
# method call forwarded from str implementation because of unicode argument
- self.checkequalnofix(u'one@two!three!', 'one!two!three!', 'replace', u'!', u'@', 1)
- self.assertRaises(TypeError, 'replace'.replace, u"r", 42)
+ self.checkequalnofix('one@two!three!', 'one!two!three!', 'replace', '!', '@', 1)
+ self.assertRaises(TypeError, 'replace'.replace, "r", 42)
+
+ def test_bytes_comparison(self):
+ with support.check_warnings():
+ warnings.simplefilter('ignore', BytesWarning)
+ self.assertEqual('abc' == b'abc', False)
+ self.assertEqual('abc' != b'abc', True)
+ self.assertEqual('abc' == bytearray(b'abc'), False)
+ self.assertEqual('abc' != bytearray(b'abc'), True)
def test_comparison(self):
# Comparisons:
- self.assertTrue(u'abc' == 'abc')
- self.assertTrue('abc' == u'abc')
- self.assertTrue(u'abc' == u'abc')
- self.assertTrue(u'abcd' > 'abc')
- self.assertTrue('abcd' > u'abc')
- self.assertTrue(u'abcd' > u'abc')
- self.assertTrue(u'abc' < 'abcd')
- self.assertTrue('abc' < u'abcd')
- self.assertTrue(u'abc' < u'abcd')
+ self.assertEqual('abc', 'abc')
+ self.assertTrue('abcd' > 'abc')
+ self.assertTrue('abc' < 'abcd')
if 0:
# Move these tests to a Unicode collation module test...
# Testing UTF-16 code point order comparisons...
# No surrogates, no fixup required.
- self.assertTrue(u'\u0061' < u'\u20ac')
+ self.assertTrue('\u0061' < '\u20ac')
# Non surrogate below surrogate value, no fixup required
- self.assertTrue(u'\u0061' < u'\ud800\udc02')
+ self.assertTrue('\u0061' < '\ud800\udc02')
# Non surrogate above surrogate value, fixup required
def test_lecmp(s, s2):
self.assertTrue(s < s2)
def test_fixup(s):
- s2 = u'\ud800\udc01'
+ s2 = '\ud800\udc01'
test_lecmp(s, s2)
- s2 = u'\ud900\udc01'
+ s2 = '\ud900\udc01'
test_lecmp(s, s2)
- s2 = u'\uda00\udc01'
+ s2 = '\uda00\udc01'
test_lecmp(s, s2)
- s2 = u'\udb00\udc01'
+ s2 = '\udb00\udc01'
test_lecmp(s, s2)
- s2 = u'\ud800\udd01'
+ s2 = '\ud800\udd01'
test_lecmp(s, s2)
- s2 = u'\ud900\udd01'
+ s2 = '\ud900\udd01'
test_lecmp(s, s2)
- s2 = u'\uda00\udd01'
+ s2 = '\uda00\udd01'
test_lecmp(s, s2)
- s2 = u'\udb00\udd01'
+ s2 = '\udb00\udd01'
test_lecmp(s, s2)
- s2 = u'\ud800\ude01'
+ s2 = '\ud800\ude01'
test_lecmp(s, s2)
- s2 = u'\ud900\ude01'
+ s2 = '\ud900\ude01'
test_lecmp(s, s2)
- s2 = u'\uda00\ude01'
+ s2 = '\uda00\ude01'
test_lecmp(s, s2)
- s2 = u'\udb00\ude01'
+ s2 = '\udb00\ude01'
test_lecmp(s, s2)
- s2 = u'\ud800\udfff'
+ s2 = '\ud800\udfff'
test_lecmp(s, s2)
- s2 = u'\ud900\udfff'
+ s2 = '\ud900\udfff'
test_lecmp(s, s2)
- s2 = u'\uda00\udfff'
+ s2 = '\uda00\udfff'
test_lecmp(s, s2)
- s2 = u'\udb00\udfff'
+ s2 = '\udb00\udfff'
test_lecmp(s, s2)
- test_fixup(u'\ue000')
- test_fixup(u'\uff61')
+ test_fixup('\ue000')
+ test_fixup('\uff61')
# Surrogates on both sides, no fixup required
- self.assertTrue(u'\ud800\udc02' < u'\ud84d\udc56')
-
- def test_capitalize(self):
- string_tests.CommonTest.test_capitalize(self)
- # check that titlecased chars are lowered correctly
- # \u1ffc is the titlecased char
- self.checkequal(u'\u1ffc\u1ff3\u1ff3\u1ff3',
- u'\u1ff3\u1ff3\u1ffc\u1ffc', 'capitalize')
- # check with cased non-letter chars
- self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
- u'\u24c5\u24ce\u24c9\u24bd\u24c4\u24c3', 'capitalize')
- self.checkequal(u'\u24c5\u24e8\u24e3\u24d7\u24de\u24dd',
- u'\u24df\u24e8\u24e3\u24d7\u24de\u24dd', 'capitalize')
- self.checkequal(u'\u2160\u2171\u2172',
- u'\u2160\u2161\u2162', 'capitalize')
- self.checkequal(u'\u2160\u2171\u2172',
- u'\u2170\u2171\u2172', 'capitalize')
- # check with Ll chars with no upper - nothing changes here
- self.checkequal(u'\u019b\u1d00\u1d86\u0221\u1fb7',
- u'\u019b\u1d00\u1d86\u0221\u1fb7', 'capitalize')
+ self.assertTrue('\ud800\udc02' < '\ud84d\udc56')
def test_islower(self):
string_tests.MixinStrUnicodeUserStringTest.test_islower(self)
- self.checkequalnofix(False, u'\u1FFc', 'islower')
-
- @requires_wide_build
- def test_islower_non_bmp(self):
+ self.checkequalnofix(False, '\u1FFc', 'islower')
# non-BMP, uppercase
- self.assertFalse(u'\U00010401'.islower())
- self.assertFalse(u'\U00010427'.islower())
+ self.assertFalse('\U00010401'.islower())
+ self.assertFalse('\U00010427'.islower())
# non-BMP, lowercase
- self.assertTrue(u'\U00010429'.islower())
- self.assertTrue(u'\U0001044E'.islower())
+ self.assertTrue('\U00010429'.islower())
+ self.assertTrue('\U0001044E'.islower())
# non-BMP, non-cased
- self.assertFalse(u'\U0001F40D'.islower())
- self.assertFalse(u'\U0001F46F'.islower())
+ self.assertFalse('\U0001F40D'.islower())
+ self.assertFalse('\U0001F46F'.islower())
def test_isupper(self):
string_tests.MixinStrUnicodeUserStringTest.test_isupper(self)
if not sys.platform.startswith('java'):
- self.checkequalnofix(False, u'\u1FFc', 'isupper')
-
- @requires_wide_build
- def test_isupper_non_bmp(self):
+ self.checkequalnofix(False, '\u1FFc', 'isupper')
# non-BMP, uppercase
- self.assertTrue(u'\U00010401'.isupper())
- self.assertTrue(u'\U00010427'.isupper())
+ self.assertTrue('\U00010401'.isupper())
+ self.assertTrue('\U00010427'.isupper())
# non-BMP, lowercase
- self.assertFalse(u'\U00010429'.isupper())
- self.assertFalse(u'\U0001044E'.isupper())
+ self.assertFalse('\U00010429'.isupper())
+ self.assertFalse('\U0001044E'.isupper())
# non-BMP, non-cased
- self.assertFalse(u'\U0001F40D'.isupper())
- self.assertFalse(u'\U0001F46F'.isupper())
+ self.assertFalse('\U0001F40D'.isupper())
+ self.assertFalse('\U0001F46F'.isupper())
def test_istitle(self):
string_tests.MixinStrUnicodeUserStringTest.test_istitle(self)
- self.checkequalnofix(True, u'\u1FFc', 'istitle')
- self.checkequalnofix(True, u'Greek \u1FFcitlecases ...', 'istitle')
+ self.checkequalnofix(True, '\u1FFc', 'istitle')
+ self.checkequalnofix(True, 'Greek \u1FFcitlecases ...', 'istitle')
- @requires_wide_build
- def test_istitle_non_bmp(self):
# non-BMP, uppercase + lowercase
- self.assertTrue(u'\U00010401\U00010429'.istitle())
- self.assertTrue(u'\U00010427\U0001044E'.istitle())
+ self.assertTrue('\U00010401\U00010429'.istitle())
+ self.assertTrue('\U00010427\U0001044E'.istitle())
# apparently there are no titlecased (Lt) non-BMP chars in Unicode 6
- for ch in [u'\U00010429', u'\U0001044E', u'\U0001F40D', u'\U0001F46F']:
- self.assertFalse(ch.istitle(), '{!r} is not title'.format(ch))
+ for ch in ['\U00010429', '\U0001044E', '\U0001F40D', '\U0001F46F']:
+ self.assertFalse(ch.istitle(), '{!a} is not title'.format(ch))
def test_isspace(self):
string_tests.MixinStrUnicodeUserStringTest.test_isspace(self)
- self.checkequalnofix(True, u'\u2000', 'isspace')
- self.checkequalnofix(True, u'\u200a', 'isspace')
- self.checkequalnofix(False, u'\u2014', 'isspace')
-
- @requires_wide_build
- def test_isspace_non_bmp(self):
+ self.checkequalnofix(True, '\u2000', 'isspace')
+ self.checkequalnofix(True, '\u200a', 'isspace')
+ self.checkequalnofix(False, '\u2014', 'isspace')
# apparently there are no non-BMP spaces chars in Unicode 6
- for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
- u'\U0001F40D', u'\U0001F46F']:
- self.assertFalse(ch.isspace(), '{!r} is not space.'.format(ch))
+ for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
+ '\U0001F40D', '\U0001F46F']:
+ self.assertFalse(ch.isspace(), '{!a} is not space.'.format(ch))
- @requires_wide_build
- def test_isalnum_non_bmp(self):
- for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
- u'\U0001D7F6', u'\U000104A0', u'\U000104A0', u'\U0001F107']:
- self.assertTrue(ch.isalnum(), '{!r} is alnum.'.format(ch))
+ def test_isalnum(self):
+ string_tests.MixinStrUnicodeUserStringTest.test_isalnum(self)
+ for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
+ '\U0001D7F6', '\U00011066', '\U000104A0', '\U0001F107']:
+ self.assertTrue(ch.isalnum(), '{!a} is alnum.'.format(ch))
def test_isalpha(self):
string_tests.MixinStrUnicodeUserStringTest.test_isalpha(self)
- self.checkequalnofix(True, u'\u1FFc', 'isalpha')
-
- @requires_wide_build
- def test_isalpha_non_bmp(self):
+ self.checkequalnofix(True, '\u1FFc', 'isalpha')
# non-BMP, cased
- self.assertTrue(u'\U00010401'.isalpha())
- self.assertTrue(u'\U00010427'.isalpha())
- self.assertTrue(u'\U00010429'.isalpha())
- self.assertTrue(u'\U0001044E'.isalpha())
+ self.assertTrue('\U00010401'.isalpha())
+ self.assertTrue('\U00010427'.isalpha())
+ self.assertTrue('\U00010429'.isalpha())
+ self.assertTrue('\U0001044E'.isalpha())
# non-BMP, non-cased
- self.assertFalse(u'\U0001F40D'.isalpha())
- self.assertFalse(u'\U0001F46F'.isalpha())
+ self.assertFalse('\U0001F40D'.isalpha())
+ self.assertFalse('\U0001F46F'.isalpha())
def test_isdecimal(self):
- self.checkequalnofix(False, u'', 'isdecimal')
- self.checkequalnofix(False, u'a', 'isdecimal')
- self.checkequalnofix(True, u'0', 'isdecimal')
- self.checkequalnofix(False, u'\u2460', 'isdecimal') # CIRCLED DIGIT ONE
- self.checkequalnofix(False, u'\xbc', 'isdecimal') # VULGAR FRACTION ONE QUARTER
- self.checkequalnofix(True, u'\u0660', 'isdecimal') # ARABIC-INDIC DIGIT ZERO
- self.checkequalnofix(True, u'0123456789', 'isdecimal')
- self.checkequalnofix(False, u'0123456789a', 'isdecimal')
+ self.checkequalnofix(False, '', 'isdecimal')
+ self.checkequalnofix(False, 'a', 'isdecimal')
+ self.checkequalnofix(True, '0', 'isdecimal')
+ self.checkequalnofix(False, '\u2460', 'isdecimal') # CIRCLED DIGIT ONE
+ self.checkequalnofix(False, '\xbc', 'isdecimal') # VULGAR FRACTION ONE QUARTER
+ self.checkequalnofix(True, '\u0660', 'isdecimal') # ARABIC-INDIC DIGIT ZERO
+ self.checkequalnofix(True, '0123456789', 'isdecimal')
+ self.checkequalnofix(False, '0123456789a', 'isdecimal')
self.checkraises(TypeError, 'abc', 'isdecimal', 42)
- @requires_wide_build
- def test_isdecimal_non_bmp(self):
- for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
- u'\U0001F40D', u'\U0001F46F', u'\U00011065', u'\U0001F107']:
- self.assertFalse(ch.isdecimal(), '{!r} is not decimal.'.format(ch))
- for ch in [u'\U0001D7F6', u'\U000104A0', u'\U000104A0']:
- self.assertTrue(ch.isdecimal(), '{!r} is decimal.'.format(ch))
+ for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
+ '\U0001F40D', '\U0001F46F', '\U00011065', '\U0001F107']:
+ self.assertFalse(ch.isdecimal(), '{!a} is not decimal.'.format(ch))
+ for ch in ['\U0001D7F6', '\U00011066', '\U000104A0']:
+ self.assertTrue(ch.isdecimal(), '{!a} is decimal.'.format(ch))
def test_isdigit(self):
string_tests.MixinStrUnicodeUserStringTest.test_isdigit(self)
- self.checkequalnofix(True, u'\u2460', 'isdigit')
- self.checkequalnofix(False, u'\xbc', 'isdigit')
- self.checkequalnofix(True, u'\u0660', 'isdigit')
+ self.checkequalnofix(True, '\u2460', 'isdigit')
+ self.checkequalnofix(False, '\xbc', 'isdigit')
+ self.checkequalnofix(True, '\u0660', 'isdigit')
- @requires_wide_build
- def test_isdigit_non_bmp(self):
- for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
- u'\U0001F40D', u'\U0001F46F', u'\U00011065']:
- self.assertFalse(ch.isdigit(), '{!r} is not a digit.'.format(ch))
- for ch in [u'\U0001D7F6', u'\U000104A0', u'\U000104A0', u'\U0001F107']:
- self.assertTrue(ch.isdigit(), '{!r} is a digit.'.format(ch))
+ for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
+ '\U0001F40D', '\U0001F46F', '\U00011065']:
+ self.assertFalse(ch.isdigit(), '{!a} is not a digit.'.format(ch))
+ for ch in ['\U0001D7F6', '\U00011066', '\U000104A0', '\U0001F107']:
+ self.assertTrue(ch.isdigit(), '{!a} is a digit.'.format(ch))
def test_isnumeric(self):
- self.checkequalnofix(False, u'', 'isnumeric')
- self.checkequalnofix(False, u'a', 'isnumeric')
- self.checkequalnofix(True, u'0', 'isnumeric')
- self.checkequalnofix(True, u'\u2460', 'isnumeric')
- self.checkequalnofix(True, u'\xbc', 'isnumeric')
- self.checkequalnofix(True, u'\u0660', 'isnumeric')
- self.checkequalnofix(True, u'0123456789', 'isnumeric')
- self.checkequalnofix(False, u'0123456789a', 'isnumeric')
-
- self.assertRaises(TypeError, u"abc".isnumeric, 42)
-
- @requires_wide_build
- def test_isnumeric_non_bmp(self):
- for ch in [u'\U00010401', u'\U00010427', u'\U00010429', u'\U0001044E',
- u'\U0001F40D', u'\U0001F46F']:
- self.assertFalse(ch.isnumeric(), '{!r} is not numeric.'.format(ch))
- for ch in [u'\U00010107', u'\U0001D7F6', u'\U00023b1b',
- u'\U000104A0', u'\U0001F107']:
- self.assertTrue(ch.isnumeric(), '{!r} is numeric.'.format(ch))
+ self.checkequalnofix(False, '', 'isnumeric')
+ self.checkequalnofix(False, 'a', 'isnumeric')
+ self.checkequalnofix(True, '0', 'isnumeric')
+ self.checkequalnofix(True, '\u2460', 'isnumeric')
+ self.checkequalnofix(True, '\xbc', 'isnumeric')
+ self.checkequalnofix(True, '\u0660', 'isnumeric')
+ self.checkequalnofix(True, '0123456789', 'isnumeric')
+ self.checkequalnofix(False, '0123456789a', 'isnumeric')
+
+ self.assertRaises(TypeError, "abc".isnumeric, 42)
+
+ for ch in ['\U00010401', '\U00010427', '\U00010429', '\U0001044E',
+ '\U0001F40D', '\U0001F46F']:
+ self.assertFalse(ch.isnumeric(), '{!a} is not numeric.'.format(ch))
+ for ch in ['\U00011065', '\U0001D7F6', '\U00011066',
+ '\U000104A0', '\U0001F107']:
+ self.assertTrue(ch.isnumeric(), '{!a} is numeric.'.format(ch))
+
+ def test_isidentifier(self):
+ self.assertTrue("a".isidentifier())
+ self.assertTrue("Z".isidentifier())
+ self.assertTrue("_".isidentifier())
+ self.assertTrue("b0".isidentifier())
+ self.assertTrue("bc".isidentifier())
+ self.assertTrue("b_".isidentifier())
+ self.assertTrue("µ".isidentifier())
+ self.assertTrue("ð”˜ð”«ð”¦ð” ð”¬ð”¡ð”¢".isidentifier())
+
+ self.assertFalse(" ".isidentifier())
+ self.assertFalse("[".isidentifier())
+ self.assertFalse("©".isidentifier())
+ self.assertFalse("0".isidentifier())
+
+ def test_isprintable(self):
+ self.assertTrue("".isprintable())
+ self.assertTrue(" ".isprintable())
+ self.assertTrue("abcdefg".isprintable())
+ self.assertFalse("abcdefg\n".isprintable())
+ # some defined Unicode character
+ self.assertTrue("\u0374".isprintable())
+ # undefined character
+ self.assertFalse("\u0378".isprintable())
+ # single surrogate character
+ self.assertFalse("\ud800".isprintable())
+
+ self.assertTrue('\U0001F46F'.isprintable())
+ self.assertFalse('\U000E0020'.isprintable())
- @requires_wide_build
def test_surrogates(self):
- # this test actually passes on narrow too, but it's just by accident.
- # Surrogates are seen as non-cased chars, so u'X\uD800X' is as
- # uppercase as 'X X'
- for s in (u'a\uD800b\uDFFF', u'a\uDFFFb\uD800',
- u'a\uD800b\uDFFFa', u'a\uDFFFb\uD800a'):
+ for s in ('a\uD800b\uDFFF', 'a\uDFFFb\uD800',
+ 'a\uD800b\uDFFFa', 'a\uDFFFb\uD800a'):
self.assertTrue(s.islower())
self.assertFalse(s.isupper())
self.assertFalse(s.istitle())
- for s in (u'A\uD800B\uDFFF', u'A\uDFFFB\uD800',
- u'A\uD800B\uDFFFA', u'A\uDFFFB\uD800A'):
+ for s in ('A\uD800B\uDFFF', 'A\uDFFFB\uD800',
+ 'A\uD800B\uDFFFA', 'A\uDFFFB\uD800A'):
self.assertFalse(s.islower())
self.assertTrue(s.isupper())
self.assertTrue(s.istitle())
for meth_name in ('islower', 'isupper', 'istitle'):
- meth = getattr(unicode, meth_name)
- for s in (u'\uD800', u'\uDFFF', u'\uD800\uD800', u'\uDFFF\uDFFF'):
- self.assertFalse(meth(s), '%r.%s() is False' % (s, meth_name))
+ meth = getattr(str, meth_name)
+ for s in ('\uD800', '\uDFFF', '\uD800\uD800', '\uDFFF\uDFFF'):
+ self.assertFalse(meth(s), '%a.%s() is False' % (s, meth_name))
for meth_name in ('isalpha', 'isalnum', 'isdigit', 'isspace',
- 'isdecimal', 'isnumeric'):
- meth = getattr(unicode, meth_name)
- for s in (u'\uD800', u'\uDFFF', u'\uD800\uD800', u'\uDFFF\uDFFF',
- u'a\uD800b\uDFFF', u'a\uDFFFb\uD800',
- u'a\uD800b\uDFFFa', u'a\uDFFFb\uD800a'):
- self.assertFalse(meth(s), '%r.%s() is False' % (s, meth_name))
+ 'isdecimal', 'isnumeric',
+ 'isidentifier', 'isprintable'):
+ meth = getattr(str, meth_name)
+ for s in ('\uD800', '\uDFFF', '\uD800\uD800', '\uDFFF\uDFFF',
+ 'a\uD800b\uDFFF', 'a\uDFFFb\uD800',
+ 'a\uD800b\uDFFFa', 'a\uDFFFb\uD800a'):
+ self.assertFalse(meth(s), '%a.%s() is False' % (s, meth_name))
@requires_wide_build
def test_lower(self):
string_tests.CommonTest.test_lower(self)
- self.assertEqual(u'\U00010427'.lower(), u'\U0001044F')
- self.assertEqual(u'\U00010427\U00010427'.lower(),
- u'\U0001044F\U0001044F')
- self.assertEqual(u'\U00010427\U0001044F'.lower(),
- u'\U0001044F\U0001044F')
- self.assertEqual(u'X\U00010427x\U0001044F'.lower(),
- u'x\U0001044Fx\U0001044F')
+ self.assertEqual('\U00010427'.lower(), '\U0001044F')
+ self.assertEqual('\U00010427\U00010427'.lower(),
+ '\U0001044F\U0001044F')
+ self.assertEqual('\U00010427\U0001044F'.lower(),
+ '\U0001044F\U0001044F')
+ self.assertEqual('X\U00010427x\U0001044F'.lower(),
+ 'x\U0001044Fx\U0001044F')
@requires_wide_build
def test_upper(self):
string_tests.CommonTest.test_upper(self)
- self.assertEqual(u'\U0001044F'.upper(), u'\U00010427')
- self.assertEqual(u'\U0001044F\U0001044F'.upper(),
- u'\U00010427\U00010427')
- self.assertEqual(u'\U00010427\U0001044F'.upper(),
- u'\U00010427\U00010427')
- self.assertEqual(u'X\U00010427x\U0001044F'.upper(),
- u'X\U00010427X\U00010427')
+ self.assertEqual('\U0001044F'.upper(), '\U00010427')
+ self.assertEqual('\U0001044F\U0001044F'.upper(),
+ '\U00010427\U00010427')
+ self.assertEqual('\U00010427\U0001044F'.upper(),
+ '\U00010427\U00010427')
+ self.assertEqual('X\U00010427x\U0001044F'.upper(),
+ 'X\U00010427X\U00010427')
@requires_wide_build
def test_capitalize(self):
string_tests.CommonTest.test_capitalize(self)
- self.assertEqual(u'\U0001044F'.capitalize(), u'\U00010427')
- self.assertEqual(u'\U0001044F\U0001044F'.capitalize(),
- u'\U00010427\U0001044F')
- self.assertEqual(u'\U00010427\U0001044F'.capitalize(),
- u'\U00010427\U0001044F')
- self.assertEqual(u'\U0001044F\U00010427'.capitalize(),
- u'\U00010427\U0001044F')
- self.assertEqual(u'X\U00010427x\U0001044F'.capitalize(),
- u'X\U0001044Fx\U0001044F')
+ self.assertEqual('\U0001044F'.capitalize(), '\U00010427')
+ self.assertEqual('\U0001044F\U0001044F'.capitalize(),
+ '\U00010427\U0001044F')
+ self.assertEqual('\U00010427\U0001044F'.capitalize(),
+ '\U00010427\U0001044F')
+ self.assertEqual('\U0001044F\U00010427'.capitalize(),
+ '\U00010427\U0001044F')
+ self.assertEqual('X\U00010427x\U0001044F'.capitalize(),
+ 'X\U0001044Fx\U0001044F')
@requires_wide_build
def test_title(self):
string_tests.MixinStrUnicodeUserStringTest.test_title(self)
- self.assertEqual(u'\U0001044F'.title(), u'\U00010427')
- self.assertEqual(u'\U0001044F\U0001044F'.title(),
- u'\U00010427\U0001044F')
- self.assertEqual(u'\U0001044F\U0001044F \U0001044F\U0001044F'.title(),
- u'\U00010427\U0001044F \U00010427\U0001044F')
- self.assertEqual(u'\U00010427\U0001044F \U00010427\U0001044F'.title(),
- u'\U00010427\U0001044F \U00010427\U0001044F')
- self.assertEqual(u'\U0001044F\U00010427 \U0001044F\U00010427'.title(),
- u'\U00010427\U0001044F \U00010427\U0001044F')
- self.assertEqual(u'X\U00010427x\U0001044F X\U00010427x\U0001044F'.title(),
- u'X\U0001044Fx\U0001044F X\U0001044Fx\U0001044F')
+ self.assertEqual('\U0001044F'.title(), '\U00010427')
+ self.assertEqual('\U0001044F\U0001044F'.title(),
+ '\U00010427\U0001044F')
+ self.assertEqual('\U0001044F\U0001044F \U0001044F\U0001044F'.title(),
+ '\U00010427\U0001044F \U00010427\U0001044F')
+ self.assertEqual('\U00010427\U0001044F \U00010427\U0001044F'.title(),
+ '\U00010427\U0001044F \U00010427\U0001044F')
+ self.assertEqual('\U0001044F\U00010427 \U0001044F\U00010427'.title(),
+ '\U00010427\U0001044F \U00010427\U0001044F')
+ self.assertEqual('X\U00010427x\U0001044F X\U00010427x\U0001044F'.title(),
+ 'X\U0001044Fx\U0001044F X\U0001044Fx\U0001044F')
@requires_wide_build
def test_swapcase(self):
string_tests.CommonTest.test_swapcase(self)
- self.assertEqual(u'\U0001044F'.swapcase(), u'\U00010427')
- self.assertEqual(u'\U00010427'.swapcase(), u'\U0001044F')
- self.assertEqual(u'\U0001044F\U0001044F'.swapcase(),
- u'\U00010427\U00010427')
- self.assertEqual(u'\U00010427\U0001044F'.swapcase(),
- u'\U0001044F\U00010427')
- self.assertEqual(u'\U0001044F\U00010427'.swapcase(),
- u'\U00010427\U0001044F')
- self.assertEqual(u'X\U00010427x\U0001044F'.swapcase(),
- u'x\U0001044FX\U00010427')
+ self.assertEqual('\U0001044F'.swapcase(), '\U00010427')
+ self.assertEqual('\U00010427'.swapcase(), '\U0001044F')
+ self.assertEqual('\U0001044F\U0001044F'.swapcase(),
+ '\U00010427\U00010427')
+ self.assertEqual('\U00010427\U0001044F'.swapcase(),
+ '\U0001044F\U00010427')
+ self.assertEqual('\U0001044F\U00010427'.swapcase(),
+ '\U00010427\U0001044F')
+ self.assertEqual('X\U00010427x\U0001044F'.swapcase(),
+ 'x\U0001044FX\U00010427')
def test_contains(self):
# Testing Unicode contains method
- self.assertIn('a', u'abdb')
- self.assertIn('a', u'bdab')
- self.assertIn('a', u'bdaba')
- self.assertIn('a', u'bdba')
- self.assertIn('a', u'bdba')
- self.assertIn(u'a', u'bdba')
- self.assertNotIn(u'a', u'bdb')
- self.assertNotIn(u'a', 'bdb')
- self.assertIn(u'a', 'bdba')
- self.assertIn(u'a', ('a',1,None))
- self.assertIn(u'a', (1,None,'a'))
- self.assertIn(u'a', (1,None,u'a'))
+ self.assertIn('a', 'abdb')
+ self.assertIn('a', 'bdab')
+ self.assertIn('a', 'bdaba')
+ self.assertIn('a', 'bdba')
+ self.assertNotIn('a', 'bdb')
+ self.assertIn('a', 'bdba')
self.assertIn('a', ('a',1,None))
self.assertIn('a', (1,None,'a'))
- self.assertIn('a', (1,None,u'a'))
- self.assertNotIn('a', ('x',1,u'y'))
+ self.assertIn('a', ('a',1,None))
+ self.assertIn('a', (1,None,'a'))
+ self.assertNotIn('a', ('x',1,'y'))
self.assertNotIn('a', ('x',1,None))
- self.assertNotIn(u'abcd', u'abcxxxx')
- self.assertIn(u'ab', u'abcd')
- self.assertIn('ab', u'abc')
- self.assertIn(u'ab', 'abc')
- self.assertIn(u'ab', (1,None,u'ab'))
- self.assertIn(u'', u'abc')
- self.assertIn('', u'abc')
-
- # If the following fails either
- # the contains operator does not propagate UnicodeErrors or
- # someone has changed the default encoding
- self.assertRaises(UnicodeDecodeError, 'g\xe2teau'.__contains__, u'\xe2')
- self.assertRaises(UnicodeDecodeError, u'g\xe2teau'.__contains__, '\xe2')
-
- self.assertIn(u'', '')
- self.assertIn('', u'')
- self.assertIn(u'', u'')
- self.assertIn(u'', 'abc')
- self.assertIn('', u'abc')
- self.assertIn(u'', u'abc')
- self.assertNotIn(u'\0', 'abc')
- self.assertNotIn('\0', u'abc')
- self.assertNotIn(u'\0', u'abc')
- self.assertIn(u'\0', '\0abc')
- self.assertIn('\0', u'\0abc')
- self.assertIn(u'\0', u'\0abc')
- self.assertIn(u'\0', 'abc\0')
- self.assertIn('\0', u'abc\0')
- self.assertIn(u'\0', u'abc\0')
- self.assertIn(u'a', '\0abc')
- self.assertIn('a', u'\0abc')
- self.assertIn(u'a', u'\0abc')
- self.assertIn(u'asdf', 'asdf')
- self.assertIn('asdf', u'asdf')
- self.assertIn(u'asdf', u'asdf')
- self.assertNotIn(u'asdf', 'asd')
- self.assertNotIn('asdf', u'asd')
- self.assertNotIn(u'asdf', u'asd')
- self.assertNotIn(u'asdf', '')
- self.assertNotIn('asdf', u'')
- self.assertNotIn(u'asdf', u'')
-
- self.assertRaises(TypeError, u"abc".__contains__)
- self.assertRaises(TypeError, u"abc".__contains__, object())
+ self.assertNotIn('abcd', 'abcxxxx')
+ self.assertIn('ab', 'abcd')
+ self.assertIn('ab', 'abc')
+ self.assertIn('ab', (1,None,'ab'))
+ self.assertIn('', 'abc')
+ self.assertIn('', '')
+ self.assertIn('', 'abc')
+ self.assertNotIn('\0', 'abc')
+ self.assertIn('\0', '\0abc')
+ self.assertIn('\0', 'abc\0')
+ self.assertIn('a', '\0abc')
+ self.assertIn('asdf', 'asdf')
+ self.assertNotIn('asdf', 'asd')
+ self.assertNotIn('asdf', '')
+
+ self.assertRaises(TypeError, "abc".__contains__)
+
+ def test_format(self):
+ self.assertEqual(''.format(), '')
+ self.assertEqual('a'.format(), 'a')
+ self.assertEqual('ab'.format(), 'ab')
+ self.assertEqual('a{{'.format(), 'a{')
+ self.assertEqual('a}}'.format(), 'a}')
+ self.assertEqual('{{b'.format(), '{b')
+ self.assertEqual('}}b'.format(), '}b')
+ self.assertEqual('a{{b'.format(), 'a{b')
+
+ # examples from the PEP:
+ import datetime
+ self.assertEqual("My name is {0}".format('Fred'), "My name is Fred")
+ self.assertEqual("My name is {0[name]}".format(dict(name='Fred')),
+ "My name is Fred")
+ self.assertEqual("My name is {0} :-{{}}".format('Fred'),
+ "My name is Fred :-{}")
+
+ d = datetime.date(2007, 8, 18)
+ self.assertEqual("The year is {0.year}".format(d),
+ "The year is 2007")
+
+ # classes we'll use for testing
+ class C:
+ def __init__(self, x=100):
+ self._x = x
+ def __format__(self, spec):
+ return spec
+
+ class D:
+ def __init__(self, x):
+ self.x = x
+ def __format__(self, spec):
+ return str(self.x)
+
+ # class with __str__, but no __format__
+ class E:
+ def __init__(self, x):
+ self.x = x
+ def __str__(self):
+ return 'E(' + self.x + ')'
+
+ # class with __repr__, but no __format__ or __str__
+ class F:
+ def __init__(self, x):
+ self.x = x
+ def __repr__(self):
+ return 'F(' + self.x + ')'
+
+ # class with __format__ that forwards to string, for some format_spec's
+ class G:
+ def __init__(self, x):
+ self.x = x
+ def __str__(self):
+ return "string is " + self.x
+ def __format__(self, format_spec):
+ if format_spec == 'd':
+ return 'G(' + self.x + ')'
+ return object.__format__(self, format_spec)
+
+ class I(datetime.date):
+ def __format__(self, format_spec):
+ return self.strftime(format_spec)
+
+ class J(int):
+ def __format__(self, format_spec):
+ return int.__format__(self * 2, format_spec)
+
+
+ self.assertEqual(''.format(), '')
+ self.assertEqual('abc'.format(), 'abc')
+ self.assertEqual('{0}'.format('abc'), 'abc')
+ self.assertEqual('{0:}'.format('abc'), 'abc')
+# self.assertEqual('{ 0 }'.format('abc'), 'abc')
+ self.assertEqual('X{0}'.format('abc'), 'Xabc')
+ self.assertEqual('{0}X'.format('abc'), 'abcX')
+ self.assertEqual('X{0}Y'.format('abc'), 'XabcY')
+ self.assertEqual('{1}'.format(1, 'abc'), 'abc')
+ self.assertEqual('X{1}'.format(1, 'abc'), 'Xabc')
+ self.assertEqual('{1}X'.format(1, 'abc'), 'abcX')
+ self.assertEqual('X{1}Y'.format(1, 'abc'), 'XabcY')
+ self.assertEqual('{0}'.format(-15), '-15')
+ self.assertEqual('{0}{1}'.format(-15, 'abc'), '-15abc')
+ self.assertEqual('{0}X{1}'.format(-15, 'abc'), '-15Xabc')
+ self.assertEqual('{{'.format(), '{')
+ self.assertEqual('}}'.format(), '}')
+ self.assertEqual('{{}}'.format(), '{}')
+ self.assertEqual('{{x}}'.format(), '{x}')
+ self.assertEqual('{{{0}}}'.format(123), '{123}')
+ self.assertEqual('{{{{0}}}}'.format(), '{{0}}')
+ self.assertEqual('}}{{'.format(), '}{')
+ self.assertEqual('}}x{{'.format(), '}x{')
+
+ # weird field names
+ self.assertEqual("{0[foo-bar]}".format({'foo-bar':'baz'}), 'baz')
+ self.assertEqual("{0[foo bar]}".format({'foo bar':'baz'}), 'baz')
+ self.assertEqual("{0[ ]}".format({' ':3}), '3')
+
+ self.assertEqual('{foo._x}'.format(foo=C(20)), '20')
+ self.assertEqual('{1}{0}'.format(D(10), D(20)), '2010')
+ self.assertEqual('{0._x.x}'.format(C(D('abc'))), 'abc')
+ self.assertEqual('{0[0]}'.format(['abc', 'def']), 'abc')
+ self.assertEqual('{0[1]}'.format(['abc', 'def']), 'def')
+ self.assertEqual('{0[1][0]}'.format(['abc', ['def']]), 'def')
+ self.assertEqual('{0[1][0].x}'.format(['abc', [D('def')]]), 'def')
+
+ # strings
+ self.assertEqual('{0:.3s}'.format('abc'), 'abc')
+ self.assertEqual('{0:.3s}'.format('ab'), 'ab')
+ self.assertEqual('{0:.3s}'.format('abcdef'), 'abc')
+ self.assertEqual('{0:.0s}'.format('abcdef'), '')
+ self.assertEqual('{0:3.3s}'.format('abc'), 'abc')
+ self.assertEqual('{0:2.3s}'.format('abc'), 'abc')
+ self.assertEqual('{0:2.2s}'.format('abc'), 'ab')
+ self.assertEqual('{0:3.2s}'.format('abc'), 'ab ')
+ self.assertEqual('{0:x<0s}'.format('result'), 'result')
+ self.assertEqual('{0:x<5s}'.format('result'), 'result')
+ self.assertEqual('{0:x<6s}'.format('result'), 'result')
+ self.assertEqual('{0:x<7s}'.format('result'), 'resultx')
+ self.assertEqual('{0:x<8s}'.format('result'), 'resultxx')
+ self.assertEqual('{0: <7s}'.format('result'), 'result ')
+ self.assertEqual('{0:<7s}'.format('result'), 'result ')
+ self.assertEqual('{0:>7s}'.format('result'), ' result')
+ self.assertEqual('{0:>8s}'.format('result'), ' result')
+ self.assertEqual('{0:^8s}'.format('result'), ' result ')
+ self.assertEqual('{0:^9s}'.format('result'), ' result ')
+ self.assertEqual('{0:^10s}'.format('result'), ' result ')
+ self.assertEqual('{0:10000}'.format('a'), 'a' + ' ' * 9999)
+ self.assertEqual('{0:10000}'.format(''), ' ' * 10000)
+ self.assertEqual('{0:10000000}'.format(''), ' ' * 10000000)
+
+ # format specifiers for user defined type
+ self.assertEqual('{0:abc}'.format(C()), 'abc')
+
+ # !r, !s and !a coercions
+ self.assertEqual('{0!s}'.format('Hello'), 'Hello')
+ self.assertEqual('{0!s:}'.format('Hello'), 'Hello')
+ self.assertEqual('{0!s:15}'.format('Hello'), 'Hello ')
+ self.assertEqual('{0!s:15s}'.format('Hello'), 'Hello ')
+ self.assertEqual('{0!r}'.format('Hello'), "'Hello'")
+ self.assertEqual('{0!r:}'.format('Hello'), "'Hello'")
+ self.assertEqual('{0!r}'.format(F('Hello')), 'F(Hello)')
+ self.assertEqual('{0!r}'.format('\u0378'), "'\\u0378'") # nonprintable
+ self.assertEqual('{0!r}'.format('\u0374'), "'\u0374'") # printable
+ self.assertEqual('{0!r}'.format(F('\u0374')), 'F(\u0374)')
+ self.assertEqual('{0!a}'.format('Hello'), "'Hello'")
+ self.assertEqual('{0!a}'.format('\u0378'), "'\\u0378'") # nonprintable
+ self.assertEqual('{0!a}'.format('\u0374'), "'\\u0374'") # printable
+ self.assertEqual('{0!a:}'.format('Hello'), "'Hello'")
+ self.assertEqual('{0!a}'.format(F('Hello')), 'F(Hello)')
+ self.assertEqual('{0!a}'.format(F('\u0374')), 'F(\\u0374)')
+
+ # test fallback to object.__format__
+ self.assertEqual('{0}'.format({}), '{}')
+ self.assertEqual('{0}'.format([]), '[]')
+ self.assertEqual('{0}'.format([1]), '[1]')
+
+ 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, PendingDeprecationWarning)):
+ 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.assertEqual("{0:date: %Y-%m-%d}".format(I(year=2007,
+ month=8,
+ day=27)),
+ "date: 2007-08-27")
+
+ # test deriving from a builtin type and overriding __format__
+ self.assertEqual("{0}".format(J(10)), "20")
+
+
+ # string format specifiers
+ self.assertEqual('{0:}'.format('a'), 'a')
+
+ # computed format specifiers
+ self.assertEqual("{0:.{1}}".format('hello world', 5), 'hello')
+ self.assertEqual("{0:.{1}s}".format('hello world', 5), 'hello')
+ self.assertEqual("{0:.{precision}s}".format('hello world', precision=5), 'hello')
+ self.assertEqual("{0:{width}.{precision}s}".format('hello world', width=10, precision=5), 'hello ')
+ self.assertEqual("{0:{width}.{precision}s}".format('hello world', width='10', precision='5'), 'hello ')
+
+ # test various errors
+ self.assertRaises(ValueError, '{'.format)
+ self.assertRaises(ValueError, '}'.format)
+ self.assertRaises(ValueError, 'a{'.format)
+ self.assertRaises(ValueError, 'a}'.format)
+ self.assertRaises(ValueError, '{a'.format)
+ self.assertRaises(ValueError, '}a'.format)
+ self.assertRaises(IndexError, '{0}'.format)
+ self.assertRaises(IndexError, '{1}'.format, 'abc')
+ self.assertRaises(KeyError, '{x}'.format)
+ self.assertRaises(ValueError, "}{".format)
+ self.assertRaises(ValueError, "abc{0:{}".format)
+ self.assertRaises(ValueError, "{0".format)
+ self.assertRaises(IndexError, "{0.}".format)
+ self.assertRaises(ValueError, "{0.}".format, 0)
+ self.assertRaises(IndexError, "{0[}".format)
+ self.assertRaises(ValueError, "{0[}".format, [])
+ self.assertRaises(KeyError, "{0]}".format)
+ self.assertRaises(ValueError, "{0.[]}".format, 0)
+ self.assertRaises(ValueError, "{0..foo}".format, 0)
+ self.assertRaises(ValueError, "{0[0}".format, 0)
+ self.assertRaises(ValueError, "{0[0:foo}".format, 0)
+ self.assertRaises(KeyError, "{c]}".format)
+ self.assertRaises(ValueError, "{{ {{{0}}".format, 0)
+ self.assertRaises(ValueError, "{0}}".format, 0)
+ self.assertRaises(KeyError, "{foo}".format, bar=3)
+ self.assertRaises(ValueError, "{0!x}".format, 3)
+ self.assertRaises(ValueError, "{0!}".format, 0)
+ self.assertRaises(ValueError, "{0!rs}".format, 0)
+ self.assertRaises(ValueError, "{!}".format)
+ self.assertRaises(IndexError, "{:}".format)
+ self.assertRaises(IndexError, "{:s}".format)
+ self.assertRaises(IndexError, "{}".format)
+ big = "23098475029384702983476098230754973209482573"
+ self.assertRaises(ValueError, ("{" + big + "}").format)
+ self.assertRaises(ValueError, ("{[" + big + "]}").format, [0])
+
+ # issue 6089
+ self.assertRaises(ValueError, "{0[0]x}".format, [None])
+ self.assertRaises(ValueError, "{0[0](10)}".format, [None])
+
+ # can't have a replacement on the field name portion
+ self.assertRaises(TypeError, '{0[{1}]}'.format, 'abcdefg', 4)
+
+ # exceed maximum recursion depth
+ self.assertRaises(ValueError, "{0:{1:{2}}}".format, 'abc', 's', '')
+ self.assertRaises(ValueError, "{0:{1:{2:{3:{4:{5:{6}}}}}}}".format,
+ 0, 1, 2, 3, 4, 5, 6, 7)
+
+ # string format spec errors
+ self.assertRaises(ValueError, "{0:-s}".format, '')
+ self.assertRaises(ValueError, format, "", "-")
+ self.assertRaises(ValueError, "{0:=s}".format, '')
+
+ # Alternate formatting is not supported
+ self.assertRaises(ValueError, format, '', '#')
+ self.assertRaises(ValueError, format, '', '#20')
+
+ def test_format_map(self):
+ self.assertEqual(''.format_map({}), '')
+ self.assertEqual('a'.format_map({}), 'a')
+ self.assertEqual('ab'.format_map({}), 'ab')
+ self.assertEqual('a{{'.format_map({}), 'a{')
+ self.assertEqual('a}}'.format_map({}), 'a}')
+ self.assertEqual('{{b'.format_map({}), '{b')
+ self.assertEqual('}}b'.format_map({}), '}b')
+ self.assertEqual('a{{b'.format_map({}), 'a{b')
+
+ # using mappings
+ class Mapping(dict):
+ def __missing__(self, key):
+ return key
+ self.assertEqual('{hello}'.format_map(Mapping()), 'hello')
+ self.assertEqual('{a} {world}'.format_map(Mapping(a='hello')), 'hello world')
+
+ class InternalMapping:
+ def __init__(self):
+ self.mapping = {'a': 'hello'}
+ def __getitem__(self, key):
+ return self.mapping[key]
+ self.assertEqual('{a}'.format_map(InternalMapping()), 'hello')
+
+
+ class C:
+ def __init__(self, x=100):
+ self._x = x
+ def __format__(self, spec):
+ return spec
+ self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20')
+
+ # test various errors
+ self.assertRaises(TypeError, ''.format_map)
+ self.assertRaises(TypeError, 'a'.format_map)
+
+ self.assertRaises(ValueError, '{'.format_map, {})
+ self.assertRaises(ValueError, '}'.format_map, {})
+ self.assertRaises(ValueError, 'a{'.format_map, {})
+ self.assertRaises(ValueError, 'a}'.format_map, {})
+ self.assertRaises(ValueError, '{a'.format_map, {})
+ self.assertRaises(ValueError, '}a'.format_map, {})
+
+ # issue #12579: can't supply positional params to format_map
+ self.assertRaises(ValueError, '{}'.format_map, {'a' : 2})
+ self.assertRaises(ValueError, '{}'.format_map, 'a')
+ self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1})
+
+ def test_format_huge_precision(self):
+ format_string = ".{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format(2.34, format_string)
+
+ def test_format_huge_width(self):
+ format_string = "{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format(2.34, format_string)
+
+ def test_format_huge_item_number(self):
+ format_string = "{{{}:.6f}}".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format_string.format(2.34)
+
+ def test_format_auto_numbering(self):
+ class C:
+ def __init__(self, x=100):
+ self._x = x
+ def __format__(self, spec):
+ return spec
+
+ self.assertEqual('{}'.format(10), '10')
+ self.assertEqual('{:5}'.format('s'), 's ')
+ self.assertEqual('{!r}'.format('s'), "'s'")
+ self.assertEqual('{._x}'.format(C(10)), '10')
+ self.assertEqual('{[1]}'.format([1, 2]), '2')
+ self.assertEqual('{[a]}'.format({'a':4, 'b':2}), '4')
+ self.assertEqual('a{}b{}c'.format(0, 1), 'a0b1c')
+
+ self.assertEqual('a{:{}}b'.format('x', '^10'), 'a x b')
+ self.assertEqual('a{:{}x}b'.format(20, '#'), 'a0x14b')
+
+ # can't mix and match numbering and auto-numbering
+ self.assertRaises(ValueError, '{}{1}'.format, 1, 2)
+ self.assertRaises(ValueError, '{1}{}'.format, 1, 2)
+ self.assertRaises(ValueError, '{:{1}}'.format, 1, 2)
+ self.assertRaises(ValueError, '{0:{}}'.format, 1, 2)
+
+ # can mix and match auto-numbering and named
+ self.assertEqual('{f}{}'.format(4, f='test'), 'test4')
+ self.assertEqual('{}{f}'.format(4, f='test'), '4test')
+ self.assertEqual('{:{f}}{g}{}'.format(1, 3, g='g', f=2), ' 1g3')
+ self.assertEqual('{f:{}}{}{g}'.format(2, 4, f=1, g='g'), ' 14g')
def test_formatting(self):
string_tests.MixinStrUnicodeUserStringTest.test_formatting(self)
# Testing Unicode formatting strings...
- self.assertEqual(u"%s, %s" % (u"abc", "abc"), u'abc, abc')
- self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, 2, 3), u'abc, abc, 1, 2.000000, 3.00')
- self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", 1, -2, 3), u'abc, abc, 1, -2.000000, 3.00')
- self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.5), u'abc, abc, -1, -2.000000, 3.50')
- self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 3.57), u'abc, abc, -1, -2.000000, 3.57')
- self.assertEqual(u"%s, %s, %i, %f, %5.2f" % (u"abc", "abc", -1, -2, 1003.57), u'abc, abc, -1, -2.000000, 1003.57')
+ self.assertEqual("%s, %s" % ("abc", "abc"), 'abc, abc')
+ self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", 1, 2, 3), 'abc, abc, 1, 2.000000, 3.00')
+ self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", 1, -2, 3), 'abc, abc, 1, -2.000000, 3.00')
+ self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.5), 'abc, abc, -1, -2.000000, 3.50')
+ self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 3.57), 'abc, abc, -1, -2.000000, 3.57')
+ self.assertEqual("%s, %s, %i, %f, %5.2f" % ("abc", "abc", -1, -2, 1003.57), 'abc, abc, -1, -2.000000, 1003.57')
if not sys.platform.startswith('java'):
- self.assertEqual(u"%r, %r" % (u"abc", "abc"), u"u'abc', 'abc'")
- self.assertEqual(u"%(x)s, %(y)s" % {'x':u"abc", 'y':"def"}, u'abc, def')
- self.assertEqual(u"%(x)s, %(\xfc)s" % {'x':u"abc", u'\xfc':"def"}, u'abc, def')
-
- self.assertEqual(u'%c' % 0x1234, u'\u1234')
- self.assertRaises(OverflowError, u"%c".__mod__, (sys.maxunicode+1,))
- self.assertRaises(ValueError, u"%.1\u1032f".__mod__, (1.0/3))
-
- for num in range(0x00,0x80):
- char = chr(num)
- self.assertEqual(u"%c" % char, unicode(char))
- self.assertEqual(u"%c" % num, unicode(char))
- self.assertTrue(char == u"%c" % char)
- self.assertTrue(char == u"%c" % num)
- # Issue 7649
- for num in range(0x80,0x100):
- uchar = unichr(num)
- self.assertEqual(uchar, u"%c" % num) # works only with ints
- self.assertEqual(uchar, u"%c" % uchar) # and unicode chars
- # the implicit decoding should fail for non-ascii chars
- self.assertRaises(UnicodeDecodeError, u"%c".__mod__, chr(num))
- self.assertRaises(UnicodeDecodeError, u"%s".__mod__, chr(num))
+ self.assertEqual("%r, %r" % (b"abc", "abc"), "b'abc', 'abc'")
+ self.assertEqual("%r" % ("\u1234",), "'\u1234'")
+ self.assertEqual("%a" % ("\u1234",), "'\\u1234'")
+ self.assertEqual("%(x)s, %(y)s" % {'x':"abc", 'y':"def"}, 'abc, def')
+ self.assertEqual("%(x)s, %(\xfc)s" % {'x':"abc", '\xfc':"def"}, 'abc, def')
+
+ self.assertEqual('%c' % 0x1234, '\u1234')
+ self.assertEqual('%c' % 0x21483, '\U00021483')
+ self.assertRaises(OverflowError, "%c".__mod__, (0x110000,))
+ self.assertEqual('%c' % '\U00021483', '\U00021483')
+ self.assertRaises(TypeError, "%c".__mod__, "aa")
+ self.assertRaises(ValueError, "%.1\u1032f".__mod__, (1.0/3))
+ self.assertRaises(TypeError, "%i".__mod__, "aa")
# formatting jobs delegated from the string implementation:
- self.assertEqual('...%(foo)s...' % {'foo':u"abc"}, u'...abc...')
self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
- self.assertEqual('...%(foo)s...' % {u'foo':"abc"}, '...abc...')
- self.assertEqual('...%(foo)s...' % {u'foo':u"abc"}, u'...abc...')
- self.assertEqual('...%(foo)s...' % {u'foo':u"abc",'def':123}, u'...abc...')
- self.assertEqual('...%(foo)s...' % {u'foo':u"abc",u'def':123}, u'...abc...')
- self.assertEqual('...%s...%s...%s...%s...' % (1,2,3,u"abc"), u'...1...2...3...abc...')
- self.assertEqual('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,u"abc"), u'...%...%s...1...2...3...abc...')
- self.assertEqual('...%s...' % u"abc", u'...abc...')
- self.assertEqual('%*s' % (5,u'abc',), u' abc')
- self.assertEqual('%*s' % (-5,u'abc',), u'abc ')
- self.assertEqual('%*.*s' % (5,2,u'abc',), u' ab')
- self.assertEqual('%*.*s' % (5,3,u'abc',), u' abc')
- self.assertEqual('%i %*.*s' % (10, 5,3,u'abc',), u'10 abc')
- self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, u'abc',), u'103 abc')
- self.assertEqual('%c' % u'a', u'a')
+ self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
+ self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
+ self.assertEqual('...%(foo)s...' % {'foo':"abc"}, '...abc...')
+ self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...')
+ self.assertEqual('...%(foo)s...' % {'foo':"abc",'def':123}, '...abc...')
+ self.assertEqual('...%s...%s...%s...%s...' % (1,2,3,"abc"), '...1...2...3...abc...')
+ self.assertEqual('...%%...%%s...%s...%s...%s...%s...' % (1,2,3,"abc"), '...%...%s...1...2...3...abc...')
+ self.assertEqual('...%s...' % "abc", '...abc...')
+ self.assertEqual('%*s' % (5,'abc',), ' abc')
+ self.assertEqual('%*s' % (-5,'abc',), 'abc ')
+ self.assertEqual('%*.*s' % (5,2,'abc',), ' ab')
+ self.assertEqual('%*.*s' % (5,3,'abc',), ' abc')
+ self.assertEqual('%i %*.*s' % (10, 5,3,'abc',), '10 abc')
+ self.assertEqual('%i%s %*.*s' % (10, 3, 5, 3, 'abc',), '103 abc')
+ self.assertEqual('%c' % 'a', 'a')
class Wrapper:
def __str__(self):
- return u'\u1234'
- self.assertEqual('%s' % Wrapper(), u'\u1234')
-
- @test_support.cpython_only
+ return '\u1234'
+ self.assertEqual('%s' % Wrapper(), '\u1234')
+
+ # issue 3382
+ NAN = float('nan')
+ INF = float('inf')
+ self.assertEqual('%f' % NAN, 'nan')
+ self.assertEqual('%F' % NAN, 'NAN')
+ self.assertEqual('%f' % INF, 'inf')
+ self.assertEqual('%F' % INF, 'INF')
+
+ @support.cpython_only
def test_formatting_huge_precision(self):
from _testcapi import INT_MAX
- format_string = u"%.{}f".format(INT_MAX + 1)
+ format_string = "%.{}f".format(INT_MAX + 1)
with self.assertRaises(ValueError):
result = format_string % 2.34
def test_formatting_huge_width(self):
- format_string = u"%{}f".format(sys.maxsize + 1)
+ format_string = "%{}f".format(sys.maxsize + 1)
with self.assertRaises(ValueError):
result = format_string % 2.34
def test_startswith_endswith_errors(self):
- for meth in (u'foo'.startswith, u'foo'.endswith):
- with self.assertRaises(UnicodeDecodeError):
- meth('\xff')
+ for meth in ('foo'.startswith, 'foo'.endswith):
with self.assertRaises(TypeError) as cm:
meth(['f'])
exc = str(cm.exception)
- self.assertIn('unicode', exc)
self.assertIn('str', exc)
self.assertIn('tuple', exc)
- @test_support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
+ @support.run_with_locale('LC_ALL', 'de_DE', 'fr_FR')
def test_format_float(self):
# should not format with a comma, but always with C locale
- self.assertEqual(u'1.0', u'%.1f' % 1.0)
+ self.assertEqual('1.0', '%.1f' % 1.0)
def test_constructor(self):
# unicode(obj) tests (this maps to PyObject_Unicode() at C level)
self.assertEqual(
- unicode(u'unicode remains unicode'),
- u'unicode remains unicode'
+ str('unicode remains unicode'),
+ 'unicode remains unicode'
)
- class UnicodeSubclass(unicode):
+ class UnicodeSubclass(str):
pass
self.assertEqual(
- unicode(UnicodeSubclass('unicode subclass becomes unicode')),
- u'unicode subclass becomes unicode'
+ str(UnicodeSubclass('unicode subclass becomes unicode')),
+ 'unicode subclass becomes unicode'
)
self.assertEqual(
- unicode('strings are converted to unicode'),
- u'strings are converted to unicode'
+ str('strings are converted to unicode'),
+ 'strings are converted to unicode'
)
- class UnicodeCompat:
- def __init__(self, x):
- self.x = x
- def __unicode__(self):
- return self.x
-
- self.assertEqual(
- unicode(UnicodeCompat('__unicode__ compatible objects are recognized')),
- u'__unicode__ compatible objects are recognized')
-
class StringCompat:
def __init__(self, x):
self.x = x
@@ -710,26 +1058,18 @@ class UnicodeTest(
return self.x
self.assertEqual(
- unicode(StringCompat('__str__ compatible objects are recognized')),
- u'__str__ compatible objects are recognized'
+ str(StringCompat('__str__ compatible objects are recognized')),
+ '__str__ compatible objects are recognized'
)
# unicode(obj) is compatible to str():
o = StringCompat('unicode(obj) is compatible to str()')
- self.assertEqual(unicode(o), u'unicode(obj) is compatible to str()')
+ self.assertEqual(str(o), 'unicode(obj) is compatible to str()')
self.assertEqual(str(o), 'unicode(obj) is compatible to str()')
- # %-formatting and .__unicode__()
- self.assertEqual(u'%s' %
- UnicodeCompat(u"u'%s' % obj uses obj.__unicode__()"),
- u"u'%s' % obj uses obj.__unicode__()")
- self.assertEqual(u'%s' %
- UnicodeCompat(u"u'%s' % obj falls back to obj.__str__()"),
- u"u'%s' % obj falls back to obj.__str__()")
-
- for obj in (123, 123.45, 123L):
- self.assertEqual(unicode(obj), unicode(str(obj)))
+ for obj in (123, 123.45, 123):
+ self.assertEqual(str(obj), str(str(obj)))
# unicode(obj, encoding, error) tests (this maps to
# PyUnicode_FromEncodedObject() at C level)
@@ -737,64 +1077,85 @@ class UnicodeTest(
if not sys.platform.startswith('java'):
self.assertRaises(
TypeError,
- unicode,
- u'decoding unicode is not supported',
+ str,
+ 'decoding unicode is not supported',
'utf-8',
'strict'
)
self.assertEqual(
- unicode('strings are decoded to unicode', 'utf-8', 'strict'),
- u'strings are decoded to unicode'
+ str(b'strings are decoded to unicode', 'utf-8', 'strict'),
+ 'strings are decoded to unicode'
)
if not sys.platform.startswith('java'):
- with test_support.check_py3k_warnings():
- buf = buffer('character buffers are decoded to unicode')
self.assertEqual(
- unicode(
- buf,
+ str(
+ memoryview(b'character buffers are decoded to unicode'),
'utf-8',
'strict'
),
- u'character buffers are decoded to unicode'
+ 'character buffers are decoded to unicode'
)
- self.assertRaises(TypeError, unicode, 42, 42, 42)
+ self.assertRaises(TypeError, str, 42, 42, 42)
+
+ def test_constructor_keyword_args(self):
+ """Pass various keyword argument combinations to the constructor."""
+ # The object argument can be passed as a keyword.
+ self.assertEqual(str(object='foo'), 'foo')
+ self.assertEqual(str(object=b'foo', encoding='utf-8'), 'foo')
+ # The errors argument without encoding triggers "decode" mode.
+ self.assertEqual(str(b'foo', errors='strict'), 'foo') # not "b'foo'"
+ self.assertEqual(str(object=b'foo', errors='strict'), 'foo')
+
+ def test_constructor_defaults(self):
+ """Check the constructor argument defaults."""
+ # The object argument defaults to '' or b''.
+ self.assertEqual(str(), '')
+ self.assertEqual(str(errors='strict'), '')
+ utf8_cent = '¢'.encode('utf-8')
+ # The encoding argument defaults to utf-8.
+ self.assertEqual(str(utf8_cent, errors='strict'), '¢')
+ # The errors argument defaults to strict.
+ self.assertRaises(UnicodeDecodeError, str, utf8_cent, encoding='ascii')
def test_codecs_utf7(self):
utfTests = [
- (u'A\u2262\u0391.', 'A+ImIDkQ.'), # RFC2152 example
- (u'Hi Mom -\u263a-!', 'Hi Mom -+Jjo--!'), # RFC2152 example
- (u'\u65E5\u672C\u8A9E', '+ZeVnLIqe-'), # RFC2152 example
- (u'Item 3 is \u00a31.', 'Item 3 is +AKM-1.'), # RFC2152 example
- (u'+', '+-'),
- (u'+-', '+--'),
- (u'+?', '+-?'),
- (u'\?', '+AFw?'),
- (u'+?', '+-?'),
- (ur'\\?', '+AFwAXA?'),
- (ur'\\\?', '+AFwAXABc?'),
- (ur'++--', '+-+---'),
- (u'\U000abcde', '+2m/c3g-'), # surrogate pairs
- (u'/', '/'),
+ ('A\u2262\u0391.', b'A+ImIDkQ.'), # RFC2152 example
+ ('Hi Mom -\u263a-!', b'Hi Mom -+Jjo--!'), # RFC2152 example
+ ('\u65E5\u672C\u8A9E', b'+ZeVnLIqe-'), # RFC2152 example
+ ('Item 3 is \u00a31.', b'Item 3 is +AKM-1.'), # RFC2152 example
+ ('+', b'+-'),
+ ('+-', b'+--'),
+ ('+?', b'+-?'),
+ ('\?', b'+AFw?'),
+ ('+?', b'+-?'),
+ (r'\\?', b'+AFwAXA?'),
+ (r'\\\?', b'+AFwAXABc?'),
+ (r'++--', b'+-+---'),
+ ('\U000abcde', b'+2m/c3g-'), # surrogate pairs
+ ('/', b'/'),
]
for (x, y) in utfTests:
self.assertEqual(x.encode('utf-7'), y)
# Unpaired surrogates are passed through
- self.assertEqual(u'\uD801'.encode('utf-7'), '+2AE-')
- self.assertEqual(u'\uD801x'.encode('utf-7'), '+2AE-x')
- self.assertEqual(u'\uDC01'.encode('utf-7'), '+3AE-')
- self.assertEqual(u'\uDC01x'.encode('utf-7'), '+3AE-x')
- self.assertEqual('+2AE-'.decode('utf-7'), u'\uD801')
- self.assertEqual('+2AE-x'.decode('utf-7'), u'\uD801x')
- self.assertEqual('+3AE-'.decode('utf-7'), u'\uDC01')
- self.assertEqual('+3AE-x'.decode('utf-7'), u'\uDC01x')
-
- self.assertEqual(u'\uD801\U000abcde'.encode('utf-7'), '+2AHab9ze-')
- self.assertEqual('+2AHab9ze-'.decode('utf-7'), u'\uD801\U000abcde')
+ self.assertEqual('\uD801'.encode('utf-7'), b'+2AE-')
+ self.assertEqual('\uD801x'.encode('utf-7'), b'+2AE-x')
+ self.assertEqual('\uDC01'.encode('utf-7'), b'+3AE-')
+ self.assertEqual('\uDC01x'.encode('utf-7'), b'+3AE-x')
+ self.assertEqual(b'+2AE-'.decode('utf-7'), '\uD801')
+ self.assertEqual(b'+2AE-x'.decode('utf-7'), '\uD801x')
+ self.assertEqual(b'+3AE-'.decode('utf-7'), '\uDC01')
+ self.assertEqual(b'+3AE-x'.decode('utf-7'), '\uDC01x')
+
+ self.assertEqual('\uD801\U000abcde'.encode('utf-7'), b'+2AHab9ze-')
+ self.assertEqual(b'+2AHab9ze-'.decode('utf-7'), '\uD801\U000abcde')
+
+ # Issue #2242: crash on some Windows/MSVC versions
+ self.assertEqual(b'+\xc1'.decode('utf-7'), '\xc1')
# Direct encoded characters
set_d = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'(),-./:?"
@@ -802,46 +1163,45 @@ class UnicodeTest(
set_o = '!"#$%&*;<=>@[]^_`{|}'
for c in set_d:
self.assertEqual(c.encode('utf7'), c.encode('ascii'))
- self.assertEqual(c.encode('ascii').decode('utf7'), unicode(c))
- self.assertTrue(c == c.encode('ascii').decode('utf7'))
+ self.assertEqual(c.encode('ascii').decode('utf7'), c)
for c in set_o:
- self.assertEqual(c.encode('ascii').decode('utf7'), unicode(c))
- self.assertTrue(c == c.encode('ascii').decode('utf7'))
+ self.assertEqual(c.encode('ascii').decode('utf7'), c)
def test_codecs_utf8(self):
- self.assertEqual(u''.encode('utf-8'), '')
- self.assertEqual(u'\u20ac'.encode('utf-8'), '\xe2\x82\xac')
- self.assertEqual(u'\ud800\udc02'.encode('utf-8'), '\xf0\x90\x80\x82')
- self.assertEqual(u'\ud84d\udc56'.encode('utf-8'), '\xf0\xa3\x91\x96')
- self.assertEqual(u'\ud800'.encode('utf-8'), '\xed\xa0\x80')
- self.assertEqual(u'\udc00'.encode('utf-8'), '\xed\xb0\x80')
- self.assertEqual(
- (u'\ud800\udc02'*1000).encode('utf-8'),
- '\xf0\x90\x80\x82'*1000
- )
+ self.assertEqual(''.encode('utf-8'), b'')
+ self.assertEqual('\u20ac'.encode('utf-8'), b'\xe2\x82\xac')
+ if sys.maxunicode == 65535:
+ self.assertEqual('\ud800\udc02'.encode('utf-8'), b'\xf0\x90\x80\x82')
+ self.assertEqual('\ud84d\udc56'.encode('utf-8'), b'\xf0\xa3\x91\x96')
+ self.assertEqual('\ud800'.encode('utf-8', 'surrogatepass'), b'\xed\xa0\x80')
+ self.assertEqual('\udc00'.encode('utf-8', 'surrogatepass'), b'\xed\xb0\x80')
+ if sys.maxunicode == 65535:
+ self.assertEqual(
+ ('\ud800\udc02'*1000).encode('utf-8'),
+ b'\xf0\x90\x80\x82'*1000)
self.assertEqual(
- u'\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
- u'\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00'
- u'\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
- u'\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
- u'\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das'
- u' Nunstuck git und'.encode('utf-8'),
- '\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81'
- '\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3'
- '\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe'
- '\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83'
- '\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8'
- '\xaa\x9e\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81'
- '\xe3\x81\x82\xe3\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81'
- '\x9f\xe3\x82\x89\xe3\x82\x81\xe3\x81\xa7\xe3\x81\x99\xe3'
- '\x80\x82\xe5\xae\x9f\xe9\x9a\x9b\xe3\x81\xab\xe3\x81\xaf'
- '\xe3\x80\x8cWenn ist das Nunstuck git und'
+ '\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
+ '\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002\u4e00'
+ '\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
+ '\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
+ '\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das'
+ ' Nunstuck git und'.encode('utf-8'),
+ b'\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81'
+ b'\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3'
+ b'\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe'
+ b'\xe3\x81\x9b\xe3\x82\x93\xe3\x80\x82\xe4\xb8\x80\xe9\x83'
+ b'\xa8\xe3\x81\xaf\xe3\x83\x89\xe3\x82\xa4\xe3\x83\x84\xe8'
+ b'\xaa\x9e\xe3\x81\xa7\xe3\x81\x99\xe3\x81\x8c\xe3\x80\x81'
+ b'\xe3\x81\x82\xe3\x81\xa8\xe3\x81\xaf\xe3\x81\xa7\xe3\x81'
+ b'\x9f\xe3\x82\x89\xe3\x82\x81\xe3\x81\xa7\xe3\x81\x99\xe3'
+ b'\x80\x82\xe5\xae\x9f\xe9\x9a\x9b\xe3\x81\xab\xe3\x81\xaf'
+ b'\xe3\x80\x8cWenn ist das Nunstuck git und'
)
# UTF-8 specific decoding tests
- self.assertEqual(unicode('\xf0\xa3\x91\x96', 'utf-8'), u'\U00023456')
- self.assertEqual(unicode('\xf0\x90\x80\x82', 'utf-8'), u'\U00010002')
- self.assertEqual(unicode('\xe2\x82\xac', 'utf-8'), u'\u20ac')
+ self.assertEqual(str(b'\xf0\xa3\x91\x96', 'utf-8'), '\U00023456' )
+ self.assertEqual(str(b'\xf0\x90\x80\x82', 'utf-8'), '\U00010002' )
+ self.assertEqual(str(b'\xe2\x82\xac', 'utf-8'), '\u20ac' )
# Other possible utf-8 test cases:
# * strict decoding testing for all of the
@@ -850,32 +1210,30 @@ class UnicodeTest(
def test_utf8_decode_valid_sequences(self):
sequences = [
# single byte
- ('\x00', u'\x00'), ('a', u'a'), ('\x7f', u'\x7f'),
+ (b'\x00', '\x00'), (b'a', 'a'), (b'\x7f', '\x7f'),
# 2 bytes
- ('\xc2\x80', u'\x80'), ('\xdf\xbf', u'\u07ff'),
+ (b'\xc2\x80', '\x80'), (b'\xdf\xbf', '\u07ff'),
# 3 bytes
- ('\xe0\xa0\x80', u'\u0800'), ('\xed\x9f\xbf', u'\ud7ff'),
- ('\xee\x80\x80', u'\uE000'), ('\xef\xbf\xbf', u'\uffff'),
+ (b'\xe0\xa0\x80', '\u0800'), (b'\xed\x9f\xbf', '\ud7ff'),
+ (b'\xee\x80\x80', '\uE000'), (b'\xef\xbf\xbf', '\uffff'),
# 4 bytes
- ('\xF0\x90\x80\x80', u'\U00010000'),
- ('\xf4\x8f\xbf\xbf', u'\U0010FFFF')
+ (b'\xF0\x90\x80\x80', '\U00010000'),
+ (b'\xf4\x8f\xbf\xbf', '\U0010FFFF')
]
for seq, res in sequences:
self.assertEqual(seq.decode('utf-8'), res)
- for ch in map(unichr, range(0, sys.maxunicode)):
- self.assertEqual(ch, ch.encode('utf-8').decode('utf-8'))
def test_utf8_decode_invalid_sequences(self):
# continuation bytes in a sequence of 2, 3, or 4 bytes
- continuation_bytes = map(chr, range(0x80, 0xC0))
+ continuation_bytes = [bytes([x]) for x in range(0x80, 0xC0)]
# start bytes of a 2-byte sequence equivalent to codepoints < 0x7F
- invalid_2B_seq_start_bytes = map(chr, range(0xC0, 0xC2))
+ invalid_2B_seq_start_bytes = [bytes([x]) for x in range(0xC0, 0xC2)]
# start bytes of a 4-byte sequence equivalent to codepoints > 0x10FFFF
- invalid_4B_seq_start_bytes = map(chr, range(0xF5, 0xF8))
+ invalid_4B_seq_start_bytes = [bytes([x]) for x in range(0xF5, 0xF8)]
invalid_start_bytes = (
continuation_bytes + invalid_2B_seq_start_bytes +
- invalid_4B_seq_start_bytes + map(chr, range(0xF7, 0x100))
+ invalid_4B_seq_start_bytes + [bytes([x]) for x in range(0xF7, 0x100)]
)
for byte in invalid_start_bytes:
@@ -889,38 +1247,29 @@ class UnicodeTest(
for cb1 in continuation_bytes[:3]:
for cb3 in continuation_bytes[:3]:
self.assertRaises(UnicodeDecodeError,
- (sb+cb1+'\x80'+cb3).decode, 'utf-8')
+ (sb+cb1+b'\x80'+cb3).decode, 'utf-8')
- for cb in map(chr, range(0x80, 0xA0)):
+ for cb in [bytes([x]) for x in range(0x80, 0xA0)]:
+ self.assertRaises(UnicodeDecodeError,
+ (b'\xE0'+cb+b'\x80').decode, 'utf-8')
self.assertRaises(UnicodeDecodeError,
- ('\xE0'+cb+'\x80').decode, 'utf-8')
+ (b'\xE0'+cb+b'\xBF').decode, 'utf-8')
+ # surrogates
+ for cb in [bytes([x]) for x in range(0xA0, 0xC0)]:
self.assertRaises(UnicodeDecodeError,
- ('\xE0'+cb+'\xBF').decode, 'utf-8')
- # XXX: surrogates shouldn't be valid UTF-8!
- # see http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf
- # (table 3-7) and http://www.rfc-editor.org/rfc/rfc3629.txt
- #for cb in map(chr, range(0xA0, 0xC0)):
- #self.assertRaises(UnicodeDecodeError,
- #('\xED'+cb+'\x80').decode, 'utf-8')
- #self.assertRaises(UnicodeDecodeError,
- #('\xED'+cb+'\xBF').decode, 'utf-8')
- # but since they are valid on Python 2 add a test for that:
- for cb, surrogate in zip(map(chr, range(0xA0, 0xC0)),
- map(unichr, range(0xd800, 0xe000, 64))):
- encoded = '\xED'+cb+'\x80'
- self.assertEqual(encoded.decode('utf-8'), surrogate)
- self.assertEqual(surrogate.encode('utf-8'), encoded)
-
- for cb in map(chr, range(0x80, 0x90)):
+ (b'\xED'+cb+b'\x80').decode, 'utf-8')
self.assertRaises(UnicodeDecodeError,
- ('\xF0'+cb+'\x80\x80').decode, 'utf-8')
+ (b'\xED'+cb+b'\xBF').decode, 'utf-8')
+ for cb in [bytes([x]) for x in range(0x80, 0x90)]:
self.assertRaises(UnicodeDecodeError,
- ('\xF0'+cb+'\xBF\xBF').decode, 'utf-8')
- for cb in map(chr, range(0x90, 0xC0)):
+ (b'\xF0'+cb+b'\x80\x80').decode, 'utf-8')
self.assertRaises(UnicodeDecodeError,
- ('\xF4'+cb+'\x80\x80').decode, 'utf-8')
+ (b'\xF0'+cb+b'\xBF\xBF').decode, 'utf-8')
+ for cb in [bytes([x]) for x in range(0x90, 0xC0)]:
self.assertRaises(UnicodeDecodeError,
- ('\xF4'+cb+'\xBF\xBF').decode, 'utf-8')
+ (b'\xF4'+cb+b'\x80\x80').decode, 'utf-8')
+ self.assertRaises(UnicodeDecodeError,
+ (b'\xF4'+cb+b'\xBF\xBF').decode, 'utf-8')
def test_issue8271(self):
# Issue #8271: during the decoding of an invalid UTF-8 byte sequence,
@@ -928,187 +1277,189 @@ class UnicodeTest(
# invalid, instead of the number of bytes specified by the start byte.
# See http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf (page 95,
# table 3-8, Row 2) for more information about the algorithm used.
- FFFD = u'\ufffd'
+ FFFD = '\ufffd'
sequences = [
# invalid start bytes
- ('\x80', FFFD), # continuation byte
- ('\x80\x80', FFFD*2), # 2 continuation bytes
- ('\xc0', FFFD),
- ('\xc0\xc0', FFFD*2),
- ('\xc1', FFFD),
- ('\xc1\xc0', FFFD*2),
- ('\xc0\xc1', FFFD*2),
+ (b'\x80', FFFD), # continuation byte
+ (b'\x80\x80', FFFD*2), # 2 continuation bytes
+ (b'\xc0', FFFD),
+ (b'\xc0\xc0', FFFD*2),
+ (b'\xc1', FFFD),
+ (b'\xc1\xc0', FFFD*2),
+ (b'\xc0\xc1', FFFD*2),
# with start byte of a 2-byte sequence
- ('\xc2', FFFD), # only the start byte
- ('\xc2\xc2', FFFD*2), # 2 start bytes
- ('\xc2\xc2\xc2', FFFD*3), # 2 start bytes
- ('\xc2\x41', FFFD+'A'), # invalid continuation byte
+ (b'\xc2', FFFD), # only the start byte
+ (b'\xc2\xc2', FFFD*2), # 2 start bytes
+ (b'\xc2\xc2\xc2', FFFD*3), # 2 start bytes
+ (b'\xc2\x41', FFFD+'A'), # invalid continuation byte
# with start byte of a 3-byte sequence
- ('\xe1', FFFD), # only the start byte
- ('\xe1\xe1', FFFD*2), # 2 start bytes
- ('\xe1\xe1\xe1', FFFD*3), # 3 start bytes
- ('\xe1\xe1\xe1\xe1', FFFD*4), # 4 start bytes
- ('\xe1\x80', FFFD), # only 1 continuation byte
- ('\xe1\x41', FFFD+'A'), # invalid continuation byte
- ('\xe1\x41\x80', FFFD+'A'+FFFD), # invalid cb followed by valid cb
- ('\xe1\x41\x41', FFFD+'AA'), # 2 invalid continuation bytes
- ('\xe1\x80\x41', FFFD+'A'), # only 1 valid continuation byte
- ('\xe1\x80\xe1\x41', FFFD*2+'A'), # 1 valid and the other invalid
- ('\xe1\x41\xe1\x80', FFFD+'A'+FFFD), # 1 invalid and the other valid
+ (b'\xe1', FFFD), # only the start byte
+ (b'\xe1\xe1', FFFD*2), # 2 start bytes
+ (b'\xe1\xe1\xe1', FFFD*3), # 3 start bytes
+ (b'\xe1\xe1\xe1\xe1', FFFD*4), # 4 start bytes
+ (b'\xe1\x80', FFFD), # only 1 continuation byte
+ (b'\xe1\x41', FFFD+'A'), # invalid continuation byte
+ (b'\xe1\x41\x80', FFFD+'A'+FFFD), # invalid cb followed by valid cb
+ (b'\xe1\x41\x41', FFFD+'AA'), # 2 invalid continuation bytes
+ (b'\xe1\x80\x41', FFFD+'A'), # only 1 valid continuation byte
+ (b'\xe1\x80\xe1\x41', FFFD*2+'A'), # 1 valid and the other invalid
+ (b'\xe1\x41\xe1\x80', FFFD+'A'+FFFD), # 1 invalid and the other valid
# with start byte of a 4-byte sequence
- ('\xf1', FFFD), # only the start byte
- ('\xf1\xf1', FFFD*2), # 2 start bytes
- ('\xf1\xf1\xf1', FFFD*3), # 3 start bytes
- ('\xf1\xf1\xf1\xf1', FFFD*4), # 4 start bytes
- ('\xf1\xf1\xf1\xf1\xf1', FFFD*5), # 5 start bytes
- ('\xf1\x80', FFFD), # only 1 continuation bytes
- ('\xf1\x80\x80', FFFD), # only 2 continuation bytes
- ('\xf1\x80\x41', FFFD+'A'), # 1 valid cb and 1 invalid
- ('\xf1\x80\x41\x41', FFFD+'AA'), # 1 valid cb and 1 invalid
- ('\xf1\x80\x80\x41', FFFD+'A'), # 2 valid cb and 1 invalid
- ('\xf1\x41\x80', FFFD+'A'+FFFD), # 1 invalid cv and 1 valid
- ('\xf1\x41\x80\x80', FFFD+'A'+FFFD*2), # 1 invalid cb and 2 invalid
- ('\xf1\x41\x80\x41', FFFD+'A'+FFFD+'A'), # 2 invalid cb and 1 invalid
- ('\xf1\x41\x41\x80', FFFD+'AA'+FFFD), # 1 valid cb and 1 invalid
- ('\xf1\x41\xf1\x80', FFFD+'A'+FFFD),
- ('\xf1\x41\x80\xf1', FFFD+'A'+FFFD*2),
- ('\xf1\xf1\x80\x41', FFFD*2+'A'),
- ('\xf1\x41\xf1\xf1', FFFD+'A'+FFFD*2),
+ (b'\xf1', FFFD), # only the start byte
+ (b'\xf1\xf1', FFFD*2), # 2 start bytes
+ (b'\xf1\xf1\xf1', FFFD*3), # 3 start bytes
+ (b'\xf1\xf1\xf1\xf1', FFFD*4), # 4 start bytes
+ (b'\xf1\xf1\xf1\xf1\xf1', FFFD*5), # 5 start bytes
+ (b'\xf1\x80', FFFD), # only 1 continuation bytes
+ (b'\xf1\x80\x80', FFFD), # only 2 continuation bytes
+ (b'\xf1\x80\x41', FFFD+'A'), # 1 valid cb and 1 invalid
+ (b'\xf1\x80\x41\x41', FFFD+'AA'), # 1 valid cb and 1 invalid
+ (b'\xf1\x80\x80\x41', FFFD+'A'), # 2 valid cb and 1 invalid
+ (b'\xf1\x41\x80', FFFD+'A'+FFFD), # 1 invalid cv and 1 valid
+ (b'\xf1\x41\x80\x80', FFFD+'A'+FFFD*2), # 1 invalid cb and 2 invalid
+ (b'\xf1\x41\x80\x41', FFFD+'A'+FFFD+'A'), # 2 invalid cb and 1 invalid
+ (b'\xf1\x41\x41\x80', FFFD+'AA'+FFFD), # 1 valid cb and 1 invalid
+ (b'\xf1\x41\xf1\x80', FFFD+'A'+FFFD),
+ (b'\xf1\x41\x80\xf1', FFFD+'A'+FFFD*2),
+ (b'\xf1\xf1\x80\x41', FFFD*2+'A'),
+ (b'\xf1\x41\xf1\xf1', FFFD+'A'+FFFD*2),
# with invalid start byte of a 4-byte sequence (rfc2279)
- ('\xf5', FFFD), # only the start byte
- ('\xf5\xf5', FFFD*2), # 2 start bytes
- ('\xf5\x80', FFFD*2), # only 1 continuation byte
- ('\xf5\x80\x80', FFFD*3), # only 2 continuation byte
- ('\xf5\x80\x80\x80', FFFD*4), # 3 continuation bytes
- ('\xf5\x80\x41', FFFD*2+'A'), # 1 valid cb and 1 invalid
- ('\xf5\x80\x41\xf5', FFFD*2+'A'+FFFD),
- ('\xf5\x41\x80\x80\x41', FFFD+'A'+FFFD*2+'A'),
+ (b'\xf5', FFFD), # only the start byte
+ (b'\xf5\xf5', FFFD*2), # 2 start bytes
+ (b'\xf5\x80', FFFD*2), # only 1 continuation byte
+ (b'\xf5\x80\x80', FFFD*3), # only 2 continuation byte
+ (b'\xf5\x80\x80\x80', FFFD*4), # 3 continuation bytes
+ (b'\xf5\x80\x41', FFFD*2+'A'), # 1 valid cb and 1 invalid
+ (b'\xf5\x80\x41\xf5', FFFD*2+'A'+FFFD),
+ (b'\xf5\x41\x80\x80\x41', FFFD+'A'+FFFD*2+'A'),
# with invalid start byte of a 5-byte sequence (rfc2279)
- ('\xf8', FFFD), # only the start byte
- ('\xf8\xf8', FFFD*2), # 2 start bytes
- ('\xf8\x80', FFFD*2), # only one continuation byte
- ('\xf8\x80\x41', FFFD*2 + 'A'), # 1 valid cb and 1 invalid
- ('\xf8\x80\x80\x80\x80', FFFD*5), # invalid 5 bytes seq with 5 bytes
+ (b'\xf8', FFFD), # only the start byte
+ (b'\xf8\xf8', FFFD*2), # 2 start bytes
+ (b'\xf8\x80', FFFD*2), # only one continuation byte
+ (b'\xf8\x80\x41', FFFD*2 + 'A'), # 1 valid cb and 1 invalid
+ (b'\xf8\x80\x80\x80\x80', FFFD*5), # invalid 5 bytes seq with 5 bytes
# with invalid start byte of a 6-byte sequence (rfc2279)
- ('\xfc', FFFD), # only the start byte
- ('\xfc\xfc', FFFD*2), # 2 start bytes
- ('\xfc\x80\x80', FFFD*3), # only 2 continuation bytes
- ('\xfc\x80\x80\x80\x80\x80', FFFD*6), # 6 continuation bytes
+ (b'\xfc', FFFD), # only the start byte
+ (b'\xfc\xfc', FFFD*2), # 2 start bytes
+ (b'\xfc\x80\x80', FFFD*3), # only 2 continuation bytes
+ (b'\xfc\x80\x80\x80\x80\x80', FFFD*6), # 6 continuation bytes
# invalid start byte
- ('\xfe', FFFD),
- ('\xfe\x80\x80', FFFD*3),
+ (b'\xfe', FFFD),
+ (b'\xfe\x80\x80', FFFD*3),
# other sequences
- ('\xf1\x80\x41\x42\x43', u'\ufffd\x41\x42\x43'),
- ('\xf1\x80\xff\x42\x43', u'\ufffd\ufffd\x42\x43'),
- ('\xf1\x80\xc2\x81\x43', u'\ufffd\x81\x43'),
- ('\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64',
- u'\x61\uFFFD\uFFFD\uFFFD\x62\uFFFD\x63\uFFFD\uFFFD\x64'),
+ (b'\xf1\x80\x41\x42\x43', '\ufffd\x41\x42\x43'),
+ (b'\xf1\x80\xff\x42\x43', '\ufffd\ufffd\x42\x43'),
+ (b'\xf1\x80\xc2\x81\x43', '\ufffd\x81\x43'),
+ (b'\x61\xF1\x80\x80\xE1\x80\xC2\x62\x80\x63\x80\xBF\x64',
+ '\x61\uFFFD\uFFFD\uFFFD\x62\uFFFD\x63\uFFFD\uFFFD\x64'),
]
for n, (seq, res) in enumerate(sequences):
self.assertRaises(UnicodeDecodeError, seq.decode, 'utf-8', 'strict')
self.assertEqual(seq.decode('utf-8', 'replace'), res)
- self.assertEqual((seq+'b').decode('utf-8', 'replace'), res+'b')
+ self.assertEqual((seq+b'b').decode('utf-8', 'replace'), res+'b')
self.assertEqual(seq.decode('utf-8', 'ignore'),
- res.replace(u'\uFFFD', ''))
+ res.replace('\uFFFD', ''))
def test_codecs_idna(self):
# Test whether trailing dot is preserved
- self.assertEqual(u"www.python.org.".encode("idna"), "www.python.org.")
+ self.assertEqual("www.python.org.".encode("idna"), b"www.python.org.")
def test_codecs_errors(self):
# Error handling (encoding)
- self.assertRaises(UnicodeError, u'Andr\202 x'.encode, 'ascii')
- self.assertRaises(UnicodeError, u'Andr\202 x'.encode, 'ascii','strict')
- self.assertEqual(u'Andr\202 x'.encode('ascii','ignore'), "Andr x")
- self.assertEqual(u'Andr\202 x'.encode('ascii','replace'), "Andr? x")
- self.assertEqual(u'Andr\202 x'.encode('ascii', 'replace'),
- u'Andr\202 x'.encode('ascii', errors='replace'))
- self.assertEqual(u'Andr\202 x'.encode('ascii', 'ignore'),
- u'Andr\202 x'.encode(encoding='ascii', errors='ignore'))
+ self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii')
+ self.assertRaises(UnicodeError, 'Andr\202 x'.encode, 'ascii','strict')
+ self.assertEqual('Andr\202 x'.encode('ascii','ignore'), b"Andr x")
+ self.assertEqual('Andr\202 x'.encode('ascii','replace'), b"Andr? x")
+ self.assertEqual('Andr\202 x'.encode('ascii', 'replace'),
+ 'Andr\202 x'.encode('ascii', errors='replace'))
+ self.assertEqual('Andr\202 x'.encode('ascii', 'ignore'),
+ 'Andr\202 x'.encode(encoding='ascii', errors='ignore'))
# Error handling (decoding)
- self.assertRaises(UnicodeError, unicode, 'Andr\202 x', 'ascii')
- self.assertRaises(UnicodeError, unicode, 'Andr\202 x', 'ascii','strict')
- self.assertEqual(unicode('Andr\202 x','ascii','ignore'), u"Andr x")
- self.assertEqual(unicode('Andr\202 x','ascii','replace'), u'Andr\uFFFD x')
- self.assertEqual(u'abcde'.decode('ascii', 'ignore'),
- u'abcde'.decode('ascii', errors='ignore'))
- self.assertEqual(u'abcde'.decode('ascii', 'replace'),
- u'abcde'.decode(encoding='ascii', errors='replace'))
+ self.assertRaises(UnicodeError, str, b'Andr\202 x', 'ascii')
+ self.assertRaises(UnicodeError, str, b'Andr\202 x', 'ascii', 'strict')
+ self.assertEqual(str(b'Andr\202 x', 'ascii', 'ignore'), "Andr x")
+ self.assertEqual(str(b'Andr\202 x', 'ascii', 'replace'), 'Andr\uFFFD x')
# Error handling (unknown character names)
- self.assertEqual("\\N{foo}xx".decode("unicode-escape", "ignore"), u"xx")
+ self.assertEqual(b"\\N{foo}xx".decode("unicode-escape", "ignore"), "xx")
# Error handling (truncated escape sequence)
- self.assertRaises(UnicodeError, "\\".decode, "unicode-escape")
+ self.assertRaises(UnicodeError, b"\\".decode, "unicode-escape")
- self.assertRaises(TypeError, "hello".decode, "test.unicode1")
- self.assertRaises(TypeError, unicode, "hello", "test.unicode2")
- self.assertRaises(TypeError, u"hello".encode, "test.unicode1")
- self.assertRaises(TypeError, u"hello".encode, "test.unicode2")
+ self.assertRaises(TypeError, b"hello".decode, "test.unicode1")
+ self.assertRaises(TypeError, str, b"hello", "test.unicode2")
+ self.assertRaises(TypeError, "hello".encode, "test.unicode1")
+ self.assertRaises(TypeError, "hello".encode, "test.unicode2")
# executes PyUnicode_Encode()
import imp
self.assertRaises(
ImportError,
imp.find_module,
"non-existing module",
- [u"non-existing dir"]
+ ["non-existing dir"]
)
# Error handling (wrong arguments)
- self.assertRaises(TypeError, u"hello".encode, 42, 42, 42)
+ self.assertRaises(TypeError, "hello".encode, 42, 42, 42)
- # Error handling (PyUnicode_EncodeDecimal())
- self.assertRaises(UnicodeError, int, u"\u0200")
+ # Error handling (lone surrogate in PyUnicode_TransformDecimalToASCII())
+ self.assertRaises(UnicodeError, int, "\ud800")
+ self.assertRaises(UnicodeError, int, "\udf00")
+ self.assertRaises(UnicodeError, float, "\ud800")
+ self.assertRaises(UnicodeError, float, "\udf00")
+ self.assertRaises(UnicodeError, complex, "\ud800")
+ self.assertRaises(UnicodeError, complex, "\udf00")
def test_codecs(self):
# Encoding
- self.assertEqual(u'hello'.encode('ascii'), 'hello')
- self.assertEqual(u'hello'.encode('utf-7'), 'hello')
- self.assertEqual(u'hello'.encode('utf-8'), 'hello')
- self.assertEqual(u'hello'.encode('utf8'), 'hello')
- self.assertEqual(u'hello'.encode('utf-16-le'), 'h\000e\000l\000l\000o\000')
- self.assertEqual(u'hello'.encode('utf-16-be'), '\000h\000e\000l\000l\000o')
- self.assertEqual(u'hello'.encode('latin-1'), 'hello')
+ self.assertEqual('hello'.encode('ascii'), b'hello')
+ self.assertEqual('hello'.encode('utf-7'), b'hello')
+ self.assertEqual('hello'.encode('utf-8'), b'hello')
+ self.assertEqual('hello'.encode('utf8'), b'hello')
+ self.assertEqual('hello'.encode('utf-16-le'), b'h\000e\000l\000l\000o\000')
+ self.assertEqual('hello'.encode('utf-16-be'), b'\000h\000e\000l\000l\000o')
+ self.assertEqual('hello'.encode('latin-1'), b'hello')
# Roundtrip safety for BMP (just the first 1024 chars)
- for c in xrange(1024):
- u = unichr(c)
+ for c in range(1024):
+ u = chr(c)
for encoding in ('utf-7', 'utf-8', 'utf-16', 'utf-16-le',
'utf-16-be', 'raw_unicode_escape',
'unicode_escape', 'unicode_internal'):
- self.assertEqual(unicode(u.encode(encoding),encoding), u)
+ self.assertEqual(str(u.encode(encoding),encoding), u)
# Roundtrip safety for BMP (just the first 256 chars)
- for c in xrange(256):
- u = unichr(c)
+ for c in range(256):
+ u = chr(c)
for encoding in ('latin-1',):
- self.assertEqual(unicode(u.encode(encoding),encoding), u)
+ self.assertEqual(str(u.encode(encoding),encoding), u)
# Roundtrip safety for BMP (just the first 128 chars)
- for c in xrange(128):
- u = unichr(c)
+ for c in range(128):
+ u = chr(c)
for encoding in ('ascii',):
- self.assertEqual(unicode(u.encode(encoding),encoding), u)
+ self.assertEqual(str(u.encode(encoding),encoding), u)
# Roundtrip safety for non-BMP (just a few chars)
- u = u'\U00010001\U00020002\U00030003\U00040004\U00050005'
+ u = '\U00010001\U00020002\U00030003\U00040004\U00050005'
for encoding in ('utf-8', 'utf-16', 'utf-16-le', 'utf-16-be',
#'raw_unicode_escape',
'unicode_escape', 'unicode_internal'):
- self.assertEqual(unicode(u.encode(encoding),encoding), u)
+ self.assertEqual(str(u.encode(encoding),encoding), u)
# UTF-8 must be roundtrip safe for all UCS-2 code points
# This excludes surrogates: in the full range, there would be
# a surrogate pair (\udbff\udc00), which gets converted back
# to a non-BMP character (\U0010fc00)
- u = u''.join(map(unichr, range(0,0xd800)+range(0xe000,0x10000)))
+ u = ''.join(map(chr, list(range(0,0xd800)) +
+ list(range(0xe000,0x10000))))
for encoding in ('utf-8',):
- self.assertEqual(unicode(u.encode(encoding),encoding), u)
+ self.assertEqual(str(u.encode(encoding),encoding), u)
def test_codecs_charmap(self):
# 0-127
- s = ''.join(map(chr, xrange(128)))
+ s = bytes(range(128))
for encoding in (
'cp037', 'cp1026',
'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850',
@@ -1133,10 +1484,10 @@ class UnicodeTest(
#'cp875'
):
- self.assertEqual(unicode(s, encoding).encode(encoding), s)
+ self.assertEqual(str(s, encoding).encode(encoding), s)
# 128-255
- s = ''.join(map(chr, xrange(128, 256)))
+ s = bytes(range(128, 256))
for encoding in (
'cp037', 'cp1026',
'cp437', 'cp500', 'cp720', 'cp737', 'cp775', 'cp850',
@@ -1158,14 +1509,14 @@ class UnicodeTest(
#'cp1006', 'cp875', 'iso8859_8',
):
- self.assertEqual(unicode(s, encoding).encode(encoding), s)
+ self.assertEqual(str(s, encoding).encode(encoding), s)
def test_concatenation(self):
- self.assertEqual((u"abc" u"def"), u"abcdef")
- self.assertEqual(("abc" u"def"), u"abcdef")
- self.assertEqual((u"abc" "def"), u"abcdef")
- self.assertEqual((u"abc" u"def" "ghi"), u"abcdefghi")
- self.assertEqual(("abc" "def" u"ghi"), u"abcdefghi")
+ self.assertEqual(("abc" "def"), "abcdef")
+ self.assertEqual(("abc" "def"), "abcdef")
+ self.assertEqual(("abc" "def"), "abcdef")
+ self.assertEqual(("abc" "def" "ghi"), "abcdefghi")
+ self.assertEqual(("abc" "def" "ghi"), "abcdefghi")
def test_printing(self):
class BitBucket:
@@ -1173,30 +1524,30 @@ class UnicodeTest(
pass
out = BitBucket()
- print >>out, u'abc'
- print >>out, u'abc', u'def'
- print >>out, u'abc', 'def'
- print >>out, 'abc', u'def'
- print >>out, u'abc\n'
- print >>out, u'abc\n',
- print >>out, u'abc\n',
- print >>out, u'def\n'
- print >>out, u'def\n'
+ print('abc', file=out)
+ print('abc', 'def', file=out)
+ print('abc', 'def', file=out)
+ print('abc', 'def', file=out)
+ print('abc\n', file=out)
+ print('abc\n', end=' ', file=out)
+ print('abc\n', end=' ', file=out)
+ print('def\n', file=out)
+ print('def\n', file=out)
def test_ucs4(self):
- x = u'\U00100000'
+ x = '\U00100000'
y = x.encode("raw-unicode-escape").decode("raw-unicode-escape")
self.assertEqual(x, y)
- y = r'\U00100000'
+ y = br'\U00100000'
x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
self.assertEqual(x, y)
- y = r'\U00010000'
+ y = br'\U00010000'
x = y.decode("raw-unicode-escape").encode("raw-unicode-escape")
self.assertEqual(x, y)
try:
- '\U11111111'.decode("raw-unicode-escape")
+ br'\U11111111'.decode("raw-unicode-escape")
except UnicodeDecodeError as e:
self.assertEqual(e.start, 0)
self.assertEqual(e.end, 10)
@@ -1210,61 +1561,58 @@ class UnicodeTest(
return "foo"
class Foo1:
- def __unicode__(self):
- return u"foo"
+ def __str__(self):
+ return "foo"
class Foo2(object):
- def __unicode__(self):
- return u"foo"
+ def __str__(self):
+ return "foo"
class Foo3(object):
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo4(str):
- def __unicode__(self):
+ def __str__(self):
return "foo"
- class Foo5(unicode):
- def __unicode__(self):
+ class Foo5(str):
+ def __str__(self):
return "foo"
class Foo6(str):
def __str__(self):
return "foos"
- def __unicode__(self):
- return u"foou"
+ def __str__(self):
+ return "foou"
- class Foo7(unicode):
+ class Foo7(str):
def __str__(self):
return "foos"
- def __unicode__(self):
- return u"foou"
+ def __str__(self):
+ return "foou"
- class Foo8(unicode):
+ class Foo8(str):
def __new__(cls, content=""):
- return unicode.__new__(cls, 2*content)
- def __unicode__(self):
+ return str.__new__(cls, 2*content)
+ def __str__(self):
return self
- class Foo9(unicode):
+ class Foo9(str):
def __str__(self):
- return "string"
- def __unicode__(self):
return "not unicode"
- self.assertEqual(unicode(Foo0()), u"foo")
- self.assertEqual(unicode(Foo1()), u"foo")
- self.assertEqual(unicode(Foo2()), u"foo")
- self.assertEqual(unicode(Foo3()), u"foo")
- self.assertEqual(unicode(Foo4("bar")), u"foo")
- self.assertEqual(unicode(Foo5("bar")), u"foo")
- self.assertEqual(unicode(Foo6("bar")), u"foou")
- self.assertEqual(unicode(Foo7("bar")), u"foou")
- self.assertEqual(unicode(Foo8("foo")), u"foofoo")
- self.assertEqual(str(Foo9("foo")), "string")
- self.assertEqual(unicode(Foo9("foo")), u"not unicode")
+ self.assertEqual(str(Foo0()), "foo")
+ self.assertEqual(str(Foo1()), "foo")
+ self.assertEqual(str(Foo2()), "foo")
+ self.assertEqual(str(Foo3()), "foo")
+ self.assertEqual(str(Foo4("bar")), "foo")
+ self.assertEqual(str(Foo5("bar")), "foo")
+ self.assertEqual(str(Foo6("bar")), "foou")
+ self.assertEqual(str(Foo7("bar")), "foou")
+ self.assertEqual(str(Foo8("foo")), "foofoo")
+ self.assertEqual(str(Foo9("foo")), "not unicode")
def test_unicode_repr(self):
class s1:
@@ -1273,345 +1621,22 @@ class UnicodeTest(
class s2:
def __repr__(self):
- return u'\\n'
+ return '\\n'
self.assertEqual(repr(s1()), '\\n')
self.assertEqual(repr(s2()), '\\n')
+ def test_printable_repr(self):
+ self.assertEqual(repr('\U00010000'), "'%c'" % (0x10000,)) # printable
+ self.assertEqual(repr('\U00014000'), "'\\U00014000'") # nonprintable
+
def test_expandtabs_overflows_gracefully(self):
# This test only affects 32-bit platforms because expandtabs can only take
# an int as the max value, not a 64-bit C long. If expandtabs is changed
# to take a 64-bit long, this test should apply to all platforms.
- if sys.maxint > (1 << 32) or struct.calcsize('P') != 4:
+ if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4:
return
- self.assertRaises(OverflowError, u't\tt\t'.expandtabs, sys.maxint)
-
- def test__format__(self):
- def test(value, format, expected):
- # test both with and without the trailing 's'
- self.assertEqual(value.__format__(format), expected)
- self.assertEqual(value.__format__(format + u's'), expected)
-
- test(u'', u'', u'')
- test(u'abc', u'', u'abc')
- test(u'abc', u'.3', u'abc')
- test(u'ab', u'.3', u'ab')
- test(u'abcdef', u'.3', u'abc')
- test(u'abcdef', u'.0', u'')
- test(u'abc', u'3.3', u'abc')
- test(u'abc', u'2.3', u'abc')
- test(u'abc', u'2.2', u'ab')
- test(u'abc', u'3.2', u'ab ')
- test(u'result', u'x<0', u'result')
- test(u'result', u'x<5', u'result')
- test(u'result', u'x<6', u'result')
- test(u'result', u'x<7', u'resultx')
- test(u'result', u'x<8', u'resultxx')
- test(u'result', u' <7', u'result ')
- test(u'result', u'<7', u'result ')
- test(u'result', u'>7', u' result')
- test(u'result', u'>8', u' result')
- test(u'result', u'^8', u' result ')
- test(u'result', u'^9', u' result ')
- test(u'result', u'^10', u' result ')
- test(u'a', u'10000', u'a' + u' ' * 9999)
- test(u'', u'10000', u' ' * 10000)
- test(u'', u'10000000', u' ' * 10000000)
-
- # test mixing unicode and str
- self.assertEqual(u'abc'.__format__('s'), u'abc')
- self.assertEqual(u'abc'.__format__('->10s'), u'-------abc')
-
- def test_format(self):
- self.assertEqual(u''.format(), u'')
- self.assertEqual(u'a'.format(), u'a')
- self.assertEqual(u'ab'.format(), u'ab')
- self.assertEqual(u'a{{'.format(), u'a{')
- self.assertEqual(u'a}}'.format(), u'a}')
- self.assertEqual(u'{{b'.format(), u'{b')
- self.assertEqual(u'}}b'.format(), u'}b')
- self.assertEqual(u'a{{b'.format(), u'a{b')
-
- # examples from the PEP:
- import datetime
- self.assertEqual(u"My name is {0}".format(u'Fred'), u"My name is Fred")
- self.assertEqual(u"My name is {0[name]}".format(dict(name=u'Fred')),
- u"My name is Fred")
- self.assertEqual(u"My name is {0} :-{{}}".format(u'Fred'),
- u"My name is Fred :-{}")
-
- # datetime.__format__ doesn't work with unicode
- #d = datetime.date(2007, 8, 18)
- #self.assertEqual("The year is {0.year}".format(d),
- # "The year is 2007")
-
- # classes we'll use for testing
- class C:
- def __init__(self, x=100):
- self._x = x
- def __format__(self, spec):
- return spec
-
- class D:
- def __init__(self, x):
- self.x = x
- def __format__(self, spec):
- return str(self.x)
-
- # class with __str__, but no __format__
- class E:
- def __init__(self, x):
- self.x = x
- def __str__(self):
- return u'E(' + self.x + u')'
-
- # class with __repr__, but no __format__ or __str__
- class F:
- def __init__(self, x):
- self.x = x
- def __repr__(self):
- return u'F(' + self.x + u')'
-
- # class with __format__ that forwards to string, for some format_spec's
- class G:
- def __init__(self, x):
- self.x = x
- def __str__(self):
- return u"string is " + self.x
- def __format__(self, format_spec):
- if format_spec == 'd':
- return u'G(' + self.x + u')'
- return object.__format__(self, format_spec)
-
- # class that returns a bad type from __format__
- class H:
- def __format__(self, format_spec):
- return 1.0
-
- class I(datetime.date):
- def __format__(self, format_spec):
- return self.strftime(format_spec)
-
- class J(int):
- def __format__(self, format_spec):
- return int.__format__(self * 2, format_spec)
-
-
- self.assertEqual(u''.format(), u'')
- self.assertEqual(u'abc'.format(), u'abc')
- self.assertEqual(u'{0}'.format(u'abc'), u'abc')
- self.assertEqual(u'{0:}'.format(u'abc'), u'abc')
- self.assertEqual(u'X{0}'.format(u'abc'), u'Xabc')
- self.assertEqual(u'{0}X'.format(u'abc'), u'abcX')
- self.assertEqual(u'X{0}Y'.format(u'abc'), u'XabcY')
- self.assertEqual(u'{1}'.format(1, u'abc'), u'abc')
- self.assertEqual(u'X{1}'.format(1, u'abc'), u'Xabc')
- self.assertEqual(u'{1}X'.format(1, u'abc'), u'abcX')
- self.assertEqual(u'X{1}Y'.format(1, u'abc'), u'XabcY')
- self.assertEqual(u'{0}'.format(-15), u'-15')
- self.assertEqual(u'{0}{1}'.format(-15, u'abc'), u'-15abc')
- self.assertEqual(u'{0}X{1}'.format(-15, u'abc'), u'-15Xabc')
- self.assertEqual(u'{{'.format(), u'{')
- self.assertEqual(u'}}'.format(), u'}')
- self.assertEqual(u'{{}}'.format(), u'{}')
- self.assertEqual(u'{{x}}'.format(), u'{x}')
- self.assertEqual(u'{{{0}}}'.format(123), u'{123}')
- self.assertEqual(u'{{{{0}}}}'.format(), u'{{0}}')
- self.assertEqual(u'}}{{'.format(), u'}{')
- self.assertEqual(u'}}x{{'.format(), u'}x{')
-
- # weird field names
- self.assertEqual(u"{0[foo-bar]}".format({u'foo-bar':u'baz'}), u'baz')
- self.assertEqual(u"{0[foo bar]}".format({u'foo bar':u'baz'}), u'baz')
- self.assertEqual(u"{0[ ]}".format({u' ':3}), u'3')
-
- self.assertEqual(u'{foo._x}'.format(foo=C(20)), u'20')
- self.assertEqual(u'{1}{0}'.format(D(10), D(20)), u'2010')
- self.assertEqual(u'{0._x.x}'.format(C(D(u'abc'))), u'abc')
- self.assertEqual(u'{0[0]}'.format([u'abc', u'def']), u'abc')
- self.assertEqual(u'{0[1]}'.format([u'abc', u'def']), u'def')
- self.assertEqual(u'{0[1][0]}'.format([u'abc', [u'def']]), u'def')
- self.assertEqual(u'{0[1][0].x}'.format(['abc', [D(u'def')]]), u'def')
-
- # strings
- self.assertEqual(u'{0:.3s}'.format(u'abc'), u'abc')
- self.assertEqual(u'{0:.3s}'.format(u'ab'), u'ab')
- self.assertEqual(u'{0:.3s}'.format(u'abcdef'), u'abc')
- self.assertEqual(u'{0:.0s}'.format(u'abcdef'), u'')
- self.assertEqual(u'{0:3.3s}'.format(u'abc'), u'abc')
- self.assertEqual(u'{0:2.3s}'.format(u'abc'), u'abc')
- self.assertEqual(u'{0:2.2s}'.format(u'abc'), u'ab')
- self.assertEqual(u'{0:3.2s}'.format(u'abc'), u'ab ')
- self.assertEqual(u'{0:x<0s}'.format(u'result'), u'result')
- self.assertEqual(u'{0:x<5s}'.format(u'result'), u'result')
- self.assertEqual(u'{0:x<6s}'.format(u'result'), u'result')
- self.assertEqual(u'{0:x<7s}'.format(u'result'), u'resultx')
- self.assertEqual(u'{0:x<8s}'.format(u'result'), u'resultxx')
- self.assertEqual(u'{0: <7s}'.format(u'result'), u'result ')
- self.assertEqual(u'{0:<7s}'.format(u'result'), u'result ')
- self.assertEqual(u'{0:>7s}'.format(u'result'), u' result')
- self.assertEqual(u'{0:>8s}'.format(u'result'), u' result')
- self.assertEqual(u'{0:^8s}'.format(u'result'), u' result ')
- self.assertEqual(u'{0:^9s}'.format(u'result'), u' result ')
- self.assertEqual(u'{0:^10s}'.format(u'result'), u' result ')
- self.assertEqual(u'{0:10000}'.format(u'a'), u'a' + u' ' * 9999)
- self.assertEqual(u'{0:10000}'.format(u''), u' ' * 10000)
- self.assertEqual(u'{0:10000000}'.format(u''), u' ' * 10000000)
-
- # format specifiers for user defined type
- self.assertEqual(u'{0:abc}'.format(C()), u'abc')
-
- # !r and !s coercions
- self.assertEqual(u'{0!s}'.format(u'Hello'), u'Hello')
- self.assertEqual(u'{0!s:}'.format(u'Hello'), u'Hello')
- self.assertEqual(u'{0!s:15}'.format(u'Hello'), u'Hello ')
- self.assertEqual(u'{0!s:15s}'.format(u'Hello'), u'Hello ')
- self.assertEqual(u'{0!r}'.format(u'Hello'), u"u'Hello'")
- self.assertEqual(u'{0!r:}'.format(u'Hello'), u"u'Hello'")
- self.assertEqual(u'{0!r}'.format(F(u'Hello')), u'F(Hello)')
-
- # test fallback to object.__format__
- self.assertEqual(u'{0}'.format({}), u'{}')
- self.assertEqual(u'{0}'.format([]), u'[]')
- self.assertEqual(u'{0}'.format([1]), u'[1]')
- self.assertEqual(u'{0}'.format(E(u'data')), u'E(data)')
- self.assertEqual(u'{0:d}'.format(G(u'data')), u'G(data)')
- self.assertEqual(u'{0!s}'.format(G(u'data')), u'string is data')
-
- msg = 'object.__format__ with a non-empty format string is deprecated'
- with test_support.check_warnings((msg, PendingDeprecationWarning)):
- self.assertEqual(u'{0:^10}'.format(E(u'data')), u' E(data) ')
- self.assertEqual(u'{0:^10s}'.format(E(u'data')), u' E(data) ')
- self.assertEqual(u'{0:>15s}'.format(G(u'data')), u' string is data')
-
- self.assertEqual(u"{0:date: %Y-%m-%d}".format(I(year=2007,
- month=8,
- day=27)),
- u"date: 2007-08-27")
-
- # test deriving from a builtin type and overriding __format__
- self.assertEqual(u"{0}".format(J(10)), u"20")
-
-
- # string format specifiers
- self.assertEqual(u'{0:}'.format('a'), u'a')
-
- # computed format specifiers
- self.assertEqual(u"{0:.{1}}".format(u'hello world', 5), u'hello')
- self.assertEqual(u"{0:.{1}s}".format(u'hello world', 5), u'hello')
- self.assertEqual(u"{0:.{precision}s}".format('hello world', precision=5), u'hello')
- self.assertEqual(u"{0:{width}.{precision}s}".format('hello world', width=10, precision=5), u'hello ')
- self.assertEqual(u"{0:{width}.{precision}s}".format('hello world', width='10', precision='5'), u'hello ')
-
- # test various errors
- self.assertRaises(ValueError, u'{'.format)
- self.assertRaises(ValueError, u'}'.format)
- self.assertRaises(ValueError, u'a{'.format)
- self.assertRaises(ValueError, u'a}'.format)
- self.assertRaises(ValueError, u'{a'.format)
- self.assertRaises(ValueError, u'}a'.format)
- self.assertRaises(IndexError, u'{0}'.format)
- self.assertRaises(IndexError, u'{1}'.format, u'abc')
- self.assertRaises(KeyError, u'{x}'.format)
- self.assertRaises(ValueError, u"}{".format)
- self.assertRaises(ValueError, u"{".format)
- self.assertRaises(ValueError, u"}".format)
- self.assertRaises(ValueError, u"abc{0:{}".format)
- self.assertRaises(ValueError, u"{0".format)
- self.assertRaises(IndexError, u"{0.}".format)
- self.assertRaises(ValueError, u"{0.}".format, 0)
- self.assertRaises(IndexError, u"{0[}".format)
- self.assertRaises(ValueError, u"{0[}".format, [])
- self.assertRaises(KeyError, u"{0]}".format)
- self.assertRaises(ValueError, u"{0.[]}".format, 0)
- self.assertRaises(ValueError, u"{0..foo}".format, 0)
- self.assertRaises(ValueError, u"{0[0}".format, 0)
- self.assertRaises(ValueError, u"{0[0:foo}".format, 0)
- self.assertRaises(KeyError, u"{c]}".format)
- self.assertRaises(ValueError, u"{{ {{{0}}".format, 0)
- self.assertRaises(ValueError, u"{0}}".format, 0)
- self.assertRaises(KeyError, u"{foo}".format, bar=3)
- self.assertRaises(ValueError, u"{0!x}".format, 3)
- self.assertRaises(ValueError, u"{0!}".format, 0)
- self.assertRaises(ValueError, u"{0!rs}".format, 0)
- self.assertRaises(ValueError, u"{!}".format)
- self.assertRaises(IndexError, u"{:}".format)
- self.assertRaises(IndexError, u"{:s}".format)
- self.assertRaises(IndexError, u"{}".format)
- big = u"23098475029384702983476098230754973209482573"
- self.assertRaises(ValueError, (u"{" + big + u"}").format)
- self.assertRaises(ValueError, (u"{[" + big + u"]}").format, [0])
-
- # issue 6089
- self.assertRaises(ValueError, u"{0[0]x}".format, [None])
- self.assertRaises(ValueError, u"{0[0](10)}".format, [None])
-
- # can't have a replacement on the field name portion
- self.assertRaises(TypeError, u'{0[{1}]}'.format, u'abcdefg', 4)
-
- # exceed maximum recursion depth
- self.assertRaises(ValueError, u"{0:{1:{2}}}".format, u'abc', u's', u'')
- self.assertRaises(ValueError, u"{0:{1:{2:{3:{4:{5:{6}}}}}}}".format,
- 0, 1, 2, 3, 4, 5, 6, 7)
-
- # string format spec errors
- self.assertRaises(ValueError, u"{0:-s}".format, u'')
- self.assertRaises(ValueError, format, u"", u"-")
- self.assertRaises(ValueError, u"{0:=s}".format, u'')
-
- # test combining string and unicode
- self.assertEqual(u"foo{0}".format('bar'), u'foobar')
- # This will try to convert the argument from unicode to str, which
- # will succeed
- self.assertEqual("foo{0}".format(u'bar'), 'foobar')
- # This will try to convert the argument from unicode to str, which
- # will fail
- self.assertRaises(UnicodeEncodeError, "foo{0}".format, u'\u1000bar')
-
- def test_format_huge_precision(self):
- format_string = u".{}f".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format(2.34, format_string)
-
- def test_format_huge_width(self):
- format_string = u"{}f".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format(2.34, format_string)
-
- def test_format_huge_item_number(self):
- format_string = u"{{{}:.6f}}".format(sys.maxsize + 1)
- with self.assertRaises(ValueError):
- result = format_string.format(2.34)
-
- def test_format_auto_numbering(self):
- class C:
- def __init__(self, x=100):
- self._x = x
- def __format__(self, spec):
- return spec
-
- self.assertEqual(u'{}'.format(10), u'10')
- self.assertEqual(u'{:5}'.format('s'), u's ')
- self.assertEqual(u'{!r}'.format('s'), u"'s'")
- self.assertEqual(u'{._x}'.format(C(10)), u'10')
- self.assertEqual(u'{[1]}'.format([1, 2]), u'2')
- self.assertEqual(u'{[a]}'.format({'a':4, 'b':2}), u'4')
- self.assertEqual(u'a{}b{}c'.format(0, 1), u'a0b1c')
-
- self.assertEqual(u'a{:{}}b'.format('x', '^10'), u'a x b')
- self.assertEqual(u'a{:{}x}b'.format(20, '#'), u'a0x14b')
-
- # can't mix and match numbering and auto-numbering
- self.assertRaises(ValueError, u'{}{1}'.format, 1, 2)
- self.assertRaises(ValueError, u'{1}{}'.format, 1, 2)
- self.assertRaises(ValueError, u'{:{1}}'.format, 1, 2)
- self.assertRaises(ValueError, u'{0:{}}'.format, 1, 2)
-
- # can mix and match auto-numbering and named
- self.assertEqual(u'{f}{}'.format(4, f='test'), u'test4')
- self.assertEqual(u'{}{f}'.format(4, f='test'), u'4test')
- self.assertEqual(u'{:{f}}{g}{}'.format(1, 3, g='g', f=2), u' 1g3')
- self.assertEqual(u'{f:{}}{}{g}'.format(2, 4, f=1, g='g'), u' 14g')
+ self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize)
def test_raiseMemError(self):
# Ensure that the freelist contains a consistent object, even
@@ -1621,46 +1646,216 @@ class UnicodeTest(
charwidth = 4 if sys.maxunicode >= 0x10000 else 2
# Note: sys.maxsize is half of the actual max allocation because of
# the signedness of Py_ssize_t.
- alloc = lambda: u"a" * (sys.maxsize // charwidth * 2)
+ alloc = lambda: "a" * (sys.maxsize // charwidth * 2)
self.assertRaises(MemoryError, alloc)
self.assertRaises(MemoryError, alloc)
def test_format_subclass(self):
- class U(unicode):
- def __unicode__(self):
- return u'__unicode__ overridden'
- u = U(u'xxx')
- self.assertEqual("%s" % u, u'__unicode__ overridden')
- self.assertEqual("{}".format(u), '__unicode__ overridden')
+ class S(str):
+ def __str__(self):
+ return '__str__ overridden'
+ s = S('xxx')
+ self.assertEqual("%s" % s, '__str__ overridden')
+ self.assertEqual("{}".format(s), '__str__ overridden')
+
+ # Test PyUnicode_FromFormat()
+ def test_from_format(self):
+ support.import_module('ctypes')
+ from ctypes import pythonapi, py_object, c_int
+ if sys.maxunicode == 65535:
+ name = "PyUnicodeUCS2_FromFormat"
+ else:
+ name = "PyUnicodeUCS4_FromFormat"
+ _PyUnicode_FromFormat = getattr(pythonapi, name)
+ _PyUnicode_FromFormat.restype = py_object
+
+ def PyUnicode_FromFormat(format, *args):
+ cargs = tuple(
+ py_object(arg) if isinstance(arg, str) else arg
+ for arg in args)
+ return _PyUnicode_FromFormat(format, *cargs)
+
+ # ascii format, non-ascii argument
+ text = PyUnicode_FromFormat(b'ascii\x7f=%U', 'unicode\xe9')
+ self.assertEqual(text, 'ascii\x7f=unicode\xe9')
+
+ # non-ascii format, ascii argument: ensure that PyUnicode_FromFormatV()
+ # raises an error
+ self.assertRaisesRegex(ValueError,
+ '^PyUnicode_FromFormatV\(\) expects an ASCII-encoded format '
+ 'string, got a non-ASCII byte: 0xe9$',
+ PyUnicode_FromFormat, b'unicode\xe9=%s', 'ascii')
+
+ self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0xabcd)), '\uabcd')
+ self.assertEqual(PyUnicode_FromFormat(b'%c', c_int(0x10ffff)), '\U0010ffff')
+
+ # other tests
+ text = PyUnicode_FromFormat(b'%%A:%A', 'abc\xe9\uabcd\U0010ffff')
+ self.assertEqual(text, r"%A:'abc\xe9\uabcd\U0010ffff'")
+
+ text = PyUnicode_FromFormat(b'repr=%V', 'abc', b'xyz')
+ self.assertEqual(text, 'repr=abc')
+
+ # Test string decode from parameter of %s using utf-8.
+ # b'\xe4\xba\xba\xe6\xb0\x91' is utf-8 encoded byte sequence of
+ # '\u4eba\u6c11'
+ text = PyUnicode_FromFormat(b'repr=%V', None, b'\xe4\xba\xba\xe6\xb0\x91')
+ self.assertEqual(text, 'repr=\u4eba\u6c11')
+
+ #Test replace error handler.
+ text = PyUnicode_FromFormat(b'repr=%V', None, b'abc\xff')
+ self.assertEqual(text, 'repr=abc\ufffd')
+
+ # Test PyUnicode_AsWideChar()
+ def test_aswidechar(self):
+ from _testcapi import unicode_aswidechar
+ support.import_module('ctypes')
+ from ctypes import c_wchar, sizeof
+
+ wchar, size = unicode_aswidechar('abcdef', 2)
+ self.assertEqual(size, 2)
+ self.assertEqual(wchar, 'ab')
+
+ wchar, size = unicode_aswidechar('abc', 3)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc')
+
+ wchar, size = unicode_aswidechar('abc', 4)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidechar('abc', 10)
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidechar('abc\0def', 20)
+ self.assertEqual(size, 7)
+ self.assertEqual(wchar, 'abc\0def\0')
+
+ nonbmp = chr(0x10ffff)
+ if sizeof(c_wchar) == 2:
+ buflen = 3
+ nchar = 2
+ else: # sizeof(c_wchar) == 4
+ buflen = 2
+ nchar = 1
+ wchar, size = unicode_aswidechar(nonbmp, buflen)
+ self.assertEqual(size, nchar)
+ self.assertEqual(wchar, nonbmp + '\0')
+
+ # Test PyUnicode_AsWideCharString()
+ def test_aswidecharstring(self):
+ from _testcapi import unicode_aswidecharstring
+ support.import_module('ctypes')
+ from ctypes import c_wchar, sizeof
+
+ wchar, size = unicode_aswidecharstring('abc')
+ self.assertEqual(size, 3)
+ self.assertEqual(wchar, 'abc\0')
+
+ wchar, size = unicode_aswidecharstring('abc\0def')
+ self.assertEqual(size, 7)
+ self.assertEqual(wchar, 'abc\0def\0')
+
+ nonbmp = chr(0x10ffff)
+ if sizeof(c_wchar) == 2:
+ nchar = 2
+ else: # sizeof(c_wchar) == 4
+ nchar = 1
+ wchar, size = unicode_aswidecharstring(nonbmp)
+ self.assertEqual(size, nchar)
+ self.assertEqual(wchar, nonbmp + '\0')
+
+
+class StringModuleTest(unittest.TestCase):
+ def test_formatter_parser(self):
+ def parse(format):
+ return list(_string.formatter_parser(format))
+
+ formatter = parse("prefix {2!s}xxx{0:^+10.3f}{obj.attr!s} {z[0]!s:10}")
+ self.assertEqual(formatter, [
+ ('prefix ', '2', '', 's'),
+ ('xxx', '0', '^+10.3f', None),
+ ('', 'obj.attr', '', 's'),
+ (' ', 'z[0]', '10', 's'),
+ ])
+
+ formatter = parse("prefix {} suffix")
+ self.assertEqual(formatter, [
+ ('prefix ', '', '', None),
+ (' suffix', None, None, None),
+ ])
+
+ formatter = parse("str")
+ self.assertEqual(formatter, [
+ ('str', None, None, None),
+ ])
+
+ formatter = parse("")
+ self.assertEqual(formatter, [])
+
+ formatter = parse("{0}")
+ self.assertEqual(formatter, [
+ ('', '0', '', None),
+ ])
+
+ self.assertRaises(TypeError, _string.formatter_parser, 1)
+
+ def test_formatter_field_name_split(self):
+ def split(name):
+ items = list(_string.formatter_field_name_split(name))
+ items[1] = list(items[1])
+ return items
+ self.assertEqual(split("obj"), ["obj", []])
+ self.assertEqual(split("obj.arg"), ["obj", [(True, 'arg')]])
+ self.assertEqual(split("obj[key]"), ["obj", [(False, 'key')]])
+ self.assertEqual(split("obj.arg[key1][key2]"), [
+ "obj",
+ [(True, 'arg'),
+ (False, 'key1'),
+ (False, 'key2'),
+ ]])
+ self.assertRaises(TypeError, _string.formatter_field_name_split, 1)
def test_encode_decimal(self):
from _testcapi import unicode_encodedecimal
- self.assertEqual(unicode_encodedecimal(u'123'),
+ self.assertEqual(unicode_encodedecimal('123'),
b'123')
- self.assertEqual(unicode_encodedecimal(u'\u0663.\u0661\u0664'),
+ self.assertEqual(unicode_encodedecimal('\u0663.\u0661\u0664'),
b'3.14')
- self.assertEqual(unicode_encodedecimal(u"\N{EM SPACE}3.14\N{EN SPACE}"),
+ self.assertEqual(unicode_encodedecimal("\N{EM SPACE}3.14\N{EN SPACE}"),
b' 3.14 ')
self.assertRaises(UnicodeEncodeError,
- unicode_encodedecimal, u"123\u20ac", "strict")
- self.assertEqual(unicode_encodedecimal(u"123\u20ac", "replace"),
+ unicode_encodedecimal, "123\u20ac", "strict")
+ self.assertEqual(unicode_encodedecimal("123\u20ac", "replace"),
b'123?')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac", "ignore"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac", "ignore"),
b'123')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac", "xmlcharrefreplace"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac", "xmlcharrefreplace"),
b'123&#8364;')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac", "backslashreplace"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac", "backslashreplace"),
b'123\\u20ac')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac\N{EM SPACE}", "replace"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac\N{EM SPACE}", "replace"),
b'123? ')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac\u20ac", "replace"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac\u20ac", "replace"),
b'123??')
- self.assertEqual(unicode_encodedecimal(u"123\u20ac\u0660", "replace"),
+ self.assertEqual(unicode_encodedecimal("123\u20ac\u0660", "replace"),
b'123?0')
+ def test_transform_decimal(self):
+ from _testcapi import unicode_transformdecimaltoascii as transform_decimal
+ self.assertEqual(transform_decimal('123'),
+ '123')
+ self.assertEqual(transform_decimal('\u0663.\u0661\u0664'),
+ '3.14')
+ self.assertEqual(transform_decimal("\N{EM SPACE}3.14\N{EN SPACE}"),
+ "\N{EM SPACE}3.14\N{EN SPACE}")
+ self.assertEqual(transform_decimal('123\u20ac'),
+ '123\u20ac')
+
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_unicode_file.py b/Lib/test/test_unicode_file.py
index f04bad39642..6c2011ace8e 100644
--- a/Lib/test/test_unicode_file.py
+++ b/Lib/test/test_unicode_file.py
@@ -5,31 +5,16 @@ import os, glob, time, shutil
import unicodedata
import unittest
-from test.test_support import run_unittest, TESTFN_UNICODE
-from test.test_support import TESTFN_ENCODING, TESTFN_UNENCODABLE
-try:
- TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)
-except (UnicodeError, TypeError):
- # Either the file system encoding is None, or the file name
- # cannot be encoded in the file system encoding.
- raise unittest.SkipTest("No Unicode filesystem semantics on this platform.")
-
-if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
- # The file system encoding does not support Latin-1
- # (which test_support assumes), so try the file system
- # encoding instead.
- import sys
+from test.support import (run_unittest, rmtree,
+ TESTFN_ENCODING, TESTFN_UNICODE, TESTFN_UNENCODABLE)
+
+if not os.path.supports_unicode_filenames:
try:
- TESTFN_UNICODE = unicode("@test-\xe0\xf2", sys.getfilesystemencoding())
- TESTFN_ENCODED = TESTFN_UNICODE.encode(TESTFN_ENCODING)
- if '?' in TESTFN_ENCODED:
- # MBCS will not report the error properly
- raise UnicodeError, "mbcs encoding problem"
+ TESTFN_UNICODE.encode(TESTFN_ENCODING)
except (UnicodeError, TypeError):
- raise unittest.SkipTest("Cannot find a suiteable filename.")
-
-if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
- raise unittest.SkipTest("Cannot find a suitable filename.")
+ # Either the file system encoding is None, or the file name
+ # cannot be encoded in the file system encoding.
+ raise unittest.SkipTest("No Unicode filesystem semantics on this platform.")
def remove_if_exists(filename):
if os.path.exists(filename):
@@ -48,7 +33,7 @@ class TestUnicodeFiles(unittest.TestCase):
self.assertTrue(os.path.exists(os.path.abspath(filename)))
self.assertTrue(os.path.isfile(os.path.abspath(filename)))
self.assertTrue(os.access(os.path.abspath(filename), os.R_OK))
- os.chmod(filename, 0777)
+ os.chmod(filename, 0o777)
os.utime(filename, None)
os.utime(filename, (time.time(), time.time()))
# Copy/rename etc tests using the same filename
@@ -58,14 +43,7 @@ class TestUnicodeFiles(unittest.TestCase):
os.path.abspath(filename)==os.path.abspath(glob.glob(filename)[0]))
# basename should appear in listdir.
path, base = os.path.split(os.path.abspath(filename))
- if isinstance(base, str):
- base = base.decode(TESTFN_ENCODING)
file_list = os.listdir(path)
- # listdir() with a unicode arg may or may not return Unicode
- # objects, depending on the platform.
- if file_list and isinstance(file_list[0], str):
- file_list = [f.decode(TESTFN_ENCODING) for f in file_list]
-
# Normalize the unicode strings, as round-tripping the name via the OS
# may return a different (but equivalent) value.
base = unicodedata.normalize("NFD", base)
@@ -73,22 +51,6 @@ class TestUnicodeFiles(unittest.TestCase):
self.assertIn(base, file_list)
- # Do as many "equivalancy' tests as we can - ie, check that although we
- # have different types for the filename, they refer to the same file.
- def _do_equivalent(self, filename1, filename2):
- # Note we only check "filename1 against filename2" - we don't bother
- # checking "filename2 against 1", as we assume we are called again with
- # the args reversed.
- self.assertTrue(type(filename1)!=type(filename2),
- "No point checking equivalent filenames of the same type")
- # stat and lstat should return the same results.
- self.assertEqual(os.stat(filename1),
- os.stat(filename2))
- self.assertEqual(os.lstat(filename1),
- os.lstat(filename2))
- # Copy/rename etc tests using equivalent filename
- self._do_copyish(filename1, filename2)
-
# Tests that copy, move, etc one file to another.
def _do_copyish(self, filename1, filename2):
# Should be able to rename the file using either name.
@@ -113,20 +75,16 @@ class TestUnicodeFiles(unittest.TestCase):
shutil.copy2(filename1, filename2 + ".new")
os.unlink(filename1 + ".new")
- def _do_directory(self, make_name, chdir_name, encoded):
- cwd = os.getcwd()
+ def _do_directory(self, make_name, chdir_name):
+ cwd = os.getcwdb()
if os.path.isdir(make_name):
- os.rmdir(make_name)
+ rmtree(make_name)
os.mkdir(make_name)
try:
os.chdir(chdir_name)
try:
- if not encoded:
- cwd_result = os.getcwdu()
- name_result = make_name
- else:
- cwd_result = os.getcwd().decode(TESTFN_ENCODING)
- name_result = make_name.decode(TESTFN_ENCODING)
+ cwd_result = os.getcwd()
+ name_result = make_name
cwd_result = unicodedata.normalize("NFD", cwd_result)
name_result = unicodedata.normalize("NFD", name_result)
@@ -141,7 +99,7 @@ class TestUnicodeFiles(unittest.TestCase):
# top-level 'test' functions would be if they could take params
def _test_single(self, filename):
remove_if_exists(filename)
- f = file(filename, "w")
+ f = open(filename, "w")
f.close()
try:
self._do_single(filename)
@@ -156,42 +114,23 @@ class TestUnicodeFiles(unittest.TestCase):
finally:
os.unlink(filename)
- def _test_equivalent(self, filename1, filename2):
- remove_if_exists(filename1)
- self.assertTrue(not os.path.exists(filename2))
- f = file(filename1, "w")
- f.close()
- try:
- self._do_equivalent(filename1, filename2)
- finally:
- os.unlink(filename1)
-
# The 'test' functions are unittest entry points, and simply call our
# _test functions with each of the filename combinations we wish to test
def test_single_files(self):
- self._test_single(TESTFN_ENCODED)
self._test_single(TESTFN_UNICODE)
if TESTFN_UNENCODABLE is not None:
self._test_single(TESTFN_UNENCODABLE)
- def test_equivalent_files(self):
- self._test_equivalent(TESTFN_ENCODED, TESTFN_UNICODE)
- self._test_equivalent(TESTFN_UNICODE, TESTFN_ENCODED)
-
def test_directories(self):
# For all 'equivalent' combinations:
# Make dir with encoded, chdir with unicode, checkdir with encoded
# (or unicode/encoded/unicode, etc
ext = ".dir"
- self._do_directory(TESTFN_ENCODED+ext, TESTFN_ENCODED+ext, True)
- self._do_directory(TESTFN_ENCODED+ext, TESTFN_UNICODE+ext, True)
- self._do_directory(TESTFN_UNICODE+ext, TESTFN_ENCODED+ext, False)
- self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext, False)
+ self._do_directory(TESTFN_UNICODE+ext, TESTFN_UNICODE+ext)
# Our directory name that can't use a non-unicode name.
if TESTFN_UNENCODABLE is not None:
self._do_directory(TESTFN_UNENCODABLE+ext,
- TESTFN_UNENCODABLE+ext,
- False)
+ TESTFN_UNENCODABLE+ext)
def test_main():
run_unittest(__name__)
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
index c30ecf4c5b5..97442564e7a 100644
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -10,9 +10,10 @@ import sys
import unittest
import hashlib
import subprocess
-import test.test_support
+import test.support
encoding = 'utf-8'
+errors = 'surrogatepass'
### Run tests
@@ -20,34 +21,34 @@ encoding = 'utf-8'
class UnicodeMethodsTest(unittest.TestCase):
# update this, if the database changes
- expectedchecksum = '4504dffd035baea02c5b9de82bebc3d65e0e0baf'
+ expectedchecksum = '21b90f1aed00081b81ca7942b22196af090015a0'
def test_method_checksum(self):
h = hashlib.sha1()
for i in range(0x10000):
- char = unichr(i)
+ char = chr(i)
data = [
# Predicates (single char)
- u"01"[char.isalnum()],
- u"01"[char.isalpha()],
- u"01"[char.isdecimal()],
- u"01"[char.isdigit()],
- u"01"[char.islower()],
- u"01"[char.isnumeric()],
- u"01"[char.isspace()],
- u"01"[char.istitle()],
- u"01"[char.isupper()],
+ "01"[char.isalnum()],
+ "01"[char.isalpha()],
+ "01"[char.isdecimal()],
+ "01"[char.isdigit()],
+ "01"[char.islower()],
+ "01"[char.isnumeric()],
+ "01"[char.isspace()],
+ "01"[char.istitle()],
+ "01"[char.isupper()],
# Predicates (multiple chars)
- u"01"[(char + u'abc').isalnum()],
- u"01"[(char + u'abc').isalpha()],
- u"01"[(char + u'123').isdecimal()],
- u"01"[(char + u'123').isdigit()],
- u"01"[(char + u'abc').islower()],
- u"01"[(char + u'123').isnumeric()],
- u"01"[(char + u' \t').isspace()],
- u"01"[(char + u'abc').istitle()],
- u"01"[(char + u'ABC').isupper()],
+ "01"[(char + 'abc').isalnum()],
+ "01"[(char + 'abc').isalpha()],
+ "01"[(char + '123').isdecimal()],
+ "01"[(char + '123').isdigit()],
+ "01"[(char + 'abc').islower()],
+ "01"[(char + '123').isnumeric()],
+ "01"[(char + ' \t').isspace()],
+ "01"[(char + 'abc').istitle()],
+ "01"[(char + 'ABC').isupper()],
# Mappings (single char)
char.lower(),
@@ -55,13 +56,13 @@ class UnicodeMethodsTest(unittest.TestCase):
char.title(),
# Mappings (multiple chars)
- (char + u'abc').lower(),
- (char + u'ABC').upper(),
- (char + u'abc').title(),
- (char + u'ABC').title(),
+ (char + 'abc').lower(),
+ (char + 'ABC').upper(),
+ (char + 'abc').title(),
+ (char + 'ABC').title(),
]
- h.update(u''.join(data).encode(encoding))
+ h.update(''.join(data).encode(encoding, errors))
result = h.hexdigest()
self.assertEqual(result, self.expectedchecksum)
@@ -79,143 +80,143 @@ class UnicodeDatabaseTest(unittest.TestCase):
class UnicodeFunctionsTest(UnicodeDatabaseTest):
# update this, if the database changes
- expectedchecksum = '6ccf1b1a36460d2694f9b0b0f0324942fe70ede6'
-
+ expectedchecksum = 'c23dfc0b5eaf3ca2aad32d733de96bb182ccda50'
def test_function_checksum(self):
data = []
h = hashlib.sha1()
for i in range(0x10000):
- char = unichr(i)
+ char = chr(i)
data = [
# Properties
- str(self.db.digit(char, -1)),
- str(self.db.numeric(char, -1)),
- str(self.db.decimal(char, -1)),
+ format(self.db.digit(char, -1), '.12g'),
+ format(self.db.numeric(char, -1), '.12g'),
+ format(self.db.decimal(char, -1), '.12g'),
self.db.category(char),
self.db.bidirectional(char),
self.db.decomposition(char),
str(self.db.mirrored(char)),
str(self.db.combining(char)),
]
- h.update(''.join(data))
+ h.update(''.join(data).encode("ascii"))
result = h.hexdigest()
self.assertEqual(result, self.expectedchecksum)
def test_digit(self):
- self.assertEqual(self.db.digit(u'A', None), None)
- self.assertEqual(self.db.digit(u'9'), 9)
- self.assertEqual(self.db.digit(u'\u215b', None), None)
- self.assertEqual(self.db.digit(u'\u2468'), 9)
- self.assertEqual(self.db.digit(u'\U00020000', None), None)
+ self.assertEqual(self.db.digit('A', None), None)
+ self.assertEqual(self.db.digit('9'), 9)
+ self.assertEqual(self.db.digit('\u215b', None), None)
+ self.assertEqual(self.db.digit('\u2468'), 9)
+ self.assertEqual(self.db.digit('\U00020000', None), None)
self.assertRaises(TypeError, self.db.digit)
- self.assertRaises(TypeError, self.db.digit, u'xx')
- self.assertRaises(ValueError, self.db.digit, u'x')
+ self.assertRaises(TypeError, self.db.digit, 'xx')
+ self.assertRaises(ValueError, self.db.digit, 'x')
def test_numeric(self):
- self.assertEqual(self.db.numeric(u'A',None), None)
- self.assertEqual(self.db.numeric(u'9'), 9)
- self.assertEqual(self.db.numeric(u'\u215b'), 0.125)
- self.assertEqual(self.db.numeric(u'\u2468'), 9.0)
- self.assertEqual(self.db.numeric(u'\ua627'), 7.0)
- self.assertEqual(self.db.numeric(u'\U00020000', None), None)
+ self.assertEqual(self.db.numeric('A',None), None)
+ self.assertEqual(self.db.numeric('9'), 9)
+ self.assertEqual(self.db.numeric('\u215b'), 0.125)
+ self.assertEqual(self.db.numeric('\u2468'), 9.0)
+ self.assertEqual(self.db.numeric('\ua627'), 7.0)
+ self.assertEqual(self.db.numeric('\U00020000', None), None)
self.assertRaises(TypeError, self.db.numeric)
- self.assertRaises(TypeError, self.db.numeric, u'xx')
- self.assertRaises(ValueError, self.db.numeric, u'x')
+ self.assertRaises(TypeError, self.db.numeric, 'xx')
+ self.assertRaises(ValueError, self.db.numeric, 'x')
def test_decimal(self):
- self.assertEqual(self.db.decimal(u'A',None), None)
- self.assertEqual(self.db.decimal(u'9'), 9)
- self.assertEqual(self.db.decimal(u'\u215b', None), None)
- self.assertEqual(self.db.decimal(u'\u2468', None), None)
- self.assertEqual(self.db.decimal(u'\U00020000', None), None)
+ self.assertEqual(self.db.decimal('A',None), None)
+ self.assertEqual(self.db.decimal('9'), 9)
+ self.assertEqual(self.db.decimal('\u215b', None), None)
+ self.assertEqual(self.db.decimal('\u2468', None), None)
+ self.assertEqual(self.db.decimal('\U00020000', None), None)
self.assertRaises(TypeError, self.db.decimal)
- self.assertRaises(TypeError, self.db.decimal, u'xx')
- self.assertRaises(ValueError, self.db.decimal, u'x')
+ self.assertRaises(TypeError, self.db.decimal, 'xx')
+ self.assertRaises(ValueError, self.db.decimal, 'x')
def test_category(self):
- self.assertEqual(self.db.category(u'\uFFFE'), 'Cn')
- self.assertEqual(self.db.category(u'a'), 'Ll')
- self.assertEqual(self.db.category(u'A'), 'Lu')
- self.assertEqual(self.db.category(u'\U00020000'), 'Lo')
+ self.assertEqual(self.db.category('\uFFFE'), 'Cn')
+ self.assertEqual(self.db.category('a'), 'Ll')
+ self.assertEqual(self.db.category('A'), 'Lu')
+ self.assertEqual(self.db.category('\U00020000'), 'Lo')
self.assertRaises(TypeError, self.db.category)
- self.assertRaises(TypeError, self.db.category, u'xx')
+ self.assertRaises(TypeError, self.db.category, 'xx')
def test_bidirectional(self):
- self.assertEqual(self.db.bidirectional(u'\uFFFE'), '')
- self.assertEqual(self.db.bidirectional(u' '), 'WS')
- self.assertEqual(self.db.bidirectional(u'A'), 'L')
- self.assertEqual(self.db.bidirectional(u'\U00020000'), 'L')
+ self.assertEqual(self.db.bidirectional('\uFFFE'), '')
+ self.assertEqual(self.db.bidirectional(' '), 'WS')
+ self.assertEqual(self.db.bidirectional('A'), 'L')
+ self.assertEqual(self.db.bidirectional('\U00020000'), 'L')
self.assertRaises(TypeError, self.db.bidirectional)
- self.assertRaises(TypeError, self.db.bidirectional, u'xx')
+ self.assertRaises(TypeError, self.db.bidirectional, 'xx')
def test_decomposition(self):
- self.assertEqual(self.db.decomposition(u'\uFFFE'),'')
- self.assertEqual(self.db.decomposition(u'\u00bc'), '<fraction> 0031 2044 0034')
+ self.assertEqual(self.db.decomposition('\uFFFE'),'')
+ self.assertEqual(self.db.decomposition('\u00bc'), '<fraction> 0031 2044 0034')
self.assertRaises(TypeError, self.db.decomposition)
- self.assertRaises(TypeError, self.db.decomposition, u'xx')
+ self.assertRaises(TypeError, self.db.decomposition, 'xx')
def test_mirrored(self):
- self.assertEqual(self.db.mirrored(u'\uFFFE'), 0)
- self.assertEqual(self.db.mirrored(u'a'), 0)
- self.assertEqual(self.db.mirrored(u'\u2201'), 1)
- self.assertEqual(self.db.mirrored(u'\U00020000'), 0)
+ self.assertEqual(self.db.mirrored('\uFFFE'), 0)
+ self.assertEqual(self.db.mirrored('a'), 0)
+ self.assertEqual(self.db.mirrored('\u2201'), 1)
+ self.assertEqual(self.db.mirrored('\U00020000'), 0)
self.assertRaises(TypeError, self.db.mirrored)
- self.assertRaises(TypeError, self.db.mirrored, u'xx')
+ self.assertRaises(TypeError, self.db.mirrored, 'xx')
def test_combining(self):
- self.assertEqual(self.db.combining(u'\uFFFE'), 0)
- self.assertEqual(self.db.combining(u'a'), 0)
- self.assertEqual(self.db.combining(u'\u20e1'), 230)
- self.assertEqual(self.db.combining(u'\U00020000'), 0)
+ self.assertEqual(self.db.combining('\uFFFE'), 0)
+ self.assertEqual(self.db.combining('a'), 0)
+ self.assertEqual(self.db.combining('\u20e1'), 230)
+ self.assertEqual(self.db.combining('\U00020000'), 0)
self.assertRaises(TypeError, self.db.combining)
- self.assertRaises(TypeError, self.db.combining, u'xx')
+ self.assertRaises(TypeError, self.db.combining, 'xx')
def test_normalize(self):
self.assertRaises(TypeError, self.db.normalize)
- self.assertRaises(ValueError, self.db.normalize, 'unknown', u'xx')
- self.assertEqual(self.db.normalize('NFKC', u''), u'')
+ self.assertRaises(ValueError, self.db.normalize, 'unknown', 'xx')
+ self.assertEqual(self.db.normalize('NFKC', ''), '')
# The rest can be found in test_normalization.py
# which requires an external file.
def test_pr29(self):
# http://www.unicode.org/review/pr-29.html
# See issues #1054943 and #10254.
- composed = (u"\u0b47\u0300\u0b3e", u"\u1100\u0300\u1161",
- u'Li\u030dt-s\u1e73\u0301',
- u'\u092e\u093e\u0930\u094d\u0915 \u091c\u093c'
- + u'\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917',
- u'\u0915\u093f\u0930\u094d\u0917\u093f\u091c\u093c'
- + 'u\u0938\u094d\u0924\u093e\u0928')
+ composed = ("\u0b47\u0300\u0b3e", "\u1100\u0300\u1161",
+ 'Li\u030dt-s\u1e73\u0301',
+ '\u092e\u093e\u0930\u094d\u0915 \u091c\u093c'
+ + '\u0941\u0915\u0947\u0930\u092c\u0930\u094d\u0917',
+ '\u0915\u093f\u0930\u094d\u0917\u093f\u091c\u093c'
+ + '\u0938\u094d\u0924\u093e\u0928')
for text in composed:
self.assertEqual(self.db.normalize('NFC', text), text)
def test_issue10254(self):
# Crash reported in #10254
- a = u'C\u0338' * 20 + u'C\u0327'
- b = u'C\u0338' * 20 + u'\xC7'
+ a = 'C\u0338' * 20 + 'C\u0327'
+ b = 'C\u0338' * 20 + '\xC7'
self.assertEqual(self.db.normalize('NFC', a), b)
def test_east_asian_width(self):
eaw = self.db.east_asian_width
- self.assertRaises(TypeError, eaw, 'a')
- self.assertRaises(TypeError, eaw, u'')
- self.assertRaises(TypeError, eaw, u'ra')
- self.assertEqual(eaw(u'\x1e'), 'N')
- self.assertEqual(eaw(u'\x20'), 'Na')
- self.assertEqual(eaw(u'\uC894'), 'W')
- self.assertEqual(eaw(u'\uFF66'), 'H')
- self.assertEqual(eaw(u'\uFF1F'), 'F')
- self.assertEqual(eaw(u'\u2010'), 'A')
- self.assertEqual(eaw(u'\U00020000'), 'W')
+ self.assertRaises(TypeError, eaw, b'a')
+ self.assertRaises(TypeError, eaw, bytearray())
+ self.assertRaises(TypeError, eaw, '')
+ self.assertRaises(TypeError, eaw, 'ra')
+ self.assertEqual(eaw('\x1e'), 'N')
+ self.assertEqual(eaw('\x20'), 'Na')
+ self.assertEqual(eaw('\uC894'), 'W')
+ self.assertEqual(eaw('\uFF66'), 'H')
+ self.assertEqual(eaw('\uFF1F'), 'F')
+ self.assertEqual(eaw('\u2010'), 'A')
+ self.assertEqual(eaw('\U00020000'), 'W')
class UnicodeMiscTest(UnicodeDatabaseTest):
@@ -227,24 +228,25 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
# This program should raise a SyntaxError in the eval.
code = "import sys;" \
"sys.modules['unicodedata'] = None;" \
- """eval("u'\N{SOFT HYPHEN}'")"""
+ """eval("'\\\\N{SOFT HYPHEN}'")"""
args = [sys.executable, "-c", code]
# We use a subprocess because the unicodedata module may already have
# been loaded in this process.
popen = subprocess.Popen(args, stderr=subprocess.PIPE)
popen.wait()
self.assertEqual(popen.returncode, 1)
- error = "SyntaxError: (unicode error) \N escapes not supported " \
+ error = "SyntaxError: (unicode error) \\N escapes not supported " \
"(can't load unicodedata module)"
- self.assertIn(error, popen.stderr.read())
+ self.assertIn(error, popen.stderr.read().decode("ascii"))
+ popen.stderr.close()
def test_decimal_numeric_consistent(self):
# Test that decimal and numeric are consistent,
# i.e. if a character has a decimal value,
# its numeric value should be the same.
count = 0
- for i in xrange(0x10000):
- c = unichr(i)
+ for i in range(0x10000):
+ c = chr(i)
dec = self.db.decimal(c, -1)
if dec != -1:
self.assertEqual(dec, self.db.numeric(c))
@@ -256,8 +258,8 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
# i.e. if a character has a digit value,
# its numeric value should be the same.
count = 0
- for i in xrange(0x10000):
- c = unichr(i)
+ for i in range(0x10000):
+ c = chr(i)
dec = self.db.digit(c, -1)
if dec != -1:
self.assertEqual(dec, self.db.numeric(c))
@@ -265,39 +267,39 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
self.assertTrue(count >= 10) # should have tested at least the ASCII digits
def test_bug_1704793(self):
- self.assertEqual(self.db.lookup("GOTHIC LETTER FAIHU"), u'\U00010346')
+ self.assertEqual(self.db.lookup("GOTHIC LETTER FAIHU"), '\U00010346')
def test_ucd_510(self):
import unicodedata
# In UCD 5.1.0, a mirrored property changed wrt. UCD 3.2.0
- self.assertTrue(unicodedata.mirrored(u"\u0f3a"))
- self.assertTrue(not unicodedata.ucd_3_2_0.mirrored(u"\u0f3a"))
+ self.assertTrue(unicodedata.mirrored("\u0f3a"))
+ self.assertTrue(not unicodedata.ucd_3_2_0.mirrored("\u0f3a"))
# Also, we now have two ways of representing
# the upper-case mapping: as delta, or as absolute value
- self.assertTrue(u"a".upper()==u'A')
- self.assertTrue(u"\u1d79".upper()==u'\ua77d')
- self.assertTrue(u".".upper()==u".")
+ self.assertTrue("a".upper()=='A')
+ self.assertTrue("\u1d79".upper()=='\ua77d')
+ self.assertTrue(".".upper()=='.')
def test_bug_5828(self):
- self.assertEqual(u"\u1d79".lower(), u"\u1d79")
+ self.assertEqual("\u1d79".lower(), "\u1d79")
# Only U+0000 should have U+0000 as its upper/lower/titlecase variant
self.assertEqual(
[
c for c in range(sys.maxunicode+1)
- if u"\x00" in unichr(c).lower()+unichr(c).upper()+unichr(c).title()
+ if "\x00" in chr(c).lower()+chr(c).upper()+chr(c).title()
],
[0]
)
def test_bug_4971(self):
# LETTER DZ WITH CARON: DZ, Dz, dz
- self.assertEqual(u"\u01c4".title(), u"\u01c5")
- self.assertEqual(u"\u01c5".title(), u"\u01c5")
- self.assertEqual(u"\u01c6".title(), u"\u01c5")
+ self.assertEqual("\u01c4".title(), "\u01c5")
+ self.assertEqual("\u01c5".title(), "\u01c5")
+ self.assertEqual("\u01c6".title(), "\u01c5")
def test_linebreak_7643(self):
for i in range(0x10000):
- lines = (unichr(i) + u'A').splitlines()
+ lines = (chr(i) + 'A').splitlines()
if i in (0x0a, 0x0b, 0x0c, 0x0d, 0x85,
0x1c, 0x1d, 0x1e, 0x2028, 0x2029):
self.assertEqual(len(lines), 2,
@@ -306,8 +308,16 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
self.assertEqual(len(lines), 1,
r"\u%.4x should not be a linebreak" % i)
+ def test_UCS4(self):
+ # unicodedata should work with code points outside the BMP
+ # even on a narrow Unicode build
+ self.assertEqual(self.db.category("\U0001012A"), "No")
+ self.assertEqual(self.db.numeric("\U0001012A"), 9000)
+ self.assertEqual(self.db.decimal("\U0001D7FD"), 7)
+ self.assertEqual(self.db.digit("\U0001D7FD"), 7)
+
def test_main():
- test.test_support.run_unittest(
+ test.support.run_unittest(
UnicodeMiscTest,
UnicodeMethodsTest,
UnicodeFunctionsTest
diff --git a/Lib/test/test_unittest.py b/Lib/test/test_unittest.py
index 86a998b6f44..bfc3ded6f12 100644
--- a/Lib/test/test_unittest.py
+++ b/Lib/test/test_unittest.py
@@ -1,12 +1,16 @@
import unittest.test
-from test import test_support
+from test import support
def test_main():
- test_support.run_unittest(unittest.test.suite())
- test_support.reap_children()
+ # used by regrtest
+ support.run_unittest(unittest.test.suite())
+ support.reap_children()
+def load_tests(*_):
+ # used by unittest
+ return unittest.test.suite()
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_univnewlines.py b/Lib/test/test_univnewlines.py
index a0a909058c7..183ae759d91 100644
--- a/Lib/test/test_univnewlines.py
+++ b/Lib/test/test_univnewlines.py
@@ -1,17 +1,10 @@
# Tests universal newline support for both reading and parsing files.
-
-# NOTE: this file tests the new `io` library backported from Python 3.x.
-# Similar tests for the builtin file object can be found in test_univnewlines2k.py.
-
-from __future__ import print_function
-from __future__ import unicode_literals
-
import io
import _pyio as pyio
import unittest
import os
import sys
-from test import test_support as support
+from test import support
if not hasattr(sys.stdin, 'newlines'):
raise unittest.SkipTest(
@@ -60,13 +53,13 @@ class TestGenericUnivNewlines(unittest.TestCase):
with self.open(support.TESTFN, self.READMODE) as fp:
data = fp.read()
self.assertEqual(data, DATA_LF)
- self.assertEqual(set(fp.newlines), set(self.NEWLINE))
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readlines(self):
with self.open(support.TESTFN, self.READMODE) as fp:
data = fp.readlines()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(set(fp.newlines), set(self.NEWLINE))
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_readline(self):
with self.open(support.TESTFN, self.READMODE) as fp:
@@ -76,7 +69,7 @@ class TestGenericUnivNewlines(unittest.TestCase):
data.append(d)
d = fp.readline()
self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(set(fp.newlines), set(self.NEWLINE))
+ self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
def test_seek(self):
with self.open(support.TESTFN, self.READMODE) as fp:
@@ -123,10 +116,10 @@ def test_main():
for test in base_tests:
class CTest(test):
open = io.open
- CTest.__name__ = str("C" + test.__name__)
+ CTest.__name__ = "C" + test.__name__
class PyTest(test):
open = staticmethod(pyio.open)
- PyTest.__name__ = str("Py" + test.__name__)
+ PyTest.__name__ = "Py" + test.__name__
tests.append(CTest)
tests.append(PyTest)
support.run_unittest(*tests)
diff --git a/Lib/test/test_univnewlines2k.py b/Lib/test/test_univnewlines2k.py
deleted file mode 100644
index 4eca31d8ba4..00000000000
--- a/Lib/test/test_univnewlines2k.py
+++ /dev/null
@@ -1,130 +0,0 @@
-# Tests universal newline support for both reading and parsing files.
-import unittest
-import os
-import sys
-from test import test_support
-
-if not hasattr(sys.stdin, 'newlines'):
- raise unittest.SkipTest, \
- "This Python does not have universal newline support"
-
-FATX = 'x' * (2**14)
-
-DATA_TEMPLATE = [
- "line1=1",
- "line2='this is a very long line designed to go past the magic " +
- "hundred character limit that is inside fileobject.c and which " +
- "is meant to speed up the common case, but we also want to test " +
- "the uncommon case, naturally.'",
- "def line3():pass",
- "line4 = '%s'" % FATX,
- ]
-
-DATA_LF = "\n".join(DATA_TEMPLATE) + "\n"
-DATA_CR = "\r".join(DATA_TEMPLATE) + "\r"
-DATA_CRLF = "\r\n".join(DATA_TEMPLATE) + "\r\n"
-
-# Note that DATA_MIXED also tests the ability to recognize a lone \r
-# before end-of-file.
-DATA_MIXED = "\n".join(DATA_TEMPLATE) + "\r"
-DATA_SPLIT = [x + "\n" for x in DATA_TEMPLATE]
-del x
-
-class TestGenericUnivNewlines(unittest.TestCase):
- # use a class variable DATA to define the data to write to the file
- # and a class variable NEWLINE to set the expected newlines value
- READMODE = 'U'
- WRITEMODE = 'wb'
-
- def setUp(self):
- with open(test_support.TESTFN, self.WRITEMODE) as fp:
- fp.write(self.DATA)
-
- def tearDown(self):
- try:
- os.unlink(test_support.TESTFN)
- except:
- pass
-
- def test_read(self):
- with open(test_support.TESTFN, self.READMODE) as fp:
- data = fp.read()
- self.assertEqual(data, DATA_LF)
- self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
-
- def test_readlines(self):
- with open(test_support.TESTFN, self.READMODE) as fp:
- data = fp.readlines()
- self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
-
- def test_readline(self):
- with open(test_support.TESTFN, self.READMODE) as fp:
- data = []
- d = fp.readline()
- while d:
- data.append(d)
- d = fp.readline()
- self.assertEqual(data, DATA_SPLIT)
- self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
-
- def test_seek(self):
- with open(test_support.TESTFN, self.READMODE) as fp:
- fp.readline()
- pos = fp.tell()
- data = fp.readlines()
- self.assertEqual(data, DATA_SPLIT[1:])
- fp.seek(pos)
- data = fp.readlines()
- self.assertEqual(data, DATA_SPLIT[1:])
-
- def test_execfile(self):
- namespace = {}
- with test_support.check_py3k_warnings():
- execfile(test_support.TESTFN, namespace)
- func = namespace['line3']
- self.assertEqual(func.func_code.co_firstlineno, 3)
- self.assertEqual(namespace['line4'], FATX)
-
-
-class TestNativeNewlines(TestGenericUnivNewlines):
- NEWLINE = None
- DATA = DATA_LF
- READMODE = 'r'
- WRITEMODE = 'w'
-
-class TestCRNewlines(TestGenericUnivNewlines):
- NEWLINE = '\r'
- DATA = DATA_CR
-
-class TestLFNewlines(TestGenericUnivNewlines):
- NEWLINE = '\n'
- DATA = DATA_LF
-
-class TestCRLFNewlines(TestGenericUnivNewlines):
- NEWLINE = '\r\n'
- DATA = DATA_CRLF
-
- def test_tell(self):
- with open(test_support.TESTFN, self.READMODE) as fp:
- self.assertEqual(repr(fp.newlines), repr(None))
- data = fp.readline()
- pos = fp.tell()
- self.assertEqual(repr(fp.newlines), repr(self.NEWLINE))
-
-class TestMixedNewlines(TestGenericUnivNewlines):
- NEWLINE = ('\r', '\n')
- DATA = DATA_MIXED
-
-
-def test_main():
- test_support.run_unittest(
- TestNativeNewlines,
- TestCRNewlines,
- TestLFNewlines,
- TestCRLFNewlines,
- TestMixedNewlines
- )
-
-if __name__ == '__main__':
- test_main()
diff --git a/Lib/test/test_unpack.py b/Lib/test/test_unpack.py
index 7ddbc621184..b1c483d4d55 100644
--- a/Lib/test/test_unpack.py
+++ b/Lib/test/test_unpack.py
@@ -62,14 +62,14 @@ Unpacking tuple of wrong size
>>> a, b = t
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking tuple of wrong size
>>> a, b = l
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking sequence too short
@@ -83,7 +83,7 @@ Unpacking sequence too long
>>> a, b = Seq()
Traceback (most recent call last):
...
- ValueError: too many values to unpack
+ ValueError: too many values to unpack (expected 2)
Unpacking a sequence where the test for too long raises a different kind of
error
@@ -107,7 +107,7 @@ error)
>>> a, b, c, d, e = BadSeq()
Traceback (most recent call last):
...
- BozoError
+ test.test_unpack.BozoError
Trigger code while expecting an IndexError (unpack sequence too short, wrong
error)
@@ -115,16 +115,16 @@ error)
>>> a, b, c = BadSeq()
Traceback (most recent call last):
...
- BozoError
+ test.test_unpack.BozoError
"""
__test__ = {'doctests' : doctests}
def test_main(verbose=False):
- from test import test_support
+ from test import support
from test import test_unpack
- test_support.run_doctest(test_unpack, verbose)
+ support.run_doctest(test_unpack, verbose)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py
new file mode 100644
index 00000000000..ae2dcbd985e
--- /dev/null
+++ b/Lib/test/test_unpack_ex.py
@@ -0,0 +1,174 @@
+# Tests for extended unpacking, starred expressions.
+
+doctests = """
+
+Unpack tuple
+
+ >>> t = (1, 2, 3)
+ >>> a, *b, c = t
+ >>> a == 1 and b == [2] and c == 3
+ True
+
+Unpack list
+
+ >>> l = [4, 5, 6]
+ >>> a, *b = l
+ >>> a == 4 and b == [5, 6]
+ True
+
+Unpack implied tuple
+
+ >>> *a, = 7, 8, 9
+ >>> a == [7, 8, 9]
+ True
+
+Unpack string... fun!
+
+ >>> a, *b = 'one'
+ >>> a == 'o' and b == ['n', 'e']
+ True
+
+Unpack long sequence
+
+ >>> a, b, c, *d, e, f, g = range(10)
+ >>> (a, b, c, d, e, f, g) == (0, 1, 2, [3, 4, 5, 6], 7, 8, 9)
+ True
+
+Unpack short sequence
+
+ >>> a, *b, c = (1, 2)
+ >>> a == 1 and c == 2 and b == []
+ True
+
+Unpack generic sequence
+
+ >>> class Seq:
+ ... def __getitem__(self, i):
+ ... if i >= 0 and i < 3: return i
+ ... raise IndexError
+ ...
+ >>> a, *b = Seq()
+ >>> a == 0 and b == [1, 2]
+ True
+
+Unpack in for statement
+
+ >>> for a, *b, c in [(1,2,3), (4,5,6,7)]:
+ ... print(a, b, c)
+ ...
+ 1 [2] 3
+ 4 [5, 6] 7
+
+Unpack in list
+
+ >>> [a, *b, c] = range(5)
+ >>> a == 0 and b == [1, 2, 3] and c == 4
+ True
+
+Multiple targets
+
+ >>> a, *b, c = *d, e = range(5)
+ >>> a == 0 and b == [1, 2, 3] and c == 4 and d == [0, 1, 2, 3] and e == 4
+ True
+
+Now for some failures
+
+Unpacking non-sequence
+
+ >>> a, *b = 7
+ Traceback (most recent call last):
+ ...
+ TypeError: 'int' object is not iterable
+
+Unpacking sequence too short
+
+ >>> a, *b, c, d, e = Seq()
+ Traceback (most recent call last):
+ ...
+ ValueError: need more than 3 values to unpack
+
+Unpacking a sequence where the test for too long raises a different kind of
+error
+
+ >>> class BozoError(Exception):
+ ... pass
+ ...
+ >>> class BadSeq:
+ ... def __getitem__(self, i):
+ ... if i >= 0 and i < 3:
+ ... return i
+ ... elif i == 3:
+ ... raise BozoError
+ ... else:
+ ... raise IndexError
+ ...
+
+Trigger code while not expecting an IndexError (unpack sequence too long, wrong
+error)
+
+ >>> a, *b, c, d, e = BadSeq()
+ Traceback (most recent call last):
+ ...
+ test.test_unpack_ex.BozoError
+
+Now some general starred expressions (all fail).
+
+ >>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: two starred expressions in assignment
+
+ >>> [*b, *c] = range(10) # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: two starred expressions in assignment
+
+ >>> *a = range(10) # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: starred assignment target must be in a list or tuple
+
+ >>> *a # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: can use starred expression only as assignment target
+
+ >>> *1 # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: can use starred expression only as assignment target
+
+ >>> x = *a # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: can use starred expression only as assignment target
+
+Some size constraints (all fail.)
+
+ >>> s = ", ".join("a%d" % i for i in range(1<<8)) + ", *rest = range(1<<8 + 1)"
+ >>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: too many expressions in star-unpacking assignment
+
+ >>> s = ", ".join("a%d" % i for i in range(1<<8 + 1)) + ", *rest = range(1<<8 + 2)"
+ >>> compile(s, 'test', 'exec') # doctest:+ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ SyntaxError: too many expressions in star-unpacking assignment
+
+(there is an additional limit, on the number of expressions after the
+'*rest', but it's 1<<24 and testing it takes too much memory.)
+
+"""
+
+__test__ = {'doctests' : doctests}
+
+def test_main(verbose=False):
+ import sys
+ from test import support
+ from test import test_unpack_ex
+ support.run_doctest(test_unpack_ex, verbose)
+
+if __name__ == "__main__":
+ test_main(verbose=True)
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 3a273f873b1..3fc499ec076 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -1,17 +1,19 @@
"""Regresssion tests for urllib"""
-import urllib
-import httplib
+import urllib.parse
+import urllib.request
+import urllib.error
+import http.client
+import email.message
+import io
import unittest
+from test import support
import os
import sys
-import mimetools
import tempfile
-import StringIO
-from test import test_support
from base64 import b64encode
-
+import collections
def hexescape(char):
"""Escape char as RFC 2396 specifies"""
@@ -20,41 +22,64 @@ def hexescape(char):
hex_repr = "0%s" % hex_repr
return "%" + hex_repr
+# Shortcut for testing FancyURLopener
+_urlopener = None
+def urlopen(url, data=None, proxies=None):
+ """urlopen(url [, data]) -> open file-like object"""
+ global _urlopener
+ if proxies is not None:
+ opener = urllib.request.FancyURLopener(proxies=proxies)
+ elif not _urlopener:
+ opener = urllib.request.FancyURLopener()
+ _urlopener = opener
+ else:
+ opener = _urlopener
+ if data is None:
+ return opener.open(url)
+ else:
+ return opener.open(url, data)
+
class FakeHTTPMixin(object):
def fakehttp(self, fakedata):
- class FakeSocket(StringIO.StringIO):
+ class FakeSocket(io.BytesIO):
+ io_refs = 1
def sendall(self, data):
FakeHTTPConnection.buf = data
def makefile(self, *args, **kwds):
+ self.io_refs += 1
return self
def read(self, amt=None):
if self.closed:
- return ""
- return StringIO.StringIO.read(self, amt)
+ return b""
+ return io.BytesIO.read(self, amt)
def readline(self, length=None):
if self.closed:
- return ""
- return StringIO.StringIO.readline(self, length)
+ return b""
+ return io.BytesIO.readline(self, length)
- class FakeHTTPConnection(httplib.HTTPConnection):
+ def close(self):
+ self.io_refs -= 1
+ if self.io_refs == 0:
+ io.BytesIO.close(self)
+
+ class FakeHTTPConnection(http.client.HTTPConnection):
# buffer to store data for verification in urlopen tests.
- buf = ""
+ buf = None
def connect(self):
self.sock = FakeSocket(fakedata)
- assert httplib.HTTP._connection_class == httplib.HTTPConnection
-
- httplib.HTTP._connection_class = FakeHTTPConnection
+ self._connection_class = http.client.HTTPConnection
+ http.client.HTTPConnection = FakeHTTPConnection
def unfakehttp(self):
- httplib.HTTP._connection_class = httplib.HTTPConnection
+ http.client.HTTPConnection = self._connection_class
class urlopen_FileTests(unittest.TestCase):
@@ -66,20 +91,21 @@ class urlopen_FileTests(unittest.TestCase):
"""
def setUp(self):
- """Setup of a temp file to use for testing"""
- self.text = "test_urllib: %s\n" % self.__class__.__name__
- FILE = file(test_support.TESTFN, 'wb')
+ # Create a temp file to use for testing
+ self.text = bytes("test_urllib: %s\n" % self.__class__.__name__,
+ "ascii")
+ f = open(support.TESTFN, 'wb')
try:
- FILE.write(self.text)
+ f.write(self.text)
finally:
- FILE.close()
- self.pathname = test_support.TESTFN
- self.returned_obj = urllib.urlopen("file:%s" % self.pathname)
+ f.close()
+ self.pathname = support.TESTFN
+ self.returned_obj = urlopen("file:%s" % self.pathname)
def tearDown(self):
"""Shut down the open object"""
self.returned_obj.close()
- os.remove(test_support.TESTFN)
+ os.remove(support.TESTFN)
def test_interface(self):
# Make sure object returned by urlopen() has the specified methods
@@ -94,7 +120,7 @@ class urlopen_FileTests(unittest.TestCase):
def test_readline(self):
self.assertEqual(self.text, self.returned_obj.readline())
- self.assertEqual('', self.returned_obj.readline(),
+ self.assertEqual(b'', self.returned_obj.readline(),
"calling readline() after exhausting the file did not"
" return an empty string")
@@ -113,37 +139,38 @@ class urlopen_FileTests(unittest.TestCase):
"did not return the expected text")
def test_close(self):
- # Test close() by calling it hear and then having it be called again
+ # Test close() by calling it here and then having it be called again
# by the tearDown() method for the test
self.returned_obj.close()
def test_info(self):
- self.assertIsInstance(self.returned_obj.info(), mimetools.Message)
+ self.assertIsInstance(self.returned_obj.info(), email.message.Message)
def test_geturl(self):
self.assertEqual(self.returned_obj.geturl(), self.pathname)
def test_getcode(self):
- self.assertEqual(self.returned_obj.getcode(), None)
+ self.assertIsNone(self.returned_obj.getcode())
def test_iter(self):
# Test iterator
# Don't need to count number of iterations since test would fail the
# instant it returned anything beyond the first line from the
- # comparison
- for line in self.returned_obj.__iter__():
+ # comparison.
+ # Use the iterator in the usual implicit way to test for ticket #4608.
+ for line in self.returned_obj:
self.assertEqual(line, self.text)
def test_relativelocalfile(self):
- self.assertRaises(ValueError,urllib.urlopen,'./' + self.pathname)
+ self.assertRaises(ValueError,urllib.request.urlopen,'./' + self.pathname)
class ProxyTests(unittest.TestCase):
def setUp(self):
# Records changes to env vars
- self.env = test_support.EnvironmentVarGuard()
+ self.env = support.EnvironmentVarGuard()
# Delete all proxy related env vars
- for k in os.environ.keys():
+ for k in list(os.environ):
if 'proxy' in k.lower():
self.env.unset(k)
@@ -154,23 +181,22 @@ class ProxyTests(unittest.TestCase):
def test_getproxies_environment_keep_no_proxies(self):
self.env.set('NO_PROXY', 'localhost')
- proxies = urllib.getproxies_environment()
+ proxies = urllib.request.getproxies_environment()
# getproxies_environment use lowered case truncated (no '_proxy') keys
self.assertEqual('localhost', proxies['no'])
# List of no_proxies with space.
self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com')
- self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
-
+ self.assertTrue(urllib.request.proxy_bypass_environment('anotherdomain.com'))
class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin):
"""Test urlopen() opening a fake http connection."""
- def test_read(self):
- self.fakehttp('Hello!')
+ def check_read(self, ver):
+ self.fakehttp(b"HTTP/" + ver + b" 200 OK\r\n\r\nHello!")
try:
- fp = urllib.urlopen("http://python.org/")
- self.assertEqual(fp.readline(), 'Hello!')
- self.assertEqual(fp.readline(), '')
+ fp = urlopen("http://python.org/")
+ self.assertEqual(fp.readline(), b"Hello!")
+ self.assertEqual(fp.readline(), b"")
self.assertEqual(fp.geturl(), 'http://python.org/')
self.assertEqual(fp.getcode(), 200)
finally:
@@ -179,105 +205,134 @@ class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin):
def test_url_fragment(self):
# Issue #11703: geturl() omits fragments in the original URL.
url = 'http://docs.python.org/library/urllib.html#OK'
- self.fakehttp('Hello!')
+ self.fakehttp(b"HTTP/1.1 200 OK\r\n\r\nHello!")
try:
- fp = urllib.urlopen(url)
+ fp = urllib.request.urlopen(url)
self.assertEqual(fp.geturl(), url)
finally:
self.unfakehttp()
+ def test_willclose(self):
+ self.fakehttp(b"HTTP/1.1 200 OK\r\n\r\nHello!")
+ try:
+ resp = urlopen("http://www.python.org")
+ self.assertTrue(resp.fp.will_close)
+ finally:
+ self.unfakehttp()
+
+ def test_read_0_9(self):
+ # "0.9" response accepted (but not "simple responses" without
+ # a status line)
+ self.check_read(b"0.9")
+
+ def test_read_1_0(self):
+ self.check_read(b"1.0")
+
+ def test_read_1_1(self):
+ self.check_read(b"1.1")
+
def test_read_bogus(self):
# urlopen() should raise IOError for many error codes.
- self.fakehttp('''HTTP/1.1 401 Authentication Required
+ self.fakehttp(b'''HTTP/1.1 401 Authentication Required
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Type: text/html; charset=iso-8859-1
''')
try:
- self.assertRaises(IOError, urllib.urlopen, "http://python.org/")
+ self.assertRaises(IOError, urlopen, "http://python.org/")
finally:
self.unfakehttp()
def test_invalid_redirect(self):
# urlopen() should raise IOError for many error codes.
- self.fakehttp("""HTTP/1.1 302 Found
+ self.fakehttp(b'''HTTP/1.1 302 Found
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
-Location: file:README
+Location: file://guidocomputer.athome.com:/python/license
Connection: close
Content-Type: text/html; charset=iso-8859-1
-""")
+''')
try:
- self.assertRaises(IOError, urllib.urlopen, "http://python.org/")
+ self.assertRaises(urllib.error.HTTPError, urlopen,
+ "http://python.org/")
finally:
self.unfakehttp()
def test_empty_socket(self):
# urlopen() raises IOError if the underlying socket does not send any
# data. (#1680230)
- self.fakehttp('')
+ self.fakehttp(b'')
try:
- self.assertRaises(IOError, urllib.urlopen, 'http://something')
+ self.assertRaises(IOError, urlopen, "http://something")
finally:
self.unfakehttp()
def test_missing_localfile(self):
- self.assertRaises(IOError, urllib.urlopen,
- 'file://localhost/a/missing/file.py')
+ # Test for #10836
+ with self.assertRaises(urllib.error.URLError) as e:
+ urlopen('file://localhost/a/file/which/doesnot/exists.py')
+ self.assertTrue(e.exception.filename)
+ self.assertTrue(e.exception.reason)
+
+ def test_file_notexists(self):
fd, tmp_file = tempfile.mkstemp()
tmp_fileurl = 'file://localhost/' + tmp_file.replace(os.path.sep, '/')
try:
self.assertTrue(os.path.exists(tmp_file))
- fp = urllib.urlopen(tmp_fileurl)
+ with urlopen(tmp_fileurl) as fobj:
+ self.assertTrue(fobj)
finally:
os.close(fd)
- fp.close()
- os.unlink(tmp_file)
-
+ os.unlink(tmp_file)
self.assertFalse(os.path.exists(tmp_file))
- self.assertRaises(IOError, urllib.urlopen, tmp_fileurl)
+ with self.assertRaises(urllib.error.URLError):
+ urlopen(tmp_fileurl)
+
+ def test_ftp_nohost(self):
+ test_ftp_url = 'ftp:///path'
+ with self.assertRaises(urllib.error.URLError) as e:
+ urlopen(test_ftp_url)
+ self.assertFalse(e.exception.filename)
+ self.assertTrue(e.exception.reason)
def test_ftp_nonexisting(self):
- self.assertRaises(IOError, urllib.urlopen,
- 'ftp://localhost/not/existing/file.py')
+ with self.assertRaises(urllib.error.URLError) as e:
+ urlopen('ftp://localhost/a/file/which/doesnot/exists.py')
+ self.assertFalse(e.exception.filename)
+ self.assertTrue(e.exception.reason)
def test_userpass_inurl(self):
- self.fakehttp('Hello!')
+ self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
try:
- fakehttp_wrapper = httplib.HTTP._connection_class
- fp = urllib.urlopen("http://user:pass@python.org/")
- authorization = ("Authorization: Basic %s\r\n" %
- b64encode('user:pass'))
- # The authorization header must be in place
- self.assertIn(authorization, fakehttp_wrapper.buf)
- self.assertEqual(fp.readline(), "Hello!")
- self.assertEqual(fp.readline(), "")
+ fp = urlopen("http://user:pass@python.org/")
+ self.assertEqual(fp.readline(), b"Hello!")
+ self.assertEqual(fp.readline(), b"")
self.assertEqual(fp.geturl(), 'http://user:pass@python.org/')
self.assertEqual(fp.getcode(), 200)
finally:
self.unfakehttp()
- def test_userpass_with_spaces_inurl(self):
- self.fakehttp('Hello!')
+ def test_userpass_inurl_w_spaces(self):
+ self.fakehttp(b"HTTP/1.0 200 OK\r\n\r\nHello!")
try:
- url = "http://a b:c d@python.org/"
- fakehttp_wrapper = httplib.HTTP._connection_class
+ userpass = "a b:c d"
+ url = "http://{}@python.org/".format(userpass)
+ fakehttp_wrapper = http.client.HTTPConnection
authorization = ("Authorization: Basic %s\r\n" %
- b64encode('a b:c d'))
- fp = urllib.urlopen(url)
+ b64encode(userpass.encode("ASCII")).decode("ASCII"))
+ fp = urlopen(url)
# The authorization header must be in place
- self.assertIn(authorization, fakehttp_wrapper.buf)
- self.assertEqual(fp.readline(), "Hello!")
- self.assertEqual(fp.readline(), "")
+ self.assertIn(authorization, fakehttp_wrapper.buf.decode("UTF-8"))
+ self.assertEqual(fp.readline(), b"Hello!")
+ self.assertEqual(fp.readline(), b"")
# the spaces are quoted in URL so no match
self.assertNotEqual(fp.geturl(), url)
self.assertEqual(fp.getcode(), 200)
finally:
self.unfakehttp()
-
class urlretrieve_FileTests(unittest.TestCase):
"""Test urllib.urlretrieve() on local files"""
@@ -292,10 +347,10 @@ class urlretrieve_FileTests(unittest.TestCase):
self.tempFiles = []
# Create a temporary file.
- self.registerFileForCleanUp(test_support.TESTFN)
- self.text = 'testing urllib.urlretrieve'
+ self.registerFileForCleanUp(support.TESTFN)
+ self.text = b'testing urllib.urlretrieve'
try:
- FILE = file(test_support.TESTFN, 'wb')
+ FILE = open(support.TESTFN, 'wb')
FILE.write(self.text)
FILE.close()
finally:
@@ -309,9 +364,14 @@ class urlretrieve_FileTests(unittest.TestCase):
except: pass
def constructLocalFileUrl(self, filePath):
- return "file://%s" % urllib.pathname2url(os.path.abspath(filePath))
+ filePath = os.path.abspath(filePath)
+ try:
+ filePath.encode("utf8")
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("filePath is not encodable to utf8")
+ return "file://%s" % urllib.request.pathname2url(filePath)
- def createNewTempFile(self, data=""):
+ def createNewTempFile(self, data=b""):
"""Creates a new temporary file containing the specified data,
registers the file for deletion during the test fixture tear down, and
returns the absolute path of the file."""
@@ -333,22 +393,22 @@ class urlretrieve_FileTests(unittest.TestCase):
def test_basic(self):
# Make sure that a local file just gets its own location returned and
# a headers value is returned.
- result = urllib.urlretrieve("file:%s" % test_support.TESTFN)
- self.assertEqual(result[0], test_support.TESTFN)
- self.assertIsInstance(result[1], mimetools.Message,
- "did not get a mimetools.Message instance as "
- "second returned value")
+ result = urllib.request.urlretrieve("file:%s" % support.TESTFN)
+ self.assertEqual(result[0], support.TESTFN)
+ self.assertIsInstance(result[1], email.message.Message,
+ "did not get a email.message.Message instance "
+ "as second returned value")
def test_copy(self):
# Test that setting the filename argument works.
- second_temp = "%s.2" % test_support.TESTFN
+ second_temp = "%s.2" % support.TESTFN
self.registerFileForCleanUp(second_temp)
- result = urllib.urlretrieve(self.constructLocalFileUrl(
- test_support.TESTFN), second_temp)
+ result = urllib.request.urlretrieve(self.constructLocalFileUrl(
+ support.TESTFN), second_temp)
self.assertEqual(second_temp, result[0])
self.assertTrue(os.path.exists(second_temp), "copy of the file was not "
"made")
- FILE = file(second_temp, 'rb')
+ FILE = open(second_temp, 'rb')
try:
text = FILE.read()
FILE.close()
@@ -365,9 +425,10 @@ class urlretrieve_FileTests(unittest.TestCase):
self.assertIsInstance(total_size, int)
self.assertEqual(count, count_holder[0])
count_holder[0] = count_holder[0] + 1
- second_temp = "%s.2" % test_support.TESTFN
+ second_temp = "%s.2" % support.TESTFN
self.registerFileForCleanUp(second_temp)
- urllib.urlretrieve(self.constructLocalFileUrl(test_support.TESTFN),
+ urllib.request.urlretrieve(
+ self.constructLocalFileUrl(support.TESTFN),
second_temp, hooktester)
def test_reporthook_0_bytes(self):
@@ -376,8 +437,8 @@ class urlretrieve_FileTests(unittest.TestCase):
def hooktester(count, block_size, total_size, _report=report):
_report.append((count, block_size, total_size))
srcFileName = self.createNewTempFile()
- urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName),
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 1)
self.assertEqual(report[0][2], 0)
@@ -389,9 +450,9 @@ class urlretrieve_FileTests(unittest.TestCase):
report = []
def hooktester(count, block_size, total_size, _report=report):
_report.append((count, block_size, total_size))
- srcFileName = self.createNewTempFile("x" * 5)
- urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ srcFileName = self.createNewTempFile(b"x" * 5)
+ urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName),
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 2)
self.assertEqual(report[0][1], 8192)
self.assertEqual(report[0][2], 5)
@@ -403,9 +464,9 @@ class urlretrieve_FileTests(unittest.TestCase):
report = []
def hooktester(count, block_size, total_size, _report=report):
_report.append((count, block_size, total_size))
- srcFileName = self.createNewTempFile("x" * 8193)
- urllib.urlretrieve(self.constructLocalFileUrl(srcFileName),
- test_support.TESTFN, hooktester)
+ srcFileName = self.createNewTempFile(b"x" * 8193)
+ urllib.request.urlretrieve(self.constructLocalFileUrl(srcFileName),
+ support.TESTFN, hooktester)
self.assertEqual(len(report), 3)
self.assertEqual(report[0][1], 8192)
self.assertEqual(report[0][2], 8193)
@@ -415,7 +476,7 @@ class urlretrieve_HttpTests(unittest.TestCase, FakeHTTPMixin):
"""Test urllib.urlretrieve() using fake http connections"""
def test_short_content_raises_ContentTooShortError(self):
- self.fakehttp('''HTTP/1.1 200 OK
+ self.fakehttp(b'''HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
@@ -428,14 +489,15 @@ FF
def _reporthook(par1, par2, par3):
pass
- try:
- self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve,
- 'http://example.com', reporthook=_reporthook)
- finally:
- self.unfakehttp()
+ with self.assertRaises(urllib.error.ContentTooShortError):
+ try:
+ urllib.request.urlretrieve('http://example.com/',
+ reporthook=_reporthook)
+ finally:
+ self.unfakehttp()
def test_short_content_raises_ContentTooShortError_without_reporthook(self):
- self.fakehttp('''HTTP/1.1 200 OK
+ self.fakehttp(b'''HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
@@ -444,18 +506,20 @@ Content-Type: text/html; charset=iso-8859-1
FF
''')
- try:
- self.assertRaises(urllib.ContentTooShortError, urllib.urlretrieve, 'http://example.com/')
- finally:
- self.unfakehttp()
+ with self.assertRaises(urllib.error.ContentTooShortError):
+ try:
+ urllib.request.urlretrieve('http://example.com/')
+ finally:
+ self.unfakehttp()
+
class QuotingTests(unittest.TestCase):
"""Tests for urllib.quote() and urllib.quote_plus()
- According to RFC 2396 ("Uniform Resource Identifiers), to escape a
- character you write it as '%' + <2 character US-ASCII hex value>. The Python
- code of ``'%' + hex(ord(<character>))[2:]`` escapes a character properly.
- Case does not matter on the hex letters.
+ According to RFC 2396 (Uniform Resource Identifiers), to escape a
+ character you write it as '%' + <2 character US-ASCII hex value>.
+ The Python code of ``'%' + hex(ord(<character>))[2:]`` escapes a
+ character properly. Case does not matter on the hex letters.
The various character sets specified are:
@@ -481,27 +545,45 @@ class QuotingTests(unittest.TestCase):
"abcdefghijklmnopqrstuvwxyz",
"0123456789",
"_.-"])
- result = urllib.quote(do_not_quote)
+ result = urllib.parse.quote(do_not_quote)
self.assertEqual(do_not_quote, result,
- "using quote(): %s != %s" % (do_not_quote, result))
- result = urllib.quote_plus(do_not_quote)
+ "using quote(): %r != %r" % (do_not_quote, result))
+ result = urllib.parse.quote_plus(do_not_quote)
self.assertEqual(do_not_quote, result,
- "using quote_plus(): %s != %s" % (do_not_quote, result))
+ "using quote_plus(): %r != %r" % (do_not_quote, result))
def test_default_safe(self):
# Test '/' is default value for 'safe' parameter
- self.assertEqual(urllib.quote.func_defaults[0], '/')
+ self.assertEqual(urllib.parse.quote.__defaults__[0], '/')
def test_safe(self):
# Test setting 'safe' parameter does what it should do
quote_by_default = "<>"
- result = urllib.quote(quote_by_default, safe=quote_by_default)
+ result = urllib.parse.quote(quote_by_default, safe=quote_by_default)
self.assertEqual(quote_by_default, result,
- "using quote(): %s != %s" % (quote_by_default, result))
- result = urllib.quote_plus(quote_by_default, safe=quote_by_default)
+ "using quote(): %r != %r" % (quote_by_default, result))
+ result = urllib.parse.quote_plus(quote_by_default,
+ safe=quote_by_default)
self.assertEqual(quote_by_default, result,
- "using quote_plus(): %s != %s" %
+ "using quote_plus(): %r != %r" %
(quote_by_default, result))
+ # Safe expressed as bytes rather than str
+ result = urllib.parse.quote(quote_by_default, safe=b"<>")
+ self.assertEqual(quote_by_default, result,
+ "using quote(): %r != %r" % (quote_by_default, result))
+ # "Safe" non-ASCII characters should have no effect
+ # (Since URIs are not allowed to have non-ASCII characters)
+ result = urllib.parse.quote("a\xfcb", encoding="latin-1", safe="\xfc")
+ expect = urllib.parse.quote("a\xfcb", encoding="latin-1", safe="")
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" %
+ (expect, result))
+ # Same as above, but using a bytes rather than str
+ result = urllib.parse.quote("a\xfcb", encoding="latin-1", safe=b"\xfc")
+ expect = urllib.parse.quote("a\xfcb", encoding="latin-1", safe="")
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" %
+ (expect, result))
def test_default_quoting(self):
# Make sure all characters that should be quoted are by default sans
@@ -511,11 +593,12 @@ class QuotingTests(unittest.TestCase):
should_quote.append(chr(127)) # For 0x7F
should_quote = ''.join(should_quote)
for char in should_quote:
- result = urllib.quote(char)
+ result = urllib.parse.quote(char)
self.assertEqual(hexescape(char), result,
- "using quote(): %s should be escaped to %s, not %s" %
+ "using quote(): "
+ "%s should be escaped to %s, not %s" %
(char, hexescape(char), result))
- result = urllib.quote_plus(char)
+ result = urllib.parse.quote_plus(char)
self.assertEqual(hexescape(char), result,
"using quote_plus(): "
"%s should be escapes to %s, not %s" %
@@ -523,38 +606,117 @@ class QuotingTests(unittest.TestCase):
del should_quote
partial_quote = "ab[]cd"
expected = "ab%5B%5Dcd"
- result = urllib.quote(partial_quote)
+ result = urllib.parse.quote(partial_quote)
self.assertEqual(expected, result,
- "using quote(): %s != %s" % (expected, result))
- result = urllib.quote_plus(partial_quote)
+ "using quote(): %r != %r" % (expected, result))
+ result = urllib.parse.quote_plus(partial_quote)
self.assertEqual(expected, result,
- "using quote_plus(): %s != %s" % (expected, result))
- self.assertRaises(TypeError, urllib.quote, None)
+ "using quote_plus(): %r != %r" % (expected, result))
def test_quoting_space(self):
# Make sure quote() and quote_plus() handle spaces as specified in
# their unique way
- result = urllib.quote(' ')
+ result = urllib.parse.quote(' ')
self.assertEqual(result, hexescape(' '),
- "using quote(): %s != %s" % (result, hexescape(' ')))
- result = urllib.quote_plus(' ')
+ "using quote(): %r != %r" % (result, hexescape(' ')))
+ result = urllib.parse.quote_plus(' ')
self.assertEqual(result, '+',
- "using quote_plus(): %s != +" % result)
+ "using quote_plus(): %r != +" % result)
given = "a b cd e f"
expect = given.replace(' ', hexescape(' '))
- result = urllib.quote(given)
+ result = urllib.parse.quote(given)
self.assertEqual(expect, result,
- "using quote(): %s != %s" % (expect, result))
+ "using quote(): %r != %r" % (expect, result))
expect = given.replace(' ', '+')
- result = urllib.quote_plus(given)
+ result = urllib.parse.quote_plus(given)
self.assertEqual(expect, result,
- "using quote_plus(): %s != %s" % (expect, result))
+ "using quote_plus(): %r != %r" % (expect, result))
def test_quoting_plus(self):
- self.assertEqual(urllib.quote_plus('alpha+beta gamma'),
+ self.assertEqual(urllib.parse.quote_plus('alpha+beta gamma'),
'alpha%2Bbeta+gamma')
- self.assertEqual(urllib.quote_plus('alpha+beta gamma', '+'),
+ self.assertEqual(urllib.parse.quote_plus('alpha+beta gamma', '+'),
'alpha+beta+gamma')
+ # Test with bytes
+ self.assertEqual(urllib.parse.quote_plus(b'alpha+beta gamma'),
+ 'alpha%2Bbeta+gamma')
+ # Test with safe bytes
+ self.assertEqual(urllib.parse.quote_plus('alpha+beta gamma', b'+'),
+ 'alpha+beta+gamma')
+
+ def test_quote_bytes(self):
+ # Bytes should quote directly to percent-encoded values
+ given = b"\xa2\xd8ab\xff"
+ expect = "%A2%D8ab%FF"
+ result = urllib.parse.quote(given)
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Encoding argument should raise type error on bytes input
+ self.assertRaises(TypeError, urllib.parse.quote, given,
+ encoding="latin-1")
+ # quote_from_bytes should work the same
+ result = urllib.parse.quote_from_bytes(given)
+ self.assertEqual(expect, result,
+ "using quote_from_bytes(): %r != %r"
+ % (expect, result))
+
+ def test_quote_with_unicode(self):
+ # Characters in Latin-1 range, encoded by default in UTF-8
+ given = "\xa2\xd8ab\xff"
+ expect = "%C2%A2%C3%98ab%C3%BF"
+ result = urllib.parse.quote(given)
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Characters in Latin-1 range, encoded by with None (default)
+ result = urllib.parse.quote(given, encoding=None, errors=None)
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Characters in Latin-1 range, encoded with Latin-1
+ given = "\xa2\xd8ab\xff"
+ expect = "%A2%D8ab%FF"
+ result = urllib.parse.quote(given, encoding="latin-1")
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Characters in BMP, encoded by default in UTF-8
+ given = "\u6f22\u5b57" # "Kanji"
+ expect = "%E6%BC%A2%E5%AD%97"
+ result = urllib.parse.quote(given)
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Characters in BMP, encoded with Latin-1
+ given = "\u6f22\u5b57"
+ self.assertRaises(UnicodeEncodeError, urllib.parse.quote, given,
+ encoding="latin-1")
+ # Characters in BMP, encoded with Latin-1, with replace error handling
+ given = "\u6f22\u5b57"
+ expect = "%3F%3F" # "??"
+ result = urllib.parse.quote(given, encoding="latin-1",
+ errors="replace")
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+ # Characters in BMP, Latin-1, with xmlcharref error handling
+ given = "\u6f22\u5b57"
+ expect = "%26%2328450%3B%26%2323383%3B" # "&#28450;&#23383;"
+ result = urllib.parse.quote(given, encoding="latin-1",
+ errors="xmlcharrefreplace")
+ self.assertEqual(expect, result,
+ "using quote(): %r != %r" % (expect, result))
+
+ def test_quote_plus_with_unicode(self):
+ # Encoding (latin-1) test for quote_plus
+ given = "\xa2\xd8 \xff"
+ expect = "%A2%D8+%FF"
+ result = urllib.parse.quote_plus(given, encoding="latin-1")
+ self.assertEqual(expect, result,
+ "using quote_plus(): %r != %r" % (expect, result))
+ # Errors test for quote_plus
+ given = "ab\u6f22\u5b57 cd"
+ expect = "ab%3F%3F+cd"
+ result = urllib.parse.quote_plus(given, encoding="latin-1",
+ errors="replace")
+ self.assertEqual(expect, result,
+ "using quote_plus(): %r != %r" % (expect, result))
+
class UnquotingTests(unittest.TestCase):
"""Tests for unquote() and unquote_plus()
@@ -569,49 +731,68 @@ class UnquotingTests(unittest.TestCase):
for num in range(128):
given = hexescape(chr(num))
expect = chr(num)
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result,
- "using unquote(): %s != %s" % (expect, result))
- result = urllib.unquote_plus(given)
+ "using unquote(): %r != %r" % (expect, result))
+ result = urllib.parse.unquote_plus(given)
self.assertEqual(expect, result,
- "using unquote_plus(): %s != %s" %
+ "using unquote_plus(): %r != %r" %
(expect, result))
escape_list.append(given)
escape_string = ''.join(escape_list)
del escape_list
- result = urllib.unquote(escape_string)
- self.assertEqual(result.count('%'), 1,
- "using quote(): not all characters escaped; %s" %
- result)
- result = urllib.unquote(escape_string)
+ result = urllib.parse.unquote(escape_string)
self.assertEqual(result.count('%'), 1,
"using unquote(): not all characters escaped: "
"%s" % result)
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, None)
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, ())
+ with support.check_warnings(('', BytesWarning), quiet=True):
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote, b'')
def test_unquoting_badpercent(self):
# Test unquoting on bad percent-escapes
given = '%xab'
expect = given
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result, "using unquote(): %r != %r"
% (expect, result))
given = '%x'
expect = given
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result, "using unquote(): %r != %r"
% (expect, result))
given = '%'
expect = given
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result, "using unquote(): %r != %r"
% (expect, result))
+ # unquote_to_bytes
+ given = '%xab'
+ expect = bytes(given, 'ascii')
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result, "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ given = '%x'
+ expect = bytes(given, 'ascii')
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result, "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ given = '%'
+ expect = bytes(given, 'ascii')
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result, "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote_to_bytes, None)
+ self.assertRaises((TypeError, AttributeError), urllib.parse.unquote_to_bytes, ())
def test_unquoting_mixed_case(self):
# Test unquoting on mixed-case hex digits in the percent-escapes
given = '%Ab%eA'
- expect = '\xab\xea'
- result = urllib.unquote(given)
- self.assertEqual(expect, result, "using unquote(): %r != %r"
+ expect = b'\xab\xea'
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result,
+ "using unquote_to_bytes(): %r != %r"
% (expect, result))
def test_unquoting_parts(self):
@@ -619,28 +800,113 @@ class UnquotingTests(unittest.TestCase):
# interspersed
given = 'ab%sd' % hexescape('c')
expect = "abcd"
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result,
- "using quote(): %s != %s" % (expect, result))
- result = urllib.unquote_plus(given)
+ "using quote(): %r != %r" % (expect, result))
+ result = urllib.parse.unquote_plus(given)
self.assertEqual(expect, result,
- "using unquote_plus(): %s != %s" % (expect, result))
+ "using unquote_plus(): %r != %r" % (expect, result))
def test_unquoting_plus(self):
# Test difference between unquote() and unquote_plus()
given = "are+there+spaces..."
expect = given
- result = urllib.unquote(given)
+ result = urllib.parse.unquote(given)
self.assertEqual(expect, result,
- "using unquote(): %s != %s" % (expect, result))
+ "using unquote(): %r != %r" % (expect, result))
expect = given.replace('+', ' ')
- result = urllib.unquote_plus(given)
+ result = urllib.parse.unquote_plus(given)
+ self.assertEqual(expect, result,
+ "using unquote_plus(): %r != %r" % (expect, result))
+
+ def test_unquote_to_bytes(self):
+ given = 'br%C3%BCckner_sapporo_20050930.doc'
+ expect = b'br\xc3\xbcckner_sapporo_20050930.doc'
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result,
+ "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ # Test on a string with unescaped non-ASCII characters
+ # (Technically an invalid URI; expect those characters to be UTF-8
+ # encoded).
+ result = urllib.parse.unquote_to_bytes("\u6f22%C3%BC")
+ expect = b'\xe6\xbc\xa2\xc3\xbc' # UTF-8 for "\u6f22\u00fc"
+ self.assertEqual(expect, result,
+ "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ # Test with a bytes as input
+ given = b'%A2%D8ab%FF'
+ expect = b'\xa2\xd8ab\xff'
+ result = urllib.parse.unquote_to_bytes(given)
+ self.assertEqual(expect, result,
+ "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
+ # Test with a bytes as input, with unescaped non-ASCII bytes
+ # (Technically an invalid URI; expect those bytes to be preserved)
+ given = b'%A2\xd8ab%FF'
+ expect = b'\xa2\xd8ab\xff'
+ result = urllib.parse.unquote_to_bytes(given)
self.assertEqual(expect, result,
- "using unquote_plus(): %s != %s" % (expect, result))
+ "using unquote_to_bytes(): %r != %r"
+ % (expect, result))
def test_unquote_with_unicode(self):
- r = urllib.unquote(u'br%C3%BCckner_sapporo_20050930.doc')
- self.assertEqual(r, u'br\xc3\xbcckner_sapporo_20050930.doc')
+ # Characters in the Latin-1 range, encoded with UTF-8
+ given = 'br%C3%BCckner_sapporo_20050930.doc'
+ expect = 'br\u00fcckner_sapporo_20050930.doc'
+ result = urllib.parse.unquote(given)
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+ # Characters in the Latin-1 range, encoded with None (default)
+ result = urllib.parse.unquote(given, encoding=None, errors=None)
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # Characters in the Latin-1 range, encoded with Latin-1
+ result = urllib.parse.unquote('br%FCckner_sapporo_20050930.doc',
+ encoding="latin-1")
+ expect = 'br\u00fcckner_sapporo_20050930.doc'
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # Characters in BMP, encoded with UTF-8
+ given = "%E6%BC%A2%E5%AD%97"
+ expect = "\u6f22\u5b57" # "Kanji"
+ result = urllib.parse.unquote(given)
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # Decode with UTF-8, invalid sequence
+ given = "%F3%B1"
+ expect = "\ufffd" # Replacement character
+ result = urllib.parse.unquote(given)
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # Decode with UTF-8, invalid sequence, replace errors
+ result = urllib.parse.unquote(given, errors="replace")
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # Decode with UTF-8, invalid sequence, ignoring errors
+ given = "%F3%B1"
+ expect = ""
+ result = urllib.parse.unquote(given, errors="ignore")
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # A mix of non-ASCII and percent-encoded characters, UTF-8
+ result = urllib.parse.unquote("\u6f22%C3%BC")
+ expect = '\u6f22\u00fc'
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
+
+ # A mix of non-ASCII and percent-encoded characters, Latin-1
+ # (Note, the string contains non-Latin-1-representable characters)
+ result = urllib.parse.unquote("\u6f22%FC", encoding="latin-1")
+ expect = '\u6f22\u00fc'
+ self.assertEqual(expect, result,
+ "using unquote(): %r != %r" % (expect, result))
class urlencode_Tests(unittest.TestCase):
"""Tests for urlencode()"""
@@ -658,7 +924,7 @@ class urlencode_Tests(unittest.TestCase):
"""
expect_somewhere = ["1st=1", "2nd=2", "3rd=3"]
- result = urllib.urlencode(given)
+ result = urllib.parse.urlencode(given)
for expected in expect_somewhere:
self.assertIn(expected, result,
"testing %s: %s not found in %s" %
@@ -691,26 +957,152 @@ class urlencode_Tests(unittest.TestCase):
# Make sure keys and values are quoted using quote_plus()
given = {"&":"="}
expect = "%s=%s" % (hexescape('&'), hexescape('='))
- result = urllib.urlencode(given)
+ result = urllib.parse.urlencode(given)
self.assertEqual(expect, result)
given = {"key name":"A bunch of pluses"}
expect = "key+name=A+bunch+of+pluses"
- result = urllib.urlencode(given)
+ result = urllib.parse.urlencode(given)
self.assertEqual(expect, result)
def test_doseq(self):
# Test that passing True for 'doseq' parameter works correctly
given = {'sequence':['1', '2', '3']}
- expect = "sequence=%s" % urllib.quote_plus(str(['1', '2', '3']))
- result = urllib.urlencode(given)
+ expect = "sequence=%s" % urllib.parse.quote_plus(str(['1', '2', '3']))
+ result = urllib.parse.urlencode(given)
self.assertEqual(expect, result)
- result = urllib.urlencode(given, True)
+ result = urllib.parse.urlencode(given, True)
for value in given["sequence"]:
expect = "sequence=%s" % value
self.assertIn(expect, result)
self.assertEqual(result.count('&'), 2,
"Expected 2 '&'s, got %s" % result.count('&'))
+ def test_empty_sequence(self):
+ self.assertEqual("", urllib.parse.urlencode({}))
+ self.assertEqual("", urllib.parse.urlencode([]))
+
+ def test_nonstring_values(self):
+ self.assertEqual("a=1", urllib.parse.urlencode({"a": 1}))
+ self.assertEqual("a=None", urllib.parse.urlencode({"a": None}))
+
+ def test_nonstring_seq_values(self):
+ self.assertEqual("a=1&a=2", urllib.parse.urlencode({"a": [1, 2]}, True))
+ self.assertEqual("a=None&a=a",
+ urllib.parse.urlencode({"a": [None, "a"]}, True))
+ data = collections.OrderedDict([("a", 1), ("b", 1)])
+ self.assertEqual("a=a&a=b",
+ urllib.parse.urlencode({"a": data}, True))
+
+ def test_urlencode_encoding(self):
+ # ASCII encoding. Expect %3F with errors="replace'
+ given = (('\u00a0', '\u00c1'),)
+ expect = '%3F=%3F'
+ result = urllib.parse.urlencode(given, encoding="ASCII", errors="replace")
+ self.assertEqual(expect, result)
+
+ # Default is UTF-8 encoding.
+ given = (('\u00a0', '\u00c1'),)
+ expect = '%C2%A0=%C3%81'
+ result = urllib.parse.urlencode(given)
+ self.assertEqual(expect, result)
+
+ # Latin-1 encoding.
+ given = (('\u00a0', '\u00c1'),)
+ expect = '%A0=%C1'
+ result = urllib.parse.urlencode(given, encoding="latin-1")
+ self.assertEqual(expect, result)
+
+ def test_urlencode_encoding_doseq(self):
+ # ASCII Encoding. Expect %3F with errors="replace'
+ given = (('\u00a0', '\u00c1'),)
+ expect = '%3F=%3F'
+ result = urllib.parse.urlencode(given, doseq=True,
+ encoding="ASCII", errors="replace")
+ self.assertEqual(expect, result)
+
+ # ASCII Encoding. On a sequence of values.
+ given = (("\u00a0", (1, "\u00c1")),)
+ expect = '%3F=1&%3F=%3F'
+ result = urllib.parse.urlencode(given, True,
+ encoding="ASCII", errors="replace")
+ self.assertEqual(expect, result)
+
+ # Utf-8
+ given = (("\u00a0", "\u00c1"),)
+ expect = '%C2%A0=%C3%81'
+ result = urllib.parse.urlencode(given, True)
+ self.assertEqual(expect, result)
+
+ given = (("\u00a0", (42, "\u00c1")),)
+ expect = '%C2%A0=42&%C2%A0=%C3%81'
+ result = urllib.parse.urlencode(given, True)
+ self.assertEqual(expect, result)
+
+ # latin-1
+ given = (("\u00a0", "\u00c1"),)
+ expect = '%A0=%C1'
+ result = urllib.parse.urlencode(given, True, encoding="latin-1")
+ self.assertEqual(expect, result)
+
+ given = (("\u00a0", (42, "\u00c1")),)
+ expect = '%A0=42&%A0=%C1'
+ result = urllib.parse.urlencode(given, True, encoding="latin-1")
+ self.assertEqual(expect, result)
+
+ def test_urlencode_bytes(self):
+ given = ((b'\xa0\x24', b'\xc1\x24'),)
+ expect = '%A0%24=%C1%24'
+ result = urllib.parse.urlencode(given)
+ self.assertEqual(expect, result)
+ result = urllib.parse.urlencode(given, True)
+ self.assertEqual(expect, result)
+
+ # Sequence of values
+ given = ((b'\xa0\x24', (42, b'\xc1\x24')),)
+ expect = '%A0%24=42&%A0%24=%C1%24'
+ result = urllib.parse.urlencode(given, True)
+ self.assertEqual(expect, result)
+
+ def test_urlencode_encoding_safe_parameter(self):
+
+ # Send '$' (\x24) as safe character
+ # Default utf-8 encoding
+
+ given = ((b'\xa0\x24', b'\xc1\x24'),)
+ result = urllib.parse.urlencode(given, safe=":$")
+ expect = '%A0$=%C1$'
+ self.assertEqual(expect, result)
+
+ given = ((b'\xa0\x24', b'\xc1\x24'),)
+ result = urllib.parse.urlencode(given, doseq=True, safe=":$")
+ expect = '%A0$=%C1$'
+ self.assertEqual(expect, result)
+
+ # Safe parameter in sequence
+ given = ((b'\xa0\x24', (b'\xc1\x24', 0xd, 42)),)
+ expect = '%A0$=%C1$&%A0$=13&%A0$=42'
+ result = urllib.parse.urlencode(given, True, safe=":$")
+ self.assertEqual(expect, result)
+
+ # Test all above in latin-1 encoding
+
+ given = ((b'\xa0\x24', b'\xc1\x24'),)
+ result = urllib.parse.urlencode(given, safe=":$",
+ encoding="latin-1")
+ expect = '%A0$=%C1$'
+ self.assertEqual(expect, result)
+
+ given = ((b'\xa0\x24', b'\xc1\x24'),)
+ expect = '%A0$=%C1$'
+ result = urllib.parse.urlencode(given, doseq=True, safe=":$",
+ encoding="latin-1")
+
+ given = ((b'\xa0\x24', (b'\xc1\x24', 0xd, 42)),)
+ expect = '%A0$=%C1$&%A0$=13&%A0$=42'
+ result = urllib.parse.urlencode(given, True, safe=":$",
+ encoding="latin-1")
+ self.assertEqual(expect, result)
+
class Pathname_Tests(unittest.TestCase):
"""Test pathname2url() and url2pathname()"""
@@ -718,11 +1110,11 @@ class Pathname_Tests(unittest.TestCase):
# Make sure simple tests pass
expected_path = os.path.join("parts", "of", "a", "path")
expected_url = "parts/of/a/path"
- result = urllib.pathname2url(expected_path)
+ result = urllib.request.pathname2url(expected_path)
self.assertEqual(expected_url, result,
"pathname2url() failed; %s != %s" %
(result, expected_url))
- result = urllib.url2pathname(expected_url)
+ result = urllib.request.url2pathname(expected_url)
self.assertEqual(expected_path, result,
"url2pathame() failed; %s != %s" %
(result, expected_path))
@@ -731,70 +1123,74 @@ class Pathname_Tests(unittest.TestCase):
# Test automatic quoting and unquoting works for pathnam2url() and
# url2pathname() respectively
given = os.path.join("needs", "quot=ing", "here")
- expect = "needs/%s/here" % urllib.quote("quot=ing")
- result = urllib.pathname2url(given)
+ expect = "needs/%s/here" % urllib.parse.quote("quot=ing")
+ result = urllib.request.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
expect = given
- result = urllib.url2pathname(result)
+ result = urllib.request.url2pathname(result)
self.assertEqual(expect, result,
"url2pathname() failed; %s != %s" %
(expect, result))
given = os.path.join("make sure", "using_quote")
- expect = "%s/using_quote" % urllib.quote("make sure")
- result = urllib.pathname2url(given)
+ expect = "%s/using_quote" % urllib.parse.quote("make sure")
+ result = urllib.request.pathname2url(given)
self.assertEqual(expect, result,
"pathname2url() failed; %s != %s" %
(expect, result))
given = "make+sure/using_unquote"
expect = os.path.join("make+sure", "using_unquote")
- result = urllib.url2pathname(given)
+ result = urllib.request.url2pathname(given)
self.assertEqual(expect, result,
"url2pathname() failed; %s != %s" %
(expect, result))
@unittest.skipUnless(sys.platform == 'win32',
- 'test specific to the nturl2path library')
+ 'test specific to the urllib.url2path function.')
def test_ntpath(self):
given = ('/C:/', '///C:/', '/C|//')
expect = 'C:\\'
for url in given:
- result = urllib.url2pathname(url)
+ result = urllib.request.url2pathname(url)
self.assertEqual(expect, result,
- 'nturl2path.url2pathname() failed; %s != %s' %
+ 'urllib.request..url2pathname() failed; %s != %s' %
(expect, result))
given = '///C|/path'
expect = 'C:\\path'
- result = urllib.url2pathname(given)
+ result = urllib.request.url2pathname(given)
self.assertEqual(expect, result,
- 'nturl2path.url2pathname() failed; %s != %s' %
+ 'urllib.request.url2pathname() failed; %s != %s' %
(expect, result))
class Utility_Tests(unittest.TestCase):
"""Testcase to test the various utility functions in the urllib."""
def test_splitpasswd(self):
- """Some of the password examples are not sensible, but it is added to
+ """Some of password examples are not sensible, but it is added to
confirming to RFC2617 and addressing issue4675.
"""
- self.assertEqual(('user', 'ab'),urllib.splitpasswd('user:ab'))
- self.assertEqual(('user', 'a\nb'),urllib.splitpasswd('user:a\nb'))
- self.assertEqual(('user', 'a\tb'),urllib.splitpasswd('user:a\tb'))
- self.assertEqual(('user', 'a\rb'),urllib.splitpasswd('user:a\rb'))
- self.assertEqual(('user', 'a\fb'),urllib.splitpasswd('user:a\fb'))
- self.assertEqual(('user', 'a\vb'),urllib.splitpasswd('user:a\vb'))
- self.assertEqual(('user', 'a:b'),urllib.splitpasswd('user:a:b'))
- self.assertEqual(('user', 'a b'),urllib.splitpasswd('user:a b'))
- self.assertEqual(('user 2', 'ab'),urllib.splitpasswd('user 2:ab'))
- self.assertEqual(('user+1', 'a+b'),urllib.splitpasswd('user+1:a+b'))
+ self.assertEqual(('user', 'ab'),urllib.parse.splitpasswd('user:ab'))
+ self.assertEqual(('user', 'a\nb'),urllib.parse.splitpasswd('user:a\nb'))
+ self.assertEqual(('user', 'a\tb'),urllib.parse.splitpasswd('user:a\tb'))
+ self.assertEqual(('user', 'a\rb'),urllib.parse.splitpasswd('user:a\rb'))
+ self.assertEqual(('user', 'a\fb'),urllib.parse.splitpasswd('user:a\fb'))
+ self.assertEqual(('user', 'a\vb'),urllib.parse.splitpasswd('user:a\vb'))
+ self.assertEqual(('user', 'a:b'),urllib.parse.splitpasswd('user:a:b'))
+ self.assertEqual(('user', 'a b'),urllib.parse.splitpasswd('user:a b'))
+ self.assertEqual(('user 2', 'ab'),urllib.parse.splitpasswd('user 2:ab'))
+ self.assertEqual(('user+1', 'a+b'),urllib.parse.splitpasswd('user+1:a+b'))
+
+ def test_thishost(self):
+ """Test the urllib.request.thishost utility function returns a tuple"""
+ self.assertIsInstance(urllib.request.thishost(), tuple)
class URLopener_Tests(unittest.TestCase):
"""Testcase to test the open method of URLopener class."""
def test_quoted_open(self):
- class DummyURLopener(urllib.URLopener):
+ class DummyURLopener(urllib.request.URLopener):
def open_spam(self, url):
return url
@@ -806,7 +1202,6 @@ class URLopener_Tests(unittest.TestCase):
"spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/"),
"//c:|windows%/:=&?~#+!$,;'@()*[]|/path/")
-
# Just commented them out.
# Can't really tell why keep failing in windows and sparc.
# Everywhere else they work ok, but on those machines, sometimes
@@ -888,24 +1283,20 @@ class URLopener_Tests(unittest.TestCase):
def test_main():
- import warnings
- with warnings.catch_warnings():
- warnings.filterwarnings('ignore', ".*urllib\.urlopen.*Python 3.0",
- DeprecationWarning)
- test_support.run_unittest(
- urlopen_FileTests,
- urlopen_HttpTests,
- urlretrieve_FileTests,
- urlretrieve_HttpTests,
- ProxyTests,
- QuotingTests,
- UnquotingTests,
- urlencode_Tests,
- Pathname_Tests,
- Utility_Tests,
- URLopener_Tests,
- #FTPWrapperTests,
- )
+ support.run_unittest(
+ urlopen_FileTests,
+ urlopen_HttpTests,
+ urlretrieve_FileTests,
+ urlretrieve_HttpTests,
+ ProxyTests,
+ QuotingTests,
+ UnquotingTests,
+ urlencode_Tests,
+ Pathname_Tests,
+ Utility_Tests,
+ URLopener_Tests,
+ #FTPWrapperTests,
+ )
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index eac995001e8..5eab30af765 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -1,12 +1,16 @@
import unittest
-from test import test_support
+from test import support
import os
+import io
import socket
-import StringIO
+import array
-import urllib2
-from urllib2 import Request, OpenerDirector
+import urllib.request
+# The proxy bypass method imported below has logic specific to the OSX
+# proxy config data structure but is testable on all platforms.
+from urllib.request import Request, OpenerDirector, _proxy_bypass_macosx_sysconf
+import urllib.error
# XXX
# Request
@@ -17,35 +21,31 @@ class TrivialTests(unittest.TestCase):
def test_trivial(self):
# A couple trivial tests
- self.assertRaises(ValueError, urllib2.urlopen, 'bogus url')
+ self.assertRaises(ValueError, urllib.request.urlopen, 'bogus url')
# XXX Name hacking to get this to work on Windows.
- fname = os.path.abspath(urllib2.__file__).replace('\\', '/')
-
- # And more hacking to get it to work on MacOS. This assumes
- # urllib.pathname2url works, unfortunately...
- if os.name == 'riscos':
- import string
- fname = os.expand(fname)
- fname = fname.translate(string.maketrans("/.", "./"))
+ fname = os.path.abspath(urllib.request.__file__).replace('\\', '/')
if os.name == 'nt':
file_url = "file:///%s" % fname
else:
file_url = "file://%s" % fname
- f = urllib2.urlopen(file_url)
+ f = urllib.request.urlopen(file_url)
buf = f.read()
f.close()
def test_parse_http_list(self):
- tests = [('a,b,c', ['a', 'b', 'c']),
- ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']),
- ('a, b, "c", "d", "e,f", g, h', ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']),
- ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])]
+ tests = [
+ ('a,b,c', ['a', 'b', 'c']),
+ ('path"o,l"og"i"cal, example', ['path"o,l"og"i"cal', 'example']),
+ ('a, b, "c", "d", "e,f", g, h',
+ ['a', 'b', '"c"', '"d"', '"e,f"', 'g', 'h']),
+ ('a="b\\"c", d="e\\,f", g="h\\\\i"',
+ ['a="b"c"', 'd="e,f"', 'g="h\\i"'])]
for string, list in tests:
- self.assertEqual(urllib2.parse_http_list(string), list)
+ self.assertEqual(urllib.request.parse_http_list(string), list)
def test_request_headers_dict():
@@ -83,7 +83,7 @@ def test_request_headers_methods():
Note the case normalization of header names here, to .capitalize()-case.
This should be preserved for backwards-compatibility. (In the HTTP case,
normalization to .title()-case is done by urllib2 before sending headers to
- httplib).
+ http.client).
>>> url = "http://example.com"
>>> r = Request(url, headers={"Spam-eggs": "blah"})
@@ -92,8 +92,7 @@ def test_request_headers_methods():
>>> r.header_items()
[('Spam-eggs', 'blah')]
>>> r.add_header("Foo-Bar", "baz")
- >>> items = r.header_items()
- >>> items.sort()
+ >>> items = sorted(r.header_items())
>>> items
[('Foo-bar', 'baz'), ('Spam-eggs', 'blah')]
@@ -103,7 +102,7 @@ def test_request_headers_methods():
>>> r.has_header("Not-there")
False
- >>> print r.get_header("Not-there")
+ >>> print(r.get_header("Not-there"))
None
>>> r.get_header("Not-there", "default")
'default'
@@ -113,7 +112,7 @@ def test_request_headers_methods():
def test_password_manager(self):
"""
- >>> mgr = urllib2.HTTPPasswordMgr()
+ >>> mgr = urllib.request.HTTPPasswordMgr()
>>> add = mgr.add_password
>>> add("Some Realm", "http://example.com/", "joe", "password")
>>> add("Some Realm", "http://example.com/ni", "ni", "ni")
@@ -178,7 +177,7 @@ def test_password_manager(self):
def test_password_manager_default_port(self):
"""
- >>> mgr = urllib2.HTTPPasswordMgr()
+ >>> mgr = urllib.request.HTTPPasswordMgr()
>>> add = mgr.add_password
The point to note here is that we can't guess the default port if there's
@@ -225,8 +224,8 @@ def test_password_manager_default_port(self):
class MockOpener:
addheaders = []
- def open(self, req, data=None,timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
- self.req, self.data, self.timeout = req, data, timeout
+ def open(self, req, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+ self.req, self.data, self.timeout = req, data, timeout
def error(self, proto, *args):
self.proto, self.args = proto, args
@@ -237,11 +236,11 @@ class MockFile:
class MockHeaders(dict):
def getheaders(self, name):
- return self.values()
+ return list(self.values())
-class MockResponse(StringIO.StringIO):
+class MockResponse(io.StringIO):
def __init__(self, code, msg, headers, data, url=None):
- StringIO.StringIO.__init__(self, data)
+ io.StringIO.__init__(self, data)
self.code, self.msg, self.headers, self.url = code, msg, headers, url
def info(self):
return self.headers
@@ -262,17 +261,27 @@ class FakeMethod:
def __call__(self, *args):
return self.handle(self.meth_name, self.action, *args)
-class MockHTTPResponse:
+class MockHTTPResponse(io.IOBase):
def __init__(self, fp, msg, status, reason):
self.fp = fp
self.msg = msg
self.status = status
self.reason = reason
+ self.code = 200
+
def read(self):
return ''
+ def info(self):
+ return {}
+
+ def geturl(self):
+ return self.url
+
+
class MockHTTPClass:
def __init__(self):
+ self.level = 0
self.req_headers = []
self.data = None
self.raise_on_endheaders = False
@@ -305,7 +314,6 @@ class MockHTTPClass:
if self.raise_on_endheaders:
import socket
raise socket.error()
-
def getresponse(self):
return MockHTTPResponse(MockFile(), {}, 200, "OK")
@@ -344,7 +352,7 @@ class MockHandler:
res = MockResponse(200, "OK", {}, "")
return self.parent.error("http", args[0], res, code, "", {})
elif action == "raise":
- raise urllib2.URLError("blah")
+ raise urllib.error.URLError("blah")
assert False
def close(self): pass
def add_parent(self, parent):
@@ -393,7 +401,7 @@ def build_test_opener(*handler_instances):
opener.add_handler(h)
return opener
-class MockHTTPHandler(urllib2.BaseHandler):
+class MockHTTPHandler(urllib.request.BaseHandler):
# useful for testing redirections and auth
# sends supplied headers and code as first response
# sends 200 OK as second response
@@ -405,26 +413,26 @@ class MockHTTPHandler(urllib2.BaseHandler):
self._count = 0
self.requests = []
def http_open(self, req):
- import mimetools, httplib, copy
- from StringIO import StringIO
+ import email, http.client, copy
+ from io import StringIO
self.requests.append(copy.deepcopy(req))
if self._count == 0:
self._count = self._count + 1
- name = httplib.responses[self.code]
- msg = mimetools.Message(StringIO(self.headers))
+ name = http.client.responses[self.code]
+ msg = email.message_from_string(self.headers)
return self.parent.error(
"http", req, MockFile(), self.code, name, msg)
else:
self.req = req
- msg = mimetools.Message(StringIO("\r\n\r\n"))
+ msg = email.message_from_string("\r\n\r\n")
return MockResponse(200, "OK", msg, "", req.get_full_url())
-class MockHTTPSHandler(urllib2.AbstractHTTPHandler):
+class MockHTTPSHandler(urllib.request.AbstractHTTPHandler):
# Useful for testing the Proxy-Authorization request by verifying the
# properties of httpcon
def __init__(self):
- urllib2.AbstractHTTPHandler.__init__(self)
+ urllib.request.AbstractHTTPHandler.__init__(self)
self.httpconn = MockHTTPClass()
def https_open(self, req):
@@ -459,7 +467,7 @@ class OpenerDirectorTests(unittest.TestCase):
# TypeError in real code; here, returning self from these mock
# methods would either cause no exception, or AttributeError.
- from urllib2 import URLError
+ from urllib.error import URLError
o = OpenerDirector()
meth_spec = [
@@ -467,7 +475,7 @@ class OpenerDirectorTests(unittest.TestCase):
[("redirect_request", "return self")],
]
handlers = add_ordered_mock_handlers(o, meth_spec)
- o.add_handler(urllib2.UnknownHandler())
+ o.add_handler(urllib.request.UnknownHandler())
for scheme in "do", "proxy", "redirect":
self.assertRaises(URLError, o.open, scheme+"://example.com/")
@@ -525,7 +533,7 @@ class OpenerDirectorTests(unittest.TestCase):
handlers = add_ordered_mock_handlers(o, meth_spec)
req = Request("http://example.com/")
- self.assertRaises(urllib2.URLError, o.open, req)
+ self.assertRaises(urllib.error.URLError, o.open, req)
self.assertEqual(o.calls, [(handlers[0], "http_open", (req,), {})])
## def test_error(self):
@@ -596,8 +604,11 @@ class OpenerDirectorTests(unittest.TestCase):
def sanepathname2url(path):
- import urllib
- urlpath = urllib.pathname2url(path)
+ try:
+ path.encode("utf8")
+ except UnicodeEncodeError:
+ raise unittest.SkipTest("path is not encodable to utf8")
+ urlpath = urllib.request.pathname2url(path)
if os.name == "nt" and urlpath.startswith("///"):
urlpath = urlpath[2:]
# XXX don't ask me about the mac...
@@ -610,10 +621,10 @@ class HandlerTests(unittest.TestCase):
def __init__(self, data): self.data = data
def retrfile(self, filename, filetype):
self.filename, self.filetype = filename, filetype
- return StringIO.StringIO(self.data), len(self.data)
+ return io.StringIO(self.data), len(self.data)
def close(self): pass
- class NullFTPHandler(urllib2.FTPHandler):
+ class NullFTPHandler(urllib.request.FTPHandler):
def __init__(self, data): self.data = data
def connect_ftp(self, user, passwd, host, port, dirs,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
@@ -664,13 +675,13 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(int(headers["Content-length"]), len(data))
def test_file(self):
- import rfc822, socket
- h = urllib2.FileHandler()
+ import email.utils, socket
+ h = urllib.request.FileHandler()
o = h.parent = MockOpener()
- TESTFN = test_support.TESTFN
+ TESTFN = support.TESTFN
urlpath = sanepathname2url(os.path.abspath(TESTFN))
- towrite = "hello, world\n"
+ towrite = b"hello, world\n"
urls = [
"file://localhost%s" % urlpath,
"file://%s" % urlpath,
@@ -699,7 +710,7 @@ class HandlerTests(unittest.TestCase):
finally:
r.close()
stats = os.stat(TESTFN)
- modified = rfc822.formatdate(stats.st_mtime)
+ modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
finally:
os.remove(TESTFN)
self.assertEqual(data, towrite)
@@ -723,12 +734,12 @@ class HandlerTests(unittest.TestCase):
finally:
f.close()
- self.assertRaises(urllib2.URLError,
+ self.assertRaises(urllib.error.URLError,
h.file_open, Request(url))
finally:
os.remove(TESTFN)
- h = urllib2.FileHandler()
+ h = urllib.request.FileHandler()
o = h.parent = MockOpener()
# XXXX why does // mean ftp (and /// mean not ftp!), and where
# is file: scheme specified? I think this is really a bug, and
@@ -738,31 +749,31 @@ class HandlerTests(unittest.TestCase):
# file:///blah.txt (a file)
# file://ftp.example.com/blah.txt (an ftp URL)
for url, ftp in [
- ("file://ftp.example.com//foo.txt", True),
+ ("file://ftp.example.com//foo.txt", False),
("file://ftp.example.com///foo.txt", False),
# XXXX bug: fails with OSError, should be URLError
("file://ftp.example.com/foo.txt", False),
- ("file://somehost//foo/something.txt", True),
+ ("file://somehost//foo/something.txt", False),
("file://localhost//foo/something.txt", False),
]:
req = Request(url)
try:
h.file_open(req)
# XXXX remove OSError when bug fixed
- except (urllib2.URLError, OSError):
- self.assertTrue(not ftp)
+ except (urllib.error.URLError, OSError):
+ self.assertFalse(ftp)
else:
- self.assertTrue(o.req is req)
+ self.assertIs(o.req, req)
self.assertEqual(req.type, "ftp")
self.assertEqual(req.type == "ftp", ftp)
def test_http(self):
- h = urllib2.AbstractHTTPHandler()
+ h = urllib.request.AbstractHTTPHandler()
o = h.parent = MockOpener()
url = "http://example.com/"
- for method, data in [("GET", None), ("POST", "blah")]:
+ for method, data in [("GET", None), ("POST", b"blah")]:
req = Request(url, data, {"Foo": "bar"})
req.timeout = None
req.add_unredirected_header("Spam", "eggs")
@@ -774,7 +785,7 @@ class HandlerTests(unittest.TestCase):
r.info; r.geturl # addinfourl methods
r.code, r.msg == 200, "OK" # added from MockHTTPClass.getreply()
hdrs = r.info()
- hdrs.get; hdrs.has_key # r.info() gives dict from .getreply()
+ hdrs.get; hdrs.__contains__ # r.info() gives dict from .getreply()
self.assertEqual(r.geturl(), url)
self.assertEqual(http.host, "example.com")
@@ -788,11 +799,15 @@ class HandlerTests(unittest.TestCase):
# check socket.error converted to URLError
http.raise_on_endheaders = True
- self.assertRaises(urllib2.URLError, h.do_open, http, req)
+ self.assertRaises(urllib.error.URLError, h.do_open, http, req)
+
+ # Check for TypeError on POST data which is str.
+ req = Request("http://example.com/","badpost")
+ self.assertRaises(TypeError, h.do_request_, req)
# check adding of standard headers
o.addheaders = [("Spam", "eggs")]
- for data in "", None: # POST, GET
+ for data in b"", None: # POST, GET
req = Request("http://example.com/", data)
r = MockResponse(200, "OK", {}, "")
newreq = h.do_request_(req)
@@ -818,19 +833,62 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(req.unredirected_hdrs["Host"], "baz")
self.assertEqual(req.unredirected_hdrs["Spam"], "foo")
+ # Check iterable body support
+ def iterable_body():
+ yield b"one"
+ yield b"two"
+ yield b"three"
+
+ for headers in {}, {"Content-Length": 11}:
+ req = Request("http://example.com/", iterable_body(), headers)
+ if not headers:
+ # Having an iterable body without a Content-Length should
+ # raise an exception
+ self.assertRaises(ValueError, h.do_request_, req)
+ else:
+ newreq = h.do_request_(req)
+
+ # A file object.
+ # Test only Content-Length attribute of request.
+
+ file_obj = io.BytesIO()
+ file_obj.write(b"Something\nSomething\nSomething\n")
+
+ for headers in {}, {"Content-Length": 30}:
+ req = Request("http://example.com/", file_obj, headers)
+ if not headers:
+ # Having an iterable body without a Content-Length should
+ # raise an exception
+ self.assertRaises(ValueError, h.do_request_, req)
+ else:
+ newreq = h.do_request_(req)
+ self.assertEqual(int(newreq.get_header('Content-length')),30)
+
+ file_obj.close()
+
+ # array.array Iterable - Content Length is calculated
+
+ iterable_array = array.array("I",[1,2,3,4])
+
+ for headers in {}, {"Content-Length": 16}:
+ req = Request("http://example.com/", iterable_array, headers)
+ newreq = h.do_request_(req)
+ self.assertEqual(int(newreq.get_header('Content-length')),16)
+
def test_http_doubleslash(self):
- # Checks that the presence of an unnecessary double slash in a url doesn't break anything
- # Previously, a double slash directly after the host could cause incorrect parsing of the url
- h = urllib2.AbstractHTTPHandler()
+ # Checks the presence of any unnecessary double slash in url does not
+ # break anything. Previously, a double slash directly after the host
+ # could cause incorrect parsing.
+ h = urllib.request.AbstractHTTPHandler()
o = h.parent = MockOpener()
- data = ""
+ data = b""
ds_urls = [
"http://example.com/foo/bar/baz.html",
"http://example.com//foo/bar/baz.html",
"http://example.com/foo//bar/baz.html",
- "http://example.com/foo/bar//baz.html",
- ]
+ "http://example.com/foo/bar//baz.html"
+ ]
for ds_url in ds_urls:
ds_req = Request(ds_url, data)
@@ -848,23 +906,24 @@ class HandlerTests(unittest.TestCase):
# Issue4493: urllib2 to supply '/' when to urls where path does not
# start with'/'
- h = urllib2.AbstractHTTPHandler()
+ h = urllib.request.AbstractHTTPHandler()
o = h.parent = MockOpener()
weird_url = 'http://www.python.org?getspam'
req = Request(weird_url)
newreq = h.do_request_(req)
- self.assertEqual(newreq.get_host(),'www.python.org')
- self.assertEqual(newreq.get_selector(),'/?getspam')
+ self.assertEqual(newreq.host,'www.python.org')
+ self.assertEqual(newreq.selector,'/?getspam')
url_without_path = 'http://www.python.org'
req = Request(url_without_path)
newreq = h.do_request_(req)
- self.assertEqual(newreq.get_host(),'www.python.org')
- self.assertEqual(newreq.get_selector(),'')
+ self.assertEqual(newreq.host,'www.python.org')
+ self.assertEqual(newreq.selector,'')
+
def test_errors(self):
- h = urllib2.HTTPErrorProcessor()
+ h = urllib.request.HTTPErrorProcessor()
o = h.parent = MockOpener()
url = "http://example.com/"
@@ -872,41 +931,43 @@ class HandlerTests(unittest.TestCase):
# all 2xx are passed through
r = MockResponse(200, "OK", {}, "", url)
newr = h.http_response(req, r)
- self.assertTrue(r is newr)
- self.assertTrue(not hasattr(o, "proto")) # o.error not called
+ self.assertIs(r, newr)
+ self.assertFalse(hasattr(o, "proto")) # o.error not called
r = MockResponse(202, "Accepted", {}, "", url)
newr = h.http_response(req, r)
- self.assertTrue(r is newr)
- self.assertTrue(not hasattr(o, "proto")) # o.error not called
+ self.assertIs(r, newr)
+ self.assertFalse(hasattr(o, "proto")) # o.error not called
r = MockResponse(206, "Partial content", {}, "", url)
newr = h.http_response(req, r)
- self.assertTrue(r is newr)
- self.assertTrue(not hasattr(o, "proto")) # o.error not called
+ self.assertIs(r, newr)
+ self.assertFalse(hasattr(o, "proto")) # o.error not called
# anything else calls o.error (and MockOpener returns None, here)
r = MockResponse(502, "Bad gateway", {}, "", url)
- self.assertTrue(h.http_response(req, r) is None)
+ self.assertIsNone(h.http_response(req, r))
self.assertEqual(o.proto, "http") # o.error called
self.assertEqual(o.args, (req, r, 502, "Bad gateway", {}))
def test_cookies(self):
cj = MockCookieJar()
- h = urllib2.HTTPCookieProcessor(cj)
+ h = urllib.request.HTTPCookieProcessor(cj)
o = h.parent = MockOpener()
req = Request("http://example.com/")
r = MockResponse(200, "OK", {}, "")
newreq = h.http_request(req)
- self.assertTrue(cj.ach_req is req is newreq)
+ self.assertIs(cj.ach_req, req)
+ self.assertIs(cj.ach_req, newreq)
self.assertEqual(req.get_origin_req_host(), "example.com")
- self.assertTrue(not req.is_unverifiable())
+ self.assertFalse(req.is_unverifiable())
newr = h.http_response(req, r)
- self.assertTrue(cj.ec_req is req)
- self.assertTrue(cj.ec_r is r is newr)
+ self.assertIs(cj.ec_req, req)
+ self.assertIs(cj.ec_r, r)
+ self.assertIs(r, newr)
def test_redirect(self):
from_url = "http://example.com/a.html"
to_url = "http://example.com/b.html"
- h = urllib2.HTTPRedirectHandler()
+ h = urllib.request.HTTPRedirectHandler()
o = h.parent = MockOpener()
# ordinary redirect behaviour
@@ -914,22 +975,22 @@ class HandlerTests(unittest.TestCase):
for data in None, "blah\nblah\n":
method = getattr(h, "http_error_%s" % code)
req = Request(from_url, data)
- req.add_header("Nonsense", "viking=withhold")
req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT
+ req.add_header("Nonsense", "viking=withhold")
if data is not None:
req.add_header("Content-Length", str(len(data)))
req.add_unredirected_header("Spam", "spam")
try:
method(req, MockFile(), code, "Blah",
MockHeaders({"location": to_url}))
- except urllib2.HTTPError:
+ except urllib.error.HTTPError:
# 307 in response to POST requires user OK
self.assertTrue(code == 307 and data is not None)
self.assertEqual(o.req.get_full_url(), to_url)
try:
self.assertEqual(o.req.get_method(), "GET")
except AttributeError:
- self.assertTrue(not o.req.has_data())
+ self.assertFalse(o.req.has_data())
# now it's a GET, there should not be headers regarding content
# (possibly dragged from before being a POST)
@@ -959,9 +1020,9 @@ class HandlerTests(unittest.TestCase):
while 1:
redirect(h, req, "http://example.com/")
count = count + 1
- except urllib2.HTTPError:
+ except urllib.error.HTTPError:
# don't stop until max_repeats, because cookies may introduce state
- self.assertEqual(count, urllib2.HTTPRedirectHandler.max_repeats)
+ self.assertEqual(count, urllib.request.HTTPRedirectHandler.max_repeats)
# detect endless non-repeating chain of redirects
req = Request(from_url, origin_req_host="example.com")
@@ -971,25 +1032,26 @@ class HandlerTests(unittest.TestCase):
while 1:
redirect(h, req, "http://example.com/%d" % count)
count = count + 1
- except urllib2.HTTPError:
+ except urllib.error.HTTPError:
self.assertEqual(count,
- urllib2.HTTPRedirectHandler.max_redirections)
+ urllib.request.HTTPRedirectHandler.max_redirections)
+
def test_invalid_redirect(self):
from_url = "http://example.com/a.html"
- valid_schemes = ['http', 'https', 'ftp']
- invalid_schemes = ['file', 'imap', 'ldap']
+ valid_schemes = ['http','https','ftp']
+ invalid_schemes = ['file','imap','ldap']
schemeless_url = "example.com/b.html"
- h = urllib2.HTTPRedirectHandler()
+ h = urllib.request.HTTPRedirectHandler()
o = h.parent = MockOpener()
req = Request(from_url)
req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT
for scheme in invalid_schemes:
invalid_url = scheme + '://' + schemeless_url
- self.assertRaises(urllib2.HTTPError, h.http_error_302,
- req, MockFile(), 302, "Security Loophole",
- MockHeaders({"location": invalid_url}))
+ self.assertRaises(urllib.error.HTTPError, h.http_error_302,
+ req, MockFile(), 302, "Security Loophole",
+ MockHeaders({"location": invalid_url}))
for scheme in valid_schemes:
valid_url = scheme + '://' + schemeless_url
@@ -997,34 +1059,46 @@ class HandlerTests(unittest.TestCase):
MockHeaders({"location": valid_url}))
self.assertEqual(o.req.get_full_url(), valid_url)
+ def test_relative_redirect(self):
+ from_url = "http://example.com/a.html"
+ relative_url = "/b.html"
+ h = urllib.request.HTTPRedirectHandler()
+ o = h.parent = MockOpener()
+ req = Request(from_url)
+ req.timeout = socket._GLOBAL_DEFAULT_TIMEOUT
+
+ valid_url = urllib.parse.urljoin(from_url,relative_url)
+ h.http_error_302(req, MockFile(), 302, "That's fine",
+ MockHeaders({"location": valid_url}))
+ self.assertEqual(o.req.get_full_url(), valid_url)
+
def test_cookie_redirect(self):
# cookies shouldn't leak into redirected requests
- from cookielib import CookieJar
-
- from test.test_cookielib import interact_netscape
+ from http.cookiejar import CookieJar
+ from test.test_http_cookiejar import interact_netscape
cj = CookieJar()
interact_netscape(cj, "http://www.example.com/", "spam=eggs")
hh = MockHTTPHandler(302, "Location: http://www.cracker.com/\r\n\r\n")
- hdeh = urllib2.HTTPDefaultErrorHandler()
- hrh = urllib2.HTTPRedirectHandler()
- cp = urllib2.HTTPCookieProcessor(cj)
+ hdeh = urllib.request.HTTPDefaultErrorHandler()
+ hrh = urllib.request.HTTPRedirectHandler()
+ cp = urllib.request.HTTPCookieProcessor(cj)
o = build_test_opener(hh, hdeh, hrh, cp)
o.open("http://www.example.com/")
- self.assertTrue(not hh.req.has_header("Cookie"))
+ self.assertFalse(hh.req.has_header("Cookie"))
def test_redirect_fragment(self):
redirected_url = 'http://www.example.com/index.html#OK\r\n\r\n'
hh = MockHTTPHandler(302, 'Location: ' + redirected_url)
- hdeh = urllib2.HTTPDefaultErrorHandler()
- hrh = urllib2.HTTPRedirectHandler()
+ hdeh = urllib.request.HTTPDefaultErrorHandler()
+ hrh = urllib.request.HTTPRedirectHandler()
o = build_test_opener(hh, hdeh, hrh)
fp = o.open('http://www.example.com')
self.assertEqual(fp.geturl(), redirected_url.strip())
def test_proxy(self):
o = OpenerDirector()
- ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128"))
+ ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128"))
o.add_handler(ph)
meth_spec = [
[("http_open", "return response")]
@@ -1042,7 +1116,7 @@ class HandlerTests(unittest.TestCase):
def test_proxy_no_proxy(self):
os.environ['no_proxy'] = 'python.org'
o = OpenerDirector()
- ph = urllib2.ProxyHandler(dict(http="proxy.example.com"))
+ ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
o.add_handler(ph)
req = Request("http://www.perl.org/")
self.assertEqual(req.get_host(), "www.perl.org")
@@ -1054,15 +1128,27 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(req.get_host(), "www.python.org")
del os.environ['no_proxy']
+ def test_proxy_no_proxy_all(self):
+ os.environ['no_proxy'] = '*'
+ o = OpenerDirector()
+ ph = urllib.request.ProxyHandler(dict(http="proxy.example.com"))
+ o.add_handler(ph)
+ req = Request("http://www.python.org")
+ self.assertEqual(req.get_host(), "www.python.org")
+ r = o.open(req)
+ self.assertEqual(req.get_host(), "www.python.org")
+ del os.environ['no_proxy']
+
def test_proxy_https(self):
o = OpenerDirector()
- ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128'))
+ ph = urllib.request.ProxyHandler(dict(https="proxy.example.com:3128"))
o.add_handler(ph)
meth_spec = [
- [("https_open","return response")]
+ [("https_open", "return response")]
]
handlers = add_ordered_mock_handlers(o, meth_spec)
+
req = Request("https://www.example.com/")
self.assertEqual(req.get_host(), "www.example.com")
r = o.open(req)
@@ -1072,7 +1158,7 @@ class HandlerTests(unittest.TestCase):
def test_proxy_https_proxy_authorization(self):
o = OpenerDirector()
- ph = urllib2.ProxyHandler(dict(https='proxy.example.com:3128'))
+ ph = urllib.request.ProxyHandler(dict(https='proxy.example.com:3128'))
o.add_handler(ph)
https_handler = MockHTTPSHandler()
o.add_handler(https_handler)
@@ -1093,10 +1179,30 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(req.get_host(), "proxy.example.com:3128")
self.assertEqual(req.get_header("Proxy-authorization"),"FooBar")
+ def test_osx_proxy_bypass(self):
+ bypass = {
+ 'exclude_simple': False,
+ 'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.10',
+ '10.0/16']
+ }
+ # Check hosts that should trigger the proxy bypass
+ for host in ('foo.bar', 'www.bar.com', '127.0.0.1', '10.10.0.1',
+ '10.0.0.1'):
+ self.assertTrue(_proxy_bypass_macosx_sysconf(host, bypass),
+ 'expected bypass of %s to be True' % host)
+ # Check hosts that should not trigger the proxy bypass
+ for host in ('abc.foo.bar', 'bar.com', '127.0.0.2', '10.11.0.1', 'test'):
+ self.assertFalse(_proxy_bypass_macosx_sysconf(host, bypass),
+ 'expected bypass of %s to be False' % host)
+
+ # Check the exclude_simple flag
+ bypass = {'exclude_simple': True, 'exceptions': []}
+ self.assertTrue(_proxy_bypass_macosx_sysconf('test', bypass))
+
def test_basic_auth(self, quote_char='"'):
opener = OpenerDirector()
password_manager = MockPasswordManager()
- auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
+ auth_handler = urllib.request.HTTPBasicAuthHandler(password_manager)
realm = "ACME Widget Store"
http_handler = MockHTTPHandler(
401, 'WWW-Authenticate: Basic realm=%s%s%s\r\n\r\n' %
@@ -1106,8 +1212,8 @@ class HandlerTests(unittest.TestCase):
self._test_basic_auth(opener, auth_handler, "Authorization",
realm, http_handler, password_manager,
"http://acme.example.com/protected",
- "http://acme.example.com/protected"
- )
+ "http://acme.example.com/protected",
+ )
def test_basic_auth_with_single_quoted_realm(self):
self.test_basic_auth(quote_char="'")
@@ -1115,27 +1221,25 @@ class HandlerTests(unittest.TestCase):
def test_basic_auth_with_unquoted_realm(self):
opener = OpenerDirector()
password_manager = MockPasswordManager()
- auth_handler = urllib2.HTTPBasicAuthHandler(password_manager)
+ auth_handler = urllib.request.HTTPBasicAuthHandler(password_manager)
realm = "ACME Widget Store"
http_handler = MockHTTPHandler(
401, 'WWW-Authenticate: Basic realm=%s\r\n\r\n' % realm)
opener.add_handler(auth_handler)
opener.add_handler(http_handler)
- msg = "Basic Auth Realm was unquoted"
- with test_support.check_warnings((msg, UserWarning)):
+ with self.assertWarns(UserWarning):
self._test_basic_auth(opener, auth_handler, "Authorization",
- realm, http_handler, password_manager,
- "http://acme.example.com/protected",
- "http://acme.example.com/protected"
- )
-
+ realm, http_handler, password_manager,
+ "http://acme.example.com/protected",
+ "http://acme.example.com/protected",
+ )
def test_proxy_basic_auth(self):
opener = OpenerDirector()
- ph = urllib2.ProxyHandler(dict(http="proxy.example.com:3128"))
+ ph = urllib.request.ProxyHandler(dict(http="proxy.example.com:3128"))
opener.add_handler(ph)
password_manager = MockPasswordManager()
- auth_handler = urllib2.ProxyBasicAuthHandler(password_manager)
+ auth_handler = urllib.request.ProxyBasicAuthHandler(password_manager)
realm = "ACME Networks"
http_handler = MockHTTPHandler(
407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm)
@@ -1162,15 +1266,15 @@ class HandlerTests(unittest.TestCase):
self.recorded = []
def record(self, info):
self.recorded.append(info)
- class TestDigestAuthHandler(urllib2.HTTPDigestAuthHandler):
+ class TestDigestAuthHandler(urllib.request.HTTPDigestAuthHandler):
def http_error_401(self, *args, **kwds):
self.parent.record("digest")
- urllib2.HTTPDigestAuthHandler.http_error_401(self,
+ urllib.request.HTTPDigestAuthHandler.http_error_401(self,
*args, **kwds)
- class TestBasicAuthHandler(urllib2.HTTPBasicAuthHandler):
+ class TestBasicAuthHandler(urllib.request.HTTPBasicAuthHandler):
def http_error_401(self, *args, **kwds):
self.parent.record("basic")
- urllib2.HTTPBasicAuthHandler.http_error_401(self,
+ urllib.request.HTTPBasicAuthHandler.http_error_401(self,
*args, **kwds)
opener = RecordingOpenerDirector()
@@ -1216,8 +1320,9 @@ class HandlerTests(unittest.TestCase):
# expect one request without authorization, then one with
self.assertEqual(len(http_handler.requests), 2)
self.assertFalse(http_handler.requests[0].has_header(auth_header))
- userpass = '%s:%s' % (user, password)
- auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip()
+ userpass = bytes('%s:%s' % (user, password), "ascii")
+ auth_hdr_value = ('Basic ' +
+ base64.encodebytes(userpass).strip().decode())
self.assertEqual(http_handler.requests[1].get_header(auth_header),
auth_hdr_value)
self.assertEqual(http_handler.requests[1].unredirected_hdrs[auth_header],
@@ -1233,13 +1338,13 @@ class HandlerTests(unittest.TestCase):
class MiscTests(unittest.TestCase):
def test_build_opener(self):
- class MyHTTPHandler(urllib2.HTTPHandler): pass
- class FooHandler(urllib2.BaseHandler):
+ class MyHTTPHandler(urllib.request.HTTPHandler): pass
+ class FooHandler(urllib.request.BaseHandler):
def foo_open(self): pass
- class BarHandler(urllib2.BaseHandler):
+ class BarHandler(urllib.request.BaseHandler):
def bar_open(self): pass
- build_opener = urllib2.build_opener
+ build_opener = urllib.request.build_opener
o = build_opener(FooHandler, BarHandler)
self.opener_has_handler(o, FooHandler)
@@ -1257,39 +1362,36 @@ class MiscTests(unittest.TestCase):
# a particular case of overriding: default handlers can be passed
# in explicitly
o = build_opener()
- self.opener_has_handler(o, urllib2.HTTPHandler)
- o = build_opener(urllib2.HTTPHandler)
- self.opener_has_handler(o, urllib2.HTTPHandler)
- o = build_opener(urllib2.HTTPHandler())
- self.opener_has_handler(o, urllib2.HTTPHandler)
+ self.opener_has_handler(o, urllib.request.HTTPHandler)
+ o = build_opener(urllib.request.HTTPHandler)
+ self.opener_has_handler(o, urllib.request.HTTPHandler)
+ o = build_opener(urllib.request.HTTPHandler())
+ self.opener_has_handler(o, urllib.request.HTTPHandler)
# Issue2670: multiple handlers sharing the same base class
- class MyOtherHTTPHandler(urllib2.HTTPHandler): pass
+ class MyOtherHTTPHandler(urllib.request.HTTPHandler): pass
o = build_opener(MyHTTPHandler, MyOtherHTTPHandler)
self.opener_has_handler(o, MyHTTPHandler)
self.opener_has_handler(o, MyOtherHTTPHandler)
def opener_has_handler(self, opener, handler_class):
- for h in opener.handlers:
- if h.__class__ == handler_class:
- break
- else:
- self.assertTrue(False)
+ self.assertTrue(any(h.__class__ == handler_class
+ for h in opener.handlers))
class RequestTests(unittest.TestCase):
def setUp(self):
- self.get = urllib2.Request("http://www.python.org/~jeremy/")
- self.post = urllib2.Request("http://www.python.org/~jeremy/",
- "data",
- headers={"X-Test": "test"})
+ self.get = Request("http://www.python.org/~jeremy/")
+ self.post = Request("http://www.python.org/~jeremy/",
+ "data",
+ headers={"X-Test": "test"})
def test_method(self):
self.assertEqual("POST", self.post.get_method())
self.assertEqual("GET", self.get.get_method())
def test_add_data(self):
- self.assertTrue(not self.get.has_data())
+ self.assertFalse(self.get.has_data())
self.assertEqual("GET", self.get.get_method())
self.get.add_data("spam")
self.assertTrue(self.get.has_data())
@@ -1301,7 +1403,7 @@ class RequestTests(unittest.TestCase):
def test_selector(self):
self.assertEqual("/~jeremy/", self.get.get_selector())
- req = urllib2.Request("http://www.python.org/")
+ req = Request("http://www.python.org/")
self.assertEqual("/", req.get_selector())
def test_get_type(self):
@@ -1311,11 +1413,11 @@ class RequestTests(unittest.TestCase):
self.assertEqual("www.python.org", self.get.get_host())
def test_get_host_unquote(self):
- req = urllib2.Request("http://www.%70ython.org/")
+ req = Request("http://www.%70ython.org/")
self.assertEqual("www.python.org", req.get_host())
def test_proxy(self):
- self.assertTrue(not self.get.has_proxy())
+ self.assertFalse(self.get.has_proxy())
self.get.set_proxy("www.perl.org", "http")
self.assertTrue(self.get.has_proxy())
self.assertEqual("www.python.org", self.get.get_origin_req_host())
@@ -1341,7 +1443,7 @@ class RequestTests(unittest.TestCase):
Issue 13211 reveals that HTTPError didn't implement the URLError
interface even though HTTPError is a subclass of URLError.
- >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
+ >>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
>>> assert hasattr(err, 'reason')
>>> err.reason
'something bad happened'
@@ -1349,9 +1451,9 @@ class RequestTests(unittest.TestCase):
def test_HTTPError_interface_call(self):
"""
- Issue 15701= - HTTPError interface has info method available from URLError.
+ Issue 15701 - HTTPError interface has info method available from URLError
"""
- err = urllib2.HTTPError(msg='something bad happened', url=None,
+ err = urllib.request.HTTPError(msg="something bad happened", url=None,
code=None, hdrs='Content-Length:42', fp=None)
self.assertTrue(hasattr(err, 'reason'))
assert hasattr(err, 'reason')
@@ -1360,19 +1462,19 @@ class RequestTests(unittest.TestCase):
try:
err.info()
except AttributeError:
- self.fail("err.info() failed")
+ self.fail('err.info call failed.')
self.assertEqual(err.info(), "Content-Length:42")
def test_main(verbose=None):
from test import test_urllib2
- test_support.run_doctest(test_urllib2, verbose)
- test_support.run_doctest(urllib2, verbose)
+ support.run_doctest(test_urllib2, verbose)
+ support.run_doctest(urllib.request, verbose)
tests = (TrivialTests,
OpenerDirectorTests,
HandlerTests,
MiscTests,
RequestTests)
- test_support.run_unittest(*tests)
+ support.run_unittest(*tests)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index ec3437597d8..f07471dd0ef 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -1,34 +1,40 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
-import urlparse
-import urllib2
-import BaseHTTPServer
+import os
+import email
+import urllib.parse
+import urllib.request
+import http.server
import unittest
import hashlib
+from test import support
+threading = support.import_module('threading')
-from test import test_support
-mimetools = test_support.import_module('mimetools', deprecated=True)
-threading = test_support.import_module('threading')
+here = os.path.dirname(__file__)
+# Self-signed cert file for 'localhost'
+CERT_localhost = os.path.join(here, 'keycert.pem')
+# Self-signed cert file for 'fakehostname'
+CERT_fakehostname = os.path.join(here, 'keycert2.pem')
# Loopback http server infrastructure
-class LoopbackHttpServer(BaseHTTPServer.HTTPServer):
+class LoopbackHttpServer(http.server.HTTPServer):
"""HTTP server w/ a few modifications that make it useful for
loopback testing purposes.
"""
def __init__(self, server_address, RequestHandlerClass):
- BaseHTTPServer.HTTPServer.__init__(self,
- server_address,
- RequestHandlerClass)
+ http.server.HTTPServer.__init__(self,
+ server_address,
+ RequestHandlerClass)
# Set the timeout of our listening socket really low so
# that we can stop the server easily.
- self.socket.settimeout(1.0)
+ self.socket.settimeout(0.1)
def get_request(self):
- """BaseHTTPServer method, overridden."""
+ """HTTPServer method, overridden."""
request, client_address = self.socket.accept()
@@ -44,10 +50,10 @@ class LoopbackHttpServerThread(threading.Thread):
def __init__(self, request_handler):
threading.Thread.__init__(self)
- self._stop = False
+ self._stop_server = False
self.ready = threading.Event()
request_handler.protocol_version = "HTTP/1.0"
- self.httpd = LoopbackHttpServer(('127.0.0.1', 0),
+ self.httpd = LoopbackHttpServer(("127.0.0.1", 0),
request_handler)
#print "Serving HTTP on %s port %s" % (self.httpd.server_name,
# self.httpd.server_port)
@@ -57,13 +63,14 @@ class LoopbackHttpServerThread(threading.Thread):
"""Stops the webserver if it's currently running."""
# Set the stop flag.
- self._stop = True
+ self._stop_server = True
self.join()
+ self.httpd.server_close()
def run(self):
self.ready.set()
- while not self._stop:
+ while not self._stop_server:
self.httpd.handle_request()
# Authentication infrastructure
@@ -90,7 +97,7 @@ class DigestAuthHandler:
def _generate_nonce(self):
self._request_num += 1
- nonce = hashlib.md5(str(self._request_num)).hexdigest()
+ nonce = hashlib.md5(str(self._request_num).encode("ascii")).hexdigest()
self._nonces.append(nonce)
return nonce
@@ -118,14 +125,14 @@ class DigestAuthHandler:
final_dict["method"] = method
final_dict["uri"] = uri
HA1_str = "%(username)s:%(realm)s:%(password)s" % final_dict
- HA1 = hashlib.md5(HA1_str).hexdigest()
+ HA1 = hashlib.md5(HA1_str.encode("ascii")).hexdigest()
HA2_str = "%(method)s:%(uri)s" % final_dict
- HA2 = hashlib.md5(HA2_str).hexdigest()
+ HA2 = hashlib.md5(HA2_str.encode("ascii")).hexdigest()
final_dict["HA1"] = HA1
final_dict["HA2"] = HA2
response_str = "%(HA1)s:%(nonce)s:%(nc)s:" \
"%(cnonce)s:%(qop)s:%(HA2)s" % final_dict
- response = hashlib.md5(response_str).hexdigest()
+ response = hashlib.md5(response_str.encode("ascii")).hexdigest()
return response == auth_dict["response"]
@@ -141,7 +148,7 @@ class DigestAuthHandler:
# not.
#request_handler.send_header('Connection', 'close')
request_handler.end_headers()
- request_handler.wfile.write("Proxy Authentication Required.")
+ request_handler.wfile.write(b"Proxy Authentication Required.")
return False
def handle_request(self, request_handler):
@@ -156,11 +163,11 @@ class DigestAuthHandler:
if len(self._users) == 0:
return True
- if 'Proxy-Authorization' not in request_handler.headers:
+ if "Proxy-Authorization" not in request_handler.headers:
return self._return_auth_challenge(request_handler)
else:
auth_dict = self._create_auth_dict(
- request_handler.headers['Proxy-Authorization']
+ request_handler.headers["Proxy-Authorization"]
)
if auth_dict["username"] in self._users:
password = self._users[ auth_dict["username"] ]
@@ -174,7 +181,7 @@ class DigestAuthHandler:
auth_validated = False
# MSIE uses short_path in its validation, but Python's
- # urllib2 uses the full path, so we're going to see if
+ # urllib.request uses the full path, so we're going to see if
# either of them works here.
for path in [request_handler.path, request_handler.short_path]:
@@ -190,7 +197,7 @@ class DigestAuthHandler:
# Proxy test infrastructure
-class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+class FakeProxyHandler(http.server.BaseHTTPRequestHandler):
"""This is a 'fake proxy' that makes it look like the entire
internet has gone down due to a sudden zombie invasion. It main
utility is in providing us with authentication support for
@@ -201,36 +208,29 @@ class FakeProxyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
# This has to be set before calling our parent's __init__(), which will
# try to call do_GET().
self.digest_auth_handler = digest_auth_handler
- BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
+ http.server.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
def log_message(self, format, *args):
# Uncomment the next line for debugging.
- #sys.stderr.write(format % args)
+ # sys.stderr.write(format % args)
pass
def do_GET(self):
- (scm, netloc, path, params, query, fragment) = urlparse.urlparse(
- self.path, 'http')
+ (scm, netloc, path, params, query, fragment) = urllib.parse.urlparse(
+ self.path, "http")
self.short_path = path
if self.digest_auth_handler.handle_request(self):
self.send_response(200, "OK")
self.send_header("Content-Type", "text/html")
self.end_headers()
- self.wfile.write("You've reached %s!<BR>" % self.path)
- self.wfile.write("Our apologies, but our server is down due to "
- "a sudden zombie invasion.")
+ self.wfile.write(bytes("You've reached %s!<BR>" % self.path,
+ "ascii"))
+ self.wfile.write(b"Our apologies, but our server is down due to "
+ b"a sudden zombie invasion.")
# Test cases
-class BaseTestCase(unittest.TestCase):
- def setUp(self):
- self._threads = test_support.threading_setup()
-
- def tearDown(self):
- test_support.threading_cleanup(*self._threads)
-
-
-class ProxyAuthTests(BaseTestCase):
+class ProxyAuthTests(unittest.TestCase):
URL = "http://localhost"
USER = "tester"
@@ -249,9 +249,10 @@ class ProxyAuthTests(BaseTestCase):
self.server.start()
self.server.ready.wait()
proxy_url = "http://127.0.0.1:%d" % self.server.port
- handler = urllib2.ProxyHandler({"http" : proxy_url})
- self.proxy_digest_handler = urllib2.ProxyDigestAuthHandler()
- self.opener = urllib2.build_opener(handler, self.proxy_digest_handler)
+ handler = urllib.request.ProxyHandler({"http" : proxy_url})
+ self.proxy_digest_handler = urllib.request.ProxyDigestAuthHandler()
+ self.opener = urllib.request.build_opener(
+ handler, self.proxy_digest_handler)
def tearDown(self):
self.server.stop()
@@ -261,13 +262,13 @@ class ProxyAuthTests(BaseTestCase):
self.proxy_digest_handler.add_password(self.REALM, self.URL,
self.USER, self.PASSWD+"bad")
self.digest_auth_handler.set_qop("auth")
- self.assertRaises(urllib2.HTTPError,
+ self.assertRaises(urllib.error.HTTPError,
self.opener.open,
self.URL)
def test_proxy_with_no_password_raises_httperror(self):
self.digest_auth_handler.set_qop("auth")
- self.assertRaises(urllib2.HTTPError,
+ self.assertRaises(urllib.error.HTTPError,
self.opener.open,
self.URL)
@@ -286,7 +287,7 @@ class ProxyAuthTests(BaseTestCase):
self.digest_auth_handler.set_qop("auth-int")
try:
result = self.opener.open(self.URL)
- except urllib2.URLError:
+ except urllib.error.URLError:
# It's okay if we don't support auth-int, but we certainly
# shouldn't receive any kind of exception here other than
# a URLError.
@@ -299,7 +300,7 @@ class ProxyAuthTests(BaseTestCase):
def GetRequestHandler(responses):
- class FakeHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+ class FakeHTTPRequestHandler(http.server.BaseHTTPRequestHandler):
server_version = "TestHTTP/"
requests = []
@@ -308,11 +309,12 @@ def GetRequestHandler(responses):
def do_GET(self):
body = self.send_head()
- if body:
- self.wfile.write(body)
+ while body:
+ done = self.wfile.write(body)
+ body = body[done:]
def do_POST(self):
- content_length = self.headers['Content-Length']
+ content_length = self.headers["Content-Length"]
post_data = self.rfile.read(int(content_length))
self.do_GET()
self.requests.append(post_data)
@@ -325,9 +327,9 @@ def GetRequestHandler(responses):
self.send_response(response_code)
for (header, value) in headers:
- self.send_header(header, value % self.port)
+ self.send_header(header, value % {'port':self.port})
if body:
- self.send_header('Content-type', 'text/plain')
+ self.send_header("Content-type", "text/plain")
self.end_headers()
return body
self.end_headers()
@@ -339,8 +341,8 @@ def GetRequestHandler(responses):
return FakeHTTPRequestHandler
-class TestUrlopen(BaseTestCase):
- """Tests urllib2.urlopen using the network.
+class TestUrlopen(unittest.TestCase):
+ """Tests urllib.request.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no
@@ -349,12 +351,32 @@ class TestUrlopen(BaseTestCase):
"""
def setUp(self):
- proxy_handler = urllib2.ProxyHandler({})
- opener = urllib2.build_opener(proxy_handler)
- urllib2.install_opener(opener)
super(TestUrlopen, self).setUp()
+ # Ignore proxies for localhost tests.
+ os.environ['NO_PROXY'] = '*'
+ self.server = None
+
+ def tearDown(self):
+ if self.server is not None:
+ self.server.stop()
+ super(TestUrlopen, self).tearDown()
- def start_server(self, responses):
+ def urlopen(self, url, data=None, **kwargs):
+ l = []
+ f = urllib.request.urlopen(url, data, **kwargs)
+ try:
+ # Exercise various methods
+ l.extend(f.readlines(200))
+ l.append(f.readline())
+ l.append(f.read(1024))
+ l.append(f.read())
+ finally:
+ f.close()
+ return b"".join(l)
+
+ def start_server(self, responses=None):
+ if responses is None:
+ responses = [(200, [], b"we don't care")]
handler = GetRequestHandler(responses)
self.server = LoopbackHttpServerThread(handler)
@@ -364,127 +386,133 @@ class TestUrlopen(BaseTestCase):
handler.port = port
return handler
+ def start_https_server(self, responses=None, certfile=CERT_localhost):
+ if not hasattr(urllib.request, 'HTTPSHandler'):
+ self.skipTest('ssl support required')
+ from test.ssl_servers import make_https_server
+ if responses is None:
+ responses = [(200, [], b"we care a bit")]
+ handler = GetRequestHandler(responses)
+ server = make_https_server(self, certfile=certfile, handler_class=handler)
+ handler.port = server.port
+ return handler
def test_redirection(self):
- expected_response = 'We got here...'
+ expected_response = b"We got here..."
responses = [
- (302, [('Location', 'http://localhost:%s/somewhere_else')], ''),
+ (302, [("Location", "http://localhost:%(port)s/somewhere_else")],
+ ""),
(200, [], expected_response)
]
handler = self.start_server(responses)
-
- try:
- f = urllib2.urlopen('http://localhost:%s/' % handler.port)
- data = f.read()
- f.close()
-
- self.assertEqual(data, expected_response)
- self.assertEqual(handler.requests, ['/', '/somewhere_else'])
- finally:
- self.server.stop()
-
+ data = self.urlopen("http://localhost:%s/" % handler.port)
+ self.assertEqual(data, expected_response)
+ self.assertEqual(handler.requests, ["/", "/somewhere_else"])
+
+ def test_chunked(self):
+ expected_response = b"hello world"
+ chunked_start = (
+ b'a\r\n'
+ b'hello worl\r\n'
+ b'1\r\n'
+ b'd\r\n'
+ b'0\r\n'
+ )
+ response = [(200, [("Transfer-Encoding", "chunked")], chunked_start)]
+ handler = self.start_server(response)
+ data = self.urlopen("http://localhost:%s/" % handler.port)
+ self.assertEqual(data, expected_response)
def test_404(self):
- expected_response = 'Bad bad bad...'
+ expected_response = b"Bad bad bad..."
handler = self.start_server([(404, [], expected_response)])
try:
- try:
- urllib2.urlopen('http://localhost:%s/weeble' % handler.port)
- except urllib2.URLError, f:
- pass
- else:
- self.fail('404 should raise URLError')
-
+ self.urlopen("http://localhost:%s/weeble" % handler.port)
+ except urllib.error.URLError as f:
data = f.read()
f.close()
+ else:
+ self.fail("404 should raise URLError")
- self.assertEqual(data, expected_response)
- self.assertEqual(handler.requests, ['/weeble'])
- finally:
- self.server.stop()
-
+ self.assertEqual(data, expected_response)
+ self.assertEqual(handler.requests, ["/weeble"])
def test_200(self):
- expected_response = 'pycon 2008...'
+ expected_response = b"pycon 2008..."
handler = self.start_server([(200, [], expected_response)])
-
- try:
- f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port)
- data = f.read()
- f.close()
-
- self.assertEqual(data, expected_response)
- self.assertEqual(handler.requests, ['/bizarre'])
- finally:
- self.server.stop()
+ data = self.urlopen("http://localhost:%s/bizarre" % handler.port)
+ self.assertEqual(data, expected_response)
+ self.assertEqual(handler.requests, ["/bizarre"])
def test_200_with_parameters(self):
- expected_response = 'pycon 2008...'
+ expected_response = b"pycon 2008..."
handler = self.start_server([(200, [], expected_response)])
-
- try:
- f = urllib2.urlopen('http://localhost:%s/bizarre' % handler.port, 'get=with_feeling')
- data = f.read()
- f.close()
-
- self.assertEqual(data, expected_response)
- self.assertEqual(handler.requests, ['/bizarre', 'get=with_feeling'])
- finally:
- self.server.stop()
-
+ data = self.urlopen("http://localhost:%s/bizarre" % handler.port,
+ b"get=with_feeling")
+ self.assertEqual(data, expected_response)
+ self.assertEqual(handler.requests, ["/bizarre", b"get=with_feeling"])
+
+ def test_https(self):
+ handler = self.start_https_server()
+ data = self.urlopen("https://localhost:%s/bizarre" % handler.port)
+ self.assertEqual(data, b"we care a bit")
+
+ def test_https_with_cafile(self):
+ handler = self.start_https_server(certfile=CERT_localhost)
+ import ssl
+ # Good cert
+ data = self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_localhost)
+ self.assertEqual(data, b"we care a bit")
+ # Bad cert
+ with self.assertRaises(urllib.error.URLError) as cm:
+ self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_fakehostname)
+ # Good cert, but mismatching hostname
+ handler = self.start_https_server(certfile=CERT_fakehostname)
+ with self.assertRaises(ssl.CertificateError) as cm:
+ self.urlopen("https://localhost:%s/bizarre" % handler.port,
+ cafile=CERT_fakehostname)
def test_sending_headers(self):
- handler = self.start_server([(200, [], "we don't care")])
-
- try:
- req = urllib2.Request("http://localhost:%s/" % handler.port,
- headers={'Range': 'bytes=20-39'})
- urllib2.urlopen(req)
- self.assertEqual(handler.headers_received['Range'], 'bytes=20-39')
- finally:
- self.server.stop()
+ handler = self.start_server()
+ req = urllib.request.Request("http://localhost:%s/" % handler.port,
+ headers={"Range": "bytes=20-39"})
+ urllib.request.urlopen(req)
+ self.assertEqual(handler.headers_received["Range"], "bytes=20-39")
def test_basic(self):
- handler = self.start_server([(200, [], "we don't care")])
-
+ handler = self.start_server()
+ open_url = urllib.request.urlopen("http://localhost:%s" % handler.port)
+ for attr in ("read", "close", "info", "geturl"):
+ self.assertTrue(hasattr(open_url, attr), "object returned from "
+ "urlopen lacks the %s attribute" % attr)
try:
- open_url = urllib2.urlopen("http://localhost:%s" % handler.port)
- for attr in ("read", "close", "info", "geturl"):
- self.assertTrue(hasattr(open_url, attr), "object returned from "
- "urlopen lacks the %s attribute" % attr)
- try:
- self.assertTrue(open_url.read(), "calling 'read' failed")
- finally:
- open_url.close()
+ self.assertTrue(open_url.read(), "calling 'read' failed")
finally:
- self.server.stop()
+ open_url.close()
def test_info(self):
- handler = self.start_server([(200, [], "we don't care")])
-
+ handler = self.start_server()
try:
- open_url = urllib2.urlopen("http://localhost:%s" % handler.port)
+ open_url = urllib.request.urlopen(
+ "http://localhost:%s" % handler.port)
info_obj = open_url.info()
- self.assertIsInstance(info_obj, mimetools.Message,
+ self.assertIsInstance(info_obj, email.message.Message,
"object returned by 'info' is not an "
- "instance of mimetools.Message")
- self.assertEqual(info_obj.getsubtype(), "plain")
+ "instance of email.message.Message")
+ self.assertEqual(info_obj.get_content_subtype(), "plain")
finally:
self.server.stop()
def test_geturl(self):
# Make sure same URL as opened is returned by geturl.
- handler = self.start_server([(200, [], "we don't care")])
-
- try:
- open_url = urllib2.urlopen("http://localhost:%s" % handler.port)
- url = open_url.geturl()
- self.assertEqual(url, "http://localhost:%s" % handler.port)
- finally:
- self.server.stop()
-
+ handler = self.start_server()
+ open_url = urllib.request.urlopen("http://localhost:%s" % handler.port)
+ url = open_url.geturl()
+ self.assertEqual(url, "http://localhost:%s" % handler.port)
def test_bad_address(self):
# Make sure proper exception is raised when connecting to a bogus
@@ -507,41 +535,32 @@ class TestUrlopen(BaseTestCase):
# failing if the ISP hijacks all invalid domain
# requests. The real solution would be to be able to
# parameterize the framework with a mock resolver.
- urllib2.urlopen, "http://sadflkjsasf.i.nvali.d./")
+ urllib.request.urlopen,
+ "http://sadflkjsasf.i.nvali.d./")
def test_iteration(self):
- expected_response = "pycon 2008..."
+ expected_response = b"pycon 2008..."
handler = self.start_server([(200, [], expected_response)])
- try:
- data = urllib2.urlopen("http://localhost:%s" % handler.port)
- for line in data:
- self.assertEqual(line, expected_response)
- finally:
- self.server.stop()
+ data = urllib.request.urlopen("http://localhost:%s" % handler.port)
+ for line in data:
+ self.assertEqual(line, expected_response)
- def ztest_line_iteration(self):
- lines = ["We\n", "got\n", "here\n", "verylong " * 8192 + "\n"]
- expected_response = "".join(lines)
+ def test_line_iteration(self):
+ lines = [b"We\n", b"got\n", b"here\n", b"verylong " * 8192 + b"\n"]
+ expected_response = b"".join(lines)
handler = self.start_server([(200, [], expected_response)])
- try:
- data = urllib2.urlopen("http://localhost:%s" % handler.port)
- for index, line in enumerate(data):
- self.assertEqual(line, lines[index],
- "Fetched line number %s doesn't match expected:\n"
- " Expected length was %s, got %s" %
- (index, len(lines[index]), len(line)))
- finally:
- self.server.stop()
+ data = urllib.request.urlopen("http://localhost:%s" % handler.port)
+ for index, line in enumerate(data):
+ self.assertEqual(line, lines[index],
+ "Fetched line number %s doesn't match expected:\n"
+ " Expected length was %s, got %s" %
+ (index, len(lines[index]), len(line)))
self.assertEqual(index + 1, len(lines))
-def test_main():
- # We will NOT depend on the network resource flag
- # (Lib/test/regrtest.py -u network) since all tests here are only
- # localhost. However, if this is a bad rationale, then uncomment
- # the next line.
- #test_support.requires("network")
- test_support.run_unittest(ProxyAuthTests, TestUrlopen)
+@support.reap_threads
+def test_main():
+ support.run_unittest(ProxyAuthTests, TestUrlopen)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_urllib2net.py b/Lib/test/test_urllib2net.py
index 4d73ac0acf9..e2b1d95c045 100644
--- a/Lib/test/test_urllib2net.py
+++ b/Lib/test/test_urllib2net.py
@@ -1,13 +1,18 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
-from test import test_support
+from test import support
from test.test_urllib2 import sanepathname2url
-import socket
-import urllib2
import os
+import socket
+import urllib.error
+import urllib.request
import sys
+try:
+ import ssl
+except ImportError:
+ ssl = None
TIMEOUT = 60 # seconds
@@ -16,7 +21,8 @@ def _retry_thrice(func, exc, *args, **kwargs):
for i in range(3):
try:
return func(*args, **kwargs)
- except exc, last_exc:
+ except exc as e:
+ last_exc = e
continue
except:
raise
@@ -29,7 +35,8 @@ def _wrap_with_retry_thrice(func, exc):
# Connecting to remote hosts is flaky. Make it more robust by retrying
# the connection several times.
-_urlopen_with_retry = _wrap_with_retry_thrice(urllib2.urlopen, urllib2.URLError)
+_urlopen_with_retry = _wrap_with_retry_thrice(urllib.request.urlopen,
+ urllib.error.URLError)
class AuthTests(unittest.TestCase):
@@ -39,7 +46,7 @@ class AuthTests(unittest.TestCase):
## could be used to HTTP authentication.
#
# def test_basic_auth(self):
-# import httplib
+# import http.client
#
# test_url = "http://www.python.org/test/test_urllib2/basic_auth"
# test_hostport = "www.python.org"
@@ -67,30 +74,21 @@ class AuthTests(unittest.TestCase):
# # reasons, let's not implement it! (it's already implemented for proxy
# # specification strings (that is, URLs or authorities specifying a
# # proxy), so we must keep that)
-# self.assertRaises(httplib.InvalidURL,
+# self.assertRaises(http.client.InvalidURL,
# urllib2.urlopen, "http://evil:thing@example.com")
class CloseSocketTest(unittest.TestCase):
def test_close(self):
- import httplib
-
# calling .close() on urllib2's response objects should close the
# underlying socket
- # delve deep into response to fetch socket._socketobject
response = _urlopen_with_retry("http://www.python.org/")
- abused_fileobject = response.fp
- self.assertTrue(abused_fileobject.__class__ is socket._fileobject)
- httpresponse = abused_fileobject._sock
- self.assertTrue(httpresponse.__class__ is httplib.HTTPResponse)
- fileobject = httpresponse.fp
- self.assertTrue(fileobject.__class__ is socket._fileobject)
-
- self.assertTrue(not fileobject.closed)
+ sock = response.fp
+ self.assertTrue(not sock.closed)
response.close()
- self.assertTrue(fileobject.closed)
+ self.assertTrue(sock.closed)
class OtherNetworkTests(unittest.TestCase):
def setUp(self):
@@ -113,20 +111,21 @@ class OtherNetworkTests(unittest.TestCase):
self._test_urls(urls, self._extra_handlers())
def test_file(self):
- TESTFN = test_support.TESTFN
+ TESTFN = support.TESTFN
f = open(TESTFN, 'w')
try:
f.write('hi there\n')
f.close()
urls = [
- 'file:'+sanepathname2url(os.path.abspath(TESTFN)),
- ('file:///nonsensename/etc/passwd', None, urllib2.URLError),
+ 'file:' + sanepathname2url(os.path.abspath(TESTFN)),
+ ('file:///nonsensename/etc/passwd', None,
+ urllib.error.URLError),
]
self._test_urls(urls, self._extra_handlers(), retry=True)
finally:
os.remove(TESTFN)
- self.assertRaises(ValueError, urllib2.urlopen,'./relative_path/to/file')
+ self.assertRaises(ValueError, urllib.request.urlopen,'./relative_path/to/file')
# XXX Following test depends on machine configurations that are internal
# to CNRI. Need to set up a public server with the right authentication
@@ -158,28 +157,17 @@ class OtherNetworkTests(unittest.TestCase):
def test_urlwithfrag(self):
urlwith_frag = "http://docs.python.org/2/glossary.html#glossary"
- with test_support.transient_internet(urlwith_frag):
- req = urllib2.Request(urlwith_frag)
- res = urllib2.urlopen(req)
+ with support.transient_internet(urlwith_frag):
+ req = urllib.request.Request(urlwith_frag)
+ res = urllib.request.urlopen(req)
self.assertEqual(res.geturl(),
"http://docs.python.org/2/glossary.html#glossary")
- def test_fileno(self):
- req = urllib2.Request("http://www.python.org")
- opener = urllib2.build_opener()
- res = opener.open(req)
- try:
- res.fileno()
- except AttributeError:
- self.fail("HTTPResponse object should return a valid fileno")
- finally:
- res.close()
-
def test_custom_headers(self):
url = "http://www.example.com"
- with test_support.transient_internet(url):
- opener = urllib2.build_opener()
- request = urllib2.Request(url)
+ with support.transient_internet(url):
+ opener = urllib.request.build_opener()
+ request = urllib.request.Request(url)
self.assertFalse(request.header_items())
opener.open(request)
self.assertTrue(request.header_items())
@@ -192,9 +180,19 @@ class OtherNetworkTests(unittest.TestCase):
# Some sites do not send Connection: close header.
# Verify that those work properly. (#issue12576)
- URL = 'http://www.imdb.com' # No Connection:close
- with test_support.transient_internet(URL):
- req = urllib2.urlopen(URL)
+ URL = 'http://www.imdb.com' # mangles Connection:close
+
+ with support.transient_internet(URL):
+ try:
+ with urllib.request.urlopen(URL) as res:
+ pass
+ except ValueError as e:
+ self.fail("urlopen failed for site not sending \
+ Connection:close")
+ else:
+ self.assertTrue(res)
+
+ req = urllib.request.urlopen(URL)
res = req.read()
self.assertTrue(res)
@@ -203,16 +201,17 @@ class OtherNetworkTests(unittest.TestCase):
import logging
debug = logging.getLogger("test_urllib2").debug
- urlopen = urllib2.build_opener(*handlers).open
+ urlopen = urllib.request.build_opener(*handlers).open
if retry:
- urlopen = _wrap_with_retry_thrice(urlopen, urllib2.URLError)
+ urlopen = _wrap_with_retry_thrice(urlopen, urllib.error.URLError)
for url in urls:
if isinstance(url, tuple):
url, req, expected_err = url
else:
req = expected_err = None
- with test_support.transient_internet(url):
+
+ with support.transient_internet(url):
debug(url)
try:
f = urlopen(url, req, TIMEOUT)
@@ -222,19 +221,21 @@ class OtherNetworkTests(unittest.TestCase):
msg = ("Didn't get expected error(s) %s for %s %s, got %s: %s" %
(expected_err, url, req, type(err), err))
self.assertIsInstance(err, expected_err, msg)
- except urllib2.URLError as err:
+ except urllib.error.URLError as err:
if isinstance(err[0], socket.timeout):
- print >>sys.stderr, "<timeout: %s>" % url
+ print("<timeout: %s>" % url, file=sys.stderr)
continue
else:
raise
else:
try:
- with test_support.transient_internet(url):
+ with support.time_out, \
+ support.socket_peer_reset, \
+ support.ioerror_peer_reset:
buf = f.read()
debug("read %d bytes" % len(buf))
except socket.timeout:
- print >>sys.stderr, "<timeout: %s>" % url
+ print("<timeout: %s>" % url, file=sys.stderr)
f.close()
debug("******** next url coming up...")
time.sleep(0.1)
@@ -242,7 +243,7 @@ class OtherNetworkTests(unittest.TestCase):
def _extra_handlers(self):
handlers = []
- cfh = urllib2.CacheFTPHandler()
+ cfh = urllib.request.CacheFTPHandler()
self.addCleanup(cfh.clear_cache)
cfh.setTimeout(1)
handlers.append(cfh)
@@ -254,79 +255,109 @@ class TimeoutTest(unittest.TestCase):
def test_http_basic(self):
self.assertTrue(socket.getdefaulttimeout() is None)
url = "http://www.python.org"
- with test_support.transient_internet(url, timeout=None):
+ with support.transient_internet(url, timeout=None):
u = _urlopen_with_retry(url)
- self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None)
+ self.addCleanup(u.close)
+ self.assertTrue(u.fp.raw._sock.gettimeout() is None)
def test_http_default_timeout(self):
self.assertTrue(socket.getdefaulttimeout() is None)
url = "http://www.python.org"
- with test_support.transient_internet(url):
+ with support.transient_internet(url):
socket.setdefaulttimeout(60)
try:
u = _urlopen_with_retry(url)
+ self.addCleanup(u.close)
finally:
socket.setdefaulttimeout(None)
- self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 60)
+ self.assertEqual(u.fp.raw._sock.gettimeout(), 60)
def test_http_no_timeout(self):
self.assertTrue(socket.getdefaulttimeout() is None)
url = "http://www.python.org"
- with test_support.transient_internet(url):
+ with support.transient_internet(url):
socket.setdefaulttimeout(60)
try:
u = _urlopen_with_retry(url, timeout=None)
+ self.addCleanup(u.close)
finally:
socket.setdefaulttimeout(None)
- self.assertTrue(u.fp._sock.fp._sock.gettimeout() is None)
+ self.assertTrue(u.fp.raw._sock.gettimeout() is None)
def test_http_timeout(self):
url = "http://www.python.org"
- with test_support.transient_internet(url):
+ with support.transient_internet(url):
u = _urlopen_with_retry(url, timeout=120)
- self.assertEqual(u.fp._sock.fp._sock.gettimeout(), 120)
+ self.addCleanup(u.close)
+ self.assertEqual(u.fp.raw._sock.gettimeout(), 120)
FTP_HOST = "ftp://ftp.mirror.nl/pub/gnu/"
def test_ftp_basic(self):
self.assertTrue(socket.getdefaulttimeout() is None)
- with test_support.transient_internet(self.FTP_HOST, timeout=None):
+ with support.transient_internet(self.FTP_HOST, timeout=None):
u = _urlopen_with_retry(self.FTP_HOST)
- self.assertTrue(u.fp.fp._sock.gettimeout() is None)
+ self.addCleanup(u.close)
+ self.assertTrue(u.fp.fp.raw._sock.gettimeout() is None)
def test_ftp_default_timeout(self):
self.assertTrue(socket.getdefaulttimeout() is None)
- with test_support.transient_internet(self.FTP_HOST):
+ with support.transient_internet(self.FTP_HOST):
socket.setdefaulttimeout(60)
try:
u = _urlopen_with_retry(self.FTP_HOST)
+ self.addCleanup(u.close)
finally:
socket.setdefaulttimeout(None)
- self.assertEqual(u.fp.fp._sock.gettimeout(), 60)
+ self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60)
def test_ftp_no_timeout(self):
self.assertTrue(socket.getdefaulttimeout() is None)
- with test_support.transient_internet(self.FTP_HOST):
+ with support.transient_internet(self.FTP_HOST):
socket.setdefaulttimeout(60)
try:
u = _urlopen_with_retry(self.FTP_HOST, timeout=None)
+ self.addCleanup(u.close)
finally:
socket.setdefaulttimeout(None)
- self.assertTrue(u.fp.fp._sock.gettimeout() is None)
+ self.assertTrue(u.fp.fp.raw._sock.gettimeout() is None)
def test_ftp_timeout(self):
- with test_support.transient_internet(self.FTP_HOST):
+ with support.transient_internet(self.FTP_HOST):
u = _urlopen_with_retry(self.FTP_HOST, timeout=60)
- self.assertEqual(u.fp.fp._sock.gettimeout(), 60)
+ self.addCleanup(u.close)
+ self.assertEqual(u.fp.fp.raw._sock.gettimeout(), 60)
+
+
+@unittest.skipUnless(ssl, "requires SSL support")
+class HTTPSTests(unittest.TestCase):
+
+ def test_sni(self):
+ self.skipTest("test disabled - test server needed")
+ # Checks that Server Name Indication works, if supported by the
+ # OpenSSL linked to.
+ # The ssl module itself doesn't have server-side support for SNI,
+ # so we rely on a third-party test site.
+ expect_sni = ssl.HAS_SNI
+ with support.transient_internet("XXX"):
+ u = urllib.request.urlopen("XXX")
+ contents = u.readall()
+ if expect_sni:
+ self.assertIn(b"Great", contents)
+ self.assertNotIn(b"Unfortunately", contents)
+ else:
+ self.assertNotIn(b"Great", contents)
+ self.assertIn(b"Unfortunately", contents)
def test_main():
- test_support.requires("network")
- test_support.run_unittest(AuthTests,
- OtherNetworkTests,
- CloseSocketTest,
- TimeoutTest,
- )
+ support.requires("network")
+ support.run_unittest(AuthTests,
+ HTTPSTests,
+ OtherNetworkTests,
+ CloseSocketTest,
+ TimeoutTest,
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_urllib_response.py b/Lib/test/test_urllib_response.py
new file mode 100644
index 00000000000..fdd33259dd3
--- /dev/null
+++ b/Lib/test/test_urllib_response.py
@@ -0,0 +1,42 @@
+"""Unit tests for code in urllib.response."""
+
+import test.support
+import urllib.response
+import unittest
+
+class TestFile(object):
+
+ def __init__(self):
+ self.closed = False
+
+ def read(self, bytes):
+ pass
+
+ def readline(self):
+ pass
+
+ def close(self):
+ self.closed = True
+
+class Testaddbase(unittest.TestCase):
+
+ # TODO(jhylton): Write tests for other functionality of addbase()
+
+ def setUp(self):
+ self.fp = TestFile()
+ self.addbase = urllib.response.addbase(self.fp)
+
+ def test_with(self):
+ def f():
+ with self.addbase as spam:
+ pass
+ self.assertFalse(self.fp.closed)
+ f()
+ self.assertTrue(self.fp.closed)
+ self.assertRaises(ValueError, f)
+
+def test_main():
+ test.support.run_unittest(Testaddbase)
+
+if __name__ == '__main__':
+ test_main()
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index 1d88331146a..383b2affd09 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -1,33 +1,21 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import unittest
-from test import test_support
+from test import support
+import contextlib
import socket
-import urllib
+import urllib.request
import sys
import os
+import email.message
import time
-mimetools = test_support.import_module("mimetools", deprecated=True)
-
-
-def _open_with_retry(func, host, *args, **kwargs):
- # Connecting to remote hosts is flaky. Make it more robust
- # by retrying the connection several times.
- for i in range(3):
- try:
- return func(host, *args, **kwargs)
- except IOError, last_exc:
- continue
- except:
- raise
- raise last_exc
-
class URLTimeoutTest(unittest.TestCase):
+ # XXX this test doesn't seem to test anything useful.
- TIMEOUT = 10.0
+ TIMEOUT = 30.0
def setUp(self):
socket.setdefaulttimeout(self.TIMEOUT)
@@ -36,11 +24,13 @@ class URLTimeoutTest(unittest.TestCase):
socket.setdefaulttimeout(None)
def testURLread(self):
- f = _open_with_retry(urllib.urlopen, "http://www.python.org/")
- x = f.read()
+ with support.transient_internet("www.python.org"):
+ f = urllib.request.urlopen("http://www.python.org/")
+ x = f.read()
+
class urlopenNetworkTests(unittest.TestCase):
- """Tests urllib.urlopen using the network.
+ """Tests urllib.reqest.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no
@@ -54,79 +44,71 @@ class urlopenNetworkTests(unittest.TestCase):
"""
- def urlopen(self, *args):
- return _open_with_retry(urllib.urlopen, *args)
+ @contextlib.contextmanager
+ def urlopen(self, *args, **kwargs):
+ resource = args[0]
+ with support.transient_internet(resource):
+ r = urllib.request.urlopen(*args, **kwargs)
+ try:
+ yield r
+ finally:
+ r.close()
def test_basic(self):
# Simple test expected to pass.
- open_url = self.urlopen("http://www.python.org/")
- for attr in ("read", "readline", "readlines", "fileno", "close",
- "info", "geturl"):
- self.assertTrue(hasattr(open_url, attr), "object returned from "
- "urlopen lacks the %s attribute" % attr)
- try:
+ with self.urlopen("http://www.python.org/") as open_url:
+ for attr in ("read", "readline", "readlines", "fileno", "close",
+ "info", "geturl"):
+ self.assertTrue(hasattr(open_url, attr), "object returned from "
+ "urlopen lacks the %s attribute" % attr)
self.assertTrue(open_url.read(), "calling 'read' failed")
- finally:
- open_url.close()
def test_readlines(self):
# Test both readline and readlines.
- open_url = self.urlopen("http://www.python.org/")
- try:
- self.assertIsInstance(open_url.readline(), basestring,
+ with self.urlopen("http://www.python.org/") as open_url:
+ self.assertIsInstance(open_url.readline(), bytes,
"readline did not return a string")
self.assertIsInstance(open_url.readlines(), list,
"readlines did not return a list")
- finally:
- open_url.close()
def test_info(self):
# Test 'info'.
- open_url = self.urlopen("http://www.python.org/")
- try:
+ with self.urlopen("http://www.python.org/") as open_url:
info_obj = open_url.info()
- finally:
- open_url.close()
- self.assertIsInstance(info_obj, mimetools.Message,
+ self.assertIsInstance(info_obj, email.message.Message,
"object returned by 'info' is not an "
- "instance of mimetools.Message")
- self.assertEqual(info_obj.getsubtype(), "html")
+ "instance of email.message.Message")
+ self.assertEqual(info_obj.get_content_subtype(), "html")
def test_geturl(self):
# Make sure same URL as opened is returned by geturl.
URL = "http://www.python.org/"
- open_url = self.urlopen(URL)
- try:
+ with self.urlopen(URL) as open_url:
gotten_url = open_url.geturl()
- finally:
- open_url.close()
- self.assertEqual(gotten_url, URL)
+ self.assertEqual(gotten_url, URL)
def test_getcode(self):
# test getcode() with the fancy opener to get 404 error codes
URL = "http://www.python.org/XXXinvalidXXX"
- open_url = urllib.FancyURLopener().open(URL)
- try:
- code = open_url.getcode()
- finally:
- open_url.close()
- self.assertEqual(code, 404)
+ with support.transient_internet(URL):
+ open_url = urllib.request.FancyURLopener().open(URL)
+ try:
+ code = open_url.getcode()
+ finally:
+ open_url.close()
+ self.assertEqual(code, 404)
def test_fileno(self):
- if (sys.platform in ('win32',) or
- not hasattr(os, 'fdopen')):
+ if sys.platform in ('win32',):
# On Windows, socket handles are not file descriptors; this
# test can't pass on Windows.
return
# Make sure fd returned by fileno is valid.
- open_url = self.urlopen("http://www.python.org/")
- fd = open_url.fileno()
- FILE = os.fdopen(fd)
- try:
- self.assertTrue(FILE.read(), "reading from file created using fd "
- "returned by fileno failed")
- finally:
- FILE.close()
+ with self.urlopen("http://www.python.org/", timeout=None) as open_url:
+ fd = open_url.fileno()
+ with os.fdopen(fd, encoding='utf-8') as f:
+ self.assertTrue(f.read(), "reading from file created using fd "
+ "returned by fileno failed")
def test_bad_address(self):
# Make sure proper exception is raised when connecting to a bogus
@@ -147,67 +129,63 @@ class urlopenNetworkTests(unittest.TestCase):
# domain will be spared to serve its defined
# purpose.
# urllib.urlopen, "http://www.sadflkjsasadf.com/")
- urllib.urlopen, "http://sadflkjsasf.i.nvali.d/")
+ urllib.request.urlopen,
+ "http://sadflkjsasf.i.nvali.d/")
+
class urlretrieveNetworkTests(unittest.TestCase):
- """Tests urllib.urlretrieve using the network."""
+ """Tests urllib.request.urlretrieve using the network."""
+ @contextlib.contextmanager
def urlretrieve(self, *args):
- return _open_with_retry(urllib.urlretrieve, *args)
+ resource = args[0]
+ with support.transient_internet(resource):
+ file_location, info = urllib.request.urlretrieve(*args)
+ try:
+ yield file_location, info
+ finally:
+ support.unlink(file_location)
def test_basic(self):
# Test basic functionality.
- file_location,info = self.urlretrieve("http://www.python.org/")
- self.assertTrue(os.path.exists(file_location), "file location returned by"
- " urlretrieve is not a valid path")
- FILE = file(file_location)
- try:
- self.assertTrue(FILE.read(), "reading from the file location returned"
- " by urlretrieve failed")
- finally:
- FILE.close()
- os.unlink(file_location)
+ with self.urlretrieve("http://www.python.org/") as (file_location, info):
+ self.assertTrue(os.path.exists(file_location), "file location returned by"
+ " urlretrieve is not a valid path")
+ with open(file_location, encoding='utf-8') as f:
+ self.assertTrue(f.read(), "reading from the file location returned"
+ " by urlretrieve failed")
def test_specified_path(self):
# Make sure that specifying the location of the file to write to works.
- file_location,info = self.urlretrieve("http://www.python.org/",
- test_support.TESTFN)
- self.assertEqual(file_location, test_support.TESTFN)
- self.assertTrue(os.path.exists(file_location))
- FILE = file(file_location)
- try:
- self.assertTrue(FILE.read(), "reading from temporary file failed")
- finally:
- FILE.close()
- os.unlink(file_location)
+ with self.urlretrieve("http://www.python.org/",
+ support.TESTFN) as (file_location, info):
+ self.assertEqual(file_location, support.TESTFN)
+ self.assertTrue(os.path.exists(file_location))
+ with open(file_location, encoding='utf-8') as f:
+ self.assertTrue(f.read(), "reading from temporary file failed")
def test_header(self):
# Make sure header returned as 2nd value from urlretrieve is good.
- file_location, header = self.urlretrieve("http://www.python.org/")
- os.unlink(file_location)
- self.assertIsInstance(header, mimetools.Message,
- "header is not an instance of mimetools.Message")
+ with self.urlretrieve("http://www.python.org/") as (file_location, info):
+ self.assertIsInstance(info, email.message.Message,
+ "info is not an instance of email.message.Message")
def test_data_header(self):
logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png"
- file_location, fileheaders = self.urlretrieve(logo)
- os.unlink(file_location)
- datevalue = fileheaders.getheader('Date')
- dateformat = '%a, %d %b %Y %H:%M:%S GMT'
- try:
- time.strptime(datevalue, dateformat)
- except ValueError:
- self.fail('Date value not in %r format', dateformat)
-
+ with self.urlretrieve(logo) as (file_location, fileheaders):
+ datevalue = fileheaders.get('Date')
+ dateformat = '%a, %d %b %Y %H:%M:%S GMT'
+ try:
+ time.strptime(datevalue, dateformat)
+ except ValueError:
+ self.fail('Date value not in %r format', dateformat)
def test_main():
- test_support.requires('network')
- with test_support.check_py3k_warnings(
- ("urllib.urlopen.. has been removed", DeprecationWarning)):
- test_support.run_unittest(URLTimeoutTest,
- urlopenNetworkTests,
- urlretrieveNetworkTests)
+ support.requires('network')
+ support.run_unittest(URLTimeoutTest,
+ urlopenNetworkTests,
+ urlretrieveNetworkTests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_urlparse.py b/Lib/test/test_urlparse.py
index 72ebfaa0896..378a427bc56 100644..100755
--- a/Lib/test/test_urlparse.py
+++ b/Lib/test/test_urlparse.py
@@ -1,8 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
-from test import test_support
+from test import support
import unittest
-import urlparse
+import urllib.parse
RFC1808_BASE = "http://a/b/c/d;p?q#f"
RFC2396_BASE = "http://a/b/c/d;p?q"
@@ -24,24 +24,35 @@ parse_qsl_test_cases = [
("&a=b", [('a', 'b')]),
("a=a+b&b=b+c", [('a', 'a b'), ('b', 'b c')]),
("a=1&a=2", [('a', '1'), ('a', '2')]),
+ (b"", []),
+ (b"&", []),
+ (b"&&", []),
+ (b"=", [(b'', b'')]),
+ (b"=a", [(b'', b'a')]),
+ (b"a", [(b'a', b'')]),
+ (b"a=", [(b'a', b'')]),
+ (b"a=", [(b'a', b'')]),
+ (b"&a=b", [(b'a', b'b')]),
+ (b"a=a+b&b=b+c", [(b'a', b'a b'), (b'b', b'b c')]),
+ (b"a=1&a=2", [(b'a', b'1'), (b'a', b'2')]),
]
class UrlParseTestCase(unittest.TestCase):
def checkRoundtrips(self, url, parsed, split):
- result = urlparse.urlparse(url)
+ result = urllib.parse.urlparse(url)
self.assertEqual(result, parsed)
t = (result.scheme, result.netloc, result.path,
result.params, result.query, result.fragment)
self.assertEqual(t, parsed)
# put it back together and it should be the same
- result2 = urlparse.urlunparse(result)
+ result2 = urllib.parse.urlunparse(result)
self.assertEqual(result2, url)
self.assertEqual(result2, result.geturl())
# the result of geturl() is a fixpoint; we can always parse it
# again to get the same result:
- result3 = urlparse.urlparse(result.geturl())
+ result3 = urllib.parse.urlparse(result.geturl())
self.assertEqual(result3.geturl(), result.geturl())
self.assertEqual(result3, result)
self.assertEqual(result3.scheme, result.scheme)
@@ -56,17 +67,17 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(result3.port, result.port)
# check the roundtrip using urlsplit() as well
- result = urlparse.urlsplit(url)
+ result = urllib.parse.urlsplit(url)
self.assertEqual(result, split)
t = (result.scheme, result.netloc, result.path,
result.query, result.fragment)
self.assertEqual(t, split)
- result2 = urlparse.urlunsplit(result)
+ result2 = urllib.parse.urlunsplit(result)
self.assertEqual(result2, url)
self.assertEqual(result2, result.geturl())
# check the fixpoint property of re-parsing the result of geturl()
- result3 = urlparse.urlsplit(result.geturl())
+ result3 = urllib.parse.urlsplit(result.geturl())
self.assertEqual(result3.geturl(), result.geturl())
self.assertEqual(result3, result)
self.assertEqual(result3.scheme, result.scheme)
@@ -81,16 +92,15 @@ class UrlParseTestCase(unittest.TestCase):
def test_qsl(self):
for orig, expect in parse_qsl_test_cases:
- result = urlparse.parse_qsl(orig, keep_blank_values=True)
+ result = urllib.parse.parse_qsl(orig, keep_blank_values=True)
self.assertEqual(result, expect, "Error parsing %r" % orig)
expect_without_blanks = [v for v in expect if len(v[1])]
- result = urlparse.parse_qsl(orig, keep_blank_values=False)
+ result = urllib.parse.parse_qsl(orig, keep_blank_values=False)
self.assertEqual(result, expect_without_blanks,
- "Error parsing %r" % orig)
-
+ "Error parsing %r" % orig)
def test_roundtrips(self):
- testcases = [
+ str_cases = [
('file:///tmp/junk.txt',
('file', '', '/tmp/junk.txt', '', '', ''),
('file', '', '/tmp/junk.txt', '', '')),
@@ -103,7 +113,7 @@ class UrlParseTestCase(unittest.TestCase):
('mms', 'wms.sys.hinet.net', '/cts/Drama/09006251100.asf',
'', '')),
('nfs://server/path/to/file.txt',
- ('nfs', 'server', '/path/to/file.txt', '', '', ''),
+ ('nfs', 'server', '/path/to/file.txt', '', '', ''),
('nfs', 'server', '/path/to/file.txt', '', '')),
('svn+ssh://svn.zope.org/repos/main/ZConfig/trunk/',
('svn+ssh', 'svn.zope.org', '/repos/main/ZConfig/trunk/',
@@ -114,16 +124,21 @@ class UrlParseTestCase(unittest.TestCase):
('git+ssh', 'git@github.com','/user/project.git',
'','',''),
('git+ssh', 'git@github.com','/user/project.git',
- '', ''))
+ '', '')),
]
- for url, parsed, split in testcases:
+ def _encode(t):
+ return (t[0].encode('ascii'),
+ tuple(x.encode('ascii') for x in t[1]),
+ tuple(x.encode('ascii') for x in t[2]))
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, parsed, split in str_cases + bytes_cases:
self.checkRoundtrips(url, parsed, split)
def test_http_roundtrips(self):
- # urlparse.urlsplit treats 'http:' as an optimized special case,
+ # urllib.parse.urlsplit treats 'http:' as an optimized special case,
# so we test both 'http:' and 'https:' in all the following.
# Three cheers for white box knowledge!
- testcases = [
+ str_cases = [
('://www.python.org',
('www.python.org', '', '', '', ''),
('www.python.org', '', '', '')),
@@ -140,21 +155,36 @@ class UrlParseTestCase(unittest.TestCase):
('a', '/b/c/d', 'p', 'q', 'f'),
('a', '/b/c/d;p', 'q', 'f')),
]
- for scheme in ('http', 'https'):
- for url, parsed, split in testcases:
- url = scheme + url
- parsed = (scheme,) + parsed
- split = (scheme,) + split
- self.checkRoundtrips(url, parsed, split)
+ def _encode(t):
+ return (t[0].encode('ascii'),
+ tuple(x.encode('ascii') for x in t[1]),
+ tuple(x.encode('ascii') for x in t[2]))
+ bytes_cases = [_encode(x) for x in str_cases]
+ str_schemes = ('http', 'https')
+ bytes_schemes = (b'http', b'https')
+ str_tests = str_schemes, str_cases
+ bytes_tests = bytes_schemes, bytes_cases
+ for schemes, test_cases in (str_tests, bytes_tests):
+ for scheme in schemes:
+ for url, parsed, split in test_cases:
+ url = scheme + url
+ parsed = (scheme,) + parsed
+ split = (scheme,) + split
+ self.checkRoundtrips(url, parsed, split)
def checkJoin(self, base, relurl, expected):
- self.assertEqual(urlparse.urljoin(base, relurl), expected,
- (base, relurl, expected))
+ str_components = (base, relurl, expected)
+ self.assertEqual(urllib.parse.urljoin(base, relurl), expected)
+ bytes_components = baseb, relurlb, expectedb = [
+ x.encode('ascii') for x in str_components]
+ self.assertEqual(urllib.parse.urljoin(baseb, relurlb), expectedb)
def test_unparse_parse(self):
- for u in ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]:
- self.assertEqual(urlparse.urlunsplit(urlparse.urlsplit(u)), u)
- self.assertEqual(urlparse.urlunparse(urlparse.urlparse(u)), u)
+ str_cases = ['Python', './Python','x-newscheme://foo.com/stuff','x://y','x:/y','x:/','/',]
+ bytes_cases = [x.encode('ascii') for x in str_cases]
+ for u in str_cases + bytes_cases:
+ self.assertEqual(urllib.parse.urlunsplit(urllib.parse.urlsplit(u)), u)
+ self.assertEqual(urllib.parse.urlunparse(urllib.parse.urlparse(u)), u)
def test_RFC1808(self):
# "normal" cases from RFC 1808:
@@ -203,11 +233,13 @@ class UrlParseTestCase(unittest.TestCase):
def test_RFC2368(self):
# Issue 11467: path that starts with a number is not parsed correctly
- self.assertEqual(urlparse.urlparse('mailto:1337@example.org'),
+ self.assertEqual(urllib.parse.urlparse('mailto:1337@example.org'),
('mailto', '', '1337@example.org', '', '', ''))
def test_RFC2396(self):
# cases from RFC 2396
+
+
self.checkJoin(RFC2396_BASE, 'g:h', 'g:h')
self.checkJoin(RFC2396_BASE, 'g', 'http://a/b/c/g')
self.checkJoin(RFC2396_BASE, './g', 'http://a/b/c/g')
@@ -301,7 +333,7 @@ class UrlParseTestCase(unittest.TestCase):
self.checkJoin(RFC3986_BASE, 'g#s/./x','http://a/b/c/g#s/./x')
self.checkJoin(RFC3986_BASE, 'g#s/../x','http://a/b/c/g#s/../x')
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
- self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') # relaxed parser
+ self.checkJoin(RFC3986_BASE, 'http:g','http://a/b/c/g') #relaxed parser
# Test for issue9721
self.checkJoin('http://a/b/c/de', ';x','http://a/b/c/;x')
@@ -339,11 +371,11 @@ class UrlParseTestCase(unittest.TestCase):
self.checkJoin('http:///', '..','http:///')
self.checkJoin('', 'http://a/b/c/g?y/./x','http://a/b/c/g?y/./x')
self.checkJoin('', 'http://a/./g', 'http://a/./g')
- self.checkJoin('svn://pathtorepo/dir1','dir2','svn://pathtorepo/dir2')
- self.checkJoin('svn+ssh://pathtorepo/dir1','dir2','svn+ssh://pathtorepo/dir2')
+ self.checkJoin('svn://pathtorepo/dir1', 'dir2', 'svn://pathtorepo/dir2')
+ self.checkJoin('svn+ssh://pathtorepo/dir1', 'dir2', 'svn+ssh://pathtorepo/dir2')
def test_RFC2732(self):
- for url, hostname, port in [
+ str_cases = [
('http://Test.python.org:5432/foo/', 'test.python.org', 5432),
('http://12.34.56.78:5432/foo/', '12.34.56.78', 5432),
('http://[::1]:5432/foo/', '::1', 5432),
@@ -364,20 +396,26 @@ class UrlParseTestCase(unittest.TestCase):
('http://[::12.34.56.78]/foo/', '::12.34.56.78', None),
('http://[::ffff:12.34.56.78]/foo/',
'::ffff:12.34.56.78', None),
- ]:
- urlparsed = urlparse.urlparse(url)
+ ]
+ def _encode(t):
+ return t[0].encode('ascii'), t[1].encode('ascii'), t[2]
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, hostname, port in str_cases + bytes_cases:
+ urlparsed = urllib.parse.urlparse(url)
self.assertEqual((urlparsed.hostname, urlparsed.port) , (hostname, port))
- for invalid_url in [
+ str_cases = [
'http://::12.34.56.78]/',
'http://[::1/foo/',
'ftp://[::1/foo/bad]/bad',
'http://[::1/foo/bad]/bad',
- 'http://[::ffff:12.34.56.78']:
- self.assertRaises(ValueError, urlparse.urlparse, invalid_url)
+ 'http://[::ffff:12.34.56.78']
+ bytes_cases = [x.encode('ascii') for x in str_cases]
+ for invalid_url in str_cases + bytes_cases:
+ self.assertRaises(ValueError, urllib.parse.urlparse, invalid_url)
def test_urldefrag(self):
- for url, defrag, frag in [
+ str_cases = [
('http://python.org#frag', 'http://python.org', 'frag'),
('http://python.org', 'http://python.org', ''),
('http://python.org/#frag', 'http://python.org/', 'frag'),
@@ -388,12 +426,20 @@ class UrlParseTestCase(unittest.TestCase):
('http://python.org/p?q', 'http://python.org/p?q', ''),
(RFC1808_BASE, 'http://a/b/c/d;p?q', 'f'),
(RFC2396_BASE, 'http://a/b/c/d;p?q', ''),
- ]:
- self.assertEqual(urlparse.urldefrag(url), (defrag, frag))
+ ]
+ def _encode(t):
+ return type(t)(x.encode('ascii') for x in t)
+ bytes_cases = [_encode(x) for x in str_cases]
+ for url, defrag, frag in str_cases + bytes_cases:
+ result = urllib.parse.urldefrag(url)
+ self.assertEqual(result.geturl(), url)
+ self.assertEqual(result, (defrag, frag))
+ self.assertEqual(result.url, defrag)
+ self.assertEqual(result.fragment, frag)
def test_urlsplit_attributes(self):
url = "HTTP://WWW.PYTHON.ORG/doc/#frag"
- p = urlparse.urlsplit(url)
+ p = urllib.parse.urlsplit(url)
self.assertEqual(p.scheme, "http")
self.assertEqual(p.netloc, "WWW.PYTHON.ORG")
self.assertEqual(p.path, "/doc/")
@@ -405,10 +451,11 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, None)
# geturl() won't return exactly the original URL in this case
# since the scheme is always case-normalized
- #self.assertEqual(p.geturl(), url)
+ # We handle this by ignoring the first 4 characters of the URL
+ self.assertEqual(p.geturl()[4:], url[4:])
url = "http://User:Pass@www.python.org:080/doc/?query=yes#frag"
- p = urlparse.urlsplit(url)
+ p = urllib.parse.urlsplit(url)
self.assertEqual(p.scheme, "http")
self.assertEqual(p.netloc, "User:Pass@www.python.org:080")
self.assertEqual(p.path, "/doc/")
@@ -425,7 +472,7 @@ class UrlParseTestCase(unittest.TestCase):
# and request email addresses as usernames.
url = "http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
- p = urlparse.urlsplit(url)
+ p = urllib.parse.urlsplit(url)
self.assertEqual(p.scheme, "http")
self.assertEqual(p.netloc, "User@example.com:Pass@www.python.org:080")
self.assertEqual(p.path, "/doc/")
@@ -437,62 +484,70 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, 80)
self.assertEqual(p.geturl(), url)
- # Verify an illegal port of value greater than 65535 is set as None
- url = "http://www.python.org:65536"
- p = urlparse.urlsplit(url)
+ # And check them all again, only with bytes this time
+ url = b"HTTP://WWW.PYTHON.ORG/doc/#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"WWW.PYTHON.ORG")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, b"www.python.org")
self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl()[4:], url[4:])
+
+ url = b"http://User:Pass@www.python.org:080/doc/?query=yes#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"User:Pass@www.python.org:080")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"query=yes")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, b"User")
+ self.assertEqual(p.password, b"Pass")
+ self.assertEqual(p.hostname, b"www.python.org")
+ self.assertEqual(p.port, 80)
+ self.assertEqual(p.geturl(), url)
- def test_issue14072(self):
- p1 = urlparse.urlsplit('tel:+31-641044153')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '+31-641044153')
-
- p2 = urlparse.urlsplit('tel:+31641044153')
- self.assertEqual(p2.scheme, 'tel')
- self.assertEqual(p2.path, '+31641044153')
-
- # Assert for urlparse
- p1 = urlparse.urlparse('tel:+31-641044153')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '+31-641044153')
-
- p2 = urlparse.urlparse('tel:+31641044153')
- self.assertEqual(p2.scheme, 'tel')
- self.assertEqual(p2.path, '+31641044153')
-
-
- def test_telurl_params(self):
- p1 = urlparse.urlparse('tel:123-4;phone-context=+1-650-516')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '123-4')
- self.assertEqual(p1.params, 'phone-context=+1-650-516')
-
- p1 = urlparse.urlparse('tel:+1-201-555-0123')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '+1-201-555-0123')
- self.assertEqual(p1.params, '')
-
- p1 = urlparse.urlparse('tel:7042;phone-context=example.com')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '7042')
- self.assertEqual(p1.params, 'phone-context=example.com')
-
- p1 = urlparse.urlparse('tel:863-1234;phone-context=+1-914-555')
- self.assertEqual(p1.scheme, 'tel')
- self.assertEqual(p1.path, '863-1234')
- self.assertEqual(p1.params, 'phone-context=+1-914-555')
+ url = b"http://User@example.com:Pass@www.python.org:080/doc/?query=yes#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.scheme, b"http")
+ self.assertEqual(p.netloc, b"User@example.com:Pass@www.python.org:080")
+ self.assertEqual(p.path, b"/doc/")
+ self.assertEqual(p.query, b"query=yes")
+ self.assertEqual(p.fragment, b"frag")
+ self.assertEqual(p.username, b"User@example.com")
+ self.assertEqual(p.password, b"Pass")
+ self.assertEqual(p.hostname, b"www.python.org")
+ self.assertEqual(p.port, 80)
+ self.assertEqual(p.geturl(), url)
+ # Verify an illegal port is returned as None
+ url = b"HTTP://WWW.PYTHON.ORG:65536/doc/#frag"
+ p = urllib.parse.urlsplit(url)
+ self.assertEqual(p.port, None)
def test_attributes_bad_port(self):
"""Check handling of non-integer ports."""
- p = urlparse.urlsplit("http://www.example.net:foo")
+ p = urllib.parse.urlsplit("http://www.example.net:foo")
self.assertEqual(p.netloc, "www.example.net:foo")
self.assertRaises(ValueError, lambda: p.port)
- p = urlparse.urlparse("http://www.example.net:foo")
+ p = urllib.parse.urlparse("http://www.example.net:foo")
self.assertEqual(p.netloc, "www.example.net:foo")
self.assertRaises(ValueError, lambda: p.port)
+ # Once again, repeat ourselves to test bytes
+ p = urllib.parse.urlsplit(b"http://www.example.net:foo")
+ self.assertEqual(p.netloc, b"www.example.net:foo")
+ self.assertRaises(ValueError, lambda: p.port)
+
+ p = urllib.parse.urlparse(b"http://www.example.net:foo")
+ self.assertEqual(p.netloc, b"www.example.net:foo")
+ self.assertRaises(ValueError, lambda: p.port)
+
def test_attributes_without_netloc(self):
# This example is straight from RFC 3261. It looks like it
# should allow the username, hostname, and port to be filled
@@ -500,7 +555,7 @@ class UrlParseTestCase(unittest.TestCase):
# scheme://netloc syntax, the netloc and related attributes
# should be left empty.
uri = "sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
- p = urlparse.urlsplit(uri)
+ p = urllib.parse.urlsplit(uri)
self.assertEqual(p.netloc, "")
self.assertEqual(p.username, None)
self.assertEqual(p.password, None)
@@ -508,7 +563,7 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, None)
self.assertEqual(p.geturl(), uri)
- p = urlparse.urlparse(uri)
+ p = urllib.parse.urlparse(uri)
self.assertEqual(p.netloc, "")
self.assertEqual(p.username, None)
self.assertEqual(p.password, None)
@@ -516,56 +571,285 @@ class UrlParseTestCase(unittest.TestCase):
self.assertEqual(p.port, None)
self.assertEqual(p.geturl(), uri)
- def test_caching(self):
- # Test case for bug #1313119
- uri = "http://example.com/doc/"
- unicode_uri = unicode(uri)
+ # You guessed it, repeating the test with bytes input
+ uri = b"sip:alice@atlanta.com;maddr=239.255.255.1;ttl=15"
+ p = urllib.parse.urlsplit(uri)
+ self.assertEqual(p.netloc, b"")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, None)
+ self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl(), uri)
- urlparse.urlparse(unicode_uri)
- p = urlparse.urlparse(uri)
- self.assertEqual(type(p.scheme), type(uri))
- self.assertEqual(type(p.hostname), type(uri))
- self.assertEqual(type(p.path), type(uri))
+ p = urllib.parse.urlparse(uri)
+ self.assertEqual(p.netloc, b"")
+ self.assertEqual(p.username, None)
+ self.assertEqual(p.password, None)
+ self.assertEqual(p.hostname, None)
+ self.assertEqual(p.port, None)
+ self.assertEqual(p.geturl(), uri)
def test_noslash(self):
# Issue 1637: http://foo.com?query is legal
- self.assertEqual(urlparse.urlparse("http://example.com?blahblah=/foo"),
+ self.assertEqual(urllib.parse.urlparse("http://example.com?blahblah=/foo"),
('http', 'example.com', '', '', 'blahblah=/foo', ''))
-
- def test_anyscheme(self):
- # Issue 7904: s3://foo.com/stuff has netloc "foo.com".
- self.assertEqual(urlparse.urlparse("s3://foo.com/stuff"),
- ('s3','foo.com','/stuff','','',''))
- self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff"),
- ('x-newscheme','foo.com','/stuff','','',''))
- self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query#fragment"),
- ('x-newscheme','foo.com','/stuff','','query','fragment'))
- self.assertEqual(urlparse.urlparse("x-newscheme://foo.com/stuff?query"),
- ('x-newscheme','foo.com','/stuff','','query',''))
+ self.assertEqual(urllib.parse.urlparse(b"http://example.com?blahblah=/foo"),
+ (b'http', b'example.com', b'', b'', b'blahblah=/foo', b''))
def test_withoutscheme(self):
# Test urlparse without scheme
# Issue 754016: urlparse goes wrong with IP:port without scheme
# RFC 1808 specifies that netloc should start with //, urlparse expects
# the same, otherwise it classifies the portion of url as path.
- self.assertEqual(urlparse.urlparse("path"),
+ self.assertEqual(urllib.parse.urlparse("path"),
('','','path','','',''))
- self.assertEqual(urlparse.urlparse("//www.python.org:80"),
+ self.assertEqual(urllib.parse.urlparse("//www.python.org:80"),
('','www.python.org:80','','','',''))
- self.assertEqual(urlparse.urlparse("http://www.python.org:80"),
+ self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
('http','www.python.org:80','','','',''))
+ # Repeat for bytes input
+ self.assertEqual(urllib.parse.urlparse(b"path"),
+ (b'',b'',b'path',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"//www.python.org:80"),
+ (b'',b'www.python.org:80',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+ (b'http',b'www.python.org:80',b'',b'',b'',b''))
def test_portseparator(self):
# Issue 754016 makes changes for port separator ':' from scheme separator
- self.assertEqual(urlparse.urlparse("path:80"),
+ self.assertEqual(urllib.parse.urlparse("path:80"),
('','','path:80','','',''))
- self.assertEqual(urlparse.urlparse("http:"),('http','','','','',''))
- self.assertEqual(urlparse.urlparse("https:"),('https','','','','',''))
- self.assertEqual(urlparse.urlparse("http://www.python.org:80"),
+ self.assertEqual(urllib.parse.urlparse("http:"),('http','','','','',''))
+ self.assertEqual(urllib.parse.urlparse("https:"),('https','','','','',''))
+ self.assertEqual(urllib.parse.urlparse("http://www.python.org:80"),
('http','www.python.org:80','','','',''))
+ # As usual, need to check bytes input as well
+ self.assertEqual(urllib.parse.urlparse(b"path:80"),
+ (b'',b'',b'path:80',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http:"),(b'http',b'',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"https:"),(b'https',b'',b'',b'',b'',b''))
+ self.assertEqual(urllib.parse.urlparse(b"http://www.python.org:80"),
+ (b'http',b'www.python.org:80',b'',b'',b'',b''))
+
+ def test_usingsys(self):
+ # Issue 3314: sys module is used in the error
+ self.assertRaises(TypeError, urllib.parse.urlencode, "foo")
+
+ def test_anyscheme(self):
+ # Issue 7904: s3://foo.com/stuff has netloc "foo.com".
+ self.assertEqual(urllib.parse.urlparse("s3://foo.com/stuff"),
+ ('s3', 'foo.com', '/stuff', '', '', ''))
+ self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff"),
+ ('x-newscheme', 'foo.com', '/stuff', '', '', ''))
+ self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query#fragment"),
+ ('x-newscheme', 'foo.com', '/stuff', '', 'query', 'fragment'))
+ self.assertEqual(urllib.parse.urlparse("x-newscheme://foo.com/stuff?query"),
+ ('x-newscheme', 'foo.com', '/stuff', '', 'query', ''))
+
+ # And for bytes...
+ self.assertEqual(urllib.parse.urlparse(b"s3://foo.com/stuff"),
+ (b's3', b'foo.com', b'/stuff', b'', b'', b''))
+ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff"),
+ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'', b''))
+ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query#fragment"),
+ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b'fragment'))
+ self.assertEqual(urllib.parse.urlparse(b"x-newscheme://foo.com/stuff?query"),
+ (b'x-newscheme', b'foo.com', b'/stuff', b'', b'query', b''))
+
+ def test_mixed_types_rejected(self):
+ # Several functions that process either strings or ASCII encoded bytes
+ # accept multiple arguments. Check they reject mixed type input
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlparse("www.python.org", b"http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlparse(b"www.python.org", "http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlsplit("www.python.org", b"http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlsplit(b"www.python.org", "http")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunparse(( b"http", "www.python.org","","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunparse(("http", b"www.python.org","","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunsplit((b"http", "www.python.org","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urlunsplit(("http", b"www.python.org","","",""))
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urljoin("http://python.org", b"http://python.org")
+ with self.assertRaisesRegex(TypeError, "Cannot mix str"):
+ urllib.parse.urljoin(b"http://python.org", "http://python.org")
+
+ def _check_result_type(self, str_type):
+ num_args = len(str_type._fields)
+ bytes_type = str_type._encoded_counterpart
+ self.assertIs(bytes_type._decoded_counterpart, str_type)
+ str_args = ('',) * num_args
+ bytes_args = (b'',) * num_args
+ str_result = str_type(*str_args)
+ bytes_result = bytes_type(*bytes_args)
+ encoding = 'ascii'
+ errors = 'strict'
+ self.assertEqual(str_result, str_args)
+ self.assertEqual(bytes_result.decode(), str_args)
+ self.assertEqual(bytes_result.decode(), str_result)
+ self.assertEqual(bytes_result.decode(encoding), str_args)
+ self.assertEqual(bytes_result.decode(encoding), str_result)
+ self.assertEqual(bytes_result.decode(encoding, errors), str_args)
+ self.assertEqual(bytes_result.decode(encoding, errors), str_result)
+ self.assertEqual(bytes_result, bytes_args)
+ self.assertEqual(str_result.encode(), bytes_args)
+ self.assertEqual(str_result.encode(), bytes_result)
+ self.assertEqual(str_result.encode(encoding), bytes_args)
+ self.assertEqual(str_result.encode(encoding), bytes_result)
+ self.assertEqual(str_result.encode(encoding, errors), bytes_args)
+ self.assertEqual(str_result.encode(encoding, errors), bytes_result)
+
+ def test_result_pairs(self):
+ # Check encoding and decoding between result pairs
+ result_types = [
+ urllib.parse.DefragResult,
+ urllib.parse.SplitResult,
+ urllib.parse.ParseResult,
+ ]
+ for result_type in result_types:
+ self._check_result_type(result_type)
+
+ def test_parse_qs_encoding(self):
+ result = urllib.parse.parse_qs("key=\u0141%E9", encoding="latin-1")
+ self.assertEqual(result, {'key': ['\u0141\xE9']})
+ result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="utf-8")
+ self.assertEqual(result, {'key': ['\u0141\xE9']})
+ result = urllib.parse.parse_qs("key=\u0141%C3%A9", encoding="ascii")
+ self.assertEqual(result, {'key': ['\u0141\ufffd\ufffd']})
+ result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii")
+ self.assertEqual(result, {'key': ['\u0141\ufffd-']})
+ result = urllib.parse.parse_qs("key=\u0141%E9-", encoding="ascii",
+ errors="ignore")
+ self.assertEqual(result, {'key': ['\u0141-']})
+
+ def test_parse_qsl_encoding(self):
+ result = urllib.parse.parse_qsl("key=\u0141%E9", encoding="latin-1")
+ self.assertEqual(result, [('key', '\u0141\xE9')])
+ result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="utf-8")
+ self.assertEqual(result, [('key', '\u0141\xE9')])
+ result = urllib.parse.parse_qsl("key=\u0141%C3%A9", encoding="ascii")
+ self.assertEqual(result, [('key', '\u0141\ufffd\ufffd')])
+ result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii")
+ self.assertEqual(result, [('key', '\u0141\ufffd-')])
+ result = urllib.parse.parse_qsl("key=\u0141%E9-", encoding="ascii",
+ errors="ignore")
+ self.assertEqual(result, [('key', '\u0141-')])
+
+ def test_splitnport(self):
+ # Normal cases are exercised by other tests; ensure that we also
+ # catch cases with no port specified. (testcase ensuring coverage)
+ result = urllib.parse.splitnport('parrot:88')
+ self.assertEqual(result, ('parrot', 88))
+ result = urllib.parse.splitnport('parrot')
+ self.assertEqual(result, ('parrot', -1))
+ result = urllib.parse.splitnport('parrot', 55)
+ self.assertEqual(result, ('parrot', 55))
+ result = urllib.parse.splitnport('parrot:')
+ self.assertEqual(result, ('parrot', None))
+
+ def test_splitquery(self):
+ # Normal cases are exercised by other tests; ensure that we also
+ # catch cases with no port specified (testcase ensuring coverage)
+ result = urllib.parse.splitquery('http://python.org/fake?foo=bar')
+ self.assertEqual(result, ('http://python.org/fake', 'foo=bar'))
+ result = urllib.parse.splitquery('http://python.org/fake?foo=bar?')
+ self.assertEqual(result, ('http://python.org/fake?foo=bar', ''))
+ result = urllib.parse.splitquery('http://python.org/fake')
+ self.assertEqual(result, ('http://python.org/fake', None))
+
+ def test_splitvalue(self):
+ # Normal cases are exercised by other tests; test pathological cases
+ # with no key/value pairs. (testcase ensuring coverage)
+ result = urllib.parse.splitvalue('foo=bar')
+ self.assertEqual(result, ('foo', 'bar'))
+ result = urllib.parse.splitvalue('foo=')
+ self.assertEqual(result, ('foo', ''))
+ result = urllib.parse.splitvalue('foobar')
+ self.assertEqual(result, ('foobar', None))
+
+ def test_to_bytes(self):
+ result = urllib.parse.to_bytes('http://www.python.org')
+ self.assertEqual(result, 'http://www.python.org')
+ self.assertRaises(UnicodeError, urllib.parse.to_bytes,
+ 'http://www.python.org/medi\u00e6val')
+
+ def test_urlencode_sequences(self):
+ # Other tests incidentally urlencode things; test non-covered cases:
+ # Sequence and object values.
+ result = urllib.parse.urlencode({'a': [1, 2], 'b': (3, 4, 5)}, True)
+ # we cannot rely on ordering here
+ assert set(result.split('&')) == {'a=1', 'a=2', 'b=3', 'b=4', 'b=5'}
+
+ class Trivial:
+ def __str__(self):
+ return 'trivial'
+
+ result = urllib.parse.urlencode({'a': Trivial()}, True)
+ self.assertEqual(result, 'a=trivial')
+
+ def test_quote_from_bytes(self):
+ self.assertRaises(TypeError, urllib.parse.quote_from_bytes, 'foo')
+ result = urllib.parse.quote_from_bytes(b'archaeological arcana')
+ self.assertEqual(result, 'archaeological%20arcana')
+ result = urllib.parse.quote_from_bytes(b'')
+ self.assertEqual(result, '')
+
+ def test_unquote_to_bytes(self):
+ result = urllib.parse.unquote_to_bytes('abc%20def')
+ self.assertEqual(result, b'abc def')
+ result = urllib.parse.unquote_to_bytes('')
+ self.assertEqual(result, b'')
+
+ def test_quote_errors(self):
+ self.assertRaises(TypeError, urllib.parse.quote, b'foo',
+ encoding='utf-8')
+ self.assertRaises(TypeError, urllib.parse.quote, b'foo', errors='strict')
+
+ def test_issue14072(self):
+ p1 = urllib.parse.urlsplit('tel:+31-641044153')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+31-641044153')
+ p2 = urllib.parse.urlsplit('tel:+31641044153')
+ self.assertEqual(p2.scheme, 'tel')
+ self.assertEqual(p2.path, '+31641044153')
+ # assert the behavior for urlparse
+ p1 = urllib.parse.urlparse('tel:+31-641044153')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+31-641044153')
+ p2 = urllib.parse.urlparse('tel:+31641044153')
+ self.assertEqual(p2.scheme, 'tel')
+ self.assertEqual(p2.path, '+31641044153')
+
+ def test_telurl_params(self):
+ p1 = urllib.parse.urlparse('tel:123-4;phone-context=+1-650-516')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '123-4')
+ self.assertEqual(p1.params, 'phone-context=+1-650-516')
+
+ p1 = urllib.parse.urlparse('tel:+1-201-555-0123')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '+1-201-555-0123')
+ self.assertEqual(p1.params, '')
+
+ p1 = urllib.parse.urlparse('tel:7042;phone-context=example.com')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '7042')
+ self.assertEqual(p1.params, 'phone-context=example.com')
+
+ p1 = urllib.parse.urlparse('tel:863-1234;phone-context=+1-914-555')
+ self.assertEqual(p1.scheme, 'tel')
+ self.assertEqual(p1.path, '863-1234')
+ self.assertEqual(p1.params, 'phone-context=+1-914-555')
+
def test_main():
- test_support.run_unittest(UrlParseTestCase)
+ support.run_unittest(UrlParseTestCase)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_userdict.py b/Lib/test/test_userdict.py
index d5cecd8612f..137c445eaee 100644
--- a/Lib/test/test_userdict.py
+++ b/Lib/test/test_userdict.py
@@ -1,7 +1,7 @@
# Check every path through every method of UserDict
-from test import test_support, mapping_tests
-import UserDict
+from test import support, mapping_tests
+import collections
d0 = {}
d1 = {"one": 1}
@@ -11,54 +11,54 @@ d4 = {"one": None, "two": None}
d5 = {"one": 1, "two": 1}
class UserDictTest(mapping_tests.TestHashMappingProtocol):
- type2test = UserDict.IterableUserDict
+ type2test = collections.UserDict
def test_all(self):
# Test constructors
- u = UserDict.UserDict()
- u0 = UserDict.UserDict(d0)
- u1 = UserDict.UserDict(d1)
- u2 = UserDict.IterableUserDict(d2)
+ u = collections.UserDict()
+ u0 = collections.UserDict(d0)
+ u1 = collections.UserDict(d1)
+ u2 = collections.UserDict(d2)
- uu = UserDict.UserDict(u)
- uu0 = UserDict.UserDict(u0)
- uu1 = UserDict.UserDict(u1)
- uu2 = UserDict.UserDict(u2)
+ uu = collections.UserDict(u)
+ uu0 = collections.UserDict(u0)
+ uu1 = collections.UserDict(u1)
+ uu2 = collections.UserDict(u2)
# keyword arg constructor
- self.assertEqual(UserDict.UserDict(one=1, two=2), d2)
+ self.assertEqual(collections.UserDict(one=1, two=2), d2)
# item sequence constructor
- self.assertEqual(UserDict.UserDict([('one',1), ('two',2)]), d2)
- self.assertEqual(UserDict.UserDict(dict=[('one',1), ('two',2)]), d2)
+ self.assertEqual(collections.UserDict([('one',1), ('two',2)]), d2)
+ self.assertEqual(collections.UserDict(dict=[('one',1), ('two',2)]), d2)
# both together
- self.assertEqual(UserDict.UserDict([('one',1), ('two',2)], two=3, three=5), d3)
+ self.assertEqual(collections.UserDict([('one',1), ('two',2)], two=3, three=5), d3)
# alternate constructor
- self.assertEqual(UserDict.UserDict.fromkeys('one two'.split()), d4)
- self.assertEqual(UserDict.UserDict().fromkeys('one two'.split()), d4)
- self.assertEqual(UserDict.UserDict.fromkeys('one two'.split(), 1), d5)
- self.assertEqual(UserDict.UserDict().fromkeys('one two'.split(), 1), d5)
+ self.assertEqual(collections.UserDict.fromkeys('one two'.split()), d4)
+ self.assertEqual(collections.UserDict().fromkeys('one two'.split()), d4)
+ self.assertEqual(collections.UserDict.fromkeys('one two'.split(), 1), d5)
+ self.assertEqual(collections.UserDict().fromkeys('one two'.split(), 1), d5)
self.assertTrue(u1.fromkeys('one two'.split()) is not u1)
- self.assertIsInstance(u1.fromkeys('one two'.split()), UserDict.UserDict)
- self.assertIsInstance(u2.fromkeys('one two'.split()), UserDict.IterableUserDict)
+ self.assertIsInstance(u1.fromkeys('one two'.split()), collections.UserDict)
+ self.assertIsInstance(u2.fromkeys('one two'.split()), collections.UserDict)
# Test __repr__
self.assertEqual(str(u0), str(d0))
self.assertEqual(repr(u1), repr(d1))
self.assertEqual(repr(u2), repr(d2))
- # Test __cmp__ and __len__
+ # Test rich comparison and __len__
all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2]
for a in all:
for b in all:
- self.assertEqual(cmp(a, b), cmp(len(a), len(b)))
+ self.assertEqual(a == b, len(a) == len(b))
# Test __getitem__
self.assertEqual(u2["one"], 1)
self.assertRaises(KeyError, u1.__getitem__, "two")
# Test __setitem__
- u3 = UserDict.UserDict(u2)
+ u3 = collections.UserDict(u2)
u3["two"] = 2
u3["three"] = 3
@@ -73,12 +73,12 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test copy()
u2a = u2.copy()
self.assertEqual(u2a, u2)
- u2b = UserDict.UserDict(x=42, y=23)
+ u2b = collections.UserDict(x=42, y=23)
u2c = u2b.copy() # making a copy of a UserDict is special cased
self.assertEqual(u2b, u2c)
- class MyUserDict(UserDict.UserDict):
- def display(self): print self
+ class MyUserDict(collections.UserDict):
+ def display(self): print(self)
m2 = MyUserDict(u2)
m2a = m2.copy()
@@ -91,28 +91,18 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
# Test keys, items, values
self.assertEqual(u2.keys(), d2.keys())
self.assertEqual(u2.items(), d2.items())
- self.assertEqual(u2.values(), d2.values())
+ self.assertEqual(list(u2.values()), list(d2.values()))
- # Test has_key and "in".
+ # Test "in".
for i in u2.keys():
self.assertIn(i, u2)
self.assertEqual(i in u1, i in d1)
self.assertEqual(i in u0, i in d0)
- with test_support.check_py3k_warnings():
- self.assertTrue(u2.has_key(i))
- self.assertEqual(u1.has_key(i), d1.has_key(i))
- self.assertEqual(u0.has_key(i), d0.has_key(i))
# Test update
- t = UserDict.UserDict()
+ t = collections.UserDict()
t.update(u2)
self.assertEqual(t, u2)
- class Items:
- def items(self):
- return (("x", 42), ("y", 23))
- t = UserDict.UserDict()
- t.update(Items())
- self.assertEqual(t, {"x": 42, "y": 23})
# Test get
for i in u2.keys():
@@ -121,7 +111,7 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
self.assertEqual(u0.get(i), d0.get(i))
# Test "in" iteration.
- for i in xrange(20):
+ for i in range(20):
u2[i] = str(i)
ikeys = []
for k in u2:
@@ -130,13 +120,13 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
self.assertEqual(set(ikeys), set(keys))
# Test setdefault
- t = UserDict.UserDict()
+ t = collections.UserDict()
self.assertEqual(t.setdefault("x", 42), 42)
- self.assertTrue(t.has_key("x"))
+ self.assertIn("x", t)
self.assertEqual(t.setdefault("x", 23), 42)
# Test pop
- t = UserDict.UserDict(x=42)
+ t = collections.UserDict(x=42)
self.assertEqual(t.pop("x"), 42)
self.assertRaises(KeyError, t.pop, "x")
self.assertEqual(t.pop("x", 1), 1)
@@ -144,19 +134,19 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
self.assertEqual(t.pop("x", 1), 42)
# Test popitem
- t = UserDict.UserDict(x=42)
+ t = collections.UserDict(x=42)
self.assertEqual(t.popitem(), ("x", 42))
self.assertRaises(KeyError, t.popitem)
def test_missing(self):
# Make sure UserDict doesn't have a __missing__ method
- self.assertEqual(hasattr(UserDict, "__missing__"), False)
+ self.assertEqual(hasattr(collections.UserDict, "__missing__"), False)
# Test several cases:
# (D) subclass defines __missing__ method returning a value
# (E) subclass defines __missing__ method raising RuntimeError
# (F) subclass sets __missing__ instance variable (no effect)
# (G) subclass doesn't define __missing__ at a all
- class D(UserDict.UserDict):
+ class D(collections.UserDict):
def __missing__(self, key):
return 42
d = D({1: 2, 3: 4})
@@ -165,185 +155,43 @@ class UserDictTest(mapping_tests.TestHashMappingProtocol):
self.assertNotIn(2, d)
self.assertNotIn(2, d.keys())
self.assertEqual(d[2], 42)
- class E(UserDict.UserDict):
+ class E(collections.UserDict):
def __missing__(self, key):
raise RuntimeError(key)
e = E()
try:
e[42]
- except RuntimeError, err:
+ except RuntimeError as err:
self.assertEqual(err.args, (42,))
else:
self.fail("e[42] didn't raise RuntimeError")
- class F(UserDict.UserDict):
+ class F(collections.UserDict):
def __init__(self):
# An instance variable __missing__ should have no effect
self.__missing__ = lambda key: None
- UserDict.UserDict.__init__(self)
+ collections.UserDict.__init__(self)
f = F()
try:
f[42]
- except KeyError, err:
+ except KeyError as err:
self.assertEqual(err.args, (42,))
else:
self.fail("f[42] didn't raise KeyError")
- class G(UserDict.UserDict):
+ class G(collections.UserDict):
pass
g = G()
try:
g[42]
- except KeyError, err:
+ except KeyError as err:
self.assertEqual(err.args, (42,))
else:
self.fail("g[42] didn't raise KeyError")
-##########################
-# Test Dict Mixin
-class SeqDict(UserDict.DictMixin):
- """Dictionary lookalike implemented with lists.
-
- Used to test and demonstrate DictMixin
- """
- def __init__(self, other=None, **kwargs):
- self.keylist = []
- self.valuelist = []
- if other is not None:
- for (key, value) in other:
- self[key] = value
- for (key, value) in kwargs.iteritems():
- self[key] = value
- def __getitem__(self, key):
- try:
- i = self.keylist.index(key)
- except ValueError:
- raise KeyError
- return self.valuelist[i]
- def __setitem__(self, key, value):
- try:
- i = self.keylist.index(key)
- self.valuelist[i] = value
- except ValueError:
- self.keylist.append(key)
- self.valuelist.append(value)
- def __delitem__(self, key):
- try:
- i = self.keylist.index(key)
- except ValueError:
- raise KeyError
- self.keylist.pop(i)
- self.valuelist.pop(i)
- def keys(self):
- return list(self.keylist)
- def copy(self):
- d = self.__class__()
- for key, value in self.iteritems():
- d[key] = value
- return d
- @classmethod
- def fromkeys(cls, keys, value=None):
- d = cls()
- for key in keys:
- d[key] = value
- return d
-
-class UserDictMixinTest(mapping_tests.TestMappingProtocol):
- type2test = SeqDict
-
- def test_all(self):
- ## Setup test and verify working of the test class
-
- # check init
- s = SeqDict()
-
- # exercise setitem
- s[10] = 'ten'
- s[20] = 'twenty'
- s[30] = 'thirty'
-
- # exercise delitem
- del s[20]
- # check getitem and setitem
- self.assertEqual(s[10], 'ten')
- # check keys() and delitem
- self.assertEqual(s.keys(), [10, 30])
-
- ## Now, test the DictMixin methods one by one
- # has_key
- self.assertTrue(s.has_key(10))
- self.assertTrue(not s.has_key(20))
-
- # __contains__
- self.assertIn(10, s)
- self.assertNotIn(20, s)
-
- # __iter__
- self.assertEqual([k for k in s], [10, 30])
-
- # __len__
- self.assertEqual(len(s), 2)
-
- # iteritems
- self.assertEqual(list(s.iteritems()), [(10,'ten'), (30, 'thirty')])
-
- # iterkeys
- self.assertEqual(list(s.iterkeys()), [10, 30])
-
- # itervalues
- self.assertEqual(list(s.itervalues()), ['ten', 'thirty'])
-
- # values
- self.assertEqual(s.values(), ['ten', 'thirty'])
-
- # items
- self.assertEqual(s.items(), [(10,'ten'), (30, 'thirty')])
-
- # get
- self.assertEqual(s.get(10), 'ten')
- self.assertEqual(s.get(15,'fifteen'), 'fifteen')
- self.assertEqual(s.get(15), None)
-
- # setdefault
- self.assertEqual(s.setdefault(40, 'forty'), 'forty')
- self.assertEqual(s.setdefault(10, 'null'), 'ten')
- del s[40]
-
- # pop
- self.assertEqual(s.pop(10), 'ten')
- self.assertNotIn(10, s)
- s[10] = 'ten'
- self.assertEqual(s.pop("x", 1), 1)
- s["x"] = 42
- self.assertEqual(s.pop("x", 1), 42)
-
- # popitem
- k, v = s.popitem()
- self.assertNotIn(k, s)
- s[k] = v
-
- # clear
- s.clear()
- self.assertEqual(len(s), 0)
-
- # empty popitem
- self.assertRaises(KeyError, s.popitem)
-
- # update
- s.update({10: 'ten', 20:'twenty'})
- self.assertEqual(s[10], 'ten')
- self.assertEqual(s[20], 'twenty')
-
- # cmp
- self.assertEqual(s, {10: 'ten', 20:'twenty'})
- t = SeqDict()
- t[20] = 'twenty'
- t[10] = 'ten'
- self.assertEqual(s, t)
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
UserDictTest,
- UserDictMixinTest
)
if __name__ == "__main__":
diff --git a/Lib/test/test_userlist.py b/Lib/test/test_userlist.py
index 3b601bc955c..868ed24cccd 100644
--- a/Lib/test/test_userlist.py
+++ b/Lib/test/test_userlist.py
@@ -1,19 +1,19 @@
# Check every path through every method of UserList
-from UserList import UserList
-from test import test_support, list_tests
+from collections import UserList
+from test import support, list_tests
class UserListTest(list_tests.CommonTest):
type2test = UserList
def test_getslice(self):
- super(UserListTest, self).test_getslice()
+ super().test_getslice()
l = [0, 1, 2, 3, 4]
u = self.type2test(l)
for i in range(-3, 6):
self.assertEqual(u[:i], l[:i])
self.assertEqual(u[i:], l[i:])
- for j in xrange(-3, 6):
+ for j in range(-3, 6):
self.assertEqual(u[i:j], l[i:j])
def test_add_specials(self):
@@ -29,7 +29,7 @@ class UserListTest(list_tests.CommonTest):
self.assertEqual(u2, list("spameggs"))
def test_iadd(self):
- super(UserListTest, self).test_iadd()
+ super().test_iadd()
u = [0, 1]
u += UserList([0, 1])
self.assertEqual(u, [0, 1, 0, 1])
@@ -50,12 +50,10 @@ class UserListTest(list_tests.CommonTest):
class T(self.type2test):
def __getitem__(self, key):
return str(key) + '!!!'
- self.assertEqual(iter(T((1,2))).next(), "0!!!")
+ self.assertEqual(next(iter(T((1,2)))), "0!!!")
def test_main():
- with test_support.check_py3k_warnings(
- (".+__(get|set|del)slice__ has been removed", DeprecationWarning)):
- test_support.run_unittest(UserListTest)
+ support.run_unittest(UserListTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_userstring.py b/Lib/test/test_userstring.py
index 2625985a7cb..7a8b9323f89 100755
--- a/Lib/test/test_userstring.py
+++ b/Lib/test/test_userstring.py
@@ -1,17 +1,15 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# UserString is a wrapper around the native builtin string type.
# UserString instances should behave similar to builtin string objects.
import string
-from test import test_support, string_tests
-from UserString import UserString, MutableString
-import warnings
+from test import support, string_tests
+
+from collections import UserString
class UserStringTest(
string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
- string_tests.MixinStrStringUserStringTest,
- string_tests.MixinStrUserStringTest
):
type2test = UserString
@@ -43,105 +41,9 @@ class UserStringTest(
# we don't fix the arguments, because UserString can't cope with it
getattr(object, methodname)(*args)
-class MutableStringTest(UserStringTest):
- type2test = MutableString
-
- # MutableStrings can be hashed => deactivate test
- def test_hash(self):
- pass
-
- def test_setitem(self):
- s = self.type2test("foo")
- self.assertRaises(IndexError, s.__setitem__, -4, "bar")
- self.assertRaises(IndexError, s.__setitem__, 3, "bar")
- s[-1] = "bar"
- self.assertEqual(s, "fobar")
- s[0] = "bar"
- self.assertEqual(s, "barobar")
-
- def test_delitem(self):
- s = self.type2test("foo")
- self.assertRaises(IndexError, s.__delitem__, -4)
- self.assertRaises(IndexError, s.__delitem__, 3)
- del s[-1]
- self.assertEqual(s, "fo")
- del s[0]
- self.assertEqual(s, "o")
- del s[0]
- self.assertEqual(s, "")
-
- def test_setslice(self):
- s = self.type2test("foo")
- s[:] = "bar"
- self.assertEqual(s, "bar")
- s[1:2] = "foo"
- self.assertEqual(s, "bfoor")
- s[1:-1] = UserString("a")
- self.assertEqual(s, "bar")
- s[0:10] = 42
- self.assertEqual(s, "42")
-
- def test_delslice(self):
- s = self.type2test("foobar")
- del s[3:10]
- self.assertEqual(s, "foo")
- del s[-1:10]
- self.assertEqual(s, "fo")
-
- def test_extended_set_del_slice(self):
- indices = (0, None, 1, 3, 19, 100, -1, -2, -31, -100)
- orig = string.ascii_letters + string.digits
- for start in indices:
- for stop in indices:
- # Use indices[1:] when MutableString can handle real
- # extended slices
- for step in (None, 1, -1):
- s = self.type2test(orig)
- L = list(orig)
- # Make sure we have a slice of exactly the right length,
- # but with (hopefully) different data.
- data = L[start:stop:step]
- data.reverse()
- L[start:stop:step] = data
- s[start:stop:step] = "".join(data)
- self.assertEqual(s, "".join(L))
-
- del L[start:stop:step]
- del s[start:stop:step]
- self.assertEqual(s, "".join(L))
-
- def test_immutable(self):
- s = self.type2test("foobar")
- s2 = s.immutable()
- self.assertEqual(s, s2)
- self.assertIsInstance(s2, UserString)
-
- def test_iadd(self):
- s = self.type2test("foo")
- s += "bar"
- self.assertEqual(s, "foobar")
- s += UserString("baz")
- self.assertEqual(s, "foobarbaz")
- s += 42
- self.assertEqual(s, "foobarbaz42")
-
- def test_imul(self):
- s = self.type2test("foo")
- s *= 1
- self.assertEqual(s, "foo")
- s *= 2
- self.assertEqual(s, "foofoo")
- s *= -1
- self.assertEqual(s, "")
def test_main():
- with warnings.catch_warnings():
- warnings.filterwarnings("ignore", ".*MutableString has been removed",
- DeprecationWarning)
- warnings.filterwarnings("ignore",
- ".*__(get|set|del)slice__ has been removed",
- DeprecationWarning)
- test_support.run_unittest(UserStringTest, MutableStringTest)
+ support.run_unittest(UserStringTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_uu.py b/Lib/test/test_uu.py
index 31046b07d5f..cbf6724fd2d 100644
--- a/Lib/test/test_uu.py
+++ b/Lib/test/test_uu.py
@@ -4,61 +4,93 @@ Nick Mathewson
"""
import unittest
-from test import test_support
+from test import support
-import sys, os, uu, cStringIO
+import sys, os
import uu
+from io import BytesIO
+import io
-plaintext = "The smooth-scaled python crept over the sleeping dog\n"
+plaintext = b"The smooth-scaled python crept over the sleeping dog\n"
-encodedtext = """\
+encodedtext = b"""\
M5&AE('-M;V]T:\"US8V%L960@<'ET:&]N(&-R97!T(&]V97(@=&AE('-L965P
(:6YG(&1O9PH """
-encodedtextwrapped = "begin %03o %s\n" + encodedtext.replace("%", "%%") + "\n \nend\n"
+# Stolen from io.py
+class FakeIO(io.TextIOWrapper):
+ """Text I/O implementation using an in-memory buffer.
+
+ Can be a used as a drop-in replacement for sys.stdin and sys.stdout.
+ """
+
+ # XXX This is really slow, but fully functional
+
+ def __init__(self, initial_value="", encoding="utf-8",
+ errors="strict", newline="\n"):
+ super(FakeIO, self).__init__(io.BytesIO(),
+ encoding=encoding,
+ errors=errors,
+ newline=newline)
+ self._encoding = encoding
+ self._errors = errors
+ if initial_value:
+ if not isinstance(initial_value, str):
+ initial_value = str(initial_value)
+ self.write(initial_value)
+ self.seek(0)
+
+ def getvalue(self):
+ self.flush()
+ return self.buffer.getvalue().decode(self._encoding, self._errors)
+
+
+def encodedtextwrapped(mode, filename):
+ return (bytes("begin %03o %s\n" % (mode, filename), "ascii") +
+ encodedtext + b"\n \nend\n")
class UUTest(unittest.TestCase):
def test_encode(self):
- inp = cStringIO.StringIO(plaintext)
- out = cStringIO.StringIO()
+ inp = io.BytesIO(plaintext)
+ out = io.BytesIO()
uu.encode(inp, out, "t1")
- self.assertEqual(out.getvalue(), encodedtextwrapped % (0666, "t1"))
- inp = cStringIO.StringIO(plaintext)
- out = cStringIO.StringIO()
- uu.encode(inp, out, "t1", 0644)
- self.assertEqual(out.getvalue(), encodedtextwrapped % (0644, "t1"))
+ self.assertEqual(out.getvalue(), encodedtextwrapped(0o666, "t1"))
+ inp = io.BytesIO(plaintext)
+ out = io.BytesIO()
+ uu.encode(inp, out, "t1", 0o644)
+ self.assertEqual(out.getvalue(), encodedtextwrapped(0o644, "t1"))
def test_decode(self):
- inp = cStringIO.StringIO(encodedtextwrapped % (0666, "t1"))
- out = cStringIO.StringIO()
+ inp = io.BytesIO(encodedtextwrapped(0o666, "t1"))
+ out = io.BytesIO()
uu.decode(inp, out)
self.assertEqual(out.getvalue(), plaintext)
- inp = cStringIO.StringIO(
- "UUencoded files may contain many lines,\n" +
- "even some that have 'begin' in them.\n" +
- encodedtextwrapped % (0666, "t1")
+ inp = io.BytesIO(
+ b"UUencoded files may contain many lines,\n" +
+ b"even some that have 'begin' in them.\n" +
+ encodedtextwrapped(0o666, "t1")
)
- out = cStringIO.StringIO()
+ out = io.BytesIO()
uu.decode(inp, out)
self.assertEqual(out.getvalue(), plaintext)
def test_truncatedinput(self):
- inp = cStringIO.StringIO("begin 644 t1\n" + encodedtext)
- out = cStringIO.StringIO()
+ inp = io.BytesIO(b"begin 644 t1\n" + encodedtext)
+ out = io.BytesIO()
try:
uu.decode(inp, out)
self.fail("No exception raised")
- except uu.Error, e:
+ except uu.Error as e:
self.assertEqual(str(e), "Truncated input file")
def test_missingbegin(self):
- inp = cStringIO.StringIO("")
- out = cStringIO.StringIO()
+ inp = io.BytesIO(b"")
+ out = io.BytesIO()
try:
uu.decode(inp, out)
self.fail("No exception raised")
- except uu.Error, e:
+ except uu.Error as e:
self.assertEqual(str(e), "No valid begin line found in input file")
class UUStdIOTest(unittest.TestCase):
@@ -72,24 +104,27 @@ class UUStdIOTest(unittest.TestCase):
sys.stdout = self.stdout
def test_encode(self):
- sys.stdin = cStringIO.StringIO(plaintext)
- sys.stdout = cStringIO.StringIO()
- uu.encode("-", "-", "t1", 0666)
- self.assertEqual(
- sys.stdout.getvalue(),
- encodedtextwrapped % (0666, "t1")
- )
+ sys.stdin = FakeIO(plaintext.decode("ascii"))
+ sys.stdout = FakeIO()
+ uu.encode("-", "-", "t1", 0o666)
+ self.assertEqual(sys.stdout.getvalue(),
+ encodedtextwrapped(0o666, "t1").decode("ascii"))
def test_decode(self):
- sys.stdin = cStringIO.StringIO(encodedtextwrapped % (0666, "t1"))
- sys.stdout = cStringIO.StringIO()
+ sys.stdin = FakeIO(encodedtextwrapped(0o666, "t1").decode("ascii"))
+ sys.stdout = FakeIO()
uu.decode("-", "-")
- self.assertEqual(sys.stdout.getvalue(), plaintext)
+ stdout = sys.stdout
+ sys.stdout = self.stdout
+ sys.stdin = self.stdin
+ self.assertEqual(stdout.getvalue(), plaintext.decode("ascii"))
class UUFileTest(unittest.TestCase):
def _kill(self, f):
# close and remove file
+ if f is None:
+ return
try:
f.close()
except (SystemExit, KeyboardInterrupt):
@@ -104,8 +139,8 @@ class UUFileTest(unittest.TestCase):
pass
def setUp(self):
- self.tmpin = test_support.TESTFN + "i"
- self.tmpout = test_support.TESTFN + "o"
+ self.tmpin = support.TESTFN + "i"
+ self.tmpout = support.TESTFN + "o"
def tearDown(self):
del self.tmpin
@@ -114,28 +149,28 @@ class UUFileTest(unittest.TestCase):
def test_encode(self):
fin = fout = None
try:
- test_support.unlink(self.tmpin)
+ support.unlink(self.tmpin)
fin = open(self.tmpin, 'wb')
fin.write(plaintext)
fin.close()
fin = open(self.tmpin, 'rb')
- fout = open(self.tmpout, 'w')
- uu.encode(fin, fout, self.tmpin, mode=0644)
+ fout = open(self.tmpout, 'wb')
+ uu.encode(fin, fout, self.tmpin, mode=0o644)
fin.close()
fout.close()
- fout = open(self.tmpout, 'r')
+ fout = open(self.tmpout, 'rb')
s = fout.read()
fout.close()
- self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin))
+ self.assertEqual(s, encodedtextwrapped(0o644, self.tmpin))
# in_file and out_file as filenames
- uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0644)
- fout = open(self.tmpout, 'r')
+ uu.encode(self.tmpin, self.tmpout, self.tmpin, mode=0o644)
+ fout = open(self.tmpout, 'rb')
s = fout.read()
fout.close()
- self.assertEqual(s, encodedtextwrapped % (0644, self.tmpin))
+ self.assertEqual(s, encodedtextwrapped(0o644, self.tmpin))
finally:
self._kill(fin)
@@ -144,16 +179,16 @@ class UUFileTest(unittest.TestCase):
def test_decode(self):
f = None
try:
- test_support.unlink(self.tmpin)
- f = open(self.tmpin, 'w')
- f.write(encodedtextwrapped % (0644, self.tmpout))
+ support.unlink(self.tmpin)
+ f = open(self.tmpin, 'wb')
+ f.write(encodedtextwrapped(0o644, self.tmpout))
f.close()
- f = open(self.tmpin, 'r')
+ f = open(self.tmpin, 'rb')
uu.decode(f)
f.close()
- f = open(self.tmpout, 'r')
+ f = open(self.tmpout, 'rb')
s = f.read()
f.close()
self.assertEqual(s, plaintext)
@@ -164,14 +199,14 @@ class UUFileTest(unittest.TestCase):
def test_decode_filename(self):
f = None
try:
- test_support.unlink(self.tmpin)
- f = open(self.tmpin, 'w')
- f.write(encodedtextwrapped % (0644, self.tmpout))
+ support.unlink(self.tmpin)
+ f = open(self.tmpin, 'wb')
+ f.write(encodedtextwrapped(0o644, self.tmpout))
f.close()
uu.decode(self.tmpin)
- f = open(self.tmpout, 'r')
+ f = open(self.tmpout, 'rb')
s = f.read()
f.close()
self.assertEqual(s, plaintext)
@@ -182,20 +217,23 @@ class UUFileTest(unittest.TestCase):
# Verify that decode() will refuse to overwrite an existing file
f = None
try:
- f = cStringIO.StringIO(encodedtextwrapped % (0644, self.tmpout))
+ f = io.BytesIO(encodedtextwrapped(0o644, self.tmpout))
- f = open(self.tmpin, 'r')
+ f = open(self.tmpin, 'rb')
uu.decode(f)
f.close()
- f = open(self.tmpin, 'r')
+ f = open(self.tmpin, 'rb')
self.assertRaises(uu.Error, uu.decode, f)
f.close()
finally:
self._kill(f)
def test_main():
- test_support.run_unittest(UUTest, UUStdIOTest, UUFileTest)
+ support.run_unittest(UUTest,
+ UUStdIOTest,
+ UUFileTest,
+ )
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_uuid.py b/Lib/test/test_uuid.py
index e5030849184..43fa6561023 100644
--- a/Lib/test/test_uuid.py
+++ b/Lib/test/test_uuid.py
@@ -1,5 +1,6 @@
from unittest import TestCase
-from test import test_support
+from test import support
+import builtins
import uuid
def importable(name):
@@ -21,8 +22,8 @@ class TestUUID(TestCase):
('00000000-0000-0000-0000-000000000000',
'{00000000-0000-0000-0000-000000000000}',
'00000000000000000000000000000000',
- '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
- '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+ b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
+ b'\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0',
(0, 0, 0, 0, 0, 0),
0,
'urn:uuid:00000000-0000-0000-0000-000000000000',
@@ -30,120 +31,120 @@ class TestUUID(TestCase):
('00010203-0405-0607-0809-0a0b0c0d0e0f',
'{00010203-0405-0607-0809-0a0b0c0d0e0f}',
'000102030405060708090a0b0c0d0e0f',
- '\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\x0d\x0e\x0f',
- '\x03\x02\x01\0\x05\x04\x07\x06\x08\t\n\x0b\x0c\x0d\x0e\x0f',
- (0x00010203L, 0x0405, 0x0607, 8, 9, 0x0a0b0c0d0e0fL),
- 0x000102030405060708090a0b0c0d0e0fL,
+ b'\0\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\x0d\x0e\x0f',
+ b'\x03\x02\x01\0\x05\x04\x07\x06\x08\t\n\x0b\x0c\x0d\x0e\x0f',
+ (0x00010203, 0x0405, 0x0607, 8, 9, 0x0a0b0c0d0e0f),
+ 0x000102030405060708090a0b0c0d0e0f,
'urn:uuid:00010203-0405-0607-0809-0a0b0c0d0e0f',
- 0x607040500010203L, 0x809, uuid.RESERVED_NCS, None),
+ 0x607040500010203, 0x809, uuid.RESERVED_NCS, None),
('02d9e6d5-9467-382e-8f9b-9300a64ac3cd',
'{02d9e6d5-9467-382e-8f9b-9300a64ac3cd}',
'02d9e6d59467382e8f9b9300a64ac3cd',
- '\x02\xd9\xe6\xd5\x94\x67\x38\x2e\x8f\x9b\x93\x00\xa6\x4a\xc3\xcd',
- '\xd5\xe6\xd9\x02\x67\x94\x2e\x38\x8f\x9b\x93\x00\xa6\x4a\xc3\xcd',
- (0x02d9e6d5L, 0x9467, 0x382e, 0x8f, 0x9b, 0x9300a64ac3cdL),
- 0x02d9e6d59467382e8f9b9300a64ac3cdL,
+ b'\x02\xd9\xe6\xd5\x94\x67\x38\x2e\x8f\x9b\x93\x00\xa6\x4a\xc3\xcd',
+ b'\xd5\xe6\xd9\x02\x67\x94\x2e\x38\x8f\x9b\x93\x00\xa6\x4a\xc3\xcd',
+ (0x02d9e6d5, 0x9467, 0x382e, 0x8f, 0x9b, 0x9300a64ac3cd),
+ 0x02d9e6d59467382e8f9b9300a64ac3cd,
'urn:uuid:02d9e6d5-9467-382e-8f9b-9300a64ac3cd',
- 0x82e946702d9e6d5L, 0xf9b, uuid.RFC_4122, 3),
+ 0x82e946702d9e6d5, 0xf9b, uuid.RFC_4122, 3),
('12345678-1234-5678-1234-567812345678',
'{12345678-1234-5678-1234-567812345678}',
'12345678123456781234567812345678',
- '\x12\x34\x56\x78'*4,
- '\x78\x56\x34\x12\x34\x12\x78\x56\x12\x34\x56\x78\x12\x34\x56\x78',
+ b'\x12\x34\x56\x78'*4,
+ b'\x78\x56\x34\x12\x34\x12\x78\x56\x12\x34\x56\x78\x12\x34\x56\x78',
(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678),
0x12345678123456781234567812345678,
'urn:uuid:12345678-1234-5678-1234-567812345678',
- 0x678123412345678L, 0x1234, uuid.RESERVED_NCS, None),
+ 0x678123412345678, 0x1234, uuid.RESERVED_NCS, None),
('6ba7b810-9dad-11d1-80b4-00c04fd430c8',
'{6ba7b810-9dad-11d1-80b4-00c04fd430c8}',
'6ba7b8109dad11d180b400c04fd430c8',
- '\x6b\xa7\xb8\x10\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- '\x10\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- (0x6ba7b810L, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8L),
- 0x6ba7b8109dad11d180b400c04fd430c8L,
+ b'\x6b\xa7\xb8\x10\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ b'\x10\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ (0x6ba7b810, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8),
+ 0x6ba7b8109dad11d180b400c04fd430c8,
'urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8',
- 0x1d19dad6ba7b810L, 0xb4, uuid.RFC_4122, 1),
+ 0x1d19dad6ba7b810, 0xb4, uuid.RFC_4122, 1),
('6ba7b811-9dad-11d1-80b4-00c04fd430c8',
'{6ba7b811-9dad-11d1-80b4-00c04fd430c8}',
'6ba7b8119dad11d180b400c04fd430c8',
- '\x6b\xa7\xb8\x11\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- '\x11\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- (0x6ba7b811L, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8L),
- 0x6ba7b8119dad11d180b400c04fd430c8L,
+ b'\x6b\xa7\xb8\x11\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ b'\x11\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ (0x6ba7b811, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8),
+ 0x6ba7b8119dad11d180b400c04fd430c8,
'urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8',
- 0x1d19dad6ba7b811L, 0xb4, uuid.RFC_4122, 1),
+ 0x1d19dad6ba7b811, 0xb4, uuid.RFC_4122, 1),
('6ba7b812-9dad-11d1-80b4-00c04fd430c8',
'{6ba7b812-9dad-11d1-80b4-00c04fd430c8}',
'6ba7b8129dad11d180b400c04fd430c8',
- '\x6b\xa7\xb8\x12\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- '\x12\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- (0x6ba7b812L, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8L),
- 0x6ba7b8129dad11d180b400c04fd430c8L,
+ b'\x6b\xa7\xb8\x12\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ b'\x12\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ (0x6ba7b812, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8),
+ 0x6ba7b8129dad11d180b400c04fd430c8,
'urn:uuid:6ba7b812-9dad-11d1-80b4-00c04fd430c8',
- 0x1d19dad6ba7b812L, 0xb4, uuid.RFC_4122, 1),
+ 0x1d19dad6ba7b812, 0xb4, uuid.RFC_4122, 1),
('6ba7b814-9dad-11d1-80b4-00c04fd430c8',
'{6ba7b814-9dad-11d1-80b4-00c04fd430c8}',
'6ba7b8149dad11d180b400c04fd430c8',
- '\x6b\xa7\xb8\x14\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- '\x14\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
- (0x6ba7b814L, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8L),
- 0x6ba7b8149dad11d180b400c04fd430c8L,
+ b'\x6b\xa7\xb8\x14\x9d\xad\x11\xd1\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ b'\x14\xb8\xa7\x6b\xad\x9d\xd1\x11\x80\xb4\x00\xc0\x4f\xd4\x30\xc8',
+ (0x6ba7b814, 0x9dad, 0x11d1, 0x80, 0xb4, 0x00c04fd430c8),
+ 0x6ba7b8149dad11d180b400c04fd430c8,
'urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8',
- 0x1d19dad6ba7b814L, 0xb4, uuid.RFC_4122, 1),
+ 0x1d19dad6ba7b814, 0xb4, uuid.RFC_4122, 1),
('7d444840-9dc0-11d1-b245-5ffdce74fad2',
'{7d444840-9dc0-11d1-b245-5ffdce74fad2}',
'7d4448409dc011d1b2455ffdce74fad2',
- '\x7d\x44\x48\x40\x9d\xc0\x11\xd1\xb2\x45\x5f\xfd\xce\x74\xfa\xd2',
- '\x40\x48\x44\x7d\xc0\x9d\xd1\x11\xb2\x45\x5f\xfd\xce\x74\xfa\xd2',
- (0x7d444840L, 0x9dc0, 0x11d1, 0xb2, 0x45, 0x5ffdce74fad2L),
- 0x7d4448409dc011d1b2455ffdce74fad2L,
+ b'\x7d\x44\x48\x40\x9d\xc0\x11\xd1\xb2\x45\x5f\xfd\xce\x74\xfa\xd2',
+ b'\x40\x48\x44\x7d\xc0\x9d\xd1\x11\xb2\x45\x5f\xfd\xce\x74\xfa\xd2',
+ (0x7d444840, 0x9dc0, 0x11d1, 0xb2, 0x45, 0x5ffdce74fad2),
+ 0x7d4448409dc011d1b2455ffdce74fad2,
'urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2',
- 0x1d19dc07d444840L, 0x3245, uuid.RFC_4122, 1),
+ 0x1d19dc07d444840, 0x3245, uuid.RFC_4122, 1),
('e902893a-9d22-3c7e-a7b8-d6e313b71d9f',
'{e902893a-9d22-3c7e-a7b8-d6e313b71d9f}',
'e902893a9d223c7ea7b8d6e313b71d9f',
- '\xe9\x02\x89\x3a\x9d\x22\x3c\x7e\xa7\xb8\xd6\xe3\x13\xb7\x1d\x9f',
- '\x3a\x89\x02\xe9\x22\x9d\x7e\x3c\xa7\xb8\xd6\xe3\x13\xb7\x1d\x9f',
- (0xe902893aL, 0x9d22, 0x3c7e, 0xa7, 0xb8, 0xd6e313b71d9fL),
- 0xe902893a9d223c7ea7b8d6e313b71d9fL,
+ b'\xe9\x02\x89\x3a\x9d\x22\x3c\x7e\xa7\xb8\xd6\xe3\x13\xb7\x1d\x9f',
+ b'\x3a\x89\x02\xe9\x22\x9d\x7e\x3c\xa7\xb8\xd6\xe3\x13\xb7\x1d\x9f',
+ (0xe902893a, 0x9d22, 0x3c7e, 0xa7, 0xb8, 0xd6e313b71d9f),
+ 0xe902893a9d223c7ea7b8d6e313b71d9f,
'urn:uuid:e902893a-9d22-3c7e-a7b8-d6e313b71d9f',
- 0xc7e9d22e902893aL, 0x27b8, uuid.RFC_4122, 3),
+ 0xc7e9d22e902893a, 0x27b8, uuid.RFC_4122, 3),
('eb424026-6f54-4ef8-a4d0-bb658a1fc6cf',
'{eb424026-6f54-4ef8-a4d0-bb658a1fc6cf}',
'eb4240266f544ef8a4d0bb658a1fc6cf',
- '\xeb\x42\x40\x26\x6f\x54\x4e\xf8\xa4\xd0\xbb\x65\x8a\x1f\xc6\xcf',
- '\x26\x40\x42\xeb\x54\x6f\xf8\x4e\xa4\xd0\xbb\x65\x8a\x1f\xc6\xcf',
- (0xeb424026L, 0x6f54, 0x4ef8, 0xa4, 0xd0, 0xbb658a1fc6cfL),
- 0xeb4240266f544ef8a4d0bb658a1fc6cfL,
+ b'\xeb\x42\x40\x26\x6f\x54\x4e\xf8\xa4\xd0\xbb\x65\x8a\x1f\xc6\xcf',
+ b'\x26\x40\x42\xeb\x54\x6f\xf8\x4e\xa4\xd0\xbb\x65\x8a\x1f\xc6\xcf',
+ (0xeb424026, 0x6f54, 0x4ef8, 0xa4, 0xd0, 0xbb658a1fc6cf),
+ 0xeb4240266f544ef8a4d0bb658a1fc6cf,
'urn:uuid:eb424026-6f54-4ef8-a4d0-bb658a1fc6cf',
- 0xef86f54eb424026L, 0x24d0, uuid.RFC_4122, 4),
+ 0xef86f54eb424026, 0x24d0, uuid.RFC_4122, 4),
('f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
'{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}',
'f81d4fae7dec11d0a76500a0c91e6bf6',
- '\xf8\x1d\x4f\xae\x7d\xec\x11\xd0\xa7\x65\x00\xa0\xc9\x1e\x6b\xf6',
- '\xae\x4f\x1d\xf8\xec\x7d\xd0\x11\xa7\x65\x00\xa0\xc9\x1e\x6b\xf6',
- (0xf81d4faeL, 0x7dec, 0x11d0, 0xa7, 0x65, 0x00a0c91e6bf6L),
- 0xf81d4fae7dec11d0a76500a0c91e6bf6L,
+ b'\xf8\x1d\x4f\xae\x7d\xec\x11\xd0\xa7\x65\x00\xa0\xc9\x1e\x6b\xf6',
+ b'\xae\x4f\x1d\xf8\xec\x7d\xd0\x11\xa7\x65\x00\xa0\xc9\x1e\x6b\xf6',
+ (0xf81d4fae, 0x7dec, 0x11d0, 0xa7, 0x65, 0x00a0c91e6bf6),
+ 0xf81d4fae7dec11d0a76500a0c91e6bf6,
'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
- 0x1d07decf81d4faeL, 0x2765, uuid.RFC_4122, 1),
+ 0x1d07decf81d4fae, 0x2765, uuid.RFC_4122, 1),
('fffefdfc-fffe-fffe-fffe-fffefdfcfbfa',
'{fffefdfc-fffe-fffe-fffe-fffefdfcfbfa}',
'fffefdfcfffefffefffefffefdfcfbfa',
- '\xff\xfe\xfd\xfc\xff\xfe\xff\xfe\xff\xfe\xff\xfe\xfd\xfc\xfb\xfa',
- '\xfc\xfd\xfe\xff\xfe\xff\xfe\xff\xff\xfe\xff\xfe\xfd\xfc\xfb\xfa',
- (0xfffefdfcL, 0xfffe, 0xfffe, 0xff, 0xfe, 0xfffefdfcfbfaL),
- 0xfffefdfcfffefffefffefffefdfcfbfaL,
+ b'\xff\xfe\xfd\xfc\xff\xfe\xff\xfe\xff\xfe\xff\xfe\xfd\xfc\xfb\xfa',
+ b'\xfc\xfd\xfe\xff\xfe\xff\xfe\xff\xff\xfe\xff\xfe\xfd\xfc\xfb\xfa',
+ (0xfffefdfc, 0xfffe, 0xfffe, 0xff, 0xfe, 0xfffefdfcfbfa),
+ 0xfffefdfcfffefffefffefffefdfcfbfa,
'urn:uuid:fffefdfc-fffe-fffe-fffe-fffefdfcfbfa',
- 0xffefffefffefdfcL, 0x3ffe, uuid.RESERVED_FUTURE, None),
+ 0xffefffefffefdfc, 0x3ffe, uuid.RESERVED_FUTURE, None),
('ffffffff-ffff-ffff-ffff-ffffffffffff',
'{ffffffff-ffff-ffff-ffff-ffffffffffff}',
'ffffffffffffffffffffffffffffffff',
- '\xff'*16,
- '\xff'*16,
- (0xffffffffL, 0xffffL, 0xffffL, 0xff, 0xff, 0xffffffffffffL),
- 0xffffffffffffffffffffffffffffffffL,
+ b'\xff'*16,
+ b'\xff'*16,
+ (0xffffffff, 0xffff, 0xffff, 0xff, 0xff, 0xffffffffffff),
+ 0xffffffffffffffffffffffffffffffff,
'urn:uuid:ffffffff-ffff-ffff-ffff-ffffffffffff',
- 0xfffffffffffffffL, 0x3fff, uuid.RESERVED_FUTURE, None),
+ 0xfffffffffffffff, 0x3fff, uuid.RESERVED_FUTURE, None),
]:
equivalents = []
# Construct each UUID in several different ways.
@@ -176,12 +177,22 @@ class TestUUID(TestCase):
for u in equivalents:
for v in equivalents:
equal(u, v)
+
+ # Bug 7380: "bytes" and "bytes_le" should give the same type.
+ equal(type(u.bytes), builtins.bytes)
+ equal(type(u.bytes_le), builtins.bytes)
+
ascending.append(u)
# Test comparison of UUIDs.
for i in range(len(ascending)):
for j in range(len(ascending)):
- equal(cmp(i, j), cmp(ascending[i], ascending[j]))
+ equal(i < j, ascending[i] < ascending[j])
+ equal(i <= j, ascending[i] <= ascending[j])
+ equal(i == j, ascending[i] == ascending[j])
+ equal(i > j, ascending[i] > ascending[j])
+ equal(i >= j, ascending[i] >= ascending[j])
+ equal(i != j, ascending[i] != ascending[j])
# Test sorting of UUIDs (above list is in ascending order).
resorted = ascending[:]
@@ -217,17 +228,17 @@ class TestUUID(TestCase):
# Field values out of range.
badvalue(lambda: uuid.UUID(fields=(-1, 0, 0, 0, 0, 0)))
- badvalue(lambda: uuid.UUID(fields=(0x100000000L, 0, 0, 0, 0, 0)))
+ badvalue(lambda: uuid.UUID(fields=(0x100000000, 0, 0, 0, 0, 0)))
badvalue(lambda: uuid.UUID(fields=(0, -1, 0, 0, 0, 0)))
- badvalue(lambda: uuid.UUID(fields=(0, 0x10000L, 0, 0, 0, 0)))
+ badvalue(lambda: uuid.UUID(fields=(0, 0x10000, 0, 0, 0, 0)))
badvalue(lambda: uuid.UUID(fields=(0, 0, -1, 0, 0, 0)))
- badvalue(lambda: uuid.UUID(fields=(0, 0, 0x10000L, 0, 0, 0)))
+ badvalue(lambda: uuid.UUID(fields=(0, 0, 0x10000, 0, 0, 0)))
badvalue(lambda: uuid.UUID(fields=(0, 0, 0, -1, 0, 0)))
- badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0x100L, 0, 0)))
+ badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0x100, 0, 0)))
badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, -1, 0)))
- badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, 0x100L, 0)))
+ badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, 0x100, 0)))
badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, 0, -1)))
- badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, 0, 0x1000000000000L)))
+ badvalue(lambda: uuid.UUID(fields=(0, 0, 0, 0, 0, 0x1000000000000)))
# Version number out of range.
badvalue(lambda: uuid.UUID('00'*16, version=0))
@@ -235,10 +246,10 @@ class TestUUID(TestCase):
# Integer value out of range.
badvalue(lambda: uuid.UUID(int=-1))
- badvalue(lambda: uuid.UUID(int=1<<128L))
+ badvalue(lambda: uuid.UUID(int=1<<128))
# Must supply exactly one of hex, bytes, fields, int.
- h, b, f, i = '00'*16, '\0'*16, (0, 0, 0, 0, 0, 0), 0
+ h, b, f, i = '00'*16, b'\0'*16, (0, 0, 0, 0, 0, 0), 0
uuid.UUID(h)
uuid.UUID(hex=h)
uuid.UUID(bytes=b)
@@ -283,13 +294,13 @@ class TestUUID(TestCase):
def check_node(self, node, source):
message = "%012x is not an RFC 4122 node ID" % node
self.assertTrue(0 < node, message)
- self.assertTrue(node < (1L << 48), message)
+ self.assertTrue(node < (1 << 48), message)
TestUUID.source2node[source] = node
if TestUUID.last_node:
if TestUUID.last_node != node:
msg = "different sources disagree on node:\n"
- for s, n in TestUUID.source2node.iteritems():
+ for s, n in TestUUID.source2node.items():
msg += " from source %r, node was %012x\n" % (s, n)
# There's actually no reason to expect the MAC addresses
# to agree across various methods -- e.g., a box may have
@@ -322,7 +333,7 @@ class TestUUID(TestCase):
node = uuid._random_getnode()
# Least significant bit of first octet must be set.
self.assertTrue(node & 0x010000000000)
- self.assertTrue(node < (1L << 48))
+ self.assertTrue(node < (1 << 48))
def test_unixdll_getnode(self):
import sys
@@ -460,14 +471,14 @@ class TestUUID(TestCase):
if pid == 0:
os.close(fds[0])
value = uuid.uuid4()
- os.write(fds[1], value.hex)
+ os.write(fds[1], value.hex.encode('latin1'))
os._exit(0)
else:
os.close(fds[1])
parent_value = uuid.uuid4().hex
os.waitpid(pid, 0)
- child_value = os.read(fds[0], 100)
+ child_value = os.read(fds[0], 100).decode('latin1')
self.assertNotEqual(parent_value, child_value)
@@ -476,7 +487,7 @@ class TestUUID(TestCase):
def test_main():
- test_support.run_unittest(TestUUID)
+ support.run_unittest(TestUUID)
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_wait3.py b/Lib/test/test_wait3.py
index 150783b6555..786e60b3272 100644
--- a/Lib/test/test_wait3.py
+++ b/Lib/test/test_wait3.py
@@ -5,17 +5,17 @@ import os
import time
import unittest
from test.fork_wait import ForkWait
-from test.test_support import run_unittest, reap_children
+from test.support import run_unittest, reap_children
try:
os.fork
except AttributeError:
- raise unittest.SkipTest, "os.fork not defined -- skipping test_wait3"
+ raise unittest.SkipTest("os.fork not defined -- skipping test_wait3")
try:
os.wait3
except AttributeError:
- raise unittest.SkipTest, "os.wait3 not defined -- skipping test_wait3"
+ raise unittest.SkipTest("os.wait3 not defined -- skipping test_wait3")
class Wait3Test(ForkWait):
def wait_impl(self, cpid):
diff --git a/Lib/test/test_wait4.py b/Lib/test/test_wait4.py
index d04a11bde10..cdcd0604b7c 100644
--- a/Lib/test/test_wait4.py
+++ b/Lib/test/test_wait4.py
@@ -4,7 +4,7 @@
import os
import time
from test.fork_wait import ForkWait
-from test.test_support import run_unittest, reap_children, get_attribute
+from test.support import run_unittest, reap_children, get_attribute
# If either of these do not exist, skip this test.
get_attribute(os, 'fork')
diff --git a/Lib/test/test_warnings.py b/Lib/test/test_warnings.py
index e502ed8f222..79be835bbdd 100644
--- a/Lib/test/test_warnings.py
+++ b/Lib/test/test_warnings.py
@@ -1,19 +1,19 @@
from contextlib import contextmanager
import linecache
import os
-import StringIO
+from io import StringIO
import sys
import unittest
import subprocess
-from test import test_support
+from test import support
from test.script_helper import assert_python_ok
-import warning_tests
+from test import warning_tests
import warnings as original_warnings
-py_warnings = test_support.import_fresh_module('warnings', blocked=['_warnings'])
-c_warnings = test_support.import_fresh_module('warnings', fresh=['_warnings'])
+py_warnings = support.import_fresh_module('warnings', blocked=['_warnings'])
+c_warnings = support.import_fresh_module('warnings', fresh=['_warnings'])
@contextmanager
def warnings_state(module):
@@ -99,7 +99,7 @@ class FilterTests(object):
self.module.resetwarnings()
self.module.filterwarnings("default", category=UserWarning)
message = UserWarning("FilterTests.test_default")
- for x in xrange(2):
+ for x in range(2):
self.module.warn(message, UserWarning)
if x == 0:
self.assertEqual(w[-1].message, message)
@@ -207,6 +207,18 @@ class WarnTests(unittest.TestCase):
self.assertEqual(str(w[-1].message), text)
self.assertTrue(w[-1].category is UserWarning)
+ # Issue 3639
+ def test_warn_nonstandard_types(self):
+ # warn() should handle non-standard types without issue.
+ for ob in (Warning, None, 42):
+ with original_warnings.catch_warnings(record=True,
+ module=self.module) as w:
+ self.module.simplefilter("once")
+ self.module.warn(ob)
+ # Don't directly compare objects since
+ # ``Warning() != Warning()``.
+ self.assertEqual(str(w[-1].message), str(UserWarning(ob)))
+
def test_filename(self):
with warnings_state(self.module):
with original_warnings.catch_warnings(record=True,
@@ -352,19 +364,19 @@ class CWarnTests(BaseTest, WarnTests):
module = c_warnings
# As an early adopter, we sanity check the
- # test_support.import_fresh_module utility function
+ # test.support.import_fresh_module utility function
def test_accelerated(self):
self.assertFalse(original_warnings is self.module)
- self.assertFalse(hasattr(self.module.warn, 'func_code'))
+ self.assertFalse(hasattr(self.module.warn, '__code__'))
class PyWarnTests(BaseTest, WarnTests):
module = py_warnings
# As an early adopter, we sanity check the
- # test_support.import_fresh_module utility function
+ # test.support.import_fresh_module utility function
def test_pure_python(self):
self.assertFalse(original_warnings is self.module)
- self.assertTrue(hasattr(self.module.warn, 'func_code'))
+ self.assertTrue(hasattr(self.module.warn, '__code__'))
class WCmdLineTests(unittest.TestCase):
@@ -492,7 +504,7 @@ class _WarningsTests(BaseTest):
with original_warnings.catch_warnings(module=self.module):
self.module.filterwarnings("always", category=UserWarning)
del self.module.showwarning
- with test_support.captured_output('stderr') as stream:
+ with support.captured_output('stderr') as stream:
self.module.warn(text)
result = stream.getvalue()
self.assertIn(text, result)
@@ -513,7 +525,7 @@ class _WarningsTests(BaseTest):
with original_warnings.catch_warnings(module=self.module):
self.module.filterwarnings("always", category=UserWarning)
del self.module.showwarning
- with test_support.captured_output('stderr') as stream:
+ with support.captured_output('stderr') as stream:
warning_tests.inner(text)
result = stream.getvalue()
self.assertEqual(result.count('\n'), 2,
@@ -538,7 +550,7 @@ class _WarningsTests(BaseTest):
with original_warnings.catch_warnings(module=self.module) as w:
self.module.filterwarnings("always", category=UserWarning)
globals_dict['__file__'] = None
- self.module.warn('test', UserWarning)
+ original_warnings.warn('test', UserWarning)
finally:
globals_dict['__file__'] = oldfile
@@ -572,7 +584,7 @@ class WarningsDisplayTests(unittest.TestCase):
expected_file_line = linecache.getline(file_name, line_num).strip()
message = 'msg'
category = Warning
- file_object = StringIO.StringIO()
+ file_object = StringIO()
expect = self.module.formatwarning(message, category, file_name,
line_num)
self.module.showwarning(message, category, file_name, line_num,
@@ -582,7 +594,7 @@ class WarningsDisplayTests(unittest.TestCase):
expected_file_line += "for the win!"
expect = self.module.formatwarning(message, category, file_name,
line_num, expected_file_line)
- file_object = StringIO.StringIO()
+ file_object = StringIO()
self.module.showwarning(message, category, file_name, line_num,
file_object, expected_file_line)
self.assertEqual(expect, file_object.getvalue())
@@ -666,11 +678,11 @@ class CatchWarningTests(BaseTest):
self.assertTrue(wmod.filters is orig_filters)
def test_check_warnings(self):
- # Explicit tests for the test_support convenience wrapper
+ # Explicit tests for the test.support convenience wrapper
wmod = self.module
if wmod is not sys.modules['warnings']:
return
- with test_support.check_warnings(quiet=False) as w:
+ with support.check_warnings(quiet=False) as w:
self.assertEqual(w.warnings, [])
wmod.simplefilter("always")
wmod.warn("foo")
@@ -682,21 +694,20 @@ class CatchWarningTests(BaseTest):
w.reset()
self.assertEqual(w.warnings, [])
- with test_support.check_warnings():
+ with support.check_warnings():
# defaults to quiet=True without argument
pass
- with test_support.check_warnings(('foo', UserWarning)):
+ with support.check_warnings(('foo', UserWarning)):
wmod.warn("foo")
with self.assertRaises(AssertionError):
- with test_support.check_warnings(('', RuntimeWarning)):
+ with support.check_warnings(('', RuntimeWarning)):
# defaults to quiet=False with argument
pass
with self.assertRaises(AssertionError):
- with test_support.check_warnings(('foo', RuntimeWarning)):
+ with support.check_warnings(('foo', RuntimeWarning)):
wmod.warn("foo")
-
class CCatchWarningTests(CatchWarningTests):
module = c_warnings
@@ -712,7 +723,7 @@ class EnvironmentVariableTests(BaseTest):
p = subprocess.Popen([sys.executable,
"-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
stdout=subprocess.PIPE, env=newenv)
- self.assertEqual(p.communicate()[0], "['ignore::DeprecationWarning']")
+ self.assertEqual(p.communicate()[0], b"['ignore::DeprecationWarning']")
self.assertEqual(p.wait(), 0)
def test_comma_separated_warnings(self):
@@ -723,7 +734,7 @@ class EnvironmentVariableTests(BaseTest):
"-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
stdout=subprocess.PIPE, env=newenv)
self.assertEqual(p.communicate()[0],
- "['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
+ b"['ignore::DeprecationWarning', 'ignore::UnicodeWarning']")
self.assertEqual(p.wait(), 0)
def test_envvar_and_command_line(self):
@@ -733,7 +744,20 @@ class EnvironmentVariableTests(BaseTest):
"-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
stdout=subprocess.PIPE, env=newenv)
self.assertEqual(p.communicate()[0],
- "['ignore::UnicodeWarning', 'ignore::DeprecationWarning']")
+ b"['ignore::UnicodeWarning', 'ignore::DeprecationWarning']")
+ self.assertEqual(p.wait(), 0)
+
+ @unittest.skipUnless(sys.getfilesystemencoding() != 'ascii',
+ 'requires non-ascii filesystemencoding')
+ def test_nonascii(self):
+ newenv = os.environ.copy()
+ newenv["PYTHONWARNINGS"] = "ignore:DeprecaciónWarning"
+ newenv["PYTHONIOENCODING"] = "utf-8"
+ p = subprocess.Popen([sys.executable,
+ "-c", "import sys; sys.stdout.write(str(sys.warnoptions))"],
+ stdout=subprocess.PIPE, env=newenv)
+ self.assertEqual(p.communicate()[0],
+ "['ignore:DeprecaciónWarning']".encode('utf-8'))
self.assertEqual(p.wait(), 0)
class CEnvironmentVariableTests(EnvironmentVariableTests):
@@ -743,18 +767,38 @@ class PyEnvironmentVariableTests(EnvironmentVariableTests):
module = py_warnings
+class BootstrapTest(unittest.TestCase):
+ def test_issue_8766(self):
+ # "import encodings" emits a warning whereas the warnings is not loaded
+ # or not completely loaded (warnings imports indirectly encodings by
+ # importing linecache) yet
+ with support.temp_cwd() as cwd, support.temp_cwd('encodings'):
+ env = os.environ.copy()
+ env['PYTHONPATH'] = cwd
+
+ # encodings loaded by initfsencoding()
+ retcode = subprocess.call([sys.executable, '-c', 'pass'], env=env)
+ self.assertEqual(retcode, 0)
+
+ # Use -W to load warnings module at startup
+ retcode = subprocess.call(
+ [sys.executable, '-c', 'pass', '-W', 'always'],
+ env=env)
+ self.assertEqual(retcode, 0)
+
def test_main():
py_warnings.onceregistry.clear()
c_warnings.onceregistry.clear()
- test_support.run_unittest(CFilterTests, PyFilterTests,
- CWarnTests, PyWarnTests,
- CWCmdLineTests, PyWCmdLineTests,
- _WarningsTests,
- CWarningsDisplayTests, PyWarningsDisplayTests,
- CCatchWarningTests, PyCatchWarningTests,
- CEnvironmentVariableTests,
- PyEnvironmentVariableTests
- )
+ support.run_unittest(
+ CFilterTests, PyFilterTests,
+ CWarnTests, PyWarnTests,
+ CWCmdLineTests, PyWCmdLineTests,
+ _WarningsTests,
+ CWarningsDisplayTests, PyWarningsDisplayTests,
+ CCatchWarningTests, PyCatchWarningTests,
+ CEnvironmentVariableTests, PyEnvironmentVariableTests,
+ BootstrapTest,
+ )
if __name__ == "__main__":
diff --git a/Lib/test/test_wave.py b/Lib/test/test_wave.py
index 02f5fae4df3..e0aace495c8 100644
--- a/Lib/test/test_wave.py
+++ b/Lib/test/test_wave.py
@@ -1,6 +1,7 @@
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
import os
import wave
+import struct
import unittest
nchannels = 2
@@ -21,13 +22,16 @@ class TestWave(unittest.TestCase):
except OSError:
pass
- def test_it(self):
+ def test_it(self, test_rounding=False):
self.f = wave.open(TESTFN, 'wb')
self.f.setnchannels(nchannels)
self.f.setsampwidth(sampwidth)
- self.f.setframerate(framerate)
+ if test_rounding:
+ self.f.setframerate(framerate - 0.1)
+ else:
+ self.f.setframerate(framerate)
self.f.setnframes(nframes)
- output = '\0' * nframes * nchannels * sampwidth
+ output = b'\0' * nframes * nchannels * sampwidth
self.f.writeframes(output)
self.f.close()
@@ -38,6 +42,23 @@ class TestWave(unittest.TestCase):
self.assertEqual(nframes, self.f.getnframes())
self.assertEqual(self.f.readframes(nframes), output)
+ def test_fractional_framerate(self):
+ """
+ Addresses [ 1512791 ] module wave does no rounding
+ Floating point framerates should be rounded, rather than truncated.
+ """
+ self.test_it(test_rounding=True)
+
+ def test_issue7681(self):
+ self.f = wave.open(TESTFN, 'wb')
+ self.f.setnchannels(nchannels)
+ self.f.setsampwidth(sampwidth)
+ self.f.setframerate(framerate)
+ # Don't call setnframes, make _write_header divide to figure it out
+ output = b'\0' * nframes * nchannels * sampwidth
+ self.f.writeframes(output)
+
+
def test_main():
run_unittest(TestWave)
diff --git a/Lib/test/test_weakref.py b/Lib/test/test_weakref.py
index 3d86cb7eeb5..571e33f492d 100644
--- a/Lib/test/test_weakref.py
+++ b/Lib/test/test_weakref.py
@@ -1,11 +1,13 @@
import gc
import sys
import unittest
-import UserList
+import collections
import weakref
import operator
+import contextlib
+import copy
-from test import test_support
+from test import support
# Used in ReferencesTestCase.test_ref_created_during_del() .
ref_from_del = None
@@ -29,9 +31,6 @@ def create_function():
def create_bound_method():
return C().method
-def create_unbound_method():
- return C.method
-
class Object:
def __init__(self, arg):
@@ -42,9 +41,9 @@ class Object:
if isinstance(other, Object):
return self.arg == other.arg
return NotImplemented
- def __ne__(self, other):
+ def __lt__(self, other):
if isinstance(other, Object):
- return self.arg != other.arg
+ return self.arg < other.arg
return NotImplemented
def __hash__(self):
return hash(self.arg)
@@ -69,7 +68,6 @@ class ReferencesTestCase(TestBase):
self.check_basic_ref(C)
self.check_basic_ref(create_function)
self.check_basic_ref(create_bound_method)
- self.check_basic_ref(create_unbound_method)
# Just make sure the tp_repr handler doesn't raise an exception.
# Live reference:
@@ -84,7 +82,6 @@ class ReferencesTestCase(TestBase):
self.check_basic_callback(C)
self.check_basic_callback(create_function)
self.check_basic_callback(create_bound_method)
- self.check_basic_callback(create_unbound_method)
def test_multiple_callbacks(self):
o = C()
@@ -126,10 +123,10 @@ class ReferencesTestCase(TestBase):
def check(proxy):
proxy.bar
- self.assertRaises(weakref.ReferenceError, check, ref1)
- self.assertRaises(weakref.ReferenceError, check, ref2)
- self.assertRaises(weakref.ReferenceError, bool, weakref.proxy(C()))
- self.assertTrue(self.cbcalled == 2)
+ self.assertRaises(ReferenceError, check, ref1)
+ self.assertRaises(ReferenceError, check, ref2)
+ self.assertRaises(ReferenceError, bool, weakref.proxy(C()))
+ self.assertEqual(self.cbcalled, 2)
def check_basic_ref(self, factory):
o = factory()
@@ -184,42 +181,40 @@ class ReferencesTestCase(TestBase):
o = C()
self.check_proxy(o, weakref.proxy(o))
- L = UserList.UserList()
+ L = collections.UserList()
p = weakref.proxy(L)
self.assertFalse(p, "proxy for empty UserList should be false")
p.append(12)
self.assertEqual(len(L), 1)
self.assertTrue(p, "proxy for non-empty UserList should be true")
- with test_support.check_py3k_warnings():
- p[:] = [2, 3]
+ p[:] = [2, 3]
self.assertEqual(len(L), 2)
self.assertEqual(len(p), 2)
self.assertIn(3, p, "proxy didn't support __contains__() properly")
p[1] = 5
self.assertEqual(L[1], 5)
self.assertEqual(p[1], 5)
- L2 = UserList.UserList(L)
+ L2 = collections.UserList(L)
p2 = weakref.proxy(L2)
self.assertEqual(p, p2)
## self.assertEqual(repr(L2), repr(p2))
- L3 = UserList.UserList(range(10))
+ L3 = collections.UserList(range(10))
p3 = weakref.proxy(L3)
- with test_support.check_py3k_warnings():
- self.assertEqual(L3[:], p3[:])
- self.assertEqual(L3[5:], p3[5:])
- self.assertEqual(L3[:5], p3[:5])
- self.assertEqual(L3[2:5], p3[2:5])
+ self.assertEqual(L3[:], p3[:])
+ self.assertEqual(L3[5:], p3[5:])
+ self.assertEqual(L3[:5], p3[:5])
+ self.assertEqual(L3[2:5], p3[2:5])
def test_proxy_unicode(self):
# See bug 5037
class C(object):
def __str__(self):
return "string"
- def __unicode__(self):
- return u"unicode"
+ def __bytes__(self):
+ return b"bytes"
instance = C()
- self.assertIn("__unicode__", dir(weakref.proxy(instance)))
- self.assertEqual(unicode(weakref.proxy(instance)), u"unicode")
+ self.assertIn("__bytes__", dir(weakref.proxy(instance)))
+ self.assertEqual(bytes(weakref.proxy(instance)), b"bytes")
def test_proxy_index(self):
class C:
@@ -707,12 +702,9 @@ class ReferencesTestCase(TestBase):
gc.collect()
def test_classes(self):
- # Check that both old-style classes and new-style classes
- # are weakrefable.
+ # Check that classes are weakrefable.
class A(object):
pass
- class B:
- pass
l = []
weakref.ref(int)
a = weakref.ref(A, l.append)
@@ -720,11 +712,6 @@ class ReferencesTestCase(TestBase):
gc.collect()
self.assertEqual(a(), None)
self.assertEqual(l, [a])
- b = weakref.ref(B, l.append)
- B = None
- gc.collect()
- self.assertEqual(b(), None)
- self.assertEqual(l, [a, b])
def test_equality(self):
# Alive weakrefs defer equality testing to their underlying object.
@@ -759,6 +746,21 @@ class ReferencesTestCase(TestBase):
self.assertEqual(a == d, a is d)
self.assertEqual(a != d, a is not d)
+ def test_ordering(self):
+ # weakrefs cannot be ordered, even if the underlying objects can.
+ ops = [operator.lt, operator.gt, operator.le, operator.ge]
+ x = Object(1)
+ y = Object(1)
+ a = weakref.ref(x)
+ b = weakref.ref(y)
+ for op in ops:
+ self.assertRaises(TypeError, op, a, b)
+ # Same when dead.
+ del x, y
+ gc.collect()
+ for op in ops:
+ self.assertRaises(TypeError, op, a, b)
+
def test_hashing(self):
# Alive weakrefs hash the same as the underlying object
x = Object(42)
@@ -779,7 +781,7 @@ class ReferencesTestCase(TestBase):
# deallocation chain, the trashcan mechanism could delay clearing
# of the weakref and make the target object visible from outside
# code even though its refcount had dropped to 0. A crash ensued.
- class C(object):
+ class C:
def __init__(self, parent):
if not parent:
return
@@ -802,10 +804,10 @@ class SubclassableWeakrefTestCase(TestBase):
class MyRef(weakref.ref):
def __init__(self, ob, callback=None, value=42):
self.value = value
- super(MyRef, self).__init__(ob, callback)
+ super().__init__(ob, callback)
def __call__(self):
self.called = True
- return super(MyRef, self).__call__()
+ return super().__call__()
o = Object("foo")
mr = MyRef(o, value=24)
self.assertTrue(mr() is o)
@@ -908,7 +910,7 @@ class MappingTestCase(TestBase):
items = [RefCycle() for i in range(N)]
dct = dict_type(cons(o) for o in items)
# Keep an iterator alive
- it = dct.iteritems()
+ it = dct.items()
try:
next(it)
except StopIteration:
@@ -940,7 +942,7 @@ class MappingTestCase(TestBase):
dct = dict_type(cons(o) for o in items)
del items
# All items will be collected at next garbage collection pass
- it = dct.iteritems()
+ it = dct.items()
try:
next(it)
except StopIteration:
@@ -965,23 +967,22 @@ class MappingTestCase(TestBase):
#
dict, objects = self.make_weak_valued_dict()
for o in objects:
- self.assertTrue(weakref.getweakrefcount(o) == 1,
- "wrong number of weak references to %r!" % o)
+ self.assertEqual(weakref.getweakrefcount(o), 1)
self.assertTrue(o is dict[o.arg],
"wrong object returned by weak dict!")
- items1 = dict.items()
- items2 = dict.copy().items()
+ items1 = list(dict.items())
+ items2 = list(dict.copy().items())
items1.sort()
items2.sort()
- self.assertTrue(items1 == items2,
+ self.assertEqual(items1, items2,
"cloning of weak-valued dictionary did not work!")
del items1, items2
- self.assertTrue(len(dict) == self.COUNT)
+ self.assertEqual(len(dict), self.COUNT)
del objects[0]
- self.assertTrue(len(dict) == (self.COUNT - 1),
+ self.assertEqual(len(dict), self.COUNT - 1,
"deleting object did not cause dictionary update")
del objects, o
- self.assertTrue(len(dict) == 0,
+ self.assertEqual(len(dict), 0,
"deleting the values did not clear the dictionary")
# regression on SF bug #447152:
dict = weakref.WeakValueDictionary()
@@ -992,7 +993,7 @@ class MappingTestCase(TestBase):
def test_weak_keys(self):
#
# This exercises d.copy(), d.items(), d[] = v, d[], del d[],
- # len(d), in d.
+ # len(d), k in d.
#
dict, objects = self.make_weak_keyed_dict()
for o in objects:
@@ -1002,10 +1003,10 @@ class MappingTestCase(TestBase):
"wrong object returned by weak dict!")
items1 = dict.items()
items2 = dict.copy().items()
- self.assertTrue(set(items1) == set(items2),
+ self.assertEqual(set(items1), set(items2),
"cloning of weak-keyed dictionary did not work!")
del items1, items2
- self.assertTrue(len(dict) == self.COUNT)
+ self.assertEqual(len(dict), self.COUNT)
del objects[0]
self.assertTrue(len(dict) == (self.COUNT - 1),
"deleting object did not cause dictionary update")
@@ -1028,16 +1029,18 @@ class MappingTestCase(TestBase):
for wr in refs:
ob = wr()
self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
# Test iterkeyrefs()
objects2 = list(objects)
- self.assertEqual(len(list(dict.iterkeyrefs())), len(objects))
- for wr in dict.iterkeyrefs():
+ self.assertEqual(len(list(dict.keyrefs())), len(objects))
+ for wr in dict.keyrefs():
ob = wr()
self.assertIn(ob, dict)
+ self.assertIn(ob, dict)
self.assertEqual(ob.arg, dict[ob])
objects2.remove(ob)
self.assertEqual(len(objects2), 0)
@@ -1069,51 +1072,143 @@ class MappingTestCase(TestBase):
def check_iters(self, dict):
# item iterator:
- items = dict.items()
- for item in dict.iteritems():
+ items = list(dict.items())
+ for item in dict.items():
items.remove(item)
- self.assertTrue(len(items) == 0, "iteritems() did not touch all items")
+ self.assertFalse(items, "items() did not touch all items")
# key iterator, via __iter__():
- keys = dict.keys()
+ keys = list(dict.keys())
for k in dict:
keys.remove(k)
- self.assertTrue(len(keys) == 0, "__iter__() did not touch all keys")
+ self.assertFalse(keys, "__iter__() did not touch all keys")
# key iterator, via iterkeys():
- keys = dict.keys()
- for k in dict.iterkeys():
+ keys = list(dict.keys())
+ for k in dict.keys():
keys.remove(k)
- self.assertTrue(len(keys) == 0, "iterkeys() did not touch all keys")
+ self.assertFalse(keys, "iterkeys() did not touch all keys")
# value iterator:
- values = dict.values()
- for v in dict.itervalues():
+ values = list(dict.values())
+ for v in dict.values():
values.remove(v)
- self.assertTrue(len(values) == 0,
+ self.assertFalse(values,
"itervalues() did not touch all values")
+ def check_weak_destroy_while_iterating(self, dict, objects, iter_name):
+ n = len(dict)
+ it = iter(getattr(dict, iter_name)())
+ next(it) # Trigger internal iteration
+ # Destroy an object
+ del objects[-1]
+ gc.collect() # just in case
+ # We have removed either the first consumed object, or another one
+ self.assertIn(len(list(it)), [len(objects), len(objects) - 1])
+ del it
+ # The removal has been committed
+ self.assertEqual(len(dict), n - 1)
+
+ def check_weak_destroy_and_mutate_while_iterating(self, dict, testcontext):
+ # Check that we can explicitly mutate the weak dict without
+ # interfering with delayed removal.
+ # `testcontext` should create an iterator, destroy one of the
+ # weakref'ed objects and then return a new key/value pair corresponding
+ # to the destroyed object.
+ with testcontext() as (k, v):
+ self.assertNotIn(k, dict)
+ with testcontext() as (k, v):
+ self.assertRaises(KeyError, dict.__delitem__, k)
+ self.assertNotIn(k, dict)
+ with testcontext() as (k, v):
+ self.assertRaises(KeyError, dict.pop, k)
+ self.assertNotIn(k, dict)
+ with testcontext() as (k, v):
+ dict[k] = v
+ self.assertEqual(dict[k], v)
+ ddict = copy.copy(dict)
+ with testcontext() as (k, v):
+ dict.update(ddict)
+ self.assertEqual(dict, ddict)
+ with testcontext() as (k, v):
+ dict.clear()
+ self.assertEqual(len(dict), 0)
+
+ def test_weak_keys_destroy_while_iterating(self):
+ # Issue #7105: iterators shouldn't crash when a key is implicitly removed
+ dict, objects = self.make_weak_keyed_dict()
+ self.check_weak_destroy_while_iterating(dict, objects, 'keys')
+ self.check_weak_destroy_while_iterating(dict, objects, 'items')
+ self.check_weak_destroy_while_iterating(dict, objects, 'values')
+ self.check_weak_destroy_while_iterating(dict, objects, 'keyrefs')
+ dict, objects = self.make_weak_keyed_dict()
+ @contextlib.contextmanager
+ def testcontext():
+ try:
+ it = iter(dict.items())
+ next(it)
+ # Schedule a key/value for removal and recreate it
+ v = objects.pop().arg
+ gc.collect() # just in case
+ yield Object(v), v
+ finally:
+ it = None # should commit all removals
+ self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext)
+
+ def test_weak_values_destroy_while_iterating(self):
+ # Issue #7105: iterators shouldn't crash when a key is implicitly removed
+ dict, objects = self.make_weak_valued_dict()
+ self.check_weak_destroy_while_iterating(dict, objects, 'keys')
+ self.check_weak_destroy_while_iterating(dict, objects, 'items')
+ self.check_weak_destroy_while_iterating(dict, objects, 'values')
+ self.check_weak_destroy_while_iterating(dict, objects, 'itervaluerefs')
+ self.check_weak_destroy_while_iterating(dict, objects, 'valuerefs')
+ dict, objects = self.make_weak_valued_dict()
+ @contextlib.contextmanager
+ def testcontext():
+ try:
+ it = iter(dict.items())
+ next(it)
+ # Schedule a key/value for removal and recreate it
+ k = objects.pop().arg
+ gc.collect() # just in case
+ yield k, Object(k)
+ finally:
+ it = None # should commit all removals
+ self.check_weak_destroy_and_mutate_while_iterating(dict, testcontext)
+
def test_make_weak_keyed_dict_from_dict(self):
o = Object(3)
dict = weakref.WeakKeyDictionary({o:364})
- self.assertTrue(dict[o] == 364)
+ self.assertEqual(dict[o], 364)
def test_make_weak_keyed_dict_from_weak_keyed_dict(self):
o = Object(3)
dict = weakref.WeakKeyDictionary({o:364})
dict2 = weakref.WeakKeyDictionary(dict)
- self.assertTrue(dict[o] == 364)
+ self.assertEqual(dict[o], 364)
def make_weak_keyed_dict(self):
dict = weakref.WeakKeyDictionary()
- objects = map(Object, range(self.COUNT))
+ objects = list(map(Object, range(self.COUNT)))
for o in objects:
dict[o] = o.arg
return dict, objects
+ def test_make_weak_valued_dict_from_dict(self):
+ o = Object(3)
+ dict = weakref.WeakValueDictionary({364:o})
+ self.assertEqual(dict[364], o)
+
+ def test_make_weak_valued_dict_from_weak_valued_dict(self):
+ o = Object(3)
+ dict = weakref.WeakValueDictionary({364:o})
+ dict2 = weakref.WeakValueDictionary(dict)
+ self.assertEqual(dict[364], o)
+
def make_weak_valued_dict(self):
dict = weakref.WeakValueDictionary()
- objects = map(Object, range(self.COUNT))
+ objects = list(map(Object, range(self.COUNT)))
for o in objects:
dict[o.arg] = o
return dict, objects
@@ -1122,15 +1217,15 @@ class MappingTestCase(TestBase):
weakdict = klass()
weakdict[key1] = value1
weakdict[key2] = value2
- self.assertTrue(len(weakdict) == 2)
+ self.assertEqual(len(weakdict), 2)
k, v = weakdict.popitem()
- self.assertTrue(len(weakdict) == 1)
+ self.assertEqual(len(weakdict), 1)
if k is key1:
self.assertTrue(v is value1)
else:
self.assertTrue(v is value2)
k, v = weakdict.popitem()
- self.assertTrue(len(weakdict) == 0)
+ self.assertEqual(len(weakdict), 0)
if k is key1:
self.assertTrue(v is value1)
else:
@@ -1150,16 +1245,16 @@ class MappingTestCase(TestBase):
" -- value parameters must be distinct objects")
weakdict = klass()
o = weakdict.setdefault(key, value1)
- self.assertIs(o, value1)
+ self.assertTrue(o is value1)
self.assertIn(key, weakdict)
- self.assertIs(weakdict.get(key), value1)
- self.assertIs(weakdict[key], value1)
+ self.assertTrue(weakdict.get(key) is value1)
+ self.assertTrue(weakdict[key] is value1)
o = weakdict.setdefault(key, value2)
- self.assertIs(o, value1)
+ self.assertTrue(o is value1)
self.assertIn(key, weakdict)
- self.assertIs(weakdict.get(key), value1)
- self.assertIs(weakdict[key], value1)
+ self.assertTrue(weakdict.get(key) is value1)
+ self.assertTrue(weakdict[key] is value1)
def test_weak_valued_dict_setdefault(self):
self.check_setdefault(weakref.WeakValueDictionary,
@@ -1171,24 +1266,22 @@ class MappingTestCase(TestBase):
def check_update(self, klass, dict):
#
- # This exercises d.update(), len(d), d.keys(), in d,
+ # This exercises d.update(), len(d), d.keys(), k in d,
# d.get(), d[].
#
weakdict = klass()
weakdict.update(dict)
self.assertEqual(len(weakdict), len(dict))
for k in weakdict.keys():
- self.assertIn(k, dict,
- "mysterious new key appeared in weak dict")
+ self.assertIn(k, dict, "mysterious new key appeared in weak dict")
v = dict.get(k)
- self.assertIs(v, weakdict[k])
- self.assertIs(v, weakdict.get(k))
+ self.assertTrue(v is weakdict[k])
+ self.assertTrue(v is weakdict.get(k))
for k in dict.keys():
- self.assertIn(k, weakdict,
- "original key disappeared in weak dict")
+ self.assertIn(k, weakdict, "original key disappeared in weak dict")
v = dict[k]
- self.assertIs(v, weakdict[k])
- self.assertIs(v, weakdict.get(k))
+ self.assertTrue(v is weakdict[k])
+ self.assertTrue(v is weakdict.get(k))
def test_weak_valued_dict_update(self):
self.check_update(weakref.WeakValueDictionary,
@@ -1204,10 +1297,10 @@ class MappingTestCase(TestBase):
o2 = Object('2')
d[o1] = 'something'
d[o2] = 'something'
- self.assertTrue(len(d) == 2)
+ self.assertEqual(len(d), 2)
del d[o1]
- self.assertTrue(len(d) == 1)
- self.assertTrue(d.keys() == [o2])
+ self.assertEqual(len(d), 1)
+ self.assertEqual(list(d.keys()), [o2])
def test_weak_valued_delitem(self):
d = weakref.WeakValueDictionary()
@@ -1215,10 +1308,10 @@ class MappingTestCase(TestBase):
o2 = Object('2')
d['something'] = o1
d['something else'] = o2
- self.assertTrue(len(d) == 2)
+ self.assertEqual(len(d), 2)
del d['something']
- self.assertTrue(len(d) == 1)
- self.assertTrue(d.items() == [('something else', o2)])
+ self.assertEqual(len(d), 1)
+ self.assertTrue(list(d.items()) == [('something else', o2)])
def test_weak_keyed_bad_delitem(self):
d = weakref.WeakKeyDictionary()
@@ -1259,7 +1352,7 @@ class MappingTestCase(TestBase):
d[o] = o.value
del o # now the only strong references to keys are in objs
# Find the order in which iterkeys sees the keys.
- objs = d.keys()
+ objs = list(d.keys())
# Reverse it, so that the iteration implementation of __delitem__
# has to keep looping to find the first object we delete.
objs.reverse()
@@ -1303,7 +1396,7 @@ libreftest = """ Doctest for examples in the library reference: weakref.rst
...
>>> obj = Dict(red=1, green=2, blue=3) # this object is weak referencable
>>> r = weakref.ref(obj)
->>> print r() is obj
+>>> print(r() is obj)
True
>>> import weakref
@@ -1316,21 +1409,21 @@ True
>>> o is o2
True
>>> del o, o2
->>> print r()
+>>> print(r())
None
>>> import weakref
>>> class ExtendedRef(weakref.ref):
... def __init__(self, ob, callback=None, **annotations):
-... super(ExtendedRef, self).__init__(ob, callback)
+... super().__init__(ob, callback)
... self.__counter = 0
-... for k, v in annotations.iteritems():
+... for k, v in annotations.items():
... setattr(self, k, v)
... def __call__(self):
... '''Return a pair containing the referent and the number of
... times the reference has been called.
... '''
-... ob = super(ExtendedRef, self).__call__()
+... ob = super().__call__()
... if ob is not None:
... self.__counter += 1
... ob = (ob, self.__counter)
@@ -1371,9 +1464,9 @@ True
>>> try:
... id2obj(a_id)
... except KeyError:
-... print 'OK'
+... print('OK')
... else:
-... print 'WeakValueDictionary error'
+... print('WeakValueDictionary error')
OK
"""
@@ -1381,14 +1474,14 @@ OK
__test__ = {'libreftest' : libreftest}
def test_main():
- test_support.run_unittest(
+ support.run_unittest(
ReferencesTestCase,
MappingTestCase,
WeakValueDictionaryTestCase,
WeakKeyDictionaryTestCase,
SubclassableWeakrefTestCase,
)
- test_support.run_doctest(sys.modules[__name__])
+ support.run_doctest(sys.modules[__name__])
if __name__ == "__main__":
diff --git a/Lib/test/test_weakset.py b/Lib/test/test_weakset.py
index d9e091ed02f..4d3878f8a65 100644
--- a/Lib/test/test_weakset.py
+++ b/Lib/test/test_weakset.py
@@ -1,5 +1,5 @@
import unittest
-from test import test_support
+from test import support
from weakref import proxy, ref, WeakSet
import operator
import copy
@@ -9,6 +9,7 @@ from random import randrange, shuffle
import sys
import warnings
import collections
+from collections import UserString as ustr
import gc
import contextlib
@@ -16,40 +17,27 @@ import contextlib
class Foo:
pass
-class SomeClass(object):
- def __init__(self, value):
- self.value = value
- def __eq__(self, other):
- if type(other) != type(self):
- return False
- return other.value == self.value
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- def __hash__(self):
- return hash((SomeClass, self.value))
-
-class RefCycle(object):
+class RefCycle:
def __init__(self):
self.cycle = self
+
class TestWeakSet(unittest.TestCase):
def setUp(self):
# need to keep references to them
- self.items = [SomeClass(c) for c in ('a', 'b', 'c')]
- self.items2 = [SomeClass(c) for c in ('x', 'y', 'z')]
- self.letters = [SomeClass(c) for c in string.ascii_letters]
- self.ab_items = [SomeClass(c) for c in 'ab']
- self.abcde_items = [SomeClass(c) for c in 'abcde']
- self.def_items = [SomeClass(c) for c in 'def']
+ self.items = [ustr(c) for c in ('a', 'b', 'c')]
+ self.items2 = [ustr(c) for c in ('x', 'y', 'z')]
+ self.ab_items = [ustr(c) for c in 'ab']
+ self.abcde_items = [ustr(c) for c in 'abcde']
+ self.def_items = [ustr(c) for c in 'def']
self.ab_weakset = WeakSet(self.ab_items)
self.abcde_weakset = WeakSet(self.abcde_items)
self.def_weakset = WeakSet(self.def_items)
+ self.letters = [ustr(c) for c in string.ascii_letters]
self.s = WeakSet(self.items)
self.d = dict.fromkeys(self.items)
- self.obj = SomeClass('F')
+ self.obj = ustr('F')
self.fs = WeakSet([self.obj])
def test_methods(self):
@@ -76,7 +64,7 @@ class TestWeakSet(unittest.TestCase):
self.assertNotIn(1, self.s)
self.assertIn(self.obj, self.fs)
del self.obj
- self.assertNotIn(SomeClass('F'), self.fs)
+ self.assertNotIn(ustr('F'), self.fs)
def test_union(self):
u = self.s.union(self.items2)
@@ -226,7 +214,7 @@ class TestWeakSet(unittest.TestCase):
self.assertNotEqual(id(self.s), id(dup))
def test_add(self):
- x = SomeClass('Q')
+ x = ustr('Q')
self.s.add(x)
self.assertIn(x, self.s)
dup = self.s.copy()
@@ -239,14 +227,14 @@ class TestWeakSet(unittest.TestCase):
self.assertTrue(len(self.fs) == 1)
def test_remove(self):
- x = SomeClass('a')
+ x = ustr('a')
self.s.remove(x)
self.assertNotIn(x, self.s)
self.assertRaises(KeyError, self.s.remove, x)
self.assertRaises(TypeError, self.s.remove, [])
def test_discard(self):
- a, q = SomeClass('a'), SomeClass('Q')
+ a, q = ustr('a'), ustr('Q')
self.s.discard(a)
self.assertNotIn(a, self.s)
self.s.discard(q)
@@ -349,12 +337,13 @@ class TestWeakSet(unittest.TestCase):
self.assertFalse(self.s == set(self.items))
self.assertFalse(self.s == list(self.items))
self.assertFalse(self.s == tuple(self.items))
+ self.assertFalse(self.s == WeakSet([Foo]))
self.assertFalse(self.s == 1)
def test_weak_destroy_while_iterating(self):
# Issue #7105: iterators shouldn't crash when a key is implicitly removed
# Create new items to be sure no-one else holds a reference
- items = [SomeClass(c) for c in ('a', 'b', 'c')]
+ items = [ustr(c) for c in ('a', 'b', 'c')]
s = WeakSet(items)
it = iter(s)
next(it) # Trigger internal iteration
@@ -369,15 +358,16 @@ class TestWeakSet(unittest.TestCase):
def test_weak_destroy_and_mutate_while_iterating(self):
# Issue #7105: iterators shouldn't crash when a key is implicitly removed
- items = [SomeClass(c) for c in string.ascii_letters]
+ items = [ustr(c) for c in string.ascii_letters]
s = WeakSet(items)
@contextlib.contextmanager
def testcontext():
try:
it = iter(s)
next(it)
+ del it
# Schedule an item for removal and recreate it
- u = SomeClass(str(items.pop()))
+ u = ustr(str(items.pop()))
gc.collect() # just in case
yield u
finally:
@@ -444,7 +434,7 @@ class TestWeakSet(unittest.TestCase):
def test_main(verbose=None):
- test_support.run_unittest(TestWeakSet)
+ support.run_unittest(TestWeakSet)
if __name__ == "__main__":
test_main(verbose=True)
diff --git a/Lib/test/test_whichdb.py b/Lib/test/test_whichdb.py
deleted file mode 100644
index 427e323f494..00000000000
--- a/Lib/test/test_whichdb.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#! /usr/bin/env python
-"""Test script for the whichdb module
- based on test_anydbm.py
-"""
-
-import os
-import test.test_support
-import unittest
-import whichdb
-import glob
-
-_fname = test.test_support.TESTFN
-
-# Silence Py3k warning
-anydbm = test.test_support.import_module('anydbm', deprecated=True)
-
-def _delete_files():
- # we don't know the precise name the underlying database uses
- # so we use glob to locate all names
- for f in glob.glob(_fname + "*"):
- try:
- os.unlink(f)
- except OSError:
- pass
-
-class WhichDBTestCase(unittest.TestCase):
- # Actual test methods are added to namespace
- # after class definition.
- def __init__(self, *args):
- unittest.TestCase.__init__(self, *args)
-
- def tearDown(self):
- _delete_files()
-
- def setUp(self):
- _delete_files()
-
-for name in anydbm._names:
- # we define a new test method for each
- # candidate database module.
- try:
- # Silence Py3k warning
- mod = test.test_support.import_module(name, deprecated=True)
- except unittest.SkipTest:
- continue
-
- def test_whichdb_name(self, name=name, mod=mod):
- # Check whether whichdb correctly guesses module name
- # for databases opened with module mod.
- # Try with empty files first
- f = mod.open(_fname, 'c')
- f.close()
- self.assertEqual(name, whichdb.whichdb(_fname))
- # Now add a key
- f = mod.open(_fname, 'w')
- f["1"] = "1"
- f.close()
- self.assertEqual(name, whichdb.whichdb(_fname))
- setattr(WhichDBTestCase,"test_whichdb_%s" % name, test_whichdb_name)
-
-def test_main():
- try:
- test.test_support.run_unittest(WhichDBTestCase)
- finally:
- _delete_files()
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_winreg.py b/Lib/test/test_winreg.py
index 2799e194802..a164d2faf1f 100644
--- a/Lib/test/test_winreg.py
+++ b/Lib/test/test_winreg.py
@@ -3,14 +3,14 @@
import os, sys, errno
import unittest
-from test import test_support
-threading = test_support.import_module("threading")
+from test import support
+threading = support.import_module("threading")
from platform import machine
# Do this first so test will be skipped if module doesn't exist
-test_support.import_module('_winreg')
+support.import_module('winreg')
# Now import everything
-from _winreg import *
+from winreg import *
try:
REMOTE_NAME = sys.argv[sys.argv.index("--remote")+1]
@@ -37,21 +37,13 @@ test_data = [
("String Val", "A string value", REG_SZ),
("StringExpand", "The path is %path%", REG_EXPAND_SZ),
("Multi-string", ["Lots", "of", "string", "values"], REG_MULTI_SZ),
- ("Raw Data", ("binary"+chr(0)+"data"), REG_BINARY),
+ ("Raw Data", b"binary\x00data", REG_BINARY),
("Big String", "x"*(2**14-1), REG_SZ),
- ("Big Binary", "x"*(2**14), REG_BINARY),
+ ("Big Binary", b"x"*(2**14), REG_BINARY),
+ # Two and three kanjis, meaning: "Japan" and "Japanese")
+ ("Japanese 日本", "日本語", REG_SZ),
]
-if test_support.have_unicode:
- test_data += [
- (unicode("Unicode Val"), unicode("A Unicode value"), REG_SZ,),
- ("UnicodeExpand", unicode("The path is %path%"), REG_EXPAND_SZ),
- ("Multi-unicode", [unicode("Lots"), unicode("of"), unicode("unicode"),
- unicode("values")], REG_MULTI_SZ),
- ("Multi-mixed", [unicode("Unicode"), unicode("and"), "string",
- "values"], REG_MULTI_SZ),
- ]
-
class BaseWinregTests(unittest.TestCase):
def setUp(self):
@@ -75,12 +67,14 @@ class BaseWinregTests(unittest.TestCase):
CloseKey(hkey)
DeleteKey(root, subkey)
- def _write_test_data(self, root_key, CreateKey=CreateKey):
+ def _write_test_data(self, root_key, subkeystr="sub_key",
+ CreateKey=CreateKey):
# Set the default value for this key.
SetValue(root_key, test_key_name, REG_SZ, "Default value")
key = CreateKey(root_key, test_key_name)
+ self.assertTrue(key.handle != 0)
# Create a sub-key
- sub_key = CreateKey(key, "sub_key")
+ sub_key = CreateKey(key, subkeystr)
# Give the sub-key some named values
for value_name, value_data, value_type in test_data:
@@ -93,7 +87,7 @@ class BaseWinregTests(unittest.TestCase):
nkeys, nvalues, since_mod = QueryInfoKey(sub_key)
self.assertEqual(nkeys, 0, "Not the correct number of sub keys")
self.assertEqual(nvalues, len(test_data),
- "Not the correct number of values")
+ "Not the correct number of values")
# Close this key this way...
# (but before we do, copy the key as an integer - this allows
# us to test that the key really gets closed).
@@ -115,7 +109,7 @@ class BaseWinregTests(unittest.TestCase):
except EnvironmentError:
pass
- def _read_test_data(self, root_key, OpenKey=OpenKey):
+ def _read_test_data(self, root_key, subkeystr="sub_key", OpenKey=OpenKey):
# Check we can get default value for this key.
val = QueryValue(root_key, test_key_name)
self.assertEqual(val, "Default value",
@@ -123,7 +117,7 @@ class BaseWinregTests(unittest.TestCase):
key = OpenKey(root_key, test_key_name)
# Read the sub-keys
- with OpenKey(key, "sub_key") as sub_key:
+ with OpenKey(key, subkeystr) as sub_key:
# Check I can enumerate over the values.
index = 0
while 1:
@@ -131,8 +125,8 @@ class BaseWinregTests(unittest.TestCase):
data = EnumValue(sub_key, index)
except EnvironmentError:
break
- self.assertIn(data, test_data,
- "Didn't read back the correct test data")
+ self.assertEqual(data in test_data, True,
+ "Didn't read back the correct test data")
index = index + 1
self.assertEqual(index, len(test_data),
"Didn't read the correct number of items")
@@ -146,7 +140,7 @@ class BaseWinregTests(unittest.TestCase):
sub_key.Close()
# Enumerate our main key.
read_val = EnumKey(key, 0)
- self.assertEqual(read_val, "sub_key", "Read subkey value wrong")
+ self.assertEqual(read_val, subkeystr, "Read subkey value wrong")
try:
EnumKey(key, 1)
self.fail("Was able to get a second key when I only have one!")
@@ -155,9 +149,9 @@ class BaseWinregTests(unittest.TestCase):
key.Close()
- def _delete_test_data(self, root_key):
+ def _delete_test_data(self, root_key, subkeystr="sub_key"):
key = OpenKey(root_key, test_key_name, 0, KEY_ALL_ACCESS)
- sub_key = OpenKey(key, "sub_key", 0, KEY_ALL_ACCESS)
+ sub_key = OpenKey(key, subkeystr, 0, KEY_ALL_ACCESS)
# It is not necessary to delete the values before deleting
# the key (although subkeys must not exist). We delete them
# manually just to prove we can :-)
@@ -168,11 +162,11 @@ class BaseWinregTests(unittest.TestCase):
self.assertEqual(nkeys, 0, "subkey not empty before delete")
self.assertEqual(nvalues, 0, "subkey not empty before delete")
sub_key.Close()
- DeleteKey(key, "sub_key")
+ DeleteKey(key, subkeystr)
try:
# Shouldnt be able to delete it twice!
- DeleteKey(key, "sub_key")
+ DeleteKey(key, subkeystr)
self.fail("Deleting the key twice succeeded")
except EnvironmentError:
pass
@@ -185,28 +179,45 @@ class BaseWinregTests(unittest.TestCase):
except WindowsError: # Use this error name this time
pass
- def _test_all(self, root_key):
- self._write_test_data(root_key)
- self._read_test_data(root_key)
- self._delete_test_data(root_key)
+ def _test_all(self, root_key, subkeystr="sub_key"):
+ self._write_test_data(root_key, subkeystr)
+ self._read_test_data(root_key, subkeystr)
+ self._delete_test_data(root_key, subkeystr)
+
+ def _test_named_args(self, key, sub_key):
+ with CreateKeyEx(key=key, sub_key=sub_key, reserved=0,
+ access=KEY_ALL_ACCESS) as ckey:
+ self.assertTrue(ckey.handle != 0)
+
+ with OpenKeyEx(key=key, sub_key=sub_key, reserved=0,
+ access=KEY_ALL_ACCESS) as okey:
+ self.assertTrue(okey.handle != 0)
+
class LocalWinregTests(BaseWinregTests):
def test_registry_works(self):
self._test_all(HKEY_CURRENT_USER)
+ self._test_all(HKEY_CURRENT_USER, "日本-subkey")
def test_registry_works_extended_functions(self):
# Substitute the regular CreateKey and OpenKey calls with their
# extended counterparts.
# Note: DeleteKeyEx is not used here because it is platform dependent
cke = lambda key, sub_key: CreateKeyEx(key, sub_key, 0, KEY_ALL_ACCESS)
- self._write_test_data(HKEY_CURRENT_USER, cke)
+ self._write_test_data(HKEY_CURRENT_USER, CreateKey=cke)
oke = lambda key, sub_key: OpenKeyEx(key, sub_key, 0, KEY_READ)
- self._read_test_data(HKEY_CURRENT_USER, oke)
+ self._read_test_data(HKEY_CURRENT_USER, OpenKey=oke)
self._delete_test_data(HKEY_CURRENT_USER)
+ def test_named_arguments(self):
+ self._test_named_args(HKEY_CURRENT_USER, test_key_name)
+ # Use the regular DeleteKey to clean up
+ # DeleteKeyEx takes named args and is tested separately
+ DeleteKey(HKEY_CURRENT_USER, test_key_name)
+
def test_connect_registry_to_local_machine_works(self):
# perform minimal ConnectRegistry test which just invokes it
h = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
@@ -218,9 +229,9 @@ class LocalWinregTests(BaseWinregTests):
connect = lambda: ConnectRegistry("abcdefghijkl", HKEY_CURRENT_USER)
self.assertRaises(WindowsError, connect)
- def test_expand_environment_strings(self):
- r = ExpandEnvironmentStrings(u"%windir%\\test")
- self.assertEqual(type(r), unicode)
+ def testExpandEnvironmentStrings(self):
+ r = ExpandEnvironmentStrings("%windir%\\test")
+ self.assertEqual(type(r), str)
self.assertEqual(r, os.environ["windir"] + "\\test")
def test_context_manager(self):
@@ -261,8 +272,7 @@ class LocalWinregTests(BaseWinregTests):
finally:
done = True
thread.join()
- with OpenKey(HKEY_CURRENT_USER, test_key_name, 0, KEY_ALL_ACCESS) as key:
- DeleteKey(key, 'changing_value')
+ DeleteKey(HKEY_CURRENT_USER, test_key_name+'\\changing_value')
DeleteKey(HKEY_CURRENT_USER, test_key_name)
def test_long_key(self):
@@ -276,8 +286,7 @@ class LocalWinregTests(BaseWinregTests):
num_subkeys, num_values, t = QueryInfoKey(key)
EnumKey(key, 0)
finally:
- with OpenKey(HKEY_CURRENT_USER, test_key_name, 0, KEY_ALL_ACCESS) as key:
- DeleteKey(key, name)
+ DeleteKey(HKEY_CURRENT_USER, '\\'.join((test_key_name, name)))
DeleteKey(HKEY_CURRENT_USER, test_key_name)
def test_dynamic_key(self):
@@ -290,7 +299,7 @@ class LocalWinregTests(BaseWinregTests):
self.skipTest("access denied to registry key "
"(are you running in a non-interactive session?)")
raise
- QueryValueEx(HKEY_PERFORMANCE_DATA, None)
+ QueryValueEx(HKEY_PERFORMANCE_DATA, "")
# Reflection requires XP x64/Vista at a minimum. XP doesn't have this stuff
# or DeleteKeyEx so make sure their use raises NotImplementedError
@@ -355,14 +364,20 @@ class RemoteWinregTests(BaseWinregTests):
@unittest.skipUnless(WIN64_MACHINE, "x64 specific registry tests")
class Win64WinregTests(BaseWinregTests):
+ def test_named_arguments(self):
+ self._test_named_args(HKEY_CURRENT_USER, test_key_name)
+ # Clean up and also exercise the named arguments
+ DeleteKeyEx(key=HKEY_CURRENT_USER, sub_key=test_key_name,
+ access=KEY_ALL_ACCESS, reserved=0)
+
def test_reflection_functions(self):
# Test that we can call the query, enable, and disable functions
# on a key which isn't on the reflection list with no consequences.
with OpenKey(HKEY_LOCAL_MACHINE, "Software") as key:
# HKLM\Software is redirected but not reflected in all OSes
self.assertTrue(QueryReflectionKey(key))
- self.assertEqual(None, EnableReflectionKey(key))
- self.assertEqual(None, DisableReflectionKey(key))
+ self.assertIsNone(EnableReflectionKey(key))
+ self.assertIsNone(DisableReflectionKey(key))
self.assertTrue(QueryReflectionKey(key))
@unittest.skipUnless(HAS_REFLECTION, "OS doesn't support reflection")
@@ -441,11 +456,11 @@ class Win64WinregTests(BaseWinregTests):
def test_main():
- test_support.run_unittest(LocalWinregTests, RemoteWinregTests,
- Win64WinregTests)
+ support.run_unittest(LocalWinregTests, RemoteWinregTests,
+ Win64WinregTests)
if __name__ == "__main__":
if not REMOTE_NAME:
- print "Remote registry calls can be tested using",
- print "'test_winreg.py --remote \\\\machine_name'"
+ print("Remote registry calls can be tested using",
+ "'test_winreg.py --remote \\\\machine_name'")
test_main()
diff --git a/Lib/test/test_winsound.py b/Lib/test/test_winsound.py
index 7cdecd86708..34c3deaf7eb 100644
--- a/Lib/test/test_winsound.py
+++ b/Lib/test/test_winsound.py
@@ -1,15 +1,15 @@
# Ridiculously simple test of the winsound module for Windows.
import unittest
-from test import test_support
-test_support.requires('audio')
+from test import support
+support.requires('audio')
import time
import os
import subprocess
-winsound = test_support.import_module('winsound')
-ctypes = test_support.import_module('ctypes')
-import _winreg
+winsound = support.import_module('winsound')
+ctypes = support.import_module('ctypes')
+import winreg
def has_sound(sound):
"""Find out if a particular event is configured with a default sound"""
@@ -19,10 +19,10 @@ def has_sound(sound):
if ctypes.windll.winmm.mixerGetNumDevs() is 0:
return False
- key = _winreg.OpenKeyEx(_winreg.HKEY_CURRENT_USER,
+ key = winreg.OpenKeyEx(winreg.HKEY_CURRENT_USER,
"AppEvents\Schemes\Apps\.Default\{0}\.Default".format(sound))
- value = _winreg.EnumValue(key, 0)[1]
- if value is not u"":
+ value = winreg.EnumValue(key, 0)[1]
+ if value is not "":
return True
else:
return False
@@ -48,7 +48,7 @@ class BeepTest(unittest.TestCase):
self._beep(32767, 75)
def test_increasingfrequency(self):
- for i in xrange(100, 2000, 100):
+ for i in range(100, 2000, 100):
self._beep(i, 75)
def _beep(self, *args):
@@ -103,7 +103,8 @@ class PlaySoundTest(unittest.TestCase):
"none", winsound.SND_ASYNC | winsound.SND_MEMORY
)
- @unittest.skipUnless(has_sound("SystemAsterisk"), "No default SystemAsterisk")
+ @unittest.skipUnless(has_sound("SystemAsterisk"),
+ "No default SystemAsterisk")
def test_alias_asterisk(self):
if _have_soundcard():
winsound.PlaySound('SystemAsterisk', winsound.SND_ALIAS)
@@ -114,7 +115,8 @@ class PlaySoundTest(unittest.TestCase):
'SystemAsterisk', winsound.SND_ALIAS
)
- @unittest.skipUnless(has_sound("SystemExclamation"), "No default SystemExclamation")
+ @unittest.skipUnless(has_sound("SystemExclamation"),
+ "No default SystemExclamation")
def test_alias_exclamation(self):
if _have_soundcard():
winsound.PlaySound('SystemExclamation', winsound.SND_ALIAS)
@@ -147,7 +149,8 @@ class PlaySoundTest(unittest.TestCase):
'SystemHand', winsound.SND_ALIAS
)
- @unittest.skipUnless(has_sound("SystemQuestion"), "No default SystemQuestion")
+ @unittest.skipUnless(has_sound("SystemQuestion"),
+ "No default SystemQuestion")
def test_alias_question(self):
if _have_soundcard():
winsound.PlaySound('SystemQuestion', winsound.SND_ALIAS)
@@ -246,11 +249,12 @@ def _have_soundcard():
p = subprocess.Popen([cscript_path, check_script],
stdout=subprocess.PIPE)
__have_soundcard_cache = not p.wait()
+ p.stdout.close()
return __have_soundcard_cache
def test_main():
- test_support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
+ support.run_unittest(BeepTest, MessageBeepTest, PlaySoundTest)
if __name__=="__main__":
test_main()
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 496451833c3..e8cc8c056ec 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
"""Unit tests for the with statement specified in PEP 343."""
@@ -9,31 +9,31 @@ __email__ = "mbland at acm dot org"
import sys
import unittest
from collections import deque
-from contextlib import GeneratorContextManager, contextmanager
-from test.test_support import run_unittest
+from contextlib import _GeneratorContextManager, contextmanager
+from test.support import run_unittest
-class MockContextManager(GeneratorContextManager):
- def __init__(self, gen):
- GeneratorContextManager.__init__(self, gen)
+class MockContextManager(_GeneratorContextManager):
+ def __init__(self, func, *args, **kwds):
+ super().__init__(func, *args, **kwds)
self.enter_called = False
self.exit_called = False
self.exit_args = None
def __enter__(self):
self.enter_called = True
- return GeneratorContextManager.__enter__(self)
+ return _GeneratorContextManager.__enter__(self)
def __exit__(self, type, value, traceback):
self.exit_called = True
self.exit_args = (type, value, traceback)
- return GeneratorContextManager.__exit__(self, type,
- value, traceback)
+ return _GeneratorContextManager.__exit__(self, type,
+ value, traceback)
def mock_contextmanager(func):
def helper(*args, **kwds):
- return MockContextManager(func(*args, **kwds))
+ return MockContextManager(func, *args, **kwds)
return helper
@@ -86,7 +86,7 @@ class Nested(object):
ex = sys.exc_info()
self.entered = None
if ex is not exc_info:
- raise ex[0], ex[1], ex[2]
+ raise ex[0](ex[1]).with_traceback(ex[2])
class MockNested(Nested):
@@ -186,7 +186,9 @@ class FailureTestCase(unittest.TestCase):
self.assertRaises(RuntimeError, shouldThrow)
class ContextmanagerAssertionMixin(object):
- TEST_EXCEPTION = RuntimeError("test exception")
+
+ def setUp(self):
+ self.TEST_EXCEPTION = RuntimeError("test exception")
def assertInWithManagerInvariants(self, mock_manager):
self.assertTrue(mock_manager.enter_called)
@@ -349,7 +351,7 @@ class NestedNonexceptionalTestCase(unittest.TestCase,
self.assertAfterWithManagerInvariantsNoError(mock_nested)
-class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
+class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
def testSingleResource(self):
cm = mock_contextmanager_generator()
def shouldThrow():
@@ -480,7 +482,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
def shouldThrow():
with cm():
- raise iter([]).next()
+ raise next(iter([]))
self.assertRaises(StopIteration, shouldThrow)
@@ -517,7 +519,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
class cm(object):
def __init__(self, bool_conversion):
class Bool:
- def __nonzero__(self):
+ def __bool__(self):
return bool_conversion()
self.exit_result = Bool()
def __enter__(self):
@@ -536,7 +538,7 @@ class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
self.assertRaises(AssertionError, falseAsBool)
def failAsBool():
- with cm(lambda: 1 // 0):
+ with cm(lambda: 1//0):
self.fail("Should NOT see this")
self.assertRaises(ZeroDivisionError, failAsBool)
@@ -603,13 +605,13 @@ class AssignmentTargetTestCase(unittest.TestCase):
def testSingleComplexTarget(self):
targets = {1: [0, 1, 2]}
with mock_contextmanager_generator() as targets[1][0]:
- self.assertEqual(targets.keys(), [1])
+ self.assertEqual(list(targets.keys()), [1])
self.assertEqual(targets[1][0].__class__, MockResource)
- with mock_contextmanager_generator() as targets.values()[0][1]:
- self.assertEqual(targets.keys(), [1])
+ with mock_contextmanager_generator() as list(targets.values())[0][1]:
+ self.assertEqual(list(targets.keys()), [1])
self.assertEqual(targets[1][1].__class__, MockResource)
with mock_contextmanager_generator() as targets[2]:
- keys = targets.keys()
+ keys = list(targets.keys())
keys.sort()
self.assertEqual(keys, [1, 2])
class C: pass
@@ -624,7 +626,7 @@ class AssignmentTargetTestCase(unittest.TestCase):
targets = {1: [0, 1, 2]}
with C() as (targets[1][0], targets[1][1], targets[1][2]):
self.assertEqual(targets, {1: [1, 2, 3]})
- with C() as (targets.values()[0][2], targets.values()[0][1], targets.values()[0][0]):
+ with C() as (list(targets.values())[0][2], list(targets.values())[0][1], list(targets.values())[0][0]):
self.assertEqual(targets, {1: [3, 2, 1]})
with C() as (targets[1], targets[2], targets[3]):
self.assertEqual(targets, {1: 1, 2: 2, 3: 3})
@@ -644,7 +646,7 @@ class ExitSwallowsExceptionTestCase(unittest.TestCase):
def __exit__(self, t, v, tb): return True
try:
with AfricanSwallow():
- 1 // 0
+ 1/0
except ZeroDivisionError:
self.fail("ZeroDivisionError should have been swallowed")
@@ -654,7 +656,7 @@ class ExitSwallowsExceptionTestCase(unittest.TestCase):
def __exit__(self, t, v, tb): return False
try:
with EuropeanSwallow():
- 1 // 0
+ 1/0
except ZeroDivisionError:
pass
else:
diff --git a/Lib/test/test_wsgiref.py b/Lib/test/test_wsgiref.py
index b7d4c86f722..08f8d9a6043 100644
--- a/Lib/test/test_wsgiref.py
+++ b/Lib/test/test_wsgiref.py
@@ -7,13 +7,13 @@ from wsgiref import util
from wsgiref.validate import validator
from wsgiref.simple_server import WSGIServer, WSGIRequestHandler, demo_app
from wsgiref.simple_server import make_server
-from StringIO import StringIO
-from SocketServer import BaseServer
+from io import StringIO, BytesIO, BufferedReader
+from socketserver import BaseServer
import os
import re
import sys
-from test import test_support
+from test import support
class MockServer(WSGIServer):
"""Non-socket HTTP server"""
@@ -44,21 +44,22 @@ def hello_app(environ,start_response):
('Content-Type','text/plain'),
('Date','Mon, 05 Jun 2006 18:49:54 GMT')
])
- return ["Hello, world!"]
+ return [b"Hello, world!"]
-def run_amock(app=hello_app, data="GET / HTTP/1.0\n\n"):
+def run_amock(app=hello_app, data=b"GET / HTTP/1.0\n\n"):
server = make_server("", 80, app, MockServer, MockHandler)
- inp, out, err, olderr = StringIO(data), StringIO(), StringIO(), sys.stderr
- sys.stderr = err
+ inp = BufferedReader(BytesIO(data))
+ out = BytesIO()
+ olderr = sys.stderr
+ err = sys.stderr = StringIO()
try:
- server.finish_request((inp,out), ("127.0.0.1",8888))
+ server.finish_request((inp, out), ("127.0.0.1",8888))
finally:
sys.stderr = olderr
return out.getvalue(), err.getvalue()
-
def compare_generic_iter(make_it,match):
"""Utility to compare a generic 2.1/2.2+ iterator with an iterable
@@ -87,26 +88,26 @@ def compare_generic_iter(make_it,match):
it = make_it()
if not iter(it) is it: raise AssertionError
for item in match:
- if not it.next()==item: raise AssertionError
+ if not next(it) == item: raise AssertionError
try:
- it.next()
+ next(it)
except StopIteration:
pass
else:
- raise AssertionError("Too many items from .next()",it)
+ raise AssertionError("Too many items from .__next__()", it)
class IntegrationTests(TestCase):
def check_hello(self, out, has_length=True):
self.assertEqual(out,
- "HTTP/1.0 200 OK\r\n"
- "Server: WSGIServer/0.1 Python/"+sys.version.split()[0]+"\r\n"
+ ("HTTP/1.0 200 OK\r\n"
+ "Server: WSGIServer/0.2 Python/"+sys.version.split()[0]+"\r\n"
"Content-Type: text/plain\r\n"
"Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" +
(has_length and "Content-Length: 13\r\n" or "") +
"\r\n"
- "Hello, world!"
+ "Hello, world!").encode("iso-8859-1")
)
def test_plain_hello(self):
@@ -124,14 +125,46 @@ class IntegrationTests(TestCase):
return ["Hello, world!"]
out, err = run_amock(validator(bad_app))
self.assertTrue(out.endswith(
- "A server error occurred. Please contact the administrator."
+ b"A server error occurred. Please contact the administrator."
))
self.assertEqual(
err.splitlines()[-2],
"AssertionError: Headers (('Content-Type', 'text/plain')) must"
- " be of type list: <type 'tuple'>"
+ " be of type list: <class 'tuple'>"
)
+ def test_wsgi_input(self):
+ def bad_app(e,s):
+ e["wsgi.input"].read()
+ s("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
+ return [b"data"]
+ out, err = run_amock(validator(bad_app))
+ self.assertTrue(out.endswith(
+ b"A server error occurred. Please contact the administrator."
+ ))
+ self.assertEqual(
+ err.splitlines()[-2], "AssertionError"
+ )
+
+ def test_bytes_validation(self):
+ def app(e, s):
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
+ ("Date", "Wed, 24 Dec 2008 13:29:32 GMT"),
+ ])
+ return [b"data"]
+ out, err = run_amock(validator(app))
+ self.assertTrue(err.endswith('"GET / HTTP/1.0" 200 4\n'))
+ ver = sys.version.split()[0].encode('ascii')
+ self.assertEqual(
+ b"HTTP/1.0 200 OK\r\n"
+ b"Server: WSGIServer/0.2 Python/" + ver + b"\r\n"
+ b"Content-Type: text/plain; charset=utf-8\r\n"
+ b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n"
+ b"\r\n"
+ b"data",
+ out)
+
class UtilityTests(TestCase):
@@ -149,6 +182,8 @@ class UtilityTests(TestCase):
util.setup_testing_defaults(env)
if isinstance(value, StringIO):
self.assertIsInstance(env[key], StringIO)
+ elif isinstance(value,BytesIO):
+ self.assertIsInstance(env[key],BytesIO)
else:
self.assertEqual(env[key], value)
@@ -220,7 +255,7 @@ class UtilityTests(TestCase):
('wsgi.run_once', 0),
('wsgi.multithread', 0),
('wsgi.multiprocess', 0),
- ('wsgi.input', StringIO("")),
+ ('wsgi.input', BytesIO()),
('wsgi.errors', StringIO()),
('wsgi.url_scheme','http'),
]:
@@ -245,6 +280,7 @@ class UtilityTests(TestCase):
def testAppURIs(self):
self.checkAppURI("http://127.0.0.1/")
self.checkAppURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
+ self.checkAppURI("http://127.0.0.1/sp%C3%A4m", SCRIPT_NAME="/späm")
self.checkAppURI("http://spam.example.com:2071/",
HTTP_HOST="spam.example.com:2071", SERVER_PORT="2071")
self.checkAppURI("http://spam.example.com/",
@@ -258,6 +294,7 @@ class UtilityTests(TestCase):
def testReqURIs(self):
self.checkReqURI("http://127.0.0.1/")
self.checkReqURI("http://127.0.0.1/spam", SCRIPT_NAME="/spam")
+ self.checkReqURI("http://127.0.0.1/sp%C3%A4m", SCRIPT_NAME="/späm")
self.checkReqURI("http://127.0.0.1/spammity/spam",
SCRIPT_NAME="/spammity", PATH_INFO="/spam")
self.checkReqURI("http://127.0.0.1/spammity/spam;ham",
@@ -302,7 +339,7 @@ class HeaderTests(TestCase):
del h['foo'] # should not raise an error
h['Foo'] = 'bar'
- for m in h.has_key, h.__contains__, h.get, h.get_all, h.__getitem__:
+ for m in h.__contains__, h.get, h.get_all, h.__getitem__:
self.assertTrue(m('foo'))
self.assertTrue(m('Foo'))
self.assertTrue(m('FOO'))
@@ -342,7 +379,6 @@ class HeaderTests(TestCase):
'\r\n'
)
-
class ErrorHandler(BaseCGIHandler):
"""Simple handler subclass for testing BaseHandler"""
@@ -354,7 +390,7 @@ class ErrorHandler(BaseCGIHandler):
def __init__(self,**kw):
setup_testing_defaults(kw)
BaseCGIHandler.__init__(
- self, StringIO(''), StringIO(), StringIO(), kw,
+ self, BytesIO(), BytesIO(), StringIO(), kw,
multithread=True, multiprocess=True
)
@@ -418,12 +454,16 @@ class HandlerTests(TestCase):
def trivial_app1(e,s):
s('200 OK',[])
- return [e['wsgi.url_scheme']]
+ return [e['wsgi.url_scheme'].encode('iso-8859-1')]
def trivial_app2(e,s):
- s('200 OK',[])(e['wsgi.url_scheme'])
+ s('200 OK',[])(e['wsgi.url_scheme'].encode('iso-8859-1'))
return []
+ def trivial_app3(e,s):
+ s('200 OK',[])
+ return ['\u0442\u0435\u0441\u0442'.encode("utf-8")]
+
def trivial_app4(e,s):
# Simulate a response to a HEAD request
s('200 OK',[('Content-Length', '12345')])
@@ -432,18 +472,25 @@ class HandlerTests(TestCase):
h = TestHandler()
h.run(trivial_app1)
self.assertEqual(h.stdout.getvalue(),
- "Status: 200 OK\r\n"
+ ("Status: 200 OK\r\n"
"Content-Length: 4\r\n"
"\r\n"
- "http")
+ "http").encode("iso-8859-1"))
h = TestHandler()
h.run(trivial_app2)
self.assertEqual(h.stdout.getvalue(),
- "Status: 200 OK\r\n"
+ ("Status: 200 OK\r\n"
"\r\n"
- "http")
+ "http").encode("iso-8859-1"))
+ h = TestHandler()
+ h.run(trivial_app3)
+ self.assertEqual(h.stdout.getvalue(),
+ b'Status: 200 OK\r\n'
+ b'Content-Length: 8\r\n'
+ b'\r\n'
+ b'\xd1\x82\xd0\xb5\xd1\x81\xd1\x82')
h = TestHandler()
h.run(trivial_app4)
@@ -464,23 +511,24 @@ class HandlerTests(TestCase):
h = ErrorHandler()
h.run(non_error_app)
self.assertEqual(h.stdout.getvalue(),
- "Status: 200 OK\r\n"
+ ("Status: 200 OK\r\n"
"Content-Length: 0\r\n"
- "\r\n")
+ "\r\n").encode("iso-8859-1"))
self.assertEqual(h.stderr.getvalue(),"")
h = ErrorHandler()
h.run(error_app)
self.assertEqual(h.stdout.getvalue(),
- "Status: %s\r\n"
+ ("Status: %s\r\n"
"Content-Type: text/plain\r\n"
"Content-Length: %d\r\n"
- "\r\n%s" % (h.error_status,len(h.error_body),h.error_body))
+ "\r\n" % (h.error_status,len(h.error_body))).encode('iso-8859-1')
+ + h.error_body)
- self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1)
+ self.assertIn("AssertionError", h.stderr.getvalue())
def testErrorAfterOutput(self):
- MSG = "Some output has been sent"
+ MSG = b"Some output has been sent"
def error_app(e,s):
s("200 OK",[])(MSG)
raise AssertionError("This should be caught by handler")
@@ -488,9 +536,9 @@ class HandlerTests(TestCase):
h = ErrorHandler()
h.run(error_app)
self.assertEqual(h.stdout.getvalue(),
- "Status: 200 OK\r\n"
- "\r\n"+MSG)
- self.assertNotEqual(h.stderr.getvalue().find("AssertionError"), -1)
+ ("Status: 200 OK\r\n"
+ "\r\n".encode("iso-8859-1")+MSG))
+ self.assertIn("AssertionError", h.stderr.getvalue())
def testHeaderFormats(self):
@@ -505,7 +553,7 @@ class HandlerTests(TestCase):
)
shortpat = (
"Status: 200 OK\r\n" "Content-Length: 0\r\n" "\r\n"
- )
+ ).encode("iso-8859-1")
for ssw in "FooBar/1.0", None:
sw = ssw and "Server: %s\r\n" % ssw or ""
@@ -526,13 +574,31 @@ class HandlerTests(TestCase):
h.server_software = ssw
h.run(non_error_app)
if proto=="HTTP/0.9":
- self.assertEqual(h.stdout.getvalue(),"")
+ self.assertEqual(h.stdout.getvalue(),b"")
else:
self.assertTrue(
- re.match(stdpat%(version,sw), h.stdout.getvalue()),
- (stdpat%(version,sw), h.stdout.getvalue())
+ re.match((stdpat%(version,sw)).encode("iso-8859-1"),
+ h.stdout.getvalue()),
+ ((stdpat%(version,sw)).encode("iso-8859-1"),
+ h.stdout.getvalue())
)
+ def testBytesData(self):
+ def app(e, s):
+ s("200 OK", [
+ ("Content-Type", "text/plain; charset=utf-8"),
+ ])
+ return [b"data"]
+
+ h = TestHandler()
+ h.run(app)
+ self.assertEqual(b"Status: 200 OK\r\n"
+ b"Content-Type: text/plain; charset=utf-8\r\n"
+ b"Content-Length: 4\r\n"
+ b"\r\n"
+ b"data",
+ h.stdout.getvalue())
+
def testCloseOnError(self):
side_effects = {'close_called': False}
MSG = b"Some output has been sent"
@@ -543,7 +609,6 @@ class HandlerTests(TestCase):
while True:
yield b'blah'
raise AssertionError("This should be caught by handler")
-
def close(self):
side_effects['close_called'] = True
return CrashyIterable()
@@ -554,7 +619,7 @@ class HandlerTests(TestCase):
def test_main():
- test_support.run_unittest(__name__)
+ support.run_unittest(__name__)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_xdrlib.py b/Lib/test/test_xdrlib.py
index 9ba8885c0aa..6004c9f1c67 100644
--- a/Lib/test/test_xdrlib.py
+++ b/Lib/test/test_xdrlib.py
@@ -1,4 +1,4 @@
-from test import test_support
+from test import support
import unittest
import xdrlib
@@ -8,15 +8,15 @@ class XDRTest(unittest.TestCase):
def test_xdr(self):
p = xdrlib.Packer()
- s = 'hello world'
- a = ['what', 'is', 'hapnin', 'doctor']
+ s = b'hello world'
+ a = [b'what', b'is', b'hapnin', b'doctor']
p.pack_int(42)
p.pack_int(-17)
p.pack_uint(9)
p.pack_bool(True)
p.pack_bool(False)
- p.pack_uhyper(45L)
+ p.pack_uhyper(45)
p.pack_float(1.9)
p.pack_double(1.9)
p.pack_string(s)
@@ -42,17 +42,17 @@ class XDRTest(unittest.TestCase):
up.set_position(pos)
self.assertTrue(up.unpack_bool() is False)
- self.assertEqual(up.unpack_uhyper(), 45L)
+ self.assertEqual(up.unpack_uhyper(), 45)
self.assertAlmostEqual(up.unpack_float(), 1.9)
self.assertAlmostEqual(up.unpack_double(), 1.9)
self.assertEqual(up.unpack_string(), s)
- self.assertEqual(up.unpack_list(up.unpack_uint), range(5))
+ self.assertEqual(up.unpack_list(up.unpack_uint), list(range(5)))
self.assertEqual(up.unpack_array(up.unpack_string), a)
up.done()
self.assertRaises(EOFError, up.unpack_uint)
def test_main():
- test_support.run_unittest(XDRTest)
+ support.run_unittest(XDRTest)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 4e161ca2f3a..3092f3bc11e 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -12,14 +12,19 @@
# except if the test is specific to the Python implementation.
import sys
-import cgi
+import html
+import unittest
-from test import test_support
-from test.test_support import findfile
+from test import support
+from test.support import findfile
from xml.etree import ElementTree as ET
SIMPLE_XMLFILE = findfile("simple.xml", subdir="xmltestdata")
+try:
+ SIMPLE_XMLFILE.encode("utf8")
+except UnicodeEncodeError:
+ raise unittest.SkipTest("filename is not encodable to utf8")
SIMPLE_NS_XMLFILE = findfile("simple-ns.xml", subdir="xmltestdata")
SAMPLE_XML = """\
@@ -64,13 +69,16 @@ def sanity():
def check_method(method):
if not hasattr(method, '__call__'):
- print method, "not callable"
+ print(method, "not callable")
-def serialize(elem, to_string=True, **options):
- import StringIO
- file = StringIO.StringIO()
+def serialize(elem, to_string=True, encoding='unicode', **options):
+ import io
+ if encoding != 'unicode':
+ file = io.BytesIO()
+ else:
+ file = io.StringIO()
tree = ET.ElementTree(elem)
- tree.write(file, **options)
+ tree.write(file, encoding=encoding, **options)
if to_string:
return file.getvalue()
else:
@@ -92,11 +100,19 @@ def normalize_crlf(tree):
if elem.tail:
elem.tail = elem.tail.replace("\r\n", "\n")
+def normalize_exception(func, *args, **kwargs):
+ # Ignore the exception __module__
+ try:
+ func(*args, **kwargs)
+ except Exception as err:
+ print("Traceback (most recent call last):")
+ print("{}: {}".format(err.__class__.__name__, err))
+
def check_string(string):
len(string)
for char in string:
if len(char) != 1:
- print "expected one-character string, got %r" % char
+ print("expected one-character string, got %r" % char)
new_string = string + ""
new_string = string + " "
string[:0]
@@ -109,19 +125,19 @@ def check_mapping(mapping):
item = mapping[key]
mapping["key"] = "value"
if mapping["key"] != "value":
- print "expected value string, got %r" % mapping["key"]
+ print("expected value string, got %r" % mapping["key"])
def check_element(element):
if not ET.iselement(element):
- print "not an element"
+ print("not an element")
if not hasattr(element, "tag"):
- print "no tag member"
+ print("no tag member")
if not hasattr(element, "attrib"):
- print "no attrib member"
+ print("no attrib member")
if not hasattr(element, "text"):
- print "no text member"
+ print("no text member")
if not hasattr(element, "tail"):
- print "no tail member"
+ print("no tail member")
check_string(element.tag)
check_mapping(element.attrib)
@@ -136,7 +152,7 @@ def check_element(element):
# element tree tests
def interface():
- r"""
+ """
Test element tree interface.
>>> element = ET.Element("tag")
@@ -144,7 +160,7 @@ def interface():
>>> tree = ET.ElementTree(element)
>>> check_element(tree.getroot())
- >>> element = ET.Element("t\xe4g", key="value")
+ >>> element = ET.Element("t\\xe4g", key="value")
>>> tree = ET.ElementTree(element)
>>> repr(element) # doctest: +ELLIPSIS
"<Element 't\\xe4g' at 0x...>"
@@ -172,12 +188,12 @@ def interface():
These methods return an iterable. See bug 6472.
- >>> check_method(element.iter("tag").next)
- >>> check_method(element.iterfind("tag").next)
- >>> check_method(element.iterfind("*").next)
- >>> check_method(tree.iter("tag").next)
- >>> check_method(tree.iterfind("tag").next)
- >>> check_method(tree.iterfind("*").next)
+ >>> check_method(element.iter("tag").__next__)
+ >>> check_method(element.iterfind("tag").__next__)
+ >>> check_method(element.iterfind("*").__next__)
+ >>> check_method(tree.iter("tag").__next__)
+ >>> check_method(tree.iterfind("tag").__next__)
+ >>> check_method(tree.iterfind("*").__next__)
These aliases are provided:
@@ -414,9 +430,9 @@ def find():
def file_init():
"""
- >>> import StringIO
+ >>> import io
- >>> stringfile = StringIO.StringIO(SAMPLE_XML)
+ >>> stringfile = io.BytesIO(SAMPLE_XML.encode("utf-8"))
>>> tree = ET.ElementTree(file=stringfile)
>>> tree.find("tag").tag
'tag'
@@ -521,7 +537,7 @@ def attrib():
>>> elem.set('testa', 'testval')
>>> elem.set('testb', 'test2')
>>> ET.tostring(elem)
- '<test testa="testval" testb="test2">aa</test>'
+ b'<test testa="testval" testb="test2">aa</test>'
>>> sorted(elem.keys())
['testa', 'testb']
>>> sorted(elem.items())
@@ -531,7 +547,7 @@ def attrib():
>>> elem.attrib['testb'] = 'test1'
>>> elem.attrib['testc'] = 'test2'
>>> ET.tostring(elem)
- '<test testa="testval" testb="test1" testc="test2">aa</test>'
+ b'<test testa="testval" testb="test1" testc="test2">aa</test>'
"""
def makeelement():
@@ -542,7 +558,7 @@ def makeelement():
>>> attrib = {"key": "value"}
>>> subelem = elem.makeelement("subtag", attrib)
>>> if subelem.attrib is attrib:
- ... print "attrib aliasing"
+ ... print("attrib aliasing")
>>> elem.append(subelem)
>>> serialize(elem)
'<tag><subtag key="value" /></tag>'
@@ -571,7 +587,7 @@ def parsefile():
>>> tree = ET.parse(SIMPLE_XMLFILE)
>>> normalize_crlf(tree)
- >>> tree.write(sys.stdout)
+ >>> tree.write(sys.stdout, encoding='unicode')
<root>
<element key="value">text</element>
<element>text</element>tail
@@ -579,7 +595,7 @@ def parsefile():
</root>
>>> tree = ET.parse(SIMPLE_NS_XMLFILE)
>>> normalize_crlf(tree)
- >>> tree.write(sys.stdout)
+ >>> tree.write(sys.stdout, encoding='unicode')
<ns0:root xmlns:ns0="namespace">
<ns0:element key="value">text</ns0:element>
<ns0:element>text</ns0:element>tail
@@ -593,7 +609,7 @@ def parsefile():
>>> parser.version # doctest: +ELLIPSIS
'Expat ...'
>>> parser.feed(data)
- >>> print serialize(parser.close())
+ >>> print(serialize(parser.close()))
<root>
<element key="value">text</element>
<element>text</element>tail
@@ -602,7 +618,7 @@ def parsefile():
>>> parser = ET.XMLTreeBuilder() # 1.2 compatibility
>>> parser.feed(data)
- >>> print serialize(parser.close())
+ >>> print(serialize(parser.close()))
<root>
<element key="value">text</element>
<element>text</element>tail
@@ -612,7 +628,7 @@ def parsefile():
>>> target = ET.TreeBuilder()
>>> parser = ET.XMLParser(target=target)
>>> parser.feed(data)
- >>> print serialize(parser.close())
+ >>> print(serialize(parser.close()))
<root>
<element key="value">text</element>
<element>text</element>tail
@@ -623,19 +639,19 @@ def parsefile():
def parseliteral():
"""
>>> element = ET.XML("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
+ >>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
<html><body>text</body></html>
>>> element = ET.fromstring("<html><body>text</body></html>")
- >>> ET.ElementTree(element).write(sys.stdout)
+ >>> ET.ElementTree(element).write(sys.stdout, encoding='unicode')
<html><body>text</body></html>
>>> sequence = ["<html><body>", "text</bo", "dy></html>"]
>>> element = ET.fromstringlist(sequence)
- >>> print ET.tostring(element)
- <html><body>text</body></html>
- >>> print "".join(ET.tostringlist(element))
- <html><body>text</body></html>
+ >>> ET.tostring(element)
+ b'<html><body>text</body></html>'
+ >>> b"".join(ET.tostringlist(element))
+ b'<html><body>text</body></html>'
>>> ET.tostring(element, "ascii")
- "<?xml version='1.0' encoding='ascii'?>\\n<html><body>text</body></html>"
+ b"<?xml version='1.0' encoding='ascii'?>\\n<html><body>text</body></html>"
>>> _, ids = ET.XMLID("<html><body>text</body></html>")
>>> len(ids)
0
@@ -654,10 +670,10 @@ def iterparse():
>>> context = iterparse(SIMPLE_XMLFILE)
>>> action, elem = next(context)
- >>> print action, elem.tag
+ >>> print(action, elem.tag)
end element
>>> for action, elem in context:
- ... print action, elem.tag
+ ... print(action, elem.tag)
end element
end empty-element
end root
@@ -666,7 +682,7 @@ def iterparse():
>>> context = iterparse(SIMPLE_NS_XMLFILE)
>>> for action, elem in context:
- ... print action, elem.tag
+ ... print(action, elem.tag)
end {namespace}element
end {namespace}element
end {namespace}empty-element
@@ -675,17 +691,17 @@ def iterparse():
>>> events = ()
>>> context = iterparse(SIMPLE_XMLFILE, events)
>>> for action, elem in context:
- ... print action, elem.tag
+ ... print(action, elem.tag)
>>> events = ()
>>> context = iterparse(SIMPLE_XMLFILE, events=events)
>>> for action, elem in context:
- ... print action, elem.tag
+ ... print(action, elem.tag)
>>> events = ("start", "end")
>>> context = iterparse(SIMPLE_XMLFILE, events)
>>> for action, elem in context:
- ... print action, elem.tag
+ ... print(action, elem.tag)
start root
start element
end element
@@ -699,9 +715,9 @@ def iterparse():
>>> context = iterparse(SIMPLE_NS_XMLFILE, events)
>>> for action, elem in context:
... if action in ("start", "end"):
- ... print action, elem.tag
+ ... print(action, elem.tag)
... else:
- ... print action, elem
+ ... print(action, elem)
start-ns ('', 'namespace')
start {namespace}root
start {namespace}element
@@ -719,25 +735,25 @@ def iterparse():
Traceback (most recent call last):
ValueError: unknown event 'bogus'
- >>> import StringIO
+ >>> import io
- >>> source = StringIO.StringIO(
- ... "<?xml version='1.0' encoding='iso-8859-1'?>\\n"
- ... "<body xmlns='http://&#233;ffbot.org/ns'\\n"
- ... " xmlns:cl\\xe9='http://effbot.org/ns'>text</body>\\n")
+ >>> source = io.BytesIO(
+ ... b"<?xml version='1.0' encoding='iso-8859-1'?>\\n"
+ ... b"<body xmlns='http://&#233;ffbot.org/ns'\\n"
+ ... b" xmlns:cl\\xe9='http://effbot.org/ns'>text</body>\\n")
>>> events = ("start-ns",)
>>> context = iterparse(source, events)
>>> for action, elem in context:
- ... print action, elem
- start-ns ('', u'http://\\xe9ffbot.org/ns')
- start-ns (u'cl\\xe9', 'http://effbot.org/ns')
+ ... print(action, elem)
+ start-ns ('', 'http://\\xe9ffbot.org/ns')
+ start-ns ('cl\\xe9', 'http://effbot.org/ns')
- >>> source = StringIO.StringIO("<document />junk")
+ >>> source = io.StringIO("<document />junk")
>>> try:
... for action, elem in iterparse(source):
- ... print action, elem.tag
- ... except ET.ParseError, v:
- ... print v
+ ... print(action, elem.tag)
+ ... except ET.ParseError as v:
+ ... print(v)
end document
junk after document element: line 1, column 12
"""
@@ -772,9 +788,9 @@ def custom_builder():
... data = f.read()
>>> class Builder:
... def start(self, tag, attrib):
- ... print "start", tag
+ ... print("start", tag)
... def end(self, tag):
- ... print "end", tag
+ ... print("end", tag)
... def data(self, text):
... pass
>>> builder = Builder()
@@ -793,15 +809,15 @@ def custom_builder():
... data = f.read()
>>> class Builder:
... def start(self, tag, attrib):
- ... print "start", tag
+ ... print("start", tag)
... def end(self, tag):
- ... print "end", tag
+ ... print("end", tag)
... def data(self, text):
... pass
... def pi(self, target, data):
- ... print "pi", target, repr(data)
+ ... print("pi", target, repr(data))
... def comment(self, data):
- ... print "comment", repr(data)
+ ... print("comment", repr(data))
>>> builder = Builder()
>>> parser = ET.XMLParser(target=builder)
>>> parser.feed(data)
@@ -822,7 +838,7 @@ def getchildren():
"""
Test Element.getchildren()
- >>> with open(SIMPLE_XMLFILE, "r") as f:
+ >>> with open(SIMPLE_XMLFILE, "rb") as f:
... tree = ET.parse(f)
>>> for elem in tree.getroot().iter():
... summarize_list(elem.getchildren())
@@ -869,10 +885,10 @@ def writestring():
"""
>>> elem = ET.XML("<html><body>text</body></html>")
>>> ET.tostring(elem)
- '<html><body>text</body></html>'
+ b'<html><body>text</body></html>'
>>> elem = ET.fromstring("<html><body>text</body></html>")
>>> ET.tostring(elem)
- '<html><body>text</body></html>'
+ b'<html><body>text</body></html>'
"""
def check_encoding(encoding):
@@ -891,58 +907,58 @@ def encoding():
Test encoding issues.
>>> elem = ET.Element("tag")
- >>> elem.text = u"abc"
+ >>> elem.text = "abc"
>>> serialize(elem)
'<tag>abc</tag>'
>>> serialize(elem, encoding="utf-8")
- '<tag>abc</tag>'
+ b'<tag>abc</tag>'
>>> serialize(elem, encoding="us-ascii")
- '<tag>abc</tag>'
+ b'<tag>abc</tag>'
>>> serialize(elem, encoding="iso-8859-1")
- "<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>abc</tag>"
+ b"<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>abc</tag>"
>>> elem.text = "<&\"\'>"
>>> serialize(elem)
'<tag>&lt;&amp;"\'&gt;</tag>'
>>> serialize(elem, encoding="utf-8")
- '<tag>&lt;&amp;"\'&gt;</tag>'
+ b'<tag>&lt;&amp;"\'&gt;</tag>'
>>> serialize(elem, encoding="us-ascii") # cdata characters
- '<tag>&lt;&amp;"\'&gt;</tag>'
+ b'<tag>&lt;&amp;"\'&gt;</tag>'
>>> serialize(elem, encoding="iso-8859-1")
- '<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag>&lt;&amp;"\'&gt;</tag>'
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag>&lt;&amp;"\'&gt;</tag>'
>>> elem.attrib["key"] = "<&\"\'>"
>>> elem.text = None
>>> serialize(elem)
'<tag key="&lt;&amp;&quot;\'&gt;" />'
>>> serialize(elem, encoding="utf-8")
- '<tag key="&lt;&amp;&quot;\'&gt;" />'
+ b'<tag key="&lt;&amp;&quot;\'&gt;" />'
>>> serialize(elem, encoding="us-ascii")
- '<tag key="&lt;&amp;&quot;\'&gt;" />'
+ b'<tag key="&lt;&amp;&quot;\'&gt;" />'
>>> serialize(elem, encoding="iso-8859-1")
- '<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="&lt;&amp;&quot;\'&gt;" />'
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="&lt;&amp;&quot;\'&gt;" />'
- >>> elem.text = u'\xe5\xf6\xf6<>'
+ >>> elem.text = '\xe5\xf6\xf6<>'
>>> elem.attrib.clear()
>>> serialize(elem)
- '<tag>&#229;&#246;&#246;&lt;&gt;</tag>'
+ '<tag>\xe5\xf6\xf6&lt;&gt;</tag>'
>>> serialize(elem, encoding="utf-8")
- '<tag>\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;</tag>'
+ b'<tag>\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;</tag>'
>>> serialize(elem, encoding="us-ascii")
- '<tag>&#229;&#246;&#246;&lt;&gt;</tag>'
+ b'<tag>&#229;&#246;&#246;&lt;&gt;</tag>'
>>> serialize(elem, encoding="iso-8859-1")
- "<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>\xe5\xf6\xf6&lt;&gt;</tag>"
+ b"<?xml version='1.0' encoding='iso-8859-1'?>\n<tag>\xe5\xf6\xf6&lt;&gt;</tag>"
- >>> elem.attrib["key"] = u'\xe5\xf6\xf6<>'
+ >>> elem.attrib["key"] = '\xe5\xf6\xf6<>'
>>> elem.text = None
>>> serialize(elem)
- '<tag key="&#229;&#246;&#246;&lt;&gt;" />'
+ '<tag key="\xe5\xf6\xf6&lt;&gt;" />'
>>> serialize(elem, encoding="utf-8")
- '<tag key="\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;" />'
+ b'<tag key="\xc3\xa5\xc3\xb6\xc3\xb6&lt;&gt;" />'
>>> serialize(elem, encoding="us-ascii")
- '<tag key="&#229;&#246;&#246;&lt;&gt;" />'
+ b'<tag key="&#229;&#246;&#246;&lt;&gt;" />'
>>> serialize(elem, encoding="iso-8859-1")
- '<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="\xe5\xf6\xf6&lt;&gt;" />'
+ b'<?xml version=\'1.0\' encoding=\'iso-8859-1\'?>\n<tag key="\xe5\xf6\xf6&lt;&gt;" />'
"""
def methods():
@@ -1008,16 +1024,18 @@ def entity():
1) good entities
>>> e = ET.XML("<document title='&#x8230;'>test</document>")
+ >>> serialize(e, encoding="us-ascii")
+ b'<document title="&#33328;">test</document>'
>>> serialize(e)
- '<document title="&#33328;">test</document>'
+ '<document title="\u8230">test</document>'
2) bad entities
- >>> ET.XML("<document>&entity;</document>")
+ >>> normalize_exception(ET.XML, "<document>&entity;</document>")
Traceback (most recent call last):
ParseError: undefined entity: line 1, column 10
- >>> ET.XML(ENTITY_XML)
+ >>> normalize_exception(ET.XML, ENTITY_XML)
Traceback (most recent call last):
ParseError: undefined entity &entity;: line 5, column 10
@@ -1049,7 +1067,7 @@ def error(xml):
try:
ET.XML(xml)
except ET.ParseError:
- return sys.exc_value
+ return sys.exc_info()[1]
def namespace():
"""
@@ -1077,7 +1095,7 @@ def namespace():
3) unknown namespaces
>>> elem = ET.XML(SAMPLE_XML_NS)
- >>> print serialize(elem)
+ >>> print(serialize(elem))
<ns0:body xmlns:ns0="http://effbot.org/ns">
<ns0:tag>text</ns0:tag>
<ns0:tag />
@@ -1230,16 +1248,16 @@ def processinginstruction():
Test ProcessingInstruction directly
>>> ET.tostring(ET.ProcessingInstruction('test', 'instruction'))
- '<?test instruction?>'
+ b'<?test instruction?>'
>>> ET.tostring(ET.PI('test', 'instruction'))
- '<?test instruction?>'
+ b'<?test instruction?>'
Issue #2746
>>> ET.tostring(ET.PI('test', '<testing&>'))
- '<?test <testing&>?>'
- >>> ET.tostring(ET.PI('test', u'<testing&>\xe3'), 'latin1')
- "<?xml version='1.0' encoding='latin1'?>\\n<?test <testing&>\\xe3?>"
+ b'<?test <testing&>?>'
+ >>> ET.tostring(ET.PI('test', '<testing&>\xe3'), 'latin1')
+ b"<?xml version='1.0' encoding='latin1'?>\\n<?test <testing&>\\xe3?>"
"""
#
@@ -1316,7 +1334,7 @@ XINCLUDE["default.xml"] = """\
<p>Example.</p>
<xi:include href="{}"/>
</document>
-""".format(cgi.escape(SIMPLE_XMLFILE, True))
+""".format(html.escape(SIMPLE_XMLFILE, True))
def xinclude_loader(href, parse="xml", encoding=None):
try:
@@ -1337,7 +1355,7 @@ def xinclude():
>>> document = xinclude_loader("C1.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(document) # C1
+ >>> print(serialize(document)) # C1
<document>
<p>120 Mz is adequate for an average home user.</p>
<disclaimer>
@@ -1351,7 +1369,7 @@ def xinclude():
>>> document = xinclude_loader("C2.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(document) # C2
+ >>> print(serialize(document)) # C2
<document>
<p>This document has been accessed
324387 times.</p>
@@ -1371,7 +1389,7 @@ def xinclude():
>>> document = xinclude_loader("C3.xml")
>>> ElementInclude.include(document, xinclude_loader)
- >>> print serialize(document) # C3
+ >>> print(serialize(document)) # C3
<document>
<p>The following is the source of the "data.xml" resource:</p>
<example>&lt;?xml version='1.0'?&gt;
@@ -1388,7 +1406,7 @@ def xinclude():
>>> ElementInclude.include(document, xinclude_loader)
Traceback (most recent call last):
IOError: resource not found
- >>> # print serialize(document) # C5
+ >>> # print(serialize(document)) # C5
"""
def xinclude_default():
@@ -1397,7 +1415,7 @@ def xinclude_default():
>>> document = xinclude_loader("default.xml")
>>> ElementInclude.include(document)
- >>> print serialize(document) # default
+ >>> print(serialize(document)) # default
<document>
<p>Example.</p>
<root>
@@ -1440,28 +1458,28 @@ def xinclude_failures():
>>> document = ET.XML(XINCLUDE["C1.xml"])
>>> ElementInclude.include(document, loader=none_loader)
Traceback (most recent call last):
- FatalIncludeError: cannot load 'disclaimer.xml' as 'xml'
+ xml.etree.ElementInclude.FatalIncludeError: cannot load 'disclaimer.xml' as 'xml'
Test failure to locate included text file.
>>> document = ET.XML(XINCLUDE["C2.xml"])
>>> ElementInclude.include(document, loader=none_loader)
Traceback (most recent call last):
- FatalIncludeError: cannot load 'count.txt' as 'text'
+ xml.etree.ElementInclude.FatalIncludeError: cannot load 'count.txt' as 'text'
Test bad parse type.
>>> document = ET.XML(XINCLUDE_BAD["B1.xml"])
>>> ElementInclude.include(document, loader=none_loader)
Traceback (most recent call last):
- FatalIncludeError: unknown parse type in xi:include tag ('BAD_TYPE')
+ xml.etree.ElementInclude.FatalIncludeError: unknown parse type in xi:include tag ('BAD_TYPE')
Test xi:fallback outside xi:include.
>>> document = ET.XML(XINCLUDE_BAD["B2.xml"])
>>> ElementInclude.include(document, loader=none_loader)
Traceback (most recent call last):
- FatalIncludeError: xi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')
+ xml.etree.ElementInclude.FatalIncludeError: xi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')
"""
# --------------------------------------------------------------------
@@ -1532,7 +1550,7 @@ def bug_xmltoolkitX1():
dump() doesn't flush the output buffer
>>> tree = ET.XML("<doc><table><tbody/></table></doc>")
- >>> ET.dump(tree); sys.stdout.write("tail")
+ >>> ET.dump(tree); print("tail")
<doc><table><tbody /></table></doc>
tail
@@ -1543,28 +1561,28 @@ def bug_xmltoolkit39():
non-ascii element and attribute names doesn't work
- >>> tree = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><t\xe4g />")
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><t\\xe4g />")
>>> ET.tostring(tree, "utf-8")
- '<t\\xc3\\xa4g />'
+ b'<t\\xc3\\xa4g />'
- >>> tree = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><tag \xe4ttr='v&#228;lue' />")
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><tag \\xe4ttr='v&#228;lue' />")
>>> tree.attrib
- {u'\\xe4ttr': u'v\\xe4lue'}
+ {'\\xe4ttr': 'v\\xe4lue'}
>>> ET.tostring(tree, "utf-8")
- '<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
+ b'<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
- >>> tree = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><t\xe4g>text</t\xe4g>")
+ >>> tree = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><t\\xe4g>text</t\\xe4g>")
>>> ET.tostring(tree, "utf-8")
- '<t\\xc3\\xa4g>text</t\\xc3\\xa4g>'
+ b'<t\\xc3\\xa4g>text</t\\xc3\\xa4g>'
- >>> tree = ET.Element(u"t\u00e4g")
+ >>> tree = ET.Element("t\u00e4g")
>>> ET.tostring(tree, "utf-8")
- '<t\\xc3\\xa4g />'
+ b'<t\\xc3\\xa4g />'
>>> tree = ET.Element("tag")
- >>> tree.set(u"\u00e4ttr", u"v\u00e4lue")
+ >>> tree.set("\u00e4ttr", "v\u00e4lue")
>>> ET.tostring(tree, "utf-8")
- '<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
+ b'<tag \\xc3\\xa4ttr="v\\xc3\\xa4lue" />'
"""
@@ -1574,8 +1592,10 @@ def bug_xmltoolkit54():
problems handling internally defined entities
>>> e = ET.XML("<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>")
+ >>> serialize(e, encoding="us-ascii")
+ b'<doc>&#33328;</doc>'
>>> serialize(e)
- '<doc>&#33328;</doc>'
+ '<doc>\u8230</doc>'
"""
@@ -1584,7 +1604,7 @@ def bug_xmltoolkit55():
make sure we're reporting the first error, not the last
- >>> e = ET.XML("<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>")
+ >>> normalize_exception(ET.XML, b"<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>")
Traceback (most recent call last):
ParseError: undefined entity &ldots;: line 1, column 36
@@ -1619,10 +1639,10 @@ def xmltoolkit62():
Don't crash when using custom entities.
>>> xmltoolkit62()
- u'A new cultivar of Begonia plant named \u2018BCT9801BEG\u2019.'
+ 'A new cultivar of Begonia plant named \u2018BCT9801BEG\u2019.'
"""
- ENTITIES = {u'rsquo': u'\u2019', u'lsquo': u'\u2018'}
+ ENTITIES = {'rsquo': '\u2019', 'lsquo': '\u2018'}
parser = ET.XMLTreeBuilder()
parser.entity.update(ENTITIES)
parser.feed(XMLTOOLKIT62_DOC)
@@ -1656,11 +1676,11 @@ def bug_200708_newline():
>>> e = ET.Element('SomeTag', text="def _f():\n return 3\n")
>>> ET.tostring(e)
- '<SomeTag text="def _f():&#10; return 3&#10;" />'
+ b'<SomeTag text="def _f():&#10; return 3&#10;" />'
>>> ET.XML(ET.tostring(e)).get("text")
'def _f():\n return 3\n'
>>> ET.tostring(ET.XML(ET.tostring(e)))
- '<SomeTag text="def _f():&#10; return 3&#10;" />'
+ b'<SomeTag text="def _f():&#10; return 3&#10;" />'
"""
@@ -1711,15 +1731,15 @@ def bug_200709_register_namespace():
"""
>>> ET.tostring(ET.Element("{http://namespace.invalid/does/not/exist/}title"))
- '<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />'
+ b'<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />'
>>> ET.register_namespace("foo", "http://namespace.invalid/does/not/exist/")
>>> ET.tostring(ET.Element("{http://namespace.invalid/does/not/exist/}title"))
- '<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />'
+ b'<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />'
And the Dublin Core namespace is in the default list:
>>> ET.tostring(ET.Element("{http://purl.org/dc/elements/1.1/}title"))
- '<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />'
+ b'<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />'
"""
@@ -1788,12 +1808,12 @@ def bug_1534630():
def check_issue6233():
"""
- >>> e = ET.XML("<?xml version='1.0' encoding='utf-8'?><body>t\\xc3\\xa3g</body>")
+ >>> e = ET.XML(b"<?xml version='1.0' encoding='utf-8'?><body>t\\xc3\\xa3g</body>")
>>> ET.tostring(e, 'ascii')
- "<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
- >>> e = ET.XML("<?xml version='1.0' encoding='iso-8859-1'?><body>t\\xe3g</body>")
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+ >>> e = ET.XML(b"<?xml version='1.0' encoding='iso-8859-1'?><body>t\\xe3g</body>")
>>> ET.tostring(e, 'ascii')
- "<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
+ b"<?xml version='1.0' encoding='ascii'?>\\n<body>t&#227;g</body>"
"""
@@ -1805,7 +1825,7 @@ def check_issue3151():
'{${stuff}}localname'
>>> t = ET.ElementTree(e)
>>> ET.tostring(e)
- '<ns0:localname xmlns:ns0="${stuff}" />'
+ b'<ns0:localname xmlns:ns0="${stuff}" />'
"""
@@ -1822,6 +1842,15 @@ def check_issue6565():
"""
+def check_issue10777():
+ """
+ Registering a namespace twice caused a "dictionary changed size during
+ iteration" bug.
+
+ >>> ET.register_namespace('test10777', 'http://myuri/')
+ >>> ET.register_namespace('test10777', 'http://myuri/')
+ """
+
def check_html_empty_elems_serialization(self):
# issue 15970
# from http://www.w3.org/TR/html401/index/elements.html
@@ -1867,8 +1896,7 @@ class CleanContext(object):
# XMLParser.doctype() is deprecated.
("This method of XMLParser is deprecated. Define doctype.. "
"method on the TreeBuilder target.", DeprecationWarning))
- self.checkwarnings = test_support.check_warnings(*deprecations,
- quiet=quiet)
+ self.checkwarnings = support.check_warnings(*deprecations, quiet=quiet)
def __enter__(self):
from xml.etree import ElementTree
@@ -1898,7 +1926,7 @@ def test_main(module_name='xml.etree.ElementTree'):
# XXX the C module should give the same warnings as the Python module
with CleanContext(quiet=not use_py_module):
- test_support.run_doctest(test_xml_etree, verbosity=True)
+ support.run_doctest(test_xml_etree, verbosity=True)
# The module should not be changed by the tests
assert test_xml_etree.ET.__name__ == module_name
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index 474a4b4e182..2ff118fae88 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -1,27 +1,43 @@
# xml.etree test for cElementTree
-from test import test_support
-from test.test_support import precisionbigmemtest, _2G
+from test import support
+from test.support import bigmemtest, _2G
import unittest
-cET = test_support.import_module('xml.etree.cElementTree')
+cET = support.import_module('xml.etree.cElementTree')
# cElementTree specific tests
def sanity():
- """
+ r"""
Import sanity.
>>> from xml.etree import cElementTree
+
+ Issue #6697.
+
+ >>> e = cElementTree.Element('a')
+ >>> getattr(e, '\uD800') # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ UnicodeEncodeError: ...
+
+ >>> p = cElementTree.XMLParser()
+ >>> p.version.split()[0]
+ 'Expat'
+ >>> getattr(p, '\uD800')
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'XMLParser' object has no attribute '\ud800'
"""
class MiscTests(unittest.TestCase):
# Issue #8651.
- @precisionbigmemtest(size=_2G + 100, memuse=1)
+ @support.bigmemtest(size=support._2G + 100, memuse=1)
def test_length_overflow(self, size):
- if size < _2G + 100:
+ if size < support._2G + 100:
self.skipTest("not enough free memory, need at least 2 GB")
data = b'x' * size
parser = cET.XMLParser()
@@ -35,7 +51,9 @@ def test_main():
from test import test_xml_etree, test_xml_etree_c
# Run the tests specific to the C implementation
- test_support.run_doctest(test_xml_etree_c, verbosity=True)
+ support.run_doctest(test_xml_etree_c, verbosity=True)
+
+ support.run_unittest(MiscTests)
# Assign the C implementation before running the doctests
# Patch the __name__, to prevent confusion with the pure Python test
diff --git a/Lib/test/test_xmllib.py b/Lib/test/test_xmllib.py
deleted file mode 100644
index 966978a92dd..00000000000
--- a/Lib/test/test_xmllib.py
+++ /dev/null
@@ -1,48 +0,0 @@
-'''Test module to thest the xmllib module.
- Sjoerd Mullender
-'''
-
-testdoc = """\
-<?xml version="1.0" encoding="UTF-8" standalone='yes' ?>
-<!-- comments aren't allowed before the <?xml?> tag,
- but they are allowed before the <!DOCTYPE> tag -->
-<?processing instructions are allowed in the same places as comments ?>
-<!DOCTYPE greeting [
- <!ELEMENT greeting (#PCDATA)>
-]>
-<greeting>Hello, world!</greeting>
-"""
-
-nsdoc = "<foo xmlns='URI' attr='val'/>"
-
-from test import test_support
-import unittest
-# Silence Py3k warning
-xmllib = test_support.import_module('xmllib', deprecated=True)
-
-class XMLParserTestCase(unittest.TestCase):
-
- def test_simple(self):
- parser = xmllib.XMLParser()
- for c in testdoc:
- parser.feed(c)
- parser.close()
-
- def test_default_namespace(self):
- class H(xmllib.XMLParser):
- def unknown_starttag(self, name, attr):
- self.name, self.attr = name, attr
- h=H()
- h.feed(nsdoc)
- h.close()
- # The default namespace applies to elements...
- self.assertEqual(h.name, "URI foo")
- # but not to attributes
- self.assertEqual(h.attr, {'attr':'val'})
-
-
-def test_main():
- test_support.run_unittest(XMLParserTestCase)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py
index 8e65fde6331..38141912a12 100644
--- a/Lib/test/test_xmlrpc.py
+++ b/Lib/test/test_xmlrpc.py
@@ -3,56 +3,50 @@ import datetime
import sys
import time
import unittest
-import xmlrpclib
-import SimpleXMLRPCServer
-import mimetools
-import httplib
+import xmlrpc.client as xmlrpclib
+import xmlrpc.server
+import http.client
import socket
-import StringIO
import os
import re
-from test import test_support
+import io
+import contextlib
+from test import support
try:
import threading
except ImportError:
threading = None
-try:
- unicode
-except NameError:
- have_unicode = False
-else:
- have_unicode = True
-
alist = [{'astring': 'foo@bar.baz.spam',
'afloat': 7283.43,
'anint': 2**20,
- 'ashortlong': 2L,
+ 'ashortlong': 2,
'anotherlist': ['.zyx.41'],
- 'abase64': xmlrpclib.Binary("my dog has fleas"),
- 'boolean': xmlrpclib.False,
- 'unicode': u'\u4000\u6000\u8000',
- u'ukey\u4000': 'regular value',
+ 'abase64': xmlrpclib.Binary(b"my dog has fleas"),
+ 'boolean': False,
+ 'unicode': '\u4000\u6000\u8000',
+ 'ukey\u4000': 'regular value',
'datetime1': xmlrpclib.DateTime('20050210T11:41:23'),
'datetime2': xmlrpclib.DateTime(
- (2005, 02, 10, 11, 41, 23, 0, 1, -1)),
+ (2005, 2, 10, 11, 41, 23, 0, 1, -1)),
'datetime3': xmlrpclib.DateTime(
- datetime.datetime(2005, 02, 10, 11, 41, 23)),
+ datetime.datetime(2005, 2, 10, 11, 41, 23)),
}]
class XMLRPCTestCase(unittest.TestCase):
def test_dump_load(self):
- self.assertEqual(alist,
- xmlrpclib.loads(xmlrpclib.dumps((alist,)))[0][0])
+ dump = xmlrpclib.dumps((alist,))
+ load = xmlrpclib.loads(dump)
+ self.assertEqual(alist, load[0][0])
def test_dump_bare_datetime(self):
# This checks that an unwrapped datetime.date object can be handled
# by the marshalling code. This can't be done via test_dump_load()
# since with use_datetime set to 1 the unmarshaller would create
# datetime objects for the 'datetime[123]' keys as well
- dt = datetime.datetime(2005, 02, 10, 11, 41, 23)
+ dt = datetime.datetime(2005, 2, 10, 11, 41, 23)
s = xmlrpclib.dumps((dt,))
(newdt,), m = xmlrpclib.loads(s, use_datetime=1)
self.assertEqual(newdt, dt)
@@ -63,7 +57,7 @@ class XMLRPCTestCase(unittest.TestCase):
def test_datetime_before_1900(self):
# same as before but with a date before 1900
- dt = datetime.datetime(1, 02, 10, 11, 41, 23)
+ dt = datetime.datetime(1, 2, 10, 11, 41, 23)
s = xmlrpclib.dumps((dt,))
(newdt,), m = xmlrpclib.loads(s, use_datetime=1)
self.assertEqual(newdt, dt)
@@ -72,15 +66,6 @@ class XMLRPCTestCase(unittest.TestCase):
(newdt,), m = xmlrpclib.loads(s, use_datetime=0)
self.assertEqual(newdt, xmlrpclib.DateTime('00010210T11:41:23'))
- def test_cmp_datetime_DateTime(self):
- now = datetime.datetime.now()
- dt = xmlrpclib.DateTime(now.timetuple())
- self.assertTrue(dt == now)
- self.assertTrue(now == dt)
- then = now + datetime.timedelta(seconds=4)
- self.assertTrue(then >= dt)
- self.assertTrue(dt < then)
-
def test_bug_1164912 (self):
d = xmlrpclib.DateTime()
((new_d,), dummy) = xmlrpclib.loads(xmlrpclib.dumps((d,),
@@ -101,7 +86,7 @@ class XMLRPCTestCase(unittest.TestCase):
self.assertEqual(t2, t.__dict__)
def test_dump_big_long(self):
- self.assertRaises(OverflowError, xmlrpclib.dumps, (2L**99,))
+ self.assertRaises(OverflowError, xmlrpclib.dumps, (2**99,))
def test_dump_bad_dict(self):
self.assertRaises(TypeError, xmlrpclib.dumps, ({(1,2,3): 1},))
@@ -119,13 +104,15 @@ class XMLRPCTestCase(unittest.TestCase):
self.assertRaises(TypeError, xmlrpclib.dumps, (d,))
def test_dump_big_int(self):
- if sys.maxint > 2L**31-1:
+ if sys.maxsize > 2**31-1:
self.assertRaises(OverflowError, xmlrpclib.dumps,
- (int(2L**34),))
+ (int(2**34),))
xmlrpclib.dumps((xmlrpclib.MAXINT, xmlrpclib.MININT))
- self.assertRaises(OverflowError, xmlrpclib.dumps, (xmlrpclib.MAXINT+1,))
- self.assertRaises(OverflowError, xmlrpclib.dumps, (xmlrpclib.MININT-1,))
+ self.assertRaises(OverflowError, xmlrpclib.dumps,
+ (xmlrpclib.MAXINT+1,))
+ self.assertRaises(OverflowError, xmlrpclib.dumps,
+ (xmlrpclib.MININT-1,))
def dummy_write(s):
pass
@@ -133,60 +120,42 @@ class XMLRPCTestCase(unittest.TestCase):
m = xmlrpclib.Marshaller()
m.dump_int(xmlrpclib.MAXINT, dummy_write)
m.dump_int(xmlrpclib.MININT, dummy_write)
- self.assertRaises(OverflowError, m.dump_int, xmlrpclib.MAXINT+1, dummy_write)
- self.assertRaises(OverflowError, m.dump_int, xmlrpclib.MININT-1, dummy_write)
-
+ self.assertRaises(OverflowError, m.dump_int,
+ xmlrpclib.MAXINT+1, dummy_write)
+ self.assertRaises(OverflowError, m.dump_int,
+ xmlrpclib.MININT-1, dummy_write)
def test_dump_none(self):
value = alist + [None]
arg1 = (alist + [None],)
strg = xmlrpclib.dumps(arg1, allow_none=True)
self.assertEqual(value,
- xmlrpclib.loads(strg)[0][0])
+ xmlrpclib.loads(strg)[0][0])
self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
- def test_default_encoding_issues(self):
- # SF bug #1115989: wrong decoding in '_stringify'
- utf8 = """<?xml version='1.0' encoding='iso-8859-1'?>
- <params>
- <param><value>
- <string>abc \x95</string>
- </value></param>
- <param><value>
- <struct>
- <member>
- <name>def \x96</name>
- <value><string>ghi \x97</string></value>
- </member>
- </struct>
- </value></param>
- </params>
- """
-
- # sys.setdefaultencoding() normally doesn't exist after site.py is
- # loaded. Import a temporary fresh copy to get access to it
- # but then restore the original copy to avoid messing with
- # other potentially modified sys module attributes
- old_encoding = sys.getdefaultencoding()
- with test_support.CleanImport('sys'):
- import sys as temp_sys
- temp_sys.setdefaultencoding("iso-8859-1")
- try:
- (s, d), m = xmlrpclib.loads(utf8)
- finally:
- temp_sys.setdefaultencoding(old_encoding)
-
- items = d.items()
- if have_unicode:
- self.assertEqual(s, u"abc \x95")
- self.assertIsInstance(s, unicode)
- self.assertEqual(items, [(u"def \x96", u"ghi \x97")])
- self.assertIsInstance(items[0][0], unicode)
- self.assertIsInstance(items[0][1], unicode)
- else:
- self.assertEqual(s, "abc \xc2\x95")
- self.assertEqual(items, [("def \xc2\x96", "ghi \xc2\x97")])
+ def test_get_host_info(self):
+ # see bug #3613, this raised a TypeError
+ transp = xmlrpc.client.Transport()
+ self.assertEqual(transp.get_host_info("user@host.tld"),
+ ('host.tld',
+ [('Authorization', 'Basic dXNlcg==')], {}))
+ def test_dump_bytes(self):
+ self.assertRaises(TypeError, xmlrpclib.dumps, (b"my dog has fleas",))
+
+ def test_ssl_presence(self):
+ try:
+ import ssl
+ except ImportError:
+ has_ssl = False
+ else:
+ has_ssl = True
+ try:
+ xmlrpc.client.ServerProxy('https://localhost:9999').bad_function()
+ except NotImplementedError:
+ self.assertFalse(has_ssl, "xmlrpc client's error with SSL support")
+ except socket.error:
+ self.assertTrue(has_ssl)
class HelperTestCase(unittest.TestCase):
def test_escape(self):
@@ -210,6 +179,12 @@ class FaultTestCase(unittest.TestCase):
s = xmlrpclib.Marshaller().dumps(f)
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, s)
+ def test_dotted_attribute(self):
+ # this will raise AttributeError because code don't want us to use
+ # private methods
+ self.assertRaises(AttributeError,
+ xmlrpc.server.resolve_dotted_attribute, str, '__add')
+ self.assertTrue(xmlrpc.server.resolve_dotted_attribute(str, 'title'))
class DateTimeTestCase(unittest.TestCase):
def test_default(self):
@@ -218,7 +193,8 @@ class DateTimeTestCase(unittest.TestCase):
def test_time(self):
d = 1181399930.036952
t = xmlrpclib.DateTime(d)
- self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d)))
+ self.assertEqual(str(t),
+ time.strftime("%Y%m%dT%H:%M:%S", time.localtime(d)))
def test_time_tuple(self):
d = (2007,6,9,10,38,50,5,160,0)
@@ -228,7 +204,7 @@ class DateTimeTestCase(unittest.TestCase):
def test_time_struct(self):
d = time.localtime(1181399930.036952)
t = xmlrpclib.DateTime(d)
- self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
+ self.assertEqual(str(t), time.strftime("%Y%m%dT%H:%M:%S", d))
def test_datetime_datetime(self):
d = datetime.datetime(2007,1,2,3,4,5)
@@ -251,25 +227,70 @@ class DateTimeTestCase(unittest.TestCase):
t2 = xmlrpclib._datetime(d)
self.assertEqual(t1, tref)
+ def test_comparison(self):
+ now = datetime.datetime.now()
+ dtime = xmlrpclib.DateTime(now.timetuple())
+
+ # datetime vs. DateTime
+ self.assertTrue(dtime == now)
+ self.assertTrue(now == dtime)
+ then = now + datetime.timedelta(seconds=4)
+ self.assertTrue(then >= dtime)
+ self.assertTrue(dtime < then)
+
+ # str vs. DateTime
+ dstr = now.strftime("%Y%m%dT%H:%M:%S")
+ self.assertTrue(dtime == dstr)
+ self.assertTrue(dstr == dtime)
+ dtime_then = xmlrpclib.DateTime(then.timetuple())
+ self.assertTrue(dtime_then >= dstr)
+ self.assertTrue(dstr < dtime_then)
+
+ # some other types
+ dbytes = dstr.encode('ascii')
+ dtuple = now.timetuple()
+ with self.assertRaises(TypeError):
+ dtime == 1970
+ with self.assertRaises(TypeError):
+ dtime != dbytes
+ with self.assertRaises(TypeError):
+ dtime == bytearray(dbytes)
+ with self.assertRaises(TypeError):
+ dtime != dtuple
+ with self.assertRaises(TypeError):
+ dtime < float(1970)
+ with self.assertRaises(TypeError):
+ dtime > dbytes
+ with self.assertRaises(TypeError):
+ dtime <= bytearray(dbytes)
+ with self.assertRaises(TypeError):
+ dtime >= dtuple
+
class BinaryTestCase(unittest.TestCase):
+
+ # XXX What should str(Binary(b"\xff")) return? I'm chosing "\xff"
+ # for now (i.e. interpreting the binary data as Latin-1-encoded
+ # text). But this feels very unsatisfactory. Perhaps we should
+ # only define repr(), and return r"Binary(b'\xff')" instead?
+
def test_default(self):
t = xmlrpclib.Binary()
self.assertEqual(str(t), '')
def test_string(self):
- d = '\x01\x02\x03abc123\xff\xfe'
+ d = b'\x01\x02\x03abc123\xff\xfe'
t = xmlrpclib.Binary(d)
- self.assertEqual(str(t), d)
+ self.assertEqual(str(t), str(d, "latin-1"))
def test_decode(self):
- d = '\x01\x02\x03abc123\xff\xfe'
- de = base64.encodestring(d)
+ d = b'\x01\x02\x03abc123\xff\xfe'
+ de = base64.encodebytes(d)
t1 = xmlrpclib.Binary()
t1.decode(de)
- self.assertEqual(str(t1), d)
+ self.assertEqual(str(t1), str(d, "latin-1"))
t2 = xmlrpclib._binary(de)
- self.assertEqual(str(t2), d)
+ self.assertEqual(str(t2), str(d, "latin-1"))
ADDR = PORT = URL = None
@@ -290,7 +311,7 @@ def http_server(evt, numrequests, requestHandler=None):
'''This is my function'''
return True
- class MyXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer):
+ class MyXMLRPCServer(xmlrpc.server.SimpleXMLRPCServer):
def get_request(self):
# Ensure the socket is always non-blocking. On Linux, socket
# attributes are not inherited like they are on *BSD and Windows.
@@ -299,11 +320,10 @@ def http_server(evt, numrequests, requestHandler=None):
return s, port
if not requestHandler:
- requestHandler = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
+ requestHandler = xmlrpc.server.SimpleXMLRPCRequestHandler
serv = MyXMLRPCServer(("localhost", 0), requestHandler,
logRequests=False, bind_and_activate=False)
try:
- serv.socket.settimeout(3)
serv.server_bind()
global ADDR, PORT, URL
ADDR, PORT = serv.socket.getsockname()
@@ -346,7 +366,7 @@ def http_multi_server(evt, numrequests, requestHandler=None):
'''This is my function'''
return True
- class MyXMLRPCServer(SimpleXMLRPCServer.MultiPathXMLRPCServer):
+ class MyXMLRPCServer(xmlrpc.server.MultiPathXMLRPCServer):
def get_request(self):
# Ensure the socket is always non-blocking. On Linux, socket
# attributes are not inherited like they are on *BSD and Windows.
@@ -355,10 +375,14 @@ def http_multi_server(evt, numrequests, requestHandler=None):
return s, port
if not requestHandler:
- requestHandler = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
+ requestHandler = xmlrpc.server.SimpleXMLRPCRequestHandler
class MyRequestHandler(requestHandler):
rpc_paths = []
+ class BrokenDispatcher:
+ def _marshaled_dispatch(self, data, dispatch_method=None, path=None):
+ raise RuntimeError("broken dispatcher")
+
serv = MyXMLRPCServer(("localhost", 0), MyRequestHandler,
logRequests=False, bind_and_activate=False)
serv.socket.settimeout(3)
@@ -374,11 +398,12 @@ def http_multi_server(evt, numrequests, requestHandler=None):
serv.server_activate()
paths = ["/foo", "/foo/bar"]
for path in paths:
- d = serv.add_dispatcher(path, SimpleXMLRPCServer.SimpleXMLRPCDispatcher())
+ d = serv.add_dispatcher(path, xmlrpc.server.SimpleXMLRPCDispatcher())
d.register_introspection_functions()
d.register_multicall_functions()
serv.get_dispatcher(paths[0]).register_function(pow)
serv.get_dispatcher(paths[1]).register_function(lambda x,y: x+y, 'add')
+ serv.add_dispatcher("/is/broken", BrokenDispatcher())
evt.set()
# handle up to 'numrequests' requests
@@ -412,7 +437,21 @@ def is_unavailable_exception(e):
if exc_mess and 'temporarily unavailable' in exc_mess.lower():
return True
- return False
+def make_request_and_skipIf(condition, reason):
+ # If we skip the test, we have to make a request because the
+ # the server created in setUp blocks expecting one to come in.
+ if not condition:
+ return lambda func: func
+ def decorator(func):
+ def make_request_and_skip(self):
+ try:
+ xmlrpclib.ServerProxy(URL).my_function()
+ except (xmlrpclib.ProtocolError, socket.error) as e:
+ if not is_unavailable_exception(e):
+ raise
+ raise unittest.SkipTest(reason)
+ return make_request_and_skip
+ return decorator
@unittest.skipUnless(threading, 'Threading required for this test.')
class BaseServerTestCase(unittest.TestCase):
@@ -422,7 +461,7 @@ class BaseServerTestCase(unittest.TestCase):
def setUp(self):
# enable traceback reporting
- SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
+ xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
self.evt = threading.Event()
# start server thread to handle requests
@@ -430,29 +469,22 @@ class BaseServerTestCase(unittest.TestCase):
threading.Thread(target=self.threadFunc, args=serv_args).start()
# wait for the server to be ready
- self.evt.wait(10)
+ self.evt.wait()
self.evt.clear()
def tearDown(self):
# wait on the server thread to terminate
- self.evt.wait(10)
+ self.evt.wait()
# disable traceback reporting
- SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
-
-# NOTE: The tests in SimpleServerTestCase will ignore failures caused by
-# "temporarily unavailable" exceptions raised in SimpleXMLRPCServer. This
-# condition occurs infrequently on some platforms, frequently on others, and
-# is apparently caused by using SimpleXMLRPCServer with a non-blocking socket
-# If the server class is updated at some point in the future to handle this
-# situation more gracefully, these tests should be modified appropriately.
+ xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = False
class SimpleServerTestCase(BaseServerTestCase):
def test_simple1(self):
try:
p = xmlrpclib.ServerProxy(URL)
self.assertEqual(p.pow(6,8), 6**8)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -461,26 +493,21 @@ class SimpleServerTestCase(BaseServerTestCase):
def test_nonascii(self):
start_string = 'P\N{LATIN SMALL LETTER Y WITH CIRCUMFLEX}t'
end_string = 'h\N{LATIN SMALL LETTER O WITH HORN}n'
-
try:
p = xmlrpclib.ServerProxy(URL)
self.assertEqual(p.add(start_string, end_string),
start_string + end_string)
except (xmlrpclib.ProtocolError, socket.error) as e:
- # ignore failures due to non-blocking socket unavailable errors.
+ # ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
- def test_unicode_host(self):
- server = xmlrpclib.ServerProxy(u"http://%s:%d/RPC2"%(ADDR, PORT))
- self.assertEqual(server.add("a", u"\xe9"), u"a\xe9")
-
# [ch] The test 404 is causing lots of false alarms.
def XXXtest_404(self):
- # send POST with httplib, it should return 404 header and
+ # send POST with http.client, it should return 404 header and
# 'Not Found' message.
- conn = httplib.HTTPConnection(ADDR, PORT)
+ conn = httplib.client.HTTPConnection(ADDR, PORT)
conn.request('POST', '/this-is-not-valid')
response = conn.getresponse()
conn.close()
@@ -489,32 +516,33 @@ class SimpleServerTestCase(BaseServerTestCase):
self.assertEqual(response.reason, 'Not Found')
def test_introspection1(self):
+ expected_methods = set(['pow', 'div', 'my_function', 'add',
+ 'system.listMethods', 'system.methodHelp',
+ 'system.methodSignature', 'system.multicall'])
try:
p = xmlrpclib.ServerProxy(URL)
meth = p.system.listMethods()
- expected_methods = set(['pow', 'div', 'my_function', 'add',
- 'system.listMethods', 'system.methodHelp',
- 'system.methodSignature', 'system.multicall'])
self.assertEqual(set(meth), expected_methods)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
+
def test_introspection2(self):
try:
# test _methodHelp()
p = xmlrpclib.ServerProxy(URL)
divhelp = p.system.methodHelp('div')
self.assertEqual(divhelp, 'This is the div function')
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
self.fail("%s\n%s" % (e, getattr(e, "headers", "")))
- @unittest.skipIf(sys.flags.optimize >= 2,
+ @make_request_and_skipIf(sys.flags.optimize >= 2,
"Docstrings are omitted with -O2 and above")
def test_introspection3(self):
try:
@@ -522,7 +550,7 @@ class SimpleServerTestCase(BaseServerTestCase):
p = xmlrpclib.ServerProxy(URL)
myfunction = p.system.methodHelp('my_function')
self.assertEqual(myfunction, 'This is my function')
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -535,7 +563,7 @@ class SimpleServerTestCase(BaseServerTestCase):
p = xmlrpclib.ServerProxy(URL)
divsig = p.system.methodSignature('div')
self.assertEqual(divsig, 'signatures not supported')
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -552,7 +580,7 @@ class SimpleServerTestCase(BaseServerTestCase):
self.assertEqual(add_result, 2+3)
self.assertEqual(pow_result, 6**8)
self.assertEqual(div_result, 127//42)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -566,14 +594,14 @@ class SimpleServerTestCase(BaseServerTestCase):
result = multicall()
# result.results contains;
- # [{'faultCode': 1, 'faultString': '<type \'exceptions.Exception\'>:'
+ # [{'faultCode': 1, 'faultString': '<class \'exceptions.Exception\'>:'
# 'method "this_is_not_exists" is not supported'>}]
self.assertEqual(result.results[0]['faultCode'], 1)
self.assertEqual(result.results[0]['faultString'],
- '<type \'exceptions.Exception\'>:method "this_is_not_exists" '
+ '<class \'Exception\'>:method "this_is_not_exists" '
'is not supported')
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -582,19 +610,24 @@ class SimpleServerTestCase(BaseServerTestCase):
def test_dotted_attribute(self):
# Raises an AttributeError because private methods are not allowed.
self.assertRaises(AttributeError,
- SimpleXMLRPCServer.resolve_dotted_attribute, str, '__add')
+ xmlrpc.server.resolve_dotted_attribute, str, '__add')
- self.assertTrue(SimpleXMLRPCServer.resolve_dotted_attribute(str, 'title'))
+ self.assertTrue(xmlrpc.server.resolve_dotted_attribute(str, 'title'))
# Get the test to run faster by sending a request with test_simple1.
# This avoids waiting for the socket timeout.
self.test_simple1()
+ def test_unicode_host(self):
+ server = xmlrpclib.ServerProxy("http://%s:%d/RPC2" % (ADDR, PORT))
+ self.assertEqual(server.add("a", "\xe9"), "a\xe9")
+
def test_partial_post(self):
# Check that a partial POST doesn't make the server loop: issue #14001.
- conn = httplib.HTTPConnection(ADDR, PORT)
+ conn = http.client.HTTPConnection(ADDR, PORT)
conn.request('POST', '/RPC2 HTTP/1.0\r\nContent-Length: 100\r\n\r\nbye')
conn.close()
+
class MultiPathServerTestCase(BaseServerTestCase):
threadFunc = staticmethod(http_multi_server)
request_count = 2
@@ -602,18 +635,23 @@ class MultiPathServerTestCase(BaseServerTestCase):
p = xmlrpclib.ServerProxy(URL+"/foo")
self.assertEqual(p.pow(6,8), 6**8)
self.assertRaises(xmlrpclib.Fault, p.add, 6, 8)
+
def test_path2(self):
p = xmlrpclib.ServerProxy(URL+"/foo/bar")
self.assertEqual(p.add(6,8), 6+8)
self.assertRaises(xmlrpclib.Fault, p.pow, 6, 8)
+ def test_path3(self):
+ p = xmlrpclib.ServerProxy(URL+"/is/broken")
+ self.assertRaises(xmlrpclib.Fault, p.add, 6, 8)
+
#A test case that verifies that a server using the HTTP/1.1 keep-alive mechanism
#does indeed serve subsequent requests on the same connection
class BaseKeepaliveServerTestCase(BaseServerTestCase):
#a request handler that supports keep-alive and logs requests into a
#class variable
- class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
- parentClass = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
+ class RequestHandler(xmlrpc.server.SimpleXMLRPCRequestHandler):
+ parentClass = xmlrpc.server.SimpleXMLRPCRequestHandler
protocol_version = 'HTTP/1.1'
myRequests = []
def handle(self):
@@ -640,6 +678,7 @@ class KeepaliveServerTestCase1(BaseKeepaliveServerTestCase):
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
#they should have all been handled by a single request handler
self.assertEqual(len(self.RequestHandler.myRequests), 1)
@@ -648,6 +687,7 @@ class KeepaliveServerTestCase1(BaseKeepaliveServerTestCase):
#due to thread scheduling)
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
+
#test special attribute access on the serverproxy, through the __call__
#function.
class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
@@ -664,6 +704,7 @@ class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
#they should have all been two request handlers, each having logged at least
#two complete requests
@@ -671,12 +712,14 @@ class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-1]), 2)
self.assertGreaterEqual(len(self.RequestHandler.myRequests[-2]), 2)
+
def test_transport(self):
p = xmlrpclib.ServerProxy(URL)
#do some requests with close.
self.assertEqual(p.pow(6,8), 6**8)
p("transport").close() #same as above, really.
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
self.assertEqual(len(self.RequestHandler.myRequests), 2)
#A test case that verifies that gzip encoding works in both directions
@@ -684,8 +727,8 @@ class KeepaliveServerTestCase2(BaseKeepaliveServerTestCase):
class GzipServerTestCase(BaseServerTestCase):
#a request handler that supports keep-alive and logs requests into a
#class variable
- class RequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
- parentClass = SimpleXMLRPCServer.SimpleXMLRPCRequestHandler
+ class RequestHandler(xmlrpc.server.SimpleXMLRPCRequestHandler):
+ parentClass = xmlrpc.server.SimpleXMLRPCRequestHandler
protocol_version = 'HTTP/1.1'
def do_POST(self):
@@ -720,16 +763,18 @@ class GzipServerTestCase(BaseServerTestCase):
self.assertEqual(p.pow(6,8), 6**8)
b = self.RequestHandler.content_length
self.assertTrue(a>b)
+ p("close")()
def test_bad_gzip_request(self):
t = self.Transport()
t.encode_threshold = None
t.fake_gzip = True
p = xmlrpclib.ServerProxy(URL, transport=t)
- cm = self.assertRaisesRegexp(xmlrpclib.ProtocolError,
- re.compile(r"\b400\b"))
+ cm = self.assertRaisesRegex(xmlrpclib.ProtocolError,
+ re.compile(r"\b400\b"))
with cm:
p.pow(6, 8)
+ p("close")()
def test_gsip_response(self):
t = self.Transport()
@@ -740,6 +785,7 @@ class GzipServerTestCase(BaseServerTestCase):
a = t.response_length
self.requestHandler.encode_threshold = 0 #always encode
self.assertEqual(p.pow(6,8), 6**8)
+ p("close")()
b = t.response_length
self.requestHandler.encode_threshold = old
self.assertTrue(a>b)
@@ -767,12 +813,12 @@ class ServerProxyTestCase(unittest.TestCase):
# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server
-class FailingMessageClass(mimetools.Message):
- def __getitem__(self, key):
+class FailingMessageClass(http.client.HTTPMessage):
+ def get(self, key, failobj=None):
key = key.lower()
if key == 'content-length':
return 'I am broken'
- return mimetools.Message.__getitem__(self, key)
+ return super().get(key, failobj)
@unittest.skipUnless(threading, 'Threading required for this test.')
@@ -791,23 +837,24 @@ class FailingServerTestCase(unittest.TestCase):
# wait on the server thread to terminate
self.evt.wait()
# reset flag
- SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = False
+ xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = False
# reset message class
- SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = mimetools.Message
+ default_class = http.client.HTTPMessage
+ xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = default_class
def test_basic(self):
# check that flag is false by default
- flagval = SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header
+ flagval = xmlrpc.server.SimpleXMLRPCServer._send_traceback_header
self.assertEqual(flagval, False)
# enable traceback reporting
- SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
+ xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
# test a call that shouldn't fail just as a smoke test
try:
p = xmlrpclib.ServerProxy(URL)
self.assertEqual(p.pow(6,8), 6**8)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e):
# protocol error; provide additional information in test output
@@ -815,12 +862,12 @@ class FailingServerTestCase(unittest.TestCase):
def test_fail_no_info(self):
# use the broken message class
- SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
+ xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
try:
p = xmlrpclib.ServerProxy(URL)
p.pow(6,8)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e) and hasattr(e, "headers"):
# The two server-side error headers shouldn't be sent back in this case
@@ -831,38 +878,53 @@ class FailingServerTestCase(unittest.TestCase):
def test_fail_with_info(self):
# use the broken message class
- SimpleXMLRPCServer.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
+ xmlrpc.server.SimpleXMLRPCRequestHandler.MessageClass = FailingMessageClass
# Check that errors in the server send back exception/traceback
# info when flag is set
- SimpleXMLRPCServer.SimpleXMLRPCServer._send_traceback_header = True
+ xmlrpc.server.SimpleXMLRPCServer._send_traceback_header = True
try:
p = xmlrpclib.ServerProxy(URL)
p.pow(6,8)
- except (xmlrpclib.ProtocolError, socket.error), e:
+ except (xmlrpclib.ProtocolError, socket.error) as e:
# ignore failures due to non-blocking socket 'unavailable' errors
if not is_unavailable_exception(e) and hasattr(e, "headers"):
# We should get error info in the response
expected_err = "invalid literal for int() with base 10: 'I am broken'"
- self.assertEqual(e.headers.get("x-exception"), expected_err)
- self.assertTrue(e.headers.get("x-traceback") is not None)
+ self.assertEqual(e.headers.get("X-exception"), expected_err)
+ self.assertTrue(e.headers.get("X-traceback") is not None)
else:
self.fail('ProtocolError not raised')
+
+@contextlib.contextmanager
+def captured_stdout(encoding='utf-8'):
+ """A variation on support.captured_stdout() which gives a text stream
+ having a `buffer` attribute.
+ """
+ import io
+ orig_stdout = sys.stdout
+ sys.stdout = io.TextIOWrapper(io.BytesIO(), encoding=encoding)
+ try:
+ yield sys.stdout
+ finally:
+ sys.stdout = orig_stdout
+
+
class CGIHandlerTestCase(unittest.TestCase):
def setUp(self):
- self.cgi = SimpleXMLRPCServer.CGIXMLRPCRequestHandler()
+ self.cgi = xmlrpc.server.CGIXMLRPCRequestHandler()
def tearDown(self):
self.cgi = None
def test_cgi_get(self):
- with test_support.EnvironmentVarGuard() as env:
+ with support.EnvironmentVarGuard() as env:
env['REQUEST_METHOD'] = 'GET'
# if the method is GET and no request_text is given, it runs handle_get
# get sysout output
- with test_support.captured_stdout() as data_out:
+ with captured_stdout(encoding=self.cgi.encoding) as data_out:
self.cgi.handle_request()
# parse Status header
@@ -890,9 +952,9 @@ class CGIHandlerTestCase(unittest.TestCase):
</methodCall>
"""
- with test_support.EnvironmentVarGuard() as env, \
- test_support.captured_stdout() as data_out, \
- test_support.captured_stdin() as data_in:
+ with support.EnvironmentVarGuard() as env, \
+ captured_stdout(encoding=self.cgi.encoding) as data_out, \
+ support.captured_stdin() as data_in:
data_in.write(data)
data_in.seek(0)
env['CONTENT_LENGTH'] = str(len(data))
@@ -902,7 +964,8 @@ class CGIHandlerTestCase(unittest.TestCase):
# will respond exception, if so, our goal is achieved ;)
handle = data_out.read()
- # start with 44th char so as not to get http header, we just need only xml
+ # start with 44th char so as not to get http header, we just
+ # need only xml
self.assertRaises(xmlrpclib.Fault, xmlrpclib.loads, handle[44:])
# Also test the content-length returned by handle_request
@@ -917,97 +980,10 @@ class CGIHandlerTestCase(unittest.TestCase):
len(content))
-class FakeSocket:
-
- def __init__(self):
- self.data = StringIO.StringIO()
-
- def send(self, buf):
- self.data.write(buf)
- return len(buf)
-
- def sendall(self, buf):
- self.data.write(buf)
-
- def getvalue(self):
- return self.data.getvalue()
-
- def makefile(self, x='r', y=-1):
- raise RuntimeError
-
- def close(self):
- pass
-
-class FakeTransport(xmlrpclib.Transport):
- """A Transport instance that records instead of sending a request.
-
- This class replaces the actual socket used by httplib with a
- FakeSocket object that records the request. It doesn't provide a
- response.
- """
-
- def make_connection(self, host):
- conn = xmlrpclib.Transport.make_connection(self, host)
- conn.sock = self.fake_socket = FakeSocket()
- return conn
-
-class TransportSubclassTestCase(unittest.TestCase):
-
- def issue_request(self, transport_class):
- """Return an HTTP request made via transport_class."""
- transport = transport_class()
- proxy = xmlrpclib.ServerProxy("http://example.com/",
- transport=transport)
- try:
- proxy.pow(6, 8)
- except RuntimeError:
- return transport.fake_socket.getvalue()
- return None
-
- def test_custom_user_agent(self):
- class TestTransport(FakeTransport):
-
- def send_user_agent(self, conn):
- xmlrpclib.Transport.send_user_agent(self, conn)
- conn.putheader("X-Test", "test_custom_user_agent")
-
- req = self.issue_request(TestTransport)
- self.assertIn("X-Test: test_custom_user_agent\r\n", req)
-
- def test_send_host(self):
- class TestTransport(FakeTransport):
-
- def send_host(self, conn, host):
- xmlrpclib.Transport.send_host(self, conn, host)
- conn.putheader("X-Test", "test_send_host")
-
- req = self.issue_request(TestTransport)
- self.assertIn("X-Test: test_send_host\r\n", req)
-
- def test_send_request(self):
- class TestTransport(FakeTransport):
-
- def send_request(self, conn, url, body):
- xmlrpclib.Transport.send_request(self, conn, url, body)
- conn.putheader("X-Test", "test_send_request")
-
- req = self.issue_request(TestTransport)
- self.assertIn("X-Test: test_send_request\r\n", req)
-
- def test_send_content(self):
- class TestTransport(FakeTransport):
-
- def send_content(self, conn, body):
- conn.putheader("X-Test", "test_send_content")
- xmlrpclib.Transport.send_content(self, conn, body)
-
- req = self.issue_request(TestTransport)
- self.assertIn("X-Test: test_send_content\r\n", req)
-
-@test_support.reap_threads
+@support.reap_threads
def test_main():
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
- BinaryTestCase, FaultTestCase, TransportSubclassTestCase]
+ BinaryTestCase, FaultTestCase]
xmlrpc_tests.append(SimpleServerTestCase)
xmlrpc_tests.append(KeepaliveServerTestCase1)
xmlrpc_tests.append(KeepaliveServerTestCase2)
@@ -1021,7 +997,7 @@ def test_main():
xmlrpc_tests.append(FailingServerTestCase)
xmlrpc_tests.append(CGIHandlerTestCase)
- test_support.run_unittest(*xmlrpc_tests)
+ support.run_unittest(*xmlrpc_tests)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_xmlrpc_net.py b/Lib/test/test_xmlrpc_net.py
new file mode 100644
index 00000000000..d72f8ac895c
--- /dev/null
+++ b/Lib/test/test_xmlrpc_net.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python3
+
+import collections
+import errno
+import socket
+import sys
+import unittest
+from test import support
+
+import xmlrpc.client as xmlrpclib
+
+class CurrentTimeTest(unittest.TestCase):
+
+ def test_current_time(self):
+ # Get the current time from xmlrpc.com. This code exercises
+ # the minimal HTTP functionality in xmlrpclib.
+ self.skipTest("time.xmlrpc.com is unreliable")
+ server = xmlrpclib.ServerProxy("http://time.xmlrpc.com/RPC2")
+ try:
+ t0 = server.currentTime.getCurrentTime()
+ except socket.error as e:
+ self.skipTest("network error: %s" % e)
+ return
+
+ # Perform a minimal sanity check on the result, just to be sure
+ # the request means what we think it means.
+ t1 = xmlrpclib.DateTime()
+
+ dt0 = xmlrpclib._datetime_type(t0.value)
+ dt1 = xmlrpclib._datetime_type(t1.value)
+ if dt0 > dt1:
+ delta = dt0 - dt1
+ else:
+ delta = dt1 - dt0
+ # The difference between the system time here and the system
+ # time on the server should not be too big.
+ self.assertTrue(delta.days <= 1)
+
+ def test_python_builders(self):
+ # Get the list of builders from the XMLRPC buildbot interface at
+ # python.org.
+ server = xmlrpclib.ServerProxy("http://buildbot.python.org/all/xmlrpc/")
+ try:
+ builders = server.getAllBuilders()
+ except socket.error as e:
+ self.skipTest("network error: %s" % e)
+ return
+ self.addCleanup(lambda: server('close')())
+
+ # Perform a minimal sanity check on the result, just to be sure
+ # the request means what we think it means.
+ self.assertIsInstance(builders, collections.Sequence)
+ self.assertTrue([x for x in builders if "3.x" in x], builders)
+
+
+def test_main():
+ support.requires("network")
+ support.run_unittest(CurrentTimeTest)
+
+if __name__ == "__main__":
+ test_main()
diff --git a/Lib/test/test_xpickle.py b/Lib/test/test_xpickle.py
deleted file mode 100644
index ac3a33f3217..00000000000
--- a/Lib/test/test_xpickle.py
+++ /dev/null
@@ -1,264 +0,0 @@
-# test_pickle dumps and loads pickles via pickle.py.
-# test_cpickle does the same, but via the cPickle module.
-# This test covers the other two cases, making pickles with one module and
-# loading them via the other. It also tests backwards compatibility with
-# previous version of Python by bouncing pickled objects through Python 2.4
-# and Python 2.5 running this file.
-
-import cPickle
-import os
-import os.path
-import pickle
-import subprocess
-import sys
-import types
-import unittest
-
-from test import test_support
-
-# Most distro-supplied Pythons don't include the tests
-# or test support files, and some don't include a way to get these back even if
-# you're will to install extra packages (like Ubuntu). Doing things like this
-# "provides" a pickletester module for older versions of Python that may be
-# installed without it. Note that one other design for this involves messing
-# with sys.path, which is less precise.
-mod_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
- "pickletester.py"))
-pickletester = types.ModuleType("test.pickletester")
-exec compile(open(mod_path).read(), mod_path, 'exec') in pickletester.__dict__
-AbstractPickleTests = pickletester.AbstractPickleTests
-if pickletester.__name__ in sys.modules:
- raise RuntimeError("Did not expect to find test.pickletester loaded")
-sys.modules[pickletester.__name__] = pickletester
-
-
-class DumpCPickle_LoadPickle(AbstractPickleTests):
-
- error = KeyError
-
- def dumps(self, arg, proto=0, fast=False):
- # Ignore fast
- return cPickle.dumps(arg, proto)
-
- def loads(self, buf):
- # Ignore fast
- return pickle.loads(buf)
-
-class DumpPickle_LoadCPickle(AbstractPickleTests):
-
- error = cPickle.BadPickleGet
-
- def dumps(self, arg, proto=0, fast=False):
- # Ignore fast
- return pickle.dumps(arg, proto)
-
- def loads(self, buf):
- # Ignore fast
- return cPickle.loads(buf)
-
-def have_python_version(name):
- """Check whether the given name is a valid Python binary and has
- test.test_support.
-
- This respects your PATH.
-
- Args:
- name: short string name of a Python binary such as "python2.4".
-
- Returns:
- True if the name is valid, False otherwise.
- """
- return os.system(name + " -c 'import test.test_support'") == 0
-
-
-class AbstractCompatTests(AbstractPickleTests):
-
- module = None
- python = None
- error = None
-
- def setUp(self):
- self.assertTrue(self.python)
- self.assertTrue(self.module)
- self.assertTrue(self.error)
-
- def send_to_worker(self, python, obj, proto):
- """Bounce a pickled object through another version of Python.
-
- This will pickle the object, send it to a child process where it will be
- unpickled, then repickled and sent back to the parent process.
-
- Args:
- python: the name of the Python binary to start.
- obj: object to pickle.
- proto: pickle protocol number to use.
-
- Returns:
- The pickled data received from the child process.
- """
- # Prevent the subprocess from picking up invalid .pyc files.
- target = __file__
- if target[-1] in ("c", "o"):
- target = target[:-1]
-
- data = self.module.dumps((proto, obj), proto)
- worker = subprocess.Popen([python, target, "worker"],
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
- stdout, stderr = worker.communicate(data)
- if worker.returncode != 0:
- raise RuntimeError(stderr)
- return stdout
-
- def dumps(self, arg, proto=0, fast=False):
- return self.send_to_worker(self.python, arg, proto)
-
- def loads(self, input):
- return self.module.loads(input)
-
- # These tests are disabled because they require some special setup
- # on the worker that's hard to keep in sync.
- def test_global_ext1(self):
- pass
-
- def test_global_ext2(self):
- pass
-
- def test_global_ext4(self):
- pass
-
- # This is a cut-down version of pickletester's test_float. Backwards
- # compatibility for the values in for_bin_protos was explicitly broken in
- # r68903 to fix a bug.
- def test_float(self):
- for_bin_protos = [4.94e-324, 1e-310]
- neg_for_bin_protos = [-x for x in for_bin_protos]
- test_values = [0.0, 7e-308, 6.626e-34, 0.1, 0.5,
- 3.14, 263.44582062374053, 6.022e23, 1e30]
- test_proto0_values = test_values + [-x for x in test_values]
- test_values = test_proto0_values + for_bin_protos + neg_for_bin_protos
-
- for value in test_proto0_values:
- pickle = self.dumps(value, 0)
- got = self.loads(pickle)
- self.assertEqual(value, got)
-
- for proto in pickletester.protocols[1:]:
- for value in test_values:
- pickle = self.dumps(value, proto)
- got = self.loads(pickle)
- self.assertEqual(value, got)
-
- # Backwards compatibility was explicitly broken in r67934 to fix a bug.
- def test_unicode_high_plane(self):
- pass
-
- # This tests a fix that's in 2.7 only
- def test_dynamic_class(self):
- pass
-
- if test_support.have_unicode:
- # This is a cut-down version of pickletester's test_unicode. Backwards
- # compatibility was explicitly broken in r67934 to fix a bug.
- def test_unicode(self):
- endcases = [u'', u'<\\u>', u'<\\\u1234>', u'<\n>', u'<\\>']
- for proto in pickletester.protocols:
- for u in endcases:
- p = self.dumps(u, proto)
- u2 = self.loads(p)
- self.assertEqual(u2, u)
-
-
-def run_compat_test(python_name):
- return (test_support.is_resource_enabled("xpickle") and
- have_python_version(python_name))
-
-
-# Test backwards compatibility with Python 2.4.
-if not run_compat_test("python2.4"):
- class CPicklePython24Compat(unittest.TestCase):
- pass
-else:
- class CPicklePython24Compat(AbstractCompatTests):
-
- module = cPickle
- python = "python2.4"
- error = cPickle.BadPickleGet
-
- # Disable these tests for Python 2.4. Making them pass would require
- # nontrivially monkeypatching the pickletester module in the worker.
- def test_reduce_calls_base(self):
- pass
-
- def test_reduce_ex_calls_base(self):
- pass
-
-class PicklePython24Compat(CPicklePython24Compat):
-
- module = pickle
- error = KeyError
-
-
-# Test backwards compatibility with Python 2.5.
-if not run_compat_test("python2.5"):
- class CPicklePython25Compat(unittest.TestCase):
- pass
-else:
- class CPicklePython25Compat(AbstractCompatTests):
-
- module = cPickle
- python = "python2.5"
- error = cPickle.BadPickleGet
-
-class PicklePython25Compat(CPicklePython25Compat):
-
- module = pickle
- error = KeyError
-
-
-# Test backwards compatibility with Python 2.6.
-if not run_compat_test("python2.6"):
- class CPicklePython26Compat(unittest.TestCase):
- pass
-else:
- class CPicklePython26Compat(AbstractCompatTests):
-
- module = cPickle
- python = "python2.6"
- error = cPickle.BadPickleGet
-
-class PicklePython26Compat(CPicklePython26Compat):
-
- module = pickle
- error = KeyError
-
-
-def worker_main(in_stream, out_stream):
- message = cPickle.load(in_stream)
- protocol, obj = message
- cPickle.dump(obj, out_stream, protocol)
-
-
-def test_main():
- if not test_support.is_resource_enabled("xpickle"):
- print >>sys.stderr, "test_xpickle -- skipping backwards compat tests."
- print >>sys.stderr, "Use 'regrtest.py -u xpickle' to run them."
- sys.stderr.flush()
-
- test_support.run_unittest(
- DumpCPickle_LoadPickle,
- DumpPickle_LoadCPickle,
- CPicklePython24Compat,
- CPicklePython25Compat,
- CPicklePython26Compat,
- PicklePython24Compat,
- PicklePython25Compat,
- PicklePython26Compat,
- )
-
-if __name__ == "__main__":
- if "worker" in sys.argv:
- worker_main(sys.stdin, sys.stdout)
- else:
- test_main()
diff --git a/Lib/test/test_xrange.py b/Lib/test/test_xrange.py
deleted file mode 100644
index 83c0e415b7f..00000000000
--- a/Lib/test/test_xrange.py
+++ /dev/null
@@ -1,218 +0,0 @@
-# Python test set -- built-in functions
-
-import test.test_support, unittest
-import sys
-import pickle
-import itertools
-
-import warnings
-warnings.filterwarnings("ignore", "integer argument expected",
- DeprecationWarning, "unittest")
-
-# pure Python implementations (3 args only), for comparison
-def pyrange(start, stop, step):
- if (start - stop) // step < 0:
- # replace stop with next element in the sequence of integers
- # that are congruent to start modulo step.
- stop += (start - stop) % step
- while start != stop:
- yield start
- start += step
-
-def pyrange_reversed(start, stop, step):
- stop += (start - stop) % step
- return pyrange(stop - step, start - step, -step)
-
-
-class XrangeTest(unittest.TestCase):
- def assert_iterators_equal(self, xs, ys, test_id, limit=None):
- # check that an iterator xs matches the expected results ys,
- # up to a given limit.
- if limit is not None:
- xs = itertools.islice(xs, limit)
- ys = itertools.islice(ys, limit)
- sentinel = object()
- pairs = itertools.izip_longest(xs, ys, fillvalue=sentinel)
- for i, (x, y) in enumerate(pairs):
- if x == y:
- continue
- elif x == sentinel:
- self.fail('{}: iterator ended unexpectedly '
- 'at position {}; expected {}'.format(test_id, i, y))
- elif y == sentinel:
- self.fail('{}: unexpected excess element {} at '
- 'position {}'.format(test_id, x, i))
- else:
- self.fail('{}: wrong element at position {};'
- 'expected {}, got {}'.format(test_id, i, y, x))
-
- def assert_xranges_equivalent(self, x, y):
- # Check that two xrange objects are equivalent, in the sense of the
- # associated sequences being the same. We want to use this for large
- # xrange objects, so instead of converting to lists and comparing
- # directly we do a number of indirect checks.
- if len(x) != len(y):
- self.fail('{} and {} have different '
- 'lengths: {} and {} '.format(x, y, len(x), len(y)))
- if len(x) >= 1:
- if x[0] != y[0]:
- self.fail('{} and {} have different initial '
- 'elements: {} and {} '.format(x, y, x[0], y[0]))
- if x[-1] != y[-1]:
- self.fail('{} and {} have different final '
- 'elements: {} and {} '.format(x, y, x[-1], y[-1]))
- if len(x) >= 2:
- x_step = x[1] - x[0]
- y_step = y[1] - y[0]
- if x_step != y_step:
- self.fail('{} and {} have different step: '
- '{} and {} '.format(x, y, x_step, y_step))
-
- def test_xrange(self):
- self.assertEqual(list(xrange(3)), [0, 1, 2])
- self.assertEqual(list(xrange(1, 5)), [1, 2, 3, 4])
- self.assertEqual(list(xrange(0)), [])
- self.assertEqual(list(xrange(-3)), [])
- self.assertEqual(list(xrange(1, 10, 3)), [1, 4, 7])
- self.assertEqual(list(xrange(5, -5, -3)), [5, 2, -1, -4])
-
- a = 10
- b = 100
- c = 50
-
- self.assertEqual(list(xrange(a, a+2)), [a, a+1])
- self.assertEqual(list(xrange(a+2, a, -1L)), [a+2, a+1])
- self.assertEqual(list(xrange(a+4, a, -2)), [a+4, a+2])
-
- seq = list(xrange(a, b, c))
- self.assertIn(a, seq)
- self.assertNotIn(b, seq)
- self.assertEqual(len(seq), 2)
-
- seq = list(xrange(b, a, -c))
- self.assertIn(b, seq)
- self.assertNotIn(a, seq)
- self.assertEqual(len(seq), 2)
-
- seq = list(xrange(-a, -b, -c))
- self.assertIn(-a, seq)
- self.assertNotIn(-b, seq)
- self.assertEqual(len(seq), 2)
-
- self.assertRaises(TypeError, xrange)
- self.assertRaises(TypeError, xrange, 1, 2, 3, 4)
- self.assertRaises(ValueError, xrange, 1, 2, 0)
-
- self.assertRaises(OverflowError, xrange, 10**100, 10**101, 10**101)
-
- self.assertRaises(TypeError, xrange, 0, "spam")
- self.assertRaises(TypeError, xrange, 0, 42, "spam")
-
- self.assertEqual(len(xrange(0, sys.maxint, sys.maxint-1)), 2)
-
- self.assertRaises(OverflowError, xrange, -sys.maxint, sys.maxint)
- self.assertRaises(OverflowError, xrange, 0, 2*sys.maxint)
-
- r = xrange(-sys.maxint, sys.maxint, 2)
- self.assertEqual(len(r), sys.maxint)
- self.assertRaises(OverflowError, xrange, -sys.maxint-1, sys.maxint, 2)
-
- def test_pickling(self):
- testcases = [(13,), (0, 11), (-22, 10), (20, 3, -1),
- (13, 21, 3), (-2, 2, 2)]
- for proto in range(pickle.HIGHEST_PROTOCOL + 1):
- for t in testcases:
- r = xrange(*t)
- self.assertEqual(list(pickle.loads(pickle.dumps(r, proto))),
- list(r))
-
- M = min(sys.maxint, sys.maxsize)
- large_testcases = testcases + [
- (0, M, 1),
- (M, 0, -1),
- (0, M, M - 1),
- (M // 2, M, 1),
- (0, -M, -1),
- (0, -M, 1 - M),
- (-M, M, 2),
- (-M, M, 1024),
- (-M, M, 10585),
- (M, -M, -2),
- (M, -M, -1024),
- (M, -M, -10585),
- ]
- for proto in range(pickle.HIGHEST_PROTOCOL + 1):
- for t in large_testcases:
- r = xrange(*t)
- r_out = pickle.loads(pickle.dumps(r, proto))
- self.assert_xranges_equivalent(r_out, r)
-
- def test_repr(self):
- # Check that repr of an xrange is a valid representation
- # of that xrange.
-
- # Valid xranges have at most min(sys.maxint, sys.maxsize) elements.
- M = min(sys.maxint, sys.maxsize)
-
- testcases = [
- (13,),
- (0, 11),
- (-22, 10),
- (20, 3, -1),
- (13, 21, 3),
- (-2, 2, 2),
- (0, M, 1),
- (M, 0, -1),
- (0, M, M - 1),
- (M // 2, M, 1),
- (0, -M, -1),
- (0, -M, 1 - M),
- (-M, M, 2),
- (-M, M, 1024),
- (-M, M, 10585),
- (M, -M, -2),
- (M, -M, -1024),
- (M, -M, -10585),
- ]
- for t in testcases:
- r = xrange(*t)
- r_out = eval(repr(r))
- self.assert_xranges_equivalent(r, r_out)
-
- def test_range_iterators(self):
- # see issue 7298
- limits = [base + jiggle
- for M in (2**32, 2**64)
- for base in (-M, -M//2, 0, M//2, M)
- for jiggle in (-2, -1, 0, 1, 2)]
- test_ranges = [(start, end, step)
- for start in limits
- for end in limits
- for step in (-2**63, -2**31, -2, -1, 1, 2)]
-
- for start, end, step in test_ranges:
- try:
- iter1 = xrange(start, end, step)
- except OverflowError:
- pass
- else:
- iter2 = pyrange(start, end, step)
- test_id = "xrange({}, {}, {})".format(start, end, step)
- # check first 100 entries
- self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
-
- try:
- iter1 = reversed(xrange(start, end, step))
- except OverflowError:
- pass
- else:
- iter2 = pyrange_reversed(start, end, step)
- test_id = "reversed(xrange({}, {}, {}))".format(start, end, step)
- self.assert_iterators_equal(iter1, iter2, test_id, limit=100)
-
-
-def test_main():
- test.test_support.run_unittest(XrangeTest)
-
-if __name__ == "__main__":
- test_main()
diff --git a/Lib/test/test_zipfile.py b/Lib/test/test_zipfile.py
index 9bd3b5834c2..e07380dd16d 100644
--- a/Lib/test/test_zipfile.py
+++ b/Lib/test/test_zipfile.py
@@ -4,25 +4,27 @@ try:
except ImportError:
zlib = None
-import os
import io
+import os
import sys
+import imp
import time
import shutil
import struct
import zipfile
import unittest
-from StringIO import StringIO
+
from tempfile import TemporaryFile
from random import randint, random
from unittest import skipUnless
-from test.test_support import TESTFN, run_unittest, findfile, unlink
+from test.support import TESTFN, run_unittest, findfile, unlink
TESTFN2 = TESTFN + "2"
TESTFNDIR = TESTFN + "d"
FIXEDTEST_SIZE = 1000
+DATAFILES_DIR = 'zipfile_datafiles'
SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'),
('ziptest2dir/_ziptest2', 'qawsedrftg'),
@@ -32,9 +34,10 @@ SMALL_TEST_DATA = [('_ziptest1', '1q2w3e4r5t'),
class TestsWithSourceFile(unittest.TestCase):
def setUp(self):
- self.line_gen = ["Zipfile test line %d. random float: %f" % (i, random())
- for i in xrange(FIXEDTEST_SIZE)]
- self.data = '\n'.join(self.line_gen) + '\n'
+ self.line_gen = (bytes("Zipfile test line %d. random float: %f" %
+ (i, random()), "ascii")
+ for i in range(FIXEDTEST_SIZE))
+ self.data = b'\n'.join(self.line_gen) + b'\n'
# Make a source file with some lines
with open(TESTFN, "wb") as fp:
@@ -57,14 +60,8 @@ class TestsWithSourceFile(unittest.TestCase):
self.assertEqual(zipfp.read("strfile"), self.data)
# Print the ZIP directory
- fp = StringIO()
- stdout = sys.stdout
- try:
- sys.stdout = fp
- zipfp.printdir()
- finally:
- sys.stdout = stdout
-
+ fp = io.StringIO()
+ zipfp.printdir(file=fp)
directory = fp.getvalue()
lines = directory.splitlines()
self.assertEqual(len(lines), 4) # Number of files + header
@@ -104,9 +101,11 @@ class TestsWithSourceFile(unittest.TestCase):
# Check that testzip doesn't raise an exception
zipfp.testzip()
+ if not isinstance(f, str):
+ f.close()
def test_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test(f, zipfile.ZIP_STORED)
def zip_open_test(self, f, compression):
@@ -130,11 +129,13 @@ class TestsWithSourceFile(unittest.TestCase):
break
zipdata2.append(read_data)
- self.assertEqual(''.join(zipdata1), self.data)
- self.assertEqual(''.join(zipdata2), self.data)
+ self.assertEqual(b''.join(zipdata1), self.data)
+ self.assertEqual(b''.join(zipdata2), self.data)
+ if not isinstance(f, str):
+ f.close()
def test_open_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_open_test(f, zipfile.ZIP_STORED)
def test_open_via_zip_info(self):
@@ -145,15 +146,15 @@ class TestsWithSourceFile(unittest.TestCase):
with zipfile.ZipFile(TESTFN2, "r") as zipfp:
infos = zipfp.infolist()
- data = ""
+ data = b""
for info in infos:
- with zipfp.open(info) as f:
- data += f.read()
- self.assertTrue(data == "foobar" or data == "barfoo")
- data = ""
+ with zipfp.open(info) as zipopen:
+ data += zipopen.read()
+ self.assertTrue(data == b"foobar" or data == b"barfoo")
+ data = b""
for info in infos:
data += zipfp.read(info)
- self.assertTrue(data == "foobar" or data == "barfoo")
+ self.assertTrue(data == b"foobar" or data == b"barfoo")
def zip_random_open_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -168,46 +169,53 @@ class TestsWithSourceFile(unittest.TestCase):
break
zipdata1.append(read_data)
- self.assertEqual(''.join(zipdata1), self.data)
+ self.assertEqual(b''.join(zipdata1), self.data)
+ if not isinstance(f, str):
+ f.close()
def test_random_open_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_random_open_test(f, zipfile.ZIP_STORED)
def test_univeral_readaheads(self):
- f = StringIO()
+ f = io.BytesIO()
- data = 'a\r\n' * 16 * 1024
- with zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED) as zipfp:
- zipfp.writestr(TESTFN, data)
+ data = b'a\r\n' * 16 * 1024
+ zipfp = zipfile.ZipFile(f, 'w', zipfile.ZIP_STORED)
+ zipfp.writestr(TESTFN, data)
+ zipfp.close()
- data2 = ''
- with zipfile.ZipFile(f, 'r') as zipfp:
- with zipfp.open(TESTFN, 'rU') as zipopen:
- for line in zipopen:
- data2 += line
+ data2 = b''
+ zipfp = zipfile.ZipFile(f, 'r')
+ with zipfp.open(TESTFN, 'rU') as zipopen:
+ for line in zipopen:
+ data2 += line
+ zipfp.close()
- self.assertEqual(data, data2.replace('\n', '\r\n'))
+ self.assertEqual(data, data2.replace(b'\n', b'\r\n'))
def zip_readline_read_test(self, f, compression):
self.make_test_archive(f, compression)
# Read the ZIP archive
- with zipfile.ZipFile(f, "r") as zipfp:
- with zipfp.open(TESTFN) as zipopen:
- data = ''
- while True:
- read = zipopen.readline()
- if not read:
- break
- data += read
-
- read = zipopen.read(100)
- if not read:
- break
- data += read
+ zipfp = zipfile.ZipFile(f, "r")
+ with zipfp.open(TESTFN) as zipopen:
+ data = b''
+ while True:
+ read = zipopen.readline()
+ if not read:
+ break
+ data += read
+
+ read = zipopen.read(100)
+ if not read:
+ break
+ data += read
self.assertEqual(data, self.data)
+ zipfp.close()
+ if not isinstance(f, str):
+ f.close()
def zip_readline_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -218,76 +226,84 @@ class TestsWithSourceFile(unittest.TestCase):
for line in self.line_gen:
linedata = zipopen.readline()
self.assertEqual(linedata, line + '\n')
+ if not isinstance(f, str):
+ f.close()
def zip_readlines_test(self, f, compression):
self.make_test_archive(f, compression)
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
- with zipfp.open(TESTFN) as zo:
- ziplines = zo.readlines()
- for line, zipline in zip(self.line_gen, ziplines):
- self.assertEqual(zipline, line + '\n')
+ with zipfp.open(TESTFN) as zipopen:
+ ziplines = zipopen.readlines()
+ for line, zipline in zip(self.line_gen, ziplines):
+ self.assertEqual(zipline, line + '\n')
+ if not isinstance(f, str):
+ f.close()
def zip_iterlines_test(self, f, compression):
self.make_test_archive(f, compression)
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
- for line, zipline in zip(self.line_gen, zipfp.open(TESTFN)):
- self.assertEqual(zipline, line + '\n')
+ with zipfp.open(TESTFN) as zipopen:
+ for line, zipline in zip(self.line_gen, zipopen):
+ self.assertEqual(zipline, line + '\n')
+ if not isinstance(f, str):
+ f.close()
def test_readline_read_stored(self):
# Issue #7610: calls to readline() interleaved with calls to read().
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readline_read_test(f, zipfile.ZIP_STORED)
def test_readline_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readline_test(f, zipfile.ZIP_STORED)
def test_readlines_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readlines_test(f, zipfile.ZIP_STORED)
def test_iterlines_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_iterlines_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
def test_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test(f, zipfile.ZIP_DEFLATED)
+
@skipUnless(zlib, "requires zlib")
def test_open_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_open_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_random_open_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_random_open_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readline_read_deflated(self):
# Issue #7610: calls to readline() interleaved with calls to read().
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readline_read_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readline_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readline_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readlines_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_readlines_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_iterlines_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_iterlines_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
@@ -300,8 +316,8 @@ class TestsWithSourceFile(unittest.TestCase):
# Get an open object for strfile
with zipfile.ZipFile(TESTFN2, "r", zipfile.ZIP_DEFLATED) as zipfp:
with zipfp.open("strfile") as openobj:
- self.assertEqual(openobj.read(1), '1')
- self.assertEqual(openobj.read(1), '2')
+ self.assertEqual(openobj.read(1), b'1')
+ self.assertEqual(openobj.read(1), b'2')
def test_absolute_arcnames(self):
with zipfile.ZipFile(TESTFN2, "w", zipfile.ZIP_STORED) as zipfp:
@@ -323,7 +339,7 @@ class TestsWithSourceFile(unittest.TestCase):
"""Test appending to an existing file that is not a zipfile."""
# NOTE: this test fails if len(d) < 22 because of the first
# line "fpin.seek(-22, 2)" in _EndRecData
- data = 'I am not a ZipFile!'*10
+ data = b'I am not a ZipFile!'*10
with open(TESTFN2, 'wb') as f:
f.write(data)
@@ -358,7 +374,8 @@ class TestsWithSourceFile(unittest.TestCase):
produces the expected result."""
with zipfile.ZipFile(TESTFN2, "w") as zipfp:
zipfp.write(TESTFN)
- self.assertEqual(zipfp.read(TESTFN), open(TESTFN).read())
+ with open(TESTFN, "rb") as f:
+ self.assertEqual(zipfp.read(TESTFN), f.read())
@skipUnless(zlib, "requires zlib")
def test_per_file_compression(self):
@@ -400,7 +417,9 @@ class TestsWithSourceFile(unittest.TestCase):
self.assertEqual(writtenfile, correctfile)
# make sure correct data is in correct file
- self.assertEqual(fdata, open(writtenfile, "rb").read())
+ with open(writtenfile, "rb") as f:
+ self.assertEqual(fdata.encode(), f.read())
+
os.remove(writtenfile)
# remove the test file subdirectories
@@ -419,7 +438,9 @@ class TestsWithSourceFile(unittest.TestCase):
else:
outfile = os.path.join(os.getcwd(), fpath)
- self.assertEqual(fdata, open(outfile, "rb").read())
+ with open(outfile, "rb") as f:
+ self.assertEqual(fdata.encode(), f.read())
+
os.remove(outfile)
# remove the test file subdirectories
@@ -446,12 +467,21 @@ class TestsWithSourceFile(unittest.TestCase):
self.make_test_archive(f, compression)
with zipfile.ZipFile(f, "r") as zipfp:
zinfo = zipfp.getinfo('strfile')
- self.assertEqual(zinfo.external_attr, 0600 << 16)
+ self.assertEqual(zinfo.external_attr, 0o600 << 16)
+ if not isinstance(f, str):
+ f.close()
def test_writestr_permissions(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test_writestr_permissions(f, zipfile.ZIP_STORED)
+ def test_writestr_extended_local_header_issue1202(self):
+ with zipfile.ZipFile(TESTFN2, 'w') as orig_zip:
+ for data in 'abcdefghijklmnop':
+ zinfo = zipfile.ZipInfo(data)
+ zinfo.flag_bits |= 0x08 # Include an extended local header.
+ orig_zip.writestr(zinfo, data)
+
def test_close(self):
"""Check that the zipfile is closed after the 'with' block."""
with zipfile.ZipFile(TESTFN2, "w") as zipfp:
@@ -473,8 +503,8 @@ class TestsWithSourceFile(unittest.TestCase):
try:
with zipfile.ZipFile(TESTFN2, "r") as zipfp2:
- raise zipfile.BadZipfile()
- except zipfile.BadZipfile:
+ raise zipfile.BadZipFile()
+ except zipfile.BadZipFile:
self.assertTrue(zipfp2.fp is None, 'zipfp is not closed')
def test_add_file_before_1980(self):
@@ -483,6 +513,15 @@ class TestsWithSourceFile(unittest.TestCase):
with zipfile.ZipFile(TESTFN2, "w") as zipfp:
self.assertRaises(ValueError, zipfp.write, TESTFN)
+
+ @skipUnless(zlib, "requires zlib")
+ def test_unicode_filenames(self):
+ # bug #10801
+ fname = findfile('zip_cp437_header.zip')
+ with zipfile.ZipFile(fname) as zipfp:
+ for name in zipfp.namelist():
+ zipfp.open(name).close()
+
def tearDown(self):
unlink(TESTFN)
unlink(TESTFN2)
@@ -496,9 +535,9 @@ class TestZip64InSmallFiles(unittest.TestCase):
self._limit = zipfile.ZIP64_LIMIT
zipfile.ZIP64_LIMIT = 5
- line_gen = ("Test of zipfile line %d." % i
+ line_gen = (bytes("Test of zipfile line %d." % i, "ascii")
for i in range(0, FIXEDTEST_SIZE))
- self.data = '\n'.join(line_gen)
+ self.data = b'\n'.join(line_gen)
# Make a source file with some lines
with open(TESTFN, "wb") as fp:
@@ -513,9 +552,11 @@ class TestZip64InSmallFiles(unittest.TestCase):
with zipfile.ZipFile(f, "w", compression) as zipfp:
self.assertRaises(zipfile.LargeZipFile,
zipfp.writestr, "another.name", self.data)
+ if not isinstance(f, str):
+ f.close()
def test_large_file_exception(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.large_file_exception_test(f, zipfile.ZIP_STORED)
self.large_file_exception_test2(f, zipfile.ZIP_STORED)
@@ -533,13 +574,8 @@ class TestZip64InSmallFiles(unittest.TestCase):
self.assertEqual(zipfp.read("strfile"), self.data)
# Print the ZIP directory
- fp = StringIO()
- stdout = sys.stdout
- try:
- sys.stdout = fp
- zipfp.printdir()
- finally:
- sys.stdout = stdout
+ fp = io.StringIO()
+ zipfp.printdir(fp)
directory = fp.getvalue()
lines = directory.splitlines()
@@ -580,14 +616,16 @@ class TestZip64InSmallFiles(unittest.TestCase):
# Check that testzip doesn't raise an exception
zipfp.testzip()
+ if not isinstance(f, str):
+ f.close()
def test_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
def test_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test(f, zipfile.ZIP_DEFLATED)
def test_absolute_arcnames(self):
@@ -606,10 +644,16 @@ class TestZip64InSmallFiles(unittest.TestCase):
class PyZipFileTests(unittest.TestCase):
def test_write_pyfile(self):
- with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
fn = __file__
if fn.endswith('.pyc') or fn.endswith('.pyo'):
- fn = fn[:-1]
+ path_split = fn.split(os.sep)
+ if os.altsep is not None:
+ path_split.extend(fn.split(os.altsep))
+ if '__pycache__' in path_split:
+ fn = imp.source_from_cache(fn)
+ else:
+ fn = fn[:-1]
zipfp.writepy(fn)
@@ -618,7 +662,7 @@ class PyZipFileTests(unittest.TestCase):
self.assertTrue(bn + 'o' in zipfp.namelist() or
bn + 'c' in zipfp.namelist())
- with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
fn = __file__
if fn.endswith(('.pyc', '.pyo')):
fn = fn[:-1]
@@ -634,7 +678,7 @@ class PyZipFileTests(unittest.TestCase):
import email
packagedir = os.path.dirname(email.__file__)
- with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
zipfp.writepy(packagedir)
# Check for a couple of modules at different levels of the
@@ -645,6 +689,22 @@ class PyZipFileTests(unittest.TestCase):
self.assertTrue('email/mime/text.pyo' in names or
'email/mime/text.pyc' in names)
+ def test_write_with_optimization(self):
+ import email
+ packagedir = os.path.dirname(email.__file__)
+ # use .pyc if running test in optimization mode,
+ # use .pyo if running test in debug mode
+ optlevel = 1 if __debug__ else 0
+ ext = '.pyo' if optlevel == 1 else '.pyc'
+
+ with TemporaryFile() as t, \
+ zipfile.PyZipFile(t, "w", optimize=optlevel) as zipfp:
+ zipfp.writepy(packagedir)
+
+ names = zipfp.namelist()
+ self.assertIn('email/__init__' + ext, names)
+ self.assertIn('email/mime/text' + ext, names)
+
def test_write_python_directory(self):
os.mkdir(TESTFN2)
try:
@@ -657,20 +717,21 @@ class PyZipFileTests(unittest.TestCase):
with open(os.path.join(TESTFN2, "mod2.txt"), "w") as fp:
fp.write("bla bla bla\n")
- zipfp = zipfile.PyZipFile(TemporaryFile(), "w")
- zipfp.writepy(TESTFN2)
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ zipfp.writepy(TESTFN2)
- names = zipfp.namelist()
- self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
- self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
- self.assertNotIn('mod2.txt', names)
+ names = zipfp.namelist()
+ self.assertTrue('mod1.pyc' in names or 'mod1.pyo' in names)
+ self.assertTrue('mod2.pyc' in names or 'mod2.pyo' in names)
+ self.assertNotIn('mod2.txt', names)
finally:
shutil.rmtree(TESTFN2)
def test_write_non_pyfile(self):
- with zipfile.PyZipFile(TemporaryFile(), "w") as zipfp:
- open(TESTFN, 'w').write('most definitely not a python file')
+ with TemporaryFile() as t, zipfile.PyZipFile(t, "w") as zipfp:
+ with open(TESTFN, 'w') as f:
+ f.write('most definitely not a python file')
self.assertRaises(RuntimeError, zipfp.writepy, TESTFN)
os.remove(TESTFN)
@@ -699,20 +760,20 @@ class OtherTests(unittest.TestCase):
def test_unicode_filenames(self):
with zipfile.ZipFile(TESTFN, "w") as zf:
- zf.writestr(u"foo.txt", "Test for unicode filename")
- zf.writestr(u"\xf6.txt", "Test for unicode filename")
- self.assertIsInstance(zf.infolist()[0].filename, unicode)
+ zf.writestr("foo.txt", "Test for unicode filename")
+ zf.writestr("\xf6.txt", "Test for unicode filename")
+ self.assertIsInstance(zf.infolist()[0].filename, str)
with zipfile.ZipFile(TESTFN, "r") as zf:
self.assertEqual(zf.filelist[0].filename, "foo.txt")
- self.assertEqual(zf.filelist[1].filename, u"\xf6.txt")
+ self.assertEqual(zf.filelist[1].filename, "\xf6.txt")
def test_create_non_existent_file_for_append(self):
if os.path.exists(TESTFN):
os.unlink(TESTFN)
filename = 'testfile.txt'
- content = 'hello, world. this is some content.'
+ content = b'hello, world. this is some content.'
try:
with zipfile.ZipFile(TESTFN, 'a') as zf:
@@ -737,7 +798,7 @@ class OtherTests(unittest.TestCase):
fp.write("this is not a legal zip file\n")
try:
zf = zipfile.ZipFile(TESTFN)
- except zipfile.BadZipfile:
+ except zipfile.BadZipFile:
pass
def test_is_zip_erroneous_file(self):
@@ -752,8 +813,8 @@ class OtherTests(unittest.TestCase):
chk = zipfile.is_zipfile(fp)
self.assertTrue(not chk)
# - passing a file-like object
- fp = StringIO()
- fp.write("this is not a legal zip file\n")
+ fp = io.BytesIO()
+ fp.write(b"this is not a legal zip file\n")
chk = zipfile.is_zipfile(fp)
self.assertTrue(not chk)
fp.seek(0, 0)
@@ -764,7 +825,8 @@ class OtherTests(unittest.TestCase):
"""Check that is_zipfile() correctly identifies zip files."""
# - passing a filename
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
- zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ zipf.writestr("foo.txt", b"O, for a Muse of Fire!")
+
chk = zipfile.is_zipfile(TESTFN)
self.assertTrue(chk)
# - passing a file object
@@ -774,7 +836,7 @@ class OtherTests(unittest.TestCase):
fp.seek(0, 0)
zip_contents = fp.read()
# - passing a file-like object
- fp = StringIO()
+ fp = io.BytesIO()
fp.write(zip_contents)
chk = zipfile.is_zipfile(fp)
self.assertTrue(chk)
@@ -797,17 +859,17 @@ class OtherTests(unittest.TestCase):
self.assertRaises(IOError, zipfile.ZipFile, TESTFN)
def test_empty_file_raises_BadZipFile(self):
- with open(TESTFN, 'w') as f:
- pass
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+ f = open(TESTFN, 'w')
+ f.close()
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)
with open(TESTFN, 'w') as fp:
fp.write("short file")
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN)
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN)
def test_closed_zip_raises_RuntimeError(self):
"""Verify that testzip() doesn't swallow inappropriate exceptions."""
- data = StringIO()
+ data = io.BytesIO()
with zipfile.ZipFile(data, mode="w") as zipf:
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
@@ -819,7 +881,8 @@ class OtherTests(unittest.TestCase):
self.assertRaises(RuntimeError, zipf.open, "foo.txt")
self.assertRaises(RuntimeError, zipf.testzip)
self.assertRaises(RuntimeError, zipf.writestr, "bogus.txt", "bogus")
- open(TESTFN, 'w').write('zipfile test data')
+ with open(TESTFN, 'w') as f:
+ f.write('zipfile test data')
self.assertRaises(RuntimeError, zipf.write, TESTFN)
def test_bad_constructor_mode(self):
@@ -843,10 +906,10 @@ class OtherTests(unittest.TestCase):
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
# read the data to make sure the file is there
with zipf.open("foo.txt") as f:
- for i in xrange(FIXEDTEST_SIZE):
- self.assertEqual(f.read(0), '')
+ for i in range(FIXEDTEST_SIZE):
+ self.assertEqual(f.read(0), b'')
- self.assertEqual(f.read(), "O, for a Muse of Fire!")
+ self.assertEqual(f.read(), b"O, for a Muse of Fire!")
def test_open_non_existent_item(self):
"""Check that attempting to call open() for an item that doesn't
@@ -874,7 +937,7 @@ class OtherTests(unittest.TestCase):
"""Check that a filename containing a null byte is properly
terminated."""
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
- zipf.writestr("foo.txt\x00qqq", "O, for a Muse of Fire!")
+ zipf.writestr("foo.txt\x00qqq", b"O, for a Muse of Fire!")
self.assertEqual(zipf.namelist(), ['foo.txt'])
def test_struct_sizes(self):
@@ -889,35 +952,60 @@ class OtherTests(unittest.TestCase):
# check default comment is empty
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
- self.assertEqual(zipf.comment, '')
+ self.assertEqual(zipf.comment, b'')
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- with zipfile.ZipFile(TESTFN, mode="r") as zipf:
- self.assertEqual(zipf.comment, '')
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, b'')
# check a simple short comment
- comment = 'Bravely taking to his feet, he beat a very brave retreat.'
+ comment = b'Bravely taking to his feet, he beat a very brave retreat.'
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
zipf.comment = comment
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- with zipfile.ZipFile(TESTFN, mode="r") as zipf:
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
self.assertEqual(zipf.comment, comment)
# check a comment of max length
- comment2 = ''.join(['%d' % (i**3 % 10) for i in xrange((1 << 16)-1)])
+ comment2 = ''.join(['%d' % (i**3 % 10) for i in range((1 << 16)-1)])
+ comment2 = comment2.encode("ascii")
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
zipf.comment = comment2
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- with zipfile.ZipFile(TESTFN, mode="r") as zipf:
- self.assertEqual(zipf.comment, comment2)
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, comment2)
# check a comment that is too long is truncated
with zipfile.ZipFile(TESTFN, mode="w") as zipf:
- zipf.comment = comment2 + 'oops'
+ zipf.comment = comment2 + b'oops'
zipf.writestr("foo.txt", "O, for a Muse of Fire!")
- with zipfile.ZipFile(TESTFN, mode="r") as zipf:
- self.assertEqual(zipf.comment, comment2)
+ with zipfile.ZipFile(TESTFN, mode="r") as zipfr:
+ self.assertEqual(zipfr.comment, comment2)
+
+ # check that comments are correctly modified in append mode
+ with zipfile.ZipFile(TESTFN,mode="w") as zipf:
+ zipf.comment = b"original comment"
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN,mode="a") as zipf:
+ zipf.comment = b"an updated comment"
+ with zipfile.ZipFile(TESTFN,mode="r") as zipf:
+ self.assertEqual(zipf.comment, b"an updated comment")
+
+ # check that comments are correctly shortened in append mode
+ with zipfile.ZipFile(TESTFN,mode="w") as zipf:
+ zipf.comment = b"original comment that's longer"
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with zipfile.ZipFile(TESTFN,mode="a") as zipf:
+ zipf.comment = b"shorter comment"
+ with zipfile.ZipFile(TESTFN,mode="r") as zipf:
+ self.assertEqual(zipf.comment, b"shorter comment")
+
+ def test_unicode_comment(self):
+ with zipfile.ZipFile(TESTFN, "w", zipfile.ZIP_STORED) as zipf:
+ zipf.writestr("foo.txt", "O, for a Muse of Fire!")
+ with self.assertRaises(TypeError):
+ zipf.comment = "this is an error"
def test_change_comment_in_empty_archive(self):
with zipfile.ZipFile(TESTFN, "a", zipfile.ZIP_STORED) as zipf:
@@ -951,23 +1039,23 @@ class OtherTests(unittest.TestCase):
self.check_testzip_with_bad_crc(zipfile.ZIP_DEFLATED)
def check_read_with_bad_crc(self, compression):
- """Tests that files with bad CRCs raise a BadZipfile exception when read."""
+ """Tests that files with bad CRCs raise a BadZipFile exception when read."""
zipdata = self.zips_with_bad_crc[compression]
# Using ZipFile.read()
with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
- self.assertRaises(zipfile.BadZipfile, zipf.read, 'afile')
+ self.assertRaises(zipfile.BadZipFile, zipf.read, 'afile')
# Using ZipExtFile.read()
with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
with zipf.open('afile', 'r') as corrupt_file:
- self.assertRaises(zipfile.BadZipfile, corrupt_file.read)
+ self.assertRaises(zipfile.BadZipFile, corrupt_file.read)
# Same with small reads (in order to exercise the buffering logic)
with zipfile.ZipFile(io.BytesIO(zipdata), mode="r") as zipf:
with zipf.open('afile', 'r') as corrupt_file:
corrupt_file.MIN_READ_SIZE = 2
- with self.assertRaises(zipfile.BadZipfile):
+ with self.assertRaises(zipfile.BadZipFile):
while corrupt_file.read(2):
pass
@@ -1001,15 +1089,15 @@ class OtherTests(unittest.TestCase):
def test_empty_zipfile(self):
# Check that creating a file in 'w' or 'a' mode and closing without
# adding any files to the archives creates a valid empty ZIP file
- with zipfile.ZipFile(TESTFN, mode="w") as zipf:
- pass
+ zipf = zipfile.ZipFile(TESTFN, mode="w")
+ zipf.close()
try:
zipf = zipfile.ZipFile(TESTFN, mode="r")
- except zipfile.BadZipfile:
+ except zipfile.BadZipFile:
self.fail("Unable to create empty ZIP file in 'w' mode")
- with zipfile.ZipFile(TESTFN, mode="a") as zipf:
- pass
+ zipf = zipfile.ZipFile(TESTFN, mode="a")
+ zipf.close()
try:
zipf = zipfile.ZipFile(TESTFN, mode="r")
except:
@@ -1017,11 +1105,11 @@ class OtherTests(unittest.TestCase):
def test_open_empty_file(self):
# Issue 1710703: Check that opening a file with less than 22 bytes
- # raises a BadZipfile exception (rather than the previously unhelpful
+ # raises a BadZipFile exception (rather than the previously unhelpful
# IOError)
- with open(TESTFN, 'w') as f:
- pass
- self.assertRaises(zipfile.BadZipfile, zipfile.ZipFile, TESTFN, 'r')
+ f = open(TESTFN, 'w')
+ f.close()
+ self.assertRaises(zipfile.BadZipFile, zipfile.ZipFile, TESTFN, 'r')
def test_create_zipinfo_before_1980(self):
self.assertRaises(ValueError,
@@ -1038,25 +1126,25 @@ class DecryptionTests(unittest.TestCase):
ZIP file."""
data = (
- 'PK\x03\x04\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00\x1a\x00'
- '\x00\x00\x08\x00\x00\x00test.txt\xfa\x10\xa0gly|\xfa-\xc5\xc0=\xf9y'
- '\x18\xe0\xa8r\xb3Z}Lg\xbc\xae\xf9|\x9b\x19\xe4\x8b\xba\xbb)\x8c\xb0\xdbl'
- 'PK\x01\x02\x14\x00\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00'
- '\x1a\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\xb6\x81'
- '\x00\x00\x00\x00test.txtPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x006\x00'
- '\x00\x00L\x00\x00\x00\x00\x00' )
+ b'PK\x03\x04\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00\x1a\x00'
+ b'\x00\x00\x08\x00\x00\x00test.txt\xfa\x10\xa0gly|\xfa-\xc5\xc0=\xf9y'
+ b'\x18\xe0\xa8r\xb3Z}Lg\xbc\xae\xf9|\x9b\x19\xe4\x8b\xba\xbb)\x8c\xb0\xdbl'
+ b'PK\x01\x02\x14\x00\x14\x00\x01\x00\x00\x00n\x92i.#y\xef?&\x00\x00\x00'
+ b'\x1a\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\xb6\x81'
+ b'\x00\x00\x00\x00test.txtPK\x05\x06\x00\x00\x00\x00\x01\x00\x01\x006\x00'
+ b'\x00\x00L\x00\x00\x00\x00\x00' )
data2 = (
- 'PK\x03\x04\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02'
- '\x00\x00\x04\x00\x15\x00zeroUT\t\x00\x03\xd6\x8b\x92G\xda\x8b\x92GUx\x04'
- '\x00\xe8\x03\xe8\x03\xc7<M\xb5a\xceX\xa3Y&\x8b{oE\xd7\x9d\x8c\x98\x02\xc0'
- 'PK\x07\x08xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00PK\x01\x02\x17\x03'
- '\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00'
- '\x04\x00\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00ze'
- 'roUT\x05\x00\x03\xd6\x8b\x92GUx\x00\x00PK\x05\x06\x00\x00\x00\x00\x01'
- '\x00\x01\x00?\x00\x00\x00[\x00\x00\x00\x00\x00' )
-
- plain = 'zipfile.py encryption test'
- plain2 = '\x00'*512
+ b'PK\x03\x04\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02'
+ b'\x00\x00\x04\x00\x15\x00zeroUT\t\x00\x03\xd6\x8b\x92G\xda\x8b\x92GUx\x04'
+ b'\x00\xe8\x03\xe8\x03\xc7<M\xb5a\xceX\xa3Y&\x8b{oE\xd7\x9d\x8c\x98\x02\xc0'
+ b'PK\x07\x08xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00PK\x01\x02\x17\x03'
+ b'\x14\x00\t\x00\x08\x00\xcf}38xu\xaa\xb2\x14\x00\x00\x00\x00\x02\x00\x00'
+ b'\x04\x00\r\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x81\x00\x00\x00\x00ze'
+ b'roUT\x05\x00\x03\xd6\x8b\x92GUx\x00\x00PK\x05\x06\x00\x00\x00\x00\x01'
+ b'\x00\x01\x00?\x00\x00\x00[\x00\x00\x00\x00\x00' )
+
+ plain = b'zipfile.py encryption test'
+ plain2 = b'\x00'*512
def setUp(self):
with open(TESTFN, "wb") as fp:
@@ -1079,24 +1167,30 @@ class DecryptionTests(unittest.TestCase):
self.assertRaises(RuntimeError, self.zip2.read, "zero")
def test_bad_password(self):
- self.zip.setpassword("perl")
+ self.zip.setpassword(b"perl")
self.assertRaises(RuntimeError, self.zip.read, "test.txt")
- self.zip2.setpassword("perl")
+ self.zip2.setpassword(b"perl")
self.assertRaises(RuntimeError, self.zip2.read, "zero")
@skipUnless(zlib, "requires zlib")
def test_good_password(self):
- self.zip.setpassword("python")
+ self.zip.setpassword(b"python")
self.assertEqual(self.zip.read("test.txt"), self.plain)
- self.zip2.setpassword("12345")
+ self.zip2.setpassword(b"12345")
self.assertEqual(self.zip2.read("zero"), self.plain2)
+ def test_unicode_password(self):
+ self.assertRaises(TypeError, self.zip.setpassword, "unicode")
+ self.assertRaises(TypeError, self.zip.read, "test.txt", "python")
+ self.assertRaises(TypeError, self.zip.open, "test.txt", pwd="python")
+ self.assertRaises(TypeError, self.zip.extract, "test.txt", pwd="python")
+
class TestsWithRandomBinaryFiles(unittest.TestCase):
def setUp(self):
datacount = randint(16, 64)*1024 + randint(1, 1024)
- self.data = ''.join(struct.pack('<f', random()*randint(-1000, 1000))
- for i in xrange(datacount))
+ self.data = b''.join(struct.pack('<f', random()*randint(-1000, 1000))
+ for i in range(datacount))
# Make a source file with some lines
with open(TESTFN, "wb") as fp:
@@ -1121,9 +1215,11 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
self.assertEqual(len(testdata), len(self.data))
self.assertEqual(testdata, self.data)
self.assertEqual(zipfp.read("another.name"), self.data)
+ if not isinstance(f, str):
+ f.close()
def test_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
@@ -1152,16 +1248,18 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
break
zipdata2.append(read_data)
- testdata1 = ''.join(zipdata1)
+ testdata1 = b''.join(zipdata1)
self.assertEqual(len(testdata1), len(self.data))
self.assertEqual(testdata1, self.data)
- testdata2 = ''.join(zipdata2)
+ testdata2 = b''.join(zipdata2)
self.assertEqual(len(testdata2), len(self.data))
self.assertEqual(testdata2, self.data)
+ if not isinstance(f, str):
+ f.close()
def test_open_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_open_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
@@ -1182,12 +1280,14 @@ class TestsWithRandomBinaryFiles(unittest.TestCase):
break
zipdata1.append(read_data)
- testdata = ''.join(zipdata1)
+ testdata = b''.join(zipdata1)
self.assertEqual(len(testdata), len(self.data))
self.assertEqual(testdata, self.data)
+ if not isinstance(f, str):
+ f.close()
def test_random_open_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.zip_random_open_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
@@ -1208,12 +1308,11 @@ class TestsWithMultipleOpens(unittest.TestCase):
# Verify that (when the ZipFile is in control of creating file objects)
# multiple open() calls can be made without interfering with each other.
with zipfile.ZipFile(TESTFN2, mode="r") as zipf:
- zopen1 = zipf.open('ones')
- zopen2 = zipf.open('ones')
- data1 = zopen1.read(500)
- data2 = zopen2.read(500)
- data1 += zopen1.read(500)
- data2 += zopen2.read(500)
+ with zipf.open('ones') as zopen1, zipf.open('ones') as zopen2:
+ data1 = zopen1.read(500)
+ data2 = zopen2.read(500)
+ data1 += zopen1.read(500)
+ data2 += zopen2.read(500)
self.assertEqual(data1, data2)
def test_different_file(self):
@@ -1225,8 +1324,8 @@ class TestsWithMultipleOpens(unittest.TestCase):
data2 = zopen2.read(500)
data1 += zopen1.read(500)
data2 += zopen2.read(500)
- self.assertEqual(data1, '1'*FIXEDTEST_SIZE)
- self.assertEqual(data2, '2'*FIXEDTEST_SIZE)
+ self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
+ self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
def test_interleaved(self):
# Verify that (when the ZipFile is in control of creating file objects)
@@ -1237,8 +1336,8 @@ class TestsWithMultipleOpens(unittest.TestCase):
data2 = zopen2.read(500)
data1 += zopen1.read(500)
data2 += zopen2.read(500)
- self.assertEqual(data1, '1'*FIXEDTEST_SIZE)
- self.assertEqual(data2, '2'*FIXEDTEST_SIZE)
+ self.assertEqual(data1, b'1'*FIXEDTEST_SIZE)
+ self.assertEqual(data2, b'2'*FIXEDTEST_SIZE)
def tearDown(self):
unlink(TESTFN2)
@@ -1274,14 +1373,19 @@ class TestWithDirectory(unittest.TestCase):
class UniversalNewlineTests(unittest.TestCase):
def setUp(self):
- self.line_gen = ["Test of zipfile line %d." % i
- for i in xrange(FIXEDTEST_SIZE)]
+ self.line_gen = [bytes("Test of zipfile line %d." % i, "ascii")
+ for i in range(FIXEDTEST_SIZE)]
self.seps = ('\r', '\r\n', '\n')
self.arcdata, self.arcfiles = {}, {}
for n, s in enumerate(self.seps):
- self.arcdata[s] = s.join(self.line_gen) + s
+ b = s.encode("ascii")
+ self.arcdata[s] = b.join(self.line_gen) + b
self.arcfiles[s] = '%s-%d' % (TESTFN, n)
- open(self.arcfiles[s], "wb").write(self.arcdata[s])
+ f = open(self.arcfiles[s], "wb")
+ try:
+ f.write(self.arcdata[s])
+ finally:
+ f.close()
def make_test_archive(self, f, compression):
# Create the ZIP archive
@@ -1298,29 +1402,32 @@ class UniversalNewlineTests(unittest.TestCase):
with zipfp.open(fn, "rU") as fp:
zipdata = fp.read()
self.assertEqual(self.arcdata[sep], zipdata)
+ if not isinstance(f, str):
+ f.close()
def readline_read_test(self, f, compression):
self.make_test_archive(f, compression)
# Read the ZIP archive
- zipfp = zipfile.ZipFile(f, "r")
- for sep, fn in self.arcfiles.items():
- with zipfp.open(fn, "rU") as zipopen:
- data = ''
- while True:
- read = zipopen.readline()
- if not read:
- break
- data += read
-
- read = zipopen.read(5)
- if not read:
- break
- data += read
+ with zipfile.ZipFile(f, "r") as zipfp:
+ for sep, fn in self.arcfiles.items():
+ with zipfp.open(fn, "rU") as zipopen:
+ data = b''
+ while True:
+ read = zipopen.readline()
+ if not read:
+ break
+ data += read
+
+ read = zipopen.read(5)
+ if not read:
+ break
+ data += read
self.assertEqual(data, self.arcdata['\n'])
- zipfp.close()
+ if not isinstance(f, str):
+ f.close()
def readline_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -1331,7 +1438,9 @@ class UniversalNewlineTests(unittest.TestCase):
with zipfp.open(fn, "rU") as zipopen:
for line in self.line_gen:
linedata = zipopen.readline()
- self.assertEqual(linedata, line + '\n')
+ self.assertEqual(linedata, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
def readlines_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -1342,7 +1451,9 @@ class UniversalNewlineTests(unittest.TestCase):
with zipfp.open(fn, "rU") as fp:
ziplines = fp.readlines()
for line, zipline in zip(self.line_gen, ziplines):
- self.assertEqual(zipline, line + '\n')
+ self.assertEqual(zipline, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
def iterlines_test(self, f, compression):
self.make_test_archive(f, compression)
@@ -1350,54 +1461,57 @@ class UniversalNewlineTests(unittest.TestCase):
# Read the ZIP archive
with zipfile.ZipFile(f, "r") as zipfp:
for sep, fn in self.arcfiles.items():
- for line, zipline in zip(self.line_gen, zipfp.open(fn, "rU")):
- self.assertEqual(zipline, line + '\n')
+ with zipfp.open(fn, "rU") as fp:
+ for line, zipline in zip(self.line_gen, fp):
+ self.assertEqual(zipline, line + b'\n')
+ if not isinstance(f, str):
+ f.close()
def test_read_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.read_test(f, zipfile.ZIP_STORED)
def test_readline_read_stored(self):
# Issue #7610: calls to readline() interleaved with calls to read().
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readline_read_test(f, zipfile.ZIP_STORED)
def test_readline_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readline_test(f, zipfile.ZIP_STORED)
def test_readlines_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readlines_test(f, zipfile.ZIP_STORED)
def test_iterlines_stored(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.iterlines_test(f, zipfile.ZIP_STORED)
@skipUnless(zlib, "requires zlib")
def test_read_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.read_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readline_read_deflated(self):
# Issue #7610: calls to readline() interleaved with calls to read().
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readline_read_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readline_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readline_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_readlines_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.readlines_test(f, zipfile.ZIP_DEFLATED)
@skipUnless(zlib, "requires zlib")
def test_iterlines_deflated(self):
- for f in (TESTFN2, TemporaryFile(), StringIO()):
+ for f in (TESTFN2, TemporaryFile(), io.BytesIO()):
self.iterlines_test(f, zipfile.ZIP_DEFLATED)
def tearDown(self):
diff --git a/Lib/test/test_zipfile64.py b/Lib/test/test_zipfile64.py
index a6f3dca4b9c..0e7d73f1fff 100644
--- a/Lib/test/test_zipfile64.py
+++ b/Lib/test/test_zipfile64.py
@@ -1,12 +1,12 @@
# Tests of the full ZIP64 functionality of zipfile
-# The test_support.requires call is the only reason for keeping this separate
+# The support.requires call is the only reason for keeping this separate
# from test_zipfile
-from test import test_support
+from test import support
# XXX(nnorwitz): disable this test by looking for extra largfile resource
# which doesn't exist. This test takes over 30 minutes to run in general
# and requires more disk space than most of the buildbots.
-test_support.requires(
+support.requires(
'extralargefile',
'test requires loads of disk-space bytes and a long time to run'
)
@@ -21,9 +21,10 @@ import zipfile, os, unittest
import time
import sys
+from io import StringIO
from tempfile import TemporaryFile
-from test.test_support import TESTFN, run_unittest
+from test.support import TESTFN, run_unittest
TESTFN2 = TESTFN + "2"
@@ -33,10 +34,8 @@ _PRINT_WORKING_MSG_INTERVAL = 5 * 60
class TestsWithSourceFile(unittest.TestCase):
def setUp(self):
# Create test data.
- # xrange() is important here -- don't want to create immortal space
- # for a million ints.
- line_gen = ("Test of zipfile line %d." % i for i in xrange(1000000))
- self.data = '\n'.join(line_gen)
+ line_gen = ("Test of zipfile line %d." % i for i in range(1000000))
+ self.data = '\n'.join(line_gen).encode('ascii')
# And write it to a file.
fp = open(TESTFN, "wb")
@@ -57,9 +56,9 @@ class TestsWithSourceFile(unittest.TestCase):
# Print still working message since this test can be really slow
if next_time <= time.time():
next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
- print >>sys.__stdout__, (
+ print((
' zipTest still writing %d of %d, be patient...' %
- (num, filecount))
+ (num, filecount)), file=sys.__stdout__)
sys.__stdout__.flush()
zipfp.close()
@@ -70,9 +69,9 @@ class TestsWithSourceFile(unittest.TestCase):
# Print still working message since this test can be really slow
if next_time <= time.time():
next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
- print >>sys.__stdout__, (
+ print((
' zipTest still reading %d of %d, be patient...' %
- (num, filecount))
+ (num, filecount)), file=sys.__stdout__)
sys.__stdout__.flush()
zipfp.close()
@@ -101,21 +100,22 @@ class OtherTests(unittest.TestCase):
# and that the resulting archive can be read properly by ZipFile
zipf = zipfile.ZipFile(TESTFN, mode="w")
zipf.debug = 100
- numfiles = (1 << 16) * 3/2
- for i in xrange(numfiles):
+ numfiles = (1 << 16) * 3//2
+ for i in range(numfiles):
zipf.writestr("foo%08d" % i, "%d" % (i**3 % 57))
self.assertEqual(len(zipf.namelist()), numfiles)
zipf.close()
zipf2 = zipfile.ZipFile(TESTFN, mode="r")
self.assertEqual(len(zipf2.namelist()), numfiles)
- for i in xrange(numfiles):
- self.assertEqual(zipf2.read("foo%08d" % i), "%d" % (i**3 % 57))
+ for i in range(numfiles):
+ content = zipf2.read("foo%08d" % i).decode('ascii')
+ self.assertEqual(content, "%d" % (i**3 % 57))
zipf.close()
def tearDown(self):
- test_support.unlink(TESTFN)
- test_support.unlink(TESTFN2)
+ support.unlink(TESTFN)
+ support.unlink(TESTFN2)
def test_main():
run_unittest(TestsWithSourceFile, OtherTests)
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py
index a66738a778c..df5ff9d6a69 100644
--- a/Lib/test/test_zipimport.py
+++ b/Lib/test/test_zipimport.py
@@ -6,7 +6,7 @@ import struct
import time
import unittest
-from test import test_support
+from test import support
from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co
# some tests can be ran even without zlib
@@ -21,7 +21,7 @@ import zipimport
import linecache
import doctest
import inspect
-import StringIO
+import io
from traceback import extract_tb, extract_stack, print_tb
raise_src = 'def do_raise(): raise TypeError\n'
@@ -32,7 +32,7 @@ def make_pyc(co, mtime):
if mtime < 0x7fffffff:
mtime = int(mtime)
else:
- mtime = int(-0x100000000L + long(mtime))
+ mtime = int(-0x100000000 + int(mtime))
pyc = imp.get_magic() + struct.pack("<i", int(mtime)) + data
return pyc
@@ -43,16 +43,13 @@ NOW = time.time()
test_pyc = make_pyc(test_co, NOW)
-if __debug__:
- pyc_ext = ".pyc"
-else:
- pyc_ext = ".pyo"
-
-
TESTMOD = "ziptestmodule"
TESTPACK = "ziptestpackage"
TESTPACK2 = "ziptestpackage2"
-TEMP_ZIP = os.path.abspath("junk95142" + os.extsep + "zip")
+TEMP_ZIP = os.path.abspath("junk95142.zip")
+
+pyc_file = imp.cache_from_source(TESTMOD + '.py')
+pyc_ext = ('.pyc' if __debug__ else '.pyo')
class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
@@ -78,14 +75,11 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
stuff = kw.get("stuff", None)
if stuff is not None:
# Prepend 'stuff' to the start of the zipfile
- f = open(TEMP_ZIP, "rb")
- data = f.read()
- f.close()
-
- f = open(TEMP_ZIP, "wb")
- f.write(stuff)
- f.write(data)
- f.close()
+ with open(TEMP_ZIP, "rb") as f:
+ data = f.read()
+ with open(TEMP_ZIP, "wb") as f:
+ f.write(stuff)
+ f.write(data)
sys.path.insert(0, TEMP_ZIP)
@@ -155,18 +149,16 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
def testBadMagic(self):
# make pyc magic word invalid, forcing loading from .py
- m0 = ord(test_pyc[0])
- m0 ^= 0x04 # flip an arbitrary bit
- badmagic_pyc = chr(m0) + test_pyc[1:]
+ badmagic_pyc = bytearray(test_pyc)
+ badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit
files = {TESTMOD + ".py": (NOW, test_src),
TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
self.doTest(".py", files, TESTMOD)
def testBadMagic2(self):
# make pyc magic word invalid, causing an ImportError
- m0 = ord(test_pyc[0])
- m0 ^= 0x04 # flip an arbitrary bit
- badmagic_pyc = chr(m0) + test_pyc[1:]
+ badmagic_pyc = bytearray(test_pyc)
+ badmagic_pyc[0] ^= 0x04 # flip an arbitrary bit
files = {TESTMOD + pyc_ext: (NOW, badmagic_pyc)}
try:
self.doTest(".py", files, TESTMOD)
@@ -176,10 +168,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
self.fail("expected ImportError; import from bad pyc")
def testBadMTime(self):
- t3 = ord(test_pyc[7])
- t3 ^= 0x02 # flip the second bit -- not the first as that one
- # isn't stored in the .py's mtime in the zip archive.
- badtime_pyc = test_pyc[:7] + chr(t3) + test_pyc[8:]
+ badtime_pyc = bytearray(test_pyc)
+ # flip the second bit -- not the first as that one isn't stored in the
+ # .py's mtime in the zip archive.
+ badtime_pyc[7] ^= 0x02
files = {TESTMOD + ".py": (NOW, test_src),
TESTMOD + pyc_ext: (NOW, badtime_pyc)}
self.doTest(".py", files, TESTMOD)
@@ -230,7 +222,8 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
self.assertEqual(zi.get_source(TESTPACK), None)
self.assertEqual(zi.get_source(mod_path), None)
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
- # To pass in the module name instead of the path, we must use the right importer
+ # To pass in the module name instead of the path, we must use the
+ # right importer
loader = mod.__loader__
self.assertEqual(loader.get_source(mod_name), None)
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
@@ -264,8 +257,10 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
mod = zi.load_module(TESTPACK2)
self.assertEqual(zi.get_filename(TESTPACK2), mod.__file__)
- self.assertEqual(zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
- self.assertEqual(zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
+ self.assertEqual(
+ zi.is_package(TESTPACK2 + os.sep + '__init__'), False)
+ self.assertEqual(
+ zi.is_package(TESTPACK2 + os.sep + TESTMOD), False)
mod_path = TESTPACK2 + os.sep + TESTMOD
mod_name = module_path_to_dotted_name(mod_path)
@@ -274,7 +269,8 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
self.assertEqual(zi.get_source(TESTPACK2), None)
self.assertEqual(zi.get_source(mod_path), None)
self.assertEqual(zi.get_filename(mod_path), mod.__file__)
- # To pass in the module name instead of the path, we must use the right importer
+ # To pass in the module name instead of the path, we must use the
+ # right importer
loader = mod.__loader__
self.assertEqual(loader.get_source(mod_name), None)
self.assertEqual(loader.get_filename(mod_name), mod.__file__)
@@ -287,7 +283,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
z.compression = self.compression
try:
name = "testdata.dat"
- data = "".join([chr(x) for x in range(256)]) * 500
+ data = bytes(x for x in range(256))
z.writestr(name, data)
z.close()
zi = zipimport.zipimporter(TEMP_ZIP)
@@ -301,8 +297,8 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
src = """if 1: # indent hack
def get_file():
return __file__
- if __loader__.get_data("some.data") != "some data":
- raise AssertionError, "bad data"\n"""
+ if __loader__.get_data("some.data") != b"some data":
+ raise AssertionError("bad data")\n"""
pyc = make_pyc(compile(src, "<???>", "exec"), NOW)
files = {TESTMOD + pyc_ext: (NOW, pyc),
"some.data": (NOW, "some data")}
@@ -313,7 +309,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
# stuff at the beginning of the file
files = {TESTMOD + ".py": (NOW, test_src)}
self.doTest(".py", files, TESTMOD,
- stuff="Some Stuff"*31)
+ stuff=b"Some Stuff"*31)
def assertModuleSource(self, module):
self.assertEqual(inspect.getsource(module), test_src)
@@ -371,7 +367,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
f,lno,n,line = extract_stack(tb.tb_frame, 1)[0]
self.assertEqual(line, raise_src.strip())
- s = StringIO.StringIO()
+ s = io.StringIO()
print_tb(tb, 1, s)
self.assertTrue(s.getvalue().endswith(raise_src))
else:
@@ -381,6 +377,20 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase):
files = {TESTMOD + ".py": (NOW, raise_src)}
self.doTest(None, files, TESTMOD, call=self.doTraceback)
+ @unittest.skipIf(support.TESTFN_UNENCODABLE is None,
+ "need an unencodable filename")
+ def testUnencodable(self):
+ filename = support.TESTFN_UNENCODABLE + ".zip"
+ z = ZipFile(filename, "w")
+ zinfo = ZipInfo(TESTMOD + ".py", time.localtime(NOW))
+ zinfo.compress_type = self.compression
+ z.writestr(zinfo, test_src)
+ z.close()
+ try:
+ zipimport.zipimporter(filename)
+ finally:
+ os.remove(filename)
+
@unittest.skipUnless(zlib, "requires zlib")
class CompressedZipImportTestCase(UncompressedZipImportTestCase):
@@ -406,12 +416,12 @@ class BadFileZipImportTestCase(unittest.TestCase):
self.assertZipFailure('A' * 33000)
def testEmptyFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
open(TESTMOD, 'w+').close()
self.assertZipFailure(TESTMOD)
def testFileUnreadable(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fd = os.open(TESTMOD, os.O_CREAT, 000)
try:
os.close(fd)
@@ -419,11 +429,11 @@ class BadFileZipImportTestCase(unittest.TestCase):
finally:
# If we leave "the read-only bit" set on Windows, nothing can
# delete TESTMOD, and later tests suffer bogus failures.
- os.chmod(TESTMOD, 0666)
- test_support.unlink(TESTMOD)
+ os.chmod(TESTMOD, 0o666)
+ support.unlink(TESTMOD)
def testNotZipFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fp = open(TESTMOD, 'w+')
fp.write('a' * 22)
fp.close()
@@ -431,7 +441,7 @@ class BadFileZipImportTestCase(unittest.TestCase):
# XXX: disabled until this works on Big-endian machines
def _testBogusZipFile(self):
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
fp = open(TESTMOD, 'w+')
fp.write(struct.pack('=I', 0x06054B50))
fp.write('a' * 18)
@@ -460,13 +470,13 @@ class BadFileZipImportTestCase(unittest.TestCase):
def test_main():
try:
- test_support.run_unittest(
+ support.run_unittest(
UncompressedZipImportTestCase,
CompressedZipImportTestCase,
BadFileZipImportTestCase,
)
finally:
- test_support.unlink(TESTMOD)
+ support.unlink(TESTMOD)
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_zipimport_support.py b/Lib/test/test_zipimport_support.py
index 1b617abcb99..060108f2d09 100644
--- a/Lib/test/test_zipimport_support.py
+++ b/Lib/test/test_zipimport_support.py
@@ -2,7 +2,7 @@
# for working with modules located inside zipfiles
# The tests are centralised in this fashion to make it easy to drop them
# if a platform doesn't support zipimport
-import test.test_support
+import test.support
import os
import os.path
import sys
@@ -13,11 +13,11 @@ import doctest
import inspect
import linecache
import pdb
-import warnings
-from test.script_helper import (spawn_python, kill_python, run_python,
+import unittest
+from test.script_helper import (spawn_python, kill_python, assert_python_ok,
temp_dir, make_script, make_zip_script)
-verbose = test.test_support.verbose
+verbose = test.support.verbose
# Library modules covered by this test set
# pdb (Issue 4201)
@@ -31,47 +31,50 @@ verbose = test.test_support.verbose
# Retrieve some helpers from other test cases
from test import (test_doctest, sample_doctest, sample_doctest_no_doctests,
sample_doctest_no_docstrings)
-from test.test_importhooks import ImportHooksBaseTestCase
def _run_object_doctest(obj, module):
- # Direct doctest output (normally just errors) to real stdout; doctest
- # output shouldn't be compared by regrtest.
- save_stdout = sys.stdout
- sys.stdout = test.test_support.get_original_stdout()
+ finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
+ runner = doctest.DocTestRunner(verbose=verbose)
+ # Use the object's fully qualified name if it has one
+ # Otherwise, use the module's name
try:
- finder = doctest.DocTestFinder(verbose=verbose, recurse=False)
- runner = doctest.DocTestRunner(verbose=verbose)
- # Use the object's fully qualified name if it has one
- # Otherwise, use the module's name
- try:
- name = "%s.%s" % (obj.__module__, obj.__name__)
- except AttributeError:
- name = module.__name__
- for example in finder.find(obj, name, module):
- runner.run(example)
- f, t = runner.failures, runner.tries
- if f:
- raise test.test_support.TestFailed("%d of %d doctests failed" % (f, t))
- finally:
- sys.stdout = save_stdout
+ name = "%s.%s" % (obj.__module__, obj.__name__)
+ except AttributeError:
+ name = module.__name__
+ for example in finder.find(obj, name, module):
+ runner.run(example)
+ f, t = runner.failures, runner.tries
+ if f:
+ raise test.support.TestFailed("%d of %d doctests failed" % (f, t))
if verbose:
- print 'doctest (%s) ... %d tests with zero failures' % (module.__name__, t)
+ print ('doctest (%s) ... %d tests with zero failures' % (module.__name__, t))
return f, t
-class ZipSupportTests(ImportHooksBaseTestCase):
- # We use the ImportHooksBaseTestCase to restore
+class ZipSupportTests(unittest.TestCase):
+ # This used to use the ImportHooksBaseTestCase to restore
# the state of the import related information
- # in the sys module after each test
+ # in the sys module after each test. However, that restores
+ # *too much* information and breaks for the invocation of
+ # of test_doctest. So we do our own thing and leave
+ # sys.modules alone.
# We also clear the linecache and zipimport cache
# just to avoid any bogus errors due to name reuse in the tests
def setUp(self):
linecache.clearcache()
zipimport._zip_directory_cache.clear()
- ImportHooksBaseTestCase.setUp(self)
+ self.path = sys.path[:]
+ self.meta_path = sys.meta_path[:]
+ self.path_hooks = sys.path_hooks[:]
+ sys.path_importer_cache.clear()
+ def tearDown(self):
+ sys.path[:] = self.path
+ sys.meta_path[:] = self.meta_path
+ sys.path_hooks[:] = self.path_hooks
+ sys.path_importer_cache.clear()
def test_inspect_getsource_issue4223(self):
test_src = "def foo(): pass\n"
@@ -84,7 +87,10 @@ class ZipSupportTests(ImportHooksBaseTestCase):
os.remove(init_name)
sys.path.insert(0, zip_name)
import zip_pkg
- self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
+ try:
+ self.assertEqual(inspect.getsource(zip_pkg.foo), test_src)
+ finally:
+ del sys.modules["zip_pkg"]
def test_doctest_issue4197(self):
# To avoid having to keep two copies of the doctest module's
@@ -123,73 +129,62 @@ class ZipSupportTests(ImportHooksBaseTestCase):
z.close()
if verbose:
zip_file = zipfile.ZipFile(zip_name, 'r')
- print 'Contents of %r:' % zip_name
+ print ('Contents of %r:' % zip_name)
zip_file.printdir()
zip_file.close()
os.remove(script_name)
sys.path.insert(0, zip_name)
import test_zipped_doctest
- # Some of the doc tests depend on the colocated text files
- # which aren't available to the zipped version (the doctest
- # module currently requires real filenames for non-embedded
- # tests). So we're forced to be selective about which tests
- # to run.
- # doctest could really use some APIs which take a text
- # string or a file object instead of a filename...
- known_good_tests = [
- test_zipped_doctest.SampleClass,
- test_zipped_doctest.SampleClass.NestedClass,
- test_zipped_doctest.SampleClass.NestedClass.__init__,
- test_zipped_doctest.SampleClass.__init__,
- test_zipped_doctest.SampleClass.a_classmethod,
- test_zipped_doctest.SampleClass.a_property,
- test_zipped_doctest.SampleClass.a_staticmethod,
- test_zipped_doctest.SampleClass.double,
- test_zipped_doctest.SampleClass.get,
- test_zipped_doctest.SampleNewStyleClass,
- test_zipped_doctest.SampleNewStyleClass.__init__,
- test_zipped_doctest.SampleNewStyleClass.double,
- test_zipped_doctest.SampleNewStyleClass.get,
- test_zipped_doctest.old_test1,
- test_zipped_doctest.old_test2,
- test_zipped_doctest.old_test3,
- test_zipped_doctest.old_test4,
- test_zipped_doctest.sample_func,
- test_zipped_doctest.test_DocTest,
- test_zipped_doctest.test_DocTestParser,
- test_zipped_doctest.test_DocTestRunner.basics,
- test_zipped_doctest.test_DocTestRunner.exceptions,
- test_zipped_doctest.test_DocTestRunner.option_directives,
- test_zipped_doctest.test_DocTestRunner.optionflags,
- test_zipped_doctest.test_DocTestRunner.verbose_flag,
- test_zipped_doctest.test_Example,
- test_zipped_doctest.test_debug,
- test_zipped_doctest.test_pdb_set_trace,
- test_zipped_doctest.test_pdb_set_trace_nested,
- test_zipped_doctest.test_testsource,
- test_zipped_doctest.test_trailing_space_in_test,
- test_zipped_doctest.test_DocTestSuite,
- test_zipped_doctest.test_DocTestFinder,
- ]
- # These remaining tests are the ones which need access
- # to the data files, so we don't run them
- fail_due_to_missing_data_files = [
- test_zipped_doctest.test_DocFileSuite,
- test_zipped_doctest.test_testfile,
- test_zipped_doctest.test_unittest_reportflags,
- ]
- # Needed for test_DocTestParser and test_debug
- deprecations = []
- if __debug__:
- # Ignore all warnings about the use of class Tester in this module.
- deprecations.append(("class Tester is deprecated", DeprecationWarning))
- if sys.py3kwarning:
- deprecations += [
- ("backquote not supported", SyntaxWarning),
- ("execfile.. not supported", DeprecationWarning)]
- with test.test_support.check_warnings(*deprecations):
+ try:
+ # Some of the doc tests depend on the colocated text files
+ # which aren't available to the zipped version (the doctest
+ # module currently requires real filenames for non-embedded
+ # tests). So we're forced to be selective about which tests
+ # to run.
+ # doctest could really use some APIs which take a text
+ # string or a file object instead of a filename...
+ known_good_tests = [
+ test_zipped_doctest.SampleClass,
+ test_zipped_doctest.SampleClass.NestedClass,
+ test_zipped_doctest.SampleClass.NestedClass.__init__,
+ test_zipped_doctest.SampleClass.__init__,
+ test_zipped_doctest.SampleClass.a_classmethod,
+ test_zipped_doctest.SampleClass.a_property,
+ test_zipped_doctest.SampleClass.a_staticmethod,
+ test_zipped_doctest.SampleClass.double,
+ test_zipped_doctest.SampleClass.get,
+ test_zipped_doctest.SampleNewStyleClass,
+ test_zipped_doctest.SampleNewStyleClass.__init__,
+ test_zipped_doctest.SampleNewStyleClass.double,
+ test_zipped_doctest.SampleNewStyleClass.get,
+ test_zipped_doctest.sample_func,
+ test_zipped_doctest.test_DocTest,
+ test_zipped_doctest.test_DocTestParser,
+ test_zipped_doctest.test_DocTestRunner.basics,
+ test_zipped_doctest.test_DocTestRunner.exceptions,
+ test_zipped_doctest.test_DocTestRunner.option_directives,
+ test_zipped_doctest.test_DocTestRunner.optionflags,
+ test_zipped_doctest.test_DocTestRunner.verbose_flag,
+ test_zipped_doctest.test_Example,
+ test_zipped_doctest.test_debug,
+ test_zipped_doctest.test_pdb_set_trace,
+ test_zipped_doctest.test_pdb_set_trace_nested,
+ test_zipped_doctest.test_testsource,
+ test_zipped_doctest.test_trailing_space_in_test,
+ test_zipped_doctest.test_DocTestSuite,
+ test_zipped_doctest.test_DocTestFinder,
+ ]
+ # These remaining tests are the ones which need access
+ # to the data files, so we don't run them
+ fail_due_to_missing_data_files = [
+ test_zipped_doctest.test_DocFileSuite,
+ test_zipped_doctest.test_testfile,
+ test_zipped_doctest.test_unittest_reportflags,
+ ]
for obj in known_good_tests:
_run_object_doctest(obj, test_zipped_doctest)
+ finally:
+ del sys.modules["test_zipped_doctest"]
def test_doctest_main_issue4197(self):
test_src = textwrap.dedent("""\
@@ -203,22 +198,22 @@ class ZipSupportTests(ImportHooksBaseTestCase):
pattern = 'File "%s", line 2, in %s'
with temp_dir() as d:
script_name = make_script(d, 'script', test_src)
- exit_code, data = run_python(script_name)
+ rc, out, err = assert_python_ok(script_name)
expected = pattern % (script_name, "__main__.Test")
if verbose:
- print "Expected line", expected
- print "Got stdout:"
- print data
- self.assertIn(expected, data)
+ print ("Expected line", expected)
+ print ("Got stdout:")
+ print (ascii(out))
+ self.assertIn(expected.encode('utf-8'), out)
zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
- exit_code, data = run_python(zip_name)
+ rc, out, err = assert_python_ok(zip_name)
expected = pattern % (run_name, "__main__.Test")
if verbose:
- print "Expected line", expected
- print "Got stdout:"
- print data
- self.assertIn(expected, data)
+ print ("Expected line", expected)
+ print ("Got stdout:")
+ print (ascii(out))
+ self.assertIn(expected.encode('utf-8'), out)
def test_pdb_issue4201(self):
test_src = textwrap.dedent("""\
@@ -226,25 +221,25 @@ class ZipSupportTests(ImportHooksBaseTestCase):
pass
import pdb
- pdb.runcall(f)
+ pdb.Pdb(nosigint=True).runcall(f)
""")
with temp_dir() as d:
script_name = make_script(d, 'script', test_src)
p = spawn_python(script_name)
- p.stdin.write('l\n')
+ p.stdin.write(b'l\n')
data = kill_python(p)
- self.assertIn(script_name, data)
+ self.assertIn(script_name.encode('utf-8'), data)
zip_name, run_name = make_zip_script(d, "test_zip",
script_name, '__main__.py')
p = spawn_python(zip_name)
- p.stdin.write('l\n')
+ p.stdin.write(b'l\n')
data = kill_python(p)
- self.assertIn(run_name, data)
+ self.assertIn(run_name.encode('utf-8'), data)
def test_main():
- test.test_support.run_unittest(ZipSupportTests)
- test.test_support.reap_children()
+ test.support.run_unittest(ZipSupportTests)
+ test.support.reap_children()
if __name__ == '__main__':
test_main()
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py
index f3dffd6f71d..4661c1d6135 100644
--- a/Lib/test/test_zlib.py
+++ b/Lib/test/test_zlib.py
@@ -1,75 +1,76 @@
import unittest
-from test.test_support import TESTFN, run_unittest, import_module, unlink, requires
+from test import support
import binascii
import random
-from test.test_support import precisionbigmemtest, _1G, _4G
import sys
+from test.support import bigmemtest, _1G, _4G
+
+zlib = support.import_module('zlib')
try:
import mmap
except ImportError:
mmap = None
-zlib = import_module('zlib')
-
class ChecksumTestCase(unittest.TestCase):
# checksum test cases
def test_crc32start(self):
- self.assertEqual(zlib.crc32(""), zlib.crc32("", 0))
- self.assertTrue(zlib.crc32("abc", 0xffffffff))
+ self.assertEqual(zlib.crc32(b""), zlib.crc32(b"", 0))
+ self.assertTrue(zlib.crc32(b"abc", 0xffffffff))
def test_crc32empty(self):
- self.assertEqual(zlib.crc32("", 0), 0)
- self.assertEqual(zlib.crc32("", 1), 1)
- self.assertEqual(zlib.crc32("", 432), 432)
+ self.assertEqual(zlib.crc32(b"", 0), 0)
+ self.assertEqual(zlib.crc32(b"", 1), 1)
+ self.assertEqual(zlib.crc32(b"", 432), 432)
def test_adler32start(self):
- self.assertEqual(zlib.adler32(""), zlib.adler32("", 1))
- self.assertTrue(zlib.adler32("abc", 0xffffffff))
+ self.assertEqual(zlib.adler32(b""), zlib.adler32(b"", 1))
+ self.assertTrue(zlib.adler32(b"abc", 0xffffffff))
def test_adler32empty(self):
- self.assertEqual(zlib.adler32("", 0), 0)
- self.assertEqual(zlib.adler32("", 1), 1)
- self.assertEqual(zlib.adler32("", 432), 432)
+ self.assertEqual(zlib.adler32(b"", 0), 0)
+ self.assertEqual(zlib.adler32(b"", 1), 1)
+ self.assertEqual(zlib.adler32(b"", 432), 432)
def assertEqual32(self, seen, expected):
# 32-bit values masked -- checksums on 32- vs 64- bit machines
# This is important if bit 31 (0x08000000L) is set.
- self.assertEqual(seen & 0x0FFFFFFFFL, expected & 0x0FFFFFFFFL)
+ self.assertEqual(seen & 0x0FFFFFFFF, expected & 0x0FFFFFFFF)
def test_penguins(self):
- self.assertEqual32(zlib.crc32("penguin", 0), 0x0e5c1a120L)
- self.assertEqual32(zlib.crc32("penguin", 1), 0x43b6aa94)
- self.assertEqual32(zlib.adler32("penguin", 0), 0x0bcf02f6)
- self.assertEqual32(zlib.adler32("penguin", 1), 0x0bd602f7)
+ self.assertEqual32(zlib.crc32(b"penguin", 0), 0x0e5c1a120)
+ self.assertEqual32(zlib.crc32(b"penguin", 1), 0x43b6aa94)
+ self.assertEqual32(zlib.adler32(b"penguin", 0), 0x0bcf02f6)
+ self.assertEqual32(zlib.adler32(b"penguin", 1), 0x0bd602f7)
- self.assertEqual(zlib.crc32("penguin"), zlib.crc32("penguin", 0))
- self.assertEqual(zlib.adler32("penguin"),zlib.adler32("penguin",1))
+ self.assertEqual(zlib.crc32(b"penguin"), zlib.crc32(b"penguin", 0))
+ self.assertEqual(zlib.adler32(b"penguin"),zlib.adler32(b"penguin",1))
- def test_abcdefghijklmnop(self):
- """test issue1202 compliance: signed crc32, adler32 in 2.x"""
- foo = 'abcdefghijklmnop'
+ def test_crc32_adler32_unsigned(self):
+ foo = b'abcdefghijklmnop'
# explicitly test signed behavior
- self.assertEqual(zlib.crc32(foo), -1808088941)
- self.assertEqual(zlib.crc32('spam'), 1138425661)
- self.assertEqual(zlib.adler32(foo+foo), -721416943)
- self.assertEqual(zlib.adler32('spam'), 72286642)
+ self.assertEqual(zlib.crc32(foo), 2486878355)
+ self.assertEqual(zlib.crc32(b'spam'), 1138425661)
+ self.assertEqual(zlib.adler32(foo+foo), 3573550353)
+ self.assertEqual(zlib.adler32(b'spam'), 72286642)
def test_same_as_binascii_crc32(self):
- foo = 'abcdefghijklmnop'
- self.assertEqual(binascii.crc32(foo), zlib.crc32(foo))
- self.assertEqual(binascii.crc32('spam'), zlib.crc32('spam'))
+ foo = b'abcdefghijklmnop'
+ crc = 2486878355
+ self.assertEqual(binascii.crc32(foo), crc)
+ self.assertEqual(zlib.crc32(foo), crc)
+ self.assertEqual(binascii.crc32(b'spam'), zlib.crc32(b'spam'))
+
- def test_negative_crc_iv_input(self):
- # The range of valid input values for the crc state should be
- # -2**31 through 2**32-1 to allow inputs artifically constrained
- # to a signed 32-bit integer.
- self.assertEqual(zlib.crc32('ham', -1), zlib.crc32('ham', 0xffffffffL))
- self.assertEqual(zlib.crc32('spam', -3141593),
- zlib.crc32('spam', 0xffd01027L))
- self.assertEqual(zlib.crc32('spam', -(2**31)),
- zlib.crc32('spam', (2**31)))
+# Issue #10276 - check that inputs >=4GB are handled correctly.
+class ChecksumBigBufferTestCase(unittest.TestCase):
+
+ @bigmemtest(size=_4G + 4, memuse=1, dry_run=False)
+ def test_big_buffer(self, size):
+ data = b"nyan" * (_1G + 1)
+ self.assertEqual(zlib.crc32(data), 1044521549)
+ self.assertEqual(zlib.adler32(data), 2256789997)
class ExceptionTestCase(unittest.TestCase):
@@ -78,7 +79,18 @@ class ExceptionTestCase(unittest.TestCase):
# specifying compression level out of range causes an error
# (but -1 is Z_DEFAULT_COMPRESSION and apparently the zlib
# accepts 0 too)
- self.assertRaises(zlib.error, zlib.compress, 'ERROR', 10)
+ self.assertRaises(zlib.error, zlib.compress, b'ERROR', 10)
+
+ def test_badargs(self):
+ self.assertRaises(TypeError, zlib.adler32)
+ self.assertRaises(TypeError, zlib.crc32)
+ self.assertRaises(TypeError, zlib.compress)
+ self.assertRaises(TypeError, zlib.decompress)
+ for arg in (42, None, '', 'abc', (), []):
+ self.assertRaises(TypeError, zlib.adler32, arg)
+ self.assertRaises(TypeError, zlib.crc32, arg)
+ self.assertRaises(TypeError, zlib.compress, arg)
+ self.assertRaises(TypeError, zlib.decompress, arg)
def test_badcompressobj(self):
# verify failure on building compress object with bad params
@@ -104,7 +116,7 @@ class BaseCompressTestCase(object):
# Generate 10MB worth of random, and expand it by repeating it.
# The assumption is that zlib's memory is not big enough to exploit
# such spread out redundancy.
- data = ''.join([binascii.a2b_hex(fmt % random.getrandbits(8 * _1M))
+ data = b''.join([random.getrandbits(8 * _1M).to_bytes(_1M, 'little')
for i in range(10)])
data = data * (size // len(data) + 1)
try:
@@ -114,7 +126,7 @@ class BaseCompressTestCase(object):
data = None
def check_big_decompress_buffer(self, size, decompress_func):
- data = 'x' * size
+ data = b'x' * size
try:
compressed = zlib.compress(data, 1)
finally:
@@ -124,7 +136,7 @@ class BaseCompressTestCase(object):
# Sanity check
try:
self.assertEqual(len(data), size)
- self.assertEqual(len(data.strip('x')), 0)
+ self.assertEqual(len(data.strip(b'x')), 0)
finally:
data = None
@@ -139,40 +151,60 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
# compress more data
data = HAMLET_SCENE * 128
x = zlib.compress(data)
- self.assertEqual(zlib.decompress(x), data)
+ self.assertEqual(zlib.compress(bytearray(data)), x)
+ for ob in x, bytearray(x):
+ self.assertEqual(zlib.decompress(ob), data)
def test_incomplete_stream(self):
# An useful error message is given
x = zlib.compress(HAMLET_SCENE)
- self.assertRaisesRegexp(zlib.error,
+ self.assertRaisesRegex(zlib.error,
"Error -5 while decompressing data: incomplete or truncated stream",
zlib.decompress, x[:-1])
# Memory use of the following functions takes into account overallocation
- @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=3)
+ @bigmemtest(size=_1G + 1024 * 1024, memuse=3)
def test_big_compress_buffer(self, size):
compress = lambda s: zlib.compress(s, 1)
self.check_big_compress_buffer(size, compress)
- @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=2)
+ @bigmemtest(size=_1G + 1024 * 1024, memuse=2)
def test_big_decompress_buffer(self, size):
self.check_big_decompress_buffer(size, zlib.decompress)
+ @bigmemtest(size=_4G + 100, memuse=1)
+ def test_length_overflow(self, size):
+ if size < _4G + 100:
+ self.skipTest("not enough free memory, need at least 4 GB")
+ data = b'x' * size
+ try:
+ self.assertRaises(OverflowError, zlib.compress, data, 1)
+ self.assertRaises(OverflowError, zlib.decompress, data)
+ finally:
+ data = None
+
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Test compression object
def test_pair(self):
# straightforward compress/decompress objects
- data = HAMLET_SCENE * 128
- co = zlib.compressobj()
- x1 = co.compress(data)
- x2 = co.flush()
- self.assertRaises(zlib.error, co.flush) # second flush should not work
- dco = zlib.decompressobj()
- y1 = dco.decompress(x1 + x2)
- y2 = dco.flush()
- self.assertEqual(data, y1 + y2)
+ datasrc = HAMLET_SCENE * 128
+ datazip = zlib.compress(datasrc)
+ # should compress both bytes and bytearray data
+ for data in (datasrc, bytearray(datasrc)):
+ co = zlib.compressobj()
+ x1 = co.compress(data)
+ x2 = co.flush()
+ self.assertRaises(zlib.error, co.flush) # second flush should not work
+ self.assertEqual(x1 + x2, datazip)
+ for v1, v2 in ((x1, x2), (bytearray(x1), bytearray(x2))):
+ dco = zlib.decompressobj()
+ y1 = dco.decompress(v1 + v2)
+ y2 = dco.flush()
+ self.assertEqual(data, y1 + y2)
+ self.assertIsInstance(dco.unconsumed_tail, bytes)
+ self.assertIsInstance(dco.unused_data, bytes)
def test_compressoptions(self):
# specify lots of options to compressobj()
@@ -197,10 +229,10 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
for i in range(0, len(data), 256):
bufs.append(co.compress(data[i:i+256]))
bufs.append(co.flush())
- combuf = ''.join(bufs)
+ combuf = b''.join(bufs)
dco = zlib.decompressobj()
- y1 = dco.decompress(''.join(bufs))
+ y1 = dco.decompress(b''.join(bufs))
y2 = dco.flush()
self.assertEqual(data, y1 + y2)
@@ -213,30 +245,36 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
for i in range(0, len(data), cx):
bufs.append(co.compress(data[i:i+cx]))
bufs.append(co.flush())
- combuf = ''.join(bufs)
+ combuf = b''.join(bufs)
+
+ decombuf = zlib.decompress(combuf)
+ # Test type of return value
+ self.assertIsInstance(decombuf, bytes)
- self.assertEqual(data, zlib.decompress(combuf))
+ self.assertEqual(data, decombuf)
dco = zlib.decompressobj()
bufs = []
for i in range(0, len(combuf), dcx):
bufs.append(dco.decompress(combuf[i:i+dcx]))
- self.assertEqual('', dco.unconsumed_tail, ########
- "(A) uct should be '': not %d long" %
+ self.assertEqual(b'', dco.unconsumed_tail, ########
+ "(A) uct should be b'': not %d long" %
len(dco.unconsumed_tail))
+ self.assertEqual(b'', dco.unused_data)
if flush:
bufs.append(dco.flush())
else:
while True:
- chunk = dco.decompress('')
+ chunk = dco.decompress(b'')
if chunk:
bufs.append(chunk)
else:
break
- self.assertEqual('', dco.unconsumed_tail, ########
- "(B) uct should be '': not %d long" %
+ self.assertEqual(b'', dco.unconsumed_tail, ########
+ "(B) uct should be b'': not %d long" %
len(dco.unconsumed_tail))
- self.assertEqual(data, ''.join(bufs))
+ self.assertEqual(b'', dco.unused_data)
+ self.assertEqual(data, b''.join(bufs))
# Failure means: "decompressobj with init options failed"
def test_decompincflush(self):
@@ -252,7 +290,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
for i in range(0, len(data), cx):
bufs.append(co.compress(data[i:i+cx]))
bufs.append(co.flush())
- combuf = ''.join(bufs)
+ combuf = b''.join(bufs)
self.assertEqual(data, zlib.decompress(combuf),
'compressed data failure')
@@ -267,7 +305,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
bufs.append(chunk)
cb = dco.unconsumed_tail
bufs.append(dco.flush())
- self.assertEqual(data, ''.join(bufs), 'Wrong data retrieved')
+ self.assertEqual(data, b''.join(bufs), 'Wrong data retrieved')
def test_decompressmaxlen(self, flush=False):
# Check a decompression object with max_length specified
@@ -277,7 +315,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
for i in range(0, len(data), 256):
bufs.append(co.compress(data[i:i+256]))
bufs.append(co.flush())
- combuf = ''.join(bufs)
+ combuf = b''.join(bufs)
self.assertEqual(data, zlib.decompress(combuf),
'compressed data failure')
@@ -295,11 +333,11 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
bufs.append(dco.flush())
else:
while chunk:
- chunk = dco.decompress('', max_length)
+ chunk = dco.decompress(b'', max_length)
self.assertFalse(len(chunk) > max_length,
'chunk too big (%d>%d)' % (len(chunk),max_length))
bufs.append(chunk)
- self.assertEqual(data, ''.join(bufs), 'Wrong data retrieved')
+ self.assertEqual(data, b''.join(bufs), 'Wrong data retrieved')
def test_decompressmaxlenflush(self):
self.test_decompressmaxlen(flush=True)
@@ -307,17 +345,17 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
def test_maxlenmisc(self):
# Misc tests of max_length
dco = zlib.decompressobj()
- self.assertRaises(ValueError, dco.decompress, "", -1)
- self.assertEqual('', dco.unconsumed_tail)
+ self.assertRaises(ValueError, dco.decompress, b"", -1)
+ self.assertEqual(b'', dco.unconsumed_tail)
def test_clear_unconsumed_tail(self):
# Issue #12050: calling decompress() without providing max_length
# should clear the unconsumed_tail attribute.
- cdata = "x\x9cKLJ\x06\x00\x02M\x01" # "abc"
+ cdata = b"x\x9cKLJ\x06\x00\x02M\x01" # "abc"
dco = zlib.decompressobj()
ddata = dco.decompress(cdata, 1)
ddata += dco.decompress(dco.unconsumed_tail)
- self.assertEqual(dco.unconsumed_tail, "")
+ self.assertEqual(dco.unconsumed_tail, b"")
def test_flushes(self):
# Test flush() with the various options, using all the
@@ -334,7 +372,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
b = obj.flush( sync )
c = obj.compress( data[3000:] )
d = obj.flush()
- self.assertEqual(zlib.decompress(''.join([a,b,c,d])),
+ self.assertEqual(zlib.decompress(b''.join([a,b,c,d])),
data, ("Decompress failed: flush "
"mode=%i, level=%i") % (sync, level))
del obj
@@ -381,26 +419,51 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
co = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
self.assertTrue(co.flush()) # Returns a zlib header
dco = zlib.decompressobj()
- self.assertEqual(dco.flush(), "") # Returns nothing
+ self.assertEqual(dco.flush(), b"") # Returns nothing
def test_decompress_incomplete_stream(self):
# This is 'foo', deflated
- x = 'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
+ x = b'x\x9cK\xcb\xcf\x07\x00\x02\x82\x01E'
# For the record
- self.assertEqual(zlib.decompress(x), 'foo')
+ self.assertEqual(zlib.decompress(x), b'foo')
self.assertRaises(zlib.error, zlib.decompress, x[:-5])
# Omitting the stream end works with decompressor objects
# (see issue #8672).
dco = zlib.decompressobj()
y = dco.decompress(x[:-5])
y += dco.flush()
- self.assertEqual(y, 'foo')
+ self.assertEqual(y, b'foo')
+
+ def test_decompress_unused_data(self):
+ # Repeated calls to decompress() after EOF should accumulate data in
+ # dco.unused_data, instead of just storing the arg to the last call.
+ source = b'abcdefghijklmnopqrstuvwxyz'
+ remainder = b'0123456789'
+ y = zlib.compress(source)
+ x = y + remainder
+ for maxlen in 0, 1000:
+ for step in 1, 2, len(y), len(x):
+ dco = zlib.decompressobj()
+ data = b''
+ for i in range(0, len(x), step):
+ if i < len(y):
+ self.assertEqual(dco.unused_data, b'')
+ if maxlen == 0:
+ data += dco.decompress(x[i : i + step])
+ self.assertEqual(dco.unconsumed_tail, b'')
+ else:
+ data += dco.decompress(
+ dco.unconsumed_tail + x[i : i + step], maxlen)
+ data += dco.flush()
+ self.assertEqual(data, source)
+ self.assertEqual(dco.unconsumed_tail, b'')
+ self.assertEqual(dco.unused_data, remainder)
def test_flush_with_freed_input(self):
# Issue #16411: decompressor accesses input to last decompress() call
# in flush(), even if this object has been freed in the meanwhile.
- input1 = 'abcdefghijklmnopqrstuvwxyz'
- input2 = 'QWERTYUIOPASDFGHJKLZXCVBNM'
+ input1 = b'abcdefghijklmnopqrstuvwxyz'
+ input2 = b'QWERTYUIOPASDFGHJKLZXCVBNM'
data = zlib.compress(input1)
dco = zlib.decompressobj()
dco.decompress(data, 1)
@@ -412,7 +475,7 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
def test_compresscopy(self):
# Test copying a compression object
data0 = HAMLET_SCENE
- data1 = HAMLET_SCENE.swapcase()
+ data1 = bytes(str(HAMLET_SCENE, "ascii").swapcase(), "ascii")
c0 = zlib.compressobj(zlib.Z_BEST_COMPRESSION)
bufs0 = []
bufs0.append(c0.compress(data0))
@@ -422,11 +485,11 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
bufs0.append(c0.compress(data0))
bufs0.append(c0.flush())
- s0 = ''.join(bufs0)
+ s0 = b''.join(bufs0)
bufs1.append(c1.compress(data1))
bufs1.append(c1.flush())
- s1 = ''.join(bufs1)
+ s1 = b''.join(bufs1)
self.assertEqual(zlib.decompress(s0),data0+data0)
self.assertEqual(zlib.decompress(s1),data0+data1)
@@ -438,36 +501,13 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
c.flush()
self.assertRaises(ValueError, c.copy)
- def test_decompress_unused_data(self):
- # Repeated calls to decompress() after EOF should accumulate data in
- # dco.unused_data, instead of just storing the arg to the last call.
- source = b'abcdefghijklmnopqrstuvwxyz'
- remainder = b'0123456789'
- y = zlib.compress(source)
- x = y + remainder
- for maxlen in 0, 1000:
- for step in 1, 2, len(y), len(x):
- dco = zlib.decompressobj()
- data = b''
- for i in range(0, len(x), step):
- if i < len(y):
- self.assertEqual(dco.unused_data, b'')
- if maxlen == 0:
- data += dco.decompress(x[i : i + step])
- self.assertEqual(dco.unconsumed_tail, b'')
- else:
- data += dco.decompress(
- dco.unconsumed_tail + x[i : i + step], maxlen)
- data += dco.flush()
- self.assertEqual(data, source)
- self.assertEqual(dco.unconsumed_tail, b'')
- self.assertEqual(dco.unused_data, remainder)
-
if hasattr(zlib.decompressobj(), "copy"):
def test_decompresscopy(self):
# Test copying a decompression object
data = HAMLET_SCENE
comp = zlib.compress(data)
+ # Test type of return value
+ self.assertIsInstance(comp, bytes)
d0 = zlib.decompressobj()
bufs0 = []
@@ -477,10 +517,10 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
bufs1 = bufs0[:]
bufs0.append(d0.decompress(comp[32:]))
- s0 = ''.join(bufs0)
+ s0 = b''.join(bufs0)
bufs1.append(d1.decompress(comp[32:]))
- s1 = ''.join(bufs1)
+ s1 = b''.join(bufs1)
self.assertEqual(s0,s1)
self.assertEqual(s0,data)
@@ -495,18 +535,31 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
# Memory use of the following functions takes into account overallocation
- @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=3)
+ @bigmemtest(size=_1G + 1024 * 1024, memuse=3)
def test_big_compress_buffer(self, size):
c = zlib.compressobj(1)
compress = lambda s: c.compress(s) + c.flush()
self.check_big_compress_buffer(size, compress)
- @precisionbigmemtest(size=_1G + 1024 * 1024, memuse=2)
+ @bigmemtest(size=_1G + 1024 * 1024, memuse=2)
def test_big_decompress_buffer(self, size):
d = zlib.decompressobj()
decompress = lambda s: d.decompress(s) + d.flush()
self.check_big_decompress_buffer(size, decompress)
+ @bigmemtest(size=_4G + 100, memuse=1)
+ def test_length_overflow(self, size):
+ if size < _4G + 100:
+ self.skipTest("not enough free memory, need at least 4 GB")
+ data = b'x' * size
+ c = zlib.compressobj(1)
+ d = zlib.decompressobj()
+ try:
+ self.assertRaises(OverflowError, c.compress, data)
+ self.assertRaises(OverflowError, d.decompress, data)
+ finally:
+ data = None
+
def genblock(seed, length, step=1024, generator=random):
"""length-byte stream of random data from a seed (in step-byte blocks)."""
@@ -515,11 +568,10 @@ def genblock(seed, length, step=1024, generator=random):
randint = generator.randint
if length < step or step < 2:
step = length
- blocks = []
+ blocks = bytes()
for i in range(0, length, step):
- blocks.append(''.join([chr(randint(0,255))
- for x in range(step)]))
- return ''.join(blocks)[:length]
+ blocks += bytes(randint(0, 255) for x in range(step))
+ return blocks
@@ -532,7 +584,7 @@ def choose_lines(source, number, seed=None, generator=random):
-HAMLET_SCENE = """
+HAMLET_SCENE = b"""
LAERTES
O, fear me not.
@@ -598,12 +650,14 @@ LAERTES
def test_main():
- run_unittest(
+ support.run_unittest(
ChecksumTestCase,
+ ChecksumBigBufferTestCase,
ExceptionTestCase,
CompressTestCase,
CompressObjectTestCase
)
if __name__ == "__main__":
- test_main()
+ unittest.main() # XXX
+ ###test_main()
diff --git a/Lib/test/testall.py b/Lib/test/testall.py
deleted file mode 100644
index 5b5cf01e81f..00000000000
--- a/Lib/test/testall.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# Backward compatibility -- you should use regrtest instead of this module.
-from warnings import warnpy3k
-warnpy3k("the test.testall module has been removed in Python 3.0",
- stacklevel=2)
-del warnpy3k
-
-
-import sys, regrtest
-sys.argv[1:] = ["-vv"]
-regrtest.main()
diff --git a/Lib/test/testcodec.py b/Lib/test/testcodec.py
index 5da754dc8af..77f408b2dcd 100644
--- a/Lib/test/testcodec.py
+++ b/Lib/test/testcodec.py
@@ -35,10 +35,10 @@ def getregentry():
decoding_map = codecs.make_identity_dict(range(256))
decoding_map.update({
- 0x78: u"abc", # 1-n decoding mapping
- "abc": 0x0078,# 1-n encoding mapping
+ 0x78: "abc", # 1-n decoding mapping
+ b"abc": 0x0078,# 1-n encoding mapping
0x01: None, # decoding mapping to <undefined>
- 0x79: u"", # decoding mapping to <remove character>
+ 0x79: "", # decoding mapping to <remove character>
})
### Encoding Map
diff --git a/Lib/test/testimg.uue b/Lib/test/testimg.uue
deleted file mode 100644
index c9b713e52ba..00000000000
--- a/Lib/test/testimg.uue
+++ /dev/null
@@ -1,1170 +0,0 @@
-begin 755 test.rawimg
-M___Y^/\A$Q3_*1LC_QL4'/\;%AS_%Q(6_QP7&?\B&AW_'A<7_QT5&/\7$A3_
-M&108_Q84%O\7%1?_$Q 6_Q<3'/\:$Q__'1<;_R$:&O\5$Q7_'!D8_SHW-O\\
-M.CW_141*_TE)3/]/3U+_'1DA_R,<)O\B'"3_249,_T=$2O]$0D7_.3<Z_T1"
-M1?].3$__44]2_QD2'/\;%![_*24M_U166_]55US_55=<_UQ>8_]<7F/_%1$9
-M_QH6'O\B(2C_65A>_U587?]87%[_65M>_Q@5&_\@'"3_%Q8<_U%34?]<6E7_
-M5U9/_U-14_\:%A__'AHB_TA&2/\]/CC_24I$_RDG*O\B'B;_)",I_UI;7/];
-M65;_7EA6_X%\?/^!?GW_7E]@_U!45O]45US_4U5:_U)46_].4%?_2TU4_T9(
-M3_]#14S_1$E/_TA)4/](1T[_1D=._TI/5?])2E'_2$=._T-%3/])2U+_2$E0
-M_T9'3O]#1$O_0D1,_T!"2O]#14S_1DE._T5(3?]$1TS_0$-(_T1'3/]!0TC_
-M0T)(_S\^1/]#0DC_04-(_SD\0?\[0$7_0#]%_SY 1?\Z/$'_.CQ!_SH\0?\[
-M.S[_/SU _Q43%O\E(R;_%Q48_S0R-?\7%1C_)R4H_Q02%?\2$!/_%!(5_Q,1
-M%/\5$Q;_^>[U_SXT/O\F'"O_'QDA_QD4&/\6$17_%1 4_Q<2%O\:%1G_&!,7
-M_Q40%/\8$Q?_%Q03_Q<3%?\:%1O_'1<?_QL4'O\L)RW_(1T?_QP7&_\5$Q;_
-M'AP?_QT;'O\<&AW_03]"_TE'2O\:%A[_'AHC_QT8'/\8%!;_'!@:_Q\;'?\@
-M&Q__(ATA_R0?(_\H(R?_&1,;_Q@4'/\='R3_2T]1_TU/4O]04%/_45%4_U14
-M5_\7$QO_&14=_R\M,/]I:6;_5597_U%34?]14$__'!<=_R,<*/\8%1O_6%A5
-M_UA85?];6%/_5%!2_QL7(/\;&B'_6%98_UM:4_];653_)2(A_R$=)?\<&1__
-M7UU@_T=%1_\M*RW_(B B_R@G)O]24TW_>7YX_Y&1CO]O:FS_5U=:_U)45_]1
-M4U;_4%)7_TY/5O])4%;_2$]5_T1(4/]%1E'_1DA0_T=)4/]&2$__1$9-_T%#
-M2O]$1DW_04-*_T!"2?] 0DG_04-*_T1&3?]!0TK_/D%&_T)%2O]!1$G_1$=,
-M_T%#2O]!0TK_/3]&_T!"2?] 0D?_/D!%_S]!1O\^0$7_.3M _ST_1/\\/D/_
-M.CQ!_ST[/O\W-3?_,C R_S N,/\M*2O_)B(D_Q82%/\7$Q7_%1 4_Q(-$?\7
-M$A;_%1 4_Q81%?__]?K_+R4N_T<^2_\A'"+_&A49_Q81%?\5$!3_&!,7_Q81
-M%?\6$17_%1 4_Q@3%_\7$1G_%Q(8_PT(#/]V<G3_241*_QD5%_\:&!/_&!44
-M_Q(0$_\5$Q;_%1,6_Q,1%/\3$13_#0L._QD5'?\=&2+_'1@<_Q@4%O\3#Q'_
-M%! 2_Q<2%O\6$17_&108_QP7&_\4$!C_%Q,;_QX;(?\=&Q[_(1\A_S$O,?\_
-M/3__3$I,_Q<3&_\9%1W_)2,F_U%13O]14U'_3U),_U)23_\=&!S_(QPF_QH7
-M'?]965;_5552_U933O]85%;_&Q<@_QD8'_]85U;_65I4_UA94O\E(R7_'!LA
-M_QL:(/]<6V'_75QB_V%@9O\7%AS_)"0G_U=86?]04$W_5U%/_UY65/]64E#_
-M>GUW_V!C7?]765?_5E=8_TQ15O]+3U?_2E!:_T=*5O].4%C_2DQ3_T=)4/]'
-M25#_14=._T9(3_]'25#_1$9-_SY 1_] 0DG_.SU$_T-%3/] 0TC_041)_TI-
-M4O\^04;_/T%(_S]!2/\^0$?_0D1+_SY 1?\^0$7_/T%&_SY 1?\Z.CW_,C(U
-M_RTM,/\G)RK_*RDK_R@F*/\J*"K_(R$C_R4A(_\I)2?_(AX@_RXJ+/\9%!C_
-M% \3_Q@3%_\3#A+_&!,7__KQ\?\@%Q[_&Q0<_QL6&O\8$Q?_%1 4_Q40%/\5
-M$!3_%1 4_Q40%/\4#Q/_%Q(6_Q<3%?\7$A;_$PX2_Q@3&?\<%1__&!,7_Q42
-M$?\4$!+_$0\2_Q(0$_\3$13_$Q$4_Q,1%/\4$A7_%A(:_QP8(?\;%AK_'!@:
-M_Q\;'?\;%QG_%Q(6_Q40%/\5$!3_% \3_Q,/%_\7$QO_'AD?_Q\9'?\=&1O_
-M(R ?_R<D(_\A'AW_%A(:_Q@4'/\@'B'_2TM(_TU/3/].4DK_3D](_QP8&O\>
-M%R'_&Q@>_U964_]:6E?_7%E4_UE55_\8%!W_&AD@_V!?9?]=7E__86)C_ST\
-M0_\6%Q[_&QTB_V%B:?]B8FO_86%L_Q<7(/\B(RK_3E!5_U-56O]74EC_)Q\C
-M_R4D(_];6UC_75Y8_VMJ:?^5DY7_A(""_UE65?]86%O_4U5:_U!26?].4%?_
-M2TU4_TE+4O]+353_1TE0_T)$2_]$1DW_1$9-_T-%3/]!0TK_04-*_SY!1O]
-M0TC_0$-(_T%$2?\\/D7_/3]&_ST_1O\^0$?_/3]$_SP^0_\]/T3_.#H__S(P
-M,_\J*"K_*RDK_R@F*/\H)BC_*2<I_R<E)_\D(B3_)R,E_R@D)O\I)2?_*24G
-M_R4@)/\8$Q?_%Q(6_Q@3%_\4#Q/_^_+R_R8;(/\;$AG_%Q,5_Q@3%_\5$!3_
-M%1 4_Q40%/\5$!3_%1 4_Q0/$_\7$A;_%Q,5_Q<3%?\5$!3_&!$;_S0J.?\:
-M$QO_%1 4_Q0/%?\1#Q+_$A 3_Q$/$O\/#1#_#0T0_Q 0$_\?'"+_&Q<?_Q81
-M%?\5$1/_$P\1_Q00$O\2#1'_$PX2_Q(-$?\3#A+_$1 7_Q<3&_\8$AK_&1$5
-M_QD4%O\M*"C_14$__STZ.?\6$AK_&!0=_RDF+/]245#_35%/_U%34/]24TW_
-M)R0C_R <)?\='"+_6UU;_V-B8?]=6UC_9V-E_QD5'O\:&"'_6EIC_V)C:O]H
-M:7#_1450_Q46'?\:'"'_7U]H_V1D;_]B8FW_$A(=_QL;)/]A8FG_7F!H_V%?
-M:/\?&R/_'!XC_SY /O\Z.#K_'AP?_R@E*_]:55#_8%M6_W9R</]D86#_5EA;
-M_U=97/]:7&'_45-8_TQ15_]*3E;_14E1_TA*4?]%1T[_149-_T-%3/]%1T[_
-M0D5*_SP_1/\]0$7_041)_SU 1?\^0$?_/#Y%_SP^1?\X.C__.CD__RPK,?\I
-M*"[_+BPN_RHH*O\J*"K_)R4G_RDG*?\E(R7_*"8H_R4C)?\F(B3_)R,E_R(>
-M(/\E(2/_)B$E_R,>(O\W,C;_)!\C_Q81%?_\\//_'A07_S$I+/\L)RG_'!<;
-M_Q0/$_\5$!3_% \3_Q40%/\5$!3_% \3_Q<2%O\3#QC_%Q(8_Q@3%_\8$1G_
-M$PP3_Q<1%?\5$!3_$1$4_Q(0$_\2$!/_$0\2_Q$/$O\0$!/_#0\2_Q43%O\@
-M&Q__%1,6_Q(0$_\1#Q+_$0\2_Q$/$O\0#A'_$0\2_Q .$?\1$A/_&!<>_Q@4
-M'/\A'1__$0\1_TI&1/]54$K_(R(A_Q,1&O\5$QS_+2PR_U-45?]-4%7_5EE>
-M_UY=8_\P+3/_'!@@_Q<8'_]>8VG_8F%H_V)A9_]C8FG_&!8?_Q<4(/]>7V;_
-M8&%H_V!A:/]45EO_&QHA_Q@7'O]E9&K_961J_U]>9/\9%R#_'!HC_TU-4/\Q
-M,S#_)R<J_QL:(?\9&![_04 __RTK+O\@'"3_)R0J_T ]./]"/D#_(1XD_Q\?
-M(O]D95__@H-]_Y:5E/]G96C_55E;_U587?].4%?_2DI3_TA'3O]&1T[_14=.
-M_T%&3/\^0TC_0$5*_SY#2/\]0D?_/D!#_SX^0?\T-#?_+R\R_RPJ+?\K*2S_
-M*B@K_RHH*_\K*2O_*"8H_RDG*?\H)BC_*2<J_R8D)_\E(R;_)2,F_R8D)O\D
-M(B3_)"(D_R0B)/\D(B3_)"(D_R(@(O\F)";_$@X0___V^?\@&!O_'AD;_QD5
-M%_\9%!C_%Q(6_QP7&_\9%!C_%A$5_Q81%?\5$!3_&!,7_Q<1%?\@&QO_%Q03
-M_Q<4&O\>("7_'B C_R@L+O\;'R'_$1$4_Q$1%/\0$!/_$! 3_Q(0$_\3#A+_
-M&A08_W!H;/\7$A;_$A 3_Q$/$O\1#Q+_$0\2_Q .$?\1#Q+_$ X1_QD9'/]/
-M2U/_-S(X_R,@&_\].S/_5U!$_UI00?]>5TO_&A4;_Q@4'/\X-CG_/#LZ_SY!
-M0O]14UC_45)9_RPM-/\?&R/_%Q@?_V%F;/]H9V[_;6QR_V]N=?\6%!W_&Q@D
-M_UU;9/]F9FG_9VAI_UM:8/\8%A__&AD@_V-C9O]H:FC_969G_Q85'/\4$QK_
-M5E=8_U]A7O]65EG_%A4<_QD8'O] /S[_)R4H_QH6'O\B'R7_9V-A_V%<8/\<
-M&"#_(2 F_T=%1_\>'![_*"8H_UY<7O]Z=7#_J:&=_W=R=/];6%[_5%5<_TY.
-M5_]$1D[_/4-+_S@[0/\Y/$'_+S(W_RDL,?\K*2S_+RHN_RTH+/\M*"S_*RDL
-M_R@H*_\F)BG_)B8I_R8F*?\E)2C_*"@K_R<G*O\G)RK_)"0G_R0D)_\E)2C_
-M*"8H_R<E)_\E(R7_)2,E_R4C)?\E(R7_*"8H_R(@(O\M*2O_^/#S_RDD)O\=
-M&1O_&QD;_WQW>_\6$17_&A49_QD4&/\8$Q?_&!,7_Q\:'O\F(27_2T5#_Y"+
-MA?^+B83_'Q\B_V)G;/]26%K_2DY0_S<W.O\K+3#_*"HM_R0F*?\:'!__%148
-M_Q04%_\9%!C_$PT1_Q(0$_\3$13_$0\2_Q$/$O\0#A'_$0\2_Q$/$O\0#A'_
-M$0X4_SXX0/\=%QO_)R,;_TI%.?]>4D/_;%E'_W5@5/\I(27_,BTS_T1 0O]"
-M0#W_55!*_U%,1O]'0D+_.C4Y_Q\;(_\7&!__4UA>_U-26?]/3E3_5U9=_Q@6
-M'_\[.$3_,R\X_UM96_];7%;_6%99_QH7(_\9&!__6UQ=_U]C6_]@8F#_&!<=
-M_QH9'_]?85__8&)?_UY>8?\8%Q[_%Q8<_T5$0_\V-#?_&!0<_QT:(/]K9F;_
-M;6AN_QD5'O\<&R+_;VQR_QT:(/\C(23_5U57_R8@)/\L)"C_4DU-_UM65O^
-M>WO_A8""_T1 0O\T,C3_)"0G_Q\>)/\;&B#_$A$7_R(B)?\H)BG_*RDL_S(P
-M,_\R-#?_-SD\_SD[/O\Z/#__.3M _S@Z/_\V.#W_-3<\_S(T-_\L+C'_*"HM
-M_R<I+/\J*"K_*"8H_R@F*/\H)BC_)R4G_R<E)_\F)";_*"8H_QD5%__\]/?_
-M)R(D_QD7&?\6%QC_DI"3_Q\:'O\8$Q?_&!,7_Q<2%O\4$A7_%1,6_QD4&/]$
-M/#C_EY&'_YF8D?_!Q,7_M+F^_Z^SM?^VM+?_P;F]_V5C9?]G:FO_76!A_S,V
-M-_\D*2G_(28F_R C)/\C)"7_(B B_QT;'O\8%AG_%A07_Q .$?\3#A+_$PX2
-M_Q(-$?\B'2'_/SD]_RPF)/]>5TO_:V%6_UU/0/]\9%7_?F19_RT>(O\H(RG_
-M-S,U_SX[-O]E6D__85=)_U=,1?\\-C3_&A8>_Q<8'_\\/T3_/3Q"_QX;(?\<
-M&R'_#PT6_R8B*_\M(B?_)2(=_UI<4_]3453_&Q@D_QD9(O]97%W_5UQ6_UI<
-M6?\9&1S_&1@>_UYB8/]O<6__9&1G_Q@7'O\<&R'_/T$__RDI+/\9%1W_'1DA
-M_S\]/_\=&B#_&14>_Q<6'?\Q,#;_&Q@>_QP:'?]J:6C_(A\K_R =*?]02T__
-M3$9$_RHB'O\H(!S_3TI%_VAE8/^)A8?_6%99_TE'2O\5%!K_24Q1_T9)3O\\
-M/T3_0$-(_SY!1O]"14K_14A-_T!#2/]!1$G_/T!'_SH[0O\\/43_.3M _SL]
-M0/\]/T+_+S$T_RLL+?\L*BS_*2<I_RDG*?\H)BC_*"8H_R@F*/\=&QW_%A(4
-M__;R\/\_.CK_+2LM_R<G*O^:F)O_&!,7_Q@3%_\9%!C_'!@:_Q43%?\:'1[_
-M&!89_Q\;&?^:E8__F92._];9VO_/T]7_T-#3_\W(RO_+O\#_8E97_T="0O]_
-M@7__8E]>_U-34/]"0C__,S,P_RXN*_\X.S7_-#8S_RLM*_\C(R;_'!D8_Q83
-M$O\1#!#_%1 6_R 9&?]%0SS_5E-(_VUC5?^ <F/_<V56_VY<3O]O6TW_74Y/
-M_UM77_\H*S#_14(]_V=;4O]F64S_6U!%_TI&1/\C'R?_&A@;_U554O\>'1S_
-M&A45_QD6'/\8%Q[_'QD=_T@N(?]*."K_4E-,_T9%2_\@&R?_%QDA_UYG;?]B
-M9VS_:&=F_QT:(/\;&R;_0D1,_S@Z/?\M+#/_&!8?_Q85&_\\03W_#0\2_Q01
-M'?\8%A__$1D=_T5'3/\8%1O_%!8;_TQ.3/\:&!O_(R F_V9D9O\L*#'_'QLC
-M_VAF:/]=6F#_(R F_T9$1_\A'R+_)"(E_U!*2/]%/SW_1D1'_Q45'O]B9&G_
-M4$]5_TQ+4?])2$[_24M0_T9(3?\_04;_0$)'_TU,4O\U-#K_,"\U_RTL,O\K
-M*C#_*RHP_RHI+_\I*"[_)R<J_RDJ*_\I*BO_*2HK_RLI+/\I)RK_*B@K_QL9
-M'/\9%1?_\_7R_SP^//\A'R'_CXJ._T]-4/\6%!?_%Q48_Q43%O\C&Q__&108
-M_QT@(?\6&!;_&Q\=_Y"1B_^BFY7_U<_-_];+RO_5R<7_T\K$_\W'O_^>DI/_
-M% \1_QD:&_\;%QG_&!,3_QD4%/\>&1G_%A$1_R4F(/\R-2__0$,]_T)%/_\R
-M,B__+BXK_R$@'_\1#Q'_(!L;_T1"._]$03;_7%)$_WIK7O]31#?_0C,F_U-"
-M-?]:2TO_'AD?_R,E*/]234?_;6)7_V582_]K7E'_95Q5_U)-4?].2TK_:FAC
-M_Q41$_\6$A3_&A<=_Q83&?\J'A__6#TL_TTX)O]H7UC_;FIL_QX7(?\@'R;_
-M4UM?_V%E9_^)B(?_%!$7_Q<3'/^"@(/_?X%^_V-C9O\8%A__%!,9_TY,1_\6
-M$Q+_&14>_Q@7'O\8("3_5%9;_Q,0%O\@(B?_65I;_Q,2&/\H)R[_9&1G_S0P
-M.?\?&R/_9V5G_V%>9/\3$!;_5U58_QX<'_\C(23_96-F_QP;(?\6%A__1TI5
-M_R <'O]D7U__@GU]_UU86/].3$__2DI-_T]/4O]&1DG_0$)'_T)$2?\^0$7_
-M/3]$_SY 1?\Y.T#_/D!%_ST_1/\]/4#_/S]"_SX^0?\_/T+_/CY!_SP\/_\S
-M,S;_(" C_QH6&/_\^O?_*R@G_Q@6&/\;&1S_+2TP_Q@8&_\6%AG_%!07_QX=
-M)/\4%AO_%1@9_RDF(?\>'R#_CXZ-_YZ8D/_3SLG_T\O)_]7+Q__3RL3_R\6]
-M_Z.7F/\8$A;_&1D<_Q@3%_\<&!K_&A88_QP8&O\7$Q7_$1(3_QT>'_\;'1K_
-M)"<A_QP@&/] 0SW_)2<D_Q47%?\>&AC_24= _U932/]I7U'_>&9<_UA(/O]%
-M."W_4D<\_V)34_\:$A;_&!H8_W)L9/]E6U'_;6!3_VI:2O]S9EO_55!+_VEG
-M8/]:6%'_$PX0_Q40%/\5$AC_'QH<_T4V,?];/BS_2C =_Y:&??^&?W__)!TD
-M_RDF+/]B:&K_?'^ _XF*B_\7%!K_&Q8<_WMW=?]O<6C_8F1A_QH9(/\7%AS_
-M14 [_T])1_\;%1W_%1<<_QHB)O\Y.T#_&18<_Q06&_]'24S_#Q 7_QP<)?]0
-M4E?_-C$]_Q\;(_]A7V'_6%5;_Q,0%O]85EG_'AP?_Q\=(/\[.D#_&!<=_Q01
-M%_\6$QG_&108_Q(,$/\J)"C_2D1(_U)04O]T<G3_7%I<_UA66/]+35+_1TI/
-M_T9)3O]"14K_/T)'_SL^0_\X.T#_,S8[_RXP-?\N+3/_+BTS_RXM,_\K+3#_
-M*RTP_RXP,_\K+3#_(!X@___T]?\O)RK_&1D<_WM^?_^3E)7_%Q<:_QT=(/]I
-M96?_;6QR_Q(5&O\F)RC_'!00_RPH*O^0BXO_F)2,_\[-QO_4T=#_T<S,_];0
-MSO_*P+S_IIJ=_QX7'O\;&![_%1(8_Q46%_\3%!7_%A<8_Q 1$O\.#1/_'!LA
-M_Q@9&O\>(![_*"TG_SQ!._\K,"S_*S L_R\K*?]!/#;_5U%'_VA>4/]B4$;_
-M4$ V_T4Z+_]=4TC_7U)-_Q40$O\0$!/_;FEC_VQB6/][;F'_>6M<_X1W:O]C
-M7%;_8%Q4_W%L9O\>%AG_%1 6_Q(0$_\@&1G_5$$Y_V%#+?]4-R7_D'UU_X^'
-MA?\K)"O_8%]E_U!45O]04U3_3$U._P<&#/\C(23_14$__U)63?\F*"7_'ATC
-M_Q@7'?]-1D#_6%!._QL6'/\7%AS_*# T_U987?\;&![_%!8;_T1&2?\4%AO_
-M'1TH_T1&2_\M*S3_'QPB_TY,3O]/3%+_%!$7_UA66?\>'!__%A07_Q$,$/\:
-M%AC_&!,5_R$:&O\;%AS_$P\7_QL7'_\=&2'_'!H=_R >(?\?'2#_4E!3_V]Q
-M=/]565O_35%3_TI.4/]#2$W_/T1)_SY#2/\_1$G_0$%(_T-"2?]"04C_0D%(
-M_ST_1/\]04/_.CY _S8Z//\5$Q7_^O+U_S0O-?\D(RG_;VIJ_Y:2D/\>&1W_
-M+2@L_Z"5E/^+?WO_'1<;_QH9'_\=&QW_'1X?_Y60D/^>E8[_S\K%_];/S__8
-MS\__U,K&_]C,Q_^=E)3_&A47_QT9&_\5$Q7_%Q47_Q@6&/\:&!K_$Q$3_Q,1
-M$_\;&1O_'!H<_QP:'/\G+";_.3X\_RHO+_\F+"C_-30M_R\J)/]+13W_6U-)
-M_W]S:O]-03C_13LQ_TU%._]P8U;_(1D5_R\K+?]/1#W_<F58_WUP8_]]<F?_
-MAGMP_W!H7O]E8E?_<G!H_S8R-/\<&1__&QD;_RTH(O\Z*![_8D(L_T@O'O^^
-MKZK_:6%?_S$M+_]C9VG_86QM_UE?8?]46ES_-ST__SM!0_\L,C3_3U-5_Q$3
-M%O\-#1#_(!XA_SPY-/^-B(C_(1LC_R,@)O\Q-CO_7F!E_Q83&?\9&R#_2DM,
-M_R =(_\<&"#_)B0G_R$?(O\<&AW_2$9)_TI(2_\4$1?_44Y4_Q\<(O\0#1/_
-M%A$5_Q@3%_\4#Q/_&Q8:_QD6'/\5$AC_%A,9_QX;(?\:%QW_%!$7_QL8'O\;
-M&![_)2,E_R4C)?]'14?_=7-U_U]?8O].4%7_2DQ1_T-%2O]!0TC_/D!%_SP^
-M0_\[/4+_,3,V_S$S-O\T-CG_+S$T_QD7&O_X\//_1T)(_RLJ,/\?&AK_;V=E
-M_R0?(_\@(B7_(" =_R$>&?\5$Q;_&AD?_Q\7&O\N+"[_C8B(_YZ5CO_/RL7_
-MTLO+_]?.SO_<TL[_ULK%_Z"7E_\D'R'_'1D;_Q84%O\7%1?_&1<9_QH8&O\3
-M$1/_$A 2_QH8&O\<&AS_&A@:_R<L)O\W/#K_*B\O_R4K)_\O,2[_*"8C_SPY
-M-/]$/SG_1S\]_QL2$O\C'!S_'AD9_S,J)/]$/#C_4DU-_VA?6?]F6E'_<69;
-M_WIM8/^%=VC_>7%G_V9C6/]L:V#_-3,P_R >(?\B("+_*"0B_RT>&/]&*QK_
-M."$5_]3&P_^4C(K_'AH8_UU?7/]A;&?_6F!<_U]E8?]I;VO_76-?_SU#/_]*
-M3T__$1,6_P\/$O\6%!?_-S0O_TQ'1_\@&B+_&!4;_S0Y/O]<7F/_659<_S R
-M-_]045+_$@\5_R <)/\7%1C_%A07_QL9'/\6%!?_(!XA_Q42&/\D(2?_%!$7
-M_QX;(?\:%1G_&A49_Q81%?\4#Q/_%Q0:_Q83&?\8%1O_%1(8_Q83&?\4$1?_
-M%A,9_QD6'/\4$!C_(!PD_Q41&?\C'R?_-38W_U-54_]E9V7_2DQ*_TI,3_]$
-M1DG_04-&_SY 0_]"1$?_/T%$_SL]0/\^0$/_.3D\__OS]O\G(BC_(2 F_XZ)
-MB?]U;VW_*B4I_Q@6&?^]M[7_O;6Q_QP7&_\8%QW_&147_Q43%?^2C8W_GI6.
-M_\K%P/_6S\__W=34_]S2SO_2QL'_H)>7_Q\:'/\7$Q7_%1,5_Q84%O\9%QG_
-M'!H<_Q,1$_\3$1/_&A@:_QL9&_\;&1O_)"DC_S4Z./\N,S/_)BPH_S0U+_\L
-M*23_2T9 _TE#._]C657_65%-_TI%0/\Y-C'_,"PN_R0B)?\8%AG_&!89_QL7
-M&?\?&QG_+"4?_X!V;/]G6US_8EQ:_VEF8?] /3S_'AH<_QD7&?\T,B__)QP;
-M_THS)_\Y)1W_RKV\_X-Y=?\@&1G_+"HL_S,Z.O](2TS_*2HK_V%B8_]]?G__
-M$1(3_[.UN/\;'2#_%A89_QP:'?\I)B'_O;BX_V!:8O\;&![_,C<\_S@Z/_\?
-M'"+_*"HO_T!!0O\7%!K_)R,K_Q,1%/\,"@W_,C S_Q84%_\2$!/_'QPB_Q@5
-M&_\3$!;_$0X4_Q@3%_\9%!C_%A$5_Q40%/\2#Q7_&A<=_Q,0%O\2#Q7_&18<
-M_Q$.%/\:%QW_$Q 6_Q82&O\7$QO_%1$9_Q82&O\?'2#_+"HM_RTK+O]24%/_
-M24I+_T5(2?]$1TC_0T9'_S]!1/\^0$/_04-&_T)$1_] 0D7___C[_R(?)?\5
-M%AW_'QP;_SPV-/\@&Q__(QTA_RX?'_\G%Q3_(AH>_Q,5&O\1%!7_0$%"_XB&
-M@_^;E8W_Q\*]_];/S__=U-3_V]'-_]'%P?^>EY?_'!<9_Q82%/\4$A3_$ X0
-M_Q43%?\=&QW_$Q$3_Q<5%_\9%QG_,"XP_QH8&O\E*B;_,C<U_S,X./\D*B;_
-M/#@P_R@D'/]O;&?_8EQ4_W]U<?]L8US_;6A<_W!J8/]U:F/_<F9=_W-F6_]J
-M7%/_4DY,_U).4/]=6%/_;61=_VI>8?]%.C__'QH:_RXJ+/\;%1G_%Q,5_R0C
-M(O\?&AS_-"4?_R<9%O]74E3_>W-Q_R4=(/\E)"K_)BHL_R @(_\H)BG_&18<
-M_VAG;?\@'R7_G)ZA_Q<9'/\:&AW_'1L>_R,>&?_$P<#_:&=M_R,@)O\7&A__
-M%QD>_Q(/%?\8%QW_*RPM_QT;'O\@'"3_$Q$4_Q84%_\U,S;_#0L._Q84%_\Q
-M+C3_.#0\_QH6'O\;%Q__%Q(6_QH5&?\6$17_%1 4_Q83&?\7%!K_%!$7_Q83
-M&?\1#A3_$0X4_Q83&?\5$AC_%A,9_QL9'/\9%QK_&1<9_Q$-%?\3#Q?_.#0\
-M_RLH+O\G*2S_<G9T_U)44O]*34[_1$A*_T1&2?]#14C_1D9)_T9(2___\O/_
-M*B4I_R B*?]"/D#_0SLY_S4O,_\7%!K_DXN._YJ2D/\J)2G_%QD>_QP:'/\I
-M)B7_CXZ'_Y65C/_$PKW_UL[,_]7*R?_:S\[_S<+!_Z&=F_\G)"/_%A(4_Q<2
-M%O\3$13_%Q47_Q84%O\5$Q7_%1,5_Q@6&/\C(2/_&QD;_R0H)O\Y/CS_+S0R
-M_R0I)_\[.SC_&R,M_S9&8/]#3VK_-3I3_S Z3O\]3UW_+#Q,_R<L/O\K,D#_
-M.D1/_UYB:O]H9V;_;F=O_X!Y<_^$>F__<V1>_Y^7E?]/34__24=$_Q\;'?\<
-M&!K_(R4H_SY*4_\6+3+_3V)N_XZHM?\<)27_)2 @_SP_0/](34O_5E93_TU,
-M2_],34[_LK2W_Q@;(/^TK[/_'AP>_Q\B(_\>&AS_(1\<_[FUL_]84U?_%A4<
-M_Q(/%?\2$!/_$ X1_Q84%_\?'2#_%1,6_Q43%O\4$A7_$Q$4_Q$/$O\3$13_
-M$A 3_S<S._\R+C?_'1DB_QH6'_\2#Q7_%Q48_Q<5&/\7%1C_#PT0_R >(?\7
-M%1C_$ X1_QH8&_\4$A7_%!(5_Q02%?\3$AG_$Q(8_Q04%_\3%!7_%!4<_Q .
-M%_]13U+_'QP;_VYO</]F9&'_A8!Z_U134O],4%+_14E+_TA(2_]*2$O_1T5(
-M___P[/\[-#3_*2HK_TU'1?\U+2O_-C T_QH7'?]9453_8UM9_R<B)O\;'2+_
-M)B0F_S8S,O^/CH?_F)B/_\3"O?_9T<__U\S+_]K/SO_%NKG_JJ:D_T],2_\5
-M$1/_%A$5_Q,1%/\7%1?_%A06_Q43%?\5$Q7_%A06_QX<'O\:&!K_(B8D_S@]
-M._\P-3/_(R@F_S4Y-_\7'RG_"Q<R_PP3-_\($S+_*SQJ_QXY=O\I2WW_)U"!
-M_SYLGO\L6HS_,EN,_T5HD/].9HW_3%1>_Y>-@O]W:V+_.#(P_S] 0?](2$7_
-M:FYE_VIN9O]U@X;_.UUQ_WVOQ/^@Q^#_>**R_W6$A/^$>WO_0S]!_QLC(/\M
-M,R__0TA&_W5Z>O^XP,+_%1\C_[V[OO\<&AS_&AT>_QX:'/\5&!+_MZFF_YN
-MAO\4#Q7_$1$4_Q02%?\4$A7_$ X1_Q02%?\3$13_$Q$4_Q$/$O\2$!/_%1,6
-M_Q,1%/\4$A7_'ALA_Q,/%_\1#17_$ P4_Q$/$O\:&!O_&1<:_Q@6&?\2$!/_
-M'1L>_Q02%?\:&!O_$@\5_Q(/%?\5$AC_%1(8_Q,2&/\1$QC_$Q4:_Q<9'O\1
-M$AG_$Q(8_S(P,O\?'1K_H9R<_X^$@_]H7%?_9EU=_V!<7O]>6ES_2D9(_U%-
-M3_]24%/___3T_RPG*?\>("7_(1X=_RXF)/],1DK_(R F_R8>(?\J(B#_'1@<
-M_Q@:'_\<&AS_=G-R_X.">_^8F(__O+JU_]C0SO_>T]+_V<[-_\6ZN?^JIJ3_
-M1T1#_Q82%/\7$A;_%Q48_QH8&O\7%1?_&!88_Q<5%_\7%1?_&QD;_QT;'?\?
-M(R'_,38T_S,X-O\=(B#_.#8Q_R0B'_\?'"+_%A,?_Q01*/\P-U7_'S%5_R V
-M7/\O5'?_.VJ-_RU:@O\>16__+%5Y_RY(;_]\@XG_GI"!_VQ@5_]%03__+C$R
-M_RHO*_]?8UK_@7]Z_UUF;?]9?)/_;YZV_Y_!V_^#I;G_H::K_S,L+/\T-3;_
-M55I8_WZ ??]L:VK_*2PM_Z"DIO]>8VC_PL##_Q,1$_\0$Q3_'AH<_R,A&O^X
-MKZG_BWQ\_Q<1%?\6%!?_%!(5_Q02%?\3$13_$Q$4_Q,1%/\2$!/_$A 3_Q,1
-M%/\2$!/_$Q$4_QH8&_])1TK_%1,6_Q .$?\2$!/_$A 3_R >(?\B("/_(R$D
-M_Q<5&/]$0D7_%!(5_Q .$?\4$!C_$@X6_QH6'O\G(RO_,2XT_S@S.?].2%#_
-M85ID_Q$.&_\4$1W_'!@@_T(]0?^MJ*K_LJJH_WMO:O]L967_BX*"_W!G9_]L
-M967_7%=7_T,^0O__^?K_)R8M_RHO._\U-#K_*"(@_U=15?\>&R'_EI&3_[2L
-MJO\^.3W_#A 5_QH8&O\>&QK_@'YW_Y63B_^\NK7_U]'/_]O0S__7S,O_PK>V
-M_ZVII_\D(2#_&A88_Q40%/\3$13_&1<9_Q<5%_\8%AC_%Q47_Q<5%_\;&1O_
-M'QT?_Q\C(?\O-S3_.#T[_QPA'_\T.#K_'R$F_QH='O\1%AS_%QHL_Q<B(_]#
-M6%+_>8^7_Y:QO/]\F*#_7GB#_T-79?](97'_,D=D_WE[>?^6A';_<&5:_TM'
-M1?]"14;_,38R_XZ/B/]Z=W;_'!DF_T%:<?^!L,+_F<79_XRWR?^JN;G_.#4T
-M_SD^/O]D:6?_S<G'_X^*BO\<&!K_CHZ1_V%C:/^FI*?_$Q,6_S S-/\E(B'_
-MDH:!_V1?6?\;'1K_&Q<9_QD4&/\=&Q[_%1,6_Q(0$_\2$!/_$A 3_Q$/$O\1
-M#Q+_$A 3_Q(0$_\-"P[_&QD<_U!/5?](1TW_%!(5_Q(0$_\/#1#_$ X1_QH8
-M&_\7%1C_$0\2_P@&"?\2$!/_&A49_T9"2O\_/4;_.CI%_Q$/&/\R*3#_0#4Z
-M_XE^@_]81U'_:5UL_V1::_]W;GO_;VAO_Z.>H/^=EY7_2D="_U535?_6RLO_
-M6U-1_TI#0_\:%17_'!8:___X\_]!/4;_4UAJ_Q02%?\D)"'_;V1I_Q<4&O\3
-M%!7_*!T<_Q80%/\7%AS_&A88_X^*BO]_>'+_G9>/_ZVKIO_2T,W_V-#,_]?+
-MQ_^MJ*/_JZFF_QD6%?\;%QG_&A49_Q,1%/\7%1C_$0\2_Q02%?\5$AC_%A07
-M_Q84%O\Y.#?_)",B_RDX-/\U.3?_&1T;_R\T,/\E(BC_'1\<_Q0:(O\7&SO_
-M'!XA_UM95O^+F)W_B:.F_X69G?]E;6__6&)?_U=O;/\E0G+_>'U[_XMU<_]O
-M95K_3TE'_R0E)O\C)2+_G92-_UUL<?\?+D7_$"M#_WVENO^;R^?_H<SD_[S
-MPO]01T?_*2<I_V!D8O_.R,;_F924_QL9&_^[N[[_2DQ1_[BWOO\9&Q[_8&-D
-M_Q@4$O\A'1O_)B$A_QD4%O\4#Q7_&!89_R(@(_\=&Q[_$A 3_Q$/$O\2$!/_
-M%A07_Q,1%/\1#Q'_$0\1_PT+#O\<&1__,SM+_Q(2'_\5#Q/_$A,4_Q 0$_\8
-M%AG_)"(E_Q<5&/\8%AC_%Q47_Q@4%O\:%1?_'!<=_PT/%O\'#!+_" <._Q,.
-M$O\<&A?_'QL3_WYI9_]]8G+_2"Y)_U,]5_]"-C__C8*!_U914?\Y.S[_+2\T
-M_\["P_\N,S'_3$U._QT8'/\7%!K___3Q_SDT.O\7%R3_)B$E_RDK*/]]<G?_
-M&A<=_XJ+C/^RIZ;_<&IN_Q,2&/\:%AC_%Q(2_W=P:O^;E8W_N+:Q_[V]NO_!
-MOKG_J:&=_YR:E?^<FI?_)2(A_R <'O\<%QO_$Q$4_QH8&_\3$13_%Q48_Q<4
-M&O\7%1C_(!X@_QD8%_\?'AW_*CDU_S<[.?\8'!K_+C8R_R<B)O\G)A__)"DU
-M_QPF2_\4&R'_/SLY_X2)CO^7K*[_@9:8_WB&A?]E;6G_771O_R1!<?]Y?GS_
-ME7]]_W=M8O](0D#_*2HK_R,E(O^?D(O_&2,G_S9?<O];C:C_99.O_UV1LO]0
-M?9O_JK"Z_U]56/\L*BS_%!@6_]#*R/^@FYO_'AP>_["PL_]"1$G_LK"S_QH:
-M'?]S=7C_%1(8_QXB)/\E*2O_%!07_Q,.$O\6%!?_&A@;_Q<5&/\2$!/_%1,6
-M_Q,1%/\0#A'_$0\2_Q$/$?\1#Q'_#PT0_QL8'O\?)CS_%!8E_QT8&O\E("3_
-M$A 3_QD7&O\L*BW_'1L>_Q<5%_\5$Q7_34E+_RDD)O\:$A;_%A(4_Q(1$/\A
-M'R+_$18<_Q@>(/\L*2C_'Q,6_V1:;?\;$BK_C("5_X%V??]%/#S_(1X=_SQ
-M/O\P,C#_S\3#_S U,_]'2$G_(!L?_QH8&___\_+_*" C_R0A)_\A'!S_/T$^
-M_W1I;O\0#1/_)28G_S4J*?\G(27_%!,9_QL7&?];5E;_9V!:_Z":DO^EHY[_
-M@(6!_YR=E_^2D(O_=GES_WAX=?\7%!/_&!06_Q<2%O\1#Q+_%A07_Q02%?\7
-M%1C_%1(8_Q84%_\C(2/_&QH9_QP;&O\G-C+_.#PZ_Q@<&O\O.SC_)2(A_S8P
-M)O\F+#S_'B=0_Q4;(_\B'AS_5%M;_U1G9_]TBHG_>XZ(_V!J8?]9<&O_+DM[
-M_W=\>O^9@X'_=6M@_W9P;O\J*RS_,#(O_X^.@_]J8F#_#"<R_W&HP/^#L<W_
-M8I:W_WFBP/^SL[S_;F)C_R0B)/\N,C#_S\G'_Y^:FO\L*BS_IJ:I_RHL,?^Q
-MK:O_&Q@7_V)C:O\G)#'_/#E%_R$B*?\4$QG_$1$4_Q,1%/\6%!?_$A 3_Q,1
-M%/\:&!O_%Q48_Q$/$O\1#Q+_$A 2_Q(0$O\0#A'_'!D?_QPC0?\*#1__$ L+
-M_R@C)?\8%1O_&1<:_R0B)?\@'B'_'1L=_R(@(O]J9FC_)B$C_Q,/'_\8&"/_
-M%1@=_QHE,/\>)CK_.3U%_R<B'?\U+R?_;&MJ_PP-#O^DHI__-3 K_R$<'/\6
-M&!;_/D,__TQ*1?_%N;7_1TQ*_RXO,/\9%!C_&!89__GM[O\G'R+_%A$5_QX;
-M&O\='1K_FHZ1_R@E*_\H*2K_,2DG_RHE)_\5$AC_(B B_WYY>?];5E#_HYJ3
-M_Y22C?]N=6[_D9:0_WI]=_]N=6[_<G-M_Q01$/\9%!C_&108_Q84%_\8%AG_
-M&!89_QD7&O\9%QK_%A07_R >(/\7%A7_&QH9_R<S,/\T.3?_%AH8_S@^0/\A
-M'QS_'A<1_T9.7O\D+5S_&ALF_R >&_\F-#/_AIN=_W.)B_]A=W7_6V1=_UYU
-M</\N3WK_>'Q^_YR'@O]G6DW_BH)^_Q\@(?\O,2__AXZ"_ZF5C?]06&+_9)2I
-M_WFHP/^;S>C_6WR3_[RWO?^"=G?_'R A_SL^/__/R<?_J*&A_S$O,?\O+S+_
-M*BDO_UQ85O\=&AG_0T)(_PD(%?\=%B+_(!HB_QD6'/\0$Q3_%148_Q02%?\1
-M#Q+_%A07_Q\=(/\6%!?_$0\2_Q$/$O\2$!/_$A 2_Q(0$_\5$AC_'2-#_Q$6
-M,/\1#Q+_%Q$5_RDE+O\G)"K_,"TS_RXL+_\Q+S'_)B0F_QX:'/]"/3__(B4^
-M_TI19_\4'BS_(S--_TI6=?\+#!W_(1D5_V%<2O]#/CG_&!,5_Z*=G_\J)"S_
-M&A4;_Q47%?])3$;_4$](_ZRBGO\9'1O_&!D:_R@F*?\P+C#___KY_RLC)_\2
-M$1?_'!T>_WEW=/^FEYC_%1,5_RDM+_^[M;/_G)>9_Q@3&?\=&Q[_%Q(2_T5)
-M0?^HG9;_A8-^_V5O9O^%C8/_;'1J_V=O9?]I;67_%Q47_QH7'?\:&!O_&!88
-M_QL9&_\>'![_'!H<_Q@6&/\:&!K_&A@:_Q@6&/\7&!G_*"\O_S([._\4&1G_
-M-3 \_R(F'?\@%A__'2DP_R$V;/\6%"3_(A\>_R$M-/^*I*?_@IVD_UUT>?]&
-M4D__46IO_RU5?/]T>8O_D8!R_W-@5O^>DHW_(2(C_Q\;'?^2BH;_IYV2_YFJ
-MM_]VHKS_F,38_ZG-XO\J.TC_B(.#_YV8D_\>'B'_2TI0_\7 PO^NIJG_.C@Z
-M_S@[//]+3D__/D-#_QH='O^"?H#_&!D:_QD9'/\<'!__$Q,6_Q04%_\6%AG_
-M%A89_QH:'?\]/4#_'Q\B_QD9'/\?'R+_#@X1_Q0.%O\4#Q/_$0\2_Q(0&?\8
-M(CW_(BI6_Q8<-O\8&"'_5$QG_T ^1_\K)R__&QHA_X.!?O]23T[_&A88_R<B
-M)O\-$B3_'",Q_S(U0/]G;8/_=H&@_Q\D-O\=%A;_."TF_R,?'?\=%A;_K:>E
-M_RLH+O\?&R/_%!(4_V)C7?\;&QC_,S$L_QL8%_\5$Q;_*2TK_Q@6&/__^/?_
-M0SL__Q\>)/\5%A?_)24B_[&EIO\;&1O_&1L>_QD3$?\6$1/_'!<=_QL9'/^2
-MC8W_14E!_Z*7D/]_?7C_7&5>_V9M9?]@9U__86A@_V1H8/\8%AC_&18<_Q84
-M%_\6%!;_&A@:_QT;'?\6%!;_%1,5_Q(0$O\9%QG_%Q47_Q<8&?\F+2W_-#T]
-M_Q09&?\S,#S_(2@>_QH0&?\)$AG_&REA_QL7)_\G(1__&!H=_S1+2O^%H:3_
-M9'A\_TU65O]2:6C_,UAW_W%R??^7@&W_A7=N_ZB@GO\A'R+_'QT?_XV*A?^H
-MH97_D:*O_R5/:?^SS^3_M<K<_Q,=)_^*A7__@X![_QXB)/]96V#_O[N]_[VY
-MN_\L,3'_-$ __S0]/?],6%?_)"<H_Y2,C_\9$13_%A07_QH:'?\0$!/_&!@;
-M_Q45&/\>'B'_'AXA_T-#1O\J*BW_(" C_RHJ+?\2$A7_% X6_Q0/$_\.# __
-M$Q$:_Q4A//\:)53_'"=*_S(U3O]B5'K_@'Z'_PT0%?\5$A[_$ T,_U!-3/\9
-M%1?_(!L?_T-"2/]65%;_8UQ<_Z:BJO]N;W;_%A07_QD2$O\Q)2'_'QH:_QL4
-M%/^IHZ'_%!$7_Q,/%_\/#0__8F-=_YN;F/\]/3K_'1L=_QL9'/\M+BC_&A88
-M___X]_],1$C_)20J_QX?(/\O-##_O[:V_QD7&?\D)"?_LZNI_[JUM_\;%AS_
-M$0\2_QX9&?\?(QO_H9:/_X!^>?\T/#C_.3\[_RTS+_\U.S?_76!:_Q@6&/\4
-M$1?_%!(5_Q,1$_\5$Q7_%1,5_Q43%?\3$1/_%!(4_QD7&?\9%QG_%A<8_R$H
-M*/\Q.CK_$A<7_RTM./\C*R'_(QDB_Q\E+?\?+67_-C5&_S<X,O\_03[_,S@R
-M_YFEI/^9I:G_;G5U_T]E8_\S67G_='R0_XB ?O^&@8'_K*:J_QL6'/\>'![_
-MC8Z(_YV8C/](66;_1VV(_Z_/Y?]TCJ/_1%1>_X2$@?^9FI3_)RTO_S U.O^P
-MKK#_P[_!_V1I:?]<:&?_='M[_X2)B?^1CY'_J*"C_Q@3%?\5$Q;_&AH=_Q 0
-M$_\7%QK_#@X1_Q86&?\='2#_'AXA_Q\?(O\9&1S_&1D<_P\/$O\3#17_$PX2
-M_Q .$?\4$AO_%1XV_QDC4/\;)4K_%!DW_V5/?/]^>87_$!@:_QH:)_\=&1O_
-M55)1_R@D)O\P*R__)R,E_R(8&_\R)2K_>7!W_T$V-?]@5EG_$0X4_Q00$O\6
-M$A3_&1(2_Y6/C?\5$AC_%! 8_Q<5%_]=7EC_GIZ;_S$R,_\<'!__'1L=_TM*
-M0_^'A(/___7R_T Z/O\;'"/_&!D:_WAZ=_^\M;7_&A@:_Q43%O\F'Q__&A88
-M_Q83&?\='"+_BX:&_RHK)/^=E(W_@X%\_R\W-/\H+2O_&1\;_RTS+_]365'_
-M&!88_Q01%_\4$A7_%1,5_Q02%/\3$1/_%!(4_Q43%?\4$A3_&1<9_QD7&?\7
-M&!G_(B<G_RPU-?\;("#_-3<__Q8>&O\=%1G_&1\G_R0V;O\9'R__)BHB_RTP
-M*O\V+2;_.S8V_VUP<?]&3T__,%%C_QM0AO\;.W/_.$]Z_UQH=_^ZLK;_(ATC
-M_R <'O^-CX;_HI^4_U-@:_]+;(/_1VN _R%"6/\A-D+_*2LI_Y^AGO_#QL?_
-MA(F._\/$Q?^_O+O_6EU>_[[#P_\^04+_S<G+_V%97/^7CY+_&1<9_R4E*/\9
-M&1S_$Q,6_Q<7&O\0$!/_'AXA_R,C)O\H*"O_&1D<_QL;'O\5%1C_$! 3_Q,.
-M%/\3#A+_$A 3_QL:(?\5'##_&B%+_Q8=0?\;'#O_9D]Y_W-P??\J-3;_'R K
-M_WUZ>?]'1$/_&!06_RTH+/]'0DC_13M$_T,T/_^$?(;_85-4_Z&9G?\4$AO_
-M$Q48_Q,1$_\<%Q?_EY&/_PT+#O\5$AC_&!<6_V5F8/]K:6;_-38W_QH<(?\4
-M$A3_5%)*_[VZN?__]O#_54]3_S4Z1O\H)2O_)" >_[&NK?\9%1?_&A49_V%6
-M5?]C657_&Q<5_QT<&_\J'!W_*"DB_Y64B?^'B(+_)2PL_Q\F)O\>)B/_*C(N
-M_TI63?\8&1K_%A$7_Q,1%/\6%!?_%A07_Q84%_\3$13_%!(4_Q02%/\6%!;_
-M&1<9_Q<5%_\?(B/_)S,R_PL2$O\M-3+_#Q$@_QL8$_\7(2S_&3!E_QXA,_\A
-M'QC_+"HE_SPZ*_\G(AW_2D<\_X*(A/\C0F3_+%>%_QQ B_\M3I;_26=]_\"N
-MLO\:'R3_(QD<_Y"0@?^>G)7_C(Z3_YFDJ_^7H[+_1UAE_SI&2O^.AH+_J*6D
-M_]W5V/^3F)C_J:JK_\&_O/^ZN;C_V-/7_[JVM/_)PL+_<VYN_X6"@?\O+BW_
-M&!H=_QH<'_\2$A7_&!89_PT.#_]86US_4515_R(E)O\@'B'_)"(E_QT;'O\3
-M$13_%A 4_Q0/$_\1#Q+_%!07_QTF/O\<(U'_%!U"_QP@//\N'CK_869R_UE>
-M7O]K;6K_E9.._U%-2_\7$A;_+"@P_QX=(_\R*S+_.C$X_WYY?_]42TO_J:"@
-M_QP7&?\8%AG_$Q(8_QD4%O^EGYW_&!,7_Q43%O\:&1C_@8%X_YF6D?\\.#;_
-M)B(D_QD8%_]334/_P+V\___T\/]]=G;_&1HA_Q .$?^(A(+_JJ>F_QX:'/\=
-M&!S_=&EH_VYF9/\:%17_'1L=_R\G*O\7(!G_-CTS_SI"/O\F+2W_(R8G_QD=
-M&_\I+BK_1E!'_QL<'?\9%!K_%1,6_Q@6&?\8%AG_&!89_Q02%?\6%!;_%1,5
-M_Q84%O\9%QG_%1,5_QXA(O\C+R[_$!<7_RLS,/\4%B7_&Q@3_Q0>*?\9,6C_
-M+S-(_TA&0_\D)"'_+2LC_SHP,_\Y,RO_/STZ_R1 8O\L5X7_'D:1_RI+D_]$
-M7W?_MZ6I_Q,:&O\B%QS_C9!^_Z.@E/]X<&[_P;6X_]++U?\<'B;_.#L\_[6H
-MH_^II*3_V<_2_WV"@O^;GI__RL7 _[JTLO_<TM7_R+ZZ_\[&Q/]^>7G_B8:%
-M_Q\>'?\7&1S_%1<:_Q$1%/\7%1C_%!46_PX/$/\_0$'_'A\@_R<E*/\E(R;_
-M(!XA_Q02%?\6$!3_% \3_P\-$/\/#Q+_'"4]_QLA4?\3'D#_%ALT_R\@.?]I
-M;GK_9&EI_VAJ9_^)AX+_4DY,_R0?(_\\.$#_1D5+_Q$*$?\Z,3C_C(>-_V-:
-M6O^BF9G_'QH<_Q84%_\3$AC_'!<9_ZJDHO\T+S/_&A@;_R<F)?]_?W;_?7IU
-M_S\V,/\K)B'_'QH4_U9,0?_+P<3___3Q_Z&6E?\:%Q;_'AH<_S<T,_^VL[+_
-M%A(4_Q\:'O\>&1__%1(8_Q<9(/\4&B+_=W!W_QPD(/^*CXG_>7Y\_S5!0/\Y
-M0D+_.4- _SM&0?]"3D7_$A,4_QD4&O\5$Q;_%1,6_Q84%_\7%1C_%!(5_Q84
-M%O\7%1?_%A06_QD7&?\8%AC_'2 A_R(N+?\@)R?_+#0Q_Q,5)/\<&13_"Q4@
-M_QHR:_\9'S7_0#\^_T!"0/\K,"K_'QPB_S8T+?\W.3;_'S99_RE7A/\:1I#_
-M*TJ2_SE2;_^QGZ'_%AX:_R8;(/^*BW[_I9^7_VA:6__JV=G_Z-C<_SDT-O]Y
-M>7;_U<G$_Z6>GO_8S,__C9*2_WR#@__(QK__O;BS_^#7U__*P;O_O[>U_XJ%
-MA?]Q;FW_+BTL_QH<'_\6&!O_%!07_Q@6&?\/#0__$Q$3_Q,1$_\D(B3_'AP?
-M_QP:'?\9%QK_%!(5_Q4/$_\4#Q/_$ X1_Q,3%O\8'RO_'R5%_Q$7,?\:%RW_
-M6$EB_V1I=?]D:6G_5EA5_X6#?O]134O_&A49_U).5O]_?H3_?WA__X!W?O^V
-ML;?_A7Q\_Z:=G?\<%QG_'!H=_QP;(?\<%QG_K:>E_X:!A?\[.3S_+RXM_X:&
-M??^=FI7_244]_QH8$_\:&!7_-"TG_[ZXO/__^OK_O+&P_R<B(O\D("+_)!\?
-M_XV*B?\/"PW_%1 4_[*HI/^WJZ?_'Q<5_QP9&/\?%1C_("0B_Y:6D_]?8F/_
-M-$)!_SA&1?\Z247_/DU(_T-/1O\1%!7_&Q8<_Q,1%/\8%AG_&1<:_Q<5&/\4
-M$A7_&1<9_Q84%O\<&AS_%1,5_Q@6&/\<(2'_)C(Q_R(I*?\E+"S_&1TL_Q\;
-M&?\.%2'_(3MT_QH?./\G)B7_*RTJ_S0[-/\U.#G_+S,K_S$V,/\<,5/_*U:$
-M_Q9$CO\N397_.%%T_ZN8F/\:(A__'A07_WQ[=/^BFI;_8%17_^77V/_KW-W_
-M+BHH_\#!N_^PJ:/_J*&A_]S-T?^&BXO_86IJ_]74S?^]NK7_W]G7_\O$OO^\
-MM[+_C8B*_V!=7/\S,C'_&AP?_Q88'?\4%!?_&!89_Q(0$_\2$!/_$Q$4_R8D
-M)O\>'B'_&AH=_Q04%_\1$13_% \3_Q0/$_\3$13_$A(5_Q<:&_\:'2[_#1$@
-M_Q@1(O\E&BW_)RTU_S8[.?]45E/_55)-_U103O\9%!C_44Y4_RXK,?\B'2/_
-M+B4L_VYI;_]-1$3_KJ6E_Q@3%?\5$Q;_#@T4_Q0/$_^LIZ?_?'AZ_S@V./\P
-M,"W_EI:-_Z&<EO],2D/_'AX;_R,A(_\H(R/_M[6X___Q[?^JGJ'_(1XD_QH:
-M'?^%@(#_MK&Q_Q(.$/\8%AG_'186_RLD)/\9%1?_%1<:_VAB9O\5'!S_FIV>
-M_SH]/O\N/S__,4)"_S1&1/\Z3$C_2E-,_Q05%O\6$QG_'!8:_QD7&O\>'!__
-M%1,6_Q,1%/\6%!?_%!(5_QP:'?\:&!O_%148_QH>(/\B+S#_&B(D_R(J+O\3
-M'2?_(AX@_QH=*?\A.G7_)"9!_RHE(/]144;_.SLN_UA93/\Q-"C_'B =_Q@O
-M3/\?2G3_"39]_RI+E/\B/V__Q*^K_Q08(/\F(1O_='1Q_ZBCG?])/SO_ZMO;
-M__+<W?\B(!W_GY>5_];'Q_^YN;;_V\_0_YB9FO]67%[_S\C(_[JRL/_:TM#_
-MPKJX_[NSK_^EFZ3_4DU-_R(@'?\>'23_%!8;_Q<5&/\<&!K_$ T3_Q,0%O\3
-M$13_*RDK_RLK+O\9&R#_%!8;_Q$3&/\D)2;_-38W_SX_0/]+3$W_*"8I_Q88
-M&_\L,3'_9FAF_U!44O\\/CO_5U)-_VQ@6_]_<VS_<FIH_QX9'?]02D[_(1PB
-M_Q *$O\L)B[_;&9N_UQ34_^MI*3_&A47_Q<5&/\/#QK_$A$>_R(?*_\6#QG_
-M%10:_Q<8&?^BG9W_IIZ<_TI(0?]&1#W_3DE#_U),1/]_=W/___#L_[&EJ/\>
-M&R'_&QL>_R4@(/]U<'#_&147_Q$/$O^JHZ/_LJNK_Q<3%?\3%1C_'AH<_R$I
-M)O^QKJW_P;R\_W=\@?])457_0TM-_T)+2_]*3TG_%Q47_Q,0%O\2$!/_&A@;
-M_Q02%?\5$Q;_$Q$4_Q04%_\2$A7_&1D<_QH:'?\8&!O_&Q\A_R M+O\B*BS_
-M(RDK_QHE+/\C)2/_)28Q_R9">_\?)#[_)R,A_S4V,/]'13W_5E9+_TU/1O\A
-M(R'_%2Q)_R!+=?\)-GW_)D>0_QPY:?^QG)C_%1DA_R8A&_]34U#_G)>1_T V
-M,O_NW]__[]G:_S N*__9T<__W]#0_WMY=O_;S<[_GYV?_T5)2__3T,__K:NH
-M_]73T/^\NK?_HYZ9_ZF?J/\T+R__'!H7_S4X/?\>(R/_%AH8_S@Z-_\S+S'_
-M&A88_W!M;/]&1$'_*"<F_S0V-/^BI*+_(R4C_U]A7O]*3$G_04- _S]!/O]9
-M6UC_3DY+_V%<5_^9C8C_MZ6A_\BTL/_1N+/_T;6N_\VTI_]40SW_(QHA_U5/
-M5_]X<GK_>'%[_WYW@?^NI['_J)^?_Z^FIO\:%1?_%Q48_Q<9(/\4%2#_(R(S
-M_QH7+O\:%RW_$Q B_QD5)?\4#!K_$ P4_S0Q,/\_/C/_2T@\_S@V+___\^__
-MMZNN_Q42&/\7%QK_=7!P_STX./\6$A3_&!89_R8?'_\;%!3_&Q<9_Q47&O]*
-M24C_-#PX_\.[N?_JV]O_X-'2_^+0U/_9R,C_T\/ _Y^:E/\?&QW_%1(8_Q,3
-M%O\8%AG_$Q$4_QD7&O\5$Q;_$! 3_Q 2%?\9&Q[_%QD<_Q45&/\9'1__("TN
-M_R,K+?\H*RS_'2HO_R4K)_\L+C;_)$%W_R4K1?\C'R'_)"8D_S\]-O]144C_
-M75Y7_Q@9&O\.)$3_&41N_P8S>O\H29+_'CMK_[NFHO\@)"S_)2 :_TM+2/^A
-MG);_.C L_^76UO_PVMO_-C0Q_]C0SO_>S\__FI:4_][/T/^EH:/_2DQ/_]#)
-MR?^LIJ3_U,[,_\"ZN/_$O+C_O;.\_S(M+?\R,"W_2$9(_YN;F/^8EI'_/3LT
-M_ZFEH_\S+RW_KZRG_T ^-_^<FI7_.3HT_W5V</\G*"+_14E!_S8Z,O]$2$#_
-M0D8^_T9,1/]44$C_RK>O_\JRJ?_)L:C_PZF@_[RAEO_5N*S_OZRB_T,W,_\>
-M&1W_1T)(_Q<3%?\?&QW_)2$C_T(^0/\_-S7_HYJ:_QL6&/\7%1C_%!$7_Q<3
-M'/\-#!G_%!(E_QT9,_\<&#+_&Q@O_Q42*/\?&C3_)B,P_S0R+?\T,BO_4%53
-M___V\O_!M+/_'QXD_Q(4%_\=&1?_)!\?_R$='_\5$Q;_-"DH_T,X-_\?&AS_
-M&AH=_T1&1/\P.#3_P[FU__'<VO_GV]?_X=71_]W0R__9S<;_GI>1_R,@'_\6
-M&!W_%QL=_Q\B(_\='2#_(" C_R(B)?\E*2O_)2LM_R8L+O\J,#+_+# R_S(X
-M.O\E,C/_)C$R_RHO+?\?*C'_)3 I_R4G+O\D/W7_*3%+_R0B)/\G*"G_1T=$
-M_U153_]254__)B@K_P\D0/\80V__!C)\_R9'C_\C/FW_N*>G_S O-?\K)B'_
-M,S$N_Z";E?\T+"C_Z]S=_^_9VO\L*2C_ULW-_]O,S/][<V__U\;&_["KJ_]*
-M2DW_V]/1_[JOKO_*O[[_Q;BW_\:\N/_)O\C_+"@J_\"\NO]Z='+_L:RG_STX
-M,O^*@7K_3DQ%_V5>6/^,AG[_1$$V_Z&@F?\N+RC_JJFB_RPK)/]>8%?_0$0[
-M_T-'/O]!13S_6%]3_Z6>DO_)KZ;_Q:J?_\JRJ?_*LJG_Q["D_\JSI_\[+RO_
-M/CH\_Q\=(/\M*BG_2$E#_TI+1?]24TW_4E--_TQ(1O]+1D;_&147_Q45&/\7
-M$A3_%@X8_Q80'O\7%1[_%A,J_Q41*_\7%2__&ALT_R$://\>&"S_'1P;_R4D
-M(_^(@X?___+R_\V\MO\@'R;_%ALA_T-!/O\E)"/_%A06_QH8&_^,?W[_FHR-
-M_R$7&O\@&R'_.C\__S4W-?^_NK7_\.'<_^W?W/_CU=+_VLK'_^'1SO^RJZ7_
-M/T$__R\Z._\N.CG_+3DX_RTY./\N.CG_+SLZ_RTX.?\N.3K_-#] _S(]/O\N
-M.SS_+SP]_R8S-/\@+2[_'2XD_R$E-/\;*BG_,#@Z_R4]=/\H,TS_'R A_RDF
-M)?\I*2;_2DU'_SH^-O\V-SC_%R$P_Q\[9_\0/(#_'D!__RH]9_^?FZ/_0S@W
-M_R<E*/\K)B#_GYV6_S,N*?_KW-W_[]C9_RLF*O_/Q\O_Y,[/_[ROJO_)O[O_
-MM[&O_TY+2O_;TLS_M*RH_\G P/_6Q\+_T,"]_\W%R?\H*"O_R<&__]/%PO_!
-MO;O_.3TU_Z&8D?\K,B;_M*RB_T,],_^.C8+_H)Z7_UU;5/^LIZ'_0CLU_U]?
-M5O])3$#_8&-7_U583/])3$#_P[>N_]2YLO^LEH[_OZ:?_^'(P__:P<#_T[V_
-M_QL4%/\?'!O_7UU:_R8D'_\[/SW_+"\P_SL^/_\W.CO_.3T[_UY@7O]?8&'_
-M2TM._Q00&/\4#QO_#Q00_QD7*O\6$2W_%Q,M_Q44,?\3$C?_.35+_S,R.?]$
-M1D3_0T5#_]'(R/__\_?_SKRY_Q\<*?\<'RO_3$E(_QP;&O\9%QG_&1<:_QP6
-M'O\@&B+_'!<=_Q@6&?]'3$S_/3\]_[^ZM?_LW=C_\-W7_]"]M__HU]'_X-'+
-M_ZNJH_\Y0$#_+SL__R@P,O\L-37_*34T_R@T,_\G,S+_)"\P_R,N+_\C+B__
-M(BTN_R8Q,O\K-C?_*C4V_R<R,_\L-BW_-459_Q >)_\?(23_+4A^_RHT3_\C
-M(R;_+"@J_R\M)O]85TS_8V)7_UQ85O\-%B?_#"91_Q$Z?/\>1(+_)SE?_[*M
-ML_\K)BC_'ATC_R0?&?^<G)/_,2\H_^[BW?_QV]S_.3<Z_\K$R/_?S,S_N:RG
-M_\&WL__ NKC_4D]._]K1R_^\M+#_NK.S_\S#O?_6R,7_SL;*_R4E*/_,Q,+_
-MVLS)_UM34?\Y.#'_P;VU_R(G&_^ ?7+_.3PP_[>\L/]=6%+_I9Z8_YB/B?]Y
-M;6C_1$0[_U)52?]*34'_14@\_V%A5O_&N*__[]/,_^#'P/_ERK__\-?0_]+#
-MP_\@%A__%1 6_Q@4%O\E(B'_+RTJ_Q83$O\U,3/_0S]!_QH6&/\F(2'_6%-3
-M_W5P<O^+A8G_$AT8_Q@4._\L'UK_'!I!_Q@9,O\3$"W_&18Z_R<E1O\R,$#_
-M)B4K_R<G*O\H*2K_V,K+__[O\/_&M+#_/CQ%_R0H,/\8%A/_&!<6_Q43%?\5
-M$Q;_HIV?_Z^GJO\9%!C_%A89_R4J*O\U-S7_M;"K_]S-R/_@T='_CX:&_VIE
-M9?]=7%O_24]+_RLV-_\N.C__+C8Z_RHS,_\J-C7_)C(Q_R(N+?\F,3+_(BTN
-M_R(M+O\C+B__%AX@_QLC)?\=)2?_("@J_R\Q*/\D0%O_#!<O_R$='_\@.W'_
-M)"U+_QH9'_\C'B+_'QL9_SDW,/]*2$#_3$='_Q49+O\<+5'_'3=C_RE :O\?
-M*43_6E18_R@E*_\?("?_'AH<_R0B)/\H)B/_YMS8_^_<W/]#0T;_:V9J_]C)
-MR?^_LJW_MZVI_\2^O/]13DW_T\K$_[VSK_^HI:3_RL6__[&EH?_$O,#_+2TP
-M_[>OK?_>T,W_,R@G_Z&<EO]45$O_:FI?_\"VK/\V.R__G:*6_T$_./^[NK/_
-M03\X_ZZIH_]45$O_.SXR_U993?]254G_3DU"_]?'OO_TU<__ZL_(_]:_NO^I
-MEY/_2#\__Q,0%O\5$AC_&108_Q<3%?\P+2S_%A,2_QT9&_\G(R7_&!06_QP9
-M&/\M*"C_3DE+_YN5F?\/"S__IZ+,_[:SO_^NH]C_%!$\_R >/_\I)D/_8F-N
-M_SH[//\F)BG_)",J_RPL+__2RLC___+M_X1R:/\6%!?_%!8;_UY=5O])1T3_
-M'!@:_QP7&_\B%13_'1$,_QL6%O\4%!?_$Q@8_RDM*_^KIJ;_W]#+_[*KJ_\P
-M-#;_*C(T_RLX.?\J-C/_+SP]_RHV._\K,S?_*3(R_RDU-/\D,"__)# O_RHR
-M-/\J,C3_("@J_Q@C)/\:(B3_("8H_R@N,/\F+"[_+"PC_QP[7?\'$R[_'148
-M_QTW</\G,U+_)R4H_QX9'_\D'R/_'QP;_R0C(O\H)BG_(QPC_QT;)/\C(RS_
-M(R ?_QP=*/\H(R?_)B4K_RPH,/\S+#/_+BDM_S<U./_5S,S_Z-;3_XZ/D/^9
-ME)C_U,7%_\>XL_^NI*#_QKZ\_UY96?_,PK[_D(J(_T=(2?_'Q<#_,BHH_\S$
-MR/\D)"?_N+"L_]C*Q__.P<#_A'UW_R(D&__*QK[_2#PU_ZRLH_^LK*/_,"\H
-M_ZNLI?\W.S/_D)*)_S\_-/]$13C_<7%D_V9G6O^1BX/_V,6__]["O_^ID8[_
-M)Q@8_RD=(/\2#0__$0\,_RLK'/\R-1__,30=_R\S'?\N,"W_,C,T_S$R,_\Q
-M,C/_*BDH_Q43%?\8%AC_3DQ/_Q48._^AG+;_9F%<_Z>BNO\<&S__(R(__UM;
-M;O\S.#+_.3TU_R ?)?\K*#3_961J_\C"P/_TZO3_5T9&_R4A*?\;'27_'1P;
-M_QD7&O\;&![_&Q<@_QP8(?\;%Q__&18<_QD7&O\@'B'_&QH9_QH8%?\R*"O_
-MVL[*_TE24O\U/4'_-3T__S$\/?\O-SG_*C(T_R<O,?\?)RG_&R,E_QDA(_\9
-M(2/_("0F_QP>(?\7'1__&2$C_QHE)O\>*2K_(2PM_R$L+?\N-2G_-TEE_Q$9
-M*?\:&1C_(BQ._RLT1?\@(B#_'AHC_Q\A)O\B)2;_(R8G_R@M+?\P-3/_,C4V
-M_S0S.?\\.$'_/C8Y_UA33O^&?GK_M*BK_\&\OO^FFY3_1T1*_^3=W?_RV];_
-M>71T_]K2U?_9R,C_T+NY_X)Z=O_$N+G_)B$C_\+!P/]03E'_-#8[_[^]O_]?
-M75__O+&X_RLG*?^[LJS_WL[+_V%95_\V-2[_R<6]_V=F7_\_.C3_P[JT_SDW
-M,/^NHIW_;&9>_SHZ+_]T=&?_:6=8_X![:?]W;UO_='!A_RXI)/\@&QO_$PX2
-M_Q$0%O\3%!7_&!4;_Q@2%O\7$@S_-S$A_SLW(?\T-"'_-C0L_Q<6%?\D(B3_
-M)"(D_R$?(?\7%1C_$A 3_Q,3%O\?(23_!@HP_S<N8_^TH]G_13AK_U%,9/\<
-M&27_/D%&_QL@'O\M,2__G9VF_WMYB?\J*S+_Q+^Z__#F[_]"+B;_-RLD_S0K
-M)?\\+2?_138P_S@K(/]$."G_3CTP_U5"-O]92#C_:UM(_W9<3O^#9TS_@VY1
-M_X5\=?_AS\S_RL;(_S<Y/O\C*2O_(RLM_RPR-/\G+2__)2LM_R(H*O\:("+_
-M(RDK_P\5%_\C)2C_#Q$4_QLA(_\9(2/_&R,E_Q\G*?\B*BS_)2TO_RD]+O]H
-M;WO_)R,S_QTF+?\@*4'_)3-*_Q8A,O\].#[_0S\]_W!L:O^FGIS_R[Z]_]7*
-MR?_FU]'_[=?/_^[3TO_MV-;_Z=;,_]G)O_\G)"/_*"LP_Z"7D/]84U7_Y-O;
-M_^S4T?]Z=77_T<G,_]C'Q__9QL;_(R ?_[^ZO/].3E'_@X%\_YJ6E/^;F9O_
-MR\?%_W9W<?_!N+C_*B8H_[JQJ__@T,W_L*BF_\' N?]H9%S_/#<Q_ZJHH?]3
-M3DC_-C0M_\"[M?\R+B;_P;ZS_WIW:_][>6K_?WEI_WQV9O\\.C/_-#DU_P\5
-M$?\@)"+_&QP=_R(@(O\H)BC_)R8E_R@F(?\W-3#_'1H5_R0@'O]*1T;_$A 3
-M_Q(0$_\7%1C_$A 3_Q84%_\5$Q;_$1$4_Q@:'?\]0C[_(R<V_UQ><_^=D8S_
-M;&-=_TI%1?^1E)7_,SP\_T9+2?^1D9K_'APL_R@I,/^0CXC__^_B_[R2:O^Y
-MCV'_K8E<_ZZ#5?^WBU__M(E9_[2+5_^WBUG_O(Y;_[>*5/^WBU/_O8E7_ZF
-M5O^1>5[_V,J[_^31R_\L+2[_$Q4:_Q(6&/\6&AS_$Q48_R@J+?\0$A7_)RDL
-M_QD;'O\F*"O_%!89_R4G*O\1$Q;_&R$C_QHB)/\?)2?_(2<I_R,I*_\I+S'_
-M+#LZ_R B*?\@+D?_.DEL_RDY9?]37X3_SLC6_]_-R?_IT,O_\-31__79UO_U
-MV=;_\M;9__36U/_KU,__X]O?_XV/GO_/Q\O_3CPX_S(Q-_\7(BG_GIB._W5K
-M9__EV=S_\-C5_WUX>/_*PL7_V<C(_][*QO^*A7__S\?#_W=U<O_*QK[_?G=Q
-M_XZ*B/_(O[C_;V]F_[^WL_\C(!__N[&M_][.R_]_=W7_3TY'_SHV+O_!NK3_
-M?7MT_S$P*?^SKJC_34Q%_WAV;O^!>6__=W)F_WYZ:_][=&;_;&9<_Q\='_]0
-M3$K_4TM'_R$;&?\@&QO_+BDM_SP\.?]04TW_-#<X_Q\C(?\;'2+_$@X6_QP8
-M&O\;&1S_&18<_QH7'?\6$QG_&!89_Q@6&?\6%AG_&!H=_U!$6?]%/DC_8%Y9
-M_[FGL?\N(RC_GIN:_Y^@H?\C)B?_*"PJ_XF)DO\G)37_)R@O_S0X-O__\./_
-MS)UM_\J:9__+G&7_PY1:_\:46__"D%?_P8]8_\"35__ CUS_P8Q6_[Z04_^I
-M?4O_1B\8_V%C8?_,Q<7_W='-_QXG)_\0%1K_'1\D_QP@(O\8&AW_)RDL_Q08
-M&O\G*RW_&1T?_RDK+O\5%QK_*"HO_Q(4&?\=("7_'B(D_R,H*/\L,3'_,C@Z
-M_RLP-?\]0TO_H:*M_R@]6O]=9H__V<S?__#9VO_UU<O_\-G:__#:V/_QV=;_
-M[MS8_^_@V__MX=C_X]C7_UUEA?\^49?_+4Q\_[W#T_]01$?_3DQ5_QTH+_^?
-MF8__?G5O_^79W/_LT]+_4D]._T(]/__8R<G_YM',_YJ/A/_+P;?_*B@A_[^Y
-MK_^.A7[_=W)L_\:^M/]>7E'_@'IR_R(@&_^QJJ3_X,[+_X1Y>/^HHYW_M;&I
-M_S(P*/\V-2[_O;RU_Z2?FO\C)!W_F96-_W%E7/]U;F+_:V9:_WET:/\@'1C_
-M'1\B_QD7%/\^/3;_,#,M_TU33_]G96?_8F)?_T9+1?\I+B[_(BDI_RHM,O\8
-M%Q[_&QD;_YJ2E?^@F)O_HYN>_ZZFJ?^SJJK_N[*R_[RUM?_$O[__Q,Z]_UM@
-M6O]866#_J[.O_RLM,/^6DIK_,2PP_S8R-/]W=7?_B8F4_R0B,O\='B7_+3,U
-M___T[O_4FV'_S)YQ_[Z%0__"DUW_OY!6_\256__ D5?_OY%7_[^,5__!D5+_
-MDFQ%_RT;#?]<4U/_8&!7_]+'P/_=SL__*S$S_RTR./\^0$7_)2DK_R8H*_\M
-M,S7_(BHL_R0L+O\6'![_+# R_Q06&?\I*S#_%!,9_S0S.?\A'R+_&!X@_R,K
-M+?\F+C+_*S V_S@T-O_4R<[_X,_7_^G7U/_MV='_\=K5__'9UO_SVMG_^-S9
-M__/7T__AR<;_^./?_Z.9E?\V,T#_)52._QXS@?\K4XK_P<+-_U=05_\G&"/_
-M='AZ_Y^7C?^'@GW_W=/6_][)SO\9'1__F9>9_\[ P?_8Q\?_9EE4_\_)P?\H
-M)R;_14(]_X)[=?\^/#7_6UI3_T$\-_\3$0S_# H'_ZJBH/_.P\+_Q+RX_U!.
-M1_] 1#O_6E1,_[:JI?]*0SW_+"TF_[>PI/^">&K_E8N _Y2)?O]A64__+RTJ
-M_S@[0/]A8V;_8F5?_U-43?\R,2K_3$I#_RXL*?\R-#+_(RHJ_QD='_\;'2#_
-M%QD<_Q\A)/\M+S+_EXV)_Z&4C_^CEI'_FXZ)_Y6,AO^1B(+_C(-]_XR#??^$
-M?7?_*B8H_V%A:O^VLKO_,BXV_XZ+D?\6%!?_$ X0_X5_@_]Z=8'_*BDZ_RDI
-M,O],45;___'K_\6,4O_ DF7_SY94_\*37?_)F6+_R)AA_\657O_*EU;_R)EI
-M_V!%(/\F&A7_(AP@_R$?*/]/3TS_S\.\_^?6UO\O,S7_%QD@_QT<(O\C)RG_
-M&QT@_R,I*_\P.#K_*"\O_Q@='?\K+B__&!D:_SL\-O]&24/_*3 P_QDC)_\<
-M(R__(R8Q_S8S.?_1R,C_Z-;2_^W:U/_VW]K_^-_:__+<U/_SW-?_]]O8__;7
-MU__LU-'_QK&O_R49'/\O*3'_9FAO_Q 4*?\A5Y'_)#N(_R-,B/^]O<S_7UA?
-M_VA79_\?(B?_HIJ0_Y"+AO_=T];_V<G-_SI!0?_%PL'_WLO+_\F]OO\Z-S;_
-M'!T>_QX;(?\G(B;_)" B_QP:'/\9&AO_(!TC_Q@8&_\7%1C_<6=J_XN#AO^>
-MF9G_='!N_ZNHH__.O+C_+B@@_R\R)?_'O:[_GX]\_YN.??^1B('_75Q;_TY1
-M5O\Y04O_-3]*_SD^1/\I,2[_+S<S_SY#/_\\/CO_(R(A_RXS,_\G+S'_*2XS
-M_QTA(_\A)RG_'R<I_RLX.?]B9&?_<G!S_VUK;O]H9FG_8&1F_UA>8/]46ES_
-M4%98_U%24_]/3E7_9F9U_Z^IM_]X='W_B(6+_X:$A_^IIZG_BH2(_W]ZAO\E
-M)#7_.#A!_VQN<?__].[_UYYD_\Z@<__6G5O_S9UJ_\J99/_,FV;_S9QG_[:/
-M7O]@/S__'1 C_Q\A'_]64$C_:F1H_S] .?_3Q\#_Y]/5_S@Z/?\='"/_&18<
-M_RTQ,_\V.#O_)RTO_RDQ,_\M,C+_%!@6_S4W-?]%1$/_+B\P_Q04%_\;'2#_
-M*BPO_U-.5/_/Q,G_Z]C8__3=V/_WW-7_]]W2__;<T__YW=K_\-?2_^_8T__J
-MU='_II21_WEQ=/\S+C3_+2\W_VYT?O]M;W+_'B O_QA,A?\A/(G_)$R*_[Z_
-MRO]\=W?_(Q,A_Q 3&/^:DHC_AX)]_]#&R?_?R<O_FYV;_\G%P__4Q,'_V<K%
-M_SLS-O\5%Q[_&!@;_R4C)O\>'B'_(2,F_RDM+_\H*C'_3E%6_Q46%_^1B8?_
-MT\# _]"]O?^DF)3_3$,]_T-$/?]35T[_BH1\_YR+A?]I8V'_6EI=_SQ$3O\W
-M1%7_-T=;_S%"6?\Z25S_,SQ#_RHP,O\A)RG_-CH\_Q88&_\G)RK_,C@Z_S,_
-M0_\K,CC_+CH^_RPW./\9(2/_*"PN_]K2U?_;TM+_X=C8_][5U?_HV=K_Y]77
-M_^C6V/_GU=?_]./C_]3)SO]X<W__L*VY_WIV?O^ ?8/_L[&T_ZVKK?^"?(#_
-MA'^+_R<F-_\E)2[_;&IL___RZ?_?J&[_Q)EM_]VF9O_'FVG_SIIH_\.06_^_
-MDFG_0!\W_S$B0?\-%!3_'1L=_YF)@/^-@7S_3DM _];)Q/_QV]S_-#<X_R ?
-M)?\:%QW_+# R_Q,5&O\A)2?_'",C_S U,?]$24/_,C(O_QH8%?\H)R[_&Q<?
-M_VYE;/_=SM+_]-[<__G?W/_XW-C__^#<__C<V/_XWM7_]]_6__'8V?_QU]3_
-M;EI6_S$H(O\M)Q__+"@J_RTD'O\J(1K_-3 K_R@B&O\<'2C_'4R"_RA&D/\F
-M38C_O<+(_Y:4C?\D&2#_&!H?_X^)?_^'A'__R\+"_]W$Q?^\M;7_R,+ _]'$
-MO__9Q+__64Q+_R@L+O\B)R?_'R(C_Q<:&_\?)"3_+S8V_Q,8'?\3&1O_%1D7
-M_S<R+/_.P;S_P;FU_SD[,O][A'?_CXV(_RX@'?\<%!+_#1P<_R] 3O\U157_
-M-TMA_S)'8_\N0U__,49>_S%"6?\T/$;_%A@;_Q06'?\Z-SW_&18<_Q<9'O\O
-M-SO_'2DM_R$J,?\C,33_(S Q_S R-?\K)2G_Y]//__+;UO_OVM7_]^+=__?B
-MWO_ZY>'_]>#;__?BW?_]XMO_S[FZ_VAB:O^IJ[#_D8V5_WY[@?^XM;O_IZ6H
-M_VUG:_]Z=X/_(R0U_R@I,/\I)RG___7K_]FE;/_-IGS_VJ1A_\JA8/_%E5[_
-MO91C_Q\- /\@&#K_,"I&_RHI,/\\/#G_3TI%_SDT+O\]-3'_U,3!_^W9U?\V
-M.SG_(R@M_R0D)_\M,C+_%AH8_S$S,?\_/CW_+3(R_R(F*/\G*2S_'1@>_VQF
-M9/_$M[+_[M;3__'7U/_VW=C_\][9__'>V/_XW]K_[MO3__G<V/_BT]/_4DI.
-M_QT;)/\L-TC_'"(L_VMB6_\@+$G_*20D_R<I)O\S/5+_)R<T_Q@M1O\]:)S_
-M,UB9_RU+@__$QM7_GIZ;_QT5&/\9%QK_@H5Y_X>%@O_)O[O_ULC%_[ROM/]J
-M8&/_T<7!_\R]N/]M9V7_)B@K_R(G+?\V.3[_)BHL_TI.4/\[/T'_1TQ,_SL^
-M/_\@(2+_'QT?_];*S?_&O+__&A88_QX:'/\Q-CO_*B0H_Q8>(O\N/TW_,3]8
-M_SE#3?\]4&+_,$1@_R8S1O\1%Q__.D=8_RXY1/\=&AG_*S \_RPL+_]A863_
-M+#0^_S=!1?\@+"O_+#4[_R0Q-O\K-SO_)BPN_RTK+?_GV-/_[]K5__+=V?_U
-MW]W_^.'B__;@WO_VX=W_^.'<___GX/_FU=7_<G%X_ZVOM/^9E)K_<6QR_["K
-ML?^HHZG_@GU__UI<9/\?)C3_,#$X_XN,C?_]\.O_X:MQ_\ZC<__=HU[_VJ=K
-M_ZV%:_\H&Q;_&!,7_Q )%?\8$QG_-C,N_SDT+_\Q*2?_&Q<5_S K)O_+O;K_
-M[=O8_SD^/O\<(2?_(!\E_S$W+_]'2T+_,S0N_QP9&/\I)2?_)R @_XU_?/_8
-MP[[_[MC/__?=U/_[W]?_\]W4__C>U?_TWM7_\N+8__7BV/_AS\O_V,7+_SQ$
-M5/\M057_.T5:_R=!;/\7("[_GY.$_R Q5?];763_%QXD_QLS6O\C,$G_$BQ-
-M_R=6C?\L69G_,4V&_[Z^S?^NL*W_0#@[_QD4&/^!A'C_@'Y[_\:\N/_5QL'_
-MNJZQ_X%Y??_&O;W_R;V^_T1 0O\/%1?_&!HA_R,G*?\3%QG_%!@:_Q@<'O\1
-M%!7_'A\@_S$O,?\Y-3?_-C$W_S@Y0/\W.4#_'!LB_R8O+_\B(2?_'2HW_RT^
-M5O\Q/E'_)2HO_QXH-_]%3V3_EI6;_ZZII/]W?HK_,#I(_[*MK?\Y/TG_04)#
-M_]'-S_\P-#S_-3U!_QLD)/\L,SG_("TR_S$]0?\8'B#_%187_]_0R__RW=C_
-M]=O8__G<V__WV]W_]MW>__#9VO_OVMC_[]G7_YJ.D?^$AHW_J*NP_Z";G_]F
-M867_K*>K_Z:AI?]S;G#_$1(=_R F-O\N+C?_H9V?__SPZ__=IVW_RJ!R_\:7
-M7?^ND'K_.2(S_QX7-?\K)$+_*"$S_QP7'?\?&AK_(!D9_QH3&O\=&!S_*24C
-M_\["O?_SW-?_/STZ_SDW.?]A6EK_-C@U_QP<&?\G)2+_+RHJ_YB,A?^FEHW_
-MT[VT_^_3R__ES\;_\-C/_^W1R?_LULW_\M;3_^+)R/^RH)W_N*:C_T8Z-O_6
-MSMC_-$=9_S1.7/\[/DG_.%:"_Q\?(O^QFGW_)3MB_T-%3/\Z/S__'#%4_Q8@
-M-/\@,D[_%SAM_R=,C?\L0'K_N[G)_X**AO\D("+_&!,7_W=Z;O]V=''_M:NG
-M_]?'OO^^L;#_8%M?_U)-3_^PJJ[_B(J/_R$F*_\<'R3_&1T?_RTQ,_\R-CC_
-M)RLM_R4F)_\>'![_'QL=_YF4EO\X-SW_1DM1_R\T.O\7$QO_("0B_R$>)/\A
-M+CO_,$!0_SD[0_^IHJ+_H**Q_TU79O][>W[_YN#>_Y*9I_\V/TW_P[BW_S@]
-M0_\Y/CS_S,C&_S<Y0?\Z/T3_&B$A_S U._\3&B#_'B,H_RPJ+?\I(23_Y]//
-M_^W8T__KV=7_\N3A__KDW/_VW=;_\=S7_][,R/_IU]G_24-+_WR%C/^8FZ#_
-MI:.E_TI&2/^DH*+_HIZ@_WES=_\G)S3_(R@Z_RPL-_^MI:C___+I_]FC:O_
-MEVW_?5PX_QT;%O\1#AO_%!$>_QD1)?\T+D+_$ T9_Q84%_\8$QG_% T5_Q(/
-M%?\K*"?_Q;NW__#6S?^KHIO_:V5C_R,9%?\E("3_&10:_Q,.$/\<%Q?_$@T-
-M_R(='_\?&!__(QPD_RH?'O\T)"'_.",A_RX<&?\G&1K_(AT?_QTB(/]U>7?_
-M0T5#_];1T_]::WO_&B8J_Q89)/\F3H;_&A\K_W)B4O\=-%[_<W-\_U953O\B
-M,$?_7&)L_RDP1O\+'TS_(CQ[_R@Z=/^XM<?_76-?_S<X.?\4$A7_='9M_U)0
-M3?]G7UO_T<*\_[JOKO]*2$K_B(6$_XB#A_]*3%'_+#$V_RTP-?\E*2O_*2LN
-M_R$C)O\3%A?_&QT;_Q\='_\?&QW_BX2$_S,S-O\Q-#G_*R\Q_Q@3%_\4$@__
-M(!L?_QPF,/\@+#/_O;>[_^C;VO]\?8[_/$Q6_W%X?O_?VM[_-SU-_S8]2__'
-MN[?_049,_SD_.__8TM#_,C,Z_S(U.O\K+S'_*RTT_RHJ,_\;'2+_O+2X_X1X
-M>__CSLG_D7UU_SXU+_]&1#__\N'4_Y^'>/^LFHS_@W=N_]_0U/]!0$?_769M
-M_T!#2/^;F9O_&147_YJ6F/^GHZ7_<&MO_R(B,?\E*#K_+R\X_ZZFJO__[M;_
-MQYMS_SX>!/\<%17_&108_Q40%/\7$A;_%A$5_Q,1%/\6%!?_%1,6_Q43%O\4
-M$A3_%!,9_QD4&/^^LJ[_Z-7-_VI=6/\E'!S_2D \_TI%1?\9%1?_%A(4_QH6
-M&/]12T__-2\S_R8@)/\Y,S?_%A$5_Q<2%O\9%!C_&A49_QL9'/\5&1O_.D1!
-M_U%64/\R-T/_[-O._S5#6/\G(R'_$!8F_S1:C?\;&RK_4T X_QTI1O\9'"[_
-M&AH=_Q4=,?\;)3#_'2 Y_Q <.?\C-V3_(#UW_ZVQQO^2C8__+2\T_Q89&O]P
-M<F__-#4O_TA&/__+N[C_KZ6H_RDK*?] .S7_N[.O_XF$A/]]?G__*2TO_QL?
-M(?\>&R'_)R(D_TA#/?\9&A3_$1$4_RDG*O^&?GS_+RTP_Q,6&_\0$Q3_*BXL
-M_V=F9?\P,3+_'2 E_SD^1/\U,S;_+2PK_T!#5?\Q04K_@I"/_]W9V_\P-$G_
-M-D!/_[^WL_\U.D#_/$$__\W)Q_\O,3C_-C<^_SX^1_\G*C7_)24R_QDB*/^'
-M@H3_M:ZU_][3R/^&<67_4U)'_RTL)?_?T,O_CGEM_ZF8B/]H9%S_TL+&_S]!
-M2/\V.D+_0T)(_YB6F/\B'B#_E9&3_Y>3E?]J:&O_)24P_R$C,O\T-#?_K:BN
-M___MX/\L'P[_'QPB_QT:(/\A'AW_'AD=_QD4&/\9%!C_%A07_R >(?\O+3#_
-M-S4X_SD[0/\_0$?_5E%7_\:YM/_NV]/_BGQY_T4V.O\I%QG_%@\/_Q,/$?\8
-M%!;_7%A:_VME:?]=5UO_2$)&_UM56?]54%3_%1 4_QX9'?\2#1'_C8>%_ZVE
-MH_^]N+/_N+"L_Z6DJ__"L:3_4F)\_R,@'_\3&2/_1EN+_QD;(_]>4TC_$Q@Q
-M_QH<*_\2$A7_%ATK_RHS.O\5%RS_#A4I_Q ;/?\C07G_HZF__XJ"AO\I(2O_
-M%1,6_V9E9/\B(A__,S0N_XZ%?_^BG)K_%Q47_RHG(O^(@'S_C(6%_Q\:'/\9
-M%QK_%A06_Q04%_\8%13_,28?_V5=6?]84U?_-#(U_XB ?O]544__@()__X:(
-MA?\W/#C_&!L@_V-C9O]N:6G_L*RN_[VZN?]W=V[_.SY#_SA#1/]\B(7_W-C:
-M_SD]4O\Q.TK_OK:R_S,X/O\^0T'_S\O)_S(T._]"0TK_-S= _RTP._\E*#/_
-M(RTQ_[RSL_^VJ[#_X-/&_XAN8/]223O_8EA-__'<U_^/>F[_G(]^_VEC6__4
-MQ,C_.#I!_S@\1/\^/4/_D(Z0_R <'O]>6ES_-# R_VUK;O\F)C'_(2,R_S,S
-M-O^OJK#_^-?H_Q@:&/\6$AO_& X7_Q02%/\5$!3_$PX2_Q@3%_\Y-SK_/SU
-M_TI(2_]%0T;_0$))_T-%3?]'0DC_T+^Y_^W7S_^$=7;_(!@<_QP7&?\7$Q7_
-M&!06_R\K+?],2$K_6U59_TQ&2O\4#A+_(QTA_S$L,/] .S__&A49_Q0/$_^Z
-MKZC_Q;&I_Z")A/^ ;&C_:V-F_[BFF/\S1F3_&!D:_Q(7'/\C)E#_%1@=_UQ8
-M2?\:&"O_'1TH_QH8&O\6&"#_(RPR_Q86)?\4%A[_&!PQ_R(Z:_^4EZC_I)N;
-M_T,^0O\<%AK_03Q _QH8&O\;'1K_2DA _Z&>F?\:%AC_+"LJ_T! /?\R+R[_
-M$P\1_QH5&?\>&QK_*"PJ_VEI9O]B4DG_MZJE_\*ZOO\E("3_9U]=_Y^7D__B
-MWMS_<7-Q_TM/4?\V.#W_7UI5_V)64?]/35#_6%)6_TU-0O]+2DG_&1P=_W5^
-M?O_=V=O_/$!5_RHT0_^_M[/_1$E/_S@].__/R\G_*2LR_ST^1?] 0$G_*RXY
-M_R8L-/\9)"7_P;:U_\*RMO_CU,[_=5U4_U!&._];44/_Z]3/_W]L8/^+@G'_
-M9F!8_]3"QO]!0TK_.CY&_T5$2O]^?'[_(Q\A_Q\;'?\B'B#_:6=J_Q@8(_\5
-M%R;_3$Q/_[*ML?_YV/?_%A$5_R$1%?\=#QC_%!(5_Q40%/\8$Q?_%Q(8_PX)
-M#?\U,#3_1D1'_U!-4_]&1U+_5EED_TQ'3?_&M:__Y]+._XQ_?O\;&1O_%1@9
-M_Q43%?\8%!;_&A88_Q82%/\1"P__#@@,_R :'O\;%1G_% \3_R ;'_\4#Q/_
-M'AD=_S\^,_^]M*;_P+*I_[RVKO_'O[O_JIN._TA;>?]34%;_&A\?_RLF2O\<
-M'B'_6%9'_QX8)O\?'2;_&1<:_Q04'?\E+#+_$Q8B_PP-%/\:&B?_#!I!_T9&
-M4?_ N;/_)B@F_QX9'?\6$17_%A89_Q(5%O\E)A__5E-._R,?(?\A(R'_)"DE
-M_S]$0O\?(R'_4U%3_VYL:?^*B8C_'1\=_XMX;O_(M+#_UL?+_R,=(?]:5%+_
-MP[V[_^+:W?^!?H3_*"HQ_R ;(?]Q96'_?G-L_SH\0?\7$AC_6%9._S0Q,/\Z
-M.#O_;7%S_]G6U?\Z/U'_,3M)_\*ZMO] 14O_.3X\_\C#P_\G*RW_/D!#_T9'
-M3O\H*S;_,C8^_Q<B(__#N;7_QK2V_]?.R/]20SW_0CXV_U!(/O_LU-'_<&%4
-M_W9R7?]A6U/_U</'_T5(3?\Y/47_-C,Y_V]M</\E(2/_'AH<_R <'O]U<W;_
-M@'^,_RPM/O\Q,SC_L*NO_^W;Z?\B&"+_#Q 7_Q 2%_\:%1?_&106_Q40$O\9
-M%!;_(!H8_S(N+/]*14G_.S<__TM(5/])25;_.34^_[FLJ_]K75[_2T,__V]J
-M9/]?6UG_%Q(6_T5 1/^CGJ+_&108_R4?(_])0T?_A'Z"_V]I;?]G867_9V%E
-M_X!Z?O\>&!S_+RHD_ZF?E?^/@7C_:V-9_W%@6O^2C8C_0%-E_R$9)_\9&1S_
-M(R$T_R A*/]F85O_%A(:_Q\?*O\6%B'_'AXI_R<J-O\M,#S_%!0A_Q03(/\7
-M&2[_'R$I_X>$@_\6&!W_&1@>_R<E*/\P+C'_'1L>_QX='/\M+"O_-#,R_T)!
-M0/\N+2S_*RTJ_WA]=_^@GI?_CHB&_^#5VO\;'!W_;5Q/_]W(P__MU=K_,2DM
-M_T$\//^UM[7_XMC;_X:$A_\R.C[_'1LD_VID:/]H96#_4590_VEG8O]$03S_
-M8U]=_R4B(?^)B8S_X]W;_SQ 3_\\1E3_M[*M_T%&3/\]0$'_H)ZA_S Z-_]
-M1D+_24A._S8Y1/\I*C7_(BHL_\2YN/_$M;G_V<W(_TU$/?]!.S/_4D= _^33
-MT_]<4DC_9V13_U=*1?_5P,;_1$=,_X&$B?]V<7?_6%):_U505/\=&AG_'1@>
-M_V]J;O]Q;7W_*"E"_RPN-O]I;&W_XMCA_R@C)_\>(![_,S$L_S<S,?]!/3O_
-M3TI%_U502O]&03O_03XY_T9$0?\\.CS_*BDP_S(S/O\X-C__,BLK_]7(Q_^H
-MGYG_=G!H_VED7_\=&!K_(!L?_Q(-$?]P:V__'1<;_T$[/_\;%1G_65-7_Q80
-M%/\E'R/_:6-G_QT7&_\='AC_96-<_Y")@_^;FI/_C7MX_Z:<F/\_4%[_%1,C
-M_QD;'O\@'C'_&1DB_R4C(/\M*S3_+2TX_RLK-O\E)3#_("$L_R8G,O\4%!__
-M$Q <_Q@7*/\<'2C_6UU@_R,B*/\D(A__-C,N_T9#/O]"/SK_/CPY_QX>&_\_
-M/SS_0T- _R0B)/\?(1__/T1 _V=D7__-R,/_ZMO@_R<G*O\]-2O_U\; __/;
-MX/\G'R/_-"\O_[BUM/_AU=C_EY>:_TM56?\6&!__)R@I_VUL9?]+3T?_8F-<
-M_RHK)?]?9&#_45E6_XJ.D/_AV]G_/T-2_SQ&5/^ZM;#_049,_T!#1/_+R<S_
-M.$%!_T%&1O]*25#_,30__R@J,O\D+"[_P[BW_[ZOL__/QL;_0S\]_SLY-O].
-M2$;_V-#3_T='1/]04TW_249%_]/"RO]15%G_MKF^_VED:O^DGJ;_)B$E_VIG
-M9O^AG*+_<6QP_W=S@_\L+4;_+C X_V%@7__GVMG_/C@V_S8U-/\Y-SG_/3]'
-M_QXA+/\;&B#_(Q\A_S(K*_\U,#+_.S<Y_SLZ.?\S,S;_+2TV_S<Y0?\J*"O_
-M:EU<_UI/2/]V;F3_AG]Y_QX9&_\8$Q?_'1@<_QT8'/\;%1G_7%9:_QX8'/\:
-M%!C_'A@<_R<A)?\F("3_(AP@_Q4.#O^>D9#_,R0D_R09&/\G&1K_3D=!_SA#
-M3O\:$R3_%!46_Q<4)_\I+#?_,3,V_R0D+_\='2C_(2$L_QP<)_\4%A[_$! 9
-M_Q,1&O\3#QC_%A,@_Q<:)?\H+3/_/#H]_S\].O\].S;_/3LV_S\]./\Q+S'_
-M'AP?_QH8&_\<&AW_'!H=_Q<7&O\8&QS_BX>%_]#(Q/_IU]O_*28L_S4S+O_4
-MQ\+_[]?<_RXF*O\Q+"S_MK&Q_^G9W?^8F)O_6&9I_YRDKO\3%AO_3DY+_WM]
-M>O]76%G_*RTP_RDS-_\X1TS_@XB-_]O5T_] 1%/_.4-1_XN&@?\^0TG_1DE*
-M_\O)S/\Q.#[_0D5*_SX]1/\I+#?_-3<__R@P,O_!MK7_OJ^S_]/1SO]#0T#_
-M04=#_UI:5__,RL?_3U%._UA=6?];75K_T+_%_TI-4O^TM[S_:F5K_YR6GO\F
-M(27_IJ.B_YV8GO]J96G_=7&!_RDJ0_\R-#S_B82(_]C0WO\3%B?_.4=<_Q$>
-M._]!3&7_*"]%_QL=+/\<'"?_(1HB_RTF+?\P*S'_,S$T_S0O,_\_04;_-CA
-M_SHX.__8R<G_S+VW_WEN8_]Y;6C_&A47_V!;7_]13%#_%Q(6_R(<(/\E'R/_
-M3DA,_UI46/^ >G[_,"HN_Q80%/\W,37_&1<9_QP8&O\B'1__'QT?_Q00$O\N
-M*2/_/45/_Q0*&?\3$13_$Q B_R$D+_\@(2C_'!PE_Q<7(/\<'"7_&AHC_R(B
-M*_\;&R3_%A0=_Q<3'/\5$A[_%!0A_Q49(?](24K_24M)_RHM+O\<'R#_&AT>
-M_Q@:'_\8%Q[_&A8>_QX?)O\F)2O_.#H]_QPA(?\Z.SS_O+FT_^?5V?\F("C_
-M+C(P_\*VL?_UW>#_*B(F_R\J*O^SK*S_V,O*_Z*=H?]7:V__FZ*N_Y>9H?\G
-M)BS_'ATC_R(F+O]E9FW_L;;"_T9=:?^"BY'_V]73_T-&4O\Z1%+_LZZI_T-%
-M3/\[/C__OKR__S$V//\[/47_0#Y'_R<K,_\N,#C_)2TO_X%Y=_^[K[+_W,K&
-M_][+Q?_>S<?_W<G!_^+)PO_0N[;_V,3 _]&ZM?_?R<O_4U9;_Z6HK?]74EC_
-MBH:._R4@)/^BGY[_FY::_V5@9/]P;G[_)RA!_S,U/?]N<WG_Y]3D_R,=*_\P
-M.DC_&R R_R$F./\8&RS_%14@_QL6'/\9%1?_'!@:_R<C)?\U,3/_0SP\_S8Q
-M-_\Q,#?_+B@L_V5=6_]P:6/_3$D^_TY+1O\B'1__&1,7_Q<1%?\4#A+_&!(6
-M_R,=(?\9$Q?_%A 4_Q\4&?\7#Q/_%Q$5_QH5&?\6$1/_)!\A_R0?(?\D'R'_
-M$A 2_QP7$O\,$1W_#Q,B_Q(.%_\8$Q__%A$=_QP7(_\<&B/_%Q8=_Q85'/\9
-M&!__'1TF_QL;)O\;&R;_%14@_Q(0&?\3$1K_%A4;_RPM+O\N,#/_&1L>_R,E
-M*/\F*"O_("@J_RHN,/\M+3#_*R\Q_RDJ*_\O+S+_'B(D_T-(3?]%2DC_T+_%
-M_R\F+?\H*2K_KJ*=__7=X/\I(27_+"<I_[RPL__2T<K_LZ*M_TIG<O]RAHK_
-M25QD_VYWA?]24E__5%QL_SY*4?]XDJ7_3FAV_WJ @O_;T\__:&=T_S [1O^@
-MGI;_0#]&_SM!0_^^NKS_+"\T_SD[0O]+25+_*RXY_R4H,_\C+S/_@7Q\_\>\
-MP?^GDXO_O:.6_["6B/_!J)?_R+&?_\VRH?_!I9?_R;*F_]O'P_]:7%__KK"X
-M_UA56_]U<7G_)R(F_YN9EO^/BXW_75A:_VMK>O\I+$7_-#0]_VA=8O_MV>/_
-M(A@A_QT<(_\='"/_*2,K_Q@2&O\8$Q?_'QT?_R0@(O\>&AS_'!@:_QH6&/\>
-M%Q?_)2 F_ST\0_\F("3_HYF<_[2NK/^)AH'_+"DH_QX8'/\4#A+_KZFM_QL5
-M&?]P:F[_*"(F_UM56?\W,37_F8Z3_V1<8/^"?(#_$PX2_Q40$O\F(2/_)R(D
-M_Q\:'/\.#A'_%A(4_Q(>,_\H-5+_$A$>_Q(/&_\4$1W_%Q0@_QL8)/\>&R?_
-M'QPH_QH7(_\@'B?_'QTF_QH8(?\2$!G_$1 7_Q(1&/\3$AC_%!,9_R$C)O\>
-M("/_.CP__SH\/_\4&AS_-SD\_U!+3_^4B8[_:V1K_X)]@_]"0$/_8V%C_Z6C
-MH/_IVMO_*R4I_RXN*__-P;S_\MK=_R8>(O\I)";_L*"H_\# O?^ZJ;G_,TQ=
-M_V9U>_]OA)#_;H:9_UEXBO]RD*;_;Y"<_V*-G_\H/$K_@H2'_]C0S/].35K_
-M.41/_UQ>5?\Z.T+_,S<Y_W)S=/\P,SC_/#Y%_T$_2/\R-4#_*RPW_R0N,O^[
-MLK+_S<#%_\"LI/^WG9#_LYF+_\.JF?_$JI7_S:^:_\.DDO_)L)__X,G$_W1U
-M=O^IJK'_7UI>_V9B:O\E("3_E9.0_XR(BO]E8&+_=76$_RTP2?\P,#G_KZBH
-M_^G<Y_\;$1K_)A\F_R ;'_\B'2/_)!\E_R<D*O\M*C#_&!,7_QT9&_\7$Q7_
-M%1$3_Q<0$/\<%QW_/3Q#_R0>(O]",CK_,2 F_R$5%O\F&R#_'!,:_QT7&_]-
-M1TO_&A08_Q<1%?\<%AK_*B0H_QP6&O\>$QC_% P0_QP6&O\7$A;_%A$3_QT8
-M&O\G(B3_'QH<_QL9'/\>&AC_$AHJ_Q8=,?\7%R+_&QLF_QL;)O\;&R;_'!HC
-M_QT;)/\>'"7_*2<P_RXK,?\P+3/_%Q0:_Q,0%O\3$Q;_$A(5_Q44&_\4$AO_
-M(B0I_SY 0_\J+"__*BPO_RXN,?]45EG_0T5(_Q</$_\7$QO_-#,Z_S$L,/]+
-M1D;_J:*<_^O8V/\J)BC_+2HE_\F]MO_KT];_+24I_S(M+_^SI*G_?()Z_[NQ
-MN_] 5&+_DXB/_[Z]RO]"5VG_1W*$_T=]A_^TO\;_8%AL_RY#3_]N>7K_WM;2
-M_TE(5?\M.$/_+#0J_TU.5?\[/4#_+S(S_R<L,?\Y.T+_2DA1_S(U0/\K+#?_
-M&R,G_YR0D?_,O<+_PZ^G_[ZDE_^]HY7_OZ:5_\:NF__%JYC_Q*:6_\2MH/_?
-MQL'_<7!O_[.SMO]13$[_65-;_R8A)?^0CHO_B(2&_V9A8_]F9G7_*RY'_S(R
-M._^HH*/_Y=OL_S0L-O\M)R__'ALA_RHL,?\C)2S_(1\H_RXI-?\?&B#_'AH<
-M_Q@3%?\:%AC_)B$C_R4C)O]!0$;_)R,E_Q@3&?\7%1C_%A<8_Q06&_\0"P__
-M&A08_QD3%_\9$Q?_$@P0_QH4&/\3#1'_&Q49_QL3%_\1"0W_$0L/_Q$,$/\6
-M$1/_'!<9_R,>(/\C'B#_'1@:_R,<%O\<'B/_*",I_QX:(O\='2;_'1TF_QP=
-M*/\L*S+_,C$W_R ?)?\8%QW_&A<=_QH7'?\9%AS_%Q0:_Q<7&O\='"+_)B4L
-M_QT:)O\7%AS_7EYA_S P,_],3$__+BHL_QT@(?\Z0D3_&1L>_Q47'_\<'"7_
-M$Q87_V-?7?_$O;?_ZMK7_RHF*/\G(1__LJ:?_^/+SO\P*"S_,"PN_\.WL_]N
-M=W#_N[6Y_S]27/^0D9+_PL3)_S<]3?\Y057_>H&'_]3,RO]H:'?_/$95_SQ"
-M1/]T;&C_3$M8_RXY1/\1&Q+_(B0I_S@Z/?\5&AK_)BLP_SD\0?])2$__,C8^
-M_S0U0/\@)2K_JZ*B_\:WO/^LFY7_JI2+_ZB3A_^?BWW_EXA[_Y>%>_][:&#_
-MBGQS_^?2S?]C8V#_JZNN_TI%1?](14O_(!L?_X)_?O]I96?_9%]C_UU=;/\C
-M)SW_/#U$_Y60EO_DT>?_*28L_S V0/\V,S__(R,L_Q,4'_\3%!__.SQ'_RLD
-M+/\N+"[_/S0S_UI25O]965S_-#<X_RTR,O\F)23_(AT?_R4@(O\B'1__)2 B
-M_RPD)_\D'!__*2$D_RLC)O\I)";_(QX@_R@C)?\F(2/_)B$A_R$<'/\D'Q__
-M)!\?_QH5%?\B'1W_)R(B_R0?'_\B&A[_(QP<_R$?(O\8(3+_$!<I_QX>)_\L
-M*2__(" I_QX;)_\6$1W_%Q(>_Q<2'O\6%!W_&1<@_QT;)/\?'2;_&AHC_Q<7
-M(/\<'"7_,S,\_U=46O\J*"O_$ X1_QH8&_]@8%W_>'IW_SP_0/\5%QK_'B E
-M_T- 1O\9)B?_65M>_\6RLO_RU='_-R<O_R,C)O^)BX+_R[>Y_S4J+_\Q+S'_
-MSL*Y_V]UA?_,P<#_.TA9_Y".D?_*Q<7_-#Y-_R\[2O]Y?G[_V];1_VUO?O\R
-M0E7_+3LZ_U122_]245[_,CQ*_QD='_\5&1O_,C8X_SH^0/\Z/T7_/3]"_TQ.
-M4?\P-#S_)2LU_R$D*?]K:&?_N["U_]/(Q__-P[__U,K&_]S2SO_EV=7_Z-K7
-M_^77U/_JW-G_]N+>_UQ>7/]L;G'_)"$@_SLY._\?'2#_1D1'_QH8&_];6F'_
-M'A\P_R0G./\T.#K_@H""_^'3[_\K+37_2%%?_RXP/_\:'2C_)BHY_QTA,/\0
-M%"/_5U!:_VEK;O^^L+'_Q+G _V5E;O].4%C_1DE._RHE)_\E'A[_(1H:_R,<
-M'/\C'!S_*"$A_R$:&O\I(B+_+B<G_S$J*O\F'Q__*B,C_RTF)O\J)27_)R(B
-M_RTH*/\K)B;_-"\O_RDD)/\E("#_(1P<_Q\A'_],/S[_/#4__T-GC/]4;(W_
-M#10H_Q<4(/\7%1[_&!4A_Q,0'/\8%2'_'1HF_QH7)/\?'"G_&18C_R =*O\T
-M,CO_*2@O_TA'3O\?'B7_'AP?_Q,1%/\/#1#_"PD,_Q<2&/]".#O_'A00_Q@:
-M%_\6%Q#_-C4N_R$X,_]-7V/_/T%(_]?(P_\R)R[_'!\D_SA"./]E65K_-2\S
-M_S@T-O_*OK7_)2L[_\_$P_\V0U3_F9>:_\W(R/] 2EG_.454_VIS<_]S<&O_
-M?7^._S% 4_\T0#__1T4^_U958O\B+#K_/D)$_SD]/_\_0T7_/4%#_SQ!1_\W
-M.3S_/D!#_S T//\G+3?_(20I_R4G)?^BG*#_YM'/__OBW?_XW]K_^N'<__WF
-MX?_ZX][_^.'<__GBW?_TV-K_;6MM_R8F*?\X-3#_DY*1_R4C)?\B("+_(1\A
-M_U-26?\N+T#_)"<X_S8Z//]/34__XM'I_S0S.O]57&C_(!\L_QP;(O\B("G_
-M(1\H_R$?*/\R+C?_&QXC_]#!Q?_9R-+_7%ML_TQ/8/\_/TC_*R,F_RL@'_\L
-M)"+_*2$?_RLC(?\L)B3_+RDG_RDC(?\F(![_)!P:_RTE(_\N)B3_+24C_R\H
-M*/\T+R__(QX>_RTH*/\U,##_'AD9_RTH*/\D'Q__)"(D_XM^>?]%-SC_)C15
-M_Q(>._\8&2K_%A,?_Q85(O\>'2K_&AHE_QX>*?\8&"/_%!,:_S(Q./\?'B7_
-M(!\F_QX<'_\>'!__'!H=_R<E*/\I)RK_$Q$4_R$?(O\F)"?_'!LA_V)64O_#
-MLJS_8VEK_QXY.O\*)"?_'D=,_V2%D?]:?8K_HZZI_S8Q,_\M*"[_MKJR_\RZ
-MO/]'/$'_*2<I_\J^M?]$2EK_U<K)_SA%5O^+B8S_R,/#_T),6_\W0U+_*C8U
-M_TQ*1?^#A93_)"Y"_R8R,?]!/SC_3TY;_QLE,_\P-#;_*BXP_R\S-?\G*RW_
-M*2XT_R\Q-/\K+3#_+3$Y_RHP.O\A)"G_)"@F_S4U./_(NKO_QK2V_\&OL?^]
-MJZW_K9^@_Z&5EO^AE9;_F8V._Y-X?O]*14G_-C0V_U-.2/]N;FO_&AD8_R8E
-M)/]B86#_6%=>_R@I.O\D)SC_-#@Z_TA&2/_AS^/_,2PP_R(C*O\R+C;_)2 B
-M_Q0/$_\>&1W_,2PP_T,_1_\H*B__S+_$_]G(TO]85FG_1DE;_T-#3O\I(27_
-M*A\>_S0I*/\N(R+_*R ?_S H)/\L)R+_-"\J_R@C'O\R*B;_,B<F_R\D(_\N
-M(R+_*2(B_RHE)?\<%Q?_%Q(2_QT8&O\=&!K_'1@8_RLF)O\=%AW_A7IS_W9I
-M7/]'.$/_,BDZ_R4>*/\>&B/_&ADF_QD:)?\8&"'_*2DR_S$Q.O\K+"W_(R(A
-M_R$?(?\?'1__'QT@_QP:'?\7%1C_-30Z_Q<4&O\5%1C_'R A_R\I+?\C)"7_
-M4TI$_X5V</]M='K_5Y&G_TB(I_\P<(__.F:(_RHP1O]P6EO_-R(G_R0A)_^V
-MKZG_T+FZ_V%46?\O+2__S<&X_VIK=O_:T='_04M:_U!.4?_ OL#_1E!?_SY*
-M6?\7(R+_1D1!_X2"DO\D+3[_+#4U_R4B'?]+2E?_+#5#_SD\0?\Z/D#_14E+
-M_S,Y._\W/$'_,3,V_Q$3%O\Q-CS_)"<R_R,F*_\;("#_,#,T_[.NKO_5SL[_
-MV<_2_]?0T/_@T-3_Y-+6_\&PMO^RHZ?_[]78_][3V/]K9FC_=&]I_RPN*_\G
-M)B7_@7]Z_VMI9/]&14O_*2LZ_QH=+O\Q-3?_149'_][1X_\H("K_(!L?_R$=
-M)?\B'2/_&Q8:_Q\:'O\H(R?_&Q@>_QD5%_^EGI[_VL_6_T-#3O\\/$O_0#I(
-M_S$J,?\G("#_(QP<_RLD)/\F'Q__+",C_S4L+/\X+R__,"<G_S(K*_\K)"3_
-M)R @_RLD)/\K(R?_%1 4_Q45&/\;%1G_'!4<_QP7&_\@&!O_*R(B_R,A(_]R
-M;6?_1STO_Z&3D/_2Q=#_8EMG_QD:)?\>(2S_,S(X_R4C)O\@'B'_'AP?_R,@
-M'_\A'AW_(1P@_R$<(O\F'R;_'AD=_QP;(O\O,SO_FI&8_YRAH?\V3T[_15]H
-M_SHW1/^3@XO_N:JN_V%:8?_DW>?_?H&2_T%)7?\N*C+_FY::_\_ NO\W+#'_
-M*R@N_[:II/^]KJ__?7)Y_R@C(__%N;#_FY&-_\C'SO],3E7_%A06_W^!B/]#
-M35O_.D95_QTL*/],3E/_CXJ<_R@R1O\?(R7_2DM,_QX@*/\H*SS_.SU$_S0X
-M.O]"2$K_.T%#_RXQ-O\N,3;_*2PQ_RHM,O\F*S'_*"LP_S0V.?\D)2;_PKBM
-M_[>CF__@R<3_BWEO_Z"-A?^[JZC_8UM9_U-+0?_FU-#_XLW+_Y:+BO\U.CK_
-M,S@]_R$>'?^0BH+_>WEQ_R8F*?\E*#3_*RX__U-26/^%A8+_V,O=_RXF,/\Q
-M+##_'QLC_QL7'_\B'R7_'1H@_S M,_\Q,3K_%Q0:_S<P,/_CU-G_.SA$_S\_
-M3O\^.$;_,RPS_R8?'_\G("#_+28F_R8?'_\V+C'_,BHM_S8N,?\B&AW_'A<7
-M_RHC(_\I(B+_*2(B_R4@)/\>&R'_'!D?_QT:(/\H(RG_*R8J_RLC)O\M)"3_
-M)",B_V=E8/]F85O_*!T<_[*GKO]S;77_)B<N_QT<(_\B'2'_(!L?_QX9'?\A
-M'"#_(QXD_R(=(_\?&B#_&A0<_R4?(_\A'"#_)B4L_RLO-_^BF9G_IZFL_WR9
-MI?]<AY__0#M5_VE3:/^OGJG_:%YA_]S/SO^-CI7_.TM5_S="0_^.CY#_U<;
-M_SXS./\G)"K_F).._Y^4D_^6BHW_'AD;_\:ZL_\Z,"S_O[[%_T%#2O]>7%[_
-M-#8]_SQ'4O\\2U'_'RD?_T5(0O^5E)O_*2\Y_UQ?9/\;("7_+C9 _Q@B,/\]
-M1DS_-#H\_T!"1?\9%QK_%QD>_RTP-?\I+#'_+C$V_R$F+/\B)2K_+C S_SDZ
-M._^^M*G_K9F1_^++QO^,>G#_F(A^_\"TK?]_<VS_J)6)_^?7U/_.OL+_13H_
-M_R\R-_]!1D;_0T$\_XV-@/]E9U[_*BDH_RTM./]W=(;_1C]'_[NQM/_AU.;_
-M,BHT_R4@)/\6$AK_&1@?_Q\>)?\='"/_(!\F_QX>*_\G*"__95Y>_]_0T?\W
-M-3[_,# __T0^3/]".T+_+28F_R4>'O\E'A[_(AL;_S J+O\9%!C_%1 4_Q<2
-M%O\:$A7_(AL;_RLD)/\K)"3_-C$Q_R4=(/]^<G7_85E<_R0?(_\A'"#_*R,F
-M_R\F)O\G)B7_76%?_WR ?O^:DY/_+R4H_Q\;'?\9&AO_'QH<_R :'O\B'"#_
-M'QD=_R,=(?\8$Q?_'!<;_QT:&?]44D__CXJ,_T]*3O\?'B7_/4%)_U=<6/_
-MPL7_T]'A_[RWR?\C'"W_24-1_]7.V/_JW=S_ZM;8_Z><J?]*0E;_/",T_W=N
-M=?_#M*[_2T!%_R$>)/]L:VK_,"LF_YN.C?\I(R?_N*VF_R@>&O]I:&__1$9-
-M_QL?)_\W0$[_1D]@_S]"3O\0#1K_"0 2_R(7+O\.!QG_*20P_QL;)/\Q-$#_
-M*"\]_R0F+?\9&1S_24E,_Q04%_\;'2+_*2PQ_R\R-_\N,3;_)"DO_R,F*_\F
-M*"O_/3X__[ZTJ?^SGY?_YL_*_Y.!=_^.>W/_P;*M_VE?6_]>4DG_[M_:_^33
-MT__7R,G_14!$_SDZ._\C(1[_85]:_RLP+O\I+2O_1TE1_S0T1_\T+SO_TL;/
-M_]3$V/]%/D;_(R F_R$?*/\W-T+_.3I%_U-47_\F)B__*"@S_Q\?*/](0$/_
-MWL_/_T,_2/]#0U+_/#E&_T [0?\D'!__*2 @_S(I*?\S*BK_&1,7_QH5&_\>
-M&1__'1@<_QL3%O\@&1G_)1X>_R@A(?\P*"3_D8B"_]?(P_]J7EK_)R(D_R$;
-M'_\H("/_,2@H_R0B'_]>8V/_8F9H_XJ%A?]02$;_(!T<_Q\='_\C'!S_)1TA
-M_R$;'_\F("3_*B(E_T])1_^1CHG_G)>1_[2PJ/\V,3'_,"LO_W]^A?\T.$#_
-M9&9D_[NVNO_<UM[_U-31_[W#O_^KL;/_U-'7_^S;V__RW-3_N;6W_S]05O\5
-M)"3_=WAY_[JMJ/]=4U;_'AP?_QT<&_^0BHC_13DU_R,>(O^EF93_@GEY_R\Q
-M.?\R-#S_+35%_SI%5O\(#R/_)1TX_VIDGO]13I#_.#AQ_Q@;2O\:$BW_+RD_
-M_Q01)/\7%R+_&!,7_QL8'O\A(23_J*BK_RLN,_\L+C/_-CD^_RPN-?\C*"[_
-M'B$F_R4G*O\S,3/_P+:L_[*?E__>QL/_DX%W_X5T;O^MFY__;&IL_X)[=?_D
-MU];_X\[,_["?G_^[LK+_)R4H_R\J+O\T,3#_("8H_U]F9O\L-#[_,C=)_S P
-M.__3R]7_U<GB_T=+3?\G,SS_%!XM_S P/?\>'RK_&ALF_R0=)_\8$1C_&1,;
-M_RXG+__DU=G_1T!*_ST]3/\V-D/_3TI0_RH>)_\I'"'_+2,?_R\C)/\:%!C_
-M(AP@_R(='_\J(B7_)R @_RDB(O\K)"3_*2(B_S0J)O]E9F#_X-/2_X%O<?\E
-M'2#_)1T@_RPE)?\J)"+_*R<E_U]?8O]97F/_'!<9_\B\N/\E'A[_(R F_R(<
-M(/\5#@[_&108_VAC9_\H'AK_KZ":_\&_M__$N+/_P+*O_S4T,_\C'R'_&Q<?
-M_S<Z1?]-4$K_R</'_^37XO_FU]C_95]5_VA@7/_CU-C_\M_?__/=V__%O,/_
-M/$%-_R4D*_\^-C3_65-1_VQG9_\A'1__<6=C_RL@'_\E'R/_'ATD_Y.'B/\Q
-M,#?_04Q=_SD]3/\\2$W_!@LG_V9CF/\Y-F;_&! L_QL,'O\>$!G_'Q8=_QL9
-M,_]75X#_4E)Y_P\/'O\E("#_+C0\_T-!0__;TM+_*BDP_RXM-/\V.$#_*RXY
-M_R8J,O\A)"G_*RDL_SHU-_^_L*K_UL.]_^W8UO^>BX/_A8!T_]C S_] 3E?_
-M+ATC_W9VA?_6Q\?_.# S_V]L<O\U-#O_-3 R_[NSK_^0EY#_041%_UI=:/\S
-M.$K_+RLT_Z2=J?_&P=G_,C4Z_QP@*/\3$A__&Q<9_Q,3%O\6%Q[_'!<C_QP7
-M'?\2#A;_*B0L_]#$Q_]33%;_0$!/_T%!3O]02U'_+"(E_RL?(O],04#_-RPK
-M_UA-3/^7CXW_-"TM_R0?(?\F'Q__*R0D_RLD)/\H(2'_,B@D_XF*A/_AU-/_
-MBWE[_R,;'O\E'2#_*R0D_RTG)?\M*2?_8&!C_U-87?\G(B3_FY&-_R0='?\:
-M%QW_(QXB_YB,A_^FFYK_5U!0_RP@'/^^LJ[_@8.!_Z^EJ/_:S]3_,C R_R4A
-M(_\?&R/_-CE$_SX_.?_)O[O_XM/4_^/6T?]13T?_/#@V_\S!QO_GV-S_]=_=
-M_\S#RO\X/4G_&QHA_S(J*/\W,2__0CT]_QD5%_\A&AK_)1X>_R <'O\@'2/_
-M>G)P_SP^1?]'5V?_.T53_SE"0O\;%C+_:5:$_Q4,'?\3%!O_$@X6_Q80&/\4
-M$1[_%Q8=_PH&%O\Q*T'_&14>_R4<'/\_0TO_24=)_];1T?\@'R7_+BTS_S$S
-M.O\N,CK_,#4[_R4H+?\P+C'_(1P>_XM[<O_!K:7_Z=30_YB%>_]Q;67_R[;,
-M_Q<I-_\F'BC_'R4U_\>_O?\M*"K_1#]%_RTI,?\X,3'_GY6+_X6$??^-BHG_
-M9F9O_RHM/O]%04G_Q+W'_]K#X/\E'"/_&!$8_R$0&O\A&B'_&QLD_R(H,/\M
-M,#O_)20J_RXM-/]545G_ULS/_T([1?\[.TK_4U-@_U-.5/\P*";_(148_RP@
-M(?].13__O[.L_]S/RO]&/CS_*"(F_R,;'O\I(B+_)1X>_RDB(O\S*27_B8J$
-M_][1T/^@CI#_*" C_R<?(O\H(2'_+"8D_S L*O]?7V+_76)G_R4@(O^PHIG_
-M95A3_Z:>G/^FG)C_P[>P_YZ6E/\H(R7_*B(E_U=(2/^4DH__WM+5_^+3V/\O
-M+BW_)" B_R(>)O\W.D7_/4!!_[RTLO_:R\O_XM[<_U5:5/\U,S7_8%E@_Z.8
-MG?_MU]C_SL7,_SQ!3?\<&R+_8EI8_U5/3?\:%17_(Q\A_R$?(?\<&AS_'QT?
-M_Q\='_]834S_2$E0_T939/]!2%;_)QTP_STK+?^KDH'_=EI7_UH]//^8=6[_
-MA6%7_X1B7_\K&!+_EH%__Z>1D_\4!@/_-RDF_T)$3/])2DO_U=+1_QP>(?\L
-M+2[_/T)'_S U._\L,3?_)"<L_QP:'?\<%QG_B'9L_\&KHO_JU,S_E8!T_W=O
-M9?_5O=+_&"HX_RPE+_\C,#W_I*">_RPH*O\\-SW_+R@R_T X-O^@E(7_@GES
-M_XE]?O]?6V/_)BDU_SLZ0/^\M[W_S+S8_RDJ,?\4'R;_&QTD_R(B+?\E*C;_
-M/$1._Q,:(/\E)"K_*RHP_SDV//\?&!C_/3E"_SL[2O]*2EG_4U!6_RLC(?\X
-M+"W_*AXA_RLD'O^7BX+_V,S%_UE.3?\J)BC_(!L=_RHC(_\J(R/_*"$A_S F
-M(O^)BH3_WM'0_Z22E/\H("/_)Q\B_RHC(_\K)2/_+RDG_VUN;_]@96K_)B$C
-M_Z21A?_ K:7_Q[NT_\6YL/_(N[;_JJ.C_R@E*_\E(R;_1C@U_[>PJO_?T-#_
-MZMO<_S0Q,/\D("+_'AHB_S<Z1?]&3E+_9EYA_]/'RO][>7O_>GU^_W5[??]H
-M96O_KJ.H__/AWO_8S=3_24Y:_QD:(?\H(B#_)A\?_R8A(?\A'1__'!P?_R >
-M(?\A'R'_'AL:_T8W-_]!.T/_1T]?_U9;9_],3E7_#0,,_RL4'_\R(2?_%0H7
-M_R$4'_\G%Q__&0T6_R$:(O\8"QC_)A@G_R :(O^6BHO_1$)+_T=(2?_1T,__
-M+"XQ_TQ.3/\9'!W_("4J_SQ!1_\I+C/_2$-'_][6V?^)>&O_P:NB_^G3R_^8
-MA';_?W1I_]>[S_\<+CC_+"4L_R8Q//^1D(__*28E_S8P-/\I(RO_1S\[_YN+
-M>_^1AG__D8.$_TE$2O\B)3#_(R,F_ZZLKO_=SN;_)RLS_SM)6/\G*S/_-C8S
-M_T) /?\_.SG_&Q,1_RPM)_\M,R__66%=_]72T?\X.4#_+3 \_SHW1/]I9&C_
-M+"(E_RXD)_\F'Q__)B(@_ST\-?_7R\?_;%M;_R8?'_\A'AW_)R @_R\F)O\M
-M(2+_-2@G_XZ.B__>T=#_LZ*B_RDD)/\D'Q__*",C_RHE)?\X,"[_96=E_V)I
-M:?\B'2'_F8R!_\.RLO^#?';_:6=B_^76VO^MH:+_*28E_R4@(/\X,RW_O;2N
-M_]3(Q/_DW-K_.#4T_R0@(O\@'"3_,C5 _SY%1?_"L[/_S+^^_^_DX_]Q:G;_
-M1U-<_UY=8_^YJZS_Z=K4_^70U?]%15+_&!HA_R0?(?\F(B3_(Q\A_R <'O\@
-M'![_(1T?_R(>(/\>&AS_-2<H_TM&3/]58&O_45ME_T=-7?\H*#?_8%UO_W)N
-ME/\C(CG_$! ?_PT-&O\*"1;_&QDZ_RPG4?\Y-%;_'R$H_Z>EHO]955[_0D5&
-M_];3TO\K+3#_.#HX_S4W-/\R-3K_,#$\_R@P-/_&NKO_Y]C=_Y5_=O_)L*O_
-MY<S+_YZ&=_][<6?_U\#3_R S/_\A&R/_+S4__V)F:/\E)R7_,2PN_R$@)_].
-M1D3_B'EL_XA]=O^1@H/_2T1+_R,E+/\U-3C_H9R<_\3#T/\>'!G_(QL?_Q<;
-M&?\?)1?_/D,W_SE"-?\M.BW_(RX;_R)"+?]ICX#_QL7$_TE$2O] /D?_-2\W
-M_T Y.?\N(B/_)1L>_RLD)/\E(1__("0<_\C#OO^#<'#_,B0E_R0='?\G("#_
-M,RHJ_RTA(O\P(R+_AX>$_]K-S/^_KJ[_*20D_R0?'_\M*"C_,"LK_S8N+/]E
-M9V7_7V9F_R,>(O]V;&'_:EU<_XR*@_^,CXG_Y]C<_["DI?\O+"O_)B$A_RLJ
-M(_^MIJ#_R+JW_^O@W_\Q+BW_(Q\A_QL7'_\P,S[_/$-#_[^NKO^_L+#_\N7D
-M_VYH=O])5F'_5E=>_[*FJ?_AU<[_Y]+7_S\_3/\@(BG_)2 B_R,?(?\C'R'_
-M(!P>_R <'O\A'1__(AX@_QX:'/\K(R'_24M._T926_]:96S_1$]:_SE#3O\J
-M,3__,C%._S G8_\T*F__/S9\_UM1FO\8%4G_95^+_T$]7?\Y04O_E923_UA4
-M7?],3U#_V=;5_S R-_\P,3+_24M)_S R.?\Q,CW_)R\S_\.WN/_DU=K_?G%L
-M_\"KJ?_<R<G_AG)N_W=N9__4O=#_%"<S_R4?)_\W0$[_.3]'_R$C)O\P+#3_
-M(20O_TQ(2O]X:F'_=FMD_Y*!@?]&/43_(R0K_SX\/_^VJZK_O\3*_SY(-_\V
-M0C/_+T P_TQC4/\Y5$/_#"D7_SY?3?\S3CW_/%I*_YBMH?_9T<W_2T=/_S0U
-M0/\M*C;_0SY _R8='?\E&Q[_)R @_R<C(?].3TC_T<?#_YR)B?\F'1W_(AT=
-M_R<@(/\L(R/_+B(C_S(E)/][>WC_U\K)_\BWM_\H(R/_)2 @_R<B(O\I)"3_
-M+B8D_ST_/?]=9&3_'QH>_WMP9?]H65G_LJNE_YN9E/_DU=G_MZNL_S,P+_\G
-M(B+_(2(;_ZZIH_^MGYS_Y=C7_S,N+O\E(2/_)" H_SD\1_\Y/C[_P*VM_Z>6
-MEO_NW]__8UUK_SA)5O]#1T__JZ"E_^'4S__FT=;_/3U*_R B*?\H(R7_)B(D
-M_R4A(_\B'B#_(AX@_R(>(/\B'B#_(AX@_R,;%_]14$__/$5,_XB*D?^+B8O_
-M24]1_SM'3/] 2%+_>'I__T9'3O\H+CC_'"4S_TQ55?]Y>GO_Q\')_SD^2O^+
-MB8O_3TM4_T)%1O_)QL7_+S W_RDI+/^8F9K_/#Y&_S<X0_\O-SO_OK*S_^+3
-MV/]W<FS_R;ZW_]_2S?^9CXO_FI6/_]['VO\U2%3_)B H_SI"3/\N,SC_:&EJ
-M_T(]0?\U-#O_4DQ*_[6IHO]=6%C_D(2'_SHU._\A*"[_0T5(_ZFDI/_&R,__
-M+D4R_TQO5_]UCWK_*#\L_R L*_\Q.C/_-T0Y_R@T/?\_0E3_RL+%_^?8TO\[
-M.T3_/$!/_TM)6?]&0DK_+B0G_RTC)O\G'A[_,"HH_V-<5O_>T,W_J9B8_R8C
-M(O\A'AW_)R @_RXE)?\N(B/_,20C_T1%/__7R,C_S+N[_R@C(_\E("#_)!\?
-M_R8A(?\N)R?_*RDK_SH_/_\?&A[_;U]6_W]O;/^1B(+_I)^:_^C9VO^ZKJ__
-M+2HI_R,>'O\D)1[_KZFA_Y.'@__BU=3_/CDY_R,?(?\C(";_1$=2_T1(2O^\
-MK*G_DX*"_^?8V/^#?8O_-TA6_U]B;?^<E)C_VL[)_^;4UO\V-T+_+C W_R@D
-M)O\G(R7_(AX@_R,?(?\B'B#_(AX@_R$='_\C'R'_*!T<_T=#1?]14%;_P+G
-M_^K9X_]=5F?_/4)4_T))6_]]=H#_M:FR_^?=[/]44F7_86%P_XR"B__@T]C_
-M/#]$_XZ0CO]03E?_0D5&_\[+RO\H*3#_*RHP_XF(CO\S-#__+C X_RXV.O_$
-MN+G_YM;:_]'!N/_3N:S_U[>O_\RPK/^9C8;_V<37_R,Q0/\E(2G_)BLQ_WAX
-M=?^=F)+_D(N+_X![>_^(@7O_9V!:_UQ=9/^5D)3_*"HM_S=#1_\[1$3_9FMK
-M_][;S_\M*BG_,"XW_S@^.O]_?HO_9D.*_Z-[K_]%+$O_JHJ]_WM8F/_3PLS_
-M[-K0_TI&3_\^/DO_4U)?_ST\0_\K(R'_+R,D_S D)?\^-##_<F9?_]?(P_^L
-MG9W_*R,F_R ;'?\G'R+_,RHJ_R\D(_\Q)2#_B8> _]W+R/_2P<'_)B$A_R0?
-M'_\H(R/_*R8F_R@C)_\I)"C_)B$E_Q\:'O]S8V#_C(![_WIW<O^GH9__X=/0
-M_\J_OO\O+"O_)2 B_RPH)O_$MJ?_=6UI_^?>WO\Z-37_)R,E_R0B)?]256#_
-M1$=3_[JKI?]U9V3_Z=O<_Y6)DO] 2EC_7%]J_Z.;GO^?F)C_Z-O6_T-#3O\N
-M,3S_*B8H_R8B)/\C'R'_)" B_R(>(/\B'B#_(!P>_R(>(/\7$!C_*2XT_\K%
-MR_^\M+C_W-/3_U%59/\A*3/_0$=3_VQN=?^7CH[_W,W2_TY17?]L;G7_=VUP
-M_]W.T_]$1U+_AHN+_V%?:/\^04+_QL'!_R<F+?\K*C'_DY&:_S<X0_\W.C__
-M)BPV_[BKJO_-N;O_MZ*6_\2HFO^[GI+_P:67_YN*>O_4R-?_+BY!_R$C*_\Y
-M-3?_C7QV_]K#M_]!-3;_)R,E_V!>6?^$A7__B(B+_Y2/D_]P<7+_2E-3_U5:
-M6O^'B8S_Z+O?_XA.H/^F9-'_QYS2_UQ(4?\U&3/_1S [_S4N*/^)?7G_FHF4
-M_]3(Q/_MVM3_4T]7_S<W1/]44V#_6UIA_RHB(/\K'R#_+R,D_STS+_^#=W#_
-MU,7 _\2UM?\K(R;_(!L=_RDA)/\T*RO_,28E_SPP*_^*B('_W,K'_]3#P_\N
-M*2G_)B$A_R,>'O\J)27_)R(F_QH5&?\A'"#_'!<;_U1$0?^6BH7_8V!;_ZFC
-MH?_;S<K_U<K)_S$N+?\H(R7_+2DG_\6WJ/]>5E+_Y-O;_SPW-_\G(R7_'1L>
-M_T!#3O\[/DK_L*&;_U]13O_DUM?_K:&J_T)-6/]35U__7E=7_X%Z>O_DU]+_
-M3T]:_RTP._\D("+_)2$C_R,?(?\D("+_(AX@_R,?(?\F(B3_(1T?_RLC(?\S
-M,2S_74Y._ZB>FO_7S\W_3U-B_RLS/?] 1U/_7%YE_X^&AO_FU]S_24Q8_U)4
-M6_]C65S_VLO0_SH]2/]^@X/_85]H_TE,3?_>V=G_+RXU_R\N-?^4DIO_/#U(
-M_SU 1?\N-#[_MJFH_\"LKO^JD8K_HHA]_ZJ4C/^YGY3_CG]R_\K#S_\P,S[_
-M(R8G_XU_@/^3@7W_WLO%_TH\/?\<%A[_(1\B_UQ>6_]K;VW_='%P_W]^??]W
-M?'K_9VMI_UU@8?_FQ=;_;DAI_]RUV/_[XMW_54A-_RDB+/\I)C+_-35 _WIS
-M9_^5C7W_R[^Z_^30S/]'1$K_,S- _S@W1/]655S_*2$?_S(F)_\S)RC_-"HF
-M_Y&%?O_9RL7_Q;:V_RLC)O\B'1__)1T@_RXE)?\K(!__-BHE_X* >?_2P+W_
-MTL'!_RDD)/\E("#_)B$A_R(='?\<%QO_%A$5_Q<2%O\;%AK_134R_Z>;EO].
-M2T;_IJ">_]W/S/_7S,O_,"TL_R8A(_\R+BS_Q+:G_U5-2?_BV=G_.C4U_R8B
-M)/\:&!O_(R8Q_T)%4?^FEY'_4D1!_^'3U/^WK+/_/$A1_U9;8?^9DY'_D(F)
-M_^G<U_]&1E'_.#M&_R<C)?\G(R7_)2$C_R8B)/\M*2O_KJJL_R,?(?\H)";_
-M;6!5_X-[:_^>AWO_<&-8_]K2T/]35V;_+34__T5,6/]:7&/_?71T_^G:W_]%
-M2%3_3U%8_V!66?_>S]3_1$=2_XZ3D_]T<GO_14A)_\G$Q/\T,SK_+"LR_YJ8
-MH?\S-#__.#M _R0J-/^KGIW_KIJ<_XY]=_]P9%W_0CLU_Y*$>_][:&#_R[_(
-M_T$_0?\X,R[_9EM:_SX\.?\J+"K_-C0V_R =(_\V-SC_='AV_VIM<O^9EI7_
-M:&9C_W!U<?]45E/_5%5/_^C;UO];44?_Y-?2_^+.U_]>4E/_-#$E_RPH)O]$
-M.T+_>FYE_XZ%=__)O+O_W<G%_T$_0?\Q,3[_1$11_TA'3O\P*BC_*AX?_S,G
-M*/\W+BC_F(V&_]C)Q/_3PL+_*B(E_R,>(/\F'B'_+20D_RXF)/\V+2?_;FEC
-M_]K(Q?_/OK[_*R8F_R4@(/\D'Q__*",C_Q0/$_\4$!+_%A$5_Q@3%_\P)B+_
-MLJ6@_T-!.O^ZL*S_T\?#_]S1T/\T+R__)R(D_S@T,O^_LZ3_23\[_^79VO]"
-M/3__)B(D_R ;'_\C)C'_0D-._ZB<E_\T*"3_WM'0_\:YOO\\2%'_5EUC_Y60
-MB_^;E)3_Z][9_U!06_\]0$O_)B$C_R<C)?\I)2?_5E)4_V=B9/]33U'_(QXB
-M_RLG*?\J)B3_1T=$_V=87/^$@8?_V-#3_UA@:O]-5EW_2$];_U5:8/]T:VO_
-MYMG>_T-&4O]46V'_1CY!_]O/TO] 1E#_<'-T_VEH;_]'2DO_GIJ<_S0V._\M
-M+#+_IJ*K_S8Y1/\O,C?_+C0^_Y^2D?^QGZ'_:U]:_UQ74?]H:6/_;FIB_WUK
-M9__#LKC_ULS(_]&_O/]V85__JJ&A_R0C*?\_-SO_)B0A_XN.B/]G;&K_455=
-M_W%P;_]^?'?_5UE6_U!12_]344G_X]/*_V=84__ATM+_Y=#+_VQ@8?\Q*C'_
-M.3,[_SPX0?^+@GO_?G5N_[ZRK?_@S,3_349-_SL]3/])2UK_.C8__S H*_\L
-M)27_+RHE_R\J)/^/BX/_S<&Z_]+ O?\N)27_)!\?_RDB(O\J(R/_*"$A_R<D
-M'_]D6U7_PK.N_\S N_\M)2/_)A\?_R0='?\J(R/_(QDC_R,<'/\@&2'_*"$K
-M_Q\D(/^]IJ'_>WMP_\"KI__&P;S_V]/1_S0M+?\D'R'_/34S_ZJDE/]5247_
-MY]C9_TI$2/\I(R?_(AP@_R >)_\M+S3_B(6$_T Z,O_BU-'_R;C _TM48O]$
-M257_E8^-_Z.<G/_FU-#_7%5A_SH[1O\M)RO_,"HN_ZJEI_\[-C;_AWM\_YN2
-MF?\A'27_(AP@_R,=&_\K+2K_-RXN_R ;'__0Q<K_5V%E_TM77O])4%S_4UM?
-M_VUH:/_>T]C_0$-/_S]+5/\T,C3_S<;&_SQ!3?]*1T;_8&%B_T-(3?]02T__
-M+3$S_RTM,/^JI*S_045-_SM 1?\I,3O_6E)0_]#$Q?^*C8[_?W^"_Y^=IO]6
-M76/_+C<^_SL]0O\N)R?_,2@H_[2GHO\J)2?_(" I_TQ'2?^'A'G_I:29_V=L
-M:/]L='C_8W9^_X:(C?^"@G__1T5"_UI54/_8R+[_<6)<_]W/S/_FTLK_=VII
-M_S4M,?\_.#__0SU%_V=@6O]N9V'_K**>_][+Q?]M9F[_0T15_U97:/]'0D[_
-M+24H_RTF)O\K)B'_-C$K_VQH8/_)O;;_U,*__RLB(O\D'Q__)A\?_RTF)O\J
-M(R/_+2<E_TI"/O\J(!S_R[^[_RLB(O\D'1W_(AL;_RLD)/\E%Q__(QL7_R(;
-M(O\N)BG_("$:_\ZRKO]S<F?_PZFF_[BSKO_=U=/_-B\O_R,>(/\_-S7_E8]_
-M_W!D8/_:R\S_95]C_RDC)_\C'2'_(!XG_ST_1/]%0D'_M:^G_]C*Q__1P,C_
-M04I8_U199?^0BHC_H)F9_^/1S?]W<'S_1D=2_R@C)?\J)2?_K*6E_Y2,BO^+
-M?GW_G)&6_R4@)O\J(B7_?W1S_UI<6O_$O;W_MK.R_[RNMO]-55__0DQ:_TE.
-M8/]'3E3_<6QL_^+7W/],3UO_.45._X2"A/_:T]/_.3Y*_ST^/_]765S_/3]&
-M_R@G+?\4&!K_)"0G_[NUO?]"1D[_049+_S$Y0_^1B8?_W]/4_U=I=_\W36/_
-M)SQ5_S!%7?](7'#_%R$O_QT?(O\F)23_4$5*_S G+O\?&A[_I9^7_["EGO^.
-MAX'_;6]M_VYV>O]6:(S_2%%B_U!:2_],3$G_4TY._]?(N_]Z;&/_V<W&_^72
-MR/^ <F__*B$A_T$Y/?])0DG_:F-=_V=B7?]/1T7_T\2__V%<8/\Y/$?_8V9R
-M_T- 1O\N)R?_*R0D_RXI)/\H(QW_<V]G_[VQJO_6Q,'_*R(B_R$<'/\C'!S_
-M*B,C_RLD)/\S*BK_(1P<_R0?'__,P,'_+20D_R4>'O\G("#_*"$A_R@='/\B
-M(1K_%A8C_RDE+?\<'1?_RJVI_W-P9?_,L*W_L*BD_]_7U?\V+R__)!\A_S H
-M)O]X<F+_A'AT_][/T/]L9FK_*"(F_R8@)/\=&R3_/D!%_SPY./^UKZ?_X=/0
-M_]7$S/],56/_1$E5_X1^?/^*@X/_UL3 _XJ#C_]'2%/_+"@J_R\H*/^OI*/_
-MJYV:_X=W=/^BEI?_+RDM_RLC(?^JDI7_44E,_\N_P/^_L+#_N*>M_UAA9_]+
-M5V#_/T94_T=/4_]234W_W-'6_U-68O]#3UC_A(*$_]3-S?\]0D[_'2,E_R\Q
-M-O]/3UC_)B<N_SI 0O\H*"O_OKC _TI.5O\R-SS_,3E#_WUU<__9S<[_-$-0
-M_R<[3_]!5&S_,3]6_V%B<_\C'";_+B4E_R@A(?]@6%S_,BHN_\K"OO^BEY#_
-MBHB#_T]34?\]0D+_<WM]_SI+6?]A8&;_65Q0_U!.1_]C6U'_TL:W_VE=5/_7
-MR,+_XL_%_X5W=/\L(R/_,RLN_T4_0_]H8U[_,2TK_R4>'O_6R<3_AH."_UI@
-M8O^/EYO_8F-D_RLF)O\N)R?_+24A_RLF(?]A757_HY>0_]3"O_\I("#_(AT=
-M_R0='?\K)"3_+R@H_RXE)?\B'AS_3TU(_\O O_\M)"3_(QP<_RLD)/\M)B;_
-M(14>_U588_\@)%'_-S!?_QX<'__'JZ?_<FI@_\>MJO^4CXK_W-'0_S@O+_\D
-M'R'_*B(@_UU62/]V:F7_V\S-_X5]@/\H(B;_(!H>_QD9(O\^/T;_.3@W_[6O
-MI__3QL'_V,?-_T--6/]%2U7_?G9T_UE45/_(N;3_B8.+_T]27?\E(R7_+"<G
-M_ZF=F?^SI)__FHN&_ZN=GO\D'!__+28F_S$F*_]"24G_GJ*@_ZVKIO]B6EC_
-M3%A7_T515O]!2%3_3%18_T(_/O_EV=S_1DE5_T),5O]K:6O_RL/#_S@]2?\J
-M,3?_$1(9_TA(4?])2U+_04=)_RHJ+?^WL;G_/$!(_RPQ-O\P-C[_>W5S_]K.
-MS_\C)2K_'"$G_U-68O\I)##_(ATA_R(@'?\D(AW_(B<E_UI96/]M96/_W=',
-M_[*HI/],4U/_,CX]_XF0D/]>86;_<7AL_Y*(?O^2AH'_?G-L_ZZBD__,Q[O_
-M7%%*_Z:2CO_AR<#_F8B(_S$I+/\X-3O_1#U%_R8A(?\@'Q[_+BPN_[^VL/^(
-M@X/_/$)$_V9R=O]O<7C_+RHJ_S$F)?\K(!__)" >_UM94O]".3/_T,*__S H
-M)O\B&QO_)1X>_S I*?\H(2'_*B,C_R\I(?^0B7O_R;VX_RLD)/\B'1W_*",C
-M_RDD)/\K(BG_6&)?_R I6/\\/&?_'!X<_[VHH_]B4DG_MZJE_W1Q;/_=S,S_
-M/C4U_R,A(_\H("/_/C@V_SLT+O]G6US_E(N+_RLD)/\>&1__&AHC_SQ 2/\\
-M.CS_IYN6_\>YL/_;R<W_2%!:_TE07O]/1TO_(B$G_U!%/O^!>W__0D)/_QT;
-M'O\G'2#_IIB5_]'%OO^JFI?_MJ>G_S$H*/\G(R7_-CP^_TQ04O]85%;_IIZ<
-M_S4Z-O\B*RO_2%%8_T9/7?]045S_AXF,_^/4V/]24&#_-T%+_U]@8?^^N[K_
-M-CE%_R@K-_\_04G_1DA/_T5(3?](3E#_*2DL_ZVIL?])25+_,3@^_S$U-_]+
-M24;_R\+"_R4@(O\B&AW_N:VP_R@C)?\@'2/_'!LA_Q86&?\E*"G_LZRF_]C+
-MQO_BUM+_N[>U_T)'1_]P=G+_4EA4_SD^0__CU]/_[]S4_^S9T?_SX-C_^^??
-M_\2[M?]%.S?_>FQI_]2^M?^:BH?_+28F_S\]0/\V+S;_'!T>_SP[.O^4D([_
-ML:6@_W!H;/\G)S3_0DA8_V9D=/\E'2#_+B,B_RTB(?\E(1__)2,>_R 8%/_/
-MPL'_+28F_Q\8&/\B&QO_*2(B_R\H*/\M)B;_,"HB_Y.,?O_,P+O_*R0D_R(=
-M'?\E("#_+2@H_RLB(O]?9%[_7F5S_UI:9?\;&13_PJVH_T<Y,/^FG9?_85]:
-M_][-S?]$.SO_(B B_QX9'?\N*RK_,BXL_W=O<O^BF9G_+28F_R$<(O\>'B?_
-M04=1_T='2O^;D8W_M:FB_]K(RO]26F3_1$Q@_Q\>*_\6&R#_4TQ&_V5?9_\I
-M)##_*B(F_S@I+?^LEY7_V<C"_Y>%@O]Y:FK_*R(B_R<C)?\O,C?_3E%6_S<W
-M.O^&@8/_'!\@_P\5%_]+45G_0$=3_T=(4_^)BX[_V\S0_T5#4_\W04O_(B,D
-M_S@U-/\L+SO_/4!,_T)$3/],3E7_2TY3_T)(2O\E)2C_L:VU_T%!2O\O,SO_
-M-CD^_TE+2?^0BXW_(1T?_R\H*/\X+R__0CT]_TA&2/]J967_D8F'_ZF=F?_K
-MW-;_U<C#_UI03/]S;6O_:&=F_T]44O\^1D/_3E)0_\>RK?_XW=;_^=[7__[C
-MW/_]Y-W_P+*S_RLC)O\A&QG_K9J0_Z>8D_\P*BC_04 __S8Q,_]%2TW_1$A&
-M_Y&(@O^:C(G_CH.(_RPJ.O]$15S_<6U]_RLC)O\M(B'_,"4D_QX:&/\>'!?_
-M&A02_\B_O_\G(B3_(AT=_R$:&O\G("#_*R0D_RXG)_\M)Q__AX!R_\_#OO\H
-M(2'_(!L;_R8A(?\F(2'_)B0A_UQ@7O]G;&K_9&-B_R(>'/^]J*/_-RTC_YV8
-MDO\].S;_WLW-_V%86/\C(2/_*",E_S8S+O^ >W7_3$1 _ZJBH/\J(R/_(!LA
-M_QD9(O\]1%#_/3Y%_X^'A?]934G_X,[2_T1,5O] 2%C_+BDO_TI&2/^!>'+_
-M(2$L_S4R/O\H(R7_,2<J_Z&1CO_ L:O_J):3_[6FIO\L(R/_)B(D_S<Y0/].
-M4%?_&!H?_TY.4?\>("7_0$-(_TQ06/\[04O_3E!8_VIL;__4Q<G_.SE)_RDS
-M/?]'2$G_;VQK_R4H-/\S-D+_/D!(_UQ>9?]+3E/_-#H\_QP<'_^>FJ+_1D9/
-M_RPO._\N,#?_,30U_TM*4/^KI*3_V\[-_^G8V/_KWMW_XM31_[^MJ?^5A'[_
-M=V1<_^?2S?_MV]?_T\O'_];+RO_3S\W_/T)#_V]Q;__JV];_^=[7___DW?__
-MY=[__^7>___GX/^BD9?_(QL?_QD4%/^,>V[_I)2+_R4@(/\^.SK_1#\__S=!
-M1?]$247_CH-\_X^!?O^IH*#_/SQ(_SY 5?]84F#_+B<G_RTA(O\M(B'_*B4@
-M_QP:%?]G8EW_R[_ _RHE)_\A'![_'Q@8_R<@(/\R*RO_+"4E_RPH(/^!?'#_
-MQ[NV_RDB(O\A'!S_(QX>_RXI*?\H*"7_8&)E_V5K9_]D9&?_(AT=_\*NIO\_
-M-"W_@X)[_QL<%O_:R\S_<F9G_RDE)_\P*"3_4DI _WIQ8_]:3TC_KZ2C_S$L
-M+/\<%QW_+"HS_SE#3?\I*C'_?W9V_R8@'O_6R<[_2DU8_T5(4_^'?'O_7EA6
-M_R@@'O],3UK_.CQ$_QX:'/\K)BC_G9*1_[*GH/^\JJ;_O:ZN_RPC(_\F(B3_
-M-38]_U988/\@(BG_'!XC_XR-E/]*3%/_0$%(_V9G<O]&253_;G!S_Z^CI/]%
-M0U/_*# Z_VAJ;?\Z.#O_)2@T_R8I-?] 0DK_5EA?_T-%2O\W/3__+2TP_VEE
-M;?\_0$?_,#$\_S4W/O]&2DS_+S$V_WYR;O^@BXG_T;FV_W5B7/_8RM+_6$Y8
-M_R@A*_\@&R'_Z=32_^'/R_]%/CC_3D9"_TU-2O]]?'O_W,_.__C9T___Z>'_
-M_^;?___GX/__YM___>3=_YR$C?\J&B+_03LY_WUL7O][:V'_)!\C_T$Y-_]"
-M.CC_+S@^_S(U-O^+@GO_>6QG_[ZTL/\V-3S_3U)D_TQ(6/\K(R;_*R$D_R\C
-M)/\L(1K_*B0<_WAP9O_2Q\#_,B@K_R :'O\A&1S_+R8F_RXC(O\N)27_)R,A
-M_VMJ7_^XKZG_*"$A_R$<'O\C'A[_+"@F_RPC(_]B8V3_8FMK_V%D9?\@'AO_
-MNJF;_R4=&_]W>'G_&!<6_\2]O?^4AH?_*" >_R8>&O];44?_95Q._V)>5O^Y
-MK*O_*RHI_R8?)O\9%1[_.$%(_R<F+?\P*B[_)B@F_WMS<?\_.T3_-3M+_U15
-M7/]/453_14M3_TQ27/\Z.4#_'A@<_RLC)O^QIZ/_J)V6_[BDG/^WIZ3_+2(G
-M_R4?(_\P+S7_3D]6_R0F+O]L;WK_75YI_U9?9?]545G_-S5%_T!*6?\W/#S_
-M+2LF_S] 2_\G+S__+S9$_S$V0O\<'BW_&ATH_T1&3O\\/D/_-34X_SP_1/\E
-M)"K_*B<M_S]!1O\T.$#_-C@__S@Z/_\F)BG_H):'_\6MJO_GT,/_HY-__]/'
-MR/\^-S__)1\G_RDB(O_KT];_U</%_T,_0?]H:FW_4UUA_[6QK__XX=S__.7@
-M___GWO__Y=S__^;=___DW?__Z.'_MYV@_S$?(?])/3G_=F%5_W]M8_\B'2'_
-M-BXL_S\W-?\D)BW_)"(D_WUY<?]M85S_K*"<_S(N-O]66VW_24E8_S$L+O\H
-M'B'_,"0E_S,H(?\N*"#_;65;_\F^M_\S*2S_(!H>_R$9'/\P)R?_+R0C_R\F
-M)O\A'1O_7UY3_XZ%?_\G("#_(QX@_Q\:&O\J)B3_+20D_UE:6_]:8V/_:6QM
-M_QX=(_^QI9[_'Q<:_S<W.O]#0#O_O;6S_Z.7F/\J(B7_*2,A_U5,1?].1SO_
-M;6MD_\:YN/\N+2S_(!D@_RDE+O]03%S_+BXW_Q4=&?]$/SG_;&!<_S@S.?])
-M4%[_14Y<_T%&3/]"2%+_/D51_T!$3/\=&QW_)1X>_["DG_^<C(/_M*"8_[.C
-MH/\I'B/_)!XB_S8U._]55U[_*S$Y_UYF</]?8&O_769L_UE57?\O+3W_.$),
-M_SD]._^HJ:/_)"LQ_QXH/?\F+4'_'2(N_QTB)_\P-CC_.3Q!_QD;'O\:&AW_
-M-SH__RHI+_\B'R7_.CQ!_RLO-_\R-#O_+S$V_S<W.O^<DX+_QJVH_^C0P?^D
-MDWS_S+^^_SLT._\A'RC_)B$G_^70S/_/P;[_6EQ?_SD]/_^ >7G_\>#:__OB
-MU?__Y-G__^7A___CW___Y=[__^7<__WDW?^FD8W_+B(>_S\X,O]D447_=F9<
-M_QH5&?] .#;_,"@F_RDE+?\E(R7_:&A?_UM23/^XJJ?_,"HR_TY18_]&2%?_
-M,"LM_RLA)/\T*"G_,"4>_R@B&O^-A7O_QKNT_RXD)_\?&1W_'Q<:_RPC(_\M
-M(B'_+",C_R8B(/\Z.2[_7U90_R8?'_\?&AS_*",C_R <&O\M)"3_4U15_UYG
-M9_]B96;_(!TC_ZJ9D_\X*RK_6E12_W%K8_^TJJ;_IYN<_R8@)/\F(R+_65),
-M_T,],_]V=&__R[Z]_RDH)_\A&B'_(!PE_SD^2O] 0D7_@H!X_YB.BO\@'2/_
-M6EQD_TA/6_]-5V7_045-_T-&4O],5F3_355?_R A(O\O*2?_J9V6_Z*,@_^L
-MEH[_HY.0_RD>(_\D'B+_*BPQ_TE05O]+5%O_2U5?_U!17/]<96O_M[.[_T$_
-M3_\I+SG_EY.;_R(?)?\K-4#_)BX^_QH>+?\A(";_A8" _TY24/\U.CC_&1L>
-M_SDX/O]!1$G_'ATC_S4R./\A(RC_*"PT_R4G+O\\/D/_/CY!_YF/>__!II__
-MY,NZ_YF&;O_3P[K_EHB)_S,M,?\G(B3_Y]+&_\:]M_]/5UO_86=I_^',T?_V
-MWMO__N?;___HW__[WMW_PZ6G__S@W/__Y][__^;?_[.DGO\F'AK_.30N_U=*
-M/?]Q8UK_&!(6_S(I*?\F'1W_*"$I_QT9&_]+3$7_44A!_\BVL_\H'B?_861U
-M_T5(5/\X,S/_)QT@_S,G*O\S*"'_*R4=_VYE7O^_M*W_,BDI_R$<'O\?%QK_
-M*R(B_S$F)?\J(2'_)R$?_RHH(/\_.#+_(!@;_R ;'?\G(B+_)2$?_RHC(_]/
-M4%'_769F_V%D9?\C'B+_IY2*_VY=5_]<4$?_<&9;_ZJ>F?^SI:;_)R(F_R0@
-M(O])1#__,BTG_W-Q;O_+P+__+"DH_R,=(?\A'27_(R\V_SH\.O]J75C_(QX@
-M_T1)5?]#2E;_04E3_T--6/]/4EW_2U!<_TM59/],5V+_(20E_RTH(_^GEX[_
-MNJ69_Z6/A_]$-C/_)QT@_R8@)/\N+C'_/$-)_T=05_]C9V__HJ*K_U1=9/\N
-M*S'_-31!_S4Z1O\:&"C_.3='_RHR0O\<("C_(" C_XR(AO]G6U;_BHZ&_X:+
-MA_]\?'__-SD^_TY15O\;'2+_*B<M_S8X/?\?(RO_+3(X_S,U.O\_/T+_AWIG
-M_[ZCF/_6NZK_@W!8_\6MI/^ADHW_,2HJ_RHC(__IS<__Q[K'_S0Y4O\_/U3_
-M4$1=_UE39_]@7&S_:V=W_WMF<O^.=GO__.+?___HW?__ZN'_HY*2_R@<'?\X
-M,"[_2#XT_V9:5?\;$A+_*R,F_R,=(?\K)2G_(AX@_SX[-O]#-S#_RK6S_RXF
-M*O]-3EG_9V1P_S$I)?\O(R3_*APD_RLB'/\E'AC_;&-<_[.HH?\V+2W_'QH<
-M_QP4%_\M)"3_+2(A_RTD)/\E'A[_(1X9_RLJ(_\6$A3_'AD=_RDA)/\F'1W_
-M*"0B_S]!/_]@:6G_8V=I_R >(?^@C8'_8%!&_SDM)O]?54O_D(1__[6HI_\F
-M'B'_)AP?_S4P,O\N+"[_85U?_\>^OO\N)27_(QX@_R$?(O\;'2+_-C<^_TU1
-M6?\^1$[_+C(Z_TE/6?]"257_14Y<_T!*5?]&4%O_/DA3_TE37O\A(RC_*2$=
-M_ZB8CO^XI9O_:EI7_X5X=_\B&QO_)"(D_R@C(_\T.3__0DA2_["GI_^EH*#_
-M24Y:_TU+3?\X.D+_(2LZ_SA#5/\H,4+_'1TH_RDD*/^AG9O_6%-'_Z><D?^)
-MB7[_75M8_]?1V?\Y/$'_2TY3_R$C*/\M+S3_+2\T_RHN-O\K,#;_.#M _S]!
-M1/]K7U#_K9B&_[JBD_]C4D3_LYR=_R\C)O\@(2+_)B$C_^S0T_^[KK/_9W)Y
-M_T=(3__FV.#_Z=GA_^K:XO_FUM[_YMGD_]S,U/_ZY>'__^C;___FV_^CE)7_
-M(QD<_R\H*/] -S#_8%92_QH1$?\F'B'_(!H>_R0>(O\>&AS_+2LH_R,;%__"
-MLZW_.34S_T)'3/]L<'+_-BXL_RXB(_\Q)2C_,RHD_R0=%_\Q*"'_DXB!_SDP
-M,/\A'![_'Q<:_RHA(?\P)23_+R8F_R4>'O\8%!+_'!H7_Q40%/\;%AK_)AXA
-M_R@?'_\J)B3_14=%_V-L;/]@9&;_(!\E_XIX;O]00CG_*Q\;_T4[,?]U:63_
-MNJVL_RDA)/\F&R+_+R@O_QP>(?\/$A/_44M)_RD@(/\A'![_(!XA_QL=(O\I
-M*C'_/$!(_T9,5O\M,3G_6F!J_S]&4O])4F#_35=B_T--6/]"3%?_45MF_R$C
-M*/\J(B#_I):-_TH\,_^)?GW_& \/_R0?(?\A'"#_4$='_T)$2?]%2U/_9U]=
-M_W)M;?\]0D[_+RTO_S]!2?]%4F7_+#9%_R@H,?]12$C_M+"N_V1;5/^]K)__
-MHX^'_U=84?]H;6G_O[W _S(T.?]/45;_(2,H_S R-_\K+3+_(2,K_RTO-O\Z
-M/$'_-C8Y_V1;5/^#<VG_?FYE_WQQ:O\N("'_)1T@_R,A(_\H(R7_\-;3_\6X
-MM_]775__,BTM__G=V?__X=O__^';___BW/__YM___^;B___JX___Z>#__^7>
-M_Z"1E?\B&A[_*20F_S(K)?]734G_'!,3_R4=(/\>&!S_'A8:_QL7&?\D)2;_
-M'AD;_[VPJ_\Q+RS_66%E_X*'C/\X,#/_-"@I_R\D(_\Q*"+_'A82_T(Y,O]3
-M2$'_*R(B_R(='_\>%AG_*B$A_RH?'O\K(R'_)1X>_Q0/$?\7$A;_%1 6_Q0/
-M$_\E'2#_*R(B_RLG)?\J+"K_9W!P_VEM;_\?'B7_?&QC_UI.1_\Q)B7_1#LT
-M_UQ02__"M;3_+"0G_R8=)/\C'2'_*2<D_WQU;_]N9&#_(1@8_QT8&O\8%AG_
-M'!XC_Q87'O] 1$S_45=A_R(F+O],4ES_/T92_T=07O\]1U+_14]:_T1.6?])
-M4U[_)R4N_RD='O]83$7_A'MU_QX9&?\G(R7_(QXB_R$<(O]P86'_CHF-_T%&
-M3/]=6%/_HY^=_SQ!3?\O+2__.CQ$_T5.7/\J*S+_8%I8_ZB=G/];5E#_P+.H
-M_Z62AO^/@WK_0DI&_U-;5_]P<G#_-C<^_TY/5O\H*B__.CQ!_RPN,_\>("C_
-M("$H_SLZ0/\D(B7_'AH8_T(Z-O]0143_(1T?_R4A(_\B'B#_(Q\A_R8B)/_I
-MU-#_HYV;_VQT=O]234__]=_=__KAX/_[XN'__N7D___IXO__Z>+__^KB___K
-MYO__Z^;_E8B-_R$8'_\A'"#_*B4@_TI"0/\5#@[_)!P?_QT7&_\@&!O_'AL:
-M_R@D)O]33$S_M*>F_S(P,O]A:&[_2D]5_R\G*_\S*"?_+B0@_R\E(?\;%1/_
-M+B@@_S\W+?\;$Q'_*20F_QX9&_\K(B+_,28E_RD@(/\H("/_%A 4_QP6'O\3
-M#A3_% \3_R$<'O\E'A[_*B4E_S@Z./]I<G+_8V=I_QL:(?]N8EG_8550_S G
-M)_\[-R__-RXG_\>YMO\Q*2S_)2 B_SLV,?^+@GO_:5E/_QT1#?\I("#_*B4G
-M_S0R-?\7&1[_)"4L_TE-5?]67&;_1$I4_T]48/\Z04W_0DM9_U-:9O]#35C_
-M1E%<_TY79?\B'B?_+"(E_W5K9_\;%A'_)B(D_R >(?\A'"#_'18=_YJ-C/_@
-MV-O_/D%&_V!;5O^8E)+_-3M#_S P,_]+3U?_&A\E_XN)AO^QIZ/_8UI:_ZJD
-MG/^:BW[_IYB+_V5E7/\\2DG_*S<T_T]44/] 0D?_4E5:_QL=(O\Z.3__*BPQ
-M_R,D*_\G)S#_0T%$_RLG*?\E(2/_.3(R_\&YO/\J*"O_'AXA_R$@'_\H(R/_
-M*20D_[JKJ_]S<&__765I_R\I+?_VX-C__>/8___HW?__Z^#_^^3?___KY___
-MZN;__^WG__WJY/^-?(;_(!<>_QT;'O\?&AS_.30V_Q<3%?\<&!K_'AH<_R,?
-M'?]S;FG_M*NE_U!#/O]22DC_*2<I_T1,3O]#2$W_,"LM_RHC(_\F'Q__*2(B
-M_Q@2%O\C(!O_)248_Q82$/\C'B+_'AH<_RLD)/\L)"+_)R(D_R<B)O\6$17_
-M%1 4_Q00$O\<&!K_)" B_R0@(O\J(B7_+2LM_VAQ<?]=9&3_'ALA_U9/0_]R
-M9&'_(ATA_S@^.O\C'AC_Q+>R_R\G*O\C(!__?75S_R,6%?\E'1O_(ATA_R0<
-M'_\H(2'_(1TE_Q@8(?\A(2K_1TA3_TY17?]-4V/_1DY>_T5-7?\Z0E+_6U]N
-M_T]99_]'5F/_3UAF_R<F+?\D'R/_(!L?_R0?(_\F)";_'AH<_QL7&?\7$A3_
-MNK:T_][1UO]%1$K_6E)._Y>1C_\Y.3S_;W!W_U!06?]E:&G_?W]\_X!X=/^\
-MJZ7_GY2-_Y>,A?]D7%C_1TU)_S="0_\J-3;_-#L[_X.)A?])3U'_)20J_S(O
-M-?\A(RC_)RTO_R,D+_\Z/#G_Y.'@_RLH+O\A'![_IIN:_R$9'/\?'"+_+BLJ
-M_Z.AF?^<F93_ULG(_[FMJ?_AU]/_^.;C__OBV___Y][__^?>___HW___ZN+_
-M_^OC__[JXO__Z^/__NOC_WUL=O\>%1S_&!89_Q@3%?\M*"K_&!06_QH6&/\<
-M&!K_65!*_S@O*?\T+BS_03P^_T5 0O\B("/_04E-_U9;8?\H(R7_*R0D_R8?
-M'_\L)27_%A 4_QH7%O\<&A7_%1$3_Q82%/\;%QG_)A\?_RXF)/\F'Q__)2 B
-M_Q81$_\;%AC_)2 @_RDD)/\F(2'_)B$A_R<?(O\F)";_9W!P_V-J:O\>&R'_
-M3D<[_V]A7O\;%AK_0$5%_QL:&?]G8ES_)B0?_QX?(/\7$A;_(AH>_R$?(O\A
-M'B3_(1D<_R(;&_\;%Q__("(J_SD[0_\_14__2E%=_T)+6?\Z0U'_1D]=_U9?
-M;?\_3%G_2%5B_TE47_]-5V'_-S8\_R@C)_\@&Q__(!L?_X%Y?/\I(23_'!<9
-M_QL7&?^>F);_KI^D_T-%2O]74DW_D8J*_TA"1O_CU=W_Y=KA_Y&/F/]<5%?_
-MO*RC_[RIG?]]>W3_24Q&_S]$0O\Y1T;_+C<W_SE"0O^.E97_+C4U_S<]/_\Y
-M.#[_&!4;_S$S./\U.SW_*BLV_U!.2__<U=7_)28M_Q87&/\W,##_)R$E_Q@3
-M%_\>(!W_9VID_WEV<?_@T,?_SKBO__SDV__XWM7__.+9___FW?__Y][__^C?
-M___JXO__Z^/__NKB__[JXO__Z^/_;EUG_R$8'_\3$13_&106_R ;'?\5$1/_
-M&A88_QH6&/\D'!K_*!\?_T,^/O\]/#O_0SU!_QX;(?])4%;_3E):_S8P-/\I
-M(B+_*R0D_RHC(_\6$A3_%1,5_Q,1$_\4$A3_$@X0_R <'O\C'!S_-"PJ_R8?
-M'_\I(B+_)!T=_R@A(?\I(R'_*2,A_RDC(?\L)B3_*B(E_RXL+O]B:VO_96QL
-M_R =(_\[-"C_AGAU_Q@3%_\7%Q3_7UU8_UI84?\C'!S_&A@;_R(=(?\C&Q__
-M(!L?_R(=(_\@&!O_*2(B_R4A*?\D)B[_+C0\_SM#3?\\1E'_0DQ7_TI47_]$
-M3EG_1U%<_SY(5O]!2%3_7EYG_Y&3F/]!/T+_(ATA_RDD*/\E("3_3T-&_R@9
-M'?\>%AG_'AH<_]S4TO_PW^7_0T5*_V5C7O^"@(+_8%I>_^C6VO_IW=[_V-+:
-M_^[@X?^]KJ'_BH)X_TU/3?\X04'_.$='_R\Y/?]%2DK_B9&._S Y.?]!3$W_
-M/T=+_R,B*/^?G*+_,S4Z_RPT-O\Q,CW_75E7_^;8V?]*04C_F)*0_YF4C_^/
-MCHW_C8N(_V1I9_]=9&3_9F5>_^W=T__VW-'__]_5__[CV/__YMW__^;=___E
-MW/__Z-___^OC__SHX/_ZYM[__NKB___JXO]:25/_(1@?_QL9'/\=&!K_&!,5
-M_Q41$_\6$A3_%A(4_QT6'?\E'R/_/#<W_T5"/?\<%!C_&A8>_TU36_](2U;_
-M/SD]_R<@(/\B&QO_*"$A_Q42$?\3$13_&!89_Q(0$O\3#Q'_'1D;_R4>'O\R
-M*BC_*2$?_S H)O\J(B#_+"0B_R@@'/\O)R/_+B8B_RHB'O\J(R/_(R$C_UIC
-M8_]C:FK_)2(H_S I'?^8BH?_-3 T_W5P:O]%0C?_(QL7_QP-$O\B&AW_(1L9
-M_R<<&_\A'1O_'QH>_R,;'O\E'A[_)2$I_S0V/O\T.D+_0TM5_SU'4O\U/TG_
-M0$I4_T]98_\X0DS_,3M)_SX^3?^KH:O_I)ZB_SLV.O\F(27_(1P@_QP7&_]2
-M0T?_,B,G_R(8&_\/#0__J9Z=_^/2V/];76+_7%I5_W%V=O]A7&#_Y-+4_^/9
-MU?_HX.3_NJVH_XA^</],44O_.C\__S]'2?\A+S+_459<_XB,BO\V/#C_0TM-
-M_SI&2O\Z0D;_'QXD_]C5V_\V.#W_+C8X_R\P._]=65?_Z=?9_UU+3?_@T<O_
-MGI2)_U]@6?]=7%7_6%U=_U9B8?]O;F?_[-_4__??UO_]W=7_^]_7__SBV?__
->YMW__N3;___GWO__ZN+_^^??__[JXO_]Z>'__^CA
-
-end
diff --git a/Lib/test/testimgr.uue b/Lib/test/testimgr.uue
deleted file mode 100644
index 76e9488d02c..00000000000
--- a/Lib/test/testimgr.uue
+++ /dev/null
@@ -1,1170 +0,0 @@
-begin 755 test.rawimg.rev
-M_UI)4_\A&!__&QD<_QT8&O\8$Q7_%1$3_Q82%/\6$A3_'18=_R4?(_\\-S?_
-M14(]_QP4&/\:%A[_35-;_TA+5O\_.3W_)R @_R(;&_\H(2'_%1(1_Q,1%/\8
-M%AG_$A 2_Q,/$?\=&1O_)1X>_S(J*/\I(1__,"@F_RHB(/\L)"+_*" <_R\G
-M(_\N)B+_*B(>_RHC(_\C(2/_6F-C_V-J:O\E(BC_,"D=_YB*A_\U,#3_=7!J
-M_T5"-_\C&Q?_' T2_R(:'?\A&QG_)QP;_R$=&_\?&A[_(QL>_R4>'O\E(2G_
-M-#8^_S0Z0O]#2U7_/4=2_S4_2?] 2E3_3UEC_SA"3/\Q.TG_/CY-_ZNAJ_^D
-MGJ+_.S8Z_R8A)?\A'"#_'!<;_U)#1_\R(R?_(A@;_P\-#_^IGIW_X]+8_UM=
-M8O]<6E7_<79V_V%<8/_DTM3_X]G5_^C@Y/^ZK:C_B'YP_TQ12_\Z/S__/T=)
-M_R$O,O]15ES_B(R*_S8\./]#2TW_.D9*_SI"1O\?'B3_V-7;_S8X/?\N-CC_
-M+S [_UU95__IU]G_74M-_^#1R_^>E(G_7V!9_UU<5?]875W_5F)A_V]N9__L
-MW]3_]]_6__W=U?_[W]?__.+9___FW?_^Y-O__^?>___JXO_[Y]___NKB__WI
-MX?__Z.'_;EUG_R$8'_\3$13_&106_R ;'?\5$1/_&A88_QH6&/\D'!K_*!\?
-M_T,^/O\]/#O_0SU!_QX;(?])4%;_3E):_S8P-/\I(B+_*R0D_RHC(_\6$A3_
-M%1,5_Q,1$_\4$A3_$@X0_R <'O\C'!S_-"PJ_R8?'_\I(B+_)!T=_R@A(?\I
-M(R'_*2,A_RDC(?\L)B3_*B(E_RXL+O]B:VO_96QL_R =(_\[-"C_AGAU_Q@3
-M%_\7%Q3_7UU8_UI84?\C'!S_&A@;_R(=(?\C&Q__(!L?_R(=(_\@&!O_*2(B
-M_R4A*?\D)B[_+C0\_SM#3?\\1E'_0DQ7_TI47_]$3EG_1U%<_SY(5O]!2%3_
-M7EYG_Y&3F/]!/T+_(ATA_RDD*/\E("3_3T-&_R@9'?\>%AG_'AH<_]S4TO_P
-MW^7_0T5*_V5C7O^"@(+_8%I>_^C6VO_IW=[_V-+:_^[@X?^]KJ'_BH)X_TU/
-M3?\X04'_.$='_R\Y/?]%2DK_B9&._S Y.?]!3$W_/T=+_R,B*/^?G*+_,S4Z
-M_RPT-O\Q,CW_75E7_^;8V?]*04C_F)*0_YF4C_^/CHW_C8N(_V1I9_]=9&3_
-M9F5>_^W=T__VW-'__]_5__[CV/__YMW__^;=___EW/__Z-___^OC__SHX/_Z
-MYM[__NKB___JXO]];';_'A4<_Q@6&?\8$Q7_+2@J_Q@4%O\:%AC_'!@:_UE0
-M2O\X+RG_-"XL_T$\/O]%0$+_(B C_T%)3?]66V'_*",E_RLD)/\F'Q__+"4E
-M_Q80%/\:%Q;_'!H5_Q41$_\6$A3_&Q<9_R8?'_\N)B3_)A\?_R4@(O\6$1/_
-M&Q88_R4@(/\I)"3_)B$A_R8A(?\G'R+_)B0F_V=P</]C:FK_'ALA_TY'._]O
-M85[_&Q8:_T!%1?\;&AG_9V)<_R8D'_\>'R#_%Q(6_R(:'O\A'R+_(1XD_R$9
-M'/\B&QO_&Q<?_R B*O\Y.T/_/T5/_TI17?]"2UG_.D-1_T9/7?]67VW_/TQ9
-M_TA58O])5%__35=A_S<V//\H(R?_(!L?_R ;'_^!>7S_*2$D_QP7&?\;%QG_
-MGIB6_ZZ?I/]#14K_5U)-_Y&*BO](0D;_X]7=_^7:X?^1CYC_7%17_[RLH_^\
-MJ9W_?7MT_TE,1O\_1$+_.4=&_RXW-_\Y0D+_CI65_RXU-?\W/3__.3@^_Q@5
-M&_\Q,SC_-3L]_RHK-O]03DO_W-75_R4F+?\6%QC_-S P_R<A)?\8$Q?_'B =
-M_V=J9/]Y=G'_X-#'_\ZXK__\Y-O_^-[5__SBV?__YMW__^?>___HW___ZN+_
-M_^OC__[JXO_^ZN+__^OC_XU\AO\@%Q[_'1L>_Q\:'/\Y-#;_%Q,5_QP8&O\>
-M&AS_(Q\=_W-N:?^TJZ7_4$,^_U)*2/\I)RG_1$Q._T-(3?\P*RW_*B,C_R8?
-M'_\I(B+_&!(6_R,@&_\E)1C_%A(0_R,>(O\>&AS_*R0D_RPD(O\G(B3_)R(F
-M_Q81%?\5$!3_%! 2_QP8&O\D("+_)" B_RHB)?\M*RW_:'%Q_UUD9/\>&R'_
-M5D]#_W)D8?\B'2'_.#XZ_R,>&/_$M[+_+R<J_R,@'_]]=7/_(Q85_R4=&_\B
-M'2'_)!P?_R@A(?\A'27_&!@A_R$A*O]'2%/_3E%=_TU38_]&3E[_14U=_SI"
-M4O];7V[_3UEG_T=68_]/6&;_)R8M_R0?(_\@&Q__)!\C_R8D)O\>&AS_&Q<9
-M_Q<2%/^ZMK3_WM'6_T5$2O]:4D[_EY&/_SDY//]O<'?_4%!9_V5H:?]_?WS_
-M@'AT_[RKI?^?E(W_EXR%_V1<6/]'34G_-T)#_RHU-O\T.SO_@XF%_TE/4?\E
-M)"K_,B\U_R$C*/\G+2__(R0O_SH\.?_DX>#_*R@N_R$<'O^FFYK_(1D<_Q\<
-M(O\N*RK_HZ&9_YR9E/_6R<C_N:VI_^'7T__XYN/_^^+;___GWO__Y][__^C?
-M___JXO__Z^/__NKB___KX__^Z^/_E8B-_R$8'_\A'"#_*B4@_TI"0/\5#@[_
-M)!P?_QT7&_\@&!O_'AL:_R@D)O]33$S_M*>F_S(P,O]A:&[_2D]5_R\G*_\S
-M*"?_+B0@_R\E(?\;%1/_+B@@_S\W+?\;$Q'_*20F_QX9&_\K(B+_,28E_RD@
-M(/\H("/_%A 4_QP6'O\3#A3_% \3_R$<'O\E'A[_*B4E_S@Z./]I<G+_8V=I
-M_QL:(?]N8EG_8550_S G)_\[-R__-RXG_\>YMO\Q*2S_)2 B_SLV,?^+@GO_
-M:5E/_QT1#?\I("#_*B4G_S0R-?\7&1[_)"4L_TE-5?]67&;_1$I4_T]48/\Z
-M04W_0DM9_U-:9O]#35C_1E%<_TY79?\B'B?_+"(E_W5K9_\;%A'_)B(D_R >
-M(?\A'"#_'18=_YJ-C/_@V-O_/D%&_V!;5O^8E)+_-3M#_S P,_]+3U?_&A\E
-M_XN)AO^QIZ/_8UI:_ZJDG/^:BW[_IYB+_V5E7/\\2DG_*S<T_T]44/] 0D?_
-M4E5:_QL=(O\Z.3__*BPQ_R,D*_\G)S#_0T%$_RLG*?\E(2/_.3(R_\&YO/\J
-M*"O_'AXA_R$@'_\H(R/_*20D_[JKJ_]S<&__765I_R\I+?_VX-C__>/8___H
-MW?__Z^#_^^3?___KY___ZN;__^WG__WJY/^@D97_(AH>_RDD)O\R*R7_5TU)
-M_QP3$_\E'2#_'A@<_QX6&O\;%QG_)"4F_QX9&_^]L*O_,2\L_UEA9?^"AXS_
-M.# S_S0H*?\O)"/_,2@B_QX6$O]".3+_4TA!_RLB(O\B'1__'A89_RHA(?\J
-M'Q[_*R,A_R4>'O\4#Q'_%Q(6_Q40%O\4#Q/_)1T@_RLB(O\K)R7_*BPJ_V=P
-M</]I;6__'QXE_WQL8_]:3D?_,28E_T0[-/]<4$O_PK6T_RPD)_\F'23_(QTA
-M_RDG)/]\=6__;F1@_R$8&/\=&!K_&!89_QP>(_\6%Q[_0$1,_U%78?\B)B[_
-M3%)<_S]&4O]'4%[_/4=2_T5/6O]$3EG_25->_R<E+O\I'1[_6$Q%_X1[=?\>
-M&1G_)R,E_R,>(O\A'"+_<&%A_XZ)C?]!1DS_75A3_Z.?G?\\04W_+RTO_SH\
-M1/]%3ES_*BLR_V!:6/^HG9S_6U90_\"SJ/^EDH;_CX-Z_T)*1O]36U?_<')P
-M_S8W/O].3U;_*"HO_SH\0?\L+C/_'B H_R A*/\[.D#_)"(E_QX:&/]".C;_
-M4$5$_R$='_\E(2/_(AX@_R,?(?\F(B3_Z=30_Z.=F_]L=';_4DU/__7?W?_Z
-MX>#_^^+A__[EY/__Z>+__^GB___JXO__Z^;__^OF_Z.4E?\C&1S_+R@H_T W
-M,/]@5E+_&A$1_R8>(?\@&A[_)!XB_QX:'/\M*RC_(QL7_\*SK?\Y-3/_0D=,
-M_VQP<O\V+BS_+B(C_S$E*/\S*B3_)!T7_S$H(?^3B('_.3 P_R$<'O\?%QK_
-M*B$A_S E)/\O)B;_)1X>_Q@4$O\<&A?_%1 4_QL6&O\F'B'_*!\?_RHF)/]%
-M1T7_8VQL_V!D9O\@'R7_BGAN_U!".?\K'QO_13LQ_W5I9/^ZK:S_*2$D_R8;
-M(O\O*"__'!XA_P\2$_]12TG_*2 @_R$<'O\@'B'_&QTB_RDJ,?\\0$C_1DQ6
-M_RTQ.?]:8&K_/T92_TE28/]-5V+_0TU8_T),5_]16V;_(2,H_RHB(/^DEHW_
-M2CPS_XE^??\8#P__)!\A_R$<(/]01T?_0D1)_T5+4_]G7UW_<FUM_SU"3O\O
-M+2__/T%)_T529?\L-D7_*"@Q_U%(2/^TL*[_9%M4_[VLG_^CCX?_5UA1_VAM
-M:?^_O<#_,C0Y_T]15O\A(RC_,#(W_RLM,O\A(RO_+2\V_SH\0?\V-CG_9%M4
-M_X-S:?]^;F7_?'%J_RX@(?\E'2#_(R$C_R@C)?_PUM/_Q;BW_U==7_\R+2W_
-M^=W9___AV___X=O__^+<___FW___YN+__^KC___IX/__Y=[_HY*2_R@<'?\X
-M,"[_2#XT_V9:5?\;$A+_*R,F_R,=(?\K)2G_(AX@_SX[-O]#-S#_RK6S_RXF
-M*O]-3EG_9V1P_S$I)?\O(R3_*APD_RLB'/\E'AC_;&-<_[.HH?\V+2W_'QH<
-M_QP4%_\M)"3_+2(A_RTD)/\E'A[_(1X9_RLJ(_\6$A3_'AD=_RDA)/\F'1W_
-M*"0B_S]!/_]@:6G_8V=I_R >(?^@C8'_8%!&_SDM)O]?54O_D(1__[6HI_\F
-M'B'_)AP?_S4P,O\N+"[_85U?_\>^OO\N)27_(QX@_R$?(O\;'2+_-C<^_TU1
-M6?\^1$[_+C(Z_TE/6?]"257_14Y<_T!*5?]&4%O_/DA3_TE37O\A(RC_*2$=
-M_ZB8CO^XI9O_:EI7_X5X=_\B&QO_)"(D_R@C(_\T.3__0DA2_["GI_^EH*#_
-M24Y:_TU+3?\X.D+_(2LZ_SA#5/\H,4+_'1TH_RDD*/^AG9O_6%-'_Z><D?^)
-MB7[_75M8_]?1V?\Y/$'_2TY3_R$C*/\M+S3_+2\T_RHN-O\K,#;_.#M _S]!
-M1/]K7U#_K9B&_[JBD_]C4D3_LYR=_R\C)O\@(2+_)B$C_^S0T_^[KK/_9W)Y
-M_T=(3__FV.#_Z=GA_^K:XO_FUM[_YMGD_]S,U/_ZY>'__^C;___FV_^SI)[_
-M)AX:_SDT+O]72CW_<6-:_Q@2%O\R*2G_)AT=_R@A*?\=&1O_2TQ%_U%(0?_(
-MMK/_*!XG_V%D=?]%2%3_.#,S_R<=(/\S)RK_,R@A_RLE'?]N95[_O[2M_S(I
-M*?\A'![_'Q<:_RLB(O\Q)B7_*B$A_R<A'_\J*"#_/S@R_R 8&_\@&QW_)R(B
-M_R4A'_\J(R/_3U!1_UUF9O]A9&7_(QXB_Z>4BO]N75?_7%!'_W!F6_^JGIG_
-MLZ6F_R<B)O\D("+_240__S(M)_]S<6[_R\"__RPI*/\C'2'_(1TE_R,O-O\Z
-M/#K_:EU8_R,>(/]$257_0TI6_T%)4_]#35C_3U)=_TM07/]+563_3%=B_R$D
-M)?\M*"/_IY>._[JEF?^ECX?_1#8S_R<=(/\F("3_+BXQ_SQ#2?]'4%?_8V=O
-M_Z*BJ_]4763_+BLQ_S4T0?\U.D;_&A@H_SDW1_\J,D+_'" H_R @(_^,B(;_
-M9UM6_XJ.AO^&BX?_?'Q__S<Y/O].45;_&QTB_RHG+?\V.#W_'R,K_RTR./\S
-M-3K_/S]"_X=Z9_^^HYC_UKNJ_X-P6/_%K:3_H9*-_S$J*O\J(R/_Z<W/_\>Z
-MQ_\T.5+_/S]4_U!$7?]94V?_8%QL_VMG=_][9G+_CG9[__SBW___Z-W__^KA
-M_Z:1C?\N(A[_/S@R_V111?]V9ES_&A49_T X-O\P*";_*24M_R4C)?]H:%__
-M6U),_[BJI_\P*C+_3E%C_T9(5_\P*RW_*R$D_S0H*?\P)1[_*"(:_XV%>__&
-MN[3_+B0G_Q\9'?\?%QK_+",C_RTB(?\L(R/_)B(@_SHY+O]?5E#_)A\?_Q\:
-M'/\H(R/_(!P:_RTD)/]35%7_7F=G_V)E9O\@'2/_JIF3_S@K*O]:5%+_<6MC
-M_[2JIO^GFYS_)B D_R8C(O]94DS_0STS_W9T;__+OKW_*2@G_R$:(?\@'"7_
-M.3Y*_T!"1?^"@'C_F(Z*_R =(_]:7&3_2$];_TU79?]!14W_0T92_TQ69/]-
-M55__("$B_R\I)_^IG9;_HHR#_ZR6CO^CDY#_*1XC_R0>(O\J+#'_25!6_TM4
-M6_]+55__4%%<_UQE:_^WL[O_03]/_RDO.?^7DYO_(A\E_RLU0/\F+C[_&AXM
-M_R$@)O^%@(#_3E)0_S4Z./\9&Q[_.3@^_T%$2?\>'2/_-3(X_R$C*/\H+#3_
-M)2<N_SP^0_\^/D'_F8][_\&FG__DR[K_F89N_]/#NO^6B(G_,RTQ_R<B)/_G
-MTL;_QKVW_T]76_]A9VG_X<S1__;>V__^Y]O__^C?__O>W?_#I:?__.#<___G
-MWO__YM__MYV@_S$?(?])/3G_=F%5_W]M8_\B'2'_-BXL_S\W-?\D)BW_)"(D
-M_WUY<?]M85S_K*"<_S(N-O]66VW_24E8_S$L+O\H'B'_,"0E_S,H(?\N*"#_
-M;65;_\F^M_\S*2S_(!H>_R$9'/\P)R?_+R0C_R\F)O\A'1O_7UY3_XZ%?_\G
-M("#_(QX@_Q\:&O\J)B3_+20D_UE:6_]:8V/_:6QM_QX=(_^QI9[_'Q<:_S<W
-M.O]#0#O_O;6S_Z.7F/\J(B7_*2,A_U5,1?].1SO_;6MD_\:YN/\N+2S_(!D@
-M_RDE+O]03%S_+BXW_Q4=&?]$/SG_;&!<_S@S.?])4%[_14Y<_T%&3/]"2%+_
-M/D51_T!$3/\=&QW_)1X>_["DG_^<C(/_M*"8_[.CH/\I'B/_)!XB_S8U._]5
-M5U[_*S$Y_UYF</]?8&O_769L_UE57?\O+3W_.$),_SD]._^HJ:/_)"LQ_QXH
-M/?\F+4'_'2(N_QTB)_\P-CC_.3Q!_QD;'O\:&AW_-SH__RHI+_\B'R7_.CQ!
-M_RLO-_\R-#O_+S$V_S<W.O^<DX+_QJVH_^C0P?^DDWS_S+^^_SLT._\A'RC_
-M)B$G_^70S/_/P;[_6EQ?_SD]/_^ >7G_\>#:__OBU?__Y-G__^7A___CW___
-MY=[__^7<__WDW?^<A(W_*AHB_T$[.?]];%[_>VMA_R0?(_]!.3?_0CHX_R\X
-M/O\R-3;_BX)[_WEL9_^^M+#_-C4\_T]29/],2%C_*R,F_RLA)/\O(R3_+"$:
-M_RHD'/]X<&;_TL? _S(H*_\@&A[_(1D<_R\F)O\N(R+_+B4E_R<C(?]K:E__
-MN*^I_R@A(?\A'![_(QX>_RPH)O\L(R/_8F-D_V)K:_]A9&7_(!X;_[JIF_\E
-M'1O_=WAY_Q@7%O_$O;W_E(:'_R@@'O\F'AK_6U%'_V5<3O]B7E;_N:RK_RLJ
-M*?\F'R;_&14>_SA!2/\G)BW_,"HN_R8H)O][<W'_/SM$_S4[2_]455S_3U%4
-M_T5+4_],4ES_.CE _QX8'/\K(R;_L:>C_ZB=EO^XI)S_MZ>D_RTB)_\E'R/_
-M,"\U_TY/5O\D)B[_;&]Z_UU>:?]67V7_55%9_S<U1?] 2EG_-SP\_RTK)O\_
-M0$O_)R\__R\V1/\Q-D+_'!XM_QH=*/]$1D[_/#Y#_S4U./\\/T3_)20J_RHG
-M+?\_04;_-#A _S8X/_\X.C__)B8I_Z"6A__%K:K_Y]##_Z.3?__3Q\C_/C<_
-M_R4?)_\I(B+_Z]/6_]7#Q?]#/T'_:&IM_U-=8?^UL:__^.'<__SEX/__Y][_
-M_^7<___FW?__Y-W__^CA_Z*1E_\C&Q__&104_XQ[;O^DE(O_)2 @_SX[.O]$
-M/S__-T%%_T1)1?^.@WS_CX%^_ZF@H/\_/$C_/D!5_UA28/\N)R?_+2$B_RTB
-M(?\J)2#_'!H5_V=B7?_+O\#_*B4G_R$<'O\?&!C_)R @_S(K*_\L)27_+"@@
-M_X%\</_'N[;_*2(B_R$<'/\C'A[_+BDI_R@H)?]@8F7_96MG_V1D9_\B'1W_
-MPJZF_S\T+?^#@GO_&QP6_]K+S/]R9F?_*24G_S H)/]22D#_>G%C_UI/2/^O
-MI*/_,2PL_QP7'?\L*C/_.4--_RDJ,?]_=G;_)B >_];)SO]*35C_14A3_X=\
-M>_]>6%;_*" >_TQ/6O\Z/$3_'AH<_RLF*/^=DI'_LJ>@_[RJIO^]KJ[_+",C
-M_R8B)/\U-CW_5EA@_R B*?\<'B/_C(V4_TI,4_] 04C_9F=R_T9)5/]N<'/_
-MKZ.D_T5#4_\H,#K_:&IM_SHX._\E*#3_)BDU_T!"2O]66%__0T5*_S<]/_\M
-M+3#_:65M_S] 1_\P,3S_-3<^_T9*3/\O,3;_?G)N_Z"+B?_1N;;_=6)<_]C*
-MTO]83EC_*"$K_R ;(?_IU-+_X<_+_T4^./].1D+_34U*_WU\>__<S\[_^-G3
-M___IX?__YM___^?@___FW__]Y-W_P+*S_RLC)O\A&QG_K9J0_Z>8D_\P*BC_
-M04 __S8Q,_]%2TW_1$A&_Y&(@O^:C(G_CH.(_RPJ.O]$15S_<6U]_RLC)O\M
-M(B'_,"4D_QX:&/\>'!?_&A02_\B_O_\G(B3_(AT=_R$:&O\G("#_*R0D_RXG
-M)_\M)Q__AX!R_\_#OO\H(2'_(!L;_R8A(?\F(2'_)B0A_UQ@7O]G;&K_9&-B
-M_R(>'/^]J*/_-RTC_YV8DO\].S;_WLW-_V%86/\C(2/_*",E_S8S+O^ >W7_
-M3$1 _ZJBH/\J(R/_(!LA_QD9(O\]1%#_/3Y%_X^'A?]934G_X,[2_T1,5O]
-M2%C_+BDO_TI&2/^!>'+_(2$L_S4R/O\H(R7_,2<J_Z&1CO_ L:O_J):3_[6F
-MIO\L(R/_)B(D_S<Y0/].4%?_&!H?_TY.4?\>("7_0$-(_TQ06/\[04O_3E!8
-M_VIL;__4Q<G_.SE)_RDS/?]'2$G_;VQK_R4H-/\S-D+_/D!(_UQ>9?]+3E/_
-M-#H\_QP<'_^>FJ+_1D9/_RPO._\N,#?_,30U_TM*4/^KI*3_V\[-_^G8V/_K
-MWMW_XM31_[^MJ?^5A'[_=V1<_^?2S?_MV]?_T\O'_];+RO_3S\W_/T)#_V]Q
-M;__JV];_^=[7___DW?__Y=[__^7>___GX/_$N[7_13LW_WIL:?_4OK7_FHJ'
-M_RTF)O\_/4#_-B\V_QP='O\\.SK_E)"._[&EH/]P:&S_)R<T_T)(6/]F9'3_
-M)1T@_RXC(O\M(B'_)2$?_R4C'O\@&!3_S\+!_RTF)O\?&!C_(AL;_RDB(O\O
-M*"C_+28F_S J(O^3C'[_S,"[_RLD)/\B'1W_)2 @_RTH*/\K(B+_7V1>_UYE
-M<_]:6F7_&QD4_\*MJ/]'.3#_IIV7_V%?6O_>S<W_1#L[_R(@(O\>&1W_+BLJ
-M_S(N+/]W;W+_HIF9_RTF)O\A'"+_'AXG_T%'4?]'1TK_FY&-_[6IHO_:R,K_
-M4EID_T1,8/\?'BO_%AL@_U-,1O]E7V?_*20P_RHB)O\X*2W_K)>5_]G(PO^7
-MA8+_>6IJ_RLB(O\G(R7_+S(W_TY15O\W-SK_AH&#_QP?(/\/%1?_2U%9_T!'
-M4_]'2%/_B8N._]O,T/]%0U/_-T%+_R(C)/\X-33_+"\[_SU 3/]"1$S_3$Y5
-M_TM.4_]"2$K_)24H_[&MM?]!04K_+S,[_S8Y/O])2TG_D(N-_R$='_\O*"C_
-M."\O_T(]/?](1DC_:F5E_Y&)A_^IG9G_Z]S6_]7(P_]:4$S_<VUK_VAG9O]/
-M5%+_/D9#_TY24/_'LJW_^-W6__G>U__^X]S__>3=_\S'N_]<44K_II*._^')
-MP/^9B(C_,2DL_S@U._]$/47_)B$A_R ?'O\N+"[_O[:P_XB#@_\\0D3_9G)V
-M_V]Q>/\O*BK_,28E_RL@'_\D(![_6UE2_T(Y,__0PK__,"@F_R(;&_\E'A[_
-M,"DI_R@A(?\J(R/_+RDA_Y")>__)O;C_*R0D_R(='?\H(R/_*20D_RLB*?]8
-M8E__("E8_SP\9_\<'AS_O:BC_V)22?^WJJ7_='%L_]W,S/\^-37_(R$C_R@@
-M(_\^.#;_.S0N_V=;7/^4BXO_*R0D_QX9'_\:&B/_/$!(_SPZ//^GFY;_Q[FP
-M_]O)S?](4%K_25!>_T]'2_\B(2?_4$4^_X%[?_]"0D__'1L>_R<=(/^FF)7_
-MT<6^_ZJ:E_^VIZ?_,2@H_R<C)?\V/#[_3%!2_UA45O^FGIS_-3HV_R(K*_](
-M45C_1D]=_U!17/^'B8S_X]38_U)08/\W04O_7V!A_[Z[NO\V.47_*"LW_S]!
-M2?]&2$__14A-_TA.4/\I*2S_K:FQ_TE)4O\Q.#[_,34W_TM)1O_+PL+_)2 B
-M_R(:'?^YK;#_*",E_R =(_\<&R'_%A89_R4H*?^SK*;_V,O&_^+6TO^[M[7_
-M0D='_W!V<O]26%3_.3Y#_^/7T__OW-3_[-G1__/@V/_[Y]__TL:W_VE=5/_7
-MR,+_XL_%_X5W=/\L(R/_,RLN_T4_0_]H8U[_,2TK_R4>'O_6R<3_AH."_UI@
-M8O^/EYO_8F-D_RLF)O\N)R?_+24A_RLF(?]A757_HY>0_]3"O_\I("#_(AT=
-M_R0='?\K)"3_+R@H_RXE)?\B'AS_3TU(_\O O_\M)"3_(QP<_RLD)/\M)B;_
-M(14>_U588_\@)%'_-S!?_QX<'__'JZ?_<FI@_\>MJO^4CXK_W-'0_S@O+_\D
-M'R'_*B(@_UU62/]V:F7_V\S-_X5]@/\H(B;_(!H>_QD9(O\^/T;_.3@W_[6O
-MI__3QL'_V,?-_T--6/]%2U7_?G9T_UE45/_(N;3_B8.+_T]27?\E(R7_+"<G
-M_ZF=F?^SI)__FHN&_ZN=GO\D'!__+28F_S$F*_]"24G_GJ*@_ZVKIO]B6EC_
-M3%A7_T515O]!2%3_3%18_T(_/O_EV=S_1DE5_T),5O]K:6O_RL/#_S@]2?\J
-M,3?_$1(9_TA(4?])2U+_04=)_RHJ+?^WL;G_/$!(_RPQ-O\P-C[_>W5S_]K.
-MS_\C)2K_'"$G_U-68O\I)##_(ATA_R(@'?\D(AW_(B<E_UI96/]M96/_W=',
-M_[*HI/],4U/_,CX]_XF0D/]>86;_<7AL_Y*(?O^2AH'_?G-L_ZZBD__7R+O_
-M>FQC_]G-QO_ETLC_@')O_RHA(?]!.3W_24))_VIC7?]G8EW_3T=%_]/$O_]A
-M7&#_.3Q'_V-F<O]#0$;_+B<G_RLD)/\N*23_*",=_W-O9_^]L:K_UL3!_RLB
-M(O\A'!S_(QP<_RHC(_\K)"3_,RHJ_R$<'/\D'Q__S,#!_RTD)/\E'A[_)R @
-M_R@A(?\H'1S_(B$:_Q86(_\I)2W_'!T7_\JMJ?]S<&7_S+"M_["HI/_?U]7_
-M-B\O_R0?(?\P*";_>')B_X1X=/_>S]#_;&9J_R@B)O\F("3_'1LD_SY 1?\\
-M.3C_M:^G_^'3T/_5Q,S_3%5C_T1)5?^$?GS_BH.#_];$P/^*@X__1TA3_RPH
-M*O\O*"C_KZ2C_ZN=FO^'=W3_HI:7_R\I+?\K(R'_JI*5_U%)3/_+O\#_O["P
-M_[BGK?]886?_2U=@_S]&5/]'3U/_4DU-_]S1UO]35F+_0T]8_X2"A/_4S<W_
-M/4)._QTC)?\O,3;_3T]8_R8G+O\Z0$+_*"@K_[ZXP/]*3E;_,C<\_S$Y0_]]
-M=7/_V<W._S1#4/\G.T__051L_S$_5O]A8G/_(QPF_RXE)?\H(2'_8%A<_S(J
-M+O_*PK[_HI>0_XJ(@_]/4U'_/4)"_W-[??\Z2UG_86!F_UE<4/]03D?_8UM1
-M_]C(OO]Q8ES_W<_,_^;2RO]W:FG_-2TQ_S\X/_]#/47_9V!:_VYG8?^LHI[_
-MWLO%_VUF;O]#1%7_5E=H_T="3O\M)2C_+28F_RLF(?\V,2O_;&A@_\F]MO_4
-MPK__*R(B_R0?'_\F'Q__+28F_RHC(_\M)R7_2D(^_RH@'/_+O[O_*R(B_R0=
-M'?\B&QO_*R0D_R47'_\C&Q?_(ALB_RXF*?\@(1K_SK*N_W-R9__#J:;_N+.N
-M_]W5T_\V+R__(QX@_S\W-?^5CW__<&1@_]K+S/]E7V/_*2,G_R,=(?\@'B?_
-M/3]$_T5"0?^UKZ?_V,K'_]' R/]!2EC_5%EE_Y"*B/^@F9G_X]'-_W=P?/]&
-M1U+_*",E_RHE)_^LI:7_E(R*_XM^??^<D9;_)2 F_RHB)?]_='/_6EQ:_\2]
-MO?^VL[+_O*ZV_TU57_]"3%K_24Y@_T=.5/]Q;&S_XM?<_TQ/6_\Y14[_A(*$
-M_]K3T_\Y/DK_/3X__U=97/\]/T;_*"<M_Q08&O\D)"?_N[6]_T)&3O]!1DO_
-M,3E#_Y&)A__?T]3_5VEW_S=-8_\G/%7_,$5=_TA<</\7(2__'1\B_R8E)/]0
-M14K_,"<N_Q\:'O^EGY?_L*6>_XZ'@?]M;VW_;G9Z_U9HC/](46+_4%I+_TQ,
-M2?]33D[_X]/*_V=84__ATM+_Y=#+_VQ@8?\Q*C'_.3,[_SPX0?^+@GO_?G5N
-M_[ZRK?_@S,3_349-_SL]3/])2UK_.C8__S H*_\L)27_+RHE_R\J)/^/BX/_
-MS<&Z_]+ O?\N)27_)!\?_RDB(O\J(R/_*"$A_R<D'_]D6U7_PK.N_\S N_\M
-M)2/_)A\?_R0='?\J(R/_(QDC_R,<'/\@&2'_*"$K_Q\D(/^]IJ'_>WMP_\"K
-MI__&P;S_V]/1_S0M+?\D'R'_/34S_ZJDE/]5247_Y]C9_TI$2/\I(R?_(AP@
-M_R >)_\M+S3_B(6$_T Z,O_BU-'_R;C _TM48O]$257_E8^-_Z.<G/_FU-#_
-M7%5A_SH[1O\M)RO_,"HN_ZJEI_\[-C;_AWM\_YN2F?\A'27_(AP@_R,=&_\K
-M+2K_-RXN_R ;'__0Q<K_5V%E_TM77O])4%S_4UM?_VUH:/_>T]C_0$-/_S]+
-M5/\T,C3_S<;&_SQ!3?]*1T;_8&%B_T-(3?]02T__+3$S_RTM,/^JI*S_045-
-M_SM 1?\I,3O_6E)0_]#$Q?^*C8[_?W^"_Y^=IO]676/_+C<^_SL]0O\N)R?_
-M,2@H_[2GHO\J)2?_(" I_TQ'2?^'A'G_I:29_V=L:/]L='C_8W9^_X:(C?^"
-M@G__1T5"_UI54/_HV];_6U%'_^37TO_BSM?_7E)3_S0Q)?\L*";_1#M"_WIN
-M9?^.A7?_R;R[_]W)Q?]!/T'_,3$^_T1$4?](1T[_,"HH_RH>'_\S)RC_-RXH
-M_YB-AO_8R<3_T\+"_RHB)?\C'B#_)AXA_RTD)/\N)B3_-BTG_VYI8__:R,7_
-MS[Z^_RLF)O\E("#_)!\?_R@C(_\4#Q/_%! 2_Q81%?\8$Q?_,"8B_[*EH/]#
-M03K_NK"L_]/'P__<T=#_-"\O_R<B)/\X-#+_O[.D_TD_.__EV=K_0CT__R8B
-M)/\@&Q__(R8Q_T)#3O^HG)?_-"@D_][1T/_&N;[_/$A1_U9=8_^5D(O_FY24
-M_^O>V?]04%O_/4!+_R8A(_\G(R7_*24G_U925/]G8F3_4T]1_R,>(O\K)RG_
-M*B8D_T='1/]G6%S_A(&'_]C0T_]88&K_359=_TA/6_]56F#_=&MK_^;9WO]#
-M1E+_5%MA_T8^0?_;S]+_0$90_W!S=/]I:&__1TI+_YZ:G/\T-CO_+2PR_Z:B
-MJ_\V.43_+S(W_RXT/O^?DI'_L9^A_VM?6O]<5U'_:&EC_VYJ8O]]:V?_P[*X
-M_];,R/_1O[S_=F%?_ZJAH?\D(RG_/S<[_R8D(?^+CHC_9VQJ_U%57?]Q<&__
-M?GQW_U=95O]044O_4U%)_^;%UO]N2&G_W+78__OBW?]52$W_*2(L_RDF,O\U
-M-4#_>G-G_Y6-??_+O[K_Y-#,_T=$2O\S,T#_.#=$_U957/\I(1__,B8G_S,G
-M*/\T*B;_D85^_]G*Q?_%MK;_*R,F_R(='_\E'2#_+B4E_RL@'_\V*B7_@H!Y
-M_]+ O?_2P<'_*20D_R4@(/\F(2'_(AT=_QP7&_\6$17_%Q(6_QL6&O]%-3+_
-MIYN6_TY+1O^FH)[_W<_,_]?,R_\P+2S_)B$C_S(N+/_$MJ?_54U)_^+9V?\Z
-M-37_)B(D_QH8&_\C)C'_0D51_Z:7D?]21$'_X=/4_[>LL_\\2%'_5EMA_YF3
-MD?^0B8G_Z=S7_T9&4?\X.T;_)R,E_R<C)?\E(2/_)B(D_RTI*_^NJJS_(Q\A
-M_R@D)O]M8%7_@WMK_YZ'>_]P8UC_VM+0_U-79O\M-3__14Q8_UI<8_]]='3_
-MZ=K?_T5(5/]/45C_8%99_][/U/]$1U+_CI.3_W1R>_]%2$G_R<3$_S0S.O\L
-M*S+_FIBA_S,T/_\X.T#_)"HT_ZN>G?^NFIS_CGUW_W!D7?]".S7_DH1[_WMH
-M8/_+O\C_03]!_S@S+O]F6UK_/CPY_RHL*O\V-#;_(!TC_S8W./]T>';_:FUR
-M_YF6E?]H9F/_<'5Q_U164_]454__Z+O?_XA.H/^F9-'_QYS2_UQ(4?\U&3/_
-M1S [_S4N*/^)?7G_FHF4_]3(Q/_MVM3_4T]7_S<W1/]44V#_6UIA_RHB(/\K
-M'R#_+R,D_STS+_^#=W#_U,7 _\2UM?\K(R;_(!L=_RDA)/\T*RO_,28E_SPP
-M*_^*B('_W,K'_]3#P_\N*2G_)B$A_R,>'O\J)27_)R(F_QH5&?\A'"#_'!<;
-M_U1$0?^6BH7_8V!;_ZFCH?_;S<K_U<K)_S$N+?\H(R7_+2DG_\6WJ/]>5E+_
-MY-O;_SPW-_\G(R7_'1L>_T!#3O\[/DK_L*&;_U]13O_DUM?_K:&J_T)-6/]3
-M5U__7E=7_X%Z>O_DU]+_3T]:_RTP._\D("+_)2$C_R,?(?\D("+_(AX@_R,?
-M(?\F(B3_(1T?_RLC(?\S,2S_74Y._ZB>FO_7S\W_3U-B_RLS/?] 1U/_7%YE
-M_X^&AO_FU]S_24Q8_U)46_]C65S_VLO0_SH]2/]^@X/_85]H_TE,3?_>V=G_
-M+RXU_R\N-?^4DIO_/#U(_SU 1?\N-#[_MJFH_\"LKO^JD8K_HHA]_ZJ4C/^Y
-MGY3_CG]R_\K#S_\P,S[_(R8G_XU_@/^3@7W_WLO%_TH\/?\<%A[_(1\B_UQ>
-M6_]K;VW_='%P_W]^??]W?'K_9VMI_UU@8?_>V\__+2HI_S N-_\X/CK_?WZ+
-M_V9#BO^C>Z__12Q+_ZJ*O?][6)C_T\+,_^S:T/]*1D__/CY+_U-27_\]/$/_
-M*R,A_R\C)/\P)"7_/C0P_W)F7__7R,/_K)V=_RLC)O\@&QW_)Q\B_S,J*O\O
-M)"/_,24@_XF'@/_=R\C_TL'!_R8A(?\D'Q__*",C_RLF)O\H(R?_*20H_R8A
-M)?\?&A[_<V-@_XR >_]Z=W+_IZ&?_^'3T/_*O[[_+RPK_R4@(O\L*";_Q+:G
-M_W5M:?_GWM[_.C4U_R<C)?\D(B7_4E5@_T1'4_^ZJZ7_=6=D_^G;W/^5B9+_
-M0$I8_UQ?:O^CFY[_GYB8_^C;UO]#0T[_+C$\_RHF*/\F(B3_(Q\A_R0@(O\B
-M'B#_(AX@_R <'O\B'B#_%Q 8_RDN-/_*Q<O_O+2X_]S3T_]1563_(2DS_T!'
-M4_]L;G7_EXZ._]S-TO].45W_;&YU_W=M</_=SM/_1$=2_X:+B_]A7VC_/D%"
-M_\;!P?\G)BW_*RHQ_Y.1FO\W.$/_-SH__R8L-O^XJZK_S;F[_[>BEO_$J)K_
-MNYZ2_\&EE_^;BGK_U,C7_RXN0?\A(RO_.34W_XU\=O_:P[?_034V_R<C)?]@
-M7EG_A(5__XB(B_^4CY/_<'%R_TI34_]56EK_AXF,_\;(S_\N13+_3&]7_W6/
-M>O\H/RS_("PK_S$Z,_\W1#G_*#0]_S]"5/_*PL7_Y]C2_SL[1/\\0$__2TE9
-M_T9"2O\N)"?_+2,F_R<>'O\P*BC_8UQ6_][0S?^IF)C_)B,B_R$>'?\G("#_
-M+B4E_RXB(_\Q)"/_1$4__]?(R/_,N[O_*",C_R4@(/\D'Q__)B$A_RXG)_\K
-M*2O_.C\__Q\:'O]O7U;_?V]L_Y&(@O^DGYK_Z-G:_[JNK_\M*BG_(QX>_R0E
-M'O^OJ:'_DX>#_^+5U/\^.3G_(Q\A_R,@)O]$1U+_1$A*_[RLJ?^3@H+_Y]C8
-M_X-]B_\W2%;_7V)M_YR4F/_:SLG_YM36_S8W0O\N,#?_*"0F_R<C)?\B'B#_
-M(Q\A_R(>(/\B'B#_(1T?_R,?(?\H'1S_1T-%_U%05O_ N<#_ZMGC_UU69_\]
-M0E3_0DE;_WUV@/^UJ;+_Y]WL_U129?]A87#_C(*+_^#3V/\\/T3_CI"._U!.
-M5_]"14;_SLO*_R@I,/\K*C#_B8B._S,T/_\N,#C_+C8Z_\2XN?_FUMK_T<&X
-M_].YK/_7MZ__S+"L_YF-AO_9Q-?_(S% _R4A*?\F*S'_>'AU_YV8DO^0BXO_
-M@'M[_XB!>_]G8%K_7%UD_Y60E/\H*BW_-T-'_SM$1/]F:VO_O\3*_SY(-_\V
-M0C/_+T P_TQC4/\Y5$/_#"D7_SY?3?\S3CW_/%I*_YBMH?_9T<W_2T=/_S0U
-M0/\M*C;_0SY _R8='?\E&Q[_)R @_R<C(?].3TC_T<?#_YR)B?\F'1W_(AT=
-M_R<@(/\L(R/_+B(C_S(E)/][>WC_U\K)_\BWM_\H(R/_)2 @_R<B(O\I)"3_
-M+B8D_ST_/?]=9&3_'QH>_WMP9?]H65G_LJNE_YN9E/_DU=G_MZNL_S,P+_\G
-M(B+_(2(;_ZZIH_^MGYS_Y=C7_S,N+O\E(2/_)" H_SD\1_\Y/C[_P*VM_Z>6
-MEO_NW]__8UUK_SA)5O]#1T__JZ"E_^'4S__FT=;_/3U*_R B*?\H(R7_)B(D
-M_R4A(_\B'B#_(AX@_R(>(/\B'B#_(AX@_R,;%_]14$__/$5,_XB*D?^+B8O_
-M24]1_SM'3/] 2%+_>'I__T9'3O\H+CC_'"4S_TQ55?]Y>GO_Q\')_SD^2O^+
-MB8O_3TM4_T)%1O_)QL7_+S W_RDI+/^8F9K_/#Y&_S<X0_\O-SO_OK*S_^+3
-MV/]W<FS_R;ZW_]_2S?^9CXO_FI6/_]['VO\U2%3_)B H_SI"3/\N,SC_:&EJ
-M_T(]0?\U-#O_4DQ*_[6IHO]=6%C_D(2'_SHU._\A*"[_0T5(_ZFDI/_$P]#_
-M'AP9_R,;'_\7&QG_'R47_SY#-_\Y0C7_+3HM_R,N&_\B0BW_:8^ _\;%Q/])
-M1$K_0#Y'_S4O-_] .3G_+B(C_R4;'O\K)"3_)2$?_R D'/_(P[[_@W!P_S(D
-M)?\D'1W_)R @_S,J*O\M(2+_,",B_X>'A/_:S<S_OZZN_RDD)/\D'Q__+2@H
-M_S K*_\V+BS_96=E_U]F9O\C'B+_=FQA_VI=7/^,BH/_C(^)_^?8W/^PI*7_
-M+RPK_R8A(?\K*B/_K::@_\BZM__KX-__,2XM_R,?(?\;%Q__,#,^_SQ#0_^_
-MKJ[_O["P__+EY/]N:';_259A_U977O^RIJG_X=7._^?2U_\_/TS_("(I_R4@
-M(O\C'R'_(Q\A_R <'O\@'![_(1T?_R(>(/\>&AS_*R,A_TE+3O]&4EO_6F5L
-M_T1/6O\Y0T[_*C$__S(Q3O\P)V/_-"IO_S\V?/];49K_&!5)_V5?B_]!/5W_
-M.4%+_Y64D_]85%W_3$]0_]G6U?\P,C?_,#$R_TE+2?\P,CG_,3(]_R<O,__#
-MM[C_Y-7:_WYQ;/_ JZG_W,G)_X9R;O]W;F?_U+W0_Q0G,_\E'R?_-T!._SD_
-M1_\A(R;_,"PT_R$D+_],2$K_>&IA_W9K9/^2@8'_1CU$_R,D*_\^/#__MJNJ
-M_]W.YO\G*S/_.TE8_R<K,_\V-C/_0D ]_S\[.?\;$Q'_+"TG_RTS+_]985W_
-MU=+1_S@Y0/\M,#S_.C=$_VED:/\L(B7_+B0G_R8?'_\F(B#_/3PU_]?+Q_]L
-M6UO_)A\?_R$>'?\G("#_+R8F_RTA(O\U*"?_CHZ+_][1T/^SHJ+_*20D_R0?
-M'_\H(R/_*B4E_S@P+O]E9V7_8FEI_R(=(?^9C('_P[*R_X-\=O]I9V+_Y=;:
-M_ZVAHO\I)B7_)2 @_S@S+?^]M*[_U,C$_^3<VO\X-33_)" B_R <)/\R-4#_
-M/D5%_\*SL__,O[[_[^3C_W%J=O]'4US_7EUC_[FKK/_IVM3_Y=#5_T5%4O\8
-M&B'_)!\A_R8B)/\C'R'_(!P>_R <'O\A'1__(AX@_QX:'/\U)RC_2T9,_U5@
-M:_]16V7_1TU=_R@H-_]@76__<FZ4_R,B.?\0$!__#0T:_PH)%O\;&3K_+"=1
-M_SDT5O\?(2C_IZ6B_UE57O]"14;_UM/2_RLM,/\X.CC_-3<T_S(U.O\P,3S_
-M*# T_\:ZN__GV-W_E7]V_\FPJ__ES,O_GH9W_WMQ9__7P-/_(#,__R$;(_\O
-M-3__8F9H_R4G)?\Q+"[_(2 G_TY&1/^(>6S_B'UV_Y&"@_]+1$O_(R4L_S4U
-M./^AG)S_S+S8_RDJ,?\4'R;_&QTD_R(B+?\E*C;_/$1._Q,:(/\E)"K_*RHP
-M_SDV//\?&!C_/3E"_SL[2O]*2EG_4U!6_RLC(?\X+"W_*AXA_RLD'O^7BX+_
-MV,S%_UE.3?\J)BC_(!L=_RHC(_\J(R/_*"$A_S F(O^)BH3_WM'0_Z22E/\H
-M("/_)Q\B_RHC(_\K)2/_+RDG_VUN;_]@96K_)B$C_Z21A?_ K:7_Q[NT_\6Y
-ML/_(N[;_JJ.C_R@E*_\E(R;_1C@U_[>PJO_?T-#_ZMO<_S0Q,/\D("+_'AHB
-M_S<Z1?]&3E+_9EYA_]/'RO][>7O_>GU^_W5[??]H96O_KJ.H__/AWO_8S=3_
-M24Y:_QD:(?\H(B#_)A\?_R8A(?\A'1__'!P?_R >(?\A'R'_'AL:_T8W-_]!
-M.T/_1T]?_U9;9_],3E7_#0,,_RL4'_\R(2?_%0H7_R$4'_\G%Q__&0T6_R$:
-M(O\8"QC_)A@G_R :(O^6BHO_1$)+_T=(2?_1T,__+"XQ_TQ.3/\9'!W_("4J
-M_SQ!1_\I+C/_2$-'_][6V?^)>&O_P:NB_^G3R_^8A';_?W1I_]>[S_\<+CC_
-M+"4L_R8Q//^1D(__*28E_S8P-/\I(RO_1S\[_YN+>_^1AG__D8.$_TE$2O\B
-M)3#_(R,F_ZZLKO_:P^#_)1PC_Q@1&/\A$!K_(1HA_QL;)/\B*##_+3 [_R4D
-M*O\N+33_55%9_];,S_]".T7_.SM*_U-38/]33E3_,"@F_R$5&/\L("'_3D4_
-M_[^SK/_<S\K_1CX\_R@B)O\C&Q[_*2(B_R4>'O\I(B+_,RDE_XF*A/_>T=#_
-MH(Z0_R@@(_\G'R+_*"$A_RPF)/\P+"K_7U]B_UUB9_\E("+_L**9_V584_^F
-MGIS_IIR8_\.WL/^>EI3_*",E_RHB)?]72$C_E)*/_][2U?_BT]C_+RXM_R0@
-M(O\B'B;_-SI%_SU 0?^\M++_VLO+_^+>W/]56E3_-3,U_V!98/^CF)W_[=?8
-M_\[%S/\\04W_'!LB_V):6/]53TW_&A45_R,?(?\A'R'_'!H<_Q\='_\?'1__
-M6$U,_TA)4/]&4V3_04A6_R<=,/\]*RW_JY*!_W9:5_]:/3S_F'5N_X5A5_^$
-M8E__*Q@2_Y:!?_^GD9/_% 8#_S<I)O]"1$S_24I+_]72T?\<'B'_+"TN_S]"
-M1_\P-3O_+#$W_R0G+/\<&AW_'!<9_XAV;/_!JZ+_ZM3,_Y6 =/]W;V7_U;W2
-M_Q@J./\L)2__(S ]_Z2@GO\L*"K_/#<]_R\H,O] .#;_H)2%_X)Y<_^)?7[_
-M7UMC_R8I-?\[.D#_O+>]_\;!V?\R-3K_'" H_Q,2'_\;%QG_$Q,6_Q87'O\<
-M%R/_'!<=_Q(.%O\J)"S_T,3'_U-,5O] 0$__04%._U!+4?\L(B7_*Q\B_TQ!
-M0/\W+"O_6$U,_Y>/C?\T+2W_)!\A_R8?'_\K)"3_*R0D_R@A(?\R*"3_B8J$
-M_^'4T_^+>7O_(QL>_R4=(/\K)"3_+2<E_RTI)_]@8&/_4UA=_R<B)/^;D8W_
-M)!T=_QH7'?\C'B+_F(R'_Z:;FO]74%#_+" <_[ZRKO^!@X'_KZ6H_]K/U/\R
-M,#+_)2$C_Q\;(_\V.43_/C\Y_\F_N__BT]3_X];1_U%/1_\\.#;_S,'&_^?8
-MW/_UW]W_S,/*_S@]2?\;&B'_,BHH_S<Q+_]"/3W_&147_R$:&O\E'A[_(!P>
-M_R =(_]Z<G#_/#Y%_T=79_\[15/_.4)"_QL6,O]I5H3_%0P=_Q,4&_\2#A;_
-M%A 8_Q01'O\7%AW_"@86_S$K0?\9%1[_)1P<_S]#2_])1TG_UM'1_R ?)?\N
-M+3/_,3,Z_RXR.O\P-3O_)2@M_S N,?\A'![_BWMR_\&MI?_IU-#_F(5[_W%M
-M9?_+MLS_%RDW_R8>*/\?)37_Q[^]_RTH*O]$/T7_+2DQ_S@Q,?^?E8O_A81]
-M_XV*B?]F9F__*BT^_T5!2?_$O<?_U<GB_T=+3?\G,SS_%!XM_S P/?\>'RK_
-M&ALF_R0=)_\8$1C_&1,;_RXG+__DU=G_1T!*_ST]3/\V-D/_3TI0_RH>)_\I
-M'"'_+2,?_R\C)/\:%!C_(AP@_R(='_\J(B7_)R @_RDB(O\K)"3_*2(B_S0J
-M)O]E9F#_X-/2_X%O<?\E'2#_)1T@_RPE)?\J)"+_*R<E_U]?8O]97F/_'!<9
-M_\B\N/\E'A[_(R F_R(<(/\5#@[_&108_VAC9_\H'AK_KZ":_\&_M__$N+/_
-MP+*O_S4T,_\C'R'_&Q<?_S<Z1?]-4$K_R</'_^37XO_FU]C_95]5_VA@7/_C
-MU-C_\M_?__/=V__%O,/_/$%-_R4D*_\^-C3_65-1_VQG9_\A'1__<6=C_RL@
-M'_\E'R/_'ATD_Y.'B/\Q,#?_04Q=_SD]3/\\2$W_!@LG_V9CF/\Y-F;_&! L
-M_QL,'O\>$!G_'Q8=_QL9,_]75X#_4E)Y_P\/'O\E("#_+C0\_T-!0__;TM+_
-M*BDP_RXM-/\V.$#_*RXY_R8J,O\A)"G_*RDL_SHU-_^_L*K_UL.]_^W8UO^>
-MBX/_A8!T_]C S_] 3E?_+ATC_W9VA?_6Q\?_.# S_V]L<O\U-#O_-3 R_[NS
-MK_^0EY#_041%_UI=:/\S.$K_+RLT_Z2=J?_4Q-C_13Y&_R,@)O\A'RC_-S="
-M_SDZ1?]35%__)B8O_R@H,_\?'RC_2$!#_][/S_]#/TC_0T-2_SPY1O] .T'_
-M)!P?_RD@(/\R*2G_,RHJ_QD3%_\:%1O_'AD?_QT8'/\;$Q;_(!D9_R4>'O\H
-M(2'_,"@D_Y&(@O_7R,/_:EY:_R<B)/\A&Q__*" C_S$H*/\D(A__7F-C_V)F
-M:/^*A87_4$A&_R ='/\?'1__(QP<_R4=(?\A&Q__)B D_RHB)?]/24?_D8Z)
-M_YR7D?^TL*C_-C$Q_S K+_]_?H7_-#A _V1F9/^[MKK_W-;>_]34T?^]P[__
-MJ[&S_]31U__LV]O_\MS4_[FUM_\_4%;_%20D_W=X>?^ZK:C_75-6_QX<'_\=
-M'!O_D(J(_T4Y-?\C'B+_I9F4_X)Y>?\O,3G_,C0\_RTU1?\Z15;_" \C_R4=
-M./]J9)[_44Z0_S@X<?\8&TK_&A(M_R\I/_\4$23_%Q<B_Q@3%_\;&![_(2$D
-M_ZBHJ_\K+C/_+"XS_S8Y/O\L+C7_(R@N_QXA)O\E)RK_,S$S_\"VK/^RGY?_
-MWL;#_Y.!=_^%=&[_K9N?_VQJ;/^">W7_Y-?6_^/.S/^PGY__N[*R_R<E*/\O
-M*B[_-#$P_R F*/]?9F;_+#0^_S(W2?\P,#O_T\O5_^'4YO\R*C3_)2 D_Q82
-M&O\9&!__'QXE_QT<(_\@'R;_'AXK_R<H+_]E7E[_W]#1_S<U/O\P,#__1#Y,
-M_T([0O\M)B;_)1X>_R4>'O\B&QO_,"HN_QD4&/\5$!3_%Q(6_QH2%?\B&QO_
-M*R0D_RLD)/\V,3'_)1T@_WYR=?]A65S_)!\C_R$<(/\K(R;_+R8F_R<F)?]=
-M85__?(!^_YJ3D_\O)2C_'QL=_QD:&_\?&AS_(!H>_R(<(/\?&1W_(QTA_Q@3
-M%_\<%QO_'1H9_U123_^/BHS_3TI._Q\>)?\]04G_5UQ8_\#"Q?_3T>'_O+?)
-M_R,<+?])0U'_U<[8_^K=W/_JUMC_IYRI_TI"5O\\(S3_=VYU_\.TKO]+0$7_
-M(1XD_VQK:O\P*R;_FXZ-_RDC)_^XK:;_*!X:_VEH;_]$1DW_&Q\G_S= 3O]&
-M3V#_/T)._Q -&O\) !+_(A<N_PX'&?\I)##_&QLD_S$T0/\H+SW_)"8M_QD9
-M'/])24S_%!07_QL=(O\I+#'_+S(W_RXQ-O\D*2__(R8K_R8H*_\]/C__OK2I
-M_[.?E__FS\K_DX%W_XY[<__!LJW_:5];_UY22?_NW]K_Y-/3_]?(R?]%0$3_
-M.3H[_R,A'O]A7UK_*S N_RDM*_]'25'_-#1'_S0O.__2QL__V,O=_RXF,/\Q
-M+##_'QLC_QL7'_\B'R7_'1H@_S M,_\Q,3K_%Q0:_S<P,/_CU-G_.SA$_S\_
-M3O\^.$;_,RPS_R8?'_\G("#_+28F_R8?'_\V+C'_,BHM_S8N,?\B&AW_'A<7
-M_RHC(_\I(B+_*2(B_R4@)/\>&R'_'!D?_QT:(/\H(RG_*R8J_RLC)O\M)"3_
-M)",B_V=E8/]F85O_*!T<_[*GKO]S;77_)B<N_QT<(_\B'2'_(!L?_QX9'?\A
-M'"#_(QXD_R(=(_\?&B#_&A0<_R4?(_\A'"#_)B4L_RLO-_^BF9G_IZFL_WR9
-MI?]<AY__0#M5_VE3:/^OGJG_:%YA_]S/SO^-CI7_.TM5_S="0_^.CY#_U<;
-M_SXS./\G)"K_F).._Y^4D_^6BHW_'AD;_\:ZL_\Z,"S_O[[%_T%#2O]>7%[_
-M-#8]_SQ'4O\\2U'_'RD?_T5(0O^5E)O_*2\Y_UQ?9/\;("7_+C9 _Q@B,/\]
-M1DS_-#H\_T!"1?\9%QK_%QD>_RTP-?\I+#'_+C$V_R$F+/\B)2K_+C S_SDZ
-M._^^M*G_K9F1_^++QO^,>G#_F(A^_\"TK?]_<VS_J)6)_^?7U/_.OL+_13H_
-M_R\R-_]!1D;_0T$\_XV-@/]E9U[_*BDH_RTM./]W=(;_1C]'_[NQM/_>T>/_
-M*" J_R ;'_\A'27_(ATC_QL6&O\?&A[_*",G_QL8'O\9%1?_I9Z>_]K/UO]#
-M0T[_/#Q+_T Z2/\Q*C'_)R @_R,<'/\K)"3_)A\?_RPC(_\U+"S_."\O_S G
-M)_\R*RO_*R0D_R<@(/\K)"3_*R,G_Q40%/\5%1C_&Q49_QP5'/\<%QO_(!@;
-M_RLB(O\C(2/_<FUG_T<]+_^ADY#_TL70_V);9_\9&B7_'B$L_S,R./\E(R;_
-M(!XA_QX<'_\C(!__(1X=_R$<(/\A'"+_)A\F_QX9'?\<&R+_+S,[_YJ1F/^<
-MH:'_-D]._T5?:/\Z-T3_DX.+_[FJKO]A6F'_Y-WG_WZ!DO]!25W_+BHR_YN6
-MFO_/P+K_-RPQ_RLH+O^VJ:3_O:ZO_WUR>?\H(R/_Q;FP_YN1C?_(Q\[_3$Y5
-M_Q84%O]_@8C_0TU;_SI&5?\=+"C_3$Y3_X^*G/\H,D;_'R,E_TI+3/\>("C_
-M*"L\_SL]1/\T.#K_0DA*_SM!0_\N,3;_+C$V_RDL,?\J+3+_)BLQ_R@K,/\T
-M-CG_)"4F_\*XK?^WHYO_X,G$_XMY;_^@C87_NZNH_V-;6?]32T'_YM30_^+-
-MR_^6BXK_-3HZ_S,X/?\A'AW_D(J"_WMY<?\F)BG_)2@T_RLN/_]34EC_A86"
-M_^'/X_\Q+##_(B,J_S(N-O\E("+_% \3_QX9'?\Q+##_0S]'_R@J+__,O\3_
-MV<C2_UA6:?]&25O_0T-._RDA)?\J'Q[_-"DH_RXC(O\K(!__,"@D_RPG(O\T
-M+RK_*",>_S(J)O\R)R;_+R0C_RXC(O\I(B+_*B4E_QP7%_\7$A+_'1@:_QT8
-M&O\=&!C_*R8F_QT6'?^%>G/_=FE<_T<X0_\R*3K_)1XH_QX:(_\:&2;_&1HE
-M_Q@8(?\I*3+_,3$Z_RLL+?\C(B'_(1\A_Q\='_\?'2#_'!H=_Q<5&/\U-#K_
-M%Q0:_Q45&/\?("'_+RDM_R,D)?]32D3_A79P_VUT>O]7D:?_2(BG_S!PC_\Z
-M9HC_*C!&_W!:6_\W(B?_)"$G_[:OJ?_0N;K_8519_R\M+__-P;C_:FMV_]K1
-MT?]!2UK_4$Y1_\"^P/]&4%__/DI9_Q<C(O]&1$'_A(*2_R0M/O\L-37_)2(=
-M_TM*5_\L-4/_.3Q!_SH^0/]%24O_,SD[_S<\0?\Q,S;_$1,6_S$V//\D)S+_
-M(R8K_QL@(/\P,S3_LZZN_]7.SO_9S]+_U]#0_^#0U/_DTM;_P;"V_[*CI__O
-MU=C_WM/8_VMF:/]T;VG_+"XK_R<F)?^!?WK_:VED_T9%2_\I*SK_&ATN_S$U
-M-_]%1D?_XM'I_S0S.O]57&C_(!\L_QP;(O\B("G_(1\H_R$?*/\R+C?_&QXC
-M_]#!Q?_9R-+_7%ML_TQ/8/\_/TC_*R,F_RL@'_\L)"+_*2$?_RLC(?\L)B3_
-M+RDG_RDC(?\F(![_)!P:_RTE(_\N)B3_+24C_R\H*/\T+R__(QX>_RTH*/\U
-M,##_'AD9_RTH*/\D'Q__)"(D_XM^>?]%-SC_)C15_Q(>._\8&2K_%A,?_Q85
-M(O\>'2K_&AHE_QX>*?\8&"/_%!,:_S(Q./\?'B7_(!\F_QX<'_\>'!__'!H=
-M_R<E*/\I)RK_$Q$4_R$?(O\F)"?_'!LA_V)64O_#LJS_8VEK_QXY.O\*)"?_
-M'D=,_V2%D?]:?8K_HZZI_S8Q,_\M*"[_MKJR_\RZO/]'/$'_*2<I_\J^M?]$
-M2EK_U<K)_SA%5O^+B8S_R,/#_T),6_\W0U+_*C8U_TQ*1?^#A93_)"Y"_R8R
-M,?]!/SC_3TY;_QLE,_\P-#;_*BXP_R\S-?\G*RW_*2XT_R\Q-/\K+3#_+3$Y
-M_RHP.O\A)"G_)"@F_S4U./_(NKO_QK2V_\&OL?^]JZW_K9^@_Z&5EO^AE9;_
-MF8V._Y-X?O]*14G_-C0V_U-.2/]N;FO_&AD8_R8E)/]B86#_6%=>_R@I.O\D
-M)SC_-#@Z_TA&2/_AT^__*RTU_TA17_\N,#__&ATH_R8J.?\=(3#_$!0C_U=0
-M6O]I:V[_OK"Q_\2YP/]E96[_3E!8_T9)3O\J)2?_)1X>_R$:&O\C'!S_(QP<
-M_R@A(?\A&AK_*2(B_RXG)_\Q*BK_)A\?_RHC(_\M)B;_*B4E_R<B(O\M*"C_
-M*R8F_S0O+_\I)"3_)2 @_R$<'/\?(1__3#\^_SPU/_]#9XS_5&R-_PT4*/\7
-M%"#_%Q4>_Q@5(?\3$!S_&!4A_QT:)O\:%R3_'QPI_QD6(_\@'2K_-#([_RDH
-M+_](1T[_'QXE_QX<'_\3$13_#PT0_PL)#/\7$AC_0C@[_QX4$/\8&A?_%A<0
-M_S8U+O\A.#/_35]C_S]!2/_7R,/_,B<N_QP?)/\X0CC_95E:_S4O,_\X-#;_
-MRKZU_R4K.__/Q,/_-D-4_YF7FO_-R,C_0$I9_SE%5/]J<W/_<W!K_WU_CO\Q
-M0%/_-$ __T=%/O]656+_(BPZ_SY"1/\Y/3__/T-%_SU!0_\\04?_-SD\_SY
-M0_\P-#S_)RTW_R$D*?\E)R7_HIR@_^;1S__[XMW_^-_:__KAW/_]YN'_^N/>
-M__CAW/_YXMW_]-C:_VUK;?\F)BG_.#4P_Y.2D?\E(R7_(B B_R$?(?]34EG_
-M+B] _R0G./\V.CS_3TU/_^31Y_\I)BS_,#9 _S8S/_\C(RS_$Q0?_Q,4'_\[
-M/$?_*R0L_RXL+O\_-#/_6E)6_UE97/\T-SC_+3(R_R8E)/\B'1__)2 B_R(=
-M'_\E("+_+"0G_R0<'_\I(23_*R,F_RDD)O\C'B#_*",E_R8A(_\F(2'_(1P<
-M_R0?'_\D'Q__&A45_R(='?\G(B+_)!\?_R(:'O\C'!S_(1\B_Q@A,O\0%RG_
-M'AXG_RPI+_\@("G_'ALG_Q81'?\7$A[_%Q(>_Q84'?\9%R#_'1LD_Q\=)O\:
-M&B/_%Q<@_QP<)?\S,SS_5U1:_RHH*_\0#A'_&A@;_V!@7?]X>G?_/#] _Q47
-M&O\>("7_0T!&_QDF)_]96U[_Q;*R__+5T?\W)R__(R,F_XF+@O_+M[G_-2HO
-M_S$O,?_.PKG_;W6%_\S!P/\[2%G_D(Z1_\K%Q?\T/DW_+SM*_WE^?O_;UM'_
-M;6]^_S)"5?\M.SK_5%)+_U)17O\R/$K_&1T?_Q49&_\R-CC_.CY _SH_1?\]
-M/T+_3$Y1_S T//\E*S7_(20I_VMH9_^[L+7_T\C'_\W#O__4RL;_W-+._^79
-MU?_HVM?_Y=?4_^K<V?_VXM[_7%Y<_VQN<?\D(2#_.SD[_Q\=(/]&1$?_&A@;
-M_UM:8?\>'S#_)"<X_S0X.O^"@(+_Y=OL_S0L-O\M)R__'ALA_RHL,?\C)2S_
-M(1\H_RXI-?\?&B#_'AH<_Q@3%?\:%AC_)B$C_R4C)O]!0$;_)R,E_Q@3&?\7
-M%1C_%A<8_Q06&_\0"P__&A08_QD3%_\9$Q?_$@P0_QH4&/\3#1'_&Q49_QL3
-M%_\1"0W_$0L/_Q$,$/\6$1/_'!<9_R,>(/\C'B#_'1@:_R,<%O\<'B/_*",I
-M_QX:(O\='2;_'1TF_QP=*/\L*S+_,C$W_R ?)?\8%QW_&A<=_QH7'?\9%AS_
-M%Q0:_Q<7&O\='"+_)B4L_QT:)O\7%AS_7EYA_S P,_],3$__+BHL_QT@(?\Z
-M0D3_&1L>_Q47'_\<'"7_$Q87_V-?7?_$O;?_ZMK7_RHF*/\G(1__LJ:?_^/+
-MSO\P*"S_,"PN_\.WL_]N=W#_N[6Y_S]27/^0D9+_PL3)_S<]3?\Y057_>H&'
-M_]3,RO]H:'?_/$95_SQ"1/]T;&C_3$M8_RXY1/\1&Q+_(B0I_S@Z/?\5&AK_
-M)BLP_SD\0?])2$__,C8^_S0U0/\@)2K_JZ*B_\:WO/^LFY7_JI2+_ZB3A_^?
-MBWW_EXA[_Y>%>_][:&#_BGQS_^?2S?]C8V#_JZNN_TI%1?](14O_(!L?_X)_
-M?O]I96?_9%]C_UU=;/\C)SW_/#U$_Y60EO_IW.?_&Q$:_R8?)O\@&Q__(ATC
-M_R0?)?\G)"K_+2HP_Q@3%_\=&1O_%Q,5_Q41$_\7$!#_'!<=_ST\0_\D'B+_
-M0C(Z_S$@)O\A%1;_)AL@_QP3&O\=%QO_34=+_QH4&/\7$17_'!8:_RHD*/\<
-M%AK_'A,8_Q0,$/\<%AK_%Q(6_Q81$_\=&!K_)R(D_Q\:'/\;&1S_'AH8_Q(:
-M*O\6'3'_%Q<B_QL;)O\;&R;_&QLF_QP:(_\=&R3_'APE_RDG,/\N*S'_,"TS
-M_Q<4&O\3$!;_$Q,6_Q(2%?\5%!O_%!(;_R(D*?\^0$/_*BPO_RHL+_\N+C'_
-M5%99_T-%2/\7#Q/_%Q,;_S0S.O\Q+##_2T9&_ZFBG/_KV-C_*B8H_RTJ)?_)
-MO;;_Z]/6_RTE*?\R+2__LZ2I_WR">O^[L;O_0%1B_Y.(C_^^O<K_0E=I_T=R
-MA/]'?8?_M+_&_V!8;/\N0T__;GEZ_][6TO])2%7_+3A#_RPT*O]-3E7_.SU
-M_R\R,_\G+#'_.3M"_TI(4?\R-4#_*RPW_QLC)_^<D)'_S+W"_\.OI_^^I)?_
-MO:.5_[^FE?_&KIO_Q:N8_\2FEO_$K:#_W\;!_W%P;_^SL[;_44Q._UE36_\F
-M(27_D(Z+_XB$AO]F86/_9F9U_RLN1_\R,CO_J*"C_^W9X_\B&"'_'1PC_QT<
-M(_\I(RO_&!(:_Q@3%_\?'1__)" B_QX:'/\<&!K_&A88_QX7%_\E(";_/3Q#
-M_R8@)/^CF9S_M*ZL_XF&@?\L*2C_'A@<_Q0.$O^OJ:W_&Q49_W!J;O\H(B;_
-M6U59_S<Q-?^9CI/_9%Q@_X)\@/\3#A+_%1 2_R8A(_\G(B3_'QH<_PX.$?\6
-M$A3_$AXS_R@U4O\2$1[_$@\;_Q01'?\7%"#_&Q@D_QX;)_\?'"C_&A<C_R >
-M)_\?'2;_&A@A_Q(0&?\1$!?_$A$8_Q,2&/\4$QG_(2,F_QX@(_\Z/#__.CP_
-M_Q0:'/\W.3S_4$M/_Y2)CO]K9&O_@GV#_T) 0_]C86/_I:.@_^G:V_\K)2G_
-M+BXK_\W!O/_RVMW_)AXB_RDD)O^PH*C_P,"]_[JIN?\S3%W_9G5[_V^$D/]N
-MAIG_67B*_W*0IO]OD)S_8HV?_R@\2O^"A(?_V-#,_TY-6O\Y1$__7%Y5_SH[
-M0O\S-SG_<G-T_S S./\\/D7_03](_S(U0/\K+#?_)"XR_[NRLO_-P,7_P*RD
-M_[>=D/^SF8O_PZJ9_\2JE?_-KYK_PZ22_\FPG__@R<3_='5V_ZFJL?]?6E[_
-M9F)J_R4@)/^5DY#_C(B*_V5@8O]U=83_+3!)_S P.?^OJ*C_Y]3D_R,=*_\P
-M.DC_&R R_R$F./\8&RS_%14@_QL6'/\9%1?_'!@:_R<C)?\U,3/_0SP\_S8Q
-M-_\Q,#?_+B@L_V5=6_]P:6/_3$D^_TY+1O\B'1__&1,7_Q<1%?\4#A+_&!(6
-M_R,=(?\9$Q?_%A 4_Q\4&?\7#Q/_%Q$5_QH5&?\6$1/_)!\A_R0?(?\D'R'_
-M$A 2_QP7$O\,$1W_#Q,B_Q(.%_\8$Q__%A$=_QP7(_\<&B/_%Q8=_Q85'/\9
-M&!__'1TF_QL;)O\;&R;_%14@_Q(0&?\3$1K_%A4;_RPM+O\N,#/_&1L>_R,E
-M*/\F*"O_("@J_RHN,/\M+3#_*R\Q_RDJ*_\O+S+_'B(D_T-(3?]%2DC_T+_%
-M_R\F+?\H*2K_KJ*=__7=X/\I(27_+"<I_[RPL__2T<K_LZ*M_TIG<O]RAHK_
-M25QD_VYWA?]24E__5%QL_SY*4?]XDJ7_3FAV_WJ @O_;T\__:&=T_S [1O^@
-MGI;_0#]&_SM!0_^^NKS_+"\T_SD[0O]+25+_*RXY_R4H,_\C+S/_@7Q\_\>\
-MP?^GDXO_O:.6_["6B/_!J)?_R+&?_\VRH?_!I9?_R;*F_]O'P_]:7%__KK"X
-M_UA56_]U<7G_)R(F_YN9EO^/BXW_75A:_VMK>O\I+$7_-#0]_VA=8O_8T-[_
-M$Q8G_SE'7/\1'CO_04QE_R@O1?\;'2S_'!PG_R$:(O\M)BW_,"LQ_S,Q-/\T
-M+S/_/T%&_S8X0/\Z.#O_V,G)_\R]M_]Y;F/_>6UH_QH5%_]@6U__44Q0_Q<2
-M%O\B'"#_)1\C_TY(3/]:5%C_@'I^_S J+O\6$!3_-S$U_QD7&?\<&!K_(AT?
-M_Q\='_\4$!+_+BDC_SU%3_\4"AG_$Q$4_Q,0(O\A)"__("$H_QP<)?\7%R#_
-M'!PE_QH:(_\B(BO_&QLD_Q84'?\7$QS_%1(>_Q04(?\5&2'_2$E*_TE+2?\J
-M+2[_'!\@_QH='O\8&A__&!<>_QH6'O\>'R;_)B4K_S@Z/?\<(2'_.CL\_[RY
-MM/_GU=G_)B H_RXR,/_"MK'_]=W@_RHB)O\O*BK_LZRL_]C+RO^BG:'_5VMO
-M_YNBKO^7F:'_)R8L_QX=(_\B)B[_969M_[&VPO]&76G_@HN1_]O5T_]#1E+_
-M.D12_[.NJ?]#14S_.SX__[Z\O_\Q-CS_.SU%_T ^1_\G*S/_+C X_R4M+_^!
-M>7?_NZ^R_]S*QO_>R\7_WLW'_]W)P?_BR<+_T+NV_]C$P/_1NK7_W\G+_U-6
-M6_^EJ*W_5U)8_XJ&CO\E("3_HI^>_YN6FO]E8&3_<&Y^_R<H0?\S-3W_;G-Y
-M_^?:V?\^.#;_-C4T_SDW.?\]/T?_'B$L_QL:(/\C'R'_,BLK_S4P,O\[-SG_
-M.SHY_S,S-O\M+3;_-SE!_RHH*_]J75S_6D](_W9N9/^&?WG_'AD;_Q@3%_\=
-M&!S_'1@<_QL5&?]<5EK_'A@<_QH4&/\>&!S_)R$E_R8@)/\B'"#_%0X._YZ1
-MD/\S)"3_)!D8_R<9&O].1T'_.$-._QH3)/\4%1;_%Q0G_RDL-_\Q,S;_)"0O
-M_QT=*/\A(2S_'!PG_Q06'O\0$!G_$Q$:_Q,/&/\6$R#_%QHE_R@M,_\\.CW_
-M/STZ_ST[-O\].S;_/STX_S$O,?\>'!__&A@;_QP:'?\<&AW_%Q<:_Q@;'/^+
-MAX7_T,C$_^G7V_\I)BS_-3,N_]3'PO_OU]S_+B8J_S$L+/^VL;'_Z=G=_YB8
-MF_]89FG_G*2N_Q,6&_].3DO_>WUZ_U=86?\K+3#_*3,W_SA'3/^#B(W_V]73
-M_T!$4_\Y0U'_BX:!_SY#2?]&24K_R\G,_S$X/O]"14K_/CU$_RDL-_\U-S__
-M*# R_\&VM?^^K[/_T]'._T-#0/]!1T/_6EI7_\S*Q_]/44[_6%U9_UM=6O_0
-MO\7_2DU2_[2WO/]J96O_G):>_R8A)?^FHZ+_G9B>_VIE:?]U<8'_*2I#_S(T
-M//^)A(C_XMCA_R@C)_\>(![_,S$L_S<S,?]!/3O_3TI%_U502O]&03O_03XY
-M_T9$0?\\.CS_*BDP_S(S/O\X-C__,BLK_]7(Q_^HGYG_=G!H_VED7_\=&!K_
-M(!L?_Q(-$?]P:V__'1<;_T$[/_\;%1G_65-7_Q80%/\E'R/_:6-G_QT7&_\=
-M'AC_96-<_Y")@_^;FI/_C7MX_Z:<F/\_4%[_%1,C_QD;'O\@'C'_&1DB_R4C
-M(/\M*S3_+2TX_RLK-O\E)3#_("$L_R8G,O\4%!__$Q <_Q@7*/\<'2C_6UU@
-M_R,B*/\D(A__-C,N_T9#/O]"/SK_/CPY_QX>&_\_/SS_0T- _R0B)/\?(1__
-M/T1 _V=D7__-R,/_ZMO@_R<G*O\]-2O_U\; __/;X/\G'R/_-"\O_[BUM/_A
-MU=C_EY>:_TM56?\6&!__)R@I_VUL9?]+3T?_8F-<_RHK)?]?9&#_45E6_XJ.
-MD/_AV]G_/T-2_SQ&5/^ZM;#_049,_T!#1/_+R<S_.$%!_T%&1O]*25#_,30_
-M_R@J,O\D+"[_P[BW_[ZOL__/QL;_0S\]_SLY-O].2$;_V-#3_T='1/]04TW_
-M249%_]/"RO]15%G_MKF^_VED:O^DGJ;_)B$E_VIG9O^AG*+_<6QP_W=S@_\L
-M+4;_+C X_V%@7__MV^G_(A@B_P\0%_\0$A?_&A47_QD4%O\5$!+_&106_R :
-M&/\R+BS_2D5)_SLW/_]+2%3_24E6_SDU/O^YK*O_:UU>_TM#/_]O:F3_7UM9
-M_Q<2%O]%0$3_HYZB_QD4&/\E'R/_24-'_X1^@O]O:6W_9V%E_V=A9?^ >G[_
-M'A@<_R\J)/^IGY7_CX%X_VMC6?]Q8%K_DHV(_T!39?\A&2?_&1D<_R,A-/\@
-M(2C_9F%;_Q82&O\?'RK_%A8A_QX>*?\G*C;_+3 \_Q04(?\4$R#_%QDN_Q\A
-M*?^'A(/_%A@=_QD8'O\G)2C_,"XQ_QT;'O\>'1S_+2PK_S0S,O]"04#_+BTL
-M_RLM*O]X?7?_H)Z7_XZ(AO_@U=K_&QP=_VU<3__=R,/_[=7:_S$I+?]!/#S_
-MM;>U_^+8V_^&A(?_,CH^_QT;)/]J9&C_:&5@_U%64/]I9V+_1$$\_V-?7?\E
-M(B'_B8F,_^/=V_\\0$__/$94_[>RK?]!1DS_/4!!_Z">H?\P.C?_0$9"_TE(
-M3O\V.43_*2HU_R(J+/_$N;C_Q+6Y_]G-R/]-1#W_03LS_U)'0/_DT]/_7%)(
-M_V=D4_]72D7_U<#&_T1'3/^!A(G_=G%W_UA26O]54%3_'1H9_QT8'O]O:F[_
-M<6U]_R@I0O\L+C;_:6QM__G8]_\6$17_(1$5_QT/&/\4$A7_%1 4_Q@3%_\7
-M$AC_#@D-_S4P-/]&1$?_4$U3_T9'4O]6663_3$=-_\:UK__GTL[_C']^_QL9
-M&_\5&!G_%1,5_Q@4%O\:%AC_%A(4_Q$+#_\." S_(!H>_QL5&?\4#Q/_(!L?
-M_Q0/$_\>&1W_/SXS_[VTIO_ LJG_O+:N_\>_N_^JFX[_2%MY_U-05O\:'Q__
-M*R9*_QP>(?]85D?_'A@F_Q\=)O\9%QK_%!0=_R4L,O\3%B+_# T4_QH:)_\,
-M&D'_1D91_\"YL_\F*";_'AD=_Q81%?\6%AG_$A46_R4F'_]64T[_(Q\A_R$C
-M(?\D*27_/T1"_Q\C(?]345/_;FQI_XJ)B/\='QW_BWAN_\BTL/_6Q\O_(QTA
-M_UI44O_#O;O_XMK=_X%^A/\H*C'_(!LA_W%E8?]^<VS_.CQ!_Q<2&/]85D[_
-M-#$P_SHX._]M<7/_V=;5_SH_4?\Q.TG_PKJV_T!%2_\Y/CS_R,/#_R<K+?\^
-M0$/_1D=._R@K-O\R-C[_%R(C_\.YM?_&M+;_U\[(_U)#/?]"/C;_4$@^_^S4
-MT?]P853_=G)=_V%;4__5P\?_14A-_SD]1?\V,SG_;VUP_R4A(_\>&AS_(!P>
-M_W5S=O^ ?XS_+"T^_S$S./^PJZ__^-?H_Q@:&/\6$AO_& X7_Q02%/\5$!3_
-M$PX2_Q@3%_\Y-SK_/SU _TI(2_]%0T;_0$))_T-%3?]'0DC_T+^Y_^W7S_^$
-M=7;_(!@<_QP7&?\7$Q7_&!06_R\K+?],2$K_6U59_TQ&2O\4#A+_(QTA_S$L
-M,/] .S__&A49_Q0/$_^ZKZC_Q;&I_Z")A/^ ;&C_:V-F_[BFF/\S1F3_&!D:
-M_Q(7'/\C)E#_%1@=_UQ82?\:&"O_'1TH_QH8&O\6&"#_(RPR_Q86)?\4%A[_
-M&!PQ_R(Z:_^4EZC_I)N;_T,^0O\<%AK_03Q _QH8&O\;'1K_2DA _Z&>F?\:
-M%AC_+"LJ_T! /?\R+R[_$P\1_QH5&?\>&QK_*"PJ_VEI9O]B4DG_MZJE_\*Z
-MOO\E("3_9U]=_Y^7D__BWMS_<7-Q_TM/4?\V.#W_7UI5_V)64?]/35#_6%)6
-M_TU-0O]+2DG_&1P=_W5^?O_=V=O_/$!5_RHT0_^_M[/_1$E/_S@].__/R\G_
-M*2LR_ST^1?] 0$G_*RXY_R8L-/\9)"7_P;:U_\*RMO_CU,[_=5U4_U!&._];
-M44/_Z]3/_W]L8/^+@G'_9F!8_]3"QO]!0TK_.CY&_T5$2O]^?'[_(Q\A_Q\;
-M'?\B'B#_:6=J_Q@8(_\5%R;_3$Q/_[*ML?__[>#_+!\._Q\<(O\=&B#_(1X=
-M_QX9'?\9%!C_&108_Q84%_\@'B'_+RTP_S<U./\Y.T#_/T!'_U915__&N;3_
-M[MO3_XI\>?]%-CK_*1<9_Q8/#_\3#Q'_&!06_UQ86O]K96G_75=;_TA"1O];
-M55G_55!4_Q40%/\>&1W_$@T1_XV'A?^MI:/_O;BS_[BPK/^EI*O_PK&D_U)B
-M?/\C(!__$QDC_T9;B_\9&R/_7E-(_Q,8,?\:'"O_$A(5_Q8=*_\J,SK_%1<L
-M_PX5*?\0&SW_(T%Y_Z.IO_^*@H;_*2$K_Q43%O]F963_(B(?_S,T+O^.A7__
-MHIR:_Q<5%_\J)R+_B(!\_XR%A?\?&AS_&1<:_Q84%O\4%!?_&!44_S$F'_]E
-M75G_6%-7_S0R-?^(@'[_55%/_X""?_^&B(7_-SPX_Q@;(/]C8V;_;FEI_["L
-MKO^]NKG_=W=N_SL^0_\X0T3_?(B%_]S8VO\Y/5+_,3M*_[ZVLO\S.#[_/D-!
-M_\_+R?\R-#O_0D-*_S<W0/\M,#O_)2@S_R,M,?^\L[/_MJNP_^#3QO^(;F#_
-M4DD[_V)83?_QW-?_CWIN_YR/?O]I8UO_U,3(_S@Z0?\X/$3_/CU#_Y".D/\@
-M'![_7EI<_S0P,O]M:V[_)B8Q_R$C,O\S,S;_KZJP___NUO_'FW/_/AX$_QP5
-M%?\9%!C_%1 4_Q<2%O\6$17_$Q$4_Q84%_\5$Q;_%1,6_Q02%/\4$QG_&108
-M_[ZRKO_HU<W_:EU8_R4<'/]*0#S_2D5%_QD5%_\6$A3_&A88_U%+3_\U+S/_
-M)B D_SDS-_\6$17_%Q(6_QD4&/\:%1G_&QD<_Q49&_\Z1$'_4590_S(W0__L
-MV\[_-4-8_R<C(?\0%B;_-%J-_QL;*O]30#C_'2E&_QD<+O\:&AW_%1TQ_QLE
-M,/\=(#G_$!PY_R,W9/\@/7?_K;'&_Y*-C_\M+S3_%AD:_W!R;_\T-2__2$8_
-M_\N[N/^OI:C_*2LI_T [-?^[LZ__B82$_WU^?_\I+2__&Q\A_QX;(?\G(B3_
-M2$,]_QD:%/\1$13_*2<J_X9^?/\O+3#_$Q8;_Q 3%/\J+BS_9V9E_S Q,O\=
-M("7_.3Y$_S4S-O\M+"O_0$-5_S%!2O^"D(__W=G;_S T2?\V0$__O[>S_S4Z
-M0/\\03__S<G'_R\Q./\V-S[_/CY'_R<J-?\E)3+_&2(H_X>"A/^UKK7_WM/(
-M_X9Q9?]34D?_+2PE_]_0R_^.>6W_J9B(_VAD7/_2PL;_/T%(_S8Z0O]#0DC_
-MF):8_R(>(/^5D9/_EY.5_VIH:_\E)3#_(2,R_S0T-_^MJ*[___+I_]FC:O_
-MEVW_?5PX_QT;%O\1#AO_%!$>_QD1)?\T+D+_$ T9_Q84%_\8$QG_% T5_Q(/
-M%?\K*"?_Q;NW__#6S?^KHIO_:V5C_R,9%?\E("3_&10:_Q,.$/\<%Q?_$@T-
-M_R(='_\?&!__(QPD_RH?'O\T)"'_.",A_RX<&?\G&1K_(AT?_QTB(/]U>7?_
-M0T5#_];1T_]::WO_&B8J_Q89)/\F3H;_&A\K_W)B4O\=-%[_<W-\_U953O\B
-M,$?_7&)L_RDP1O\+'TS_(CQ[_R@Z=/^XM<?_76-?_S<X.?\4$A7_='9M_U)0
-M3?]G7UO_T<*\_[JOKO]*2$K_B(6$_XB#A_]*3%'_+#$V_RTP-?\E*2O_*2LN
-M_R$C)O\3%A?_&QT;_Q\='_\?&QW_BX2$_S,S-O\Q-#G_*R\Q_Q@3%_\4$@__
-M(!L?_QPF,/\@+#/_O;>[_^C;VO]\?8[_/$Q6_W%X?O_?VM[_-SU-_S8]2__'
-MN[?_049,_SD_.__8TM#_,C,Z_S(U.O\K+S'_*RTT_RHJ,_\;'2+_O+2X_X1X
-M>__CSLG_D7UU_SXU+_]&1#__\N'4_Y^'>/^LFHS_@W=N_]_0U/]!0$?_769M
-M_T!#2/^;F9O_&147_YJ6F/^GHZ7_<&MO_R(B,?\E*#K_+R\X_ZZFJO_\\.O_
-MW:=M_\J@<O_&EUW_KI!Z_SDB,_\>%S7_*R1"_R@A,_\<%QW_'QH:_R 9&?\:
-M$QK_'1@<_RDE(__.PKW_\]S7_S\].O\Y-SG_85I:_S8X-?\<'!G_)R4B_R\J
-M*O^8C(7_II:-_].]M/_OT\O_Y<_&__#8S__MT<G_[-;-__+6T__BR<C_LJ"=
-M_[BFH_]&.C;_UL[8_S1'6?\T3ES_.SY)_SA6@O\?'R+_L9I]_R4[8O]#14S_
-M.C\__QPQ5/\6(#3_(#)._Q<X;?\G3(W_+$!Z_[NYR?^"BH;_)" B_Q@3%_]W
-M>F[_=G1Q_[6KI__7Q[[_OK&P_V!;7_]234__L*JN_XB*C_\A)BO_'!\D_QD=
-M'_\M,3/_,C8X_R<K+?\E)B?_'AP>_Q\;'?^9E);_.#<]_T9+4?\O-#K_%Q,;
-M_R D(O\A'B3_(2X[_S! 4/\Y.T/_J:*B_Z"BL?]-5V;_>WM^_^;@WO^2F:?_
-M-C]-_\.XM_\X/4/_.3X\_\S(QO\W.4'_.C]$_QHA(?\P-3O_$QH@_QXC*/\L
-M*BW_*2$D_^?3S__MV-/_Z]G5__+DX?_ZY-S_]MW6__'<U__>S,C_Z=?9_TE#
-M2_]\A8S_F)N@_Z6CI?]*1DC_I*"B_Z*>H/]Y<W?_)R<T_R,H.O\L+#?_K:6H
-M__WPZ__AJW'_SJ-S_]VC7O_:IVO_K85K_R@;%O\8$Q?_$ D5_Q@3&?\V,R[_
-M.30O_S$I)_\;%Q7_,"LF_\N]NO_MV]C_.3X^_QPA)_\@'R7_,3<O_T=+0O\S
-M-"[_'!D8_RDE)_\G("#_C7]\_]C#OO_NV,__]]W4__O?U__SW=3_^-[5__3>
-MU?_RXMC_]>+8_^'/R__8Q<O_/$14_RU!5?\[15K_)T%L_Q<@+O^?DX3_(#%5
-M_UM=9/\7'B3_&S-:_R,P2?\2+$W_)U:-_RQ9F?\Q38;_OK[-_ZZPK?] .#O_
-M&108_X&$>/^ ?GO_QKRX_]7&P?^ZKK'_@7E]_\:]O?_)O;[_1$!"_P\5%_\8
-M&B'_(R<I_Q,7&?\4&!K_&!P>_Q$4%?\>'R#_,2\Q_SDU-_\V,3?_.#E _S<Y
-M0/\<&R+_)B\O_R(A)_\=*C?_+3Y6_S$^4?\E*B__'B@W_T5/9/^6E9O_KJFD
-M_W=^BO\P.DC_LJVM_SD_2?]!0D/_T<W/_S T//\U/4'_&R0D_RPS.?\@+3+_
-M,3U!_Q@>(/\5%A?_W]#+__+=V/_UV]C_^=S;__?;W?_VW=[_\-G:_^_:V/_O
-MV=?_FHZ1_X2&C?^HJ[#_H)N?_V9A9?^LIZO_IJ&E_W-N</\1$AW_("8V_RXN
-M-_^AG9____7K_]FE;/_-IGS_VJ1A_\JA8/_%E5[_O91C_Q\- /\@&#K_,"I&
-M_RHI,/\\/#G_3TI%_SDT+O\]-3'_U,3!_^W9U?\V.SG_(R@M_R0D)_\M,C+_
-M%AH8_S$S,?\_/CW_+3(R_R(F*/\G*2S_'1@>_VQF9/_$M[+_[M;3__'7U/_V
-MW=C_\][9__'>V/_XW]K_[MO3__G<V/_BT]/_4DI._QT;)/\L-TC_'"(L_VMB
-M6_\@+$G_*20D_R<I)O\S/5+_)R<T_Q@M1O\]:)S_,UB9_RU+@__$QM7_GIZ;
-M_QT5&/\9%QK_@H5Y_X>%@O_)O[O_ULC%_[ROM/]J8&/_T<7!_\R]N/]M9V7_
-M)B@K_R(G+?\V.3[_)BHL_TI.4/\[/T'_1TQ,_SL^/_\@(2+_'QT?_];*S?_&
-MO+__&A88_QX:'/\Q-CO_*B0H_Q8>(O\N/TW_,3]8_SE#3?\]4&+_,$1@_R8S
-M1O\1%Q__.D=8_RXY1/\=&AG_*S \_RPL+_]A863_+#0^_S=!1?\@+"O_+#4[
-M_R0Q-O\K-SO_)BPN_RTK+?_GV-/_[]K5__+=V?_UW]W_^.'B__;@WO_VX=W_
-M^.'<___GX/_FU=7_<G%X_ZVOM/^9E)K_<6QR_["KL?^HHZG_@GU__UI<9/\?
-M)C3_,#$X_XN,C?__\NG_WZAN_\29;?_=IF;_QYMI_\Z::/_#D%O_OY)I_T ?
-M-_\Q(D'_#104_QT;'?^9B8#_C8%\_TY+0/_6R<3_\=O<_S0W./\@'R7_&A<=
-M_RPP,O\3%1K_(24G_QPC(_\P-3'_1$E#_S(R+_\:&!7_*"<N_QL7'_]N96S_
-MW<[2__3>W/_YW]S_^-S8___@W/_XW-C_^-[5__??UO_QV-G_\=?4_VY:5O\Q
-M*"+_+2<?_RPH*O\M)![_*B$:_S4P*_\H(AK_'!TH_QU,@O\H1I#_)DV(_[W"
-MR/^6E(W_)!D@_Q@:'_^/B7__AX1__\O"PO_=Q,7_O+6U_\C"P/_1Q+__V<2_
-M_UE,2_\H+"[_(B<G_Q\B(_\7&AO_'R0D_R\V-O\3&!W_$QD;_Q49%_\W,BS_
-MSL&\_\&YM?\Y.S+_>X1W_X^-B/\N(!W_'!02_PT<'/\O0$[_-455_S=+8?\R
-M1V/_+D-?_S%&7O\Q0EG_-#Q&_Q88&_\4%AW_.C<]_QD6'/\7&1[_+S<[_QTI
-M+?\A*C'_(S$T_R,P,?\P,C7_*R4I_^?3S__RV];_[]K5__?BW?_WXM[_^N7A
-M__7@V__WXMW__>+;_\^YNO]H8FK_J:NP_Y&-E?]^>X'_N+6[_Z>EJ/]M9VO_
-M>G>#_R,D-?\H*3#_*2<I___T[O_7GF3_SJ!S_]:=6__-G6K_RIED_\R;9O_-
-MG&?_MH]>_V _/_\=$"/_'R$?_U902/]J9&C_/T Y_]/'P/_GT]7_.#H]_QT<
-M(_\9%AS_+3$S_S8X._\G+2__*3$S_RTR,O\4&!;_-3<U_T5$0_\N+S#_%!07
-M_QL=(/\J+"__4TY4_\_$R?_KV-C_]-W8__?<U?_WW=+_]MS3__G=VO_PU]+_
-M[]C3_^K5T?^FE)'_>7%T_S,N-/\M+S?_;G1^_VUO<O\>("__&$R%_R$\B?\D
-M3(K_OK_*_WQW=_\C$R'_$!,8_YJ2B/^'@GW_T,;)_]_)R_^;G9O_R<7#_]3$
-MP?_9RL7_.S,V_Q47'O\8&!O_)2,F_QX>(?\A(R;_*2TO_R@J,?].45;_%187
-M_Y&)A__3P,#_T+V]_Z28E/],0SW_0T0]_U-73O^*A'S_G(N%_VEC8?]:6EW_
-M/$1._S=$5?\W1UO_,4)9_SI)7/\S/$/_*C R_R$G*?\V.CS_%A@;_R<G*O\R
-M.#K_,S]#_RLR./\N.C[_+#<X_QDA(_\H+"[_VM+5_]O2TO_AV-C_WM75_^C9
-MVO_GU=?_Z-;8_^?5U__TX^/_U,G._WAS?_^PK;G_>G9^_X!]@_^SL;3_K:NM
-M_X)\@/^$?XO_)R8W_R4E+O]L:FS___'K_\6,4O_ DF7_SY94_\*37?_)F6+_
-MR)AA_\657O_*EU;_R)EI_V!%(/\F&A7_(AP@_R$?*/]/3TS_S\.\_^?6UO\O
-M,S7_%QD@_QT<(O\C)RG_&QT@_R,I*_\P.#K_*"\O_Q@='?\K+B__&!D:_SL\
-M-O]&24/_*3 P_QDC)_\<(R__(R8Q_S8S.?_1R,C_Z-;2_^W:U/_VW]K_^-_:
-M__+<U/_SW-?_]]O8__;7U__LU-'_QK&O_R49'/\O*3'_9FAO_Q 4*?\A5Y'_
-M)#N(_R-,B/^]O<S_7UA?_VA79_\?(B?_HIJ0_Y"+AO_=T];_V<G-_SI!0?_%
-MPL'_WLO+_\F]OO\Z-S;_'!T>_QX;(?\G(B;_)" B_QP:'/\9&AO_(!TC_Q@8
-M&_\7%1C_<6=J_XN#AO^>F9G_='!N_ZNHH__.O+C_+B@@_R\R)?_'O:[_GX]\
-M_YN.??^1B('_75Q;_TY15O\Y04O_-3]*_SD^1/\I,2[_+S<S_SY#/_\\/CO_
-M(R(A_RXS,_\G+S'_*2XS_QTA(_\A)RG_'R<I_RLX.?]B9&?_<G!S_VUK;O]H
-M9FG_8&1F_UA>8/]46ES_4%98_U%24_]/3E7_9F9U_Z^IM_]X='W_B(6+_X:$
-MA_^IIZG_BH2(_W]ZAO\E)#7_.#A!_VQN<?__].[_U)MA_\R><?^^A4/_PI-=
-M_[^05O_$E5O_P)%7_[^15_^_C%?_P9%2_Y)L1?\M&PW_7%-3_V!@5__2Q\#_
-MW<[/_RLQ,_\M,CC_/D!%_R4I*_\F*"O_+3,U_R(J+/\D+"[_%AP>_RPP,O\4
-M%AG_*2LP_Q03&?\T,SG_(1\B_Q@>(/\C*RW_)BXR_RLP-O\X-#;_U,G._^#/
-MU__IU]3_[=G1__':U?_QV=;_\]K9__C<V?_SU]/_X<G&__CCW_^CF97_-C-
-M_R54CO\>,X'_*U.*_\'"S?]74%?_)Q@C_W1X>O^?EXW_AX)]_]W3UO_>R<[_
-M&1T?_YF7F?_.P,'_V,?'_V995/_/R<'_*"<F_T5"/?^">W7_/CPU_UM:4_]!
-M/#?_$Q$,_PP*!_^JHJ#_SL/"_\2\N/]03D?_0$0[_UI43/^VJJ7_2D,]_RPM
-M)O^WL*3_@GAJ_Y6+@/^4B7[_85E/_R\M*O\X.T#_86-F_V)E7_]35$W_,C$J
-M_TQ*0_\N+"G_,C0R_R,J*O\9'1__&QT@_Q<9'/\?(23_+2\R_Y>-B?^AE(__
-MHY:1_YN.B?^5C(;_D8B"_XR#??^,@WW_A'UW_RHF*/]A86K_MK*[_S(N-O^.
-MBY'_%A07_Q .$/^%?X/_>G6!_RHI.O\I*3+_3%%6___PX__,G6W_RIIG_\N<
-M9?_#E%K_QI1;_\*05__!CUC_P)-7_\"/7/_!C%;_OI!3_ZE]2_]&+QC_86-A
-M_\S%Q?_=T<W_'B<G_Q 5&O\='R3_'" B_Q@:'?\G*2S_%!@:_R<K+?\9'1__
-M*2LN_Q47&O\H*B__$A09_QT@)?\>(B3_(R@H_RPQ,?\R.#K_*S U_SU#2_^A
-MHJW_*#U:_UUFC__9S-__\-G:__75R__PV=K_\-K8__'9UO_NW-C_[^#;_^WA
-MV/_CV-?_766%_SY1E_\M3'S_O</3_U!$1_].3%7_'2@O_Y^9C_]^=6__Y=G<
-M_^S3TO]23T[_0CT__]C)R?_FT<S_FH^$_\O!M_\J*"'_O[FO_XZ%?O]W<FS_
-MQKZT_UY>4?^ >G+_(B ;_[&JI/_@SLO_A'EX_ZBCG?^UL:G_,C H_S8U+O^]
-MO+7_I)^:_R,D'?^9E8W_<65<_W5N8O]K9EK_>71H_R =&/\='R+_&1<4_SX]
-M-O\P,RW_35-/_V=E9_]B8E__1DM%_RDN+O\B*2G_*BTR_Q@7'O\;&1O_FI*5
-M_Z"8F_^CFY[_KJ:I_[.JJO^[LK+_O+6U_\2_O__$SKW_6V!:_UA98/^KLZ__
-M*RTP_Y:2FO\Q+##_-C(T_W=U=_^)B93_)"(R_QT>)?\M,S7__^_B_[R2:O^Y
-MCV'_K8E<_ZZ#5?^WBU__M(E9_[2+5_^WBUG_O(Y;_[>*5/^WBU/_O8E7_ZF
-M5O^1>5[_V,J[_^31R_\L+2[_$Q4:_Q(6&/\6&AS_$Q48_R@J+?\0$A7_)RDL
-M_QD;'O\F*"O_%!89_R4G*O\1$Q;_&R$C_QHB)/\?)2?_(2<I_R,I*_\I+S'_
-M+#LZ_R B*?\@+D?_.DEL_RDY9?]37X3_SLC6_]_-R?_IT,O_\-31__79UO_U
-MV=;_\M;9__36U/_KU,__X]O?_XV/GO_/Q\O_3CPX_S(Q-_\7(BG_GIB._W5K
-M9__EV=S_\-C5_WUX>/_*PL7_V<C(_][*QO^*A7__S\?#_W=U<O_*QK[_?G=Q
-M_XZ*B/_(O[C_;V]F_[^WL_\C(!__N[&M_][.R_]_=W7_3TY'_SHV+O_!NK3_
-M?7MT_S$P*?^SKJC_34Q%_WAV;O^!>6__=W)F_WYZ:_][=&;_;&9<_Q\='_]0
-M3$K_4TM'_R$;&?\@&QO_+BDM_SP\.?]04TW_-#<X_Q\C(?\;'2+_$@X6_QP8
-M&O\;&1S_&18<_QH7'?\6$QG_&!89_Q@6&?\6%AG_&!H=_U!$6?]%/DC_8%Y9
-M_[FGL?\N(RC_GIN:_Y^@H?\C)B?_*"PJ_XF)DO\G)37_)R@O_S0X-O_PYN__
-M0BXF_S<K)/\T*R7_/"TG_T4V,/\X*R#_1#@I_TX],/]50C;_64@X_VM;2/]V
-M7$[_@V=,_X-N4?^%?'7_X<_,_\K&R/\W.3[_(RDK_R,K+?\L,C3_)RTO_R4K
-M+?\B*"K_&B B_R,I*_\/%1?_(R4H_P\1%/\;(2/_&2$C_QLC)?\?)RG_(BHL
-M_R4M+_\I/2[_:&][_R<C,_\=)BW_("E!_R4S2O\6(3+_/3@^_T,_/?]P;&K_
-MIIZ<_\N^O?_5RLG_YM?1_^W7S__NT]+_[=C6_^G6S/_9R;__)R0C_R@K,/^@
-MEY#_6%-5_^3;V__LU-'_>G5U_]')S/_8Q\?_V<;&_R,@'_^_NKS_3DY1_X.!
-M?/^:EI3_FYF;_\O'Q?]V=W'_P;BX_RHF*/^ZL:O_X-#-_["HIO_!P+G_:&1<
-M_SPW,?^JJ*'_4TY(_S8T+?_ N[7_,BXF_\&^L_]Z=VO_>WEJ_W]Y:?]\=F;_
-M/#HS_S0Y-?\/%1'_("0B_QL<'?\B("+_*"8H_R<F)?\H)B'_-S4P_QT:%?\D
-M(![_2D=&_Q(0$_\2$!/_%Q48_Q(0$_\6%!?_%1,6_Q$1%/\8&AW_/4(^_R,G
-M-O]<7G/_G9&,_VQC7?]*147_D925_S,\//]&2TG_D9&:_QX<+/\H*3#_D(^(
-M__3J]/]71D;_)2$I_QL=)?\='!O_&1<:_QL8'O\;%R#_'!@A_QL7'_\9%AS_
-M&1<:_R >(?\;&AG_&A@5_S(H*__:SLK_25)2_S4]0?\U/3__,3P]_R\W.?\J
-M,C3_)R\Q_Q\G*?\;(R7_&2$C_QDA(_\@)";_'!XA_Q<='_\9(2/_&B4F_QXI
-M*O\A+"W_(2PM_RXU*?\W267_$1DI_QH9&/\B+$[_*S1%_R B(/\>&B/_'R$F
-M_R(E)O\C)B?_*"TM_S U,_\R-3;_-#,Y_SPX0?\^-CG_6%-._X9^>O^TJ*O_
-MP;R^_Z:;E/]'1$K_Y-W=__+;UO]Y='3_VM+5_]G(R/_0N[G_@GIV_\2XN?\F
-M(2/_PL' _U!.4?\T-CO_O[V__U]=7_^\L;C_*R<I_[NRK/_>SLO_85E7_S8U
-M+O_)Q;W_9V9?_S\Z-/_#NK3_.3<P_ZZBG?]L9E[_.CHO_W1T9_]I9UC_@'MI
-M_W=O6_]T<&'_+BDD_R ;&_\3#A+_$1 6_Q,4%?\8%1O_&!(6_Q<2#/\W,2'_
-M.S<A_S0T(?\V-"S_%Q85_R0B)/\D(B3_(1\A_Q<5&/\2$!/_$Q,6_Q\A)/\&
-M"C#_-RYC_[2CV?]%.&O_44QD_QP9)?\^04;_&R >_RTQ+_^=G:;_>WF)_RHK
-M,O_$O[K___+M_X1R:/\6%!?_%!8;_UY=5O])1T3_'!@:_QP7&_\B%13_'1$,
-M_QL6%O\4%!?_$Q@8_RDM*_^KIJ;_W]#+_[*KJ_\P-#;_*C(T_RLX.?\J-C/_
-M+SP]_RHV._\K,S?_*3(R_RDU-/\D,"__)# O_RHR-/\J,C3_("@J_Q@C)/\:
-M(B3_("8H_R@N,/\F+"[_+"PC_QP[7?\'$R[_'148_QTW</\G,U+_)R4H_QX9
-M'_\D'R/_'QP;_R0C(O\H)BG_(QPC_QT;)/\C(RS_(R ?_QP=*/\H(R?_)B4K
-M_RPH,/\S+#/_+BDM_S<U./_5S,S_Z-;3_XZ/D/^9E)C_U,7%_\>XL_^NI*#_
-MQKZ\_UY96?_,PK[_D(J(_T=(2?_'Q<#_,BHH_\S$R/\D)"?_N+"L_]C*Q__.
-MP<#_A'UW_R(D&__*QK[_2#PU_ZRLH_^LK*/_,"\H_ZNLI?\W.S/_D)*)_S\_
-M-/]$13C_<7%D_V9G6O^1BX/_V,6__]["O_^ID8[_)Q@8_RD=(/\2#0__$0\,
-M_RLK'/\R-1__,30=_R\S'?\N,"W_,C,T_S$R,_\Q,C/_*BDH_Q43%?\8%AC_
-M3DQ/_Q48._^AG+;_9F%<_Z>BNO\<&S__(R(__UM;;O\S.#+_.3TU_R ?)?\K
-M*#3_961J_\C"P/_^[_#_QK2P_SX\1?\D*##_&!83_Q@7%O\5$Q7_%1,6_Z*=
-MG_^OIZK_&108_Q86&?\E*BK_-3<U_[6PJ__<S<C_X-'1_X^&AO]J967_75Q;
-M_TE/2_\K-C?_+CH__RXV.O\J,S/_*C8U_R8R,?\B+BW_)C$R_R(M+O\B+2[_
-M(RXO_Q8>(/\;(R7_'24G_R H*O\O,2C_)$!;_PP7+_\A'1__(#MQ_R0M2_\:
-M&1__(QXB_Q\;&?\Y-S#_2DA _TQ'1_\5&2[_'"U1_QTW8_\I0&K_'RE$_UI4
-M6/\H)2O_'R G_QX:'/\D(B3_*"8C_^;<V/_OW-S_0T-&_VMF:O_8R<G_O[*M
-M_[>MJ?_$OKS_44Y-_]/*Q/^]LZ__J*6D_\K%O_^QI:'_Q+S _RTM,/^WKZW_
-MWM#-_S,H)_^AG);_5%1+_VIJ7__ MJS_-CLO_YVBEO]!/SC_N[JS_T$_./^N
-MJ:/_5%1+_SL^,O]664W_4E5)_TY-0O_7Q[[_]-7/_^K/R/_6O[K_J9>3_T@_
-M/_\3$!;_%1(8_QD4&/\7$Q7_,"TL_Q83$O\=&1O_)R,E_Q@4%O\<&1C_+2@H
-M_TY)2_^;E9G_#PL__Z>BS/^VL[__KJ/8_Q01//\@'C__*29#_V)C;O\Z.SS_
-M)B8I_R0C*O\L+"__TLK(___S]__.O+G_'QPI_QP?*_],24C_'!L:_QD7&?\9
-M%QK_'!8>_R :(O\<%QW_&!89_T=,3/\]/SW_O[JU_^S=V/_PW=?_T+VW_^C7
-MT?_@T<O_JZJC_SE 0/\O.S__*# R_RPU-?\I-33_*#0S_R<S,O\D+S#_(RXO
-M_R,N+_\B+2[_)C$R_RLV-_\J-3;_)S(S_RPV+?\U15G_$!XG_Q\A)/\M2'[_
-M*C1/_R,C)O\L*"K_+RTF_UA73/]C8E?_7%A6_PT6)_\,)E'_$3I\_QY$@O\G
-M.5__LJVS_RLF*/\>'2/_)!\9_YR<D_\Q+RC_[N+=__';W/\Y-SK_RL3(_]_,
-MS/^YK*?_P;>S_\"ZN/]23T[_VM'+_[RTL/^ZL[/_S,.]_];(Q?_.QLK_)24H
-M_\S$PO_:S,G_6U-1_SDX,?_!O;7_(B<;_X!]<O\Y/##_M[RP_UU84O^EGIC_
-MF(^)_WEM:/]$1#O_4E5)_TI-0?]%2#S_86%6_\:XK__OT\S_X,? _^7*O__P
-MU]#_TL/#_R 6'_\5$!;_&!06_R4B(?\O+2K_%A,2_S4Q,_]#/T'_&A88_R8A
-M(?]84U/_=7!R_XN%B?\2'1C_&!0[_RP?6O\<&D'_&!DR_Q,0+?\9%CK_)R5&
-M_S(P0/\F)2O_)R<J_R@I*O_8RLO___+R_\V\MO\@'R;_%ALA_T-!/O\E)"/_
-M%A06_QH8&_^,?W[_FHR-_R$7&O\@&R'_.C\__S4W-?^_NK7_\.'<_^W?W/_C
-MU=+_VLK'_^'1SO^RJZ7_/T$__R\Z._\N.CG_+3DX_RTY./\N.CG_+SLZ_RTX
-M.?\N.3K_-#] _S(]/O\N.SS_+SP]_R8S-/\@+2[_'2XD_R$E-/\;*BG_,#@Z
-M_R4]=/\H,TS_'R A_RDF)?\I*2;_2DU'_SH^-O\V-SC_%R$P_Q\[9_\0/(#_
-M'D!__RH]9_^?FZ/_0S@W_R<E*/\K)B#_GYV6_S,N*?_KW-W_[]C9_RLF*O_/
-MQ\O_Y,[/_[ROJO_)O[O_M[&O_TY+2O_;TLS_M*RH_\G P/_6Q\+_T,"]_\W%
-MR?\H*"O_R<&__]/%PO_!O;O_.3TU_Z&8D?\K,B;_M*RB_T,],_^.C8+_H)Z7
-M_UU;5/^LIZ'_0CLU_U]?5O])3$#_8&-7_U583/])3$#_P[>N_]2YLO^LEH[_
-MOZ:?_^'(P__:P<#_T[V__QL4%/\?'!O_7UU:_R8D'_\[/SW_+"\P_SL^/_\W
-M.CO_.3T[_UY@7O]?8&'_2TM._Q00&/\4#QO_#Q00_QD7*O\6$2W_%Q,M_Q44
-M,?\3$C?_.35+_S,R.?]$1D3_0T5#_]'(R/__]O+_P;2S_Q\>)/\2%!?_'1D7
-M_R0?'_\A'1__%1,6_S0I*/]#.#?_'QH<_QH:'?]$1D3_,#@T_\.YM?_QW-K_
-MY]O7_^'5T?_=T,O_V<W&_YZ7D?\C(!__%A@=_Q<;'?\?(B/_'1T@_R @(_\B
-M(B7_)2DK_R4K+?\F+"[_*C R_RPP,O\R.#K_)3(S_R8Q,O\J+RW_'RHQ_R4P
-M*?\E)R[_)#]U_RDQ2_\D(B3_)R@I_T='1/]454__4E5/_R8H*_\/)$#_&$-O
-M_P8R?/\F1X__(SYM_[BGI_\P+S7_*R8A_S,Q+O^@FY7_-"PH_^O<W?_OV=K_
-M+"DH_];-S?_;S,S_>W-O_]?&QO^PJZO_2DI-_]O3T?^ZKZ[_RK^^_\6XM__&
-MO+C_R;_(_RPH*O_ O+K_>G1R_[&LI_\].#+_BH%Z_TY,1?]E7EC_C(9^_T1!
-M-O^AH)G_+B\H_ZJIHO\L*R3_7F!7_T!$._]#1S[_044\_UA?4_^EGI+_R:^F
-M_\6JG__*LJG_RK*I_\>PI/_*LZ?_.R\K_SXZ//\?'2#_+2HI_TA)0_]*2T7_
-M4E--_U)33?],2$;_2T9&_QD5%_\5%1C_%Q(4_Q8.&/\6$![_%Q4>_Q83*O\5
-M$2O_%Q4O_QH;-/\A&CS_'A@L_QT<&_\E)"/_B(.'___S[_^WJZ[_%1(8_Q<7
-M&O]U<'#_/3@X_Q82%/\8%AG_)A\?_QL4%/\;%QG_%1<:_TI)2/\T/#C_P[NY
-M_^K;V__@T=+_XM#4_]G(R/_3P\#_GYJ4_Q\;'?\5$AC_$Q,6_Q@6&?\3$13_
-M&1<:_Q43%O\0$!/_$!(5_QD;'O\7&1S_%148_QD='_\@+2[_(RLM_R@K+/\=
-M*B__)2LG_RPN-O\D07?_)2M%_R,?(?\D)B3_/STV_U%12/]=7E?_&!D:_PXD
-M1/\91&[_!C-Z_RA)DO\>.VO_NZ:B_R D+/\E(!K_2TM(_Z&<EO\Z,"S_Y=;6
-M__#:V_\V-#'_V-#._][/S_^:EI3_WL_0_Z6AH_]*3$__T,G)_ZRFI/_4SLS_
-MP+JX_\2\N/^]L[S_,BTM_S(P+?](1DC_FYN8_YB6D?\].S3_J:6C_S,O+?^O
-MK*?_0#XW_YR:E?\Y.C3_=79P_R<H(O]%24'_-CHR_T1(0/]"1C[_1DQ$_U10
-M2/_*MZ__RK*I_\FQJ/_#J:#_O*&6_]6XK/^_K*+_0S<S_QX9'?]'0DC_%Q,5
-M_Q\;'?\E(2/_0CY _S\W-?^CFIK_&Q88_Q<5&/\4$1?_%Q,<_PT,&?\4$B7_
-M'1DS_QP8,O\;&"__%1(H_Q\:-/\F(S#_-#(M_S0R*_]055/___#L_[&EJ/\>
-M&R'_&QL>_R4@(/]U<'#_&147_Q$/$O^JHZ/_LJNK_Q<3%?\3%1C_'AH<_R$I
-M)O^QKJW_P;R\_W=\@?])457_0TM-_T)+2_]*3TG_%Q47_Q,0%O\2$!/_&A@;
-M_Q02%?\5$Q;_$Q$4_Q04%_\2$A7_&1D<_QH:'?\8&!O_&Q\A_R M+O\B*BS_
-M(RDK_QHE+/\C)2/_)28Q_R9">_\?)#[_)R,A_S4V,/]'13W_5E9+_TU/1O\A
-M(R'_%2Q)_R!+=?\)-GW_)D>0_QPY:?^QG)C_%1DA_R8A&_]34U#_G)>1_T V
-M,O_NW]__[]G:_S N*__9T<__W]#0_WMY=O_;S<[_GYV?_T5)2__3T,__K:NH
-M_]73T/^\NK?_HYZ9_ZF?J/\T+R__'!H7_S4X/?\>(R/_%AH8_S@Z-_\S+S'_
-M&A88_W!M;/]&1$'_*"<F_S0V-/^BI*+_(R4C_U]A7O]*3$G_04- _S]!/O]9
-M6UC_3DY+_V%<5_^9C8C_MZ6A_\BTL/_1N+/_T;6N_\VTI_]40SW_(QHA_U5/
-M5_]X<GK_>'%[_WYW@?^NI['_J)^?_Z^FIO\:%1?_%Q48_Q<9(/\4%2#_(R(S
-M_QH7+O\:%RW_$Q B_QD5)?\4#!K_$ P4_S0Q,/\_/C/_2T@\_S@V+___\>W_
-MJIZA_R$>)/\:&AW_A8" _[:QL?\2#A#_&!89_QT6%O\K)"3_&147_Q47&O]H
-M8F;_%1P<_YJ=GO\Z/3[_+C\__S%"0O\T1D3_.DQ(_TI33/\4%1;_%A,9_QP6
-M&O\9%QK_'AP?_Q43%O\3$13_%A07_Q02%?\<&AW_&A@;_Q45&/\:'B#_(B\P
-M_QHB)/\B*B[_$QTG_R(>(/\:'2G_(3IU_R0F0?\J)2#_45%&_SL[+O]864S_
-M,30H_QX@'?\8+TS_'TIT_PDV??\J2Y3_(C]O_\2OJ_\4&"#_)B$;_W1T<?^H
-MHYW_23\[_^K;V__RW-W_(B =_Y^7E?_6Q\?_N;FV_]O/T/^8F9K_5EQ>_\_(
-MR/^ZLK#_VM+0_\*ZN/^[LZ__I9ND_U)-3?\B(!W_'ATD_Q06&_\7%1C_'!@:
-M_Q -$_\3$!;_$Q$4_RLI*_\K*R[_&1L@_Q06&_\1$QC_)"4F_S4V-_\^/T#_
-M2TQ-_R@F*?\6&!O_+#$Q_V9H9O]05%+_/#X[_U=23?]L8%O_?W-L_W)J:/\>
-M&1W_4$I._R$<(O\0"A+_+"8N_VQF;O]<4U/_K:2D_QH5%_\7%1C_#P\:_Q(1
-M'O\B'RO_%@\9_Q44&O\7&!G_HIV=_Z:>G/]*2$'_1D0]_TY)0_]23$3_?W=S
-M___Z^O^\L;#_)R(B_R0@(O\D'Q__C8J)_P\+#?\5$!3_LJBD_[>KI_\?%Q7_
-M'!D8_Q\5&/\@)"+_EI:3_U]B8_\T0D'_.$9%_SI)1?\^34C_0T]&_Q$4%?\;
-M%AS_$Q$4_Q@6&?\9%QK_%Q48_Q02%?\9%QG_%A06_QP:'/\5$Q7_&!88_QPA
-M(?\F,C'_(BDI_R4L+/\9'2S_'QL9_PX5(?\A.W3_&A\X_R<F)?\K+2K_-#LT
-M_S4X.?\O,RO_,38P_QPQ4_\K5H3_%D2._RY-E?\X473_JYB8_QHB'_\>%!?_
-M?'MT_Z*:EO]@5%?_Y=?8_^O<W?\N*BC_P,&[_["IH_^HH:'_W,W1_X:+B_]A
-M:FK_U=3-_[VZM?_?V=?_R\2^_[RWLO^-B(K_8%U<_S,R,?\:'!__%A@=_Q04
-M%_\8%AG_$A 3_Q(0$_\3$13_)B0F_QX>(?\:&AW_%!07_Q$1%/\4#Q/_% \3
-M_Q,1%/\2$A7_%QH;_QH=+O\-$2#_&!$B_R4:+?\G+37_-CLY_U164_]54DW_
-M5%!._QD4&/]13E3_+BLQ_R(=(_\N)2S_;FEO_TU$1/^NI:7_&!,5_Q43%O\.
-M#13_% \3_ZRGI_]\>'K_.#8X_S P+?^6EHW_H9R6_TQ*0_\>'AO_(R$C_R@C
-M(_^WM;C___3Q_Z&6E?\:%Q;_'AH<_S<T,_^VL[+_%A(4_Q\:'O\>&1__%1(8
-M_Q<9(/\4&B+_=W!W_QPD(/^*CXG_>7Y\_S5!0/\Y0D+_.4- _SM&0?]"3D7_
-M$A,4_QD4&O\5$Q;_%1,6_Q84%_\7%1C_%!(5_Q84%O\7%1?_%A06_QD7&?\8
-M%AC_'2 A_R(N+?\@)R?_+#0Q_Q,5)/\<&13_"Q4@_QHR:_\9'S7_0#\^_T!"
-M0/\K,"K_'QPB_S8T+?\W.3;_'S99_RE7A/\:1I#_*TJ2_SE2;_^QGZ'_%AX:
-M_R8;(/^*BW[_I9^7_VA:6__JV=G_Z-C<_SDT-O]Y>7;_U<G$_Z6>GO_8S,__
-MC9*2_WR#@__(QK__O;BS_^#7U__*P;O_O[>U_XJ%A?]Q;FW_+BTL_QH<'_\6
-M&!O_%!07_Q@6&?\/#0__$Q$3_Q,1$_\D(B3_'AP?_QP:'?\9%QK_%!(5_Q4/
-M$_\4#Q/_$ X1_Q,3%O\8'RO_'R5%_Q$7,?\:%RW_6$EB_V1I=?]D:6G_5EA5
-M_X6#?O]134O_&A49_U).5O]_?H3_?WA__X!W?O^VL;?_A7Q\_Z:=G?\<%QG_
-M'!H=_QP;(?\<%QG_K:>E_X:!A?\[.3S_+RXM_X:&??^=FI7_244]_QH8$_\:
-M&!7_-"TG_[ZXO/__]/#_?79V_QD:(?\0#A'_B(2"_ZJGIO\>&AS_'1@<_W1I
-M:/]N9F3_&A45_QT;'?\O)RK_%R 9_S8],_\Z0C[_)BTM_R,F)_\9'1O_*2XJ
-M_T901_\;'!W_&10:_Q43%O\8%AG_&!89_Q@6&?\4$A7_%A06_Q43%?\6%!;_
-M&1<9_Q43%?\>(2+_(R\N_Q 7%_\K,S#_%!8E_QL8$_\4'BG_&3%H_R\S2/](
-M1D/_)"0A_RTK(_\Z,#/_.3,K_S\].O\D0&+_+%>%_QY&D?\J2Y/_1%]W_[>E
-MJ?\3&AK_(A<<_XV0?O^CH)3_>'!N_\&UN/_2R]7_'!XF_S@[//^UJ*/_J:2D
-M_]G/TO]]@H+_FYZ?_\K%P/^ZM++_W-+5_\B^NO_.QL3_?GEY_XF&A?\?'AW_
-M%QD<_Q47&O\1$13_%Q48_Q05%O\.#Q#_/T!!_QX?(/\G)2C_)2,F_R >(?\4
-M$A7_%A 4_Q0/$_\/#1#_#P\2_QPE/?\;(5'_$QY _Q8;-/\O(#G_:6YZ_V1I
-M:?]H:F?_B8>"_U).3/\D'R/_/#A _T9%2_\1"A'_.C$X_XR'C?]C6EK_HIF9
-M_Q\:'/\6%!?_$Q(8_QP7&?^JI*+_-"\S_QH8&_\G)B7_?W]V_WUZ=?\_-C#_
-M*R8A_Q\:%/]63$'_R\'$___V\/]53U/_-3I&_R@E*_\D(![_L:ZM_QD5%_\:
-M%1G_8595_V-95?\;%Q7_'1P;_RH<'?\H*2+_E92)_X>(@O\E+"S_'R8F_QXF
-M(_\J,B[_2E9-_Q@9&O\6$1?_$Q$4_Q84%_\6%!?_%A07_Q,1%/\4$A3_%!(4
-M_Q84%O\9%QG_%Q47_Q\B(_\G,S+_"Q(2_RTU,O\/$2#_&Q@3_Q<A+/\9,&7_
-M'B$S_R$?&/\L*B7_/#HK_R<B'?]*1SS_@HB$_R-"9/\L5X7_'$"+_RU.EO])
-M9WW_P*ZR_QH?)/\C&1S_D)"!_YZ<E?^,CI/_F:2K_Y>CLO]'6&7_.D9*_XZ&
-M@O^HI:3_W=78_Y.8F/^IJJO_P;^\_[JYN/_8T]?_NK:T_\G"PO]S;F[_A8*!
-M_R\N+?\8&AW_&AP?_Q(2%?\8%AG_#0X/_UA;7/]15%7_(B4F_R >(?\D(B7_
-M'1L>_Q,1%/\6$!3_% \3_Q$/$O\4%!?_'28^_QPC4?\4'4+_'" \_RX>.O]A
-M9G+_65Y>_VMM:O^5DX[_44U+_Q<2%O\L*##_'ATC_S(K,O\Z,3C_?GE__U1+
-M2_^IH*#_'!<9_Q@6&?\3$AC_&106_Z6?G?\8$Q?_%1,6_QH9&/^!@7C_F9:1
-M_SPX-O\F(B3_&1@7_U--0__ O;S___7R_T Z/O\;'"/_&!D:_WAZ=_^\M;7_
-M&A@:_Q43%O\F'Q__&A88_Q83&?\='"+_BX:&_RHK)/^=E(W_@X%\_R\W-/\H
-M+2O_&1\;_RTS+_]365'_&!88_Q01%_\4$A7_%1,5_Q02%/\3$1/_%!(4_Q43
-M%?\4$A3_&1<9_QD7&?\7&!G_(B<G_RPU-?\;("#_-3<__Q8>&O\=%1G_&1\G
-M_R0V;O\9'R__)BHB_RTP*O\V+2;_.S8V_VUP<?]&3T__,%%C_QM0AO\;.W/_
-M.$]Z_UQH=_^ZLK;_(ATC_R <'O^-CX;_HI^4_U-@:_]+;(/_1VN _R%"6/\A
-M-D+_*2LI_Y^AGO_#QL?_A(F._\/$Q?^_O+O_6EU>_[[#P_\^04+_S<G+_V%9
-M7/^7CY+_&1<9_R4E*/\9&1S_$Q,6_Q<7&O\0$!/_'AXA_R,C)O\H*"O_&1D<
-M_QL;'O\5%1C_$! 3_Q,.%/\3#A+_$A 3_QL:(?\5'##_&B%+_Q8=0?\;'#O_
-M9D]Y_W-P??\J-3;_'R K_WUZ>?]'1$/_&!06_RTH+/]'0DC_13M$_T,T/_^$
-M?(;_85-4_Z&9G?\4$AO_$Q48_Q,1$_\<%Q?_EY&/_PT+#O\5$AC_&!<6_V5F
-M8/]K:6;_-38W_QH<(?\4$A3_5%)*_[VZN?__^/?_3$1(_R4D*O\>'R#_+S0P
-M_[^VMO\9%QG_)"0G_[.KJ?^ZM;?_&Q8<_Q$/$O\>&1G_'R,;_Z&6C_^ ?GG_
-M-#PX_SD_._\M,R__-3LW_UU@6O\8%AC_%!$7_Q02%?\3$1/_%1,5_Q43%?\5
-M$Q7_$Q$3_Q02%/\9%QG_&1<9_Q87&/\A*"C_,3HZ_Q(7%_\M+3C_(RLA_R,9
-M(O\?)2W_'RUE_S8U1O\W.#+_/T$^_S,X,O^9I:3_F:6I_VYU=?]/96/_,UEY
-M_W1\D/^(@'[_AH&!_ZRFJO\;%AS_'AP>_XV.B/^=F(S_2%EF_T=MB/^OS^7_
-M=(ZC_T147O^$A('_F9J4_R<M+_\P-3K_L*ZP_\._P?]D:6G_7&AG_W1[>_^$
-MB8G_D8^1_ZB@H_\8$Q7_%1,6_QH:'?\0$!/_%Q<:_PX.$?\6%AG_'1T@_QX>
-M(?\?'R+_&1D<_QD9'/\/#Q+_$PT5_Q,.$O\0#A'_%!(;_Q4>-O\9(U#_&R5*
-M_Q09-_]E3WS_?GF%_Q 8&O\:&B?_'1D;_U524?\H)";_,"LO_R<C)?\B&!O_
-M,B4J_WEP=_]!-C7_8%99_Q$.%/\4$!+_%A(4_QD2$O^5CXW_%1(8_Q00&/\7
-M%1?_75Y8_YZ>F_\Q,C/_'!P?_QT;'?]+2D/_AX2#___X]_]#.S__'QXD_Q46
-M%_\E)2+_L:6F_QL9&_\9&Q[_&1,1_Q81$_\<%QW_&QD<_Y*-C?]%24'_HI>0
-M_W]]>/]<95[_9FUE_V!G7_]A:&#_9&A@_Q@6&/\9%AS_%A07_Q84%O\:&!K_
-M'1L=_Q84%O\5$Q7_$A 2_QD7&?\7%1?_%Q@9_R8M+?\T/3W_%!D9_S,P//\A
-M*![_&A 9_PD2&?\;*6'_&Q<G_R<A'_\8&AW_-$M*_X6AI/]D>'S_3596_U)I
-M:/\S6'?_<7)]_Y> ;?^%=V[_J*">_R$?(O\?'1__C8J%_ZBAE?^1HJ__)4]I
-M_[//Y/^URMS_$QTG_XJ%?_^#@'O_'B(D_UE;8/^_N[W_O;F[_RPQ,?\T0#__
-M-#T]_TQ85_\D)RC_E(R/_QD1%/\6%!?_&AH=_Q 0$_\8&!O_%148_QX>(?\>
-M'B'_0T-&_RHJ+?\@("/_*BHM_Q(2%?\4#A;_% \3_PX,#_\3$1K_%2$\_QHE
-M5/\<)TK_,C5._V)4>O^ ?H?_#1 5_Q42'O\0#0S_4$U,_QD5%_\@&Q__0T)(
-M_U945O]C7%S_IJ*J_VYO=O\6%!?_&1(2_S$E(?\?&AK_&Q04_ZFCH?\4$1?_
-M$P\7_P\-#_]B8UW_FYN8_ST].O\=&QW_&QD<_RTN*/\:%AC___KY_RLC)_\2
-M$1?_'!T>_WEW=/^FEYC_%1,5_RDM+_^[M;/_G)>9_Q@3&?\=&Q[_%Q(2_T5)
-M0?^HG9;_A8-^_V5O9O^%C8/_;'1J_V=O9?]I;67_%Q47_QH7'?\:&!O_&!88
-M_QL9&_\>'![_'!H<_Q@6&/\:&!K_&A@:_Q@6&/\7&!G_*"\O_S([._\4&1G_
-M-3 \_R(F'?\@%A__'2DP_R$V;/\6%"3_(A\>_R$M-/^*I*?_@IVD_UUT>?]&
-M4D__46IO_RU5?/]T>8O_D8!R_W-@5O^>DHW_(2(C_Q\;'?^2BH;_IYV2_YFJ
-MM_]VHKS_F,38_ZG-XO\J.TC_B(.#_YV8D_\>'B'_2TI0_\7 PO^NIJG_.C@Z
-M_S@[//]+3D__/D-#_QH='O^"?H#_&!D:_QD9'/\<'!__$Q,6_Q04%_\6%AG_
-M%A89_QH:'?\]/4#_'Q\B_QD9'/\?'R+_#@X1_Q0.%O\4#Q/_$0\2_Q(0&?\8
-M(CW_(BI6_Q8<-O\8&"'_5$QG_T ^1_\K)R__&QHA_X.!?O]23T[_&A88_R<B
-M)O\-$B3_'",Q_S(U0/]G;8/_=H&@_Q\D-O\=%A;_."TF_R,?'?\=%A;_K:>E
-M_RLH+O\?&R/_%!(4_V)C7?\;&QC_,S$L_QL8%_\5$Q;_*2TK_Q@6&/_Y[>[_
-M)Q\B_Q81%?\>&QK_'1T:_YJ.D?\H)2O_*"DJ_S$I)_\J)2?_%1(8_R(@(O]^
-M>7G_6U90_Z.:D_^4DHW_;G5N_Y&6D/]Z?7?_;G5N_W)S;?\4$1#_&108_QD4
-M&/\6%!?_&!89_Q@6&?\9%QK_&1<:_Q84%_\@'B#_%Q85_QL:&?\G,S#_-#DW
-M_Q8:&/\X/D#_(1\<_QX7$?]&3E[_)"U<_QH;)O\@'AO_)C0S_X:;G?]SB8O_
-M87=U_UMD7?]>=7#_+D]Z_WA\?O^<AX+_9UI-_XJ"?O\?("'_+S$O_X>.@O^I
-ME8W_4%AB_V24J?]YJ,#_F\WH_UM\D_^\M[W_@G9W_Q\@(?\[/C__S\G'_ZBA
-MH?\Q+S'_+R\R_RHI+_]<6%;_'1H9_T-"2/\)"!7_'18B_R :(O\9%AS_$!,4
-M_Q45&/\4$A7_$0\2_Q84%_\?'2#_%A07_Q$/$O\1#Q+_$A 3_Q(0$O\2$!/_
-M%1(8_QTC0_\1%C#_$0\2_Q<1%?\I)2[_)R0J_S M,_\N+"__,2\Q_R8D)O\>
-M&AS_0CT__R(E/O]*46?_%!XL_R,S3?]*5G7_"PP=_R$9%?]A7$K_0SXY_Q@3
-M%?^BG9__*B0L_QH5&_\5%Q7_24Q&_U!/2/^LHI[_&1T;_Q@9&O\H)BG_,"XP
-M___S\O\H("/_)"$G_R$<'/\_03[_=&EN_Q -$_\E)B?_-2HI_R<A)?\4$QG_
-M&Q<9_UM65O]G8%K_H)J2_Z6CGO^ A8'_G)V7_Y*0B_]V>7/_>'AU_Q<4$_\8
-M%!;_%Q(6_Q$/$O\6%!?_%!(5_Q<5&/\5$AC_%A07_R,A(_\;&AG_'!L:_R<V
-M,O\X/#K_&!P:_R\[./\E(B'_-C F_R8L//\>)U#_%1LC_R(>'/]46UO_5&=G
-M_W2*B?][CHC_8&IA_UEP:_\N2WO_=WQZ_YF#@?]U:V#_=G!N_RHK+/\P,B__
-MCXZ#_VIB8/\,)S+_<:C _X.QS?]BEK?_>:+ _[.SO/]N8F/_)"(D_RXR,/_/
-MR<?_GYJ:_RPJ+/^FIJG_*BPQ_[&MJ_\;&!?_8F-J_R<D,?\\.47_(2(I_Q03
-M&?\1$13_$Q$4_Q84%_\2$!/_$Q$4_QH8&_\7%1C_$0\2_Q$/$O\2$!+_$A 2
-M_Q .$?\<&1__'"-!_PH-'_\0"PO_*",E_Q@5&_\9%QK_)"(E_R >(?\=&QW_
-M(B B_VIF:/\F(2/_$P\?_Q@8(_\5&!W_&B4P_QXF.O\Y/47_)R(=_S4O)_]L
-M:VK_# T._Z2BG_\U,"O_(1P<_Q88%O\^0S__3$I%_\6YM?]'3$K_+B\P_QD4
-M&/\8%AG___3Q_SDT.O\7%R3_)B$E_RDK*/]]<G?_&A<=_XJ+C/^RIZ;_<&IN
-M_Q,2&/\:%AC_%Q(2_W=P:O^;E8W_N+:Q_[V]NO_!OKG_J:&=_YR:E?^<FI?_
-M)2(A_R <'O\<%QO_$Q$4_QH8&_\3$13_%Q48_Q<4&O\7%1C_(!X@_QD8%_\?
-M'AW_*CDU_S<[.?\8'!K_+C8R_R<B)O\G)A__)"DU_QPF2_\4&R'_/SLY_X2)
-MCO^7K*[_@9:8_WB&A?]E;6G_771O_R1!<?]Y?GS_E7]]_W=M8O](0D#_*2HK
-M_R,E(O^?D(O_&2,G_S9?<O];C:C_99.O_UV1LO]0?9O_JK"Z_U]56/\L*BS_
-M%!@6_]#*R/^@FYO_'AP>_["PL_]"1$G_LK"S_QH:'?]S=7C_%1(8_QXB)/\E
-M*2O_%!07_Q,.$O\6%!?_&A@;_Q<5&/\2$!/_%1,6_Q,1%/\0#A'_$0\2_Q$/
-M$?\1#Q'_#PT0_QL8'O\?)CS_%!8E_QT8&O\E("3_$A 3_QD7&O\L*BW_'1L>
-M_Q<5%_\5$Q7_34E+_RDD)O\:$A;_%A(4_Q(1$/\A'R+_$18<_Q@>(/\L*2C_
-M'Q,6_V1:;?\;$BK_C("5_X%V??]%/#S_(1X=_SQ /O\P,C#_S\3#_S U,_]'
-M2$G_(!L?_QH8&___^//_03U&_U-8:O\4$A7_)"0A_V]D:?\7%!K_$Q05_R@=
-M'/\6$!3_%Q8<_QH6&/^/BHK_?WAR_YV7C_^MJZ;_TM#-_]C0S/_7R\?_K:BC
-M_ZNIIO\9%A7_&Q<9_QH5&?\3$13_%Q48_Q$/$O\4$A7_%1(8_Q84%_\6%!;_
-M.3@W_R0C(O\I.#3_-3DW_QD=&_\O-##_)2(H_QT?'/\4&B+_%QL[_QP>(?];
-M65;_BYB=_XFCIO^%F9W_96UO_UAB7_]7;VS_)4)R_WA]>_^+=7/_;V5:_T])
-M1_\D)2;_(R4B_YV4C?]=;''_'RY%_Q K0_]]I;K_F\OG_Z',Y/^\P,+_4$='
-M_RDG*?]@9&+_SLC&_YF4E/\;&1O_N[N^_TI,4?^XM[[_&1L>_V!C9/\8%!+_
-M(1T;_R8A(?\9%!;_% \5_Q@6&?\B("/_'1L>_Q(0$_\1#Q+_$A 3_Q84%_\3
-M$13_$0\1_Q$/$?\-"P[_'!D?_S,[2_\2$A__%0\3_Q(3%/\0$!/_&!89_R0B
-M)?\7%1C_&!88_Q<5%_\8%!;_&A47_QP7'?\-#Q;_!PP2_P@'#O\3#A+_'!H7
-M_Q\;$_]^:6?_?6)R_T@N2?]3/5?_0C8__XV"@?]645'_.3L^_RTO-/_.PL/_
-M+C,Q_TQ-3O\=&!S_%Q0:___Y^O\G)BW_*B\[_S4T.O\H(B#_5U%5_QX;(?^6
-MD9/_M*RJ_SXY/?\.$!7_&A@:_QX;&O^ ?G?_E9.+_[RZM?_7T<__V]#/_]?,
-MR__"M[;_K:FG_R0A(/\:%AC_%1 4_Q,1%/\9%QG_%Q47_Q@6&/\7%1?_%Q47
-M_QL9&_\?'1__'R,A_R\W-/\X/3O_'"$?_S0X.O\?(2;_&AT>_Q$6'/\7&BS_
-M%R(C_T-84O]YCY?_EK&\_WR8H/]>>(/_0U=E_TAE<?\R1V3_>7MY_Y:$=O]P
-M95K_2T=%_T)%1O\Q-C+_CH^(_WIW=O\<&2;_05IQ_X&PPO^9Q=G_C+?)_ZJY
-MN?\X-33_.3X^_V1I9__-R<?_CXJ*_QP8&O^.CI'_86-H_Z:DI_\3$Q;_,#,T
-M_R4B(?^2AH'_9%]9_QL=&O\;%QG_&108_QT;'O\5$Q;_$A 3_Q(0$_\2$!/_
-M$0\2_Q$/$O\2$!/_$A 3_PT+#O\;&1S_4$]5_TA'3?\4$A7_$A 3_P\-$/\0
-M#A'_&A@;_Q<5&/\1#Q+_" 8)_Q(0$_\:%1G_1D)*_S\]1O\Z.D7_$0\8_S(I
-M,/] -3K_B7Z#_UA'4?]I76S_9%IK_W=N>_]O:&__HYZ@_YV7E?]*1T+_55-5
-M_];*R_];4U'_2D-#_QH5%?\<%AK___3T_RPG*?\>("7_(1X=_RXF)/],1DK_
-M(R F_R8>(?\J(B#_'1@<_Q@:'_\<&AS_=G-R_X.">_^8F(__O+JU_]C0SO_>
-MT]+_V<[-_\6ZN?^JIJ3_1T1#_Q82%/\7$A;_%Q48_QH8&O\7%1?_&!88_Q<5
-M%_\7%1?_&QD;_QT;'?\?(R'_,38T_S,X-O\=(B#_.#8Q_R0B'_\?'"+_%A,?
-M_Q01*/\P-U7_'S%5_R V7/\O5'?_.VJ-_RU:@O\>16__+%5Y_RY(;_]\@XG_
-MGI"!_VQ@5_]%03__+C$R_RHO*_]?8UK_@7]Z_UUF;?]9?)/_;YZV_Y_!V_^#
-MI;G_H::K_S,L+/\T-3;_55I8_WZ ??]L:VK_*2PM_Z"DIO]>8VC_PL##_Q,1
-M$_\0$Q3_'AH<_R,A&O^XKZG_BWQ\_Q<1%?\6%!?_%!(5_Q02%?\3$13_$Q$4
-M_Q,1%/\2$!/_$A 3_Q,1%/\2$!/_$Q$4_QH8&_])1TK_%1,6_Q .$?\2$!/_
-M$A 3_R >(?\B("/_(R$D_Q<5&/]$0D7_%!(5_Q .$?\4$!C_$@X6_QH6'O\G
-M(RO_,2XT_S@S.?].2%#_85ID_Q$.&_\4$1W_'!@@_T(]0?^MJ*K_LJJH_WMO
-M:O]L967_BX*"_W!G9_]L967_7%=7_T,^0O__\.S_.S0T_RDJ*_]-1T7_-2TK
-M_S8P-/\:%QW_65%4_V-;6?\G(B;_&QTB_R8D)O\V,S+_CXZ'_YB8C__$PKW_
-MV='/_]?,R__:S\[_Q;JY_ZJFI/]/3$O_%1$3_Q81%?\3$13_%Q47_Q84%O\5
-M$Q7_%1,5_Q84%O\>'![_&A@:_R(F)/\X/3O_,#4S_R,H)O\U.3?_%Q\I_PL7
-M,O\,$S?_"!,R_RL\:O\>.7;_*4M]_R=0@?\^;)[_+%J,_S);C/]%:)#_3F:-
-M_TQ47O^7C8+_=VMB_S@R,/\_0$'_2$A%_VIN9?]J;F;_=8.&_SM=<?]]K\3_
-MH,?@_WBBLO]UA(3_A'M[_T,_0?\;(R#_+3,O_T-(1O]U>GK_N,#"_Q4?(_^]
-MN[[_'!H<_QH='O\>&AS_%1@2_[>IIO^;@(;_% \5_Q$1%/\4$A7_%!(5_Q .
-M$?\4$A7_$Q$4_Q,1%/\1#Q+_$A 3_Q43%O\3$13_%!(5_QX;(?\3#Q?_$0T5
-M_Q ,%/\1#Q+_&A@;_QD7&O\8%AG_$A 3_QT;'O\4$A7_&A@;_Q(/%?\2#Q7_
-M%1(8_Q42&/\3$AC_$1,8_Q,5&O\7&1[_$1(9_Q,2&/\R,#+_'QT:_Z&<G/^/
-MA(/_:%Q7_V9=7?]@7%[_7EI<_TI&2/]134__4E!3___R\_\J)2G_("(I_T(^
-M0/]#.SG_-2\S_Q<4&O^3BX[_FI*0_RHE*?\7&1[_'!H<_RDF)?^/CH?_E96,
-M_\3"O?_6SLS_U<K)_]K/SO_-PL'_H9V;_R<D(_\6$A3_%Q(6_Q,1%/\7%1?_
-M%A06_Q43%?\5$Q7_&!88_R,A(_\;&1O_)"@F_SD^//\O-#+_)"DG_SL[./\;
-M(RW_-D9@_T-/:O\U.E/_,#I._SU/7?\L/$S_)RP^_RLR0/\Z1$__7F)J_VAG
-M9O]N9V__@'ES_X1Z;_]S9%[_GY>5_T]-3_])1T3_'QL=_QP8&O\C)2C_/DI3
-M_Q8M,O]/8F[_CJBU_QPE)?\E("#_/#] _TA-2_]65E/_34Q+_TQ-3O^RM+?_
-M&!L@_[2OL_\>'![_'R(C_QX:'/\A'QS_N;6S_UA35_\6%1S_$@\5_Q(0$_\0
-M#A'_%A07_Q\=(/\5$Q;_%1,6_Q02%?\3$13_$0\2_Q,1%/\2$!/_-S,[_S(N
-M-_\=&2+_&A8?_Q(/%?\7%1C_%Q48_Q<5&/\/#1#_(!XA_Q<5&/\0#A'_&A@;
-M_Q02%?\4$A7_%!(5_Q,2&?\3$AC_%!07_Q,4%?\4%1S_$ X7_U%/4O\?'!O_
-M;F]P_V9D8?^%@'K_5%-2_TQ04O]%24O_2$A+_TI(2_]'14C___C[_R(?)?\5
-M%AW_'QP;_SPV-/\@&Q__(QTA_RX?'_\G%Q3_(AH>_Q,5&O\1%!7_0$%"_XB&
-M@_^;E8W_Q\*]_];/S__=U-3_V]'-_]'%P?^>EY?_'!<9_Q82%/\4$A3_$ X0
-M_Q43%?\=&QW_$Q$3_Q<5%_\9%QG_,"XP_QH8&O\E*B;_,C<U_S,X./\D*B;_
-M/#@P_R@D'/]O;&?_8EQ4_W]U<?]L8US_;6A<_W!J8/]U:F/_<F9=_W-F6_]J
-M7%/_4DY,_U).4/]=6%/_;61=_VI>8?]%.C__'QH:_RXJ+/\;%1G_%Q,5_R0C
-M(O\?&AS_-"4?_R<9%O]74E3_>W-Q_R4=(/\E)"K_)BHL_R @(_\H)BG_&18<
-M_VAG;?\@'R7_G)ZA_Q<9'/\:&AW_'1L>_R,>&?_$P<#_:&=M_R,@)O\7&A__
-M%QD>_Q(/%?\8%QW_*RPM_QT;'O\@'"3_$Q$4_Q84%_\U,S;_#0L._Q84%_\Q
-M+C3_.#0\_QH6'O\;%Q__%Q(6_QH5&?\6$17_%1 4_Q83&?\7%!K_%!$7_Q83
-M&?\1#A3_$0X4_Q83&?\5$AC_%A,9_QL9'/\9%QK_&1<9_Q$-%?\3#Q?_.#0\
-M_RLH+O\G*2S_<G9T_U)44O]*34[_1$A*_T1&2?]#14C_1D9)_T9(2__[\_;_
-M)R(H_R$@)O^.B8G_=6]M_RHE*?\8%AG_O;>U_[VUL?\<%QO_&!<=_QD5%_\5
-M$Q7_DHV-_YZ5CO_*Q<#_UL_/_]W4U/_<TL[_TL;!_Z"7E_\?&AS_%Q,5_Q43
-M%?\6%!;_&1<9_QP:'/\3$1/_$Q$3_QH8&O\;&1O_&QD;_R0I(_\U.CC_+C,S
-M_R8L*/\T-2__+"DD_TM&0/])0SO_8UE5_UE13?]*14#_.38Q_S L+O\D(B7_
-M&!89_Q@6&?\;%QG_'QL9_RPE'_^ =FS_9UM<_V)<6O]I9F'_0#T\_QX:'/\9
-M%QG_-#(O_R<<&_]*,R?_.24=_\J]O/^#>77_(!D9_RPJ+/\S.CK_2$M,_RDJ
-M*_]A8F/_?7Y__Q$2$_^SM;C_&QT@_Q86&?\<&AW_*28A_[VXN/]@6F+_&Q@>
-M_S(W//\X.C__'QPB_R@J+_] 04+_%Q0:_R<C*_\3$13_# H-_S(P,_\6%!?_
-M$A 3_Q\<(O\8%1O_$Q 6_Q$.%/\8$Q?_&108_Q81%?\5$!3_$@\5_QH7'?\3
-M$!;_$@\5_QD6'/\1#A3_&A<=_Q,0%O\6$AK_%Q,;_Q41&?\6$AK_'QT@_RPJ
-M+?\M*R[_4E!3_TE*2_]%2$G_1$=(_T-&1_\_043_/D!#_T%#1O]"1$?_0$)%
-M__CP\_]'0DC_*RHP_Q\:&O]O9V7_)!\C_R B)?\@(!W_(1X9_Q43%O\:&1__
-M'Q<:_RXL+O^-B(C_GI6._\_*Q?_2R\O_U\[._]S2SO_6RL7_H)>7_R0?(?\=
-M&1O_%A06_Q<5%_\9%QG_&A@:_Q,1$_\2$!+_&A@:_QP:'/\:&!K_)RPF_S<\
-M.O\J+R__)2LG_R\Q+O\H)B/_/#DT_T0_.?]'/SW_&Q(2_R,<'/\>&1G_,RHD
-M_T0\./]234W_:%]9_V9:4?]Q9EO_>FU@_X5W:/]Y<6?_9F-8_VQK8/\U,S#_
-M(!XA_R(@(O\H)"+_+1X8_T8K&O\X(17_U,;#_Y2,BO\>&AC_75]<_V%L9_]:
-M8%S_7V5A_VEO:_]=8U__/4,__TI/3_\1$Q;_#P\2_Q84%_\W-"__3$='_R :
-M(O\8%1O_-#D^_UQ>8_]95ES_,#(W_U!14O\2#Q7_(!PD_Q<5&/\6%!?_&QD<
-M_Q84%_\@'B'_%1(8_R0A)_\4$1?_'ALA_QH5&?\:%1G_%A$5_Q0/$_\7%!K_
-M%A,9_Q@5&_\5$AC_%A,9_Q01%_\6$QG_&18<_Q00&/\@'"3_%1$9_R,?)_\U
-M-C?_4U53_V5G9?]*3$K_2DQ/_T1&2?]!0T;_/D!#_T)$1_\_043_.SU _SY
-M0_\Y.3S_^O+U_S0O-?\D(RG_;VIJ_Y:2D/\>&1W_+2@L_Z"5E/^+?WO_'1<;
-M_QH9'_\=&QW_'1X?_Y60D/^>E8[_S\K%_];/S__8S\__U,K&_]C,Q_^=E)3_
-M&A47_QT9&_\5$Q7_%Q47_Q@6&/\:&!K_$Q$3_Q,1$_\;&1O_'!H<_QP:'/\G
-M+";_.3X\_RHO+_\F+"C_-30M_R\J)/]+13W_6U-)_W]S:O]-03C_13LQ_TU%
-M._]P8U;_(1D5_R\K+?]/1#W_<F58_WUP8_]]<F?_AGMP_W!H7O]E8E?_<G!H
-M_S8R-/\<&1__&QD;_RTH(O\Z*![_8D(L_T@O'O^^KZK_:6%?_S$M+_]C9VG_
-M86QM_UE?8?]46ES_-ST__SM!0_\L,C3_3U-5_Q$3%O\-#1#_(!XA_SPY-/^-
-MB(C_(1LC_R,@)O\Q-CO_7F!E_Q83&?\9&R#_2DM,_R =(_\<&"#_)B0G_R$?
-M(O\<&AW_2$9)_TI(2_\4$1?_44Y4_Q\<(O\0#1/_%A$5_Q@3%_\4#Q/_&Q8:
-M_QD6'/\5$AC_%A,9_QX;(?\:%QW_%!$7_QL8'O\;&![_)2,E_R4C)?]'14?_
-M=7-U_U]?8O].4%7_2DQ1_T-%2O]!0TC_/D!%_SP^0_\[/4+_,3,V_S$S-O\T
-M-CG_+S$T_QD7&O__]/7_+R<J_QD9'/][?G__DY25_Q<7&O\='2#_:65G_VUL
-M<O\2%1K_)B<H_QP4$/\L*"K_D(N+_YB4C/_.S<;_U-'0_]',S/_6T,[_RL"\
-M_Z::G?\>%Q[_&Q@>_Q42&/\5%A?_$Q05_Q87&/\0$1+_#@T3_QP;(?\8&1K_
-M'B >_R@M)_\\03O_*S L_RLP+/\O*RG_03PV_U=11_]H7E#_8E!&_U! -O]%
-M.B__75-(_U]23?\5$!+_$! 3_VYI8_]L8EC_>VYA_WEK7/^$=VK_8UQ6_V!<
-M5/]Q;&;_'A89_Q40%O\2$!/_(!D9_U1!.?]A0RW_5#<E_Y!]=?^/AX7_*R0K
-M_V!?9?]05%;_4%-4_TQ-3O\'!@S_(R$D_T5!/_]25DW_)B@E_QX=(_\8%QW_
-M349 _UA03O\;%AS_%Q8<_R@P-/]66%W_&Q@>_Q06&_]$1DG_%!8;_QT=*/]$
-M1DO_+2LT_Q\<(O].3$[_3TQ2_Q01%_]85EG_'AP?_Q84%_\1#!#_&A88_Q@3
-M%?\A&AK_&Q8<_Q,/%_\;%Q__'1DA_QP:'?\@'B'_'QT@_U)04_]O<73_55E;
-M_TU14_]*3E#_0TA-_S]$2?\^0TC_/T1)_T!!2/]#0DG_0D%(_T)!2/\]/T3_
-M/4%#_SH^0/\V.CS_%1,5__SZ]_\K*"?_&!88_QL9'/\M+3#_&!@;_Q86&?\4
-M%!?_'ATD_Q06&_\5&!G_*28A_QX?(/^/CHW_GIB0_]/.R?_3R\G_U<O'_]/*
-MQ/_+Q;W_HY>8_Q@2%O\9&1S_&!,7_QP8&O\:%AC_'!@:_Q<3%?\1$A/_'1X?
-M_QL=&O\D)R'_'" 8_T!#/?\E)R3_%1<5_QX:&/])1T#_5E-(_VE?4?]X9ES_
-M6$@^_T4X+?]21SS_8E-3_QH2%O\8&AC_<FQD_V5;4?]M8%/_:EI*_W-F6_]5
-M4$O_:6=@_UI84?\3#A#_%1 4_Q42&/\?&AS_138Q_UL^+/]*,!W_EH9]_X9_
-M?_\D'23_*28L_V)H:O]\?X#_B8J+_Q<4&O\;%AS_>W=U_V]Q:/]B9&'_&AD@
-M_Q<6'/]%0#O_3TE'_QL5'?\5%QS_&B(F_SD[0/\9%AS_%!8;_T=)3/\/$!?_
-M'!PE_U!25_\V,3W_'QLC_V%?8?]855O_$Q 6_UA66?\>'!__'QT@_SLZ0/\8
-M%QW_%!$7_Q83&?\9%!C_$@P0_RHD*/]*1$C_4E!2_W1R=/]<6ES_6%98_TM-
-M4O]'2D__1DE._T)%2O\_0D?_.SY#_S@[0/\S-CO_+C U_RXM,_\N+3/_+BTS
-M_RLM,/\K+3#_+C S_RLM,/\@'B#_\_7R_SP^//\A'R'_CXJ._T]-4/\6%!?_
-M%Q48_Q43%O\C&Q__&108_QT@(?\6&!;_&Q\=_Y"1B_^BFY7_U<_-_];+RO_5
-MR<7_T\K$_\W'O_^>DI/_% \1_QD:&_\;%QG_&!,3_QD4%/\>&1G_%A$1_R4F
-M(/\R-2__0$,]_T)%/_\R,B__+BXK_R$@'_\1#Q'_(!L;_T1"._]$03;_7%)$
-M_WIK7O]31#?_0C,F_U-"-?]:2TO_'AD?_R,E*/]234?_;6)7_V582_]K7E'_
-M95Q5_U)-4?].2TK_:FAC_Q41$_\6$A3_&A<=_Q83&?\J'A__6#TL_TTX)O]H
-M7UC_;FIL_QX7(?\@'R;_4UM?_V%E9_^)B(?_%!$7_Q<3'/^"@(/_?X%^_V-C
-M9O\8%A__%!,9_TY,1_\6$Q+_&14>_Q@7'O\8("3_5%9;_Q,0%O\@(B?_65I;
-M_Q,2&/\H)R[_9&1G_S0P.?\?&R/_9V5G_V%>9/\3$!;_5U58_QX<'_\C(23_
-M96-F_QP;(?\6%A__1TI5_R <'O]D7U__@GU]_UU86/].3$__2DI-_T]/4O]&
-M1DG_0$)'_T)$2?\^0$7_/3]$_SY 1?\Y.T#_/D!%_ST_1/\]/4#_/S]"_SX^
-M0?\_/T+_/CY!_SP\/_\S,S;_(" C_QH6&/_V\O#_/SHZ_RTK+?\G)RK_FIB;
-M_Q@3%_\8$Q?_&108_QP8&O\5$Q7_&AT>_Q@6&?\?&QG_FI6/_YF4CO_6V=K_
-MS]/5_]#0T__-R,K_R[_ _V)65_]'0D+_?X%__V)?7O]34U#_0D(__S,S,/\N
-M+BO_.#LU_S0V,_\K+2O_(R,F_QP9&/\6$Q+_$0P0_Q40%O\@&1G_14,\_U93
-M2/]M8U7_@')C_W-E5O]N7$[_;UM-_UU.3_];5U__*"LP_T5"/?]G6U+_9EE,
-M_UM01?]*1D3_(Q\G_QH8&_]555+_'AT<_QH5%?\9%AS_&!<>_Q\9'?](+B'_
-M2C@J_U)33/]&14O_(!LG_Q<9(?]>9VW_8F=L_VAG9O\=&B#_&QLF_T)$3/\X
-M.CW_+2PS_Q@6'_\6%1O_/$$]_PT/$O\4$1W_&!8?_Q$9'?]%1TS_&!4;_Q06
-M&_],3DS_&A@;_R,@)O]F9&;_+"@Q_Q\;(_]H9FC_75I@_R,@)O]&1$?_(1\B
-M_R0B)?]02DC_13\]_T9$1_\5%1[_8F1I_U!/5?],2U'_24A._TE+4/]&2$W_
-M/T%&_T!"1_]-3%+_-30Z_S O-?\M+#+_*RHP_RLJ,/\J*2__*2@N_R<G*O\I
-M*BO_*2HK_RDJ*_\K*2S_*2<J_RHH*_\;&1S_&147__ST]_\G(B3_&1<9_Q87
-M&/^2D)/_'QH>_Q@3%_\8$Q?_%Q(6_Q02%?\5$Q;_&108_T0\./^7D8?_F9B1
-M_\'$Q?^TN;[_K[.U_[:TM__!N;W_96-E_V=J:_]=8&'_,S8W_R0I*?\A)B;_
-M(",D_R,D)?\B("+_'1L>_Q@6&?\6%!?_$ X1_Q,.$O\3#A+_$@T1_R(=(?\_
-M.3W_+"8D_UY72_]K85;_74] _WQD5?]^9%G_+1XB_R@C*?\W,S7_/CLV_V5:
-M3_]A5TG_5TQ%_SPV-/\:%A[_%Q@?_SP_1/\]/$+_'ALA_QP;(?\/#1;_)B(K
-M_RTB)_\E(AW_6EQ3_U-15/\;&"3_&1DB_UE<7?]77%;_6EQ9_QD9'/\9&![_
-M7F)@_V]Q;_]D9&?_&!<>_QP;(?\_03__*2DL_QD5'?\=&2'_/ST__QT:(/\9
-M%1[_%Q8=_S$P-O\;&![_'!H=_VII:/\B'RO_(!TI_U!+3_],1D3_*B(>_R@@
-M'/]/2D7_:&5@_XF%A_]85EG_24=*_Q44&O])3%'_1DE._SP_1/] 0TC_/D%&
-M_T)%2O]%2$W_0$-(_T%$2?\_0$?_.CM"_SP]1/\Y.T#_.SU _ST_0O\O,33_
-M*RPM_RPJ+/\I)RG_*2<I_R@F*/\H)BC_*"8H_QT;'?\6$A3_^/#S_RDD)O\=
-M&1O_&QD;_WQW>_\6$17_&A49_QD4&/\8$Q?_&!,7_Q\:'O\F(27_2T5#_Y"+
-MA?^+B83_'Q\B_V)G;/]26%K_2DY0_S<W.O\K+3#_*"HM_R0F*?\:'!__%148
-M_Q04%_\9%!C_$PT1_Q(0$_\3$13_$0\2_Q$/$O\0#A'_$0\2_Q$/$O\0#A'_
-M$0X4_SXX0/\=%QO_)R,;_TI%.?]>4D/_;%E'_W5@5/\I(27_,BTS_T1 0O]"
-M0#W_55!*_U%,1O]'0D+_.C4Y_Q\;(_\7&!__4UA>_U-26?]/3E3_5U9=_Q@6
-M'_\[.$3_,R\X_UM96_];7%;_6%99_QH7(_\9&!__6UQ=_U]C6_]@8F#_&!<=
-M_QH9'_]?85__8&)?_UY>8?\8%Q[_%Q8<_T5$0_\V-#?_&!0<_QT:(/]K9F;_
-M;6AN_QD5'O\<&R+_;VQR_QT:(/\C(23_5U57_R8@)/\L)"C_4DU-_UM65O^
-M>WO_A8""_T1 0O\T,C3_)"0G_Q\>)/\;&B#_$A$7_R(B)?\H)BG_*RDL_S(P
-M,_\R-#?_-SD\_SD[/O\Z/#__.3M _S@Z/_\V.#W_-3<\_S(T-_\L+C'_*"HM
-M_R<I+/\J*"K_*"8H_R@F*/\H)BC_)R4G_R<E)_\F)";_*"8H_QD5%___]OG_
-M(!@;_QX9&_\9%1?_&108_Q<2%O\<%QO_&108_Q81%?\6$17_%1 4_Q@3%_\7
-M$17_(!L;_Q<4$_\7%!K_'B E_QX@(_\H+"[_&Q\A_Q$1%/\1$13_$! 3_Q 0
-M$_\2$!/_$PX2_QH4&/]P:&S_%Q(6_Q(0$_\1#Q+_$0\2_Q$/$O\0#A'_$0\2
-M_Q .$?\9&1S_3TM3_S<R./\C(!O_/3LS_U=01/]:4$'_7E=+_QH5&_\8%!S_
-M.#8Y_SP[.O\^04+_45-8_U%26?\L+33_'QLC_Q<8'_]A9FS_:&=N_VUL<O]O
-M;G7_%A0=_QL8)/]=6V3_9F9I_V=H:?];6F#_&!8?_QH9(/]C8V;_:&IH_V5F
-M9_\6%1S_%!,:_U976/]?85[_5E99_Q85'/\9&![_0#\^_R<E*/\:%A[_(A\E
-M_V=C8?]A7&#_'!@@_R$@)O]'14?_'AP>_R@F*/]>7%[_>G5P_ZFAG?]W<G3_
-M6UA>_U157/].3E?_1$9._SU#2_\X.T#_.3Q!_R\R-_\I+#'_*RDL_R\J+O\M
-M*"S_+2@L_RLI+/\H*"O_)B8I_R8F*?\F)BG_)24H_R@H*_\G)RK_)R<J_R0D
-M)_\D)"?_)24H_R@F*/\G)2?_)2,E_R4C)?\E(R7_)2,E_R@F*/\B("+_+2DK
-M__SP\_\>%!?_,2DL_RPG*?\<%QO_% \3_Q40%/\4#Q/_%1 4_Q40%/\4#Q/_
-M%Q(6_Q,/&/\7$AC_&!,7_Q@1&?\3#!/_%Q$5_Q40%/\1$13_$A 3_Q(0$_\1
-M#Q+_$0\2_Q 0$_\-#Q+_%1,6_R ;'_\5$Q;_$A 3_Q$/$O\1#Q+_$0\2_Q .
-M$?\1#Q+_$ X1_Q$2$_\8%Q[_&!0<_R$='_\1#Q'_2D9$_U502O\C(B'_$Q$:
-M_Q43'/\M+#+_4U15_TU05?]665[_7EUC_S M,_\<&"#_%Q@?_UYC:?]B86C_
-M8F%G_V-B:?\8%A__%Q0@_UY?9O]@86C_8&%H_U166_\;&B'_&!<>_V5D:O]E
-M9&K_7UYD_QD7(/\<&B/_34U0_S$S,/\G)RK_&QHA_QD8'O]!0#__+2LN_R <
-M)/\G)"K_0#TX_T(^0/\A'B3_'Q\B_V1E7_^"@WW_EI64_V=E:/]565O_55A=
-M_TY05_]*2E/_2$=._T9'3O]%1T[_049,_SY#2/] 14K_/D-(_SU"1_\^0$/_
-M/CY!_S0T-_\O+S+_+"HM_RLI+/\J*"O_*B@K_RLI*_\H)BC_*2<I_R@F*/\I
-M)RK_)B0G_R4C)O\E(R;_)B0F_R0B)/\D(B3_)"(D_R0B)/\D(B3_(B B_R8D
-M)O\2#A#_^_+R_R8;(/\;$AG_%Q,5_Q@3%_\5$!3_%1 4_Q40%/\5$!3_%1 4
-M_Q0/$_\7$A;_%Q,5_Q<3%?\5$!3_&!$;_S0J.?\:$QO_%1 4_Q0/%?\1#Q+_
-M$A 3_Q$/$O\/#1#_#0T0_Q 0$_\?'"+_&Q<?_Q81%?\5$1/_$P\1_Q00$O\2
-M#1'_$PX2_Q(-$?\3#A+_$1 7_Q<3&_\8$AK_&1$5_QD4%O\M*"C_14$__STZ
-M.?\6$AK_&!0=_RDF+/]245#_35%/_U%34/]24TW_)R0C_R <)?\='"+_6UU;
-M_V-B8?]=6UC_9V-E_QD5'O\:&"'_6EIC_V)C:O]H:7#_1450_Q46'?\:'"'_
-M7U]H_V1D;_]B8FW_$A(=_QL;)/]A8FG_7F!H_V%?:/\?&R/_'!XC_SY /O\Z
-M.#K_'AP?_R@E*_]:55#_8%M6_W9R</]D86#_5EA;_U=97/]:7&'_45-8_TQ1
-M5_]*3E;_14E1_TA*4?]%1T[_149-_T-%3/]%1T[_0D5*_SP_1/\]0$7_041)
-M_SU 1?\^0$?_/#Y%_SP^1?\X.C__.CD__RPK,?\I*"[_+BPN_RHH*O\J*"K_
-M)R4G_RDG*?\E(R7_*"8H_R4C)?\F(B3_)R,E_R(>(/\E(2/_)B$E_R,>(O\W
-M,C;_)!\C_Q81%?_Z\?'_(!<>_QL4'/\;%AK_&!,7_Q40%/\5$!3_%1 4_Q40
-M%/\5$!3_% \3_Q<2%O\7$Q7_%Q(6_Q,.$O\8$QG_'!4?_Q@3%_\5$A'_%! 2
-M_Q$/$O\2$!/_$Q$4_Q,1%/\3$13_%!(5_Q82&O\<&"'_&Q8:_QP8&O\?&QW_
-M&Q<9_Q<2%O\5$!3_%1 4_Q0/$_\3#Q?_%Q,;_QX9'_\?&1W_'1D;_R,@'_\G
-M)"/_(1X=_Q82&O\8%!S_(!XA_TM+2/]-3TS_3E)*_TY/2/\<&!K_'A<A_QL8
-M'O]65E/_6EI7_UQ95/]955?_&!0=_QH9(/]@7V7_75Y?_V%B8_\]/$/_%A<>
-M_QL=(O]A8FG_8F)K_V%A;/\7%R#_(B,J_TY05?]355K_5U)8_R<?(_\E)"/_
-M6UM8_UU>6/]K:FG_E9.5_X2 @O]95E7_6%A;_U-56O]04EG_3E!7_TM-5/])
-M2U+_2TU4_T=)4/]"1$O_1$9-_T1&3?]#14S_04-*_T%#2O\^04;_0$-(_T!#
-M2/]!1$G_/#Y%_ST_1O\]/T;_/D!'_ST_1/\\/D/_/3]$_S@Z/_\R,#/_*B@J
-M_RLI*_\H)BC_*"8H_RDG*?\G)2?_)"(D_R<C)?\H)";_*24G_RDE)_\E("3_
-M&!,7_Q<2%O\8$Q?_% \3___U^O\O)2[_1SY+_R$<(O\:%1G_%A$5_Q40%/\8
-M$Q?_%A$5_Q81%?\5$!3_&!,7_Q<1&?\7$AC_#0@,_W9R=/])1$K_&147_QH8
-M$_\8%13_$A 3_Q43%O\5$Q;_$Q$4_Q,1%/\-"P[_&14=_QT9(O\=&!S_&!06
-M_Q,/$?\4$!+_%Q(6_Q81%?\9%!C_'!<;_Q00&/\7$QO_'ALA_QT;'O\A'R'_
-M,2\Q_S\]/_],2DS_%Q,;_QD5'?\E(R;_45%._U%34?]/4DS_4E)/_QT8'/\C
-M'";_&A<=_UE95O]555+_5E-._UA45O\;%R#_&1@?_UA75O]96E3_6%E2_R4C
-M)?\<&R'_&QH@_UQ;8?]=7&+_86!F_Q<6'/\D)"?_5UA9_U!03?]744__7E94
-M_U924/]Z?7?_8&-=_U=95_]65UC_3%%6_TM/5_]*4%K_1TI6_TY06/]*3%/_
-M1TE0_T=)4/]%1T[_1DA/_T=)4/]$1DW_/D!'_T!"2?\[/43_0T5,_T!#2/]!
-M1$G_2DU2_SY!1O\_04C_/T%(_SY 1_]"1$O_/D!%_SY 1?\_04;_/D!%_SHZ
-M/?\R,C7_+2TP_R<G*O\K*2O_*"8H_RHH*O\C(2/_)2$C_RDE)_\B'B#_+BHL
-M_QD4&/\4#Q/_&!,7_Q,.$O\8$Q?_^>[U_SXT/O\F'"O_'QDA_QD4&/\6$17_
-M%1 4_Q<2%O\:%1G_&!,7_Q40%/\8$Q?_%Q03_Q<3%?\:%1O_'1<?_QL4'O\L
-M)RW_(1T?_QP7&_\5$Q;_'AP?_QT;'O\<&AW_03]"_TE'2O\:%A[_'AHC_QT8
-M'/\8%!;_'!@:_Q\;'?\@&Q__(ATA_R0?(_\H(R?_&1,;_Q@4'/\='R3_2T]1
-M_TU/4O]04%/_45%4_U145_\7$QO_&14=_R\M,/]I:6;_5597_U%34?]14$__
-M'!<=_R,<*/\8%1O_6%A5_UA85?];6%/_5%!2_QL7(/\;&B'_6%98_UM:4_];
-M653_)2(A_R$=)?\<&1__7UU@_T=%1_\M*RW_(B B_R@G)O]24TW_>7YX_Y&1
-MCO]O:FS_5U=:_U)45_]14U;_4%)7_TY/5O])4%;_2$]5_T1(4/]%1E'_1DA0
-M_T=)4/]&2$__1$9-_T%#2O]$1DW_04-*_T!"2?] 0DG_04-*_T1&3?]!0TK_
-M/D%&_T)%2O]!1$G_1$=,_T%#2O]!0TK_/3]&_T!"2?] 0D?_/D!%_S]!1O\^
-M0$7_.3M _ST_1/\\/D/_.CQ!_ST[/O\W-3?_,C R_S N,/\M*2O_)B(D_Q82
-M%/\7$Q7_%1 4_Q(-$?\7$A;_%1 4_Q81%?__^?C_(1,4_RD;(_\;%!S_&Q8<
-M_Q<2%O\<%QG_(AH=_QX7%_\=%1C_%Q(4_QD4&/\6%!;_%Q47_Q,0%O\7$QS_
-M&A,?_QT7&_\A&AK_%1,5_QP9&/\Z-S;_/#H]_T5$2O])24S_3T]2_QT9(?\C
-M'";_(APD_TE&3/]'1$K_1$)%_SDW.O]$0D7_3DQ/_U%/4O\9$AS_&Q0>_RDE
-M+?]45EO_55=<_U577/]<7F/_7%YC_Q41&?\:%A[_(B$H_UE87O]56%W_6%Q>
-M_UE;7O\8%1O_(!PD_Q<6'/]14U'_7%I5_U=63_]345/_&A8?_QX:(O](1DC_
-M/3XX_TE*1/\I)RK_(AXF_R0C*?]:6US_6UE6_UY85O^!?'S_@7Y]_UY?8/]0
-M5%;_5%=<_U-56O]25%O_3E!7_TM-5/]&2$__0T5,_T1)3_](25#_2$=._T9'
-M3O]*3U7_24I1_TA'3O]#14S_24M2_TA)4/]&1T[_0T1+_T)$3/] 0DK_0T5,
-M_T9)3O]%2$W_1$=,_T!#2/]$1TS_04-(_T-"2/\_/D3_0T)(_T%#2/\Y/$'_
-M.T!%_T _1?\^0$7_.CQ!_SH\0?\Z/$'_.SL^_S\]0/\5$Q;_)2,F_Q<5&/\T
->,C7_%Q48_R<E*/\4$A7_$A 3_Q02%?\3$13_%1,6
-
-end
diff --git a/Lib/test/testrgb.uue b/Lib/test/testrgb.uue
deleted file mode 100644
index a588eb90d89..00000000000
--- a/Lib/test/testrgb.uue
+++ /dev/null
@@ -1,971 +0,0 @@
-begin 644 test.rgb
-M =H! 0 # 'T :0 # /\ 3FEE=7=E(%-P:65G96QS=')A870
-M
-M
-M
-M
-M
-M
-M
-M
-M
-M
-M O8 -6@ #MT !!@ 1W0 $UH !36
-M 65@ %]D !E9 :W '%\ !W? ?8@ (.4 ")H CZ@ )6L
-M ";J H; *>\ "MR L]0 +G@ "_Z Q?0 ,P #2# V!@
-M-XD #D+ ZC@ /! #V3 _%@ 0)D $(< !#GP 12( $:E !(
-M* 2:L $LN !,L0 3C, $^V !1.0 4KP %0_ !5P@ 5T4 %C(
-M !:2P 6\X %U1 !>U 8%< &': !C70 9. &9C !GY@ :6D
-M &KL !L;P ;?( &]U !P^ <GL '/^ !U@0 =P0 'B' !Z"@
-M>XT 'T0 !^DP @!8 (&9 "#' A)D (8< "'GP B2( (JC ",
-M) C:< (\J "0K0 DC ).S "5-@ EK4 )@U "9LP FS( )RS
-M ">- G[, *$N "BIP I"@ *6E "G)@ J*( Q8 -VP #UX
-M !#? 27 $]@ !56 6UP &%D !G: ;70 '. !Y@ ?XP
-M(68 "+H D:P )>H "=J H[0 *G "OS M=@ +O@ #![ Q
-M_@ ,X$ #4$ VAP . D #F, [#P /)$ #X4 _EP 01H $*=
-M !$( 1:, $<F !(J0 2BP $NO !-,0 3K0 % W !1N@ 4ST
-M %3 !60P 5\8 %E) !:S 7$\ %W2 !?50 8-@ &); !CW@
-M96$ &;D !H9P :>H &MM !L\ ;G, &_V !Q>0 <OP '1_ !V
-M @ =X4 'D( !ZBP ? X 'V1 !_% @)< ((: "#FP A1H (:=
-M "(( B:, (LD ",I0 CB@ (^K "1+@ DK$ )0T "5MP ES8
-M )BV ":- F[, )TT ">LP H#0 *&L "C* I*< *8F "GI
-MJ2$ S9 .7 #]\ !%> 2VP %%< !76 76 &-D !I; ;
-MW@ '5\ ![A @9 (>< "-I D[ )FD "?K I;@ *O$ "QT
-M M]P +WD ##\ R?P - ( #6% W" .(H #H- [D /1(
-M #Z5 ! & 09L $,> !$H0 1B0 $>G !)*@ 2JT $PP !-L@
-M3S4 %"X !2.P 4[X %5! !6Q 6$< %G* !;30 7- %Y3 !?
-MU@ 85D &+< !D7P 9>( &=E !HZ :FL &ON !M<0 ;O0 '!W
-M !Q^@ <WT '4 !V@P > 8 'F) ![# ?(\ 'X2 !_E0 @1@
-M (*; "$&@ A9L (<> "(H0 BB0 (NC "-)@ CJD ) L "1KP
-MDS( )2U "6. E[< )DW ":M0 G#0 )VU "?- H+4 *(K "C
-MJ0 I28 *:G "H(P J:( " @0 ($ !_ ?P 'X "
-M @0 ( "! @0 ($ "! @0 ($ " @0 '\
-M " @0 ($ "! @0 ( "! @0 ($ "! @0
-M ( "! @0 ($ "! @0 ($ "! @0 ($ "!
-M@0 ($ "! @ ($ "! @0 ($ "! @0 ($ "!
-M @0 ($ "! @0 ($ "! @0 ($ "! @0 ($
-M "! @0 ($ "! @0 ($ "! @0 ($ "! @0
-M ($ "! @0 ($ "! ?P ($ "! @0 ($ "!
-M@0 ($ "! @0 ($ "! @0 ($ "! @0 ($ "!
-M ?P ($ !^ @0 '\ "! ?@ '\ "! @0 ($
-M !_ ?P '\ " @0 ( "! @0 '\ "! @0
-M ($ "! @0 '\ "! @0 ($ "! @0 ($ "!
-M@0 ($ "! @0 ($ "! @0 ($ "! @0 ($ "!
-M @0 ($ "! @0 ($ "! @0 ($ "! @0 ($
-M "! @0 ($ "! @0 ($ "! @0 ($ "! @0
-M ($ "! @0 ($ "! @0 ($ "! @0 ($ "!
-M@0 ($ "! @0 ($ "! @0 ($ "! ?P ($ "!
-M @0 ($ !_ @0 ($ "! @0 ($ "! @0 ($
-M "! @0 ($ "! @0 ($ !_ @0 '\ "! ?P
-M ($ "! @0 ($ !_ ?P '\ " @0 ( "!
-M@0 ( "! @0 ($ "! ?P ($ "! @0 ($ "!
-M @0 ($ "! @0 ($ "! @0 ($ "! @ ($
-M "! @0 ($ "! @0 ($ "! @0 ($ "! @0
-M ($ "! @0 ($ "! @0 ($ "! @0 ($ "!
-M@0 ($ "! @0 ($ "! @0 ($ "! @0 ($ "!
-M @0 ($ "! @0 ($ "! @0 ($ "! @0 ($
-M "! ?P ($ "! @0 '\ "! @0 ($ "! @0
-M ($ "! ?0 'X !\ ?0 '\ !_ ?P 'D !\
-M?P '\ !_ ?P ('J^!0C'!P6&1T7&!08%A<6'!\;&A48-CU*3%(A
-M)B1,2D4Z14]2'!XM6UQ<8V,9'BA>75Y>&R0<455/4Q\B2#A$*B8I7%96?'U@
-M5EQ:6U=43TQ/4$Y.55%.3%)03DM,2DQ.34Q(3$A(1$A(00-% T&+/D 6)A@U
-M&"@5$Q4!% $6 .WY$QL4%A(7&A<5$A04%1 3$Q<:$QDW.D1)3QD<'$9$0C="
-M3$\2%"565U=>7A$6(5A87%L5'!936E91%AI&/DHG'B-;65A\?E]45U544$U(
-M14E)1T=/2D=%2TE'1$1"14E(1T-'0T(^0D,\0#] SR+.ST3(Q4R%242$!(!
-M$0$3 .W_(2D;&Q<<(AX=%QD6%Q,7&ATA%1PZ/$5)3QTC(DE'1#E$3E$9&RE4
-M555<7!4:(EE56%D8(!=17%=3&AY(/4DI(B1:6UZ!@5Y05%-23DM&0T1(2$9*
-M24A#24A&0T) 0T9%1$!$04,_0T$Y.T ^ SJ+.S\5)1<T%R<4$A0!$P$5 /OU
-M/BLA&!44%AD7%!<3%1L?'BT?&Q8?'AU"2AXC'!8:'1\A(R<;'"114E-45QL=
-M,&9744\=*!M555-2("%84U0A)1]@1RTB)DUXCFQ:5U975E954%%04$]-2DU*
-M24E*34I&2DE,2DI&24=%1D5 1$-!/C<R,"LD%!44$18!% $5 +;N-!P9%!$0
-M$A43$!,4$Q47%"<=%Q,<&QH_1Q8:&!08&QL='R,3%!]/3U!15!,5+6E64U 7
-M'!4#6,)0%QI66EDB'1E=12L@)U-^D6I75%-23U!/2$9(24A&0T9#0D)#1D-!
-M141'0T,_0D) 04 [/SX\.S4P+BDB$A,0#1(!$ $1 /OY/B8?&185%QH8%1@7
-M%QH=&RPA'!4>'1Q!21H>'1@<'R B)"@9&!U+35!15!<9+VE545$<(QA86%M4
-M&QM86ULE(1Q?1RTB*%)YD6]74E%03DE(1$5&1T9$041!0$!!1$$^0D%$04$]
-M0$ ^/SXY/3PZ/3<R,"TF%A<5$A<!%0$6 /OZ+DLB&144%Q45%!<9& QT2A<3
-M%!,6%A04#ATB'!81$A85&!L8&R$>(3$_3!L=)DY13$\<)AU64DY6(!]65%(E
-M(2!A8F8<)UE-3U10=UU76%976E984U!03D]034=)1$Q(25)&2$A'2T5%1D4]
-M-3 J*R@J(R,G("P8$Q<!$@$7 ./U)3X<%1$0$Q$1$!,1$@AR1!48%1 3$Q$1
-M"Q49&!0/$!(1%!<0$QL;'R\]2A,5(U%34E(8'!=955-4%QA76EDC&QI;7& 6
-M)%A04592?6-95U%/4$I03$E)1TA)1D!"/45#1$T#095 1$! 04 Z,BTG*28H
-M(2$E'BH4#Q,!#@$3 /O_+T<A&A85&!86%1@7%PUV21D:&!(5%1,3#1D='1@3
-M%!<6&1P4%QX=(3$_3!<9)5%13U(=(QI95598&QE865@E'!M<76$7)%=05UY6
-M>F!75DQ+2D=.2D='149'1#Y .T- 04H^/S\^0CX^/SXZ,BTG*R@J(R4I(BX9
-M%!@!$P$8 (7Q'AP:%P44C!,6%182&1\7$1(2$P,4XA4:(1H:'1D6%!03%QL?
-M'1L?(QT:'"%(3$I(&B$>4U=45QT@95]C0QXB:6ML("I56E@C(UA8:96"55M:
-M65=44E102TU-3$I*1DA(245&1D=$0T0_,RHK*"@I)R0E)B<G)!<6 1<!$P"%
-M\1<4%A,%$(P/$A,2#A,5$Q(0#Q #$8T2$A@6&!L7$A 0#P\3 QG2("0>$A0>
-M2T]23Q@7&%9:6544&5]>8CP7'6)B81<C4%52'R1;7FJ3@%9855)034M-241&
-M1D5#0T%#0T0^/S] /SX_.C H*28F)R4B(R0E)2 3$@$3 0\ A?H@&QL8!16!
-M% ,7B!,8'!@5%!$2 Q/B%!8<&QP?&Q<5%103%QX?'2,G(188($M-3DX<'AM6
-M6EQ9&!I@76$]%AMA8F$7(DY35R<E6UUKE8196%-03DM)2T="1$1#04$^0$!!
-M/#T]/CT\/3@R*BLH*"DG)"<H*2DE&!<!& $4 (7R(!D5%P44\1,6%144&SD;
-M%!42$Q(0$!,B'Q43$1(1$A$2%QL:%18H/SD:'2Q03U!-(R4B6V%891XA8VIP
-M4!TA:&]M'21I:&@C(SXZ'RM05G!@6UQA6%=645%.34Q.2D1%245'144_/S$N
-M+BHJ)RDE*"4D)2 C)2(V 2,!%0"%\AL2$Q,%$/$/$A,3$!$J$Q /#Q /#0T0
-M'!<1$0\0#0X-#A 3$A$4*$$Z$A0F45%34R0<'%UB6V,5&%IC:446'%]D8A(;
-M8F!?&QY .!PE55MR85A97%-13DE*1T9%1T4_0$1 0#X^.CDK*"PH*"4G(R8C
-M(B,>(2$>,@$? 1$ A?LF&Q<8!16!% ,7[148-!H5%!$2$0\-$!\;%A43%!(3
-M$A,1%Q@9&2U%/188*5)-45(G(!U;8UUG&1I:8FA%%1I?9&(2&V%>81\</CH>
-M*%I@=F165UI13$I%2$5%0T5"/#U!/3X\/#@Z+"DN*BHG*24H)28G(B4F(S<!
-M) $6 )[S%RPI&Q,4$Q04$Q88&!<9$Q44%!,3$A(3$A8?%A,#$KL1$A$3'AP?
-M$41*(1H<,E557F,S(!]I:&=I'R!F:&A;(1YJ:F0@(U P*B$>/RXD*CA )")?
-M?91H6UU74P-.BTQ(2DA'0T$W,BTL RN%*"DH*B<#)@4D@2(!)@$0 )[P%"DG
-M%P\0#Q 0#Q(/$A,1#!$0$1 0#P\0#Q,;$Q ##[L.#PX2%Q0=#T90(A$3+%10
-M65TM&!AC86%B%A1?86%6&A=D9%X7&DTS)QH80"L<)#T^'A]E@Y5E65A02@-'
-MED9#14-"0#XT+RHI*"@I)B<F)R0C(R0%(H$@ 20!#@">_!XQ+!P4%105%107
-M$Q<8&!,7%1$2$A$1$ T5(!42 Q'4$!$0$1@8(1%*52,3%2U3359>,!P77F)B
-M8Q@77F!@5!L8965?&1Q-,2<;&4$M("= 0B$?9(*69U553DI(1D5!/D ^/3X^
-M-"\L*RHJ*R@I*"DF)24F!22!(@$F 1( EOD;&Q<8%AL8%144%Q4;$QHE(RXA
-M%!0#$X42&&P6$P,2Q1$2$1Q3.!LS1$%+&QPY.D)8630C'VQN<G4=)&1I:6 ?
-M(&9H9QP:6%Y9'!X^*!XE86 @)D<>*%YPG71>7%=.2T!!-S$L+@,L@2L#*8DH
-M*RHJ)R<H*"<$)8$H 2(!*P"6]A@9%102%Q01$1 3$1L4%" @+!\1$0,0A0X4
-M:!(0 P_)#@\.&4LR(#M04%<5%#8[05-2+1L89F=L;A086V9H6A898VIF%1-7
-M8585&#\E%A]C7!@@11PF7'6A<EA53D9#.SPR+"DJ*"@I* ,FB24H)R<D)"4F
-M)00C@28!( $I )[_(!X9&1<<&186%1@7(!<7'AXH&Q$1$! 2$QIP%Q(#$<D0
-M$1 93S<C/5=:7AH8.#P^45$L'Q=A:&UO%AM=9F=;&!IC:&46%%9?5A890"<:
-M(F=A'"%''BA>>JEW6U1.1#TX.2\I*R\M+2LH R:))2@G)R0D)2@G!"6!* $B
-M 2T ]?,F&QM[%1D8%Q<>)4.%A")L6E Z,"TI'Q@7&!$3%!(2$1(2$11 &QLY
-M0T=4)3-"/4I&0CDC'UY95%T?1#A;5EDC'UU;8!T?7U]A'AQ#-QP@9FX>(G(@
-M)%<D*$U6>X)"-"<D(!<E*2PS-SP^/T _/3PW,2TL*@,H@R<G)@$H 1< ]? D
-M&1EW$144$Q,:(46+B1]G6$XW+2HF'!44% T0$0\/#@\/#@XX%R-%4EE@(2U
-M0%!,0C4;&%A23E86."]97%87&%QC8A<986)>%Q9$-!0:9F@5&VP:(54@)$U6
-M>X! ,B0>&A$B)BDP-#D[/#LZ.#<T+BHI* ,F@R4E) $F 14 ]?@I'1M\%AH9
-M&!@?)DN0BQ]B4DHW*R@D&A44&1,2$Q$1$!$1$!$^'2=*7FQU*3)$0E511SH?
-M%U-33U<8.S-;6U@:&5M?8!@:7V!>&!=%-A@=:VT9'&\=(U<F+%);@(5$-"0?
-M&Q(B*"LR,C<Y.CDX-C4R+"@G*@,H@R<G)@$H 1D ^/<D&1B3'A<7%A46&#B'
-MD<6^M;>]96MA-RDF)"4B'AD7$1(2$2$])$M60%59(BDU-D])130>'T1"(2$6
-M*R<=4U0D(EU661P>8&]G'B$_+!TA/R >'38>'6@K*4]$'AQ%8(=92AI13D1(
-M1DI-2$E'0D1 0$(T+2PI*0,H 1T!% "@]"(7%Y :$Q,2$A,4/)&8Q+FSM+EC
-M:F V*28C)" ;%A0##I@-'3DF5V%/9&0>(S,[6E=,-A88/SP;&PT#(H1<41@9
-M URS&1AB<607&T$I%1D]&A46,!@::1\=2T8B($IEA59'%$Q)/T-!14A#1$ [
-M/3L]/S$L*B<G R8!&P$2 /C\)QD6DA\8&!<4%1E$EYG!M*^VP65G73,D(2 C
-M(AT8%A 3$Q(B/RQ>:UU\?BTH-SYE85<\&A<\/1X<#R8M)5I3&QE95UH9&5YO
-M9!@</RD9'3\=&1<Q&QQJ(B!03"HH3VB)6$D5248\0#Y"14!!/SH\.3L]+RLL
-M*2D#* $= 18 ]? Z+2J;%Q<8&A4>&1F/CMK5T\K 5T)_7E _,"LU,RLF&!(0
-M%AD\2%5C5DY-3U\P/5),140G&U(<%1P>'2$J3$LG(6UL9B F3#TS'QL]$AT?
-M'4P;&TP;)F8Q(VA@)D<B)4@]1QYI55%.4$U&1U(Z-3(P,"\N*@,K@RPJ*P$<
-M 1< PO(Z*R>8$Q,4&!,=%AN5E-G3T,B_5D*!7U-",RX[-BTC&1,,$!E#4V-R
-M95Q;3E<K0EM94$8?&%4=%187&2XX4T4;&0-GL!H;1#HL%A5!#Q$6&4<5%DX8
-M(&0H&V9:($0?(DH_1!5D3TM(2TA!0DPT+RPJ*BDH)P,J@RDG* $9 14 ]?8_
-M+2>:&!@9'!4:&!^:F=;/T,W+8D=_8E-",RXX-"LC'!81%2!%5FV <VYO75LH
-M16=F6THC&E4>&AD8'TA*4D8@%UYB:!T;0C@M&!8\#108$448%$P:(V8L'VA=
-M(T8A)%!%1A5B4$Q)248_0$TU,"TK*RHI)P,I@RLI*@$; 1D ^_(\(8Y0%Q@6
-M'Q@A%AV+E<W*Q<2_DQ$;&1,4&1$@+ST_+RL?$1L[-D1>-R8U2Q\H1U=+4551
-M2F,3%!T9'RPF6&PA)E]GAQ<<@WYF'QE'$AX>)%L6)UL8+F<Y(V=D%E@?)&8A
-M'U4>7WU83TU224=)141%0$5$0$)!0D$_-@$C 1@ ^_4^'XI-%!43&Q0@&!^1
-MF\_+R<K'D@\:%Q,4&1$F-4-%,BX@#QM"05)K1#-"2QDE36)87EQ-2V@1$A<3
-M'CTX7VH7'UMEB!$3@(%C%A-,$Q47(%80(EH2)V0P&V5>$%4<(6,;%DH<7WU8
-M3$I/1D)$0#] .T _/3\^/SX\,P$@ 18 ^_,\(8]/%A<5(QD=%AN0HM76U=/-
-MGA09&Q@9'A8E,D!",BXA$2!$1%QZ4T)36AXC4FUE:V523FH5%AH6*EA-:&X>
-M(%-AB107@G]C&!1.%AD8&%03(%D3*&0T'V=A$U<>(V4<%D<@9()=3DI/1D!"
-M/CT^.3X]/3\^/SX\,P$@ 1H ]?<G&!PP&QD7)!L9(2"-D,G)Q\2]F!8<%QH8
-M&A43'QHA&#TD%1A 2%%</BT\4Q889%%32EM+8%$0%!@<,2P=?7\D+&J BQH<
-M=6AA(!P[1QT<)D <&TP7)5<](V%;%ED?($ =%QD8$"A(4G1<6%)/3DI'0T [
-M-0,S@S P,P$P 2 ]?HH%ADM&!84'188)A^.F,[+R\K%EQ(9$Q@6&!,2'ATG
-M($,G%QI'4U]F2#A'4Q(:;%M@6F909U@.$!(:-CXPAG\=)FA_BA06=W%D&19
-M2147(CL6%DD0'%(Q&U]5$%8<'3H7$1,4#"1$4'):5DU*245"/CLV, 4M@3 !
-M+0$> /3\*Q@;+1@6%!X4%2D>CY[3T]73RZ,8&1@<&AP7$1T;)!Q )14>259I
-M>%A%4F(:&')E;6IS56E:$Q45'T5;2I:&)"EB?(D7&WMO8AH714\;%1HY&11'
-M#QQ0-A]A6!-8'A\[&!06&1(J2E)T7%A+1T9"/SLX,P0N@RLK+@$K 2 ^_4J
-M''^5&B!G<AHH$"J+C,;0S,Z\G1X>&!<5&!(3(1H>)SLL+"DV1U!&-B](31(3
-M8UAA7&I65&89%A,9.2TE=84K95943@PD/TTE(QU 3AP<-%T>&TD;*$LT(DY2
-M%UD?%Q 8%1H<%Q\A'2$@4W1;4U!-24A)2$E(2$1#0 $\ 14 ^_0G&7Z4%QUE
-M;!4G%"B+E,W1S-# FA<8$A84%Q$-&QD@+4$P,"L\45Y00#I34A 0:6)N:W=<
-M7&P6$! 904,W?8<D7U13308A058H'1=&4!86,%@8%D86'48K'$Q,$58<% P6
-M$QH6#Q<9&AX=4'%944Y(1$-$04)!03]!/@$Z 1, ^_\O&7N3%QUI;1(F'"R0
-MF,[4T=;*IAX;%143%A .'!@>*#PK*R]!5VAB4$5=7Q40;FQ[>81C8'$>%1(@
-M5&%4D(\K8%!03 <C15(F'AA-6!L7*%8;%$04'40M'TY/%%@>%A$:&"$;$QL=
-M'" ?4F]534I#/SX_0$-"0CT].@$V 14 ^_4U*6J0'2R4>QL?'1^0CL7/S\;'
-ME!<;%1<8&A,3&QP<)CPO*"TD/4EJ.#$[5A4M/5AC9W!>5V@T'QLB'BP>JE\O
-M:6UA7#]#-%46$"$TB",F.V49($PC("<B'4E+%U0B$Q47$QH<&!DA'1<>'B4E
-M1W5B55%*2$5#0C8V.0$T 1H ^_(O(VJ2&2B5?Q<9&QZ0E<K/S\K,E!49$Q46
-M&!$1&1H:+#XO+#0J15-S03M%8QDK1&5P<GMH8G R&1DH*$(OKV$M9VQ?6CU!
-M,E,3#1XYB!L@-F 3&TL=&"0?&D9($4X<#1$3#Q86$A,;%Q$8&",C17-?4$Q%
-M0T ^/3,S-@$Q 1< ^_HT)&^6'BV@BQT:'1V5GL_6V-38G1H=%1<8&A,3&QP<
-M)SDJ)C4O2UM_345-<"$O3W)]?89P97(V'!LM.F)(OFDQ8V%95#<[+$\1#2 \
-MC2$C,5X6&4H@'"8A'$A*%%$?$!88%!L9%18>&A0;&R4E1W5?3DI#03X\.S$Q
-M- $O 1D ^_-(,!IE(R4=&18?&BZ(CL7+SL[%ER$;%A<9&A,2&AP:)CHO)RXC
-M-#D]$AP9)#A-65%;8&AG6& P(2(B&!H5PXH87&=<86M?/T\6$A<O1R(;/F-<
-M-U(5)!@7'!<A&"<7(1D9%1,:&1L8&1<9'!@D&2<W4V5*3TE&0T=$0 %# 3P
-M^_!"*AIG'R(@'A,9%RR(E<K+SM+*EQ\9%!47&!$0&!H8+#PO*S$F.3\_$AP9
-M*CQ-7UIF;7=Q8VLS'B D'BLAQHP:7VQ@96]C0T\3#Q0T1QH5.5Y6,E$/'!44
-M&10>$B$1&Q45$0\4$Q42$Q$3%A <$1\V56=,3$9#0$1!/0% 3D ^_A'*Q]O
-M)" @(14:'RZ-GL_2U]S6H"0=%A<9&A,2&AP:)S<J)2\H/$1'&R,>,T12:&9Q
-M>H5Y9FPU("(H+48XU)0>76%:7VE=/4H1#Q8W3" 8-%Q9,% 2(!<6&Q8@%204
-M'AH:%A07%A@5%A06&10@%2,U4V5*2D1!/D(_.P$^ 3D KO8H)HEM*1FUL1L=
-M%Q6-CL#/U,[!EQP5%189'!,3&AL;(S@S*"\D0#M534 Q+B4$&<D?;%Q:83P<
-M&2\;)QV\=1DL.DPK8W\3N" 9'2&X8AX\/R(O0AHK% TS%Q,B&Q84%Q@5%!4=
-M%A4<%!T6&AL9&B M+E-+24A'1$-& 4<!10#[\R(@B6\E%K>U%Q<5$XV5Q<_4
-MTL:7&A,3%!<:$1$8&1DI.C,L-2E&0UE1138L(A86%QLE=EM<9CT:%S(<,R6]
-M>1DJ.DLJ8GX2M1T6&B:X6A@W.APJ010C$0HP%! <%1 .$Q01$ \7$ \6#A<0
-M$A,1$ATJ*U!*2$=&04!# 40!0@#[^R<ACG4J&+V]'!@9%9*>RM;=W-*@'Q<5
-M%AD<$Q,:&QLD-2XF-"Q+26-92CDP)!@8&Q\L@&=B:4 >&30G2CG*@R L,T@I
-M87T1LQL6'"F]8!LR.!\H0!<G$PPR%A(?&!,1&!D6%1(:$Q(9$1H3%A<5%A\L
-M+5))141#/SY! 4(!0 #[^R4=&S0?(1\4'AH50H.-O<_4S<&7&104$!4=$Q<9
-M,!HF-3@F,!QG5'%<7&!C75M33%!376$_&BP9%2(<'Q94<2 J+",I'&TEH1P=
-M'AG ;28?'A4=+1XD%!<V#A<T/!X?%AD5%!D:%QD4%!D8&1P:&147/"XL=%).
-M2DE( 4D!2P#[^!\6'#8;'1\7&A4408:5PL_4T<67%Q(2#A,;$147+A@J-S@J
-M."1L7'5C:&IJ9F9<3DY89%XZ&BH5$R,:)1E2<QTD*B F%F<?GAD:&Q[!9R :
-M&0\7+!L<$10S"Q0N-!87$A41$!,4$1,.#A,2$QD7%PT/-"@I=E1-2$9% 48!
-M2 #[_R(5'SP@(RXG(A,10(B;Q];=V]&>'!84$!4=$Q<9,!HE,C,D/"AO8G]L
-M;7!U<G-J4E)=;6I%'RX;%R0?-"=7>R4E)B H&6@@G!<:'2/$:",7%Q(8*QT@
-M$Q8U#18Q.!H;%QH6%187%!81$185%AL9&1$3."LG<E)*1$1# D8 X?,I*4 Y
-M,QJ.D"D>'"6'C+W,R<[!FR,4%A07%A45&",;)CPR)S@M8&I33EU,/D!/:F9O
-M<V]>E4]$'1HH4S)NM24@0$M32TZW(+,>(QP<LU<<%1,1%R 6%A44$A03.S<B
-M'Q4#&(40(1@1&P,5C1D8%Q4<%U(;<&%Z4E(#2P%( .'R)2(^.R\4BY(E&1HF
-MCI7"SLK/PITD$A(1%103$Q8A&2@^-"D[(T9/.CI//"PR1&)G9WEZ9)=-1QL8
-M)4HM8J@E(#]-5DQ-M!NO'"(:'[53%0\0#A0=$Q,2$0\1$#,N&18/ Q6%#1X5
-M#A@%$HT4%!4.3QQO9(!34$E( 4@!10#A_RH@0D,U%Y.:*A<<*8^5Q-;5VLVA
-M)Q87$Q<6%148(QLD.2\D.QLV0S4P/2PG*SI>:&Z A'.?3TD?'",^%D^.'"4\
-M2%9-3+(8M!X?'B&Y6!82$A 6'Q45%!,1$Q(W,AT:$@,7A0\@%Q : Q2/$Q,4
-M$Q0041]N9H543$5( 4H!1P#J[#0K12LT'519)B(F,H>/O<_+SKFD2Q,5%!<6
-M%146'AHD.S,F-RDR-S)J=GV!GHR,D(U>@F(P045E9H9QQ."RA'M!("]&>L(C
-MOAP>'!*FAA44%141%104$A,6%!4A%Q44$AL:&1,>%1L5%008C1H>&1@R&IR#
-M5UU>7$@!3P%3 );P-"I'+3 745LB'20SCIC"T<S/NJ9, Q'1%103$Q0<&"8]
-M-2@Y'Q<3$SPY2U!L6EMH9E2-:S) 2&YN@UVOQZ*$>S\C,TAZP!^[&AT:&*F
-M#Q$2$@X2$1$/$!,1$AL/#0P/&!<6$!L2& \/ Q*.$Q49$A(P'9R$7%U<6D8!
-M30%0 /O_.RE--38:66,G&R8VCYC$V=?:Q:I/%183%Q85%18>&B(X,",U%PL,
-M""L>*2<^+#)%3DR7=S@_2&IJ=3M]H'AUA$,;+4-UN!6]'!H>%;>;%!$4%! 4
-M$Q,1$A43%!X3$1 1&AD8$AT4&A(2%143$1,7$1,R'Z&/:&9@7DH!40%2 -/T
-M*24=)$HF(2 <'QQR>X^USM+-N:1#%!88&A<8%Q<;'2$T-B Q'R(?*%557'>-
-M@F]Y;XF!5S\R*UIZ;9.VV[FK+#98?6HMIFC#$Q0<&JE\%1<5%0,4I1,3%!,4
-M&TH6$1,3(2,D&$45$1@6'BLT.5!D&QT@0:JH:F6"9V4!5P%" -/T)R >)D8@
-M'B(8&AIS@IBZT-/.NJ9$$A(5&!46%149&R,V."(V(AP3$3<Q-E1J6D552(.0
-M8$$Q+V-_9GR>P:6F+#5:@&LLI&/ $1,:(:]\$102$@,1I1 0$1 1&$<3#A 0
-M'B A%4(2#A .%B,N,TA:#A$8/:BJ;V6"9V4!5P$^ -/_+!XA+DPC)BH=&!QV
-M@YB\V-[9Q:I'%A<7&A<8%Q<;'1\Q,QTX)!\6%# ?("\[+1XL+GR>;$4N*E^!
-M75EOGX.A,S15?FPIH%["$Q >([B+%Q84% ,3I1(2$Q(3&DD5$!(2("(C%T04
-M$!02&B<Q.$YA$10<0JVR>VR+<&P!7 %# -/Z+3LZ(%4ADZH]%1H:=XNUS\_+
-MMJ<@&!04&1<8%Q<;'R$T.Q\Z)AX<+"-2E[R@@V5Q9'EV6D5&,HAV)G'"V<FY
-M-#YGQXH:D6BG%C0A@5D:&1@>%@,3I1(2$Q,.'%5-%1,0$1L8$@D3&4I&11@P
-M.H-1;&M[;Z"50E7+44,!%0$: -/Y)B\T(E$;D:PY$!@;?I.ZT=#,MZDA%A 1
-M%Q46%149'2,W/2$X(1T6&B)8C[&8>%=E1WN$94=%-H]W&5JPQ;>Y-3YIR8H8
-MCF.D$S,BAE\=%Q0;$P,0I0\/$! +&4]'$A -#A@5#P80%4(].@\I-7Y'75IN
-M:)Z71U/*4T,!%0$6 -/_)RHU*%<>EK0^#AH>@)6\U]O7PJTD&A43&1<8%Q<;
-M'Q\O.!PT'QH1%Q=#>99\7D-(,GF6<$M",8YZ'$&!F8RJ.#EDS8\<CF&F$S E
-MDF0;&QD=%0,2I1$1$A(-&U!(%!(/$!H7$0@2&D8_.A$R0(E8:61W;Z.=2E76
-M6TH!&@$< /OS1FH5(6D:%1P4'!B*<H^FS<S'HZ85&1D4&!(5&!<6-R(T-QLP
-M*!PB.R%6G::=;U]L<GMS6D<F(HUQ14.ZY^3"1REBQI0;OE&^'F02&R$6%1DC
-M'A,2$Q<4$1$.'TL?$Q03&248&!<6%QT6$@X2%Q-G<DE7/X%1/C3#,4X!' $:
-M /OX/5@2)&04%!T0%A:*>)>KT-#+J*D6%Q41%0\2$A04.",X.1TT(A\:&QY9
-MF*.9;6)O0GUU94DE)91L+BNER\S 1R=DR)09NTRW&V,4'2$4#Q8@&Q /$!01
-M#P\+&3L2#Q,0%B(5%A44%1</# <.&AMI8BX]-H)1.R_",TT!& $4 /O_05,4
-M)&\7$R@6%QJ/?YVMTMC7K:L9&QH3%Q$4%186.20I-1DO)1T4%QQ;BXF%95A7
-M)7B+;T\D(YU='Q!]FZ&\4"E@SID;NTJX&6 8(289%!@B'1(1$A83$1$-'#,2
-M%1(0&"07&!<8&AP-!P@3'!]^?4A30HU6.2W.+DP!'0$7 /OQ.B0E*'<=C*9N
-M&!@2:HVQNKF=E9<A'AL4&Q08&A@@%QTU.1HR)A\U2R$YCJZ8A6EO<7Q]8D K
-M(HLG<JBOLINZ6"P6R)L>LTFS'7@8)"L7$A<;&!,6%!$2$1$0'CPE&B03&BT>
-M%Q5+)A84$"(<("@6;2J5?3P=/C##,TD!'P$; -?T-!<A*W(7BZ=J$A82<)6V
-MO;ZAFIHB'!<1&!$5%!4>&!XY.QPV(B8I)AL[B:R6AFUT07Y_;4(J)9 C7XV3
-MD7VP52H8RIL<L$2P&G42(BD4#A08%1 3$0X##Z$-&"86&" 0%RH;%1-))!(2
-M$1\6'BD36A* =CP>0#+$-4@!&P$8 )O_.1<F*7T:BK)P$QH7=YNXO<&IG)PE
-M(!P3&A,#%[D@&1\J-Q@N)R<D'!0_A)>!>&5=)'F5=T@I(Y\9-EME75"J7RP4
-MT* >L$*R&G,5'B44$Q8:%Q(5$Q #$:$/&Q\4'242&2P=%Q5-*1H6$B$1&"P?
-M9!N,@44A/##/,$<!( $: -;R(R<</FX3)RDE&1E66I*>@9>+<W43%A82%Q48
-M&!<C&1HR.AHX(28\4",<6V>)B&%K>WJ!8&XL+X-@,L#-M\"\8R0PQYHLJ3&K
-M%VHQ12D9%!07$Q0;& 02H1$?01\+)1L:)2$=(F@C'R,=,#I%'2=J#I\K'!8_
-M1;5*, $8 1D ^_,@(1Q!:0TF*B$3%U9@FJ.%G9!Y>!04$@\4$A42%"$:&S8\
-M'#LB,"PG&QY;9XJ.:G!+?(-K<"LRCF(GJ+&6HK-B(C+)FBJF+*T88R0Y(A,1
-M$100$1@5#P\0$ X9(PT+(Q47(AX;(&8A#Q@8)28](B]K#:(P'!A#2KE,+P$4
-M 18 ^_\H)"$_=! E-2<4&UMGH*6 G))V>!<8%Q$6%!<5%B,;'"<X&"\E-B8>
-M%2)45'1[8%DN=YEU=BHPCVH,<8-B>;-N)"[/GRRF*K$;8B<\(101$Q82$QH7
-M$1$2$A <' H0*!@9)" =(FHF$Q@5&AXY)S5L#*0U(18^3,5'+@$9 1@ ^^XB
-M%1H:D2LJ)R<8(GE0DXUND'=N;1 8&!<9&1H:%R 5&3 W&$ <$5Y<)ALSG8MU
-M77!Z?H)-?B$O@HUBJ<#HD[UW(3_'H3$R+U892!4B(AP4&!42%R 7$A(3$A,8
-M0S 2%2XJ,R\Q)AP_/F<L374=%4HY%9\L&Q5&2)X;&@$I 3 ENT?$1L=CB4I
-M*242('E6FI)UEGUU<Q$#%+\6%A<7%!X6&C,Y&CX?%TXM&QXTFXEW9'5/?(=:
-M@B QCI58E*C-?+=V(#[)H2\O*5@:0@@6&A83%1(/%!T4#P\#$* 2(Q8/$24D
-M+2PO)!H])5$>,U8,&5P^$YTD%1=,3Z(=&0$F 2X V/DG%AX=FB@H,2H5(GY;
-MHY1ND7IN<A09&188&!D9%B 7&R<T%C@A'D8D&B FAG-A6UXN>)QGBA\OAZE0
-M9'F;6[R"'SO/J#$O*EP=0PD=(!D0%101%A\6$1$#$J 5'1$1%RDG,"XQ)AY"
-M(DH4(TH+(6%#&*(J&A5)4*P9& $H 3 ^_DG%QYTF!4OLYD9'A)!EGYF@VIE
-M91<=&Q@;'AP8&AH8&2\[&3P='S!L)!XTIZ1Y3V]\BW)6C2,=AI*WO-CB2(.3
-M(5#"J3H\3T,>@!H<'Q87&1D=0"(<(A$6$Q(9/58V(6='+R%^3A@F)#% @Z V
-M%B8=%J4N(Q1=&"P7%@$K 1@ ^_HC$1UWEQ,MM9<3&Q))G8-OC71O;147&!89
-M'!H6&!@6&"\[&3 F%BDV%!\MI)UT4FI5>8!@DB(;BIVJHL3-.X.8'DK IC@[
-M3D,=?AD9'!,4%A8:/1\9'PX.#P\0(BH<&$P^)QJ!3Q8B$B,U;8$D%BT?%J<H
-M&Q)C&S$8$P$M 18 ^_\K$AQYIA4INYP8'1=%J(5EA6QG:1<:&A@;'AP8&AH8
-M%R@R%#4B(!TA%B(ABH)=1E$M=)%SGB$?DJ>9=IBI*HB='DO%KCHX2SX:@A@9
-M'!,4%A8:/1\9'PX4%!$2&"(6&%1 *QN#4AHG#1PR9W8?'3@C':TK'Q1B&S,;
-M%0$I 1@ ^_<_)!<BIAL>$1,='(U!D'A>95]@8!@<%Q8:'185$AD7&2T]&3P>
-M&1EA)Q\=2J1\5FAW?6UNGB(?A96O:>3<)W][)&"]NS$_/5<HCQ07'1,;&"$A
-M1BTC+146$P\:/%1*3GJ'%1X,3!<?2%9<JG87$B$:%*$7%P]=F#H=' $H 1@
-M^_@['A8EI1D;$Q$7&8U)EWUE;6=H:!86%!08&Q03$!<5&"T]&3 H$!(I%R$:
-M2Z%X5FE8<H!WH!\=BJ&B3\_*'86 (EN[N3% /5@GC!$4&A 8%1X>0RH@*A(.
-M#PP1(24G-51^$!(-314;0E1<HF\4$B4:%*,1#PUCFST;&0$N 18 ^_]#'Q4E
-ML1L9&18<&Y)%HG]<9F!A9!@9%A8:'185$AD7%R8T%#,A&@D;&R<8-(5D35(S
-M<9>%J"$?C:B1);.U$XJ#'EF_O2PT-$PDE!D6&A 8%1X>0RH@*A(4% X3%1H<
-M,F* #1404!D@0U9CIFX6&3$?&ZD4$P]BFST=&P$M 1H F?=(*B PMADGJ;<<
-M$AD;CWDX.R\W6A@7%1,#%=\3%!D9&"@Z%S@A(BUE1C(^,J2I=6-YD'Z!JAP>
-MB(QFB.6C7H&4+SJPP6EG>XF1HQ46'1,:$1D@(2(<'!(5$A$;-E!*-WR%&B<;
-M428O)1LJ=S59%!(4$HT8&!=8FS,?'0%# 8, F?A$)!\TMA<DJ[46#QDCEGX\
-M/S,[8!81$A$#$X(1$@,7VB@Z%RTK&24M-3A!.*6E=659?("!IA8<CIA9;<^.
-M5(2:+36NOVEH>XF/H!,3&A 7#A8='A\9&0\-#@X2'B,E&4]Y&!H94B0K(Q@E
-M<#96#A 2$H\2$!5>GC(<&P%* 80 F?],)1XOOQDDL[H;$1X?H8 T.2TU71@4
-M%!,#%=\3%!D9%B$Q$BTC(Q\?-C<_,YF9;D\S=(B&K!L>C9U(1Z]T1(29)S"P
-MPV1<=(21J!@5&A 7#A8='A\9&0\3$Q 4%1D;%&5^$!H=52@P)R(R>4%@$106
-M&945%!==GC$<'0%+ 8< GO(^(QIWM1H6'Q@9(H8DC7PT*QLO41@7%144$Q05
-M% ,9VB<U(#\:&2=N+R(J)C9Q3V.&<WIWMB,>AI1K@X!80BF>QX[%NU[#0LM<
-MDADH'!8:$R$F*QP>&!,4$A,A,$M!.WE]-BMY0Q8L2$0_AE2=&Q@3%X\.&!9@
-M9C<A% %* ;D ^_4Z'!EZM1@3'Q83'(8KE($W+1\S6181$A,2$1(3$A<7&"<U
-M(#<>%1\V'RHP+39P3U%0.T]HLAT<CY]@;&M"-BNAQHG$O%W#0<E9CQ<E&1,7
-M$!XC*!D;%1 .#A :'"$='$]P-2!Z1!0H0CLT?%.9$A41%Y$+$A=F:38<$@%2
-M ;H ^_] &QAXO!H5)AH6'8LJG8,O*!DM4Q@4%!44$Q05%!D9%R(L&S46'1DD
-M&28M-CMM1C ;&SA<NB(@C:)32T<A(2F?PX3#OUJ^/LUAEQDE&1,7$!XC*!D;
-M%1 3$Q(;%1H6&V9S*A]]1Q@M1T5#A&&A%!,3')<-%1AE:S4:% %4 ;T F/!3
-M1BL>K1<95545&QTBB8(L)B,N31H7% ,7 Q3=%AD7(S(2,B 3+&4S&"4K'3R$
-M9(6+EGVR)!R!E9.KLF5*@J38F*N\N->TPFZ!+1T?%1D/7%4F(24>%!03$A<^
-M44(\.G)>:HY+%C C,CA_2Z 9&1@6G1<6&'B1-B07 4,!O "8]D\Z)2"N%156
-M61<<'"F4B"PF)C)6&1$1 Q3@$1(2%!<5(C,2-1$8(3 A'RHZ(D>(0E= 3F>N
-M'QF0G(ZDHUA&AJ75F*J_N=.VPFZ"+AH<$A8.6U0E'B(;$1 /#Q0F(QT@'F9>
-M;9--$B@=*S%Y2Z 7%A(4GQ,3&8&6."(8 4T!O0"8_U4U*"2Q&1IA8QL=*BB5
-MAR4?'BI*&!83 Q;@$Q04%AD7'R<++0\;%QD>(2P\)TJ"(RP<+4G &B.0GHR9
-MET<ZCJC=DZG!NMBZR7.%+Q@:$A@-6%$B("0=$Q84$10='!0<+F%9:Y51%RP>
-M,CI^5*D<&!,9I1@5&H&9/"89 5,!P "8\'8A$8*F'!QH9!4=*ADS/BTG&RI'
-M'1H6 QG@%185%AD5(BX7,"43*6A(0R$C,RLZ8H61DW>I&AQ^E&ZXU28\HZ32
-M@I_ LM6ZQ'F%'1P:%!@6$$$@*"8A%103$!(]44 T.7II9X),(T!+$3B-6ID<
-M%Q@9HC,;)79U,"$4 4$!Q "8]'8:#H2G&AAI9A4;)R ]0BTF'2Y0'!03 Q;@
-M$A03%!<3(2\7,Q88'C$S1B0K,#,]0%=&2U^E&A>0H'"URQX[J*3/@I[%M-*^
-MQGF&'AD7$145#T ?)2,>$A /#0\E(1X;(&YI:H=.'SA%"C&'6ID:%!(7I"\8
-M)G]Z-B8: 4P!P0"8_WT9$(BJ'AUT;AH=+Q<V.B8C&2E&&QD5 QC@%!85%AD5
-M'B,0*Q0;%!DO2"0M.CD_)"P>*D2W$R*-HWC!TAPXM:G9?9O*NMS(SGZ)'Q<5
-M$1<4#C\>)R4@%!84#P\<&Q,6+VED:(E2)#Q&$3J,8Z(?%A,<JC0:)W]]/RL?
-M 58!RP#[\946'#.R%!X?&" B=R")?$!"0$%%%!H6%A<8%187%AD8(2TG,204
-M(&LU/D J(BTV6820DF^A&B!^EUO9W#9VQ)[/DH._L]>[M85M+!\;%QD/$Q,D
-M'QT:%1,3$18K13$M8G5I57Y+&5:$?WZW?)T9'2$9I84\+7V5/1,5 2<!O #[
-M])87&C2S$AH9$AD:<"2/?D%"0T9.$Q03$Q05$A05%!<6("XG-!49%3(?/T(P
-M'#0Y-E=&2E*?'AN+GUK9V#1YR9[,DH/&N-?!MX5N+1P8%!8-$1$B'!H7$@\/
-M#A,?)1<726EI6(--%4Y^>'>Q?)T7&AL7IX$Y+H::11@8 2T!N #N_Z$:'C>V
-M%A\>%1<4=QR*>34Y.3M"$AD5%187%!87%AD8'2(@+!,<"QH90$ K'S8W'RD:
-M*SFQ%B:*I6CJZ#EYU:78C7S(O>#*OXIQ+AH6%!@/$Q,D'AP9%!44$!,8'Q$:
-M6&1D5H51&E)_?X"VA:8$'(FMACLOAIU)&AH!- &^ /OZL"(B'XD-%*2G%1@8
-M(I-C045%2$85'!09&A@5&18<%1@A,2DL+!DA=#@E*C0Y*S!3A(Z5=)@?%W26
-M5]C=*+NCH=&+:LVUU[ZRBEPQ'QT7&1,3%"8A'1<4$Q,4%1LN("(M-3E334X8
-M5#$C+&]$I146%!.G>C@MC99#&R,!(P&X /OZL2(@'XH+$*BK%QD5))9B0D9)
-M34\4%A$6%Q42%Q0:$Q8A,BDL'1L5.Q\F+3LX,S8Q5D1-49@B%'N:5-?<*L&I
-MH<V+:M2ZV<2WB%TR'!@4%A 0$20>&A01#P\1$AH=$1$:+3M64E 43BL=)6E$
-MI1,3#0^G>#8PEIQ*'B$!(P&U /O_O"<D)(T/%;*W'QP?()9?-#@Z/D,1&Q,8
-M&1<4&18<%1@<)B(E&1\.(1HG*S0U+S$<*Q8N.*L:'GRB8.7K+L"PJ-R&8=6]
-MW\N\C6 S&A84&!(2$R8>&A01%!03$A<:#1@E)S94550942XB+FY-KA@5#A2L
-M?#@PEJ%,'B,!* &W /OMH20=@+$0&18D%QIF')X^/T)$2$P6&1H:'Q84%Q4=
-M&Q@@,"0N)R I=4$@1BY,*!U,='V4;ZL@&W&=.]O='97'MM":7LBPT+BOI$T=
-M)!L8&A,6%"LN(!L8)C= 32D;,692.TU;;&@=3B(2+FY3I!<8&AXK&1H9G9Q!
-M/4,!1 %S /OQGAX:@+$.%A8D%1=B')T]/T)&3%,5$Q87'!,1%!(:&!4>+R(J
-M'1X=.B8E43M9-" O2C9+/Z\8(72C/]O<()?'N<^97,BRTKJSFTT@'185& T0
-M$2DK&Q83)38_3"88,6A4/E)@<VH92AP*)F93I!45#Q$?#Q08G9Y(1$D!3 %W
-M /O_JB$:A;82&!TK&15H%9HZ+C$T.DH4%AP9'A43%A0<&A4:(AHB$R(:(20J
-M43M8,1X8'PDJ(L04)G2H2>KR(I_6N=N85L^ZVL*[I5(B'A07'! 3$RLK&101
-M)#4^2R@6+&90/%=L?W(>4"$0+&Q<K1H7#Q(B%A47HJ9*1DX!4@%_ /OLJ"$>
-M(' 7$J.K%1@<)JV\@55-2TD7%A,;%184%Q4<'1LA+BPK+",Q>SXA,#U+1B%)
-M=7V0:9@A&U"1,M_:*\_0=LZ?2\^HT+>9J"\7/2,8-S$8;$$F-*(C7DE /EA+
-M5XBAL+.NISTA5WI[@;&?IA<8(" S+BTB)1H4,#,!/ $O /OPI1L;(' 5#Z.K
-M$Q4:*:Z\?%%+2T\5$! 8$A,1%!(9&A@?+2HI)24F0B0C-D563R,L2S9'.9P9
-M(5.7-M_9+M'0><V=2="KT[J>GR\:.",:.B\6;40G-J0E84Q#05M.7(VEM+BU
-MM$,:3W)Q=Z>?IA45&14B%Q<0%0P,,3X!2 $V /O_L1X;)749$:JR%Q,>(;'!
-M=TE#0DH7$Q(:%!43%!(9&A@;("(C&B,E)A\G-4=632$5( DF'+$5)E.<0.[O
-M,-G?>]N?1=.MU;RCJ30<-1X6.#,:<$8H-*(C7TI!/UE.89FWR-'1S50C57AX
-M?JZHKQH7%Q0C&AH3&100-#\!2P$X /OOKA@:<#@4&1\4&1I(.+G;TM3(P)0=
-M&!89%!H6$Q4>'!@?+BTL+R<V=T4A)#9(5QI$;GJ2:Z(L&DB6+-;;,<[/E-"C
-M3\FDS+BXO"TM2)B1-*,MIS>5-' B03) /D1(KZFHH):LHC,=2!4=(T UFA@8
-M%QP9)3,R+R@T,"T!*P%3 /OSJQ(7<#@2%A\4%Q=)/+O;T=#(PYH;$A,6$1<3
-M$!(;&14=+2LK*BLN02L?)CU17ADD1#-).Z8D($N<,-;:--#/EL^A3,FFSKJ\
-MLRTP1IN6.Z4OK#Z:.G8H23I(1DQ0M[*QJ:&XK#<90A,;(3XWFA85$1,,$AD8
-M&!(:(S(!,@%5 /O_MQ47=3T6&"8;&Q5*-,/JX.+9TY\?%1,8$QD5$! 9%Q49
-M(",H'24L)"4C)#]171@.&08H'KL@)4NA.N7P-MC>FMZE2M"LU,#$O3(R2)N8
-M/:DSKT"<.74G139$0D94RLK)P[S5OT,>1Q<?)4(_HQL7%!<-%!T<&Q4?)C0!
-M- %0 /ORLR07%Q\?%B@W'!U$-+7:U]'+QI$?'1TC(",E*RTN,C(Z,S(M,2DN
-M=4LD*41/3RM ;WR/;:<U(2Z5*-W:*,W,;\:K3=&NOK>XR"JZ<J<R>D58?C:9
-M**(D5SL^/%.2II^IJ:2G*SP@*4-%34U&1A<8%!@>'BHK+S0\+!L!(P&' /OV
-MM!X4&1\=$RDX&AI&.+G<V]70S9<@&!LB'2 B*2LL,# X,C$O*C G/S$B*$=5
-M52@D0S)'/J<O)C&;+-S9*<W,<\:K2M.OO[B\ORB\=*PX@4Q>AD&@+ZDK8$1'
-M15^>KZJRLK"S+SH=*DE+4U-(1A45$@X0%1,1%1L:&!P!) &# /O_P1\2'20A
-M%31#'QI$,,/QY^'=V9XC%A<?'2 B)24F*BPR)28J'R4E)"DD)T=44B8/& 8F
-M([@P*S.@-.OO+-;;>]>P2MNZRL7&R2S >K$]BDYEC$2A+JHL7D!#05BER<7*
-MRL?*.SX?+4A*4E),2QD5%Q86%Q85%QHA'AT!)0&( /ORMB8A/B,6&WZ-&B$_
-M-;7<W-+'SJ4_.SDX.#DZ.3I /CP]-"XD-"DZ=$PA)29'-C@P9X!_9Z,W*""6
-M*=W9*LO/JKNO2LRHP,*]R2N_PKLUD2:B,X*75*$U5D!73$"NLHZ?P\"_%!M:
-M'STP/SL[7F%.&!L0*BTM,3=+.40!0P'( /ORO!\;0204&'^,%QL_-[KAW]7*
-MT:M!.CHY.3H[.#D_/3L\,RTN)2HX/3,@)BE-/C<A.SQ /9LX)2:=+MS8)L?.
-MK[^Q2]*LP,? Q2C!Q;T]F#*L/8V>6Z<[7TQC6$RWN9:FR,&]%!Q=)#\O/CH]
-M8&!+$ \4%Q$3%!(U,D8!10'( /O_S2 60R46&HR:(2 Z-;_P[>/:X;(_+RXM
-M+2XO+2XT,BXO)B =(1LP)2@?*2E*.C87'Q >*I]#)RN?,^OO*\_DO,FW3MNT
-MR=;0S2C)T\$YH2NT0XZ@7:Q"7TE@54G#U*R_X=K3&Q]?)CLL.S<Y7E]+%!0/
-M&187%1,Y,T0!0P'1 /OWN2DK2!H9&AXB'1E,/;78U[?1RZ- /S(U-#,R,"\O
-M+C(W-C,M62<D?D\F*B9,5U8G47R"7[,H(QF3*-W<.LC,I[.X3LNPL[W%RBC"
-MR5$QM1MR,+!2F(EH.TE!/%:OS,"_T,,?%A8A*A(S01@A4W*)&#M:03(M.D9
-M*RH!*@'+ /OSO!P?21L7%Q8:%Q9,/[K=W;W7T:I .S U-30S+RXN+3$V-3(V
-M11XA2#0C*"U78E@6)CI$.:TF'1^<+^+;-\3,K+>Z3]&TL\/(QB7$S%,XO2=]
-M/+Q8GH]M1%5-2&&XT\?*U\,6$!0B+1,Q/Q8A4W"%'10?&AD0%B4P)2<!*0'*
-M /O_SA\<3!P9&1P@'!A'/;_L\-#HX*LY+R@L*2@G)",C(B8K*B<L-1 ?+2HC
-M+"]88UP-#!$>)[(K'B2<,>[Q.<K?N<' 4MJ\NLS6SB7,VELYP2* .;==I9AY
-M1%)*16'&[^#E\-(@%1@E+Q8U0QHF6'6+$A@L'!@3&2<R)B<!* '8 /OPL$4P
-M$Q85%I^J&!DJ-:O(T89E6TLW/SHS-3$M,BXN+R E)RHH6R\?<4L?(ADP0$<N
-M46-J1%@K)QPD(]C<1FK)K:F\3<2OI+^AP#"MS2>62U^L+Y8XLSBC2S)-24*^
-MS\BZDS\6&!@5+!(;)188*$N9/\R_V#P_0VX\*2H!+P'( /OOM#PH%A<3$YVG
-M%!8J-[#-T89E7$\V.C8S-C(N,2TM+AXC)2@Q0!<=.RT9'ALW2$<9+3= *50E
-M(!HB)MS<0V;)LJV^3LJSI<6EO"VOT"B<5&JV.Z(_NC^I5#Y954W'U<^_ES\0
-M$A03+1,9(Q09*$F5"Z*SHQ$>)F,[)B,!+ '* /O^QCXD&!@5%:*O&18E-;7<
-MX(]J74DK+BXJ*B8B)B(B(Q8;'2 O) PA("0:(Q\Y2DP5'!TI'UHH'QXD*.;O
-M0VO8O[?$4=.]J,JQQ"VWWC.A5&K -IU!NT&N5#M64D[7].K6J4@3%1D7,!8=
-M)Q@<+4Z;#Z>VKA0@*6(Z)B0!+ '2 /OM:!<;5D0:&Q0,%A<8*Z;+JS8T.3,]
-M.S<R-"\O-#0J)"0H,"XC72X8<%(H'R,;(BDC)"P?*"<K,#,M.,S3D)C%LZ"\
-M6;Z(2< HR">LQ\!W&[XUHZ,HI3.)-#AD6H._OXX8( \,'!\='2TT,S,H%1A/
-M.[9<NC\_;C(U)30!:@' /OR<A0674<8%Q41%A08+:;0JS0R.#8\-C,R-3 P
-M,C(H(R(F+BPL.Q,5-S,E&1\<(R8<&R,@'2,E*"PI-<S6CY3%N*2^6<**2,4J
-MQ"2PRL%]),8\K*POK#N2/T5Q9XO%PI$8'0T/*S4T,S S,C(I$Q9,&)QAHALB
-M6S@]'R@!9 '" /O_A!847DD<'"(=&Q03*:O?LC J*RHO*BLI*20D*BH@&!H@
-M*"8L' <='2<G'B0?)"@C'2,C'"@F+#,N-]7HCIG4QZ[&7LR01\<RS"2XV,Z$
-M(LI(K*PPJS>0/T1Q9I'8WJDG*1(1*S(Q+RXR,3$J%1A.%:%FIQPC6S,Y("L!
-M90'( .3T1BDE&QH>("$?'!HA&14KRE)!/STY-#$I)2,C)B$?(R8J+2TI92D8
-M3D4@(R8F)RTS-CE!.4YZJ[Z42MW6=-7(N7:Y(\!1.[]?N"FLRU<NO5\TM#"=
-M7B]G6&E;820;$A85&Q8, R&4+!4D)"$8$Q8D,&/9:V0E1AXOIHD!,@&Z /OJ
-M1B$='!<8%Q@7%A<>&A@HSE(]/3PW,B\G(R$A)!X=(24I+"PU21D9+#0B&B$E
-M)BTU-3,X-E-^J+R;1-W;=-+(NWJX(<%.-KU=L2>RSEDUQ68ZNC>B9CIT9WMO
-M<"D;#A 4%1(2,3<T-!8B(A\5$!,A"BZC.$P902 QG7D!*P&_ /OT5R4;'1D;
-M&QP;&1D@&QHRVDDU-3$O*B<?&QD9(!P7&1H>(2$N-Q$:(BL@'A\B(R@P,C0\
-M/EB&M,&F1^3R>=K9T(+$)L)0-+]?O"N[WF$VR6<_PSFN;#IT:8!W="X@$Q$3
-M&!@7-SLT-A<D)"$7$A,?!C>T15$</ALMG7L!*@'$ /OO)B0E)S @*3 V.$A.
-M3%%US,@^*RTT+RTJ(BL7*!0C(R4I+"\N>S,M04HR/CUJG+W)T<_2ULR_(S"0
-M5=O1=<S'QA^\47R4F\5QN"BKS::Y7#&A2"VU)K-K:FEF,S41(ATB*"4A,!4>
-M1A,3&!,7%A0=/C9SC%U%E3Q)FBP!, &( .'F+BLK+38K.#U"2%M<9VY\S\8Y
-M*2LR+2LH("D5)1$A(2,G*BT];R,F*3,A.#]LGK[*U]?3V-;))"N74]O4=<G'
-MQB"Z3H&6F<=WN":QT*C 9#>H3C2[+KYW>7EV.CD5)!P@ R:7-1H@1Q 0%1 4
-M$Q$:0B=>D6-%E#Q+D1P!*0&/ /OP0C<T/$4X1$Y566MV@X.%X<HW(R,L)R4B
-M&B,/(P\;&1L?(B4I:"<=("46/4-PILO5YNWN[>G9)RB@6.3L>M'8V2._3H.:
-MF\MVP2JZX+#!:#RJ4S; ,L%Z>W]\/#0/(!LB*"<H-QTD2A(2%Q(6%1$8/2-<
-MG6Q*D3-&D1X!* &0 .OB:F%<55]95UE;5%-75EZ[RRX:&!P8+14L'BL9*A8C
-M)"<I*S$Z*4=L9836R<O1UM;9U,_?GLLX-RF.9]S5>,7(QG_#<KYQB+AFLQ^M
-MRW5'+K1T*:A%;F]F:V9<'TI'&1LM.4TX(2(6&AP<'009C!U92%FQ*)JA)RJ2
-M-0$O 38 [.^2CXF#BXF+BXZ*BXF ><K1+146&A4J$BD;*!8G$R$B)2<I+SLB
-M+DDY7\C-T-39V=;6U-N/QSPQ(IAKV=AXPLC*A<=UQG>*OV^W(+'.=TXVNGLP
-MKDQV>7)Z=&8=3$L;&RD\4S<C'0X8&187$P,6C!I$/EZG(YN@)BR))0$H 3@
-M^_^\N:VNM[2TM[RWM[VID=CD+!,2%A,H$"<9)A0E$1L:'R$C*2P@(#HI4\[?
-MZ?#U]?+TZ^.-STXR%YYUY?!]RMG>BL]WRGZ.R&^_([O>?T\ZP7TQLTUX@7=^
-M>VP?4%,A("X\4#0?&Q(<&QD:%A@8%AA016"Y+IZ?(RB))P$G 30 ^^-M9V5:
-M6U=85UQ64TL88<7-)QHD(ATL&BT?+AHO&24D*#$Z-4NM6H_?VLO:V-;8V]C7
-MA9=\TT=5+X]OW-)./\G,A+<AKWYLM%%R&Z3+>)VI*"ZUFAV-7&)::!@B%#8M
-M3V=?12XI,AX;E9N>J:JRM;^]6F"O,)HP-'>4,@$E 34 ^_"=FIR4E)"/DX^,
-MD'TO8\71)Q4?(!HI&"L=*Q<J%" B*#$X,$.B/6;,V=79VMG<X.'895%,PT1,
-M*)EUV=-//<G1C\$HN85ROEYZ(*K.>:.Q,#6\GR2596YF=!T?%STS4V5B2RXI
-M+1<9DIB;IJJRM;_.8%FS+9(L,G6)(@$> 3, ^__,RLO#QL+!P,#!OJE&8<S=
-M'A ='!@G%"<9*14H$AT>(RPR*SVA*%W9\/7P\/'N[^WC73XMO5!.'9]^Y>Q2
-M0MCFFLLJOXYWQEZ (K'@A*BU,C:]I".9<75K>2 =&3XP36=B1BDB*A@;FJ"C
-MKK.[O,3$6UBK*Y8Q-G>)) $= 2T A^YA<4-=5EL#5_%210U35\#/,SA%*RLU
-M+"X>,ADP&3DB("TR-C;.U]31U=;9V=/&WY5 CH&*S5<C>HU]ULX?F<''5,$F
-M/74U4S<,!Z#"N$<[3*4])J1J@'Y/*D!F7TTJ0RDR*A\@'"0RB8^1B8:"?7UW
-M*&J[-I$7$(.!.@$R 58 ^_2;GH63D)61D8R1;!M38,?.,3) *2@S*BP<,!8K
-M$S,?'BLN,#3)S]?9VMG:W-?)XYDS5#-3PE 8>)>"T\D=E\#'6<DG0GL\6CP1
-M"J+#O$Y$5*I#+;!XBXE9+3MC950Q2BPT*AT=&2$OC926CHR(@X-])F&R+HL4
-M#G]U*0$I 5$ ^__4S+["O\3 O[_!DBU<8-+=*RT^)28M(B06+!0I%#0A&",F
-M*SC4X.GM\?'S^//A^*,V)1XKP5<G=)^'W=X9F<[89L\H18(^6T$3#*K.Q%!
-M6K9*++>"E91A+SAA8E,R3"XR(QD;%Q\MEZ&CFY61C(R$*F&V,HX6$(5Z*@$I
-M 4P ^^M2951=8F%>5FD@%2 H3+S6-2 B*2 K.B\=+QHV0S G+S$YR-+4VMK4
-MU]C7T:\<,6\ID8B(S%]G)Y"&ULU!P<N^-AXA)B(<&R,;&&J&F6ZCN" EKGQ]
-M@5M62TI$+C,_.R$S,3,C*2DY9W-N:69@7%A3576W?8N'J8B&-0%! 7$ ^_&,
-MDI:3F9B5EYE%&AP?3\/6,QD<)QTI."\=+AD\23 C(R8SR-;:W]_<W-O7U+$9
-M*6@45SM,O5A7(IJ+T\E!PLN]-QT;(B :&AT8%6>#F7"HO"@RO8^.B%Q103\^
-M,3=#/B(S+RXA)R<X9'!K9F1>6E923F:I=(6$IX1Z) $X 6X ^__%P,_"R<C%
-MRLA@)B(A3\_G+Q<=(QLC,"@8*Q@[1BD9'",VT>CM]OCR\_?V[,8E+V80(20C
-MO5]H'Z*0W=DZQ=[).AP>)R0<&2 8%W&+GG2KSBXOQY^;D5U..34Y*2\^/",N
-M)RD=(1\K8G)M:&!85%!13V:O>(B&J8I_)0$X 6P ^^YD<UMJ9&9G7C\C'TAH
-M.<#5/2,<,SLO,S(6-4,P%R O5,G8V-72T]K2T]&1=#0W?G(OA8F*RG<A&(A]
-MR<N;P\'%-AX;)B$F+S%6%X? O90]/4Y\A6%=3E5;65Q#,BD\&RHZ0S@^.",N
-MU=+8U=K7V-?CSG^Y?H.TK8"+-P$N 6P ^_2>H)V=F9N<CS\0(5!D0,?3.AP6
-M,3@M,3(8-T0O%!TL3L38W=S=W-W7V-64<2XO=&\@3#Q,OW<3$Y*"QLF=Q<3*
-M,Q<8(QXC+2I1%HG O9A#1%>$BV-:1$1'0DD\,"<Z&"<X/S(Z-R$LTM+8U=G5
-MUM7CR7.M=GVQJWQ_)@$E 6H ^__7SM;-RLS-MF ='U9J/]/G.!T9+38G*2T4
-M-44N%!LJ4\_K]/?W]OGP[^JF>3,M;FT>&"$DOGPC$)J'T-^;R=39.Q48)1XA
-M*2A.%9'3T*1,0U.*G&E:/#<W,3HS*B$V%B<R,RLN+!DHVMOAWNCGZ.?TU'BP
-M>H"SK8*$)P$E 6P ^^EN;69I:%MI-T$4'8!\0,3<."4=,AHG(S%#+Q4N'VS2
-MW-S8W-C5UMG45B(?*AX:*QHH@I"(R(T@'W]_PL6UP+^_2RXG(QLD-AT;%RR\
-MM3)WB!T2'$Y586-?7EE&&QT]'!X[+3$T,34IS];5W=[AV]W;NFJPE8&[J&N#
-M-0$P 2D ^_*HF::;FI"2'R(4&XF!2\G;-Q\7,!4E(S5),A@G%V7.WM_<X-S>
-MW]C76B@G*"0A,"(=3$9-PI09&HF$PL2UPL3$3"PG(AHD-A@9&3+!N3N$C2 4
-M'$!%2T=#1D(\&!8W%ADW*2HQ,#(ET]O:XN+EX.+BN6*KC7NUI6=W) $I 2<
-M^__?Q-W'SL._0#$-'9F-3M;Q-" :+!,A'#!$,AHH&V[=]/GX__CX]_'Q;C$M
-M+"TJ-2@<'2@FO98D&(^'R]V\R-'962@B'Q<?+Q,3%3?.P3E[CRX<#2\U-S(N
-M,3$T%A0Z&1<O'2$C(S KY_+O]_?Z]??]SVBID7ZXIVUZ(P$H 2D ^^ML?&%@
-M7F, .D8P.44N,<'5.2TG,A@Q/3(H+!YDLM/4V-G8VM/8TTXD2"Q;220F4C1&
-MG)F#U9L8&GF"N\6T8\&X92LM/BQ004P_(A_-OQ@<.R@B35A-8F!&'UA$&3PO
-M9#Y%*SLV.RXMT]79W>+>W=S@U7BTFG*QJ7]D- $X 8T ^_6EIJ2AE90-&"HI
-M/$HT-<39.R@D,AHS/C(F*1AFM];7W=[>W]O<TTH;-R)B+"0I/2<M:%A+QIX5
-M%X6%O\BO8,6]9R@G.2I./TP^(1W*O!8:-B0>/S]#4$0S%T<Y&C L831!+#4Q
-M-RPKV-K=W^'@X>'GU7&OE&RKHWU<)@$Q 8P ^__9S=K*Q;T?(# J/$\Y/=3M
-M-B,D+18Q/RTB)QULQ.[Q]O/Q^.[YXE(=+!QK("DG,R<8/3,MQ)X=&8*'R=:\
-M:M',;28B-B9*.T<[(!_6QAH>,2H6+C$Y/3 F$3HN'2LL82PW("PD*R8MY^_R
-M]?CV]OC_YG*MF7&PJ():'P$P 8L ^^MQ<UYK:Q87%1DN+R<5)KK8/B<E+T(N
-M&"<@?+[/U-?4U=78V,O+5%5:;"Z$560D6DE-C9F&S:T[&'A[N,&Q?;V^0A<A
-M*1D:'A4@,3<W0$ B+R<W5E$O-V2;I(I(K4E#SSQ!)#DR02 7R]C8V]W>VMC7
-MD8VPGV6KI7 =-@$W 9\ ^_"KHZ.GA1L3"1,S-"D7*[W;/B$?-TLT&24@?\/8
-MW=_=WM[BXL_%1$%%02"3,5T>,S L5EE-OK X%(1^O,:N>;V]0!4:)Q<8'!0?
-M+S4Q.3D;+R$J/CXJ*$^5J7XZK3]"S30])#,M/1X6T-W;W-O=V=K9CH:KFV&G
-MH6X2)@$N 9T ^_WASMW:K2@8$!@V.3$;,,OM.1P@,4<S'"DGC=CN]_OS^/3R
-M]>'8/"T[)Q>?(%L7&R,2)RPQOJY &8& QM6Z@<;)1 \8(Q,4&!$>,3DV.#<<
-M)B(=+3$E'D66KG<PLCE!T3 U&RP@,1@5W_+U^??V\._OFH2HH&:LIG,1( $N
-M :$ ^^MM<EUZ,S5",QT:&1H<([W7.CE:-1DB*H6-M,O&S\G-T\B=HS;865Q)
-M@B)]8DP_5#1.;8UZR88B%VYQI[ZP7T^NCRLD'S,X+2<>'98]43H;(B0[4$.B
-ML69^WJ=-MT,\QD%$(3L@*"TDS]/5X=S6U\C92XR@I4BBH'<T.@$W :@ ^_"G
-MH)>0(A<D(1<:&1,8)<+</3=:.!PE*HR6O=//V-'6ULF@ICK.1TX^5A^:.T4_
-M,2 R.$Q N8H@$WITJ\>Q6TVJBB8?'3$V*R8<&Y0W2S03)!XN0#NBHE=[X)D_
-MN#T^R#D_(34:(RHAT]C9Y.3=W,S70X6;HT:@GG,G* $L :4 ^_S=RL:N.1XK
-M*!P?(!H=*<[S/SEA-APG+YBFT^_E\.WL\N*RN$;6-#0[.!^Q)4,Z'!8@%R<L
-MNX(D&'=VM=>^8%*PB"$<&2TR)R4>'YDX1B\7("$A,#FIH$U[YI(VPS@YS#<Z
-M&C 3'BPIY^WK\OKV\=[I27R8I4JDHGDG(P$L :T ^^EJ;3@6&QXE0AD7&145
-M)[?-FV,5)!H0%PT?'R0>(2$9&A\@=T/3>RHDABM27GQ.1VQ&3'MTQU\Y%6U-
-M6[RN2H2'438U*RXF%QL?'80V.3$7#Q\P,[O:CE9^WDU+MTP[T#HZ,30S(KA[
-MR74O/]1XC&[41VU(FQ>8I6\Q.@$X :H ^_*CEUP;#A$1+@T4$PT/*+O6HF49
-M(!0.%PT=&!P?)",<&1TB>471:R893A]B-'-5,&(P'SPZM6,X$G907\*O2(6#
-M3#$P*2LC%AT=&X0S-"\3$ALF++?;?4QXVCT]NT8_TC,U+RTJ';1XSGTU1.&'
-MFG?00&9#F166HVLB* $O :8 ^__9P'T=$109-! 6&!02*\7PJVLC)1D3'!(B
-M'R,J-#@N)R(==4/66AH6)AIR'7-6(EPI"R(HN%TW%'129]&Z2HB(2BPM)2DA
-M$QL?'XLS,2L8%" <(+WH?#QQWS<VQT$YV#(R*RLJ&[R$XY$^1O*?K(/?05U
-MFQF:IW B)0$O :X ^]9S!!48%!85%!<6%A09&*[-6!P\11<4&$\S)#<5%A@9
-M'!M!4$/.6"$FC2HX1BX=,3 Y.61WQH\T&F\O/[BH*36OA'\O(2$D/104*GPP
-M&Q0L93(E1#8K54J/VTE/LT _QS@^1S4R*(2UR&5')<MMB%S&2$)(F""3E6LP
-M,@$W :X ^^Z;'A44$!(1$103$Q(3%++571Q 1142%DLO(#,1$A05&1E$5C?;
-M0R,66AM *1P:'24@'#<]L8TO&7(U1KNE*SNSA'XM'QLB0QH1)WXM%A,N9C$@
-M/C,L0T&0V31 MSI!R3$W/BHE(H*NTW%2+-!YF&3"03I"EAZ1DV@E(P$T :@
-M^__'/AP9%1<6$Q85%104&;[H:B5*2AD6&E$U)CD6%QD:&Q4Z43+L-2<0-!M3
-M'1D:%1L=$",@K9(M%G T2,NO*4"[B7TI&QXG2!D1*88O$Q J9S =.34M0#&"
-MW3 VOS4\S2\V/B<E&8>UWH93+=^.J6C2/S9#F"*5EVHE(0$T :T ^^ .(B =
-M'1@8%R$P.$!'5[33>3H9#Q$66FE;1EE4%!T1A:.SK*ND?!\CBR-(,2L5*SHL
-M*3UYOX8K%F0?+G^:%R)\A1P:%A<4'UE7-7Y/?X4X(&9IKKEN0T2%VE)*LCY!
-MR3M*0#LS,;.PQF [3==N?EO(041#D!Y<,FXQ,@$V ; ANT?'!H>&0,4\AXM
-M-3M 4;G;?#87#P\46&570E50$!D-AZ6XL*2Q8B 96QM3&!P2'3,7%1M!J8(A
-M$V4B-(6<%2> A1H7%!05)EU3,H!1@H@\&V-IK+IW/D.(V#T[MCA#RS1#-S H
-M+;.KTVY)6-QZCV/$.CP]CAQ:,&LF(P$S :H ^_\L'QTA'AD9%B O-SD_5L;N
-MBD4I%A,87&M=2%M5%1X2C:V]N*7"4B,31AE>$QH2%BH5#A CHXHI%68B,XZB
-M%RJ(C!\9%A08,658-(A5@(8W&&-NL+UW.SA\W#DQOC,^SS)"-RTE([RVX(A2
-M8O&/G&G4.#@^D"!>-&TF(0$S :\ ^^@8&Q<4%!(7.D!+1DE-2+G/=AP9%18M
-M2EE*$B$P/QD3J*F$:&:89!H<4!U)*R@:(#(E'C%KJ)M"&D :&D"9&"H]+A$9
-M&BIF2:6^)%V3W'%1/5514%9"21U^VU5#LT\[R3)%23DT);6VSE0[0\]@<5C&
-M2D9*?B$=(&HC)@%/ ;$ ^]<:$@X2$ X3-SU(0T)%0K_7=1@7$Q0K2%5&#ATL
-M.Q4/K[&);&.F1AD7)AA8&!T8&"P6%APZEYL^%CP8'4B>%BM +P\5&RQI4JJZ
-M(%^7WG-/.%I635)-2AQ^V4 TMTD]RRL^0"XL)+:RU%U&4=1L@F#"0SY$?!\;
-M'F<8%P%, :T ^_@8%A@4%1,8.3]*14!#1]#MA" <%Q@O3%M,%",Q0!H4NL6@
-M@&NX,Q@2(Q5<&AT:%B,6%!@BE*1#'$$:&TJA&BQ ,A,:'BAI8K?")6>?XG%+
-M-E]B3UA-2QEUW3PJOT0XSRD]0"LF&<'"XW506^M_BV;403I%?B,?(FD8%0%,
-M ;( ^_<5%1@5%!<8#31'4U)D3:_.?AL9%188% \,'AD3'Q,=,Z:IKKN.>58?
-M2B%')B8:'3(B%"=!4;,F'149%A].(2$E0B%3:8@=;K#+(5*[W80Q(6%L01A.
-M,#MSU5%)MDL\PRU#3C8^([6VR#TV/M%475/'344Y<",<'G:,/@$X :\ ^]@1
-M$0\2$!,2"3!$34=91[72?QD8$Q06$@L(&A4/&P\9/K2RMK^;6U ?)AY6&!T7
-M%"P6#1H:1KDH&1$6%293'R,I1"-1;(D?>+3''52]VGXJ&V5S/!)6,3AQUC\[
-MND4^PRM 1RLV(KFTSD,^2-1A<EO#2#TS;2$:''-_+0$S :L ^_D6(1T4%1@7
-M#C5&4$963,;GC!L5%1@:%A$.(!L4(!0>/[W O,>J2%,:*QQ8'A\9%"43#!H,
-M1L F'A86$B56(R$D/Q]3;HH=B\C6(UK#XH$H('%^.A=8-#IMV3HQPD YR"<^
-M1B@R%\/&UU)"4.QP=F'513DV;R4>('6 + $Q ; @NDB Q?V%A(6&"Q)/U16
-M/JM>/V19%D2B&"-'@FUE97X<))5X65J(92<<-"A;&BHA*38\(2 N*8,='B@Q
-M'APK,D L*G>7AMH=3\/:+3RUVX<^)&A@4&(\72&,VT]4K4Q!H3="3D0U++BY
-MR#TS0--(4T7&3(EW6E09'FY]0@$V 6T ^]L8$!(5%! 4&BY%-TA)-:Q=0VI;
-M$D">%!]#?FEA87H8*I^!8V"-4QD9(2%A$A\6'BHP%!,9(808&"4N&QTL,T$M
-M+7V>B-4<7,C5*3RWV(0Z&V1E5F=!7R*)W4!&LD9 GCI&2#DJ*KFUS40[1]-2
-M9$K 1X1Q4E :&&IM*0$N 6P ^^TB#Q :&149(#)*.TM).;EK2V]?%T6C&25)
-MA&]G9X >+ZF/:W&20"$9(R!F%A\6'B<M%!07'X<6&2<P'1XM-$(N*WB@CN ;
-M;=WM,4&UXH8R'6IH46E$8R6)XSP\MT$]H#! 238I(L3$V4U!4N1<9U?51(%V
-M6%4='6]Q* $L 6D ^^$G'BPQ.T5*.SE!/# ^/RO'F6A?&A\1;QL_&5<4(V<;
-M&%R#DWB87B,>,2(@-#@V,"PR'QPH*& H'RX^.CD;/$ D'T!?P^ J*\#@(R^T
-MV)I9'REE1UPE8%:0V5)4L$Q$S$%&4#\R+K>SQCTV1M-$347*6;YJIB5FHG"#
-M1@$X 5\ ^]@C(#$S/4I003Y$.BDS-BO(GW!D&!L-:Q<[%5,0'V,7'F.)FGN<
-M4!,;'ADC*RTK)2$G%! 7'5TB(C-#/SP>/T,B(41DR-LG-<;;'R^UU9=5&"AL
-M3V,K9%F.VT-&M49#R4%&230J++BOQC\Y2-!'4T;"5+EDGB%GG&QS+0$P 6
-M^^(H'C,W04]51D%&/"HR.#+5J'9I'2 2<!U!&UD6)6D='660FXVF/Q49(!DE
-M+2TK)2 F%!,8'%LC)#9&0CX>/T,D'S]GS>HG/=?S)S2XX9=+%B=M2V(J7U&*
-MX3\\ND% RSA!2C$H),.^ST,[3MA'4$G34;9II"9JH7%W+ $N 6$ ^]DV-#E'
-M+" A*S(Y.38V02M<2&1Y&Q<<'!E:'!@<)20@#I D&!I!3B06)S<V+R@L)QX9
-M&A@@)3,].C8V.#$?&QT=&AR%Q-LL+L+<*BRQW9MIKAM+>EDP-TR-TU-1@4E*
-MS#Y*1#<_,K6SSD!#5\=.65K%4KQKGB6BGFF!0P$\ 8@ ^]HX-3<_(1H?*S W
-M.C,M.2A=3VY_&1,8&!56&!08(2 <#I$D&1E'0Q,5%"PS)!TA'!80$0\3&BTZ
-M/3L[/2\<&!H:%QN'R-<F,\?7)BRQV9AFI!9.?5@M,T>(U41#AD-)R3A%/2PW
-M,+:OT4-'6LI175V_3;=EEB&CF&5Q*@$T 80 ^^<^-CD]'ALC,C4[.S,M-RIJ
-M6G:&'A@='1M<'AH>)R8B%9XS)"=..!H4%RDQ)!TA'!00$Q,6%R@\/ST]/S$>
-M&AP<%QB+T.DI-=3O+C&VZ9A8G!-.>U<K*3B#VT YBSY&RS%"/BDU*,&^TT-!
-M6LQ/6%O02K1JG":FG6IU*0$R 8D ^]XG7#ME12PG(BTQ-#-&0#O)MV-H%U]0
-M%B C3%A^+A0U&1H?'Q(C3QD4(B\H)2 E(RLD'1P>(2%*22X@'A\>'B8K/2$\
-MM-DH,+'@)BJLRJ%OKJ$L(RYMPFF1TU)2J4P_OSQ%1S,X+W>RQL7'P<*VP+7+
-M6ZU8CB2>FF1^00$] 7D ^] 61QY,+QT<&B8K,2]!.#C)O6YM%5M,$AP?2%1Z
-M*A Q%Q@='1 I10H1$"0A'!<<&B(;%!,2%!E)2RT?'1H7%A\E.B$[N=4@,K;=
-M(BJLRYUKHIDF'29FMEV+U49$KD4^O#8]/BLP+7FORLO-R<F[Q+K)5JA2AB"?
-MEF!N* $U 7, ^]@3.1%!*!L<(2TP,S0_-CK8S'EY&F!1%R(E3EJ ,!8W&1PB
-M'Q0N/103$R$@'!<<&B(;%A<5%!5(22H<&A@8&AXF.!PZO.<F+L+U*B^SV*)7
-MFY<G'B)EL4:"VT,ZLT,[OC$[0"<N)8&[W-[>W>+0V-'?4Z57BB6BFV5P)P$S
-M 6X H>0K2#(X+" <%QHE,SPW-RQ;8SY&'Q<5$A8A%Q09$Q49$P,AC!(2'2(7
-M'QTC(QT<'P,FR" 9&ALN,QXH*RHP,#$K,B1-2,4M*IW@)2FSRJURBF2%7VQ1
-MI7:"SW1&ED9#O#1"4CDS,WS!BY:(EY^AEZ;#7[A;>2:6C5IZ10$] 6( H=0=
-M.B F&Q46%1@C,3PQ,"A=:4E+'1,1#A(=$Q 4#Q$5$0,?UQ 7$1,.$Q$7&A85
-M&!T;&Q40$14M,!LE*"@N+2\J+R)(2K\F*:+=(2>PT:)GAEQW4EQ*DFB TV<[
-MGC]!NB\[22XH+WR\DZ.6J+&RI;+'7+!5<2*9BUAK+ $T 5T H><C,!LA&!4;
-M&1PG-4,V,2YE<$Q.(AD7%!@C&18?%Q<:%@,DUQ(<# \2&!8<'!<6&1T;&Q42
-M$Q8L+ADC)B J+2LI+QY#1= O**[U*2R\TK-*<DEN4E0^>$YZVV@PH$ [OBPY
-M2RLE(X''I[VPP<C-P<G;6JY8=2>;CUUK*0$T 6@ ^^,A(R,K&A<?(AP:&!<F
-M0R2<K($H'!*M&6XF63638( 2$B,D'!$4,U(>&QT@)"<H(R<F(1D7&!@9)B,_
-M/QP\3XYK@T-CH-LI*[S=(B:HO;E=>Y"9BJ:<GTJ'S%I/54(Y=#A%2$ W,K+%
-MI)"+F96:DI_$=K%>:B20BF*$20$Y :@ ^]D8'!PC$A,=(!H8%A<@/""9KH8I
-M& ZI%6HB53&.7'P.$"$B&@X2'C41#Q$4&!L<%QX=&! 0$1(3(R \/!HY2XED
-M?4!AH]HE+L':'B2@P*E,=82&>)"0C3R$T$U$7CLW<S,^/S4L+K+ K)V9JJJO
-MI+#)=:I:8B"3B&!U, $P :@ ^^TB'1TI&!@?)!X<&AXE/2:CM(DL'A2O&W H
-M6S>99((3%28G'PX6$B@2$A07&QX?&B ?&A(1$A,4(1XZ.A0W4)1K@D)CI>DK
-M+LWR)BFPP+HS9F]N67)O8BB"V$XY7#HS<C \03(K)+O-P+>SP\3-P\G@=*E?
-M9B65C&5U+0$P :\ J><:)A\C)2HP%QL5$Q =0R(Z)A8@&AM+&!4:*!H8$!H6
-M$QHD'!P8*C$B R;/(R0E,#$S&A86%1L;*4,O+S%92!,;.C!&G-@H);;6*2^I
-M>KMBC\IIA(?&;$]ZTE5#*E5 ,S%"44 W)Y'"IY>5E9N8EJ#!;[9.6R6+AF-U
-M1P$[ :, J=P1'QL='R0J$QD3$1 7/!XR(!4;$Q='%!$6)!83#!82$1@B&AD:
-M&AT7 QO/&AL<)RLM%! 3$A02)$ L+"Y610\3,RQ&HM@F*KW3)2VD@K%4B+U7
-M<GV_6$-YUD@X-$X],BP[2#4L(Y"]KZ2CIJZKIJW&<+-,4R&.A&%F+@$R :
-MJ>D;)B B)"<M&!T7%1<</21",2$F'!U-&A<<*AP>%!P7%ATG'QL>$A87 QO/
-M'!T>*2XP%Q,3$A44(CXJ*BY40Q<7-#%+J>LJ+<GK+3*S?+M D[Y"1T>T8"YN
-MWDDM+$T[+R<Y2C(K&YS,P[Z]O\;%Q,3?<;-162:0B&9F*P$R :@ K^PV+R$Q
-M+"@U(!P5&",F1B49&!@;#Q@7%Q 8$1D7#0\0$QD@(!H6(RDB)B8H,C<E QW)
-M'!H:(BPF'&$S3RPA1!X?)1==M]<H'Y_.+"ZS<+E<DLE-58?*=U5$:%A$$BD]
-M&C!!3SY *J*\E8N'?7M[8'/-8*Y%2Q]^9V-L/0%$ 98 J=LL)QLL)1\I&AH3
-M%B$C0",3%1<6"Q03$PP4#143"0L,$1<>'A@<'B,: QV#*S$? Q?)%A07'"4:
-M%EXP3"H@0AL7'!9?O=HF(:;+*"RW=[52D<0]08',:$9";$LY&R0Z&BL\2#8U
-M):*WFY23BXB%:'S28ZM%11M_95]=)P$] 9 G>4T+1XJ(R$N'QX8&B8E02<8
-M%Q84$!H9&1(:$QL; Q';%APC(QTC'"@>'1T<+#(@&!H:&1<7'28=%UXP3"X=
-M.AD5'!-CQ.HJ)[+C,###;KL_D,(W.7K4:#P\=$PN$2(X%28Y23(T(*O&K*JH
-MGY>7>XKG8ZM*2""":61=(P$\ 94 ^^<L0#\L'Q]'+"XS5EPX,B0?(A\B)Q\D
-M)B8@)2,A'!\?%1TB'QX<(C(I)R\I)QT>'AT@)"8C("4\6BL1&UUW0!HE1B=>
-MLM$O)H*Y+S&YA<!9D<5-2G[1?E4Z2UY*'QLX0$5"43PU*6>UQ[_&SM77U-G>
-M7'$@.R!'&V$P. $Z 8( ^]$F-C,C%!0\)"PT4EDW,B4=(!T@)!PA(R0>(R$A
-M'!\?%1TB'QH<'R$7'BD@&Q$2$A07&QT:%QPS5"@.&&!Z/Q<@0"9;LM4G(XNW
-M*B_"=<%(CL4^.W[6;T([4E$\'1DV/C\_3C0K)&BPR,/*TMG:U]SB7FXA.1U$
-M&%H?)P$X 8 ^^0I,#8C$Q,[*RX_6EDT+28B)2(E+"0I*RDC*"8F(20D&B(G
-M)"(C(1@0'BP@'A87%Q89'1\:%QPS5RH0&F!X/!4>0QE9Q?(W(XG+-3'.;\P[
-MD,HT+WG;;3(M5%(R&14R.CH]3# E(6N[T\W4W.7HY>KV7&PD.Q]&&EL>) $T
-M 8( ^^\U7S\H.3 C6FZQP&Y83B<>&AP<(1HB)RH?(R8E(B@F+R0@'!\^/XR-
-M*" >(1PA)B0I(RH[+TXE'Q00#!@[$!<0+C-C2,,N)#A:,S:U.\-4FLA95'-K
-MCE,_/F(Z1#]%0T<\0SPW*26@S]W:W.'>W-W:;2DPD24B(5E . $\ 4\ ^],M
-M43 =*B$44&NPN650224>&AP<(1HB)RH?(R8E(B@F+R0@'"$_-6=L%!05%1 5
-M&A<<%ATR*$<>'!$-"1(X%!H7-3A?0<@G'T)9+S2^*\1#E\A*17-P?T! 154L
-M0CU#04$Y0#0M)"><T>+?X>;CX>+8:R8UDB,@'U(O)P$Z 4T ^^$K2"X:)AT0
-M5VF^Q&5.1BHE(2,C*"$I+C$F*BTJ)RTK-"DE(1],/$-4#1<7&!,8'1H?&2 T
-M*4@?'A,/"Q="'A@6-B%-/]<R'#AE-3C*)<\VF<U .6IS?3$T1U8B/CD_/3PW
-M/C G(26BYOOX^OWZ^/GT;28XDR4B(5,N) $V 4\ ^^DZ:"PB*2@H-R/%TFQ@
-M2"8?(A\A)"<A'AHC)",H+QXH,!DH'R1Y.%4[*A\B*B4I(QHX)28?'QTH*A0B
-M)R%2K&LZ)TR1BJDS+K*\02FU6LE6C,-;4C5%E$(Q.%LS-C U+30T,#DZ*28X
-MN[:QK:"6EHY^239(:Q@D8%XZ. $Z 4@ ^]$S7!\;(!\?+A[!R%M//R,@)"$C
-M)BDC(!PE)B4H+QXH,!DH'R)^-S0>&1,5'1H>&!,Q'A\<'!HE)Q$?)!M6LFDY
-M)$>%?:XQ*+JZ/">^2LI%B<-,0S9*A2XR/TXE-"XS*RXQ+3$P)"@UNK2OJY^5
-ME8UX131.;ADE85<I)P$X 48 ^^(T52 <(B$A,AO0V5Q,/RLK+"DK+"\I)B0M
-M+BTO-",M-1XM)"2+1282&!86'AH>&!0R'R >'APG*1,A)AQBPV,>"AYD6J,V
-M+;;,1RG*1-4XB\A"-RI,@R0F04\;,"HO)RDO*RTJ(20UR,;!O:VAH9F32C93
-M;AHF8E@H) $T 4@ ^^,P*C8B$QTP1R_$TFE;3B4>*"(?)"(J'B8F(R(B)1<2
-M&AH8)AUS7$,Z*",F)2$R.BTA(1\@'1@Z&A@A+25$<'JGIX^(1ELG)ZFZ62^X
-M=M%:4<!?62)!DCXU'5=#04!+.T$V%CPR*R TKL[2T-36MJ?8V&AI*R5Z9$LZ
-M+@$W 4< H,\L(RX@#QDL/RJ_R%9)0R$?*2,@*"<O(RHG)",B)1<2 QC8)A9Z
-M:3@I'AH9&A@I,2PB'QT=&A4T%!4@*21*=G21B'!F,%HB(:^Y5"W!:]%+3KY0
-M2B-$@BTU(DHU/#Y).3PS$S8G)B SKL[/T-#2L*/5TV9O+B9_:44K'0$U 48
-MH.$Q(C(E%!XQ0RC,V5A&0RDJ-"XK,"PT*#(R+RXI*AP7 QW8*QV%=D<R)1X:
-M&1@I,2LC(1\?'!<U%Q4?+R-3A6U72# Z*G W)+;082_-:MI!4,!&/A=&A"0L
-M)4LL.3I%,S<Q$3$D(QLPL]79U^#DP;+OWFMT+">!:T8I&@$Q 44 ^^,J'R4C
-M&AXG'A>>UDY+2#$@'"0?(RPO)RLD("0G%!@9'!L;(B-G+Y#09R4L."8A'Q\=
-M("(F'2([F*%.:$2+KF'GDETRFKHQ+J2O>2.PC<Y5%HA;52A3G$8E3"@\1#I*
-M0S8V,3(Q,#DFK9O$;X6H64'0RXHZ/1V"<2DT/P%8 8( GM$@&QT=%AHC&!6>
-MST,\.BH@'"0?(RPO)RLD("0C$ ,5VA<8(B%M/9/%6QHA,B,>'" >'!P?&1LS
-MD:%/7S>#JEK=@4DJEL L**FN<B.YD<=.%(%-1BQ.BC(C2R K/3A(03$Q+"TK
-M*S8EN*/)>8VK6TO4S8LZ.!Z*>28H+@%2 84 L=XH("$B&Q\H&QFEVD,\0#$G
-M(RLF+#4X,#(K)RLK%14;'!P@*R-R1Z'28AD>,R4@'B,#(<<F'APOFIPV13J3
-MN6'D?D$NF\\W*[:]?2C%F\A,%G]#.AU,CR@?2AXH.S1".RXN*2HF*#0DPK?@
-MBZ"[8U/FXI8U,R&0>R8E*P%3 84 ^]TP,",?)2 S.AHPV41.1C,?("8?,2TQ
-M'1<C(B(D(1\@*2HF)")@6QRN=2XC(1\=("0C(!PC("PWF:REGU5HJ6'.E55#
-MD, X*HZ3C1NS+,5*7CU241]"FSED)4 P3#Q%&AXU,38L*C,[J9'&<'ZM;(G4
-MPC\W1CR 7B@XA@%' ;0 ^\LF+!L7'QHM,10PU#@_."P?("8?+BHN&A<C(B(@
-M&QD:(R8C)"-E81VG;2<<'1L9'!X=&A0?'"4OF:F9ASM3GE[/CDM"C\8S)).4
-MBAFZ,+Y#7#9'2RE(E"]?(#8B1CI"%QDP+#$F)3 ZM)G+>HBT<Y77OCHR1D&-
-M9RDM= $_ ;$ ^]@N,1\;(ATP,1<WXSL_/C,F)RTF-C(V(AXJ*2DE'AP=*"LK
-M+21G9BBR<R8=(B >(2,B'QHE(28KHJ=\7$!IKVC<C3LWCM4^)YB?EA[&.K]!
-M7C0\/!]%E2E<&RX8/31 &1<M*2XA(BXYOJWBC)C ?ZCGSD4O04.-92HM=P%&
-M ;L ^^8T)!H?)2,F*R]>T3X_3$(F'AX;+A@4%A4;)"0Q('5<(R F)B5??I,H
-M'1L<'B =(1<;&4^,3B5)6,7AR2U1V-S8J58T=:Y%)&HFC2>F&F]-)TY@3AH2
-M+ADP)$ ]+1Q,%R(Q-S8O*RL_J9?*=W.M6TG:T\E$.QY:+BM11P$[ <\ JM0J
-M(!(8'AP?'BA>T#4P/CLF'AX;*A00$A(;)"0Q'7)9'QPC)B9A@),E&P,:SAP9
-M'1,7&E**2AY!7,+1MQQ#SMW6G$(C;K1 'FLKCB.M'FA&'T!/0@T %P<D&S0O
-M)AE)%!TL,C$I)B@^M)_/@7NR7U+?T\A .B%?,"U)- $O <8 ^^$R)189'QT@
-M'B=EWS<P1$(M)24B,!D5%QHB*RLV)7YA)"$K+R==?)HO'QD?("(?(Q@<'52/
-M3Q\]5\#3O"-)U>KJITH\=\-+(6PPFRFX*&E$&S=&/Q )(@XI&S$H)!E)%!LI
-M+RXD(R8]OK/FDX[!:5[NY-=%.2-A*RE'- $T =( ^]A&)BA"15\O,RA#STA2
-M1D$?("DJ%QL?'!89'B$D@L-:)!\C*!]C:(5&'!\<(1\D)4>)D:@Q+X5 9+K>
-MT;^SU]O4MU8D>:A6'QN(-2*4>3D\158C.)Z0<4HM/R0B%QXDJS,S/C4N)BHS
-MK)?#=VZ?;'76S)^R*"XP*&8^20$[ =4 ^\0^(!\W.E0F*!] SS]#.3L<("DJ
-M$Q49&!,9'B$HB,A>(AL@*")C9H5('1T<'1L@(DF.E[ Q*WXX9K;6U,.QT=O<
-MM5 D>*U3'!R*.1Z9>3$T-44/'61..!L2*1$7$Q@AJ"XN.2XH(2<QMI_&@72;
-M:GO7SI^R)2HQ)F8T-P$P <L ^]1%(R$W.5,F*!](WD-#/$ D*3(S&1H>'1L@
-M)2@PD==J)R$H,21>8HI0(!\C)2$F*D^1G+0V,'\T9+O<U+VKU.SRN3\5=[I=
-M'AV012.E@B\R+3H()6I1.!@:+Q07&!LAJ"LL-BPC'B4SP++>DX6M;(+DX["[
-M)R\T(%\L,@$P =, ^^)-/"T]*B8G&!LOV4I,0U G(1\D&" ?)2 B)"(F8-)Q
-M(" E(B5B8QFX'B8@#AAG&IJWLZ\S(1]%2L?BV%5<V-_;PTTK-%%G'V,?(R2(
-M-UU,32>89BP>&1TS@'D>(#Q#TC T0#DR*2PWJKW6@W3/5R.%QS-R.S*OD$5H
-M2@$T :D ^\E+,QXP'QL=$1,GU4 ]-DH>'",C%!P=(B B)"(J9M-O'1TE)"=?
-M7A>\'B <#A1C'J"_N+(T'Q<Z4,/7UU]@U-_=O$$D-E-G'6<@'QV',$P]2 MC
-M-A ,$!895U(/(#1!TBDM."XJ)"DUL,/8BX# 3AUVQS!L-#"SET1=. $K 9T
-M^]5')Q0P'AHD&!DNY$<]-D\J*2TO&B(B*B<I*RDT9>"!)24L*BM?61S()2,B
-M%1EH**_!Q, U(QLW3<GDYF5HX_+SQ3PE/EEL(7$K)1Z3,4$Y/ 9F.1@;'A\;
-M5U(/)2Y#VRHN-BLF(2LZO];MGH780"YVUCAO-36[D$%:,P$O :0 ^]DZ*!\9
-M%AXC'18LQU9/3E$E(D K3(TM(1\D)"$DA--['B D)2=C722-'1TBAYI0'*Z!
-MJ-0R(R-$.;O4T4<VQMS=RDDA*"\]%QH>'B-P16=30C*$'1L6&!X=%D$>'$M)
-MT24S.CH[+3$><J70>V7,-R@UO2I%,3&+?8EO/@%) << AL$U(!(7$P,7\@XD
-MQ$Q 04LB'T$L38\M'Q\D)"$HBM1Y&QTD)RE@6"*1'1<>C)M0(+*#I<\P(1LY
-M/[_3UD\XP=C?PST:*C$]%1H>'!UR/E=%0A96#!0.$!$6!BL5'$-'T1\M,S(U
-M*"X<>ZW4A6VV*1XEOR@_*3&5A(IF+0%! ;T ^\8R'!,;$Q8<'!(JT%- 05 L
-M*TPW6)<T)"8K*R@RB>&+(R4K+2U@4R>;)!HCF*97++Z!K]HR)1\V/LGBXU$\
-MS.?US#@;,C="&2$E("!Z/$<[.1MI%1,2%A07"C$9)3])UB N,2XP)3 AB\'I
-MF''+%R8?QRU$+3B?A8UF*@%% <0 ^^ C&!HA)# [*C19ST5*8%0F&"$_K,H\
-M)AXB'B(EA-"0(R(A)"IB9R*94YR8L)0E)4B/U=@M(B9%0;++W%0U8)W8S$TB
-M6$T5(2$<'Q],4&16,"V!5SQN5U\2?Y,#)DQ+T2$N1SLW+!T9;*+,=&72."\]
-MGBH],C:%<WYC-0% ;T ^\,<$1 :&R@P)"U1S#L[4TXH%2!%L\\^(ALB'B(I
-MBM&.(!\A)BQ?8B"B6)Z<MY8C(DB2TM,N(!XZ0+3+WEHS69C7Q4$;6D\5'Q\:
-M'1U-25-('2N26CUU86(8@9$&*41*TAXM0C4Q)QH7=JO4@&^]*B4PH"@W*#B4
-M>7U;*0$Z ;< ^]HE&"$A&R(M)2Y5UD([4U,P(2Q.O]Q&*",I)2DSB=Z@*"<H
-M+#!?726P9::FPYXH*E>4WN(O)"(W/;S:XE4U8*/MSCP<8E4:(R$<'Q]82$9!
-M)SVK=EJ8A80KEJ<4-T))U1PL/S L)!P<B,'JE7?5&"PCI"P\+T"@@HE?)@$[
-M ;P ^]@Q)B0M-DX@*C \&$)*658A+2$>@L5-*!TC(R$BA-"4(R(C(R=O:B.%
-MI;2PMJ,K)C6JT-PP(B)%4F'*>WY]:ZC>U%HA(!\A'Q\A(1HW0U]G50P?)Q<?
-M'Q8B&"<BBTM)SS%,'2I',T?9:Z++=FG/."P\CR4T*SM[?X1*, $F :X ^[PJ
-M'QTB*D0:)"HV&#D[2E C+!XDB\Q.)ALC(R$FBM&2(!\C)2EN92&1K;NYNZ,E
-M(SBPT-LQ(!HZ3E['>7U[9:/AS4X:(A\A'1P>'QLW.T];3@,4(0H4%PT:"Q@:
-MBD)(T"Y.'"5!+D/6>*O3A'2[+B4QD"8P(S^+AH-$)0$C :P ^\PI%!LB)3P3
-M)2LY'ST[2E,K."HKE]A9*B J*B@PB=ZD*"<J*R]M8":DP,?%R*HH)4:WW^HT
-M)!XW1F;3>WIU:*[SV$D9*"8F(1P@(1Y&04=63 TK,A4A)QDA&"8@ED1'T2Q,
-M&2 \*4C>B<'IF'_7'"PFD2DV*4>;D9%)(@$C :X ^^8S6#,S/3D1)R]=T4 \
-M1&@E)Q\@-<=;'QT@)B(GB]"B)!\C)2YE:2&!LG9BVJ(E("VNQ-HT(B1 1;.^
-MXW9<8ZS4U5(A(20A'AX?(!PH3&ME73=OE#D?&A8Z458HHEY&TC X-#H\-+O=
-M=JO+=V?3/R,_:"4N)T1L=H-++ $X 9P ^\XK22LV0#L3+3-ATCDP-V0B)!\B
-M/,M;'QX@)B$HCM&B)!\C)3!G:1V,LGQGUJ$F(#.TR-PU(!PU1;._Y&I37:O:
-MT$4:'R(?'!P='AHG1F!;32A=;B(0#0D9)S0AI55%TRTZ-S4Q,+K8?[#,AG'
-M,QLU9B<L($9Y?8)$)0$U 9P ^]TG.R<V0C\;+"U9U3@M.FDL+B8F/==L)B$G
-M+RTUCMZS*20H*CAE8B*9PX-IY:TI)3B]U.0X)" R/L+,[W%'7KGIY448)"8C
-M(" A(AXU2U511RA@<B,0#0H;+#D?IUE"UBLX-3(P*,;GE<GEGGO7("$O8B4Q
-M(4Z(B)%+(P$U :$ ^] 9'QD7-S4M&RV Q$I'-SDC'B0?'+YP)1T@*B(BA,RN
-M)!\H*RQE9B)A7(.)W*4K(2.@M]\M(1\^0ZZPY'9A7JG.UTPI(B$A'AX?(!PA
-M3EML6DX_3F-O?)I)BUU+DUU0U3<R23D],[C:;*G);F?0,R=.1R8T+TIA9(%$
-M*P$_ :H ^\,<&QLE0T(Z+D*/Q40^+SDB&R0A),-P)!T@*B$CA\VN)!\H*RYG
-M9AYL78J/V*0L(2JFNN N'Q<S0ZZPY6A65Z;5TC\B(!\?'!P='AHC2U)E3T,Q
-M,2<J-E$57SU!E%1/UC(Q2S(R+[?5<:O)<FZ])Q] /R,L)$AJ:X$]) $\ :L
-M^\0>(Q<?/CDM(R)IQDE -4 N)2LE(,B#,B0G,RTPA]J_*20M,#9E7R-V:HR,
-MY[ O)BNMR.LQ(QLP/+^_\FY)5K+AYS\@)2,C(" A(AXK249:1#DJ,C T/UL8
-M94$YE5A,V3 P23 Q)\/D?L#<AG?4%"4W.2$P(4QX=I)&(P$^ ;8 Q\HW,S!0
-M0Q=-/4JAS4] -D ='B A2,.)'1T@(R,D>,FW(R B)"0]9!YE6:64V:PO(ANC
-MG-<N(RA'/JV6WVM63Z7/UDHI)20C!2"O%T],D8M13%)_3C@S57O)2HM41L4W
-M+)I&0SNSV&RWS8N/VE0H3#AJ03M*HEB'.RX!2 &D ,?$2$) 8U0I7TY:K=%'
-M-2H^'1L@(T_'B1T=(",B)7O*MR,@(B0F/V0:<%FKF=6K,"(BJ9_8+B$@/#ZM
-MEM]=24>@U-$](B,B(04>KQM018J)3T=(>D<N)55ZP3Z)2T7&,"F9/C@WLM-R
-MOM*/E<=(($(S:3TT3*E8A#4H 44!I #'OSXV+TPY##XS/)C92S0M0R8E)R=.
-MT9PF(B<L+C)[U\@H)2<I+CU='WMHLIODMS,G(:ZMY3,E)#DYP*?N8SA#J^'F
-M/2 H)B4%(J\C43R(BTD[0'A&*!Q,><<YBT]"R2\IF#PW+[[B=\G?F9K>-28Z
-M+FA"-5*U79 Z(0%# :D ^\\R5WHL*S,Y/53%TD1/64HG)AXH5LV8(AT@)2,C
-M/\B[(R ?(2<K/QY6;(*:VJ\I'AZA@]0Y(2922JF"V(M6;9C)UD(W)B4@(2 @
-M'R$<15; XV=46X"R[&5PB]A$CE=&RC PCC\X.KG:N*ROK(;70"DQ=9*+>WM:
-M9)0M1P%$ 6L ^\A%;X\_+#I$-$+"V#M 24(D(QXJ7-"8(QX@)2(D1<B[(R ?
-M(2<I/QI?;XB?V:XJ'B6IA]4Y'R!'2*R"V'U(8I3.U#<P)",>'QX>'1\=0U"Y
-MV59"27:IW5)A@M,_D$Y%RRDJB#0P-KC6P;FWL(W$,2$K>)B+>X%@79 J0P%$
-M 6L ^\8N3'4H(#$W*#_*YSL\2T8N+2<P8]ZI)B$G+BXQ1-?,*"4D)BXK.A]O
-M?Y&DZ+HM(R2OD^(^(R-$1+R3YX,W7YS:YC8N*"<B(R(B(2,H1U' ZET]0GVU
-MYU1AC. \CE!"SB@KB3,N+L3FT=/7S)G9(R4F>)V0@(AG7)4H-P$[ 68 ^\\I
-M-SJ+BJ]+O9C,T$]+7T,A)"4P7\.=)ATB*B,@@,C!(1\C)B<H)1Y@>W*?T+XK
-M(B:G:=XU)25@4Z5DW))8:IZ8UDX\*"0A(B @'B 8-,NXTV0S4W6.TEUU<--2
-MBVA"P2TQFD,_-JJ[EIJ2EWK702LW=K<V)5E_BY-R4P%: 8P ^]LJ+CY^0WLL
-MBEC"VD8^4CPC(R0T9LB=(QL?*B0EA\O!(1\C)B,D(1IC@'>AT[\L("BV;=XU
-M(R)51ZMGVXE*7YN8VT,Q)B(?(!X>'!X0+L6TTU4I1VZ.S5%N;<Y'BU]!P28J
-MD3@Z+*NYHJB>I8K(+B,U?,,U(UZ%B(]Q4P%: 8D ^]XM,#A_9J-%JGO3[$H^
-M4STK+S ^<M>L*R G,R\QB=W2)B0H*R@I)A]SC'JGX<HO)2S$=><Z)R121+IU
-MZ95 7*.?Z$,N*B8C)"(B("(7*<J\W%$A0&R7W$YL=]U$AF$^QB<KDS<W)KC-
-MM\2[P9O4+B$YC=I!)V"$B)1P2@%5 8< ^]^@T=)1,SLH>93$U%=$8&$@("0O
-M<,"U)ATD*R4K@<?#*2$>)289(!M!A5NARLDM)2>H4MLW)1Y.2IM.UZI87U=Z
-MTEH[(B,A(B A)!\A+$Z:S6(]4V6&W%A;7-!(@VA-V34UFTA%/JBNBGV,E'+/
-M/B> ?<4]'B);;7!]>@%I 6$ ^[M.9)Q(&3 N?8G(VD\W4UHB'R,S=\6U(QLA
-M*R8PB,K#*2$>)2(5'!=$BF"CS<HN(RFW5MLW(QM#/J%1UJ%-5U=ZUT\P("$?
-M(!X?(ATC,4Z>SU,S1UZ&UTQ46<L]@U],V2XNDCU -*FLD8B4GW_#,R9_@<L\
-M%A]>;W%^? %K 6 ^^B(IL=<-4<UB9K4[5,W5%LJ*R\]@]3$*R I-#$\BMS4
-M+B8C*B<:(1Q4EF.IV]4Q*"W%7N0\)QU .[!?Y*U"4UZ!Y$\M)"4C)"(C)B$K
-M,UVHUT\K0%R/YDE28]HZ?F%)WB\OE#P]+K; JJ*JN8[*,".-D]Y*'"%<:W1_
-M=P%G 5T ^]9IV-U-+#) 9WVZS$I 1%P?)R@F?L6V)A\@)1\E>;W!)" A'1L5
-M%AHRED:>S,LL(RRG2=DU)!LQ49%!U+-189&)UU%&)24C)"NL(295:WM8T&8_
-M6&-TWU186=12DWM)Q#HRH3] -)V<=UTU>V#(02Y:.2HV(SAV<I5C<0%3 4\
-M^\5(M>)((B8U<XV_T$0S-U4A)B<JA<JV(QT=)2 J@,#!)" A'1<1$A8UFTN@
-MS\PM(2ZV3=DU(A@F19=$TZQ(6Y.)W$8[(R,A(BFJ'R1@>X=CTE<U3%QTVDA1
-M5L]'DW)(Q#,KF#0[*IZ:?60[A&B_/S-;/"PT'3=X;99F=0%6 54 ^^9NW/M5
-M*2DU>I7+Y$<S.%8I,C,TD=G%*R(E+BLV@M+2*24F(AP6%QM%ITZFW=<P)C+$
-M5>(Z)AHC0J92X;<\5IF0Z48X)R<E)BVN(RAM@YYPVE,M15I]Z45/8-Y$CG1%
-MR30LFC,X)*NNCG!"DGO+03AF/BHV(#9T:IEH< )4 /O61]+74R4F0F5WN\5!
-M/E%.*!\H*(;$PB4@(20D)V/%OB8@'R,3$A47(J ZK,/0+R0RI#O:/R0?,4Z7
-M)-"^46.+E-E;2R,E)U1D42(I)$1<A]-J75M@:]Y284'24'1O2YP[,JM$-SZ1
-MH5I18V)GN,B\7Z$I.R&(:EUO=U8!2P%) /O;4=?.4C$H.VZ%O,D_,41'*AXG
-M+HW)PB(>'B0F+6G(OB8@'R,/$!$3)J5!L,?1+R(TLS_9/2(;)D.<*-&Y2%V0
-ME-Y00"$C)5)B3QXG)D=8@=!@5D]::]E&6S[/1G-H2IHV+*(Y,C22GU]7:6IK
-MLLR_8:$C-R2.;%5P?%D"40#[Z%ODXEXT+$1ZCLG=03%$2# J,S>8V-,J(R8M
-M+C9NVL\K)20H%!06&#"R0[K3W#0G.+])Y4(F("-"J#3>QCQ6E9OK4#TF)RE6
-M9U,C*RI'9X386$U(573F0U1&VT!P:4>>-"VF-B\NG[%K7&AN?</6T7:J)#\F
-MBV=1<7Y7 5 !4P#[RE/2RV$Q.T%[;JW$34Q:/RLE)22#NKTE'R(C(1]5KKLC
-M'QTC(QPA*R"A<*>\T2TA,Y1%V4@G("<TA#+1P&)5C9S0848K+J<V?)DE(!LJ
-M+A_*95Y<7VC83U0TQDU&8DU/,S"L344[4,6.@J9C/D(G**(G*4EYF6AX?HU_
-M 4(!4 #[TUC2T& J,SB"=;+,1CU+-B@E*BJ+P< E'R(C(21;L\ E'QTC&1P9
-M(22F>ZO!TRT?-:1)V$0C'!XOA3K4N%1)CYS453LG*J4V>Y(='!TM+AO%85=0
-M6VC30TLRQD%'84A+,2VD14 Q4L2-?YU=-STG**<E($>$I&QT=HB" 44!50#[
-MXV?AY6PQ.3R+?K[@33M).C L+R^/S=(N)"DJ*"=DPLPM)B0J(R,@*!^]>\#&
-MVS0D/:I5YTHI(B MB$#BR4M$E:/F7#HM,*H[AYLA(B,K-R#05TM)4VW>0#\T
-MS3Q*8$-0+2VJ03LI6M"*?Y]6+CLN,;0J($R'I6=L8X:" 4<!6@#[OES,RFDQ
-M/T5:89[%;E5H3B@F(2M@MK\B'Q\F(R4^'+LB'1LD'Q<B*1JN9Z:NTR\@-7]@
-MS&,G(2=$0:?'R%AEB)G-?%(E)Z6*?98F)7-:O;*V7UI@5&S<6TZ$TTH_7$8M
-M&B>]3DM#A]1W8U5=<"\B)$HN'I>>@6UZC&)+ 4D!3@#[R&+/TFHM.#U@9Z++
-M9D170B4F)C%HO<(B'Q\F(R="(+\B'1LD%QL;)B&R<JFSU2\>-X]DRU\C'1X_
-M0J_*P$I9BIG1<$<C):6,?I$@(G1<O;.N54Q.3FS73T6"TSX^63\G&"2U1D8Y
-MB=-I33Q%7"$?)44G&I^EAV]V:%%: 4P!3@#[V''=YG<U/T-G;JS>;4-61RTM
-M*S9LR=0K)"8M*BU**LLK)"(K)2,B+B#.<\.XW38C/Y5PVF4I(R ]1;78T4%4
-MD*#C=T8H*JR4BYPE*G]:Q+:\34))1W'B3#F$VCD]5STH%"2[0D$QD=]7-R<P
-M2!<=)E P'Z6PCFUN5DA0 4P!4P#[NV/&R&\A/4E=746_8$=R1B<D)!UGJL$B
-M'!PC)"H<'\$D'B A'!HC+1>I9:VDU2\A)F)TT&HF)"1%.*?0S&-5?(/ CU,J
-M**.:=)<M(95,P+"M9V!44TW68EB$S4XE-E@N0BO 5CQ#<\Y03VQ6<R8E(5PN
-MOI"#44)]6690 4<!40#[R&S-TG(A.4)C8D?$7#QF0"<D*2-OL<0B'!PC)"H<
-M'\ D'B A'2$6)1VM<+"HUR\?*')XSV8B(!M .:_3Q%5)?H/$@T@H**2==Y8I
-M(Y))O["G85=&3TW15D^"S4(C,4\G0"BX3C<Y=<U#.U0_8APE(5@JPI>(4T)[
-M2V!< 4X!6P#[UWK9Y8 J04EJ9T_383EC0RXK+BASO=8K(2,J*S,A),PM)2<H
-M*"(6*1S*<\RPWS8D,'B$WFPH)AT^/+7AU4Q$A(K6BD<L+Z^KAZ(O*ZI1R[^X
-M6$L_1U+<4T.$U#T=+T\F.BB^2C(Q?=DT)T$Q82,N*& RRJ**3SUS.F%9 5 !
-M8P#[MU3"Q70C+D->*Q[$@F*;9"8G(2%5D+\@'1TD*"4<2+\D'"0F'F-17Q^G
-M8*J*T"\A($AES8 F'B)&-Z?!S5A5=%2TBUTE)YF?AIX?)BM)H*985U946#[<
-M559KPTDW&5%222VY2#8^<\\J)V(P(1T=)5ACS*13/9!F;'Z! 6P!DP#[QEW(
-MSW<C*S]C+1[)@V"78R8G)29=E\(@'1TD*"4>3< D'"0F%5@D,!RK:JV/T2\?
-M(E9JS'TB&AD_.*_&QTU+=E2Y@U(C)YVDBYT<)B9)HJM:6%%(5#_924QIPSTQ
-M$DA+1RJQ0#$V=<XE(58D'2 B)UEET:A3/I!A>(B& 7,!H@#[TFG7XH4L,T5H
-M,276AEJ/8BLN+2MAH]0I(B0K+RXB3\LM(RLM(54@-Q['<L>4W#@D*EUVVX4H
-M(!D^.;73V$-%?EG(B4\E+*FSFJLD+3%"GJUB3$5!3$+E1D)KRC@J$4A)02JW
-M/"PP>]HC'%,I(B(D(EIMW;),,HE><9*2 7X!K@#[NTJ.P(@L.T4A'BZP@T1V
-M>"HE'QY2,[\F&QXI(2,A>[@D'2,D*5]89QRC2:5LS#4C(S8N7(LD'R-(/):P
-MS5I>2R<^?T\>()6^EZ<H)3Y25IPV*UA=7(S88$MAND4W24]-4"RQ4CXW1L(B
-M'; E(R$9*:;&TK5'<E1#T]31 =@!WP#[QU&2R8@I-3TA'RRV@T)R<2HF("!9
-M.<(H&QXI(2,IB;TD'2,D(F(I/!ZH4JIQS#4A(#@T6XLD&1I .INYR5!01R%%
-M>T(;'9C%FJ<H(SQ05)XZ*U%/48G44$%@NSDK04A(3BFI23@U2<(@&JTC'1L6
-M**S+UK='=E@^U]S9 > !YP#[S%RFX9DQ.$0F("Z_B#QF;R\Q*R1;0M P(B4P
-M*"HOD,DK(B@I*U@@/!R]8K=TW3XC*#X[9Y0K'AH\/*?'VTA)3R)0@4(=)Z;1
-MJK8Q)S9,6*8U(DA&4(?C4C=?OC8H/T9%2"FM23$Q2\LE(KDH(!P6);/8XKM"
-M<%(YX^_L ?,!^P#[M3=IM8<F0#8>.HZ@;#18=" B(1\>%,$F&!LB*"8B?KLD
-M'2 H(EYS912H,)=:S3LB'2HL<IDF(B=12HVBRF1@*R!&9S F+97"@FHB)3=6
-M.H,@%UE34X[04TLD-#M,3%532BBU2CL^28T?*"\]2&6'F=;#3&MF4D-0K=;7
-M =P!W0#[NSMLOHHF/2\=.Y"E:"=(9!TC(B$C&,(F&!LB*"8JC, D'2 H(F1E
-M6AFM.9U?S3L@&2LN;YDF'!Y'1Y&IR%I,'AM,7R0B*9?(A6HB(S)1-X$?%5%'
-M2(O,0T$C-2] 1$Y.2"6M03,Y2XL=*"\]1F6)G=S(4&UG5$92LMW> >,!Y #[
-MQ$5ZU)HM/S8</)2Q<"="9B4N+24E(,\M'R(I+RTPD\PK(B4M*U]>6AO"1Z9A
-MWD0B'BXR=Z(M(1Y!1YNUVE)$'Q9392DJ.*S9EWDK)R].-X8<#TM 1XG;13<B
-M."P]0DQ+0B6Q02\V29 A+SA"2&J1J>O56G-H3SY.Q_CY ?X!_0"BLR89D),H
-M/S--1H*)B#I<?28A)!@7$K\D'1H@)"<?<KXA&P,AUEYJ8ARC(Y(VS5@C)2YU
-M0* C(2)0185)TE98+TAR+#XE*HZKDZ8C)$!7'U$E2%A+6&_)23U):S1"2&53
-M/!^B3SLW-5"DS=C=T:E^7,W7Q\K-0V_6U]W> =X!X #[LB,;FI@J0#%+2(B,
-M@RI%;2,B)1H<%+\B'1H@)"<G@,,A&R$A)&!L8QZH+9@[S5@A(S-[1*(C&QE$
-M/H=-SDQ(*49X(3(C)Y&QEJ8C(CE0&DX@0U!!4&S%.3-(;"@V0%Y..AR:1B\P
-M-$JDSMC>U*V$9-+;R\O/0G';WN3E >4!YP"BP"LAK:<P039%1)&:CBQ$<2LM
-M,!X>&L@G(B$G*RXMA\\H( ,FU%QG9"*]-YT]WF$C*#: 3*HJ(!D]/8]9X$1
-M+DJ!(34H,:' J+4L)C=.&$X>0$P[3FK4.RE';R4S/EQ+-!R>1BPN,4NKV^GK
-MXK^5=^?MT];3/V_J^03_ /N7'Q1NBR Z/T5%?'Z@2%5@)R(A(!5=P"<>&" K
-M)2!PMB(<'BDE96=G':8M>Q;,9R<D0&-(HRP=,TTQ=A[.6%-[5AY:1!PHD:"F
-MKB,D/6 I(Y132')4<Z13.FT[-#5*7TH_,&U'/#Y,-FZ)MES26"LATLLX0DI[
-MSM/AW^ !WP'= /N1&Q1[E" [/T%)@X&@/$!2)R$B)1IBOR4<&" K)2A\NR(<
-M'BDH8FMD':XT@AS+9B4H2G%/I"P7*D,J=B#)34A\6"!//!HFDJ>JKB,B-E@B
-M'HU,06=)<*-#,&HX*"E"6$4]+65 ,3=*,7*+N6+*3B$;U,\^1DU\S]GIYN<!
-MY@'D /BB(QF,I"4^1#=$CH^I/SY8+BTM*AQGRRHA'R<R+"R!QRDA(RXH8&5D
-M(L(_@QO:<BDP4GI:KS$<+#DI?R;62D6'7BA,.AXKG;*\O2PF-58@'(Q*0&9&
-M;J]%*&@Z)29 5D,W+6D_,#5&+WZ@T7786"@@Z>%%3DU]W/@$_P'] /N-(CE>
-M82,W.#XV>V>P/&18)B0D&AQFP"L>'"8B)2%?J2$>'B8C9&ME&YL;>1:]AQX:
-M1TY6JRDF'D@M+B9Q1$M<5%-<0!PFHY:<I"<C-58N>FEE6459/"9+/T1"+2A.
-M0SA$*BU&0#\_*8>JPW_(/R<BUL5!;6&OW.#>W-T!W0'A /N$&CML:Q\Y.C@U
-M@FRT-5)((R$C(21PQR@:&28C)2-JKR$<'B@C8VMD'JD=>!>]AB >45Q>K"H?
-M%4$F*BAS.SM544M2.1@CIYVDIR(?+T\F;UY?435*/"M +S8V'AU&/C4_)"=!
-M.#@Z)I:MT)/'-Q\BT\,_:EVQX>7GY>8!Y 'H /B<*D%]>R1!0B\RBWF^-D],
-M*RLO+"IXTC(@(2\N+B=KN"@A(RPL8F)A(+HE=QC$E"@F6V5BN2LF&3@G,"9[
-M/S543T5,.AXKL:BXMRTE,$XD;%U653= -RT_)R\Q'!I$/#4\)2H_-#8X)J#%
-MYZ/3/B4IZ]5#:%.U^/P%_P#[H"$Y56,A+#4M)'%<G#9M6"XA)2$@6[<L'APG
-M(R8;4W\@(!HD)%MC;2.>&CH[LY@E(44[9+@L("Y<-QDY7#E>7$Q244P='I^#
-MF* C(CM>.7!K;%T]3#NC,3U!+B<X01X=/R\E03<[-CJ"J,%\OCLH)\R^7S]Y
-MVM79X=_> =P!W0#[G1\]86T=+C<F(GEAH"Y;22P>)"@H9;XI&ADG)"8=7H4@
-M'AHF)%IC;!VE%S= M9<B(TQ':[DM&25,+AT_8#-03D9(140;'J2,H*,>'C57
-M,69@9E4M0CVI*R@M(B(V/!L:.BD?/"\T,3>3K="3OS0?(=#!7#UYX.+DY>/E
-M >4!Y #WMS%)=G\B-C\D)'UMK#)623$H,#,N;<DS("$P+R\A7XXG(Q\J+5E:
-M:1ZQ'S=#O:,J*55.;<8N("E0+A5$;#A)14%"/D =);"<M+,I)#95*UY?75DO
-M.#FH)!XF'1TP.1D:-RHB.BLR+S><QNBDS#LA)N7/6CF \?L%_P'] /N-'C)%
-M7!DV)BTE7TRG,F-7+20I'AI[M"<=&B,A(R N4!\<(QHD56=F(Y,J4F.FG"0B
-M3#-OO2<A)4I%>(HC9%ME35)D7R(GEH..D",B,59;7UQKNT\YFR5 /BTF@% X
-M'CY)(S@H-"Y#07N?NFZZB3$DQK=;:=';V]_=I]P!W@'? /N1(CA19A4X*"4C
-M:%*J*E%(*R$H)2*%NR09%R,B(R(Y5A\:(QPD5&=E'9DK5&NJFR C4CUTOB@:
-M'#Y"@(X=7$]7149652$IG8R6DQX>+%!455%ELS\ODQ\U+AX@@%(Z&SA$'3(C
-M+"<^/H^FRX;#B"TBTKU79\S>Y^C>I> !YP'F /NF+C]D=AI ,"DE:%NX,$Y&
-M,"LT,"B-QBX?'RPM+"8Z7R8?*" M4UYB(*HX6G&TIR8F64-VRRDA(#E @I@@
-M6DA-04-,32 OJ:*LHRDD*DE+2U!<MT$IER(K)AHAA4XU&3E!'C4A*"4\/IG!
-MY)G3EC,GY\9/8>'V_O_[P_P"_P#[GAHN/5H6*1TI&T5!LR=U5#,@*B$=7JTI
-M'AHB)2$?(#(;'2(?(U%F92**5T=;F:8F(C\G;K\H(24V.E@@55936%U<9&(E
-M(XZ9AS,@)#%)5V^K9#%!1BA'0B@CAE:&AW\^5B(M/2LX.D)GF*I8I(TJ(\_'
-M4E1=9VQW<GO? =T!X0#[I!XT2F,2*1TA&4Q(MAYD2#,=)R@E9;0I'!<B)B$A
-M*#@8&R(A(U!F9!Z475!FGJ4B($0M<< I'1TO/%T>24I)35)055<D*)>ECS8=
-M("Y#4&>B72LT.A@W,B @B%N.BWPY41TG.",R-3]ZH[MPK9(J(\VZ.3]$4UQG
-M9G;B >@!Z@#[LR8Y5W$8,B8H'4M1R"AA13@G,S,K;K\R(1\K,2HG*C\@("<E
-M*D]=82.G;EQPJK,G)$DR<\LL(R$C.FHC1$-!0T]+2TPA+:>ZI40G)BX\1V.B
-M5"XU-1HY*AP@C&>*AGPW3ALJ-A\M,S^'OM:#Q:$Q*NG'-#]066!K>X[\ O\
-M^Y(=+C15$B8A*2 V,+,J67 E)"0<&%RA+1P7)"$D'ADC%!TD'2(_:6DA@48F
-M2W^G(1\R+E^^)2 B(CY93CI955Q56U->*!V.FU=W&R0C/U*GH%I-0CI40B@H
-MFT>1?EC905,H-#0V-D!$4(:31)TF(B/3LWE/X.'BWN34X0+; /N2'# ^6A(C
-M'24>.S>U)DYD*2,<(AYCJ"T:%"0B)!X>*A(9(1TD06EG'HU0+56$J!X<,"Q=
-MOB4>'QTW440R3TE.2E!(4R,AF*5:>!LB(SE(IZ!.2SHK0S$=))U3G(E;T3Q.
-M(R\O+C [05^8HE*<(R$AT*YR2-C9VM;9S.4!Z 'F )JC*#A(9ALK(RLB/D/*
-M+DUG,2\J*R5LLS8?' ,MWB4A*Q8>*28H/V!C(*!@.5^0M28F-2YAQRXC(1LV
-M33XN24)%0$8^22$IJ+AJA2(D*#1"L*5)33@A."@=*:%8IXE=USE+(2TM*BLX
-M/VNMNF.S+R F[+MG1^;IZN;FW/H"_P#[E1PH,%(1(1XB'"@7K3-,<BPC*"07
-M(8$P'AHA)"8>$A<4&B$?)$5L9B5N.1LQ9*PD(B\A$TD@'B$B,4A6.6I28&)8
-M5V8H((TS?0\A($=)4UUM3B])944Q2*Y4GX=1:< Y5B@W,BLV03E4:65J(2 C
-M)=.W7RW9V]O<W^+C > !W@#[E!DH-U81'AH>&BL;LS5'<"XB)2H=*(@P'!<A
-M)28>%!H0%AX?)D=L9!]X0A\[::TA&R@>$DL@'!X=*D!,,6!&4E=-3%LC(I8\
-M?@\?'$=$2U]M0BU!4C8H2+!;K(]8;;TT42,R+2,O/#9;<VYQ(!TA(]:X72W=
-MX>'BYN;J >D!Y0#UHR,O0& :)B D'BTCPCE";#8N,3,D,9,Y(1\J,"\E&!P5
-M&R8H*D5C8""*4"M%=;HI)B\<#U$I(2 ;*3Q&+5H_24U#0E$A*J1*B1@D(5!"
-M16=R/2\_12PH4;1DO:-7:+\R3R$P*R$M.C9D@WY\+B4C*/#%5S+Y"/\ ^)4>
-M)B5)$R <&ADF&ZLL98PS*2,B$C)!(A\9(1XA'A$6%A,@(B4J<&\E8T<E-$NT
-M)R0A)&]@&!H9(QY,82Y<4EY26EE>+AY%=1DE(B)AC4Q3G4TO1%PR6)Q0J(9Z
-M1E=P/E8O03,H*$ E&#9$'R,@(230FW9/W>#AY /B N8 ^Y$:)"M-$QT8%A<E
-M&; O88<P*"0H%CE((AT6(1\C'@\2$ \=(B<L<&T>;$XF.U"U)!T=)W5D&!@6
-M'A=$5R921E!'3TY3)1U,>QDC'AQAB498GT$M/$XK6IU6LY*#2EMR-T\J/"X@
-M(3HB&CI%'2$>'R+4G71-W^'BY>GIZ@+K /B@(BDR5QPE'AX;)!Z],5F".#0O
-M,1Y"4RLB'BHJ*R44%Q44)2LK*F=I'WQ:,41<PBPF(RE\;B$=&!P60%$B3#]'
-M/45$22<I6(0>)R,A<(Y!7:,\+SI%*F"H6\"ECT)3<#9.*#HL'B [)!Y"4"$E
-M(B,FZ:-L4O7Z^_X%_P#[C1\@($ .'QL;&B9,IC)N52LG("$3("T1)ALB)2 C
-M%!X4$QX>)3AR:2%94"<O)[8L(C%[3PT@)S4>+%5F5&!-66987&4G)6<1)"$@
-M'8S;1E:20S-7)8:C6IQ^BUQ)-%!'6B(_,2LP1"DC,KPK(1\C)*MO:2W8V-W@
-MW^?F ><!Y #[B!@<)4(.'!<8&R1,IS!H3R<H)"45*#<3)!DB)B @$!8.#QP>
-M)3IR9QIB52<W+KDI(#:"61$@)3(9)4U<2E1!2UI-45<>(FL6(AX<%HW805N4
-M.S!/'XFG6J2+F&5*-U1"51TY+"0G02<A,KDH'B C)*MP92G@X^CKY.OJ >T!
-MZ@#YE2$A*DH5)!T@'BA3M#)A2B\S+B\;+C\;*1XK,2DH%AP3%"$E*CAI8QMN
-M83 [-\<Q)3N+:1TI*C07)$E61$\Z0E-#1DXB+'4;)B A'9K@/F"8-3!+&HNQ
-M8ZJ:IV4\*T] 4ALZ*B,G0RLE.<$J'B$H*;IS72_V_?__^P/_ ?T ^X8>'APV
-M%1H<'6FE/D@I3DTM(Q\B%AL8$"(<)"(D)A44$AHB(B4M<60A0V$A.ABR*A]S
-M%1LA'R$E(2I376->75)N9V-F+2,?(R8<&12TUDI.CSQW66E\=*6-A5A)0S8[
-MA5$J-2@O+SG@+AZ:'"(JF93(J=/CV][>W^+CX@+C /M\%QL:-!,8&A]NJT-*
-M)TQ(*R,?(A(@)1(>&B0D(B(1$! 8(" B*W%D&T]D'3X>MR<@=18='1PA'1@A
-M2%%33DU"7UE66"8?&Q\D&A<2MM%$4I$Y<%!H?WBKE(Q<34(U.XE/)"\C+20\
-MX2@<FQD<*Z&9R:W7YN+GY^CJZ^H"ZP#UC2 ='SD7'!XC<[104BE$0S J)BD8
-M(R46(QXK+"<G%A44'"0D*BUH71Y6<B(X(\0O(WTC)2(D*"$8(4=.349%.EM/
-M1T\G)" D)AX;%[K>15J7.6]097^ O)^79$<W*C2#224R(2<C.N0K(:8A'RZC
-MG-:YX?C[!?^!_@'_ ?X ^W8<&14J%A@:2BDL/D(C36$E)!\E%!85$Q09'R0?
-M(A,8("0A(2(F<&HA.UX:11E<'R 6'B(D'!L?*D-/75E176U98E]A/"<?'WPD
-M&1F6I$I-BD;=X9A7HYUT1D)&-T*5-3\^&S@]-DO5+1@P)1<=9'''K]O5V=W>
-MW^+CX@'B >, ^VP5%A,H%!884"\N/$ @25LC)!\E$!<:$1(7'R8?(!$6("0A
-M(1\D<&H;1V$611IB)!\2&A\>&1L7(CM%44M#3U],5517-B,;&WDA%Q>8GT52
-MBD+5VH]4K*E[3$1'-T*5-3TX%3,[*T[5)A<P(1,@:G;0N.3>XN;GZ.KKZ@'J
-M >L LWT>&!@M&!H<63@T044B058H*R8L%AH<%18;)BXF)18;)2DF)B<F9V,>
-M3F\;0!MG)AX7(@,AOR(;(#D_2D(Z1E8_2$E--R@@(($I'!N>KD-7D4CCY9%<
-MO+Q]23\Y+CF.+C<Y&#$U*E#<)18W)Q@>9WG@SOSX_ 7_@?X!_@'_ )]G'Q06
-M'1,8&!H?/CM!(59:-"(D(Q05$Q00'APJ'R(=!"'8)"4N:VPC*'47%%A1'!LA
-M'Q\C&R(I+CQ-45=?65Q65&>80B$H)$8=&1S2Y4I>@E[:WMKAH7A-04<]2HXY
-M34LHHCHV/5?92)"/C8AG9%[3T=78W=W<W^/@W@+B *!=&!$4&Q$6%AP?/CP]
-M&U!2,"(D(Q(3$1(.'!PL'R(=(0,CV"8B+&ML'31X$Q==6!P8'1L;'1@B(28T
-M0T9,5$Y12$A>DS\=)"!#&18:U-]%8X!:UMW2X*Z"3T%'.4J1.4Q'(IPU-#)9
-MV$&2E(Z+:61EW=S?X^;FY>CKZ.8"Z@"@;B$3&2 5&AHD*$,]0QY)3C8I*RH6
-M%1,4$B C-"8I)"@#*=$L*BYB92 [AA@77UHC&B(C("(@*24D+CL\0DI$1SY!
-M7I%!(BDE3R@>'MSP0V6"8.CIV.Z]BDTX."]%B3!!/R.?,RPQ7>9*F)F/C61=
-M9NWV__X%_X+\^@'^ ?\ M%,?'!H5$Q04'2,W/1@>6U8](!LA$109$A$;'B@?
-M)B B'",B'B,C8VHH'8<T:C<7$AT9&QL#'L0I/D)54DE48TQ)3:NB.B4@&T<G
-M&P^=V&)5=F#4U>2H<$L_23)<BCA-2D8DVSTX.U?93<N)655=86?4UM77V=W;
-MWN+?X@+A /M)&!D8$Q$2$A8?-T(4%E-+.2 ;(1(1%A /&1XJ(2@B)" G)B(C
-M(6-J(BF*,'!"&PT:&QP=&AL>(38Z2T<_2EE".SZAGC8A'!=#(Q@-GM)=6G9<
-MTMG@K7Y1/T<O5HP\2T9"'M4X-C!9UTO1E&!<76)NW]_=W^+FY.?JY^H!Z0'H
-M /M:(1L=&!46%ATE/$4<&DU(/R<B*!43&!(3'24R*3 J+"@O+BHJ(UIC)3"8
-M-75%(QPB(2<A'R,E)30T0STU0$\X,3ZKI#LF(1Q2,B(/J>-;7'%AY./HNHA,
-H.C\A48@V0SHZ']@V+B]=Z5W@GE]=6%9O[/?]^_S__O__^_X!_0'_
-
-end
diff --git a/Lib/test/testtar.tar b/Lib/test/testtar.tar
index 440182a437d..bb9345373e9 100644
--- a/Lib/test/testtar.tar
+++ b/Lib/test/testtar.tar
Binary files differ
diff --git a/Lib/test/tf_inherit_check.py b/Lib/test/tf_inherit_check.py
index a8b80d2726e..92ebd95e523 100644
--- a/Lib/test/tf_inherit_check.py
+++ b/Lib/test/tf_inherit_check.py
@@ -10,7 +10,7 @@ try:
fd = int(sys.argv[2])
try:
- os.write(fd, "blat")
+ os.write(fd, b"blat")
except os.error:
# Success -- could not write to fd.
sys.exit(0)
@@ -19,7 +19,7 @@ try:
sys.stderr.write("fd %d is open in child" % fd)
sys.exit(1)
-except StandardError:
+except Exception:
if verbose:
raise
sys.exit(1)
diff --git a/Lib/test/threaded_import_hangers.py b/Lib/test/threaded_import_hangers.py
index d7508741d3f..adf03e31ffd 100644
--- a/Lib/test/threaded_import_hangers.py
+++ b/Lib/test/threaded_import_hangers.py
@@ -29,7 +29,7 @@ class Worker(threading.Thread):
for name, func, args in [
# Bug 147376: TemporaryFile hung on Windows, starting in Python 2.4.
- ("tempfile.TemporaryFile", tempfile.TemporaryFile, ()),
+ ("tempfile.TemporaryFile", lambda: tempfile.TemporaryFile().close(), ()),
# The real cause for bug 147376: ntpath.abspath() caused the hang.
("os.path.abspath", os.path.abspath, ('.',)),
diff --git a/Lib/test/time_hashlib.py b/Lib/test/time_hashlib.py
index 1bf707da19b..d9394630638 100644
--- a/Lib/test/time_hashlib.py
+++ b/Lib/test/time_hashlib.py
@@ -6,7 +6,7 @@ import hashlib
def creatorFunc():
- raise RuntimeError, "eek, creatorFunc not overridden"
+ raise RuntimeError("eek, creatorFunc not overridden")
def test_scaled_msg(scale, name):
iterations = 106201/scale * 20
@@ -14,27 +14,27 @@ def test_scaled_msg(scale, name):
localCF = creatorFunc
start = time.time()
- for f in xrange(iterations):
+ for f in range(iterations):
x = localCF(longStr).digest()
end = time.time()
- print ('%2.2f' % (end-start)), "seconds", iterations, "x", len(longStr), "bytes", name
+ print(('%2.2f' % (end-start)), "seconds", iterations, "x", len(longStr), "bytes", name)
def test_create():
start = time.time()
- for f in xrange(20000):
+ for f in range(20000):
d = creatorFunc()
end = time.time()
- print ('%2.2f' % (end-start)), "seconds", '[20000 creations]'
+ print(('%2.2f' % (end-start)), "seconds", '[20000 creations]')
def test_zero():
start = time.time()
- for f in xrange(20000):
+ for f in range(20000):
x = creatorFunc().digest()
end = time.time()
- print ('%2.2f' % (end-start)), "seconds", '[20000 "" digests]'
+ print(('%2.2f' % (end-start)), "seconds", '[20000 "" digests]')
@@ -44,35 +44,35 @@ hName = sys.argv[1]
# setup our creatorFunc to test the requested hash
#
if hName in ('_md5', '_sha'):
- exec 'import '+hName
- exec 'creatorFunc = '+hName+'.new'
- print "testing speed of old", hName, "legacy interface"
+ exec('import '+hName)
+ exec('creatorFunc = '+hName+'.new')
+ print("testing speed of old", hName, "legacy interface")
elif hName == '_hashlib' and len(sys.argv) > 3:
import _hashlib
- exec 'creatorFunc = _hashlib.%s' % sys.argv[2]
- print "testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2])
+ exec('creatorFunc = _hashlib.%s' % sys.argv[2])
+ print("testing speed of _hashlib.%s" % sys.argv[2], getattr(_hashlib, sys.argv[2]))
elif hName == '_hashlib' and len(sys.argv) == 3:
import _hashlib
- exec 'creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2]
- print "testing speed of _hashlib.new(%r)" % sys.argv[2]
-elif hasattr(hashlib, hName) and callable(getattr(hashlib, hName)):
+ exec('creatorFunc = lambda x=_hashlib.new : x(%r)' % sys.argv[2])
+ print("testing speed of _hashlib.new(%r)" % sys.argv[2])
+elif hasattr(hashlib, hName) and hasattr(getattr(hashlib, hName), '__call__'):
creatorFunc = getattr(hashlib, hName)
- print "testing speed of hashlib."+hName, getattr(hashlib, hName)
+ print("testing speed of hashlib."+hName, getattr(hashlib, hName))
else:
- exec "creatorFunc = lambda x=hashlib.new : x(%r)" % hName
- print "testing speed of hashlib.new(%r)" % hName
+ exec("creatorFunc = lambda x=hashlib.new : x(%r)" % hName)
+ print("testing speed of hashlib.new(%r)" % hName)
try:
test_create()
except ValueError:
- print
- print "pass argument(s) naming the hash to run a speed test on:"
- print " '_md5' and '_sha' test the legacy builtin md5 and sha"
- print " '_hashlib' 'openssl_hName' 'fast' tests the builtin _hashlib"
- print " '_hashlib' 'hName' tests builtin _hashlib.new(shaFOO)"
- print " 'hName' tests the hashlib.hName() implementation if it exists"
- print " otherwise it uses hashlib.new(hName)."
- print
+ print()
+ print("pass argument(s) naming the hash to run a speed test on:")
+ print(" '_md5' and '_sha' test the legacy builtin md5 and sha")
+ print(" '_hashlib' 'openssl_hName' 'fast' tests the builtin _hashlib")
+ print(" '_hashlib' 'hName' tests builtin _hashlib.new(shaFOO)")
+ print(" 'hName' tests the hashlib.hName() implementation if it exists")
+ print(" otherwise it uses hashlib.new(hName).")
+ print()
raise
test_zero()
diff --git a/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt b/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt
new file mode 100644
index 00000000000..2f53718dace
--- /dev/null
+++ b/Lib/test/tokenize_tests-latin1-coding-cookie-and-utf8-bom-sig.txt
@@ -0,0 +1,13 @@
+# -*- coding: latin1 -*-
+# IMPORTANT: this file has the utf-8 BOM signature '\xef\xbb\xbf'
+# at the start of it. Make sure this is preserved if any changes
+# are made! Also note that the coding cookie above conflicts with
+# the presense of a utf-8 BOM signature -- this is intended.
+
+# Arbitrary encoded utf-8 text (stolen from test_doctest2.py).
+x = 'ЉЊЈÐЂ'
+def y():
+ """
+ And again in a comment. ЉЊЈÐЂ
+ """
+ pass
diff --git a/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt b/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt
new file mode 100644
index 00000000000..81931c46985
--- /dev/null
+++ b/Lib/test/tokenize_tests-no-coding-cookie-and-utf8-bom-sig-only.txt
@@ -0,0 +1,11 @@
+# IMPORTANT: this file has the utf-8 BOM signature '\xef\xbb\xbf'
+# at the start of it. Make sure this is preserved if any changes
+# are made!
+
+# Arbitrary encoded utf-8 text (stolen from test_doctest2.py).
+x = 'ЉЊЈÐЂ'
+def y():
+ """
+ And again in a comment. ЉЊЈÐЂ
+ """
+ pass
diff --git a/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt b/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt
new file mode 100644
index 00000000000..04561e48472
--- /dev/null
+++ b/Lib/test/tokenize_tests-utf8-coding-cookie-and-no-utf8-bom-sig.txt
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# IMPORTANT: unlike the other test_tokenize-*.txt files, this file
+# does NOT have the utf-8 BOM signature '\xef\xbb\xbf' at the start
+# of it. Make sure this is not added inadvertently by your editor
+# if any changes are made to this file!
+
+# Arbitrary encoded utf-8 text (stolen from test_doctest2.py).
+x = 'ЉЊЈÐЂ'
+def y():
+ """
+ And again in a comment. ЉЊЈÐЂ
+ """
+ pass
diff --git a/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt b/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt
new file mode 100644
index 00000000000..74568a7ecb5
--- /dev/null
+++ b/Lib/test/tokenize_tests-utf8-coding-cookie-and-utf8-bom-sig.txt
@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+# IMPORTANT: this file has the utf-8 BOM signature '\xef\xbb\xbf'
+# at the start of it. Make sure this is preserved if any changes
+# are made!
+
+# Arbitrary encoded utf-8 text (stolen from test_doctest2.py).
+x = 'ЉЊЈÐЂ'
+def y():
+ """
+ And again in a comment. ЉЊЈÐЂ
+ """
+ pass
diff --git a/Lib/test/tokenize_tests.txt b/Lib/test/tokenize_tests.txt
index 4ef3bf134aa..06c83b0a848 100644
--- a/Lib/test/tokenize_tests.txt
+++ b/Lib/test/tokenize_tests.txt
@@ -21,7 +21,7 @@ y = [3, 4,
5]
z = {'a':5,
'b':6}
-x = (len(`y`) + 5*x - a[
+x = (len(repr(y)) + 5*x - a[
3 ]
- x + len({
}
@@ -36,22 +36,22 @@ x = 1 \
x = 0
# Ordinary integers
-0xff <> 255
-0377 <> 255
-2147483647 != 017777777777
--2147483647-1 != 020000000000
-037777777777 != -1
-0xffffffff != -1
+0xff != 255
+0o377 != 255
+2147483647 != 0o17777777777
+-2147483647-1 != 0o20000000000
+0o37777777777 != -1
+0xffffffff != -1; 0o37777777777 != -1; -0o1234567 == 0O001234567; 0b10101 == 0B00010101
# Long integers
-x = 0L
-x = 0l
-x = 0xffffffffffffffffL
-x = 0xffffffffffffffffl
-x = 077777777777777777L
-x = 077777777777777777l
-x = 123456789012345678901234567890L
-x = 123456789012345678901234567890l
+x = 0
+x = 0
+x = 0xffffffffffffffff
+x = 0xffffffffffffffff
+x = 0o77777777777777777
+x = 0B11101010111111111
+x = 123456789012345678901234567890
+x = 123456789012345678901234567890
# Floating-point numbers
x = 3.14
@@ -110,19 +110,19 @@ y = r"""foo
bar \\ baz
""" + R'''spam
'''
-x = u'abc' + U'ABC'
-y = u"abc" + U"ABC"
-x = ur'abc' + Ur'ABC' + uR'ABC' + UR'ABC'
-y = ur"abc" + Ur"ABC" + uR"ABC" + UR"ABC"
-x = ur'\\' + UR'\\'
-x = ur'\'' + ''
-y = ur'''
+x = b'abc' + B'ABC'
+y = b"abc" + B"ABC"
+x = br'abc' + Br'ABC' + bR'ABC' + BR'ABC'
+y = br"abc" + Br"ABC" + bR"ABC" + BR"ABC"
+x = br'\\' + BR'\\'
+x = br'\'' + ''
+y = br'''
foo bar \\
-baz''' + UR'''
+baz''' + BR'''
foo'''
-y = Ur"""foo
+y = Br"""foo
bar \\ baz
-""" + uR'''spam
+""" + bR'''spam
'''
# Indentation
@@ -146,10 +146,10 @@ if 0:
def d22(a, b, c=1, d=2): pass
def d01v(a=1, *restt, **restd): pass
-(x, y) <> ({'a':1}, {'b':2})
+(x, y) != ({'a':1}, {'b':2})
# comparison
-if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass
+if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 != 1 in 1 not in 1 is 1 is not 1: pass
# binary
x = 1 & 1
@@ -176,3 +176,6 @@ x = sys.modules['time'].time()
@staticmethod
def foo(): pass
+@staticmethod
+def foo(x:1)->1: pass
+
diff --git a/Lib/test/win_console_handler.py b/Lib/test/win_console_handler.py
index 0ffcee2e914..e7779b93635 100644
--- a/Lib/test/win_console_handler.py
+++ b/Lib/test/win_console_handler.py
@@ -40,9 +40,9 @@ if __name__ == "__main__":
print("Unable to add SetConsoleCtrlHandler")
exit(-1)
- # Awaken mail process
+ # Awake main process
m = mmap.mmap(-1, 1, sys.argv[1])
- m[0] = '1'
+ m[0] = 1
# Do nothing but wait for the signal
while True:
diff --git a/Lib/test/wrongcert.pem b/Lib/test/wrongcert.pem
deleted file mode 100644
index 5f92f9bce76..00000000000
--- a/Lib/test/wrongcert.pem
+++ /dev/null
@@ -1,32 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnH
-FlbsVUg2Xtk6+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6T
-f9lnNTwpSoeK24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQAB
-AoGAQFko4uyCgzfxr4Ezb4Mp5pN3Npqny5+Jey3r8EjSAX9Ogn+CNYgoBcdtFgbq
-1yif/0sK7ohGBJU9FUCAwrqNBI9ZHB6rcy7dx+gULOmRBGckln1o5S1+smVdmOsW
-7zUVLBVByKuNWqTYFlzfVd6s4iiXtAE2iHn3GCyYdlICwrECQQDhMQVxHd3EFbzg
-SFmJBTARlZ2GKA3c1g/h9/XbkEPQ9/RwI3vnjJ2RaSnjlfoLl8TOcf0uOGbOEyFe
-19RvCLXjAkEA1s+UE5ziF+YVkW3WolDCQ2kQ5WG9+ccfNebfh6b67B7Ln5iG0Sbg
-ky9cjsO3jbMJQtlzAQnH1850oRD5Gi51dQJAIbHCDLDZU9Ok1TI+I2BhVuA6F666
-lEZ7TeZaJSYq34OaUYUdrwG9OdqwZ9sy9LUav4ESzu2lhEQchCJrKMn23QJAReqs
-ZLHUeTjfXkVk7dHhWPWSlUZ6AhmIlA/AQ7Payg2/8wM/JkZEJEPvGVykms9iPUrv
-frADRr+hAGe43IewnQJBAJWKZllPgKuEBPwoEldHNS8nRu61D7HzxEzQ2xnfj+Nk
-2fgf1MAzzTRsikfGENhVsVWeqOcijWb6g5gsyCmlRpc=
------END RSA PRIVATE KEY-----
------BEGIN CERTIFICATE-----
-MIICsDCCAhmgAwIBAgIJAOqYOYFJfEEoMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNV
-BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
-aWRnaXRzIFB0eSBMdGQwHhcNMDgwNjI2MTgxNTUyWhcNMDkwNjI2MTgxNTUyWjBF
-MQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50
-ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
-gQC89ZNxjTgWgq7Z1g0tJ65w+k7lNAj5IgjLb155UkUrz0XsHDnHFlbsVUg2Xtk6
-+bo2UEYIzN7cIm5ImpmyW/2z0J1IDVDlvR2xJ659xrE0v5c2cB6Tf9lnNTwpSoeK
-24Nd7Jwq4j9vk95fLrdqsBq0/KVlsCXeixS/CaqqduXfvwIDAQABo4GnMIGkMB0G
-A1UdDgQWBBTctMtI3EO9OjLI0x9Zo2ifkwIiNjB1BgNVHSMEbjBsgBTctMtI3EO9
-OjLI0x9Zo2ifkwIiNqFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUt
-U3RhdGUxITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAOqYOYFJ
-fEEoMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAQwa7jya/DfhaDn7E
-usPkpgIX8WCL2B1SqnRTXEZfBPPVq/cUmFGyEVRVATySRuMwi8PXbVcOhXXuocA+
-43W+iIsD9pXapCZhhOerCq18TC1dWK98vLUsoK8PMjB6e5H/O8bqojv0EeC+fyCw
-eSHj5jpC8iZKjCHBn+mAi4cQ514=
------END CERTIFICATE-----
diff --git a/Lib/test/xmltests.py b/Lib/test/xmltests.py
index d203709221f..0bfcba181e8 100644
--- a/Lib/test/xmltests.py
+++ b/Lib/test/xmltests.py
@@ -2,9 +2,9 @@
# standard library.
import sys
-import test.test_support
+import test.support
-test.test_support.verbose = 0
+test.support.verbose = 0
def runtest(name):
__import__(name)
@@ -17,5 +17,4 @@ runtest("test.test_pyexpat")
runtest("test.test_sax")
runtest("test.test_xml_etree")
runtest("test.test_xml_etree_c")
-runtest("test.test_xmllib")
runtest("test.test_xmlrpc")
diff --git a/Lib/test/zip_cp437_header.zip b/Lib/test/zip_cp437_header.zip
new file mode 100644
index 00000000000..f7c6cf17042
--- /dev/null
+++ b/Lib/test/zip_cp437_header.zip
Binary files differ
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index 62ea0b48e6c..dfb400548bd 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -5,26 +5,8 @@
# Copyright (C) 2002, 2003 Python Software Foundation.
# Written by Greg Ward <gward@python.net>
-__revision__ = "$Id$"
-
import string, re
-try:
- _unicode = unicode
-except NameError:
- # If Python is built without Unicode support, the unicode type
- # will not exist. Fake one.
- class _unicode(object):
- pass
-
-# Do the right thing with boolean values for all known Python versions
-# (so this module can be copied to projects that don't depend on Python
-# 2.3, e.g. Optik and Docutils) by uncommenting the block of code below.
-#try:
-# True, False
-#except NameError:
-# (True, False) = (1, 0)
-
__all__ = ['TextWrapper', 'wrap', 'fill', 'dedent']
# Hardcode the recognized whitespace characters to the US-ASCII
@@ -79,12 +61,10 @@ class TextWrapper:
Drop leading and trailing whitespace from lines.
"""
- whitespace_trans = string.maketrans(_whitespace, ' ' * len(_whitespace))
-
unicode_whitespace_trans = {}
- uspace = ord(u' ')
- for x in map(ord, _whitespace):
- unicode_whitespace_trans[x] = uspace
+ uspace = ord(' ')
+ for x in _whitespace:
+ unicode_whitespace_trans[ord(x)] = uspace
# This funky little regex is just the trick for splitting
# text up into word-wrappable chunks. E.g.
@@ -105,11 +85,10 @@ class TextWrapper:
# XXX this is not locale- or charset-aware -- string.lowercase
# is US-ASCII only (and therefore English-only)
- sentence_end_re = re.compile(r'[%s]' # lowercase letter
+ sentence_end_re = re.compile(r'[a-z]' # lowercase letter
r'[\.\!\?]' # sentence-ending punct.
r'[\"\']?' # optional end-of-quote
- r'\Z' # end of chunk
- % string.lowercase)
+ r'\Z') # end of chunk
def __init__(self,
@@ -132,13 +111,6 @@ class TextWrapper:
self.drop_whitespace = drop_whitespace
self.break_on_hyphens = break_on_hyphens
- # recompile the regexes for Unicode mode -- done in this clumsy way for
- # backwards compatibility because it's rather common to monkey-patch
- # the TextWrapper class' wordsep_re attribute.
- self.wordsep_re_uni = re.compile(self.wordsep_re.pattern, re.U)
- self.wordsep_simple_re_uni = re.compile(
- self.wordsep_simple_re.pattern, re.U)
-
# -- Private methods -----------------------------------------------
# (possibly useful for subclasses to override)
@@ -153,10 +125,7 @@ class TextWrapper:
if self.expand_tabs:
text = text.expandtabs()
if self.replace_whitespace:
- if isinstance(text, str):
- text = text.translate(self.whitespace_trans)
- elif isinstance(text, _unicode):
- text = text.translate(self.unicode_whitespace_trans)
+ text = text.translate(self.unicode_whitespace_trans)
return text
@@ -175,18 +144,11 @@ class TextWrapper:
'use', ' ', 'the', ' ', '-b', ' ', option!'
otherwise.
"""
- if isinstance(text, _unicode):
- if self.break_on_hyphens:
- pat = self.wordsep_re_uni
- else:
- pat = self.wordsep_simple_re_uni
+ if self.break_on_hyphens is True:
+ chunks = self.wordsep_re.split(text)
else:
- if self.break_on_hyphens:
- pat = self.wordsep_re
- else:
- pat = self.wordsep_simple_re
- chunks = pat.split(text)
- chunks = filter(None, chunks) # remove empty chunks
+ chunks = self.wordsep_simple_re.split(text)
+ chunks = [c for c in chunks if c]
return chunks
def _fix_sentence_endings(self, chunks):
@@ -422,4 +384,4 @@ def dedent(text):
if __name__ == "__main__":
#print dedent("\tfoo\n\tbar")
#print dedent(" \thello there\n \t how are you?")
- print dedent("Hello there.\n This is indented.")
+ print(dedent("Hello there.\n This is indented."))
diff --git a/Lib/this.py b/Lib/this.py
index 37754b785ab..e68dd3ff39b 100644
--- a/Lib/this.py
+++ b/Lib/this.py
@@ -25,4 +25,4 @@ for c in (65, 97):
for i in range(26):
d[chr(i+c)] = chr((i+13) % 26 + c)
-print "".join([d.get(c, c) for c in s])
+print("".join([d.get(c, c) for c in s]))
diff --git a/Lib/threading.py b/Lib/threading.py
index db9ab29c7da..58ffa7ebc27 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -1,53 +1,40 @@
"""Thread module emulating a subset of Java's threading model."""
import sys as _sys
+import _thread
-try:
- import thread
-except ImportError:
- del _sys.modules[__name__]
- raise
-
-import warnings
-
-from collections import deque as _deque
from time import time as _time, sleep as _sleep
from traceback import format_exc as _format_exc
+from _weakrefset import WeakSet
-# Note regarding PEP 8 compliant aliases
+# Note regarding PEP 8 compliant names
# This threading model was originally inspired by Java, and inherited
# the convention of camelCase function and method names from that
-# language. While those names are not in any imminent danger of being
-# deprecated, starting with Python 2.6, the module now provides a
-# PEP 8 compliant alias for any such method name.
-# Using the new PEP 8 compliant names also facilitates substitution
+# language. Those originaly names are not in any imminent danger of
+# being deprecated (even for Py3k),so this module provides them as an
+# alias for the PEP 8 compliant names
+# Note that using the new PEP 8 compliant names facilitates substitution
# with the multiprocessing module, which doesn't provide the old
# Java inspired names.
-
-# Rename some stuff so "from threading import *" is safe
-__all__ = ['activeCount', 'active_count', 'Condition', 'currentThread',
- 'current_thread', 'enumerate', 'Event',
- 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread',
+__all__ = ['active_count', 'Condition', 'current_thread', 'enumerate', 'Event',
+ 'Lock', 'RLock', 'Semaphore', 'BoundedSemaphore', 'Thread', 'Barrier',
'Timer', 'setprofile', 'settrace', 'local', 'stack_size']
-_start_new_thread = thread.start_new_thread
-_allocate_lock = thread.allocate_lock
-_get_ident = thread.get_ident
-ThreadError = thread.error
-del thread
-
+# Rename some stuff so "from threading import *" is safe
+_start_new_thread = _thread.start_new_thread
+_allocate_lock = _thread.allocate_lock
+_get_ident = _thread.get_ident
+ThreadError = _thread.error
+try:
+ _CRLock = _thread.RLock
+except AttributeError:
+ _CRLock = None
+TIMEOUT_MAX = _thread.TIMEOUT_MAX
+del _thread
-# sys.exc_clear is used to work around the fact that except blocks
-# don't fully clear the exception until 3.0.
-warnings.filterwarnings('ignore', category=DeprecationWarning,
- module='threading', message='sys.exc_clear')
# Debug support (adapted from ihooks.py).
-# All the major classes here derive from _Verbose. We force that to
-# be a new-style class so that all the major classes here are new-style.
-# This helps debugging (type(instance) is more revealing for instances
-# of new-style classes).
_VERBOSE = False
@@ -58,10 +45,10 @@ if __debug__:
def __init__(self, verbose=None):
if verbose is None:
verbose = _VERBOSE
- self.__verbose = verbose
+ self._verbose = verbose
def _note(self, format, *args):
- if self.__verbose:
+ if self._verbose:
format = format % args
# Issue #4188: calling current_thread() can incur an infinite
# recursion if it has to create a DummyThread on the fly.
@@ -98,37 +85,41 @@ def settrace(func):
Lock = _allocate_lock
-def RLock(*args, **kwargs):
- return _RLock(*args, **kwargs)
+def RLock(verbose=None, *args, **kwargs):
+ if verbose is None:
+ verbose = _VERBOSE
+ if (__debug__ and verbose) or _CRLock is None:
+ return _PyRLock(verbose, *args, **kwargs)
+ return _CRLock(*args, **kwargs)
class _RLock(_Verbose):
def __init__(self, verbose=None):
_Verbose.__init__(self, verbose)
- self.__block = _allocate_lock()
- self.__owner = None
- self.__count = 0
+ self._block = _allocate_lock()
+ self._owner = None
+ self._count = 0
def __repr__(self):
- owner = self.__owner
+ owner = self._owner
try:
owner = _active[owner].name
except KeyError:
pass
return "<%s owner=%r count=%d>" % (
- self.__class__.__name__, owner, self.__count)
+ self.__class__.__name__, owner, self._count)
- def acquire(self, blocking=1):
+ def acquire(self, blocking=True, timeout=-1):
me = _get_ident()
- if self.__owner == me:
- self.__count = self.__count + 1
+ if self._owner == me:
+ self._count = self._count + 1
if __debug__:
self._note("%s.acquire(%s): recursive success", self, blocking)
return 1
- rc = self.__block.acquire(blocking)
+ rc = self._block.acquire(blocking, timeout)
if rc:
- self.__owner = me
- self.__count = 1
+ self._owner = me
+ self._count = 1
if __debug__:
self._note("%s.acquire(%s): initial success", self, blocking)
else:
@@ -139,12 +130,12 @@ class _RLock(_Verbose):
__enter__ = acquire
def release(self):
- if self.__owner != _get_ident():
+ if self._owner != _get_ident():
raise RuntimeError("cannot release un-acquired lock")
- self.__count = count = self.__count - 1
+ self._count = count = self._count - 1
if not count:
- self.__owner = None
- self.__block.release()
+ self._owner = None
+ self._block.release()
if __debug__:
self._note("%s.release(): final release", self)
else:
@@ -156,26 +147,26 @@ class _RLock(_Verbose):
# Internal methods used by condition variables
- def _acquire_restore(self, count_owner):
- count, owner = count_owner
- self.__block.acquire()
- self.__count = count
- self.__owner = owner
+ def _acquire_restore(self, state):
+ self._block.acquire()
+ self._count, self._owner = state
if __debug__:
self._note("%s._acquire_restore()", self)
def _release_save(self):
if __debug__:
self._note("%s._release_save()", self)
- count = self.__count
- self.__count = 0
- owner = self.__owner
- self.__owner = None
- self.__block.release()
+ count = self._count
+ self._count = 0
+ owner = self._owner
+ self._owner = None
+ self._block.release()
return (count, owner)
def _is_owned(self):
- return self.__owner == _get_ident()
+ return self._owner == _get_ident()
+
+_PyRLock = _RLock
def Condition(*args, **kwargs):
@@ -187,7 +178,7 @@ class _Condition(_Verbose):
_Verbose.__init__(self, verbose)
if lock is None:
lock = RLock()
- self.__lock = lock
+ self._lock = lock
# Export the lock's acquire() and release() methods
self.acquire = lock.acquire
self.release = lock.release
@@ -206,28 +197,28 @@ class _Condition(_Verbose):
self._is_owned = lock._is_owned
except AttributeError:
pass
- self.__waiters = []
+ self._waiters = []
def __enter__(self):
- return self.__lock.__enter__()
+ return self._lock.__enter__()
def __exit__(self, *args):
- return self.__lock.__exit__(*args)
+ return self._lock.__exit__(*args)
def __repr__(self):
- return "<Condition(%s, %d)>" % (self.__lock, len(self.__waiters))
+ return "<Condition(%s, %d)>" % (self._lock, len(self._waiters))
def _release_save(self):
- self.__lock.release() # No state to save
+ self._lock.release() # No state to save
def _acquire_restore(self, x):
- self.__lock.acquire() # Ignore saved state
+ self._lock.acquire() # Ignore saved state
def _is_owned(self):
# Return True if lock is owned by current_thread.
# This method is called only if __lock doesn't have _is_owned().
- if self.__lock.acquire(0):
- self.__lock.release()
+ if self._lock.acquire(0):
+ self._lock.release()
return False
else:
return True
@@ -237,47 +228,63 @@ class _Condition(_Verbose):
raise RuntimeError("cannot wait on un-acquired lock")
waiter = _allocate_lock()
waiter.acquire()
- self.__waiters.append(waiter)
+ self._waiters.append(waiter)
saved_state = self._release_save()
try: # restore state no matter what (e.g., KeyboardInterrupt)
if timeout is None:
waiter.acquire()
+ gotit = True
if __debug__:
self._note("%s.wait(): got it", self)
else:
- # Balancing act: We can't afford a pure busy loop, so we
- # have to sleep; but if we sleep the whole timeout time,
- # we'll be unresponsive. The scheme here sleeps very
- # little at first, longer as time goes on, but never longer
- # than 20 times per second (or the timeout time remaining).
- endtime = _time() + timeout
- delay = 0.0005 # 500 us -> initial delay of 1 ms
- while True:
- gotit = waiter.acquire(0)
- if gotit:
- break
- remaining = endtime - _time()
- if remaining <= 0:
- break
- delay = min(delay * 2, remaining, .05)
- _sleep(delay)
+ if timeout > 0:
+ gotit = waiter.acquire(True, timeout)
+ else:
+ gotit = waiter.acquire(False)
if not gotit:
if __debug__:
self._note("%s.wait(%s): timed out", self, timeout)
try:
- self.__waiters.remove(waiter)
+ self._waiters.remove(waiter)
except ValueError:
pass
else:
if __debug__:
self._note("%s.wait(%s): got it", self, timeout)
+ return gotit
finally:
self._acquire_restore(saved_state)
+ def wait_for(self, predicate, timeout=None):
+ endtime = None
+ waittime = timeout
+ result = predicate()
+ while not result:
+ if waittime is not None:
+ if endtime is None:
+ endtime = _time() + waittime
+ else:
+ waittime = endtime - _time()
+ if waittime <= 0:
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Timed out.",
+ self, predicate, timeout)
+ break
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Waiting with timeout=%s.",
+ self, predicate, timeout, waittime)
+ self.wait(waittime)
+ result = predicate()
+ else:
+ if __debug__:
+ self._note("%s.wait_for(%r, %r): Success.",
+ self, predicate, timeout)
+ return result
+
def notify(self, n=1):
if not self._is_owned():
raise RuntimeError("cannot notify on un-acquired lock")
- __waiters = self.__waiters
+ __waiters = self._waiters
waiters = __waiters[:n]
if not waiters:
if __debug__:
@@ -292,10 +299,10 @@ class _Condition(_Verbose):
except ValueError:
pass
- def notifyAll(self):
- self.notify(len(self.__waiters))
+ def notify_all(self):
+ self.notify(len(self._waiters))
- notify_all = notifyAll
+ notifyAll = notify_all
def Semaphore(*args, **kwargs):
@@ -309,38 +316,48 @@ class _Semaphore(_Verbose):
if value < 0:
raise ValueError("semaphore initial value must be >= 0")
_Verbose.__init__(self, verbose)
- self.__cond = Condition(Lock())
- self.__value = value
+ self._cond = Condition(Lock())
+ self._value = value
- def acquire(self, blocking=1):
+ def acquire(self, blocking=True, timeout=None):
+ if not blocking and timeout is not None:
+ raise ValueError("can't specify timeout for non-blocking acquire")
rc = False
- self.__cond.acquire()
- while self.__value == 0:
+ endtime = None
+ self._cond.acquire()
+ while self._value == 0:
if not blocking:
break
if __debug__:
self._note("%s.acquire(%s): blocked waiting, value=%s",
- self, blocking, self.__value)
- self.__cond.wait()
+ self, blocking, self._value)
+ if timeout is not None:
+ if endtime is None:
+ endtime = _time() + timeout
+ else:
+ timeout = endtime - _time()
+ if timeout <= 0:
+ break
+ self._cond.wait(timeout)
else:
- self.__value = self.__value - 1
+ self._value = self._value - 1
if __debug__:
self._note("%s.acquire: success, value=%s",
- self, self.__value)
+ self, self._value)
rc = True
- self.__cond.release()
+ self._cond.release()
return rc
__enter__ = acquire
def release(self):
- self.__cond.acquire()
- self.__value = self.__value + 1
+ self._cond.acquire()
+ self._value = self._value + 1
if __debug__:
self._note("%s.release: success, value=%s",
- self, self.__value)
- self.__cond.notify()
- self.__cond.release()
+ self, self._value)
+ self._cond.notify()
+ self._cond.release()
def __exit__(self, t, v, tb):
self.release()
@@ -356,8 +373,8 @@ class _BoundedSemaphore(_Semaphore):
self._initial_value = value
def release(self):
- if self._Semaphore__value >= self._initial_value:
- raise ValueError, "Semaphore released too many times"
+ if self._value >= self._initial_value:
+ raise ValueError("Semaphore released too many times")
return _Semaphore.release(self)
@@ -370,41 +387,213 @@ class _Event(_Verbose):
def __init__(self, verbose=None):
_Verbose.__init__(self, verbose)
- self.__cond = Condition(Lock())
- self.__flag = False
+ self._cond = Condition(Lock())
+ self._flag = False
def _reset_internal_locks(self):
# private! called by Thread._reset_internal_locks by _after_fork()
- self.__cond.__init__()
+ self._cond.__init__()
- def isSet(self):
- return self.__flag
+ def is_set(self):
+ return self._flag
- is_set = isSet
+ isSet = is_set
def set(self):
- self.__cond.acquire()
+ self._cond.acquire()
try:
- self.__flag = True
- self.__cond.notify_all()
+ self._flag = True
+ self._cond.notify_all()
finally:
- self.__cond.release()
+ self._cond.release()
def clear(self):
- self.__cond.acquire()
+ self._cond.acquire()
try:
- self.__flag = False
+ self._flag = False
finally:
- self.__cond.release()
+ self._cond.release()
def wait(self, timeout=None):
- self.__cond.acquire()
+ self._cond.acquire()
try:
- if not self.__flag:
- self.__cond.wait(timeout)
- return self.__flag
+ signaled = self._flag
+ if not signaled:
+ signaled = self._cond.wait(timeout)
+ return signaled
finally:
- self.__cond.release()
+ self._cond.release()
+
+
+# A barrier class. Inspired in part by the pthread_barrier_* api and
+# the CyclicBarrier class from Java. See
+# http://sourceware.org/pthreads-win32/manual/pthread_barrier_init.html and
+# http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/
+# CyclicBarrier.html
+# for information.
+# We maintain two main states, 'filling' and 'draining' enabling the barrier
+# to be cyclic. Threads are not allowed into it until it has fully drained
+# since the previous cycle. In addition, a 'resetting' state exists which is
+# similar to 'draining' except that threads leave with a BrokenBarrierError,
+# and a 'broken' state in which all threads get the exception.
+class Barrier(_Verbose):
+ """
+ Barrier. Useful for synchronizing a fixed number of threads
+ at known synchronization points. Threads block on 'wait()' and are
+ simultaneously once they have all made that call.
+ """
+ def __init__(self, parties, action=None, timeout=None, verbose=None):
+ """
+ Create a barrier, initialised to 'parties' threads.
+ 'action' is a callable which, when supplied, will be called
+ by one of the threads after they have all entered the
+ barrier and just prior to releasing them all.
+ If a 'timeout' is provided, it is uses as the default for
+ all subsequent 'wait()' calls.
+ """
+ _Verbose.__init__(self, verbose)
+ self._cond = Condition(Lock())
+ self._action = action
+ self._timeout = timeout
+ self._parties = parties
+ self._state = 0 #0 filling, 1, draining, -1 resetting, -2 broken
+ self._count = 0
+
+ def wait(self, timeout=None):
+ """
+ Wait for the barrier. When the specified number of threads have
+ started waiting, they are all simultaneously awoken. If an 'action'
+ was provided for the barrier, one of the threads will have executed
+ that callback prior to returning.
+ Returns an individual index number from 0 to 'parties-1'.
+ """
+ if timeout is None:
+ timeout = self._timeout
+ with self._cond:
+ self._enter() # Block while the barrier drains.
+ index = self._count
+ self._count += 1
+ try:
+ if index + 1 == self._parties:
+ # We release the barrier
+ self._release()
+ else:
+ # We wait until someone releases us
+ self._wait(timeout)
+ return index
+ finally:
+ self._count -= 1
+ # Wake up any threads waiting for barrier to drain.
+ self._exit()
+
+ # Block until the barrier is ready for us, or raise an exception
+ # if it is broken.
+ def _enter(self):
+ while self._state in (-1, 1):
+ # It is draining or resetting, wait until done
+ self._cond.wait()
+ #see if the barrier is in a broken state
+ if self._state < 0:
+ raise BrokenBarrierError
+ assert self._state == 0
+
+ # Optionally run the 'action' and release the threads waiting
+ # in the barrier.
+ def _release(self):
+ try:
+ if self._action:
+ self._action()
+ # enter draining state
+ self._state = 1
+ self._cond.notify_all()
+ except:
+ #an exception during the _action handler. Break and reraise
+ self._break()
+ raise
+
+ # Wait in the barrier until we are relased. Raise an exception
+ # if the barrier is reset or broken.
+ def _wait(self, timeout):
+ if not self._cond.wait_for(lambda : self._state != 0, timeout):
+ #timed out. Break the barrier
+ self._break()
+ raise BrokenBarrierError
+ if self._state < 0:
+ raise BrokenBarrierError
+ assert self._state == 1
+
+ # If we are the last thread to exit the barrier, signal any threads
+ # waiting for the barrier to drain.
+ def _exit(self):
+ if self._count == 0:
+ if self._state in (-1, 1):
+ #resetting or draining
+ self._state = 0
+ self._cond.notify_all()
+
+ def reset(self):
+ """
+ Reset the barrier to the initial state.
+ Any threads currently waiting will get the BrokenBarrier exception
+ raised.
+ """
+ with self._cond:
+ if self._count > 0:
+ if self._state == 0:
+ #reset the barrier, waking up threads
+ self._state = -1
+ elif self._state == -2:
+ #was broken, set it to reset state
+ #which clears when the last thread exits
+ self._state = -1
+ else:
+ self._state = 0
+ self._cond.notify_all()
+
+ def abort(self):
+ """
+ Place the barrier into a 'broken' state.
+ Useful in case of error. Any currently waiting threads and
+ threads attempting to 'wait()' will have BrokenBarrierError
+ raised.
+ """
+ with self._cond:
+ self._break()
+
+ def _break(self):
+ # An internal error was detected. The barrier is set to
+ # a broken state all parties awakened.
+ self._state = -2
+ self._cond.notify_all()
+
+ @property
+ def parties(self):
+ """
+ Return the number of threads required to trip the barrier.
+ """
+ return self._parties
+
+ @property
+ def n_waiting(self):
+ """
+ Return the number of threads that are currently waiting at the barrier.
+ """
+ # We don't need synchronization here since this is an ephemeral result
+ # anyway. It returns the correct value in the steady state.
+ if self._state == 0:
+ return self._count
+ return 0
+
+ @property
+ def broken(self):
+ """
+ Return True if the barrier is in a broken state
+ """
+ return self._state == -2
+
+#exception raised by the Barrier class
+class BrokenBarrierError(RuntimeError): pass
+
# Helper to generate new thread names
_counter = 0
@@ -418,6 +607,8 @@ _active_limbo_lock = _allocate_lock()
_active = {} # maps thread id to Thread object
_limbo = {}
+# For debug and leak testing
+_dangling = WeakSet()
# Main class for threads
@@ -431,7 +622,7 @@ class Thread(_Verbose):
__exc_info = _sys.exc_info
# Keep sys.exc_clear too to clear the exception just before
# allowing .join() to return.
- __exc_clear = _sys.exc_clear
+ #XXX __exc_clear = _sys.exc_clear
def __init__(self, group=None, target=None, name=None,
args=(), kwargs=None, verbose=None):
@@ -439,125 +630,122 @@ class Thread(_Verbose):
_Verbose.__init__(self, verbose)
if kwargs is None:
kwargs = {}
- self.__target = target
- self.__name = str(name or _newname())
- self.__args = args
- self.__kwargs = kwargs
- self.__daemonic = self._set_daemon()
- self.__ident = None
- self.__started = Event()
- self.__stopped = False
- self.__block = Condition(Lock())
- self.__initialized = True
+ self._target = target
+ self._name = str(name or _newname())
+ self._args = args
+ self._kwargs = kwargs
+ self._daemonic = self._set_daemon()
+ self._ident = None
+ self._started = Event()
+ self._stopped = False
+ self._block = Condition(Lock())
+ self._initialized = True
# sys.stderr is not stored in the class like
# sys.exc_info since it can be changed between instances
- self.__stderr = _sys.stderr
+ self._stderr = _sys.stderr
+ _dangling.add(self)
def _reset_internal_locks(self):
# private! Called by _after_fork() to reset our internal locks as
# they may be in an invalid state leading to a deadlock or crash.
- if hasattr(self, '_Thread__block'): # DummyThread deletes self.__block
- self.__block.__init__()
- self.__started._reset_internal_locks()
-
- @property
- def _block(self):
- # used by a unittest
- return self.__block
+ if hasattr(self, '_block'): # DummyThread deletes _block
+ self._block.__init__()
+ self._started._reset_internal_locks()
def _set_daemon(self):
# Overridden in _MainThread and _DummyThread
return current_thread().daemon
def __repr__(self):
- assert self.__initialized, "Thread.__init__() was not called"
+ assert self._initialized, "Thread.__init__() was not called"
status = "initial"
- if self.__started.is_set():
+ if self._started.is_set():
status = "started"
- if self.__stopped:
+ if self._stopped:
status = "stopped"
- if self.__daemonic:
+ if self._daemonic:
status += " daemon"
- if self.__ident is not None:
- status += " %s" % self.__ident
- return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status)
+ if self._ident is not None:
+ status += " %s" % self._ident
+ return "<%s(%s, %s)>" % (self.__class__.__name__, self._name, status)
def start(self):
- if not self.__initialized:
+ if not self._initialized:
raise RuntimeError("thread.__init__() not called")
- if self.__started.is_set():
+
+ if self._started.is_set():
raise RuntimeError("threads can only be started once")
if __debug__:
self._note("%s.start(): starting thread", self)
with _active_limbo_lock:
_limbo[self] = self
try:
- _start_new_thread(self.__bootstrap, ())
+ _start_new_thread(self._bootstrap, ())
except Exception:
with _active_limbo_lock:
del _limbo[self]
raise
- self.__started.wait()
+ self._started.wait()
def run(self):
try:
- if self.__target:
- self.__target(*self.__args, **self.__kwargs)
+ if self._target:
+ self._target(*self._args, **self._kwargs)
finally:
# Avoid a refcycle if the thread is running a function with
# an argument that has a member that points to the thread.
- del self.__target, self.__args, self.__kwargs
+ del self._target, self._args, self._kwargs
- def __bootstrap(self):
+ def _bootstrap(self):
# Wrapper around the real bootstrap code that ignores
# exceptions during interpreter cleanup. Those typically
# happen when a daemon thread wakes up at an unfortunate
# moment, finds the world around it destroyed, and raises some
# random exception *** while trying to report the exception in
- # __bootstrap_inner() below ***. Those random exceptions
+ # _bootstrap_inner() below ***. Those random exceptions
# don't help anybody, and they confuse users, so we suppress
# them. We suppress them only when it appears that the world
# indeed has already been destroyed, so that exceptions in
- # __bootstrap_inner() during normal business hours are properly
+ # _bootstrap_inner() during normal business hours are properly
# reported. Also, we only suppress them for daemonic threads;
# if a non-daemonic encounters this, something else is wrong.
try:
- self.__bootstrap_inner()
+ self._bootstrap_inner()
except:
- if self.__daemonic and _sys is None:
+ if self._daemonic and _sys is None:
return
raise
def _set_ident(self):
- self.__ident = _get_ident()
+ self._ident = _get_ident()
- def __bootstrap_inner(self):
+ def _bootstrap_inner(self):
try:
self._set_ident()
- self.__started.set()
+ self._started.set()
with _active_limbo_lock:
- _active[self.__ident] = self
+ _active[self._ident] = self
del _limbo[self]
if __debug__:
- self._note("%s.__bootstrap(): thread started", self)
+ self._note("%s._bootstrap(): thread started", self)
if _trace_hook:
- self._note("%s.__bootstrap(): registering trace hook", self)
+ self._note("%s._bootstrap(): registering trace hook", self)
_sys.settrace(_trace_hook)
if _profile_hook:
- self._note("%s.__bootstrap(): registering profile hook", self)
+ self._note("%s._bootstrap(): registering profile hook", self)
_sys.setprofile(_profile_hook)
try:
self.run()
except SystemExit:
if __debug__:
- self._note("%s.__bootstrap(): raised SystemExit", self)
+ self._note("%s._bootstrap(): raised SystemExit", self)
except:
if __debug__:
- self._note("%s.__bootstrap(): unhandled exception", self)
+ self._note("%s._bootstrap(): unhandled exception", self)
# If sys.stderr is no more (most likely from interpreter
- # shutdown) use self.__stderr. Otherwise still use sys (as in
+ # shutdown) use self._stderr. Otherwise still use sys (as in
# _sys) in case sys.stderr was redefined since the creation of
# self.
if _sys:
@@ -567,69 +755,66 @@ class Thread(_Verbose):
# Do the best job possible w/o a huge amt. of code to
# approximate a traceback (code ideas from
# Lib/traceback.py)
- exc_type, exc_value, exc_tb = self.__exc_info()
+ exc_type, exc_value, exc_tb = self._exc_info()
try:
- print>>self.__stderr, (
+ print((
"Exception in thread " + self.name +
- " (most likely raised during interpreter shutdown):")
- print>>self.__stderr, (
- "Traceback (most recent call last):")
+ " (most likely raised during interpreter shutdown):"), file=self._stderr)
+ print((
+ "Traceback (most recent call last):"), file=self._stderr)
while exc_tb:
- print>>self.__stderr, (
+ print((
' File "%s", line %s, in %s' %
(exc_tb.tb_frame.f_code.co_filename,
exc_tb.tb_lineno,
- exc_tb.tb_frame.f_code.co_name))
+ exc_tb.tb_frame.f_code.co_name)), file=self._stderr)
exc_tb = exc_tb.tb_next
- print>>self.__stderr, ("%s: %s" % (exc_type, exc_value))
+ print(("%s: %s" % (exc_type, exc_value)), file=self._stderr)
# Make sure that exc_tb gets deleted since it is a memory
# hog; deleting everything else is just for thoroughness
finally:
del exc_type, exc_value, exc_tb
else:
if __debug__:
- self._note("%s.__bootstrap(): normal return", self)
+ self._note("%s._bootstrap(): normal return", self)
finally:
# Prevent a race in
# test_threading.test_no_refcycle_through_target when
# the exception keeps the target alive past when we
# assert that it's dead.
- self.__exc_clear()
+ #XXX self.__exc_clear()
+ pass
finally:
with _active_limbo_lock:
- self.__stop()
+ self._stop()
try:
- # We don't call self.__delete() because it also
+ # We don't call self._delete() because it also
# grabs _active_limbo_lock.
del _active[_get_ident()]
except:
pass
- def __stop(self):
- # DummyThreads delete self.__block, but they have no waiters to
- # notify anyway (join() is forbidden on them).
- if not hasattr(self, '_Thread__block'):
- return
- self.__block.acquire()
- self.__stopped = True
- self.__block.notify_all()
- self.__block.release()
+ def _stop(self):
+ self._block.acquire()
+ self._stopped = True
+ self._block.notify_all()
+ self._block.release()
- def __delete(self):
+ def _delete(self):
"Remove current thread from the dict of currently running threads."
- # Notes about running with dummy_thread:
+ # Notes about running with _dummy_thread:
#
- # Must take care to not raise an exception if dummy_thread is being
+ # Must take care to not raise an exception if _dummy_thread is being
# used (and thus this module is being used as an instance of
- # dummy_threading). dummy_thread.get_ident() always returns -1 since
- # there is only one thread if dummy_thread is being used. Thus
+ # dummy_threading). _dummy_thread.get_ident() always returns -1 since
+ # there is only one thread if _dummy_thread is being used. Thus
# len(_active) is always <= 1 here, and any Thread instance created
# overwrites the (if any) thread currently registered in _active.
#
# An instance of _MainThread is always created by 'threading'. This
# gets overwritten the instant an instance of Thread is created; both
- # threads return -1 from dummy_thread.get_ident() and thus have the
+ # threads return -1 from _dummy_thread.get_ident() and thus have the
# same key in the dict. So when the _MainThread instance created by
# 'threading' tries to clean itself up when atexit calls this method
# it gets a KeyError if another Thread instance was created.
@@ -651,71 +836,72 @@ class Thread(_Verbose):
raise
def join(self, timeout=None):
- if not self.__initialized:
+ if not self._initialized:
raise RuntimeError("Thread.__init__() not called")
- if not self.__started.is_set():
+ if not self._started.is_set():
raise RuntimeError("cannot join thread before it is started")
if self is current_thread():
raise RuntimeError("cannot join current thread")
if __debug__:
- if not self.__stopped:
+ if not self._stopped:
self._note("%s.join(): waiting until thread stops", self)
- self.__block.acquire()
+
+ self._block.acquire()
try:
if timeout is None:
- while not self.__stopped:
- self.__block.wait()
+ while not self._stopped:
+ self._block.wait()
if __debug__:
self._note("%s.join(): thread stopped", self)
else:
deadline = _time() + timeout
- while not self.__stopped:
+ while not self._stopped:
delay = deadline - _time()
if delay <= 0:
if __debug__:
self._note("%s.join(): timed out", self)
break
- self.__block.wait(delay)
+ self._block.wait(delay)
else:
if __debug__:
self._note("%s.join(): thread stopped", self)
finally:
- self.__block.release()
+ self._block.release()
@property
def name(self):
- assert self.__initialized, "Thread.__init__() not called"
- return self.__name
+ assert self._initialized, "Thread.__init__() not called"
+ return self._name
@name.setter
def name(self, name):
- assert self.__initialized, "Thread.__init__() not called"
- self.__name = str(name)
+ assert self._initialized, "Thread.__init__() not called"
+ self._name = str(name)
@property
def ident(self):
- assert self.__initialized, "Thread.__init__() not called"
- return self.__ident
+ assert self._initialized, "Thread.__init__() not called"
+ return self._ident
- def isAlive(self):
- assert self.__initialized, "Thread.__init__() not called"
- return self.__started.is_set() and not self.__stopped
+ def is_alive(self):
+ assert self._initialized, "Thread.__init__() not called"
+ return self._started.is_set() and not self._stopped
- is_alive = isAlive
+ isAlive = is_alive
@property
def daemon(self):
- assert self.__initialized, "Thread.__init__() not called"
- return self.__daemonic
+ assert self._initialized, "Thread.__init__() not called"
+ return self._daemonic
@daemon.setter
def daemon(self, daemonic):
- if not self.__initialized:
+ if not self._initialized:
raise RuntimeError("Thread.__init__() not called")
- if self.__started.is_set():
+ if self._started.is_set():
raise RuntimeError("cannot set daemon status of active thread");
- self.__daemonic = daemonic
+ self._daemonic = daemonic
def isDaemon(self):
return self.daemon
@@ -767,16 +953,16 @@ class _MainThread(Thread):
def __init__(self):
Thread.__init__(self, name="MainThread")
- self._Thread__started.set()
+ self._started.set()
self._set_ident()
with _active_limbo_lock:
- _active[_get_ident()] = self
+ _active[self._ident] = self
def _set_daemon(self):
return False
def _exitfunc(self):
- self._Thread__stop()
+ self._stop()
t = _pickSomeNonDaemonThread()
if t:
if __debug__:
@@ -786,7 +972,7 @@ class _MainThread(Thread):
t = _pickSomeNonDaemonThread()
if __debug__:
self._note("%s: exiting", self)
- self._Thread__delete()
+ self._delete()
def _pickSomeNonDaemonThread():
for t in enumerate():
@@ -808,49 +994,52 @@ class _DummyThread(Thread):
def __init__(self):
Thread.__init__(self, name=_newname("Dummy-%d"))
- # Thread.__block consumes an OS-level locking primitive, which
+ # Thread._block consumes an OS-level locking primitive, which
# can never be used by a _DummyThread. Since a _DummyThread
# instance is immortal, that's bad, so release this resource.
- del self._Thread__block
+ del self._block
- self._Thread__started.set()
+ self._started.set()
self._set_ident()
with _active_limbo_lock:
- _active[_get_ident()] = self
+ _active[self._ident] = self
def _set_daemon(self):
return True
+ def _stop(self):
+ pass
+
def join(self, timeout=None):
assert False, "cannot join a dummy thread"
# Global API functions
-def currentThread():
+def current_thread():
try:
return _active[_get_ident()]
except KeyError:
##print "current_thread(): no current thread for", _get_ident()
return _DummyThread()
-current_thread = currentThread
+currentThread = current_thread
-def activeCount():
+def active_count():
with _active_limbo_lock:
return len(_active) + len(_limbo)
-active_count = activeCount
+activeCount = active_count
def _enumerate():
# Same as enumerate(), but without the lock. Internal use only.
- return _active.values() + _limbo.values()
+ return list(_active.values()) + list(_limbo.values())
def enumerate():
with _active_limbo_lock:
- return _active.values() + _limbo.values()
+ return list(_active.values()) + list(_limbo.values())
-from thread import stack_size
+from _thread import stack_size
# Create the main thread object,
# and make it available for the interpreter
@@ -862,7 +1051,7 @@ _shutdown = _MainThread()._exitfunc
# module, or from the python fallback
try:
- from thread import _local as local
+ from _thread import _local as local
except ImportError:
from _threading_local import local
@@ -881,110 +1070,21 @@ def _after_fork():
new_active = {}
current = current_thread()
with _active_limbo_lock:
- for thread in _active.itervalues():
+ for thread in _active.values():
# Any lock/condition variable may be currently locked or in an
# invalid state, so we reinitialize them.
- if hasattr(thread, '_reset_internal_locks'):
- thread._reset_internal_locks()
+ thread._reset_internal_locks()
if thread is current:
# There is only one active thread. We reset the ident to
# its new value since it can have changed.
ident = _get_ident()
- thread._Thread__ident = ident
+ thread._ident = ident
new_active[ident] = thread
else:
# All the others are already stopped.
- thread._Thread__stop()
+ thread._stop()
_limbo.clear()
_active.clear()
_active.update(new_active)
assert len(_active) == 1
-
-
-# Self-test code
-
-def _test():
-
- class BoundedQueue(_Verbose):
-
- def __init__(self, limit):
- _Verbose.__init__(self)
- self.mon = RLock()
- self.rc = Condition(self.mon)
- self.wc = Condition(self.mon)
- self.limit = limit
- self.queue = _deque()
-
- def put(self, item):
- self.mon.acquire()
- while len(self.queue) >= self.limit:
- self._note("put(%s): queue full", item)
- self.wc.wait()
- self.queue.append(item)
- self._note("put(%s): appended, length now %d",
- item, len(self.queue))
- self.rc.notify()
- self.mon.release()
-
- def get(self):
- self.mon.acquire()
- while not self.queue:
- self._note("get(): queue empty")
- self.rc.wait()
- item = self.queue.popleft()
- self._note("get(): got %s, %d left", item, len(self.queue))
- self.wc.notify()
- self.mon.release()
- return item
-
- class ProducerThread(Thread):
-
- def __init__(self, queue, quota):
- Thread.__init__(self, name="Producer")
- self.queue = queue
- self.quota = quota
-
- def run(self):
- from random import random
- counter = 0
- while counter < self.quota:
- counter = counter + 1
- self.queue.put("%s.%d" % (self.name, counter))
- _sleep(random() * 0.00001)
-
-
- class ConsumerThread(Thread):
-
- def __init__(self, queue, count):
- Thread.__init__(self, name="Consumer")
- self.queue = queue
- self.count = count
-
- def run(self):
- while self.count > 0:
- item = self.queue.get()
- print item
- self.count = self.count - 1
-
- NP = 3
- QL = 4
- NI = 5
-
- Q = BoundedQueue(QL)
- P = []
- for i in range(NP):
- t = ProducerThread(Q, NI)
- t.name = ("Producer-%d" % (i+1))
- P.append(t)
- C = ConsumerThread(Q, NI*NP)
- for t in P:
- t.start()
- _sleep(0.000001)
- C.start()
- for t in P:
- t.join()
- C.join()
-
-if __name__ == '__main__':
- _test()
diff --git a/Lib/timeit.py b/Lib/timeit.py
index da9e819bc07..1ae59e0cccd 100644
--- a/Lib/timeit.py
+++ b/Lib/timeit.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Tool for measuring execution time of small code snippets.
@@ -122,27 +122,27 @@ class Timer:
"""Constructor. See class doc string."""
self.timer = timer
ns = {}
- if isinstance(stmt, basestring):
+ if isinstance(stmt, str):
stmt = reindent(stmt, 8)
- if isinstance(setup, basestring):
+ if isinstance(setup, str):
setup = reindent(setup, 4)
src = template % {'stmt': stmt, 'setup': setup}
- elif hasattr(setup, '__call__'):
+ elif callable(setup):
src = template % {'stmt': stmt, 'setup': '_setup()'}
ns['_setup'] = setup
else:
raise ValueError("setup is neither a string nor callable")
self.src = src # Save for traceback display
code = compile(src, dummy_src_name, "exec")
- exec code in globals(), ns
+ exec(code, globals(), ns)
self.inner = ns["inner"]
- elif hasattr(stmt, '__call__'):
+ elif callable(stmt):
self.src = None
- if isinstance(setup, basestring):
+ if isinstance(setup, str):
_setup = setup
def setup():
- exec _setup in globals(), ns
- elif not hasattr(setup, '__call__'):
+ exec(_setup, globals(), ns)
+ elif not callable(setup):
raise ValueError("setup is neither a string nor callable")
self.inner = _template_func(setup, stmt)
else:
@@ -234,10 +234,10 @@ def repeat(stmt="pass", setup="pass", timer=default_timer,
"""Convenience function to create Timer object and call repeat method."""
return Timer(stmt, setup, timer).repeat(repeat, number)
-def main(args=None):
+def main(args=None, *, _wrap_timer=None):
"""Main program, used when run as a script.
- The optional argument specifies the command line to be parsed,
+ The optional 'args' argument specifies the command line to be parsed,
defaulting to sys.argv[1:].
The return value is an exit code to be passed to sys.exit(); it
@@ -246,6 +246,10 @@ def main(args=None):
When an exception happens during timing, a traceback is printed to
stderr and the return value is 1. Exceptions at other times
(including the template compilation) are not caught.
+
+ '_wrap_timer' is an internal interface used for unit testing. If it
+ is not None, it must be a callable that accepts a timer function
+ and returns another timer function (used for unit testing).
"""
if args is None:
args = sys.argv[1:]
@@ -254,9 +258,9 @@ def main(args=None):
opts, args = getopt.getopt(args, "n:s:r:tcvh",
["number=", "setup=", "repeat=",
"time", "clock", "verbose", "help"])
- except getopt.error, err:
- print err
- print "use -h/--help for command line help"
+ except getopt.error as err:
+ print(err)
+ print("use -h/--help for command line help")
return 2
timer = default_timer
stmt = "\n".join(args) or "pass"
@@ -283,7 +287,7 @@ def main(args=None):
precision += 1
verbose += 1
if o in ("-h", "--help"):
- print __doc__,
+ print(__doc__, end=' ')
return 0
setup = "\n".join(setup) or "pass"
# Include the current directory, so that local imports work (sys.path
@@ -291,6 +295,8 @@ def main(args=None):
# directory)
import os
sys.path.insert(0, os.curdir)
+ if _wrap_timer is not None:
+ timer = _wrap_timer(timer)
t = Timer(stmt, setup, timer)
if number == 0:
# determine number so that 0.2 <= total time < 2.0
@@ -302,7 +308,7 @@ def main(args=None):
t.print_exc()
return 1
if verbose:
- print "%d loops -> %.*g secs" % (number, precision, x)
+ print("%d loops -> %.*g secs" % (number, precision, x))
if x >= 0.2:
break
try:
@@ -312,18 +318,18 @@ def main(args=None):
return 1
best = min(r)
if verbose:
- print "raw times:", " ".join(["%.*g" % (precision, x) for x in r])
- print "%d loops," % number,
+ print("raw times:", " ".join(["%.*g" % (precision, x) for x in r]))
+ print("%d loops," % number, end=' ')
usec = best * 1e6 / number
if usec < 1000:
- print "best of %d: %.*g usec per loop" % (repeat, precision, usec)
+ print("best of %d: %.*g usec per loop" % (repeat, precision, usec))
else:
msec = usec / 1000
if msec < 1000:
- print "best of %d: %.*g msec per loop" % (repeat, precision, msec)
+ print("best of %d: %.*g msec per loop" % (repeat, precision, msec))
else:
sec = msec / 1000
- print "best of %d: %.*g sec per loop" % (repeat, precision, sec)
+ print("best of %d: %.*g sec per loop" % (repeat, precision, sec))
return None
if __name__ == "__main__":
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/tkinter/__init__.py
index e5c2e5181f1..f2cb60f4b5e 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/tkinter/__init__.py
@@ -18,29 +18,27 @@ Actions are bound to events by resources (e.g. keyword argument
command) or with the method bind.
Example (Hello, World):
-import Tkinter
-from Tkconstants import *
-tk = Tkinter.Tk()
-frame = Tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
+import tkinter
+from tkinter.constants import *
+tk = tkinter.Tk()
+frame = tkinter.Frame(tk, relief=RIDGE, borderwidth=2)
frame.pack(fill=BOTH,expand=1)
-label = Tkinter.Label(frame, text="Hello, World")
+label = tkinter.Label(frame, text="Hello, World")
label.pack(fill=X, expand=1)
-button = Tkinter.Button(frame,text="Exit",command=tk.destroy)
+button = tkinter.Button(frame,text="Exit",command=tk.destroy)
button.pack(side=BOTTOM)
tk.mainloop()
"""
-__version__ = "$Revision: 81008 $"
+__version__ = "$Revision$"
import sys
if sys.platform == "win32":
# Attempt to configure Tcl/Tk without requiring PATH
- import FixTk
+ from tkinter import _fix
import _tkinter # If this fails your Python may not be configured for Tk
-tkinter = _tkinter # b/w compat for export
TclError = _tkinter.TclError
-from types import *
-from Tkconstants import *
+from tkinter.constants import *
wantobjects = 1
@@ -51,18 +49,12 @@ READABLE = _tkinter.READABLE
WRITABLE = _tkinter.WRITABLE
EXCEPTION = _tkinter.EXCEPTION
-# These are not always defined, e.g. not on Win32 with Tk 8.0 :-(
-try: _tkinter.createfilehandler
-except AttributeError: _tkinter.createfilehandler = None
-try: _tkinter.deletefilehandler
-except AttributeError: _tkinter.deletefilehandler = None
-
-def _flatten(tuple):
+def _flatten(seq):
"""Internal function."""
res = ()
- for item in tuple:
- if type(item) in (TupleType, ListType):
+ for item in seq:
+ if isinstance(item, (tuple, list)):
res = res + _flatten(item)
elif item is not None:
res = res + (item,)
@@ -73,17 +65,17 @@ except AttributeError: pass
def _cnfmerge(cnfs):
"""Internal function."""
- if type(cnfs) is DictionaryType:
+ if isinstance(cnfs, dict):
return cnfs
- elif type(cnfs) in (NoneType, StringType):
+ elif isinstance(cnfs, (type(None), str)):
return cnfs
else:
cnf = {}
for c in _flatten(cnfs):
try:
cnf.update(c)
- except (AttributeError, TypeError), msg:
- print "_cnfmerge: fallback due to:", msg
+ except (AttributeError, TypeError) as msg:
+ print("_cnfmerge: fallback due to:", msg)
for k, v in c.items():
cnf[k] = v
return cnf
@@ -160,7 +152,7 @@ def _exit(code=0):
code = int(code)
except ValueError:
pass
- raise SystemExit, code
+ raise SystemExit(code)
_varnum = 0
class Variable:
@@ -228,8 +220,8 @@ class Variable:
self._master.deletecommand(cbname)
def trace_vinfo(self):
"""Return all trace callback information."""
- return map(self._tk.split, self._tk.splitlist(
- self._tk.call("trace", "vinfo", self._name)))
+ return [self._tk.split(x) for x in self._tk.splitlist(
+ self._tk.call("trace", "vinfo", self._name))]
def __eq__(self, other):
"""Comparison for equality (==).
@@ -257,7 +249,7 @@ class StringVar(Variable):
def get(self):
"""Return value of variable as string."""
value = self._tk.globalgetvar(self._name)
- if isinstance(value, basestring):
+ if isinstance(value, str):
return value
return str(value)
@@ -880,9 +872,9 @@ class Misc:
data = self.tk.split(
self.tk.call('winfo', 'visualsavailable', self._w,
includeids and 'includeids' or None))
- if type(data) is StringType:
+ if isinstance(data, str):
data = [self.tk.split(data)]
- return map(self.__winfo_parseitem, data)
+ return [self.__winfo_parseitem(x) for x in data]
def __winfo_parseitem(self, t):
"""Internal function."""
return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
@@ -947,7 +939,7 @@ class Misc:
self.tk.call('bindtags', self._w, tagList)
def _bind(self, what, sequence, func, add, needcleanup=1):
"""Internal function."""
- if type(func) is StringType:
+ if isinstance(func, str):
self.tk.call(what + (sequence, func))
elif func:
funcid = self._register(func, self._substitute,
@@ -1075,18 +1067,17 @@ class Misc:
for k, v in cnf.items():
if v is not None:
if k[-1] == '_': k = k[:-1]
- if hasattr(v, '__call__'):
+ if callable(v):
v = self._register(v)
elif isinstance(v, (tuple, list)):
nv = []
for item in v:
- if not isinstance(item, (basestring, int)):
- break
- elif isinstance(item, int):
- nv.append('%d' % item)
- else:
- # format it to proper Tcl code if it contains space
+ if isinstance(item, int):
+ nv.append(str(item))
+ elif isinstance(item, str):
nv.append(('{%s}' if ' ' in item else '%s') % item)
+ else:
+ break
else:
v = ' '.join(nv)
res = res + ('-'+k, v)
@@ -1116,7 +1107,7 @@ class Misc:
f = CallWrapper(func, subst, self).__call__
name = repr(id(f))
try:
- func = func.im_func
+ func = func.__func__
except AttributeError:
pass
try:
@@ -1199,7 +1190,7 @@ class Misc:
def _report_exception(self):
"""Internal function."""
import sys
- exc, val, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
+ exc, val, tb = sys.exc_info()
root = self._root()
root.report_callback_exception(exc, val, tb)
def _configure(self, cmd, cnf, kw):
@@ -1214,7 +1205,7 @@ class Misc:
self.tk.call(_flatten((self._w, cmd)))):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
- if type(cnf) is StringType:
+ if isinstance(cnf, str):
x = self.tk.split(
self.tk.call(_flatten((self._w, cmd, '-'+cnf))))
return (x[0][1:],) + x[1:]
@@ -1235,12 +1226,10 @@ class Misc:
__getitem__ = cget
def __setitem__(self, key, value):
self.configure({key: value})
- def __contains__(self, key):
- raise TypeError("Tkinter objects don't support 'in' tests.")
def keys(self):
"""Return a list of all resource names of this widget."""
- return map(lambda x: x[0][1:],
- self.tk.split(self.tk.call(self._w, 'configure')))
+ return [x[0][1:] for x in
+ self.tk.split(self.tk.call(self._w, 'configure'))]
def __str__(self):
"""Return the window path name of this widget."""
return self._w
@@ -1262,18 +1251,18 @@ class Misc:
def pack_slaves(self):
"""Return a list of all slaves of this widget
in its packing order."""
- return map(self._nametowidget,
- self.tk.splitlist(
- self.tk.call('pack', 'slaves', self._w)))
+ return [self._nametowidget(x) for x in
+ self.tk.splitlist(
+ self.tk.call('pack', 'slaves', self._w))]
slaves = pack_slaves
# Place method that applies to the master
def place_slaves(self):
"""Return a list of all slaves of this widget
in its packing order."""
- return map(self._nametowidget,
- self.tk.splitlist(
+ return [self._nametowidget(x) for x in
+ self.tk.splitlist(
self.tk.call(
- 'place', 'slaves', self._w)))
+ 'place', 'slaves', self._w))]
# Grid methods that apply to the master
def grid_bbox(self, column=None, row=None, col2=None, row2=None):
"""Return a tuple of integer coordinates for the bounding
@@ -1297,7 +1286,7 @@ class Misc:
bbox = grid_bbox
def _grid_configure(self, command, index, cnf, kw):
"""Internal function."""
- if type(cnf) is StringType and not kw:
+ if isinstance(cnf, str) and not kw:
if cnf[-1:] == '_':
cnf = cnf[:-1]
if cnf[:1] != '-':
@@ -1377,9 +1366,9 @@ class Misc:
args = args + ('-row', row)
if column is not None:
args = args + ('-column', column)
- return map(self._nametowidget,
- self.tk.splitlist(self.tk.call(
- ('grid', 'slaves', self._w) + args)))
+ return [self._nametowidget(x) for x in
+ self.tk.splitlist(self.tk.call(
+ ('grid', 'slaves', self._w) + args))]
# Support for the "event" command, new in Tk 4.2.
# By Case Roole.
@@ -1436,8 +1425,8 @@ class CallWrapper:
if self.subst:
args = self.subst(*args)
return self.func(*args)
- except SystemExit, msg:
- raise SystemExit, msg
+ except SystemExit:
+ raise
except:
self.widget._report_exception()
@@ -1533,7 +1522,7 @@ class Wm:
if len(wlist) > 1:
wlist = (wlist,) # Tk needs a list of windows here
args = ('wm', 'colormapwindows', self._w) + wlist
- return map(self._nametowidget, self.tk.call(args))
+ return [self._nametowidget(x) for x in self.tk.call(args)]
colormapwindows = wm_colormapwindows
def wm_command(self, value=None):
"""Store VALUE in WM_COMMAND property. It is the command
@@ -1647,7 +1636,7 @@ class Wm:
"""Bind function FUNC to command NAME for this widget.
Return the function bound to NAME if None is given. NAME could be
e.g. "WM_SAVE_YOURSELF" or "WM_DELETE_WINDOW"."""
- if hasattr(func, '__call__'):
+ if callable(func):
command = self._register(func)
else:
command = func
@@ -1726,19 +1715,16 @@ class Tk(Misc, Wm):
# Version sanity checks
tk_version = self.tk.getvar('tk_version')
if tk_version != _tkinter.TK_VERSION:
- raise RuntimeError, \
- "tk.h version (%s) doesn't match libtk.a version (%s)" \
- % (_tkinter.TK_VERSION, tk_version)
+ raise RuntimeError("tk.h version (%s) doesn't match libtk.a version (%s)"
+ % (_tkinter.TK_VERSION, tk_version))
# Under unknown circumstances, tcl_version gets coerced to float
tcl_version = str(self.tk.getvar('tcl_version'))
if tcl_version != _tkinter.TCL_VERSION:
- raise RuntimeError, \
- "tcl.h version (%s) doesn't match libtcl.a version (%s)" \
- % (_tkinter.TCL_VERSION, tcl_version)
+ raise RuntimeError("tcl.h version (%s) doesn't match libtcl.a version (%s)" \
+ % (_tkinter.TCL_VERSION, tcl_version))
if TkVersion < 4.0:
- raise RuntimeError, \
- "Tk 4.0 or higher is required; found Tk %s" \
- % str(TkVersion)
+ raise RuntimeError("Tk 4.0 or higher is required; found Tk %s"
+ % str(TkVersion))
# Create and register the tkerror and exit commands
# We need to inline parts of _register here, _ register
# would register differently-named commands.
@@ -1754,7 +1740,7 @@ class Tk(Misc, Wm):
def destroy(self):
"""Destroy this and all descendants widgets. This will
end the application of this Tcl interpreter."""
- for c in self.children.values(): c.destroy()
+ for c in list(self.children.values()): c.destroy()
self.tk.call('destroy', self._w)
Misc.destroy(self)
global _default_root
@@ -1762,8 +1748,8 @@ class Tk(Misc, Wm):
_default_root = None
def readprofile(self, baseName, className):
"""Internal function. It reads BASENAME.tcl and CLASSNAME.tcl into
- the Tcl Interpreter and calls execfile on BASENAME.py and CLASSNAME.py if
- such a file exists in the home directory."""
+ the Tcl Interpreter and calls exec on the contents of BASENAME.py and
+ CLASSNAME.py if such a file exists in the home directory."""
import os
if 'HOME' in os.environ: home = os.environ['HOME']
else: home = os.curdir
@@ -1772,15 +1758,15 @@ class Tk(Misc, Wm):
base_tcl = os.path.join(home, '.%s.tcl' % baseName)
base_py = os.path.join(home, '.%s.py' % baseName)
dir = {'self': self}
- exec 'from Tkinter import *' in dir
+ exec('from tkinter import *', dir)
if os.path.isfile(class_tcl):
self.tk.call('source', class_tcl)
if os.path.isfile(class_py):
- execfile(class_py, dir)
+ exec(open(class_py).read(), dir)
if os.path.isfile(base_tcl):
self.tk.call('source', base_tcl)
if os.path.isfile(base_py):
- execfile(base_py, dir)
+ exec(open(base_py).read(), dir)
def report_callback_exception(self, exc, val, tb):
"""Internal function. It reports exception on sys.stderr."""
import traceback, sys
@@ -1995,18 +1981,16 @@ class BaseWidget(Misc):
BaseWidget._setup(self, master, cnf)
if self._tclCommands is None:
self._tclCommands = []
- classes = []
- for k in cnf.keys():
- if type(k) is ClassType:
- classes.append((k, cnf[k]))
- del cnf[k]
+ classes = [(k, v) for k, v in cnf.items() if isinstance(k, type)]
+ for k, v in classes:
+ del cnf[k]
self.tk.call(
(widgetName, self._w) + extra + self._options(cnf))
for k, v in classes:
k.configure(self, v)
def destroy(self):
"""Destroy this and all descendants widgets."""
- for c in self.children.values(): c.destroy()
+ for c in list(self.children.values()): c.destroy()
self.tk.call('destroy', self._w)
if self._name in self.master.children:
del self.master.children[self._name]
@@ -2203,14 +2187,14 @@ class Canvas(Widget, XView, YView):
def coords(self, *args):
"""Return a list of coordinates for the item given in ARGS."""
# XXX Should use _flatten on args
- return map(getdouble,
+ return [getdouble(x) for x in
self.tk.splitlist(
- self.tk.call((self._w, 'coords') + args)))
+ self.tk.call((self._w, 'coords') + args))]
def _create(self, itemType, args, kw): # Args: (val, val, ..., cnf={})
"""Internal function."""
args = _flatten(args)
cnf = args[-1]
- if type(cnf) in (DictionaryType, TupleType):
+ if isinstance(cnf, (dict, tuple)):
args = args[:-1]
else:
cnf = {}
@@ -3186,7 +3170,7 @@ class OptionMenu(Menubutton):
if 'command' in kwargs:
del kwargs['command']
if kwargs:
- raise TclError, 'unknown option -'+kwargs.keys()[0]
+ raise TclError('unknown option -'+kwargs.keys()[0])
menu.add_command(label=value,
command=_setit(variable, value, callback))
for v in values:
@@ -3212,7 +3196,7 @@ class Image:
if not master:
master = _default_root
if not master:
- raise RuntimeError, 'Too early to create image'
+ raise RuntimeError('Too early to create image')
self.tk = master.tk
if not name:
Image._last_id += 1
@@ -3224,7 +3208,7 @@ class Image:
elif kw: cnf = kw
options = ()
for k, v in cnf.items():
- if hasattr(v, '__call__'):
+ if callable(v):
v = self._register(v)
options = options + ('-'+k, v)
self.tk.call(('image', 'create', imgtype, name,) + options)
@@ -3247,7 +3231,7 @@ class Image:
for k, v in _cnfmerge(kw).items():
if v is not None:
if k[-1] == '_': k = k[:-1]
- if hasattr(v, '__call__'):
+ if callable(v):
v = self._register(v)
res = res + ('-'+k, v)
self.tk.call((self.name, 'config') + res)
@@ -3698,7 +3682,7 @@ class PanedWindow(Widget):
'paneconfigure', tagOrId)):
cnf[x[0][1:]] = (x[0][1:],) + x[1:]
return cnf
- if type(cnf) == StringType and not kw:
+ if isinstance(cnf, str) and not kw:
x = self.tk.split(self.tk.call(
self._w, 'paneconfigure', tagOrId, '-'+cnf))
return (x[0][1:],) + x[1:]
@@ -3738,11 +3722,7 @@ def _test():
root = Tk()
text = "This is Tcl/Tk version %s" % TclVersion
if TclVersion >= 8.1:
- try:
- text = text + unicode("\nThis should be a cedilla: \347",
- "iso-8859-1")
- except NameError:
- pass # no unicode support
+ text += "\nThis should be a cedilla: \xe7"
label = Label(root, text=text)
label.pack()
test = Button(root, text="Click me!",
diff --git a/Lib/tkinter/__main__.py b/Lib/tkinter/__main__.py
new file mode 100644
index 00000000000..757880d439c
--- /dev/null
+++ b/Lib/tkinter/__main__.py
@@ -0,0 +1,7 @@
+"""Main entry point"""
+
+import sys
+if sys.argv[0].endswith("__main__.py"):
+ sys.argv[0] = "python -m tkinter"
+from . import _test as main
+main()
diff --git a/Lib/lib-tk/FixTk.py b/Lib/tkinter/_fix.py
index 49960c74ca8..5a69d897876 100644
--- a/Lib/lib-tk/FixTk.py
+++ b/Lib/tkinter/_fix.py
@@ -19,10 +19,10 @@ except (ImportError, AttributeError):
return s
else:
def convert_path(s):
- assert isinstance(s, str) # sys.prefix contains only bytes
- udir = s.decode("mbcs")
+ if isinstance(s, bytes):
+ s = s.decode("mbcs")
hdir = ctypes.windll.kernel32.\
- CreateFileW(udir, 0x80, # FILE_READ_ATTRIBUTES
+ CreateFileW(s, 0x80, # FILE_READ_ATTRIBUTES
1, # FILE_SHARE_READ
None, 3, # OPEN_EXISTING
0x02000000, # FILE_FLAG_BACKUP_SEMANTICS
@@ -30,7 +30,7 @@ else:
if hdir == -1:
# Cannot open directory, give up
return s
- buf = ctypes.create_unicode_buffer(u"", 32768)
+ buf = ctypes.create_unicode_buffer("", 32768)
res = ctypes.windll.kernel32.\
GetFinalPathNameByHandleW(hdir, buf, len(buf),
0) # VOLUME_NAME_DOS
@@ -38,7 +38,7 @@ else:
if res == 0:
# Conversion failed (e.g. network location)
return s
- s = buf[:res].encode("mbcs")
+ s = buf[:res]
# Ignore leading \\?\
if s.startswith("\\\\?\\"):
s = s[4:]
diff --git a/Lib/lib-tk/tkColorChooser.py b/Lib/tkinter/colorchooser.py
index cf6283b3572..6027067208c 100644
--- a/Lib/lib-tk/tkColorChooser.py
+++ b/Lib/tkinter/colorchooser.py
@@ -19,7 +19,7 @@
# - title: dialog title
#
-from tkCommonDialog import Dialog
+from tkinter.commondialog import Dialog
#
@@ -69,4 +69,4 @@ def askcolor(color = None, **options):
# test stuff
if __name__ == "__main__":
- print "color", askcolor()
+ print("color", askcolor())
diff --git a/Lib/lib-tk/tkCommonDialog.py b/Lib/tkinter/commondialog.py
index 2cd9be4eac0..d2688dba9b5 100644
--- a/Lib/lib-tk/tkCommonDialog.py
+++ b/Lib/tkinter/commondialog.py
@@ -1,14 +1,14 @@
# base class for tk common dialogues
#
# this module provides a base class for accessing the common
-# dialogues available in Tk 4.2 and newer. use tkFileDialog,
-# tkColorChooser, and tkMessageBox to access the individual
+# dialogues available in Tk 4.2 and newer. use filedialog,
+# colorchooser, and messagebox to access the individual
# dialogs.
#
# written by Fredrik Lundh, May 1997
#
-from Tkinter import *
+from tkinter import *
class Dialog:
@@ -18,7 +18,7 @@ class Dialog:
# FIXME: should this be placed on the module level instead?
if TkVersion < 4.2:
- raise TclError, "this module requires Tk 4.2 or newer"
+ raise TclError("this module requires Tk 4.2 or newer")
self.master = master
self.options = options
diff --git a/Lib/lib-tk/Tkconstants.py b/Lib/tkinter/constants.py
index 63eee33d24d..63eee33d24d 100644
--- a/Lib/lib-tk/Tkconstants.py
+++ b/Lib/tkinter/constants.py
diff --git a/Lib/lib-tk/Dialog.py b/Lib/tkinter/dialog.py
index 2d089593ba2..be085abe1dd 100644
--- a/Lib/lib-tk/Dialog.py
+++ b/Lib/tkinter/dialog.py
@@ -1,7 +1,7 @@
# dialog.py -- Tkinter interface to the tk_dialog script.
-from Tkinter import *
-from Tkinter import _cnfmerge
+from tkinter import *
+from tkinter import _cnfmerge
if TkVersion <= 3.6:
DIALOG_ICON = 'warning'
@@ -36,7 +36,7 @@ def _test():
'strings': ('Save File',
'Discard Changes',
'Return to Editor')})
- print d.num
+ print(d.num)
if __name__ == '__main__':
diff --git a/Lib/lib-tk/Tkdnd.py b/Lib/tkinter/dnd.py
index 2e37d9ec395..55f0776ce9a 100644
--- a/Lib/lib-tk/Tkdnd.py
+++ b/Lib/tkinter/dnd.py
@@ -100,7 +100,7 @@ active; it will never call dnd_commit().
"""
-import Tkinter
+import tkinter
# The factory function
@@ -219,7 +219,7 @@ class Icon:
self.detach()
if not canvas:
return
- label = Tkinter.Label(canvas, text=self.name,
+ label = tkinter.Label(canvas, text=self.name,
borderwidth=2, relief="raised")
id = canvas.create_window(x, y, window=label, anchor="nw")
self.canvas = canvas
@@ -268,8 +268,8 @@ class Icon:
class Tester:
def __init__(self, root):
- self.top = Tkinter.Toplevel(root)
- self.canvas = Tkinter.Canvas(self.top, width=100, height=100)
+ self.top = tkinter.Toplevel(root)
+ self.canvas = tkinter.Canvas(self.top, width=100, height=100)
self.canvas.pack(fill="both", expand=1)
self.canvas.dnd_accept = self.dnd_accept
@@ -300,9 +300,9 @@ class Tester:
source.attach(self.canvas, x, y)
def test():
- root = Tkinter.Tk()
+ root = tkinter.Tk()
root.geometry("+1+1")
- Tkinter.Button(command=root.quit, text="Quit").pack()
+ tkinter.Button(command=root.quit, text="Quit").pack()
t1 = Tester(root)
t1.top.geometry("+1+60")
t2 = Tester(root)
diff --git a/Lib/lib-tk/FileDialog.py b/Lib/tkinter/filedialog.py
index 06ce2b92298..98d2d5c3205 100644
--- a/Lib/lib-tk/FileDialog.py
+++ b/Lib/tkinter/filedialog.py
@@ -6,10 +6,15 @@ Classes:
- LoadFileDialog
- SaveFileDialog
+This module also presents tk common file dialogues, it provides interfaces
+to the native file dialogues available in Tk 4.2 and newer, and the
+directory dialogue available in Tk 8.3 and newer.
+These interfaces were written by Fredrik Lundh, May 1997.
"""
-from Tkinter import *
-from Dialog import Dialog
+from tkinter import *
+from tkinter.dialog import Dialog
+from tkinter import commondialog
import os
import fnmatch
@@ -259,6 +264,176 @@ class SaveFileDialog(FileDialog):
self.quit(file)
+
+# For the following classes and modules:
+#
+# options (all have default values):
+#
+# - defaultextension: added to filename if not explicitly given
+#
+# - filetypes: sequence of (label, pattern) tuples. the same pattern
+# may occur with several patterns. use "*" as pattern to indicate
+# all files.
+#
+# - initialdir: initial directory. preserved by dialog instance.
+#
+# - initialfile: initial file (ignored by the open dialog). preserved
+# by dialog instance.
+#
+# - parent: which window to place the dialog on top of
+#
+# - title: dialog title
+#
+# - multiple: if true user may select more than one file
+#
+# options for the directory chooser:
+#
+# - initialdir, parent, title: see above
+#
+# - mustexist: if true, user must pick an existing directory
+#
+
+
+class _Dialog(commondialog.Dialog):
+
+ def _fixoptions(self):
+ try:
+ # make sure "filetypes" is a tuple
+ self.options["filetypes"] = tuple(self.options["filetypes"])
+ except KeyError:
+ pass
+
+ def _fixresult(self, widget, result):
+ if result:
+ # keep directory and filename until next time
+ import os
+ # convert Tcl path objects to strings
+ try:
+ result = result.string
+ except AttributeError:
+ # it already is a string
+ pass
+ path, file = os.path.split(result)
+ self.options["initialdir"] = path
+ self.options["initialfile"] = file
+ self.filename = result # compatibility
+ return result
+
+
+#
+# file dialogs
+
+class Open(_Dialog):
+ "Ask for a filename to open"
+
+ command = "tk_getOpenFile"
+
+ def _fixresult(self, widget, result):
+ if isinstance(result, tuple):
+ # multiple results:
+ result = tuple([getattr(r, "string", r) for r in result])
+ if result:
+ import os
+ path, file = os.path.split(result[0])
+ self.options["initialdir"] = path
+ # don't set initialfile or filename, as we have multiple of these
+ return result
+ if not widget.tk.wantobjects() and "multiple" in self.options:
+ # Need to split result explicitly
+ return self._fixresult(widget, widget.tk.splitlist(result))
+ return _Dialog._fixresult(self, widget, result)
+
+class SaveAs(_Dialog):
+ "Ask for a filename to save as"
+
+ command = "tk_getSaveFile"
+
+
+# the directory dialog has its own _fix routines.
+class Directory(commondialog.Dialog):
+ "Ask for a directory"
+
+ command = "tk_chooseDirectory"
+
+ def _fixresult(self, widget, result):
+ if result:
+ # convert Tcl path objects to strings
+ try:
+ result = result.string
+ except AttributeError:
+ # it already is a string
+ pass
+ # keep directory until next time
+ self.options["initialdir"] = result
+ self.directory = result # compatibility
+ return result
+
+#
+# convenience stuff
+
+def askopenfilename(**options):
+ "Ask for a filename to open"
+
+ return Open(**options).show()
+
+def asksaveasfilename(**options):
+ "Ask for a filename to save as"
+
+ return SaveAs(**options).show()
+
+def askopenfilenames(**options):
+ """Ask for multiple filenames to open
+
+ Returns a list of filenames or empty list if
+ cancel button selected
+ """
+ options["multiple"]=1
+ return Open(**options).show()
+
+# FIXME: are the following perhaps a bit too convenient?
+
+def askopenfile(mode = "r", **options):
+ "Ask for a filename to open, and returned the opened file"
+
+ filename = Open(**options).show()
+ if filename:
+ return open(filename, mode)
+ return None
+
+def askopenfiles(mode = "r", **options):
+ """Ask for multiple filenames and return the open file
+ objects
+
+ returns a list of open file objects or an empty list if
+ cancel selected
+ """
+
+ files = askopenfilenames(**options)
+ if files:
+ ofiles=[]
+ for filename in files:
+ ofiles.append(open(filename, mode))
+ files=ofiles
+ return files
+
+
+def asksaveasfile(mode = "w", **options):
+ "Ask for a filename to save as, and returned the opened file"
+
+ filename = SaveAs(**options).show()
+ if filename:
+ return open(filename, mode)
+ return None
+
+def askdirectory (**options):
+ "Ask for a directory, and return the file name"
+ return Directory(**options).show()
+
+
+
+# --------------------------------------------------------------------
+# test stuff
+
def test():
"""Simple test program."""
root = Tk()
@@ -267,8 +442,40 @@ def test():
loadfile = fd.go(key="test")
fd = SaveFileDialog(root)
savefile = fd.go(key="test")
- print loadfile, savefile
+ print(loadfile, savefile)
+
+ # Since the file name may contain non-ASCII characters, we need
+ # to find an encoding that likely supports the file name, and
+ # displays correctly on the terminal.
+
+ # Start off with UTF-8
+ enc = "utf-8"
+ import sys
+
+ # See whether CODESET is defined
+ try:
+ import locale
+ locale.setlocale(locale.LC_ALL,'')
+ enc = locale.nl_langinfo(locale.CODESET)
+ except (ImportError, AttributeError):
+ pass
+
+ # dialog for openening files
+
+ openfilename=askopenfilename(filetypes=[("all files", "*")])
+ try:
+ fp=open(openfilename,"r")
+ fp.close()
+ except:
+ print("Could not open File: ")
+ print(sys.exc_info()[1])
+
+ print("open", openfilename.encode(enc))
+
+ # dialog for saving files
+ saveasfilename=asksaveasfilename()
+ print("saveas", saveasfilename.encode(enc))
if __name__ == '__main__':
test()
diff --git a/Lib/lib-tk/tkFont.py b/Lib/tkinter/font.py
index 229f2513e71..5425b060132 100644
--- a/Lib/lib-tk/tkFont.py
+++ b/Lib/tkinter/font.py
@@ -8,7 +8,7 @@
__version__ = "0.9"
-import Tkinter
+import tkinter
# weight/slant
NORMAL = "normal"
@@ -31,7 +31,7 @@ class Font:
name -- name to use for this font configuration (defaults to a unique name)
exists -- does a named font by this name already exist?
Creates a new named font if False, points to the existing font if True.
- Raises _Tkinter.TclError if the assertion is false.
+ Raises _tkinter.TclError if the assertion is false.
the following are ignored if font is specified:
@@ -65,7 +65,7 @@ class Font:
def __init__(self, root=None, font=None, name=None, exists=False, **options):
if not root:
- root = Tkinter._default_root
+ root = tkinter._default_root
if font:
# get actual settings corresponding to the given font
font = root.tk.splitlist(root.tk.call("font", "actual", font))
@@ -79,7 +79,8 @@ class Font:
self.delete_font = False
# confirm font exists
if self.name not in root.tk.call("font", "names"):
- raise Tkinter._tkinter.TclError, "named font %s does not already exist" % (self.name,)
+ raise tkinter._tkinter.TclError(
+ "named font %s does not already exist" % (self.name,))
# if font config info supplied, apply it
if font:
root.tk.call("font", "configure", self.name, *font)
@@ -96,7 +97,7 @@ class Font:
return self.name
def __eq__(self, other):
- return self.name == other.name and isinstance(other, Font)
+ return isinstance(other, Font) and self.name == other.name
def __getitem__(self, key):
return self.cget(key)
@@ -166,13 +167,13 @@ class Font:
def families(root=None):
"Get font families (as a tuple)"
if not root:
- root = Tkinter._default_root
+ root = tkinter._default_root
return root.tk.splitlist(root.tk.call("font", "families"))
def names(root=None):
"Get names of defined fonts (as a tuple)"
if not root:
- root = Tkinter._default_root
+ root = tkinter._default_root
return root.tk.splitlist(root.tk.call("font", "names"))
# --------------------------------------------------------------------
@@ -180,32 +181,32 @@ def names(root=None):
if __name__ == "__main__":
- root = Tkinter.Tk()
+ root = tkinter.Tk()
# create a font
f = Font(family="times", size=30, weight=NORMAL)
- print f.actual()
- print f.actual("family")
- print f.actual("weight")
+ print(f.actual())
+ print(f.actual("family"))
+ print(f.actual("weight"))
- print f.config()
- print f.cget("family")
- print f.cget("weight")
+ print(f.config())
+ print(f.cget("family"))
+ print(f.cget("weight"))
- print names()
+ print(names())
- print f.measure("hello"), f.metrics("linespace")
+ print(f.measure("hello"), f.metrics("linespace"))
- print f.metrics()
+ print(f.metrics())
f = Font(font=("Courier", 20, "bold"))
- print f.measure("hello"), f.metrics("linespace")
+ print(f.measure("hello"), f.metrics("linespace"))
- w = Tkinter.Label(root, text="Hello, world", font=f)
+ w = tkinter.Label(root, text="Hello, world", font=f)
w.pack()
- w = Tkinter.Button(root, text="Quit!", command=root.destroy)
+ w = tkinter.Button(root, text="Quit!", command=root.destroy)
w.pack()
fb = Font(font=w["font"]).copy()
@@ -213,4 +214,4 @@ if __name__ == "__main__":
w.config(font=fb)
- Tkinter.mainloop()
+ tkinter.mainloop()
diff --git a/Lib/lib-tk/tkMessageBox.py b/Lib/tkinter/messagebox.py
index 9ee923576ff..5c35d5adbaf 100644
--- a/Lib/lib-tk/tkMessageBox.py
+++ b/Lib/tkinter/messagebox.py
@@ -22,7 +22,7 @@
# - type: dialog type; that is, which buttons to display (see below)
#
-from tkCommonDialog import Dialog
+from tkinter.commondialog import Dialog
#
# constants
@@ -124,11 +124,11 @@ def askretrycancel(title=None, message=None, **options):
if __name__ == "__main__":
- print "info", showinfo("Spam", "Egg Information")
- print "warning", showwarning("Spam", "Egg Warning")
- print "error", showerror("Spam", "Egg Alert")
- print "question", askquestion("Spam", "Question?")
- print "proceed", askokcancel("Spam", "Proceed?")
- print "yes/no", askyesno("Spam", "Got it?")
- print "yes/no/cancel", askyesnocancel("Spam", "Want it?")
- print "try again", askretrycancel("Spam", "Try again?")
+ print("info", showinfo("Spam", "Egg Information"))
+ print("warning", showwarning("Spam", "Egg Warning"))
+ print("error", showerror("Spam", "Egg Alert"))
+ print("question", askquestion("Spam", "Question?"))
+ print("proceed", askokcancel("Spam", "Proceed?"))
+ print("yes/no", askyesno("Spam", "Got it?"))
+ print("yes/no/cancel", askyesnocancel("Spam", "Want it?"))
+ print("try again", askretrycancel("Spam", "Try again?"))
diff --git a/Lib/lib-tk/ScrolledText.py b/Lib/tkinter/scrolledtext.py
index a1ef79ca74c..9aa936ae949 100644
--- a/Lib/lib-tk/ScrolledText.py
+++ b/Lib/tkinter/scrolledtext.py
@@ -13,8 +13,8 @@ Place methods are redirected to the Frame widget however.
__all__ = ['ScrolledText']
-from Tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
-from Tkconstants import RIGHT, LEFT, Y, BOTH
+from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
+from tkinter.constants import RIGHT, LEFT, Y, BOTH
class ScrolledText(Text):
def __init__(self, master=None, **kw):
@@ -30,8 +30,8 @@ class ScrolledText(Text):
# Copy geometry methods of self.frame without overriding Text
# methods -- hack!
text_meths = vars(Text).keys()
- methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
- methods = set(methods).difference(text_meths)
+ methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
+ methods = methods.difference(text_meths)
for m in methods:
if m[0] != '_' and m != 'config' and m != 'configure':
@@ -42,11 +42,10 @@ class ScrolledText(Text):
def example():
- import __main__
- from Tkconstants import END
+ from tkinter.constants import END
stext = ScrolledText(bg='white', height=10)
- stext.insert(END, __main__.__doc__)
+ stext.insert(END, __doc__)
stext.pack(fill=BOTH, side=LEFT, expand=True)
stext.focus_set()
stext.mainloop()
diff --git a/Lib/lib-tk/tkSimpleDialog.py b/Lib/tkinter/simpledialog.py
index 023475db252..45302b4569b 100644
--- a/Lib/lib-tk/tkSimpleDialog.py
+++ b/Lib/tkinter/simpledialog.py
@@ -1,20 +1,18 @@
#
# An Introduction to Tkinter
-# tkSimpleDialog.py
#
# Copyright (c) 1997 by Fredrik Lundh
#
+# This copyright applies to Dialog, askinteger, askfloat and asktring
+#
# fredrik@pythonware.com
# http://www.pythonware.com
#
+"""This modules handles dialog boxes.
-# --------------------------------------------------------------------
-# dialog base class
-
-'''Dialog boxes
+It contains the following public symbols:
-This module handles dialog boxes. It contains the following
-public symbols:
+SimpleDialog -- A simple but flexible modal dialog box
Dialog -- a base class for dialogs
@@ -23,9 +21,95 @@ askinteger -- get an integer from the user
askfloat -- get a float from the user
askstring -- get a string from the user
-'''
+"""
+
+from tkinter import *
+from tkinter import messagebox
+
+import tkinter # used at _QueryDialog for tkinter._default_root
+
+class SimpleDialog:
+
+ def __init__(self, master,
+ text='', buttons=[], default=None, cancel=None,
+ title=None, class_=None):
+ if class_:
+ self.root = Toplevel(master, class_=class_)
+ else:
+ self.root = Toplevel(master)
+ if title:
+ self.root.title(title)
+ self.root.iconname(title)
+ self.message = Message(self.root, text=text, aspect=400)
+ self.message.pack(expand=1, fill=BOTH)
+ self.frame = Frame(self.root)
+ self.frame.pack()
+ self.num = default
+ self.cancel = cancel
+ self.default = default
+ self.root.bind('<Return>', self.return_event)
+ for num in range(len(buttons)):
+ s = buttons[num]
+ b = Button(self.frame, text=s,
+ command=(lambda self=self, num=num: self.done(num)))
+ if num == default:
+ b.config(relief=RIDGE, borderwidth=8)
+ b.pack(side=LEFT, fill=BOTH, expand=1)
+ self.root.protocol('WM_DELETE_WINDOW', self.wm_delete_window)
+ self._set_transient(master)
+
+ def _set_transient(self, master, relx=0.5, rely=0.3):
+ widget = self.root
+ widget.withdraw() # Remain invisible while we figure out the geometry
+ widget.transient(master)
+ widget.update_idletasks() # Actualize geometry information
+ if master.winfo_ismapped():
+ m_width = master.winfo_width()
+ m_height = master.winfo_height()
+ m_x = master.winfo_rootx()
+ m_y = master.winfo_rooty()
+ else:
+ m_width = master.winfo_screenwidth()
+ m_height = master.winfo_screenheight()
+ m_x = m_y = 0
+ w_width = widget.winfo_reqwidth()
+ w_height = widget.winfo_reqheight()
+ x = m_x + (m_width - w_width) * relx
+ y = m_y + (m_height - w_height) * rely
+ if x+w_width > master.winfo_screenwidth():
+ x = master.winfo_screenwidth() - w_width
+ elif x < 0:
+ x = 0
+ if y+w_height > master.winfo_screenheight():
+ y = master.winfo_screenheight() - w_height
+ elif y < 0:
+ y = 0
+ widget.geometry("+%d+%d" % (x, y))
+ widget.deiconify() # Become visible at the desired location
+
+ def go(self):
+ self.root.wait_visibility()
+ self.root.grab_set()
+ self.root.mainloop()
+ self.root.destroy()
+ return self.num
+
+ def return_event(self, event):
+ if self.default is None:
+ self.root.bell()
+ else:
+ self.done(self.default)
+
+ def wm_delete_window(self):
+ if self.cancel is None:
+ self.root.bell()
+ else:
+ self.done(self.cancel)
+
+ def done(self, num):
+ self.num = num
+ self.root.quit()
-from Tkinter import *
class Dialog(Toplevel):
@@ -66,7 +150,6 @@ class Dialog(Toplevel):
self.buttonbox()
-
if not self.initial_focus:
self.initial_focus = self
@@ -76,7 +159,7 @@ class Dialog(Toplevel):
self.geometry("+%d+%d" % (parent.winfo_rootx()+50,
parent.winfo_rooty()+50))
- self.deiconify() # become visibile now
+ self.deiconify() # become visible now
self.initial_focus.focus_set()
@@ -177,8 +260,7 @@ class _QueryDialog(Dialog):
parent = None):
if not parent:
- import Tkinter
- parent = Tkinter._default_root
+ parent = tkinter._default_root
self.prompt = prompt
self.minvalue = minvalue
@@ -207,13 +289,10 @@ class _QueryDialog(Dialog):
return self.entry
def validate(self):
-
- import tkMessageBox
-
try:
result = self.getresult()
except ValueError:
- tkMessageBox.showwarning(
+ messagebox.showwarning(
"Illegal value",
self.errormessage + "\nPlease try again",
parent = self
@@ -221,7 +300,7 @@ class _QueryDialog(Dialog):
return 0
if self.minvalue is not None and result < self.minvalue:
- tkMessageBox.showwarning(
+ messagebox.showwarning(
"Too small",
"The allowed minimum value is %s. "
"Please try again." % self.minvalue,
@@ -230,7 +309,7 @@ class _QueryDialog(Dialog):
return 0
if self.maxvalue is not None and result > self.maxvalue:
- tkMessageBox.showwarning(
+ messagebox.showwarning(
"Too large",
"The allowed maximum value is %s. "
"Please try again." % self.maxvalue,
@@ -313,11 +392,32 @@ def askstring(title, prompt, **kw):
d = _QueryString(title, prompt, **kw)
return d.result
-if __name__ == "__main__":
- root = Tk()
- root.update()
- print askinteger("Spam", "Egg count", initialvalue=12*12)
- print askfloat("Spam", "Egg weight\n(in tons)", minvalue=1, maxvalue=100)
- print askstring("Spam", "Egg label")
+if __name__ == '__main__':
+
+ def test():
+ root = Tk()
+ def doit(root=root):
+ d = SimpleDialog(root,
+ text="This is a test dialog. "
+ "Would this have been an actual dialog, "
+ "the buttons below would have been glowing "
+ "in soft pink light.\n"
+ "Do you believe this?",
+ buttons=["Yes", "No", "Cancel"],
+ default=0,
+ cancel=2,
+ title="Test Dialog")
+ print(d.go())
+ print(askinteger("Spam", "Egg count", initialvalue=12*12))
+ print(askfloat("Spam", "Egg weight\n(in tons)", minvalue=1,
+ maxvalue=100))
+ print(askstring("Spam", "Egg label"))
+ t = Button(root, text='Test', command=doit)
+ t.pack()
+ q = Button(root, text='Quit', command=t.quit)
+ q.pack()
+ t.mainloop()
+
+ test()
diff --git a/Lib/lib-tk/test/README b/Lib/tkinter/test/README
index 79cd16c74d7..79cd16c74d7 100644
--- a/Lib/lib-tk/test/README
+++ b/Lib/tkinter/test/README
diff --git a/Lib/lib-tk/test/test_tkinter/__init__.py b/Lib/tkinter/test/__init__.py
index e69de29bb2d..e69de29bb2d 100644
--- a/Lib/lib-tk/test/test_tkinter/__init__.py
+++ b/Lib/tkinter/test/__init__.py
diff --git a/Lib/tkinter/test/runtktests.py b/Lib/tkinter/test/runtktests.py
new file mode 100644
index 00000000000..e21eca4c45e
--- /dev/null
+++ b/Lib/tkinter/test/runtktests.py
@@ -0,0 +1,72 @@
+"""
+Use this module to get and run all tk tests.
+
+tkinter tests should live in a package inside the directory where this file
+lives, like test_tkinter.
+Extensions also should live in packages following the same rule as above.
+"""
+
+import os
+import sys
+import unittest
+import importlib
+import test.support
+
+this_dir_path = os.path.abspath(os.path.dirname(__file__))
+
+def is_package(path):
+ for name in os.listdir(path):
+ if name in ('__init__.py', '__init__.pyc', '__init.pyo'):
+ return True
+ return False
+
+def get_tests_modules(basepath=this_dir_path, gui=True, packages=None):
+ """This will import and yield modules whose names start with test_
+ and are inside packages found in the path starting at basepath.
+
+ If packages is specified it should contain package names that
+ want their tests collected.
+ """
+ py_ext = '.py'
+
+ for dirpath, dirnames, filenames in os.walk(basepath):
+ for dirname in list(dirnames):
+ if dirname[0] == '.':
+ dirnames.remove(dirname)
+
+ if is_package(dirpath) and filenames:
+ pkg_name = dirpath[len(basepath) + len(os.sep):].replace('/', '.')
+ if packages and pkg_name not in packages:
+ continue
+
+ filenames = filter(
+ lambda x: x.startswith('test_') and x.endswith(py_ext),
+ filenames)
+
+ for name in filenames:
+ try:
+ yield importlib.import_module(
+ ".%s.%s" % (pkg_name, name[:-len(py_ext)]),
+ "tkinter.test")
+ except test.support.ResourceDenied:
+ if gui:
+ raise
+
+def get_tests(text=True, gui=True, packages=None):
+ """Yield all the tests in the modules found by get_tests_modules.
+
+ If nogui is True, only tests that do not require a GUI will be
+ returned."""
+ attrs = []
+ if text:
+ attrs.append('tests_nogui')
+ if gui:
+ attrs.append('tests_gui')
+ for module in get_tests_modules(gui=gui, packages=packages):
+ for attr in attrs:
+ for test in getattr(module, attr, ()):
+ yield test
+
+if __name__ == "__main__":
+ test.support.use_resources = ['gui']
+ test.support.run_unittest(*get_tests())
diff --git a/Lib/tkinter/test/support.py b/Lib/tkinter/test/support.py
new file mode 100644
index 00000000000..6dd6d4a3fcb
--- /dev/null
+++ b/Lib/tkinter/test/support.py
@@ -0,0 +1,79 @@
+import sys
+import tkinter
+import unittest
+
+_tk_unavailable = None
+
+def check_tk_availability():
+ """Check that Tk is installed and available."""
+ global _tk_unavailable
+
+ if _tk_unavailable is None:
+ _tk_unavailable = False
+ if sys.platform == 'darwin':
+ # The Aqua Tk implementations on OS X can abort the process if
+ # being called in an environment where a window server connection
+ # cannot be made, for instance when invoked by a buildbot or ssh
+ # process not running under the same user id as the current console
+ # user. To avoid that, raise an exception if the window manager
+ # connection is not available.
+ from ctypes import cdll, c_int, pointer, Structure
+ from ctypes.util import find_library
+
+ app_services = cdll.LoadLibrary(find_library("ApplicationServices"))
+
+ if app_services.CGMainDisplayID() == 0:
+ _tk_unavailable = "cannot run without OS X window manager"
+ else:
+ class ProcessSerialNumber(Structure):
+ _fields_ = [("highLongOfPSN", c_int),
+ ("lowLongOfPSN", c_int)]
+ psn = ProcessSerialNumber()
+ psn_p = pointer(psn)
+ if ( (app_services.GetCurrentProcess(psn_p) < 0) or
+ (app_services.SetFrontProcess(psn_p) < 0) ):
+ _tk_unavailable = "cannot run without OS X gui process"
+ else: # not OS X
+ import tkinter
+ try:
+ tkinter.Button()
+ except tkinter.TclError as msg:
+ # assuming tk is not available
+ _tk_unavailable = "tk not available: %s" % msg
+
+ if _tk_unavailable:
+ raise unittest.SkipTest(_tk_unavailable)
+ return
+
+def get_tk_root():
+ check_tk_availability() # raise exception if tk unavailable
+ try:
+ root = tkinter._default_root
+ except AttributeError:
+ # it is possible to disable default root in Tkinter, although
+ # I haven't seen people doing it (but apparently someone did it
+ # here).
+ root = None
+
+ if root is None:
+ # create a new master only if there isn't one already
+ root = tkinter.Tk()
+
+ return root
+
+def root_deiconify():
+ root = get_tk_root()
+ root.deiconify()
+
+def root_withdraw():
+ root = get_tk_root()
+ root.withdraw()
+
+
+def simulate_mouse_click(widget, x, y):
+ """Generate proper events to click at the x, y position (tries to act
+ like an X server)."""
+ widget.event_generate('<Enter>', x=0, y=0)
+ widget.event_generate('<Motion>', x=x, y=y)
+ widget.event_generate('<ButtonPress-1>', x=x, y=y)
+ widget.event_generate('<ButtonRelease-1>', x=x, y=y)
diff --git a/Lib/lib-tk/test/test_ttk/__init__.py b/Lib/tkinter/test/test_tkinter/__init__.py
index e69de29bb2d..e69de29bb2d 100644
--- a/Lib/lib-tk/test/test_ttk/__init__.py
+++ b/Lib/tkinter/test/test_tkinter/__init__.py
diff --git a/Lib/tkinter/test/test_tkinter/test_font.py b/Lib/tkinter/test/test_tkinter/test_font.py
new file mode 100644
index 00000000000..dfd630b4de4
--- /dev/null
+++ b/Lib/tkinter/test/test_tkinter/test_font.py
@@ -0,0 +1,33 @@
+import unittest
+import tkinter
+from tkinter import font
+from test.support import requires, run_unittest
+import tkinter.test.support as support
+
+requires('gui')
+
+class FontTest(unittest.TestCase):
+
+ def setUp(self):
+ support.root_deiconify()
+
+ def tearDown(self):
+ support.root_withdraw()
+
+ def test_font_eq(self):
+ fontname = "TkDefaultFont"
+ try:
+ f = font.Font(name=fontname, exists=True)
+ except tkinter._tkinter.TclError:
+ f = font.Font(name=fontname, exists=False)
+ font1 = font.nametofont(fontname)
+ font2 = font.nametofont(fontname)
+ self.assertIsNot(font1, font2)
+ self.assertEqual(font1, font2)
+ self.assertNotEqual(font1, font1.copy())
+ self.assertNotEqual(font1, 0)
+
+tests_gui = (FontTest, )
+
+if __name__ == "__main__":
+ run_unittest(*tests_gui)
diff --git a/Lib/lib-tk/test/test_tkinter/test_loadtk.py b/Lib/tkinter/test/test_tkinter/test_loadtk.py
index 32c640de1df..bab7bcd37ce 100644
--- a/Lib/lib-tk/test/test_tkinter/test_loadtk.py
+++ b/Lib/tkinter/test/test_tkinter/test_loadtk.py
@@ -1,8 +1,8 @@
import os
import sys
import unittest
-from test import test_support
-from Tkinter import Tcl, TclError
+import test.support as test_support
+from tkinter import Tcl, TclError
test_support.requires('gui')
@@ -31,7 +31,8 @@ class TkLoadTest(unittest.TestCase):
# doesn't actually carry through to the process level
# because they don't support unsetenv
# If that's the case, abort.
- display = os.popen('echo $DISPLAY').read().strip()
+ with os.popen('echo $DISPLAY') as pipe:
+ display = pipe.read().strip()
if display:
return
diff --git a/Lib/lib-tk/test/test_tkinter/test_text.py b/Lib/tkinter/test/test_tkinter/test_text.py
index e6c08be7ac0..a93c4ce25e7 100644
--- a/Lib/lib-tk/test/test_tkinter/test_text.py
+++ b/Lib/tkinter/test/test_tkinter/test_text.py
@@ -1,7 +1,7 @@
import unittest
-import Tkinter
-from test.test_support import requires, run_unittest
-from ttk import setup_master
+import tkinter
+from test.support import requires, run_unittest
+from tkinter.ttk import setup_master
requires('gui')
@@ -9,7 +9,7 @@ class TextTest(unittest.TestCase):
def setUp(self):
self.root = setup_master()
- self.text = Tkinter.Text(self.root)
+ self.text = tkinter.Text(self.root)
def tearDown(self):
self.text.destroy()
@@ -19,12 +19,12 @@ class TextTest(unittest.TestCase):
text = self.text
# pattern and index are obligatory arguments.
- self.assertRaises(Tkinter.TclError, text.search, None, '1.0')
- self.assertRaises(Tkinter.TclError, text.search, 'a', None)
- self.assertRaises(Tkinter.TclError, text.search, None, None)
+ self.assertRaises(tkinter.TclError, text.search, None, '1.0')
+ self.assertRaises(tkinter.TclError, text.search, 'a', None)
+ self.assertRaises(tkinter.TclError, text.search, None, None)
# Invalid text index.
- self.assertRaises(Tkinter.TclError, text.search, '', 0)
+ self.assertRaises(tkinter.TclError, text.search, '', 0)
# Check if we are getting the indices as strings -- you are likely
# to get Tcl_Obj under Tk 8.5 if Tkinter doesn't convert it.
diff --git a/Lib/tkinter/test/test_ttk/__init__.py b/Lib/tkinter/test/test_ttk/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Lib/tkinter/test/test_ttk/__init__.py
diff --git a/Lib/lib-tk/test/test_ttk/test_extensions.py b/Lib/tkinter/test/test_ttk/test_extensions.py
index 6e46cbc62fa..5912af4fdde 100644
--- a/Lib/lib-tk/test/test_ttk/test_extensions.py
+++ b/Lib/tkinter/test/test_ttk/test_extensions.py
@@ -1,10 +1,10 @@
import sys
import unittest
-import Tkinter
-import ttk
-from test.test_support import requires, run_unittest
+import tkinter
+from tkinter import ttk
+from test.support import requires, run_unittest
-import support
+import tkinter.test.support as support
requires('gui')
@@ -22,19 +22,19 @@ class LabeledScaleTest(unittest.TestCase):
x = ttk.LabeledScale()
var = x._variable._name
x.destroy()
- self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, var)
+ self.assertRaises(tkinter.TclError, x.tk.globalgetvar, var)
# manually created variable
- myvar = Tkinter.DoubleVar()
+ myvar = tkinter.DoubleVar()
name = myvar._name
x = ttk.LabeledScale(variable=myvar)
x.destroy()
self.assertEqual(x.tk.globalgetvar(name), myvar.get())
del myvar
- self.assertRaises(Tkinter.TclError, x.tk.globalgetvar, name)
+ self.assertRaises(tkinter.TclError, x.tk.globalgetvar, name)
# checking that the tracing callback is properly removed
- myvar = Tkinter.IntVar()
+ myvar = tkinter.IntVar()
# LabeledScale will start tracing myvar
x = ttk.LabeledScale(variable=myvar)
x.destroy()
@@ -45,22 +45,22 @@ class LabeledScaleTest(unittest.TestCase):
# it tries calling instance attributes not yet defined.
ttk.LabeledScale(variable=myvar)
if hasattr(sys, 'last_type'):
- self.assertFalse(sys.last_type == Tkinter.TclError)
+ self.assertFalse(sys.last_type == tkinter.TclError)
def test_initialization(self):
# master passing
x = ttk.LabeledScale()
- self.assertEqual(x.master, Tkinter._default_root)
+ self.assertEqual(x.master, tkinter._default_root)
x.destroy()
- master = Tkinter.Frame()
+ master = tkinter.Frame()
x = ttk.LabeledScale(master)
self.assertEqual(x.master, master)
x.destroy()
# variable initialization/passing
passed_expected = ((2.5, 2), ('0', 0), (0, 0), (10, 10),
- (-1, -1), (sys.maxint + 1, sys.maxint + 1))
+ (-1, -1), (sys.maxsize + 1, sys.maxsize + 1))
for pair in passed_expected:
x = ttk.LabeledScale(from_=pair[0])
self.assertEqual(x.value, pair[1])
@@ -72,7 +72,7 @@ class LabeledScaleTest(unittest.TestCase):
self.assertRaises(ValueError, x._variable.get)
x.destroy()
# variable should have its default value set to the from_ value
- myvar = Tkinter.DoubleVar(value=20)
+ myvar = tkinter.DoubleVar(value=20)
x = ttk.LabeledScale(variable=myvar)
self.assertEqual(x.value, 0)
x.destroy()
@@ -100,7 +100,7 @@ class LabeledScaleTest(unittest.TestCase):
x.destroy()
# extra, and invalid, kwargs
- self.assertRaises(Tkinter.TclError, ttk.LabeledScale, a='b')
+ self.assertRaises(tkinter.TclError, ttk.LabeledScale, a='b')
def test_horizontal_range(self):
@@ -184,7 +184,7 @@ class OptionMenuTest(unittest.TestCase):
def setUp(self):
support.root_deiconify()
- self.textvar = Tkinter.StringVar()
+ self.textvar = tkinter.StringVar()
def tearDown(self):
del self.textvar
@@ -192,18 +192,18 @@ class OptionMenuTest(unittest.TestCase):
def test_widget_destroy(self):
- var = Tkinter.StringVar()
+ var = tkinter.StringVar()
optmenu = ttk.OptionMenu(None, var)
name = var._name
optmenu.update_idletasks()
optmenu.destroy()
self.assertEqual(optmenu.tk.globalgetvar(name), var.get())
del var
- self.assertRaises(Tkinter.TclError, optmenu.tk.globalgetvar, name)
+ self.assertRaises(tkinter.TclError, optmenu.tk.globalgetvar, name)
def test_initialization(self):
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
ttk.OptionMenu, None, self.textvar, invalid='thing')
optmenu = ttk.OptionMenu(None, self.textvar, 'b', 'a', 'b')
@@ -249,7 +249,7 @@ class OptionMenuTest(unittest.TestCase):
self.assertEqual(optmenu._variable.get(), items[0])
# changing to an invalid index shouldn't change the variable
- self.assertRaises(Tkinter.TclError, optmenu['menu'].invoke, -1)
+ self.assertRaises(tkinter.TclError, optmenu['menu'].invoke, -1)
self.assertEqual(optmenu._variable.get(), items[0])
optmenu.destroy()
diff --git a/Lib/lib-tk/test/test_ttk/test_functions.py b/Lib/tkinter/test/test_ttk/test_functions.py
index 15e76c1ed1d..2303e4cd468 100644
--- a/Lib/lib-tk/test/test_ttk/test_functions.py
+++ b/Lib/tkinter/test/test_ttk/test_functions.py
@@ -1,7 +1,6 @@
# -*- encoding: utf-8 -*-
-import sys
import unittest
-import ttk
+from tkinter import ttk
class MockTclObj(object):
typename = 'test'
@@ -10,7 +9,7 @@ class MockTclObj(object):
self.val = val
def __str__(self):
- return unicode(self.val)
+ return str(self.val)
class MockStateSpec(object):
@@ -58,10 +57,10 @@ class InternalFunctionsTest(unittest.TestCase):
{'-test': '{1 -1 {} 2m 0}', '-nochange1': 3,
'-nochange2': 'abc def' })
- opts = {u'αβγ': True, u'á': False}
+ opts = {'αβγ': True, 'á': False}
orig_opts = opts.copy()
# check if giving unicode keys is fine
- check_against(ttk._format_optdict(opts), {u'-αβγ': True, u'-á': False})
+ check_against(ttk._format_optdict(opts), {'-αβγ': True, '-á': False})
# opts should remain unchanged
self.assertEqual(opts, orig_opts)
@@ -72,33 +71,33 @@ class InternalFunctionsTest(unittest.TestCase):
{'-option': '{one two} three'})
# ignore an option
- amount_opts = len(ttk._format_optdict(opts, ignore=(u'á'))) // 2
+ amount_opts = len(ttk._format_optdict(opts, ignore=('á'))) / 2
self.assertEqual(amount_opts, len(opts) - 1)
# ignore non-existing options
- amount_opts = len(ttk._format_optdict(opts, ignore=(u'á', 'b'))) // 2
+ amount_opts = len(ttk._format_optdict(opts, ignore=('á', 'b'))) / 2
self.assertEqual(amount_opts, len(opts) - 1)
# ignore every option
- self.assertFalse(ttk._format_optdict(opts, ignore=opts.keys()))
+ self.assertFalse(ttk._format_optdict(opts, ignore=list(opts.keys())))
def test_format_mapdict(self):
opts = {'a': [('b', 'c', 'val'), ('d', 'otherval'), ('', 'single')]}
result = ttk._format_mapdict(opts)
- self.assertEqual(len(result), len(opts.keys()) * 2)
+ self.assertEqual(len(result), len(list(opts.keys())) * 2)
self.assertEqual(result, ('-a', '{b c} val d otherval {} single'))
self.assertEqual(ttk._format_mapdict(opts, script=True),
('-a', '{{b c} val d otherval {} single}'))
self.assertEqual(ttk._format_mapdict({2: []}), ('-2', ''))
- opts = {u'üñíćódè': [(u'á', u'vãl')]}
+ opts = {'üñíćódè': [('á', 'vãl')]}
result = ttk._format_mapdict(opts)
- self.assertEqual(result, (u'-üñíćódè', u'á vãl'))
+ self.assertEqual(result, ('-üñíćódè', 'á vãl'))
# empty states
- valid = {'opt': [('', u'', 'hi')]}
+ valid = {'opt': [('', '', 'hi')]}
self.assertEqual(ttk._format_mapdict(valid), ('-opt', '{ } hi'))
# when passing multiple states, they all must be strings
@@ -143,10 +142,8 @@ class InternalFunctionsTest(unittest.TestCase):
self.assertEqual(ttk._format_elemcreate('image', False, 'test',
('a', 'b', 'c')), ("test {a b} c", ()))
# state spec and options
- res = ttk._format_elemcreate('image', False, 'test',
- ('a', 'b'), a='x', b='y')
- self.assertEqual(res[0], "test a b")
- self.assertEqual(set(res[1]), {"-a", "x", "-b", "y"})
+ self.assertEqual(ttk._format_elemcreate('image', False, 'test',
+ ('a', 'b'), a='x'), ("test a b", ("-a", "x")))
# format returned values as a tcl script
# state spec with multiple states and an option with a multivalue
self.assertEqual(ttk._format_elemcreate('image', True, 'test',
@@ -212,7 +209,11 @@ class InternalFunctionsTest(unittest.TestCase):
# empty layout
self.assertEqual(ttk._format_layoutlist([])[0], '')
- # smallest (after an empty one) acceptable layout
+ # _format_layoutlist always expects the second item (in every item)
+ # to act like a dict (except when the value evalutes to False).
+ self.assertRaises(AttributeError,
+ ttk._format_layoutlist, [('a', 'b')])
+
smallest = ttk._format_layoutlist([('a', None)], indent=0)
self.assertEqual(smallest,
ttk._format_layoutlist([('a', '')], indent=0))
@@ -225,16 +226,14 @@ class InternalFunctionsTest(unittest.TestCase):
self.assertEqual(sample(i, i), sample_expected(i, i))
# invalid layout format, different kind of exceptions will be
- # raised
+ # raised by internal functions
# plain wrong format
self.assertRaises(ValueError, ttk._format_layoutlist,
['bad', 'format'])
- self.assertRaises(TypeError, ttk._format_layoutlist, None)
- # _format_layoutlist always expects the second item (in every item)
- # to act like a dict (except when the value evalutes to False).
- self.assertRaises(AttributeError,
- ttk._format_layoutlist, [('a', 'b')])
+ # will try to use iteritems in the 'bad' string
+ self.assertRaises(AttributeError, ttk._format_layoutlist,
+ [('name', 'bad')])
# bad children formatting
self.assertRaises(ValueError, ttk._format_layoutlist,
[('name', {'children': {'a': None}})])
@@ -250,11 +249,11 @@ class InternalFunctionsTest(unittest.TestCase):
ttk._script_from_settings({'name': {'layout': None}}),
"ttk::style layout name {\nnull\n}")
- configdict = {u'αβγ': True, u'á': False}
+ configdict = {'αβγ': True, 'á': False}
self.assertTrue(
ttk._script_from_settings({'name': {'configure': configdict}}))
- mapdict = {u'üñíćódè': [(u'á', u'vãl')]}
+ mapdict = {'üñíćódè': [('á', 'vãl')]}
self.assertTrue(
ttk._script_from_settings({'name': {'map': mapdict}}))
@@ -383,25 +382,21 @@ class InternalFunctionsTest(unittest.TestCase):
def test_convert_stringval(self):
tests = (
- (0, 0), ('09', 9), ('a', 'a'), (u'áÚ', u'áÚ'), ([], '[]'),
+ (0, 0), ('09', 9), ('a', 'a'), ('áÚ', 'áÚ'), ([], '[]'),
(None, 'None')
)
for orig, expected in tests:
self.assertEqual(ttk._convert_stringval(orig), expected)
- if sys.getdefaultencoding() == 'ascii':
- self.assertRaises(UnicodeDecodeError,
- ttk._convert_stringval, 'á')
-
class TclObjsToPyTest(unittest.TestCase):
def test_unicode(self):
- adict = {'opt': u'välúè'}
- self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': u'välúè'})
+ adict = {'opt': 'välúè'}
+ self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': 'välúè'})
adict['opt'] = MockTclObj(adict['opt'])
- self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': u'välúè'})
+ self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': 'välúè'})
def test_multivalues(self):
adict = {'opt': [1, 2, 3, 4]}
@@ -410,9 +405,9 @@ class TclObjsToPyTest(unittest.TestCase):
adict['opt'] = [1, 'xm', 3]
self.assertEqual(ttk.tclobjs_to_py(adict), {'opt': [1, 'xm', 3]})
- adict['opt'] = (MockStateSpec('a', 'b'), u'válũè')
+ adict['opt'] = (MockStateSpec('a', 'b'), 'válũè')
self.assertEqual(ttk.tclobjs_to_py(adict),
- {'opt': [('a', 'b', u'válũè')]})
+ {'opt': [('a', 'b', 'válũè')]})
self.assertEqual(ttk.tclobjs_to_py({'x': ['y z']}),
{'x': ['y z']})
@@ -424,5 +419,5 @@ class TclObjsToPyTest(unittest.TestCase):
tests_nogui = (InternalFunctionsTest, TclObjsToPyTest)
if __name__ == "__main__":
- from test.test_support import run_unittest
+ from test.support import run_unittest
run_unittest(*tests_nogui)
diff --git a/Lib/lib-tk/test/test_ttk/test_style.py b/Lib/tkinter/test/test_ttk/test_style.py
index 630e0750d0b..e9a1eb4ad8e 100644
--- a/Lib/lib-tk/test/test_ttk/test_style.py
+++ b/Lib/tkinter/test/test_ttk/test_style.py
@@ -1,9 +1,9 @@
import unittest
-import Tkinter
-import ttk
-from test.test_support import requires, run_unittest
+import tkinter
+from tkinter import ttk
+from test.support import requires, run_unittest
-import support
+import tkinter.test.support as support
requires('gui')
@@ -43,7 +43,7 @@ class StyleTest(unittest.TestCase):
def test_layout(self):
style = self.style
- self.assertRaises(Tkinter.TclError, style.layout, 'NotALayout')
+ self.assertRaises(tkinter.TclError, style.layout, 'NotALayout')
tv_style = style.layout('Treeview')
# "erase" Treeview layout
@@ -60,12 +60,12 @@ class StyleTest(unittest.TestCase):
self.assertTrue(isinstance(style.layout('TButton'), list))
# correct layout, but "option" doesn't exist as option
- self.assertRaises(Tkinter.TclError, style.layout, 'Treeview',
+ self.assertRaises(tkinter.TclError, style.layout, 'Treeview',
[('name', {'option': 'inexistent'})])
def test_theme_use(self):
- self.assertRaises(Tkinter.TclError, self.style.theme_use,
+ self.assertRaises(tkinter.TclError, self.style.theme_use,
'nonexistingname')
curr_theme = self.style.theme_use()
diff --git a/Lib/lib-tk/test/test_ttk/test_widgets.py b/Lib/tkinter/test/test_ttk/test_widgets.py
index aca90cf80bd..f5c0f17dd0f 100644
--- a/Lib/lib-tk/test/test_ttk/test_widgets.py
+++ b/Lib/tkinter/test/test_ttk/test_widgets.py
@@ -1,11 +1,12 @@
import unittest
-import Tkinter
-import ttk
-from test.test_support import requires, run_unittest
+import tkinter
+import os
+from tkinter import ttk
+from test.support import requires, run_unittest
import sys
-import support
-from test_functions import MockTclObj, MockStateSpec
+import tkinter.test.support as support
+from tkinter.test.test_ttk.test_functions import MockTclObj, MockStateSpec
requires('gui')
@@ -31,9 +32,9 @@ class WidgetTest(unittest.TestCase):
), "label")
self.assertEqual(self.widget.identify(-1, -1), "")
- self.assertRaises(Tkinter.TclError, self.widget.identify, None, 5)
- self.assertRaises(Tkinter.TclError, self.widget.identify, 5, None)
- self.assertRaises(Tkinter.TclError, self.widget.identify, 5, '')
+ self.assertRaises(tkinter.TclError, self.widget.identify, None, 5)
+ self.assertRaises(tkinter.TclError, self.widget.identify, 5, None)
+ self.assertRaises(tkinter.TclError, self.widget.identify, 5, '')
def test_widget_state(self):
@@ -60,9 +61,9 @@ class WidgetTest(unittest.TestCase):
# attempt to set invalid statespec
currstate = self.widget.state()
- self.assertRaises(Tkinter.TclError, self.widget.instate,
+ self.assertRaises(tkinter.TclError, self.widget.instate,
['badstate'])
- self.assertRaises(Tkinter.TclError, self.widget.instate,
+ self.assertRaises(tkinter.TclError, self.widget.instate,
['disabled', 'badstate'])
# verify that widget didn't change its state
self.assertEqual(currstate, self.widget.state())
@@ -93,7 +94,7 @@ class CheckbuttonTest(unittest.TestCase):
# the variable automatically created by ttk.Checkbutton is actually
# undefined till we invoke the Checkbutton
self.assertEqual(cbtn.state(), ('alternate', ))
- self.assertRaises(Tkinter.TclError, cbtn.tk.globalgetvar,
+ self.assertRaises(tkinter.TclError, cbtn.tk.globalgetvar,
cbtn['variable'])
res = cbtn.invoke()
@@ -189,10 +190,10 @@ class ComboboxTest(unittest.TestCase):
self.assertEqual(self.combo['values'], ('1', '', '2'))
# out of range
- self.assertRaises(Tkinter.TclError, self.combo.current,
+ self.assertRaises(tkinter.TclError, self.combo.current,
len(self.combo['values']))
# it expects an integer (or something that can be converted to int)
- self.assertRaises(Tkinter.TclError, self.combo.current, '')
+ self.assertRaises(tkinter.TclError, self.combo.current, '')
# testing creating combobox with empty string in values
combo2 = ttk.Combobox(values=[1, 2, ''])
@@ -216,8 +217,8 @@ class EntryTest(unittest.TestCase):
for item in self.entry.bbox(0):
self.assertTrue(isinstance(item, int))
- self.assertRaises(Tkinter.TclError, self.entry.bbox, 'noindex')
- self.assertRaises(Tkinter.TclError, self.entry.bbox, None)
+ self.assertRaises(tkinter.TclError, self.entry.bbox, 'noindex')
+ self.assertRaises(tkinter.TclError, self.entry.bbox, None)
def test_identify(self):
@@ -228,9 +229,9 @@ class EntryTest(unittest.TestCase):
self.assertEqual(self.entry.identify(5, 5), "textarea")
self.assertEqual(self.entry.identify(-1, -1), "")
- self.assertRaises(Tkinter.TclError, self.entry.identify, None, 5)
- self.assertRaises(Tkinter.TclError, self.entry.identify, 5, None)
- self.assertRaises(Tkinter.TclError, self.entry.identify, 5, '')
+ self.assertRaises(tkinter.TclError, self.entry.identify, None, 5)
+ self.assertRaises(tkinter.TclError, self.entry.identify, 5, None)
+ self.assertRaises(tkinter.TclError, self.entry.identify, 5, '')
def test_validation_options(self):
@@ -258,7 +259,7 @@ class EntryTest(unittest.TestCase):
self.assertEqual(len(success), 1)
self.entry['validatecommand'] = True
- self.assertRaises(Tkinter.TclError, self.entry.validate)
+ self.assertRaises(tkinter.TclError, self.entry.validate)
def test_validation(self):
@@ -319,49 +320,49 @@ class PanedwindowTest(unittest.TestCase):
# attempt to add a child that is not a direct child of the paned window
label = ttk.Label(self.paned)
child = ttk.Label(label)
- self.assertRaises(Tkinter.TclError, self.paned.add, child)
+ self.assertRaises(tkinter.TclError, self.paned.add, child)
label.destroy()
child.destroy()
# another attempt
label = ttk.Label()
child = ttk.Label(label)
- self.assertRaises(Tkinter.TclError, self.paned.add, child)
+ self.assertRaises(tkinter.TclError, self.paned.add, child)
child.destroy()
label.destroy()
good_child = ttk.Label()
self.paned.add(good_child)
# re-adding a child is not accepted
- self.assertRaises(Tkinter.TclError, self.paned.add, good_child)
+ self.assertRaises(tkinter.TclError, self.paned.add, good_child)
other_child = ttk.Label(self.paned)
self.paned.add(other_child)
self.assertEqual(self.paned.pane(0), self.paned.pane(1))
- self.assertRaises(Tkinter.TclError, self.paned.pane, 2)
+ self.assertRaises(tkinter.TclError, self.paned.pane, 2)
good_child.destroy()
other_child.destroy()
- self.assertRaises(Tkinter.TclError, self.paned.pane, 0)
+ self.assertRaises(tkinter.TclError, self.paned.pane, 0)
def test_forget(self):
- self.assertRaises(Tkinter.TclError, self.paned.forget, None)
- self.assertRaises(Tkinter.TclError, self.paned.forget, 0)
+ self.assertRaises(tkinter.TclError, self.paned.forget, None)
+ self.assertRaises(tkinter.TclError, self.paned.forget, 0)
self.paned.add(ttk.Label())
self.paned.forget(0)
- self.assertRaises(Tkinter.TclError, self.paned.forget, 0)
+ self.assertRaises(tkinter.TclError, self.paned.forget, 0)
def test_insert(self):
- self.assertRaises(Tkinter.TclError, self.paned.insert, None, 0)
- self.assertRaises(Tkinter.TclError, self.paned.insert, 0, None)
- self.assertRaises(Tkinter.TclError, self.paned.insert, 0, 0)
+ self.assertRaises(tkinter.TclError, self.paned.insert, None, 0)
+ self.assertRaises(tkinter.TclError, self.paned.insert, 0, None)
+ self.assertRaises(tkinter.TclError, self.paned.insert, 0, 0)
child = ttk.Label()
child2 = ttk.Label()
child3 = ttk.Label()
- self.assertRaises(Tkinter.TclError, self.paned.insert, 0, child)
+ self.assertRaises(tkinter.TclError, self.paned.insert, 0, child)
self.paned.insert('end', child2)
self.paned.insert(0, child)
@@ -388,7 +389,7 @@ class PanedwindowTest(unittest.TestCase):
def test_pane(self):
- self.assertRaises(Tkinter.TclError, self.paned.pane, 0)
+ self.assertRaises(tkinter.TclError, self.paned.pane, 0)
child = ttk.Label()
self.paned.add(child)
@@ -398,21 +399,21 @@ class PanedwindowTest(unittest.TestCase):
self.assertEqual(self.paned.pane(0, 'weight'), 0)
self.assertEqual(self.paned.pane(0), self.paned.pane(str(child)))
- self.assertRaises(Tkinter.TclError, self.paned.pane, 0,
+ self.assertRaises(tkinter.TclError, self.paned.pane, 0,
badoption='somevalue')
def test_sashpos(self):
- self.assertRaises(Tkinter.TclError, self.paned.sashpos, None)
- self.assertRaises(Tkinter.TclError, self.paned.sashpos, '')
- self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
+ self.assertRaises(tkinter.TclError, self.paned.sashpos, None)
+ self.assertRaises(tkinter.TclError, self.paned.sashpos, '')
+ self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child = ttk.Label(self.paned, text='a')
self.paned.add(child, weight=1)
- self.assertRaises(Tkinter.TclError, self.paned.sashpos, 0)
+ self.assertRaises(tkinter.TclError, self.paned.sashpos, 0)
child2 = ttk.Label(self.paned, text='b')
self.paned.add(child2)
- self.assertRaises(Tkinter.TclError, self.paned.sashpos, 1)
+ self.assertRaises(tkinter.TclError, self.paned.sashpos, 1)
self.paned.pack(expand=True, fill='both')
self.paned.wait_visibility()
@@ -431,7 +432,7 @@ class RadiobuttonTest(unittest.TestCase):
success.append(1)
return "cb test called"
- myvar = Tkinter.IntVar()
+ myvar = tkinter.IntVar()
cbtn = ttk.Radiobutton(command=cb_test, variable=myvar, value=0)
cbtn2 = ttk.Radiobutton(command=cb_test, variable=myvar, value=1)
@@ -495,8 +496,8 @@ class ScaleTest(unittest.TestCase):
self.scale['value'] = 30
self.assertEqual(self.scale.get(), self.scale['value'])
- self.assertRaises(Tkinter.TclError, self.scale.get, '', 0)
- self.assertRaises(Tkinter.TclError, self.scale.get, 0, '')
+ self.assertRaises(tkinter.TclError, self.scale.get, '', 0)
+ self.assertRaises(tkinter.TclError, self.scale.get, 0, '')
def test_set(self):
@@ -510,7 +511,7 @@ class ScaleTest(unittest.TestCase):
self.assertEqual(self.scale.get(), min)
# changing directly the variable doesn't impose this limitation tho
- var = Tkinter.DoubleVar()
+ var = tkinter.DoubleVar()
self.scale['variable'] = var
var.set(max + 5)
self.assertEqual(self.scale.get(), var.get())
@@ -527,7 +528,7 @@ class ScaleTest(unittest.TestCase):
self.assertEqual(self.scale.get(0, 0), min)
self.assertEqual(self.scale.get(self.scale.winfo_width(), 0), max)
- self.assertRaises(Tkinter.TclError, self.scale.set, None)
+ self.assertRaises(tkinter.TclError, self.scale.set, None)
class NotebookTest(unittest.TestCase):
@@ -550,7 +551,7 @@ class NotebookTest(unittest.TestCase):
def test_tab_identifiers(self):
self.nb.forget(0)
self.nb.hide(self.child2)
- self.assertRaises(Tkinter.TclError, self.nb.tab, self.child1)
+ self.assertRaises(tkinter.TclError, self.nb.tab, self.child1)
self.assertEqual(self.nb.index('end'), 1)
self.nb.add(self.child2)
self.assertEqual(self.nb.index('end'), 1)
@@ -571,7 +572,7 @@ class NotebookTest(unittest.TestCase):
try:
if self.nb.tab('@%d, 5' % i, text=None) == 'a':
break
- except Tkinter.TclError:
+ except tkinter.TclError:
pass
else:
@@ -579,11 +580,11 @@ class NotebookTest(unittest.TestCase):
def test_add_and_hidden(self):
- self.assertRaises(Tkinter.TclError, self.nb.hide, -1)
- self.assertRaises(Tkinter.TclError, self.nb.hide, 'hi')
- self.assertRaises(Tkinter.TclError, self.nb.hide, None)
- self.assertRaises(Tkinter.TclError, self.nb.add, None)
- self.assertRaises(Tkinter.TclError, self.nb.add, ttk.Label(),
+ self.assertRaises(tkinter.TclError, self.nb.hide, -1)
+ self.assertRaises(tkinter.TclError, self.nb.hide, 'hi')
+ self.assertRaises(tkinter.TclError, self.nb.hide, None)
+ self.assertRaises(tkinter.TclError, self.nb.add, None)
+ self.assertRaises(tkinter.TclError, self.nb.add, ttk.Label(),
unknown='option')
tabs = self.nb.tabs()
@@ -608,9 +609,9 @@ class NotebookTest(unittest.TestCase):
def test_forget(self):
- self.assertRaises(Tkinter.TclError, self.nb.forget, -1)
- self.assertRaises(Tkinter.TclError, self.nb.forget, 'hi')
- self.assertRaises(Tkinter.TclError, self.nb.forget, None)
+ self.assertRaises(tkinter.TclError, self.nb.forget, -1)
+ self.assertRaises(tkinter.TclError, self.nb.forget, 'hi')
+ self.assertRaises(tkinter.TclError, self.nb.forget, None)
tabs = self.nb.tabs()
child1_index = self.nb.index(self.child1)
@@ -624,8 +625,8 @@ class NotebookTest(unittest.TestCase):
def test_index(self):
- self.assertRaises(Tkinter.TclError, self.nb.index, -1)
- self.assertRaises(Tkinter.TclError, self.nb.index, None)
+ self.assertRaises(tkinter.TclError, self.nb.index, -1)
+ self.assertRaises(tkinter.TclError, self.nb.index, None)
self.assertTrue(isinstance(self.nb.index('end'), int))
self.assertEqual(self.nb.index(self.child1), 0)
@@ -645,8 +646,8 @@ class NotebookTest(unittest.TestCase):
self.nb.insert('end', 0)
self.assertEqual(self.nb.tabs(), tabs)
# bad moves
- self.assertRaises(Tkinter.TclError, self.nb.insert, 2, tabs[0])
- self.assertRaises(Tkinter.TclError, self.nb.insert, -1, tabs[0])
+ self.assertRaises(tkinter.TclError, self.nb.insert, 2, tabs[0])
+ self.assertRaises(tkinter.TclError, self.nb.insert, -1, tabs[0])
# new tab
child3 = ttk.Label()
@@ -657,13 +658,13 @@ class NotebookTest(unittest.TestCase):
self.nb.insert(self.child1, child3)
self.assertEqual(self.nb.tabs(), (str(child3), ) + tabs)
self.nb.forget(child3)
- self.assertRaises(Tkinter.TclError, self.nb.insert, 2, child3)
- self.assertRaises(Tkinter.TclError, self.nb.insert, -1, child3)
+ self.assertRaises(tkinter.TclError, self.nb.insert, 2, child3)
+ self.assertRaises(tkinter.TclError, self.nb.insert, -1, child3)
# bad inserts
- self.assertRaises(Tkinter.TclError, self.nb.insert, 'end', None)
- self.assertRaises(Tkinter.TclError, self.nb.insert, None, 0)
- self.assertRaises(Tkinter.TclError, self.nb.insert, None, None)
+ self.assertRaises(tkinter.TclError, self.nb.insert, 'end', None)
+ self.assertRaises(tkinter.TclError, self.nb.insert, None, 0)
+ self.assertRaises(tkinter.TclError, self.nb.insert, None, None)
def test_select(self):
@@ -687,9 +688,9 @@ class NotebookTest(unittest.TestCase):
def test_tab(self):
- self.assertRaises(Tkinter.TclError, self.nb.tab, -1)
- self.assertRaises(Tkinter.TclError, self.nb.tab, 'notab')
- self.assertRaises(Tkinter.TclError, self.nb.tab, None)
+ self.assertRaises(tkinter.TclError, self.nb.tab, -1)
+ self.assertRaises(tkinter.TclError, self.nb.tab, 'notab')
+ self.assertRaises(tkinter.TclError, self.nb.tab, None)
self.assertTrue(isinstance(self.nb.tab(self.child1), dict))
self.assertEqual(self.nb.tab(self.child1, text=None), 'a')
@@ -794,7 +795,7 @@ class TreeviewTest(unittest.TestCase):
# child3 has child2 as parent, thus trying to set child2 as a children
# of child3 should result in an error
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.set_children, child3, child2)
# remove child2 children
@@ -817,20 +818,20 @@ class TreeviewTest(unittest.TestCase):
self.assertEqual(self.tv.column('#0', 'width'), 10)
self.assertEqual(self.tv.column('#0', width=None), 10)
# check read-only option
- self.assertRaises(Tkinter.TclError, self.tv.column, '#0', id='X')
+ self.assertRaises(tkinter.TclError, self.tv.column, '#0', id='X')
- self.assertRaises(Tkinter.TclError, self.tv.column, 'invalid')
+ self.assertRaises(tkinter.TclError, self.tv.column, 'invalid')
invalid_kws = [
{'unknown_option': 'some value'}, {'stretch': 'wrong'},
{'anchor': 'wrong'}, {'width': 'wrong'}, {'minwidth': 'wrong'}
]
for kw in invalid_kws:
- self.assertRaises(Tkinter.TclError, self.tv.column, '#0',
+ self.assertRaises(tkinter.TclError, self.tv.column, '#0',
**kw)
def test_delete(self):
- self.assertRaises(Tkinter.TclError, self.tv.delete, '#0')
+ self.assertRaises(tkinter.TclError, self.tv.delete, '#0')
item_id = self.tv.insert('', 'end')
item2 = self.tv.insert(item_id, 'end')
@@ -841,7 +842,7 @@ class TreeviewTest(unittest.TestCase):
self.assertFalse(self.tv.get_children())
# reattach should fail
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.reattach, item_id, '', 'end')
# test multiple item delete
@@ -880,13 +881,13 @@ class TreeviewTest(unittest.TestCase):
self.assertEqual(self.tv.get_children(item_id), ())
# bad values
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.reattach, 'nonexistent', '', 'end')
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.detach, 'nonexistent')
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.reattach, item2, 'otherparent', 'end')
- self.assertRaises(Tkinter.TclError,
+ self.assertRaises(tkinter.TclError,
self.tv.reattach, item2, '', 'invalid')
# multiple detach
@@ -903,7 +904,7 @@ class TreeviewTest(unittest.TestCase):
# the following will make a tk.call equivalent to
# tk.call(treeview, "exists") which should result in an error
# in the tcl interpreter since tk requires an item.
- self.assertRaises(Tkinter.TclError, self.tv.exists, None)
+ self.assertRaises(tkinter.TclError, self.tv.exists, None)
def test_focus(self):
@@ -918,7 +919,7 @@ class TreeviewTest(unittest.TestCase):
self.assertEqual(self.tv.focus(), '')
# try focusing inexistent item
- self.assertRaises(Tkinter.TclError, self.tv.focus, 'hi')
+ self.assertRaises(tkinter.TclError, self.tv.focus, 'hi')
def test_heading(self):
@@ -931,14 +932,14 @@ class TreeviewTest(unittest.TestCase):
self.assertEqual(self.tv.heading('#0', text=None), 'hi')
# invalid option
- self.assertRaises(Tkinter.TclError, self.tv.heading, '#0',
+ self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
background=None)
# invalid value
- self.assertRaises(Tkinter.TclError, self.tv.heading, '#0',
+ self.assertRaises(tkinter.TclError, self.tv.heading, '#0',
anchor=1)
# XXX skipping for now; should be fixed to work with newer ttk
- @unittest.skip("skipping pending resolution of Issue #10734")
+ @unittest.skip
def test_heading_callback(self):
def simulate_heading_click(x, y):
support.simulate_mouse_click(self.tv, x, y)
@@ -975,7 +976,7 @@ class TreeviewTest(unittest.TestCase):
def test_index(self):
# item 'what' doesn't exist
- self.assertRaises(Tkinter.TclError, self.tv.index, 'what')
+ self.assertRaises(tkinter.TclError, self.tv.index, 'what')
self.assertEqual(self.tv.index(''), 0)
@@ -1001,34 +1002,34 @@ class TreeviewTest(unittest.TestCase):
# but it fails after item has been deleted
self.tv.delete(item1)
- self.assertRaises(Tkinter.TclError, self.tv.index, c2)
+ self.assertRaises(tkinter.TclError, self.tv.index, c2)
def test_insert_item(self):
# parent 'none' doesn't exist
- self.assertRaises(Tkinter.TclError, self.tv.insert, 'none', 'end')
+ self.assertRaises(tkinter.TclError, self.tv.insert, 'none', 'end')
# open values
- self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
+ self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
open='')
- self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
+ self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
open='please')
self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=True)))
self.assertFalse(self.tv.delete(self.tv.insert('', 'end', open=False)))
# invalid index
- self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'middle')
+ self.assertRaises(tkinter.TclError, self.tv.insert, '', 'middle')
# trying to duplicate item id is invalid
itemid = self.tv.insert('', 'end', 'first-item')
self.assertEqual(itemid, 'first-item')
- self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
+ self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
'first-item')
- self.assertRaises(Tkinter.TclError, self.tv.insert, '', 'end',
+ self.assertRaises(tkinter.TclError, self.tv.insert, '', 'end',
MockTclObj('first-item'))
# unicode values
- value = u'\xe1ba'
+ value = '\xe1ba'
item = self.tv.insert('', 'end', values=(value, ))
self.assertEqual(self.tv.item(item, 'values'), (value, ))
self.assertEqual(self.tv.item(item, values=None), (value, ))
@@ -1086,11 +1087,11 @@ class TreeviewTest(unittest.TestCase):
self.assertEqual(self.tv.set(item), {'B': 123})
# inexistent column
- self.assertRaises(Tkinter.TclError, self.tv.set, item, 'A')
- self.assertRaises(Tkinter.TclError, self.tv.set, item, 'A', 'b')
+ self.assertRaises(tkinter.TclError, self.tv.set, item, 'A')
+ self.assertRaises(tkinter.TclError, self.tv.set, item, 'A', 'b')
# inexistent item
- self.assertRaises(Tkinter.TclError, self.tv.set, 'notme')
+ self.assertRaises(tkinter.TclError, self.tv.set, 'notme')
def test_tag_bind(self):
@@ -1130,7 +1131,7 @@ class TreeviewTest(unittest.TestCase):
def test_tag_configure(self):
# Just testing parameter passing for now
self.assertRaises(TypeError, self.tv.tag_configure)
- self.assertRaises(Tkinter.TclError, self.tv.tag_configure,
+ self.assertRaises(tkinter.TclError, self.tv.tag_configure,
'test', sky='blue')
self.tv.tag_configure('test', foreground='blue')
self.assertEqual(str(self.tv.tag_configure('test', 'foreground')),
diff --git a/Lib/lib-tk/Tix.py b/Lib/tkinter/tix.py
index d474235e852..18866c432db 100644
--- a/Lib/lib-tk/Tix.py
+++ b/Lib/tkinter/tix.py
@@ -1,4 +1,4 @@
-# -*-mode: python; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
+# -*-mode: python; fill-column: 75; tab-width: 8 -*-
#
# $Id$
#
@@ -26,12 +26,12 @@
# appreciate the advantages.
#
-from Tkinter import *
-from Tkinter import _flatten, _cnfmerge, _default_root
+from tkinter import *
+from tkinter import _flatten, _cnfmerge, _default_root
# WARNING - TkVersion is a limited precision floating point number
if TkVersion < 3.999:
- raise ImportError, "This version of Tix.py requires Tk 4.0 or higher"
+ raise ImportError("This version of Tix.py requires Tk 4.0 or higher")
import _tkinter # If this fails your Python may not be configured for Tk
@@ -72,7 +72,7 @@ TCL_ALL_EVENTS = 0
# BEWARE - this is implemented by copying some code from the Widget class
# in Tkinter (to override Widget initialization) and is therefore
# liable to break.
-import Tkinter, os
+import tkinter, os
# Could probably add this to Tkinter.Misc
class tixCommand:
@@ -207,11 +207,11 @@ class tixCommand:
else:
return self.tk.call('tix', 'resetoptions', newScheme, newFontSet)
-class Tk(Tkinter.Tk, tixCommand):
+class Tk(tkinter.Tk, tixCommand):
"""Toplevel widget of Tix which represents mostly the main window
of an application. It has an associated Tcl interpreter."""
def __init__(self, screenName=None, baseName=None, className='Tix'):
- Tkinter.Tk.__init__(self, screenName, baseName, className)
+ tkinter.Tk.__init__(self, screenName, baseName, className)
tixlib = os.environ.get('TIX_LIBRARY')
self.tk.eval('global auto_path; lappend auto_path [file dir [info nameof]]')
if tixlib is not None:
@@ -227,7 +227,7 @@ class Tk(Tkinter.Tk, tixCommand):
def destroy(self):
# For safety, remove an delete_window binding before destroy
self.protocol("WM_DELETE_WINDOW", "")
- Tkinter.Tk.destroy(self)
+ tkinter.Tk.destroy(self)
# The Tix 'tixForm' geometry manager
class Form:
@@ -268,16 +268,16 @@ class Form:
return self.tk.call('tixForm', 'info', self._w, option)
def slaves(self):
- return map(self._nametowidget,
- self.tk.splitlist(
+ return [self._nametowidget(x) for x in
+ self.tk.splitlist(
self.tk.call(
- 'tixForm', 'slaves', self._w)))
+ 'tixForm', 'slaves', self._w))]
-Tkinter.Widget.__bases__ = Tkinter.Widget.__bases__ + (Form,)
+tkinter.Widget.__bases__ = tkinter.Widget.__bases__ + (Form,)
-class TixWidget(Tkinter.Widget):
+class TixWidget(tkinter.Widget):
"""A TixWidget class is used to package all (or most) Tix widgets.
Widget initialization is extended in two ways:
@@ -308,7 +308,7 @@ class TixWidget(Tkinter.Widget):
else:
static_options = ['options']
- for k,v in cnf.items()[:]:
+ for k,v in list(cnf.items()):
if k in static_options:
extra = extra + ('-' + k, v)
del cnf[k]
@@ -338,7 +338,7 @@ class TixWidget(Tkinter.Widget):
def __getattr__(self, name):
if name in self.subwidget_list:
return self.subwidget_list[name]
- raise AttributeError, name
+ raise AttributeError(name)
def set_silent(self, value):
"""Set a variable without calling its action routine"""
@@ -349,7 +349,7 @@ class TixWidget(Tkinter.Widget):
the sub-class)."""
n = self._subwidget_name(name)
if not n:
- raise TclError, "Subwidget " + name + " not child of " + self._name
+ raise TclError("Subwidget " + name + " not child of " + self._name)
# Remove header of name and leading dot
n = n[len(self._w)+1:]
return self._nametowidget(n)
@@ -398,14 +398,14 @@ class TixWidget(Tkinter.Widget):
# These are missing from Tkinter
def image_create(self, imgtype, cnf={}, master=None, **kw):
if not master:
- master = Tkinter._default_root
+ master = tkinter._default_root
if not master:
- raise RuntimeError, 'Too early to create image'
+ raise RuntimeError('Too early to create image')
if kw and cnf: cnf = _cnfmerge((cnf, kw))
elif kw: cnf = kw
options = ()
for k, v in cnf.items():
- if hasattr(v, '__call__'):
+ if callable(v):
v = self._register(v)
options = options + ('-'+k, v)
return master.tk.call(('image', 'create', imgtype,) + options)
@@ -463,7 +463,7 @@ class TixSubWidget(TixWidget):
# we must be careful not to destroy the frame widget since this
# also destroys the parent NoteBook thus leading to an exception
# in Tkinter when it finally calls Tcl to destroy the NoteBook
- for c in self.children.values(): c.destroy()
+ for c in list(self.children.values()): c.destroy()
if self._name in self.master.children:
del self.master.children[self._name]
if self._name in self.master.subwidget_list:
@@ -490,7 +490,7 @@ class DisplayStyle:
master = _default_root # global from Tkinter
if not master and 'refwindow' in cnf: master=cnf['refwindow']
elif not master and 'refwindow' in kw: master= kw['refwindow']
- elif not master: raise RuntimeError, "Too early to create display style: no root window"
+ elif not master: raise RuntimeError("Too early to create display style: no root window")
self.tk = master.tk
self.stylename = self.tk.call('tixDisplayStyle', itemtype,
*self._options(cnf,kw) )
@@ -1201,8 +1201,7 @@ class OptionMenu(TixWidget):
menu Menu"""
def __init__(self, master, cnf={}, **kw):
- TixWidget.__init__(self, master, 'tixOptionMenu',
- ['labelside', 'options'], cnf, kw)
+ TixWidget.__init__(self, master, 'tixOptionMenu', ['options'], cnf, kw)
self.subwidget_list['menubutton'] = _dummyMenubutton(self, 'menubutton')
self.subwidget_list['menu'] = _dummyMenu(self, 'menu')
@@ -1555,8 +1554,8 @@ class Tree(TixWidget):
'''This command is used to indicate whether the entry given by
entryPath has children entries and whether the children are visible. mode
must be one of open, close or none. If mode is set to open, a (+)
- indicator is drawn next to the entry. If mode is set to close, a (-)
- indicator is drawn next to the entry. If mode is set to none, no
+ indicator is drawn next the entry. If mode is set to close, a (-)
+ indicator is drawn next the entry. If mode is set to none, no
indicators will be drawn for this entry. The default mode is none. The
open mode indicates the entry has hidden children and this entry can be
opened by the user. The close mode indicates that all the children of the
diff --git a/Lib/lib-tk/ttk.py b/Lib/tkinter/ttk.py
index d632f77e9fb..5ae20a86789 100644
--- a/Lib/lib-tk/ttk.py
+++ b/Lib/tkinter/ttk.py
@@ -25,12 +25,12 @@ __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
# functions
"tclobjs_to_py", "setup_master"]
-import Tkinter
+import tkinter
-_flatten = Tkinter._flatten
+_flatten = tkinter._flatten
# Verify if Tk is new enough to not need the Tile package
-_REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False
+_REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
def _load_tile(master):
if _REQUIRE_TILE:
@@ -56,15 +56,15 @@ def _format_optdict(optdict, script=False, ignore=None):
format = "%s" if not script else "{%s}"
opts = []
- for opt, value in optdict.iteritems():
+ for opt, value in optdict.items():
if ignore and opt in ignore:
continue
if isinstance(value, (list, tuple)):
v = []
for val in value:
- if isinstance(val, basestring):
- v.append(unicode(val) if val else '{}')
+ if isinstance(val, str):
+ v.append(str(val) if val else '{}')
else:
v.append(str(val))
@@ -95,7 +95,7 @@ def _format_mapdict(mapdict, script=False):
format = "%s" if not script else "{%s}"
opts = []
- for opt, value in mapdict.iteritems():
+ for opt, value in mapdict.items():
opt_val = []
# each value in mapdict is expected to be a sequence, where each item
@@ -212,14 +212,14 @@ def _script_from_settings(settings):
script = []
# a script will be generated according to settings passed, which
# will then be evaluated by Tcl
- for name, opts in settings.iteritems():
+ for name, opts in settings.items():
# will format specific keys according to Tcl code
if opts.get('configure'): # format 'configure'
- s = ' '.join(map(unicode, _format_optdict(opts['configure'], True)))
+ s = ' '.join(map(str, _format_optdict(opts['configure'], True)))
script.append("ttk::style configure %s %s;" % (name, s))
if opts.get('map'): # format 'map'
- s = ' '.join(map(unicode, _format_mapdict(opts['map'], True)))
+ s = ' '.join(map(str, _format_mapdict(opts['map'], True)))
script.append("ttk::style map %s %s;" % (name, s))
if 'layout' in opts: # format 'layout' which may be empty
@@ -235,7 +235,7 @@ def _script_from_settings(settings):
# find where args end, and where kwargs start
argc = 1 # etype was the first one
- while argc < len(eopts) and not hasattr(eopts[argc], 'iteritems'):
+ while argc < len(eopts) and not hasattr(eopts[argc], 'items'):
argc += 1
elemargs = eopts[1:argc]
@@ -324,7 +324,7 @@ def _val_or_dict(options, func, *args):
def _convert_stringval(value):
"""Converts a value to, hopefully, a more appropriate Python object."""
- value = unicode(value)
+ value = str(value)
try:
value = int(value)
except (ValueError, TypeError):
@@ -335,12 +335,12 @@ def _convert_stringval(value):
def tclobjs_to_py(adict):
"""Returns adict with its values converted from Tcl objects to Python
objects."""
- for opt, val in adict.iteritems():
- if val and hasattr(val, '__len__') and not isinstance(val, basestring):
+ for opt, val in adict.items():
+ if val and hasattr(val, '__len__') and not isinstance(val, str):
if getattr(val[0], 'typename', None) == 'StateSpec':
val = _list_from_statespec(val)
else:
- val = map(_convert_stringval, val)
+ val = list(map(_convert_stringval, val))
elif hasattr(val, 'typename'): # some other (single) Tcl object
val = _convert_stringval(val)
@@ -357,11 +357,11 @@ def setup_master(master=None):
If it is not allowed to use the default root and master is None,
RuntimeError is raised."""
if master is None:
- if Tkinter._support_default_root:
- master = Tkinter._default_root or Tkinter.Tk()
+ if tkinter._support_default_root:
+ master = tkinter._default_root or tkinter.Tk()
else:
raise RuntimeError(
- "No master specified and Tkinter is "
+ "No master specified and tkinter is "
"configured to not support default root")
return master
@@ -530,7 +530,7 @@ class Style(object):
self.tk.call("ttk::setTheme", themename)
-class Widget(Tkinter.Widget):
+class Widget(tkinter.Widget):
"""Base class for Tk themed widgets."""
def __init__(self, master, widgetname, kw=None):
@@ -557,7 +557,7 @@ class Widget(Tkinter.Widget):
if not getattr(master, '_tile_loaded', False):
# Load tile now, if needed
_load_tile(master)
- Tkinter.Widget.__init__(self, master, widgetname, kw=kw)
+ tkinter.Widget.__init__(self, master, widgetname, kw=kw)
def identify(self, x, y):
@@ -648,7 +648,7 @@ class Checkbutton(Widget):
return self.tk.call(self._w, "invoke")
-class Entry(Widget, Tkinter.Entry):
+class Entry(Widget, tkinter.Entry):
"""Ttk Entry widget displays a one-line text string and allows that
string to be edited by the user."""
@@ -798,7 +798,7 @@ class Labelframe(Widget):
"""
Widget.__init__(self, master, "ttk::labelframe", kw)
-LabelFrame = Labelframe # Tkinter name compatibility
+LabelFrame = Labelframe # tkinter name compatibility
class Menubutton(Widget):
@@ -953,7 +953,7 @@ class Notebook(Widget):
self.tk.call("ttk::notebook::enableTraversal", self._w)
-class Panedwindow(Widget, Tkinter.PanedWindow):
+class Panedwindow(Widget, tkinter.PanedWindow):
"""Ttk Panedwindow widget displays a number of subwindows, stacked
either vertically or horizontally."""
@@ -975,7 +975,7 @@ class Panedwindow(Widget, Tkinter.PanedWindow):
Widget.__init__(self, master, "ttk::panedwindow", kw)
- forget = Tkinter.PanedWindow.forget # overrides Pack.forget
+ forget = tkinter.PanedWindow.forget # overrides Pack.forget
def insert(self, pos, child, **kw):
@@ -1009,7 +1009,7 @@ class Panedwindow(Widget, Tkinter.PanedWindow):
Returns the new position of sash number index."""
return self.tk.call(self._w, "sashpos", index, newpos)
-PanedWindow = Panedwindow # Tkinter name compatibility
+PanedWindow = Panedwindow # tkinter name compatibility
class Progressbar(Widget):
@@ -1082,7 +1082,7 @@ class Radiobutton(Widget):
return self.tk.call(self._w, "invoke")
-class Scale(Widget, Tkinter.Scale):
+class Scale(Widget, tkinter.Scale):
"""Ttk Scale widget is typically used to control the numeric value of
a linked variable that varies uniformly over some range."""
@@ -1121,7 +1121,7 @@ class Scale(Widget, Tkinter.Scale):
return self.tk.call(self._w, 'get', x, y)
-class Scrollbar(Widget, Tkinter.Scrollbar):
+class Scrollbar(Widget, tkinter.Scrollbar):
"""Ttk Scrollbar controls the viewport of a scrollable widget."""
def __init__(self, master=None, **kw):
@@ -1170,7 +1170,7 @@ class Sizegrip(Widget):
Widget.__init__(self, master, "ttk::sizegrip", kw)
-class Treeview(Widget, Tkinter.XView, Tkinter.YView):
+class Treeview(Widget, tkinter.XView, tkinter.YView):
"""Ttk Treeview widget displays a hierarchical collection of items.
Each item has a textual label, an optional image, and an optional list
@@ -1286,7 +1286,7 @@ class Treeview(Widget, Tkinter.XView, Tkinter.YView):
To configure the tree column heading, call this with column = "#0" """
cmd = kw.get('command')
- if cmd and not isinstance(cmd, basestring):
+ if cmd and not isinstance(cmd, str):
# callback not registered yet, do it now
kw['command'] = self.master.register(cmd, self._substitute)
@@ -1482,7 +1482,7 @@ class Treeview(Widget, Tkinter.XView, Tkinter.YView):
# Extensions
-class LabeledScale(Frame, object):
+class LabeledScale(Frame):
"""A Ttk Scale widget with a Ttk Label widget indicating its
current value.
@@ -1492,7 +1492,7 @@ class LabeledScale(Frame, object):
def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
"""Construct an horizontal LabeledScale with parent master, a
variable to be associated with the Ttk Scale widget and its range.
- If variable is not specified, a Tkinter.IntVar is created.
+ If variable is not specified, a tkinter.IntVar is created.
WIDGET-SPECIFIC OPTIONS
@@ -1503,7 +1503,7 @@ class LabeledScale(Frame, object):
self._label_top = kw.pop('compound', 'top') == 'top'
Frame.__init__(self, master, **kw)
- self._variable = variable or Tkinter.IntVar(master)
+ self._variable = variable or tkinter.IntVar(master)
self._variable.set(from_)
self._last_valid = from_
@@ -1577,7 +1577,7 @@ class LabeledScale(Frame, object):
class OptionMenu(Menubutton):
- """Themed OptionMenu, based after Tkinter's OptionMenu, which allows
+ """Themed OptionMenu, based after tkinter's OptionMenu, which allows
the user to select a value from a menu."""
def __init__(self, master, variable, default=None, *values, **kwargs):
@@ -1598,13 +1598,13 @@ class OptionMenu(Menubutton):
kw = {'textvariable': variable, 'style': kwargs.pop('style', None),
'direction': kwargs.pop('direction', None)}
Menubutton.__init__(self, master, **kw)
- self['menu'] = Tkinter.Menu(self, tearoff=False)
+ self['menu'] = tkinter.Menu(self, tearoff=False)
self._variable = variable
self._callback = kwargs.pop('command', None)
if kwargs:
- raise Tkinter.TclError('unknown option -%s' % (
- kwargs.iterkeys().next()))
+ raise tkinter.TclError('unknown option -%s' % (
+ next(iter(kwargs.keys()))))
self.set_menu(default, *values)
@@ -1623,7 +1623,7 @@ class OptionMenu(Menubutton):
menu.delete(0, 'end')
for val in values:
menu.add_radiobutton(label=val,
- command=Tkinter._setit(self._variable, val, self._callback))
+ command=tkinter._setit(self._variable, val, self._callback))
if default:
self._variable.set(default)
diff --git a/Lib/toaiff.py b/Lib/toaiff.py
deleted file mode 100644
index 3a2b80cbe38..00000000000
--- a/Lib/toaiff.py
+++ /dev/null
@@ -1,110 +0,0 @@
-"""Convert "arbitrary" sound files to AIFF (Apple and SGI's audio format).
-
-Input may be compressed.
-Uncompressed file type may be AIFF, WAV, VOC, 8SVX, NeXT/Sun, and others.
-An exception is raised if the file is not of a recognized type.
-Returned filename is either the input filename or a temporary filename;
-in the latter case the caller must ensure that it is removed.
-Other temporary files used are removed by the function.
-"""
-from warnings import warnpy3k
-warnpy3k("the toaiff module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-import tempfile
-import pipes
-import sndhdr
-
-__all__ = ["error", "toaiff"]
-
-table = {}
-
-t = pipes.Template()
-t.append('sox -t au - -t aiff -r 8000 -', '--')
-table['au'] = t
-
-# XXX The following is actually sub-optimal.
-# XXX The HCOM sampling rate can be 22k, 22k/2, 22k/3 or 22k/4.
-# XXX We must force the output sampling rate else the SGI won't play
-# XXX files sampled at 5.5k or 7.333k; however this means that files
-# XXX sampled at 11k are unnecessarily expanded.
-# XXX Similar comments apply to some other file types.
-t = pipes.Template()
-t.append('sox -t hcom - -t aiff -r 22050 -', '--')
-table['hcom'] = t
-
-t = pipes.Template()
-t.append('sox -t voc - -t aiff -r 11025 -', '--')
-table['voc'] = t
-
-t = pipes.Template()
-t.append('sox -t wav - -t aiff -', '--')
-table['wav'] = t
-
-t = pipes.Template()
-t.append('sox -t 8svx - -t aiff -r 16000 -', '--')
-table['8svx'] = t
-
-t = pipes.Template()
-t.append('sox -t sndt - -t aiff -r 16000 -', '--')
-table['sndt'] = t
-
-t = pipes.Template()
-t.append('sox -t sndr - -t aiff -r 16000 -', '--')
-table['sndr'] = t
-
-uncompress = pipes.Template()
-uncompress.append('uncompress', '--')
-
-
-class error(Exception):
- pass
-
-def toaiff(filename):
- temps = []
- ret = None
- try:
- ret = _toaiff(filename, temps)
- finally:
- for temp in temps[:]:
- if temp != ret:
- try:
- os.unlink(temp)
- except os.error:
- pass
- temps.remove(temp)
- return ret
-
-def _toaiff(filename, temps):
- if filename[-2:] == '.Z':
- (fd, fname) = tempfile.mkstemp()
- os.close(fd)
- temps.append(fname)
- sts = uncompress.copy(filename, fname)
- if sts:
- raise error, filename + ': uncompress failed'
- else:
- fname = filename
- try:
- ftype = sndhdr.whathdr(fname)
- if ftype:
- ftype = ftype[0] # All we're interested in
- except IOError, msg:
- if type(msg) == type(()) and len(msg) == 2 and \
- type(msg[0]) == type(0) and type(msg[1]) == type(''):
- msg = msg[1]
- if type(msg) != type(''):
- msg = repr(msg)
- raise error, filename + ': ' + msg
- if ftype == 'aiff':
- return fname
- if ftype is None or not ftype in table:
- raise error, '%s: unsupported audio file type %r' % (filename, ftype)
- (fd, temp) = tempfile.mkstemp()
- os.close(fd)
- temps.append(temp)
- sts = table[ftype].copy(fname, temp)
- if sts:
- raise error, filename + ': conversion to aiff failed'
- return temp
diff --git a/Lib/token.py b/Lib/token.py
index 34abf62016a..6b5320db8c3 100755
--- a/Lib/token.py
+++ b/Lib/token.py
@@ -1,7 +1,7 @@
-#! /usr/bin/env python
-
"""Token constants (from "token.h")."""
+__all__ = ['tok_name', 'ISTERMINAL', 'ISNONTERMINAL', 'ISEOF']
+
# This file is automatically generated; please don't muck it up!
#
# To update the symbols in this file, 'cd' to the top directory of
@@ -35,44 +35,43 @@ GREATER = 21
EQUAL = 22
DOT = 23
PERCENT = 24
-BACKQUOTE = 25
-LBRACE = 26
-RBRACE = 27
-EQEQUAL = 28
-NOTEQUAL = 29
-LESSEQUAL = 30
-GREATEREQUAL = 31
-TILDE = 32
-CIRCUMFLEX = 33
-LEFTSHIFT = 34
-RIGHTSHIFT = 35
-DOUBLESTAR = 36
-PLUSEQUAL = 37
-MINEQUAL = 38
-STAREQUAL = 39
-SLASHEQUAL = 40
-PERCENTEQUAL = 41
-AMPEREQUAL = 42
-VBAREQUAL = 43
-CIRCUMFLEXEQUAL = 44
-LEFTSHIFTEQUAL = 45
-RIGHTSHIFTEQUAL = 46
-DOUBLESTAREQUAL = 47
-DOUBLESLASH = 48
-DOUBLESLASHEQUAL = 49
-AT = 50
-OP = 51
-ERRORTOKEN = 52
-N_TOKENS = 53
+LBRACE = 25
+RBRACE = 26
+EQEQUAL = 27
+NOTEQUAL = 28
+LESSEQUAL = 29
+GREATEREQUAL = 30
+TILDE = 31
+CIRCUMFLEX = 32
+LEFTSHIFT = 33
+RIGHTSHIFT = 34
+DOUBLESTAR = 35
+PLUSEQUAL = 36
+MINEQUAL = 37
+STAREQUAL = 38
+SLASHEQUAL = 39
+PERCENTEQUAL = 40
+AMPEREQUAL = 41
+VBAREQUAL = 42
+CIRCUMFLEXEQUAL = 43
+LEFTSHIFTEQUAL = 44
+RIGHTSHIFTEQUAL = 45
+DOUBLESTAREQUAL = 46
+DOUBLESLASH = 47
+DOUBLESLASHEQUAL = 48
+AT = 49
+RARROW = 50
+ELLIPSIS = 51
+OP = 52
+ERRORTOKEN = 53
+N_TOKENS = 54
NT_OFFSET = 256
#--end constants--
-tok_name = {}
-for _name, _value in globals().items():
- if type(_value) is type(0):
- tok_name[_value] = _name
-del _name, _value
-
+tok_name = {value: name
+ for name, value in globals().items()
+ if isinstance(value, int)}
+__all__.extend(tok_name.values())
def ISTERMINAL(x):
return x < NT_OFFSET
@@ -84,7 +83,7 @@ def ISEOF(x):
return x == ENDMARKER
-def main():
+def _main():
import re
import sys
args = sys.argv[1:]
@@ -94,7 +93,7 @@ def main():
outFileName = args[1]
try:
fp = open(inFileName)
- except IOError, err:
+ except IOError as err:
sys.stdout.write("I/O error: %s\n" % str(err))
sys.exit(1)
lines = fp.read().split("\n")
@@ -109,12 +108,11 @@ def main():
name, val = match.group(1, 2)
val = int(val)
tokens[val] = name # reverse so we can sort them...
- keys = tokens.keys()
- keys.sort()
+ keys = sorted(tokens.keys())
# load the output skeleton from the target:
try:
fp = open(outFileName)
- except IOError, err:
+ except IOError as err:
sys.stderr.write("I/O error: %s\n" % str(err))
sys.exit(2)
format = fp.read().split("\n")
@@ -131,7 +129,7 @@ def main():
format[start:end] = lines
try:
fp = open(outFileName, 'w')
- except IOError, err:
+ except IOError as err:
sys.stderr.write("I/O error: %s\n" % str(err))
sys.exit(4)
fp.write("\n".join(format))
@@ -139,4 +137,4 @@ def main():
if __name__ == "__main__":
- main()
+ _main()
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index ca7b07493cf..29c9e29b30f 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -1,9 +1,12 @@
"""Tokenization help for Python programs.
-generate_tokens(readline) is a generator that breaks a stream of
-text into Python tokens. It accepts a readline-like method which is called
-repeatedly to get the next line of input (or "" for EOF). It generates
-5-tuples with these members:
+tokenize(readline) is a generator that breaks a stream of bytes into
+Python tokens. It decodes the bytes according to PEP-0263 for
+determining source file encoding.
+
+It accepts a readline-like method which is called repeatedly to get the
+next line of input (or b"" for EOF). It generates 5-tuples with these
+members:
the token type (see token.py)
the token (a string)
@@ -13,53 +16,63 @@ repeatedly to get the next line of input (or "" for EOF). It generates
It is designed to match the working of the Python tokenizer exactly, except
that it produces COMMENT tokens for comments and gives type OP for all
-operators
-
-Older entry points
- tokenize_loop(readline, tokeneater)
- tokenize(readline, tokeneater=printtoken)
-are the same, except instead of generating tokens, tokeneater is a callback
-function to which the 5 fields described above are passed as 5 arguments,
-each time a new token is found."""
+operators. Additionally, all token lists start with an ENCODING token
+which tells you which encoding was used to decode the bytes stream.
+"""
__author__ = 'Ka-Ping Yee <ping@lfw.org>'
__credits__ = ('GvR, ESR, Tim Peters, Thomas Wouters, Fred Drake, '
- 'Skip Montanaro, Raymond Hettinger')
-
-import string, re
+ 'Skip Montanaro, Raymond Hettinger, Trent Nelson, '
+ 'Michael Foord')
+import builtins
+import re
+import sys
from token import *
+from codecs import lookup, BOM_UTF8
+import collections
+from io import TextIOWrapper
+cookie_re = re.compile("coding[:=]\s*([-\w.]+)")
import token
-__all__ = [x for x in dir(token) if not x.startswith("_")]
-__all__ += ["COMMENT", "tokenize", "generate_tokens", "NL", "untokenize"]
-del x
+__all__ = token.__all__ + ["COMMENT", "tokenize", "detect_encoding",
+ "NL", "untokenize", "ENCODING", "TokenInfo"]
del token
COMMENT = N_TOKENS
tok_name[COMMENT] = 'COMMENT'
NL = N_TOKENS + 1
tok_name[NL] = 'NL'
-N_TOKENS += 2
+ENCODING = N_TOKENS + 2
+tok_name[ENCODING] = 'ENCODING'
+N_TOKENS += 3
+
+class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
+ def __repr__(self):
+ annotated_type = '%d (%s)' % (self.type, tok_name[self.type])
+ return ('TokenInfo(type=%s, string=%r, start=%r, end=%r, line=%r)' %
+ self._replace(type=annotated_type))
def group(*choices): return '(' + '|'.join(choices) + ')'
def any(*choices): return group(*choices) + '*'
def maybe(*choices): return group(*choices) + '?'
+# Note: we use unicode matching for names ("\w") but ascii matching for
+# number literals.
Whitespace = r'[ \f\t]*'
Comment = r'#[^\r\n]*'
Ignore = Whitespace + any(r'\\\r?\n' + Whitespace) + maybe(Comment)
-Name = r'[a-zA-Z_]\w*'
+Name = r'\w+'
-Hexnumber = r'0[xX][\da-fA-F]+[lL]?'
-Octnumber = r'(0[oO][0-7]+)|(0[0-7]*)[lL]?'
-Binnumber = r'0[bB][01]+[lL]?'
-Decnumber = r'[1-9]\d*[lL]?'
+Hexnumber = r'0[xX][0-9a-fA-F]+'
+Binnumber = r'0[bB][01]+'
+Octnumber = r'0[oO][0-7]+'
+Decnumber = r'(?:0+|[1-9][0-9]*)'
Intnumber = group(Hexnumber, Binnumber, Octnumber, Decnumber)
-Exponent = r'[eE][-+]?\d+'
-Pointfloat = group(r'\d+\.\d*', r'\.\d+') + maybe(Exponent)
-Expfloat = r'\d+' + Exponent
+Exponent = r'[eE][-+]?[0-9]+'
+Pointfloat = group(r'[0-9]+\.[0-9]*', r'\.[0-9]+') + maybe(Exponent)
+Expfloat = r'[0-9]+' + Exponent
Floatnumber = group(Pointfloat, Expfloat)
-Imagnumber = group(r'\d+[jJ]', Floatnumber + r'[jJ]')
+Imagnumber = group(r'[0-9]+[jJ]', Floatnumber + r'[jJ]')
Number = group(Imagnumber, Floatnumber, Intnumber)
# Tail end of ' string.
@@ -70,61 +83,54 @@ Double = r'[^"\\]*(?:\\.[^"\\]*)*"'
Single3 = r"[^'\\]*(?:(?:\\.|'(?!''))[^'\\]*)*'''"
# Tail end of """ string.
Double3 = r'[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""'
-Triple = group("[uUbB]?[rR]?'''", '[uUbB]?[rR]?"""')
+Triple = group("[bB]?[rR]?'''", '[bB]?[rR]?"""')
# Single-line ' or " string.
-String = group(r"[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'",
- r'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"')
+String = group(r"[bB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'",
+ r'[bB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*"')
# Because of leftmost-then-longest match semantics, be sure to put the
# longest operators first (e.g., if = came before ==, == would get
# recognized as two instances of =).
-Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=",
- r"//=?",
+Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=",
+ r"//=?", r"->",
r"[+\-*/%&|^=<>]=?",
r"~")
Bracket = '[][(){}]'
-Special = group(r'\r?\n', r'[:;.,`@]')
+Special = group(r'\r?\n', r'\.\.\.', r'[:;.,@]')
Funny = group(Operator, Bracket, Special)
PlainToken = group(Number, Funny, String, Name)
Token = Ignore + PlainToken
# First (or only) line of ' or " string.
-ContStr = group(r"[uUbB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" +
+ContStr = group(r"[bB]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*" +
group("'", r'\\\r?\n'),
- r'[uUbB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' +
+ r'[bB]?[rR]?"[^\n"\\]*(?:\\.[^\n"\\]*)*' +
group('"', r'\\\r?\n'))
PseudoExtras = group(r'\\\r?\n|\Z', Comment, Triple)
PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name)
+def _compile(expr):
+ return re.compile(expr, re.UNICODE)
+
tokenprog, pseudoprog, single3prog, double3prog = map(
- re.compile, (Token, PseudoToken, Single3, Double3))
-endprogs = {"'": re.compile(Single), '"': re.compile(Double),
+ _compile, (Token, PseudoToken, Single3, Double3))
+endprogs = {"'": _compile(Single), '"': _compile(Double),
"'''": single3prog, '"""': double3prog,
"r'''": single3prog, 'r"""': double3prog,
- "u'''": single3prog, 'u"""': double3prog,
- "ur'''": single3prog, 'ur"""': double3prog,
- "R'''": single3prog, 'R"""': double3prog,
- "U'''": single3prog, 'U"""': double3prog,
- "uR'''": single3prog, 'uR"""': double3prog,
- "Ur'''": single3prog, 'Ur"""': double3prog,
- "UR'''": single3prog, 'UR"""': double3prog,
"b'''": single3prog, 'b"""': double3prog,
"br'''": single3prog, 'br"""': double3prog,
+ "R'''": single3prog, 'R"""': double3prog,
"B'''": single3prog, 'B"""': double3prog,
"bR'''": single3prog, 'bR"""': double3prog,
"Br'''": single3prog, 'Br"""': double3prog,
"BR'''": single3prog, 'BR"""': double3prog,
- 'r': None, 'R': None, 'u': None, 'U': None,
- 'b': None, 'B': None}
+ 'r': None, 'R': None, 'b': None, 'B': None}
triple_quoted = {}
for t in ("'''", '"""',
"r'''", 'r"""', "R'''", 'R"""',
- "u'''", 'u"""', "U'''", 'U"""',
- "ur'''", 'ur"""', "Ur'''", 'Ur"""',
- "uR'''", 'uR"""', "UR'''", 'UR"""',
"b'''", 'b"""', "B'''", 'B"""',
"br'''", 'br"""', "Br'''", 'Br"""',
"bR'''", 'bR"""', "BR'''", 'BR"""'):
@@ -132,48 +138,19 @@ for t in ("'''", '"""',
single_quoted = {}
for t in ("'", '"',
"r'", 'r"', "R'", 'R"',
- "u'", 'u"', "U'", 'U"',
- "ur'", 'ur"', "Ur'", 'Ur"',
- "uR'", 'uR"', "UR'", 'UR"',
"b'", 'b"', "B'", 'B"',
"br'", 'br"', "Br'", 'Br"',
"bR'", 'bR"', "BR'", 'BR"' ):
single_quoted[t] = t
+del _compile
+
tabsize = 8
class TokenError(Exception): pass
class StopTokenizing(Exception): pass
-def printtoken(type, token, srow_scol, erow_ecol, line): # for testing
- srow, scol = srow_scol
- erow, ecol = erow_ecol
- print "%d,%d-%d,%d:\t%s\t%s" % \
- (srow, scol, erow, ecol, tok_name[type], repr(token))
-
-def tokenize(readline, tokeneater=printtoken):
- """
- The tokenize() function accepts two parameters: one representing the
- input stream, and one providing an output mechanism for tokenize().
-
- The first parameter, readline, must be a callable object which provides
- the same interface as the readline() method of built-in file objects.
- Each call to the function should return one line of input as a string.
-
- The second parameter, tokeneater, must also be a callable object. It is
- called once for each token, with five arguments, corresponding to the
- tuples generated by generate_tokens().
- """
- try:
- tokenize_loop(readline, tokeneater)
- except StopTokenizing:
- pass
-
-# backwards compatible interface
-def tokenize_loop(readline, tokeneater):
- for token_info in generate_tokens(readline):
- tokeneater(*token_info)
class Untokenizer:
@@ -181,6 +158,7 @@ class Untokenizer:
self.tokens = []
self.prev_row = 1
self.prev_col = 0
+ self.encoding = None
def add_whitespace(self, start):
row, col = start
@@ -195,6 +173,9 @@ class Untokenizer:
self.compat(t, iterable)
break
tok_type, token, start, end, line = t
+ if tok_type == ENCODING:
+ self.encoding = token
+ continue
self.add_whitespace(start)
self.tokens.append(token)
self.prev_row, self.prev_col = end
@@ -208,6 +189,7 @@ class Untokenizer:
indents = []
toks_append = self.tokens.append
toknum, tokval = token
+
if toknum in (NAME, NUMBER):
tokval += ' '
if toknum in (NEWLINE, NL):
@@ -215,6 +197,9 @@ class Untokenizer:
prevstring = False
for tok in iterable:
toknum, tokval = tok[:2]
+ if toknum == ENCODING:
+ self.encoding = tokval
+ continue
if toknum in (NAME, NUMBER):
tokval += ' '
@@ -240,8 +225,11 @@ class Untokenizer:
startline = False
toks_append(tokval)
+
def untokenize(iterable):
"""Transform tokens back into Python source code.
+ It returns a bytes object, encoded using the ENCODING
+ token, which is the first token sequence output by tokenize.
Each element returned by the iterable must be a token sequence
with at least two elements, a token number and token value. If
@@ -251,58 +239,181 @@ def untokenize(iterable):
Untokenized source will match input source exactly
Round-trip invariant for limited intput:
- # Output text will tokenize the back to the input
- t1 = [tok[:2] for tok in generate_tokens(f.readline)]
+ # Output bytes will tokenize the back to the input
+ t1 = [tok[:2] for tok in tokenize(f.readline)]
newcode = untokenize(t1)
- readline = iter(newcode.splitlines(1)).next
- t2 = [tok[:2] for tok in generate_tokens(readline)]
+ readline = BytesIO(newcode).readline
+ t2 = [tok[:2] for tok in tokenize(readline)]
assert t1 == t2
"""
ut = Untokenizer()
- return ut.untokenize(iterable)
+ out = ut.untokenize(iterable)
+ if ut.encoding is not None:
+ out = out.encode(ut.encoding)
+ return out
+
+
+def _get_normal_name(orig_enc):
+ """Imitates get_normal_name in tokenizer.c."""
+ # Only care about the first 12 characters.
+ enc = orig_enc[:12].lower().replace("_", "-")
+ if enc == "utf-8" or enc.startswith("utf-8-"):
+ return "utf-8"
+ if enc in ("latin-1", "iso-8859-1", "iso-latin-1") or \
+ enc.startswith(("latin-1-", "iso-8859-1-", "iso-latin-1-")):
+ return "iso-8859-1"
+ return orig_enc
+
+def detect_encoding(readline):
+ """
+ The detect_encoding() function is used to detect the encoding that should
+ be used to decode a Python source file. It requires one argment, readline,
+ in the same way as the tokenize() generator.
-def generate_tokens(readline):
+ It will call readline a maximum of twice, and return the encoding used
+ (as a string) and a list of any lines (left as bytes) it has read in.
+
+ It detects the encoding from the presence of a utf-8 bom or an encoding
+ cookie as specified in pep-0263. If both a bom and a cookie are present,
+ but disagree, a SyntaxError will be raised. If the encoding cookie is an
+ invalid charset, raise a SyntaxError. Note that if a utf-8 bom is found,
+ 'utf-8-sig' is returned.
+
+ If no encoding is specified, then the default of 'utf-8' will be returned.
+ """
+ bom_found = False
+ encoding = None
+ default = 'utf-8'
+ def read_or_stop():
+ try:
+ return readline()
+ except StopIteration:
+ return b''
+
+ def find_cookie(line):
+ try:
+ # Decode as UTF-8. Either the line is an encoding declaration,
+ # in which case it should be pure ASCII, or it must be UTF-8
+ # per default encoding.
+ line_string = line.decode('utf-8')
+ except UnicodeDecodeError:
+ raise SyntaxError("invalid or missing encoding declaration")
+
+ matches = cookie_re.findall(line_string)
+ if not matches:
+ return None
+ encoding = _get_normal_name(matches[0])
+ try:
+ codec = lookup(encoding)
+ except LookupError:
+ # This behaviour mimics the Python interpreter
+ raise SyntaxError("unknown encoding: " + encoding)
+
+ if bom_found:
+ if encoding != 'utf-8':
+ # This behaviour mimics the Python interpreter
+ raise SyntaxError('encoding problem: utf-8')
+ encoding += '-sig'
+ return encoding
+
+ first = read_or_stop()
+ if first.startswith(BOM_UTF8):
+ bom_found = True
+ first = first[3:]
+ default = 'utf-8-sig'
+ if not first:
+ return default, []
+
+ encoding = find_cookie(first)
+ if encoding:
+ return encoding, [first]
+
+ second = read_or_stop()
+ if not second:
+ return default, [first]
+
+ encoding = find_cookie(second)
+ if encoding:
+ return encoding, [first, second]
+
+ return default, [first, second]
+
+
+def open(filename):
+ """Open a file in read only mode using the encoding detected by
+ detect_encoding().
+ """
+ buffer = builtins.open(filename, 'rb')
+ encoding, lines = detect_encoding(buffer.readline)
+ buffer.seek(0)
+ text = TextIOWrapper(buffer, encoding, line_buffering=True)
+ text.mode = 'r'
+ return text
+
+
+def tokenize(readline):
"""
- The generate_tokens() generator requires one argment, readline, which
+ The tokenize() generator requires one argment, readline, which
must be a callable object which provides the same interface as the
- readline() method of built-in file objects. Each call to the function
- should return one line of input as a string. Alternately, readline
+ readline() method of built-in file objects. Each call to the function
+ should return one line of input as bytes. Alternately, readline
can be a callable function terminating with StopIteration:
- readline = open(myfile).next # Example of alternate readline
+ readline = open(myfile, 'rb').__next__ # Example of alternate readline
The generator produces 5-tuples with these members: the token type; the
token string; a 2-tuple (srow, scol) of ints specifying the row and
column where the token begins in the source; a 2-tuple (erow, ecol) of
ints specifying the row and column where the token ends in the source;
- and the line on which the token was found. The line passed is the
+ and the line on which the token was found. The line passed is the
logical line; continuation lines are included.
+
+ The first token sequence will always be an ENCODING token
+ which tells you which encoding was used to decode the bytes stream.
"""
+ # This import is here to avoid problems when the itertools module is not
+ # built yet and tokenize is imported.
+ from itertools import chain, repeat
+ encoding, consumed = detect_encoding(readline)
+ rl_gen = iter(readline, b"")
+ empty = repeat(b"")
+ return _tokenize(chain(consumed, rl_gen, empty).__next__, encoding)
+
+
+def _tokenize(readline, encoding):
lnum = parenlev = continued = 0
- namechars, numchars = string.ascii_letters + '_', '0123456789'
+ numchars = '0123456789'
contstr, needcont = '', 0
contline = None
indents = [0]
- while 1: # loop over lines in stream
+ if encoding is not None:
+ if encoding == "utf-8-sig":
+ # BOM will already have been stripped.
+ encoding = "utf-8"
+ yield TokenInfo(ENCODING, encoding, (0, 0), (0, 0), '')
+ while True: # loop over lines in stream
try:
line = readline()
except StopIteration:
- line = ''
+ line = b''
+
+ if encoding is not None:
+ line = line.decode(encoding)
lnum += 1
pos, max = 0, len(line)
if contstr: # continued string
if not line:
- raise TokenError, ("EOF in multi-line string", strstart)
+ raise TokenError("EOF in multi-line string", strstart)
endmatch = endprog.match(line)
if endmatch:
pos = end = endmatch.end(0)
- yield (STRING, contstr + line[:end],
+ yield TokenInfo(STRING, contstr + line[:end],
strstart, (lnum, end), contline + line)
contstr, needcont = '', 0
contline = None
elif needcont and line[-2:] != '\\\n' and line[-3:] != '\\\r\n':
- yield (ERRORTOKEN, contstr + line,
+ yield TokenInfo(ERRORTOKEN, contstr + line,
strstart, (lnum, len(line)), contline)
contstr = ''
contline = None
@@ -332,29 +443,29 @@ def generate_tokens(readline):
if line[pos] == '#':
comment_token = line[pos:].rstrip('\r\n')
nl_pos = pos + len(comment_token)
- yield (COMMENT, comment_token,
+ yield TokenInfo(COMMENT, comment_token,
(lnum, pos), (lnum, pos + len(comment_token)), line)
- yield (NL, line[nl_pos:],
+ yield TokenInfo(NL, line[nl_pos:],
(lnum, nl_pos), (lnum, len(line)), line)
else:
- yield ((NL, COMMENT)[line[pos] == '#'], line[pos:],
+ yield TokenInfo((NL, COMMENT)[line[pos] == '#'], line[pos:],
(lnum, pos), (lnum, len(line)), line)
continue
if column > indents[-1]: # count indents or dedents
indents.append(column)
- yield (INDENT, line[:pos], (lnum, 0), (lnum, pos), line)
+ yield TokenInfo(INDENT, line[:pos], (lnum, 0), (lnum, pos), line)
while column < indents[-1]:
if column not in indents:
raise IndentationError(
"unindent does not match any outer indentation level",
("<tokenize>", lnum, pos, line))
indents = indents[:-1]
- yield (DEDENT, '', (lnum, pos), (lnum, pos), line)
+ yield TokenInfo(DEDENT, '', (lnum, pos), (lnum, pos), line)
else: # continued statement
if not line:
- raise TokenError, ("EOF in multi-line statement", (lnum, 0))
+ raise TokenError("EOF in multi-line statement", (lnum, 0))
continued = 0
while pos < max:
@@ -366,22 +477,22 @@ def generate_tokens(readline):
continue
token, initial = line[start:end], line[start]
- if initial in numchars or \
- (initial == '.' and token != '.'): # ordinary number
- yield (NUMBER, token, spos, epos, line)
+ if (initial in numchars or # ordinary number
+ (initial == '.' and token != '.' and token != '...')):
+ yield TokenInfo(NUMBER, token, spos, epos, line)
elif initial in '\r\n':
- yield (NL if parenlev > 0 else NEWLINE,
+ yield TokenInfo(NL if parenlev > 0 else NEWLINE,
token, spos, epos, line)
elif initial == '#':
assert not token.endswith("\n")
- yield (COMMENT, token, spos, epos, line)
+ yield TokenInfo(COMMENT, token, spos, epos, line)
elif token in triple_quoted:
endprog = endprogs[token]
endmatch = endprog.match(line, pos)
if endmatch: # all on one line
pos = endmatch.end(0)
token = line[start:pos]
- yield (STRING, token, spos, (lnum, pos), line)
+ yield TokenInfo(STRING, token, spos, (lnum, pos), line)
else:
strstart = (lnum, start) # multiple lines
contstr = line[start:]
@@ -398,9 +509,9 @@ def generate_tokens(readline):
contline = line
break
else: # ordinary string
- yield (STRING, token, spos, epos, line)
- elif initial in namechars: # ordinary name
- yield (NAME, token, spos, epos, line)
+ yield TokenInfo(STRING, token, spos, epos, line)
+ elif initial.isidentifier(): # ordinary name
+ yield TokenInfo(NAME, token, spos, epos, line)
elif initial == '\\': # continued stmt
continued = 1
else:
@@ -408,19 +519,43 @@ def generate_tokens(readline):
parenlev += 1
elif initial in ')]}':
parenlev -= 1
- yield (OP, token, spos, epos, line)
+ yield TokenInfo(OP, token, spos, epos, line)
else:
- yield (ERRORTOKEN, line[pos],
+ yield TokenInfo(ERRORTOKEN, line[pos],
(lnum, pos), (lnum, pos+1), line)
pos += 1
for indent in indents[1:]: # pop remaining indent levels
- yield (DEDENT, '', (lnum, 0), (lnum, 0), '')
- yield (ENDMARKER, '', (lnum, 0), (lnum, 0), '')
-
-if __name__ == '__main__': # testing
- import sys
- if len(sys.argv) > 1:
- tokenize(open(sys.argv[1]).readline)
- else:
- tokenize(sys.stdin.readline)
+ yield TokenInfo(DEDENT, '', (lnum, 0), (lnum, 0), '')
+ yield TokenInfo(ENDMARKER, '', (lnum, 0), (lnum, 0), '')
+
+
+# An undocumented, backwards compatible, API for all the places in the standard
+# library that expect to be able to use tokenize with strings
+def generate_tokens(readline):
+ return _tokenize(readline, None)
+
+if __name__ == "__main__":
+ # Quick sanity check
+ s = b'''def parseline(self, line):
+ """Parse the line into a command name and a string containing
+ the arguments. Returns a tuple containing (command, args, line).
+ 'command' and 'args' may be None if the line couldn't be parsed.
+ """
+ line = line.strip()
+ if not line:
+ return None, None, line
+ elif line[0] == '?':
+ line = 'help ' + line[1:]
+ elif line[0] == '!':
+ if hasattr(self, 'do_shell'):
+ line = 'shell ' + line[1:]
+ else:
+ return None, None, line
+ i, n = 0, len(line)
+ while i < n and line[i] in self.identchars: i = i+1
+ cmd, arg = line[:i], line[i:].strip()
+ return cmd, arg, line
+ '''
+ for tok in tokenize(iter(s.splitlines()).__next__):
+ print(tok)
diff --git a/Lib/trace.py b/Lib/trace.py
index 38a13e2a9f0..850369b9ff4 100644
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# portions copyright 2001, Autonomous Zones Industries, Inc., all rights...
# err... reserved and offered to the public under the terms of the
@@ -47,7 +47,8 @@ Sample use, programmatically
r = tracer.results()
r.write_results(show_missing=True, coverdir="/tmp")
"""
-
+__all__ = ['Trace', 'CoverageResults']
+import io
import linecache
import os
import re
@@ -58,11 +59,8 @@ import tokenize
import inspect
import gc
import dis
-try:
- import cPickle
- pickle = cPickle
-except ImportError:
- import pickle
+import pickle
+from warnings import warn as _warn
try:
import threading
@@ -80,7 +78,7 @@ else:
sys.settrace(None)
threading.settrace(None)
-def usage(outfile):
+def _usage(outfile):
outfile.write("""Usage: %s [OPTIONS] <file> [ARGS]
Meta-options:
@@ -130,12 +128,11 @@ PRAGMA_NOCOVER = "#pragma NO COVER"
# Simple rx to find lines with no code.
rx_blank = re.compile(r'^\s*(#.*)?$')
-class Ignore:
- def __init__(self, modules = None, dirs = None):
- self._mods = modules or []
- self._dirs = dirs or []
-
- self._dirs = map(os.path.normpath, self._dirs)
+class _Ignore:
+ def __init__(self, modules=None, dirs=None):
+ self._mods = set() if not modules else set(modules)
+ self._dirs = [] if not dirs else [os.path.normpath(d)
+ for d in dirs]
self._ignore = { '<string>': 1 }
def names(self, filename, modulename):
@@ -143,24 +140,22 @@ class Ignore:
return self._ignore[modulename]
# haven't seen this one before, so see if the module name is
- # on the ignore list. Need to take some care since ignoring
- # "cmp" musn't mean ignoring "cmpcache" but ignoring
- # "Spam" must also mean ignoring "Spam.Eggs".
+ # on the ignore list.
+ if modulename in self._mods: # Identical names, so ignore
+ self._ignore[modulename] = 1
+ return 1
+
+ # check if the module is a proper submodule of something on
+ # the ignore list
for mod in self._mods:
- if mod == modulename: # Identical names, so ignore
- self._ignore[modulename] = 1
- return 1
- # check if the module is a proper submodule of something on
- # the ignore list
- n = len(mod)
- # (will not overflow since if the first n characters are the
- # same and the name has not already occurred, then the size
- # of "name" is greater than that of "mod")
- if mod == modulename[:n] and modulename[n] == '.':
+ # Need to take some care since ignoring
+ # "cmp" mustn't mean ignoring "cmpcache" but ignoring
+ # "Spam" must also mean ignoring "Spam.Eggs".
+ if modulename.startswith(mod + '.'):
self._ignore[modulename] = 1
return 1
- # Now check that __file__ isn't in one of the directories
+ # Now check that filename isn't in one of the directories
if filename is None:
# must be a built-in, so we must ignore
self._ignore[modulename] = 1
@@ -183,14 +178,14 @@ class Ignore:
self._ignore[modulename] = 0
return 0
-def modname(path):
+def _modname(path):
"""Return a plausible module name for the patch."""
base = os.path.basename(path)
filename, ext = os.path.splitext(base)
return filename
-def fullmodname(path):
+def _fullmodname(path):
"""Return a plausible module name for the path."""
# If the file 'path' is part of a package, then the filename isn't
@@ -241,9 +236,16 @@ class CoverageResults:
counts, calledfuncs, callers = \
pickle.load(open(self.infile, 'rb'))
self.update(self.__class__(counts, calledfuncs, callers))
- except (IOError, EOFError, ValueError), err:
- print >> sys.stderr, ("Skipping counts file %r: %s"
- % (self.infile, err))
+ except (IOError, EOFError, ValueError) as err:
+ print(("Skipping counts file %r: %s"
+ % (self.infile, err)), file=sys.stderr)
+
+ def is_ignored_filename(self, filename):
+ """Return True if the filename does not refer to a file
+ we want to have reported.
+ """
+ return (filename == "<string>" or
+ filename.startswith("<doctest "))
def update(self, other):
"""Merge in the data from another CoverageResults"""
@@ -254,13 +256,13 @@ class CoverageResults:
other_calledfuncs = other.calledfuncs
other_callers = other.callers
- for key in other_counts.keys():
+ for key in other_counts:
counts[key] = counts.get(key, 0) + other_counts[key]
- for key in other_calledfuncs.keys():
+ for key in other_calledfuncs:
calledfuncs[key] = 1
- for key in other_callers.keys():
+ for key in other_callers:
callers[key] = 1
def write_results(self, show_missing=True, summary=False, coverdir=None):
@@ -268,46 +270,41 @@ class CoverageResults:
@param coverdir
"""
if self.calledfuncs:
- print
- print "functions called:"
- calls = self.calledfuncs.keys()
- calls.sort()
- for filename, modulename, funcname in calls:
- print ("filename: %s, modulename: %s, funcname: %s"
- % (filename, modulename, funcname))
+ print()
+ print("functions called:")
+ calls = self.calledfuncs
+ for filename, modulename, funcname in sorted(calls):
+ print(("filename: %s, modulename: %s, funcname: %s"
+ % (filename, modulename, funcname)))
if self.callers:
- print
- print "calling relationships:"
- calls = self.callers.keys()
- calls.sort()
+ print()
+ print("calling relationships:")
lastfile = lastcfile = ""
- for ((pfile, pmod, pfunc), (cfile, cmod, cfunc)) in calls:
+ for ((pfile, pmod, pfunc), (cfile, cmod, cfunc)) \
+ in sorted(self.callers):
if pfile != lastfile:
- print
- print "***", pfile, "***"
+ print()
+ print("***", pfile, "***")
lastfile = pfile
lastcfile = ""
if cfile != pfile and lastcfile != cfile:
- print " -->", cfile
+ print(" -->", cfile)
lastcfile = cfile
- print " %s.%s -> %s.%s" % (pmod, pfunc, cmod, cfunc)
+ print(" %s.%s -> %s.%s" % (pmod, pfunc, cmod, cfunc))
# turn the counts data ("(filename, lineno) = count") into something
# accessible on a per-file basis
per_file = {}
- for filename, lineno in self.counts.keys():
+ for filename, lineno in self.counts:
lines_hit = per_file[filename] = per_file.get(filename, {})
lines_hit[lineno] = self.counts[(filename, lineno)]
# accumulate summary info, if needed
sums = {}
- for filename, count in per_file.iteritems():
- # skip some "files" we don't care about...
- if filename == "<string>":
- continue
- if filename.startswith("<doctest "):
+ for filename, count in per_file.items():
+ if self.is_ignored_filename(filename):
continue
if filename.endswith((".pyc", ".pyo")):
@@ -315,59 +312,57 @@ class CoverageResults:
if coverdir is None:
dir = os.path.dirname(os.path.abspath(filename))
- modulename = modname(filename)
+ modulename = _modname(filename)
else:
dir = coverdir
if not os.path.exists(dir):
os.makedirs(dir)
- modulename = fullmodname(filename)
+ modulename = _fullmodname(filename)
# If desired, get a list of the line numbers which represent
# executable content (returned as a dict for better lookup speed)
if show_missing:
- lnotab = find_executable_linenos(filename)
+ lnotab = _find_executable_linenos(filename)
else:
lnotab = {}
source = linecache.getlines(filename)
coverpath = os.path.join(dir, modulename + ".cover")
+ with open(filename, 'rb') as fp:
+ encoding, _ = tokenize.detect_encoding(fp.readline)
n_hits, n_lines = self.write_results_file(coverpath, source,
- lnotab, count)
-
+ lnotab, count, encoding)
if summary and n_lines:
- percent = 100 * n_hits // n_lines
+ percent = int(100 * n_hits / n_lines)
sums[modulename] = n_lines, percent, modulename, filename
if summary and sums:
- mods = sums.keys()
- mods.sort()
- print "lines cov% module (path)"
- for m in mods:
+ print("lines cov% module (path)")
+ for m in sorted(sums):
n_lines, percent, modulename, filename = sums[m]
- print "%5d %3d%% %s (%s)" % sums[m]
+ print("%5d %3d%% %s (%s)" % sums[m])
if self.outfile:
# try and store counts and module info into self.outfile
try:
pickle.dump((self.counts, self.calledfuncs, self.callers),
open(self.outfile, 'wb'), 1)
- except IOError, err:
- print >> sys.stderr, "Can't save counts files because %s" % err
+ except IOError as err:
+ print("Can't save counts files because %s" % err, file=sys.stderr)
- def write_results_file(self, path, lines, lnotab, lines_hit):
+ def write_results_file(self, path, lines, lnotab, lines_hit, encoding=None):
"""Return a coverage results file in path."""
try:
- outfile = open(path, "w")
- except IOError, err:
- print >> sys.stderr, ("trace: Could not open %r for writing: %s"
- "- skipping" % (path, err))
+ outfile = open(path, "w", encoding=encoding)
+ except IOError as err:
+ print(("trace: Could not open %r for writing: %s"
+ "- skipping" % (path, err)), file=sys.stderr)
return 0, 0
n_lines = 0
n_hits = 0
- for i, line in enumerate(lines):
- lineno = i + 1
+ for lineno, line in enumerate(lines, 1):
# do the blank/comment match to try to mark more lines
# (help the reader find stuff that hasn't been covered)
if lineno in lines_hit:
@@ -380,17 +375,17 @@ class CoverageResults:
# lines preceded by no marks weren't hit
# Highlight them if so indicated, unless the line contains
# #pragma: NO COVER
- if lineno in lnotab and not PRAGMA_NOCOVER in lines[i]:
+ if lineno in lnotab and not PRAGMA_NOCOVER in line:
outfile.write(">>>>>> ")
n_lines += 1
else:
outfile.write(" ")
- outfile.write(lines[i].expandtabs(8))
+ outfile.write(line.expandtabs(8))
outfile.close()
return n_hits, n_lines
-def find_lines_from_code(code, strs):
+def _find_lines_from_code(code, strs):
"""Return dict where keys are lines in the line number table."""
linenos = {}
@@ -400,19 +395,19 @@ def find_lines_from_code(code, strs):
return linenos
-def find_lines(code, strs):
+def _find_lines(code, strs):
"""Return lineno dict for all code objects reachable from code."""
# get all of the lineno information from the code of this scope level
- linenos = find_lines_from_code(code, strs)
+ linenos = _find_lines_from_code(code, strs)
# and check the constants for references to other code objects
for c in code.co_consts:
if inspect.iscode(c):
# find another code object, so recurse into it
- linenos.update(find_lines(c, strs))
+ linenos.update(_find_lines(c, strs))
return linenos
-def find_strings(filename):
+def _find_strings(filename, encoding=None):
"""Return a dict of possible docstring positions.
The dict maps line numbers to strings. There is an entry for
@@ -423,29 +418,31 @@ def find_strings(filename):
# 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
- f = open(filename)
- for ttype, tstr, start, end, line in tokenize.generate_tokens(f.readline):
- if ttype == token.STRING:
- if prev_ttype == token.INDENT:
- sline, scol = start
- eline, ecol = end
- for i in range(sline, eline + 1):
- d[i] = 1
- prev_ttype = ttype
- f.close()
+ with open(filename, encoding=encoding) as f:
+ tok = tokenize.generate_tokens(f.readline)
+ for ttype, tstr, start, end, line in tok:
+ if ttype == token.STRING:
+ if prev_ttype == token.INDENT:
+ sline, scol = start
+ eline, ecol = end
+ for i in range(sline, eline + 1):
+ d[i] = 1
+ prev_ttype = ttype
return d
-def find_executable_linenos(filename):
+def _find_executable_linenos(filename):
"""Return dict where keys are line numbers in the line number table."""
try:
- prog = open(filename, "rU").read()
- except IOError, err:
- print >> sys.stderr, ("Not printing coverage data for %r: %s"
- % (filename, err))
+ with tokenize.open(filename) as f:
+ prog = f.read()
+ encoding = f.encoding
+ except IOError as err:
+ print(("Not printing coverage data for %r: %s"
+ % (filename, err)), file=sys.stderr)
return {}
code = compile(prog, filename, "exec")
- strs = find_strings(filename)
- return find_lines(code, strs)
+ strs = _find_strings(filename, encoding)
+ return _find_lines(code, strs)
class Trace:
def __init__(self, count=1, trace=1, countfuncs=0, countcallers=0,
@@ -470,9 +467,8 @@ class Trace:
"""
self.infile = infile
self.outfile = outfile
- self.ignore = Ignore(ignoremods, ignoredirs)
+ self.ignore = _Ignore(ignoremods, ignoredirs)
self.counts = {} # keys are (filename, linenumber)
- self.blabbed = {} # for debugging
self.pathtobasename = {} # for memoizing os.path.basename
self.donothing = 0
self.trace = trace
@@ -510,7 +506,7 @@ class Trace:
if not self.donothing:
_settrace(self.globaltrace)
try:
- exec cmd in globals, locals
+ exec(cmd, globals, locals)
finally:
if not self.donothing:
_unsettrace()
@@ -530,7 +526,7 @@ class Trace:
code = frame.f_code
filename = code.co_filename
if filename:
- modulename = modname(filename)
+ modulename = _modname(filename)
else:
modulename = None
@@ -597,15 +593,15 @@ class Trace:
code = frame.f_code
filename = frame.f_globals.get('__file__', None)
if filename:
- # XXX modname() doesn't work right for packages, so
+ # XXX _modname() doesn't work right for packages, so
# the ignore support won't work right for packages
- modulename = modname(filename)
+ modulename = _modname(filename)
if modulename is not None:
ignore_it = self.ignore.names(filename, modulename)
if not ignore_it:
if self.trace:
- print (" --- modulename: %s, funcname: %s"
- % (modulename, code.co_name))
+ print((" --- modulename: %s, funcname: %s"
+ % (modulename, code.co_name)))
return self.localtrace
else:
return None
@@ -619,10 +615,10 @@ class Trace:
self.counts[key] = self.counts.get(key, 0) + 1
if self.start_time:
- print '%.2f' % (time.time() - self.start_time),
+ print('%.2f' % (time.time() - self.start_time), end=' ')
bname = os.path.basename(filename)
- print "%s(%d): %s" % (bname, lineno,
- linecache.getline(filename, lineno)),
+ print("%s(%d): %s" % (bname, lineno,
+ linecache.getline(filename, lineno)), end='')
return self.localtrace
def localtrace_trace(self, frame, why, arg):
@@ -632,10 +628,10 @@ class Trace:
lineno = frame.f_lineno
if self.start_time:
- print '%.2f' % (time.time() - self.start_time),
+ print('%.2f' % (time.time() - self.start_time), end=' ')
bname = os.path.basename(filename)
- print "%s(%d): %s" % (bname, lineno,
- linecache.getline(filename, lineno)),
+ print("%s(%d): %s" % (bname, lineno,
+ linecache.getline(filename, lineno)), end='')
return self.localtrace
def localtrace_count(self, frame, why, arg):
@@ -670,7 +666,7 @@ def main(argv=None):
"coverdir=", "listfuncs",
"trackcalls", "timing"])
- except getopt.error, msg:
+ except getopt.error as msg:
sys.stderr.write("%s: %s\n" % (sys.argv[0], msg))
sys.stderr.write("Try `%s --help' for more information\n"
% sys.argv[0])
@@ -692,7 +688,7 @@ def main(argv=None):
for opt, val in opts:
if opt == "--help":
- usage(sys.stdout)
+ _usage(sys.stdout)
sys.exit(0)
if opt == "--version":
@@ -805,7 +801,7 @@ def main(argv=None):
'__cached__': None,
}
t.runctx(code, globs, globs)
- except IOError, err:
+ except IOError as err:
_err_exit("Cannot run file %r because: %s" % (sys.argv[0], err))
except SystemExit:
pass
@@ -815,5 +811,47 @@ def main(argv=None):
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/Lib/traceback.py b/Lib/traceback.py
index da17d3a1f80..8d4e96edcb6 100644
--- a/Lib/traceback.py
+++ b/Lib/traceback.py
@@ -2,12 +2,11 @@
import linecache
import sys
-import types
__all__ = ['extract_stack', 'extract_tb', 'format_exception',
'format_exception_only', 'format_list', 'format_stack',
'format_tb', 'print_exc', 'format_exc', 'print_exception',
- 'print_last', 'print_stack', 'print_tb', 'tb_lineno']
+ 'print_last', 'print_stack', 'print_tb']
def _print(file, str='', terminator='\n'):
file.write(str+terminator)
@@ -71,11 +70,11 @@ def print_tb(tb, limit=None, file=None):
tb = tb.tb_next
n = n+1
-def format_tb(tb, limit = None):
+def format_tb(tb, limit=None):
"""A shorthand for 'format_list(extract_stack(f, limit))."""
return format_list(extract_tb(tb, limit))
-def extract_tb(tb, limit = None):
+def extract_tb(tb, limit=None):
"""Return list of up to limit pre-processed entries from traceback.
This is useful for alternate formatting of stack traces. If
@@ -107,7 +106,36 @@ def extract_tb(tb, limit = None):
return list
-def print_exception(etype, value, tb, limit=None, file=None):
+_cause_message = (
+ "\nThe above exception was the direct cause "
+ "of the following exception:\n")
+
+_context_message = (
+ "\nDuring handling of the above exception, "
+ "another exception occurred:\n")
+
+def _iter_chain(exc, custom_tb=None, seen=None):
+ if seen is None:
+ seen = set()
+ seen.add(exc)
+ its = []
+ cause = exc.__cause__
+ if cause is not None and cause not in seen:
+ its.append(_iter_chain(cause, None, seen))
+ its.append([(_cause_message, None)])
+ else:
+ context = exc.__context__
+ if context is not None and context not in seen:
+ its.append(_iter_chain(context, None, seen))
+ its.append([(_context_message, None)])
+ its.append([(exc, custom_tb or exc.__traceback__)])
+ # itertools.chain is in an extension module and may be unavailable
+ for it in its:
+ for x in it:
+ yield x
+
+
+def print_exception(etype, value, tb, limit=None, file=None, chain=True):
"""Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
@@ -120,14 +148,22 @@ def print_exception(etype, value, tb, limit=None, file=None):
"""
if file is None:
file = sys.stderr
- if tb:
- _print(file, 'Traceback (most recent call last):')
- print_tb(tb, limit, file)
- lines = format_exception_only(etype, value)
- for line in lines:
- _print(file, line, '')
-
-def format_exception(etype, value, tb, limit = None):
+ if chain:
+ values = _iter_chain(value, tb)
+ else:
+ values = [(value, tb)]
+ for value, tb in values:
+ if isinstance(value, str):
+ _print(file, value)
+ continue
+ if tb:
+ _print(file, 'Traceback (most recent call last):')
+ print_tb(tb, limit, file)
+ lines = format_exception_only(type(value), value)
+ for line in lines:
+ _print(file, line, '')
+
+def format_exception(etype, value, tb, limit=None, chain=True):
"""Format a stack trace and the exception information.
The arguments have the same meaning as the corresponding arguments
@@ -136,12 +172,19 @@ def format_exception(etype, value, tb, limit = None):
these lines are concatenated and printed, exactly the same text is
printed as does print_exception().
"""
- if tb:
- list = ['Traceback (most recent call last):\n']
- list = list + format_tb(tb, limit)
+ list = []
+ if chain:
+ values = _iter_chain(value, tb)
else:
- list = []
- list = list + format_exception_only(etype, value)
+ values = [(value, tb)]
+ for value, tb in values:
+ if isinstance(value, str):
+ list.append(value + '\n')
+ continue
+ if tb:
+ list.append('Traceback (most recent call last):\n')
+ list.extend(format_tb(tb, limit))
+ list.extend(format_exception_only(type(value), value))
return list
def format_exception_only(etype, value):
@@ -160,47 +203,39 @@ def format_exception_only(etype, value):
string in the list.
"""
-
- # An instance should not have a meaningful value parameter, but
- # sometimes does, particularly for string exceptions, such as
- # >>> raise string1, string2 # deprecated
- #
- # Clear these out first because issubtype(string1, SyntaxError)
- # would raise another exception and mask the original problem.
- if (isinstance(etype, BaseException) or
- isinstance(etype, types.InstanceType) or
- etype is None or type(etype) is str):
+ # Gracefully handle (the way Python 2.4 and earlier did) the case of
+ # being called with (None, None).
+ if etype is None:
return [_format_final_exc_line(etype, value)]
stype = etype.__name__
+ smod = etype.__module__
+ if smod not in ("__main__", "builtins"):
+ stype = smod + '.' + stype
if not issubclass(etype, SyntaxError):
return [_format_final_exc_line(stype, value)]
# It was a syntax error; show exactly where the problem was found.
lines = []
- try:
- msg, (filename, lineno, offset, badline) = value.args
- except Exception:
- pass
- else:
- filename = filename or "<string>"
- lines.append(' File "%s", line %d\n' % (filename, lineno))
- if badline is not None:
- lines.append(' %s\n' % badline.strip())
- if offset is not None:
- caretspace = badline.rstrip('\n')[:offset].lstrip()
- # non-space whitespace (likes tabs) must be kept for alignment
- caretspace = ((c.isspace() and c or ' ') for c in caretspace)
- # only three spaces to account for offset1 == pos 0
- lines.append(' %s^\n' % ''.join(caretspace))
- value = msg
-
- lines.append(_format_final_exc_line(stype, value))
+ filename = value.filename or "<string>"
+ lineno = str(value.lineno) or '?'
+ lines.append(' File "%s", line %s\n' % (filename, lineno))
+ badline = value.text
+ offset = value.offset
+ if badline is not None:
+ lines.append(' %s\n' % badline.strip())
+ if offset is not None:
+ caretspace = badline.rstrip('\n')[:offset].lstrip()
+ # non-space whitespace (likes tabs) must be kept for alignment
+ caretspace = ((c.isspace() and c or ' ') for c in caretspace)
+ # only three spaces to account for offset1 == pos 0
+ lines.append(' %s^\n' % ''.join(caretspace))
+ msg = value.msg or "<no detail available>"
+ lines.append("%s: %s\n" % (stype, msg))
return lines
def _format_final_exc_line(etype, value):
- """Return a list of a single line -- normal case for format_exception_only"""
valuestr = _some_str(value)
if value is None or not valuestr:
line = "%s\n" % etype
@@ -211,39 +246,32 @@ def _format_final_exc_line(etype, value):
def _some_str(value):
try:
return str(value)
- except Exception:
- pass
- try:
- value = unicode(value)
- return value.encode("ascii", "backslashreplace")
- except Exception:
- pass
- return '<unprintable %s object>' % type(value).__name__
+ except:
+ return '<unprintable %s object>' % type(value).__name__
-def print_exc(limit=None, file=None):
- """Shorthand for 'print_exception(sys.exc_type, sys.exc_value, sys.exc_traceback, limit, file)'.
- (In fact, it uses sys.exc_info() to retrieve the same information
- in a thread-safe way.)"""
+def print_exc(limit=None, file=None, chain=True):
+ """Shorthand for 'print_exception(*sys.exc_info(), limit, file)'."""
if file is None:
file = sys.stderr
try:
etype, value, tb = sys.exc_info()
- print_exception(etype, value, tb, limit, file)
+ print_exception(etype, value, tb, limit, file, chain)
finally:
etype = value = tb = None
-def format_exc(limit=None):
+def format_exc(limit=None, chain=True):
"""Like print_exc() but return a string."""
try:
etype, value, tb = sys.exc_info()
- return ''.join(format_exception(etype, value, tb, limit))
+ return ''.join(
+ format_exception(etype, value, tb, limit, chain))
finally:
etype = value = tb = None
-def print_last(limit=None, file=None):
+def print_last(limit=None, file=None, chain=True):
"""This is a shorthand for 'print_exception(sys.last_type,
sys.last_value, sys.last_traceback, limit, file)'."""
if not hasattr(sys, "last_type"):
@@ -251,7 +279,7 @@ def print_last(limit=None, file=None):
if file is None:
file = sys.stderr
print_exception(sys.last_type, sys.last_value, sys.last_traceback,
- limit, file)
+ limit, file, chain)
def print_stack(f=None, limit=None, file=None):
@@ -277,7 +305,7 @@ def format_stack(f=None, limit=None):
f = sys.exc_info()[2].tb_frame.f_back
return format_list(extract_stack(f, limit))
-def extract_stack(f=None, limit = None):
+def extract_stack(f=None, limit=None):
"""Extract the raw traceback from the current stack frame.
The return value has the same format as for extract_tb(). The
@@ -310,10 +338,3 @@ def extract_stack(f=None, limit = None):
n = n+1
list.reverse()
return list
-
-def tb_lineno(tb):
- """Calculate correct line number of traceback given in tb.
-
- Obsolete in 2.3.
- """
- return tb.tb_lineno
diff --git a/Lib/lib-tk/turtle.py b/Lib/turtle.py
index aa4fe8475b8..ac0c32cf217 100644
--- a/Lib/lib-tk/turtle.py
+++ b/Lib/turtle.py
@@ -1,6 +1,6 @@
#
# turtle.py: a Tkinter based turtle graphics module for Python
-# Version 1.0.1 - 24. 9. 2009
+# Version 1.1b - 4. 5. 2009
#
# Copyright (C) 2006 - 2010 Gregor Lingl
# email: glingl@aon.at
@@ -100,49 +100,47 @@ extensions in mind. These will be commented and documented elsewhere.
"""
-_ver = "turtle 1.0b1 - for Python 2.6 - 30. 5. 2008, 18:08"
+_ver = "turtle 1.1b- - for Python 3.1 - 4. 5. 2009"
-#print _ver
+# print(_ver)
-import Tkinter as TK
+import tkinter as TK
import types
import math
import time
import os
+import inspect
from os.path import isfile, split, join
from copy import deepcopy
-
-from math import * ## for compatibility with old turtle module
+from tkinter import simpledialog
_tg_classes = ['ScrolledCanvas', 'TurtleScreen', 'Screen',
'RawTurtle', 'Turtle', 'RawPen', 'Pen', 'Shape', 'Vec2D']
_tg_screen_functions = ['addshape', 'bgcolor', 'bgpic', 'bye',
'clearscreen', 'colormode', 'delay', 'exitonclick', 'getcanvas',
- 'getshapes', 'listen', 'mode', 'onkey', 'onscreenclick', 'ontimer',
+ 'getshapes', 'listen', 'mainloop', 'mode', 'numinput',
+ 'onkey', 'onkeypress', 'onkeyrelease', 'onscreenclick', 'ontimer',
'register_shape', 'resetscreen', 'screensize', 'setup',
- 'setworldcoordinates', 'title', 'tracer', 'turtles', 'update',
+ 'setworldcoordinates', 'textinput', 'title', 'tracer', 'turtles', 'update',
'window_height', 'window_width']
_tg_turtle_functions = ['back', 'backward', 'begin_fill', 'begin_poly', 'bk',
'circle', 'clear', 'clearstamp', 'clearstamps', 'clone', 'color',
'degrees', 'distance', 'dot', 'down', 'end_fill', 'end_poly', 'fd',
- 'fill', 'fillcolor', 'forward', 'get_poly', 'getpen', 'getscreen',
+ 'fillcolor', 'filling', 'forward', 'get_poly', 'getpen', 'getscreen', 'get_shapepoly',
'getturtle', 'goto', 'heading', 'hideturtle', 'home', 'ht', 'isdown',
'isvisible', 'left', 'lt', 'onclick', 'ondrag', 'onrelease', 'pd',
'pen', 'pencolor', 'pendown', 'pensize', 'penup', 'pos', 'position',
'pu', 'radians', 'right', 'reset', 'resizemode', 'rt',
'seth', 'setheading', 'setpos', 'setposition', 'settiltangle',
- 'setundobuffer', 'setx', 'sety', 'shape', 'shapesize', 'showturtle',
- 'speed', 'st', 'stamp', 'tilt', 'tiltangle', 'towards', 'tracer',
+ 'setundobuffer', 'setx', 'sety', 'shape', 'shapesize', 'shapetransform', 'shearfactor', 'showturtle',
+ 'speed', 'st', 'stamp', 'tilt', 'tiltangle', 'towards',
'turtlesize', 'undo', 'undobufferentries', 'up', 'width',
- 'window_height', 'window_width', 'write', 'xcor', 'ycor']
-_tg_utilities = ['write_docstringdict', 'done', 'mainloop']
-_math_functions = ['acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'cosh',
- 'e', 'exp', 'fabs', 'floor', 'fmod', 'frexp', 'hypot', 'ldexp', 'log',
- 'log10', 'modf', 'pi', 'pow', 'sin', 'sinh', 'sqrt', 'tan', 'tanh']
+ 'write', 'xcor', 'ycor']
+_tg_utilities = ['write_docstringdict', 'done']
__all__ = (_tg_classes + _tg_screen_functions + _tg_turtle_functions +
- _tg_utilities + _math_functions)
+ _tg_utilities) # + _math_functions)
_alias_list = ['addshape', 'backward', 'bk', 'fd', 'ht', 'lt', 'pd', 'pos',
'pu', 'rt', 'seth', 'setpos', 'setposition', 'st',
@@ -170,21 +168,10 @@ _CFG = {"width" : 0.5, # Screen
"using_IDLE": False
}
-##print "cwd:", os.getcwd()
-##print "__file__:", __file__
-##
-##def show(dictionary):
-## print "=========================="
-## for key in sorted(dictionary.keys()):
-## print key, ":", dictionary[key]
-## print "=========================="
-## print
-
def config_dict(filename):
"""Convert content of config-file into dictionary."""
- f = open(filename, "r")
- cfglines = f.readlines()
- f.close()
+ with open(filename, "r") as f:
+ cfglines = f.readlines()
cfgdict = {}
for line in cfglines:
line = line.strip()
@@ -193,7 +180,7 @@ def config_dict(filename):
try:
key, value = line.split("=")
except:
- print "Bad line in config-file %s:\n%s" % (filename,line)
+ print("Bad line in config-file %s:\n%s" % (filename,line))
continue
key = key.strip()
value = value.strip()
@@ -228,7 +215,6 @@ def readconfig(cfgdict):
cfgdict2 = {}
if isfile(default_cfg):
cfgdict1 = config_dict(default_cfg)
- #print "1. Loading config-file %s from: %s" % (default_cfg, os.getcwd())
if "importconfig" in cfgdict1:
default_cfg = "turtle_%s.cfg" % cfgdict1["importconfig"]
try:
@@ -237,20 +223,14 @@ def readconfig(cfgdict):
except:
cfg_file2 = ""
if isfile(cfg_file2):
- #print "2. Loading config-file %s:" % cfg_file2
cfgdict2 = config_dict(cfg_file2)
-## show(_CFG)
-## show(cfgdict2)
_CFG.update(cfgdict2)
-## show(_CFG)
-## show(cfgdict1)
_CFG.update(cfgdict1)
-## show(_CFG)
try:
readconfig(_CFG)
except:
- print "No configfile read, reason unknown"
+ print ("No configfile read, reason unknown")
class Vec2D(tuple):
@@ -326,28 +306,24 @@ __stringBody = (
'self.%(attribute)s.%(method)s(*args, **kw)')
def __forwardmethods(fromClass, toClass, toPart, exclude = ()):
- """Helper functions for Scrolled Canvas, used to forward
- ScrolledCanvas-methods to Tkinter.Canvas class.
- """
+ ### MANY CHANGES ###
+ _dict_1 = {}
+ __methodDict(toClass, _dict_1)
_dict = {}
- __methodDict(toClass, _dict)
- for ex in _dict.keys():
- if ex[:1] == '_' or ex[-1:] == '_':
- del _dict[ex]
- for ex in exclude:
- if ex in _dict:
- del _dict[ex]
- for ex in __methods(fromClass):
- if ex in _dict:
- del _dict[ex]
+ mfc = __methods(fromClass)
+ for ex in _dict_1.keys():
+ if ex[:1] == '_' or ex[-1:] == '_' or ex in exclude or ex in mfc:
+ pass
+ else:
+ _dict[ex] = _dict_1[ex]
for method, func in _dict.items():
d = {'method': method, 'func': func}
- if type(toPart) == types.StringType:
+ if isinstance(toPart, str):
execString = \
__stringBody % {'method' : method, 'attribute' : toPart}
- exec execString in d
- fromClass.__dict__[method] = d[method]
+ exec(execString, d)
+ setattr(fromClass, method, d[method]) ### NEWU!
class ScrolledCanvas(TK.Frame):
@@ -699,7 +675,7 @@ class TurtleScreenBase(object):
fun(x, y)
self.cv.bind("<Button-%s>" % num, eventfun, add)
- def _onkey(self, fun, key):
+ def _onkeyrelease(self, fun, key):
"""Bind fun to key-release event of key.
Canvas must have focus. See method listen
"""
@@ -710,6 +686,24 @@ class TurtleScreenBase(object):
fun()
self.cv.bind("<KeyRelease-%s>" % key, eventfun)
+ def _onkeypress(self, fun, key=None):
+ """If key is given, bind fun to key-press event of key.
+ Otherwise bind fun to any key-press.
+ Canvas must have focus. See method listen.
+ """
+ if fun is None:
+ if key is None:
+ self.cv.unbind("<KeyPress>", None)
+ else:
+ self.cv.unbind("<KeyPress-%s>" % key, None)
+ else:
+ def eventfun(event):
+ fun()
+ if key is None:
+ self.cv.bind("<KeyPress>", eventfun)
+ else:
+ self.cv.bind("<KeyPress-%s>" % key, eventfun)
+
def _listen(self):
"""Set focus on canvas (in order to collect key-events)
"""
@@ -728,10 +722,11 @@ class TurtleScreenBase(object):
"""
return self.cv.create_image(0, 0, image=image)
- def _drawimage(self, item, (x, y), image):
+ def _drawimage(self, item, pos, image):
"""Configure image item as to draw image object
at position (x,y) on canvas)
"""
+ x, y = pos
self.cv.coords(item, (x * self.xscale, -y * self.yscale))
self.cv.itemconfig(item, image=image)
@@ -767,7 +762,7 @@ class TurtleScreenBase(object):
def _rescale(self, xscalefactor, yscalefactor):
items = self.cv.find_all()
for item in items:
- coordinates = self.cv.coords(item)
+ coordinates = list(self.cv.coords(item))
newcoordlist = []
while coordinates:
x, y = coordinates[:2]
@@ -802,6 +797,57 @@ class TurtleScreenBase(object):
height = self.cv['height']
return width, height
+ def mainloop(self):
+ """Starts event loop - calling Tkinter's mainloop function.
+
+ No argument.
+
+ Must be last statement in a turtle graphics program.
+ Must NOT be used if a script is run from within IDLE in -n mode
+ (No subprocess) - for interactive use of turtle graphics.
+
+ Example (for a TurtleScreen instance named screen):
+ >>> screen.mainloop()
+
+ """
+ TK.mainloop()
+
+ def textinput(self, title, prompt):
+ """Pop up a dialog window for input of a string.
+
+ Arguments: title is the title of the dialog window,
+ prompt is a text mostly describing what information to input.
+
+ Return the string input
+ If the dialog is canceled, return None.
+
+ Example (for a TurtleScreen instance named screen):
+ >>> screen.textinput("NIM", "Name of first player:")
+
+ """
+ return simpledialog.askstring(title, prompt)
+
+ def numinput(self, title, prompt, default=None, minval=None, maxval=None):
+ """Pop up a dialog window for input of a number.
+
+ Arguments: title is the title of the dialog window,
+ prompt is a text mostly describing what numerical information to input.
+ default: default value
+ minval: minimum value for imput
+ maxval: maximum value for input
+
+ The number input must be in the range minval .. maxval if these are
+ given. If not, a hint is issued and the dialog remains open for
+ correction. Return the number input.
+ If the dialog is canceled, return None.
+
+ Example (for a TurtleScreen instance named screen):
+ >>> screen.numinput("Poker", "Your stakes:", 1000, minval=10, maxval=10000)
+
+ """
+ return simpledialog.askfloat(title, prompt, initialvalue=default,
+ minvalue=minval, maxvalue=maxval)
+
##############################################################################
### End of Tkinter - interface ###
@@ -914,7 +960,6 @@ class TurtleScreen(TurtleScreenBase):
upon components of the underlying graphics toolkit -
which is Tkinter in this case.
"""
-# _STANDARD_DELAY = 5
_RUNNING = True
def __init__(self, cv, mode=_CFG["mode"],
@@ -952,11 +997,11 @@ class TurtleScreen(TurtleScreenBase):
def clear(self):
"""Delete all drawings and all turtles from the TurtleScreen.
+ No argument.
+
Reset empty TurtleScreen to its initial state: white background,
no backgroundimage, no eventbindings and tracing on.
- No argument.
-
Example (for a TurtleScreen instance named screen):
>>> screen.clear()
@@ -973,8 +1018,10 @@ class TurtleScreen(TurtleScreenBase):
self.bgcolor("white")
for btn in 1, 2, 3:
self.onclick(None, btn)
+ self.onkeypress(None)
for key in self._keys[:]:
self.onkey(None, key)
+ self.onkeypress(None, key)
Turtle._pen = None
def mode(self, mode=None):
@@ -1084,7 +1131,6 @@ class TurtleScreen(TurtleScreenBase):
shape = Shape("polygon", shape)
## else shape assumed to be Shape-instance
self._shapes[name] = shape
- # print "shape added:" , self._shapes
def _colorstr(self, color):
"""Return color string corresponding to args.
@@ -1301,8 +1347,7 @@ class TurtleScreen(TurtleScreenBase):
clicked point on the canvas.
num -- the number of the mouse-button, defaults to 1
- Example (for a TurtleScreen instance named screen
- and a Turtle instance named turtle):
+ Example (for a TurtleScreen instance named screen)
>>> screen.onclick(goto)
>>> # Subsequently clicking into the TurtleScreen will
@@ -1339,7 +1384,39 @@ class TurtleScreen(TurtleScreenBase):
self._keys.remove(key)
elif key not in self._keys:
self._keys.append(key)
- self._onkey(fun, key)
+ self._onkeyrelease(fun, key)
+
+ def onkeypress(self, fun, key=None):
+ """Bind fun to key-press event of key if key is given,
+ or to any key-press-event if no key is given.
+
+ Arguments:
+ fun -- a function with no arguments
+ key -- a string: key (e.g. "a") or key-symbol (e.g. "space")
+
+ In order to be able to register key-events, TurtleScreen
+ must have focus. (See method listen.)
+
+ Example (for a TurtleScreen instance named screen
+ and a Turtle instance named turtle):
+
+ >>> def f():
+ ... fd(50)
+ ... lt(60)
+ ...
+ >>> screen.onkeypress(f, "Up")
+ >>> screen.listen()
+
+ Subsequently the turtle can be moved by repeatedly pressing
+ the up-arrow key, or by keeping pressed the up-arrow key.
+ consequently drawing a hexagon.
+ """
+ if fun is None:
+ if key in self._keys:
+ self._keys.remove(key)
+ elif key is not None and key not in self._keys:
+ self._keys.append(key)
+ self._onkeypress(fun, key)
def listen(self, xdummy=None, ydummy=None):
"""Set focus on TurtleScreen (in order to collect key-events)
@@ -1413,7 +1490,7 @@ class TurtleScreen(TurtleScreenBase):
Example (for a Turtle instance named turtle):
>>> turtle.screensize(2000,1500)
- >>> # e. g. to search for an erroneously escaped turtle ;-)
+ >>> # e.g. to search for an erroneously escaped turtle ;-)
"""
return self._resize(canvwidth, canvheight, bg)
@@ -1421,6 +1498,7 @@ class TurtleScreen(TurtleScreenBase):
resetscreen = reset
clearscreen = clear
addshape = register_shape
+ onkeyrelease = onkey
class TNavigator(object):
"""Navigation part of the RawTurtle.
@@ -1894,10 +1972,10 @@ class TNavigator(object):
l = 2.0 * radius * math.sin(w2*math.pi/180.0*self._degreesPerAU)
if radius < 0:
l, w, w2 = -l, -w, -w2
- tr = self.tracer()
+ tr = self._tracer()
dl = self._delay()
if speed == 0:
- self.tracer(0, 0)
+ self._tracer(0, 0)
else:
self.speed(0)
self._rotate(w2)
@@ -1908,7 +1986,7 @@ class TNavigator(object):
self._rotate(w)
self._rotate(-w2)
if speed == 0:
- self.tracer(tr, dl)
+ self._tracer(tr, dl)
self.speed(speed)
if self.undobuffer:
self.undobuffer.cumulate = False
@@ -1917,7 +1995,7 @@ class TNavigator(object):
def speed(self, s=0):
"""dummy method - to be overwritten by child class"""
- def tracer(self, a=None, b=None):
+ def _tracer(self, a=None, b=None):
"""dummy method - to be overwritten by child class"""
def _delay(self, n=None):
"""dummy method - to be overwritten by child class"""
@@ -1950,10 +2028,11 @@ class TPen(object):
self._fillcolor = fillcolor
self._drawing = True
self._speed = 3
- self._stretchfactor = (1, 1)
- self._tilt = 0
+ self._stretchfactor = (1., 1.)
+ self._shearfactor = 0.
+ self._tilt = 0.
+ self._shapetrafo = (1., 0., 0., 1.)
self._outlinewidth = 1
- ### self.screen = None # to override by child class
def resizemode(self, rmode=None):
"""Set resizemode to one of the values: "auto", "user", "noresize".
@@ -2265,6 +2344,7 @@ class TPen(object):
"speed" : number in range 0..10
"resizemode" : "auto" or "user" or "noresize"
"stretchfactor": (positive number, positive number)
+ "shearfactor": number
"outline" : positive number
"tilt" : number
@@ -2279,19 +2359,19 @@ class TPen(object):
>>> turtle.pen()
{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
'pencolor': 'red', 'pendown': True, 'fillcolor': 'black',
- 'stretchfactor': (1,1), 'speed': 3}
+ 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
>>> penstate=turtle.pen()
>>> turtle.color("yellow","")
>>> turtle.penup()
>>> turtle.pen()
{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
'pencolor': 'yellow', 'pendown': False, 'fillcolor': '',
- 'stretchfactor': (1,1), 'speed': 3}
+ 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
>>> p.pen(penstate, fillcolor="green")
>>> p.pen()
{'pensize': 10, 'shown': True, 'resizemode': 'auto', 'outline': 1,
'pencolor': 'red', 'pendown': True, 'fillcolor': 'green',
- 'stretchfactor': (1,1), 'speed': 3}
+ 'stretchfactor': (1,1), 'speed': 3, 'shearfactor': 0.0}
"""
_pd = {"shown" : self._shown,
"pendown" : self._drawing,
@@ -2301,6 +2381,7 @@ class TPen(object):
"speed" : self._speed,
"resizemode" : self._resizemode,
"stretchfactor" : self._stretchfactor,
+ "shearfactor" : self._shearfactor,
"outline" : self._outlinewidth,
"tilt" : self._tilt
}
@@ -2354,12 +2435,20 @@ class TPen(object):
if isinstance(sf, (int, float)):
sf = (sf, sf)
self._stretchfactor = sf
+ if "shearfactor" in p:
+ self._shearfactor = p["shearfactor"]
if "outline" in p:
self._outlinewidth = p["outline"]
if "shown" in p:
self._shown = p["shown"]
if "tilt" in p:
self._tilt = p["tilt"]
+ if "stretchfactor" in p or "tilt" in p or "shearfactor" in p:
+ scx, scy = self._stretchfactor
+ shf = self._shearfactor
+ sa, ca = math.sin(self._tilt), math.cos(self._tilt)
+ self._shapetrafo = ( scx*ca, scy*(shf*ca + sa),
+ -scx*sa, scy*(ca - shf*sa))
self._update()
## three dummy methods to be implemented by child class:
@@ -2392,7 +2481,7 @@ class _TurtleImage(object):
self._setshape(shapeIndex)
def _setshape(self, shapeIndex):
- screen = self.screen # RawTurtle.screens[self.screenIndex]
+ screen = self.screen
self.shapeIndex = shapeIndex
if self._type == "polygon" == screen._shapes[shapeIndex]._type:
return
@@ -2464,7 +2553,7 @@ class RawTurtle(TPen, TNavigator):
"""Delete the turtle's drawings and restore its default values.
No argument.
-,
+
Delete the turtle's drawings from the screen, re-center the turtle
and set variables to the default values.
@@ -2572,7 +2661,7 @@ class RawTurtle(TPen, TNavigator):
t._drawturtle()
screen._update()
- def tracer(self, flag=None, delay=None):
+ def _tracer(self, flag=None, delay=None):
"""Turns turtle animation on/off and set delay for update drawings.
Optional arguments:
@@ -2705,6 +2794,8 @@ class RawTurtle(TPen, TNavigator):
if stretch_wid is stretch_len is outline is None:
stretch_wid, stretch_len = self._stretchfactor
return stretch_wid, stretch_len, self._outlinewidth
+ if stretch_wid == 0 or stretch_len == 0:
+ raise TurtleGraphicsError("stretch_wid/stretch_len must not be zero")
if stretch_wid is not None:
if stretch_len is None:
stretchfactor = stretch_wid, stretch_wid
@@ -2719,11 +2810,33 @@ class RawTurtle(TPen, TNavigator):
self.pen(resizemode="user",
stretchfactor=stretchfactor, outline=outline)
+ def shearfactor(self, shear=None):
+ """Set or return the current shearfactor.
+
+ Optional argument: shear -- number, tangent of the shear angle
+
+ Shear the turtleshape according to the given shearfactor shear,
+ which is the tangent of the shear angle. DO NOT change the
+ turtle's heading (direction of movement).
+ If shear is not given: return the current shearfactor, i. e. the
+ tangent of the shear angle, by which lines parallel to the
+ heading of the turtle are sheared.
+
+ Examples (for a Turtle instance named turtle):
+ >>> turtle.shape("circle")
+ >>> turtle.shapesize(5,2)
+ >>> turtle.shearfactor(0.5)
+ >>> turtle.shearfactor()
+ >>> 0.5
+ """
+ if shear is None:
+ return self._shearfactor
+ self.pen(resizemode="user", shearfactor=shear)
+
def settiltangle(self, angle):
"""Rotate the turtleshape to point in the specified direction
- Optional argument:
- angle -- number
+ Argument: angle -- number
Rotate the turtleshape to point in the direction specified by angle,
regardless of its current tilt-angle. DO NOT change the turtle's
@@ -2744,14 +2857,19 @@ class RawTurtle(TPen, TNavigator):
tilt = (tilt * math.pi / 180.0) % (2*math.pi)
self.pen(resizemode="user", tilt=tilt)
- def tiltangle(self):
- """Return the current tilt-angle.
+ def tiltangle(self, angle=None):
+ """Set or return the current tilt-angle.
- No argument.
+ Optional argument: angle -- number
+
+ Rotate the turtleshape to point in the direction specified by angle,
+ regardless of its current tilt-angle. DO NOT change the turtle's
+ heading (direction of movement).
+ If angle is not given: return the current tilt-angle, i. e. the angle
+ between the orientation of the turtleshape and the heading of the
+ turtle (its direction of movement).
- Return the current tilt-angle, i. e. the angle between the
- orientation of the turtleshape and the heading of the turtle
- (its direction of movement).
+ Deprecated since Python 3.1
Examples (for a Turtle instance named turtle):
>>> turtle.shape("circle")
@@ -2759,8 +2877,11 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.tilt(45)
>>> turtle.tiltangle()
"""
- tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
- return (tilt / self._degreesPerAU) % self._fullcircle
+ if angle is None:
+ tilt = -self._tilt * (180.0/math.pi) * self._angleOrient
+ return (tilt / self._degreesPerAU) % self._fullcircle
+ else:
+ self.settiltangle(angle)
def tilt(self, angle):
"""Rotate the turtleshape by angle.
@@ -2781,6 +2902,46 @@ class RawTurtle(TPen, TNavigator):
"""
self.settiltangle(angle + self.tiltangle())
+ def shapetransform(self, t11=None, t12=None, t21=None, t22=None):
+ """Set or return the current transformation matrix of the turtle shape.
+
+ Optional arguments: t11, t12, t21, t22 -- numbers.
+
+ If none of the matrix elements are given, return the transformation
+ matrix.
+ Otherwise set the given elements and transform the turtleshape
+ according to the matrix consisting of first row t11, t12 and
+ second row t21, 22.
+ Modify stretchfactor, shearfactor and tiltangle according to the
+ given matrix.
+
+ Examples (for a Turtle instance named turtle):
+ >>> turtle.shape("square")
+ >>> turtle.shapesize(4,2)
+ >>> turtle.shearfactor(-0.5)
+ >>> turtle.shapetransform()
+ (4.0, -1.0, -0.0, 2.0)
+ """
+ if t11 is t12 is t21 is t22 is None:
+ return self._shapetrafo
+ m11, m12, m21, m22 = self._shapetrafo
+ if t11 is not None: m11 = t11
+ if t12 is not None: m12 = t12
+ if t21 is not None: m21 = t21
+ if t22 is not None: m22 = t22
+ if t11 * t22 - t12 * t21 == 0:
+ raise TurtleGraphicsError("Bad shape transform matrix: must not be singular")
+ self._shapetrafo = (m11, m12, m21, m22)
+ alfa = math.atan2(-m21, m11) % (2 * math.pi)
+ sa, ca = math.sin(alfa), math.cos(alfa)
+ a11, a12, a21, a22 = (ca*m11 - sa*m21, ca*m12 - sa*m22,
+ sa*m11 + ca*m21, sa*m12 + ca*m22)
+ self._stretchfactor = a11, a22
+ self._shearfactor = a12/a22
+ self._tilt = alfa
+ self._update()
+
+
def _polytrafo(self, poly):
"""Computes transformed polygon shapes from a shape
according to current position and heading.
@@ -2793,6 +2954,36 @@ class RawTurtle(TPen, TNavigator):
return [(p0+(e1*x+e0*y)/screen.xscale, p1+(-e0*x+e1*y)/screen.yscale)
for (x, y) in poly]
+ def get_shapepoly(self):
+ """Return the current shape polygon as tuple of coordinate pairs.
+
+ No argument.
+
+ Examples (for a Turtle instance named turtle):
+ >>> turtle.shape("square")
+ >>> turtle.shapetransform(4, -1, 0, 2)
+ >>> turtle.get_shapepoly()
+ ((50, -20), (30, 20), (-50, 20), (-30, -20))
+
+ """
+ shape = self.screen._shapes[self.turtle.shapeIndex]
+ if shape._type == "polygon":
+ return self._getshapepoly(shape._data, shape._type == "compound")
+ # else return None
+
+ def _getshapepoly(self, polygon, compound=False):
+ """Calculate transformed shape polygon according to resizemode
+ and shapetransform.
+ """
+ if self._resizemode == "user" or compound:
+ t11, t12, t21, t22 = self._shapetrafo
+ elif self._resizemode == "auto":
+ l = max(1, self._pensize/5.0)
+ t11, t12, t21, t22 = l, 0, 0, l
+ elif self._resizemode == "noresize":
+ return polygon
+ return tuple([(t11*x + t12*y, t21*x + t22*y) for (x, y) in polygon])
+
def _drawturtle(self):
"""Manages the correct rendering of the turtle with respect to
its shape, resizemode, stretch and tilt etc."""
@@ -2804,35 +2995,20 @@ class RawTurtle(TPen, TNavigator):
self._hidden_from_screen = False
tshape = shape._data
if ttype == "polygon":
- if self._resizemode == "noresize":
- w = 1
- shape = tshape
- else:
- if self._resizemode == "auto":
- lx = ly = max(1, self._pensize/5.0)
- w = self._pensize
- tiltangle = 0
- elif self._resizemode == "user":
- lx, ly = self._stretchfactor
- w = self._outlinewidth
- tiltangle = self._tilt
- shape = [(lx*x, ly*y) for (x, y) in tshape]
- t0, t1 = math.sin(tiltangle), math.cos(tiltangle)
- shape = [(t1*x+t0*y, -t0*x+t1*y) for (x, y) in shape]
- shape = self._polytrafo(shape)
+ if self._resizemode == "noresize": w = 1
+ elif self._resizemode == "auto": w = self._pensize
+ else: w =self._outlinewidth
+ shape = self._polytrafo(self._getshapepoly(tshape))
fc, oc = self._fillcolor, self._pencolor
screen._drawpoly(titem, shape, fill=fc, outline=oc,
width=w, top=True)
elif ttype == "image":
screen._drawimage(titem, self._position, tshape)
elif ttype == "compound":
- lx, ly = self._stretchfactor
- w = self._outlinewidth
for item, (poly, fc, oc) in zip(titem, tshape):
- poly = [(lx*x, ly*y) for (x, y) in poly]
- poly = self._polytrafo(poly)
+ poly = self._polytrafo(self._getshapepoly(poly, True))
screen._drawpoly(item, poly, fill=self._cc(fc),
- outline=self._cc(oc), width=w, top=True)
+ outline=self._cc(oc), width=self._outlinewidth, top=True)
else:
if self._hidden_from_screen:
return
@@ -2869,22 +3045,10 @@ class RawTurtle(TPen, TNavigator):
tshape = shape._data
if ttype == "polygon":
stitem = screen._createpoly()
- if self._resizemode == "noresize":
- w = 1
- shape = tshape
- else:
- if self._resizemode == "auto":
- lx = ly = max(1, self._pensize/5.0)
- w = self._pensize
- tiltangle = 0
- elif self._resizemode == "user":
- lx, ly = self._stretchfactor
- w = self._outlinewidth
- tiltangle = self._tilt
- shape = [(lx*x, ly*y) for (x, y) in tshape]
- t0, t1 = math.sin(tiltangle), math.cos(tiltangle)
- shape = [(t1*x+t0*y, -t0*x+t1*y) for (x, y) in shape]
- shape = self._polytrafo(shape)
+ if self._resizemode == "noresize": w = 1
+ elif self._resizemode == "auto": w = self._pensize
+ else: w =self._outlinewidth
+ shape = self._polytrafo(self._getshapepoly(tshape))
fc, oc = self._fillcolor, self._pencolor
screen._drawpoly(stitem, shape, fill=fc, outline=oc,
width=w, top=True)
@@ -2897,13 +3061,10 @@ class RawTurtle(TPen, TNavigator):
item = screen._createpoly()
stitem.append(item)
stitem = tuple(stitem)
- lx, ly = self._stretchfactor
- w = self._outlinewidth
for item, (poly, fc, oc) in zip(stitem, tshape):
- poly = [(lx*x, ly*y) for (x, y) in poly]
- poly = self._polytrafo(poly)
+ poly = self._polytrafo(self._getshapepoly(poly, True))
screen._drawpoly(item, poly, fill=self._cc(fc),
- outline=self._cc(oc), width=w, top=True)
+ outline=self._cc(oc), width=self._outlinewidth, top=True)
self.stampItems.append(stitem)
self.undobuffer.push(("stamp", stitem))
return stitem
@@ -2978,7 +3139,7 @@ class RawTurtle(TPen, TNavigator):
if pen is down. All other methodes for turtle movement depend
on this one.
"""
- ## Version mit undo-stuff
+ ## Version with undo-stuff
go_modes = ( self._drawing,
self._pencolor,
self._pensize,
@@ -3034,7 +3195,7 @@ class RawTurtle(TPen, TNavigator):
cLI, cL, pl, items = coodata
screen = self.screen
if abs(self._position - new) > 0.5:
- print "undogoto: HALLO-DA-STIMMT-WAS-NICHT!"
+ print ("undogoto: HALLO-DA-STIMMT-WAS-NICHT!")
# restore former situation
self.currentLineItem = cLI
self.currentLine = cL
@@ -3086,7 +3247,7 @@ class RawTurtle(TPen, TNavigator):
if filling:
if self._fillpath == []:
self._fillpath = None
- print "Unwahrscheinlich in _undogoto!"
+ print("Unwahrscheinlich in _undogoto!")
elif self._fillpath is not None:
self._fillpath.pop()
self._update() #count=True)
@@ -3125,56 +3286,19 @@ class RawTurtle(TPen, TNavigator):
if usePos:
self.currentLine = [self._position]
- def fill(self, flag=None):
- """Call fill(True) before drawing a shape to fill, fill(False) when done.
+ def filling(self):
+ """Return fillstate (True if filling, False else).
- Optional argument:
- flag -- True/False (or 1/0 respectively)
-
- Call fill(True) before drawing the shape you want to fill,
- and fill(False) when done.
- When used without argument: return fillstate (True if filling,
- False else)
+ No argument.
Example (for a Turtle instance named turtle):
- >>> turtle.fill(True)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.fill(False)
+ >>> turtle.begin_fill()
+ >>> if turtle.filling():
+ ... turtle.pensize(5)
+ ... else:
+ ... turtle.pensize(3)
"""
- filling = isinstance(self._fillpath, list)
- if flag is None:
- return filling
- screen = self.screen
- entry1 = entry2 = ()
- if filling:
- if len(self._fillpath) > 2:
- self.screen._drawpoly(self._fillitem, self._fillpath,
- fill=self._fillcolor)
- entry1 = ("dofill", self._fillitem)
- if flag:
- self._fillitem = self.screen._createpoly()
- self.items.append(self._fillitem)
- self._fillpath = [self._position]
- entry2 = ("beginfill", self._fillitem) # , self._fillpath)
- self._newLine()
- else:
- self._fillitem = self._fillpath = None
- if self.undobuffer:
- if entry1 == ():
- if entry2 != ():
- self.undobuffer.push(entry2)
- else:
- if entry2 == ():
- self.undobuffer.push(entry1)
- else:
- self.undobuffer.push(["seq", entry1, entry2])
- self._update()
+ return isinstance(self._fillpath, list)
def begin_fill(self):
"""Called just before drawing a shape to be filled.
@@ -3182,17 +3306,20 @@ class RawTurtle(TPen, TNavigator):
No argument.
Example (for a Turtle instance named turtle):
+ >>> turtle.color("black", "red")
>>> turtle.begin_fill()
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
+ >>> turtle.circle(60)
>>> turtle.end_fill()
"""
- self.fill(True)
+ if not self.filling():
+ self._fillitem = self.screen._createpoly()
+ self.items.append(self._fillitem)
+ self._fillpath = [self._position]
+ self._newLine()
+ if self.undobuffer:
+ self.undobuffer.push(("beginfill", self._fillitem))
+ self._update()
+
def end_fill(self):
"""Fill the shape drawn after the call begin_fill().
@@ -3200,17 +3327,19 @@ class RawTurtle(TPen, TNavigator):
No argument.
Example (for a Turtle instance named turtle):
+ >>> turtle.color("black", "red")
>>> turtle.begin_fill()
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
- >>> turtle.left(90)
- >>> turtle.forward(100)
+ >>> turtle.circle(60)
>>> turtle.end_fill()
"""
- self.fill(False)
+ if self.filling():
+ if len(self._fillpath) > 2:
+ self.screen._drawpoly(self._fillitem, self._fillpath,
+ fill=self._fillcolor)
+ if self.undobuffer:
+ self.undobuffer.push(("dofill", self._fillitem))
+ self._fillitem = self._fillpath = None
+ self._update()
def dot(self, size=None, *color):
"""Draw a dot with diameter size, using color.
@@ -3226,7 +3355,6 @@ class RawTurtle(TPen, TNavigator):
>>> turtle.dot()
>>> turtle.fd(50); turtle.dot(20, "blue"); turtle.fd(50)
"""
- #print "dot-1:", size, color
if not color:
if isinstance(size, (str, tuple)):
color = self._colorstr(size)
@@ -3239,10 +3367,8 @@ class RawTurtle(TPen, TNavigator):
if size is None:
size = self._pensize + max(self._pensize, 4)
color = self._colorstr(color)
- #print "dot-2:", size, color
if hasattr(self.screen, "_dot"):
item = self.screen._dot(self._position, size, color)
- #print "dot:", size, color, "item:", item
self.items.append(item)
if self.undobuffer:
self.undobuffer.push(("dot", item))
@@ -3338,7 +3464,7 @@ class RawTurtle(TPen, TNavigator):
>>> p = turtle.get_poly()
>>> turtle.register_shape("myFavouriteShape", p)
"""
- ## check if there is any poly? -- 1st solution:
+ ## check if there is any poly?
if self._poly is not None:
return tuple(self._poly)
@@ -3382,35 +3508,11 @@ class RawTurtle(TPen, TNavigator):
### screen oriented methods recurring to methods of TurtleScreen
################################################################
- def window_width(self):
- """ Returns the width of the turtle window.
-
- No argument.
-
- Example (for a TurtleScreen instance named screen):
- >>> screen.window_width()
- 640
- """
- return self.screen._window_size()[0]
-
- def window_height(self):
- """ Return the height of the turtle window.
-
- No argument.
-
- Example (for a TurtleScreen instance named screen):
- >>> screen.window_height()
- 480
- """
- return self.screen._window_size()[1]
-
def _delay(self, delay=None):
"""Set delay value which determines speed of turtle animation.
"""
return self.screen.delay(delay)
- ##### event binding methods #####
-
def onclick(self, fun, btn=1, add=None):
"""Bind fun to mouse-click event on this turtle on canvas.
@@ -3503,8 +3605,9 @@ class RawTurtle(TPen, TNavigator):
elif action == "beginfill":
item = data[0]
self._fillitem = self._fillpath = None
- self.screen._delete(item)
- self.items.remove(item)
+ if item in self.items:
+ self.screen._delete(item)
+ self.items.remove(item)
elif action == "pen":
TPen.pen(self, data[0])
self.undobuffer.pop()
@@ -3765,11 +3868,11 @@ def read_docstrings(lang):
module = __import__(modname)
docsdict = module.docsdict
for key in docsdict:
- #print key
try:
- eval(key).im_func.__doc__ = docsdict[key]
+# eval(key).im_func.__doc__ = docsdict[key]
+ eval(key).__doc__ = docsdict[key]
except:
- print "Bad docstring-entry: %s" % key
+ print("Bad docstring-entry: %s" % key)
_LANGUAGE = _CFG["language"]
@@ -3777,47 +3880,42 @@ try:
if _LANGUAGE != "english":
read_docstrings(_LANGUAGE)
except ImportError:
- print "Cannot find docsdict for", _LANGUAGE
+ print("Cannot find docsdict for", _LANGUAGE)
except:
print ("Unknown Error when trying to import %s-docstring-dictionary" %
_LANGUAGE)
def getmethparlist(ob):
- "Get strings describing the arguments for the given object"
- argText1 = argText2 = ""
+ """Get strings describing the arguments for the given object
+
+ Returns a pair of strings representing function parameter lists
+ including parenthesis. The first string is suitable for use in
+ function definition and the second is suitable for use in function
+ call. The "self" parameter is not included.
+ """
+ defText = callText = ""
# bit of a hack for methods - turn it into a function
# but we drop the "self" param.
- if type(ob)==types.MethodType:
- fob = ob.im_func
- argOffset = 1
- else:
- fob = ob
- argOffset = 0
# Try and build one for Python defined functions
- if type(fob) in [types.FunctionType, types.LambdaType]:
- try:
- counter = fob.func_code.co_argcount
- items2 = list(fob.func_code.co_varnames[argOffset:counter])
- realArgs = fob.func_code.co_varnames[argOffset:counter]
- defaults = fob.func_defaults or []
- defaults = list(map(lambda name: "=%s" % repr(name), defaults))
- defaults = [""] * (len(realArgs)-len(defaults)) + defaults
- items1 = map(lambda arg, dflt: arg+dflt, realArgs, defaults)
- if fob.func_code.co_flags & 0x4:
- items1.append("*"+fob.func_code.co_varnames[counter])
- items2.append("*"+fob.func_code.co_varnames[counter])
- counter += 1
- if fob.func_code.co_flags & 0x8:
- items1.append("**"+fob.func_code.co_varnames[counter])
- items2.append("**"+fob.func_code.co_varnames[counter])
- argText1 = ", ".join(items1)
- argText1 = "(%s)" % argText1
- argText2 = ", ".join(items2)
- argText2 = "(%s)" % argText2
- except:
- pass
- return argText1, argText2
+ args, varargs, varkw = inspect.getargs(ob.__code__)
+ items2 = args[1:]
+ realArgs = args[1:]
+ defaults = ob.__defaults__ or []
+ defaults = ["=%r" % (value,) for value in defaults]
+ defaults = [""] * (len(realArgs)-len(defaults)) + defaults
+ items1 = [arg + dflt for arg, dflt in zip(realArgs, defaults)]
+ if varargs is not None:
+ items1.append("*" + varargs)
+ items2.append("*" + varargs)
+ if varkw is not None:
+ items1.append("**" + varkw)
+ items2.append("**" + varkw)
+ defText = ", ".join(items1)
+ defText = "(%s)" % defText
+ callText = ", ".join(items2)
+ callText = "(%s)" % callText
+ return defText, callText
def _turtle_docrevise(docstr):
"""To reduce docstrings from RawTurtle class for functions
@@ -3851,26 +3949,25 @@ def _screen_docrevise(docstr):
for methodname in _tg_screen_functions:
pl1, pl2 = getmethparlist(eval('_Screen.' + methodname))
if pl1 == "":
- print ">>>>>>", pl1, pl2
+ print(">>>>>>", pl1, pl2)
continue
defstr = ("def %(key)s%(pl1)s: return _getscreen().%(key)s%(pl2)s" %
{'key':methodname, 'pl1':pl1, 'pl2':pl2})
- exec defstr
+ exec(defstr)
eval(methodname).__doc__ = _screen_docrevise(eval('_Screen.'+methodname).__doc__)
for methodname in _tg_turtle_functions:
pl1, pl2 = getmethparlist(eval('Turtle.' + methodname))
if pl1 == "":
- print ">>>>>>", pl1, pl2
+ print(">>>>>>", pl1, pl2)
continue
defstr = ("def %(key)s%(pl1)s: return _getpen().%(key)s%(pl2)s" %
{'key':methodname, 'pl1':pl1, 'pl2':pl2})
- exec defstr
+ exec(defstr)
eval(methodname).__doc__ = _turtle_docrevise(eval('Turtle.'+methodname).__doc__)
-done = mainloop = TK.mainloop
-del pl1, pl2, defstr
+done = mainloop
if __name__ == "__main__":
def switchpen():
@@ -3890,13 +3987,13 @@ if __name__ == "__main__":
width(3)
for i in range(3):
if i == 2:
- fill(1)
+ begin_fill()
for _ in range(4):
forward(20)
left(90)
if i == 2:
color("maroon")
- fill(0)
+ end_fill()
up()
forward(30)
down()
@@ -3923,13 +4020,13 @@ if __name__ == "__main__":
right(90)
# filled staircase
tracer(True)
- fill(1)
+ begin_fill()
for i in range(5):
forward(20)
left(90)
forward(20)
right(90)
- fill(0)
+ end_fill()
# more text
def demo2():
@@ -3960,10 +4057,11 @@ if __name__ == "__main__":
for _ in range(3):
fd(laenge)
lt(120)
+ end_fill()
laenge += 10
lt(15)
speed((speed()+1)%12)
- end_fill()
+ #end_fill()
lt(120)
pu()
@@ -3972,13 +4070,13 @@ if __name__ == "__main__":
pd()
color("red","yellow")
speed(0)
- fill(1)
+ begin_fill()
for _ in range(4):
circle(50, 90)
rt(90)
fd(30)
rt(90)
- fill(0)
+ end_fill()
lt(90)
pu()
fd(30)
diff --git a/Lib/turtledemo/__init__.py b/Lib/turtledemo/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Lib/turtledemo/__init__.py
diff --git a/Lib/turtledemo/__main__.py b/Lib/turtledemo/__main__.py
new file mode 100755
index 00000000000..cbf3aeb6921
--- /dev/null
+++ b/Lib/turtledemo/__main__.py
@@ -0,0 +1,266 @@
+#!/usr/bin/env python3
+import sys
+import os
+
+from tkinter import *
+from idlelib.Percolator import Percolator
+from idlelib.ColorDelegator import ColorDelegator
+from idlelib.textView import view_file # TextViewer
+from imp import reload
+
+import turtle
+import time
+
+demo_dir = os.path.dirname(os.path.abspath(__file__))
+
+STARTUP = 1
+READY = 2
+RUNNING = 3
+DONE = 4
+EVENTDRIVEN = 5
+
+menufont = ("Arial", 12, NORMAL)
+btnfont = ("Arial", 12, 'bold')
+txtfont = ('Lucida Console', 8, 'normal')
+
+def getExampleEntries():
+ return [entry[:-3] for entry in os.listdir(demo_dir) if
+ entry.endswith(".py") and entry[0] != '_']
+
+def showDemoHelp():
+ view_file(demo.root, "Help on turtleDemo",
+ os.path.join(demo_dir, "demohelp.txt"))
+
+def showAboutDemo():
+ view_file(demo.root, "About turtleDemo",
+ os.path.join(demo_dir, "about_turtledemo.txt"))
+
+def showAboutTurtle():
+ view_file(demo.root, "About the new turtle module.",
+ os.path.join(demo_dir, "about_turtle.txt"))
+
+class DemoWindow(object):
+
+ def __init__(self, filename=None): #, root=None):
+ self.root = root = turtle._root = Tk()
+ root.wm_protocol("WM_DELETE_WINDOW", self._destroy)
+
+ #################
+ self.mBar = Frame(root, relief=RAISED, borderwidth=2)
+ self.mBar.pack(fill=X)
+
+ self.ExamplesBtn = self.makeLoadDemoMenu()
+ self.OptionsBtn = self.makeHelpMenu()
+ self.mBar.tk_menuBar(self.ExamplesBtn, self.OptionsBtn) #, QuitBtn)
+
+ root.title('Python turtle-graphics examples')
+ #################
+ self.left_frame = left_frame = Frame(root)
+ self.text_frame = text_frame = Frame(left_frame)
+ self.vbar = vbar =Scrollbar(text_frame, name='vbar')
+ self.text = text = Text(text_frame,
+ name='text', padx=5, wrap='none',
+ width=45)
+ vbar['command'] = text.yview
+ vbar.pack(side=LEFT, fill=Y)
+ #####################
+ self.hbar = hbar =Scrollbar(text_frame, name='hbar', orient=HORIZONTAL)
+ hbar['command'] = text.xview
+ hbar.pack(side=BOTTOM, fill=X)
+ #####################
+ text['yscrollcommand'] = vbar.set
+ text.config(font=txtfont)
+ text.config(xscrollcommand=hbar.set)
+ text.pack(side=LEFT, fill=Y, expand=1)
+ #####################
+ self.output_lbl = Label(left_frame, height= 1,text=" --- ", bg = "#ddf",
+ font = ("Arial", 16, 'normal'))
+ self.output_lbl.pack(side=BOTTOM, expand=0, fill=X)
+ #####################
+ text_frame.pack(side=LEFT, fill=BOTH, expand=0)
+ left_frame.pack(side=LEFT, fill=BOTH, expand=0)
+ self.graph_frame = g_frame = Frame(root)
+
+ turtle._Screen._root = g_frame
+ turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
+ #xturtle.Screen._canvas.pack(expand=1, fill="both")
+ self.screen = _s_ = turtle.Screen()
+#####
+ turtle.TurtleScreen.__init__(_s_, _s_._canvas)
+#####
+ self.scanvas = _s_._canvas
+ #xturtle.RawTurtle.canvases = [self.scanvas]
+ turtle.RawTurtle.screens = [_s_]
+
+ self.scanvas.pack(side=TOP, fill=BOTH, expand=1)
+
+ self.btn_frame = btn_frame = Frame(g_frame, height=100)
+ self.start_btn = Button(btn_frame, text=" START ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command=self.startDemo)
+ self.start_btn.pack(side=LEFT, fill=X, expand=1)
+ self.stop_btn = Button(btn_frame, text=" STOP ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command = self.stopIt)
+ self.stop_btn.pack(side=LEFT, fill=X, expand=1)
+ self.clear_btn = Button(btn_frame, text=" CLEAR ", font=btnfont, fg = "white",
+ disabledforeground = "#fed", command = self.clearCanvas)
+ self.clear_btn.pack(side=LEFT, fill=X, expand=1)
+
+ self.btn_frame.pack(side=TOP, fill=BOTH, expand=0)
+ self.graph_frame.pack(side=TOP, fill=BOTH, expand=1)
+
+ Percolator(text).insertfilter(ColorDelegator())
+ self.dirty = False
+ self.exitflag = False
+ if filename:
+ self.loadfile(filename)
+ self.configGUI(NORMAL, DISABLED, DISABLED, DISABLED,
+ "Choose example from menu", "black")
+ self.state = STARTUP
+
+ def _destroy(self):
+ self.root.destroy()
+ sys.exit()
+
+ def configGUI(self, menu, start, stop, clear, txt="", color="blue"):
+ self.ExamplesBtn.config(state=menu)
+
+ self.start_btn.config(state=start)
+ if start == NORMAL:
+ self.start_btn.config(bg="#d00")
+ else:
+ self.start_btn.config(bg="#fca")
+
+ self.stop_btn.config(state=stop)
+ if stop == NORMAL:
+ self.stop_btn.config(bg="#d00")
+ else:
+ self.stop_btn.config(bg="#fca")
+ self.clear_btn.config(state=clear)
+
+ self.clear_btn.config(state=clear)
+ if clear == NORMAL:
+ self.clear_btn.config(bg="#d00")
+ else:
+ self.clear_btn.config(bg="#fca")
+
+ self.output_lbl.config(text=txt, fg=color)
+
+
+ def makeLoadDemoMenu(self):
+ CmdBtn = Menubutton(self.mBar, text='Examples', underline=0, font=menufont)
+ CmdBtn.pack(side=LEFT, padx="2m")
+ CmdBtn.menu = Menu(CmdBtn)
+
+ for entry in getExampleEntries():
+ def loadexample(x):
+ def emit():
+ self.loadfile(x)
+ return emit
+ CmdBtn.menu.add_command(label=entry, underline=0,
+ font=menufont, command=loadexample(entry))
+
+ CmdBtn['menu'] = CmdBtn.menu
+ return CmdBtn
+
+ def makeHelpMenu(self):
+ CmdBtn = Menubutton(self.mBar, text='Help', underline=0, font=menufont)
+ CmdBtn.pack(side=LEFT, padx='2m')
+ CmdBtn.menu = Menu(CmdBtn)
+
+ CmdBtn.menu.add_command(label='About turtle.py', font=menufont,
+ command=showAboutTurtle)
+ CmdBtn.menu.add_command(label='turtleDemo - Help', font=menufont,
+ command=showDemoHelp)
+ CmdBtn.menu.add_command(label='About turtleDemo', font=menufont,
+ command=showAboutDemo)
+
+ CmdBtn['menu'] = CmdBtn.menu
+ return CmdBtn
+
+ def refreshCanvas(self):
+ if not self.dirty: return
+ self.screen.clear()
+ #self.screen.mode("standard")
+ self.dirty=False
+
+ def loadfile(self, filename):
+ self.refreshCanvas()
+ modname = 'turtledemo.' + filename
+ __import__(modname)
+ self.module = sys.modules[modname]
+ with open(self.module.__file__, 'r') as f:
+ chars = f.read()
+ self.text.delete("1.0", "end")
+ self.text.insert("1.0", chars)
+ self.root.title(filename + " - a Python turtle graphics example")
+ reload(self.module)
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
+ "Press start button", "red")
+ self.state = READY
+
+ def startDemo(self):
+ self.refreshCanvas()
+ self.dirty = True
+ turtle.TurtleScreen._RUNNING = True
+ self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
+ "demo running...", "black")
+ self.screen.clear()
+ self.screen.mode("standard")
+ self.state = RUNNING
+
+ try:
+ result = self.module.main()
+ if result == "EVENTLOOP":
+ self.state = EVENTDRIVEN
+ else:
+ self.state = DONE
+ except turtle.Terminator:
+ self.state = DONE
+ result = "stopped!"
+ if self.state == DONE:
+ self.configGUI(NORMAL, NORMAL, DISABLED, NORMAL,
+ result)
+ elif self.state == EVENTDRIVEN:
+ self.exitflag = True
+ self.configGUI(DISABLED, DISABLED, NORMAL, DISABLED,
+ "use mouse/keys or STOP", "red")
+
+ def clearCanvas(self):
+ self.refreshCanvas()
+ self.screen._delete("all")
+ self.scanvas.config(cursor="")
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED)
+
+ def stopIt(self):
+ if self.exitflag:
+ self.clearCanvas()
+ self.exitflag = False
+ self.configGUI(NORMAL, NORMAL, DISABLED, DISABLED,
+ "STOPPED!", "red")
+ turtle.TurtleScreen._RUNNING = False
+ #print "stopIT: exitflag = True"
+ else:
+ turtle.TurtleScreen._RUNNING = False
+ #print "stopIt: exitflag = False"
+
+if __name__ == '__main__':
+ demo = DemoWindow()
+ RUN = True
+ while RUN:
+ try:
+ #print("ENTERING mainloop")
+ demo.root.mainloop()
+ except AttributeError:
+ #print("AttributeError!- WAIT A MOMENT!")
+ time.sleep(0.3)
+ print("GOING ON ..")
+ demo.ckearCanvas()
+ except TypeError:
+ demo.screen._delete("all")
+ #print("CRASH!!!- WAIT A MOMENT!")
+ time.sleep(0.3)
+ #print("GOING ON ..")
+ demo.clearCanvas()
+ except:
+ print("BYE!")
+ RUN = False
diff --git a/Lib/turtledemo/about_turtle.txt b/Lib/turtledemo/about_turtle.txt
new file mode 100644
index 00000000000..d02c7b32600
--- /dev/null
+++ b/Lib/turtledemo/about_turtle.txt
@@ -0,0 +1,76 @@
+
+========================================================
+ A new turtle module for Python
+========================================================
+
+Turtle graphics is a popular way for introducing programming to
+kids. It was part of the original Logo programming language developed
+by Wally Feurzig and Seymour Papert in 1966.
+
+Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it
+the command turtle.forward(15), and it moves (on-screen!) 15 pixels in
+the direction it is facing, drawing a line as it moves. Give it the
+command turtle.right(25), and it rotates in-place 25 degrees clockwise.
+
+By combining together these and similar commands, intricate shapes and
+pictures can easily be drawn.
+
+----- turtle.py
+
+This module is an extended reimplementation of turtle.py from the
+Python standard distribution up to Python 2.5. (See: http:\\www.python.org)
+
+It tries to keep the merits of turtle.py and to be (nearly) 100%
+compatible with it. This means in the first place to enable the
+learning programmer to use all the commands, classes and methods
+interactively when using the module from within IDLE run with
+the -n switch.
+
+Roughly it has the following features added:
+
+- Better animation of the turtle movements, especially of turning the
+ turtle. So the turtles can more easily be used as a visual feedback
+ instrument by the (beginning) programmer.
+
+- Different turtle shapes, gif-images as turtle shapes, user defined
+ and user controllable turtle shapes, among them compound
+ (multicolored) shapes. Turtle shapes can be stgretched and tilted, which
+ makes turtles zu very versatile geometrical objects.
+
+- Fine control over turtle movement and screen updates via delay(),
+ and enhanced tracer() and speed() methods.
+
+- Aliases for the most commonly used commands, like fd for forward etc.,
+ following the early Logo traditions. This reduces the boring work of
+ typing long sequences of commands, which often occur in a natural way
+ when kids try to program fancy pictures on their first encounter with
+ turtle graphcis.
+
+- Turtles now have an undo()-method with configurable undo-buffer.
+
+- Some simple commands/methods for creating event driven programs
+ (mouse-, key-, timer-events). Especially useful for programming games.
+
+- A scrollable Canvas class. The default scrollable Canvas can be
+ extended interactively as needed while playing around with the turtle(s).
+
+- A TurtleScreen class with methods controlling background color or
+ background image, window and canvas size and other properties of the
+ TurtleScreen.
+
+- There is a method, setworldcoordinates(), to install a user defined
+ coordinate-system for the TurtleScreen.
+
+- The implementation uses a 2-vector class named Vec2D, derived from tuple.
+ This class is public, so it can be imported by the application programmer,
+ which makes certain types of computations very natural and compact.
+
+- Appearance of the TurtleScreen and the Turtles at startup/import can be
+ configured by means of a turtle.cfg configuration file.
+ The default configuration mimics the appearance of the old turtle module.
+
+- If configured appropriately the module reads in docstrings from a docstring
+ dictionary in some different language, supplied separately and replaces
+ the english ones by those read in. There is a utility function
+ write_docstringdict() to write a dictionary with the original (english)
+ docstrings to disc, so it can serve as a template for translations.
diff --git a/Lib/turtledemo/about_turtledemo.txt b/Lib/turtledemo/about_turtledemo.txt
new file mode 100644
index 00000000000..a9009bd5fbf
--- /dev/null
+++ b/Lib/turtledemo/about_turtledemo.txt
@@ -0,0 +1,13 @@
+
+ --------------------------------------
+ About this viewer
+ --------------------------------------
+
+ Tiny demo viewer to view turtle graphics example scripts.
+
+ Quickly and dirtyly assembled by Gregor Lingl.
+ June, 2006
+
+ For more information see: turtleDemo - Help
+
+ Have fun!
diff --git a/Lib/turtledemo/bytedesign.py b/Lib/turtledemo/bytedesign.py
new file mode 100644
index 00000000000..64b1d7d5b03
--- /dev/null
+++ b/Lib/turtledemo/bytedesign.py
@@ -0,0 +1,162 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_bytedesign.py
+
+An example adapted from the example-suite
+of PythonCard's turtle graphics.
+
+It's based on an article in BYTE magazine
+Problem Solving with Logo: Using Turtle
+Graphics to Redraw a Design
+November 1982, p. 118 - 134
+
+-------------------------------------------
+
+Due to the statement
+
+t.delay(0)
+
+in line 152, which sets the animation delay
+to 0, this animation runs in "line per line"
+mode as fast as possible.
+"""
+
+import math
+from turtle import Turtle, mainloop
+from time import clock
+
+# wrapper for any additional drawing routines
+# that need to know about each other
+class Designer(Turtle):
+
+ def design(self, homePos, scale):
+ self.up()
+ for i in range(5):
+ self.forward(64.65 * scale)
+ self.down()
+ self.wheel(self.position(), scale)
+ self.up()
+ self.backward(64.65 * scale)
+ self.right(72)
+ self.up()
+ self.goto(homePos)
+ self.right(36)
+ self.forward(24.5 * scale)
+ self.right(198)
+ self.down()
+ self.centerpiece(46 * scale, 143.4, scale)
+ self.getscreen().tracer(True)
+
+ def wheel(self, initpos, scale):
+ self.right(54)
+ for i in range(4):
+ self.pentpiece(initpos, scale)
+ self.down()
+ self.left(36)
+ for i in range(5):
+ self.tripiece(initpos, scale)
+ self.left(36)
+ for i in range(5):
+ self.down()
+ self.right(72)
+ self.forward(28 * scale)
+ self.up()
+ self.backward(28 * scale)
+ self.left(54)
+ self.getscreen().update()
+
+ def tripiece(self, initpos, scale):
+ oldh = self.heading()
+ self.down()
+ self.backward(2.5 * scale)
+ self.tripolyr(31.5 * scale, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.down()
+ self.backward(2.5 * scale)
+ self.tripolyl(31.5 * scale, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.left(72)
+ self.getscreen().update()
+
+ def pentpiece(self, initpos, scale):
+ oldh = self.heading()
+ self.up()
+ self.forward(29 * scale)
+ self.down()
+ for i in range(5):
+ self.forward(18 * scale)
+ self.right(72)
+ self.pentr(18 * scale, 75, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.forward(29 * scale)
+ self.down()
+ for i in range(5):
+ self.forward(18 * scale)
+ self.right(72)
+ self.pentl(18 * scale, 75, scale)
+ self.up()
+ self.goto(initpos)
+ self.setheading(oldh)
+ self.left(72)
+ self.getscreen().update()
+
+ def pentl(self, side, ang, scale):
+ if side < (2 * scale): return
+ self.forward(side)
+ self.left(ang)
+ self.pentl(side - (.38 * scale), ang, scale)
+
+ def pentr(self, side, ang, scale):
+ if side < (2 * scale): return
+ self.forward(side)
+ self.right(ang)
+ self.pentr(side - (.38 * scale), ang, scale)
+
+ def tripolyr(self, side, scale):
+ if side < (4 * scale): return
+ self.forward(side)
+ self.right(111)
+ self.forward(side / 1.78)
+ self.right(111)
+ self.forward(side / 1.3)
+ self.right(146)
+ self.tripolyr(side * .75, scale)
+
+ def tripolyl(self, side, scale):
+ if side < (4 * scale): return
+ self.forward(side)
+ self.left(111)
+ self.forward(side / 1.78)
+ self.left(111)
+ self.forward(side / 1.3)
+ self.left(146)
+ self.tripolyl(side * .75, scale)
+
+ def centerpiece(self, s, a, scale):
+ self.forward(s); self.left(a)
+ if s < (7.5 * scale):
+ return
+ self.centerpiece(s - (1.2 * scale), a, scale)
+
+def main():
+ t = Designer()
+ t.speed(0)
+ t.hideturtle()
+ t.getscreen().delay(0)
+ t.getscreen().tracer(0)
+ at = clock()
+ t.design(t.position(), 2)
+ et = clock()
+ return "runtime: %.2f sec." % (et-at)
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/chaos.py b/Lib/turtledemo/chaos.py
new file mode 100644
index 00000000000..d4656f89148
--- /dev/null
+++ b/Lib/turtledemo/chaos.py
@@ -0,0 +1,59 @@
+# File: tdemo_chaos.py
+# Author: Gregor Lingl
+# Date: 2009-06-24
+
+# A demonstration of chaos
+
+from turtle import *
+
+N = 80
+
+def f(x):
+ return 3.9*x*(1-x)
+
+def g(x):
+ return 3.9*(x-x**2)
+
+def h(x):
+ return 3.9*x-3.9*x*x
+
+def jumpto(x, y):
+ penup(); goto(x,y)
+
+def line(x1, y1, x2, y2):
+ jumpto(x1, y1)
+ pendown()
+ goto(x2, y2)
+
+def coosys():
+ line(-1, 0, N+1, 0)
+ line(0, -0.1, 0, 1.1)
+
+def plot(fun, start, colour):
+ pencolor(colour)
+ x = start
+ jumpto(0, x)
+ pendown()
+ dot(5)
+ for i in range(N):
+ x=fun(x)
+ goto(i+1,x)
+ dot(5)
+
+def main():
+ reset()
+ setworldcoordinates(-1.0,-0.1, N+1, 1.1)
+ speed(0)
+ hideturtle()
+ coosys()
+ plot(f, 0.35, "blue")
+ plot(g, 0.35, "green")
+ plot(h, 0.35, "red")
+ # Now zoom in:
+ for s in range(100):
+ setworldcoordinates(0.5*s,-0.1, N+1, 1.1)
+ return "Done!"
+
+if __name__ == "__main__":
+ main()
+ mainloop()
diff --git a/Lib/turtledemo/clock.py b/Lib/turtledemo/clock.py
new file mode 100644
index 00000000000..a0d157ba49d
--- /dev/null
+++ b/Lib/turtledemo/clock.py
@@ -0,0 +1,132 @@
+#!/usr/bin/env python3
+# -*- coding: cp1252 -*-
+""" turtle-example-suite:
+
+ tdemo_clock.py
+
+Enhanced clock-program, showing date
+and time
+ ------------------------------------
+ Press STOP to exit the program!
+ ------------------------------------
+"""
+from turtle import *
+from datetime import datetime
+
+mode("logo")
+
+def jump(distanz, winkel=0):
+ penup()
+ right(winkel)
+ forward(distanz)
+ left(winkel)
+ pendown()
+
+def hand(laenge, spitze):
+ fd(laenge*1.15)
+ rt(90)
+ fd(spitze/2.0)
+ lt(120)
+ fd(spitze)
+ lt(120)
+ fd(spitze)
+ lt(120)
+ fd(spitze/2.0)
+
+def make_hand_shape(name, laenge, spitze):
+ reset()
+ jump(-laenge*0.15)
+ begin_poly()
+ hand(laenge, spitze)
+ end_poly()
+ hand_form = get_poly()
+ register_shape(name, hand_form)
+
+
+def clockface(radius):
+ reset()
+ pensize(7)
+ for i in range(60):
+ jump(radius)
+ if i % 5 == 0:
+ fd(25)
+ jump(-radius-25)
+ else:
+ dot(3)
+ jump(-radius)
+ rt(6)
+
+def setup():
+ global second_hand, minute_hand, hour_hand, writer
+ mode("logo")
+ make_hand_shape("second_hand", 125, 25)
+ make_hand_shape("minute_hand", 130, 25)
+ make_hand_shape("hour_hand", 90, 25)
+ clockface(160)
+ second_hand = Turtle()
+ second_hand.shape("second_hand")
+ second_hand.color("gray20", "gray80")
+ minute_hand = Turtle()
+ minute_hand.shape("minute_hand")
+ minute_hand.color("blue1", "red1")
+ hour_hand = Turtle()
+ hour_hand.shape("hour_hand")
+ hour_hand.color("blue3", "red3")
+ for hand in second_hand, minute_hand, hour_hand:
+ hand.resizemode("user")
+ hand.shapesize(1, 1, 3)
+ hand.speed(0)
+ ht()
+ writer = Turtle()
+ #writer.mode("logo")
+ writer.ht()
+ writer.pu()
+ writer.bk(85)
+
+
+def wochentag(t):
+ wochentag = ["Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday", "Sunday"]
+ return wochentag[t.weekday()]
+
+def datum(z):
+ monat = ["Jan.", "Feb.", "Mar.", "Apr.", "May", "June",
+ "July", "Aug.", "Sep.", "Oct.", "Nov.", "Dec."]
+ j = z.year
+ m = monat[z.month - 1]
+ t = z.day
+ return "%s %d %d" % (m, t, j)
+
+def tick():
+ t = datetime.today()
+ sekunde = t.second + t.microsecond*0.000001
+ minute = t.minute + sekunde/60.0
+ stunde = t.hour + minute/60.0
+ tracer(False)
+ writer.clear()
+ writer.home()
+ writer.forward(65)
+ writer.write(wochentag(t),
+ align="center", font=("Courier", 14, "bold"))
+ writer.back(150)
+ writer.write(datum(t),
+ align="center", font=("Courier", 14, "bold"))
+ writer.forward(85)
+ tracer(True)
+ second_hand.setheading(6*sekunde)
+ minute_hand.setheading(6*minute)
+ hour_hand.setheading(30*stunde)
+ tracer(True)
+ ontimer(tick, 100)
+
+def main():
+ tracer(False)
+ setup()
+ tracer(True)
+ tick()
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/colormixer.py b/Lib/turtledemo/colormixer.py
new file mode 100644
index 00000000000..f5d308d4430
--- /dev/null
+++ b/Lib/turtledemo/colormixer.py
@@ -0,0 +1,60 @@
+# colormixer
+
+from turtle import Screen, Turtle, mainloop
+import sys
+sys.setrecursionlimit(20000) # overcomes, for now, an instability of Python 3.0
+
+class ColorTurtle(Turtle):
+
+ def __init__(self, x, y):
+ Turtle.__init__(self)
+ self.shape("turtle")
+ self.resizemode("user")
+ self.shapesize(3,3,5)
+ self.pensize(10)
+ self._color = [0,0,0]
+ self.x = x
+ self._color[x] = y
+ self.color(self._color)
+ self.speed(0)
+ self.left(90)
+ self.pu()
+ self.goto(x,0)
+ self.pd()
+ self.sety(1)
+ self.pu()
+ self.sety(y)
+ self.pencolor("gray25")
+ self.ondrag(self.shift)
+
+ def shift(self, x, y):
+ self.sety(max(0,min(y,1)))
+ self._color[self.x] = self.ycor()
+ self.fillcolor(self._color)
+ setbgcolor()
+
+def setbgcolor():
+ screen.bgcolor(red.ycor(), green.ycor(), blue.ycor())
+
+def main():
+ global screen, red, green, blue
+ screen = Screen()
+ screen.delay(0)
+ screen.setworldcoordinates(-1, -0.3, 3, 1.3)
+
+ red = ColorTurtle(0, .5)
+ green = ColorTurtle(1, .5)
+ blue = ColorTurtle(2, .5)
+ setbgcolor()
+
+ writer = Turtle()
+ writer.ht()
+ writer.pu()
+ writer.goto(1,1.15)
+ writer.write("DRAG!",align="center",font=("Arial",30,("bold","italic")))
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/demohelp.txt b/Lib/turtledemo/demohelp.txt
new file mode 100644
index 00000000000..fe83bc76019
--- /dev/null
+++ b/Lib/turtledemo/demohelp.txt
@@ -0,0 +1,70 @@
+
+
+ ----------------------------------------------
+
+ turtleDemo - Help
+
+ ----------------------------------------------
+
+ This document has two sections:
+
+ (1) How to use the demo viewer
+ (2) How to add your own demos to the demo repository
+
+
+ (1) How to use the demo viewer.
+
+ Select a demoscript from the example menu.
+ The (syntax coloured) source code appears in the left
+ source code window. IT CANNOT BE EDITED, but ONLY VIEWED!
+
+ - Press START button to start the demo.
+ - Stop execution by pressing the STOP button.
+ - Clear screen by pressing the CLEAR button.
+ - Restart by pressing the START button again.
+
+ SPECIAL demos are those which run EVENTDRIVEN.
+ (For example clock.py - or oldTurtleDemo.py which
+ in the end expects a mouse click.):
+
+ Press START button to start the demo.
+
+ - Until the EVENTLOOP is entered everything works
+ as in an ordinary demo script.
+
+ - When the EVENTLOOP is entered, you control the
+ application by using the mouse and/or keys (or it's
+ controlled by some timer events)
+ To stop it you can and must press the STOP button.
+
+ While the EVENTLOOP is running, the examples menu is disabled.
+
+ - Only after having pressed the STOP button, you may
+ restart it or choose another example script.
+
+ * * * * * * * *
+ In some rare situations there may occur interferences/conflicts
+ between events concerning the demo script and those concerning the
+ demo-viewer. (They run in the same process.) Strange behaviour may be
+ the consequence and in the worst case you must close and restart the
+ viewer.
+ * * * * * * * *
+
+
+ (2) How to add your own demos to the demo repository
+
+ - place: same directory as turtledemo/__main__.py
+
+ - requirements on source code:
+ code must contain a main() function which will
+ be executed by the viewer (see provided example scripts)
+ main() may return a string which will be displayed
+ in the Label below the source code window (when execution
+ has finished.)
+
+ !! For programs, which are EVENT DRIVEN, main must return
+ !! the string "EVENTLOOP". This informs the viewer, that the
+ !! script is still running and must be stopped by the user!
+
+
+
diff --git a/Lib/turtledemo/forest.py b/Lib/turtledemo/forest.py
new file mode 100644
index 00000000000..a837d844c91
--- /dev/null
+++ b/Lib/turtledemo/forest.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python3
+""" turtlegraphics-example-suite:
+
+ tdemo_forest.py
+
+Displays a 'forest' of 3 'breadth-first-trees'
+similar to the one from example tree.
+For further remarks see xtx_tree.py
+
+This example is a 'breadth-first'-rewrite of
+a Logo program written by Erich Neuwirth. See:
+http://homepage.univie.ac.at/erich.neuwirth/
+"""
+from turtle import Turtle, colormode, tracer, mainloop
+from random import randrange
+from time import clock
+
+def symRandom(n):
+ return randrange(-n,n+1)
+
+def randomize( branchlist, angledist, sizedist ):
+ return [ (angle+symRandom(angledist),
+ sizefactor*1.01**symRandom(sizedist))
+ for angle, sizefactor in branchlist ]
+
+def randomfd( t, distance, parts, angledist ):
+ for i in range(parts):
+ t.left(symRandom(angledist))
+ t.forward( (1.0 * distance)/parts )
+
+def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
+ # benutzt Liste von turtles und Liste von Zweiglisten,
+ # fuer jede turtle eine!
+ if level > 0:
+ lst = []
+ brs = []
+ for t, branchlist in list(zip(tlist,branchlists)):
+ t.pensize( size * widthfactor )
+ t.pencolor( 255 - (180 - 11 * level + symRandom(15)),
+ 180 - 11 * level + symRandom(15),
+ 0 )
+ t.pendown()
+ randomfd(t, size, level, angledist )
+ yield 1
+ for angle, sizefactor in branchlist:
+ t.left(angle)
+ lst.append(t.clone())
+ brs.append(randomize(branchlist, angledist, sizedist))
+ t.right(angle)
+ for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
+ angledist, sizedist):
+ yield None
+
+
+def start(t,x,y):
+ colormode(255)
+ t.reset()
+ t.speed(0)
+ t.hideturtle()
+ t.left(90)
+ t.penup()
+ t.setpos(x,y)
+ t.pendown()
+
+def doit1(level, pen):
+ pen.hideturtle()
+ start(pen, 20, -208)
+ t = tree( [pen], 80, level, 0.1, [[ (45,0.69), (0,0.65), (-45,0.71) ]] )
+ return t
+
+def doit2(level, pen):
+ pen.hideturtle()
+ start(pen, -135, -130)
+ t = tree( [pen], 120, level, 0.1, [[ (45,0.69), (-45,0.71) ]] )
+ return t
+
+def doit3(level, pen):
+ pen.hideturtle()
+ start(pen, 190, -90)
+ t = tree( [pen], 100, level, 0.1, [[ (45,0.7), (0,0.72), (-45,0.65) ]] )
+ return t
+
+# Hier 3 Baumgeneratoren:
+def main():
+ p = Turtle()
+ p.ht()
+ tracer(75,0)
+ u = doit1(6, Turtle(undobuffersize=1))
+ s = doit2(7, Turtle(undobuffersize=1))
+ t = doit3(5, Turtle(undobuffersize=1))
+ a = clock()
+ while True:
+ done = 0
+ for b in u,s,t:
+ try:
+ b.__next__()
+ except:
+ done += 1
+ if done == 3:
+ break
+
+ tracer(1,10)
+ b = clock()
+ return "runtime: %.2f sec." % (b-a)
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/fractalcurves.py b/Lib/turtledemo/fractalcurves.py
new file mode 100644
index 00000000000..c49f8b88ea1
--- /dev/null
+++ b/Lib/turtledemo/fractalcurves.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_fractalCurves.py
+
+This program draws two fractal-curve-designs:
+(1) A hilbert curve (in a box)
+(2) A combination of Koch-curves.
+
+The CurvesTurtle class and the fractal-curve-
+methods are taken from the PythonCard example
+scripts for turtle-graphics.
+"""
+from turtle import *
+from time import sleep, clock
+
+class CurvesTurtle(Pen):
+ # example derived from
+ # Turtle Geometry: The Computer as a Medium for Exploring Mathematics
+ # by Harold Abelson and Andrea diSessa
+ # p. 96-98
+ def hilbert(self, size, level, parity):
+ if level == 0:
+ return
+ # rotate and draw first subcurve with opposite parity to big curve
+ self.left(parity * 90)
+ self.hilbert(size, level - 1, -parity)
+ # interface to and draw second subcurve with same parity as big curve
+ self.forward(size)
+ self.right(parity * 90)
+ self.hilbert(size, level - 1, parity)
+ # third subcurve
+ self.forward(size)
+ self.hilbert(size, level - 1, parity)
+ # fourth subcurve
+ self.right(parity * 90)
+ self.forward(size)
+ self.hilbert(size, level - 1, -parity)
+ # a final turn is needed to make the turtle
+ # end up facing outward from the large square
+ self.left(parity * 90)
+
+ # Visual Modeling with Logo: A Structural Approach to Seeing
+ # by James Clayson
+ # Koch curve, after Helge von Koch who introduced this geometric figure in 1904
+ # p. 146
+ def fractalgon(self, n, rad, lev, dir):
+ import math
+
+ # if dir = 1 turn outward
+ # if dir = -1 turn inward
+ edge = 2 * rad * math.sin(math.pi / n)
+ self.pu()
+ self.fd(rad)
+ self.pd()
+ self.rt(180 - (90 * (n - 2) / n))
+ for i in range(n):
+ self.fractal(edge, lev, dir)
+ self.rt(360 / n)
+ self.lt(180 - (90 * (n - 2) / n))
+ self.pu()
+ self.bk(rad)
+ self.pd()
+
+ # p. 146
+ def fractal(self, dist, depth, dir):
+ if depth < 1:
+ self.fd(dist)
+ return
+ self.fractal(dist / 3, depth - 1, dir)
+ self.lt(60 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+ self.rt(120 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+ self.lt(60 * dir)
+ self.fractal(dist / 3, depth - 1, dir)
+
+def main():
+ ft = CurvesTurtle()
+
+ ft.reset()
+ ft.speed(0)
+ ft.ht()
+ ft.getscreen().tracer(1,0)
+ ft.pu()
+
+ size = 6
+ ft.setpos(-33*size, -32*size)
+ ft.pd()
+
+ ta=clock()
+ ft.fillcolor("red")
+ ft.begin_fill()
+ ft.fd(size)
+
+ ft.hilbert(size, 6, 1)
+
+ # frame
+ ft.fd(size)
+ for i in range(3):
+ ft.lt(90)
+ ft.fd(size*(64+i%2))
+ ft.pu()
+ for i in range(2):
+ ft.fd(size)
+ ft.rt(90)
+ ft.pd()
+ for i in range(4):
+ ft.fd(size*(66+i%2))
+ ft.rt(90)
+ ft.end_fill()
+ tb=clock()
+ res = "Hilbert: %.2fsec. " % (tb-ta)
+
+ sleep(3)
+
+ ft.reset()
+ ft.speed(0)
+ ft.ht()
+ ft.getscreen().tracer(1,0)
+
+ ta=clock()
+ ft.color("black", "blue")
+ ft.begin_fill()
+ ft.fractalgon(3, 250, 4, 1)
+ ft.end_fill()
+ ft.begin_fill()
+ ft.color("red")
+ ft.fractalgon(3, 200, 4, -1)
+ ft.end_fill()
+ tb=clock()
+ res += "Koch: %.2fsec." % (tb-ta)
+ return res
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/lindenmayer.py b/Lib/turtledemo/lindenmayer.py
new file mode 100644
index 00000000000..3925f25da61
--- /dev/null
+++ b/Lib/turtledemo/lindenmayer.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ xtx_lindenmayer_indian.py
+
+Each morning women in Tamil Nadu, in southern
+India, place designs, created by using rice
+flour and known as kolam on the thresholds of
+their homes.
+
+These can be described by Lindenmayer systems,
+which can easily be implemented with turtle
+graphics and Python.
+
+Two examples are shown here:
+(1) the snake kolam
+(2) anklets of Krishna
+
+Taken from Marcia Ascher: Mathematics
+Elsewhere, An Exploration of Ideas Across
+Cultures
+
+"""
+################################
+# Mini Lindenmayer tool
+###############################
+
+from turtle import *
+
+def replace( seq, replacementRules, n ):
+ for i in range(n):
+ newseq = ""
+ for element in seq:
+ newseq = newseq + replacementRules.get(element,element)
+ seq = newseq
+ return seq
+
+def draw( commands, rules ):
+ for b in commands:
+ try:
+ rules[b]()
+ except TypeError:
+ try:
+ draw(rules[b], rules)
+ except:
+ pass
+
+
+def main():
+ ################################
+ # Example 1: Snake kolam
+ ################################
+
+
+ def r():
+ right(45)
+
+ def l():
+ left(45)
+
+ def f():
+ forward(7.5)
+
+ snake_rules = {"-":r, "+":l, "f":f, "b":"f+f+f--f--f+f+f"}
+ snake_replacementRules = {"b": "b+f+b--f--b+f+b"}
+ snake_start = "b--f--b--f"
+
+ drawing = replace(snake_start, snake_replacementRules, 3)
+
+ reset()
+ speed(3)
+ tracer(1,0)
+ ht()
+ up()
+ backward(195)
+ down()
+ draw(drawing, snake_rules)
+
+ from time import sleep
+ sleep(3)
+
+ ################################
+ # Example 2: Anklets of Krishna
+ ################################
+
+ def A():
+ color("red")
+ circle(10,90)
+
+ def B():
+ from math import sqrt
+ color("black")
+ l = 5/sqrt(2)
+ forward(l)
+ circle(l, 270)
+ forward(l)
+
+ def F():
+ color("green")
+ forward(10)
+
+ krishna_rules = {"a":A, "b":B, "f":F}
+ krishna_replacementRules = {"a" : "afbfa", "b" : "afbfbfbfa" }
+ krishna_start = "fbfbfbfb"
+
+ reset()
+ speed(0)
+ tracer(3,0)
+ ht()
+ left(45)
+ drawing = replace(krishna_start, krishna_replacementRules, 3)
+ draw(drawing, krishna_rules)
+ tracer(1)
+ return "Done!"
+
+if __name__=='__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/minimal_hanoi.py b/Lib/turtledemo/minimal_hanoi.py
new file mode 100644
index 00000000000..cfb78dcac14
--- /dev/null
+++ b/Lib/turtledemo/minimal_hanoi.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_minimal_hanoi.py
+
+A minimal 'Towers of Hanoi' animation:
+A tower of 6 discs is transferred from the
+left to the right peg.
+
+An imho quite elegant and concise
+implementation using a tower class, which
+is derived from the built-in type list.
+
+Discs are turtles with shape "square", but
+stretched to rectangles by shapesize()
+ ---------------------------------------
+ To exit press STOP button
+ ---------------------------------------
+"""
+from turtle import *
+
+class Disc(Turtle):
+ def __init__(self, n):
+ Turtle.__init__(self, shape="square", visible=False)
+ self.pu()
+ self.shapesize(1.5, n*1.5, 2) # square-->rectangle
+ self.fillcolor(n/6., 0, 1-n/6.)
+ self.st()
+
+class Tower(list):
+ "Hanoi tower, a subclass of built-in type list"
+ def __init__(self, x):
+ "create an empty tower. x is x-position of peg"
+ self.x = x
+ def push(self, d):
+ d.setx(self.x)
+ d.sety(-150+34*len(self))
+ self.append(d)
+ def pop(self):
+ d = list.pop(self)
+ d.sety(150)
+ return d
+
+def hanoi(n, from_, with_, to_):
+ if n > 0:
+ hanoi(n-1, from_, to_, with_)
+ to_.push(from_.pop())
+ hanoi(n-1, with_, from_, to_)
+
+def play():
+ onkey(None,"space")
+ clear()
+ hanoi(6, t1, t2, t3)
+ write("press STOP button to exit",
+ align="center", font=("Courier", 16, "bold"))
+
+def main():
+ global t1, t2, t3
+ ht(); penup(); goto(0, -225) # writer turtle
+ t1 = Tower(-250)
+ t2 = Tower(0)
+ t3 = Tower(250)
+ # make tower of 6 discs
+ for i in range(6,0,-1):
+ t1.push(Disc(i))
+ # prepare spartanic user interface ;-)
+ write("press spacebar to start game",
+ align="center", font=("Courier", 16, "bold"))
+ onkey(play, "space")
+ listen()
+ return "EVENTLOOP"
+
+if __name__=="__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/nim.py b/Lib/turtledemo/nim.py
new file mode 100644
index 00000000000..792ba515348
--- /dev/null
+++ b/Lib/turtledemo/nim.py
@@ -0,0 +1,226 @@
+""" turtle-example-suite:
+
+ tdemo_nim.py
+
+Play nim against the computer. The player
+who takes the last stick is the winner.
+
+Implements the model-view-controller
+design pattern.
+"""
+
+
+import turtle
+import random
+import time
+
+SCREENWIDTH = 640
+SCREENHEIGHT = 480
+
+MINSTICKS = 7
+MAXSTICKS = 31
+
+HUNIT = SCREENHEIGHT // 12
+WUNIT = SCREENWIDTH // ((MAXSTICKS // 5) * 11 + (MAXSTICKS % 5) * 2)
+
+SCOLOR = (63, 63, 31)
+HCOLOR = (255, 204, 204)
+COLOR = (204, 204, 255)
+
+def randomrow():
+ return random.randint(MINSTICKS, MAXSTICKS)
+
+def computerzug(state):
+ xored = state[0] ^ state[1] ^ state[2]
+ if xored == 0:
+ return randommove(state)
+ for z in range(3):
+ s = state[z] ^ xored
+ if s <= state[z]:
+ move = (z, s)
+ return move
+
+def randommove(state):
+ m = max(state)
+ while True:
+ z = random.randint(0,2)
+ if state[z] > (m > 1):
+ break
+ rand = random.randint(m > 1, state[z]-1)
+ return z, rand
+
+
+class NimModel(object):
+ def __init__(self, game):
+ self.game = game
+
+ def setup(self):
+ if self.game.state not in [Nim.CREATED, Nim.OVER]:
+ return
+ self.sticks = [randomrow(), randomrow(), randomrow()]
+ self.player = 0
+ self.winner = None
+ self.game.view.setup()
+ self.game.state = Nim.RUNNING
+
+ def move(self, row, col):
+ maxspalte = self.sticks[row]
+ self.sticks[row] = col
+ self.game.view.notify_move(row, col, maxspalte, self.player)
+ if self.game_over():
+ self.game.state = Nim.OVER
+ self.winner = self.player
+ self.game.view.notify_over()
+ elif self.player == 0:
+ self.player = 1
+ row, col = computerzug(self.sticks)
+ self.move(row, col)
+ self.player = 0
+
+ def game_over(self):
+ return self.sticks == [0, 0, 0]
+
+ def notify_move(self, row, col):
+ if self.sticks[row] <= col:
+ return
+ self.move(row, col)
+
+
+class Stick(turtle.Turtle):
+ def __init__(self, row, col, game):
+ turtle.Turtle.__init__(self, visible=False)
+ self.row = row
+ self.col = col
+ self.game = game
+ x, y = self.coords(row, col)
+ self.shape("square")
+ self.shapesize(HUNIT/10.0, WUNIT/20.0)
+ self.speed(0)
+ self.pu()
+ self.goto(x,y)
+ self.color("white")
+ self.showturtle()
+
+ def coords(self, row, col):
+ packet, remainder = divmod(col, 5)
+ x = (3 + 11 * packet + 2 * remainder) * WUNIT
+ y = (2 + 3 * row) * HUNIT
+ return x - SCREENWIDTH // 2 + WUNIT // 2, SCREENHEIGHT // 2 - y - HUNIT // 2
+
+ def makemove(self, x, y):
+ if self.game.state != Nim.RUNNING:
+ return
+ self.game.controller.notify_move(self.row, self.col)
+
+
+class NimView(object):
+ def __init__(self, game):
+ self.game = game
+ self.screen = game.screen
+ self.model = game.model
+ self.screen.colormode(255)
+ self.screen.tracer(False)
+ self.screen.bgcolor((240, 240, 255))
+ self.writer = turtle.Turtle(visible=False)
+ self.writer.pu()
+ self.writer.speed(0)
+ self.sticks = {}
+ for row in range(3):
+ for col in range(MAXSTICKS):
+ self.sticks[(row, col)] = Stick(row, col, game)
+ self.display("... a moment please ...")
+ self.screen.tracer(True)
+
+ def display(self, msg1, msg2=None):
+ self.screen.tracer(False)
+ self.writer.clear()
+ if msg2 is not None:
+ self.writer.goto(0, - SCREENHEIGHT // 2 + 48)
+ self.writer.pencolor("red")
+ self.writer.write(msg2, align="center", font=("Courier",18,"bold"))
+ self.writer.goto(0, - SCREENHEIGHT // 2 + 20)
+ self.writer.pencolor("black")
+ self.writer.write(msg1, align="center", font=("Courier",14,"bold"))
+ self.screen.tracer(True)
+
+
+ def setup(self):
+ self.screen.tracer(False)
+ for row in range(3):
+ for col in range(self.model.sticks[row]):
+ self.sticks[(row, col)].color(SCOLOR)
+ for row in range(3):
+ for col in range(self.model.sticks[row], MAXSTICKS):
+ self.sticks[(row, col)].color("white")
+ self.display("Your turn! Click leftmost stick to remove.")
+ self.screen.tracer(True)
+
+ def notify_move(self, row, col, maxspalte, player):
+ if player == 0:
+ farbe = HCOLOR
+ for s in range(col, maxspalte):
+ self.sticks[(row, s)].color(farbe)
+ else:
+ self.display(" ... thinking ... ")
+ time.sleep(0.5)
+ self.display(" ... thinking ... aaah ...")
+ farbe = COLOR
+ for s in range(maxspalte-1, col-1, -1):
+ time.sleep(0.2)
+ self.sticks[(row, s)].color(farbe)
+ self.display("Your turn! Click leftmost stick to remove.")
+
+ def notify_over(self):
+ if self.game.model.winner == 0:
+ msg2 = "Congrats. You're the winner!!!"
+ else:
+ msg2 = "Sorry, the computer is the winner."
+ self.display("To play again press space bar. To leave press ESC.", msg2)
+
+ def clear(self):
+ if self.game.state == Nim.OVER:
+ self.screen.clear()
+
+class NimController(object):
+
+ def __init__(self, game):
+ self.game = game
+ self.sticks = game.view.sticks
+ self.BUSY = False
+ for stick in self.sticks.values():
+ stick.onclick(stick.makemove)
+ self.game.screen.onkey(self.game.model.setup, "space")
+ self.game.screen.onkey(self.game.view.clear, "Escape")
+ self.game.view.display("Press space bar to start game")
+ self.game.screen.listen()
+
+ def notify_move(self, row, col):
+ if self.BUSY:
+ return
+ self.BUSY = True
+ self.game.model.notify_move(row, col)
+ self.BUSY = False
+
+class Nim(object):
+ CREATED = 0
+ RUNNING = 1
+ OVER = 2
+ def __init__(self, screen):
+ self.state = Nim.CREATED
+ self.screen = screen
+ self.model = NimModel(self)
+ self.view = NimView(self)
+ self.controller = NimController(self)
+
+
+mainscreen = turtle.Screen()
+mainscreen.mode("standard")
+mainscreen.setup(SCREENWIDTH, SCREENHEIGHT)
+
+def main():
+ nim = Nim(mainscreen)
+ return "EVENTLOOP!"
+
+if __name__ == "__main__":
+ main()
+ turtle.mainloop()
diff --git a/Lib/turtledemo/paint.py b/Lib/turtledemo/paint.py
new file mode 100644
index 00000000000..68058ab6ac8
--- /dev/null
+++ b/Lib/turtledemo/paint.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_paint.py
+
+A simple eventdriven paint program
+
+- use left mouse button to move turtle
+- middle mouse button to change color
+- right mouse button do turn filling on/off
+ -------------------------------------------
+ Play around by clicking into the canvas
+ using all three mouse buttons.
+ -------------------------------------------
+ To exit press STOP button
+ -------------------------------------------
+"""
+from turtle import *
+
+def switchupdown(x=0, y=0):
+ if pen()["pendown"]:
+ end_fill()
+ up()
+ else:
+ down()
+ begin_fill()
+
+def changecolor(x=0, y=0):
+ global colors
+ colors = colors[1:]+colors[:1]
+ color(colors[0])
+
+def main():
+ global colors
+ shape("circle")
+ resizemode("user")
+ shapesize(.5)
+ width(3)
+ colors=["red", "green", "blue", "yellow"]
+ color(colors[0])
+ switchupdown()
+ onscreenclick(goto,1)
+ onscreenclick(changecolor,2)
+ onscreenclick(switchupdown,3)
+ return "EVENTLOOP"
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/peace.py b/Lib/turtledemo/peace.py
new file mode 100644
index 00000000000..63cf7cc2e1b
--- /dev/null
+++ b/Lib/turtledemo/peace.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_peace.py
+
+A very simple drawing suitable as a beginner's
+programming example.
+
+Uses only commands, which are also available in
+old turtle.py.
+
+Intentionally no variables are used except for the
+colorloop:
+"""
+
+from turtle import *
+
+def main():
+ peacecolors = ("red3", "orange", "yellow",
+ "seagreen4", "orchid4",
+ "royalblue1", "dodgerblue4")
+
+ reset()
+ s = Screen()
+ up()
+ goto(-320,-195)
+ width(70)
+
+ for pcolor in peacecolors:
+ color(pcolor)
+ down()
+ forward(640)
+ up()
+ backward(640)
+ left(90)
+ forward(66)
+ right(90)
+
+ width(25)
+ color("white")
+ goto(0,-170)
+ down()
+
+ circle(170)
+ left(90)
+ forward(340)
+ up()
+ left(180)
+ forward(170)
+ right(45)
+ down()
+ forward(170)
+ up()
+ backward(170)
+ left(90)
+ down()
+ forward(170)
+ up()
+
+ goto(0,300) # vanish if hideturtle() is not available ;-)
+ return "Done!!"
+
+if __name__ == "__main__":
+ main()
+ mainloop()
diff --git a/Lib/turtledemo/penrose.py b/Lib/turtledemo/penrose.py
new file mode 100644
index 00000000000..f73c864b7b4
--- /dev/null
+++ b/Lib/turtledemo/penrose.py
@@ -0,0 +1,181 @@
+#!/usr/bin/env python3
+""" xturtle-example-suite:
+
+ xtx_kites_and_darts.py
+
+Constructs two aperiodic penrose-tilings,
+consisting of kites and darts, by the method
+of inflation in six steps.
+
+Starting points are the patterns "sun"
+consisting of five kites and "star"
+consisting of five darts.
+
+For more information see:
+ http://en.wikipedia.org/wiki/Penrose_tiling
+ -------------------------------------------
+"""
+from turtle import *
+from math import cos, pi
+from time import clock, sleep
+
+f = (5**0.5-1)/2.0 # (sqrt(5)-1)/2 -- golden ratio
+d = 2 * cos(3*pi/10)
+
+def kite(l):
+ fl = f * l
+ lt(36)
+ fd(l)
+ rt(108)
+ fd(fl)
+ rt(36)
+ fd(fl)
+ rt(108)
+ fd(l)
+ rt(144)
+
+def dart(l):
+ fl = f * l
+ lt(36)
+ fd(l)
+ rt(144)
+ fd(fl)
+ lt(36)
+ fd(fl)
+ rt(144)
+ fd(l)
+ rt(144)
+
+def inflatekite(l, n):
+ if n == 0:
+ px, py = pos()
+ h, x, y = int(heading()), round(px,3), round(py,3)
+ tiledict[(h,x,y)] = True
+ return
+ fl = f * l
+ lt(36)
+ inflatedart(fl, n-1)
+ fd(l)
+ rt(144)
+ inflatekite(fl, n-1)
+ lt(18)
+ fd(l*d)
+ rt(162)
+ inflatekite(fl, n-1)
+ lt(36)
+ fd(l)
+ rt(180)
+ inflatedart(fl, n-1)
+ lt(36)
+
+def inflatedart(l, n):
+ if n == 0:
+ px, py = pos()
+ h, x, y = int(heading()), round(px,3), round(py,3)
+ tiledict[(h,x,y)] = False
+ return
+ fl = f * l
+ inflatekite(fl, n-1)
+ lt(36)
+ fd(l)
+ rt(180)
+ inflatedart(fl, n-1)
+ lt(54)
+ fd(l*d)
+ rt(126)
+ inflatedart(fl, n-1)
+ fd(l)
+ rt(144)
+
+def draw(l, n, th=2):
+ clear()
+ l = l * f**n
+ shapesize(l/100.0, l/100.0, th)
+ for k in tiledict:
+ h, x, y = k
+ setpos(x, y)
+ setheading(h)
+ if tiledict[k]:
+ shape("kite")
+ color("black", (0, 0.75, 0))
+ else:
+ shape("dart")
+ color("black", (0.75, 0, 0))
+ stamp()
+
+def sun(l, n):
+ for i in range(5):
+ inflatekite(l, n)
+ lt(72)
+
+def star(l,n):
+ for i in range(5):
+ inflatedart(l, n)
+ lt(72)
+
+def makeshapes():
+ tracer(0)
+ begin_poly()
+ kite(100)
+ end_poly()
+ register_shape("kite", get_poly())
+ begin_poly()
+ dart(100)
+ end_poly()
+ register_shape("dart", get_poly())
+ tracer(1)
+
+def start():
+ reset()
+ ht()
+ pu()
+ makeshapes()
+ resizemode("user")
+
+def test(l=200, n=4, fun=sun, startpos=(0,0), th=2):
+ global tiledict
+ goto(startpos)
+ setheading(0)
+ tiledict = {}
+ a = clock()
+ tracer(0)
+ fun(l, n)
+ b = clock()
+ draw(l, n, th)
+ tracer(1)
+ c = clock()
+ print("Calculation: %7.4f s" % (b - a))
+ print("Drawing: %7.4f s" % (c - b))
+ print("Together: %7.4f s" % (c - a))
+ nk = len([x for x in tiledict if tiledict[x]])
+ nd = len([x for x in tiledict if not tiledict[x]])
+ print("%d kites and %d darts = %d pieces." % (nk, nd, nk+nd))
+
+def demo(fun=sun):
+ start()
+ for i in range(8):
+ a = clock()
+ test(300, i, fun)
+ b = clock()
+ t = b - a
+ if t < 2:
+ sleep(2 - t)
+
+def main():
+ #title("Penrose-tiling with kites and darts.")
+ mode("logo")
+ bgcolor(0.3, 0.3, 0)
+ demo(sun)
+ sleep(2)
+ demo(star)
+ pencolor("black")
+ goto(0,-200)
+ pencolor(0.7,0.7,1)
+ write("Please wait...",
+ align="center", font=('Arial Black', 36, 'bold'))
+ test(600, 8, startpos=(70, 117))
+ return "Done"
+
+if __name__ == "__main__":
+ msg = main()
+ mainloop()
diff --git a/Lib/turtledemo/planet_and_moon.py b/Lib/turtledemo/planet_and_moon.py
new file mode 100644
index 00000000000..14c4bbccc41
--- /dev/null
+++ b/Lib/turtledemo/planet_and_moon.py
@@ -0,0 +1,113 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_planets_and_moon.py
+
+Gravitational system simulation using the
+approximation method from Feynman-lectures,
+p.9-8, using turtlegraphics.
+
+Example: heavy central body, light planet,
+very light moon!
+Planet has a circular orbit, moon a stable
+orbit around the planet.
+
+You can hold the movement temporarily by pressing
+the left mouse button with mouse over the
+scrollbar of the canvas.
+
+"""
+from turtle import Shape, Turtle, mainloop, Vec2D as Vec
+from time import sleep
+
+G = 8
+
+class GravSys(object):
+ def __init__(self):
+ self.planets = []
+ self.t = 0
+ self.dt = 0.01
+ def init(self):
+ for p in self.planets:
+ p.init()
+ def start(self):
+ for i in range(10000):
+ self.t += self.dt
+ for p in self.planets:
+ p.step()
+
+class Star(Turtle):
+ def __init__(self, m, x, v, gravSys, shape):
+ Turtle.__init__(self, shape=shape)
+ self.penup()
+ self.m = m
+ self.setpos(x)
+ self.v = v
+ gravSys.planets.append(self)
+ self.gravSys = gravSys
+ self.resizemode("user")
+ self.pendown()
+ def init(self):
+ dt = self.gravSys.dt
+ self.a = self.acc()
+ self.v = self.v + 0.5*dt*self.a
+ def acc(self):
+ a = Vec(0,0)
+ for planet in self.gravSys.planets:
+ if planet != self:
+ v = planet.pos()-self.pos()
+ a += (G*planet.m/abs(v)**3)*v
+ return a
+ def step(self):
+ dt = self.gravSys.dt
+ self.setpos(self.pos() + dt*self.v)
+ if self.gravSys.planets.index(self) != 0:
+ self.setheading(self.towards(self.gravSys.planets[0]))
+ self.a = self.acc()
+ self.v = self.v + dt*self.a
+
+## create compound yellow/blue turtleshape for planets
+
+def main():
+ s = Turtle()
+ s.reset()
+ s.getscreen().tracer(0,0)
+ s.ht()
+ s.pu()
+ s.fd(6)
+ s.lt(90)
+ s.begin_poly()
+ s.circle(6, 180)
+ s.end_poly()
+ m1 = s.get_poly()
+ s.begin_poly()
+ s.circle(6,180)
+ s.end_poly()
+ m2 = s.get_poly()
+
+ planetshape = Shape("compound")
+ planetshape.addcomponent(m1,"orange")
+ planetshape.addcomponent(m2,"blue")
+ s.getscreen().register_shape("planet", planetshape)
+ s.getscreen().tracer(1,0)
+
+ ## setup gravitational system
+ gs = GravSys()
+ sun = Star(1000000, Vec(0,0), Vec(0,-2.5), gs, "circle")
+ sun.color("yellow")
+ sun.shapesize(1.8)
+ sun.pu()
+ earth = Star(12500, Vec(210,0), Vec(0,195), gs, "planet")
+ earth.pencolor("green")
+ earth.shapesize(0.8)
+ moon = Star(1, Vec(220,0), Vec(0,295), gs, "planet")
+ moon.pencolor("blue")
+ moon.shapesize(0.5)
+ gs.init()
+ gs.start()
+ return "Done!"
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ #mainloop()
diff --git a/Lib/turtledemo/round_dance.py b/Lib/turtledemo/round_dance.py
new file mode 100644
index 00000000000..10383614c6e
--- /dev/null
+++ b/Lib/turtledemo/round_dance.py
@@ -0,0 +1,86 @@
+""" turtle-example-suite:
+
+ tdemo_round_dance.py
+
+(Needs version 1.1 of the turtle module that
+comes with Python 3.1)
+
+Dancing turtles have a compound shape
+consisting of a series of triangles of
+decreasing size.
+
+Turtles march along a circle while rotating
+pairwise in opposite direction, with one
+exception. Does that breaking of symmetry
+enhance the attractiveness of the example?
+
+Press any key to stop the animation.
+
+Technically: demonstrates use of compound
+shapes, transformation of shapes as well as
+cloning turtles. The animation is
+controlled through update().
+"""
+
+from turtle import *
+
+def stop():
+ global running
+ running = False
+
+def main():
+ global running
+ clearscreen()
+ bgcolor("gray10")
+ tracer(False)
+ shape("triangle")
+ f = 0.793402
+ phi = 9.064678
+ s = 5
+ c = 1
+ # create compound shape
+ sh = Shape("compound")
+ for i in range(10):
+ shapesize(s)
+ p =get_shapepoly()
+ s *= f
+ c *= f
+ tilt(-phi)
+ sh.addcomponent(p, (c, 0.25, 1-c), "black")
+ register_shape("multitri", sh)
+ # create dancers
+ shapesize(1)
+ shape("multitri")
+ pu()
+ setpos(0, -200)
+ dancers = []
+ for i in range(180):
+ fd(7)
+ tilt(-4)
+ lt(2)
+ update()
+ if i % 12 == 0:
+ dancers.append(clone())
+ home()
+ # dance
+ running = True
+ onkeypress(stop)
+ listen()
+ cs = 1
+ while running:
+ ta = -4
+ for dancer in dancers:
+ dancer.fd(7)
+ dancer.lt(2)
+ dancer.tilt(ta)
+ ta = -4 if ta > 0 else 2
+ if cs < 180:
+ right(4)
+ shapesize(cs)
+ cs *= 1.005
+ update()
+ return "DONE!"
+
+if __name__=='__main__':
+ print(main())
+ mainloop()
diff --git a/Lib/turtledemo/tree.py b/Lib/turtledemo/tree.py
new file mode 100644
index 00000000000..9c0b1f7bb43
--- /dev/null
+++ b/Lib/turtledemo/tree.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_tree.py
+
+Displays a 'breadth-first-tree' - in contrast
+to the classical Logo tree drawing programs,
+which use a depth-first-algorithm.
+
+Uses:
+(1) a tree-generator, where the drawing is
+quasi the side-effect, whereas the generator
+always yields None.
+(2) Turtle-cloning: At each branching point the
+current pen is cloned. So in the end there
+are 1024 turtles.
+"""
+from turtle import Turtle, mainloop
+from time import clock
+
+def tree(plist, l, a, f):
+ """ plist is list of pens
+ l is length of branch
+ a is half of the angle between 2 branches
+ f is factor by which branch is shortened
+ from level to level."""
+ if l > 3:
+ lst = []
+ for p in plist:
+ p.forward(l)
+ q = p.clone()
+ p.left(a)
+ q.right(a)
+ lst.append(p)
+ lst.append(q)
+ for x in tree(lst, l*f, a, f):
+ yield None
+
+def maketree():
+ p = Turtle()
+ p.setundobuffer(None)
+ p.hideturtle()
+ p.speed(0)
+ p.getscreen().tracer(30,0)
+ p.left(90)
+ p.penup()
+ p.forward(-210)
+ p.pendown()
+ t = tree([p], 200, 65, 0.6375)
+ for x in t:
+ pass
+ print(len(p.getscreen().turtles()))
+
+def main():
+ a=clock()
+ maketree()
+ b=clock()
+ return "done: %.2f sec." % (b-a)
+
+if __name__ == "__main__":
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/turtle.cfg b/Lib/turtledemo/turtle.cfg
new file mode 100644
index 00000000000..bd89a741f92
--- /dev/null
+++ b/Lib/turtledemo/turtle.cfg
@@ -0,0 +1,10 @@
+width = 800
+height = 600
+canvwidth = 1200
+canvheight = 900
+shape = arrow
+mode = standard
+resizemode = auto
+fillcolor = ""
+title = Python turtle graphics demo.
+
diff --git a/Lib/turtledemo/two_canvases.py b/Lib/turtledemo/two_canvases.py
new file mode 100644
index 00000000000..02d89db57e7
--- /dev/null
+++ b/Lib/turtledemo/two_canvases.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+## DEMONSTRATES USE OF 2 CANVASES, SO CANNOT BE RUN IN DEMOVIEWER!
+"""turtle example: Using TurtleScreen and RawTurtle
+for drawing on two distinct canvases.
+"""
+from turtle import TurtleScreen, RawTurtle, TK
+
+root = TK.Tk()
+cv1 = TK.Canvas(root, width=300, height=200, bg="#ddffff")
+cv2 = TK.Canvas(root, width=300, height=200, bg="#ffeeee")
+cv1.pack()
+cv2.pack()
+
+s1 = TurtleScreen(cv1)
+s1.bgcolor(0.85, 0.85, 1)
+s2 = TurtleScreen(cv2)
+s2.bgcolor(1, 0.85, 0.85)
+
+p = RawTurtle(s1)
+q = RawTurtle(s2)
+
+p.color("red", (1, 0.85, 0.85))
+p.width(3)
+q.color("blue", (0.85, 0.85, 1))
+q.width(3)
+
+for t in p,q:
+ t.shape("turtle")
+ t.lt(36)
+
+q.lt(180)
+
+for t in p, q:
+ t.begin_fill()
+for i in range(5):
+ for t in p, q:
+ t.fd(50)
+ t.lt(72)
+for t in p,q:
+ t.end_fill()
+ t.lt(54)
+ t.pu()
+ t.bk(50)
+
+## Want to get some info?
+
+#print(s1, s2)
+#print(p, q)
+#print(s1.turtles())
+#print(s2.turtles())
+
+TK.mainloop()
diff --git a/Lib/turtledemo/wikipedia.py b/Lib/turtledemo/wikipedia.py
new file mode 100644
index 00000000000..0f274420c8f
--- /dev/null
+++ b/Lib/turtledemo/wikipedia.py
@@ -0,0 +1,65 @@
+""" turtle-example-suite:
+
+ tdemo_wikipedia3.py
+
+This example is
+inspired by the Wikipedia article on turtle
+graphics. (See example wikipedia1 for URLs)
+
+First we create (ne-1) (i.e. 35 in this
+example) copies of our first turtle p.
+Then we let them perform their steps in
+parallel.
+
+Followed by a complete undo().
+"""
+from turtle import Screen, Turtle, mainloop
+from time import clock, sleep
+
+def mn_eck(p, ne,sz):
+ turtlelist = [p]
+ #create ne-1 additional turtles
+ for i in range(1,ne):
+ q = p.clone()
+ q.rt(360.0/ne)
+ turtlelist.append(q)
+ p = q
+ for i in range(ne):
+ c = abs(ne/2.0-i)/(ne*.7)
+ # let those ne turtles make a step
+ # in parallel:
+ for t in turtlelist:
+ t.rt(360./ne)
+ t.pencolor(1-c,0,c)
+ t.fd(sz)
+
+def main():
+ s = Screen()
+ s.bgcolor("black")
+ p=Turtle()
+ p.speed(0)
+ p.hideturtle()
+ p.pencolor("red")
+ p.pensize(3)
+
+ s.tracer(36,0)
+
+ at = clock()
+ mn_eck(p, 36, 19)
+ et = clock()
+ z1 = et-at
+
+ sleep(1)
+
+ at = clock()
+ while any([t.undobufferentries() for t in s.turtles()]):
+ for t in s.turtles():
+ t.undo()
+ et = clock()
+ return "runtime: %.3f sec" % (z1+et-at)
+
+
+if __name__ == '__main__':
+ msg = main()
+ print(msg)
+ mainloop()
diff --git a/Lib/turtledemo/yinyang.py b/Lib/turtledemo/yinyang.py
new file mode 100644
index 00000000000..11d1f47cae2
--- /dev/null
+++ b/Lib/turtledemo/yinyang.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+""" turtle-example-suite:
+
+ tdemo_yinyang.py
+
+Another drawing suitable as a beginner's
+programming example.
+
+The small circles are drawn by the circle
+command.
+
+"""
+
+from turtle import *
+
+def yin(radius, color1, color2):
+ width(3)
+ color("black", color1)
+ begin_fill()
+ circle(radius/2., 180)
+ circle(radius, 180)
+ left(180)
+ circle(-radius/2., 180)
+ end_fill()
+ left(90)
+ up()
+ forward(radius*0.35)
+ right(90)
+ down()
+ color(color1, color2)
+ begin_fill()
+ circle(radius*0.15)
+ end_fill()
+ left(90)
+ up()
+ backward(radius*0.35)
+ down()
+ left(90)
+
+def main():
+ reset()
+ yin(200, "black", "white")
+ yin(200, "white", "black")
+ ht()
+ return "Done!"
+
+if __name__ == '__main__':
+ main()
+ mainloop()
diff --git a/Lib/types.py b/Lib/types.py
index ff90e049730..ab354d1a715 100644
--- a/Lib/types.py
+++ b/Lib/types.py
@@ -1,48 +1,17 @@
-"""Define names for all type symbols known in the standard interpreter.
-
-Types that are part of optional modules (e.g. array) are not listed.
+"""
+Define names for built-in types that aren't directly accessible as a builtin.
"""
import sys
# Iterators in Python aren't a matter of type but of protocol. A large
# and changing number of builtin types implement *some* flavor of
# iterator. Don't check the type! Use hasattr to check for both
-# "__iter__" and "next" attributes instead.
-
-NoneType = type(None)
-TypeType = type
-ObjectType = object
-
-IntType = int
-LongType = long
-FloatType = float
-BooleanType = bool
-try:
- ComplexType = complex
-except NameError:
- pass
-
-StringType = str
-
-# StringTypes is already outdated. Instead of writing "type(x) in
-# types.StringTypes", you should use "isinstance(x, basestring)". But
-# we keep around for compatibility with Python 2.2.
-try:
- UnicodeType = unicode
- StringTypes = (StringType, UnicodeType)
-except NameError:
- StringTypes = (StringType,)
-
-BufferType = buffer
-
-TupleType = tuple
-ListType = list
-DictType = DictionaryType = dict
+# "__iter__" and "__next__" attributes instead.
def _f(): pass
FunctionType = type(_f)
LambdaType = type(lambda: None) # Same as FunctionType
-CodeType = type(_f.func_code)
+CodeType = type(_f.__code__)
def _g():
yield 1
@@ -50,18 +19,12 @@ GeneratorType = type(_g())
class _C:
def _m(self): pass
-ClassType = type(_C)
-UnboundMethodType = type(_C._m) # Same as MethodType
-_x = _C()
-InstanceType = type(_x)
-MethodType = type(_x._m)
+MethodType = type(_C()._m)
BuiltinFunctionType = type(len)
BuiltinMethodType = type([].append) # Same as BuiltinFunctionType
ModuleType = type(sys)
-FileType = file
-XRangeType = xrange
try:
raise TypeError
@@ -69,16 +32,10 @@ except TypeError:
tb = sys.exc_info()[2]
TracebackType = type(tb)
FrameType = type(tb.tb_frame)
- del tb
-
-SliceType = slice
-EllipsisType = type(Ellipsis)
-
-DictProxyType = type(TypeType.__dict__)
-NotImplementedType = type(NotImplemented)
+ tb = None; del tb
# For Jython, the following two types are identical
-GetSetDescriptorType = type(FunctionType.func_code)
-MemberDescriptorType = type(FunctionType.func_globals)
+GetSetDescriptorType = type(FunctionType.__code__)
+MemberDescriptorType = type(FunctionType.__globals__)
-del sys, _f, _g, _C, _x # Not for export
+del sys, _f, _g, _C, # Not for export
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py
index 6257936618a..bea810711db 100644
--- a/Lib/unittest/case.py
+++ b/Lib/unittest/case.py
@@ -1,20 +1,17 @@
"""Test case implementation"""
-import collections
import sys
import functools
import difflib
import pprint
import re
-import types
import warnings
+import collections
from . import result
-from .util import (
- strclass, safe_repr, unorderable_list_difference,
- _count_diff_all_purpose, _count_diff_hashable
-)
-
+from .util import (strclass, safe_repr, sorted_list_difference,
+ unorderable_list_difference, _count_diff_all_purpose,
+ _count_diff_hashable)
__unittest = True
@@ -29,7 +26,6 @@ class SkipTest(Exception):
Usually you can use TestResult.skip() or one of the skipping decorators
instead of raising this directly.
"""
- pass
class _ExpectedFailure(Exception):
"""
@@ -46,7 +42,17 @@ class _UnexpectedSuccess(Exception):
"""
The test was supposed to fail, but it didn't!
"""
- pass
+
+
+class _Outcome(object):
+ def __init__(self):
+ self.success = True
+ self.skipped = None
+ self.unexpectedSuccess = None
+ self.expectedFailure = None
+ self.errors = []
+ self.failures = []
+
def _id(obj):
return obj
@@ -56,7 +62,7 @@ def skip(reason):
Unconditionally skip a test.
"""
def decorator(test_item):
- if not isinstance(test_item, (type, types.ClassType)):
+ if not isinstance(test_item, type):
@functools.wraps(test_item)
def skip_wrapper(*args, **kwargs):
raise SkipTest(reason)
@@ -95,13 +101,26 @@ def expectedFailure(func):
return wrapper
-class _AssertRaisesContext(object):
- """A context manager used to implement TestCase.assertRaises* methods."""
+class _AssertRaisesBaseContext(object):
- def __init__(self, expected, test_case, expected_regexp=None):
+ def __init__(self, expected, test_case, callable_obj=None,
+ expected_regex=None):
self.expected = expected
self.failureException = test_case.failureException
- self.expected_regexp = expected_regexp
+ if callable_obj is not None:
+ try:
+ self.obj_name = callable_obj.__name__
+ except AttributeError:
+ self.obj_name = str(callable_obj)
+ else:
+ self.obj_name = None
+ if isinstance(expected_regex, (bytes, str)):
+ expected_regex = re.compile(expected_regex)
+ self.expected_regex = expected_regex
+
+
+class _AssertRaisesContext(_AssertRaisesBaseContext):
+ """A context manager used to implement TestCase.assertRaises* methods."""
def __enter__(self):
return self
@@ -112,24 +131,77 @@ class _AssertRaisesContext(object):
exc_name = self.expected.__name__
except AttributeError:
exc_name = str(self.expected)
- raise self.failureException(
- "{0} not raised".format(exc_name))
+ if self.obj_name:
+ raise self.failureException("{0} not raised by {1}"
+ .format(exc_name, self.obj_name))
+ else:
+ raise self.failureException("{0} not raised"
+ .format(exc_name))
if not issubclass(exc_type, self.expected):
# let unexpected exceptions pass through
return False
- self.exception = exc_value # store for later retrieval
- if self.expected_regexp is None:
+ # store exception, without traceback, for later retrieval
+ self.exception = exc_value.with_traceback(None)
+ if self.expected_regex is None:
return True
- expected_regexp = self.expected_regexp
- if isinstance(expected_regexp, basestring):
- expected_regexp = re.compile(expected_regexp)
- if not expected_regexp.search(str(exc_value)):
+ expected_regex = self.expected_regex
+ if not expected_regex.search(str(exc_value)):
raise self.failureException('"%s" does not match "%s"' %
- (expected_regexp.pattern, str(exc_value)))
+ (expected_regex.pattern, str(exc_value)))
return True
+class _AssertWarnsContext(_AssertRaisesBaseContext):
+ """A context manager used to implement TestCase.assertWarns* methods."""
+
+ def __enter__(self):
+ # The __warningregistry__'s need to be in a pristine state for tests
+ # to work properly.
+ for v in sys.modules.values():
+ if getattr(v, '__warningregistry__', None):
+ v.__warningregistry__ = {}
+ self.warnings_manager = warnings.catch_warnings(record=True)
+ self.warnings = self.warnings_manager.__enter__()
+ warnings.simplefilter("always", self.expected)
+ return self
+
+ def __exit__(self, exc_type, exc_value, tb):
+ self.warnings_manager.__exit__(exc_type, exc_value, tb)
+ if exc_type is not None:
+ # let unexpected exceptions pass through
+ return
+ try:
+ exc_name = self.expected.__name__
+ except AttributeError:
+ exc_name = str(self.expected)
+ first_matching = None
+ for m in self.warnings:
+ w = m.message
+ if not isinstance(w, self.expected):
+ continue
+ if first_matching is None:
+ first_matching = w
+ if (self.expected_regex is not None and
+ not self.expected_regex.search(str(w))):
+ continue
+ # store warning for later retrieval
+ self.warning = w
+ self.filename = m.filename
+ self.lineno = m.lineno
+ return
+ # Now we simply try to choose a helpful failure message
+ if first_matching is not None:
+ raise self.failureException('"%s" does not match "%s"' %
+ (self.expected_regex.pattern, str(first_matching)))
+ if self.obj_name:
+ raise self.failureException("{0} not triggered by {1}"
+ .format(exc_name, self.obj_name))
+ else:
+ raise self.failureException("{0} not triggered"
+ .format(exc_name))
+
+
class TestCase(object):
"""A class whose instances are single test cases.
@@ -162,7 +234,7 @@ class TestCase(object):
# objects used in assert methods) will be printed on failure in *addition*
# to any explicit message passed.
- longMessage = False
+ longMessage = True
# This attribute sets the maximum length of a diff in failure messages
# by assert methods using difflib. It is looked up as an instance attribute
@@ -184,13 +256,18 @@ class TestCase(object):
not have a method with the specified name.
"""
self._testMethodName = methodName
- self._resultForDoCleanups = None
+ self._outcomeForDoCleanups = None
+ self._testMethodDoc = 'No test'
try:
testMethod = getattr(self, methodName)
except AttributeError:
- raise ValueError("no such test method in %s: %s" %
- (self.__class__, methodName))
- self._testMethodDoc = testMethod.__doc__
+ if methodName != 'runTest':
+ # we allow instantiation with no explicit method name
+ # but not an *incorrect* or missing method name
+ raise ValueError("no such test method in %s: %s" %
+ (self.__class__, methodName))
+ else:
+ self._testMethodDoc = testMethod.__doc__
self._cleanups = []
# Map types to custom assertEqual functions that will compare
@@ -202,11 +279,7 @@ class TestCase(object):
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
self.addTypeEqualityFunc(set, 'assertSetEqual')
self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
- try:
- self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
- except NameError:
- # No unicode support in this build
- pass
+ self.addTypeEqualityFunc(str, 'assertMultiLineEqual')
def addTypeEqualityFunc(self, typeobj, function):
"""Add a type specific assertEqual style function to compare a type.
@@ -273,9 +346,6 @@ class TestCase(object):
return self._testMethodName == other._testMethodName
- def __ne__(self, other):
- return not self == other
-
def __hash__(self):
return hash((type(self), self._testMethodName))
@@ -295,6 +365,36 @@ class TestCase(object):
RuntimeWarning, 2)
result.addSuccess(self)
+ def _executeTestPart(self, function, outcome, isTest=False):
+ try:
+ function()
+ except KeyboardInterrupt:
+ raise
+ except SkipTest as e:
+ outcome.success = False
+ outcome.skipped = str(e)
+ except _UnexpectedSuccess:
+ exc_info = sys.exc_info()
+ outcome.success = False
+ if isTest:
+ outcome.unexpectedSuccess = exc_info
+ else:
+ outcome.errors.append(exc_info)
+ except _ExpectedFailure:
+ outcome.success = False
+ exc_info = sys.exc_info()
+ if isTest:
+ outcome.expectedFailure = exc_info
+ else:
+ outcome.errors.append(exc_info)
+ except self.failureException:
+ outcome.success = False
+ outcome.failures.append(sys.exc_info())
+ exc_info = sys.exc_info()
+ except:
+ outcome.success = False
+ outcome.errors.append(sys.exc_info())
+
def run(self, result=None):
orig_result = result
if result is None:
@@ -303,7 +403,6 @@ class TestCase(object):
if startTestRun is not None:
startTestRun()
- self._resultForDoCleanups = result
result.startTest(self)
testMethod = getattr(self, self._testMethodName)
@@ -318,57 +417,42 @@ class TestCase(object):
result.stopTest(self)
return
try:
- success = False
- try:
- self.setUp()
- except SkipTest as e:
- self._addSkip(result, str(e))
- except KeyboardInterrupt:
- raise
- except:
- result.addError(self, sys.exc_info())
+ outcome = _Outcome()
+ self._outcomeForDoCleanups = outcome
+
+ self._executeTestPart(self.setUp, outcome)
+ if outcome.success:
+ self._executeTestPart(testMethod, outcome, isTest=True)
+ self._executeTestPart(self.tearDown, outcome)
+
+ self.doCleanups()
+ if outcome.success:
+ result.addSuccess(self)
else:
- try:
- testMethod()
- except KeyboardInterrupt:
- raise
- except self.failureException:
- result.addFailure(self, sys.exc_info())
- except _ExpectedFailure as e:
- addExpectedFailure = getattr(result, 'addExpectedFailure', None)
- if addExpectedFailure is not None:
- addExpectedFailure(self, e.exc_info)
- else:
- warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
- RuntimeWarning)
- result.addSuccess(self)
- except _UnexpectedSuccess:
+ if outcome.skipped is not None:
+ self._addSkip(result, outcome.skipped)
+ for exc_info in outcome.errors:
+ result.addError(self, exc_info)
+ for exc_info in outcome.failures:
+ result.addFailure(self, exc_info)
+ if outcome.unexpectedSuccess is not None:
addUnexpectedSuccess = getattr(result, 'addUnexpectedSuccess', None)
if addUnexpectedSuccess is not None:
addUnexpectedSuccess(self)
else:
warnings.warn("TestResult has no addUnexpectedSuccess method, reporting as failures",
RuntimeWarning)
- result.addFailure(self, sys.exc_info())
- except SkipTest as e:
- self._addSkip(result, str(e))
- except:
- result.addError(self, sys.exc_info())
- else:
- success = True
+ result.addFailure(self, outcome.unexpectedSuccess)
+
+ if outcome.expectedFailure is not None:
+ addExpectedFailure = getattr(result, 'addExpectedFailure', None)
+ if addExpectedFailure is not None:
+ addExpectedFailure(self, outcome.expectedFailure)
+ else:
+ warnings.warn("TestResult has no addExpectedFailure method, reporting as passes",
+ RuntimeWarning)
+ result.addSuccess(self)
- try:
- self.tearDown()
- except KeyboardInterrupt:
- raise
- except:
- result.addError(self, sys.exc_info())
- success = False
-
- cleanUpSuccess = self.doCleanups()
- success = success and cleanUpSuccess
- if success:
- result.addSuccess(self)
finally:
result.stopTest(self)
if orig_result is None:
@@ -379,18 +463,15 @@ class TestCase(object):
def doCleanups(self):
"""Execute all cleanup functions. Normally called for you after
tearDown."""
- result = self._resultForDoCleanups
- ok = True
+ outcome = self._outcomeForDoCleanups or _Outcome()
while self._cleanups:
- function, args, kwargs = self._cleanups.pop(-1)
- try:
- function(*args, **kwargs)
- except KeyboardInterrupt:
- raise
- except:
- ok = False
- result.addError(self, sys.exc_info())
- return ok
+ function, args, kwargs = self._cleanups.pop()
+ part = lambda: function(*args, **kwargs)
+ self._executeTestPart(part, outcome)
+
+ # return this for backwards compatibility
+ # even though we no longer us it internally
+ return outcome.success
def __call__(self, *args, **kwds):
return self.run(*args, **kwds)
@@ -469,12 +550,43 @@ class TestCase(object):
the_exception = cm.exception
self.assertEqual(the_exception.error_code, 3)
"""
- context = _AssertRaisesContext(excClass, self)
+ context = _AssertRaisesContext(excClass, self, callableObj)
if callableObj is None:
return context
with context:
callableObj(*args, **kwargs)
+ def assertWarns(self, expected_warning, callable_obj=None, *args, **kwargs):
+ """Fail unless a warning of class warnClass is triggered
+ by callableObj when invoked with arguments args and keyword
+ arguments kwargs. If a different type of warning is
+ triggered, it will not be handled: depending on the other
+ warning filtering rules in effect, it might be silenced, printed
+ out, or raised as an exception.
+
+ If called with callableObj omitted or None, will return a
+ context object used like this::
+
+ with self.assertWarns(SomeWarning):
+ do_something()
+
+ The context manager keeps a reference to the first matching
+ warning as the 'warning' attribute; similarly, the 'filename'
+ and 'lineno' attributes give you information about the line
+ of Python code from which the warning was triggered.
+ This allows you to inspect the warning after the assertion::
+
+ with self.assertWarns(SomeWarning) as cm:
+ do_something()
+ the_warning = cm.warning
+ self.assertEqual(the_warning.some_attribute, 147)
+ """
+ context = _AssertWarnsContext(expected_warning, self, callable_obj)
+ if callable_obj is None:
+ return context
+ with context:
+ callable_obj(*args, **kwargs)
+
def _getAssertEqualityFunc(self, first, second):
"""Get a detailed comparison function for the types of the two args.
@@ -495,7 +607,7 @@ class TestCase(object):
if type(first) is type(second):
asserter = self._type_equality_funcs.get(type(first))
if asserter is not None:
- if isinstance(asserter, basestring):
+ if isinstance(asserter, str):
asserter = getattr(self, asserter)
return asserter
@@ -524,8 +636,8 @@ class TestCase(object):
safe_repr(second)))
raise self.failureException(msg)
-
- def assertAlmostEqual(self, first, second, places=None, msg=None, delta=None):
+ def assertAlmostEqual(self, first, second, places=None, msg=None,
+ delta=None):
"""Fail if the two objects are unequal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
@@ -563,7 +675,8 @@ class TestCase(object):
msg = self._formatMessage(msg, standardMsg)
raise self.failureException(msg)
- def assertNotAlmostEqual(self, first, second, places=None, msg=None, delta=None):
+ def assertNotAlmostEqual(self, first, second, places=None, msg=None,
+ delta=None):
"""Fail if the two objects are equal as determined by their
difference rounded to the given number of decimal places
(default 7) and comparing to zero, or by comparing that the
@@ -594,34 +707,6 @@ class TestCase(object):
msg = self._formatMessage(msg, standardMsg)
raise self.failureException(msg)
- # Synonyms for assertion methods
-
- # The plurals are undocumented. Keep them that way to discourage use.
- # Do not add more. Do not remove.
- # Going through a deprecation cycle on these would annoy many people.
- assertEquals = assertEqual
- assertNotEquals = assertNotEqual
- assertAlmostEquals = assertAlmostEqual
- assertNotAlmostEquals = assertNotAlmostEqual
- assert_ = assertTrue
-
- # These fail* assertion method names are pending deprecation and will
- # be a DeprecationWarning in 3.2; http://bugs.python.org/issue2578
- def _deprecate(original_func):
- def deprecated_func(*args, **kwargs):
- warnings.warn(
- 'Please use {0} instead.'.format(original_func.__name__),
- PendingDeprecationWarning, 2)
- return original_func(*args, **kwargs)
- return deprecated_func
-
- failUnlessEqual = _deprecate(assertEqual)
- failIfEqual = _deprecate(assertNotEqual)
- failUnlessAlmostEqual = _deprecate(assertAlmostEqual)
- failIfAlmostEqual = _deprecate(assertNotAlmostEqual)
- failUnless = _deprecate(assertTrue)
- failUnlessRaises = _deprecate(assertRaises)
- failIf = _deprecate(assertFalse)
def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
"""An equality assertion for ordered sequences (like lists and tuples).
@@ -637,7 +722,7 @@ class TestCase(object):
msg: Optional message to use on failure instead of a list of
differences.
"""
- if seq_type is not None:
+ if seq_type != None:
seq_type_name = seq_type.__name__
if not isinstance(seq1, seq_type):
raise self.failureException('First sequence is not a %s: %s'
@@ -675,7 +760,7 @@ class TestCase(object):
elements = (seq_type_name.capitalize(), seq1_repr, seq2_repr)
differing = '%ss differ: %s != %s\n' % elements
- for i in xrange(min(len1, len2)):
+ for i in range(min(len1, len2)):
try:
item1 = seq1[i]
except (TypeError, IndexError, NotImplementedError):
@@ -722,6 +807,7 @@ class TestCase(object):
diffMsg = '\n' + '\n'.join(
difflib.ndiff(pprint.pformat(seq1).splitlines(),
pprint.pformat(seq2).splitlines()))
+
standardMsg = self._truncateMessage(standardMsg, diffMsg)
msg = self._formatMessage(msg, standardMsg)
self.fail(msg)
@@ -770,16 +856,16 @@ class TestCase(object):
"""
try:
difference1 = set1.difference(set2)
- except TypeError, e:
+ except TypeError as e:
self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError, e:
+ except AttributeError as e:
self.fail('first argument does not support set difference: %s' % e)
try:
difference2 = set2.difference(set1)
- except TypeError, e:
+ except TypeError as e:
self.fail('invalid type when attempting set difference: %s' % e)
- except AttributeError, e:
+ except AttributeError as e:
self.fail('second argument does not support set difference: %s' % e)
if not (difference1 or difference2):
@@ -837,17 +923,19 @@ class TestCase(object):
standardMsg = self._truncateMessage(standardMsg, diff)
self.fail(self._formatMessage(msg, standardMsg))
- def assertDictContainsSubset(self, expected, actual, msg=None):
- """Checks whether actual is a superset of expected."""
+ def assertDictContainsSubset(self, subset, dictionary, msg=None):
+ """Checks whether dictionary is a superset of subset."""
+ warnings.warn('assertDictContainsSubset is deprecated',
+ DeprecationWarning)
missing = []
mismatched = []
- for key, value in expected.iteritems():
- if key not in actual:
+ for key, value in subset.items():
+ if key not in dictionary:
missing.append(key)
- elif value != actual[key]:
+ elif value != dictionary[key]:
mismatched.append('%s, expected: %s, actual: %s' %
(safe_repr(key), safe_repr(value),
- safe_repr(actual[key])))
+ safe_repr(dictionary[key])))
if not (missing or mismatched):
return
@@ -863,37 +951,73 @@ class TestCase(object):
self.fail(self._formatMessage(msg, standardMsg))
- def assertItemsEqual(self, expected_seq, actual_seq, msg=None):
- """An unordered sequence specific comparison. It asserts that
- actual_seq and expected_seq have the same element counts.
- Equivalent to::
+ def assertSameElements(self, expected_seq, actual_seq, msg=None):
+ """An unordered sequence specific comparison.
- self.assertEqual(Counter(iter(actual_seq)),
- Counter(iter(expected_seq)))
+ Raises with an error message listing which elements of expected_seq
+ are missing from actual_seq and vice versa if any.
- Asserts that each element has the same count in both sequences.
- Example:
- - [0, 1, 1] and [1, 0, 1] compare equal.
- - [0, 0, 1] and [0, 1] compare unequal.
+ Duplicate elements are ignored when comparing *expected_seq* and
+ *actual_seq*. It is the equivalent of ``assertEqual(set(expected),
+ set(actual))`` but it works with sequences of unhashable objects as
+ well.
"""
- first_seq, second_seq = list(expected_seq), list(actual_seq)
- with warnings.catch_warnings():
- if sys.py3kwarning:
- # Silence Py3k warning raised during the sorting
- for _msg in ["(code|dict|type) inequality comparisons",
- "builtin_function_or_method order comparisons",
- "comparing unequal types"]:
- warnings.filterwarnings("ignore", _msg, DeprecationWarning)
+ warnings.warn('assertSameElements is deprecated',
+ DeprecationWarning)
+ try:
+ expected = set(expected_seq)
+ actual = set(actual_seq)
+ missing = sorted(expected.difference(actual))
+ unexpected = sorted(actual.difference(expected))
+ except TypeError:
+ # Fall back to slower list-compare if any of the objects are
+ # not hashable.
+ expected = list(expected_seq)
+ actual = list(actual_seq)
try:
- first = collections.Counter(first_seq)
- second = collections.Counter(second_seq)
+ expected.sort()
+ actual.sort()
except TypeError:
- # Handle case with unhashable elements
- differences = _count_diff_all_purpose(first_seq, second_seq)
+ missing, unexpected = unorderable_list_difference(expected,
+ actual)
else:
- if first == second:
- return
- differences = _count_diff_hashable(first_seq, second_seq)
+ missing, unexpected = sorted_list_difference(expected, actual)
+ errors = []
+ if missing:
+ errors.append('Expected, but missing:\n %s' %
+ safe_repr(missing))
+ if unexpected:
+ errors.append('Unexpected, but present:\n %s' %
+ safe_repr(unexpected))
+ if errors:
+ standardMsg = '\n'.join(errors)
+ self.fail(self._formatMessage(msg, standardMsg))
+
+
+ def assertCountEqual(self, first, second, msg=None):
+ """An unordered sequence comparison asserting that the same elements,
+ regardless of order. If the same element occurs more than once,
+ it verifies that the elements occur the same number of times.
+
+ self.assertEqual(Counter(list(first)),
+ Counter(list(second)))
+
+ Example:
+ - [0, 1, 1] and [1, 0, 1] compare equal.
+ - [0, 0, 1] and [0, 1] compare unequal.
+
+ """
+ first_seq, second_seq = list(first), list(second)
+ try:
+ first = collections.Counter(first_seq)
+ second = collections.Counter(second_seq)
+ except TypeError:
+ # Handle case with unhashable elements
+ differences = _count_diff_all_purpose(first_seq, second_seq)
+ else:
+ if first == second:
+ return
+ differences = _count_diff_hashable(first_seq, second_seq)
if differences:
standardMsg = 'Element counts were not equal:\n'
@@ -905,10 +1029,8 @@ class TestCase(object):
def assertMultiLineEqual(self, first, second, msg=None):
"""Assert that two multi-line strings are equal."""
- self.assertIsInstance(first, basestring,
- 'First argument is not a string')
- self.assertIsInstance(second, basestring,
- 'Second argument is not a string')
+ self.assertIsInstance(first, str, 'First argument is not a string')
+ self.assertIsInstance(second, str, 'Second argument is not a string')
if first != second:
# don't use difflib if the strings are too long
@@ -975,47 +1097,92 @@ class TestCase(object):
standardMsg = '%s is an instance of %r' % (safe_repr(obj), cls)
self.fail(self._formatMessage(msg, standardMsg))
- def assertRaisesRegexp(self, expected_exception, expected_regexp,
- callable_obj=None, *args, **kwargs):
- """Asserts that the message in a raised exception matches a regexp.
+ def assertRaisesRegex(self, expected_exception, expected_regex,
+ callable_obj=None, *args, **kwargs):
+ """Asserts that the message in a raised exception matches a regex.
Args:
expected_exception: Exception class expected to be raised.
- expected_regexp: Regexp (re pattern object or string) expected
+ expected_regex: Regex (re pattern object or string) expected
+ to be found in error message.
+ callable_obj: Function to be called.
+ args: Extra args.
+ kwargs: Extra kwargs.
+ """
+ context = _AssertRaisesContext(expected_exception, self, callable_obj,
+ expected_regex)
+ if callable_obj is None:
+ return context
+ with context:
+ callable_obj(*args, **kwargs)
+
+ def assertWarnsRegex(self, expected_warning, expected_regex,
+ callable_obj=None, *args, **kwargs):
+ """Asserts that the message in a triggered warning matches a regexp.
+ Basic functioning is similar to assertWarns() with the addition
+ that only warnings whose messages also match the regular expression
+ are considered successful matches.
+
+ Args:
+ expected_warning: Warning class expected to be triggered.
+ expected_regex: Regex (re pattern object or string) expected
to be found in error message.
callable_obj: Function to be called.
args: Extra args.
kwargs: Extra kwargs.
"""
- context = _AssertRaisesContext(expected_exception, self, expected_regexp)
+ context = _AssertWarnsContext(expected_warning, self, callable_obj,
+ expected_regex)
if callable_obj is None:
return context
with context:
callable_obj(*args, **kwargs)
- def assertRegexpMatches(self, text, expected_regexp, msg=None):
+ def assertRegex(self, text, expected_regex, msg=None):
"""Fail the test unless the text matches the regular expression."""
- if isinstance(expected_regexp, basestring):
- expected_regexp = re.compile(expected_regexp)
- if not expected_regexp.search(text):
- msg = msg or "Regexp didn't match"
- msg = '%s: %r not found in %r' % (msg, expected_regexp.pattern, text)
+ if isinstance(expected_regex, (str, bytes)):
+ assert expected_regex, "expected_regex must not be empty."
+ expected_regex = re.compile(expected_regex)
+ if not expected_regex.search(text):
+ msg = msg or "Regex didn't match"
+ msg = '%s: %r not found in %r' % (msg, expected_regex.pattern, text)
raise self.failureException(msg)
- def assertNotRegexpMatches(self, text, unexpected_regexp, msg=None):
+ def assertNotRegex(self, text, unexpected_regex, msg=None):
"""Fail the test if the text matches the regular expression."""
- if isinstance(unexpected_regexp, basestring):
- unexpected_regexp = re.compile(unexpected_regexp)
- match = unexpected_regexp.search(text)
+ if isinstance(unexpected_regex, (str, bytes)):
+ unexpected_regex = re.compile(unexpected_regex)
+ match = unexpected_regex.search(text)
if match:
- msg = msg or "Regexp matched"
+ msg = msg or "Regex matched"
msg = '%s: %r matches %r in %r' % (msg,
text[match.start():match.end()],
- unexpected_regexp.pattern,
+ unexpected_regex.pattern,
text)
raise self.failureException(msg)
+ def _deprecate(original_func):
+ def deprecated_func(*args, **kwargs):
+ warnings.warn(
+ 'Please use {0} instead.'.format(original_func.__name__),
+ DeprecationWarning, 2)
+ return original_func(*args, **kwargs)
+ return deprecated_func
+
+ # see #9424
+ failUnlessEqual = assertEquals = _deprecate(assertEqual)
+ failIfEqual = assertNotEquals = _deprecate(assertNotEqual)
+ failUnlessAlmostEqual = assertAlmostEquals = _deprecate(assertAlmostEqual)
+ failIfAlmostEqual = assertNotAlmostEquals = _deprecate(assertNotAlmostEqual)
+ failUnless = assert_ = _deprecate(assertTrue)
+ failUnlessRaises = _deprecate(assertRaises)
+ failIf = _deprecate(assertFalse)
+ assertRaisesRegexp = _deprecate(assertRaisesRegex)
+ assertRegexpMatches = _deprecate(assertRegex)
+
+
+
class FunctionTestCase(TestCase):
"""A test case that wraps a test function.
diff --git a/Lib/unittest/loader.py b/Lib/unittest/loader.py
index e88f536b394..541884e4161 100644
--- a/Lib/unittest/loader.py
+++ b/Lib/unittest/loader.py
@@ -5,11 +5,11 @@ import re
import sys
import traceback
import types
+import functools
-from functools import cmp_to_key as _CmpToKey
from fnmatch import fnmatch
-from . import case, suite
+from . import case, suite, util
__unittest = True
@@ -34,6 +34,11 @@ def _make_failed_test(classname, methodname, exception, suiteClass):
TestClass = type(classname, (case.TestCase,), attrs)
return suiteClass((TestClass(methodname),))
+def _jython_aware_splitext(path):
+ if path.lower().endswith('$py.class'):
+ return path[:-9]
+ return os.path.splitext(path)[0]
+
class TestLoader(object):
"""
@@ -41,7 +46,7 @@ class TestLoader(object):
and returning them wrapped in a TestSuite
"""
testMethodPrefix = 'test'
- sortTestMethodsUsing = cmp
+ sortTestMethodsUsing = staticmethod(util.three_way_cmp)
suiteClass = suite.TestSuite
_top_level_dir = None
@@ -69,7 +74,7 @@ class TestLoader(object):
if use_load_tests and load_tests is not None:
try:
return load_tests(self, tests, None)
- except Exception, e:
+ except Exception as e:
return _make_failed_load_tests(module.__name__, e,
self.suiteClass)
return tests
@@ -103,13 +108,17 @@ class TestLoader(object):
return self.loadTestsFromModule(obj)
elif isinstance(obj, type) and issubclass(obj, case.TestCase):
return self.loadTestsFromTestCase(obj)
- elif (isinstance(obj, types.UnboundMethodType) and
+ elif (isinstance(obj, types.FunctionType) and
isinstance(parent, type) and
issubclass(parent, case.TestCase)):
- return self.suiteClass([parent(obj.__name__)])
+ name = obj.__name__
+ inst = parent(name)
+ # static methods follow a different path
+ if not isinstance(getattr(inst, name), types.FunctionType):
+ return self.suiteClass([inst])
elif isinstance(obj, suite.TestSuite):
return obj
- elif hasattr(obj, '__call__'):
+ if callable(obj):
test = obj()
if isinstance(test, suite.TestSuite):
return test
@@ -134,17 +143,17 @@ class TestLoader(object):
def isTestMethod(attrname, testCaseClass=testCaseClass,
prefix=self.testMethodPrefix):
return attrname.startswith(prefix) and \
- hasattr(getattr(testCaseClass, attrname), '__call__')
- testFnNames = filter(isTestMethod, dir(testCaseClass))
+ callable(getattr(testCaseClass, attrname))
+ testFnNames = list(filter(isTestMethod, dir(testCaseClass)))
if self.sortTestMethodsUsing:
- testFnNames.sort(key=_CmpToKey(self.sortTestMethodsUsing))
+ testFnNames.sort(key=functools.cmp_to_key(self.sortTestMethodsUsing))
return testFnNames
def discover(self, start_dir, pattern='test*.py', top_level_dir=None):
"""Find and return all test modules from the specified start
- directory, recursing into subdirectories to find them. Only test files
- that match the pattern will be loaded. (Using shell style pattern
- matching.)
+ directory, recursing into subdirectories to find them and return all
+ tests found within them. Only test files that match the pattern will
+ be loaded. (Using shell style pattern matching.)
All test modules must be importable from the top level of the project.
If the start directory is not the top level directory then the top
@@ -217,7 +226,7 @@ class TestLoader(object):
return os.path.dirname(full_path)
def _get_name_from_path(self, path):
- path = os.path.splitext(os.path.normpath(path))[0]
+ path = _jython_aware_splitext(os.path.normpath(path))
_relpath = os.path.relpath(path, self._top_level_dir)
assert not os.path.isabs(_relpath), "Path must be within the project"
@@ -254,11 +263,11 @@ class TestLoader(object):
yield _make_failed_import_test(name, self.suiteClass)
else:
mod_file = os.path.abspath(getattr(module, '__file__', full_path))
- realpath = os.path.splitext(mod_file)[0]
- fullpath_noext = os.path.splitext(full_path)[0]
+ realpath = _jython_aware_splitext(mod_file)
+ fullpath_noext = _jython_aware_splitext(full_path)
if realpath.lower() != fullpath_noext.lower():
module_dir = os.path.dirname(realpath)
- mod_name = os.path.splitext(os.path.basename(full_path))[0]
+ mod_name = _jython_aware_splitext(os.path.basename(full_path))
expected_dir = os.path.dirname(full_path)
msg = ("%r module incorrectly imported from %r. Expected %r. "
"Is this module globally installed?")
@@ -287,7 +296,7 @@ class TestLoader(object):
else:
try:
yield load_tests(self, tests, pattern)
- except Exception, e:
+ except Exception as e:
yield _make_failed_load_tests(package.__name__, e,
self.suiteClass)
@@ -302,13 +311,15 @@ def _makeLoader(prefix, sortUsing, suiteClass=None):
loader.suiteClass = suiteClass
return loader
-def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp):
+def getTestCaseNames(testCaseClass, prefix, sortUsing=util.three_way_cmp):
return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass)
-def makeSuite(testCaseClass, prefix='test', sortUsing=cmp,
+def makeSuite(testCaseClass, prefix='test', sortUsing=util.three_way_cmp,
suiteClass=suite.TestSuite):
- return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass)
+ return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(
+ testCaseClass)
-def findTestCases(module, prefix='test', sortUsing=cmp,
+def findTestCases(module, prefix='test', sortUsing=util.three_way_cmp,
suiteClass=suite.TestSuite):
- return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module)
+ return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(\
+ module)
diff --git a/Lib/unittest/main.py b/Lib/unittest/main.py
index 3396bb0ab69..55d4e4be148 100644
--- a/Lib/unittest/main.py
+++ b/Lib/unittest/main.py
@@ -58,7 +58,24 @@ Examples:
in MyTestCase
"""
+def _convert_name(name):
+ # on Linux / Mac OS X 'foo.PY' is not importable, but on
+ # Windows it is. Simpler to do a case insensitive match
+ # a better check would be to check that the name is a
+ # valid Python module name.
+ if os.path.isfile(name) and name.lower().endswith('.py'):
+ if os.path.isabs(name):
+ rel_path = os.path.relpath(name, os.getcwd())
+ if os.path.isabs(rel_path) or rel_path.startswith(os.pardir):
+ return name
+ name = rel_path
+ # on Windows both '\' and '/' are used as path
+ # separators. Better to replace both than rely on os.path.sep
+ return name[:-3].replace('\\', '.').replace('/', '.')
+ return name
+def _convert_names(names):
+ return [_convert_name(name) for name in names]
class TestProgram(object):
"""A command-line program that runs a set of tests; this is primarily
@@ -67,13 +84,13 @@ class TestProgram(object):
USAGE = USAGE_FROM_MODULE
# defaults for testing
- failfast = catchbreak = buffer = progName = None
+ failfast = catchbreak = buffer = progName = warnings = None
def __init__(self, module='__main__', defaultTest=None, argv=None,
testRunner=None, testLoader=loader.defaultTestLoader,
exit=True, verbosity=1, failfast=None, catchbreak=None,
- buffer=None):
- if isinstance(module, basestring):
+ buffer=None, warnings=None):
+ if isinstance(module, str):
self.module = __import__(module)
for part in module.split('.')[1:]:
self.module = getattr(self.module, part)
@@ -87,6 +104,18 @@ class TestProgram(object):
self.catchbreak = catchbreak
self.verbosity = verbosity
self.buffer = buffer
+ if warnings is None and not sys.warnoptions:
+ # even if DreprecationWarnings are ignored by default
+ # print them anyway unless other warnings settings are
+ # specified by the warnings arg or the -W python flag
+ self.warnings = 'default'
+ else:
+ # here self.warnings is set either to the value passed
+ # to the warnings args or to None.
+ # If the user didn't pass a value self.warnings will
+ # be None. This means that the behavior is unchanged
+ # and depends on the values passed to -W.
+ self.warnings = warnings
self.defaultTest = defaultTest
self.testRunner = testRunner
self.testLoader = testLoader
@@ -96,7 +125,7 @@ class TestProgram(object):
def usageExit(self, msg=None):
if msg:
- print msg
+ print(msg)
usage = {'progName': self.progName, 'catchbreak': '', 'failfast': '',
'buffer': ''}
if self.failfast != False:
@@ -105,11 +134,12 @@ class TestProgram(object):
usage['catchbreak'] = CATCHBREAK
if self.buffer != False:
usage['buffer'] = BUFFEROUTPUT
- print self.USAGE % usage
+ print(self.USAGE % usage)
sys.exit(2)
def parseArgs(self, argv):
- if len(argv) > 1 and argv[1].lower() == 'discover':
+ if ((len(argv) > 1 and argv[1].lower() == 'discover') or
+ (len(argv) == 1 and self.module is None)):
self._do_discovery(argv[2:])
return
@@ -117,38 +147,48 @@ class TestProgram(object):
long_opts = ['help', 'verbose', 'quiet', 'failfast', 'catch', 'buffer']
try:
options, args = getopt.getopt(argv[1:], 'hHvqfcb', long_opts)
- for opt, value in options:
- if opt in ('-h','-H','--help'):
- self.usageExit()
- if opt in ('-q','--quiet'):
- self.verbosity = 0
- if opt in ('-v','--verbose'):
- self.verbosity = 2
- if opt in ('-f','--failfast'):
- if self.failfast is None:
- self.failfast = True
- # Should this raise an exception if -f is not valid?
- if opt in ('-c','--catch'):
- if self.catchbreak is None:
- self.catchbreak = True
- # Should this raise an exception if -c is not valid?
- if opt in ('-b','--buffer'):
- if self.buffer is None:
- self.buffer = True
- # Should this raise an exception if -b is not valid?
- if len(args) == 0 and self.defaultTest is None:
- # createTests will load tests from self.module
- self.testNames = None
- elif len(args) > 0:
- self.testNames = args
- if __name__ == '__main__':
- # to support python -m unittest ...
- self.module = None
- else:
- self.testNames = (self.defaultTest,)
- self.createTests()
- except getopt.error, msg:
+ except getopt.error as msg:
self.usageExit(msg)
+ return
+
+ for opt, value in options:
+ if opt in ('-h','-H','--help'):
+ self.usageExit()
+ if opt in ('-q','--quiet'):
+ self.verbosity = 0
+ if opt in ('-v','--verbose'):
+ self.verbosity = 2
+ if opt in ('-f','--failfast'):
+ if self.failfast is None:
+ self.failfast = True
+ # Should this raise an exception if -f is not valid?
+ if opt in ('-c','--catch'):
+ if self.catchbreak is None:
+ self.catchbreak = True
+ # Should this raise an exception if -c is not valid?
+ if opt in ('-b','--buffer'):
+ if self.buffer is None:
+ self.buffer = True
+ # Should this raise an exception if -b is not valid?
+
+ if len(args) == 0 and self.module is None:
+ # this allows "python -m unittest -v" to still work for
+ # test discovery. This means -c / -b / -v / -f options will
+ # be handled twice, which is harmless but not ideal.
+ self._do_discovery(argv[1:])
+ return
+
+ if len(args) == 0 and self.defaultTest is None:
+ # createTests will load tests from self.module
+ self.testNames = None
+ elif len(args) > 0:
+ self.testNames = _convert_names(args)
+ if __name__ == '__main__':
+ # to support python -m unittest ...
+ self.module = None
+ else:
+ self.testNames = (self.defaultTest,)
+ self.createTests()
def createTests(self):
if self.testNames is None:
@@ -215,11 +255,12 @@ class TestProgram(object):
installHandler()
if self.testRunner is None:
self.testRunner = runner.TextTestRunner
- if isinstance(self.testRunner, (type, types.ClassType)):
+ if isinstance(self.testRunner, type):
try:
testRunner = self.testRunner(verbosity=self.verbosity,
failfast=self.failfast,
- buffer=self.buffer)
+ buffer=self.buffer,
+ warnings=self.warnings)
except TypeError:
# didn't accept the verbosity, buffer or failfast arguments
testRunner = self.testRunner()
diff --git a/Lib/unittest/result.py b/Lib/unittest/result.py
index 2cc17d71c85..44bf1862e4f 100644
--- a/Lib/unittest/result.py
+++ b/Lib/unittest/result.py
@@ -1,11 +1,10 @@
"""Test result object"""
import os
+import io
import sys
import traceback
-from StringIO import StringIO
-
from . import util
from functools import wraps
@@ -65,8 +64,8 @@ class TestResult(object):
def _setupStdout(self):
if self.buffer:
if self._stderr_buffer is None:
- self._stderr_buffer = StringIO()
- self._stdout_buffer = StringIO()
+ self._stderr_buffer = io.StringIO()
+ self._stdout_buffer = io.StringIO()
sys.stdout = self._stdout_buffer
sys.stderr = self._stderr_buffer
diff --git a/Lib/unittest/runner.py b/Lib/unittest/runner.py
index 7632fe9823c..28b8865978a 100644
--- a/Lib/unittest/runner.py
+++ b/Lib/unittest/runner.py
@@ -2,6 +2,7 @@
import sys
import time
+import warnings
from . import result
from .signals import registerResult
@@ -124,13 +125,16 @@ class TextTestRunner(object):
"""
resultclass = TextTestResult
- def __init__(self, stream=sys.stderr, descriptions=True, verbosity=1,
- failfast=False, buffer=False, resultclass=None):
+ def __init__(self, stream=None, descriptions=True, verbosity=1,
+ failfast=False, buffer=False, resultclass=None, warnings=None):
+ if stream is None:
+ stream = sys.stderr
self.stream = _WritelnDecorator(stream)
self.descriptions = descriptions
self.verbosity = verbosity
self.failfast = failfast
self.buffer = buffer
+ self.warnings = warnings
if resultclass is not None:
self.resultclass = resultclass
@@ -143,17 +147,30 @@ class TextTestRunner(object):
registerResult(result)
result.failfast = self.failfast
result.buffer = self.buffer
- startTime = time.time()
- startTestRun = getattr(result, 'startTestRun', None)
- if startTestRun is not None:
- startTestRun()
- try:
- test(result)
- finally:
- stopTestRun = getattr(result, 'stopTestRun', None)
- if stopTestRun is not None:
- stopTestRun()
- stopTime = time.time()
+ with warnings.catch_warnings():
+ if self.warnings:
+ # if self.warnings is set, use it to filter all the warnings
+ warnings.simplefilter(self.warnings)
+ # if the filter is 'default' or 'always', special-case the
+ # warnings from the deprecated unittest methods to show them
+ # no more than once per module, because they can be fairly
+ # noisy. The -Wd and -Wa flags can be used to bypass this
+ # only when self.warnings is None.
+ if self.warnings in ['default', 'always']:
+ warnings.filterwarnings('module',
+ category=DeprecationWarning,
+ message='Please use assert\w+ instead.')
+ startTime = time.time()
+ startTestRun = getattr(result, 'startTestRun', None)
+ if startTestRun is not None:
+ startTestRun()
+ try:
+ test(result)
+ finally:
+ stopTestRun = getattr(result, 'stopTestRun', None)
+ if stopTestRun is not None:
+ stopTestRun()
+ stopTime = time.time()
timeTaken = stopTime - startTime
result.printErrors()
if hasattr(result, 'separator2'):
@@ -176,7 +193,7 @@ class TextTestRunner(object):
infos = []
if not result.wasSuccessful():
self.stream.write("FAILED")
- failed, errored = map(len, (result.failures, result.errors))
+ failed, errored = len(result.failures), len(result.errors)
if failed:
infos.append("failures=%d" % failed)
if errored:
diff --git a/Lib/unittest/suite.py b/Lib/unittest/suite.py
index 633af5cb085..cde5d385ed1 100644
--- a/Lib/unittest/suite.py
+++ b/Lib/unittest/suite.py
@@ -31,9 +31,6 @@ class BaseTestSuite(object):
def __ne__(self, other):
return not self == other
- # Can't guarantee hash invariant, so flag as unhashable
- __hash__ = None
-
def __iter__(self):
return iter(self._tests)
@@ -45,7 +42,7 @@ class BaseTestSuite(object):
def addTest(self, test):
# sanity checks
- if not hasattr(test, '__call__'):
+ if not callable(test):
raise TypeError("{} is not callable".format(repr(test)))
if isinstance(test, type) and issubclass(test,
(case.TestCase, TestSuite)):
@@ -54,7 +51,7 @@ class BaseTestSuite(object):
self._tests.append(test)
def addTests(self, tests):
- if isinstance(tests, basestring):
+ if isinstance(tests, str):
raise TypeError("tests must be an iterable of tests, not a string")
for test in tests:
self.addTest(test)
@@ -170,6 +167,7 @@ class TestSuite(BaseTestSuite):
self._handleModuleTearDown(result)
+
result._moduleSetUpFailed = False
try:
module = sys.modules[currentModule]
@@ -180,7 +178,7 @@ class TestSuite(BaseTestSuite):
_call_if_exists(result, '_setupStdout')
try:
setUpModule()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
result._moduleSetUpFailed = True
@@ -239,7 +237,7 @@ class TestSuite(BaseTestSuite):
_call_if_exists(result, '_setupStdout')
try:
tearDownClass()
- except Exception, e:
+ except Exception as e:
if isinstance(result, _DebugResult):
raise
className = util.strclass(previousClass)
diff --git a/Lib/unittest/test/_test_warnings.py b/Lib/unittest/test/_test_warnings.py
new file mode 100644
index 00000000000..d0be18d4add
--- /dev/null
+++ b/Lib/unittest/test/_test_warnings.py
@@ -0,0 +1,74 @@
+# helper module for test_runner.Test_TextTestRunner.test_warnings
+
+"""
+This module has a number of tests that raise different kinds of warnings.
+When the tests are run, the warnings are caught and their messages are printed
+to stdout. This module also accepts an arg that is then passed to
+unittest.main to affect the behavior of warnings.
+Test_TextTestRunner.test_warnings executes this script with different
+combinations of warnings args and -W flags and check that the output is correct.
+See #10535.
+"""
+
+import io
+import sys
+import unittest
+import warnings
+
+def warnfun():
+ warnings.warn('rw', RuntimeWarning)
+
+class TestWarnings(unittest.TestCase):
+ # unittest warnings will be printed at most once per type (max one message
+ # for the fail* methods, and one for the assert* methods)
+ def test_assert(self):
+ self.assertEquals(2+2, 4)
+ self.assertEquals(2*2, 4)
+ self.assertEquals(2**2, 4)
+
+ def test_fail(self):
+ self.failUnless(1)
+ self.failUnless(True)
+
+ def test_other_unittest(self):
+ self.assertAlmostEqual(2+2, 4)
+ self.assertNotAlmostEqual(4+4, 2)
+
+ # these warnings are normally silenced, but they are printed in unittest
+ def test_deprecation(self):
+ warnings.warn('dw', DeprecationWarning)
+ warnings.warn('dw', DeprecationWarning)
+ warnings.warn('dw', DeprecationWarning)
+
+ def test_import(self):
+ warnings.warn('iw', ImportWarning)
+ warnings.warn('iw', ImportWarning)
+ warnings.warn('iw', ImportWarning)
+
+ # user warnings should always be printed
+ def test_warning(self):
+ warnings.warn('uw')
+ warnings.warn('uw')
+ warnings.warn('uw')
+
+ # these warnings come from the same place; they will be printed
+ # only once by default or three times if the 'always' filter is used
+ def test_function(self):
+
+ warnfun()
+ warnfun()
+ warnfun()
+
+
+
+if __name__ == '__main__':
+ with warnings.catch_warnings(record=True) as ws:
+ # if an arg is provided pass it to unittest.main as 'warnings'
+ if len(sys.argv) == 2:
+ unittest.main(exit=False, warnings=sys.argv.pop())
+ else:
+ unittest.main(exit=False)
+
+ # print all the warning messages collected
+ for w in ws:
+ print(w.message)
diff --git a/Lib/unittest/test/support.py b/Lib/unittest/test/support.py
index f1cf03b1420..dbe4ddcd0e7 100644
--- a/Lib/unittest/test/support.py
+++ b/Lib/unittest/test/support.py
@@ -1,6 +1,21 @@
import unittest
+class TestEquality(object):
+ """Used as a mixin for TestCase"""
+
+ # Check for a valid __eq__ implementation
+ def test_eq(self):
+ for obj_1, obj_2 in self.eq_pairs:
+ self.assertEqual(obj_1, obj_2)
+ self.assertEqual(obj_2, obj_1)
+
+ # Check for a valid __ne__ implementation
+ def test_ne(self):
+ for obj_1, obj_2 in self.ne_pairs:
+ self.assertNotEqual(obj_1, obj_2)
+ self.assertNotEqual(obj_2, obj_1)
+
class TestHashing(object):
"""Used as a mixin for TestCase"""
@@ -12,7 +27,7 @@ class TestHashing(object):
self.fail("%r and %r do not hash equal" % (obj_1, obj_2))
except KeyboardInterrupt:
raise
- except Exception, e:
+ except Exception as e:
self.fail("Problem hashing %r and %r: %s" % (obj_1, obj_2, e))
for obj_1, obj_2 in self.ne_pairs:
@@ -22,34 +37,18 @@ class TestHashing(object):
(obj_1, obj_2))
except KeyboardInterrupt:
raise
- except Exception, e:
+ except Exception as e:
self.fail("Problem hashing %s and %s: %s" % (obj_1, obj_2, e))
-class TestEquality(object):
- """Used as a mixin for TestCase"""
-
- # Check for a valid __eq__ implementation
- def test_eq(self):
- for obj_1, obj_2 in self.eq_pairs:
- self.assertEqual(obj_1, obj_2)
- self.assertEqual(obj_2, obj_1)
-
- # Check for a valid __ne__ implementation
- def test_ne(self):
- for obj_1, obj_2 in self.ne_pairs:
- self.assertNotEqual(obj_1, obj_2)
- self.assertNotEqual(obj_2, obj_1)
-
-
class LoggingResult(unittest.TestResult):
def __init__(self, log):
self._events = log
- super(LoggingResult, self).__init__()
+ super().__init__()
def startTest(self, test):
self._events.append('startTest')
- super(LoggingResult, self).startTest(test)
+ super().startTest(test)
def startTestRun(self):
self._events.append('startTestRun')
@@ -57,7 +56,7 @@ class LoggingResult(unittest.TestResult):
def stopTest(self, test):
self._events.append('stopTest')
- super(LoggingResult, self).stopTest(test)
+ super().stopTest(test)
def stopTestRun(self):
self._events.append('stopTestRun')
@@ -65,7 +64,7 @@ class LoggingResult(unittest.TestResult):
def addFailure(self, *args):
self._events.append('addFailure')
- super(LoggingResult, self).addFailure(*args)
+ super().addFailure(*args)
def addSuccess(self, *args):
self._events.append('addSuccess')
@@ -73,7 +72,7 @@ class LoggingResult(unittest.TestResult):
def addError(self, *args):
self._events.append('addError')
- super(LoggingResult, self).addError(*args)
+ super().addError(*args)
def addSkip(self, *args):
self._events.append('addSkip')
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py
index e1ba6147066..a1d20ebf2da 100644
--- a/Lib/unittest/test/test_assertions.py
+++ b/Lib/unittest/test/test_assertions.py
@@ -1,5 +1,5 @@
import datetime
-
+import warnings
import unittest
@@ -58,7 +58,7 @@ class Test_Assertions(unittest.TestCase):
try:
self.assertRaises(KeyError, lambda: None)
except self.failureException as e:
- self.assertIn("KeyError not raised", e.args)
+ self.assertIn("KeyError not raised", str(e))
else:
self.fail("assertRaises() didn't fail")
try:
@@ -70,9 +70,10 @@ class Test_Assertions(unittest.TestCase):
with self.assertRaises(KeyError) as cm:
try:
raise KeyError
- except Exception, e:
+ except Exception as e:
+ exc = e
raise
- self.assertIs(cm.exception, e)
+ self.assertIs(cm.exception, exc)
with self.assertRaises(KeyError):
raise KeyError("key")
@@ -80,7 +81,7 @@ class Test_Assertions(unittest.TestCase):
with self.assertRaises(KeyError):
pass
except self.failureException as e:
- self.assertIn("KeyError not raised", e.args)
+ self.assertIn("KeyError not raised", str(e))
else:
self.fail("assertRaises() didn't fail")
try:
@@ -91,15 +92,15 @@ class Test_Assertions(unittest.TestCase):
else:
self.fail("assertRaises() didn't let exception pass through")
- def testAssertNotRegexpMatches(self):
- self.assertNotRegexpMatches('Ala ma kota', r'r+')
+ def testAssertNotRegex(self):
+ self.assertNotRegex('Ala ma kota', r'r+')
try:
- self.assertNotRegexpMatches('Ala ma kota', r'k.t', 'Message')
- except self.failureException, e:
+ self.assertNotRegex('Ala ma kota', r'k.t', 'Message')
+ except self.failureException as e:
self.assertIn("'kot'", e.args[0])
self.assertIn('Message', e.args[0])
else:
- self.fail('assertNotRegexpMatches should have failed.')
+ self.fail('assertNotRegex should have failed.')
class TestLongMessage(unittest.TestCase):
@@ -126,7 +127,7 @@ class TestLongMessage(unittest.TestCase):
self.testableFalse = TestableTestFalse('testTest')
def testDefault(self):
- self.assertFalse(unittest.TestCase.longMessage)
+ self.assertTrue(unittest.TestCase.longMessage)
def test_formatMsg(self):
self.assertEqual(self.testableFalse._formatMessage(None, "foo"), "foo")
@@ -141,7 +142,7 @@ class TestLongMessage(unittest.TestCase):
def test_formatMessage_unicode_error(self):
one = ''.join(chr(i) for i in range(255))
# this used to cause a UnicodeDecodeError constructing msg
- self.testableTrue._formatMessage(one, u'\uFFFD')
+ self.testableTrue._formatMessage(one, '\uFFFD')
def assertMessages(self, methodName, args, errors):
def getMethod(i):
@@ -152,15 +153,15 @@ class TestLongMessage(unittest.TestCase):
test = self.testableTrue
return getattr(test, methodName)
- for i, expected_regexp in enumerate(errors):
+ for i, expected_regex in enumerate(errors):
testMethod = getMethod(i)
kwargs = {}
withMsg = i % 2
if withMsg:
kwargs = {"msg": "oops"}
- with self.assertRaisesRegexp(self.failureException,
- expected_regexp=expected_regexp):
+ with self.assertRaisesRegex(self.failureException,
+ expected_regex=expected_regex):
testMethod(*args, **kwargs)
def testAssertTrue(self):
@@ -223,10 +224,13 @@ class TestLongMessage(unittest.TestCase):
"\+ \{'key': 'value'\} : oops$"])
def testAssertDictContainsSubset(self):
- self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
- ["^Missing: 'key'$", "^oops$",
- "^Missing: 'key'$",
- "^Missing: 'key' : oops$"])
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
+
+ self.assertMessages('assertDictContainsSubset', ({'key': 'value'}, {}),
+ ["^Missing: 'key'$", "^oops$",
+ "^Missing: 'key'$",
+ "^Missing: 'key' : oops$"])
def testAssertMultiLineEqual(self):
self.assertMessages('assertMultiLineEqual', ("", "foo"),
@@ -280,7 +284,3 @@ class TestLongMessage(unittest.TestCase):
["^unexpectedly identical: None$", "^oops$",
"^unexpectedly identical: None$",
"^unexpectedly identical: None : oops$"])
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Lib/unittest/test/test_break.py b/Lib/unittest/test/test_break.py
index 560001103f8..77ce20143bf 100644
--- a/Lib/unittest/test/test_break.py
+++ b/Lib/unittest/test/test_break.py
@@ -1,12 +1,10 @@
import gc
+import io
import os
import sys
import signal
import weakref
-from cStringIO import StringIO
-
-
import unittest
@@ -144,7 +142,7 @@ class TestBreak(unittest.TestCase):
def testRunner(self):
# Creating a TextTestRunner with the appropriate argument should
# register the TextTestResult it creates
- runner = unittest.TextTestRunner(stream=StringIO())
+ runner = unittest.TextTestRunner(stream=io.StringIO())
result = runner.run(unittest.TestSuite())
self.assertIn(result, unittest.signals._results)
@@ -211,7 +209,8 @@ class TestBreak(unittest.TestCase):
self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
'verbosity': verbosity,
- 'failfast': failfast})])
+ 'failfast': failfast,
+ 'warnings': None})])
self.assertEqual(FakeRunner.runArgs, [test])
self.assertEqual(p.result, result)
@@ -224,7 +223,8 @@ class TestBreak(unittest.TestCase):
self.assertEqual(FakeRunner.initArgs, [((), {'buffer': None,
'verbosity': verbosity,
- 'failfast': failfast})])
+ 'failfast': failfast,
+ 'warnings': None})])
self.assertEqual(FakeRunner.runArgs, [test])
self.assertEqual(p.result, result)
diff --git a/Lib/unittest/test/test_case.py b/Lib/unittest/test/test_case.py
index e92b0191674..c74a539515a 100644
--- a/Lib/unittest/test/test_case.py
+++ b/Lib/unittest/test/test_case.py
@@ -3,14 +3,17 @@ import pprint
import pickle
import re
import sys
+import warnings
+import inspect
from copy import deepcopy
-from test import test_support
+from test import support
import unittest
from .support import (
- TestEquality, TestHashing, LoggingResult, ResultWithNoStartTestRunStopTestRun
+ TestEquality, TestHashing, LoggingResult,
+ ResultWithNoStartTestRunStopTestRun
)
@@ -50,9 +53,9 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
eq_pairs = [(Test.Foo('test1'), Test.Foo('test1'))]
# Used by TestEquality.test_ne
- ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest'))
- ,(Test.Foo('test1'), Test.Bar('test1'))
- ,(Test.Foo('test1'), Test.Bar('test2'))]
+ ne_pairs = [(Test.Foo('test1'), Test.Foo('runTest')),
+ (Test.Foo('test1'), Test.Bar('test1')),
+ (Test.Foo('test1'), Test.Bar('test2'))]
################################################################
### /Set up attributes used by inherited tests
@@ -69,18 +72,28 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
# thing.
def test_init__no_test_name(self):
class Test(unittest.TestCase):
- def runTest(self): raise TypeError()
+ def runTest(self): raise MyException()
def test(self): pass
self.assertEqual(Test().id()[-13:], '.Test.runTest')
+ # test that TestCase can be instantiated with no args
+ # primarily for use at the interactive interpreter
+ test = unittest.TestCase()
+ test.assertEqual(3, 3)
+ with test.assertRaises(test.failureException):
+ test.assertEqual(3, 2)
+
+ with self.assertRaises(AttributeError):
+ test.run()
+
# "class TestCase([methodName])"
# ...
# "Each instance of TestCase will run a single test method: the
# method named methodName."
def test_init__test_name__valid(self):
class Test(unittest.TestCase):
- def runTest(self): raise TypeError()
+ def runTest(self): raise MyException()
def test(self): pass
self.assertEqual(Test('test').id()[-10:], '.Test.test')
@@ -91,7 +104,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
# method named methodName."
def test_init__test_name__invalid(self):
class Test(unittest.TestCase):
- def runTest(self): raise TypeError()
+ def runTest(self): raise MyException()
def test(self): pass
try:
@@ -174,8 +187,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
super(Foo, self).test()
raise RuntimeError('raised by Foo.test')
- expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
- 'stopTest']
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addError', 'stopTest']
Foo(events).run(result)
self.assertEqual(events, expected)
@@ -192,8 +205,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
super(Foo, self).test()
raise RuntimeError('raised by Foo.test')
- expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addError',
- 'tearDown', 'stopTest', 'stopTestRun']
+ expected = ['startTestRun', 'startTest', 'setUp', 'test',
+ 'tearDown', 'addError', 'stopTest', 'stopTestRun']
Foo(events).run()
self.assertEqual(events, expected)
@@ -213,8 +226,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
super(Foo, self).test()
self.fail('raised by Foo.test')
- expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
- 'stopTest']
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addFailure', 'stopTest']
Foo(events).run(result)
self.assertEqual(events, expected)
@@ -228,8 +241,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
super(Foo, self).test()
self.fail('raised by Foo.test')
- expected = ['startTestRun', 'startTest', 'setUp', 'test', 'addFailure',
- 'tearDown', 'stopTest', 'stopTestRun']
+ expected = ['startTestRun', 'startTest', 'setUp', 'test',
+ 'tearDown', 'addFailure', 'stopTest', 'stopTestRun']
events = []
Foo(events).run()
self.assertEqual(events, expected)
@@ -370,7 +383,8 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
def runTest(self):
pass
- self.assertIsInstance(Foo().id(), basestring)
+ self.assertIsInstance(Foo().id(), str)
+
# "If result is omitted or None, a temporary result object is created
# and used, but is not made available to the caller. As TestCase owns the
@@ -422,9 +436,9 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
class SadSnake(object):
"""Dummy class for test_addTypeEqualityFunc."""
s1, s2 = SadSnake(), SadSnake()
- self.assertNotEqual(s1, s2)
+ self.assertFalse(s1 == s2)
def AllSnakesCreatedEqual(a, b, msg=None):
- return type(a) is type(b) is SadSnake
+ return type(a) == type(b) == SadSnake
self.addTypeEqualityFunc(SadSnake, AllSnakesCreatedEqual)
self.assertEqual(s1, s2)
# No this doesn't clean up and remove the SadSnake equality func
@@ -475,32 +489,34 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
animals)
def testAssertDictContainsSubset(self):
- self.assertDictContainsSubset({}, {})
- self.assertDictContainsSubset({}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1})
- self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
- self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
+ with warnings.catch_warnings():
+ warnings.simplefilter("ignore", DeprecationWarning)
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({1: "one"}, {})
+ self.assertDictContainsSubset({}, {})
+ self.assertDictContainsSubset({}, {'a': 1})
+ self.assertDictContainsSubset({'a': 1}, {'a': 1})
+ self.assertDictContainsSubset({'a': 1}, {'a': 1, 'b': 2})
+ self.assertDictContainsSubset({'a': 1, 'b': 2}, {'a': 1, 'b': 2})
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 2}, {'a': 1})
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({1: "one"}, {})
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'c': 1}, {'a': 1})
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 2}, {'a': 1})
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'c': 1}, {'a': 1})
- with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
+
+ with self.assertRaises(self.failureException):
+ self.assertDictContainsSubset({'a': 1, 'c': 1}, {'a': 1})
- with test_support.check_warnings(("", UnicodeWarning)):
one = ''.join(chr(i) for i in range(255))
# this used to cause a UnicodeDecodeError constructing the failure msg
with self.assertRaises(self.failureException):
- self.assertDictContainsSubset({'foo': one}, {'foo': u'\uFFFD'})
+ self.assertDictContainsSubset({'foo': one}, {'foo': '\uFFFD'})
def testAssertEqual(self):
equal_pairs = [
@@ -602,6 +618,7 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self.maxDiff = len(diff)//2
try:
+
self.assertSequenceEqual(seq1, seq2)
except self.failureException as e:
msg = e.args[0]
@@ -680,14 +697,14 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self.addCleanup(lambda: setattr(self, '_diffThreshold', old_threshold))
# under the threshold: diff marker (^) in error message
- s = u'x' * (2**7)
+ s = 'x' * (2**7)
with self.assertRaises(self.failureException) as cm:
self.assertEqual(s + 'a', s + 'b')
self.assertIn('^', str(cm.exception))
self.assertEqual(s + 'a', s + 'a')
# over the threshold: diff not used and marker (^) not in error message
- s = u'x' * (2**9)
+ s = 'x' * (2**9)
# if the path that uses difflib is taken, _truncateMessage will be
# called -- replace it with explodingTruncation to verify that this
# doesn't happen
@@ -704,56 +721,56 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self.assertEqual(str(cm.exception), '%r != %r' % (s1, s2))
self.assertEqual(s + 'a', s + 'a')
- def testAssertItemsEqual(self):
+ def testAssertCountEqual(self):
a = object()
- self.assertItemsEqual([1, 2, 3], [3, 2, 1])
- self.assertItemsEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
- self.assertItemsEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
- self.assertItemsEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertCountEqual([1, 2, 3], [3, 2, 1])
+ self.assertCountEqual(['foo', 'bar', 'baz'], ['bar', 'baz', 'foo'])
+ self.assertCountEqual([a, a, 2, 2, 3], (a, 2, 3, a, 2))
+ self.assertCountEqual([1, "2", "a", "a"], ["a", "2", True, "a"])
+ self.assertRaises(self.failureException, self.assertCountEqual,
[1, 2] + [3] * 100, [1] * 100 + [2, 3])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[1, "2", "a", "a"], ["a", "2", True, 1])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[10], [10, 11])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[10, 11], [10])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[10, 11, 10], [10, 11])
# Test that sequences of unhashable objects can be tested for sameness:
- self.assertItemsEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
+ self.assertCountEqual([[1, 2], [3, 4], 0], [False, [3, 4], [1, 2]])
# Test that iterator of unhashable objects can be tested for sameness:
- self.assertItemsEqual(iter([1, 2, [], 3, 4]),
+ self.assertCountEqual(iter([1, 2, [], 3, 4]),
iter([1, 2, [], 3, 4]))
# hashable types, but not orderable
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[], [divmod, 'x', 1, 5j, 2j, frozenset()])
# comparing dicts
- self.assertItemsEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
+ self.assertCountEqual([{'a': 1}, {'b': 2}], [{'b': 2}, {'a': 1}])
# comparing heterogenous non-hashable sequences
- self.assertItemsEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertCountEqual([1, 'x', divmod, []], [divmod, [], 'x', 1])
+ self.assertRaises(self.failureException, self.assertCountEqual,
[], [divmod, [], 'x', 1, 5j, 2j, set()])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[[1]], [[2]])
# Same elements, but not same sequence length
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[1, 1, 2], [2, 1])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[1, 1, "2", "a", "a"], ["2", "2", True, "a"])
- self.assertRaises(self.failureException, self.assertItemsEqual,
+ self.assertRaises(self.failureException, self.assertCountEqual,
[1, {'b': 2}, None, True], [{'b': 2}, True, None])
# Same elements which don't reliably compare, in
# different order, see issue 10242
a = [{2,4}, {1,2}]
b = a[::-1]
- self.assertItemsEqual(a, b)
+ self.assertCountEqual(a, b)
- # test utility functions supporting assertItemsEqual()
+ # test utility functions supporting assertCountEqual()
diffs = set(unittest.util._count_diff_all_purpose('aaabccd', 'abbbcce'))
expected = {(3,1,'a'), (1,3,'b'), (1,0,'d'), (0,1,'e')}
@@ -849,62 +866,34 @@ class Test_TestCase(unittest.TestCase, TestEquality, TestHashing):
self.assertRaises(self.failureException, self.assertLess, 'ant', 'ant')
self.assertRaises(self.failureException, self.assertLessEqual, 'bug', 'ant')
- # Try Unicode
- self.assertGreater(u'bug', u'ant')
- self.assertGreaterEqual(u'bug', u'ant')
- self.assertGreaterEqual(u'ant', u'ant')
- self.assertLess(u'ant', u'bug')
- self.assertLessEqual(u'ant', u'bug')
- self.assertLessEqual(u'ant', u'ant')
- self.assertRaises(self.failureException, self.assertGreater, u'ant', u'bug')
- self.assertRaises(self.failureException, self.assertGreater, u'ant', u'ant')
- self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
- u'bug')
- self.assertRaises(self.failureException, self.assertLess, u'bug', u'ant')
- self.assertRaises(self.failureException, self.assertLess, u'ant', u'ant')
- self.assertRaises(self.failureException, self.assertLessEqual, u'bug', u'ant')
-
- # Try Mixed String/Unicode
- self.assertGreater('bug', u'ant')
- self.assertGreater(u'bug', 'ant')
- self.assertGreaterEqual('bug', u'ant')
- self.assertGreaterEqual(u'bug', 'ant')
- self.assertGreaterEqual('ant', u'ant')
- self.assertGreaterEqual(u'ant', 'ant')
- self.assertLess('ant', u'bug')
- self.assertLess(u'ant', 'bug')
- self.assertLessEqual('ant', u'bug')
- self.assertLessEqual(u'ant', 'bug')
- self.assertLessEqual('ant', u'ant')
- self.assertLessEqual(u'ant', 'ant')
- self.assertRaises(self.failureException, self.assertGreater, 'ant', u'bug')
- self.assertRaises(self.failureException, self.assertGreater, u'ant', 'bug')
- self.assertRaises(self.failureException, self.assertGreater, 'ant', u'ant')
- self.assertRaises(self.failureException, self.assertGreater, u'ant', 'ant')
- self.assertRaises(self.failureException, self.assertGreaterEqual, 'ant',
- u'bug')
- self.assertRaises(self.failureException, self.assertGreaterEqual, u'ant',
- 'bug')
- self.assertRaises(self.failureException, self.assertLess, 'bug', u'ant')
- self.assertRaises(self.failureException, self.assertLess, u'bug', 'ant')
- self.assertRaises(self.failureException, self.assertLess, 'ant', u'ant')
- self.assertRaises(self.failureException, self.assertLess, u'ant', 'ant')
- self.assertRaises(self.failureException, self.assertLessEqual, 'bug', u'ant')
- self.assertRaises(self.failureException, self.assertLessEqual, u'bug', 'ant')
+ # Try bytes
+ self.assertGreater(b'bug', b'ant')
+ self.assertGreaterEqual(b'bug', b'ant')
+ self.assertGreaterEqual(b'ant', b'ant')
+ self.assertLess(b'ant', b'bug')
+ self.assertLessEqual(b'ant', b'bug')
+ self.assertLessEqual(b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertGreater, b'ant', b'bug')
+ self.assertRaises(self.failureException, self.assertGreater, b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertGreaterEqual, b'ant',
+ b'bug')
+ self.assertRaises(self.failureException, self.assertLess, b'bug', b'ant')
+ self.assertRaises(self.failureException, self.assertLess, b'ant', b'ant')
+ self.assertRaises(self.failureException, self.assertLessEqual, b'bug', b'ant')
def testAssertMultiLineEqual(self):
- sample_text = b"""\
+ sample_text = """\
http://www.python.org/doc/2.3/lib/module-unittest.html
test case
A test case is the smallest unit of testing. [...]
"""
- revised_sample_text = b"""\
+ revised_sample_text = """\
http://www.python.org/doc/2.4.1/lib/module-unittest.html
test case
A test case is the smallest unit of testing. [...] You may provide your
own implementation that does not subclass from TestCase, of course.
"""
- sample_text_error = b"""\
+ sample_text_error = """\
- http://www.python.org/doc/2.3/lib/module-unittest.html
? ^
+ http://www.python.org/doc/2.4.1/lib/module-unittest.html
@@ -916,21 +905,19 @@ test case
+ own implementation that does not subclass from TestCase, of course.
"""
self.maxDiff = None
- for type_changer in (lambda x: x, lambda x: x.decode('utf8')):
- try:
- self.assertMultiLineEqual(type_changer(sample_text),
- type_changer(revised_sample_text))
- except self.failureException, e:
- # need to remove the first line of the error message
- error = str(e).encode('utf8').split('\n', 1)[1]
+ try:
+ self.assertMultiLineEqual(sample_text, revised_sample_text)
+ except self.failureException as e:
+ # need to remove the first line of the error message
+ error = str(e).split('\n', 1)[1]
- # assertMultiLineEqual is hooked up as the default for
- # unicode strings - so we can't use it for this check
- self.assertTrue(sample_text_error == error)
+ # no fair testing ourself with ourself, and assertEqual is used for strings
+ # so can't use assertEqual either. Just use assertTrue.
+ self.assertTrue(sample_text_error == error)
def testAsertEqualSingleLine(self):
- sample_text = u"laden swallows fly slowly"
- revised_sample_text = u"unladen swallows fly quickly"
+ sample_text = "laden swallows fly slowly"
+ revised_sample_text = "unladen swallows fly quickly"
sample_text_error = """\
- laden swallows fly slowly
? ^^^^
@@ -949,54 +936,44 @@ test case
self.assertIsNotNone('DjZoPloGears on Rails')
self.assertRaises(self.failureException, self.assertIsNotNone, None)
- def testAssertRegexpMatches(self):
- self.assertRegexpMatches('asdfabasdf', r'ab+')
- self.assertRaises(self.failureException, self.assertRegexpMatches,
+ def testAssertRegex(self):
+ self.assertRegex('asdfabasdf', r'ab+')
+ self.assertRaises(self.failureException, self.assertRegex,
'saaas', r'aaaa')
- def testAssertRaisesRegexp(self):
+ def testAssertRaisesRegex(self):
class ExceptionMock(Exception):
pass
def Stub():
raise ExceptionMock('We expect')
- self.assertRaisesRegexp(ExceptionMock, re.compile('expect$'), Stub)
- self.assertRaisesRegexp(ExceptionMock, 'expect$', Stub)
- self.assertRaisesRegexp(ExceptionMock, u'expect$', Stub)
+ self.assertRaisesRegex(ExceptionMock, re.compile('expect$'), Stub)
+ self.assertRaisesRegex(ExceptionMock, 'expect$', Stub)
- def testAssertNotRaisesRegexp(self):
- self.assertRaisesRegexp(
- self.failureException, '^Exception not raised$',
- self.assertRaisesRegexp, Exception, re.compile('x'),
+ def testAssertNotRaisesRegex(self):
+ self.assertRaisesRegex(
+ self.failureException, '^Exception not raised by <lambda>$',
+ self.assertRaisesRegex, Exception, re.compile('x'),
lambda: None)
- self.assertRaisesRegexp(
- self.failureException, '^Exception not raised$',
- self.assertRaisesRegexp, Exception, 'x',
- lambda: None)
- self.assertRaisesRegexp(
- self.failureException, '^Exception not raised$',
- self.assertRaisesRegexp, Exception, u'x',
+ self.assertRaisesRegex(
+ self.failureException, '^Exception not raised by <lambda>$',
+ self.assertRaisesRegex, Exception, 'x',
lambda: None)
- def testAssertRaisesRegexpMismatch(self):
+ def testAssertRaisesRegexMismatch(self):
def Stub():
raise Exception('Unexpected')
- self.assertRaisesRegexp(
- self.failureException,
- r'"\^Expected\$" does not match "Unexpected"',
- self.assertRaisesRegexp, Exception, '^Expected$',
- Stub)
- self.assertRaisesRegexp(
+ self.assertRaisesRegex(
self.failureException,
r'"\^Expected\$" does not match "Unexpected"',
- self.assertRaisesRegexp, Exception, u'^Expected$',
+ self.assertRaisesRegex, Exception, '^Expected$',
Stub)
- self.assertRaisesRegexp(
+ self.assertRaisesRegex(
self.failureException,
r'"\^Expected\$" does not match "Unexpected"',
- self.assertRaisesRegexp, Exception,
+ self.assertRaisesRegex, Exception,
re.compile('^Expected$'), Stub)
def testAssertRaisesExcValue(self):
@@ -1014,33 +991,176 @@ test case
self.assertIsInstance(e, ExceptionMock)
self.assertEqual(e.args[0], v)
- def testSynonymAssertMethodNames(self):
- """Test undocumented method name synonyms.
-
- Please do not use these methods names in your own code.
-
- This test confirms their continued existence and functionality
- in order to avoid breaking existing code.
+ def testAssertWarnsCallable(self):
+ def _runtime_warn():
+ warnings.warn("foo", RuntimeWarning)
+ # Success when the right warning is triggered, even several times
+ self.assertWarns(RuntimeWarning, _runtime_warn)
+ self.assertWarns(RuntimeWarning, _runtime_warn)
+ # A tuple of warning classes is accepted
+ self.assertWarns((DeprecationWarning, RuntimeWarning), _runtime_warn)
+ # *args and **kwargs also work
+ self.assertWarns(RuntimeWarning,
+ warnings.warn, "foo", category=RuntimeWarning)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ self.assertWarns(RuntimeWarning, lambda: 0)
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ self.assertWarns(DeprecationWarning, _runtime_warn)
+ # Filters for other warnings are not modified
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises(RuntimeWarning):
+ self.assertWarns(DeprecationWarning, _runtime_warn)
+
+ def testAssertWarnsContext(self):
+ # Believe it or not, it is preferrable to duplicate all tests above,
+ # to make sure the __warningregistry__ $@ is circumvented correctly.
+ def _runtime_warn():
+ warnings.warn("foo", RuntimeWarning)
+ _runtime_warn_lineno = inspect.getsourcelines(_runtime_warn)[1]
+ with self.assertWarns(RuntimeWarning) as cm:
+ _runtime_warn()
+ # A tuple of warning classes is accepted
+ with self.assertWarns((DeprecationWarning, RuntimeWarning)) as cm:
+ _runtime_warn()
+ # The context manager exposes various useful attributes
+ self.assertIsInstance(cm.warning, RuntimeWarning)
+ self.assertEqual(cm.warning.args[0], "foo")
+ self.assertIn("test_case.py", cm.filename)
+ self.assertEqual(cm.lineno, _runtime_warn_lineno + 1)
+ # Same with several warnings
+ with self.assertWarns(RuntimeWarning):
+ _runtime_warn()
+ _runtime_warn()
+ with self.assertWarns(RuntimeWarning):
+ warnings.warn("foo", category=RuntimeWarning)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ with self.assertWarns(RuntimeWarning):
+ pass
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ with self.assertWarns(DeprecationWarning):
+ _runtime_warn()
+ # Filters for other warnings are not modified
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises(RuntimeWarning):
+ with self.assertWarns(DeprecationWarning):
+ _runtime_warn()
+
+ def testAssertWarnsRegexCallable(self):
+ def _runtime_warn(msg):
+ warnings.warn(msg, RuntimeWarning)
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "foox")
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ lambda: 0)
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(DeprecationWarning, "o+",
+ _runtime_warn, "foox")
+ # Failure when message doesn't match
+ with self.assertRaises(self.failureException):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "barz")
+ # A little trickier: we ask RuntimeWarnings to be raised, and then
+ # check for some of them. It is implementation-defined whether
+ # non-matching RuntimeWarnings are simply re-raised, or produce a
+ # failureException.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises((RuntimeWarning, self.failureException)):
+ self.assertWarnsRegex(RuntimeWarning, "o+",
+ _runtime_warn, "barz")
+
+ def testAssertWarnsRegexContext(self):
+ # Same as above, but with assertWarnsRegex as a context manager
+ def _runtime_warn(msg):
+ warnings.warn(msg, RuntimeWarning)
+ _runtime_warn_lineno = inspect.getsourcelines(_runtime_warn)[1]
+ with self.assertWarnsRegex(RuntimeWarning, "o+") as cm:
+ _runtime_warn("foox")
+ self.assertIsInstance(cm.warning, RuntimeWarning)
+ self.assertEqual(cm.warning.args[0], "foox")
+ self.assertIn("test_case.py", cm.filename)
+ self.assertEqual(cm.lineno, _runtime_warn_lineno + 1)
+ # Failure when no warning is triggered
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ pass
+ # Failure when another warning is triggered
+ with warnings.catch_warnings():
+ # Force default filter (in case tests are run with -We)
+ warnings.simplefilter("default", RuntimeWarning)
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(DeprecationWarning, "o+"):
+ _runtime_warn("foox")
+ # Failure when message doesn't match
+ with self.assertRaises(self.failureException):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ _runtime_warn("barz")
+ # A little trickier: we ask RuntimeWarnings to be raised, and then
+ # check for some of them. It is implementation-defined whether
+ # non-matching RuntimeWarnings are simply re-raised, or produce a
+ # failureException.
+ with warnings.catch_warnings():
+ warnings.simplefilter("error", RuntimeWarning)
+ with self.assertRaises((RuntimeWarning, self.failureException)):
+ with self.assertWarnsRegex(RuntimeWarning, "o+"):
+ _runtime_warn("barz")
+
+ def testDeprecatedMethodNames(self):
"""
- self.assertNotEquals(3, 5)
- self.assertEquals(3, 3)
- self.assertAlmostEquals(2.0, 2.0)
- self.assertNotAlmostEquals(3.0, 5.0)
- self.assert_(True)
-
- def testPendingDeprecationMethodNames(self):
- """Test fail* methods pending deprecation, they will warn in 3.2.
-
- Do not use these methods. They will go away in 3.3.
+ Test that the deprecated methods raise a DeprecationWarning. See #9424.
"""
- with test_support.check_warnings():
- self.failIfEqual(3, 5)
- self.failUnlessEqual(3, 3)
- self.failUnlessAlmostEqual(2.0, 2.0)
- self.failIfAlmostEqual(3.0, 5.0)
- self.failUnless(True)
- self.failUnlessRaises(TypeError, lambda _: 3.14 + u'spam')
- self.failIf(False)
+ old = (
+ (self.failIfEqual, (3, 5)),
+ (self.assertNotEquals, (3, 5)),
+ (self.failUnlessEqual, (3, 3)),
+ (self.assertEquals, (3, 3)),
+ (self.failUnlessAlmostEqual, (2.0, 2.0)),
+ (self.assertAlmostEquals, (2.0, 2.0)),
+ (self.failIfAlmostEqual, (3.0, 5.0)),
+ (self.assertNotAlmostEquals, (3.0, 5.0)),
+ (self.failUnless, (True,)),
+ (self.assert_, (True,)),
+ (self.failUnlessRaises, (TypeError, lambda _: 3.14 + 'spam')),
+ (self.failIf, (False,)),
+ (self.assertSameElements, ([1, 1, 2, 3], [1, 2, 3])),
+ (self.assertDictContainsSubset, (dict(a=1, b=2), dict(a=1, b=2, c=3))),
+ (self.assertRaisesRegexp, (KeyError, 'foo', lambda: {}['foo'])),
+ (self.assertRegexpMatches, ('bar', 'bar')),
+ )
+ for meth, args in old:
+ with self.assertWarns(DeprecationWarning):
+ meth(*args)
+
+ def testDeprecatedFailMethods(self):
+ """Test that the deprecated fail* methods get removed in 3.3"""
+ if sys.version_info[:2] < (3, 3):
+ return
+ deprecated_names = [
+ 'failIfEqual', 'failUnlessEqual', 'failUnlessAlmostEqual',
+ 'failIfAlmostEqual', 'failUnless', 'failUnlessRaises', 'failIf',
+ 'assertSameElements', 'assertDictContainsSubset',
+ ]
+ for deprecated_name in deprecated_names:
+ with self.assertRaises(AttributeError):
+ getattr(self, deprecated_name) # remove these in 3.3
def testDeepcopy(self):
# Issue: 5660
@@ -1053,6 +1173,23 @@ test case
# This shouldn't blow up
deepcopy(test)
+ def testPickle(self):
+ # Issue 10326
+
+ # Can't use TestCase classes defined in Test class as
+ # pickle does not work with inner classes
+ test = unittest.TestCase('run')
+ for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
+
+ # blew up prior to fix
+ pickled_test = pickle.dumps(test, protocol=protocol)
+ unpickled_test = pickle.loads(pickled_test)
+ self.assertEqual(test, unpickled_test)
+
+ # exercise the TestCase instance in a way that will invoke
+ # the type equality lookup mechanism
+ unpickled_test.assertEqual(set(), set())
+
def testKeyboardInterrupt(self):
def _raise(self=None):
raise KeyboardInterrupt
@@ -1078,6 +1215,33 @@ test case
with self.assertRaises(KeyboardInterrupt):
klass('test_something').run()
+ def testSkippingEverywhere(self):
+ def _skip(self=None):
+ raise unittest.SkipTest('some reason')
+ def nothing(self):
+ pass
+
+ class Test1(unittest.TestCase):
+ test_something = _skip
+
+ class Test2(unittest.TestCase):
+ setUp = _skip
+ test_something = nothing
+
+ class Test3(unittest.TestCase):
+ test_something = nothing
+ tearDown = _skip
+
+ class Test4(unittest.TestCase):
+ def test_something(self):
+ self.addCleanup(_skip)
+
+ for klass in (Test1, Test2, Test3, Test4):
+ result = unittest.TestResult()
+ klass('test_something').run(result)
+ self.assertEqual(len(result.skipped), 1)
+ self.assertEqual(result.testsRun, 1)
+
def testSystemExit(self):
def _raise(self=None):
raise SystemExit
@@ -1104,21 +1268,3 @@ test case
klass('test_something').run(result)
self.assertEqual(len(result.errors), 1)
self.assertEqual(result.testsRun, 1)
-
- def testPickle(self):
- # Issue 10326
-
- # Can't use TestCase classes defined in Test class as
- # pickle does not work with inner classes
- test = unittest.TestCase('run')
- for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
-
- # blew up prior to fix
- pickled_test = pickle.dumps(test, protocol=protocol)
-
- unpickled_test = pickle.loads(pickled_test)
- self.assertEqual(test, unpickled_test)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Lib/unittest/test/test_discovery.py b/Lib/unittest/test/test_discovery.py
index 1155de116f9..e688f8e35ac 100644
--- a/Lib/unittest/test/test_discovery.py
+++ b/Lib/unittest/test/test_discovery.py
@@ -5,12 +5,23 @@ import sys
import unittest
+class TestableTestProgram(unittest.TestProgram):
+ module = '__main__'
+ exit = True
+ defaultTest = failfast = catchbreak = buffer = None
+ verbosity = 1
+ progName = ''
+ testRunner = testLoader = None
+
+ def __init__(self):
+ pass
+
+
class TestDiscovery(unittest.TestCase):
# Heavily mocked tests so I can avoid hitting the filesystem
def test_get_name_from_path(self):
loader = unittest.TestLoader()
-
loader._top_level_dir = '/foo'
name = loader._get_name_from_path('/foo/bar/baz.py')
self.assertEqual(name, 'bar.baz')
@@ -105,9 +116,6 @@ class TestDiscovery(unittest.TestCase):
def __eq__(self, other):
return self.path == other.path
- # Silence py3k warning
- __hash__ = None
-
loader._get_module_from_name = lambda name: Module(name)
def loadTestsFromModule(module, use_load_tests):
if use_load_tests:
@@ -199,8 +207,7 @@ class TestDiscovery(unittest.TestCase):
test.test_this_does_not_exist()
def test_command_line_handling_parseArgs(self):
- # Haha - take that uninstantiable class
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
args = []
def do_discovery(argv):
@@ -212,13 +219,39 @@ class TestDiscovery(unittest.TestCase):
program.parseArgs(['something', 'discover', 'foo', 'bar'])
self.assertEqual(args, ['foo', 'bar'])
+ def test_command_line_handling_discover_by_default(self):
+ program = TestableTestProgram()
+ program.module = None
+
+ self.called = False
+ def do_discovery(argv):
+ self.called = True
+ self.assertEqual(argv, [])
+ program._do_discovery = do_discovery
+ program.parseArgs(['something'])
+ self.assertTrue(self.called)
+
+ def test_command_line_handling_discover_by_default_with_options(self):
+ program = TestableTestProgram()
+ program.module = None
+
+ args = ['something', '-v', '-b', '-v', '-c', '-f']
+ self.called = False
+ def do_discovery(argv):
+ self.called = True
+ self.assertEqual(argv, args[1:])
+ program._do_discovery = do_discovery
+ program.parseArgs(args)
+ self.assertTrue(self.called)
+
+
def test_command_line_handling_do_discovery_too_many_arguments(self):
class Stop(Exception):
pass
def usageExit():
raise Stop
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program.usageExit = usageExit
with self.assertRaises(Stop):
@@ -227,7 +260,7 @@ class TestDiscovery(unittest.TestCase):
def test_command_line_handling_do_discovery_calls_loader(self):
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
class Loader(object):
args = []
@@ -241,49 +274,49 @@ class TestDiscovery(unittest.TestCase):
self.assertEqual(Loader.args, [('.', 'test*.py', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['--verbose'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('.', 'test*.py', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery([], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('.', 'test*.py', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['fish'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['fish', 'eggs'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('fish', 'eggs', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['fish', 'eggs', 'ham'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('fish', 'eggs', 'ham')])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['-s', 'fish'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('fish', 'test*.py', None)])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['-t', 'fish'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('.', 'test*.py', 'fish')])
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['-p', 'fish'], Loader=Loader)
self.assertEqual(program.test, 'tests')
self.assertEqual(Loader.args, [('.', 'fish', None)])
@@ -291,7 +324,7 @@ class TestDiscovery(unittest.TestCase):
self.assertFalse(program.catchbreak)
Loader.args = []
- program = object.__new__(unittest.TestProgram)
+ program = TestableTestProgram()
program._do_discovery(['-p', 'eggs', '-s', 'fish', '-v', '-f', '-c'],
Loader=Loader)
self.assertEqual(program.test, 'tests')
@@ -334,7 +367,7 @@ class TestDiscovery(unittest.TestCase):
expected_dir = os.path.abspath('foo')
msg = re.escape(r"'foo' module incorrectly imported from %r. Expected %r. "
"Is this module globally installed?" % (mod_dir, expected_dir))
- self.assertRaisesRegexp(
+ self.assertRaisesRegex(
ImportError, '^%s$' % msg, loader.discover,
start_dir='foo', pattern='foo.py'
)
diff --git a/Lib/unittest/test/test_functiontestcase.py b/Lib/unittest/test/test_functiontestcase.py
index 63dd8781509..9ce5ee3556e 100644
--- a/Lib/unittest/test/test_functiontestcase.py
+++ b/Lib/unittest/test/test_functiontestcase.py
@@ -58,8 +58,8 @@ class Test_FunctionTestCase(unittest.TestCase):
def tearDown():
events.append('tearDown')
- expected = ['startTest', 'setUp', 'test', 'addError', 'tearDown',
- 'stopTest']
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addError', 'stopTest']
unittest.FunctionTestCase(test, setUp, tearDown).run(result)
self.assertEqual(events, expected)
@@ -84,8 +84,8 @@ class Test_FunctionTestCase(unittest.TestCase):
def tearDown():
events.append('tearDown')
- expected = ['startTest', 'setUp', 'test', 'addFailure', 'tearDown',
- 'stopTest']
+ expected = ['startTest', 'setUp', 'test', 'tearDown',
+ 'addFailure', 'stopTest']
unittest.FunctionTestCase(test, setUp, tearDown).run(result)
self.assertEqual(events, expected)
@@ -124,7 +124,7 @@ class Test_FunctionTestCase(unittest.TestCase):
def test_id(self):
test = unittest.FunctionTestCase(lambda: None)
- self.assertIsInstance(test.id(), basestring)
+ self.assertIsInstance(test.id(), str)
# "Returns a one-line description of the test, or None if no description
# has been provided. The default implementation of this method returns
@@ -142,7 +142,3 @@ class Test_FunctionTestCase(unittest.TestCase):
test = unittest.FunctionTestCase(lambda: None, description=desc)
self.assertEqual(test.shortDescription(), "this tests foo")
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Lib/unittest/test/test_loader.py b/Lib/unittest/test/test_loader.py
index 3544a20f7cf..f7e31a57f1b 100644
--- a/Lib/unittest/test/test_loader.py
+++ b/Lib/unittest/test/test_loader.py
@@ -186,7 +186,7 @@ class Test_TestLoader(unittest.TestCase):
self.assertEqual(suite.countTestCases(), 1)
test = list(suite)[0]
- self.assertRaisesRegexp(TypeError, "some failure", test.m)
+ self.assertRaisesRegex(TypeError, "some failure", test.m)
################################################################
### /Tests for TestLoader.loadTestsFromModule()
@@ -205,7 +205,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromName('')
- except ValueError, e:
+ except ValueError as e:
self.assertEqual(str(e), "Empty module name")
else:
self.fail("TestLoader.loadTestsFromName failed to raise ValueError")
@@ -238,7 +238,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromName('sdasfasfasdf')
- except ImportError, e:
+ except ImportError as e:
self.assertEqual(str(e), "No module named sdasfasfasdf")
else:
self.fail("TestLoader.loadTestsFromName failed to raise ImportError")
@@ -254,7 +254,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromName('unittest.sdasfasfasdf')
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
else:
self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
@@ -271,7 +271,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromName('sdasfasfasdf', unittest)
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
else:
self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
@@ -292,7 +292,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromName('', unittest)
- except AttributeError:
+ except AttributeError as e:
pass
else:
self.fail("Failed to raise AttributeError")
@@ -425,7 +425,7 @@ class Test_TestLoader(unittest.TestCase):
loader = unittest.TestLoader()
try:
loader.loadTestsFromName('testcase_1.testfoo', m)
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
else:
self.fail("Failed to raise AttributeError")
@@ -512,7 +512,7 @@ class Test_TestLoader(unittest.TestCase):
loader = unittest.TestLoader()
try:
- loader.loadTestsFromName('return_wrong', m)
+ suite = loader.loadTestsFromName('return_wrong', m)
except TypeError:
pass
else:
@@ -583,7 +583,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromNames([''])
- except ValueError, e:
+ except ValueError as e:
self.assertEqual(str(e), "Empty module name")
else:
self.fail("TestLoader.loadTestsFromNames failed to raise ValueError")
@@ -618,7 +618,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromNames(['sdasfasfasdf'])
- except ImportError, e:
+ except ImportError as e:
self.assertEqual(str(e), "No module named sdasfasfasdf")
else:
self.fail("TestLoader.loadTestsFromNames failed to raise ImportError")
@@ -634,7 +634,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromNames(['unittest.sdasfasfasdf', 'unittest'])
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
else:
self.fail("TestLoader.loadTestsFromNames failed to raise AttributeError")
@@ -653,7 +653,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromNames(['sdasfasfasdf'], unittest)
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
else:
self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
@@ -672,7 +672,7 @@ class Test_TestLoader(unittest.TestCase):
try:
loader.loadTestsFromNames(['TestCase', 'sdasfasfasdf'], unittest)
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "'module' object has no attribute 'sdasfasfasdf'")
else:
self.fail("TestLoader.loadTestsFromName failed to raise AttributeError")
@@ -821,7 +821,7 @@ class Test_TestLoader(unittest.TestCase):
loader = unittest.TestLoader()
try:
loader.loadTestsFromNames(['testcase_1.testfoo'], m)
- except AttributeError, e:
+ except AttributeError as e:
self.assertEqual(str(e), "type object 'MyTestCase' has no attribute 'testfoo'")
else:
self.fail("Failed to raise AttributeError")
@@ -895,7 +895,7 @@ class Test_TestLoader(unittest.TestCase):
loader = unittest.TestLoader()
try:
- loader.loadTestsFromNames(['return_wrong'], m)
+ suite = loader.loadTestsFromNames(['return_wrong'], m)
except TypeError:
pass
else:
@@ -1093,7 +1093,7 @@ class Test_TestLoader(unittest.TestCase):
# "The default value is 'test'"
def test_testMethodPrefix__default_value(self):
loader = unittest.TestLoader()
- self.assertTrue(loader.testMethodPrefix == 'test')
+ self.assertEqual(loader.testMethodPrefix, 'test')
################################################################
### /Tests for TestLoader.testMethodPrefix
@@ -1105,7 +1105,7 @@ class Test_TestLoader(unittest.TestCase):
# getTestCaseNames() and all the loadTestsFromX() methods"
def test_sortTestMethodsUsing__loadTestsFromTestCase(self):
def reversed_cmp(x, y):
- return -cmp(x, y)
+ return -((x > y) - (x < y))
class Foo(unittest.TestCase):
def test_1(self): pass
@@ -1121,7 +1121,7 @@ class Test_TestLoader(unittest.TestCase):
# getTestCaseNames() and all the loadTestsFromX() methods"
def test_sortTestMethodsUsing__loadTestsFromModule(self):
def reversed_cmp(x, y):
- return -cmp(x, y)
+ return -((x > y) - (x < y))
m = types.ModuleType('m')
class Foo(unittest.TestCase):
@@ -1139,7 +1139,7 @@ class Test_TestLoader(unittest.TestCase):
# getTestCaseNames() and all the loadTestsFromX() methods"
def test_sortTestMethodsUsing__loadTestsFromName(self):
def reversed_cmp(x, y):
- return -cmp(x, y)
+ return -((x > y) - (x < y))
m = types.ModuleType('m')
class Foo(unittest.TestCase):
@@ -1157,7 +1157,7 @@ class Test_TestLoader(unittest.TestCase):
# getTestCaseNames() and all the loadTestsFromX() methods"
def test_sortTestMethodsUsing__loadTestsFromNames(self):
def reversed_cmp(x, y):
- return -cmp(x, y)
+ return -((x > y) - (x < y))
m = types.ModuleType('m')
class Foo(unittest.TestCase):
@@ -1177,7 +1177,7 @@ class Test_TestLoader(unittest.TestCase):
# Does it actually affect getTestCaseNames()?
def test_sortTestMethodsUsing__getTestCaseNames(self):
def reversed_cmp(x, y):
- return -cmp(x, y)
+ return -((x > y) - (x < y))
class Foo(unittest.TestCase):
def test_1(self): pass
@@ -1190,9 +1190,19 @@ class Test_TestLoader(unittest.TestCase):
self.assertEqual(loader.getTestCaseNames(Foo), test_names)
# "The default value is the built-in cmp() function"
+ # Since cmp is now defunct, we simply verify that the results
+ # occur in the same order as they would with the default sort.
def test_sortTestMethodsUsing__default_value(self):
loader = unittest.TestLoader()
- self.assertTrue(loader.sortTestMethodsUsing is cmp)
+
+ class Foo(unittest.TestCase):
+ def test_2(self): pass
+ def test_3(self): pass
+ def test_1(self): pass
+
+ test_names = ['test_2', 'test_3', 'test_1']
+ self.assertEqual(loader.getTestCaseNames(Foo), sorted(test_names))
+
# "it can be set to None to disable the sort."
#
@@ -1280,7 +1290,3 @@ class Test_TestLoader(unittest.TestCase):
def test_suiteClass__default_value(self):
loader = unittest.TestLoader()
self.assertTrue(loader.suiteClass is unittest.TestSuite)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Lib/unittest/test/test_program.py b/Lib/unittest/test/test_program.py
index 45d90975e7d..d5d0f5a71c1 100644
--- a/Lib/unittest/test/test_program.py
+++ b/Lib/unittest/test/test_program.py
@@ -1,4 +1,4 @@
-from cStringIO import StringIO
+import io
import os
import sys
@@ -68,7 +68,7 @@ class Test_TestProgram(unittest.TestCase):
def test_NonExit(self):
program = unittest.main(exit=False,
argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=StringIO()),
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
testLoader=self.FooBarLoader())
self.assertTrue(hasattr(program, 'result'))
@@ -78,7 +78,7 @@ class Test_TestProgram(unittest.TestCase):
SystemExit,
unittest.main,
argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=StringIO()),
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
exit=True,
testLoader=self.FooBarLoader())
@@ -88,7 +88,7 @@ class Test_TestProgram(unittest.TestCase):
SystemExit,
unittest.main,
argv=["foobar"],
- testRunner=unittest.TextTestRunner(stream=StringIO()),
+ testRunner=unittest.TextTestRunner(stream=io.StringIO()),
testLoader=self.FooBarLoader())
@@ -99,6 +99,7 @@ class InitialisableProgram(unittest.TestProgram):
defaultTest = None
testRunner = None
testLoader = unittest.defaultTestLoader
+ module = '__main__'
progName = 'test'
test = 'test'
def __init__(self, *args):
@@ -182,6 +183,27 @@ class TestCommandLineArgs(unittest.TestCase):
program.parseArgs([None, opt])
self.assertEqual(getattr(program, attr), not_none)
+ def testWarning(self):
+ """Test the warnings argument"""
+ # see #10535
+ class FakeTP(unittest.TestProgram):
+ def parseArgs(self, *args, **kw): pass
+ def runTests(self, *args, **kw): pass
+ warnoptions = sys.warnoptions[:]
+ try:
+ sys.warnoptions[:] = []
+ # no warn options, no arg -> default
+ self.assertEqual(FakeTP().warnings, 'default')
+ # no warn options, w/ arg -> arg value
+ self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+ sys.warnoptions[:] = ['somevalue']
+ # warn options, no arg -> None
+ # warn options, w/ arg -> arg value
+ self.assertEqual(FakeTP().warnings, None)
+ self.assertEqual(FakeTP(warnings='ignore').warnings, 'ignore')
+ finally:
+ sys.warnoptions[:] = warnoptions
+
def testRunTestsRunnerClass(self):
program = self.program
@@ -189,12 +211,14 @@ class TestCommandLineArgs(unittest.TestCase):
program.verbosity = 'verbosity'
program.failfast = 'failfast'
program.buffer = 'buffer'
+ program.warnings = 'warnings'
program.runTests()
self.assertEqual(FakeRunner.initArgs, {'verbosity': 'verbosity',
'failfast': 'failfast',
- 'buffer': 'buffer'})
+ 'buffer': 'buffer',
+ 'warnings': 'warnings'})
self.assertEqual(FakeRunner.test, 'test')
self.assertIs(program.result, RESULT)
@@ -224,7 +248,7 @@ class TestCommandLineArgs(unittest.TestCase):
program.runTests()
- # If initializing raises a type error it should be retried
+ # If initialising raises a type error it should be retried
# without the new keyword arguments
self.assertEqual(FakeRunner.initArgs, {})
self.assertEqual(FakeRunner.test, 'test')
@@ -250,6 +274,85 @@ class TestCommandLineArgs(unittest.TestCase):
program.runTests()
self.assertTrue(self.installed)
+ def _patch_isfile(self, names, exists=True):
+ def isfile(path):
+ return path in names
+ original = os.path.isfile
+ os.path.isfile = isfile
+ def restore():
+ os.path.isfile = original
+ self.addCleanup(restore)
+
+
+ def testParseArgsFileNames(self):
+ # running tests with filenames instead of module names
+ program = self.program
+ argv = ['progname', 'foo.py', 'bar.Py', 'baz.PY', 'wing.txt']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ # note that 'wing.txt' is not a Python file so the name should
+ # *not* be converted to a module name
+ expected = ['foo', 'bar', 'baz', 'wing.txt']
+ self.assertEqual(program.testNames, expected)
+
+
+ def testParseArgsFilePaths(self):
+ program = self.program
+ argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ expected = ['foo.bar.baz', 'green.red']
+ self.assertEqual(program.testNames, expected)
+
+
+ def testParseArgsNonExistentFiles(self):
+ program = self.program
+ argv = ['progname', 'foo/bar/baz.py', 'green\\red.py']
+ self._patch_isfile([])
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ self.assertEqual(program.testNames, argv[1:])
+
+ def testParseArgsAbsolutePathsThatCanBeConverted(self):
+ cur_dir = os.getcwd()
+ program = self.program
+ def _join(name):
+ return os.path.join(cur_dir, name)
+ argv = ['progname', _join('foo/bar/baz.py'), _join('green\\red.py')]
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ expected = ['foo.bar.baz', 'green.red']
+ self.assertEqual(program.testNames, expected)
+
+ def testParseArgsAbsolutePathsThatCannotBeConverted(self):
+ program = self.program
+ # even on Windows '/...' is considered absolute by os.path.abspath
+ argv = ['progname', '/foo/bar/baz.py', '/green/red.py']
+ self._patch_isfile(argv)
+
+ program.createTests = lambda: None
+ program.parseArgs(argv)
+
+ self.assertEqual(program.testNames, argv[1:])
+
+ # it may be better to use platform specific functions to normalise paths
+ # rather than accepting '.PY' and '\' as file seprator on Linux / Mac
+ # it would also be better to check that a filename is a valid module
+ # identifier (we have a regex for this in loader.py)
+ # for invalid filenames should we raise a useful error rather than
+ # leaving the current error message (import of filename fails) in place?
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/unittest/test/test_result.py b/Lib/unittest/test/test_result.py
index eb68c1d01c2..1c58e61bb2b 100644
--- a/Lib/unittest/test/test_result.py
+++ b/Lib/unittest/test/test_result.py
@@ -1,7 +1,8 @@
+import io
import sys
import textwrap
-from StringIO import StringIO
-from test import test_support
+
+from test import support
import traceback
import unittest
@@ -28,7 +29,6 @@ class Test_TestResult(unittest.TestCase):
self.assertIsNone(result._stdout_buffer)
self.assertIsNone(result._stderr_buffer)
-
# "This method can be called to signal that the set of tests being
# run should be aborted by setting the TestResult's shouldStop
# attribute to True."
@@ -289,10 +289,10 @@ class Test_TestResult(unittest.TestCase):
self.assertTrue(result.shouldStop)
def testFailFastSetByRunner(self):
- runner = unittest.TextTestRunner(stream=StringIO(), failfast=True)
+ runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True)
def test(result):
self.assertTrue(result.failfast)
- runner.run(test)
+ result = runner.run(test)
classDict = dict(unittest.TestResult.__dict__)
@@ -313,8 +313,8 @@ OldResult = type('OldResult', (object,), classDict)
class Test_OldTestResult(unittest.TestCase):
def assertOldResultWarning(self, test, failures):
- with test_support.check_warnings(("TestResult has no add.+ method,",
- RuntimeWarning)):
+ with support.check_warnings(("TestResult has no add.+ method,",
+ RuntimeWarning)):
result = OldResult()
test.run(result)
self.assertEqual(len(result.failures), failures)
@@ -356,7 +356,7 @@ class Test_OldTestResult(unittest.TestCase):
def testFoo(self):
pass
runner = unittest.TextTestRunner(resultclass=OldResult,
- stream=StringIO())
+ stream=io.StringIO())
# This will raise an exception if TextTestRunner can't handle old
# test result objects
runner.run(Test('testFoo'))
@@ -412,18 +412,18 @@ class TestOutputBuffering(unittest.TestCase):
self.assertIsNot(real_out, sys.stdout)
self.assertIsNot(real_err, sys.stderr)
- self.assertIsInstance(sys.stdout, StringIO)
- self.assertIsInstance(sys.stderr, StringIO)
+ self.assertIsInstance(sys.stdout, io.StringIO)
+ self.assertIsInstance(sys.stderr, io.StringIO)
self.assertIsNot(sys.stdout, sys.stderr)
out_stream = sys.stdout
err_stream = sys.stderr
- result._original_stdout = StringIO()
- result._original_stderr = StringIO()
+ result._original_stdout = io.StringIO()
+ result._original_stderr = io.StringIO()
- print 'foo'
- print >> sys.stderr, 'bar'
+ print('foo')
+ print('bar', file=sys.stderr)
self.assertEqual(out_stream.getvalue(), 'foo\n')
self.assertEqual(err_stream.getvalue(), 'bar\n')
@@ -463,12 +463,12 @@ class TestOutputBuffering(unittest.TestCase):
result = self.getStartedResult()
buffered_out = sys.stdout
buffered_err = sys.stderr
- result._original_stdout = StringIO()
- result._original_stderr = StringIO()
+ result._original_stdout = io.StringIO()
+ result._original_stderr = io.StringIO()
- print >> sys.stdout, 'foo'
+ print('foo', file=sys.stdout)
if include_error:
- print >> sys.stderr, 'bar'
+ print('bar', file=sys.stderr)
addFunction = getattr(result, add_attr)
@@ -489,6 +489,7 @@ class TestOutputBuffering(unittest.TestCase):
Stderr:
bar
""")
+
expectedFullMessage = 'A traceback%s%s' % (expectedOutMessage, expectedErrMessage)
self.assertIs(test, self)
@@ -503,7 +504,7 @@ class TestOutputBuffering(unittest.TestCase):
class Foo(unittest.TestCase):
@classmethod
def setUpClass(cls):
- 1//0
+ 1/0
def test_foo(self):
pass
suite = unittest.TestSuite([Foo('test_foo')])
@@ -517,7 +518,7 @@ class TestOutputBuffering(unittest.TestCase):
class Foo(unittest.TestCase):
@classmethod
def tearDownClass(cls):
- 1//0
+ 1/0
def test_foo(self):
pass
suite = unittest.TestSuite([Foo('test_foo')])
@@ -534,7 +535,7 @@ class TestOutputBuffering(unittest.TestCase):
class Module(object):
@staticmethod
def setUpModule():
- 1//0
+ 1/0
Foo.__module__ = 'Module'
sys.modules['Module'] = Module
@@ -553,7 +554,7 @@ class TestOutputBuffering(unittest.TestCase):
class Module(object):
@staticmethod
def tearDownModule():
- 1//0
+ 1/0
Foo.__module__ = 'Module'
sys.modules['Module'] = Module
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py
index d1cefae4c17..aed1e76940a 100644
--- a/Lib/unittest/test/test_runner.py
+++ b/Lib/unittest/test/test_runner.py
@@ -1,7 +1,10 @@
-import unittest
-
-from cStringIO import StringIO
+import io
+import os
+import sys
import pickle
+import subprocess
+
+import unittest
from .support import LoggingResult, ResultWithNoStartTestRunStopTestRun
@@ -31,25 +34,20 @@ class TestCleanUp(unittest.TestCase):
[(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')),
(cleanup2, (), {})])
- result = test.doCleanups()
- self.assertTrue(result)
-
- self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3),
- dict(four='hello', five='goodbye'))])
+ self.assertTrue(test.doCleanups())
+ self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))])
def testCleanUpWithErrors(self):
class TestableTest(unittest.TestCase):
def testNothing(self):
pass
- class MockResult(object):
+ class MockOutcome(object):
+ success = True
errors = []
- def addError(self, test, exc_info):
- self.errors.append((test, exc_info))
- result = MockResult()
test = TestableTest('testNothing')
- test._resultForDoCleanups = result
+ test._outcomeForDoCleanups = MockOutcome
exc1 = Exception('foo')
exc2 = Exception('bar')
@@ -63,10 +61,11 @@ class TestCleanUp(unittest.TestCase):
test.addCleanup(cleanup2)
self.assertFalse(test.doCleanups())
+ self.assertFalse(MockOutcome.success)
- (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors)
- self.assertEqual((test1, Type1, instance1), (test, Exception, exc1))
- self.assertEqual((test2, Type2, instance2), (test, Exception, exc2))
+ (Type1, instance1, _), (Type2, instance2, _) = reversed(MockOutcome.errors)
+ self.assertEqual((Type1, instance1), (Exception, exc1))
+ self.assertEqual((Type2, instance2), (Exception, exc2))
def testCleanupInRun(self):
blowUp = False
@@ -145,6 +144,7 @@ class Test_TextTestRunner(unittest.TestCase):
self.assertFalse(runner.failfast)
self.assertFalse(runner.buffer)
self.assertEqual(runner.verbosity, 1)
+ self.assertEqual(runner.warnings, None)
self.assertTrue(runner.descriptions)
self.assertEqual(runner.resultclass, unittest.TextTestResult)
@@ -159,7 +159,7 @@ class Test_TextTestRunner(unittest.TestCase):
# This used to raise an exception due to TextTestResult not passing
# on arguments in its __init__ super call
- ATextResult(None, None, None)
+ ATextResult(None, None, 1)
def testBufferAndFailfast(self):
@@ -167,7 +167,7 @@ class Test_TextTestRunner(unittest.TestCase):
def testFoo(self):
pass
result = unittest.TestResult()
- runner = unittest.TextTestRunner(stream=StringIO(), failfast=True,
+ runner = unittest.TextTestRunner(stream=io.StringIO(), failfast=True,
buffer=True)
# Use our result object
runner._makeResult = lambda: result
@@ -186,7 +186,7 @@ class Test_TextTestRunner(unittest.TestCase):
self.addCleanup(cleanup)
result = unittest.TestResult()
- runner = unittest.TextTestRunner(stream=StringIO())
+ runner = unittest.TextTestRunner(stream=io.StringIO())
# Use our result object
runner._makeResult = lambda: result
@@ -207,7 +207,7 @@ class Test_TextTestRunner(unittest.TestCase):
class Runner(unittest.TextTestRunner):
def __init__(self):
- super(Runner, self).__init__(StringIO())
+ super(Runner, self).__init__(io.StringIO())
def _makeResult(self):
return OldTextResult()
@@ -223,7 +223,7 @@ class Test_TextTestRunner(unittest.TestCase):
class LoggingRunner(unittest.TextTestRunner):
def __init__(self, events):
- super(LoggingRunner, self).__init__(StringIO())
+ super(LoggingRunner, self).__init__(io.StringIO())
self._events = events
def _makeResult(self):
@@ -238,12 +238,10 @@ class Test_TextTestRunner(unittest.TestCase):
def test_pickle_unpickle(self):
# Issue #7197: a TextTestRunner should be (un)pickleable. This is
# required by test_multiprocessing under Windows (in verbose mode).
- from StringIO import StringIO as PickleableIO
- # cStringIO objects are not pickleable, but StringIO objects are.
- stream = PickleableIO("foo")
+ stream = io.StringIO("foo")
runner = unittest.TextTestRunner(stream)
- for protocol in range(pickle.HIGHEST_PROTOCOL + 1):
- s = pickle.dumps(runner, protocol=protocol)
+ for protocol in range(2, pickle.HIGHEST_PROTOCOL + 1):
+ s = pickle.dumps(runner, protocol)
obj = pickle.loads(s)
# StringIO objects never compare equal, a cheap test instead.
self.assertEqual(obj.stream.getvalue(), stream.getvalue())
@@ -261,6 +259,73 @@ class Test_TextTestRunner(unittest.TestCase):
expectedresult = (runner.stream, DESCRIPTIONS, VERBOSITY)
self.assertEqual(runner._makeResult(), expectedresult)
-
-if __name__ == '__main__':
- unittest.main()
+ def test_warnings(self):
+ """
+ Check that warnings argument of TextTestRunner correctly affects the
+ behavior of the warnings.
+ """
+ # see #10535 and the _test_warnings file for more information
+
+ def get_parse_out_err(p):
+ return [b.splitlines() for b in p.communicate()]
+ opts = dict(stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ cwd=os.path.dirname(__file__))
+ ae_msg = b'Please use assertEqual instead.'
+ at_msg = b'Please use assertTrue instead.'
+
+ # no args -> all the warnings are printed, unittest warnings only once
+ p = subprocess.Popen([sys.executable, '_test_warnings.py'], **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ # check that the total number of warnings in the output is correct
+ self.assertEqual(len(out), 12)
+ # check that the numbers of the different kind of warnings is correct
+ for msg in [b'dw', b'iw', b'uw']:
+ self.assertEqual(out.count(msg), 3)
+ for msg in [ae_msg, at_msg, b'rw']:
+ self.assertEqual(out.count(msg), 1)
+
+ args_list = (
+ # passing 'ignore' as warnings arg -> no warnings
+ [sys.executable, '_test_warnings.py', 'ignore'],
+ # -W doesn't affect the result if the arg is passed
+ [sys.executable, '-Wa', '_test_warnings.py', 'ignore'],
+ # -W affects the result if the arg is not passed
+ [sys.executable, '-Wi', '_test_warnings.py']
+ )
+ # in all these cases no warnings are printed
+ for args in args_list:
+ p = subprocess.Popen(args, **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ self.assertEqual(len(out), 0)
+
+
+ # passing 'always' as warnings arg -> all the warnings printed,
+ # unittest warnings only once
+ p = subprocess.Popen([sys.executable, '_test_warnings.py', 'always'],
+ **opts)
+ out, err = get_parse_out_err(p)
+ self.assertIn(b'OK', err)
+ self.assertEqual(len(out), 14)
+ for msg in [b'dw', b'iw', b'uw', b'rw']:
+ self.assertEqual(out.count(msg), 3)
+ for msg in [ae_msg, at_msg]:
+ self.assertEqual(out.count(msg), 1)
+
+ def testStdErrLookedUpAtInstantiationTime(self):
+ # see issue 10786
+ old_stderr = sys.stderr
+ f = io.StringIO()
+ sys.stderr = f
+ try:
+ runner = unittest.TextTestRunner()
+ self.assertTrue(runner.stream.stream is f)
+ finally:
+ sys.stderr = old_stderr
+
+ def testSpecifiedStreamUsed(self):
+ # see issue 10786
+ f = io.StringIO()
+ runner = unittest.TextTestRunner(f)
+ self.assertTrue(runner.stream.stream is f)
diff --git a/Lib/unittest/test/test_setups.py b/Lib/unittest/test/test_setups.py
index 9456819ea16..b8d5aa41e94 100644
--- a/Lib/unittest/test/test_setups.py
+++ b/Lib/unittest/test/test_setups.py
@@ -1,7 +1,6 @@
+import io
import sys
-from cStringIO import StringIO
-
import unittest
@@ -13,7 +12,7 @@ class TestSetups(unittest.TestCase):
def getRunner(self):
return unittest.TextTestRunner(resultclass=resultFactory,
- stream=StringIO())
+ stream=io.StringIO())
def runTests(self, *cases):
suite = unittest.TestSuite()
for case in cases:
@@ -501,7 +500,7 @@ class TestSetups(unittest.TestCase):
messages = ('setUpModule', 'tearDownModule', 'setUpClass', 'tearDownClass', 'test_something')
for phase, msg in enumerate(messages):
- with self.assertRaisesRegexp(Exception, msg):
+ with self.assertRaisesRegex(Exception, msg):
suite.debug()
if __name__ == '__main__':
diff --git a/Lib/unittest/test/test_skipping.py b/Lib/unittest/test/test_skipping.py
index d6639d17e55..952240eeede 100644
--- a/Lib/unittest/test/test_skipping.py
+++ b/Lib/unittest/test/test_skipping.py
@@ -66,7 +66,7 @@ class Test_TestSkipping(unittest.TestCase):
self.assertEqual(result.skipped, [(test, "testing")])
self.assertEqual(record, [])
- def test_skip_non_unittest_class_old_style(self):
+ def test_skip_non_unittest_class(self):
@unittest.skip("testing")
class Mixin:
def test_1(self):
@@ -81,21 +81,6 @@ class Test_TestSkipping(unittest.TestCase):
self.assertEqual(result.skipped, [(test, "testing")])
self.assertEqual(record, [])
- def test_skip_non_unittest_class_new_style(self):
- @unittest.skip("testing")
- class Mixin(object):
- def test_1(self):
- record.append(1)
- class Foo(Mixin, unittest.TestCase):
- pass
- record = []
- result = unittest.TestResult()
- test = Foo("test_1")
- suite = unittest.TestSuite([test])
- suite.run(result)
- self.assertEqual(result.skipped, [(test, "testing")])
- self.assertEqual(record, [])
-
def test_expected_failure(self):
class Foo(unittest.TestCase):
@unittest.expectedFailure
@@ -162,7 +147,3 @@ class Test_TestSkipping(unittest.TestCase):
suite = unittest.TestSuite([test])
suite.run(result)
self.assertEqual(result.skipped, [(test, "testing")])
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/Lib/unittest/test/test_suite.py b/Lib/unittest/test/test_suite.py
index 72fb527a685..2db978ddb8a 100644
--- a/Lib/unittest/test/test_suite.py
+++ b/Lib/unittest/test/test_suite.py
@@ -26,15 +26,15 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
################################################################
# Used by TestEquality.test_eq
- eq_pairs = [(unittest.TestSuite(), unittest.TestSuite()),
- (unittest.TestSuite(), unittest.TestSuite([])),
- (_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
+ eq_pairs = [(unittest.TestSuite(), unittest.TestSuite())
+ ,(unittest.TestSuite(), unittest.TestSuite([]))
+ ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_1'))]
# Used by TestEquality.test_ne
- ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1')),
- (unittest.TestSuite([]), _mk_TestSuite('test_1')),
- (_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3')),
- (_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
+ ne_pairs = [(unittest.TestSuite(), _mk_TestSuite('test_1'))
+ ,(unittest.TestSuite([]), _mk_TestSuite('test_1'))
+ ,(_mk_TestSuite('test_1', 'test_2'), _mk_TestSuite('test_1', 'test_3'))
+ ,(_mk_TestSuite('test_1'), _mk_TestSuite('test_2'))]
################################################################
### /Set up attributes needed by inherited tests
@@ -363,5 +363,6 @@ class Test_TestSuite(unittest.TestCase, TestEquality):
self.assertFalse(result._testRunEntered)
+
if __name__ == '__main__':
unittest.main()
diff --git a/Lib/unittest/util.py b/Lib/unittest/util.py
index 220a024e903..ccdf0b81fa8 100644
--- a/Lib/unittest/util.py
+++ b/Lib/unittest/util.py
@@ -1,6 +1,6 @@
"""Various utility functions."""
-from collections import namedtuple, OrderedDict
+from collections import namedtuple, OrderedDict
__unittest = True
@@ -14,7 +14,6 @@ def safe_repr(obj, short=False):
return result
return result[:_MAX_LENGTH] + ' [truncated]...'
-
def strclass(cls):
return "%s.%s" % (cls.__module__, cls.__name__)
@@ -59,42 +58,27 @@ def sorted_list_difference(expected, actual):
return missing, unexpected
-def unorderable_list_difference(expected, actual, ignore_duplicate=False):
+def unorderable_list_difference(expected, actual):
"""Same behavior as sorted_list_difference but
for lists of unorderable items (like dicts).
As it does a linear search per item (remove) it
- has O(n*n) performance.
- """
+ has O(n*n) performance."""
missing = []
- unexpected = []
while expected:
item = expected.pop()
try:
actual.remove(item)
except ValueError:
missing.append(item)
- if ignore_duplicate:
- for lst in expected, actual:
- try:
- while True:
- lst.remove(item)
- except ValueError:
- pass
- if ignore_duplicate:
- while actual:
- item = actual.pop()
- unexpected.append(item)
- try:
- while True:
- actual.remove(item)
- except ValueError:
- pass
- return missing, unexpected
# anything left in actual is unexpected
return missing, actual
+def three_way_cmp(x, y):
+ """Return -1 if x < y, 0 if x == y and 1 if x > y"""
+ return (x > y) - (x < y)
+
_Mismatch = namedtuple('Mismatch', 'actual expected value')
def _count_diff_all_purpose(actual, expected):
diff --git a/Lib/urllib.py b/Lib/urllib.py
deleted file mode 100644
index 33641a57001..00000000000
--- a/Lib/urllib.py
+++ /dev/null
@@ -1,1602 +0,0 @@
-"""Open an arbitrary URL.
-
-See the following document for more info on URLs:
-"Names and Addresses, URIs, URLs, URNs, URCs", at
-http://www.w3.org/pub/WWW/Addressing/Overview.html
-
-See also the HTTP spec (from which the error codes are derived):
-"HTTP - Hypertext Transfer Protocol", at
-http://www.w3.org/pub/WWW/Protocols/
-
-Related standards and specs:
-- RFC1808: the "relative URL" spec. (authoritative status)
-- RFC1738 - the "URL standard". (authoritative status)
-- RFC1630 - the "URI spec". (informational status)
-
-The object returned by URLopener().open(file) will differ per
-protocol. All you know is that is has methods read(), readline(),
-readlines(), fileno(), close() and info(). The read*(), fileno()
-and close() methods work like those of open files.
-The info() method returns a mimetools.Message object which can be
-used to query various info about the object, if available.
-(mimetools.Message objects are queried with the getheader() method.)
-"""
-
-import string
-import socket
-import os
-import time
-import sys
-import base64
-
-from urlparse import urljoin as basejoin
-
-__all__ = ["urlopen", "URLopener", "FancyURLopener", "urlretrieve",
- "urlcleanup", "quote", "quote_plus", "unquote", "unquote_plus",
- "urlencode", "url2pathname", "pathname2url", "splittag",
- "localhost", "thishost", "ftperrors", "basejoin", "unwrap",
- "splittype", "splithost", "splituser", "splitpasswd", "splitport",
- "splitnport", "splitquery", "splitattr", "splitvalue",
- "getproxies"]
-
-__version__ = '1.17' # XXX This version is not always updated :-(
-
-MAXFTPCACHE = 10 # Trim the ftp cache beyond this size
-
-# Helper for non-unix systems
-if os.name == 'nt':
- from nturl2path import url2pathname, pathname2url
-elif os.name == 'riscos':
- from rourl2path import url2pathname, pathname2url
-else:
- def url2pathname(pathname):
- """OS-specific conversion from a relative URL of the 'file' scheme
- to a file system path; not recommended for general use."""
- return unquote(pathname)
-
- def pathname2url(pathname):
- """OS-specific conversion from a file system path to a relative URL
- of the 'file' scheme; not recommended for general use."""
- return quote(pathname)
-
-# This really consists of two pieces:
-# (1) a class which handles opening of all sorts of URLs
-# (plus assorted utilities etc.)
-# (2) a set of functions for parsing URLs
-# XXX Should these be separated out into different modules?
-
-
-# Shortcut for basic usage
-_urlopener = None
-def urlopen(url, data=None, proxies=None):
- """Create a file-like object for the specified URL to read from."""
- from warnings import warnpy3k
- warnpy3k("urllib.urlopen() has been removed in Python 3.0 in "
- "favor of urllib2.urlopen()", stacklevel=2)
-
- global _urlopener
- if proxies is not None:
- opener = FancyURLopener(proxies=proxies)
- elif not _urlopener:
- opener = FancyURLopener()
- _urlopener = opener
- else:
- opener = _urlopener
- if data is None:
- return opener.open(url)
- else:
- return opener.open(url, data)
-def urlretrieve(url, filename=None, reporthook=None, data=None):
- global _urlopener
- if not _urlopener:
- _urlopener = FancyURLopener()
- return _urlopener.retrieve(url, filename, reporthook, data)
-def urlcleanup():
- if _urlopener:
- _urlopener.cleanup()
- _safe_quoters.clear()
- ftpcache.clear()
-
-# check for SSL
-try:
- import ssl
-except:
- _have_ssl = False
-else:
- _have_ssl = True
-
-# exception raised when downloaded size does not match content-length
-class ContentTooShortError(IOError):
- def __init__(self, message, content):
- IOError.__init__(self, message)
- self.content = content
-
-ftpcache = {}
-class URLopener:
- """Class to open URLs.
- This is a class rather than just a subroutine because we may need
- more than one set of global protocol-specific options.
- Note -- this is a base class for those who don't want the
- automatic handling of errors type 302 (relocated) and 401
- (authorization needed)."""
-
- __tempfiles = None
-
- version = "Python-urllib/%s" % __version__
-
- # Constructor
- def __init__(self, proxies=None, **x509):
- if proxies is None:
- proxies = getproxies()
- assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
- self.proxies = proxies
- self.key_file = x509.get('key_file')
- self.cert_file = x509.get('cert_file')
- self.addheaders = [('User-Agent', self.version)]
- self.__tempfiles = []
- self.__unlink = os.unlink # See cleanup()
- self.tempcache = None
- # Undocumented feature: if you assign {} to tempcache,
- # it is used to cache files retrieved with
- # self.retrieve(). This is not enabled by default
- # since it does not work for changing documents (and I
- # haven't got the logic to check expiration headers
- # yet).
- self.ftpcache = ftpcache
- # Undocumented feature: you can use a different
- # ftp cache by assigning to the .ftpcache member;
- # in case you want logically independent URL openers
- # XXX This is not threadsafe. Bah.
-
- def __del__(self):
- self.close()
-
- def close(self):
- self.cleanup()
-
- def cleanup(self):
- # This code sometimes runs when the rest of this module
- # has already been deleted, so it can't use any globals
- # or import anything.
- if self.__tempfiles:
- for file in self.__tempfiles:
- try:
- self.__unlink(file)
- except OSError:
- pass
- del self.__tempfiles[:]
- if self.tempcache:
- self.tempcache.clear()
-
- def addheader(self, *args):
- """Add a header to be used by the HTTP interface only
- e.g. u.addheader('Accept', 'sound/basic')"""
- self.addheaders.append(args)
-
- # External interface
- def open(self, fullurl, data=None):
- """Use URLopener().open(file) instead of open(file, 'r')."""
- fullurl = unwrap(toBytes(fullurl))
- # percent encode url, fixing lame server errors for e.g, like space
- # within url paths.
- fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
- if self.tempcache and fullurl in self.tempcache:
- filename, headers = self.tempcache[fullurl]
- fp = open(filename, 'rb')
- return addinfourl(fp, headers, fullurl)
- urltype, url = splittype(fullurl)
- if not urltype:
- urltype = 'file'
- if urltype in self.proxies:
- proxy = self.proxies[urltype]
- urltype, proxyhost = splittype(proxy)
- host, selector = splithost(proxyhost)
- url = (host, fullurl) # Signal special case to open_*()
- else:
- proxy = None
- name = 'open_' + urltype
- self.type = urltype
- name = name.replace('-', '_')
- if not hasattr(self, name):
- if proxy:
- return self.open_unknown_proxy(proxy, fullurl, data)
- else:
- return self.open_unknown(fullurl, data)
- try:
- if data is None:
- return getattr(self, name)(url)
- else:
- return getattr(self, name)(url, data)
- except socket.error, msg:
- raise IOError, ('socket error', msg), sys.exc_info()[2]
-
- def open_unknown(self, fullurl, data=None):
- """Overridable interface to open unknown URL type."""
- type, url = splittype(fullurl)
- raise IOError, ('url error', 'unknown url type', type)
-
- def open_unknown_proxy(self, proxy, fullurl, data=None):
- """Overridable interface to open unknown URL type."""
- type, url = splittype(fullurl)
- raise IOError, ('url error', 'invalid proxy for %s' % type, proxy)
-
- # External interface
- def retrieve(self, url, filename=None, reporthook=None, data=None):
- """retrieve(url) returns (filename, headers) for a local object
- or (tempfilename, headers) for a remote object."""
- url = unwrap(toBytes(url))
- if self.tempcache and url in self.tempcache:
- return self.tempcache[url]
- type, url1 = splittype(url)
- if filename is None and (not type or type == 'file'):
- try:
- fp = self.open_local_file(url1)
- hdrs = fp.info()
- fp.close()
- return url2pathname(splithost(url1)[1]), hdrs
- except IOError:
- pass
- fp = self.open(url, data)
- try:
- headers = fp.info()
- if filename:
- tfp = open(filename, 'wb')
- else:
- import tempfile
- garbage, path = splittype(url)
- garbage, path = splithost(path or "")
- path, garbage = splitquery(path or "")
- path, garbage = splitattr(path or "")
- suffix = os.path.splitext(path)[1]
- (fd, filename) = tempfile.mkstemp(suffix)
- self.__tempfiles.append(filename)
- tfp = os.fdopen(fd, 'wb')
- try:
- result = filename, headers
- if self.tempcache is not None:
- self.tempcache[url] = result
- bs = 1024*8
- size = -1
- read = 0
- blocknum = 0
- if "content-length" in headers:
- size = int(headers["Content-Length"])
- if reporthook:
- reporthook(blocknum, bs, size)
- while 1:
- block = fp.read(bs)
- if block == "":
- break
- read += len(block)
- tfp.write(block)
- blocknum += 1
- if reporthook:
- reporthook(blocknum, bs, size)
- finally:
- tfp.close()
- finally:
- fp.close()
-
- # raise exception if actual size does not match content-length header
- if size >= 0 and read < size:
- raise ContentTooShortError("retrieval incomplete: got only %i out "
- "of %i bytes" % (read, size), result)
-
- return result
-
- # Each method named open_<type> knows how to open that type of URL
-
- def open_http(self, url, data=None):
- """Use HTTP protocol."""
- import httplib
- user_passwd = None
- proxy_passwd= None
- if isinstance(url, str):
- host, selector = splithost(url)
- if host:
- user_passwd, host = splituser(host)
- host = unquote(host)
- realhost = host
- else:
- host, selector = url
- # check whether the proxy contains authorization information
- proxy_passwd, host = splituser(host)
- # now we proceed with the url we want to obtain
- urltype, rest = splittype(selector)
- url = rest
- user_passwd = None
- if urltype.lower() != 'http':
- realhost = None
- else:
- realhost, rest = splithost(rest)
- if realhost:
- user_passwd, realhost = splituser(realhost)
- if user_passwd:
- selector = "%s://%s%s" % (urltype, realhost, rest)
- if proxy_bypass(realhost):
- host = realhost
-
- #print "proxy via http:", host, selector
- if not host: raise IOError, ('http error', 'no host given')
-
- if proxy_passwd:
- proxy_passwd = unquote(proxy_passwd)
- proxy_auth = base64.b64encode(proxy_passwd).strip()
- else:
- proxy_auth = None
-
- if user_passwd:
- user_passwd = unquote(user_passwd)
- auth = base64.b64encode(user_passwd).strip()
- else:
- auth = None
- h = httplib.HTTP(host)
- if data is not None:
- h.putrequest('POST', selector)
- h.putheader('Content-Type', 'application/x-www-form-urlencoded')
- h.putheader('Content-Length', '%d' % len(data))
- else:
- h.putrequest('GET', selector)
- if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
- if auth: h.putheader('Authorization', 'Basic %s' % auth)
- if realhost: h.putheader('Host', realhost)
- for args in self.addheaders: h.putheader(*args)
- h.endheaders(data)
- errcode, errmsg, headers = h.getreply()
- fp = h.getfile()
- if errcode == -1:
- if fp: fp.close()
- # something went wrong with the HTTP status line
- raise IOError, ('http protocol error', 0,
- 'got a bad status line', None)
- # According to RFC 2616, "2xx" code indicates that the client's
- # request was successfully received, understood, and accepted.
- if (200 <= errcode < 300):
- return addinfourl(fp, headers, "http:" + url, errcode)
- else:
- if data is None:
- return self.http_error(url, fp, errcode, errmsg, headers)
- else:
- return self.http_error(url, fp, errcode, errmsg, headers, data)
-
- def http_error(self, url, fp, errcode, errmsg, headers, data=None):
- """Handle http errors.
- Derived class can override this, or provide specific handlers
- named http_error_DDD where DDD is the 3-digit error code."""
- # First check if there's a specific handler for this error
- name = 'http_error_%d' % errcode
- if hasattr(self, name):
- method = getattr(self, name)
- if data is None:
- result = method(url, fp, errcode, errmsg, headers)
- else:
- result = method(url, fp, errcode, errmsg, headers, data)
- if result: return result
- return self.http_error_default(url, fp, errcode, errmsg, headers)
-
- def http_error_default(self, url, fp, errcode, errmsg, headers):
- """Default error handler: close the connection and raise IOError."""
- fp.close()
- raise IOError, ('http error', errcode, errmsg, headers)
-
- if _have_ssl:
- def open_https(self, url, data=None):
- """Use HTTPS protocol."""
-
- import httplib
- user_passwd = None
- proxy_passwd = None
- if isinstance(url, str):
- host, selector = splithost(url)
- if host:
- user_passwd, host = splituser(host)
- host = unquote(host)
- realhost = host
- else:
- host, selector = url
- # here, we determine, whether the proxy contains authorization information
- proxy_passwd, host = splituser(host)
- urltype, rest = splittype(selector)
- url = rest
- user_passwd = None
- if urltype.lower() != 'https':
- realhost = None
- else:
- realhost, rest = splithost(rest)
- if realhost:
- user_passwd, realhost = splituser(realhost)
- if user_passwd:
- selector = "%s://%s%s" % (urltype, realhost, rest)
- #print "proxy via https:", host, selector
- if not host: raise IOError, ('https error', 'no host given')
- if proxy_passwd:
- proxy_passwd = unquote(proxy_passwd)
- proxy_auth = base64.b64encode(proxy_passwd).strip()
- else:
- proxy_auth = None
- if user_passwd:
- user_passwd = unquote(user_passwd)
- auth = base64.b64encode(user_passwd).strip()
- else:
- auth = None
- h = httplib.HTTPS(host, 0,
- key_file=self.key_file,
- cert_file=self.cert_file)
- if data is not None:
- h.putrequest('POST', selector)
- h.putheader('Content-Type',
- 'application/x-www-form-urlencoded')
- h.putheader('Content-Length', '%d' % len(data))
- else:
- h.putrequest('GET', selector)
- if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
- if auth: h.putheader('Authorization', 'Basic %s' % auth)
- if realhost: h.putheader('Host', realhost)
- for args in self.addheaders: h.putheader(*args)
- h.endheaders(data)
- errcode, errmsg, headers = h.getreply()
- fp = h.getfile()
- if errcode == -1:
- if fp: fp.close()
- # something went wrong with the HTTP status line
- raise IOError, ('http protocol error', 0,
- 'got a bad status line', None)
- # According to RFC 2616, "2xx" code indicates that the client's
- # request was successfully received, understood, and accepted.
- if (200 <= errcode < 300):
- return addinfourl(fp, headers, "https:" + url, errcode)
- else:
- if data is None:
- return self.http_error(url, fp, errcode, errmsg, headers)
- else:
- return self.http_error(url, fp, errcode, errmsg, headers,
- data)
-
- def open_file(self, url):
- """Use local file or FTP depending on form of URL."""
- if not isinstance(url, str):
- raise IOError, ('file error', 'proxy support for file protocol currently not implemented')
- if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
- return self.open_ftp(url)
- else:
- return self.open_local_file(url)
-
- def open_local_file(self, url):
- """Use local file."""
- import mimetypes, mimetools, email.utils
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- host, file = splithost(url)
- localname = url2pathname(file)
- try:
- stats = os.stat(localname)
- except OSError, e:
- raise IOError(e.errno, e.strerror, e.filename)
- size = stats.st_size
- modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
- mtype = mimetypes.guess_type(url)[0]
- headers = mimetools.Message(StringIO(
- 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
- (mtype or 'text/plain', size, modified)))
- if not host:
- urlfile = file
- if file[:1] == '/':
- urlfile = 'file://' + file
- elif file[:2] == './':
- raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)
- return addinfourl(open(localname, 'rb'),
- headers, urlfile)
- host, port = splitport(host)
- if not port \
- and socket.gethostbyname(host) in (localhost(), thishost()):
- urlfile = file
- if file[:1] == '/':
- urlfile = 'file://' + file
- return addinfourl(open(localname, 'rb'),
- headers, urlfile)
- raise IOError, ('local file error', 'not on local host')
-
- def open_ftp(self, url):
- """Use FTP protocol."""
- if not isinstance(url, str):
- raise IOError, ('ftp error', 'proxy support for ftp protocol currently not implemented')
- import mimetypes, mimetools
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- host, path = splithost(url)
- if not host: raise IOError, ('ftp error', 'no host given')
- host, port = splitport(host)
- user, host = splituser(host)
- if user: user, passwd = splitpasswd(user)
- else: passwd = None
- host = unquote(host)
- user = user or ''
- passwd = passwd or ''
- host = socket.gethostbyname(host)
- if not port:
- import ftplib
- port = ftplib.FTP_PORT
- else:
- port = int(port)
- path, attrs = splitattr(path)
- path = unquote(path)
- dirs = path.split('/')
- dirs, file = dirs[:-1], dirs[-1]
- if dirs and not dirs[0]: dirs = dirs[1:]
- if dirs and not dirs[0]: dirs[0] = '/'
- key = user, host, port, '/'.join(dirs)
- # XXX thread unsafe!
- if len(self.ftpcache) > MAXFTPCACHE:
- # Prune the cache, rather arbitrarily
- for k in self.ftpcache.keys():
- if k != key:
- v = self.ftpcache[k]
- del self.ftpcache[k]
- v.close()
- try:
- if not key in self.ftpcache:
- self.ftpcache[key] = \
- ftpwrapper(user, passwd, host, port, dirs)
- if not file: type = 'D'
- else: type = 'I'
- for attr in attrs:
- attr, value = splitvalue(attr)
- if attr.lower() == 'type' and \
- value in ('a', 'A', 'i', 'I', 'd', 'D'):
- type = value.upper()
- (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
- mtype = mimetypes.guess_type("ftp:" + url)[0]
- headers = ""
- if mtype:
- headers += "Content-Type: %s\n" % mtype
- if retrlen is not None and retrlen >= 0:
- headers += "Content-Length: %d\n" % retrlen
- headers = mimetools.Message(StringIO(headers))
- return addinfourl(fp, headers, "ftp:" + url)
- except ftperrors(), msg:
- raise IOError, ('ftp error', msg), sys.exc_info()[2]
-
- def open_data(self, url, data=None):
- """Use "data" URL."""
- if not isinstance(url, str):
- raise IOError, ('data error', 'proxy support for data protocol currently not implemented')
- # ignore POSTed data
- #
- # syntax of data URLs:
- # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
- # mediatype := [ type "/" subtype ] *( ";" parameter )
- # data := *urlchar
- # parameter := attribute "=" value
- import mimetools
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- try:
- [type, data] = url.split(',', 1)
- except ValueError:
- raise IOError, ('data error', 'bad data URL')
- if not type:
- type = 'text/plain;charset=US-ASCII'
- semi = type.rfind(';')
- if semi >= 0 and '=' not in type[semi:]:
- encoding = type[semi+1:]
- type = type[:semi]
- else:
- encoding = ''
- msg = []
- msg.append('Date: %s'%time.strftime('%a, %d %b %Y %H:%M:%S GMT',
- time.gmtime(time.time())))
- msg.append('Content-type: %s' % type)
- if encoding == 'base64':
- data = base64.decodestring(data)
- else:
- data = unquote(data)
- msg.append('Content-Length: %d' % len(data))
- msg.append('')
- msg.append(data)
- msg = '\n'.join(msg)
- f = StringIO(msg)
- headers = mimetools.Message(f, 0)
- #f.fileno = None # needed for addinfourl
- return addinfourl(f, headers, url)
-
-
-class FancyURLopener(URLopener):
- """Derived class with handlers for errors we can handle (perhaps)."""
-
- def __init__(self, *args, **kwargs):
- URLopener.__init__(self, *args, **kwargs)
- self.auth_cache = {}
- self.tries = 0
- self.maxtries = 10
-
- def http_error_default(self, url, fp, errcode, errmsg, headers):
- """Default error handling -- don't raise an exception."""
- return addinfourl(fp, headers, "http:" + url, errcode)
-
- def http_error_302(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 302 -- relocated (temporarily)."""
- self.tries += 1
- if self.maxtries and self.tries >= self.maxtries:
- if hasattr(self, "http_error_500"):
- meth = self.http_error_500
- else:
- meth = self.http_error_default
- self.tries = 0
- return meth(url, fp, 500,
- "Internal Server Error: Redirect Recursion", headers)
- result = self.redirect_internal(url, fp, errcode, errmsg, headers,
- data)
- self.tries = 0
- return result
-
- def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
- if 'location' in headers:
- newurl = headers['location']
- elif 'uri' in headers:
- newurl = headers['uri']
- else:
- return
- fp.close()
- # In case the server sent a relative URL, join with original:
- newurl = basejoin(self.type + ":" + url, newurl)
-
- # For security reasons we do not allow redirects to protocols
- # other than HTTP, HTTPS or FTP.
- newurl_lower = newurl.lower()
- if not (newurl_lower.startswith('http://') or
- newurl_lower.startswith('https://') or
- newurl_lower.startswith('ftp://')):
- raise IOError('redirect error', errcode,
- errmsg + " - Redirection to url '%s' is not allowed" %
- newurl,
- headers)
-
- return self.open(newurl)
-
- def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 301 -- also relocated (permanently)."""
- return self.http_error_302(url, fp, errcode, errmsg, headers, data)
-
- def http_error_303(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 303 -- also relocated (essentially identical to 302)."""
- return self.http_error_302(url, fp, errcode, errmsg, headers, data)
-
- def http_error_307(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 307 -- relocated, but turn POST into error."""
- if data is None:
- return self.http_error_302(url, fp, errcode, errmsg, headers, data)
- else:
- return self.http_error_default(url, fp, errcode, errmsg, headers)
-
- def http_error_401(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 401 -- authentication required.
- This function supports Basic authentication only."""
- if not 'www-authenticate' in headers:
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- stuff = headers['www-authenticate']
- import re
- match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
- if not match:
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- scheme, realm = match.groups()
- if scheme.lower() != 'basic':
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- name = 'retry_' + self.type + '_basic_auth'
- if data is None:
- return getattr(self,name)(url, realm)
- else:
- return getattr(self,name)(url, realm, data)
-
- def http_error_407(self, url, fp, errcode, errmsg, headers, data=None):
- """Error 407 -- proxy authentication required.
- This function supports Basic authentication only."""
- if not 'proxy-authenticate' in headers:
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- stuff = headers['proxy-authenticate']
- import re
- match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
- if not match:
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- scheme, realm = match.groups()
- if scheme.lower() != 'basic':
- URLopener.http_error_default(self, url, fp,
- errcode, errmsg, headers)
- name = 'retry_proxy_' + self.type + '_basic_auth'
- if data is None:
- return getattr(self,name)(url, realm)
- else:
- return getattr(self,name)(url, realm, data)
-
- def retry_proxy_http_basic_auth(self, url, realm, data=None):
- host, selector = splithost(url)
- newurl = 'http://' + host + selector
- proxy = self.proxies['http']
- urltype, proxyhost = splittype(proxy)
- proxyhost, proxyselector = splithost(proxyhost)
- i = proxyhost.find('@') + 1
- proxyhost = proxyhost[i:]
- user, passwd = self.get_user_passwd(proxyhost, realm, i)
- if not (user or passwd): return None
- proxyhost = quote(user, safe='') + ':' + quote(passwd, safe='') + '@' + proxyhost
- self.proxies['http'] = 'http://' + proxyhost + proxyselector
- if data is None:
- return self.open(newurl)
- else:
- return self.open(newurl, data)
-
- def retry_proxy_https_basic_auth(self, url, realm, data=None):
- host, selector = splithost(url)
- newurl = 'https://' + host + selector
- proxy = self.proxies['https']
- urltype, proxyhost = splittype(proxy)
- proxyhost, proxyselector = splithost(proxyhost)
- i = proxyhost.find('@') + 1
- proxyhost = proxyhost[i:]
- user, passwd = self.get_user_passwd(proxyhost, realm, i)
- if not (user or passwd): return None
- proxyhost = quote(user, safe='') + ':' + quote(passwd, safe='') + '@' + proxyhost
- self.proxies['https'] = 'https://' + proxyhost + proxyselector
- if data is None:
- return self.open(newurl)
- else:
- return self.open(newurl, data)
-
- def retry_http_basic_auth(self, url, realm, data=None):
- host, selector = splithost(url)
- i = host.find('@') + 1
- host = host[i:]
- user, passwd = self.get_user_passwd(host, realm, i)
- if not (user or passwd): return None
- host = quote(user, safe='') + ':' + quote(passwd, safe='') + '@' + host
- newurl = 'http://' + host + selector
- if data is None:
- return self.open(newurl)
- else:
- return self.open(newurl, data)
-
- def retry_https_basic_auth(self, url, realm, data=None):
- host, selector = splithost(url)
- i = host.find('@') + 1
- host = host[i:]
- user, passwd = self.get_user_passwd(host, realm, i)
- if not (user or passwd): return None
- host = quote(user, safe='') + ':' + quote(passwd, safe='') + '@' + host
- newurl = 'https://' + host + selector
- if data is None:
- return self.open(newurl)
- else:
- return self.open(newurl, data)
-
- def get_user_passwd(self, host, realm, clear_cache=0):
- key = realm + '@' + host.lower()
- if key in self.auth_cache:
- if clear_cache:
- del self.auth_cache[key]
- else:
- return self.auth_cache[key]
- user, passwd = self.prompt_user_passwd(host, realm)
- if user or passwd: self.auth_cache[key] = (user, passwd)
- return user, passwd
-
- def prompt_user_passwd(self, host, realm):
- """Override this in a GUI environment!"""
- import getpass
- try:
- user = raw_input("Enter username for %s at %s: " % (realm,
- host))
- passwd = getpass.getpass("Enter password for %s in %s at %s: " %
- (user, realm, host))
- return user, passwd
- except KeyboardInterrupt:
- print
- return None, None
-
-
-# Utility functions
-
-_localhost = None
-def localhost():
- """Return the IP address of the magic hostname 'localhost'."""
- global _localhost
- if _localhost is None:
- _localhost = socket.gethostbyname('localhost')
- return _localhost
-
-_thishost = None
-def thishost():
- """Return the IP address of the current host."""
- global _thishost
- if _thishost is None:
- _thishost = socket.gethostbyname(socket.gethostname())
- return _thishost
-
-_ftperrors = None
-def ftperrors():
- """Return the set of errors raised by the FTP class."""
- global _ftperrors
- if _ftperrors is None:
- import ftplib
- _ftperrors = ftplib.all_errors
- return _ftperrors
-
-_noheaders = None
-def noheaders():
- """Return an empty mimetools.Message object."""
- global _noheaders
- if _noheaders is None:
- import mimetools
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
- _noheaders = mimetools.Message(StringIO(), 0)
- _noheaders.fp.close() # Recycle file descriptor
- return _noheaders
-
-
-# Utility classes
-
-class ftpwrapper:
- """Class used by open_ftp() for cache of open FTP connections."""
-
- def __init__(self, user, passwd, host, port, dirs,
- timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
- persistent=True):
- self.user = user
- self.passwd = passwd
- self.host = host
- self.port = port
- self.dirs = dirs
- self.timeout = timeout
- self.refcount = 0
- self.keepalive = persistent
- self.init()
-
- def init(self):
- import ftplib
- self.busy = 0
- self.ftp = ftplib.FTP()
- self.ftp.connect(self.host, self.port, self.timeout)
- self.ftp.login(self.user, self.passwd)
- for dir in self.dirs:
- self.ftp.cwd(dir)
-
- def retrfile(self, file, type):
- import ftplib
- self.endtransfer()
- if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
- else: cmd = 'TYPE ' + type; isdir = 0
- try:
- self.ftp.voidcmd(cmd)
- except ftplib.all_errors:
- self.init()
- self.ftp.voidcmd(cmd)
- conn = None
- if file and not isdir:
- # Try to retrieve as a file
- try:
- cmd = 'RETR ' + file
- conn, retrlen = self.ftp.ntransfercmd(cmd)
- except ftplib.error_perm, reason:
- if str(reason)[:3] != '550':
- raise IOError, ('ftp error', reason), sys.exc_info()[2]
- if not conn:
- # Set transfer mode to ASCII!
- self.ftp.voidcmd('TYPE A')
- # Try a directory listing. Verify that directory exists.
- if file:
- pwd = self.ftp.pwd()
- try:
- try:
- self.ftp.cwd(file)
- except ftplib.error_perm, reason:
- raise IOError, ('ftp error', reason), sys.exc_info()[2]
- finally:
- self.ftp.cwd(pwd)
- cmd = 'LIST ' + file
- else:
- cmd = 'LIST'
- conn, retrlen = self.ftp.ntransfercmd(cmd)
- self.busy = 1
- ftpobj = addclosehook(conn.makefile('rb'), self.file_close)
- self.refcount += 1
- conn.close()
- # Pass back both a suitably decorated object and a retrieval length
- return (ftpobj, retrlen)
-
- def endtransfer(self):
- if not self.busy:
- return
- self.busy = 0
- try:
- self.ftp.voidresp()
- except ftperrors():
- pass
-
- def close(self):
- self.keepalive = False
- if self.refcount <= 0:
- self.real_close()
-
- def file_close(self):
- self.endtransfer()
- self.refcount -= 1
- if self.refcount <= 0 and not self.keepalive:
- self.real_close()
-
- def real_close(self):
- self.endtransfer()
- try:
- self.ftp.close()
- except ftperrors():
- pass
-
-class addbase:
- """Base class for addinfo and addclosehook."""
-
- def __init__(self, fp):
- self.fp = fp
- self.read = self.fp.read
- self.readline = self.fp.readline
- if hasattr(self.fp, "readlines"): self.readlines = self.fp.readlines
- if hasattr(self.fp, "fileno"):
- self.fileno = self.fp.fileno
- else:
- self.fileno = lambda: None
- if hasattr(self.fp, "__iter__"):
- self.__iter__ = self.fp.__iter__
- if hasattr(self.fp, "next"):
- self.next = self.fp.next
-
- def __repr__(self):
- return '<%s at %r whose fp = %r>' % (self.__class__.__name__,
- id(self), self.fp)
-
- def close(self):
- self.read = None
- self.readline = None
- self.readlines = None
- self.fileno = None
- if self.fp: self.fp.close()
- self.fp = None
-
-class addclosehook(addbase):
- """Class to add a close hook to an open file."""
-
- def __init__(self, fp, closehook, *hookargs):
- addbase.__init__(self, fp)
- self.closehook = closehook
- self.hookargs = hookargs
-
- def close(self):
- if self.closehook:
- self.closehook(*self.hookargs)
- self.closehook = None
- self.hookargs = None
- addbase.close(self)
-
-class addinfo(addbase):
- """class to add an info() method to an open file."""
-
- def __init__(self, fp, headers):
- addbase.__init__(self, fp)
- self.headers = headers
-
- def info(self):
- return self.headers
-
-class addinfourl(addbase):
- """class to add info() and geturl() methods to an open file."""
-
- def __init__(self, fp, headers, url, code=None):
- addbase.__init__(self, fp)
- self.headers = headers
- self.url = url
- self.code = code
-
- def info(self):
- return self.headers
-
- def getcode(self):
- return self.code
-
- def geturl(self):
- return self.url
-
-
-# Utilities to parse URLs (most of these return None for missing parts):
-# unwrap('<URL:type://host/path>') --> 'type://host/path'
-# splittype('type:opaquestring') --> 'type', 'opaquestring'
-# splithost('//host[:port]/path') --> 'host[:port]', '/path'
-# splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'
-# splitpasswd('user:passwd') -> 'user', 'passwd'
-# splitport('host:port') --> 'host', 'port'
-# splitquery('/path?query') --> '/path', 'query'
-# splittag('/path#tag') --> '/path', 'tag'
-# splitattr('/path;attr1=value1;attr2=value2;...') ->
-# '/path', ['attr1=value1', 'attr2=value2', ...]
-# splitvalue('attr=value') --> 'attr', 'value'
-# unquote('abc%20def') -> 'abc def'
-# quote('abc def') -> 'abc%20def')
-
-try:
- unicode
-except NameError:
- def _is_unicode(x):
- return 0
-else:
- def _is_unicode(x):
- return isinstance(x, unicode)
-
-def toBytes(url):
- """toBytes(u"URL") --> 'URL'."""
- # Most URL schemes require ASCII. If that changes, the conversion
- # can be relaxed
- if _is_unicode(url):
- try:
- url = url.encode("ASCII")
- except UnicodeError:
- raise UnicodeError("URL " + repr(url) +
- " contains non-ASCII characters")
- return url
-
-def unwrap(url):
- """unwrap('<URL:type://host/path>') --> 'type://host/path'."""
- url = url.strip()
- if url[:1] == '<' and url[-1:] == '>':
- url = url[1:-1].strip()
- if url[:4] == 'URL:': url = url[4:].strip()
- return url
-
-_typeprog = None
-def splittype(url):
- """splittype('type:opaquestring') --> 'type', 'opaquestring'."""
- global _typeprog
- if _typeprog is None:
- import re
- _typeprog = re.compile('^([^/:]+):')
-
- match = _typeprog.match(url)
- if match:
- scheme = match.group(1)
- return scheme.lower(), url[len(scheme) + 1:]
- return None, url
-
-_hostprog = None
-def splithost(url):
- """splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
- global _hostprog
- if _hostprog is None:
- import re
- _hostprog = re.compile('^//([^/?]*)(.*)$')
-
- match = _hostprog.match(url)
- if match:
- host_port = match.group(1)
- path = match.group(2)
- if path and not path.startswith('/'):
- path = '/' + path
- return host_port, path
- return None, url
-
-_userprog = None
-def splituser(host):
- """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
- global _userprog
- if _userprog is None:
- import re
- _userprog = re.compile('^(.*)@(.*)$')
-
- match = _userprog.match(host)
- if match: return match.group(1, 2)
- return None, host
-
-_passwdprog = None
-def splitpasswd(user):
- """splitpasswd('user:passwd') -> 'user', 'passwd'."""
- global _passwdprog
- if _passwdprog is None:
- import re
- _passwdprog = re.compile('^([^:]*):(.*)$',re.S)
-
- match = _passwdprog.match(user)
- if match: return match.group(1, 2)
- return user, None
-
-# splittag('/path#tag') --> '/path', 'tag'
-_portprog = None
-def splitport(host):
- """splitport('host:port') --> 'host', 'port'."""
- global _portprog
- if _portprog is None:
- import re
- _portprog = re.compile('^(.*):([0-9]+)$')
-
- match = _portprog.match(host)
- if match: return match.group(1, 2)
- return host, None
-
-_nportprog = None
-def splitnport(host, defport=-1):
- """Split host and port, returning numeric port.
- Return given default port if no ':' found; defaults to -1.
- Return numerical port if a valid number are found after ':'.
- Return None if ':' but not a valid number."""
- global _nportprog
- if _nportprog is None:
- import re
- _nportprog = re.compile('^(.*):(.*)$')
-
- match = _nportprog.match(host)
- if match:
- host, port = match.group(1, 2)
- try:
- if not port: raise ValueError, "no digits"
- nport = int(port)
- except ValueError:
- nport = None
- return host, nport
- return host, defport
-
-_queryprog = None
-def splitquery(url):
- """splitquery('/path?query') --> '/path', 'query'."""
- global _queryprog
- if _queryprog is None:
- import re
- _queryprog = re.compile('^(.*)\?([^?]*)$')
-
- match = _queryprog.match(url)
- if match: return match.group(1, 2)
- return url, None
-
-_tagprog = None
-def splittag(url):
- """splittag('/path#tag') --> '/path', 'tag'."""
- global _tagprog
- if _tagprog is None:
- import re
- _tagprog = re.compile('^(.*)#([^#]*)$')
-
- match = _tagprog.match(url)
- if match: return match.group(1, 2)
- return url, None
-
-def splitattr(url):
- """splitattr('/path;attr1=value1;attr2=value2;...') ->
- '/path', ['attr1=value1', 'attr2=value2', ...]."""
- words = url.split(';')
- return words[0], words[1:]
-
-_valueprog = None
-def splitvalue(attr):
- """splitvalue('attr=value') --> 'attr', 'value'."""
- global _valueprog
- if _valueprog is None:
- import re
- _valueprog = re.compile('^([^=]*)=(.*)$')
-
- match = _valueprog.match(attr)
- if match: return match.group(1, 2)
- return attr, None
-
-# urlparse contains a duplicate of this method to avoid a circular import. If
-# you update this method, also update the copy in urlparse. This code
-# duplication does not exist in Python3.
-
-_hexdig = '0123456789ABCDEFabcdef'
-_hextochr = dict((a + b, chr(int(a + b, 16)))
- for a in _hexdig for b in _hexdig)
-
-def unquote(s):
- """unquote('abc%20def') -> 'abc def'."""
- res = s.split('%')
- # fastpath
- if len(res) == 1:
- return s
- s = res[0]
- for item in res[1:]:
- try:
- s += _hextochr[item[:2]] + item[2:]
- except KeyError:
- s += '%' + item
- except UnicodeDecodeError:
- s += unichr(int(item[:2], 16)) + item[2:]
- return s
-
-def unquote_plus(s):
- """unquote('%7e/abc+def') -> '~/abc def'"""
- s = s.replace('+', ' ')
- return unquote(s)
-
-always_safe = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- 'abcdefghijklmnopqrstuvwxyz'
- '0123456789' '_.-')
-_safe_map = {}
-for i, c in zip(xrange(256), str(bytearray(xrange(256)))):
- _safe_map[c] = c if (i < 128 and c in always_safe) else '%{:02X}'.format(i)
-_safe_quoters = {}
-
-def quote(s, safe='/'):
- """quote('abc def') -> 'abc%20def'
-
- Each part of a URL, e.g. the path info, the query, etc., has a
- different set of reserved characters that must be quoted.
-
- RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
- the following reserved characters.
-
- reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
- "$" | ","
-
- Each of these characters is reserved in some component of a URL,
- but not necessarily in all of them.
-
- By default, the quote function is intended for quoting the path
- section of a URL. Thus, it will not encode '/'. This character
- is reserved, but in typical usage the quote function is being
- called on a path where the existing slash characters are used as
- reserved characters.
- """
- # fastpath
- if not s:
- if s is None:
- raise TypeError('None object cannot be quoted')
- return s
- cachekey = (safe, always_safe)
- try:
- (quoter, safe) = _safe_quoters[cachekey]
- except KeyError:
- safe_map = _safe_map.copy()
- safe_map.update([(c, c) for c in safe])
- quoter = safe_map.__getitem__
- safe = always_safe + safe
- _safe_quoters[cachekey] = (quoter, safe)
- if not s.rstrip(safe):
- return s
- return ''.join(map(quoter, s))
-
-def quote_plus(s, safe=''):
- """Quote the query fragment of a URL; replacing ' ' with '+'"""
- if ' ' in s:
- s = quote(s, safe + ' ')
- return s.replace(' ', '+')
- return quote(s, safe)
-
-def urlencode(query, doseq=0):
- """Encode a sequence of two-element tuples or dictionary into a URL query string.
-
- If any values in the query arg are sequences and doseq is true, each
- sequence element is converted to a separate parameter.
-
- If the query arg is a sequence of two-element tuples, the order of the
- parameters in the output will match the order of parameters in the
- input.
- """
-
- if hasattr(query,"items"):
- # mapping objects
- query = query.items()
- else:
- # it's a bother at times that strings and string-like objects are
- # sequences...
- try:
- # non-sequence items should not work with len()
- # non-empty strings will fail this
- if len(query) and not isinstance(query[0], tuple):
- raise TypeError
- # zero-length sequences of all types will get here and succeed,
- # but that's a minor nit - since the original implementation
- # allowed empty dicts that type of behavior probably should be
- # preserved for consistency
- except TypeError:
- ty,va,tb = sys.exc_info()
- raise TypeError, "not a valid non-string sequence or mapping object", tb
-
- l = []
- if not doseq:
- # preserve old behavior
- for k, v in query:
- k = quote_plus(str(k))
- v = quote_plus(str(v))
- l.append(k + '=' + v)
- else:
- for k, v in query:
- k = quote_plus(str(k))
- if isinstance(v, str):
- v = quote_plus(v)
- l.append(k + '=' + v)
- elif _is_unicode(v):
- # is there a reasonable way to convert to ASCII?
- # encode generates a string, but "replace" or "ignore"
- # lose information and "strict" can raise UnicodeError
- v = quote_plus(v.encode("ASCII","replace"))
- l.append(k + '=' + v)
- else:
- try:
- # is this a sufficient test for sequence-ness?
- len(v)
- except TypeError:
- # not a sequence
- v = quote_plus(str(v))
- l.append(k + '=' + v)
- else:
- # loop over the sequence
- for elt in v:
- l.append(k + '=' + quote_plus(str(elt)))
- return '&'.join(l)
-
-# Proxy handling
-def getproxies_environment():
- """Return a dictionary of scheme -> proxy server URL mappings.
-
- Scan the environment for variables named <scheme>_proxy;
- this seems to be the standard convention. If you need a
- different way, you can pass a proxies dictionary to the
- [Fancy]URLopener constructor.
-
- """
- proxies = {}
- for name, value in os.environ.items():
- name = name.lower()
- if value and name[-6:] == '_proxy':
- proxies[name[:-6]] = value
- return proxies
-
-def proxy_bypass_environment(host):
- """Test if proxies should not be used for a particular host.
-
- Checks the environment for a variable named no_proxy, which should
- be a list of DNS suffixes separated by commas, or '*' for all hosts.
- """
- no_proxy = os.environ.get('no_proxy', '') or os.environ.get('NO_PROXY', '')
- # '*' is special case for always bypass
- if no_proxy == '*':
- return 1
- # strip port off host
- hostonly, port = splitport(host)
- # check if the host ends with any of the DNS suffixes
- no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
- for name in no_proxy_list:
- if name and (hostonly.endswith(name) or host.endswith(name)):
- return 1
- # otherwise, don't bypass
- return 0
-
-
-if sys.platform == 'darwin':
- from _scproxy import _get_proxy_settings, _get_proxies
-
- def proxy_bypass_macosx_sysconf(host):
- """
- Return True iff this host shouldn't be accessed using a proxy
-
- This function uses the MacOSX framework SystemConfiguration
- to fetch the proxy information.
- """
- import re
- import socket
- from fnmatch import fnmatch
-
- hostonly, port = splitport(host)
-
- def ip2num(ipAddr):
- parts = ipAddr.split('.')
- parts = map(int, parts)
- if len(parts) != 4:
- parts = (parts + [0, 0, 0, 0])[:4]
- return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3]
-
- proxy_settings = _get_proxy_settings()
-
- # Check for simple host names:
- if '.' not in host:
- if proxy_settings['exclude_simple']:
- return True
-
- hostIP = None
-
- for value in proxy_settings.get('exceptions', ()):
- # Items in the list are strings like these: *.local, 169.254/16
- if not value: continue
-
- m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value)
- if m is not None:
- if hostIP is None:
- try:
- hostIP = socket.gethostbyname(hostonly)
- hostIP = ip2num(hostIP)
- except socket.error:
- continue
-
- base = ip2num(m.group(1))
- mask = m.group(2)
- if mask is None:
- mask = 8 * (m.group(1).count('.') + 1)
-
- else:
- mask = int(mask[1:])
- mask = 32 - mask
-
- if (hostIP >> mask) == (base >> mask):
- return True
-
- elif fnmatch(host, value):
- return True
-
- return False
-
- def getproxies_macosx_sysconf():
- """Return a dictionary of scheme -> proxy server URL mappings.
-
- This function uses the MacOSX framework SystemConfiguration
- to fetch the proxy information.
- """
- return _get_proxies()
-
- def proxy_bypass(host):
- if getproxies_environment():
- return proxy_bypass_environment(host)
- else:
- return proxy_bypass_macosx_sysconf(host)
-
- def getproxies():
- return getproxies_environment() or getproxies_macosx_sysconf()
-
-elif os.name == 'nt':
- def getproxies_registry():
- """Return a dictionary of scheme -> proxy server URL mappings.
-
- Win32 uses the registry to store proxies.
-
- """
- proxies = {}
- try:
- import _winreg
- except ImportError:
- # Std module, so should be around - but you never know!
- return proxies
- try:
- internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
- r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
- proxyEnable = _winreg.QueryValueEx(internetSettings,
- 'ProxyEnable')[0]
- if proxyEnable:
- # Returned as Unicode but problems if not converted to ASCII
- proxyServer = str(_winreg.QueryValueEx(internetSettings,
- 'ProxyServer')[0])
- if '=' in proxyServer:
- # Per-protocol settings
- for p in proxyServer.split(';'):
- protocol, address = p.split('=', 1)
- # See if address has a type:// prefix
- import re
- if not re.match('^([^/:]+)://', address):
- address = '%s://%s' % (protocol, address)
- proxies[protocol] = address
- else:
- # Use one setting for all protocols
- if proxyServer[:5] == 'http:':
- proxies['http'] = proxyServer
- else:
- proxies['http'] = 'http://%s' % proxyServer
- proxies['https'] = 'https://%s' % proxyServer
- proxies['ftp'] = 'ftp://%s' % proxyServer
- internetSettings.Close()
- except (WindowsError, ValueError, TypeError):
- # Either registry key not found etc, or the value in an
- # unexpected format.
- # proxies already set up to be empty so nothing to do
- pass
- return proxies
-
- def getproxies():
- """Return a dictionary of scheme -> proxy server URL mappings.
-
- Returns settings gathered from the environment, if specified,
- or the registry.
-
- """
- return getproxies_environment() or getproxies_registry()
-
- def proxy_bypass_registry(host):
- try:
- import _winreg
- import re
- except ImportError:
- # Std modules, so should be around - but you never know!
- return 0
- try:
- internetSettings = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER,
- r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
- proxyEnable = _winreg.QueryValueEx(internetSettings,
- 'ProxyEnable')[0]
- proxyOverride = str(_winreg.QueryValueEx(internetSettings,
- 'ProxyOverride')[0])
- # ^^^^ Returned as Unicode but problems if not converted to ASCII
- except WindowsError:
- return 0
- if not proxyEnable or not proxyOverride:
- return 0
- # try to make a host list from name and IP address.
- rawHost, port = splitport(host)
- host = [rawHost]
- try:
- addr = socket.gethostbyname(rawHost)
- if addr != rawHost:
- host.append(addr)
- except socket.error:
- pass
- try:
- fqdn = socket.getfqdn(rawHost)
- if fqdn != rawHost:
- host.append(fqdn)
- except socket.error:
- pass
- # make a check value list from the registry entry: replace the
- # '<local>' string by the localhost entry and the corresponding
- # canonical entry.
- proxyOverride = proxyOverride.split(';')
- # now check if we match one of the registry values.
- for test in proxyOverride:
- if test == '<local>':
- if '.' not in rawHost:
- return 1
- test = test.replace(".", r"\.") # mask dots
- test = test.replace("*", r".*") # change glob sequence
- test = test.replace("?", r".") # change glob char
- for val in host:
- # print "%s <--> %s" %( test, val )
- if re.match(test, val, re.I):
- return 1
- return 0
-
- def proxy_bypass(host):
- """Return a dictionary of scheme -> proxy server URL mappings.
-
- Returns settings gathered from the environment, if specified,
- or the registry.
-
- """
- if getproxies_environment():
- return proxy_bypass_environment(host)
- else:
- return proxy_bypass_registry(host)
-
-else:
- # By default use environment variables
- getproxies = getproxies_environment
- proxy_bypass = proxy_bypass_environment
-
-# Test and time quote() and unquote()
-def test1():
- s = ''
- for i in range(256): s = s + chr(i)
- s = s*4
- t0 = time.time()
- qs = quote(s)
- uqs = unquote(qs)
- t1 = time.time()
- if uqs != s:
- print 'Wrong!'
- print repr(s)
- print repr(qs)
- print repr(uqs)
- print round(t1 - t0, 3), 'sec'
-
-
-def reporthook(blocknum, blocksize, totalsize):
- # Report during remote transfers
- print "Block number: %d, Block size: %d, Total size: %d" % (
- blocknum, blocksize, totalsize)
diff --git a/Lib/urllib/__init__.py b/Lib/urllib/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/Lib/urllib/__init__.py
diff --git a/Lib/urllib/error.py b/Lib/urllib/error.py
new file mode 100644
index 00000000000..eb14c1d8b45
--- /dev/null
+++ b/Lib/urllib/error.py
@@ -0,0 +1,69 @@
+"""Exception classes raised by urllib.
+
+The base exception class is URLError, which inherits from IOError. It
+doesn't define any behavior of its own, but is the base class for all
+exceptions defined in this package.
+
+HTTPError is an exception class that is also a valid HTTP response
+instance. It behaves this way because HTTP protocol errors are valid
+responses, with a status code, headers, and a body. In some contexts,
+an application may want to handle an exception like a regular
+response.
+"""
+
+import urllib.response
+
+# do these error classes make sense?
+# make sure all of the IOError stuff is overridden. we just want to be
+# subtypes.
+
+class URLError(IOError):
+ # URLError is a sub-type of IOError, but it doesn't share any of
+ # the implementation. need to override __init__ and __str__.
+ # It sets self.args for compatibility with other EnvironmentError
+ # subclasses, but args doesn't have the typical format with errno in
+ # slot 0 and strerror in slot 1. This may be better than nothing.
+ def __init__(self, reason, filename=None):
+ self.args = reason,
+ self.reason = reason
+ if filename is not None:
+ self.filename = filename
+
+ def __str__(self):
+ return '<urlopen error %s>' % self.reason
+
+class HTTPError(URLError, urllib.response.addinfourl):
+ """Raised when HTTP error occurs, but also acts like non-error return"""
+ __super_init = urllib.response.addinfourl.__init__
+
+ def __init__(self, url, code, msg, hdrs, fp):
+ self.code = code
+ self.msg = msg
+ self.hdrs = hdrs
+ self.fp = fp
+ self.filename = url
+ # The addinfourl classes depend on fp being a valid file
+ # object. In some cases, the HTTPError may not have a valid
+ # file object. If this happens, the simplest workaround is to
+ # not initialize the base classes.
+ if fp is not None:
+ self.__super_init(fp, hdrs, url, code)
+
+ def __str__(self):
+ return 'HTTP Error %s: %s' % (self.code, self.msg)
+
+ # since URLError specifies a .reason attribute, HTTPError should also
+ # provide this attribute. See issue13211 for discussion.
+ @property
+ def reason(self):
+ return self.msg
+
+ def info(self):
+ return self.hdrs
+
+
+# exception raised when downloaded size does not match content-length
+class ContentTooShortError(URLError):
+ def __init__(self, message, content):
+ URLError.__init__(self, message)
+ self.content = content
diff --git a/Lib/urllib/parse.py b/Lib/urllib/parse.py
new file mode 100644
index 00000000000..dc75f8f28cf
--- /dev/null
+++ b/Lib/urllib/parse.py
@@ -0,0 +1,983 @@
+"""Parse (absolute and relative) URLs.
+
+urlparse module is based upon the following RFC specifications.
+
+RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
+and L. Masinter, January 2005.
+
+RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
+and L.Masinter, December 1999.
+
+RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T.
+Berners-Lee, R. Fielding, and L. Masinter, August 1998.
+
+RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zawinski, July 1998.
+
+RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
+1995.
+
+RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
+McCahill, December 1994
+
+RFC 3986 is considered the current standard and any future changes to
+urlparse module should conform with it. The urlparse module is
+currently not entirely compliant with this RFC due to defacto
+scenarios for parsing, and for backward compatibility purposes, some
+parsing quirks from older RFCs are retained. The testcases in
+test_urlparse.py provides a good indicator of parsing behavior.
+"""
+
+import sys
+import collections
+
+__all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag",
+ "urlsplit", "urlunsplit", "urlencode", "parse_qs",
+ "parse_qsl", "quote", "quote_plus", "quote_from_bytes",
+ "unquote", "unquote_plus", "unquote_to_bytes"]
+
+# A classification of schemes ('' means apply by default)
+uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap',
+ 'wais', 'file', 'https', 'shttp', 'mms',
+ 'prospero', 'rtsp', 'rtspu', '', 'sftp',
+ 'svn', 'svn+ssh']
+uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
+ 'imap', 'wais', 'file', 'mms', 'https', 'shttp',
+ 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
+ 'svn', 'svn+ssh', 'sftp', 'nfs', 'git', 'git+ssh']
+uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
+ 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
+ 'mms', '', 'sftp', 'tel']
+
+# These are not actually used anymore, but should stay for backwards
+# compatibility. (They are undocumented, but have a public-looking name.)
+non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
+ 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
+uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms',
+ 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', '']
+uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news',
+ 'nntp', 'wais', 'https', 'shttp', 'snews',
+ 'file', 'prospero', '']
+
+# Characters valid in scheme names
+scheme_chars = ('abcdefghijklmnopqrstuvwxyz'
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ '0123456789'
+ '+-.')
+
+# XXX: Consider replacing with functools.lru_cache
+MAX_CACHE_SIZE = 20
+_parse_cache = {}
+
+def clear_cache():
+ """Clear the parse cache and the quoters cache."""
+ _parse_cache.clear()
+ _safe_quoters.clear()
+
+
+# Helpers for bytes handling
+# For 3.2, we deliberately require applications that
+# handle improperly quoted URLs to do their own
+# decoding and encoding. If valid use cases are
+# presented, we may relax this by using latin-1
+# decoding internally for 3.3
+_implicit_encoding = 'ascii'
+_implicit_errors = 'strict'
+
+def _noop(obj):
+ return obj
+
+def _encode_result(obj, encoding=_implicit_encoding,
+ errors=_implicit_errors):
+ return obj.encode(encoding, errors)
+
+def _decode_args(args, encoding=_implicit_encoding,
+ errors=_implicit_errors):
+ return tuple(x.decode(encoding, errors) if x else '' for x in args)
+
+def _coerce_args(*args):
+ # Invokes decode if necessary to create str args
+ # and returns the coerced inputs along with
+ # an appropriate result coercion function
+ # - noop for str inputs
+ # - encoding function otherwise
+ str_input = isinstance(args[0], str)
+ for arg in args[1:]:
+ # We special-case the empty string to support the
+ # "scheme=''" default argument to some functions
+ if arg and isinstance(arg, str) != str_input:
+ raise TypeError("Cannot mix str and non-str arguments")
+ if str_input:
+ return args + (_noop,)
+ return _decode_args(args) + (_encode_result,)
+
+# Result objects are more helpful than simple tuples
+class _ResultMixinStr(object):
+ """Standard approach to encoding parsed results from str to bytes"""
+ __slots__ = ()
+
+ def encode(self, encoding='ascii', errors='strict'):
+ return self._encoded_counterpart(*(x.encode(encoding, errors) for x in self))
+
+
+class _ResultMixinBytes(object):
+ """Standard approach to decoding parsed results from bytes to str"""
+ __slots__ = ()
+
+ def decode(self, encoding='ascii', errors='strict'):
+ return self._decoded_counterpart(*(x.decode(encoding, errors) for x in self))
+
+
+class _NetlocResultMixinBase(object):
+ """Shared methods for the parsed result objects containing a netloc element"""
+ __slots__ = ()
+
+ @property
+ def username(self):
+ return self._userinfo[0]
+
+ @property
+ def password(self):
+ return self._userinfo[1]
+
+ @property
+ def hostname(self):
+ hostname = self._hostinfo[0]
+ if not hostname:
+ hostname = None
+ elif hostname is not None:
+ hostname = hostname.lower()
+ return hostname
+
+ @property
+ def port(self):
+ port = self._hostinfo[1]
+ if port is not None:
+ port = int(port, 10)
+ # Return None on an illegal port
+ if not ( 0 <= port <= 65535):
+ return None
+ return port
+
+
+class _NetlocResultMixinStr(_NetlocResultMixinBase, _ResultMixinStr):
+ __slots__ = ()
+
+ @property
+ def _userinfo(self):
+ netloc = self.netloc
+ userinfo, have_info, hostinfo = netloc.rpartition('@')
+ if have_info:
+ username, have_password, password = userinfo.partition(':')
+ if not have_password:
+ password = None
+ else:
+ username = password = None
+ return username, password
+
+ @property
+ def _hostinfo(self):
+ netloc = self.netloc
+ _, _, hostinfo = netloc.rpartition('@')
+ _, have_open_br, bracketed = hostinfo.partition('[')
+ if have_open_br:
+ hostname, _, port = bracketed.partition(']')
+ _, have_port, port = port.partition(':')
+ else:
+ hostname, have_port, port = hostinfo.partition(':')
+ if not have_port:
+ port = None
+ return hostname, port
+
+
+class _NetlocResultMixinBytes(_NetlocResultMixinBase, _ResultMixinBytes):
+ __slots__ = ()
+
+ @property
+ def _userinfo(self):
+ netloc = self.netloc
+ userinfo, have_info, hostinfo = netloc.rpartition(b'@')
+ if have_info:
+ username, have_password, password = userinfo.partition(b':')
+ if not have_password:
+ password = None
+ else:
+ username = password = None
+ return username, password
+
+ @property
+ def _hostinfo(self):
+ netloc = self.netloc
+ _, _, hostinfo = netloc.rpartition(b'@')
+ _, have_open_br, bracketed = hostinfo.partition(b'[')
+ if have_open_br:
+ hostname, _, port = bracketed.partition(b']')
+ _, have_port, port = port.partition(b':')
+ else:
+ hostname, have_port, port = hostinfo.partition(b':')
+ if not have_port:
+ port = None
+ return hostname, port
+
+
+from collections import namedtuple
+
+_DefragResultBase = namedtuple('DefragResult', 'url fragment')
+_SplitResultBase = namedtuple('SplitResult', 'scheme netloc path query fragment')
+_ParseResultBase = namedtuple('ParseResult', 'scheme netloc path params query fragment')
+
+# For backwards compatibility, alias _NetlocResultMixinStr
+# ResultBase is no longer part of the documented API, but it is
+# retained since deprecating it isn't worth the hassle
+ResultBase = _NetlocResultMixinStr
+
+# Structured result objects for string data
+class DefragResult(_DefragResultBase, _ResultMixinStr):
+ __slots__ = ()
+ def geturl(self):
+ if self.fragment:
+ return self.url + '#' + self.fragment
+ else:
+ return self.url
+
+class SplitResult(_SplitResultBase, _NetlocResultMixinStr):
+ __slots__ = ()
+ def geturl(self):
+ return urlunsplit(self)
+
+class ParseResult(_ParseResultBase, _NetlocResultMixinStr):
+ __slots__ = ()
+ def geturl(self):
+ return urlunparse(self)
+
+# Structured result objects for bytes data
+class DefragResultBytes(_DefragResultBase, _ResultMixinBytes):
+ __slots__ = ()
+ def geturl(self):
+ if self.fragment:
+ return self.url + b'#' + self.fragment
+ else:
+ return self.url
+
+class SplitResultBytes(_SplitResultBase, _NetlocResultMixinBytes):
+ __slots__ = ()
+ def geturl(self):
+ return urlunsplit(self)
+
+class ParseResultBytes(_ParseResultBase, _NetlocResultMixinBytes):
+ __slots__ = ()
+ def geturl(self):
+ return urlunparse(self)
+
+# Set up the encode/decode result pairs
+def _fix_result_transcoding():
+ _result_pairs = (
+ (DefragResult, DefragResultBytes),
+ (SplitResult, SplitResultBytes),
+ (ParseResult, ParseResultBytes),
+ )
+ for _decoded, _encoded in _result_pairs:
+ _decoded._encoded_counterpart = _encoded
+ _encoded._decoded_counterpart = _decoded
+
+_fix_result_transcoding()
+del _fix_result_transcoding
+
+def urlparse(url, scheme='', allow_fragments=True):
+ """Parse a URL into 6 components:
+ <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
+ Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
+ Note that we don't break the components up in smaller bits
+ (e.g. netloc is a single string) and we don't expand % escapes."""
+ url, scheme, _coerce_result = _coerce_args(url, scheme)
+ splitresult = urlsplit(url, scheme, allow_fragments)
+ scheme, netloc, url, query, fragment = splitresult
+ if scheme in uses_params and ';' in url:
+ url, params = _splitparams(url)
+ else:
+ params = ''
+ result = ParseResult(scheme, netloc, url, params, query, fragment)
+ return _coerce_result(result)
+
+def _splitparams(url):
+ if '/' in url:
+ i = url.find(';', url.rfind('/'))
+ if i < 0:
+ return url, ''
+ else:
+ i = url.find(';')
+ return url[:i], url[i+1:]
+
+def _splitnetloc(url, start=0):
+ delim = len(url) # position of end of domain part of url, default is end
+ for c in '/?#': # look for delimiters; the order is NOT important
+ wdelim = url.find(c, start) # find first of this delim
+ if wdelim >= 0: # if found
+ delim = min(delim, wdelim) # use earliest delim position
+ return url[start:delim], url[delim:] # return (domain, rest)
+
+def urlsplit(url, scheme='', allow_fragments=True):
+ """Parse a URL into 5 components:
+ <scheme>://<netloc>/<path>?<query>#<fragment>
+ Return a 5-tuple: (scheme, netloc, path, query, fragment).
+ Note that we don't break the components up in smaller bits
+ (e.g. netloc is a single string) and we don't expand % escapes."""
+ url, scheme, _coerce_result = _coerce_args(url, scheme)
+ allow_fragments = bool(allow_fragments)
+ key = url, scheme, allow_fragments, type(url), type(scheme)
+ cached = _parse_cache.get(key, None)
+ if cached:
+ return _coerce_result(cached)
+ if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
+ clear_cache()
+ netloc = query = fragment = ''
+ i = url.find(':')
+ if i > 0:
+ if url[:i] == 'http': # optimize the common case
+ scheme = url[:i].lower()
+ url = url[i+1:]
+ if url[:2] == '//':
+ netloc, url = _splitnetloc(url, 2)
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
+ if allow_fragments and '#' in url:
+ url, fragment = url.split('#', 1)
+ if '?' in url:
+ url, query = url.split('?', 1)
+ v = SplitResult(scheme, netloc, url, query, fragment)
+ _parse_cache[key] = v
+ return _coerce_result(v)
+ for c in url[:i]:
+ if c not in scheme_chars:
+ break
+ else:
+ # make sure "url" is not actually a port number (in which case
+ # "scheme" is really part of the path)
+ rest = url[i+1:]
+ if not rest or any(c not in '0123456789' for c in rest):
+ # not a port number
+ scheme, url = url[:i].lower(), rest
+
+ if url[:2] == '//':
+ netloc, url = _splitnetloc(url, 2)
+ if (('[' in netloc and ']' not in netloc) or
+ (']' in netloc and '[' not in netloc)):
+ raise ValueError("Invalid IPv6 URL")
+ if allow_fragments and '#' in url:
+ url, fragment = url.split('#', 1)
+ if '?' in url:
+ url, query = url.split('?', 1)
+ v = SplitResult(scheme, netloc, url, query, fragment)
+ _parse_cache[key] = v
+ return _coerce_result(v)
+
+def urlunparse(components):
+ """Put a parsed URL back together again. This may result in a
+ slightly different, but equivalent URL, if the URL that was parsed
+ originally had redundant delimiters, e.g. a ? with an empty query
+ (the draft states that these are equivalent)."""
+ scheme, netloc, url, params, query, fragment, _coerce_result = (
+ _coerce_args(*components))
+ if params:
+ url = "%s;%s" % (url, params)
+ return _coerce_result(urlunsplit((scheme, netloc, url, query, fragment)))
+
+def urlunsplit(components):
+ """Combine the elements of a tuple as returned by urlsplit() into a
+ complete URL as a string. The data argument can be any five-item iterable.
+ This may result in a slightly different, but equivalent URL, if the URL that
+ was parsed originally had unnecessary delimiters (for example, a ? with an
+ empty query; the RFC states that these are equivalent)."""
+ scheme, netloc, url, query, fragment, _coerce_result = (
+ _coerce_args(*components))
+ if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
+ if url and url[:1] != '/': url = '/' + url
+ url = '//' + (netloc or '') + url
+ if scheme:
+ url = scheme + ':' + url
+ if query:
+ url = url + '?' + query
+ if fragment:
+ url = url + '#' + fragment
+ return _coerce_result(url)
+
+def urljoin(base, url, allow_fragments=True):
+ """Join a base URL and a possibly relative URL to form an absolute
+ interpretation of the latter."""
+ if not base:
+ return url
+ if not url:
+ return base
+ base, url, _coerce_result = _coerce_args(base, url)
+ bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
+ urlparse(base, '', allow_fragments)
+ scheme, netloc, path, params, query, fragment = \
+ urlparse(url, bscheme, allow_fragments)
+ if scheme != bscheme or scheme not in uses_relative:
+ return _coerce_result(url)
+ if scheme in uses_netloc:
+ if netloc:
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
+ netloc = bnetloc
+ if path[:1] == '/':
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
+ if not path and not params:
+ path = bpath
+ params = bparams
+ if not query:
+ query = bquery
+ return _coerce_result(urlunparse((scheme, netloc, path,
+ params, query, fragment)))
+ segments = bpath.split('/')[:-1] + path.split('/')
+ # XXX The stuff below is bogus in various ways...
+ if segments[-1] == '.':
+ segments[-1] = ''
+ while '.' in segments:
+ segments.remove('.')
+ while 1:
+ i = 1
+ n = len(segments) - 1
+ while i < n:
+ if (segments[i] == '..'
+ and segments[i-1] not in ('', '..')):
+ del segments[i-1:i+1]
+ break
+ i = i+1
+ else:
+ break
+ if segments == ['', '..']:
+ segments[-1] = ''
+ elif len(segments) >= 2 and segments[-1] == '..':
+ segments[-2:] = ['']
+ return _coerce_result(urlunparse((scheme, netloc, '/'.join(segments),
+ params, query, fragment)))
+
+def urldefrag(url):
+ """Removes any existing fragment from URL.
+
+ Returns a tuple of the defragmented URL and the fragment. If
+ the URL contained no fragments, the second element is the
+ empty string.
+ """
+ url, _coerce_result = _coerce_args(url)
+ if '#' in url:
+ s, n, p, a, q, frag = urlparse(url)
+ defrag = urlunparse((s, n, p, a, q, ''))
+ else:
+ frag = ''
+ defrag = url
+ return _coerce_result(DefragResult(defrag, frag))
+
+def unquote_to_bytes(string):
+ """unquote_to_bytes('abc%20def') -> b'abc def'."""
+ # Note: strings are encoded as UTF-8. This is only an issue if it contains
+ # unescaped non-ASCII characters, which URIs should not.
+ if not string:
+ # Is it a string-like object?
+ string.split
+ return b''
+ if isinstance(string, str):
+ string = string.encode('utf-8')
+ res = string.split(b'%')
+ if len(res) == 1:
+ return string
+ string = res[0]
+ for item in res[1:]:
+ try:
+ string += bytes([int(item[:2], 16)]) + item[2:]
+ except ValueError:
+ string += b'%' + item
+ return string
+
+def unquote(string, encoding='utf-8', errors='replace'):
+ """Replace %xx escapes by their single-character equivalent. The optional
+ encoding and errors parameters specify how to decode percent-encoded
+ sequences into Unicode characters, as accepted by the bytes.decode()
+ method.
+ By default, percent-encoded sequences are decoded with UTF-8, and invalid
+ sequences are replaced by a placeholder character.
+
+ unquote('abc%20def') -> 'abc def'.
+ """
+ if string == '':
+ return string
+ res = string.split('%')
+ if len(res) == 1:
+ return string
+ if encoding is None:
+ encoding = 'utf-8'
+ if errors is None:
+ errors = 'replace'
+ # pct_sequence: contiguous sequence of percent-encoded bytes, decoded
+ pct_sequence = b''
+ string = res[0]
+ for item in res[1:]:
+ try:
+ if not item:
+ raise ValueError
+ pct_sequence += bytes.fromhex(item[:2])
+ rest = item[2:]
+ if not rest:
+ # This segment was just a single percent-encoded character.
+ # May be part of a sequence of code units, so delay decoding.
+ # (Stored in pct_sequence).
+ continue
+ except ValueError:
+ rest = '%' + item
+ # Encountered non-percent-encoded characters. Flush the current
+ # pct_sequence.
+ string += pct_sequence.decode(encoding, errors) + rest
+ pct_sequence = b''
+ if pct_sequence:
+ # Flush the final pct_sequence
+ string += pct_sequence.decode(encoding, errors)
+ return string
+
+def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
+ encoding='utf-8', errors='replace'):
+ """Parse a query given as a string argument.
+
+ Arguments:
+
+ qs: percent-encoded query string to be parsed
+
+ keep_blank_values: flag indicating whether blank values in
+ percent-encoded queries should be treated as blank strings.
+ A true value indicates that blanks should be retained as
+ blank strings. The default false value indicates that
+ blank values are to be ignored and treated as if they were
+ not included.
+
+ strict_parsing: flag indicating what to do with parsing errors.
+ If false (the default), errors are silently ignored.
+ If true, errors raise a ValueError exception.
+
+ encoding and errors: specify how to decode percent-encoded sequences
+ into Unicode characters, as accepted by the bytes.decode() method.
+ """
+ parsed_result = {}
+ pairs = parse_qsl(qs, keep_blank_values, strict_parsing,
+ encoding=encoding, errors=errors)
+ for name, value in pairs:
+ if name in parsed_result:
+ parsed_result[name].append(value)
+ else:
+ parsed_result[name] = [value]
+ return parsed_result
+
+def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
+ encoding='utf-8', errors='replace'):
+ """Parse a query given as a string argument.
+
+ Arguments:
+
+ qs: percent-encoded query string to be parsed
+
+ keep_blank_values: flag indicating whether blank values in
+ percent-encoded queries should be treated as blank strings. A
+ true value indicates that blanks should be retained as blank
+ strings. The default false value indicates that blank values
+ are to be ignored and treated as if they were not included.
+
+ strict_parsing: flag indicating what to do with parsing errors. If
+ false (the default), errors are silently ignored. If true,
+ errors raise a ValueError exception.
+
+ encoding and errors: specify how to decode percent-encoded sequences
+ into Unicode characters, as accepted by the bytes.decode() method.
+
+ Returns a list, as G-d intended.
+ """
+ qs, _coerce_result = _coerce_args(qs)
+ pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
+ r = []
+ for name_value in pairs:
+ if not name_value and not strict_parsing:
+ continue
+ nv = name_value.split('=', 1)
+ if len(nv) != 2:
+ if strict_parsing:
+ raise ValueError("bad query field: %r" % (name_value,))
+ # Handle case of a control-name with no equal sign
+ if keep_blank_values:
+ nv.append('')
+ else:
+ continue
+ if len(nv[1]) or keep_blank_values:
+ name = nv[0].replace('+', ' ')
+ name = unquote(name, encoding=encoding, errors=errors)
+ name = _coerce_result(name)
+ value = nv[1].replace('+', ' ')
+ value = unquote(value, encoding=encoding, errors=errors)
+ value = _coerce_result(value)
+ r.append((name, value))
+ return r
+
+def unquote_plus(string, encoding='utf-8', errors='replace'):
+ """Like unquote(), but also replace plus signs by spaces, as required for
+ unquoting HTML form values.
+
+ unquote_plus('%7e/abc+def') -> '~/abc def'
+ """
+ string = string.replace('+', ' ')
+ return unquote(string, encoding, errors)
+
+_ALWAYS_SAFE = frozenset(b'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+ b'abcdefghijklmnopqrstuvwxyz'
+ b'0123456789'
+ b'_.-')
+_ALWAYS_SAFE_BYTES = bytes(_ALWAYS_SAFE)
+_safe_quoters = {}
+
+class Quoter(collections.defaultdict):
+ """A mapping from bytes (in range(0,256)) to strings.
+
+ String values are percent-encoded byte values, unless the key < 128, and
+ in the "safe" set (either the specified safe set, or default set).
+ """
+ # Keeps a cache internally, using defaultdict, for efficiency (lookups
+ # of cached keys don't call Python code at all).
+ def __init__(self, safe):
+ """safe: bytes object."""
+ self.safe = _ALWAYS_SAFE.union(safe)
+
+ def __repr__(self):
+ # Without this, will just display as a defaultdict
+ return "<Quoter %r>" % dict(self)
+
+ def __missing__(self, b):
+ # Handle a cache miss. Store quoted string in cache and return.
+ res = chr(b) if b in self.safe else '%{:02X}'.format(b)
+ self[b] = res
+ return res
+
+def quote(string, safe='/', encoding=None, errors=None):
+ """quote('abc def') -> 'abc%20def'
+
+ Each part of a URL, e.g. the path info, the query, etc., has a
+ different set of reserved characters that must be quoted.
+
+ RFC 2396 Uniform Resource Identifiers (URI): Generic Syntax lists
+ the following reserved characters.
+
+ reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" |
+ "$" | ","
+
+ Each of these characters is reserved in some component of a URL,
+ but not necessarily in all of them.
+
+ By default, the quote function is intended for quoting the path
+ section of a URL. Thus, it will not encode '/'. This character
+ is reserved, but in typical usage the quote function is being
+ called on a path where the existing slash characters are used as
+ reserved characters.
+
+ string and safe may be either str or bytes objects. encoding must
+ not be specified if string is a str.
+
+ The optional encoding and errors parameters specify how to deal with
+ non-ASCII characters, as accepted by the str.encode method.
+ By default, encoding='utf-8' (characters are encoded with UTF-8), and
+ errors='strict' (unsupported characters raise a UnicodeEncodeError).
+ """
+ if isinstance(string, str):
+ if not string:
+ return string
+ if encoding is None:
+ encoding = 'utf-8'
+ if errors is None:
+ errors = 'strict'
+ string = string.encode(encoding, errors)
+ else:
+ if encoding is not None:
+ raise TypeError("quote() doesn't support 'encoding' for bytes")
+ if errors is not None:
+ raise TypeError("quote() doesn't support 'errors' for bytes")
+ return quote_from_bytes(string, safe)
+
+def quote_plus(string, safe='', encoding=None, errors=None):
+ """Like quote(), but also replace ' ' with '+', as required for quoting
+ HTML form values. Plus signs in the original string are escaped unless
+ they are included in safe. It also does not have safe default to '/'.
+ """
+ # Check if ' ' in string, where string may either be a str or bytes. If
+ # there are no spaces, the regular quote will produce the right answer.
+ if ((isinstance(string, str) and ' ' not in string) or
+ (isinstance(string, bytes) and b' ' not in string)):
+ return quote(string, safe, encoding, errors)
+ if isinstance(safe, str):
+ space = ' '
+ else:
+ space = b' '
+ string = quote(string, safe + space, encoding, errors)
+ return string.replace(' ', '+')
+
+def quote_from_bytes(bs, safe='/'):
+ """Like quote(), but accepts a bytes object rather than a str, and does
+ not perform string-to-bytes encoding. It always returns an ASCII string.
+ quote_from_bytes(b'abc def\x3f') -> 'abc%20def%3f'
+ """
+ if not isinstance(bs, (bytes, bytearray)):
+ raise TypeError("quote_from_bytes() expected bytes")
+ if not bs:
+ return ''
+ if isinstance(safe, str):
+ # Normalize 'safe' by converting to bytes and removing non-ASCII chars
+ safe = safe.encode('ascii', 'ignore')
+ else:
+ safe = bytes([c for c in safe if c < 128])
+ if not bs.rstrip(_ALWAYS_SAFE_BYTES + safe):
+ return bs.decode()
+ try:
+ quoter = _safe_quoters[safe]
+ except KeyError:
+ _safe_quoters[safe] = quoter = Quoter(safe).__getitem__
+ return ''.join([quoter(char) for char in bs])
+
+def urlencode(query, doseq=False, safe='', encoding=None, errors=None):
+ """Encode a sequence of two-element tuples or dictionary into a URL query string.
+
+ If any values in the query arg are sequences and doseq is true, each
+ sequence element is converted to a separate parameter.
+
+ If the query arg is a sequence of two-element tuples, the order of the
+ parameters in the output will match the order of parameters in the
+ input.
+
+ The query arg may be either a string or a bytes type. When query arg is a
+ string, the safe, encoding and error parameters are sent the quote_plus for
+ encoding.
+ """
+
+ if hasattr(query, "items"):
+ query = query.items()
+ else:
+ # It's a bother at times that strings and string-like objects are
+ # sequences.
+ try:
+ # non-sequence items should not work with len()
+ # non-empty strings will fail this
+ if len(query) and not isinstance(query[0], tuple):
+ raise TypeError
+ # Zero-length sequences of all types will get here and succeed,
+ # but that's a minor nit. Since the original implementation
+ # allowed empty dicts that type of behavior probably should be
+ # preserved for consistency
+ except TypeError:
+ ty, va, tb = sys.exc_info()
+ raise TypeError("not a valid non-string sequence "
+ "or mapping object").with_traceback(tb)
+
+ l = []
+ if not doseq:
+ for k, v in query:
+ if isinstance(k, bytes):
+ k = quote_plus(k, safe)
+ else:
+ k = quote_plus(str(k), safe, encoding, errors)
+
+ if isinstance(v, bytes):
+ v = quote_plus(v, safe)
+ else:
+ v = quote_plus(str(v), safe, encoding, errors)
+ l.append(k + '=' + v)
+ else:
+ for k, v in query:
+ if isinstance(k, bytes):
+ k = quote_plus(k, safe)
+ else:
+ k = quote_plus(str(k), safe, encoding, errors)
+
+ if isinstance(v, bytes):
+ v = quote_plus(v, safe)
+ l.append(k + '=' + v)
+ elif isinstance(v, str):
+ v = quote_plus(v, safe, encoding, errors)
+ l.append(k + '=' + v)
+ else:
+ try:
+ # Is this a sufficient test for sequence-ness?
+ x = len(v)
+ except TypeError:
+ # not a sequence
+ v = quote_plus(str(v), safe, encoding, errors)
+ l.append(k + '=' + v)
+ else:
+ # loop over the sequence
+ for elt in v:
+ if isinstance(elt, bytes):
+ elt = quote_plus(elt, safe)
+ else:
+ elt = quote_plus(str(elt), safe, encoding, errors)
+ l.append(k + '=' + elt)
+ return '&'.join(l)
+
+# Utilities to parse URLs (most of these return None for missing parts):
+# unwrap('<URL:type://host/path>') --> 'type://host/path'
+# splittype('type:opaquestring') --> 'type', 'opaquestring'
+# splithost('//host[:port]/path') --> 'host[:port]', '/path'
+# splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'
+# splitpasswd('user:passwd') -> 'user', 'passwd'
+# splitport('host:port') --> 'host', 'port'
+# splitquery('/path?query') --> '/path', 'query'
+# splittag('/path#tag') --> '/path', 'tag'
+# splitattr('/path;attr1=value1;attr2=value2;...') ->
+# '/path', ['attr1=value1', 'attr2=value2', ...]
+# splitvalue('attr=value') --> 'attr', 'value'
+# urllib.parse.unquote('abc%20def') -> 'abc def'
+# quote('abc def') -> 'abc%20def')
+
+def to_bytes(url):
+ """to_bytes(u"URL") --> 'URL'."""
+ # Most URL schemes require ASCII. If that changes, the conversion
+ # can be relaxed.
+ # XXX get rid of to_bytes()
+ if isinstance(url, str):
+ try:
+ url = url.encode("ASCII").decode()
+ except UnicodeError:
+ raise UnicodeError("URL " + repr(url) +
+ " contains non-ASCII characters")
+ return url
+
+def unwrap(url):
+ """unwrap('<URL:type://host/path>') --> 'type://host/path'."""
+ url = str(url).strip()
+ if url[:1] == '<' and url[-1:] == '>':
+ url = url[1:-1].strip()
+ if url[:4] == 'URL:': url = url[4:].strip()
+ return url
+
+_typeprog = None
+def splittype(url):
+ """splittype('type:opaquestring') --> 'type', 'opaquestring'."""
+ global _typeprog
+ if _typeprog is None:
+ import re
+ _typeprog = re.compile('^([^/:]+):')
+
+ match = _typeprog.match(url)
+ if match:
+ scheme = match.group(1)
+ return scheme.lower(), url[len(scheme) + 1:]
+ return None, url
+
+_hostprog = None
+def splithost(url):
+ """splithost('//host[:port]/path') --> 'host[:port]', '/path'."""
+ global _hostprog
+ if _hostprog is None:
+ import re
+ _hostprog = re.compile('^//([^/?]*)(.*)$')
+
+ match = _hostprog.match(url)
+ if match:
+ host_port = match.group(1)
+ path = match.group(2)
+ if path and not path.startswith('/'):
+ path = '/' + path
+ return host_port, path
+ return None, url
+
+_userprog = None
+def splituser(host):
+ """splituser('user[:passwd]@host[:port]') --> 'user[:passwd]', 'host[:port]'."""
+ global _userprog
+ if _userprog is None:
+ import re
+ _userprog = re.compile('^(.*)@(.*)$')
+
+ match = _userprog.match(host)
+ if match: return match.group(1, 2)
+ return None, host
+
+_passwdprog = None
+def splitpasswd(user):
+ """splitpasswd('user:passwd') -> 'user', 'passwd'."""
+ global _passwdprog
+ if _passwdprog is None:
+ import re
+ _passwdprog = re.compile('^([^:]*):(.*)$',re.S)
+
+ match = _passwdprog.match(user)
+ if match: return match.group(1, 2)
+ return user, None
+
+# splittag('/path#tag') --> '/path', 'tag'
+_portprog = None
+def splitport(host):
+ """splitport('host:port') --> 'host', 'port'."""
+ global _portprog
+ if _portprog is None:
+ import re
+ _portprog = re.compile('^(.*):([0-9]+)$')
+
+ match = _portprog.match(host)
+ if match: return match.group(1, 2)
+ return host, None
+
+_nportprog = None
+def splitnport(host, defport=-1):
+ """Split host and port, returning numeric port.
+ Return given default port if no ':' found; defaults to -1.
+ Return numerical port if a valid number are found after ':'.
+ Return None if ':' but not a valid number."""
+ global _nportprog
+ if _nportprog is None:
+ import re
+ _nportprog = re.compile('^(.*):(.*)$')
+
+ match = _nportprog.match(host)
+ if match:
+ host, port = match.group(1, 2)
+ try:
+ if not port: raise ValueError("no digits")
+ nport = int(port)
+ except ValueError:
+ nport = None
+ return host, nport
+ return host, defport
+
+_queryprog = None
+def splitquery(url):
+ """splitquery('/path?query') --> '/path', 'query'."""
+ global _queryprog
+ if _queryprog is None:
+ import re
+ _queryprog = re.compile('^(.*)\?([^?]*)$')
+
+ match = _queryprog.match(url)
+ if match: return match.group(1, 2)
+ return url, None
+
+_tagprog = None
+def splittag(url):
+ """splittag('/path#tag') --> '/path', 'tag'."""
+ global _tagprog
+ if _tagprog is None:
+ import re
+ _tagprog = re.compile('^(.*)#([^#]*)$')
+
+ match = _tagprog.match(url)
+ if match: return match.group(1, 2)
+ return url, None
+
+def splitattr(url):
+ """splitattr('/path;attr1=value1;attr2=value2;...') ->
+ '/path', ['attr1=value1', 'attr2=value2', ...]."""
+ words = url.split(';')
+ return words[0], words[1:]
+
+_valueprog = None
+def splitvalue(attr):
+ """splitvalue('attr=value') --> 'attr', 'value'."""
+ global _valueprog
+ if _valueprog is None:
+ import re
+ _valueprog = re.compile('^([^=]*)=(.*)$')
+
+ match = _valueprog.match(attr)
+ if match: return match.group(1, 2)
+ return attr, None
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
new file mode 100644
index 00000000000..eb45c7eac6e
--- /dev/null
+++ b/Lib/urllib/request.py
@@ -0,0 +1,2484 @@
+"""An extensible library for opening URLs using a variety of protocols
+
+The simplest way to use this module is to call the urlopen function,
+which accepts a string containing a URL or a Request object (described
+below). It opens the URL and returns the results as file-like
+object; the returned object has some extra methods described below.
+
+The OpenerDirector manages a collection of Handler objects that do
+all the actual work. Each Handler implements a particular protocol or
+option. The OpenerDirector is a composite object that invokes the
+Handlers needed to open the requested URL. For example, the
+HTTPHandler performs HTTP GET and POST requests and deals with
+non-error returns. The HTTPRedirectHandler automatically deals with
+HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
+deals with digest authentication.
+
+urlopen(url, data=None) -- Basic usage is the same as original
+urllib. pass the url and optionally data to post to an HTTP URL, and
+get a file-like object back. One difference is that you can also pass
+a Request instance instead of URL. Raises a URLError (subclass of
+IOError); for HTTP errors, raises an HTTPError, which can also be
+treated as a valid response.
+
+build_opener -- Function that creates a new OpenerDirector instance.
+Will install the default handlers. Accepts one or more Handlers as
+arguments, either instances or Handler classes that it will
+instantiate. If one of the argument is a subclass of the default
+handler, the argument will be installed instead of the default.
+
+install_opener -- Installs a new opener as the default opener.
+
+objects of interest:
+
+OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
+the Handler classes, while dealing with requests and responses.
+
+Request -- An object that encapsulates the state of a request. The
+state can be as simple as the URL. It can also include extra HTTP
+headers, e.g. a User-Agent.
+
+BaseHandler --
+
+internals:
+BaseHandler and parent
+_call_chain conventions
+
+Example usage:
+
+import urllib.request
+
+# set up authentication info
+authinfo = urllib.request.HTTPBasicAuthHandler()
+authinfo.add_password(realm='PDQ Application',
+ uri='https://mahler:8092/site-updates.py',
+ user='klem',
+ passwd='geheim$parole')
+
+proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})
+
+# build a new opener that adds authentication and caching FTP handlers
+opener = urllib.request.build_opener(proxy_support, authinfo,
+ urllib.request.CacheFTPHandler)
+
+# install it
+urllib.request.install_opener(opener)
+
+f = urllib.request.urlopen('http://www.python.org/')
+"""
+
+# XXX issues:
+# If an authentication error handler that tries to perform
+# authentication for some reason but fails, how should the error be
+# signalled? The client needs to know the HTTP error code. But if
+# the handler knows that the problem was, e.g., that it didn't know
+# that hash algo that requested in the challenge, it would be good to
+# pass that information along to the client, too.
+# ftp errors aren't handled cleanly
+# check digest against correct (i.e. non-apache) implementation
+
+# Possible extensions:
+# complex proxies XXX not sure what exactly was meant by this
+# abstract factory for opener
+
+import base64
+import bisect
+import email
+import hashlib
+import http.client
+import io
+import os
+import posixpath
+import random
+import re
+import socket
+import sys
+import time
+import collections
+import warnings
+
+from urllib.error import URLError, HTTPError, ContentTooShortError
+from urllib.parse import (
+ urlparse, urlsplit, urljoin, unwrap, quote, unquote,
+ splittype, splithost, splitport, splituser, splitpasswd,
+ splitattr, splitquery, splitvalue, splittag, to_bytes, urlunparse)
+from urllib.response import addinfourl, addclosehook
+
+# check for SSL
+try:
+ import ssl
+except ImportError:
+ _have_ssl = False
+else:
+ _have_ssl = True
+
+# used in User-Agent header sent
+__version__ = sys.version[:3]
+
+_opener = None
+def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
+ *, cafile=None, capath=None):
+ global _opener
+ if cafile or capath:
+ if not _have_ssl:
+ raise ValueError('SSL support not available')
+ context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
+ context.options |= ssl.OP_NO_SSLv2
+ if cafile or capath:
+ context.verify_mode = ssl.CERT_REQUIRED
+ context.load_verify_locations(cafile, capath)
+ check_hostname = True
+ else:
+ check_hostname = False
+ https_handler = HTTPSHandler(context=context, check_hostname=check_hostname)
+ opener = build_opener(https_handler)
+ elif _opener is None:
+ _opener = opener = build_opener()
+ else:
+ opener = _opener
+ return opener.open(url, data, timeout)
+
+def install_opener(opener):
+ global _opener
+ _opener = opener
+
+# TODO(jhylton): Make this work with the same global opener.
+_urlopener = None
+def urlretrieve(url, filename=None, reporthook=None, data=None):
+ global _urlopener
+ if not _urlopener:
+ _urlopener = FancyURLopener()
+ return _urlopener.retrieve(url, filename, reporthook, data)
+
+def urlcleanup():
+ if _urlopener:
+ _urlopener.cleanup()
+ global _opener
+ if _opener:
+ _opener = None
+
+# copied from cookielib.py
+_cut_port_re = re.compile(r":\d+$", re.ASCII)
+def request_host(request):
+ """Return request-host, as defined by RFC 2965.
+
+ Variation from RFC: returned value is lowercased, for convenient
+ comparison.
+
+ """
+ url = request.full_url
+ host = urlparse(url)[1]
+ if host == "":
+ host = request.get_header("Host", "")
+
+ # remove port, if present
+ host = _cut_port_re.sub("", host, 1)
+ return host.lower()
+
+class Request:
+
+ def __init__(self, url, data=None, headers={},
+ origin_req_host=None, unverifiable=False):
+ # unwrap('<URL:type://host/path>') --> 'type://host/path'
+ self.full_url = unwrap(url)
+ self.full_url, self.fragment = splittag(self.full_url)
+ self.data = data
+ self.headers = {}
+ self._tunnel_host = None
+ for key, value in headers.items():
+ self.add_header(key, value)
+ self.unredirected_hdrs = {}
+ if origin_req_host is None:
+ origin_req_host = request_host(self)
+ self.origin_req_host = origin_req_host
+ self.unverifiable = unverifiable
+ self._parse()
+
+ def _parse(self):
+ self.type, rest = splittype(self.full_url)
+ if self.type is None:
+ raise ValueError("unknown url type: %s" % self.full_url)
+ self.host, self.selector = splithost(rest)
+ if self.host:
+ self.host = unquote(self.host)
+
+ def get_method(self):
+ if self.data is not None:
+ return "POST"
+ else:
+ return "GET"
+
+ # Begin deprecated methods
+
+ def add_data(self, data):
+ self.data = data
+
+ def has_data(self):
+ return self.data is not None
+
+ def get_data(self):
+ return self.data
+
+ def get_full_url(self):
+ if self.fragment:
+ return '%s#%s' % (self.full_url, self.fragment)
+ else:
+ return self.full_url
+
+ def get_type(self):
+ return self.type
+
+ def get_host(self):
+ return self.host
+
+ def get_selector(self):
+ return self.selector
+
+ def is_unverifiable(self):
+ return self.unverifiable
+
+ def get_origin_req_host(self):
+ return self.origin_req_host
+
+ # End deprecated methods
+
+ def set_proxy(self, host, type):
+ if self.type == 'https' and not self._tunnel_host:
+ self._tunnel_host = self.host
+ else:
+ self.type= type
+ self.selector = self.full_url
+ self.host = host
+
+ def has_proxy(self):
+ return self.selector == self.full_url
+
+ def add_header(self, key, val):
+ # useful for something like authentication
+ self.headers[key.capitalize()] = val
+
+ def add_unredirected_header(self, key, val):
+ # will not be added to a redirected request
+ self.unredirected_hdrs[key.capitalize()] = val
+
+ def has_header(self, header_name):
+ return (header_name in self.headers or
+ header_name in self.unredirected_hdrs)
+
+ def get_header(self, header_name, default=None):
+ return self.headers.get(
+ header_name,
+ self.unredirected_hdrs.get(header_name, default))
+
+ def header_items(self):
+ hdrs = self.unredirected_hdrs.copy()
+ hdrs.update(self.headers)
+ return list(hdrs.items())
+
+class OpenerDirector:
+ def __init__(self):
+ client_version = "Python-urllib/%s" % __version__
+ self.addheaders = [('User-agent', client_version)]
+ # self.handlers is retained only for backward compatibility
+ self.handlers = []
+ # manage the individual handlers
+ self.handle_open = {}
+ self.handle_error = {}
+ self.process_response = {}
+ self.process_request = {}
+
+ def add_handler(self, handler):
+ if not hasattr(handler, "add_parent"):
+ raise TypeError("expected BaseHandler instance, got %r" %
+ type(handler))
+
+ added = False
+ for meth in dir(handler):
+ if meth in ["redirect_request", "do_open", "proxy_open"]:
+ # oops, coincidental match
+ continue
+
+ i = meth.find("_")
+ protocol = meth[:i]
+ condition = meth[i+1:]
+
+ if condition.startswith("error"):
+ j = condition.find("_") + i + 1
+ kind = meth[j+1:]
+ try:
+ kind = int(kind)
+ except ValueError:
+ pass
+ lookup = self.handle_error.get(protocol, {})
+ self.handle_error[protocol] = lookup
+ elif condition == "open":
+ kind = protocol
+ lookup = self.handle_open
+ elif condition == "response":
+ kind = protocol
+ lookup = self.process_response
+ elif condition == "request":
+ kind = protocol
+ lookup = self.process_request
+ else:
+ continue
+
+ handlers = lookup.setdefault(kind, [])
+ if handlers:
+ bisect.insort(handlers, handler)
+ else:
+ handlers.append(handler)
+ added = True
+
+ if added:
+ bisect.insort(self.handlers, handler)
+ handler.add_parent(self)
+
+ def close(self):
+ # Only exists for backwards compatibility.
+ pass
+
+ def _call_chain(self, chain, kind, meth_name, *args):
+ # Handlers raise an exception if no one else should try to handle
+ # the request, or return None if they can't but another handler
+ # could. Otherwise, they return the response.
+ handlers = chain.get(kind, ())
+ for handler in handlers:
+ func = getattr(handler, meth_name)
+ result = func(*args)
+ if result is not None:
+ return result
+
+ def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
+ # accept a URL or a Request object
+ if isinstance(fullurl, str):
+ req = Request(fullurl, data)
+ else:
+ req = fullurl
+ if data is not None:
+ req.data = data
+
+ req.timeout = timeout
+ protocol = req.type
+
+ # pre-process request
+ meth_name = protocol+"_request"
+ for processor in self.process_request.get(protocol, []):
+ meth = getattr(processor, meth_name)
+ req = meth(req)
+
+ response = self._open(req, data)
+
+ # post-process response
+ meth_name = protocol+"_response"
+ for processor in self.process_response.get(protocol, []):
+ meth = getattr(processor, meth_name)
+ response = meth(req, response)
+
+ return response
+
+ def _open(self, req, data=None):
+ result = self._call_chain(self.handle_open, 'default',
+ 'default_open', req)
+ if result:
+ return result
+
+ protocol = req.type
+ result = self._call_chain(self.handle_open, protocol, protocol +
+ '_open', req)
+ if result:
+ return result
+
+ return self._call_chain(self.handle_open, 'unknown',
+ 'unknown_open', req)
+
+ def error(self, proto, *args):
+ if proto in ('http', 'https'):
+ # XXX http[s] protocols are special-cased
+ dict = self.handle_error['http'] # https is not different than http
+ proto = args[2] # YUCK!
+ meth_name = 'http_error_%s' % proto
+ http_err = 1
+ orig_args = args
+ else:
+ dict = self.handle_error
+ meth_name = proto + '_error'
+ http_err = 0
+ args = (dict, proto, meth_name) + args
+ result = self._call_chain(*args)
+ if result:
+ return result
+
+ if http_err:
+ args = (dict, 'default', 'http_error_default') + orig_args
+ return self._call_chain(*args)
+
+# XXX probably also want an abstract factory that knows when it makes
+# sense to skip a superclass in favor of a subclass and when it might
+# make sense to include both
+
+def build_opener(*handlers):
+ """Create an opener object from a list of handlers.
+
+ The opener will use several default handlers, including support
+ for HTTP, FTP and when applicable HTTPS.
+
+ If any of the handlers passed as arguments are subclasses of the
+ default handlers, the default handlers will not be used.
+ """
+ def isclass(obj):
+ return isinstance(obj, type) or hasattr(obj, "__bases__")
+
+ opener = OpenerDirector()
+ default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
+ HTTPDefaultErrorHandler, HTTPRedirectHandler,
+ FTPHandler, FileHandler, HTTPErrorProcessor]
+ if hasattr(http.client, "HTTPSConnection"):
+ default_classes.append(HTTPSHandler)
+ skip = set()
+ for klass in default_classes:
+ for check in handlers:
+ if isclass(check):
+ if issubclass(check, klass):
+ skip.add(klass)
+ elif isinstance(check, klass):
+ skip.add(klass)
+ for klass in skip:
+ default_classes.remove(klass)
+
+ for klass in default_classes:
+ opener.add_handler(klass())
+
+ for h in handlers:
+ if isclass(h):
+ h = h()
+ opener.add_handler(h)
+ return opener
+
+class BaseHandler:
+ handler_order = 500
+
+ def add_parent(self, parent):
+ self.parent = parent
+
+ def close(self):
+ # Only exists for backwards compatibility
+ pass
+
+ def __lt__(self, other):
+ if not hasattr(other, "handler_order"):
+ # Try to preserve the old behavior of having custom classes
+ # inserted after default ones (works only for custom user
+ # classes which are not aware of handler_order).
+ return True
+ return self.handler_order < other.handler_order
+
+
+class HTTPErrorProcessor(BaseHandler):
+ """Process HTTP error responses."""
+ handler_order = 1000 # after all other processing
+
+ def http_response(self, request, response):
+ code, msg, hdrs = response.code, response.msg, response.info()
+
+ # According to RFC 2616, "2xx" code indicates that the client's
+ # request was successfully received, understood, and accepted.
+ if not (200 <= code < 300):
+ response = self.parent.error(
+ 'http', request, response, code, msg, hdrs)
+
+ return response
+
+ https_response = http_response
+
+class HTTPDefaultErrorHandler(BaseHandler):
+ def http_error_default(self, req, fp, code, msg, hdrs):
+ raise HTTPError(req.full_url, code, msg, hdrs, fp)
+
+class HTTPRedirectHandler(BaseHandler):
+ # maximum number of redirections to any single URL
+ # this is needed because of the state that cookies introduce
+ max_repeats = 4
+ # maximum total number of redirections (regardless of URL) before
+ # assuming we're in a loop
+ max_redirections = 10
+
+ def redirect_request(self, req, fp, code, msg, headers, newurl):
+ """Return a Request or None in response to a redirect.
+
+ This is called by the http_error_30x methods when a
+ redirection response is received. If a redirection should
+ take place, return a new Request to allow http_error_30x to
+ perform the redirect. Otherwise, raise HTTPError if no-one
+ else should try to handle this url. Return None if you can't
+ but another Handler might.
+ """
+ m = req.get_method()
+ if (not (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
+ or code in (301, 302, 303) and m == "POST")):
+ raise HTTPError(req.full_url, code, msg, headers, fp)
+
+ # Strictly (according to RFC 2616), 301 or 302 in response to
+ # a POST MUST NOT cause a redirection without confirmation
+ # from the user (of urllib.request, in this case). In practice,
+ # essentially all clients do redirect in this case, so we do
+ # the same.
+ # be conciliant with URIs containing a space
+ newurl = newurl.replace(' ', '%20')
+ CONTENT_HEADERS = ("content-length", "content-type")
+ newheaders = dict((k, v) for k, v in req.headers.items()
+ if k.lower() not in CONTENT_HEADERS)
+ return Request(newurl,
+ headers=newheaders,
+ origin_req_host=req.origin_req_host,
+ unverifiable=True)
+
+ # Implementation note: To avoid the server sending us into an
+ # infinite loop, the request object needs to track what URLs we
+ # have already seen. Do this by adding a handler-specific
+ # attribute to the Request object.
+ def http_error_302(self, req, fp, code, msg, headers):
+ # Some servers (incorrectly) return multiple Location headers
+ # (so probably same goes for URI). Use first header.
+ if "location" in headers:
+ newurl = headers["location"]
+ elif "uri" in headers:
+ newurl = headers["uri"]
+ else:
+ return
+
+ # fix a possible malformed URL
+ urlparts = urlparse(newurl)
+
+ # For security reasons we don't allow redirection to anything other
+ # than http, https or ftp.
+
+ if urlparts.scheme not in ('http', 'https', 'ftp', ''):
+ raise HTTPError(
+ newurl, code,
+ "%s - Redirection to url '%s' is not allowed" % (msg, newurl),
+ headers, fp)
+
+ if not urlparts.path:
+ urlparts = list(urlparts)
+ urlparts[2] = "/"
+ newurl = urlunparse(urlparts)
+
+ newurl = urljoin(req.full_url, newurl)
+
+ # XXX Probably want to forget about the state of the current
+ # request, although that might interact poorly with other
+ # handlers that also use handler-specific request attributes
+ new = self.redirect_request(req, fp, code, msg, headers, newurl)
+ if new is None:
+ return
+
+ # loop detection
+ # .redirect_dict has a key url if url was previously visited.
+ if hasattr(req, 'redirect_dict'):
+ visited = new.redirect_dict = req.redirect_dict
+ if (visited.get(newurl, 0) >= self.max_repeats or
+ len(visited) >= self.max_redirections):
+ raise HTTPError(req.full_url, code,
+ self.inf_msg + msg, headers, fp)
+ else:
+ visited = new.redirect_dict = req.redirect_dict = {}
+ visited[newurl] = visited.get(newurl, 0) + 1
+
+ # Don't close the fp until we are sure that we won't use it
+ # with HTTPError.
+ fp.read()
+ fp.close()
+
+ return self.parent.open(new, timeout=req.timeout)
+
+ http_error_301 = http_error_303 = http_error_307 = http_error_302
+
+ inf_msg = "The HTTP server returned a redirect error that would " \
+ "lead to an infinite loop.\n" \
+ "The last 30x error message was:\n"
+
+
+def _parse_proxy(proxy):
+ """Return (scheme, user, password, host/port) given a URL or an authority.
+
+ If a URL is supplied, it must have an authority (host:port) component.
+ According to RFC 3986, having an authority component means the URL must
+ have two slashes after the scheme:
+
+ >>> _parse_proxy('file:/ftp.example.com/')
+ Traceback (most recent call last):
+ ValueError: proxy URL with no authority: 'file:/ftp.example.com/'
+
+ The first three items of the returned tuple may be None.
+
+ Examples of authority parsing:
+
+ >>> _parse_proxy('proxy.example.com')
+ (None, None, None, 'proxy.example.com')
+ >>> _parse_proxy('proxy.example.com:3128')
+ (None, None, None, 'proxy.example.com:3128')
+
+ The authority component may optionally include userinfo (assumed to be
+ username:password):
+
+ >>> _parse_proxy('joe:password@proxy.example.com')
+ (None, 'joe', 'password', 'proxy.example.com')
+ >>> _parse_proxy('joe:password@proxy.example.com:3128')
+ (None, 'joe', 'password', 'proxy.example.com:3128')
+
+ Same examples, but with URLs instead:
+
+ >>> _parse_proxy('http://proxy.example.com/')
+ ('http', None, None, 'proxy.example.com')
+ >>> _parse_proxy('http://proxy.example.com:3128/')
+ ('http', None, None, 'proxy.example.com:3128')
+ >>> _parse_proxy('http://joe:password@proxy.example.com/')
+ ('http', 'joe', 'password', 'proxy.example.com')
+ >>> _parse_proxy('http://joe:password@proxy.example.com:3128')
+ ('http', 'joe', 'password', 'proxy.example.com:3128')
+
+ Everything after the authority is ignored:
+
+ >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128')
+ ('ftp', 'joe', 'password', 'proxy.example.com')
+
+ Test for no trailing '/' case:
+
+ >>> _parse_proxy('http://joe:password@proxy.example.com')
+ ('http', 'joe', 'password', 'proxy.example.com')
+
+ """
+ scheme, r_scheme = splittype(proxy)
+ if not r_scheme.startswith("/"):
+ # authority
+ scheme = None
+ authority = proxy
+ else:
+ # URL
+ if not r_scheme.startswith("//"):
+ raise ValueError("proxy URL with no authority: %r" % proxy)
+ # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
+ # and 3.3.), path is empty or starts with '/'
+ end = r_scheme.find("/", 2)
+ if end == -1:
+ end = None
+ authority = r_scheme[2:end]
+ userinfo, hostport = splituser(authority)
+ if userinfo is not None:
+ user, password = splitpasswd(userinfo)
+ else:
+ user = password = None
+ return scheme, user, password, hostport
+
+class ProxyHandler(BaseHandler):
+ # Proxies must be in front
+ handler_order = 100
+
+ def __init__(self, proxies=None):
+ if proxies is None:
+ proxies = getproxies()
+ assert hasattr(proxies, 'keys'), "proxies must be a mapping"
+ self.proxies = proxies
+ for type, url in proxies.items():
+ setattr(self, '%s_open' % type,
+ lambda r, proxy=url, type=type, meth=self.proxy_open: \
+ meth(r, proxy, type))
+
+ def proxy_open(self, req, proxy, type):
+ orig_type = req.type
+ proxy_type, user, password, hostport = _parse_proxy(proxy)
+ if proxy_type is None:
+ proxy_type = orig_type
+
+ if req.host and proxy_bypass(req.host):
+ return None
+
+ if user and password:
+ user_pass = '%s:%s' % (unquote(user),
+ unquote(password))
+ creds = base64.b64encode(user_pass.encode()).decode("ascii")
+ req.add_header('Proxy-authorization', 'Basic ' + creds)
+ hostport = unquote(hostport)
+ req.set_proxy(hostport, proxy_type)
+ if orig_type == proxy_type or orig_type == 'https':
+ # let other handlers take care of it
+ return None
+ else:
+ # need to start over, because the other handlers don't
+ # grok the proxy's URL type
+ # e.g. if we have a constructor arg proxies like so:
+ # {'http': 'ftp://proxy.example.com'}, we may end up turning
+ # a request for http://acme.example.com/a into one for
+ # ftp://proxy.example.com/a
+ return self.parent.open(req, timeout=req.timeout)
+
+class HTTPPasswordMgr:
+
+ def __init__(self):
+ self.passwd = {}
+
+ def add_password(self, realm, uri, user, passwd):
+ # uri could be a single URI or a sequence
+ if isinstance(uri, str):
+ uri = [uri]
+ if realm not in self.passwd:
+ self.passwd[realm] = {}
+ for default_port in True, False:
+ reduced_uri = tuple(
+ [self.reduce_uri(u, default_port) for u in uri])
+ self.passwd[realm][reduced_uri] = (user, passwd)
+
+ def find_user_password(self, realm, authuri):
+ domains = self.passwd.get(realm, {})
+ for default_port in True, False:
+ reduced_authuri = self.reduce_uri(authuri, default_port)
+ for uris, authinfo in domains.items():
+ for uri in uris:
+ if self.is_suburi(uri, reduced_authuri):
+ return authinfo
+ return None, None
+
+ def reduce_uri(self, uri, default_port=True):
+ """Accept authority or URI and extract only the authority and path."""
+ # note HTTP URLs do not have a userinfo component
+ parts = urlsplit(uri)
+ if parts[1]:
+ # URI
+ scheme = parts[0]
+ authority = parts[1]
+ path = parts[2] or '/'
+ else:
+ # host or host:port
+ scheme = None
+ authority = uri
+ path = '/'
+ host, port = splitport(authority)
+ if default_port and port is None and scheme is not None:
+ dport = {"http": 80,
+ "https": 443,
+ }.get(scheme)
+ if dport is not None:
+ authority = "%s:%d" % (host, dport)
+ return authority, path
+
+ def is_suburi(self, base, test):
+ """Check if test is below base in a URI tree
+
+ Both args must be URIs in reduced form.
+ """
+ if base == test:
+ return True
+ if base[0] != test[0]:
+ return False
+ common = posixpath.commonprefix((base[1], test[1]))
+ if len(common) == len(base[1]):
+ return True
+ return False
+
+
+class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr):
+
+ def find_user_password(self, realm, authuri):
+ user, password = HTTPPasswordMgr.find_user_password(self, realm,
+ authuri)
+ if user is not None:
+ return user, password
+ return HTTPPasswordMgr.find_user_password(self, None, authuri)
+
+
+class AbstractBasicAuthHandler:
+
+ # XXX this allows for multiple auth-schemes, but will stupidly pick
+ # the last one with a realm specified.
+
+ # allow for double- and single-quoted realm values
+ # (single quotes are a violation of the RFC, but appear in the wild)
+ rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+'
+ 'realm=(["\']?)([^"\']*)\\2', re.I)
+
+ # XXX could pre-emptively send auth info already accepted (RFC 2617,
+ # end of section 2, and section 1.2 immediately after "credentials"
+ # production).
+
+ def __init__(self, password_mgr=None):
+ if password_mgr is None:
+ password_mgr = HTTPPasswordMgr()
+ self.passwd = password_mgr
+ self.add_password = self.passwd.add_password
+ self.retried = 0
+
+ def reset_retry_count(self):
+ self.retried = 0
+
+ def http_error_auth_reqed(self, authreq, host, req, headers):
+ # host may be an authority (without userinfo) or a URL with an
+ # authority
+ # XXX could be multiple headers
+ authreq = headers.get(authreq, None)
+
+ if self.retried > 5:
+ # retry sending the username:password 5 times before failing.
+ raise HTTPError(req.get_full_url(), 401, "basic auth failed",
+ headers, None)
+ else:
+ self.retried += 1
+
+ if authreq:
+ mo = AbstractBasicAuthHandler.rx.search(authreq)
+ if mo:
+ scheme, quote, realm = mo.groups()
+ if quote not in ["'", '"']:
+ warnings.warn("Basic Auth Realm was unquoted",
+ UserWarning, 2)
+ if scheme.lower() == 'basic':
+ response = self.retry_http_basic_auth(host, req, realm)
+ if response and response.code != 401:
+ self.retried = 0
+ return response
+
+ def retry_http_basic_auth(self, host, req, realm):
+ user, pw = self.passwd.find_user_password(realm, host)
+ if pw is not None:
+ raw = "%s:%s" % (user, pw)
+ auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii")
+ if req.headers.get(self.auth_header, None) == auth:
+ return None
+ req.add_unredirected_header(self.auth_header, auth)
+ return self.parent.open(req, timeout=req.timeout)
+ else:
+ return None
+
+
+class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
+
+ auth_header = 'Authorization'
+
+ def http_error_401(self, req, fp, code, msg, headers):
+ url = req.full_url
+ response = self.http_error_auth_reqed('www-authenticate',
+ url, req, headers)
+ self.reset_retry_count()
+ return response
+
+
+class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
+
+ auth_header = 'Proxy-authorization'
+
+ def http_error_407(self, req, fp, code, msg, headers):
+ # http_error_auth_reqed requires that there is no userinfo component in
+ # authority. Assume there isn't one, since urllib.request does not (and
+ # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
+ # userinfo.
+ authority = req.host
+ response = self.http_error_auth_reqed('proxy-authenticate',
+ authority, req, headers)
+ self.reset_retry_count()
+ return response
+
+
+def randombytes(n):
+ """Return n random bytes."""
+ return os.urandom(n)
+
+class AbstractDigestAuthHandler:
+ # Digest authentication is specified in RFC 2617.
+
+ # XXX The client does not inspect the Authentication-Info header
+ # in a successful response.
+
+ # XXX It should be possible to test this implementation against
+ # a mock server that just generates a static set of challenges.
+
+ # XXX qop="auth-int" supports is shaky
+
+ def __init__(self, passwd=None):
+ if passwd is None:
+ passwd = HTTPPasswordMgr()
+ self.passwd = passwd
+ self.add_password = self.passwd.add_password
+ self.retried = 0
+ self.nonce_count = 0
+ self.last_nonce = None
+
+ def reset_retry_count(self):
+ self.retried = 0
+
+ def http_error_auth_reqed(self, auth_header, host, req, headers):
+ authreq = headers.get(auth_header, None)
+ if self.retried > 5:
+ # Don't fail endlessly - if we failed once, we'll probably
+ # fail a second time. Hm. Unless the Password Manager is
+ # prompting for the information. Crap. This isn't great
+ # but it's better than the current 'repeat until recursion
+ # depth exceeded' approach <wink>
+ raise HTTPError(req.full_url, 401, "digest auth failed",
+ headers, None)
+ else:
+ self.retried += 1
+ if authreq:
+ scheme = authreq.split()[0]
+ if scheme.lower() == 'digest':
+ return self.retry_http_digest_auth(req, authreq)
+
+ def retry_http_digest_auth(self, req, auth):
+ token, challenge = auth.split(' ', 1)
+ chal = parse_keqv_list(filter(None, parse_http_list(challenge)))
+ auth = self.get_authorization(req, chal)
+ if auth:
+ auth_val = 'Digest %s' % auth
+ if req.headers.get(self.auth_header, None) == auth_val:
+ return None
+ req.add_unredirected_header(self.auth_header, auth_val)
+ resp = self.parent.open(req, timeout=req.timeout)
+ return resp
+
+ def get_cnonce(self, nonce):
+ # The cnonce-value is an opaque
+ # quoted string value provided by the client and used by both client
+ # and server to avoid chosen plaintext attacks, to provide mutual
+ # authentication, and to provide some message integrity protection.
+ # This isn't a fabulous effort, but it's probably Good Enough.
+ s = "%s:%s:%s:" % (self.nonce_count, nonce, time.ctime())
+ b = s.encode("ascii") + randombytes(8)
+ dig = hashlib.sha1(b).hexdigest()
+ return dig[:16]
+
+ def get_authorization(self, req, chal):
+ try:
+ realm = chal['realm']
+ nonce = chal['nonce']
+ qop = chal.get('qop')
+ algorithm = chal.get('algorithm', 'MD5')
+ # mod_digest doesn't send an opaque, even though it isn't
+ # supposed to be optional
+ opaque = chal.get('opaque', None)
+ except KeyError:
+ return None
+
+ H, KD = self.get_algorithm_impls(algorithm)
+ if H is None:
+ return None
+
+ user, pw = self.passwd.find_user_password(realm, req.full_url)
+ if user is None:
+ return None
+
+ # XXX not implemented yet
+ if req.data is not None:
+ entdig = self.get_entity_digest(req.data, chal)
+ else:
+ entdig = None
+
+ A1 = "%s:%s:%s" % (user, realm, pw)
+ A2 = "%s:%s" % (req.get_method(),
+ # XXX selector: what about proxies and full urls
+ req.selector)
+ if qop == 'auth':
+ if nonce == self.last_nonce:
+ self.nonce_count += 1
+ else:
+ self.nonce_count = 1
+ self.last_nonce = nonce
+ ncvalue = '%08x' % self.nonce_count
+ cnonce = self.get_cnonce(nonce)
+ noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, H(A2))
+ respdig = KD(H(A1), noncebit)
+ elif qop is None:
+ respdig = KD(H(A1), "%s:%s" % (nonce, H(A2)))
+ else:
+ # XXX handle auth-int.
+ raise URLError("qop '%s' is not supported." % qop)
+
+ # XXX should the partial digests be encoded too?
+
+ base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
+ 'response="%s"' % (user, realm, nonce, req.selector,
+ respdig)
+ if opaque:
+ base += ', opaque="%s"' % opaque
+ if entdig:
+ base += ', digest="%s"' % entdig
+ base += ', algorithm="%s"' % algorithm
+ if qop:
+ base += ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce)
+ return base
+
+ def get_algorithm_impls(self, algorithm):
+ # lambdas assume digest modules are imported at the top level
+ if algorithm == 'MD5':
+ H = lambda x: hashlib.md5(x.encode("ascii")).hexdigest()
+ elif algorithm == 'SHA':
+ H = lambda x: hashlib.sha1(x.encode("ascii")).hexdigest()
+ # XXX MD5-sess
+ KD = lambda s, d: H("%s:%s" % (s, d))
+ return H, KD
+
+ def get_entity_digest(self, data, chal):
+ # XXX not implemented yet
+ return None
+
+
+class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
+ """An authentication protocol defined by RFC 2069
+
+ Digest authentication improves on basic authentication because it
+ does not transmit passwords in the clear.
+ """
+
+ auth_header = 'Authorization'
+ handler_order = 490 # before Basic auth
+
+ def http_error_401(self, req, fp, code, msg, headers):
+ host = urlparse(req.full_url)[1]
+ retry = self.http_error_auth_reqed('www-authenticate',
+ host, req, headers)
+ self.reset_retry_count()
+ return retry
+
+
+class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
+
+ auth_header = 'Proxy-Authorization'
+ handler_order = 490 # before Basic auth
+
+ def http_error_407(self, req, fp, code, msg, headers):
+ host = req.host
+ retry = self.http_error_auth_reqed('proxy-authenticate',
+ host, req, headers)
+ self.reset_retry_count()
+ return retry
+
+class AbstractHTTPHandler(BaseHandler):
+
+ def __init__(self, debuglevel=0):
+ self._debuglevel = debuglevel
+
+ def set_http_debuglevel(self, level):
+ self._debuglevel = level
+
+ def do_request_(self, request):
+ host = request.host
+ if not host:
+ raise URLError('no host given')
+
+ if request.data is not None: # POST
+ data = request.data
+ if isinstance(data, str):
+ msg = "POST data should be bytes or an iterable of bytes. "\
+ "It cannot be of type str."
+ raise TypeError(msg)
+ if not request.has_header('Content-type'):
+ request.add_unredirected_header(
+ 'Content-type',
+ 'application/x-www-form-urlencoded')
+ if not request.has_header('Content-length'):
+ try:
+ mv = memoryview(data)
+ except TypeError:
+ if isinstance(data, collections.Iterable):
+ raise ValueError("Content-Length should be specified "
+ "for iterable data of type %r %r" % (type(data),
+ data))
+ else:
+ request.add_unredirected_header(
+ 'Content-length', '%d' % (len(mv) * mv.itemsize))
+
+ sel_host = host
+ if request.has_proxy():
+ scheme, sel = splittype(request.selector)
+ sel_host, sel_path = splithost(sel)
+ if not request.has_header('Host'):
+ request.add_unredirected_header('Host', sel_host)
+ for name, value in self.parent.addheaders:
+ name = name.capitalize()
+ if not request.has_header(name):
+ request.add_unredirected_header(name, value)
+
+ return request
+
+ def do_open(self, http_class, req, **http_conn_args):
+ """Return an HTTPResponse object for the request, using http_class.
+
+ http_class must implement the HTTPConnection API from http.client.
+ """
+ host = req.host
+ if not host:
+ raise URLError('no host given')
+
+ # will parse host:port
+ h = http_class(host, timeout=req.timeout, **http_conn_args)
+
+ headers = dict(req.unredirected_hdrs)
+ headers.update(dict((k, v) for k, v in req.headers.items()
+ if k not in headers))
+
+ # TODO(jhylton): Should this be redesigned to handle
+ # persistent connections?
+
+ # We want to make an HTTP/1.1 request, but the addinfourl
+ # class isn't prepared to deal with a persistent connection.
+ # It will try to read all remaining data from the socket,
+ # which will block while the server waits for the next request.
+ # So make sure the connection gets closed after the (only)
+ # request.
+ headers["Connection"] = "close"
+ headers = dict((name.title(), val) for name, val in headers.items())
+
+ if req._tunnel_host:
+ tunnel_headers = {}
+ proxy_auth_hdr = "Proxy-Authorization"
+ if proxy_auth_hdr in headers:
+ tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
+ # Proxy-Authorization should not be sent to origin
+ # server.
+ del headers[proxy_auth_hdr]
+ h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
+
+ try:
+ h.request(req.get_method(), req.selector, req.data, headers)
+ except socket.error as err: # timeout error
+ h.close()
+ raise URLError(err)
+ else:
+ r = h.getresponse()
+
+ r.url = req.get_full_url()
+ # This line replaces the .msg attribute of the HTTPResponse
+ # with .headers, because urllib clients expect the response to
+ # have the reason in .msg. It would be good to mark this
+ # attribute is deprecated and get then to use info() or
+ # .headers.
+ r.msg = r.reason
+ return r
+
+
+class HTTPHandler(AbstractHTTPHandler):
+
+ def http_open(self, req):
+ return self.do_open(http.client.HTTPConnection, req)
+
+ http_request = AbstractHTTPHandler.do_request_
+
+if hasattr(http.client, 'HTTPSConnection'):
+ import ssl
+
+ class HTTPSHandler(AbstractHTTPHandler):
+
+ def __init__(self, debuglevel=0, context=None, check_hostname=None):
+ AbstractHTTPHandler.__init__(self, debuglevel)
+ self._context = context
+ self._check_hostname = check_hostname
+
+ def https_open(self, req):
+ return self.do_open(http.client.HTTPSConnection, req,
+ context=self._context, check_hostname=self._check_hostname)
+
+ https_request = AbstractHTTPHandler.do_request_
+
+class HTTPCookieProcessor(BaseHandler):
+ def __init__(self, cookiejar=None):
+ import http.cookiejar
+ if cookiejar is None:
+ cookiejar = http.cookiejar.CookieJar()
+ self.cookiejar = cookiejar
+
+ def http_request(self, request):
+ self.cookiejar.add_cookie_header(request)
+ return request
+
+ def http_response(self, request, response):
+ self.cookiejar.extract_cookies(response, request)
+ return response
+
+ https_request = http_request
+ https_response = http_response
+
+class UnknownHandler(BaseHandler):
+ def unknown_open(self, req):
+ type = req.type
+ raise URLError('unknown url type: %s' % type)
+
+def parse_keqv_list(l):
+ """Parse list of key=value strings where keys are not duplicated."""
+ parsed = {}
+ for elt in l:
+ k, v = elt.split('=', 1)
+ if v[0] == '"' and v[-1] == '"':
+ v = v[1:-1]
+ parsed[k] = v
+ return parsed
+
+def parse_http_list(s):
+ """Parse lists as described by RFC 2068 Section 2.
+
+ In particular, parse comma-separated lists where the elements of
+ the list may include quoted-strings. A quoted-string could
+ contain a comma. A non-quoted string could have quotes in the
+ middle. Neither commas nor quotes count if they are escaped.
+ Only double-quotes count, not single-quotes.
+ """
+ res = []
+ part = ''
+
+ escape = quote = False
+ for cur in s:
+ if escape:
+ part += cur
+ escape = False
+ continue
+ if quote:
+ if cur == '\\':
+ escape = True
+ continue
+ elif cur == '"':
+ quote = False
+ part += cur
+ continue
+
+ if cur == ',':
+ res.append(part)
+ part = ''
+ continue
+
+ if cur == '"':
+ quote = True
+
+ part += cur
+
+ # append last part
+ if part:
+ res.append(part)
+
+ return [part.strip() for part in res]
+
+class FileHandler(BaseHandler):
+ # Use local file or FTP depending on form of URL
+ def file_open(self, req):
+ url = req.selector
+ if url[:2] == '//' and url[2:3] != '/' and (req.host and
+ req.host != 'localhost'):
+ if not req.host is self.get_names():
+ raise URLError("file:// scheme is supported only on localhost")
+ else:
+ return self.open_local_file(req)
+
+ # names for the localhost
+ names = None
+ def get_names(self):
+ if FileHandler.names is None:
+ try:
+ FileHandler.names = tuple(
+ socket.gethostbyname_ex('localhost')[2] +
+ socket.gethostbyname_ex(socket.gethostname())[2])
+ except socket.gaierror:
+ FileHandler.names = (socket.gethostbyname('localhost'),)
+ return FileHandler.names
+
+ # not entirely sure what the rules are here
+ def open_local_file(self, req):
+ import email.utils
+ import mimetypes
+ host = req.host
+ filename = req.selector
+ localfile = url2pathname(filename)
+ try:
+ stats = os.stat(localfile)
+ size = stats.st_size
+ modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+ mtype = mimetypes.guess_type(filename)[0]
+ headers = email.message_from_string(
+ 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
+ (mtype or 'text/plain', size, modified))
+ if host:
+ host, port = splitport(host)
+ if not host or \
+ (not port and _safe_gethostbyname(host) in self.get_names()):
+ if host:
+ origurl = 'file://' + host + filename
+ else:
+ origurl = 'file://' + filename
+ return addinfourl(open(localfile, 'rb'), headers, origurl)
+ except OSError as exp:
+ # users shouldn't expect OSErrors coming from urlopen()
+ raise URLError(exp)
+ raise URLError('file not on local host')
+
+def _safe_gethostbyname(host):
+ try:
+ return socket.gethostbyname(host)
+ except socket.gaierror:
+ return None
+
+class FTPHandler(BaseHandler):
+ def ftp_open(self, req):
+ import ftplib
+ import mimetypes
+ host = req.host
+ if not host:
+ raise URLError('ftp error: no host given')
+ host, port = splitport(host)
+ if port is None:
+ port = ftplib.FTP_PORT
+ else:
+ port = int(port)
+
+ # username/password handling
+ user, host = splituser(host)
+ if user:
+ user, passwd = splitpasswd(user)
+ else:
+ passwd = None
+ host = unquote(host)
+ user = user or ''
+ passwd = passwd or ''
+
+ try:
+ host = socket.gethostbyname(host)
+ except socket.error as msg:
+ raise URLError(msg)
+ path, attrs = splitattr(req.selector)
+ dirs = path.split('/')
+ dirs = list(map(unquote, dirs))
+ dirs, file = dirs[:-1], dirs[-1]
+ if dirs and not dirs[0]:
+ dirs = dirs[1:]
+ try:
+ fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
+ type = file and 'I' or 'D'
+ for attr in attrs:
+ attr, value = splitvalue(attr)
+ if attr.lower() == 'type' and \
+ value in ('a', 'A', 'i', 'I', 'd', 'D'):
+ type = value.upper()
+ fp, retrlen = fw.retrfile(file, type)
+ headers = ""
+ mtype = mimetypes.guess_type(req.full_url)[0]
+ if mtype:
+ headers += "Content-type: %s\n" % mtype
+ if retrlen is not None and retrlen >= 0:
+ headers += "Content-length: %d\n" % retrlen
+ headers = email.message_from_string(headers)
+ return addinfourl(fp, headers, req.full_url)
+ except ftplib.all_errors as exp:
+ exc = URLError('ftp error: %r' % exp)
+ raise exc.with_traceback(sys.exc_info()[2])
+
+ def connect_ftp(self, user, passwd, host, port, dirs, timeout):
+ return ftpwrapper(user, passwd, host, port, dirs, timeout,
+ persistent=False)
+
+class CacheFTPHandler(FTPHandler):
+ # XXX would be nice to have pluggable cache strategies
+ # XXX this stuff is definitely not thread safe
+ def __init__(self):
+ self.cache = {}
+ self.timeout = {}
+ self.soonest = 0
+ self.delay = 60
+ self.max_conns = 16
+
+ def setTimeout(self, t):
+ self.delay = t
+
+ def setMaxConns(self, m):
+ self.max_conns = m
+
+ def connect_ftp(self, user, passwd, host, port, dirs, timeout):
+ key = user, host, port, '/'.join(dirs), timeout
+ if key in self.cache:
+ self.timeout[key] = time.time() + self.delay
+ else:
+ self.cache[key] = ftpwrapper(user, passwd, host, port,
+ dirs, timeout)
+ self.timeout[key] = time.time() + self.delay
+ self.check_cache()
+ return self.cache[key]
+
+ def check_cache(self):
+ # first check for old ones
+ t = time.time()
+ if self.soonest <= t:
+ for k, v in list(self.timeout.items()):
+ if v < t:
+ self.cache[k].close()
+ del self.cache[k]
+ del self.timeout[k]
+ self.soonest = min(list(self.timeout.values()))
+
+ # then check the size
+ if len(self.cache) == self.max_conns:
+ for k, v in list(self.timeout.items()):
+ if v == self.soonest:
+ del self.cache[k]
+ del self.timeout[k]
+ break
+ self.soonest = min(list(self.timeout.values()))
+
+ def clear_cache(self):
+ for conn in self.cache.values():
+ conn.close()
+ self.cache.clear()
+ self.timeout.clear()
+
+
+# Code move from the old urllib module
+
+MAXFTPCACHE = 10 # Trim the ftp cache beyond this size
+
+# Helper for non-unix systems
+if os.name == 'nt':
+ from nturl2path import url2pathname, pathname2url
+else:
+ def url2pathname(pathname):
+ """OS-specific conversion from a relative URL of the 'file' scheme
+ to a file system path; not recommended for general use."""
+ return unquote(pathname)
+
+ def pathname2url(pathname):
+ """OS-specific conversion from a file system path to a relative URL
+ of the 'file' scheme; not recommended for general use."""
+ return quote(pathname)
+
+# This really consists of two pieces:
+# (1) a class which handles opening of all sorts of URLs
+# (plus assorted utilities etc.)
+# (2) a set of functions for parsing URLs
+# XXX Should these be separated out into different modules?
+
+
+ftpcache = {}
+class URLopener:
+ """Class to open URLs.
+ This is a class rather than just a subroutine because we may need
+ more than one set of global protocol-specific options.
+ Note -- this is a base class for those who don't want the
+ automatic handling of errors type 302 (relocated) and 401
+ (authorization needed)."""
+
+ __tempfiles = None
+
+ version = "Python-urllib/%s" % __version__
+
+ # Constructor
+ def __init__(self, proxies=None, **x509):
+ if proxies is None:
+ proxies = getproxies()
+ assert hasattr(proxies, 'keys'), "proxies must be a mapping"
+ self.proxies = proxies
+ self.key_file = x509.get('key_file')
+ self.cert_file = x509.get('cert_file')
+ self.addheaders = [('User-Agent', self.version)]
+ self.__tempfiles = []
+ self.__unlink = os.unlink # See cleanup()
+ self.tempcache = None
+ # Undocumented feature: if you assign {} to tempcache,
+ # it is used to cache files retrieved with
+ # self.retrieve(). This is not enabled by default
+ # since it does not work for changing documents (and I
+ # haven't got the logic to check expiration headers
+ # yet).
+ self.ftpcache = ftpcache
+ # Undocumented feature: you can use a different
+ # ftp cache by assigning to the .ftpcache member;
+ # in case you want logically independent URL openers
+ # XXX This is not threadsafe. Bah.
+
+ def __del__(self):
+ self.close()
+
+ def close(self):
+ self.cleanup()
+
+ def cleanup(self):
+ # This code sometimes runs when the rest of this module
+ # has already been deleted, so it can't use any globals
+ # or import anything.
+ if self.__tempfiles:
+ for file in self.__tempfiles:
+ try:
+ self.__unlink(file)
+ except OSError:
+ pass
+ del self.__tempfiles[:]
+ if self.tempcache:
+ self.tempcache.clear()
+
+ def addheader(self, *args):
+ """Add a header to be used by the HTTP interface only
+ e.g. u.addheader('Accept', 'sound/basic')"""
+ self.addheaders.append(args)
+
+ # External interface
+ def open(self, fullurl, data=None):
+ """Use URLopener().open(file) instead of open(file, 'r')."""
+ fullurl = unwrap(to_bytes(fullurl))
+ fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]|")
+ if self.tempcache and fullurl in self.tempcache:
+ filename, headers = self.tempcache[fullurl]
+ fp = open(filename, 'rb')
+ return addinfourl(fp, headers, fullurl)
+ urltype, url = splittype(fullurl)
+ if not urltype:
+ urltype = 'file'
+ if urltype in self.proxies:
+ proxy = self.proxies[urltype]
+ urltype, proxyhost = splittype(proxy)
+ host, selector = splithost(proxyhost)
+ url = (host, fullurl) # Signal special case to open_*()
+ else:
+ proxy = None
+ name = 'open_' + urltype
+ self.type = urltype
+ name = name.replace('-', '_')
+ if not hasattr(self, name):
+ if proxy:
+ return self.open_unknown_proxy(proxy, fullurl, data)
+ else:
+ return self.open_unknown(fullurl, data)
+ try:
+ if data is None:
+ return getattr(self, name)(url)
+ else:
+ return getattr(self, name)(url, data)
+ except socket.error as msg:
+ raise IOError('socket error', msg).with_traceback(sys.exc_info()[2])
+
+ def open_unknown(self, fullurl, data=None):
+ """Overridable interface to open unknown URL type."""
+ type, url = splittype(fullurl)
+ raise IOError('url error', 'unknown url type', type)
+
+ def open_unknown_proxy(self, proxy, fullurl, data=None):
+ """Overridable interface to open unknown URL type."""
+ type, url = splittype(fullurl)
+ raise IOError('url error', 'invalid proxy for %s' % type, proxy)
+
+ # External interface
+ def retrieve(self, url, filename=None, reporthook=None, data=None):
+ """retrieve(url) returns (filename, headers) for a local object
+ or (tempfilename, headers) for a remote object."""
+ url = unwrap(to_bytes(url))
+ if self.tempcache and url in self.tempcache:
+ return self.tempcache[url]
+ type, url1 = splittype(url)
+ if filename is None and (not type or type == 'file'):
+ try:
+ fp = self.open_local_file(url1)
+ hdrs = fp.info()
+ fp.close()
+ return url2pathname(splithost(url1)[1]), hdrs
+ except IOError as msg:
+ pass
+ fp = self.open(url, data)
+ try:
+ headers = fp.info()
+ if filename:
+ tfp = open(filename, 'wb')
+ else:
+ import tempfile
+ garbage, path = splittype(url)
+ garbage, path = splithost(path or "")
+ path, garbage = splitquery(path or "")
+ path, garbage = splitattr(path or "")
+ suffix = os.path.splitext(path)[1]
+ (fd, filename) = tempfile.mkstemp(suffix)
+ self.__tempfiles.append(filename)
+ tfp = os.fdopen(fd, 'wb')
+ try:
+ result = filename, headers
+ if self.tempcache is not None:
+ self.tempcache[url] = result
+ bs = 1024*8
+ size = -1
+ read = 0
+ blocknum = 0
+ if "content-length" in headers:
+ size = int(headers["Content-Length"])
+ if reporthook:
+ reporthook(blocknum, bs, size)
+ while 1:
+ block = fp.read(bs)
+ if not block:
+ break
+ read += len(block)
+ tfp.write(block)
+ blocknum += 1
+ if reporthook:
+ reporthook(blocknum, bs, size)
+ finally:
+ tfp.close()
+ finally:
+ fp.close()
+
+ # raise exception if actual size does not match content-length header
+ if size >= 0 and read < size:
+ raise ContentTooShortError(
+ "retrieval incomplete: got only %i out of %i bytes"
+ % (read, size), result)
+
+ return result
+
+ # Each method named open_<type> knows how to open that type of URL
+
+ def _open_generic_http(self, connection_factory, url, data):
+ """Make an HTTP connection using connection_class.
+
+ This is an internal method that should be called from
+ open_http() or open_https().
+
+ Arguments:
+ - connection_factory should take a host name and return an
+ HTTPConnection instance.
+ - url is the url to retrieval or a host, relative-path pair.
+ - data is payload for a POST request or None.
+ """
+
+ user_passwd = None
+ proxy_passwd= None
+ if isinstance(url, str):
+ host, selector = splithost(url)
+ if host:
+ user_passwd, host = splituser(host)
+ host = unquote(host)
+ realhost = host
+ else:
+ host, selector = url
+ # check whether the proxy contains authorization information
+ proxy_passwd, host = splituser(host)
+ # now we proceed with the url we want to obtain
+ urltype, rest = splittype(selector)
+ url = rest
+ user_passwd = None
+ if urltype.lower() != 'http':
+ realhost = None
+ else:
+ realhost, rest = splithost(rest)
+ if realhost:
+ user_passwd, realhost = splituser(realhost)
+ if user_passwd:
+ selector = "%s://%s%s" % (urltype, realhost, rest)
+ if proxy_bypass(realhost):
+ host = realhost
+
+ if not host: raise IOError('http error', 'no host given')
+
+ if proxy_passwd:
+ proxy_passwd = unquote(proxy_passwd)
+ proxy_auth = base64.b64encode(proxy_passwd.encode()).decode('ascii')
+ else:
+ proxy_auth = None
+
+ if user_passwd:
+ user_passwd = unquote(user_passwd)
+ auth = base64.b64encode(user_passwd.encode()).decode('ascii')
+ else:
+ auth = None
+ http_conn = connection_factory(host)
+ headers = {}
+ if proxy_auth:
+ headers["Proxy-Authorization"] = "Basic %s" % proxy_auth
+ if auth:
+ headers["Authorization"] = "Basic %s" % auth
+ if realhost:
+ headers["Host"] = realhost
+
+ # Add Connection:close as we don't support persistent connections yet.
+ # This helps in closing the socket and avoiding ResourceWarning
+
+ headers["Connection"] = "close"
+
+ for header, value in self.addheaders:
+ headers[header] = value
+
+ if data is not None:
+ headers["Content-Type"] = "application/x-www-form-urlencoded"
+ http_conn.request("POST", selector, data, headers)
+ else:
+ http_conn.request("GET", selector, headers=headers)
+
+ try:
+ response = http_conn.getresponse()
+ except http.client.BadStatusLine:
+ # something went wrong with the HTTP status line
+ raise URLError("http protocol error: bad status line")
+
+ # According to RFC 2616, "2xx" code indicates that the client's
+ # request was successfully received, understood, and accepted.
+ if 200 <= response.status < 300:
+ return addinfourl(response, response.msg, "http:" + url,
+ response.status)
+ else:
+ return self.http_error(
+ url, response.fp,
+ response.status, response.reason, response.msg, data)
+
+ def open_http(self, url, data=None):
+ """Use HTTP protocol."""
+ return self._open_generic_http(http.client.HTTPConnection, url, data)
+
+ def http_error(self, url, fp, errcode, errmsg, headers, data=None):
+ """Handle http errors.
+
+ Derived class can override this, or provide specific handlers
+ named http_error_DDD where DDD is the 3-digit error code."""
+ # First check if there's a specific handler for this error
+ name = 'http_error_%d' % errcode
+ if hasattr(self, name):
+ method = getattr(self, name)
+ if data is None:
+ result = method(url, fp, errcode, errmsg, headers)
+ else:
+ result = method(url, fp, errcode, errmsg, headers, data)
+ if result: return result
+ return self.http_error_default(url, fp, errcode, errmsg, headers)
+
+ def http_error_default(self, url, fp, errcode, errmsg, headers):
+ """Default error handler: close the connection and raise IOError."""
+ fp.close()
+ raise HTTPError(url, errcode, errmsg, headers, None)
+
+ if _have_ssl:
+ def _https_connection(self, host):
+ return http.client.HTTPSConnection(host,
+ key_file=self.key_file,
+ cert_file=self.cert_file)
+
+ def open_https(self, url, data=None):
+ """Use HTTPS protocol."""
+ return self._open_generic_http(self._https_connection, url, data)
+
+ def open_file(self, url):
+ """Use local file or FTP depending on form of URL."""
+ if not isinstance(url, str):
+ raise URLError('file error: proxy support for file protocol currently not implemented')
+ if url[:2] == '//' and url[2:3] != '/' and url[2:12].lower() != 'localhost/':
+ raise ValueError("file:// scheme is supported only on localhost")
+ else:
+ return self.open_local_file(url)
+
+ def open_local_file(self, url):
+ """Use local file."""
+ import mimetypes, email.utils
+ from io import StringIO
+ host, file = splithost(url)
+ localname = url2pathname(file)
+ try:
+ stats = os.stat(localname)
+ except OSError as e:
+ raise URLError(e.strerror, e.filename)
+ size = stats.st_size
+ modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
+ mtype = mimetypes.guess_type(url)[0]
+ headers = email.message_from_string(
+ 'Content-Type: %s\nContent-Length: %d\nLast-modified: %s\n' %
+ (mtype or 'text/plain', size, modified))
+ if not host:
+ urlfile = file
+ if file[:1] == '/':
+ urlfile = 'file://' + file
+ return addinfourl(open(localname, 'rb'), headers, urlfile)
+ host, port = splitport(host)
+ if (not port
+ and socket.gethostbyname(host) in ((localhost(),) + thishost())):
+ urlfile = file
+ if file[:1] == '/':
+ urlfile = 'file://' + file
+ elif file[:2] == './':
+ raise ValueError("local file url may start with / or file:. Unknown url of type: %s" % url)
+ return addinfourl(open(localname, 'rb'), headers, urlfile)
+ raise URLError('local file error: not on local host')
+
+ def open_ftp(self, url):
+ """Use FTP protocol."""
+ if not isinstance(url, str):
+ raise URLError('ftp error: proxy support for ftp protocol currently not implemented')
+ import mimetypes
+ host, path = splithost(url)
+ if not host: raise URLError('ftp error: no host given')
+ host, port = splitport(host)
+ user, host = splituser(host)
+ if user: user, passwd = splitpasswd(user)
+ else: passwd = None
+ host = unquote(host)
+ user = unquote(user or '')
+ passwd = unquote(passwd or '')
+ host = socket.gethostbyname(host)
+ if not port:
+ import ftplib
+ port = ftplib.FTP_PORT
+ else:
+ port = int(port)
+ path, attrs = splitattr(path)
+ path = unquote(path)
+ dirs = path.split('/')
+ dirs, file = dirs[:-1], dirs[-1]
+ if dirs and not dirs[0]: dirs = dirs[1:]
+ if dirs and not dirs[0]: dirs[0] = '/'
+ key = user, host, port, '/'.join(dirs)
+ # XXX thread unsafe!
+ if len(self.ftpcache) > MAXFTPCACHE:
+ # Prune the cache, rather arbitrarily
+ for k in self.ftpcache.keys():
+ if k != key:
+ v = self.ftpcache[k]
+ del self.ftpcache[k]
+ v.close()
+ try:
+ if key not in self.ftpcache:
+ self.ftpcache[key] = \
+ ftpwrapper(user, passwd, host, port, dirs)
+ if not file: type = 'D'
+ else: type = 'I'
+ for attr in attrs:
+ attr, value = splitvalue(attr)
+ if attr.lower() == 'type' and \
+ value in ('a', 'A', 'i', 'I', 'd', 'D'):
+ type = value.upper()
+ (fp, retrlen) = self.ftpcache[key].retrfile(file, type)
+ mtype = mimetypes.guess_type("ftp:" + url)[0]
+ headers = ""
+ if mtype:
+ headers += "Content-Type: %s\n" % mtype
+ if retrlen is not None and retrlen >= 0:
+ headers += "Content-Length: %d\n" % retrlen
+ headers = email.message_from_string(headers)
+ return addinfourl(fp, headers, "ftp:" + url)
+ except ftperrors() as exp:
+ raise URLError('ftp error %r' % exp).with_traceback(sys.exc_info()[2])
+
+ def open_data(self, url, data=None):
+ """Use "data" URL."""
+ if not isinstance(url, str):
+ raise URLError('data error: proxy support for data protocol currently not implemented')
+ # ignore POSTed data
+ #
+ # syntax of data URLs:
+ # dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
+ # mediatype := [ type "/" subtype ] *( ";" parameter )
+ # data := *urlchar
+ # parameter := attribute "=" value
+ try:
+ [type, data] = url.split(',', 1)
+ except ValueError:
+ raise IOError('data error', 'bad data URL')
+ if not type:
+ type = 'text/plain;charset=US-ASCII'
+ semi = type.rfind(';')
+ if semi >= 0 and '=' not in type[semi:]:
+ encoding = type[semi+1:]
+ type = type[:semi]
+ else:
+ encoding = ''
+ msg = []
+ msg.append('Date: %s'%time.strftime('%a, %d %b %Y %H:%M:%S GMT',
+ time.gmtime(time.time())))
+ msg.append('Content-type: %s' % type)
+ if encoding == 'base64':
+ # XXX is this encoding/decoding ok?
+ data = base64.decodebytes(data.encode('ascii')).decode('latin1')
+ else:
+ data = unquote(data)
+ msg.append('Content-Length: %d' % len(data))
+ msg.append('')
+ msg.append(data)
+ msg = '\n'.join(msg)
+ headers = email.message_from_string(msg)
+ f = io.StringIO(msg)
+ #f.fileno = None # needed for addinfourl
+ return addinfourl(f, headers, url)
+
+
+class FancyURLopener(URLopener):
+ """Derived class with handlers for errors we can handle (perhaps)."""
+
+ def __init__(self, *args, **kwargs):
+ URLopener.__init__(self, *args, **kwargs)
+ self.auth_cache = {}
+ self.tries = 0
+ self.maxtries = 10
+
+ def http_error_default(self, url, fp, errcode, errmsg, headers):
+ """Default error handling -- don't raise an exception."""
+ return addinfourl(fp, headers, "http:" + url, errcode)
+
+ def http_error_302(self, url, fp, errcode, errmsg, headers, data=None):
+ """Error 302 -- relocated (temporarily)."""
+ self.tries += 1
+ if self.maxtries and self.tries >= self.maxtries:
+ if hasattr(self, "http_error_500"):
+ meth = self.http_error_500
+ else:
+ meth = self.http_error_default
+ self.tries = 0
+ return meth(url, fp, 500,
+ "Internal Server Error: Redirect Recursion", headers)
+ result = self.redirect_internal(url, fp, errcode, errmsg, headers,
+ data)
+ self.tries = 0
+ return result
+
+ def redirect_internal(self, url, fp, errcode, errmsg, headers, data):
+ if 'location' in headers:
+ newurl = headers['location']
+ elif 'uri' in headers:
+ newurl = headers['uri']
+ else:
+ return
+ fp.close()
+
+ # In case the server sent a relative URL, join with original:
+ newurl = urljoin(self.type + ":" + url, newurl)
+
+ urlparts = urlparse(newurl)
+
+ # For security reasons, we don't allow redirection to anything other
+ # than http, https and ftp.
+
+ # We are using newer HTTPError with older redirect_internal method
+ # This older method will get deprecated in 3.3
+
+ if urlparts.scheme not in ('http', 'https', 'ftp', ''):
+ raise HTTPError(newurl, errcode,
+ errmsg +
+ " Redirection to url '%s' is not allowed." % newurl,
+ headers, fp)
+
+ return self.open(newurl)
+
+ def http_error_301(self, url, fp, errcode, errmsg, headers, data=None):
+ """Error 301 -- also relocated (permanently)."""
+ return self.http_error_302(url, fp, errcode, errmsg, headers, data)
+
+ def http_error_303(self, url, fp, errcode, errmsg, headers, data=None):
+ """Error 303 -- also relocated (essentially identical to 302)."""
+ return self.http_error_302(url, fp, errcode, errmsg, headers, data)
+
+ def http_error_307(self, url, fp, errcode, errmsg, headers, data=None):
+ """Error 307 -- relocated, but turn POST into error."""
+ if data is None:
+ return self.http_error_302(url, fp, errcode, errmsg, headers, data)
+ else:
+ return self.http_error_default(url, fp, errcode, errmsg, headers)
+
+ def http_error_401(self, url, fp, errcode, errmsg, headers, data=None,
+ retry=False):
+ """Error 401 -- authentication required.
+ This function supports Basic authentication only."""
+ if 'www-authenticate' not in headers:
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ stuff = headers['www-authenticate']
+ import re
+ match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
+ if not match:
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ scheme, realm = match.groups()
+ if scheme.lower() != 'basic':
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ if not retry:
+ URLopener.http_error_default(self, url, fp, errcode, errmsg,
+ headers)
+ name = 'retry_' + self.type + '_basic_auth'
+ if data is None:
+ return getattr(self,name)(url, realm)
+ else:
+ return getattr(self,name)(url, realm, data)
+
+ def http_error_407(self, url, fp, errcode, errmsg, headers, data=None,
+ retry=False):
+ """Error 407 -- proxy authentication required.
+ This function supports Basic authentication only."""
+ if 'proxy-authenticate' not in headers:
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ stuff = headers['proxy-authenticate']
+ import re
+ match = re.match('[ \t]*([^ \t]+)[ \t]+realm="([^"]*)"', stuff)
+ if not match:
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ scheme, realm = match.groups()
+ if scheme.lower() != 'basic':
+ URLopener.http_error_default(self, url, fp,
+ errcode, errmsg, headers)
+ if not retry:
+ URLopener.http_error_default(self, url, fp, errcode, errmsg,
+ headers)
+ name = 'retry_proxy_' + self.type + '_basic_auth'
+ if data is None:
+ return getattr(self,name)(url, realm)
+ else:
+ return getattr(self,name)(url, realm, data)
+
+ def retry_proxy_http_basic_auth(self, url, realm, data=None):
+ host, selector = splithost(url)
+ newurl = 'http://' + host + selector
+ proxy = self.proxies['http']
+ urltype, proxyhost = splittype(proxy)
+ proxyhost, proxyselector = splithost(proxyhost)
+ i = proxyhost.find('@') + 1
+ proxyhost = proxyhost[i:]
+ user, passwd = self.get_user_passwd(proxyhost, realm, i)
+ if not (user or passwd): return None
+ proxyhost = "%s:%s@%s" % (quote(user, safe=''),
+ quote(passwd, safe=''), proxyhost)
+ self.proxies['http'] = 'http://' + proxyhost + proxyselector
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
+
+ def retry_proxy_https_basic_auth(self, url, realm, data=None):
+ host, selector = splithost(url)
+ newurl = 'https://' + host + selector
+ proxy = self.proxies['https']
+ urltype, proxyhost = splittype(proxy)
+ proxyhost, proxyselector = splithost(proxyhost)
+ i = proxyhost.find('@') + 1
+ proxyhost = proxyhost[i:]
+ user, passwd = self.get_user_passwd(proxyhost, realm, i)
+ if not (user or passwd): return None
+ proxyhost = "%s:%s@%s" % (quote(user, safe=''),
+ quote(passwd, safe=''), proxyhost)
+ self.proxies['https'] = 'https://' + proxyhost + proxyselector
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
+
+ def retry_http_basic_auth(self, url, realm, data=None):
+ host, selector = splithost(url)
+ i = host.find('@') + 1
+ host = host[i:]
+ user, passwd = self.get_user_passwd(host, realm, i)
+ if not (user or passwd): return None
+ host = "%s:%s@%s" % (quote(user, safe=''),
+ quote(passwd, safe=''), host)
+ newurl = 'http://' + host + selector
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
+
+ def retry_https_basic_auth(self, url, realm, data=None):
+ host, selector = splithost(url)
+ i = host.find('@') + 1
+ host = host[i:]
+ user, passwd = self.get_user_passwd(host, realm, i)
+ if not (user or passwd): return None
+ host = "%s:%s@%s" % (quote(user, safe=''),
+ quote(passwd, safe=''), host)
+ newurl = 'https://' + host + selector
+ if data is None:
+ return self.open(newurl)
+ else:
+ return self.open(newurl, data)
+
+ def get_user_passwd(self, host, realm, clear_cache=0):
+ key = realm + '@' + host.lower()
+ if key in self.auth_cache:
+ if clear_cache:
+ del self.auth_cache[key]
+ else:
+ return self.auth_cache[key]
+ user, passwd = self.prompt_user_passwd(host, realm)
+ if user or passwd: self.auth_cache[key] = (user, passwd)
+ return user, passwd
+
+ def prompt_user_passwd(self, host, realm):
+ """Override this in a GUI environment!"""
+ import getpass
+ try:
+ user = input("Enter username for %s at %s: " % (realm, host))
+ passwd = getpass.getpass("Enter password for %s in %s at %s: " %
+ (user, realm, host))
+ return user, passwd
+ except KeyboardInterrupt:
+ print()
+ return None, None
+
+
+# Utility functions
+
+_localhost = None
+def localhost():
+ """Return the IP address of the magic hostname 'localhost'."""
+ global _localhost
+ if _localhost is None:
+ _localhost = socket.gethostbyname('localhost')
+ return _localhost
+
+_thishost = None
+def thishost():
+ """Return the IP addresses of the current host."""
+ global _thishost
+ if _thishost is None:
+ _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
+ return _thishost
+
+_ftperrors = None
+def ftperrors():
+ """Return the set of errors raised by the FTP class."""
+ global _ftperrors
+ if _ftperrors is None:
+ import ftplib
+ _ftperrors = ftplib.all_errors
+ return _ftperrors
+
+_noheaders = None
+def noheaders():
+ """Return an empty email Message object."""
+ global _noheaders
+ if _noheaders is None:
+ _noheaders = email.message_from_string("")
+ return _noheaders
+
+
+# Utility classes
+
+class ftpwrapper:
+ """Class used by open_ftp() for cache of open FTP connections."""
+
+ def __init__(self, user, passwd, host, port, dirs, timeout=None,
+ persistent=True):
+ self.user = user
+ self.passwd = passwd
+ self.host = host
+ self.port = port
+ self.dirs = dirs
+ self.timeout = timeout
+ self.refcount = 0
+ self.keepalive = persistent
+ self.init()
+
+ def init(self):
+ import ftplib
+ self.busy = 0
+ self.ftp = ftplib.FTP()
+ self.ftp.connect(self.host, self.port, self.timeout)
+ self.ftp.login(self.user, self.passwd)
+ for dir in self.dirs:
+ self.ftp.cwd(dir)
+
+ def retrfile(self, file, type):
+ import ftplib
+ self.endtransfer()
+ if type in ('d', 'D'): cmd = 'TYPE A'; isdir = 1
+ else: cmd = 'TYPE ' + type; isdir = 0
+ try:
+ self.ftp.voidcmd(cmd)
+ except ftplib.all_errors:
+ self.init()
+ self.ftp.voidcmd(cmd)
+ conn = None
+ if file and not isdir:
+ # Try to retrieve as a file
+ try:
+ cmd = 'RETR ' + file
+ conn, retrlen = self.ftp.ntransfercmd(cmd)
+ except ftplib.error_perm as reason:
+ if str(reason)[:3] != '550':
+ raise URLError('ftp error: %d' % reason).with_traceback(
+ sys.exc_info()[2])
+ if not conn:
+ # Set transfer mode to ASCII!
+ self.ftp.voidcmd('TYPE A')
+ # Try a directory listing. Verify that directory exists.
+ if file:
+ pwd = self.ftp.pwd()
+ try:
+ try:
+ self.ftp.cwd(file)
+ except ftplib.error_perm as reason:
+ raise URLError('ftp error: %d' % reason) from reason
+ finally:
+ self.ftp.cwd(pwd)
+ cmd = 'LIST ' + file
+ else:
+ cmd = 'LIST'
+ conn, retrlen = self.ftp.ntransfercmd(cmd)
+ self.busy = 1
+
+ ftpobj = addclosehook(conn.makefile('rb'), self.file_close)
+ self.refcount += 1
+ conn.close()
+ # Pass back both a suitably decorated object and a retrieval length
+ return (ftpobj, retrlen)
+
+ def endtransfer(self):
+ self.busy = 0
+
+ def close(self):
+ self.keepalive = False
+ if self.refcount <= 0:
+ self.real_close()
+
+ def file_close(self):
+ self.endtransfer()
+ self.refcount -= 1
+ if self.refcount <= 0 and not self.keepalive:
+ self.real_close()
+
+ def real_close(self):
+ self.endtransfer()
+ try:
+ self.ftp.close()
+ except ftperrors():
+ pass
+
+# Proxy handling
+def getproxies_environment():
+ """Return a dictionary of scheme -> proxy server URL mappings.
+
+ Scan the environment for variables named <scheme>_proxy;
+ this seems to be the standard convention. If you need a
+ different way, you can pass a proxies dictionary to the
+ [Fancy]URLopener constructor.
+
+ """
+ proxies = {}
+ for name, value in os.environ.items():
+ name = name.lower()
+ if value and name[-6:] == '_proxy':
+ proxies[name[:-6]] = value
+ return proxies
+
+def proxy_bypass_environment(host):
+ """Test if proxies should not be used for a particular host.
+
+ Checks the environment for a variable named no_proxy, which should
+ be a list of DNS suffixes separated by commas, or '*' for all hosts.
+ """
+ no_proxy = os.environ.get('no_proxy', '') or os.environ.get('NO_PROXY', '')
+ # '*' is special case for always bypass
+ if no_proxy == '*':
+ return 1
+ # strip port off host
+ hostonly, port = splitport(host)
+ # check if the host ends with any of the DNS suffixes
+ no_proxy_list = [proxy.strip() for proxy in no_proxy.split(',')]
+ for name in no_proxy_list:
+ if name and (hostonly.endswith(name) or host.endswith(name)):
+ return 1
+ # otherwise, don't bypass
+ return 0
+
+
+# This code tests an OSX specific data structure but is testable on all
+# platforms
+def _proxy_bypass_macosx_sysconf(host, proxy_settings):
+ """
+ Return True iff this host shouldn't be accessed using a proxy
+
+ This function uses the MacOSX framework SystemConfiguration
+ to fetch the proxy information.
+
+ proxy_settings come from _scproxy._get_proxy_settings or get mocked ie:
+ { 'exclude_simple': bool,
+ 'exceptions': ['foo.bar', '*.bar.com', '127.0.0.1', '10.1', '10.0/16']
+ }
+ """
+ import re
+ import socket
+ from fnmatch import fnmatch
+
+ hostonly, port = splitport(host)
+
+ def ip2num(ipAddr):
+ parts = ipAddr.split('.')
+ parts = list(map(int, parts))
+ if len(parts) != 4:
+ parts = (parts + [0, 0, 0, 0])[:4]
+ return (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8) | parts[3]
+
+ # Check for simple host names:
+ if '.' not in host:
+ if proxy_settings['exclude_simple']:
+ return True
+
+ hostIP = None
+
+ for value in proxy_settings.get('exceptions', ()):
+ # Items in the list are strings like these: *.local, 169.254/16
+ if not value: continue
+
+ m = re.match(r"(\d+(?:\.\d+)*)(/\d+)?", value)
+ if m is not None:
+ if hostIP is None:
+ try:
+ hostIP = socket.gethostbyname(hostonly)
+ hostIP = ip2num(hostIP)
+ except socket.error:
+ continue
+
+ base = ip2num(m.group(1))
+ mask = m.group(2)
+ if mask is None:
+ mask = 8 * (m.group(1).count('.') + 1)
+ else:
+ mask = int(mask[1:])
+ mask = 32 - mask
+
+ if (hostIP >> mask) == (base >> mask):
+ return True
+
+ elif fnmatch(host, value):
+ return True
+
+ return False
+
+
+if sys.platform == 'darwin':
+ from _scproxy import _get_proxy_settings, _get_proxies
+
+ def proxy_bypass_macosx_sysconf(host):
+ proxy_settings = _get_proxy_settings()
+ return _proxy_bypass_macosx_sysconf(host, proxy_settings)
+
+ def getproxies_macosx_sysconf():
+ """Return a dictionary of scheme -> proxy server URL mappings.
+
+ This function uses the MacOSX framework SystemConfiguration
+ to fetch the proxy information.
+ """
+ return _get_proxies()
+
+
+
+ def proxy_bypass(host):
+ if getproxies_environment():
+ return proxy_bypass_environment(host)
+ else:
+ return proxy_bypass_macosx_sysconf(host)
+
+ def getproxies():
+ return getproxies_environment() or getproxies_macosx_sysconf()
+
+
+elif os.name == 'nt':
+ def getproxies_registry():
+ """Return a dictionary of scheme -> proxy server URL mappings.
+
+ Win32 uses the registry to store proxies.
+
+ """
+ proxies = {}
+ try:
+ import winreg
+ except ImportError:
+ # Std module, so should be around - but you never know!
+ return proxies
+ try:
+ internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
+ r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
+ proxyEnable = winreg.QueryValueEx(internetSettings,
+ 'ProxyEnable')[0]
+ if proxyEnable:
+ # Returned as Unicode but problems if not converted to ASCII
+ proxyServer = str(winreg.QueryValueEx(internetSettings,
+ 'ProxyServer')[0])
+ if '=' in proxyServer:
+ # Per-protocol settings
+ for p in proxyServer.split(';'):
+ protocol, address = p.split('=', 1)
+ # See if address has a type:// prefix
+ import re
+ if not re.match('^([^/:]+)://', address):
+ address = '%s://%s' % (protocol, address)
+ proxies[protocol] = address
+ else:
+ # Use one setting for all protocols
+ if proxyServer[:5] == 'http:':
+ proxies['http'] = proxyServer
+ else:
+ proxies['http'] = 'http://%s' % proxyServer
+ proxies['https'] = 'https://%s' % proxyServer
+ proxies['ftp'] = 'ftp://%s' % proxyServer
+ internetSettings.Close()
+ except (WindowsError, ValueError, TypeError):
+ # Either registry key not found etc, or the value in an
+ # unexpected format.
+ # proxies already set up to be empty so nothing to do
+ pass
+ return proxies
+
+ def getproxies():
+ """Return a dictionary of scheme -> proxy server URL mappings.
+
+ Returns settings gathered from the environment, if specified,
+ or the registry.
+
+ """
+ return getproxies_environment() or getproxies_registry()
+
+ def proxy_bypass_registry(host):
+ try:
+ import winreg
+ import re
+ except ImportError:
+ # Std modules, so should be around - but you never know!
+ return 0
+ try:
+ internetSettings = winreg.OpenKey(winreg.HKEY_CURRENT_USER,
+ r'Software\Microsoft\Windows\CurrentVersion\Internet Settings')
+ proxyEnable = winreg.QueryValueEx(internetSettings,
+ 'ProxyEnable')[0]
+ proxyOverride = str(winreg.QueryValueEx(internetSettings,
+ 'ProxyOverride')[0])
+ # ^^^^ Returned as Unicode but problems if not converted to ASCII
+ except WindowsError:
+ return 0
+ if not proxyEnable or not proxyOverride:
+ return 0
+ # try to make a host list from name and IP address.
+ rawHost, port = splitport(host)
+ host = [rawHost]
+ try:
+ addr = socket.gethostbyname(rawHost)
+ if addr != rawHost:
+ host.append(addr)
+ except socket.error:
+ pass
+ try:
+ fqdn = socket.getfqdn(rawHost)
+ if fqdn != rawHost:
+ host.append(fqdn)
+ except socket.error:
+ pass
+ # make a check value list from the registry entry: replace the
+ # '<local>' string by the localhost entry and the corresponding
+ # canonical entry.
+ proxyOverride = proxyOverride.split(';')
+ # now check if we match one of the registry values.
+ for test in proxyOverride:
+ if test == '<local>':
+ if '.' not in rawHost:
+ return 1
+ test = test.replace(".", r"\.") # mask dots
+ test = test.replace("*", r".*") # change glob sequence
+ test = test.replace("?", r".") # change glob char
+ for val in host:
+ if re.match(test, val, re.I):
+ return 1
+ return 0
+
+ def proxy_bypass(host):
+ """Return a dictionary of scheme -> proxy server URL mappings.
+
+ Returns settings gathered from the environment, if specified,
+ or the registry.
+
+ """
+ if getproxies_environment():
+ return proxy_bypass_environment(host)
+ else:
+ return proxy_bypass_registry(host)
+
+else:
+ # By default use environment variables
+ getproxies = getproxies_environment
+ proxy_bypass = proxy_bypass_environment
diff --git a/Lib/urllib/response.py b/Lib/urllib/response.py
new file mode 100644
index 00000000000..ffaa5fa6fc1
--- /dev/null
+++ b/Lib/urllib/response.py
@@ -0,0 +1,96 @@
+"""Response classes used by urllib.
+
+The base class, addbase, defines a minimal file-like interface,
+including read() and readline(). The typical response object is an
+addinfourl instance, which defines an info() method that returns
+headers and a geturl() method that returns the url.
+"""
+
+class addbase(object):
+ """Base class for addinfo and addclosehook."""
+
+ # XXX Add a method to expose the timeout on the underlying socket?
+
+ def __init__(self, fp):
+ # TODO(jhylton): Is there a better way to delegate using io?
+ self.fp = fp
+ self.read = self.fp.read
+ self.readline = self.fp.readline
+ # TODO(jhylton): Make sure an object with readlines() is also iterable
+ if hasattr(self.fp, "readlines"):
+ self.readlines = self.fp.readlines
+ if hasattr(self.fp, "fileno"):
+ self.fileno = self.fp.fileno
+ else:
+ self.fileno = lambda: None
+
+ def __iter__(self):
+ # Assigning `__iter__` to the instance doesn't work as intended
+ # because the iter builtin does something like `cls.__iter__(obj)`
+ # and thus fails to find the _bound_ method `obj.__iter__`.
+ # Returning just `self.fp` works for built-in file objects but
+ # might not work for general file-like objects.
+ return iter(self.fp)
+
+ def __repr__(self):
+ return '<%s at %r whose fp = %r>' % (self.__class__.__name__,
+ id(self), self.fp)
+
+ def close(self):
+ self.read = None
+ self.readline = None
+ self.readlines = None
+ self.fileno = None
+ if self.fp: self.fp.close()
+ self.fp = None
+
+ def __enter__(self):
+ if self.fp is None:
+ raise ValueError("I/O operation on closed file")
+ return self
+
+ def __exit__(self, type, value, traceback):
+ self.close()
+
+class addclosehook(addbase):
+ """Class to add a close hook to an open file."""
+
+ def __init__(self, fp, closehook, *hookargs):
+ addbase.__init__(self, fp)
+ self.closehook = closehook
+ self.hookargs = hookargs
+
+ def close(self):
+ if self.closehook:
+ self.closehook(*self.hookargs)
+ self.closehook = None
+ self.hookargs = None
+ addbase.close(self)
+
+class addinfo(addbase):
+ """class to add an info() method to an open file."""
+
+ def __init__(self, fp, headers):
+ addbase.__init__(self, fp)
+ self.headers = headers
+
+ def info(self):
+ return self.headers
+
+class addinfourl(addbase):
+ """class to add info() and geturl() methods to an open file."""
+
+ def __init__(self, fp, headers, url, code=None):
+ addbase.__init__(self, fp)
+ self.headers = headers
+ self.url = url
+ self.code = code
+
+ def info(self):
+ return self.headers
+
+ def getcode(self):
+ return self.code
+
+ def geturl(self):
+ return self.url
diff --git a/Lib/robotparser.py b/Lib/urllib/robotparser.py
index 1722863d144..75be4af4091 100644
--- a/Lib/robotparser.py
+++ b/Lib/urllib/robotparser.py
@@ -9,11 +9,10 @@
The robots.txt Exclusion Protocol is implemented as specified in
http://info.webcrawler.com/mak/projects/robots/norobots-rfc.html
"""
-import urlparse
-import urllib
-__all__ = ["RobotFileParser"]
+import urllib.parse, urllib.request
+__all__ = ["RobotFileParser"]
class RobotFileParser:
""" This class provides a set of methods to read, parse and answer
@@ -49,21 +48,20 @@ class RobotFileParser:
def set_url(self, url):
"""Sets the URL referring to a robots.txt file."""
self.url = url
- self.host, self.path = urlparse.urlparse(url)[1:3]
+ self.host, self.path = urllib.parse.urlparse(url)[1:3]
def read(self):
"""Reads the robots.txt URL and feeds it to the parser."""
- opener = URLopener()
- f = opener.open(self.url)
- lines = [line.strip() for line in f]
- f.close()
- self.errcode = opener.errcode
- if self.errcode in (401, 403):
- self.disallow_all = True
- elif self.errcode >= 400:
- self.allow_all = True
- elif self.errcode == 200 and lines:
- self.parse(lines)
+ try:
+ f = urllib.request.urlopen(self.url)
+ except urllib.error.HTTPError as err:
+ if err.code in (401, 403):
+ self.disallow_all = True
+ elif err.code >= 400:
+ self.allow_all = True
+ else:
+ raw = f.read()
+ self.parse(raw.decode("utf-8").splitlines())
def _add_entry(self, entry):
if "*" in entry.useragents:
@@ -75,19 +73,19 @@ class RobotFileParser:
self.entries.append(entry)
def parse(self, lines):
- """parse the input lines from a robots.txt file.
- We allow that a user-agent: line is not preceded by
- one or more blank lines."""
+ """Parse the input lines from a robots.txt file.
+
+ We allow that a user-agent: line is not preceded by
+ one or more blank lines.
+ """
# states:
# 0: start state
# 1: saw user-agent line
# 2: saw an allow or disallow line
state = 0
- linenumber = 0
entry = Entry()
for line in lines:
- linenumber += 1
if not line:
if state == 1:
entry = Entry()
@@ -106,7 +104,7 @@ class RobotFileParser:
line = line.split(':', 1)
if len(line) == 2:
line[0] = line[0].strip().lower()
- line[1] = urllib.unquote(line[1].strip())
+ line[1] = urllib.parse.unquote(line[1].strip())
if line[0] == "user-agent":
if state == 2:
self._add_entry(entry)
@@ -133,10 +131,10 @@ class RobotFileParser:
return True
# search for given user agent matches
# the first match counts
- parsed_url = urlparse.urlparse(urllib.unquote(url))
- url = urlparse.urlunparse(('', '', parsed_url.path,
- parsed_url.params, parsed_url.query, parsed_url.fragment))
- url = urllib.quote(url)
+ parsed_url = urllib.parse.urlparse(urllib.parse.unquote(url))
+ url = urllib.parse.urlunparse(('','',parsed_url.path,
+ parsed_url.params,parsed_url.query, parsed_url.fragment))
+ url = urllib.parse.quote(url)
if not url:
url = "/"
for entry in self.entries:
@@ -148,7 +146,6 @@ class RobotFileParser:
# agent not found ==> access granted
return True
-
def __str__(self):
return ''.join([str(entry) + "\n" for entry in self.entries])
@@ -160,7 +157,7 @@ class RuleLine:
if path == '' and not allowance:
# an empty value means allow all
allowance = True
- self.path = urllib.quote(path)
+ self.path = urllib.parse.quote(path)
self.allowance = allowance
def applies_to(self, filename):
@@ -205,18 +202,3 @@ class Entry:
if line.applies_to(filename):
return line.allowance
return True
-
-class URLopener(urllib.FancyURLopener):
- def __init__(self, *args):
- urllib.FancyURLopener.__init__(self, *args)
- self.errcode = 200
-
- def prompt_user_passwd(self, host, realm):
- ## If robots.txt file is accessible only with a password,
- ## we act as if the file wasn't there.
- return None, None
-
- def http_error_default(self, url, fp, errcode, errmsg, headers):
- self.errcode = errcode
- return urllib.FancyURLopener.http_error_default(self, url, fp, errcode,
- errmsg, headers)
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
deleted file mode 100644
index aadeb7371eb..00000000000
--- a/Lib/urllib2.py
+++ /dev/null
@@ -1,1470 +0,0 @@
-"""An extensible library for opening URLs using a variety of protocols
-
-The simplest way to use this module is to call the urlopen function,
-which accepts a string containing a URL or a Request object (described
-below). It opens the URL and returns the results as file-like
-object; the returned object has some extra methods described below.
-
-The OpenerDirector manages a collection of Handler objects that do
-all the actual work. Each Handler implements a particular protocol or
-option. The OpenerDirector is a composite object that invokes the
-Handlers needed to open the requested URL. For example, the
-HTTPHandler performs HTTP GET and POST requests and deals with
-non-error returns. The HTTPRedirectHandler automatically deals with
-HTTP 301, 302, 303 and 307 redirect errors, and the HTTPDigestAuthHandler
-deals with digest authentication.
-
-urlopen(url, data=None) -- Basic usage is the same as original
-urllib. pass the url and optionally data to post to an HTTP URL, and
-get a file-like object back. One difference is that you can also pass
-a Request instance instead of URL. Raises a URLError (subclass of
-IOError); for HTTP errors, raises an HTTPError, which can also be
-treated as a valid response.
-
-build_opener -- Function that creates a new OpenerDirector instance.
-Will install the default handlers. Accepts one or more Handlers as
-arguments, either instances or Handler classes that it will
-instantiate. If one of the argument is a subclass of the default
-handler, the argument will be installed instead of the default.
-
-install_opener -- Installs a new opener as the default opener.
-
-objects of interest:
-
-OpenerDirector -- Sets up the User Agent as the Python-urllib client and manages
-the Handler classes, while dealing with requests and responses.
-
-Request -- An object that encapsulates the state of a request. The
-state can be as simple as the URL. It can also include extra HTTP
-headers, e.g. a User-Agent.
-
-BaseHandler --
-
-exceptions:
-URLError -- A subclass of IOError, individual protocols have their own
-specific subclass.
-
-HTTPError -- Also a valid HTTP response, so you can treat an HTTP error
-as an exceptional event or valid response.
-
-internals:
-BaseHandler and parent
-_call_chain conventions
-
-Example usage:
-
-import urllib2
-
-# set up authentication info
-authinfo = urllib2.HTTPBasicAuthHandler()
-authinfo.add_password(realm='PDQ Application',
- uri='https://mahler:8092/site-updates.py',
- user='klem',
- passwd='geheim$parole')
-
-proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})
-
-# build a new opener that adds authentication and caching FTP handlers
-opener = urllib2.build_opener(proxy_support, authinfo, urllib2.CacheFTPHandler)
-
-# install it
-urllib2.install_opener(opener)
-
-f = urllib2.urlopen('http://www.python.org/')
-
-
-"""
-
-# XXX issues:
-# If an authentication error handler that tries to perform
-# authentication for some reason but fails, how should the error be
-# signalled? The client needs to know the HTTP error code. But if
-# the handler knows that the problem was, e.g., that it didn't know
-# that hash algo that requested in the challenge, it would be good to
-# pass that information along to the client, too.
-# ftp errors aren't handled cleanly
-# check digest against correct (i.e. non-apache) implementation
-
-# Possible extensions:
-# complex proxies XXX not sure what exactly was meant by this
-# abstract factory for opener
-
-import base64
-import hashlib
-import httplib
-import mimetools
-import os
-import posixpath
-import random
-import re
-import socket
-import sys
-import time
-import urlparse
-import bisect
-import warnings
-
-try:
- from cStringIO import StringIO
-except ImportError:
- from StringIO import StringIO
-
-from urllib import (unwrap, unquote, splittype, splithost, quote,
- addinfourl, splitport, splittag, toBytes,
- splitattr, ftpwrapper, splituser, splitpasswd, splitvalue)
-
-# support for FileHandler, proxies via environment variables
-from urllib import localhost, url2pathname, getproxies, proxy_bypass
-
-# used in User-Agent header sent
-__version__ = sys.version[:3]
-
-_opener = None
-def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
- global _opener
- if _opener is None:
- _opener = build_opener()
- return _opener.open(url, data, timeout)
-
-def install_opener(opener):
- global _opener
- _opener = opener
-
-# do these error classes make sense?
-# make sure all of the IOError stuff is overridden. we just want to be
-# subtypes.
-
-class URLError(IOError):
- # URLError is a sub-type of IOError, but it doesn't share any of
- # the implementation. need to override __init__ and __str__.
- # It sets self.args for compatibility with other EnvironmentError
- # subclasses, but args doesn't have the typical format with errno in
- # slot 0 and strerror in slot 1. This may be better than nothing.
- def __init__(self, reason):
- self.args = reason,
- self.reason = reason
-
- def __str__(self):
- return '<urlopen error %s>' % self.reason
-
-class HTTPError(URLError, addinfourl):
- """Raised when HTTP error occurs, but also acts like non-error return"""
- __super_init = addinfourl.__init__
-
- def __init__(self, url, code, msg, hdrs, fp):
- self.code = code
- self.msg = msg
- self.hdrs = hdrs
- self.fp = fp
- self.filename = url
- # The addinfourl classes depend on fp being a valid file
- # object. In some cases, the HTTPError may not have a valid
- # file object. If this happens, the simplest workaround is to
- # not initialize the base classes.
- if fp is not None:
- self.__super_init(fp, hdrs, url, code)
-
- def __str__(self):
- return 'HTTP Error %s: %s' % (self.code, self.msg)
-
- # since URLError specifies a .reason attribute, HTTPError should also
- # provide this attribute. See issue13211 fo discussion.
- @property
- def reason(self):
- return self.msg
-
- def info(self):
- return self.hdrs
-
-# copied from cookielib.py
-_cut_port_re = re.compile(r":\d+$")
-def request_host(request):
- """Return request-host, as defined by RFC 2965.
-
- Variation from RFC: returned value is lowercased, for convenient
- comparison.
-
- """
- url = request.get_full_url()
- host = urlparse.urlparse(url)[1]
- if host == "":
- host = request.get_header("Host", "")
-
- # remove port, if present
- host = _cut_port_re.sub("", host, 1)
- return host.lower()
-
-class Request:
-
- def __init__(self, url, data=None, headers={},
- origin_req_host=None, unverifiable=False):
- # unwrap('<URL:type://host/path>') --> 'type://host/path'
- self.__original = unwrap(url)
- self.__original, self.__fragment = splittag(self.__original)
- self.type = None
- # self.__r_type is what's left after doing the splittype
- self.host = None
- self.port = None
- self._tunnel_host = None
- self.data = data
- self.headers = {}
- for key, value in headers.items():
- self.add_header(key, value)
- self.unredirected_hdrs = {}
- if origin_req_host is None:
- origin_req_host = request_host(self)
- self.origin_req_host = origin_req_host
- self.unverifiable = unverifiable
-
- def __getattr__(self, attr):
- # XXX this is a fallback mechanism to guard against these
- # methods getting called in a non-standard order. this may be
- # too complicated and/or unnecessary.
- # XXX should the __r_XXX attributes be public?
- if attr[:12] == '_Request__r_':
- name = attr[12:]
- if hasattr(Request, 'get_' + name):
- getattr(self, 'get_' + name)()
- return getattr(self, attr)
- raise AttributeError, attr
-
- def get_method(self):
- if self.has_data():
- return "POST"
- else:
- return "GET"
-
- # XXX these helper methods are lame
-
- def add_data(self, data):
- self.data = data
-
- def has_data(self):
- return self.data is not None
-
- def get_data(self):
- return self.data
-
- def get_full_url(self):
- if self.__fragment:
- return '%s#%s' % (self.__original, self.__fragment)
- else:
- return self.__original
-
- def get_type(self):
- if self.type is None:
- self.type, self.__r_type = splittype(self.__original)
- if self.type is None:
- raise ValueError, "unknown url type: %s" % self.__original
- return self.type
-
- def get_host(self):
- if self.host is None:
- self.host, self.__r_host = splithost(self.__r_type)
- if self.host:
- self.host = unquote(self.host)
- return self.host
-
- def get_selector(self):
- return self.__r_host
-
- def set_proxy(self, host, type):
- if self.type == 'https' and not self._tunnel_host:
- self._tunnel_host = self.host
- else:
- self.type = type
- self.__r_host = self.__original
-
- self.host = host
-
- def has_proxy(self):
- return self.__r_host == self.__original
-
- def get_origin_req_host(self):
- return self.origin_req_host
-
- def is_unverifiable(self):
- return self.unverifiable
-
- def add_header(self, key, val):
- # useful for something like authentication
- self.headers[key.capitalize()] = val
-
- def add_unredirected_header(self, key, val):
- # will not be added to a redirected request
- self.unredirected_hdrs[key.capitalize()] = val
-
- def has_header(self, header_name):
- return (header_name in self.headers or
- header_name in self.unredirected_hdrs)
-
- def get_header(self, header_name, default=None):
- return self.headers.get(
- header_name,
- self.unredirected_hdrs.get(header_name, default))
-
- def header_items(self):
- hdrs = self.unredirected_hdrs.copy()
- hdrs.update(self.headers)
- return hdrs.items()
-
-class OpenerDirector:
- def __init__(self):
- client_version = "Python-urllib/%s" % __version__
- self.addheaders = [('User-agent', client_version)]
- # self.handlers is retained only for backward compatibility
- self.handlers = []
- # manage the individual handlers
- self.handle_open = {}
- self.handle_error = {}
- self.process_response = {}
- self.process_request = {}
-
- def add_handler(self, handler):
- if not hasattr(handler, "add_parent"):
- raise TypeError("expected BaseHandler instance, got %r" %
- type(handler))
-
- added = False
- for meth in dir(handler):
- if meth in ["redirect_request", "do_open", "proxy_open"]:
- # oops, coincidental match
- continue
-
- i = meth.find("_")
- protocol = meth[:i]
- condition = meth[i+1:]
-
- if condition.startswith("error"):
- j = condition.find("_") + i + 1
- kind = meth[j+1:]
- try:
- kind = int(kind)
- except ValueError:
- pass
- lookup = self.handle_error.get(protocol, {})
- self.handle_error[protocol] = lookup
- elif condition == "open":
- kind = protocol
- lookup = self.handle_open
- elif condition == "response":
- kind = protocol
- lookup = self.process_response
- elif condition == "request":
- kind = protocol
- lookup = self.process_request
- else:
- continue
-
- handlers = lookup.setdefault(kind, [])
- if handlers:
- bisect.insort(handlers, handler)
- else:
- handlers.append(handler)
- added = True
-
- if added:
- bisect.insort(self.handlers, handler)
- handler.add_parent(self)
-
- def close(self):
- # Only exists for backwards compatibility.
- pass
-
- def _call_chain(self, chain, kind, meth_name, *args):
- # Handlers raise an exception if no one else should try to handle
- # the request, or return None if they can't but another handler
- # could. Otherwise, they return the response.
- handlers = chain.get(kind, ())
- for handler in handlers:
- func = getattr(handler, meth_name)
-
- result = func(*args)
- if result is not None:
- return result
-
- def open(self, fullurl, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT):
- # accept a URL or a Request object
- if isinstance(fullurl, basestring):
- req = Request(fullurl, data)
- else:
- req = fullurl
- if data is not None:
- req.add_data(data)
-
- req.timeout = timeout
- protocol = req.get_type()
-
- # pre-process request
- meth_name = protocol+"_request"
- for processor in self.process_request.get(protocol, []):
- meth = getattr(processor, meth_name)
- req = meth(req)
-
- response = self._open(req, data)
-
- # post-process response
- meth_name = protocol+"_response"
- for processor in self.process_response.get(protocol, []):
- meth = getattr(processor, meth_name)
- response = meth(req, response)
-
- return response
-
- def _open(self, req, data=None):
- result = self._call_chain(self.handle_open, 'default',
- 'default_open', req)
- if result:
- return result
-
- protocol = req.get_type()
- result = self._call_chain(self.handle_open, protocol, protocol +
- '_open', req)
- if result:
- return result
-
- return self._call_chain(self.handle_open, 'unknown',
- 'unknown_open', req)
-
- def error(self, proto, *args):
- if proto in ('http', 'https'):
- # XXX http[s] protocols are special-cased
- dict = self.handle_error['http'] # https is not different than http
- proto = args[2] # YUCK!
- meth_name = 'http_error_%s' % proto
- http_err = 1
- orig_args = args
- else:
- dict = self.handle_error
- meth_name = proto + '_error'
- http_err = 0
- args = (dict, proto, meth_name) + args
- result = self._call_chain(*args)
- if result:
- return result
-
- if http_err:
- args = (dict, 'default', 'http_error_default') + orig_args
- return self._call_chain(*args)
-
-# XXX probably also want an abstract factory that knows when it makes
-# sense to skip a superclass in favor of a subclass and when it might
-# make sense to include both
-
-def build_opener(*handlers):
- """Create an opener object from a list of handlers.
-
- The opener will use several default handlers, including support
- for HTTP, FTP and when applicable, HTTPS.
-
- If any of the handlers passed as arguments are subclasses of the
- default handlers, the default handlers will not be used.
- """
- import types
- def isclass(obj):
- return isinstance(obj, (types.ClassType, type))
-
- opener = OpenerDirector()
- default_classes = [ProxyHandler, UnknownHandler, HTTPHandler,
- HTTPDefaultErrorHandler, HTTPRedirectHandler,
- FTPHandler, FileHandler, HTTPErrorProcessor]
- if hasattr(httplib, 'HTTPS'):
- default_classes.append(HTTPSHandler)
- skip = set()
- for klass in default_classes:
- for check in handlers:
- if isclass(check):
- if issubclass(check, klass):
- skip.add(klass)
- elif isinstance(check, klass):
- skip.add(klass)
- for klass in skip:
- default_classes.remove(klass)
-
- for klass in default_classes:
- opener.add_handler(klass())
-
- for h in handlers:
- if isclass(h):
- h = h()
- opener.add_handler(h)
- return opener
-
-class BaseHandler:
- handler_order = 500
-
- def add_parent(self, parent):
- self.parent = parent
-
- def close(self):
- # Only exists for backwards compatibility
- pass
-
- def __lt__(self, other):
- if not hasattr(other, "handler_order"):
- # Try to preserve the old behavior of having custom classes
- # inserted after default ones (works only for custom user
- # classes which are not aware of handler_order).
- return True
- return self.handler_order < other.handler_order
-
-
-class HTTPErrorProcessor(BaseHandler):
- """Process HTTP error responses."""
- handler_order = 1000 # after all other processing
-
- def http_response(self, request, response):
- code, msg, hdrs = response.code, response.msg, response.info()
-
- # According to RFC 2616, "2xx" code indicates that the client's
- # request was successfully received, understood, and accepted.
- if not (200 <= code < 300):
- response = self.parent.error(
- 'http', request, response, code, msg, hdrs)
-
- return response
-
- https_response = http_response
-
-class HTTPDefaultErrorHandler(BaseHandler):
- def http_error_default(self, req, fp, code, msg, hdrs):
- raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
-
-class HTTPRedirectHandler(BaseHandler):
- # maximum number of redirections to any single URL
- # this is needed because of the state that cookies introduce
- max_repeats = 4
- # maximum total number of redirections (regardless of URL) before
- # assuming we're in a loop
- max_redirections = 10
-
- def redirect_request(self, req, fp, code, msg, headers, newurl):
- """Return a Request or None in response to a redirect.
-
- This is called by the http_error_30x methods when a
- redirection response is received. If a redirection should
- take place, return a new Request to allow http_error_30x to
- perform the redirect. Otherwise, raise HTTPError if no-one
- else should try to handle this url. Return None if you can't
- but another Handler might.
- """
- m = req.get_method()
- if (code in (301, 302, 303, 307) and m in ("GET", "HEAD")
- or code in (301, 302, 303) and m == "POST"):
- # Strictly (according to RFC 2616), 301 or 302 in response
- # to a POST MUST NOT cause a redirection without confirmation
- # from the user (of urllib2, in this case). In practice,
- # essentially all clients do redirect in this case, so we
- # do the same.
- # be conciliant with URIs containing a space
- newurl = newurl.replace(' ', '%20')
- newheaders = dict((k,v) for k,v in req.headers.items()
- if k.lower() not in ("content-length", "content-type")
- )
- return Request(newurl,
- headers=newheaders,
- origin_req_host=req.get_origin_req_host(),
- unverifiable=True)
- else:
- raise HTTPError(req.get_full_url(), code, msg, headers, fp)
-
- # Implementation note: To avoid the server sending us into an
- # infinite loop, the request object needs to track what URLs we
- # have already seen. Do this by adding a handler-specific
- # attribute to the Request object.
- def http_error_302(self, req, fp, code, msg, headers):
- # Some servers (incorrectly) return multiple Location headers
- # (so probably same goes for URI). Use first header.
- if 'location' in headers:
- newurl = headers.getheaders('location')[0]
- elif 'uri' in headers:
- newurl = headers.getheaders('uri')[0]
- else:
- return
-
- # fix a possible malformed URL
- urlparts = urlparse.urlparse(newurl)
- if not urlparts.path:
- urlparts = list(urlparts)
- urlparts[2] = "/"
- newurl = urlparse.urlunparse(urlparts)
-
- newurl = urlparse.urljoin(req.get_full_url(), newurl)
-
- # For security reasons we do not allow redirects to protocols
- # other than HTTP, HTTPS or FTP.
- newurl_lower = newurl.lower()
- if not (newurl_lower.startswith('http://') or
- newurl_lower.startswith('https://') or
- newurl_lower.startswith('ftp://')):
- raise HTTPError(newurl, code,
- msg + " - Redirection to url '%s' is not allowed" %
- newurl,
- headers, fp)
-
- # XXX Probably want to forget about the state of the current
- # request, although that might interact poorly with other
- # handlers that also use handler-specific request attributes
- new = self.redirect_request(req, fp, code, msg, headers, newurl)
- if new is None:
- return
-
- # loop detection
- # .redirect_dict has a key url if url was previously visited.
- if hasattr(req, 'redirect_dict'):
- visited = new.redirect_dict = req.redirect_dict
- if (visited.get(newurl, 0) >= self.max_repeats or
- len(visited) >= self.max_redirections):
- raise HTTPError(req.get_full_url(), code,
- self.inf_msg + msg, headers, fp)
- else:
- visited = new.redirect_dict = req.redirect_dict = {}
- visited[newurl] = visited.get(newurl, 0) + 1
-
- # Don't close the fp until we are sure that we won't use it
- # with HTTPError.
- fp.read()
- fp.close()
-
- return self.parent.open(new, timeout=req.timeout)
-
- http_error_301 = http_error_303 = http_error_307 = http_error_302
-
- inf_msg = "The HTTP server returned a redirect error that would " \
- "lead to an infinite loop.\n" \
- "The last 30x error message was:\n"
-
-
-def _parse_proxy(proxy):
- """Return (scheme, user, password, host/port) given a URL or an authority.
-
- If a URL is supplied, it must have an authority (host:port) component.
- According to RFC 3986, having an authority component means the URL must
- have two slashes after the scheme:
-
- >>> _parse_proxy('file:/ftp.example.com/')
- Traceback (most recent call last):
- ValueError: proxy URL with no authority: 'file:/ftp.example.com/'
-
- The first three items of the returned tuple may be None.
-
- Examples of authority parsing:
-
- >>> _parse_proxy('proxy.example.com')
- (None, None, None, 'proxy.example.com')
- >>> _parse_proxy('proxy.example.com:3128')
- (None, None, None, 'proxy.example.com:3128')
-
- The authority component may optionally include userinfo (assumed to be
- username:password):
-
- >>> _parse_proxy('joe:password@proxy.example.com')
- (None, 'joe', 'password', 'proxy.example.com')
- >>> _parse_proxy('joe:password@proxy.example.com:3128')
- (None, 'joe', 'password', 'proxy.example.com:3128')
-
- Same examples, but with URLs instead:
-
- >>> _parse_proxy('http://proxy.example.com/')
- ('http', None, None, 'proxy.example.com')
- >>> _parse_proxy('http://proxy.example.com:3128/')
- ('http', None, None, 'proxy.example.com:3128')
- >>> _parse_proxy('http://joe:password@proxy.example.com/')
- ('http', 'joe', 'password', 'proxy.example.com')
- >>> _parse_proxy('http://joe:password@proxy.example.com:3128')
- ('http', 'joe', 'password', 'proxy.example.com:3128')
-
- Everything after the authority is ignored:
-
- >>> _parse_proxy('ftp://joe:password@proxy.example.com/rubbish:3128')
- ('ftp', 'joe', 'password', 'proxy.example.com')
-
- Test for no trailing '/' case:
-
- >>> _parse_proxy('http://joe:password@proxy.example.com')
- ('http', 'joe', 'password', 'proxy.example.com')
-
- """
- scheme, r_scheme = splittype(proxy)
- if not r_scheme.startswith("/"):
- # authority
- scheme = None
- authority = proxy
- else:
- # URL
- if not r_scheme.startswith("//"):
- raise ValueError("proxy URL with no authority: %r" % proxy)
- # We have an authority, so for RFC 3986-compliant URLs (by ss 3.
- # and 3.3.), path is empty or starts with '/'
- end = r_scheme.find("/", 2)
- if end == -1:
- end = None
- authority = r_scheme[2:end]
- userinfo, hostport = splituser(authority)
- if userinfo is not None:
- user, password = splitpasswd(userinfo)
- else:
- user = password = None
- return scheme, user, password, hostport
-
-class ProxyHandler(BaseHandler):
- # Proxies must be in front
- handler_order = 100
-
- def __init__(self, proxies=None):
- if proxies is None:
- proxies = getproxies()
- assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
- self.proxies = proxies
- for type, url in proxies.items():
- setattr(self, '%s_open' % type,
- lambda r, proxy=url, type=type, meth=self.proxy_open: \
- meth(r, proxy, type))
-
- def proxy_open(self, req, proxy, type):
- orig_type = req.get_type()
- proxy_type, user, password, hostport = _parse_proxy(proxy)
-
- if proxy_type is None:
- proxy_type = orig_type
-
- if req.host and proxy_bypass(req.host):
- return None
-
- if user and password:
- user_pass = '%s:%s' % (unquote(user), unquote(password))
- creds = base64.b64encode(user_pass).strip()
- req.add_header('Proxy-authorization', 'Basic ' + creds)
- hostport = unquote(hostport)
- req.set_proxy(hostport, proxy_type)
-
- if orig_type == proxy_type or orig_type == 'https':
- # let other handlers take care of it
- return None
- else:
- # need to start over, because the other handlers don't
- # grok the proxy's URL type
- # e.g. if we have a constructor arg proxies like so:
- # {'http': 'ftp://proxy.example.com'}, we may end up turning
- # a request for http://acme.example.com/a into one for
- # ftp://proxy.example.com/a
- return self.parent.open(req, timeout=req.timeout)
-
-class HTTPPasswordMgr:
-
- def __init__(self):
- self.passwd = {}
-
- def add_password(self, realm, uri, user, passwd):
- # uri could be a single URI or a sequence
- if isinstance(uri, basestring):
- uri = [uri]
- if not realm in self.passwd:
- self.passwd[realm] = {}
- for default_port in True, False:
- reduced_uri = tuple(
- [self.reduce_uri(u, default_port) for u in uri])
- self.passwd[realm][reduced_uri] = (user, passwd)
-
- def find_user_password(self, realm, authuri):
- domains = self.passwd.get(realm, {})
- for default_port in True, False:
- reduced_authuri = self.reduce_uri(authuri, default_port)
- for uris, authinfo in domains.iteritems():
- for uri in uris:
- if self.is_suburi(uri, reduced_authuri):
- return authinfo
- return None, None
-
- def reduce_uri(self, uri, default_port=True):
- """Accept authority or URI and extract only the authority and path."""
- # note HTTP URLs do not have a userinfo component
- parts = urlparse.urlsplit(uri)
- if parts[1]:
- # URI
- scheme = parts[0]
- authority = parts[1]
- path = parts[2] or '/'
- else:
- # host or host:port
- scheme = None
- authority = uri
- path = '/'
- host, port = splitport(authority)
- if default_port and port is None and scheme is not None:
- dport = {"http": 80,
- "https": 443,
- }.get(scheme)
- if dport is not None:
- authority = "%s:%d" % (host, dport)
- return authority, path
-
- def is_suburi(self, base, test):
- """Check if test is below base in a URI tree
-
- Both args must be URIs in reduced form.
- """
- if base == test:
- return True
- if base[0] != test[0]:
- return False
- common = posixpath.commonprefix((base[1], test[1]))
- if len(common) == len(base[1]):
- return True
- return False
-
-
-class HTTPPasswordMgrWithDefaultRealm(HTTPPasswordMgr):
-
- def find_user_password(self, realm, authuri):
- user, password = HTTPPasswordMgr.find_user_password(self, realm,
- authuri)
- if user is not None:
- return user, password
- return HTTPPasswordMgr.find_user_password(self, None, authuri)
-
-
-class AbstractBasicAuthHandler:
-
- # XXX this allows for multiple auth-schemes, but will stupidly pick
- # the last one with a realm specified.
-
- # allow for double- and single-quoted realm values
- # (single quotes are a violation of the RFC, but appear in the wild)
- rx = re.compile('(?:.*,)*[ \t]*([^ \t]+)[ \t]+'
- 'realm=(["\']?)([^"\']*)\\2', re.I)
-
- # XXX could pre-emptively send auth info already accepted (RFC 2617,
- # end of section 2, and section 1.2 immediately after "credentials"
- # production).
-
- def __init__(self, password_mgr=None):
- if password_mgr is None:
- password_mgr = HTTPPasswordMgr()
- self.passwd = password_mgr
- self.add_password = self.passwd.add_password
- self.retried = 0
-
- def reset_retry_count(self):
- self.retried = 0
-
- def http_error_auth_reqed(self, authreq, host, req, headers):
- # host may be an authority (without userinfo) or a URL with an
- # authority
- # XXX could be multiple headers
- authreq = headers.get(authreq, None)
-
- if self.retried > 5:
- # retry sending the username:password 5 times before failing.
- raise HTTPError(req.get_full_url(), 401, "basic auth failed",
- headers, None)
- else:
- self.retried += 1
-
- if authreq:
- mo = AbstractBasicAuthHandler.rx.search(authreq)
- if mo:
- scheme, quote, realm = mo.groups()
- if quote not in ['"', "'"]:
- warnings.warn("Basic Auth Realm was unquoted",
- UserWarning, 2)
- if scheme.lower() == 'basic':
- response = self.retry_http_basic_auth(host, req, realm)
- if response and response.code != 401:
- self.retried = 0
- return response
-
- def retry_http_basic_auth(self, host, req, realm):
- user, pw = self.passwd.find_user_password(realm, host)
- if pw is not None:
- raw = "%s:%s" % (user, pw)
- auth = 'Basic %s' % base64.b64encode(raw).strip()
- if req.headers.get(self.auth_header, None) == auth:
- return None
- req.add_unredirected_header(self.auth_header, auth)
- return self.parent.open(req, timeout=req.timeout)
- else:
- return None
-
-
-class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
-
- auth_header = 'Authorization'
-
- def http_error_401(self, req, fp, code, msg, headers):
- url = req.get_full_url()
- response = self.http_error_auth_reqed('www-authenticate',
- url, req, headers)
- self.reset_retry_count()
- return response
-
-
-class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
-
- auth_header = 'Proxy-authorization'
-
- def http_error_407(self, req, fp, code, msg, headers):
- # http_error_auth_reqed requires that there is no userinfo component in
- # authority. Assume there isn't one, since urllib2 does not (and
- # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
- # userinfo.
- authority = req.get_host()
- response = self.http_error_auth_reqed('proxy-authenticate',
- authority, req, headers)
- self.reset_retry_count()
- return response
-
-
-def randombytes(n):
- """Return n random bytes."""
- # Use /dev/urandom if it is available. Fall back to random module
- # if not. It might be worthwhile to extend this function to use
- # other platform-specific mechanisms for getting random bytes.
- if os.path.exists("/dev/urandom"):
- f = open("/dev/urandom")
- s = f.read(n)
- f.close()
- return s
- else:
- L = [chr(random.randrange(0, 256)) for i in range(n)]
- return "".join(L)
-
-class AbstractDigestAuthHandler:
- # Digest authentication is specified in RFC 2617.
-
- # XXX The client does not inspect the Authentication-Info header
- # in a successful response.
-
- # XXX It should be possible to test this implementation against
- # a mock server that just generates a static set of challenges.
-
- # XXX qop="auth-int" supports is shaky
-
- def __init__(self, passwd=None):
- if passwd is None:
- passwd = HTTPPasswordMgr()
- self.passwd = passwd
- self.add_password = self.passwd.add_password
- self.retried = 0
- self.nonce_count = 0
- self.last_nonce = None
-
- def reset_retry_count(self):
- self.retried = 0
-
- def http_error_auth_reqed(self, auth_header, host, req, headers):
- authreq = headers.get(auth_header, None)
- if self.retried > 5:
- # Don't fail endlessly - if we failed once, we'll probably
- # fail a second time. Hm. Unless the Password Manager is
- # prompting for the information. Crap. This isn't great
- # but it's better than the current 'repeat until recursion
- # depth exceeded' approach <wink>
- raise HTTPError(req.get_full_url(), 401, "digest auth failed",
- headers, None)
- else:
- self.retried += 1
- if authreq:
- scheme = authreq.split()[0]
- if scheme.lower() == 'digest':
- return self.retry_http_digest_auth(req, authreq)
-
- def retry_http_digest_auth(self, req, auth):
- token, challenge = auth.split(' ', 1)
- chal = parse_keqv_list(parse_http_list(challenge))
- auth = self.get_authorization(req, chal)
- if auth:
- auth_val = 'Digest %s' % auth
- if req.headers.get(self.auth_header, None) == auth_val:
- return None
- req.add_unredirected_header(self.auth_header, auth_val)
- resp = self.parent.open(req, timeout=req.timeout)
- return resp
-
- def get_cnonce(self, nonce):
- # The cnonce-value is an opaque
- # quoted string value provided by the client and used by both client
- # and server to avoid chosen plaintext attacks, to provide mutual
- # authentication, and to provide some message integrity protection.
- # This isn't a fabulous effort, but it's probably Good Enough.
- dig = hashlib.sha1("%s:%s:%s:%s" % (self.nonce_count, nonce, time.ctime(),
- randombytes(8))).hexdigest()
- return dig[:16]
-
- def get_authorization(self, req, chal):
- try:
- realm = chal['realm']
- nonce = chal['nonce']
- qop = chal.get('qop')
- algorithm = chal.get('algorithm', 'MD5')
- # mod_digest doesn't send an opaque, even though it isn't
- # supposed to be optional
- opaque = chal.get('opaque', None)
- except KeyError:
- return None
-
- H, KD = self.get_algorithm_impls(algorithm)
- if H is None:
- return None
-
- user, pw = self.passwd.find_user_password(realm, req.get_full_url())
- if user is None:
- return None
-
- # XXX not implemented yet
- if req.has_data():
- entdig = self.get_entity_digest(req.get_data(), chal)
- else:
- entdig = None
-
- A1 = "%s:%s:%s" % (user, realm, pw)
- A2 = "%s:%s" % (req.get_method(),
- # XXX selector: what about proxies and full urls
- req.get_selector())
- if qop == 'auth':
- if nonce == self.last_nonce:
- self.nonce_count += 1
- else:
- self.nonce_count = 1
- self.last_nonce = nonce
-
- ncvalue = '%08x' % self.nonce_count
- cnonce = self.get_cnonce(nonce)
- noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, H(A2))
- respdig = KD(H(A1), noncebit)
- elif qop is None:
- respdig = KD(H(A1), "%s:%s" % (nonce, H(A2)))
- else:
- # XXX handle auth-int.
- raise URLError("qop '%s' is not supported." % qop)
-
- # XXX should the partial digests be encoded too?
-
- base = 'username="%s", realm="%s", nonce="%s", uri="%s", ' \
- 'response="%s"' % (user, realm, nonce, req.get_selector(),
- respdig)
- if opaque:
- base += ', opaque="%s"' % opaque
- if entdig:
- base += ', digest="%s"' % entdig
- base += ', algorithm="%s"' % algorithm
- if qop:
- base += ', qop=auth, nc=%s, cnonce="%s"' % (ncvalue, cnonce)
- return base
-
- def get_algorithm_impls(self, algorithm):
- # algorithm should be case-insensitive according to RFC2617
- algorithm = algorithm.upper()
- # lambdas assume digest modules are imported at the top level
- if algorithm == 'MD5':
- H = lambda x: hashlib.md5(x).hexdigest()
- elif algorithm == 'SHA':
- H = lambda x: hashlib.sha1(x).hexdigest()
- # XXX MD5-sess
- KD = lambda s, d: H("%s:%s" % (s, d))
- return H, KD
-
- def get_entity_digest(self, data, chal):
- # XXX not implemented yet
- return None
-
-
-class HTTPDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
- """An authentication protocol defined by RFC 2069
-
- Digest authentication improves on basic authentication because it
- does not transmit passwords in the clear.
- """
-
- auth_header = 'Authorization'
- handler_order = 490 # before Basic auth
-
- def http_error_401(self, req, fp, code, msg, headers):
- host = urlparse.urlparse(req.get_full_url())[1]
- retry = self.http_error_auth_reqed('www-authenticate',
- host, req, headers)
- self.reset_retry_count()
- return retry
-
-
-class ProxyDigestAuthHandler(BaseHandler, AbstractDigestAuthHandler):
-
- auth_header = 'Proxy-Authorization'
- handler_order = 490 # before Basic auth
-
- def http_error_407(self, req, fp, code, msg, headers):
- host = req.get_host()
- retry = self.http_error_auth_reqed('proxy-authenticate',
- host, req, headers)
- self.reset_retry_count()
- return retry
-
-class AbstractHTTPHandler(BaseHandler):
-
- def __init__(self, debuglevel=0):
- self._debuglevel = debuglevel
-
- def set_http_debuglevel(self, level):
- self._debuglevel = level
-
- def do_request_(self, request):
- host = request.get_host()
- if not host:
- raise URLError('no host given')
-
- if request.has_data(): # POST
- data = request.get_data()
- if not request.has_header('Content-type'):
- request.add_unredirected_header(
- 'Content-type',
- 'application/x-www-form-urlencoded')
- if not request.has_header('Content-length'):
- request.add_unredirected_header(
- 'Content-length', '%d' % len(data))
-
- sel_host = host
- if request.has_proxy():
- scheme, sel = splittype(request.get_selector())
- sel_host, sel_path = splithost(sel)
-
- if not request.has_header('Host'):
- request.add_unredirected_header('Host', sel_host)
- for name, value in self.parent.addheaders:
- name = name.capitalize()
- if not request.has_header(name):
- request.add_unredirected_header(name, value)
-
- return request
-
- def do_open(self, http_class, req):
- """Return an addinfourl object for the request, using http_class.
-
- http_class must implement the HTTPConnection API from httplib.
- The addinfourl return value is a file-like object. It also
- has methods and attributes including:
- - info(): return a mimetools.Message object for the headers
- - geturl(): return the original request URL
- - code: HTTP status code
- """
- host = req.get_host()
- if not host:
- raise URLError('no host given')
-
- h = http_class(host, timeout=req.timeout) # will parse host:port
- h.set_debuglevel(self._debuglevel)
-
- headers = dict(req.unredirected_hdrs)
- headers.update(dict((k, v) for k, v in req.headers.items()
- if k not in headers))
-
- # We want to make an HTTP/1.1 request, but the addinfourl
- # class isn't prepared to deal with a persistent connection.
- # It will try to read all remaining data from the socket,
- # which will block while the server waits for the next request.
- # So make sure the connection gets closed after the (only)
- # request.
- headers["Connection"] = "close"
- headers = dict(
- (name.title(), val) for name, val in headers.items())
-
- if req._tunnel_host:
- tunnel_headers = {}
- proxy_auth_hdr = "Proxy-Authorization"
- if proxy_auth_hdr in headers:
- tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
- # Proxy-Authorization should not be sent to origin
- # server.
- del headers[proxy_auth_hdr]
- h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
-
- try:
- h.request(req.get_method(), req.get_selector(), req.data, headers)
- except socket.error, err: # XXX what error?
- h.close()
- raise URLError(err)
- else:
- try:
- r = h.getresponse(buffering=True)
- except TypeError: # buffering kw not supported
- r = h.getresponse()
-
- # Pick apart the HTTPResponse object to get the addinfourl
- # object initialized properly.
-
- # Wrap the HTTPResponse object in socket's file object adapter
- # for Windows. That adapter calls recv(), so delegate recv()
- # to read(). This weird wrapping allows the returned object to
- # have readline() and readlines() methods.
-
- # XXX It might be better to extract the read buffering code
- # out of socket._fileobject() and into a base class.
-
- r.recv = r.read
- fp = socket._fileobject(r, close=True)
-
- resp = addinfourl(fp, r.msg, req.get_full_url())
- resp.code = r.status
- resp.msg = r.reason
- return resp
-
-
-class HTTPHandler(AbstractHTTPHandler):
-
- def http_open(self, req):
- return self.do_open(httplib.HTTPConnection, req)
-
- http_request = AbstractHTTPHandler.do_request_
-
-if hasattr(httplib, 'HTTPS'):
- class HTTPSHandler(AbstractHTTPHandler):
-
- def https_open(self, req):
- return self.do_open(httplib.HTTPSConnection, req)
-
- https_request = AbstractHTTPHandler.do_request_
-
-class HTTPCookieProcessor(BaseHandler):
- def __init__(self, cookiejar=None):
- import cookielib
- if cookiejar is None:
- cookiejar = cookielib.CookieJar()
- self.cookiejar = cookiejar
-
- def http_request(self, request):
- self.cookiejar.add_cookie_header(request)
- return request
-
- def http_response(self, request, response):
- self.cookiejar.extract_cookies(response, request)
- return response
-
- https_request = http_request
- https_response = http_response
-
-class UnknownHandler(BaseHandler):
- def unknown_open(self, req):
- type = req.get_type()
- raise URLError('unknown url type: %s' % type)
-
-def parse_keqv_list(l):
- """Parse list of key=value strings where keys are not duplicated."""
- parsed = {}
- for elt in l:
- k, v = elt.split('=', 1)
- if v[0] == '"' and v[-1] == '"':
- v = v[1:-1]
- parsed[k] = v
- return parsed
-
-def parse_http_list(s):
- """Parse lists as described by RFC 2068 Section 2.
-
- In particular, parse comma-separated lists where the elements of
- the list may include quoted-strings. A quoted-string could
- contain a comma. A non-quoted string could have quotes in the
- middle. Neither commas nor quotes count if they are escaped.
- Only double-quotes count, not single-quotes.
- """
- res = []
- part = ''
-
- escape = quote = False
- for cur in s:
- if escape:
- part += cur
- escape = False
- continue
- if quote:
- if cur == '\\':
- escape = True
- continue
- elif cur == '"':
- quote = False
- part += cur
- continue
-
- if cur == ',':
- res.append(part)
- part = ''
- continue
-
- if cur == '"':
- quote = True
-
- part += cur
-
- # append last part
- if part:
- res.append(part)
-
- return [part.strip() for part in res]
-
-def _safe_gethostbyname(host):
- try:
- return socket.gethostbyname(host)
- except socket.gaierror:
- return None
-
-class FileHandler(BaseHandler):
- # Use local file or FTP depending on form of URL
- def file_open(self, req):
- url = req.get_selector()
- if url[:2] == '//' and url[2:3] != '/' and (req.host and
- req.host != 'localhost'):
- req.type = 'ftp'
- return self.parent.open(req)
- else:
- return self.open_local_file(req)
-
- # names for the localhost
- names = None
- def get_names(self):
- if FileHandler.names is None:
- try:
- FileHandler.names = tuple(
- socket.gethostbyname_ex('localhost')[2] +
- socket.gethostbyname_ex(socket.gethostname())[2])
- except socket.gaierror:
- FileHandler.names = (socket.gethostbyname('localhost'),)
- return FileHandler.names
-
- # not entirely sure what the rules are here
- def open_local_file(self, req):
- import email.utils
- import mimetypes
- host = req.get_host()
- filename = req.get_selector()
- localfile = url2pathname(filename)
- try:
- stats = os.stat(localfile)
- size = stats.st_size
- modified = email.utils.formatdate(stats.st_mtime, usegmt=True)
- mtype = mimetypes.guess_type(filename)[0]
- headers = mimetools.Message(StringIO(
- 'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
- (mtype or 'text/plain', size, modified)))
- if host:
- host, port = splitport(host)
- if not host or \
- (not port and _safe_gethostbyname(host) in self.get_names()):
- if host:
- origurl = 'file://' + host + filename
- else:
- origurl = 'file://' + filename
- return addinfourl(open(localfile, 'rb'), headers, origurl)
- except OSError, msg:
- # urllib2 users shouldn't expect OSErrors coming from urlopen()
- raise URLError(msg)
- raise URLError('file not on local host')
-
-class FTPHandler(BaseHandler):
- def ftp_open(self, req):
- import ftplib
- import mimetypes
- host = req.get_host()
- if not host:
- raise URLError('ftp error: no host given')
- host, port = splitport(host)
- if port is None:
- port = ftplib.FTP_PORT
- else:
- port = int(port)
-
- # username/password handling
- user, host = splituser(host)
- if user:
- user, passwd = splitpasswd(user)
- else:
- passwd = None
- host = unquote(host)
- user = user or ''
- passwd = passwd or ''
-
- try:
- host = socket.gethostbyname(host)
- except socket.error, msg:
- raise URLError(msg)
- path, attrs = splitattr(req.get_selector())
- dirs = path.split('/')
- dirs = map(unquote, dirs)
- dirs, file = dirs[:-1], dirs[-1]
- if dirs and not dirs[0]:
- dirs = dirs[1:]
- try:
- fw = self.connect_ftp(user, passwd, host, port, dirs, req.timeout)
- type = file and 'I' or 'D'
- for attr in attrs:
- attr, value = splitvalue(attr)
- if attr.lower() == 'type' and \
- value in ('a', 'A', 'i', 'I', 'd', 'D'):
- type = value.upper()
- fp, retrlen = fw.retrfile(file, type)
- headers = ""
- mtype = mimetypes.guess_type(req.get_full_url())[0]
- if mtype:
- headers += "Content-type: %s\n" % mtype
- if retrlen is not None and retrlen >= 0:
- headers += "Content-length: %d\n" % retrlen
- sf = StringIO(headers)
- headers = mimetools.Message(sf)
- return addinfourl(fp, headers, req.get_full_url())
- except ftplib.all_errors, msg:
- raise URLError, ('ftp error: %s' % msg), sys.exc_info()[2]
-
- def connect_ftp(self, user, passwd, host, port, dirs, timeout):
- fw = ftpwrapper(user, passwd, host, port, dirs, timeout,
- persistent=False)
-## fw.ftp.set_debuglevel(1)
- return fw
-
-class CacheFTPHandler(FTPHandler):
- # XXX would be nice to have pluggable cache strategies
- # XXX this stuff is definitely not thread safe
- def __init__(self):
- self.cache = {}
- self.timeout = {}
- self.soonest = 0
- self.delay = 60
- self.max_conns = 16
-
- def setTimeout(self, t):
- self.delay = t
-
- def setMaxConns(self, m):
- self.max_conns = m
-
- def connect_ftp(self, user, passwd, host, port, dirs, timeout):
- key = user, host, port, '/'.join(dirs), timeout
- if key in self.cache:
- self.timeout[key] = time.time() + self.delay
- else:
- self.cache[key] = ftpwrapper(user, passwd, host, port, dirs, timeout)
- self.timeout[key] = time.time() + self.delay
- self.check_cache()
- return self.cache[key]
-
- def check_cache(self):
- # first check for old ones
- t = time.time()
- if self.soonest <= t:
- for k, v in self.timeout.items():
- if v < t:
- self.cache[k].close()
- del self.cache[k]
- del self.timeout[k]
- self.soonest = min(self.timeout.values())
-
- # then check the size
- if len(self.cache) == self.max_conns:
- for k, v in self.timeout.items():
- if v == self.soonest:
- del self.cache[k]
- del self.timeout[k]
- break
- self.soonest = min(self.timeout.values())
-
- def clear_cache(self):
- for conn in self.cache.values():
- conn.close()
- self.cache.clear()
- self.timeout.clear()
diff --git a/Lib/urlparse.py b/Lib/urlparse.py
deleted file mode 100644
index f370ce3bdcc..00000000000
--- a/Lib/urlparse.py
+++ /dev/null
@@ -1,403 +0,0 @@
-"""Parse (absolute and relative) URLs.
-
-urlparse module is based upon the following RFC specifications.
-
-RFC 3986 (STD66): "Uniform Resource Identifiers" by T. Berners-Lee, R. Fielding
-and L. Masinter, January 2005.
-
-RFC 2732 : "Format for Literal IPv6 Addresses in URL's by R.Hinden, B.Carpenter
-and L.Masinter, December 1999.
-
-RFC 2396: "Uniform Resource Identifiers (URI)": Generic Syntax by T.
-Berners-Lee, R. Fielding, and L. Masinter, August 1998.
-
-RFC 2368: "The mailto URL scheme", by P.Hoffman , L Masinter, J. Zwinski, July 1998.
-
-RFC 1808: "Relative Uniform Resource Locators", by R. Fielding, UC Irvine, June
-1995.
-
-RFC 1738: "Uniform Resource Locators (URL)" by T. Berners-Lee, L. Masinter, M.
-McCahill, December 1994
-
-RFC 3986 is considered the current standard and any future changes to
-urlparse module should conform with it. The urlparse module is
-currently not entirely compliant with this RFC due to defacto
-scenarios for parsing, and for backward compatibility purposes, some
-parsing quirks from older RFCs are retained. The testcases in
-test_urlparse.py provides a good indicator of parsing behavior.
-
-"""
-
-__all__ = ["urlparse", "urlunparse", "urljoin", "urldefrag",
- "urlsplit", "urlunsplit", "parse_qs", "parse_qsl"]
-
-# A classification of schemes ('' means apply by default)
-uses_relative = ['ftp', 'http', 'gopher', 'nntp', 'imap',
- 'wais', 'file', 'https', 'shttp', 'mms',
- 'prospero', 'rtsp', 'rtspu', '', 'sftp',
- 'svn', 'svn+ssh']
-uses_netloc = ['ftp', 'http', 'gopher', 'nntp', 'telnet',
- 'imap', 'wais', 'file', 'mms', 'https', 'shttp',
- 'snews', 'prospero', 'rtsp', 'rtspu', 'rsync', '',
- 'svn', 'svn+ssh', 'sftp','nfs','git', 'git+ssh']
-uses_params = ['ftp', 'hdl', 'prospero', 'http', 'imap',
- 'https', 'shttp', 'rtsp', 'rtspu', 'sip', 'sips',
- 'mms', '', 'sftp', 'tel']
-
-# These are not actually used anymore, but should stay for backwards
-# compatibility. (They are undocumented, but have a public-looking name.)
-non_hierarchical = ['gopher', 'hdl', 'mailto', 'news',
- 'telnet', 'wais', 'imap', 'snews', 'sip', 'sips']
-uses_query = ['http', 'wais', 'imap', 'https', 'shttp', 'mms',
- 'gopher', 'rtsp', 'rtspu', 'sip', 'sips', '']
-uses_fragment = ['ftp', 'hdl', 'http', 'gopher', 'news',
- 'nntp', 'wais', 'https', 'shttp', 'snews',
- 'file', 'prospero', '']
-
-# Characters valid in scheme names
-scheme_chars = ('abcdefghijklmnopqrstuvwxyz'
- 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
- '0123456789'
- '+-.')
-
-MAX_CACHE_SIZE = 20
-_parse_cache = {}
-
-def clear_cache():
- """Clear the parse cache."""
- _parse_cache.clear()
-
-
-class ResultMixin(object):
- """Shared methods for the parsed result objects."""
-
- @property
- def username(self):
- netloc = self.netloc
- if "@" in netloc:
- userinfo = netloc.rsplit("@", 1)[0]
- if ":" in userinfo:
- userinfo = userinfo.split(":", 1)[0]
- return userinfo
- return None
-
- @property
- def password(self):
- netloc = self.netloc
- if "@" in netloc:
- userinfo = netloc.rsplit("@", 1)[0]
- if ":" in userinfo:
- return userinfo.split(":", 1)[1]
- return None
-
- @property
- def hostname(self):
- netloc = self.netloc.split('@')[-1]
- if '[' in netloc and ']' in netloc:
- return netloc.split(']')[0][1:].lower()
- elif ':' in netloc:
- return netloc.split(':')[0].lower()
- elif netloc == '':
- return None
- else:
- return netloc.lower()
-
- @property
- def port(self):
- netloc = self.netloc.split('@')[-1].split(']')[-1]
- if ':' in netloc:
- port = netloc.split(':')[1]
- port = int(port, 10)
- # verify legal port
- if (0 <= port <= 65535):
- return port
- return None
-
-from collections import namedtuple
-
-class SplitResult(namedtuple('SplitResult', 'scheme netloc path query fragment'), ResultMixin):
-
- __slots__ = ()
-
- def geturl(self):
- return urlunsplit(self)
-
-
-class ParseResult(namedtuple('ParseResult', 'scheme netloc path params query fragment'), ResultMixin):
-
- __slots__ = ()
-
- def geturl(self):
- return urlunparse(self)
-
-
-def urlparse(url, scheme='', allow_fragments=True):
- """Parse a URL into 6 components:
- <scheme>://<netloc>/<path>;<params>?<query>#<fragment>
- Return a 6-tuple: (scheme, netloc, path, params, query, fragment).
- Note that we don't break the components up in smaller bits
- (e.g. netloc is a single string) and we don't expand % escapes."""
- tuple = urlsplit(url, scheme, allow_fragments)
- scheme, netloc, url, query, fragment = tuple
- if scheme in uses_params and ';' in url:
- url, params = _splitparams(url)
- else:
- params = ''
- return ParseResult(scheme, netloc, url, params, query, fragment)
-
-def _splitparams(url):
- if '/' in url:
- i = url.find(';', url.rfind('/'))
- if i < 0:
- return url, ''
- else:
- i = url.find(';')
- return url[:i], url[i+1:]
-
-def _splitnetloc(url, start=0):
- delim = len(url) # position of end of domain part of url, default is end
- for c in '/?#': # look for delimiters; the order is NOT important
- wdelim = url.find(c, start) # find first of this delim
- if wdelim >= 0: # if found
- delim = min(delim, wdelim) # use earliest delim position
- return url[start:delim], url[delim:] # return (domain, rest)
-
-def urlsplit(url, scheme='', allow_fragments=True):
- """Parse a URL into 5 components:
- <scheme>://<netloc>/<path>?<query>#<fragment>
- Return a 5-tuple: (scheme, netloc, path, query, fragment).
- Note that we don't break the components up in smaller bits
- (e.g. netloc is a single string) and we don't expand % escapes."""
- allow_fragments = bool(allow_fragments)
- key = url, scheme, allow_fragments, type(url), type(scheme)
- cached = _parse_cache.get(key, None)
- if cached:
- return cached
- if len(_parse_cache) >= MAX_CACHE_SIZE: # avoid runaway growth
- clear_cache()
- netloc = query = fragment = ''
- i = url.find(':')
- if i > 0:
- if url[:i] == 'http': # optimize the common case
- scheme = url[:i].lower()
- url = url[i+1:]
- if url[:2] == '//':
- netloc, url = _splitnetloc(url, 2)
- if (('[' in netloc and ']' not in netloc) or
- (']' in netloc and '[' not in netloc)):
- raise ValueError("Invalid IPv6 URL")
- if allow_fragments and '#' in url:
- url, fragment = url.split('#', 1)
- if '?' in url:
- url, query = url.split('?', 1)
- v = SplitResult(scheme, netloc, url, query, fragment)
- _parse_cache[key] = v
- return v
- for c in url[:i]:
- if c not in scheme_chars:
- break
- else:
- # make sure "url" is not actually a port number (in which case
- # "scheme" is really part of the path)
- rest = url[i+1:]
- if not rest or any(c not in '0123456789' for c in rest):
- # not a port number
- scheme, url = url[:i].lower(), rest
-
- if url[:2] == '//':
- netloc, url = _splitnetloc(url, 2)
- if (('[' in netloc and ']' not in netloc) or
- (']' in netloc and '[' not in netloc)):
- raise ValueError("Invalid IPv6 URL")
- if allow_fragments and '#' in url:
- url, fragment = url.split('#', 1)
- if '?' in url:
- url, query = url.split('?', 1)
- v = SplitResult(scheme, netloc, url, query, fragment)
- _parse_cache[key] = v
- return v
-
-def urlunparse(data):
- """Put a parsed URL back together again. This may result in a
- slightly different, but equivalent URL, if the URL that was parsed
- originally had redundant delimiters, e.g. a ? with an empty query
- (the draft states that these are equivalent)."""
- scheme, netloc, url, params, query, fragment = data
- if params:
- url = "%s;%s" % (url, params)
- return urlunsplit((scheme, netloc, url, query, fragment))
-
-def urlunsplit(data):
- """Combine the elements of a tuple as returned by urlsplit() into a
- complete URL as a string. The data argument can be any five-item iterable.
- This may result in a slightly different, but equivalent URL, if the URL that
- was parsed originally had unnecessary delimiters (for example, a ? with an
- empty query; the RFC states that these are equivalent)."""
- scheme, netloc, url, query, fragment = data
- if netloc or (scheme and scheme in uses_netloc and url[:2] != '//'):
- if url and url[:1] != '/': url = '/' + url
- url = '//' + (netloc or '') + url
- if scheme:
- url = scheme + ':' + url
- if query:
- url = url + '?' + query
- if fragment:
- url = url + '#' + fragment
- return url
-
-def urljoin(base, url, allow_fragments=True):
- """Join a base URL and a possibly relative URL to form an absolute
- interpretation of the latter."""
- if not base:
- return url
- if not url:
- return base
- bscheme, bnetloc, bpath, bparams, bquery, bfragment = \
- urlparse(base, '', allow_fragments)
- scheme, netloc, path, params, query, fragment = \
- urlparse(url, bscheme, allow_fragments)
- if scheme != bscheme or scheme not in uses_relative:
- return url
- if scheme in uses_netloc:
- if netloc:
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
- netloc = bnetloc
- if path[:1] == '/':
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
- if not path and not params:
- path = bpath
- params = bparams
- if not query:
- query = bquery
- return urlunparse((scheme, netloc, path,
- params, query, fragment))
- segments = bpath.split('/')[:-1] + path.split('/')
- # XXX The stuff below is bogus in various ways...
- if segments[-1] == '.':
- segments[-1] = ''
- while '.' in segments:
- segments.remove('.')
- while 1:
- i = 1
- n = len(segments) - 1
- while i < n:
- if (segments[i] == '..'
- and segments[i-1] not in ('', '..')):
- del segments[i-1:i+1]
- break
- i = i+1
- else:
- break
- if segments == ['', '..']:
- segments[-1] = ''
- elif len(segments) >= 2 and segments[-1] == '..':
- segments[-2:] = ['']
- return urlunparse((scheme, netloc, '/'.join(segments),
- params, query, fragment))
-
-def urldefrag(url):
- """Removes any existing fragment from URL.
-
- Returns a tuple of the defragmented URL and the fragment. If
- the URL contained no fragments, the second element is the
- empty string.
- """
- if '#' in url:
- s, n, p, a, q, frag = urlparse(url)
- defrag = urlunparse((s, n, p, a, q, ''))
- return defrag, frag
- else:
- return url, ''
-
-# unquote method for parse_qs and parse_qsl
-# Cannot use directly from urllib as it would create a circular reference
-# because urllib uses urlparse methods (urljoin). If you update this function,
-# update it also in urllib. This code duplication does not existin in Python3.
-
-_hexdig = '0123456789ABCDEFabcdef'
-_hextochr = dict((a+b, chr(int(a+b,16)))
- for a in _hexdig for b in _hexdig)
-
-def unquote(s):
- """unquote('abc%20def') -> 'abc def'."""
- res = s.split('%')
- # fastpath
- if len(res) == 1:
- return s
- s = res[0]
- for item in res[1:]:
- try:
- s += _hextochr[item[:2]] + item[2:]
- except KeyError:
- s += '%' + item
- except UnicodeDecodeError:
- s += unichr(int(item[:2], 16)) + item[2:]
- return s
-
-def parse_qs(qs, keep_blank_values=0, strict_parsing=0):
- """Parse a query given as a string argument.
-
- Arguments:
-
- qs: percent-encoded query string to be parsed
-
- keep_blank_values: flag indicating whether blank values in
- percent-encoded queries should be treated as blank strings.
- A true value indicates that blanks should be retained as
- blank strings. The default false value indicates that
- blank values are to be ignored and treated as if they were
- not included.
-
- strict_parsing: flag indicating what to do with parsing errors.
- If false (the default), errors are silently ignored.
- If true, errors raise a ValueError exception.
- """
- dict = {}
- for name, value in parse_qsl(qs, keep_blank_values, strict_parsing):
- if name in dict:
- dict[name].append(value)
- else:
- dict[name] = [value]
- return dict
-
-def parse_qsl(qs, keep_blank_values=0, strict_parsing=0):
- """Parse a query given as a string argument.
-
- Arguments:
-
- qs: percent-encoded query string to be parsed
-
- keep_blank_values: flag indicating whether blank values in
- percent-encoded queries should be treated as blank strings. A
- true value indicates that blanks should be retained as blank
- strings. The default false value indicates that blank values
- are to be ignored and treated as if they were not included.
-
- strict_parsing: flag indicating what to do with parsing errors. If
- false (the default), errors are silently ignored. If true,
- errors raise a ValueError exception.
-
- Returns a list, as G-d intended.
- """
- pairs = [s2 for s1 in qs.split('&') for s2 in s1.split(';')]
- r = []
- for name_value in pairs:
- if not name_value and not strict_parsing:
- continue
- nv = name_value.split('=', 1)
- if len(nv) != 2:
- if strict_parsing:
- raise ValueError, "bad query field: %r" % (name_value,)
- # Handle case of a control-name with no equal sign
- if keep_blank_values:
- nv.append('')
- else:
- continue
- if len(nv[1]) or keep_blank_values:
- name = unquote(nv[0].replace('+', ' '))
- value = unquote(nv[1].replace('+', ' '))
- r.append((name, value))
-
- return r
diff --git a/Lib/user.py b/Lib/user.py
deleted file mode 100644
index 596f0a74628..00000000000
--- a/Lib/user.py
+++ /dev/null
@@ -1,48 +0,0 @@
-"""Hook to allow user-specified customization code to run.
-
-As a policy, Python doesn't run user-specified code on startup of
-Python programs (interactive sessions execute the script specified in
-the PYTHONSTARTUP environment variable if it exists).
-
-However, some programs or sites may find it convenient to allow users
-to have a standard customization file, which gets run when a program
-requests it. This module implements such a mechanism. A program
-that wishes to use the mechanism must execute the statement
-
- import user
-
-The user module looks for a file .pythonrc.py in the user's home
-directory and if it can be opened, execfile()s it in its own global
-namespace. Errors during this phase are not caught; that's up to the
-program that imports the user module, if it wishes.
-
-The user's .pythonrc.py could conceivably test for sys.version if it
-wishes to do different things depending on the Python version.
-
-"""
-from warnings import warnpy3k
-warnpy3k("the user module has been removed in Python 3.0", stacklevel=2)
-del warnpy3k
-
-import os
-
-home = os.curdir # Default
-if 'HOME' in os.environ:
- home = os.environ['HOME']
-elif os.name == 'posix':
- home = os.path.expanduser("~/")
-elif os.name == 'nt': # Contributed by Jeff Bauer
- if 'HOMEPATH' in os.environ:
- if 'HOMEDRIVE' in os.environ:
- home = os.environ['HOMEDRIVE'] + os.environ['HOMEPATH']
- else:
- home = os.environ['HOMEPATH']
-
-pythonrc = os.path.join(home, ".pythonrc.py")
-try:
- f = open(pythonrc)
-except IOError:
- pass
-else:
- f.close()
- execfile(pythonrc)
diff --git a/Lib/uu.py b/Lib/uu.py
index f8fa4c47576..d68d29374a8 100755
--- a/Lib/uu.py
+++ b/Lib/uu.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright 1994 by Lance Ellinghouse
# Cathedral City, California Republic, United States of America.
@@ -47,8 +47,8 @@ def encode(in_file, out_file, name=None, mode=None):
opened_files = []
try:
if in_file == '-':
- in_file = sys.stdin
- elif isinstance(in_file, basestring):
+ in_file = sys.stdin.buffer
+ elif isinstance(in_file, str):
if name is None:
name = os.path.basename(in_file)
if mode is None:
@@ -62,8 +62,8 @@ def encode(in_file, out_file, name=None, mode=None):
# Open out_file if it is a pathname
#
if out_file == '-':
- out_file = sys.stdout
- elif isinstance(out_file, basestring):
+ out_file = sys.stdout.buffer
+ elif isinstance(out_file, str):
out_file = open(out_file, 'wb')
opened_files.append(out_file)
#
@@ -72,32 +72,33 @@ def encode(in_file, out_file, name=None, mode=None):
if name is None:
name = '-'
if mode is None:
- mode = 0666
+ mode = 0o666
#
# Write the data
#
- out_file.write('begin %o %s\n' % ((mode&0777),name))
+ out_file.write(('begin %o %s\n' % ((mode & 0o777), name)).encode("ascii"))
data = in_file.read(45)
while len(data) > 0:
out_file.write(binascii.b2a_uu(data))
data = in_file.read(45)
- out_file.write(' \nend\n')
+ out_file.write(b' \nend\n')
finally:
for f in opened_files:
f.close()
-def decode(in_file, out_file=None, mode=None, quiet=0):
+def decode(in_file, out_file=None, mode=None, quiet=False):
"""Decode uuencoded file"""
#
# Open the input file, if needed.
#
opened_files = []
if in_file == '-':
- in_file = sys.stdin
- elif isinstance(in_file, basestring):
- in_file = open(in_file)
+ in_file = sys.stdin.buffer
+ elif isinstance(in_file, str):
+ in_file = open(in_file, 'rb')
opened_files.append(in_file)
+
try:
#
# Read until a begin is encountered or we've exhausted the file
@@ -106,17 +107,18 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
hdr = in_file.readline()
if not hdr:
raise Error('No valid begin line found in input file')
- if not hdr.startswith('begin'):
+ if not hdr.startswith(b'begin'):
continue
- hdrfields = hdr.split(' ', 2)
- if len(hdrfields) == 3 and hdrfields[0] == 'begin':
+ hdrfields = hdr.split(b' ', 2)
+ if len(hdrfields) == 3 and hdrfields[0] == b'begin':
try:
int(hdrfields[1], 8)
break
except ValueError:
pass
if out_file is None:
- out_file = hdrfields[2].rstrip()
+ # If the filename isn't ASCII, what's up with that?!?
+ out_file = hdrfields[2].rstrip(b' \t\r\n\f').decode("ascii")
if os.path.exists(out_file):
raise Error('Cannot overwrite existing file: %s' % out_file)
if mode is None:
@@ -125,8 +127,8 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
# Open the output file
#
if out_file == '-':
- out_file = sys.stdout
- elif isinstance(out_file, basestring):
+ out_file = sys.stdout.buffer
+ elif isinstance(out_file, str):
fp = open(out_file, 'wb')
try:
os.path.chmod(out_file, mode)
@@ -138,12 +140,12 @@ def decode(in_file, out_file=None, mode=None, quiet=0):
# Main decoding loop
#
s = in_file.readline()
- while s and s.strip() != 'end':
+ while s and s.strip(b' \t\r\n\f') != b'end':
try:
data = binascii.a2b_uu(s)
- except binascii.Error, v:
+ except binascii.Error as v:
# Workaround for broken uuencoders by /Fredrik Lundh
- nbytes = (((ord(s[0])-32) & 63) * 4 + 5) // 3
+ nbytes = (((s[0]-32) & 63) * 4 + 5) // 3
data = binascii.a2b_uu(s[:nbytes])
if not quiet:
sys.stderr.write("Warning: %s\n" % v)
@@ -168,8 +170,9 @@ def test():
parser.error('incorrect number of arguments')
sys.exit(1)
- input = sys.stdin
- output = sys.stdout
+ # Use the binary streams underlying stdin/stdout
+ input = sys.stdin.buffer
+ output = sys.stdout.buffer
if len(args) > 0:
input = args[0]
if len(args) > 1:
@@ -177,18 +180,18 @@ def test():
if options.decode:
if options.text:
- if isinstance(output, basestring):
- output = open(output, 'w')
+ if isinstance(output, str):
+ output = open(output, 'wb')
else:
- print sys.argv[0], ': cannot do -t to stdout'
+ print(sys.argv[0], ': cannot do -t to stdout')
sys.exit(1)
decode(input, output)
else:
if options.text:
- if isinstance(input, basestring):
- input = open(input, 'r')
+ if isinstance(input, str):
+ input = open(input, 'rb')
else:
- print sys.argv[0], ': cannot do -t from stdin'
+ print(sys.argv[0], ': cannot do -t from stdin')
sys.exit(1)
encode(input, output)
diff --git a/Lib/uuid.py b/Lib/uuid.py
index fdd0c5cbec0..5684ad7acee 100644
--- a/Lib/uuid.py
+++ b/Lib/uuid.py
@@ -13,7 +13,7 @@ Typical usage:
>>> import uuid
# make a UUID based on the host ID and current time
- >>> uuid.uuid1()
+ >>> uuid.uuid1() # doctest: +SKIP
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
# make a UUID using an MD5 hash of a namespace UUID and a name
@@ -21,7 +21,7 @@ Typical usage:
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
# make a random UUID
- >>> uuid.uuid4()
+ >>> uuid.uuid4() # doctest: +SKIP
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
# make a UUID using a SHA-1 hash of a namespace UUID and a name
@@ -37,7 +37,7 @@ Typical usage:
# get the raw 16 bytes of the UUID
>>> x.bytes
- '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
+ b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
# make a UUID from a 16-byte string
>>> uuid.UUID(bytes=x.bytes)
@@ -50,6 +50,9 @@ RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, RESERVED_FUTURE = [
'reserved for NCS compatibility', 'specified in RFC 4122',
'reserved for Microsoft compatibility', 'reserved for future definition']
+int_ = int # The built-in int type
+bytes_ = bytes # The built-in bytes type
+
class UUID(object):
"""Instances of the UUID class represent UUIDs as specified in RFC 4122.
UUID objects are immutable, hashable, and usable as dictionary keys.
@@ -132,54 +135,84 @@ class UUID(object):
hex = hex.strip('{}').replace('-', '')
if len(hex) != 32:
raise ValueError('badly formed hexadecimal UUID string')
- int = long(hex, 16)
+ int = int_(hex, 16)
if bytes_le is not None:
if len(bytes_le) != 16:
raise ValueError('bytes_le is not a 16-char string')
- bytes = (bytes_le[3] + bytes_le[2] + bytes_le[1] + bytes_le[0] +
- bytes_le[5] + bytes_le[4] + bytes_le[7] + bytes_le[6] +
+ bytes = (bytes_(reversed(bytes_le[0:4])) +
+ bytes_(reversed(bytes_le[4:6])) +
+ bytes_(reversed(bytes_le[6:8])) +
bytes_le[8:])
if bytes is not None:
if len(bytes) != 16:
raise ValueError('bytes is not a 16-char string')
- int = long(('%02x'*16) % tuple(map(ord, bytes)), 16)
+ assert isinstance(bytes, bytes_), repr(bytes)
+ int = int_(('%02x'*16) % tuple(bytes), 16)
if fields is not None:
if len(fields) != 6:
raise ValueError('fields is not a 6-tuple')
(time_low, time_mid, time_hi_version,
clock_seq_hi_variant, clock_seq_low, node) = fields
- if not 0 <= time_low < 1<<32L:
+ if not 0 <= time_low < 1<<32:
raise ValueError('field 1 out of range (need a 32-bit value)')
- if not 0 <= time_mid < 1<<16L:
+ if not 0 <= time_mid < 1<<16:
raise ValueError('field 2 out of range (need a 16-bit value)')
- if not 0 <= time_hi_version < 1<<16L:
+ if not 0 <= time_hi_version < 1<<16:
raise ValueError('field 3 out of range (need a 16-bit value)')
- if not 0 <= clock_seq_hi_variant < 1<<8L:
+ if not 0 <= clock_seq_hi_variant < 1<<8:
raise ValueError('field 4 out of range (need an 8-bit value)')
- if not 0 <= clock_seq_low < 1<<8L:
+ if not 0 <= clock_seq_low < 1<<8:
raise ValueError('field 5 out of range (need an 8-bit value)')
- if not 0 <= node < 1<<48L:
+ if not 0 <= node < 1<<48:
raise ValueError('field 6 out of range (need a 48-bit value)')
- clock_seq = (clock_seq_hi_variant << 8L) | clock_seq_low
- int = ((time_low << 96L) | (time_mid << 80L) |
- (time_hi_version << 64L) | (clock_seq << 48L) | node)
+ clock_seq = (clock_seq_hi_variant << 8) | clock_seq_low
+ int = ((time_low << 96) | (time_mid << 80) |
+ (time_hi_version << 64) | (clock_seq << 48) | node)
if int is not None:
- if not 0 <= int < 1<<128L:
+ if not 0 <= int < 1<<128:
raise ValueError('int is out of range (need a 128-bit value)')
if version is not None:
if not 1 <= version <= 5:
raise ValueError('illegal version number')
# Set the variant to RFC 4122.
- int &= ~(0xc000 << 48L)
- int |= 0x8000 << 48L
+ int &= ~(0xc000 << 48)
+ int |= 0x8000 << 48
# Set the version number.
- int &= ~(0xf000 << 64L)
- int |= version << 76L
+ int &= ~(0xf000 << 64)
+ int |= version << 76
self.__dict__['int'] = int
- def __cmp__(self, other):
+ def __eq__(self, other):
+ if isinstance(other, UUID):
+ return self.int == other.int
+ return NotImplemented
+
+ def __ne__(self, other):
+ if isinstance(other, UUID):
+ return self.int != other.int
+ return NotImplemented
+
+ # Q. What's the value of being able to sort UUIDs?
+ # A. Use them as keys in a B-Tree or similar mapping.
+
+ def __lt__(self, other):
+ if isinstance(other, UUID):
+ return self.int < other.int
+ return NotImplemented
+
+ def __gt__(self, other):
+ if isinstance(other, UUID):
+ return self.int > other.int
+ return NotImplemented
+
+ def __le__(self, other):
+ if isinstance(other, UUID):
+ return self.int <= other.int
+ return NotImplemented
+
+ def __ge__(self, other):
if isinstance(other, UUID):
- return cmp(self.int, other.int)
+ return self.int >= other.int
return NotImplemented
def __hash__(self):
@@ -199,97 +232,84 @@ class UUID(object):
return '%s-%s-%s-%s-%s' % (
hex[:8], hex[8:12], hex[12:16], hex[16:20], hex[20:])
- def get_bytes(self):
- bytes = ''
+ @property
+ def bytes(self):
+ bytes = bytearray()
for shift in range(0, 128, 8):
- bytes = chr((self.int >> shift) & 0xff) + bytes
- return bytes
-
- bytes = property(get_bytes)
+ bytes.insert(0, (self.int >> shift) & 0xff)
+ return bytes_(bytes)
- def get_bytes_le(self):
+ @property
+ def bytes_le(self):
bytes = self.bytes
- return (bytes[3] + bytes[2] + bytes[1] + bytes[0] +
- bytes[5] + bytes[4] + bytes[7] + bytes[6] + bytes[8:])
+ return (bytes_(reversed(bytes[0:4])) +
+ bytes_(reversed(bytes[4:6])) +
+ bytes_(reversed(bytes[6:8])) +
+ bytes[8:])
- bytes_le = property(get_bytes_le)
-
- def get_fields(self):
+ @property
+ def fields(self):
return (self.time_low, self.time_mid, self.time_hi_version,
self.clock_seq_hi_variant, self.clock_seq_low, self.node)
- fields = property(get_fields)
-
- def get_time_low(self):
- return self.int >> 96L
-
- time_low = property(get_time_low)
-
- def get_time_mid(self):
- return (self.int >> 80L) & 0xffff
-
- time_mid = property(get_time_mid)
-
- def get_time_hi_version(self):
- return (self.int >> 64L) & 0xffff
+ @property
+ def time_low(self):
+ return self.int >> 96
- time_hi_version = property(get_time_hi_version)
+ @property
+ def time_mid(self):
+ return (self.int >> 80) & 0xffff
- def get_clock_seq_hi_variant(self):
- return (self.int >> 56L) & 0xff
+ @property
+ def time_hi_version(self):
+ return (self.int >> 64) & 0xffff
- clock_seq_hi_variant = property(get_clock_seq_hi_variant)
+ @property
+ def clock_seq_hi_variant(self):
+ return (self.int >> 56) & 0xff
- def get_clock_seq_low(self):
- return (self.int >> 48L) & 0xff
+ @property
+ def clock_seq_low(self):
+ return (self.int >> 48) & 0xff
- clock_seq_low = property(get_clock_seq_low)
+ @property
+ def time(self):
+ return (((self.time_hi_version & 0x0fff) << 48) |
+ (self.time_mid << 32) | self.time_low)
- def get_time(self):
- return (((self.time_hi_version & 0x0fffL) << 48L) |
- (self.time_mid << 32L) | self.time_low)
-
- time = property(get_time)
-
- def get_clock_seq(self):
- return (((self.clock_seq_hi_variant & 0x3fL) << 8L) |
+ @property
+ def clock_seq(self):
+ return (((self.clock_seq_hi_variant & 0x3f) << 8) |
self.clock_seq_low)
- clock_seq = property(get_clock_seq)
-
- def get_node(self):
+ @property
+ def node(self):
return self.int & 0xffffffffffff
- node = property(get_node)
-
- def get_hex(self):
+ @property
+ def hex(self):
return '%032x' % self.int
- hex = property(get_hex)
-
- def get_urn(self):
+ @property
+ def urn(self):
return 'urn:uuid:' + str(self)
- urn = property(get_urn)
-
- def get_variant(self):
- if not self.int & (0x8000 << 48L):
+ @property
+ def variant(self):
+ if not self.int & (0x8000 << 48):
return RESERVED_NCS
- elif not self.int & (0x4000 << 48L):
+ elif not self.int & (0x4000 << 48):
return RFC_4122
- elif not self.int & (0x2000 << 48L):
+ elif not self.int & (0x2000 << 48):
return RESERVED_MICROSOFT
else:
return RESERVED_FUTURE
- variant = property(get_variant)
-
- def get_version(self):
+ @property
+ def version(self):
# The version bits are only meaningful for RFC 4122 UUIDs.
if self.variant == RFC_4122:
- return int((self.int >> 76L) & 0xf)
-
- version = property(get_version)
+ return int((self.int >> 76) & 0xf)
def _find_mac(command, args, hw_identifiers, get_index):
import os
@@ -387,12 +407,13 @@ def _netbios_getnode():
continue
status._unpack()
bytes = map(ord, status.adapter_address)
- return ((bytes[0]<<40L) + (bytes[1]<<32L) + (bytes[2]<<24L) +
- (bytes[3]<<16L) + (bytes[4]<<8L) + bytes[5])
+ return ((bytes[0]<<40) + (bytes[1]<<32) + (bytes[2]<<24) +
+ (bytes[3]<<16) + (bytes[4]<<8) + bytes[5])
# Thanks to Thomas Heller for ctypes and for his help with its use here.
# If ctypes is available, use it to find system routines for UUID generation.
+# XXX This makes the module non-thread-safe!
_uuid_generate_random = _uuid_generate_time = _UuidCreate = None
try:
import ctypes, ctypes.util
@@ -443,18 +464,18 @@ def _unixdll_getnode():
"""Get the hardware address on Unix using ctypes."""
_buffer = ctypes.create_string_buffer(16)
_uuid_generate_time(_buffer)
- return UUID(bytes=_buffer.raw).node
+ return UUID(bytes=bytes_(_buffer.raw)).node
def _windll_getnode():
"""Get the hardware address on Windows using ctypes."""
_buffer = ctypes.create_string_buffer(16)
if _UuidCreate(_buffer) == 0:
- return UUID(bytes=_buffer.raw).node
+ return UUID(bytes=bytes_(_buffer.raw)).node
def _random_getnode():
"""Get a random node ID, with eighth bit set as suggested by RFC 4122."""
import random
- return random.randrange(0, 1<<48L) | 0x010000000000L
+ return random.randrange(0, 1<<48) | 0x010000000000
_node = None
@@ -498,25 +519,25 @@ def uuid1(node=None, clock_seq=None):
if _uuid_generate_time and node is clock_seq is None:
_buffer = ctypes.create_string_buffer(16)
_uuid_generate_time(_buffer)
- return UUID(bytes=_buffer.raw)
+ return UUID(bytes=bytes_(_buffer.raw))
global _last_timestamp
import time
nanoseconds = int(time.time() * 1e9)
# 0x01b21dd213814000 is the number of 100-ns intervals between the
# UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
- timestamp = int(nanoseconds//100) + 0x01b21dd213814000L
+ timestamp = int(nanoseconds/100) + 0x01b21dd213814000
if _last_timestamp is not None and timestamp <= _last_timestamp:
timestamp = _last_timestamp + 1
_last_timestamp = timestamp
if clock_seq is None:
import random
- clock_seq = random.randrange(1<<14L) # instead of stable storage
- time_low = timestamp & 0xffffffffL
- time_mid = (timestamp >> 32L) & 0xffffL
- time_hi_version = (timestamp >> 48L) & 0x0fffL
- clock_seq_low = clock_seq & 0xffL
- clock_seq_hi_variant = (clock_seq >> 8L) & 0x3fL
+ clock_seq = random.randrange(1<<14) # instead of stable storage
+ time_low = timestamp & 0xffffffff
+ time_mid = (timestamp >> 32) & 0xffff
+ time_hi_version = (timestamp >> 48) & 0x0fff
+ clock_seq_low = clock_seq & 0xff
+ clock_seq_hi_variant = (clock_seq >> 8) & 0x3f
if node is None:
node = getnode()
return UUID(fields=(time_low, time_mid, time_hi_version,
@@ -525,7 +546,7 @@ def uuid1(node=None, clock_seq=None):
def uuid3(namespace, name):
"""Generate a UUID from the MD5 hash of a namespace UUID and a name."""
from hashlib import md5
- hash = md5(namespace.bytes + name).digest()
+ hash = md5(namespace.bytes + bytes(name, "utf-8")).digest()
return UUID(bytes=hash[:16], version=3)
def uuid4():
@@ -535,7 +556,7 @@ def uuid4():
if _uuid_generate_random:
_buffer = ctypes.create_string_buffer(16)
_uuid_generate_random(_buffer)
- return UUID(bytes=_buffer.raw)
+ return UUID(bytes=bytes_(_buffer.raw))
# Otherwise, get randomness from urandom or the 'random' module.
try:
@@ -543,13 +564,13 @@ def uuid4():
return UUID(bytes=os.urandom(16), version=4)
except:
import random
- bytes = [chr(random.randrange(256)) for i in range(16)]
+ bytes = bytes_(random.randrange(256) for i in range(16))
return UUID(bytes=bytes, version=4)
def uuid5(namespace, name):
"""Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
from hashlib import sha1
- hash = sha1(namespace.bytes + name).digest()
+ hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest()
return UUID(bytes=hash[:16], version=5)
# The following standard UUIDs are for use with uuid3() or uuid5().
diff --git a/Lib/warnings.py b/Lib/warnings.py
index 08b70afbad7..edbbb5eda4f 100644
--- a/Lib/warnings.py
+++ b/Lib/warnings.py
@@ -5,23 +5,12 @@
# See bug 683658.
import linecache
import sys
-import types
__all__ = ["warn", "showwarning", "formatwarning", "filterwarnings",
"resetwarnings", "catch_warnings"]
-def warnpy3k(message, category=None, stacklevel=1):
- """Issue a deprecation warning for Python 3.x related changes.
-
- Warnings are omitted unless Python is started with the -3 option.
- """
- if sys.py3kwarning:
- if category is None:
- category = DeprecationWarning
- warn(message, category, stacklevel+1)
-
-def _show_warning(message, category, filename, lineno, file=None, line=None):
+def showwarning(message, category, filename, lineno, file=None, line=None):
"""Hook to write a warning to a file; replace if you like."""
if file is None:
file = sys.stderr
@@ -29,9 +18,6 @@ def _show_warning(message, category, filename, lineno, file=None, line=None):
file.write(formatwarning(message, category, filename, lineno, line))
except IOError:
pass # the file (probably stderr) is invalid - this warning gets lost.
-# Keep a working version around in case the deprecation of the old API is
-# triggered.
-showwarning = _show_warning
def formatwarning(message, category, filename, lineno, line=None):
"""Function to format a warning the standard way."""
@@ -43,7 +29,7 @@ def formatwarning(message, category, filename, lineno, line=None):
return s
def filterwarnings(action, message="", category=Warning, module="", lineno=0,
- append=0):
+ append=False):
"""Insert an entry into the list of warnings filters (at the front).
'action' -- one of "error", "ignore", "always", "default", "module",
@@ -57,11 +43,10 @@ def filterwarnings(action, message="", category=Warning, module="", lineno=0,
import re
assert action in ("error", "ignore", "always", "default", "module",
"once"), "invalid action: %r" % (action,)
- assert isinstance(message, basestring), "message must be a string"
- assert isinstance(category, (type, types.ClassType)), \
- "category must be a class"
+ assert isinstance(message, str), "message must be a string"
+ assert isinstance(category, type), "category must be a class"
assert issubclass(category, Warning), "category must be a Warning subclass"
- assert isinstance(module, basestring), "module must be a string"
+ assert isinstance(module, str), "module must be a string"
assert isinstance(lineno, int) and lineno >= 0, \
"lineno must be an int >= 0"
item = (action, re.compile(message, re.I), category,
@@ -71,7 +56,7 @@ def filterwarnings(action, message="", category=Warning, module="", lineno=0,
else:
filters.insert(0, item)
-def simplefilter(action, category=Warning, lineno=0, append=0):
+def simplefilter(action, category=Warning, lineno=0, append=False):
"""Insert a simple entry into the list of warnings filters (at the front).
A simple filter matches all modules and messages.
@@ -104,8 +89,8 @@ def _processoptions(args):
for arg in args:
try:
_setoption(arg)
- except _OptionError, msg:
- print >>sys.stderr, "Invalid -W option ignored:", msg
+ except _OptionError as msg:
+ print("Invalid -W option ignored:", msg, file=sys.stderr)
# Helper for _processoptions()
def _setoption(arg):
@@ -274,6 +259,9 @@ def warn_explicit(message, category, filename, lineno,
raise RuntimeError(
"Unrecognized action (%r) in warnings.filters:\n %s" %
(action, item))
+ if not callable(showwarning):
+ raise TypeError("warnings.showwarning() must be set to a "
+ "function or method")
# Print message and context
showwarning(message, category, filename, lineno)
@@ -315,7 +303,7 @@ class catch_warnings(object):
"""
- def __init__(self, record=False, module=None):
+ def __init__(self, *, record=False, module=None):
"""Specify whether to record warnings and if an alternative module
should be used other than sys.modules['warnings'].
@@ -369,10 +357,10 @@ class catch_warnings(object):
# If either if the compiled regexs are None, match anything.
_warnings_defaults = False
try:
- from _warnings import (filters, default_action, once_registry,
+ from _warnings import (filters, _defaultaction, _onceregistry,
warn, warn_explicit)
- defaultaction = default_action
- onceregistry = once_registry
+ defaultaction = _defaultaction
+ onceregistry = _onceregistry
_warnings_defaults = True
except ImportError:
filters = []
@@ -384,9 +372,7 @@ except ImportError:
_processoptions(sys.warnoptions)
if not _warnings_defaults:
silence = [ImportWarning, PendingDeprecationWarning]
- # Don't silence DeprecationWarning if -3 or -Q was used.
- if not sys.py3kwarning and not sys.flags.division_warning:
- silence.append(DeprecationWarning)
+ silence.append(DeprecationWarning)
for cls in silence:
simplefilter("ignore", category=cls)
bytes_warning = sys.flags.bytes_warning
@@ -397,4 +383,11 @@ if not _warnings_defaults:
else:
bytes_action = "ignore"
simplefilter(bytes_action, category=BytesWarning, append=1)
+ # resource usage warnings are enabled by default in pydebug mode
+ if hasattr(sys, 'gettotalrefcount'):
+ resource_action = "always"
+ else:
+ resource_action = "ignore"
+ simplefilter(resource_action, category=ResourceWarning, append=1)
+
del _warnings_defaults
diff --git a/Lib/wave.py b/Lib/wave.py
index 16b11dcfcd2..54f030267a8 100644
--- a/Lib/wave.py
+++ b/Lib/wave.py
@@ -71,7 +71,7 @@ The close() method is called automatically when the class instance
is destroyed.
"""
-import __builtin__
+import builtins
__all__ = ["open", "openfp", "Error"]
@@ -84,7 +84,7 @@ _array_fmts = None, 'b', 'h', None, 'l'
# Determine endian-ness
import struct
-if struct.pack("h", 1) == "\000\001":
+if struct.pack("h", 1) == b"\000\001":
big_endian = 1
else:
big_endian = 0
@@ -126,10 +126,10 @@ class Wave_read:
self._convert = None
self._soundpos = 0
self._file = Chunk(file, bigendian = 0)
- if self._file.getname() != 'RIFF':
- raise Error, 'file does not start with RIFF id'
- if self._file.read(4) != 'WAVE':
- raise Error, 'not a WAVE file'
+ if self._file.getname() != b'RIFF':
+ raise Error('file does not start with RIFF id')
+ if self._file.read(4) != b'WAVE':
+ raise Error('not a WAVE file')
self._fmt_chunk_read = 0
self._data_chunk = None
while 1:
@@ -139,24 +139,24 @@ class Wave_read:
except EOFError:
break
chunkname = chunk.getname()
- if chunkname == 'fmt ':
+ if chunkname == b'fmt ':
self._read_fmt_chunk(chunk)
self._fmt_chunk_read = 1
- elif chunkname == 'data':
+ elif chunkname == b'data':
if not self._fmt_chunk_read:
- raise Error, 'data chunk before fmt chunk'
+ raise Error('data chunk before fmt chunk')
self._data_chunk = chunk
self._nframes = chunk.chunksize // self._framesize
self._data_seek_needed = 0
break
chunk.skip()
if not self._fmt_chunk_read or not self._data_chunk:
- raise Error, 'fmt chunk and/or data chunk missing'
+ raise Error('fmt chunk and/or data chunk missing')
def __init__(self, f):
self._i_opened_the_file = None
- if isinstance(f, basestring):
- f = __builtin__.open(f, 'rb')
+ if isinstance(f, str):
+ f = builtins.open(f, 'rb')
self._i_opened_the_file = f
# else, assume it is an open file object already
try:
@@ -214,11 +214,11 @@ class Wave_read:
return None
def getmark(self, id):
- raise Error, 'no marks'
+ raise Error('no marks')
def setpos(self, pos):
if pos < 0 or pos > self._nframes:
- raise Error, 'position not in range'
+ raise Error('position not in range')
self._soundpos = pos
self._data_seek_needed = 1
@@ -230,7 +230,7 @@ class Wave_read:
self._data_chunk.seek(pos, 0)
self._data_seek_needed = 0
if nframes == 0:
- return ''
+ return b''
if self._sampwidth > 1 and big_endian:
# unfortunately the fromfile() method does not take
# something that only looks like a file object, so
@@ -240,7 +240,7 @@ class Wave_read:
data = array.array(_array_fmts[self._sampwidth])
nitems = nframes * self._nchannels
if nitems * self._sampwidth > chunk.chunksize - chunk.size_read:
- nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
+ nitems = (chunk.chunksize - chunk.size_read) // self._sampwidth
data.fromfile(chunk.file.file, nitems)
# "tell" data chunk how much was read
chunk.size_read = chunk.size_read + nitems * self._sampwidth
@@ -248,7 +248,7 @@ class Wave_read:
chunk = chunk.file
chunk.size_read = chunk.size_read + nitems * self._sampwidth
data.byteswap()
- data = data.tostring()
+ data = data.tobytes()
else:
data = self._data_chunk.read(nframes * self._framesize)
if self._convert and data:
@@ -261,12 +261,12 @@ class Wave_read:
#
def _read_fmt_chunk(self, chunk):
- wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack('<HHLLH', chunk.read(14))
+ wFormatTag, self._nchannels, self._framerate, dwAvgBytesPerSec, wBlockAlign = struct.unpack_from('<HHLLH', chunk.read(14))
if wFormatTag == WAVE_FORMAT_PCM:
- sampwidth = struct.unpack('<H', chunk.read(2))[0]
+ sampwidth = struct.unpack_from('<H', chunk.read(2))[0]
self._sampwidth = (sampwidth + 7) // 8
else:
- raise Error, 'unknown format: %r' % (wFormatTag,)
+ raise Error('unknown format: %r' % (wFormatTag,))
self._framesize = self._nchannels * self._sampwidth
self._comptype = 'NONE'
self._compname = 'not compressed'
@@ -299,8 +299,8 @@ class Wave_write:
def __init__(self, f):
self._i_opened_the_file = None
- if isinstance(f, basestring):
- f = __builtin__.open(f, 'wb')
+ if isinstance(f, str):
+ f = builtins.open(f, 'wb')
self._i_opened_the_file = f
try:
self.initfp(f)
@@ -329,43 +329,43 @@ class Wave_write:
#
def setnchannels(self, nchannels):
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if nchannels < 1:
- raise Error, 'bad # of channels'
+ raise Error('bad # of channels')
self._nchannels = nchannels
def getnchannels(self):
if not self._nchannels:
- raise Error, 'number of channels not set'
+ raise Error('number of channels not set')
return self._nchannels
def setsampwidth(self, sampwidth):
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if sampwidth < 1 or sampwidth > 4:
- raise Error, 'bad sample width'
+ raise Error('bad sample width')
self._sampwidth = sampwidth
def getsampwidth(self):
if not self._sampwidth:
- raise Error, 'sample width not set'
+ raise Error('sample width not set')
return self._sampwidth
def setframerate(self, framerate):
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if framerate <= 0:
- raise Error, 'bad frame rate'
- self._framerate = framerate
+ raise Error('bad frame rate')
+ self._framerate = int(round(framerate))
def getframerate(self):
if not self._framerate:
- raise Error, 'frame rate not set'
+ raise Error('frame rate not set')
return self._framerate
def setnframes(self, nframes):
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self._nframes = nframes
def getnframes(self):
@@ -373,9 +373,9 @@ class Wave_write:
def setcomptype(self, comptype, compname):
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
if comptype not in ('NONE',):
- raise Error, 'unsupported compression type'
+ raise Error('unsupported compression type')
self._comptype = comptype
self._compname = compname
@@ -388,7 +388,7 @@ class Wave_write:
def setparams(self, params):
nchannels, sampwidth, framerate, nframes, comptype, compname = params
if self._datawritten:
- raise Error, 'cannot change parameters after starting to write'
+ raise Error('cannot change parameters after starting to write')
self.setnchannels(nchannels)
self.setsampwidth(sampwidth)
self.setframerate(framerate)
@@ -397,15 +397,15 @@ class Wave_write:
def getparams(self):
if not self._nchannels or not self._sampwidth or not self._framerate:
- raise Error, 'not all parameters set'
+ raise Error('not all parameters set')
return self._nchannels, self._sampwidth, self._framerate, \
self._nframes, self._comptype, self._compname
def setmark(self, id, pos, name):
- raise Error, 'setmark() not supported'
+ raise Error('setmark() not supported')
def getmark(self, id):
- raise Error, 'no marks'
+ raise Error('no marks')
def getmarkers(self):
return None
@@ -452,26 +452,26 @@ class Wave_write:
def _ensure_header_written(self, datasize):
if not self._headerwritten:
if not self._nchannels:
- raise Error, '# channels not specified'
+ raise Error('# channels not specified')
if not self._sampwidth:
- raise Error, 'sample width not specified'
+ raise Error('sample width not specified')
if not self._framerate:
- raise Error, 'sampling rate not specified'
+ raise Error('sampling rate not specified')
self._write_header(datasize)
def _write_header(self, initlength):
assert not self._headerwritten
- self._file.write('RIFF')
+ self._file.write(b'RIFF')
if not self._nframes:
- self._nframes = initlength / (self._nchannels * self._sampwidth)
+ self._nframes = initlength // (self._nchannels * self._sampwidth)
self._datalength = self._nframes * self._nchannels * self._sampwidth
self._form_length_pos = self._file.tell()
self._file.write(struct.pack('<L4s4sLHHLLHH4s',
- 36 + self._datalength, 'WAVE', 'fmt ', 16,
+ 36 + self._datalength, b'WAVE', b'fmt ', 16,
WAVE_FORMAT_PCM, self._nchannels, self._framerate,
self._nchannels * self._framerate * self._sampwidth,
self._nchannels * self._sampwidth,
- self._sampwidth * 8, 'data'))
+ self._sampwidth * 8, b'data'))
self._data_length_pos = self._file.tell()
self._file.write(struct.pack('<L', self._datalength))
self._headerwritten = True
@@ -499,6 +499,6 @@ def open(f, mode=None):
elif mode in ('w', 'wb'):
return Wave_write(f)
else:
- raise Error, "mode must be 'r', 'rb', 'w', or 'wb'"
+ raise Error("mode must be 'r', 'rb', 'w', or 'wb'")
openfp = open # B/W compatibility
diff --git a/Lib/weakref.py b/Lib/weakref.py
index 88c60e71974..fcb6b74d1b1 100644
--- a/Lib/weakref.py
+++ b/Lib/weakref.py
@@ -9,8 +9,6 @@ http://www.python.org/dev/peps/pep-0205/
# they are called this instead of "ref" to avoid name collisions with
# the module-global ref() function imported from _weakref.
-import UserDict
-
from _weakref import (
getweakrefcount,
getweakrefs,
@@ -20,19 +18,19 @@ from _weakref import (
ProxyType,
ReferenceType)
-from _weakrefset import WeakSet
-
-from exceptions import ReferenceError
+from _weakrefset import WeakSet, _IterationGuard
+import collections # Import after _weakref to avoid circular import.
ProxyTypes = (ProxyType, CallableProxyType)
__all__ = ["ref", "proxy", "getweakrefcount", "getweakrefs",
- "WeakKeyDictionary", "ReferenceError", "ReferenceType", "ProxyType",
- "CallableProxyType", "ProxyTypes", "WeakValueDictionary", 'WeakSet']
+ "WeakKeyDictionary", "ReferenceType", "ProxyType",
+ "CallableProxyType", "ProxyTypes", "WeakValueDictionary",
+ "WeakSet"]
-class WeakValueDictionary(UserDict.UserDict):
+class WeakValueDictionary(collections.MutableMapping):
"""Mapping class that references values weakly.
Entries in the dictionary will be discarded when no strong
@@ -48,25 +46,41 @@ class WeakValueDictionary(UserDict.UserDict):
def remove(wr, selfref=ref(self)):
self = selfref()
if self is not None:
- del self.data[wr.key]
+ if self._iterating:
+ self._pending_removals.append(wr.key)
+ else:
+ del self.data[wr.key]
self._remove = remove
- UserDict.UserDict.__init__(self, *args, **kw)
+ # A list of keys to be removed
+ self._pending_removals = []
+ self._iterating = set()
+ self.data = d = {}
+ self.update(*args, **kw)
+
+ def _commit_removals(self):
+ l = self._pending_removals
+ d = self.data
+ # We shouldn't encounter any KeyError, because this method should
+ # always be called *before* mutating the dict.
+ while l:
+ del d[l.pop()]
def __getitem__(self, key):
o = self.data[key]()
if o is None:
- raise KeyError, key
+ raise KeyError(key)
else:
return o
- def __contains__(self, key):
- try:
- o = self.data[key]()
- except KeyError:
- return False
- return o is not None
+ def __delitem__(self, key):
+ if self._pending_removals:
+ self._commit_removals()
+ del self.data[key]
- def has_key(self, key):
+ def __len__(self):
+ return len(self.data) - len(self._pending_removals)
+
+ def __contains__(self, key):
try:
o = self.data[key]()
except KeyError:
@@ -77,6 +91,8 @@ class WeakValueDictionary(UserDict.UserDict):
return "<WeakValueDictionary at %s>" % id(self)
def __setitem__(self, key, value):
+ if self._pending_removals:
+ self._commit_removals()
self.data[key] = KeyedRef(value, self._remove, key)
def copy(self):
@@ -112,24 +128,19 @@ class WeakValueDictionary(UserDict.UserDict):
return o
def items(self):
- L = []
- for key, wr in self.data.items():
- o = wr()
- if o is not None:
- L.append((key, o))
- return L
-
- def iteritems(self):
- for wr in self.data.itervalues():
- value = wr()
- if value is not None:
- yield wr.key, value
+ with _IterationGuard(self):
+ for k, wr in self.data.items():
+ v = wr()
+ if v is not None:
+ yield k, v
- def iterkeys(self):
- return self.data.iterkeys()
+ def keys(self):
+ with _IterationGuard(self):
+ for k, wr in self.data.items():
+ if wr() is not None:
+ yield k
- def __iter__(self):
- return self.data.iterkeys()
+ __iter__ = keys
def itervaluerefs(self):
"""Return an iterator that yields the weak references to the values.
@@ -141,22 +152,29 @@ class WeakValueDictionary(UserDict.UserDict):
keep the values around longer than needed.
"""
- return self.data.itervalues()
+ with _IterationGuard(self):
+ for wr in self.data.values():
+ yield wr
- def itervalues(self):
- for wr in self.data.itervalues():
- obj = wr()
- if obj is not None:
- yield obj
+ def values(self):
+ with _IterationGuard(self):
+ for wr in self.data.values():
+ obj = wr()
+ if obj is not None:
+ yield obj
def popitem(self):
- while 1:
+ if self._pending_removals:
+ self._commit_removals()
+ while True:
key, wr = self.data.popitem()
o = wr()
if o is not None:
return key, o
def pop(self, key, *args):
+ if self._pending_removals:
+ self._commit_removals()
try:
o = self.data.pop(key)()
except KeyError:
@@ -164,7 +182,7 @@ class WeakValueDictionary(UserDict.UserDict):
return args[0]
raise
if o is None:
- raise KeyError, key
+ raise KeyError(key)
else:
return o
@@ -172,12 +190,16 @@ class WeakValueDictionary(UserDict.UserDict):
try:
wr = self.data[key]
except KeyError:
+ if self._pending_removals:
+ self._commit_removals()
self.data[key] = KeyedRef(default, self._remove, key)
return default
else:
return wr()
def update(self, dict=None, **kwargs):
+ if self._pending_removals:
+ self._commit_removals()
d = self.data
if dict is not None:
if not hasattr(dict, "items"):
@@ -197,15 +219,7 @@ class WeakValueDictionary(UserDict.UserDict):
keep the values around longer than needed.
"""
- return self.data.values()
-
- def values(self):
- L = []
- for wr in self.data.values():
- o = wr()
- if o is not None:
- L.append(o)
- return L
+ return list(self.data.values())
class KeyedRef(ref):
@@ -226,10 +240,10 @@ class KeyedRef(ref):
return self
def __init__(self, ob, callback, key):
- super(KeyedRef, self).__init__(ob, callback)
+ super().__init__(ob, callback)
-class WeakKeyDictionary(UserDict.UserDict):
+class WeakKeyDictionary(collections.MutableMapping):
""" Mapping class that references keys weakly.
Entries in the dictionary will be discarded when there is no
@@ -245,9 +259,29 @@ class WeakKeyDictionary(UserDict.UserDict):
def remove(k, selfref=ref(self)):
self = selfref()
if self is not None:
- del self.data[k]
+ if self._iterating:
+ self._pending_removals.append(k)
+ else:
+ del self.data[k]
self._remove = remove
- if dict is not None: self.update(dict)
+ # A list of dead weakrefs (keys to be removed)
+ self._pending_removals = []
+ self._iterating = set()
+ if dict is not None:
+ self.update(dict)
+
+ def _commit_removals(self):
+ # NOTE: We don't need to call this method before mutating the dict,
+ # because a dead weakref never compares equal to a live weakref,
+ # even if they happened to refer to equal objects.
+ # However, it means keys may already have been removed.
+ l = self._pending_removals
+ d = self.data
+ while l:
+ try:
+ del d[l.pop()]
+ except KeyError:
+ pass
def __delitem__(self, key):
del self.data[ref(key)]
@@ -255,6 +289,9 @@ class WeakKeyDictionary(UserDict.UserDict):
def __getitem__(self, key):
return self.data[ref(key)]
+ def __len__(self):
+ return len(self.data) - len(self._pending_removals)
+
def __repr__(self):
return "<WeakKeyDictionary at %s>" % id(self)
@@ -283,57 +320,34 @@ class WeakKeyDictionary(UserDict.UserDict):
def get(self, key, default=None):
return self.data.get(ref(key),default)
- def has_key(self, key):
- try:
- wr = ref(key)
- except TypeError:
- return 0
- return wr in self.data
-
def __contains__(self, key):
try:
wr = ref(key)
except TypeError:
- return 0
+ return False
return wr in self.data
def items(self):
- L = []
- for key, value in self.data.items():
- o = key()
- if o is not None:
- L.append((o, value))
- return L
-
- def iteritems(self):
- for wr, value in self.data.iteritems():
- key = wr()
- if key is not None:
- yield key, value
+ with _IterationGuard(self):
+ for wr, value in self.data.items():
+ key = wr()
+ if key is not None:
+ yield key, value
- def iterkeyrefs(self):
- """Return an iterator that yields the weak references to the keys.
-
- The references are not guaranteed to be 'live' at the time
- they are used, so the result of calling the references needs
- to be checked before being used. This can be used to avoid
- creating references that will cause the garbage collector to
- keep the keys around longer than needed.
-
- """
- return self.data.iterkeys()
-
- def iterkeys(self):
- for wr in self.data.iterkeys():
- obj = wr()
- if obj is not None:
- yield obj
+ def keys(self):
+ with _IterationGuard(self):
+ for wr in self.data:
+ obj = wr()
+ if obj is not None:
+ yield obj
- def __iter__(self):
- return self.iterkeys()
+ __iter__ = keys
- def itervalues(self):
- return self.data.itervalues()
+ def values(self):
+ with _IterationGuard(self):
+ for wr, value in self.data.items():
+ if wr() is not None:
+ yield value
def keyrefs(self):
"""Return a list of weak references to the keys.
@@ -345,18 +359,10 @@ class WeakKeyDictionary(UserDict.UserDict):
keep the keys around longer than needed.
"""
- return self.data.keys()
-
- def keys(self):
- L = []
- for wr in self.data.keys():
- o = wr()
- if o is not None:
- L.append(o)
- return L
+ return list(self.data)
def popitem(self):
- while 1:
+ while True:
key, value = self.data.popitem()
o = key()
if o is not None:
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
index f3c53d423cf..202f34a1a2e 100644
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -1,7 +1,8 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
"""Interfaces for launching and remotely controlling Web browsers."""
# Maintained by Georg Brandl.
+import io
import os
import shlex
import sys
@@ -159,7 +160,7 @@ class GenericBrowser(BaseBrowser):
and without remote functionality."""
def __init__(self, name):
- if isinstance(name, basestring):
+ if isinstance(name, str):
self.name = name
self.args = ["%s"]
else:
@@ -205,12 +206,18 @@ class UnixBrowser(BaseBrowser):
"""Parent class for all Unix browsers with remote functionality."""
raise_opts = None
+ background = False
+ redirect_stdout = True
+ # In remote_args, %s will be replaced with the requested URL. %action will
+ # be replaced depending on the value of 'new' passed to open.
+ # remote_action is used for new=0 (open). If newwin is not None, it is
+ # used for new=1 (open_new). If newtab is not None, it is used for
+ # new=3 (open_new_tab). After both substitutions are made, any empty
+ # strings in the transformed remote_args list will be removed.
remote_args = ['%action', '%s']
remote_action = None
remote_action_newwin = None
remote_action_newtab = None
- background = False
- redirect_stdout = True
def _invoke(self, args, remote, autoraise):
raise_opt = []
@@ -223,19 +230,13 @@ class UnixBrowser(BaseBrowser):
cmdline = [self.name] + raise_opt + args
if remote or self.background:
- inout = file(os.devnull, "r+")
+ inout = io.open(os.devnull, "r+")
else:
# for TTY browsers, we need stdin/out
inout = None
- # if possible, put browser in separate process group, so
- # keyboard interrupts don't affect browser as well as Python
- setsid = getattr(os, 'setsid', None)
- if not setsid:
- setsid = getattr(os, 'setpgrp', None)
-
p = subprocess.Popen(cmdline, close_fds=True, stdin=inout,
stdout=(self.redirect_stdout and inout or None),
- stderr=inout, preexec_fn=setsid)
+ stderr=inout, start_new_session=True)
if remote:
# wait five seconds. If the subprocess is not finished, the
# remote invocation has (hopefully) started a new instance.
@@ -272,6 +273,7 @@ class UnixBrowser(BaseBrowser):
args = [arg.replace("%s", url).replace("%action", action)
for arg in self.remote_args]
+ args = [arg for arg in args if arg]
success = self._invoke(args, True, autoraise)
if not success:
# remote invocation failed, try straight way
@@ -343,7 +345,7 @@ class Konqueror(BaseBrowser):
else:
action = "openURL"
- devnull = file(os.devnull, "r+")
+ devnull = io.open(os.devnull, "r+")
# if possible, put browser in separate process group, so
# keyboard interrupts don't affect browser as well as Python
setsid = getattr(os, 'setsid', None)
@@ -652,22 +654,22 @@ def main():
-t: open new tab""" % sys.argv[0]
try:
opts, args = getopt.getopt(sys.argv[1:], 'ntd')
- except getopt.error, msg:
- print >>sys.stderr, msg
- print >>sys.stderr, usage
+ except getopt.error as msg:
+ print(msg, file=sys.stderr)
+ print(usage, file=sys.stderr)
sys.exit(1)
new_win = 0
for o, a in opts:
if o == '-n': new_win = 1
elif o == '-t': new_win = 2
if len(args) != 1:
- print >>sys.stderr, usage
+ print(usage, file=sys.stderr)
sys.exit(1)
url = args[0]
open(url, new_win)
- print "\a"
+ print("\a")
if __name__ == "__main__":
main()
diff --git a/Lib/whichdb.py b/Lib/whichdb.py
deleted file mode 100644
index 9071430b154..00000000000
--- a/Lib/whichdb.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# !/usr/bin/env python
-"""Guess which db package to use to open a db file."""
-
-import os
-import struct
-import sys
-
-try:
- import dbm
- _dbmerror = dbm.error
-except ImportError:
- dbm = None
- # just some sort of valid exception which might be raised in the
- # dbm test
- _dbmerror = IOError
-
-def whichdb(filename):
- """Guess which db package to use to open a db file.
-
- Return values:
-
- - None if the database file can't be read;
- - empty string if the file can be read but can't be recognized
- - the module name (e.g. "dbm" or "gdbm") if recognized.
-
- Importing the given module may still fail, and opening the
- database using that module may still fail.
- """
-
- # Check for dbm first -- this has a .pag and a .dir file
- try:
- f = open(filename + os.extsep + "pag", "rb")
- f.close()
- # dbm linked with gdbm on OS/2 doesn't have .dir file
- if not (dbm.library == "GNU gdbm" and sys.platform == "os2emx"):
- f = open(filename + os.extsep + "dir", "rb")
- f.close()
- return "dbm"
- except IOError:
- # some dbm emulations based on Berkeley DB generate a .db file
- # some do not, but they should be caught by the dbhash checks
- try:
- f = open(filename + os.extsep + "db", "rb")
- f.close()
- # guarantee we can actually open the file using dbm
- # kind of overkill, but since we are dealing with emulations
- # it seems like a prudent step
- if dbm is not None:
- d = dbm.open(filename)
- d.close()
- return "dbm"
- except (IOError, _dbmerror):
- pass
-
- # Check for dumbdbm next -- this has a .dir and a .dat file
- try:
- # First check for presence of files
- os.stat(filename + os.extsep + "dat")
- size = os.stat(filename + os.extsep + "dir").st_size
- # dumbdbm files with no keys are empty
- if size == 0:
- return "dumbdbm"
- f = open(filename + os.extsep + "dir", "rb")
- try:
- if f.read(1) in ("'", '"'):
- return "dumbdbm"
- finally:
- f.close()
- except (OSError, IOError):
- pass
-
- # See if the file exists, return None if not
- try:
- f = open(filename, "rb")
- except IOError:
- return None
-
- # Read the start of the file -- the magic number
- s16 = f.read(16)
- f.close()
- s = s16[0:4]
-
- # Return "" if not at least 4 bytes
- if len(s) != 4:
- return ""
-
- # Convert to 4-byte int in native byte order -- return "" if impossible
- try:
- (magic,) = struct.unpack("=l", s)
- except struct.error:
- return ""
-
- # Check for GNU dbm
- if magic in (0x13579ace, 0x13579acd, 0x13579acf):
- return "gdbm"
-
- # Check for old Berkeley db hash file format v2
- if magic in (0x00061561, 0x61150600):
- return "bsddb185"
-
- # Later versions of Berkeley db hash file have a 12-byte pad in
- # front of the file type
- try:
- (magic,) = struct.unpack("=l", s16[-4:])
- except struct.error:
- return ""
-
- # Check for BSD hash
- if magic in (0x00061561, 0x61150600):
- return "dbhash"
-
- # Unknown
- return ""
-
-if __name__ == "__main__":
- for filename in sys.argv[1:]:
- print whichdb(filename) or "UNKNOWN", filename
diff --git a/Lib/wsgiref/handlers.py b/Lib/wsgiref/handlers.py
index 8cb57e223aa..63d5993eca0 100644
--- a/Lib/wsgiref/handlers.py
+++ b/Lib/wsgiref/handlers.py
@@ -1,30 +1,14 @@
"""Base classes for server/gateway implementations"""
-from types import StringType
-from util import FileWrapper, guess_scheme, is_hop_by_hop
-from headers import Headers
+from .util import FileWrapper, guess_scheme, is_hop_by_hop
+from .headers import Headers
import sys, os, time
-__all__ = ['BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler']
-
-try:
- dict
-except NameError:
- def dict(items):
- d = {}
- for k,v in items:
- d[k] = v
- return d
-
-# Uncomment for 2.2 compatibility.
-#try:
-# True
-# False
-#except NameError:
-# True = not None
-# False = not True
-
+__all__ = [
+ 'BaseHandler', 'SimpleHandler', 'BaseCGIHandler', 'CGIHandler',
+ 'IISCGIHandler', 'read_environ'
+]
# Weekday and month names for HTTP date/time formatting; always English!
_weekdayname = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
@@ -38,6 +22,74 @@ def format_date_time(timestamp):
_weekdayname[wd], day, _monthname[month], year, hh, mm, ss
)
+_is_request = {
+ 'SCRIPT_NAME', 'PATH_INFO', 'QUERY_STRING', 'REQUEST_METHOD', 'AUTH_TYPE',
+ 'CONTENT_TYPE', 'CONTENT_LENGTH', 'HTTPS', 'REMOTE_USER', 'REMOTE_IDENT',
+}.__contains__
+
+def _needs_transcode(k):
+ return _is_request(k) or k.startswith('HTTP_') or k.startswith('SSL_') \
+ or (k.startswith('REDIRECT_') and _needs_transcode(k[9:]))
+
+def read_environ():
+ """Read environment, fixing HTTP variables"""
+ enc = sys.getfilesystemencoding()
+ esc = 'surrogateescape'
+ try:
+ ''.encode('utf-8', esc)
+ except LookupError:
+ esc = 'replace'
+ environ = {}
+
+ # Take the basic environment from native-unicode os.environ. Attempt to
+ # fix up the variables that come from the HTTP request to compensate for
+ # the bytes->unicode decoding step that will already have taken place.
+ for k, v in os.environ.items():
+ if _needs_transcode(k):
+
+ # On win32, the os.environ is natively Unicode. Different servers
+ # decode the request bytes using different encodings.
+ if sys.platform == 'win32':
+ software = os.environ.get('SERVER_SOFTWARE', '').lower()
+
+ # On IIS, the HTTP request will be decoded as UTF-8 as long
+ # as the input is a valid UTF-8 sequence. Otherwise it is
+ # decoded using the system code page (mbcs), with no way to
+ # detect this has happened. Because UTF-8 is the more likely
+ # encoding, and mbcs is inherently unreliable (an mbcs string
+ # that happens to be valid UTF-8 will not be decoded as mbcs)
+ # always recreate the original bytes as UTF-8.
+ if software.startswith('microsoft-iis/'):
+ v = v.encode('utf-8').decode('iso-8859-1')
+
+ # Apache mod_cgi writes bytes-as-unicode (as if ISO-8859-1) direct
+ # to the Unicode environ. No modification needed.
+ elif software.startswith('apache/'):
+ pass
+
+ # Python 3's http.server.CGIHTTPRequestHandler decodes
+ # using the urllib.unquote default of UTF-8, amongst other
+ # issues.
+ elif (
+ software.startswith('simplehttp/')
+ and 'python/3' in software
+ ):
+ v = v.encode('utf-8').decode('iso-8859-1')
+
+ # For other servers, guess that they have written bytes to
+ # the environ using stdio byte-oriented interfaces, ending up
+ # with the system code page.
+ else:
+ v = v.encode(enc, 'replace').decode('iso-8859-1')
+
+ # Recover bytes from unicode environ, using surrogate escapes
+ # where available (Python 3.1+).
+ else:
+ v = v.encode(enc, esc).decode('iso-8859-1')
+
+ environ[k] = v
+ return environ
+
class BaseHandler:
"""Manage the invocation of a WSGI application"""
@@ -55,7 +107,7 @@ class BaseHandler:
# os_environ is used to supply configuration from the OS environment:
# by default it's a copy of 'os.environ' as of import time, but you can
# override this in e.g. your __init__ method.
- os_environ = dict(os.environ.items())
+ os_environ= read_environ()
# Collaborator classes
wsgi_file_wrapper = FileWrapper # set to None to disable
@@ -65,7 +117,7 @@ class BaseHandler:
traceback_limit = None # Print entire traceback to self.get_stderr()
error_status = "500 Internal Server Error"
error_headers = [('Content-Type','text/plain')]
- error_body = "A server error occurred. Please contact the administrator."
+ error_body = b"A server error occurred. Please contact the administrator."
# State variables (don't mess with these)
status = result = None
@@ -158,50 +210,60 @@ class BaseHandler:
self.set_content_length()
def start_response(self, status, headers,exc_info=None):
- """'start_response()' callable as specified by PEP 333"""
+ """'start_response()' callable as specified by PEP 3333"""
if exc_info:
try:
if self.headers_sent:
# Re-raise original exception if headers sent
- raise exc_info[0], exc_info[1], exc_info[2]
+ raise exc_info[0](exc_info[1]).with_traceback(exc_info[2])
finally:
exc_info = None # avoid dangling circular ref
elif self.headers is not None:
raise AssertionError("Headers already set!")
- assert type(status) is StringType,"Status must be a string"
+ self.status = status
+ self.headers = self.headers_class(headers)
+ status = self._convert_string_type(status, "Status")
assert len(status)>=4,"Status must be at least 4 characters"
assert int(status[:3]),"Status message must begin w/3-digit code"
assert status[3]==" ", "Status message must have a space after code"
+
if __debug__:
- for name,val in headers:
- assert type(name) is StringType,"Header names must be strings"
- assert type(val) is StringType,"Header values must be strings"
+ for name, val in headers:
+ name = self._convert_string_type(name, "Header name")
+ val = self._convert_string_type(val, "Header value")
assert not is_hop_by_hop(name),"Hop-by-hop headers not allowed"
- self.status = status
- self.headers = self.headers_class(headers)
+
return self.write
+ def _convert_string_type(self, value, title):
+ """Convert/check value type."""
+ if type(value) is str:
+ return value
+ raise AssertionError(
+ "{0} must be of type str (got {1})".format(title, repr(value))
+ )
def send_preamble(self):
"""Transmit version/status/date/server, via self._write()"""
if self.origin_server:
if self.client_is_modern():
- self._write('HTTP/%s %s\r\n' % (self.http_version,self.status))
+ self._write(('HTTP/%s %s\r\n' % (self.http_version,self.status)).encode('iso-8859-1'))
if 'Date' not in self.headers:
self._write(
- 'Date: %s\r\n' % format_date_time(time.time())
+ ('Date: %s\r\n' % format_date_time(time.time())).encode('iso-8859-1')
)
if self.server_software and 'Server' not in self.headers:
- self._write('Server: %s\r\n' % self.server_software)
+ self._write(('Server: %s\r\n' % self.server_software).encode('iso-8859-1'))
else:
- self._write('Status: %s\r\n' % self.status)
+ self._write(('Status: %s\r\n' % self.status).encode('iso-8859-1'))
def write(self, data):
- """'write()' callable as specified by PEP 333"""
+ """'write()' callable as specified by PEP 3333"""
- assert type(data) is StringType,"write() argument must be string"
+ assert type(data) is bytes, \
+ "write() argument must be a bytes instance"
if not self.status:
raise AssertionError("write() before start_response()")
@@ -268,7 +330,7 @@ class BaseHandler:
self.headers_sent = True
if not self.origin_server or self.client_is_modern():
self.send_preamble()
- self._write(str(self.headers))
+ self._write(bytes(self.headers))
def result_is_file(self):
@@ -389,7 +451,6 @@ class SimpleHandler(BaseHandler):
def _write(self,data):
self.stdout.write(data)
- self._write = self.stdout.write
def _flush(self):
self.stdout.flush()
@@ -445,6 +506,42 @@ class CGIHandler(BaseCGIHandler):
def __init__(self):
BaseCGIHandler.__init__(
- self, sys.stdin, sys.stdout, sys.stderr, dict(os.environ.items()),
- multithread=False, multiprocess=True
+ self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
+ read_environ(), multithread=False, multiprocess=True
+ )
+
+
+class IISCGIHandler(BaseCGIHandler):
+ """CGI-based invocation with workaround for IIS path bug
+
+ This handler should be used in preference to CGIHandler when deploying on
+ Microsoft IIS without having set the config allowPathInfo option (IIS>=7)
+ or metabase allowPathInfoForScriptMappings (IIS<7).
+ """
+ wsgi_run_once = True
+ os_environ = {}
+
+ # By default, IIS gives a PATH_INFO that duplicates the SCRIPT_NAME at
+ # the front, causing problems for WSGI applications that wish to implement
+ # routing. This handler strips any such duplicated path.
+
+ # IIS can be configured to pass the correct PATH_INFO, but this causes
+ # another bug where PATH_TRANSLATED is wrong. Luckily this variable is
+ # rarely used and is not guaranteed by WSGI. On IIS<7, though, the
+ # setting can only be made on a vhost level, affecting all other script
+ # mappings, many of which break when exposed to the PATH_TRANSLATED bug.
+ # For this reason IIS<7 is almost never deployed with the fix. (Even IIS7
+ # rarely uses it because there is still no UI for it.)
+
+ # There is no way for CGI code to tell whether the option was set, so a
+ # separate handler class is provided.
+ def __init__(self):
+ environ= read_environ()
+ path = environ.get('PATH_INFO', '')
+ script = environ.get('SCRIPT_NAME', '')
+ if (path+'/').startswith(script+'/'):
+ environ['PATH_INFO'] = path[len(script):]
+ BaseCGIHandler.__init__(
+ self, sys.stdin.buffer, sys.stdout.buffer, sys.stderr,
+ environ, multithread=False, multiprocess=True
)
diff --git a/Lib/wsgiref/headers.py b/Lib/wsgiref/headers.py
index 6c8c60c8913..d93962831ae 100644
--- a/Lib/wsgiref/headers.py
+++ b/Lib/wsgiref/headers.py
@@ -5,8 +5,6 @@ so portions are Copyright (C) 2001,2002 Python Software Foundation, and were
written by Barry Warsaw.
"""
-from types import ListType, TupleType
-
# Regular expression that matches `special' characters in parameters, the
# existence of which force quoting of the parameter value.
import re
@@ -32,9 +30,20 @@ class Headers:
"""Manage a collection of HTTP response headers"""
def __init__(self,headers):
- if type(headers) is not ListType:
+ if type(headers) is not list:
raise TypeError("Headers must be a list of name/value tuples")
self._headers = headers
+ if __debug__:
+ for k, v in headers:
+ self._convert_string_type(k)
+ self._convert_string_type(v)
+
+ def _convert_string_type(self, value):
+ """Convert/check value type."""
+ if type(value) is str:
+ return value
+ raise AssertionError("Header names/values must be"
+ " of type str (got {0})".format(repr(value)))
def __len__(self):
"""Return the total number of headers, including duplicates."""
@@ -43,14 +52,15 @@ class Headers:
def __setitem__(self, name, val):
"""Set the value of a header."""
del self[name]
- self._headers.append((name, val))
+ self._headers.append(
+ (self._convert_string_type(name), self._convert_string_type(val)))
def __delitem__(self,name):
"""Delete all occurrences of a header, if present.
Does *not* raise an exception if the header is missing.
"""
- name = name.lower()
+ name = self._convert_string_type(name.lower())
self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name]
def __getitem__(self,name):
@@ -64,12 +74,10 @@ class Headers:
"""
return self.get(name)
- def has_key(self, name):
+ def __contains__(self, name):
"""Return true if the message contains the header."""
return self.get(name) is not None
- __contains__ = has_key
-
def get_all(self, name):
"""Return a list of all the values for the named field.
@@ -79,13 +87,13 @@ class Headers:
fields deleted and re-inserted are always appended to the header list.
If no fields exist with the given name, returns an empty list.
"""
- name = name.lower()
+ name = self._convert_string_type(name.lower())
return [kv[1] for kv in self._headers if kv[0].lower()==name]
def get(self,name,default=None):
"""Get the first header value for 'name', or return 'default'"""
- name = name.lower()
+ name = self._convert_string_type(name.lower())
for k,v in self._headers:
if k.lower()==name:
return v
@@ -130,6 +138,9 @@ class Headers:
suitable for direct HTTP transmission."""
return '\r\n'.join(["%s: %s" % kv for kv in self._headers]+['',''])
+ def __bytes__(self):
+ return str(self).encode('iso-8859-1')
+
def setdefault(self,name,value):
"""Return first matching header value for 'name', or 'value'
@@ -137,7 +148,8 @@ class Headers:
and value 'value'."""
result = self.get(name)
if result is None:
- self._headers.append((name,value))
+ self._headers.append((self._convert_string_type(name),
+ self._convert_string_type(value)))
return value
else:
return result
@@ -160,10 +172,13 @@ class Headers:
"""
parts = []
if _value is not None:
+ _value = self._convert_string_type(_value)
parts.append(_value)
for k, v in _params.items():
+ k = self._convert_string_type(k)
if v is None:
parts.append(k.replace('_', '-'))
else:
+ v = self._convert_string_type(v)
parts.append(_formatparam(k.replace('_', '-'), v))
- self._headers.append((_name, "; ".join(parts)))
+ self._headers.append((self._convert_string_type(_name), "; ".join(parts)))
diff --git a/Lib/wsgiref/simple_server.py b/Lib/wsgiref/simple_server.py
index e6a385b03c7..af82f953c53 100644
--- a/Lib/wsgiref/simple_server.py
+++ b/Lib/wsgiref/simple_server.py
@@ -1,4 +1,4 @@
-"""BaseHTTPServer that implements the Python WSGI protocol (PEP 333, rev 1.21)
+"""BaseHTTPServer that implements the Python WSGI protocol (PEP 3333)
This is both an example of how WSGI can be implemented, and a basis for running
simple web applications on a local machine, such as might be done when testing
@@ -10,11 +10,12 @@ For example usage, see the 'if __name__=="__main__"' block at the end of the
module. See also the BaseHTTPServer module docs for other API information.
"""
-from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
-import urllib, sys
+from http.server import BaseHTTPRequestHandler, HTTPServer
+import sys
+import urllib.parse
from wsgiref.handlers import SimpleHandler
-__version__ = "0.1"
+__version__ = "0.2"
__all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']
@@ -73,13 +74,14 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
def get_environ(self):
env = self.server.base_environ.copy()
env['SERVER_PROTOCOL'] = self.request_version
+ env['SERVER_SOFTWARE'] = self.server_version
env['REQUEST_METHOD'] = self.command
if '?' in self.path:
path,query = self.path.split('?',1)
else:
path,query = self.path,''
- env['PATH_INFO'] = urllib.unquote(path)
+ env['PATH_INFO'] = urllib.parse.unquote_to_bytes(path).decode('iso-8859-1')
env['QUERY_STRING'] = query
host = self.address_string()
@@ -87,17 +89,16 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
env['REMOTE_HOST'] = host
env['REMOTE_ADDR'] = self.client_address[0]
- if self.headers.typeheader is None:
- env['CONTENT_TYPE'] = self.headers.type
+ if self.headers.get('content-type') is None:
+ env['CONTENT_TYPE'] = self.headers.get_content_type()
else:
- env['CONTENT_TYPE'] = self.headers.typeheader
+ env['CONTENT_TYPE'] = self.headers['content-type']
- length = self.headers.getheader('content-length')
+ length = self.headers.get('content-length')
if length:
env['CONTENT_LENGTH'] = length
- for h in self.headers.headers:
- k,v = h.split(':',1)
+ for k, v in self.headers.items():
k=k.replace('-','_').upper(); v=v.strip()
if k in env:
continue # skip content length, type,etc.
@@ -126,15 +127,15 @@ class WSGIRequestHandler(BaseHTTPRequestHandler):
def demo_app(environ,start_response):
- from StringIO import StringIO
+ from io import StringIO
stdout = StringIO()
- print >>stdout, "Hello world!"
- print >>stdout
- h = environ.items(); h.sort()
+ print("Hello world!", file=stdout)
+ print(file=stdout)
+ h = sorted(environ.items())
for k,v in h:
- print >>stdout, k,'=', repr(v)
- start_response("200 OK", [('Content-Type','text/plain')])
- return [stdout.getvalue()]
+ print(k,'=',repr(v), file=stdout)
+ start_response("200 OK", [('Content-Type','text/plain; charset=utf-8')])
+ return [stdout.getvalue().encode("utf-8")]
def make_server(
@@ -149,7 +150,7 @@ def make_server(
if __name__ == '__main__':
httpd = make_server('', 8000, demo_app)
sa = httpd.socket.getsockname()
- print "Serving HTTP on", sa[0], "port", sa[1], "..."
+ print("Serving HTTP on", sa[0], "port", sa[1], "...")
import webbrowser
webbrowser.open('http://localhost:8000/xyz?abc')
httpd.handle_request() # serve one request, then exit
diff --git a/Lib/wsgiref/util.py b/Lib/wsgiref/util.py
index 194b187a4dc..1f1e6cce179 100644
--- a/Lib/wsgiref/util.py
+++ b/Lib/wsgiref/util.py
@@ -26,7 +26,7 @@ class FileWrapper:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
data = self.filelike.read(self.blksize)
if data:
return data
@@ -43,7 +43,7 @@ def guess_scheme(environ):
def application_uri(environ):
"""Return the application's base URI (no PATH_INFO or QUERY_STRING)"""
url = environ['wsgi.url_scheme']+'://'
- from urllib import quote
+ from urllib.parse import quote
if environ.get('HTTP_HOST'):
url += environ['HTTP_HOST']
@@ -60,10 +60,10 @@ def application_uri(environ):
url += quote(environ.get('SCRIPT_NAME') or '/')
return url
-def request_uri(environ, include_query=1):
+def request_uri(environ, include_query=True):
"""Return the full request URI, optionally including the query string"""
url = application_uri(environ)
- from urllib import quote
+ from urllib.parse import quote
path_info = quote(environ.get('PATH_INFO',''),safe='/;=,')
if not environ.get('SCRIPT_NAME'):
url += path_info[1:]
@@ -142,8 +142,8 @@ def setup_testing_defaults(environ):
environ.setdefault('wsgi.multithread', 0)
environ.setdefault('wsgi.multiprocess', 0)
- from StringIO import StringIO
- environ.setdefault('wsgi.input', StringIO(""))
+ from io import StringIO, BytesIO
+ environ.setdefault('wsgi.input', BytesIO())
environ.setdefault('wsgi.errors', StringIO())
environ.setdefault('wsgi.url_scheme',guess_scheme(environ))
diff --git a/Lib/wsgiref/validate.py b/Lib/wsgiref/validate.py
index 04a893d7c61..49eaa514cc5 100644
--- a/Lib/wsgiref/validate.py
+++ b/Lib/wsgiref/validate.py
@@ -98,7 +98,7 @@ Some of the things this checks:
- That it is not a string (it should be a list of a single string; a
string will work, but perform horribly).
- - That .next() returns a string
+ - That .__next__() returns a string
- That the iterator is not iterated over until start_response has
been called (that can signal either a server or application
@@ -113,7 +113,6 @@ __all__ = ['validator']
import re
import sys
-from types import DictType, StringType, TupleType, ListType
import warnings
header_re = re.compile(r'^[a-zA-Z][a-zA-Z0-9\-_]*$')
@@ -128,6 +127,12 @@ def assert_(cond, *args):
if not cond:
raise AssertionError(*args)
+def check_string_type(value, title):
+ if type (value) is str:
+ return value
+ raise AssertionError(
+ "{0} must be of type str (got {1})".format(title, repr(value)))
+
def validator(application):
"""
@@ -189,22 +194,23 @@ class InputWrapper:
self.input = wsgi_input
def read(self, *args):
- assert_(len(args) <= 1)
+ assert_(len(args) == 1)
v = self.input.read(*args)
- assert_(type(v) is type(""))
+ assert_(type(v) is bytes)
return v
- def readline(self):
- v = self.input.readline()
- assert_(type(v) is type(""))
+ def readline(self, *args):
+ assert_(len(args) <= 1)
+ v = self.input.readline(*args)
+ assert_(type(v) is bytes)
return v
def readlines(self, *args):
assert_(len(args) <= 1)
lines = self.input.readlines(*args)
- assert_(type(lines) is type([]))
+ assert_(type(lines) is list)
for line in lines:
- assert_(type(line) is type(""))
+ assert_(type(line) is bytes)
return lines
def __iter__(self):
@@ -223,7 +229,7 @@ class ErrorWrapper:
self.errors = wsgi_errors
def write(self, s):
- assert_(type(s) is type(""))
+ assert_(type(s) is str)
self.errors.write(s)
def flush(self):
@@ -242,7 +248,7 @@ class WriteWrapper:
self.writer = wsgi_writer
def __call__(self, s):
- assert_(type(s) is type(""))
+ assert_(type(s) is bytes)
self.writer(s)
class PartialIteratorWrapper:
@@ -265,10 +271,12 @@ class IteratorWrapper:
def __iter__(self):
return self
- def next(self):
+ def __next__(self):
assert_(not self.closed,
"Iterator read after closed")
- v = self.iterator.next()
+ v = next(self.iterator)
+ if type(v) is not bytes:
+ assert_(False, "Iterator yielded non-bytestring (%r)" % (v,))
if self.check_start_response is not None:
assert_(self.check_start_response,
"The application returns and we started iterating over its body, but start_response has not yet been called")
@@ -288,7 +296,7 @@ class IteratorWrapper:
"Iterator garbage collected without being closed")
def check_environ(environ):
- assert_(type(environ) is DictType,
+ assert_(type(environ) is dict,
"Environment is not of the right type: %r (environment: %r)"
% (type(environ), environ))
@@ -315,11 +323,11 @@ def check_environ(environ):
if '.' in key:
# Extension, we don't care about its type
continue
- assert_(type(environ[key]) is StringType,
+ assert_(type(environ[key]) is str,
"Environmental variable %s is not a string: %r (value: %r)"
% (key, type(environ[key]), environ[key]))
- assert_(type(environ['wsgi.version']) is TupleType,
+ assert_(type(environ['wsgi.version']) is tuple,
"wsgi.version should be a tuple (%r)" % (environ['wsgi.version'],))
assert_(environ['wsgi.url_scheme'] in ('http', 'https'),
"wsgi.url_scheme unknown: %r" % environ['wsgi.url_scheme'])
@@ -365,8 +373,7 @@ def check_errors(wsgi_errors):
% (wsgi_errors, attr))
def check_status(status):
- assert_(type(status) is StringType,
- "Status must be a string (not %r)" % status)
+ status = check_string_type(status, "Status")
# Implicitly check that we can turn it into an integer:
status_code = status.split(None, 1)[0]
assert_(len(status_code) == 3,
@@ -380,16 +387,18 @@ def check_status(status):
% status, WSGIWarning)
def check_headers(headers):
- assert_(type(headers) is ListType,
+ assert_(type(headers) is list,
"Headers (%r) must be of type list: %r"
% (headers, type(headers)))
header_names = {}
for item in headers:
- assert_(type(item) is TupleType,
+ assert_(type(item) is tuple,
"Individual headers (%r) must be of type tuple: %r"
% (item, type(item)))
assert_(len(item) == 2)
name, value = item
+ name = check_string_type(name, "Header name")
+ value = check_string_type(value, "Header value")
assert_(name.lower() != 'status',
"The Status header cannot be used; it conflicts with CGI "
"script, and HTTP status is not given through headers "
@@ -405,11 +414,13 @@ def check_headers(headers):
% (value, bad_header_value_re.search(value).group(0)))
def check_content_type(status, headers):
+ status = check_string_type(status, "Status")
code = int(status.split(None, 1)[0])
# @@: need one more person to verify this interpretation of RFC 2616
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
NO_MESSAGE_BODY = (204, 304)
for name, value in headers:
+ name = check_string_type(name, "Header name")
if name.lower() == 'content-type':
if code not in NO_MESSAGE_BODY:
return
@@ -419,14 +430,14 @@ def check_content_type(status, headers):
assert_(0, "No Content-Type header found in headers (%s)" % headers)
def check_exc_info(exc_info):
- assert_(exc_info is None or type(exc_info) is type(()),
+ assert_(exc_info is None or type(exc_info) is tuple,
"exc_info (%r) is not a tuple: %r" % (exc_info, type(exc_info)))
# More exc_info checks?
def check_iterator(iterator):
- # Technically a string is legal, which is why it's a really bad
+ # Technically a bytestring is legal, which is why it's a really bad
# idea, because it may cause the response to be returned
# character-by-character
- assert_(not isinstance(iterator, str),
+ assert_(not isinstance(iterator, (str, bytes)),
"You should not return a string as your application iterator, "
- "instead return a single-item list containing that string.")
+ "instead return a single-item list containing a bytestring.")
diff --git a/Lib/xdrlib.py b/Lib/xdrlib.py
index ef172dd37d6..29639159cb8 100644
--- a/Lib/xdrlib.py
+++ b/Lib/xdrlib.py
@@ -5,10 +5,7 @@ See: RFC 1014
"""
import struct
-try:
- from cStringIO import StringIO as _StringIO
-except ImportError:
- from StringIO import StringIO as _StringIO
+from io import BytesIO
__all__ = ["Error", "Packer", "Unpacker", "ConversionError"]
@@ -16,7 +13,7 @@ __all__ = ["Error", "Packer", "Unpacker", "ConversionError"]
class Error(Exception):
"""Exception class for this module. Use:
- except xdrlib.Error, var:
+ except xdrlib.Error as var:
# var has the Error instance for the exception
Public ivars:
@@ -43,7 +40,7 @@ class Packer:
self.reset()
def reset(self):
- self.__buf = _StringIO()
+ self.__buf = BytesIO()
def get_buffer(self):
return self.__buf.getvalue()
@@ -59,31 +56,31 @@ class Packer:
pack_enum = pack_int
def pack_bool(self, x):
- if x: self.__buf.write('\0\0\0\1')
- else: self.__buf.write('\0\0\0\0')
+ if x: self.__buf.write(b'\0\0\0\1')
+ else: self.__buf.write(b'\0\0\0\0')
def pack_uhyper(self, x):
- self.pack_uint(x>>32 & 0xffffffffL)
- self.pack_uint(x & 0xffffffffL)
+ self.pack_uint(x>>32 & 0xffffffff)
+ self.pack_uint(x & 0xffffffff)
pack_hyper = pack_uhyper
def pack_float(self, x):
try: self.__buf.write(struct.pack('>f', x))
- except struct.error, msg:
- raise ConversionError, msg
+ except struct.error as msg:
+ raise ConversionError(msg)
def pack_double(self, x):
try: self.__buf.write(struct.pack('>d', x))
- except struct.error, msg:
- raise ConversionError, msg
+ except struct.error as msg:
+ raise ConversionError(msg)
def pack_fstring(self, n, s):
if n < 0:
- raise ValueError, 'fstring size must be nonnegative'
+ raise ValueError('fstring size must be nonnegative')
data = s[:n]
n = ((n+3)//4)*4
- data = data + (n - len(data)) * '\0'
+ data = data + (n - len(data)) * b'\0'
self.__buf.write(data)
pack_fopaque = pack_fstring
@@ -104,7 +101,7 @@ class Packer:
def pack_farray(self, n, list, pack_item):
if len(list) != n:
- raise ValueError, 'wrong array size'
+ raise ValueError('wrong array size')
for item in list:
pack_item(item)
@@ -166,12 +163,12 @@ class Unpacker:
def unpack_uhyper(self):
hi = self.unpack_uint()
lo = self.unpack_uint()
- return long(hi)<<32 | lo
+ return int(hi)<<32 | lo
def unpack_hyper(self):
x = self.unpack_uhyper()
- if x >= 0x8000000000000000L:
- x = x - 0x10000000000000000L
+ if x >= 0x8000000000000000:
+ x = x - 0x10000000000000000
return x
def unpack_float(self):
@@ -192,7 +189,7 @@ class Unpacker:
def unpack_fstring(self, n):
if n < 0:
- raise ValueError, 'fstring size must be nonnegative'
+ raise ValueError('fstring size must be nonnegative')
i = self.__pos
j = i + (n+3)//4*4
if j > len(self.__buf):
@@ -215,7 +212,7 @@ class Unpacker:
x = self.unpack_uint()
if x == 0: break
if x != 1:
- raise ConversionError, '0 or 1 expected, got %r' % (x,)
+ raise ConversionError('0 or 1 expected, got %r' % (x,))
item = unpack_item()
list.append(item)
return list
diff --git a/Lib/xml/__init__.py b/Lib/xml/__init__.py
index deed983d976..bf6d8ddfd04 100644
--- a/Lib/xml/__init__.py
+++ b/Lib/xml/__init__.py
@@ -18,24 +18,3 @@ etree -- The ElementTree XML library. This is a subset of the full
__all__ = ["dom", "parsers", "sax", "etree"]
-
-_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
-
-
-try:
- import _xmlplus
-except ImportError:
- pass
-else:
- try:
- v = _xmlplus.version_info
- except AttributeError:
- # _xmlplus is too old; ignore it
- pass
- else:
- if v >= _MINIMUM_XMLPLUS_VERSION:
- import sys
- _xmlplus.__path__.extend(__path__)
- sys.modules[__name__] = _xmlplus
- else:
- del v
diff --git a/Lib/xml/dom/NodeFilter.py b/Lib/xml/dom/NodeFilter.py
index fc052459da4..640e0bfd246 100644
--- a/Lib/xml/dom/NodeFilter.py
+++ b/Lib/xml/dom/NodeFilter.py
@@ -9,7 +9,7 @@ class NodeFilter:
FILTER_REJECT = 2
FILTER_SKIP = 3
- SHOW_ALL = 0xFFFFFFFFL
+ SHOW_ALL = 0xFFFFFFFF
SHOW_ELEMENT = 0x00000001
SHOW_ATTRIBUTE = 0x00000002
SHOW_TEXT = 0x00000004
diff --git a/Lib/xml/dom/__init__.py b/Lib/xml/dom/__init__.py
index 6363d00630d..4401bdfcf33 100644
--- a/Lib/xml/dom/__init__.py
+++ b/Lib/xml/dom/__init__.py
@@ -136,4 +136,4 @@ XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
EMPTY_NAMESPACE = None
EMPTY_PREFIX = None
-from domreg import getDOMImplementation,registerDOMImplementation
+from .domreg import getDOMImplementation, registerDOMImplementation
diff --git a/Lib/xml/dom/domreg.py b/Lib/xml/dom/domreg.py
index ec3acdf9c1d..cb35bb05964 100644
--- a/Lib/xml/dom/domreg.py
+++ b/Lib/xml/dom/domreg.py
@@ -36,7 +36,7 @@ def _good_enough(dom, features):
return 0
return 1
-def getDOMImplementation(name = None, features = ()):
+def getDOMImplementation(name=None, features=()):
"""getDOMImplementation(name = None, features = ()) -> DOM implementation.
Return a suitable DOM implementation. The name is either
@@ -62,7 +62,7 @@ def getDOMImplementation(name = None, features = ()):
# User did not specify a name, try implementations in arbitrary
# order, returning the one that has the required features
- if isinstance(features, StringTypes):
+ if isinstance(features, str):
features = _parse_feature_string(features)
for creator in registered.values():
dom = creator()
@@ -72,12 +72,12 @@ def getDOMImplementation(name = None, features = ()):
for creator in well_known_implementations.keys():
try:
dom = getDOMImplementation(name = creator)
- except StandardError: # typically ImportError, or AttributeError
+ except Exception: # typically ImportError, or AttributeError
continue
if _good_enough(dom, features):
return dom
- raise ImportError,"no suitable DOM implementation found"
+ raise ImportError("no suitable DOM implementation found")
def _parse_feature_string(s):
features = []
@@ -87,7 +87,7 @@ def _parse_feature_string(s):
while i < length:
feature = parts[i]
if feature[0] in "0123456789":
- raise ValueError, "bad feature name: %r" % (feature,)
+ raise ValueError("bad feature name: %r" % (feature,))
i = i + 1
version = None
if i < length:
diff --git a/Lib/xml/dom/expatbuilder.py b/Lib/xml/dom/expatbuilder.py
index 4fba87585f3..a98fe03235e 100644
--- a/Lib/xml/dom/expatbuilder.py
+++ b/Lib/xml/dom/expatbuilder.py
@@ -476,8 +476,8 @@ class FilterVisibilityController(object):
if val == FILTER_INTERRUPT:
raise ParseEscape
if val not in _ALLOWED_FILTER_RETURNS:
- raise ValueError, \
- "startContainer() returned illegal value: " + repr(val)
+ raise ValueError(
+ "startContainer() returned illegal value: " + repr(val))
return val
else:
return FILTER_ACCEPT
@@ -496,8 +496,8 @@ class FilterVisibilityController(object):
# node is handled by the caller
return FILTER_REJECT
if val not in _ALLOWED_FILTER_RETURNS:
- raise ValueError, \
- "acceptNode() returned illegal value: " + repr(val)
+ raise ValueError(
+ "acceptNode() returned illegal value: " + repr(val))
return val
else:
return FILTER_ACCEPT
@@ -918,7 +918,7 @@ def parse(file, namespaces=True):
else:
builder = ExpatBuilder()
- if isinstance(file, StringTypes):
+ if isinstance(file, str):
fp = open(file, 'rb')
try:
result = builder.parseFile(fp)
@@ -952,7 +952,7 @@ def parseFragment(file, context, namespaces=True):
else:
builder = FragmentBuilder(context)
- if isinstance(file, StringTypes):
+ if isinstance(file, str):
fp = open(file, 'rb')
try:
result = builder.parseFile(fp)
diff --git a/Lib/xml/dom/minicompat.py b/Lib/xml/dom/minicompat.py
index de4cb4f78ab..62725c6198d 100644
--- a/Lib/xml/dom/minicompat.py
+++ b/Lib/xml/dom/minicompat.py
@@ -40,12 +40,7 @@ __all__ = ["NodeList", "EmptyNodeList", "StringTypes", "defproperty"]
import xml.dom
-try:
- unicode
-except NameError:
- StringTypes = type(''),
-else:
- StringTypes = type(''), type(unicode(''))
+StringTypes = (str,)
class NodeList(list):
@@ -100,7 +95,7 @@ class EmptyNodeList(tuple):
def defproperty(klass, name, doc):
- get = getattr(klass, ("_get_" + name)).im_func
+ get = getattr(klass, ("_get_" + name))
def set(self, value, name=name):
raise xml.dom.NoModificationAllowedErr(
"attempt to modify read-only attribute " + repr(name))
diff --git a/Lib/xml/dom/minidom.py b/Lib/xml/dom/minidom.py
index 7e2898cd3ef..f23ad053333 100644
--- a/Lib/xml/dom/minidom.py
+++ b/Lib/xml/dom/minidom.py
@@ -14,6 +14,8 @@ Todo:
* SAX 2 namespaces
"""
+import codecs
+import io
import xml.dom
from xml.dom import EMPTY_NAMESPACE, EMPTY_PREFIX, XMLNS_NAMESPACE, domreg
@@ -38,26 +40,26 @@ class Node(xml.dom.Node):
prefix = EMPTY_PREFIX # non-null only for NS elements and attributes
- def __nonzero__(self):
+ def __bool__(self):
return True
- def toxml(self, encoding = None):
+ def toxml(self, encoding=None):
return self.toprettyxml("", "", encoding)
- def toprettyxml(self, indent="\t", newl="\n", encoding = None):
+ def toprettyxml(self, indent="\t", newl="\n", encoding=None):
# indent = the indentation string to prepend, per level
# newl = the newline string to append
- writer = _get_StringIO()
- if encoding is not None:
- import codecs
- # Can't use codecs.getwriter to preserve 2.0 compatibility
- writer = codecs.lookup(encoding)[3](writer)
+ use_encoding = "utf-8" if encoding is None else encoding
+ writer = codecs.getwriter(use_encoding)(io.BytesIO())
if self.nodeType == Node.DOCUMENT_NODE:
# Can pass encoding only to document, to put it into XML header
self.writexml(writer, "", indent, newl, encoding)
else:
self.writexml(writer, "", indent, newl)
- return writer.getvalue()
+ if encoding is None:
+ return writer.stream.getvalue().decode(use_encoding)
+ else:
+ return writer.stream.getvalue()
def hasChildNodes(self):
if self.childNodes:
@@ -251,7 +253,7 @@ class Node(xml.dom.Node):
def _call_user_data_handler(self, operation, src, dst):
if hasattr(self, "_user_data"):
- for key, (data, handler) in self._user_data.items():
+ for key, (data, handler) in list(self._user_data.items()):
if handler is not None:
handler.handle(operation, key, data, src, dst)
@@ -266,6 +268,14 @@ class Node(xml.dom.Node):
self.previousSibling = None
self.nextSibling = None
+ # A Node is its own context manager, to ensure that an unlink() call occurs.
+ # This is similar to how a file object works.
+ def __enter__(self):
+ return self
+
+ def __exit__(self, et, ev, tb):
+ self.unlink()
+
defproperty(Node, "firstChild", doc="First child node, or None.")
defproperty(Node, "lastChild", doc="Last child node, or None.")
defproperty(Node, "localName", doc="Namespace-local name of this node.")
@@ -355,6 +365,8 @@ class Attr(Node):
# nodeValue and value are set elsewhere
def _get_localName(self):
+ if 'localName' in self.__dict__:
+ return self.__dict__['localName']
return self.nodeName.split(":", 1)[-1]
def _get_name(self):
@@ -474,7 +486,7 @@ class NamedNodeMap(object):
def item(self, index):
try:
- return self[self._attrs.keys()[index]]
+ return self[list(self._attrs.keys())[index]]
except IndexError:
return None
@@ -490,8 +502,8 @@ class NamedNodeMap(object):
L.append(((node.namespaceURI, node.localName), node.value))
return L
- def has_key(self, key):
- if isinstance(key, StringTypes):
+ def __contains__(self, key):
+ if isinstance(key, str):
return key in self._attrs
else:
return key in self._attrsNS
@@ -510,12 +522,29 @@ class NamedNodeMap(object):
__len__ = _get_length
- __hash__ = None # Mutable type can't be correctly hashed
- def __cmp__(self, other):
+ def _cmp(self, other):
if self._attrs is getattr(other, "_attrs", None):
return 0
else:
- return cmp(id(self), id(other))
+ return (id(self) > id(other)) - (id(self) < id(other))
+
+ def __eq__(self, other):
+ return self._cmp(other) == 0
+
+ def __ge__(self, other):
+ return self._cmp(other) >= 0
+
+ def __gt__(self, other):
+ return self._cmp(other) > 0
+
+ def __le__(self, other):
+ return self._cmp(other) <= 0
+
+ def __lt__(self, other):
+ return self._cmp(other) < 0
+
+ def __ne__(self, other):
+ return self._cmp(other) != 0
def __getitem__(self, attname_or_tuple):
if isinstance(attname_or_tuple, tuple):
@@ -525,7 +554,7 @@ class NamedNodeMap(object):
# same as set
def __setitem__(self, attname, value):
- if isinstance(value, StringTypes):
+ if isinstance(value, str):
try:
node = self._attrs[attname]
except KeyError:
@@ -535,7 +564,7 @@ class NamedNodeMap(object):
node.value = value
else:
if not isinstance(value, Attr):
- raise TypeError, "value must be a string or Attr object"
+ raise TypeError("value must be a string or Attr object")
node = value
self.setNamedItem(node)
@@ -659,13 +688,15 @@ class Element(Node):
# namespaces.
def _get_localName(self):
+ if 'localName' in self.__dict__:
+ return self.__dict__['localName']
return self.tagName.split(":", 1)[-1]
def _get_tagName(self):
return self.tagName
def unlink(self):
- for attr in self._attrs.values():
+ for attr in list(self._attrs.values()):
attr.unlink()
self._attrs = None
self._attrsNS = None
@@ -798,8 +829,7 @@ class Element(Node):
writer.write(indent+"<" + self.tagName)
attrs = self._get_attributes()
- a_names = attrs.keys()
- a_names.sort()
+ a_names = sorted(attrs.keys())
for a_name in a_names:
writer.write(" %s=\"" % a_name)
@@ -1125,7 +1155,7 @@ def _get_containing_entref(node):
return None
-class Comment(Childless, CharacterData):
+class Comment(CharacterData):
nodeType = Node.COMMENT_NODE
nodeName = "#comment"
@@ -1182,7 +1212,7 @@ class ReadOnlySequentialNamedNodeMap(object):
else:
node = self.getNamedItem(name_or_tuple)
if node is None:
- raise KeyError, name_or_tuple
+ raise KeyError(name_or_tuple)
return node
def item(self, index):
@@ -1609,16 +1639,16 @@ class Document(Node, DocumentLS):
return e
def createTextNode(self, data):
- if not isinstance(data, StringTypes):
- raise TypeError, "node contents must be a string"
+ if not isinstance(data, str):
+ raise TypeError("node contents must be a string")
t = Text()
t.data = data
t.ownerDocument = self
return t
def createCDATASection(self, data):
- if not isinstance(data, StringTypes):
- raise TypeError, "node contents must be a string"
+ if not isinstance(data, str):
+ raise TypeError("node contents must be a string")
c = CDATASection()
c.data = data
c.ownerDocument = self
@@ -1901,11 +1931,6 @@ def _nssplit(qualifiedName):
return (None, fields[0])
-def _get_StringIO():
- # we can't use cStringIO since it doesn't support Unicode strings
- from StringIO import StringIO
- return StringIO()
-
def _do_pulldom_parse(func, args, kwargs):
events = func(*args, **kwargs)
toktype, rootNode = events.getEvent()
@@ -1935,7 +1960,7 @@ def parseString(string, parser=None):
def getDOMImplementation(features=None):
if features:
- if isinstance(features, StringTypes):
+ if isinstance(features, str):
features = domreg._parse_feature_string(features)
for f, v in features:
if not Document.implementation.hasFeature(f, v):
diff --git a/Lib/xml/dom/pulldom.py b/Lib/xml/dom/pulldom.py
index 18f49b50196..d5ac8b2b984 100644
--- a/Lib/xml/dom/pulldom.py
+++ b/Lib/xml/dom/pulldom.py
@@ -2,11 +2,6 @@ import xml.sax
import xml.sax.handler
import types
-try:
- _StringTypes = [types.StringType, types.UnicodeType]
-except AttributeError:
- _StringTypes = [types.StringType]
-
START_ELEMENT = "START_ELEMENT"
END_ELEMENT = "END_ELEMENT"
COMMENT = "COMMENT"
@@ -201,7 +196,7 @@ class PullDOM(xml.sax.ContentHandler):
class ErrorHandler:
def warning(self, exception):
- print exception
+ print(exception)
def error(self, exception):
raise exception
def fatalError(self, exception):
@@ -228,7 +223,7 @@ class DOMEventStream:
return rc
raise IndexError
- def next(self):
+ def __next__(self):
rc = self.getEvent()
if rc:
return rc
@@ -330,8 +325,8 @@ default_bufsize = (2 ** 14) - 20
def parse(stream_or_string, parser=None, bufsize=None):
if bufsize is None:
bufsize = default_bufsize
- if type(stream_or_string) in _StringTypes:
- stream = open(stream_or_string)
+ if isinstance(stream_or_string, str):
+ stream = open(stream_or_string, 'rb')
else:
stream = stream_or_string
if not parser:
@@ -340,9 +335,9 @@ def parse(stream_or_string, parser=None, bufsize=None):
def parseString(string, parser=None):
try:
- from cStringIO import StringIO
+ from io import StringIO
except ImportError:
- from StringIO import StringIO
+ from io import StringIO
bufsize = len(string)
buf = StringIO(string)
diff --git a/Lib/xml/dom/xmlbuilder.py b/Lib/xml/dom/xmlbuilder.py
index dc7c5d47058..d7986247091 100644
--- a/Lib/xml/dom/xmlbuilder.py
+++ b/Lib/xml/dom/xmlbuilder.py
@@ -190,8 +190,8 @@ class DOMBuilder:
options.errorHandler = self.errorHandler
fp = input.byteStream
if fp is None and options.systemId:
- import urllib2
- fp = urllib2.urlopen(input.systemId)
+ import urllib.request
+ fp = urllib.request.urlopen(input.systemId)
return self._parse_bytestream(fp, options)
def parseWithContext(self, input, cnode, action):
@@ -223,14 +223,14 @@ class DOMEntityResolver(object):
source.encoding = self._guess_media_encoding(source)
# determine the base URI is we can
- import posixpath, urlparse
- parts = urlparse.urlparse(systemId)
+ import posixpath, urllib.parse
+ parts = urllib.parse.urlparse(systemId)
scheme, netloc, path, params, query, fragment = parts
# XXX should we check the scheme here as well?
if path and not path.endswith("/"):
path = posixpath.dirname(path) + "/"
parts = scheme, netloc, path, params, query, fragment
- source.baseURI = urlparse.urlunparse(parts)
+ source.baseURI = urllib.parse.urlunparse(parts)
return source
@@ -242,8 +242,8 @@ class DOMEntityResolver(object):
return self._opener
def _create_opener(self):
- import urllib2
- return urllib2.build_opener()
+ import urllib.request
+ return urllib.request.build_opener()
def _guess_media_encoding(self, source):
info = source.byteStream.info()
diff --git a/Lib/xml/etree/ElementInclude.py b/Lib/xml/etree/ElementInclude.py
index 84fd7548b28..6cc1b44e958 100644
--- a/Lib/xml/etree/ElementInclude.py
+++ b/Lib/xml/etree/ElementInclude.py
@@ -67,7 +67,7 @@ class FatalIncludeError(SyntaxError):
#
# @param href Resource reference.
# @param parse Parse mode. Either "xml" or "text".
-# @param encoding Optional text encoding.
+# @param encoding Optional text encoding (UTF-8 by default for "text").
# @return The expanded resource. If the parse mode is "xml", this
# is an ElementTree instance. If the parse mode is "text", this
# is a Unicode string. If the loader fails, it can return None
@@ -75,13 +75,14 @@ class FatalIncludeError(SyntaxError):
# @throws IOError If the loader fails to load the resource.
def default_loader(href, parse, encoding=None):
- file = open(href)
if parse == "xml":
+ file = open(href, 'rb')
data = ElementTree.parse(file).getroot()
else:
+ if not encoding:
+ encoding = 'UTF-8'
+ file = open(href, 'r', encoding=encoding)
data = file.read()
- if encoding:
- data = data.decode(encoding)
file.close()
return data
diff --git a/Lib/xml/etree/ElementPath.py b/Lib/xml/etree/ElementPath.py
index 4a626d799c8..52e65f063da 100644
--- a/Lib/xml/etree/ElementPath.py
+++ b/Lib/xml/etree/ElementPath.py
@@ -255,7 +255,7 @@ def iterfind(elem, path, namespaces=None):
_cache.clear()
if path[:1] == "/":
raise SyntaxError("cannot use absolute path on element")
- next = iter(xpath_tokenizer(path, namespaces)).next
+ next = iter(xpath_tokenizer(path, namespaces)).__next__
token = next()
selector = []
while 1:
@@ -282,7 +282,7 @@ def iterfind(elem, path, namespaces=None):
def find(elem, path, namespaces=None):
try:
- return iterfind(elem, path, namespaces).next()
+ return next(iterfind(elem, path, namespaces))
except StopIteration:
return None
@@ -297,7 +297,7 @@ def findall(elem, path, namespaces=None):
def findtext(elem, path, default=None, namespaces=None):
try:
- elem = iterfind(elem, path, namespaces).next()
+ elem = next(iterfind(elem, path, namespaces))
return elem.text or ""
except StopIteration:
return default
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index d8ec67a90eb..9742f32f381 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -101,7 +101,7 @@ import re
import warnings
-class _SimpleElementPath(object):
+class _SimpleElementPath:
# emulate pre-1.2 find/findtext/findall behaviour
def find(self, element, tag, namespaces=None):
for elem in element:
@@ -168,7 +168,7 @@ def iselement(element):
# @see Comment
# @see ProcessingInstruction
-class Element(object):
+class Element:
# <tag attrib>text<child/>...</tag>tail
##
@@ -247,7 +247,7 @@ class Element(object):
def __len__(self):
return len(self._children)
- def __nonzero__(self):
+ def __bool__(self):
warnings.warn(
"The behavior of this method will change in future versions. "
"Use specific 'len(elem)' or 'elem is not None' test instead.",
@@ -497,7 +497,7 @@ class Element(object):
def itertext(self):
tag = self.tag
- if not isinstance(tag, basestring) and tag is not None:
+ if not isinstance(tag, str) and tag is not None:
return
if self.text:
yield self.text
@@ -577,19 +577,41 @@ PI = ProcessingInstruction
# an URI, and this argument is interpreted as a local name.
# @return An opaque object, representing the QName.
-class QName(object):
+class QName:
def __init__(self, text_or_uri, tag=None):
if tag:
text_or_uri = "{%s}%s" % (text_or_uri, tag)
self.text = text_or_uri
def __str__(self):
return self.text
+ def __repr__(self):
+ return '<QName %r>' % (self.text,)
def __hash__(self):
return hash(self.text)
- def __cmp__(self, other):
+ def __le__(self, other):
+ if isinstance(other, QName):
+ return self.text <= other.text
+ return self.text <= other
+ def __lt__(self, other):
+ if isinstance(other, QName):
+ return self.text < other.text
+ return self.text < other
+ def __ge__(self, other):
+ if isinstance(other, QName):
+ return self.text >= other.text
+ return self.text >= other
+ def __gt__(self, other):
if isinstance(other, QName):
- return cmp(self.text, other.text)
- return cmp(self.text, other)
+ return self.text > other.text
+ return self.text > other
+ def __eq__(self, other):
+ if isinstance(other, QName):
+ return self.text == other.text
+ return self.text == other
+ def __ne__(self, other):
+ if isinstance(other, QName):
+ return self.text != other.text
+ return self.text != other
# --------------------------------------------------------------------
@@ -602,7 +624,7 @@ class QName(object):
# @keyparam file Optional file handle or file name. If given, the
# tree is initialized with the contents of this XML file.
-class ElementTree(object):
+class ElementTree:
def __init__(self, element=None, file=None):
# assert element is None or iselement(element)
@@ -779,11 +801,12 @@ class ElementTree(object):
# @param file A file name, or a file object opened for writing.
# @param **options Options, given as keyword arguments.
# @keyparam encoding Optional output encoding (default is US-ASCII).
+ # Use "unicode" to return a Unicode string.
# @keyparam method Optional output method ("xml", "html", "text" or
# "c14n"; default is "xml").
# @keyparam xml_declaration Controls if an XML declaration should
# be added to the file. Use False for never, True for always,
- # None for only if not US-ASCII or UTF-8. None is default.
+ # None for only if not US-ASCII or UTF-8 or Unicode. None is default.
def write(self, file_or_filename,
# keyword arguments
@@ -797,28 +820,46 @@ class ElementTree(object):
elif method not in _serialize:
# FIXME: raise an ImportError for c14n if ElementC14N is missing?
raise ValueError("unknown method %r" % method)
- if hasattr(file_or_filename, "write"):
- file = file_or_filename
- else:
- file = open(file_or_filename, "wb")
- write = file.write
if not encoding:
if method == "c14n":
encoding = "utf-8"
else:
encoding = "us-ascii"
- elif xml_declaration or (xml_declaration is None and
- encoding not in ("utf-8", "us-ascii")):
- if method == "xml":
- write("<?xml version='1.0' encoding='%s'?>\n" % encoding)
+ elif encoding == str: # lxml.etree compatibility.
+ encoding = "unicode"
+ else:
+ encoding = encoding.lower()
+ if hasattr(file_or_filename, "write"):
+ file = file_or_filename
+ else:
+ if encoding != "unicode":
+ file = open(file_or_filename, "wb")
+ else:
+ file = open(file_or_filename, "w")
+ if encoding != "unicode":
+ def write(text):
+ try:
+ return file.write(text.encode(encoding,
+ "xmlcharrefreplace"))
+ except (TypeError, AttributeError):
+ _raise_serialization_error(text)
+ else:
+ write = file.write
+ if method == "xml" and (xml_declaration or
+ (xml_declaration is None and
+ encoding not in ("utf-8", "us-ascii", "unicode"))):
+ declared_encoding = encoding
+ if encoding == "unicode":
+ # Retrieve the default encoding for the xml declaration
+ import locale
+ declared_encoding = locale.getpreferredencoding()
+ write("<?xml version='1.0' encoding='%s'?>\n" % declared_encoding)
if method == "text":
- _serialize_text(write, self._root, encoding)
+ _serialize_text(write, self._root)
else:
- qnames, namespaces = _namespaces(
- self._root, encoding, default_namespace
- )
+ qnames, namespaces = _namespaces(self._root, default_namespace)
serialize = _serialize[method]
- serialize(write, self._root, encoding, qnames, namespaces)
+ serialize(write, self._root, qnames, namespaces)
if file_or_filename is not file:
file.close()
@@ -829,7 +870,7 @@ class ElementTree(object):
# --------------------------------------------------------------------
# serialization support
-def _namespaces(elem, encoding, default_namespace=None):
+def _namespaces(elem, default_namespace=None):
# identify namespaces used in this tree
# maps qnames to *encoded* prefix:local names
@@ -840,9 +881,6 @@ def _namespaces(elem, encoding, default_namespace=None):
if default_namespace:
namespaces[default_namespace] = ""
- def encode(text):
- return text.encode(encoding)
-
def add_qname(qname):
# calculate serialized qname representation
try:
@@ -856,9 +894,9 @@ def _namespaces(elem, encoding, default_namespace=None):
if prefix != "xml":
namespaces[uri] = prefix
if prefix:
- qnames[qname] = encode("%s:%s" % (prefix, tag))
+ qnames[qname] = "%s:%s" % (prefix, tag)
else:
- qnames[qname] = encode(tag) # default element
+ qnames[qname] = tag # default element
else:
if default_namespace:
# FIXME: can this be handled in XML 1.0?
@@ -866,7 +904,7 @@ def _namespaces(elem, encoding, default_namespace=None):
"cannot use non-qualified names with "
"default_namespace option"
)
- qnames[qname] = encode(qname)
+ qnames[qname] = qname
except TypeError:
_raise_serialization_error(qname)
@@ -880,7 +918,7 @@ def _namespaces(elem, encoding, default_namespace=None):
if isinstance(tag, QName):
if tag.text not in qnames:
add_qname(tag.text)
- elif isinstance(tag, basestring):
+ elif isinstance(tag, str):
if tag not in qnames:
add_qname(tag)
elif tag is not None and tag is not Comment and tag is not PI:
@@ -897,23 +935,23 @@ def _namespaces(elem, encoding, default_namespace=None):
add_qname(text.text)
return qnames, namespaces
-def _serialize_xml(write, elem, encoding, qnames, namespaces):
+def _serialize_xml(write, elem, qnames, namespaces):
tag = elem.tag
text = elem.text
if tag is Comment:
- write("<!--%s-->" % _encode(text, encoding))
+ write("<!--%s-->" % text)
elif tag is ProcessingInstruction:
- write("<?%s?>" % _encode(text, encoding))
+ write("<?%s?>" % text)
else:
tag = qnames[tag]
if tag is None:
if text:
- write(_escape_cdata(text, encoding))
+ write(_escape_cdata(text))
for e in elem:
- _serialize_xml(write, e, encoding, qnames, None)
+ _serialize_xml(write, e, qnames, None)
else:
write("<" + tag)
- items = elem.items()
+ items = list(elem.items())
if items or namespaces:
if namespaces:
for v, k in sorted(namespaces.items(),
@@ -921,8 +959,8 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
if k:
k = ":" + k
write(" xmlns%s=\"%s\"" % (
- k.encode(encoding),
- _escape_attrib(v, encoding)
+ k,
+ _escape_attrib(v)
))
for k, v in sorted(items): # lexical order
if isinstance(k, QName):
@@ -930,19 +968,19 @@ def _serialize_xml(write, elem, encoding, qnames, namespaces):
if isinstance(v, QName):
v = qnames[v.text]
else:
- v = _escape_attrib(v, encoding)
+ v = _escape_attrib(v)
write(" %s=\"%s\"" % (qnames[k], v))
if text or len(elem):
write(">")
if text:
- write(_escape_cdata(text, encoding))
+ write(_escape_cdata(text))
for e in elem:
- _serialize_xml(write, e, encoding, qnames, None)
+ _serialize_xml(write, e, qnames, None)
write("</" + tag + ">")
else:
write(" />")
if elem.tail:
- write(_escape_cdata(elem.tail, encoding))
+ write(_escape_cdata(elem.tail))
HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr",
"img", "input", "isindex", "link", "meta", "param")
@@ -952,23 +990,23 @@ try:
except NameError:
pass
-def _serialize_html(write, elem, encoding, qnames, namespaces):
+def _serialize_html(write, elem, qnames, namespaces):
tag = elem.tag
text = elem.text
if tag is Comment:
- write("<!--%s-->" % _escape_cdata(text, encoding))
+ write("<!--%s-->" % _escape_cdata(text))
elif tag is ProcessingInstruction:
- write("<?%s?>" % _escape_cdata(text, encoding))
+ write("<?%s?>" % _escape_cdata(text))
else:
tag = qnames[tag]
if tag is None:
if text:
- write(_escape_cdata(text, encoding))
+ write(_escape_cdata(text))
for e in elem:
- _serialize_html(write, e, encoding, qnames, None)
+ _serialize_html(write, e, qnames, None)
else:
write("<" + tag)
- items = elem.items()
+ items = list(elem.items())
if items or namespaces:
if namespaces:
for v, k in sorted(namespaces.items(),
@@ -976,8 +1014,8 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
if k:
k = ":" + k
write(" xmlns%s=\"%s\"" % (
- k.encode(encoding),
- _escape_attrib(v, encoding)
+ k,
+ _escape_attrib(v)
))
for k, v in sorted(items): # lexical order
if isinstance(k, QName):
@@ -985,28 +1023,28 @@ def _serialize_html(write, elem, encoding, qnames, namespaces):
if isinstance(v, QName):
v = qnames[v.text]
else:
- v = _escape_attrib_html(v, encoding)
+ v = _escape_attrib_html(v)
# FIXME: handle boolean attributes
write(" %s=\"%s\"" % (qnames[k], v))
write(">")
tag = tag.lower()
if text:
if tag == "script" or tag == "style":
- write(_encode(text, encoding))
+ write(text)
else:
- write(_escape_cdata(text, encoding))
+ write(_escape_cdata(text))
for e in elem:
- _serialize_html(write, e, encoding, qnames, None)
+ _serialize_html(write, e, qnames, None)
if tag not in HTML_EMPTY:
write("</" + tag + ">")
if elem.tail:
- write(_escape_cdata(elem.tail, encoding))
+ write(_escape_cdata(elem.tail))
-def _serialize_text(write, elem, encoding):
+def _serialize_text(write, elem):
for part in elem.itertext():
- write(part.encode(encoding))
+ write(part)
if elem.tail:
- write(elem.tail.encode(encoding))
+ write(elem.tail)
_serialize = {
"xml": _serialize_xml,
@@ -1030,7 +1068,7 @@ _serialize = {
def register_namespace(prefix, uri):
if re.match("ns\d+$", prefix):
raise ValueError("Prefix format reserved for internal use")
- for k, v in _namespace_map.items():
+ for k, v in list(_namespace_map.items()):
if k == uri or v == prefix:
del _namespace_map[k]
_namespace_map[uri] = prefix
@@ -1053,13 +1091,7 @@ def _raise_serialization_error(text):
"cannot serialize %r (type %s)" % (text, type(text).__name__)
)
-def _encode(text, encoding):
- try:
- return text.encode(encoding, "xmlcharrefreplace")
- except (TypeError, AttributeError):
- _raise_serialization_error(text)
-
-def _escape_cdata(text, encoding):
+def _escape_cdata(text):
# escape character data
try:
# it's worth avoiding do-nothing calls for strings that are
@@ -1071,11 +1103,11 @@ def _escape_cdata(text, encoding):
text = text.replace("<", "&lt;")
if ">" in text:
text = text.replace(">", "&gt;")
- return text.encode(encoding, "xmlcharrefreplace")
+ return text
except (TypeError, AttributeError):
_raise_serialization_error(text)
-def _escape_attrib(text, encoding):
+def _escape_attrib(text):
# escape attribute value
try:
if "&" in text:
@@ -1088,11 +1120,11 @@ def _escape_attrib(text, encoding):
text = text.replace("\"", "&quot;")
if "\n" in text:
text = text.replace("\n", "&#10;")
- return text.encode(encoding, "xmlcharrefreplace")
+ return text
except (TypeError, AttributeError):
_raise_serialization_error(text)
-def _escape_attrib_html(text, encoding):
+def _escape_attrib_html(text):
# escape attribute value
try:
if "&" in text:
@@ -1101,7 +1133,7 @@ def _escape_attrib_html(text, encoding):
text = text.replace(">", "&gt;")
if "\"" in text:
text = text.replace("\"", "&quot;")
- return text.encode(encoding, "xmlcharrefreplace")
+ return text
except (TypeError, AttributeError):
_raise_serialization_error(text)
@@ -1109,13 +1141,15 @@ def _escape_attrib_html(text, encoding):
##
# Generates a string representation of an XML element, including all
-# subelements.
+# subelements. If encoding is "unicode", the return type is a string;
+# otherwise it is a bytes array.
#
# @param element An Element instance.
# @keyparam encoding Optional output encoding (default is US-ASCII).
+# Use "unicode" to return a Unicode string.
# @keyparam method Optional output method ("xml", "html", "text" or
# "c14n"; default is "xml").
-# @return An encoded string containing the XML data.
+# @return An (optionally) encoded string containing the XML data.
# @defreturn string
def tostring(element, encoding=None, method=None):
@@ -1125,14 +1159,20 @@ def tostring(element, encoding=None, method=None):
file = dummy()
file.write = data.append
ElementTree(element).write(file, encoding, method=method)
- return "".join(data)
+ if encoding in (str, "unicode"):
+ return "".join(data)
+ else:
+ return b"".join(data)
##
# Generates a string representation of an XML element, including all
-# subelements. The string is returned as a sequence of string fragments.
+# subelements. If encoding is False, the string is returned as a
+# sequence of string fragments; otherwise it is a sequence of
+# bytestrings.
#
# @param element An Element instance.
# @keyparam encoding Optional output encoding (default is US-ASCII).
+# Use "unicode" to return a Unicode string.
# @keyparam method Optional output method ("xml", "html", "text" or
# "c14n"; default is "xml").
# @return A sequence object containing the XML data.
@@ -1162,7 +1202,7 @@ def dump(elem):
# debugging
if not isinstance(elem, ElementTree):
elem = ElementTree(elem)
- elem.write(sys.stdout)
+ elem.write(sys.stdout, encoding="unicode")
tail = elem.getroot().tail
if not tail or tail[-1] != "\n":
sys.stdout.write("\n")
@@ -1203,7 +1243,7 @@ def iterparse(source, events=None, parser=None):
parser = XMLParser(target=TreeBuilder())
return _IterParseIterator(source, events, parser, close_source)
-class _IterParseIterator(object):
+class _IterParseIterator:
def __init__(self, source, events, parser, close_source=False):
self._file = source
@@ -1239,10 +1279,6 @@ class _IterParseIterator(object):
parser.EndElementHandler = handler
elif event == "start-ns":
def handler(prefix, uri, event=event, append=append):
- try:
- uri = (uri or "").encode("ascii")
- except UnicodeError:
- pass
append((event, (prefix or "", uri or "")))
parser.StartNamespaceDeclHandler = handler
elif event == "end-ns":
@@ -1252,7 +1288,7 @@ class _IterParseIterator(object):
else:
raise ValueError("unknown event %r" % event)
- def next(self):
+ def __next__(self):
while 1:
try:
item = self._events[self._index]
@@ -1363,7 +1399,7 @@ def fromstringlist(sequence, parser=None):
# @param element_factory Optional element factory. This factory
# is called to create new Element instances, as necessary.
-class TreeBuilder(object):
+class TreeBuilder:
def __init__(self, element_factory=None):
self._data = [] # data collector
@@ -1453,7 +1489,7 @@ class TreeBuilder(object):
# @see #ElementTree
# @see #TreeBuilder
-class XMLParser(object):
+class XMLParser:
def __init__(self, html=0, target=None, encoding=None):
try:
@@ -1506,13 +1542,6 @@ class XMLParser(object):
err.position = value.lineno, value.offset
raise err
- def _fixtext(self, text):
- # convert text string to ascii, if possible
- try:
- return text.encode("ascii")
- except UnicodeError:
- return text
-
def _fixname(self, key):
# expand qname, and convert name string to ascii, if possible
try:
@@ -1521,30 +1550,28 @@ class XMLParser(object):
name = key
if "}" in name:
name = "{" + name
- self._names[key] = name = self._fixtext(name)
+ self._names[key] = name
return name
def _start(self, tag, attrib_in):
fixname = self._fixname
- fixtext = self._fixtext
tag = fixname(tag)
attrib = {}
for key, value in attrib_in.items():
- attrib[fixname(key)] = fixtext(value)
+ attrib[fixname(key)] = value
return self.target.start(tag, attrib)
def _start_list(self, tag, attrib_in):
fixname = self._fixname
- fixtext = self._fixtext
tag = fixname(tag)
attrib = {}
if attrib_in:
for i in range(0, len(attrib_in), 2):
- attrib[fixname(attrib_in[i])] = fixtext(attrib_in[i+1])
+ attrib[fixname(attrib_in[i])] = attrib_in[i+1]
return self.target.start(tag, attrib)
def _data(self, text):
- return self.target.data(self._fixtext(text))
+ return self.target.data(text)
def _end(self, tag):
return self.target.end(self._fixname(tag))
@@ -1555,7 +1582,7 @@ class XMLParser(object):
except AttributeError:
pass
else:
- return comment(self._fixtext(data))
+ return comment(data)
def _pi(self, target, data):
try:
@@ -1563,7 +1590,7 @@ class XMLParser(object):
except AttributeError:
pass
else:
- return pi(self._fixtext(target), self._fixtext(data))
+ return pi(target, data)
def _default(self, text):
prefix = text[:1]
@@ -1639,7 +1666,7 @@ class XMLParser(object):
def feed(self, data):
try:
self._parser.Parse(data, 0)
- except self._error, v:
+ except self._error as v:
self._raiseerror(v)
##
@@ -1651,7 +1678,7 @@ class XMLParser(object):
def close(self):
try:
self._parser.Parse("", 1) # end of data
- except self._error, v:
+ except self._error as v:
self._raiseerror(v)
tree = self.target.close()
del self.target, self._parser # get rid of circular references
diff --git a/Lib/xml/parsers/expat.py b/Lib/xml/parsers/expat.py
index 00b5c78ec0b..a805b828d80 100644
--- a/Lib/xml/parsers/expat.py
+++ b/Lib/xml/parsers/expat.py
@@ -1,4 +1,10 @@
"""Interface to the Expat non-validating XML parser."""
-__version__ = '$Revision: 17640 $'
+__version__ = '$Revision$'
+
+import sys
from pyexpat import *
+
+# provide pyexpat submodules as xml.parsers.expat submodules
+sys.modules['xml.parsers.expat.model'] = model
+sys.modules['xml.parsers.expat.errors'] = errors
diff --git a/Lib/xml/sax/__init__.py b/Lib/xml/sax/__init__.py
index 005b66e38a8..b161b1f07a9 100644
--- a/Lib/xml/sax/__init__.py
+++ b/Lib/xml/sax/__init__.py
@@ -19,9 +19,9 @@ xmlreader -- Base classes and constants which define the SAX 2 API for
expatreader -- Driver that allows use of the Expat parser with SAX.
"""
-from xmlreader import InputSource
-from handler import ContentHandler, ErrorHandler
-from _exceptions import SAXException, SAXNotRecognizedException, \
+from .xmlreader import InputSource
+from .handler import ContentHandler, ErrorHandler
+from ._exceptions import SAXException, SAXNotRecognizedException, \
SAXParseException, SAXNotSupportedException, \
SAXReaderNotAvailable
@@ -33,10 +33,7 @@ def parse(source, handler, errorHandler=ErrorHandler()):
parser.parse(source)
def parseString(string, handler, errorHandler=ErrorHandler()):
- try:
- from cStringIO import StringIO
- except ImportError:
- from StringIO import StringIO
+ from io import BytesIO
if errorHandler is None:
errorHandler = ErrorHandler()
@@ -45,7 +42,7 @@ def parseString(string, handler, errorHandler=ErrorHandler()):
parser.setErrorHandler(errorHandler)
inpsrc = InputSource()
- inpsrc.setByteStream(StringIO(string))
+ inpsrc.setByteStream(BytesIO(string))
parser.parse(inpsrc)
# this is the parser list used by the make_parser function if no
@@ -79,7 +76,7 @@ def make_parser(parser_list = []):
for parser_name in parser_list + default_parser_list:
try:
return _create_parser(parser_name)
- except ImportError,e:
+ except ImportError as e:
import sys
if parser_name in sys.modules:
# The parser module was found, but importing it
diff --git a/Lib/xml/sax/expatreader.py b/Lib/xml/sax/expatreader.py
index 92a79c1c74d..a227cdab572 100644
--- a/Lib/xml/sax/expatreader.py
+++ b/Lib/xml/sax/expatreader.py
@@ -205,7 +205,7 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
# document. When feeding chunks, they are not normally final -
# except when invoked from close.
self._parser.Parse(data, isFinal)
- except expat.error, e:
+ except expat.error as e:
exc = SAXParseException(expat.ErrorString(e.code), e, self)
# FIXME: when to invoke error()?
self._err_handler.fatalError(exc)
@@ -219,6 +219,9 @@ class ExpatParser(xmlreader.IncrementalParser, xmlreader.Locator):
self._parsing = 0
# break cycle created by expat handlers pointing to our methods
self._parser = None
+ bs = self._source.getByteStream()
+ if bs is not None:
+ bs.close()
def _reset_cont_handler(self):
self._parser.ProcessingInstructionHandler = \
diff --git a/Lib/xml/sax/handler.py b/Lib/xml/sax/handler.py
index f9e91b6d470..481733d2cbe 100644
--- a/Lib/xml/sax/handler.py
+++ b/Lib/xml/sax/handler.py
@@ -39,7 +39,7 @@ class ErrorHandler:
def warning(self, exception):
"Handle a warning."
- print exception
+ print(exception)
# ===== CONTENTHANDLER =====
diff --git a/Lib/xml/sax/saxutils.py b/Lib/xml/sax/saxutils.py
index 97d65d8fd33..625bc122ac2 100644
--- a/Lib/xml/sax/saxutils.py
+++ b/Lib/xml/sax/saxutils.py
@@ -3,14 +3,9 @@ A library of useful helper classes to the SAX classes, for the
convenience of application and driver writers.
"""
-import os, urlparse, urllib, types
-import handler
-import xmlreader
-
-try:
- _StringTypes = [types.StringType, types.UnicodeType]
-except AttributeError:
- _StringTypes = [types.StringType]
+import os, urllib.parse, urllib.request
+from . import handler
+from . import xmlreader
# See whether the xmlcharrefreplace error handler is
# supported
@@ -83,7 +78,7 @@ def quoteattr(data, entities={}):
class XMLGenerator(handler.ContentHandler):
- def __init__(self, out=None, encoding="iso-8859-1"):
+ def __init__(self, out=None, encoding="iso-8859-1", short_empty_elements=False):
if out is None:
import sys
out = sys.stdout
@@ -93,6 +88,8 @@ class XMLGenerator(handler.ContentHandler):
self._current_context = self._ns_contexts[-1]
self._undeclared_ns_maps = []
self._encoding = encoding
+ self._short_empty_elements = short_empty_elements
+ self._pending_start_element = False
def _write(self, text):
if isinstance(text, str):
@@ -117,6 +114,11 @@ class XMLGenerator(handler.ContentHandler):
# Return the unqualified name
return name[1]
+ def _finish_pending_start_element(self,endElement=False):
+ if self._pending_start_element:
+ self._write('>')
+ self._pending_start_element = False
+
# ContentHandler methods
def startDocument(self):
@@ -133,15 +135,24 @@ class XMLGenerator(handler.ContentHandler):
del self._ns_contexts[-1]
def startElement(self, name, attrs):
+ self._finish_pending_start_element()
self._write('<' + name)
for (name, value) in attrs.items():
self._write(' %s=%s' % (name, quoteattr(value)))
- self._write('>')
+ if self._short_empty_elements:
+ self._pending_start_element = True
+ else:
+ self._write(">")
def endElement(self, name):
- self._write('</%s>' % name)
+ if self._pending_start_element:
+ self._write('/>')
+ self._pending_start_element = False
+ else:
+ self._write('</%s>' % name)
def startElementNS(self, name, qname, attrs):
+ self._finish_pending_start_element()
self._write('<' + self._qname(name))
for prefix, uri in self._undeclared_ns_maps:
@@ -153,18 +164,30 @@ class XMLGenerator(handler.ContentHandler):
for (name, value) in attrs.items():
self._write(' %s=%s' % (self._qname(name), quoteattr(value)))
- self._write('>')
+ if self._short_empty_elements:
+ self._pending_start_element = True
+ else:
+ self._write(">")
def endElementNS(self, name, qname):
- self._write('</%s>' % self._qname(name))
+ if self._pending_start_element:
+ self._write('/>')
+ self._pending_start_element = False
+ else:
+ self._write('</%s>' % self._qname(name))
def characters(self, content):
- self._write(escape(content))
+ if content:
+ self._finish_pending_start_element()
+ self._write(escape(content))
def ignorableWhitespace(self, content):
- self._write(content)
+ if content:
+ self._finish_pending_start_element()
+ self._write(content)
def processingInstruction(self, target, data):
+ self._finish_pending_start_element()
self._write('<?%s %s?>' % (target, data))
@@ -279,11 +302,11 @@ class XMLFilterBase(xmlreader.XMLReader):
# --- Utility functions
-def prepare_input_source(source, base = ""):
+def prepare_input_source(source, base=""):
"""This function takes an InputSource and an optional base URL and
returns a fully resolved InputSource object ready for reading."""
- if type(source) in _StringTypes:
+ if isinstance(source, str):
source = xmlreader.InputSource(source)
elif hasattr(source, "read"):
f = source
@@ -300,8 +323,8 @@ def prepare_input_source(source, base = ""):
source.setSystemId(sysidfilename)
f = open(sysidfilename, "rb")
else:
- source.setSystemId(urlparse.urljoin(base, sysid))
- f = urllib.urlopen(source.getSystemId())
+ source.setSystemId(urllib.parse.urljoin(base, sysid))
+ f = urllib.request.urlopen(source.getSystemId())
source.setByteStream(f)
diff --git a/Lib/xml/sax/xmlreader.py b/Lib/xml/sax/xmlreader.py
index 74aa39a7f12..7ef497f94fe 100644
--- a/Lib/xml/sax/xmlreader.py
+++ b/Lib/xml/sax/xmlreader.py
@@ -1,9 +1,9 @@
"""An XML Reader is the SAX 2 name for an XML parser. XML Parsers
should be based on this code. """
-import handler
+from . import handler
-from _exceptions import SAXNotSupportedException, SAXNotRecognizedException
+from ._exceptions import SAXNotSupportedException, SAXNotRecognizedException
# ===== XMLREADER =====
@@ -113,13 +113,13 @@ class IncrementalParser(XMLReader):
XMLReader.__init__(self)
def parse(self, source):
- import saxutils
+ from . import saxutils
source = saxutils.prepare_input_source(source)
self.prepareParser(source)
file = source.getByteStream()
buffer = file.read(self._bufsize)
- while buffer != "":
+ while buffer:
self.feed(buffer)
buffer = file.read(self._bufsize)
self.close()
@@ -294,20 +294,20 @@ class AttributesImpl:
return self._attrs[name]
def getNameByQName(self, name):
- if not name in self._attrs:
- raise KeyError, name
+ if name not in self._attrs:
+ raise KeyError(name)
return name
def getQNameByName(self, name):
- if not name in self._attrs:
- raise KeyError, name
+ if name not in self._attrs:
+ raise KeyError(name)
return name
def getNames(self):
- return self._attrs.keys()
+ return list(self._attrs.keys())
def getQNames(self):
- return self._attrs.keys()
+ return list(self._attrs.keys())
def __len__(self):
return len(self._attrs)
@@ -316,10 +316,7 @@ class AttributesImpl:
return self._attrs[name]
def keys(self):
- return self._attrs.keys()
-
- def has_key(self, name):
- return name in self._attrs
+ return list(self._attrs.keys())
def __contains__(self, name):
return name in self._attrs
@@ -331,10 +328,10 @@ class AttributesImpl:
return self.__class__(self._attrs)
def items(self):
- return self._attrs.items()
+ return list(self._attrs.items())
def values(self):
- return self._attrs.values()
+ return list(self._attrs.values())
# ===== ATTRIBUTESNSIMPL =====
@@ -353,20 +350,20 @@ class AttributesNSImpl(AttributesImpl):
if qname == name:
return self._attrs[nsname]
- raise KeyError, name
+ raise KeyError(name)
def getNameByQName(self, name):
for (nsname, qname) in self._qnames.items():
if qname == name:
return nsname
- raise KeyError, name
+ raise KeyError(name)
def getQNameByName(self, name):
return self._qnames[name]
def getQNames(self):
- return self._qnames.values()
+ return list(self._qnames.values())
def copy(self):
return self.__class__(self._attrs, self._qnames)
diff --git a/Lib/xmllib.py b/Lib/xmllib.py
deleted file mode 100644
index 96ee8411e7a..00000000000
--- a/Lib/xmllib.py
+++ /dev/null
@@ -1,930 +0,0 @@
-"""A parser for XML, using the derived class as static DTD."""
-
-# Author: Sjoerd Mullender.
-
-import re
-import string
-
-import warnings
-warnings.warn("The xmllib module is obsolete. Use xml.sax instead.",
- DeprecationWarning, 2)
-del warnings
-
-version = '0.3'
-
-class Error(RuntimeError):
- pass
-
-# Regular expressions used for parsing
-
-_S = '[ \t\r\n]+' # white space
-_opS = '[ \t\r\n]*' # optional white space
-_Name = '[a-zA-Z_:][-a-zA-Z0-9._:]*' # valid XML name
-_QStr = "(?:'[^']*'|\"[^\"]*\")" # quoted XML string
-illegal = re.compile('[^\t\r\n -\176\240-\377]') # illegal chars in content
-interesting = re.compile('[]&<]')
-
-amp = re.compile('&')
-ref = re.compile('&(' + _Name + '|#[0-9]+|#x[0-9a-fA-F]+)[^-a-zA-Z0-9._:]')
-entityref = re.compile('&(?P<name>' + _Name + ')[^-a-zA-Z0-9._:]')
-charref = re.compile('&#(?P<char>[0-9]+[^0-9]|x[0-9a-fA-F]+[^0-9a-fA-F])')
-space = re.compile(_S + '$')
-newline = re.compile('\n')
-
-attrfind = re.compile(
- _S + '(?P<name>' + _Name + ')'
- '(' + _opS + '=' + _opS +
- '(?P<value>'+_QStr+'|[-a-zA-Z0-9.:+*%?!\(\)_#=~]+))?')
-starttagopen = re.compile('<' + _Name)
-starttagend = re.compile(_opS + '(?P<slash>/?)>')
-starttagmatch = re.compile('<(?P<tagname>'+_Name+')'
- '(?P<attrs>(?:'+attrfind.pattern+')*)'+
- starttagend.pattern)
-endtagopen = re.compile('</')
-endbracket = re.compile(_opS + '>')
-endbracketfind = re.compile('(?:[^>\'"]|'+_QStr+')*>')
-tagfind = re.compile(_Name)
-cdataopen = re.compile(r'<!\[CDATA\[')
-cdataclose = re.compile(r'\]\]>')
-# this matches one of the following:
-# SYSTEM SystemLiteral
-# PUBLIC PubidLiteral SystemLiteral
-_SystemLiteral = '(?P<%s>'+_QStr+')'
-_PublicLiteral = '(?P<%s>"[-\'\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*"|' \
- "'[-\(\)+,./:=?;!*#@$_%% \n\ra-zA-Z0-9]*')"
-_ExternalId = '(?:SYSTEM|' \
- 'PUBLIC'+_S+_PublicLiteral%'pubid'+ \
- ')'+_S+_SystemLiteral%'syslit'
-doctype = re.compile('<!DOCTYPE'+_S+'(?P<name>'+_Name+')'
- '(?:'+_S+_ExternalId+')?'+_opS)
-xmldecl = re.compile('<\?xml'+_S+
- 'version'+_opS+'='+_opS+'(?P<version>'+_QStr+')'+
- '(?:'+_S+'encoding'+_opS+'='+_opS+
- "(?P<encoding>'[A-Za-z][-A-Za-z0-9._]*'|"
- '"[A-Za-z][-A-Za-z0-9._]*"))?'
- '(?:'+_S+'standalone'+_opS+'='+_opS+
- '(?P<standalone>\'(?:yes|no)\'|"(?:yes|no)"))?'+
- _opS+'\?>')
-procopen = re.compile(r'<\?(?P<proc>' + _Name + ')' + _opS)
-procclose = re.compile(_opS + r'\?>')
-commentopen = re.compile('<!--')
-commentclose = re.compile('-->')
-doubledash = re.compile('--')
-attrtrans = string.maketrans(' \r\n\t', ' ')
-
-# definitions for XML namespaces
-_NCName = '[a-zA-Z_][-a-zA-Z0-9._]*' # XML Name, minus the ":"
-ncname = re.compile(_NCName + '$')
-qname = re.compile('(?:(?P<prefix>' + _NCName + '):)?' # optional prefix
- '(?P<local>' + _NCName + ')$')
-
-xmlns = re.compile('xmlns(?::(?P<ncname>'+_NCName+'))?$')
-
-# XML parser base class -- find tags and call handler functions.
-# Usage: p = XMLParser(); p.feed(data); ...; p.close().
-# The dtd is defined by deriving a class which defines methods with
-# special names to handle tags: start_foo and end_foo to handle <foo>
-# and </foo>, respectively. The data between tags is passed to the
-# parser by calling self.handle_data() with some data as argument (the
-# data may be split up in arbitrary chunks).
-
-class XMLParser:
- attributes = {} # default, to be overridden
- elements = {} # default, to be overridden
-
- # parsing options, settable using keyword args in __init__
- __accept_unquoted_attributes = 0
- __accept_missing_endtag_name = 0
- __map_case = 0
- __accept_utf8 = 0
- __translate_attribute_references = 1
-
- # Interface -- initialize and reset this instance
- def __init__(self, **kw):
- self.__fixed = 0
- if 'accept_unquoted_attributes' in kw:
- self.__accept_unquoted_attributes = kw['accept_unquoted_attributes']
- if 'accept_missing_endtag_name' in kw:
- self.__accept_missing_endtag_name = kw['accept_missing_endtag_name']
- if 'map_case' in kw:
- self.__map_case = kw['map_case']
- if 'accept_utf8' in kw:
- self.__accept_utf8 = kw['accept_utf8']
- if 'translate_attribute_references' in kw:
- self.__translate_attribute_references = kw['translate_attribute_references']
- self.reset()
-
- def __fixelements(self):
- self.__fixed = 1
- self.elements = {}
- self.__fixdict(self.__dict__)
- self.__fixclass(self.__class__)
-
- def __fixclass(self, kl):
- self.__fixdict(kl.__dict__)
- for k in kl.__bases__:
- self.__fixclass(k)
-
- def __fixdict(self, dict):
- for key in dict.keys():
- if key[:6] == 'start_':
- tag = key[6:]
- start, end = self.elements.get(tag, (None, None))
- if start is None:
- self.elements[tag] = getattr(self, key), end
- elif key[:4] == 'end_':
- tag = key[4:]
- start, end = self.elements.get(tag, (None, None))
- if end is None:
- self.elements[tag] = start, getattr(self, key)
-
- # Interface -- reset this instance. Loses all unprocessed data
- def reset(self):
- self.rawdata = ''
- self.stack = []
- self.nomoretags = 0
- self.literal = 0
- self.lineno = 1
- self.__at_start = 1
- self.__seen_doctype = None
- self.__seen_starttag = 0
- self.__use_namespaces = 0
- self.__namespaces = {'xml':None} # xml is implicitly declared
- # backward compatibility hack: if elements not overridden,
- # fill it in ourselves
- if self.elements is XMLParser.elements:
- self.__fixelements()
-
- # For derived classes only -- enter literal mode (CDATA) till EOF
- def setnomoretags(self):
- self.nomoretags = self.literal = 1
-
- # For derived classes only -- enter literal mode (CDATA)
- def setliteral(self, *args):
- self.literal = 1
-
- # Interface -- feed some data to the parser. Call this as
- # often as you want, with as little or as much text as you
- # want (may include '\n'). (This just saves the text, all the
- # processing is done by goahead().)
- def feed(self, data):
- self.rawdata = self.rawdata + data
- self.goahead(0)
-
- # Interface -- handle the remaining data
- def close(self):
- self.goahead(1)
- if self.__fixed:
- self.__fixed = 0
- # remove self.elements so that we don't leak
- del self.elements
-
- # Interface -- translate references
- def translate_references(self, data, all = 1):
- if not self.__translate_attribute_references:
- return data
- i = 0
- while 1:
- res = amp.search(data, i)
- if res is None:
- return data
- s = res.start(0)
- res = ref.match(data, s)
- if res is None:
- self.syntax_error("bogus `&'")
- i = s+1
- continue
- i = res.end(0)
- str = res.group(1)
- rescan = 0
- if str[0] == '#':
- if str[1] == 'x':
- str = chr(int(str[2:], 16))
- else:
- str = chr(int(str[1:]))
- if data[i - 1] != ';':
- self.syntax_error("`;' missing after char reference")
- i = i-1
- elif all:
- if str in self.entitydefs:
- str = self.entitydefs[str]
- rescan = 1
- elif data[i - 1] != ';':
- self.syntax_error("bogus `&'")
- i = s + 1 # just past the &
- continue
- else:
- self.syntax_error("reference to unknown entity `&%s;'" % str)
- str = '&' + str + ';'
- elif data[i - 1] != ';':
- self.syntax_error("bogus `&'")
- i = s + 1 # just past the &
- continue
-
- # when we get here, str contains the translated text and i points
- # to the end of the string that is to be replaced
- data = data[:s] + str + data[i:]
- if rescan:
- i = s
- else:
- i = s + len(str)
-
- # Interface - return a dictionary of all namespaces currently valid
- def getnamespace(self):
- nsdict = {}
- for t, d, nst in self.stack:
- nsdict.update(d)
- return nsdict
-
- # Internal -- handle data as far as reasonable. May leave state
- # and data to be processed by a subsequent call. If 'end' is
- # true, force handling all data as if followed by EOF marker.
- def goahead(self, end):
- rawdata = self.rawdata
- i = 0
- n = len(rawdata)
- while i < n:
- if i > 0:
- self.__at_start = 0
- if self.nomoretags:
- data = rawdata[i:n]
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- i = n
- break
- res = interesting.search(rawdata, i)
- if res:
- j = res.start(0)
- else:
- j = n
- if i < j:
- data = rawdata[i:j]
- if self.__at_start and space.match(data) is None:
- self.syntax_error('illegal data at start of file')
- self.__at_start = 0
- if not self.stack and space.match(data) is None:
- self.syntax_error('data not in content')
- if not self.__accept_utf8 and illegal.search(data):
- self.syntax_error('illegal character in content')
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- i = j
- if i == n: break
- if rawdata[i] == '<':
- if starttagopen.match(rawdata, i):
- if self.literal:
- data = rawdata[i]
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- i = i+1
- continue
- k = self.parse_starttag(i)
- if k < 0: break
- self.__seen_starttag = 1
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- if endtagopen.match(rawdata, i):
- k = self.parse_endtag(i)
- if k < 0: break
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- if commentopen.match(rawdata, i):
- if self.literal:
- data = rawdata[i]
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- i = i+1
- continue
- k = self.parse_comment(i)
- if k < 0: break
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- if cdataopen.match(rawdata, i):
- k = self.parse_cdata(i)
- if k < 0: break
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- res = xmldecl.match(rawdata, i)
- if res:
- if not self.__at_start:
- self.syntax_error("<?xml?> declaration not at start of document")
- version, encoding, standalone = res.group('version',
- 'encoding',
- 'standalone')
- if version[1:-1] != '1.0':
- raise Error('only XML version 1.0 supported')
- if encoding: encoding = encoding[1:-1]
- if standalone: standalone = standalone[1:-1]
- self.handle_xml(encoding, standalone)
- i = res.end(0)
- continue
- res = procopen.match(rawdata, i)
- if res:
- k = self.parse_proc(i)
- if k < 0: break
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- res = doctype.match(rawdata, i)
- if res:
- if self.literal:
- data = rawdata[i]
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- i = i+1
- continue
- if self.__seen_doctype:
- self.syntax_error('multiple DOCTYPE elements')
- if self.__seen_starttag:
- self.syntax_error('DOCTYPE not at beginning of document')
- k = self.parse_doctype(res)
- if k < 0: break
- self.__seen_doctype = res.group('name')
- if self.__map_case:
- self.__seen_doctype = self.__seen_doctype.lower()
- self.lineno = self.lineno + rawdata[i:k].count('\n')
- i = k
- continue
- elif rawdata[i] == '&':
- if self.literal:
- data = rawdata[i]
- self.handle_data(data)
- i = i+1
- continue
- res = charref.match(rawdata, i)
- if res is not None:
- i = res.end(0)
- if rawdata[i-1] != ';':
- self.syntax_error("`;' missing in charref")
- i = i-1
- if not self.stack:
- self.syntax_error('data not in content')
- self.handle_charref(res.group('char')[:-1])
- self.lineno = self.lineno + res.group(0).count('\n')
- continue
- res = entityref.match(rawdata, i)
- if res is not None:
- i = res.end(0)
- if rawdata[i-1] != ';':
- self.syntax_error("`;' missing in entityref")
- i = i-1
- name = res.group('name')
- if self.__map_case:
- name = name.lower()
- if name in self.entitydefs:
- self.rawdata = rawdata = rawdata[:res.start(0)] + self.entitydefs[name] + rawdata[i:]
- n = len(rawdata)
- i = res.start(0)
- else:
- self.unknown_entityref(name)
- self.lineno = self.lineno + res.group(0).count('\n')
- continue
- elif rawdata[i] == ']':
- if self.literal:
- data = rawdata[i]
- self.handle_data(data)
- i = i+1
- continue
- if n-i < 3:
- break
- if cdataclose.match(rawdata, i):
- self.syntax_error("bogus `]]>'")
- self.handle_data(rawdata[i])
- i = i+1
- continue
- else:
- raise Error('neither < nor & ??')
- # We get here only if incomplete matches but
- # nothing else
- break
- # end while
- if i > 0:
- self.__at_start = 0
- if end and i < n:
- data = rawdata[i]
- self.syntax_error("bogus `%s'" % data)
- if not self.__accept_utf8 and illegal.search(data):
- self.syntax_error('illegal character in content')
- self.handle_data(data)
- self.lineno = self.lineno + data.count('\n')
- self.rawdata = rawdata[i+1:]
- return self.goahead(end)
- self.rawdata = rawdata[i:]
- if end:
- if not self.__seen_starttag:
- self.syntax_error('no elements in file')
- if self.stack:
- self.syntax_error('missing end tags')
- while self.stack:
- self.finish_endtag(self.stack[-1][0])
-
- # Internal -- parse comment, return length or -1 if not terminated
- def parse_comment(self, i):
- rawdata = self.rawdata
- if rawdata[i:i+4] != '<!--':
- raise Error('unexpected call to handle_comment')
- res = commentclose.search(rawdata, i+4)
- if res is None:
- return -1
- if doubledash.search(rawdata, i+4, res.start(0)):
- self.syntax_error("`--' inside comment")
- if rawdata[res.start(0)-1] == '-':
- self.syntax_error('comment cannot end in three dashes')
- if not self.__accept_utf8 and \
- illegal.search(rawdata, i+4, res.start(0)):
- self.syntax_error('illegal character in comment')
- self.handle_comment(rawdata[i+4: res.start(0)])
- return res.end(0)
-
- # Internal -- handle DOCTYPE tag, return length or -1 if not terminated
- def parse_doctype(self, res):
- rawdata = self.rawdata
- n = len(rawdata)
- name = res.group('name')
- if self.__map_case:
- name = name.lower()
- pubid, syslit = res.group('pubid', 'syslit')
- if pubid is not None:
- pubid = pubid[1:-1] # remove quotes
- pubid = ' '.join(pubid.split()) # normalize
- if syslit is not None: syslit = syslit[1:-1] # remove quotes
- j = k = res.end(0)
- if k >= n:
- return -1
- if rawdata[k] == '[':
- level = 0
- k = k+1
- dq = sq = 0
- while k < n:
- c = rawdata[k]
- if not sq and c == '"':
- dq = not dq
- elif not dq and c == "'":
- sq = not sq
- elif sq or dq:
- pass
- elif level <= 0 and c == ']':
- res = endbracket.match(rawdata, k+1)
- if res is None:
- return -1
- self.handle_doctype(name, pubid, syslit, rawdata[j+1:k])
- return res.end(0)
- elif c == '<':
- level = level + 1
- elif c == '>':
- level = level - 1
- if level < 0:
- self.syntax_error("bogus `>' in DOCTYPE")
- k = k+1
- res = endbracketfind.match(rawdata, k)
- if res is None:
- return -1
- if endbracket.match(rawdata, k) is None:
- self.syntax_error('garbage in DOCTYPE')
- self.handle_doctype(name, pubid, syslit, None)
- return res.end(0)
-
- # Internal -- handle CDATA tag, return length or -1 if not terminated
- def parse_cdata(self, i):
- rawdata = self.rawdata
- if rawdata[i:i+9] != '<![CDATA[':
- raise Error('unexpected call to parse_cdata')
- res = cdataclose.search(rawdata, i+9)
- if res is None:
- return -1
- if not self.__accept_utf8 and \
- illegal.search(rawdata, i+9, res.start(0)):
- self.syntax_error('illegal character in CDATA')
- if not self.stack:
- self.syntax_error('CDATA not in content')
- self.handle_cdata(rawdata[i+9:res.start(0)])
- return res.end(0)
-
- __xml_namespace_attributes = {'ns':None, 'src':None, 'prefix':None}
- # Internal -- handle a processing instruction tag
- def parse_proc(self, i):
- rawdata = self.rawdata
- end = procclose.search(rawdata, i)
- if end is None:
- return -1
- j = end.start(0)
- if not self.__accept_utf8 and illegal.search(rawdata, i+2, j):
- self.syntax_error('illegal character in processing instruction')
- res = tagfind.match(rawdata, i+2)
- if res is None:
- raise Error('unexpected call to parse_proc')
- k = res.end(0)
- name = res.group(0)
- if self.__map_case:
- name = name.lower()
- if name == 'xml:namespace':
- self.syntax_error('old-fashioned namespace declaration')
- self.__use_namespaces = -1
- # namespace declaration
- # this must come after the <?xml?> declaration (if any)
- # and before the <!DOCTYPE> (if any).
- if self.__seen_doctype or self.__seen_starttag:
- self.syntax_error('xml:namespace declaration too late in document')
- attrdict, namespace, k = self.parse_attributes(name, k, j)
- if namespace:
- self.syntax_error('namespace declaration inside namespace declaration')
- for attrname in attrdict.keys():
- if not attrname in self.__xml_namespace_attributes:
- self.syntax_error("unknown attribute `%s' in xml:namespace tag" % attrname)
- if not 'ns' in attrdict or not 'prefix' in attrdict:
- self.syntax_error('xml:namespace without required attributes')
- prefix = attrdict.get('prefix')
- if ncname.match(prefix) is None:
- self.syntax_error('xml:namespace illegal prefix value')
- return end.end(0)
- if prefix in self.__namespaces:
- self.syntax_error('xml:namespace prefix not unique')
- self.__namespaces[prefix] = attrdict['ns']
- else:
- if name.lower() == 'xml':
- self.syntax_error('illegal processing instruction target name')
- self.handle_proc(name, rawdata[k:j])
- return end.end(0)
-
- # Internal -- parse attributes between i and j
- def parse_attributes(self, tag, i, j):
- rawdata = self.rawdata
- attrdict = {}
- namespace = {}
- while i < j:
- res = attrfind.match(rawdata, i)
- if res is None:
- break
- attrname, attrvalue = res.group('name', 'value')
- if self.__map_case:
- attrname = attrname.lower()
- i = res.end(0)
- if attrvalue is None:
- self.syntax_error("no value specified for attribute `%s'" % attrname)
- attrvalue = attrname
- elif attrvalue[:1] == "'" == attrvalue[-1:] or \
- attrvalue[:1] == '"' == attrvalue[-1:]:
- attrvalue = attrvalue[1:-1]
- elif not self.__accept_unquoted_attributes:
- self.syntax_error("attribute `%s' value not quoted" % attrname)
- res = xmlns.match(attrname)
- if res is not None:
- # namespace declaration
- ncname = res.group('ncname')
- namespace[ncname or ''] = attrvalue or None
- if not self.__use_namespaces:
- self.__use_namespaces = len(self.stack)+1
- continue
- if '<' in attrvalue:
- self.syntax_error("`<' illegal in attribute value")
- if attrname in attrdict:
- self.syntax_error("attribute `%s' specified twice" % attrname)
- attrvalue = attrvalue.translate(attrtrans)
- attrdict[attrname] = self.translate_references(attrvalue)
- return attrdict, namespace, i
-
- # Internal -- handle starttag, return length or -1 if not terminated
- def parse_starttag(self, i):
- rawdata = self.rawdata
- # i points to start of tag
- end = endbracketfind.match(rawdata, i+1)
- if end is None:
- return -1
- tag = starttagmatch.match(rawdata, i)
- if tag is None or tag.end(0) != end.end(0):
- self.syntax_error('garbage in starttag')
- return end.end(0)
- nstag = tagname = tag.group('tagname')
- if self.__map_case:
- nstag = tagname = nstag.lower()
- if not self.__seen_starttag and self.__seen_doctype and \
- tagname != self.__seen_doctype:
- self.syntax_error('starttag does not match DOCTYPE')
- if self.__seen_starttag and not self.stack:
- self.syntax_error('multiple elements on top level')
- k, j = tag.span('attrs')
- attrdict, nsdict, k = self.parse_attributes(tagname, k, j)
- self.stack.append((tagname, nsdict, nstag))
- if self.__use_namespaces:
- res = qname.match(tagname)
- else:
- res = None
- if res is not None:
- prefix, nstag = res.group('prefix', 'local')
- if prefix is None:
- prefix = ''
- ns = None
- for t, d, nst in self.stack:
- if prefix in d:
- ns = d[prefix]
- if ns is None and prefix != '':
- ns = self.__namespaces.get(prefix)
- if ns is not None:
- nstag = ns + ' ' + nstag
- elif prefix != '':
- nstag = prefix + ':' + nstag # undo split
- self.stack[-1] = tagname, nsdict, nstag
- # translate namespace of attributes
- attrnamemap = {} # map from new name to old name (used for error reporting)
- for key in attrdict.keys():
- attrnamemap[key] = key
- if self.__use_namespaces:
- nattrdict = {}
- for key, val in attrdict.items():
- okey = key
- res = qname.match(key)
- if res is not None:
- aprefix, key = res.group('prefix', 'local')
- if self.__map_case:
- key = key.lower()
- if aprefix is not None:
- ans = None
- for t, d, nst in self.stack:
- if aprefix in d:
- ans = d[aprefix]
- if ans is None:
- ans = self.__namespaces.get(aprefix)
- if ans is not None:
- key = ans + ' ' + key
- else:
- key = aprefix + ':' + key
- nattrdict[key] = val
- attrnamemap[key] = okey
- attrdict = nattrdict
- attributes = self.attributes.get(nstag)
- if attributes is not None:
- for key in attrdict.keys():
- if not key in attributes:
- self.syntax_error("unknown attribute `%s' in tag `%s'" % (attrnamemap[key], tagname))
- for key, val in attributes.items():
- if val is not None and not key in attrdict:
- attrdict[key] = val
- method = self.elements.get(nstag, (None, None))[0]
- self.finish_starttag(nstag, attrdict, method)
- if tag.group('slash') == '/':
- self.finish_endtag(tagname)
- return tag.end(0)
-
- # Internal -- parse endtag
- def parse_endtag(self, i):
- rawdata = self.rawdata
- end = endbracketfind.match(rawdata, i+1)
- if end is None:
- return -1
- res = tagfind.match(rawdata, i+2)
- if res is None:
- if self.literal:
- self.handle_data(rawdata[i])
- return i+1
- if not self.__accept_missing_endtag_name:
- self.syntax_error('no name specified in end tag')
- tag = self.stack[-1][0]
- k = i+2
- else:
- tag = res.group(0)
- if self.__map_case:
- tag = tag.lower()
- if self.literal:
- if not self.stack or tag != self.stack[-1][0]:
- self.handle_data(rawdata[i])
- return i+1
- k = res.end(0)
- if endbracket.match(rawdata, k) is None:
- self.syntax_error('garbage in end tag')
- self.finish_endtag(tag)
- return end.end(0)
-
- # Internal -- finish processing of start tag
- def finish_starttag(self, tagname, attrdict, method):
- if method is not None:
- self.handle_starttag(tagname, method, attrdict)
- else:
- self.unknown_starttag(tagname, attrdict)
-
- # Internal -- finish processing of end tag
- def finish_endtag(self, tag):
- self.literal = 0
- if not tag:
- self.syntax_error('name-less end tag')
- found = len(self.stack) - 1
- if found < 0:
- self.unknown_endtag(tag)
- return
- else:
- found = -1
- for i in range(len(self.stack)):
- if tag == self.stack[i][0]:
- found = i
- if found == -1:
- self.syntax_error('unopened end tag')
- return
- while len(self.stack) > found:
- if found < len(self.stack) - 1:
- self.syntax_error('missing close tag for %s' % self.stack[-1][2])
- nstag = self.stack[-1][2]
- method = self.elements.get(nstag, (None, None))[1]
- if method is not None:
- self.handle_endtag(nstag, method)
- else:
- self.unknown_endtag(nstag)
- if self.__use_namespaces == len(self.stack):
- self.__use_namespaces = 0
- del self.stack[-1]
-
- # Overridable -- handle xml processing instruction
- def handle_xml(self, encoding, standalone):
- pass
-
- # Overridable -- handle DOCTYPE
- def handle_doctype(self, tag, pubid, syslit, data):
- pass
-
- # Overridable -- handle start tag
- def handle_starttag(self, tag, method, attrs):
- method(attrs)
-
- # Overridable -- handle end tag
- def handle_endtag(self, tag, method):
- method()
-
- # Example -- handle character reference, no need to override
- def handle_charref(self, name):
- try:
- if name[0] == 'x':
- n = int(name[1:], 16)
- else:
- n = int(name)
- except ValueError:
- self.unknown_charref(name)
- return
- if not 0 <= n <= 255:
- self.unknown_charref(name)
- return
- self.handle_data(chr(n))
-
- # Definition of entities -- derived classes may override
- entitydefs = {'lt': '&#60;', # must use charref
- 'gt': '&#62;',
- 'amp': '&#38;', # must use charref
- 'quot': '&#34;',
- 'apos': '&#39;',
- }
-
- # Example -- handle data, should be overridden
- def handle_data(self, data):
- pass
-
- # Example -- handle cdata, could be overridden
- def handle_cdata(self, data):
- pass
-
- # Example -- handle comment, could be overridden
- def handle_comment(self, data):
- pass
-
- # Example -- handle processing instructions, could be overridden
- def handle_proc(self, name, data):
- pass
-
- # Example -- handle relatively harmless syntax errors, could be overridden
- def syntax_error(self, message):
- raise Error('Syntax error at line %d: %s' % (self.lineno, message))
-
- # To be overridden -- handlers for unknown objects
- def unknown_starttag(self, tag, attrs): pass
- def unknown_endtag(self, tag): pass
- def unknown_charref(self, ref): pass
- def unknown_entityref(self, name):
- self.syntax_error("reference to unknown entity `&%s;'" % name)
-
-
-class TestXMLParser(XMLParser):
-
- def __init__(self, **kw):
- self.testdata = ""
- XMLParser.__init__(self, **kw)
-
- def handle_xml(self, encoding, standalone):
- self.flush()
- print 'xml: encoding =',encoding,'standalone =',standalone
-
- def handle_doctype(self, tag, pubid, syslit, data):
- self.flush()
- print 'DOCTYPE:',tag, repr(data)
-
- def handle_data(self, data):
- self.testdata = self.testdata + data
- if len(repr(self.testdata)) >= 70:
- self.flush()
-
- def flush(self):
- data = self.testdata
- if data:
- self.testdata = ""
- print 'data:', repr(data)
-
- def handle_cdata(self, data):
- self.flush()
- print 'cdata:', repr(data)
-
- def handle_proc(self, name, data):
- self.flush()
- print 'processing:',name,repr(data)
-
- def handle_comment(self, data):
- self.flush()
- r = repr(data)
- if len(r) > 68:
- r = r[:32] + '...' + r[-32:]
- print 'comment:', r
-
- def syntax_error(self, message):
- print 'error at line %d:' % self.lineno, message
-
- def unknown_starttag(self, tag, attrs):
- self.flush()
- if not attrs:
- print 'start tag: <' + tag + '>'
- else:
- print 'start tag: <' + tag,
- for name, value in attrs.items():
- print name + '=' + '"' + value + '"',
- print '>'
-
- def unknown_endtag(self, tag):
- self.flush()
- print 'end tag: </' + tag + '>'
-
- def unknown_entityref(self, ref):
- self.flush()
- print '*** unknown entity ref: &' + ref + ';'
-
- def unknown_charref(self, ref):
- self.flush()
- print '*** unknown char ref: &#' + ref + ';'
-
- def close(self):
- XMLParser.close(self)
- self.flush()
-
-def test(args = None):
- import sys, getopt
- from time import time
-
- if not args:
- args = sys.argv[1:]
-
- opts, args = getopt.getopt(args, 'st')
- klass = TestXMLParser
- do_time = 0
- for o, a in opts:
- if o == '-s':
- klass = XMLParser
- elif o == '-t':
- do_time = 1
-
- if args:
- file = args[0]
- else:
- file = 'test.xml'
-
- if file == '-':
- f = sys.stdin
- else:
- try:
- f = open(file, 'r')
- except IOError, msg:
- print file, ":", msg
- sys.exit(1)
-
- data = f.read()
- if f is not sys.stdin:
- f.close()
-
- x = klass()
- t0 = time()
- try:
- if do_time:
- x.feed(data)
- x.close()
- else:
- for c in data:
- x.feed(c)
- x.close()
- except Error, msg:
- t1 = time()
- print msg
- if do_time:
- print 'total time: %g' % (t1-t0)
- sys.exit(1)
- t1 = time()
- if do_time:
- print 'total time: %g' % (t1-t0)
-
-
-if __name__ == '__main__':
- test()
diff --git a/Lib/xmlrpc/__init__.py b/Lib/xmlrpc/__init__.py
new file mode 100644
index 00000000000..196d3788575
--- /dev/null
+++ b/Lib/xmlrpc/__init__.py
@@ -0,0 +1 @@
+# This directory is a Python package.
diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpc/client.py
index b93ea23b929..ec8d8e92d6f 100644
--- a/Lib/xmlrpclib.py
+++ b/Lib/xmlrpc/client.py
@@ -85,11 +85,6 @@
# OF THIS SOFTWARE.
# --------------------------------------------------------------------
-#
-# things to look into some day:
-
-# TODO: sort out True/False/boolean issues for Python 2.3
-
"""
An XML-RPC client interface for Python.
@@ -108,13 +103,11 @@ Exported classes:
ServerProxy Represents a logical connection to an XML-RPC server
MultiCall Executor of boxcared xmlrpc requests
- Boolean boolean wrapper to generate a "boolean" XML-RPC value
DateTime dateTime wrapper for an ISO 8601 string or time tuple or
localtime integer value to generate a "dateTime.iso8601"
XML-RPC value
Binary binary data wrapper
- SlowParser Slow but safe standard parser (based on xmllib)
Marshaller Generate an XML-RPC params chunk from a Python data structure
Unmarshaller Unmarshal an XML-RPC response from incoming XML event message
Transport Handles an HTTP transaction to an XML-RPC server
@@ -122,12 +115,10 @@ Exported classes:
Exported constants:
- True
- False
+ (none)
Exported functions:
- boolean Convert any Python value to an XML-RPC boolean
getparser Create instance of the fastest available parser & attach
to an unmarshalling object
dumps Convert an argument tuple or a Fault instance to an XML-RPC
@@ -136,12 +127,13 @@ Exported functions:
name (None if not present).
"""
-import re, string, time, operator
-
-from types import *
+import base64
+import time
+import http.client
+from xml.parsers import expat
import socket
import errno
-import httplib
+from io import BytesIO
try:
import gzip
except ImportError:
@@ -151,47 +143,20 @@ except ImportError:
# Internal stuff
try:
- unicode
-except NameError:
- unicode = None # unicode support not available
-
-try:
import datetime
except ImportError:
datetime = None
-try:
- _bool_is_builtin = False.__class__.__name__ == "bool"
-except NameError:
- _bool_is_builtin = 0
-
-def _decode(data, encoding, is8bit=re.compile("[\x80-\xff]").search):
- # decode non-ascii string (if possible)
- if unicode and encoding and is8bit(data):
- data = unicode(data, encoding)
- return data
-
-def escape(s, replace=string.replace):
- s = replace(s, "&", "&amp;")
- s = replace(s, "<", "&lt;")
- return replace(s, ">", "&gt;",)
-
-if unicode:
- def _stringify(string):
- # convert to 7-bit ascii if possible
- try:
- return string.encode("ascii")
- except UnicodeError:
- return string
-else:
- def _stringify(string):
- return string
+def escape(s):
+ s = s.replace("&", "&amp;")
+ s = s.replace("<", "&lt;")
+ return s.replace(">", "&gt;",)
__version__ = "1.0.1"
# xmlrpc integer limits
-MAXINT = 2L**31-1
-MININT = -2L**31
+MAXINT = 2**31-1
+MININT = -2**31
# --------------------------------------------------------------------
# Error constants (from Dan Libby's specification at
@@ -260,7 +225,7 @@ class ResponseError(Error):
##
# Indicates an XML-RPC fault response package. This exception is
# raised by the unmarshalling layer, if the XML-RPC response contains
-# a fault string. This exception can also used as a class, to
+# a fault string. This exception can also be used as a class, to
# generate a fault XML-RPC message.
#
# @param faultCode The XML-RPC fault code.
@@ -273,78 +238,15 @@ class Fault(Error):
self.faultCode = faultCode
self.faultString = faultString
def __repr__(self):
- return (
- "<Fault %s: %s>" %
- (self.faultCode, repr(self.faultString))
- )
+ return "<Fault %s: %r>" % (self.faultCode, self.faultString)
# --------------------------------------------------------------------
# Special values
##
-# Wrapper for XML-RPC boolean values. Use the xmlrpclib.True and
-# xmlrpclib.False constants, or the xmlrpclib.boolean() function, to
-# generate boolean XML-RPC values.
-#
-# @param value A boolean value. Any true value is interpreted as True,
-# all other values are interpreted as False.
-
-from sys import modules
-mod_dict = modules[__name__].__dict__
-if _bool_is_builtin:
- boolean = Boolean = bool
- # to avoid breaking code which references xmlrpclib.{True,False}
- mod_dict['True'] = True
- mod_dict['False'] = False
-else:
- class Boolean:
- """Boolean-value wrapper.
-
- Use True or False to generate a "boolean" XML-RPC value.
- """
-
- def __init__(self, value = 0):
- self.value = operator.truth(value)
+# Backwards compatibility
- def encode(self, out):
- out.write("<value><boolean>%d</boolean></value>\n" % self.value)
-
- def __cmp__(self, other):
- if isinstance(other, Boolean):
- other = other.value
- return cmp(self.value, other)
-
- def __repr__(self):
- if self.value:
- return "<Boolean True at %x>" % id(self)
- else:
- return "<Boolean False at %x>" % id(self)
-
- def __int__(self):
- return self.value
-
- def __nonzero__(self):
- return self.value
-
- mod_dict['True'] = Boolean(1)
- mod_dict['False'] = Boolean(0)
-
- ##
- # Map true or false value to XML-RPC boolean values.
- #
- # @def boolean(value)
- # @param value A boolean value. Any true value is mapped to True,
- # all other values are mapped to False.
- # @return xmlrpclib.True or xmlrpclib.False.
- # @see Boolean
- # @see True
- # @see False
-
- def boolean(value, _truefalse=(False, True)):
- """Convert any Python value to XML-RPC 'boolean'."""
- return _truefalse[operator.truth(value)]
-
-del modules, mod_dict
+boolean = Boolean = bool
##
# Wrapper for XML-RPC DateTime values. This converts a time value to
@@ -366,7 +268,7 @@ def _strftime(value):
value.year, value.month, value.day,
value.hour, value.minute, value.second)
- if not isinstance(value, (TupleType, time.struct_time)):
+ if not isinstance(value, (tuple, time.struct_time)):
if value == 0:
value = time.time()
value = time.localtime(value)
@@ -380,7 +282,7 @@ class DateTime:
"""
def __init__(self, value=0):
- if isinstance(value, StringType):
+ if isinstance(value, str):
self.value = value
else:
self.value = _strftime(value)
@@ -392,7 +294,7 @@ class DateTime:
elif datetime and isinstance(other, datetime.datetime):
s = self.value
o = other.strftime("%Y%m%dT%H:%M:%S")
- elif isinstance(other, (str, unicode)):
+ elif isinstance(other, str):
s = self.value
o = other
elif hasattr(other, "timetuple"):
@@ -433,10 +335,6 @@ class DateTime:
def timetuple(self):
return time.strptime(self.value, "%Y%m%dT%H:%M:%S")
- def __cmp__(self, other):
- s, o = self.make_comparable(other)
- return cmp(s, o)
-
##
# Get date/time value.
#
@@ -446,11 +344,10 @@ class DateTime:
return self.value
def __repr__(self):
- return "<DateTime %s at %x>" % (repr(self.value), id(self))
+ return "<DateTime %r at %x>" % (self.value, id(self))
def decode(self, data):
- data = str(data)
- self.value = string.strip(data)
+ self.value = str(data).strip()
def encode(self, out):
out.write("<value><dateTime.iso8601>")
@@ -473,16 +370,17 @@ def _datetime_type(data):
#
# @param data An 8-bit string containing arbitrary data.
-import base64
-try:
- import cStringIO as StringIO
-except ImportError:
- import StringIO
-
class Binary:
"""Wrapper for binary data."""
def __init__(self, data=None):
+ if data is None:
+ data = b""
+ else:
+ if not isinstance(data, bytes):
+ raise TypeError("expected bytes, not %s" %
+ data.__class__.__name__)
+ data = bytes(data) # Make a copy of the bytes!
self.data = data
##
@@ -491,19 +389,26 @@ class Binary:
# @return Buffer contents, as an 8-bit string.
def __str__(self):
- return self.data or ""
+ return str(self.data, "latin-1") # XXX encoding?!
- def __cmp__(self, other):
+ def __eq__(self, other):
if isinstance(other, Binary):
other = other.data
- return cmp(self.data, other)
+ return self.data == other
+
+ def __ne__(self, other):
+ if isinstance(other, Binary):
+ other = other.data
+ return self.data != other
def decode(self, data):
- self.data = base64.decodestring(data)
+ self.data = base64.decodebytes(data)
def encode(self, out):
out.write("<value><base64>\n")
- base64.encode(StringIO.StringIO(self.data), out)
+ encoded = base64.encodebytes(self.data)
+ out.write(encoded.decode('ascii'))
+ out.write('\n')
out.write("</base64></value>\n")
def _binary(data):
@@ -513,69 +418,27 @@ def _binary(data):
return value
WRAPPERS = (DateTime, Binary)
-if not _bool_is_builtin:
- WRAPPERS = WRAPPERS + (Boolean,)
# --------------------------------------------------------------------
# XML parsers
-try:
- # optional xmlrpclib accelerator
- import _xmlrpclib
- FastParser = _xmlrpclib.Parser
- FastUnmarshaller = _xmlrpclib.Unmarshaller
-except (AttributeError, ImportError):
- FastParser = FastUnmarshaller = None
+class ExpatParser:
+ # fast expat parser for Python 2.0 and later.
+ def __init__(self, target):
+ self._parser = parser = expat.ParserCreate(None, None)
+ self._target = target
+ parser.StartElementHandler = target.start
+ parser.EndElementHandler = target.end
+ parser.CharacterDataHandler = target.data
+ encoding = None
+ target.xml(encoding, None)
-try:
- import _xmlrpclib
- FastMarshaller = _xmlrpclib.Marshaller
-except (AttributeError, ImportError):
- FastMarshaller = None
+ def feed(self, data):
+ self._parser.Parse(data, 0)
-try:
- from xml.parsers import expat
- if not hasattr(expat, "ParserCreate"):
- raise ImportError
-except ImportError:
- ExpatParser = None # expat not available
-else:
- class ExpatParser:
- # fast expat parser for Python 2.0 and later.
- def __init__(self, target):
- self._parser = parser = expat.ParserCreate(None, None)
- self._target = target
- parser.StartElementHandler = target.start
- parser.EndElementHandler = target.end
- parser.CharacterDataHandler = target.data
- encoding = None
- if not parser.returns_unicode:
- encoding = "utf-8"
- target.xml(encoding, None)
-
- def feed(self, data):
- self._parser.Parse(data, 0)
-
- def close(self):
- self._parser.Parse("", 1) # end of data
- del self._target, self._parser # get rid of circular references
-
-class SlowParser:
- """Default XML parser (based on xmllib.XMLParser)."""
- # this is the slowest parser.
- def __init__(self, target):
- import xmllib # lazy subclassing (!)
- if xmllib.XMLParser not in SlowParser.__bases__:
- SlowParser.__bases__ = (xmllib.XMLParser,)
- self.handle_xml = target.xml
- self.unknown_starttag = target.start
- self.handle_data = target.data
- self.handle_cdata = target.data
- self.unknown_endtag = target.end
- try:
- xmllib.XMLParser.__init__(self, accept_utf8=1)
- except TypeError:
- xmllib.XMLParser.__init__(self) # pre-2.0
+ def close(self):
+ self._parser.Parse("", 1) # end of data
+ del self._target, self._parser # get rid of circular references
# --------------------------------------------------------------------
# XML-RPC marshalling and unmarshalling code
@@ -600,7 +463,7 @@ class Marshaller:
# by the way, if you don't understand what's going on in here,
# that's perfectly ok.
- def __init__(self, encoding=None, allow_none=0):
+ def __init__(self, encoding=None, allow_none=False):
self.memo = {}
self.data = None
self.encoding = encoding
@@ -632,7 +495,7 @@ class Marshaller:
dump(v, write)
write("</param>\n")
write("</params>\n")
- result = string.join(out, "")
+ result = "".join(out)
return result
def __dump(self, value, write):
@@ -640,73 +503,64 @@ class Marshaller:
f = self.dispatch[type(value)]
except KeyError:
# check if this object can be marshalled as a structure
- try:
- value.__dict__
- except:
- raise TypeError, "cannot marshal %s objects" % type(value)
+ if not hasattr(value, '__dict__'):
+ raise TypeError("cannot marshal %s objects" % type(value))
# check if this class is a sub-class of a basic type,
# because we don't know how to marshal these types
# (e.g. a string sub-class)
for type_ in type(value).__mro__:
if type_ in self.dispatch.keys():
- raise TypeError, "cannot marshal %s objects" % type(value)
- f = self.dispatch[InstanceType]
+ raise TypeError("cannot marshal %s objects" % type(value))
+ # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix
+ # for the p3yk merge, this should probably be fixed more neatly.
+ f = self.dispatch["_arbitrary_instance"]
f(self, value, write)
def dump_nil (self, value, write):
if not self.allow_none:
- raise TypeError, "cannot marshal None unless allow_none is enabled"
+ raise TypeError("cannot marshal None unless allow_none is enabled")
write("<value><nil/></value>")
- dispatch[NoneType] = dump_nil
+ dispatch[type(None)] = dump_nil
def dump_int(self, value, write):
# in case ints are > 32 bits
if value > MAXINT or value < MININT:
- raise OverflowError, "int exceeds XML-RPC limits"
+ raise OverflowError("int exceeds XML-RPC limits")
write("<value><int>")
write(str(value))
write("</int></value>\n")
- dispatch[IntType] = dump_int
+ #dispatch[int] = dump_int
- if _bool_is_builtin:
- def dump_bool(self, value, write):
- write("<value><boolean>")
- write(value and "1" or "0")
- write("</boolean></value>\n")
- dispatch[bool] = dump_bool
+ def dump_bool(self, value, write):
+ write("<value><boolean>")
+ write(value and "1" or "0")
+ write("</boolean></value>\n")
+ dispatch[bool] = dump_bool
def dump_long(self, value, write):
if value > MAXINT or value < MININT:
- raise OverflowError, "long int exceeds XML-RPC limits"
+ raise OverflowError("long int exceeds XML-RPC limits")
write("<value><int>")
write(str(int(value)))
write("</int></value>\n")
- dispatch[LongType] = dump_long
+ dispatch[int] = dump_long
def dump_double(self, value, write):
write("<value><double>")
write(repr(value))
write("</double></value>\n")
- dispatch[FloatType] = dump_double
+ dispatch[float] = dump_double
- def dump_string(self, value, write, escape=escape):
+ def dump_unicode(self, value, write, escape=escape):
write("<value><string>")
write(escape(value))
write("</string></value>\n")
- dispatch[StringType] = dump_string
-
- if unicode:
- def dump_unicode(self, value, write, escape=escape):
- value = value.encode(self.encoding)
- write("<value><string>")
- write(escape(value))
- write("</string></value>\n")
- dispatch[UnicodeType] = dump_unicode
+ dispatch[str] = dump_unicode
def dump_array(self, value, write):
i = id(value)
if i in self.memo:
- raise TypeError, "cannot marshal recursive sequences"
+ raise TypeError("cannot marshal recursive sequences")
self.memo[i] = None
dump = self.__dump
write("<value><array><data>\n")
@@ -714,29 +568,26 @@ class Marshaller:
dump(v, write)
write("</data></array></value>\n")
del self.memo[i]
- dispatch[TupleType] = dump_array
- dispatch[ListType] = dump_array
+ dispatch[tuple] = dump_array
+ dispatch[list] = dump_array
def dump_struct(self, value, write, escape=escape):
i = id(value)
if i in self.memo:
- raise TypeError, "cannot marshal recursive dictionaries"
+ raise TypeError("cannot marshal recursive dictionaries")
self.memo[i] = None
dump = self.__dump
write("<value><struct>\n")
for k, v in value.items():
write("<member>\n")
- if type(k) is not StringType:
- if unicode and type(k) is UnicodeType:
- k = k.encode(self.encoding)
- else:
- raise TypeError, "dictionary key must be string"
+ if not isinstance(k, str):
+ raise TypeError("dictionary key must be string")
write("<name>%s</name>\n" % escape(k))
dump(v, write)
write("</member>\n")
write("</struct></value>\n")
del self.memo[i]
- dispatch[DictType] = dump_struct
+ dispatch[dict] = dump_struct
if datetime:
def dump_datetime(self, value, write):
@@ -754,7 +605,11 @@ class Marshaller:
else:
# store instance attributes as a struct (really?)
self.dump_struct(value.__dict__, write)
- dispatch[InstanceType] = dump_instance
+ dispatch[DateTime] = dump_instance
+ dispatch[Binary] = dump_instance
+ # XXX(twouters): using "_arbitrary_instance" as key as a quick-fix
+ # for the p3yk merge, this should probably be fixed more neatly.
+ dispatch["_arbitrary_instance"] = dump_instance
##
# XML-RPC unmarshaller.
@@ -773,7 +628,7 @@ class Unmarshaller:
# and again, if you don't understand what's going on in here,
# that's perfectly ok.
- def __init__(self, use_datetime=0):
+ def __init__(self, use_datetime=False):
self._type = None
self._stack = []
self._marks = []
@@ -783,7 +638,7 @@ class Unmarshaller:
self.append = self._stack.append
self._use_datetime = use_datetime
if use_datetime and not datetime:
- raise ValueError, "the datetime module is not available"
+ raise ValueError("the datetime module is not available")
def close(self):
# return response tuple and target method
@@ -813,14 +668,14 @@ class Unmarshaller:
def data(self, text):
self._data.append(text)
- def end(self, tag, join=string.join):
+ def end(self, tag):
# call the appropriate end tag handler
try:
f = self.dispatch[tag]
except KeyError:
pass # unknown tag ?
else:
- return f(self, join(self._data, ""))
+ return f(self, "".join(self._data))
#
# accelerator support
@@ -850,7 +705,7 @@ class Unmarshaller:
elif data == "1":
self.append(True)
else:
- raise TypeError, "bad boolean value"
+ raise TypeError("bad boolean value")
self._value = 0
dispatch["boolean"] = end_boolean
@@ -868,8 +723,8 @@ class Unmarshaller:
def end_string(self, data):
if self._encoding:
- data = _decode(data, self._encoding)
- self.append(_stringify(data))
+ data = data.decode(self._encoding)
+ self.append(data)
self._value = 0
dispatch["string"] = end_string
dispatch["name"] = end_string # struct keys are always strings
@@ -887,14 +742,14 @@ class Unmarshaller:
dict = {}
items = self._stack[mark:]
for i in range(0, len(items), 2):
- dict[_stringify(items[i])] = items[i+1]
+ dict[items[i]] = items[i+1]
self._stack[mark:] = [dict]
self._value = 0
dispatch["struct"] = end_struct
def end_base64(self, data):
value = Binary()
- value.decode(data)
+ value.decode(data.encode("ascii"))
self.append(value)
self._value = 0
dispatch["base64"] = end_base64
@@ -924,7 +779,7 @@ class Unmarshaller:
def end_methodName(self, data):
if self._encoding:
- data = _decode(data, self._encoding)
+ data = data.decode(self._encoding)
self._methodname = data
self._type = "methodName" # no params
dispatch["methodName"] = end_methodName
@@ -957,8 +812,7 @@ class MultiCallIterator:
elif type(item) == type([]):
return item[0]
else:
- raise ValueError,\
- "unexpected type in multicall result"
+ raise ValueError("unexpected type in multicall result")
class MultiCall:
"""server -> a object used to boxcar method calls
@@ -999,20 +853,22 @@ class MultiCall:
# --------------------------------------------------------------------
# convenience functions
+FastMarshaller = FastParser = FastUnmarshaller = None
+
##
# Create a parser object, and connect it to an unmarshalling instance.
# This function picks the fastest available XML parser.
#
# return A (parser, unmarshaller) tuple.
-def getparser(use_datetime=0):
+def getparser(use_datetime=False):
"""getparser() -> parser, unmarshaller
Create an instance of the fastest available parser, and attach it
to an unmarshalling object. Return both objects.
"""
if use_datetime and not datetime:
- raise ValueError, "the datetime module is not available"
+ raise ValueError("the datetime module is not available")
if FastParser and FastUnmarshaller:
if use_datetime:
mkdatetime = _datetime_type
@@ -1024,10 +880,8 @@ def getparser(use_datetime=0):
target = Unmarshaller(use_datetime=use_datetime)
if FastParser:
parser = FastParser(target)
- elif ExpatParser:
- parser = ExpatParser(target)
else:
- parser = SlowParser(target)
+ parser = ExpatParser(target)
return parser, target
##
@@ -1044,7 +898,7 @@ def getparser(use_datetime=0):
# @return A string containing marshalled data.
def dumps(params, methodname=None, methodresponse=None, encoding=None,
- allow_none=0):
+ allow_none=False):
"""data [,options] -> marshalled data
Convert an argument tuple or a Fault instance to an XML-RPC
@@ -1066,12 +920,10 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
where necessary.
"""
- assert isinstance(params, TupleType) or isinstance(params, Fault),\
- "argument must be tuple or Fault instance"
-
+ assert isinstance(params, (tuple, Fault)), "argument must be tuple or Fault instance"
if isinstance(params, Fault):
methodresponse = 1
- elif methodresponse and isinstance(params, TupleType):
+ elif methodresponse and isinstance(params, tuple):
assert len(params) == 1, "response tuple must be a singleton"
if not encoding:
@@ -1092,7 +944,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
# standard XML-RPC wrappings
if methodname:
# a method call
- if not isinstance(methodname, StringType):
+ if not isinstance(methodname, str):
methodname = methodname.encode(encoding)
data = (
xmlheader,
@@ -1111,7 +963,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
)
else:
return data # return as is
- return string.join(data, "")
+ return "".join(data)
##
# Convert an XML-RPC packet to a Python object. If the XML-RPC packet
@@ -1122,7 +974,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
# (None if not present).
# @see Fault
-def loads(data, use_datetime=0):
+def loads(data, use_datetime=False):
"""data -> unmarshalled data, method name
Convert an XML-RPC packet to unmarshalled data plus a method
@@ -1151,7 +1003,7 @@ def gzip_encode(data):
"""
if not gzip:
raise NotImplementedError
- f = StringIO.StringIO()
+ f = BytesIO()
gzf = gzip.GzipFile(mode="wb", fileobj=f, compresslevel=1)
gzf.write(data)
gzf.close()
@@ -1175,7 +1027,7 @@ def gzip_decode(data):
"""
if not gzip:
raise NotImplementedError
- f = StringIO.StringIO(data)
+ f = BytesIO(data)
gzf = gzip.GzipFile(mode="rb", fileobj=f)
try:
decoded = gzf.read()
@@ -1201,12 +1053,12 @@ class GzipDecodedResponse(gzip.GzipFile if gzip else object):
#GzipFile
if not gzip:
raise NotImplementedError
- self.stringio = StringIO.StringIO(response.read())
- gzip.GzipFile.__init__(self, mode="rb", fileobj=self.stringio)
+ self.io = BytesIO(response.read())
+ gzip.GzipFile.__init__(self, mode="rb", fileobj=self.io)
def close(self):
gzip.GzipFile.close(self)
- self.stringio.close()
+ self.io.close()
# --------------------------------------------------------------------
@@ -1243,10 +1095,11 @@ class Transport:
# that they can decode such a request
encode_threshold = None #None = don't encode
- def __init__(self, use_datetime=0):
+ def __init__(self, use_datetime=False):
self._use_datetime = use_datetime
self._connection = (None, None)
self._extra_headers = []
+
##
# Send a complete request, and parse the response.
# Retry request if a cached connection has disconnected.
@@ -1257,61 +1110,46 @@ class Transport:
# @param verbose Debugging flag.
# @return Parsed response.
- def request(self, host, handler, request_body, verbose=0):
+ def request(self, host, handler, request_body, verbose=False):
#retry request once if cached connection has gone cold
for i in (0, 1):
try:
return self.single_request(host, handler, request_body, verbose)
- except socket.error, e:
+ except socket.error as e:
if i or e.errno not in (errno.ECONNRESET, errno.ECONNABORTED, errno.EPIPE):
raise
- except httplib.BadStatusLine: #close after we sent request
+ except http.client.BadStatusLine: #close after we sent request
if i:
raise
- ##
- # Send a complete request, and parse the response.
- #
- # @param host Target host.
- # @param handler Target PRC handler.
- # @param request_body XML-RPC request body.
- # @param verbose Debugging flag.
- # @return Parsed response.
-
- def single_request(self, host, handler, request_body, verbose=0):
+ def single_request(self, host, handler, request_body, verbose=False):
# issue XML-RPC request
-
- h = self.make_connection(host)
- if verbose:
- h.set_debuglevel(1)
-
try:
- self.send_request(h, handler, request_body)
- self.send_host(h, host)
- self.send_user_agent(h)
- self.send_content(h, request_body)
-
- response = h.getresponse(buffering=True)
- if response.status == 200:
+ http_conn = self.send_request(host, handler, request_body, verbose)
+ resp = http_conn.getresponse()
+ if resp.status == 200:
self.verbose = verbose
- return self.parse_response(response)
+ return self.parse_response(resp)
+
except Fault:
raise
except Exception:
- # All unexpected errors leave connection in
+ #All unexpected errors leave connection in
# a strange state, so we clear it.
self.close()
raise
- #discard any response data and raise exception
- if (response.getheader("content-length", 0)):
- response.read()
+ #We got an error response.
+ #Discard any response data and raise exception
+ if resp.getheader("content-length", ""):
+ resp.read()
raise ProtocolError(
host + handler,
- response.status, response.reason,
- response.msg,
+ resp.status, resp.reason,
+ dict(resp.getheaders())
)
+
##
# Create parser.
#
@@ -1334,21 +1172,21 @@ class Transport:
def get_host_info(self, host):
x509 = {}
- if isinstance(host, TupleType):
+ if isinstance(host, tuple):
host, x509 = host
- import urllib
- auth, host = urllib.splituser(host)
+ import urllib.parse
+ auth, host = urllib.parse.splituser(host)
if auth:
- import base64
- auth = base64.encodestring(urllib.unquote(auth))
- auth = string.join(string.split(auth), "") # get rid of whitespace
+ auth = urllib.parse.unquote_to_bytes(auth)
+ auth = base64.encodebytes(auth).decode("utf-8")
+ auth = "".join(auth.split()) # get rid of whitespace
extra_headers = [
("Authorization", "Basic " + auth)
]
else:
- extra_headers = None
+ extra_headers = []
return host, extra_headers, x509
@@ -1356,18 +1194,16 @@ class Transport:
# Connect to server.
#
# @param host Target host.
- # @return A connection handle.
+ # @return An HTTPConnection object
def make_connection(self, host):
#return an existing connection if possible. This allows
#HTTP/1.1 keep-alive.
if self._connection and host == self._connection[0]:
return self._connection[1]
-
# create a HTTP connection object from a host descriptor
chost, self._extra_headers, x509 = self.get_host_info(host)
- #store the host argument along with the connection object
- self._connection = host, httplib.HTTPConnection(chost)
+ self._connection = host, http.client.HTTPConnection(chost)
return self._connection[1]
##
@@ -1380,54 +1216,49 @@ class Transport:
self._connection = (None, None)
##
- # Send request header.
+ # Send HTTP request.
#
- # @param connection Connection handle.
- # @param handler Target RPC handler.
- # @param request_body XML-RPC body.
-
- def send_request(self, connection, handler, request_body):
- if (self.accept_gzip_encoding and gzip):
+ # @param host Host descriptor (URL or (URL, x509 info) tuple).
+ # @param handler Targer RPC handler (a path relative to host)
+ # @param request_body The XML-RPC request body
+ # @param debug Enable debugging if debug is true.
+ # @return An HTTPConnection.
+
+ def send_request(self, host, handler, request_body, debug):
+ connection = self.make_connection(host)
+ headers = self._extra_headers[:]
+ if debug:
+ connection.set_debuglevel(1)
+ if self.accept_gzip_encoding and gzip:
connection.putrequest("POST", handler, skip_accept_encoding=True)
- connection.putheader("Accept-Encoding", "gzip")
+ headers.append(("Accept-Encoding", "gzip"))
else:
connection.putrequest("POST", handler)
+ headers.append(("Content-Type", "text/xml"))
+ headers.append(("User-Agent", self.user_agent))
+ self.send_headers(connection, headers)
+ self.send_content(connection, request_body)
+ return connection
##
- # Send host name.
- #
- # @param connection Connection handle.
- # @param host Host name.
+ # Send request headers.
+ # This function provides a useful hook for subclassing
#
- # Note: This function doesn't actually add the "Host"
- # header anymore, it is done as part of the connection.putrequest() in
- # send_request() above.
-
- def send_host(self, connection, host):
- extra_headers = self._extra_headers
- if extra_headers:
- if isinstance(extra_headers, DictType):
- extra_headers = extra_headers.items()
- for key, value in extra_headers:
- connection.putheader(key, value)
+ # @param connection httpConnection.
+ # @param headers list of key,value pairs for HTTP headers
- ##
- # Send user-agent identifier.
- #
- # @param connection Connection handle.
-
- def send_user_agent(self, connection):
- connection.putheader("User-Agent", self.user_agent)
+ def send_headers(self, connection, headers):
+ for key, val in headers:
+ connection.putheader(key, val)
##
# Send request body.
+ # This function provides a useful hook for subclassing
#
- # @param connection Connection handle.
+ # @param connection httpConnection.
# @param request_body XML-RPC request body.
def send_content(self, connection, request_body):
- connection.putheader("Content-Type", "text/xml")
-
#optionally encode the request
if (self.encode_threshold is not None and
self.encode_threshold < len(request_body) and
@@ -1446,9 +1277,8 @@ class Transport:
def parse_response(self, response):
# read response data from httpresponse, and parse it
-
- # Check for new http response object, else it is a file object
- if hasattr(response,'getheader'):
+ # Check for new http response object, otherwise it is a file object.
+ if hasattr(response, 'getheader'):
if response.getheader("Content-Encoding", "") == "gzip":
stream = GzipDecodedResponse(response)
else:
@@ -1463,7 +1293,7 @@ class Transport:
if not data:
break
if self.verbose:
- print "body:", repr(data)
+ print("body:", repr(data))
p.feed(data)
if stream is not response:
@@ -1483,18 +1313,16 @@ class SafeTransport(Transport):
def make_connection(self, host):
if self._connection and host == self._connection[0]:
return self._connection[1]
+
+ if not hasattr(http.client, "HTTPSConnection"):
+ raise NotImplementedError(
+ "your version of http.client doesn't support HTTPS")
# create a HTTPS connection object from a host descriptor
# host may be a string, or a (host, x509-dict) tuple
- try:
- HTTPS = httplib.HTTPSConnection
- except AttributeError:
- raise NotImplementedError(
- "your version of httplib doesn't support HTTPS"
- )
- else:
- chost, self._extra_headers, x509 = self.get_host_info(host)
- self._connection = host, HTTPS(chost, None, **(x509 or {}))
- return self._connection[1]
+ chost, self._extra_headers, x509 = self.get_host_info(host)
+ self._connection = host, http.client.HTTPSConnection(chost,
+ None, **(x509 or {}))
+ return self._connection[1]
##
# Standard server proxy. This class establishes a virtual connection
@@ -1535,19 +1363,16 @@ class ServerProxy:
the given encoding.
"""
- def __init__(self, uri, transport=None, encoding=None, verbose=0,
- allow_none=0, use_datetime=0):
+ def __init__(self, uri, transport=None, encoding=None, verbose=False,
+ allow_none=False, use_datetime=False):
# establish a "logical" server connection
- if isinstance(uri, unicode):
- uri = uri.encode('ISO-8859-1')
-
# get the url
- import urllib
- type, uri = urllib.splittype(uri)
+ import urllib.parse
+ type, uri = urllib.parse.splittype(uri)
if type not in ("http", "https"):
- raise IOError, "unsupported XML-RPC protocol"
- self.__host, self.__handler = urllib.splithost(uri)
+ raise IOError("unsupported XML-RPC protocol")
+ self.__host, self.__handler = urllib.parse.splithost(uri)
if not self.__handler:
self.__handler = "/RPC2"
@@ -1558,7 +1383,7 @@ class ServerProxy:
transport = Transport(use_datetime=use_datetime)
self.__transport = transport
- self.__encoding = encoding
+ self.__encoding = encoding or 'utf-8'
self.__verbose = verbose
self.__allow_none = allow_none
@@ -1569,7 +1394,7 @@ class ServerProxy:
# call a method on the remote server
request = dumps(params, methodname, encoding=self.__encoding,
- allow_none=self.__allow_none)
+ allow_none=self.__allow_none).encode(self.__encoding)
response = self.__transport.request(
self.__host,
@@ -1622,18 +1447,17 @@ if __name__ == "__main__":
# server = ServerProxy("http://localhost:8000") # local server
server = ServerProxy("http://time.xmlrpc.com/RPC2")
- print server
-
try:
- print server.currentTime.getCurrentTime()
- except Error, v:
- print "ERROR", v
+ print(server.currentTime.getCurrentTime())
+ except Error as v:
+ print("ERROR", v)
+ # The server at xmlrpc.com doesn't seem to support multicall anymore.
multi = MultiCall(server)
multi.currentTime.getCurrentTime()
multi.currentTime.getCurrentTime()
try:
for response in multi():
- print response
- except Error, v:
- print "ERROR", v
+ print(response)
+ except Error as v:
+ print("ERROR", v)
diff --git a/Lib/SimpleXMLRPCServer.py b/Lib/xmlrpc/server.py
index f15cd62f4cf..fd170265837 100644
--- a/Lib/SimpleXMLRPCServer.py
+++ b/Lib/xmlrpc/server.py
@@ -1,4 +1,4 @@
-r"""Simple XML-RPC Server.
+r"""XML-RPC Servers.
This module can be used to create simple XML-RPC servers
by creating a server and either installing functions, a
@@ -8,6 +8,12 @@ class.
It can also be used to handle XML-RPC requests in a CGI
environment using CGIXMLRPCRequestHandler.
+The Doc* classes can be used to create XML-RPC servers that
+serve pydoc-style documentation in response to HTTP
+GET requests. This documentation is dynamically generated
+based on the functions and methods registered with the
+server.
+
A list of possible usage patterns follows:
1. Install functions:
@@ -21,15 +27,14 @@ server.serve_forever()
class MyFuncs:
def __init__(self):
- # make all of the string functions available through
- # string.func_name
- import string
- self.string = string
+ # make all of the sys functions available through sys.func_name
+ import sys
+ self.sys = sys
def _listMethods(self):
# implement this method so that system.listMethods
- # knows to advertise the strings methods
+ # knows to advertise the sys methods
return list_public_methods(self) + \
- ['string.' + method for method in list_public_methods(self.string)]
+ ['sys.' + method for method in list_public_methods(self.sys)]
def pow(self, x, y): return pow(x, y)
def add(self, x, y) : return x + y
@@ -62,7 +67,7 @@ class Math:
elif method == 'add':
return params[0] + params[1]
else:
- raise 'bad method'
+ raise ValueError('bad method')
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_introspection_functions()
@@ -99,14 +104,16 @@ server.handle_request()
# Written by Brian Quinlan (brian@sweetapp.com).
# Based on code written by Fredrik Lundh.
-import xmlrpclib
-from xmlrpclib import Fault
-import SocketServer
-import BaseHTTPServer
+from xmlrpc.client import Fault, dumps, loads, gzip_encode, gzip_decode
+from http.server import BaseHTTPRequestHandler
+import http.server
+import socketserver
import sys
import os
-import traceback
import re
+import pydoc
+import inspect
+import traceback
try:
import fcntl
except ImportError:
@@ -142,20 +149,7 @@ def list_public_methods(obj):
return [member for member in dir(obj)
if not member.startswith('_') and
- hasattr(getattr(obj, member), '__call__')]
-
-def remove_duplicates(lst):
- """remove_duplicates([2,2,2,1,3,3]) => [3,1,2]
-
- Returns a copy of a list without duplicates. Every list
- item must be hashable and the order of the items in the
- resulting list is not defined.
- """
- u = {}
- for x in lst:
- u[x] = 1
-
- return u.keys()
+ callable(getattr(obj, member))]
class SimpleXMLRPCDispatcher:
"""Mix-in class that dispatches XML-RPC requests.
@@ -163,14 +157,14 @@ class SimpleXMLRPCDispatcher:
This class is used to register XML-RPC method handlers
and then to dispatch them. This class doesn't need to be
instanced directly when used by SimpleXMLRPCServer but it
- can be instanced when used by the MultiPathXMLRPCServer.
+ can be instanced when used by the MultiPathXMLRPCServer
"""
def __init__(self, allow_none=False, encoding=None):
self.funcs = {}
self.instance = None
self.allow_none = allow_none
- self.encoding = encoding
+ self.encoding = encoding or 'utf-8'
def register_instance(self, instance, allow_dotted_names=False):
"""Registers an instance to respond to XML-RPC requests.
@@ -208,7 +202,7 @@ class SimpleXMLRPCDispatcher:
self.instance = instance
self.allow_dotted_names = allow_dotted_names
- def register_function(self, function, name = None):
+ def register_function(self, function, name=None):
"""Registers a function to respond to XML-RPC requests.
The optional name argument can be used to set a Unicode name
@@ -251,7 +245,7 @@ class SimpleXMLRPCDispatcher:
"""
try:
- params, method = xmlrpclib.loads(data)
+ params, method = loads(data)
# generate response
if dispatch_method is not None:
@@ -260,43 +254,38 @@ class SimpleXMLRPCDispatcher:
response = self._dispatch(method, params)
# wrap response in a singleton tuple
response = (response,)
- response = xmlrpclib.dumps(response, methodresponse=1,
- allow_none=self.allow_none, encoding=self.encoding)
- except Fault, fault:
- response = xmlrpclib.dumps(fault, allow_none=self.allow_none,
- encoding=self.encoding)
+ response = dumps(response, methodresponse=1,
+ allow_none=self.allow_none, encoding=self.encoding)
+ except Fault as fault:
+ response = dumps(fault, allow_none=self.allow_none,
+ encoding=self.encoding)
except:
# report exception back to server
exc_type, exc_value, exc_tb = sys.exc_info()
- response = xmlrpclib.dumps(
- xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
+ response = dumps(
+ Fault(1, "%s:%s" % (exc_type, exc_value)),
encoding=self.encoding, allow_none=self.allow_none,
)
- return response
+ return response.encode(self.encoding)
def system_listMethods(self):
"""system.listMethods() => ['add', 'subtract', 'multiple']
Returns a list of the methods supported by the server."""
- methods = self.funcs.keys()
+ methods = set(self.funcs.keys())
if self.instance is not None:
# Instance can implement _listMethod to return a list of
# methods
if hasattr(self.instance, '_listMethods'):
- methods = remove_duplicates(
- methods + self.instance._listMethods()
- )
+ methods |= set(self.instance._listMethods())
# if the instance has a _dispatch method then we
# don't have enough information to provide a list
# of methods
elif not hasattr(self.instance, '_dispatch'):
- methods = remove_duplicates(
- methods + list_public_methods(self.instance)
- )
- methods.sort()
- return methods
+ methods |= set(list_public_methods(self.instance))
+ return sorted(methods)
def system_methodSignature(self, method_name):
"""system.methodSignature('add') => [double, int, int]
@@ -340,7 +329,6 @@ class SimpleXMLRPCDispatcher:
if method is None:
return ""
else:
- import pydoc
return pydoc.getdoc(method)
def system_multicall(self, call_list):
@@ -362,7 +350,7 @@ class SimpleXMLRPCDispatcher:
# XXX A marshalling error in any response will fail the entire
# multicall. If someone cares they should fix this.
results.append([self._dispatch(method_name, params)])
- except Fault, fault:
+ except Fault as fault:
results.append(
{'faultCode' : fault.faultCode,
'faultString' : fault.faultString}
@@ -421,7 +409,7 @@ class SimpleXMLRPCDispatcher:
else:
raise Exception('method "%s" is not supported' % method)
-class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
+class SimpleXMLRPCRequestHandler(BaseHTTPRequestHandler):
"""Simple XML-RPC request handler class.
Handles all HTTP POST requests and attempts to decode them as
@@ -491,7 +479,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
break
L.append(chunk)
size_remaining -= len(L[-1])
- data = ''.join(L)
+ data = b''.join(L)
data = self.decode_request_content(data)
if data is None:
@@ -505,7 +493,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
response = self.server._marshaled_dispatch(
data, getattr(self, '_dispatch', None), self.path
)
- except Exception, e: # This should only happen if the module is buggy
+ except Exception as e: # This should only happen if the module is buggy
# internal error, report as HTTP server error
self.send_response(500)
@@ -513,12 +501,13 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if hasattr(self.server, '_send_traceback_header') and \
self.server._send_traceback_header:
self.send_header("X-exception", str(e))
- self.send_header("X-traceback", traceback.format_exc())
+ trace = traceback.format_exc()
+ trace = str(trace.encode('ASCII', 'backslashreplace'), 'ASCII')
+ self.send_header("X-traceback", trace)
self.send_header("Content-length", "0")
self.end_headers()
else:
- # got a valid XML RPC response
self.send_response(200)
self.send_header("Content-type", "text/xml")
if self.encode_threshold is not None:
@@ -526,7 +515,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
q = self.accept_encodings().get("gzip", 0)
if q:
try:
- response = xmlrpclib.gzip_encode(response)
+ response = gzip_encode(response)
self.send_header("Content-Encoding", "gzip")
except NotImplementedError:
pass
@@ -541,7 +530,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
return data
if encoding == "gzip":
try:
- return xmlrpclib.gzip_decode(data)
+ return gzip_decode(data)
except NotImplementedError:
self.send_response(501, "encoding %r not supported" % encoding)
except ValueError:
@@ -554,7 +543,7 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def report_404 (self):
# Report a 404 error
self.send_response(404)
- response = 'No such page'
+ response = b'No such page'
self.send_header("Content-type", "text/plain")
self.send_header("Content-length", str(len(response)))
self.end_headers()
@@ -564,16 +553,16 @@ class SimpleXMLRPCRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
"""Selectively log an accepted request."""
if self.server.logRequests:
- BaseHTTPServer.BaseHTTPRequestHandler.log_request(self, code, size)
+ BaseHTTPRequestHandler.log_request(self, code, size)
-class SimpleXMLRPCServer(SocketServer.TCPServer,
+class SimpleXMLRPCServer(socketserver.TCPServer,
SimpleXMLRPCDispatcher):
"""Simple XML-RPC server.
Simple XML-RPC server that allows functions and a single instance
to be installed to handle requests. The default implementation
attempts to dispatch XML-RPC calls to the functions or instance
- installed in the server. Override the _dispatch method inhereted
+ installed in the server. Override the _dispatch method inherited
from SimpleXMLRPCDispatcher to change this behavior.
"""
@@ -590,7 +579,7 @@ class SimpleXMLRPCServer(SocketServer.TCPServer,
self.logRequests = logRequests
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
- SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
+ socketserver.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
# [Bug #1222790] If possible, set close-on-exec flag; if a
# method spawns a subprocess, the subprocess shouldn't have
@@ -615,7 +604,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
encoding, bind_and_activate)
self.dispatchers = {}
self.allow_none = allow_none
- self.encoding = encoding
+ self.encoding = encoding or 'utf-8'
def add_dispatcher(self, path, dispatcher):
self.dispatchers[path] = dispatcher
@@ -633,9 +622,10 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer):
# (each dispatcher should have handled their own
# exceptions)
exc_type, exc_value = sys.exc_info()[:2]
- response = xmlrpclib.dumps(
- xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)),
+ response = dumps(
+ Fault(1, "%s:%s" % (exc_type, exc_value)),
encoding=self.encoding, allow_none=self.allow_none)
+ response = response.encode(self.encoding)
return response
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
@@ -649,10 +639,12 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
response = self._marshaled_dispatch(request_text)
- print 'Content-Type: text/xml'
- print 'Content-Length: %d' % len(response)
- print
- sys.stdout.write(response)
+ print('Content-Type: text/xml')
+ print('Content-Length: %d' % len(response))
+ print()
+ sys.stdout.flush()
+ sys.stdout.buffer.write(response)
+ sys.stdout.buffer.flush()
def handle_get(self):
"""Handle a single HTTP GET request.
@@ -662,22 +654,24 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
"""
code = 400
- message, explain = \
- BaseHTTPServer.BaseHTTPRequestHandler.responses[code]
+ message, explain = BaseHTTPRequestHandler.responses[code]
- response = BaseHTTPServer.DEFAULT_ERROR_MESSAGE % \
+ response = http.server.DEFAULT_ERROR_MESSAGE % \
{
'code' : code,
'message' : message,
'explain' : explain
}
- print 'Status: %d %s' % (code, message)
- print 'Content-Type: %s' % BaseHTTPServer.DEFAULT_ERROR_CONTENT_TYPE
- print 'Content-Length: %d' % len(response)
- print
- sys.stdout.write(response)
-
- def handle_request(self, request_text = None):
+ response = response.encode('utf-8')
+ print('Status: %d %s' % (code, message))
+ print('Content-Type: %s' % http.server.DEFAULT_ERROR_CONTENT_TYPE)
+ print('Content-Length: %d' % len(response))
+ print()
+ sys.stdout.flush()
+ sys.stdout.buffer.write(response)
+ sys.stdout.buffer.flush()
+
+ def handle_request(self, request_text=None):
"""Handle a single XML-RPC request passed through a CGI post method.
If no XML data is given then it is read from stdin. The resulting
@@ -692,15 +686,280 @@ class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
# POST data is normally available through stdin
try:
length = int(os.environ.get('CONTENT_LENGTH', None))
- except (TypeError, ValueError):
+ except (ValueError, TypeError):
length = -1
if request_text is None:
request_text = sys.stdin.read(length)
self.handle_xmlrpc(request_text)
+
+# -----------------------------------------------------------------------------
+# Self documenting XML-RPC Server.
+
+class ServerHTMLDoc(pydoc.HTMLDoc):
+ """Class used to generate pydoc HTML document for a server"""
+
+ def markup(self, text, escape=None, funcs={}, classes={}, methods={}):
+ """Mark up some plain text, given a context of symbols to look for.
+ Each context dictionary maps object names to anchor names."""
+ escape = escape or self.escape
+ results = []
+ here = 0
+
+ # XXX Note that this regular expression does not allow for the
+ # hyperlinking of arbitrary strings being used as method
+ # names. Only methods with names consisting of word characters
+ # and '.'s are hyperlinked.
+ pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|'
+ r'RFC[- ]?(\d+)|'
+ r'PEP[- ]?(\d+)|'
+ r'(self\.)?((?:\w|\.)+))\b')
+ while 1:
+ match = pattern.search(text, here)
+ if not match: break
+ start, end = match.span()
+ results.append(escape(text[here:start]))
+
+ all, scheme, rfc, pep, selfdot, name = match.groups()
+ if scheme:
+ url = escape(all).replace('"', '&quot;')
+ results.append('<a href="%s">%s</a>' % (url, url))
+ elif rfc:
+ url = 'http://www.rfc-editor.org/rfc/rfc%d.txt' % int(rfc)
+ results.append('<a href="%s">%s</a>' % (url, escape(all)))
+ elif pep:
+ url = 'http://www.python.org/dev/peps/pep-%04d/' % int(pep)
+ results.append('<a href="%s">%s</a>' % (url, escape(all)))
+ elif text[end:end+1] == '(':
+ results.append(self.namelink(name, methods, funcs, classes))
+ elif selfdot:
+ results.append('self.<strong>%s</strong>' % name)
+ else:
+ results.append(self.namelink(name, classes))
+ here = end
+ results.append(escape(text[here:]))
+ return ''.join(results)
+
+ def docroutine(self, object, name, mod=None,
+ funcs={}, classes={}, methods={}, cl=None):
+ """Produce HTML documentation for a function or method object."""
+
+ anchor = (cl and cl.__name__ or '') + '-' + name
+ note = ''
+
+ title = '<a name="%s"><strong>%s</strong></a>' % (
+ self.escape(anchor), self.escape(name))
+
+ if inspect.ismethod(object):
+ args, varargs, varkw, defaults = inspect.getargspec(object)
+ # exclude the argument bound to the instance, it will be
+ # confusing to the non-Python user
+ argspec = inspect.formatargspec (
+ args[1:],
+ varargs,
+ varkw,
+ defaults,
+ formatvalue=self.formatvalue
+ )
+ elif inspect.isfunction(object):
+ args, varargs, varkw, defaults = inspect.getargspec(object)
+ argspec = inspect.formatargspec(
+ args, varargs, varkw, defaults, formatvalue=self.formatvalue)
+ else:
+ argspec = '(...)'
+
+ if isinstance(object, tuple):
+ argspec = object[0] or argspec
+ docstring = object[1] or ""
+ else:
+ docstring = pydoc.getdoc(object)
+
+ decl = title + argspec + (note and self.grey(
+ '<font face="helvetica, arial">%s</font>' % note))
+
+ doc = self.markup(
+ docstring, self.preformat, funcs, classes, methods)
+ doc = doc and '<dd><tt>%s</tt></dd>' % doc
+ return '<dl><dt>%s</dt>%s</dl>\n' % (decl, doc)
+
+ def docserver(self, server_name, package_documentation, methods):
+ """Produce HTML documentation for an XML-RPC server."""
+
+ fdict = {}
+ for key, value in methods.items():
+ fdict[key] = '#-' + key
+ fdict[value] = fdict[key]
+
+ server_name = self.escape(server_name)
+ head = '<big><big><strong>%s</strong></big></big>' % server_name
+ result = self.heading(head, '#ffffff', '#7799ee')
+
+ doc = self.markup(package_documentation, self.preformat, fdict)
+ doc = doc and '<tt>%s</tt>' % doc
+ result = result + '<p>%s</p>\n' % doc
+
+ contents = []
+ method_items = sorted(methods.items())
+ for key, value in method_items:
+ contents.append(self.docroutine(value, key, funcs=fdict))
+ result = result + self.bigsection(
+ 'Methods', '#ffffff', '#eeaa77', ''.join(contents))
+
+ return result
+
+class XMLRPCDocGenerator:
+ """Generates documentation for an XML-RPC server.
+
+ This class is designed as mix-in and should not
+ be constructed directly.
+ """
+
+ def __init__(self):
+ # setup variables used for HTML documentation
+ self.server_name = 'XML-RPC Server Documentation'
+ self.server_documentation = \
+ "This server exports the following methods through the XML-RPC "\
+ "protocol."
+ self.server_title = 'XML-RPC Server Documentation'
+
+ def set_server_title(self, server_title):
+ """Set the HTML title of the generated server documentation"""
+
+ self.server_title = server_title
+
+ def set_server_name(self, server_name):
+ """Set the name of the generated HTML server documentation"""
+
+ self.server_name = server_name
+
+ def set_server_documentation(self, server_documentation):
+ """Set the documentation string for the entire server."""
+
+ self.server_documentation = server_documentation
+
+ def generate_html_documentation(self):
+ """generate_html_documentation() => html documentation for the server
+
+ Generates HTML documentation for the server using introspection for
+ installed functions and instances that do not implement the
+ _dispatch method. Alternatively, instances can choose to implement
+ the _get_method_argstring(method_name) method to provide the
+ argument string used in the documentation and the
+ _methodHelp(method_name) method to provide the help text used
+ in the documentation."""
+
+ methods = {}
+
+ for method_name in self.system_listMethods():
+ if method_name in self.funcs:
+ method = self.funcs[method_name]
+ elif self.instance is not None:
+ method_info = [None, None] # argspec, documentation
+ if hasattr(self.instance, '_get_method_argstring'):
+ method_info[0] = self.instance._get_method_argstring(method_name)
+ if hasattr(self.instance, '_methodHelp'):
+ method_info[1] = self.instance._methodHelp(method_name)
+
+ method_info = tuple(method_info)
+ if method_info != (None, None):
+ method = method_info
+ elif not hasattr(self.instance, '_dispatch'):
+ try:
+ method = resolve_dotted_attribute(
+ self.instance,
+ method_name
+ )
+ except AttributeError:
+ method = method_info
+ else:
+ method = method_info
+ else:
+ assert 0, "Could not find method in self.functions and no "\
+ "instance installed"
+
+ methods[method_name] = method
+
+ documenter = ServerHTMLDoc()
+ documentation = documenter.docserver(
+ self.server_name,
+ self.server_documentation,
+ methods
+ )
+
+ return documenter.page(self.server_title, documentation)
+
+class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
+ """XML-RPC and documentation request handler class.
+
+ Handles all HTTP POST requests and attempts to decode them as
+ XML-RPC requests.
+
+ Handles all HTTP GET requests and interprets them as requests
+ for documentation.
+ """
+
+ def do_GET(self):
+ """Handles the HTTP GET request.
+
+ Interpret all HTTP GET requests as requests for server
+ documentation.
+ """
+ # Check that the path is legal
+ if not self.is_rpc_path_valid():
+ self.report_404()
+ return
+
+ response = self.server.generate_html_documentation().encode('utf-8')
+ self.send_response(200)
+ self.send_header("Content-type", "text/html")
+ self.send_header("Content-length", str(len(response)))
+ self.end_headers()
+ self.wfile.write(response)
+
+class DocXMLRPCServer( SimpleXMLRPCServer,
+ XMLRPCDocGenerator):
+ """XML-RPC and HTML documentation server.
+
+ Adds the ability to serve server documentation to the capabilities
+ of SimpleXMLRPCServer.
+ """
+
+ def __init__(self, addr, requestHandler=DocXMLRPCRequestHandler,
+ logRequests=True, allow_none=False, encoding=None,
+ bind_and_activate=True):
+ SimpleXMLRPCServer.__init__(self, addr, requestHandler, logRequests,
+ allow_none, encoding, bind_and_activate)
+ XMLRPCDocGenerator.__init__(self)
+
+class DocCGIXMLRPCRequestHandler( CGIXMLRPCRequestHandler,
+ XMLRPCDocGenerator):
+ """Handler for XML-RPC data and documentation requests passed through
+ CGI"""
+
+ def handle_get(self):
+ """Handles the HTTP GET request.
+
+ Interpret all HTTP GET requests as requests for server
+ documentation.
+ """
+
+ response = self.generate_html_documentation().encode('utf-8')
+
+ print('Content-Type: text/html')
+ print('Content-Length: %d' % len(response))
+ print()
+ sys.stdout.flush()
+ sys.stdout.buffer.write(response)
+ sys.stdout.buffer.flush()
+
+ def __init__(self):
+ CGIXMLRPCRequestHandler.__init__(self)
+ XMLRPCDocGenerator.__init__(self)
+
+
if __name__ == '__main__':
- print 'Running XML-RPC server on port 8000'
+ print('Running XML-RPC server on port 8000')
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index 6e776882539..5b3f6f9603e 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1,10 +1,19 @@
"""
Read and write ZIP files.
+
+XXX references to utf-8 need further investigation.
"""
-import struct, os, time, sys, shutil
-import binascii, cStringIO, stat
import io
+import os
import re
+import imp
+import sys
+import time
+import stat
+import shutil
+import struct
+import binascii
+
try:
import zlib # We may need its compression method
@@ -13,10 +22,10 @@ except ImportError:
zlib = None
crc32 = binascii.crc32
-__all__ = ["BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED", "is_zipfile",
- "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile" ]
+__all__ = ["BadZipFile", "BadZipfile", "error", "ZIP_STORED", "ZIP_DEFLATED",
+ "is_zipfile", "ZipInfo", "ZipFile", "PyZipFile", "LargeZipFile"]
-class BadZipfile(Exception):
+class BadZipFile(Exception):
pass
@@ -26,7 +35,8 @@ class LargeZipFile(Exception):
and those extensions are disabled.
"""
-error = BadZipfile # The exception raised by this module
+error = BadZipfile = BadZipFile # Pre-3.2 compatibility names
+
ZIP64_LIMIT = (1 << 31) - 1
ZIP_FILECOUNT_LIMIT = 1 << 16
@@ -45,8 +55,8 @@ ZIP_DEFLATED = 8
# The "end of central directory" structure, magic number, size, and indices
# (section V.I in the format document)
-structEndArchive = "<4s4H2LH"
-stringEndArchive = "PK\005\006"
+structEndArchive = b"<4s4H2LH"
+stringEndArchive = b"PK\005\006"
sizeEndCentDir = struct.calcsize(structEndArchive)
_ECD_SIGNATURE = 0
@@ -65,7 +75,7 @@ _ECD_LOCATION = 9
# The "central directory" structure, magic number, size, and indices
# of entries in the structure (section V.F in the format document)
structCentralDir = "<4s4B4HL2L5H2L"
-stringCentralDir = "PK\001\002"
+stringCentralDir = b"PK\001\002"
sizeCentralDir = struct.calcsize(structCentralDir)
# indexes of entries in the central directory structure
@@ -92,7 +102,7 @@ _CD_LOCAL_HEADER_OFFSET = 18
# The "local file header" structure, magic number, size, and indices
# (section V.A in the format document)
structFileHeader = "<4s2B4HL2L2H"
-stringFileHeader = "PK\003\004"
+stringFileHeader = b"PK\003\004"
sizeFileHeader = struct.calcsize(structFileHeader)
_FH_SIGNATURE = 0
@@ -110,13 +120,13 @@ _FH_EXTRA_FIELD_LENGTH = 11
# The "Zip64 end of central directory locator" structure, magic number, and size
structEndArchive64Locator = "<4sLQL"
-stringEndArchive64Locator = "PK\x06\x07"
+stringEndArchive64Locator = b"PK\x06\x07"
sizeEndCentDir64Locator = struct.calcsize(structEndArchive64Locator)
# The "Zip64 end of central directory" record, magic number, size, and indices
# (section V.G in the format document)
structEndArchive64 = "<4sQ2H2L4Q"
-stringEndArchive64 = "PK\x06\x06"
+stringEndArchive64 = b"PK\x06\x06"
sizeEndCentDir64 = struct.calcsize(structEndArchive64)
_CD64_SIGNATURE = 0
@@ -171,7 +181,7 @@ def _EndRecData64(fpin, offset, endrec):
return endrec
if diskno != 0 or disks != 1:
- raise BadZipfile("zipfiles that span multiple disks are not supported")
+ raise BadZipFile("zipfiles that span multiple disks are not supported")
# Assume no 'zip64 extensible data'
fpin.seek(offset - sizeEndCentDir64Locator - sizeEndCentDir64, 2)
@@ -211,13 +221,13 @@ def _EndRecData(fpin):
except IOError:
return None
data = fpin.read()
- if data[0:4] == stringEndArchive and data[-2:] == "\000\000":
+ if data[0:4] == stringEndArchive and data[-2:] == b"\000\000":
# the signature is correct and there's no comment, unpack structure
endrec = struct.unpack(structEndArchive, data)
endrec=list(endrec)
# Append a blank comment and record start offset
- endrec.append("")
+ endrec.append(b"")
endrec.append(filesize - sizeEndCentDir)
# Try to read the "Zip64 end of central directory" structure
@@ -296,8 +306,8 @@ class ZipInfo (object):
# Standard values:
self.compress_type = ZIP_STORED # Type of compression for the file
- self.comment = "" # Comment for each file
- self.extra = "" # ZIP extra data
+ self.comment = b"" # Comment for each file
+ self.extra = b"" # ZIP extra data
if sys.platform == 'win32':
self.create_system = 0 # System which created ZIP archive
else:
@@ -351,19 +361,10 @@ class ZipInfo (object):
return header + filename + extra
def _encodeFilenameFlags(self):
- if isinstance(self.filename, unicode):
- try:
- return self.filename.encode('ascii'), self.flag_bits
- except UnicodeEncodeError:
- return self.filename.encode('utf-8'), self.flag_bits | 0x800
- else:
- return self.filename, self.flag_bits
-
- def _decodeFilename(self):
- if self.flag_bits & 0x800:
- return self.filename.decode('utf-8')
- else:
- return self.filename
+ try:
+ return self.filename.encode('ascii'), self.flag_bits
+ except UnicodeEncodeError:
+ return self.filename.encode('utf-8'), self.flag_bits | 0x800
def _decodeExtra(self):
# Try to decode the extra field.
@@ -381,20 +382,20 @@ class ZipInfo (object):
elif ln == 0:
counts = ()
else:
- raise RuntimeError, "Corrupt extra field %s"%(ln,)
+ raise RuntimeError("Corrupt extra field %s"%(ln,))
idx = 0
# ZIP64 extension (large files and/or large archives)
- if self.file_size in (0xffffffffffffffffL, 0xffffffffL):
+ if self.file_size in (0xffffffffffffffff, 0xffffffff):
self.file_size = counts[idx]
idx += 1
- if self.compress_size == 0xFFFFFFFFL:
+ if self.compress_size == 0xFFFFFFFF:
self.compress_size = counts[idx]
idx += 1
- if self.header_offset == 0xffffffffL:
+ if self.header_offset == 0xffffffff:
old = self.header_offset
self.header_offset = counts[idx]
idx+=1
@@ -437,7 +438,7 @@ class _ZipDecrypter:
def _crc32(self, ch, crc):
"""Compute the CRC32 primitive on one byte."""
- return ((crc >> 8) & 0xffffff) ^ self.crctable[(crc ^ ord(ch)) & 0xff]
+ return ((crc >> 8) & 0xffffff) ^ self.crctable[(crc ^ ch) & 0xff]
def __init__(self, pwd):
self.key0 = 305419896
@@ -450,14 +451,13 @@ class _ZipDecrypter:
self.key0 = self._crc32(c, self.key0)
self.key1 = (self.key1 + (self.key0 & 255)) & 4294967295
self.key1 = (self.key1 * 134775813 + 1) & 4294967295
- self.key2 = self._crc32(chr((self.key1 >> 24) & 255), self.key2)
+ self.key2 = self._crc32((self.key1 >> 24) & 255, self.key2)
def __call__(self, c):
"""Decrypt a single character."""
- c = ord(c)
+ assert isinstance(c, int)
k = self.key2 | 2
c = c ^ (((k * (k^1)) >> 8) & 255)
- c = chr(c)
self._UpdateKeys(c)
return c
@@ -495,10 +495,10 @@ class ZipExtFile(io.BufferedIOBase):
MIN_READ_SIZE = 4096
# Search for universal newlines or line chunks.
- PATTERN = re.compile(r'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
+ PATTERN = re.compile(br'^(?P<chunk>[^\r\n]+)|(?P<newline>\n|\r\n?)')
def __init__(self, fileobj, mode, zipinfo, decrypter=None,
- close_fileobj=False):
+ close_fileobj=False):
self._fileobj = fileobj
self._decrypter = decrypter
self._close_fileobj = close_fileobj
@@ -515,9 +515,9 @@ class ZipExtFile(io.BufferedIOBase):
raise NotImplementedError("compression type %d (%s)" % (self._compress_type, descr))
else:
raise NotImplementedError("compression type %d" % (self._compress_type,))
- self._unconsumed = ''
+ self._unconsumed = b''
- self._readbuffer = ''
+ self._readbuffer = b''
self._offset = 0
self._universal = 'U' in mode
@@ -545,7 +545,7 @@ class ZipExtFile(io.BufferedIOBase):
if not self._universal and limit < 0:
# Shortcut common case - newline found in buffer.
- i = self._readbuffer.find('\n', self._offset) + 1
+ i = self._readbuffer.find(b'\n', self._offset) + 1
if i > 0:
line = self._readbuffer[self._offset: i]
self._offset = i
@@ -554,10 +554,10 @@ class ZipExtFile(io.BufferedIOBase):
if not self._universal:
return io.BufferedIOBase.readline(self, limit)
- line = ''
+ line = b''
while limit < 0 or len(line) < limit:
readahead = self.peek(2)
- if readahead == '':
+ if readahead == b'':
return line
#
@@ -576,7 +576,7 @@ class ZipExtFile(io.BufferedIOBase):
if newline not in self.newlines:
self.newlines.append(newline)
self._offset += len(newline)
- return line + '\n'
+ return line + b'\n'
chunk = match.group('chunk')
if limit >= 0:
@@ -603,7 +603,7 @@ class ZipExtFile(io.BufferedIOBase):
"""Read and return up to n bytes.
If the argument is omitted, None, or negative, data is read and returned until EOF is reached..
"""
- buf = ''
+ buf = b''
if n is None:
n = -1
while True:
@@ -625,7 +625,7 @@ class ZipExtFile(io.BufferedIOBase):
self._running_crc = crc32(newdata, self._running_crc) & 0xffffffff
# Check the CRC if we're at the end of the file
if eof and self._running_crc != self._expected_crc:
- raise BadZipfile("Bad CRC-32 for file %r" % self.name)
+ raise BadZipFile("Bad CRC-32 for file %r" % self.name)
def read1(self, n):
"""Read up to n bytes with at most one read() system call."""
@@ -647,7 +647,7 @@ class ZipExtFile(io.BufferedIOBase):
self._compress_left -= len(data)
if data and self._decrypter is not None:
- data = ''.join(map(self._decrypter, data))
+ data = bytes(map(self._decrypter, data))
if self._compress_type == ZIP_STORED:
self._update_crc(data, eof=(self._compress_left==0))
@@ -680,14 +680,14 @@ class ZipExtFile(io.BufferedIOBase):
return data
def close(self):
- try :
+ try:
if self._close_fileobj:
self._fileobj.close()
finally:
- super(ZipExtFile, self).close()
+ super().close()
-class ZipFile(object):
+class ZipFile:
""" Class with methods to open, read, write, close, list zip files.
z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=False)
@@ -713,10 +713,10 @@ class ZipFile(object):
pass
elif compression == ZIP_DEFLATED:
if not zlib:
- raise RuntimeError,\
- "Compression requires the (missing) zlib module"
+ raise RuntimeError(
+ "Compression requires the (missing) zlib module")
else:
- raise RuntimeError, "That compression method is not supported"
+ raise RuntimeError("That compression method is not supported")
self._allowZip64 = allowZip64
self._didModify = False
@@ -726,19 +726,20 @@ class ZipFile(object):
self.compression = compression # Method of compression
self.mode = key = mode.replace('b', '')[0]
self.pwd = None
- self._comment = ''
+ self._comment = b''
# Check if we were passed a file-like object
- if isinstance(file, basestring):
+ if isinstance(file, str):
+ # No, it's a filename
self._filePassed = 0
self.filename = file
modeDict = {'r' : 'rb', 'w': 'wb', 'a' : 'r+b'}
try:
- self.fp = open(file, modeDict[mode])
+ self.fp = io.open(file, modeDict[mode])
except IOError:
if mode == 'a':
mode = key = 'w'
- self.fp = open(file, modeDict[mode])
+ self.fp = io.open(file, modeDict[mode])
else:
raise
else:
@@ -759,7 +760,7 @@ class ZipFile(object):
self._RealGetContents()
# seek to start of directory and overwrite
self.fp.seek(self.start_dir, 0)
- except BadZipfile:
+ except BadZipFile:
# file is not a zip file, just append
self.fp.seek(0, 2)
@@ -787,11 +788,11 @@ class ZipFile(object):
try:
endrec = _EndRecData(fp)
except IOError:
- raise BadZipfile("File is not a zip file")
+ raise BadZipFile("File is not a zip file")
if not endrec:
- raise BadZipfile, "File is not a zip file"
+ raise BadZipFile("File is not a zip file")
if self.debug > 1:
- print endrec
+ print(endrec)
size_cd = endrec[_ECD_SIZE] # bytes in central directory
offset_cd = endrec[_ECD_OFFSET] # offset of central directory
self._comment = endrec[_ECD_COMMENT] # archive comment
@@ -804,21 +805,28 @@ class ZipFile(object):
if self.debug > 2:
inferred = concat + offset_cd
- print "given, inferred, offset", offset_cd, inferred, concat
+ print("given, inferred, offset", offset_cd, inferred, concat)
# self.start_dir: Position of start of central directory
self.start_dir = offset_cd + concat
fp.seek(self.start_dir, 0)
data = fp.read(size_cd)
- fp = cStringIO.StringIO(data)
+ fp = io.BytesIO(data)
total = 0
while total < size_cd:
centdir = fp.read(sizeCentralDir)
if centdir[0:4] != stringCentralDir:
- raise BadZipfile, "Bad magic number for central directory"
+ raise BadZipFile("Bad magic number for central directory")
centdir = struct.unpack(structCentralDir, centdir)
if self.debug > 2:
- print centdir
+ print(centdir)
filename = fp.read(centdir[_CD_FILENAME_LENGTH])
+ flags = centdir[5]
+ if flags & 0x800:
+ # UTF-8 file names extension
+ filename = filename.decode('utf-8')
+ else:
+ # Historical ZIP filename encoding
+ filename = filename.decode('cp437')
# Create ZipInfo instance to store file information
x = ZipInfo(filename)
x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH])
@@ -835,7 +843,6 @@ class ZipFile(object):
x._decodeExtra()
x.header_offset = x.header_offset + concat
- x.filename = x._decodeFilename()
self.filelist.append(x)
self.NameToInfo[x.filename] = x
@@ -845,7 +852,7 @@ class ZipFile(object):
+ centdir[_CD_COMMENT_LENGTH])
if self.debug > 2:
- print "total", total
+ print("total", total)
def namelist(self):
@@ -860,12 +867,14 @@ class ZipFile(object):
archive."""
return self.filelist
- def printdir(self):
+ def printdir(self, file=None):
"""Print a table of contents for the zip file."""
- print "%-46s %19s %12s" % ("File Name", "Modified ", "Size")
+ print("%-46s %19s %12s" % ("File Name", "Modified ", "Size"),
+ file=file)
for zinfo in self.filelist:
date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6]
- print "%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size)
+ print("%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size),
+ file=file)
def testzip(self):
"""Read all the files and check the CRC."""
@@ -877,7 +886,7 @@ class ZipFile(object):
with self.open(zinfo.filename, "r") as f:
while f.read(chunk_size): # Check CRC-32
pass
- except BadZipfile:
+ except BadZipFile:
return zinfo.filename
def getinfo(self, name):
@@ -891,7 +900,12 @@ class ZipFile(object):
def setpassword(self, pwd):
"""Set default password for encrypted files."""
- self.pwd = pwd
+ if pwd and not isinstance(pwd, bytes):
+ raise TypeError("pwd: expected bytes, got %s" % type(pwd))
+ if pwd:
+ self.pwd = pwd
+ else:
+ self.pwd = None
@property
def comment(self):
@@ -900,6 +914,8 @@ class ZipFile(object):
@comment.setter
def comment(self, comment):
+ if not isinstance(comment, bytes):
+ raise TypeError("comment: expected bytes, got %s" % type(comment))
# check for valid comment length
if len(comment) >= ZIP_MAX_COMMENT:
if self.debug:
@@ -911,24 +927,25 @@ class ZipFile(object):
def read(self, name, pwd=None):
"""Return file bytes (as a string) for name."""
- return self.open(name, "r", pwd).read()
+ with self.open(name, "r", pwd) as fp:
+ return fp.read()
def open(self, name, mode="r", pwd=None):
"""Return file-like object for 'name'."""
if mode not in ("r", "U", "rU"):
- raise RuntimeError, 'open() requires mode "r", "U", or "rU"'
+ raise RuntimeError('open() requires mode "r", "U", or "rU"')
+ if pwd and not isinstance(pwd, bytes):
+ raise TypeError("pwd: expected bytes, got %s" % type(pwd))
if not self.fp:
- raise RuntimeError, \
- "Attempt to read ZIP archive that was already closed"
+ raise RuntimeError(
+ "Attempt to read ZIP archive that was already closed")
# Only open a new file for instances where we were not
# given a file object in the constructor
if self._filePassed:
zef_file = self.fp
- should_close = False
else:
- zef_file = open(self.filename, 'rb')
- should_close = True
+ zef_file = io.open(self.filename, 'rb')
try:
# Make sure we have an info object
@@ -938,23 +955,28 @@ class ZipFile(object):
else:
# Get info object for name
zinfo = self.getinfo(name)
-
zef_file.seek(zinfo.header_offset, 0)
# Skip the file header:
fheader = zef_file.read(sizeFileHeader)
if fheader[0:4] != stringFileHeader:
- raise BadZipfile, "Bad magic number for file header"
+ raise BadZipFile("Bad magic number for file header")
fheader = struct.unpack(structFileHeader, fheader)
fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
if fheader[_FH_EXTRA_FIELD_LENGTH]:
zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
- if fname != zinfo.orig_filename:
- raise BadZipfile, \
- 'File name in directory "%s" and header "%s" differ.' % (
- zinfo.orig_filename, fname)
+ if zinfo.flag_bits & 0x800:
+ # UTF-8 filename
+ fname_str = fname.decode("utf-8")
+ else:
+ fname_str = fname.decode("cp437")
+
+ if fname_str != zinfo.orig_filename:
+ raise BadZipFile(
+ 'File name in directory %r and header %r differ.'
+ % (zinfo.orig_filename, fname))
# check for encrypted flag & handle password
is_encrypted = zinfo.flag_bits & 0x1
@@ -963,8 +985,8 @@ class ZipFile(object):
if not pwd:
pwd = self.pwd
if not pwd:
- raise RuntimeError, "File %s is encrypted, " \
- "password required for extraction" % name
+ raise RuntimeError("File %s is encrypted, password "
+ "required for extraction" % name)
zd = _ZipDecrypter(pwd)
# The first 12 bytes in the cypher stream is an encryption header
@@ -972,21 +994,21 @@ class ZipFile(object):
# completely random, while the 12th contains the MSB of the CRC,
# or the MSB of the file time depending on the header type
# and is used to check the correctness of the password.
- bytes = zef_file.read(12)
- h = map(zd, bytes[0:12])
+ header = zef_file.read(12)
+ h = list(map(zd, header[0:12]))
if zinfo.flag_bits & 0x8:
# compare against the file type from extended local headers
check_byte = (zinfo._raw_time >> 8) & 0xff
else:
# compare against the CRC otherwise
check_byte = (zinfo.CRC >> 24) & 0xff
- if ord(h[11]) != check_byte:
+ if h[11] != check_byte:
raise RuntimeError("Bad password for file", name)
return ZipExtFile(zef_file, mode, zinfo, zd,
- close_fileobj=should_close)
+ close_fileobj=not self._filePassed)
except:
- if should_close:
+ if not self._filePassed:
zef_file.close()
raise
@@ -1046,7 +1068,7 @@ class ZipFile(object):
return targetpath
with self.open(member, pwd=pwd) as source, \
- file(targetpath, "wb") as target:
+ open(targetpath, "wb") as target:
shutil.copyfileobj(source, target)
return targetpath
@@ -1055,24 +1077,24 @@ class ZipFile(object):
"""Check for errors before writing a file to the archive."""
if zinfo.filename in self.NameToInfo:
if self.debug: # Warning for duplicate names
- print "Duplicate name:", zinfo.filename
+ print("Duplicate name:", zinfo.filename)
if self.mode not in ("w", "a"):
- raise RuntimeError, 'write() requires mode "w" or "a"'
+ raise RuntimeError('write() requires mode "w" or "a"')
if not self.fp:
- raise RuntimeError, \
- "Attempt to write ZIP archive that was already closed"
+ raise RuntimeError(
+ "Attempt to write ZIP archive that was already closed")
if zinfo.compress_type == ZIP_DEFLATED and not zlib:
- raise RuntimeError, \
- "Compression requires the (missing) zlib module"
+ raise RuntimeError(
+ "Compression requires the (missing) zlib module")
if zinfo.compress_type not in (ZIP_STORED, ZIP_DEFLATED):
- raise RuntimeError, \
- "That compression method is not supported"
+ raise RuntimeError("That compression method is not supported")
if zinfo.file_size > ZIP64_LIMIT:
if not self._allowZip64:
raise LargeZipFile("Filesize would require ZIP64 extensions")
if zinfo.header_offset > ZIP64_LIMIT:
if not self._allowZip64:
- raise LargeZipFile("Zipfile size would require ZIP64 extensions")
+ raise LargeZipFile(
+ "Zipfile size would require ZIP64 extensions")
def write(self, filename, arcname=None, compress_type=None):
"""Put the bytes from filename into the archive under the name
@@ -1094,7 +1116,7 @@ class ZipFile(object):
if isdir:
arcname += '/'
zinfo = ZipInfo(arcname, date_time)
- zinfo.external_attr = (st[0] & 0xFFFF) << 16L # Unix attributes
+ zinfo.external_attr = (st[0] & 0xFFFF) << 16 # Unix attributes
if compress_type is None:
zinfo.compress_type = self.compression
else:
@@ -1155,16 +1177,19 @@ class ZipFile(object):
self.filelist.append(zinfo)
self.NameToInfo[zinfo.filename] = zinfo
- def writestr(self, zinfo_or_arcname, bytes, compress_type=None):
- """Write a file into the archive. The contents is the string
- 'bytes'. 'zinfo_or_arcname' is either a ZipInfo instance or
+ def writestr(self, zinfo_or_arcname, data, compress_type=None):
+ """Write a file into the archive. The contents is 'data', which
+ may be either a 'str' or a 'bytes' instance; if it is a 'str',
+ it is encoded as UTF-8 first.
+ 'zinfo_or_arcname' is either a ZipInfo instance or
the name of the file in the archive."""
+ if isinstance(data, str):
+ data = data.encode("utf-8")
if not isinstance(zinfo_or_arcname, ZipInfo):
zinfo = ZipInfo(filename=zinfo_or_arcname,
date_time=time.localtime(time.time())[:6])
-
zinfo.compress_type = self.compression
- zinfo.external_attr = 0600 << 16
+ zinfo.external_attr = 0o600 << 16
else:
zinfo = zinfo_or_arcname
@@ -1172,24 +1197,24 @@ class ZipFile(object):
raise RuntimeError(
"Attempt to write to ZIP archive that was already closed")
+ zinfo.file_size = len(data) # Uncompressed size
+ zinfo.header_offset = self.fp.tell() # Start of header data
if compress_type is not None:
zinfo.compress_type = compress_type
- zinfo.file_size = len(bytes) # Uncompressed size
- zinfo.header_offset = self.fp.tell() # Start of header bytes
self._writecheck(zinfo)
self._didModify = True
- zinfo.CRC = crc32(bytes) & 0xffffffff # CRC-32 checksum
+ zinfo.CRC = crc32(data) & 0xffffffff # CRC-32 checksum
if zinfo.compress_type == ZIP_DEFLATED:
co = zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION,
zlib.DEFLATED, -15)
- bytes = co.compress(bytes) + co.flush()
- zinfo.compress_size = len(bytes) # Compressed size
+ data = co.compress(data) + co.flush()
+ zinfo.compress_size = len(data) # Compressed size
else:
zinfo.compress_size = zinfo.file_size
- zinfo.header_offset = self.fp.tell() # Start of header bytes
+ zinfo.header_offset = self.fp.tell() # Start of header data
self.fp.write(zinfo.FileHeader())
- self.fp.write(bytes)
+ self.fp.write(data)
self.fp.flush()
if zinfo.flag_bits & 0x08:
# Write CRC and file sizes after the file data
@@ -1230,7 +1255,7 @@ class ZipFile(object):
if zinfo.header_offset > ZIP64_LIMIT:
extra.append(zinfo.header_offset)
- header_offset = 0xffffffffL
+ header_offset = 0xffffffff
else:
header_offset = zinfo.header_offset
@@ -1250,22 +1275,21 @@ class ZipFile(object):
try:
filename, flag_bits = zinfo._encodeFilenameFlags()
centdir = struct.pack(structCentralDir,
- stringCentralDir, create_version,
- zinfo.create_system, extract_version, zinfo.reserved,
- flag_bits, zinfo.compress_type, dostime, dosdate,
- zinfo.CRC, compress_size, file_size,
- len(filename), len(extra_data), len(zinfo.comment),
- 0, zinfo.internal_attr, zinfo.external_attr,
- header_offset)
+ stringCentralDir, create_version,
+ zinfo.create_system, extract_version, zinfo.reserved,
+ flag_bits, zinfo.compress_type, dostime, dosdate,
+ zinfo.CRC, compress_size, file_size,
+ len(filename), len(extra_data), len(zinfo.comment),
+ 0, zinfo.internal_attr, zinfo.external_attr,
+ header_offset)
except DeprecationWarning:
- print >>sys.stderr, (structCentralDir,
- stringCentralDir, create_version,
- zinfo.create_system, extract_version, zinfo.reserved,
- zinfo.flag_bits, zinfo.compress_type, dostime, dosdate,
- zinfo.CRC, compress_size, file_size,
- len(zinfo.filename), len(extra_data), len(zinfo.comment),
- 0, zinfo.internal_attr, zinfo.external_attr,
- header_offset)
+ print((structCentralDir, stringCentralDir, create_version,
+ zinfo.create_system, extract_version, zinfo.reserved,
+ zinfo.flag_bits, zinfo.compress_type, dostime, dosdate,
+ zinfo.CRC, compress_size, file_size,
+ len(zinfo.filename), len(extra_data), len(zinfo.comment),
+ 0, zinfo.internal_attr, zinfo.external_attr,
+ header_offset), file=sys.stderr)
raise
self.fp.write(centdir)
self.fp.write(filename)
@@ -1311,7 +1335,13 @@ class ZipFile(object):
class PyZipFile(ZipFile):
"""Class to create ZIP archives with Python library files and packages."""
- def writepy(self, pathname, basename = ""):
+ def __init__(self, file, mode="r", compression=ZIP_STORED,
+ allowZip64=False, optimize=-1):
+ ZipFile.__init__(self, file, mode=mode, compression=compression,
+ allowZip64=allowZip64)
+ self._optimize = optimize
+
+ def writepy(self, pathname, basename=""):
"""Add all files from "pathname" to the ZIP archive.
If pathname is a package directory, search the directory and
@@ -1333,10 +1363,10 @@ class PyZipFile(ZipFile):
else:
basename = name
if self.debug:
- print "Adding package in", pathname, "as", basename
+ print("Adding package in", pathname, "as", basename)
fname, arcname = self._get_codename(initname[0:-3], basename)
if self.debug:
- print "Adding", arcname
+ print("Adding", arcname)
self.write(fname, arcname)
dirlist = os.listdir(pathname)
dirlist.remove("__init__.py")
@@ -1352,12 +1382,12 @@ class PyZipFile(ZipFile):
fname, arcname = self._get_codename(path[0:-3],
basename)
if self.debug:
- print "Adding", arcname
+ print("Adding", arcname)
self.write(fname, arcname)
else:
# This is NOT a package directory, add its files at top level
if self.debug:
- print "Adding files from directory", pathname
+ print("Adding files from directory", pathname)
for filename in os.listdir(pathname):
path = os.path.join(pathname, filename)
root, ext = os.path.splitext(filename)
@@ -1365,15 +1395,15 @@ class PyZipFile(ZipFile):
fname, arcname = self._get_codename(path[0:-3],
basename)
if self.debug:
- print "Adding", arcname
+ print("Adding", arcname)
self.write(fname, arcname)
else:
if pathname[-3:] != ".py":
- raise RuntimeError, \
- 'Files added with writepy() must end with ".py"'
+ raise RuntimeError(
+ 'Files added with writepy() must end with ".py"')
fname, arcname = self._get_codename(pathname[0:-3], basename)
if self.debug:
- print "Adding file", arcname
+ print("Adding file", arcname)
self.write(fname, arcname)
def _get_codename(self, pathname, basename):
@@ -1383,25 +1413,64 @@ class PyZipFile(ZipFile):
archive name, compiling if necessary. For example, given
/python/lib/string, return (/python/lib/string.pyc, string).
"""
- file_py = pathname + ".py"
- file_pyc = pathname + ".pyc"
- file_pyo = pathname + ".pyo"
- if os.path.isfile(file_pyo) and \
- os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime:
- fname = file_pyo # Use .pyo file
- elif not os.path.isfile(file_pyc) or \
- os.stat(file_pyc).st_mtime < os.stat(file_py).st_mtime:
+ def _compile(file, optimize=-1):
import py_compile
if self.debug:
- print "Compiling", file_py
+ print("Compiling", file)
try:
- py_compile.compile(file_py, file_pyc, None, True)
- except py_compile.PyCompileError,err:
- print err.msg
- fname = file_pyc
+ py_compile.compile(file, doraise=True, optimize=optimize)
+ except py_compile.PyCompileError as error:
+ print(err.msg)
+ return False
+ return True
+
+ file_py = pathname + ".py"
+ file_pyc = pathname + ".pyc"
+ file_pyo = pathname + ".pyo"
+ pycache_pyc = imp.cache_from_source(file_py, True)
+ pycache_pyo = imp.cache_from_source(file_py, False)
+ if self._optimize == -1:
+ # legacy mode: use whatever file is present
+ if (os.path.isfile(file_pyo) and
+ os.stat(file_pyo).st_mtime >= os.stat(file_py).st_mtime):
+ # Use .pyo file.
+ arcname = fname = file_pyo
+ elif (os.path.isfile(file_pyc) and
+ os.stat(file_pyc).st_mtime >= os.stat(file_py).st_mtime):
+ # Use .pyc file.
+ arcname = fname = file_pyc
+ elif (os.path.isfile(pycache_pyc) and
+ os.stat(pycache_pyc).st_mtime >= os.stat(file_py).st_mtime):
+ # Use the __pycache__/*.pyc file, but write it to the legacy pyc
+ # file name in the archive.
+ fname = pycache_pyc
+ arcname = file_pyc
+ elif (os.path.isfile(pycache_pyo) and
+ os.stat(pycache_pyo).st_mtime >= os.stat(file_py).st_mtime):
+ # Use the __pycache__/*.pyo file, but write it to the legacy pyo
+ # file name in the archive.
+ fname = pycache_pyo
+ arcname = file_pyo
+ else:
+ # Compile py into PEP 3147 pyc file.
+ if _compile(file_py):
+ fname = (pycache_pyc if __debug__ else pycache_pyo)
+ arcname = (file_pyc if __debug__ else file_pyo)
+ else:
+ fname = arcname = file_py
else:
- fname = file_pyc
- archivename = os.path.split(fname)[1]
+ # new mode: use given optimization level
+ if self._optimize == 0:
+ fname = pycache_pyc
+ arcname = file_pyc
+ else:
+ fname = pycache_pyo
+ arcname = file_pyo
+ if not (os.path.isfile(fname) and
+ os.stat(fname).st_mtime >= os.stat(file_py).st_mtime):
+ if not _compile(file_py, optimize=self._optimize):
+ fname = arcname = file_py
+ archivename = os.path.split(arcname)[1]
if basename:
archivename = "%s/%s" % (basename, archivename)
return (fname, archivename)
@@ -1420,29 +1489,29 @@ def main(args = None):
args = sys.argv[1:]
if not args or args[0] not in ('-l', '-c', '-e', '-t'):
- print USAGE
+ print(USAGE)
sys.exit(1)
if args[0] == '-l':
if len(args) != 2:
- print USAGE
+ print(USAGE)
sys.exit(1)
with ZipFile(args[1], 'r') as zf:
zf.printdir()
elif args[0] == '-t':
if len(args) != 2:
- print USAGE
+ print(USAGE)
sys.exit(1)
with ZipFile(args[1], 'r') as zf:
badfile = zf.testzip()
if badfile:
print("The following enclosed file is corrupted: {!r}".format(badfile))
- print "Done testing"
+ print("Done testing")
elif args[0] == '-e':
if len(args) != 3:
- print USAGE
+ print(USAGE)
sys.exit(1)
with ZipFile(args[1], 'r') as zf:
@@ -1461,7 +1530,7 @@ def main(args = None):
elif args[0] == '-c':
if len(args) < 3:
- print USAGE
+ print(USAGE)
sys.exit(1)
def addToZip(zf, path, zippath):